typeclaw 0.48.13 → 0.50.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/types/agent/attention-escalation.d.ts +18 -0
- package/dist/types/agent/auth.d.ts +7 -0
- package/dist/types/agent/compaction.d.ts +8 -0
- package/dist/types/agent/git-nudge.d.ts +6 -0
- package/dist/types/agent/guard-types.d.ts +25 -0
- package/dist/types/agent/guards.d.ts +7 -0
- package/dist/types/agent/idle-compaction.d.ts +7 -0
- package/dist/types/agent/index.d.ts +163 -0
- package/dist/types/agent/live-subagents.d.ts +113 -0
- package/dist/types/agent/llm-replay-sanitizer.d.ts +11 -0
- package/dist/types/agent/loop-guard.d.ts +67 -0
- package/dist/types/agent/model-fallback.d.ts +29 -0
- package/dist/types/agent/model-overrides.d.ts +8 -0
- package/dist/types/agent/multimodal/index.d.ts +2 -0
- package/dist/types/agent/multimodal/look-at.d.ts +60 -0
- package/dist/types/agent/multimodal/looker.d.ts +61 -0
- package/dist/types/agent/multimodal/read-redirect.d.ts +6 -0
- package/dist/types/agent/network/response-body.d.ts +1 -0
- package/dist/types/agent/network/safe-http.d.ts +46 -0
- package/dist/types/agent/plugin-tools.d.ts +129 -0
- package/dist/types/agent/proactive-next-step-nudge.d.ts +2 -0
- package/dist/types/agent/prompt-cache-key.d.ts +3 -0
- package/dist/types/agent/provider-error.d.ts +23 -0
- package/dist/types/agent/reload-tool.d.ts +10 -0
- package/dist/types/agent/restart/index.d.ts +31 -0
- package/dist/types/agent/restart-handoff/index.d.ts +32 -0
- package/dist/types/agent/restart-handoff/paths.d.ts +1 -0
- package/dist/types/agent/retry-same-ref.d.ts +41 -0
- package/dist/types/agent/reviewer-activity.d.ts +3 -0
- package/dist/types/agent/reviewer-bash-policy.d.ts +8 -0
- package/dist/types/agent/self.d.ts +1 -0
- package/dist/types/agent/session-meta.d.ts +28 -0
- package/dist/types/agent/session-origin.d.ts +65 -0
- package/dist/types/agent/subagent-cache-keepalive.d.ts +38 -0
- package/dist/types/agent/subagent-completion-reminder.d.ts +29 -0
- package/dist/types/agent/subagent-drain.d.ts +25 -0
- package/dist/types/agent/subagent-session.d.ts +3 -0
- package/dist/types/agent/subagents.d.ts +153 -0
- package/dist/types/agent/system-prompt.d.ts +7 -0
- package/dist/types/agent/throttle-circuit.d.ts +25 -0
- package/dist/types/agent/todo/continuation-policy.d.ts +54 -0
- package/dist/types/agent/todo/continuation-state.d.ts +11 -0
- package/dist/types/agent/todo/continuation-wiring.d.ts +32 -0
- package/dist/types/agent/todo/continuation.d.ts +21 -0
- package/dist/types/agent/todo/scope.d.ts +6 -0
- package/dist/types/agent/todo/store.d.ts +16 -0
- package/dist/types/agent/tool-error-remediation.d.ts +1 -0
- package/dist/types/agent/tool-file-safety.d.ts +78 -0
- package/dist/types/agent/tool-not-found-nudge.d.ts +9 -0
- package/dist/types/agent/tool-result-budget.d.ts +15 -0
- package/dist/types/agent/tools/channel-disengage.d.ts +18 -0
- package/dist/types/agent/tools/channel-edit.d.ts +19 -0
- package/dist/types/agent/tools/channel-fetch-attachment.d.ts +36 -0
- package/dist/types/agent/tools/channel-handoff.d.ts +13 -0
- package/dist/types/agent/tools/channel-history-render.d.ts +3 -0
- package/dist/types/agent/tools/channel-history.d.ts +25 -0
- package/dist/types/agent/tools/channel-log.d.ts +5 -0
- package/dist/types/agent/tools/channel-react.d.ts +23 -0
- package/dist/types/agent/tools/channel-read.d.ts +27 -0
- package/dist/types/agent/tools/channel-reply.d.ts +47 -0
- package/dist/types/agent/tools/channel-send.d.ts +42 -0
- package/dist/types/agent/tools/channel-session-search.d.ts +10 -0
- package/dist/types/agent/tools/curl-impersonate.d.ts +37 -0
- package/dist/types/agent/tools/ddg.d.ts +18 -0
- package/dist/types/agent/tools/grant-role.d.ts +25 -0
- package/dist/types/agent/tools/keyed-semaphore.d.ts +10 -0
- package/dist/types/agent/tools/post-github-review.d.ts +38 -0
- package/dist/types/agent/tools/restart.d.ts +25 -0
- package/dist/types/agent/tools/runtime-notice.d.ts +3 -0
- package/dist/types/agent/tools/search-retry.d.ts +16 -0
- package/dist/types/agent/tools/skip-response.d.ts +17 -0
- package/dist/types/agent/tools/spawn-subagent.d.ts +77 -0
- package/dist/types/agent/tools/stream-snapshot.d.ts +23 -0
- package/dist/types/agent/tools/subagent-access.d.ts +20 -0
- package/dist/types/agent/tools/subagent-cancel.d.ts +23 -0
- package/dist/types/agent/tools/subagent-output.d.ts +50 -0
- package/dist/types/agent/tools/todo/index.d.ts +14 -0
- package/dist/types/agent/tools/webfetch/adaptive-html.d.ts +29 -0
- package/dist/types/agent/tools/webfetch/fetch.d.ts +26 -0
- package/dist/types/agent/tools/webfetch/html-lexical.d.ts +27 -0
- package/dist/types/agent/tools/webfetch/index.d.ts +1 -0
- package/dist/types/agent/tools/webfetch/inline-style-visibility.d.ts +3 -0
- package/dist/types/agent/tools/webfetch/strategies/grep.d.ts +11 -0
- package/dist/types/agent/tools/webfetch/strategies/jq.d.ts +4 -0
- package/dist/types/agent/tools/webfetch/strategies/raw.d.ts +1 -0
- package/dist/types/agent/tools/webfetch/strategies/readability.d.ts +16 -0
- package/dist/types/agent/tools/webfetch/strategies/selector.d.ts +4 -0
- package/dist/types/agent/tools/webfetch/strategies/snapshot.d.ts +1 -0
- package/dist/types/agent/tools/webfetch/tool.d.ts +15 -0
- package/dist/types/agent/tools/webfetch/types.d.ts +32 -0
- package/dist/types/agent/tools/websearch.d.ts +17 -0
- package/dist/types/agent/tools/wikipedia.d.ts +7 -0
- package/dist/types/agent/tools-without-local-file-operands.d.ts +1 -0
- package/dist/types/agent/turn-runner.d.ts +36 -0
- package/dist/types/agent-messenger/config-dir.d.ts +19 -0
- package/dist/types/browser/dockerfile.d.ts +2 -0
- package/dist/types/browser/registry.d.ts +49 -0
- package/dist/types/bundled-plugins/bun-hygiene/policy.d.ts +18 -0
- package/dist/types/bundled-plugins/github-cli-auth/git-askpass.d.ts +5 -0
- package/dist/types/bundled-plugins/guard/keys.d.ts +6 -0
- package/dist/types/bundled-plugins/guard/policies/managed-config.d.ts +7 -0
- package/dist/types/bundled-plugins/guard/policies/memory-topics-delete.d.ts +11 -0
- package/dist/types/bundled-plugins/guard/policies/memory-topics-write.d.ts +7 -0
- package/dist/types/bundled-plugins/guard/policies/non-workspace-write.d.ts +9 -0
- package/dist/types/bundled-plugins/guard/policies/skill-authoring.d.ts +20 -0
- package/dist/types/bundled-plugins/guard/policies/uncommitted-changes.d.ts +12 -0
- package/dist/types/bundled-plugins/guard/policy.d.ts +11 -0
- package/dist/types/bundled-plugins/memory/secret-detector.d.ts +11 -0
- package/dist/types/bundled-plugins/memory/slug.d.ts +4 -0
- package/dist/types/bundled-plugins/security/permissions.d.ts +20 -0
- package/dist/types/bundled-plugins/security/policies/private-surface-read.d.ts +34 -0
- package/dist/types/bundled-plugins/security/policies/ssrf.d.ts +18 -0
- package/dist/types/bundled-plugins/security/policy.d.ts +4 -0
- package/dist/types/channels/adapter-namespace.d.ts +2 -0
- package/dist/types/channels/adapters/mention-hints.d.ts +12 -0
- package/dist/types/channels/adapters/webex-id-ref.d.ts +5 -0
- package/dist/types/channels/background-handoff.d.ts +56 -0
- package/dist/types/channels/background-obligations.d.ts +135 -0
- package/dist/types/channels/catch-up.d.ts +26 -0
- package/dist/types/channels/commands.d.ts +2 -0
- package/dist/types/channels/completion-claim.d.ts +20 -0
- package/dist/types/channels/continuation-willingness.d.ts +1 -0
- package/dist/types/channels/continuity-types.d.ts +75 -0
- package/dist/types/channels/describe-error.d.ts +1 -0
- package/dist/types/channels/engagement.d.ts +34 -0
- package/dist/types/channels/github-false-receipt.d.ts +20 -0
- package/dist/types/channels/github-repo.d.ts +2 -0
- package/dist/types/channels/github-rereview-guard.d.ts +24 -0
- package/dist/types/channels/github-review-check.d.ts +135 -0
- package/dist/types/channels/github-review-claim.d.ts +3 -0
- package/dist/types/channels/github-review-turn-ledger.d.ts +71 -0
- package/dist/types/channels/github-review-verdict-coordinator.d.ts +117 -0
- package/dist/types/channels/github-token-bridge.d.ts +20 -0
- package/dist/types/channels/github-verdict-activity.d.ts +12 -0
- package/dist/types/channels/inbound-journal.d.ts +272 -0
- package/dist/types/channels/last-alive.d.ts +3 -0
- package/dist/types/channels/membership-cache.d.ts +27 -0
- package/dist/types/channels/membership.d.ts +21 -0
- package/dist/types/channels/outbound-flood-filter.d.ts +7 -0
- package/dist/types/channels/participants.d.ts +4 -0
- package/dist/types/channels/persistence.d.ts +32 -0
- package/dist/types/channels/recovery-notice.d.ts +26 -0
- package/dist/types/channels/recovery-outbox.d.ts +58 -0
- package/dist/types/channels/router.d.ts +798 -0
- package/dist/types/channels/schema.d.ts +501 -0
- package/dist/types/channels/session-handoff.d.ts +58 -0
- package/dist/types/channels/session-search.d.ts +29 -0
- package/dist/types/channels/types.d.ts +414 -0
- package/dist/types/channels/waiting-reactions.d.ts +25 -0
- package/dist/types/cli/builtins.d.ts +2 -0
- package/dist/types/cli/command-meta.d.ts +9 -0
- package/dist/types/coding-agent/broker-body.d.ts +7 -0
- package/dist/types/coding-agent/broker.d.ts +22 -0
- package/dist/types/coding-agent/claude.d.ts +22 -0
- package/dist/types/coding-agent/codex.d.ts +19 -0
- package/dist/types/coding-agent/index.d.ts +71 -0
- package/dist/types/coding-agent/omo-state.d.ts +2 -0
- package/dist/types/coding-agent/omo-stream.d.ts +22 -0
- package/dist/types/coding-agent/omo.d.ts +133 -0
- package/dist/types/coding-agent/runner.d.ts +35 -0
- package/dist/types/coding-agent/tool.d.ts +27 -0
- package/dist/types/coding-agent/worktree.d.ts +22 -0
- package/dist/types/commands/index.d.ts +45 -0
- package/dist/types/config/config.d.ts +814 -0
- package/dist/types/config/index.d.ts +3 -0
- package/dist/types/config/model-overrides.d.ts +3 -0
- package/dist/types/config/providers.d.ts +1456 -0
- package/dist/types/config/reloadable.d.ts +9 -0
- package/dist/types/container/agent-operation-lock.d.ts +31 -0
- package/dist/types/container/build-cache.d.ts +39 -0
- package/dist/types/container/compose-project.d.ts +1 -0
- package/dist/types/container/controller.d.ts +25 -0
- package/dist/types/container/docker-app.d.ts +23 -0
- package/dist/types/container/exit-reason.d.ts +10 -0
- package/dist/types/container/index.d.ts +14 -0
- package/dist/types/container/log-archive.d.ts +68 -0
- package/dist/types/container/log-colors.d.ts +3 -0
- package/dist/types/container/log-timestamps.d.ts +9 -0
- package/dist/types/container/logs.d.ts +37 -0
- package/dist/types/container/memory-limit.d.ts +13 -0
- package/dist/types/container/memory-oversubscription.d.ts +20 -0
- package/dist/types/container/oom-events.d.ts +18 -0
- package/dist/types/container/port.d.ts +18 -0
- package/dist/types/container/require-running.d.ts +16 -0
- package/dist/types/container/restart.d.ts +32 -0
- package/dist/types/container/shared.d.ts +93 -0
- package/dist/types/container/shell.d.ts +35 -0
- package/dist/types/container/start.d.ts +144 -0
- package/dist/types/container/stats.d.ts +31 -0
- package/dist/types/container/status.d.ts +25 -0
- package/dist/types/container/stop.d.ts +24 -0
- package/dist/types/container/tool-oom-priority.d.ts +4 -0
- package/dist/types/container/verify-running.d.ts +49 -0
- package/dist/types/cron/consumer.d.ts +42 -0
- package/dist/types/cron/count-state.d.ts +24 -0
- package/dist/types/cron/index.d.ts +21 -0
- package/dist/types/cron/list.d.ts +33 -0
- package/dist/types/cron/reloadable.d.ts +11 -0
- package/dist/types/cron/scheduler.d.ts +51 -0
- package/dist/types/cron/schema.d.ts +108 -0
- package/dist/types/dependencies/bin-resolver.d.ts +28 -0
- package/dist/types/dependencies/bins.d.ts +22 -0
- package/dist/types/dependencies/index.d.ts +2 -0
- package/dist/types/git/bound-gc-config.d.ts +4 -0
- package/dist/types/git/hookless.d.ts +1 -0
- package/dist/types/git/reconcile-ignored.d.ts +13 -0
- package/dist/types/git/resolve-agent-git.d.ts +8 -0
- package/dist/types/git/resolve-identity.d.ts +10 -0
- package/dist/types/git/run.d.ts +24 -0
- package/dist/types/git/system-commit.d.ts +2 -0
- package/dist/types/hostd/client.d.ts +13 -0
- package/dist/types/hostd/models.d.ts +1 -0
- package/dist/types/hostd/paths.d.ts +17 -0
- package/dist/types/hostd/protocol.d.ts +93 -0
- package/dist/types/hostd/spawn.d.ts +17 -0
- package/dist/types/hostd/version.d.ts +18 -0
- package/dist/types/init/auto-upgrade.d.ts +41 -0
- package/dist/types/init/cli-version.d.ts +7 -0
- package/dist/types/init/dockerfile.d.ts +34 -0
- package/dist/types/init/ensure-deps.d.ts +17 -0
- package/dist/types/init/env-file.d.ts +3 -0
- package/dist/types/init/gitignore.d.ts +5 -0
- package/dist/types/init/local-source-stamp.d.ts +3 -0
- package/dist/types/init/packagejson.d.ts +7 -0
- package/dist/types/init/paths.d.ts +3 -0
- package/dist/types/init/reconcile-plugin-deps.d.ts +13 -0
- package/dist/types/init/run-bun-install.d.ts +16 -0
- package/dist/types/init/windows-dev-link.d.ts +8 -0
- package/dist/types/mcp/catalog.d.ts +7 -0
- package/dist/types/mcp/client.d.ts +58 -0
- package/dist/types/mcp/manager.d.ts +56 -0
- package/dist/types/mcp/tools.d.ts +23 -0
- package/dist/types/models/embedding-model.d.ts +20 -0
- package/dist/types/models/transformers-version.d.ts +1 -0
- package/dist/types/network/internal-destinations.d.ts +29 -0
- package/dist/types/operations/classify-tool-outcome.d.ts +35 -0
- package/dist/types/operations/incidents.d.ts +47 -0
- package/dist/types/operations/index.d.ts +3 -0
- package/dist/types/operations/remediations.d.ts +25 -0
- package/dist/types/path-safety/real-intended-path.d.ts +9 -0
- package/dist/types/permissions/builtins.d.ts +25 -0
- package/dist/types/permissions/grant.d.ts +19 -0
- package/dist/types/permissions/index.d.ts +6 -0
- package/dist/types/permissions/match-rule.d.ts +28 -0
- package/dist/types/permissions/permissions.d.ts +42 -0
- package/dist/types/permissions/resolve.d.ts +25 -0
- package/dist/types/permissions/schema.d.ts +14 -0
- package/dist/types/plugin/context.d.ts +20 -0
- package/dist/types/plugin/core-tool-names.d.ts +4 -0
- package/dist/types/plugin/define.d.ts +46 -0
- package/dist/types/plugin/hooks.d.ts +52 -0
- package/dist/types/plugin/index.d.ts +11 -0
- package/dist/types/plugin/load-skill.d.ts +14 -0
- package/dist/types/plugin/loader.d.ts +25 -0
- package/dist/types/plugin/manager.d.ts +42 -0
- package/dist/types/plugin/registry.d.ts +73 -0
- package/dist/types/plugin/skills.d.ts +11 -0
- package/dist/types/plugin/types.d.ts +336 -0
- package/dist/types/plugin/zod-introspect.d.ts +11 -0
- package/dist/types/reload/client.d.ts +11 -0
- package/dist/types/reload/docker-exec-client.d.ts +11 -0
- package/dist/types/reload/format.d.ts +2 -0
- package/dist/types/reload/index.d.ts +6 -0
- package/dist/types/reload/recover.d.ts +22 -0
- package/dist/types/reload/registry.d.ts +10 -0
- package/dist/types/reload/types.d.ts +25 -0
- package/dist/types/role-claim/client.d.ts +20 -0
- package/dist/types/role-claim/code.d.ts +4 -0
- package/dist/types/role-claim/controller.d.ts +59 -0
- package/dist/types/role-claim/index.d.ts +6 -0
- package/dist/types/role-claim/match-rule.d.ts +9 -0
- package/dist/types/role-claim/pending.d.ts +35 -0
- package/dist/types/role-claim/reload-after-claim.d.ts +16 -0
- package/dist/types/run/llm-fetch-observer.d.ts +50 -0
- package/dist/types/sandbox/availability.d.ts +21 -0
- package/dist/types/sandbox/build.d.ts +7 -0
- package/dist/types/sandbox/canonical-secrets.d.ts +8 -0
- package/dist/types/sandbox/coding-agent.d.ts +20 -0
- package/dist/types/sandbox/dependency-bins.d.ts +19 -0
- package/dist/types/sandbox/dev-source.d.ts +4 -0
- package/dist/types/sandbox/env-exposure.d.ts +1 -0
- package/dist/types/sandbox/errors.d.ts +20 -0
- package/dist/types/sandbox/hidden-paths.d.ts +11 -0
- package/dist/types/sandbox/index.d.ts +14 -0
- package/dist/types/sandbox/package-install.d.ts +1 -0
- package/dist/types/sandbox/policy.d.ts +71 -0
- package/dist/types/sandbox/privileged-runtime.d.ts +13 -0
- package/dist/types/sandbox/quote.d.ts +2 -0
- package/dist/types/sandbox/runtime-private.d.ts +1 -0
- package/dist/types/sandbox/session-tmp.d.ts +6 -0
- package/dist/types/sandbox/symlinks.d.ts +6 -0
- package/dist/types/sandbox/writable-zones.d.ts +15 -0
- package/dist/types/secrets/coding-agent-auth.d.ts +25 -0
- package/dist/types/secrets/defaults.d.ts +21 -0
- package/dist/types/secrets/export-github-cli-store.d.ts +22 -0
- package/dist/types/secrets/hydrate.d.ts +7 -0
- package/dist/types/secrets/index.d.ts +7 -0
- package/dist/types/secrets/provision-github-cli-store.d.ts +45 -0
- package/dist/types/secrets/refresh-provider-oauth.d.ts +22 -0
- package/dist/types/secrets/resolve.d.ts +14 -0
- package/dist/types/secrets/schema.d.ts +840 -0
- package/dist/types/secrets/storage.d.ts +56 -0
- package/dist/types/shared/host-locale.d.ts +1 -0
- package/dist/types/shared/index.d.ts +5 -0
- package/dist/types/shared/local-time.d.ts +4 -0
- package/dist/types/shared/platform.d.ts +2 -0
- package/dist/types/shared/protocol.d.ts +424 -0
- package/dist/types/shared/style-text.d.ts +3 -0
- package/dist/types/shared/wsl.d.ts +17 -0
- package/dist/types/stream/broker.d.ts +2 -0
- package/dist/types/stream/index.d.ts +2 -0
- package/dist/types/stream/types.d.ts +71 -0
- package/package.json +13 -6
- package/scripts/build-plugin-types.ts +105 -0
- package/scripts/check-plugin-sdk.ts +111 -0
- package/scripts/dump-system-prompt.ts +52 -110
- package/scripts/require-parallel.ts +5 -32
- package/src/agent/guard-types.ts +3 -0
- package/src/agent/guards.ts +4 -0
- package/src/agent/idle-compaction.ts +174 -0
- package/src/agent/index.ts +210 -80
- package/src/agent/live-sessions.ts +2 -2
- package/src/agent/live-subagents.ts +20 -0
- package/src/agent/multimodal/look-at.ts +22 -9
- package/src/agent/plugin-tools.ts +66 -12
- package/src/agent/prompt-cache-key.ts +42 -0
- package/src/agent/provider-error.ts +179 -10
- package/src/agent/restart-handoff/index.ts +7 -14
- package/src/agent/reviewer-activity.ts +68 -0
- package/src/agent/reviewer-bash-policy.ts +41 -1
- package/src/agent/session-origin.ts +58 -9
- package/src/agent/subagent-cache-keepalive.ts +198 -0
- package/src/agent/subagent-session.ts +6 -0
- package/src/agent/subagents.ts +59 -9
- package/src/agent/system-prompt.ts +68 -202
- package/src/agent/todo/continuation-policy.ts +12 -4
- package/src/agent/tool-file-safety.ts +119 -15
- package/src/agent/tool-not-found-nudge.ts +1 -1
- package/src/agent/tools/channel-edit.ts +20 -10
- package/src/agent/tools/channel-fetch-attachment.ts +12 -5
- package/src/agent/tools/channel-handoff.ts +72 -0
- package/src/agent/tools/channel-history-render.ts +2 -1
- package/src/agent/tools/channel-read.ts +57 -10
- package/src/agent/tools/channel-reply.ts +55 -30
- package/src/agent/tools/channel-send.ts +69 -19
- package/src/agent/tools/channel-session-search.ts +35 -0
- package/src/agent/tools/curl-impersonate.ts +22 -6
- package/src/agent/tools/ddg.ts +13 -5
- package/src/agent/tools/post-github-review.ts +77 -15
- package/src/agent/tools/skip-response.ts +2 -2
- package/src/agent/tools/spawn-subagent.ts +190 -23
- package/src/agent/tools/stream-snapshot.ts +15 -2
- package/src/agent/tools/subagent-access.ts +11 -4
- package/src/agent/tools/subagent-output.ts +8 -0
- package/src/browser/bsk-shim.mjs +74 -0
- package/src/browser/dockerfile.ts +84 -0
- package/src/browser/egress.ts +104 -0
- package/src/browser/managed-browser.ts +205 -0
- package/src/browser/registry.ts +110 -0
- package/src/browser/relay.ts +231 -0
- package/src/browser/sandbox-entry.ts +167 -0
- package/src/bundled-plugins/agent-browser/index.ts +2 -0
- package/src/bundled-plugins/backup/README.md +10 -9
- package/src/bundled-plugins/backup/runner.ts +140 -58
- package/src/bundled-plugins/backup/subagents.ts +58 -26
- package/src/bundled-plugins/browser-agent/browser-agent.ts +89 -0
- package/src/bundled-plugins/browser-agent/index.ts +12 -0
- package/src/bundled-plugins/doc-render/index.ts +0 -10
- package/src/bundled-plugins/doc-render/render.ts +83 -111
- package/src/bundled-plugins/doc-render/skills/typeclaw-render-pdf/SKILL.md +152 -257
- package/src/bundled-plugins/github-cli-auth/gh-command.ts +38 -2
- package/src/bundled-plugins/github-cli-auth/git-auth-diagnostic.ts +95 -0
- package/src/bundled-plugins/github-cli-auth/granted-push.ts +135 -0
- package/src/bundled-plugins/github-cli-auth/index.ts +158 -70
- package/src/bundled-plugins/github-cli-auth/review-account.ts +23 -0
- package/src/bundled-plugins/github-cli-auth/review-checkout.ts +9 -2
- package/src/bundled-plugins/github-cli-auth/review-recorder.ts +45 -7
- package/src/bundled-plugins/managed-browser/index.ts +74 -0
- package/src/bundled-plugins/managed-browser/skills/browser-use/browser-use/SKILL.md +27 -0
- package/src/bundled-plugins/managed-browser/skills/browserskill/browserskill/SKILL.md +28 -0
- package/src/bundled-plugins/managed-browser/skills/omowright/omowright/SKILL.md +40 -0
- package/src/bundled-plugins/operator/operator.ts +15 -4
- package/src/bundled-plugins/qa/index.ts +11 -0
- package/src/bundled-plugins/qa/qa.ts +160 -0
- package/src/bundled-plugins/qa/skills/qa-cli.ts +50 -0
- package/src/bundled-plugins/qa/skills/qa-general.ts +30 -0
- package/src/bundled-plugins/qa/skills/qa-http.ts +39 -0
- package/src/bundled-plugins/qa/skills/qa-pr.ts +51 -0
- package/src/bundled-plugins/qa/skills/qa-web.ts +49 -0
- package/src/bundled-plugins/reviewer/skills/code-review.ts +1 -1
- package/src/bundled-plugins/security/index.ts +103 -36
- package/src/bundled-plugins/security/policies/git-exfil.ts +24 -12
- package/src/bundled-plugins/security/policies/outbound-secret-scan.ts +1 -0
- package/src/channels/adapter-namespace.ts +13 -0
- package/src/channels/adapters/discord-bot-reactions.ts +18 -0
- package/src/channels/adapters/discord-bot.ts +219 -72
- package/src/channels/adapters/discord-reactions.ts +18 -0
- package/src/channels/adapters/discord.ts +114 -8
- package/src/channels/adapters/github/inbound.ts +103 -8
- package/src/channels/adapters/github/index.ts +267 -19
- package/src/channels/adapters/github/last-alive.ts +15 -0
- package/src/channels/adapters/github/outbound.ts +54 -18
- package/src/channels/adapters/github/pending-review-store.ts +141 -0
- package/src/channels/adapters/github/permission-guidance.ts +1 -0
- package/src/channels/adapters/github/reactions.ts +100 -0
- package/src/channels/adapters/github/reconcile-cooldown-store.ts +197 -67
- package/src/channels/adapters/github/reconcile-open-prs.ts +418 -33
- package/src/channels/adapters/github/recovery.ts +106 -0
- package/src/channels/adapters/github/review-check.ts +510 -0
- package/src/channels/adapters/github/review-submitter.ts +34 -2
- package/src/channels/adapters/instagram.ts +32 -14
- package/src/channels/adapters/kakaotalk.ts +22 -7
- package/src/channels/adapters/line.ts +18 -3
- package/src/channels/adapters/outbound-account.ts +20 -0
- package/src/channels/adapters/own-reactions.ts +66 -0
- package/src/channels/adapters/recovery-correlation.ts +214 -0
- package/src/channels/adapters/slack-attachment-download.ts +14 -3
- package/src/channels/adapters/slack-bot-author-resolver.ts +4 -3
- package/src/channels/adapters/slack-bot-channel-resolver.ts +9 -6
- package/src/channels/adapters/slack-bot-classify.ts +19 -11
- package/src/channels/adapters/slack-bot-dedupe.ts +111 -28
- package/src/channels/adapters/slack-bot-reactions.ts +18 -0
- package/src/channels/adapters/slack-bot-slash-commands.ts +3 -1
- package/src/channels/adapters/slack-bot.ts +424 -124
- package/src/channels/adapters/slack-classify.ts +26 -4
- package/src/channels/adapters/slack-inbound-revision.ts +96 -0
- package/src/channels/adapters/slack-reactions.ts +18 -0
- package/src/channels/adapters/slack-thread-ts.ts +6 -0
- package/src/channels/adapters/slack.ts +48 -3
- package/src/channels/adapters/teams.ts +14 -4
- package/src/channels/adapters/telegram-bot.ts +56 -10
- package/src/channels/adapters/webex-bot.ts +12 -2
- package/src/channels/adapters/webex.ts +12 -2
- package/src/channels/background-handoff.ts +434 -0
- package/src/channels/background-obligations.ts +893 -0
- package/src/channels/catch-up.ts +137 -0
- package/src/channels/continuation-willingness.ts +2 -2
- package/src/channels/continuity-types.ts +272 -0
- package/src/channels/engagement.ts +17 -1
- package/src/channels/github-false-receipt.ts +3 -3
- package/src/channels/github-rereview-guard.ts +9 -5
- package/src/channels/github-review-check.ts +598 -0
- package/src/channels/github-review-turn-ledger.ts +102 -28
- package/src/channels/github-review-verdict-coordinator.ts +72 -12
- package/src/channels/github-token-bridge.ts +35 -5
- package/src/channels/inbound-journal.ts +1738 -0
- package/src/channels/index.ts +6 -1
- package/src/channels/last-alive.ts +34 -0
- package/src/channels/manager.ts +25 -8
- package/src/channels/recovery-dispatcher.ts +264 -0
- package/src/channels/recovery-notice.ts +94 -0
- package/src/channels/recovery-outbox.ts +459 -0
- package/src/channels/router.ts +2951 -736
- package/src/channels/schema.ts +8 -1
- package/src/channels/session-handoff.fixture.ts +144 -0
- package/src/channels/session-handoff.ts +175 -0
- package/src/channels/session-search.ts +71 -0
- package/src/channels/subagent-completion-bridge.ts +17 -14
- package/src/channels/types.ts +133 -18
- package/src/channels/waiting-reactions.ts +664 -0
- package/src/cli/channel.ts +2 -3
- package/src/cli/compose.ts +7 -4
- package/src/cli/hostd.ts +49 -3
- package/src/cli/init.ts +2 -3
- package/src/cli/inspect.ts +11 -14
- package/src/cli/model.ts +132 -3
- package/src/coding-agent/broker-body.ts +38 -0
- package/src/coding-agent/broker.ts +290 -0
- package/src/coding-agent/claude.ts +95 -0
- package/src/coding-agent/codex.ts +104 -0
- package/src/coding-agent/index.ts +512 -0
- package/src/coding-agent/omo-state.ts +69 -0
- package/src/coding-agent/omo-stream.ts +138 -0
- package/src/coding-agent/omo.ts +192 -0
- package/src/coding-agent/runner.ts +285 -0
- package/src/coding-agent/tool.ts +62 -0
- package/src/coding-agent/worktree.ts +355 -0
- package/src/compose/restart.ts +10 -3
- package/src/compose/start.ts +20 -3
- package/src/config/config.ts +121 -25
- package/src/config/model-overrides.ts +59 -0
- package/src/config/models-mutation.ts +185 -2
- package/src/config/providers-mutation.ts +12 -4
- package/src/config/providers.ts +71 -9
- package/src/container/exit-reason.ts +44 -0
- package/src/container/index.ts +5 -0
- package/src/container/log-archive.ts +51 -13
- package/src/container/memory-limit.ts +1 -1
- package/src/container/memory-oversubscription.ts +36 -6
- package/src/container/oom-events.ts +86 -0
- package/src/container/restart.ts +2 -0
- package/src/container/shared.ts +8 -1
- package/src/container/start.ts +120 -17
- package/src/container/stop.ts +6 -2
- package/src/container/tool-oom-priority.ts +32 -0
- package/src/cron/consumer.ts +10 -4
- package/src/cron/reloadable.ts +23 -2
- package/src/doctor/checks.ts +22 -8
- package/src/hostd/daemon.ts +33 -11
- package/src/hostd/spawn.ts +106 -5
- package/src/hostd/version.ts +20 -0
- package/src/hostd/watchdog.ts +241 -0
- package/src/init/auto-upgrade.ts +7 -1
- package/src/init/dockerfile.ts +112 -602
- package/src/init/index.ts +6 -6
- package/src/init/local-source-stamp.ts +68 -0
- package/src/init/models-dev.ts +4 -0
- package/src/init/validate-api-key.ts +3 -0
- package/src/mcp/client.ts +3 -1
- package/src/operations/classify-tool-outcome.ts +45 -1
- package/src/operations/incidents.ts +10 -5
- package/src/permissions/builtins.ts +7 -0
- package/src/permissions/permissions.ts +18 -9
- package/src/permissions/resolve.ts +7 -1
- package/src/plugin/context.ts +2 -0
- package/src/plugin/core-tool-names.ts +1 -1
- package/src/plugin/define.ts +1 -0
- package/src/plugin/hooks.ts +137 -0
- package/src/plugin/index.ts +7 -0
- package/src/plugin/manager.ts +4 -0
- package/src/plugin/types.ts +66 -1
- package/src/run/background-handoff-boot.ts +86 -0
- package/src/run/bundled-plugins.ts +6 -0
- package/src/run/index.ts +107 -97
- package/src/run/llm-fetch-observer.ts +12 -15
- package/src/run/resource-sample.ts +19 -0
- package/src/sandbox/build.ts +4 -0
- package/src/sandbox/canonical-secrets.ts +4 -0
- package/src/sandbox/coding-agent.ts +214 -0
- package/src/sandbox/dev-source.ts +26 -0
- package/src/sandbox/hidden-paths.ts +16 -2
- package/src/sandbox/policy.ts +1 -0
- package/src/sandbox/runtime-private.ts +4 -1
- package/src/secrets/coding-agent-auth.ts +97 -0
- package/src/secrets/index.ts +0 -16
- package/src/secrets/storage.ts +13 -0
- package/src/server/command-runner.ts +6 -2
- package/src/server/index.ts +101 -40
- package/src/skills/typeclaw-channel-github/SKILL.md +15 -13
- package/src/skills/typeclaw-claude-code/SKILL.md +25 -260
- package/src/skills/typeclaw-claude-code/references/auth-flow.md +7 -23
- package/src/skills/typeclaw-claude-code/references/headless-sessions.md +11 -0
- package/src/skills/typeclaw-claude-code/references/results-and-worktrees.md +13 -0
- package/src/skills/typeclaw-codex-cli/SKILL.md +35 -270
- package/src/skills/typeclaw-codex-cli/references/auth-flow.md +13 -20
- package/src/skills/typeclaw-codex-cli/references/headless-sessions.md +26 -0
- package/src/skills/typeclaw-codex-cli/references/results-and-worktrees.md +28 -0
- package/src/skills/typeclaw-config/SKILL.md +60 -26
- package/src/skills/typeclaw-config/references/dockerfile.md +14 -13
- package/src/skills/typeclaw-cron/SKILL.md +1 -1
- package/src/skills/typeclaw-github-contributing/SKILL.md +3 -3
- package/src/skills/typeclaw-memory/SKILL.md +3 -3
- package/src/skills/typeclaw-monorepo/SKILL.md +1 -1
- package/src/skills/typeclaw-omo-cli/SKILL.md +52 -0
- package/src/skills/typeclaw-omo-cli/references/auth-flow.md +11 -0
- package/src/skills/typeclaw-omo-cli/references/headless-sessions.md +11 -0
- package/src/skills/typeclaw-omo-cli/references/results-and-worktrees.md +23 -0
- package/src/skills/typeclaw-permissions/SKILL.md +7 -7
- package/src/skills/typeclaw-plugins/SKILL.md +15 -15
- package/src/skills/typeclaw-skills/SKILL.md +19 -2
- package/src/skills/typeclaw-troubleshooting/SKILL.md +26 -2
- package/typeclaw.schema.json +448 -6
- package/src/bundled-plugins/doc-render/templates/lib.typ +0 -339
- package/src/bundled-plugins/github-cli-auth/gh-store.ts +0 -733
- package/src/secrets/claude-credentials-json.ts +0 -129
- package/src/secrets/codex-auth-json.ts +0 -102
- package/src/secrets/export-claude-credentials-file.ts +0 -270
- package/src/secrets/export-codex-auth-file.ts +0 -250
- package/src/skills/typeclaw-claude-code/references/stop-hook.md +0 -101
- package/src/skills/typeclaw-claude-code/references/tmux-driving.md +0 -243
- package/src/skills/typeclaw-codex-cli/references/stop-hook.md +0 -92
- package/src/skills/typeclaw-codex-cli/references/tmux-driving.md +0 -239
package/src/plugin/index.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export {
|
|
2
2
|
bashTool,
|
|
3
|
+
codingAgentTool,
|
|
3
4
|
defineCommand,
|
|
4
5
|
definePlugin,
|
|
5
6
|
defineSubagent,
|
|
@@ -16,6 +17,10 @@ export {
|
|
|
16
17
|
|
|
17
18
|
export type {
|
|
18
19
|
BuiltinToolRef,
|
|
20
|
+
ChannelMessageObservedEvent,
|
|
21
|
+
ChannelOutboundBeforeEvent,
|
|
22
|
+
ChannelOutboundBeforeResult,
|
|
23
|
+
ChannelOutboundOrigin,
|
|
19
24
|
CommandExecResult,
|
|
20
25
|
CommandStreams,
|
|
21
26
|
ContainerCommand,
|
|
@@ -53,6 +58,7 @@ export type {
|
|
|
53
58
|
SessionTurnEndEvent,
|
|
54
59
|
SessionTurnStartEvent,
|
|
55
60
|
SpawnSubagentOptions,
|
|
61
|
+
SlackObservedMessage,
|
|
56
62
|
Subagent,
|
|
57
63
|
SubagentContext,
|
|
58
64
|
Tool,
|
|
@@ -98,3 +104,4 @@ export {
|
|
|
98
104
|
type RegisteredTool,
|
|
99
105
|
} from './registry'
|
|
100
106
|
export { createHookBus, type HookBus } from './hooks'
|
|
107
|
+
export { createSubagentSessionManager } from '@/agent/subagent-session'
|
package/src/plugin/manager.ts
CHANGED
|
@@ -37,6 +37,7 @@ export type LoadPluginsOptions = {
|
|
|
37
37
|
resolveGithubTokenForRepo?: ResolveGithubTokenForRepo
|
|
38
38
|
hasGithubAppTokenResolver?: () => boolean
|
|
39
39
|
getGithubAppSelfLogin?: () => string | null
|
|
40
|
+
resolveGithubPatForRepo?: ResolveGithubTokenForRepo
|
|
40
41
|
// Bundled plugins resolved by the runtime (not from typeclaw.json). Loaded
|
|
41
42
|
// before user-declared `entries` so a config block named after a bundled
|
|
42
43
|
// plugin (e.g. "memory") is consumed by the bundled plugin, and so plugin-
|
|
@@ -129,6 +130,7 @@ export async function loadPlugins(opts: LoadPluginsOptions): Promise<LoadPlugins
|
|
|
129
130
|
resolveGithubTokenForRepo: opts.resolveGithubTokenForRepo,
|
|
130
131
|
hasGithubAppTokenResolver: opts.hasGithubAppTokenResolver,
|
|
131
132
|
getGithubAppSelfLogin: opts.getGithubAppSelfLogin,
|
|
133
|
+
resolveGithubPatForRepo: opts.resolveGithubPatForRepo,
|
|
132
134
|
spawnSubagent: (name, payload, options) => spawnSubagentImpl(name, payload, options),
|
|
133
135
|
isBooted: () => booted,
|
|
134
136
|
},
|
|
@@ -245,6 +247,7 @@ type RegisterOnePluginArgs = {
|
|
|
245
247
|
resolveGithubTokenForRepo?: ResolveGithubTokenForRepo
|
|
246
248
|
hasGithubAppTokenResolver?: () => boolean
|
|
247
249
|
getGithubAppSelfLogin?: () => string | null
|
|
250
|
+
resolveGithubPatForRepo?: ResolveGithubTokenForRepo
|
|
248
251
|
spawnSubagent: SpawnSubagentFn
|
|
249
252
|
isBooted: () => boolean
|
|
250
253
|
}
|
|
@@ -277,6 +280,7 @@ async function registerOnePlugin(args: RegisterOnePluginArgs): Promise<void> {
|
|
|
277
280
|
resolveGithubTokenForRepo: args.ctxDeps.resolveGithubTokenForRepo,
|
|
278
281
|
hasGithubAppTokenResolver: args.ctxDeps.hasGithubAppTokenResolver,
|
|
279
282
|
getGithubAppSelfLogin: args.ctxDeps.getGithubAppSelfLogin,
|
|
283
|
+
resolveGithubPatForRepo: args.ctxDeps.resolveGithubPatForRepo,
|
|
280
284
|
spawnSubagent: args.ctxDeps.spawnSubagent,
|
|
281
285
|
isBooted: args.ctxDeps.isBooted,
|
|
282
286
|
})
|
package/src/plugin/types.ts
CHANGED
|
@@ -54,7 +54,12 @@ export type SubagentContext<P = unknown> = {
|
|
|
54
54
|
payload: P
|
|
55
55
|
}
|
|
56
56
|
|
|
57
|
-
export type RunSession = (override?: {
|
|
57
|
+
export type RunSession = (override?: {
|
|
58
|
+
userPrompt?: string
|
|
59
|
+
// Called after a completed run with the terminal assistant text, or null
|
|
60
|
+
// after an empty terminal response or provider failure. No block projection.
|
|
61
|
+
onFinalMessage?: (message: string | null) => void
|
|
62
|
+
}) => Promise<void>
|
|
58
63
|
|
|
59
64
|
// The plugin-author-facing subagent declaration. Differs from
|
|
60
65
|
// `@/agent/subagents`'s `Subagent` only in the shape of `tools`/`customTools`:
|
|
@@ -68,6 +73,9 @@ export type RunSession = (override?: { userPrompt?: string }) => Promise<void>
|
|
|
68
73
|
export type Subagent<P = unknown> = SubagentShared<P> & {
|
|
69
74
|
tools?: BuiltinToolRef[]
|
|
70
75
|
customTools?: Tool<any>[]
|
|
76
|
+
// Trusted plugin declaration, never a model payload or per-call override.
|
|
77
|
+
// Raw source readers use in-memory sessions rather than persisted transcripts.
|
|
78
|
+
ephemeral?: boolean
|
|
71
79
|
}
|
|
72
80
|
|
|
73
81
|
// Cron job map keys are local; the runtime prefixes with `__plugin_<plugin-name>_`
|
|
@@ -248,6 +256,57 @@ export type HookContext = {
|
|
|
248
256
|
logger: PluginLogger
|
|
249
257
|
}
|
|
250
258
|
|
|
259
|
+
// Raw Socket Mode message deliveries, not the router's admitted/wake events.
|
|
260
|
+
// Edits, deletes, self/bot messages and duplicates are intentionally included.
|
|
261
|
+
export type SlackObservedMessage = {
|
|
262
|
+
readonly type: 'message'
|
|
263
|
+
readonly channel: string
|
|
264
|
+
readonly ts?: string
|
|
265
|
+
readonly subtype?: string
|
|
266
|
+
readonly text?: string
|
|
267
|
+
readonly user?: string
|
|
268
|
+
readonly thread_ts?: string
|
|
269
|
+
readonly event_ts?: string
|
|
270
|
+
readonly deleted_ts?: string
|
|
271
|
+
readonly message?: Readonly<Record<string, unknown>>
|
|
272
|
+
readonly previous_message?: Readonly<Record<string, unknown>>
|
|
273
|
+
readonly [key: string]: unknown
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
// Deep-frozen snapshot after transport ack, before classification/deduplication.
|
|
277
|
+
// Observe-only and best-effort: never awaited by routing, never starts a session.
|
|
278
|
+
// This is a Slack-bot capability, not a cross-adapter or durable event journal.
|
|
279
|
+
export type ChannelMessageObservedEvent = {
|
|
280
|
+
readonly adapter: 'slack-bot'
|
|
281
|
+
readonly workspace: string | null
|
|
282
|
+
readonly selfUserId: string | null
|
|
283
|
+
readonly receivedAt: number
|
|
284
|
+
readonly event: SlackObservedMessage
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
// Last-mile text transform for trusted, in-process plugins; not a delivery gate.
|
|
288
|
+
// Only text can be replaced. Invalid/empty results, errors and timeouts retain
|
|
289
|
+
// the previous text. An attachment-only send cannot acquire a caption.
|
|
290
|
+
export type ChannelOutboundOrigin = {
|
|
291
|
+
readonly kind: SessionOrigin['kind']
|
|
292
|
+
readonly jobId?: string
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
export type ChannelOutboundBeforeEvent = {
|
|
296
|
+
readonly adapter: string
|
|
297
|
+
readonly workspace: string
|
|
298
|
+
readonly chat: string
|
|
299
|
+
readonly thread?: string
|
|
300
|
+
readonly text: string
|
|
301
|
+
readonly op: 'send' | 'edit'
|
|
302
|
+
readonly messageId?: string
|
|
303
|
+
readonly source: 'tool' | 'system'
|
|
304
|
+
readonly outputKind?: 'substantive' | 'status' | 'meta'
|
|
305
|
+
readonly origin?: ChannelOutboundOrigin
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
export type ChannelOutboundBeforeResult = { text: string } | undefined
|
|
309
|
+
|
|
251
310
|
export type Hooks = {
|
|
252
311
|
'session.start'?: (event: SessionStartEvent, ctx: HookContext) => Promise<void> | void
|
|
253
312
|
'session.end'?: (event: SessionEndEvent, ctx: HookContext) => Promise<void> | void
|
|
@@ -257,6 +316,11 @@ export type Hooks = {
|
|
|
257
316
|
'session.turn.end'?: (event: SessionTurnEndEvent, ctx: HookContext) => Promise<void> | void
|
|
258
317
|
'tool.before'?: (event: ToolBeforeEvent, ctx: HookContext) => Promise<ToolBeforeResult> | ToolBeforeResult
|
|
259
318
|
'tool.after'?: (event: ToolAfterEvent, ctx: HookContext) => Promise<void> | void
|
|
319
|
+
'channel.message.observed'?: (event: ChannelMessageObservedEvent, ctx: HookContext) => Promise<void> | void
|
|
320
|
+
'channel.outbound.before'?: (
|
|
321
|
+
event: ChannelOutboundBeforeEvent,
|
|
322
|
+
ctx: HookContext,
|
|
323
|
+
) => Promise<ChannelOutboundBeforeResult> | ChannelOutboundBeforeResult
|
|
260
324
|
}
|
|
261
325
|
|
|
262
326
|
export type HookName = keyof Hooks
|
|
@@ -305,6 +369,7 @@ export type PluginGithubServices = {
|
|
|
305
369
|
resolveTokenForRepo: ResolveGithubTokenForRepo
|
|
306
370
|
hasAppTokenResolver: () => boolean
|
|
307
371
|
getAppSelfLogin?: () => string | null
|
|
372
|
+
resolvePatForRepo?: ResolveGithubTokenForRepo
|
|
308
373
|
}
|
|
309
374
|
|
|
310
375
|
export type PluginExports = {
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import { consumeRestartHandoff } from '@/agent/restart-handoff'
|
|
2
|
+
import type { LegacyBackgroundHandoffReader } from '@/channels/background-handoff'
|
|
3
|
+
import type { BackgroundObligationStore } from '@/channels/background-obligations'
|
|
4
|
+
import type { InboundJournal } from '@/channels/inbound-journal'
|
|
5
|
+
import { loadChannelSessions } from '@/channels/persistence'
|
|
6
|
+
import type { RecoveryOutbox } from '@/channels/recovery-outbox'
|
|
7
|
+
import type { ChannelRouter, RestartReservation } from '@/channels/router'
|
|
8
|
+
import { channelKeyId, type ChannelKey } from '@/channels/types'
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Transfer interrupted source authority at boot, before adapters or the dispatcher run; never replay work.
|
|
12
|
+
* Committed mixed decisions are repaired first, issued transfers re-import unchanged, inbound-seeded
|
|
13
|
+
* partitions absorb their compatible children, and only then do legacy inventory and unmatched
|
|
14
|
+
* children take their independent notices. A failure freezes dependent background progress
|
|
15
|
+
* (apparently valid child JSON is not proof of independence from an unreadable journal) and is
|
|
16
|
+
* rethrown; the caller keeps adapters running and dependent notices fail closed at dispatch.
|
|
17
|
+
*/
|
|
18
|
+
export async function bootBackgroundObligations(options: {
|
|
19
|
+
inboundJournal: InboundJournal
|
|
20
|
+
obligations: BackgroundObligationStore
|
|
21
|
+
outbox: RecoveryOutbox
|
|
22
|
+
inventory: LegacyBackgroundHandoffReader
|
|
23
|
+
}): Promise<void> {
|
|
24
|
+
try {
|
|
25
|
+
await options.inboundJournal.initialize()
|
|
26
|
+
await options.inboundJournal.repair()
|
|
27
|
+
await options.inboundJournal.importOldEpoch(options.outbox)
|
|
28
|
+
await options.obligations.migrateLegacy(options.inventory, options.outbox)
|
|
29
|
+
await options.obligations.importOldEpoch(options.outbox)
|
|
30
|
+
} catch (error) {
|
|
31
|
+
options.obligations.setFrozen(error)
|
|
32
|
+
throw error
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/** Ordinary #291 restart greetings retain their reservation/TTL behavior. */
|
|
37
|
+
export async function bootChannelRestartGreeting(options: {
|
|
38
|
+
agentDir: string
|
|
39
|
+
router: Pick<ChannelRouter, 'reserveRestartHandoff'>
|
|
40
|
+
configured: (key: ChannelKey) => boolean
|
|
41
|
+
startAdapters: () => Promise<void>
|
|
42
|
+
onError: (error: unknown) => void
|
|
43
|
+
}): Promise<void> {
|
|
44
|
+
const report = (error: unknown): void => {
|
|
45
|
+
try {
|
|
46
|
+
options.onError(error)
|
|
47
|
+
} catch {
|
|
48
|
+
// Reporting must not strand a greeting reservation.
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
let reservation: RestartReservation | null = null
|
|
52
|
+
try {
|
|
53
|
+
const explicit = await consumeRestartHandoff(options.agentDir, {
|
|
54
|
+
accept: (handoff) => handoff.origin.kind === 'channel',
|
|
55
|
+
})
|
|
56
|
+
if (explicit?.origin.kind === 'channel') {
|
|
57
|
+
try {
|
|
58
|
+
const originalKey = explicit.origin.key
|
|
59
|
+
const mappings = await loadChannelSessions(options.agentDir)
|
|
60
|
+
if (
|
|
61
|
+
options.configured(originalKey) &&
|
|
62
|
+
mappings.some(
|
|
63
|
+
(mapping) =>
|
|
64
|
+
channelKeyId(mapping) === channelKeyId(originalKey) &&
|
|
65
|
+
mapping.sessionId === explicit.originatingSessionId,
|
|
66
|
+
)
|
|
67
|
+
) {
|
|
68
|
+
const { interruptedSubagents: _coveredLostWork, ...greeting } = explicit
|
|
69
|
+
reservation = options.router.reserveRestartHandoff(greeting)
|
|
70
|
+
}
|
|
71
|
+
} catch (error) {
|
|
72
|
+
report(error)
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
await options.startAdapters()
|
|
76
|
+
if (reservation) {
|
|
77
|
+
try {
|
|
78
|
+
await reservation.resume()
|
|
79
|
+
} catch (error) {
|
|
80
|
+
report(error)
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
} finally {
|
|
84
|
+
reservation?.release()
|
|
85
|
+
}
|
|
86
|
+
}
|
|
@@ -1,13 +1,16 @@
|
|
|
1
1
|
import agentBrowserPlugin from '@/bundled-plugins/agent-browser'
|
|
2
2
|
import backupPlugin from '@/bundled-plugins/backup'
|
|
3
|
+
import browserAgentPlugin from '@/bundled-plugins/browser-agent'
|
|
3
4
|
import bunHygienePlugin from '@/bundled-plugins/bun-hygiene'
|
|
4
5
|
import docRenderPlugin from '@/bundled-plugins/doc-render'
|
|
5
6
|
import explorerPlugin from '@/bundled-plugins/explorer'
|
|
6
7
|
import githubCliAuthPlugin from '@/bundled-plugins/github-cli-auth'
|
|
7
8
|
import guardPlugin from '@/bundled-plugins/guard'
|
|
9
|
+
import browserPlugin from '@/bundled-plugins/managed-browser'
|
|
8
10
|
import memoryPlugin from '@/bundled-plugins/memory'
|
|
9
11
|
import operatorPlugin from '@/bundled-plugins/operator'
|
|
10
12
|
import plannerPlugin from '@/bundled-plugins/planner'
|
|
13
|
+
import qaPlugin from '@/bundled-plugins/qa'
|
|
11
14
|
import researcherPlugin from '@/bundled-plugins/researcher'
|
|
12
15
|
import reviewerPlugin from '@/bundled-plugins/reviewer'
|
|
13
16
|
import scoutPlugin from '@/bundled-plugins/scout'
|
|
@@ -59,10 +62,13 @@ export const BUNDLED_PLUGINS: ResolvedPlugin[] = [
|
|
|
59
62
|
{ name: 'memory', version: undefined, source: '<bundled>', defined: memoryPlugin },
|
|
60
63
|
{ name: 'backup', version: undefined, source: '<bundled>', defined: backupPlugin },
|
|
61
64
|
{ name: 'agent-browser', version: undefined, source: '<bundled>', defined: agentBrowserPlugin },
|
|
65
|
+
{ name: 'managed-browser', version: undefined, source: '<bundled>', defined: browserPlugin },
|
|
62
66
|
{ name: 'doc-render', version: undefined, source: '<bundled>', defined: docRenderPlugin },
|
|
63
67
|
{ name: 'explorer', version: undefined, source: '<bundled>', defined: explorerPlugin },
|
|
68
|
+
{ name: 'browser-agent', version: undefined, source: '<bundled>', defined: browserAgentPlugin },
|
|
64
69
|
{ name: 'scout', version: undefined, source: '<bundled>', defined: scoutPlugin },
|
|
65
70
|
{ name: 'reviewer', version: undefined, source: '<bundled>', defined: reviewerPlugin },
|
|
71
|
+
{ name: 'qa', version: undefined, source: '<bundled>', defined: qaPlugin },
|
|
66
72
|
{ name: 'researcher', version: undefined, source: '<bundled>', defined: researcherPlugin },
|
|
67
73
|
{ name: 'planner', version: undefined, source: '<bundled>', defined: plannerPlugin },
|
|
68
74
|
{ name: 'operator', version: undefined, source: '<bundled>', defined: operatorPlugin },
|
package/src/run/index.ts
CHANGED
|
@@ -7,9 +7,9 @@ import { createProviderAuthReloadable } from '@/agent/auth-reloadable'
|
|
|
7
7
|
import { LiveSessionRegistry } from '@/agent/live-sessions'
|
|
8
8
|
import { LiveSubagentRegistry, newestRunningBackgroundChildStartedAt } from '@/agent/live-subagents'
|
|
9
9
|
import { requestContainerRestart } from '@/agent/restart'
|
|
10
|
-
import { consumeRestartHandoff } from '@/agent/restart-handoff'
|
|
11
10
|
import { sessionMetaPayload } from '@/agent/session-meta'
|
|
12
11
|
import type { SessionOrigin } from '@/agent/session-origin'
|
|
12
|
+
import { createSubagentSessionManager } from '@/agent/subagent-session'
|
|
13
13
|
import {
|
|
14
14
|
awaitWithSubagentTimeout,
|
|
15
15
|
createSubagentConsumer,
|
|
@@ -34,13 +34,20 @@ import {
|
|
|
34
34
|
createGithubTokenBridge,
|
|
35
35
|
createPrVerdictActivityBridge,
|
|
36
36
|
createSubagentCompletionBridge,
|
|
37
|
+
setReviewCoverageCapture,
|
|
37
38
|
setReviewObserver,
|
|
38
39
|
setReviewOutputObserver,
|
|
39
40
|
type ChannelManager,
|
|
40
41
|
type PrVerdictActivityBridge,
|
|
41
42
|
type SubagentCompletionBridge,
|
|
42
43
|
} from '@/channels'
|
|
44
|
+
import { LegacyBackgroundHandoffReader } from '@/channels/background-handoff'
|
|
45
|
+
import { BackgroundObligationStore } from '@/channels/background-obligations'
|
|
46
|
+
import { InboundJournal } from '@/channels/inbound-journal'
|
|
47
|
+
import { RecoveryDispatcher } from '@/channels/recovery-dispatcher'
|
|
48
|
+
import { RecoveryOutbox } from '@/channels/recovery-outbox'
|
|
43
49
|
import { createTunnelBridge, type TunnelBridge } from '@/channels/tunnel-bridge'
|
|
50
|
+
import { retainCodingAgentService } from '@/coding-agent'
|
|
44
51
|
import { createConfigReloadable, getConfig, loadConfigBundleSync, reloadConfig, withDefaultPlugins } from '@/config'
|
|
45
52
|
import {
|
|
46
53
|
type CountStore,
|
|
@@ -66,13 +73,7 @@ import type { CronHandlerContext } from '@/plugin/types'
|
|
|
66
73
|
import { createContainerBroker, publishForwardResult, subscribeForwardRequest } from '@/portbroker'
|
|
67
74
|
import { formatChannelReloadSummary, ReloadRegistry, type ReloadAllResult, type ReloadContext } from '@/reload'
|
|
68
75
|
import { createClaimController } from '@/role-claim'
|
|
69
|
-
import {
|
|
70
|
-
exportClaudeCredentialsFileForAgent,
|
|
71
|
-
exportCodexAuthFileForAgent,
|
|
72
|
-
exportGithubCliStoreForAgent,
|
|
73
|
-
hydrateChannelEnvFromSecrets,
|
|
74
|
-
refreshProviderOAuthForAgent,
|
|
75
|
-
} from '@/secrets'
|
|
76
|
+
import { exportGithubCliStoreForAgent, hydrateChannelEnvFromSecrets, refreshProviderOAuthForAgent } from '@/secrets'
|
|
76
77
|
import { createServer, type Server } from '@/server'
|
|
77
78
|
import {
|
|
78
79
|
createCommandRunner,
|
|
@@ -86,6 +87,7 @@ import { createStream, type Stream } from '@/stream'
|
|
|
86
87
|
import { createTui as createTuiDefault, type TuiOptions } from '@/tui'
|
|
87
88
|
import { createTunnelManager, type TunnelManager, type TunnelManagerOptions } from '@/tunnels'
|
|
88
89
|
|
|
90
|
+
import { bootChannelRestartGreeting, bootBackgroundObligations } from './background-handoff-boot'
|
|
89
91
|
import { BUNDLED_PLUGINS } from './bundled-plugins'
|
|
90
92
|
import { buildChannelSessionFactory } from './channel-session-factory'
|
|
91
93
|
import { installFatalGuard } from './fatal-guard'
|
|
@@ -128,10 +130,7 @@ export type StartAgentOptions = {
|
|
|
128
130
|
// over the real env + <cwd>/secrets.json. Injectable so tests can supply a
|
|
129
131
|
// fake secrets provider without touching process.env.
|
|
130
132
|
caps?: RuntimeCapabilities
|
|
131
|
-
//
|
|
132
|
-
// observe secrets only after the awaited provider-OAuth refresh settles.
|
|
133
|
-
exportCodexAuthFile?: typeof exportCodexAuthFileForAgent
|
|
134
|
-
exportClaudeCredentialsFile?: typeof exportClaudeCredentialsFileForAgent
|
|
133
|
+
// The GitHub CLI exporter observes secrets only after the boot refresh settles.
|
|
135
134
|
exportGithubCliStore?: typeof exportGithubCliStoreForAgent
|
|
136
135
|
// Boot-time proactive provider-OAuth refresh. Injectable so a test can supply
|
|
137
136
|
// a refresh that holds the real secrets lock on a gate, proving the boot
|
|
@@ -200,8 +199,6 @@ async function startAgentRuntime(
|
|
|
200
199
|
createChannelManager: createChannelManagerFor = createChannelManager,
|
|
201
200
|
createTunnelManager: createTunnelManagerFor = createTunnelManager,
|
|
202
201
|
caps = createRuntimeCapabilities(process.env, join(cwd, 'secrets.json')),
|
|
203
|
-
exportCodexAuthFile = exportCodexAuthFileForAgent,
|
|
204
|
-
exportClaudeCredentialsFile = exportClaudeCredentialsFileForAgent,
|
|
205
202
|
exportGithubCliStore = exportGithubCliStoreForAgent,
|
|
206
203
|
refreshProviderOAuth = refreshProviderOAuthForAgent,
|
|
207
204
|
startResourceSampler: startResourceSamplerFor = startResourceSampler,
|
|
@@ -321,6 +318,7 @@ async function startAgentRuntime(
|
|
|
321
318
|
resolveGithubTokenForRepo: githubTokenBridge.resolveTokenForRepo,
|
|
322
319
|
hasGithubAppTokenResolver: githubTokenBridge.hasAppTokenResolver,
|
|
323
320
|
getGithubAppSelfLogin: githubTokenBridge.getAppSelfLogin,
|
|
321
|
+
resolveGithubPatForRepo: githubTokenBridge.resolvePatForRepo,
|
|
324
322
|
...(cwdConfig.roles !== undefined ? { roles: cwdConfig.roles } : {}),
|
|
325
323
|
})
|
|
326
324
|
// Emit the container's fixed resource limits BEFORE vector startup. The
|
|
@@ -408,11 +406,11 @@ async function startAgentRuntime(
|
|
|
408
406
|
// log. Channel-adapter OAuth already has host-side renewal crons; this is the
|
|
409
407
|
// provider-OAuth equivalent.
|
|
410
408
|
//
|
|
411
|
-
// MUST be awaited, and MUST run before the
|
|
409
|
+
// MUST be awaited, and MUST run before the GitHub CLI store exporter below
|
|
412
410
|
// and the first session-producing consumer (subagentConsumer.start /
|
|
413
411
|
// cronConsumer.start / channelManager.start / the websocket server). The
|
|
414
412
|
// refresh holds SecretsBackend's file lock across its network request
|
|
415
|
-
// (`CredentialStore.modify`), while the synchronous readers the
|
|
413
|
+
// (`CredentialStore.modify`), while the synchronous readers the exporter and
|
|
416
414
|
// channel hydration use give up after ~200ms and throw ELOCKED.
|
|
417
415
|
// Fire-and-forget here would let a slow refresh still own the lock when an
|
|
418
416
|
// exporter or consumer reads secrets — worse than the lazy path. Awaiting
|
|
@@ -424,33 +422,9 @@ async function startAgentRuntime(
|
|
|
424
422
|
log: (message) => console.warn(message),
|
|
425
423
|
})
|
|
426
424
|
|
|
427
|
-
//
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
// after the awaited boot refresh so the fresh ephemeral HOME receives the
|
|
431
|
-
// refreshed token, never the stale pre-refresh value. The exporter is
|
|
432
|
-
// failure-tolerant by design: any error (gate miss, fs error, corrupt file)
|
|
433
|
-
// returns a non-fatal result and the agent boot continues. See
|
|
434
|
-
// src/secrets/export-codex-auth-file.ts for the newer-wins compare that
|
|
435
|
-
// prevents clobbering Codex CLI's in-place token refreshes.
|
|
436
|
-
exportCodexAuthFile({
|
|
437
|
-
agentDir: cwd,
|
|
438
|
-
codexCliEnabled: cwdConfig.docker.file.codexCli,
|
|
439
|
-
log: (message) => console.warn(message),
|
|
440
|
-
})
|
|
441
|
-
|
|
442
|
-
// Same shape as the codex exporter above, gated on `docker.file.claudeCode`
|
|
443
|
-
// and `secrets.json#providers.anthropic`. It likewise runs after the boot
|
|
444
|
-
// refresh, then writes ~/.claude/.credentials.json so the Claude Code CLI in
|
|
445
|
-
// the container can run without the user pasting a CLAUDE_CODE_OAUTH_TOKEN.
|
|
446
|
-
// See src/secrets/export-claude-credentials-file.ts for the newer-wins compare
|
|
447
|
-
// that prevents clobbering Claude Code's in-place token refreshes, and the
|
|
448
|
-
// read-merge-write that preserves any mcpOAuth state in the file.
|
|
449
|
-
exportClaudeCredentialsFile({
|
|
450
|
-
agentDir: cwd,
|
|
451
|
-
claudeCodeEnabled: cwdConfig.docker.file.claudeCode,
|
|
452
|
-
log: (message) => console.warn(message),
|
|
453
|
-
})
|
|
425
|
+
// Coding credentials stay in the runtime; neither CLI receives an exported profile.
|
|
426
|
+
const stopCodingAgents = retainCodingAgentService(cwd)
|
|
427
|
+
registerBootCleanup(stopCodingAgents)
|
|
454
428
|
|
|
455
429
|
const githubCliExport = exportGithubCliStore({
|
|
456
430
|
agentDir: cwd,
|
|
@@ -458,7 +432,7 @@ async function startAgentRuntime(
|
|
|
458
432
|
})
|
|
459
433
|
if (githubCliExport.action === 'failed') {
|
|
460
434
|
console.warn(
|
|
461
|
-
'[run] trusted GitHub CLI store unavailable;
|
|
435
|
+
'[run] trusted GitHub CLI store unavailable; brokered `gh` commands will not authenticate. ' +
|
|
462
436
|
'On the host, run `gh auth login --hostname github.com`, then run a real `typeclaw restart`.',
|
|
463
437
|
)
|
|
464
438
|
}
|
|
@@ -478,15 +452,46 @@ async function startAgentRuntime(
|
|
|
478
452
|
},
|
|
479
453
|
})
|
|
480
454
|
|
|
455
|
+
const legacyBackgroundHandoffs = new LegacyBackgroundHandoffReader(cwd, {
|
|
456
|
+
onError: (error) => console.warn(`[run] legacy background upgrade failed: ${error}`),
|
|
457
|
+
})
|
|
458
|
+
const backgroundObligations = new BackgroundObligationStore(cwd, {
|
|
459
|
+
epoch: legacyBackgroundHandoffs.processEpoch,
|
|
460
|
+
onError: (error) => console.warn(`[run] background continuity failed: ${error}`),
|
|
461
|
+
})
|
|
481
462
|
const liveSubagentRegistry = new LiveSubagentRegistry()
|
|
482
463
|
const subagentCoalescer = new SubagentCoalescer()
|
|
483
464
|
const liveSessionRegistry = new LiveSessionRegistry()
|
|
484
465
|
|
|
466
|
+
const recoveryOutbox = new RecoveryOutbox(cwd, {
|
|
467
|
+
epoch: backgroundObligations.epoch,
|
|
468
|
+
onError: (error) => console.warn(`[run] recovery outbox failed: ${error}`),
|
|
469
|
+
})
|
|
470
|
+
const inboundJournal = new InboundJournal(cwd, {
|
|
471
|
+
backgroundObligations,
|
|
472
|
+
onError: (error) => console.warn(`[run] inbound continuity recovery blocked: ${error}`),
|
|
473
|
+
})
|
|
474
|
+
registerBootCleanup(() => inboundJournal.close())
|
|
475
|
+
let recoveryDispatcher: RecoveryDispatcher | undefined
|
|
485
476
|
const channelManager = createChannelManagerFor({
|
|
486
477
|
agentDir: cwd,
|
|
478
|
+
backgroundObligations,
|
|
479
|
+
inboundJournal,
|
|
480
|
+
recoveryOutbox,
|
|
487
481
|
secretsProvider: caps.secrets,
|
|
488
482
|
channelsConfigRef: () => getConfig().channels,
|
|
489
483
|
aliasesRef: () => getConfig().alias,
|
|
484
|
+
onRecoveryReady: () => {
|
|
485
|
+
void recoveryDispatcher?.wake().catch((error) => console.warn(`[run] recovery wake failed: ${error}`))
|
|
486
|
+
},
|
|
487
|
+
// Resolve the live bus at delivery time so plugin reloads take effect
|
|
488
|
+
// without rebuilding adapters, and no subscribers means no snapshot work.
|
|
489
|
+
slackBotMessageObserver: {
|
|
490
|
+
active: () => pluginRuntime.get().hooks.count('channel.message.observed') > 0,
|
|
491
|
+
observe: (event) => pluginRuntime.get().hooks.runChannelMessageObserved(event),
|
|
492
|
+
},
|
|
493
|
+
outboundReviewer: (event) => pluginRuntime.get().hooks.runChannelOutboundBefore(event),
|
|
494
|
+
outboundReviewerActive: () => pluginRuntime.get().hooks.count('channel.outbound.before') > 0,
|
|
490
495
|
tunnelUrlForChannel: (name) => resolveTunnelUrlForChannel(name, tunnelManager),
|
|
491
496
|
tunnelConfiguredForChannel: (name) => isTunnelConfiguredForChannel(name),
|
|
492
497
|
createSessionForChannel: buildChannelSessionFactory({
|
|
@@ -514,11 +519,6 @@ async function startAgentRuntime(
|
|
|
514
519
|
stream,
|
|
515
520
|
newestRunningChildSubagentStartedAt: (sessionId) =>
|
|
516
521
|
newestRunningBackgroundChildStartedAt(liveSubagentRegistry.list({ parentSessionId: sessionId })),
|
|
517
|
-
listRunningBackgroundSubagentNames: (sessionId) =>
|
|
518
|
-
liveSubagentRegistry
|
|
519
|
-
.list({ parentSessionId: sessionId })
|
|
520
|
-
.filter((child) => child.status === 'running' && child.background === true)
|
|
521
|
-
.map((child) => child.subagentName),
|
|
522
522
|
cancelRunningSubagentsByWorkKey: (workKey, reason) => liveSubagentRegistry.cancelRunningByWorkKey(workKey, reason),
|
|
523
523
|
onReload: async () => {
|
|
524
524
|
const { results } = await reloadAllNonDestructive()
|
|
@@ -567,7 +567,11 @@ async function startAgentRuntime(
|
|
|
567
567
|
const snap = pluginRuntime.get()
|
|
568
568
|
const entry = snap.pluginSubagentByShim.get(subagent)
|
|
569
569
|
if (entry) {
|
|
570
|
-
const sessionManager =
|
|
570
|
+
const sessionManager = createSubagentSessionManager(
|
|
571
|
+
cwd,
|
|
572
|
+
sessionFactory.sessionDir(),
|
|
573
|
+
entry.pluginSubagent.ephemeral,
|
|
574
|
+
)
|
|
571
575
|
const sessionId = sessionManager.getSessionId()
|
|
572
576
|
const origin: SessionOrigin = {
|
|
573
577
|
kind: 'subagent' as const,
|
|
@@ -615,6 +619,9 @@ async function startAgentRuntime(
|
|
|
615
619
|
...(resolveSubagentProfile(entry.pluginSubagent, subagentOptions) !== undefined
|
|
616
620
|
? { profile: resolveSubagentProfile(entry.pluginSubagent, subagentOptions) }
|
|
617
621
|
: {}),
|
|
622
|
+
...(entry.pluginSubagent.thinkingLevel !== undefined
|
|
623
|
+
? { thinkingLevel: entry.pluginSubagent.thinkingLevel }
|
|
624
|
+
: {}),
|
|
618
625
|
...(entry.pluginSubagent.toolResultBudget !== undefined
|
|
619
626
|
? { toolResultBudget: entry.pluginSubagent.toolResultBudget }
|
|
620
627
|
: {}),
|
|
@@ -889,9 +896,13 @@ async function startAgentRuntime(
|
|
|
889
896
|
// empty-turn fallback is suppressed: the review IS the turn's output, but it goes
|
|
890
897
|
// through the GitHub API, not the channel send path. In-process router call — no
|
|
891
898
|
// stream fan-out, since this is the recording session's own bookkeeping.
|
|
892
|
-
|
|
893
|
-
channelManager.router.
|
|
894
|
-
|
|
899
|
+
setReviewCoverageCapture(async (sessionId) => ({
|
|
900
|
+
expectedAccountIdentity: await channelManager.router.captureTurnAccountIdentity?.(sessionId, 'github'),
|
|
901
|
+
inboundCoverage: (await channelManager.router.captureInboundResultCoverage?.(sessionId)) ?? [],
|
|
902
|
+
backgroundCoverage: (await channelManager.router.captureBackgroundResultCoverage?.(sessionId)) ?? [],
|
|
903
|
+
}))
|
|
904
|
+
registerBootCleanup(() => setReviewCoverageCapture(null))
|
|
905
|
+
setReviewOutputObserver((output) => channelManager.router.noteGithubReviewOutput(output).then(() => {}))
|
|
895
906
|
registerBootCleanup(() => setReviewOutputObserver(null))
|
|
896
907
|
|
|
897
908
|
// Registered before channels so its cache clear lands before any channel
|
|
@@ -907,36 +918,38 @@ async function startAgentRuntime(
|
|
|
907
918
|
|
|
908
919
|
reloadRegistry.register(createChannelsReloadable({ manager: channelManager }))
|
|
909
920
|
|
|
910
|
-
// Two-phase channel restart-resume around adapter startup, to close the race
|
|
911
|
-
// where an adapter starts receiving before the resume claims the handoff:
|
|
912
|
-
// 1. Claim the channel handoff and RESERVE the originating key BEFORE
|
|
913
|
-
// channelManager.start(). The reservation installs a per-key gate, so an
|
|
914
|
-
// inbound that arrives the instant an adapter connects coalesces onto the
|
|
915
|
-
// resume instead of stale-rolling the mapping or creating a rival session.
|
|
916
|
-
// 2. start() the adapters (registers outbound callbacks the wake reply needs).
|
|
917
|
-
// 3. resume() the reservation: reopen the exact session and enqueue the wake
|
|
918
|
-
// — skipped automatically if a real inbound already coalesced in (2)→(3).
|
|
919
|
-
// Claims ONLY channel handoffs; tui handoffs are left on disk (peek-then-delete
|
|
920
|
-
// never removes an unclaimed handoff) for the websocket open handler to claim.
|
|
921
|
-
// Best-effort throughout: any failure leaves the todo to resume on the next inbound.
|
|
922
|
-
let restartReservation: ReturnType<typeof channelManager.router.reserveRestartHandoff> = null
|
|
923
|
-
try {
|
|
924
|
-
const handoff = await consumeRestartHandoff(cwd, { accept: (h) => h.origin.kind === 'channel' })
|
|
925
|
-
if (handoff !== null) restartReservation = channelManager.router.reserveRestartHandoff(handoff)
|
|
926
|
-
} catch (err) {
|
|
927
|
-
console.warn(`[run] channel restart-resume reserve failed: ${err instanceof Error ? err.message : err}`)
|
|
928
|
-
}
|
|
929
|
-
|
|
930
921
|
registerBootCleanup(() => channelManager.stop())
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
922
|
+
recoveryDispatcher = new RecoveryDispatcher(recoveryOutbox, channelManager.router, {
|
|
923
|
+
onError: (error) => console.warn(`[run] recovery dispatch failed: ${error}`),
|
|
924
|
+
backgroundObligations,
|
|
925
|
+
inboundJournal,
|
|
926
|
+
})
|
|
927
|
+
registerBootCleanup(() => recoveryDispatcher?.stop())
|
|
928
|
+
try {
|
|
929
|
+
// Attempted before adapters start or the dispatcher wakes; failure does not block either.
|
|
930
|
+
await bootBackgroundObligations({
|
|
931
|
+
inboundJournal,
|
|
932
|
+
obligations: backgroundObligations,
|
|
933
|
+
outbox: recoveryOutbox,
|
|
934
|
+
inventory: legacyBackgroundHandoffs,
|
|
935
|
+
})
|
|
936
|
+
} catch (error) {
|
|
937
|
+
// Keep the operator/adapter surface and verified inventory-only notices alive;
|
|
938
|
+
// the helper has already frozen dependent background progress.
|
|
939
|
+
console.warn(`[run] continuity blocked pending operator repair: ${error}`)
|
|
939
940
|
}
|
|
941
|
+
// Growth-driven compaction runs on the journal's own writer queue once boot recovery has been
|
|
942
|
+
// attempted. A frozen journal is never rewritten; `inboundJournal.close()` (shutdown or
|
|
943
|
+
// boot-failure cleanup) stops maintenance and waits for a compaction already in progress.
|
|
944
|
+
inboundJournal.startMaintenance()
|
|
945
|
+
await bootChannelRestartGreeting({
|
|
946
|
+
agentDir: cwd,
|
|
947
|
+
router: channelManager.router,
|
|
948
|
+
configured: (key) => getConfig().channels[key.adapter] !== undefined,
|
|
949
|
+
startAdapters: () => channelManager.start(),
|
|
950
|
+
onError: (error) => console.warn(`[run] channel restart-resume failed: ${error}`),
|
|
951
|
+
})
|
|
952
|
+
await recoveryDispatcher.wake()
|
|
940
953
|
|
|
941
954
|
// Captured separately from setSpawnSubagent so both the plugin context and
|
|
942
955
|
// the plugin-command runner can dispatch through the same path. The setter
|
|
@@ -1107,10 +1120,18 @@ async function startAgentRuntime(
|
|
|
1107
1120
|
subagentCompletionBridge.stop()
|
|
1108
1121
|
prVerdictActivityBridge.stop()
|
|
1109
1122
|
setReviewObserver(null)
|
|
1123
|
+
setReviewCoverageCapture(null)
|
|
1124
|
+
setReviewOutputObserver(null)
|
|
1125
|
+
await stopCodingAgents()
|
|
1110
1126
|
await tunnelManager.stop()
|
|
1127
|
+
await recoveryDispatcher?.stop()
|
|
1111
1128
|
await channelManager.stop()
|
|
1112
1129
|
await mcpManager?.closeAll()
|
|
1113
1130
|
} finally {
|
|
1131
|
+
await inboundJournal.close().catch((error) => console.warn(`[run] inbound continuity close failed: ${error}`))
|
|
1132
|
+
await backgroundObligations
|
|
1133
|
+
.flush()
|
|
1134
|
+
.catch((error) => console.warn(`[run] background continuity flush failed: ${error}`))
|
|
1114
1135
|
await pluginsLoaded.disposePlugins()
|
|
1115
1136
|
disposeProcessGlobals()
|
|
1116
1137
|
}
|
|
@@ -1133,10 +1154,6 @@ async function startAgentRuntime(
|
|
|
1133
1154
|
forceExit.unref()
|
|
1134
1155
|
void (async () => {
|
|
1135
1156
|
if (containerName !== undefined) {
|
|
1136
|
-
// Persist the interrupted-subagent handoff BEFORE markRestartAbortForAllLive
|
|
1137
|
-
// aborts the sessions and stop() tears them down — both read the same live
|
|
1138
|
-
// set this write depends on.
|
|
1139
|
-
await channelManager.router.writeInterruptedSubagentHandoff().catch(() => undefined)
|
|
1140
1157
|
await markRestartAbortPendingForOrigin(cwd, { kind: 'tui', sessionId: 'tui' }).catch(() => undefined)
|
|
1141
1158
|
await channelManager.router.markRestartAbortForAllLive().catch(() => undefined)
|
|
1142
1159
|
}
|
|
@@ -1350,6 +1367,7 @@ type PluginOnlySubagentKeys = Exclude<keyof import('@/plugin').Subagent<any>, ke
|
|
|
1350
1367
|
const PLUGIN_ONLY_KEYS_DROPPED_BY_SHIM = {
|
|
1351
1368
|
tools: true,
|
|
1352
1369
|
customTools: true,
|
|
1370
|
+
ephemeral: true,
|
|
1353
1371
|
} satisfies Record<PluginOnlySubagentKeys, true>
|
|
1354
1372
|
// Reference the table so it's not dead code. The value is a runtime no-op;
|
|
1355
1373
|
// the load-bearing work is the `satisfies` clause above which forces
|
|
@@ -1357,17 +1375,9 @@ const PLUGIN_ONLY_KEYS_DROPPED_BY_SHIM = {
|
|
|
1357
1375
|
void PLUGIN_ONLY_KEYS_DROPPED_BY_SHIM
|
|
1358
1376
|
|
|
1359
1377
|
function pluginSubagentShim(subagent: import('@/plugin').Subagent<any>): InternalSubagent<any> {
|
|
1360
|
-
//
|
|
1361
|
-
//
|
|
1362
|
-
//
|
|
1363
|
-
|
|
1364
|
-
// reference. Every other plugin-side field lives on `SubagentShared` and is structurally
|
|
1365
|
-
// assignable to the internal `Subagent`, so a rest-spread carries them
|
|
1366
|
-
// verbatim — including `visibility` and `requiresSpecificPermission`,
|
|
1367
|
-
// whose silent drop in the previous shim made every plugin-contributed
|
|
1368
|
-
// public subagent (scout, explorer, operator) invisible to the
|
|
1369
|
-
// `spawn_subagent` tool. The list of keys removed here is enforced
|
|
1370
|
-
// exhaustive at compile time by `PLUGIN_ONLY_KEYS_DROPPED_BY_SHIM` above.
|
|
1371
|
-
const { tools: _tools, customTools: _customTools, ...shared } = subagent
|
|
1378
|
+
// Plugin-only tools and transcript persistence are resolved by the native
|
|
1379
|
+
// factory through pluginSubagentByShim, which retains the original declaration.
|
|
1380
|
+
// The internal registry shim carries only the shared scheduling/role contract.
|
|
1381
|
+
const { tools: _tools, customTools: _customTools, ephemeral: _ephemeral, ...shared } = subagent
|
|
1372
1382
|
return shared
|
|
1373
1383
|
}
|