Commit Graph

31148 Commits

Author SHA1 Message Date
Peter Steinberger
f348284fa9 fix(daemon): avoid workgroup schtasks user prompts 2026-05-27 06:17:27 +01:00
MoerAI
d92a33306e fix(daemon): keep Windows Scheduled Task running on battery power (#59299)
The Windows Gateway daemon crashes (or rather is killed by Task Scheduler) every time the laptop unplugs from AC power. Reporter on Windows 10 22H2 documented a 100% failure rate.

Root cause: `activateScheduledTask` in `src/daemon/schtasks.ts` used `schtasks /Create` with CLI flags (`/SC ONLOGON /RL LIMITED /TR ...`). That CLI surface cannot set `<DisallowStartIfOnBatteries>` or `<StopIfGoingOnBatteries>`, so the task inherits the Task Scheduler defaults (both `true`), which prevent the task from starting on battery and stop it when AC power is lost mid-run.

This change switches `/Create` to `/Create /XML <tempfile>` and emits a Task Scheduler XML payload that mirrors the prior CLI flags (ONLOGON trigger, LeastPrivilege run level, InteractiveToken logon when a `taskUser` is resolved, single-instance policy, no idle restrictions, exec action wired to the existing `gateway.cmd` / `gateway.vbs` launcher) AND sets:

  <DisallowStartIfOnBatteries>false</DisallowStartIfOnBatteries>
  <StopIfGoingOnBatteries>false</StopIfGoingOnBatteries>

The XML is written as UTF-16 LE with a BOM, which is what `schtasks /XML` expects on all Windows locales. The temp file is cleaned up in a `finally` block.

The same XML re-apply is also issued from `updateExistingScheduledTask` after the existing `/Change /TR` call, so users upgrading from older versions inherit the new battery flags on the next gateway install/refresh instead of staying broken until a full uninstall+reinstall.

This follows clawsweeper's direction on #59299: "Land a narrow Windows Scheduled Task settings repair that lets the Gateway task start and continue on battery while preserving the current Startup-folder fallback, hidden launcher, quoting, and update behavior."

Preserved unchanged:
- Startup-folder fallback when `/Create` is denied or times out
- Hidden launcher (.vbs) selection via `OPENCLAW_WINDOWS_TASK_HIDDEN_LAUNCHER`
- `quoteSchtasksArg` quoting strategy for the script launch path
- `/Change` update path semantics (still updates `/TR` first)
- All `runScheduledTaskOrThrow` and fallback launch behavior downstream

Verification:
- `node scripts/run-vitest.mjs src/daemon/schtasks.install.test.ts` — 12 passed (incl. 2 new battery-flag regression tests)
- `node scripts/run-vitest.mjs src/daemon/schtasks.test.ts src/daemon/schtasks.startup-fallback.test.ts src/daemon/schtasks.stop.test.ts src/daemon/schtasks-exec.test.ts` — 54 passed (sibling daemon coverage)
- `pnpm tsgo:core` — passed (production typecheck)

Closes #59299
2026-05-27 06:17:27 +01:00
Peter Steinberger
b75f70bc04 perf(gateway): avoid cloning live switch store reads 2026-05-27 06:15:18 +01:00
Jesse Merhi
42f0822bfa fix(exec): hide unavailable durable approval actions (#86359)
* fix(macos): align ask always approval actions

* fix(macos): harden approval prompt decisions

* fix(ui): satisfy approval action lint

* fix(infra): settle jsonl sockets on close

* fix(ui): explain unavailable durable approvals

* test(macos): document legacy approval fallback
2026-05-27 14:58:11 +10:00
Alex Knight
2899560a6b fix(reply): derive explicit control command turns
Derive explicit source-reply command turns from authorized control-command bodies when legacy command source metadata is missing.

Preserve native/text structured command semantics, keep unauthorized native commands and structured normal command bodies on plugin-owned fallback paths, and pass bot username normalization through the derived detection.

Co-authored-by: Alex Knight <aknight@atlassian.com>
2026-05-27 05:57:04 +01:00
Andy Ye
2e3b4b58a1 test(agents): cover cold default model alias resolution
Adds regression coverage for provider-qualified default models with aliasless configured model entries.

Refs #86635

Co-authored-by: Andy Ye <35905412+TurboTheTurtle@users.noreply.github.com>
2026-05-27 05:47:14 +01:00
Peter Steinberger
5371b96af1 fix: prefer trusted argv runtime fallback roots 2026-05-27 05:46:51 +01:00
Peter Steinberger
e71b6f7e57 fix: expand startup argv runtime fallback hints 2026-05-27 05:46:51 +01:00
Peter Steinberger
2b9be22c0b fix: keep plugin runtime fallback on startup root 2026-05-27 05:46:51 +01:00
Peter Steinberger
78b2aeeae4 test: cover plugin runtime diagnostic context 2026-05-27 05:46:51 +01:00
Andy Ye
66a8262028 Fix runtime fallback startup argv default 2026-05-27 05:46:51 +01:00
Andy Ye
41fa603aa8 Fix plugin runtime module resolution diagnostics 2026-05-27 05:46:51 +01:00
Andy Tien
8246e91e92 fix(ui): show config open failure feedback (#87108)
Fixes #87020.

Summary:
- Surface config.openFile failures in the Control UI instead of silently doing nothing.
- Return actionable gateway errors for headless opener failures, including the config path.
- Add gateway and UI controller regression coverage for the failed-open path.

Verification:
- node scripts/run-vitest.mjs run --config test/vitest/vitest.gateway-methods.config.ts src/gateway/server-methods/config.test.ts --reporter=dot
- node scripts/run-vitest.mjs run --config test/vitest/vitest.ui.config.ts ui/src/ui/controllers/config.test.ts --reporter=dot
- pnpm check:changed via Blacksmith Testbox tbx_01ksktydqx6mk3n20yevcbkwtn
- autoreview --mode local

Thanks @Linux2010.

Co-authored-by: Linux2010 <35169750+Linux2010@users.noreply.github.com>
2026-05-27 05:45:45 +01:00
Peter Steinberger
8fa4fad3a7 perf(gateway): skip duplicate turn session touch 2026-05-27 05:28:10 +01:00
Peter Steinberger
1c8a11265b test: avoid repeated module reloads in unit tests 2026-05-27 05:24:40 +01:00
zhang-guiping
608fa52c80 fix(media): keep explicit workspace roots scoped
Fixes MEDIA delivery for agent workspaces named `workspace-*` by carrying the explicit resolved workspace directory into scoped outbound media local roots. The unscoped default local media boundary remains closed for `workspace-*` sibling directories.

Proof:
- node scripts/run-vitest.mjs src/media/read-capability.test.ts src/media/local-media-access.test.ts
- pnpm exec oxfmt --write --threads=1 src/media/read-capability.ts src/media/read-capability.test.ts src/media/local-media-access.test.ts
- node scripts/run-vitest.mjs src/media/read-capability.test.ts src/media/local-media-access.test.ts src/auto-reply/reply/reply-media-paths.test.ts
- /Users/steipete/Projects/agent-scripts/skills/autoreview/scripts/autoreview --mode branch --base origin/main

Fixes #86879.
2026-05-27 05:24:07 +01:00
Sebastien Tardif
4980c32846 fix(agents): recover failed subagent lifecycle completions
Recover failed subagent lifecycle completions through a shared retry/resume recovery path.

Proof:
- node scripts/run-vitest.mjs src/agents/subagent-registry.test.ts src/agents/subagent-registry.lifecycle-retry-grace.e2e.test.ts
- pnpm changed:lanes --json
- pnpm check:changed (Blacksmith Testbox tbx_01ksksytyrfxscxs78e8f3eegk)
- .agents/skills/autoreview/scripts/autoreview --mode local

Co-authored-by: Sebastien Tardif <sebtardif@ncf.ca>
2026-05-27 05:18:58 +01:00
Peter Steinberger
2831d697ce test: move lightweight command tests to light suite 2026-05-27 05:13:11 +01:00
Vincent Koc
6d5c15a744 fix(gateway): bound loopback preflight calls 2026-05-27 06:11:19 +02:00
Agustin Rivera
e72621e566 fix(hooks): enforce default hook agent allowlist
Enforce hook allowedAgentIds against the effective default agent when hook payloads omit or blank agentId, while preserving omitted-agent dispatch semantics for default/global routing.

Also updates the affected generated hook config docs from the contributor change and fixes the current-main memory-core test mock after rebasing the PR branch.

Verification:
- pnpm format:check extensions/memory-core/src/dreaming.test.ts src/gateway/hooks.ts src/gateway/hooks.test.ts src/gateway/server/hooks-request-handler.ts src/gateway/server.hooks.test.ts && git diff --check
- node scripts/run-vitest.mjs run --config test/vitest/vitest.gateway-server.config.ts src/gateway/hooks.test.ts src/gateway/server.hooks.test.ts --reporter=dot --pool=forks --no-file-parallelism --testTimeout=120000
- node scripts/run-tsgo.mjs -p test/tsconfig/tsconfig.extensions.test.json --incremental --tsBuildInfoFile .artifacts/tsgo-cache/extensions-test-local-pr87124.tsbuildinfo
- pnpm check:test-types
- .agents/skills/autoreview/scripts/autoreview --mode branch --base origin/main
- GitHub PR merge state CLEAN; CodeQL Critical Quality rerun succeeded after first runner checkout wedged

Co-authored-by: Agustin Rivera <agustin@rivera-web.com>
2026-05-27 05:05:18 +01:00
Peter Steinberger
05ff771010 test: speed up plugin test fixtures 2026-05-27 05:01:57 +01:00
Gio Della-Libera
371c4d621a fix(doctor): keep hooks model checks read-only (#86101)
Behavior addressed: doctor hooks model validation now loads the model catalog read-only, so lint/doctor can warn without writable catalog side effects.
Real environment tested: local temp merged tree on current origin/main.
Exact steps or command run after this patch: node scripts/run-vitest.mjs src/flows/doctor-core-checks.test.ts src/flows/doctor-health-contributions.test.ts --reporter=dot; ./node_modules/.bin/oxfmt --check --threads=1 src/flows/doctor-core-checks.ts src/flows/doctor-health-contributions.ts src/flows/doctor-core-checks.test.ts src/flows/doctor-health-contributions.test.ts; ./node_modules/.bin/oxlint src/flows/doctor-core-checks.ts src/flows/doctor-health-contributions.ts src/flows/doctor-core-checks.test.ts src/flows/doctor-health-contributions.test.ts; git diff --check origin/main <merged-tree>
Evidence after fix: 2 test files passed, 30 tests passed; oxfmt passed; oxlint passed; diff check passed.
Observed result after fix: hooks.gmail.model doctor paths call loadModelCatalog with readOnly true in both structured and legacy health surfaces.
What was not tested: GitHub Actions run details could not be refreshed because the Actions API was rate-limited; gh reported no required checks for the branch.

Thanks @giodl73-repo.

Co-authored-by: Gio Della-Libera <giodl73@gmail.com>
2026-05-27 04:55:39 +01:00
Gio Della-Libera
a4e0b6ef47 fix(daemon): keep node tasks off gateway listener cleanup
Keep Windows node service stop/restart/status from treating the gateway listener port as node-owned runtime evidence. Node Scheduled Task and Startup fallback paths now match the installed node host command line before reporting or terminating a node runtime, so WSL2 gateway loopback connectivity is not disturbed by node lifecycle commands.

Fixes #85289.

Verification:
- node scripts/run-vitest.mjs src/daemon/schtasks.startup-fallback.test.ts src/daemon/schtasks.stop.test.ts
- git diff --check

Co-authored-by: Gio Della-Libera <giodl73@gmail.com>
2026-05-27 04:51:51 +01:00
Peter Steinberger
d2711c900d perf(gateway): reuse prepared auth stores 2026-05-27 04:51:43 +01:00
Peter Steinberger
acbb06e266 test: harden e2e harness isolation 2026-05-26 23:20:42 -04:00
Peter Steinberger
96c576674d fix: keep approval runtime token local-only
Follow-up to #86771. Keep approval runtime authority source-based instead of loopback-host-based.\n\nProof: autoreview clean; Crabbox AWS run_5f28c413194d on cbx_ec9ef82cf95a passed 5 focused files / 68 tests plus formatter.\n\nCo-authored-by: fuller-stack-dev <263060202+fuller-stack-dev@users.noreply.github.com>
2026-05-27 04:20:38 +01:00
Peter Steinberger
145b57c734 perf(gateway): defer skipped-channel sidecars 2026-05-27 04:20:26 +01:00
Peter Steinberger
5177180376 test: speed up doctor config flow tests 2026-05-27 04:11:02 +01:00
Agustin Rivera
c1151ea899 fix(events): sanitize queued system markers (#87094)
* fix(events): sanitize queued system markers

* fix(changelog): record system event sanitization
2026-05-26 20:07:39 -07:00
Peter Steinberger
f393ebe54e fix(gateway): remove redundant unknown union 2026-05-26 23:06:26 -04:00
Peter Steinberger
e7f644c7b1 test: speed up model fallback tests 2026-05-27 04:06:03 +01:00
Andy Ye
ae52be9f32 fix(imessage): stage remote media before understanding
Stage remote iMessage attachments before media understanding so the image pipeline receives local remote-cache paths instead of raw macOS Messages paths.

Fixes #87089

Co-authored-by: Andy Ye <35905412+TurboTheTurtle@users.noreply.github.com>
2026-05-27 04:05:36 +01:00
Chunyue Wang
982e88821c fix(gateway): drop stale subagent announce history
Fix stale `subagent_announce` history hydration after `/new` by filtering pre-session-start announce/user reply pairs before `chat.history` projection.

Maintainer fixups added:
- require the adjacent assistant reply to carry a pre-session timestamp before dropping it
- preserve record timestamps for oversized transcript placeholders
- run the filter after Claude CLI history import and support imported timestamp/text fallback
- overread one local transcript message only as boundary context so limit-window edges do not leak stale assistant replies

Verification:
- `git diff --check`
- `node scripts/run-vitest.mjs src/gateway/server-methods/server-methods.test.ts src/gateway/session-utils.fs.test.ts src/gateway/session-history-state.test.ts src/gateway/cli-session-history.test.ts src/gateway/server.chat.gateway-server-chat-b.test.ts` -> 11 files, 463 tests passed
- `/Users/steipete/Projects/agent-scripts/skills/autoreview/scripts/autoreview --mode branch --base origin/main` -> clean, no accepted/actionable findings

Thanks @openperf.
2026-05-27 03:59:08 +01:00
Jason (Json)
13cfb77c10 fix: repair local approval resolution (#86771) 2026-05-26 19:56:30 -07:00
Val Alexander
b4f69286fd fix(gateway): stop chat timeout fallback cascade
Fix gateway/chat timeout abort propagation so timed-out runs do not cascade through fallbacks. Preserve provider timeout errors when the gateway abort signal did not fire, and keep timeout stop reasons in async gateway agent results. Includes regression coverage for chat, follow-up, memory flush, fallback classification, and gateway agent timeout results. Fixes #83962.
2026-05-27 03:54:44 +01:00
Peter Steinberger
b74cd69c6f perf(gateway): defer scheduled service imports 2026-05-27 03:52:15 +01:00
Peter Steinberger
0126aba57f test: speed up capability cli tests 2026-05-27 03:48:59 +01:00
Peter Steinberger
0ee4ccf02c perf(gateway): defer startup warning fallback imports 2026-05-27 03:45:42 +01:00
Peter Steinberger
a43cf2b5db test: type current plugin metadata snapshot mock 2026-05-27 03:44:27 +01:00
Peter Steinberger
1242931ba8 test: align WebChat delivery hint expectations 2026-05-27 03:44:27 +01:00
Peter Steinberger
0cfccdb0c7 fix(codex): keep WebChat delivery hints out of user requests
Land PR #87003 from @ragesaq with a maintainer fix for routed room events.

Co-authored-by: Forge <forge@psiclawops.dev>
2026-05-27 03:44:27 +01:00
Peter Steinberger
657f9d1422 test: speed up command secret gateway tests 2026-05-27 03:43:52 +01:00
Sarah Fortune
41962ed369 fix(status): show explicit fast mode state (#87115) 2026-05-26 19:43:14 -07:00
Josh Lehman
9119492f15 fix: preserve plugin LLM command auth (#85936)
Merged via squash.

Prepared head SHA: e61c724708
Co-authored-by: jalehman <550978+jalehman@users.noreply.github.com>
Reviewed-by: @jalehman
2026-05-26 22:41:52 -04:00
Peter Steinberger
f7a39f487c test: align loopback prompt metadata 2026-05-26 22:38:22 -04:00
Peter Steinberger
166097e564 perf(gateway): reuse metadata for startup warnings 2026-05-27 03:36:00 +01:00
Peter Steinberger
53f36a8ee6 fix(plugin-sdk): stabilize diagnostic event root alias
Fixes #87082.

Co-authored-by: Kaspre <kaspre@gmail.com>
2026-05-27 03:34:54 +01:00
Neerav Makwana
6842d72a9c fix(tui): queue prompts submitted while busy (#86722)
* fix(tui): queue busy prompt submissions

* fix(tui): queue local busy sends

* fix(tui): keep gateway busy gate

* fix(tui): treat injected backends as local

* fix(tui): preserve stop interrupts

* fix(tui): satisfy queue readiness typing

* fix(tui): keep stop aborting active runs

* fix(tui): limit embedded stop shortcut

* fix(tui): stop active and queued runs

* fix(tui): block gateway busy slash sends

* fix(tui): let stop text pass busy gate

* fix(tui): allow queued stop text

* fix(tui): clear queued abort state

* fix(tui): let stop abort finishing local runs

* fix(tui): abort terminal local maintenance on stop

* fix(tui): emit aborted after stopped maintenance

* fix(tui): preserve stop fallback and queue order

* fix(tui): let idle local stop finish

---------

Co-authored-by: Peter Steinberger <steipete@gmail.com>
2026-05-27 03:34:36 +01:00
Kaspre
b3f8a0edf3 fix(plugin-sdk): use Function.name to find onDiagnosticEvent export (#87084)
* fix(plugin-sdk): use Function.name to find onDiagnosticEvent export

normalizeDiagnosticEventsModule hardcodes `mod.r` as the fallback alias
for onDiagnosticEvent, but the bundler reassigns export aliases across
builds. On 2026.5.25-beta.1, `r` is emitFailoverEvent — calling it as
onDiagnosticEvent returns a non-function, so the combo unsubscribe
closure throws TypeError on every gateway stop.

Replace the hardcoded letter with Function.name introspection. JS
functions retain their original .name regardless of export aliasing,
so this survives bundler alias changes.

Fixes #87082

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>

* test(plugin-sdk): cover diagnostic event alias shifts

* fix(plugin-sdk): harden diagnostic alias cleanup

---------

Co-authored-by: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-26 19:31:41 -07:00
Sarah Fortune
df6ec2822f Suppress transient runner failures in channels (#87069) 2026-05-26 19:30:43 -07:00