@code-yeongyu/senpi 2026.9.12-3 → 2026.9.13-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 -0
- package/README.md +3 -1
- package/dist/bun/cli.js +2 -3
- package/dist/bun/cli.js.map +1 -1
- package/dist/bun/runtime-modules.d.ts +3 -0
- package/dist/bun/runtime-modules.d.ts.map +1 -0
- package/dist/bun/runtime-modules.js +17 -0
- package/dist/bun/runtime-modules.js.map +1 -0
- package/dist/bun/runtime-setup.js +2 -5
- package/dist/bun/runtime-setup.js.map +1 -1
- package/dist/core/agent-session.d.ts +2 -2
- package/dist/core/agent-session.d.ts.map +1 -1
- package/dist/core/agent-session.js +38 -30
- package/dist/core/agent-session.js.map +1 -1
- package/dist/core/discovered-resource-scope.d.ts +23 -0
- package/dist/core/discovered-resource-scope.d.ts.map +1 -0
- package/dist/core/discovered-resource-scope.js +44 -0
- package/dist/core/discovered-resource-scope.js.map +1 -0
- package/dist/core/extensions/builtin/ask-user/notify.d.ts +24 -0
- package/dist/core/extensions/builtin/ask-user/notify.d.ts.map +1 -0
- package/dist/core/extensions/builtin/ask-user/notify.js +11 -0
- package/dist/core/extensions/builtin/ask-user/notify.js.map +1 -0
- package/dist/core/extensions/builtin/ask-user/registry.d.ts +2 -0
- package/dist/core/extensions/builtin/ask-user/registry.d.ts.map +1 -1
- package/dist/core/extensions/builtin/ask-user/registry.js.map +1 -1
- package/dist/core/extensions/builtin/ask-user/resume.d.ts +1 -1
- package/dist/core/extensions/builtin/ask-user/resume.d.ts.map +1 -1
- package/dist/core/extensions/builtin/ask-user/resume.js +10 -20
- package/dist/core/extensions/builtin/ask-user/resume.js.map +1 -1
- package/dist/core/extensions/builtin/ask-user/tool.d.ts +5 -2
- package/dist/core/extensions/builtin/ask-user/tool.d.ts.map +1 -1
- package/dist/core/extensions/builtin/ask-user/tool.js +41 -6
- package/dist/core/extensions/builtin/ask-user/tool.js.map +1 -1
- package/dist/core/extensions/builtin/goal/channel-state-subscriptions.d.ts +2 -1
- package/dist/core/extensions/builtin/goal/channel-state-subscriptions.d.ts.map +1 -1
- package/dist/core/extensions/builtin/goal/channel-state-subscriptions.js +1 -1
- package/dist/core/extensions/builtin/goal/channel-state-subscriptions.js.map +1 -1
- package/dist/core/extensions/builtin/goal/monitor-continuation.d.ts.map +1 -1
- package/dist/core/extensions/builtin/goal/monitor-continuation.js +27 -13
- package/dist/core/extensions/builtin/goal/monitor-continuation.js.map +1 -1
- package/dist/core/extensions/builtin/hooks/config-loader.d.ts +2 -0
- package/dist/core/extensions/builtin/hooks/config-loader.d.ts.map +1 -1
- package/dist/core/extensions/builtin/hooks/config-loader.js +27 -0
- package/dist/core/extensions/builtin/hooks/config-loader.js.map +1 -1
- package/dist/core/extensions/builtin/hooks/dispatcher.js +1 -0
- package/dist/core/extensions/builtin/hooks/dispatcher.js.map +1 -1
- package/dist/core/extensions/builtin/hooks/index.d.ts.map +1 -1
- package/dist/core/extensions/builtin/hooks/index.js +51 -2
- package/dist/core/extensions/builtin/hooks/index.js.map +1 -1
- package/dist/core/extensions/builtin/hooks/lifecycle-adapter.d.ts +18 -1
- package/dist/core/extensions/builtin/hooks/lifecycle-adapter.d.ts.map +1 -1
- package/dist/core/extensions/builtin/hooks/lifecycle-adapter.js +36 -1
- package/dist/core/extensions/builtin/hooks/lifecycle-adapter.js.map +1 -1
- package/dist/core/extensions/builtin/hooks/matcher.js +1 -0
- package/dist/core/extensions/builtin/hooks/matcher.js.map +1 -1
- package/dist/core/extensions/builtin/hooks/output-parser.js +6 -0
- package/dist/core/extensions/builtin/hooks/output-parser.js.map +1 -1
- package/dist/core/extensions/builtin/hooks/trust-storage.d.ts +2 -0
- package/dist/core/extensions/builtin/hooks/trust-storage.d.ts.map +1 -1
- package/dist/core/extensions/builtin/hooks/trust-storage.js +13 -0
- package/dist/core/extensions/builtin/hooks/trust-storage.js.map +1 -1
- package/dist/core/extensions/builtin/hooks/types.d.ts +14 -2
- package/dist/core/extensions/builtin/hooks/types.d.ts.map +1 -1
- package/dist/core/extensions/builtin/hooks/types.js +1 -1
- package/dist/core/extensions/builtin/hooks/types.js.map +1 -1
- package/dist/core/extensions/builtin/monitor-state-event.d.ts +1 -0
- package/dist/core/extensions/builtin/monitor-state-event.d.ts.map +1 -1
- package/dist/core/extensions/builtin/monitor-state-event.js.map +1 -1
- package/dist/core/extensions/builtin/terminal/tools/bash.d.ts +1 -0
- package/dist/core/extensions/builtin/terminal/tools/bash.d.ts.map +1 -1
- package/dist/core/extensions/builtin/terminal/tools/bash.js +13 -2
- package/dist/core/extensions/builtin/terminal/tools/bash.js.map +1 -1
- package/dist/core/extensions/loader.d.ts.map +1 -1
- package/dist/core/extensions/loader.js +5 -1
- package/dist/core/extensions/loader.js.map +1 -1
- package/dist/core/extensions/runner.d.ts +5 -16
- package/dist/core/extensions/runner.d.ts.map +1 -1
- package/dist/core/extensions/runner.js +16 -5
- package/dist/core/extensions/runner.js.map +1 -1
- package/dist/core/extensions/types.d.ts +28 -5
- package/dist/core/extensions/types.d.ts.map +1 -1
- package/dist/core/extensions/types.js.map +1 -1
- package/dist/core/extensions/wrapper.d.ts +8 -3
- package/dist/core/extensions/wrapper.d.ts.map +1 -1
- package/dist/core/extensions/wrapper.js +12 -6
- package/dist/core/extensions/wrapper.js.map +1 -1
- package/dist/core/keybindings.d.ts +8 -1
- package/dist/core/keybindings.d.ts.map +1 -1
- package/dist/core/keybindings.js +7 -1
- package/dist/core/keybindings.js.map +1 -1
- package/dist/core/package-manager.d.ts +4 -2
- package/dist/core/package-manager.d.ts.map +1 -1
- package/dist/core/package-manager.js +7 -2
- package/dist/core/package-manager.js.map +1 -1
- package/dist/core/pi-manifest.d.ts +2 -0
- package/dist/core/pi-manifest.d.ts.map +1 -1
- package/dist/core/pi-manifest.js +3 -0
- package/dist/core/pi-manifest.js.map +1 -1
- package/dist/core/resource-loader.d.ts +9 -0
- package/dist/core/resource-loader.d.ts.map +1 -1
- package/dist/core/resource-loader.js +69 -21
- package/dist/core/resource-loader.js.map +1 -1
- package/dist/core/settings-manager.d.ts +1 -0
- package/dist/core/settings-manager.d.ts.map +1 -1
- package/dist/core/settings-manager.js +1 -0
- package/dist/core/settings-manager.js.map +1 -1
- package/dist/core/settings-shapes.d.ts +1 -0
- package/dist/core/settings-shapes.d.ts.map +1 -1
- package/dist/core/settings-shapes.js.map +1 -1
- package/dist/core/source-info.d.ts +5 -1
- package/dist/core/source-info.d.ts.map +1 -1
- package/dist/core/source-info.js.map +1 -1
- package/dist/core/tools/bash.d.ts.map +1 -1
- package/dist/core/tools/bash.js +5 -0
- package/dist/core/tools/bash.js.map +1 -1
- package/dist/modes/app-server/server/skills.d.ts.map +1 -1
- package/dist/modes/app-server/server/skills.js +1 -0
- package/dist/modes/app-server/server/skills.js.map +1 -1
- package/dist/modes/interactive/components/ask-user-answer-chip.d.ts +17 -0
- package/dist/modes/interactive/components/ask-user-answer-chip.d.ts.map +1 -0
- package/dist/modes/interactive/components/ask-user-answer-chip.js +86 -0
- package/dist/modes/interactive/components/ask-user-answer-chip.js.map +1 -0
- package/dist/modes/interactive/components/ask-user-answer-key.d.ts +3 -1
- package/dist/modes/interactive/components/ask-user-answer-key.d.ts.map +1 -1
- package/dist/modes/interactive/components/ask-user-answer-key.js +11 -1
- package/dist/modes/interactive/components/ask-user-answer-key.js.map +1 -1
- package/dist/modes/interactive/components/ask-user-async-widget.d.ts +5 -2
- package/dist/modes/interactive/components/ask-user-async-widget.d.ts.map +1 -1
- package/dist/modes/interactive/components/ask-user-async-widget.js +18 -12
- package/dist/modes/interactive/components/ask-user-async-widget.js.map +1 -1
- package/dist/modes/interactive/components/ask-user-countdown.d.ts +8 -0
- package/dist/modes/interactive/components/ask-user-countdown.d.ts.map +1 -0
- package/dist/modes/interactive/components/ask-user-countdown.js +23 -0
- package/dist/modes/interactive/components/ask-user-countdown.js.map +1 -0
- package/dist/modes/interactive/components/ask-user-question-keys.d.ts.map +1 -1
- package/dist/modes/interactive/components/ask-user-question-keys.js +85 -17
- package/dist/modes/interactive/components/ask-user-question-keys.js.map +1 -1
- package/dist/modes/interactive/components/ask-user-question-render.d.ts.map +1 -1
- package/dist/modes/interactive/components/ask-user-question-render.js +22 -7
- package/dist/modes/interactive/components/ask-user-question-render.js.map +1 -1
- package/dist/modes/interactive/components/ask-user-question-state.d.ts +15 -0
- package/dist/modes/interactive/components/ask-user-question-state.d.ts.map +1 -1
- package/dist/modes/interactive/components/ask-user-question-state.js +57 -13
- package/dist/modes/interactive/components/ask-user-question-state.js.map +1 -1
- package/dist/modes/interactive/components/ask-user-question.d.ts +8 -2
- package/dist/modes/interactive/components/ask-user-question.d.ts.map +1 -1
- package/dist/modes/interactive/components/ask-user-question.js +16 -8
- package/dist/modes/interactive/components/ask-user-question.js.map +1 -1
- package/dist/modes/interactive/components/config-selector.d.ts +2 -1
- package/dist/modes/interactive/components/config-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/config-selector.js.map +1 -1
- package/dist/modes/interactive/components/custom-editor.d.ts +2 -0
- package/dist/modes/interactive/components/custom-editor.d.ts.map +1 -1
- package/dist/modes/interactive/components/custom-editor.js +10 -1
- package/dist/modes/interactive/components/custom-editor.js.map +1 -1
- package/dist/modes/interactive/components/loaded-resource-section.d.ts +14 -0
- package/dist/modes/interactive/components/loaded-resource-section.d.ts.map +1 -0
- package/dist/modes/interactive/components/loaded-resource-section.js +25 -0
- package/dist/modes/interactive/components/loaded-resource-section.js.map +1 -0
- package/dist/modes/interactive/components/user-message.d.ts +2 -1
- package/dist/modes/interactive/components/user-message.d.ts.map +1 -1
- package/dist/modes/interactive/components/user-message.js +12 -2
- package/dist/modes/interactive/components/user-message.js.map +1 -1
- package/dist/modes/interactive/interactive-mode.d.ts +14 -11
- package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-mode.js +263 -165
- package/dist/modes/interactive/interactive-mode.js.map +1 -1
- package/dist/modes/interactive/loaded-resource-scopes.d.ts +28 -0
- package/dist/modes/interactive/loaded-resource-scopes.d.ts.map +1 -0
- package/dist/modes/interactive/loaded-resource-scopes.js +107 -0
- package/dist/modes/interactive/loaded-resource-scopes.js.map +1 -0
- package/dist/modes/interactive/tips/catalog/input-tips.d.ts +1 -1
- package/dist/modes/interactive/tips/catalog/input-tips.js +2 -2
- package/dist/modes/interactive/tips/catalog/input-tips.js.map +1 -1
- package/dist/modes/rpc/host-lifecycle.d.ts.map +1 -1
- package/dist/modes/rpc/host-lifecycle.js +7 -0
- package/dist/modes/rpc/host-lifecycle.js.map +1 -1
- package/dist/modes/rpc/session-worker.js +5 -0
- package/dist/modes/rpc/session-worker.js.map +1 -1
- package/docs/environment-variables.md +5 -1
- package/docs/extensions.md +43 -5
- package/docs/keybindings.md +5 -2
- package/docs/packages.md +17 -0
- package/docs/rpc.md +6 -3
- package/docs/settings.md +5 -1
- package/docs/tui.md +15 -3
- package/node_modules/@code-yeongyu/senpi-codemode/CHANGELOG.md +28 -0
- package/node_modules/@code-yeongyu/senpi-codemode/README.md +16 -4
- package/node_modules/@code-yeongyu/senpi-codemode/package.json +4 -4
- package/node_modules/@code-yeongyu/senpi-codemode/src/kernels/js/worker-core.js +2 -0
- package/node_modules/@code-yeongyu/senpi-codemode/src/kernels/session-env.ts +6 -0
- package/node_modules/@code-yeongyu/senpi-codemode/src/tool/detached-cell-manager.ts +6 -1
- package/node_modules/@code-yeongyu/senpi-codemode/src/tool/run-eval-cell.ts +31 -12
- package/node_modules/@earendil-works/chord/package.json +1 -1
- package/node_modules/@earendil-works/pi-agent-core/dist/harness/messages.d.ts +1 -1
- package/node_modules/@earendil-works/pi-agent-core/dist/harness/messages.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-agent-core/dist/harness/messages.js +1 -1
- package/node_modules/@earendil-works/pi-agent-core/dist/harness/messages.js.map +1 -1
- package/node_modules/@earendil-works/pi-agent-core/package.json +4 -4
- package/node_modules/@earendil-works/pi-ai/dist/api/devin-agent.lazy.d.ts +2 -0
- package/node_modules/@earendil-works/pi-ai/dist/api/devin-agent.lazy.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/api/devin-agent.lazy.js +6 -1
- package/node_modules/@earendil-works/pi-ai/dist/api/devin-agent.lazy.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/api/openai-codex-responses.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/api/openai-codex-responses.js +55 -17
- package/node_modules/@earendil-works/pi-ai/dist/api/openai-codex-responses.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/api/openai-responses-shared.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/api/openai-responses-shared.js +2 -1
- package/node_modules/@earendil-works/pi-ai/dist/api/openai-responses-shared.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/api/openai-responses.d.ts +2 -1
- package/node_modules/@earendil-works/pi-ai/dist/api/openai-responses.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/api/openai-responses.js +9 -0
- package/node_modules/@earendil-works/pi-ai/dist/api/openai-responses.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/api/responses-completion-grace.d.ts +30 -0
- package/node_modules/@earendil-works/pi-ai/dist/api/responses-completion-grace.d.ts.map +1 -0
- package/node_modules/@earendil-works/pi-ai/dist/api/responses-completion-grace.js +94 -0
- package/node_modules/@earendil-works/pi-ai/dist/api/responses-completion-grace.js.map +1 -0
- package/node_modules/@earendil-works/pi-ai/dist/api/websocket-liveness.d.ts +48 -0
- package/node_modules/@earendil-works/pi-ai/dist/api/websocket-liveness.d.ts.map +1 -0
- package/node_modules/@earendil-works/pi-ai/dist/api/websocket-liveness.js +104 -0
- package/node_modules/@earendil-works/pi-ai/dist/api/websocket-liveness.js.map +1 -0
- package/node_modules/@earendil-works/pi-ai/dist/devin-provider.d.ts +6 -0
- package/node_modules/@earendil-works/pi-ai/dist/devin-provider.d.ts.map +1 -0
- package/node_modules/@earendil-works/pi-ai/dist/devin-provider.js +4 -0
- package/node_modules/@earendil-works/pi-ai/dist/devin-provider.js.map +1 -0
- package/node_modules/@earendil-works/pi-ai/dist/providers/data/.manifest.json +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/data/nvidia.json +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/data/openrouter.json +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/data/together.json +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/data/vercel-ai-gateway.json +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/utils/retry.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/utils/retry.js +7 -3
- package/node_modules/@earendil-works/pi-ai/dist/utils/retry.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/package.json +10 -2
- package/node_modules/@earendil-works/pi-pty/package.json +1 -1
- package/node_modules/@earendil-works/pi-telemetry/package.json +1 -1
- package/node_modules/@earendil-works/pi-tui/README.md +11 -3
- package/node_modules/@earendil-works/pi-tui/dist/index.d.ts +2 -1
- package/node_modules/@earendil-works/pi-tui/dist/index.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-tui/dist/index.js +1 -0
- package/node_modules/@earendil-works/pi-tui/dist/index.js.map +1 -1
- package/node_modules/@earendil-works/pi-tui/dist/mouse-input.d.ts +37 -0
- package/node_modules/@earendil-works/pi-tui/dist/mouse-input.d.ts.map +1 -0
- package/node_modules/@earendil-works/pi-tui/dist/mouse-input.js +97 -0
- package/node_modules/@earendil-works/pi-tui/dist/mouse-input.js.map +1 -0
- package/node_modules/@earendil-works/pi-tui/dist/stdin-buffer.d.ts +2 -0
- package/node_modules/@earendil-works/pi-tui/dist/stdin-buffer.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-tui/dist/stdin-buffer.js +38 -0
- package/node_modules/@earendil-works/pi-tui/dist/stdin-buffer.js.map +1 -1
- package/node_modules/@earendil-works/pi-tui/dist/terminal.d.ts +25 -1
- package/node_modules/@earendil-works/pi-tui/dist/terminal.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-tui/dist/terminal.js +110 -4
- package/node_modules/@earendil-works/pi-tui/dist/terminal.js.map +1 -1
- package/node_modules/@earendil-works/pi-tui/dist/tui-alt-screen.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-tui/dist/tui-alt-screen.js +5 -50
- package/node_modules/@earendil-works/pi-tui/dist/tui-alt-screen.js.map +1 -1
- package/node_modules/@earendil-works/pi-tui/dist/tui-main-screen.d.ts +12 -0
- package/node_modules/@earendil-works/pi-tui/dist/tui-main-screen.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-tui/dist/tui-main-screen.js +129 -3
- package/node_modules/@earendil-works/pi-tui/dist/tui-main-screen.js.map +1 -1
- package/node_modules/@earendil-works/pi-tui/dist/tui.d.ts +28 -0
- package/node_modules/@earendil-works/pi-tui/dist/tui.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-tui/dist/tui.js +160 -0
- package/node_modules/@earendil-works/pi-tui/dist/tui.js.map +1 -1
- package/node_modules/@earendil-works/pi-tui/package.json +1 -1
- package/package.json +13 -9
- package/dist/bun/register-cursor-agent.d.ts +0 -2
- package/dist/bun/register-cursor-agent.d.ts.map +0 -1
- package/dist/bun/register-cursor-agent.js +0 -4
- package/dist/bun/register-cursor-agent.js.map +0 -1
|
@@ -24,6 +24,7 @@ export declare const ASK_USER_MIN_TIMEOUT_MINUTES = 1;
|
|
|
24
24
|
export declare const ASK_USER_MAX_TIMEOUT_MINUTES = 120;
|
|
25
25
|
export interface AskUserSettings {
|
|
26
26
|
enabled?: boolean;
|
|
27
|
+
bell?: boolean;
|
|
27
28
|
timeoutMinutes?: number;
|
|
28
29
|
}
|
|
29
30
|
export interface ThinkingBudgetsSettings {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"settings-shapes.d.ts","sourceRoot":"","sources":["../../src/core/settings-shapes.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,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WAAW,CAAC;AAEjE,MAAM,WAAW,gBAAgB;IAChC,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,OAAO,CAAC,EAAE,oBAAoB,CAAC;CAC/B;AAED,MAAM,WAAW,cAAc;IAC9B,WAAW,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,UAAU,CAAC;CAC3C"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"settings-shapes.js","sourceRoot":"","sources":["../../src/core/settings-shapes.ts"],"names":[],"mappings":"AAyBA,MAAM,CAAC,MAAM,gCAAgC,GAAG,EAAE,CAAC;AACnD,MAAM,CAAC,MAAM,4BAA4B,GAAG,CAAC,CAAC;AAC9C,MAAM,CAAC,MAAM,4BAA4B,GAAG,GAAG,CAAC","sourcesContent":["export interface PromptCacheKeepAliveSettings {\n\tenabled?: boolean; // default: false\n\tmaxRequestsPerSession?: number; // default: 3\n\tmaxCostUsdPerSession?: number; // default: 0.05\n\tmarginSeconds?: number; // default: 60\n}\n\nexport interface PromptCacheSettings {\n\tcacheAwareTimeouts?: boolean; // default: true (size foreground tool waits by the model's prompt-cache TTL)\n\tsafetyBufferSeconds?: number; // default: 30 (headroom subtracted from the cache TTL)\n\tgoalBackstopMaxSeconds?: number; // default: 270 (Goal monitor re-check backstop while wake sources are live; 5m TTL - 30s buffer)\n\tkeepAlive?: PromptCacheKeepAliveSettings;\n}\n\nexport interface ImageSettings {\n\tautoResize?: boolean; // default: true (resize images to 2000x2000 max for better model compatibility)\n\tblockImages?: boolean; // default: false - when true, prevents all images from being sent to LLM providers\n\tmaxHistoricalImages?: number; // default: undefined (preserve existing transport behavior)\n}\n\nexport interface LookAtSettings {\n\tenabled?: boolean; // default: true\n\tmodels?: string[]; // default: undefined (use the default look-at chain)\n}\n\nexport const ASK_USER_DEFAULT_TIMEOUT_MINUTES = 30;\nexport const ASK_USER_MIN_TIMEOUT_MINUTES = 1;\nexport const ASK_USER_MAX_TIMEOUT_MINUTES = 120;\n\nexport interface AskUserSettings {\n\tenabled?: boolean; // default: true\n\ttimeoutMinutes?: number; // default: 30, clamped to 1-120 when read\n}\n\nexport interface ThinkingBudgetsSettings {\n\tminimal?: number;\n\tlow?: number;\n\tmedium?: number;\n\thigh?: number;\n}\n\nexport type MermaidRenderingMode = \"off\" | \"final\" | \"streaming\";\n\nexport interface MarkdownSettings {\n\tcodeBlockIndent?: string; // default: \" \"\n\tmermaid?: MermaidRenderingMode; // default: \"streaming\"\n}\n\nexport interface OpenAISettings {\n\tserviceTier?: \"auto\" | \"flex\" | \"priority\";\n}\n"]}
|
|
1
|
+
{"version":3,"file":"settings-shapes.js","sourceRoot":"","sources":["../../src/core/settings-shapes.ts"],"names":[],"mappings":"AAyBA,MAAM,CAAC,MAAM,gCAAgC,GAAG,EAAE,CAAC;AACnD,MAAM,CAAC,MAAM,4BAA4B,GAAG,CAAC,CAAC;AAC9C,MAAM,CAAC,MAAM,4BAA4B,GAAG,GAAG,CAAC","sourcesContent":["export interface PromptCacheKeepAliveSettings {\n\tenabled?: boolean; // default: false\n\tmaxRequestsPerSession?: number; // default: 3\n\tmaxCostUsdPerSession?: number; // default: 0.05\n\tmarginSeconds?: number; // default: 60\n}\n\nexport interface PromptCacheSettings {\n\tcacheAwareTimeouts?: boolean; // default: true (size foreground tool waits by the model's prompt-cache TTL)\n\tsafetyBufferSeconds?: number; // default: 30 (headroom subtracted from the cache TTL)\n\tgoalBackstopMaxSeconds?: number; // default: 270 (Goal monitor re-check backstop while wake sources are live; 5m TTL - 30s buffer)\n\tkeepAlive?: PromptCacheKeepAliveSettings;\n}\n\nexport interface ImageSettings {\n\tautoResize?: boolean; // default: true (resize images to 2000x2000 max for better model compatibility)\n\tblockImages?: boolean; // default: false - when true, prevents all images from being sent to LLM providers\n\tmaxHistoricalImages?: number; // default: undefined (preserve existing transport behavior)\n}\n\nexport interface LookAtSettings {\n\tenabled?: boolean; // default: true\n\tmodels?: string[]; // default: undefined (use the default look-at chain)\n}\n\nexport const ASK_USER_DEFAULT_TIMEOUT_MINUTES = 30;\nexport const ASK_USER_MIN_TIMEOUT_MINUTES = 1;\nexport const ASK_USER_MAX_TIMEOUT_MINUTES = 120;\n\nexport interface AskUserSettings {\n\tenabled?: boolean; // default: true\n\tbell?: boolean; // default: true; ring once for a newly displayed question\n\ttimeoutMinutes?: number; // default: 30, clamped to 1-120 when read\n}\n\nexport interface ThinkingBudgetsSettings {\n\tminimal?: number;\n\tlow?: number;\n\tmedium?: number;\n\thigh?: number;\n}\n\nexport type MermaidRenderingMode = \"off\" | \"final\" | \"streaming\";\n\nexport interface MarkdownSettings {\n\tcodeBlockIndent?: string; // default: \" \"\n\tmermaid?: MermaidRenderingMode; // default: \"streaming\"\n}\n\nexport interface OpenAISettings {\n\tserviceTier?: \"auto\" | \"flex\" | \"priority\";\n}\n"]}
|
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
import type { PathMetadata } from "./package-manager.ts";
|
|
2
|
-
|
|
2
|
+
/**
|
|
3
|
+
* Where a resource comes from. `system` marks resources the harness itself provides: builtin and bundled
|
|
4
|
+
* extensions, command-line packages whose manifest declares `pi.system`, and what those contribute.
|
|
5
|
+
*/
|
|
6
|
+
export type SourceScope = "user" | "project" | "temporary" | "system";
|
|
3
7
|
export type SourceOrigin = "package" | "top-level";
|
|
4
8
|
export interface SourceInfo {
|
|
5
9
|
path: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"source-info.d.ts","sourceRoot":"","sources":["../../src/core/source-info.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAEzD,MAAM,MAAM,WAAW,GAAG,MAAM,GAAG,SAAS,GAAG,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"source-info.d.ts","sourceRoot":"","sources":["../../src/core/source-info.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAEzD;;;GAGG;AACH,MAAM,MAAM,WAAW,GAAG,MAAM,GAAG,SAAS,GAAG,WAAW,GAAG,QAAQ,CAAC;AACtE,MAAM,MAAM,YAAY,GAAG,SAAS,GAAG,WAAW,CAAC;AAEnD,MAAM,WAAW,UAAU;IAC1B,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,WAAW,CAAC;IACnB,MAAM,EAAE,YAAY,CAAC;IACrB,OAAO,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,YAAY,GAAG,UAAU,CAQjF;AAED,wBAAgB,yBAAyB,CACxC,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE;IACR,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,WAAW,CAAC;IACpB,MAAM,CAAC,EAAE,YAAY,CAAC;IACtB,OAAO,CAAC,EAAE,MAAM,CAAC;CACjB,GACC,UAAU,CAQZ"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"source-info.js","sourceRoot":"","sources":["../../src/core/source-info.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"source-info.js","sourceRoot":"","sources":["../../src/core/source-info.ts"],"names":[],"mappings":"AAiBA,MAAM,UAAU,gBAAgB,CAAC,IAAY,EAAE,QAAsB;IACpE,OAAO;QACN,IAAI;QACJ,MAAM,EAAE,QAAQ,CAAC,MAAM;QACvB,KAAK,EAAE,QAAQ,CAAC,KAAK;QACrB,MAAM,EAAE,QAAQ,CAAC,MAAM;QACvB,OAAO,EAAE,QAAQ,CAAC,OAAO;KACzB,CAAC;AACH,CAAC;AAED,MAAM,UAAU,yBAAyB,CACxC,IAAY,EACZ,OAKC;IAED,OAAO;QACN,IAAI;QACJ,MAAM,EAAE,OAAO,CAAC,MAAM;QACtB,KAAK,EAAE,OAAO,CAAC,KAAK,IAAI,WAAW;QACnC,MAAM,EAAE,OAAO,CAAC,MAAM,IAAI,WAAW;QACrC,OAAO,EAAE,OAAO,CAAC,OAAO;KACxB,CAAC;AACH,CAAC","sourcesContent":["import type { PathMetadata } from \"./package-manager.ts\";\n\n/**\n * Where a resource comes from. `system` marks resources the harness itself provides: builtin and bundled\n * extensions, command-line packages whose manifest declares `pi.system`, and what those contribute.\n */\nexport type SourceScope = \"user\" | \"project\" | \"temporary\" | \"system\";\nexport type SourceOrigin = \"package\" | \"top-level\";\n\nexport interface SourceInfo {\n\tpath: string;\n\tsource: string;\n\tscope: SourceScope;\n\torigin: SourceOrigin;\n\tbaseDir?: string;\n}\n\nexport function createSourceInfo(path: string, metadata: PathMetadata): SourceInfo {\n\treturn {\n\t\tpath,\n\t\tsource: metadata.source,\n\t\tscope: metadata.scope,\n\t\torigin: metadata.origin,\n\t\tbaseDir: metadata.baseDir,\n\t};\n}\n\nexport function createSyntheticSourceInfo(\n\tpath: string,\n\toptions: {\n\t\tsource: string;\n\t\tscope?: SourceScope;\n\t\torigin?: SourceOrigin;\n\t\tbaseDir?: string;\n\t},\n): SourceInfo {\n\treturn {\n\t\tpath,\n\t\tsource: options.source,\n\t\tscope: options.scope ?? \"temporary\",\n\t\torigin: options.origin ?? \"top-level\",\n\t\tbaseDir: options.baseDir,\n\t};\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bash.d.ts","sourceRoot":"","sources":["../../../src/core/tools/bash.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,+BAA+B,CAAC;AAE/D,OAAO,EAAE,KAAK,MAAM,EAAE,IAAI,EAAE,MAAM,SAAS,CAAC;AAE5C,OAAO,EAIN,KAAK,WAAW,EAGhB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,KAAK,EAAoB,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAI/E,OAAO,EAAoD,KAAK,gBAAgB,EAAE,MAAM,eAAe,CAAC;AAkBxG,QAAA,MAAM,UAAU;;;EAGd,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eAAe,GAAG,SAAS,EAAE,eAAe,CAAC,CAEjF;AAED,wBAAgB,cAAc,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,eAAe,GAAG,SAAS,CAAC,OAAO,UAAU,CAAC,CAQnG"}
|
package/dist/core/tools/bash.js
CHANGED
|
@@ -161,12 +161,17 @@ function resolveSpawnContext(command, cwd, spawnHook, exposeSessionEnvironment,
|
|
|
161
161
|
const env = { ...getShellEnv() };
|
|
162
162
|
delete env.PI_SESSION_ID;
|
|
163
163
|
delete env.PI_SESSION_FILE;
|
|
164
|
+
delete env.PI_SESSION_CWD;
|
|
165
|
+
delete env.PI_GOAL_STORE_FILE;
|
|
164
166
|
delete env.PI_PROVIDER;
|
|
165
167
|
delete env.PI_MODEL;
|
|
166
168
|
delete env.PI_REASONING_LEVEL;
|
|
167
169
|
if (exposeSessionEnvironment && ctx) {
|
|
168
170
|
const model = ctx.model;
|
|
169
171
|
env.PI_SESSION_ID = ctx.sessionManager.getSessionId();
|
|
172
|
+
env.PI_SESSION_CWD = ctx.cwd;
|
|
173
|
+
if (ctx.goalStoreFile)
|
|
174
|
+
env.PI_GOAL_STORE_FILE = ctx.goalStoreFile;
|
|
170
175
|
const sessionFile = ctx.sessionManager.getSessionFile();
|
|
171
176
|
if (sessionFile)
|
|
172
177
|
env.PI_SESSION_FILE = sessionFile;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bash.js","sourceRoot":"","sources":["../../../src/core/tools/bash.ts"],"names":[],"mappings":"AAAA,kHAAkH;AAClH,OAAO,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AACpC,OAAO,EAAE,MAAM,IAAI,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAEtD,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AACtC,OAAO,EAAe,IAAI,EAAE,MAAM,SAAS,CAAC;AAC5C,OAAO,EAAE,mBAAmB,EAAE,MAAM,8BAA8B,CAAC;AACnE,OAA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AC,UAAU;IAC7D,cAAc,EAAE,SAAS;CACzB,CAAC;AAEF,MAAM,UAAU,wBAAwB,CACvC,GAAW,EACX,OAAyB;IAEzB,OAAO,yBAAyB,CAAC,GAAG,EAAE,cAAc,EAAE,OAAO,CAAC,CAAC;AAChE,CAAC;AAED,MAAM,UAAU,cAAc,CAAC,GAAW,EAAE,OAAyB;IACpE,MAAM,UAAU,GAAG,wBAAwB,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;IAC1D,MAAM,IAAI,GAAG,kBAAkB,CAAC,UAAU,CAAC,CAAC;IAC5C,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE;QACnB,aAAa,EAAE,UAAU,CAAC,aAAa;QACvC,gBAAgB,EAAE,UAAU,CAAC,gBAAgB;KAC7C,CAAC,CAAC;IACH,OAAO,IAAI,CAAC;AACb,CAAC","sourcesContent":["// allow: SIZE_OK - pre-existing cohesive shell integration; this patch only hardens its output-finalization seam.\nimport { constants } from \"node:fs\";\nimport { access as fsAccess } from \"node:fs/promises\";\nimport type { AgentTool } from \"@earendil-works/pi-agent-core\";\nimport { spawn } from \"child_process\";\nimport { type Static, Type } from \"typebox\";\nimport { waitForChildProcess } from \"../../utils/child-process.ts\";\nimport {\n\tgetShellConfig,\n\tgetShellEnv,\n\tkillProcessTree,\n\ttype ShellConfig,\n\ttrackDetachedChildPid,\n\tuntrackDetachedChildPid,\n} from \"../../utils/shell.ts\";\nimport type { ExtensionContext, ToolDefinition } from \"../extensions/types.ts\";\nimport { OutputAccumulator } from \"./output-accumulator.ts\";\nimport { BASH_UPDATE_THROTTLE_MS, createShellRenderers } from \"./renderers/bash.ts\";\nimport { wrapToolDefinition } from \"./tool-definition-wrapper.ts\";\nimport { DEFAULT_MAX_BYTES, DEFAULT_MAX_LINES, formatSize, type TruncationResult } from \"./truncate.ts\";\n\nconst MAX_TIMEOUT_MS = 2_147_483_647;\nconst MAX_TIMEOUT_SECONDS = MAX_TIMEOUT_MS / 1000;\n\nfunction resolveTimeoutMs(timeout: number | undefined): number | undefined {\n\tif (timeout === undefined) return undefined;\n\tif (!Number.isFinite(timeout) || timeout <= 0) {\n\t\tthrow new Error(\"Invalid timeout: must be a finite number of seconds\");\n\t}\n\n\tconst timeoutMs = timeout * 1000;\n\tif (timeoutMs > MAX_TIMEOUT_MS) {\n\t\tthrow new Error(`Invalid timeout: maximum is ${MAX_TIMEOUT_SECONDS} seconds`);\n\t}\n\treturn timeoutMs;\n}\n\nconst bashSchema = Type.Object({\n\tcommand: Type.String({ description: \"Shell command to execute\" }),\n\ttimeout: Type.Optional(Type.Number({ description: \"Timeout in seconds (optional, no default timeout)\" })),\n});\n\nexport const bashToolSystemPromptContribution = {\n\tsnippet: \"Execute bash commands (ls, rg, find, etc.)\",\n\tguidelines: [\"You can inspect PI_* environment variables for current model and session details.\"],\n} as const;\n\nexport type BashToolInput = Static<typeof bashSchema>;\n\nexport interface BashToolDetails {\n\ttruncation?: TruncationResult;\n\tfullOutputPath?: string;\n}\n\n/**\n * Pluggable operations for the bash tool.\n * Override these to delegate command execution to remote systems (for example SSH).\n */\nexport interface BashOperations {\n\t/**\n\t * Execute a command and stream output.\n\t * @param command The command to execute\n\t * @param cwd Working directory\n\t * @param options Execution options\n\t * @returns Promise resolving to exit code (null if killed)\n\t */\n\texec: (\n\t\tcommand: string,\n\t\tcwd: string,\n\t\toptions: {\n\t\t\tonData: (data: Buffer) => void;\n\t\t\tsignal?: AbortSignal;\n\t\t\ttimeout?: number;\n\t\t\tenv?: NodeJS.ProcessEnv;\n\t\t},\n\t) => Promise<{ exitCode: number | null }>;\n}\n\n/** Shared process execution used by the built-in shell tools. */\nexport function createLocalShellOperations(shellName: string, resolveShellConfig: () => ShellConfig): BashOperations {\n\treturn {\n\t\texec: async (command, cwd, { onData, signal, timeout, env }) => {\n\t\t\tconst timeoutMs = resolveTimeoutMs(timeout);\n\t\t\tif (signal?.aborted) {\n\t\t\t\tthrow new Error(\"aborted\");\n\t\t\t}\n\t\t\tconst shellConfig = resolveShellConfig();\n\t\t\ttry {\n\t\t\t\tawait fsAccess(cwd, constants.F_OK);\n\t\t\t} catch {\n\t\t\t\tthrow new Error(`Working directory does not exist: ${cwd}\\nCannot execute ${shellName} commands.`);\n\t\t\t}\n\n\t\t\tconst commandFromStdin = shellConfig.commandTransport === \"stdin\";\n\t\t\tconst child = spawn(shellConfig.shell, commandFromStdin ? shellConfig.args : [...shellConfig.args, command], {\n\t\t\t\tcwd,\n\t\t\t\tdetached: process.platform !== \"win32\",\n\t\t\t\tenv: env ?? getShellEnv(),\n\t\t\t\tstdio: [commandFromStdin ? \"pipe\" : \"ignore\", \"pipe\", \"pipe\"],\n\t\t\t\twindowsHide: true,\n\t\t\t});\n\t\t\tif (commandFromStdin) {\n\t\t\t\tchild.stdin?.on(\"error\", () => {});\n\t\t\t\tchild.stdin?.end(command);\n\t\t\t}\n\t\t\tif (child.pid) trackDetachedChildPid(child.pid);\n\t\t\tlet timedOut = false;\n\t\t\tlet timeoutHandle: NodeJS.Timeout | undefined;\n\t\t\tlet streamCallbackError: unknown;\n\t\t\tlet hasStreamCallbackError = false;\n\t\t\t// Fires once the process tree has been killed so waitForChildProcess\n\t\t\t// stops preserving output tails; descendants that survive the group\n\t\t\t// kill must not keep the aborted command running forever.\n\t\t\tconst killedController = new AbortController();\n\t\t\tconst onAbort = () => {\n\t\t\t\tif (child.pid) killProcessTree(child.pid);\n\t\t\t\tkilledController.abort();\n\t\t\t};\n\n\t\t\ttry {\n\t\t\t\tconst handleData = (data: Buffer) => {\n\t\t\t\t\tif (hasStreamCallbackError) return;\n\t\t\t\t\ttry {\n\t\t\t\t\t\tconst callbackResult = (onData as (data: Buffer) => unknown)(data);\n\t\t\t\t\t\tif (callbackResult && typeof (callbackResult as { then?: unknown }).then === \"function\") {\n\t\t\t\t\t\t\tvoid Promise.resolve(callbackResult).catch((error) => {\n\t\t\t\t\t\t\t\tif (!hasStreamCallbackError) {\n\t\t\t\t\t\t\t\t\tstreamCallbackError = error;\n\t\t\t\t\t\t\t\t\thasStreamCallbackError = true;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tonAbort();\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t}\n\t\t\t\t\t} catch (error) {\n\t\t\t\t\t\tstreamCallbackError = error;\n\t\t\t\t\t\thasStreamCallbackError = true;\n\t\t\t\t\t\tonAbort();\n\t\t\t\t\t}\n\t\t\t\t};\n\t\t\t\t// Set timeout if provided.\n\t\t\t\tif (timeoutMs !== undefined) {\n\t\t\t\t\ttimeoutHandle = setTimeout(() => {\n\t\t\t\t\t\ttimedOut = true;\n\t\t\t\t\t\tonAbort();\n\t\t\t\t\t}, timeoutMs);\n\t\t\t\t}\n\t\t\t\t// Stream stdout and stderr.\n\t\t\t\tchild.stdout?.on(\"data\", handleData);\n\t\t\t\tchild.stderr?.on(\"data\", handleData);\n\t\t\t\t// Handle abort signal by killing the entire process tree.\n\t\t\t\tif (signal) {\n\t\t\t\t\tif (signal.aborted) onAbort();\n\t\t\t\t\telse signal.addEventListener(\"abort\", onAbort, { once: true });\n\t\t\t\t}\n\t\t\t\t// Handle shell spawn errors and wait for the process to terminate without hanging\n\t\t\t\t// on inherited stdio handles held by detached descendants.\n\t\t\t\tconst exitCode = await waitForChildProcess(child, { signal: killedController.signal });\n\t\t\t\tif (hasStreamCallbackError) {\n\t\t\t\t\tthrow streamCallbackError;\n\t\t\t\t}\n\t\t\t\tif (signal?.aborted) {\n\t\t\t\t\tthrow new Error(\"aborted\");\n\t\t\t\t}\n\t\t\t\tif (timedOut) {\n\t\t\t\t\tthrow new Error(`timeout:${timeout}`);\n\t\t\t\t}\n\t\t\t\treturn { exitCode };\n\t\t\t} finally {\n\t\t\t\tconst pid = child.pid;\n\t\t\t\tif (pid !== undefined) {\n\t\t\t\t\tif (child.exitCode !== null || child.signalCode !== null) {\n\t\t\t\t\t\tuntrackDetachedChildPid(pid);\n\t\t\t\t\t} else {\n\t\t\t\t\t\t// The kill grace released the wait while the child is still\n\t\t\t\t\t\t// alive (kill pending): keep it tracked so shutdown cleanup\n\t\t\t\t\t\t// retries, and unref it so it cannot pin the event loop.\n\t\t\t\t\t\tchild.unref();\n\t\t\t\t\t\tchild.once(\"exit\", () => untrackDetachedChildPid(pid));\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif (timeoutHandle) clearTimeout(timeoutHandle);\n\t\t\t\tif (signal) signal.removeEventListener(\"abort\", onAbort);\n\t\t\t}\n\t\t},\n\t};\n}\n\n/**\n * Create bash operations using pi's built-in local shell execution backend.\n *\n * This is useful for extensions that intercept user_bash and still want pi's\n * standard local shell behavior while wrapping or rewriting commands.\n */\nexport function createLocalBashOperations(options?: { shellPath?: string }): BashOperations {\n\treturn createLocalShellOperations(\"bash\", () => getShellConfig(options?.shellPath));\n}\n\nexport interface BashSpawnContext {\n\tcommand: string;\n\tcwd: string;\n\tenv: NodeJS.ProcessEnv;\n}\n\nexport type BashSpawnHook = (context: BashSpawnContext) => BashSpawnContext;\n\nfunction resolveSpawnContext(\n\tcommand: string,\n\tcwd: string,\n\tspawnHook: BashSpawnHook | undefined,\n\texposeSessionEnvironment: boolean,\n\tctx: ExtensionContext | undefined,\n): BashSpawnContext {\n\tconst env = { ...getShellEnv() };\n\tdelete env.PI_SESSION_ID;\n\tdelete env.PI_SESSION_FILE;\n\tdelete env.PI_PROVIDER;\n\tdelete env.PI_MODEL;\n\tdelete env.PI_REASONING_LEVEL;\n\tif (exposeSessionEnvironment && ctx) {\n\t\tconst model = ctx.model;\n\t\tenv.PI_SESSION_ID = ctx.sessionManager.getSessionId();\n\t\tconst sessionFile = ctx.sessionManager.getSessionFile();\n\t\tif (sessionFile) env.PI_SESSION_FILE = sessionFile;\n\t\tif (model) {\n\t\t\tenv.PI_PROVIDER = model.provider;\n\t\t\tenv.PI_MODEL = model.id;\n\t\t}\n\t\tif (ctx.thinkingLevel) env.PI_REASONING_LEVEL = ctx.thinkingLevel;\n\t}\n\tconst baseContext: BashSpawnContext = { command, cwd, env };\n\treturn spawnHook ? spawnHook(baseContext) : baseContext;\n}\n\nexport interface BashToolOptions {\n\t/** Custom operations for command execution. Default: local shell */\n\toperations?: BashOperations;\n\t/** Command prefix prepended to every command (for example shell setup commands) */\n\tcommandPrefix?: string;\n\t/** Optional explicit shell path from settings */\n\tshellPath?: string;\n\t/** Expose current Pi session metadata as PI_* environment variables. Default: true */\n\texposeSessionEnvironment?: boolean;\n\t/** Hook to adjust command, cwd, or env before execution */\n\tspawnHook?: BashSpawnHook;\n}\n\nexport type BashRenderState = {\n\tstartedAt: number | undefined;\n\tendedAt: number | undefined;\n\tinterval: NodeJS.Timeout | undefined;\n};\n\nexport interface ShellToolConfig {\n\tname: string;\n\tlabel: string;\n\tshellName: string;\n\tprompt: string;\n\tpromptSnippet: string;\n\tpromptGuidelines?: readonly string[];\n\ttempFilePrefix: string;\n}\n\nexport function createShellToolDefinition(\n\tcwd: string,\n\tconfig: ShellToolConfig,\n\toptions?: BashToolOptions,\n): ToolDefinition<typeof bashSchema, BashToolDetails | undefined, BashRenderState> {\n\tconst ops = options?.operations ?? createLocalBashOperations({ shellPath: options?.shellPath });\n\tconst commandPrefix = options?.commandPrefix;\n\tconst exposeSessionEnvironment = options?.exposeSessionEnvironment ?? true;\n\tconst spawnHook = options?.spawnHook;\n\treturn {\n\t\tname: config.name,\n\t\tlabel: config.label,\n\t\tdescription: `Execute a ${config.shellName} command in the current working directory. Returns stdout and stderr. Output is truncated to last ${DEFAULT_MAX_LINES} lines or ${DEFAULT_MAX_BYTES / 1024}KB (whichever is hit first). If truncated, full output is saved to a temp file. Optionally provide a timeout in seconds.`,\n\t\tpromptSnippet: config.promptSnippet,\n\t\tpromptGuidelines: exposeSessionEnvironment && config.promptGuidelines ? [...config.promptGuidelines] : undefined,\n\t\tparameters: bashSchema,\n\t\tconstrainedSampling: { type: \"json_schema\", strict: \"prefer\" },\n\t\tasync execute(\n\t\t\t_toolCallId,\n\t\t\t{ command, timeout }: { command: string; timeout?: number },\n\t\t\tsignal?: AbortSignal,\n\t\t\tonUpdate?,\n\t\t\tctx?: ExtensionContext,\n\t\t) {\n\t\t\tconst resolvedCommand = commandPrefix ? `${commandPrefix}\\n${command}` : command;\n\t\t\tconst spawnContext = resolveSpawnContext(\n\t\t\t\tresolvedCommand,\n\t\t\t\tctx?.cwd || cwd,\n\t\t\t\tspawnHook,\n\t\t\t\texposeSessionEnvironment,\n\t\t\t\tctx,\n\t\t\t);\n\t\t\tconst output = new OutputAccumulator({ tempFilePrefix: config.tempFilePrefix });\n\t\t\tlet acceptingOutput = true;\n\t\t\tlet updateTimer: NodeJS.Timeout | undefined;\n\t\t\tlet updateDirty = false;\n\t\t\tlet lastUpdateAt = 0;\n\t\t\tlet outputUpdateError: unknown;\n\t\t\tlet hasOutputUpdateError = false;\n\n\t\t\tconst emitOutputUpdate = () => {\n\t\t\t\tif (!onUpdate || !updateDirty || hasOutputUpdateError) return;\n\t\t\t\tupdateDirty = false;\n\t\t\t\tlastUpdateAt = Date.now();\n\t\t\t\tconst snapshot = output.snapshot({ persistIfTruncated: true });\n\t\t\t\ttry {\n\t\t\t\t\tonUpdate({\n\t\t\t\t\t\tcontent: [{ type: \"text\", text: snapshot.content || \"\" }],\n\t\t\t\t\t\tdetails: {\n\t\t\t\t\t\t\ttruncation: snapshot.truncation.truncated ? snapshot.truncation : undefined,\n\t\t\t\t\t\t\tfullOutputPath: snapshot.fullOutputPath,\n\t\t\t\t\t\t},\n\t\t\t\t\t});\n\t\t\t\t} catch (error) {\n\t\t\t\t\toutputUpdateError = error;\n\t\t\t\t\thasOutputUpdateError = true;\n\t\t\t\t}\n\t\t\t};\n\n\t\t\tconst clearUpdateTimer = () => {\n\t\t\t\tif (updateTimer) {\n\t\t\t\t\tclearTimeout(updateTimer);\n\t\t\t\t\tupdateTimer = undefined;\n\t\t\t\t}\n\t\t\t};\n\n\t\t\tconst scheduleOutputUpdate = () => {\n\t\t\t\tif (!onUpdate) return;\n\t\t\t\tupdateDirty = true;\n\t\t\t\tconst delay = BASH_UPDATE_THROTTLE_MS - (Date.now() - lastUpdateAt);\n\t\t\t\tif (delay <= 0) {\n\t\t\t\t\tclearUpdateTimer();\n\t\t\t\t\temitOutputUpdate();\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tupdateTimer ??= setTimeout(() => {\n\t\t\t\t\tupdateTimer = undefined;\n\t\t\t\t\temitOutputUpdate();\n\t\t\t\t}, delay);\n\t\t\t};\n\n\t\t\tif (onUpdate) {\n\t\t\t\tonUpdate({ content: [], details: undefined });\n\t\t\t}\n\n\t\t\tconst handleData = (data: Buffer) => {\n\t\t\t\tif (!acceptingOutput) return;\n\t\t\t\toutput.append(data);\n\t\t\t\tscheduleOutputUpdate();\n\t\t\t};\n\n\t\t\tconst finishOutput = async () => {\n\t\t\t\tacceptingOutput = false;\n\t\t\t\tclearUpdateTimer();\n\t\t\t\tlet primaryError: unknown;\n\t\t\t\tlet hasPrimaryError = false;\n\t\t\t\tlet snapshot: Awaited<ReturnType<OutputAccumulator[\"snapshot\"]>> | undefined;\n\t\t\t\ttry {\n\t\t\t\t\toutput.finish();\n\t\t\t\t\temitOutputUpdate();\n\t\t\t\t\tsnapshot = output.snapshot({ persistIfTruncated: true });\n\t\t\t\t\tif (hasOutputUpdateError) {\n\t\t\t\t\t\tprimaryError = outputUpdateError;\n\t\t\t\t\t\thasPrimaryError = true;\n\t\t\t\t\t}\n\t\t\t\t} catch (error) {\n\t\t\t\t\tprimaryError = error;\n\t\t\t\t\thasPrimaryError = true;\n\t\t\t\t}\n\t\t\t\ttry {\n\t\t\t\t\tawait output.closeTempFile();\n\t\t\t\t} catch (closeError) {\n\t\t\t\t\tif (hasPrimaryError) {\n\t\t\t\t\t\tthrow new AggregateError(\n\t\t\t\t\t\t\t[primaryError, closeError],\n\t\t\t\t\t\t\t\"Bash output finalization and spill cleanup failed\",\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t\tthrow closeError;\n\t\t\t\t}\n\t\t\t\tif (hasPrimaryError) {\n\t\t\t\t\ttry {\n\t\t\t\t\t\tawait output.removeTempFile();\n\t\t\t\t\t} catch (unlinkError) {\n\t\t\t\t\t\tif (!(unlinkError instanceof Error)) throw unlinkError;\n\t\t\t\t\t\tthrow new AggregateError(\n\t\t\t\t\t\t\t[primaryError, unlinkError],\n\t\t\t\t\t\t\t\"Bash output finalization and spill cleanup failed\",\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t\tthrow primaryError;\n\t\t\t\t}\n\t\t\t\tif (snapshot === undefined) {\n\t\t\t\t\tthrow new Error(\"Bash output finalization produced no snapshot\");\n\t\t\t\t}\n\t\t\t\treturn snapshot;\n\t\t\t};\n\n\t\t\tconst formatOutput = (snapshot: Awaited<ReturnType<typeof finishOutput>>, emptyText = \"(no output)\") => {\n\t\t\t\tconst truncation = snapshot.truncation;\n\t\t\t\tlet text = snapshot.content || emptyText;\n\t\t\t\tlet details: BashToolDetails | undefined;\n\t\t\t\tif (truncation.truncated) {\n\t\t\t\t\tdetails = { truncation, fullOutputPath: snapshot.fullOutputPath };\n\t\t\t\t\tconst startLine = truncation.totalLines - truncation.outputLines + 1;\n\t\t\t\t\tconst endLine = truncation.totalLines;\n\t\t\t\t\tif (truncation.lastLinePartial) {\n\t\t\t\t\t\tconst lastLineSize = formatSize(output.getLastLineBytes());\n\t\t\t\t\t\ttext += `\\n\\n[Showing last ${formatSize(truncation.outputBytes)} of line ${endLine} (line is ${lastLineSize}). Full output: ${snapshot.fullOutputPath}]`;\n\t\t\t\t\t} else if (truncation.truncatedBy === \"lines\") {\n\t\t\t\t\t\ttext += `\\n\\n[Showing lines ${startLine}-${endLine} of ${truncation.totalLines}. Full output: ${snapshot.fullOutputPath}]`;\n\t\t\t\t\t} else {\n\t\t\t\t\t\ttext += `\\n\\n[Showing lines ${startLine}-${endLine} of ${truncation.totalLines} (${formatSize(DEFAULT_MAX_BYTES)} limit). Full output: ${snapshot.fullOutputPath}]`;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\treturn { text, details };\n\t\t\t};\n\n\t\t\tconst appendStatus = (text: string, status: string) => `${text ? `${text}\\n\\n` : \"\"}${status}`;\n\n\t\t\ttry {\n\t\t\t\tlet exitCode: number | null;\n\t\t\t\ttry {\n\t\t\t\t\tconst result = await ops.exec(spawnContext.command, spawnContext.cwd, {\n\t\t\t\t\t\tonData: handleData,\n\t\t\t\t\t\tsignal,\n\t\t\t\t\t\ttimeout,\n\t\t\t\t\t\tenv: spawnContext.env,\n\t\t\t\t\t});\n\t\t\t\t\texitCode = result.exitCode;\n\t\t\t\t} catch (err) {\n\t\t\t\t\tlet snapshot: Awaited<ReturnType<typeof finishOutput>>;\n\t\t\t\t\ttry {\n\t\t\t\t\t\tsnapshot = await finishOutput();\n\t\t\t\t\t} catch (cleanupError) {\n\t\t\t\t\t\tthrow new AggregateError([err, cleanupError], \"Bash command and output cleanup failed\");\n\t\t\t\t\t}\n\t\t\t\t\tconst { text } = formatOutput(snapshot, \"\");\n\t\t\t\t\tif (err instanceof Error && err.message === \"aborted\") {\n\t\t\t\t\t\tthrow new Error(appendStatus(text, \"Command aborted\"));\n\t\t\t\t\t}\n\t\t\t\t\tif (err instanceof Error && err.message.startsWith(\"timeout:\")) {\n\t\t\t\t\t\tconst timeoutSecs = err.message.split(\":\")[1];\n\t\t\t\t\t\tthrow new Error(appendStatus(text, `Command timed out after ${timeoutSecs} seconds`));\n\t\t\t\t\t}\n\t\t\t\t\ttry {\n\t\t\t\t\t\tawait output.removeTempFile();\n\t\t\t\t\t} catch (unlinkError) {\n\t\t\t\t\t\tthrow new AggregateError([err, unlinkError], \"Bash command and output cleanup failed\");\n\t\t\t\t\t}\n\t\t\t\t\tthrow err;\n\t\t\t\t}\n\n\t\t\t\tconst snapshot = await finishOutput();\n\t\t\t\tconst { text: outputText, details } = formatOutput(snapshot);\n\t\t\t\tif (exitCode !== 0 && exitCode !== null) {\n\t\t\t\t\tthrow new Error(appendStatus(outputText, `Command exited with code ${exitCode}`));\n\t\t\t\t}\n\t\t\t\treturn { content: [{ type: \"text\", text: outputText }], details };\n\t\t\t} finally {\n\t\t\t\tclearUpdateTimer();\n\t\t\t}\n\t\t},\n\t\t...createShellRenderers(config.prompt),\n\t};\n}\n\nconst bashToolConfig: ShellToolConfig = {\n\tname: \"bash\",\n\tlabel: \"bash\",\n\tshellName: \"bash\",\n\tprompt: \"$\",\n\tpromptSnippet: bashToolSystemPromptContribution.snippet,\n\tpromptGuidelines: bashToolSystemPromptContribution.guidelines,\n\ttempFilePrefix: \"pi-bash\",\n};\n\nexport function createBashToolDefinition(\n\tcwd: string,\n\toptions?: BashToolOptions,\n): ToolDefinition<typeof bashSchema, BashToolDetails | undefined, BashRenderState> {\n\treturn createShellToolDefinition(cwd, bashToolConfig, options);\n}\n\nexport function createBashTool(cwd: string, options?: BashToolOptions): AgentTool<typeof bashSchema> {\n\tconst definition = createBashToolDefinition(cwd, options);\n\tconst tool = wrapToolDefinition(definition);\n\tObject.assign(tool, {\n\t\tpromptSnippet: definition.promptSnippet,\n\t\tpromptGuidelines: definition.promptGuidelines,\n\t});\n\treturn tool;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"bash.js","sourceRoot":"","sources":["../../../src/core/tools/bash.ts"],"names":[],"mappings":"AAAA,kHAAkH;AAClH,OAAO,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AACpC,OAAO,EAAE,MAAM,IAAI,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAEtD,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AACtC,OAAO,EAAe,IAAI,EAAE,MAAM,SAAS,CAAC;AAC5C,OAAO,EAAE,mBAAmB,EAAE,MAAM,8BAA8B,CAAC;AACnE,OAAO,EACN,cAAc,EACd,WAAW,EACX,eAAe,EAEf,qBAAqB,EACrB,uBAAuB,GACvB,MAAM,sBAAsB,CAAC;AAE9B,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAC5D,OAAO,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Aa,EAAE,gCAAgC,CAAC,OAAO;IACvD,gBAAgB,EAAE,gCAAgC,CAAC,UAAU;IAC7D,cAAc,EAAE,SAAS;CACzB,CAAC;AAEF,MAAM,UAAU,wBAAwB,CACvC,GAAW,EACX,OAAyB;IAEzB,OAAO,yBAAyB,CAAC,GAAG,EAAE,cAAc,EAAE,OAAO,CAAC,CAAC;AAChE,CAAC;AAED,MAAM,UAAU,cAAc,CAAC,GAAW,EAAE,OAAyB;IACpE,MAAM,UAAU,GAAG,wBAAwB,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;IAC1D,MAAM,IAAI,GAAG,kBAAkB,CAAC,UAAU,CAAC,CAAC;IAC5C,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE;QACnB,aAAa,EAAE,UAAU,CAAC,aAAa;QACvC,gBAAgB,EAAE,UAAU,CAAC,gBAAgB;KAC7C,CAAC,CAAC;IACH,OAAO,IAAI,CAAC;AACb,CAAC","sourcesContent":["// allow: SIZE_OK - pre-existing cohesive shell integration; this patch only hardens its output-finalization seam.\nimport { constants } from \"node:fs\";\nimport { access as fsAccess } from \"node:fs/promises\";\nimport type { AgentTool } from \"@earendil-works/pi-agent-core\";\nimport { spawn } from \"child_process\";\nimport { type Static, Type } from \"typebox\";\nimport { waitForChildProcess } from \"../../utils/child-process.ts\";\nimport {\n\tgetShellConfig,\n\tgetShellEnv,\n\tkillProcessTree,\n\ttype ShellConfig,\n\ttrackDetachedChildPid,\n\tuntrackDetachedChildPid,\n} from \"../../utils/shell.ts\";\nimport type { ExtensionContext, ToolDefinition } from \"../extensions/types.ts\";\nimport { OutputAccumulator } from \"./output-accumulator.ts\";\nimport { BASH_UPDATE_THROTTLE_MS, createShellRenderers } from \"./renderers/bash.ts\";\nimport { wrapToolDefinition } from \"./tool-definition-wrapper.ts\";\nimport { DEFAULT_MAX_BYTES, DEFAULT_MAX_LINES, formatSize, type TruncationResult } from \"./truncate.ts\";\n\nconst MAX_TIMEOUT_MS = 2_147_483_647;\nconst MAX_TIMEOUT_SECONDS = MAX_TIMEOUT_MS / 1000;\n\nfunction resolveTimeoutMs(timeout: number | undefined): number | undefined {\n\tif (timeout === undefined) return undefined;\n\tif (!Number.isFinite(timeout) || timeout <= 0) {\n\t\tthrow new Error(\"Invalid timeout: must be a finite number of seconds\");\n\t}\n\n\tconst timeoutMs = timeout * 1000;\n\tif (timeoutMs > MAX_TIMEOUT_MS) {\n\t\tthrow new Error(`Invalid timeout: maximum is ${MAX_TIMEOUT_SECONDS} seconds`);\n\t}\n\treturn timeoutMs;\n}\n\nconst bashSchema = Type.Object({\n\tcommand: Type.String({ description: \"Shell command to execute\" }),\n\ttimeout: Type.Optional(Type.Number({ description: \"Timeout in seconds (optional, no default timeout)\" })),\n});\n\nexport const bashToolSystemPromptContribution = {\n\tsnippet: \"Execute bash commands (ls, rg, find, etc.)\",\n\tguidelines: [\"You can inspect PI_* environment variables for current model and session details.\"],\n} as const;\n\nexport type BashToolInput = Static<typeof bashSchema>;\n\nexport interface BashToolDetails {\n\ttruncation?: TruncationResult;\n\tfullOutputPath?: string;\n}\n\n/**\n * Pluggable operations for the bash tool.\n * Override these to delegate command execution to remote systems (for example SSH).\n */\nexport interface BashOperations {\n\t/**\n\t * Execute a command and stream output.\n\t * @param command The command to execute\n\t * @param cwd Working directory\n\t * @param options Execution options\n\t * @returns Promise resolving to exit code (null if killed)\n\t */\n\texec: (\n\t\tcommand: string,\n\t\tcwd: string,\n\t\toptions: {\n\t\t\tonData: (data: Buffer) => void;\n\t\t\tsignal?: AbortSignal;\n\t\t\ttimeout?: number;\n\t\t\tenv?: NodeJS.ProcessEnv;\n\t\t},\n\t) => Promise<{ exitCode: number | null }>;\n}\n\n/** Shared process execution used by the built-in shell tools. */\nexport function createLocalShellOperations(shellName: string, resolveShellConfig: () => ShellConfig): BashOperations {\n\treturn {\n\t\texec: async (command, cwd, { onData, signal, timeout, env }) => {\n\t\t\tconst timeoutMs = resolveTimeoutMs(timeout);\n\t\t\tif (signal?.aborted) {\n\t\t\t\tthrow new Error(\"aborted\");\n\t\t\t}\n\t\t\tconst shellConfig = resolveShellConfig();\n\t\t\ttry {\n\t\t\t\tawait fsAccess(cwd, constants.F_OK);\n\t\t\t} catch {\n\t\t\t\tthrow new Error(`Working directory does not exist: ${cwd}\\nCannot execute ${shellName} commands.`);\n\t\t\t}\n\n\t\t\tconst commandFromStdin = shellConfig.commandTransport === \"stdin\";\n\t\t\tconst child = spawn(shellConfig.shell, commandFromStdin ? shellConfig.args : [...shellConfig.args, command], {\n\t\t\t\tcwd,\n\t\t\t\tdetached: process.platform !== \"win32\",\n\t\t\t\tenv: env ?? getShellEnv(),\n\t\t\t\tstdio: [commandFromStdin ? \"pipe\" : \"ignore\", \"pipe\", \"pipe\"],\n\t\t\t\twindowsHide: true,\n\t\t\t});\n\t\t\tif (commandFromStdin) {\n\t\t\t\tchild.stdin?.on(\"error\", () => {});\n\t\t\t\tchild.stdin?.end(command);\n\t\t\t}\n\t\t\tif (child.pid) trackDetachedChildPid(child.pid);\n\t\t\tlet timedOut = false;\n\t\t\tlet timeoutHandle: NodeJS.Timeout | undefined;\n\t\t\tlet streamCallbackError: unknown;\n\t\t\tlet hasStreamCallbackError = false;\n\t\t\t// Fires once the process tree has been killed so waitForChildProcess\n\t\t\t// stops preserving output tails; descendants that survive the group\n\t\t\t// kill must not keep the aborted command running forever.\n\t\t\tconst killedController = new AbortController();\n\t\t\tconst onAbort = () => {\n\t\t\t\tif (child.pid) killProcessTree(child.pid);\n\t\t\t\tkilledController.abort();\n\t\t\t};\n\n\t\t\ttry {\n\t\t\t\tconst handleData = (data: Buffer) => {\n\t\t\t\t\tif (hasStreamCallbackError) return;\n\t\t\t\t\ttry {\n\t\t\t\t\t\tconst callbackResult = (onData as (data: Buffer) => unknown)(data);\n\t\t\t\t\t\tif (callbackResult && typeof (callbackResult as { then?: unknown }).then === \"function\") {\n\t\t\t\t\t\t\tvoid Promise.resolve(callbackResult).catch((error) => {\n\t\t\t\t\t\t\t\tif (!hasStreamCallbackError) {\n\t\t\t\t\t\t\t\t\tstreamCallbackError = error;\n\t\t\t\t\t\t\t\t\thasStreamCallbackError = true;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tonAbort();\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t}\n\t\t\t\t\t} catch (error) {\n\t\t\t\t\t\tstreamCallbackError = error;\n\t\t\t\t\t\thasStreamCallbackError = true;\n\t\t\t\t\t\tonAbort();\n\t\t\t\t\t}\n\t\t\t\t};\n\t\t\t\t// Set timeout if provided.\n\t\t\t\tif (timeoutMs !== undefined) {\n\t\t\t\t\ttimeoutHandle = setTimeout(() => {\n\t\t\t\t\t\ttimedOut = true;\n\t\t\t\t\t\tonAbort();\n\t\t\t\t\t}, timeoutMs);\n\t\t\t\t}\n\t\t\t\t// Stream stdout and stderr.\n\t\t\t\tchild.stdout?.on(\"data\", handleData);\n\t\t\t\tchild.stderr?.on(\"data\", handleData);\n\t\t\t\t// Handle abort signal by killing the entire process tree.\n\t\t\t\tif (signal) {\n\t\t\t\t\tif (signal.aborted) onAbort();\n\t\t\t\t\telse signal.addEventListener(\"abort\", onAbort, { once: true });\n\t\t\t\t}\n\t\t\t\t// Handle shell spawn errors and wait for the process to terminate without hanging\n\t\t\t\t// on inherited stdio handles held by detached descendants.\n\t\t\t\tconst exitCode = await waitForChildProcess(child, { signal: killedController.signal });\n\t\t\t\tif (hasStreamCallbackError) {\n\t\t\t\t\tthrow streamCallbackError;\n\t\t\t\t}\n\t\t\t\tif (signal?.aborted) {\n\t\t\t\t\tthrow new Error(\"aborted\");\n\t\t\t\t}\n\t\t\t\tif (timedOut) {\n\t\t\t\t\tthrow new Error(`timeout:${timeout}`);\n\t\t\t\t}\n\t\t\t\treturn { exitCode };\n\t\t\t} finally {\n\t\t\t\tconst pid = child.pid;\n\t\t\t\tif (pid !== undefined) {\n\t\t\t\t\tif (child.exitCode !== null || child.signalCode !== null) {\n\t\t\t\t\t\tuntrackDetachedChildPid(pid);\n\t\t\t\t\t} else {\n\t\t\t\t\t\t// The kill grace released the wait while the child is still\n\t\t\t\t\t\t// alive (kill pending): keep it tracked so shutdown cleanup\n\t\t\t\t\t\t// retries, and unref it so it cannot pin the event loop.\n\t\t\t\t\t\tchild.unref();\n\t\t\t\t\t\tchild.once(\"exit\", () => untrackDetachedChildPid(pid));\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif (timeoutHandle) clearTimeout(timeoutHandle);\n\t\t\t\tif (signal) signal.removeEventListener(\"abort\", onAbort);\n\t\t\t}\n\t\t},\n\t};\n}\n\n/**\n * Create bash operations using pi's built-in local shell execution backend.\n *\n * This is useful for extensions that intercept user_bash and still want pi's\n * standard local shell behavior while wrapping or rewriting commands.\n */\nexport function createLocalBashOperations(options?: { shellPath?: string }): BashOperations {\n\treturn createLocalShellOperations(\"bash\", () => getShellConfig(options?.shellPath));\n}\n\nexport interface BashSpawnContext {\n\tcommand: string;\n\tcwd: string;\n\tenv: NodeJS.ProcessEnv;\n}\n\nexport type BashSpawnHook = (context: BashSpawnContext) => BashSpawnContext;\n\nfunction resolveSpawnContext(\n\tcommand: string,\n\tcwd: string,\n\tspawnHook: BashSpawnHook | undefined,\n\texposeSessionEnvironment: boolean,\n\tctx: ExtensionContext | undefined,\n): BashSpawnContext {\n\tconst env = { ...getShellEnv() };\n\tdelete env.PI_SESSION_ID;\n\tdelete env.PI_SESSION_FILE;\n\tdelete env.PI_SESSION_CWD;\n\tdelete env.PI_GOAL_STORE_FILE;\n\tdelete env.PI_PROVIDER;\n\tdelete env.PI_MODEL;\n\tdelete env.PI_REASONING_LEVEL;\n\tif (exposeSessionEnvironment && ctx) {\n\t\tconst model = ctx.model;\n\t\tenv.PI_SESSION_ID = ctx.sessionManager.getSessionId();\n\t\tenv.PI_SESSION_CWD = ctx.cwd;\n\t\tif (ctx.goalStoreFile) env.PI_GOAL_STORE_FILE = ctx.goalStoreFile;\n\t\tconst sessionFile = ctx.sessionManager.getSessionFile();\n\t\tif (sessionFile) env.PI_SESSION_FILE = sessionFile;\n\t\tif (model) {\n\t\t\tenv.PI_PROVIDER = model.provider;\n\t\t\tenv.PI_MODEL = model.id;\n\t\t}\n\t\tif (ctx.thinkingLevel) env.PI_REASONING_LEVEL = ctx.thinkingLevel;\n\t}\n\tconst baseContext: BashSpawnContext = { command, cwd, env };\n\treturn spawnHook ? spawnHook(baseContext) : baseContext;\n}\n\nexport interface BashToolOptions {\n\t/** Custom operations for command execution. Default: local shell */\n\toperations?: BashOperations;\n\t/** Command prefix prepended to every command (for example shell setup commands) */\n\tcommandPrefix?: string;\n\t/** Optional explicit shell path from settings */\n\tshellPath?: string;\n\t/** Expose current Pi session metadata as PI_* environment variables. Default: true */\n\texposeSessionEnvironment?: boolean;\n\t/** Hook to adjust command, cwd, or env before execution */\n\tspawnHook?: BashSpawnHook;\n}\n\nexport type BashRenderState = {\n\tstartedAt: number | undefined;\n\tendedAt: number | undefined;\n\tinterval: NodeJS.Timeout | undefined;\n};\n\nexport interface ShellToolConfig {\n\tname: string;\n\tlabel: string;\n\tshellName: string;\n\tprompt: string;\n\tpromptSnippet: string;\n\tpromptGuidelines?: readonly string[];\n\ttempFilePrefix: string;\n}\n\nexport function createShellToolDefinition(\n\tcwd: string,\n\tconfig: ShellToolConfig,\n\toptions?: BashToolOptions,\n): ToolDefinition<typeof bashSchema, BashToolDetails | undefined, BashRenderState> {\n\tconst ops = options?.operations ?? createLocalBashOperations({ shellPath: options?.shellPath });\n\tconst commandPrefix = options?.commandPrefix;\n\tconst exposeSessionEnvironment = options?.exposeSessionEnvironment ?? true;\n\tconst spawnHook = options?.spawnHook;\n\treturn {\n\t\tname: config.name,\n\t\tlabel: config.label,\n\t\tdescription: `Execute a ${config.shellName} command in the current working directory. Returns stdout and stderr. Output is truncated to last ${DEFAULT_MAX_LINES} lines or ${DEFAULT_MAX_BYTES / 1024}KB (whichever is hit first). If truncated, full output is saved to a temp file. Optionally provide a timeout in seconds.`,\n\t\tpromptSnippet: config.promptSnippet,\n\t\tpromptGuidelines: exposeSessionEnvironment && config.promptGuidelines ? [...config.promptGuidelines] : undefined,\n\t\tparameters: bashSchema,\n\t\tconstrainedSampling: { type: \"json_schema\", strict: \"prefer\" },\n\t\tasync execute(\n\t\t\t_toolCallId,\n\t\t\t{ command, timeout }: { command: string; timeout?: number },\n\t\t\tsignal?: AbortSignal,\n\t\t\tonUpdate?,\n\t\t\tctx?: ExtensionContext,\n\t\t) {\n\t\t\tconst resolvedCommand = commandPrefix ? `${commandPrefix}\\n${command}` : command;\n\t\t\tconst spawnContext = resolveSpawnContext(\n\t\t\t\tresolvedCommand,\n\t\t\t\tctx?.cwd || cwd,\n\t\t\t\tspawnHook,\n\t\t\t\texposeSessionEnvironment,\n\t\t\t\tctx,\n\t\t\t);\n\t\t\tconst output = new OutputAccumulator({ tempFilePrefix: config.tempFilePrefix });\n\t\t\tlet acceptingOutput = true;\n\t\t\tlet updateTimer: NodeJS.Timeout | undefined;\n\t\t\tlet updateDirty = false;\n\t\t\tlet lastUpdateAt = 0;\n\t\t\tlet outputUpdateError: unknown;\n\t\t\tlet hasOutputUpdateError = false;\n\n\t\t\tconst emitOutputUpdate = () => {\n\t\t\t\tif (!onUpdate || !updateDirty || hasOutputUpdateError) return;\n\t\t\t\tupdateDirty = false;\n\t\t\t\tlastUpdateAt = Date.now();\n\t\t\t\tconst snapshot = output.snapshot({ persistIfTruncated: true });\n\t\t\t\ttry {\n\t\t\t\t\tonUpdate({\n\t\t\t\t\t\tcontent: [{ type: \"text\", text: snapshot.content || \"\" }],\n\t\t\t\t\t\tdetails: {\n\t\t\t\t\t\t\ttruncation: snapshot.truncation.truncated ? snapshot.truncation : undefined,\n\t\t\t\t\t\t\tfullOutputPath: snapshot.fullOutputPath,\n\t\t\t\t\t\t},\n\t\t\t\t\t});\n\t\t\t\t} catch (error) {\n\t\t\t\t\toutputUpdateError = error;\n\t\t\t\t\thasOutputUpdateError = true;\n\t\t\t\t}\n\t\t\t};\n\n\t\t\tconst clearUpdateTimer = () => {\n\t\t\t\tif (updateTimer) {\n\t\t\t\t\tclearTimeout(updateTimer);\n\t\t\t\t\tupdateTimer = undefined;\n\t\t\t\t}\n\t\t\t};\n\n\t\t\tconst scheduleOutputUpdate = () => {\n\t\t\t\tif (!onUpdate) return;\n\t\t\t\tupdateDirty = true;\n\t\t\t\tconst delay = BASH_UPDATE_THROTTLE_MS - (Date.now() - lastUpdateAt);\n\t\t\t\tif (delay <= 0) {\n\t\t\t\t\tclearUpdateTimer();\n\t\t\t\t\temitOutputUpdate();\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tupdateTimer ??= setTimeout(() => {\n\t\t\t\t\tupdateTimer = undefined;\n\t\t\t\t\temitOutputUpdate();\n\t\t\t\t}, delay);\n\t\t\t};\n\n\t\t\tif (onUpdate) {\n\t\t\t\tonUpdate({ content: [], details: undefined });\n\t\t\t}\n\n\t\t\tconst handleData = (data: Buffer) => {\n\t\t\t\tif (!acceptingOutput) return;\n\t\t\t\toutput.append(data);\n\t\t\t\tscheduleOutputUpdate();\n\t\t\t};\n\n\t\t\tconst finishOutput = async () => {\n\t\t\t\tacceptingOutput = false;\n\t\t\t\tclearUpdateTimer();\n\t\t\t\tlet primaryError: unknown;\n\t\t\t\tlet hasPrimaryError = false;\n\t\t\t\tlet snapshot: Awaited<ReturnType<OutputAccumulator[\"snapshot\"]>> | undefined;\n\t\t\t\ttry {\n\t\t\t\t\toutput.finish();\n\t\t\t\t\temitOutputUpdate();\n\t\t\t\t\tsnapshot = output.snapshot({ persistIfTruncated: true });\n\t\t\t\t\tif (hasOutputUpdateError) {\n\t\t\t\t\t\tprimaryError = outputUpdateError;\n\t\t\t\t\t\thasPrimaryError = true;\n\t\t\t\t\t}\n\t\t\t\t} catch (error) {\n\t\t\t\t\tprimaryError = error;\n\t\t\t\t\thasPrimaryError = true;\n\t\t\t\t}\n\t\t\t\ttry {\n\t\t\t\t\tawait output.closeTempFile();\n\t\t\t\t} catch (closeError) {\n\t\t\t\t\tif (hasPrimaryError) {\n\t\t\t\t\t\tthrow new AggregateError(\n\t\t\t\t\t\t\t[primaryError, closeError],\n\t\t\t\t\t\t\t\"Bash output finalization and spill cleanup failed\",\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t\tthrow closeError;\n\t\t\t\t}\n\t\t\t\tif (hasPrimaryError) {\n\t\t\t\t\ttry {\n\t\t\t\t\t\tawait output.removeTempFile();\n\t\t\t\t\t} catch (unlinkError) {\n\t\t\t\t\t\tif (!(unlinkError instanceof Error)) throw unlinkError;\n\t\t\t\t\t\tthrow new AggregateError(\n\t\t\t\t\t\t\t[primaryError, unlinkError],\n\t\t\t\t\t\t\t\"Bash output finalization and spill cleanup failed\",\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t\tthrow primaryError;\n\t\t\t\t}\n\t\t\t\tif (snapshot === undefined) {\n\t\t\t\t\tthrow new Error(\"Bash output finalization produced no snapshot\");\n\t\t\t\t}\n\t\t\t\treturn snapshot;\n\t\t\t};\n\n\t\t\tconst formatOutput = (snapshot: Awaited<ReturnType<typeof finishOutput>>, emptyText = \"(no output)\") => {\n\t\t\t\tconst truncation = snapshot.truncation;\n\t\t\t\tlet text = snapshot.content || emptyText;\n\t\t\t\tlet details: BashToolDetails | undefined;\n\t\t\t\tif (truncation.truncated) {\n\t\t\t\t\tdetails = { truncation, fullOutputPath: snapshot.fullOutputPath };\n\t\t\t\t\tconst startLine = truncation.totalLines - truncation.outputLines + 1;\n\t\t\t\t\tconst endLine = truncation.totalLines;\n\t\t\t\t\tif (truncation.lastLinePartial) {\n\t\t\t\t\t\tconst lastLineSize = formatSize(output.getLastLineBytes());\n\t\t\t\t\t\ttext += `\\n\\n[Showing last ${formatSize(truncation.outputBytes)} of line ${endLine} (line is ${lastLineSize}). Full output: ${snapshot.fullOutputPath}]`;\n\t\t\t\t\t} else if (truncation.truncatedBy === \"lines\") {\n\t\t\t\t\t\ttext += `\\n\\n[Showing lines ${startLine}-${endLine} of ${truncation.totalLines}. Full output: ${snapshot.fullOutputPath}]`;\n\t\t\t\t\t} else {\n\t\t\t\t\t\ttext += `\\n\\n[Showing lines ${startLine}-${endLine} of ${truncation.totalLines} (${formatSize(DEFAULT_MAX_BYTES)} limit). Full output: ${snapshot.fullOutputPath}]`;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\treturn { text, details };\n\t\t\t};\n\n\t\t\tconst appendStatus = (text: string, status: string) => `${text ? `${text}\\n\\n` : \"\"}${status}`;\n\n\t\t\ttry {\n\t\t\t\tlet exitCode: number | null;\n\t\t\t\ttry {\n\t\t\t\t\tconst result = await ops.exec(spawnContext.command, spawnContext.cwd, {\n\t\t\t\t\t\tonData: handleData,\n\t\t\t\t\t\tsignal,\n\t\t\t\t\t\ttimeout,\n\t\t\t\t\t\tenv: spawnContext.env,\n\t\t\t\t\t});\n\t\t\t\t\texitCode = result.exitCode;\n\t\t\t\t} catch (err) {\n\t\t\t\t\tlet snapshot: Awaited<ReturnType<typeof finishOutput>>;\n\t\t\t\t\ttry {\n\t\t\t\t\t\tsnapshot = await finishOutput();\n\t\t\t\t\t} catch (cleanupError) {\n\t\t\t\t\t\tthrow new AggregateError([err, cleanupError], \"Bash command and output cleanup failed\");\n\t\t\t\t\t}\n\t\t\t\t\tconst { text } = formatOutput(snapshot, \"\");\n\t\t\t\t\tif (err instanceof Error && err.message === \"aborted\") {\n\t\t\t\t\t\tthrow new Error(appendStatus(text, \"Command aborted\"));\n\t\t\t\t\t}\n\t\t\t\t\tif (err instanceof Error && err.message.startsWith(\"timeout:\")) {\n\t\t\t\t\t\tconst timeoutSecs = err.message.split(\":\")[1];\n\t\t\t\t\t\tthrow new Error(appendStatus(text, `Command timed out after ${timeoutSecs} seconds`));\n\t\t\t\t\t}\n\t\t\t\t\ttry {\n\t\t\t\t\t\tawait output.removeTempFile();\n\t\t\t\t\t} catch (unlinkError) {\n\t\t\t\t\t\tthrow new AggregateError([err, unlinkError], \"Bash command and output cleanup failed\");\n\t\t\t\t\t}\n\t\t\t\t\tthrow err;\n\t\t\t\t}\n\n\t\t\t\tconst snapshot = await finishOutput();\n\t\t\t\tconst { text: outputText, details } = formatOutput(snapshot);\n\t\t\t\tif (exitCode !== 0 && exitCode !== null) {\n\t\t\t\t\tthrow new Error(appendStatus(outputText, `Command exited with code ${exitCode}`));\n\t\t\t\t}\n\t\t\t\treturn { content: [{ type: \"text\", text: outputText }], details };\n\t\t\t} finally {\n\t\t\t\tclearUpdateTimer();\n\t\t\t}\n\t\t},\n\t\t...createShellRenderers(config.prompt),\n\t};\n}\n\nconst bashToolConfig: ShellToolConfig = {\n\tname: \"bash\",\n\tlabel: \"bash\",\n\tshellName: \"bash\",\n\tprompt: \"$\",\n\tpromptSnippet: bashToolSystemPromptContribution.snippet,\n\tpromptGuidelines: bashToolSystemPromptContribution.guidelines,\n\ttempFilePrefix: \"pi-bash\",\n};\n\nexport function createBashToolDefinition(\n\tcwd: string,\n\toptions?: BashToolOptions,\n): ToolDefinition<typeof bashSchema, BashToolDetails | undefined, BashRenderState> {\n\treturn createShellToolDefinition(cwd, bashToolConfig, options);\n}\n\nexport function createBashTool(cwd: string, options?: BashToolOptions): AgentTool<typeof bashSchema> {\n\tconst definition = createBashToolDefinition(cwd, options);\n\tconst tool = wrapToolDefinition(definition);\n\tObject.assign(tool, {\n\t\tpromptSnippet: definition.promptSnippet,\n\t\tpromptGuidelines: definition.promptGuidelines,\n\t});\n\treturn tool;\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"skills.d.ts","sourceRoot":"","sources":["../../../../src/modes/app-server/server/skills.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,8BAA8B,CAAC;AACvE,OAAO,EAAc,KAAK,KAAK,EAAE,MAAM,yBAAyB,CAAC;AAEjE,OAAO,KAAK,EAEX,UAAU,EAIV,MAAM,sBAAsB,CAAC;AAE9B,OAAO,KAAK,EAAE,cAA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Y;IAChC,MAAM,IAAI,KAAK,CAAC,0BAA0B,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;AAC5D,CAAC","sourcesContent":["import { existsSync, statSync } from \"node:fs\";\nimport { resolve } from \"node:path\";\nimport { getAgentDir } from \"../../../config.ts\";\nimport type { ResourceDiagnostic } from \"../../../core/diagnostics.ts\";\nimport { loadSkills, type Skill } from \"../../../core/skills.ts\";\nimport { resolvePath } from \"../../../utils/paths.ts\";\nimport type {\n\tSkillMetadata,\n\tSkillScope,\n\tSkillsListEntry,\n\tSkillsListParams,\n\tSkillsListResponse,\n} from \"../protocol/index.ts\";\nimport { invalidParamsError, RpcHandlerError } from \"../rpc/errors.ts\";\nimport type { MethodRegistry } from \"../rpc/registry.ts\";\nimport type { ThreadRegistry } from \"../threads/registry.ts\";\n\nexport interface RegisterAppServerSkillMethodsOptions {\n\treadonly agentDir?: string;\n\treadonly serverCwd?: string;\n\treadonly threads?: Pick<ThreadRegistry, \"listLoaded\" | \"getLoadedThread\">;\n\treadonly resourceLoaderFactory?: (cwd: string) => Promise<SkillResourceLoader> | SkillResourceLoader;\n}\n\nexport function registerAppServerSkillMethods(\n\tregistry: MethodRegistry,\n\toptions: RegisterAppServerSkillMethodsOptions = {},\n): void {\n\tconst serverCwd = resolvePath(options.serverCwd ?? process.cwd());\n\tconst agentDir = options.agentDir ?? getAgentDir();\n\tconst cachedLoaders = new Map<string, Promise<SkillResourceLoader>>();\n\n\tregistry.register(\"skills/list\", {\n\t\tscope: \"global\",\n\t\thandler: async ({ request }) => {\n\t\t\tconst params = parseSkillsListParams(request.params);\n\t\t\tconst requestedCwds = params.cwds && params.cwds.length > 0 ? params.cwds : [serverCwd];\n\t\t\tconst entries = await Promise.all(\n\t\t\t\trequestedCwds.map((cwd) => {\n\t\t\t\t\tconst resolvedCwd = resolvePath(cwd, serverCwd, { trim: true });\n\t\t\t\t\treturn buildSkillsListEntry(resolvedCwd, params.forceReload === true, {\n\t\t\t\t\t\tagentDir,\n\t\t\t\t\t\tthreads: options.threads,\n\t\t\t\t\t\tresourceLoaderFactory: options.resourceLoaderFactory,\n\t\t\t\t\t\tcachedLoaders,\n\t\t\t\t\t});\n\t\t\t\t}),\n\t\t\t);\n\t\t\treturn { data: entries } satisfies SkillsListResponse;\n\t\t},\n\t});\n}\n\ntype SkillsListEntryOptions = {\n\treadonly agentDir: string;\n\treadonly threads: Pick<ThreadRegistry, \"listLoaded\" | \"getLoadedThread\"> | undefined;\n\treadonly resourceLoaderFactory: ((cwd: string) => Promise<SkillResourceLoader> | SkillResourceLoader) | undefined;\n\treadonly cachedLoaders: Map<string, Promise<SkillResourceLoader>>;\n};\n\ninterface SkillResourceLoader {\n\tgetSkills(): { skills: Skill[]; diagnostics: ResourceDiagnostic[] };\n\treload(): Promise<void>;\n}\n\nasync function buildSkillsListEntry(\n\tcwd: string,\n\tforceReload: boolean,\n\toptions: SkillsListEntryOptions,\n): Promise<SkillsListEntry> {\n\tconst invalidEntry = validateSkillCwd(cwd);\n\tif (invalidEntry) return invalidEntry;\n\n\ttry {\n\t\tconst loader = await getCachedLoader(cwd, options);\n\t\tif (forceReload) await loader.reload();\n\t\tconst loaded = loader.getSkills();\n\t\treturn {\n\t\t\tcwd,\n\t\t\tskills: loaded.skills.map(toWireSkill),\n\t\t\terrors: loaded.diagnostics.map((diagnostic) => toWireSkillError(diagnostic, cwd)),\n\t\t};\n\t} catch (error) {\n\t\treturn { cwd, skills: [], errors: [{ path: cwd, message: errorMessage(error) }] };\n\t}\n}\n\nfunction validateSkillCwd(cwd: string): SkillsListEntry | undefined {\n\tif (!existsSync(cwd)) {\n\t\treturn { cwd, skills: [], errors: [{ path: cwd, message: \"skill cwd does not exist\" }] };\n\t}\n\ttry {\n\t\tif (!statSync(cwd).isDirectory()) {\n\t\t\treturn { cwd, skills: [], errors: [{ path: cwd, message: \"skill cwd is not a directory\" }] };\n\t\t}\n\t} catch (error) {\n\t\treturn { cwd, skills: [], errors: [{ path: cwd, message: errorMessage(error) }] };\n\t}\n\treturn undefined;\n}\n\nasync function getCachedLoader(cwd: string, options: SkillsListEntryOptions): Promise<SkillResourceLoader> {\n\tlet loaderPromise = options.cachedLoaders.get(cwd);\n\tif (!loaderPromise) {\n\t\tloaderPromise = Promise.resolve().then(\n\t\t\t() => findLoadedLoader(cwd, options.threads) ?? createLoader(cwd, options),\n\t\t);\n\t\toptions.cachedLoaders.set(cwd, loaderPromise);\n\t}\n\ttry {\n\t\treturn await loaderPromise;\n\t} catch (error) {\n\t\toptions.cachedLoaders.delete(cwd);\n\t\tthrow error;\n\t}\n}\n\nfunction findLoadedLoader(\n\tcwd: string,\n\tthreads: Pick<ThreadRegistry, \"listLoaded\" | \"getLoadedThread\"> | undefined,\n): SkillResourceLoader | undefined {\n\tif (!threads) return undefined;\n\tconst loaded = threads.listLoaded().find((thread) => resolve(thread.cwd) === cwd);\n\tif (!loaded) return undefined;\n\ttry {\n\t\treturn threads.getLoadedThread(loaded.id).session.resourceLoader;\n\t} catch {\n\t\treturn undefined;\n\t}\n}\n\nasync function createLoader(cwd: string, options: SkillsListEntryOptions): Promise<SkillResourceLoader> {\n\tif (options.resourceLoaderFactory) return options.resourceLoaderFactory(cwd);\n\tlet loaded = loadSkills({ cwd, agentDir: options.agentDir, skillPaths: [], includeDefaults: true });\n\treturn {\n\t\tgetSkills: () => loaded,\n\t\treload: async () => {\n\t\t\tloaded = loadSkills({ cwd, agentDir: options.agentDir, skillPaths: [], includeDefaults: true });\n\t\t},\n\t};\n}\n\nfunction toWireSkill(skill: Skill): SkillMetadata {\n\treturn {\n\t\tname: skill.name,\n\t\tdescription: skill.description,\n\t\tpath: skill.filePath,\n\t\tscope: mapSkillScope(skill.sourceInfo.scope),\n\t\tenabled: !skill.disableModelInvocation,\n\t};\n}\n\nexport function mapSkillScope(scope: Skill[\"sourceInfo\"][\"scope\"]): SkillScope {\n\tswitch (scope) {\n\t\tcase \"user\":\n\t\t\treturn \"user\";\n\t\tcase \"project\":\n\t\t\treturn \"repo\";\n\t\tcase \"temporary\":\n\t\t\treturn \"system\";\n\t\tdefault:\n\t\t\treturn assertNever(scope);\n\t}\n}\n\nfunction toWireSkillError(diagnostic: ResourceDiagnostic, cwd: string) {\n\treturn { path: diagnostic.path ?? cwd, message: diagnostic.message };\n}\n\nfunction parseSkillsListParams(value: unknown): SkillsListParams {\n\tif (value === undefined || value === null) return {};\n\tif (!isRecord(value)) throw new RpcHandlerError(invalidParamsError());\n\tconst cwds = value.cwds;\n\tif (cwds !== undefined && !isStringArray(cwds)) throw new RpcHandlerError(invalidParamsError());\n\tconst forceReload = value.forceReload;\n\tif (forceReload !== undefined && typeof forceReload !== \"boolean\") {\n\t\tthrow new RpcHandlerError(invalidParamsError());\n\t}\n\treturn { cwds, forceReload };\n}\n\nfunction isStringArray(value: unknown): value is readonly string[] {\n\treturn Array.isArray(value) && value.every((item) => typeof item === \"string\");\n}\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n\treturn typeof value === \"object\" && value !== null && !Array.isArray(value);\n}\n\nfunction errorMessage(error: unknown): string {\n\treturn error instanceof Error ? error.message : String(error);\n}\n\nfunction assertNever(value: never): never {\n\tthrow new Error(`Unhandled skill scope: ${String(value)}`);\n}\n"]}
|
|
1
|
+
{"version":3,"file":"skills.js","sourceRoot":"","sources":["../../../../src/modes/app-server/server/skills.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAC/C,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAEjD,OAAO,EAAE,UAAU,EAAc,MAAM,yBAAyB,CAAC;AACjE,OAAO,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAQtD,OAAO,EAAE,kBAAkB,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAWvE,MAAM,UAAU,6BAA6B,CAC5C,QAAwB,EACxB,OAAO,GAAyC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AO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;AAC/D,CAAC;AAED,SAAS,WAAW,CAAC,KAAY;IAChC,MAAM,IAAI,KAAK,CAAC,0BAA0B,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;AAC5D,CAAC","sourcesContent":["import { existsSync, statSync } from \"node:fs\";\nimport { resolve } from \"node:path\";\nimport { getAgentDir } from \"../../../config.ts\";\nimport type { ResourceDiagnostic } from \"../../../core/diagnostics.ts\";\nimport { loadSkills, type Skill } from \"../../../core/skills.ts\";\nimport { resolvePath } from \"../../../utils/paths.ts\";\nimport type {\n\tSkillMetadata,\n\tSkillScope,\n\tSkillsListEntry,\n\tSkillsListParams,\n\tSkillsListResponse,\n} from \"../protocol/index.ts\";\nimport { invalidParamsError, RpcHandlerError } from \"../rpc/errors.ts\";\nimport type { MethodRegistry } from \"../rpc/registry.ts\";\nimport type { ThreadRegistry } from \"../threads/registry.ts\";\n\nexport interface RegisterAppServerSkillMethodsOptions {\n\treadonly agentDir?: string;\n\treadonly serverCwd?: string;\n\treadonly threads?: Pick<ThreadRegistry, \"listLoaded\" | \"getLoadedThread\">;\n\treadonly resourceLoaderFactory?: (cwd: string) => Promise<SkillResourceLoader> | SkillResourceLoader;\n}\n\nexport function registerAppServerSkillMethods(\n\tregistry: MethodRegistry,\n\toptions: RegisterAppServerSkillMethodsOptions = {},\n): void {\n\tconst serverCwd = resolvePath(options.serverCwd ?? process.cwd());\n\tconst agentDir = options.agentDir ?? getAgentDir();\n\tconst cachedLoaders = new Map<string, Promise<SkillResourceLoader>>();\n\n\tregistry.register(\"skills/list\", {\n\t\tscope: \"global\",\n\t\thandler: async ({ request }) => {\n\t\t\tconst params = parseSkillsListParams(request.params);\n\t\t\tconst requestedCwds = params.cwds && params.cwds.length > 0 ? params.cwds : [serverCwd];\n\t\t\tconst entries = await Promise.all(\n\t\t\t\trequestedCwds.map((cwd) => {\n\t\t\t\t\tconst resolvedCwd = resolvePath(cwd, serverCwd, { trim: true });\n\t\t\t\t\treturn buildSkillsListEntry(resolvedCwd, params.forceReload === true, {\n\t\t\t\t\t\tagentDir,\n\t\t\t\t\t\tthreads: options.threads,\n\t\t\t\t\t\tresourceLoaderFactory: options.resourceLoaderFactory,\n\t\t\t\t\t\tcachedLoaders,\n\t\t\t\t\t});\n\t\t\t\t}),\n\t\t\t);\n\t\t\treturn { data: entries } satisfies SkillsListResponse;\n\t\t},\n\t});\n}\n\ntype SkillsListEntryOptions = {\n\treadonly agentDir: string;\n\treadonly threads: Pick<ThreadRegistry, \"listLoaded\" | \"getLoadedThread\"> | undefined;\n\treadonly resourceLoaderFactory: ((cwd: string) => Promise<SkillResourceLoader> | SkillResourceLoader) | undefined;\n\treadonly cachedLoaders: Map<string, Promise<SkillResourceLoader>>;\n};\n\ninterface SkillResourceLoader {\n\tgetSkills(): { skills: Skill[]; diagnostics: ResourceDiagnostic[] };\n\treload(): Promise<void>;\n}\n\nasync function buildSkillsListEntry(\n\tcwd: string,\n\tforceReload: boolean,\n\toptions: SkillsListEntryOptions,\n): Promise<SkillsListEntry> {\n\tconst invalidEntry = validateSkillCwd(cwd);\n\tif (invalidEntry) return invalidEntry;\n\n\ttry {\n\t\tconst loader = await getCachedLoader(cwd, options);\n\t\tif (forceReload) await loader.reload();\n\t\tconst loaded = loader.getSkills();\n\t\treturn {\n\t\t\tcwd,\n\t\t\tskills: loaded.skills.map(toWireSkill),\n\t\t\terrors: loaded.diagnostics.map((diagnostic) => toWireSkillError(diagnostic, cwd)),\n\t\t};\n\t} catch (error) {\n\t\treturn { cwd, skills: [], errors: [{ path: cwd, message: errorMessage(error) }] };\n\t}\n}\n\nfunction validateSkillCwd(cwd: string): SkillsListEntry | undefined {\n\tif (!existsSync(cwd)) {\n\t\treturn { cwd, skills: [], errors: [{ path: cwd, message: \"skill cwd does not exist\" }] };\n\t}\n\ttry {\n\t\tif (!statSync(cwd).isDirectory()) {\n\t\t\treturn { cwd, skills: [], errors: [{ path: cwd, message: \"skill cwd is not a directory\" }] };\n\t\t}\n\t} catch (error) {\n\t\treturn { cwd, skills: [], errors: [{ path: cwd, message: errorMessage(error) }] };\n\t}\n\treturn undefined;\n}\n\nasync function getCachedLoader(cwd: string, options: SkillsListEntryOptions): Promise<SkillResourceLoader> {\n\tlet loaderPromise = options.cachedLoaders.get(cwd);\n\tif (!loaderPromise) {\n\t\tloaderPromise = Promise.resolve().then(\n\t\t\t() => findLoadedLoader(cwd, options.threads) ?? createLoader(cwd, options),\n\t\t);\n\t\toptions.cachedLoaders.set(cwd, loaderPromise);\n\t}\n\ttry {\n\t\treturn await loaderPromise;\n\t} catch (error) {\n\t\toptions.cachedLoaders.delete(cwd);\n\t\tthrow error;\n\t}\n}\n\nfunction findLoadedLoader(\n\tcwd: string,\n\tthreads: Pick<ThreadRegistry, \"listLoaded\" | \"getLoadedThread\"> | undefined,\n): SkillResourceLoader | undefined {\n\tif (!threads) return undefined;\n\tconst loaded = threads.listLoaded().find((thread) => resolve(thread.cwd) === cwd);\n\tif (!loaded) return undefined;\n\ttry {\n\t\treturn threads.getLoadedThread(loaded.id).session.resourceLoader;\n\t} catch {\n\t\treturn undefined;\n\t}\n}\n\nasync function createLoader(cwd: string, options: SkillsListEntryOptions): Promise<SkillResourceLoader> {\n\tif (options.resourceLoaderFactory) return options.resourceLoaderFactory(cwd);\n\tlet loaded = loadSkills({ cwd, agentDir: options.agentDir, skillPaths: [], includeDefaults: true });\n\treturn {\n\t\tgetSkills: () => loaded,\n\t\treload: async () => {\n\t\t\tloaded = loadSkills({ cwd, agentDir: options.agentDir, skillPaths: [], includeDefaults: true });\n\t\t},\n\t};\n}\n\nfunction toWireSkill(skill: Skill): SkillMetadata {\n\treturn {\n\t\tname: skill.name,\n\t\tdescription: skill.description,\n\t\tpath: skill.filePath,\n\t\tscope: mapSkillScope(skill.sourceInfo.scope),\n\t\tenabled: !skill.disableModelInvocation,\n\t};\n}\n\nexport function mapSkillScope(scope: Skill[\"sourceInfo\"][\"scope\"]): SkillScope {\n\tswitch (scope) {\n\t\tcase \"user\":\n\t\t\treturn \"user\";\n\t\tcase \"project\":\n\t\t\treturn \"repo\";\n\t\tcase \"temporary\":\n\t\tcase \"system\":\n\t\t\treturn \"system\";\n\t\tdefault:\n\t\t\treturn assertNever(scope);\n\t}\n}\n\nfunction toWireSkillError(diagnostic: ResourceDiagnostic, cwd: string) {\n\treturn { path: diagnostic.path ?? cwd, message: diagnostic.message };\n}\n\nfunction parseSkillsListParams(value: unknown): SkillsListParams {\n\tif (value === undefined || value === null) return {};\n\tif (!isRecord(value)) throw new RpcHandlerError(invalidParamsError());\n\tconst cwds = value.cwds;\n\tif (cwds !== undefined && !isStringArray(cwds)) throw new RpcHandlerError(invalidParamsError());\n\tconst forceReload = value.forceReload;\n\tif (forceReload !== undefined && typeof forceReload !== \"boolean\") {\n\t\tthrow new RpcHandlerError(invalidParamsError());\n\t}\n\treturn { cwds, forceReload };\n}\n\nfunction isStringArray(value: unknown): value is readonly string[] {\n\treturn Array.isArray(value) && value.every((item) => typeof item === \"string\");\n}\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n\treturn typeof value === \"object\" && value !== null && !Array.isArray(value);\n}\n\nfunction errorMessage(error: unknown): string {\n\treturn error instanceof Error ? error.message : String(error);\n}\n\nfunction assertNever(value: never): never {\n\tthrow new Error(`Unhandled skill scope: ${String(value)}`);\n}\n"]}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { type Component, MouseRegion } from "@earendil-works/pi-tui";
|
|
2
|
+
import type { SessionEntry } from "../../../core/session-manager.ts";
|
|
3
|
+
export interface AskUserAnswerFrame {
|
|
4
|
+
readonly requestId: string;
|
|
5
|
+
readonly body: string;
|
|
6
|
+
}
|
|
7
|
+
export declare function parseAskUserAnswerFrame(text: string): AskUserAnswerFrame | undefined;
|
|
8
|
+
/** Custom entries are display metadata, excluded from model context. Older sessions may lack them. */
|
|
9
|
+
export declare function getAskUserAnswerHeaders(entries: readonly SessionEntry[], requestId: string): readonly string[];
|
|
10
|
+
/** A compact display over the unchanged user-message body; normal mouse dispatch requests the redraw. */
|
|
11
|
+
export declare class AskUserAnswerChip extends MouseRegion {
|
|
12
|
+
private readonly fullBody;
|
|
13
|
+
constructor(frame: AskUserAnswerFrame, headers: readonly string[], fullBody: Component);
|
|
14
|
+
invalidate(): void;
|
|
15
|
+
dispose(): void;
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=ask-user-answer-chip.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ask-user-answer-chip.d.ts","sourceRoot":"","sources":["../../../../src/modes/interactive/components/ask-user-answer-chip.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,SAAS,EAAa,WAAW,EAAmB,MAAM,wBAAwB,CAAC;AAEjG,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,kCAAkC,CAAC;AAIrE,MAAM,WAAW,kBAAkB;IAClC,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;CACtB;AAED,wBAAgB,uBAAuB,CAAC,IAAI,EAAE,MAAM,GAAG,kBAAkB,GAAG,SAAS,CAGpF;AAED,sGAAsG;AACtG,wBAAgB,uBAAuB,CAAC,OAAO,EAAE,SAAS,YAAY,EAAE,EAAE,SAAS,EAAE,MAAM,GAAG,SAAS,MAAM,EAAE,CAW9G;AA2BD,yGAAyG;AACzG,qBAAa,iBAAkB,SAAQ,WAAW;IACjD,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAY;IAErC,YAAY,KAAK,EAAE,kBAAkB,EAAE,OAAO,EAAE,SAAS,MAAM,EAAE,EAAE,QAAQ,EAAE,SAAS,EAmBrF;IAEQ,UAAU,IAAI,IAAI,CAG1B;IAED,OAAO,IAAI,IAAI,CAEd;CACD"}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import { Container, MouseRegion, truncateToWidth } from "@earendil-works/pi-tui";
|
|
2
|
+
import { ASK_USER_QUESTION_ENTRY } from "../../../core/extensions/builtin/ask-user/notify.js";
|
|
3
|
+
import { stripAnsi } from "../../../utils/ansi.js";
|
|
4
|
+
import { theme } from "../theme/theme.js";
|
|
5
|
+
export function parseAskUserAnswerFrame(text) {
|
|
6
|
+
const match = /^\[Answer to question ([^\]\r\n]+)\]\r?\n([\s\S]*)$/.exec(text);
|
|
7
|
+
return match ? { requestId: match[1], body: match[2] } : undefined;
|
|
8
|
+
}
|
|
9
|
+
/** Custom entries are display metadata, excluded from model context. Older sessions may lack them. */
|
|
10
|
+
export function getAskUserAnswerHeaders(entries, requestId) {
|
|
11
|
+
for (let index = entries.length - 1; index >= 0; index--) {
|
|
12
|
+
const entry = entries[index];
|
|
13
|
+
if (entry.type !== "custom" || entry.customType !== ASK_USER_QUESTION_ENTRY)
|
|
14
|
+
continue;
|
|
15
|
+
const data = entry.data;
|
|
16
|
+
if (typeof data !== "object" || data === null || !("requestId" in data) || data.requestId !== requestId)
|
|
17
|
+
continue;
|
|
18
|
+
if (!("headers" in data) || !Array.isArray(data.headers))
|
|
19
|
+
continue;
|
|
20
|
+
const headers = data.headers;
|
|
21
|
+
return headers.filter((header) => typeof header === "string");
|
|
22
|
+
}
|
|
23
|
+
return [];
|
|
24
|
+
}
|
|
25
|
+
function summaryRows(frame, headers) {
|
|
26
|
+
const fallbackHeaders = headers.length > 0 ? headers : [frame.requestId];
|
|
27
|
+
if (/^(?:The user did not answer|The user dismissed|The pending question|This session has no user)/.test(frame.body)) {
|
|
28
|
+
return fallbackHeaders.map((header) => `↳ ${header}: (no answer)`);
|
|
29
|
+
}
|
|
30
|
+
const answers = [];
|
|
31
|
+
let comment;
|
|
32
|
+
let unanswered = [];
|
|
33
|
+
for (const line of frame.body.split("\n")) {
|
|
34
|
+
const separator = line.indexOf(": ");
|
|
35
|
+
if (separator < 1)
|
|
36
|
+
continue;
|
|
37
|
+
const header = line.slice(0, separator);
|
|
38
|
+
const value = line.slice(separator + 2);
|
|
39
|
+
if (header === "The user responded")
|
|
40
|
+
comment = value;
|
|
41
|
+
else if (header === "Unanswered")
|
|
42
|
+
unanswered = value.split(", ");
|
|
43
|
+
else
|
|
44
|
+
answers.push(`↳ ${header}: ${value}`);
|
|
45
|
+
}
|
|
46
|
+
if (comment !== undefined) {
|
|
47
|
+
answers.push(`↳ ${headers[0] ?? unanswered[0] ?? frame.requestId}: ${JSON.stringify(comment)}`);
|
|
48
|
+
}
|
|
49
|
+
else
|
|
50
|
+
answers.push(...unanswered.map((header) => `↳ ${header}: (no answer)`));
|
|
51
|
+
return answers.length > 0 ? answers : fallbackHeaders.map((header) => `↳ ${header}: (no answer)`);
|
|
52
|
+
}
|
|
53
|
+
/** A compact display over the unchanged user-message body; normal mouse dispatch requests the redraw. */
|
|
54
|
+
export class AskUserAnswerChip extends MouseRegion {
|
|
55
|
+
constructor(frame, headers, fullBody) {
|
|
56
|
+
const rows = summaryRows(frame, headers).map((row) => stripAnsi(row).replace(/\s+/g, " "));
|
|
57
|
+
const summary = {
|
|
58
|
+
render: (width) => rows.map((row) => theme.fg("muted", truncateToWidth(row, width, "…"))),
|
|
59
|
+
invalidate() { },
|
|
60
|
+
};
|
|
61
|
+
const content = new Container();
|
|
62
|
+
content.addChild(summary);
|
|
63
|
+
let expanded = false;
|
|
64
|
+
super(content, (event) => {
|
|
65
|
+
if (event.button !== "left")
|
|
66
|
+
return undefined;
|
|
67
|
+
if (event.type === "press")
|
|
68
|
+
return { handled: true, render: false };
|
|
69
|
+
if (event.type !== "click" || (event.clickCount ?? 1) !== 1)
|
|
70
|
+
return undefined;
|
|
71
|
+
expanded = !expanded;
|
|
72
|
+
content.detachAll();
|
|
73
|
+
content.addChild(expanded ? fullBody : summary);
|
|
74
|
+
return { handled: true };
|
|
75
|
+
});
|
|
76
|
+
this.fullBody = fullBody;
|
|
77
|
+
}
|
|
78
|
+
invalidate() {
|
|
79
|
+
super.invalidate();
|
|
80
|
+
this.fullBody.invalidate();
|
|
81
|
+
}
|
|
82
|
+
dispose() {
|
|
83
|
+
this.fullBody.dispose?.();
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
//# sourceMappingURL=ask-user-answer-chip.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ask-user-answer-chip.js","sourceRoot":"","sources":["../../../../src/modes/interactive/components/ask-user-answer-chip.ts"],"names":[],"mappings":"AAAA,OAAO,EAAkB,SAAS,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AACjG,OAAO,EAAE,uBAAuB,EAAE,MAAM,qDAAqD,CAAC;AAE9F,OAAO,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AACnD,OAAO,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAO1C,MAAM,UAAU,uBAAuB,CAAC,IAAY;IACnD,MAAM,KAAK,GAAG,qDAAqD,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAC/E,OAAO,KAAK,CAAC,CAAC,CAAC,EAAE,SAAS,EAAE,KAAK,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC;AACpE,CAAC;AAED,sGAAsG;AACtG,MAAM,UAAU,uBAAuB,CAAC,OAAgC,EAAE,SAAiB;IAC1F,KAAK,IAAI,KAAK,GAAG,OAAO,CAAC,MAAM,GAAG,CAAC,EAAE,KAAK,IAAI,CAAC,EAAE,KAAK,EAAE,EAAE,CAAC;QAC1D,MAAM,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC,CAAC;QAC7B,IAAI,KAAK,CAAC,IAAI,KAAK,QAAQ,IAAI,KAAK,CAAC,UAAU,KAAK,uBAAuB;YAAE,SAAS;QACtF,MAAM,IAAI,GAAG,KAAK,CAAC,IAAI,CAAC;QACxB,IAAI,OAAO,IAAI,KAAK,QAAQ,IAAI,IAAI,KAAK,IAAI,IAAI,CAAC,CAAC,WAAW,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GAAG,CAAC,CAAC,CAAC;YACzF,UAAU,KAAI,CAAC;SACf,CAAC;QACF,MAAM,OAAO,GAAG,IAAI,SAAS,EAAE,CAAC;QAChC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;QAC1B,IAAI,QAAQ,GAAG,KAAK,CAAC;QACrB,KAAK,CAAC,OAAO,EAAE,CAAC,KAAK,EAAE,EAAE;YACxB,IAAI,KAAK,CAAC,MAAM,KAAK,MAAM;gBAAE,OAAO,SAAS,CAAC;YAC9C,IAAI,KAAK,CAAC,IAAI,KAAK,OAAO;gBAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC;YACpE,IAAI,KAAK,CAAC,IAAI,KAAK,OAAO,IAAI,CAAC,KAAK,CAAC,UAAU,IAAI,CAAC,CAAC,KAAK,CAAC;gBAAE,OAAO,SAAS,CAAC;YAC9E,QAAQ,GAAG,CAAC,QAAQ,CAAC;YACrB,OAAO,CAAC,SAAS,EAAE,CAAC;YACpB,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC;YAChD,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;QAC1B,CAAC,CAAC,CAAC;QACH,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;IAC1B,CAAC;IAEQ,UAAU;QAClB,KAAK,CAAC,UAAU,EAAE,CAAC;QACnB,IAAI,CAAC,QAAQ,CAAC,UAAU,EAAE,CAAC;IAC5B,CAAC;IAED,OAAO;QACN,IAAI,CAAC,QAAQ,CAAC,OAAO,EAAE,EAAE,CAAC;IAC3B,CAAC;CACD","sourcesContent":["import { type Component, Container, MouseRegion, truncateToWidth } from \"@earendil-works/pi-tui\";\nimport { ASK_USER_QUESTION_ENTRY } from \"../../../core/extensions/builtin/ask-user/notify.ts\";\nimport type { SessionEntry } from \"../../../core/session-manager.ts\";\nimport { stripAnsi } from \"../../../utils/ansi.ts\";\nimport { theme } from \"../theme/theme.ts\";\n\nexport interface AskUserAnswerFrame {\n\treadonly requestId: string;\n\treadonly body: string;\n}\n\nexport function parseAskUserAnswerFrame(text: string): AskUserAnswerFrame | undefined {\n\tconst match = /^\\[Answer to question ([^\\]\\r\\n]+)\\]\\r?\\n([\\s\\S]*)$/.exec(text);\n\treturn match ? { requestId: match[1], body: match[2] } : undefined;\n}\n\n/** Custom entries are display metadata, excluded from model context. Older sessions may lack them. */\nexport function getAskUserAnswerHeaders(entries: readonly SessionEntry[], requestId: string): readonly string[] {\n\tfor (let index = entries.length - 1; index >= 0; index--) {\n\t\tconst entry = entries[index];\n\t\tif (entry.type !== \"custom\" || entry.customType !== ASK_USER_QUESTION_ENTRY) continue;\n\t\tconst data = entry.data;\n\t\tif (typeof data !== \"object\" || data === null || !(\"requestId\" in data) || data.requestId !== requestId) continue;\n\t\tif (!(\"headers\" in data) || !Array.isArray(data.headers)) continue;\n\t\tconst headers: unknown[] = data.headers;\n\t\treturn headers.filter((header): header is string => typeof header === \"string\");\n\t}\n\treturn [];\n}\n\nfunction summaryRows(frame: AskUserAnswerFrame, headers: readonly string[]): string[] {\n\tconst fallbackHeaders = headers.length > 0 ? headers : [frame.requestId];\n\tif (\n\t\t/^(?:The user did not answer|The user dismissed|The pending question|This session has no user)/.test(frame.body)\n\t) {\n\t\treturn fallbackHeaders.map((header) => `↳ ${header}: (no answer)`);\n\t}\n\tconst answers: string[] = [];\n\tlet comment: string | undefined;\n\tlet unanswered: string[] = [];\n\tfor (const line of frame.body.split(\"\\n\")) {\n\t\tconst separator = line.indexOf(\": \");\n\t\tif (separator < 1) continue;\n\t\tconst header = line.slice(0, separator);\n\t\tconst value = line.slice(separator + 2);\n\t\tif (header === \"The user responded\") comment = value;\n\t\telse if (header === \"Unanswered\") unanswered = value.split(\", \");\n\t\telse answers.push(`↳ ${header}: ${value}`);\n\t}\n\tif (comment !== undefined) {\n\t\tanswers.push(`↳ ${headers[0] ?? unanswered[0] ?? frame.requestId}: ${JSON.stringify(comment)}`);\n\t} else answers.push(...unanswered.map((header) => `↳ ${header}: (no answer)`));\n\treturn answers.length > 0 ? answers : fallbackHeaders.map((header) => `↳ ${header}: (no answer)`);\n}\n\n/** A compact display over the unchanged user-message body; normal mouse dispatch requests the redraw. */\nexport class AskUserAnswerChip extends MouseRegion {\n\tprivate readonly fullBody: Component;\n\n\tconstructor(frame: AskUserAnswerFrame, headers: readonly string[], fullBody: Component) {\n\t\tconst rows = summaryRows(frame, headers).map((row) => stripAnsi(row).replace(/\\s+/g, \" \"));\n\t\tconst summary: Component = {\n\t\t\trender: (width) => rows.map((row) => theme.fg(\"muted\", truncateToWidth(row, width, \"…\"))),\n\t\t\tinvalidate() {},\n\t\t};\n\t\tconst content = new Container();\n\t\tcontent.addChild(summary);\n\t\tlet expanded = false;\n\t\tsuper(content, (event) => {\n\t\t\tif (event.button !== \"left\") return undefined;\n\t\t\tif (event.type === \"press\") return { handled: true, render: false };\n\t\t\tif (event.type !== \"click\" || (event.clickCount ?? 1) !== 1) return undefined;\n\t\t\texpanded = !expanded;\n\t\t\tcontent.detachAll();\n\t\t\tcontent.addChild(expanded ? fullBody : summary);\n\t\t\treturn { handled: true };\n\t\t});\n\t\tthis.fullBody = fullBody;\n\t}\n\n\toverride invalidate(): void {\n\t\tsuper.invalidate();\n\t\tthis.fullBody.invalidate();\n\t}\n\n\tdispose(): void {\n\t\tthis.fullBody.dispose?.();\n\t}\n}\n"]}
|
|
@@ -5,8 +5,10 @@
|
|
|
5
5
|
* terminal does not report Option as Alt.
|
|
6
6
|
*/
|
|
7
7
|
import { type KeybindingsManager, type KeyId } from "@earendil-works/pi-tui";
|
|
8
|
-
/**
|
|
8
|
+
/** Rebindable action that expands the pending question, retaining the legacy Option-letter chord. */
|
|
9
9
|
export declare const ASK_USER_ANSWER_KEYBINDING = "app.question.answer";
|
|
10
|
+
/** Prefer the arrow chord, or the retained letter chord on terminals that commonly reserve it. */
|
|
11
|
+
export declare function askUserAnswerKeyHint(env?: NodeJS.ProcessEnv): string;
|
|
10
12
|
/** Glyphs the bound `alt+<letter>` chords type on darwin when Option composes. */
|
|
11
13
|
export declare function darwinOptionGlyphs(keys: readonly KeyId[]): ReadonlySet<string>;
|
|
12
14
|
/** True when `data` is the editor input that expands the pending question on `platform`. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ask-user-answer-key.d.ts","sourceRoot":"","sources":["../../../../src/modes/interactive/components/ask-user-answer-key.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAwC,KAAK,kBAAkB,EAAE,KAAK,KAAK,EAAE,MAAM,wBAAwB,CAAC;
|
|
1
|
+
{"version":3,"file":"ask-user-answer-key.d.ts","sourceRoot":"","sources":["../../../../src/modes/interactive/components/ask-user-answer-key.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAwC,KAAK,kBAAkB,EAAE,KAAK,KAAK,EAAE,MAAM,wBAAwB,CAAC;AAKnH,qGAAqG;AACrG,eAAO,MAAM,0BAA0B,wBAAwB,CAAC;AAEhE,kGAAkG;AAClG,wBAAgB,oBAAoB,CAAC,GAAG,GAAE,MAAM,CAAC,UAAwB,GAAG,MAAM,CAOjF;AAsCD,kFAAkF;AAClF,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,SAAS,KAAK,EAAE,GAAG,WAAW,CAAC,MAAM,CAAC,CAQ9E;AAED,4FAA4F;AAC5F,wBAAgB,uBAAuB,CACtC,IAAI,EAAE,MAAM,EACZ,QAAQ,GAAE,MAAM,CAAC,QAA2B,EAC5C,WAAW,GAAE,kBAAqC,GAChD,OAAO,CAIT"}
|
|
@@ -5,8 +5,18 @@
|
|
|
5
5
|
* terminal does not report Option as Alt.
|
|
6
6
|
*/
|
|
7
7
|
import { decodeKittyPrintable, getKeybindings } from "@earendil-works/pi-tui";
|
|
8
|
-
|
|
8
|
+
import { QUESTION_ANSWER_FALLBACK_KEY, QUESTION_ANSWER_PRIMARY_KEY } from "../../../core/keybindings.js";
|
|
9
|
+
import { formatKeyText, keyText } from "./keybinding-hints.js";
|
|
10
|
+
/** Rebindable action that expands the pending question, retaining the legacy Option-letter chord. */
|
|
9
11
|
export const ASK_USER_ANSWER_KEYBINDING = "app.question.answer";
|
|
12
|
+
/** Prefer the arrow chord, or the retained letter chord on terminals that commonly reserve it. */
|
|
13
|
+
export function askUserAnswerKeyHint(env = process.env) {
|
|
14
|
+
const keys = getKeybindings().getKeys(ASK_USER_ANSWER_KEYBINDING);
|
|
15
|
+
const preferred = env.TMUX || ["Apple_Terminal", "WarpTerminal", "vscode"].includes(env.TERM_PROGRAM ?? "")
|
|
16
|
+
? QUESTION_ANSWER_FALLBACK_KEY
|
|
17
|
+
: QUESTION_ANSWER_PRIMARY_KEY;
|
|
18
|
+
return keys.includes(preferred) ? formatKeyText(preferred) : keyText(ASK_USER_ANSWER_KEYBINDING);
|
|
19
|
+
}
|
|
10
20
|
/**
|
|
11
21
|
* What each letter key types on a US-layout macOS keyboard while Option is
|
|
12
22
|
* held and the terminal lets Option compose characters instead of sending
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ask-user-answer-key.js","sourceRoot":"","sources":["../../../../src/modes/interactive/components/ask-user-answer-key.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,oBAAoB,EAAE,cAAc,EAAuC,MAAM,wBAAwB,CAAC;AAEnH,
|
|
1
|
+
{"version":3,"file":"ask-user-answer-key.js","sourceRoot":"","sources":["../../../../src/modes/interactive/components/ask-user-answer-key.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,oBAAoB,EAAE,cAAc,EAAuC,MAAM,wBAAwB,CAAC;AAEnH,OAAO,EAAE,4BAA4B,EAAE,2BAA2B,EAAE,MAAM,8BAA8B,CAAC;AACzG,OAAO,EAAE,aAAa,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAC;AAE/D,qGA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CAAC,CAAC,CAAC,GAAG,CAAC,oBAAoB,CAAC,IAAI,CAAC,IAAI,IAAI,CAAC,CAAC;AACpH,CAAC","sourcesContent":["/**\n * The editor shortcut that expands a pending async (waitForAnswer=false)\n * question into the full AskUserQuestionComponent: a rebindable keybinding\n * action plus the macOS Option-compose glyphs that stand in for it when the\n * terminal does not report Option as Alt.\n */\n\nimport { decodeKittyPrintable, getKeybindings, type KeybindingsManager, type KeyId } from \"@earendil-works/pi-tui\";\n\nimport { QUESTION_ANSWER_FALLBACK_KEY, QUESTION_ANSWER_PRIMARY_KEY } from \"../../../core/keybindings.ts\";\nimport { formatKeyText, keyText } from \"./keybinding-hints.ts\";\n\n/** Rebindable action that expands the pending question, retaining the legacy Option-letter chord. */\nexport const ASK_USER_ANSWER_KEYBINDING = \"app.question.answer\";\n\n/** Prefer the arrow chord, or the retained letter chord on terminals that commonly reserve it. */\nexport function askUserAnswerKeyHint(env: NodeJS.ProcessEnv = process.env): string {\n\tconst keys = getKeybindings().getKeys(ASK_USER_ANSWER_KEYBINDING);\n\tconst preferred =\n\t\tenv.TMUX || [\"Apple_Terminal\", \"WarpTerminal\", \"vscode\"].includes(env.TERM_PROGRAM ?? \"\")\n\t\t\t? QUESTION_ANSWER_FALLBACK_KEY\n\t\t\t: QUESTION_ANSWER_PRIMARY_KEY;\n\treturn keys.includes(preferred) ? formatKeyText(preferred) : keyText(ASK_USER_ANSWER_KEYBINDING);\n}\n\n/**\n * What each letter key types on a US-layout macOS keyboard while Option is\n * held and the terminal lets Option compose characters instead of sending\n * Alt (the default in Terminal.app, iTerm2, Ghostty and kitty), as\n * `[Option+letter, Option+Shift+letter]`. Accepting the glyphs of the bound\n * `alt+<letter>` chords keeps the advertised shortcut working without a\n * terminal-settings detour; other platforms never see Option this way, so\n * they keep treating the glyphs as text. The dead keys `e`, `i`, `n` and `u`\n * compose with the next keystroke instead of typing a glyph, so a binding on\n * one of them needs the terminal's Option-as-Meta setting.\n */\nconst DARWIN_OPTION_GLYPHS: Readonly<Record<string, readonly [string, string]>> = {\n\ta: [\"å\", \"Å\"],\n\tb: [\"∫\", \"ı\"],\n\tc: [\"ç\", \"Ç\"],\n\td: [\"∂\", \"Î\"],\n\tf: [\"ƒ\", \"Ï\"],\n\tg: [\"©\", \"˝\"],\n\th: [\"˙\", \"Ó\"],\n\tj: [\"∆\", \"Ô\"],\n\tk: [\"˚\", \"\\uf8ff\"],\n\tl: [\"¬\", \"Ò\"],\n\tm: [\"µ\", \"Â\"],\n\to: [\"ø\", \"Ø\"],\n\tp: [\"π\", \"∏\"],\n\tq: [\"œ\", \"Œ\"],\n\tr: [\"®\", \"‰\"],\n\ts: [\"ß\", \"Í\"],\n\tt: [\"†\", \"ˇ\"],\n\tv: [\"√\", \"◊\"],\n\tw: [\"∑\", \"„\"],\n\tx: [\"≈\", \"˛\"],\n\ty: [\"¥\", \"Á\"],\n\tz: [\"Ω\", \"¸\"],\n};\n\n/** Glyphs the bound `alt+<letter>` chords type on darwin when Option composes. */\nexport function darwinOptionGlyphs(keys: readonly KeyId[]): ReadonlySet<string> {\n\tconst glyphs = new Set<string>();\n\tfor (const key of keys) {\n\t\tconst letter = /^alt\\+([a-z])$/i.exec(key)?.[1]?.toLowerCase();\n\t\tif (letter === undefined) continue;\n\t\tfor (const glyph of DARWIN_OPTION_GLYPHS[letter] ?? []) glyphs.add(glyph);\n\t}\n\treturn glyphs;\n}\n\n/** True when `data` is the editor input that expands the pending question on `platform`. */\nexport function matchesAskUserAnswerKey(\n\tdata: string,\n\tplatform: NodeJS.Platform = process.platform,\n\tkeybindings: KeybindingsManager = getKeybindings(),\n): boolean {\n\tif (keybindings.matches(data, ASK_USER_ANSWER_KEYBINDING)) return true;\n\tif (platform !== \"darwin\") return false;\n\treturn darwinOptionGlyphs(keybindings.getKeys(ASK_USER_ANSWER_KEYBINDING)).has(decodeKittyPrintable(data) ?? data);\n}\n"]}
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
import { Container, type TUI } from "@earendil-works/pi-tui";
|
|
10
10
|
import type { QuestionRequest, QuestionResponse } from "../../../core/extensions/types.ts";
|
|
11
11
|
import { type QuestionDraft } from "./ask-user-question-state.ts";
|
|
12
|
-
/**
|
|
12
|
+
/** Host-owned widget slot displaying one request from the pending queue. */
|
|
13
13
|
export declare const ASK_USER_WIDGET_KEY = "ask-user";
|
|
14
14
|
type Question = QuestionRequest["questions"][number];
|
|
15
15
|
/** Question ids the draft has not answered yet. */
|
|
@@ -18,7 +18,7 @@ export declare function unansweredIds(request: QuestionRequest, draft: QuestionD
|
|
|
18
18
|
export declare function buildCommentResponse(request: QuestionRequest, draft: QuestionDraft, comment: string): QuestionResponse;
|
|
19
19
|
/** Response for an idle countdown that expired while the widget was collapsed. */
|
|
20
20
|
export declare function buildTimedOutResponse(request: QuestionRequest, draft: QuestionDraft, autoResolvedAfterMs: number): QuestionResponse;
|
|
21
|
-
export declare function renderStatusLine(unanswered: number, countdownLabel: string): string;
|
|
21
|
+
export declare function renderStatusLine(unanswered: number, countdownLabel: string, pendingCount?: number): string;
|
|
22
22
|
export declare function renderQuestionLine(question: Question): string;
|
|
23
23
|
export declare function renderOptionsLine(question: Question, remaining: number): string;
|
|
24
24
|
/** Hint naming every way into the pending question; the shortcut segment follows the effective binding. */
|
|
@@ -28,6 +28,8 @@ export interface AskUserAsyncWidgetOptions {
|
|
|
28
28
|
draft: QuestionDraft;
|
|
29
29
|
/** Idle countdown shown in the line; 0 disables it. */
|
|
30
30
|
timeoutMs: number;
|
|
31
|
+
getDeadlineAtMs?: () => number;
|
|
32
|
+
pendingCount?: number;
|
|
31
33
|
tui?: TUI;
|
|
32
34
|
onExpire: () => void;
|
|
33
35
|
}
|
|
@@ -35,6 +37,7 @@ export declare class AskUserAsyncWidget extends Container {
|
|
|
35
37
|
private readonly request;
|
|
36
38
|
private readonly draft;
|
|
37
39
|
private readonly countdown;
|
|
40
|
+
private readonly pendingCount;
|
|
38
41
|
private countdownLabel;
|
|
39
42
|
constructor(options: AskUserAsyncWidgetOptions);
|
|
40
43
|
dispose(): void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ask-user-async-widget.d.ts","sourceRoot":"","sources":["../../../../src/modes/interactive/components/ask-user-async-widget.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,SAAS,EAAuB,KAAK,GAAG,EAAE,MAAM,wBAAwB,CAAC;AAClF,OAAO,KAAK,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,mCAAmC,CAAC;
|
|
1
|
+
{"version":3,"file":"ask-user-async-widget.d.ts","sourceRoot":"","sources":["../../../../src/modes/interactive/components/ask-user-async-widget.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,SAAS,EAAuB,KAAK,GAAG,EAAE,MAAM,wBAAwB,CAAC;AAClF,OAAO,KAAK,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,mCAAmC,CAAC;AAI3F,OAAO,EAAwB,KAAK,aAAa,EAAE,MAAM,8BAA8B,CAAC;AAGxF,4EAA4E;AAC5E,eAAO,MAAM,mBAAmB,aAAa,CAAC;AAE9C,KAAK,QAAQ,GAAG,eAAe,CAAC,WAAW,CAAC,CAAC,MAAM,CAAC,CAAC;AAUrD,mDAAmD;AACnD,wBAAgB,aAAa,CAAC,OAAO,EAAE,eAAe,EAAE,KAAK,EAAE,aAAa,GAAG,MAAM,EAAE,CAEtF;AAED,+FAA+F;AAC/F,wBAAgB,oBAAoB,CACnC,OAAO,EAAE,eAAe,EACxB,KAAK,EAAE,aAAa,EACpB,OAAO,EAAE,MAAM,GACb,gBAAgB,CAOlB;AAED,kFAAkF;AAClF,wBAAgB,qBAAqB,CACpC,OAAO,EAAE,eAAe,EACxB,KAAK,EAAE,aAAa,EACpB,mBAAmB,EAAE,MAAM,GACzB,gBAAgB,CASlB;AAED,wBAAgB,gBAAgB,CAAC,UAAU,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM,EAAE,YAAY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