mirror of
https://github.com/openclaw/openclaw.git
synced 2026-06-09 23:41:55 +08:00
Compare commits
9 Commits
ci-core-te
...
codex/ui-e
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
80ca2bf451 | ||
|
|
999cb095c4 | ||
|
|
e0668ee22d | ||
|
|
3288d97428 | ||
|
|
49319ca986 | ||
|
|
3b591566c6 | ||
|
|
eab40d89a1 | ||
|
|
8ef1415e94 | ||
|
|
c0a2798a03 |
4
.github/labeler.yml
vendored
4
.github/labeler.yml
vendored
@@ -297,10 +297,6 @@
|
||||
- changed-files:
|
||||
- any-glob-to-any-file:
|
||||
- "extensions/openai/**"
|
||||
"extensions: codex":
|
||||
- changed-files:
|
||||
- any-glob-to-any-file:
|
||||
- "extensions/codex/**"
|
||||
"extensions: kimi-coding":
|
||||
- changed-files:
|
||||
- any-glob-to-any-file:
|
||||
|
||||
128
.github/workflows/ci.yml
vendored
128
.github/workflows/ci.yml
vendored
@@ -37,10 +37,9 @@ jobs:
|
||||
run_build_artifacts: ${{ steps.manifest.outputs.run_build_artifacts }}
|
||||
run_checks_fast: ${{ steps.manifest.outputs.run_checks_fast }}
|
||||
checks_fast_core_matrix: ${{ steps.manifest.outputs.checks_fast_core_matrix }}
|
||||
checks_node_extensions_matrix: ${{ steps.manifest.outputs.checks_node_extensions_matrix }}
|
||||
checks_fast_extensions_matrix: ${{ steps.manifest.outputs.checks_fast_extensions_matrix }}
|
||||
run_checks: ${{ steps.manifest.outputs.run_checks }}
|
||||
checks_matrix: ${{ steps.manifest.outputs.checks_matrix }}
|
||||
checks_node_core_test_matrix: ${{ steps.manifest.outputs.checks_node_core_test_matrix }}
|
||||
run_extension_fast: ${{ steps.manifest.outputs.run_extension_fast }}
|
||||
extension_fast_matrix: ${{ steps.manifest.outputs.extension_fast_matrix }}
|
||||
run_check: ${{ steps.manifest.outputs.run_check }}
|
||||
@@ -136,9 +135,6 @@ jobs:
|
||||
run: |
|
||||
node --input-type=module <<'EOF'
|
||||
import { appendFileSync } from "node:fs";
|
||||
import {
|
||||
createNodeTestShards,
|
||||
} from "./scripts/lib/ci-node-test-plan.mjs";
|
||||
import {
|
||||
createExtensionTestShards,
|
||||
DEFAULT_EXTENSION_TEST_SHARD_COUNT,
|
||||
@@ -215,11 +211,12 @@ jobs:
|
||||
]
|
||||
: [],
|
||||
),
|
||||
checks_node_extensions_matrix: extensionShardMatrix,
|
||||
checks_fast_extensions_matrix: extensionShardMatrix,
|
||||
run_checks: runNode,
|
||||
checks_matrix: createMatrix(
|
||||
runNode
|
||||
? [
|
||||
{ check_name: "checks-node-test", runtime: "node", task: "test" },
|
||||
{ check_name: "checks-node-channels", runtime: "node", task: "channels" },
|
||||
...(isPush
|
||||
? [
|
||||
@@ -235,17 +232,6 @@ jobs:
|
||||
]
|
||||
: [],
|
||||
),
|
||||
checks_node_core_test_matrix: createMatrix(
|
||||
runNode
|
||||
? createNodeTestShards().map((shard) => ({
|
||||
check_name: shard.checkName,
|
||||
runtime: "node",
|
||||
task: "test-shard",
|
||||
shard_name: shard.shardName,
|
||||
configs: shard.configs,
|
||||
}))
|
||||
: [],
|
||||
),
|
||||
run_extension_fast: hasChangedExtensions,
|
||||
extension_fast_matrix: createMatrix(
|
||||
hasChangedExtensions
|
||||
@@ -484,7 +470,7 @@ jobs:
|
||||
;;
|
||||
esac
|
||||
|
||||
checks-node-extensions-shard:
|
||||
checks-fast-extensions-shard:
|
||||
name: ${{ matrix.check_name }}
|
||||
needs: [preflight]
|
||||
if: needs.preflight.outputs.run_checks_fast == 'true'
|
||||
@@ -492,7 +478,7 @@ jobs:
|
||||
timeout-minutes: 60
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix: ${{ fromJson(needs.preflight.outputs.checks_node_extensions_matrix) }}
|
||||
matrix: ${{ fromJson(needs.preflight.outputs.checks_fast_extensions_matrix) }}
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v6
|
||||
@@ -511,16 +497,16 @@ jobs:
|
||||
OPENCLAW_EXTENSION_BATCH: ${{ matrix.extensions_csv }}
|
||||
run: pnpm test:extensions:batch -- "$OPENCLAW_EXTENSION_BATCH"
|
||||
|
||||
checks-node-extensions:
|
||||
name: checks-node-extensions
|
||||
needs: [preflight, checks-node-extensions-shard]
|
||||
checks-fast-extensions:
|
||||
name: checks-fast-extensions
|
||||
needs: [preflight, checks-fast-extensions-shard]
|
||||
if: always() && needs.preflight.outputs.run_checks_fast == 'true'
|
||||
runs-on: blacksmith-16vcpu-ubuntu-2404
|
||||
timeout-minutes: 5
|
||||
steps:
|
||||
- name: Verify extension shards
|
||||
env:
|
||||
SHARD_RESULT: ${{ needs.checks-node-extensions-shard.result }}
|
||||
SHARD_RESULT: ${{ needs.checks-fast-extensions-shard.result }}
|
||||
run: |
|
||||
if [ "$SHARD_RESULT" != "success" ]; then
|
||||
echo "Extension shard checks failed: $SHARD_RESULT" >&2
|
||||
@@ -613,102 +599,6 @@ jobs:
|
||||
;;
|
||||
esac
|
||||
|
||||
checks-node-core-test-shard:
|
||||
name: ${{ matrix.check_name }}
|
||||
needs: [preflight, build-artifacts]
|
||||
if: always() && needs.preflight.outputs.run_checks == 'true' && needs.build-artifacts.result == 'success'
|
||||
runs-on: blacksmith-16vcpu-ubuntu-2404
|
||||
timeout-minutes: 60
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix: ${{ fromJson(needs.preflight.outputs.checks_node_core_test_matrix) }}
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v6
|
||||
with:
|
||||
persist-credentials: false
|
||||
submodules: false
|
||||
|
||||
- name: Setup Node environment
|
||||
uses: ./.github/actions/setup-node-env
|
||||
with:
|
||||
node-version: "${{ matrix.node_version || '24.x' }}"
|
||||
cache-key-suffix: "${{ matrix.cache_key_suffix || 'node24' }}"
|
||||
install-bun: "false"
|
||||
use-sticky-disk: "false"
|
||||
|
||||
- name: Configure Node test resources
|
||||
run: echo "OPENCLAW_VITEST_MAX_WORKERS=2" >> "$GITHUB_ENV"
|
||||
|
||||
- name: Download dist artifact
|
||||
uses: actions/download-artifact@v8
|
||||
with:
|
||||
name: dist-build
|
||||
path: dist/
|
||||
|
||||
- name: Download A2UI bundle artifact
|
||||
uses: actions/download-artifact@v8
|
||||
with:
|
||||
name: canvas-a2ui-bundle
|
||||
path: src/canvas-host/a2ui/
|
||||
|
||||
- name: Run Node test shard
|
||||
env:
|
||||
NODE_OPTIONS: --max-old-space-size=6144
|
||||
OPENCLAW_NODE_TEST_CONFIGS_JSON: ${{ toJson(matrix.configs) }}
|
||||
shell: bash
|
||||
run: |
|
||||
set -euo pipefail
|
||||
node --input-type=module <<'EOF'
|
||||
import { spawnSync } from "node:child_process";
|
||||
import { resolveVitestCliEntry, resolveVitestNodeArgs } from "./scripts/run-vitest.mjs";
|
||||
|
||||
const configs = JSON.parse(process.env.OPENCLAW_NODE_TEST_CONFIGS_JSON ?? "[]");
|
||||
if (!Array.isArray(configs) || configs.length === 0) {
|
||||
console.error("Missing node test shard configs");
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
for (const config of configs) {
|
||||
console.error(`[test] starting ${config}`);
|
||||
const result = spawnSync(
|
||||
"pnpm",
|
||||
[
|
||||
"exec",
|
||||
"node",
|
||||
...resolveVitestNodeArgs(process.env),
|
||||
resolveVitestCliEntry(),
|
||||
"run",
|
||||
"--config",
|
||||
config,
|
||||
],
|
||||
{
|
||||
env: process.env,
|
||||
stdio: "inherit",
|
||||
},
|
||||
);
|
||||
if ((result.status ?? 1) !== 0) {
|
||||
process.exit(result.status ?? 1);
|
||||
}
|
||||
}
|
||||
EOF
|
||||
|
||||
checks-node-core-test:
|
||||
name: checks-node-core-test
|
||||
needs: [preflight, checks-node-core-test-shard]
|
||||
if: always() && needs.preflight.outputs.run_checks == 'true'
|
||||
runs-on: blacksmith-16vcpu-ubuntu-2404
|
||||
timeout-minutes: 5
|
||||
steps:
|
||||
- name: Verify node test shards
|
||||
env:
|
||||
SHARD_RESULT: ${{ needs.checks-node-core-test-shard.result }}
|
||||
run: |
|
||||
if [ "$SHARD_RESULT" != "success" ]; then
|
||||
echo "Node test shards failed: $SHARD_RESULT" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
extension-fast:
|
||||
name: "extension-fast"
|
||||
needs: [preflight]
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
{
|
||||
"$schema": "./node_modules/oxfmt/configuration_schema.json",
|
||||
"sortImports": {
|
||||
"experimentalSortImports": {
|
||||
"newlinesBetween": false,
|
||||
},
|
||||
"sortPackageJson": {
|
||||
"experimentalSortPackageJson": {
|
||||
"sortScripts": true,
|
||||
},
|
||||
"tabWidth": 2,
|
||||
|
||||
@@ -13,17 +13,13 @@
|
||||
"eslint/no-new": "off",
|
||||
"eslint/no-shadow": "off",
|
||||
"eslint/no-unmodified-loop-condition": "off",
|
||||
"eslint-plugin-unicorn/prefer-set-size": "off",
|
||||
"oxc/no-accumulating-spread": "off",
|
||||
"oxc/no-async-endpoint-handlers": "off",
|
||||
"oxc/no-map-spread": "off",
|
||||
"typescript/consistent-return": "error",
|
||||
"typescript/no-explicit-any": "error",
|
||||
"typescript/no-extraneous-class": "off",
|
||||
"typescript/no-unnecessary-type-conversion": "off",
|
||||
"typescript/no-unsafe-type-assertion": "off",
|
||||
"unicorn/consistent-function-scoping": "off",
|
||||
"unicorn/prefer-set-size": "off",
|
||||
"unicorn/require-post-message-target-origin": "off"
|
||||
},
|
||||
"ignorePatterns": [
|
||||
@@ -58,7 +54,13 @@
|
||||
"**/*test-support.ts"
|
||||
],
|
||||
"rules": {
|
||||
"typescript/await-thenable": "off",
|
||||
"typescript/no-base-to-string": "off",
|
||||
"typescript/no-explicit-any": "off",
|
||||
"typescript/no-floating-promises": "off",
|
||||
"typescript/no-misused-spread": "off",
|
||||
"typescript/no-redundant-type-constituents": "off",
|
||||
"typescript/no-unnecessary-template-expression": "off",
|
||||
"typescript/unbound-method": "off",
|
||||
"eslint/no-unsafe-optional-chaining": "off"
|
||||
}
|
||||
|
||||
@@ -73,8 +73,6 @@
|
||||
- Extension test boundary:
|
||||
- Keep extension-owned onboarding/config/provider coverage under the owning bundled plugin package when feasible.
|
||||
- If core tests need bundled plugin behavior, consume it through public `src/plugin-sdk/<id>.ts` facades or the plugin's `api.ts`, not private extension modules.
|
||||
- Shared helpers under `test/helpers/**` are part of that same boundary. Do not hardcode repo-relative `extensions/**` imports there, and do not keep plugin-local deep mocks in shared helpers just because multiple tests use them.
|
||||
- When core tests or shared helpers need bundled plugin public surfaces, use `src/test-utils/bundled-plugin-public-surface.ts` for `api.ts`, `runtime-api.ts`, `contract-api.ts`, `test-api.ts`, plugin entrypoint `index.js`, and resolved module ids for dynamic import or mocking.
|
||||
- If a core test is asserting extension-specific behavior instead of a generic contract, move it to the owning extension package.
|
||||
|
||||
## Docs Linking (Mintlify)
|
||||
@@ -151,7 +149,6 @@
|
||||
- Config schema drift uses `pnpm config:docs:gen` / `pnpm config:docs:check`.
|
||||
- Plugin SDK API drift uses `pnpm plugin-sdk:api:gen` / `pnpm plugin-sdk:api:check`.
|
||||
- If you change config schema/help or the public Plugin SDK surface, run the matching gen command and commit the updated `.sha256` hash file. Keep the two drift-check flows adjacent in scripts/workflows/docs guidance rather than inventing a third pattern.
|
||||
- When `pnpm tsgo` fails, triage by coherent surface instead of by raw error count: rerun the gate, group failures by package/module/type contract, open the source-of-truth type or export file first, fix the root mismatch, then rerun `pnpm tsgo` before widening into downstream consumers. Check `origin/main` before doing broad cleanup because some apparent type debt is already fixed upstream.
|
||||
- For narrowly scoped changes, prefer narrowly scoped tests that directly validate the touched behavior. If no meaningful scoped test exists, say so explicitly and use the next most direct validation available.
|
||||
- Verification modes for work on `main`:
|
||||
- Default mode: `main` is relatively stable. Count pre-commit hook coverage when it already verified the current tree, avoid rerunning the exact same checks just for ceremony, and prefer keeping CI/main green before landing.
|
||||
@@ -299,7 +296,7 @@
|
||||
|
||||
- When working on a GitHub Issue or PR, print the full URL at the end of the task.
|
||||
- When answering questions, respond with high-confidence answers only: verify in code; do not guess.
|
||||
- Carbon version edits are owner-only: do not change `@buape/carbon` version pins unless you are Shadow (@thewilloftheshadow) as verified by gh.
|
||||
- Carbon: prefer latest published beta over stable when possible; do not switch to stable casually.
|
||||
- Any dependency with `pnpm.patchedDependencies` must use an exact version (no `^`/`~`).
|
||||
- Patching dependencies (pnpm patches, overrides, or vendored changes) requires explicit approval; do not do this by default.
|
||||
- **Multi-agent safety:** do **not** create/apply/drop `git stash` entries unless explicitly requested (this includes `git pull --rebase --autostash`). Assume other agents may be working; keep unrelated WIP untouched and avoid cross-cutting state changes.
|
||||
|
||||
161
CHANGELOG.md
161
CHANGELOG.md
@@ -6,149 +6,67 @@ Docs: https://docs.openclaw.ai
|
||||
|
||||
### Changes
|
||||
|
||||
- Memory/Active Memory: add a new optional Active Memory plugin that gives OpenClaw a dedicated memory sub-agent right before the main reply, so ongoing chats can automatically pull in relevant preferences, context, and past details without making users remember to manually say "remember this" or "search memory" first. Includes configurable message/recent/full context modes, live `/verbose` inspection, advanced prompt/thinking overrides for tuning, and opt-in transcript persistence for debugging. Docs: https://docs.openclaw.ai/concepts/active-memory. (#63286) Thanks @Takhoffman.
|
||||
- Memory/Active Memory: add a new optional Active Memory plugin that gives OpenClaw a dedicated memory sub-agent right before the main reply, so ongoing chats can automatically pull in relevant preferences, context, and past details without making users remember to manually say "remember this" or "search memory" first. Includes configurable message/recent/full context modes, live `/verbose` inspection, advanced prompt/thinking overrides for tuning, and opt-in transcript persistence for debugging.
|
||||
- macOS/Talk: add an experimental local MLX speech provider for Talk Mode, with explicit provider selection, local utterance playback, interruption handling, and system-voice fallback. (#63539) Thanks @ImLukeF.
|
||||
- CLI/exec policy: add a local `openclaw exec-policy` command with `show`, `preset`, and `set` subcommands for synchronizing requested `tools.exec.*` config with the local exec approvals file, plus follow-up hardening for node-host rejection, rollback safety, and sync conflict detection. (#64050)
|
||||
- Gateway: add a `commands.list` RPC so remote gateway clients can discover runtime-native, text, skill, and plugin commands with surface-aware naming and serialized argument metadata. (#62656) Thanks @samzong.
|
||||
- Models/providers: add per-provider `models.providers.*.request.allowPrivateNetwork` for trusted self-hosted OpenAI-compatible endpoints, keep the opt-in scoped to model request surfaces, and refresh cached WebSocket managers when request transport overrides change. (#63671) Thanks @qas.
|
||||
- QA/testing: add a `--runner multipass` lane for `openclaw qa suite` so repo-backed QA scenarios can run inside a disposable Linux VM and write back the usual report, summary, and VM logs. (#63426) Thanks @shakkernerd.
|
||||
- Docs i18n: chunk raw doc translation, reject truncated tagged outputs, avoid ambiguous body-only wrapper unwrapping, and recover from terminated Pi translation sessions without changing the default `openai/gpt-5.4` path. (#62969, #63808) Thanks @hxy91819.
|
||||
- Control UI/dreaming: simplify the Scene and Diary surfaces, preserve unknown phase state for partial status payloads, and stabilize waiting-entry recency ordering so Dreaming status and review lists stay clear and deterministic. (#64035) Thanks @davemorin.
|
||||
- QA/testing: add a `--runner multipass` lane for `openclaw qa suite` so repo-backed QA scenarios can run inside a disposable Linux VM and write back the usual report, summary, and VM logs. (#63426) Thanks @shakkernerd.
|
||||
- Gateway: split startup and runtime seams so gateway lifecycle sequencing, reload state, and shutdown behavior stay easier to maintain without changing observed behavior. (#63975) Thanks @gumadeiras.
|
||||
- Matrix/partial streaming: add MSC4357 live markers to draft preview sends and edits so supporting Matrix clients can render a live/typewriter animation and stop it when the final edit lands. (#63513) Thanks @TigerInYourDream.
|
||||
- QA/Telegram: add a live `openclaw qa telegram` lane for private-group bot-to-bot checks, harden its artifact handling, and preserve native Telegram command reply threading for QA verification. (#64303) Thanks @obviyus.
|
||||
- Models/Codex: add the bundled Codex provider and plugin-owned app-server harness so `codex/gpt-*` models use Codex-managed auth, native threads, model discovery, and compaction while `openai/gpt-*` stays on the normal OpenAI provider path. (#64298) Thanks @steipete.
|
||||
- Agents: add an opt-in strict-agentic embedded Pi execution contract for GPT-5-family runs so plan-only or filler turns keep acting until they hit a real blocker. (#64241) Thanks @100yenadmin.
|
||||
- Control UI/webchat: normalize assistant `MEDIA:`/reply/voice directives into structured bubble rendering, rename the unreleased rich web shortcode to `[embed ...]`, and surface session runtime roots so hosted web content is written to the correct document path instead of guessed local files.
|
||||
|
||||
### Fixes
|
||||
|
||||
- CLI/WhatsApp media sends: route gateway-mode outbound sends with `--media` through the channel `sendMedia` path and preserve media access context, so WhatsApp document and attachment sends stop silently dropping the file while still delivering the caption. (#64478) Thanks @ShionEria.
|
||||
- fix(nostr): require operator.admin scope for profile mutation routes [AI]. (#63553) Thanks @pgondhi987.
|
||||
- Gateway/startup: keep WebSocket RPC available while channels and plugin sidecars start, hold `chat.history` unavailable until startup sidecars finish so synchronous history reads cannot stall startup (reported in #63450), refresh advertised gateway methods after deferred plugin reloads, and enforce the pre-auth WebSocket upgrade budget before the no-handler 503 path so upgrade floods cannot bypass connection limits during that window. (#63480) Thanks @neeravmakwana.
|
||||
- Gateway/tailscale: start Tailscale exposure and the gateway update check before awaiting channel and plugin sidecar startup so remote operators are not locked out when startup sidecars stall.
|
||||
- WhatsApp: keep inbound replies, media, composing indicators, and queued outbound deliveries attached to the current socket across reconnect gaps, including fresh retry-eligible sends after the listener comes back. (#30806, #46299, #62892, #63916) Thanks @mcaxtr.
|
||||
- Microsoft Teams: restore media downloads for personal DMs, Bot Framework `a:` conversations, OneDrive/SharePoint shared files, and Graph-backed chat IDs; accept Bot Framework audience tokens; and deliver cron announcements to Teams conversation IDs. (#55383, #58001, #58249, #62219, #62674, #63063, #63942, #63951, #63953) Thanks @obviyus.
|
||||
- Gateway/thread routing: preserve Slack, Telegram, Mattermost, and ACP parent-thread delivery targets so subagent, cron, and stream-relay completion messages land back in the originating thread or topic. (#54840, #57056, #63228, #63506) Thanks @yzzymt.
|
||||
- Agents/timeouts: extend the default LLM idle window to 120s and keep silent no-token idle timeouts on recovery paths, so slow models can retry or fall back before users see an error.
|
||||
- Gateway/agents: preserve configured model selection and richer `IDENTITY.md` content across agent create/update flows and workspace moves, and fail safely instead of silently overwriting unreadable identity files. (#61577) Thanks @samzong.
|
||||
- Skills/TaskFlow: restore valid frontmatter fences for the bundled `taskflow` and `taskflow-inbox-triage` skills so they stay discoverable and loadable after updates. (#64469) Thanks @extrasmall0.
|
||||
- Windows/exec: settle supervisor waits from child exit state after stdout and stderr drain even when `close` never arrives, so CLI commands stop hanging or dying with forced `SIGKILL` on Windows. (#64072) Thanks @obviyus.
|
||||
- Browser/sandbox: prevent sandbox browser CDP startup hangs by recreating containers when the browser security hash changes and by waiting on the correct sandbox browser lifecycle. (#62873) Thanks @Syysean.
|
||||
- fix(agents): guard nodes tool outPath against workspace boundary [AI-assisted]. (#63551) Thanks @pgondhi987.
|
||||
- fix(qqbot): enforce media storage boundary for all outbound local file paths [AI]. (#63271) Thanks @pgondhi987.
|
||||
- iMessage/self-chat: distinguish normal DM outbound rows from true self-chat using `destination_caller_id` plus chat participants, while preserving multi-handle self-chat aliases so outbound DM replies stop looping back as inbound messages. (#61619) Thanks @neeravmakwana.
|
||||
- fix(browser): auto-generate browser control auth token for none/trusted-proxy modes [AI]. (#63280) Thanks @pgondhi987.
|
||||
- fix(exec): replace TOCTOU check-then-read with atomic pinned-fd open in script preflight [AI]. (#62333) Thanks @pgondhi987.
|
||||
- WhatsApp/auto-reply: keep inbound reply, media, and composing sends on the current socket across reconnects, wait through reconnect gaps, and retry timeout-only send failures without dropping the active socket ref. (#62892) Thanks @mcaxtr.
|
||||
- Config/plugins: let config writes keep disabled plugin entries without forcing required plugin config schemas or crashing raw plugin validation, so slot switches and similar plugin-state updates persist cleanly. (#63296) Thanks @fuller-stack-dev.
|
||||
- WhatsApp/outbound queue: drain queued WhatsApp deliveries when the listener reconnects without dropping reconnect-delayed sends after a special TTL or rewriting retry history, so disconnect-window outbound messages can recover once the channel is ready again. (#46299) Thanks @manuel-claw.
|
||||
- Tools/web_fetch: add an opt-in `tools.web.fetch.ssrfPolicy.allowRfc2544BenchmarkRange` config so fake-IP proxy environments that resolve public sites into `198.18.0.0/15` can use `web_fetch` without weakening the default SSRF block. (#61830) Thanks @xing-xing-coder.
|
||||
- Daemon/gateway install: preserve safe custom service env vars on forced reinstall, merge prior custom PATH segments behind the managed service PATH, and stop removed managed env keys from persisting as custom carryover. (#63136) Thanks @WarrenJones.
|
||||
- Config validation: surface the actual offending field for strict-schema union failures in bindings, including top-level unexpected keys on the matching ACP branch. (#40841) Thanks @Hollychou924.
|
||||
- QQBot/security: replace raw `fetch()` in the image-size probe with SSRF-guarded `fetchRemoteMedia`, fix `resolveRepoRoot()` to walk up to `.git` instead of hardcoding two parent levels, and refresh the raw-fetch allowlist to match the corrected scan. (#63495) Thanks @dims.
|
||||
- Cron/scheduling: treat `nextRunAtMs <= 0` as invalid across cron update, maintenance, timer, and stale-delivery paths so corrupted zero timestamps self-heal instead of causing immediate runs or skipped deliveries. (#63507) Thanks @WarrenJones.
|
||||
- Status: show configured fallback models in `/status` and shared session status cards so per-agent fallback configuration is visible before a live failover happens. (#33111) Thanks @AnCoSONG.
|
||||
- Fireworks/FirePass: disable Kimi K2.5 Turbo reasoning output by forcing thinking off on the FirePass path and hardening the provider wrapper so hidden reasoning no longer leaks into visible replies. (#63607) Thanks @frankekn.
|
||||
- Sessions/model selection: preserve catalog-backed session model labels and keep already-qualified session model refs stable when catalog metadata is unavailable, so Control UI model selection survives reloads without bogus provider-prefixed values. (#61382) Thanks @Mule-ME.
|
||||
- Gateway/startup: keep WebSocket RPC available while channels and plugin sidecars start, hold `chat.history` unavailable until startup sidecars finish so synchronous history reads cannot stall startup (reported in #63450), refresh advertised gateway methods after deferred plugin reloads, and enforce the pre-auth WebSocket upgrade budget before the no-handler 503 path so upgrade floods cannot bypass connection limits during that window. (#63480) Thanks @neeravmakwana.
|
||||
- Dreaming/cron: reconcile managed dreaming cron from the resolved gateway startup config so boot-time schedule recovery respects the configured cadence and timezone. (#63873) Thanks @mbelinky.
|
||||
- Dreaming/cron: keep managed dreaming cron reconciled after startup by rechecking lifecycle state during runtime config/plugin changes, recovering missing managed jobs, and applying cadence/timezone updates idempotently. (#63929) Thanks @mbelinky.
|
||||
- Gateway/tailscale: start Tailscale exposure and the gateway update check before awaiting channel and plugin sidecar startup so remote operators are not locked out when startup sidecars stall.
|
||||
- QQBot/streaming: make block streaming configurable per QQ bot account via `streaming.mode` (`"partial"` | `"off"`, default `"partial"`) instead of hardcoding it off, so responses can be delivered incrementally. (#63746)
|
||||
- QQBot/config: allow extra fields in `channels.qqbot` and `channels.qqbot.accounts.*` so extended qqbot builds can add new config options without gateway startup failing on schema validation. (#64075) Thanks @WideLee.
|
||||
- Dreaming/gateway: require `operator.admin` for persistent `/dreaming on|off` changes and treat missing gateway client scopes as unprivileged instead of silently allowing config writes. (#63872) Thanks @mbelinky.
|
||||
- Matrix/multi-account: keep room-level `account` scoping, inherited room overrides, and implicit account selection consistent across top-level default auth, named accounts, and cached-credential env setups. (#58449) thanks @Daanvdplas and @gumadeiras.
|
||||
- Gateway/pairing: prefer explicit QR bootstrap auth over earlier Tailscale auth classification so iOS `/pair qr` silent bootstrap pairing does not fall through to `pairing required`. (#59232) Thanks @ngutman.
|
||||
- Browser/control: auto-generate browser-control auth tokens for `none` and `trusted-proxy` modes, and route browser auth/profile/doctor helpers through the public browser plugin facades. (#63280, #63957) Thanks @pgondhi987.
|
||||
- Browser/act: centralize `/act` request normalization and execution dispatch while adding stable machine-readable route-level error codes for invalid requests, selector misuse, evaluate-disabled gating, target mismatch, and existing-session unsupported actions. (#63977) Thanks @joshavant.
|
||||
- Security/exec: replace script-preflight check-then-read logic with an atomic pinned-file-descriptor open, and expand the host environment denylist for dangerous runtime-control variables. (#62333, #63277) Thanks @pgondhi987.
|
||||
- Security/nodes: keep `nodes` tool output paths inside the workspace boundary so model-driven node writes cannot escape the intended workspace. (#63551) Thanks @pgondhi987.
|
||||
- Security/QQBot: enforce media storage boundaries for all outbound local file paths and route image-size probes through SSRF-guarded media fetching instead of raw `fetch()`. (#63271, #63495) Thanks @pgondhi987.
|
||||
- Channel setup: ignore workspace plugin shadows when resolving trusted channel setup catalog entries so onboarding and setup flows keep using the bundled, trusted setup contract.
|
||||
- Gateway/memory startup: load the explicitly selected memory-slot plugin during gateway startup, while keeping restrictive allowlists and implicit default memory slots from auto-starting unrelated memory plugins. (#64423) Thanks @EronFan.
|
||||
- Config/plugins: let config writes keep disabled plugin entries without forcing required plugin config schemas or crashing raw plugin validation, and avoid re-activating plugin registry state during schema checks. (#54971, #63296) Thanks @fuller-stack-dev.
|
||||
- Config validation: surface the actual offending field for strict-schema union failures in bindings, including top-level unexpected keys on the matching ACP branch. (#40841) Thanks @Hollychou924.
|
||||
- Wizard/plugin config: coerce integer-typed plugin config fields from interactive text input so integer schema values persist as numbers instead of failing validation. (#63346) Thanks @jalehman.
|
||||
- Daemon/gateway install: preserve safe custom service env vars on forced reinstall, merge prior custom PATH segments behind the managed service PATH, and stop removed managed env keys from persisting as custom carryover. (#63136) Thanks @WarrenJones.
|
||||
- Cron/scheduling: treat `nextRunAtMs <= 0` as invalid across cron update, maintenance, timer, and stale-delivery paths so corrupted zero timestamps self-heal instead of causing immediate runs or skipped deliveries. (#63507) Thanks @WarrenJones.
|
||||
- Cron/auth: resolve auth profiles consistently for isolated cron jobs so scheduled runs use the same configured provider credentials as interactive sessions. (#62797) Thanks @neeravmakwana.
|
||||
- Tasks: let `openclaw tasks cancel` cancel stuck background tasks that never reached a normal terminal state. (#62506) Thanks @neeravmakwana.
|
||||
- Sessions/model selection: preserve catalog-backed session model labels, provider-qualified context limits, and already-qualified session model refs when catalog metadata is unavailable, so model selection and memory/context budgets survive reloads without bogus provider prefixes. (#61382, #62493) Thanks @Mule-ME.
|
||||
- Status: show configured fallback models in `/status` and shared session status cards so per-agent fallback configuration is visible before a live failover happens. (#33111) Thanks @AnCoSONG.
|
||||
- `/context detail` now compares the tracked prompt estimate with cached context usage and surfaces untracked provider/runtime overhead when present. (#28391) Thanks @ImLukeF.
|
||||
- Gateway/sessions: scope bare `sessions.create` aliases like `main` to the requested agent while preserving the canonical `global` and `unknown` sentinel keys. (#58207) Thanks @jalehman.
|
||||
- Gateway/session reset: emit the typed `before_reset` hook for gateway `/new` and `/reset`, preserving reset-hook behavior even when the previous transcript has already been archived. (#53872) Thanks @VACInc.
|
||||
- WhatsApp/outbound queue: drain same-account pending WhatsApp deliveries when the listener reconnects, including fresh queued sends that are already retry-eligible, so reconnects recover deliverable outbound messages without waiting for another gateway restart. (#63916) Thanks @mcaxtr.
|
||||
- Config/Discord: coerce safe integer numeric Discord IDs to strings during config validation, keep unsafe or precision-losing numeric snowflakes rejected, and align `openclaw doctor` repair guidance with the same fail-closed behavior. (#45125) Thanks @moliendocode.
|
||||
- Gateway/sessions: scope bare `sessions.create` aliases like `main` to the requested agent while preserving the canonical `global` and `unknown` sentinel keys. (#58207) thanks @jalehman.
|
||||
- `/context detail` now compares the tracked prompt estimate with cached context usage and surfaces untracked provider/runtime overhead when present. (#28391) thanks @ImLukeF.
|
||||
- Gateway/session reset: emit the typed `before_reset` hook for gateway `/new` and `/reset`, preserving reset-hook behavior even when the previous transcript has already been archived. (#53872) thanks @VACInc
|
||||
- Plugins/commands: pass the active host `sessionKey` into plugin command contexts, and include `sessionId` when it is already available from the active session entry, so bundled and third-party commands can resolve the current conversation reliably. (#59044) Thanks @jalehman.
|
||||
- Agents/auth: honor `models.providers.*.authHeader` for pi embedded runner model requests by injecting `Authorization: Bearer <apiKey>` when requested. (#54390) Thanks @lndyzwdxhs.
|
||||
- Claude CLI: clear inherited Anthropic auth/header environment aliases before spawning Claude Code and add sanitized CLI backend auth-env diagnostics for debugging gateway-run provider selection.
|
||||
- Agents/failover: classify AbortError and stream-abort messages as timeout so Ollama NDJSON stream aborts stop showing `reason=unknown` in model fallback logs. (#58324) Thanks @yelog.
|
||||
- Fireworks/FirePass: disable Kimi K2.5 Turbo reasoning output by forcing thinking off on the FirePass path and hardening the provider wrapper so hidden reasoning no longer leaks into visible replies. (#63607) Thanks @frankekn.
|
||||
- Matrix/multi-account: keep room-level `account` scoping, inherited room overrides, and implicit account selection consistent across top-level default auth, named accounts, and cached-credential env setups. (#58449) Thanks @gumadeiras.
|
||||
- Matrix/runtime: resolve the verification/bootstrap runtime from a distinct packaged Matrix entry so global npm installs stop failing on crypto bootstrap with missing-module or recursive runtime alias errors. (#59249) Thanks @gumadeiras.
|
||||
- Matrix/streaming: preserve ordered block flushes before tool, message, and agent boundaries, add explicit `channels.matrix.blockStreaming` opt-in so Matrix `streaming: "off"` stays final-only by default, and move MiniMax plain-text final handling into the MiniMax provider runtime instead of the shared core heuristic. (#59266) Thanks @gumadeiras.
|
||||
- QQBot/streaming: make block streaming configurable per QQ bot account via `streaming.mode` (`"partial"` | `"off"`, default `"partial"`) instead of hardcoding it off, so responses can be delivered incrementally. (#63746)
|
||||
- Discord: update Carbon to v0.15.0. Thanks @thewilloftheshadow.
|
||||
- Config/Discord: coerce safe integer numeric Discord IDs to strings during config validation, keep unsafe or precision-losing numeric snowflakes rejected, and align `openclaw doctor` repair guidance with the same fail-closed behavior. (#45125) Thanks @moliendocode.
|
||||
- Dreaming/cron: stop runtime cron reconciliation on ordinary user turns and only recover managed dreaming cron state during heartbeat-triggered dreaming checks, so unrelated chat traffic does not silently recreate removed jobs. (#63938) Thanks @mbelinky.
|
||||
- UI/compaction: keep the compaction indicator in a retry-pending state until the run actually finishes, so the UI does not show `Context compacted` before compaction actually finishes. (#55132) Thanks @mpz4life.
|
||||
- Cron/tool schemas: keep cron tool schemas strict-model-friendly while still preserving `failureAlert=false`, nullable `agentId`/`sessionKey`, and flattened add/update recovery for the newly exposed cron job fields. (#55043) Thanks @brunolorente.
|
||||
- BlueBubbles/config: accept `enrichGroupParticipantsFromContacts` in the core strict config schema so gateways no longer fail validation or startup when the BlueBubbles plugin writes that field. (#56889) Thanks @zqchris.
|
||||
- Feishu/webhooks: read webhook bodies through the pre-auth guard so unauthenticated webhook traffic stays under the same body budget as other protected channel ingress paths.
|
||||
- Tools/web_fetch: add an opt-in `tools.web.fetch.ssrfPolicy.allowRfc2544BenchmarkRange` config so fake-IP proxy environments that resolve public sites into `198.18.0.0/15` can use `web_fetch` without weakening the default SSRF block. (#61830) Thanks @xing-xing-coder.
|
||||
- Dreaming/gateway: require `operator.admin` for persistent `/dreaming on|off` changes and treat missing gateway client scopes as unprivileged instead of silently allowing config writes. (#63872) Thanks @mbelinky.
|
||||
- Dreaming/cron: reconcile managed dreaming cron from startup config and runtime lifecycle changes, but only recover managed dreaming cron state during heartbeat-triggered dreaming checks so ordinary chat traffic does not recreate removed jobs. (#63873, #63929, #63938) Thanks @mbelinky.
|
||||
- Agents/failover: classify AbortError and stream-abort messages as timeout so Ollama NDJSON stream aborts stop showing `reason=unknown` in model fallback logs. (#58324) Thanks @yelog
|
||||
- Exec approvals: route Slack, Discord, and Telegram approvals through the shared channel approval-capability path so native approval auth, delivery, and `/approve` handling stay aligned across channels while preserving Telegram session-key agent filtering. (#58634) thanks @gumadeiras
|
||||
- Matrix/runtime: resolve the verification/bootstrap runtime from a distinct packaged Matrix entry so global npm installs stop failing on crypto bootstrap with missing-module or recursive runtime alias errors. (#59249) Thanks @gumadeiras.
|
||||
- Matrix/streaming: preserve ordered block flushes before tool, message, and agent boundaries, add explicit `channels.matrix.blockStreaming` opt-in so Matrix `streaming: "off"` stays final-only by default, and move MiniMax plain-text final handling into the MiniMax provider runtime instead of the shared core heuristic. (#59266) thanks @gumadeiras
|
||||
- Gateway/agents: fix stale run-context TTL cleanup so the new maintenance sweep compiles and resets orphaned run sequence state correctly. (#52731) thanks @artwalker
|
||||
- Memory/lancedb: accept `dreaming` config when `memory-lancedb` owns the memory slot so Dreaming surfaces can read slot-owner settings without schema rejection. (#63874) Thanks @mbelinky.
|
||||
- Control UI/dreaming: keep the Dreaming trace area contained and scrollable so overlays no longer cover tabs or blow out the page layout. (#63875) Thanks @mbelinky.
|
||||
- Dreaming/diary: add idempotent narrative subagent runs, preserve restrictive `DREAMS.md` permissions during atomic writes, and surface temp cleanup failures so repeated sweeps do not double-run the same narrative request or silently weaken diary safety. (#63876) Thanks @mbelinky.
|
||||
- Heartbeats/sessions: remove stale accumulated isolated heartbeat session keys when the next tick converges them back to the canonical sibling, so repaired sessions stop showing orphaned `:heartbeat:heartbeat` variants in session listings. (#59606) Thanks @rogerdigital.
|
||||
- Gateway/run cleanup: fix stale run-context TTL cleanup so the new maintenance sweep resets orphaned run sequence state and prevents unbounded run-context growth. (#52731) Thanks @artwalker.
|
||||
- UI/compaction: keep the compaction indicator in a retry-pending state until the run actually finishes, so the UI does not show `Context compacted` before compaction actually finishes. (#55132) Thanks @mpz4life.
|
||||
- Cron/tool schemas: keep cron tool schemas strict-model-friendly while still preserving `failureAlert=false`, nullable `agentId`/`sessionKey`, and flattened add/update recovery for the newly exposed cron job fields. (#55043) Thanks @brunolorente.
|
||||
- Git metadata: read commit ids from packed refs as well as loose refs so version and status metadata stay accurate after repository maintenance. (#63943)
|
||||
- Gateway: keep `commands.list` skill entries categorized under tools and include provider-aware plugin `nativeName` metadata even when `scope=text`, so remote clients can group skills correctly and map text-surface plugin commands back to native aliases.
|
||||
- TUI: reset footer activity to idle when switching sessions so a stale streaming indicator cannot persist after the selection changes. (#63988) Thanks @neeravmakwana.
|
||||
- iMessage: treat `sender === chat_identifier` as self-chat only when `destination_caller_id` is present and matches the sender, fixing DM outbound rows that omit destination from being run through self-chat echo handling. (#63980) Thanks @neeravmakwana.
|
||||
- Cron/Telegram: collapse isolated announce delivery to the final assistant-visible text only for Telegram targets, while preserving existing multi-message direct delivery semantics for other channels. (#63228) Thanks @welfo-beo.
|
||||
- Gateway/thread routing: preserve Slack, Telegram, and Mattermost thread-child delivery targets so bound subagent completion messages land in the originating thread instead of top-level channels. (#54840) Thanks @yzzymt.
|
||||
- ACP/stream relay: pass parent delivery context to ACP stream relay system events so `streamTo="parent"` updates route to the correct thread or topic instead of falling back to the main DM. (#57056) Thanks @pingren.
|
||||
- Agents/sessions: preserve announce `threadId` when `sessions.list` fallback rehydrates agent-to-agent announce targets so final announce messages stay in the originating thread/topic. (#63506) Thanks @SnowSky1.
|
||||
- iMessage/self-chat: remember ambiguous `sender === chat_identifier` outbound rows with missing `destination_caller_id` in self-chat dedupe state so the later reflected inbound copy still drops instead of re-entering inbound handling when the echo cache misses. Thanks @neeravmakwana.
|
||||
- Claude CLI: stop marking spawned Claude Code runs as host-managed so they keep using normal CLI subscription behavior. (#64023) Thanks @Alex-Alaniz.
|
||||
- Agents/failover: classify OpenRouter `404 No endpoints found for <model>` responses as `model_not_found` so fallback chains continue past retired OpenRouter candidates. (#61472) Thanks @MonkeyLeeT.
|
||||
- Browser/plugin SDK: route browser auth, profile, host-inspection, and doctor readiness helpers through browser plugin public facades so core compatibility helpers stop carrying duplicate runtime implementations. (#63957) Thanks @joshavant.
|
||||
- Agents/failover: allow cooldown probes for `timeout` (including network outage classifications) so the primary model can recover after failover without a gateway restart. (#63996) Thanks @neeravmakwana.
|
||||
- iMessage (imsg): strip an accidental protobuf length-delimited UTF-8 field wrapper from inbound `text` and `reply_to_text` when it fully consumes the field, fixing leading garbage before the real message. (#63868) Thanks @neeravmakwana.
|
||||
- Gateway/pairing: fail closed for paired device records that have no device tokens, and reject pairing approvals whose requested scopes do not match the requested device roles.
|
||||
- ACP/gateway chat: classify lifecycle errors before forwarding them to ACP clients so refusals use ACP's refusal stop reason while transient backend errors continue to finish as normal turns.
|
||||
- Agents/BTW: strip replayed tool blocks, hidden reasoning, and malformed image payloads from `/btw` side-question context so Bedrock no-tools side questions keep working after tool-use turns. (#64225) Thanks @ngutman.
|
||||
- Commands/btw: keep tool-less side questions from sending injected empty `tools` arrays on strict OpenAI-compatible providers, so `/btw` continues working after prior tool-call history. (#64219) Thanks @ngutman.
|
||||
- Agents/Bedrock: let `/btw` side questions use `auth: "aws-sdk"` without a static API key so Bedrock IAM and instance-role sessions stop failing before the side question runs. (#64218) Thanks @SnowSky1.
|
||||
- Feishu: route `/btw` side questions and `/stop` onto bounded out-of-band lanes so BTW no longer waits behind a busy normal chat turn while ordinary same-chat traffic stays FIFO. (#64324) Thanks @ngutman.
|
||||
- Agents/failover: detect llama.cpp slot context overflows as context-overflow errors so compaction can retry self-hosted OpenAI-compatible runs instead of surfacing the raw upstream 400. (#64196) Thanks @alexander-applyinnovations.
|
||||
- Claude CLI/skills: pass eligible OpenClaw skills into CLI runs, including native Claude Code skill resolution via a temporary plugin plus per-run skill env/API key injection. (#62686, #62723) Thanks @zomars.
|
||||
- Discord: keep generated auto-thread names working with reasoning models by giving title generation enough output budget for thinking plus visible title text. (#64172) Thanks @hanamizuki.
|
||||
- Heartbeat: ignore doc-only Markdown fence markers in the default `HEARTBEAT.md` template so comment-only heartbeat scaffolds skip API calls again. (#63434) Thanks @ravyg.
|
||||
- Control UI/BTW: render `/btw` side results as dismissible ephemeral cards in the browser, send `/btw` immediately during active runs, and clear stale BTW cards on reset flows so webchat matches the intended detached side-question behavior. (#64290) Thanks @ngutman.
|
||||
- Reply/skills: keep resolved skill and memory secret config stable through embedded reply runs so raw SecretRefs in secondary skill settings no longer crash replies when the gateway already has the live env. (#64249) Thanks @mbelinky.
|
||||
- Dreaming/startup: keep plugin-registered startup hooks alive across workspace hook reloads and include dreaming startup owners in the gateway startup plugin scope, so managed Dreaming cron registration comes back reliably after gateway boot. (#62327) Thanks @mbelinky.
|
||||
- Plugins: treat duplicate `registerService` calls from the same plugin id as idempotent so snapshot and activation loads no longer emit spurious `service already registered` diagnostics. (#62033, #64128) Thanks @ly85206559.
|
||||
- Discord/TTS: route auto voice replies through the native voice-note path so Discord receives Opus voice messages instead of regular audio attachments. (#64096) Thanks @LiuHuaize.
|
||||
- Config/plugins: use plugin-owned command alias metadata when `plugins.allow` contains runtime command names like `dreaming`, and point users at the owning plugin instead of stale plugin-not-found guidance. (#64242) Thanks @feiskyer.
|
||||
- Agents/Gemini: strip orphaned `required` entries from Gemini tool schemas so provider validation no longer rejects tools after schema cleanup or union flattening. (#64284) Thanks @xxxxxmax.
|
||||
- Assistant text: strip Qwen-style XML tool call payloads from visible replies so web and channel messages no longer show raw `<tool_call><function=...>` output. (#64214) Thanks @MoerAI.
|
||||
- Daemon/gateway: prevent systemd restart storms on configuration errors by exiting with `EX_CONFIG` and adding generated unit restart-prevention guards. (#63913) Thanks @neo1027144-creator.
|
||||
- Agents/exec: prevent gateway crash ("Agent listener invoked outside active run") when a subagent exec tool produces stdout/stderr after the agent run has ended or been aborted. (#62821) Thanks @openperf.
|
||||
- Browser/tabs: route `/tabs/action` close/select through the same browser endpoint reachability and policy checks as list/new (including Playwright-backed remote tab operations), reject CDP HTTP redirects on probe requests, and sanitize blocked-endpoint error responses so tab list/focus/close flows fail closed without echoing raw policy details back to callers. (#63332)
|
||||
- Gateway/OpenAI compat: return real `usage` for non-stream `/v1/chat/completions` responses, emit the final usage chunk when `stream_options.include_usage=true`, and bound usage-gated stream finalization after lifecycle end. (#62986) Thanks @Lellansin.
|
||||
- Matrix/migration: keep packaged warning-only crypto migrations from being misclassified as actionable when only helper chunks are present, so startup and doctor stay on the warning-only path instead of creating unnecessary migration snapshots. (#64373) Thanks @gumadeiras.
|
||||
- Matrix/ACP thread bindings: preserve canonical room casing and parent conversation routing during ACP session spawn so mixed-case room ids bind correctly from top-level rooms and existing Matrix threads. (#64343) Thanks @gumadeiras.
|
||||
- Agents/subagents: deduplicate delivered completion announces so retry or re-entry cleanup does not inject duplicate internal-context completion turns into the parent session. (#61525) Thanks @100yenadmin.
|
||||
- Agents/exec: keep sandboxed `tools.exec.host=auto` sessions from honoring per-call `host=node` or `host=gateway` overrides while a sandbox runtime is active, and stop advertising node routing in that state so exec stays on the sandbox host. (#63880)
|
||||
- Gateway/restart sentinel: route restart notices only from stored canonical delivery metadata and skip outbound guessing from lossy session keys, avoiding misdelivery on case-sensitive channels like Matrix. (#64391) Thanks @gumadeiras.
|
||||
- Browser/act: centralize `/act` request normalization and execution dispatch while adding stable machine-readable route-level error codes for invalid requests, selector misuse, evaluate-disabled gating, target mismatch, and existing-session unsupported actions. (#63977) Thanks @joshavant.
|
||||
- Windows/exec: settle supervisor waits from child exit state after stdout and stderr drain even when `close` never arrives, so CLI commands stop hanging or dying with forced `SIGKILL` on Windows. (#64072) Thanks @obviyus.
|
||||
|
||||
- Cron/isolated agent: run scheduled agent turns as non-owner senders so owner-only tools stay unavailable during cron execution. (#63878)
|
||||
- Voice Call/realtime: reject oversized realtime WebSocket frames before bridge setup so large pre-start payloads cannot crash the gateway. (#63890) Thanks @mmaps.
|
||||
- Browser/sandbox: gate `/sandbox/novnc` behind bridge auth and stop surfacing sandbox observer URLs in model-visible prompt context. (#63882) Thanks @eleqtrizit.
|
||||
|
||||
- Discord/sandbox: include `image` in sandbox media param normalization so Discord event cover images cannot bypass sandbox path rewriting. (#64377) Thanks @mmaps.
|
||||
- Agents/exec: extend exec completion detection to cover local background exec formats so the owner-downgrade fires correctly for all exec paths. (#64376) Thanks @mmaps.
|
||||
- Security/dependencies: pin axios to 1.15.0 and add a plugin install dependency denylist that blocks known malicious packages before install. (#63891) Thanks @mmaps.
|
||||
- Browser/security: apply three-phase interaction navigation guard to pressKey and type(submit) so delayed JS redirects from keypress cannot bypass SSRF policy. (#63889) Thanks @mmaps.
|
||||
|
||||
- Browser/security: guard existing-session Chrome MCP interaction routes with SSRF post-checks so delayed navigation from click, type, press, and evaluate cannot bypass the configured policy. (#64370) Thanks @eleqtrizit.
|
||||
- Browser/security: default browser SSRF policy to strict mode so unconfigured installs block private-network navigation, and align external-content marker span mapping so ZWS-injected boundary spoofs are fully sanitized. (#63885) Thanks @eleqtrizit.
|
||||
- Browser/security: apply SSRF navigation policy to subframe document navigations so iframe-targeted private-network hops are blocked without quarantining the parent page. (#64371) Thanks @eleqtrizit.
|
||||
- Hooks/security: mark agent hook system events as untrusted and sanitize hook display names before cron metadata reuse. (#64372) Thanks @eleqtrizit.
|
||||
- Media/security: honor sender-scoped `toolsBySender` policy for outbound host-media reads so denied senders cannot trigger host file disclosure via attachment hydration. (#64459) Thanks @eleqtrizit.
|
||||
- Browser/security: reject strict-policy hostname navigation unless the hostname is an explicit allowlist exception or IP literal, and route CDP HTTP discovery through the pinned SSRF fetch path. (#64367) Thanks @eleqtrizit.
|
||||
- Plugins/ACPX: wrap plugin tools on the MCP bridge with the shared `before_tool_call` handler so block and approval hooks fire consistently across all execution paths. (#63886) Thanks @eleqtrizit.
|
||||
|
||||
- Logging/security: redact Gmail watcher `--hook-token` values from startup logging and `logs.tail` output. (#62661) Thanks @eleqtrizit.
|
||||
- Models/fallback: preserve `/models` selection across transient primary-model failures and config reloads so the fallback chain no longer permanently clobbers a user-chosen model. (#64471) Thanks @hoyyeva.
|
||||
|
||||
- Sandbox/security: auto-derive CDP source-range from Docker network gateway and refuse to start the socat relay without one, so peer containers cannot reach CDP unauthenticated. (#61404) Thanks @dims.
|
||||
- Daemon/launchd: keep `openclaw gateway stop` persistent without uninstalling the macOS LaunchAgent, re-enable it on explicit restart or repair, and harden launchd label handling. (#64447) Thanks @ngutman.
|
||||
- Agents/Slack: preserve threaded announce delivery when `sessions.list` rows lack stored thread metadata by falling back to the thread id encoded in the session key. (#63143) Thanks @mariosousa-finn.
|
||||
- Plugins/context engines: preserve `plugins.slots.contextEngine` through normalization and keep explicitly selected workspace context-engine plugins enabled, so loader diagnostics and plugin activation stop dropping that slot selection. (#64192) Thanks @hclsys.
|
||||
- Heartbeat: stop top-level `interval:` and `prompt:` fields outside the `tasks:` block from bleeding into the last parsed heartbeat task. (#64488) Thanks @Rahulkumar070.
|
||||
## 2026.4.9
|
||||
|
||||
### Changes
|
||||
@@ -196,7 +114,6 @@ Docs: https://docs.openclaw.ai
|
||||
- Control UI/models: preserve provider-qualified refs for OpenRouter catalog models whose ids already contain slashes so picker selections submit allowlist-compatible model refs instead of dropping the `openrouter/` prefix. (#63416) Thanks @sallyom.
|
||||
- Plugin SDK/command auth: split command status builders onto the lightweight `openclaw/plugin-sdk/command-status` subpath while preserving deprecated `command-auth` compatibility exports, so auth-only plugin imports no longer pull status/context warmup into CLI onboarding paths. (#63174) Thanks @hxy91819.
|
||||
- Wizard/plugin config: coerce integer-typed plugin config fields from interactive text input so integer schema values persist as numbers instead of failing validation. (#63346) Thanks @jalehman.
|
||||
- Dreaming/narrative: harden request-scoped diary fallback so scheduled dreaming only falls back on the dedicated subagent-runtime error, stop trusting spoofable raw error-code objects, and avoid leaking workspace paths when local fallback writes fail. (#64156) Thanks @mbelinky.
|
||||
|
||||
## 2026.4.8
|
||||
|
||||
@@ -317,9 +234,6 @@ Docs: https://docs.openclaw.ai
|
||||
- CLI/tasks: `openclaw tasks cancel` now records operator cancellation for CLI runtime tasks instead of returning "Task runtime does not support cancellation yet", so stuck `running` CLI tasks can be cleared. (#62419) Thanks @neeravmakwana.
|
||||
- Sessions/context: resolve context window limits using the active provider plus model (not bare model id alone) when persisting session usage, applying inline directives, and sizing memory-flush / preflight compaction thresholds, so duplicate model ids across providers no longer leak the wrong `contextTokens` into the session store or `/status`. (#62472) Thanks @neeravmakwana.
|
||||
- Channels/setup: exclude workspace shadow entries from channel setup catalog lookups and align trust checks with auto-enable so workspace-scoped overrides no longer bypass the trusted catalog. (`GHSA-82qx-6vj7-p8m2`) Thanks @zsxsoft.
|
||||
- Reply execution: prefer the active runtime snapshot over stale queued reply config during embedded reply and follow-up execution so SecretRef-backed reply turns stop crashing after secrets have already resolved. (#62693) Thanks @mbelinky.
|
||||
- Android/manual connect: allow blank port input only for TLS manual gateway endpoints so standard HTTPS Tailscale hosts default to `443` without silently changing cleartext manual connects. (#63134) Thanks @Tyler-RNG.
|
||||
- Matrix/agents: hide owner-only `set-profile` from embedded agent channel-action discovery so non-owner runs stop advertising profile updates they cannot execute. (#62662) Thanks @eleqtrizit.
|
||||
|
||||
## 2026.4.5
|
||||
|
||||
@@ -570,6 +484,7 @@ Docs: https://docs.openclaw.ai
|
||||
- Matrix: avoid failing startup when token auth already knows the user ID but still needs optional device metadata, retry transient auth bootstrap requests, and backfill missing device IDs after startup while keeping unknown-device storage reuse conservative until metadata is repaired. (#61383) Thanks @gumadeiras.
|
||||
- Agents/exec: stop streaming `tool_execution_update` events after an exec session backgrounds, preventing delayed background output from hitting a stale listener and crashing the gateway while keeping the output available through `process poll/log`. (#61627) Thanks @openperf.
|
||||
- Matrix: pass configured `deviceId` through health probes and keep probe-only client setup out of durable Matrix storage, so health checks preserve the correct device identity without rewriting `storage-meta.json` or related probe state on disk. (#61581) Thanks @MoerAI.
|
||||
||||||| parent of b4694a4ac7 (Telegram: add outbound chunker regression coverage)
|
||||
- Image generation/build: write stable runtime alias files into `dist/` and route provider-auth runtime lookups through those aliases so image-generation providers keep resolving auth/runtime modules after rebuilds instead of crashing on missing hashed chunk files.
|
||||
- Config/runtime: pin the first successful config load in memory for the running process and refresh that snapshot on successful writes/reloads, so hot paths stop reparsing `openclaw.json` between watcher-driven swaps.
|
||||
- Config/legacy cleanup: stop probing obsolete alternate legacy config names and service labels during local config/service detection, while keeping the active `~/.openclaw/openclaw.json` path canonical.
|
||||
|
||||
@@ -102,11 +102,6 @@ For coordinated change sets that genuinely need more than 10 PRs, join the **#cl
|
||||
- For targeted shared-surface work, use `pnpm test:contracts:channels` or `pnpm test:contracts:plugins`
|
||||
- These commands also cover the shared seam/smoke files that the default unit lane skips
|
||||
- If you changed broader runtime behavior, still run the relevant wider lanes (`pnpm test:extensions`, `pnpm test:channels`, or `pnpm test`) before asking for review
|
||||
- If you touched bundled-plugin boundaries in shared code, run the matching inventories:
|
||||
- `node scripts/check-src-extension-import-boundary.mjs --json` for `src/**`
|
||||
- `node scripts/check-sdk-package-extension-import-boundary.mjs --json` for `src/plugin-sdk/**` and `packages/**`
|
||||
- `node scripts/check-test-helper-extension-import-boundary.mjs --json` for `test/helpers/**`
|
||||
- Shared test helpers must use `src/test-utils/bundled-plugin-public-surface.ts` instead of repo-relative `extensions/**` imports. Keep plugin-local deep mocks inside the owning bundled plugin package.
|
||||
- If you have access to Codex, run `codex review --base origin/main` locally before opening or updating your PR. Treat this as the current highest standard of AI review, even if GitHub Codex review also runs.
|
||||
- Do not submit refactor-only PRs unless a maintainer explicitly requested that refactor for an active fix or deliverable.
|
||||
- Do not submit test or CI-config fixes for failures already red on `main` CI. If a failure is already visible in the [main branch CI runs](https://github.com/openclaw/openclaw/actions), it's a known issue the Maintainer team is tracking, and a PR that only addresses those failures will be closed automatically. If you spot a _new_ regression not yet shown in main CI, report it as an issue first.
|
||||
|
||||
@@ -1,52 +0,0 @@
|
||||
# OpenClaw Incident Response Plan
|
||||
|
||||
## 1. Detection and triage
|
||||
|
||||
We monitor security signals from:
|
||||
|
||||
- GitHub Security Advisories (GHSA) and private vulnerability reports.
|
||||
- Public GitHub issues/discussions when reports are not sensitive.
|
||||
- Automated signals (for example Dependabot, CodeQL, npm advisories, and secret scanning).
|
||||
|
||||
Initial triage:
|
||||
|
||||
1. Confirm affected component, version, and trust boundary impact.
|
||||
2. Classify as security issue vs hardening/no-action using the repository `SECURITY.md` scope and out-of-scope rules.
|
||||
3. An incident owner responds accordingly.
|
||||
|
||||
## 2. Assessment
|
||||
|
||||
Severity guide:
|
||||
|
||||
- **Critical:** Package/release/repository compromise, active exploitation, or unauthenticated trust-boundary bypass with high-impact control or data exposure.
|
||||
- **High:** Verified trust-boundary bypass requiring limited preconditions (for example authenticated but unauthorized high-impact action), or exposure of OpenClaw-owned sensitive credentials.
|
||||
- **Medium:** Significant security weakness with practical impact but constrained exploitability or substantial prerequisites.
|
||||
- **Low:** Defense-in-depth findings, narrowly scoped denial-of-service, or hardening/parity gaps without a demonstrated trust-boundary bypass.
|
||||
|
||||
## 3. Response
|
||||
|
||||
1. Acknowledge receipt to the reporter (private when sensitive).
|
||||
2. Reproduce on supported releases and latest `main`, then implement and validate a patch with regression coverage.
|
||||
3. For critical/high incidents, prepare patched release(s) as fast as practical.
|
||||
4. For medium/low incidents, patch in normal release flow and document mitigation guidance.
|
||||
|
||||
## 4. Communication
|
||||
|
||||
We communicate through:
|
||||
|
||||
- GitHub Security Advisories in the affected repository.
|
||||
- Release notes/changelog entries for fixed versions.
|
||||
- Direct reporter follow-up on status and resolution.
|
||||
|
||||
Disclosure policy:
|
||||
|
||||
- Critical/high incidents should receive coordinated disclosure, with CVE issuance when appropriate.
|
||||
- Low-risk hardening findings may be documented in release notes or advisories without CVE, depending on impact and user exposure.
|
||||
|
||||
## 5. Recovery and follow-up
|
||||
|
||||
After shipping the fix:
|
||||
|
||||
1. Verify remediations in CI and release artifacts.
|
||||
2. Run a short post-incident review (timeline, root cause, detection gap, prevention plan).
|
||||
3. Add follow-up hardening/tests/docs tasks and track them to completion.
|
||||
@@ -8,10 +8,6 @@
|
||||
|
||||
### Fixed
|
||||
|
||||
## 2026.4.10 - 2026-04-10
|
||||
|
||||
Maintenance update for the current OpenClaw release.
|
||||
|
||||
## 2026.4.6 - 2026-04-06
|
||||
|
||||
First App Store release of OpenClaw for iPhone. Pair with your OpenClaw Gateway to use chat, voice, sharing, and device actions from iOS.
|
||||
|
||||
@@ -2,8 +2,8 @@
|
||||
// Source of truth: apps/ios/version.json
|
||||
// Generated by scripts/ios-sync-versioning.ts.
|
||||
|
||||
OPENCLAW_IOS_VERSION = 2026.4.10
|
||||
OPENCLAW_MARKETING_VERSION = 2026.4.10
|
||||
OPENCLAW_IOS_VERSION = 2026.4.6
|
||||
OPENCLAW_MARKETING_VERSION = 2026.4.6
|
||||
OPENCLAW_BUILD_VERSION = 1
|
||||
|
||||
#include? "../build/Version.xcconfig"
|
||||
|
||||
@@ -1 +1 @@
|
||||
Maintenance update for the current OpenClaw release.
|
||||
First App Store release of OpenClaw for iPhone. Pair with your OpenClaw Gateway to use chat, voice, sharing, and device actions from iOS.
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
{
|
||||
"version": "2026.4.10"
|
||||
"version": "2026.4.6"
|
||||
}
|
||||
|
||||
@@ -8,8 +8,6 @@ struct HostEnvOverrideDiagnostics: Equatable {
|
||||
enum HostEnvSanitizer {
|
||||
/// Generated from src/infra/host-env-security-policy.json via scripts/generate-host-env-security-policy-swift.mjs.
|
||||
/// Parity is validated by src/infra/host-env-security.policy-parity.test.ts.
|
||||
private static let blockedInheritedKeys = HostEnvSecurityPolicy.blockedInheritedKeys
|
||||
private static let blockedInheritedPrefixes = HostEnvSecurityPolicy.blockedInheritedPrefixes
|
||||
private static let blockedKeys = HostEnvSecurityPolicy.blockedKeys
|
||||
private static let blockedPrefixes = HostEnvSecurityPolicy.blockedPrefixes
|
||||
private static let blockedOverrideKeys = HostEnvSecurityPolicy.blockedOverrideKeys
|
||||
@@ -30,11 +28,6 @@ enum HostEnvSanitizer {
|
||||
return self.blockedPrefixes.contains(where: { upperKey.hasPrefix($0) })
|
||||
}
|
||||
|
||||
private static func isBlockedInherited(_ upperKey: String) -> Bool {
|
||||
if self.blockedInheritedKeys.contains(upperKey) { return true }
|
||||
return self.blockedInheritedPrefixes.contains(where: { upperKey.hasPrefix($0) })
|
||||
}
|
||||
|
||||
private static func isBlockedOverride(_ upperKey: String) -> Bool {
|
||||
if self.blockedOverrideKeys.contains(upperKey) { return true }
|
||||
return self.blockedOverridePrefixes.contains(where: { upperKey.hasPrefix($0) })
|
||||
@@ -120,7 +113,7 @@ enum HostEnvSanitizer {
|
||||
let key = rawKey.trimmingCharacters(in: .whitespacesAndNewlines)
|
||||
guard !key.isEmpty else { continue }
|
||||
let upper = key.uppercased()
|
||||
if self.isBlockedInherited(upper) { continue }
|
||||
if self.isBlocked(upper) { continue }
|
||||
merged[key] = value
|
||||
}
|
||||
|
||||
|
||||
@@ -5,232 +5,20 @@
|
||||
import Foundation
|
||||
|
||||
enum HostEnvSecurityPolicy {
|
||||
static let blockedInheritedKeys: Set<String> = [
|
||||
"_JAVA_OPTIONS",
|
||||
"AMQP_URL",
|
||||
"ANSIBLE_CALLBACK_PLUGINS",
|
||||
"ANSIBLE_COLLECTIONS_PATH",
|
||||
"ANSIBLE_CONFIG",
|
||||
"ANSIBLE_CONNECTION_PLUGINS",
|
||||
"ANSIBLE_FILTER_PLUGINS",
|
||||
"ANSIBLE_INVENTORY_PLUGINS",
|
||||
"ANSIBLE_LIBRARY",
|
||||
"ANSIBLE_LOOKUP_PLUGINS",
|
||||
"ANSIBLE_MODULE_UTILS",
|
||||
"ANSIBLE_REMOTE_TEMP",
|
||||
"ANSIBLE_ROLES_PATH",
|
||||
"ANSIBLE_STRATEGY_PLUGINS",
|
||||
"ANT_OPTS",
|
||||
"AWS_ACCESS_KEY_ID",
|
||||
"AWS_CONTAINER_CREDENTIALS_FULL_URI",
|
||||
"AWS_CONTAINER_CREDENTIALS_RELATIVE_URI",
|
||||
"AWS_SECRET_ACCESS_KEY",
|
||||
"AWS_SECURITY_TOKEN",
|
||||
"AWS_SESSION_TOKEN",
|
||||
"AZURE_CLIENT_ID",
|
||||
"AZURE_CLIENT_SECRET",
|
||||
"BASH_ENV",
|
||||
"BROWSER",
|
||||
"BUN_CONFIG_REGISTRY",
|
||||
"BUNDLE_GEMFILE",
|
||||
"BZR_EDITOR",
|
||||
"BZR_PLUGIN_PATH",
|
||||
"BZR_SSH",
|
||||
"C_INCLUDE_PATH",
|
||||
"CARGO_BUILD_RUSTC",
|
||||
"CARGO_BUILD_RUSTC_WRAPPER",
|
||||
"CARGO_HOME",
|
||||
"CATALINA_OPTS",
|
||||
"CC",
|
||||
"CFLAGS",
|
||||
"CGO_CFLAGS",
|
||||
"CGO_LDFLAGS",
|
||||
"CLASSPATH",
|
||||
"CMAKE_C_COMPILER",
|
||||
"CMAKE_CXX_COMPILER",
|
||||
"CMAKE_TOOLCHAIN_FILE",
|
||||
"COMPOSER_HOME",
|
||||
"CONFIG_SHELL",
|
||||
"CONFIG_SITE",
|
||||
"CORECLR_PROFILER",
|
||||
"CORECLR_PROFILER_PATH",
|
||||
"CPATH",
|
||||
"CPLUS_INCLUDE_PATH",
|
||||
"CURL_HOME",
|
||||
"CXX",
|
||||
"DATABASE_URL",
|
||||
"DENO_DIR",
|
||||
"DOTNET_ADDITIONAL_DEPS",
|
||||
"DOTNET_STARTUP_HOOKS",
|
||||
"EDITOR",
|
||||
"ELIXIR_ERL_OPTIONS",
|
||||
"EMACSLOADPATH",
|
||||
"ENV",
|
||||
"ERL_AFLAGS",
|
||||
"ERL_FLAGS",
|
||||
"ERL_ZFLAGS",
|
||||
"EXINIT",
|
||||
"FCEDIT",
|
||||
"GCONV_PATH",
|
||||
"GEM_HOME",
|
||||
"GEM_PATH",
|
||||
"GH_TOKEN",
|
||||
"GIT_ALTERNATE_OBJECT_DIRECTORIES",
|
||||
"GIT_ASKPASS",
|
||||
"GIT_COMMON_DIR",
|
||||
"GIT_DIR",
|
||||
"GIT_EDITOR",
|
||||
"GIT_EXEC_PATH",
|
||||
"GIT_EXTERNAL_DIFF",
|
||||
"GIT_HOOK_PATH",
|
||||
"GIT_INDEX_FILE",
|
||||
"GIT_NAMESPACE",
|
||||
"GIT_OBJECT_DIRECTORY",
|
||||
"GIT_PROXY_COMMAND",
|
||||
"GIT_SEQUENCE_EDITOR",
|
||||
"GIT_SSH",
|
||||
"GIT_SSH_COMMAND",
|
||||
"GIT_SSL_CAINFO",
|
||||
"GIT_SSL_CAPATH",
|
||||
"GIT_SSL_NO_VERIFY",
|
||||
"GIT_TEMPLATE_DIR",
|
||||
"GIT_WORK_TREE",
|
||||
"GITHUB_TOKEN",
|
||||
"GITLAB_TOKEN",
|
||||
"GLIBC_TUNABLES",
|
||||
"GOENV",
|
||||
"GOFLAGS",
|
||||
"GONOPROXY",
|
||||
"GONOSUMCHECK",
|
||||
"GONOSUMDB",
|
||||
"GOPATH",
|
||||
"GOPRIVATE",
|
||||
"GOPROXY",
|
||||
"GRADLE_OPTS",
|
||||
"GVIMINIT",
|
||||
"HELM_HOME",
|
||||
"HELM_PLUGINS",
|
||||
"HGRCPATH",
|
||||
"HOSTALIASES",
|
||||
"IFS",
|
||||
"JAVA_OPTS",
|
||||
"JAVA_TOOL_OPTIONS",
|
||||
"JDK_JAVA_OPTIONS",
|
||||
"JULIA_EDITOR",
|
||||
"LDFLAGS",
|
||||
"LESSCLOSE",
|
||||
"LESSOPEN",
|
||||
"LIBRARY_PATH",
|
||||
"LUA_CPATH",
|
||||
"LUA_INIT",
|
||||
"LUA_INIT_5_1",
|
||||
"LUA_INIT_5_2",
|
||||
"LUA_INIT_5_3",
|
||||
"LUA_INIT_5_4",
|
||||
"LUA_PATH",
|
||||
"MAKEFLAGS",
|
||||
"MAVEN_OPTS",
|
||||
"MFLAGS",
|
||||
"MONGODB_URI",
|
||||
"MYVIMRC",
|
||||
"NODE_AUTH_TOKEN",
|
||||
"NODE_OPTIONS",
|
||||
"NODE_PATH",
|
||||
"NPM_TOKEN",
|
||||
"OBJC_INCLUDE_PATH",
|
||||
"OPENSSL_CONF",
|
||||
"OPENSSL_ENGINES",
|
||||
"PACKER_PLUGIN_PATH",
|
||||
"PERL5DB",
|
||||
"PERL5DBCMD",
|
||||
"PERL5LIB",
|
||||
"PERL5OPT",
|
||||
"PHP_INI_SCAN_DIR",
|
||||
"PHPRC",
|
||||
"PIP_CONFIG_FILE",
|
||||
"PIP_EXTRA_INDEX_URL",
|
||||
"PIP_FIND_LINKS",
|
||||
"PIP_INDEX_URL",
|
||||
"PIP_PYPI_URL",
|
||||
"PIP_TRUSTED_HOST",
|
||||
"PROMPT_COMMAND",
|
||||
"PS4",
|
||||
"PYTHONBREAKPOINT",
|
||||
"PYTHONHOME",
|
||||
"PYTHONPATH",
|
||||
"PYTHONSTARTUP",
|
||||
"PYTHONUSERBASE",
|
||||
"R_ENVIRON",
|
||||
"R_ENVIRON_USER",
|
||||
"R_LIBS_USER",
|
||||
"R_PROFILE",
|
||||
"R_PROFILE_USER",
|
||||
"REDIS_URL",
|
||||
"RUBYLIB",
|
||||
"RUBYOPT",
|
||||
"RUBYSHELL",
|
||||
"RUSTC_WRAPPER",
|
||||
"RUSTFLAGS",
|
||||
"SBT_OPTS",
|
||||
"SHELL",
|
||||
"SHELLOPTS",
|
||||
"SSH_ASKPASS",
|
||||
"SSLKEYLOGFILE",
|
||||
"SUDO_ASKPASS",
|
||||
"SUDO_EDITOR",
|
||||
"SVN_EDITOR",
|
||||
"SVN_SSH",
|
||||
"TF_CLI_CONFIG_FILE",
|
||||
"TF_PLUGIN_CACHE_DIR",
|
||||
"UV_DEFAULT_INDEX",
|
||||
"UV_EXTRA_INDEX_URL",
|
||||
"UV_INDEX",
|
||||
"UV_INDEX_URL",
|
||||
"UV_PYTHON",
|
||||
"VAGRANT_VAGRANTFILE",
|
||||
"VIMINIT",
|
||||
"VIRTUAL_ENV",
|
||||
"VISUAL",
|
||||
"WGETRC",
|
||||
"XDG_CONFIG_DIRS",
|
||||
"XDG_CONFIG_HOME",
|
||||
"YARN_RC_FILENAME"
|
||||
]
|
||||
|
||||
static let blockedInheritedPrefixes: [String] = [
|
||||
"BASH_FUNC_",
|
||||
"DYLD_",
|
||||
"LD_"
|
||||
]
|
||||
|
||||
static let blockedKeys: Set<String> = [
|
||||
"_JAVA_OPTIONS",
|
||||
"ANT_OPTS",
|
||||
"BASH_ENV",
|
||||
"BROWSER",
|
||||
"BZR_EDITOR",
|
||||
"BZR_PLUGIN_PATH",
|
||||
"BZR_SSH",
|
||||
"CARGO_BUILD_RUSTC",
|
||||
"CARGO_BUILD_RUSTC_WRAPPER",
|
||||
"CATALINA_OPTS",
|
||||
"CC",
|
||||
"CMAKE_C_COMPILER",
|
||||
"CMAKE_CXX_COMPILER",
|
||||
"CMAKE_TOOLCHAIN_FILE",
|
||||
"CONFIG_SHELL",
|
||||
"CONFIG_SITE",
|
||||
"CORECLR_PROFILER",
|
||||
"CXX",
|
||||
"DOTNET_ADDITIONAL_DEPS",
|
||||
"DOTNET_STARTUP_HOOKS",
|
||||
"ELIXIR_ERL_OPTIONS",
|
||||
"EMACSLOADPATH",
|
||||
"ENV",
|
||||
"ERL_AFLAGS",
|
||||
"ERL_FLAGS",
|
||||
"ERL_ZFLAGS",
|
||||
"EXINIT",
|
||||
"GCONV_PATH",
|
||||
"GIT_ALTERNATE_OBJECT_DIRECTORIES",
|
||||
"GIT_COMMON_DIR",
|
||||
@@ -238,7 +26,6 @@ enum HostEnvSecurityPolicy {
|
||||
"GIT_EDITOR",
|
||||
"GIT_EXEC_PATH",
|
||||
"GIT_EXTERNAL_DIFF",
|
||||
"GIT_HOOK_PATH",
|
||||
"GIT_INDEX_FILE",
|
||||
"GIT_NAMESPACE",
|
||||
"GIT_OBJECT_DIRECTORY",
|
||||
@@ -250,85 +37,42 @@ enum HostEnvSecurityPolicy {
|
||||
"GIT_WORK_TREE",
|
||||
"GLIBC_TUNABLES",
|
||||
"GRADLE_OPTS",
|
||||
"GVIMINIT",
|
||||
"HELM_PLUGINS",
|
||||
"HGRCPATH",
|
||||
"HOSTALIASES",
|
||||
"IFS",
|
||||
"JAVA_OPTS",
|
||||
"JAVA_TOOL_OPTIONS",
|
||||
"JDK_JAVA_OPTIONS",
|
||||
"JULIA_EDITOR",
|
||||
"LUA_INIT",
|
||||
"LUA_INIT_5_1",
|
||||
"LUA_INIT_5_2",
|
||||
"LUA_INIT_5_3",
|
||||
"LUA_INIT_5_4",
|
||||
"MAKEFLAGS",
|
||||
"MAVEN_OPTS",
|
||||
"MFLAGS",
|
||||
"MYVIMRC",
|
||||
"NODE_OPTIONS",
|
||||
"NODE_PATH",
|
||||
"PACKER_PLUGIN_PATH",
|
||||
"PERL5LIB",
|
||||
"PERL5OPT",
|
||||
"PS4",
|
||||
"PYTHONBREAKPOINT",
|
||||
"PYTHONHOME",
|
||||
"PYTHONPATH",
|
||||
"R_ENVIRON",
|
||||
"R_ENVIRON_USER",
|
||||
"R_PROFILE",
|
||||
"R_PROFILE_USER",
|
||||
"RUBYLIB",
|
||||
"RUBYOPT",
|
||||
"RUBYSHELL",
|
||||
"RUSTC_WRAPPER",
|
||||
"SBT_OPTS",
|
||||
"SHELL",
|
||||
"SHELLOPTS",
|
||||
"SSLKEYLOGFILE",
|
||||
"SUDO_ASKPASS",
|
||||
"SVN_EDITOR",
|
||||
"SVN_SSH",
|
||||
"VAGRANT_VAGRANTFILE",
|
||||
"VIMINIT"
|
||||
"SSLKEYLOGFILE"
|
||||
]
|
||||
|
||||
static let blockedOverrideKeys: Set<String> = [
|
||||
"ALL_PROXY",
|
||||
"AMQP_URL",
|
||||
"ANSIBLE_CALLBACK_PLUGINS",
|
||||
"ANSIBLE_COLLECTIONS_PATH",
|
||||
"ANSIBLE_CONFIG",
|
||||
"ANSIBLE_CONNECTION_PLUGINS",
|
||||
"ANSIBLE_FILTER_PLUGINS",
|
||||
"ANSIBLE_INVENTORY_PLUGINS",
|
||||
"ANSIBLE_LIBRARY",
|
||||
"ANSIBLE_LOOKUP_PLUGINS",
|
||||
"ANSIBLE_MODULE_UTILS",
|
||||
"ANSIBLE_REMOTE_TEMP",
|
||||
"ANSIBLE_ROLES_PATH",
|
||||
"ANSIBLE_STRATEGY_PLUGINS",
|
||||
"AWS_ACCESS_KEY_ID",
|
||||
"AWS_CONFIG_FILE",
|
||||
"AWS_CONTAINER_CREDENTIALS_FULL_URI",
|
||||
"AWS_CONTAINER_CREDENTIALS_RELATIVE_URI",
|
||||
"AWS_SECRET_ACCESS_KEY",
|
||||
"AWS_SECURITY_TOKEN",
|
||||
"AWS_SESSION_TOKEN",
|
||||
"AWS_SHARED_CREDENTIALS_FILE",
|
||||
"AWS_WEB_IDENTITY_TOKEN_FILE",
|
||||
"AZURE_AUTH_LOCATION",
|
||||
"AZURE_CLIENT_ID",
|
||||
"AZURE_CLIENT_SECRET",
|
||||
"BUN_CONFIG_REGISTRY",
|
||||
"BUNDLE_GEMFILE",
|
||||
"C_INCLUDE_PATH",
|
||||
"CARGO_BUILD_RUSTC_WRAPPER",
|
||||
"CARGO_HOME",
|
||||
"CFLAGS",
|
||||
"CGO_CFLAGS",
|
||||
"CGO_LDFLAGS",
|
||||
"CLASSPATH",
|
||||
@@ -338,7 +82,6 @@ enum HostEnvSecurityPolicy {
|
||||
"CPLUS_INCLUDE_PATH",
|
||||
"CURL_CA_BUNDLE",
|
||||
"CURL_HOME",
|
||||
"DATABASE_URL",
|
||||
"DENO_DIR",
|
||||
"DOCKER_CERT_PATH",
|
||||
"DOCKER_CONTEXT",
|
||||
@@ -348,7 +91,6 @@ enum HostEnvSecurityPolicy {
|
||||
"FCEDIT",
|
||||
"GEM_HOME",
|
||||
"GEM_PATH",
|
||||
"GH_TOKEN",
|
||||
"GIT_ALTERNATE_OBJECT_DIRECTORIES",
|
||||
"GIT_ASKPASS",
|
||||
"GIT_COMMON_DIR",
|
||||
@@ -364,8 +106,6 @@ enum HostEnvSecurityPolicy {
|
||||
"GIT_SSL_CAPATH",
|
||||
"GIT_SSL_NO_VERIFY",
|
||||
"GIT_WORK_TREE",
|
||||
"GITHUB_TOKEN",
|
||||
"GITLAB_TOKEN",
|
||||
"GOENV",
|
||||
"GOFLAGS",
|
||||
"GONOPROXY",
|
||||
@@ -383,7 +123,6 @@ enum HostEnvSecurityPolicy {
|
||||
"HTTP_PROXY",
|
||||
"HTTPS_PROXY",
|
||||
"KUBECONFIG",
|
||||
"LDFLAGS",
|
||||
"LESSCLOSE",
|
||||
"LESSOPEN",
|
||||
"LIBRARY_PATH",
|
||||
@@ -392,12 +131,9 @@ enum HostEnvSecurityPolicy {
|
||||
"MAKEFLAGS",
|
||||
"MANPAGER",
|
||||
"MFLAGS",
|
||||
"MONGODB_URI",
|
||||
"NO_PROXY",
|
||||
"NODE_AUTH_TOKEN",
|
||||
"NODE_EXTRA_CA_CERTS",
|
||||
"NODE_TLS_REJECT_UNAUTHORIZED",
|
||||
"NPM_TOKEN",
|
||||
"OBJC_INCLUDE_PATH",
|
||||
"OPENSSL_CONF",
|
||||
"OPENSSL_ENGINES",
|
||||
@@ -415,18 +151,13 @@ enum HostEnvSecurityPolicy {
|
||||
"PROMPT_COMMAND",
|
||||
"PYTHONSTARTUP",
|
||||
"PYTHONUSERBASE",
|
||||
"R_LIBS_USER",
|
||||
"REDIS_URL",
|
||||
"REQUESTS_CA_BUNDLE",
|
||||
"RUSTC_WRAPPER",
|
||||
"RUSTFLAGS",
|
||||
"SSH_ASKPASS",
|
||||
"SSH_AUTH_SOCK",
|
||||
"SSL_CERT_DIR",
|
||||
"SSL_CERT_FILE",
|
||||
"SUDO_EDITOR",
|
||||
"TF_CLI_CONFIG_FILE",
|
||||
"TF_PLUGIN_CACHE_DIR",
|
||||
"UV_DEFAULT_INDEX",
|
||||
"UV_EXTRA_INDEX_URL",
|
||||
"UV_INDEX",
|
||||
@@ -435,7 +166,6 @@ enum HostEnvSecurityPolicy {
|
||||
"VIRTUAL_ENV",
|
||||
"VISUAL",
|
||||
"WGETRC",
|
||||
"XDG_CONFIG_DIRS",
|
||||
"XDG_CONFIG_HOME",
|
||||
"YARN_RC_FILENAME",
|
||||
"ZDOTDIR"
|
||||
@@ -444,8 +174,7 @@ enum HostEnvSecurityPolicy {
|
||||
static let blockedOverridePrefixes: [String] = [
|
||||
"CARGO_REGISTRIES_",
|
||||
"GIT_CONFIG_",
|
||||
"NPM_CONFIG_",
|
||||
"TF_VAR_"
|
||||
"NPM_CONFIG_"
|
||||
]
|
||||
|
||||
static let blockedPrefixes: [String] = [
|
||||
|
||||
@@ -2510,20 +2510,17 @@ public struct AgentSummary: Codable, Sendable {
|
||||
public struct AgentsCreateParams: Codable, Sendable {
|
||||
public let name: String
|
||||
public let workspace: String
|
||||
public let model: String?
|
||||
public let emoji: String?
|
||||
public let avatar: String?
|
||||
|
||||
public init(
|
||||
name: String,
|
||||
workspace: String,
|
||||
model: String?,
|
||||
emoji: String?,
|
||||
avatar: String?)
|
||||
{
|
||||
self.name = name
|
||||
self.workspace = workspace
|
||||
self.model = model
|
||||
self.emoji = emoji
|
||||
self.avatar = avatar
|
||||
}
|
||||
@@ -2531,7 +2528,6 @@ public struct AgentsCreateParams: Codable, Sendable {
|
||||
private enum CodingKeys: String, CodingKey {
|
||||
case name
|
||||
case workspace
|
||||
case model
|
||||
case emoji
|
||||
case avatar
|
||||
}
|
||||
@@ -2542,20 +2538,17 @@ public struct AgentsCreateResult: Codable, Sendable {
|
||||
public let agentid: String
|
||||
public let name: String
|
||||
public let workspace: String
|
||||
public let model: String?
|
||||
|
||||
public init(
|
||||
ok: Bool,
|
||||
agentid: String,
|
||||
name: String,
|
||||
workspace: String,
|
||||
model: String?)
|
||||
workspace: String)
|
||||
{
|
||||
self.ok = ok
|
||||
self.agentid = agentid
|
||||
self.name = name
|
||||
self.workspace = workspace
|
||||
self.model = model
|
||||
}
|
||||
|
||||
private enum CodingKeys: String, CodingKey {
|
||||
@@ -2563,7 +2556,6 @@ public struct AgentsCreateResult: Codable, Sendable {
|
||||
case agentid = "agentId"
|
||||
case name
|
||||
case workspace
|
||||
case model
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2572,7 +2564,6 @@ public struct AgentsUpdateParams: Codable, Sendable {
|
||||
public let name: String?
|
||||
public let workspace: String?
|
||||
public let model: String?
|
||||
public let emoji: String?
|
||||
public let avatar: String?
|
||||
|
||||
public init(
|
||||
@@ -2580,14 +2571,12 @@ public struct AgentsUpdateParams: Codable, Sendable {
|
||||
name: String?,
|
||||
workspace: String?,
|
||||
model: String?,
|
||||
emoji: String?,
|
||||
avatar: String?)
|
||||
{
|
||||
self.agentid = agentid
|
||||
self.name = name
|
||||
self.workspace = workspace
|
||||
self.model = model
|
||||
self.emoji = emoji
|
||||
self.avatar = avatar
|
||||
}
|
||||
|
||||
@@ -2596,7 +2585,6 @@ public struct AgentsUpdateParams: Codable, Sendable {
|
||||
case name
|
||||
case workspace
|
||||
case model
|
||||
case emoji
|
||||
case avatar
|
||||
}
|
||||
}
|
||||
@@ -2895,92 +2883,6 @@ public struct ModelsListResult: Codable, Sendable {
|
||||
}
|
||||
}
|
||||
|
||||
public struct CommandEntry: Codable, Sendable {
|
||||
public let name: String
|
||||
public let nativename: String?
|
||||
public let textaliases: [String]?
|
||||
public let description: String
|
||||
public let category: AnyCodable?
|
||||
public let source: AnyCodable
|
||||
public let scope: AnyCodable
|
||||
public let acceptsargs: Bool
|
||||
public let args: [[String: AnyCodable]]?
|
||||
|
||||
public init(
|
||||
name: String,
|
||||
nativename: String?,
|
||||
textaliases: [String]?,
|
||||
description: String,
|
||||
category: AnyCodable?,
|
||||
source: AnyCodable,
|
||||
scope: AnyCodable,
|
||||
acceptsargs: Bool,
|
||||
args: [[String: AnyCodable]]?)
|
||||
{
|
||||
self.name = name
|
||||
self.nativename = nativename
|
||||
self.textaliases = textaliases
|
||||
self.description = description
|
||||
self.category = category
|
||||
self.source = source
|
||||
self.scope = scope
|
||||
self.acceptsargs = acceptsargs
|
||||
self.args = args
|
||||
}
|
||||
|
||||
private enum CodingKeys: String, CodingKey {
|
||||
case name
|
||||
case nativename = "nativeName"
|
||||
case textaliases = "textAliases"
|
||||
case description
|
||||
case category
|
||||
case source
|
||||
case scope
|
||||
case acceptsargs = "acceptsArgs"
|
||||
case args
|
||||
}
|
||||
}
|
||||
|
||||
public struct CommandsListParams: Codable, Sendable {
|
||||
public let agentid: String?
|
||||
public let provider: String?
|
||||
public let scope: AnyCodable?
|
||||
public let includeargs: Bool?
|
||||
|
||||
public init(
|
||||
agentid: String?,
|
||||
provider: String?,
|
||||
scope: AnyCodable?,
|
||||
includeargs: Bool?)
|
||||
{
|
||||
self.agentid = agentid
|
||||
self.provider = provider
|
||||
self.scope = scope
|
||||
self.includeargs = includeargs
|
||||
}
|
||||
|
||||
private enum CodingKeys: String, CodingKey {
|
||||
case agentid = "agentId"
|
||||
case provider
|
||||
case scope
|
||||
case includeargs = "includeArgs"
|
||||
}
|
||||
}
|
||||
|
||||
public struct CommandsListResult: Codable, Sendable {
|
||||
public let commands: [CommandEntry]
|
||||
|
||||
public init(
|
||||
commands: [CommandEntry])
|
||||
{
|
||||
self.commands = commands
|
||||
}
|
||||
|
||||
private enum CodingKeys: String, CodingKey {
|
||||
case commands
|
||||
}
|
||||
}
|
||||
|
||||
public struct SkillsStatusParams: Codable, Sendable {
|
||||
public let agentid: String?
|
||||
|
||||
@@ -4272,7 +4174,6 @@ public struct ChatEvent: Codable, Sendable {
|
||||
public let state: AnyCodable
|
||||
public let message: AnyCodable?
|
||||
public let errormessage: String?
|
||||
public let errorkind: AnyCodable?
|
||||
public let usage: AnyCodable?
|
||||
public let stopreason: String?
|
||||
|
||||
@@ -4283,7 +4184,6 @@ public struct ChatEvent: Codable, Sendable {
|
||||
state: AnyCodable,
|
||||
message: AnyCodable?,
|
||||
errormessage: String?,
|
||||
errorkind: AnyCodable?,
|
||||
usage: AnyCodable?,
|
||||
stopreason: String?)
|
||||
{
|
||||
@@ -4293,7 +4193,6 @@ public struct ChatEvent: Codable, Sendable {
|
||||
self.state = state
|
||||
self.message = message
|
||||
self.errormessage = errormessage
|
||||
self.errorkind = errorkind
|
||||
self.usage = usage
|
||||
self.stopreason = stopreason
|
||||
}
|
||||
@@ -4305,7 +4204,6 @@ public struct ChatEvent: Codable, Sendable {
|
||||
case state
|
||||
case message
|
||||
case errormessage = "errorMessage"
|
||||
case errorkind = "errorKind"
|
||||
case usage
|
||||
case stopreason = "stopReason"
|
||||
}
|
||||
|
||||
@@ -2510,20 +2510,17 @@ public struct AgentSummary: Codable, Sendable {
|
||||
public struct AgentsCreateParams: Codable, Sendable {
|
||||
public let name: String
|
||||
public let workspace: String
|
||||
public let model: String?
|
||||
public let emoji: String?
|
||||
public let avatar: String?
|
||||
|
||||
public init(
|
||||
name: String,
|
||||
workspace: String,
|
||||
model: String?,
|
||||
emoji: String?,
|
||||
avatar: String?)
|
||||
{
|
||||
self.name = name
|
||||
self.workspace = workspace
|
||||
self.model = model
|
||||
self.emoji = emoji
|
||||
self.avatar = avatar
|
||||
}
|
||||
@@ -2531,7 +2528,6 @@ public struct AgentsCreateParams: Codable, Sendable {
|
||||
private enum CodingKeys: String, CodingKey {
|
||||
case name
|
||||
case workspace
|
||||
case model
|
||||
case emoji
|
||||
case avatar
|
||||
}
|
||||
@@ -2542,20 +2538,17 @@ public struct AgentsCreateResult: Codable, Sendable {
|
||||
public let agentid: String
|
||||
public let name: String
|
||||
public let workspace: String
|
||||
public let model: String?
|
||||
|
||||
public init(
|
||||
ok: Bool,
|
||||
agentid: String,
|
||||
name: String,
|
||||
workspace: String,
|
||||
model: String?)
|
||||
workspace: String)
|
||||
{
|
||||
self.ok = ok
|
||||
self.agentid = agentid
|
||||
self.name = name
|
||||
self.workspace = workspace
|
||||
self.model = model
|
||||
}
|
||||
|
||||
private enum CodingKeys: String, CodingKey {
|
||||
@@ -2563,7 +2556,6 @@ public struct AgentsCreateResult: Codable, Sendable {
|
||||
case agentid = "agentId"
|
||||
case name
|
||||
case workspace
|
||||
case model
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2572,7 +2564,6 @@ public struct AgentsUpdateParams: Codable, Sendable {
|
||||
public let name: String?
|
||||
public let workspace: String?
|
||||
public let model: String?
|
||||
public let emoji: String?
|
||||
public let avatar: String?
|
||||
|
||||
public init(
|
||||
@@ -2580,14 +2571,12 @@ public struct AgentsUpdateParams: Codable, Sendable {
|
||||
name: String?,
|
||||
workspace: String?,
|
||||
model: String?,
|
||||
emoji: String?,
|
||||
avatar: String?)
|
||||
{
|
||||
self.agentid = agentid
|
||||
self.name = name
|
||||
self.workspace = workspace
|
||||
self.model = model
|
||||
self.emoji = emoji
|
||||
self.avatar = avatar
|
||||
}
|
||||
|
||||
@@ -2596,7 +2585,6 @@ public struct AgentsUpdateParams: Codable, Sendable {
|
||||
case name
|
||||
case workspace
|
||||
case model
|
||||
case emoji
|
||||
case avatar
|
||||
}
|
||||
}
|
||||
@@ -2895,92 +2883,6 @@ public struct ModelsListResult: Codable, Sendable {
|
||||
}
|
||||
}
|
||||
|
||||
public struct CommandEntry: Codable, Sendable {
|
||||
public let name: String
|
||||
public let nativename: String?
|
||||
public let textaliases: [String]?
|
||||
public let description: String
|
||||
public let category: AnyCodable?
|
||||
public let source: AnyCodable
|
||||
public let scope: AnyCodable
|
||||
public let acceptsargs: Bool
|
||||
public let args: [[String: AnyCodable]]?
|
||||
|
||||
public init(
|
||||
name: String,
|
||||
nativename: String?,
|
||||
textaliases: [String]?,
|
||||
description: String,
|
||||
category: AnyCodable?,
|
||||
source: AnyCodable,
|
||||
scope: AnyCodable,
|
||||
acceptsargs: Bool,
|
||||
args: [[String: AnyCodable]]?)
|
||||
{
|
||||
self.name = name
|
||||
self.nativename = nativename
|
||||
self.textaliases = textaliases
|
||||
self.description = description
|
||||
self.category = category
|
||||
self.source = source
|
||||
self.scope = scope
|
||||
self.acceptsargs = acceptsargs
|
||||
self.args = args
|
||||
}
|
||||
|
||||
private enum CodingKeys: String, CodingKey {
|
||||
case name
|
||||
case nativename = "nativeName"
|
||||
case textaliases = "textAliases"
|
||||
case description
|
||||
case category
|
||||
case source
|
||||
case scope
|
||||
case acceptsargs = "acceptsArgs"
|
||||
case args
|
||||
}
|
||||
}
|
||||
|
||||
public struct CommandsListParams: Codable, Sendable {
|
||||
public let agentid: String?
|
||||
public let provider: String?
|
||||
public let scope: AnyCodable?
|
||||
public let includeargs: Bool?
|
||||
|
||||
public init(
|
||||
agentid: String?,
|
||||
provider: String?,
|
||||
scope: AnyCodable?,
|
||||
includeargs: Bool?)
|
||||
{
|
||||
self.agentid = agentid
|
||||
self.provider = provider
|
||||
self.scope = scope
|
||||
self.includeargs = includeargs
|
||||
}
|
||||
|
||||
private enum CodingKeys: String, CodingKey {
|
||||
case agentid = "agentId"
|
||||
case provider
|
||||
case scope
|
||||
case includeargs = "includeArgs"
|
||||
}
|
||||
}
|
||||
|
||||
public struct CommandsListResult: Codable, Sendable {
|
||||
public let commands: [CommandEntry]
|
||||
|
||||
public init(
|
||||
commands: [CommandEntry])
|
||||
{
|
||||
self.commands = commands
|
||||
}
|
||||
|
||||
private enum CodingKeys: String, CodingKey {
|
||||
case commands
|
||||
}
|
||||
}
|
||||
|
||||
public struct SkillsStatusParams: Codable, Sendable {
|
||||
public let agentid: String?
|
||||
|
||||
@@ -4272,7 +4174,6 @@ public struct ChatEvent: Codable, Sendable {
|
||||
public let state: AnyCodable
|
||||
public let message: AnyCodable?
|
||||
public let errormessage: String?
|
||||
public let errorkind: AnyCodable?
|
||||
public let usage: AnyCodable?
|
||||
public let stopreason: String?
|
||||
|
||||
@@ -4283,7 +4184,6 @@ public struct ChatEvent: Codable, Sendable {
|
||||
state: AnyCodable,
|
||||
message: AnyCodable?,
|
||||
errormessage: String?,
|
||||
errorkind: AnyCodable?,
|
||||
usage: AnyCodable?,
|
||||
stopreason: String?)
|
||||
{
|
||||
@@ -4293,7 +4193,6 @@ public struct ChatEvent: Codable, Sendable {
|
||||
self.state = state
|
||||
self.message = message
|
||||
self.errormessage = errormessage
|
||||
self.errorkind = errorkind
|
||||
self.usage = usage
|
||||
self.stopreason = stopreason
|
||||
}
|
||||
@@ -4305,7 +4204,6 @@ public struct ChatEvent: Codable, Sendable {
|
||||
case state
|
||||
case message
|
||||
case errormessage = "errorMessage"
|
||||
case errorkind = "errorKind"
|
||||
case usage
|
||||
case stopreason = "stopReason"
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
1977d4698bb80b9aa99315f1114a61b5692bd5630f2ac4a225d81ddc5459d588 config-baseline.json
|
||||
d1ee5c4d01deac5cf8ea284cafcd8b6c952b2554d40947d2463d08e314acfcda config-baseline.core.json
|
||||
e1f94346a8507ce3dec763b598e79f3bb89ff2e33189ce977cc87d3b05e71c1d config-baseline.channel.json
|
||||
0fb10e5cb00e7da2cd07c959e0e3397ecb2fdcf15e13a7eae06a2c5b2346bb10 config-baseline.plugin.json
|
||||
0a75b57f5dbb0bb1488eacb47111ee22ff42dd3747bfe07bb69c9445d5e55c3e config-baseline.json
|
||||
ff15bb8b4231fc80174249ae89bcb61439d7adda5ee6be95e4d304680253a59f config-baseline.core.json
|
||||
7f42b22b46c487d64aaac46001ba9d9096cf7bf0b1c263a54d39946303ff5018 config-baseline.channel.json
|
||||
483d4f3c1d516719870ad6f2aba6779b9950f85471ee77b9994a077a7574a892 config-baseline.plugin.json
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
2256ba1237c3608ca981bce3a7c66b6880b12d05025f260d5c086b69038f408b plugin-sdk-api-baseline.json
|
||||
6360529513280140c122020466f0821a9acc83aba64612cf90656c2af0261ab3 plugin-sdk-api-baseline.jsonl
|
||||
087dc7fe9759330c953a00130ea20242b3d7f460eaa530d631cfb2a9f96e0370 plugin-sdk-api-baseline.json
|
||||
a84765a726e0493dc87d2799020fd454407b1fe2c4d3ad69e8c3cc3a0cde834b plugin-sdk-api-baseline.jsonl
|
||||
|
||||
@@ -43,8 +43,6 @@ together`, and similar hints) and no descendant subagent run is still
|
||||
responsible for the final answer, OpenClaw re-prompts once for the actual
|
||||
result before delivery.
|
||||
|
||||
<a id="maintenance"></a>
|
||||
|
||||
Task reconciliation for cron is runtime-owned: an active cron task stays live while the
|
||||
cron runtime still tracks that job as running, even if an old child session row still exists.
|
||||
Once the runtime stops owning the job and the 5-minute grace window expires, maintenance can
|
||||
|
||||
@@ -164,14 +164,10 @@ Enable any bundled hook:
|
||||
openclaw hooks enable <hook-name>
|
||||
```
|
||||
|
||||
<a id="session-memory"></a>
|
||||
|
||||
### session-memory details
|
||||
|
||||
Extracts the last 15 user/assistant messages, generates a descriptive filename slug via LLM, and saves to `<workspace>/memory/YYYY-MM-DD-slug.md`. Requires `workspace.dir` to be configured.
|
||||
|
||||
<a id="bootstrap-extra-files"></a>
|
||||
|
||||
### bootstrap-extra-files config
|
||||
|
||||
```json
|
||||
@@ -191,18 +187,6 @@ Extracts the last 15 user/assistant messages, generates a descriptive filename s
|
||||
|
||||
Paths resolve relative to workspace. Only recognized bootstrap basenames are loaded (`AGENTS.md`, `SOUL.md`, `TOOLS.md`, `IDENTITY.md`, `USER.md`, `HEARTBEAT.md`, `BOOTSTRAP.md`, `MEMORY.md`).
|
||||
|
||||
<a id="command-logger"></a>
|
||||
|
||||
### command-logger details
|
||||
|
||||
Logs every slash command to `~/.openclaw/logs/commands.log`.
|
||||
|
||||
<a id="boot-md"></a>
|
||||
|
||||
### boot-md details
|
||||
|
||||
Runs `BOOT.md` from the active workspace when the gateway starts.
|
||||
|
||||
## Plugin hooks
|
||||
|
||||
Plugins can register hooks through the Plugin SDK for deeper integration: intercepting tool calls, modifying prompts, controlling message flow, and more. The Plugin SDK exposes 28 hooks covering model resolution, agent lifecycle, message flow, tool execution, subagent coordination, and gateway lifecycle.
|
||||
|
||||
39
docs/ci.md
39
docs/ci.md
@@ -12,25 +12,24 @@ The CI runs on every push to `main` and every pull request. It uses smart scopin
|
||||
|
||||
## Job Overview
|
||||
|
||||
| Job | Purpose | When it runs |
|
||||
| ------------------------ | --------------------------------------------------------------------------------------- | ----------------------------------- |
|
||||
| `preflight` | Detect docs-only changes, changed scopes, changed extensions, and build the CI manifest | Always on non-draft pushes and PRs |
|
||||
| `security-fast` | Private key detection, workflow audit via `zizmor`, production dependency audit | Always on non-draft pushes and PRs |
|
||||
| `build-artifacts` | Build `dist/` and the Control UI once, upload reusable artifacts for downstream jobs | Node-relevant changes |
|
||||
| `checks-fast-core` | Fast Linux correctness lanes such as bundled/plugin-contract/protocol checks | Node-relevant changes |
|
||||
| `checks-node-extensions` | Full bundled-plugin test shards across the extension suite | Node-relevant changes |
|
||||
| `checks-node-core-test` | Core Node test shards, excluding channel, bundled, contract, and extension lanes | Node-relevant changes |
|
||||
| `extension-fast` | Focused tests for only the changed bundled plugins | When extension changes are detected |
|
||||
| `check` | Main local gate in CI: `pnpm check` plus `pnpm build:strict-smoke` | Node-relevant changes |
|
||||
| `check-additional` | Architecture, boundary, import-cycle guards plus the gateway watch regression harness | Node-relevant changes |
|
||||
| `build-smoke` | Built-CLI smoke tests and startup-memory smoke | Node-relevant changes |
|
||||
| `checks` | Remaining Linux Node lanes: channel tests and push-only Node 22 compatibility | Node-relevant changes |
|
||||
| `check-docs` | Docs formatting, lint, and broken-link checks | Docs changed |
|
||||
| `skills-python` | Ruff + pytest for Python-backed skills | Python-skill-relevant changes |
|
||||
| `checks-windows` | Windows-specific test lanes | Windows-relevant changes |
|
||||
| `macos-node` | macOS TypeScript test lane using the shared built artifacts | macOS-relevant changes |
|
||||
| `macos-swift` | Swift lint, build, and tests for the macOS app | macOS-relevant changes |
|
||||
| `android` | Android build and test matrix | Android-relevant changes |
|
||||
| Job | Purpose | When it runs |
|
||||
| ------------------------ | ---------------------------------------------------------------------------------------- | ----------------------------------- |
|
||||
| `preflight` | Detect docs-only changes, changed scopes, changed extensions, and build the CI manifest | Always on non-draft pushes and PRs |
|
||||
| `security-fast` | Private key detection, workflow audit via `zizmor`, production dependency audit | Always on non-draft pushes and PRs |
|
||||
| `build-artifacts` | Build `dist/` and the Control UI once, upload reusable artifacts for downstream jobs | Node-relevant changes |
|
||||
| `checks-fast-core` | Fast Linux correctness lanes such as bundled/plugin-contract/protocol checks | Node-relevant changes |
|
||||
| `checks-fast-extensions` | Aggregate the extension shard lanes after `checks-fast-extensions-shard` completes | Node-relevant changes |
|
||||
| `extension-fast` | Focused tests for only the changed bundled plugins | When extension changes are detected |
|
||||
| `check` | Main local gate in CI: `pnpm check` plus `pnpm build:strict-smoke` | Node-relevant changes |
|
||||
| `check-additional` | Architecture, boundary, import-cycle guards plus the gateway watch regression harness | Node-relevant changes |
|
||||
| `build-smoke` | Built-CLI smoke tests and startup-memory smoke | Node-relevant changes |
|
||||
| `checks` | Heavier Linux Node lanes: full tests, channel tests, and push-only Node 22 compatibility | Node-relevant changes |
|
||||
| `check-docs` | Docs formatting, lint, and broken-link checks | Docs changed |
|
||||
| `skills-python` | Ruff + pytest for Python-backed skills | Python-skill-relevant changes |
|
||||
| `checks-windows` | Windows-specific test lanes | Windows-relevant changes |
|
||||
| `macos-node` | macOS TypeScript test lane using the shared built artifacts | macOS-relevant changes |
|
||||
| `macos-swift` | Swift lint, build, and tests for the macOS app | macOS-relevant changes |
|
||||
| `android` | Android build and test matrix | Android-relevant changes |
|
||||
|
||||
## Fail-Fast Order
|
||||
|
||||
@@ -39,7 +38,7 @@ Jobs are ordered so cheap checks fail before expensive ones run:
|
||||
1. `preflight` decides which lanes exist at all. The `docs-scope` and `changed-scope` logic are steps inside this job, not standalone jobs.
|
||||
2. `security-fast`, `check`, `check-additional`, `check-docs`, and `skills-python` fail quickly without waiting on the heavier artifact and platform matrix jobs.
|
||||
3. `build-artifacts` overlaps with the fast Linux lanes so downstream consumers can start as soon as the shared build is ready.
|
||||
4. Heavier platform and runtime lanes fan out after that: `checks-fast-core`, `checks-node-extensions`, `checks-node-core-test`, `extension-fast`, `checks`, `checks-windows`, `macos-node`, `macos-swift`, and `android`.
|
||||
4. Heavier platform and runtime lanes fan out after that: `checks-fast-core`, `checks-fast-extensions`, `extension-fast`, `checks`, `checks-windows`, `macos-node`, `macos-swift`, and `android`.
|
||||
|
||||
Scope logic lives in `scripts/ci-changed-scope.mjs` and is covered by unit tests in `src/scripts/ci-changed-scope.test.ts`.
|
||||
The separate `install-smoke` workflow reuses the same scope script through its own `preflight` job. It computes `run_install_smoke` from the narrower changed-smoke signal, so Docker/install smoke only runs for install, packaging, and container-relevant changes.
|
||||
|
||||
@@ -37,7 +37,7 @@ Use routing bindings to pin inbound channel traffic to a specific agent.
|
||||
If you also want different visible skills per agent, configure
|
||||
`agents.defaults.skills` and `agents.list[].skills` in `openclaw.json`. See
|
||||
[Skills config](/tools/skills-config) and
|
||||
[Configuration Reference](/gateway/configuration-reference#agents-defaults-skills).
|
||||
[Configuration Reference](/gateway/configuration-reference#agentsdefaultsskills).
|
||||
|
||||
List bindings:
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
---
|
||||
summary: "CLI reference for `openclaw approvals` and `openclaw exec-policy`"
|
||||
summary: "CLI reference for `openclaw approvals` (exec approvals for gateway or node hosts)"
|
||||
read_when:
|
||||
- You want to edit exec approvals from the CLI
|
||||
- You need to manage allowlists on gateway or node hosts
|
||||
@@ -18,45 +18,6 @@ Related:
|
||||
- Exec approvals: [Exec approvals](/tools/exec-approvals)
|
||||
- Nodes: [Nodes](/nodes)
|
||||
|
||||
## `openclaw exec-policy`
|
||||
|
||||
`openclaw exec-policy` is the local convenience command for keeping the requested
|
||||
`tools.exec.*` config and the local host approvals file aligned in one step.
|
||||
|
||||
Use it when you want to:
|
||||
|
||||
- inspect the local requested policy, host approvals file, and effective merge
|
||||
- apply a local preset such as YOLO or deny-all
|
||||
- synchronize local `tools.exec.*` and local `~/.openclaw/exec-approvals.json`
|
||||
|
||||
Examples:
|
||||
|
||||
```bash
|
||||
openclaw exec-policy show
|
||||
openclaw exec-policy show --json
|
||||
|
||||
openclaw exec-policy preset yolo
|
||||
openclaw exec-policy preset cautious --json
|
||||
|
||||
openclaw exec-policy set --host gateway --security full --ask off --ask-fallback full
|
||||
```
|
||||
|
||||
Output modes:
|
||||
|
||||
- no `--json`: prints the human-readable table view
|
||||
- `--json`: prints machine-readable structured output
|
||||
|
||||
Current scope:
|
||||
|
||||
- `exec-policy` is **local-only**
|
||||
- it updates the local config file and the local approvals file together
|
||||
- it does **not** push policy to the gateway host or a node host
|
||||
- `--host node` is rejected in this command because node exec approvals are fetched from the node at runtime and must be managed through node-targeted approvals commands instead
|
||||
- `openclaw exec-policy show` marks `host=node` scopes as node-managed at runtime instead of deriving an effective policy from the local approvals file
|
||||
|
||||
If you need to edit remote host approvals directly, keep using `openclaw approvals set --gateway`
|
||||
or `openclaw approvals set --node <id|name|ip>`.
|
||||
|
||||
## Common commands
|
||||
|
||||
```bash
|
||||
@@ -139,16 +100,6 @@ Why `tools.exec.host=gateway` in this example:
|
||||
|
||||
This matches the current host-default YOLO behavior. Tighten it if you want approvals.
|
||||
|
||||
Local shortcut:
|
||||
|
||||
```bash
|
||||
openclaw exec-policy preset yolo
|
||||
```
|
||||
|
||||
That local shortcut updates both the requested local `tools.exec.*` config and the
|
||||
local approvals defaults together. It is equivalent in intent to the manual two-step
|
||||
setup above, but only for the local machine.
|
||||
|
||||
## Allowlist helpers
|
||||
|
||||
```bash
|
||||
|
||||
@@ -151,7 +151,7 @@ See [Plugin hooks](/plugins/architecture#provider-runtime-hooks) for the hook AP
|
||||
|
||||
- `agent.wait` default: 30s (just the wait). `timeoutMs` param overrides.
|
||||
- Agent runtime: `agents.defaults.timeoutSeconds` default 172800s (48 hours); enforced in `runEmbeddedPiAgent` abort timer.
|
||||
- LLM idle timeout: `agents.defaults.llm.idleTimeoutSeconds` aborts a model request when no response chunks arrive before the idle window. Set it explicitly for slow local models or reasoning/tool-call providers; set it to 0 to disable. If it is not set, OpenClaw uses `agents.defaults.timeoutSeconds` when configured, otherwise 120s. Cron-triggered runs with no explicit LLM or agent timeout disable the idle watchdog and rely on the cron outer timeout.
|
||||
- LLM idle timeout: `agents.defaults.llm.idleTimeoutSeconds` aborts a model request when no response chunks arrive before the idle window. Set it explicitly for slow local models or reasoning/tool-call providers; set it to 0 to disable. If it is not set, OpenClaw uses `agents.defaults.timeoutSeconds` when configured, otherwise 60s. Cron-triggered runs with no explicit LLM or agent timeout disable the idle watchdog and rely on the cron outer timeout.
|
||||
|
||||
## Where things can end early
|
||||
|
||||
|
||||
@@ -50,13 +50,6 @@ For model selection rules, see [/concepts/models](/concepts/models).
|
||||
family, transcript/tooling quirks, transport/cache hints). It is not the
|
||||
same as the [public capability model](/plugins/architecture#public-capability-model)
|
||||
which describes what a plugin registers (text inference, speech, etc.).
|
||||
- The bundled `codex` provider is paired with the bundled Codex agent harness.
|
||||
Use `codex/gpt-*` when you want Codex-owned login, model discovery, native
|
||||
thread resume, and app-server execution. Plain `openai/gpt-*` refs continue
|
||||
to use the OpenAI provider and the normal OpenClaw provider transport.
|
||||
Codex-only deployments can disable automatic PI fallback with
|
||||
`agents.defaults.embeddedHarness.fallback: "none"`; see
|
||||
[Codex Harness](/plugins/codex-harness).
|
||||
|
||||
## Plugin-owned provider behavior
|
||||
|
||||
|
||||
@@ -62,10 +62,6 @@ This boots a fresh Multipass guest, installs dependencies, builds OpenClaw
|
||||
inside the guest, runs `qa suite`, then copies the normal QA report and
|
||||
summary back into `.artifacts/qa-e2e/...` on the host.
|
||||
It reuses the same scenario-selection behavior as `qa suite` on the host.
|
||||
Host and Multipass suite runs execute multiple selected scenarios in parallel
|
||||
with isolated gateway workers by default, up to 64 workers or the selected
|
||||
scenario count. Use `--concurrency <count>` to tune the worker count, or
|
||||
`--concurrency 1` for serial execution.
|
||||
Live runs forward the supported QA auth inputs that are practical for the
|
||||
guest: env-based provider keys, the QA live provider config path, and
|
||||
`CODEX_HOME` when present. Keep `--output-dir` under the repo root so the guest
|
||||
|
||||
@@ -1074,7 +1074,6 @@
|
||||
"concepts/memory-qmd",
|
||||
"concepts/memory-honcho",
|
||||
"concepts/memory-search",
|
||||
"concepts/active-memory",
|
||||
"concepts/dreaming"
|
||||
]
|
||||
},
|
||||
@@ -1113,7 +1112,6 @@
|
||||
"tools/plugin",
|
||||
"plugins/community",
|
||||
"plugins/bundles",
|
||||
"plugins/codex-harness",
|
||||
"plugins/webhooks",
|
||||
"plugins/voice-call",
|
||||
{
|
||||
@@ -1131,7 +1129,6 @@
|
||||
"plugins/sdk-overview",
|
||||
"plugins/sdk-entrypoints",
|
||||
"plugins/sdk-runtime",
|
||||
"plugins/sdk-agent-harness",
|
||||
"plugins/sdk-setup",
|
||||
"plugins/sdk-testing",
|
||||
"plugins/manifest",
|
||||
|
||||
@@ -159,14 +159,6 @@ model_instructions_file="..."`). Codex does not expose a Claude-style
|
||||
`--append-system-prompt` flag, so OpenClaw writes the assembled prompt to a
|
||||
temporary file for each fresh Codex CLI session.
|
||||
|
||||
The bundled Anthropic `claude-cli` backend receives the OpenClaw skills snapshot
|
||||
two ways: the compact OpenClaw skills catalog in the appended system prompt, and
|
||||
a temporary Claude Code plugin passed with `--plugin-dir`. The plugin contains
|
||||
only the eligible skills for that agent/session, so Claude Code's native skill
|
||||
resolver sees the same filtered set that OpenClaw would otherwise advertise in
|
||||
the prompt. Skill env/API key overrides are still applied by OpenClaw to the
|
||||
child process environment for the run.
|
||||
|
||||
## Sessions
|
||||
|
||||
- If the CLI supports sessions, set `sessionArg` (e.g. `--session-id`) or
|
||||
|
||||
@@ -1053,10 +1053,6 @@ Time format in system prompt. Default: `auto` (OS preference).
|
||||
fallbacks: ["openai/gpt-5.4-mini"],
|
||||
},
|
||||
params: { cacheRetention: "long" }, // global default provider params
|
||||
embeddedHarness: {
|
||||
runtime: "auto", // auto | pi | registered harness id, e.g. codex
|
||||
fallback: "pi", // pi | none
|
||||
},
|
||||
pdfMaxBytesMb: 10,
|
||||
pdfMaxPages: 20,
|
||||
thinkingDefault: "low",
|
||||
@@ -1104,37 +1100,9 @@ Time format in system prompt. Default: `auto` (OS preference).
|
||||
- `models`: the configured model catalog and allowlist for `/model`. Each entry can include `alias` (shortcut) and `params` (provider-specific, for example `temperature`, `maxTokens`, `cacheRetention`, `context1m`).
|
||||
- `params`: global default provider parameters applied to all models. Set at `agents.defaults.params` (e.g. `{ cacheRetention: "long" }`).
|
||||
- `params` merge precedence (config): `agents.defaults.params` (global base) is overridden by `agents.defaults.models["provider/model"].params` (per-model), then `agents.list[].params` (matching agent id) overrides by key. See [Prompt Caching](/reference/prompt-caching) for details.
|
||||
- `embeddedHarness`: default low-level embedded agent runtime policy. Use `runtime: "auto"` to let registered plugin harnesses claim supported models, `runtime: "pi"` to force the built-in PI harness, or a registered harness id such as `runtime: "codex"`. Set `fallback: "none"` to disable automatic PI fallback.
|
||||
- Config writers that mutate these fields (for example `/models set`, `/models set-image`, and fallback add/remove commands) save canonical object form and preserve existing fallback lists when possible.
|
||||
- `maxConcurrent`: max parallel agent runs across sessions (each session still serialized). Default: 4.
|
||||
|
||||
### `agents.defaults.embeddedHarness`
|
||||
|
||||
`embeddedHarness` controls which low-level executor runs embedded agent turns.
|
||||
Most deployments should keep the default `{ runtime: "auto", fallback: "pi" }`.
|
||||
Use it when a trusted plugin provides a native harness, such as the bundled
|
||||
Codex app-server harness.
|
||||
|
||||
```json5
|
||||
{
|
||||
agents: {
|
||||
defaults: {
|
||||
model: "codex/gpt-5.4",
|
||||
embeddedHarness: {
|
||||
runtime: "codex",
|
||||
fallback: "none",
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
```
|
||||
|
||||
- `runtime`: `"auto"`, `"pi"`, or a registered plugin harness id. The bundled Codex plugin registers `codex`.
|
||||
- `fallback`: `"pi"` or `"none"`. `"pi"` keeps the built-in PI harness as the compatibility fallback. `"none"` makes missing or unsupported plugin harness selection fail instead of silently using PI.
|
||||
- Environment overrides: `OPENCLAW_AGENT_RUNTIME=<id|auto|pi>` overrides `runtime`; `OPENCLAW_AGENT_HARNESS_FALLBACK=none` disables PI fallback for that process.
|
||||
- For Codex-only deployments, set `model: "codex/gpt-5.4"`, `embeddedHarness.runtime: "codex"`, and `embeddedHarness.fallback: "none"`.
|
||||
- This only controls the embedded chat harness. Media generation, vision, PDF, music, video, and TTS still use their provider/model settings.
|
||||
|
||||
**Built-in alias shorthands** (only apply when the model is in `agents.defaults.models`):
|
||||
|
||||
| Alias | Model |
|
||||
@@ -1615,7 +1583,6 @@ scripts/sandbox-browser-setup.sh # optional browser image
|
||||
thinkingDefault: "high", // per-agent thinking level override
|
||||
reasoningDefault: "on", // per-agent reasoning visibility override
|
||||
fastModeDefault: false, // per-agent fast mode override
|
||||
embeddedHarness: { runtime: "auto", fallback: "pi" },
|
||||
params: { cacheRetention: "none" }, // overrides matching defaults.models params by key
|
||||
skills: ["docs-search"], // replaces agents.defaults.skills when set
|
||||
identity: {
|
||||
@@ -1656,7 +1623,6 @@ scripts/sandbox-browser-setup.sh # optional browser image
|
||||
- `thinkingDefault`: optional per-agent default thinking level (`off | minimal | low | medium | high | xhigh | adaptive`). Overrides `agents.defaults.thinkingDefault` for this agent when no per-message or session override is set.
|
||||
- `reasoningDefault`: optional per-agent default reasoning visibility (`on | off | stream`). Applies when no per-message or session reasoning override is set.
|
||||
- `fastModeDefault`: optional per-agent default for fast mode (`true | false`). Applies when no per-message or session fast-mode override is set.
|
||||
- `embeddedHarness`: optional per-agent low-level harness policy override. Use `{ runtime: "codex", fallback: "none" }` to make one agent Codex-only while other agents keep the default PI fallback.
|
||||
- `runtime`: optional per-agent runtime descriptor. Use `type: "acp"` with `runtime.acp` defaults (`agent`, `backend`, `mode`, `cwd`) when the agent should default to ACP harness sessions.
|
||||
- `identity.avatar`: workspace-relative path, `http(s)` URL, or `data:` URI.
|
||||
- `identity` derives defaults: `ackReaction` from `emoji`, `mentionPatterns` from `name`/`emoji`.
|
||||
@@ -2333,7 +2299,7 @@ Notes:
|
||||
|
||||
### `tools.experimental`
|
||||
|
||||
Experimental built-in tool flags. Default off unless a strict-agentic GPT-5 auto-enable rule applies.
|
||||
Experimental built-in tool flags. Default off unless a runtime-specific auto-enable rule applies.
|
||||
|
||||
```json5
|
||||
{
|
||||
@@ -2348,7 +2314,7 @@ Experimental built-in tool flags. Default off unless a strict-agentic GPT-5 auto
|
||||
Notes:
|
||||
|
||||
- `planTool`: enables the structured `update_plan` tool for non-trivial multi-step work tracking.
|
||||
- Default: `false` unless `agents.defaults.embeddedPi.executionContract` (or a per-agent override) is set to `"strict-agentic"` for an OpenAI or OpenAI Codex GPT-5-family run. Set `true` to force the tool on outside that scope, or `false` to keep it off even for strict-agentic GPT-5 runs.
|
||||
- Default: `false` for non-OpenAI providers. OpenAI and OpenAI Codex runs auto-enable it when unset; set `false` to disable that auto-enable.
|
||||
- When enabled, the system prompt also adds usage guidance so the model only uses it for substantial work and keeps at most one step `in_progress`.
|
||||
|
||||
### `agents.defaults.subagents`
|
||||
@@ -2792,7 +2758,7 @@ See [Plugins](/tools/plugin).
|
||||
evaluateEnabled: true,
|
||||
defaultProfile: "user",
|
||||
ssrfPolicy: {
|
||||
// dangerouslyAllowPrivateNetwork: true, // opt in only for trusted private-network access
|
||||
dangerouslyAllowPrivateNetwork: true, // default trusted-network mode
|
||||
// allowPrivateNetwork: true, // legacy alias
|
||||
// hostnameAllowlist: ["*.example.com", "example.com"],
|
||||
// allowedHostnames: ["localhost"],
|
||||
@@ -2820,8 +2786,8 @@ See [Plugins](/tools/plugin).
|
||||
```
|
||||
|
||||
- `evaluateEnabled: false` disables `act:evaluate` and `wait --fn`.
|
||||
- `ssrfPolicy.dangerouslyAllowPrivateNetwork` is disabled when unset, so browser navigation stays strict by default.
|
||||
- Set `ssrfPolicy.dangerouslyAllowPrivateNetwork: true` only when you intentionally trust private-network browser navigation.
|
||||
- `ssrfPolicy.dangerouslyAllowPrivateNetwork` defaults to `true` when unset (trusted-network model).
|
||||
- Set `ssrfPolicy.dangerouslyAllowPrivateNetwork: false` for strict public-only browser navigation.
|
||||
- In strict mode, remote CDP profile endpoints (`profiles.*.cdpUrl`) are subject to the same private-network blocking during reachability/discovery checks.
|
||||
- `ssrfPolicy.allowPrivateNetwork` remains supported as a legacy alias.
|
||||
- In strict mode, use `ssrfPolicy.hostnameAllowlist` and `ssrfPolicy.allowedHostnames` for explicit exceptions.
|
||||
@@ -2893,6 +2859,7 @@ See [Plugins](/tools/plugin).
|
||||
enabled: true,
|
||||
basePath: "/openclaw",
|
||||
// root: "dist/control-ui",
|
||||
// embedSandbox: "powerful", // powerful | isolated
|
||||
// allowedOrigins: ["https://control.example.com"], // required for non-loopback Control UI
|
||||
// dangerouslyAllowHostHeaderOriginFallback: false, // dangerous Host-header origin fallback mode
|
||||
// allowInsecureAuth: false,
|
||||
|
||||
@@ -224,7 +224,7 @@ When validation fails:
|
||||
- Omit `agents.list[].skills` to inherit the defaults.
|
||||
- Set `agents.list[].skills: []` for no skills.
|
||||
- See [Skills](/tools/skills), [Skills config](/tools/skills-config), and
|
||||
the [Configuration Reference](/gateway/configuration-reference#agents-defaults-skills).
|
||||
the [Configuration Reference](/gateway/configuration-reference#agentsdefaultsskills).
|
||||
|
||||
</Accordion>
|
||||
|
||||
|
||||
@@ -400,7 +400,7 @@ implemented in `src/gateway/server-methods/*.ts`.
|
||||
- `wake` schedules an immediate or next-heartbeat wake text injection
|
||||
- `cron.list`, `cron.status`, `cron.add`, `cron.update`, `cron.remove`,
|
||||
`cron.run`, `cron.runs`
|
||||
- skills/tools: `commands.list`, `skills.*`, `tools.catalog`, `tools.effective`
|
||||
- skills/tools: `skills.*`, `tools.catalog`, `tools.effective`
|
||||
|
||||
### Common event families
|
||||
|
||||
@@ -431,18 +431,6 @@ implemented in `src/gateway/server-methods/*.ts`.
|
||||
|
||||
### Operator helper methods
|
||||
|
||||
- Operators may call `commands.list` (`operator.read`) to fetch the runtime
|
||||
command inventory for an agent.
|
||||
- `agentId` is optional; omit it to read the default agent workspace.
|
||||
- `scope` controls which surface the primary `name` targets:
|
||||
- `text` returns the primary text command token without the leading `/`
|
||||
- `native` and the default `both` path return provider-aware native names
|
||||
when available
|
||||
- `textAliases` carries exact slash aliases such as `/model` and `/m`.
|
||||
- `nativeName` carries the provider-aware native command name when one exists.
|
||||
- `provider` is optional and only affects native naming plus native plugin
|
||||
command availability.
|
||||
- `includeArgs=false` omits serialized argument metadata from the response.
|
||||
- Operators may call `tools.catalog` (`operator.read`) to fetch the runtime tool catalog for an
|
||||
agent. The response includes grouped tools and provenance metadata:
|
||||
- `source`: `core` or `plugin`
|
||||
|
||||
@@ -13,7 +13,7 @@ OpenClaw is **not** a hostile multi-tenant security boundary for multiple advers
|
||||
If you need mixed-trust or adversarial-user operation, split trust boundaries (separate gateway + credentials, ideally separate OS users/hosts).
|
||||
</Warning>
|
||||
|
||||
**On this page:** [Trust model](#scope-first-personal-assistant-security-model) | [Quick audit](#quick-check-openclaw-security-audit) | [Hardened baseline](#hardened-baseline-in-60-seconds) | [DM access model](#dm-access-model-pairing-allowlist-open-disabled) | [Configuration hardening](#configuration-hardening-examples) | [Incident response](#incident-response)
|
||||
**On this page:** [Trust model](#scope-first-personal-assistant-security-model) | [Quick audit](#quick-check-openclaw-security-audit) | [Hardened baseline](#hardened-baseline-in-60-seconds) | [DM access model](#dm-access-model-pairing--allowlist--open--disabled) | [Configuration hardening](#configuration-hardening-examples) | [Incident response](#incident-response)
|
||||
|
||||
## Scope first: personal assistant security model
|
||||
|
||||
@@ -187,7 +187,7 @@ Allowlists gate triggers and command authorization. The `contextVisibility` sett
|
||||
- `contextVisibility: "allowlist"` filters supplemental context to senders allowed by the active allowlist checks.
|
||||
- `contextVisibility: "allowlist_quote"` behaves like `allowlist`, but still keeps one explicit quoted reply.
|
||||
|
||||
Set `contextVisibility` per channel or per room/conversation. See [Group Chats](/channels/groups#context-visibility-and-allowlists) for setup details.
|
||||
Set `contextVisibility` per channel or per room/conversation. See [Group Chats](/channels/groups#context-visibility) for setup details.
|
||||
|
||||
Advisory triage guidance:
|
||||
|
||||
@@ -579,8 +579,6 @@ Plugins run **in-process** with the Gateway. Treat them as trusted code:
|
||||
|
||||
Details: [Plugins](/tools/plugin)
|
||||
|
||||
<a id="dm-access-model-pairing-allowlist-open-disabled"></a>
|
||||
|
||||
## DM access model (pairing / allowlist / open / disabled)
|
||||
|
||||
All current DM-capable channels support a DM policy (`dmPolicy` or `*.dm.policy`) that gates inbound DMs **before** the message is processed:
|
||||
@@ -1151,13 +1149,13 @@ access those accounts and data. Treat browser profiles as **sensitive state**:
|
||||
- Disable browser proxy routing when you don’t need it (`gateway.nodes.browser.mode="off"`).
|
||||
- Chrome MCP existing-session mode is **not** “safer”; it can act as you in whatever that host Chrome profile can reach.
|
||||
|
||||
### Browser SSRF policy (strict by default)
|
||||
### Browser SSRF policy (trusted-network default)
|
||||
|
||||
OpenClaw’s browser navigation policy is strict by default: private/internal destinations stay blocked unless you explicitly opt in.
|
||||
OpenClaw’s browser network policy defaults to the trusted-operator model: private/internal destinations are allowed unless you explicitly disable them.
|
||||
|
||||
- Default: `browser.ssrfPolicy.dangerouslyAllowPrivateNetwork` is unset, so browser navigation keeps private/internal/special-use destinations blocked.
|
||||
- Default: `browser.ssrfPolicy.dangerouslyAllowPrivateNetwork: true` (implicit when unset).
|
||||
- Legacy alias: `browser.ssrfPolicy.allowPrivateNetwork` is still accepted for compatibility.
|
||||
- Opt-in mode: set `browser.ssrfPolicy.dangerouslyAllowPrivateNetwork: true` to allow private/internal/special-use destinations.
|
||||
- Strict mode: set `browser.ssrfPolicy.dangerouslyAllowPrivateNetwork: false` to block private/internal/special-use destinations by default.
|
||||
- In strict mode, use `hostnameAllowlist` (patterns like `*.example.com`) and `allowedHostnames` (exact host exceptions, including blocked names like `localhost`) for explicit exceptions.
|
||||
- Navigation is checked before request and best-effort re-checked on the final `http(s)` URL after navigation to reduce redirect-based pivots.
|
||||
|
||||
|
||||
@@ -111,7 +111,7 @@ Fix options:
|
||||
Related:
|
||||
|
||||
- [/gateway/local-models](/gateway/local-models)
|
||||
- [/gateway/configuration](/gateway/configuration)
|
||||
- [/gateway/configuration#models](/gateway/configuration#models)
|
||||
- [/gateway/configuration-reference#openai-compatible-endpoints](/gateway/configuration-reference#openai-compatible-endpoints)
|
||||
|
||||
## No replies
|
||||
|
||||
@@ -48,10 +48,6 @@ These commands sit beside the main test suites when you need QA-lab realism:
|
||||
|
||||
- `pnpm openclaw qa suite`
|
||||
- Runs repo-backed QA scenarios directly on the host.
|
||||
- Runs multiple selected scenarios in parallel by default with isolated
|
||||
gateway workers, up to 64 workers or the selected scenario count. Use
|
||||
`--concurrency <count>` to tune the worker count, or `--concurrency 1` for
|
||||
the older serial lane.
|
||||
- `pnpm openclaw qa suite --runner multipass`
|
||||
- Runs the same QA suite inside a disposable Multipass Linux VM.
|
||||
- Keeps the same scenario-selection behavior as `qa suite` on the host.
|
||||
@@ -88,7 +84,7 @@ Think of the suites as “increasing realism” (and increasing flakiness/cost):
|
||||
- `pnpm test --watch` still uses the native root `vitest.config.ts` project graph, because a multi-shard watch loop is not practical.
|
||||
- `pnpm test`, `pnpm test:watch`, and `pnpm test:perf:imports` route explicit file/directory targets through scoped lanes first, so `pnpm test extensions/discord/src/monitor/message-handler.preflight.test.ts` avoids paying the full root project startup tax.
|
||||
- `pnpm test:changed` expands changed git paths into the same scoped lanes when the diff only touches routable source/test files; config/setup edits still fall back to the broad root-project rerun.
|
||||
- Import-light unit tests from agents, commands, plugins, auto-reply helpers, `plugin-sdk`, and similar pure utility areas route through the `unit-fast` lane, which skips `test/setup-openclaw-runtime.ts`; stateful/runtime-heavy files stay on the existing lanes.
|
||||
- Selected `plugin-sdk` and `commands` tests also route through dedicated light lanes that skip `test/setup-openclaw-runtime.ts`; stateful/runtime-heavy files stay on the existing lanes.
|
||||
- Selected `plugin-sdk` and `commands` helper source files also map changed-mode runs to explicit sibling tests in those light lanes, so helper edits avoid rerunning the full heavy suite for that directory.
|
||||
- `auto-reply` now has three dedicated buckets: top-level core helpers, top-level `reply.*` integration tests, and the `src/auto-reply/reply/**` subtree. This keeps the heaviest reply harness work off the cheap status/chunk/token tests.
|
||||
- Embedded runner note:
|
||||
@@ -320,7 +316,6 @@ Single-provider Docker recipes:
|
||||
|
||||
```bash
|
||||
pnpm test:docker:live-cli-backend:claude
|
||||
pnpm test:docker:live-cli-backend:claude-subscription
|
||||
pnpm test:docker:live-cli-backend:codex
|
||||
pnpm test:docker:live-cli-backend:gemini
|
||||
```
|
||||
@@ -330,7 +325,6 @@ Notes:
|
||||
- The Docker runner lives at `scripts/test-live-cli-backend-docker.sh`.
|
||||
- It runs the live CLI-backend smoke inside the repo Docker image as the non-root `node` user.
|
||||
- It resolves CLI smoke metadata from the owning extension, then installs the matching Linux CLI package (`@anthropic-ai/claude-code`, `@openai/codex`, or `@google/gemini-cli`) into a cached writable prefix at `OPENCLAW_DOCKER_CLI_TOOLS_DIR` (default: `~/.cache/openclaw/docker-cli-tools`).
|
||||
- `pnpm test:docker:live-cli-backend:claude-subscription` requires portable Claude Code subscription OAuth through either `~/.claude/.credentials.json` with `claudeAiOauth.subscriptionType` or `CLAUDE_CODE_OAUTH_TOKEN` from `claude setup-token`. It first proves direct `claude -p` in Docker, then runs two Gateway CLI-backend turns without preserving Anthropic API-key env vars. This subscription lane disables the Claude MCP/tool and image probes by default because Claude currently routes third-party app usage through extra-usage billing instead of normal subscription plan limits.
|
||||
- The live CLI-backend smoke now exercises the same end-to-end flow for Claude, Codex, and Gemini: text turn, image classification turn, then MCP `cron` tool call verified through the gateway CLI.
|
||||
- Claude's default smoke also patches the session from Sonnet to Opus and verifies the resumed session still remembers an earlier note.
|
||||
|
||||
@@ -390,55 +384,6 @@ Docker notes:
|
||||
- It sources `~/.profile`, stages the matching CLI auth material into the container, installs `acpx` into a writable npm prefix, then installs the requested live CLI (`@anthropic-ai/claude-code`, `@openai/codex`, or `@google/gemini-cli`) if missing.
|
||||
- Inside Docker, the runner sets `OPENCLAW_LIVE_ACP_BIND_ACPX_COMMAND=$HOME/.npm-global/bin/acpx` so acpx keeps provider env vars from the sourced profile available to the child harness CLI.
|
||||
|
||||
## Live: Codex app-server harness smoke
|
||||
|
||||
- Goal: validate the plugin-owned Codex harness through the normal gateway
|
||||
`agent` method:
|
||||
- load the bundled `codex` plugin
|
||||
- select `OPENCLAW_AGENT_RUNTIME=codex`
|
||||
- send a first gateway agent turn to `codex/gpt-5.4`
|
||||
- send a second turn to the same OpenClaw session and verify the app-server
|
||||
thread can resume
|
||||
- run `/codex status` and `/codex models` through the same gateway command
|
||||
path
|
||||
- Test: `src/gateway/gateway-codex-harness.live.test.ts`
|
||||
- Enable: `OPENCLAW_LIVE_CODEX_HARNESS=1`
|
||||
- Default model: `codex/gpt-5.4`
|
||||
- Optional image probe: `OPENCLAW_LIVE_CODEX_HARNESS_IMAGE_PROBE=1`
|
||||
- Optional MCP/tool probe: `OPENCLAW_LIVE_CODEX_HARNESS_MCP_PROBE=1`
|
||||
- The smoke sets `OPENCLAW_AGENT_HARNESS_FALLBACK=none` so a broken Codex
|
||||
harness cannot pass by silently falling back to PI.
|
||||
- Auth: `OPENAI_API_KEY` from the shell/profile, plus optional copied
|
||||
`~/.codex/auth.json` and `~/.codex/config.toml`
|
||||
|
||||
Local recipe:
|
||||
|
||||
```bash
|
||||
source ~/.profile
|
||||
OPENCLAW_LIVE_CODEX_HARNESS=1 \
|
||||
OPENCLAW_LIVE_CODEX_HARNESS_IMAGE_PROBE=1 \
|
||||
OPENCLAW_LIVE_CODEX_HARNESS_MCP_PROBE=1 \
|
||||
OPENCLAW_LIVE_CODEX_HARNESS_MODEL=codex/gpt-5.4 \
|
||||
pnpm test:live -- src/gateway/gateway-codex-harness.live.test.ts
|
||||
```
|
||||
|
||||
Docker recipe:
|
||||
|
||||
```bash
|
||||
source ~/.profile
|
||||
pnpm test:docker:live-codex-harness
|
||||
```
|
||||
|
||||
Docker notes:
|
||||
|
||||
- The Docker runner lives at `scripts/test-live-codex-harness-docker.sh`.
|
||||
- It sources the mounted `~/.profile`, passes `OPENAI_API_KEY`, copies Codex CLI
|
||||
auth files when present, installs `@openai/codex` into a writable mounted npm
|
||||
prefix, stages the source tree, then runs only the Codex-harness live test.
|
||||
- Docker enables the image and MCP/tool probes by default. Set
|
||||
`OPENCLAW_LIVE_CODEX_HARNESS_IMAGE_PROBE=0` or
|
||||
`OPENCLAW_LIVE_CODEX_HARNESS_MCP_PROBE=0` when you need a narrower debug run.
|
||||
|
||||
### Recommended live recipes
|
||||
|
||||
Narrow, explicit allowlists are fastest and least flaky:
|
||||
@@ -667,7 +612,6 @@ The live-model Docker runners also bind-mount only the needed CLI auth homes (or
|
||||
- Direct models: `pnpm test:docker:live-models` (script: `scripts/test-live-models-docker.sh`)
|
||||
- ACP bind smoke: `pnpm test:docker:live-acp-bind` (script: `scripts/test-live-acp-bind-docker.sh`)
|
||||
- CLI backend smoke: `pnpm test:docker:live-cli-backend` (script: `scripts/test-live-cli-backend-docker.sh`)
|
||||
- Codex app-server harness smoke: `pnpm test:docker:live-codex-harness` (script: `scripts/test-live-codex-harness-docker.sh`)
|
||||
- Gateway + dev agent: `pnpm test:docker:live-gateway` (script: `scripts/test-live-gateway-models-docker.sh`)
|
||||
- Open WebUI live smoke: `pnpm test:docker:openwebui` (script: `scripts/e2e/openwebui-docker.sh`)
|
||||
- Onboarding wizard (TTY, full scaffolding): `pnpm test:docker:onboard` (script: `scripts/e2e/onboard-docker.sh`)
|
||||
@@ -725,7 +669,6 @@ Useful env vars:
|
||||
- Override manually with `OPENCLAW_DOCKER_AUTH_DIRS=all`, `OPENCLAW_DOCKER_AUTH_DIRS=none`, or a comma list like `OPENCLAW_DOCKER_AUTH_DIRS=.claude,.codex`
|
||||
- `OPENCLAW_LIVE_GATEWAY_MODELS=...` / `OPENCLAW_LIVE_MODELS=...` to narrow the run
|
||||
- `OPENCLAW_LIVE_GATEWAY_PROVIDERS=...` / `OPENCLAW_LIVE_PROVIDERS=...` to filter providers in-container
|
||||
- `OPENCLAW_SKIP_DOCKER_BUILD=1` to reuse an existing `openclaw:local-live` image for reruns that do not need a rebuild
|
||||
- `OPENCLAW_LIVE_REQUIRE_PROFILE_KEYS=1` to ensure creds come from the profile store (not env)
|
||||
- `OPENCLAW_OPENWEBUI_MODEL=...` to choose the model exposed by the gateway for the Open WebUI smoke
|
||||
- `OPENCLAW_OPENWEBUI_PROMPT=...` to override the nonce-check prompt used by the Open WebUI smoke
|
||||
|
||||
@@ -251,19 +251,18 @@ flowchart TD
|
||||
|
||||
Common log signatures:
|
||||
|
||||
- `cron: scheduler disabled; jobs will not run automatically` → cron is disabled.
|
||||
- `heartbeat skipped` with `reason=quiet-hours` → outside configured active hours.
|
||||
- `heartbeat skipped` with `reason=empty-heartbeat-file` → `HEARTBEAT.md` exists but only contains blank/header-only scaffolding.
|
||||
- `heartbeat skipped` with `reason=no-tasks-due` → `HEARTBEAT.md` task mode is active but none of the task intervals are due yet.
|
||||
- `heartbeat skipped` with `reason=alerts-disabled` → all heartbeat visibility is disabled (`showOk`, `showAlerts`, and `useIndicator` are all off).
|
||||
- `requests-in-flight` → main lane busy; heartbeat wake was deferred.
|
||||
- `unknown accountId` → heartbeat delivery target account does not exist.
|
||||
- `cron: scheduler disabled; jobs will not run automatically` → cron is disabled.
|
||||
- `heartbeat skipped` with `reason=quiet-hours` → outside configured active hours.
|
||||
- `heartbeat skipped` with `reason=empty-heartbeat-file` → `HEARTBEAT.md` exists but only contains blank/header-only scaffolding.
|
||||
- `heartbeat skipped` with `reason=no-tasks-due` → `HEARTBEAT.md` task mode is active but none of the task intervals are due yet.
|
||||
- `heartbeat skipped` with `reason=alerts-disabled` → all heartbeat visibility is disabled (`showOk`, `showAlerts`, and `useIndicator` are all off).
|
||||
- `requests-in-flight` → main lane busy; heartbeat wake was deferred. - `unknown accountId` → heartbeat delivery target account does not exist.
|
||||
|
||||
Deep pages:
|
||||
Deep pages:
|
||||
|
||||
- [/gateway/troubleshooting#cron-and-heartbeat-delivery](/gateway/troubleshooting#cron-and-heartbeat-delivery)
|
||||
- [/automation/cron-jobs#troubleshooting](/automation/cron-jobs#troubleshooting)
|
||||
- [/gateway/heartbeat](/gateway/heartbeat)
|
||||
- [/gateway/troubleshooting#cron-and-heartbeat-delivery](/gateway/troubleshooting#cron-and-heartbeat-delivery)
|
||||
- [/automation/cron-jobs#troubleshooting](/automation/cron-jobs#troubleshooting)
|
||||
- [/gateway/heartbeat](/gateway/heartbeat)
|
||||
|
||||
</Accordion>
|
||||
|
||||
@@ -339,7 +338,7 @@ flowchart TD
|
||||
|
||||
- [/tools/exec](/tools/exec)
|
||||
- [/tools/exec-approvals](/tools/exec-approvals)
|
||||
- [/gateway/security#what-the-audit-checks-high-level](/gateway/security#what-the-audit-checks-high-level)
|
||||
- [/gateway/security#runtime-expectation-drift](/gateway/security#runtime-expectation-drift)
|
||||
|
||||
</Accordion>
|
||||
|
||||
@@ -377,7 +376,6 @@ flowchart TD
|
||||
- [/tools/browser-wsl2-windows-remote-cdp-troubleshooting](/tools/browser-wsl2-windows-remote-cdp-troubleshooting)
|
||||
|
||||
</Accordion>
|
||||
|
||||
</AccordionGroup>
|
||||
|
||||
## Related
|
||||
|
||||
@@ -1,487 +0,0 @@
|
||||
---
|
||||
title: "Codex Harness"
|
||||
summary: "Run OpenClaw embedded agent turns through the bundled Codex app-server harness"
|
||||
read_when:
|
||||
- You want to use the bundled Codex app-server harness
|
||||
- You need Codex model refs and config examples
|
||||
- You want to disable PI fallback for Codex-only deployments
|
||||
---
|
||||
|
||||
# Codex Harness
|
||||
|
||||
The bundled `codex` plugin lets OpenClaw run embedded agent turns through the
|
||||
Codex app-server instead of the built-in PI harness.
|
||||
|
||||
Use this when you want Codex to own the low-level agent session: model
|
||||
discovery, native thread resume, native compaction, and app-server execution.
|
||||
OpenClaw still owns chat channels, session files, model selection, tools,
|
||||
approvals, media delivery, and the visible transcript mirror.
|
||||
|
||||
The harness is off by default. It is selected only when the `codex` plugin is
|
||||
enabled and the resolved model is a `codex/*` model, or when you explicitly
|
||||
force `embeddedHarness.runtime: "codex"` or `OPENCLAW_AGENT_RUNTIME=codex`.
|
||||
If you never configure `codex/*`, existing PI, OpenAI, Anthropic, Gemini, local,
|
||||
and custom-provider runs keep their current behavior.
|
||||
|
||||
## Pick the right model prefix
|
||||
|
||||
OpenClaw has separate routes for OpenAI and Codex-shaped access:
|
||||
|
||||
| Model ref | Runtime path | Use when |
|
||||
| ---------------------- | -------------------------------------------- | ----------------------------------------------------------------------- |
|
||||
| `openai/gpt-5.4` | OpenAI provider through OpenClaw/PI plumbing | You want direct OpenAI Platform API access with `OPENAI_API_KEY`. |
|
||||
| `openai-codex/gpt-5.4` | OpenAI Codex OAuth provider through PI | You want ChatGPT/Codex OAuth without the Codex app-server harness. |
|
||||
| `codex/gpt-5.4` | Bundled Codex provider plus Codex harness | You want native Codex app-server execution for the embedded agent turn. |
|
||||
|
||||
The Codex harness only claims `codex/*` model refs. Existing `openai/*`,
|
||||
`openai-codex/*`, Anthropic, Gemini, xAI, local, and custom provider refs keep
|
||||
their normal paths.
|
||||
|
||||
## Requirements
|
||||
|
||||
- OpenClaw with the bundled `codex` plugin available.
|
||||
- Codex app-server `0.118.0` or newer.
|
||||
- Codex auth available to the app-server process.
|
||||
|
||||
The plugin blocks older or unversioned app-server handshakes. That keeps
|
||||
OpenClaw on the protocol surface it has been tested against.
|
||||
|
||||
For live and Docker smoke tests, auth usually comes from `OPENAI_API_KEY`, plus
|
||||
optional Codex CLI files such as `~/.codex/auth.json` and
|
||||
`~/.codex/config.toml`. Use the same auth material your local Codex app-server
|
||||
uses.
|
||||
|
||||
## Minimal config
|
||||
|
||||
Use `codex/gpt-5.4`, enable the bundled plugin, and force the `codex` harness:
|
||||
|
||||
```json5
|
||||
{
|
||||
plugins: {
|
||||
entries: {
|
||||
codex: {
|
||||
enabled: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
agents: {
|
||||
defaults: {
|
||||
model: "codex/gpt-5.4",
|
||||
embeddedHarness: {
|
||||
runtime: "codex",
|
||||
fallback: "none",
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
```
|
||||
|
||||
If your config uses `plugins.allow`, include `codex` there too:
|
||||
|
||||
```json5
|
||||
{
|
||||
plugins: {
|
||||
allow: ["codex"],
|
||||
entries: {
|
||||
codex: {
|
||||
enabled: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
```
|
||||
|
||||
Setting `agents.defaults.model` or an agent model to `codex/<model>` also
|
||||
auto-enables the bundled `codex` plugin. The explicit plugin entry is still
|
||||
useful in shared configs because it makes the deployment intent obvious.
|
||||
|
||||
## Add Codex without replacing other models
|
||||
|
||||
Keep `runtime: "auto"` when you want Codex for `codex/*` models and PI for
|
||||
everything else:
|
||||
|
||||
```json5
|
||||
{
|
||||
plugins: {
|
||||
entries: {
|
||||
codex: {
|
||||
enabled: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
agents: {
|
||||
defaults: {
|
||||
model: {
|
||||
primary: "codex/gpt-5.4",
|
||||
fallbacks: ["openai/gpt-5.4", "anthropic/claude-opus-4-6"],
|
||||
},
|
||||
models: {
|
||||
"codex/gpt-5.4": { alias: "codex" },
|
||||
"codex/gpt-5.4-mini": { alias: "codex-mini" },
|
||||
"openai/gpt-5.4": { alias: "gpt" },
|
||||
"anthropic/claude-opus-4-6": { alias: "opus" },
|
||||
},
|
||||
embeddedHarness: {
|
||||
runtime: "auto",
|
||||
fallback: "pi",
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
```
|
||||
|
||||
With this shape:
|
||||
|
||||
- `/model codex` or `/model codex/gpt-5.4` uses the Codex app-server harness.
|
||||
- `/model gpt` or `/model openai/gpt-5.4` uses the OpenAI provider path.
|
||||
- `/model opus` uses the Anthropic provider path.
|
||||
- If a non-Codex model is selected, PI remains the compatibility harness.
|
||||
|
||||
## Codex-only deployments
|
||||
|
||||
Disable PI fallback when you need to prove that every embedded agent turn uses
|
||||
the Codex harness:
|
||||
|
||||
```json5
|
||||
{
|
||||
agents: {
|
||||
defaults: {
|
||||
model: "codex/gpt-5.4",
|
||||
embeddedHarness: {
|
||||
runtime: "codex",
|
||||
fallback: "none",
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
```
|
||||
|
||||
Environment override:
|
||||
|
||||
```bash
|
||||
OPENCLAW_AGENT_RUNTIME=codex \
|
||||
OPENCLAW_AGENT_HARNESS_FALLBACK=none \
|
||||
openclaw gateway run
|
||||
```
|
||||
|
||||
With fallback disabled, OpenClaw fails early if the Codex plugin is disabled,
|
||||
the requested model is not a `codex/*` ref, the app-server is too old, or the
|
||||
app-server cannot start.
|
||||
|
||||
## Per-agent Codex
|
||||
|
||||
You can make one agent Codex-only while the default agent keeps normal
|
||||
auto-selection:
|
||||
|
||||
```json5
|
||||
{
|
||||
agents: {
|
||||
defaults: {
|
||||
embeddedHarness: {
|
||||
runtime: "auto",
|
||||
fallback: "pi",
|
||||
},
|
||||
},
|
||||
list: [
|
||||
{
|
||||
id: "main",
|
||||
default: true,
|
||||
model: "anthropic/claude-opus-4-6",
|
||||
},
|
||||
{
|
||||
id: "codex",
|
||||
name: "Codex",
|
||||
model: "codex/gpt-5.4",
|
||||
embeddedHarness: {
|
||||
runtime: "codex",
|
||||
fallback: "none",
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
}
|
||||
```
|
||||
|
||||
Use normal session commands to switch agents and models. `/new` creates a fresh
|
||||
OpenClaw session and the Codex harness creates or resumes its sidecar app-server
|
||||
thread as needed. `/reset` clears the OpenClaw session binding for that thread.
|
||||
|
||||
## Model discovery
|
||||
|
||||
By default, the Codex plugin asks the app-server for available models. If
|
||||
discovery fails or times out, it uses the bundled fallback catalog:
|
||||
|
||||
- `codex/gpt-5.4`
|
||||
- `codex/gpt-5.4-mini`
|
||||
- `codex/gpt-5.2`
|
||||
|
||||
You can tune discovery under `plugins.entries.codex.config.discovery`:
|
||||
|
||||
```json5
|
||||
{
|
||||
plugins: {
|
||||
entries: {
|
||||
codex: {
|
||||
enabled: true,
|
||||
config: {
|
||||
discovery: {
|
||||
enabled: true,
|
||||
timeoutMs: 2500,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
```
|
||||
|
||||
Disable discovery when you want startup to avoid probing Codex and stick to the
|
||||
fallback catalog:
|
||||
|
||||
```json5
|
||||
{
|
||||
plugins: {
|
||||
entries: {
|
||||
codex: {
|
||||
enabled: true,
|
||||
config: {
|
||||
discovery: {
|
||||
enabled: false,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
```
|
||||
|
||||
## App-server connection and policy
|
||||
|
||||
By default, the plugin starts Codex locally with:
|
||||
|
||||
```bash
|
||||
codex app-server --listen stdio://
|
||||
```
|
||||
|
||||
You can keep that default and only tune Codex native policy:
|
||||
|
||||
```json5
|
||||
{
|
||||
plugins: {
|
||||
entries: {
|
||||
codex: {
|
||||
enabled: true,
|
||||
config: {
|
||||
appServer: {
|
||||
approvalPolicy: "on-request",
|
||||
sandbox: "workspace-write",
|
||||
serviceTier: "priority",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
```
|
||||
|
||||
For an already-running app-server, use WebSocket transport:
|
||||
|
||||
```json5
|
||||
{
|
||||
plugins: {
|
||||
entries: {
|
||||
codex: {
|
||||
enabled: true,
|
||||
config: {
|
||||
appServer: {
|
||||
transport: "websocket",
|
||||
url: "ws://127.0.0.1:39175",
|
||||
authToken: "${CODEX_APP_SERVER_TOKEN}",
|
||||
requestTimeoutMs: 60000,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
```
|
||||
|
||||
Supported `appServer` fields:
|
||||
|
||||
| Field | Default | Meaning |
|
||||
| ------------------- | ---------------------------------------- | ------------------------------------------------------------------------ |
|
||||
| `transport` | `"stdio"` | `"stdio"` spawns Codex; `"websocket"` connects to `url`. |
|
||||
| `command` | `"codex"` | Executable for stdio transport. |
|
||||
| `args` | `["app-server", "--listen", "stdio://"]` | Arguments for stdio transport. |
|
||||
| `url` | unset | WebSocket app-server URL. |
|
||||
| `authToken` | unset | Bearer token for WebSocket transport. |
|
||||
| `headers` | `{}` | Extra WebSocket headers. |
|
||||
| `requestTimeoutMs` | `60000` | Timeout for app-server control-plane calls. |
|
||||
| `approvalPolicy` | `"never"` | Native Codex approval policy sent to thread start/resume/turn. |
|
||||
| `sandbox` | `"workspace-write"` | Native Codex sandbox mode sent to thread start/resume. |
|
||||
| `approvalsReviewer` | `"user"` | Use `"guardian_subagent"` to let Codex guardian review native approvals. |
|
||||
| `serviceTier` | unset | Optional Codex service tier, for example `"priority"`. |
|
||||
|
||||
The older environment variables still work as fallbacks for local testing when
|
||||
the matching config field is unset:
|
||||
|
||||
- `OPENCLAW_CODEX_APP_SERVER_BIN`
|
||||
- `OPENCLAW_CODEX_APP_SERVER_ARGS`
|
||||
- `OPENCLAW_CODEX_APP_SERVER_APPROVAL_POLICY`
|
||||
- `OPENCLAW_CODEX_APP_SERVER_SANDBOX`
|
||||
- `OPENCLAW_CODEX_APP_SERVER_GUARDIAN=1`
|
||||
|
||||
Config is preferred for repeatable deployments.
|
||||
|
||||
## Common recipes
|
||||
|
||||
Local Codex with default stdio transport:
|
||||
|
||||
```json5
|
||||
{
|
||||
plugins: {
|
||||
entries: {
|
||||
codex: {
|
||||
enabled: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
```
|
||||
|
||||
Codex-only harness validation, with PI fallback disabled:
|
||||
|
||||
```json5
|
||||
{
|
||||
embeddedHarness: {
|
||||
fallback: "none",
|
||||
},
|
||||
plugins: {
|
||||
entries: {
|
||||
codex: {
|
||||
enabled: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
```
|
||||
|
||||
Guardian-reviewed Codex approvals:
|
||||
|
||||
```json5
|
||||
{
|
||||
plugins: {
|
||||
entries: {
|
||||
codex: {
|
||||
enabled: true,
|
||||
config: {
|
||||
appServer: {
|
||||
approvalPolicy: "on-request",
|
||||
approvalsReviewer: "guardian_subagent",
|
||||
sandbox: "workspace-write",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
```
|
||||
|
||||
Remote app-server with explicit headers:
|
||||
|
||||
```json5
|
||||
{
|
||||
plugins: {
|
||||
entries: {
|
||||
codex: {
|
||||
enabled: true,
|
||||
config: {
|
||||
appServer: {
|
||||
transport: "websocket",
|
||||
url: "ws://gateway-host:39175",
|
||||
headers: {
|
||||
"X-OpenClaw-Agent": "main",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
```
|
||||
|
||||
Model switching stays OpenClaw-controlled. When an OpenClaw session is attached
|
||||
to an existing Codex thread, the next turn sends the currently selected
|
||||
`codex/*` model, provider, approval policy, sandbox, and service tier to
|
||||
app-server again. Switching from `codex/gpt-5.4` to `codex/gpt-5.2` keeps the
|
||||
thread binding but asks Codex to continue with the newly selected model.
|
||||
|
||||
## Codex command
|
||||
|
||||
The bundled plugin registers `/codex` as an authorized slash command. It is
|
||||
generic and works on any channel that supports OpenClaw text commands.
|
||||
|
||||
Common forms:
|
||||
|
||||
- `/codex status` shows live app-server connectivity, models, account, rate limits, MCP servers, and skills.
|
||||
- `/codex models` lists live Codex app-server models.
|
||||
- `/codex threads [filter]` lists recent Codex threads.
|
||||
- `/codex resume <thread-id>` attaches the current OpenClaw session to an existing Codex thread.
|
||||
- `/codex compact` asks Codex app-server to compact the attached thread.
|
||||
- `/codex review` starts Codex native review for the attached thread.
|
||||
- `/codex account` shows account and rate-limit status.
|
||||
- `/codex mcp` lists Codex app-server MCP server status.
|
||||
- `/codex skills` lists Codex app-server skills.
|
||||
|
||||
`/codex resume` writes the same sidecar binding file that the harness uses for
|
||||
normal turns. On the next message, OpenClaw resumes that Codex thread, passes the
|
||||
currently selected OpenClaw `codex/*` model into app-server, and keeps extended
|
||||
history enabled.
|
||||
|
||||
The command surface requires Codex app-server `0.118.0` or newer. Individual
|
||||
control methods are reported as `unsupported by this Codex app-server` if a
|
||||
future or custom app-server does not expose that JSON-RPC method.
|
||||
|
||||
## Tools, media, and compaction
|
||||
|
||||
The Codex harness changes the low-level embedded agent executor only.
|
||||
|
||||
OpenClaw still builds the tool list and receives dynamic tool results from the
|
||||
harness. Text, images, video, music, TTS, approvals, and messaging-tool output
|
||||
continue through the normal OpenClaw delivery path.
|
||||
|
||||
When the selected model uses the Codex harness, native thread compaction is
|
||||
delegated to Codex app-server. OpenClaw keeps a transcript mirror for channel
|
||||
history, search, `/new`, `/reset`, and future model or harness switching.
|
||||
|
||||
Media generation does not require PI. Image, video, music, PDF, TTS, and media
|
||||
understanding continue to use the matching provider/model settings such as
|
||||
`agents.defaults.imageGenerationModel`, `videoGenerationModel`, `pdfModel`, and
|
||||
`messages.tts`.
|
||||
|
||||
## Troubleshooting
|
||||
|
||||
**Codex does not appear in `/model`:** enable `plugins.entries.codex.enabled`,
|
||||
set a `codex/*` model ref, or check whether `plugins.allow` excludes `codex`.
|
||||
|
||||
**OpenClaw falls back to PI:** set `embeddedHarness.fallback: "none"` or
|
||||
`OPENCLAW_AGENT_HARNESS_FALLBACK=none` while testing.
|
||||
|
||||
**The app-server is rejected:** upgrade Codex so the app-server handshake
|
||||
reports version `0.118.0` or newer.
|
||||
|
||||
**Model discovery is slow:** lower `plugins.entries.codex.config.discovery.timeoutMs`
|
||||
or disable discovery.
|
||||
|
||||
**WebSocket transport fails immediately:** check `appServer.url`, `authToken`,
|
||||
and that the remote app-server speaks the same Codex app-server protocol version.
|
||||
|
||||
**A non-Codex model uses PI:** that is expected. The Codex harness only claims
|
||||
`codex/*` model refs.
|
||||
|
||||
## Related
|
||||
|
||||
- [Agent Harness Plugins](/plugins/sdk-agent-harness)
|
||||
- [Model Providers](/concepts/model-providers)
|
||||
- [Configuration Reference](/gateway/configuration-reference)
|
||||
- [Testing](/help/testing#live-codex-app-server-harness-smoke)
|
||||
@@ -147,7 +147,6 @@ Those belong in your plugin code and `package.json`.
|
||||
| `providers` | No | `string[]` | Provider ids owned by this plugin. |
|
||||
| `modelSupport` | No | `object` | Manifest-owned shorthand model-family metadata used to auto-load the plugin before runtime. |
|
||||
| `cliBackends` | No | `string[]` | CLI inference backend ids owned by this plugin. Used for startup auto-activation from explicit config refs. |
|
||||
| `commandAliases` | No | `object[]` | Command names owned by this plugin that should produce plugin-aware config and CLI diagnostics before runtime loads. |
|
||||
| `providerAuthEnvVars` | No | `Record<string, string[]>` | Cheap provider-auth env metadata that OpenClaw can inspect without loading plugin code. |
|
||||
| `providerAuthAliases` | No | `Record<string, string>` | Provider ids that should reuse another provider id for auth lookup, for example a coding provider that shares the base provider API key and auth profiles. |
|
||||
| `channelEnvVars` | No | `Record<string, string[]>` | Cheap channel env metadata that OpenClaw can inspect without loading plugin code. Use this for env-driven channel setup or auth surfaces that generic startup/config helpers should see. |
|
||||
@@ -184,30 +183,6 @@ OpenClaw reads this before provider runtime loads.
|
||||
| `cliDescription` | No | `string` | Description used in CLI help. |
|
||||
| `onboardingScopes` | No | `Array<"text-inference" \| "image-generation">` | Which onboarding surfaces this choice should appear in. If omitted, it defaults to `["text-inference"]`. |
|
||||
|
||||
## commandAliases reference
|
||||
|
||||
Use `commandAliases` when a plugin owns a runtime command name that users may
|
||||
mistakenly put in `plugins.allow` or try to run as a root CLI command. OpenClaw
|
||||
uses this metadata for diagnostics without importing plugin runtime code.
|
||||
|
||||
```json
|
||||
{
|
||||
"commandAliases": [
|
||||
{
|
||||
"name": "dreaming",
|
||||
"kind": "runtime-slash",
|
||||
"cliCommand": "memory"
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
| Field | Required | Type | What it means |
|
||||
| ------------ | -------- | ----------------- | ----------------------------------------------------------------------- |
|
||||
| `name` | Yes | `string` | Command name that belongs to this plugin. |
|
||||
| `kind` | No | `"runtime-slash"` | Marks the alias as a chat slash command rather than a root CLI command. |
|
||||
| `cliCommand` | No | `string` | Related root CLI command to suggest for CLI operations, if one exists. |
|
||||
|
||||
## uiHints reference
|
||||
|
||||
`uiHints` is a map from config field names to small rendering hints.
|
||||
|
||||
@@ -1,264 +0,0 @@
|
||||
---
|
||||
title: "Agent Harness Plugins"
|
||||
sidebarTitle: "Agent Harness"
|
||||
summary: "Experimental SDK surface for plugins that replace the low level embedded agent executor"
|
||||
read_when:
|
||||
- You are changing the embedded agent runtime or harness registry
|
||||
- You are registering an agent harness from a bundled or trusted plugin
|
||||
- You need to understand how the Codex plugin relates to model providers
|
||||
---
|
||||
|
||||
# Agent Harness Plugins
|
||||
|
||||
An **agent harness** is the low level executor for one prepared OpenClaw agent
|
||||
turn. It is not a model provider, not a channel, and not a tool registry.
|
||||
|
||||
Use this surface only for bundled or trusted native plugins. The contract is
|
||||
still experimental because the parameter types intentionally mirror the current
|
||||
embedded runner.
|
||||
|
||||
## When to use a harness
|
||||
|
||||
Register an agent harness when a model family has its own native session
|
||||
runtime and the normal OpenClaw provider transport is the wrong abstraction.
|
||||
|
||||
Examples:
|
||||
|
||||
- a native coding-agent server that owns threads and compaction
|
||||
- a local CLI or daemon that must stream native plan/reasoning/tool events
|
||||
- a model runtime that needs its own resume id in addition to the OpenClaw
|
||||
session transcript
|
||||
|
||||
Do **not** register a harness just to add a new LLM API. For normal HTTP or
|
||||
WebSocket model APIs, build a [provider plugin](/plugins/sdk-provider-plugins).
|
||||
|
||||
## What core still owns
|
||||
|
||||
Before a harness is selected, OpenClaw has already resolved:
|
||||
|
||||
- provider and model
|
||||
- runtime auth state
|
||||
- thinking level and context budget
|
||||
- the OpenClaw transcript/session file
|
||||
- workspace, sandbox, and tool policy
|
||||
- channel reply callbacks and streaming callbacks
|
||||
- model fallback and live model switching policy
|
||||
|
||||
That split is intentional. A harness runs a prepared attempt; it does not pick
|
||||
providers, replace channel delivery, or silently switch models.
|
||||
|
||||
## Register a harness
|
||||
|
||||
**Import:** `openclaw/plugin-sdk/agent-harness`
|
||||
|
||||
```typescript
|
||||
import type { AgentHarness } from "openclaw/plugin-sdk/agent-harness";
|
||||
import { definePluginEntry } from "openclaw/plugin-sdk/plugin-entry";
|
||||
|
||||
const myHarness: AgentHarness = {
|
||||
id: "my-harness",
|
||||
label: "My native agent harness",
|
||||
|
||||
supports(ctx) {
|
||||
return ctx.provider === "my-provider"
|
||||
? { supported: true, priority: 100 }
|
||||
: { supported: false };
|
||||
},
|
||||
|
||||
async runAttempt(params) {
|
||||
// Start or resume your native thread.
|
||||
// Use params.prompt, params.tools, params.images, params.onPartialReply,
|
||||
// params.onAgentEvent, and the other prepared attempt fields.
|
||||
return await runMyNativeTurn(params);
|
||||
},
|
||||
};
|
||||
|
||||
export default definePluginEntry({
|
||||
id: "my-native-agent",
|
||||
name: "My Native Agent",
|
||||
description: "Runs selected models through a native agent daemon.",
|
||||
register(api) {
|
||||
api.registerAgentHarness(myHarness);
|
||||
},
|
||||
});
|
||||
```
|
||||
|
||||
## Selection policy
|
||||
|
||||
OpenClaw chooses a harness after provider/model resolution:
|
||||
|
||||
1. `OPENCLAW_AGENT_RUNTIME=<id>` forces a registered harness with that id.
|
||||
2. `OPENCLAW_AGENT_RUNTIME=pi` forces the built-in PI harness.
|
||||
3. `OPENCLAW_AGENT_RUNTIME=auto` asks registered harnesses if they support the
|
||||
resolved provider/model.
|
||||
4. If no registered harness matches, OpenClaw uses PI unless PI fallback is
|
||||
disabled.
|
||||
|
||||
Forced plugin harness failures surface as run failures. In `auto` mode,
|
||||
OpenClaw may fall back to PI when the selected plugin harness fails before a
|
||||
turn has produced side effects. Set `OPENCLAW_AGENT_HARNESS_FALLBACK=none` or
|
||||
`embeddedHarness.fallback: "none"` to make that fallback a hard failure instead.
|
||||
|
||||
The bundled Codex plugin registers `codex` as its harness id. For compatibility,
|
||||
`codex-app-server` and `app-server` also resolve to that same harness when you
|
||||
set `OPENCLAW_AGENT_RUNTIME` manually.
|
||||
|
||||
## Provider plus harness pairing
|
||||
|
||||
Most harnesses should also register a provider. The provider makes model refs,
|
||||
auth status, model metadata, and `/model` selection visible to the rest of
|
||||
OpenClaw. The harness then claims that provider in `supports(...)`.
|
||||
|
||||
The bundled Codex plugin follows this pattern:
|
||||
|
||||
- provider id: `codex`
|
||||
- user model refs: `codex/gpt-5.4`, `codex/gpt-5.2`, or another model returned
|
||||
by the Codex app server
|
||||
- harness id: `codex`
|
||||
- auth: synthetic provider availability, because the Codex harness owns the
|
||||
native Codex login/session
|
||||
- app-server request: OpenClaw sends the bare model id to Codex and lets the
|
||||
harness talk to the native app-server protocol
|
||||
|
||||
The Codex plugin is additive. Plain `openai/gpt-*` refs remain OpenAI provider
|
||||
refs and continue to use the normal OpenClaw provider path. Select `codex/gpt-*`
|
||||
when you want Codex-managed auth, Codex model discovery, native threads, and
|
||||
Codex app-server execution. `/model` can switch among the Codex models returned
|
||||
by the Codex app server without requiring OpenAI provider credentials.
|
||||
|
||||
For operator setup, model prefix examples, and Codex-only configs, see
|
||||
[Codex Harness](/plugins/codex-harness).
|
||||
|
||||
OpenClaw requires Codex app-server `0.118.0` or newer. The Codex plugin checks
|
||||
the app-server initialize handshake and blocks older or unversioned servers so
|
||||
OpenClaw only runs against the protocol surface it has been tested with.
|
||||
|
||||
## Disable PI fallback
|
||||
|
||||
By default, OpenClaw runs embedded agents with `agents.defaults.embeddedHarness`
|
||||
set to `{ runtime: "auto", fallback: "pi" }`. In `auto` mode, registered plugin
|
||||
harnesses can claim a provider/model pair. If none match, or if an auto-selected
|
||||
plugin harness fails before producing output, OpenClaw falls back to PI.
|
||||
|
||||
Set `fallback: "none"` when you need to prove that a plugin harness is the only
|
||||
runtime being exercised. This disables automatic PI fallback; it does not block
|
||||
an explicit `runtime: "pi"` or `OPENCLAW_AGENT_RUNTIME=pi`.
|
||||
|
||||
For Codex-only embedded runs:
|
||||
|
||||
```json
|
||||
{
|
||||
"agents": {
|
||||
"defaults": {
|
||||
"model": "codex/gpt-5.4",
|
||||
"embeddedHarness": {
|
||||
"runtime": "codex",
|
||||
"fallback": "none"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
If you want any registered plugin harness to claim matching models but never
|
||||
want OpenClaw to silently fall back to PI, keep `runtime: "auto"` and disable
|
||||
the fallback:
|
||||
|
||||
```json
|
||||
{
|
||||
"agents": {
|
||||
"defaults": {
|
||||
"embeddedHarness": {
|
||||
"runtime": "auto",
|
||||
"fallback": "none"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
Per-agent overrides use the same shape:
|
||||
|
||||
```json
|
||||
{
|
||||
"agents": {
|
||||
"defaults": {
|
||||
"embeddedHarness": {
|
||||
"runtime": "auto",
|
||||
"fallback": "pi"
|
||||
}
|
||||
},
|
||||
"list": [
|
||||
{
|
||||
"id": "codex-only",
|
||||
"model": "codex/gpt-5.4",
|
||||
"embeddedHarness": {
|
||||
"runtime": "codex",
|
||||
"fallback": "none"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
`OPENCLAW_AGENT_RUNTIME` still overrides the configured runtime. Use
|
||||
`OPENCLAW_AGENT_HARNESS_FALLBACK=none` to disable PI fallback from the
|
||||
environment.
|
||||
|
||||
```bash
|
||||
OPENCLAW_AGENT_RUNTIME=codex \
|
||||
OPENCLAW_AGENT_HARNESS_FALLBACK=none \
|
||||
openclaw gateway run
|
||||
```
|
||||
|
||||
With fallback disabled, a session fails early when the requested harness is not
|
||||
registered, does not support the resolved provider/model, or fails before
|
||||
producing turn side effects. That is intentional for Codex-only deployments and
|
||||
for live tests that must prove the Codex app-server path is actually in use.
|
||||
|
||||
This setting only controls the embedded agent harness. It does not disable
|
||||
image, video, music, TTS, PDF, or other provider-specific model routing.
|
||||
|
||||
## Native sessions and transcript mirror
|
||||
|
||||
A harness may keep a native session id, thread id, or daemon-side resume token.
|
||||
Keep that binding explicitly associated with the OpenClaw session, and keep
|
||||
mirroring user-visible assistant/tool output into the OpenClaw transcript.
|
||||
|
||||
The OpenClaw transcript remains the compatibility layer for:
|
||||
|
||||
- channel-visible session history
|
||||
- transcript search and indexing
|
||||
- switching back to the built-in PI harness on a later turn
|
||||
- generic `/new`, `/reset`, and session deletion behavior
|
||||
|
||||
If your harness stores a sidecar binding, implement `reset(...)` so OpenClaw can
|
||||
clear it when the owning OpenClaw session is reset.
|
||||
|
||||
## Tool and media results
|
||||
|
||||
Core constructs the OpenClaw tool list and passes it into the prepared attempt.
|
||||
When a harness executes a dynamic tool call, return the tool result back through
|
||||
the harness result shape instead of sending channel media yourself.
|
||||
|
||||
This keeps text, image, video, music, TTS, approval, and messaging-tool outputs
|
||||
on the same delivery path as PI-backed runs.
|
||||
|
||||
## Current limitations
|
||||
|
||||
- The public import path is generic, but some attempt/result type aliases still
|
||||
carry `Pi` names for compatibility.
|
||||
- Third-party harness installation is experimental. Prefer provider plugins
|
||||
until you need a native session runtime.
|
||||
- Harness switching is supported across turns. Do not switch harnesses in the
|
||||
middle of a turn after native tools, approvals, assistant text, or message
|
||||
sends have started.
|
||||
|
||||
## Related
|
||||
|
||||
- [SDK Overview](/plugins/sdk-overview)
|
||||
- [Runtime Helpers](/plugins/sdk-runtime)
|
||||
- [Provider Plugins](/plugins/sdk-provider-plugins)
|
||||
- [Codex Harness](/plugins/codex-harness)
|
||||
- [Model Providers](/concepts/model-providers)
|
||||
@@ -256,7 +256,7 @@ should use `resolveInboundMentionDecision({ facts, policy })`.
|
||||
<Step title="Package and manifest">
|
||||
Create the standard plugin files. The `channel` field in `package.json` is
|
||||
what makes this a channel plugin. For the full package-metadata surface,
|
||||
see [Plugin Setup and Config](/plugins/sdk-setup#openclaw-channel):
|
||||
see [Plugin Setup and Config](/plugins/sdk-setup#openclawchannel):
|
||||
|
||||
<CodeGroup>
|
||||
```json package.json
|
||||
|
||||
@@ -219,7 +219,6 @@ explicitly promotes one as public.
|
||||
| `plugin-sdk/models-provider-runtime` | `/models` command/provider reply helpers |
|
||||
| `plugin-sdk/skill-commands-runtime` | Skill command listing helpers |
|
||||
| `plugin-sdk/native-command-registry` | Native command registry/build/serialize helpers |
|
||||
| `plugin-sdk/agent-harness` | Experimental trusted-plugin surface for low-level agent harnesses: harness types, active-run steer/abort helpers, OpenClaw tool bridge helpers, and attempt result utilities |
|
||||
| `plugin-sdk/provider-zai-endpoint` | Z.AI endpoint detection helpers |
|
||||
| `plugin-sdk/infra-runtime` | System event/heartbeat helpers |
|
||||
| `plugin-sdk/collection-runtime` | Small bounded cache helpers |
|
||||
@@ -303,21 +302,20 @@ methods:
|
||||
|
||||
### Capability registration
|
||||
|
||||
| Method | What it registers |
|
||||
| ------------------------------------------------ | ------------------------------------- |
|
||||
| `api.registerProvider(...)` | Text inference (LLM) |
|
||||
| `api.registerAgentHarness(...)` | Experimental low-level agent executor |
|
||||
| `api.registerCliBackend(...)` | Local CLI inference backend |
|
||||
| `api.registerChannel(...)` | Messaging channel |
|
||||
| `api.registerSpeechProvider(...)` | Text-to-speech / STT synthesis |
|
||||
| `api.registerRealtimeTranscriptionProvider(...)` | Streaming realtime transcription |
|
||||
| `api.registerRealtimeVoiceProvider(...)` | Duplex realtime voice sessions |
|
||||
| `api.registerMediaUnderstandingProvider(...)` | Image/audio/video analysis |
|
||||
| `api.registerImageGenerationProvider(...)` | Image generation |
|
||||
| `api.registerMusicGenerationProvider(...)` | Music generation |
|
||||
| `api.registerVideoGenerationProvider(...)` | Video generation |
|
||||
| `api.registerWebFetchProvider(...)` | Web fetch / scrape provider |
|
||||
| `api.registerWebSearchProvider(...)` | Web search |
|
||||
| Method | What it registers |
|
||||
| ------------------------------------------------ | -------------------------------- |
|
||||
| `api.registerProvider(...)` | Text inference (LLM) |
|
||||
| `api.registerCliBackend(...)` | Local CLI inference backend |
|
||||
| `api.registerChannel(...)` | Messaging channel |
|
||||
| `api.registerSpeechProvider(...)` | Text-to-speech / STT synthesis |
|
||||
| `api.registerRealtimeTranscriptionProvider(...)` | Streaming realtime transcription |
|
||||
| `api.registerRealtimeVoiceProvider(...)` | Duplex realtime voice sessions |
|
||||
| `api.registerMediaUnderstandingProvider(...)` | Image/audio/video analysis |
|
||||
| `api.registerImageGenerationProvider(...)` | Image generation |
|
||||
| `api.registerMusicGenerationProvider(...)` | Music generation |
|
||||
| `api.registerVideoGenerationProvider(...)` | Video generation |
|
||||
| `api.registerWebFetchProvider(...)` | Web fetch / scrape provider |
|
||||
| `api.registerWebSearchProvider(...)` | Web search |
|
||||
|
||||
### Tools and commands
|
||||
|
||||
|
||||
@@ -20,13 +20,6 @@ API key auth, and dynamic model resolution.
|
||||
structure and manifest setup.
|
||||
</Info>
|
||||
|
||||
<Tip>
|
||||
Provider plugins add models to OpenClaw's normal inference loop. If the model
|
||||
must run through a native agent daemon that owns threads, compaction, or tool
|
||||
events, pair the provider with an [agent harness](/plugins/sdk-agent-harness)
|
||||
instead of putting daemon protocol details in core.
|
||||
</Tip>
|
||||
|
||||
## Walkthrough
|
||||
|
||||
<Steps>
|
||||
|
||||
@@ -50,9 +50,9 @@ const timeoutMs = api.runtime.agent.resolveAgentTimeoutMs(cfg);
|
||||
// Ensure workspace exists
|
||||
await api.runtime.agent.ensureAgentWorkspace(cfg);
|
||||
|
||||
// Run an embedded agent turn
|
||||
// Run an embedded Pi agent
|
||||
const agentDir = api.runtime.agent.resolveAgentDir(cfg);
|
||||
const result = await api.runtime.agent.runEmbeddedAgent({
|
||||
const result = await api.runtime.agent.runEmbeddedPiAgent({
|
||||
sessionId: "my-plugin:task-1",
|
||||
runId: crypto.randomUUID(),
|
||||
sessionFile: path.join(agentDir, "sessions", "my-plugin-task-1.jsonl"),
|
||||
@@ -62,12 +62,6 @@ const result = await api.runtime.agent.runEmbeddedAgent({
|
||||
});
|
||||
```
|
||||
|
||||
`runEmbeddedAgent(...)` is the neutral helper for starting a normal OpenClaw
|
||||
agent turn from plugin code. It uses the same provider/model resolution and
|
||||
agent-harness selection as channel-triggered replies.
|
||||
|
||||
`runEmbeddedPiAgent(...)` remains as a compatibility alias.
|
||||
|
||||
**Session store helpers** are under `api.runtime.agent.session`:
|
||||
|
||||
```typescript
|
||||
|
||||
@@ -69,9 +69,9 @@ OpenClaw has three public release lanes:
|
||||
- npm release preflight fails closed unless the tarball includes both
|
||||
`dist/control-ui/index.html` and a non-empty `dist/control-ui/assets/` payload
|
||||
so we do not ship an empty browser dashboard again
|
||||
- If the release work touched CI planning, extension timing manifests, or
|
||||
extension test matrices, regenerate and review the planner-owned
|
||||
`checks-node-extensions` workflow matrix outputs from `.github/workflows/ci.yml`
|
||||
- If the release work touched CI planning, extension timing manifests, or fast
|
||||
test matrices, regenerate and review the planner-owned `checks-fast-extensions`
|
||||
workflow matrix outputs from `.github/workflows/ci.yml`
|
||||
before approval so release notes do not describe a stale CI layout
|
||||
- Stable macOS release readiness also includes the updater surfaces:
|
||||
- the GitHub release must end up with the packaged `.zip`, `.dmg`, and `.dSYM.zip`
|
||||
|
||||
50
docs/reference/rich-output-protocol.md
Normal file
50
docs/reference/rich-output-protocol.md
Normal file
@@ -0,0 +1,50 @@
|
||||
# Rich Output Protocol
|
||||
|
||||
Assistant output can carry a small set of delivery/render directives:
|
||||
|
||||
- `MEDIA:` for attachment delivery
|
||||
- `[[audio_as_voice]]` for audio presentation hints
|
||||
- `[[reply_to_current]]` / `[[reply_to:<id>]]` for reply metadata
|
||||
- `[canvas ...]` for Control UI rich rendering
|
||||
|
||||
These directives are separate. `MEDIA:` and reply/voice tags remain delivery metadata; `[canvas ...]` is the web-only rich render path.
|
||||
|
||||
## `[canvas ...]`
|
||||
|
||||
`[canvas ...]` is the only agent-facing rich render syntax for the Control UI.
|
||||
|
||||
Self-closing example:
|
||||
|
||||
```text
|
||||
[canvas ref="cv_123" title="Status" /]
|
||||
```
|
||||
|
||||
Rules:
|
||||
|
||||
- `[view ...]` is no longer valid for new output.
|
||||
- Canvas shortcodes render in the assistant message surface only.
|
||||
- Only URL-backed canvases are rendered. Use `ref="..."` or `url="..."`.
|
||||
- Block-form inline HTML canvas shortcodes are not rendered.
|
||||
- The web UI strips the shortcode from visible text and renders the canvas inline.
|
||||
- `MEDIA:` is not a canvas alias and should not be used for rich canvas rendering.
|
||||
|
||||
## Stored Rendering Shape
|
||||
|
||||
The normalized/stored assistant content block is a structured `canvas` item:
|
||||
|
||||
```json
|
||||
{
|
||||
"type": "canvas",
|
||||
"preview": {
|
||||
"kind": "canvas",
|
||||
"surface": "assistant_message",
|
||||
"render": "url",
|
||||
"viewId": "cv_123",
|
||||
"url": "/__openclaw__/canvas/documents/cv_123/index.html",
|
||||
"title": "Status",
|
||||
"preferredHeight": 320
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
Stored/rendered rich blocks use this `canvas` shape directly. `present_view` is not recognized.
|
||||
@@ -136,6 +136,9 @@ Skills provide your tools. When you need one, check its `SKILL.md`. Keep local n
|
||||
|
||||
When you receive a heartbeat poll (message matches the configured heartbeat prompt), don't just reply `HEARTBEAT_OK` every time. Use heartbeats productively!
|
||||
|
||||
Default heartbeat prompt:
|
||||
`Read HEARTBEAT.md if it exists (workspace context). Follow it strictly. Do not infer or repeat old tasks from prior chats. If nothing needs attention, reply HEARTBEAT_OK.`
|
||||
|
||||
You are free to edit `HEARTBEAT.md` with a short checklist or reminders. Keep it small to limit token burn.
|
||||
|
||||
### Heartbeat vs Cron: When to Use Each
|
||||
|
||||
@@ -146,7 +146,7 @@ Browser settings live in `~/.openclaw/openclaw.json`.
|
||||
browser: {
|
||||
enabled: true, // default: true
|
||||
ssrfPolicy: {
|
||||
// dangerouslyAllowPrivateNetwork: true, // opt in only for trusted private-network access
|
||||
dangerouslyAllowPrivateNetwork: true, // default trusted-network mode
|
||||
// allowPrivateNetwork: true, // legacy alias
|
||||
// hostnameAllowlist: ["*.example.com", "example.com"],
|
||||
// allowedHostnames: ["localhost"],
|
||||
@@ -191,7 +191,7 @@ Notes:
|
||||
- `remoteCdpHandshakeTimeoutMs` applies to remote CDP WebSocket reachability checks.
|
||||
- Browser navigation/open-tab is SSRF-guarded before navigation and best-effort re-checked on final `http(s)` URL after navigation.
|
||||
- In strict SSRF mode, remote CDP endpoint discovery/probes (`cdpUrl`, including `/json/version` lookups) are checked too.
|
||||
- `browser.ssrfPolicy.dangerouslyAllowPrivateNetwork` is disabled by default. Set it to `true` only when you intentionally trust private-network browser access.
|
||||
- `browser.ssrfPolicy.dangerouslyAllowPrivateNetwork` defaults to `true` (trusted-network model). Set it to `false` for strict public-only browsing.
|
||||
- `browser.ssrfPolicy.allowPrivateNetwork` remains supported as a legacy alias for compatibility.
|
||||
- `attachOnly: true` means “never launch a local browser; only attach if it is already running.”
|
||||
- `color` + per-profile `color` tint the browser UI so you can see which profile is active.
|
||||
|
||||
@@ -20,11 +20,6 @@ session or config defaults request `ask: "on-miss"`.
|
||||
Use `openclaw approvals get`, `openclaw approvals get --gateway`, or
|
||||
`openclaw approvals get --node <id|name|ip>` to inspect the requested policy,
|
||||
host policy sources, and the effective result.
|
||||
For the local machine, `openclaw exec-policy show` exposes the same merged view and
|
||||
`openclaw exec-policy set|preset` can synchronize the local requested policy with the
|
||||
local host approvals file in one step. When a local scope requests `host=node`,
|
||||
`openclaw exec-policy show` reports that scope as node-managed at runtime instead of
|
||||
pretending the local approvals file is the effective source of truth.
|
||||
|
||||
If the companion app UI is **not available**, any request that requires a prompt is
|
||||
resolved by the **ask fallback** (default: deny).
|
||||
@@ -148,21 +143,6 @@ openclaw approvals set --stdin <<'EOF'
|
||||
EOF
|
||||
```
|
||||
|
||||
Local shortcut for the same gateway-host policy on the current machine:
|
||||
|
||||
```bash
|
||||
openclaw exec-policy preset yolo
|
||||
```
|
||||
|
||||
That local shortcut updates both:
|
||||
|
||||
- local `tools.exec.host/security/ask`
|
||||
- local `~/.openclaw/exec-approvals.json` defaults
|
||||
|
||||
It is intentionally local-only. If you need to change gateway-host or node-host approvals
|
||||
remotely, continue using `openclaw approvals set --gateway` or
|
||||
`openclaw approvals set --node <id|name|ip>`.
|
||||
|
||||
For a node host, apply the same approvals file on that node instead:
|
||||
|
||||
```bash
|
||||
@@ -178,12 +158,6 @@ openclaw approvals set --node <id|name|ip> --stdin <<'EOF'
|
||||
EOF
|
||||
```
|
||||
|
||||
Important local-only limitation:
|
||||
|
||||
- `openclaw exec-policy` does not synchronize node approvals
|
||||
- `openclaw exec-policy set --host node` is rejected
|
||||
- node exec approvals are fetched from the node at runtime, so node-targeted updates must use `openclaw approvals --node ...`
|
||||
|
||||
Session-only shortcut:
|
||||
|
||||
- `/exec security=full ask=off` changes only the current session.
|
||||
|
||||
@@ -68,7 +68,7 @@ tool with the `react` action. Reaction behavior varies by channel.
|
||||
Per-channel `reactionLevel` config controls how broadly the agent uses reactions. Values are typically `off`, `ack`, `minimal`, or `extensive`.
|
||||
|
||||
- [Telegram reactionLevel](/channels/telegram#reaction-notifications) — `channels.telegram.reactionLevel`
|
||||
- [WhatsApp reactionLevel](/channels/whatsapp#reaction-level) — `channels.whatsapp.reactionLevel`
|
||||
- [WhatsApp reactionLevel](/channels/whatsapp#reactions) — `channels.whatsapp.reactionLevel`
|
||||
|
||||
Set `reactionLevel` on individual channels to tune how actively the agent reacts to messages on each platform.
|
||||
|
||||
|
||||
@@ -303,13 +303,6 @@ When an agent run starts, OpenClaw:
|
||||
|
||||
This is **scoped to the agent run**, not a global shell environment.
|
||||
|
||||
For the bundled `claude-cli` backend, OpenClaw also materializes the same
|
||||
eligible snapshot as a temporary Claude Code plugin and passes it with
|
||||
`--plugin-dir`. Claude Code can then use its native skill resolver while
|
||||
OpenClaw still owns precedence, per-agent allowlists, gating, and
|
||||
`skills.entries.*` env/API key injection. Other CLI backends use the prompt
|
||||
catalog only.
|
||||
|
||||
## Session snapshot (performance)
|
||||
|
||||
OpenClaw snapshots the eligible skills **when a session starts** and reuses that list for subsequent turns in the same session. Changes to skills or config take effect on the next new session.
|
||||
|
||||
@@ -152,7 +152,6 @@ Bundled plugins can add more slash commands. Current bundled commands in this re
|
||||
- `/phone status|arm <camera|screen|writes|all> [duration]|disarm` temporarily arms high-risk phone node commands.
|
||||
- `/voice status|list [limit]|set <voiceId|name>` manages Talk voice config. On Discord, the native command name is `/talkvoice`.
|
||||
- `/card ...` sends LINE rich card presets. See [LINE](/channels/line).
|
||||
- `/codex status|models|threads|resume|compact|review|account|mcp|skills` inspects and controls the bundled Codex app-server harness. See [Codex Harness](/plugins/codex-harness).
|
||||
- QQBot-only commands:
|
||||
- `/bot-ping`
|
||||
- `/bot-version`
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
"description": "OpenClaw ACP runtime backend",
|
||||
"type": "module",
|
||||
"dependencies": {
|
||||
"acpx": "0.5.3"
|
||||
"acpx": "0.5.2"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@openclaw/plugin-sdk": "workspace:*"
|
||||
|
||||
@@ -2,7 +2,7 @@ import { describe, expect, it } from "vitest";
|
||||
|
||||
type SplitCommandLine = (
|
||||
value: string,
|
||||
platform?: string,
|
||||
platform?: NodeJS.Platform | string,
|
||||
) => {
|
||||
command: string;
|
||||
args: string[];
|
||||
|
||||
@@ -1,15 +1,11 @@
|
||||
import type { AcpSessionStore } from "acpx/runtime";
|
||||
import { beforeEach, describe, expect, it, vi } from "vitest";
|
||||
import type { AcpRuntime } from "../runtime-api.js";
|
||||
import { AcpxRuntime } from "./runtime.js";
|
||||
|
||||
type TestSessionStore = {
|
||||
load(sessionId: string): Promise<Record<string, unknown> | undefined>;
|
||||
save(record: Record<string, unknown>): Promise<void>;
|
||||
};
|
||||
|
||||
function makeRuntime(baseStore: TestSessionStore): {
|
||||
function makeRuntime(baseStore: AcpSessionStore): {
|
||||
runtime: AcpxRuntime;
|
||||
wrappedStore: TestSessionStore & { markFresh: (sessionKey: string) => void };
|
||||
wrappedStore: AcpSessionStore & { markFresh: (sessionKey: string) => void };
|
||||
delegate: { close: AcpRuntime["close"] };
|
||||
} {
|
||||
const runtime = new AcpxRuntime({
|
||||
@@ -26,7 +22,7 @@ function makeRuntime(baseStore: TestSessionStore): {
|
||||
runtime,
|
||||
wrappedStore: (
|
||||
runtime as unknown as {
|
||||
sessionStore: TestSessionStore & { markFresh: (sessionKey: string) => void };
|
||||
sessionStore: AcpSessionStore & { markFresh: (sessionKey: string) => void };
|
||||
}
|
||||
).sessionStore,
|
||||
delegate: (runtime as unknown as { delegate: { close: AcpRuntime["close"] } }).delegate,
|
||||
@@ -39,7 +35,7 @@ describe("AcpxRuntime fresh reset wrapper", () => {
|
||||
});
|
||||
|
||||
it("keeps stale persistent loads hidden until a fresh record is saved", async () => {
|
||||
const baseStore: TestSessionStore = {
|
||||
const baseStore: AcpSessionStore = {
|
||||
load: vi.fn(async () => ({ acpxRecordId: "stale" }) as never),
|
||||
save: vi.fn(async () => {}),
|
||||
};
|
||||
@@ -72,7 +68,7 @@ describe("AcpxRuntime fresh reset wrapper", () => {
|
||||
});
|
||||
|
||||
it("marks the session fresh after discardPersistentState close", async () => {
|
||||
const baseStore: TestSessionStore = {
|
||||
const baseStore: AcpSessionStore = {
|
||||
load: vi.fn(async () => ({ acpxRecordId: "stale" }) as never),
|
||||
save: vi.fn(async () => {}),
|
||||
};
|
||||
|
||||
@@ -111,7 +111,7 @@ describe("active-memory plugin", () => {
|
||||
runEmbeddedPiAgent.mockResolvedValue({
|
||||
payloads: [{ text: "- lemon pepper wings\n- blue cheese" }],
|
||||
});
|
||||
await plugin.register(api as unknown as OpenClawPluginApi);
|
||||
plugin.register(api as unknown as OpenClawPluginApi);
|
||||
});
|
||||
|
||||
afterEach(async () => {
|
||||
@@ -406,7 +406,7 @@ describe("active-memory plugin", () => {
|
||||
agents: ["main"],
|
||||
allowedChatTypes: ["direct", "group"],
|
||||
};
|
||||
await plugin.register(api as unknown as OpenClawPluginApi);
|
||||
plugin.register(api as unknown as OpenClawPluginApi);
|
||||
|
||||
const result = await hooks.before_prompt_build(
|
||||
{ prompt: "what wings should we order?", messages: [] },
|
||||
@@ -509,7 +509,7 @@ describe("active-memory plugin", () => {
|
||||
agents: ["main"],
|
||||
queryMode: "message",
|
||||
};
|
||||
await plugin.register(api as unknown as OpenClawPluginApi);
|
||||
plugin.register(api as unknown as OpenClawPluginApi);
|
||||
|
||||
await hooks.before_prompt_build(
|
||||
{
|
||||
@@ -537,7 +537,7 @@ describe("active-memory plugin", () => {
|
||||
queryMode: "message",
|
||||
promptStyle: "preference-only",
|
||||
};
|
||||
await plugin.register(api as unknown as OpenClawPluginApi);
|
||||
plugin.register(api as unknown as OpenClawPluginApi);
|
||||
|
||||
await hooks.before_prompt_build(
|
||||
{
|
||||
@@ -582,7 +582,7 @@ describe("active-memory plugin", () => {
|
||||
agents: ["main"],
|
||||
thinking: "medium",
|
||||
};
|
||||
await plugin.register(api as unknown as OpenClawPluginApi);
|
||||
plugin.register(api as unknown as OpenClawPluginApi);
|
||||
|
||||
await hooks.before_prompt_build(
|
||||
{
|
||||
@@ -608,7 +608,7 @@ describe("active-memory plugin", () => {
|
||||
agents: ["main"],
|
||||
promptAppend: "Prefer stable long-term preferences over one-off events.",
|
||||
};
|
||||
await plugin.register(api as unknown as OpenClawPluginApi);
|
||||
plugin.register(api as unknown as OpenClawPluginApi);
|
||||
|
||||
await hooks.before_prompt_build(
|
||||
{
|
||||
@@ -637,7 +637,7 @@ describe("active-memory plugin", () => {
|
||||
promptOverride: "Custom memory prompt. Return NONE or one user fact.",
|
||||
promptAppend: "Extra custom instruction.",
|
||||
};
|
||||
await plugin.register(api as unknown as OpenClawPluginApi);
|
||||
plugin.register(api as unknown as OpenClawPluginApi);
|
||||
|
||||
await hooks.before_prompt_build(
|
||||
{
|
||||
@@ -710,7 +710,7 @@ describe("active-memory plugin", () => {
|
||||
api.pluginConfig = {
|
||||
agents: ["main"],
|
||||
};
|
||||
await plugin.register(api as unknown as OpenClawPluginApi);
|
||||
plugin.register(api as unknown as OpenClawPluginApi);
|
||||
|
||||
await hooks.before_prompt_build(
|
||||
{ prompt: "what wings should i order? temp transcript", messages: [] },
|
||||
@@ -735,7 +735,7 @@ describe("active-memory plugin", () => {
|
||||
agents: ["main"],
|
||||
modelFallbackPolicy: "resolved-only",
|
||||
};
|
||||
await plugin.register(api as unknown as OpenClawPluginApi);
|
||||
plugin.register(api as unknown as OpenClawPluginApi);
|
||||
|
||||
const result = await hooks.before_prompt_build(
|
||||
{ prompt: "what wings should i order? no fallback", messages: [] },
|
||||
@@ -872,7 +872,7 @@ describe("active-memory plugin", () => {
|
||||
timeoutMs: 250,
|
||||
logging: true,
|
||||
};
|
||||
await plugin.register(api as unknown as OpenClawPluginApi);
|
||||
plugin.register(api as unknown as OpenClawPluginApi);
|
||||
let lastAbortSignal: AbortSignal | undefined;
|
||||
runEmbeddedPiAgent.mockImplementation(async (params: { abortSignal?: AbortSignal }) => {
|
||||
lastAbortSignal = params.abortSignal;
|
||||
@@ -918,7 +918,7 @@ describe("active-memory plugin", () => {
|
||||
agents: ["main"],
|
||||
logging: true,
|
||||
};
|
||||
await plugin.register(api as unknown as OpenClawPluginApi);
|
||||
plugin.register(api as unknown as OpenClawPluginApi);
|
||||
|
||||
await hooks.before_prompt_build(
|
||||
{ prompt: "what wings should i order? session id cache", messages: [] },
|
||||
@@ -1037,7 +1037,7 @@ describe("active-memory plugin", () => {
|
||||
agents: ["main"],
|
||||
queryMode: "message",
|
||||
};
|
||||
await plugin.register(api as unknown as OpenClawPluginApi);
|
||||
plugin.register(api as unknown as OpenClawPluginApi);
|
||||
|
||||
await hooks.before_prompt_build(
|
||||
{
|
||||
@@ -1065,7 +1065,7 @@ describe("active-memory plugin", () => {
|
||||
agents: ["main"],
|
||||
queryMode: "full",
|
||||
};
|
||||
await plugin.register(api as unknown as OpenClawPluginApi);
|
||||
plugin.register(api as unknown as OpenClawPluginApi);
|
||||
|
||||
await hooks.before_prompt_build(
|
||||
{
|
||||
@@ -1096,7 +1096,7 @@ describe("active-memory plugin", () => {
|
||||
agents: ["main"],
|
||||
queryMode: "recent",
|
||||
};
|
||||
await plugin.register(api as unknown as OpenClawPluginApi);
|
||||
plugin.register(api as unknown as OpenClawPluginApi);
|
||||
|
||||
await hooks.before_prompt_build(
|
||||
{
|
||||
@@ -1174,7 +1174,7 @@ describe("active-memory plugin", () => {
|
||||
agents: ["main"],
|
||||
maxSummaryChars: 40,
|
||||
};
|
||||
await plugin.register(api as unknown as OpenClawPluginApi);
|
||||
plugin.register(api as unknown as OpenClawPluginApi);
|
||||
runEmbeddedPiAgent.mockResolvedValueOnce({
|
||||
payloads: [
|
||||
{
|
||||
@@ -1211,7 +1211,7 @@ describe("active-memory plugin", () => {
|
||||
agents: ["main"],
|
||||
maxSummaryChars: 90,
|
||||
};
|
||||
await plugin.register(api as unknown as OpenClawPluginApi);
|
||||
plugin.register(api as unknown as OpenClawPluginApi);
|
||||
|
||||
await hooks.before_prompt_build(
|
||||
{ prompt: "what wings should i order? prompt-count-check", messages: [] },
|
||||
@@ -1261,7 +1261,7 @@ describe("active-memory plugin", () => {
|
||||
transcriptDir: "active-memory-subagents",
|
||||
logging: true,
|
||||
};
|
||||
await plugin.register(api as unknown as OpenClawPluginApi);
|
||||
plugin.register(api as unknown as OpenClawPluginApi);
|
||||
const mkdirSpy = vi.spyOn(fs, "mkdir").mockResolvedValue(undefined);
|
||||
const mkdtempSpy = vi.spyOn(fs, "mkdtemp");
|
||||
const rmSpy = vi.spyOn(fs, "rm").mockResolvedValue(undefined);
|
||||
@@ -1305,7 +1305,7 @@ describe("active-memory plugin", () => {
|
||||
transcriptDir: "C:/temp/escape",
|
||||
logging: true,
|
||||
};
|
||||
await plugin.register(api as unknown as OpenClawPluginApi);
|
||||
plugin.register(api as unknown as OpenClawPluginApi);
|
||||
const mkdirSpy = vi.spyOn(fs, "mkdir").mockResolvedValue(undefined);
|
||||
|
||||
await hooks.before_prompt_build(
|
||||
@@ -1342,7 +1342,7 @@ describe("active-memory plugin", () => {
|
||||
transcriptDir: "active-memory-subagents",
|
||||
logging: true,
|
||||
};
|
||||
await plugin.register(api as unknown as OpenClawPluginApi);
|
||||
plugin.register(api as unknown as OpenClawPluginApi);
|
||||
const mkdirSpy = vi.spyOn(fs, "mkdir").mockResolvedValue(undefined);
|
||||
|
||||
await hooks.before_prompt_build(
|
||||
@@ -1409,7 +1409,7 @@ describe("active-memory plugin", () => {
|
||||
agents: ["main"],
|
||||
logging: true,
|
||||
};
|
||||
await plugin.register(api as unknown as OpenClawPluginApi);
|
||||
plugin.register(api as unknown as OpenClawPluginApi);
|
||||
|
||||
for (let index = 0; index <= 1000; index += 1) {
|
||||
await hooks.before_prompt_build(
|
||||
|
||||
@@ -1496,7 +1496,7 @@ export default definePluginEntry({
|
||||
agentId: effectiveAgentId,
|
||||
sessionKey: resolvedSessionKey,
|
||||
});
|
||||
return undefined;
|
||||
return;
|
||||
}
|
||||
if (!isEnabledForAgent(config, effectiveAgentId)) {
|
||||
await persistPluginStatusLines({
|
||||
@@ -1504,7 +1504,7 @@ export default definePluginEntry({
|
||||
agentId: effectiveAgentId,
|
||||
sessionKey: resolvedSessionKey,
|
||||
});
|
||||
return undefined;
|
||||
return;
|
||||
}
|
||||
if (!isEligibleInteractiveSession(ctx)) {
|
||||
await persistPluginStatusLines({
|
||||
@@ -1512,7 +1512,7 @@ export default definePluginEntry({
|
||||
agentId: effectiveAgentId,
|
||||
sessionKey: resolvedSessionKey,
|
||||
});
|
||||
return undefined;
|
||||
return;
|
||||
}
|
||||
if (
|
||||
!isAllowedChatType(config, {
|
||||
@@ -1526,7 +1526,7 @@ export default definePluginEntry({
|
||||
agentId: effectiveAgentId,
|
||||
sessionKey: resolvedSessionKey,
|
||||
});
|
||||
return undefined;
|
||||
return;
|
||||
}
|
||||
const query = buildQuery({
|
||||
latestUserMessage: event.prompt,
|
||||
@@ -1544,11 +1544,11 @@ export default definePluginEntry({
|
||||
currentModelId: ctx.modelId,
|
||||
});
|
||||
if (!result.summary) {
|
||||
return undefined;
|
||||
return;
|
||||
}
|
||||
const metadata = buildMetadata(result.summary);
|
||||
if (!metadata) {
|
||||
return undefined;
|
||||
return;
|
||||
}
|
||||
return {
|
||||
prependSystemContext: ACTIVE_MEMORY_PLUGIN_GUIDANCE,
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
"description": "OpenClaw Amazon Bedrock provider plugin",
|
||||
"type": "module",
|
||||
"dependencies": {
|
||||
"@aws-sdk/client-bedrock": "3.1028.0"
|
||||
"@aws-sdk/client-bedrock": "3.1024.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@openclaw/plugin-sdk": "workspace:*"
|
||||
|
||||
@@ -7,6 +7,7 @@ import {
|
||||
CLAUDE_CLI_BACKEND_ID,
|
||||
CLAUDE_CLI_DEFAULT_MODEL_REF,
|
||||
CLAUDE_CLI_CLEAR_ENV,
|
||||
CLAUDE_CLI_HOST_MANAGED_ENV,
|
||||
CLAUDE_CLI_MODEL_ALIASES,
|
||||
CLAUDE_CLI_SESSION_ID_FIELDS,
|
||||
normalizeClaudeBackendConfig,
|
||||
@@ -62,6 +63,7 @@ export function buildAnthropicCliBackend(): CliBackendPlugin {
|
||||
systemPromptArg: "--append-system-prompt",
|
||||
systemPromptMode: "append",
|
||||
systemPromptWhen: "first",
|
||||
env: { ...CLAUDE_CLI_HOST_MANAGED_ENV },
|
||||
clearEnv: [...CLAUDE_CLI_CLEAR_ENV],
|
||||
reliability: {
|
||||
watchdog: {
|
||||
|
||||
@@ -2,6 +2,7 @@ import { describe, expect, it } from "vitest";
|
||||
import { buildAnthropicCliBackend } from "./cli-backend.js";
|
||||
import {
|
||||
CLAUDE_CLI_CLEAR_ENV,
|
||||
CLAUDE_CLI_HOST_MANAGED_ENV,
|
||||
normalizeClaudeBackendConfig,
|
||||
normalizeClaudePermissionArgs,
|
||||
normalizeClaudeSettingSourcesArgs,
|
||||
@@ -131,19 +132,16 @@ describe("normalizeClaudeBackendConfig", () => {
|
||||
expect(normalized?.resumeArgs).toContain("user");
|
||||
});
|
||||
|
||||
it("leaves claude cli subscription-managed, restricts setting sources, and clears inherited env overrides", () => {
|
||||
it("marks claude cli as host-managed, restricts setting sources, and clears inherited env overrides", () => {
|
||||
const backend = buildAnthropicCliBackend();
|
||||
|
||||
expect(backend.config.env).toBeUndefined();
|
||||
expect(backend.config.env).toEqual(CLAUDE_CLI_HOST_MANAGED_ENV);
|
||||
expect(backend.config.args).toContain("--setting-sources");
|
||||
expect(backend.config.args).toContain("user");
|
||||
expect(backend.config.resumeArgs).toContain("--setting-sources");
|
||||
expect(backend.config.resumeArgs).toContain("user");
|
||||
expect(backend.config.clearEnv).toEqual([...CLAUDE_CLI_CLEAR_ENV]);
|
||||
expect(backend.config.clearEnv).toContain("ANTHROPIC_API_TOKEN");
|
||||
expect(backend.config.clearEnv).toContain("ANTHROPIC_BASE_URL");
|
||||
expect(backend.config.clearEnv).toContain("ANTHROPIC_CUSTOM_HEADERS");
|
||||
expect(backend.config.clearEnv).toContain("ANTHROPIC_OAUTH_TOKEN");
|
||||
expect(backend.config.clearEnv).toContain("CLAUDE_CONFIG_DIR");
|
||||
expect(backend.config.clearEnv).toContain("CLAUDE_CODE_USE_BEDROCK");
|
||||
expect(backend.config.clearEnv).toContain("CLAUDE_CODE_OAUTH_TOKEN");
|
||||
|
||||
@@ -40,6 +40,10 @@ export const CLAUDE_CLI_SESSION_ID_FIELDS = [
|
||||
"conversationId",
|
||||
] as const;
|
||||
|
||||
export const CLAUDE_CLI_HOST_MANAGED_ENV = {
|
||||
CLAUDE_CODE_PROVIDER_MANAGED_BY_HOST: "1",
|
||||
} as const;
|
||||
|
||||
// Claude Code honors provider-routing, auth, and config-root env before
|
||||
// consulting its local login state, so inherited shell overrides must not
|
||||
// steer OpenClaw-managed Claude CLI runs toward a different provider,
|
||||
@@ -47,11 +51,8 @@ export const CLAUDE_CLI_SESSION_ID_FIELDS = [
|
||||
export const CLAUDE_CLI_CLEAR_ENV = [
|
||||
"ANTHROPIC_API_KEY",
|
||||
"ANTHROPIC_API_KEY_OLD",
|
||||
"ANTHROPIC_API_TOKEN",
|
||||
"ANTHROPIC_AUTH_TOKEN",
|
||||
"ANTHROPIC_BASE_URL",
|
||||
"ANTHROPIC_CUSTOM_HEADERS",
|
||||
"ANTHROPIC_OAUTH_TOKEN",
|
||||
"ANTHROPIC_UNIX_SOCKET",
|
||||
"CLAUDE_CONFIG_DIR",
|
||||
"CLAUDE_CODE_API_KEY_FILE_DESCRIPTOR",
|
||||
|
||||
@@ -18,7 +18,7 @@ function runWrapper(apiKey: string | undefined): Record<string, string> | undefi
|
||||
return {} as never;
|
||||
};
|
||||
const wrapper = createAnthropicBetaHeadersWrapper(base, [CONTEXT_1M_BETA]);
|
||||
void wrapper(
|
||||
wrapper(
|
||||
{ provider: "anthropic", id: "claude-opus-4-6" } as never,
|
||||
{} as never,
|
||||
{ apiKey } as never,
|
||||
@@ -64,7 +64,7 @@ describe("anthropic stream wrappers", () => {
|
||||
extraParams: { context1m: true, serviceTier: "auto" },
|
||||
} as never);
|
||||
|
||||
void wrapped?.(
|
||||
wrapped?.(
|
||||
{ provider: "anthropic", api: "anthropic-messages", id: "claude-sonnet-4-6" } as never,
|
||||
{} as never,
|
||||
{ apiKey: "sk-ant-oat01-oauth-token" } as never,
|
||||
@@ -91,7 +91,7 @@ describe("anthropic stream wrappers", () => {
|
||||
extraParams: { context1m: true, serviceTier: "auto" },
|
||||
} as never);
|
||||
|
||||
void wrapped?.(
|
||||
wrapped?.(
|
||||
{ provider: "anthropic", api: "anthropic-messages", id: "claude-sonnet-4-6" } as never,
|
||||
{} as never,
|
||||
{ apiKey: "sk-ant-api-123" } as never,
|
||||
@@ -121,7 +121,7 @@ describe("createAnthropicFastModeWrapper", () => {
|
||||
};
|
||||
|
||||
const wrapper = createAnthropicFastModeWrapper(base, params.enabled ?? true);
|
||||
void wrapper(
|
||||
wrapper(
|
||||
{
|
||||
provider: params.provider ?? "anthropic",
|
||||
api: params.api ?? "anthropic-messages",
|
||||
@@ -177,7 +177,7 @@ describe("createAnthropicServiceTierWrapper", () => {
|
||||
};
|
||||
|
||||
const wrapper = createAnthropicServiceTierWrapper(base, params.serviceTier ?? "auto");
|
||||
void wrapper(
|
||||
wrapper(
|
||||
{
|
||||
provider: params.provider ?? "anthropic",
|
||||
api: params.api ?? "anthropic-messages",
|
||||
|
||||
@@ -1370,7 +1370,7 @@ describe("BlueBubbles webhook monitor", () => {
|
||||
mockDispatchReplyWithBufferedBlockDispatcher.mockImplementationOnce(async (params) => {
|
||||
await params.dispatcherOptions.onReplyStart?.();
|
||||
await params.dispatcherOptions.deliver({ text: "replying now" }, { kind: "final" });
|
||||
params.dispatcherOptions.onIdle?.();
|
||||
await params.dispatcherOptions.onIdle?.();
|
||||
return EMPTY_DISPATCH_RESULT;
|
||||
});
|
||||
|
||||
|
||||
@@ -109,7 +109,7 @@ function applyBlueBubblesSetupPatch(
|
||||
}
|
||||
|
||||
function validateBlueBubblesWebhookPath(value: string): string | undefined {
|
||||
const trimmed = value.trim();
|
||||
const trimmed = String(value ?? "").trim();
|
||||
if (!trimmed) {
|
||||
return "Required";
|
||||
}
|
||||
@@ -222,7 +222,7 @@ export const blueBubblesSetupWizard: ChannelSetupWizard = {
|
||||
currentValue: ({ cfg, accountId }) =>
|
||||
normalizeOptionalString(resolveBlueBubblesAccount({ cfg, accountId }).config.serverUrl),
|
||||
validate: ({ value }) => validateBlueBubblesServerUrlInput(value),
|
||||
normalizeValue: ({ value }) => value.trim(),
|
||||
normalizeValue: ({ value }) => String(value).trim(),
|
||||
applySet: async ({ cfg, accountId, value }) =>
|
||||
applyBlueBubblesSetupPatch(cfg, accountId, {
|
||||
serverUrl: value,
|
||||
@@ -241,7 +241,7 @@ export const blueBubblesSetupWizard: ChannelSetupWizard = {
|
||||
shouldPrompt: ({ credentialValues }) =>
|
||||
credentialValues[CONFIGURE_CUSTOM_WEBHOOK_FLAG] === "1",
|
||||
validate: ({ value }) => validateBlueBubblesWebhookPath(value),
|
||||
normalizeValue: ({ value }) => value.trim(),
|
||||
normalizeValue: ({ value }) => String(value).trim(),
|
||||
applySet: async ({ cfg, accountId, value }) =>
|
||||
applyBlueBubblesSetupPatch(cfg, accountId, {
|
||||
webhookPath: value,
|
||||
|
||||
@@ -65,7 +65,7 @@ describe("browser plugin", () => {
|
||||
|
||||
it("forwards per-session browser options into the tool factory", async () => {
|
||||
const { api, registerTool } = createApi();
|
||||
registerBrowserPlugin(api);
|
||||
await registerBrowserPlugin(api);
|
||||
|
||||
const tool = registerTool.mock.calls[0]?.[0];
|
||||
if (typeof tool !== "function") {
|
||||
|
||||
@@ -286,7 +286,7 @@ async function callBrowserProxy(params: {
|
||||
? Math.max(1, Math.floor(params.timeoutMs))
|
||||
: DEFAULT_BROWSER_PROXY_TIMEOUT_MS;
|
||||
const gatewayTimeoutMs = proxyTimeoutMs + BROWSER_PROXY_GATEWAY_TIMEOUT_SLACK_MS;
|
||||
const payload = await browserToolDeps.callGatewayTool(
|
||||
const payload = await browserToolDeps.callGatewayTool<{ payloadJSON?: string; payload?: string }>(
|
||||
"node.invoke",
|
||||
{ timeoutMs: gatewayTimeoutMs },
|
||||
{
|
||||
|
||||
@@ -83,12 +83,10 @@ describe("startBrowserBridgeServer auth", () => {
|
||||
});
|
||||
|
||||
it("serves noVNC bootstrap html without leaking password in Location header", async () => {
|
||||
let resolveCalls = 0;
|
||||
const bridge = await startBrowserBridgeServer({
|
||||
resolved: buildResolvedConfig(),
|
||||
authToken: "secret-token",
|
||||
resolveSandboxNoVncToken: (token) => {
|
||||
resolveCalls += 1;
|
||||
if (token !== "valid-token") {
|
||||
return null;
|
||||
}
|
||||
@@ -97,15 +95,8 @@ describe("startBrowserBridgeServer auth", () => {
|
||||
});
|
||||
servers.push({ stop: () => stopBrowserBridgeServer(bridge.server) });
|
||||
|
||||
const unauth = await fetch(`${bridge.baseUrl}/sandbox/novnc?token=valid-token`);
|
||||
expect(unauth.status).toBe(401);
|
||||
expect(resolveCalls).toBe(0);
|
||||
|
||||
const res = await fetch(`${bridge.baseUrl}/sandbox/novnc?token=valid-token`, {
|
||||
headers: { Authorization: "Bearer secret-token" },
|
||||
});
|
||||
const res = await fetch(`${bridge.baseUrl}/sandbox/novnc?token=valid-token`);
|
||||
expect(res.status).toBe(200);
|
||||
expect(resolveCalls).toBe(1);
|
||||
expect(res.headers.get("location")).toBeNull();
|
||||
expect(res.headers.get("cache-control")).toContain("no-store");
|
||||
expect(res.headers.get("referrer-policy")).toBe("no-referrer");
|
||||
|
||||
@@ -13,7 +13,6 @@ import {
|
||||
type ProfileContext,
|
||||
} from "./server-context.js";
|
||||
import {
|
||||
hasVerifiedBrowserAuth,
|
||||
installBrowserAuthMiddleware,
|
||||
installBrowserCommonMiddleware,
|
||||
} from "./server-middleware.js";
|
||||
@@ -77,19 +76,8 @@ export async function startBrowserBridgeServer(params: {
|
||||
const app = express();
|
||||
installBrowserCommonMiddleware(app);
|
||||
|
||||
const authToken = normalizeOptionalString(params.authToken);
|
||||
const authPassword = normalizeOptionalString(params.authPassword);
|
||||
if (!authToken && !authPassword) {
|
||||
throw new Error("bridge server requires auth (authToken/authPassword missing)");
|
||||
}
|
||||
installBrowserAuthMiddleware(app, { token: authToken, password: authPassword });
|
||||
|
||||
if (params.resolveSandboxNoVncToken) {
|
||||
app.get("/sandbox/novnc", (req, res) => {
|
||||
if (!hasVerifiedBrowserAuth(req)) {
|
||||
res.status(401).send("Unauthorized");
|
||||
return;
|
||||
}
|
||||
res.setHeader("Cache-Control", "no-store, no-cache, must-revalidate, proxy-revalidate");
|
||||
res.setHeader("Pragma", "no-cache");
|
||||
res.setHeader("Expires", "0");
|
||||
@@ -108,6 +96,13 @@ export async function startBrowserBridgeServer(params: {
|
||||
});
|
||||
}
|
||||
|
||||
const authToken = normalizeOptionalString(params.authToken);
|
||||
const authPassword = normalizeOptionalString(params.authPassword);
|
||||
if (!authToken && !authPassword) {
|
||||
throw new Error("bridge server requires auth (authToken/authPassword missing)");
|
||||
}
|
||||
installBrowserAuthMiddleware(app, { token: authToken, password: authPassword });
|
||||
|
||||
const state: BrowserServerState = {
|
||||
server: null as unknown as Server,
|
||||
port,
|
||||
|
||||
@@ -1,65 +0,0 @@
|
||||
import { afterEach, describe, expect, it, vi } from "vitest";
|
||||
|
||||
const fetchWithSsrFGuardMock = vi.hoisted(() => vi.fn());
|
||||
|
||||
vi.mock("openclaw/plugin-sdk/ssrf-runtime", async (importOriginal) => {
|
||||
const actual = await importOriginal<typeof import("openclaw/plugin-sdk/ssrf-runtime")>();
|
||||
return {
|
||||
...actual,
|
||||
fetchWithSsrFGuard: (...args: unknown[]) => fetchWithSsrFGuardMock(...args),
|
||||
};
|
||||
});
|
||||
|
||||
import { fetchJson, fetchOk } from "./cdp.helpers.js";
|
||||
|
||||
describe("cdp helpers", () => {
|
||||
afterEach(() => {
|
||||
fetchWithSsrFGuardMock.mockReset();
|
||||
});
|
||||
|
||||
it("releases guarded CDP fetches after the response body is consumed", async () => {
|
||||
const release = vi.fn(async () => {});
|
||||
const json = vi.fn(async () => {
|
||||
expect(release).not.toHaveBeenCalled();
|
||||
return { ok: true };
|
||||
});
|
||||
fetchWithSsrFGuardMock.mockResolvedValueOnce({
|
||||
response: {
|
||||
ok: true,
|
||||
status: 200,
|
||||
json,
|
||||
},
|
||||
release,
|
||||
});
|
||||
|
||||
await expect(
|
||||
fetchJson("http://127.0.0.1:9222/json/version", 250, undefined, {
|
||||
dangerouslyAllowPrivateNetwork: false,
|
||||
allowedHostnames: ["127.0.0.1"],
|
||||
}),
|
||||
).resolves.toEqual({ ok: true });
|
||||
|
||||
expect(json).toHaveBeenCalledTimes(1);
|
||||
expect(release).toHaveBeenCalledTimes(1);
|
||||
});
|
||||
|
||||
it("releases guarded CDP fetches for bodyless requests", async () => {
|
||||
const release = vi.fn(async () => {});
|
||||
fetchWithSsrFGuardMock.mockResolvedValueOnce({
|
||||
response: {
|
||||
ok: true,
|
||||
status: 200,
|
||||
},
|
||||
release,
|
||||
});
|
||||
|
||||
await expect(
|
||||
fetchOk("http://127.0.0.1:9222/json/close/TARGET_1", 250, undefined, {
|
||||
dangerouslyAllowPrivateNetwork: false,
|
||||
allowedHostnames: ["127.0.0.1"],
|
||||
}),
|
||||
).resolves.toBeUndefined();
|
||||
|
||||
expect(release).toHaveBeenCalledTimes(1);
|
||||
});
|
||||
});
|
||||
@@ -1,17 +1,11 @@
|
||||
import { fetchWithSsrFGuard } from "openclaw/plugin-sdk/ssrf-runtime";
|
||||
import { normalizeLowercaseStringOrEmpty } from "openclaw/plugin-sdk/text-runtime";
|
||||
import WebSocket from "ws";
|
||||
import { isLoopbackHost } from "../gateway/net.js";
|
||||
import {
|
||||
SsrFBlockedError,
|
||||
type SsrFPolicy,
|
||||
resolvePinnedHostnameWithPolicy,
|
||||
} from "../infra/net/ssrf.js";
|
||||
import { type SsrFPolicy, resolvePinnedHostnameWithPolicy } from "../infra/net/ssrf.js";
|
||||
import { rawDataToString } from "../infra/ws.js";
|
||||
import { redactSensitiveText } from "../logging/redact.js";
|
||||
import { getDirectAgentForCdp, withNoProxyForCdpUrl } from "./cdp-proxy-bypass.js";
|
||||
import { CDP_HTTP_REQUEST_TIMEOUT_MS, CDP_WS_HANDSHAKE_TIMEOUT_MS } from "./cdp-timeouts.js";
|
||||
import { BrowserCdpEndpointBlockedError } from "./errors.js";
|
||||
import { resolveBrowserRateLimitMessage } from "./rate-limit-message.js";
|
||||
|
||||
export { isLoopbackHost };
|
||||
@@ -68,13 +62,9 @@ export async function assertCdpEndpointAllowed(
|
||||
if (!["http:", "https:", "ws:", "wss:"].includes(parsed.protocol)) {
|
||||
throw new Error(`Invalid CDP URL protocol: ${parsed.protocol.replace(":", "")}`);
|
||||
}
|
||||
try {
|
||||
await resolvePinnedHostnameWithPolicy(parsed.hostname, {
|
||||
policy: ssrfPolicy,
|
||||
});
|
||||
} catch (error) {
|
||||
throw new BrowserCdpEndpointBlockedError({ cause: error });
|
||||
}
|
||||
await resolvePinnedHostnameWithPolicy(parsed.hostname, {
|
||||
policy: ssrfPolicy,
|
||||
});
|
||||
}
|
||||
|
||||
export function redactCdpUrl(cdpUrl: string | null | undefined): string | null | undefined {
|
||||
@@ -162,11 +152,6 @@ export function normalizeCdpHttpBaseForJsonEndpoints(cdpUrl: string): string {
|
||||
}
|
||||
}
|
||||
|
||||
type CdpFetchResult = {
|
||||
response: Response;
|
||||
release: () => Promise<void>;
|
||||
};
|
||||
|
||||
function createCdpSender(ws: WebSocket) {
|
||||
let nextId = 1;
|
||||
const pending = new Map<number, Pending>();
|
||||
@@ -232,47 +217,23 @@ export async function fetchJson<T>(
|
||||
url: string,
|
||||
timeoutMs = CDP_HTTP_REQUEST_TIMEOUT_MS,
|
||||
init?: RequestInit,
|
||||
ssrfPolicy?: SsrFPolicy,
|
||||
): Promise<T> {
|
||||
const { response, release } = await fetchCdpChecked(url, timeoutMs, init, ssrfPolicy);
|
||||
try {
|
||||
return (await response.json()) as T;
|
||||
} finally {
|
||||
await release();
|
||||
}
|
||||
const res = await fetchCdpChecked(url, timeoutMs, init);
|
||||
return (await res.json()) as T;
|
||||
}
|
||||
|
||||
export async function fetchCdpChecked(
|
||||
url: string,
|
||||
timeoutMs = CDP_HTTP_REQUEST_TIMEOUT_MS,
|
||||
init?: RequestInit,
|
||||
ssrfPolicy?: SsrFPolicy,
|
||||
): Promise<CdpFetchResult> {
|
||||
): Promise<Response> {
|
||||
const ctrl = new AbortController();
|
||||
const t = setTimeout(ctrl.abort.bind(ctrl), timeoutMs);
|
||||
let guardedRelease: (() => Promise<void>) | undefined;
|
||||
let released = false;
|
||||
const release = async () => {
|
||||
if (released) {
|
||||
return;
|
||||
}
|
||||
released = true;
|
||||
clearTimeout(t);
|
||||
await guardedRelease?.();
|
||||
};
|
||||
try {
|
||||
const headers = getHeadersWithAuth(url, (init?.headers as Record<string, string>) || {});
|
||||
const res = await withNoProxyForCdpUrl(url, async () => {
|
||||
const guarded = await fetchWithSsrFGuard({
|
||||
url,
|
||||
init: { ...init, headers },
|
||||
signal: ctrl.signal,
|
||||
policy: ssrfPolicy ?? { allowPrivateNetwork: true },
|
||||
auditContext: "browser-cdp",
|
||||
});
|
||||
guardedRelease = guarded.release;
|
||||
return guarded.response;
|
||||
});
|
||||
const res = await withNoProxyForCdpUrl(url, () =>
|
||||
fetch(url, { ...init, headers, signal: ctrl.signal }),
|
||||
);
|
||||
if (!res.ok) {
|
||||
if (res.status === 429) {
|
||||
// Do not reflect upstream response text into the error surface (log/agent injection risk)
|
||||
@@ -280,13 +241,9 @@ export async function fetchCdpChecked(
|
||||
}
|
||||
throw new Error(`HTTP ${res.status}`);
|
||||
}
|
||||
return { response: res, release };
|
||||
} catch (error) {
|
||||
await release();
|
||||
if (error instanceof SsrFBlockedError) {
|
||||
throw new BrowserCdpEndpointBlockedError({ cause: error });
|
||||
}
|
||||
throw error;
|
||||
return res;
|
||||
} finally {
|
||||
clearTimeout(t);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -294,10 +251,8 @@ export async function fetchOk(
|
||||
url: string,
|
||||
timeoutMs = CDP_HTTP_REQUEST_TIMEOUT_MS,
|
||||
init?: RequestInit,
|
||||
ssrfPolicy?: SsrFPolicy,
|
||||
): Promise<void> {
|
||||
const { release } = await fetchCdpChecked(url, timeoutMs, init, ssrfPolicy);
|
||||
await release();
|
||||
await fetchCdpChecked(url, timeoutMs, init);
|
||||
}
|
||||
|
||||
export function openCdpWebSocket(
|
||||
|
||||
@@ -1,29 +1,13 @@
|
||||
import { createServer } from "node:http";
|
||||
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
|
||||
import { afterEach, describe, expect, it, vi } from "vitest";
|
||||
import { type WebSocket, WebSocketServer } from "ws";
|
||||
import { SsrFBlockedError } from "../infra/net/ssrf.js";
|
||||
import { rawDataToString } from "../infra/ws.js";
|
||||
import { isWebSocketUrl } from "./cdp.helpers.js";
|
||||
import { createTargetViaCdp, evaluateJavaScript, normalizeCdpWsUrl, snapshotAria } from "./cdp.js";
|
||||
import { parseHttpUrl } from "./config.js";
|
||||
import { BrowserCdpEndpointBlockedError } from "./errors.js";
|
||||
import { InvalidBrowserNavigationUrlError } from "./navigation-guard.js";
|
||||
|
||||
vi.mock("openclaw/plugin-sdk/browser-security-runtime", async () => {
|
||||
const actual = await vi.importActual<
|
||||
typeof import("openclaw/plugin-sdk/browser-security-runtime")
|
||||
>("openclaw/plugin-sdk/browser-security-runtime");
|
||||
const lookupFn = async (_hostname: string, options?: { all?: boolean }) => {
|
||||
const result = { address: "93.184.216.34", family: 4 };
|
||||
return options?.all === true ? [result] : result;
|
||||
};
|
||||
return {
|
||||
...actual,
|
||||
resolvePinnedHostnameWithPolicy: (hostname: string, params: object = {}) =>
|
||||
actual.resolvePinnedHostnameWithPolicy(hostname, { ...params, lookupFn: lookupFn as never }),
|
||||
};
|
||||
});
|
||||
|
||||
describe("cdp", () => {
|
||||
let httpServer: ReturnType<typeof createServer> | null = null;
|
||||
let wsServer: WebSocketServer | null = null;
|
||||
@@ -72,7 +56,6 @@ describe("cdp", () => {
|
||||
};
|
||||
|
||||
afterEach(async () => {
|
||||
vi.unstubAllEnvs();
|
||||
await new Promise<void>((resolve) => {
|
||||
if (!httpServer) {
|
||||
return resolve();
|
||||
@@ -202,22 +185,6 @@ describe("cdp", () => {
|
||||
}
|
||||
});
|
||||
|
||||
it("blocks hostname navigation targets when strict SSRF policy is configured", async () => {
|
||||
const fetchSpy = vi.spyOn(globalThis, "fetch");
|
||||
try {
|
||||
await expect(
|
||||
createTargetViaCdp({
|
||||
cdpUrl: "http://127.0.0.1:9222",
|
||||
url: "https://example.com",
|
||||
ssrfPolicy: { dangerouslyAllowPrivateNetwork: false },
|
||||
}),
|
||||
).rejects.toBeInstanceOf(InvalidBrowserNavigationUrlError);
|
||||
expect(fetchSpy).not.toHaveBeenCalled();
|
||||
} finally {
|
||||
fetchSpy.mockRestore();
|
||||
}
|
||||
});
|
||||
|
||||
it("blocks unsupported non-network navigation URLs", async () => {
|
||||
const fetchSpy = vi.spyOn(globalThis, "fetch");
|
||||
try {
|
||||
@@ -268,39 +235,39 @@ describe("cdp", () => {
|
||||
await expect(
|
||||
createTargetViaCdp({
|
||||
cdpUrl: `http://127.0.0.1:${httpPort}`,
|
||||
url: "https://93.184.216.34",
|
||||
url: "https://example.com",
|
||||
ssrfPolicy: {
|
||||
dangerouslyAllowPrivateNetwork: false,
|
||||
allowedHostnames: ["127.0.0.1"],
|
||||
},
|
||||
}),
|
||||
).rejects.toBeInstanceOf(BrowserCdpEndpointBlockedError);
|
||||
).rejects.toBeInstanceOf(SsrFBlockedError);
|
||||
});
|
||||
|
||||
it("blocks the initial /json/version fetch when the cdpUrl host is outside strict SSRF policy", async () => {
|
||||
await expect(
|
||||
createTargetViaCdp({
|
||||
cdpUrl: "http://169.254.169.254:9222",
|
||||
url: "https://93.184.216.34",
|
||||
url: "https://example.com",
|
||||
ssrfPolicy: {
|
||||
dangerouslyAllowPrivateNetwork: false,
|
||||
allowedHostnames: ["127.0.0.1"],
|
||||
},
|
||||
}),
|
||||
).rejects.toBeInstanceOf(BrowserCdpEndpointBlockedError);
|
||||
).rejects.toBeInstanceOf(SsrFBlockedError);
|
||||
});
|
||||
|
||||
it("blocks direct websocket cdp urls outside strict SSRF policy", async () => {
|
||||
await expect(
|
||||
createTargetViaCdp({
|
||||
cdpUrl: "ws://169.254.169.254:9222/devtools/browser/PIVOT",
|
||||
url: "https://93.184.216.34",
|
||||
url: "https://example.com",
|
||||
ssrfPolicy: {
|
||||
dangerouslyAllowPrivateNetwork: false,
|
||||
allowedHostnames: ["127.0.0.1"],
|
||||
},
|
||||
}),
|
||||
).rejects.toBeInstanceOf(BrowserCdpEndpointBlockedError);
|
||||
).rejects.toBeInstanceOf(SsrFBlockedError);
|
||||
});
|
||||
|
||||
it("evaluates javascript via CDP", async () => {
|
||||
@@ -503,17 +470,3 @@ describe("parseHttpUrl with WebSocket protocols", () => {
|
||||
expect(() => parseHttpUrl("file:///etc/passwd", "test")).toThrow("must be http(s) or ws(s)");
|
||||
});
|
||||
});
|
||||
const proxyEnvKeys = [
|
||||
"ALL_PROXY",
|
||||
"all_proxy",
|
||||
"HTTP_PROXY",
|
||||
"http_proxy",
|
||||
"HTTPS_PROXY",
|
||||
"https_proxy",
|
||||
] as const;
|
||||
|
||||
beforeEach(() => {
|
||||
for (const key of proxyEnvKeys) {
|
||||
vi.stubEnv(key, "");
|
||||
}
|
||||
});
|
||||
|
||||
@@ -78,8 +78,8 @@ export async function captureScreenshot(opts: {
|
||||
contentSize?: { width?: number; height?: number };
|
||||
};
|
||||
const size = metrics?.cssContentSize ?? metrics?.contentSize;
|
||||
const contentWidth = size?.width ?? 0;
|
||||
const contentHeight = size?.height ?? 0;
|
||||
const contentWidth = Number(size?.width ?? 0);
|
||||
const contentHeight = Number(size?.height ?? 0);
|
||||
if (contentWidth > 0 && contentHeight > 0) {
|
||||
const vpResult = (await send("Runtime.evaluate", {
|
||||
expression:
|
||||
@@ -91,14 +91,14 @@ export async function captureScreenshot(opts: {
|
||||
};
|
||||
};
|
||||
const v = vpResult?.result?.value;
|
||||
const currentW = v?.w ?? 0;
|
||||
const currentH = v?.h ?? 0;
|
||||
const currentW = Number(v?.w ?? 0);
|
||||
const currentH = Number(v?.h ?? 0);
|
||||
savedVp = {
|
||||
w: currentW,
|
||||
h: currentH,
|
||||
dpr: v?.dpr ?? 1,
|
||||
sw: v?.sw ?? currentW,
|
||||
sh: v?.sh ?? currentH,
|
||||
dpr: Number(v?.dpr ?? 1),
|
||||
sw: Number(v?.sw ?? currentW),
|
||||
sh: Number(v?.sh ?? currentH),
|
||||
};
|
||||
// mobile: false is the safe default — CDP provides no way to query
|
||||
// the active mobile flag, and inferring from navigator.maxTouchPoints
|
||||
@@ -148,7 +148,11 @@ export async function captureScreenshot(opts: {
|
||||
returnByValue: true,
|
||||
})) as { result?: { value?: { w?: number; h?: number; dpr?: number } } };
|
||||
const p = postResult?.result?.value;
|
||||
if (p?.w !== savedVp.w || p?.h !== savedVp.h || p?.dpr !== savedVp.dpr) {
|
||||
if (
|
||||
Number(p?.w) !== savedVp.w ||
|
||||
Number(p?.h) !== savedVp.h ||
|
||||
Number(p?.dpr) !== savedVp.dpr
|
||||
) {
|
||||
await send("Emulation.setDeviceMetricsOverride", {
|
||||
width: savedVp.w,
|
||||
height: savedVp.h,
|
||||
@@ -183,13 +187,12 @@ export async function createTargetViaCdp(opts: {
|
||||
wsUrl = opts.cdpUrl;
|
||||
} else {
|
||||
// Standard HTTP(S) CDP endpoint — discover WebSocket URL via /json/version.
|
||||
await assertCdpEndpointAllowed(opts.cdpUrl, opts.ssrfPolicy);
|
||||
const version = await fetchJson<{ webSocketDebuggerUrl?: string }>(
|
||||
appendCdpPath(opts.cdpUrl, "/json/version"),
|
||||
1500,
|
||||
undefined,
|
||||
opts.ssrfPolicy,
|
||||
);
|
||||
const wsUrlRaw = version?.webSocketDebuggerUrl?.trim() ?? "";
|
||||
const wsUrlRaw = String(version?.webSocketDebuggerUrl ?? "").trim();
|
||||
wsUrl = wsUrlRaw ? normalizeCdpWsUrl(wsUrlRaw, opts.cdpUrl) : "";
|
||||
if (!wsUrl) {
|
||||
throw new Error("CDP /json/version missing webSocketDebuggerUrl");
|
||||
@@ -201,7 +204,7 @@ export async function createTargetViaCdp(opts: {
|
||||
const created = (await send("Target.createTarget", { url: opts.url })) as {
|
||||
targetId?: string;
|
||||
};
|
||||
const targetId = created?.targetId?.trim() ?? "";
|
||||
const targetId = String(created?.targetId ?? "").trim();
|
||||
if (!targetId) {
|
||||
throw new Error("CDP Target.createTarget returned no targetId");
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { normalizeLowercaseStringOrEmpty } from "openclaw/plugin-sdk/text-runtime";
|
||||
import { normalizeString } from "../record-shared.js";
|
||||
import type { SnapshotAriaNode } from "./client.types.js";
|
||||
import type { SnapshotAriaNode } from "./client.js";
|
||||
import {
|
||||
getRoleSnapshotStats,
|
||||
type RoleRefMap,
|
||||
|
||||
@@ -7,7 +7,7 @@ import { normalizeOptionalString, readStringValue } from "openclaw/plugin-sdk/te
|
||||
import { resolvePreferredOpenClawTmpDir } from "../infra/tmp-openclaw-dir.js";
|
||||
import { asRecord } from "../record-shared.js";
|
||||
import type { ChromeMcpSnapshotNode } from "./chrome-mcp.snapshot.js";
|
||||
import type { BrowserTab } from "./client.types.js";
|
||||
import type { BrowserTab } from "./client.js";
|
||||
import { BrowserProfileUnavailableError, BrowserTabNotFoundError } from "./errors.js";
|
||||
|
||||
type ChromeMcpStructuredPage = {
|
||||
|
||||
@@ -691,7 +691,7 @@ export function readBrowserVersion(executablePath: string): string | null {
|
||||
}
|
||||
|
||||
export function parseBrowserMajorVersion(rawVersion: string | null | undefined): number | null {
|
||||
const matches = [...(rawVersion ?? "").matchAll(CHROME_VERSION_RE)];
|
||||
const matches = [...String(rawVersion ?? "").matchAll(CHROME_VERSION_RE)];
|
||||
const match = matches.at(-1);
|
||||
if (!match?.[1]) {
|
||||
return null;
|
||||
|
||||
@@ -6,6 +6,7 @@ import os from "node:os";
|
||||
import path from "node:path";
|
||||
import { afterAll, afterEach, beforeAll, beforeEach, describe, expect, it, vi } from "vitest";
|
||||
import { WebSocketServer } from "ws";
|
||||
import { SsrFBlockedError } from "../infra/net/ssrf.js";
|
||||
import {
|
||||
decorateOpenClawProfile,
|
||||
ensureProfileCleanExit,
|
||||
@@ -21,7 +22,6 @@ import {
|
||||
DEFAULT_OPENCLAW_BROWSER_COLOR,
|
||||
DEFAULT_OPENCLAW_BROWSER_PROFILE_NAME,
|
||||
} from "./constants.js";
|
||||
import { BrowserCdpEndpointBlockedError } from "./errors.js";
|
||||
|
||||
type StopChromeTarget = Parameters<typeof stopOpenClawChrome>[0];
|
||||
|
||||
@@ -357,7 +357,7 @@ describe("browser chrome helpers", () => {
|
||||
dangerouslyAllowPrivateNetwork: false,
|
||||
allowedHostnames: ["127.0.0.1"],
|
||||
}),
|
||||
).rejects.toBeInstanceOf(BrowserCdpEndpointBlockedError);
|
||||
).rejects.toBeInstanceOf(SsrFBlockedError);
|
||||
} finally {
|
||||
await new Promise<void>((resolve) => server.close(() => resolve()));
|
||||
}
|
||||
|
||||
@@ -171,22 +171,14 @@ async function fetchChromeVersion(
|
||||
const ctrl = new AbortController();
|
||||
const t = setTimeout(ctrl.abort.bind(ctrl), timeoutMs);
|
||||
try {
|
||||
await assertCdpEndpointAllowed(cdpUrl, ssrfPolicy);
|
||||
const versionUrl = appendCdpPath(cdpUrl, "/json/version");
|
||||
const { response, release } = await fetchCdpChecked(
|
||||
versionUrl,
|
||||
timeoutMs,
|
||||
{ signal: ctrl.signal },
|
||||
ssrfPolicy,
|
||||
);
|
||||
try {
|
||||
const data = (await response.json()) as ChromeVersion;
|
||||
if (!data || typeof data !== "object") {
|
||||
return null;
|
||||
}
|
||||
return data;
|
||||
} finally {
|
||||
await release();
|
||||
const res = await fetchCdpChecked(versionUrl, timeoutMs, { signal: ctrl.signal });
|
||||
const data = (await res.json()) as ChromeVersion;
|
||||
if (!data || typeof data !== "object") {
|
||||
return null;
|
||||
}
|
||||
return data;
|
||||
} catch {
|
||||
return null;
|
||||
} finally {
|
||||
|
||||
@@ -4,10 +4,95 @@ import type {
|
||||
BrowserActionTabResult,
|
||||
} from "./client-actions-types.js";
|
||||
import { buildProfileQuery, withBaseUrl } from "./client-actions-url.js";
|
||||
import type { BrowserActRequest, BrowserFormField } from "./client-actions.types.js";
|
||||
import { fetchBrowserJson } from "./client-fetch.js";
|
||||
|
||||
export type { BrowserActRequest, BrowserFormField } from "./client-actions.types.js";
|
||||
export type BrowserFormField = {
|
||||
ref: string;
|
||||
type: string;
|
||||
value?: string | number | boolean;
|
||||
};
|
||||
|
||||
export type BrowserActRequest =
|
||||
| {
|
||||
kind: "click";
|
||||
ref?: string;
|
||||
selector?: string;
|
||||
targetId?: string;
|
||||
doubleClick?: boolean;
|
||||
button?: string;
|
||||
modifiers?: string[];
|
||||
delayMs?: number;
|
||||
timeoutMs?: number;
|
||||
}
|
||||
| {
|
||||
kind: "type";
|
||||
ref?: string;
|
||||
selector?: string;
|
||||
text: string;
|
||||
targetId?: string;
|
||||
submit?: boolean;
|
||||
slowly?: boolean;
|
||||
timeoutMs?: number;
|
||||
}
|
||||
| { kind: "press"; key: string; targetId?: string; delayMs?: number }
|
||||
| {
|
||||
kind: "hover";
|
||||
ref?: string;
|
||||
selector?: string;
|
||||
targetId?: string;
|
||||
timeoutMs?: number;
|
||||
}
|
||||
| {
|
||||
kind: "scrollIntoView";
|
||||
ref?: string;
|
||||
selector?: string;
|
||||
targetId?: string;
|
||||
timeoutMs?: number;
|
||||
}
|
||||
| {
|
||||
kind: "drag";
|
||||
startRef?: string;
|
||||
startSelector?: string;
|
||||
endRef?: string;
|
||||
endSelector?: string;
|
||||
targetId?: string;
|
||||
timeoutMs?: number;
|
||||
}
|
||||
| {
|
||||
kind: "select";
|
||||
ref?: string;
|
||||
selector?: string;
|
||||
values: string[];
|
||||
targetId?: string;
|
||||
timeoutMs?: number;
|
||||
}
|
||||
| {
|
||||
kind: "fill";
|
||||
fields: BrowserFormField[];
|
||||
targetId?: string;
|
||||
timeoutMs?: number;
|
||||
}
|
||||
| { kind: "resize"; width: number; height: number; targetId?: string }
|
||||
| {
|
||||
kind: "wait";
|
||||
timeMs?: number;
|
||||
text?: string;
|
||||
textGone?: string;
|
||||
selector?: string;
|
||||
url?: string;
|
||||
loadState?: "load" | "domcontentloaded" | "networkidle";
|
||||
fn?: string;
|
||||
targetId?: string;
|
||||
timeoutMs?: number;
|
||||
}
|
||||
| { kind: "evaluate"; fn: string; ref?: string; targetId?: string; timeoutMs?: number }
|
||||
| { kind: "close"; targetId?: string }
|
||||
| {
|
||||
kind: "batch";
|
||||
actions: BrowserActRequest[];
|
||||
targetId?: string;
|
||||
stopOnError?: boolean;
|
||||
};
|
||||
|
||||
export type BrowserActResponse = {
|
||||
ok: true;
|
||||
|
||||
@@ -1,87 +0,0 @@
|
||||
export type BrowserFormField = {
|
||||
ref: string;
|
||||
type: string;
|
||||
value?: string | number | boolean;
|
||||
};
|
||||
|
||||
export type BrowserActRequest =
|
||||
| {
|
||||
kind: "click";
|
||||
ref?: string;
|
||||
selector?: string;
|
||||
targetId?: string;
|
||||
doubleClick?: boolean;
|
||||
button?: string;
|
||||
modifiers?: string[];
|
||||
delayMs?: number;
|
||||
timeoutMs?: number;
|
||||
}
|
||||
| {
|
||||
kind: "type";
|
||||
ref?: string;
|
||||
selector?: string;
|
||||
text: string;
|
||||
targetId?: string;
|
||||
submit?: boolean;
|
||||
slowly?: boolean;
|
||||
timeoutMs?: number;
|
||||
}
|
||||
| { kind: "press"; key: string; targetId?: string; delayMs?: number }
|
||||
| {
|
||||
kind: "hover";
|
||||
ref?: string;
|
||||
selector?: string;
|
||||
targetId?: string;
|
||||
timeoutMs?: number;
|
||||
}
|
||||
| {
|
||||
kind: "scrollIntoView";
|
||||
ref?: string;
|
||||
selector?: string;
|
||||
targetId?: string;
|
||||
timeoutMs?: number;
|
||||
}
|
||||
| {
|
||||
kind: "drag";
|
||||
startRef?: string;
|
||||
startSelector?: string;
|
||||
endRef?: string;
|
||||
endSelector?: string;
|
||||
targetId?: string;
|
||||
timeoutMs?: number;
|
||||
}
|
||||
| {
|
||||
kind: "select";
|
||||
ref?: string;
|
||||
selector?: string;
|
||||
values: string[];
|
||||
targetId?: string;
|
||||
timeoutMs?: number;
|
||||
}
|
||||
| {
|
||||
kind: "fill";
|
||||
fields: BrowserFormField[];
|
||||
targetId?: string;
|
||||
timeoutMs?: number;
|
||||
}
|
||||
| { kind: "resize"; width: number; height: number; targetId?: string }
|
||||
| {
|
||||
kind: "wait";
|
||||
timeMs?: number;
|
||||
text?: string;
|
||||
textGone?: string;
|
||||
selector?: string;
|
||||
url?: string;
|
||||
loadState?: "load" | "domcontentloaded" | "networkidle";
|
||||
fn?: string;
|
||||
targetId?: string;
|
||||
timeoutMs?: number;
|
||||
}
|
||||
| { kind: "evaluate"; fn: string; ref?: string; targetId?: string; timeoutMs?: number }
|
||||
| { kind: "close"; targetId?: string }
|
||||
| {
|
||||
kind: "batch";
|
||||
actions: BrowserActRequest[];
|
||||
targetId?: string;
|
||||
stopOnError?: boolean;
|
||||
};
|
||||
@@ -1,42 +1,6 @@
|
||||
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
|
||||
import type { BrowserDispatchResponse } from "./routes/dispatcher.js";
|
||||
|
||||
vi.mock("openclaw/plugin-sdk/browser-security-runtime", async () => {
|
||||
const actual = await vi.importActual<
|
||||
typeof import("openclaw/plugin-sdk/browser-security-runtime")
|
||||
>("openclaw/plugin-sdk/browser-security-runtime");
|
||||
const lookupFn = async (_hostname: string, options?: { all?: boolean }) => {
|
||||
const result = { address: "93.184.216.34", family: 4 };
|
||||
return options?.all === true ? [result] : result;
|
||||
};
|
||||
return {
|
||||
...actual,
|
||||
resolvePinnedHostnameWithPolicy: (hostname: string, params: object = {}) =>
|
||||
actual.resolvePinnedHostnameWithPolicy(hostname, { ...params, lookupFn: lookupFn as never }),
|
||||
};
|
||||
});
|
||||
|
||||
vi.mock("openclaw/plugin-sdk/ssrf-runtime", async () => {
|
||||
const actual = await vi.importActual<typeof import("openclaw/plugin-sdk/ssrf-runtime")>(
|
||||
"openclaw/plugin-sdk/ssrf-runtime",
|
||||
);
|
||||
return {
|
||||
...actual,
|
||||
fetchWithSsrFGuard: async (params: {
|
||||
url: string;
|
||||
init?: RequestInit;
|
||||
signal?: AbortSignal;
|
||||
}) => ({
|
||||
response: await fetch(params.url, {
|
||||
...params.init,
|
||||
signal: params.signal,
|
||||
}),
|
||||
finalUrl: params.url,
|
||||
release: async () => {},
|
||||
}),
|
||||
};
|
||||
});
|
||||
|
||||
function okDispatchResponse(): BrowserDispatchResponse {
|
||||
return { status: 200, body: { ok: true } };
|
||||
}
|
||||
@@ -123,16 +87,6 @@ async function expectThrownBrowserFetchError(
|
||||
describe("fetchBrowserJson loopback auth", () => {
|
||||
beforeEach(() => {
|
||||
vi.restoreAllMocks();
|
||||
for (const key of [
|
||||
"ALL_PROXY",
|
||||
"all_proxy",
|
||||
"HTTP_PROXY",
|
||||
"http_proxy",
|
||||
"HTTPS_PROXY",
|
||||
"https_proxy",
|
||||
]) {
|
||||
vi.stubEnv(key, "");
|
||||
}
|
||||
vi.stubEnv("OPENCLAW_GATEWAY_TOKEN", "loopback-token");
|
||||
mocks.loadConfig.mockClear();
|
||||
mocks.loadConfig.mockReturnValue({
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import { fetchWithSsrFGuard } from "openclaw/plugin-sdk/ssrf-runtime";
|
||||
import { normalizeOptionalString } from "openclaw/plugin-sdk/text-runtime";
|
||||
import { normalizeLowercaseStringOrEmpty } from "openclaw/plugin-sdk/text-runtime";
|
||||
import { formatCliCommand } from "../cli/command-format.js";
|
||||
@@ -6,7 +5,12 @@ import { loadConfig } from "../config/config.js";
|
||||
import { isLoopbackHost } from "../gateway/net.js";
|
||||
import { getBridgeAuthForPort } from "./bridge-auth-registry.js";
|
||||
import { resolveBrowserControlAuth } from "./control-auth.js";
|
||||
import {
|
||||
createBrowserControlContext,
|
||||
startBrowserControlServiceFromConfig,
|
||||
} from "./control-service.js";
|
||||
import { resolveBrowserRateLimitMessage } from "./rate-limit-message.js";
|
||||
import { createBrowserRouteDispatcher } from "./routes/dispatcher.js";
|
||||
|
||||
// Application-level error from the browser control service (service is reachable
|
||||
// but returned an error response). Must NOT be wrapped with "Can't reach ..." messaging.
|
||||
@@ -184,17 +188,8 @@ async function fetchHttpJson<T>(
|
||||
}
|
||||
|
||||
const t = setTimeout(() => ctrl.abort(new Error("timed out")), timeoutMs);
|
||||
let release: (() => Promise<void>) | undefined;
|
||||
try {
|
||||
const guarded = await fetchWithSsrFGuard({
|
||||
url,
|
||||
init,
|
||||
signal: ctrl.signal,
|
||||
policy: { allowPrivateNetwork: true },
|
||||
auditContext: "browser-control-client",
|
||||
});
|
||||
release = guarded.release;
|
||||
const res = guarded.response;
|
||||
const res = await fetch(url, { ...init, signal: ctrl.signal });
|
||||
if (!res.ok) {
|
||||
if (isRateLimitStatus(res.status)) {
|
||||
// Do not reflect upstream response text into the error surface (log/agent injection risk)
|
||||
@@ -209,7 +204,6 @@ async function fetchHttpJson<T>(
|
||||
return (await res.json()) as T;
|
||||
} finally {
|
||||
clearTimeout(t);
|
||||
await release?.();
|
||||
if (upstreamSignal && upstreamAbortListener) {
|
||||
upstreamSignal.removeEventListener("abort", upstreamAbortListener);
|
||||
}
|
||||
@@ -228,7 +222,11 @@ export async function fetchBrowserJson<T>(
|
||||
return await fetchHttpJson<T>(url, { ...httpInit, timeoutMs });
|
||||
}
|
||||
isDispatcherPath = true;
|
||||
const { dispatchBrowserControlRequest } = await import("./local-dispatch.runtime.js");
|
||||
const started = await startBrowserControlServiceFromConfig();
|
||||
if (!started) {
|
||||
throw new Error("browser control disabled");
|
||||
}
|
||||
const dispatcher = createBrowserRouteDispatcher(createBrowserControlContext());
|
||||
const parsed = new URL(url, "http://localhost");
|
||||
const query: Record<string, unknown> = {};
|
||||
for (const [key, value] of parsed.searchParams.entries()) {
|
||||
@@ -268,7 +266,7 @@ export async function fetchBrowserJson<T>(
|
||||
timer = setTimeout(() => abortCtrl.abort(new Error("timed out")), timeoutMs);
|
||||
}
|
||||
|
||||
const dispatchPromise = dispatchBrowserControlRequest({
|
||||
const dispatchPromise = dispatcher.dispatch({
|
||||
method:
|
||||
init?.method?.toUpperCase() === "DELETE"
|
||||
? "DELETE"
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import { fetchBrowserJson } from "./client-fetch.js";
|
||||
import type { BrowserTab, BrowserTransport, SnapshotAriaNode } from "./client.types.js";
|
||||
|
||||
export type { BrowserTab, BrowserTransport, SnapshotAriaNode } from "./client.types.js";
|
||||
export type BrowserTransport = "cdp" | "chrome-mcp";
|
||||
|
||||
export type BrowserStatus = {
|
||||
enabled: boolean;
|
||||
@@ -48,6 +47,24 @@ export type BrowserResetProfileResult = {
|
||||
to?: string;
|
||||
};
|
||||
|
||||
export type BrowserTab = {
|
||||
targetId: string;
|
||||
title: string;
|
||||
url: string;
|
||||
wsUrl?: string;
|
||||
type?: string;
|
||||
};
|
||||
|
||||
export type SnapshotAriaNode = {
|
||||
ref: string;
|
||||
role: string;
|
||||
name: string;
|
||||
value?: string;
|
||||
description?: string;
|
||||
backendDOMNodeId?: number;
|
||||
depth: number;
|
||||
};
|
||||
|
||||
export type SnapshotResult =
|
||||
| {
|
||||
ok: true;
|
||||
|
||||
@@ -1,19 +0,0 @@
|
||||
export type BrowserTransport = "cdp" | "chrome-mcp";
|
||||
|
||||
export type BrowserTab = {
|
||||
targetId: string;
|
||||
title: string;
|
||||
url: string;
|
||||
wsUrl?: string;
|
||||
type?: string;
|
||||
};
|
||||
|
||||
export type SnapshotAriaNode = {
|
||||
ref: string;
|
||||
role: string;
|
||||
name: string;
|
||||
value?: string;
|
||||
description?: string;
|
||||
backendDOMNodeId?: number;
|
||||
depth: number;
|
||||
};
|
||||
@@ -307,9 +307,11 @@ describe("browser config", () => {
|
||||
});
|
||||
});
|
||||
|
||||
it("defaults browser SSRF policy to strict mode when unset", () => {
|
||||
it("defaults browser SSRF policy to trusted-network mode", () => {
|
||||
const resolved = resolveBrowserConfig({});
|
||||
expect(resolved.ssrfPolicy).toEqual({});
|
||||
expect(resolved.ssrfPolicy).toEqual({
|
||||
dangerouslyAllowPrivateNetwork: true,
|
||||
});
|
||||
});
|
||||
|
||||
it("supports explicit strict mode by disabling private network access", () => {
|
||||
@@ -321,19 +323,6 @@ describe("browser config", () => {
|
||||
expect(resolved.ssrfPolicy).toEqual({});
|
||||
});
|
||||
|
||||
it("keeps allowlist-only browser SSRF policy strict by default", () => {
|
||||
const resolved = resolveBrowserConfig({
|
||||
ssrfPolicy: {
|
||||
allowedHostnames: ["example.com"],
|
||||
hostnameAllowlist: ["*.example.com"],
|
||||
},
|
||||
} as unknown as BrowserConfig);
|
||||
expect(resolved.ssrfPolicy).toEqual({
|
||||
allowedHostnames: ["example.com"],
|
||||
hostnameAllowlist: ["*.example.com"],
|
||||
});
|
||||
});
|
||||
|
||||
it("resolves existing-session profiles without cdpPort or cdpUrl", () => {
|
||||
const resolved = resolveBrowserConfig({
|
||||
profiles: {
|
||||
|
||||
@@ -42,14 +42,6 @@ export {
|
||||
export type { BrowserControlAuth };
|
||||
export { parseBrowserHttpUrl as parseHttpUrl };
|
||||
|
||||
type BrowserSsrFPolicyCompat = NonNullable<BrowserConfig["ssrfPolicy"]> & {
|
||||
/**
|
||||
* Legacy raw-config alias. Keep it out of the public BrowserConfig type while
|
||||
* still accepting old user files until doctor rewrites them.
|
||||
*/
|
||||
allowPrivateNetwork?: boolean;
|
||||
};
|
||||
|
||||
export type ResolvedBrowserConfig = {
|
||||
enabled: boolean;
|
||||
evaluateEnabled: boolean;
|
||||
@@ -127,7 +119,9 @@ function resolveCdpPortRangeStart(
|
||||
const normalizeStringList = normalizeOptionalTrimmedStringList;
|
||||
|
||||
function resolveBrowserSsrFPolicy(cfg: BrowserConfig | undefined): SsrFPolicy | undefined {
|
||||
const rawPolicy = cfg?.ssrfPolicy as BrowserSsrFPolicyCompat | undefined;
|
||||
const rawPolicy = cfg?.ssrfPolicy as
|
||||
| (BrowserConfig["ssrfPolicy"] & { allowPrivateNetwork?: boolean })
|
||||
| undefined;
|
||||
const allowPrivateNetwork = rawPolicy?.allowPrivateNetwork;
|
||||
const dangerouslyAllowPrivateNetwork = rawPolicy?.dangerouslyAllowPrivateNetwork;
|
||||
const allowedHostnames = normalizeStringList(rawPolicy?.allowedHostnames);
|
||||
@@ -135,7 +129,9 @@ function resolveBrowserSsrFPolicy(cfg: BrowserConfig | undefined): SsrFPolicy |
|
||||
const hasExplicitPrivateSetting =
|
||||
allowPrivateNetwork !== undefined || dangerouslyAllowPrivateNetwork !== undefined;
|
||||
const resolvedAllowPrivateNetwork =
|
||||
dangerouslyAllowPrivateNetwork === true || allowPrivateNetwork === true;
|
||||
dangerouslyAllowPrivateNetwork === true ||
|
||||
allowPrivateNetwork === true ||
|
||||
!hasExplicitPrivateSetting;
|
||||
|
||||
if (
|
||||
!resolvedAllowPrivateNetwork &&
|
||||
@@ -143,9 +139,7 @@ function resolveBrowserSsrFPolicy(cfg: BrowserConfig | undefined): SsrFPolicy |
|
||||
!allowedHostnames &&
|
||||
!hostnameAllowlist
|
||||
) {
|
||||
// Keep the default policy object present so CDP guards still enforce
|
||||
// fail-closed private-network checks on unconfigured installs.
|
||||
return {};
|
||||
return undefined;
|
||||
}
|
||||
|
||||
return {
|
||||
|
||||
@@ -9,7 +9,7 @@ const mocks = vi.hoisted(() => ({
|
||||
({
|
||||
authConfig,
|
||||
}: {
|
||||
authConfig?: NonNullable<NonNullable<OpenClawConfig["gateway"]>["auth"]>;
|
||||
authConfig?: NonNullable<NonNullable<OpenClawConfig["gateway"]>["auth"]> | undefined;
|
||||
}) => {
|
||||
const token =
|
||||
typeof authConfig?.token === "string"
|
||||
@@ -58,14 +58,6 @@ vi.mock("../gateway/auth.js", () => ({
|
||||
resolveGatewayAuth: mocks.resolveGatewayAuth,
|
||||
}));
|
||||
|
||||
function readPersistedConfig(): OpenClawConfig {
|
||||
const persistedCfg = mocks.writeConfigFile.mock.calls[0]?.[0];
|
||||
if (!persistedCfg) {
|
||||
throw new Error("expected persisted config");
|
||||
}
|
||||
return persistedCfg;
|
||||
}
|
||||
|
||||
let ensureBrowserControlAuth: typeof import("./control-auth.js").ensureBrowserControlAuth;
|
||||
|
||||
describe("ensureBrowserControlAuth", () => {
|
||||
@@ -184,7 +176,7 @@ describe("ensureBrowserControlAuth", () => {
|
||||
expect(result.auth.token).toBe(result.generatedToken);
|
||||
expect(result.auth.password).toBeUndefined();
|
||||
expect(mocks.writeConfigFile).toHaveBeenCalledTimes(1);
|
||||
const persistedCfg = readPersistedConfig();
|
||||
const persistedCfg = mocks.writeConfigFile.mock.calls[0]?.[0] as OpenClawConfig | undefined;
|
||||
expect(persistedCfg?.gateway?.auth?.mode).toBe("none");
|
||||
expect(persistedCfg?.gateway?.auth?.token).toBe(result.generatedToken);
|
||||
expect(mocks.ensureGatewayStartupAuth).not.toHaveBeenCalled();
|
||||
@@ -231,7 +223,7 @@ describe("ensureBrowserControlAuth", () => {
|
||||
expect(result.auth.token).toBe(result.generatedToken);
|
||||
expect(result.auth.password).toBeUndefined();
|
||||
expect(mocks.writeConfigFile).toHaveBeenCalledTimes(1);
|
||||
const persistedCfg = readPersistedConfig();
|
||||
const persistedCfg = mocks.writeConfigFile.mock.calls[0]?.[0] as OpenClawConfig | undefined;
|
||||
expect(persistedCfg?.gateway?.auth?.mode).toBe("none");
|
||||
expect(persistedCfg?.gateway?.auth?.token).toBe(result.generatedToken);
|
||||
expect(mocks.ensureGatewayStartupAuth).not.toHaveBeenCalled();
|
||||
@@ -254,7 +246,7 @@ describe("ensureBrowserControlAuth", () => {
|
||||
expect(result.auth.password).toBe(result.generatedToken);
|
||||
expect(result.auth.token).toBeUndefined();
|
||||
expect(mocks.writeConfigFile).toHaveBeenCalledTimes(1);
|
||||
const persistedCfg = readPersistedConfig();
|
||||
const persistedCfg = mocks.writeConfigFile.mock.calls[0]?.[0] as OpenClawConfig | undefined;
|
||||
expect(persistedCfg?.gateway?.auth?.mode).toBe("trusted-proxy");
|
||||
expect(persistedCfg?.gateway?.auth?.password).toBe(result.generatedToken);
|
||||
expect(mocks.ensureGatewayStartupAuth).not.toHaveBeenCalled();
|
||||
@@ -281,7 +273,7 @@ describe("ensureBrowserControlAuth", () => {
|
||||
expect(result.auth.password).toBe(result.generatedToken);
|
||||
expect(result.auth.token).toBeUndefined();
|
||||
expect(mocks.writeConfigFile).toHaveBeenCalledTimes(1);
|
||||
const persistedCfg = readPersistedConfig();
|
||||
const persistedCfg = mocks.writeConfigFile.mock.calls[0]?.[0] as OpenClawConfig | undefined;
|
||||
expect(persistedCfg?.gateway?.auth?.mode).toBe("trusted-proxy");
|
||||
expect(persistedCfg?.gateway?.auth?.password).toBe(result.generatedToken);
|
||||
expect(mocks.ensureGatewayStartupAuth).not.toHaveBeenCalled();
|
||||
|
||||
@@ -1,12 +1,5 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { SsrFBlockedError } from "../infra/net/ssrf.js";
|
||||
import {
|
||||
BROWSER_ENDPOINT_BLOCKED_MESSAGE,
|
||||
BROWSER_NAVIGATION_BLOCKED_MESSAGE,
|
||||
BrowserCdpEndpointBlockedError,
|
||||
BrowserValidationError,
|
||||
toBrowserErrorResponse,
|
||||
} from "./errors.js";
|
||||
import { BrowserValidationError, toBrowserErrorResponse } from "./errors.js";
|
||||
|
||||
describe("browser error mapping", () => {
|
||||
it("maps blocked browser targets to conflict responses", () => {
|
||||
@@ -27,22 +20,4 @@ describe("browser error mapping", () => {
|
||||
message: "bad input",
|
||||
});
|
||||
});
|
||||
|
||||
it("sanitizes navigation-target SSRF policy errors without leaking raw policy details", () => {
|
||||
expect(
|
||||
toBrowserErrorResponse(
|
||||
new SsrFBlockedError("Blocked hostname or private/internal/special-use IP address"),
|
||||
),
|
||||
).toEqual({
|
||||
status: 400,
|
||||
message: BROWSER_NAVIGATION_BLOCKED_MESSAGE,
|
||||
});
|
||||
});
|
||||
|
||||
it("maps CDP endpoint policy blocks to a distinct endpoint-scoped message", () => {
|
||||
expect(toBrowserErrorResponse(new BrowserCdpEndpointBlockedError())).toEqual({
|
||||
status: 400,
|
||||
message: BROWSER_ENDPOINT_BLOCKED_MESSAGE,
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1,9 +1,6 @@
|
||||
import { SsrFBlockedError } from "../infra/net/ssrf.js";
|
||||
import { InvalidBrowserNavigationUrlError } from "./navigation-guard.js";
|
||||
|
||||
export const BROWSER_ENDPOINT_BLOCKED_MESSAGE = "browser endpoint blocked by policy";
|
||||
export const BROWSER_NAVIGATION_BLOCKED_MESSAGE = "browser navigation blocked by policy";
|
||||
|
||||
export class BrowserError extends Error {
|
||||
status: number;
|
||||
|
||||
@@ -14,18 +11,6 @@ export class BrowserError extends Error {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Raised when a browser CDP endpoint (the cdpUrl itself) fails the
|
||||
* configured SSRF policy. Distinct from a blocked navigation target so
|
||||
* callers see "fix your browser endpoint config" rather than "fix your
|
||||
* navigation URL".
|
||||
*/
|
||||
export class BrowserCdpEndpointBlockedError extends BrowserError {
|
||||
constructor(options?: ErrorOptions) {
|
||||
super(BROWSER_ENDPOINT_BLOCKED_MESSAGE, 400, options);
|
||||
}
|
||||
}
|
||||
|
||||
export class BrowserValidationError extends BrowserError {
|
||||
constructor(message: string, options?: ErrorOptions) {
|
||||
super(message, 400, options);
|
||||
@@ -91,12 +76,7 @@ export function toBrowserErrorResponse(err: unknown): {
|
||||
return { status: 409, message: err.message };
|
||||
}
|
||||
if (err instanceof SsrFBlockedError) {
|
||||
// SsrFBlockedError from this point is from a navigation-target check
|
||||
// (assertBrowserNavigationAllowed / resolvePinnedHostnameWithPolicy on a
|
||||
// requested URL). CDP endpoint blocks are rethrown as
|
||||
// BrowserCdpEndpointBlockedError by assertCdpEndpointAllowed and handled
|
||||
// by the BrowserError branch above.
|
||||
return { status: 400, message: BROWSER_NAVIGATION_BLOCKED_MESSAGE };
|
||||
return { status: 400, message: err.message };
|
||||
}
|
||||
if (
|
||||
err instanceof InvalidBrowserNavigationUrlError ||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { normalizeOptionalString } from "openclaw/plugin-sdk/text-runtime";
|
||||
import type { BrowserFormField } from "./client-actions.types.js";
|
||||
import type { BrowserFormField } from "./client-actions-core.js";
|
||||
|
||||
export const DEFAULT_FILL_FIELD_TYPE = "text";
|
||||
|
||||
|
||||
@@ -1,20 +0,0 @@
|
||||
import {
|
||||
createBrowserControlContext,
|
||||
startBrowserControlServiceFromConfig,
|
||||
} from "./control-service.js";
|
||||
import {
|
||||
createBrowserRouteDispatcher,
|
||||
type BrowserDispatchRequest,
|
||||
type BrowserDispatchResponse,
|
||||
} from "./routes/dispatcher.js";
|
||||
|
||||
export async function dispatchBrowserControlRequest(
|
||||
req: BrowserDispatchRequest,
|
||||
): Promise<BrowserDispatchResponse> {
|
||||
const started = await startBrowserControlServiceFromConfig();
|
||||
if (!started) {
|
||||
throw new Error("browser control disabled");
|
||||
}
|
||||
const dispatcher = createBrowserRouteDispatcher(createBrowserControlContext());
|
||||
return await dispatcher.dispatch(req);
|
||||
}
|
||||
@@ -116,85 +116,6 @@ describe("browser navigation guard", () => {
|
||||
expect(lookupFn).toHaveBeenCalledWith("example.com", { all: true });
|
||||
});
|
||||
|
||||
it("blocks hostname navigation when strict SSRF policy is explicitly configured", async () => {
|
||||
const lookupFn = createLookupFn("93.184.216.34");
|
||||
await expect(
|
||||
assertBrowserNavigationAllowed({
|
||||
url: "https://example.com",
|
||||
lookupFn,
|
||||
ssrfPolicy: { dangerouslyAllowPrivateNetwork: false },
|
||||
}),
|
||||
).rejects.toThrow(/dns rebinding protections are unavailable/i);
|
||||
expect(lookupFn).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it("allows explicitly allowed hostnames in strict mode", async () => {
|
||||
const lookupFn = createLookupFn("93.184.216.34");
|
||||
await expect(
|
||||
assertBrowserNavigationAllowed({
|
||||
url: "https://agent.internal",
|
||||
lookupFn,
|
||||
ssrfPolicy: {
|
||||
dangerouslyAllowPrivateNetwork: false,
|
||||
allowedHostnames: ["agent.internal"],
|
||||
},
|
||||
}),
|
||||
).resolves.toBeUndefined();
|
||||
});
|
||||
|
||||
it("allows wildcard-allowlisted hostnames in strict mode", async () => {
|
||||
const lookupFn = createLookupFn("93.184.216.34");
|
||||
await expect(
|
||||
assertBrowserNavigationAllowed({
|
||||
url: "https://sub.example.com",
|
||||
lookupFn,
|
||||
ssrfPolicy: {
|
||||
dangerouslyAllowPrivateNetwork: false,
|
||||
hostnameAllowlist: ["*.example.com"],
|
||||
},
|
||||
}),
|
||||
).resolves.toBeUndefined();
|
||||
});
|
||||
|
||||
it("does not treat the bare suffix as matching a wildcard allowlist entry", async () => {
|
||||
const lookupFn = createLookupFn("93.184.216.34");
|
||||
await expect(
|
||||
assertBrowserNavigationAllowed({
|
||||
url: "https://example.com",
|
||||
lookupFn,
|
||||
ssrfPolicy: {
|
||||
dangerouslyAllowPrivateNetwork: false,
|
||||
hostnameAllowlist: ["*.example.com"],
|
||||
},
|
||||
}),
|
||||
).rejects.toThrow(/dns rebinding protections are unavailable/i);
|
||||
expect(lookupFn).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it("does not match sibling domains against wildcard allowlist entries", async () => {
|
||||
const lookupFn = createLookupFn("93.184.216.34");
|
||||
await expect(
|
||||
assertBrowserNavigationAllowed({
|
||||
url: "https://evil-example.com",
|
||||
lookupFn,
|
||||
ssrfPolicy: {
|
||||
dangerouslyAllowPrivateNetwork: false,
|
||||
hostnameAllowlist: ["*.example.com"],
|
||||
},
|
||||
}),
|
||||
).rejects.toThrow(/dns rebinding protections are unavailable/i);
|
||||
expect(lookupFn).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it("treats bracketed IPv6 URL hostnames as IP literals in strict mode", async () => {
|
||||
await expect(
|
||||
assertBrowserNavigationAllowed({
|
||||
url: "https://[2606:4700:4700::1111]/",
|
||||
ssrfPolicy: { dangerouslyAllowPrivateNetwork: false },
|
||||
}),
|
||||
).resolves.toBeUndefined();
|
||||
});
|
||||
|
||||
it("blocks strict policy navigation when env proxy is configured", async () => {
|
||||
vi.stubEnv("HTTP_PROXY", "http://127.0.0.1:7890");
|
||||
const lookupFn = createLookupFn("93.184.216.34");
|
||||
@@ -244,15 +165,6 @@ describe("browser navigation guard", () => {
|
||||
).resolves.toBeUndefined();
|
||||
});
|
||||
|
||||
it("blocks final hostname URLs in strict mode after navigation", async () => {
|
||||
await expect(
|
||||
assertBrowserNavigationResultAllowed({
|
||||
url: "https://example.com/final",
|
||||
ssrfPolicy: { dangerouslyAllowPrivateNetwork: false },
|
||||
}),
|
||||
).rejects.toBeInstanceOf(InvalidBrowserNavigationUrlError);
|
||||
});
|
||||
|
||||
it("blocks private intermediate redirect hops", async () => {
|
||||
const publicLookup = createLookupFn("93.184.216.34");
|
||||
const privateLookup = createLookupFn("127.0.0.1");
|
||||
|
||||
@@ -1,8 +1,3 @@
|
||||
import { isIP } from "node:net";
|
||||
import {
|
||||
matchesHostnameAllowlist,
|
||||
normalizeHostname,
|
||||
} from "openclaw/plugin-sdk/browser-security-runtime";
|
||||
import { normalizeOptionalString } from "openclaw/plugin-sdk/text-runtime";
|
||||
import { hasProxyEnvConfigured } from "../infra/net/proxy-env.js";
|
||||
import {
|
||||
@@ -46,24 +41,6 @@ export function requiresInspectableBrowserNavigationRedirects(ssrfPolicy?: SsrFP
|
||||
return !isPrivateNetworkAllowedByPolicy(ssrfPolicy);
|
||||
}
|
||||
|
||||
function isIpLiteralHostname(hostname: string): boolean {
|
||||
return isIP(normalizeHostname(hostname)) !== 0;
|
||||
}
|
||||
|
||||
function isExplicitlyAllowedBrowserHostname(hostname: string, ssrfPolicy?: SsrFPolicy): boolean {
|
||||
const normalizedHostname = normalizeHostname(hostname);
|
||||
const exactMatches = ssrfPolicy?.allowedHostnames ?? [];
|
||||
if (exactMatches.some((value) => normalizeHostname(value) === normalizedHostname)) {
|
||||
return true;
|
||||
}
|
||||
const hostnameAllowlist = (ssrfPolicy?.hostnameAllowlist ?? [])
|
||||
.map((pattern) => normalizeHostname(pattern))
|
||||
.filter(Boolean);
|
||||
return hostnameAllowlist.length > 0
|
||||
? matchesHostnameAllowlist(normalizedHostname, hostnameAllowlist)
|
||||
: false;
|
||||
}
|
||||
|
||||
export async function assertBrowserNavigationAllowed(
|
||||
opts: {
|
||||
url: string;
|
||||
@@ -101,21 +78,6 @@ export async function assertBrowserNavigationAllowed(
|
||||
);
|
||||
}
|
||||
|
||||
// Browser navigations happen in Chromium's network stack, not Node's. In
|
||||
// strict mode, a hostname-based URL would be resolved twice by different
|
||||
// resolvers, so Node-side pinning cannot guarantee the browser connects to
|
||||
// the same address that passed policy checks.
|
||||
if (
|
||||
opts.ssrfPolicy &&
|
||||
!isPrivateNetworkAllowedByPolicy(opts.ssrfPolicy) &&
|
||||
!isIpLiteralHostname(parsed.hostname) &&
|
||||
!isExplicitlyAllowedBrowserHostname(parsed.hostname, opts.ssrfPolicy)
|
||||
) {
|
||||
throw new InvalidBrowserNavigationUrlError(
|
||||
"Navigation blocked: strict browser SSRF policy requires an IP-literal URL because browser DNS rebinding protections are unavailable for hostname-based navigation",
|
||||
);
|
||||
}
|
||||
|
||||
await resolvePinnedHostnameWithPolicy(parsed.hostname, {
|
||||
lookupFn: opts.lookupFn,
|
||||
policy: opts.ssrfPolicy,
|
||||
@@ -125,8 +87,7 @@ export async function assertBrowserNavigationAllowed(
|
||||
/**
|
||||
* Best-effort post-navigation guard for final page URLs.
|
||||
* Only validates network URLs (http/https) and about:blank to avoid false
|
||||
* positives on browser-internal error pages (e.g. chrome-error://). In strict
|
||||
* mode this intentionally re-applies the hostname gate after redirects.
|
||||
* positives on browser-internal error pages (e.g. chrome-error://).
|
||||
*/
|
||||
export async function assertBrowserNavigationResultAllowed(
|
||||
opts: {
|
||||
|
||||
@@ -111,9 +111,7 @@ describe("BrowserProfilesService", () => {
|
||||
});
|
||||
|
||||
it("accepts per-profile cdpUrl for remote Chrome", async () => {
|
||||
const resolved = resolveBrowserConfig({
|
||||
ssrfPolicy: { dangerouslyAllowPrivateNetwork: true },
|
||||
});
|
||||
const resolved = resolveBrowserConfig({});
|
||||
const { ctx } = createCtx(resolved);
|
||||
|
||||
vi.mocked(loadConfig).mockReturnValue({ browser: { profiles: {} } });
|
||||
|
||||
@@ -124,11 +124,6 @@ export function createBrowserProfilesService(ctx: BrowserRouteContext) {
|
||||
}
|
||||
|
||||
if (rawCdpUrl) {
|
||||
if (driver === "existing-session") {
|
||||
throw new BrowserValidationError(
|
||||
"driver=existing-session does not accept cdpUrl; it attaches via the Chrome MCP auto-connect flow",
|
||||
);
|
||||
}
|
||||
let parsed: ReturnType<typeof parseHttpUrl>;
|
||||
try {
|
||||
parsed = parseHttpUrl(rawCdpUrl, "browser.profiles.cdpUrl");
|
||||
@@ -136,6 +131,11 @@ export function createBrowserProfilesService(ctx: BrowserRouteContext) {
|
||||
} catch (err) {
|
||||
throw new BrowserValidationError(formatErrorMessage(err));
|
||||
}
|
||||
if (driver === "existing-session") {
|
||||
throw new BrowserValidationError(
|
||||
"driver=existing-session does not accept cdpUrl; it attaches via the Chrome MCP auto-connect flow",
|
||||
);
|
||||
}
|
||||
profileConfig = {
|
||||
cdpUrl: parsed.normalized,
|
||||
...(driver ? { driver } : {}),
|
||||
|
||||
@@ -340,7 +340,7 @@ export function buildRoleSnapshotFromAiSnapshot(
|
||||
aiSnapshot: string,
|
||||
options: RoleSnapshotOptions = {},
|
||||
): { snapshot: string; refs: RoleRefMap } {
|
||||
const lines = aiSnapshot.split("\n");
|
||||
const lines = String(aiSnapshot ?? "").split("\n");
|
||||
const refs: RoleRefMap = {};
|
||||
|
||||
if (options.interactive) {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { chromium } from "playwright-core";
|
||||
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
|
||||
import { afterEach, describe, expect, it, vi } from "vitest";
|
||||
import { SsrFBlockedError } from "../infra/net/ssrf.js";
|
||||
import * as chromeModule from "./chrome.js";
|
||||
import { BrowserTabNotFoundError } from "./errors.js";
|
||||
@@ -15,33 +15,9 @@ import {
|
||||
listPagesViaPlaywright,
|
||||
} from "./pw-session.js";
|
||||
|
||||
vi.mock("openclaw/plugin-sdk/browser-security-runtime", async () => {
|
||||
const actual = await vi.importActual<
|
||||
typeof import("openclaw/plugin-sdk/browser-security-runtime")
|
||||
>("openclaw/plugin-sdk/browser-security-runtime");
|
||||
const lookupFn = async (_hostname: string, options?: { all?: boolean }) => {
|
||||
const result = { address: "93.184.216.34", family: 4 };
|
||||
return options?.all === true ? [result] : result;
|
||||
};
|
||||
return {
|
||||
...actual,
|
||||
resolvePinnedHostnameWithPolicy: (hostname: string, params: object = {}) =>
|
||||
actual.resolvePinnedHostnameWithPolicy(hostname, { ...params, lookupFn: lookupFn as never }),
|
||||
};
|
||||
});
|
||||
|
||||
const connectOverCdpSpy = vi.spyOn(chromium, "connectOverCDP");
|
||||
const getChromeWebSocketUrlSpy = vi.spyOn(chromeModule, "getChromeWebSocketUrl");
|
||||
|
||||
const PROXY_ENV_KEYS = [
|
||||
"ALL_PROXY",
|
||||
"all_proxy",
|
||||
"HTTP_PROXY",
|
||||
"http_proxy",
|
||||
"HTTPS_PROXY",
|
||||
"https_proxy",
|
||||
] as const;
|
||||
|
||||
type MockRoute = { continue: () => Promise<void>; abort: () => Promise<void> };
|
||||
type MockRequest = {
|
||||
isNavigationRequest: () => boolean;
|
||||
@@ -150,7 +126,6 @@ async function dispatchMockNavigation(params: {
|
||||
getRouteHandler: () => MockRouteHandler | null;
|
||||
mainFrame: object;
|
||||
url: string;
|
||||
frame?: object;
|
||||
isNavigationRequest?: boolean;
|
||||
resourceType?: string;
|
||||
route?: Partial<MockRoute>;
|
||||
@@ -162,7 +137,7 @@ async function dispatchMockNavigation(params: {
|
||||
const { resourceType } = params;
|
||||
await handler(createMockRoute(params.route), {
|
||||
isNavigationRequest: () => params.isNavigationRequest ?? true,
|
||||
frame: () => params.frame ?? params.mainFrame,
|
||||
frame: () => params.mainFrame,
|
||||
...(resourceType ? { resourceType: () => resourceType } : {}),
|
||||
url: () => params.url,
|
||||
});
|
||||
@@ -194,14 +169,7 @@ function mockBlockedRedirectNavigation(params: {
|
||||
});
|
||||
}
|
||||
|
||||
beforeEach(() => {
|
||||
for (const key of PROXY_ENV_KEYS) {
|
||||
vi.stubEnv(key, "");
|
||||
}
|
||||
});
|
||||
|
||||
afterEach(async () => {
|
||||
vi.unstubAllEnvs();
|
||||
connectOverCdpSpy.mockClear();
|
||||
getChromeWebSocketUrlSpy.mockClear();
|
||||
await closePlaywrightBrowserConnection().catch(() => {});
|
||||
@@ -233,20 +201,6 @@ describe("pw-session createPageViaPlaywright navigation guard", () => {
|
||||
expect(pageGoto).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it("blocks hostname navigation when strict SSRF policy is configured", async () => {
|
||||
const { pageGoto } = installBrowserMocks();
|
||||
|
||||
await expect(
|
||||
createPageViaPlaywright({
|
||||
cdpUrl: "http://127.0.0.1:18792",
|
||||
url: "https://example.com",
|
||||
ssrfPolicy: { dangerouslyAllowPrivateNetwork: false, allowedHostnames: ["127.0.0.1"] },
|
||||
}),
|
||||
).rejects.toBeInstanceOf(InvalidBrowserNavigationUrlError);
|
||||
|
||||
expect(pageGoto).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it("blocks private intermediate redirect hops", async () => {
|
||||
const { pageGoto, pageClose, getRouteHandler, mainFrame } = installBrowserMocks();
|
||||
mockBlockedRedirectNavigation({ pageGoto, getRouteHandler, mainFrame });
|
||||
@@ -283,41 +237,6 @@ describe("pw-session createPageViaPlaywright navigation guard", () => {
|
||||
expect(pageClose).toHaveBeenCalledTimes(1);
|
||||
});
|
||||
|
||||
it("aborts private subframe document hops without quarantining the page", async () => {
|
||||
const { pageGoto, pageClose, getRouteHandler, mainFrame } = installBrowserMocks();
|
||||
const subframe = {};
|
||||
const subframeRoute = createMockRoute();
|
||||
pageGoto.mockImplementationOnce(async () => {
|
||||
await dispatchMockNavigation({
|
||||
getRouteHandler,
|
||||
mainFrame,
|
||||
url: "https://93.184.216.34/start",
|
||||
});
|
||||
await dispatchMockNavigation({
|
||||
getRouteHandler,
|
||||
mainFrame,
|
||||
frame: subframe,
|
||||
url: "http://127.0.0.1:18080/internal-hop",
|
||||
route: subframeRoute,
|
||||
});
|
||||
return {
|
||||
request: () => ({
|
||||
url: () => "https://93.184.216.34/start",
|
||||
redirectedFrom: () => null,
|
||||
}),
|
||||
};
|
||||
});
|
||||
|
||||
const created = await createPageViaPlaywright({
|
||||
cdpUrl: "http://127.0.0.1:18792",
|
||||
url: "https://93.184.216.34/start",
|
||||
});
|
||||
|
||||
expect(created.targetId).toBe("TARGET_1");
|
||||
expect(subframeRoute.abort).toHaveBeenCalledTimes(1);
|
||||
expect(pageClose).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it("preserves the created tab on ordinary navigation failure", async () => {
|
||||
const { pageGoto, pageClose } = installBrowserMocks();
|
||||
pageGoto.mockRejectedValueOnce(new Error("page.goto: net::ERR_NAME_NOT_RESOLVED"));
|
||||
|
||||
@@ -14,7 +14,6 @@ import { SsrFBlockedError, type SsrFPolicy } from "../infra/net/ssrf.js";
|
||||
import { withNoProxyForCdpUrl } from "./cdp-proxy-bypass.js";
|
||||
import {
|
||||
appendCdpPath,
|
||||
assertCdpEndpointAllowed,
|
||||
fetchJson,
|
||||
getHeadersWithAuth,
|
||||
normalizeCdpHttpBaseForJsonEndpoints,
|
||||
@@ -338,9 +337,9 @@ export function ensurePageState(page: Page): PageState {
|
||||
});
|
||||
page.on("pageerror", (err: Error) => {
|
||||
state.errors.push({
|
||||
message: err.message || String(err),
|
||||
name: err.name || undefined,
|
||||
stack: err.stack || undefined,
|
||||
message: err?.message ? String(err.message) : String(err),
|
||||
name: err?.name ? String(err.name) : undefined,
|
||||
stack: err?.stack ? String(err.stack) : undefined,
|
||||
timestamp: new Date().toISOString(),
|
||||
});
|
||||
if (state.errors.length > MAX_PAGE_ERRORS) {
|
||||
@@ -425,15 +424,12 @@ function observeBrowser(browser: Browser) {
|
||||
}
|
||||
}
|
||||
|
||||
async function connectBrowser(cdpUrl: string, ssrfPolicy?: SsrFPolicy): Promise<ConnectedBrowser> {
|
||||
async function connectBrowser(cdpUrl: string): Promise<ConnectedBrowser> {
|
||||
const normalized = normalizeCdpUrl(cdpUrl);
|
||||
const cached = cachedByCdpUrl.get(normalized);
|
||||
if (cached) {
|
||||
return cached;
|
||||
}
|
||||
// Run SSRF policy check only on cache miss so transient DNS failures
|
||||
// do not break active sessions that already hold a live CDP connection.
|
||||
await assertCdpEndpointAllowed(normalized, ssrfPolicy);
|
||||
const connecting = connectingByCdpUrl.get(normalized);
|
||||
if (connecting) {
|
||||
return await connecting;
|
||||
@@ -444,9 +440,7 @@ async function connectBrowser(cdpUrl: string, ssrfPolicy?: SsrFPolicy): Promise<
|
||||
for (let attempt = 0; attempt < 3; attempt += 1) {
|
||||
try {
|
||||
const timeout = 5000 + attempt * 2000;
|
||||
const wsUrl = await getChromeWebSocketUrl(normalized, timeout, ssrfPolicy).catch(
|
||||
() => null,
|
||||
);
|
||||
const wsUrl = await getChromeWebSocketUrl(normalized, timeout).catch(() => null);
|
||||
const endpoint = wsUrl ?? normalized;
|
||||
const headers = getHeadersWithAuth(endpoint);
|
||||
// Bypass proxy for loopback CDP connections (#31219)
|
||||
@@ -568,10 +562,8 @@ async function findPageByTargetIdViaTargetList(
|
||||
pages: Page[],
|
||||
targetId: string,
|
||||
cdpUrl: string,
|
||||
ssrfPolicy?: SsrFPolicy,
|
||||
): Promise<Page | null> {
|
||||
const cdpHttpBase = normalizeCdpHttpBaseForJsonEndpoints(cdpUrl);
|
||||
await assertCdpEndpointAllowed(cdpUrl, ssrfPolicy);
|
||||
const targets = await fetchJson<
|
||||
Array<{
|
||||
id: string;
|
||||
@@ -586,7 +578,6 @@ async function findPageByTargetId(
|
||||
browser: Browser,
|
||||
targetId: string,
|
||||
cdpUrl?: string,
|
||||
ssrfPolicy?: SsrFPolicy,
|
||||
): Promise<Page | null> {
|
||||
const pages = await getAllPages(browser);
|
||||
let resolvedViaCdp = false;
|
||||
@@ -604,7 +595,7 @@ async function findPageByTargetId(
|
||||
}
|
||||
if (cdpUrl) {
|
||||
try {
|
||||
return await findPageByTargetIdViaTargetList(pages, targetId, cdpUrl, ssrfPolicy);
|
||||
return await findPageByTargetIdViaTargetList(pages, targetId, cdpUrl);
|
||||
} catch {
|
||||
// Ignore fetch errors and fall through to return null.
|
||||
}
|
||||
@@ -618,13 +609,12 @@ async function findPageByTargetId(
|
||||
async function resolvePageByTargetIdOrThrow(opts: {
|
||||
cdpUrl: string;
|
||||
targetId: string;
|
||||
ssrfPolicy?: SsrFPolicy;
|
||||
}): Promise<Page> {
|
||||
if (isBlockedTarget(opts.cdpUrl, opts.targetId)) {
|
||||
throw new BlockedBrowserTargetError();
|
||||
}
|
||||
const { browser } = await connectBrowser(opts.cdpUrl, opts.ssrfPolicy);
|
||||
const page = await findPageByTargetId(browser, opts.targetId, opts.cdpUrl, opts.ssrfPolicy);
|
||||
const { browser } = await connectBrowser(opts.cdpUrl);
|
||||
const page = await findPageByTargetId(browser, opts.targetId, opts.cdpUrl);
|
||||
if (!page) {
|
||||
throw new BrowserTabNotFoundError();
|
||||
}
|
||||
@@ -634,12 +624,11 @@ async function resolvePageByTargetIdOrThrow(opts: {
|
||||
export async function getPageForTargetId(opts: {
|
||||
cdpUrl: string;
|
||||
targetId?: string;
|
||||
ssrfPolicy?: SsrFPolicy;
|
||||
}): Promise<Page> {
|
||||
if (opts.targetId && isBlockedTarget(opts.cdpUrl, opts.targetId)) {
|
||||
throw new BlockedBrowserTargetError();
|
||||
}
|
||||
const { browser } = await connectBrowser(opts.cdpUrl, opts.ssrfPolicy);
|
||||
const { browser } = await connectBrowser(opts.cdpUrl);
|
||||
const pages = await getAllPages(browser);
|
||||
if (!pages.length) {
|
||||
throw new Error("No pages available in the connected browser.");
|
||||
@@ -659,7 +648,7 @@ export async function getPageForTargetId(opts: {
|
||||
if (!opts.targetId) {
|
||||
return first;
|
||||
}
|
||||
const found = await findPageByTargetId(browser, opts.targetId, opts.cdpUrl, opts.ssrfPolicy);
|
||||
const found = await findPageByTargetId(browser, opts.targetId, opts.cdpUrl);
|
||||
if (found) {
|
||||
if (isBlockedPageRef(opts.cdpUrl, found)) {
|
||||
throw new BlockedBrowserTargetError();
|
||||
@@ -704,36 +693,6 @@ function isTopLevelNavigationRequest(page: Page, request: Request): boolean {
|
||||
}
|
||||
}
|
||||
|
||||
function isSubframeDocumentNavigationRequest(page: Page, request: Request): boolean {
|
||||
let sameMainFrame = false;
|
||||
try {
|
||||
sameMainFrame = request.frame() === page.mainFrame();
|
||||
} catch {
|
||||
// Fail closed: if frame resolution throws after the top-level check already
|
||||
// determined this is NOT the main frame, treat it as a subframe document
|
||||
// navigation so the SSRF guard still fires. Returning false here would let
|
||||
// transient renderer churn skip the policy check entirely.
|
||||
return true;
|
||||
}
|
||||
if (sameMainFrame) {
|
||||
return false;
|
||||
}
|
||||
|
||||
try {
|
||||
if (request.isNavigationRequest()) {
|
||||
return true;
|
||||
}
|
||||
} catch {
|
||||
// Fall through to the resource-type check.
|
||||
}
|
||||
|
||||
try {
|
||||
return request.resourceType() === "document";
|
||||
} catch {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
function isPolicyDenyNavigationError(err: unknown): boolean {
|
||||
return err instanceof SsrFBlockedError || err instanceof InvalidBrowserNavigationUrlError;
|
||||
}
|
||||
@@ -799,10 +758,7 @@ export async function gotoPageWithNavigationGuard(opts: {
|
||||
await route.abort().catch(() => {});
|
||||
return;
|
||||
}
|
||||
const isTopLevel = isTopLevelNavigationRequest(opts.page, request);
|
||||
const isSubframeDocument =
|
||||
!isTopLevel && isSubframeDocumentNavigationRequest(opts.page, request);
|
||||
if (!isTopLevel && !isSubframeDocument) {
|
||||
if (!isTopLevelNavigationRequest(opts.page, request)) {
|
||||
await route.continue();
|
||||
return;
|
||||
}
|
||||
@@ -813,9 +769,7 @@ export async function gotoPageWithNavigationGuard(opts: {
|
||||
});
|
||||
} catch (err) {
|
||||
if (isPolicyDenyNavigationError(err)) {
|
||||
if (isTopLevel) {
|
||||
blockedError = err;
|
||||
}
|
||||
blockedError = err;
|
||||
await route.abort().catch(() => {});
|
||||
return;
|
||||
}
|
||||
@@ -933,9 +887,7 @@ function cdpSocketNeedsAttach(wsUrl: string): boolean {
|
||||
async function tryTerminateExecutionViaCdp(opts: {
|
||||
cdpUrl: string;
|
||||
targetId: string;
|
||||
ssrfPolicy?: SsrFPolicy;
|
||||
}): Promise<void> {
|
||||
await assertCdpEndpointAllowed(opts.cdpUrl, opts.ssrfPolicy);
|
||||
const cdpHttpBase = normalizeCdpHttpBaseForJsonEndpoints(opts.cdpUrl);
|
||||
const listUrl = appendCdpPath(cdpHttpBase, "/json/list");
|
||||
|
||||
@@ -1024,7 +976,6 @@ export async function forceDisconnectPlaywrightForTarget(opts: {
|
||||
cdpUrl: string;
|
||||
targetId?: string;
|
||||
reason?: string;
|
||||
ssrfPolicy?: SsrFPolicy;
|
||||
}): Promise<void> {
|
||||
const normalized = normalizeCdpUrl(opts.cdpUrl);
|
||||
const cur = cachedByCdpUrl.get(normalized);
|
||||
@@ -1045,11 +996,7 @@ export async function forceDisconnectPlaywrightForTarget(opts: {
|
||||
// disconnect Playwright's CDP connection.
|
||||
const targetId = normalizeOptionalString(opts.targetId) ?? "";
|
||||
if (targetId) {
|
||||
await tryTerminateExecutionViaCdp({
|
||||
cdpUrl: normalized,
|
||||
targetId,
|
||||
ssrfPolicy: opts.ssrfPolicy,
|
||||
}).catch(() => {});
|
||||
await tryTerminateExecutionViaCdp({ cdpUrl: normalized, targetId }).catch(() => {});
|
||||
}
|
||||
|
||||
// Fire-and-forget: don't await because browser.close() may hang on the stuck CDP pipe.
|
||||
@@ -1060,10 +1007,7 @@ export async function forceDisconnectPlaywrightForTarget(opts: {
|
||||
* List all pages/tabs from the persistent Playwright connection.
|
||||
* Used for remote profiles where HTTP-based /json/list is ephemeral.
|
||||
*/
|
||||
export async function listPagesViaPlaywright(opts: {
|
||||
cdpUrl: string;
|
||||
ssrfPolicy?: SsrFPolicy;
|
||||
}): Promise<
|
||||
export async function listPagesViaPlaywright(opts: { cdpUrl: string }): Promise<
|
||||
Array<{
|
||||
targetId: string;
|
||||
title: string;
|
||||
@@ -1071,7 +1015,7 @@ export async function listPagesViaPlaywright(opts: {
|
||||
type: string;
|
||||
}>
|
||||
> {
|
||||
const { browser } = await connectBrowser(opts.cdpUrl, opts.ssrfPolicy);
|
||||
const { browser } = await connectBrowser(opts.cdpUrl);
|
||||
const pages = await getAllPages(browser);
|
||||
const results: Array<{
|
||||
targetId: string;
|
||||
@@ -1112,7 +1056,7 @@ export async function createPageViaPlaywright(opts: {
|
||||
url: string;
|
||||
type: string;
|
||||
}> {
|
||||
const { browser } = await connectBrowser(opts.cdpUrl, opts.ssrfPolicy);
|
||||
const { browser } = await connectBrowser(opts.cdpUrl);
|
||||
const context = browser.contexts()[0] ?? (await browser.newContext());
|
||||
ensureContextState(context);
|
||||
|
||||
@@ -1175,7 +1119,6 @@ export async function createPageViaPlaywright(opts: {
|
||||
export async function closePageByTargetIdViaPlaywright(opts: {
|
||||
cdpUrl: string;
|
||||
targetId: string;
|
||||
ssrfPolicy?: SsrFPolicy;
|
||||
}): Promise<void> {
|
||||
const page = await resolvePageByTargetIdOrThrow(opts);
|
||||
await page.close();
|
||||
@@ -1188,7 +1131,6 @@ export async function closePageByTargetIdViaPlaywright(opts: {
|
||||
export async function focusPageByTargetIdViaPlaywright(opts: {
|
||||
cdpUrl: string;
|
||||
targetId: string;
|
||||
ssrfPolicy?: SsrFPolicy;
|
||||
}): Promise<void> {
|
||||
const page = await resolvePageByTargetIdOrThrow(opts);
|
||||
try {
|
||||
|
||||
@@ -256,7 +256,7 @@ export async function downloadViaPlaywright(opts: {
|
||||
const timeout = normalizeTimeoutMs(opts.timeoutMs, 120_000);
|
||||
|
||||
const ref = requireRef(opts.ref);
|
||||
const outPath = opts.path?.trim() ?? "";
|
||||
const outPath = String(opts.path ?? "").trim();
|
||||
if (!outPath) {
|
||||
throw new Error("path is required");
|
||||
}
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import { describe, expect, it, vi } from "vitest";
|
||||
import {
|
||||
getPwToolsCoreNavigationGuardMocks,
|
||||
getPwToolsCoreSessionMocks,
|
||||
installPwToolsCoreTestHooks,
|
||||
setPwToolsCoreCurrentPage,
|
||||
@@ -10,18 +9,6 @@ import {
|
||||
installPwToolsCoreTestHooks();
|
||||
const mod = await import("./pw-tools-core.js");
|
||||
|
||||
function createMutableFrame(initialUrl: string) {
|
||||
let currentUrl = initialUrl;
|
||||
return {
|
||||
frame: {
|
||||
url: vi.fn(() => currentUrl),
|
||||
},
|
||||
setUrl: (nextUrl: string) => {
|
||||
currentUrl = nextUrl;
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
describe("pw-tools-core interaction navigation guard", () => {
|
||||
it("waits for the grace window before completing a successful non-navigating click", async () => {
|
||||
vi.useFakeTimers();
|
||||
@@ -133,12 +120,12 @@ describe("pw-tools-core interaction navigation guard", () => {
|
||||
}
|
||||
});
|
||||
|
||||
it("checks subframe navigations before a later main-frame navigation", async () => {
|
||||
it("ignores subframe framenavigated events before the main frame navigates", async () => {
|
||||
vi.useFakeTimers();
|
||||
try {
|
||||
const listeners = new Set<(frame: object) => void>();
|
||||
const mainFrame = {};
|
||||
const subframe = { url: () => "https://example.com/embed" };
|
||||
const subframe = {};
|
||||
let currentUrl = "http://127.0.0.1:9222/json/version";
|
||||
const click = vi.fn(async () => {
|
||||
setTimeout(() => {
|
||||
@@ -182,449 +169,10 @@ describe("pw-tools-core interaction navigation guard", () => {
|
||||
expect(
|
||||
getPwToolsCoreSessionMocks().assertPageNavigationCompletedSafely,
|
||||
).not.toHaveBeenCalled();
|
||||
expect(
|
||||
getPwToolsCoreNavigationGuardMocks().assertBrowserNavigationResultAllowed,
|
||||
).not.toHaveBeenCalled();
|
||||
|
||||
await vi.advanceTimersByTimeAsync(10);
|
||||
await task;
|
||||
|
||||
expect(
|
||||
getPwToolsCoreNavigationGuardMocks().assertBrowserNavigationResultAllowed,
|
||||
).toHaveBeenCalledWith({
|
||||
ssrfPolicy: { allowPrivateNetwork: false },
|
||||
url: "https://example.com/embed",
|
||||
});
|
||||
expect(getPwToolsCoreSessionMocks().assertPageNavigationCompletedSafely).toHaveBeenCalledWith(
|
||||
{
|
||||
cdpUrl: "http://127.0.0.1:18792",
|
||||
page,
|
||||
response: null,
|
||||
ssrfPolicy: { allowPrivateNetwork: false },
|
||||
targetId: "T1",
|
||||
},
|
||||
);
|
||||
} finally {
|
||||
vi.useRealTimers();
|
||||
}
|
||||
});
|
||||
|
||||
it("blocks subframe-only navigation to a private URL during the post-action grace window", async () => {
|
||||
vi.useFakeTimers();
|
||||
try {
|
||||
const listeners = new Set<(frame: object) => void>();
|
||||
const mainFrame = {};
|
||||
const subframe = { url: () => "http://169.254.169.254/latest/meta-data/" };
|
||||
const click = vi.fn(async () => {
|
||||
setTimeout(() => {
|
||||
for (const listener of listeners) {
|
||||
listener(subframe);
|
||||
}
|
||||
}, 10);
|
||||
});
|
||||
const page = {
|
||||
mainFrame: vi.fn(() => mainFrame),
|
||||
on: vi.fn((event: string, listener: (frame: object) => void) => {
|
||||
if (event === "framenavigated") {
|
||||
listeners.add(listener);
|
||||
}
|
||||
}),
|
||||
off: vi.fn((event: string, listener: (frame: object) => void) => {
|
||||
if (event === "framenavigated") {
|
||||
listeners.delete(listener);
|
||||
}
|
||||
}),
|
||||
url: vi.fn(() => "https://attacker.example.com/page"),
|
||||
};
|
||||
setPwToolsCoreCurrentRefLocator({ click });
|
||||
setPwToolsCoreCurrentPage(page);
|
||||
|
||||
const blocked = new Error("SSRF blocked: private network");
|
||||
getPwToolsCoreNavigationGuardMocks().assertBrowserNavigationResultAllowed.mockRejectedValueOnce(
|
||||
blocked,
|
||||
);
|
||||
|
||||
const task = mod.clickViaPlaywright({
|
||||
cdpUrl: "http://127.0.0.1:18792",
|
||||
targetId: "T1",
|
||||
ref: "1",
|
||||
ssrfPolicy: { allowPrivateNetwork: false },
|
||||
});
|
||||
const rejection = expect(task).rejects.toThrow("SSRF blocked: private network");
|
||||
|
||||
await vi.advanceTimersByTimeAsync(10);
|
||||
await vi.advanceTimersByTimeAsync(240);
|
||||
await rejection;
|
||||
expect(
|
||||
getPwToolsCoreSessionMocks().assertPageNavigationCompletedSafely,
|
||||
).not.toHaveBeenCalled();
|
||||
} finally {
|
||||
vi.useRealTimers();
|
||||
}
|
||||
});
|
||||
|
||||
it("snapshots delayed subframe URLs before later rewrites make them look safe", async () => {
|
||||
vi.useFakeTimers();
|
||||
try {
|
||||
const listeners = new Set<(frame: object) => void>();
|
||||
const mainFrame = {};
|
||||
const subframe = createMutableFrame("http://169.254.169.254/latest/meta-data/");
|
||||
const click = vi.fn(async () => {
|
||||
setTimeout(() => {
|
||||
for (const listener of listeners) {
|
||||
listener(subframe.frame);
|
||||
}
|
||||
}, 10);
|
||||
setTimeout(() => {
|
||||
subframe.setUrl("https://example.com/embed");
|
||||
}, 20);
|
||||
});
|
||||
const page = {
|
||||
mainFrame: vi.fn(() => mainFrame),
|
||||
on: vi.fn((event: string, listener: (frame: object) => void) => {
|
||||
if (event === "framenavigated") {
|
||||
listeners.add(listener);
|
||||
}
|
||||
}),
|
||||
off: vi.fn((event: string, listener: (frame: object) => void) => {
|
||||
if (event === "framenavigated") {
|
||||
listeners.delete(listener);
|
||||
}
|
||||
}),
|
||||
url: vi.fn(() => "https://attacker.example.com/page"),
|
||||
};
|
||||
setPwToolsCoreCurrentRefLocator({ click });
|
||||
setPwToolsCoreCurrentPage(page);
|
||||
|
||||
const task = mod.clickViaPlaywright({
|
||||
cdpUrl: "http://127.0.0.1:18792",
|
||||
targetId: "T1",
|
||||
ref: "1",
|
||||
ssrfPolicy: { allowPrivateNetwork: false },
|
||||
});
|
||||
|
||||
await vi.advanceTimersByTimeAsync(20);
|
||||
await vi.advanceTimersByTimeAsync(230);
|
||||
await task;
|
||||
|
||||
expect(
|
||||
getPwToolsCoreNavigationGuardMocks().assertBrowserNavigationResultAllowed,
|
||||
).toHaveBeenCalledWith({
|
||||
ssrfPolicy: { allowPrivateNetwork: false },
|
||||
url: "http://169.254.169.254/latest/meta-data/",
|
||||
});
|
||||
} finally {
|
||||
vi.useRealTimers();
|
||||
}
|
||||
});
|
||||
|
||||
it("still quarantines the main frame when a delayed subframe block fires first", async () => {
|
||||
vi.useFakeTimers();
|
||||
try {
|
||||
const listeners = new Set<(frame: object) => void>();
|
||||
const mainFrame = {};
|
||||
const subframe = { url: () => "http://169.254.169.254/latest/meta-data/" };
|
||||
let currentUrl = "https://attacker.example.com/page";
|
||||
const click = vi.fn(async () => {
|
||||
setTimeout(() => {
|
||||
for (const listener of listeners) {
|
||||
listener(subframe);
|
||||
}
|
||||
}, 10);
|
||||
setTimeout(() => {
|
||||
currentUrl = "http://127.0.0.1:8080/internal";
|
||||
for (const listener of listeners) {
|
||||
listener(mainFrame);
|
||||
}
|
||||
}, 20);
|
||||
});
|
||||
const page = {
|
||||
mainFrame: vi.fn(() => mainFrame),
|
||||
on: vi.fn((event: string, listener: (frame: object) => void) => {
|
||||
if (event === "framenavigated") {
|
||||
listeners.add(listener);
|
||||
}
|
||||
}),
|
||||
off: vi.fn((event: string, listener: (frame: object) => void) => {
|
||||
if (event === "framenavigated") {
|
||||
listeners.delete(listener);
|
||||
}
|
||||
}),
|
||||
url: vi.fn(() => currentUrl),
|
||||
};
|
||||
setPwToolsCoreCurrentRefLocator({ click });
|
||||
setPwToolsCoreCurrentPage(page);
|
||||
|
||||
const subframeBlocked = new Error("subframe blocked");
|
||||
const mainFrameBlocked = new Error("main frame blocked");
|
||||
getPwToolsCoreNavigationGuardMocks().assertBrowserNavigationResultAllowed.mockRejectedValueOnce(
|
||||
subframeBlocked,
|
||||
);
|
||||
getPwToolsCoreSessionMocks().assertPageNavigationCompletedSafely.mockRejectedValueOnce(
|
||||
mainFrameBlocked,
|
||||
);
|
||||
|
||||
const task = mod.clickViaPlaywright({
|
||||
cdpUrl: "http://127.0.0.1:18792",
|
||||
targetId: "T1",
|
||||
ref: "1",
|
||||
ssrfPolicy: { allowPrivateNetwork: false },
|
||||
});
|
||||
const rejection = expect(task).rejects.toThrow("main frame blocked");
|
||||
|
||||
await vi.advanceTimersByTimeAsync(20);
|
||||
await rejection;
|
||||
expect(getPwToolsCoreSessionMocks().assertPageNavigationCompletedSafely).toHaveBeenCalledWith(
|
||||
{
|
||||
cdpUrl: "http://127.0.0.1:18792",
|
||||
page,
|
||||
response: null,
|
||||
ssrfPolicy: { allowPrivateNetwork: false },
|
||||
targetId: "T1",
|
||||
},
|
||||
);
|
||||
} finally {
|
||||
vi.useRealTimers();
|
||||
}
|
||||
});
|
||||
|
||||
it("does not stop watching for a later main-frame navigation after a harmless subframe hop", async () => {
|
||||
vi.useFakeTimers();
|
||||
try {
|
||||
const listeners = new Set<(frame: object) => void>();
|
||||
const mainFrame = {};
|
||||
const subframe = { url: () => "about:blank" };
|
||||
let currentUrl = "http://127.0.0.1:9222/json/version";
|
||||
const click = vi.fn(async () => {
|
||||
setTimeout(() => {
|
||||
for (const listener of listeners) {
|
||||
listener(subframe);
|
||||
}
|
||||
}, 10);
|
||||
setTimeout(() => {
|
||||
currentUrl = "http://127.0.0.1:9222/json/list";
|
||||
for (const listener of listeners) {
|
||||
listener(mainFrame);
|
||||
}
|
||||
}, 20);
|
||||
});
|
||||
const page = {
|
||||
mainFrame: vi.fn(() => mainFrame),
|
||||
on: vi.fn((event: string, listener: (frame: object) => void) => {
|
||||
if (event === "framenavigated") {
|
||||
listeners.add(listener);
|
||||
}
|
||||
}),
|
||||
off: vi.fn((event: string, listener: (frame: object) => void) => {
|
||||
if (event === "framenavigated") {
|
||||
listeners.delete(listener);
|
||||
}
|
||||
}),
|
||||
url: vi.fn(() => currentUrl),
|
||||
};
|
||||
setPwToolsCoreCurrentRefLocator({ click });
|
||||
setPwToolsCoreCurrentPage(page);
|
||||
|
||||
const task = mod.clickViaPlaywright({
|
||||
cdpUrl: "http://127.0.0.1:18792",
|
||||
targetId: "T1",
|
||||
ref: "1",
|
||||
ssrfPolicy: { allowPrivateNetwork: false },
|
||||
});
|
||||
|
||||
await vi.advanceTimersByTimeAsync(20);
|
||||
await task;
|
||||
|
||||
expect(
|
||||
getPwToolsCoreNavigationGuardMocks().assertBrowserNavigationResultAllowed,
|
||||
).not.toHaveBeenCalled();
|
||||
expect(getPwToolsCoreSessionMocks().assertPageNavigationCompletedSafely).toHaveBeenCalledWith(
|
||||
{
|
||||
cdpUrl: "http://127.0.0.1:18792",
|
||||
page,
|
||||
response: null,
|
||||
ssrfPolicy: { allowPrivateNetwork: false },
|
||||
targetId: "T1",
|
||||
},
|
||||
);
|
||||
} finally {
|
||||
vi.useRealTimers();
|
||||
}
|
||||
});
|
||||
|
||||
it("checks delayed subframe navigations in the action-error recovery path", async () => {
|
||||
vi.useFakeTimers();
|
||||
try {
|
||||
const listeners = new Set<(frame: object) => void>();
|
||||
const mainFrame = {};
|
||||
const subframe = { url: () => "http://169.254.169.254/latest/meta-data/" };
|
||||
const page = {
|
||||
mainFrame: vi.fn(() => mainFrame),
|
||||
evaluate: vi.fn(async () => {
|
||||
setTimeout(() => {
|
||||
for (const listener of listeners) {
|
||||
listener(subframe);
|
||||
}
|
||||
}, 10);
|
||||
throw new Error("evaluate failed");
|
||||
}),
|
||||
on: vi.fn((event: string, listener: (frame: object) => void) => {
|
||||
if (event === "framenavigated") {
|
||||
listeners.add(listener);
|
||||
}
|
||||
}),
|
||||
off: vi.fn((event: string, listener: (frame: object) => void) => {
|
||||
if (event === "framenavigated") {
|
||||
listeners.delete(listener);
|
||||
}
|
||||
}),
|
||||
url: vi.fn(() => "https://attacker.example.com/page"),
|
||||
};
|
||||
setPwToolsCoreCurrentPage(page);
|
||||
|
||||
const blocked = new Error("SSRF blocked: private network");
|
||||
getPwToolsCoreNavigationGuardMocks().assertBrowserNavigationResultAllowed.mockRejectedValueOnce(
|
||||
blocked,
|
||||
);
|
||||
|
||||
const task = mod.evaluateViaPlaywright({
|
||||
cdpUrl: "http://127.0.0.1:18792",
|
||||
targetId: "T1",
|
||||
fn: "() => 1",
|
||||
ssrfPolicy: { allowPrivateNetwork: false },
|
||||
});
|
||||
const rejection = expect(task).rejects.toThrow("SSRF blocked: private network");
|
||||
|
||||
await vi.advanceTimersByTimeAsync(10);
|
||||
await vi.advanceTimersByTimeAsync(240);
|
||||
await rejection;
|
||||
expect(
|
||||
getPwToolsCoreSessionMocks().assertPageNavigationCompletedSafely,
|
||||
).not.toHaveBeenCalled();
|
||||
} finally {
|
||||
vi.useRealTimers();
|
||||
}
|
||||
});
|
||||
|
||||
it("snapshots subframe URLs observed during the action before they change", async () => {
|
||||
vi.useFakeTimers();
|
||||
try {
|
||||
const listeners = new Set<(frame: object) => void>();
|
||||
const mainFrame = {};
|
||||
const subframe = createMutableFrame("http://169.254.169.254/latest/meta-data/");
|
||||
const click = vi.fn(
|
||||
() =>
|
||||
new Promise<void>((resolve) => {
|
||||
setTimeout(() => {
|
||||
for (const listener of listeners) {
|
||||
listener(subframe.frame);
|
||||
}
|
||||
}, 10);
|
||||
setTimeout(() => {
|
||||
subframe.setUrl("https://example.com/embed");
|
||||
}, 20);
|
||||
setTimeout(resolve, 30);
|
||||
}),
|
||||
);
|
||||
const page = {
|
||||
mainFrame: vi.fn(() => mainFrame),
|
||||
on: vi.fn((event: string, listener: (frame: object) => void) => {
|
||||
if (event === "framenavigated") {
|
||||
listeners.add(listener);
|
||||
}
|
||||
}),
|
||||
off: vi.fn((event: string, listener: (frame: object) => void) => {
|
||||
if (event === "framenavigated") {
|
||||
listeners.delete(listener);
|
||||
}
|
||||
}),
|
||||
url: vi.fn(() => "https://attacker.example.com/page"),
|
||||
};
|
||||
setPwToolsCoreCurrentRefLocator({ click });
|
||||
setPwToolsCoreCurrentPage(page);
|
||||
|
||||
const task = mod.clickViaPlaywright({
|
||||
cdpUrl: "http://127.0.0.1:18792",
|
||||
targetId: "T1",
|
||||
ref: "1",
|
||||
ssrfPolicy: { allowPrivateNetwork: false },
|
||||
});
|
||||
|
||||
await vi.advanceTimersByTimeAsync(30);
|
||||
await vi.advanceTimersByTimeAsync(250);
|
||||
await task;
|
||||
|
||||
expect(
|
||||
getPwToolsCoreNavigationGuardMocks().assertBrowserNavigationResultAllowed,
|
||||
).toHaveBeenCalledWith({
|
||||
ssrfPolicy: { allowPrivateNetwork: false },
|
||||
url: "http://169.254.169.254/latest/meta-data/",
|
||||
});
|
||||
} finally {
|
||||
vi.useRealTimers();
|
||||
}
|
||||
});
|
||||
|
||||
it("still quarantines the main frame when an in-flight subframe block fires first", async () => {
|
||||
vi.useFakeTimers();
|
||||
try {
|
||||
const listeners = new Set<(frame: object) => void>();
|
||||
const mainFrame = {};
|
||||
const subframe = { url: () => "http://169.254.169.254/latest/meta-data/" };
|
||||
let currentUrl = "https://attacker.example.com/page";
|
||||
const click = vi.fn(
|
||||
() =>
|
||||
new Promise<void>((resolve) => {
|
||||
setTimeout(() => {
|
||||
for (const listener of listeners) {
|
||||
listener(subframe);
|
||||
}
|
||||
}, 10);
|
||||
setTimeout(() => {
|
||||
currentUrl = "http://127.0.0.1:8080/internal";
|
||||
for (const listener of listeners) {
|
||||
listener(mainFrame);
|
||||
}
|
||||
}, 20);
|
||||
setTimeout(resolve, 30);
|
||||
}),
|
||||
);
|
||||
const page = {
|
||||
mainFrame: vi.fn(() => mainFrame),
|
||||
on: vi.fn((event: string, listener: (frame: object) => void) => {
|
||||
if (event === "framenavigated") {
|
||||
listeners.add(listener);
|
||||
}
|
||||
}),
|
||||
off: vi.fn((event: string, listener: (frame: object) => void) => {
|
||||
if (event === "framenavigated") {
|
||||
listeners.delete(listener);
|
||||
}
|
||||
}),
|
||||
url: vi.fn(() => currentUrl),
|
||||
};
|
||||
setPwToolsCoreCurrentRefLocator({ click });
|
||||
setPwToolsCoreCurrentPage(page);
|
||||
|
||||
const subframeBlocked = new Error("subframe blocked");
|
||||
const mainFrameBlocked = new Error("main frame blocked");
|
||||
getPwToolsCoreNavigationGuardMocks().assertBrowserNavigationResultAllowed.mockRejectedValueOnce(
|
||||
subframeBlocked,
|
||||
);
|
||||
getPwToolsCoreSessionMocks().assertPageNavigationCompletedSafely.mockRejectedValueOnce(
|
||||
mainFrameBlocked,
|
||||
);
|
||||
|
||||
const task = mod.clickViaPlaywright({
|
||||
cdpUrl: "http://127.0.0.1:18792",
|
||||
targetId: "T1",
|
||||
ref: "1",
|
||||
ssrfPolicy: { allowPrivateNetwork: false },
|
||||
});
|
||||
const rejection = expect(task).rejects.toThrow("main frame blocked");
|
||||
|
||||
await vi.advanceTimersByTimeAsync(30);
|
||||
await rejection;
|
||||
expect(getPwToolsCoreSessionMocks().assertPageNavigationCompletedSafely).toHaveBeenCalledWith(
|
||||
{
|
||||
cdpUrl: "http://127.0.0.1:18792",
|
||||
@@ -850,115 +398,6 @@ describe("pw-tools-core interaction navigation guard", () => {
|
||||
});
|
||||
});
|
||||
|
||||
it("runs the post-keypress navigation guard when navigation starts shortly after the keypress resolves", async () => {
|
||||
vi.useFakeTimers();
|
||||
try {
|
||||
const listeners = new Set<() => void>();
|
||||
let currentUrl = "http://127.0.0.1:9222/json/version";
|
||||
const page = {
|
||||
keyboard: {
|
||||
press: vi.fn(async () => {
|
||||
setTimeout(() => {
|
||||
currentUrl = "http://127.0.0.1:9222/private-target";
|
||||
for (const listener of listeners) {
|
||||
listener();
|
||||
}
|
||||
}, 10);
|
||||
}),
|
||||
},
|
||||
on: vi.fn((event: string, listener: () => void) => {
|
||||
if (event === "framenavigated") {
|
||||
listeners.add(listener);
|
||||
}
|
||||
}),
|
||||
off: vi.fn((event: string, listener: () => void) => {
|
||||
if (event === "framenavigated") {
|
||||
listeners.delete(listener);
|
||||
}
|
||||
}),
|
||||
url: vi.fn(() => currentUrl),
|
||||
};
|
||||
setPwToolsCoreCurrentPage(page);
|
||||
|
||||
const task = mod.pressKeyViaPlaywright({
|
||||
cdpUrl: "http://127.0.0.1:18792",
|
||||
targetId: "T1",
|
||||
key: "Enter",
|
||||
ssrfPolicy: { allowPrivateNetwork: false },
|
||||
});
|
||||
|
||||
await vi.advanceTimersByTimeAsync(10);
|
||||
await task;
|
||||
|
||||
expect(getPwToolsCoreSessionMocks().assertPageNavigationCompletedSafely).toHaveBeenCalledWith(
|
||||
{
|
||||
cdpUrl: "http://127.0.0.1:18792",
|
||||
page,
|
||||
response: null,
|
||||
ssrfPolicy: { allowPrivateNetwork: false },
|
||||
targetId: "T1",
|
||||
},
|
||||
);
|
||||
} finally {
|
||||
vi.useRealTimers();
|
||||
}
|
||||
});
|
||||
|
||||
it("propagates blocked delayed submit navigation instead of reporting type success", async () => {
|
||||
vi.useFakeTimers();
|
||||
try {
|
||||
const listeners = new Set<() => void>();
|
||||
let currentUrl = "https://example.com/form";
|
||||
const locator = {
|
||||
fill: vi.fn(async () => {}),
|
||||
press: vi.fn(async () => {
|
||||
setTimeout(() => {
|
||||
currentUrl = "http://127.0.0.1:9222/private-target";
|
||||
for (const listener of listeners) {
|
||||
listener();
|
||||
}
|
||||
}, 10);
|
||||
}),
|
||||
};
|
||||
const page = {
|
||||
on: vi.fn((event: string, listener: () => void) => {
|
||||
if (event === "framenavigated") {
|
||||
listeners.add(listener);
|
||||
}
|
||||
}),
|
||||
off: vi.fn((event: string, listener: () => void) => {
|
||||
if (event === "framenavigated") {
|
||||
listeners.delete(listener);
|
||||
}
|
||||
}),
|
||||
url: vi.fn(() => currentUrl),
|
||||
};
|
||||
setPwToolsCoreCurrentRefLocator(locator);
|
||||
setPwToolsCoreCurrentPage(page);
|
||||
|
||||
const blocked = new Error("blocked delayed interaction navigation");
|
||||
getPwToolsCoreSessionMocks().assertPageNavigationCompletedSafely.mockRejectedValueOnce(
|
||||
blocked,
|
||||
);
|
||||
|
||||
const task = mod.typeViaPlaywright({
|
||||
cdpUrl: "http://127.0.0.1:18792",
|
||||
targetId: "T1",
|
||||
ref: "1",
|
||||
text: "hello",
|
||||
submit: true,
|
||||
ssrfPolicy: { allowPrivateNetwork: false },
|
||||
});
|
||||
const rejection = expect(task).rejects.toThrow("blocked delayed interaction navigation");
|
||||
|
||||
await vi.advanceTimersByTimeAsync(10);
|
||||
await rejection;
|
||||
expect(listeners.size).toBe(0);
|
||||
} finally {
|
||||
vi.useRealTimers();
|
||||
}
|
||||
});
|
||||
|
||||
it("does not run the post-click navigation guard when the url is unchanged", async () => {
|
||||
const click = vi.fn(async () => {});
|
||||
const page = { url: vi.fn(() => "http://127.0.0.1:9222/json/version") };
|
||||
|
||||
@@ -10,12 +10,8 @@ import {
|
||||
resolveActInteractionTimeoutMs,
|
||||
resolveActWaitTimeoutMs,
|
||||
} from "./act-policy.js";
|
||||
import type { BrowserActRequest, BrowserFormField } from "./client-actions.types.js";
|
||||
import type { BrowserActRequest, BrowserFormField } from "./client-actions-core.js";
|
||||
import { DEFAULT_FILL_FIELD_TYPE } from "./form-fields.js";
|
||||
import {
|
||||
assertBrowserNavigationResultAllowed,
|
||||
withBrowserNavigationPolicy,
|
||||
} from "./navigation-guard.js";
|
||||
import { DEFAULT_UPLOAD_DIR, resolveStrictExistingPathsWithinRoot } from "./paths.js";
|
||||
import {
|
||||
assertPageNavigationCompletedSafely,
|
||||
@@ -123,84 +119,20 @@ function isMainFrameNavigation(page: NavigationObservablePage, frame: Frame): bo
|
||||
return frame === page.mainFrame();
|
||||
}
|
||||
|
||||
async function assertSubframeNavigationAllowed(
|
||||
frameUrl: string,
|
||||
ssrfPolicy?: SsrFPolicy,
|
||||
): Promise<void> {
|
||||
if (!ssrfPolicy || (!frameUrl.startsWith("http://") && !frameUrl.startsWith("https://"))) {
|
||||
// Non-network frame URLs like about:blank and about:srcdoc do not cross the
|
||||
// browser SSRF boundary, so they should not trigger the navigation policy.
|
||||
return;
|
||||
}
|
||||
|
||||
await assertBrowserNavigationResultAllowed({
|
||||
url: frameUrl,
|
||||
...withBrowserNavigationPolicy(ssrfPolicy),
|
||||
});
|
||||
}
|
||||
|
||||
type ObservedDelayedNavigations = {
|
||||
mainFrameNavigated: boolean;
|
||||
subframes: string[];
|
||||
};
|
||||
|
||||
function snapshotNetworkFrameUrl(frame: Frame): string | null {
|
||||
try {
|
||||
const frameUrl = frame.url();
|
||||
return frameUrl.startsWith("http://") || frameUrl.startsWith("https://") ? frameUrl : null;
|
||||
} catch {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
async function assertObservedDelayedNavigations(opts: {
|
||||
cdpUrl: string;
|
||||
page: Page;
|
||||
ssrfPolicy?: SsrFPolicy;
|
||||
targetId?: string;
|
||||
observed: ObservedDelayedNavigations;
|
||||
}): Promise<void> {
|
||||
let subframeError: unknown;
|
||||
try {
|
||||
for (const frameUrl of opts.observed.subframes) {
|
||||
await assertSubframeNavigationAllowed(frameUrl, opts.ssrfPolicy);
|
||||
}
|
||||
} catch (err) {
|
||||
subframeError = err;
|
||||
}
|
||||
if (opts.observed.mainFrameNavigated) {
|
||||
await assertPageNavigationCompletedSafely({
|
||||
cdpUrl: opts.cdpUrl,
|
||||
page: opts.page,
|
||||
response: null,
|
||||
ssrfPolicy: opts.ssrfPolicy,
|
||||
targetId: opts.targetId,
|
||||
});
|
||||
}
|
||||
if (subframeError) {
|
||||
throw subframeError;
|
||||
}
|
||||
}
|
||||
|
||||
function observeDelayedInteractionNavigation(
|
||||
page: NavigationObservablePage,
|
||||
previousUrl: string,
|
||||
): Promise<ObservedDelayedNavigations> {
|
||||
): Promise<boolean> {
|
||||
if (didCrossDocumentUrlChange(page, previousUrl)) {
|
||||
return Promise.resolve({ mainFrameNavigated: true, subframes: [] });
|
||||
return Promise.resolve(true);
|
||||
}
|
||||
if (typeof page.on !== "function" || typeof page.off !== "function") {
|
||||
return Promise.resolve({ mainFrameNavigated: false, subframes: [] });
|
||||
return Promise.resolve(false);
|
||||
}
|
||||
|
||||
return new Promise<ObservedDelayedNavigations>((resolve) => {
|
||||
const subframes: string[] = [];
|
||||
return new Promise<boolean>((resolve) => {
|
||||
const onFrameNavigated = (frame: Frame) => {
|
||||
if (!isMainFrameNavigation(page, frame)) {
|
||||
const frameUrl = snapshotNetworkFrameUrl(frame);
|
||||
if (frameUrl) {
|
||||
subframes.push(frameUrl);
|
||||
}
|
||||
return;
|
||||
}
|
||||
// Use isHashOnlyNavigation rather than !didCrossDocumentUrlChange: the
|
||||
@@ -210,14 +142,11 @@ function observeDelayedInteractionNavigation(
|
||||
return;
|
||||
}
|
||||
cleanup();
|
||||
resolve({ mainFrameNavigated: true, subframes });
|
||||
resolve(true);
|
||||
};
|
||||
const timeout = setTimeout(() => {
|
||||
cleanup();
|
||||
resolve({
|
||||
mainFrameNavigated: didCrossDocumentUrlChange(page, previousUrl),
|
||||
subframes,
|
||||
});
|
||||
resolve(didCrossDocumentUrlChange(page, previousUrl));
|
||||
}, INTERACTION_NAVIGATION_GRACE_MS);
|
||||
const cleanup = () => {
|
||||
clearTimeout(timeout);
|
||||
@@ -267,13 +196,8 @@ function scheduleDelayedInteractionNavigationGuard(opts: {
|
||||
}
|
||||
resolve();
|
||||
};
|
||||
const subframes: string[] = [];
|
||||
const onFrameNavigated = (frame: Frame) => {
|
||||
if (!isMainFrameNavigation(page, frame)) {
|
||||
const frameUrl = snapshotNetworkFrameUrl(frame);
|
||||
if (frameUrl) {
|
||||
subframes.push(frameUrl);
|
||||
}
|
||||
return;
|
||||
}
|
||||
// Use isHashOnlyNavigation rather than !didCrossDocumentUrlChange: the
|
||||
@@ -283,26 +207,16 @@ function scheduleDelayedInteractionNavigationGuard(opts: {
|
||||
return;
|
||||
}
|
||||
cleanup();
|
||||
void assertObservedDelayedNavigations({
|
||||
void assertPageNavigationCompletedSafely({
|
||||
cdpUrl: opts.cdpUrl,
|
||||
page: opts.page,
|
||||
response: null,
|
||||
ssrfPolicy: opts.ssrfPolicy,
|
||||
targetId: opts.targetId,
|
||||
observed: { mainFrameNavigated: true, subframes },
|
||||
}).then(() => settle(), settle);
|
||||
};
|
||||
const timeout = setTimeout(() => {
|
||||
cleanup();
|
||||
void assertObservedDelayedNavigations({
|
||||
cdpUrl: opts.cdpUrl,
|
||||
page: opts.page,
|
||||
ssrfPolicy: opts.ssrfPolicy,
|
||||
targetId: opts.targetId,
|
||||
observed: {
|
||||
mainFrameNavigated: didCrossDocumentUrlChange(page, opts.previousUrl),
|
||||
subframes,
|
||||
},
|
||||
}).then(() => settle(), settle);
|
||||
settle();
|
||||
}, INTERACTION_NAVIGATION_GRACE_MS);
|
||||
const cleanup = () => {
|
||||
clearTimeout(timeout);
|
||||
@@ -334,13 +248,8 @@ async function assertInteractionNavigationCompletedSafely<T>(opts: {
|
||||
// slow interactions, silently bypassing the SSRF guard.
|
||||
const navPage = opts.page as unknown as NavigationObservablePage;
|
||||
let navigatedDuringAction = false;
|
||||
const subframeNavigationsDuringAction: string[] = [];
|
||||
const onFrameNavigated = (frame: Frame) => {
|
||||
if (!isMainFrameNavigation(navPage, frame)) {
|
||||
const frameUrl = snapshotNetworkFrameUrl(frame);
|
||||
if (frameUrl) {
|
||||
subframeNavigationsDuringAction.push(frameUrl);
|
||||
}
|
||||
return;
|
||||
}
|
||||
// Use isHashOnlyNavigation rather than didCrossDocumentUrlChange: the event
|
||||
@@ -369,15 +278,6 @@ async function assertInteractionNavigationCompletedSafely<T>(opts: {
|
||||
const navigationObserved =
|
||||
navigatedDuringAction || didCrossDocumentUrlChange(opts.page, opts.previousUrl);
|
||||
|
||||
let subframeError: unknown;
|
||||
try {
|
||||
for (const frameUrl of subframeNavigationsDuringAction) {
|
||||
await assertSubframeNavigationAllowed(frameUrl, opts.ssrfPolicy);
|
||||
}
|
||||
} catch (err) {
|
||||
subframeError = err;
|
||||
}
|
||||
|
||||
if (navigationObserved) {
|
||||
await assertPageNavigationCompletedSafely({
|
||||
cdpUrl: opts.cdpUrl,
|
||||
@@ -390,14 +290,17 @@ async function assertInteractionNavigationCompletedSafely<T>(opts: {
|
||||
// Preserve the action-error path semantics: if a rejected click/evaluate still
|
||||
// triggers a delayed navigation, the SSRF block must win over the original
|
||||
// action error instead of surfacing a stale interaction failure.
|
||||
const observed = await observeDelayedInteractionNavigation(opts.page, opts.previousUrl);
|
||||
if (observed.mainFrameNavigated || observed.subframes.length > 0) {
|
||||
await assertObservedDelayedNavigations({
|
||||
const delayedNavigationObserved = await observeDelayedInteractionNavigation(
|
||||
opts.page,
|
||||
opts.previousUrl,
|
||||
);
|
||||
if (delayedNavigationObserved) {
|
||||
await assertPageNavigationCompletedSafely({
|
||||
cdpUrl: opts.cdpUrl,
|
||||
page: opts.page,
|
||||
response: null,
|
||||
ssrfPolicy: opts.ssrfPolicy,
|
||||
targetId: opts.targetId,
|
||||
observed,
|
||||
});
|
||||
}
|
||||
} else {
|
||||
@@ -413,10 +316,6 @@ async function assertInteractionNavigationCompletedSafely<T>(opts: {
|
||||
});
|
||||
}
|
||||
|
||||
if (subframeError) {
|
||||
throw subframeError;
|
||||
}
|
||||
|
||||
if (actionError) {
|
||||
throw actionError;
|
||||
}
|
||||
@@ -480,6 +379,25 @@ function createAbortPromiseWithListener(
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
async function assertPostInteractionNavigationSafe(opts: {
|
||||
cdpUrl: string;
|
||||
page: Awaited<ReturnType<typeof getPageForTargetId>>;
|
||||
ssrfPolicy?: SsrFPolicy;
|
||||
targetId?: string;
|
||||
}): Promise<void> {
|
||||
if (!opts.ssrfPolicy) {
|
||||
return;
|
||||
}
|
||||
await assertPageNavigationCompletedSafely({
|
||||
cdpUrl: opts.cdpUrl,
|
||||
page: opts.page,
|
||||
response: null,
|
||||
ssrfPolicy: opts.ssrfPolicy,
|
||||
targetId: opts.targetId,
|
||||
});
|
||||
}
|
||||
|
||||
export async function highlightViaPlaywright(opts: {
|
||||
cdpUrl: string;
|
||||
targetId?: string;
|
||||
@@ -641,16 +559,12 @@ export async function pressKeyViaPlaywright(opts: {
|
||||
}
|
||||
const page = await getPageForTargetId(opts);
|
||||
ensurePageState(page);
|
||||
const previousUrl = page.url();
|
||||
await assertInteractionNavigationCompletedSafely({
|
||||
action: async () => {
|
||||
await page.keyboard.press(key, {
|
||||
delay: Math.max(0, Math.floor(opts.delayMs ?? 0)),
|
||||
});
|
||||
},
|
||||
await page.keyboard.press(key, {
|
||||
delay: Math.max(0, Math.floor(opts.delayMs ?? 0)),
|
||||
});
|
||||
await assertPostInteractionNavigationSafe({
|
||||
cdpUrl: opts.cdpUrl,
|
||||
page,
|
||||
previousUrl,
|
||||
ssrfPolicy: opts.ssrfPolicy,
|
||||
targetId: opts.targetId,
|
||||
});
|
||||
@@ -683,14 +597,10 @@ export async function typeViaPlaywright(opts: {
|
||||
await locator.fill(text, { timeout });
|
||||
}
|
||||
if (opts.submit) {
|
||||
const previousUrl = page.url();
|
||||
await assertInteractionNavigationCompletedSafely({
|
||||
action: async () => {
|
||||
await locator.press("Enter", { timeout });
|
||||
},
|
||||
await locator.press("Enter", { timeout });
|
||||
await assertPostInteractionNavigationSafe({
|
||||
cdpUrl: opts.cdpUrl,
|
||||
page,
|
||||
previousUrl,
|
||||
ssrfPolicy: opts.ssrfPolicy,
|
||||
targetId: opts.targetId,
|
||||
});
|
||||
|
||||
@@ -7,21 +7,6 @@ import {
|
||||
setPwToolsCoreCurrentPage,
|
||||
} from "./pw-tools-core.test-harness.js";
|
||||
|
||||
vi.mock("openclaw/plugin-sdk/browser-security-runtime", async () => {
|
||||
const actual = await vi.importActual<
|
||||
typeof import("openclaw/plugin-sdk/browser-security-runtime")
|
||||
>("openclaw/plugin-sdk/browser-security-runtime");
|
||||
const lookupFn = async (_hostname: string, options?: { all?: boolean }) => {
|
||||
const result = { address: "93.184.216.34", family: 4 };
|
||||
return options?.all === true ? [result] : result;
|
||||
};
|
||||
return {
|
||||
...actual,
|
||||
resolvePinnedHostnameWithPolicy: (hostname: string, params: object = {}) =>
|
||||
actual.resolvePinnedHostnameWithPolicy(hostname, { ...params, lookupFn: lookupFn as never }),
|
||||
};
|
||||
});
|
||||
|
||||
installPwToolsCoreTestHooks();
|
||||
const mod = await import("./pw-tools-core.snapshot.js");
|
||||
|
||||
|
||||
@@ -89,7 +89,7 @@ export async function snapshotAiViaPlaywright(opts: {
|
||||
timeout: Math.max(500, Math.min(60_000, Math.floor(opts.timeoutMs ?? 5000))),
|
||||
track: "response",
|
||||
});
|
||||
let snapshot = result?.full ?? "";
|
||||
let snapshot = String(result?.full ?? "");
|
||||
const maxChars = opts.maxChars;
|
||||
const limit =
|
||||
typeof maxChars === "number" && Number.isFinite(maxChars) && maxChars > 0
|
||||
@@ -152,7 +152,7 @@ export async function snapshotRoleViaPlaywright(opts: {
|
||||
timeout: 5000,
|
||||
track: "response",
|
||||
});
|
||||
const built = buildRoleSnapshotFromAiSnapshot(result?.full ?? "", opts.options);
|
||||
const built = buildRoleSnapshotFromAiSnapshot(String(result?.full ?? ""), opts.options);
|
||||
storeRoleRefsForTarget({
|
||||
page,
|
||||
cdpUrl: opts.cdpUrl,
|
||||
@@ -178,7 +178,7 @@ export async function snapshotRoleViaPlaywright(opts: {
|
||||
: page.locator(":root");
|
||||
|
||||
const ariaSnapshot = await locator.ariaSnapshot();
|
||||
const built = buildRoleSnapshotFromAriaSnapshot(ariaSnapshot ?? "", opts.options);
|
||||
const built = buildRoleSnapshotFromAriaSnapshot(String(ariaSnapshot ?? ""), opts.options);
|
||||
storeRoleRefsForTarget({
|
||||
page,
|
||||
cdpUrl: opts.cdpUrl,
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user