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
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
import { z } from 'zod'
|
|
2
|
+
|
|
3
|
+
const eventSchema = z.object({ type: z.string().min(1) }).passthrough()
|
|
4
|
+
const messageSchema = z.object({ role: z.string() }).passthrough()
|
|
5
|
+
const assistantSchema = z.object({
|
|
6
|
+
role: z.literal('assistant'),
|
|
7
|
+
content: z.array(z.object({ type: z.string(), text: z.string().optional() }).passthrough()),
|
|
8
|
+
stopReason: z.enum(['stop', 'length', 'toolUse', 'error', 'aborted']),
|
|
9
|
+
})
|
|
10
|
+
const sessionSchema = z.object({
|
|
11
|
+
type: z.literal('session'),
|
|
12
|
+
version: z.literal(3),
|
|
13
|
+
id: z.string().uuid(),
|
|
14
|
+
cwd: z.string(),
|
|
15
|
+
})
|
|
16
|
+
|
|
17
|
+
// OmO print mode emits one `message_update` record per streamed token, each
|
|
18
|
+
// repeating a full usage object (~100x amplification over the model output).
|
|
19
|
+
// The parser ignores them, so they are dropped before the output cap and the
|
|
20
|
+
// JSONL artifact; a single long tool call otherwise trips the cap mid-task.
|
|
21
|
+
export class OmoDeltaFilter {
|
|
22
|
+
private pending = ''
|
|
23
|
+
|
|
24
|
+
push(text: string): string {
|
|
25
|
+
this.pending += text
|
|
26
|
+
const end = this.pending.lastIndexOf('\n')
|
|
27
|
+
if (end === -1) {
|
|
28
|
+
if (this.pending.length > 4 * 1024 * 1024) throw new Error('OmO event exceeds the 4 MiB event limit.')
|
|
29
|
+
return ''
|
|
30
|
+
}
|
|
31
|
+
const lines = this.pending.slice(0, end + 1)
|
|
32
|
+
this.pending = this.pending.slice(end + 1)
|
|
33
|
+
return lines
|
|
34
|
+
.split('\n')
|
|
35
|
+
.slice(0, -1)
|
|
36
|
+
.filter((line) => !isMessageUpdate(line))
|
|
37
|
+
.map((line) => `${line}\n`)
|
|
38
|
+
.join('')
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
flush(): string {
|
|
42
|
+
const rest = this.pending
|
|
43
|
+
this.pending = ''
|
|
44
|
+
return rest
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
function isMessageUpdate(line: string): boolean {
|
|
49
|
+
if (!line.startsWith('{"type":"message_update"')) return false
|
|
50
|
+
try {
|
|
51
|
+
return (JSON.parse(line) as { type?: unknown }).type === 'message_update'
|
|
52
|
+
} catch {
|
|
53
|
+
return false
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
export class OmoStreamParser {
|
|
58
|
+
sessionId: string | undefined
|
|
59
|
+
finalMessage = ''
|
|
60
|
+
terminal = false
|
|
61
|
+
failed = false
|
|
62
|
+
permissionDenied = false
|
|
63
|
+
malformed = false
|
|
64
|
+
private pending = ''
|
|
65
|
+
|
|
66
|
+
constructor(private readonly expected: { readonly sessionId: string; readonly cwd: string }) {}
|
|
67
|
+
|
|
68
|
+
push(text: string): void {
|
|
69
|
+
this.pending += text
|
|
70
|
+
let newline: number
|
|
71
|
+
while ((newline = this.pending.indexOf('\n')) !== -1) {
|
|
72
|
+
if (newline > 4 * 1024 * 1024) throw new Error('OmO event exceeds the 4 MiB event limit.')
|
|
73
|
+
const line = this.pending.slice(0, newline)
|
|
74
|
+
this.pending = this.pending.slice(newline + 1)
|
|
75
|
+
this.line(line)
|
|
76
|
+
}
|
|
77
|
+
if (this.pending.length > 4 * 1024 * 1024) throw new Error('OmO event exceeds the 4 MiB event limit.')
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
finish(): void {
|
|
81
|
+
// The pinned print-mode protocol always flushes newline-delimited records.
|
|
82
|
+
if (this.pending.trim()) this.malformed = true
|
|
83
|
+
this.pending = ''
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
private line(line: string): void {
|
|
87
|
+
if (!line.trim()) return
|
|
88
|
+
try {
|
|
89
|
+
const event = eventSchema.parse(JSON.parse(line))
|
|
90
|
+
switch (event.type) {
|
|
91
|
+
case 'session': {
|
|
92
|
+
const session = sessionSchema.parse(event)
|
|
93
|
+
if (session.id !== this.expected.sessionId || session.cwd !== this.expected.cwd || this.sessionId) {
|
|
94
|
+
this.malformed = true
|
|
95
|
+
} else this.sessionId = session.id
|
|
96
|
+
break
|
|
97
|
+
}
|
|
98
|
+
case 'agent_start':
|
|
99
|
+
this.terminal = false
|
|
100
|
+
this.failed = false
|
|
101
|
+
this.finalMessage = ''
|
|
102
|
+
break
|
|
103
|
+
case 'message_end': {
|
|
104
|
+
const { message } = z.object({ message: messageSchema }).parse(event)
|
|
105
|
+
if (message.role === 'assistant') assistantSchema.parse(message)
|
|
106
|
+
break
|
|
107
|
+
}
|
|
108
|
+
case 'tool_execution_end':
|
|
109
|
+
// Failed tools may be recovered by the agent. Keep their structured
|
|
110
|
+
// events in the JSONL artifact, not as a terminal English heuristic.
|
|
111
|
+
z.object({ toolCallId: z.string(), toolName: z.string(), isError: z.boolean(), result: z.unknown() }).parse(
|
|
112
|
+
event,
|
|
113
|
+
)
|
|
114
|
+
break
|
|
115
|
+
case 'agent_end': {
|
|
116
|
+
const end = z.object({ messages: z.array(messageSchema), willRetry: z.boolean().optional() }).parse(event)
|
|
117
|
+
const assistants = end.messages
|
|
118
|
+
.filter((message) => message.role === 'assistant')
|
|
119
|
+
.map((message) => assistantSchema.parse(message))
|
|
120
|
+
const final = assistants.at(-1)
|
|
121
|
+
this.terminal = false
|
|
122
|
+
this.failed = false
|
|
123
|
+
this.finalMessage = ''
|
|
124
|
+
if (end.willRetry || !final) break
|
|
125
|
+
this.finalMessage = final.content
|
|
126
|
+
.filter((block) => block.type === 'text')
|
|
127
|
+
.map((block) => z.string().parse(block.text))
|
|
128
|
+
.join('\n')
|
|
129
|
+
this.failed = final.stopReason === 'error' || final.stopReason === 'aborted'
|
|
130
|
+
this.terminal = final.stopReason === 'stop' || this.failed
|
|
131
|
+
break
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
} catch {
|
|
135
|
+
this.malformed = true
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
}
|
|
@@ -0,0 +1,192 @@
|
|
|
1
|
+
import { join } from 'node:path'
|
|
2
|
+
|
|
3
|
+
import { z } from 'zod'
|
|
4
|
+
|
|
5
|
+
import type { CodingAgentProvider } from '@/secrets/coding-agent-auth'
|
|
6
|
+
|
|
7
|
+
import { CLAUDE_CODE_VERSION } from './claude'
|
|
8
|
+
|
|
9
|
+
export const OMO_CLI_VERSION = '5.1.19'
|
|
10
|
+
|
|
11
|
+
// Only metadata understood by the pinned Senpi transport crosses this boundary.
|
|
12
|
+
// Never copy provider URLs, headers, keys, or fallback chains from model records.
|
|
13
|
+
export const omoModelSchema = z.object({
|
|
14
|
+
id: z.string().min(1),
|
|
15
|
+
name: z.string(),
|
|
16
|
+
reasoning: z.boolean(),
|
|
17
|
+
input: z.array(z.enum(['text', 'image'])),
|
|
18
|
+
contextWindow: z.number().positive(),
|
|
19
|
+
maxTokens: z.number().positive(),
|
|
20
|
+
cost: z.object({
|
|
21
|
+
input: z.number(),
|
|
22
|
+
output: z.number(),
|
|
23
|
+
cacheRead: z.number(),
|
|
24
|
+
cacheWrite: z.number(),
|
|
25
|
+
}),
|
|
26
|
+
thinkingLevelMap: z.record(z.string(), z.union([z.string(), z.null()])).optional(),
|
|
27
|
+
compat: z
|
|
28
|
+
.object({
|
|
29
|
+
supportsEagerToolInputStreaming: z.boolean().optional(),
|
|
30
|
+
supportsLongCacheRetention: z.boolean().optional(),
|
|
31
|
+
sendSessionAffinityHeaders: z.boolean().optional(),
|
|
32
|
+
supportsCacheControlOnTools: z.boolean().optional(),
|
|
33
|
+
supportsDisabledThinking: z.boolean().optional(),
|
|
34
|
+
supportsTemperature: z.boolean().optional(),
|
|
35
|
+
supportsToolChoice: z.boolean().optional(),
|
|
36
|
+
supportsForcedToolChoice: z.boolean().optional(),
|
|
37
|
+
forceAdaptiveThinking: z.boolean().optional(),
|
|
38
|
+
allowEmptySignature: z.boolean().optional(),
|
|
39
|
+
supportsToolReferences: z.boolean().optional(),
|
|
40
|
+
supportsDeveloperRole: z.boolean().optional(),
|
|
41
|
+
})
|
|
42
|
+
.optional(),
|
|
43
|
+
})
|
|
44
|
+
export type OmoModel = z.infer<typeof omoModelSchema>
|
|
45
|
+
|
|
46
|
+
const DISABLED_COMPONENTS = [
|
|
47
|
+
'memory',
|
|
48
|
+
'telemetry',
|
|
49
|
+
'builtin-mcps',
|
|
50
|
+
'onboarding',
|
|
51
|
+
'lsp',
|
|
52
|
+
'ast-grep',
|
|
53
|
+
'browser-bridge',
|
|
54
|
+
'computer-use',
|
|
55
|
+
'x-search',
|
|
56
|
+
'claude-code',
|
|
57
|
+
'thread',
|
|
58
|
+
'gateway',
|
|
59
|
+
'config-watch',
|
|
60
|
+
] as const
|
|
61
|
+
|
|
62
|
+
export function omoArguments(options: {
|
|
63
|
+
readonly model: string
|
|
64
|
+
readonly sessionId: string
|
|
65
|
+
readonly configDir: string
|
|
66
|
+
}): string[] {
|
|
67
|
+
return [
|
|
68
|
+
'omo',
|
|
69
|
+
'-p',
|
|
70
|
+
'--mode',
|
|
71
|
+
'json',
|
|
72
|
+
'--model',
|
|
73
|
+
`typeclaw/${options.model}`,
|
|
74
|
+
'--session-dir',
|
|
75
|
+
join(options.configDir, 'sessions'),
|
|
76
|
+
'--session-id',
|
|
77
|
+
options.sessionId,
|
|
78
|
+
'--no-approve',
|
|
79
|
+
'--offline',
|
|
80
|
+
'--permission-preset',
|
|
81
|
+
'full-access',
|
|
82
|
+
'--no-ask-user',
|
|
83
|
+
'--no-model-fallback',
|
|
84
|
+
'--no-recommended-models',
|
|
85
|
+
...DISABLED_COMPONENTS.map((name) => `--omo-senpi-${name}-disabled`),
|
|
86
|
+
]
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
export function omoEnvironment(configDir: string, capability: string): Record<string, string> {
|
|
90
|
+
return {
|
|
91
|
+
HOME: join(configDir, 'home'),
|
|
92
|
+
OMO_CODING_AGENT_DIR: join(configDir, 'agent'),
|
|
93
|
+
TMPDIR: join(configDir, 'tmp'),
|
|
94
|
+
BUN_TMPDIR: join(configDir, 'tmp'),
|
|
95
|
+
BUN_INSTALL: join(configDir, 'home', '.bun'),
|
|
96
|
+
XDG_CONFIG_HOME: join(configDir, 'config'),
|
|
97
|
+
XDG_CACHE_HOME: join(configDir, 'cache'),
|
|
98
|
+
XDG_DATA_HOME: join(configDir, 'data'),
|
|
99
|
+
XDG_STATE_HOME: join(configDir, 'state'),
|
|
100
|
+
TYPECLAW_CODING_AGENT_CAPABILITY: capability,
|
|
101
|
+
PI_OFFLINE: '1',
|
|
102
|
+
PI_SKIP_VERSION_CHECK: '1',
|
|
103
|
+
PI_TELEMETRY: '0',
|
|
104
|
+
DO_NOT_TRACK: '1',
|
|
105
|
+
OMO_SEND_ANONYMOUS_TELEMETRY: '0',
|
|
106
|
+
SENPI_NO_FALLBACK: '1',
|
|
107
|
+
PI_CLAUDE_CODE_VERSION: CLAUDE_CODE_VERSION,
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
export function omoConfiguration(options: {
|
|
112
|
+
readonly configDir: string
|
|
113
|
+
readonly baseUrl: string
|
|
114
|
+
readonly provider: CodingAgentProvider
|
|
115
|
+
readonly model: OmoModel
|
|
116
|
+
}) {
|
|
117
|
+
const model = `typeclaw/${options.model.id}`
|
|
118
|
+
return {
|
|
119
|
+
models: {
|
|
120
|
+
providers: {
|
|
121
|
+
typeclaw: {
|
|
122
|
+
baseUrl: options.baseUrl + (options.provider === 'openai-codex' ? '/v1' : ''),
|
|
123
|
+
api: options.provider === 'anthropic' ? 'anthropic-messages' : 'openai-codex-responses',
|
|
124
|
+
apiKey: '$TYPECLAW_CODING_AGENT_CAPABILITY',
|
|
125
|
+
authHeader: true,
|
|
126
|
+
models: [options.model],
|
|
127
|
+
},
|
|
128
|
+
},
|
|
129
|
+
},
|
|
130
|
+
settings: {
|
|
131
|
+
enableInstallTelemetry: false,
|
|
132
|
+
transport: 'sse',
|
|
133
|
+
permissionPreset: 'full-access',
|
|
134
|
+
retry: { modelFallback: false },
|
|
135
|
+
compaction: { model },
|
|
136
|
+
enabledModels: [model],
|
|
137
|
+
disabledBuiltinExtensions: [
|
|
138
|
+
'mcp',
|
|
139
|
+
'cache-keepalive',
|
|
140
|
+
'claude-sdk-oauth',
|
|
141
|
+
'cursor-cli-oauth',
|
|
142
|
+
'imagegen',
|
|
143
|
+
'openai-image-gen',
|
|
144
|
+
'anthropic-web-search',
|
|
145
|
+
'openai-web-search',
|
|
146
|
+
'look-at',
|
|
147
|
+
'video-in',
|
|
148
|
+
'btw',
|
|
149
|
+
'schedule',
|
|
150
|
+
],
|
|
151
|
+
},
|
|
152
|
+
orchestration: {
|
|
153
|
+
model_profile: model,
|
|
154
|
+
memory: { enabled: false },
|
|
155
|
+
telemetry: { enabled: false },
|
|
156
|
+
task: {
|
|
157
|
+
state_dir: join(options.configDir, 'task-state'),
|
|
158
|
+
default_execution_mode: 'in-process',
|
|
159
|
+
host_shard_prewarm: 'off',
|
|
160
|
+
default_concurrency: 3,
|
|
161
|
+
global_concurrency: 3,
|
|
162
|
+
max_depth: 1,
|
|
163
|
+
isolation: { enabled: false },
|
|
164
|
+
},
|
|
165
|
+
categories: Object.fromEntries(
|
|
166
|
+
[
|
|
167
|
+
'visual-engineering',
|
|
168
|
+
'artistry',
|
|
169
|
+
'ultrabrain',
|
|
170
|
+
'deep-low',
|
|
171
|
+
'deep-high',
|
|
172
|
+
'quick',
|
|
173
|
+
'unspecified-low',
|
|
174
|
+
'unspecified-high',
|
|
175
|
+
'architect',
|
|
176
|
+
'writing',
|
|
177
|
+
].map((name) => [name, { models: [model] }]),
|
|
178
|
+
),
|
|
179
|
+
agents: Object.fromEntries(
|
|
180
|
+
[
|
|
181
|
+
'explore',
|
|
182
|
+
'librarian',
|
|
183
|
+
'plan-consultant',
|
|
184
|
+
'plan-reviewer',
|
|
185
|
+
'omo-native-code-reviewer',
|
|
186
|
+
'omo-native-qa-executor',
|
|
187
|
+
'omo-native-gate-reviewer',
|
|
188
|
+
].map((name) => [name, { model, models: [], execution_mode: 'in-process' }]),
|
|
189
|
+
),
|
|
190
|
+
},
|
|
191
|
+
}
|
|
192
|
+
}
|
|
@@ -0,0 +1,285 @@
|
|
|
1
|
+
import { spawn } from 'node:child_process'
|
|
2
|
+
import { once } from 'node:events'
|
|
3
|
+
import { join } from 'node:path'
|
|
4
|
+
|
|
5
|
+
import { readOomEvents, toolOomNote } from '@/container/oom-events'
|
|
6
|
+
import { withToolOomPriorityArgv } from '@/container/tool-oom-priority'
|
|
7
|
+
import { prepareCodingCommand } from '@/sandbox/coding-agent'
|
|
8
|
+
import type { CodingAgentAuthResolver, CodingAgentProvider } from '@/secrets/coding-agent-auth'
|
|
9
|
+
|
|
10
|
+
import { SecretScrubber, startCodingBroker, type CodingBroker } from './broker'
|
|
11
|
+
import { ClaudeStreamParser, claudeArguments, claudeEnvironment, type CodingMode } from './claude'
|
|
12
|
+
import { CodexStreamParser, codexArguments, codexConfig, codexEnvironment } from './codex'
|
|
13
|
+
import { omoArguments, omoConfiguration, omoEnvironment, type OmoModel } from './omo'
|
|
14
|
+
import { hasOmoSession, prepareOmoDirectories } from './omo-state'
|
|
15
|
+
import { OmoDeltaFilter, OmoStreamParser } from './omo-stream'
|
|
16
|
+
import type { CodingWorkspace } from './worktree'
|
|
17
|
+
|
|
18
|
+
const OUTPUT_LIMIT_BYTES = 16 * 1024 * 1024
|
|
19
|
+
|
|
20
|
+
export type CodingRunResult = {
|
|
21
|
+
readonly state: 'completed' | 'incomplete' | 'failed' | 'cancelled'
|
|
22
|
+
readonly finalMessage: string
|
|
23
|
+
readonly sessionId?: string
|
|
24
|
+
readonly exitCode: number | null
|
|
25
|
+
readonly diagnostic: string
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export type CodingRunOptions = {
|
|
29
|
+
readonly engine?: 'claude' | 'codex' | 'omo'
|
|
30
|
+
readonly provider?: CodingAgentProvider
|
|
31
|
+
readonly modelMetadata?: OmoModel
|
|
32
|
+
readonly workspace: CodingWorkspace
|
|
33
|
+
readonly auth: CodingAgentAuthResolver
|
|
34
|
+
readonly model: string
|
|
35
|
+
readonly allowedModels: readonly string[]
|
|
36
|
+
readonly mode: CodingMode
|
|
37
|
+
readonly sessionId: string
|
|
38
|
+
readonly resume: boolean
|
|
39
|
+
readonly prompt: string
|
|
40
|
+
readonly timeoutSeconds: number
|
|
41
|
+
readonly signal?: AbortSignal
|
|
42
|
+
readonly writeArtifact: (path: string, text: string) => Promise<void>
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export async function runCodingAgent(
|
|
46
|
+
options: CodingRunOptions,
|
|
47
|
+
testDependencies?: {
|
|
48
|
+
command: (
|
|
49
|
+
argv: readonly string[],
|
|
50
|
+
env: Record<string, string>,
|
|
51
|
+
) => Promise<{ argv: string[]; env: Record<string, string> }>
|
|
52
|
+
broker?: typeof startCodingBroker
|
|
53
|
+
},
|
|
54
|
+
): Promise<CodingRunResult> {
|
|
55
|
+
const engine = options.engine ?? 'claude'
|
|
56
|
+
const deadline = Date.now() + options.timeoutSeconds * 1000
|
|
57
|
+
const timeout = new AbortController()
|
|
58
|
+
const signal = options.signal ? AbortSignal.any([options.signal, timeout.signal]) : timeout.signal
|
|
59
|
+
const timer = setTimeout(() => timeout.abort(), options.timeoutSeconds * 1000)
|
|
60
|
+
let broker: CodingBroker | undefined
|
|
61
|
+
let cleanupPrepared: (() => Promise<void>) | undefined
|
|
62
|
+
const cwd = join(options.workspace.taskRoot, 'worktree')
|
|
63
|
+
const parser =
|
|
64
|
+
engine === 'claude'
|
|
65
|
+
? new ClaudeStreamParser()
|
|
66
|
+
: engine === 'codex'
|
|
67
|
+
? new CodexStreamParser()
|
|
68
|
+
: new OmoStreamParser({ sessionId: options.sessionId, cwd })
|
|
69
|
+
let stdout = ''
|
|
70
|
+
let stdoutTail = ''
|
|
71
|
+
let stderr = ''
|
|
72
|
+
let exitCode: number | null = null
|
|
73
|
+
let failure = false
|
|
74
|
+
let missingSession = false
|
|
75
|
+
let outputCapExceeded = false
|
|
76
|
+
let deadlineExpired = false
|
|
77
|
+
const oom = readOomEvents()
|
|
78
|
+
try {
|
|
79
|
+
signal.throwIfAborted()
|
|
80
|
+
const provider = options.provider ?? (engine === 'claude' ? 'anthropic' : 'openai-codex')
|
|
81
|
+
const configDir = join(options.workspace.taskRoot, engine)
|
|
82
|
+
if (engine === 'omo') {
|
|
83
|
+
if (!options.provider || options.modelMetadata?.id !== options.model)
|
|
84
|
+
throw new Error('Missing OmO model metadata.')
|
|
85
|
+
if (options.resume && !(await hasOmoSession(configDir, options.sessionId, cwd))) {
|
|
86
|
+
missingSession = true
|
|
87
|
+
throw new Error('OmO session is missing or unsafe.')
|
|
88
|
+
}
|
|
89
|
+
await prepareOmoDirectories(configDir)
|
|
90
|
+
}
|
|
91
|
+
broker = await (testDependencies?.broker ?? startCodingBroker)({
|
|
92
|
+
engine,
|
|
93
|
+
provider,
|
|
94
|
+
auth: options.auth,
|
|
95
|
+
allowedModels: options.allowedModels,
|
|
96
|
+
deadline,
|
|
97
|
+
signal,
|
|
98
|
+
})
|
|
99
|
+
if (engine === 'codex') {
|
|
100
|
+
await options.writeArtifact(join(configDir, 'config.toml'), codexConfig(options.model, broker.baseUrl))
|
|
101
|
+
}
|
|
102
|
+
if (engine === 'omo' && options.modelMetadata) {
|
|
103
|
+
const config = omoConfiguration({ configDir, baseUrl: broker.baseUrl, provider, model: options.modelMetadata })
|
|
104
|
+
for (const [path, value] of [
|
|
105
|
+
['agent/models.json', config.models],
|
|
106
|
+
['agent/settings.json', config.settings],
|
|
107
|
+
['home/.omo/omo.jsonc', config.orchestration],
|
|
108
|
+
] as const)
|
|
109
|
+
await options.writeArtifact(join(configDir, path), JSON.stringify(value, null, 2))
|
|
110
|
+
}
|
|
111
|
+
const env =
|
|
112
|
+
engine === 'claude'
|
|
113
|
+
? claudeEnvironment(configDir, broker.baseUrl, broker.capability)
|
|
114
|
+
: engine === 'codex'
|
|
115
|
+
? codexEnvironment(configDir, broker.capability)
|
|
116
|
+
: omoEnvironment(configDir, broker.capability)
|
|
117
|
+
const args =
|
|
118
|
+
engine === 'claude'
|
|
119
|
+
? claudeArguments(options)
|
|
120
|
+
: engine === 'codex'
|
|
121
|
+
? codexArguments(options)
|
|
122
|
+
: omoArguments({ ...options, configDir })
|
|
123
|
+
const prepared: {
|
|
124
|
+
argv: string[]
|
|
125
|
+
env: Record<string, string>
|
|
126
|
+
extraFiles?: Array<number | 'ignore'>
|
|
127
|
+
cleanup?: () => Promise<void>
|
|
128
|
+
} = testDependencies
|
|
129
|
+
? await testDependencies.command(args, env)
|
|
130
|
+
: await prepareCodingCommand(args, {
|
|
131
|
+
source: options.workspace.source,
|
|
132
|
+
taskRoot: options.workspace.taskRoot,
|
|
133
|
+
cwd,
|
|
134
|
+
mode: options.mode,
|
|
135
|
+
env,
|
|
136
|
+
engine,
|
|
137
|
+
}).then((command) => ({
|
|
138
|
+
argv: ['bash', '-c', `exec ${command.commandString}`],
|
|
139
|
+
env: command.spawnEnv,
|
|
140
|
+
extraFiles: command.extraFiles,
|
|
141
|
+
cleanup: command.cleanup,
|
|
142
|
+
}))
|
|
143
|
+
cleanupPrepared = prepared.cleanup
|
|
144
|
+
signal.throwIfAborted()
|
|
145
|
+
const [executable, ...argv] = withToolOomPriorityArgv(prepared.argv)
|
|
146
|
+
if (!executable) throw new Error('Coding command is empty.')
|
|
147
|
+
const child = spawn(executable, argv, {
|
|
148
|
+
cwd,
|
|
149
|
+
env: prepared.env,
|
|
150
|
+
detached: true,
|
|
151
|
+
stdio: ['pipe', 'pipe', 'pipe', ...(prepared.extraFiles ?? [])],
|
|
152
|
+
})
|
|
153
|
+
if (!child.stdin || !child.stdout || !child.stderr) throw new Error('Coding pipes unavailable.')
|
|
154
|
+
const kill = () => {
|
|
155
|
+
if (child.pid === undefined) return
|
|
156
|
+
try {
|
|
157
|
+
process.kill(-child.pid, 'SIGKILL')
|
|
158
|
+
} catch (error) {
|
|
159
|
+
if (!(error instanceof Error && 'code' in error && error.code === 'ESRCH')) throw error
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
const closed = once(child, 'close')
|
|
163
|
+
// Attach readers before sending the prompt or cancellation.
|
|
164
|
+
const consume = async (stream: NodeJS.ReadableStream, output: boolean): Promise<void> => {
|
|
165
|
+
const decoder = new TextDecoder()
|
|
166
|
+
const scrubber = new SecretScrubber([broker?.capability ?? ''])
|
|
167
|
+
const deltas = output && engine === 'omo' ? new OmoDeltaFilter() : undefined
|
|
168
|
+
let total = 0
|
|
169
|
+
for await (const chunk of stream) {
|
|
170
|
+
if (outputCapExceeded) continue
|
|
171
|
+
const bytes = Buffer.isBuffer(chunk) ? chunk : Buffer.from(String(chunk))
|
|
172
|
+
const scrubbed = scrubber.push(decoder.decode(bytes, { stream: true }))
|
|
173
|
+
const text = deltas ? deltas.push(scrubbed) : scrubbed
|
|
174
|
+
total += Buffer.byteLength(text)
|
|
175
|
+
if (total > OUTPUT_LIMIT_BYTES) {
|
|
176
|
+
outputCapExceeded = true
|
|
177
|
+
failure = true
|
|
178
|
+
kill()
|
|
179
|
+
continue
|
|
180
|
+
}
|
|
181
|
+
if (output) {
|
|
182
|
+
stdout += text
|
|
183
|
+
try {
|
|
184
|
+
parser.push(text)
|
|
185
|
+
} catch {
|
|
186
|
+
failure = true
|
|
187
|
+
kill()
|
|
188
|
+
}
|
|
189
|
+
} else stderr += text
|
|
190
|
+
}
|
|
191
|
+
const flushed = scrubber.push(decoder.decode(), true)
|
|
192
|
+
const final = deltas ? deltas.push(flushed) + deltas.flush() : flushed
|
|
193
|
+
if (outputCapExceeded) return
|
|
194
|
+
total += Buffer.byteLength(final)
|
|
195
|
+
if (total > OUTPUT_LIMIT_BYTES) {
|
|
196
|
+
outputCapExceeded = true
|
|
197
|
+
failure = true
|
|
198
|
+
return
|
|
199
|
+
}
|
|
200
|
+
if (output) {
|
|
201
|
+
stdout += final
|
|
202
|
+
stdoutTail = final
|
|
203
|
+
} else stderr += final
|
|
204
|
+
}
|
|
205
|
+
// Observe pipe/parser failures immediately, including the decoder's final
|
|
206
|
+
// flush. Waiting for process exit before attaching a rejection handler can
|
|
207
|
+
// leave an oversized final JSONL record as an unhandled rejection.
|
|
208
|
+
const reads = [consume(child.stdout, true), consume(child.stderr, false)].map((read) =>
|
|
209
|
+
read.catch(() => {
|
|
210
|
+
failure = true
|
|
211
|
+
kill()
|
|
212
|
+
}),
|
|
213
|
+
)
|
|
214
|
+
signal.addEventListener('abort', kill, { once: true })
|
|
215
|
+
child.stdin.on('error', () => {
|
|
216
|
+
failure = true
|
|
217
|
+
})
|
|
218
|
+
try {
|
|
219
|
+
if (signal.aborted) kill()
|
|
220
|
+
else
|
|
221
|
+
child.stdin.end(
|
|
222
|
+
engine !== 'claude' && options.mode === 'plan'
|
|
223
|
+
? `Plan this task without modifying the repository. The worktree and Git database are read-only.\n\n${options.prompt}`
|
|
224
|
+
: options.prompt,
|
|
225
|
+
)
|
|
226
|
+
const [code, killedBy] = await closed
|
|
227
|
+
exitCode = typeof code === 'number' ? code : killedBy === 'SIGKILL' ? 137 : null
|
|
228
|
+
await Promise.all(reads)
|
|
229
|
+
// The decoder/scrubber tail is available only at EOF. Validate it after
|
|
230
|
+
// reaping, rather than attempting to kill a process already exiting.
|
|
231
|
+
parser.push(stdoutTail)
|
|
232
|
+
parser.finish()
|
|
233
|
+
} finally {
|
|
234
|
+
signal.removeEventListener('abort', kill)
|
|
235
|
+
kill()
|
|
236
|
+
await Promise.allSettled([closed, ...reads])
|
|
237
|
+
}
|
|
238
|
+
} catch {
|
|
239
|
+
failure = true
|
|
240
|
+
} finally {
|
|
241
|
+
// The broker can reject an expired capability before the event loop
|
|
242
|
+
// delivers our timeout callback. The deadline, not callback order, wins.
|
|
243
|
+
deadlineExpired = Date.now() >= deadline
|
|
244
|
+
clearTimeout(timer)
|
|
245
|
+
await broker?.close()
|
|
246
|
+
await cleanupPrepared?.()
|
|
247
|
+
}
|
|
248
|
+
const invocation = crypto.randomUUID()
|
|
249
|
+
await options.writeArtifact(join(options.workspace.taskRoot, 'output', `${invocation}.jsonl`), stdout)
|
|
250
|
+
await options.writeArtifact(join(options.workspace.taskRoot, 'output', `${invocation}.stderr`), stderr)
|
|
251
|
+
const timedOut =
|
|
252
|
+
timeout.signal.aborted ||
|
|
253
|
+
deadlineExpired ||
|
|
254
|
+
(options.signal?.reason instanceof DOMException && options.signal.reason.name === 'TimeoutError')
|
|
255
|
+
const state = timedOut
|
|
256
|
+
? 'incomplete'
|
|
257
|
+
: options.signal?.aborted
|
|
258
|
+
? 'cancelled'
|
|
259
|
+
: missingSession
|
|
260
|
+
? 'incomplete'
|
|
261
|
+
: failure || exitCode !== 0 || parser.failed || parser.malformed
|
|
262
|
+
? 'failed'
|
|
263
|
+
: !parser.terminal || parser.permissionDenied || (engine !== 'claude' && !parser.sessionId)
|
|
264
|
+
? 'incomplete'
|
|
265
|
+
: 'completed'
|
|
266
|
+
return {
|
|
267
|
+
state,
|
|
268
|
+
finalMessage: parser.finalMessage,
|
|
269
|
+
exitCode,
|
|
270
|
+
...(parser.sessionId ? { sessionId: parser.sessionId } : {}),
|
|
271
|
+
diagnostic:
|
|
272
|
+
toolOomNote(oom, exitCode ?? 0, 'coding_agent') ??
|
|
273
|
+
(state === 'completed'
|
|
274
|
+
? ''
|
|
275
|
+
: missingSession
|
|
276
|
+
? 'The recorded OmO session is missing or unsafe. Restore its task-local session file before resuming; partial work is preserved.'
|
|
277
|
+
: timedOut
|
|
278
|
+
? 'Invocation timed out; partial work is preserved.'
|
|
279
|
+
: outputCapExceeded
|
|
280
|
+
? 'The coding CLI exceeded the 16 MiB output limit and was stopped; partial work is preserved. Resume with a narrower prompt.'
|
|
281
|
+
: parser.permissionDenied
|
|
282
|
+
? 'The coding CLI reported a permission denial; review the task and continue explicitly.'
|
|
283
|
+
: 'Invocation did not complete. Inspect the saved output and partial diff; verify the installed CLI and sandbox.'),
|
|
284
|
+
}
|
|
285
|
+
}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { Type } from '@earendil-works/pi-ai'
|
|
2
|
+
import { defineTool } from '@earendil-works/pi-coding-agent'
|
|
3
|
+
|
|
4
|
+
import type { SessionOrigin } from '@/agent/session-origin'
|
|
5
|
+
import type { PermissionService } from '@/permissions'
|
|
6
|
+
|
|
7
|
+
import { codingRequestSchema, getCodingAgentService, type CodingAgentService } from './index'
|
|
8
|
+
|
|
9
|
+
export function createCodingAgentTool(options: {
|
|
10
|
+
agentDir: string
|
|
11
|
+
sessionId: string
|
|
12
|
+
getOrigin: () => SessionOrigin | undefined
|
|
13
|
+
permissions: PermissionService
|
|
14
|
+
service?: CodingAgentService
|
|
15
|
+
}) {
|
|
16
|
+
return defineTool({
|
|
17
|
+
name: 'coding_agent',
|
|
18
|
+
label: 'Coding Agent',
|
|
19
|
+
description:
|
|
20
|
+
'Run headless Claude Code, Codex or OmO in an isolated persistent Git worktree through the credential broker. ' +
|
|
21
|
+
'Use a background operator for long runs. New tasks require repo and an anthropic (claude/omo) or openai-codex (codex/omo) modelRef; continuation uses taskId. ' +
|
|
22
|
+
'The baseline is committed HEAD, not dirty source files. Inspect state, finalMessage and the complete patch before applying. ' +
|
|
23
|
+
'Plan mode makes the worktree and Git database read-only. result reads a receipt; dispose requires explicit discard:true.',
|
|
24
|
+
parameters: Type.Union([
|
|
25
|
+
Type.Object({
|
|
26
|
+
action: Type.Literal('run'),
|
|
27
|
+
engine: Type.Union([Type.Literal('claude'), Type.Literal('codex'), Type.Literal('omo')]),
|
|
28
|
+
repo: Type.Optional(Type.String()),
|
|
29
|
+
modelRef: Type.Optional(Type.String()),
|
|
30
|
+
taskId: Type.Optional(Type.String()),
|
|
31
|
+
prompt: Type.String(),
|
|
32
|
+
mode: Type.Optional(Type.Union([Type.Literal('plan'), Type.Literal('code')])),
|
|
33
|
+
timeoutSeconds: Type.Optional(Type.Number({ exclusiveMinimum: 0, maximum: 2_147_483.647 })),
|
|
34
|
+
}),
|
|
35
|
+
Type.Object({ action: Type.Literal('result'), taskId: Type.String() }),
|
|
36
|
+
Type.Object({ action: Type.Literal('dispose'), taskId: Type.String(), discard: Type.Literal(true) }),
|
|
37
|
+
]),
|
|
38
|
+
async execute(_id, params, signal, onUpdate) {
|
|
39
|
+
try {
|
|
40
|
+
const request = codingRequestSchema.parse(params)
|
|
41
|
+
const result = await (options.service ?? getCodingAgentService(options.agentDir)).execute(
|
|
42
|
+
request,
|
|
43
|
+
{
|
|
44
|
+
sessionId: options.sessionId,
|
|
45
|
+
origin: options.getOrigin(),
|
|
46
|
+
permissions: options.permissions,
|
|
47
|
+
onPrepared: (receipt) =>
|
|
48
|
+
onUpdate?.({
|
|
49
|
+
content: [{ type: 'text', text: JSON.stringify(receipt) }],
|
|
50
|
+
details: receipt,
|
|
51
|
+
}),
|
|
52
|
+
},
|
|
53
|
+
signal,
|
|
54
|
+
)
|
|
55
|
+
return { content: [{ type: 'text' as const, text: JSON.stringify(result) }], details: result }
|
|
56
|
+
} catch (error) {
|
|
57
|
+
const result = { ok: false, diagnostic: error instanceof Error ? error.message : 'Coding delegation failed.' }
|
|
58
|
+
return { content: [{ type: 'text' as const, text: JSON.stringify(result) }], details: result }
|
|
59
|
+
}
|
|
60
|
+
},
|
|
61
|
+
})
|
|
62
|
+
}
|