@oh-my-pi/pi-coding-agent 17.0.9 → 17.1.1
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 +78 -0
- package/README.md +1 -1
- package/dist/cli.js +4685 -4614
- package/dist/types/async/job-manager.d.ts +37 -1
- package/dist/types/cli/args.d.ts +2 -0
- package/dist/types/cli/bench-cli.d.ts +41 -0
- package/dist/types/commands/bench.d.ts +15 -3
- package/dist/types/commands/launch.d.ts +4 -0
- package/dist/types/config/model-registry.d.ts +3 -1
- package/dist/types/config/models-config-schema.d.ts +18 -6
- package/dist/types/config/models-config.d.ts +14 -5
- package/dist/types/config/provider-globals.d.ts +2 -2
- package/dist/types/config/service-tier.d.ts +5 -1
- package/dist/types/config/settings-schema.d.ts +374 -47
- package/dist/types/config/settings.d.ts +7 -0
- package/dist/types/dap/client.d.ts +20 -0
- package/dist/types/exec/bash-executor.d.ts +38 -0
- package/dist/types/exec/direnv.d.ts +33 -0
- package/dist/types/export/html/args.d.ts +15 -0
- package/dist/types/export/html/index.d.ts +11 -26
- package/dist/types/export/html/web-palette.d.ts +55 -116
- package/dist/types/extensibility/extensions/loader.d.ts +3 -0
- package/dist/types/extensibility/extensions/types.d.ts +17 -2
- package/dist/types/extensibility/legacy-pi-coding-agent-shim.d.ts +3 -0
- package/dist/types/extensibility/plugins/legacy-pi-compat.d.ts +13 -0
- package/dist/types/live/attestation.d.ts +2 -0
- package/dist/types/live/controller.d.ts +48 -0
- package/dist/types/live/protocol.d.ts +85 -0
- package/dist/types/live/protocol.test.d.ts +1 -0
- package/dist/types/live/transport.d.ts +35 -0
- package/dist/types/live/visualizer.d.ts +30 -0
- package/dist/types/lsp/client.d.ts +16 -1
- package/dist/types/mcp/config-writer.test.d.ts +1 -0
- package/dist/types/mcp/oauth-discovery.d.ts +2 -0
- package/dist/types/mcp/smithery-auth.d.ts +1 -1
- package/dist/types/mcp/smithery-auth.test.d.ts +1 -0
- package/dist/types/memory-backend/tool-names.d.ts +2 -0
- package/dist/types/modes/components/assistant-message.d.ts +1 -0
- package/dist/types/modes/components/custom-message.d.ts +1 -1
- package/dist/types/modes/components/login-dialog.d.ts +2 -2
- package/dist/types/modes/components/message-frame.d.ts +8 -4
- package/dist/types/modes/components/plan-review-overlay.d.ts +26 -0
- package/dist/types/modes/components/session-account-selector.d.ts +11 -0
- package/dist/types/modes/components/settings-defs.d.ts +7 -1
- package/dist/types/modes/components/status-line/component.jj-cache.test.d.ts +1 -0
- package/dist/types/modes/components/tool-execution.d.ts +9 -1
- package/dist/types/modes/controllers/command-controller.d.ts +1 -1
- package/dist/types/modes/controllers/event-controller.d.ts +6 -1
- package/dist/types/modes/controllers/live-command-controller.d.ts +14 -0
- package/dist/types/modes/controllers/selector-controller.d.ts +1 -0
- package/dist/types/modes/interactive-mode.d.ts +6 -0
- package/dist/types/modes/theme/theme.d.ts +1 -1
- package/dist/types/modes/types.d.ts +4 -1
- package/dist/types/modes/utils/context-usage.d.ts +12 -2
- package/dist/types/plan-mode/plan-files.d.ts +10 -0
- package/dist/types/registry/agent-lifecycle.d.ts +21 -9
- package/dist/types/registry/agent-registry.d.ts +11 -4
- package/dist/types/sdk.d.ts +15 -1
- package/dist/types/secrets/index.d.ts +15 -2
- package/dist/types/secrets/obfuscator.d.ts +113 -15
- package/dist/types/session/acp-permission-gate.d.ts +19 -0
- package/dist/types/session/agent-session-events.d.ts +84 -0
- package/dist/types/session/agent-session-types.d.ts +321 -0
- package/dist/types/session/agent-session.d.ts +135 -753
- package/dist/types/session/async-job-delivery.d.ts +28 -0
- package/dist/types/session/auth-storage.d.ts +1 -1
- package/dist/types/session/bash-runner.d.ts +75 -0
- package/dist/types/session/blob-store.d.ts +11 -1
- package/dist/types/session/blob-store.test.d.ts +1 -0
- package/dist/types/session/checkpoint-entries.d.ts +28 -0
- package/dist/types/session/eval-runner.d.ts +51 -0
- package/dist/types/session/irc-bridge.d.ts +46 -0
- package/dist/types/session/messages.d.ts +24 -0
- package/dist/types/session/model-controls.d.ts +180 -0
- package/dist/types/session/prewalk.d.ts +46 -0
- package/dist/types/session/queued-messages.d.ts +22 -0
- package/dist/types/session/redis-session-storage.d.ts +1 -0
- package/dist/types/session/retry-fallback-chains.d.ts +74 -0
- package/dist/types/session/role-models.d.ts +15 -0
- package/dist/types/session/session-advisors.d.ts +228 -0
- package/dist/types/session/session-entries.d.ts +8 -0
- package/dist/types/session/session-handoff.d.ts +70 -0
- package/dist/types/session/session-history-format.d.ts +6 -1
- package/dist/types/session/session-maintenance.d.ts +246 -0
- package/dist/types/session/session-manager.d.ts +41 -0
- package/dist/types/session/session-memory.d.ts +56 -0
- package/dist/types/session/session-provider-boundary.d.ts +62 -0
- package/dist/types/session/session-stats.d.ts +48 -0
- package/dist/types/session/session-tools.d.ts +158 -0
- package/dist/types/session/session-workspace.d.ts +32 -0
- package/dist/types/session/stream-guards.d.ts +44 -0
- package/dist/types/session/streaming-output.d.ts +8 -0
- package/dist/types/session/todo-tracker.d.ts +56 -0
- package/dist/types/session/ttsr-coordinator.d.ts +51 -0
- package/dist/types/session/turn-recovery.d.ts +225 -0
- package/dist/types/slash-commands/helpers/session-pin.d.ts +9 -0
- package/dist/types/stt/index.d.ts +0 -2
- package/dist/types/stt/stt-controller.d.ts +7 -0
- package/dist/types/system-prompt.d.ts +2 -0
- package/dist/types/task/executor.d.ts +4 -1
- package/dist/types/task/output-manager.d.ts +3 -1
- package/dist/types/tiny/title-client.d.ts +10 -0
- package/dist/types/tools/approval.d.ts +1 -0
- package/dist/types/tools/browser/launch.d.ts +5 -0
- package/dist/types/tools/builtin-names.d.ts +1 -1
- package/dist/types/tools/computer/protocol.d.ts +43 -0
- package/dist/types/tools/computer/supervisor.d.ts +32 -0
- package/dist/types/tools/computer/worker-entry.d.ts +1 -0
- package/dist/types/tools/computer/worker.d.ts +15 -0
- package/dist/types/tools/computer-renderer.d.ts +22 -0
- package/dist/types/tools/computer.d.ts +71 -0
- package/dist/types/tools/context.d.ts +2 -0
- package/dist/types/tools/default-renderer.d.ts +21 -0
- package/dist/types/tools/image-gen.d.ts +4 -4
- package/dist/types/tools/image-providers.d.ts +38 -0
- package/dist/types/tools/index.d.ts +7 -0
- package/dist/types/tools/path-utils.d.ts +8 -0
- package/dist/types/tools/todo.d.ts +10 -4
- package/dist/types/tools/xdev.d.ts +5 -1
- package/dist/types/tts/streaming-player.d.ts +10 -29
- package/dist/types/tts/vocalizer.d.ts +5 -0
- package/dist/types/utils/jj.d.ts +29 -0
- package/dist/types/utils/lang-from-path.d.ts +1 -0
- package/dist/types/utils/title-generator.d.ts +30 -0
- package/dist/types/utils/tools-manager.d.ts +1 -2
- package/dist/types/vibe/runtime.d.ts +36 -8
- package/dist/types/web/search/index.d.ts +1 -1
- package/dist/types/web/search/provider.d.ts +15 -5
- package/dist/types/web/search/types.d.ts +94 -0
- package/package.json +12 -12
- package/scripts/generate-share-viewer.ts +4 -6
- package/src/advisor/__tests__/advisor.test.ts +643 -0
- package/src/advisor/runtime.ts +144 -43
- package/src/async/job-manager.ts +90 -2
- package/src/cli/args.ts +3 -0
- package/src/cli/auth-gateway-cli.ts +18 -3
- package/src/cli/bench-cli.ts +395 -29
- package/src/cli/flag-tables.ts +3 -0
- package/src/cli/gc-cli.ts +2 -2
- package/src/cli/setup-cli.ts +2 -14
- package/src/cli/usage-cli.ts +10 -1
- package/src/cli.ts +8 -0
- package/src/collab/host.ts +3 -2
- package/src/commands/bench.ts +18 -4
- package/src/commands/launch.ts +4 -0
- package/src/config/model-registry.ts +16 -2
- package/src/config/models-config-schema.ts +15 -4
- package/src/config/provider-globals.ts +9 -9
- package/src/config/service-tier.ts +26 -1
- package/src/config/settings-schema.ts +270 -51
- package/src/config/settings.ts +81 -2
- package/src/dap/client.ts +37 -4
- package/src/edit/index.ts +49 -12
- package/src/eval/executor-base.ts +1 -0
- package/src/eval/js/executor.ts +2 -0
- package/src/eval/py/executor.ts +103 -33
- package/src/exec/bash-executor.ts +90 -6
- package/src/exec/direnv.ts +145 -0
- package/src/export/html/args.ts +20 -0
- package/src/export/html/index.ts +45 -47
- package/src/export/html/template.css +19 -1
- package/src/export/html/template.html +6 -0
- package/src/export/html/template.js +21 -0
- package/src/export/html/tool-views.generated.js +31 -31
- package/src/export/html/web-palette.ts +116 -132
- package/src/export/share.ts +249 -49
- package/src/extensibility/extensions/loader.ts +29 -1
- package/src/extensibility/extensions/runner.ts +6 -0
- package/src/extensibility/extensions/types.ts +33 -2
- package/src/extensibility/extensions/wrapper.ts +68 -12
- package/src/extensibility/legacy-pi-coding-agent-shim.ts +7 -1
- package/src/extensibility/plugins/legacy-pi-compat.ts +19 -1
- package/src/hindsight/state.ts +64 -6
- package/src/internal-urls/local-protocol.ts +2 -1
- package/src/internal-urls/memory-protocol.ts +2 -2
- package/src/internal-urls/skill-protocol.ts +2 -2
- package/src/internal-urls/ssh-protocol.ts +2 -1
- package/src/internal-urls/vault-protocol.ts +2 -1
- package/src/live/attestation.ts +91 -0
- package/src/live/controller.ts +517 -0
- package/src/live/prompts/agent-final-message.md +3 -0
- package/src/live/prompts/live-instructions.md +23 -0
- package/src/live/protocol.test.ts +140 -0
- package/src/live/protocol.ts +233 -0
- package/src/live/transport.ts +422 -0
- package/src/live/visualizer.ts +214 -0
- package/src/lsp/client.ts +29 -9
- package/src/lsp/index.ts +19 -4
- package/src/main.ts +8 -1
- package/src/mcp/config-writer.test.ts +43 -0
- package/src/mcp/config-writer.ts +109 -82
- package/src/mcp/oauth-discovery.ts +10 -2
- package/src/mcp/smithery-auth.test.ts +29 -0
- package/src/mcp/smithery-auth.ts +3 -2
- package/src/memories/index.ts +40 -20
- package/src/memory-backend/tool-names.ts +2 -0
- package/src/mnemopi/backend.ts +24 -7
- package/src/modes/acp/acp-agent.ts +56 -10
- package/src/modes/acp/acp-event-mapper.ts +8 -1
- package/src/modes/components/agent-hub.ts +1 -1
- package/src/modes/components/assistant-message.ts +7 -2
- package/src/modes/components/custom-message.ts +4 -1
- package/src/modes/components/login-dialog.ts +14 -4
- package/src/modes/components/message-frame.ts +14 -8
- package/src/modes/components/plan-review-overlay.ts +350 -35
- package/src/modes/components/session-account-selector.ts +62 -0
- package/src/modes/components/settings-defs.ts +23 -1
- package/src/modes/components/settings-selector.ts +169 -1
- package/src/modes/components/status-line/component.jj-cache.test.ts +229 -0
- package/src/modes/components/status-line/component.ts +123 -2
- package/src/modes/components/tool-execution.ts +28 -112
- package/src/modes/controllers/command-controller.ts +56 -15
- package/src/modes/controllers/event-controller.ts +111 -16
- package/src/modes/controllers/extension-ui-controller.test.ts +1 -0
- package/src/modes/controllers/extension-ui-controller.ts +20 -4
- package/src/modes/controllers/input-controller.ts +47 -39
- package/src/modes/controllers/live-command-controller.ts +255 -0
- package/src/modes/controllers/mcp-command-controller.ts +10 -1
- package/src/modes/controllers/omfg-controller.ts +44 -40
- package/src/modes/controllers/selector-controller.ts +80 -10
- package/src/modes/controllers/session-focus-controller.ts +6 -1
- package/src/modes/interactive-mode.ts +176 -38
- package/src/modes/runtime-init.ts +2 -0
- package/src/modes/setup-wizard/scenes/web-search.ts +17 -9
- package/src/modes/theme/theme.ts +1 -1
- package/src/modes/types.ts +4 -1
- package/src/modes/utils/context-usage.ts +23 -7
- package/src/modes/utils/ui-helpers.ts +10 -5
- package/src/plan-mode/plan-files.ts +40 -0
- package/src/prompts/bench/cache-prefix-chunk.md +1 -0
- package/src/prompts/bench/cache-prefix.md +3 -0
- package/src/prompts/bench/cache-suffix.md +1 -0
- package/src/prompts/system/computer-safety.md +14 -0
- package/src/prompts/system/custom-system-prompt.md +1 -1
- package/src/prompts/system/project-prompt.md +8 -1
- package/src/prompts/system/subagent-async-pending.md +6 -0
- package/src/prompts/system/system-prompt.md +1 -1
- package/src/prompts/system/workflow-notice.md +48 -40
- package/src/prompts/system/xdev-mount-notice.md +4 -0
- package/src/prompts/tools/computer.md +26 -0
- package/src/prompts/tools/todo.md +3 -1
- package/src/registry/agent-lifecycle.ts +116 -46
- package/src/registry/agent-registry.ts +35 -8
- package/src/registry/persisted-agents.ts +26 -2
- package/src/sdk.ts +215 -136
- package/src/secrets/index.ts +127 -4
- package/src/secrets/obfuscator.ts +2328 -105
- package/src/session/acp-permission-gate.ts +165 -0
- package/src/session/agent-session-error-log.test.ts +1 -1
- package/src/session/agent-session-events.ts +66 -0
- package/src/session/agent-session-types.ts +343 -0
- package/src/session/agent-session.ts +1940 -12218
- package/src/session/artifacts.ts +6 -5
- package/src/session/async-job-delivery.ts +74 -0
- package/src/session/auth-storage.ts +1 -0
- package/src/session/bash-runner.ts +326 -0
- package/src/session/blob-store.test.ts +56 -0
- package/src/session/blob-store.ts +18 -2
- package/src/session/checkpoint-entries.ts +81 -0
- package/src/session/eval-runner.ts +217 -0
- package/src/session/indexed-session-storage.ts +9 -2
- package/src/session/irc-bridge.ts +203 -0
- package/src/session/messages.ts +266 -1
- package/src/session/model-controls.ts +714 -0
- package/src/session/prewalk.ts +252 -0
- package/src/session/queued-messages.ts +93 -0
- package/src/session/redis-session-storage.ts +51 -11
- package/src/session/retry-fallback-chains.ts +455 -0
- package/src/session/role-models.ts +85 -0
- package/src/session/session-advisors.ts +1679 -0
- package/src/session/session-context.ts +6 -3
- package/src/session/session-entries.ts +8 -0
- package/src/session/session-handoff.ts +308 -0
- package/src/session/session-history-format.ts +20 -9
- package/src/session/session-loader.ts +0 -46
- package/src/session/session-maintenance.ts +2983 -0
- package/src/session/session-manager.ts +390 -30
- package/src/session/session-memory.ts +222 -0
- package/src/session/session-provider-boundary.ts +307 -0
- package/src/session/session-stats.ts +293 -0
- package/src/session/session-tools.ts +980 -0
- package/src/session/session-workspace.ts +53 -0
- package/src/session/stream-guards.ts +417 -0
- package/src/session/streaming-output.ts +52 -5
- package/src/session/todo-tracker.ts +380 -0
- package/src/session/ttsr-coordinator.ts +496 -0
- package/src/session/turn-recovery.ts +1629 -0
- package/src/slash-commands/builtin-registry.ts +257 -20
- package/src/slash-commands/helpers/session-pin.ts +44 -0
- package/src/slash-commands/helpers/usage-report.ts +22 -3
- package/src/stt/downloader.ts +0 -2
- package/src/stt/index.ts +0 -2
- package/src/stt/stt-controller.ts +57 -146
- package/src/system-prompt.ts +45 -17
- package/src/task/executor.ts +285 -70
- package/src/task/index.ts +98 -105
- package/src/task/output-manager.ts +25 -3
- package/src/task/persisted-revive.ts +4 -3
- package/src/task/structured-subagent.ts +1 -0
- package/src/tiny/title-client.ts +22 -0
- package/src/tools/approval.ts +55 -10
- package/src/tools/bash-interactive.ts +116 -86
- package/src/tools/bash-skill-urls.ts +28 -2
- package/src/tools/bash.ts +339 -123
- package/src/tools/browser/launch.ts +9 -1
- package/src/tools/browser/tab-supervisor.ts +8 -5
- package/src/tools/browser.ts +94 -47
- package/src/tools/builtin-names.ts +1 -0
- package/src/tools/computer/protocol.ts +28 -0
- package/src/tools/computer/supervisor.ts +258 -0
- package/src/tools/computer/worker-entry.ts +25 -0
- package/src/tools/computer/worker.ts +135 -0
- package/src/tools/computer-renderer.ts +108 -0
- package/src/tools/computer.ts +433 -0
- package/src/tools/context.ts +2 -0
- package/src/tools/default-renderer.ts +139 -0
- package/src/tools/essential-tools.ts +1 -0
- package/src/tools/image-gen.ts +20 -28
- package/src/tools/image-providers.ts +50 -0
- package/src/tools/index.ts +14 -0
- package/src/tools/path-utils.ts +49 -2
- package/src/tools/read.ts +156 -88
- package/src/tools/renderers.ts +9 -1
- package/src/tools/todo.ts +101 -11
- package/src/tools/vibe.ts +1 -2
- package/src/tools/write.ts +51 -1
- package/src/tools/xdev.ts +121 -29
- package/src/tts/streaming-player.ts +82 -283
- package/src/tts/vocalizer.ts +18 -1
- package/src/utils/clipboard.ts +1 -30
- package/src/utils/jj.ts +125 -4
- package/src/utils/lang-from-path.ts +7 -0
- package/src/utils/mac-file-urls.applescript +37 -0
- package/src/utils/title-generator.ts +137 -1
- package/src/utils/tool-choice.ts +14 -0
- package/src/utils/tools-manager.ts +1 -19
- package/src/vibe/runtime.ts +852 -72
- package/src/web/search/index.ts +3 -6
- package/src/web/search/provider.ts +31 -16
- package/src/web/search/providers/xai.ts +7 -1
- package/src/web/search/types.ts +3 -0
- package/dist/types/stt/recorder.d.ts +0 -30
- package/dist/types/stt/transcriber.d.ts +0 -14
- package/dist/types/stt/wav.d.ts +0 -29
- package/dist/types/tts/player.d.ts +0 -32
- package/src/stt/recorder.ts +0 -551
- package/src/stt/transcriber.ts +0 -60
- package/src/stt/wav.ts +0 -173
- package/src/tts/player.ts +0 -137
|
@@ -102,6 +102,9 @@ const EXTENSION_LANG: Record<string, readonly [string, string]> = {
|
|
|
102
102
|
md: ["markdown", "markdown"],
|
|
103
103
|
markdown: ["markdown", "markdown"],
|
|
104
104
|
mdx: ["markdown", "markdown"],
|
|
105
|
+
mdc: ["markdown", "markdown"],
|
|
106
|
+
mkd: ["markdown", "markdown"],
|
|
107
|
+
mdown: ["markdown", "markdown"],
|
|
105
108
|
rst: ["restructuredtext", "restructuredtext"],
|
|
106
109
|
adoc: ["asciidoc", "asciidoc"],
|
|
107
110
|
tex: ["latex", "latex"],
|
|
@@ -217,6 +220,10 @@ export function getLanguageFromPath(filePath: string): string | undefined {
|
|
|
217
220
|
return undefined;
|
|
218
221
|
}
|
|
219
222
|
|
|
223
|
+
export function isMarkdownPath(filePath: string): boolean {
|
|
224
|
+
return getLanguageFromPath(filePath) === "markdown";
|
|
225
|
+
}
|
|
226
|
+
|
|
220
227
|
/**
|
|
221
228
|
* LSP language identifier; falls back to `plaintext`.
|
|
222
229
|
*/
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
-- Returns the POSIX paths of every file URL currently on the macOS
|
|
2
|
+
-- pasteboard, one path per line. `pbpaste(1)` only surfaces plain text,
|
|
3
|
+
-- EPS, or RTF, so a Finder Cmd+C (which puts only a `public.file-url`
|
|
4
|
+
-- representation on the pasteboard) makes `pbpaste` empty. The
|
|
5
|
+
-- `«class furl»` coercion reaches the file-URL representation directly and
|
|
6
|
+
-- works for both single-file and multi-file selections.
|
|
7
|
+
--
|
|
8
|
+
-- The coercion is guarded by `clipboard info for «class furl»`: AppleScript
|
|
9
|
+
-- happily coerces plain *text* into a file URL by treating it as an HFS
|
|
10
|
+
-- path, so an unguarded cast turns a copied `https://i.can.ac/x.png` string
|
|
11
|
+
-- into the mangled `/https/::i.can.ac:x.png` (HFS `:`↔`/` swap) and the
|
|
12
|
+
-- paste dead-ends with "Image not found" instead of falling back to pasting
|
|
13
|
+
-- the text. `clipboard info for` inspects the actual pasteboard types, so
|
|
14
|
+
-- it is `{}` unless a real `public.file-url` representation is present.
|
|
15
|
+
--
|
|
16
|
+
-- The `try` blocks suppress the `-1700` "can't make … into type" error
|
|
17
|
+
-- AppleScript raises when the clipboard holds no file URLs, so the script's
|
|
18
|
+
-- exit status only reflects `osascript` itself.
|
|
19
|
+
on run
|
|
20
|
+
set output to ""
|
|
21
|
+
try
|
|
22
|
+
if (clipboard info for «class furl») is {} then return output
|
|
23
|
+
set theClip to the clipboard as «class furl»
|
|
24
|
+
if class of theClip is list then
|
|
25
|
+
repeat with anItem in theClip
|
|
26
|
+
try
|
|
27
|
+
set output to output & POSIX path of anItem & linefeed
|
|
28
|
+
end try
|
|
29
|
+
end repeat
|
|
30
|
+
else
|
|
31
|
+
try
|
|
32
|
+
set output to POSIX path of theClip & linefeed
|
|
33
|
+
end try
|
|
34
|
+
end if
|
|
35
|
+
end try
|
|
36
|
+
return output
|
|
37
|
+
end run
|
|
@@ -387,7 +387,143 @@ export function setTerminalTitle(title: string): void {
|
|
|
387
387
|
}
|
|
388
388
|
|
|
389
389
|
export function setSessionTerminalTitle(sessionName: string | undefined, cwd?: string): void {
|
|
390
|
-
|
|
390
|
+
// An authoritative session title (rename, new session, focus swap) supersedes
|
|
391
|
+
// any extension override so the base title tracks the real session again.
|
|
392
|
+
terminalTitleRuntime.extensionOverride = undefined;
|
|
393
|
+
terminalTitleRuntime.label = sanitizeTerminalTitlePart(sessionName) ?? getFallbackTerminalTitle(cwd);
|
|
394
|
+
emitTerminalTitle();
|
|
395
|
+
}
|
|
396
|
+
|
|
397
|
+
/**
|
|
398
|
+
* Set a terminal title from an extension's `setTitle()`. Unlike the session base
|
|
399
|
+
* title, this owns the terminal verbatim: the run-state separator will not rewrite
|
|
400
|
+
* it on the next spinner tick or state change. Cleared when the app next sets an
|
|
401
|
+
* authoritative session title via {@link setSessionTerminalTitle}.
|
|
402
|
+
*/
|
|
403
|
+
export function setExtensionTerminalTitle(title: string): void {
|
|
404
|
+
terminalTitleRuntime.extensionOverride = title;
|
|
405
|
+
emitTerminalTitle();
|
|
406
|
+
}
|
|
407
|
+
|
|
408
|
+
export type TerminalTitleState = "idle" | "working" | "attention";
|
|
409
|
+
|
|
410
|
+
/** Separator glyphs carrying the run state between the `π` brand and the session
|
|
411
|
+
* label — the brand itself stays bare (no prefix glyph). Spinner frames animate
|
|
412
|
+
* the separator while working; they are self-contained (not the theme's symbol
|
|
413
|
+
* set) to avoid a utils→modes import cycle; OSC titles render in tab/window bars
|
|
414
|
+
* that handle Unicode. */
|
|
415
|
+
const TITLE_SPINNER_FRAMES = ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"] as const;
|
|
416
|
+
const TITLE_SPINNER_INTERVAL_MS = 80;
|
|
417
|
+
/** The user's turn: the title reads like a shell prompt awaiting input. */
|
|
418
|
+
const TITLE_IDLE_SEPARATOR = ">";
|
|
419
|
+
/** Agent blocked on the user (ask / approval prompt). */
|
|
420
|
+
const TITLE_ATTENTION_SEPARATOR = "!";
|
|
421
|
+
|
|
422
|
+
const terminalTitleRuntime: {
|
|
423
|
+
label: string | undefined;
|
|
424
|
+
state: TerminalTitleState;
|
|
425
|
+
frame: number;
|
|
426
|
+
enabled: boolean;
|
|
427
|
+
timer: NodeJS.Timeout | undefined;
|
|
428
|
+
lastEmitted: string | undefined;
|
|
429
|
+
/** A title an extension set via `setTitle()`. While set, it owns the terminal
|
|
430
|
+
* title verbatim: the run-state separator never rewrites it. Cleared when the
|
|
431
|
+
* app next establishes an authoritative session title (rename, new session,
|
|
432
|
+
* focus swap) via `setSessionTerminalTitle`. */
|
|
433
|
+
extensionOverride: string | undefined;
|
|
434
|
+
} = {
|
|
435
|
+
label: undefined,
|
|
436
|
+
state: "idle",
|
|
437
|
+
frame: 0,
|
|
438
|
+
enabled: true,
|
|
439
|
+
timer: undefined,
|
|
440
|
+
lastEmitted: undefined,
|
|
441
|
+
extensionOverride: undefined,
|
|
442
|
+
};
|
|
443
|
+
|
|
444
|
+
/**
|
|
445
|
+
* Compose the terminal title from the `π` brand, a state-carrying SEPARATOR, and
|
|
446
|
+
* the session label. The brand never gains a prefix glyph — the separator slot
|
|
447
|
+
* expresses the run state instead. Pure (no I/O) so the state→separator contract
|
|
448
|
+
* is unit-testable:
|
|
449
|
+
* - `idle` (user's turn): `π > label` — reads like a prompt awaiting input;
|
|
450
|
+
* - `working`: `π ⠋ label` — spinner frames animate the separator;
|
|
451
|
+
* - `attention`: `π ! label` — agent blocked on the user;
|
|
452
|
+
* - disabled: `π: label` — the pre-state layout.
|
|
453
|
+
* Without a label the separator trails the brand (`π >`) so the state stays visible.
|
|
454
|
+
*/
|
|
455
|
+
export function buildTerminalTitleWithState(
|
|
456
|
+
label: string | undefined,
|
|
457
|
+
state: TerminalTitleState,
|
|
458
|
+
frame: number,
|
|
459
|
+
enabled: boolean,
|
|
460
|
+
): string {
|
|
461
|
+
if (!enabled) return label ? `${DEFAULT_TERMINAL_TITLE}: ${label}` : DEFAULT_TERMINAL_TITLE;
|
|
462
|
+
const separator =
|
|
463
|
+
state === "working"
|
|
464
|
+
? TITLE_SPINNER_FRAMES[frame % TITLE_SPINNER_FRAMES.length]
|
|
465
|
+
: state === "attention"
|
|
466
|
+
? TITLE_ATTENTION_SEPARATOR
|
|
467
|
+
: TITLE_IDLE_SEPARATOR;
|
|
468
|
+
return label ? `${DEFAULT_TERMINAL_TITLE} ${separator} ${label}` : `${DEFAULT_TERMINAL_TITLE} ${separator}`;
|
|
469
|
+
}
|
|
470
|
+
|
|
471
|
+
function emitTerminalTitle(): void {
|
|
472
|
+
// An extension override owns the terminal verbatim; the run-state separator and
|
|
473
|
+
// spinner ticks must not clobber it (still deduped via lastEmitted).
|
|
474
|
+
const next =
|
|
475
|
+
terminalTitleRuntime.extensionOverride ??
|
|
476
|
+
buildTerminalTitleWithState(
|
|
477
|
+
terminalTitleRuntime.label,
|
|
478
|
+
terminalTitleRuntime.state,
|
|
479
|
+
terminalTitleRuntime.frame,
|
|
480
|
+
terminalTitleRuntime.enabled,
|
|
481
|
+
);
|
|
482
|
+
if (next === terminalTitleRuntime.lastEmitted) return;
|
|
483
|
+
terminalTitleRuntime.lastEmitted = next;
|
|
484
|
+
setTerminalTitle(next);
|
|
485
|
+
}
|
|
486
|
+
|
|
487
|
+
function stopTerminalTitleSpinner(): void {
|
|
488
|
+
if (terminalTitleRuntime.timer) {
|
|
489
|
+
clearInterval(terminalTitleRuntime.timer);
|
|
490
|
+
terminalTitleRuntime.timer = undefined;
|
|
491
|
+
}
|
|
492
|
+
}
|
|
493
|
+
|
|
494
|
+
function startTerminalTitleSpinner(): void {
|
|
495
|
+
if (terminalTitleRuntime.timer || !process.stdout.isTTY) return;
|
|
496
|
+
terminalTitleRuntime.timer = setInterval(() => {
|
|
497
|
+
terminalTitleRuntime.frame = (terminalTitleRuntime.frame + 1) % TITLE_SPINNER_FRAMES.length;
|
|
498
|
+
emitTerminalTitle();
|
|
499
|
+
}, TITLE_SPINNER_INTERVAL_MS);
|
|
500
|
+
// Never keep the event loop alive for a cosmetic animation.
|
|
501
|
+
terminalTitleRuntime.timer.unref?.();
|
|
502
|
+
}
|
|
503
|
+
|
|
504
|
+
/**
|
|
505
|
+
* Reflect the agent run state in the terminal title's separator: `working`
|
|
506
|
+
* animates spinner frames in the separator slot, `idle` shows `>` (your turn),
|
|
507
|
+
* `attention` shows `!` (agent blocked on you). Gated off by `tui.titleState`.
|
|
508
|
+
*/
|
|
509
|
+
export function setTerminalTitleState(state: TerminalTitleState): void {
|
|
510
|
+
terminalTitleRuntime.state = state;
|
|
511
|
+
if (state === "working" && terminalTitleRuntime.enabled) startTerminalTitleSpinner();
|
|
512
|
+
else stopTerminalTitleSpinner();
|
|
513
|
+
emitTerminalTitle();
|
|
514
|
+
}
|
|
515
|
+
|
|
516
|
+
/** Enable/disable the run-state separator (driven by the `tui.titleState` setting). */
|
|
517
|
+
export function setTerminalTitleStateEnabled(enabled: boolean): void {
|
|
518
|
+
terminalTitleRuntime.enabled = enabled;
|
|
519
|
+
if (enabled && terminalTitleRuntime.state === "working") startTerminalTitleSpinner();
|
|
520
|
+
else stopTerminalTitleSpinner();
|
|
521
|
+
emitTerminalTitle();
|
|
522
|
+
}
|
|
523
|
+
|
|
524
|
+
/** Stop the spinner timer; call on session/UI teardown. */
|
|
525
|
+
export function disposeTerminalTitleState(): void {
|
|
526
|
+
stopTerminalTitleSpinner();
|
|
391
527
|
}
|
|
392
528
|
|
|
393
529
|
/**
|
package/src/utils/tool-choice.ts
CHANGED
|
@@ -12,6 +12,19 @@ export function buildNamedToolChoice(toolName: string, model?: Model<Api>): Tool
|
|
|
12
12
|
return { type: "tool", name: toolName };
|
|
13
13
|
}
|
|
14
14
|
|
|
15
|
+
if (toolName === "computer" && model.supportsComputerUse === true) {
|
|
16
|
+
if (
|
|
17
|
+
model.api === "openai-codex-responses" ||
|
|
18
|
+
model.api === "openai-responses" ||
|
|
19
|
+
model.api === "azure-openai-responses"
|
|
20
|
+
) {
|
|
21
|
+
return { type: "computer" };
|
|
22
|
+
}
|
|
23
|
+
return undefined;
|
|
24
|
+
}
|
|
25
|
+
// Models without native computer support receive the tool as a regular
|
|
26
|
+
// function tool, so the generic named-function forcing below applies.
|
|
27
|
+
|
|
15
28
|
if (
|
|
16
29
|
model.api === "openai-codex-responses" ||
|
|
17
30
|
model.api === "openai-responses" ||
|
|
@@ -39,6 +52,7 @@ export function buildNamedToolChoice(toolName: string, model?: Model<Api>): Tool
|
|
|
39
52
|
*/
|
|
40
53
|
export function isToolChoiceActive(toolChoice: ToolChoice | undefined, tools: readonly { name: string }[]): boolean {
|
|
41
54
|
if (!toolChoice || typeof toolChoice === "string") return true;
|
|
55
|
+
if (toolChoice.type === "computer") return tools.some(tool => tool.name === "computer");
|
|
42
56
|
const name =
|
|
43
57
|
toolChoice.type === "tool"
|
|
44
58
|
? toolChoice.name
|
|
@@ -73,16 +73,6 @@ interface ToolConfig {
|
|
|
73
73
|
getAssetName: (version: string, plat: string, architecture: string) => string | null;
|
|
74
74
|
}
|
|
75
75
|
|
|
76
|
-
// ffmpeg static-binary asset names (eugeneware/ffmpeg-static direct binaries).
|
|
77
|
-
// Maps node arch (arm64|x64) only; everything else is unsupported.
|
|
78
|
-
export function ffmpegAssetName(_version: string, plat: string, architecture: string): string | null {
|
|
79
|
-
if (architecture !== "arm64" && architecture !== "x64") return null;
|
|
80
|
-
if (plat === "darwin") return `ffmpeg-darwin-${architecture}`;
|
|
81
|
-
if (plat === "linux") return `ffmpeg-linux-${architecture}`;
|
|
82
|
-
if (plat === "win32") return architecture === "x64" ? "ffmpeg-win32-x64" : null;
|
|
83
|
-
return null;
|
|
84
|
-
}
|
|
85
|
-
|
|
86
76
|
const TOOLS: Record<string, ToolConfig> = {
|
|
87
77
|
sd: {
|
|
88
78
|
name: "sd",
|
|
@@ -139,14 +129,6 @@ const TOOLS: Record<string, ToolConfig> = {
|
|
|
139
129
|
return null;
|
|
140
130
|
},
|
|
141
131
|
},
|
|
142
|
-
ffmpeg: {
|
|
143
|
-
name: "ffmpeg",
|
|
144
|
-
repo: "eugeneware/ffmpeg-static",
|
|
145
|
-
binaryName: "ffmpeg",
|
|
146
|
-
tagPrefix: "",
|
|
147
|
-
isDirectBinary: true,
|
|
148
|
-
getAssetName: ffmpegAssetName,
|
|
149
|
-
},
|
|
150
132
|
};
|
|
151
133
|
|
|
152
134
|
// CLI packages installed via uv/pip
|
|
@@ -164,7 +146,7 @@ const PYTHON_TOOLS: Record<string, PythonPackageToolConfig> = {
|
|
|
164
146
|
},
|
|
165
147
|
};
|
|
166
148
|
|
|
167
|
-
export type ToolName = "sd" | "sg" | "yt-dlp" | "trafilatura"
|
|
149
|
+
export type ToolName = "sd" | "sg" | "yt-dlp" | "trafilatura";
|
|
168
150
|
|
|
169
151
|
// Get the path to a tool (system-wide or in our tools dir)
|
|
170
152
|
export function getToolPath(tool: ToolName): string | null {
|