Commit Graph

343 Commits

Author SHA1 Message Date
YeonGyu-Kim 503df29195 fix(team-mode): register spawned sessions early 2026-05-06 14:20:50 +09:00
YeonGyu-Kim d737f2e214 test(background-agent): remove forbidden assertions in manager tests
Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
2026-05-06 14:20:50 +09:00
YeonGyu-Kim 15a0e10450 feat(background-agent): adapt task poller for team-mode work distribution 2026-05-06 14:19:39 +09:00
YeonGyu-Kim 00a6647021 feat(background-agent): adapt idle event handler for team-mode sessions 2026-05-06 14:19:39 +09:00
YeonGyu-Kim a0d122b1e6 feat(background-agent): integrate team-mode into background manager 2026-05-06 14:19:39 +09:00
YeonGyu-Kim 417a368af8 feat(background-agent): extend types for team-mode background tasks 2026-05-06 14:19:39 +09:00
YeonGyu-Kim 32fab88d68 fix(process-cleanup): add test seam to prevent process.exitCode contaminating bun runner
scheduleForcedExit() sets process.exitCode which taints the bun test runner's
own exit code for the entire suite. This caused CI to fail even though all
tests passed individually.

Fix:
- Add __disableScheduledForcedExitForTesting / __enableScheduledForcedExitForTesting
  seams to skip scheduleForcedExit() during tests
- beforeEach disables forced exit; afterEach re-enables
- The 'fallback exit timer' test explicitly re-enables to verify setTimeout/clearTimeout
- Remove process.exitCode and exitSpy assertions that required forced exit to be active
  (shutdown call counts are sufficient to verify behavior)
2026-05-05 19:04:40 +09:00
YeonGyu-Kim ad535cd29d fix(process-cleanup): isolate test and avoid checking process.exitCode directly
The test file modifies process.exitCode and emits process signals which can
leak into bun test's exit code. Add:
1. mock.module() sentinel to route to isolated batch (following abort-with-timeout.test.ts pattern)
2. Global afterAll() hook that resets process.exitCode = 0 before test runner checks it
3. Remove direct checks of process.exitCode in assertions - only check that process.exit() was called with the right code via spy

This ensures bun test exits with code 0 even after tests verify process.exit behavior.

Fixes #3792
2026-05-05 05:15:59 +09:00
YeonGyu-Kim 45452a039c Merge pull request #3731 from yizhifengye/fix/process-cleanup-infinite-loop-epipe
fix(background-agent): detach error listener before running body to s…
2026-05-05 04:24:01 +09:00
YeonGyu-Kim fd62f5b072 Merge pull request #3639 from auyua9/fix/fatal-cleanup-exit
fix(background): exit after fatal cleanup
2026-05-05 04:15:50 +09:00
YeonGyu-Kim 6323fa8ef9 fix(background-agent): fix parentSessionID -> parentSessionId typo causing TS build failure
Property 'parentSessionID' does not exist on type 'LaunchInput' / 'BackgroundTask'.
The correct casing is 'parentSessionId' (camelCase with lowercase 'd').
Fixes CI build failure on dev branch.
2026-05-05 03:53:44 +09:00
YeonGyu-Kim e699f3388d Merge pull request #3455 from CHLK/fix/cli-run-premature-exit-with-background-tasks
fix(cli-run): prevent premature exit when background tasks are active
2026-05-04 23:58:34 +09:00
YeonGyu-Kim 65c1b50946 test(background-agent): align manager test fixtures with normalized field names
Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
2026-05-04 16:30:06 +09:00
YeonGyu-Kim 3ae9f5f104 fix(background-agent): prevent false task completion on status API outage
Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
2026-05-04 16:30:06 +09:00
YeonGyu-Kim da251c9b30 refactor(background-agent): normalize task ID field naming
Rename BackgroundTask and attempt ID fields to camelCase across background-agent consumers while moving BackgroundManager construction to a single config object.

Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
2026-05-02 03:01:03 +09:00
auyua9 875fffb7d1 fix(background): exit after fatal cleanup 2026-05-01 16:04:03 +08:00
yizhifengye 49c2a40251 fix(background-agent): detach error listener before running body to stop re-entrant log loop
When shutdown() itself emitted uncaughtException (e.g. EPIPE while closing
a broken pipe), the error listener re-entered itself, re-logged, re-ran
cleanup, and threw EPIPE again. The 6 s forced-exit timer could not fire
because every re-entry stalled the event loop with fresh synchronous work.

Users hit this after v3.17.5 and observed 100+ GB of log lines written to
disk within minutes, with one confirmed report of a 157 GB log file filling
the filesystem.

Detaching the listener with process.off() before running log() + handler()
breaks the loop at the first re-emit: the second event has no listener to
invoke, and the first invocation's scheduleForcedExit() proceeds normally.
2026-04-30 14:47:09 +08:00
Choi Kijin / 최 기진 / チョイ キジン 7adb725960 Merge remote-tracking branch 'origin/dev' into fix/retry-recovery-and-observability 2026-04-29 12:25:02 +09:00
Choi Kijin / 최 기진 / チョイ キジン 2237c1accd fix(background-agent): guard stale launch errors and retry links
Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
2026-04-28 21:43:09 +09:00
YeonGyu-Kim 24201ea951 perf(background-agent): index tasks by parent session
Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
2026-04-28 18:00:04 +09:00
Choi Kijin / 최 기진 / チョイ キジン 3fc9e6bafd Merge remote-tracking branch 'origin/dev' into opencode/mighty-wolf 2026-04-28 15:47:58 +09:00
Choi Kijin / 최 기진 / チョイ キジン 79054ea3e5 feat(background-task): render retry timelines and links
Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
2026-04-28 15:29:49 +09:00
Choi Kijin / 최 기진 / チョイ キジン 25548f2561 fix(model-fallback): retry forbidden provider errors
Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
2026-04-28 15:29:33 +09:00
Choi Kijin / 최 기진 / チョイ キジン a4968a3d1d feat(background-task): track retry attempts across sessions
Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
2026-04-28 15:27:35 +09:00
YeonGyu-Kim bda7fdbbda test(background-agent): add spawner test coverage
Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
2026-04-27 21:15:40 +09:00
柯杨 eaa3837d0b Merge remote-tracking branch 'origin/dev' into fix/cli-run-premature-exit-with-background-tasks 2026-04-22 09:45:56 +08:00
YeonGyu-Kim aa79284dc5 fix(background-agent): reset process.exitCode to 0 between cleanup tests
CI test suite exited 1 despite 0 failing tests because process-cleanup.test.ts
assertions left process.exitCode=1 in place. The afterEach hook only reset to
originalExitCode (which starts undefined), not 0, so Bun picked up exitCode=1
on shutdown and reported the shared batch as failing.

Explicitly set process.exitCode = 0 in beforeEach and afterEach so each test
starts and ends with a clean exit state.
2026-04-18 19:57:26 +09:00
YeonGyu-Kim b9d2acdcf9 fix(background-agent): run manager cleanup on uncaughtException and unhandledRejection
Signal handlers covered SIGINT/SIGTERM/SIGBREAK/beforeExit/exit, but a
synchronous throw or a top-level rejected promise terminated the process
without letting TmuxSessionManager (or any other registered manager) run
its shutdown hook. That reliably left orphan tmux panes after an opencode
crash.

Added registration for uncaughtException and unhandledRejection that fan
out through the existing cleanupAll() path, set process.exitCode = 1,
and arm the same 6 second forced-exit guard we use for signals. Test
helpers hold process-level spies so the new tests do not leak listeners
between runs.
2026-04-18 19:32:04 +09:00
YeonGyu-Kim 91848057ea fix(background-agent): fire promptAsync before tmux callback
Awaiting the tmux callback blocked the prompt for up to 10s (waitForSessionReady downstream). During that window the spawned pane ran 'opencode attach' against an empty session and rendered a blank TUI. Users saw 'pane created but attach not working'.

Start promptWithModelSuggestionRetry immediately after session.create, then invoke the tmux callback as fire-and-forget. The session becomes active before the attach client connects.

Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
2026-04-18 17:22:11 +09:00
YeonGyu-Kim f34a074f12 docs: bump claude-opus-4-6 to claude-opus-4-7 across docs, examples, and AGENTS.md
Syncs the README translations, CONTRIBUTING, docs/reference,
docs/guide, docs/examples JSONC configs, and the hierarchical
src/**/AGENTS.md files with the model version bump already landed
in the source and migration commits.
2026-04-17 14:52:19 +09:00
YeonGyu-Kim def44338ff refactor(models): bump claude-opus-4-6 to claude-opus-4-7 across fallback chains, categories, and hooks
Updates the canonical Anthropic Opus model in every fallback chain
(sisyphus, oracle, prometheus, metis, momus, visual-engineering,
ultrabrain, deep, artistry, unspecified-high), the unspecified-high
category default, the think-mode HIGH_VARIANT_MAP, the Claude Code
alias map, the claude-thinking legacy alias, the context-limit GA
regex, and event.ts fallback strings.

Widens supportsCachedAnthropicLimit to accept both claude-*-4-6 and
claude-*-4-7 so the 1M context cache still applies across the bump.

Regenerates the bundled model-capabilities snapshot from models.dev
and the model-fallback snapshot to match the new source output.
2026-04-17 14:51:52 +09:00
YeonGyu-Kim 56be458ede fix(config): remove obsolete maxDescendants config 2026-04-16 23:13:34 +09:00
YeonGyu-Kim 611f1cc932 fix(background-agent): remove descendant spawn cap 2026-04-16 23:02:27 +09:00
YeonGyu-Kim 80d3339c4c feat(background-agent): add wait-for-task-session helper
Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
2026-04-16 13:52:04 +09:00
柯杨 dd95d59402 fix(cli-run): cover all terminal paths for background task marker cleanup
Address review feedback: add updateBackgroundTaskMarker() calls to
three additional terminal paths in BackgroundManager that were missing
marker cleanup, which could leave stale "active" markers and prevent
CLI run mode from exiting:

- processKey() startTask error handler
- handleEvent() session error (non-retryable)
- pruneStaleTasksAndNotifications() stale task cleanup

Closes #3452
2026-04-16 12:02:43 +08:00
柯杨 aa90cff9cc fix(cli-run): prevent premature exit when background tasks are active
When using `opencode run`, the process exits prematurely if the main
agent dispatches background subtasks. The CLI completion checker relies
on `session.children()` + `session.status()` APIs which cannot see
tasks in "pending" state (no session created yet) or tasks whose
sessions are momentarily idle between operations.

This fix bridges BackgroundManager state to the CLI completion checker
using the existing run-continuation-state marker system:

- Add "background-task" continuation marker source
- BackgroundManager writes/clears markers on task lifecycle events
  (launch, cancel, complete, crash)
- CLI completion checker blocks exit when marker is active
- Fix todo-continuation-enforcer to also check "pending" task status

Closes #3452
2026-04-16 11:59:11 +08:00
YeonGyu-Kim 051ab840d6 Merge pull request #3348 from code-yeongyu/refactor/ulw-repo-cleanup-20260411
refactor: simplify nullish guards and remove dead no-op paths
2026-04-12 18:04:43 +09:00
YeonGyu-Kim 3bfa3bd608 fix(background-agent): pass query directory to session.get in 4 call-sites (#2937)
resolveSubagentSpawnContext and related lookups called client.session.get
without the query.directory parameter, causing project-scoped sessions
to 404 under newer OpenCode SDK versions. Threaded directory through
SpawnerContext/BackgroundManager so all four call-sites pass it.

🤖 Generated with OhMyOpenCode assistance
https://github.com/code-yeongyu/oh-my-opencode
2026-04-12 02:30:01 +09:00
YeonGyu-Kim a6e4f211a3 fix(shared): normalize claude model IDs for anthropic provider (#3290)
Anthropic API accepts claude-opus-4.6 (dot format) but not
claude-opus-4-6 (dash format). Added anthropic case to
transformModelForProvider to normalize dash-format model IDs before
they reach the provider. Updated model config snapshots and test
expectations to match the new dot-format output.

🤖 Generated with OhMyOpenCode assistance
https://github.com/code-yeongyu/oh-my-opencode
2026-04-12 02:28:27 +09:00
YeonGyu-Kim 141798efed refactor(background-agent): standardize loop detector null guards
Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
2026-04-12 00:42:52 +09:00
YeonGyu-Kim 4de02094ab test(background-agent): lock nullish loop detector behavior
Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
2026-04-12 00:42:25 +09:00
YeonGyu-Kim 79a475d60f refactor(background-agent): simplify loop detector null guard
Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
2026-04-12 00:07:10 +09:00
YeonGyu-Kim 0c5cd3a1c4 chore(agents): update all AGENTS.md generation dates to 2026-04-11
🤖 Generated with OhMyOpenCode assistance
2026-04-11 22:33:22 +09:00
YeonGyu-Kim 4180a0ba0a test(features): update background agent, MCP loader, and tmux tests
Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
2026-04-10 15:53:30 +09:00
YeonGyu-Kim 33ac57ba7a refactor: update remaining modules to use plugin-identity constants
Update various modules to use centralized constants from plugin-identity:
- get-local-version/formatter: Use PUBLISHED_PACKAGE_NAME
- run/session-resolver: Use PUBLISHED_PACKAGE_NAME
- background-agent/task-poller: Use PUBLISHED_PACKAGE_NAME
- mcp-oauth/provider: Use PUBLISHED_PACKAGE_NAME
- auto-update-checker/constants: Use ACCEPTED_PACKAGE_NAMES
- comment-checker/downloader: Use PUBLISHED_PACKAGE_NAME
- legacy-plugin-toast/hook: Use PLUGIN_NAME
- shared/data-path: Use CACHE_DIR_NAME
- shared/external-plugin-detector: Use ACCEPTED_PACKAGE_NAMES
- shared/logger: Use LOG_FILENAME
- tools/ast-grep/downloader: Use PUBLISHED_PACKAGE_NAME
- tools/call-omo-agent/tools: Use PUBLISHED_PACKAGE_NAME
- tools/delegate-task/category-resolver: Use PUBLISHED_PACKAGE_NAME
- tools/grep/constants: Use PUBLISHED_PACKAGE_NAME
- tools/grep/downloader: Use PUBLISHED_PACKAGE_NAME
- tools/lsp/lsp-client-wrapper: Use PUBLISHED_PACKAGE_NAME

🤖 Generated with assistance of OhMyOpenCode
2026-04-10 11:16:16 +09:00
YeonGyu-Kim 545c444a85 Merge remote-tracking branch 'origin/dev' into fix/delegate-task-depth-guard-rebased 2026-04-09 11:06:31 +09:00
YeonGyu-Kim bdf6e4195a Merge pull request #3225 from code-yeongyu/fix/agent-name-safety
fix(agent): narrow ULW auto-start + strip ZWSP on background path + fix auto-update identity
2026-04-08 17:40:48 +09:00
YeonGyu-Kim 119c23342a test(background): fix variant propagation test to match parent-context resolution 2026-04-08 17:25:54 +09:00
YeonGyu-Kim 359f74132a fix(delegate-task): strip ZWSP from agent names on background launch path
Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
2026-04-08 17:17:26 +09:00
YeonGyu-Kim 80c74c8849 fix(background): prevent double-decrement of descendant quota in processKey error cleanup 2026-04-08 17:15:18 +09:00