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/init/index.ts
CHANGED
|
@@ -760,8 +760,8 @@ function addCustomModel(
|
|
|
760
760
|
customModels[ref] = meta ?? {}
|
|
761
761
|
}
|
|
762
762
|
|
|
763
|
-
// agent-browser ships in every agent: the bundled SKILL.md (src/
|
|
764
|
-
// agent-browser/SKILL.md) is a discovery stub that calls `agent-browser
|
|
763
|
+
// agent-browser ships in every agent: the bundled SKILL.md (src/bundled-plugins/
|
|
764
|
+
// agent-browser/skills/agent-browser/SKILL.md) is a discovery stub that calls `agent-browser
|
|
765
765
|
// skills get core` at runtime, so the CLI must be installed for the skill
|
|
766
766
|
// to function. The Dockerfile pre-downloads Chromium too, so the agent
|
|
767
767
|
// can drive a browser without any first-run setup.
|
|
@@ -769,7 +769,7 @@ function addCustomModel(
|
|
|
769
769
|
// Must match the Dockerfile Layer 4 global install (dockerfile.ts); they are
|
|
770
770
|
// two installs of the same CLI and a skew is silent. Enforced by a guard test
|
|
771
771
|
// in packagejson.test.ts.
|
|
772
|
-
export const AGENT_BROWSER_VERSION = '^0.
|
|
772
|
+
export const AGENT_BROWSER_VERSION = '^0.39.1'
|
|
773
773
|
function buildPackageJson(root: string, name: string, platform: NodeJS.Platform): Record<string, unknown> {
|
|
774
774
|
return {
|
|
775
775
|
name,
|
|
@@ -812,6 +812,7 @@ export async function writeDockerAssets(root: string): Promise<DockerAssetsResul
|
|
|
812
812
|
await writeFile(
|
|
813
813
|
join(root, DOCKERFILE),
|
|
814
814
|
buildDockerfile(typeclawConfig.docker.file, {
|
|
815
|
+
browser: typeclawConfig.browser,
|
|
815
816
|
// A local-spec dev install must inline the heavy stack: its unreleased
|
|
816
817
|
// version has no published `typeclaw-base` tag, so resolving a base
|
|
817
818
|
// image version would pin a nonexistent `FROM ghcr.io/...:<version>`.
|
|
@@ -1003,9 +1004,8 @@ export async function readExistingProviderApiKey(root: string, providerId: Known
|
|
|
1003
1004
|
// shaped, or the access token is absent/blank.
|
|
1004
1005
|
//
|
|
1005
1006
|
// The token lives under `access` — pi-ai's secrets.json shape (`{ type:
|
|
1006
|
-
// 'oauth', access, refresh, expires, accountId }`)
|
|
1007
|
-
//
|
|
1008
|
-
// the unrelated `~/.codex/auth.json` export (`{ tokens: { access_token } }`).
|
|
1007
|
+
// 'oauth', access, refresh, expires, accountId }`). NOT `access_token`, which
|
|
1008
|
+
// belongs to the native Codex auth.json format that TypeClaw no longer exports.
|
|
1009
1009
|
// Reading `access_token` here silently returned false for every real
|
|
1010
1010
|
// credential, re-running the browser login on resume instead of reusing it.
|
|
1011
1011
|
//
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { execFile } from 'node:child_process'
|
|
2
|
+
import { createHash } from 'node:crypto'
|
|
3
|
+
import { mkdir, readFile, writeFile } from 'node:fs/promises'
|
|
4
|
+
import { dirname, join } from 'node:path'
|
|
5
|
+
import { promisify } from 'node:util'
|
|
6
|
+
|
|
7
|
+
const execFileAsync = promisify(execFile)
|
|
8
|
+
|
|
9
|
+
// Lives inside node_modules so a wiped or reinstalled node_modules also drops
|
|
10
|
+
// the stamp, which forces the next start to re-copy the checkout.
|
|
11
|
+
const STAMP_FILE = join('node_modules', '.typeclaw-local-source')
|
|
12
|
+
|
|
13
|
+
// Identifies the exact source a `file:` checkout would copy: committed HEAD plus
|
|
14
|
+
// uncommitted edits. Returns null when the checkout is not a Git repo, so the
|
|
15
|
+
// caller cannot tell whether the copy is stale and keeps its old behavior.
|
|
16
|
+
export async function localSourceFingerprint(sourceDir: string): Promise<string | null> {
|
|
17
|
+
try {
|
|
18
|
+
const git = async (...args: string[]) =>
|
|
19
|
+
(await execFileAsync('git', ['-C', sourceDir, ...args], { maxBuffer: 64 * 1024 * 1024 })).stdout
|
|
20
|
+
const [head, diff, untracked] = await Promise.all([
|
|
21
|
+
git('rev-parse', 'HEAD'),
|
|
22
|
+
git('diff', 'HEAD'),
|
|
23
|
+
git('ls-files', '--others', '--exclude-standard'),
|
|
24
|
+
])
|
|
25
|
+
// `git diff HEAD` skips untracked files, so hash their contents too: an edit
|
|
26
|
+
// to a new, not-yet-added file must still count as a source change.
|
|
27
|
+
const paths = untracked.split('\n').filter((path) => path !== '')
|
|
28
|
+
const untrackedHashes =
|
|
29
|
+
paths.length === 0
|
|
30
|
+
? ''
|
|
31
|
+
: (
|
|
32
|
+
await new Promise<string>((resolve, reject) => {
|
|
33
|
+
const child = execFile(
|
|
34
|
+
'git',
|
|
35
|
+
['-C', sourceDir, 'hash-object', '--stdin-paths'],
|
|
36
|
+
{ maxBuffer: 64 * 1024 * 1024 },
|
|
37
|
+
(error, stdout) => (error ? reject(error) : resolve(stdout)),
|
|
38
|
+
)
|
|
39
|
+
child.stdin?.end(paths.join('\n'))
|
|
40
|
+
})
|
|
41
|
+
).trim()
|
|
42
|
+
return createHash('sha256')
|
|
43
|
+
.update(head)
|
|
44
|
+
.update('\0')
|
|
45
|
+
.update(diff)
|
|
46
|
+
.update('\0')
|
|
47
|
+
.update(untracked)
|
|
48
|
+
.update('\0')
|
|
49
|
+
.update(untrackedHashes)
|
|
50
|
+
.digest('hex')
|
|
51
|
+
} catch {
|
|
52
|
+
return null
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
export async function readLocalSourceStamp(cwd: string): Promise<string | null> {
|
|
57
|
+
try {
|
|
58
|
+
return (await readFile(join(cwd, STAMP_FILE), 'utf8')).trim()
|
|
59
|
+
} catch {
|
|
60
|
+
return null
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
export async function writeLocalSourceStamp(cwd: string, fingerprint: string): Promise<void> {
|
|
65
|
+
const path = join(cwd, STAMP_FILE)
|
|
66
|
+
await mkdir(dirname(path), { recursive: true })
|
|
67
|
+
await writeFile(path, `${fingerprint}\n`)
|
|
68
|
+
}
|
package/src/init/models-dev.ts
CHANGED
|
@@ -52,6 +52,10 @@ const PROVIDER_TO_MODELS_DEV: Record<KnownProviderId, string | null> = {
|
|
|
52
52
|
// `kimi-for-coding` alias is surfaced regardless of upstream membership.
|
|
53
53
|
'moonshot-coding': 'moonshot',
|
|
54
54
|
opengateway: null,
|
|
55
|
+
// models.dev's `inception` catalog lists only Mercury 2 / 2.5 / Edit 2, which
|
|
56
|
+
// are retired for new users or don't serve chat. Surface the curated
|
|
57
|
+
// Mercury 3 record alone.
|
|
58
|
+
inception: null,
|
|
55
59
|
}
|
|
56
60
|
|
|
57
61
|
function upstreamProviderFor(
|
|
@@ -32,6 +32,8 @@ const PROVIDER_PROBE: Partial<Record<KnownProviderId, Probe>> = {
|
|
|
32
32
|
// validation, because init would vouch for a key that cannot complete a single
|
|
33
33
|
// request. /v1/me is the cheapest endpoint that actually 401s on a bad key.
|
|
34
34
|
opengateway: { url: 'https://apis.opengateway.ai/v1/me', authHeader: 'bearer', successShape: 'json-object' },
|
|
35
|
+
// inception has no probe: its /v1/models is public and returns 200 for any
|
|
36
|
+
// key, so probing it would vouch for garbage.
|
|
35
37
|
}
|
|
36
38
|
|
|
37
39
|
// When a base-URL override (ANTHROPIC_BASE_URL / OPENAI_BASE_URL) points at a
|
|
@@ -194,6 +196,7 @@ export const API_KEY_DASHBOARD_URL: Partial<Record<KnownProviderId, string>> = {
|
|
|
194
196
|
moonshot: 'https://platform.moonshot.ai/console/api-keys',
|
|
195
197
|
'moonshot-coding': 'https://www.kimi.com/code/console',
|
|
196
198
|
opengateway: 'https://opengateway.ai/docs/reference/guides/authentication',
|
|
199
|
+
inception: 'https://platform.inceptionlabs.ai',
|
|
197
200
|
}
|
|
198
201
|
|
|
199
202
|
// MiniMax sells the same `minimax` provider under two billing surfaces that
|
package/src/mcp/client.ts
CHANGED
|
@@ -7,6 +7,7 @@ import type { Transport } from '@modelcontextprotocol/sdk/shared/transport.js'
|
|
|
7
7
|
import { CallToolResultSchema, type CallToolResult, type ListToolsRequest } from '@modelcontextprotocol/sdk/types.js'
|
|
8
8
|
|
|
9
9
|
import type { McpServer } from '@/config/config'
|
|
10
|
+
import { withToolOomPriorityArgv } from '@/container/tool-oom-priority'
|
|
10
11
|
import type { ToolFileOperands } from '@/plugin'
|
|
11
12
|
import { resolveSecret } from '@/secrets/resolve'
|
|
12
13
|
|
|
@@ -207,7 +208,8 @@ export function createTransport(
|
|
|
207
208
|
authProvider?: OAuthClientProvider,
|
|
208
209
|
): Transport {
|
|
209
210
|
if (server.command) {
|
|
210
|
-
|
|
211
|
+
const [command = server.command, ...args] = withToolOomPriorityArgv([server.command, ...server.args])
|
|
212
|
+
return new StdioClientTransport({ command, args, env: resolveServerEnv(server, env) })
|
|
211
213
|
}
|
|
212
214
|
const url = new URL(requiredUrl(server))
|
|
213
215
|
return authProvider === undefined
|
|
@@ -1,11 +1,17 @@
|
|
|
1
1
|
import { isSecretShapedToken } from '@/bundled-plugins/memory/secret-detector'
|
|
2
2
|
|
|
3
|
+
export type BuiltinSearchBin = 'rg' | 'fd'
|
|
4
|
+
|
|
3
5
|
export type OperationalIncidentFact =
|
|
4
6
|
| { kind: 'bash-command-not-found'; bin: string }
|
|
5
7
|
| { kind: 'declared-skill-bin-unresolved'; bin: string }
|
|
6
8
|
| { kind: 'sandbox-proc-unavailable' }
|
|
9
|
+
| { kind: 'builtin-search-bin-unavailable'; bin: BuiltinSearchBin }
|
|
7
10
|
|
|
8
|
-
export type OperationalIncidentResolutionSignal =
|
|
11
|
+
export type OperationalIncidentResolutionSignal =
|
|
12
|
+
| 'successful-bin'
|
|
13
|
+
| 'successful-sandbox-real-proc'
|
|
14
|
+
| 'successful-builtin-search-tool'
|
|
9
15
|
|
|
10
16
|
export type OperationalIncidentSuccessInput = {
|
|
11
17
|
tool: string
|
|
@@ -17,6 +23,7 @@ export const OPERATIONAL_INCIDENT_RESOLUTION_SIGNAL_BY_KIND = {
|
|
|
17
23
|
'bash-command-not-found': 'successful-bin',
|
|
18
24
|
'declared-skill-bin-unresolved': 'successful-bin',
|
|
19
25
|
'sandbox-proc-unavailable': 'successful-sandbox-real-proc',
|
|
26
|
+
'builtin-search-bin-unavailable': 'successful-builtin-search-tool',
|
|
20
27
|
} as const satisfies Record<OperationalIncidentFact['kind'], OperationalIncidentResolutionSignal>
|
|
21
28
|
|
|
22
29
|
export class DeclaredSkillBinUnresolvedError extends Error {
|
|
@@ -32,10 +39,30 @@ const COMMAND_NOT_FOUND = new RegExp(
|
|
|
32
39
|
`^(?:/bin/bash: |bash: line [1-9][0-9]{0,5}: )(${SAFE_BIN}): command not found\\n(?:\\n){1,2}Command exited with code 127$`,
|
|
33
40
|
)
|
|
34
41
|
|
|
42
|
+
// Pi's grep/find reject with these fixed literals when `ensureTool` returns no
|
|
43
|
+
// rg/fd path (pi packages/coding-agent/src/core/tools/{grep,find}.ts; published
|
|
44
|
+
// dist/core/tools/{grep,find}.js, identical in 0.87.1, 0.99.2, and 1.0.0).
|
|
45
|
+
// Classification accepts the literal alone or followed by the exact `: `
|
|
46
|
+
// separator and untrusted context. Context is never parsed or persisted; the
|
|
47
|
+
// bin comes only from the closed grep->rg/find->fd tool mapping. This contract
|
|
48
|
+
// needs no unreleased Pi format. Wording drift stays an ordinary tool failure;
|
|
49
|
+
// re-verify the literals and default-operations invariant on every Pi bump.
|
|
50
|
+
const BUILTIN_SEARCH_TOOLS = {
|
|
51
|
+
grep: { bin: 'rg', unavailable: 'ripgrep (rg) is not available and could not be downloaded' },
|
|
52
|
+
find: { bin: 'fd', unavailable: 'fd is not available and could not be downloaded' },
|
|
53
|
+
} as const satisfies Record<string, { bin: BuiltinSearchBin; unavailable: string }>
|
|
54
|
+
|
|
35
55
|
export function classifyToolOutcome(input: { tool: string; error: unknown }): OperationalIncidentFact | null {
|
|
36
56
|
if (input.error instanceof DeclaredSkillBinUnresolvedError && isSafeBin(input.error.bin)) {
|
|
37
57
|
return { kind: 'declared-skill-bin-unresolved', bin: input.error.bin }
|
|
38
58
|
}
|
|
59
|
+
const searchTool = builtinSearchTool(input.tool)
|
|
60
|
+
if (searchTool !== undefined) {
|
|
61
|
+
if (!(input.error instanceof Error)) return null
|
|
62
|
+
const { message } = input.error
|
|
63
|
+
const unavailable = message === searchTool.unavailable || message.startsWith(`${searchTool.unavailable}: `)
|
|
64
|
+
return unavailable ? { kind: 'builtin-search-bin-unavailable', bin: searchTool.bin } : null
|
|
65
|
+
}
|
|
39
66
|
if (input.tool !== 'bash' || !(input.error instanceof Error)) return null
|
|
40
67
|
if (input.error.name === 'SandboxDegradedProcError') return { kind: 'sandbox-proc-unavailable' }
|
|
41
68
|
|
|
@@ -47,6 +74,12 @@ export function classifyToolOutcome(input: { tool: string; error: unknown }): Op
|
|
|
47
74
|
export function deriveOperationalIncidentFactsForSuccess(
|
|
48
75
|
input: OperationalIncidentSuccessInput,
|
|
49
76
|
): OperationalIncidentFact[] {
|
|
77
|
+
// TypeClaw builds grep/find without custom operations (createPiBuiltinToolDefinition),
|
|
78
|
+
// so a successful pi grep/find run proves `ensureTool` returned an rg/fd path.
|
|
79
|
+
// Passing a custom `operations.glob` to find would bypass fd and break this proof.
|
|
80
|
+
// Bash `rg`/`fd` runs never count: they use the sandbox PATH, not pi's tool bin.
|
|
81
|
+
const searchTool = builtinSearchTool(input.tool)
|
|
82
|
+
if (searchTool !== undefined) return [{ kind: 'builtin-search-bin-unavailable', bin: searchTool.bin }]
|
|
50
83
|
if (input.tool !== 'bash') return []
|
|
51
84
|
const command = input.args.command
|
|
52
85
|
if (typeof command !== 'string') return []
|
|
@@ -64,6 +97,17 @@ function bashCommandNotFoundFact(bin: string): OperationalIncidentFact | null {
|
|
|
64
97
|
return isSafeBin(bin) ? { kind: 'bash-command-not-found', bin } : null
|
|
65
98
|
}
|
|
66
99
|
|
|
100
|
+
function builtinSearchTool(tool: string): (typeof BUILTIN_SEARCH_TOOLS)[keyof typeof BUILTIN_SEARCH_TOOLS] | undefined {
|
|
101
|
+
switch (tool) {
|
|
102
|
+
case 'grep':
|
|
103
|
+
return BUILTIN_SEARCH_TOOLS.grep
|
|
104
|
+
case 'find':
|
|
105
|
+
return BUILTIN_SEARCH_TOOLS.find
|
|
106
|
+
default:
|
|
107
|
+
return undefined
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
|
|
67
111
|
function successfulBinFacts(bin: string): OperationalIncidentFact[] {
|
|
68
112
|
if (!isSafeBin(bin)) return []
|
|
69
113
|
return [
|
|
@@ -40,11 +40,16 @@ export function incidentsPath(agentDir: string): string {
|
|
|
40
40
|
}
|
|
41
41
|
|
|
42
42
|
export function fingerprintIncident(fact: OperationalIncidentFact): string {
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
43
|
+
switch (fact.kind) {
|
|
44
|
+
case 'sandbox-proc-unavailable':
|
|
45
|
+
return 'sandbox:proc-unavailable'
|
|
46
|
+
case 'bash-command-not-found':
|
|
47
|
+
return `bash:command-not-found:${normalizeBin(fact.bin)}`
|
|
48
|
+
case 'declared-skill-bin-unresolved':
|
|
49
|
+
return `skill-bin:declared-but-unresolved:${normalizeBin(fact.bin)}`
|
|
50
|
+
case 'builtin-search-bin-unavailable':
|
|
51
|
+
return `builtin-search:bin-unavailable:${fact.bin}`
|
|
52
|
+
}
|
|
48
53
|
}
|
|
49
54
|
|
|
50
55
|
export function deriveMechanicallyVerifiedIncidentFingerprints(input: OperationalIncidentSuccessInput): Set<string> {
|
|
@@ -39,6 +39,10 @@ export const CORE_PERMISSIONS = {
|
|
|
39
39
|
// permissions.ts), not the guest role, which is now grantable.
|
|
40
40
|
fsSeePrivate: 'fs.see.private',
|
|
41
41
|
fsSeeSecrets: 'fs.see.secrets',
|
|
42
|
+
// Drives the TypeClaw-managed shared browser (its logins span sessions and
|
|
43
|
+
// channels). Granted with fsSeePrivate because the browser's file exchange
|
|
44
|
+
// lives under workspace/, which that same tier already sees.
|
|
45
|
+
browserShared: 'browser.shared',
|
|
42
46
|
} as const
|
|
43
47
|
|
|
44
48
|
// Sentinel that `expandOwnerWildcard` swaps for the concrete union of
|
|
@@ -87,6 +91,7 @@ export const BUILTIN_ROLES: Readonly<Record<BuiltinRoleName, BuiltinRoleSpec>> =
|
|
|
87
91
|
CORE_PERMISSIONS.subagentOutput,
|
|
88
92
|
CORE_PERMISSIONS.subagentSpawnOperator,
|
|
89
93
|
CORE_PERMISSIONS.fsSeePrivate,
|
|
94
|
+
CORE_PERMISSIONS.browserShared,
|
|
90
95
|
CORE_PERMISSIONS.fsSeeSecrets,
|
|
91
96
|
'security.bypass.low',
|
|
92
97
|
'security.bypass.medium',
|
|
@@ -106,6 +111,7 @@ export const BUILTIN_ROLES: Readonly<Record<BuiltinRoleName, BuiltinRoleSpec>> =
|
|
|
106
111
|
CORE_PERMISSIONS.subagentOutput,
|
|
107
112
|
CORE_PERMISSIONS.subagentSpawnOperator,
|
|
108
113
|
CORE_PERMISSIONS.fsSeePrivate,
|
|
114
|
+
CORE_PERMISSIONS.browserShared,
|
|
109
115
|
CORE_PERMISSIONS.fsSeeSecrets,
|
|
110
116
|
'security.bypass.low',
|
|
111
117
|
'security.bypass.medium',
|
|
@@ -120,6 +126,7 @@ export const BUILTIN_ROLES: Readonly<Record<BuiltinRoleName, BuiltinRoleSpec>> =
|
|
|
120
126
|
CORE_PERMISSIONS.subagentCancel,
|
|
121
127
|
CORE_PERMISSIONS.subagentOutput,
|
|
122
128
|
CORE_PERMISSIONS.fsSeePrivate,
|
|
129
|
+
CORE_PERMISSIONS.browserShared,
|
|
123
130
|
'security.bypass.low',
|
|
124
131
|
],
|
|
125
132
|
},
|
|
@@ -8,6 +8,8 @@ import type { RoleConfig, RolesConfig } from './schema'
|
|
|
8
8
|
export type PermissionService = {
|
|
9
9
|
has(origin: SessionOrigin | undefined, permission: string): boolean
|
|
10
10
|
resolveRole(origin: SessionOrigin | undefined): string
|
|
11
|
+
// Discovery/delegation must distinguish an actual rule from the guest fallback.
|
|
12
|
+
resolveRole(origin: SessionOrigin | undefined, options: { requireMatch: true }): string | undefined
|
|
11
13
|
describe(origin: SessionOrigin | undefined): { role: string; permissions: readonly string[] }
|
|
12
14
|
// Orders two role names on the severity tower so callers can cap an
|
|
13
15
|
// action to the requester's role (a guest turn must not read the output
|
|
@@ -208,9 +210,9 @@ export function createPermissionService(opts: CreatePermissionServiceOptions = {
|
|
|
208
210
|
// chat ids — even denied traffic that resolves to guest — would otherwise
|
|
209
211
|
// grow the map without limit until the next role-table rebuild. See
|
|
210
212
|
// createBoundedCache for the eviction policy.
|
|
211
|
-
const roleCache = createBoundedCache<string>(ROLE_CACHE_MAX)
|
|
213
|
+
const roleCache = createBoundedCache<string | null>(ROLE_CACHE_MAX)
|
|
212
214
|
|
|
213
|
-
function computeRole(origin: SessionOrigin): string {
|
|
215
|
+
function computeRole(origin: SessionOrigin): string | null {
|
|
214
216
|
// Runtime-owned infrastructure (memory, backup) acts on the operator's
|
|
215
217
|
// behalf over operator-owned state. It is constructed only by runtime/
|
|
216
218
|
// bundled code — inbound channel/cron content cannot produce this kind —
|
|
@@ -230,25 +232,28 @@ export function createPermissionService(opts: CreatePermissionServiceOptions = {
|
|
|
230
232
|
}
|
|
231
233
|
|
|
232
234
|
const matchable = toMatchable(origin)
|
|
233
|
-
if (matchable === null) return
|
|
235
|
+
if (matchable === null) return null
|
|
234
236
|
|
|
235
237
|
for (const role of resolved) {
|
|
236
238
|
for (const rule of role.match) {
|
|
237
239
|
if (matchesOrigin(rule, matchable)) return role.name
|
|
238
240
|
}
|
|
239
241
|
}
|
|
240
|
-
return
|
|
242
|
+
return null
|
|
241
243
|
}
|
|
242
244
|
|
|
243
|
-
function resolveRole(origin: SessionOrigin | undefined): string
|
|
244
|
-
|
|
245
|
+
function resolveRole(origin: SessionOrigin | undefined): string
|
|
246
|
+
function resolveRole(origin: SessionOrigin | undefined, options: { requireMatch: true }): string | undefined
|
|
247
|
+
function resolveRole(origin: SessionOrigin | undefined, options?: { requireMatch: true }): string | undefined {
|
|
248
|
+
const fallback = options?.requireMatch ? undefined : 'guest'
|
|
249
|
+
if (origin === undefined) return fallback
|
|
245
250
|
const key = roleCacheKey(origin)
|
|
246
|
-
if (key === null) return computeRole(origin)
|
|
251
|
+
if (key === null) return computeRole(origin) ?? fallback
|
|
247
252
|
const cached = roleCache.get(key)
|
|
248
|
-
if (cached !== undefined) return cached
|
|
253
|
+
if (cached !== undefined) return cached ?? fallback
|
|
249
254
|
const role = computeRole(origin)
|
|
250
255
|
roleCache.set(key, role)
|
|
251
|
-
return role
|
|
256
|
+
return role ?? fallback
|
|
252
257
|
}
|
|
253
258
|
|
|
254
259
|
function invalidateRoleCache(): void {
|
|
@@ -409,6 +414,7 @@ function roleCacheKey(origin: SessionOrigin): string | null {
|
|
|
409
414
|
origin.chat,
|
|
410
415
|
origin.parentChat ?? '',
|
|
411
416
|
origin.lastInboundAuthorId ?? '',
|
|
417
|
+
origin.lastInboundAuthorAdapter ?? origin.adapter,
|
|
412
418
|
].join('\u0000')
|
|
413
419
|
default:
|
|
414
420
|
return null
|
|
@@ -427,6 +433,9 @@ function toMatchable(origin: SessionOrigin): Parameters<typeof matchesOrigin>[1]
|
|
|
427
433
|
chat: origin.chat,
|
|
428
434
|
...(origin.parentChat !== undefined ? { parentChat: origin.parentChat } : {}),
|
|
429
435
|
...(origin.lastInboundAuthorId !== undefined ? { lastInboundAuthorId: origin.lastInboundAuthorId } : {}),
|
|
436
|
+
...(origin.lastInboundAuthorAdapter !== undefined
|
|
437
|
+
? { lastInboundAuthorAdapter: origin.lastInboundAuthorAdapter }
|
|
438
|
+
: {}),
|
|
430
439
|
}
|
|
431
440
|
default:
|
|
432
441
|
return null
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { adapterNamespace } from '@/channels/adapter-namespace'
|
|
1
2
|
import { decodeWebexId } from '@/channels/adapters/webex-id-ref'
|
|
2
3
|
import type { AdapterId } from '@/channels/schema'
|
|
3
4
|
|
|
@@ -29,6 +30,7 @@ export type MatchableOrigin =
|
|
|
29
30
|
chat: string
|
|
30
31
|
parentChat?: string
|
|
31
32
|
lastInboundAuthorId?: string
|
|
33
|
+
lastInboundAuthorAdapter?: AdapterId
|
|
32
34
|
}
|
|
33
35
|
|
|
34
36
|
export function matchesOrigin(rule: MatchRule, origin: MatchableOrigin): boolean {
|
|
@@ -60,7 +62,11 @@ function matchesChannel(rule: Extract<MatchRule, { kind: 'channel' }>, origin: M
|
|
|
60
62
|
if (rule.chat !== undefined && !matchesChat(rule.chat, origin)) return false
|
|
61
63
|
}
|
|
62
64
|
|
|
63
|
-
if (rule.author !== undefined
|
|
65
|
+
if (rule.author !== undefined) {
|
|
66
|
+
if (adapterNamespace(origin.lastInboundAuthorAdapter ?? origin.adapter) !== adapterNamespace(origin.adapter))
|
|
67
|
+
return false
|
|
68
|
+
if (!matchesAuthor(rule.platform, rule.author, origin.lastInboundAuthorId)) return false
|
|
69
|
+
}
|
|
64
70
|
return true
|
|
65
71
|
}
|
|
66
72
|
|
package/src/plugin/context.ts
CHANGED
|
@@ -15,6 +15,7 @@ export type CreatePluginContextOptions<TConfig> = {
|
|
|
15
15
|
resolveGithubTokenForRepo?: ResolveGithubTokenForRepo
|
|
16
16
|
hasGithubAppTokenResolver?: () => boolean
|
|
17
17
|
getGithubAppSelfLogin?: () => string | null
|
|
18
|
+
resolveGithubPatForRepo?: ResolveGithubTokenForRepo
|
|
18
19
|
spawnSubagent: SpawnSubagentFn
|
|
19
20
|
isBooted: () => boolean
|
|
20
21
|
}
|
|
@@ -36,6 +37,7 @@ export function createPluginContext<TConfig>(opts: CreatePluginContextOptions<TC
|
|
|
36
37
|
resolveTokenForRepo: opts.resolveGithubTokenForRepo ?? githubTokenUnavailable,
|
|
37
38
|
hasAppTokenResolver: opts.hasGithubAppTokenResolver ?? (() => false),
|
|
38
39
|
getAppSelfLogin: opts.getGithubAppSelfLogin ?? (() => null),
|
|
40
|
+
resolvePatForRepo: opts.resolveGithubPatForRepo ?? githubTokenUnavailable,
|
|
39
41
|
},
|
|
40
42
|
spawnSubagent: async (name: string, payload?: unknown, options?: SpawnSubagentOptions) => {
|
|
41
43
|
if (!opts.isBooted()) {
|
|
@@ -10,6 +10,6 @@ export const PI_BUILTIN_TOOL_NAMES: readonly PiBuiltinToolName[] = [
|
|
|
10
10
|
'ls',
|
|
11
11
|
]
|
|
12
12
|
|
|
13
|
-
export const CORE_SYSTEM_TOOL_NAMES = ['web_search', 'web_fetch', 'look_at'] as const
|
|
13
|
+
export const CORE_SYSTEM_TOOL_NAMES = ['web_search', 'web_fetch', 'look_at', 'coding_agent'] as const
|
|
14
14
|
|
|
15
15
|
export const CORE_TOOL_NAMES: ReadonlySet<string> = new Set([...PI_BUILTIN_TOOL_NAMES, ...CORE_SYSTEM_TOOL_NAMES])
|
package/src/plugin/define.ts
CHANGED
|
@@ -80,3 +80,4 @@ export const findTool: BuiltinToolRef = { __builtinTool: 'find' }
|
|
|
80
80
|
export const lsTool: BuiltinToolRef = { __builtinTool: 'ls' }
|
|
81
81
|
export const webSearchTool: BuiltinToolRef = { __builtinTool: 'web_search' }
|
|
82
82
|
export const webFetchTool: BuiltinToolRef = { __builtinTool: 'web_fetch' }
|
|
83
|
+
export const codingAgentTool: BuiltinToolRef = { __builtinTool: 'coding_agent' }
|
package/src/plugin/hooks.ts
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import type {
|
|
2
|
+
ChannelMessageObservedEvent,
|
|
3
|
+
ChannelOutboundBeforeEvent,
|
|
2
4
|
HookContext,
|
|
3
5
|
Hooks,
|
|
4
6
|
PluginLogger,
|
|
@@ -45,6 +47,11 @@ export const END_HANDLER_TIMEOUT_MS = 60_000
|
|
|
45
47
|
// inline, AND regressions that re-introduce expensive inline prompt work.
|
|
46
48
|
export const PROMPT_HANDLER_TIMEOUT_MS = 20_000
|
|
47
49
|
|
|
50
|
+
// Observers should enqueue and return. These bounds abandon asynchronous work;
|
|
51
|
+
// they cannot preempt synchronous code in a full-trust, in-process plugin.
|
|
52
|
+
export const OBSERVED_HANDLER_TIMEOUT_MS = 10_000
|
|
53
|
+
export const OUTBOUND_HANDLER_TIMEOUT_MS = 30_000
|
|
54
|
+
|
|
48
55
|
export type RegisteredHook<K extends keyof Hooks> = {
|
|
49
56
|
pluginName: string
|
|
50
57
|
agentDir: string
|
|
@@ -61,12 +68,15 @@ export type HookBus = {
|
|
|
61
68
|
runSessionPrompt: (event: SessionPromptEvent) => Promise<void>
|
|
62
69
|
runSessionTurnStart: (event: SessionTurnStartEvent) => Promise<void>
|
|
63
70
|
runSessionTurnEnd: (event: SessionTurnEndEvent) => Promise<void>
|
|
71
|
+
runChannelMessageObserved: (event: ChannelMessageObservedEvent) => void
|
|
72
|
+
runChannelOutboundBefore: (event: ChannelOutboundBeforeEvent) => Promise<{ text: string }>
|
|
64
73
|
runToolBefore: (
|
|
65
74
|
event: ToolBeforeEvent,
|
|
66
75
|
guards?: readonly {
|
|
67
76
|
owner: string
|
|
68
77
|
key: string
|
|
69
78
|
tools: ReadonlySet<string>
|
|
79
|
+
skipOnCheckError?: true
|
|
70
80
|
check: (
|
|
71
81
|
event: Readonly<ToolBeforeEvent>,
|
|
72
82
|
) =>
|
|
@@ -89,6 +99,8 @@ export type CreateHookBusOptions = {
|
|
|
89
99
|
endHandlerTimeoutMs?: number
|
|
90
100
|
// Test seam: per-handler ceiling for session.prompt invocations.
|
|
91
101
|
promptHandlerTimeoutMs?: number
|
|
102
|
+
observedHandlerTimeoutMs?: number
|
|
103
|
+
outboundHandlerTimeoutMs?: number
|
|
92
104
|
}
|
|
93
105
|
|
|
94
106
|
type Registries = {
|
|
@@ -100,12 +112,16 @@ type Registries = {
|
|
|
100
112
|
'session.turn.end': RegisteredHook<'session.turn.end'>[]
|
|
101
113
|
'tool.before': Array<RegisteredHook<'tool.before'> | { pluginName: string; guardOwner: true; logger: PluginLogger }>
|
|
102
114
|
'tool.after': RegisteredHook<'tool.after'>[]
|
|
115
|
+
'channel.message.observed': RegisteredHook<'channel.message.observed'>[]
|
|
116
|
+
'channel.outbound.before': RegisteredHook<'channel.outbound.before'>[]
|
|
103
117
|
}
|
|
104
118
|
|
|
105
119
|
export function createHookBus(options: CreateHookBusOptions = {}): HookBus {
|
|
106
120
|
const idleHandlerTimeoutMs = options.idleHandlerTimeoutMs ?? IDLE_HANDLER_TIMEOUT_MS
|
|
107
121
|
const endHandlerTimeoutMs = options.endHandlerTimeoutMs ?? END_HANDLER_TIMEOUT_MS
|
|
108
122
|
const promptHandlerTimeoutMs = options.promptHandlerTimeoutMs ?? PROMPT_HANDLER_TIMEOUT_MS
|
|
123
|
+
const observedHandlerTimeoutMs = options.observedHandlerTimeoutMs ?? OBSERVED_HANDLER_TIMEOUT_MS
|
|
124
|
+
const outboundHandlerTimeoutMs = options.outboundHandlerTimeoutMs ?? OUTBOUND_HANDLER_TIMEOUT_MS
|
|
109
125
|
const r: Registries = {
|
|
110
126
|
'session.start': [],
|
|
111
127
|
'session.end': [],
|
|
@@ -115,6 +131,8 @@ export function createHookBus(options: CreateHookBusOptions = {}): HookBus {
|
|
|
115
131
|
'session.turn.end': [],
|
|
116
132
|
'tool.before': [],
|
|
117
133
|
'tool.after': [],
|
|
134
|
+
'channel.message.observed': [],
|
|
135
|
+
'channel.outbound.before': [],
|
|
118
136
|
}
|
|
119
137
|
|
|
120
138
|
function ctx(reg: { pluginName: string; agentDir: string; logger: PluginLogger }): HookContext {
|
|
@@ -123,6 +141,9 @@ export function createHookBus(options: CreateHookBusOptions = {}): HookBus {
|
|
|
123
141
|
|
|
124
142
|
return {
|
|
125
143
|
registerAll(pluginName, agentDir, logger, hooks) {
|
|
144
|
+
for (const name of Object.keys(hooks)) {
|
|
145
|
+
if (!Object.hasOwn(r, name)) logger.warn(`Ignoring unknown hook "${name}" (plugin ${pluginName}).`)
|
|
146
|
+
}
|
|
126
147
|
const base = { pluginName, agentDir, logger }
|
|
127
148
|
r['tool.before'].push({ pluginName, guardOwner: true, logger })
|
|
128
149
|
if (hooks['session.start']) r['session.start'].push({ ...base, handler: hooks['session.start'] })
|
|
@@ -133,6 +154,12 @@ export function createHookBus(options: CreateHookBusOptions = {}): HookBus {
|
|
|
133
154
|
if (hooks['session.turn.end']) r['session.turn.end'].push({ ...base, handler: hooks['session.turn.end'] })
|
|
134
155
|
if (hooks['tool.before']) r['tool.before'].push({ ...base, handler: hooks['tool.before'] })
|
|
135
156
|
if (hooks['tool.after']) r['tool.after'].push({ ...base, handler: hooks['tool.after'] })
|
|
157
|
+
if (hooks['channel.message.observed']) {
|
|
158
|
+
r['channel.message.observed'].push({ ...base, handler: hooks['channel.message.observed'] })
|
|
159
|
+
}
|
|
160
|
+
if (hooks['channel.outbound.before']) {
|
|
161
|
+
r['channel.outbound.before'].push({ ...base, handler: hooks['channel.outbound.before'] })
|
|
162
|
+
}
|
|
136
163
|
},
|
|
137
164
|
|
|
138
165
|
unregisterAll(pluginName) {
|
|
@@ -144,6 +171,8 @@ export function createHookBus(options: CreateHookBusOptions = {}): HookBus {
|
|
|
144
171
|
r['session.turn.end'] = r['session.turn.end'].filter((h) => h.pluginName !== pluginName)
|
|
145
172
|
r['tool.before'] = r['tool.before'].filter((h) => h.pluginName !== pluginName)
|
|
146
173
|
r['tool.after'] = r['tool.after'].filter((h) => h.pluginName !== pluginName)
|
|
174
|
+
r['channel.message.observed'] = r['channel.message.observed'].filter((h) => h.pluginName !== pluginName)
|
|
175
|
+
r['channel.outbound.before'] = r['channel.outbound.before'].filter((h) => h.pluginName !== pluginName)
|
|
147
176
|
},
|
|
148
177
|
|
|
149
178
|
async runSessionStart(event) {
|
|
@@ -231,6 +260,7 @@ export function createHookBus(options: CreateHookBusOptions = {}): HookBus {
|
|
|
231
260
|
result = await guard.check(event)
|
|
232
261
|
} catch (err) {
|
|
233
262
|
reg.logger.error(`guard ${guard.key} threw: ${err instanceof Error ? err.message : String(err)}`)
|
|
263
|
+
if (guard.skipOnCheckError) continue
|
|
234
264
|
return { block: true, reason: `guard ${guard.key} failed closed after its check threw` }
|
|
235
265
|
}
|
|
236
266
|
if (result === undefined) continue
|
|
@@ -266,6 +296,68 @@ export function createHookBus(options: CreateHookBusOptions = {}): HookBus {
|
|
|
266
296
|
}
|
|
267
297
|
},
|
|
268
298
|
|
|
299
|
+
runChannelMessageObserved(event) {
|
|
300
|
+
const regs = r['channel.message.observed']
|
|
301
|
+
if (regs.length === 0) return
|
|
302
|
+
let snapshot: ChannelMessageObservedEvent
|
|
303
|
+
try {
|
|
304
|
+
snapshot = deepFreeze(structuredClone(event))
|
|
305
|
+
} catch {
|
|
306
|
+
for (const reg of regs) reportChannelHookFailure(reg, 'channel.message.observed', 'snapshot failed')
|
|
307
|
+
return
|
|
308
|
+
}
|
|
309
|
+
for (const reg of regs) {
|
|
310
|
+
// Capture the registration set at receipt, even if a handler reloads it.
|
|
311
|
+
queueMicrotask(() => {
|
|
312
|
+
void runChannelHandler(
|
|
313
|
+
reg,
|
|
314
|
+
'channel.message.observed',
|
|
315
|
+
() => reg.handler(snapshot, ctx(reg)),
|
|
316
|
+
observedHandlerTimeoutMs,
|
|
317
|
+
)
|
|
318
|
+
})
|
|
319
|
+
}
|
|
320
|
+
},
|
|
321
|
+
|
|
322
|
+
async runChannelOutboundBefore(event) {
|
|
323
|
+
const regs = r['channel.outbound.before']
|
|
324
|
+
if (regs.length === 0) return { text: event.text }
|
|
325
|
+
let text = event.text
|
|
326
|
+
// Capture registrations before awaiting: a reload/addition belongs to the
|
|
327
|
+
// next logical delivery, not the chain currently being transformed.
|
|
328
|
+
const registrations = regs.slice()
|
|
329
|
+
for (const reg of registrations) {
|
|
330
|
+
const snapshot = Object.freeze({
|
|
331
|
+
...event,
|
|
332
|
+
text,
|
|
333
|
+
...(event.origin ? { origin: Object.freeze({ ...event.origin }) } : {}),
|
|
334
|
+
})
|
|
335
|
+
const result = await runChannelHandler(
|
|
336
|
+
reg,
|
|
337
|
+
'channel.outbound.before',
|
|
338
|
+
() => reg.handler(snapshot, ctx(reg)),
|
|
339
|
+
outboundHandlerTimeoutMs,
|
|
340
|
+
)
|
|
341
|
+
if (result === undefined) continue
|
|
342
|
+
try {
|
|
343
|
+
if (typeof result === 'object' && result !== null) {
|
|
344
|
+
const keys = Reflect.ownKeys(result)
|
|
345
|
+
if (keys.length === 1 && keys[0] === 'text') {
|
|
346
|
+
const replacement = result.text
|
|
347
|
+
if (typeof replacement === 'string' && replacement.trim().length > 0) {
|
|
348
|
+
if (event.text.trim().length > 0) text = replacement
|
|
349
|
+
continue
|
|
350
|
+
}
|
|
351
|
+
}
|
|
352
|
+
}
|
|
353
|
+
} catch {
|
|
354
|
+
// Invalid accessors cannot turn a fail-open transform into a failure.
|
|
355
|
+
}
|
|
356
|
+
reportChannelHookFailure(reg, 'channel.outbound.before', 'invalid result')
|
|
357
|
+
}
|
|
358
|
+
return { text }
|
|
359
|
+
},
|
|
360
|
+
|
|
269
361
|
count(name) {
|
|
270
362
|
if (name === 'tool.before') return r[name].filter((entry) => !('guardOwner' in entry)).length
|
|
271
363
|
return r[name].length
|
|
@@ -278,6 +370,51 @@ function reportHookError(reg: { logger: PluginLogger }, hook: keyof Hooks, err:
|
|
|
278
370
|
reg.logger.error(`hook ${hook} threw: ${message}`)
|
|
279
371
|
}
|
|
280
372
|
|
|
373
|
+
function reportChannelHookFailure(
|
|
374
|
+
reg: { pluginName: string; logger: PluginLogger },
|
|
375
|
+
hook: 'channel.message.observed' | 'channel.outbound.before',
|
|
376
|
+
kind: string,
|
|
377
|
+
): void {
|
|
378
|
+
try {
|
|
379
|
+
// Rejected/thrown values may contain message bodies or credentials.
|
|
380
|
+
reg.logger.error(`hook ${hook} ${kind} (plugin ${reg.pluginName})`)
|
|
381
|
+
} catch {
|
|
382
|
+
// Diagnostics must not break routing or fail-open delivery.
|
|
383
|
+
}
|
|
384
|
+
}
|
|
385
|
+
|
|
386
|
+
function runChannelHandler<T>(
|
|
387
|
+
reg: { pluginName: string; logger: PluginLogger },
|
|
388
|
+
hook: 'channel.message.observed' | 'channel.outbound.before',
|
|
389
|
+
invoke: () => T | Promise<T>,
|
|
390
|
+
timeoutMs: number,
|
|
391
|
+
): Promise<T | undefined> {
|
|
392
|
+
return new Promise((resolve) => {
|
|
393
|
+
let settled = false
|
|
394
|
+
const finish = (value?: T, failure?: string) => {
|
|
395
|
+
if (settled) return
|
|
396
|
+
settled = true
|
|
397
|
+
clearTimeout(timer)
|
|
398
|
+
if (failure) reportChannelHookFailure(reg, hook, failure)
|
|
399
|
+
resolve(value)
|
|
400
|
+
}
|
|
401
|
+
const timer = setTimeout(() => finish(undefined, 'timed out'), timeoutMs)
|
|
402
|
+
Promise.resolve()
|
|
403
|
+
.then(invoke)
|
|
404
|
+
.then(
|
|
405
|
+
(value) => finish(value),
|
|
406
|
+
() => finish(undefined, 'failed'),
|
|
407
|
+
)
|
|
408
|
+
})
|
|
409
|
+
}
|
|
410
|
+
|
|
411
|
+
function deepFreeze<T>(value: T): T {
|
|
412
|
+
if (value === null || typeof value !== 'object' || Object.isFrozen(value)) return value
|
|
413
|
+
Object.freeze(value)
|
|
414
|
+
for (const key of Object.keys(value)) deepFreeze((value as Record<string, unknown>)[key])
|
|
415
|
+
return value
|
|
416
|
+
}
|
|
417
|
+
|
|
281
418
|
async function raceWithTimeout<T>(work: Promise<T>, ms: number, label: string): Promise<T> {
|
|
282
419
|
let timer: ReturnType<typeof setTimeout> | null = null
|
|
283
420
|
const timeout = new Promise<never>((_, reject) => {
|