typeclaw 0.49.0 → 0.51.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/bash-sandbox-env.d.ts +15 -0
- package/dist/types/agent/bash-sandbox-proc.d.ts +8 -0
- package/dist/types/agent/bash-sandbox.d.ts +94 -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 +8 -0
- package/dist/types/agent/index.d.ts +151 -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/output-allowance.d.ts +4 -0
- package/dist/types/agent/plugin-tools.d.ts +58 -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-composition.d.ts +17 -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 +27 -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 +760 -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 +827 -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 +1458 -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 +145 -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/eval/cell.d.ts +26 -0
- package/dist/types/eval/config.d.ts +19 -0
- package/dist/types/eval/dispatch.d.ts +7 -0
- package/dist/types/eval/kernel.d.ts +28 -0
- package/dist/types/eval/process.d.ts +23 -0
- package/dist/types/eval/protocol.d.ts +34 -0
- package/dist/types/eval/sandbox.d.ts +10 -0
- package/dist/types/eval/tool.d.ts +17 -0
- package/dist/types/eval/wire.d.ts +33 -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 +3 -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/require-parallel.ts +5 -32
- package/src/agent/bash-sandbox-env.ts +104 -0
- package/src/agent/bash-sandbox-proc.ts +70 -0
- package/src/agent/bash-sandbox.ts +225 -0
- package/src/agent/compaction.ts +22 -10
- package/src/agent/guard-types.ts +3 -0
- package/src/agent/guards.ts +4 -0
- package/src/agent/idle-compaction.ts +178 -0
- package/src/agent/index.ts +139 -172
- package/src/agent/live-subagents.ts +19 -0
- package/src/agent/multimodal/look-at.ts +22 -9
- package/src/agent/output-allowance.ts +7 -0
- package/src/agent/plugin-tools.ts +39 -377
- package/src/agent/reviewer-bash-policy.ts +41 -1
- package/src/agent/session-origin.ts +28 -11
- package/src/agent/subagent-cache-keepalive.ts +198 -0
- package/src/agent/subagent-completion-reminder.ts +2 -2
- package/src/agent/subagent-session.ts +6 -0
- package/src/agent/subagents.ts +46 -8
- package/src/agent/system-prompt-composition.ts +141 -0
- package/src/agent/system-prompt.ts +5 -5
- package/src/agent/todo/scope.ts +1 -1
- package/src/agent/tool-file-safety.ts +6 -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-read.ts +57 -10
- package/src/agent/tools/channel-reply.ts +33 -26
- package/src/agent/tools/channel-send.ts +21 -13
- package/src/agent/tools/channel-session-search.ts +35 -0
- package/src/agent/tools/curl-impersonate.ts +11 -4
- package/src/agent/tools/ddg.ts +84 -16
- package/src/agent/tools/spawn-subagent.ts +27 -11
- package/src/agent/tools/stream-snapshot.ts +15 -2
- package/src/agent/tools/subagent-access.ts +11 -4
- package/src/agent/tools-without-local-file-operands.ts +4 -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/fill-secret.ts +307 -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/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/explorer/explorer.ts +1 -1
- package/src/bundled-plugins/github-cli-auth/gh-command.ts +4 -0
- package/src/bundled-plugins/github-cli-auth/gh-review-detect.ts +40 -16
- package/src/bundled-plugins/github-cli-auth/git-auth-diagnostic.ts +95 -0
- package/src/bundled-plugins/github-cli-auth/graphql-auth-nudge.ts +12 -7
- package/src/bundled-plugins/github-cli-auth/index.ts +85 -60
- package/src/bundled-plugins/managed-browser/index.ts +179 -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/memory/dreaming.ts +4 -1
- package/src/bundled-plugins/memory/load-memory.ts +2 -4
- package/src/bundled-plugins/memory/memory-logger.ts +74 -2
- package/src/bundled-plugins/memory/transcript-preload.ts +103 -0
- package/src/bundled-plugins/memory/vector/hybrid.ts +25 -14
- package/src/bundled-plugins/operator/operator.ts +1 -1
- 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/security/index.ts +53 -34
- package/src/bundled-plugins/security/policies/outbound-secret-scan.ts +1 -0
- package/src/bundled-plugins/security/policies/private-surface-read.ts +166 -201
- package/src/channels/adapter-namespace.ts +13 -0
- package/src/channels/adapters/discord-bot-reference.ts +5 -4
- package/src/channels/adapters/discord-bot.ts +98 -5
- package/src/channels/adapters/discord-classify.ts +8 -3
- package/src/channels/adapters/discord.ts +29 -0
- package/src/channels/adapters/github/index.ts +16 -0
- package/src/channels/adapters/github/last-alive.ts +4 -16
- 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 +1 -0
- package/src/channels/adapters/slack-bot-slash-commands.ts +3 -1
- package/src/channels/adapters/slack-bot.ts +299 -67
- package/src/channels/adapters/slack-classify.ts +1 -0
- package/src/channels/catch-up.ts +137 -0
- package/src/channels/continuation-willingness.ts +2 -2
- package/src/channels/continuity-types.ts +1 -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 +5 -1
- package/src/channels/github-review-verdict-coordinator.ts +68 -2
- package/src/channels/github-token-bridge.ts +24 -0
- package/src/channels/last-alive.ts +34 -0
- package/src/channels/manager.ts +8 -1
- package/src/channels/router.ts +515 -243
- 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 +3 -2
- package/src/channels/types.ts +12 -2
- package/src/cli/channel.ts +2 -3
- package/src/cli/hostd.ts +3 -0
- package/src/cli/init.ts +2 -3
- package/src/cli/model.ts +132 -3
- package/src/coding-agent/index.ts +7 -1
- package/src/coding-agent/omo-stream.ts +40 -0
- package/src/coding-agent/runner.ts +30 -8
- package/src/config/config.ts +126 -22
- 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 +69 -4
- package/src/container/start.ts +132 -5
- package/src/doctor/checks.ts +33 -22
- package/src/doctor/index.ts +48 -12
- package/src/doctor/operational-incidents.ts +16 -1
- package/src/doctor/plugin-bridge.ts +14 -1
- package/src/doctor/stage.ts +14 -0
- package/src/doctor/types.ts +6 -0
- package/src/eval/cell.ts +93 -0
- package/src/eval/config.ts +32 -0
- package/src/eval/dispatch.ts +67 -0
- package/src/eval/entry.ts +261 -0
- package/src/eval/kernel.ts +154 -0
- package/src/eval/process.ts +113 -0
- package/src/eval/protocol.ts +26 -0
- package/src/eval/redeclare.ts +174 -0
- package/src/eval/sandbox.ts +114 -0
- package/src/eval/tool.ts +98 -0
- package/src/eval/wire.ts +93 -0
- package/src/hostd/daemon.ts +13 -1
- package/src/init/auto-upgrade.ts +7 -1
- package/src/init/dockerfile.ts +57 -12
- package/src/init/index.ts +4 -3
- 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/operations/classify-tool-outcome.ts +1 -1
- 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 +6 -1
- package/src/plugin/hooks.ts +137 -0
- package/src/plugin/index.ts +6 -0
- package/src/plugin/manager.ts +4 -0
- package/src/plugin/types.ts +60 -0
- package/src/run/bundled-plugins.ts +6 -0
- package/src/run/index.ts +24 -14
- package/src/run/llm-fetch-observer.ts +12 -15
- package/src/sandbox/canonical-secrets.ts +4 -0
- package/src/sandbox/dev-source.ts +26 -0
- package/src/sandbox/env-exposure.ts +20 -0
- package/src/sandbox/hidden-paths.ts +16 -2
- package/src/secrets/storage.ts +13 -0
- package/src/server/index.ts +46 -11
- package/src/skills/typeclaw-channel-github/SKILL.md +8 -8
- package/src/skills/typeclaw-config/SKILL.md +57 -5
- package/src/skills/typeclaw-config/references/dockerfile.md +2 -2
- package/src/skills/typeclaw-github-contributing/SKILL.md +1 -1
- package/src/skills/typeclaw-monorepo/SKILL.md +1 -1
- package/src/skills/typeclaw-permissions/SKILL.md +7 -7
- package/src/skills/typeclaw-troubleshooting/SKILL.md +12 -1
- package/typeclaw.schema.json +488 -5
- 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/agent/index.ts
CHANGED
|
@@ -10,6 +10,7 @@ import {
|
|
|
10
10
|
} from '@earendil-works/pi-coding-agent'
|
|
11
11
|
import type { AgentSession, ToolDefinition } from '@earendil-works/pi-coding-agent'
|
|
12
12
|
|
|
13
|
+
import { adapterNamespace } from '@/channels/adapter-namespace'
|
|
13
14
|
import type { ChannelRouter } from '@/channels/router'
|
|
14
15
|
import type { ReactionRef } from '@/channels/types'
|
|
15
16
|
import { createCodingAgentTool } from '@/coding-agent/tool'
|
|
@@ -21,6 +22,17 @@ import {
|
|
|
21
22
|
type ResolvedProfile,
|
|
22
23
|
type ThinkingLevel,
|
|
23
24
|
} from '@/config'
|
|
25
|
+
import { config } from '@/config/config'
|
|
26
|
+
import { registerEvalTool, EVAL_PROMPT_HINT } from '@/eval/tool'
|
|
27
|
+
|
|
28
|
+
import { composeSystemPrompt, deriveSystemPromptMode, type SystemPromptMode } from './system-prompt-composition'
|
|
29
|
+
export {
|
|
30
|
+
composeSystemPrompt,
|
|
31
|
+
deriveSystemPromptMode,
|
|
32
|
+
type SystemPromptMode,
|
|
33
|
+
type SystemPromptComposition,
|
|
34
|
+
} from './system-prompt-composition'
|
|
35
|
+
import { effectiveModels } from '@/config/model-overrides'
|
|
24
36
|
import { defaultThinkingLevelForRef, isOpenAiFamilyRef, providerForModelRef, type ModelRef } from '@/config/providers'
|
|
25
37
|
import { renderMcpCatalog } from '@/mcp/catalog'
|
|
26
38
|
import type { McpManager } from '@/mcp/manager'
|
|
@@ -28,6 +40,7 @@ import { createMcpDispatcherTools, MCP_DISPATCHER_TOOL_NAMES, resolveMcpCallPref
|
|
|
28
40
|
import { noopPermissionService, type PermissionService, type RolesConfig } from '@/permissions'
|
|
29
41
|
import type {
|
|
30
42
|
BuiltinToolRef,
|
|
43
|
+
ChannelOutboundOrigin,
|
|
31
44
|
HookBus,
|
|
32
45
|
MaterializedSkills,
|
|
33
46
|
PluginRegistry,
|
|
@@ -45,10 +58,12 @@ import { createCompactionSettingsManager } from './compaction'
|
|
|
45
58
|
import { renderGitNudge } from './git-nudge'
|
|
46
59
|
import type { InternalGuard } from './guard-types'
|
|
47
60
|
import { buildInternalGuards } from './guards'
|
|
61
|
+
import { attachIdleCompaction } from './idle-compaction'
|
|
48
62
|
import type { LiveSubagentRegistry } from './live-subagents'
|
|
49
63
|
import { sanitizeMessagesForLlmReplay } from './llm-replay-sanitizer'
|
|
50
64
|
import { applyModelRuntimeOverrides } from './model-overrides'
|
|
51
65
|
import { createChannelLookAtTool, createLookAtTool } from './multimodal'
|
|
66
|
+
import { defaultOutputAllowance } from './output-allowance'
|
|
52
67
|
import {
|
|
53
68
|
buildBuiltinPiToolOverrides,
|
|
54
69
|
isPiCodingBuiltinName,
|
|
@@ -65,12 +80,8 @@ import type { RestartHandoffOrigin } from './restart-handoff'
|
|
|
65
80
|
import type { SubagentBashPolicy } from './reviewer-bash-policy'
|
|
66
81
|
import { loadSelf } from './self'
|
|
67
82
|
import { SESSION_META_CUSTOM_TYPE, sessionMetaPayload } from './session-meta'
|
|
68
|
-
import {
|
|
69
|
-
|
|
70
|
-
renderSessionOrigin,
|
|
71
|
-
type SessionOrigin,
|
|
72
|
-
type SessionRoleContext,
|
|
73
|
-
} from './session-origin'
|
|
83
|
+
import { renderSessionOrigin, type SessionOrigin, type SessionRoleContext } from './session-origin'
|
|
84
|
+
import { SubagentCacheKeepalive } from './subagent-cache-keepalive'
|
|
74
85
|
import type { CreateSessionForSubagent, SubagentCoalescer, SubagentRegistry } from './subagents'
|
|
75
86
|
import {
|
|
76
87
|
buildSystemPolicy,
|
|
@@ -84,11 +95,13 @@ import { createBudgetState, type ToolResultBudget, wrapToolDefinitionWithBudget
|
|
|
84
95
|
import { createChannelDisengageTool } from './tools/channel-disengage'
|
|
85
96
|
import { createChannelEditTool } from './tools/channel-edit'
|
|
86
97
|
import { createChannelFetchAttachmentTool, resolveInboxBaseDir } from './tools/channel-fetch-attachment'
|
|
98
|
+
import { createChannelHandoffTool } from './tools/channel-handoff'
|
|
87
99
|
import { createChannelHistoryTool } from './tools/channel-history'
|
|
88
100
|
import { createChannelReactTool } from './tools/channel-react'
|
|
89
101
|
import { createChannelReadTool } from './tools/channel-read'
|
|
90
102
|
import { createChannelReplyTool } from './tools/channel-reply'
|
|
91
103
|
import { createChannelSendTool } from './tools/channel-send'
|
|
104
|
+
import { createChannelSessionSearchTool } from './tools/channel-session-search'
|
|
92
105
|
import { createGrantRoleTool } from './tools/grant-role'
|
|
93
106
|
import { createPostGithubReviewTool } from './tools/post-github-review'
|
|
94
107
|
import { createRestartTool } from './tools/restart'
|
|
@@ -114,7 +127,7 @@ type AgentSessionTools = NonNullable<Parameters<typeof createAgentSession>[0]>['
|
|
|
114
127
|
// the full model maximum before context clamping (dist/api/simple-options.js:17),
|
|
115
128
|
// so preserve the former safe default at the session boundary. Explicit budgets
|
|
116
129
|
// remain untouched for compaction and channel-specific output caps.
|
|
117
|
-
export
|
|
130
|
+
export { DEFAULT_MAX_OUTPUT_TOKENS } from './output-allowance'
|
|
118
131
|
|
|
119
132
|
export type PluginSessionWiring = {
|
|
120
133
|
registry: PluginRegistry
|
|
@@ -212,6 +225,9 @@ export type CreateSessionOptions = {
|
|
|
212
225
|
// overrides) so different sessions on the same agent can run different
|
|
213
226
|
// models without per-session config edits.
|
|
214
227
|
profile?: string
|
|
228
|
+
// Thinking level overriding the resolved profile's own. Ignored when `profile`
|
|
229
|
+
// fell back to `default`, so the fallback session keeps `default`'s level.
|
|
230
|
+
thinkingLevel?: ThinkingLevel
|
|
215
231
|
// Override the resolved ref directly, bypassing `profile` resolution. Used
|
|
216
232
|
// by the model-fallback helper (`promptWithFallback`) to recreate a session
|
|
217
233
|
// pinned to the next ref in the chain after the previous one failed. When
|
|
@@ -262,11 +278,16 @@ export type CreateSessionResult = {
|
|
|
262
278
|
// in config.ts), so they arrive here as `resolved.thinkingLevel` — the first term.
|
|
263
279
|
// That is why `deep`'s `high` still beats a lowered global default, and why there
|
|
264
280
|
// is no profile special-casing in this function.
|
|
281
|
+
//
|
|
282
|
+
// `override` (a subagent's declared `thinkingLevel`) wins only when the requested
|
|
283
|
+
// profile actually resolved; a fallback to `default` ignores it.
|
|
265
284
|
export function resolveSessionThinkingLevel(
|
|
266
285
|
models: Models,
|
|
267
|
-
resolved: Pick<ResolvedProfile, 'thinkingLevel' | 'profile'
|
|
286
|
+
resolved: Pick<ResolvedProfile, 'thinkingLevel' | 'profile'> & { fellBackToDefault?: boolean },
|
|
268
287
|
activeRef: ModelRef,
|
|
288
|
+
override?: ThinkingLevel,
|
|
269
289
|
): ThinkingLevel | undefined {
|
|
290
|
+
if (override !== undefined && resolved.fellBackToDefault !== true) return override
|
|
270
291
|
return resolved.thinkingLevel ?? models.default.thinkingLevel ?? defaultThinkingLevelForRef(activeRef)
|
|
271
292
|
}
|
|
272
293
|
|
|
@@ -285,7 +306,10 @@ export function attachLoopGuardTurnTracking(
|
|
|
285
306
|
}
|
|
286
307
|
|
|
287
308
|
export async function createSessionWithDispose(options: CreateSessionOptions = {}): Promise<CreateSessionResult> {
|
|
288
|
-
|
|
309
|
+
// Profiles resolve against the session's effective models: the global block
|
|
310
|
+
// with any `modelOverrides` matching this session's channel layered on top.
|
|
311
|
+
const models = effectiveModels(getConfig(), options.origin)
|
|
312
|
+
const resolved = resolveProfile(models, options.profile)
|
|
289
313
|
// Unknown profiles silently fall back to `default`. The fallback is by design
|
|
290
314
|
// (see `resolveProfile`) and surfacing a warning here just creates noise on
|
|
291
315
|
// every memory-logger / dreaming subagent spawn for advanced users who know
|
|
@@ -310,24 +334,6 @@ export async function createSessionWithDispose(options: CreateSessionOptions = {
|
|
|
310
334
|
)
|
|
311
335
|
: null
|
|
312
336
|
|
|
313
|
-
const resourceLoader =
|
|
314
|
-
options.systemPromptOverride !== undefined
|
|
315
|
-
? await createOverrideResourceLoader(
|
|
316
|
-
options.systemPromptOverride,
|
|
317
|
-
options.origin,
|
|
318
|
-
options.permissions,
|
|
319
|
-
options.runtimeVersion,
|
|
320
|
-
)
|
|
321
|
-
: await createResourceLoader({
|
|
322
|
-
...(options.plugins ? { plugins: options.plugins, materializedSkills } : {}),
|
|
323
|
-
...(options.origin ? { origin: options.origin } : {}),
|
|
324
|
-
...(options.permissions ? { permissions: options.permissions } : {}),
|
|
325
|
-
...(options.runtimeVersion !== undefined ? { runtimeVersion: options.runtimeVersion } : {}),
|
|
326
|
-
...(options.mcpManager !== undefined ? { mcpManager: options.mcpManager } : {}),
|
|
327
|
-
...(options.subagentRegistry !== undefined ? { subagentRegistry: options.subagentRegistry } : {}),
|
|
328
|
-
...(isOpenAiFamilyRef(activeRef) ? { proactiveNextStepNudge: true } : {}),
|
|
329
|
-
})
|
|
330
|
-
|
|
331
337
|
const getOrigin: () => SessionOrigin | undefined =
|
|
332
338
|
options.originRef !== undefined ? () => options.originRef!.current : () => options.origin
|
|
333
339
|
|
|
@@ -549,21 +555,85 @@ export async function createSessionWithDispose(options: CreateSessionOptions = {
|
|
|
549
555
|
...new Set([...builtinActiveNames, ...[...wrappedCustomSystemTools, ...pluginCustomTools].map((t) => t.name)]),
|
|
550
556
|
]
|
|
551
557
|
|
|
558
|
+
let activeSession: AgentSession | undefined
|
|
559
|
+
const evalRuntime = registerEvalTool({
|
|
560
|
+
settings: config.eval,
|
|
561
|
+
tools: customTools,
|
|
562
|
+
activeNames: intendedActiveToolNames,
|
|
563
|
+
getActiveNames: () => activeSession?.getActiveToolNames() ?? intendedActiveToolNames,
|
|
564
|
+
wrappers: {
|
|
565
|
+
agentDir: options.plugins?.agentDir ?? process.cwd(),
|
|
566
|
+
sessionId: options.plugins?.sessionId ?? sessionManager.getSessionId(),
|
|
567
|
+
hooks: options.plugins?.hooks ?? createHookBus(),
|
|
568
|
+
guards,
|
|
569
|
+
getOrigin,
|
|
570
|
+
getAbort,
|
|
571
|
+
getLoopGuardTurn,
|
|
572
|
+
permissions: options.permissions ?? noopPermissionService,
|
|
573
|
+
bashPolicy: options.bashPolicy,
|
|
574
|
+
},
|
|
575
|
+
budget: sessionBudget,
|
|
576
|
+
budgetState: sessionBudgetState,
|
|
577
|
+
})
|
|
578
|
+
|
|
579
|
+
const resourceLoader =
|
|
580
|
+
options.systemPromptOverride !== undefined
|
|
581
|
+
? await createOverrideResourceLoader(
|
|
582
|
+
options.systemPromptOverride + (evalRuntime ? `\n\n${EVAL_PROMPT_HINT}` : ''),
|
|
583
|
+
options.origin,
|
|
584
|
+
options.permissions,
|
|
585
|
+
options.runtimeVersion,
|
|
586
|
+
)
|
|
587
|
+
: await createResourceLoader({
|
|
588
|
+
evalEnabled: evalRuntime !== undefined,
|
|
589
|
+
...(options.plugins ? { plugins: options.plugins, materializedSkills } : {}),
|
|
590
|
+
...(options.origin ? { origin: options.origin } : {}),
|
|
591
|
+
...(options.permissions ? { permissions: options.permissions } : {}),
|
|
592
|
+
...(options.runtimeVersion !== undefined ? { runtimeVersion: options.runtimeVersion } : {}),
|
|
593
|
+
...(options.mcpManager !== undefined ? { mcpManager: options.mcpManager } : {}),
|
|
594
|
+
...(options.subagentRegistry !== undefined ? { subagentRegistry: options.subagentRegistry } : {}),
|
|
595
|
+
...(isOpenAiFamilyRef(activeRef) ? { proactiveNextStepNudge: true } : {}),
|
|
596
|
+
})
|
|
597
|
+
|
|
552
598
|
const model = applyModelRuntimeOverrides(resolveModel(activeRef), activeRef)
|
|
553
599
|
// Read live so a reloaded `models` lands on the next session without a
|
|
554
600
|
// container restart.
|
|
555
|
-
const thinkingLevel = resolveSessionThinkingLevel(
|
|
601
|
+
const thinkingLevel = resolveSessionThinkingLevel(models, resolved, activeRef, options.thinkingLevel)
|
|
602
|
+
// Read per session like `models`, so a reloaded ceiling applies to new sessions.
|
|
603
|
+
const maxCompactionTriggerTokens = getConfig().compaction.maxTriggerTokens
|
|
556
604
|
const { session } = await createAgentSession({
|
|
557
605
|
model,
|
|
558
606
|
modelRuntime,
|
|
559
607
|
sessionManager,
|
|
560
|
-
settingsManager: createCompactionSettingsManager(model),
|
|
608
|
+
settingsManager: createCompactionSettingsManager(model, maxCompactionTriggerTokens),
|
|
561
609
|
resourceLoader,
|
|
562
610
|
noTools: 'builtin',
|
|
563
611
|
tools: intendedActiveToolNames,
|
|
564
612
|
customTools,
|
|
565
613
|
...(thinkingLevel ? { thinkingLevel } : {}),
|
|
566
614
|
})
|
|
615
|
+
// Pi's general warmer also runs without background children. TypeClaw owns
|
|
616
|
+
// the narrower idle-parent policy and never persists synthetic ping results.
|
|
617
|
+
activeSession = session
|
|
618
|
+
session.setCacheWarmingMode('off')
|
|
619
|
+
const cacheKeepalive = options.liveSubagentRegistry
|
|
620
|
+
? new SubagentCacheKeepalive(
|
|
621
|
+
options.plugins?.sessionId ?? sessionManager.getSessionId(),
|
|
622
|
+
options.liveSubagentRegistry,
|
|
623
|
+
(requestModel, context, streamOptions) => modelRuntime.streamSimple(requestModel, context, streamOptions),
|
|
624
|
+
)
|
|
625
|
+
: undefined
|
|
626
|
+
const unsubCacheKeepalive = session.subscribe((event) => {
|
|
627
|
+
if (event.type === 'agent_start') cacheKeepalive?.startTurn()
|
|
628
|
+
if (event.type === 'agent_settled') cacheKeepalive?.settle()
|
|
629
|
+
})
|
|
630
|
+
const innerDispose = session.dispose.bind(session)
|
|
631
|
+
session.dispose = () => {
|
|
632
|
+
void evalRuntime?.dispose()
|
|
633
|
+
cacheKeepalive?.close()
|
|
634
|
+
unsubCacheKeepalive()
|
|
635
|
+
innerDispose()
|
|
636
|
+
}
|
|
567
637
|
|
|
568
638
|
// Wrapping also means `agent.streamFunction !== streamSimple`, which puts pi's
|
|
569
639
|
// summarization auth on its lenient branch (agent-session.js:214-232): a
|
|
@@ -572,21 +642,20 @@ export async function createSessionWithDispose(options: CreateSessionOptions = {
|
|
|
572
642
|
// this function, so every origin now behaves the same way.
|
|
573
643
|
const innerStreamFunction = session.agent.streamFunction
|
|
574
644
|
session.agent.streamFunction = async (requestModel, context, streamOptions) => {
|
|
575
|
-
const maxTokens =
|
|
576
|
-
streamOptions?.maxTokens ??
|
|
577
|
-
(requestModel.maxTokens > 0 ? Math.min(requestModel.maxTokens, DEFAULT_MAX_OUTPUT_TOKENS) : undefined)
|
|
645
|
+
const maxTokens = streamOptions?.maxTokens ?? defaultOutputAllowance(requestModel)
|
|
578
646
|
const promptCacheKey = promptCacheKeyForOrigin(getOrigin())
|
|
579
|
-
const onPayload =
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
647
|
+
const onPayload = async (payload: unknown, payloadModel: typeof requestModel) => {
|
|
648
|
+
const next = (await streamOptions?.onPayload?.(payload, payloadModel)) ?? payload
|
|
649
|
+
const final = promptCacheKey === undefined ? next : withPromptCacheKey(next, promptCacheKey)
|
|
650
|
+
if (streamOptions?.sessionId === session.sessionId) {
|
|
651
|
+
cacheKeepalive?.capture(payloadModel, context, { ...streamOptions, maxTokens }, final)
|
|
652
|
+
}
|
|
653
|
+
return final
|
|
654
|
+
}
|
|
586
655
|
return await innerStreamFunction(requestModel, context, {
|
|
587
656
|
...streamOptions,
|
|
588
657
|
maxTokens,
|
|
589
|
-
|
|
658
|
+
onPayload,
|
|
590
659
|
})
|
|
591
660
|
}
|
|
592
661
|
|
|
@@ -642,6 +711,12 @@ export async function createSessionWithDispose(options: CreateSessionOptions = {
|
|
|
642
711
|
const unsubRestart = subscribeRestartNotice(options.stream, sessionManager)
|
|
643
712
|
|
|
644
713
|
const unsubToolNudge = attachToolNotFoundNudge(session, intendedActiveToolNames)
|
|
714
|
+
// An applied idle summary replaces the prefix the keepalive captured;
|
|
715
|
+
// replaying the old one would only refresh a cache no turn will read.
|
|
716
|
+
const stopIdleCompaction = attachIdleCompaction(session, {
|
|
717
|
+
maxTriggerTokens: maxCompactionTriggerTokens,
|
|
718
|
+
onApplied: () => cacheKeepalive?.invalidate(),
|
|
719
|
+
})
|
|
645
720
|
|
|
646
721
|
// Registered only once creation can no longer fail, so a rejected creation
|
|
647
722
|
// leaves no scope entry behind; tools resolve the scope lazily at call time.
|
|
@@ -653,6 +728,10 @@ export async function createSessionWithDispose(options: CreateSessionOptions = {
|
|
|
653
728
|
)
|
|
654
729
|
: undefined
|
|
655
730
|
const dispose = async () => {
|
|
731
|
+
await evalRuntime?.dispose()
|
|
732
|
+
stopIdleCompaction()
|
|
733
|
+
cacheKeepalive?.close()
|
|
734
|
+
unsubCacheKeepalive()
|
|
656
735
|
releaseSubagentTmp?.()
|
|
657
736
|
unsubLoopGuardTurn()
|
|
658
737
|
unsubRestart?.()
|
|
@@ -695,7 +774,12 @@ export function buildRestartHandoffWiring(
|
|
|
695
774
|
// session. Returns undefined for non-channel/no-author origins.
|
|
696
775
|
export function currentChannelAuthor(getOrigin: () => SessionOrigin | undefined): string | undefined {
|
|
697
776
|
const origin = getOrigin()
|
|
698
|
-
|
|
777
|
+
if (origin?.kind !== 'channel') return undefined
|
|
778
|
+
// The legacy restart record carries only a target-local author ID. Foreign
|
|
779
|
+
// requesters must remain authorless there, matching their target role rules.
|
|
780
|
+
if (adapterNamespace(origin.lastInboundAuthorAdapter ?? origin.adapter) !== adapterNamespace(origin.adapter))
|
|
781
|
+
return undefined
|
|
782
|
+
return origin.lastInboundAuthorId
|
|
699
783
|
}
|
|
700
784
|
|
|
701
785
|
function restartHandoffOriginFor(origin: SessionOrigin): RestartHandoffOrigin | null {
|
|
@@ -821,6 +905,10 @@ export function buildChannelTools(
|
|
|
821
905
|
): ToolDefinition[] {
|
|
822
906
|
if (!channelRouter) return []
|
|
823
907
|
const tools: ToolDefinition[] = []
|
|
908
|
+
const getOutboundOrigin = (): ChannelOutboundOrigin | undefined => {
|
|
909
|
+
const current = getOrigin ? getOrigin() : origin
|
|
910
|
+
return current ? { kind: current.kind, ...(current.kind === 'cron' ? { jobId: current.jobId } : {}) } : undefined
|
|
911
|
+
}
|
|
824
912
|
if (origin?.kind === 'channel') {
|
|
825
913
|
// adapter/workspace/chat/thread are session-key fields and never vary across
|
|
826
914
|
// a session's turns, so they stay snapshotted. The review round does: it is
|
|
@@ -841,21 +929,23 @@ export function buildChannelTools(
|
|
|
841
929
|
createChannelReplyTool({
|
|
842
930
|
router: channelRouter,
|
|
843
931
|
origin: channelOrigin,
|
|
932
|
+
getOutboundOrigin,
|
|
844
933
|
...(sessionId !== undefined ? { sessionId } : {}),
|
|
845
934
|
}),
|
|
846
935
|
)
|
|
847
936
|
if (origin.adapter === 'github' && sessionId !== undefined)
|
|
848
937
|
tools.push(createPostGithubReviewTool({ router: channelRouter, origin: channelOrigin, sessionId }))
|
|
849
938
|
tools.push(createChannelHistoryTool({ router: channelRouter, origin: channelOrigin }))
|
|
850
|
-
tools.push(createChannelReadTool({ router: channelRouter }))
|
|
939
|
+
tools.push(createChannelReadTool({ router: channelRouter, ...(sessionId !== undefined ? { sessionId } : {}) }))
|
|
851
940
|
tools.push(
|
|
852
941
|
createChannelSendTool({
|
|
853
942
|
router: channelRouter,
|
|
854
943
|
origin: channelOrigin,
|
|
944
|
+
getOutboundOrigin,
|
|
855
945
|
...(sessionId !== undefined ? { sessionId } : {}),
|
|
856
946
|
}),
|
|
857
947
|
)
|
|
858
|
-
tools.push(createChannelEditTool({ router: channelRouter }))
|
|
948
|
+
tools.push(createChannelEditTool({ router: channelRouter, getOutboundOrigin }))
|
|
859
949
|
// Read the live turn origin, falling back to the static snapshot when no
|
|
860
950
|
// getter is wired (composition tests). `reactionRef` is per-turn, so the
|
|
861
951
|
// getter is what makes reactions work outside tests.
|
|
@@ -884,11 +974,13 @@ export function buildChannelTools(
|
|
|
884
974
|
tools.push(createChannelDisengageTool({ router: channelRouter, origin: channelOrigin }))
|
|
885
975
|
if (sessionId !== undefined) {
|
|
886
976
|
tools.push(createSkipResponseTool({ router: channelRouter, sessionId }))
|
|
977
|
+
tools.push(createChannelHandoffTool({ router: channelRouter, sessionId }))
|
|
978
|
+
tools.push(createChannelSessionSearchTool({ router: channelRouter, sessionId }))
|
|
887
979
|
}
|
|
888
980
|
} else {
|
|
889
|
-
tools.push(createChannelSendTool({ router: channelRouter }))
|
|
981
|
+
tools.push(createChannelSendTool({ router: channelRouter, getOutboundOrigin }))
|
|
890
982
|
tools.push(createChannelReadTool({ router: channelRouter }))
|
|
891
|
-
tools.push(createChannelEditTool({ router: channelRouter }))
|
|
983
|
+
tools.push(createChannelEditTool({ router: channelRouter, getOutboundOrigin }))
|
|
892
984
|
}
|
|
893
985
|
return tools
|
|
894
986
|
}
|
|
@@ -1180,133 +1272,7 @@ export type CreateResourceLoaderOptions = {
|
|
|
1180
1272
|
// useful; mostly an escape hatch for ad-hoc debugging).
|
|
1181
1273
|
mode?: SystemPromptMode
|
|
1182
1274
|
proactiveNextStepNudge?: boolean
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
// Origins with a conversation partner waiting on the reply get the full-mode
|
|
1186
|
-
// session context: the interactive orchestration context with the live public
|
|
1187
|
-
// roster, the MCP catalog, and the git nudge. Unattended origins (cron fires,
|
|
1188
|
-
// default subagents, system processes) skip that context and the roster/git/MCP
|
|
1189
|
-
// work it needs — their origin block already says what is expected. Every
|
|
1190
|
-
// origin gets the same shared policy either way.
|
|
1191
|
-
//
|
|
1192
|
-
// Exhaustive switch (not a boolean expression) so a future origin kind forces
|
|
1193
|
-
// the author to make an explicit full-or-slim decision at compile time. The
|
|
1194
|
-
// previous form silently defaulted new origins to slim, which would have
|
|
1195
|
-
// stripped the interactive context from a new interactive surface by
|
|
1196
|
-
// accident.
|
|
1197
|
-
export function deriveSystemPromptMode(origin: SessionOrigin | undefined): SystemPromptMode {
|
|
1198
|
-
if (origin === undefined) return 'full'
|
|
1199
|
-
switch (origin.kind) {
|
|
1200
|
-
case 'tui':
|
|
1201
|
-
case 'channel':
|
|
1202
|
-
return 'full'
|
|
1203
|
-
case 'cron':
|
|
1204
|
-
case 'subagent':
|
|
1205
|
-
case 'system':
|
|
1206
|
-
return 'slim'
|
|
1207
|
-
default: {
|
|
1208
|
-
const _exhaustive: never = origin
|
|
1209
|
-
void _exhaustive
|
|
1210
|
-
return 'full'
|
|
1211
|
-
}
|
|
1212
|
-
}
|
|
1213
|
-
}
|
|
1214
|
-
|
|
1215
|
-
// Pure inputs for `composeSystemPrompt`. Each field maps 1:1 to a rendered
|
|
1216
|
-
// section of the prompt; callers that don't want a section pass `undefined`
|
|
1217
|
-
// (or `''` for `gitNudge`). Extracted so the debug dumper in
|
|
1218
|
-
// `scripts/dump-system-prompt.ts` can reuse the exact same composition
|
|
1219
|
-
// pipeline `createResourceLoader` uses, with no risk of drift if the
|
|
1220
|
-
// section order changes.
|
|
1221
|
-
//
|
|
1222
|
-
// `mode` selects only the optional session context, never the policy: every
|
|
1223
|
-
// standard session starts with `buildSystemPolicy(branding)`.
|
|
1224
|
-
// - 'full' (default) — TUI, channel, and origin-less sessions: appends the
|
|
1225
|
-
// interactive context (`renderInteractiveSessionContext`) with the roster.
|
|
1226
|
-
// - 'slim' — cron, default subagents, system processes: no interactive
|
|
1227
|
-
// context; the origin block covers per-kind specifics (no human, side
|
|
1228
|
-
// effects via tools, narrow scope).
|
|
1229
|
-
export type SystemPromptMode = 'full' | 'slim'
|
|
1230
|
-
|
|
1231
|
-
export type SystemPromptComposition = {
|
|
1232
|
-
mode?: SystemPromptMode
|
|
1233
|
-
// Whether the prompt discloses that the agent runs on TypeClaw. When false,
|
|
1234
|
-
// the policy's opening is phrased generically, the `## Runtime` version
|
|
1235
|
-
// block is dropped, and the runtime-disclosure rule is appended. Defaults to
|
|
1236
|
-
// true. Mirrors `config.branding`.
|
|
1237
|
-
branding?: boolean
|
|
1238
|
-
self: string
|
|
1239
|
-
// Pre-rendered interactive-context roster (from `renderPublicSubagentRoster`).
|
|
1240
|
-
// Kept as a ready string so this composer stays pure and registry-free; the
|
|
1241
|
-
// registry-aware caller renders it. Ignored in slim mode (no interactive
|
|
1242
|
-
// context). Falls back to `DEFAULT_SUBAGENT_ROSTER` when omitted.
|
|
1243
|
-
subagentRoster?: string
|
|
1244
|
-
runtimeVersion?: string
|
|
1245
|
-
origin?: SessionOrigin
|
|
1246
|
-
roleContext?: SessionRoleContext
|
|
1247
|
-
mcpCatalog?: string
|
|
1248
|
-
gitNudge: string
|
|
1249
|
-
proactiveNextStepNudge?: string
|
|
1250
|
-
}
|
|
1251
|
-
|
|
1252
|
-
// Section-order contract for the system prompt. Kept as a pure string→string
|
|
1253
|
-
// transform so it can be exercised without disk, plugin runtime, or auth.
|
|
1254
|
-
//
|
|
1255
|
-
// Cache-suffix ordering: least-volatile sections first, most-volatile last.
|
|
1256
|
-
// This minimises the number of cached prompt bytes invalidated when a
|
|
1257
|
-
// section changes (the provider's prompt cache hits up to the first byte
|
|
1258
|
-
// that differs).
|
|
1259
|
-
//
|
|
1260
|
-
// 0. shared policy — identical for every standard session of an agent.
|
|
1261
|
-
// 1. self — IDENTITY.md + SOUL.md (plus any plugin `session.prompt` append).
|
|
1262
|
-
// 2. runtime block (or the runtime-disclosure rule when branding is off) —
|
|
1263
|
-
// only changes on typeclaw releases.
|
|
1264
|
-
// 3. interactive context (full mode) — stable per agent registry, so it
|
|
1265
|
-
// precedes the per-session origin block.
|
|
1266
|
-
// 4. origin block + role — stable across sessions of the same kind; channel
|
|
1267
|
-
// origins carry per-conversation details.
|
|
1268
|
-
// 5. MCP catalog — changes when servers connect or disconnect.
|
|
1269
|
-
// 6. gitNudge — rare changes; agent folders force-commit sessions/ and
|
|
1270
|
-
// memory/ after every turn, so the dirty-files list is empty most of
|
|
1271
|
-
// the time.
|
|
1272
|
-
// 7. proactive next-step nudge — deterministic per model family.
|
|
1273
|
-
//
|
|
1274
|
-
// The wall-clock anchor that used to live here as `## Now` moved out
|
|
1275
|
-
// entirely. It is now injected into the user turn at each `session.prompt`
|
|
1276
|
-
// site via `renderTurnTimeAnchor` (src/agent/system-prompt.ts) so the
|
|
1277
|
-
// stamp reflects the moment of THIS turn, not session creation. Per-turn
|
|
1278
|
-
// injection costs zero cached bytes — the user turn is the non-cacheable
|
|
1279
|
-
// suffix anyway — and removes the staleness failure mode where a session
|
|
1280
|
-
// opened Friday answered "today is Friday" on Thursday. Retrieved memory and
|
|
1281
|
-
// the live channel role ride in the user turn for the same reason.
|
|
1282
|
-
//
|
|
1283
|
-
// pi appends project context (AGENTS.md), the skill catalog, and the cwd
|
|
1284
|
-
// after this preamble when it builds the final system message.
|
|
1285
|
-
export function composeSystemPrompt(parts: SystemPromptComposition): string {
|
|
1286
|
-
const branding = parts.branding ?? true
|
|
1287
|
-
let prompt = `${buildSystemPolicy(branding)}\n\n${parts.self}`
|
|
1288
|
-
if (branding && parts.runtimeVersion !== undefined) {
|
|
1289
|
-
prompt = `${prompt}\n\n${renderRuntimeBlock(parts.runtimeVersion)}`
|
|
1290
|
-
}
|
|
1291
|
-
if (!branding) {
|
|
1292
|
-
prompt = `${prompt}\n\n${renderRuntimeNondisclosureRule()}`
|
|
1293
|
-
}
|
|
1294
|
-
if (parts.mode !== 'slim') {
|
|
1295
|
-
prompt = `${prompt}\n\n${renderInteractiveSessionContext(parts.subagentRoster ?? DEFAULT_SUBAGENT_ROSTER)}`
|
|
1296
|
-
}
|
|
1297
|
-
if (parts.origin !== undefined) {
|
|
1298
|
-
prompt = `${prompt}\n\n${renderSessionOrigin(parts.origin, Date.now(), parts.roleContext)}`
|
|
1299
|
-
}
|
|
1300
|
-
if (parts.mcpCatalog !== undefined && parts.mcpCatalog !== '') {
|
|
1301
|
-
prompt = `${prompt}\n\n${parts.mcpCatalog}`
|
|
1302
|
-
}
|
|
1303
|
-
if (parts.gitNudge !== '') {
|
|
1304
|
-
prompt = `${prompt}\n\n${parts.gitNudge}`
|
|
1305
|
-
}
|
|
1306
|
-
if (parts.proactiveNextStepNudge !== undefined && parts.proactiveNextStepNudge !== '') {
|
|
1307
|
-
prompt = `${prompt}\n\n${parts.proactiveNextStepNudge}`
|
|
1308
|
-
}
|
|
1309
|
-
return prompt
|
|
1275
|
+
evalEnabled?: boolean
|
|
1310
1276
|
}
|
|
1311
1277
|
|
|
1312
1278
|
export async function createResourceLoader(options: CreateResourceLoaderOptions = {}): Promise<DefaultResourceLoader> {
|
|
@@ -1395,6 +1361,7 @@ export async function createResourceLoader(options: CreateResourceLoaderOptions
|
|
|
1395
1361
|
...(roleContext !== undefined ? { roleContext } : {}),
|
|
1396
1362
|
...(mcpCatalog !== undefined ? { mcpCatalog } : {}),
|
|
1397
1363
|
gitNudge,
|
|
1364
|
+
...(options.evalEnabled ? { evalHint: EVAL_PROMPT_HINT } : {}),
|
|
1398
1365
|
...(options.proactiveNextStepNudge === true ? { proactiveNextStepNudge: PROACTIVE_NEXT_STEP_NUDGE } : {}),
|
|
1399
1366
|
})
|
|
1400
1367
|
|
|
@@ -115,17 +115,30 @@ export type StatusSnapshot = {
|
|
|
115
115
|
}
|
|
116
116
|
|
|
117
117
|
export class LiveSubagentRegistry {
|
|
118
|
+
private readonly listeners = new Set<(parentSessionId: string | undefined) => void>()
|
|
118
119
|
private readonly entries = new Map<string, LiveSubagent>()
|
|
119
120
|
private readonly events = new Map<string, SubagentProgressEvent[]>()
|
|
120
121
|
private readonly capturedFinalMessages = new Map<string, string>()
|
|
121
122
|
private readonly pendingWorkKeyRegistrations = new Map<string, Set<PendingWorkKeyRegistration>>()
|
|
122
123
|
|
|
124
|
+
subscribe(listener: (parentSessionId: string | undefined) => void): () => void {
|
|
125
|
+
this.listeners.add(listener)
|
|
126
|
+
return () => {
|
|
127
|
+
this.listeners.delete(listener)
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
private notify(parentSessionId: string | undefined): void {
|
|
132
|
+
for (const listener of this.listeners) listener(parentSessionId)
|
|
133
|
+
}
|
|
134
|
+
|
|
123
135
|
register(live: LiveSubagent): void {
|
|
124
136
|
if (this.entries.has(live.taskId)) {
|
|
125
137
|
throw new Error(`task ${live.taskId} already registered`)
|
|
126
138
|
}
|
|
127
139
|
this.entries.set(live.taskId, live)
|
|
128
140
|
this.events.set(live.taskId, [{ kind: 'started', ts: live.startedAt }])
|
|
141
|
+
this.notify(live.parentSessionId)
|
|
129
142
|
}
|
|
130
143
|
|
|
131
144
|
beginWorkKeyRegistration(workKey: string): PendingWorkKeyRegistration {
|
|
@@ -151,9 +164,11 @@ export class LiveSubagentRegistry {
|
|
|
151
164
|
}
|
|
152
165
|
|
|
153
166
|
unregister(taskId: string): void {
|
|
167
|
+
const entry = this.entries.get(taskId)
|
|
154
168
|
this.entries.delete(taskId)
|
|
155
169
|
this.events.delete(taskId)
|
|
156
170
|
this.capturedFinalMessages.delete(taskId)
|
|
171
|
+
if (entry) this.notify(entry.parentSessionId)
|
|
157
172
|
}
|
|
158
173
|
|
|
159
174
|
get(taskId: string): LiveSubagent | undefined {
|
|
@@ -198,6 +213,7 @@ export class LiveSubagentRegistry {
|
|
|
198
213
|
if (entry === undefined) return
|
|
199
214
|
entry.completion = completion
|
|
200
215
|
entry.status = completion.ok ? 'completed' : 'failed'
|
|
216
|
+
this.notify(entry.parentSessionId)
|
|
201
217
|
}
|
|
202
218
|
|
|
203
219
|
// First-writer-wins settlement, returning whether THIS caller won. A subagent
|
|
@@ -215,6 +231,7 @@ export class LiveSubagentRegistry {
|
|
|
215
231
|
if (entry === undefined || entry.status !== 'running') return false
|
|
216
232
|
entry.completion = completion
|
|
217
233
|
entry.status = completion.ok ? 'completed' : 'failed'
|
|
234
|
+
this.notify(entry.parentSessionId)
|
|
218
235
|
return true
|
|
219
236
|
}
|
|
220
237
|
|
|
@@ -288,10 +305,12 @@ export class LiveSubagentRegistry {
|
|
|
288
305
|
|
|
289
306
|
clear(): void {
|
|
290
307
|
// Shutdown must not erase evidence of children that have not terminated.
|
|
308
|
+
const parents = new Set(Array.from(this.entries.values(), (entry) => entry.parentSessionId))
|
|
291
309
|
this.entries.clear()
|
|
292
310
|
this.events.clear()
|
|
293
311
|
this.capturedFinalMessages.clear()
|
|
294
312
|
this.pendingWorkKeyRegistrations.clear()
|
|
313
|
+
for (const parent of parents) this.notify(parent)
|
|
295
314
|
}
|
|
296
315
|
|
|
297
316
|
private removePendingWorkKeyRegistration(registration: PendingWorkKeyRegistration): void {
|
|
@@ -116,19 +116,28 @@ export function createChannelLookAtTool(
|
|
|
116
116
|
description:
|
|
117
117
|
'View an image attached to a channel message. Inbound messages show ' +
|
|
118
118
|
'`[<Platform> attachment #N: <kind> <metadata>]`; pass `N` as `attachment_id`. Do not invent ids. ' +
|
|
119
|
-
'Images on the CURRENT inbound resolve directly; for
|
|
120
|
-
'
|
|
119
|
+
'Images on the CURRENT inbound resolve directly; for an EARLIER message call channel_history first. ' +
|
|
120
|
+
'On Slack pass file_id when the request names an exact file or several messages reuse #1.',
|
|
121
121
|
parameters: Type.Object({
|
|
122
122
|
attachment_id: Type.Integer({
|
|
123
123
|
description: 'The number N from the inbound `[<Platform> attachment #N: ...]` placeholder.',
|
|
124
124
|
minimum: 1,
|
|
125
125
|
}),
|
|
126
|
+
file_id: Type.Optional(
|
|
127
|
+
Type.String({ pattern: '^F[A-Z0-9]+$', description: 'Exact Slack file ID from the request or history.' }),
|
|
128
|
+
),
|
|
126
129
|
prompt: Type.Optional(
|
|
127
130
|
Type.String({ description: 'Optional question to ask about the image; omitted means describe it.' }),
|
|
128
131
|
),
|
|
129
132
|
}),
|
|
130
133
|
async execute(_toolCallId, params) {
|
|
131
|
-
|
|
134
|
+
if (params.file_id !== undefined && origin.adapter !== 'slack' && origin.adapter !== 'slack-bot')
|
|
135
|
+
return errorResult('file_id is only supported for Slack attachments', { count: 0, prompt: params.prompt })
|
|
136
|
+
const found = router.lookupInboundAttachment({
|
|
137
|
+
...origin,
|
|
138
|
+
id: params.attachment_id,
|
|
139
|
+
...(params.file_id !== undefined ? { ref: params.file_id } : {}),
|
|
140
|
+
})
|
|
132
141
|
if (found === null) {
|
|
133
142
|
const validIds = router.listInboundAttachmentIds(origin)
|
|
134
143
|
const validMsg =
|
|
@@ -151,12 +160,16 @@ export function createChannelLookAtTool(
|
|
|
151
160
|
maxBytes: LOOK_AT_MAX_BYTES,
|
|
152
161
|
...(found.filename !== undefined ? { filename: found.filename } : {}),
|
|
153
162
|
})
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
163
|
+
const viewed = result.ok
|
|
164
|
+
? await runLookAtImages(
|
|
165
|
+
[toImageContent(result.buffer.toString('base64'), result.mimetype ?? 'image/jpeg')],
|
|
166
|
+
params.prompt,
|
|
167
|
+
permissions,
|
|
168
|
+
)
|
|
169
|
+
: errorResult(result.error, { count: 0, prompt: params.prompt })
|
|
170
|
+
if (origin.adapter === 'slack' || origin.adapter === 'slack-bot')
|
|
171
|
+
viewed.content.unshift({ type: 'text', text: `Selected Slack file_id=${found.ref}` })
|
|
172
|
+
return viewed
|
|
160
173
|
},
|
|
161
174
|
})
|
|
162
175
|
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export const DEFAULT_MAX_OUTPUT_TOKENS = 32_000
|
|
2
|
+
|
|
3
|
+
// The output cap every session request sends when the caller set none.
|
|
4
|
+
// Undefined leaves the provider's own default in place.
|
|
5
|
+
export function defaultOutputAllowance(model: { maxTokens: number }): number | undefined {
|
|
6
|
+
return model.maxTokens > 0 ? Math.min(model.maxTokens, DEFAULT_MAX_OUTPUT_TOKENS) : undefined
|
|
7
|
+
}
|