@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
|
@@ -2,9 +2,10 @@ import * as path from "node:path";
|
|
|
2
2
|
import { ThinkingLevel } from "@gajae-code/agent-core";
|
|
3
3
|
import { getOAuthProviders } from "@gajae-code/ai/utils/oauth";
|
|
4
4
|
import type { OAuthProvider } from "@gajae-code/ai/utils/oauth/types";
|
|
5
|
-
import type { Component, OverlayHandle } from "@gajae-code/tui";
|
|
5
|
+
import type { Component, OverlayHandle, SlashCommand } from "@gajae-code/tui";
|
|
6
6
|
import { Input, isPetMode, Loader, Spacer, Text } from "@gajae-code/tui";
|
|
7
7
|
import { getAgentDbPath, getProjectDir, logger, VERSION } from "@gajae-code/utils";
|
|
8
|
+
import { type AppKeybinding, formatKeyHints } from "../../config/keybindings";
|
|
8
9
|
import {
|
|
9
10
|
activateModelProfile,
|
|
10
11
|
type MaterializeModelProfileForDeletionResult,
|
|
@@ -69,6 +70,8 @@ import {
|
|
|
69
70
|
import { TelegramDaemonController } from "../../sdk/bus/telegram-daemon-control";
|
|
70
71
|
import { runTelegramSetup, type TelegramSetupPreflight } from "../../sdk/bus/telegram-setup";
|
|
71
72
|
import { type SessionInfo, SessionManager } from "../../session/session-manager";
|
|
73
|
+
import { getTreeForInternalRead } from "../../session/session-manager-internal";
|
|
74
|
+
|
|
72
75
|
import { FileSessionStorage } from "../../session/session-storage";
|
|
73
76
|
import {
|
|
74
77
|
CREDENTIAL_AUTO_IMPORT_DISCOVERY_WARNING,
|
|
@@ -105,9 +108,15 @@ import {
|
|
|
105
108
|
setSearchFallbackProviders,
|
|
106
109
|
setSearchHardTimeoutMs,
|
|
107
110
|
} from "../../tools";
|
|
111
|
+
import { copyToClipboard } from "../../utils/clipboard";
|
|
108
112
|
import { setSessionTerminalTitle } from "../../utils/title-generator";
|
|
109
113
|
import { AgentDashboard } from "../components/agent-dashboard";
|
|
110
114
|
import { AssistantMessageComponent } from "../components/assistant-message";
|
|
115
|
+
import {
|
|
116
|
+
type CommandPaletteAction,
|
|
117
|
+
CommandPaletteComponent,
|
|
118
|
+
type CommandPaletteEntry,
|
|
119
|
+
} from "../components/command-palette";
|
|
111
120
|
import {
|
|
112
121
|
CustomModelPresetWizardComponent,
|
|
113
122
|
type CustomModelPresetWizardSubmit,
|
|
@@ -125,6 +134,12 @@ import type {
|
|
|
125
134
|
import { OAuthSelectorComponent } from "../components/oauth-selector";
|
|
126
135
|
import { isPetAvailable } from "../components/pet-capability";
|
|
127
136
|
import { PetSelectorComponent } from "../components/pet-selector";
|
|
137
|
+
import {
|
|
138
|
+
type PlanPreviewOptions,
|
|
139
|
+
PlanPreviewOverlay,
|
|
140
|
+
type PlanPreviewResult,
|
|
141
|
+
} from "../components/plan-preview-overlay";
|
|
142
|
+
|
|
128
143
|
import { PluginSelectorComponent } from "../components/plugin-selector";
|
|
129
144
|
import {
|
|
130
145
|
type ProviderOnboardingAction,
|
|
@@ -132,15 +147,20 @@ import {
|
|
|
132
147
|
} from "../components/provider-onboarding-selector";
|
|
133
148
|
import { SessionObserverOverlayComponent } from "../components/session-observer-overlay";
|
|
134
149
|
import { SessionSelectorComponent } from "../components/session-selector";
|
|
150
|
+
import { dashboardSessions, SessionsDashboardComponent } from "../components/sessions-dashboard";
|
|
135
151
|
import { SettingsSelectorComponent } from "../components/settings-selector";
|
|
136
|
-
import
|
|
152
|
+
import { TasksPaneComponent } from "../components/tasks-pane";
|
|
137
153
|
import { ThemeSelectorComponent } from "../components/theme-selector";
|
|
138
154
|
import { ThinkingSelectorComponent } from "../components/thinking-selector";
|
|
139
155
|
import { ToolExecutionComponent } from "../components/tool-execution";
|
|
156
|
+
import type { StatusLineSettings } from "../components/tool-status-header";
|
|
157
|
+
import { TranscriptViewerOverlay, transcriptViewerEntries } from "../components/transcript-viewer-overlay";
|
|
140
158
|
import { TreeSelectorComponent } from "../components/tree-selector";
|
|
141
159
|
import { UserMessageSelectorComponent } from "../components/user-message-selector";
|
|
142
160
|
import type { JobsObserver } from "../jobs-observer";
|
|
143
161
|
import type { SessionObserverRegistry } from "../session-observer-registry";
|
|
162
|
+
import type { TasksAggregator } from "../tasks-aggregator";
|
|
163
|
+
import type { TranscriptItemRegistry } from "../transcript-item-registry";
|
|
144
164
|
|
|
145
165
|
const CALLBACK_SERVER_PROVIDERS = new Set<string>([
|
|
146
166
|
"anthropic",
|
|
@@ -684,15 +704,31 @@ export function createNotificationsEditorOperations(
|
|
|
684
704
|
}
|
|
685
705
|
|
|
686
706
|
export class SelectorController {
|
|
707
|
+
#transcriptViewerOpen = false;
|
|
708
|
+
#transcriptViewer?: TranscriptViewerOverlay;
|
|
709
|
+
#sessionsDashboardOpen = false;
|
|
710
|
+
#sessionsDashboard?: SessionsDashboardComponent;
|
|
711
|
+
#tasksPane?: TasksPaneComponent;
|
|
712
|
+
#closeTasksPane?: () => void;
|
|
713
|
+
|
|
687
714
|
#credentialAutoImportStateStore?: CredentialAutoImportStateStore;
|
|
688
715
|
|
|
689
716
|
constructor(
|
|
690
717
|
private ctx: InteractiveModeContext,
|
|
691
718
|
credentialAutoImportStateStore?: CredentialAutoImportStateStore,
|
|
719
|
+
private readonly clipboard: (text: string) => void = copyToClipboard,
|
|
692
720
|
) {
|
|
693
721
|
this.#credentialAutoImportStateStore = credentialAutoImportStateStore;
|
|
694
722
|
}
|
|
695
723
|
|
|
724
|
+
isTranscriptViewerOpen(): boolean {
|
|
725
|
+
return this.#transcriptViewerOpen;
|
|
726
|
+
}
|
|
727
|
+
refreshTranscriptViewer(identityMap?: ReadonlyMap<string, string>): void {
|
|
728
|
+
this.#transcriptViewer?.refresh(identityMap);
|
|
729
|
+
this.ctx.ui.requestRender();
|
|
730
|
+
}
|
|
731
|
+
|
|
696
732
|
async #refreshOAuthProviderAuthState(): Promise<void> {
|
|
697
733
|
const oauthProviders = getOAuthProviders();
|
|
698
734
|
await Promise.all(
|
|
@@ -726,6 +762,52 @@ export class SelectorController {
|
|
|
726
762
|
this.ctx.ui.requestRender();
|
|
727
763
|
}
|
|
728
764
|
|
|
765
|
+
showCommandPalette(
|
|
766
|
+
commands: SlashCommand[],
|
|
767
|
+
actions: CommandPaletteAction[],
|
|
768
|
+
executeSlashCommand: (name: string) => Promise<void>,
|
|
769
|
+
): void {
|
|
770
|
+
const seenCommands = new Set<string>();
|
|
771
|
+
const entries: CommandPaletteEntry[] = [
|
|
772
|
+
...actions.map(action => ({
|
|
773
|
+
id: `action:${action.id}`,
|
|
774
|
+
label: action.label,
|
|
775
|
+
description: action.id,
|
|
776
|
+
keybinding: formatKeyHints(this.ctx.keybindings.getKeys(action.id as AppKeybinding)) || undefined,
|
|
777
|
+
searchText: action.id,
|
|
778
|
+
handler: action.handler,
|
|
779
|
+
})),
|
|
780
|
+
...commands
|
|
781
|
+
.filter(command => {
|
|
782
|
+
if (seenCommands.has(command.name)) return false;
|
|
783
|
+
seenCommands.add(command.name);
|
|
784
|
+
return true;
|
|
785
|
+
})
|
|
786
|
+
.map(command => ({
|
|
787
|
+
id: `command:${command.name}`,
|
|
788
|
+
label: `/${command.name}`,
|
|
789
|
+
description: command.description ?? "Slash command",
|
|
790
|
+
searchText: command.name,
|
|
791
|
+
handler: () => executeSlashCommand(command.name),
|
|
792
|
+
})),
|
|
793
|
+
];
|
|
794
|
+
|
|
795
|
+
this.showSelector(done => {
|
|
796
|
+
const selector = new CommandPaletteComponent(
|
|
797
|
+
entries,
|
|
798
|
+
entry => {
|
|
799
|
+
done();
|
|
800
|
+
void Promise.resolve()
|
|
801
|
+
.then(() => entry.handler?.())
|
|
802
|
+
.catch(error => {
|
|
803
|
+
this.ctx.showError(error instanceof Error ? error.message : String(error));
|
|
804
|
+
});
|
|
805
|
+
},
|
|
806
|
+
done,
|
|
807
|
+
);
|
|
808
|
+
return { component: selector, focus: selector };
|
|
809
|
+
});
|
|
810
|
+
}
|
|
729
811
|
showProviderOnboarding(): void {
|
|
730
812
|
this.showSelector(done => {
|
|
731
813
|
const selector = new ProviderOnboardingSelectorComponent(
|
|
@@ -968,6 +1050,7 @@ export class SelectorController {
|
|
|
968
1050
|
await this.ctx.session.modelRegistry.refresh("offline");
|
|
969
1051
|
await this.ctx.notifyConfigChanged?.();
|
|
970
1052
|
this.ctx.showStatus(formatProviderSetupResult(result));
|
|
1053
|
+
wizard.complete();
|
|
971
1054
|
done();
|
|
972
1055
|
this.ctx.ui.requestRender();
|
|
973
1056
|
} catch (err) {
|
|
@@ -1786,7 +1869,7 @@ export class SelectorController {
|
|
|
1786
1869
|
}
|
|
1787
1870
|
|
|
1788
1871
|
showTreeSelector(): void {
|
|
1789
|
-
const tree = this.ctx.sessionManager
|
|
1872
|
+
const tree = getTreeForInternalRead(this.ctx.sessionManager);
|
|
1790
1873
|
const realLeafId = this.ctx.sessionManager.getLeafId();
|
|
1791
1874
|
|
|
1792
1875
|
if (tree.length === 0) {
|
|
@@ -1912,7 +1995,7 @@ export class SelectorController {
|
|
|
1912
1995
|
}
|
|
1913
1996
|
|
|
1914
1997
|
async showSessionSelector(): Promise<void> {
|
|
1915
|
-
const sessions = await SessionManager.
|
|
1998
|
+
const sessions = await SessionManager.listForResumePickerReadOnly(
|
|
1916
1999
|
this.ctx.sessionManager.getCwd(),
|
|
1917
2000
|
this.ctx.sessionManager.getSessionDir(),
|
|
1918
2001
|
);
|
|
@@ -1934,9 +2017,9 @@ export class SelectorController {
|
|
|
1934
2017
|
if (!(await this.#detachActiveSessionBeforeDeletion(session.path))) {
|
|
1935
2018
|
return false;
|
|
1936
2019
|
}
|
|
1937
|
-
const storage = new FileSessionStorage();
|
|
1938
2020
|
try {
|
|
1939
|
-
await
|
|
2021
|
+
await this.#deleteSession(session.path);
|
|
2022
|
+
|
|
1940
2023
|
return true;
|
|
1941
2024
|
} catch (err) {
|
|
1942
2025
|
throw new Error(`Failed to delete session: ${err instanceof Error ? err.message : String(err)}`, {
|
|
@@ -1972,6 +2055,15 @@ export class SelectorController {
|
|
|
1972
2055
|
setSessionTerminalTitle(sessionManager.getSessionName?.(), sessionManager.getCwd());
|
|
1973
2056
|
}
|
|
1974
2057
|
|
|
2058
|
+
async #deleteSession(sessionPath: string): Promise<void> {
|
|
2059
|
+
const sessionManager = this.ctx.sessionManager as { dropSession?: (path: string) => Promise<void> };
|
|
2060
|
+
if (sessionManager.dropSession) {
|
|
2061
|
+
await sessionManager.dropSession(sessionPath);
|
|
2062
|
+
return;
|
|
2063
|
+
}
|
|
2064
|
+
await new FileSessionStorage().deleteSessionWithArtifacts(sessionPath);
|
|
2065
|
+
}
|
|
2066
|
+
|
|
1975
2067
|
async #detachActiveSessionBeforeDeletion(sessionPath: string): Promise<boolean> {
|
|
1976
2068
|
const currentSessionFile = this.ctx.sessionManager.getSessionFile();
|
|
1977
2069
|
if (currentSessionFile !== sessionPath) {
|
|
@@ -2000,9 +2092,12 @@ export class SelectorController {
|
|
|
2000
2092
|
async handleResumeSession(sessionPath: string): Promise<void> {
|
|
2001
2093
|
const previousSessionId = this.ctx.sessionManager.getSessionId();
|
|
2002
2094
|
this.#clearTransientSessionUi();
|
|
2095
|
+
const migrationPolicy =
|
|
2096
|
+
this.ctx.settings?.get("session.directoryMigration") === "disabled" ? "disabled" : "copy-retain";
|
|
2097
|
+
const writableSessionPath = await SessionManager.prepareManagedCandidateForWrite(sessionPath, migrationPolicy);
|
|
2003
2098
|
|
|
2004
2099
|
// Switch session via AgentSession (emits hook and tool session events)
|
|
2005
|
-
if (!(await this.ctx.session.switchSession(
|
|
2100
|
+
if (!(await this.ctx.session.switchSession(writableSessionPath))) return;
|
|
2006
2101
|
const switchingToDifferentSession = previousSessionId !== this.ctx.sessionManager.getSessionId();
|
|
2007
2102
|
if (switchingToDifferentSession) this.ctx.resetIrcSidebarSession();
|
|
2008
2103
|
this.#refreshSessionTerminalTitle();
|
|
@@ -2047,8 +2142,7 @@ export class SelectorController {
|
|
|
2047
2142
|
return;
|
|
2048
2143
|
}
|
|
2049
2144
|
|
|
2050
|
-
|
|
2051
|
-
await storage.deleteSessionWithArtifacts(sessionFile);
|
|
2145
|
+
await this.#deleteSession(sessionFile);
|
|
2052
2146
|
|
|
2053
2147
|
// Show session selector
|
|
2054
2148
|
this.ctx.showStatus("Current session transcript and artifacts deleted");
|
|
@@ -2273,7 +2367,10 @@ export class SelectorController {
|
|
|
2273
2367
|
if (handledCandidates || (secondCandidates.length === 0 && secondSourceFailures.length === 0)) {
|
|
2274
2368
|
let persisted = false;
|
|
2275
2369
|
try {
|
|
2276
|
-
persisted = await stateStore.write({
|
|
2370
|
+
persisted = await stateStore.write({
|
|
2371
|
+
initialImportResolution: "accepted",
|
|
2372
|
+
lastImportVersion: VERSION,
|
|
2373
|
+
});
|
|
2277
2374
|
} catch {
|
|
2278
2375
|
logger.warn("Credential auto-import state persistence failed", {
|
|
2279
2376
|
classification: "state-write-failed",
|
|
@@ -2385,6 +2482,94 @@ export class SelectorController {
|
|
|
2385
2482
|
this.ctx.ui.requestRender();
|
|
2386
2483
|
}
|
|
2387
2484
|
|
|
2485
|
+
async showSessionsDashboard(): Promise<void> {
|
|
2486
|
+
if (this.#sessionsDashboardOpen) {
|
|
2487
|
+
if (this.#sessionsDashboard) this.ctx.ui.setFocus(this.#sessionsDashboard);
|
|
2488
|
+
return;
|
|
2489
|
+
}
|
|
2490
|
+
this.#sessionsDashboardOpen = true;
|
|
2491
|
+
try {
|
|
2492
|
+
const sessions = dashboardSessions(await SessionManager.listAll());
|
|
2493
|
+
let overlayHandle: OverlayHandle | undefined;
|
|
2494
|
+
const dashboard = new SessionsDashboardComponent(
|
|
2495
|
+
sessions,
|
|
2496
|
+
() => {
|
|
2497
|
+
this.#sessionsDashboardOpen = false;
|
|
2498
|
+
this.#sessionsDashboard = undefined;
|
|
2499
|
+
overlayHandle?.hide();
|
|
2500
|
+
this.ctx.ui.setFocus(this.ctx.editor);
|
|
2501
|
+
this.ctx.ui.requestRender();
|
|
2502
|
+
},
|
|
2503
|
+
() => this.ctx.ui.requestRender(),
|
|
2504
|
+
);
|
|
2505
|
+
this.#sessionsDashboard = dashboard;
|
|
2506
|
+
overlayHandle = this.ctx.ui.showOverlay(dashboard, {
|
|
2507
|
+
anchor: "bottom-center",
|
|
2508
|
+
width: "100%",
|
|
2509
|
+
maxHeight: "100%",
|
|
2510
|
+
margin: 0,
|
|
2511
|
+
});
|
|
2512
|
+
this.ctx.ui.setFocus(dashboard);
|
|
2513
|
+
this.ctx.ui.requestRender();
|
|
2514
|
+
} catch (error) {
|
|
2515
|
+
this.#sessionsDashboardOpen = false;
|
|
2516
|
+
throw error;
|
|
2517
|
+
}
|
|
2518
|
+
}
|
|
2519
|
+
|
|
2520
|
+
showTranscriptViewer(registry: TranscriptItemRegistry): void {
|
|
2521
|
+
if (this.#transcriptViewerOpen) return;
|
|
2522
|
+
this.#transcriptViewerOpen = true;
|
|
2523
|
+
let overlayHandle: OverlayHandle | undefined;
|
|
2524
|
+
const viewer = new TranscriptViewerOverlay({
|
|
2525
|
+
title: "Transcript",
|
|
2526
|
+
getEntries: () => transcriptViewerEntries(registry),
|
|
2527
|
+
onClose: () => {
|
|
2528
|
+
this.#transcriptViewerOpen = false;
|
|
2529
|
+
this.#transcriptViewer = undefined;
|
|
2530
|
+
overlayHandle?.hide();
|
|
2531
|
+
this.ctx.ui.setFocus(this.ctx.editor);
|
|
2532
|
+
this.ctx.ui.requestRender(true);
|
|
2533
|
+
},
|
|
2534
|
+
requestRender: () => this.ctx.ui.requestRender(),
|
|
2535
|
+
copyToClipboard: this.clipboard,
|
|
2536
|
+
});
|
|
2537
|
+
this.#transcriptViewer = viewer;
|
|
2538
|
+
overlayHandle = this.ctx.ui.showOverlay(viewer, {
|
|
2539
|
+
anchor: "bottom-center",
|
|
2540
|
+
width: "100%",
|
|
2541
|
+
maxHeight: "100%",
|
|
2542
|
+
margin: 0,
|
|
2543
|
+
});
|
|
2544
|
+
this.ctx.ui.setFocus(viewer);
|
|
2545
|
+
this.ctx.ui.requestRender();
|
|
2546
|
+
}
|
|
2547
|
+
|
|
2548
|
+
showPlanPreview(content: string | null, options?: PlanPreviewOptions): Promise<PlanPreviewResult> {
|
|
2549
|
+
return new Promise(resolve => {
|
|
2550
|
+
let overlayHandle: OverlayHandle | undefined;
|
|
2551
|
+
const overlay = new PlanPreviewOverlay(
|
|
2552
|
+
content,
|
|
2553
|
+
result => {
|
|
2554
|
+
overlayHandle?.hide();
|
|
2555
|
+
this.ctx.ui.setFocus(this.ctx.editor);
|
|
2556
|
+
this.ctx.ui.requestRender(true);
|
|
2557
|
+
resolve(result);
|
|
2558
|
+
},
|
|
2559
|
+
() => this.ctx.ui.requestRender(),
|
|
2560
|
+
options,
|
|
2561
|
+
);
|
|
2562
|
+
overlayHandle = this.ctx.ui.showOverlay(overlay, {
|
|
2563
|
+
anchor: "bottom-center",
|
|
2564
|
+
width: "100%",
|
|
2565
|
+
maxHeight: "100%",
|
|
2566
|
+
margin: 0,
|
|
2567
|
+
});
|
|
2568
|
+
this.ctx.ui.setFocus(overlay);
|
|
2569
|
+
this.ctx.ui.requestRender();
|
|
2570
|
+
});
|
|
2571
|
+
}
|
|
2572
|
+
|
|
2388
2573
|
/**
|
|
2389
2574
|
* Jobs overlay: navigate ongoing monitor + cron jobs (Monitors then Crons,
|
|
2390
2575
|
* newest-first), drill into per-type detail, and cancel/delete with a y/N
|
|
@@ -2411,4 +2596,34 @@ export class SelectorController {
|
|
|
2411
2596
|
this.ctx.ui.setFocus(overlay.getFocus());
|
|
2412
2597
|
this.ctx.ui.requestRender();
|
|
2413
2598
|
}
|
|
2599
|
+
|
|
2600
|
+
showTasksPane(aggregator: TasksAggregator): void {
|
|
2601
|
+
if (this.#closeTasksPane) {
|
|
2602
|
+
this.#closeTasksPane();
|
|
2603
|
+
return;
|
|
2604
|
+
}
|
|
2605
|
+
let unsubscribe: (() => void) | undefined;
|
|
2606
|
+
const close = () => {
|
|
2607
|
+
unsubscribe?.();
|
|
2608
|
+
this.#tasksPane = undefined;
|
|
2609
|
+
this.#closeTasksPane = undefined;
|
|
2610
|
+
this.ctx.editorContainer.clear();
|
|
2611
|
+
this.ctx.editorContainer.addChild(this.ctx.editor);
|
|
2612
|
+
this.ctx.ui.setFocus(this.ctx.editor);
|
|
2613
|
+
this.ctx.ui.requestRender();
|
|
2614
|
+
};
|
|
2615
|
+
this.#closeTasksPane = close;
|
|
2616
|
+
this.#tasksPane = new TasksPaneComponent(aggregator, {
|
|
2617
|
+
close,
|
|
2618
|
+
requestRender: () => {
|
|
2619
|
+
if (this.#tasksPane) this.ctx.ui.setFocus(this.#tasksPane.getFocus());
|
|
2620
|
+
this.ctx.ui.requestRender();
|
|
2621
|
+
},
|
|
2622
|
+
});
|
|
2623
|
+
unsubscribe = aggregator.onChange(() => this.#tasksPane?.refresh());
|
|
2624
|
+
this.ctx.editorContainer.clear();
|
|
2625
|
+
this.ctx.editorContainer.addChild(this.#tasksPane);
|
|
2626
|
+
this.ctx.ui.setFocus(this.#tasksPane.getFocus());
|
|
2627
|
+
this.ctx.ui.requestRender();
|
|
2628
|
+
}
|
|
2414
2629
|
}
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
import { visibleWidth } from "@gajae-code/tui";
|
|
2
|
+
import { STTController, type SttState } from "../../stt";
|
|
3
|
+
import { theme } from "../theme/theme";
|
|
4
|
+
|
|
5
|
+
interface SttEditor {
|
|
6
|
+
cursorOverride: string | undefined;
|
|
7
|
+
cursorOverrideWidth: number | undefined;
|
|
8
|
+
getUseTerminalCursor(): boolean;
|
|
9
|
+
insertText(text: string): void;
|
|
10
|
+
setUseTerminalCursor(enabled: boolean): void;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
interface SttUi {
|
|
14
|
+
getShowHardwareCursor(): boolean;
|
|
15
|
+
requestRender(): void;
|
|
16
|
+
setShowHardwareCursor(enabled: boolean): void;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export interface SttModeContext {
|
|
20
|
+
editor: SttEditor;
|
|
21
|
+
showStatus(message: string): void;
|
|
22
|
+
showWarning(message: string): void;
|
|
23
|
+
ui: SttUi;
|
|
24
|
+
updateEditorChrome(): void;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/** Coordinates STT state with the interactive composer presentation. */
|
|
28
|
+
export class SttModeController {
|
|
29
|
+
readonly #stt = new STTController();
|
|
30
|
+
#animationInterval: NodeJS.Timeout | undefined;
|
|
31
|
+
#hue = 0;
|
|
32
|
+
#previousShowHardwareCursor: boolean | undefined;
|
|
33
|
+
#previousUseTerminalCursor: boolean | undefined;
|
|
34
|
+
|
|
35
|
+
async toggle(ctx: SttModeContext): Promise<void> {
|
|
36
|
+
await this.#stt.toggle(ctx.editor, {
|
|
37
|
+
showWarning: message => ctx.showWarning(message),
|
|
38
|
+
showStatus: message => ctx.showStatus(message),
|
|
39
|
+
onStateChange: state => this.#onStateChange(ctx, state),
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
dispose(ctx: Pick<SttModeContext, "editor" | "ui">): void {
|
|
44
|
+
this.#cleanupAnimation(ctx);
|
|
45
|
+
this.#stt.dispose();
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
#onStateChange(ctx: SttModeContext, state: SttState): void {
|
|
49
|
+
if (state === "recording") {
|
|
50
|
+
this.#previousShowHardwareCursor = ctx.ui.getShowHardwareCursor();
|
|
51
|
+
this.#previousUseTerminalCursor = ctx.editor.getUseTerminalCursor();
|
|
52
|
+
ctx.ui.setShowHardwareCursor(false);
|
|
53
|
+
ctx.editor.setUseTerminalCursor(false);
|
|
54
|
+
this.#startAnimation(ctx);
|
|
55
|
+
} else if (state === "transcribing") {
|
|
56
|
+
this.#stopAnimation();
|
|
57
|
+
this.#setMicCursor(ctx.editor, { r: 200, g: 200, b: 200 });
|
|
58
|
+
} else {
|
|
59
|
+
this.#cleanupAnimation(ctx);
|
|
60
|
+
}
|
|
61
|
+
ctx.updateEditorChrome();
|
|
62
|
+
ctx.ui.requestRender();
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
#setMicCursor(editor: SttEditor, color: { r: number; g: number; b: number }): void {
|
|
66
|
+
editor.cursorOverride = `\x1b[38;2;${color.r};${color.g};${color.b}m${theme.icon.mic}\x1b[0m`;
|
|
67
|
+
editor.cursorOverrideWidth = visibleWidth(editor.cursorOverride);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
#startAnimation(ctx: Pick<SttModeContext, "editor" | "ui">): void {
|
|
71
|
+
if (this.#animationInterval) return;
|
|
72
|
+
this.#hue = 0;
|
|
73
|
+
this.#updateMicIcon(ctx.editor);
|
|
74
|
+
this.#animationInterval = setInterval(() => {
|
|
75
|
+
this.#hue = (this.#hue + 8) % 360;
|
|
76
|
+
this.#updateMicIcon(ctx.editor);
|
|
77
|
+
ctx.ui.requestRender();
|
|
78
|
+
}, 60);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
#updateMicIcon(editor: SttEditor): void {
|
|
82
|
+
const c = hsvToRgb(this.#hue, 0.9, 1);
|
|
83
|
+
this.#setMicCursor(editor, c);
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
#stopAnimation(): void {
|
|
87
|
+
if (this.#animationInterval) {
|
|
88
|
+
clearInterval(this.#animationInterval);
|
|
89
|
+
this.#animationInterval = undefined;
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
#cleanupAnimation(ctx: Pick<SttModeContext, "editor" | "ui">): void {
|
|
94
|
+
this.#stopAnimation();
|
|
95
|
+
ctx.editor.cursorOverride = undefined;
|
|
96
|
+
ctx.editor.cursorOverrideWidth = undefined;
|
|
97
|
+
if (this.#previousShowHardwareCursor !== undefined) {
|
|
98
|
+
ctx.ui.setShowHardwareCursor(this.#previousShowHardwareCursor);
|
|
99
|
+
this.#previousShowHardwareCursor = undefined;
|
|
100
|
+
}
|
|
101
|
+
if (this.#previousUseTerminalCursor !== undefined) {
|
|
102
|
+
ctx.editor.setUseTerminalCursor(this.#previousUseTerminalCursor);
|
|
103
|
+
this.#previousUseTerminalCursor = undefined;
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
function hsvToRgb(h: number, s: number, v: number): { r: number; g: number; b: number } {
|
|
109
|
+
const c = v * s;
|
|
110
|
+
const x = c * (1 - Math.abs(((h / 60) % 2) - 1));
|
|
111
|
+
const m = v - c;
|
|
112
|
+
const [r, g, b] =
|
|
113
|
+
h < 60
|
|
114
|
+
? [c, x, 0]
|
|
115
|
+
: h < 120
|
|
116
|
+
? [x, c, 0]
|
|
117
|
+
: h < 180
|
|
118
|
+
? [0, c, x]
|
|
119
|
+
: h < 240
|
|
120
|
+
? [0, x, c]
|
|
121
|
+
: h < 300
|
|
122
|
+
? [x, 0, c]
|
|
123
|
+
: [c, 0, x];
|
|
124
|
+
return { r: Math.round((r + m) * 255), g: Math.round((g + m) * 255), b: Math.round((b + m) * 255) };
|
|
125
|
+
}
|