@code-yeongyu/senpi 2026.8.29 → 2026.8.30-3
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 +172 -0
- package/dist/core/agent-session.d.ts +47 -1
- package/dist/core/agent-session.d.ts.map +1 -1
- package/dist/core/agent-session.js +406 -39
- package/dist/core/agent-session.js.map +1 -1
- package/dist/core/bash-executor.d.ts.map +1 -1
- package/dist/core/bash-executor.js +155 -37
- package/dist/core/bash-executor.js.map +1 -1
- package/dist/core/compaction/compaction-execution.d.ts +14 -0
- package/dist/core/compaction/compaction-execution.d.ts.map +1 -0
- package/dist/core/compaction/compaction-execution.js +121 -0
- package/dist/core/compaction/compaction-execution.js.map +1 -0
- package/dist/core/compaction/compaction-settings.d.ts +17 -0
- package/dist/core/compaction/compaction-settings.d.ts.map +1 -0
- package/dist/core/compaction/compaction-settings.js +17 -0
- package/dist/core/compaction/compaction-settings.js.map +1 -0
- package/dist/core/compaction/compaction.d.ts +13 -26
- package/dist/core/compaction/compaction.d.ts.map +1 -1
- package/dist/core/compaction/compaction.js +7 -136
- package/dist/core/compaction/compaction.js.map +1 -1
- package/dist/core/compaction/ideal-compaction-settings.d.ts +9 -0
- package/dist/core/compaction/ideal-compaction-settings.d.ts.map +1 -0
- package/dist/core/compaction/ideal-compaction-settings.js +7 -0
- package/dist/core/compaction/ideal-compaction-settings.js.map +1 -0
- package/dist/core/compaction-settings-access.d.ts +19 -0
- package/dist/core/compaction-settings-access.d.ts.map +1 -0
- package/dist/core/compaction-settings-access.js +10 -0
- package/dist/core/compaction-settings-access.js.map +1 -0
- package/dist/core/compaction-settings-resolver.d.ts +22 -0
- package/dist/core/compaction-settings-resolver.d.ts.map +1 -0
- package/dist/core/compaction-settings-resolver.js +46 -0
- package/dist/core/compaction-settings-resolver.js.map +1 -0
- package/dist/core/credential-accounts.d.ts.map +1 -1
- package/dist/core/credential-accounts.js +23 -9
- package/dist/core/credential-accounts.js.map +1 -1
- package/dist/core/credential-pool/env-slots.d.ts.map +1 -1
- package/dist/core/credential-pool/env-slots.js +2 -0
- package/dist/core/credential-pool/env-slots.js.map +1 -1
- package/dist/core/extensions/builtin/compaction/context-pipeline.d.ts +18 -0
- package/dist/core/extensions/builtin/compaction/context-pipeline.d.ts.map +1 -0
- package/dist/core/extensions/builtin/compaction/context-pipeline.js +32 -0
- package/dist/core/extensions/builtin/compaction/context-pipeline.js.map +1 -0
- package/dist/core/extensions/builtin/compaction/deterministic-fallback.d.ts +8 -2
- package/dist/core/extensions/builtin/compaction/deterministic-fallback.d.ts.map +1 -1
- package/dist/core/extensions/builtin/compaction/deterministic-fallback.js +164 -48
- package/dist/core/extensions/builtin/compaction/deterministic-fallback.js.map +1 -1
- package/dist/core/extensions/builtin/compaction/emergency-prune.d.ts +17 -0
- package/dist/core/extensions/builtin/compaction/emergency-prune.d.ts.map +1 -0
- package/dist/core/extensions/builtin/compaction/emergency-prune.js +64 -0
- package/dist/core/extensions/builtin/compaction/emergency-prune.js.map +1 -0
- package/dist/core/extensions/builtin/compaction/extension-wiring.d.ts +27 -0
- package/dist/core/extensions/builtin/compaction/extension-wiring.d.ts.map +1 -0
- package/dist/core/extensions/builtin/compaction/extension-wiring.js +84 -0
- package/dist/core/extensions/builtin/compaction/extension-wiring.js.map +1 -0
- package/dist/core/extensions/builtin/compaction/idle-retry.d.ts +1 -1
- package/dist/core/extensions/builtin/compaction/idle-retry.d.ts.map +1 -1
- package/dist/core/extensions/builtin/compaction/idle-retry.js +1 -1
- package/dist/core/extensions/builtin/compaction/idle-retry.js.map +1 -1
- package/dist/core/extensions/builtin/compaction/idle.d.ts +1 -0
- package/dist/core/extensions/builtin/compaction/idle.d.ts.map +1 -1
- package/dist/core/extensions/builtin/compaction/idle.js +13 -2
- package/dist/core/extensions/builtin/compaction/idle.js.map +1 -1
- package/dist/core/extensions/builtin/compaction/index.d.ts +1 -1
- package/dist/core/extensions/builtin/compaction/index.d.ts.map +1 -1
- package/dist/core/extensions/builtin/compaction/index.js +148 -150
- package/dist/core/extensions/builtin/compaction/index.js.map +1 -1
- package/dist/core/extensions/builtin/compaction/log.d.ts +1 -1
- package/dist/core/extensions/builtin/compaction/log.d.ts.map +1 -1
- package/dist/core/extensions/builtin/compaction/log.js +2 -0
- package/dist/core/extensions/builtin/compaction/log.js.map +1 -1
- package/dist/core/extensions/builtin/compaction/model-selection.d.ts +14 -0
- package/dist/core/extensions/builtin/compaction/model-selection.d.ts.map +1 -0
- package/dist/core/extensions/builtin/compaction/model-selection.js +37 -0
- package/dist/core/extensions/builtin/compaction/model-selection.js.map +1 -0
- package/dist/core/extensions/builtin/compaction/model-usability-budget.d.ts +30 -0
- package/dist/core/extensions/builtin/compaction/model-usability-budget.d.ts.map +1 -0
- package/dist/core/extensions/builtin/compaction/model-usability-budget.js +74 -0
- package/dist/core/extensions/builtin/compaction/model-usability-budget.js.map +1 -0
- package/dist/core/extensions/builtin/compaction/openai-remote-dependencies.d.ts +9 -0
- package/dist/core/extensions/builtin/compaction/openai-remote-dependencies.d.ts.map +1 -0
- package/dist/core/extensions/builtin/compaction/openai-remote-dependencies.js +2 -0
- package/dist/core/extensions/builtin/compaction/openai-remote-dependencies.js.map +1 -0
- package/dist/core/extensions/builtin/compaction/openai-remote.d.ts +3 -6
- package/dist/core/extensions/builtin/compaction/openai-remote.d.ts.map +1 -1
- package/dist/core/extensions/builtin/compaction/openai-remote.js.map +1 -1
- package/dist/core/extensions/builtin/compaction/orchestration.d.ts +46 -0
- package/dist/core/extensions/builtin/compaction/orchestration.d.ts.map +1 -0
- package/dist/core/extensions/builtin/compaction/orchestration.js +103 -0
- package/dist/core/extensions/builtin/compaction/orchestration.js.map +1 -0
- package/dist/core/extensions/builtin/compaction/policy.d.ts +12 -2
- package/dist/core/extensions/builtin/compaction/policy.d.ts.map +1 -1
- package/dist/core/extensions/builtin/compaction/policy.js +52 -26
- package/dist/core/extensions/builtin/compaction/policy.js.map +1 -1
- package/dist/core/extensions/builtin/compaction/retained-message-safety.d.ts.map +1 -1
- package/dist/core/extensions/builtin/compaction/retained-message-safety.js +31 -8
- package/dist/core/extensions/builtin/compaction/retained-message-safety.js.map +1 -1
- package/dist/core/extensions/builtin/compaction/speculation-lead.d.ts +8 -0
- package/dist/core/extensions/builtin/compaction/speculation-lead.d.ts.map +1 -0
- package/dist/core/extensions/builtin/compaction/speculation-lead.js +17 -0
- package/dist/core/extensions/builtin/compaction/speculation-lead.js.map +1 -0
- package/dist/core/extensions/builtin/compaction/speculative-job.d.ts +22 -0
- package/dist/core/extensions/builtin/compaction/speculative-job.d.ts.map +1 -0
- package/dist/core/extensions/builtin/compaction/speculative-job.js +16 -0
- package/dist/core/extensions/builtin/compaction/speculative-job.js.map +1 -0
- package/dist/core/extensions/builtin/compaction/speculative-summary.d.ts +22 -0
- package/dist/core/extensions/builtin/compaction/speculative-summary.d.ts.map +1 -0
- package/dist/core/extensions/builtin/compaction/speculative-summary.js +131 -0
- package/dist/core/extensions/builtin/compaction/speculative-summary.js.map +1 -0
- package/dist/core/extensions/builtin/compaction/speculative.d.ts +8 -13
- package/dist/core/extensions/builtin/compaction/speculative.d.ts.map +1 -1
- package/dist/core/extensions/builtin/compaction/speculative.js +7 -196
- package/dist/core/extensions/builtin/compaction/speculative.js.map +1 -1
- package/dist/core/extensions/builtin/compaction/token-budget-reminder.d.ts +24 -0
- package/dist/core/extensions/builtin/compaction/token-budget-reminder.d.ts.map +1 -0
- package/dist/core/extensions/builtin/compaction/token-budget-reminder.js +25 -0
- package/dist/core/extensions/builtin/compaction/token-budget-reminder.js.map +1 -0
- package/dist/core/extensions/builtin/compaction/tool-admission.d.ts +27 -0
- package/dist/core/extensions/builtin/compaction/tool-admission.d.ts.map +1 -0
- package/dist/core/extensions/builtin/compaction/tool-admission.js +56 -0
- package/dist/core/extensions/builtin/compaction/tool-admission.js.map +1 -0
- package/dist/core/extensions/builtin/cursor-cli-oauth/stream.d.ts.map +1 -1
- package/dist/core/extensions/builtin/cursor-cli-oauth/stream.js +8 -28
- package/dist/core/extensions/builtin/cursor-cli-oauth/stream.js.map +1 -1
- package/dist/core/extensions/builtin/permission-system/external-dir.d.ts.map +1 -1
- package/dist/core/extensions/builtin/permission-system/external-dir.js +15 -5
- package/dist/core/extensions/builtin/permission-system/external-dir.js.map +1 -1
- package/dist/core/extensions/builtin/permission-system/parsers.d.ts.map +1 -1
- package/dist/core/extensions/builtin/permission-system/parsers.js +16 -1
- package/dist/core/extensions/builtin/permission-system/parsers.js.map +1 -1
- package/dist/core/extensions/builtin/terminal/manager.d.ts +5 -0
- package/dist/core/extensions/builtin/terminal/manager.d.ts.map +1 -1
- package/dist/core/extensions/builtin/terminal/manager.js +31 -3
- package/dist/core/extensions/builtin/terminal/manager.js.map +1 -1
- package/dist/core/extensions/builtin/terminal/monitor-permission.d.ts +8 -0
- package/dist/core/extensions/builtin/terminal/monitor-permission.d.ts.map +1 -0
- package/dist/core/extensions/builtin/terminal/monitor-permission.js +16 -0
- package/dist/core/extensions/builtin/terminal/monitor-permission.js.map +1 -0
- package/dist/core/extensions/builtin/terminal/monitor-registry.d.ts +13 -0
- package/dist/core/extensions/builtin/terminal/monitor-registry.d.ts.map +1 -1
- package/dist/core/extensions/builtin/terminal/monitor-registry.js +403 -3
- package/dist/core/extensions/builtin/terminal/monitor-registry.js.map +1 -1
- package/dist/core/extensions/builtin/terminal/runtime-session.d.ts +11 -0
- package/dist/core/extensions/builtin/terminal/runtime-session.d.ts.map +1 -1
- package/dist/core/extensions/builtin/terminal/runtime-session.js +18 -2
- package/dist/core/extensions/builtin/terminal/runtime-session.js.map +1 -1
- package/dist/core/extensions/builtin/terminal/session-bundle.d.ts.map +1 -1
- package/dist/core/extensions/builtin/terminal/session-bundle.js +1 -0
- package/dist/core/extensions/builtin/terminal/session-bundle.js.map +1 -1
- package/dist/core/extensions/builtin/terminal/tools/kill-bash.d.ts.map +1 -1
- package/dist/core/extensions/builtin/terminal/tools/kill-bash.js +5 -2
- package/dist/core/extensions/builtin/terminal/tools/kill-bash.js.map +1 -1
- package/dist/core/extensions/builtin/terminal/tools/monitor.d.ts +4 -0
- package/dist/core/extensions/builtin/terminal/tools/monitor.d.ts.map +1 -1
- package/dist/core/extensions/builtin/terminal/tools/monitor.js +40 -2
- package/dist/core/extensions/builtin/terminal/tools/monitor.js.map +1 -1
- package/dist/core/model-resolver.js +2 -2
- package/dist/core/model-resolver.js.map +1 -1
- package/dist/core/sdk.d.ts.map +1 -1
- package/dist/core/sdk.js +5 -0
- package/dist/core/sdk.js.map +1 -1
- package/dist/core/session-manager.d.ts.map +1 -1
- package/dist/core/session-manager.js +10 -1
- package/dist/core/session-manager.js.map +1 -1
- package/dist/core/settings-manager.d.ts +15 -85
- package/dist/core/settings-manager.d.ts.map +1 -1
- package/dist/core/settings-manager.js +15 -17
- package/dist/core/settings-manager.js.map +1 -1
- package/dist/core/settings-public-types.d.ts +11 -0
- package/dist/core/settings-public-types.d.ts.map +1 -0
- package/dist/core/settings-public-types.js +2 -0
- package/dist/core/settings-public-types.js.map +1 -0
- package/dist/core/settings-shapes.d.ts +36 -0
- package/dist/core/settings-shapes.d.ts.map +1 -0
- package/dist/core/settings-shapes.js +2 -0
- package/dist/core/settings-shapes.js.map +1 -0
- package/dist/core/shared-host-policy.d.ts +6 -0
- package/dist/core/shared-host-policy.d.ts.map +1 -0
- package/dist/core/shared-host-policy.js +7 -0
- package/dist/core/shared-host-policy.js.map +1 -0
- package/dist/core/terminal-settings.d.ts +22 -0
- package/dist/core/terminal-settings.d.ts.map +1 -0
- package/dist/core/terminal-settings.js +2 -0
- package/dist/core/terminal-settings.js.map +1 -0
- package/dist/core/tools/bash.d.ts.map +1 -1
- package/dist/core/tools/bash.js +97 -15
- package/dist/core/tools/bash.js.map +1 -1
- package/dist/core/tools/index.d.ts +1 -0
- package/dist/core/tools/index.d.ts.map +1 -1
- package/dist/core/tools/index.js +8 -0
- package/dist/core/tools/index.js.map +1 -1
- package/dist/core/tools/output-accumulator.d.ts +1 -1
- package/dist/core/tools/output-accumulator.d.ts.map +1 -1
- package/dist/core/tools/output-accumulator.js +76 -34
- package/dist/core/tools/output-accumulator.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/main.d.ts.map +1 -1
- package/dist/main.js +17 -5
- package/dist/main.js.map +1 -1
- package/dist/modes/index.d.ts +1 -1
- package/dist/modes/index.d.ts.map +1 -1
- package/dist/modes/index.js +1 -1
- package/dist/modes/index.js.map +1 -1
- package/dist/modes/interactive/components/footer.d.ts +7 -0
- package/dist/modes/interactive/components/footer.d.ts.map +1 -1
- package/dist/modes/interactive/components/footer.js +34 -8
- package/dist/modes/interactive/components/footer.js.map +1 -1
- package/dist/modes/interactive/grok/chrome.d.ts +2 -0
- package/dist/modes/interactive/grok/chrome.d.ts.map +1 -1
- package/dist/modes/interactive/grok/chrome.js.map +1 -1
- package/dist/modes/interactive/interactive-host-runtime.d.ts +132 -1
- package/dist/modes/interactive/interactive-host-runtime.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-host-runtime.js +633 -117
- package/dist/modes/interactive/interactive-host-runtime.js.map +1 -1
- package/dist/modes/interactive/interactive-mode.d.ts +7 -0
- package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-mode.js +114 -2
- package/dist/modes/interactive/interactive-mode.js.map +1 -1
- package/dist/modes/rpc/connection-handler.d.ts +8 -1
- package/dist/modes/rpc/connection-handler.d.ts.map +1 -1
- package/dist/modes/rpc/connection-handler.js +158 -49
- package/dist/modes/rpc/connection-handler.js.map +1 -1
- package/dist/modes/rpc/host-ensure.d.ts +19 -0
- package/dist/modes/rpc/host-ensure.d.ts.map +1 -1
- package/dist/modes/rpc/host-ensure.js +79 -15
- package/dist/modes/rpc/host-ensure.js.map +1 -1
- package/dist/modes/rpc/host-lifecycle.d.ts +29 -0
- package/dist/modes/rpc/host-lifecycle.d.ts.map +1 -1
- package/dist/modes/rpc/host-lifecycle.js +96 -25
- package/dist/modes/rpc/host-lifecycle.js.map +1 -1
- package/dist/modes/rpc/host-watchdog.d.ts +2 -0
- package/dist/modes/rpc/host-watchdog.d.ts.map +1 -1
- package/dist/modes/rpc/host-watchdog.js +23 -12
- package/dist/modes/rpc/host-watchdog.js.map +1 -1
- package/dist/modes/rpc/multi-session-host.js +6 -4
- package/dist/modes/rpc/multi-session-host.js.map +1 -1
- package/dist/modes/rpc/rpc-client.d.ts +20 -4
- package/dist/modes/rpc/rpc-client.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-client.js +76 -17
- package/dist/modes/rpc/rpc-client.js.map +1 -1
- package/dist/modes/rpc/rpc-input-validation.d.ts +1 -0
- package/dist/modes/rpc/rpc-input-validation.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-input-validation.js +66 -0
- package/dist/modes/rpc/rpc-input-validation.js.map +1 -1
- package/dist/modes/rpc/rpc-types.d.ts +86 -1
- package/dist/modes/rpc/rpc-types.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-types.js.map +1 -1
- package/dist/modes/rpc/session-binding.d.ts +1 -0
- package/dist/modes/rpc/session-binding.d.ts.map +1 -1
- package/dist/modes/rpc/session-binding.js +21 -1
- package/dist/modes/rpc/session-binding.js.map +1 -1
- package/dist/modes/rpc/session-command-router.d.ts.map +1 -1
- package/dist/modes/rpc/session-command-router.js +1 -0
- package/dist/modes/rpc/session-command-router.js.map +1 -1
- package/dist/modes/rpc/session-event-writer.d.ts +2 -0
- package/dist/modes/rpc/session-event-writer.d.ts.map +1 -1
- package/dist/modes/rpc/session-event-writer.js +54 -7
- package/dist/modes/rpc/session-event-writer.js.map +1 -1
- package/dist/modes/rpc/session-extension-ui-requests.d.ts +1 -0
- package/dist/modes/rpc/session-extension-ui-requests.d.ts.map +1 -1
- package/dist/modes/rpc/session-extension-ui-requests.js +5 -0
- package/dist/modes/rpc/session-extension-ui-requests.js.map +1 -1
- package/dist/modes/rpc/session-registry.d.ts +10 -2
- package/dist/modes/rpc/session-registry.d.ts.map +1 -1
- package/dist/modes/rpc/session-registry.js +58 -4
- package/dist/modes/rpc/session-registry.js.map +1 -1
- package/dist/modes/rpc/socket-event-fanout.d.ts +22 -0
- package/dist/modes/rpc/socket-event-fanout.d.ts.map +1 -0
- package/dist/modes/rpc/socket-event-fanout.js +84 -0
- package/dist/modes/rpc/socket-event-fanout.js.map +1 -0
- package/docs/rpc.md +22 -2
- package/docs/settings.md +34 -0
- package/docs/windows.md +2 -0
- package/node_modules/@code-yeongyu/senpi-codemode/CHANGELOG.md +62 -0
- package/node_modules/@code-yeongyu/senpi-codemode/package.json +4 -4
- package/node_modules/@code-yeongyu/senpi-codemode/src/kernels/js/worker-indirect-eval.js +139 -90
- package/node_modules/@code-yeongyu/senpi-codemode/src/prompt/eval-prompt.ts +4 -4
- package/node_modules/@earendil-works/pi-agent-core/dist/harness/env/nodejs.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-agent-core/dist/harness/env/nodejs.js +40 -20
- package/node_modules/@earendil-works/pi-agent-core/dist/harness/env/nodejs.js.map +1 -1
- package/node_modules/@earendil-works/pi-agent-core/dist/harness/types.d.ts +3 -3
- package/node_modules/@earendil-works/pi-agent-core/dist/harness/types.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-agent-core/dist/harness/types.js.map +1 -1
- package/node_modules/@earendil-works/pi-agent-core/dist/harness/utils/shell-output.d.ts +1 -1
- package/node_modules/@earendil-works/pi-agent-core/dist/harness/utils/shell-output.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-agent-core/dist/harness/utils/shell-output.js +28 -9
- package/node_modules/@earendil-works/pi-agent-core/dist/harness/utils/shell-output.js.map +1 -1
- package/node_modules/@earendil-works/pi-agent-core/package.json +3 -3
- 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 +67 -38
- package/node_modules/@earendil-works/pi-ai/dist/api/anthropic-messages.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/api/cursor-agent/measure.d.ts +20 -0
- package/node_modules/@earendil-works/pi-ai/dist/api/cursor-agent/measure.d.ts.map +1 -0
- package/node_modules/@earendil-works/pi-ai/dist/api/cursor-agent/measure.js +443 -0
- package/node_modules/@earendil-works/pi-ai/dist/api/cursor-agent/measure.js.map +1 -0
- package/node_modules/@earendil-works/pi-ai/dist/api/cursor-agent.d.ts +2 -0
- package/node_modules/@earendil-works/pi-ai/dist/api/cursor-agent.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/api/cursor-agent.js +2 -0
- package/node_modules/@earendil-works/pi-ai/dist/api/cursor-agent.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/api/openai-completions.js +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/api/openai-completions.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/index.d.ts +1 -0
- package/node_modules/@earendil-works/pi-ai/dist/index.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/index.js +1 -0
- package/node_modules/@earendil-works/pi-ai/dist/index.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/data/.manifest.json +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/data/cloudflare-ai-gateway.json +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/data/cloudflare-workers-ai.json +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/data/fireworks.json +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/data/opencode-go.json +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/data/opencode.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/zai-coding-cn.json +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/data/zai.json +1 -1
- package/node_modules/@earendil-works/pi-ai/package.json +2 -2
- package/node_modules/@earendil-works/pi-pty/dist/screen-operations.d.ts +42 -0
- package/node_modules/@earendil-works/pi-pty/dist/screen-operations.d.ts.map +1 -0
- package/node_modules/@earendil-works/pi-pty/dist/screen-operations.js +34 -0
- package/node_modules/@earendil-works/pi-pty/dist/screen-operations.js.map +1 -0
- package/node_modules/@earendil-works/pi-pty/dist/screen-text.d.ts +8 -0
- package/node_modules/@earendil-works/pi-pty/dist/screen-text.d.ts.map +1 -0
- package/node_modules/@earendil-works/pi-pty/dist/screen-text.js +51 -0
- package/node_modules/@earendil-works/pi-pty/dist/screen-text.js.map +1 -0
- package/node_modules/@earendil-works/pi-pty/dist/screen.d.ts +45 -0
- package/node_modules/@earendil-works/pi-pty/dist/screen.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-pty/dist/screen.js +178 -55
- package/node_modules/@earendil-works/pi-pty/dist/screen.js.map +1 -1
- 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/dist/components/editor.d.ts +7 -0
- package/node_modules/@earendil-works/pi-tui/dist/components/editor.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-tui/dist/components/editor.js +5 -0
- package/node_modules/@earendil-works/pi-tui/dist/components/editor.js.map +1 -1
- package/node_modules/@earendil-works/pi-tui/dist/mux.d.ts +1 -1
- package/node_modules/@earendil-works/pi-tui/dist/mux.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-tui/dist/mux.js +2 -2
- package/node_modules/@earendil-works/pi-tui/dist/mux.js.map +1 -1
- package/node_modules/@earendil-works/pi-tui/dist/terminal.d.ts +1 -0
- package/node_modules/@earendil-works/pi-tui/dist/terminal.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-tui/dist/terminal.js +19 -0
- package/node_modules/@earendil-works/pi-tui/dist/terminal.js.map +1 -1
- package/node_modules/@earendil-works/pi-tui/package.json +1 -1
- package/package.json +7 -7
|
@@ -13,6 +13,16 @@ export class TerminalRuntimeSession {
|
|
|
13
13
|
this.consumed = 0;
|
|
14
14
|
this.outputListeners = new Set();
|
|
15
15
|
this.unsubscribeData = null;
|
|
16
|
+
/**
|
|
17
|
+
* The screen is a best-effort projection; a rejected feed/resize must never
|
|
18
|
+
* become an unhandled rejection that kills the host process (#837), and
|
|
19
|
+
* `buffer` remains the source of truth for reads. The screen hands every
|
|
20
|
+
* caller coalesced into one queued operation the same memoized promise, so
|
|
21
|
+
* attach the rejection handler once per distinct promise - re-attaching per
|
|
22
|
+
* PTY chunk would grow promise reactions without bound while a replay is
|
|
23
|
+
* stalled behind a slow parser.
|
|
24
|
+
*/
|
|
25
|
+
this.lastScreenWrite = null;
|
|
16
26
|
this.command = command;
|
|
17
27
|
this.screen = new TerminalScreen({
|
|
18
28
|
cols: options.cols,
|
|
@@ -52,7 +62,7 @@ export class TerminalRuntimeSession {
|
|
|
52
62
|
const text = this.decoder.decode(chunk, { stream: true });
|
|
53
63
|
if (text.length === 0)
|
|
54
64
|
return text;
|
|
55
|
-
|
|
65
|
+
this.ownScreenWrite(this.screen.feed(text));
|
|
56
66
|
this.buffer += text;
|
|
57
67
|
if (this.buffer.length > MAX_SESSION_OUTPUT_CHARS) {
|
|
58
68
|
const overflow = this.buffer.length - MAX_SESSION_OUTPUT_CHARS;
|
|
@@ -82,7 +92,13 @@ export class TerminalRuntimeSession {
|
|
|
82
92
|
return this.screen.snapshot();
|
|
83
93
|
}
|
|
84
94
|
resizeScreen(cols, rows) {
|
|
85
|
-
|
|
95
|
+
this.ownScreenWrite(this.screen.resize(cols, rows));
|
|
96
|
+
}
|
|
97
|
+
ownScreenWrite(written) {
|
|
98
|
+
if (written === this.lastScreenWrite)
|
|
99
|
+
return;
|
|
100
|
+
this.lastScreenWrite = written;
|
|
101
|
+
written.catch(() => { });
|
|
86
102
|
}
|
|
87
103
|
dispose() {
|
|
88
104
|
this.unsubscribeData?.();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runtime-session.js","sourceRoot":"","sources":["../../../../../src/core/extensions/builtin/terminal/runtime-session.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,cAAc,EAEd,eAAe,GAGf,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,kBAAkB,EAAE,wBAAwB,EAAE,MAAM,aAAa,CAAC;AAW3E;;;;GAIG;AACH,MAAM,OAAO,sBAAsB;IAWlC,YAAY,OAAe,EAAE,OAA+B;QAP3C,YAAO,GAAG,IAAI,WAAW,CAAC,OAAO,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC,CAAC;QAC9D,WAAM,GAAG,EAAE,CAAC;QACZ,iBAAY,GAAG,CAAC,CAAC;QACjB,aAAQ,GAAG,CAAC,CAAC;QACJ,oBAAe,GAAG,IAAI,GAAG,EAA2B,CAAC;QAC9D,oBAAe,GAAwB,IAAI,CAAC;
|
|
1
|
+
{"version":3,"file":"runtime-session.js","sourceRoot":"","sources":["../../../../../src/core/extensions/builtin/terminal/runtime-session.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,cAAc,EAEd,eAAe,GAGf,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,kBAAkB,EAAE,wBAAwB,EAAE,MAAM,aAAa,CAAC;AAW3E;;;;GAIG;AACH,MAAM,OAAO,sBAAsB;IAWlC,YAAY,OAAe,EAAE,OAA+B;QAP3C,YAAO,GAAG,IAAI,WAAW,CAAC,OAAO,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC,CAAC;QAC9D,WAAM,GAAG,EAAE,CAAC;QACZ,iBAAY,GAAG,CAAC,CAAC;QACjB,aAAQ,GAAG,CAAC,CAAC;QACJ,oBAAe,GAAG,IAAI,GAAG,EAA2B,CAAC;QAC9D,oBAAe,GAAwB,IAAI,CAAC;QAkFpD;;;;;;;;WAQG;QACK,oBAAe,GAAyB,IAAI,CAAC;QAxFpD,IAAI,CAAC,OAAO,GAAG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QACT,OAAO,IAAI,CAAC,MAAM,CAAC;IACpB,CAAC;IAED,QAAQ;QACP,OAAO,IAAI,CAAC,MAAM,CAAC,QAAQ,EAAE,CAAC;IAC/B,CAAC;IAED,YAAY,CAAC,IAAY,EAAE,IAAY;QACtC,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC;IACrD,CAAC;IAaO,cAAc,CAAC,OAAsB;QAC5C,IAAI,OAAO,KAAK,IAAI,CAAC,eAAe;YAAE,OAAO;QAC7C,IAAI,CAAC,eAAe,GAAG,OAAO,CAAC;QAC/B,OAAO,CAAC,KAAK,CAAC,GAAG,EAAE,GAAE,CAAC,CAAC,CAAC;IACzB,CAAC;IAED,OAAO;QACN,IAAI,CAAC,eAAe,EAAE,EAAE,CAAC;QACzB,IAAI,CAAC,eAAe,GAAG,IAAI,CAAC;QAC5B,IAAI,CAAC,eAAe,CAAC,KAAK,EAAE,CAAC;QAC7B,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC;IACvB,CAAC;CACD","sourcesContent":["import {\n\tTerminalScreen,\n\ttype TerminalScreenSnapshot,\n\tTerminalSession,\n\ttype TerminalSessionExit,\n\ttype TerminalSessionOptions,\n} from \"@earendil-works/pi-pty\";\nimport { DEFAULT_SCROLLBACK, MAX_SESSION_OUTPUT_CHARS } from \"./shared.ts\";\n\nexport interface TerminalRuntimeOptions extends TerminalSessionOptions {\n\treadonly scrollback?: number;\n}\n\nexport interface DeltaRead {\n\treadonly text: string;\n\treadonly droppedChars: number;\n}\n\n/**\n * A live terminal session: a pi-pty {@link TerminalSession} plus an xterm screen model\n * and a bounded decoded-output buffer with a per-consumer read cursor. Reads are pure\n * non-blocking peeks; watchers subscribe through `onOutput` (the monitor path).\n */\nexport class TerminalRuntimeSession {\n\treadonly session: TerminalSession;\n\treadonly command: string;\n\tprivate readonly screen: TerminalScreen;\n\tprivate readonly decoder = new TextDecoder(\"utf-8\", { fatal: false });\n\tprivate buffer = \"\";\n\tprivate droppedChars = 0;\n\tprivate consumed = 0;\n\tprivate readonly outputListeners = new Set<(chunk: string) => void>();\n\tprivate unsubscribeData: (() => void) | null = null;\n\n\tconstructor(command: string, options: TerminalRuntimeOptions) {\n\t\tthis.command = command;\n\t\tthis.screen = new TerminalScreen({\n\t\t\tcols: options.cols,\n\t\t\trows: options.rows,\n\t\t\tscrollback: options.scrollback ?? DEFAULT_SCROLLBACK,\n\t\t});\n\t\tthis.session = new TerminalSession(options);\n\t\tthis.unsubscribeData = this.session.onData((chunk) => {\n\t\t\tconst text = this.ingest(chunk);\n\t\t\tif (text.length === 0) return;\n\t\t\tfor (const listener of this.outputListeners) {\n\t\t\t\ttry {\n\t\t\t\t\tlistener(text);\n\t\t\t\t} catch {\n\t\t\t\t\t// Output observers must not interfere with the session's ingest path.\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\t\tthis.session.start();\n\t}\n\n\tget backend(): string | null {\n\t\treturn this.session.backend;\n\t}\n\n\tget exited(): boolean {\n\t\treturn this.session.exited;\n\t}\n\n\tget exitResult(): TerminalSessionExit | null {\n\t\treturn this.session.exitResult;\n\t}\n\n\t/** Total decoded chars produced so far (including any dropped from the front). */\n\tget totalChars(): number {\n\t\treturn this.droppedChars + this.buffer.length;\n\t}\n\n\tprivate ingest(chunk: Uint8Array): string {\n\t\tconst text = this.decoder.decode(chunk, { stream: true });\n\t\tif (text.length === 0) return text;\n\t\tthis.ownScreenWrite(this.screen.feed(text));\n\t\tthis.buffer += text;\n\t\tif (this.buffer.length > MAX_SESSION_OUTPUT_CHARS) {\n\t\t\tconst overflow = this.buffer.length - MAX_SESSION_OUTPUT_CHARS;\n\t\t\tthis.buffer = this.buffer.slice(overflow);\n\t\t\tthis.droppedChars += overflow;\n\t\t}\n\t\treturn text;\n\t}\n\n\t/** Subscribe to decoded output without affecting the read cursor. */\n\tonOutput(listener: (chunk: string) => void): () => void {\n\t\tthis.outputListeners.add(listener);\n\t\treturn () => this.outputListeners.delete(listener);\n\t}\n\n\t/** Return output produced since the last read and advance the read cursor. */\n\treadDelta(): DeltaRead {\n\t\tconst start = Math.max(this.consumed, this.droppedChars);\n\t\tconst dropped = Math.max(0, this.droppedChars - this.consumed);\n\t\tconst text = this.buffer.slice(start - this.droppedChars);\n\t\tthis.consumed = this.totalChars;\n\t\treturn { text, droppedChars: dropped };\n\t}\n\n\t/** Full retained decoded output (`view:\"log\"`), without advancing the cursor. */\n\tfullOutput(): string {\n\t\treturn this.buffer;\n\t}\n\n\tsnapshot(): TerminalScreenSnapshot {\n\t\treturn this.screen.snapshot();\n\t}\n\n\tresizeScreen(cols: number, rows: number): void {\n\t\tthis.ownScreenWrite(this.screen.resize(cols, rows));\n\t}\n\n\t/**\n\t * The screen is a best-effort projection; a rejected feed/resize must never\n\t * become an unhandled rejection that kills the host process (#837), and\n\t * `buffer` remains the source of truth for reads. The screen hands every\n\t * caller coalesced into one queued operation the same memoized promise, so\n\t * attach the rejection handler once per distinct promise - re-attaching per\n\t * PTY chunk would grow promise reactions without bound while a replay is\n\t * stalled behind a slow parser.\n\t */\n\tprivate lastScreenWrite: Promise<void> | null = null;\n\n\tprivate ownScreenWrite(written: Promise<void>): void {\n\t\tif (written === this.lastScreenWrite) return;\n\t\tthis.lastScreenWrite = written;\n\t\twritten.catch(() => {});\n\t}\n\n\tdispose(): void {\n\t\tthis.unsubscribeData?.();\n\t\tthis.unsubscribeData = null;\n\t\tthis.outputListeners.clear();\n\t\tthis.screen.dispose();\n\t}\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"session-bundle.d.ts","sourceRoot":"","sources":["../../../../../src/core/extensions/builtin/terminal/session-bundle.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,2BAA2B,CAAC;AACrE,OAAO,EAAE,eAAe,EAAE,KAAK,sBAAsB,EAAE,MAAM,cAAc,CAAC;AAC5E,OAAO,EAAE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,KAAK,IAAI,CAAC;IAC7E,QAAQ,CAAC,iBAAiB,EAAE,CAAC,QAAQ,EAAE,SAAS,mBAAmB,EAAE,KAAK,IAAI,CAAC;IAC/E,QAAQ,CAAC,gBAAgB,EAAE,CAAC,EAAE,EAAE,MAAM,EAAE,OAAO,EAAE,sBAAsB,KAAK,IAAI,CAAC;CACjF;AAKD;;;;;;GAMG;AACH,qBAAa,qBAAqB;;IACjC,QAAQ,CAAC,OAAO,EAAE,eAAe,CAAC;IAClC,QAAQ,CAAC,QAAQ,EAAE,eAAe,CAAC;gBAOvB,OAAO,EAAE,sBAAsB;IAQ3C,gGAAgG;IAChG,IAAI,CAAC,KAAK,EAAE,kBAAkB,GAAG,IAAI;IAarC,IAAI,IAAI,IAAI;IAIZ,kBAAkB,IAAI,SAAS,mBAAmB,EAAE;IAIpD,qBAAqB,CAAC,EAAE,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,EAAE,WAAW,SAAa,GAAG,IAAI;IAMtF,oBAAoB,CAAC,EAAE,EAAE,MAAM,EAAE,OAAO,EAAE,sBAAsB,GAAG,IAAI;IAWjE,QAAQ,IAAI,OAAO,CAAC,IAAI,CAAC;CAuB/B;AAID,kGAAkG;AAClG,wBAAsB,UAAU,CAAC,UAAU,EAAE,MAAM,EAAE,MAAM,EAAE,qBAAqB,GAAG,OAAO,CAAC,IAAI,CAAC,CAIjG;AAED,wBAAgB,iBAAiB,CAAC,UAAU,EAAE,MAAM,GAAG,qBAAqB,GAAG,SAAS,CAIvF;AAED,wBAAsB,oBAAoB,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAI5E"}
|
|
@@ -19,6 +19,7 @@ export class TerminalSessionBundle {
|
|
|
19
19
|
this.manager = new TerminalManager(options);
|
|
20
20
|
this.monitors = new MonitorRegistry((event) => this.#dispatchMonitorEvent(event), {
|
|
21
21
|
onChange: (snapshot) => this.#sinks?.onMonitorState(snapshot),
|
|
22
|
+
reserve: () => this.manager.reserve(),
|
|
22
23
|
});
|
|
23
24
|
}
|
|
24
25
|
/** Install live sinks, re-publish channel state, and flush everything buffered while parked. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"session-bundle.js","sourceRoot":"","sources":["../../../../../src/core/extensions/builtin/terminal/session-bundle.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAA+B,MAAM,cAAc,CAAC;AAC5E,OAAO,EAAqB,eAAe,EAA6B,MAAM,uBAAuB,CAAC;AAUtG,MAAM,yBAAyB,GAAG,GAAG,CAAC;AACtC,MAAM,gBAAgB,GAAG,EAAE,CAAC;AAE5B;;;;;;GAMG;AACH,MAAM,OAAO,qBAAqB;IAGjC,MAAM,GAA8B,IAAI,CAAC;IACzC,oBAAoB,GAAmB,EAAE,CAAC;IAC1C,YAAY,GAAG,IAAI,GAAG,EAAkC,CAAC;IACzD,YAAY,GAAG,IAAI,GAAG,EAA+B,CAAC;IACtD,SAAS,GAAG,KAAK,CAAC;IAElB,YAAY,OAA+B;QAC1C,IAAI,CAAC,OAAO,GAAG,IAAI,eAAe,CAAC,OAAO,CAAC,CAAC;QAC5C,IAAI,CAAC,QAAQ,GAAG,IAAI,eAAe,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,IAAI,CAAC,qBAAqB,CAAC,KAAK,CAAC,EAAE;YACjF,QAAQ,EAAE,CAAC,QAAQ,EAAE,EAAE,CAAC,IAAI,CAAC,MAAM,EAAE,cAAc,CAAC,QAAQ,CAAC;
|
|
1
|
+
{"version":3,"file":"session-bundle.js","sourceRoot":"","sources":["../../../../../src/core/extensions/builtin/terminal/session-bundle.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAA+B,MAAM,cAAc,CAAC;AAC5E,OAAO,EAAqB,eAAe,EAA6B,MAAM,uBAAuB,CAAC;AAUtG,MAAM,yBAAyB,GAAG,GAAG,CAAC;AACtC,MAAM,gBAAgB,GAAG,EAAE,CAAC;AAE5B;;;;;;GAMG;AACH,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AAG,aAAa,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC;IAC7C,aAAa,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC;IACjC,OAAO,MAAM,CAAC;AACf,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,oBAAoB,CAAC,UAAkB;IAC5D,MAAM,MAAM,GAAG,aAAa,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC;IAC7C,aAAa,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC;IACjC,MAAM,MAAM,EAAE,QAAQ,EAAE,CAAC;AAC1B,CAAC","sourcesContent":["import type { WakeSourceStateItem } from \"../monitor-state-event.ts\";\nimport { TerminalManager, type TerminalManagerOptions } from \"./manager.ts\";\nimport { type MonitorEvent, MonitorRegistry, type MonitorSnapshotEntry } from \"./monitor-registry.ts\";\nimport type { TerminalRuntimeSession } from \"./runtime-session.ts\";\n\nexport interface TerminalEventSinks {\n\treadonly onMonitorEvent: (event: MonitorEvent) => void;\n\treadonly onMonitorState: (snapshot: readonly MonitorSnapshotEntry[]) => void;\n\treadonly onBackgroundState: (snapshot: readonly WakeSourceStateItem[]) => void;\n\treadonly onBackgroundExit: (id: string, runtime: TerminalRuntimeSession) => void;\n}\n\nconst MAX_PARKED_MONITOR_EVENTS = 100;\nconst MAX_PARKED_EXITS = 32;\n\n/**\n * The long-lived terminal runtime for one agent session: the PTY session manager plus\n * the monitor registry. A session reload replaces the extension runner and re-runs the\n * extension factory, so this state must outlive any single extension instance; event\n * routing goes through mutable sinks the current owner instance binds. While parked\n * (the reload window, or a headless reload that never re-binds) events buffer bounded.\n */\nexport class TerminalSessionBundle {\n\treadonly manager: TerminalManager;\n\treadonly monitors: MonitorRegistry;\n\t#sinks: TerminalEventSinks | null = null;\n\t#parkedMonitorEvents: MonitorEvent[] = [];\n\t#parkedExits = new Map<string, TerminalRuntimeSession>();\n\t#backgrounds = new Map<string, WakeSourceStateItem>();\n\t#torndown = false;\n\n\tconstructor(options: TerminalManagerOptions) {\n\t\tthis.manager = new TerminalManager(options);\n\t\tthis.monitors = new MonitorRegistry((event) => this.#dispatchMonitorEvent(event), {\n\t\t\tonChange: (snapshot) => this.#sinks?.onMonitorState(snapshot),\n\t\t\treserve: () => this.manager.reserve(),\n\t\t});\n\t}\n\n\t/** Install live sinks, re-publish channel state, and flush everything buffered while parked. */\n\tbind(sinks: TerminalEventSinks): void {\n\t\tif (this.#torndown) return;\n\t\tthis.#sinks = sinks;\n\t\tconst parkedMonitorEvents = this.#parkedMonitorEvents;\n\t\tthis.#parkedMonitorEvents = [];\n\t\tconst parkedExits = [...this.#parkedExits];\n\t\tthis.#parkedExits.clear();\n\t\tsinks.onMonitorState(this.monitors.snapshot());\n\t\tsinks.onBackgroundState(this.backgroundSnapshot());\n\t\tfor (const event of parkedMonitorEvents) sinks.onMonitorEvent(event);\n\t\tfor (const [id, runtime] of parkedExits) sinks.onBackgroundExit(id, runtime);\n\t}\n\n\tpark(): void {\n\t\tthis.#sinks = null;\n\t}\n\n\tbackgroundSnapshot(): readonly WakeSourceStateItem[] {\n\t\treturn [...this.#backgrounds.values()];\n\t}\n\n\tnotifyBackgroundStart(id: string, description: string, startedAtMs = Date.now()): void {\n\t\tif (this.#torndown) return;\n\t\tthis.#backgrounds.set(id, { id, description, startedAtMs });\n\t\tthis.#sinks?.onBackgroundState(this.backgroundSnapshot());\n\t}\n\n\tnotifyBackgroundExit(id: string, runtime: TerminalRuntimeSession): void {\n\t\tif (this.#torndown) return;\n\t\tif (this.#backgrounds.delete(id)) this.#sinks?.onBackgroundState(this.backgroundSnapshot());\n\t\tif (this.#sinks) {\n\t\t\tthis.#sinks.onBackgroundExit(id, runtime);\n\t\t\treturn;\n\t\t}\n\t\tif (this.#parkedExits.size >= MAX_PARKED_EXITS) return;\n\t\tthis.#parkedExits.set(id, runtime);\n\t}\n\n\tasync teardown(): Promise<void> {\n\t\tif (this.#torndown) return;\n\t\tthis.#parkedMonitorEvents = [];\n\t\tthis.#parkedExits.clear();\n\t\tthis.monitors.dispose();\n\t\tif (this.#backgrounds.size > 0) {\n\t\t\tthis.#backgrounds.clear();\n\t\t\tthis.#sinks?.onBackgroundState([]);\n\t\t}\n\t\tthis.#torndown = true;\n\t\tthis.#sinks = null;\n\t\tawait this.manager.teardown();\n\t}\n\n\t#dispatchMonitorEvent(event: MonitorEvent): void {\n\t\tif (this.#torndown) return;\n\t\tif (this.#sinks) {\n\t\t\tthis.#sinks.onMonitorEvent(event);\n\t\t\treturn;\n\t\t}\n\t\tthis.#parkedMonitorEvents.push(event);\n\t\tif (this.#parkedMonitorEvents.length > MAX_PARKED_MONITOR_EVENTS) this.#parkedMonitorEvents.shift();\n\t}\n}\n\nconst parkedBundles = new Map<string, TerminalSessionBundle>();\n\n/** Park a bundle across a reload; at most one parked bundle per session, older ones torn down. */\nexport async function parkBundle(sessionKey: string, bundle: TerminalSessionBundle): Promise<void> {\n\tconst previous = parkedBundles.get(sessionKey);\n\tparkedBundles.set(sessionKey, bundle);\n\tif (previous && previous !== bundle) await previous.teardown();\n}\n\nexport function claimParkedBundle(sessionKey: string): TerminalSessionBundle | undefined {\n\tconst bundle = parkedBundles.get(sessionKey);\n\tparkedBundles.delete(sessionKey);\n\treturn bundle;\n}\n\nexport async function teardownParkedBundle(sessionKey: string): Promise<void> {\n\tconst bundle = parkedBundles.get(sessionKey);\n\tparkedBundles.delete(sessionKey);\n\tawait bundle?.teardown();\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"kill-bash.d.ts","sourceRoot":"","sources":["../../../../../../src/core/extensions/builtin/terminal/tools/kill-bash.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,MAAM,EAAE,IAAI,EAAE,MAAM,SAAS,CAAC;AAE5C,OAAO,EAAe,KAAK,mBAAmB,EAAE,KAAK,kBAAkB,EAAc,MAAM,cAAc,CAAC;AAE1G,eAAO,MAAM,cAAc;;;EAGzB,CAAC;AAEH,MAAM,MAAM,aAAa,GAAG,MAAM,CAAC,OAAO,cAAc,CAAC,CAAC;AAE1D,wBAAgB,kBAAkB,CAAC,GAAG,EAAE,mBAAmB;;;;;;;;;yBAO9B,MAAM,SAAS,aAAa,YAAY,WAAW,GAAG,OAAO,CAAC,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"kill-bash.d.ts","sourceRoot":"","sources":["../../../../../../src/core/extensions/builtin/terminal/tools/kill-bash.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,MAAM,EAAE,IAAI,EAAE,MAAM,SAAS,CAAC;AAE5C,OAAO,EAAe,KAAK,mBAAmB,EAAE,KAAK,kBAAkB,EAAc,MAAM,cAAc,CAAC;AAE1G,eAAO,MAAM,cAAc;;;EAGzB,CAAC;AAEH,MAAM,MAAM,aAAa,GAAG,MAAM,CAAC,OAAO,cAAc,CAAC,CAAC;AAE1D,wBAAgB,kBAAkB,CAAC,GAAG,EAAE,mBAAmB;;;;;;;;;yBAO9B,MAAM,SAAS,aAAa,YAAY,WAAW,GAAG,OAAO,CAAC,kBAAkB,CAAC;EAe7G"}
|
|
@@ -14,12 +14,15 @@ export function createKillBashTool(ctx) {
|
|
|
14
14
|
parameters: killBashSchema,
|
|
15
15
|
async execute(_toolCallId, input, _signal) {
|
|
16
16
|
if (input.all) {
|
|
17
|
-
const
|
|
17
|
+
const terminalCount = ctx.manager.size;
|
|
18
|
+
const fileCount = (await ctx.monitorRegistry?.stopAllFiles()) ?? 0;
|
|
18
19
|
await ctx.manager.teardown();
|
|
19
|
-
return textResult(`Killed ${
|
|
20
|
+
return textResult(`Killed ${terminalCount + fileCount} session(s).`);
|
|
20
21
|
}
|
|
21
22
|
if (!input.bash_id)
|
|
22
23
|
return errorResult("Provide `bash_id` or set `all:true`.");
|
|
24
|
+
if (await ctx.monitorRegistry?.stopFile(input.bash_id))
|
|
25
|
+
return textResult(`Killed ${input.bash_id}.`);
|
|
23
26
|
const runtime = ctx.manager.get(input.bash_id);
|
|
24
27
|
if (!runtime)
|
|
25
28
|
return errorResult(`No terminal session found with id: ${input.bash_id}`);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"kill-bash.js","sourceRoot":"","sources":["../../../../../../src/core/extensions/builtin/terminal/tools/kill-bash.ts"],"names":[],"mappings":"AAAA,OAAO,EAAe,IAAI,EAAE,MAAM,SAAS,CAAC;AAC5C,OAAO,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AAClD,OAAO,EAAE,WAAW,EAAqD,UAAU,EAAE,MAAM,cAAc,CAAC;AAE1G,MAAM,CAAC,MAAM,cAAc,GAAG,IAAI,CAAC,MAAM,CAAC;IACzC,OAAO,EAAE,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,WAAW,EAAE,0BAA0B,EAAE,CAAC,CAAC;IAChF,GAAG,EAAE,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE,WAAW,EAAE,0CAA0C,EAAE,CAAC,CAAC;CAC7F,CAAC,CAAC;AAIH,MAAM,UAAU,kBAAkB,CAAC,GAAwB;IAC1D,OAAO;QACN,IAAI,EAAE,kBAAkB;QACxB,KAAK,EAAE,WAAW;QAClB,WAAW,EAAE,oFAAoF;QACjG,aAAa,EAAE,8DAA8D;QAC7E,UAAU,EAAE,cAAc;QAC1B,KAAK,CAAC,OAAO,CAAC,WAAmB,EAAE,KAAoB,EAAE,OAAqB;YAC7E,IAAI,KAAK,CAAC,GAAG,EAAE,CAAC;gBACf,MAAM,
|
|
1
|
+
{"version":3,"file":"kill-bash.js","sourceRoot":"","sources":["../../../../../../src/core/extensions/builtin/terminal/tools/kill-bash.ts"],"names":[],"mappings":"AAAA,OAAO,EAAe,IAAI,EAAE,MAAM,SAAS,CAAC;AAC5C,OAAO,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AAClD,OAAO,EAAE,WAAW,EAAqD,UAAU,EAAE,MAAM,cAAc,CAAC;AAE1G,MAAM,CAAC,MAAM,cAAc,GAAG,IAAI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AC,OAAO,EAAE,CAAC,CAAC;YACxF,MAAM,GAAG,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;YACtC,OAAO,UAAU,CAAC,UAAU,KAAK,CAAC,OAAO,GAAG,CAAC,CAAC;QAC/C,CAAC;KACD,CAAC;AACH,CAAC","sourcesContent":["import { type Static, Type } from \"typebox\";\nimport { TERMINAL_KILL_TOOL } from \"../shared.ts\";\nimport { errorResult, type TerminalToolContext, type TerminalToolResult, textResult } from \"./context.ts\";\n\nexport const killBashSchema = Type.Object({\n\tbash_id: Type.Optional(Type.String({ description: \"Session id to tree-kill.\" })),\n\tall: Type.Optional(Type.Boolean({ description: \"Tree-kill every live background session.\" })),\n});\n\nexport type KillBashInput = Static<typeof killBashSchema>;\n\nexport function createKillBashTool(ctx: TerminalToolContext) {\n\treturn {\n\t\tname: TERMINAL_KILL_TOOL,\n\t\tlabel: \"kill_bash\",\n\t\tdescription: \"Terminate a background bash session (or all of them) and its process tree cleanly.\",\n\t\tpromptSnippet: \"Tree-kill a background bash session (or all) with no orphans\",\n\t\tparameters: killBashSchema,\n\t\tasync execute(_toolCallId: string, input: KillBashInput, _signal?: AbortSignal): Promise<TerminalToolResult> {\n\t\t\tif (input.all) {\n\t\t\t\tconst terminalCount = ctx.manager.size;\n\t\t\t\tconst fileCount = (await ctx.monitorRegistry?.stopAllFiles()) ?? 0;\n\t\t\t\tawait ctx.manager.teardown();\n\t\t\t\treturn textResult(`Killed ${terminalCount + fileCount} session(s).`);\n\t\t\t}\n\t\t\tif (!input.bash_id) return errorResult(\"Provide `bash_id` or set `all:true`.\");\n\t\t\tif (await ctx.monitorRegistry?.stopFile(input.bash_id)) return textResult(`Killed ${input.bash_id}.`);\n\t\t\tconst runtime = ctx.manager.get(input.bash_id);\n\t\t\tif (!runtime) return errorResult(`No terminal session found with id: ${input.bash_id}`);\n\t\t\tawait ctx.manager.stop(input.bash_id);\n\t\t\treturn textResult(`Killed ${input.bash_id}.`);\n\t\t},\n\t};\n}\n"]}
|
|
@@ -13,6 +13,8 @@ export declare const monitorSchema: Type.TObject<{
|
|
|
13
13
|
action: Type.TOptional<Type.TUnsafe<"create" | "rearm">>;
|
|
14
14
|
description: Type.TOptional<Type.TString>;
|
|
15
15
|
command: Type.TOptional<Type.TString>;
|
|
16
|
+
path: Type.TOptional<Type.TString>;
|
|
17
|
+
event: Type.TOptional<Type.TUnsafe<"create" | "modify">>;
|
|
16
18
|
filter: Type.TOptional<Type.TString>;
|
|
17
19
|
timeout_ms: Type.TOptional<Type.TNumber>;
|
|
18
20
|
persistent: Type.TOptional<Type.TBoolean>;
|
|
@@ -30,6 +32,8 @@ export declare function createMonitorTool(ctx: TerminalToolContext): {
|
|
|
30
32
|
action: Type.TOptional<Type.TUnsafe<"create" | "rearm">>;
|
|
31
33
|
description: Type.TOptional<Type.TString>;
|
|
32
34
|
command: Type.TOptional<Type.TString>;
|
|
35
|
+
path: Type.TOptional<Type.TString>;
|
|
36
|
+
event: Type.TOptional<Type.TUnsafe<"create" | "modify">>;
|
|
33
37
|
filter: Type.TOptional<Type.TString>;
|
|
34
38
|
timeout_ms: Type.TOptional<Type.TNumber>;
|
|
35
39
|
persistent: Type.TOptional<Type.TBoolean>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"monitor.d.ts","sourceRoot":"","sources":["../../../../../../src/core/extensions/builtin/terminal/tools/monitor.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,MAAM,EAAE,IAAI,EAAE,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"monitor.d.ts","sourceRoot":"","sources":["../../../../../../src/core/extensions/builtin/terminal/tools/monitor.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,MAAM,EAAE,IAAI,EAAE,MAAM,SAAS,CAAC;AAI5C,OAAO,EAAe,KAAK,mBAAmB,EAAE,KAAK,kBAAkB,EAAc,MAAM,cAAc,CAAC;AAC1G,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAGhD,eAAO,MAAM,0BAA0B,SAAU,CAAC;AAClD,eAAO,MAAM,sBAAsB,UAAY,CAAC;AAEhD;;;;;GAKG;AACH,eAAO,MAAM,aAAa;;;;;;;;;;EAoCxB,CAAC;AACH,MAAM,MAAM,YAAY,GAAG,MAAM,CAAC,OAAO,aAAa,CAAC,CAAC;AA+DxD,mGAAmG;AACnG,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,mBAAmB;;;;;;;;;;;;;;;;;;yBAsB1C,MAAM,SACZ,YAAY,YACT,WAAW,cACT,SAAS,YACX;QAAE,GAAG,CAAC,EAAE,MAAM,CAAA;KAAE,GACxB,OAAO,CAAC,kBAAkB,CAAC;EA6C/B"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { StringEnum } from "@earendil-works/pi-ai";
|
|
2
2
|
import { Type } from "typebox";
|
|
3
|
+
import { APPROVED_MONITOR_PARENT } from "../monitor-permission.js";
|
|
3
4
|
import { MonitorRegistry } from "../monitor-registry.js";
|
|
4
5
|
import { DEFAULT_COLS, DEFAULT_ROWS, TERMINAL_MONITOR_TOOL } from "../shared.js";
|
|
5
6
|
import { errorResult, textResult } from "./context.js";
|
|
@@ -25,6 +26,8 @@ export const monitorSchema = Type.Object({
|
|
|
25
26
|
command: Type.Optional(Type.String({
|
|
26
27
|
description: "Create (required): shell command to run and watch in a PTY-backed monitor session.",
|
|
27
28
|
})),
|
|
29
|
+
path: Type.Optional(Type.String({ minLength: 1, description: "File path to watch for a native event." })),
|
|
30
|
+
event: Type.Optional(StringEnum(["create", "modify"], { description: "Native file event (defaults to create)." })),
|
|
28
31
|
filter: Type.Optional(Type.String({ description: "Only PTY output lines matching this regex become monitor events." })),
|
|
29
32
|
timeout_ms: Type.Optional(Type.Number({
|
|
30
33
|
minimum: 1,
|
|
@@ -34,6 +37,12 @@ export const monitorSchema = Type.Object({
|
|
|
34
37
|
persistent: Type.Optional(Type.Boolean({ description: "Keep watching until the command exits or kill_bash stops its bash_id." })),
|
|
35
38
|
bash_id: Type.Optional(Type.String({ description: "Rearm (required): paused monitor bash_id to resume." })),
|
|
36
39
|
});
|
|
40
|
+
function isFileCreateInput(input) {
|
|
41
|
+
return (typeof input.description === "string" &&
|
|
42
|
+
input.description.length > 0 &&
|
|
43
|
+
typeof input.path === "string" &&
|
|
44
|
+
input.path.length > 0);
|
|
45
|
+
}
|
|
37
46
|
function isCreateInput(input) {
|
|
38
47
|
return (typeof input.description === "string" &&
|
|
39
48
|
input.description.length > 0 &&
|
|
@@ -109,9 +118,38 @@ export function createMonitorTool(ctx) {
|
|
|
109
118
|
ctx.onMonitorRearmed?.(bashId);
|
|
110
119
|
return textResult(`Monitor ${bashId} re-armed.`);
|
|
111
120
|
}
|
|
112
|
-
|
|
113
|
-
|
|
121
|
+
const fileInput = isFileCreateInput(input);
|
|
122
|
+
const commandInput = isCreateInput(input);
|
|
123
|
+
if (fileInput && commandInput)
|
|
124
|
+
return errorResult("monitor accepts either command or path, not both.");
|
|
125
|
+
if (fileInput) {
|
|
126
|
+
if (input.filter !== undefined || input.persistent)
|
|
127
|
+
return errorResult("Native file monitors do not support filter or persistent.");
|
|
128
|
+
if (!ctx.monitorRegistry)
|
|
129
|
+
return errorResult("Native file monitors require a lifecycle-owned monitor registry.");
|
|
130
|
+
try {
|
|
131
|
+
const id = await ctx.monitorRegistry.registerFile({
|
|
132
|
+
description: input.description,
|
|
133
|
+
path: input.path,
|
|
134
|
+
event: input.event ?? "create",
|
|
135
|
+
timeoutMs: resolveTimeoutMs(input.timeout_ms),
|
|
136
|
+
cwd: execCtx?.cwd ?? ctx.cwd,
|
|
137
|
+
...(input[APPROVED_MONITOR_PARENT] !== undefined
|
|
138
|
+
? {
|
|
139
|
+
approvedParent: input[APPROVED_MONITOR_PARENT],
|
|
140
|
+
}
|
|
141
|
+
: {}),
|
|
142
|
+
});
|
|
143
|
+
return textResult(`Monitor started with ID: ${id}`, {
|
|
144
|
+
details: { bash_id: id, watch_id: id, monitor: true },
|
|
145
|
+
});
|
|
146
|
+
}
|
|
147
|
+
catch (error) {
|
|
148
|
+
return errorResult(error instanceof Error ? error.message : String(error));
|
|
149
|
+
}
|
|
114
150
|
}
|
|
151
|
+
if (!commandInput)
|
|
152
|
+
return errorResult("monitor requires description and command or path to start a watcher.");
|
|
115
153
|
return createMonitor(ctx, registry, input, execCtx);
|
|
116
154
|
},
|
|
117
155
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"monitor.js","sourceRoot":"","sources":["../../../../../../src/core/extensions/builtin/terminal/tools/monitor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AACnD,OAAO,EAAe,IAAI,EAAE,MAAM,SAAS,CAAC;AAC5C,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AACzD,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,qBAAqB,EAAE,MAAM,cAAc,CAAC;AACjF,OAAO,EAAE,WAAW,EAAqD,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1G,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAChD,OAAO,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AAEjD,MAAM,CAAC,MAAM,0BAA0B,GAAG,OAAO,CAAC;AAClD,MAAM,CAAC,MAAM,sBAAsB,GAAG,SAAS,CAAC;AAEhD;;;;;GAKG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG,IAAI,CAAC,MAAM,CAAC;IACxC,MAAM,EAAE,IAAI,CAAC,QAAQ,CACpB,UAAU,CAAC,CAAC,QAAQ,EAAE,OAAO,CAAU,EAAE;QACxC,WAAW,EAAE,wEAAwE;KACrF,CAAC,CACF;IACD,WAAW,EAAE,IAAI,CAAC,QAAQ,CACzB,IAAI,CAAC,MAAM,CAAC;QACX,SAAS,EAAE,CAAC;QACZ,SAAS,EAAE,GAAG;QACd,WAAW,EAAE,wFAA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,WAAW,CAAC,oCAAoC,MAAM,EAAE,CAAC,CAAC;gBAC9F,IAAI,OAAO,KAAK,YAAY;oBAAE,OAAO,UAAU,CAAC,WAAW,MAAM,kCAAkC,CAAC,CAAC;gBACrG,GAAG,CAAC,gBAAgB,EAAE,CAAC,MAAM,CAAC,CAAC;gBAC/B,OAAO,UAAU,CAAC,WAAW,MAAM,YAAY,CAAC,CAAC;YAClD,CAAC;YACD,IAAI,CAAC,aAAa,CAAC,KAAK,CAAC,EAAE,CAAC;gBAC3B,OAAO,WAAW,CAAC,8DAA8D,CAAC,CAAC;YACpF,CAAC;YACD,OAAO,aAAa,CAAC,GAAG,EAAE,QAAQ,EAAE,KAAK,EAAE,OAAO,CAAC,CAAC;QACrD,CAAC;KACD,CAAC;AACH,CAAC","sourcesContent":["import { StringEnum } from \"@earendil-works/pi-ai\";\nimport { type Static, Type } from \"typebox\";\nimport { MonitorRegistry } from \"../monitor-registry.ts\";\nimport { DEFAULT_COLS, DEFAULT_ROWS, TERMINAL_MONITOR_TOOL } from \"../shared.ts\";\nimport { errorResult, type TerminalToolContext, type TerminalToolResult, textResult } from \"./context.ts\";\nimport { renderMonitorCall } from \"./render.ts\";\nimport { spawnCommandSession } from \"./spawn.ts\";\n\nexport const DEFAULT_MONITOR_TIMEOUT_MS = 300_000;\nexport const MAX_MONITOR_TIMEOUT_MS = 3_600_000;\n\n/**\n * One flat object schema, no top-level union: several provider payload paths\n * (e.g. Anthropic's legacy input_schema conversion) rebuild tool schemas from\n * top-level `properties` only, so a root anyOf would reach the model as an\n * empty schema. Branch requirements are enforced at runtime in `execute`.\n */\nexport const monitorSchema = Type.Object({\n\taction: Type.Optional(\n\t\tStringEnum([\"create\", \"rearm\"] as const, {\n\t\t\tdescription: \"Defaults to create. rearm resumes a monitor paused by the wake budget.\",\n\t\t}),\n\t),\n\tdescription: Type.Optional(\n\t\tType.String({\n\t\t\tminLength: 1,\n\t\t\tmaxLength: 200,\n\t\t\tdescription: \"Create (required): specific label shown with every event, e.g. 'errors in deploy.log'.\",\n\t\t}),\n\t),\n\tcommand: Type.Optional(\n\t\tType.String({\n\t\t\tdescription: \"Create (required): shell command to run and watch in a PTY-backed monitor session.\",\n\t\t}),\n\t),\n\tfilter: Type.Optional(\n\t\tType.String({ description: \"Only PTY output lines matching this regex become monitor events.\" }),\n\t),\n\ttimeout_ms: Type.Optional(\n\t\tType.Number({\n\t\t\tminimum: 1,\n\t\t\tmaximum: MAX_MONITOR_TIMEOUT_MS,\n\t\t\tdescription: \"Watcher deadline in milliseconds (default 300000; ignored by persistent monitors).\",\n\t\t}),\n\t),\n\tpersistent: Type.Optional(\n\t\tType.Boolean({ description: \"Keep watching until the command exits or kill_bash stops its bash_id.\" }),\n\t),\n\tbash_id: Type.Optional(Type.String({ description: \"Rearm (required): paused monitor bash_id to resume.\" })),\n});\nexport type MonitorInput = Static<typeof monitorSchema>;\n\ntype MonitorCreateInput = MonitorInput & { description: string; command: string };\n\nfunction isCreateInput(input: MonitorInput): input is MonitorCreateInput {\n\treturn (\n\t\ttypeof input.description === \"string\" &&\n\t\tinput.description.length > 0 &&\n\t\ttypeof input.command === \"string\" &&\n\t\tinput.command.length > 0\n\t);\n}\n\nfunction resolveDimension(value: number | undefined, fallback: number): number {\n\tif (value === undefined || !Number.isFinite(value) || value < 1) return fallback;\n\treturn Math.trunc(value);\n}\n\nfunction resolveTimeoutMs(value: number | undefined): number {\n\tconst timeout = value ?? DEFAULT_MONITOR_TIMEOUT_MS;\n\treturn Math.min(Math.max(Math.trunc(timeout), 1), MAX_MONITOR_TIMEOUT_MS);\n}\n\nfunction compileFilter(filter: string | undefined): RegExp | undefined {\n\tif (filter === undefined) return undefined;\n\treturn new RegExp(filter);\n}\n\nasync function createMonitor(\n\tctx: TerminalToolContext,\n\tregistry: MonitorRegistry,\n\tinput: MonitorCreateInput,\n\texecCtx: { cwd?: string } | undefined,\n): Promise<TerminalToolResult> {\n\tlet filter: RegExp | undefined;\n\ttry {\n\t\tfilter = compileFilter(input.filter);\n\t} catch {\n\t\treturn errorResult(`Invalid monitor filter regex: ${input.filter}`);\n\t}\n\n\tconst { id, runtime } = await spawnCommandSession(ctx, {\n\t\tcommand: input.command,\n\t\tcols: resolveDimension(undefined, ctx.defaultCols || DEFAULT_COLS),\n\t\trows: resolveDimension(undefined, ctx.defaultRows || DEFAULT_ROWS),\n\t\tcwd: execCtx?.cwd,\n\t\t...(input.persistent ? {} : { timeoutMs: resolveTimeoutMs(input.timeout_ms) }),\n\t});\n\tctx.onMonitorRearmed?.(id);\n\tregistry.register({ id, description: input.description, runtime, filter });\n\treturn textResult(`Monitor started with ID: ${id}`, { details: { bash_id: id, monitor: true } });\n}\n\n/** Build the PTY-backed monitor tool. Monitor handles share TerminalManager's bash_N namespace. */\nexport function createMonitorTool(ctx: TerminalToolContext) {\n\tlet fallbackRegistry: MonitorRegistry | undefined;\n\tconst getRegistry = (): MonitorRegistry => {\n\t\tconst sessionRegistry = ctx.monitorRegistry;\n\t\tif (sessionRegistry) return sessionRegistry;\n\t\tfallbackRegistry ??= new MonitorRegistry((event) => ctx.onMonitorEvent?.(event));\n\t\treturn fallbackRegistry;\n\t};\n\treturn {\n\t\tname: TERMINAL_MONITOR_TOOL,\n\t\tlabel: \"monitor\",\n\t\tdescription:\n\t\t\t\"Subscribe to a command's output instead of polling: newline-terminated PTY output lines (stderr merged) that match filter arrive as injected events while you keep working; command exit always delivers a summary event. Identical consecutive line-only update batches are deduped, so a watcher reprinting unchanged status does not re-wake the session. Returns a bash_id immediately; peek with bash_output, stop with kill_bash.\",\n\t\tpromptSnippet: \"Subscribe to a command's PTY output lines as injected events instead of polling\",\n\t\tpromptGuidelines: [\n\t\t\t\"Waiting on observable state (CI checks, builds, log patterns, deploys) means a monitor, never a foreground sleep/poll loop.\",\n\t\t\t\"Shape the command for the events you need: one-shot gate = `until <cond>; do sleep 1; done; printf 'READY\\\\n'` with filter ^READY$; stream = `tail -n 0 -F <log> | grep --line-buffered <pat>` with persistent: true, then kill_bash.\",\n\t\t\t\"Sleep loops belong INSIDE the monitor command, never in your turn: about to sleep, re-poll bash_output, or foreground-block on a long command means register a monitor and keep working.\",\n\t\t],\n\t\tparameters: monitorSchema,\n\t\trenderCall: renderMonitorCall,\n\t\tasync execute(\n\t\t\t_toolCallId: string,\n\t\t\tinput: MonitorInput,\n\t\t\t_signal?: AbortSignal,\n\t\t\t_onUpdate?: undefined,\n\t\t\texecCtx?: { cwd?: string },\n\t\t): Promise<TerminalToolResult> {\n\t\t\tconst registry = getRegistry();\n\t\t\tif (input.action === \"rearm\") {\n\t\t\t\tconst bashId = input.bash_id;\n\t\t\t\tif (bashId === undefined || bashId.length === 0) return errorResult(\"monitor rearm requires bash_id.\");\n\t\t\t\tconst outcome = registry.rearm(bashId);\n\t\t\t\tif (outcome === \"not_found\") return errorResult(`No active monitor found with id: ${bashId}`);\n\t\t\t\tif (outcome === \"not_paused\") return textResult(`Monitor ${bashId} is not paused; no action taken.`);\n\t\t\t\tctx.onMonitorRearmed?.(bashId);\n\t\t\t\treturn textResult(`Monitor ${bashId} re-armed.`);\n\t\t\t}\n\t\t\tif (!isCreateInput(input)) {\n\t\t\t\treturn errorResult(\"monitor requires description and command to start a watcher.\");\n\t\t\t}\n\t\t\treturn createMonitor(ctx, registry, input, execCtx);\n\t\t},\n\t};\n}\n"]}
|
|
1
|
+
{"version":3,"file":"monitor.js","sourceRoot":"","sources":["../../../../../../src/core/extensions/builtin/terminal/tools/monitor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AACnD,OAAO,EAAe,IAAI,EAAE,MAAM,SAAS,CAAC;AAC5C,OAAO,EAAE,uBAAuB,EAAE,MAAM,0BAA0B,CAAC;AACnE,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AACzD,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,qBAAqB,EAAE,MAAM,cAAc,CAAC;AACjF,OAAO,EAAE,WAAW,EAAqD,UAA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ACJ,CAAC;gBAAC,OAAO,KAAK,EAAE,CAAC;oBAChB,OAAO,WAAW,CAAC,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC;gBAC5E,CAAC;YACF,CAAC;YACD,IAAI,CAAC,YAAY;gBAAE,OAAO,WAAW,CAAC,sEAAsE,CAAC,CAAC;YAC9G,OAAO,aAAa,CAAC,GAAG,EAAE,QAAQ,EAAE,KAAK,EAAE,OAAO,CAAC,CAAC;QACrD,CAAC;KACD,CAAC;AACH,CAAC","sourcesContent":["import { StringEnum } from \"@earendil-works/pi-ai\";\nimport { type Static, Type } from \"typebox\";\nimport { APPROVED_MONITOR_PARENT } from \"../monitor-permission.ts\";\nimport { MonitorRegistry } from \"../monitor-registry.ts\";\nimport { DEFAULT_COLS, DEFAULT_ROWS, TERMINAL_MONITOR_TOOL } from \"../shared.ts\";\nimport { errorResult, type TerminalToolContext, type TerminalToolResult, textResult } from \"./context.ts\";\nimport { renderMonitorCall } from \"./render.ts\";\nimport { spawnCommandSession } from \"./spawn.ts\";\n\nexport const DEFAULT_MONITOR_TIMEOUT_MS = 300_000;\nexport const MAX_MONITOR_TIMEOUT_MS = 3_600_000;\n\n/**\n * One flat object schema, no top-level union: several provider payload paths\n * (e.g. Anthropic's legacy input_schema conversion) rebuild tool schemas from\n * top-level `properties` only, so a root anyOf would reach the model as an\n * empty schema. Branch requirements are enforced at runtime in `execute`.\n */\nexport const monitorSchema = Type.Object({\n\taction: Type.Optional(\n\t\tStringEnum([\"create\", \"rearm\"] as const, {\n\t\t\tdescription: \"Defaults to create. rearm resumes a monitor paused by the wake budget.\",\n\t\t}),\n\t),\n\tdescription: Type.Optional(\n\t\tType.String({\n\t\t\tminLength: 1,\n\t\t\tmaxLength: 200,\n\t\t\tdescription: \"Create (required): specific label shown with every event, e.g. 'errors in deploy.log'.\",\n\t\t}),\n\t),\n\tcommand: Type.Optional(\n\t\tType.String({\n\t\t\tdescription: \"Create (required): shell command to run and watch in a PTY-backed monitor session.\",\n\t\t}),\n\t),\n\tpath: Type.Optional(Type.String({ minLength: 1, description: \"File path to watch for a native event.\" })),\n\tevent: Type.Optional(\n\t\tStringEnum([\"create\", \"modify\"] as const, { description: \"Native file event (defaults to create).\" }),\n\t),\n\tfilter: Type.Optional(\n\t\tType.String({ description: \"Only PTY output lines matching this regex become monitor events.\" }),\n\t),\n\ttimeout_ms: Type.Optional(\n\t\tType.Number({\n\t\t\tminimum: 1,\n\t\t\tmaximum: MAX_MONITOR_TIMEOUT_MS,\n\t\t\tdescription: \"Watcher deadline in milliseconds (default 300000; ignored by persistent monitors).\",\n\t\t}),\n\t),\n\tpersistent: Type.Optional(\n\t\tType.Boolean({ description: \"Keep watching until the command exits or kill_bash stops its bash_id.\" }),\n\t),\n\tbash_id: Type.Optional(Type.String({ description: \"Rearm (required): paused monitor bash_id to resume.\" })),\n});\nexport type MonitorInput = Static<typeof monitorSchema>;\n\ntype MonitorCreateInput = MonitorInput & { description: string; command: string };\ntype FileMonitorCreateInput = MonitorInput & { description: string; path: string };\n\nfunction isFileCreateInput(input: MonitorInput): input is FileMonitorCreateInput {\n\treturn (\n\t\ttypeof input.description === \"string\" &&\n\t\tinput.description.length > 0 &&\n\t\ttypeof input.path === \"string\" &&\n\t\tinput.path.length > 0\n\t);\n}\n\nfunction isCreateInput(input: MonitorInput): input is MonitorCreateInput {\n\treturn (\n\t\ttypeof input.description === \"string\" &&\n\t\tinput.description.length > 0 &&\n\t\ttypeof input.command === \"string\" &&\n\t\tinput.command.length > 0\n\t);\n}\n\nfunction resolveDimension(value: number | undefined, fallback: number): number {\n\tif (value === undefined || !Number.isFinite(value) || value < 1) return fallback;\n\treturn Math.trunc(value);\n}\n\nfunction resolveTimeoutMs(value: number | undefined): number {\n\tconst timeout = value ?? DEFAULT_MONITOR_TIMEOUT_MS;\n\treturn Math.min(Math.max(Math.trunc(timeout), 1), MAX_MONITOR_TIMEOUT_MS);\n}\n\nfunction compileFilter(filter: string | undefined): RegExp | undefined {\n\tif (filter === undefined) return undefined;\n\treturn new RegExp(filter);\n}\n\nasync function createMonitor(\n\tctx: TerminalToolContext,\n\tregistry: MonitorRegistry,\n\tinput: MonitorCreateInput,\n\texecCtx: { cwd?: string } | undefined,\n): Promise<TerminalToolResult> {\n\tlet filter: RegExp | undefined;\n\ttry {\n\t\tfilter = compileFilter(input.filter);\n\t} catch {\n\t\treturn errorResult(`Invalid monitor filter regex: ${input.filter}`);\n\t}\n\n\tconst { id, runtime } = await spawnCommandSession(ctx, {\n\t\tcommand: input.command,\n\t\tcols: resolveDimension(undefined, ctx.defaultCols || DEFAULT_COLS),\n\t\trows: resolveDimension(undefined, ctx.defaultRows || DEFAULT_ROWS),\n\t\tcwd: execCtx?.cwd,\n\t\t...(input.persistent ? {} : { timeoutMs: resolveTimeoutMs(input.timeout_ms) }),\n\t});\n\tctx.onMonitorRearmed?.(id);\n\tregistry.register({ id, description: input.description, runtime, filter });\n\treturn textResult(`Monitor started with ID: ${id}`, { details: { bash_id: id, monitor: true } });\n}\n\n/** Build the PTY-backed monitor tool. Monitor handles share TerminalManager's bash_N namespace. */\nexport function createMonitorTool(ctx: TerminalToolContext) {\n\tlet fallbackRegistry: MonitorRegistry | undefined;\n\tconst getRegistry = (): MonitorRegistry => {\n\t\tconst sessionRegistry = ctx.monitorRegistry;\n\t\tif (sessionRegistry) return sessionRegistry;\n\t\tfallbackRegistry ??= new MonitorRegistry((event) => ctx.onMonitorEvent?.(event));\n\t\treturn fallbackRegistry;\n\t};\n\treturn {\n\t\tname: TERMINAL_MONITOR_TOOL,\n\t\tlabel: \"monitor\",\n\t\tdescription:\n\t\t\t\"Subscribe to a command's output instead of polling: newline-terminated PTY output lines (stderr merged) that match filter arrive as injected events while you keep working; command exit always delivers a summary event. Identical consecutive line-only update batches are deduped, so a watcher reprinting unchanged status does not re-wake the session. Returns a bash_id immediately; peek with bash_output, stop with kill_bash.\",\n\t\tpromptSnippet: \"Subscribe to a command's PTY output lines as injected events instead of polling\",\n\t\tpromptGuidelines: [\n\t\t\t\"Waiting on observable state (CI checks, builds, log patterns, deploys) means a monitor, never a foreground sleep/poll loop.\",\n\t\t\t\"Shape the command for the events you need: one-shot gate = `until <cond>; do sleep 1; done; printf 'READY\\\\n'` with filter ^READY$; stream = `tail -n 0 -F <log> | grep --line-buffered <pat>` with persistent: true, then kill_bash.\",\n\t\t\t\"Sleep loops belong INSIDE the monitor command, never in your turn: about to sleep, re-poll bash_output, or foreground-block on a long command means register a monitor and keep working.\",\n\t\t],\n\t\tparameters: monitorSchema,\n\t\trenderCall: renderMonitorCall,\n\t\tasync execute(\n\t\t\t_toolCallId: string,\n\t\t\tinput: MonitorInput,\n\t\t\t_signal?: AbortSignal,\n\t\t\t_onUpdate?: undefined,\n\t\t\texecCtx?: { cwd?: string },\n\t\t): Promise<TerminalToolResult> {\n\t\t\tconst registry = getRegistry();\n\t\t\tif (input.action === \"rearm\") {\n\t\t\t\tconst bashId = input.bash_id;\n\t\t\t\tif (bashId === undefined || bashId.length === 0) return errorResult(\"monitor rearm requires bash_id.\");\n\t\t\t\tconst outcome = registry.rearm(bashId);\n\t\t\t\tif (outcome === \"not_found\") return errorResult(`No active monitor found with id: ${bashId}`);\n\t\t\t\tif (outcome === \"not_paused\") return textResult(`Monitor ${bashId} is not paused; no action taken.`);\n\t\t\t\tctx.onMonitorRearmed?.(bashId);\n\t\t\t\treturn textResult(`Monitor ${bashId} re-armed.`);\n\t\t\t}\n\t\t\tconst fileInput = isFileCreateInput(input);\n\t\t\tconst commandInput = isCreateInput(input);\n\t\t\tif (fileInput && commandInput) return errorResult(\"monitor accepts either command or path, not both.\");\n\t\t\tif (fileInput) {\n\t\t\t\tif (input.filter !== undefined || input.persistent)\n\t\t\t\t\treturn errorResult(\"Native file monitors do not support filter or persistent.\");\n\t\t\t\tif (!ctx.monitorRegistry)\n\t\t\t\t\treturn errorResult(\"Native file monitors require a lifecycle-owned monitor registry.\");\n\t\t\t\ttry {\n\t\t\t\t\tconst id = await ctx.monitorRegistry.registerFile({\n\t\t\t\t\t\tdescription: input.description,\n\t\t\t\t\t\tpath: input.path,\n\t\t\t\t\t\tevent: input.event ?? \"create\",\n\t\t\t\t\t\ttimeoutMs: resolveTimeoutMs(input.timeout_ms),\n\t\t\t\t\t\tcwd: execCtx?.cwd ?? ctx.cwd,\n\t\t\t\t\t\t...((input as Record<string | symbol, unknown>)[APPROVED_MONITOR_PARENT] !== undefined\n\t\t\t\t\t\t\t? {\n\t\t\t\t\t\t\t\t\tapprovedParent: (input as Record<string | symbol, unknown>)[\n\t\t\t\t\t\t\t\t\t\tAPPROVED_MONITOR_PARENT\n\t\t\t\t\t\t\t\t\t] as string,\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t: {}),\n\t\t\t\t\t});\n\t\t\t\t\treturn textResult(`Monitor started with ID: ${id}`, {\n\t\t\t\t\t\tdetails: { bash_id: id, watch_id: id, monitor: true },\n\t\t\t\t\t});\n\t\t\t\t} catch (error) {\n\t\t\t\t\treturn errorResult(error instanceof Error ? error.message : String(error));\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (!commandInput) return errorResult(\"monitor requires description and command or path to start a watcher.\");\n\t\t\treturn createMonitor(ctx, registry, input, execCtx);\n\t\t},\n\t};\n}\n"]}
|
|
@@ -29,8 +29,8 @@ export const defaultModelPerProvider = {
|
|
|
29
29
|
xai: "grok-4.5",
|
|
30
30
|
groq: "openai/gpt-oss-120b",
|
|
31
31
|
cerebras: "gpt-oss-120b",
|
|
32
|
-
zai: "glm-5.
|
|
33
|
-
"zai-coding-cn": "glm-5.
|
|
32
|
+
zai: "glm-5.3",
|
|
33
|
+
"zai-coding-cn": "glm-5.3",
|
|
34
34
|
mistral: "devstral-medium-latest",
|
|
35
35
|
minimax: "MiniMax-M2.7",
|
|
36
36
|
"minimax-cn": "MiniMax-M2.7",
|