@gajae-code/coding-agent 0.11.0 → 0.11.2
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/CHANGELOG.md +63 -1
- package/dist/types/async/job-manager.d.ts +46 -7
- package/dist/types/cli/config-cli.d.ts +11 -1
- package/dist/types/cli/notify-cli.d.ts +1 -0
- package/dist/types/cli/session-picker.d.ts +2 -1
- package/dist/types/cli/setup-cli.d.ts +1 -1
- package/dist/types/commands/mcp-serve.d.ts +33 -0
- package/dist/types/commands/mcp.d.ts +1 -1
- package/dist/types/commands/notify.d.ts +0 -2
- package/dist/types/commands/sdk.d.ts +1 -1
- package/dist/types/config/atomic-yaml-patch.d.ts +18 -0
- package/dist/types/config/file-lock.d.ts +14 -4
- package/dist/types/config/keybindings.d.ts +42 -1
- package/dist/types/config/model-auth.d.ts +3 -0
- package/dist/types/config/model-bindings-applier.d.ts +13 -0
- package/dist/types/config/model-discovery-manager.d.ts +49 -0
- package/dist/types/config/model-equivalence.d.ts +20 -0
- package/dist/types/config/model-registry.d.ts +16 -15
- package/dist/types/config/model-resolver.d.ts +28 -18
- package/dist/types/config/models-config-schema.d.ts +11 -0
- package/dist/types/config/settings-schema.d.ts +56 -1
- package/dist/types/config/settings.d.ts +14 -11
- package/dist/types/coordinator-mcp/policy.d.ts +5 -0
- package/dist/types/coordinator-mcp/question-gate-codec.d.ts +129 -0
- package/dist/types/coordinator-mcp/question-state.d.ts +356 -0
- package/dist/types/coordinator-mcp/server.d.ts +4 -0
- package/dist/types/discovery/helpers.d.ts +0 -6
- package/dist/types/edit/index.d.ts +3 -0
- package/dist/types/eval/py/env.d.ts +9 -0
- package/dist/types/extensibility/extensions/loader.d.ts +2 -1
- package/dist/types/extensibility/extensions/runner.d.ts +2 -2
- package/dist/types/extensibility/extensions/types.d.ts +34 -3
- package/dist/types/extensibility/hooks/runner.d.ts +1 -1
- package/dist/types/extensibility/shared-events.d.ts +2 -0
- package/dist/types/gjc-runtime/deep-interview-recorder.d.ts +10 -1
- package/dist/types/gjc-runtime/deep-interview-state.d.ts +44 -0
- package/dist/types/gjc-runtime/goal-mode-request.d.ts +11 -1
- package/dist/types/gjc-runtime/launch-worktree.d.ts +4 -2
- package/dist/types/gjc-runtime/linux-proc.d.ts +29 -0
- package/dist/types/gjc-runtime/session-resolution.d.ts +2 -2
- package/dist/types/gjc-runtime/state-migrations.d.ts +1 -1
- package/dist/types/gjc-runtime/state-writer.d.ts +2 -1
- package/dist/types/gjc-runtime/team-launch.d.ts +59 -0
- package/dist/types/gjc-runtime/team-notify.d.ts +45 -0
- package/dist/types/gjc-runtime/team-runtime.d.ts +29 -121
- package/dist/types/gjc-runtime/team-store.d.ts +160 -0
- package/dist/types/gjc-runtime/team-workers.d.ts +78 -0
- package/dist/types/gjc-runtime/tmux-owner-isolation.d.ts +8 -0
- package/dist/types/gjc-runtime/ultragoal-change-set.d.ts +13 -0
- package/dist/types/gjc-runtime/ultragoal-evidence.d.ts +38 -0
- package/dist/types/gjc-runtime/ultragoal-guard.d.ts +7 -0
- package/dist/types/gjc-runtime/ultragoal-pipeline.d.ts +23 -0
- package/dist/types/gjc-runtime/ultragoal-receipt-freshness.d.ts +11 -0
- package/dist/types/gjc-runtime/ultragoal-runtime.d.ts +55 -33
- package/dist/types/gjc-runtime/workflow-cli-common.d.ts +8 -0
- package/dist/types/gjc-runtime/workflow-manifest.d.ts +3 -0
- package/dist/types/goals/continuation-timeout-guard.d.ts +22 -0
- package/dist/types/goals/runtime.d.ts +1 -0
- package/dist/types/goals/state.d.ts +8 -0
- package/dist/types/harness-control-plane/lifecycle-reconciliation.d.ts +17 -0
- package/dist/types/harness-control-plane/phase-rollup.d.ts +4 -7
- package/dist/types/harness-control-plane/receipt-ingest.d.ts +5 -0
- package/dist/types/harness-control-plane/receipt-spool.d.ts +4 -0
- package/dist/types/hindsight/state.d.ts +11 -4
- package/dist/types/lsp/lspmux.d.ts +5 -3
- package/dist/types/lsp/path-trust.d.ts +1 -0
- package/dist/types/main.d.ts +3 -2
- package/dist/types/memories/storage.d.ts +1 -0
- package/dist/types/modes/action-registry.d.ts +29 -0
- package/dist/types/modes/components/chrome.d.ts +14 -0
- package/dist/types/modes/components/command-palette.d.ts +27 -0
- package/dist/types/modes/components/custom-provider-wizard.d.ts +1 -0
- package/dist/types/modes/components/index.d.ts +2 -1
- package/dist/types/modes/components/pet-selector.d.ts +1 -1
- package/dist/types/modes/components/plan-preview-overlay.d.ts +43 -0
- package/dist/types/modes/components/queue-mode-selector.d.ts +1 -1
- package/dist/types/modes/components/queue-pane.d.ts +12 -0
- package/dist/types/modes/components/read-tool-group.d.ts +6 -0
- package/dist/types/modes/components/session-observer-overlay.d.ts +3 -4
- package/dist/types/modes/components/sessions-dashboard.d.ts +32 -0
- package/dist/types/modes/components/settings-selector.d.ts +1 -1
- package/dist/types/modes/components/show-images-selector.d.ts +1 -1
- package/dist/types/modes/components/status-line/types.d.ts +1 -1
- package/dist/types/modes/components/status-line.d.ts +1 -94
- package/dist/types/modes/components/tasks-pane.d.ts +15 -0
- package/dist/types/modes/components/theme-selector.d.ts +1 -1
- package/dist/types/modes/components/tool-execution.d.ts +15 -0
- package/dist/types/modes/components/tool-status-header.d.ts +111 -0
- package/dist/types/modes/components/transcript-viewer-overlay.d.ts +42 -0
- package/dist/types/modes/controllers/command-controller.d.ts +2 -2
- package/dist/types/modes/controllers/extension-ui-controller.d.ts +1 -0
- package/dist/types/modes/controllers/goal-mode-controller.d.ts +62 -0
- package/dist/types/modes/controllers/input-controller.d.ts +8 -1
- package/dist/types/modes/controllers/mode-gate.d.ts +8 -0
- package/dist/types/modes/controllers/plan-mode-controller.d.ts +65 -0
- package/dist/types/modes/controllers/selector-controller.d.ts +15 -3
- package/dist/types/modes/controllers/stt-controller.d.ts +26 -0
- package/dist/types/modes/interactive-mode.d.ts +21 -19
- package/dist/types/modes/jobs-observer.d.ts +2 -0
- package/dist/types/modes/shared/agent-wire/deep-interview-gate.d.ts +4 -11
- package/dist/types/modes/shared/agent-wire/workflow-gate-broker.d.ts +21 -2
- package/dist/types/modes/shared/agent-wire/workflow-gate-types.d.ts +31 -0
- package/dist/types/modes/tasks-aggregator.d.ts +39 -0
- package/dist/types/modes/transcript-item-registry.d.ts +60 -0
- package/dist/types/modes/types.d.ts +22 -15
- package/dist/types/modes/utils/ui-helpers.d.ts +2 -2
- package/dist/types/runtime-mcp/manager.d.ts +1 -1
- package/dist/types/sdk/broker/broker.d.ts +78 -12
- package/dist/types/sdk/broker/ensure.d.ts +9 -0
- package/dist/types/sdk/broker/lifecycle-codec.d.ts +4 -0
- package/dist/types/sdk/broker/lifecycle-ledger.d.ts +15 -1
- package/dist/types/sdk/broker/lifecycle.d.ts +6 -2
- package/dist/types/sdk/broker/process-incarnation.d.ts +2 -0
- package/dist/types/sdk/broker/session-index.d.ts +0 -1
- package/dist/types/sdk/broker/state-version.d.ts +2 -0
- package/dist/types/sdk/bus/chat-effect-journal.d.ts +1 -0
- package/dist/types/sdk/bus/config-commands.d.ts +1 -1
- package/dist/types/sdk/bus/config.d.ts +11 -0
- package/dist/types/sdk/bus/daemon-paths.d.ts +1 -0
- package/dist/types/sdk/bus/discord-daemon.d.ts +5 -0
- package/dist/types/sdk/bus/html-format.d.ts +3 -2
- package/dist/types/sdk/bus/index.d.ts +27 -0
- package/dist/types/sdk/bus/lifecycle-control-runtime.d.ts +4 -0
- package/dist/types/sdk/bus/notification-service.d.ts +20 -0
- package/dist/types/sdk/bus/rate-limit-pool.d.ts +13 -2
- package/dist/types/sdk/bus/recent-activity.d.ts +21 -12
- package/dist/types/sdk/bus/rich-document.d.ts +7 -0
- package/dist/types/sdk/bus/rich-render.d.ts +18 -41
- package/dist/types/sdk/bus/telegram-daemon-contract.d.ts +9 -4
- package/dist/types/sdk/bus/telegram-daemon.d.ts +69 -3
- package/dist/types/sdk/bus/threaded-inbound.d.ts +1 -1
- package/dist/types/sdk/bus/threaded-render.d.ts +13 -0
- package/dist/types/sdk/bus/topic-registry.d.ts +24 -2
- package/dist/types/sdk/host/control/operations.d.ts +1 -1
- package/dist/types/sdk/host/host.d.ts +2 -0
- package/dist/types/sdk/index.d.ts +1 -0
- package/dist/types/sdk/session-directory.d.ts +56 -0
- package/dist/types/session/agent-session.d.ts +82 -47
- package/dist/types/session/agent-storage.d.ts +7 -0
- package/dist/types/session/fallback-chain-controller.d.ts +10 -2
- package/dist/types/session/internal/managed-session-scope.d.ts +102 -0
- package/dist/types/session/internal/managed-session-storage.d.ts +38 -0
- package/dist/types/session/messages.d.ts +16 -0
- package/dist/types/session/session-manager-internal.d.ts +14 -0
- package/dist/types/session/session-manager.d.ts +82 -12
- package/dist/types/session/session-storage.d.ts +43 -3
- package/dist/types/session/volatile-context-pruning.d.ts +15 -0
- package/dist/types/skill-state/{deep-interview-mutation-guard.d.ts → workflow-mutation-guard.d.ts} +24 -8
- package/dist/types/skill-state/workflow-state-contract.d.ts +1 -3
- package/dist/types/slash-commands/builtin-registry.d.ts +4 -1
- package/dist/types/system-prompt.d.ts +2 -11
- package/dist/types/task/executor.d.ts +3 -1
- package/dist/types/thinking.d.ts +7 -0
- package/dist/types/tool-discovery/tool-index.d.ts +1 -50
- package/dist/types/tools/ask.d.ts +64 -2
- package/dist/types/tools/bash.d.ts +3 -0
- package/dist/types/tools/browser/dead-tab-recovery.d.ts +24 -0
- package/dist/types/tools/browser/tab-supervisor.d.ts +21 -0
- package/dist/types/tools/cron.d.ts +2 -0
- package/dist/types/tools/fetch.d.ts +1 -0
- package/dist/types/tools/index.d.ts +30 -15
- package/dist/types/tools/output-meta.d.ts +1 -0
- package/dist/types/tools/read.d.ts +3 -0
- package/dist/types/tools/search-tool-bm25.d.ts +3 -4
- package/dist/types/tools/subagent-render.d.ts +1 -0
- package/dist/types/tools/subagent.d.ts +6 -1
- package/dist/types/utils/event-bus.d.ts +1 -1
- package/dist/types/web/search/index.d.ts +3 -1
- package/package.json +21 -9
- package/scripts/build-sdk-package-smoke.ts +39 -1
- package/scripts/generate-hotkeys-docs.ts +74 -0
- package/scripts/generate-sdk-operation-inventory.ts +64 -20
- package/scripts/verify-gjc-sdk-canonicalization.ts +182 -2
- package/src/async/job-manager.ts +455 -69
- package/src/cli/config-cli.ts +75 -2
- package/src/cli/notify-cli.ts +92 -26
- package/src/cli/session-picker.ts +20 -3
- package/src/cli/setup-cli.ts +1 -1
- package/src/cli.ts +1 -1
- package/src/commands/config.ts +1 -1
- package/src/commands/harness.ts +34 -106
- package/src/commands/launch.ts +6 -4
- package/src/commands/mcp-serve.ts +85 -8
- package/src/commands/mcp.ts +2 -2
- package/src/commands/notify.ts +8 -4
- package/src/commands/sdk.ts +61 -40
- package/src/commands/ultragoal.ts +4 -1
- package/src/config/atomic-yaml-patch.ts +80 -13
- package/src/config/file-lock.ts +105 -43
- package/src/config/keybindings.ts +64 -20
- package/src/config/model-auth.ts +9 -0
- package/src/config/model-bindings-applier.ts +139 -0
- package/src/config/model-discovery-manager.ts +224 -0
- package/src/config/model-equivalence.ts +66 -0
- package/src/config/model-registry.ts +169 -302
- package/src/config/model-resolver.ts +361 -369
- package/src/config/models-config-schema.ts +5 -4
- package/src/config/settings-schema.ts +159 -2
- package/src/config/settings.ts +458 -482
- package/src/coordinator-mcp/policy.ts +76 -11
- package/src/coordinator-mcp/question-gate-codec.ts +274 -0
- package/src/coordinator-mcp/question-state.ts +778 -0
- package/src/coordinator-mcp/server.ts +1702 -238
- package/src/debug/index.ts +1 -1
- package/src/defaults/gjc/skills/deep-interview/SKILL.md +13 -1
- package/src/defaults/gjc/skills/team/SKILL.md +16 -0
- package/src/discovery/helpers.ts +1 -50
- package/src/edit/index.ts +64 -0
- package/src/eval/py/env.ts +26 -0
- package/src/eval/py/kernel.ts +5 -3
- package/src/extensibility/extensions/loader.ts +9 -1
- package/src/extensibility/extensions/runner.ts +12 -3
- package/src/extensibility/extensions/types.ts +39 -1
- package/src/extensibility/gjc-plugins/installer.ts +16 -16
- package/src/extensibility/hooks/runner.ts +2 -2
- package/src/extensibility/runtime-skill-discovery.ts +33 -13
- package/src/extensibility/shared-events.ts +2 -0
- package/src/gjc-runtime/deep-interview-recorder.ts +63 -3
- package/src/gjc-runtime/deep-interview-runtime.ts +76 -27
- package/src/gjc-runtime/deep-interview-state.ts +317 -5
- package/src/gjc-runtime/goal-mode-request.ts +55 -8
- package/src/gjc-runtime/launch-tmux.ts +2 -5
- package/src/gjc-runtime/launch-worktree.ts +5 -5
- package/src/gjc-runtime/linux-proc.ts +71 -0
- package/src/gjc-runtime/ralplan-runtime.ts +74 -90
- package/src/gjc-runtime/session-resolution.ts +18 -3
- package/src/gjc-runtime/session-state-sidecar.ts +6 -107
- package/src/gjc-runtime/state-migrations.ts +1 -1
- package/src/gjc-runtime/state-runtime.ts +320 -249
- package/src/gjc-runtime/state-writer.ts +36 -40
- package/src/gjc-runtime/team-launch.ts +319 -0
- package/src/gjc-runtime/team-notify.ts +326 -0
- package/src/gjc-runtime/team-runtime.ts +1099 -1482
- package/src/gjc-runtime/team-store.ts +828 -0
- package/src/gjc-runtime/team-workers.ts +962 -0
- package/src/gjc-runtime/tmux-owner-isolation-cli.ts +2 -11
- package/src/gjc-runtime/tmux-owner-isolation.ts +14 -9
- package/src/gjc-runtime/tmux-sessions.ts +4 -21
- package/src/gjc-runtime/ultragoal-change-set.ts +172 -0
- package/src/gjc-runtime/ultragoal-evidence.ts +874 -0
- package/src/gjc-runtime/ultragoal-guard.ts +83 -12
- package/src/gjc-runtime/ultragoal-pipeline.ts +306 -0
- package/src/gjc-runtime/ultragoal-receipt-freshness.ts +102 -1
- package/src/gjc-runtime/ultragoal-runtime.ts +156 -1319
- package/src/gjc-runtime/workflow-cli-common.ts +30 -0
- package/src/gjc-runtime/workflow-manifest.generated.json +58 -0
- package/src/gjc-runtime/workflow-manifest.ts +18 -0
- package/src/goals/continuation-timeout-guard.ts +79 -0
- package/src/goals/runtime.ts +7 -5
- package/src/goals/state.ts +18 -0
- package/src/harness-control-plane/lifecycle-reconciliation.ts +64 -0
- package/src/harness-control-plane/phase-rollup.ts +4 -7
- package/src/harness-control-plane/receipt-ingest.ts +5 -0
- package/src/harness-control-plane/receipt-spool.ts +51 -7
- package/src/harness-control-plane/session-lease.ts +12 -130
- package/src/hindsight/backend.ts +26 -27
- package/src/hindsight/state.ts +101 -32
- package/src/hooks/skill-state.ts +17 -11
- package/src/internal-urls/docs-index.generated.ts +21 -18
- package/src/lsp/client.ts +1 -1
- package/src/lsp/config.ts +145 -26
- package/src/lsp/index.ts +1 -1
- package/src/lsp/lspmux.ts +39 -10
- package/src/lsp/path-trust.ts +81 -0
- package/src/main.ts +28 -8
- package/src/memories/index.ts +1 -0
- package/src/memories/storage.ts +6 -2
- package/src/modes/action-registry.ts +165 -0
- package/src/modes/components/chrome.ts +40 -0
- package/src/modes/components/command-palette.ts +168 -0
- package/src/modes/components/custom-editor.ts +1 -1
- package/src/modes/components/custom-provider-wizard.ts +51 -14
- package/src/modes/components/index.ts +2 -1
- package/src/modes/components/pet-selector.ts +11 -17
- package/src/modes/components/plan-preview-overlay.ts +295 -0
- package/src/modes/components/queue-mode-selector.ts +10 -27
- package/src/modes/components/queue-pane.ts +79 -0
- package/src/modes/components/read-tool-group.ts +13 -0
- package/src/modes/components/session-observer-overlay.ts +207 -772
- package/src/modes/components/sessions-dashboard.ts +181 -0
- package/src/modes/components/settings-selector.ts +1 -1
- package/src/modes/components/show-images-selector.ts +10 -24
- package/src/modes/components/status-line/types.ts +1 -1
- package/src/modes/components/status-line.ts +1 -969
- package/src/modes/components/tasks-pane.ts +73 -0
- package/src/modes/components/theme-selector.ts +11 -31
- package/src/modes/components/tool-execution.ts +22 -0
- package/src/modes/components/tool-status-header.ts +1056 -0
- package/src/modes/components/transcript-viewer-overlay.ts +384 -0
- package/src/modes/controllers/btw-controller.ts +1 -0
- package/src/modes/controllers/command-controller.ts +9 -15
- package/src/modes/controllers/event-controller.ts +3 -2
- package/src/modes/controllers/extension-ui-controller.ts +72 -25
- package/src/modes/controllers/goal-mode-controller.ts +474 -0
- package/src/modes/controllers/input-controller.ts +764 -229
- package/src/modes/controllers/mode-gate.ts +24 -0
- package/src/modes/controllers/plan-mode-controller.ts +517 -0
- package/src/modes/controllers/selector-controller.ts +225 -10
- package/src/modes/controllers/stt-controller.ts +125 -0
- package/src/modes/interactive-mode.ts +302 -1151
- package/src/modes/jobs-observer.ts +3 -0
- package/src/modes/runtime-init.ts +8 -0
- package/src/modes/shared/agent-wire/deep-interview-gate.ts +31 -106
- package/src/modes/shared/agent-wire/workflow-gate-broker.ts +78 -19
- package/src/modes/shared/agent-wire/workflow-gate-types.ts +177 -0
- package/src/modes/tasks-aggregator.ts +199 -0
- package/src/modes/transcript-item-registry.ts +229 -0
- package/src/modes/types.ts +47 -20
- package/src/modes/utils/ui-helpers.ts +17 -9
- package/src/prompts/agent-fragments/ralplan-persistence.md +6 -0
- package/src/prompts/agent-fragments/restricted-bash.md +1 -0
- package/src/prompts/agents/architect.md +2 -8
- package/src/prompts/agents/critic.md +2 -8
- package/src/prompts/agents/executor.md +3 -0
- package/src/prompts/agents/planner.md +4 -12
- package/src/prompts/system/custom-system-prompt.md +1 -23
- package/src/prompts/system/plan-mode-approved.md +8 -0
- package/src/prompts/system/system-prompt.md +17 -96
- package/src/prompts/tools/bash.md +4 -4
- package/src/prompts/tools/browser.md +15 -52
- package/src/prompts/tools/find.md +2 -2
- package/src/prompts/tools/hashline.md +13 -55
- package/src/prompts/tools/read.md +3 -6
- package/src/prompts/tools/search-tool-bm25.md +0 -2
- package/src/prompts/tools/search.md +2 -4
- package/src/prompts/tools/skill-discovery.md +1 -2
- package/src/prompts/tools/task.md +1 -1
- package/src/runtime-mcp/manager.ts +1 -1
- package/src/sdk/broker/broker.ts +206 -78
- package/src/sdk/broker/discovery.ts +21 -2
- package/src/sdk/broker/ensure.ts +85 -25
- package/src/sdk/broker/lifecycle-codec.ts +11 -0
- package/src/sdk/broker/lifecycle-ledger.ts +371 -74
- package/src/sdk/broker/lifecycle.ts +1399 -142
- package/src/sdk/broker/process-incarnation.ts +5 -13
- package/src/sdk/broker/session-index.ts +145 -56
- package/src/sdk/broker/state-version.ts +21 -0
- package/src/sdk/broker/transport.ts +1 -1
- package/src/sdk/bus/chat-daemon-cli.ts +2 -0
- package/src/sdk/bus/chat-daemon-control.ts +8 -28
- package/src/sdk/bus/chat-effect-journal.ts +14 -4
- package/src/sdk/bus/config-commands.ts +5 -4
- package/src/sdk/bus/config.ts +98 -0
- package/src/sdk/bus/conversation-store.ts +5 -29
- package/src/sdk/bus/daemon-paths.ts +2 -0
- package/src/sdk/bus/discord-daemon.ts +25 -8
- package/src/sdk/bus/html-format.ts +20 -3
- package/src/sdk/bus/index.ts +834 -113
- package/src/sdk/bus/lifecycle-control-runtime.ts +91 -33
- package/src/sdk/bus/native-runtime-compatibility.ts +1 -1
- package/src/sdk/bus/natives-augment.d.ts +26 -1
- package/src/sdk/bus/notification-service.ts +168 -20
- package/src/sdk/bus/rate-limit-pool.ts +58 -14
- package/src/sdk/bus/recent-activity.ts +188 -74
- package/src/sdk/bus/rich-document.ts +258 -0
- package/src/sdk/bus/rich-render.ts +62 -70
- package/src/sdk/bus/telegram-daemon-cli.ts +15 -59
- package/src/sdk/bus/telegram-daemon-contract.ts +9 -4
- package/src/sdk/bus/telegram-daemon.ts +1491 -247
- package/src/sdk/bus/threaded-inbound.ts +8 -3
- package/src/sdk/bus/threaded-render.ts +57 -1
- package/src/sdk/bus/topic-registry.ts +120 -13
- package/src/sdk/host/control/dispatch.ts +14 -2
- package/src/sdk/host/control/operations.ts +6 -1
- package/src/sdk/host/host.ts +31 -1
- package/src/sdk/host/query/handlers.ts +20 -22
- package/src/sdk/host/query/revision-store.ts +80 -57
- package/src/sdk/index.ts +1 -0
- package/src/sdk/protocol/operation-inventory.generated.json +943 -1907
- package/src/sdk/session-directory.ts +141 -0
- package/src/sdk/session.ts +458 -479
- package/src/session/agent-session.ts +1901 -637
- package/src/session/agent-storage.ts +18 -0
- package/src/session/cache-economics.ts +25 -8
- package/src/session/fallback-chain-controller.ts +53 -3
- package/src/session/internal/managed-session-scope.ts +2226 -0
- package/src/session/internal/managed-session-storage.ts +453 -0
- package/src/session/messages.ts +91 -2
- package/src/session/session-manager-internal.ts +33 -0
- package/src/session/session-manager.ts +1112 -333
- package/src/session/session-storage.ts +444 -39
- package/src/session/volatile-context-pruning.ts +78 -0
- package/src/setup/credential-auto-import.ts +2 -1
- package/src/setup/hermes/templates/operator-instructions.v1.md +1 -1
- package/src/setup/provider-onboarding.ts +36 -61
- package/src/setup/provider-presets.json +5 -0
- package/src/skill-state/active-state.ts +3 -13
- package/src/skill-state/{deep-interview-mutation-guard.ts → workflow-mutation-guard.ts} +47 -29
- package/src/skill-state/workflow-state-contract.ts +6 -41
- package/src/slash-commands/builtin-registry.ts +46 -11
- package/src/system-prompt.ts +37 -44
- package/src/task/agents.ts +19 -1
- package/src/task/executor.ts +90 -6
- package/src/task/index.ts +62 -37
- package/src/thinking.ts +21 -6
- package/src/tool-discovery/tool-index.ts +2 -134
- package/src/tools/ask.ts +157 -21
- package/src/tools/ast-edit.ts +1 -1
- package/src/tools/bash.ts +38 -0
- package/src/tools/browser/dead-tab-recovery.ts +78 -0
- package/src/tools/browser/tab-supervisor.ts +282 -36
- package/src/tools/computer.ts +10 -3
- package/src/tools/cron.ts +30 -16
- package/src/tools/eval.ts +1 -2
- package/src/tools/fetch.ts +11 -4
- package/src/tools/index.ts +76 -24
- package/src/tools/output-meta.ts +13 -5
- package/src/tools/read.ts +37 -1
- package/src/tools/resource-gc.ts +2 -2
- package/src/tools/search-tool-bm25.ts +11 -74
- package/src/tools/subagent-render.ts +19 -8
- package/src/tools/subagent.ts +84 -32
- package/src/utils/event-bus.ts +9 -4
- package/src/web/search/index.ts +3 -3
- package/dist/types/discovery/plugin-dir-roots.d.ts +0 -15
- package/dist/types/runtime-mcp/discoverable-tool-metadata.d.ts +0 -7
- package/src/discovery/plugin-dir-roots.ts +0 -28
- package/src/runtime-mcp/discoverable-tool-metadata.ts +0 -25
|
@@ -41,6 +41,11 @@ export interface RateLimitItem<T = unknown> {
|
|
|
41
41
|
/** Opaque payload the caller maps to an actual Telegram send. */
|
|
42
42
|
payload: T;
|
|
43
43
|
}
|
|
44
|
+
export type RateLimitDisposition = "queued" | "sending" | "accepted" | "rejected" | "ambiguous" | "removed" | "expired";
|
|
45
|
+
export interface RateLimitHandle {
|
|
46
|
+
itemId: string;
|
|
47
|
+
settled: Promise<Exclude<RateLimitDisposition, "queued" | "sending">>;
|
|
48
|
+
}
|
|
44
49
|
/** Options for {@link RateLimitPool}. */
|
|
45
50
|
export interface RateLimitPoolOptions {
|
|
46
51
|
/** Burst capacity (max tokens). Default 20 (Telegram per-chat burst). */
|
|
@@ -74,6 +79,7 @@ export declare class RateLimitPool<T = unknown> {
|
|
|
74
79
|
private readonly laneCursor;
|
|
75
80
|
private tokens;
|
|
76
81
|
private lastRefill;
|
|
82
|
+
private readonly settlements;
|
|
77
83
|
private seqCounter;
|
|
78
84
|
constructor(options?: RateLimitPoolOptions);
|
|
79
85
|
/** Number of items currently queued across all lanes. */
|
|
@@ -85,7 +91,12 @@ export declare class RateLimitPool<T = unknown> {
|
|
|
85
91
|
* item in the same `(sessionId, lane)` replace its payload (latest wins)
|
|
86
92
|
* while preserving FIFO position; identified items are always appended.
|
|
87
93
|
*/
|
|
88
|
-
submit(item: RateLimitItem<T>):
|
|
94
|
+
submit(item: RateLimitItem<T>): RateLimitHandle;
|
|
95
|
+
/** Settle a stable item after its external transport effect has a known outcome. */
|
|
96
|
+
settle(itemId: string, disposition: Exclude<RateLimitDisposition, "queued" | "sending">): void;
|
|
97
|
+
/** Mark a granted item as owned by an external transport effect. */
|
|
98
|
+
markSending(itemId: string): void;
|
|
99
|
+
private handle;
|
|
89
100
|
/**
|
|
90
101
|
* Grant as many queued items as tokens allow at `nowMs`. This compatibility
|
|
91
102
|
* wrapper discards items that expired during the drain.
|
|
@@ -98,7 +109,7 @@ export declare class RateLimitPool<T = unknown> {
|
|
|
98
109
|
*/
|
|
99
110
|
drainWithExpired(nowMs?: number): RateLimitDrainResult<T>;
|
|
100
111
|
/** Remove queued items matching `predicate` without consuming tokens. Returns removed items in lane/FIFO order. */
|
|
101
|
-
removeWhere(predicate: (item: RateLimitItem<T>) => boolean): RateLimitItem<T>[];
|
|
112
|
+
removeWhere(predicate: (item: RateLimitItem<T>) => boolean, disposition?: Exclude<RateLimitDisposition, "queued" | "sending">): RateLimitItem<T>[];
|
|
102
113
|
/** Remove exactly one queued item by its stable id without consuming a token. */
|
|
103
114
|
removeById(itemId: string): RateLimitItem<T> | undefined;
|
|
104
115
|
private refill;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/** One ranked recent-session entry surfaced to the picker. */
|
|
2
2
|
export interface RecentSessionEntry {
|
|
3
|
-
/** Session id
|
|
3
|
+
/** Session id from the validated managed candidate header. */
|
|
4
4
|
sessionId: string;
|
|
5
|
-
/**
|
|
5
|
+
/** Validated workspace path recorded by the managed candidate. */
|
|
6
6
|
path?: string;
|
|
7
7
|
/** Branch, when recoverable from the header. */
|
|
8
8
|
branch?: string;
|
|
@@ -18,22 +18,31 @@ export interface RecentSessionEntry {
|
|
|
18
18
|
internal?: boolean;
|
|
19
19
|
}
|
|
20
20
|
export interface RecentActivityDeps {
|
|
21
|
-
/**
|
|
22
|
-
|
|
21
|
+
/** Workspace whose managed sessions will be listed readonly. */
|
|
22
|
+
cwd: string;
|
|
23
|
+
/** Agent directory used to resolve the managed session scope. */
|
|
24
|
+
agentDir?: string;
|
|
25
|
+
/** Explicit managed root for isolated tests. */
|
|
26
|
+
sessionsRoot?: string;
|
|
23
27
|
/** Optional breadcrumb session-file paths (current terminals). */
|
|
24
28
|
breadcrumbPaths?: string[];
|
|
25
29
|
/** Max entries to return (default 20). */
|
|
26
30
|
limit?: number;
|
|
27
31
|
/** Include internal helper/sub-agent sessions (default true). */
|
|
28
32
|
includeInternal?: boolean;
|
|
33
|
+
/** Search every validated v2 workspace scope below the session root (default false). */
|
|
34
|
+
allWorkspaces?: boolean;
|
|
29
35
|
/** Injection seam for tests. */
|
|
30
36
|
readInitialLines?: (file: string, maxLines: number) => string[];
|
|
31
37
|
}
|
|
32
|
-
/**
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
38
|
+
/** Lists readonly managed candidates, optionally across every validated v2 workspace scope, ranked by history-file mtime. */
|
|
39
|
+
export type ListRecentSessionsResult = {
|
|
40
|
+
kind: "complete";
|
|
41
|
+
entries: RecentSessionEntry[];
|
|
42
|
+
warnings: readonly string[];
|
|
43
|
+
} | {
|
|
44
|
+
kind: "error";
|
|
45
|
+
code: "scope_unavailable" | "managed_scan_failed";
|
|
46
|
+
message: string;
|
|
47
|
+
};
|
|
48
|
+
export declare function listRecentSessions(deps: RecentActivityDeps): Promise<ListRecentSessionsResult>;
|
|
@@ -2,26 +2,17 @@
|
|
|
2
2
|
* Rich-message promotion for stable non-editable Telegram text sends.
|
|
3
3
|
*
|
|
4
4
|
* When enabled, the daemon promotes eligible finalized `sendMessage` payloads
|
|
5
|
-
* carrying raw markdown to
|
|
6
|
-
*
|
|
7
|
-
*
|
|
5
|
+
* carrying raw markdown to Bot API `sendRichMessage`. Only an explicit
|
|
6
|
+
* `{ ok: false }` response selects the unchanged HTML path; ambiguous transport
|
|
7
|
+
* outcomes remain single-attempt and never fall back.
|
|
8
8
|
*/
|
|
9
9
|
import type { BotApi } from "./telegram-daemon";
|
|
10
10
|
import type { ThreadedSend } from "./threaded-render";
|
|
11
11
|
/**
|
|
12
|
-
* Telegram's hard per-message character ceiling (4096).
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
* Overflow is already safe without it. The production final-answer text is capped
|
|
18
|
-
* at 3500 chars upstream (`summaryFromMessage(..., 3500)`), so a promoted
|
|
19
|
-
* `sendRichMessage` never approaches this ceiling; and if the Bot API ever rejects
|
|
20
|
-
* an oversized rich payload it returns `{ ok: false }`, which
|
|
21
|
-
* `deliverRichWithFallback` (below) turns into the chunked HTML `splitTelegramHtml`
|
|
22
|
-
* fallback (each chunk ≤ TELEGRAM_MESSAGE_LIMIT). This constant only marks where a
|
|
23
|
-
* future rich splitter would read its ceiling; wiring it into a branch would change
|
|
24
|
-
* byte-for-byte behavior and is out of scope.
|
|
12
|
+
* Telegram's hard per-message character ceiling (4096). Final-answer promotion
|
|
13
|
+
* uses this value to keep oversized Markdown on the existing chunked HTML path.
|
|
14
|
+
* `/btw` eligibility has its own 32,768-scalar route guard; only a definite
|
|
15
|
+
* rich rejection may select the correlated HTML path.
|
|
25
16
|
*/
|
|
26
17
|
export declare const RICH_MESSAGE_LIMIT = 4096;
|
|
27
18
|
/** Wrap raw markdown in the `sendRichMessage` request payload shape. */
|
|
@@ -30,9 +21,12 @@ export declare function buildRichMessage(raw: string, extras?: {
|
|
|
30
21
|
}): {
|
|
31
22
|
rich_message: {
|
|
32
23
|
markdown: string;
|
|
24
|
+
skip_entity_detection: true;
|
|
33
25
|
};
|
|
34
26
|
reply_markup?: unknown;
|
|
35
27
|
};
|
|
28
|
+
/** Whether `/btw` Markdown may use Bot API 10.1 rich delivery. */
|
|
29
|
+
export declare function isBtwRichEligible(markdown: string): boolean;
|
|
36
30
|
/**
|
|
37
31
|
* Whether a granted send should be promoted to `sendRichMessage`. Fail-closed
|
|
38
32
|
* and class-aware: every clause must hold, otherwise the daemon keeps the HTML path.
|
|
@@ -42,37 +36,21 @@ export declare function shouldPromoteRich(input: {
|
|
|
42
36
|
send: ThreadedSend;
|
|
43
37
|
}): boolean;
|
|
44
38
|
/**
|
|
45
|
-
* Deliver the promoted rich message, falling back to `fallbackDeliver`
|
|
46
|
-
*
|
|
47
|
-
*
|
|
48
|
-
* returns `res.json()` for JSON methods, so `ok:false` does not throw). On
|
|
49
|
-
* failure exactly one diagnostic is logged before the fallback runs; on success
|
|
50
|
-
* the fallback never runs.
|
|
51
|
-
*
|
|
52
|
-
* Returns the sent message's `message_id` on success (when the response carries
|
|
53
|
-
* one), otherwise `undefined` — including every failure/fallback path and a
|
|
54
|
-
* success whose response omits `result.message_id`. Callers that ignore the
|
|
55
|
-
* return value are unaffected.
|
|
39
|
+
* Deliver the promoted rich message, falling back to `fallbackDeliver` only
|
|
40
|
+
* after an explicit `{ ok: false }` response. Transport errors and malformed or
|
|
41
|
+
* ambiguous responses are logged but never retried or sent again through HTML.
|
|
56
42
|
*/
|
|
57
43
|
export declare function deliverRichWithFallback(botApi: BotApi, base: {
|
|
58
44
|
chat_id: string | number;
|
|
59
45
|
message_thread_id?: number;
|
|
60
|
-
}, send: ThreadedSend, fallbackDeliver: () => Promise<void>, log?: {
|
|
46
|
+
}, send: ThreadedSend, signal: AbortSignal, fallbackDeliver: () => Promise<void>, log?: {
|
|
61
47
|
warn(msg: string): void;
|
|
62
48
|
}): Promise<number | undefined>;
|
|
63
49
|
/**
|
|
64
50
|
* Deliver an action-needed (ask/idle) message via `sendRichMessage`, falling
|
|
65
|
-
* back to the unchanged HTML chunk loop
|
|
66
|
-
*
|
|
67
|
-
*
|
|
68
|
-
* `reply_markup` alongside `rich_message`), and surfaces a structured outcome so
|
|
69
|
-
* the daemon can route inbound replies to the resulting message id.
|
|
70
|
-
*
|
|
71
|
-
* On rich success: returns `{ messageId, usedRich: true, usedFallback: false }`
|
|
72
|
-
* where `messageId` is `res.result.message_id` when present. On a `{ ok:false }`
|
|
73
|
-
* response or a thrown transport error: warns exactly once, runs `htmlFallback`,
|
|
74
|
-
* and returns `{ messageId, usedRich: false, usedFallback: true }` where
|
|
75
|
-
* `messageId` is the fallback's return value (the last HTML chunk's id).
|
|
51
|
+
* back to the unchanged HTML chunk loop only after an explicit `{ ok:false }`
|
|
52
|
+
* response. Other outcomes are ambiguous, are logged, and preserve the single
|
|
53
|
+
* physical rich delivery.
|
|
76
54
|
*/
|
|
77
55
|
export declare function deliverRichActionWithFallback(botApi: BotApi, base: {
|
|
78
56
|
chat_id: string | number;
|
|
@@ -80,8 +58,7 @@ export declare function deliverRichActionWithFallback(botApi: BotApi, base: {
|
|
|
80
58
|
}, opts: {
|
|
81
59
|
markdown: string;
|
|
82
60
|
replyMarkup?: unknown;
|
|
83
|
-
|
|
84
|
-
}, htmlFallback: () => Promise<number | undefined>, log?: {
|
|
61
|
+
}, signal: AbortSignal, htmlFallback: () => Promise<number | undefined>, log?: {
|
|
85
62
|
warn(msg: string): void;
|
|
86
63
|
}): Promise<{
|
|
87
64
|
messageId?: number;
|
|
@@ -5,8 +5,13 @@
|
|
|
5
5
|
/** Protocol version the daemon advertises in its ClientHello. */
|
|
6
6
|
export declare const NOTIFICATION_PROTOCOL_VERSION = 3;
|
|
7
7
|
/**
|
|
8
|
-
* Operational generation the current daemon build speaks.
|
|
9
|
-
*
|
|
10
|
-
*
|
|
8
|
+
* Operational generation the current daemon build speaks. Decoupled from
|
|
9
|
+
* {@link NOTIFICATION_PROTOCOL_VERSION} (#2304): additive `tool_activity` /
|
|
10
|
+
* `reasoning_summary` frames do not bump the wire protocol version, but a
|
|
11
|
+
* freshly-upgraded host must still recognize an older, still-live daemon that
|
|
12
|
+
* predates capability-gated frame enforcement and trigger a reload. Bump this
|
|
13
|
+
* on every daemon-behavior change independent of the wire version.
|
|
14
|
+
* The current development baseline already includes #2299's generation 4;
|
|
15
|
+
* this behavior change therefore advances the operational generation to 5.
|
|
11
16
|
*/
|
|
12
|
-
export declare const DAEMON_GENERATION =
|
|
17
|
+
export declare const DAEMON_GENERATION = 5;
|
|
@@ -18,6 +18,11 @@ export interface DaemonState {
|
|
|
18
18
|
startedAt: number;
|
|
19
19
|
heartbeatAt: number;
|
|
20
20
|
roots: string[];
|
|
21
|
+
/**
|
|
22
|
+
* Present only for the Windows source-launch handoff. `pid` starts as this
|
|
23
|
+
* short-lived launcher PID and may be rebound exactly once to the daemon PID.
|
|
24
|
+
*/
|
|
25
|
+
launcherPid?: number;
|
|
21
26
|
version: 1;
|
|
22
27
|
/**
|
|
23
28
|
* Operational daemon generation of the process that owns the lock, distinct
|
|
@@ -55,6 +60,8 @@ export interface TelegramDaemonDeps {
|
|
|
55
60
|
logPath?: string;
|
|
56
61
|
}) => SpawnResult;
|
|
57
62
|
execPath?: string;
|
|
63
|
+
/** Injectable platform seam for source-linked Windows daemon spawning. */
|
|
64
|
+
platform?: NodeJS.Platform;
|
|
58
65
|
randomId?: () => string;
|
|
59
66
|
/**
|
|
60
67
|
* Signal delivery + poll timing for the stale-generation reload handoff in
|
|
@@ -73,6 +80,11 @@ export declare const CLIENT_PING_PONG_CAPABILITY = "client_ping_pong";
|
|
|
73
80
|
/** Capability required for typed controls and semantic Selected acknowledgement frames. */
|
|
74
81
|
export declare const ASK_SELECTED_ACK_CAPABILITY = "ask_selected_ack_v1";
|
|
75
82
|
export declare const ASK_CONTROLS_CAPABILITY = "ask_controls_v1";
|
|
83
|
+
/** Capability required for tool lifecycle and reasoning-summary frames. */
|
|
84
|
+
export declare const TOOL_ACTIVITY_CAPABILITY = "tool_activity_v1";
|
|
85
|
+
export declare const BTW_QUESTION_MAX_UNICODE_SCALARS = 4096;
|
|
86
|
+
export declare const BTW_QUESTION_MAX_UTF8_BYTES = 16384;
|
|
87
|
+
export declare function endpointAuthorityDigest(url: string, token: string, connectionIdentity?: string): string;
|
|
76
88
|
export { type DaemonPaths, daemonPaths } from "./daemon-paths";
|
|
77
89
|
export declare function deriveLifecycleAuditRedactionKey(botToken: string): Uint8Array;
|
|
78
90
|
/**
|
|
@@ -126,6 +138,10 @@ export declare function acquireDaemonOwnership(input: {
|
|
|
126
138
|
pid?: number;
|
|
127
139
|
pidAlive?: (pid: number) => boolean;
|
|
128
140
|
randomId?: () => string;
|
|
141
|
+
/** Permit one Windows source launcher PID to daemon PID handoff. */
|
|
142
|
+
allowPidRebind?: boolean;
|
|
143
|
+
/** A caller-supplied opaque owner identity, used when the launcher PID is not durable. */
|
|
144
|
+
ownerId?: string;
|
|
129
145
|
}): Promise<{
|
|
130
146
|
acquired: boolean;
|
|
131
147
|
ownerId?: string;
|
|
@@ -137,13 +153,22 @@ export declare function acquireDaemonOwnership(input: {
|
|
|
137
153
|
export declare function renewDaemonHeartbeat(input: {
|
|
138
154
|
settings: Settings;
|
|
139
155
|
ownerId: string;
|
|
156
|
+
/** Bind a daemon heartbeat to the Telegram identity that acquired the lock. */
|
|
157
|
+
tokenFingerprint: string;
|
|
158
|
+
chatId: string;
|
|
159
|
+
/** Require the current daemon PID after the launcher-to-daemon PID rebind. */
|
|
160
|
+
pid: number;
|
|
140
161
|
fs?: TelegramDaemonFs;
|
|
141
162
|
now?: () => number;
|
|
142
|
-
pid?: number;
|
|
143
163
|
}): Promise<boolean>;
|
|
144
164
|
export declare function releaseDaemonOwnership(input: {
|
|
145
165
|
settings: Settings;
|
|
146
166
|
ownerId: string;
|
|
167
|
+
/** Bind release to the Telegram identity that acquired the lock. */
|
|
168
|
+
tokenFingerprint: string;
|
|
169
|
+
chatId: string;
|
|
170
|
+
/** Require the current daemon PID after the launcher-to-daemon PID rebind. */
|
|
171
|
+
pid: number;
|
|
147
172
|
fs?: TelegramDaemonFs;
|
|
148
173
|
now?: () => number;
|
|
149
174
|
}): Promise<void>;
|
|
@@ -230,17 +255,40 @@ export declare class TelegramBotTransport implements BotApi {
|
|
|
230
255
|
}): Promise<unknown>;
|
|
231
256
|
}
|
|
232
257
|
export type TelegramUpdateOutcome = "consumed" | "retry";
|
|
258
|
+
export type TelegramPollResult = {
|
|
259
|
+
kind: "success";
|
|
260
|
+
updateCount: number;
|
|
261
|
+
} | {
|
|
262
|
+
kind: "aborted";
|
|
263
|
+
} | {
|
|
264
|
+
kind: "getUpdates_failed";
|
|
265
|
+
error: string;
|
|
266
|
+
} | {
|
|
267
|
+
kind: "api_failure";
|
|
268
|
+
errorCode?: number;
|
|
269
|
+
description: string;
|
|
270
|
+
} | {
|
|
271
|
+
kind: "conflict";
|
|
272
|
+
description: string;
|
|
273
|
+
backoffMs: number;
|
|
274
|
+
};
|
|
233
275
|
export interface TelegramUpdatePollerOptions {
|
|
234
276
|
botApi: BotApi;
|
|
235
277
|
runtime: NotificationOperatorRuntime;
|
|
236
278
|
backoff: OperatorBackoffPolicy;
|
|
237
279
|
processUpdate: (update: unknown) => Promise<TelegramUpdateOutcome>;
|
|
280
|
+
health?: TelegramPollHealth;
|
|
281
|
+
}
|
|
282
|
+
export declare class TelegramPollHealth {
|
|
283
|
+
#private;
|
|
284
|
+
record(result: TelegramPollResult): void;
|
|
238
285
|
}
|
|
239
286
|
/** Owns getUpdates offset, conflict backoff, and per-update error isolation. */
|
|
240
287
|
export declare class TelegramUpdatePoller {
|
|
241
288
|
#private;
|
|
242
289
|
constructor(opts: TelegramUpdatePollerOptions);
|
|
243
290
|
pollOnce(signal?: AbortSignal): Promise<number>;
|
|
291
|
+
pollOnceResult(signal?: AbortSignal): Promise<TelegramPollResult>;
|
|
244
292
|
}
|
|
245
293
|
/** Mutable dispatch state shared by session frames and inbound Telegram updates. */
|
|
246
294
|
export declare class TelegramEventDispatchState {
|
|
@@ -275,6 +323,9 @@ export interface TelegramDaemonOptions {
|
|
|
275
323
|
clearTimeoutImpl?: typeof clearTimeout;
|
|
276
324
|
setIntervalImpl?: typeof setInterval;
|
|
277
325
|
clearIntervalImpl?: typeof clearInterval;
|
|
326
|
+
btw?: {
|
|
327
|
+
enabled: boolean;
|
|
328
|
+
};
|
|
278
329
|
idleTimeoutMs?: number;
|
|
279
330
|
scanIntervalMs?: number;
|
|
280
331
|
pid?: number;
|
|
@@ -323,6 +374,8 @@ interface SessionSocket {
|
|
|
323
374
|
logicalSessionId: string;
|
|
324
375
|
token: string;
|
|
325
376
|
endpointKey: string;
|
|
377
|
+
endpointDigest: string;
|
|
378
|
+
hostGeneration: number;
|
|
326
379
|
ws: WebSocket;
|
|
327
380
|
pending: Map<string, {
|
|
328
381
|
sessionId: string;
|
|
@@ -330,6 +383,7 @@ interface SessionSocket {
|
|
|
330
383
|
}>;
|
|
331
384
|
/** True once the server advertised the `client_ping_pong` capability. */
|
|
332
385
|
capable: boolean;
|
|
386
|
+
ephemeralCapable: boolean;
|
|
333
387
|
/** Timestamp (via opts.now) of the last received pong; seeds the TTL window. */
|
|
334
388
|
lastPongAt: number;
|
|
335
389
|
/** Nonce of the most recent in-flight ping, if any. */
|
|
@@ -357,6 +411,7 @@ export declare class TelegramNotificationDaemon {
|
|
|
357
411
|
private running;
|
|
358
412
|
private readonly fsImpl;
|
|
359
413
|
private readonly botApi;
|
|
414
|
+
private readonly effects;
|
|
360
415
|
private readonly topics;
|
|
361
416
|
/** Serializes registry snapshots so an older atomic write cannot overwrite newer rename state. */
|
|
362
417
|
private topicsPersistQueue;
|
|
@@ -453,7 +508,7 @@ export declare class TelegramNotificationDaemon {
|
|
|
453
508
|
persistSeenUpdateIds(): Promise<void>;
|
|
454
509
|
private pruneSeenUpdateIds;
|
|
455
510
|
private rememberSeenUpdateId;
|
|
456
|
-
private
|
|
511
|
+
private reserveSeenUpdateId;
|
|
457
512
|
scanRoots(): Promise<void>;
|
|
458
513
|
connectSession(sessionId: string, url: string, token: string): void;
|
|
459
514
|
/**
|
|
@@ -490,6 +545,9 @@ export declare class TelegramNotificationDaemon {
|
|
|
490
545
|
private sessionCanClaimIdentity;
|
|
491
546
|
private submitThreadedFrame;
|
|
492
547
|
private existingTopicForPrivateChat;
|
|
548
|
+
private topicAuthorityLease;
|
|
549
|
+
private topicAuthorityLeaseFromRegistry;
|
|
550
|
+
private topicLeaseIsCurrent;
|
|
493
551
|
/** Best-effort re-assertion for a durable user-owned topic name. */
|
|
494
552
|
private reconcileUserTopicName;
|
|
495
553
|
private rememberPendingThreadedFrame;
|
|
@@ -502,7 +560,7 @@ export declare class TelegramNotificationDaemon {
|
|
|
502
560
|
*/
|
|
503
561
|
private ensureTopic;
|
|
504
562
|
private topicPastOrphanGrace;
|
|
505
|
-
private
|
|
563
|
+
private observeOrphanedTopic;
|
|
506
564
|
/** Best-effort delete of a session topic once its local notification endpoint shuts down. */
|
|
507
565
|
private deleteTopic;
|
|
508
566
|
private persistTopics;
|
|
@@ -540,6 +598,7 @@ export declare class TelegramNotificationDaemon {
|
|
|
540
598
|
private flushChain;
|
|
541
599
|
private flushPool;
|
|
542
600
|
/** Drain the shared rate-limit pool and deliver each granted send to its topic. */
|
|
601
|
+
private submitPool;
|
|
543
602
|
private flushPoolInner;
|
|
544
603
|
/**
|
|
545
604
|
* Track the Telegram message id backing a streamed `(sessionId, coalesceKey)`
|
|
@@ -570,6 +629,13 @@ export declare class TelegramNotificationDaemon {
|
|
|
570
629
|
private notifyThreadedFallback;
|
|
571
630
|
private startFlushTimer;
|
|
572
631
|
private stopFlushTimer;
|
|
632
|
+
private renewOwnershipHeartbeat;
|
|
633
|
+
/**
|
|
634
|
+
* Ownership must be renewed independently of Telegram's 25-second long poll:
|
|
635
|
+
* the ownership TTL is shorter than a single poll request.
|
|
636
|
+
*/
|
|
637
|
+
private startOwnershipHeartbeatTimer;
|
|
638
|
+
private stopOwnershipHeartbeatTimer;
|
|
573
639
|
/** Run a root scan, guarding against overlapping scans from the timer + loop. */
|
|
574
640
|
private runScan;
|
|
575
641
|
private startScanTimer;
|
|
@@ -41,6 +41,13 @@ export interface ThreadedSend {
|
|
|
41
41
|
richMarkdown?: string;
|
|
42
42
|
/** Live-turn raw markdown for opt-in draft streaming (set ONLY on non-finalized turn frames; never triggers rich-final promotion, which requires `lane === "finalized"`). */
|
|
43
43
|
richDraftMarkdown?: string;
|
|
44
|
+
/**
|
|
45
|
+
* True for a terminal tool_activity frame (phase completed/failed/cancelled/
|
|
46
|
+
* unknown). The daemon evicts the tool's `tool:<toolCallId>` live-message entry
|
|
47
|
+
* after delivering it, so completed tools do not accumulate unbounded across a
|
|
48
|
+
* long session (concurrent in-flight `started` entries are retained).
|
|
49
|
+
*/
|
|
50
|
+
terminal?: boolean;
|
|
44
51
|
}
|
|
45
52
|
interface ThreadedFrame {
|
|
46
53
|
type?: unknown;
|
|
@@ -60,6 +67,12 @@ interface ThreadedFrame {
|
|
|
60
67
|
finalAnswer?: boolean;
|
|
61
68
|
text?: unknown;
|
|
62
69
|
messageRef?: unknown;
|
|
70
|
+
turnRef?: unknown;
|
|
71
|
+
toolCallId?: unknown;
|
|
72
|
+
toolName?: unknown;
|
|
73
|
+
argsSummary?: unknown;
|
|
74
|
+
resultSummary?: unknown;
|
|
75
|
+
isError?: unknown;
|
|
63
76
|
source?: unknown;
|
|
64
77
|
data?: unknown;
|
|
65
78
|
mime?: unknown;
|
|
@@ -20,6 +20,8 @@ export interface TopicRecord {
|
|
|
20
20
|
identitySent: boolean;
|
|
21
21
|
/** Creation timestamp (ms epoch). */
|
|
22
22
|
createdAt: number;
|
|
23
|
+
/** First positive observation that the owning endpoint is stale, dead, or missing. */
|
|
24
|
+
orphanedAt?: number;
|
|
23
25
|
/** Last applied or observed Telegram topic title. */
|
|
24
26
|
name?: string;
|
|
25
27
|
/** Naming authority. Missing values are legacy daemon-owned records. */
|
|
@@ -34,11 +36,17 @@ export interface TopicRecord {
|
|
|
34
36
|
replayGeneration?: number;
|
|
35
37
|
/** Last SDK event sequence durably consumed within replayGeneration. */
|
|
36
38
|
replaySeq?: number;
|
|
39
|
+
/** Serialized authority epoch; a late create may commit only in its starting epoch. */
|
|
40
|
+
authorityEpoch?: number;
|
|
41
|
+
/** An uncertain delete fences future creation and inbound routing. */
|
|
42
|
+
authorityState?: "active" | "delete_pending";
|
|
37
43
|
}
|
|
38
44
|
/** Serialisable shape persisted to disk. */
|
|
39
45
|
export interface TopicRegistryState {
|
|
40
46
|
/** sessionId -> record. */
|
|
41
47
|
topics: Record<string, TopicRecord>;
|
|
48
|
+
/** Durable deletion epochs retained after a definite delete. */
|
|
49
|
+
fences?: Record<string, number>;
|
|
42
50
|
}
|
|
43
51
|
export declare function emptyTopicRegistryState(): TopicRegistryState;
|
|
44
52
|
/**
|
|
@@ -47,14 +55,18 @@ export declare function emptyTopicRegistryState(): TopicRegistryState;
|
|
|
47
55
|
* `createForumTopic` call); reuse-on-resume is automatic when a record exists.
|
|
48
56
|
*/
|
|
49
57
|
export declare class TopicRegistry {
|
|
58
|
+
#private;
|
|
50
59
|
private readonly topics;
|
|
51
60
|
/** Maps topicId -> sessionId for fast inbound routing. */
|
|
52
61
|
private readonly byTopic;
|
|
53
62
|
/** In-flight create promises, keyed by session, to dedupe concurrent creates. */
|
|
54
63
|
private readonly inflight;
|
|
64
|
+
/** Monotonic authority epochs, including deletion fences for absent records. */
|
|
65
|
+
private readonly epochs;
|
|
55
66
|
constructor(state?: TopicRegistryState);
|
|
56
67
|
/** Merge serialized state and normalize authority fields from older releases. */
|
|
57
68
|
load(state: TopicRegistryState): void;
|
|
69
|
+
private rebuildInboundRoutes;
|
|
58
70
|
/** Resolve the owning session for a topic id (for fail-closed inbound routing). */
|
|
59
71
|
sessionForTopic(topicId: string): string | undefined;
|
|
60
72
|
/** All session ids with a persisted topic record. */
|
|
@@ -65,13 +77,17 @@ export declare class TopicRegistry {
|
|
|
65
77
|
* Return the existing active topic for `sessionId`, or create one via
|
|
66
78
|
* `create` (called only on first use).
|
|
67
79
|
*/
|
|
68
|
-
getOrCreateTopic(sessionId: string, create: () => Promise<
|
|
80
|
+
getOrCreateTopic(sessionId: string, create: () => Promise<unknown>, now?: () => number, name?: string): Promise<TopicRecord>;
|
|
69
81
|
/** Mark the identity header as sent for a session. Idempotent. */
|
|
70
82
|
markIdentitySent(sessionId: string): void;
|
|
71
83
|
/** Whether the identity header still needs sending for this session. */
|
|
72
84
|
needsIdentity(sessionId: string): boolean;
|
|
73
85
|
/** Remember stable repo/branch identity independently of the displayed name. */
|
|
74
86
|
markIdentityKey(sessionId: string, identityKey: string): boolean;
|
|
87
|
+
/** Start the orphan grace clock on the first positive liveness-loss observation. */
|
|
88
|
+
markOrphaned(sessionId: string, now: number): boolean;
|
|
89
|
+
/** Clear a prior orphan observation after the endpoint is positively live again. */
|
|
90
|
+
clearOrphaned(sessionId: string): boolean;
|
|
75
91
|
/** Last durably consumed SDK event cursor for reconnect replay. */
|
|
76
92
|
replayCursor(sessionId: string): {
|
|
77
93
|
generation: number;
|
|
@@ -93,7 +109,13 @@ export declare class TopicRegistry {
|
|
|
93
109
|
markUserNamePending(sessionId: string, name: string): boolean;
|
|
94
110
|
/** Commit a successfully-applied daemon topic title. */
|
|
95
111
|
markNameApplied(sessionId: string, name: string): void;
|
|
96
|
-
/**
|
|
112
|
+
/** Fence new work before the remote delete starts, including an absent in-flight create. */
|
|
113
|
+
beginDelete(sessionId: string): TopicRecord | undefined;
|
|
114
|
+
/** Wait for a revoked create to settle before admitting a later lifecycle epoch. */
|
|
115
|
+
awaitInflight(sessionId: string): Promise<void>;
|
|
116
|
+
/** Remove only after a definite remote deletion; ambiguity deliberately retains its fence. */
|
|
117
|
+
settleDelete(sessionId: string, topicId: string): boolean;
|
|
118
|
+
/** Remove a topic record immediately for local/test cleanup compatibility. */
|
|
97
119
|
delete(sessionId: string): boolean;
|
|
98
120
|
/** Serialise for atomic persistence beside the daemon state. */
|
|
99
121
|
serialize(): TopicRegistryState;
|
|
@@ -11,7 +11,7 @@ export interface ControlSurface {
|
|
|
11
11
|
abort(): Promise<ControlValue> | ControlValue;
|
|
12
12
|
abortAndPrompt(text: string): Promise<ControlValue> | ControlValue;
|
|
13
13
|
answerAsk(id: string, answer: ControlValue): Promise<ControlValue> | ControlValue;
|
|
14
|
-
answerGate(id: string, response: ControlValue, expectedSessionId?: string): Promise<ControlValue> | ControlValue;
|
|
14
|
+
answerGate(id: string, response: ControlValue, expectedSessionId?: string, idempotencyKey?: string): Promise<ControlValue> | ControlValue;
|
|
15
15
|
approvePlan(id: string, choice: ControlValue, expectedSessionId?: string): Promise<ControlValue> | ControlValue;
|
|
16
16
|
invokeSkill(name: string, args: ControlValue): Promise<ControlValue> | ControlValue;
|
|
17
17
|
setPlanMode(on: boolean): Promise<ControlValue> | ControlValue;
|
|
@@ -12,6 +12,8 @@ export interface SessionSdkHostOptions extends HostEndpointAdapters {
|
|
|
12
12
|
installProviderDefinitions?: (capability: string, definitions: unknown) => void;
|
|
13
13
|
onProviderDefinitionsRemoved?: (capability: string) => void;
|
|
14
14
|
onReverseCancel?: (requestId: string, reason: "provider_disconnected" | "lease_released") => void;
|
|
15
|
+
/** Best-effort capabilities mirrored from the native transport for out-of-band consumers. */
|
|
16
|
+
connectionCapabilities?: (connectionId: string) => ReadonlySet<string>;
|
|
15
17
|
}
|
|
16
18
|
/** SDK hosting is independent of notification configuration. Only root sessions host an endpoint. */
|
|
17
19
|
export declare function shouldHostSdk(_settings: unknown, isTopLevel: boolean, env?: NodeJS.ProcessEnv): boolean;
|
|
@@ -4,3 +4,4 @@ export * as host from "./host";
|
|
|
4
4
|
export * as mcp from "./mcp";
|
|
5
5
|
export type { Q10CurrentThinkingLevel, Q10Model, Q10SettableThinkingLevel, Q10ThinkingCapabilities, Q10ThinkingEffort, Q10ThinkingMode, } from "./models";
|
|
6
6
|
export * from "./session";
|
|
7
|
+
export * from "./session-directory";
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import type { ResumeSessionIdentity } from "../session/session-manager";
|
|
2
|
+
/** Version of the supported readonly managed-session directory API. */
|
|
3
|
+
/** Broker-owned policy for managed-session migration decisions after scope validation. */
|
|
4
|
+
export type DirectoryMigrationPolicy = "copy-retain" | "disabled";
|
|
5
|
+
export declare const SESSION_DIRECTORY_API_VERSION: 1;
|
|
6
|
+
/** A collision-resistant v2 managed-session scope for one canonical workspace identity. */
|
|
7
|
+
export interface ManagedSessionScope {
|
|
8
|
+
readonly apiVersion: 1;
|
|
9
|
+
readonly layoutVersion: 2;
|
|
10
|
+
readonly identityVersion: 1;
|
|
11
|
+
readonly agentDir: string;
|
|
12
|
+
readonly sessionsRoot: string;
|
|
13
|
+
readonly canonicalCwd: string;
|
|
14
|
+
readonly legacyLexicalCwd: string;
|
|
15
|
+
readonly directoryName: string;
|
|
16
|
+
readonly directoryPath: string;
|
|
17
|
+
}
|
|
18
|
+
export type ResolveManagedSessionScopeResult = {
|
|
19
|
+
kind: "resolved";
|
|
20
|
+
scope: ManagedSessionScope;
|
|
21
|
+
} | {
|
|
22
|
+
kind: "error";
|
|
23
|
+
code: "cwd_missing" | "cwd_not_directory" | "identity_unavailable" | "network_unsupported" | "sessions_root_unavailable" | "binding_conflict" | "binding_invalid";
|
|
24
|
+
message: string;
|
|
25
|
+
};
|
|
26
|
+
export interface LogicalSessionCandidate {
|
|
27
|
+
readonly sessionId: string;
|
|
28
|
+
readonly path: string;
|
|
29
|
+
readonly cwd: string;
|
|
30
|
+
readonly provenance: "v2" | "legacy";
|
|
31
|
+
readonly identity: Readonly<ResumeSessionIdentity>;
|
|
32
|
+
readonly migrationState: "native_v2" | "legacy_unmigrated" | "migrated_v2";
|
|
33
|
+
}
|
|
34
|
+
export type ListManagedSessionCandidatesResult = {
|
|
35
|
+
kind: "complete";
|
|
36
|
+
scope: ManagedSessionScope;
|
|
37
|
+
owned: readonly LogicalSessionCandidate[];
|
|
38
|
+
foreignCount: number;
|
|
39
|
+
invalid: readonly {
|
|
40
|
+
code: string;
|
|
41
|
+
}[];
|
|
42
|
+
} | {
|
|
43
|
+
kind: "error";
|
|
44
|
+
code: "scan_failed" | "unsafe_root" | "invalid_candidate";
|
|
45
|
+
message: string;
|
|
46
|
+
};
|
|
47
|
+
/** Resolve a v2 scope without creating, migrating, or deleting session data. */
|
|
48
|
+
export declare function resolveManagedSessionScope(input: {
|
|
49
|
+
cwd: string;
|
|
50
|
+
agentDir?: string;
|
|
51
|
+
sessionsRoot?: string;
|
|
52
|
+
}): Promise<ResolveManagedSessionScopeResult>;
|
|
53
|
+
/** List readonly v2 and validated legacy candidates for an already resolved scope. */
|
|
54
|
+
export declare function listManagedSessionCandidates(input: {
|
|
55
|
+
scope: ManagedSessionScope;
|
|
56
|
+
}): Promise<ListManagedSessionCandidatesResult>;
|