Commit Graph

319 Commits (00dcd931cb7c35e8d8a209eb4fd7828b661011de)

Author SHA1 Message Date
Peter Steinberger 949200d7cb test(browser): fix windows download tmp path assertions 9 months ago
Peter Steinberger 6a80e9db05 fix(browser): harden writable output paths 9 months ago
Agent 002539c01e fix(security): harden sandbox novnc observer flow 9 months ago
Agent e4d22fb07a fix(browser): fail closed browser auth bootstrap 9 months ago
金炳 28c80689d4
fix(browser): resolve correct targetId in navigate response after renderer swap (#25326)
* fix(browser): resolve correct targetId in navigate response after renderer swap

When `navigateViaPlaywright` triggers a Chrome renderer-process swap
(e.g. navigating from chrome-extension:// to https://), the old
`tab.targetId` captured before navigation becomes stale. The `/navigate`
route previously returned this stale targetId in its response.

After navigation, re-resolve the current tab by matching against the
final URL via `profileCtx.listTabs()`. If the old target is already gone
but the new one is not yet visible (extension re-attach in progress),
retry after 800ms.

Follow-up to #19744 (67bac62c2) which fixed the extension-side stale
session cleanup.

* fix(browser): prefer non-stale targetId when multiple tabs share the same URL

When multiple tabs have the same URL after navigation, find() could pick
a pre-existing tab instead of the newly created one. Now only re-resolve
when the old target is gone (renderer swap detected), and prefer the tab
whose targetId differs from the old one.

* fix(browser): encapsulate targetId resolution logic after navigation

Introduced a new function `resolveTargetIdAfterNavigate` to handle the resolution of the correct targetId after a navigation event that may trigger a renderer swap. This refactor improves code clarity and reuses the logic for determining the current targetId, ensuring that the correct tab is identified even when multiple tabs share the same URL.

* refactor(tests): simplify listTabs initialization in agent snapshot tests

Updated the initialization of listTabs in the agent snapshot tests for better readability by removing unnecessary line breaks. This change enhances code clarity without altering the test logic.

* fix(ui): widen Set type to accept string tokens in external-link helper

* chore: retrigger CI (unrelated Windows flaky test)

Co-authored-by: Cursor <cursoragent@cursor.com>

---------

Co-authored-by: Cursor <cursoragent@cursor.com>
9 months ago
Ayaan Zaidi 44220ef24a test: add outside-workspace error mapping coverage 9 months ago
YuzuruS f5c2be1910 fix: distinguish outside-workspace errors from not-found in fs-safe
When editing a file outside the workspace root, SafeOpenError previously
used the "invalid-path" code with the message "path escapes root". This
was indistinguishable from other invalid-path errors (hardlinks, symlinks,
non-files) and consumers often fell back to a generic "not found" message,
which was misleading.

Add a new "outside-workspace" error code with the message "file is outside
workspace root" so consumers can surface a clear, accurate error message.

- fs-safe.ts: add "outside-workspace" to SafeOpenErrorCode, use it for
  all path-escapes-root checks in openFileWithinRoot/writeFileWithinRoot
- pi-tools.read.ts: map "outside-workspace" to EACCES instead of rethrowing
- browser/paths.ts: return specific "File is outside {scopeLabel}" message
- media/server.ts: return 400 with descriptive message for outside-workspace
- fs-safe.test.ts: update traversal test expectations

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
9 months ago
Peter Steinberger eaa9e1c661 refactor(browser): unify fill field normalization 9 months ago
Rick a0b12f2ba7 fix(browser): accept fill fields without explicit type
Default missing fill field type to 'text' in /act route to avoid spurious 'fields are required' failures from relay/tool callers. Add regression test for fill payloads with ref+value only.
9 months ago
Taras Shynkarenko 20730af20b fix(browser): stop wrapping application errors with Can't reach message 9 months ago
Peter Steinberger fae8de9ae0 fix(browser): land PR #27617 relay reconnect resilience 9 months ago
Peter Steinberger 79659b2b14 fix(browser): land PR #11880 decodeURIComponent guardrails
Guard malformed percent-encoding in relay target routes and browser dispatcher params, add regression tests, and update changelog.
Landed from contributor @Yida-Dev (PR #11880).

Co-authored-by: Yida-Dev <reyifeijun@gmail.com>
9 months ago
Peter Steinberger 5416cabdf8 fix(browser): land PR #21277 dedupe concurrent relay init
Add shared per-port relay initialization dedupe so concurrent callers await a single startup lifecycle, with regression coverage and changelog entry.
Landed from contributor @HOYALIM (PR #21277).

Co-authored-by: Ho Lim <subhoya@gmail.com>
9 months ago
Peter Steinberger ce833cd6de fix(browser): land PR #24142 flush relay pending timers on stop
Flush pending extension request timers/rejections during relay shutdown and document in changelog.
Landed from contributor @kevinWangSheng (PR #24142).

Co-authored-by: Shawn <118158941+kevinWangSheng@users.noreply.github.com>
9 months ago
Peter Steinberger 42cf32c386 fix(browser): land PR #26015 query-token auth for /json relay routes
Align relay HTTP /json auth with websocket auth by accepting query-param tokens, add regression coverage, and update changelog.
Landed from contributor @Sid-Qin (PR #26015).

Co-authored-by: SidQin-cyber <sidqin0410@gmail.com>
9 months ago
Peter Steinberger 4c75eca580 fix(browser): land PR #23962 extension relay CORS fix
Reworks browser relay CORS handling for extension-origin preflight and JSON responses, adds regression tests, and updates changelog.
Landed from contributor @miloudbelarebia (PR #23962).

Co-authored-by: Miloud Belarebia <miloudbelarebia@users.noreply.github.com>
9 months ago
Peter Steinberger f41715a18f refactor(browser): split act route modules and dedupe path guards 9 months ago
Peter Steinberger 496a76c03b fix(security): harden browser trace/download temp path handling 9 months ago
Peter Steinberger ef326f5cd0 fix(browser): revalidate upload paths at use time 9 months ago
Peter Steinberger 31f2bf9519 test: fix gate regressions 9 months ago
Peter Steinberger f9de17106a refactor(browser): share relay token + options validation tests 9 months ago
Peter Steinberger 3f923e8313 test: add env -S allowlist bypass regressions 9 months ago
Peter Steinberger 5eb72ab769 fix(security): harden browser SSRF defaults and migrate legacy key 9 months ago
oneaix 216d99e585 fix(browser): derive relay auth token from gateway token in Chrome extension
The extension relay server authenticates using an HMAC-SHA256 derived
token (`openclaw-extension-relay-v1:<port>`), but the Chrome extension
was sending the raw gateway token. This caused both the WebSocket
connection and the options page validation to fail with 401 Unauthorized.

Additionally, the options page validation request triggered a CORS
preflight (due to the custom `x-openclaw-relay-token` header) which the
relay rejects because OPTIONS requests lack auth headers. The options
page now delegates the check to the background service worker which has
host_permissions and bypasses CORS preflight.

Fixes #23842

Co-authored-by: Cursor <cursoragent@cursor.com>
(cherry picked from commit bbc654b9f063ef24e7d511275e7d8c670414970b)
9 months ago
Mustafa Kemal bb8f538cd4 Browser relay: accept raw gateway token in extension auth
(cherry picked from commit e682a768d0ebe65f9818c6d47fd79e18c38d650f)
9 months ago
Peter Steinberger 1c753ea786 test: dedupe fixtures and test harness setup 9 months ago
Peter Steinberger 8af19ddc5b refactor: extract shared dedupe helpers for runtime paths 9 months ago
Peter Steinberger 2081b3a3c4 refactor(channels): dedupe hook and monitor execution paths 9 months ago
Peter Steinberger 8af6d1a186 refactor(test): dedupe repeated fixture setup helpers 9 months ago
Peter Steinberger 53ed7a0f5c test: dedupe repeated test fixtures and assertions 9 months ago
Peter Steinberger 772cf7df33 test: load chrome extension background utils across module modes 9 months ago
Peter Steinberger 2858901441 test(flaky): harden slow vmFork unit suites
Co-authored-by: Ho Lim <166576253+HOYALIM@users.noreply.github.com>
9 months ago
Peter Steinberger 9ea5228f42 fix(browser): recover stale remote target ids
Co-authored-by: Ilya Strelov <10761735+strelov1@users.noreply.github.com>
9 months ago
Peter Steinberger 1fe2043742 fix(browser): harden extension relay worker recovery
Co-authored-by: codexGW <9350182+codexGW@users.noreply.github.com>
9 months ago
Peter Steinberger 40494d67f2 fix(browser): harden extension relay reconnect race
Co-authored-by: Ho Lim <166576253+HOYALIM@users.noreply.github.com>
9 months ago
Peter Steinberger 78220db2be refactor(browser): dedupe control-server test harness 9 months ago
Peter Steinberger 296b19e413 test: dedupe gateway browser discord and channel coverage 9 months ago
Peter Steinberger f14ebd743c refactor(security): unify local-host and tailnet CIDR checks 9 months ago
tyler 9b23e5ce1f test: fix flaky auth tests when OPENCLAW_GATEWAY_TOKEN is present 9 months ago
Peter Steinberger 4a2492496e test: move browser and web auto-reply local suites out of e2e 9 months ago
Peter Steinberger 6c2e999776 refactor(security): unify secure id paths and guard weak patterns 9 months ago
Peter Steinberger ccc00d874c test(core): reduce mock reset overhead in targeted suites 9 months ago
Peter Steinberger 8a0a28763e test(core): reduce mock reset overhead across unit and e2e specs 9 months ago
Peter Steinberger 2557945a8d test(core): use lightweight clears in subagent and browser setup 9 months ago
Peter Steinberger 6e253096ed test(core): use lightweight clears in command and dispatch setup 9 months ago
Peter Steinberger 96674ca301 fix(ci): add explicit mock types in pw-session mock setup 9 months ago
Peter Steinberger 0194d50339 test: stabilize pw-session cdp mocking in parallel runs 9 months ago
Peter Steinberger 0c1a52307c fix: align draft/outbound typings and tests 9 months ago
Peter Steinberger d7f01c2c55 test(browser): use lightweight clears in server lifecycle setup 9 months ago
Peter Steinberger 639b2f5f5b test(browser): dedupe pw-session playwright mock wiring 9 months ago