@code-yeongyu/senpi 2026.7.10 → 2026.7.11
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 +62 -0
- package/README.md +4 -2
- package/dist/core/extensions/builtin/bash-timeout/timeout.js +2 -2
- package/dist/core/extensions/builtin/bash-timeout/timeout.js.map +1 -1
- package/dist/core/extensions/builtin/compaction/index.d.ts.map +1 -1
- package/dist/core/extensions/builtin/compaction/index.js +10 -1
- package/dist/core/extensions/builtin/compaction/index.js.map +1 -1
- package/dist/core/extensions/builtin/goal/store.d.ts.map +1 -1
- package/dist/core/extensions/builtin/goal/store.js +88 -3
- package/dist/core/extensions/builtin/goal/store.js.map +1 -1
- package/dist/core/extensions/builtin/prompt-preset/gpt-5.6.d.ts +3 -0
- package/dist/core/extensions/builtin/prompt-preset/gpt-5.6.d.ts.map +1 -0
- package/dist/core/extensions/builtin/prompt-preset/gpt-5.6.js +83 -0
- package/dist/core/extensions/builtin/prompt-preset/gpt-5.6.js.map +1 -0
- package/dist/core/extensions/builtin/prompt-preset/presets.d.ts.map +1 -1
- package/dist/core/extensions/builtin/prompt-preset/presets.js +6 -0
- package/dist/core/extensions/builtin/prompt-preset/presets.js.map +1 -1
- package/dist/core/extensions/builtin/prompt-preset/settings.d.ts +1 -1
- package/dist/core/extensions/builtin/prompt-preset/settings.d.ts.map +1 -1
- package/dist/core/extensions/builtin/prompt-preset/settings.js +1 -0
- package/dist/core/extensions/builtin/prompt-preset/settings.js.map +1 -1
- package/dist/core/extensions/builtin/terminal/notify.d.ts +3 -3
- package/dist/core/extensions/builtin/terminal/notify.d.ts.map +1 -1
- package/dist/core/extensions/builtin/terminal/notify.js +7 -4
- package/dist/core/extensions/builtin/terminal/notify.js.map +1 -1
- package/dist/core/extensions/builtin/terminal/runtime-session.d.ts +5 -3
- package/dist/core/extensions/builtin/terminal/runtime-session.d.ts.map +1 -1
- package/dist/core/extensions/builtin/terminal/runtime-session.js +32 -16
- package/dist/core/extensions/builtin/terminal/runtime-session.js.map +1 -1
- package/dist/core/extensions/builtin/terminal/tools/bash-output.d.ts +1 -1
- package/dist/core/extensions/builtin/terminal/tools/bash-output.d.ts.map +1 -1
- package/dist/core/extensions/builtin/terminal/tools/bash-output.js +10 -4
- package/dist/core/extensions/builtin/terminal/tools/bash-output.js.map +1 -1
- package/dist/core/extensions/builtin/todotools/tools/todowrite.d.ts.map +1 -1
- package/dist/core/extensions/builtin/todotools/tools/todowrite.js +5 -8
- package/dist/core/extensions/builtin/todotools/tools/todowrite.js.map +1 -1
- package/dist/core/extensions/runner.d.ts +1 -0
- package/dist/core/extensions/runner.d.ts.map +1 -1
- package/dist/core/extensions/runner.js +5 -0
- package/dist/core/extensions/runner.js.map +1 -1
- package/dist/core/extensions/types.d.ts +5 -8
- 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.map +1 -1
- package/dist/core/extensions/wrapper.js +22 -3
- package/dist/core/extensions/wrapper.js.map +1 -1
- package/dist/core/keybindings.d.ts +8 -3
- package/dist/core/keybindings.d.ts.map +1 -1
- package/dist/core/keybindings.js +7 -3
- package/dist/core/keybindings.js.map +1 -1
- package/dist/core/model-registry.d.ts +1 -6
- package/dist/core/model-registry.d.ts.map +1 -1
- package/dist/core/model-registry.js +19 -6
- package/dist/core/model-registry.js.map +1 -1
- package/dist/core/settings-manager.d.ts +4 -3
- package/dist/core/settings-manager.d.ts.map +1 -1
- package/dist/core/settings-manager.js +2 -1
- package/dist/core/settings-manager.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/modes/interactive/components/custom-editor.js +1 -1
- package/dist/modes/interactive/components/custom-editor.js.map +1 -1
- package/dist/modes/interactive/components/login-dialog.d.ts +4 -0
- package/dist/modes/interactive/components/login-dialog.d.ts.map +1 -1
- package/dist/modes/interactive/components/login-dialog.js +9 -2
- package/dist/modes/interactive/components/login-dialog.js.map +1 -1
- package/dist/modes/interactive/components/settings-selector.js +1 -1
- package/dist/modes/interactive/components/settings-selector.js.map +1 -1
- package/dist/modes/interactive/components/thinking-selector.js +1 -1
- package/dist/modes/interactive/components/thinking-selector.js.map +1 -1
- package/dist/modes/interactive/components/tool-execution-fallback.d.ts +6 -0
- package/dist/modes/interactive/components/tool-execution-fallback.d.ts.map +1 -0
- package/dist/modes/interactive/components/tool-execution-fallback.js +40 -0
- package/dist/modes/interactive/components/tool-execution-fallback.js.map +1 -0
- package/dist/modes/interactive/components/tool-execution-images.d.ts +23 -0
- package/dist/modes/interactive/components/tool-execution-images.d.ts.map +1 -0
- package/dist/modes/interactive/components/tool-execution-images.js +104 -0
- package/dist/modes/interactive/components/tool-execution-images.js.map +1 -0
- package/dist/modes/interactive/components/tool-execution-renderer.d.ts +28 -0
- package/dist/modes/interactive/components/tool-execution-renderer.d.ts.map +1 -0
- package/dist/modes/interactive/components/tool-execution-renderer.js +135 -0
- package/dist/modes/interactive/components/tool-execution-renderer.js.map +1 -0
- package/dist/modes/interactive/components/tool-execution-types.d.ts +23 -0
- package/dist/modes/interactive/components/tool-execution-types.d.ts.map +1 -0
- package/dist/modes/interactive/components/tool-execution-types.js +2 -0
- package/dist/modes/interactive/components/tool-execution-types.js.map +1 -0
- package/dist/modes/interactive/components/tool-execution.d.ts +13 -39
- package/dist/modes/interactive/components/tool-execution.d.ts.map +1 -1
- package/dist/modes/interactive/components/tool-execution.js +51 -294
- package/dist/modes/interactive/components/tool-execution.js.map +1 -1
- package/dist/modes/interactive/components/tool-renderer-boundary.d.ts +17 -0
- package/dist/modes/interactive/components/tool-renderer-boundary.d.ts.map +1 -0
- package/dist/modes/interactive/components/tool-renderer-boundary.js +75 -0
- package/dist/modes/interactive/components/tool-renderer-boundary.js.map +1 -0
- package/dist/modes/interactive/components/tree-selector.d.ts +5 -0
- package/dist/modes/interactive/components/tree-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/tree-selector.js +50 -17
- package/dist/modes/interactive/components/tree-selector.js.map +1 -1
- package/dist/modes/interactive/interactive-mode.d.ts +1 -2
- package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-mode.js +44 -40
- package/dist/modes/interactive/interactive-mode.js.map +1 -1
- package/dist/modes/interactive/theme/dark.json +1 -0
- package/dist/modes/interactive/theme/light.json +1 -0
- package/dist/modes/interactive/theme/theme-schema.json +6 -2
- package/dist/modes/interactive/theme/theme.d.ts +3 -2
- package/dist/modes/interactive/theme/theme.d.ts.map +1 -1
- package/dist/modes/interactive/theme/theme.js +11 -4
- package/dist/modes/interactive/theme/theme.js.map +1 -1
- package/dist/utils/clipboard-native.d.ts +1 -0
- package/dist/utils/clipboard-native.d.ts.map +1 -1
- package/dist/utils/clipboard-native.js.map +1 -1
- package/dist/utils/clipboard.d.ts +2 -0
- package/dist/utils/clipboard.d.ts.map +1 -1
- package/dist/utils/clipboard.js +13 -0
- package/dist/utils/clipboard.js.map +1 -1
- package/docs/custom-provider.md +4 -3
- package/docs/extensions.md +140 -1
- package/docs/keybindings.md +1 -0
- package/docs/models.md +45 -4
- package/docs/providers.md +3 -0
- package/docs/quickstart.md +1 -1
- package/docs/rpc.md +2 -2
- package/docs/sdk.md +1 -1
- package/docs/settings.md +3 -3
- package/docs/themes.md +5 -3
- package/docs/tui.md +1 -1
- package/docs/usage.md +2 -1
- package/examples/extensions/custom-provider-anthropic/package-lock.json +2 -2
- package/examples/extensions/custom-provider-anthropic/package.json +1 -1
- package/examples/extensions/custom-provider-gitlab-duo/package.json +1 -1
- package/examples/extensions/gondolin/package-lock.json +2 -2
- package/examples/extensions/gondolin/package.json +1 -1
- package/examples/extensions/sandbox/package-lock.json +2 -2
- package/examples/extensions/sandbox/package.json +1 -1
- package/examples/extensions/with-deps/package-lock.json +2 -2
- package/examples/extensions/with-deps/package.json +1 -1
- package/node_modules/@code-yeongyu/senpi-codemode/CHANGELOG.md +3 -0
- package/node_modules/@code-yeongyu/senpi-codemode/package.json +3 -3
- package/node_modules/@code-yeongyu/senpi-codemode/src/bridge/protocol.ts +7 -7
- package/node_modules/@code-yeongyu/senpi-codemode/src/completion/tool-bridge.ts +3 -0
- package/node_modules/@code-yeongyu/senpi-codemode/src/extension/session-manager.ts +69 -8
- package/node_modules/@code-yeongyu/senpi-codemode/src/index.ts +39 -13
- package/node_modules/@code-yeongyu/senpi-codemode/src/kernels/js/context-manager.ts +191 -148
- package/node_modules/@code-yeongyu/senpi-codemode/src/kernels/js/inline-worker-entry.js +23 -0
- package/node_modules/@code-yeongyu/senpi-codemode/src/kernels/js/inline-worker.ts +4 -175
- package/node_modules/@code-yeongyu/senpi-codemode/src/kernels/js/kernel-contract.ts +38 -0
- package/node_modules/@code-yeongyu/senpi-codemode/src/kernels/js/run-queue.ts +82 -0
- package/node_modules/@code-yeongyu/senpi-codemode/src/kernels/js/worker-core.js +7 -3
- package/node_modules/@code-yeongyu/senpi-codemode/src/kernels/js/worker-host.ts +117 -0
- package/node_modules/@code-yeongyu/senpi-codemode/src/kernels/py/kernel-contract.ts +32 -0
- package/node_modules/@code-yeongyu/senpi-codemode/src/kernels/py/kernel.ts +231 -199
- package/node_modules/@code-yeongyu/senpi-codemode/src/kernels/py/process.ts +119 -0
- package/node_modules/@code-yeongyu/senpi-codemode/src/kernels/py/transport.ts +237 -0
- package/node_modules/@code-yeongyu/senpi-codemode/src/kernels/shared/subprocess-contract.ts +22 -0
- package/node_modules/@code-yeongyu/senpi-codemode/src/kernels/shared/subprocess-kernel.ts +214 -189
- package/node_modules/@code-yeongyu/senpi-codemode/src/kernels/shared/subprocess-process.ts +174 -0
- package/node_modules/@code-yeongyu/senpi-codemode/src/kernels/shared/subprocess-queue.ts +100 -0
- package/node_modules/@code-yeongyu/senpi-codemode/src/kernels/shared/subprocess-run.ts +98 -0
- package/node_modules/@code-yeongyu/senpi-codemode/src/tool/cell-handler.ts +205 -0
- package/node_modules/@code-yeongyu/senpi-codemode/src/tool/eval-tool.ts +208 -203
- package/node_modules/@code-yeongyu/senpi-codemode/src/tool/render.ts +215 -25
- package/node_modules/@code-yeongyu/senpi-codemode/src/tool/types.ts +1 -0
- package/node_modules/@earendil-works/pi-agent-core/README.md +1 -1
- package/node_modules/@earendil-works/pi-agent-core/dist/agent-loop.js +2 -0
- package/node_modules/@earendil-works/pi-agent-core/dist/agent-loop.js.map +1 -1
- package/node_modules/@earendil-works/pi-agent-core/dist/types.d.ts +4 -3
- package/node_modules/@earendil-works/pi-agent-core/dist/types.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-agent-core/dist/types.js.map +1 -1
- package/node_modules/@earendil-works/pi-agent-core/package.json +2 -2
- package/node_modules/@earendil-works/pi-ai/README.md +4 -2
- package/node_modules/@earendil-works/pi-ai/dist/api/anthropic-messages.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/api/anthropic-messages.js +89 -40
- package/node_modules/@earendil-works/pi-ai/dist/api/anthropic-messages.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/api/azure-openai-responses.d.ts +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/api/azure-openai-responses.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/api/azure-openai-responses.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/api/bedrock-converse-stream.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/api/bedrock-converse-stream.js +7 -7
- package/node_modules/@earendil-works/pi-ai/dist/api/bedrock-converse-stream.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/api/openai-codex-responses.d.ts +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 +10 -3
- 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-completions.d.ts +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/api/openai-completions.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/api/openai-completions.js +5 -1
- package/node_modules/@earendil-works/pi-ai/dist/api/openai-completions.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/api/openai-responses-shared.d.ts +3 -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 +35 -4
- 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 +1 -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 +7 -3
- package/node_modules/@earendil-works/pi-ai/dist/api/openai-responses.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/api/simple-options.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/api/simple-options.js +8 -3
- package/node_modules/@earendil-works/pi-ai/dist/api/simple-options.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/api/transform-messages.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/api/transform-messages.js +4 -3
- package/node_modules/@earendil-works/pi-ai/dist/api/transform-messages.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/compat.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/compat.js +2 -1
- package/node_modules/@earendil-works/pi-ai/dist/compat.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/models.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/models.generated.d.ts +483 -61
- package/node_modules/@earendil-works/pi-ai/dist/models.generated.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/models.js +13 -4
- package/node_modules/@earendil-works/pi-ai/dist/models.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/amazon-bedrock.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/amazon-bedrock.js +5 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/amazon-bedrock.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/amazon-bedrock.models.d.ts +62 -5
- package/node_modules/@earendil-works/pi-ai/dist/providers/amazon-bedrock.models.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/amazon-bedrock.models.js +32 -20
- package/node_modules/@earendil-works/pi-ai/dist/providers/amazon-bedrock.models.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/anthropic.models.d.ts +11 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/anthropic.models.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/anthropic.models.js +6 -4
- package/node_modules/@earendil-works/pi-ai/dist/providers/anthropic.models.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/azure-openai-responses.models.d.ts +7 -8
- package/node_modules/@earendil-works/pi-ai/dist/providers/azure-openai-responses.models.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/azure-openai-responses.models.js +20 -21
- package/node_modules/@earendil-works/pi-ai/dist/providers/azure-openai-responses.models.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/cloudflare-ai-gateway.models.d.ts +11 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/cloudflare-ai-gateway.models.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/cloudflare-ai-gateway.models.js +6 -4
- package/node_modules/@earendil-works/pi-ai/dist/providers/cloudflare-ai-gateway.models.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/cloudflare-auth.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/cloudflare-auth.js +9 -6
- package/node_modules/@earendil-works/pi-ai/dist/providers/cloudflare-auth.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/deepseek.models.d.ts +2 -2
- package/node_modules/@earendil-works/pi-ai/dist/providers/deepseek.models.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/deepseek.models.js +2 -2
- package/node_modules/@earendil-works/pi-ai/dist/providers/deepseek.models.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/fireworks.models.d.ts +2 -2
- package/node_modules/@earendil-works/pi-ai/dist/providers/fireworks.models.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/fireworks.models.js +2 -2
- package/node_modules/@earendil-works/pi-ai/dist/providers/fireworks.models.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/github-copilot.models.d.ts +100 -2
- package/node_modules/@earendil-works/pi-ai/dist/providers/github-copilot.models.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/github-copilot.models.js +64 -5
- package/node_modules/@earendil-works/pi-ai/dist/providers/github-copilot.models.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/openai-codex.models.d.ts +56 -0
- package/node_modules/@earendil-works/pi-ai/dist/providers/openai-codex.models.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/openai-codex.models.js +20 -9
- package/node_modules/@earendil-works/pi-ai/dist/providers/openai-codex.models.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/openai.models.d.ts +77 -8
- package/node_modules/@earendil-works/pi-ai/dist/providers/openai.models.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/openai.models.js +37 -24
- package/node_modules/@earendil-works/pi-ai/dist/providers/openai.models.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/opencode-go.models.d.ts +3 -3
- package/node_modules/@earendil-works/pi-ai/dist/providers/opencode-go.models.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/opencode-go.models.js +3 -3
- package/node_modules/@earendil-works/pi-ai/dist/providers/opencode-go.models.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/opencode.models.d.ts +80 -4
- package/node_modules/@earendil-works/pi-ai/dist/providers/opencode.models.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/opencode.models.js +64 -8
- package/node_modules/@earendil-works/pi-ai/dist/providers/opencode.models.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/openrouter.models.d.ts +25 -22
- package/node_modules/@earendil-works/pi-ai/dist/providers/openrouter.models.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/openrouter.models.js +64 -79
- package/node_modules/@earendil-works/pi-ai/dist/providers/openrouter.models.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/vercel-ai-gateway.models.d.ts +45 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/vercel-ai-gateway.models.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/vercel-ai-gateway.models.js +43 -7
- package/node_modules/@earendil-works/pi-ai/dist/providers/vercel-ai-gateway.models.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/zai-coding-cn.models.d.ts +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/zai-coding-cn.models.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/zai-coding-cn.models.js +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/zai-coding-cn.models.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/zai.models.d.ts +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/zai.models.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/zai.models.js +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/zai.models.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/types.d.ts +30 -7
- package/node_modules/@earendil-works/pi-ai/dist/types.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/types.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/utils/deferred-tools.d.ts +9 -0
- package/node_modules/@earendil-works/pi-ai/dist/utils/deferred-tools.d.ts.map +1 -0
- package/node_modules/@earendil-works/pi-ai/dist/utils/deferred-tools.js +36 -0
- package/node_modules/@earendil-works/pi-ai/dist/utils/deferred-tools.js.map +1 -0
- package/node_modules/@earendil-works/pi-ai/dist/utils/estimate.d.ts +3 -3
- package/node_modules/@earendil-works/pi-ai/dist/utils/estimate.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/utils/estimate.js +35 -14
- package/node_modules/@earendil-works/pi-ai/dist/utils/estimate.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/package.json +1 -1
- package/node_modules/@earendil-works/pi-pty/package.json +1 -1
- package/node_modules/@earendil-works/pi-tui/dist/components/image.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-tui/dist/components/image.js +2 -1
- package/node_modules/@earendil-works/pi-tui/dist/components/image.js.map +1 -1
- 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 +2 -1
- package/node_modules/@earendil-works/pi-tui/dist/index.js.map +1 -1
- package/node_modules/@earendil-works/pi-tui/dist/keys.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-tui/dist/keys.js +6 -5
- package/node_modules/@earendil-works/pi-tui/dist/keys.js.map +1 -1
- package/node_modules/@earendil-works/pi-tui/dist/terminal-image.d.ts +0 -1
- package/node_modules/@earendil-works/pi-tui/dist/terminal-image.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-tui/dist/terminal-image.js +0 -9
- package/node_modules/@earendil-works/pi-tui/dist/terminal-image.js.map +1 -1
- package/node_modules/@earendil-works/pi-tui/dist/terminal-text.d.ts +4 -0
- package/node_modules/@earendil-works/pi-tui/dist/terminal-text.d.ts.map +1 -0
- package/node_modules/@earendil-works/pi-tui/dist/terminal-text.js +18 -0
- package/node_modules/@earendil-works/pi-tui/dist/terminal-text.js.map +1 -0
- package/node_modules/@earendil-works/pi-tui/package.json +2 -2
- package/package.json +6 -6
|
@@ -0,0 +1,237 @@
|
|
|
1
|
+
import { dirname, join } from "node:path";
|
|
2
|
+
import { fileURLToPath } from "node:url";
|
|
3
|
+
import {
|
|
4
|
+
type BridgeConnectionConfig,
|
|
5
|
+
decodeBridgeFrame,
|
|
6
|
+
encodeBridgeFrame,
|
|
7
|
+
type HostToKernelMessage,
|
|
8
|
+
isKernelToHostMessage,
|
|
9
|
+
type KernelToHostMessage,
|
|
10
|
+
} from "../../bridge/protocol.ts";
|
|
11
|
+
import {
|
|
12
|
+
defaultSpawn,
|
|
13
|
+
hardKill,
|
|
14
|
+
type KernelChild,
|
|
15
|
+
type KernelSpawnOptions,
|
|
16
|
+
type KernelSpawnProcess,
|
|
17
|
+
numberOrNull,
|
|
18
|
+
signalOrNull,
|
|
19
|
+
splitCommand,
|
|
20
|
+
waitForExit,
|
|
21
|
+
withTimeout,
|
|
22
|
+
} from "./process.ts";
|
|
23
|
+
|
|
24
|
+
export type PythonTransportResult = Extract<KernelToHostMessage, { type: "result" }>;
|
|
25
|
+
|
|
26
|
+
export interface PythonTransportRunInput {
|
|
27
|
+
readonly cellId: string;
|
|
28
|
+
readonly code: string;
|
|
29
|
+
readonly timeoutMs?: number;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export interface PythonTransportOptions {
|
|
33
|
+
readonly interpreterPath: string;
|
|
34
|
+
readonly sessionId: string;
|
|
35
|
+
readonly cwd: string;
|
|
36
|
+
readonly connection: BridgeConnectionConfig;
|
|
37
|
+
readonly env?: NodeJS.ProcessEnv;
|
|
38
|
+
readonly startupTimeoutMs: number;
|
|
39
|
+
readonly onMessage?: (message: KernelToHostMessage) => void;
|
|
40
|
+
readonly spawnProcess?: KernelSpawnProcess;
|
|
41
|
+
readonly isOwned: () => boolean;
|
|
42
|
+
readonly onRetirementFailure: (transport: PythonKernelTransport, error: Error) => void;
|
|
43
|
+
readonly onResult: (transport: PythonKernelTransport, result: PythonTransportResult) => void;
|
|
44
|
+
readonly onError: (transport: PythonKernelTransport, error: Error) => void;
|
|
45
|
+
readonly onExit: (transport: PythonKernelTransport, error: Error) => void;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
const hardKillWaitMs = 500;
|
|
49
|
+
|
|
50
|
+
export class PythonKernelTransport {
|
|
51
|
+
readonly #options: PythonTransportOptions;
|
|
52
|
+
readonly #child: KernelChild;
|
|
53
|
+
#stdoutBuffer = "";
|
|
54
|
+
#stderrTail = "";
|
|
55
|
+
#settleReady: ((error?: Error) => void) | null = null;
|
|
56
|
+
#detachChildListeners: (() => void) | null = null;
|
|
57
|
+
#active = true;
|
|
58
|
+
#exited = false;
|
|
59
|
+
#retirement: Promise<void> | null = null;
|
|
60
|
+
|
|
61
|
+
private constructor(options: PythonTransportOptions, child: KernelChild) {
|
|
62
|
+
this.#options = options;
|
|
63
|
+
this.#child = child;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
static async start(options: PythonTransportOptions): Promise<PythonKernelTransport> {
|
|
67
|
+
const scriptPath = join(dirname(fileURLToPath(import.meta.url)), "prelude.py");
|
|
68
|
+
const invocation = splitCommand(options.interpreterPath);
|
|
69
|
+
const spawnOptions: KernelSpawnOptions = {
|
|
70
|
+
command: invocation.command,
|
|
71
|
+
args: [...invocation.args, "-u", scriptPath],
|
|
72
|
+
cwd: options.cwd,
|
|
73
|
+
env: { ...process.env, ...options.env, PYTHONUNBUFFERED: "1", PYTHONIOENCODING: "utf-8" },
|
|
74
|
+
};
|
|
75
|
+
const child = (options.spawnProcess ?? defaultSpawn)(spawnOptions);
|
|
76
|
+
const transport = new PythonKernelTransport(options, child);
|
|
77
|
+
try {
|
|
78
|
+
await transport.#initialize();
|
|
79
|
+
if (!transport.#active) throw new Error("Python kernel exited during startup");
|
|
80
|
+
if (!options.isOwned()) throw new Error("Python kernel startup was superseded");
|
|
81
|
+
} catch (error) {
|
|
82
|
+
try {
|
|
83
|
+
await transport.retire();
|
|
84
|
+
} catch (retirementError) {
|
|
85
|
+
options.onRetirementFailure(
|
|
86
|
+
transport,
|
|
87
|
+
retirementError instanceof Error ? retirementError : new Error(String(retirementError)),
|
|
88
|
+
);
|
|
89
|
+
}
|
|
90
|
+
throw error;
|
|
91
|
+
}
|
|
92
|
+
return transport;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
run(input: PythonTransportRunInput): void {
|
|
96
|
+
this.#write({ type: "run", cellId: input.cellId, code: input.code, timeoutMs: input.timeoutMs });
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
interrupt(reason: string): void {
|
|
100
|
+
try {
|
|
101
|
+
this.#write({ type: "interrupt", reason });
|
|
102
|
+
} catch (error) {
|
|
103
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
104
|
+
this.#stderrTail = `${this.#stderrTail}Python interrupt frame write failed: ${message}\n`.slice(-4_000);
|
|
105
|
+
}
|
|
106
|
+
if (process.platform === "win32") this.#child.kill();
|
|
107
|
+
else this.#child.kill("SIGINT");
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
async close(): Promise<void> {
|
|
111
|
+
if (this.#exited) return;
|
|
112
|
+
if (this.#retirement) {
|
|
113
|
+
await this.#retirement;
|
|
114
|
+
return;
|
|
115
|
+
}
|
|
116
|
+
if (!this.#active) {
|
|
117
|
+
await hardKill(this.#child, hardKillWaitMs);
|
|
118
|
+
return;
|
|
119
|
+
}
|
|
120
|
+
this.#active = false;
|
|
121
|
+
const exited = waitForExit(this.#child, hardKillWaitMs);
|
|
122
|
+
try {
|
|
123
|
+
this.#write({ type: "close" });
|
|
124
|
+
} catch (error) {
|
|
125
|
+
if (!(error instanceof Error)) throw error;
|
|
126
|
+
}
|
|
127
|
+
if (!(await exited)) await hardKill(this.#child, hardKillWaitMs);
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
retire(): Promise<void> {
|
|
131
|
+
if (this.#exited) return Promise.resolve();
|
|
132
|
+
if (this.#retirement) return this.#retirement;
|
|
133
|
+
this.#active = false;
|
|
134
|
+
const retirement = hardKill(this.#child, hardKillWaitMs).finally(() => {
|
|
135
|
+
this.#detachListeners();
|
|
136
|
+
if (this.#retirement === retirement) this.#retirement = null;
|
|
137
|
+
});
|
|
138
|
+
this.#retirement = retirement;
|
|
139
|
+
return retirement;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
async #initialize(): Promise<void> {
|
|
143
|
+
const ready = new Promise<void>((resolve, reject) => {
|
|
144
|
+
this.#settleReady = (error) => (error ? reject(error) : resolve());
|
|
145
|
+
});
|
|
146
|
+
const onStdout = (chunk: unknown) => this.#onStdout(String(chunk));
|
|
147
|
+
const onStderr = (chunk: unknown) => this.#onStderr(String(chunk));
|
|
148
|
+
const onError = (error: unknown) => this.#onError(error instanceof Error ? error : new Error(String(error)));
|
|
149
|
+
const onExit = (code: unknown, signal: unknown) => this.#onExit(numberOrNull(code), signalOrNull(signal));
|
|
150
|
+
this.#detachChildListeners = () => {
|
|
151
|
+
this.#child.stdout.off("data", onStdout);
|
|
152
|
+
this.#child.stderr.off("data", onStderr);
|
|
153
|
+
this.#child.off("error", onError);
|
|
154
|
+
this.#child.off("exit", onExit);
|
|
155
|
+
};
|
|
156
|
+
this.#child.stdout.on("data", onStdout);
|
|
157
|
+
this.#child.stderr.on("data", onStderr);
|
|
158
|
+
this.#child.on("error", onError);
|
|
159
|
+
this.#child.on("exit", onExit);
|
|
160
|
+
this.#write({ type: "init", sessionId: this.#options.sessionId, connection: this.#options.connection });
|
|
161
|
+
await withTimeout(ready, this.#options.startupTimeoutMs, "Python kernel did not become ready");
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
#write(message: HostToKernelMessage): void {
|
|
165
|
+
this.#child.stdin.write(encodeBridgeFrame(message));
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
#onStdout(chunk: string): void {
|
|
169
|
+
if (!this.#active) return;
|
|
170
|
+
this.#stdoutBuffer += chunk;
|
|
171
|
+
let newline = this.#stdoutBuffer.indexOf("\n");
|
|
172
|
+
while (newline >= 0) {
|
|
173
|
+
const line = this.#stdoutBuffer.slice(0, newline + 1);
|
|
174
|
+
this.#stdoutBuffer = this.#stdoutBuffer.slice(newline + 1);
|
|
175
|
+
this.#handleLine(line);
|
|
176
|
+
newline = this.#stdoutBuffer.indexOf("\n");
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
#onStderr(chunk: string): void {
|
|
181
|
+
if (!this.#active) return;
|
|
182
|
+
this.#stderrTail = `${this.#stderrTail}${chunk}`.slice(-4_000);
|
|
183
|
+
this.#options.onMessage?.({ type: "text", stream: "stderr", data: chunk });
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
#handleLine(line: string): void {
|
|
187
|
+
const decoded = decodeBridgeFrame(line);
|
|
188
|
+
if (!decoded.ok) {
|
|
189
|
+
this.#options.onMessage?.({ type: "text", stream: "stderr", data: `${decoded.error.message}\n` });
|
|
190
|
+
return;
|
|
191
|
+
}
|
|
192
|
+
if (!isKernelToHostMessage(decoded.message)) return;
|
|
193
|
+
const message = decoded.message;
|
|
194
|
+
if (message.type === "ready") this.#settleStartup();
|
|
195
|
+
else if (message.type === "init-failed") this.#settleStartup(new Error(message.error.message));
|
|
196
|
+
else if (message.type === "result") this.#options.onResult(this, message);
|
|
197
|
+
this.#options.onMessage?.(message);
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
#onExit(code: number | null, signal: string | null): void {
|
|
201
|
+
if (this.#exited) return;
|
|
202
|
+
this.#exited = true;
|
|
203
|
+
const active = this.#active;
|
|
204
|
+
this.#active = false;
|
|
205
|
+
const error = new Error(this.#stderrTail.trim() || `Python kernel exited (${code ?? signal ?? "unknown"})`);
|
|
206
|
+
this.#detachListeners();
|
|
207
|
+
if (!active) return;
|
|
208
|
+
if (!this.#settleStartup(error)) this.#options.onExit(this, error);
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
#onError(error: Error): void {
|
|
212
|
+
if (this.#exited || !this.#active) return;
|
|
213
|
+
this.#active = false;
|
|
214
|
+
if (!this.#settleStartup(error)) this.#options.onError(this, error);
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
#detachListeners(): void {
|
|
218
|
+
const detach = this.#detachChildListeners;
|
|
219
|
+
if (!detach) return;
|
|
220
|
+
this.#detachChildListeners = null;
|
|
221
|
+
detach();
|
|
222
|
+
this.#stdoutBuffer = "";
|
|
223
|
+
this.#stderrTail = "";
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
#settleStartup(error?: Error): boolean {
|
|
227
|
+
const settle = this.#settleReady;
|
|
228
|
+
if (!settle) return false;
|
|
229
|
+
this.#settleReady = null;
|
|
230
|
+
settle(error);
|
|
231
|
+
return true;
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
export function failedPythonResult(cellId: string, message: string, stack?: string): PythonTransportResult {
|
|
236
|
+
return { type: "result", cellId, ok: false, error: stack ? { message, stack } : { message }, durationMs: 0 };
|
|
237
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { BridgeConnectionConfig, KernelToHostMessage } from "../../bridge/protocol.ts";
|
|
2
|
+
import type { SubprocessSpawn } from "./subprocess-process.ts";
|
|
3
|
+
|
|
4
|
+
export interface KernelRunInput {
|
|
5
|
+
readonly cellId: string;
|
|
6
|
+
readonly code: string;
|
|
7
|
+
readonly timeoutMs?: number;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export type KernelResult = Extract<KernelToHostMessage, { type: "result" }>;
|
|
11
|
+
export type ToolCallMessage = Extract<KernelToHostMessage, { type: "tool-call" }>;
|
|
12
|
+
|
|
13
|
+
export interface SubprocessKernelOptions {
|
|
14
|
+
readonly command: string;
|
|
15
|
+
readonly args: readonly string[];
|
|
16
|
+
readonly cwd?: string;
|
|
17
|
+
readonly env?: NodeJS.ProcessEnv;
|
|
18
|
+
readonly sessionId: string;
|
|
19
|
+
readonly connection: BridgeConnectionConfig;
|
|
20
|
+
readonly spawn?: SubprocessSpawn;
|
|
21
|
+
readonly onMessage?: (message: KernelToHostMessage) => void;
|
|
22
|
+
}
|