typeclaw 0.49.0 → 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 +9 -2
- 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/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 +74 -16
- package/src/agent/live-subagents.ts +19 -0
- package/src/agent/multimodal/look-at.ts +22 -9
- package/src/agent/plugin-tools.ts +13 -1
- package/src/agent/reviewer-bash-policy.ts +41 -1
- package/src/agent/session-origin.ts +26 -10
- package/src/agent/subagent-cache-keepalive.ts +198 -0
- package/src/agent/subagent-session.ts +6 -0
- package/src/agent/subagents.ts +46 -8
- package/src/agent/system-prompt.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 +13 -5
- 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/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/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 +4 -0
- package/src/bundled-plugins/github-cli-auth/git-auth-diagnostic.ts +95 -0
- package/src/bundled-plugins/github-cli-auth/index.ts +75 -59
- 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 +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/channels/adapter-namespace.ts +13 -0
- package/src/channels/adapters/discord-bot.ts +97 -5
- 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-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 +427 -136
- 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/types.ts +12 -2
- package/src/cli/channel.ts +2 -3
- 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 +111 -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 +59 -0
- package/src/container/start.ts +95 -4
- package/src/doctor/checks.ts +8 -6
- 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/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/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/hidden-paths.ts +16 -2
- package/src/secrets/storage.ts +13 -0
- package/src/skills/typeclaw-channel-github/SKILL.md +8 -8
- package/src/skills/typeclaw-config/SKILL.md +39 -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 +436 -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/channels/router.ts
CHANGED
|
@@ -34,24 +34,27 @@ import { SUBAGENT_OUTPUT_TOOL_NAME } from '@/agent/tools/subagent-output'
|
|
|
34
34
|
import { promptPersistentTurnWithFallback } from '@/agent/turn-runner'
|
|
35
35
|
import { type Command, type CommandPermission, type CommandResult, createCommandRegistry } from '@/commands'
|
|
36
36
|
import { getConfig, resolveModel } from '@/config'
|
|
37
|
-
import {
|
|
38
|
-
import type
|
|
37
|
+
import { effectiveModels } from '@/config/model-overrides'
|
|
38
|
+
import { CORE_PERMISSIONS, type MatchableOrigin, type PermissionService } from '@/permissions'
|
|
39
|
+
import type { ChannelOutboundBeforeEvent, ChannelOutboundOrigin, HookBus } from '@/plugin'
|
|
39
40
|
import { extractClaimCode } from '@/role-claim'
|
|
40
41
|
import type { Stream } from '@/stream'
|
|
41
42
|
|
|
43
|
+
import { adapterNamespace } from './adapter-namespace'
|
|
42
44
|
import { extractMentionedUserIds } from './adapters/mention-hints'
|
|
43
45
|
import {
|
|
44
46
|
BackgroundObligationStore,
|
|
45
47
|
type BackgroundObligation,
|
|
46
48
|
type BackgroundObligationRef,
|
|
47
49
|
} from './background-obligations'
|
|
50
|
+
import { createInboundCatchUp, type ListMissedInbound } from './catch-up'
|
|
48
51
|
import { formatChannelCommandHelp } from './commands'
|
|
49
52
|
import { isQualifyingWorkResult } from './completion-claim'
|
|
50
53
|
import { detectContinuationWillingness } from './continuation-willingness'
|
|
51
54
|
import type { RecoveryFailure, RecoveryRecord } from './continuity-types'
|
|
52
55
|
import { describeError } from './describe-error'
|
|
53
56
|
import {
|
|
54
|
-
|
|
57
|
+
countEngagementHumans,
|
|
55
58
|
decideEngagement,
|
|
56
59
|
grantStickyForReplyTargets,
|
|
57
60
|
isMultiHumanGroup,
|
|
@@ -109,6 +112,13 @@ import {
|
|
|
109
112
|
type ReadCapability,
|
|
110
113
|
type WriteCapability,
|
|
111
114
|
} from './schema'
|
|
115
|
+
import { checkHandoffAccess, createSessionHandoff, type ChannelHandoffResult } from './session-handoff'
|
|
116
|
+
import {
|
|
117
|
+
createSessionSearch,
|
|
118
|
+
type SessionActivity,
|
|
119
|
+
type SessionSearchArgs,
|
|
120
|
+
type SessionSearchTarget,
|
|
121
|
+
} from './session-search'
|
|
112
122
|
import type {
|
|
113
123
|
ChannelHistoryMessage,
|
|
114
124
|
ChannelKey,
|
|
@@ -243,6 +253,7 @@ export const SESSION_GC_INTERVAL_MS = 60 * 1000
|
|
|
243
253
|
export const MAX_CHANNEL_SENDS_PER_TURN = 10
|
|
244
254
|
export const ENGAGE_REACTION_EMOJI = 'eyes'
|
|
245
255
|
export const CONTINUATION_REACTION_EMOJI = 'hourglass_flowing_sand'
|
|
256
|
+
export const QUEUED_REACTION_EMOJI = 'hourglass_flowing_sand'
|
|
246
257
|
// Marks the triggering message of a turn that failed for a reason the user can
|
|
247
258
|
// only answer by retrying, in place of a chat notice. Adapters that cannot
|
|
248
259
|
// render it (GitHub's fixed set, reaction-less platforms) get the text notice.
|
|
@@ -394,7 +405,7 @@ export const EMPTY_TURN_RETRY_NUDGE = [
|
|
|
394
405
|
// Reminder-only nudge for the stranded-toolUse-after-send retry. Distinct from
|
|
395
406
|
// EMPTY_TURN_RETRY_NUDGE: that one diagnoses output-budget exhaustion and tells
|
|
396
407
|
// the model to "answer directly", which makes a stranded investigation RE-RUN
|
|
397
|
-
// its tools and strand again. Here the model already sent a `
|
|
408
|
+
// its tools and strand again. Here the model already sent a `continue_after_reply: true`
|
|
398
409
|
// status ack and did real tool work; the turn just ended on an unanswered
|
|
399
410
|
// toolUse before final prose. The prior toolUse/toolResult entries are still in
|
|
400
411
|
// this session's branch on the re-prompt, so the recovery is to STOP, read what
|
|
@@ -450,7 +461,7 @@ export const COLD_START_REPLY_NUDGE = [
|
|
|
450
461
|
// both EMPTY_TURN_RETRY_NUDGE (which misdiagnoses a clean `stop` as output-budget
|
|
451
462
|
// exhaustion and, per its own docstring, makes the model RE-RUN its tools and
|
|
452
463
|
// strand again) and STRANDED_TOOLUSE_CONTINUATION_NUDGE (which assumes a
|
|
453
|
-
// `
|
|
464
|
+
// `continue_after_reply: true` status reply already landed). Here NO send landed,
|
|
454
465
|
// the model gathered real
|
|
455
466
|
// tool results, then the final completion came back as a bare empty `stop` — the
|
|
456
467
|
// Fireworks/gpt empty-completion degeneration. The recovery is to READ the results
|
|
@@ -478,7 +489,7 @@ export const EMPTY_STOP_AFTER_TOOL_WORK_NUDGE = [
|
|
|
478
489
|
// is a one-shot correction offer, not recovery from no output.
|
|
479
490
|
export const MAX_WILLINGNESS_NUDGES = 1
|
|
480
491
|
// Injected when a reply that ended the turn (terminal-reply abort) promised to
|
|
481
|
-
// keep working but omitted `
|
|
492
|
+
// keep working but omitted `continue_after_reply: true`. Reminder-only, SYSTEM MESSAGE
|
|
482
493
|
// framing so persona-rich models do not reply to the notice itself.
|
|
483
494
|
// Leads with the DELIVERY imperative, mirroring SEND_WILLINGNESS_NUDGE below. An
|
|
484
495
|
// earlier revision closed on a bare "If there is nothing left to do, reply with
|
|
@@ -493,13 +504,13 @@ export const WILLINGNESS_NUDGE = [
|
|
|
493
504
|
'',
|
|
494
505
|
'Your last reply promised the human you would keep working, but the turn ended',
|
|
495
506
|
'right after sending — a successful channel reply ends the turn unless you set',
|
|
496
|
-
'`
|
|
507
|
+
'`continue_after_reply: true` on it. This is an automated signal from the channel',
|
|
497
508
|
'router, not a message from anyone in the chat. **Do not acknowledge or reply to',
|
|
498
509
|
'this notice itself.**',
|
|
499
510
|
'',
|
|
500
511
|
'Someone is waiting on the result you just promised. Do the work now (fetch data,',
|
|
501
512
|
'run a tool, spawn a subagent) and post what you find — and on any further status',
|
|
502
|
-
'reply that precedes more work this turn, set `
|
|
513
|
+
'reply that precedes more work this turn, set `continue_after_reply: true`. If you',
|
|
503
514
|
'already did the work, post the conclusion you reached: having no work left is NOT',
|
|
504
515
|
'the same as having nothing to report, and a promise that never lands reads to the',
|
|
505
516
|
'human as being ignored.',
|
|
@@ -512,7 +523,7 @@ export const WILLINGNESS_NUDGE = [
|
|
|
512
523
|
// did fresh work after it, then ended on an EMPTY `stop` leaf — the answer was
|
|
513
524
|
// computed but never sent (the Kimi/Fireworks empty-completion flake). Distinct
|
|
514
525
|
// from WILLINGNESS_NUDGE: that path is a `channel_reply` that ended the turn and
|
|
515
|
-
// needs `
|
|
526
|
+
// needs `continue_after_reply: true`; this path is a `channel_send` (which never ends the
|
|
516
527
|
// turn) whose follow-up degenerated, so the model just needs to emit the reply it
|
|
517
528
|
// already worked out. Shares MAX_WILLINGNESS_NUDGES so a turn can't double-nudge.
|
|
518
529
|
// Scopes NO_REPLY the same way WILLINGNESS_NUDGE does, and for the same reason:
|
|
@@ -752,12 +763,17 @@ export type CreateSessionForChannel = (params: {
|
|
|
752
763
|
|
|
753
764
|
export type ConfigForAdapter = (adapter: ChannelKey['adapter']) => ChannelAdapterConfig | undefined
|
|
754
765
|
|
|
766
|
+
export type { ChannelHandoffResult } from './session-handoff'
|
|
767
|
+
|
|
768
|
+
const CONVERSATION_ORIGIN_WINDOW_MS = 30 * 60_000
|
|
769
|
+
|
|
755
770
|
type QueuedInbound = {
|
|
756
771
|
inputId: string
|
|
757
772
|
text: string
|
|
758
773
|
referenceContext?: InboundReferenceContext
|
|
759
774
|
attachments?: readonly InboundAttachment[]
|
|
760
775
|
authorId: string
|
|
776
|
+
authorAdapter?: AdapterId
|
|
761
777
|
authorName: string
|
|
762
778
|
authorIsBot: boolean
|
|
763
779
|
externalMessageId: string
|
|
@@ -777,6 +793,8 @@ type QueuedInbound = {
|
|
|
777
793
|
ts: number
|
|
778
794
|
githubReviewRound?: GithubReviewFollowupRound
|
|
779
795
|
githubReviewThreadCloseout?: GithubReviewThreadCloseout
|
|
796
|
+
routingNote?: string
|
|
797
|
+
handoff?: true
|
|
780
798
|
}
|
|
781
799
|
|
|
782
800
|
type ObservedInbound = {
|
|
@@ -803,7 +821,7 @@ type ObservedInbound = {
|
|
|
803
821
|
source: 'prefetch' | 'observed'
|
|
804
822
|
}
|
|
805
823
|
|
|
806
|
-
type TimedAttachment = { ts: number; attachment: InboundAttachment }
|
|
824
|
+
type TimedAttachment = { ts: number; attachment: InboundAttachment; current?: boolean }
|
|
807
825
|
|
|
808
826
|
type ChannelAgentSession = AgentSession & { getAbortReason?: () => string | undefined }
|
|
809
827
|
|
|
@@ -867,6 +885,8 @@ type PendingReloadCoverage = {
|
|
|
867
885
|
// Author context a completion-only wake needs for author-scoped role
|
|
868
886
|
// resolution, exactly as the reloaded session would have restored it.
|
|
869
887
|
lastTurnAuthorId: string | null
|
|
888
|
+
lastTurnAuthorAdapter: AdapterId
|
|
889
|
+
lastTurnHandoff: boolean
|
|
870
890
|
lastTurnAuthorIds: string[]
|
|
871
891
|
}
|
|
872
892
|
|
|
@@ -949,18 +969,10 @@ type LiveSession = {
|
|
|
949
969
|
// are empty. This turn-scoped snapshot, populated right after the splice
|
|
950
970
|
// and cleared when the turn ends, is what the lookup reads so a freshly-
|
|
951
971
|
// arrived attachment stays resolvable for the whole turn it belongs to.
|
|
952
|
-
currentTurnAttachments: readonly
|
|
953
|
-
//
|
|
954
|
-
//
|
|
955
|
-
// turn-scoped queue above, so look_at/fetch can't resolve it; stashing the
|
|
956
|
-
// fetched refs here makes the same `attachment_id: N` resolvable. MUST be
|
|
957
|
-
// searched LAST so a live `#1` still wins over a historical `#1` (the
|
|
958
|
-
// newest-first collision rule lookupInboundAttachment documents). Bounded,
|
|
959
|
-
// never persisted, never exposes the ref to the model. historyTimedAttachments
|
|
960
|
-
// is the ts-tagged source of truth (ordered oldest→newest, deduped by id);
|
|
961
|
-
// historyAttachments is its flat projection consumed by the lookup helpers.
|
|
972
|
+
currentTurnAttachments: readonly TimedAttachment[]
|
|
973
|
+
// Message-local numbers may collide. Keep timestamped history refs so an
|
|
974
|
+
// observed old #1 cannot shadow a newer file discovered through history.
|
|
962
975
|
historyTimedAttachments: readonly TimedAttachment[]
|
|
963
|
-
historyAttachments: InboundAttachment[]
|
|
964
976
|
draining: boolean
|
|
965
977
|
// Every drain invocation still running, including the tail it executes after
|
|
966
978
|
// `draining` flips back to false. `drain()` deliberately no-ops while a drain
|
|
@@ -986,6 +998,7 @@ type LiveSession = {
|
|
|
986
998
|
// leaks a timer that fires past the turn's end.
|
|
987
999
|
promptInFlight: boolean
|
|
988
1000
|
lastInboundAt: number
|
|
1001
|
+
recentMessages: SessionActivity[]
|
|
989
1002
|
// Transcript-file size (bytes) captured immediately after cold-start, before
|
|
990
1003
|
// any user turn — a proxy for the fixed base-context rebuild cost (rendered
|
|
991
1004
|
// system prompt + injected memory + prefetched channel context). Read by the
|
|
@@ -994,6 +1007,7 @@ type LiveSession = {
|
|
|
994
1007
|
baseContextBytes: number
|
|
995
1008
|
firstUnprocessedAt: number
|
|
996
1009
|
currentTurnAuthorId: string | null
|
|
1010
|
+
currentTurnAuthorAdapter: AdapterId
|
|
997
1011
|
currentTurnAuthorIds: Set<string>
|
|
998
1012
|
// Reaction target of the inbound that triggered THIS turn (the last item in
|
|
999
1013
|
// the drained batch, mirroring `currentTurnAuthorId`). Surfaced on the live
|
|
@@ -1012,6 +1026,13 @@ type LiveSession = {
|
|
|
1012
1026
|
// and target cannot disagree. Reset with `currentTurnReactionRef` in the drain
|
|
1013
1027
|
// finally; preserved across reminder-only iterations exactly like it.
|
|
1014
1028
|
currentTurnExplicitlyAddressed: boolean
|
|
1029
|
+
// True when THIS turn's batch carries a cross-session handoff inbound. The
|
|
1030
|
+
// handoff loop guard: a handoff-started turn cannot hand off again.
|
|
1031
|
+
currentTurnHandoff: boolean
|
|
1032
|
+
// Whether the most recent inbound was private, for handoff context framing.
|
|
1033
|
+
lastInboundIsDm: boolean
|
|
1034
|
+
// Hint each recently visited conversation only once in this session.
|
|
1035
|
+
originHintedKeys: Set<string>
|
|
1015
1036
|
// Typing-status anchor of the inbound that triggered THIS turn (last item in
|
|
1016
1037
|
// the drained batch, mirroring `currentTurnReactionRef`). Adapter-opaque ts
|
|
1017
1038
|
// carried only to the typing path; null when the triggering inbound supplied
|
|
@@ -1053,6 +1074,8 @@ type LiveSession = {
|
|
|
1053
1074
|
// inserted into Set"), so a multi-author prior turn like alice→bob
|
|
1054
1075
|
// restores `bob`, the same identity normal turns would have used.
|
|
1055
1076
|
lastTurnAuthorId: string | null
|
|
1077
|
+
lastTurnAuthorAdapter: AdapterId
|
|
1078
|
+
lastTurnHandoff: boolean
|
|
1056
1079
|
consecutiveAborts: number
|
|
1057
1080
|
// Per-(chat:thread) count of bot messages sent without intervening user
|
|
1058
1081
|
// input being rendered into the model's context. Reset at the top of each
|
|
@@ -1100,7 +1123,7 @@ type LiveSession = {
|
|
|
1100
1123
|
// channel send landed this turn. `validateChannelTurn` compares it to the
|
|
1101
1124
|
// turn-end leaf: a DIFFERENT assistant `stop` leaf means the model replied,
|
|
1102
1125
|
// kept working, then ended with FRESH final prose it forgot to deliver
|
|
1103
|
-
// (the `
|
|
1126
|
+
// (the `continue_after_reply: true` progress-reply bug) — recover it. A leaf that still
|
|
1104
1127
|
// matches is narration the model emitted BEFORE/with the reply that already
|
|
1105
1128
|
// landed, so it stays suppressed. Reset to null on every new prompt batch.
|
|
1106
1129
|
lastSendLeafId: string | null
|
|
@@ -1190,7 +1213,7 @@ type LiveSession = {
|
|
|
1190
1213
|
// nudge itself queues — same anti-reloop discipline as the empty-turn budget.
|
|
1191
1214
|
willingnessNudges: number
|
|
1192
1215
|
// Stashed by `installChannelReplyTerminalHook` after a successful
|
|
1193
|
-
// `channel_reply` that omitted `
|
|
1216
|
+
// `channel_reply` that omitted `continue_after_reply: true`. Read once
|
|
1194
1217
|
// by `validateChannelTurn` to decide the continuation nudge. `turnSeq`-stamped
|
|
1195
1218
|
// (like `skippedTurn`/`skipLockedSendTurn`) so a stale record from an earlier
|
|
1196
1219
|
// turn can never trigger a nudge on a later one. `null` when no such reply
|
|
@@ -1204,7 +1227,7 @@ type LiveSession = {
|
|
|
1204
1227
|
// assistant. Cleared on consumption, stop, or a fresh user turn.
|
|
1205
1228
|
pendingTerminalReplyStop: { turnSeq: number; tokens: number } | null
|
|
1206
1229
|
// Stamped by `installChannelReplyTerminalHook` when a successful `channel_reply`
|
|
1207
|
-
// set `
|
|
1230
|
+
// set `continue_after_reply: true` — the machine-readable "I'll keep working this turn"
|
|
1208
1231
|
// promise. `validateChannelTurn` reads it to recover a turn that made that promise,
|
|
1209
1232
|
// did more work, then ended on a fresh empty `stop` (dropped its conclusion) —
|
|
1210
1233
|
// independent of what natural-language phrase the ack used, so a persona speaking
|
|
@@ -1271,7 +1294,7 @@ type LiveSession = {
|
|
|
1271
1294
|
emptyTurnFallbackTurn: number | null
|
|
1272
1295
|
// Set when a WILLINGNESS-ACK exhaustion path (empty_stop_after_continue_reply /
|
|
1273
1296
|
// empty_stop_after_send_ack) would post EMPTY_TURN_FALLBACK_TEXT, but the model
|
|
1274
|
-
// just made a machine-readable promise to keep working (`
|
|
1297
|
+
// just made a machine-readable promise to keep working (`continue_after_reply: true` /
|
|
1275
1298
|
// willingness phrase) and did post-ack tool work. Rather than posting the scary
|
|
1276
1299
|
// "I got stuck" notice synchronously at validateChannelTurn — BEFORE the drain
|
|
1277
1300
|
// loop runs maybeContinueTodosChannel, which can re-prompt the same logical turn
|
|
@@ -1330,7 +1353,7 @@ type LiveSession = {
|
|
|
1330
1353
|
// this logical turn. Unlike toolExecutionThisLogicalTurn, channel_reply and
|
|
1331
1354
|
// todo/control calls cannot satisfy a later durable completion claim.
|
|
1332
1355
|
qualifyingWorkThisLogicalTurn: boolean
|
|
1333
|
-
// True while a successful `channel_reply({
|
|
1356
|
+
// True while a successful `channel_reply({ continue_after_reply: true })`
|
|
1334
1357
|
// promise remains unfulfilled in this LOGICAL turn. Unlike the per-iteration
|
|
1335
1358
|
// `continueReplyTurn` stamp used by retry authorization and empty-stop
|
|
1336
1359
|
// recovery, this survives reminder-only iterations so a provider failure
|
|
@@ -1343,7 +1366,7 @@ type LiveSession = {
|
|
|
1343
1366
|
// True while the latest landed output accounted to this logical turn was a
|
|
1344
1367
|
// continuation-willingness/status message ("I'll check and get back to you"):
|
|
1345
1368
|
// the turn told the user more was coming without the machine-readable
|
|
1346
|
-
// `
|
|
1369
|
+
// `continue_after_reply` flag. A substantive send clears it; meta notices
|
|
1347
1370
|
// (provider error, fallbacks) leave it. Together with
|
|
1348
1371
|
// `promisedWorkOutstandingThisLogicalTurn` it marks promised unfinished work,
|
|
1349
1372
|
// which explicit silence can never settle. Reset with the logical turn.
|
|
@@ -1466,8 +1489,13 @@ export type SendOptions = TransportSendOptions & {
|
|
|
1466
1489
|
// set it explicitly because recovery prose fulfills promised work whereas
|
|
1467
1490
|
// provider/fallback/control notices are meta output and must not.
|
|
1468
1491
|
outputKind?: 'substantive' | 'status' | 'meta'
|
|
1492
|
+
// Runtime-owned provenance; never populated from model tool arguments.
|
|
1493
|
+
origin?: ChannelOutboundOrigin
|
|
1469
1494
|
}
|
|
1470
1495
|
|
|
1496
|
+
export type EditMessageOptions = { origin?: ChannelOutboundOrigin }
|
|
1497
|
+
export type ChannelOutboundReviewer = (event: ChannelOutboundBeforeEvent) => Promise<{ text: string }>
|
|
1498
|
+
|
|
1471
1499
|
export const DUPLICATE_SEND_ERROR =
|
|
1472
1500
|
'Duplicate not sent. Do not call channel_send/channel_reply again this turn. ' +
|
|
1473
1501
|
'End with NO_REPLY unless you have genuinely new, non-redundant information.'
|
|
@@ -1482,6 +1510,11 @@ export const SKIP_RESPONSE_LOCK_ERROR =
|
|
|
1482
1510
|
'something to say, send it on the next turn.'
|
|
1483
1511
|
|
|
1484
1512
|
export type ChannelRouter = {
|
|
1513
|
+
registerMissedInbound: (adapter: AdapterId, callback: ListMissedInbound) => void
|
|
1514
|
+
unregisterMissedInbound: (adapter: AdapterId, callback: ListMissedInbound) => void
|
|
1515
|
+
catchUp: (adapter: AdapterId) => Promise<void>
|
|
1516
|
+
disconnectCatchUp: (adapter: AdapterId) => void
|
|
1517
|
+
catchUpTargets: (adapter: AdapterId) => Promise<readonly ChannelKey[]>
|
|
1485
1518
|
route: (event: InboundMessage, onAdmitted?: () => Promise<void>) => Promise<RouteReceipt>
|
|
1486
1519
|
send: (msg: OutboundMessage, opts?: SendOptions) => Promise<SendResult>
|
|
1487
1520
|
acceptBackgroundResponse: (args: {
|
|
@@ -1602,7 +1635,11 @@ export type ChannelRouter = {
|
|
|
1602
1635
|
// send()'s flood/cap/dup/sticky guards.
|
|
1603
1636
|
registerEditMessage: (adapter: ChannelKey['adapter'], cb: EditMessageCallback) => void
|
|
1604
1637
|
unregisterEditMessage: (adapter: ChannelKey['adapter'], cb: EditMessageCallback) => void
|
|
1605
|
-
editMessage: (req: EditMessageRequest) => Promise<EditMessageResult>
|
|
1638
|
+
editMessage: (req: EditMessageRequest, opts?: EditMessageOptions) => Promise<EditMessageResult>
|
|
1639
|
+
// Direct adapter control responses use the same transform without entering
|
|
1640
|
+
// send accounting, sticky engagement or turn-completion bookkeeping.
|
|
1641
|
+
reviewOutbound: (event: ChannelOutboundBeforeEvent) => Promise<string>
|
|
1642
|
+
hasOutboundReviewer: () => boolean
|
|
1606
1643
|
registerFetchAttachment: (adapter: ChannelKey['adapter'], cb: FetchAttachmentCallback) => void
|
|
1607
1644
|
unregisterFetchAttachment: (adapter: ChannelKey['adapter'], cb: FetchAttachmentCallback) => void
|
|
1608
1645
|
fetchAttachment: (adapter: ChannelKey['adapter'], args: FetchAttachmentArgs) => Promise<FetchAttachmentResult>
|
|
@@ -1623,7 +1660,7 @@ export type ChannelRouter = {
|
|
|
1623
1660
|
registerReviewSubmitter: (adapter: ChannelKey['adapter'], submitter: ReviewSubmitter) => void
|
|
1624
1661
|
unregisterReviewSubmitter: (adapter: ChannelKey['adapter'], submitter: ReviewSubmitter) => void
|
|
1625
1662
|
submitReview: (req: SubmitReviewRequest) => Promise<SubmitReviewResult>
|
|
1626
|
-
lookupInboundAttachment: (args: ChannelKey & { id: number }) => InboundAttachment | null
|
|
1663
|
+
lookupInboundAttachment: (args: ChannelKey & { id: number; ref?: string }) => InboundAttachment | null
|
|
1627
1664
|
listInboundAttachmentIds: (args: ChannelKey) => readonly number[]
|
|
1628
1665
|
// Stash refs from a channel_history fetch so prior-turn attachments stay
|
|
1629
1666
|
// resolvable by their placeholder id. Called by the channel_history tool
|
|
@@ -1657,6 +1694,12 @@ export type ChannelRouter = {
|
|
|
1657
1694
|
// session was found and the reminder was queued, `no-live-session`
|
|
1658
1695
|
// otherwise. Used by the subagent-completion bridge in
|
|
1659
1696
|
// src/run/index.ts; safe for tests to call directly via a fake router.
|
|
1697
|
+
// Delegate work to the live session that owns `target` on any adapter instead of
|
|
1698
|
+
// posting there blind. Routed as a synthetic inbound authored by the source
|
|
1699
|
+
// turn's requester, so it queues behind any running turn and re-checks the
|
|
1700
|
+
// requester's target role without linking identities across platforms.
|
|
1701
|
+
handoff: (args: { fromSessionId: string; target: ChannelKey; text: string }) => Promise<ChannelHandoffResult>
|
|
1702
|
+
searchSessions: (args: SessionSearchArgs) => SessionSearchTarget[]
|
|
1660
1703
|
injectSubagentCompletionReminder: (args: {
|
|
1661
1704
|
parentSessionId: string
|
|
1662
1705
|
subagent: string
|
|
@@ -1930,6 +1973,8 @@ export type CreateChannelRouterOptions = {
|
|
|
1930
1973
|
workKey: string,
|
|
1931
1974
|
reason: string,
|
|
1932
1975
|
) => Promise<{ matched: number; cancelled: number; failures: number }>
|
|
1976
|
+
reviewOutbound?: ChannelOutboundReviewer
|
|
1977
|
+
outboundReviewerActive?: () => boolean
|
|
1933
1978
|
}
|
|
1934
1979
|
|
|
1935
1980
|
export type RestartCommandContext = {
|
|
@@ -2694,6 +2739,8 @@ export function createChannelRouter(options: CreateChannelRouterOptions): Channe
|
|
|
2694
2739
|
coverageDeferredParentSessionId: live.coverageDeferredParentSessionId,
|
|
2695
2740
|
...(live.turnAccountIdentity !== undefined ? { turnAccountIdentity: live.turnAccountIdentity } : {}),
|
|
2696
2741
|
lastTurnAuthorId: live.lastTurnAuthorId,
|
|
2742
|
+
lastTurnAuthorAdapter: live.lastTurnAuthorAdapter,
|
|
2743
|
+
lastTurnHandoff: live.lastTurnHandoff,
|
|
2697
2744
|
lastTurnAuthorIds: [...live.lastTurnAuthorIds],
|
|
2698
2745
|
})
|
|
2699
2746
|
|
|
@@ -2938,6 +2985,8 @@ export function createChannelRouter(options: CreateChannelRouterOptions): Channe
|
|
|
2938
2985
|
if (coverage.turnAccountIdentity !== undefined) live.turnAccountIdentity = coverage.turnAccountIdentity
|
|
2939
2986
|
if (live.lastTurnAuthorId === null && coverage.lastTurnAuthorId !== null) {
|
|
2940
2987
|
live.lastTurnAuthorId = coverage.lastTurnAuthorId
|
|
2988
|
+
live.lastTurnAuthorAdapter = coverage.lastTurnAuthorAdapter
|
|
2989
|
+
live.lastTurnHandoff = coverage.lastTurnHandoff
|
|
2941
2990
|
live.lastTurnAuthorIds = new Set(coverage.lastTurnAuthorIds)
|
|
2942
2991
|
}
|
|
2943
2992
|
}
|
|
@@ -3218,7 +3267,7 @@ export function createChannelRouter(options: CreateChannelRouterOptions): Channe
|
|
|
3218
3267
|
keyId,
|
|
3219
3268
|
room,
|
|
3220
3269
|
session: created.session,
|
|
3221
|
-
activeModelRef: resolveFallbackChain(getConfig()
|
|
3270
|
+
activeModelRef: resolveFallbackChain(effectiveModels(getConfig(), origin), undefined)[0]!,
|
|
3222
3271
|
turnThinkingDefault: created.session.thinkingLevel,
|
|
3223
3272
|
lastQuestionSignal: null,
|
|
3224
3273
|
pendingUserTurnSignal: null,
|
|
@@ -3252,7 +3301,6 @@ export function createChannelRouter(options: CreateChannelRouterOptions): Channe
|
|
|
3252
3301
|
contextBuffer: [],
|
|
3253
3302
|
currentTurnAttachments: [],
|
|
3254
3303
|
historyTimedAttachments: [],
|
|
3255
|
-
historyAttachments: [],
|
|
3256
3304
|
draining: false,
|
|
3257
3305
|
activeDrains: new Set(),
|
|
3258
3306
|
debounceTimer: null,
|
|
@@ -3266,9 +3314,14 @@ export function createChannelRouter(options: CreateChannelRouterOptions): Channe
|
|
|
3266
3314
|
baseContextBytes: 0,
|
|
3267
3315
|
firstUnprocessedAt: 0,
|
|
3268
3316
|
currentTurnAuthorId: null,
|
|
3317
|
+
recentMessages: [],
|
|
3318
|
+
currentTurnAuthorAdapter: key.adapter,
|
|
3269
3319
|
currentTurnAuthorIds: new Set(),
|
|
3270
3320
|
currentTurnReactionRef: null,
|
|
3271
3321
|
currentTurnExplicitlyAddressed: false,
|
|
3322
|
+
currentTurnHandoff: false,
|
|
3323
|
+
lastInboundIsDm: false,
|
|
3324
|
+
originHintedKeys: new Set(),
|
|
3272
3325
|
currentTurnTypingThread: null,
|
|
3273
3326
|
dirtyTypingThreads: new Set(),
|
|
3274
3327
|
currentTurnEngageReactions: [],
|
|
@@ -3287,6 +3340,8 @@ export function createChannelRouter(options: CreateChannelRouterOptions): Channe
|
|
|
3287
3340
|
// stay in sync, so they are written in the same statement.
|
|
3288
3341
|
lastTurnAuthorIds: triggeringAuthorId !== undefined ? new Set([triggeringAuthorId]) : new Set(),
|
|
3289
3342
|
lastTurnAuthorId: triggeringAuthorId ?? null,
|
|
3343
|
+
lastTurnAuthorAdapter: key.adapter,
|
|
3344
|
+
lastTurnHandoff: false,
|
|
3290
3345
|
consecutiveAborts: 0,
|
|
3291
3346
|
consecutiveSends: new Map(),
|
|
3292
3347
|
lastSentText: new Map(),
|
|
@@ -3499,8 +3554,8 @@ export function createChannelRouter(options: CreateChannelRouterOptions): Channe
|
|
|
3499
3554
|
): Promise<void> => {
|
|
3500
3555
|
const prefetch = adapterConfig.history.prefetch
|
|
3501
3556
|
const isThread = live.key.thread !== null
|
|
3502
|
-
|
|
3503
|
-
|
|
3557
|
+
let head = isThread ? prefetch.thread.head : 0
|
|
3558
|
+
let tail = isThread ? prefetch.thread.tail : prefetch.channel.tail
|
|
3504
3559
|
if (head === 0 && tail === 0) return
|
|
3505
3560
|
|
|
3506
3561
|
// One fetch per cold start. We always pass the live thread when present so
|
|
@@ -3535,10 +3590,33 @@ export function createChannelRouter(options: CreateChannelRouterOptions): Channe
|
|
|
3535
3590
|
// "Recent context" and once in "Current message". Adapters typically
|
|
3536
3591
|
// return the latest channel/thread messages, so this overlap is the
|
|
3537
3592
|
// common case, not the edge case.
|
|
3538
|
-
|
|
3593
|
+
let filteredMessages =
|
|
3539
3594
|
triggeringMessageId !== undefined
|
|
3540
3595
|
? result.messages.filter((m) => m.externalMessageId !== triggeringMessageId)
|
|
3541
3596
|
: result.messages
|
|
3597
|
+
let fromParentChannel = false
|
|
3598
|
+
|
|
3599
|
+
// A thread rooted at the triggering message (a top-level mention the bot
|
|
3600
|
+
// answers in-thread) has no history of its own yet, so the thread fetch
|
|
3601
|
+
// seeds nothing and the agent starts blind to what was just said in the
|
|
3602
|
+
// channel, including its own recent posts. Seed from the channel tail.
|
|
3603
|
+
if (filteredMessages.length === 0 && isThread && live.key.thread === triggeringMessageId) {
|
|
3604
|
+
tail = prefetch.channel.tail
|
|
3605
|
+
if (tail === 0) return
|
|
3606
|
+
head = 0
|
|
3607
|
+
const channelResult = await fetchHistory(live.key.adapter, {
|
|
3608
|
+
chat: live.key.chat,
|
|
3609
|
+
thread: null,
|
|
3610
|
+
limit: tail + 1,
|
|
3611
|
+
prefetch: true,
|
|
3612
|
+
})
|
|
3613
|
+
if (!channelResult.ok) {
|
|
3614
|
+
logger.info(`[channels] ${live.keyId}: channel prefetch fallback skipped (${channelResult.error})`)
|
|
3615
|
+
return
|
|
3616
|
+
}
|
|
3617
|
+
filteredMessages = channelResult.messages.filter((m) => m.externalMessageId !== triggeringMessageId)
|
|
3618
|
+
fromParentChannel = true
|
|
3619
|
+
}
|
|
3542
3620
|
if (filteredMessages.length === 0) return
|
|
3543
3621
|
|
|
3544
3622
|
const seeded = sliceHeadTail(filteredMessages, head, tail)
|
|
@@ -3577,6 +3655,16 @@ export function createChannelRouter(options: CreateChannelRouterOptions): Channe
|
|
|
3577
3655
|
// normal. We push into contextBuffer (not promptQueue) because these are
|
|
3578
3656
|
// background context for the model, not turns it must respond to.
|
|
3579
3657
|
live.contextBuffer.push(...observed)
|
|
3658
|
+
// Persisted participants only include authors routed since the session went
|
|
3659
|
+
// live, so a cold-started thread would undercount humans who spoke earlier
|
|
3660
|
+
// and lose them once the context buffer drains. Record the thread's own
|
|
3661
|
+
// historical human speakers; parent-channel seeds are not thread members.
|
|
3662
|
+
if ((isThread || live.room?.kind === 'thread') && !fromParentChannel) {
|
|
3663
|
+
for (const item of observed) {
|
|
3664
|
+
if (item.authorIsBot || live.participants.some((p) => p.authorId === item.authorId)) continue
|
|
3665
|
+
live.participants = updateParticipants(live.participants, item.authorId, item.authorName, now(), false)
|
|
3666
|
+
}
|
|
3667
|
+
}
|
|
3580
3668
|
logger.info(`[channels] ${live.keyId}: prefetched ${observed.length} context messages`)
|
|
3581
3669
|
}
|
|
3582
3670
|
|
|
@@ -3739,12 +3827,12 @@ export function createChannelRouter(options: CreateChannelRouterOptions): Channe
|
|
|
3739
3827
|
// tools and `channel_send` must keep the follow-up so genuine multi-step turns
|
|
3740
3828
|
// continue. A prior non-typeclaw `afterToolCall` (none today) is composed.
|
|
3741
3829
|
//
|
|
3742
|
-
// `channel_reply({
|
|
3830
|
+
// `channel_reply({ continue_after_reply: true })` is the explicit opt-out: a
|
|
3743
3831
|
// mid-turn status reply ("working on it…") that the model follows with more
|
|
3744
3832
|
// work this turn. The tool surfaces that intent as
|
|
3745
|
-
// `details.
|
|
3833
|
+
// `details.continue_after_reply === true`, and we keep the follow-up so the turn
|
|
3746
3834
|
// proceeds. The kimi 32k loop only recurs when the model genuinely has nothing
|
|
3747
|
-
// left to say after a reply, which `
|
|
3835
|
+
// left to say after a reply, which `continue_after_reply` asserts is not the
|
|
3748
3836
|
// case; Layer 2's maxTokens cap still bounds any misuse.
|
|
3749
3837
|
// IDs are cache hints, never generation authority. Call only inside the lane.
|
|
3750
3838
|
const resolveBackgroundCoverage = async (
|
|
@@ -3880,7 +3968,7 @@ export function createChannelRouter(options: CreateChannelRouterOptions): Channe
|
|
|
3880
3968
|
const details = context.result.details as
|
|
3881
3969
|
| {
|
|
3882
3970
|
ok?: unknown
|
|
3883
|
-
|
|
3971
|
+
continue_after_reply?: unknown
|
|
3884
3972
|
backgroundCoverage?: BackgroundObligationRef[]
|
|
3885
3973
|
inboundCoverage?: InboundRef[]
|
|
3886
3974
|
}
|
|
@@ -3895,11 +3983,11 @@ export function createChannelRouter(options: CreateChannelRouterOptions): Channe
|
|
|
3895
3983
|
live.qualifyingWorkThisLogicalTurn = true
|
|
3896
3984
|
}
|
|
3897
3985
|
const succeeded = context.toolCall.name === 'channel_reply' && !context.isError && details?.ok === true
|
|
3898
|
-
const keepTurnAlive = details?.
|
|
3986
|
+
const keepTurnAlive = details?.continue_after_reply === true
|
|
3899
3987
|
if (succeeded) {
|
|
3900
3988
|
// This hook is authoritative for channel_reply semantics: the send path
|
|
3901
3989
|
// cannot distinguish channel_reply from channel_send, but here the
|
|
3902
|
-
// explicit
|
|
3990
|
+
// explicit continue_after_reply flag tells us whether the delivered reply
|
|
3903
3991
|
// renewed the promise or terminally fulfilled it.
|
|
3904
3992
|
const text = (context.toolCall.arguments as { text?: unknown } | undefined)?.text
|
|
3905
3993
|
if (!keepTurnAlive && !promisesUnfinishedWork(live, text)) {
|
|
@@ -4377,6 +4465,9 @@ export function createChannelRouter(options: CreateChannelRouterOptions): Channe
|
|
|
4377
4465
|
...(live.room?.parentChat !== undefined ? { parentChat: live.room.parentChat } : {}),
|
|
4378
4466
|
...(live.room?.parentChatName !== undefined ? { parentChatName: live.room.parentChatName } : {}),
|
|
4379
4467
|
...(live.currentTurnAuthorId !== null ? { lastInboundAuthorId: live.currentTurnAuthorId } : {}),
|
|
4468
|
+
...(live.currentTurnAuthorAdapter !== live.key.adapter
|
|
4469
|
+
? { lastInboundAuthorAdapter: live.currentTurnAuthorAdapter }
|
|
4470
|
+
: {}),
|
|
4380
4471
|
...(live.currentTurnReactionRef !== null ? { reactionRef: live.currentTurnReactionRef } : {}),
|
|
4381
4472
|
participants: live.participants,
|
|
4382
4473
|
...(membership !== null ? { membership } : {}),
|
|
@@ -4834,7 +4925,7 @@ export function createChannelRouter(options: CreateChannelRouterOptions): Channe
|
|
|
4834
4925
|
}
|
|
4835
4926
|
|
|
4836
4927
|
// The logical turn told the user more was coming and has not delivered it: a
|
|
4837
|
-
// `
|
|
4928
|
+
// `continue_after_reply: true` reply, or a landed status/continuation message
|
|
4838
4929
|
// that no substantive output followed. Silence cannot answer such a promise.
|
|
4839
4930
|
const owesPromisedWork = (live: LiveSession): boolean =>
|
|
4840
4931
|
live.promisedWorkOutstandingThisLogicalTurn || live.statusOutputOutstandingThisLogicalTurn
|
|
@@ -5412,6 +5503,7 @@ export function createChannelRouter(options: CreateChannelRouterOptions): Channe
|
|
|
5412
5503
|
// which skip this branch.
|
|
5413
5504
|
live.pendingProviderError = null
|
|
5414
5505
|
live.currentTurnAuthorId = batch[batch.length - 1]!.authorId
|
|
5506
|
+
live.currentTurnAuthorAdapter = batch[batch.length - 1]!.authorAdapter ?? live.key.adapter
|
|
5415
5507
|
live.currentTurnAuthorIds = new Set(batch.map((m) => m.authorId))
|
|
5416
5508
|
live.currentTurnReactionRef = batch[batch.length - 1]!.reactionRef ?? null
|
|
5417
5509
|
const trigger = batch[batch.length - 1]!
|
|
@@ -5420,6 +5512,7 @@ export function createChannelRouter(options: CreateChannelRouterOptions): Channe
|
|
|
5420
5512
|
}
|
|
5421
5513
|
live.currentTurnExplicitlyAddressed =
|
|
5422
5514
|
trigger.isDm || trigger.isBotMention || trigger.replyToBotMessageId !== null
|
|
5515
|
+
live.currentTurnHandoff = batch.some((m) => m.handoff === true)
|
|
5423
5516
|
live.currentTurnTypingThread = batch[batch.length - 1]!.typingThread ?? null
|
|
5424
5517
|
live.currentTurnEngageReactions = batch.flatMap((m) =>
|
|
5425
5518
|
m.engageReaction !== undefined ? [m.engageReaction] : [],
|
|
@@ -5427,7 +5520,12 @@ export function createChannelRouter(options: CreateChannelRouterOptions): Channe
|
|
|
5427
5520
|
live.consecutiveSends.clear()
|
|
5428
5521
|
live.lastSentText.clear()
|
|
5429
5522
|
live.lastSendLeafId = null
|
|
5430
|
-
live.pendingQuoteCandidate = captureQuoteCandidate(
|
|
5523
|
+
live.pendingQuoteCandidate = captureQuoteCandidate(
|
|
5524
|
+
live.key.adapter,
|
|
5525
|
+
// A handoff inbound has no platform message to quote or reply to.
|
|
5526
|
+
batch.filter((m) => m.handoff !== true),
|
|
5527
|
+
observed,
|
|
5528
|
+
)
|
|
5431
5529
|
// A real user batch starts a fresh logical turn → restore the full
|
|
5432
5530
|
// empty-turn retry budget and drop any raised output-token budget left
|
|
5433
5531
|
// over from a prior turn's length-retry. Reset here (batch.length > 0)
|
|
@@ -5504,6 +5602,8 @@ export function createChannelRouter(options: CreateChannelRouterOptions): Channe
|
|
|
5504
5602
|
// turn `batch[batch.length - 1]!.authorId` semantics) so a multi-
|
|
5505
5603
|
// author prior turn like alice→bob restores `bob`, not alice.
|
|
5506
5604
|
live.currentTurnAuthorId = live.lastTurnAuthorId
|
|
5605
|
+
live.currentTurnAuthorAdapter = live.lastTurnAuthorAdapter
|
|
5606
|
+
live.currentTurnHandoff = live.lastTurnHandoff
|
|
5507
5607
|
live.currentTurnAuthorIds = new Set(live.lastTurnAuthorIds)
|
|
5508
5608
|
} else {
|
|
5509
5609
|
live.currentTurnEngageReactions = []
|
|
@@ -5583,7 +5683,7 @@ export function createChannelRouter(options: CreateChannelRouterOptions): Channe
|
|
|
5583
5683
|
live.promptInFlight = true
|
|
5584
5684
|
try {
|
|
5585
5685
|
const result = await promptPersistentTurnWithFallback({
|
|
5586
|
-
refs: resolveFallbackChain(getConfig().
|
|
5686
|
+
refs: resolveFallbackChain(effectiveModels(getConfig(), live.originRef.current), undefined),
|
|
5587
5687
|
currentModelRef: live.activeModelRef,
|
|
5588
5688
|
session: live.session,
|
|
5589
5689
|
text: promptText,
|
|
@@ -5762,6 +5862,8 @@ export function createChannelRouter(options: CreateChannelRouterOptions): Channe
|
|
|
5762
5862
|
live.lastTurnAuthorIds = new Set(live.currentTurnAuthorIds)
|
|
5763
5863
|
if (live.currentTurnAuthorId !== null) {
|
|
5764
5864
|
live.lastTurnAuthorId = live.currentTurnAuthorId
|
|
5865
|
+
live.lastTurnAuthorAdapter = live.currentTurnAuthorAdapter
|
|
5866
|
+
live.lastTurnHandoff = live.currentTurnHandoff
|
|
5765
5867
|
}
|
|
5766
5868
|
}
|
|
5767
5869
|
} finally {
|
|
@@ -5770,6 +5872,7 @@ export function createChannelRouter(options: CreateChannelRouterOptions): Channe
|
|
|
5770
5872
|
live.currentTurnAuthorIds = new Set()
|
|
5771
5873
|
live.currentTurnReactionRef = null
|
|
5772
5874
|
live.currentTurnExplicitlyAddressed = false
|
|
5875
|
+
live.currentTurnHandoff = false
|
|
5773
5876
|
live.currentTurnEngageReactions = []
|
|
5774
5877
|
// Drop any still-held reactions if the loop exited without running the
|
|
5775
5878
|
// per-turn finally (e.g. session destroyed mid-drain): never leave a
|
|
@@ -6021,7 +6124,7 @@ export function createChannelRouter(options: CreateChannelRouterOptions): Channe
|
|
|
6021
6124
|
)
|
|
6022
6125
|
}
|
|
6023
6126
|
|
|
6024
|
-
const
|
|
6127
|
+
const routeInbound = async (event: InboundMessage, onAdmitted?: () => Promise<void>): Promise<RouteReceipt> => {
|
|
6025
6128
|
const adapterConfig = options.configForAdapter(event.adapter)
|
|
6026
6129
|
if (!adapterConfig) return { kind: 'denied' }
|
|
6027
6130
|
|
|
@@ -6040,7 +6143,9 @@ export function createChannelRouter(options: CreateChannelRouterOptions): Channe
|
|
|
6040
6143
|
// Claims are accepted from any chat (DM, group, thread) because the
|
|
6041
6144
|
// resulting match rule is platform-wide + author-scoped — see
|
|
6042
6145
|
// src/role-claim/match-rule.ts.
|
|
6043
|
-
|
|
6146
|
+
// A handoff's text is delegated context, never control traffic: it must not
|
|
6147
|
+
// claim roles or run commands on the requester's behalf.
|
|
6148
|
+
if (event.handoff !== true && claimHandler !== undefined && extractClaimCode(event.text) !== null) {
|
|
6044
6149
|
const outcome = await claimHandler({
|
|
6045
6150
|
adapter: event.adapter,
|
|
6046
6151
|
workspace: event.workspace,
|
|
@@ -6074,7 +6179,7 @@ export function createChannelRouter(options: CreateChannelRouterOptions): Channe
|
|
|
6074
6179
|
|
|
6075
6180
|
// Parse once, here, so the public-command fast path (below) and the
|
|
6076
6181
|
// post-gate command block share one parse and lookup.
|
|
6077
|
-
const parsedCommand = commands.parse(event.text)
|
|
6182
|
+
const parsedCommand = event.handoff === true ? null : commands.parse(event.text)
|
|
6078
6183
|
const commandInfo = parsedCommand === null ? undefined : commands.get(parsedCommand.name)
|
|
6079
6184
|
|
|
6080
6185
|
// Public-command fast path: a known command that is both ungated
|
|
@@ -6155,6 +6260,7 @@ export function createChannelRouter(options: CreateChannelRouterOptions): Channe
|
|
|
6155
6260
|
chat: event.chat,
|
|
6156
6261
|
...(event.room?.parentChat !== undefined ? { parentChat: event.room.parentChat } : {}),
|
|
6157
6262
|
lastInboundAuthorId: event.authorId,
|
|
6263
|
+
...(event.authorAdapter !== undefined ? { lastInboundAuthorAdapter: event.authorAdapter } : {}),
|
|
6158
6264
|
},
|
|
6159
6265
|
messageId: event.externalMessageId || undefined,
|
|
6160
6266
|
eventKind: event.eventKind ?? 'message',
|
|
@@ -6184,15 +6290,20 @@ export function createChannelRouter(options: CreateChannelRouterOptions): Channe
|
|
|
6184
6290
|
let live = await ensureLive(key, event.externalMessageId, event.authorId, undefined, event.room, generation)
|
|
6185
6291
|
live.room = event.room
|
|
6186
6292
|
|
|
6187
|
-
const isNewAuthor = !live.participants.some((p) => p.authorId === event.authorId)
|
|
6188
|
-
|
|
6189
|
-
|
|
6190
|
-
|
|
6191
|
-
|
|
6192
|
-
|
|
6193
|
-
|
|
6194
|
-
|
|
6195
|
-
|
|
6293
|
+
const isNewAuthor = event.handoff !== true && !live.participants.some((p) => p.authorId === event.authorId)
|
|
6294
|
+
// A delegated note is not evidence that its author joined this conversation.
|
|
6295
|
+
if (event.handoff !== true) {
|
|
6296
|
+
live.participants = updateParticipants(
|
|
6297
|
+
live.participants,
|
|
6298
|
+
event.authorId,
|
|
6299
|
+
event.authorName,
|
|
6300
|
+
now(),
|
|
6301
|
+
event.authorIsBot,
|
|
6302
|
+
)
|
|
6303
|
+
void persistParticipants(live)
|
|
6304
|
+
live.recentMessages.push({ text: event.text.slice(0, 2000), at: now() })
|
|
6305
|
+
if (live.recentMessages.length > 20) live.recentMessages.shift()
|
|
6306
|
+
}
|
|
6196
6307
|
|
|
6197
6308
|
// A previously-unseen author just spoke. The cached membership count
|
|
6198
6309
|
// (from /members or history-derived) was computed without them, so
|
|
@@ -6213,7 +6324,8 @@ export function createChannelRouter(options: CreateChannelRouterOptions): Channe
|
|
|
6213
6324
|
|
|
6214
6325
|
const membership = await membershipForEngagement(live)
|
|
6215
6326
|
|
|
6216
|
-
const
|
|
6327
|
+
const botInThread = hasBotParticipated(live)
|
|
6328
|
+
const effectiveHumans = countEngagementHumans(event, live.participants, membership, now(), botInThread)
|
|
6217
6329
|
live.multiHumanGroup = isMultiHumanGroup(event.isDm, effectiveHumans)
|
|
6218
6330
|
|
|
6219
6331
|
const decision: EngagementDecision = decideEngagement({
|
|
@@ -6225,7 +6337,7 @@ export function createChannelRouter(options: CreateChannelRouterOptions): Channe
|
|
|
6225
6337
|
participants: live.participants,
|
|
6226
6338
|
membership,
|
|
6227
6339
|
selfAliases: computeSelfAliases(),
|
|
6228
|
-
botInThread
|
|
6340
|
+
botInThread,
|
|
6229
6341
|
})
|
|
6230
6342
|
|
|
6231
6343
|
if (decision === 'observe') {
|
|
@@ -6276,11 +6388,20 @@ export function createChannelRouter(options: CreateChannelRouterOptions): Channe
|
|
|
6276
6388
|
event.replyToBotMessageId === null &&
|
|
6277
6389
|
!live.multiHumanGroup
|
|
6278
6390
|
|
|
6279
|
-
const engageReaction = autoReactOnEngage(event)
|
|
6391
|
+
const engageReaction = autoReactOnEngage(event, live.draining)
|
|
6280
6392
|
|
|
6281
6393
|
updateLoopGuard(live, event)
|
|
6282
6394
|
|
|
6283
|
-
|
|
6395
|
+
const originNote = event.handoff !== true ? takeConversationOriginNote(live, event) : undefined
|
|
6396
|
+
live.lastInboundIsDm = event.isDm
|
|
6397
|
+
enqueue(
|
|
6398
|
+
live,
|
|
6399
|
+
originNote !== undefined
|
|
6400
|
+
? { ...event, routingNote: [event.routingNote, originNote].filter((n) => n !== undefined).join('\n') }
|
|
6401
|
+
: event,
|
|
6402
|
+
engageReaction,
|
|
6403
|
+
admission.inputId,
|
|
6404
|
+
)
|
|
6284
6405
|
|
|
6285
6406
|
// Start showing "typing..." the moment we know we're going to engage,
|
|
6286
6407
|
// so users see the indicator during the debounce window — not just
|
|
@@ -6299,6 +6420,17 @@ export function createChannelRouter(options: CreateChannelRouterOptions): Channe
|
|
|
6299
6420
|
})
|
|
6300
6421
|
}
|
|
6301
6422
|
|
|
6423
|
+
const route = async (event: InboundMessage, onAdmitted?: () => Promise<void>): Promise<RouteReceipt> => {
|
|
6424
|
+
const receipt = await routeInbound(event, onAdmitted)
|
|
6425
|
+
if (receipt.kind === 'observed' || receipt.kind === 'control') catchUp.noteObserved(event)
|
|
6426
|
+
return receipt
|
|
6427
|
+
}
|
|
6428
|
+
const catchUp = createInboundCatchUp({ agentDir: options.agentDir, route, logger, now })
|
|
6429
|
+
const catchUpTargets = async (adapter: AdapterId): Promise<readonly ChannelKey[]> => {
|
|
6430
|
+
await ensureLoaded()
|
|
6431
|
+
return (mappings ?? []).filter((record) => record.adapter === adapter)
|
|
6432
|
+
}
|
|
6433
|
+
|
|
6302
6434
|
const inboundAuthorOrigin = (event: InboundMessage): SessionOrigin => ({
|
|
6303
6435
|
kind: 'channel',
|
|
6304
6436
|
adapter: event.adapter,
|
|
@@ -6307,6 +6439,7 @@ export function createChannelRouter(options: CreateChannelRouterOptions): Channe
|
|
|
6307
6439
|
thread: event.thread,
|
|
6308
6440
|
...(event.room?.parentChat !== undefined ? { parentChat: event.room.parentChat } : {}),
|
|
6309
6441
|
lastInboundAuthorId: event.authorId,
|
|
6442
|
+
...(event.authorAdapter !== undefined ? { lastInboundAuthorAdapter: event.authorAdapter } : {}),
|
|
6310
6443
|
})
|
|
6311
6444
|
|
|
6312
6445
|
const isChannelRespondDenied = (event: InboundMessage): boolean =>
|
|
@@ -6401,6 +6534,7 @@ export function createChannelRouter(options: CreateChannelRouterOptions): Channe
|
|
|
6401
6534
|
...(event.referenceContext !== undefined ? { referenceContext: event.referenceContext } : {}),
|
|
6402
6535
|
...(event.attachments !== undefined && event.attachments.length > 0 ? { attachments: event.attachments } : {}),
|
|
6403
6536
|
authorId: event.authorId,
|
|
6537
|
+
...(event.authorAdapter !== undefined ? { authorAdapter: event.authorAdapter } : {}),
|
|
6404
6538
|
authorName: event.authorName,
|
|
6405
6539
|
authorIsBot: event.authorIsBot,
|
|
6406
6540
|
externalMessageId: event.externalMessageId,
|
|
@@ -6415,6 +6549,8 @@ export function createChannelRouter(options: CreateChannelRouterOptions): Channe
|
|
|
6415
6549
|
...(event.githubReviewThreadCloseout !== undefined
|
|
6416
6550
|
? { githubReviewThreadCloseout: event.githubReviewThreadCloseout }
|
|
6417
6551
|
: {}),
|
|
6552
|
+
...(event.routingNote !== undefined ? { routingNote: event.routingNote } : {}),
|
|
6553
|
+
...(event.handoff === true ? { handoff: true as const } : {}),
|
|
6418
6554
|
receivedAt: now(),
|
|
6419
6555
|
ts: event.ts,
|
|
6420
6556
|
})
|
|
@@ -6616,15 +6752,21 @@ export function createChannelRouter(options: CreateChannelRouterOptions): Channe
|
|
|
6616
6752
|
// supporting reactions, a transient API error) can NEVER block engagement,
|
|
6617
6753
|
// enqueueing, or the agent's actual reply. No reactionRef = nothing reactable
|
|
6618
6754
|
// (synthetic inbounds, reaction-less adapters) = silent skip.
|
|
6619
|
-
|
|
6620
|
-
|
|
6755
|
+
//
|
|
6756
|
+
// A message queued behind an in-flight turn gets an :hourglass_flowing_sand:
|
|
6757
|
+
// even where typing renders: that indicator belongs to the running turn and
|
|
6758
|
+
// cannot tell the sender their message is waiting. GitHub's fixed reaction
|
|
6759
|
+
// set has no hourglass, so it keeps :eyes:.
|
|
6760
|
+
const autoReactOnEngage = (event: InboundMessage, queuedBehindTurn: boolean): WaitingReactionHandle | null => {
|
|
6761
|
+
if (event.reactionRef === undefined) return null
|
|
6762
|
+
if (!queuedBehindTurn && typingCapableAdapters.has(event.adapter)) return null
|
|
6621
6763
|
return waitingReactions.acquire({
|
|
6622
6764
|
adapter: event.adapter,
|
|
6623
6765
|
workspace: event.workspace,
|
|
6624
6766
|
chat: event.chat,
|
|
6625
6767
|
thread: event.thread,
|
|
6626
6768
|
reactionRef: event.reactionRef,
|
|
6627
|
-
emoji: ENGAGE_REACTION_EMOJI,
|
|
6769
|
+
emoji: queuedBehindTurn && event.adapter !== 'github' ? QUEUED_REACTION_EMOJI : ENGAGE_REACTION_EMOJI,
|
|
6628
6770
|
})
|
|
6629
6771
|
}
|
|
6630
6772
|
|
|
@@ -6850,7 +6992,26 @@ export function createChannelRouter(options: CreateChannelRouterOptions): Channe
|
|
|
6850
6992
|
editMessageCallbacks.get(adapter)?.delete(cb)
|
|
6851
6993
|
}
|
|
6852
6994
|
|
|
6853
|
-
const
|
|
6995
|
+
const hasOutboundReviewer = (): boolean =>
|
|
6996
|
+
options.reviewOutbound !== undefined && (options.outboundReviewerActive?.() ?? true)
|
|
6997
|
+
|
|
6998
|
+
const reviewOutbound = async (event: ChannelOutboundBeforeEvent): Promise<string> => {
|
|
6999
|
+
if (!hasOutboundReviewer()) return event.text
|
|
7000
|
+
try {
|
|
7001
|
+
const result = await options.reviewOutbound!(event)
|
|
7002
|
+
// A transform cannot undo the normal reasoning/flood protections or
|
|
7003
|
+
// synthesize a caption on an attachment-only delivery.
|
|
7004
|
+
const text = normalizeSendText(result.text)
|
|
7005
|
+
if (event.text.trim().length === 0) return event.text
|
|
7006
|
+
if (text !== undefined && text.trim().length > 0 && checkOutboundFlood(text).ok) return text
|
|
7007
|
+
} catch {
|
|
7008
|
+
// Plugin failures are categorical: never log message-bearing errors.
|
|
7009
|
+
}
|
|
7010
|
+
logger.warn('[channels] outbound transform failed or returned invalid text; retaining original')
|
|
7011
|
+
return event.text
|
|
7012
|
+
}
|
|
7013
|
+
|
|
7014
|
+
const editMessage = async (req: EditMessageRequest, opts?: EditMessageOptions): Promise<EditMessageResult> => {
|
|
6854
7015
|
// Strip leaked `<think>` blocks before the edit reaches any adapter, exactly
|
|
6855
7016
|
// as the send path does via normalizeSendText — an edit is another way text
|
|
6856
7017
|
// reaches the chat, so it must not become a hole that writes raw reasoning a
|
|
@@ -6860,7 +7021,7 @@ export function createChannelRouter(options: CreateChannelRouterOptions): Channe
|
|
|
6860
7021
|
if (normalized === undefined) {
|
|
6861
7022
|
return { ok: false, error: 'message-edit-empty-after-normalization', code: 'not-found' }
|
|
6862
7023
|
}
|
|
6863
|
-
|
|
7024
|
+
let normalizedReq = normalized === req.text ? req : { ...req, text: normalized }
|
|
6864
7025
|
const callbacks = editMessageCallbacks.get(req.adapter)
|
|
6865
7026
|
if (!callbacks || callbacks.size === 0) {
|
|
6866
7027
|
return isWriteCapabilityUnavailable(req.adapter, 'message-edit')
|
|
@@ -6871,6 +7032,21 @@ export function createChannelRouter(options: CreateChannelRouterOptions): Channe
|
|
|
6871
7032
|
}
|
|
6872
7033
|
: { ok: false, error: 'message-edit-not-supported', code: 'not-supported' }
|
|
6873
7034
|
}
|
|
7035
|
+
const reviewed = hasOutboundReviewer()
|
|
7036
|
+
if (reviewed) {
|
|
7037
|
+
const text = await reviewOutbound({
|
|
7038
|
+
adapter: req.adapter,
|
|
7039
|
+
workspace: req.workspace,
|
|
7040
|
+
chat: req.chat,
|
|
7041
|
+
...(req.thread != null ? { thread: req.thread } : {}),
|
|
7042
|
+
text: normalized,
|
|
7043
|
+
op: 'edit',
|
|
7044
|
+
messageId: req.messageId,
|
|
7045
|
+
source: 'tool',
|
|
7046
|
+
...(opts?.origin ? { origin: opts.origin } : {}),
|
|
7047
|
+
})
|
|
7048
|
+
normalizedReq = { ...normalizedReq, text }
|
|
7049
|
+
}
|
|
6874
7050
|
const snapshot = Array.from(callbacks)
|
|
6875
7051
|
let lastError: EditMessageResult & { ok: false } = { ok: false, error: 'message-edit-not-supported' }
|
|
6876
7052
|
for (const cb of snapshot) {
|
|
@@ -6880,7 +7056,7 @@ export function createChannelRouter(options: CreateChannelRouterOptions): Channe
|
|
|
6880
7056
|
fetchHistoryTimeoutMs,
|
|
6881
7057
|
`[channels] ${req.adapter} edit message`,
|
|
6882
7058
|
)
|
|
6883
|
-
if (result.ok) return result
|
|
7059
|
+
if (result.ok) return reviewed ? { ...result, deliveredText: normalizedReq.text } : result
|
|
6884
7060
|
lastError = result
|
|
6885
7061
|
} catch (err) {
|
|
6886
7062
|
logger.warn(`[channels] edit message threw for ${req.adapter}: ${describeError(err)}`)
|
|
@@ -7032,43 +7208,45 @@ export function createChannelRouter(options: CreateChannelRouterOptions): Channe
|
|
|
7032
7208
|
)
|
|
7033
7209
|
}
|
|
7034
7210
|
|
|
7035
|
-
const lookupInboundAttachment = (args: ChannelKey & { id: number }): InboundAttachment | null => {
|
|
7211
|
+
const lookupInboundAttachment = (args: ChannelKey & { id: number; ref?: string }): InboundAttachment | null => {
|
|
7036
7212
|
const live = liveSessions.get(channelKeyId(args))
|
|
7037
7213
|
if (live === undefined) return null
|
|
7038
|
-
|
|
7039
|
-
|
|
7040
|
-
//
|
|
7041
|
-
//
|
|
7042
|
-
|
|
7043
|
-
|
|
7044
|
-
|
|
7045
|
-
|
|
7046
|
-
|
|
7047
|
-
const
|
|
7048
|
-
|
|
7049
|
-
|
|
7050
|
-
|
|
7051
|
-
|
|
7052
|
-
|
|
7053
|
-
|
|
7054
|
-
for (
|
|
7055
|
-
const item
|
|
7056
|
-
|
|
7057
|
-
|
|
7058
|
-
|
|
7059
|
-
|
|
7060
|
-
|
|
7214
|
+
const matches = (attachment: InboundAttachment) =>
|
|
7215
|
+
attachment.id === args.id && (args.ref === undefined || attachment.ref === args.ref)
|
|
7216
|
+
// An actual attachment on the in-flight request wins. Observed scrollback
|
|
7217
|
+
// in that same prompt is NOT the current request's attachment.
|
|
7218
|
+
for (let i = live.currentTurnAttachments.length - 1; i >= 0; i--) {
|
|
7219
|
+
const entry = live.currentTurnAttachments[i]!
|
|
7220
|
+
if (entry.current && matches(entry.attachment)) return entry.attachment
|
|
7221
|
+
}
|
|
7222
|
+
let newest: TimedAttachment | undefined
|
|
7223
|
+
for (const entries of [live.currentTurnAttachments, live.historyTimedAttachments]) {
|
|
7224
|
+
for (const entry of entries) {
|
|
7225
|
+
if (matches(entry.attachment) && (newest === undefined || entry.ts >= newest.ts)) newest = entry
|
|
7226
|
+
}
|
|
7227
|
+
}
|
|
7228
|
+
// Future arrivals must never retarget a tool call from an in-flight turn.
|
|
7229
|
+
if (!live.draining) {
|
|
7230
|
+
for (const item of [...live.contextBuffer, ...live.promptQueue]) {
|
|
7231
|
+
for (const attachment of item.attachments ?? []) {
|
|
7232
|
+
if (matches(attachment) && (newest === undefined || item.ts >= newest.ts))
|
|
7233
|
+
newest = { ts: item.ts, attachment }
|
|
7234
|
+
}
|
|
7235
|
+
}
|
|
7236
|
+
}
|
|
7237
|
+
return newest?.attachment ?? null
|
|
7061
7238
|
}
|
|
7062
7239
|
|
|
7063
7240
|
const listInboundAttachmentIds = (args: ChannelKey): readonly number[] => {
|
|
7064
7241
|
const live = liveSessions.get(channelKeyId(args))
|
|
7065
7242
|
if (live === undefined) return []
|
|
7066
7243
|
const ids = new Set<number>()
|
|
7067
|
-
for (const
|
|
7068
|
-
|
|
7069
|
-
for (const
|
|
7244
|
+
for (const entry of live.currentTurnAttachments) ids.add(entry.attachment.id)
|
|
7245
|
+
if (!live.draining) {
|
|
7246
|
+
for (const item of [...live.promptQueue, ...live.contextBuffer])
|
|
7247
|
+
for (const attachment of item.attachments ?? []) ids.add(attachment.id)
|
|
7070
7248
|
}
|
|
7071
|
-
for (const
|
|
7249
|
+
for (const entry of live.historyTimedAttachments) ids.add(entry.attachment.id)
|
|
7072
7250
|
return Array.from(ids).sort((a, b) => a - b)
|
|
7073
7251
|
}
|
|
7074
7252
|
|
|
@@ -7079,23 +7257,18 @@ export function createChannelRouter(options: CreateChannelRouterOptions): Channe
|
|
|
7079
7257
|
(message.attachments ?? []).map((attachment) => ({ ts: message.ts, attachment })),
|
|
7080
7258
|
)
|
|
7081
7259
|
if (incoming.length === 0) return
|
|
7082
|
-
//
|
|
7083
|
-
//
|
|
7084
|
-
|
|
7085
|
-
// freshest ref or an older paged `#1` would shadow a newer one. Dedupe by
|
|
7086
|
-
// id keeping the freshest ts (a re-fetch of the same message is a no-op,
|
|
7087
|
-
// not a duplicate), sort ascending by ts, then keep the freshest LIMIT so
|
|
7088
|
-
// eviction drops the OLDEST refs, never newer ones.
|
|
7089
|
-
const byId = new Map<number, TimedAttachment>()
|
|
7260
|
+
// Keep each distinct ref, not only the latest message-local number: an
|
|
7261
|
+
// explicit file_id must still select an older file from this conversation.
|
|
7262
|
+
const byRef = new Map<string, TimedAttachment>()
|
|
7090
7263
|
for (const entry of [...live.historyTimedAttachments, ...incoming]) {
|
|
7091
|
-
const
|
|
7092
|
-
|
|
7264
|
+
const key = `${entry.attachment.id}:${entry.attachment.ref}`
|
|
7265
|
+
const existing = byRef.get(key)
|
|
7266
|
+
if (existing === undefined || entry.ts >= existing.ts) byRef.set(key, entry)
|
|
7093
7267
|
}
|
|
7094
|
-
const sorted = Array.from(
|
|
7268
|
+
const sorted = Array.from(byRef.values()).sort((a, b) => a.ts - b.ts)
|
|
7095
7269
|
const kept =
|
|
7096
7270
|
sorted.length > HISTORY_ATTACHMENT_LIMIT ? sorted.slice(sorted.length - HISTORY_ATTACHMENT_LIMIT) : sorted
|
|
7097
7271
|
live.historyTimedAttachments = kept
|
|
7098
|
-
live.historyAttachments = kept.map((entry) => entry.attachment)
|
|
7099
7272
|
}
|
|
7100
7273
|
|
|
7101
7274
|
const send = async (msg: OutboundMessage, opts?: SendOptions): Promise<SendResult> => {
|
|
@@ -7122,9 +7295,24 @@ export function createChannelRouter(options: CreateChannelRouterOptions): Channe
|
|
|
7122
7295
|
// Recovery is a transport-only operation. Do not even look up the live
|
|
7123
7296
|
// session: doing so would let a delayed notice alter a newer logical turn.
|
|
7124
7297
|
if (opts?.accounting === 'recovery') {
|
|
7298
|
+
const reviewed = hasOutboundReviewer()
|
|
7299
|
+
if (reviewed) {
|
|
7300
|
+
const text = await reviewOutbound({
|
|
7301
|
+
adapter: msg.adapter,
|
|
7302
|
+
workspace: msg.workspace,
|
|
7303
|
+
chat: msg.chat,
|
|
7304
|
+
...(msg.thread != null ? { thread: msg.thread } : {}),
|
|
7305
|
+
text: msg.text ?? '',
|
|
7306
|
+
op: 'send',
|
|
7307
|
+
source,
|
|
7308
|
+
outputKind: opts.outputKind ?? 'meta',
|
|
7309
|
+
...(opts.origin ? { origin: opts.origin } : {}),
|
|
7310
|
+
})
|
|
7311
|
+
if (msg.text !== undefined) msg = { ...msg, text }
|
|
7312
|
+
}
|
|
7125
7313
|
for (const callback of Array.from(callbacks)) {
|
|
7126
7314
|
const result = await callback({ ...msg, sendOptions: opts })
|
|
7127
|
-
if (result.ok) return result
|
|
7315
|
+
if (result.ok) return reviewed && msg.text !== undefined ? { ...result, deliveredText: msg.text } : result
|
|
7128
7316
|
return result
|
|
7129
7317
|
}
|
|
7130
7318
|
return { ok: false, error: 'no recovery transport available', code: 'no-adapter' }
|
|
@@ -7309,7 +7497,27 @@ export function createChannelRouter(options: CreateChannelRouterOptions): Channe
|
|
|
7309
7497
|
let messageId: string | undefined
|
|
7310
7498
|
let messageIds: readonly string[] | undefined
|
|
7311
7499
|
let reactionRef: ReactionRef | undefined
|
|
7500
|
+
let deliveredText: string | undefined
|
|
7312
7501
|
try {
|
|
7502
|
+
if (hasOutboundReviewer()) {
|
|
7503
|
+
const reviewed = await reviewOutbound({
|
|
7504
|
+
adapter: msg.adapter,
|
|
7505
|
+
workspace: msg.workspace,
|
|
7506
|
+
chat: msg.chat,
|
|
7507
|
+
...(msg.thread != null ? { thread: msg.thread } : {}),
|
|
7508
|
+
text: msg.text ?? '',
|
|
7509
|
+
op: 'send',
|
|
7510
|
+
source,
|
|
7511
|
+
outputKind,
|
|
7512
|
+
...(opts?.origin ? { origin: opts.origin } : {}),
|
|
7513
|
+
})
|
|
7514
|
+
// Admission, duplicate reservations and output-kind decisions stay based
|
|
7515
|
+
// on the authored text. A nondeterministic reviewer cannot evade them.
|
|
7516
|
+
if (msg.text !== undefined) {
|
|
7517
|
+
msg = { ...msg, text: reviewed }
|
|
7518
|
+
deliveredText = reviewed
|
|
7519
|
+
}
|
|
7520
|
+
}
|
|
7313
7521
|
for (const cb of snapshot) {
|
|
7314
7522
|
if (dependentLiveSend && !inboundJournal.health().available) {
|
|
7315
7523
|
lastError = 'continuity persistence unavailable'
|
|
@@ -7392,7 +7600,7 @@ export function createChannelRouter(options: CreateChannelRouterOptions): Channe
|
|
|
7392
7600
|
// (d) provider-error, empty-turn-fallback, and control notices are
|
|
7393
7601
|
// explicitly meta and preserve, so a warning can never self-clear.
|
|
7394
7602
|
// The channel_reply afterToolCall hook above remains authoritative for its
|
|
7395
|
-
// machine-readable
|
|
7603
|
+
// machine-readable continue_after_reply flag.
|
|
7396
7604
|
if (outputKind === 'substantive') {
|
|
7397
7605
|
live.promisedWorkOutstandingThisLogicalTurn = false
|
|
7398
7606
|
live.statusOutputOutstandingThisLogicalTurn = false
|
|
@@ -7458,11 +7666,12 @@ export function createChannelRouter(options: CreateChannelRouterOptions): Channe
|
|
|
7458
7666
|
...(messageId !== undefined ? { messageId } : {}),
|
|
7459
7667
|
...(messageIds !== undefined ? { messageIds } : {}),
|
|
7460
7668
|
...(reactionRef !== undefined ? { reactionRef } : {}),
|
|
7669
|
+
...(deliveredText !== undefined ? { deliveredText } : {}),
|
|
7461
7670
|
}
|
|
7462
7671
|
}
|
|
7463
7672
|
|
|
7464
7673
|
// The turn ended via terminal channel_reply completion. If that reply promised to keep
|
|
7465
|
-
// working but omitted `
|
|
7674
|
+
// working but omitted `continue_after_reply: true`, queue ONE reminder-only re-prompt so
|
|
7466
7675
|
// the model gets a second chance to actually do it. The tool batch already
|
|
7467
7676
|
// terminated (safe default preserved); this only adds an optional nudge. Bounded by
|
|
7468
7677
|
// MAX_WILLINGNESS_NUDGES and gated on `promptQueue` being empty so a real
|
|
@@ -7628,10 +7837,10 @@ export function createChannelRouter(options: CreateChannelRouterOptions): Channe
|
|
|
7628
7837
|
return
|
|
7629
7838
|
}
|
|
7630
7839
|
|
|
7631
|
-
// A send landed this turn, but the model may have posted a `
|
|
7840
|
+
// A send landed this turn, but the model may have posted a `continue_after_reply: true`
|
|
7632
7841
|
// progress reply, kept working, then ENDED with its final answer as plain
|
|
7633
7842
|
// prose — never calling a channel tool again. The terminal-reply abort fires
|
|
7634
|
-
// only for a `channel_reply` WITHOUT `
|
|
7843
|
+
// only for a `channel_reply` WITHOUT `continue_after_reply: true`, so that `stopReason:
|
|
7635
7844
|
// 'stop'` text leaf is left undelivered and unguarded (the false-receipt
|
|
7636
7845
|
// guard is github-only). The discriminator is leaf IDENTITY: only when the
|
|
7637
7846
|
// turn-end `stop` leaf is a DIFFERENT entry than the one in place at the last
|
|
@@ -7642,17 +7851,17 @@ export function createChannelRouter(options: CreateChannelRouterOptions): Channe
|
|
|
7642
7851
|
const terminalReplyCompletedThisTurn = live.lastTerminalReplyCompletion?.turnSeq === live.turnSeq
|
|
7643
7852
|
maybeNudgeContinuationWillingness(live)
|
|
7644
7853
|
|
|
7645
|
-
// A `channel_reply({
|
|
7854
|
+
// A `channel_reply({ continue_after_reply: true })` progress ack landed this turn (the
|
|
7646
7855
|
// machine-readable "I'll keep working" promise — `continueReplyTurn` is stamped
|
|
7647
7856
|
// by installChannelReplyTerminalHook), the model did more work, then ended on a
|
|
7648
7857
|
// FRESH empty `stop` — dropping its conclusion. This is the SAME degeneration as
|
|
7649
|
-
// the phrase-gated `channel_send` branch below, but keyed on the `
|
|
7858
|
+
// the phrase-gated `channel_send` branch below, but keyed on the `continue_after_reply: true`
|
|
7650
7859
|
// FLAG instead of a natural-language willingness phrase. The flag is the robust
|
|
7651
7860
|
// signal: it fires regardless of the ack's language or register, closing the gap
|
|
7652
7861
|
// where a persona speaking a phrasing outside the willingness table (e.g. casual
|
|
7653
7862
|
// Korean "확인해볼게") stranded the user in silence. The `attemptMadeToolCall`
|
|
7654
7863
|
// half ties the first trigger to real post-ack work; `willingnessNudges > 0`
|
|
7655
|
-
// lets a retry that re-emitted `
|
|
7864
|
+
// lets a retry that re-emitted `continue_after_reply: true` and re-stranded spend the shared
|
|
7656
7865
|
// budget toward the visible fallback instead of bailing silent. Same
|
|
7657
7866
|
// MAX_WILLINGNESS_NUDGES bound, same empty-`promptQueue` gate (a coalesced live
|
|
7658
7867
|
// inbound supersedes this turn's silence), and same nudge/fallback path as the
|
|
@@ -7740,7 +7949,7 @@ export function createChannelRouter(options: CreateChannelRouterOptions): Channe
|
|
|
7740
7949
|
|
|
7741
7950
|
const trailing = recoverableAssistantText(live.session)
|
|
7742
7951
|
if (trailing === null || trailing.source !== 'leaf') {
|
|
7743
|
-
// A `
|
|
7952
|
+
// A `continue_after_reply: true` status reply landed, then the turn stranded on an
|
|
7744
7953
|
// unanswered `toolUse` (the post-tool follow-up never produced an
|
|
7745
7954
|
// assistant message — aborted loop / cancelled stream). The promised
|
|
7746
7955
|
// work never finished, so the user is left with a bare "checking now…"
|
|
@@ -7760,6 +7969,17 @@ export function createChannelRouter(options: CreateChannelRouterOptions): Channe
|
|
|
7760
7969
|
return
|
|
7761
7970
|
}
|
|
7762
7971
|
if (branchLeafEntry(live.session)?.id === live.lastSendLeafId) return
|
|
7972
|
+
// A fresh post-send prose leaf while this turn's background child is still
|
|
7973
|
+
// running is the model narrating its own spawn ("Researcher spawned, I'll
|
|
7974
|
+
// report back"), written as invisible console text, often in the tool
|
|
7975
|
+
// result's language rather than the user's. The ack already landed and the
|
|
7976
|
+
// child's completion turn owns the real answer, so do not post it.
|
|
7977
|
+
if (isAwaitingBackgroundChild(live, 'post_send_prose')) {
|
|
7978
|
+
logger.info(
|
|
7979
|
+
`[channels] ${live.keyId} post_send_prose_suppressed cause=awaiting_background_child text_len=${trailing.text.length}`,
|
|
7980
|
+
)
|
|
7981
|
+
return
|
|
7982
|
+
}
|
|
7763
7983
|
}
|
|
7764
7984
|
|
|
7765
7985
|
if (unfinishedToolUseWithoutReply) {
|
|
@@ -8141,7 +8361,7 @@ export function createChannelRouter(options: CreateChannelRouterOptions): Channe
|
|
|
8141
8361
|
chat: live.key.chat,
|
|
8142
8362
|
thread: live.key.thread,
|
|
8143
8363
|
text,
|
|
8144
|
-
|
|
8364
|
+
continueAfterReply: false,
|
|
8145
8365
|
resolveReviewThread: false,
|
|
8146
8366
|
})
|
|
8147
8367
|
if (falseReceipt.kind === 'block') return falseReceipt.reason
|
|
@@ -8153,7 +8373,7 @@ export function createChannelRouter(options: CreateChannelRouterOptions): Channe
|
|
|
8153
8373
|
thread: live.key.thread,
|
|
8154
8374
|
text,
|
|
8155
8375
|
wantsResolve: false,
|
|
8156
|
-
|
|
8376
|
+
continueAfterReply: false,
|
|
8157
8377
|
getReviewState: (req) => getReviewState(req),
|
|
8158
8378
|
})
|
|
8159
8379
|
if (rereview.block) return rereview.reason
|
|
@@ -8339,6 +8559,7 @@ export function createChannelRouter(options: CreateChannelRouterOptions): Channe
|
|
|
8339
8559
|
|
|
8340
8560
|
const stop = async (): Promise<void> => {
|
|
8341
8561
|
closing = true
|
|
8562
|
+
await catchUp.stop()
|
|
8342
8563
|
if (!options.inboundJournal) inboundJournal.cancelInitialization()
|
|
8343
8564
|
unsubscribeJournalFailure()
|
|
8344
8565
|
if (gcTimer) clearInterval(gcTimer)
|
|
@@ -8669,13 +8890,32 @@ export function createChannelRouter(options: CreateChannelRouterOptions): Channe
|
|
|
8669
8890
|
return { kind: 'unknown-command', name: lowered }
|
|
8670
8891
|
}
|
|
8671
8892
|
|
|
8672
|
-
const acceptBackgroundResponse: ChannelRouter['acceptBackgroundResponse'] = async (args) =>
|
|
8673
|
-
|
|
8893
|
+
const acceptBackgroundResponse: ChannelRouter['acceptBackgroundResponse'] = async (args) => {
|
|
8894
|
+
// Freeze the authenticated live actor before entering the asynchronous lane.
|
|
8895
|
+
// Legacy callers without a live parent retain their supplied provenance.
|
|
8896
|
+
const live = liveSessions.get(channelKeyId(args.key))
|
|
8897
|
+
let principal: MatchableOrigin | undefined
|
|
8898
|
+
if (live !== undefined && !live.destroyed && live.sessionId === args.parentSessionId) {
|
|
8899
|
+
const authorId = live.currentTurnAuthorId ?? live.lastTurnAuthorId
|
|
8900
|
+
const authorAdapter =
|
|
8901
|
+
live.currentTurnAuthorId !== null ? live.currentTurnAuthorAdapter : live.lastTurnAuthorAdapter
|
|
8902
|
+
principal = {
|
|
8903
|
+
kind: 'channel',
|
|
8904
|
+
adapter: live.key.adapter,
|
|
8905
|
+
workspace: live.key.workspace,
|
|
8906
|
+
chat: live.key.chat,
|
|
8907
|
+
...(live.room?.parentChat !== undefined ? { parentChat: live.room.parentChat } : {}),
|
|
8908
|
+
...(authorId !== null ? { lastInboundAuthorId: authorId } : {}),
|
|
8909
|
+
...(authorAdapter !== live.key.adapter ? { lastInboundAuthorAdapter: authorAdapter } : {}),
|
|
8910
|
+
}
|
|
8911
|
+
}
|
|
8912
|
+
return backgroundObligations.withTargetLane(args.key, async () => {
|
|
8674
8913
|
await ready
|
|
8675
8914
|
inboundJournal.assertAvailable()
|
|
8676
|
-
const row = await backgroundObligations.accept(args)
|
|
8915
|
+
const row = await backgroundObligations.accept({ ...args, ...(principal !== undefined ? { principal } : {}) })
|
|
8677
8916
|
return { obligationId: row.obligationId, generation: row.generation }
|
|
8678
8917
|
})
|
|
8918
|
+
}
|
|
8679
8919
|
|
|
8680
8920
|
const suppressUnstartedBackgroundResponse: ChannelRouter['suppressUnstartedBackgroundResponse'] = async (
|
|
8681
8921
|
ref,
|
|
@@ -8837,6 +9077,52 @@ export function createChannelRouter(options: CreateChannelRouterOptions): Channe
|
|
|
8837
9077
|
return { kind: 'delivered', keyId: live.keyId }
|
|
8838
9078
|
}
|
|
8839
9079
|
|
|
9080
|
+
// Only shared namespaces identify the same person across conversations.
|
|
9081
|
+
// Check the NEW inbound author, not the session's previous turn owner.
|
|
9082
|
+
const takeConversationOriginNote = (live: LiveSession, event: InboundMessage): string | undefined => {
|
|
9083
|
+
let origin: LiveSession | undefined
|
|
9084
|
+
for (const s of liveSessions.values()) {
|
|
9085
|
+
if (s === live || s.destroyed || adapterNamespace(s.key.adapter) !== adapterNamespace(event.adapter)) continue
|
|
9086
|
+
if (!options.configForAdapter(s.key.adapter)?.enabled) continue
|
|
9087
|
+
if (
|
|
9088
|
+
!s.participants.some(
|
|
9089
|
+
(p) => p.authorId === event.authorId && now() - p.lastMessageAt <= CONVERSATION_ORIGIN_WINDOW_MS,
|
|
9090
|
+
)
|
|
9091
|
+
)
|
|
9092
|
+
continue
|
|
9093
|
+
const access = checkHandoffAccess({
|
|
9094
|
+
source: {
|
|
9095
|
+
...live,
|
|
9096
|
+
currentTurnAuthorId: event.authorId,
|
|
9097
|
+
currentTurnAuthorAdapter: event.adapter,
|
|
9098
|
+
currentTurnHandoff: false,
|
|
9099
|
+
lastTurnHandoff: false,
|
|
9100
|
+
},
|
|
9101
|
+
target: s,
|
|
9102
|
+
permissions,
|
|
9103
|
+
})
|
|
9104
|
+
if (!access.ok) continue
|
|
9105
|
+
if (origin === undefined || s.lastInboundAt > origin.lastInboundAt) origin = s
|
|
9106
|
+
}
|
|
9107
|
+
if (origin === undefined || live.originHintedKeys.has(origin.keyId)) return undefined
|
|
9108
|
+
live.originHintedKeys.add(origin.keyId)
|
|
9109
|
+
const k = origin.key
|
|
9110
|
+
const thread = k.thread !== null ? ` thread="${k.thread}"` : ''
|
|
9111
|
+
return (
|
|
9112
|
+
`[runtime note: this user was just talking with you in another conversation ` +
|
|
9113
|
+
`(adapter="${k.adapter}" workspace="${k.workspace}" chat="${k.chat}"${thread}). ` +
|
|
9114
|
+
'If they ask you to continue there or to deliver a result there, use `channel_handoff` with that target ' +
|
|
9115
|
+
'instead of `channel_send`, so the session that owns that conversation answers with its current context.]'
|
|
9116
|
+
)
|
|
9117
|
+
}
|
|
9118
|
+
|
|
9119
|
+
const handoff = createSessionHandoff({ sessions: liveSessions, permissions, route, logger, now })
|
|
9120
|
+
const searchSessions = createSessionSearch({
|
|
9121
|
+
sessions: liveSessions,
|
|
9122
|
+
permissions,
|
|
9123
|
+
configForAdapter: options.configForAdapter,
|
|
9124
|
+
})
|
|
9125
|
+
|
|
8840
9126
|
const injectSubagentCompletionReminder = async (args: {
|
|
8841
9127
|
parentSessionId: string
|
|
8842
9128
|
subagent: string
|
|
@@ -9451,6 +9737,11 @@ export function createChannelRouter(options: CreateChannelRouterOptions): Channe
|
|
|
9451
9737
|
registerMembership,
|
|
9452
9738
|
unregisterMembership,
|
|
9453
9739
|
registerHistory,
|
|
9740
|
+
registerMissedInbound: catchUp.register,
|
|
9741
|
+
unregisterMissedInbound: catchUp.unregister,
|
|
9742
|
+
catchUp: catchUp.run,
|
|
9743
|
+
disconnectCatchUp: catchUp.disconnect,
|
|
9744
|
+
catchUpTargets,
|
|
9454
9745
|
unregisterHistory,
|
|
9455
9746
|
fetchHistory,
|
|
9456
9747
|
registerMessageGet,
|
|
@@ -9462,6 +9753,8 @@ export function createChannelRouter(options: CreateChannelRouterOptions): Channe
|
|
|
9462
9753
|
registerEditMessage,
|
|
9463
9754
|
unregisterEditMessage,
|
|
9464
9755
|
editMessage,
|
|
9756
|
+
reviewOutbound,
|
|
9757
|
+
hasOutboundReviewer,
|
|
9465
9758
|
registerFetchAttachment,
|
|
9466
9759
|
unregisterFetchAttachment,
|
|
9467
9760
|
fetchAttachment,
|
|
@@ -9488,6 +9781,8 @@ export function createChannelRouter(options: CreateChannelRouterOptions): Channe
|
|
|
9488
9781
|
hasOutstandingGithubReviewThreadCloseout,
|
|
9489
9782
|
markTurnSkipped,
|
|
9490
9783
|
clearSticky,
|
|
9784
|
+
handoff,
|
|
9785
|
+
searchSessions,
|
|
9491
9786
|
reserveRestartHandoff,
|
|
9492
9787
|
resumeRestartHandoff,
|
|
9493
9788
|
stop,
|
|
@@ -9617,21 +9912,15 @@ export function createChannelRouter(options: CreateChannelRouterOptions): Channe
|
|
|
9617
9912
|
function collectTurnAttachments(
|
|
9618
9913
|
observed: readonly ObservedInbound[],
|
|
9619
9914
|
batch: readonly QueuedInbound[],
|
|
9620
|
-
): readonly
|
|
9621
|
-
const out:
|
|
9622
|
-
for (const item of observed)
|
|
9623
|
-
|
|
9915
|
+
): readonly TimedAttachment[] {
|
|
9916
|
+
const out: TimedAttachment[] = []
|
|
9917
|
+
for (const item of observed) for (const attachment of item.attachments ?? []) out.push({ ts: item.ts, attachment })
|
|
9918
|
+
const current = batch.at(-1)
|
|
9919
|
+
for (const item of batch)
|
|
9920
|
+
for (const attachment of item.attachments ?? []) out.push({ ts: item.ts, attachment, current: item === current })
|
|
9624
9921
|
return out
|
|
9625
9922
|
}
|
|
9626
9923
|
|
|
9627
|
-
function findAttachmentById(attachments: readonly InboundAttachment[], id: number): InboundAttachment | null {
|
|
9628
|
-
for (let i = attachments.length - 1; i >= 0; i--) {
|
|
9629
|
-
const attachment = attachments[i]
|
|
9630
|
-
if (attachment?.id === id) return attachment
|
|
9631
|
-
}
|
|
9632
|
-
return null
|
|
9633
|
-
}
|
|
9634
|
-
|
|
9635
9924
|
// Strips the platform's user/group-mention markup so a bare ping can be told
|
|
9636
9925
|
// from a mention that also carries real text. Slack and Discord both encode
|
|
9637
9926
|
// mentions as `<@id>` / `<@id|name>` (users) and `<!subteam^ID>` / `<!channel>`
|
|
@@ -9910,11 +10199,13 @@ function formatInboundPromptLines(
|
|
|
9910
10199
|
authorIsBot: boolean
|
|
9911
10200
|
text: string
|
|
9912
10201
|
referenceContext?: InboundReferenceContext
|
|
10202
|
+
routingNote?: string
|
|
9913
10203
|
},
|
|
9914
10204
|
adapter: AdapterId,
|
|
9915
10205
|
maxTextChars?: number,
|
|
9916
10206
|
): string {
|
|
9917
|
-
const lines = inbound.
|
|
10207
|
+
const lines = inbound.routingNote !== undefined ? [inbound.routingNote] : []
|
|
10208
|
+
lines.push(...(inbound.referenceContext?.sources.map(renderQuoteAnchor) ?? []))
|
|
9918
10209
|
lines.push(
|
|
9919
10210
|
formatAuthorLine(
|
|
9920
10211
|
inbound.ts,
|
|
@@ -10506,7 +10797,7 @@ function assistantLeafStopReason(session: AgentSession): 'length' | 'error' | 'a
|
|
|
10506
10797
|
// alongside its tool call and DID land a real send this turn (that trailing
|
|
10507
10798
|
// `toolUse` is delivered narration, not a stranded promise — leave it alone).
|
|
10508
10799
|
// Keys on the model having INTENDED to keep working with nothing yet said; used
|
|
10509
|
-
// to re-prompt a turn that strands mid-work after a `
|
|
10800
|
+
// to re-prompt a turn that strands mid-work after a `continue_after_reply: true` status
|
|
10510
10801
|
// reply instead of ending in silence.
|
|
10511
10802
|
function leafIsStrandedToolUse(session: AgentSession): boolean {
|
|
10512
10803
|
const leaf = branchLeafEntry(session)
|
|
@@ -10590,7 +10881,7 @@ function repairDanglingToolUseBranch(session: AgentSession, timestamp: number):
|
|
|
10590
10881
|
// (the model did more work, then dropped its conclusion) from a legitimate
|
|
10591
10882
|
// ack-then-stop where the model meant to wait for the user (leaf unchanged since
|
|
10592
10883
|
// the send). The two willingness paths below layer their own promise-signal on top
|
|
10593
|
-
// of this shape: `channel_reply({
|
|
10884
|
+
// of this shape: `channel_reply({ continue_after_reply: true })` via `continueReplyTurn`, and
|
|
10594
10885
|
// `channel_send` acks via the willingness phrase table.
|
|
10595
10886
|
function isFreshEmptyStopAfterSend(live: LiveSession): boolean {
|
|
10596
10887
|
const leaf = branchLeafEntry(live.session)
|
|
@@ -10600,10 +10891,10 @@ function isFreshEmptyStopAfterSend(live: LiveSession): boolean {
|
|
|
10600
10891
|
return leaf.id !== live.lastSendLeafId
|
|
10601
10892
|
}
|
|
10602
10893
|
|
|
10603
|
-
// The `channel_send` analogue of the `
|
|
10894
|
+
// The `channel_send` analogue of the `continue_after_reply: true` recovery: the most recent
|
|
10604
10895
|
// send to this target was a continuation-willingness ack (by phrase), then the
|
|
10605
10896
|
// model produced a fresh empty stop. `channel_send` keeps the turn alive without a
|
|
10606
|
-
// `
|
|
10897
|
+
// `continue_after_reply: true` flag and stamps no semantic marker, so the phrase table is the
|
|
10607
10898
|
// only "I promised to keep working" signal available for that shape.
|
|
10608
10899
|
function isEmptyStopAfterWillingnessAck(live: LiveSession): boolean {
|
|
10609
10900
|
if (!isFreshEmptyStopAfterSend(live)) return false
|