@code-yeongyu/senpi 2026.8.30 → 2026.9.2-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 +234 -4
- package/README.md +3 -0
- package/dist/core/agent-session.d.ts +29 -0
- package/dist/core/agent-session.d.ts.map +1 -1
- package/dist/core/agent-session.js +168 -18
- package/dist/core/agent-session.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/extensions/builtin/claude-sdk-oauth/options.d.ts.map +1 -1
- package/dist/core/extensions/builtin/claude-sdk-oauth/options.js +6 -2
- package/dist/core/extensions/builtin/claude-sdk-oauth/options.js.map +1 -1
- package/dist/core/extensions/builtin/claude-sdk-oauth/session-registry.d.ts +9 -1
- package/dist/core/extensions/builtin/claude-sdk-oauth/session-registry.d.ts.map +1 -1
- package/dist/core/extensions/builtin/claude-sdk-oauth/session-registry.js +10 -3
- package/dist/core/extensions/builtin/claude-sdk-oauth/session-registry.js.map +1 -1
- package/dist/core/extensions/builtin/claude-sdk-oauth/stream.d.ts.map +1 -1
- package/dist/core/extensions/builtin/claude-sdk-oauth/stream.js +2 -1
- package/dist/core/extensions/builtin/claude-sdk-oauth/stream.js.map +1 -1
- package/dist/core/extensions/builtin/compaction/context-pipeline.d.ts +24 -0
- package/dist/core/extensions/builtin/compaction/context-pipeline.d.ts.map +1 -0
- package/dist/core/extensions/builtin/compaction/context-pipeline.js +43 -0
- package/dist/core/extensions/builtin/compaction/context-pipeline.js.map +1 -0
- package/dist/core/extensions/builtin/compaction/deterministic-fallback.d.ts +1 -1
- package/dist/core/extensions/builtin/compaction/deterministic-fallback.d.ts.map +1 -1
- package/dist/core/extensions/builtin/compaction/deterministic-fallback.js +8 -2
- 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 +152 -154
- 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/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 +23 -0
- package/dist/core/extensions/builtin/compaction/speculative-summary.d.ts.map +1 -0
- package/dist/core/extensions/builtin/compaction/speculative-summary.js +132 -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 +21 -197
- 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/hooks/trust-state-json.d.ts +5 -0
- package/dist/core/extensions/builtin/hooks/trust-state-json.d.ts.map +1 -0
- package/dist/core/extensions/builtin/hooks/trust-state-json.js +76 -0
- package/dist/core/extensions/builtin/hooks/trust-state-json.js.map +1 -0
- package/dist/core/extensions/builtin/hooks/trust-storage.d.ts +7 -1
- package/dist/core/extensions/builtin/hooks/trust-storage.d.ts.map +1 -1
- package/dist/core/extensions/builtin/hooks/trust-storage.js +60 -8
- package/dist/core/extensions/builtin/hooks/trust-storage.js.map +1 -1
- package/dist/core/extensions/builtin/hooks/trust.d.ts +1 -2
- package/dist/core/extensions/builtin/hooks/trust.d.ts.map +1 -1
- package/dist/core/extensions/builtin/hooks/trust.js +1 -72
- package/dist/core/extensions/builtin/hooks/trust.js.map +1 -1
- package/dist/core/extensions/builtin/prompt-preset/claude-fable-5-1.d.ts +3 -0
- package/dist/core/extensions/builtin/prompt-preset/claude-fable-5-1.d.ts.map +1 -0
- package/dist/core/extensions/builtin/prompt-preset/claude-fable-5-1.js +110 -0
- package/dist/core/extensions/builtin/prompt-preset/claude-fable-5-1.js.map +1 -0
- package/dist/core/extensions/builtin/prompt-preset/claude-fable-5.d.ts.map +1 -1
- package/dist/core/extensions/builtin/prompt-preset/claude-fable-5.js +2 -1
- package/dist/core/extensions/builtin/prompt-preset/claude-fable-5.js.map +1 -1
- package/dist/core/extensions/builtin/prompt-preset/claude-opus-4-5.d.ts.map +1 -1
- package/dist/core/extensions/builtin/prompt-preset/claude-opus-4-5.js +7 -1
- package/dist/core/extensions/builtin/prompt-preset/claude-opus-4-5.js.map +1 -1
- package/dist/core/extensions/builtin/prompt-preset/claude-opus-4-6.d.ts.map +1 -1
- package/dist/core/extensions/builtin/prompt-preset/claude-opus-4-6.js +7 -1
- package/dist/core/extensions/builtin/prompt-preset/claude-opus-4-6.js.map +1 -1
- package/dist/core/extensions/builtin/prompt-preset/claude-opus-4-7.d.ts.map +1 -1
- package/dist/core/extensions/builtin/prompt-preset/claude-opus-4-7.js +7 -1
- package/dist/core/extensions/builtin/prompt-preset/claude-opus-4-7.js.map +1 -1
- package/dist/core/extensions/builtin/prompt-preset/claude-opus-4-8.d.ts.map +1 -1
- package/dist/core/extensions/builtin/prompt-preset/claude-opus-4-8.js +7 -1
- package/dist/core/extensions/builtin/prompt-preset/claude-opus-4-8.js.map +1 -1
- package/dist/core/extensions/builtin/prompt-preset/claude-opus-5.d.ts.map +1 -1
- package/dist/core/extensions/builtin/prompt-preset/claude-opus-5.js +2 -1
- package/dist/core/extensions/builtin/prompt-preset/claude-opus-5.js.map +1 -1
- package/dist/core/extensions/builtin/prompt-preset/execution-tooling.d.ts +50 -0
- package/dist/core/extensions/builtin/prompt-preset/execution-tooling.d.ts.map +1 -0
- package/dist/core/extensions/builtin/prompt-preset/execution-tooling.js +66 -0
- package/dist/core/extensions/builtin/prompt-preset/execution-tooling.js.map +1 -0
- package/dist/core/extensions/builtin/prompt-preset/gpt-5.6.d.ts +5 -1
- package/dist/core/extensions/builtin/prompt-preset/gpt-5.6.d.ts.map +1 -1
- package/dist/core/extensions/builtin/prompt-preset/gpt-5.6.js +6 -1
- package/dist/core/extensions/builtin/prompt-preset/gpt-5.6.js.map +1 -1
- package/dist/core/extensions/builtin/prompt-preset/kimi-k2-6.d.ts.map +1 -1
- package/dist/core/extensions/builtin/prompt-preset/kimi-k2-6.js +11 -1
- package/dist/core/extensions/builtin/prompt-preset/kimi-k2-6.js.map +1 -1
- package/dist/core/extensions/builtin/prompt-preset/kimi-k2-7.d.ts.map +1 -1
- package/dist/core/extensions/builtin/prompt-preset/kimi-k2-7.js +11 -1
- package/dist/core/extensions/builtin/prompt-preset/kimi-k2-7.js.map +1 -1
- package/dist/core/extensions/builtin/prompt-preset/kimi-k3.d.ts.map +1 -1
- package/dist/core/extensions/builtin/prompt-preset/kimi-k3.js +2 -1
- package/dist/core/extensions/builtin/prompt-preset/kimi-k3.js.map +1 -1
- package/dist/core/extensions/builtin/prompt-preset/presets.d.ts.map +1 -1
- package/dist/core/extensions/builtin/prompt-preset/presets.js +18 -1
- 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/recommended-models/index.d.ts +1 -1
- package/dist/core/extensions/builtin/recommended-models/index.d.ts.map +1 -1
- package/dist/core/extensions/builtin/recommended-models/index.js +1 -1
- package/dist/core/extensions/builtin/recommended-models/index.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/ttsr/index.d.ts.map +1 -1
- package/dist/core/extensions/builtin/ttsr/index.js +4 -0
- package/dist/core/extensions/builtin/ttsr/index.js.map +1 -1
- package/dist/core/extensions/builtin/ttsr/manager.d.ts +2 -0
- package/dist/core/extensions/builtin/ttsr/manager.d.ts.map +1 -1
- package/dist/core/extensions/builtin/ttsr/manager.js +28 -1
- package/dist/core/extensions/builtin/ttsr/manager.js.map +1 -1
- package/dist/core/extensions/runner.d.ts +5 -0
- package/dist/core/extensions/runner.d.ts.map +1 -1
- package/dist/core/extensions/runner.js +7 -0
- package/dist/core/extensions/runner.js.map +1 -1
- package/dist/core/provider-composer.d.ts.map +1 -1
- package/dist/core/provider-composer.js +17 -8
- package/dist/core/provider-composer.js.map +1 -1
- package/dist/core/retry-fallback/controller.d.ts +14 -0
- package/dist/core/retry-fallback/controller.d.ts.map +1 -1
- package/dist/core/retry-fallback/controller.js +33 -3
- package/dist/core/retry-fallback/controller.js.map +1 -1
- package/dist/core/retry-fallback/log.js +1 -1
- package/dist/core/retry-fallback/log.js.map +1 -1
- package/dist/core/retry-fallback/settings.d.ts.map +1 -1
- package/dist/core/retry-fallback/settings.js +1 -0
- package/dist/core/retry-fallback/settings.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-activity.d.ts +47 -0
- package/dist/core/session-activity.d.ts.map +1 -0
- package/dist/core/session-activity.js +58 -0
- package/dist/core/session-activity.js.map +1 -0
- package/dist/core/session-manager.d.ts +8 -12
- package/dist/core/session-manager.d.ts.map +1 -1
- package/dist/core/session-manager.js +118 -7
- package/dist/core/session-manager.js.map +1 -1
- package/dist/core/session-resident-store.d.ts +8 -1
- package/dist/core/session-resident-store.d.ts.map +1 -1
- package/dist/core/session-resident-store.js +12 -5
- package/dist/core/session-resident-store.js.map +1 -1
- package/dist/core/settings-manager.d.ts +10 -87
- package/dist/core/settings-manager.d.ts.map +1 -1
- package/dist/core/settings-manager.js +14 -20
- 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/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 +4 -4
- package/dist/main.d.ts.map +1 -1
- package/dist/main.js +27 -11
- package/dist/main.js.map +1 -1
- package/dist/modes/app-server/daemon/process.d.ts +13 -2
- package/dist/modes/app-server/daemon/process.d.ts.map +1 -1
- package/dist/modes/app-server/daemon/process.js +58 -12
- package/dist/modes/app-server/daemon/process.js.map +1 -1
- package/dist/modes/app-server/daemon.js +65 -7
- package/dist/modes/app-server/daemon.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/interactive-host-runtime.d.ts +84 -1
- package/dist/modes/interactive/interactive-host-runtime.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-host-runtime.js +435 -112
- package/dist/modes/interactive/interactive-host-runtime.js.map +1 -1
- package/dist/modes/interactive/interactive-mode.d.ts +11 -1
- package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-mode.js +59 -6
- package/dist/modes/interactive/interactive-mode.js.map +1 -1
- package/dist/modes/interactive/tips/catalog/ethos-tips.js +1 -1
- package/dist/modes/interactive/tips/catalog/ethos-tips.js.map +1 -1
- package/dist/modes/rpc/connection-handler.d.ts +12 -5
- package/dist/modes/rpc/connection-handler.d.ts.map +1 -1
- package/dist/modes/rpc/connection-handler.js +180 -25
- package/dist/modes/rpc/connection-handler.js.map +1 -1
- package/dist/modes/rpc/custom-capability.d.ts +2 -0
- package/dist/modes/rpc/custom-capability.d.ts.map +1 -1
- package/dist/modes/rpc/custom-capability.js +2 -0
- package/dist/modes/rpc/custom-capability.js.map +1 -1
- package/dist/modes/rpc/host-ensure.d.ts +17 -0
- package/dist/modes/rpc/host-ensure.d.ts.map +1 -1
- package/dist/modes/rpc/host-ensure.js +150 -23
- package/dist/modes/rpc/host-ensure.js.map +1 -1
- package/dist/modes/rpc/host-lifecycle.d.ts +54 -0
- package/dist/modes/rpc/host-lifecycle.d.ts.map +1 -1
- package/dist/modes/rpc/host-lifecycle.js +259 -69
- package/dist/modes/rpc/host-lifecycle.js.map +1 -1
- package/dist/modes/rpc/host-watchdog.d.ts +2 -2
- package/dist/modes/rpc/host-watchdog.d.ts.map +1 -1
- package/dist/modes/rpc/host-watchdog.js +89 -21
- package/dist/modes/rpc/host-watchdog.js.map +1 -1
- package/dist/modes/rpc/multi-session-host.d.ts +38 -0
- package/dist/modes/rpc/multi-session-host.d.ts.map +1 -1
- package/dist/modes/rpc/multi-session-host.js +149 -61
- package/dist/modes/rpc/multi-session-host.js.map +1 -1
- package/dist/modes/rpc/ownership-safe-lock.d.ts +14 -0
- package/dist/modes/rpc/ownership-safe-lock.d.ts.map +1 -0
- package/dist/modes/rpc/ownership-safe-lock.js +87 -0
- package/dist/modes/rpc/ownership-safe-lock.js.map +1 -0
- package/dist/modes/rpc/rpc-client.d.ts +13 -2
- package/dist/modes/rpc/rpc-client.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-client.js +46 -12
- package/dist/modes/rpc/rpc-client.js.map +1 -1
- package/dist/modes/rpc/rpc-types.d.ts +21 -3
- package/dist/modes/rpc/rpc-types.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-types.js +1 -0
- package/dist/modes/rpc/rpc-types.js.map +1 -1
- package/dist/modes/rpc/session-binding.d.ts +2 -1
- package/dist/modes/rpc/session-binding.d.ts.map +1 -1
- package/dist/modes/rpc/session-binding.js +1 -0
- package/dist/modes/rpc/session-binding.js.map +1 -1
- package/dist/modes/rpc/session-command-router.d.ts +54 -1
- package/dist/modes/rpc/session-command-router.d.ts.map +1 -1
- package/dist/modes/rpc/session-command-router.js +180 -3
- package/dist/modes/rpc/session-command-router.js.map +1 -1
- package/dist/modes/rpc/session-event-writer.d.ts +18 -0
- package/dist/modes/rpc/session-event-writer.d.ts.map +1 -1
- package/dist/modes/rpc/session-event-writer.js +88 -8
- package/dist/modes/rpc/session-event-writer.js.map +1 -1
- package/dist/modes/rpc/session-registry.d.ts +11 -1
- package/dist/modes/rpc/session-registry.d.ts.map +1 -1
- package/dist/modes/rpc/session-registry.js +25 -0
- package/dist/modes/rpc/session-registry.js.map +1 -1
- package/dist/modes/rpc/socket-transport.d.ts +13 -0
- package/dist/modes/rpc/socket-transport.d.ts.map +1 -0
- package/dist/modes/rpc/socket-transport.js +92 -0
- package/dist/modes/rpc/socket-transport.js.map +1 -0
- package/dist/modes/rpc/widget-line-renderer.d.ts +17 -0
- package/dist/modes/rpc/widget-line-renderer.d.ts.map +1 -0
- package/dist/modes/rpc/widget-line-renderer.js +73 -0
- package/dist/modes/rpc/widget-line-renderer.js.map +1 -0
- package/dist/utils/fs-watch.d.ts.map +1 -1
- package/dist/utils/fs-watch.js +11 -2
- package/dist/utils/fs-watch.js.map +1 -1
- package/docs/app-server.md +2 -2
- package/docs/containerization.md +2 -2
- package/docs/development.md +7 -7
- package/docs/extensions.md +5 -5
- package/docs/grok-neo.md +1 -1
- package/docs/index.md +1 -1
- package/docs/packages.md +2 -2
- package/docs/quickstart.md +4 -4
- package/docs/release-guide.md +21 -21
- package/docs/rpc.md +83 -6
- package/docs/sdk.md +1 -1
- package/docs/settings.md +8 -8
- package/docs/skills.md +2 -2
- package/docs/terminal-tools.md +1 -1
- package/docs/termux.md +1 -1
- package/docs/tui.md +1 -1
- package/examples/AGENTS.md +1 -1
- package/examples/sdk/README.md +1 -1
- package/node_modules/@code-yeongyu/senpi-codemode/CHANGELOG.md +85 -0
- package/node_modules/@code-yeongyu/senpi-codemode/README.md +6 -4
- package/node_modules/@code-yeongyu/senpi-codemode/package.json +4 -4
- package/node_modules/@code-yeongyu/senpi-codemode/src/extension/skill-contribution.ts +105 -0
- package/node_modules/@code-yeongyu/senpi-codemode/src/index.ts +6 -1
- package/node_modules/@code-yeongyu/senpi-codemode/src/prompt/eval-prompt.ts +10 -1
- package/node_modules/@code-yeongyu/senpi-codemode/src/skill/bun-1-4/SKILL.md +44 -0
- package/node_modules/@code-yeongyu/senpi-codemode/src/skill/bun-1-4/references/breaking-changes.md +75 -0
- package/node_modules/@code-yeongyu/senpi-codemode/src/skill/bun-1-4/references/build.md +114 -0
- package/node_modules/@code-yeongyu/senpi-codemode/src/skill/bun-1-4/references/dev-tooling.md +34 -0
- package/node_modules/@code-yeongyu/senpi-codemode/src/skill/bun-1-4/references/http-networking.md +113 -0
- package/node_modules/@code-yeongyu/senpi-codemode/src/skill/bun-1-4/references/install.md +93 -0
- package/node_modules/@code-yeongyu/senpi-codemode/src/skill/bun-1-4/references/node-compat-platforms.md +36 -0
- package/node_modules/@code-yeongyu/senpi-codemode/src/skill/bun-1-4/references/performance.md +33 -0
- package/node_modules/@code-yeongyu/senpi-codemode/src/skill/bun-1-4/references/runtime-apis.md +156 -0
- package/node_modules/@code-yeongyu/senpi-codemode/src/skill/bun-1-4/references/security.md +52 -0
- package/node_modules/@code-yeongyu/senpi-codemode/src/skill/bun-1-4/references/test.md +103 -0
- package/node_modules/@code-yeongyu/senpi-codemode/src/tool/eval-tool-options.ts +3 -1
- package/node_modules/@code-yeongyu/senpi-codemode/src/tool/eval-tool.ts +2 -0
- package/node_modules/@earendil-works/pi-agent-core/README.md +3 -0
- package/node_modules/@earendil-works/pi-agent-core/dist/agent-loop.d.ts +3 -0
- package/node_modules/@earendil-works/pi-agent-core/dist/agent-loop.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-agent-core/dist/agent-loop.js +2 -2
- package/node_modules/@earendil-works/pi-agent-core/dist/agent-loop.js.map +1 -1
- package/node_modules/@earendil-works/pi-agent-core/package.json +3 -3
- package/node_modules/@earendil-works/pi-ai/README.md +6 -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 +24 -7
- 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.d.ts +7 -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 +316 -2
- package/node_modules/@earendil-works/pi-ai/dist/api/cursor-agent.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/api/cursor-conversation-rotation.d.ts +4 -0
- package/node_modules/@earendil-works/pi-ai/dist/api/cursor-conversation-rotation.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/api/cursor-conversation-rotation.js +23 -0
- package/node_modules/@earendil-works/pi-ai/dist/api/cursor-conversation-rotation.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/api/openai-responses.d.ts +24 -0
- 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 +20 -2
- package/node_modules/@earendil-works/pi-ai/dist/api/openai-responses.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/amazon-bedrock.json +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/data/anthropic.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/google.json +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/data/groq.json +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/data/nvidia.json +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/data/opencode.json +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/data/opengateway.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/vercel-ai-gateway.json +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/utils/retry-profile/profiles.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/utils/retry-profile/profiles.js +3 -1
- package/node_modules/@earendil-works/pi-ai/dist/utils/retry-profile/profiles.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/utils/retry.js +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/utils/retry.js.map +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/README.md +6 -3
- package/node_modules/@earendil-works/pi-telemetry/package.json +1 -1
- package/node_modules/@earendil-works/pi-tui/README.md +5 -4
- package/node_modules/@earendil-works/pi-tui/native/darwin/README.md +2 -2
- package/node_modules/@earendil-works/pi-tui/native/win32/README.md +2 -2
- package/node_modules/@earendil-works/pi-tui/package.json +1 -1
- package/package.json +7 -7
|
@@ -1,38 +1,95 @@
|
|
|
1
1
|
import xterm from "@xterm/headless";
|
|
2
|
+
import { MAX_PENDING_WRITE_CHARS, settleOperation, sharedSettler, } from "./screen-operations.js";
|
|
3
|
+
import { decodeInput, normalizeDimension, normalizeReplayHistoryLength, normalizeScrollback, readLine, sanitizeString, } from "./screen-text.js";
|
|
2
4
|
const XtermTerminal = xterm.Terminal;
|
|
3
5
|
const DEFAULT_COLS = 80;
|
|
4
6
|
const DEFAULT_ROWS = 24;
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
7
|
+
/**
|
|
8
|
+
* Headless xterm screen model with serialized, flow-controlled writes.
|
|
9
|
+
*
|
|
10
|
+
* Every terminal mutation (feed, resize, backlog replay) runs through one
|
|
11
|
+
* FIFO queue that awaits xterm's parse callback before issuing the next
|
|
12
|
+
* write, so xterm's pending-write watermark can never be exceeded. When the
|
|
13
|
+
* queued backlog outgrows {@link MAX_PENDING_WRITE_CHARS}, the queued writes
|
|
14
|
+
* collapse into a single bounded history replay that reconstructs the same
|
|
15
|
+
* screen state. After {@link TerminalScreen.dispose}, queued and future
|
|
16
|
+
* operations settle as resolved no-ops; a terminal is never created after
|
|
17
|
+
* disposal.
|
|
18
|
+
*/
|
|
10
19
|
export class TerminalScreen {
|
|
11
20
|
constructor(options = {}) {
|
|
12
21
|
this.history = [];
|
|
13
22
|
this.historyLength = 0;
|
|
23
|
+
this.operations = [];
|
|
24
|
+
this.pendingChars = 0;
|
|
25
|
+
this.draining = false;
|
|
26
|
+
this.disposed = false;
|
|
27
|
+
this.notifyDisposed = () => undefined;
|
|
14
28
|
const cols = normalizeDimension(options.cols, DEFAULT_COLS);
|
|
15
29
|
const rows = normalizeDimension(options.rows, DEFAULT_ROWS);
|
|
16
30
|
this.scrollback = normalizeScrollback(options.scrollback);
|
|
17
31
|
this.maxReplayHistoryLength = normalizeReplayHistoryLength(cols, rows, this.scrollback);
|
|
32
|
+
this.whenDisposed = new Promise((resolve) => {
|
|
33
|
+
this.notifyDisposed = resolve;
|
|
34
|
+
});
|
|
18
35
|
this.terminal = this.createTerminal(cols, rows);
|
|
19
36
|
}
|
|
20
37
|
feed(data) {
|
|
38
|
+
if (this.disposed)
|
|
39
|
+
return Promise.resolve();
|
|
21
40
|
const payload = decodeInput(data);
|
|
22
41
|
const sanitizedPayload = sanitizeString(payload);
|
|
23
42
|
if (sanitizedPayload.length > 0)
|
|
24
43
|
this.appendHistory(sanitizedPayload);
|
|
25
|
-
|
|
44
|
+
if (this.pendingChars + payload.length > MAX_PENDING_WRITE_CHARS) {
|
|
45
|
+
return this.coalesceFeedIntoReplay(payload);
|
|
46
|
+
}
|
|
47
|
+
this.pendingChars += payload.length;
|
|
48
|
+
const operation = { kind: "write", payload, settled: null, settlers: [] };
|
|
49
|
+
return this.enqueue(operation, sharedSettler(operation));
|
|
26
50
|
}
|
|
27
51
|
resize(cols, rows) {
|
|
52
|
+
if (this.disposed)
|
|
53
|
+
return Promise.resolve();
|
|
28
54
|
const nextCols = normalizeDimension(cols, this.terminal.cols);
|
|
29
55
|
const nextRows = normalizeDimension(rows, this.terminal.rows);
|
|
30
|
-
this.
|
|
31
|
-
|
|
32
|
-
|
|
56
|
+
const snapshot = this.history.join("");
|
|
57
|
+
const tail = this.operations[this.operations.length - 1];
|
|
58
|
+
if (tail !== undefined && tail.kind === "resize") {
|
|
59
|
+
tail.cols = nextCols;
|
|
60
|
+
tail.rows = nextRows;
|
|
61
|
+
this.pendingChars += snapshot.length - tail.replay.length;
|
|
62
|
+
tail.replay = snapshot;
|
|
63
|
+
return sharedSettler(tail);
|
|
64
|
+
}
|
|
65
|
+
if (this.pendingChars + snapshot.length > MAX_PENDING_WRITE_CHARS) {
|
|
66
|
+
return this.coalesceQueueIntoResize(nextCols, nextRows, snapshot);
|
|
67
|
+
}
|
|
68
|
+
const operation = {
|
|
69
|
+
kind: "resize",
|
|
70
|
+
cols: nextCols,
|
|
71
|
+
rows: nextRows,
|
|
72
|
+
replay: snapshot,
|
|
73
|
+
settled: null,
|
|
74
|
+
settlers: [],
|
|
75
|
+
};
|
|
76
|
+
this.pendingChars += snapshot.length;
|
|
77
|
+
return this.enqueue(operation, sharedSettler(operation));
|
|
33
78
|
}
|
|
79
|
+
/**
|
|
80
|
+
* Resolves once everything fed before this call has been parsed. Attaches
|
|
81
|
+
* to the queue tail instead of enqueueing a marker so a flush can never
|
|
82
|
+
* split a tail replay (which would let over-cap feeds mint unbounded new
|
|
83
|
+
* replay operations); only an empty queue enqueues a zero-length write.
|
|
84
|
+
*/
|
|
34
85
|
flush() {
|
|
35
|
-
|
|
86
|
+
if (this.disposed)
|
|
87
|
+
return Promise.resolve();
|
|
88
|
+
const tail = this.operations[this.operations.length - 1];
|
|
89
|
+
if (tail !== undefined)
|
|
90
|
+
return sharedSettler(tail);
|
|
91
|
+
const operation = { kind: "write", payload: "", settled: null, settlers: [] };
|
|
92
|
+
return this.enqueue(operation, sharedSettler(operation));
|
|
36
93
|
}
|
|
37
94
|
snapshot() {
|
|
38
95
|
const buffer = this.terminal.buffer.active;
|
|
@@ -58,6 +115,15 @@ export class TerminalScreen {
|
|
|
58
115
|
};
|
|
59
116
|
}
|
|
60
117
|
dispose() {
|
|
118
|
+
if (this.disposed)
|
|
119
|
+
return;
|
|
120
|
+
this.disposed = true;
|
|
121
|
+
this.notifyDisposed();
|
|
122
|
+
const pending = this.operations.splice(0, this.operations.length);
|
|
123
|
+
this.pendingChars = 0;
|
|
124
|
+
for (const operation of pending) {
|
|
125
|
+
settleOperation(operation.settlers, null);
|
|
126
|
+
}
|
|
61
127
|
this.terminal.dispose();
|
|
62
128
|
}
|
|
63
129
|
createTerminal(cols, rows) {
|
|
@@ -70,6 +136,108 @@ export class TerminalScreen {
|
|
|
70
136
|
logLevel: "off",
|
|
71
137
|
});
|
|
72
138
|
}
|
|
139
|
+
enqueue(operation, settled) {
|
|
140
|
+
this.operations.push(operation);
|
|
141
|
+
void this.drain();
|
|
142
|
+
return settled;
|
|
143
|
+
}
|
|
144
|
+
/**
|
|
145
|
+
* Route an over-cap feed to the queue's tail replay instead of enqueueing
|
|
146
|
+
* another write. Replay payloads are owned snapshot strings (immune to
|
|
147
|
+
* history trimming) bounded to the replay budget, and every coalesced feed
|
|
148
|
+
* shares the tail's memoized promise, so a flood cannot grow the queue,
|
|
149
|
+
* its payload memory, or its settler memory past the configured bounds.
|
|
150
|
+
*/
|
|
151
|
+
coalesceFeedIntoReplay(payload) {
|
|
152
|
+
const tail = this.operations[this.operations.length - 1];
|
|
153
|
+
if (tail !== undefined && tail.kind === "replay") {
|
|
154
|
+
const previousLength = tail.payload.length;
|
|
155
|
+
tail.payload = this.boundReplayPayload(tail.payload + payload);
|
|
156
|
+
this.pendingChars += tail.payload.length - previousLength;
|
|
157
|
+
return sharedSettler(tail);
|
|
158
|
+
}
|
|
159
|
+
const operation = {
|
|
160
|
+
kind: "replay",
|
|
161
|
+
payload: this.history.join(""),
|
|
162
|
+
settled: null,
|
|
163
|
+
settlers: [],
|
|
164
|
+
};
|
|
165
|
+
this.pendingChars += operation.payload.length;
|
|
166
|
+
return this.enqueue(operation, sharedSettler(operation));
|
|
167
|
+
}
|
|
168
|
+
/**
|
|
169
|
+
* A resize whose snapshot would push the queued payload past the cap
|
|
170
|
+
* collapses the whole queue into one resize at the latest dimensions:
|
|
171
|
+
* every dropped operation's payload is already covered by the bounded
|
|
172
|
+
* history snapshot, and their settlers settle with this operation.
|
|
173
|
+
*/
|
|
174
|
+
coalesceQueueIntoResize(cols, rows, snapshot) {
|
|
175
|
+
const operation = {
|
|
176
|
+
kind: "resize",
|
|
177
|
+
cols,
|
|
178
|
+
rows,
|
|
179
|
+
replay: snapshot,
|
|
180
|
+
settled: null,
|
|
181
|
+
settlers: [],
|
|
182
|
+
};
|
|
183
|
+
for (const queued of this.operations.splice(0, this.operations.length)) {
|
|
184
|
+
for (const settler of queued.settlers)
|
|
185
|
+
operation.settlers.push(settler);
|
|
186
|
+
queued.settlers.length = 0;
|
|
187
|
+
}
|
|
188
|
+
this.pendingChars = snapshot.length;
|
|
189
|
+
return this.enqueue(operation, sharedSettler(operation));
|
|
190
|
+
}
|
|
191
|
+
boundReplayPayload(payload) {
|
|
192
|
+
if (payload.length <= this.maxReplayHistoryLength)
|
|
193
|
+
return payload;
|
|
194
|
+
return sanitizeString(payload.slice(-this.maxReplayHistoryLength));
|
|
195
|
+
}
|
|
196
|
+
async drain() {
|
|
197
|
+
if (this.draining)
|
|
198
|
+
return;
|
|
199
|
+
this.draining = true;
|
|
200
|
+
try {
|
|
201
|
+
while (!this.disposed) {
|
|
202
|
+
const operation = this.operations.shift();
|
|
203
|
+
if (operation === undefined)
|
|
204
|
+
return;
|
|
205
|
+
this.pendingChars -= operation.kind === "resize" ? operation.replay.length : operation.payload.length;
|
|
206
|
+
try {
|
|
207
|
+
await this.run(operation);
|
|
208
|
+
settleOperation(operation.settlers, null);
|
|
209
|
+
}
|
|
210
|
+
catch (error) {
|
|
211
|
+
settleOperation(operation.settlers, error instanceof Error ? error : new Error(String(error)));
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
finally {
|
|
216
|
+
this.draining = false;
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
async run(operation) {
|
|
220
|
+
if (this.disposed)
|
|
221
|
+
return;
|
|
222
|
+
switch (operation.kind) {
|
|
223
|
+
case "write":
|
|
224
|
+
await this.raceDisposal(this.write(operation.payload));
|
|
225
|
+
return;
|
|
226
|
+
case "replay":
|
|
227
|
+
this.terminal.reset();
|
|
228
|
+
await this.raceDisposal(this.write(operation.payload));
|
|
229
|
+
return;
|
|
230
|
+
case "resize":
|
|
231
|
+
this.terminal.dispose();
|
|
232
|
+
this.terminal = this.createTerminal(operation.cols, operation.rows);
|
|
233
|
+
await this.raceDisposal(this.write(operation.replay));
|
|
234
|
+
return;
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
/** A disposed terminal may never invoke its parse callback; do not hang. */
|
|
238
|
+
raceDisposal(written) {
|
|
239
|
+
return Promise.race([written, this.whenDisposed]);
|
|
240
|
+
}
|
|
73
241
|
write(payload) {
|
|
74
242
|
return new Promise((resolve, reject) => {
|
|
75
243
|
try {
|
|
@@ -107,49 +275,4 @@ export class TerminalScreen {
|
|
|
107
275
|
this.historyLength = trimmed.length;
|
|
108
276
|
}
|
|
109
277
|
}
|
|
110
|
-
function readLine(buffer, lineIndex) {
|
|
111
|
-
return buffer.getLine(lineIndex)?.translateToString(true) ?? "";
|
|
112
|
-
}
|
|
113
|
-
function normalizeDimension(value, fallback) {
|
|
114
|
-
if (value === undefined || !Number.isFinite(value))
|
|
115
|
-
return fallback;
|
|
116
|
-
return Math.min(MAX_SIZE, Math.max(MIN_SIZE, Math.trunc(value)));
|
|
117
|
-
}
|
|
118
|
-
function normalizeScrollback(value) {
|
|
119
|
-
if (value === undefined || !Number.isFinite(value))
|
|
120
|
-
return DEFAULT_SCROLLBACK;
|
|
121
|
-
return Math.max(0, Math.trunc(value));
|
|
122
|
-
}
|
|
123
|
-
function normalizeReplayHistoryLength(cols, rows, scrollback) {
|
|
124
|
-
const visibleCells = Math.max(MIN_SIZE, cols) * Math.max(MIN_SIZE, rows + scrollback + 1);
|
|
125
|
-
return Math.min(MAX_REPLAY_HISTORY_LENGTH, Math.max(MIN_REPLAY_HISTORY_LENGTH, visibleCells * 4));
|
|
126
|
-
}
|
|
127
|
-
function decodeInput(value) {
|
|
128
|
-
if (typeof value === "string")
|
|
129
|
-
return value;
|
|
130
|
-
return new TextDecoder("utf-8", { fatal: false }).decode(value);
|
|
131
|
-
}
|
|
132
|
-
function sanitizeString(value) {
|
|
133
|
-
let output = "";
|
|
134
|
-
for (let index = 0; index < value.length; index += 1) {
|
|
135
|
-
const code = value.charCodeAt(index);
|
|
136
|
-
if (code >= 0xd800 && code <= 0xdbff) {
|
|
137
|
-
const next = value.charCodeAt(index + 1);
|
|
138
|
-
if (next >= 0xdc00 && next <= 0xdfff) {
|
|
139
|
-
output += value[index] + value[index + 1];
|
|
140
|
-
index += 1;
|
|
141
|
-
}
|
|
142
|
-
else {
|
|
143
|
-
output += "\uFFFD";
|
|
144
|
-
}
|
|
145
|
-
}
|
|
146
|
-
else if (code >= 0xdc00 && code <= 0xdfff) {
|
|
147
|
-
output += "\uFFFD";
|
|
148
|
-
}
|
|
149
|
-
else {
|
|
150
|
-
output += value[index];
|
|
151
|
-
}
|
|
152
|
-
}
|
|
153
|
-
return output;
|
|
154
|
-
}
|
|
155
278
|
//# sourceMappingURL=screen.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"screen.js","sourceRoot":"","sources":["../src/screen.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,MAAM,iBAAiB,CAAC;AAmBpC,MAAM,aAAa,GAAG,KAAK,CAAC,QAAQ,CAAC;AACrC,MAAM,YAAY,GAAG,EAAE,CAAC;AACxB,MAAM,YAAY,GAAG,EAAE,CAAC;AACxB,MAAM,kBAAkB,GAAG,IAAI,CAAC;AAChC,MAAM,QAAQ,GAAG,CAAC,CAAC;AACnB,MAAM,QAAQ,GAAG,KAAK,CAAC;AACvB,MAAM,yBAAyB,GAAG,IAAI,CAAC;AACvC,MAAM,yBAAyB,GAAG,SAAS,CAAC;AAE5C,MAAM,OAAO,cAAc;IAO1B,YAAY,UAAiC,EAAE;QAL9B,YAAO,GAAa,EAAE,CAAC;QAChC,kBAAa,GAAG,CAAC,CAAC;QAKzB,MAAM,IAAI,GAAG,kBAAkB,CAAC,OAAO,CAAC,IAAI,EAAE,YAAY,CAAC,CAAC;QAC5D,MAAM,IAAI,GAAG,kBAAkB,CAAC,OAAO,CAAC,IAAI,EAAE,YAAY,CAAC,CAAC;QAC5D,IAAI,CAAC,UAAU,GAAG,mBAAmB,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC;QAC1D,IAAI,CAAC,sBAAsB,GAAG,4BAA4B,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC,UAAU,CAAC,CAAC;QACxF,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC,cAAc,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;IACjD,CAAC;IAED,IAAI,CAAC,IAAyB;QAC7B,MAAM,OAAO,GAAG,WAAW,CAAC,IAAI,CAAC,CAAC;QAClC,MAAM,gBAAgB,GAAG,cAAc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,KAAK,CAAC,MAAM,EAAE,KAAK,IAAI,CAAC,EAAE,CAAC;QACtD,MAAM,IAAI,GAAG,KAAK,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC;QACrC,IAAI,IAAI,IAAI,MAAM,IAAI,IAAI,IAAI,MAAM,EAAE,CAAC;YACtC,MAAM,IAAI,GAAG,KAAK,CAAC,UAAU,CAAC,KAAK,GAAG,CAAC,CAAC,CAAC;YACzC,IAAI,IAAI,IAAI,MAAM,IAAI,IAAI,IAAI,MAAM,EAAE,CAAC;gBACtC,MAAM,IAAI,KAAK,CAAC,KAAK,CAAC,GAAG,KAAK,CAAC,KAAK,GAAG,CAAC,CAAC,CAAC;gBAC1C,KAAK,IAAI,CAAC,CAAC;YACZ,CAAC;iBAAM,CAAC;gBACP,MAAM,IAAI,QAAQ,CAAC;YACpB,CAAC;QACF,CAAC;aAAM,IAAI,IAAI,IAAI,MAAM,IAAI,IAAI,IAAI,MAAM,EAAE,CAAC;YAC7C,MAAM,IAAI,QAAQ,CAAC;QACpB,CAAC;aAAM,CAAC;YACP,MAAM,IAAI,KAAK,CAAC,KAAK,CAAC,CAAC;QACxB,CAAC;IACF,CAAC;IACD,OAAO,MAAM,CAAC;AACf,CAAC","sourcesContent":["import type { Terminal as XtermTerminalType } from \"@xterm/headless\";\nimport xterm from \"@xterm/headless\";\n\nexport interface TerminalScreenOptions {\n\treadonly cols?: number;\n\treadonly rows?: number;\n\treadonly scrollback?: number;\n}\n\nexport interface TerminalScreenSnapshot {\n\treadonly cols: number;\n\treadonly rows: number;\n\treadonly visibleGrid: readonly string[];\n\treadonly scrollback: readonly string[];\n\treadonly cursor: {\n\t\treadonly x: number;\n\t\treadonly y: number;\n\t};\n}\n\nconst XtermTerminal = xterm.Terminal;\nconst DEFAULT_COLS = 80;\nconst DEFAULT_ROWS = 24;\nconst DEFAULT_SCROLLBACK = 1000;\nconst MIN_SIZE = 1;\nconst MAX_SIZE = 10000;\nconst MIN_REPLAY_HISTORY_LENGTH = 4096;\nconst MAX_REPLAY_HISTORY_LENGTH = 1_000_000;\n\nexport class TerminalScreen {\n\tprivate terminal: XtermTerminalType;\n\tprivate readonly history: string[] = [];\n\tprivate historyLength = 0;\n\tprivate readonly maxReplayHistoryLength: number;\n\tprivate readonly scrollback: number;\n\n\tconstructor(options: TerminalScreenOptions = {}) {\n\t\tconst cols = normalizeDimension(options.cols, DEFAULT_COLS);\n\t\tconst rows = normalizeDimension(options.rows, DEFAULT_ROWS);\n\t\tthis.scrollback = normalizeScrollback(options.scrollback);\n\t\tthis.maxReplayHistoryLength = normalizeReplayHistoryLength(cols, rows, this.scrollback);\n\t\tthis.terminal = this.createTerminal(cols, rows);\n\t}\n\n\tfeed(data: string | Uint8Array): Promise<void> {\n\t\tconst payload = decodeInput(data);\n\t\tconst sanitizedPayload = sanitizeString(payload);\n\t\tif (sanitizedPayload.length > 0) this.appendHistory(sanitizedPayload);\n\t\treturn this.write(payload);\n\t}\n\n\tresize(cols: number, rows: number): Promise<void> {\n\t\tconst nextCols = normalizeDimension(cols, this.terminal.cols);\n\t\tconst nextRows = normalizeDimension(rows, this.terminal.rows);\n\t\tthis.terminal.dispose();\n\t\tthis.terminal = this.createTerminal(nextCols, nextRows);\n\t\treturn this.write(this.history.join(\"\"));\n\t}\n\n\tflush(): Promise<void> {\n\t\treturn this.write(\"\");\n\t}\n\n\tsnapshot(): TerminalScreenSnapshot {\n\t\tconst buffer = this.terminal.buffer.active;\n\t\tconst viewportStart = buffer.viewportY;\n\t\tconst visibleGrid: string[] = [];\n\t\tconst scrollback: string[] = [];\n\t\tconst scrollbackStart = Math.max(0, viewportStart - this.scrollback);\n\n\t\tfor (let lineIndex = scrollbackStart; lineIndex < viewportStart; lineIndex += 1) {\n\t\t\tscrollback.push(readLine(buffer, lineIndex));\n\t\t}\n\t\tfor (let row = 0; row < this.terminal.rows; row += 1) {\n\t\t\tvisibleGrid.push(readLine(buffer, viewportStart + row));\n\t\t}\n\n\t\treturn {\n\t\t\tcols: this.terminal.cols,\n\t\t\trows: this.terminal.rows,\n\t\t\tvisibleGrid,\n\t\t\tscrollback,\n\t\t\tcursor: {\n\t\t\t\tx: buffer.cursorX,\n\t\t\t\ty: buffer.cursorY,\n\t\t\t},\n\t\t};\n\t}\n\n\tdispose(): void {\n\t\tthis.terminal.dispose();\n\t}\n\n\tprivate createTerminal(cols: number, rows: number): XtermTerminalType {\n\t\treturn new XtermTerminal({\n\t\t\tcols,\n\t\t\trows,\n\t\t\tscrollback: this.scrollback,\n\t\t\tdisableStdin: true,\n\t\t\tallowProposedApi: true,\n\t\t\tlogLevel: \"off\",\n\t\t});\n\t}\n\n\tprivate write(payload: string): Promise<void> {\n\t\treturn new Promise((resolve, reject) => {\n\t\t\ttry {\n\t\t\t\tthis.terminal.write(payload, resolve);\n\t\t\t} catch (error) {\n\t\t\t\tconst sanitizedPayload = sanitizeString(payload);\n\t\t\t\tif (sanitizedPayload === payload) {\n\t\t\t\t\treject(error instanceof Error ? error : new Error(String(error)));\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tthis.terminal.write(sanitizedPayload, resolve);\n\t\t\t}\n\t\t});\n\t}\n\n\tprivate appendHistory(payload: string): void {\n\t\tthis.history.push(payload);\n\t\tthis.historyLength += payload.length;\n\t\tthis.trimHistory();\n\t}\n\n\tprivate trimHistory(): void {\n\t\twhile (this.historyLength > this.maxReplayHistoryLength && this.history.length > 1) {\n\t\t\tconst removed = this.history.shift();\n\t\t\tif (removed === undefined) return;\n\t\t\tthis.historyLength -= removed.length;\n\t\t}\n\n\t\tif (this.historyLength <= this.maxReplayHistoryLength) return;\n\t\tconst [onlyChunk] = this.history;\n\t\tif (onlyChunk === undefined) return;\n\t\tconst trimmed = sanitizeString(onlyChunk.slice(-this.maxReplayHistoryLength));\n\t\tthis.history[0] = trimmed;\n\t\tthis.historyLength = trimmed.length;\n\t}\n}\n\nfunction readLine(buffer: XtermTerminalType[\"buffer\"][\"active\"], lineIndex: number): string {\n\treturn buffer.getLine(lineIndex)?.translateToString(true) ?? \"\";\n}\n\nfunction normalizeDimension(value: number | undefined, fallback: number): number {\n\tif (value === undefined || !Number.isFinite(value)) return fallback;\n\treturn Math.min(MAX_SIZE, Math.max(MIN_SIZE, Math.trunc(value)));\n}\n\nfunction normalizeScrollback(value: number | undefined): number {\n\tif (value === undefined || !Number.isFinite(value)) return DEFAULT_SCROLLBACK;\n\treturn Math.max(0, Math.trunc(value));\n}\n\nfunction normalizeReplayHistoryLength(cols: number, rows: number, scrollback: number): number {\n\tconst visibleCells = Math.max(MIN_SIZE, cols) * Math.max(MIN_SIZE, rows + scrollback + 1);\n\treturn Math.min(MAX_REPLAY_HISTORY_LENGTH, Math.max(MIN_REPLAY_HISTORY_LENGTH, visibleCells * 4));\n}\n\nfunction decodeInput(value: string | Uint8Array): string {\n\tif (typeof value === \"string\") return value;\n\treturn new TextDecoder(\"utf-8\", { fatal: false }).decode(value);\n}\n\nfunction sanitizeString(value: string): string {\n\tlet output = \"\";\n\tfor (let index = 0; index < value.length; index += 1) {\n\t\tconst code = value.charCodeAt(index);\n\t\tif (code >= 0xd800 && code <= 0xdbff) {\n\t\t\tconst next = value.charCodeAt(index + 1);\n\t\t\tif (next >= 0xdc00 && next <= 0xdfff) {\n\t\t\t\toutput += value[index] + value[index + 1];\n\t\t\t\tindex += 1;\n\t\t\t} else {\n\t\t\t\toutput += \"\\uFFFD\";\n\t\t\t}\n\t\t} else if (code >= 0xdc00 && code <= 0xdfff) {\n\t\t\toutput += \"\\uFFFD\";\n\t\t} else {\n\t\t\toutput += value[index];\n\t\t}\n\t}\n\treturn output;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"screen.js","sourceRoot":"","sources":["../src/screen.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,MAAM,iBAAiB,CAAC;AACpC,OAAO,EACN,uBAAuB,EAIvB,eAAe,EACf,aAAa,GACb,MAAM,wBAAwB,CAAC;AAEhC,OAAO,EACN,WAAW,EACX,kBAAkB,EAClB,4BAA4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C,WAAW,EAAE,CAAC;IACpB,CAAC;IAEO,WAAW;QAClB,OAAO,IAAI,CAAC,aAAa,GAAG,IAAI,CAAC,sBAAsB,IAAI,IAAI,CAAC,OAAO,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YACpF,MAAM,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,CAAC;YACrC,IAAI,OAAO,KAAK,SAAS;gBAAE,OAAO;YAClC,IAAI,CAAC,aAAa,IAAI,OAAO,CAAC,MAAM,CAAC;QACtC,CAAC;QAED,IAAI,IAAI,CAAC,aAAa,IAAI,IAAI,CAAC,sBAAsB;YAAE,OAAO;QAC9D,MAAM,CAAC,SAAS,CAAC,GAAG,IAAI,CAAC,OAAO,CAAC;QACjC,IAAI,SAAS,KAAK,SAAS;YAAE,OAAO;QACpC,MAAM,OAAO,GAAG,cAAc,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,sBAAsB,CAAC,CAAC,CAAC;QAC9E,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC;QAC1B,IAAI,CAAC,aAAa,GAAG,OAAO,CAAC,MAAM,CAAC;IACrC,CAAC;CACD","sourcesContent":["import type { Terminal as XtermTerminalType } from \"@xterm/headless\";\nimport xterm from \"@xterm/headless\";\nimport {\n\tMAX_PENDING_WRITE_CHARS,\n\ttype ReplayOperation,\n\ttype ResizeOperation,\n\ttype ScreenOperation,\n\tsettleOperation,\n\tsharedSettler,\n} from \"./screen-operations.ts\";\n\nimport {\n\tdecodeInput,\n\tnormalizeDimension,\n\tnormalizeReplayHistoryLength,\n\tnormalizeScrollback,\n\treadLine,\n\tsanitizeString,\n} from \"./screen-text.ts\";\n\nexport interface TerminalScreenOptions {\n\treadonly cols?: number;\n\treadonly rows?: number;\n\treadonly scrollback?: number;\n}\n\nexport interface TerminalScreenSnapshot {\n\treadonly cols: number;\n\treadonly rows: number;\n\treadonly visibleGrid: readonly string[];\n\treadonly scrollback: readonly string[];\n\treadonly cursor: {\n\t\treadonly x: number;\n\t\treadonly y: number;\n\t};\n}\n\nconst XtermTerminal = xterm.Terminal;\nconst DEFAULT_COLS = 80;\nconst DEFAULT_ROWS = 24;\n\n/**\n * Headless xterm screen model with serialized, flow-controlled writes.\n *\n * Every terminal mutation (feed, resize, backlog replay) runs through one\n * FIFO queue that awaits xterm's parse callback before issuing the next\n * write, so xterm's pending-write watermark can never be exceeded. When the\n * queued backlog outgrows {@link MAX_PENDING_WRITE_CHARS}, the queued writes\n * collapse into a single bounded history replay that reconstructs the same\n * screen state. After {@link TerminalScreen.dispose}, queued and future\n * operations settle as resolved no-ops; a terminal is never created after\n * disposal.\n */\nexport class TerminalScreen {\n\tprivate terminal: XtermTerminalType;\n\tprivate readonly history: string[] = [];\n\tprivate historyLength = 0;\n\tprivate readonly operations: ScreenOperation[] = [];\n\tprivate pendingChars = 0;\n\tprivate draining = false;\n\tprivate disposed = false;\n\tprivate notifyDisposed: () => void = () => undefined;\n\tprivate readonly whenDisposed: Promise<void>;\n\tprivate readonly maxReplayHistoryLength: number;\n\tprivate readonly scrollback: number;\n\n\tconstructor(options: TerminalScreenOptions = {}) {\n\t\tconst cols = normalizeDimension(options.cols, DEFAULT_COLS);\n\t\tconst rows = normalizeDimension(options.rows, DEFAULT_ROWS);\n\t\tthis.scrollback = normalizeScrollback(options.scrollback);\n\t\tthis.maxReplayHistoryLength = normalizeReplayHistoryLength(cols, rows, this.scrollback);\n\t\tthis.whenDisposed = new Promise((resolve) => {\n\t\t\tthis.notifyDisposed = resolve;\n\t\t});\n\t\tthis.terminal = this.createTerminal(cols, rows);\n\t}\n\n\tfeed(data: string | Uint8Array): Promise<void> {\n\t\tif (this.disposed) return Promise.resolve();\n\t\tconst payload = decodeInput(data);\n\t\tconst sanitizedPayload = sanitizeString(payload);\n\t\tif (sanitizedPayload.length > 0) this.appendHistory(sanitizedPayload);\n\t\tif (this.pendingChars + payload.length > MAX_PENDING_WRITE_CHARS) {\n\t\t\treturn this.coalesceFeedIntoReplay(payload);\n\t\t}\n\t\tthis.pendingChars += payload.length;\n\t\tconst operation: ScreenOperation = { kind: \"write\", payload, settled: null, settlers: [] };\n\t\treturn this.enqueue(operation, sharedSettler(operation));\n\t}\n\n\tresize(cols: number, rows: number): Promise<void> {\n\t\tif (this.disposed) return Promise.resolve();\n\t\tconst nextCols = normalizeDimension(cols, this.terminal.cols);\n\t\tconst nextRows = normalizeDimension(rows, this.terminal.rows);\n\t\tconst snapshot = this.history.join(\"\");\n\t\tconst tail = this.operations[this.operations.length - 1];\n\t\tif (tail !== undefined && tail.kind === \"resize\") {\n\t\t\ttail.cols = nextCols;\n\t\t\ttail.rows = nextRows;\n\t\t\tthis.pendingChars += snapshot.length - tail.replay.length;\n\t\t\ttail.replay = snapshot;\n\t\t\treturn sharedSettler(tail);\n\t\t}\n\t\tif (this.pendingChars + snapshot.length > MAX_PENDING_WRITE_CHARS) {\n\t\t\treturn this.coalesceQueueIntoResize(nextCols, nextRows, snapshot);\n\t\t}\n\t\tconst operation: ResizeOperation = {\n\t\t\tkind: \"resize\",\n\t\t\tcols: nextCols,\n\t\t\trows: nextRows,\n\t\t\treplay: snapshot,\n\t\t\tsettled: null,\n\t\t\tsettlers: [],\n\t\t};\n\t\tthis.pendingChars += snapshot.length;\n\t\treturn this.enqueue(operation, sharedSettler(operation));\n\t}\n\n\t/**\n\t * Resolves once everything fed before this call has been parsed. Attaches\n\t * to the queue tail instead of enqueueing a marker so a flush can never\n\t * split a tail replay (which would let over-cap feeds mint unbounded new\n\t * replay operations); only an empty queue enqueues a zero-length write.\n\t */\n\tflush(): Promise<void> {\n\t\tif (this.disposed) return Promise.resolve();\n\t\tconst tail = this.operations[this.operations.length - 1];\n\t\tif (tail !== undefined) return sharedSettler(tail);\n\t\tconst operation: ScreenOperation = { kind: \"write\", payload: \"\", settled: null, settlers: [] };\n\t\treturn this.enqueue(operation, sharedSettler(operation));\n\t}\n\n\tsnapshot(): TerminalScreenSnapshot {\n\t\tconst buffer = this.terminal.buffer.active;\n\t\tconst viewportStart = buffer.viewportY;\n\t\tconst visibleGrid: string[] = [];\n\t\tconst scrollback: string[] = [];\n\t\tconst scrollbackStart = Math.max(0, viewportStart - this.scrollback);\n\n\t\tfor (let lineIndex = scrollbackStart; lineIndex < viewportStart; lineIndex += 1) {\n\t\t\tscrollback.push(readLine(buffer, lineIndex));\n\t\t}\n\t\tfor (let row = 0; row < this.terminal.rows; row += 1) {\n\t\t\tvisibleGrid.push(readLine(buffer, viewportStart + row));\n\t\t}\n\n\t\treturn {\n\t\t\tcols: this.terminal.cols,\n\t\t\trows: this.terminal.rows,\n\t\t\tvisibleGrid,\n\t\t\tscrollback,\n\t\t\tcursor: {\n\t\t\t\tx: buffer.cursorX,\n\t\t\t\ty: buffer.cursorY,\n\t\t\t},\n\t\t};\n\t}\n\n\tdispose(): void {\n\t\tif (this.disposed) return;\n\t\tthis.disposed = true;\n\t\tthis.notifyDisposed();\n\t\tconst pending = this.operations.splice(0, this.operations.length);\n\t\tthis.pendingChars = 0;\n\t\tfor (const operation of pending) {\n\t\t\tsettleOperation(operation.settlers, null);\n\t\t}\n\t\tthis.terminal.dispose();\n\t}\n\n\tprivate createTerminal(cols: number, rows: number): XtermTerminalType {\n\t\treturn new XtermTerminal({\n\t\t\tcols,\n\t\t\trows,\n\t\t\tscrollback: this.scrollback,\n\t\t\tdisableStdin: true,\n\t\t\tallowProposedApi: true,\n\t\t\tlogLevel: \"off\",\n\t\t});\n\t}\n\n\tprivate enqueue(operation: ScreenOperation, settled: Promise<void>): Promise<void> {\n\t\tthis.operations.push(operation);\n\t\tvoid this.drain();\n\t\treturn settled;\n\t}\n\n\t/**\n\t * Route an over-cap feed to the queue's tail replay instead of enqueueing\n\t * another write. Replay payloads are owned snapshot strings (immune to\n\t * history trimming) bounded to the replay budget, and every coalesced feed\n\t * shares the tail's memoized promise, so a flood cannot grow the queue,\n\t * its payload memory, or its settler memory past the configured bounds.\n\t */\n\tprivate coalesceFeedIntoReplay(payload: string): Promise<void> {\n\t\tconst tail = this.operations[this.operations.length - 1];\n\t\tif (tail !== undefined && tail.kind === \"replay\") {\n\t\t\tconst previousLength = tail.payload.length;\n\t\t\ttail.payload = this.boundReplayPayload(tail.payload + payload);\n\t\t\tthis.pendingChars += tail.payload.length - previousLength;\n\t\t\treturn sharedSettler(tail);\n\t\t}\n\t\tconst operation: ReplayOperation = {\n\t\t\tkind: \"replay\",\n\t\t\tpayload: this.history.join(\"\"),\n\t\t\tsettled: null,\n\t\t\tsettlers: [],\n\t\t};\n\t\tthis.pendingChars += operation.payload.length;\n\t\treturn this.enqueue(operation, sharedSettler(operation));\n\t}\n\n\t/**\n\t * A resize whose snapshot would push the queued payload past the cap\n\t * collapses the whole queue into one resize at the latest dimensions:\n\t * every dropped operation's payload is already covered by the bounded\n\t * history snapshot, and their settlers settle with this operation.\n\t */\n\tprivate coalesceQueueIntoResize(cols: number, rows: number, snapshot: string): Promise<void> {\n\t\tconst operation: ResizeOperation = {\n\t\t\tkind: \"resize\",\n\t\t\tcols,\n\t\t\trows,\n\t\t\treplay: snapshot,\n\t\t\tsettled: null,\n\t\t\tsettlers: [],\n\t\t};\n\t\tfor (const queued of this.operations.splice(0, this.operations.length)) {\n\t\t\tfor (const settler of queued.settlers) operation.settlers.push(settler);\n\t\t\tqueued.settlers.length = 0;\n\t\t}\n\t\tthis.pendingChars = snapshot.length;\n\t\treturn this.enqueue(operation, sharedSettler(operation));\n\t}\n\n\tprivate boundReplayPayload(payload: string): string {\n\t\tif (payload.length <= this.maxReplayHistoryLength) return payload;\n\t\treturn sanitizeString(payload.slice(-this.maxReplayHistoryLength));\n\t}\n\n\tprivate async drain(): Promise<void> {\n\t\tif (this.draining) return;\n\t\tthis.draining = true;\n\t\ttry {\n\t\t\twhile (!this.disposed) {\n\t\t\t\tconst operation = this.operations.shift();\n\t\t\t\tif (operation === undefined) return;\n\t\t\t\tthis.pendingChars -= operation.kind === \"resize\" ? operation.replay.length : operation.payload.length;\n\t\t\t\ttry {\n\t\t\t\t\tawait this.run(operation);\n\t\t\t\t\tsettleOperation(operation.settlers, null);\n\t\t\t\t} catch (error) {\n\t\t\t\t\tsettleOperation(operation.settlers, error instanceof Error ? error : new Error(String(error)));\n\t\t\t\t}\n\t\t\t}\n\t\t} finally {\n\t\t\tthis.draining = false;\n\t\t}\n\t}\n\n\tprivate async run(operation: ScreenOperation): Promise<void> {\n\t\tif (this.disposed) return;\n\t\tswitch (operation.kind) {\n\t\t\tcase \"write\":\n\t\t\t\tawait this.raceDisposal(this.write(operation.payload));\n\t\t\t\treturn;\n\t\t\tcase \"replay\":\n\t\t\t\tthis.terminal.reset();\n\t\t\t\tawait this.raceDisposal(this.write(operation.payload));\n\t\t\t\treturn;\n\t\t\tcase \"resize\":\n\t\t\t\tthis.terminal.dispose();\n\t\t\t\tthis.terminal = this.createTerminal(operation.cols, operation.rows);\n\t\t\t\tawait this.raceDisposal(this.write(operation.replay));\n\t\t\t\treturn;\n\t\t}\n\t}\n\n\t/** A disposed terminal may never invoke its parse callback; do not hang. */\n\tprivate raceDisposal(written: Promise<void>): Promise<void> {\n\t\treturn Promise.race([written, this.whenDisposed]);\n\t}\n\n\tprivate write(payload: string): Promise<void> {\n\t\treturn new Promise((resolve, reject) => {\n\t\t\ttry {\n\t\t\t\tthis.terminal.write(payload, resolve);\n\t\t\t} catch (error) {\n\t\t\t\tconst sanitizedPayload = sanitizeString(payload);\n\t\t\t\tif (sanitizedPayload === payload) {\n\t\t\t\t\treject(error instanceof Error ? error : new Error(String(error)));\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tthis.terminal.write(sanitizedPayload, resolve);\n\t\t\t}\n\t\t});\n\t}\n\n\tprivate appendHistory(payload: string): void {\n\t\tthis.history.push(payload);\n\t\tthis.historyLength += payload.length;\n\t\tthis.trimHistory();\n\t}\n\n\tprivate trimHistory(): void {\n\t\twhile (this.historyLength > this.maxReplayHistoryLength && this.history.length > 1) {\n\t\t\tconst removed = this.history.shift();\n\t\t\tif (removed === undefined) return;\n\t\t\tthis.historyLength -= removed.length;\n\t\t}\n\n\t\tif (this.historyLength <= this.maxReplayHistoryLength) return;\n\t\tconst [onlyChunk] = this.history;\n\t\tif (onlyChunk === undefined) return;\n\t\tconst trimmed = sanitizeString(onlyChunk.slice(-this.maxReplayHistoryLength));\n\t\tthis.history[0] = trimmed;\n\t\tthis.historyLength = trimmed.length;\n\t}\n}\n"]}
|
|
@@ -34,6 +34,9 @@ Applications can use the in-memory reference or provide an adapter for OpenTelem
|
|
|
34
34
|
|
|
35
35
|
```bash
|
|
36
36
|
npm install @earendil-works/pi-telemetry
|
|
37
|
+
|
|
38
|
+
# Bun alternative
|
|
39
|
+
bun add @earendil-works/pi-telemetry
|
|
37
40
|
```
|
|
38
41
|
|
|
39
42
|
## Telemetry Concepts
|
|
@@ -449,14 +452,14 @@ The package does not use `AsyncLocalStorage` or another runtime-specific ambient
|
|
|
449
452
|
From this package directory:
|
|
450
453
|
|
|
451
454
|
```bash
|
|
452
|
-
|
|
453
|
-
|
|
455
|
+
bun run test
|
|
456
|
+
bun run build
|
|
454
457
|
```
|
|
455
458
|
|
|
456
459
|
Repository-wide type checking, formatting, linting, and smoke checks run with:
|
|
457
460
|
|
|
458
461
|
```bash
|
|
459
|
-
|
|
462
|
+
bun run check
|
|
460
463
|
```
|
|
461
464
|
|
|
462
465
|
## License
|
|
@@ -828,7 +828,7 @@ See `test/chat-simple.ts` for a complete chat interface example with:
|
|
|
828
828
|
|
|
829
829
|
Run it:
|
|
830
830
|
```bash
|
|
831
|
-
|
|
831
|
+
bunx tsx test/chat-simple.ts
|
|
832
832
|
```
|
|
833
833
|
|
|
834
834
|
## Development
|
|
@@ -836,12 +836,13 @@ npx tsx test/chat-simple.ts
|
|
|
836
836
|
```bash
|
|
837
837
|
# Install dependencies (from monorepo root)
|
|
838
838
|
npm install
|
|
839
|
+
# Bun alternative: bun install
|
|
839
840
|
|
|
840
841
|
# Run type checking
|
|
841
|
-
|
|
842
|
+
bun run check
|
|
842
843
|
|
|
843
844
|
# Run the demo
|
|
844
|
-
|
|
845
|
+
bunx tsx test/chat-simple.ts
|
|
845
846
|
```
|
|
846
847
|
|
|
847
848
|
### Debug logging
|
|
@@ -849,5 +850,5 @@ npx tsx test/chat-simple.ts
|
|
|
849
850
|
Set `PI_TUI_WRITE_LOG` to capture the raw ANSI stream written to stdout.
|
|
850
851
|
|
|
851
852
|
```bash
|
|
852
|
-
PI_TUI_WRITE_LOG=/tmp/tui-ansi.log
|
|
853
|
+
PI_TUI_WRITE_LOG=/tmp/tui-ansi.log bunx tsx test/chat-simple.ts
|
|
853
854
|
```
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Build both macOS architectures from the repository root:
|
|
4
4
|
|
|
5
5
|
```sh
|
|
6
|
-
|
|
6
|
+
bun run --cwd packages/tui build:native:darwin
|
|
7
7
|
```
|
|
8
8
|
|
|
9
9
|
The build uses macOS 11.0 as the arm64 deployment target and macOS 10.15 as the x86_64 deployment target. On macOS, `build.sh` finds Apple clang and the active macOS SDK through `xcrun`. Either an Intel or Apple Silicon host can build both outputs.
|
|
@@ -12,7 +12,7 @@ A non-macOS host needs a complete Darwin cross-toolchain, including a macOS SDK
|
|
|
12
12
|
|
|
13
13
|
```sh
|
|
14
14
|
CC=/path/to/osxcross/clang SDKROOT=/path/to/MacOSX.sdk \
|
|
15
|
-
|
|
15
|
+
bun run --cwd packages/tui build:native:darwin
|
|
16
16
|
```
|
|
17
17
|
|
|
18
18
|
The SDK must be obtained and used in accordance with Apple's license. Plain Linux or Windows clang is not enough because the addon includes and links CoreGraphics.
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Build both Windows architectures from the repository root:
|
|
4
4
|
|
|
5
5
|
```sh
|
|
6
|
-
|
|
6
|
+
bun run --cwd packages/tui build:native:win32
|
|
7
7
|
```
|
|
8
8
|
|
|
9
9
|
On Windows, the build uses the Microsoft C++ Build Tools from Visual Studio. `build.mjs` locates `VsDevCmd.bat`, initializes a developer environment for `amd64` and `arm64`, and builds the addon with `cl.exe`/`link.exe`.
|
|
@@ -16,7 +16,7 @@ For non-Windows cross-builds, or for custom Windows toolchains, set `PI_TUI_WIN3
|
|
|
16
16
|
PI_TUI_WIN32_TOOLCHAIN=mingw \
|
|
17
17
|
CC_X64=/path/to/x86_64-w64-mingw32-gcc \
|
|
18
18
|
CC_ARM64=/path/to/aarch64-w64-mingw32-gcc \
|
|
19
|
-
|
|
19
|
+
bun run --cwd packages/tui build:native:win32
|
|
20
20
|
```
|
|
21
21
|
|
|
22
22
|
The addon intentionally avoids the C runtime and links only against `kernel32`.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@code-yeongyu/senpi",
|
|
3
|
-
"version": "2026.
|
|
3
|
+
"version": "2026.9.2-3",
|
|
4
4
|
"description": "Coding agent CLI with read, bash, edit, write tools and session management",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"piConfig": {
|
|
@@ -48,9 +48,9 @@
|
|
|
48
48
|
"qa:app-server": "node scripts/qa-app-server/run-all.mjs"
|
|
49
49
|
},
|
|
50
50
|
"dependencies": {
|
|
51
|
-
"@earendil-works/pi-agent-core": "npm:@code-yeongyu/senpi-agent-core@2026.
|
|
52
|
-
"@earendil-works/pi-ai": "npm:@code-yeongyu/senpi-ai@2026.
|
|
53
|
-
"@earendil-works/pi-tui": "npm:@code-yeongyu/senpi-tui@2026.
|
|
51
|
+
"@earendil-works/pi-agent-core": "npm:@code-yeongyu/senpi-agent-core@2026.9.2-3",
|
|
52
|
+
"@earendil-works/pi-ai": "npm:@code-yeongyu/senpi-ai@2026.9.2-3",
|
|
53
|
+
"@earendil-works/pi-tui": "npm:@code-yeongyu/senpi-tui@2026.9.2-3",
|
|
54
54
|
"@silvia-odwyer/photon-node": "0.3.4",
|
|
55
55
|
"chalk": "6.0.0",
|
|
56
56
|
"cross-spawn": "7.0.6",
|
|
@@ -70,8 +70,8 @@
|
|
|
70
70
|
"@anthropic-ai/sdk": "0.120.0",
|
|
71
71
|
"@aws-sdk/client-bedrock-runtime": "3.1116.0",
|
|
72
72
|
"@bufbuild/protobuf": "2.14.0",
|
|
73
|
-
"@code-yeongyu/senpi-codemode": "2026.
|
|
74
|
-
"@earendil-works/pi-pty": "npm:@code-yeongyu/senpi-pty@2026.
|
|
73
|
+
"@code-yeongyu/senpi-codemode": "2026.9.2-3",
|
|
74
|
+
"@earendil-works/pi-pty": "npm:@code-yeongyu/senpi-pty@2026.9.2-3",
|
|
75
75
|
"@modelcontextprotocol/sdk": "1.30.0",
|
|
76
76
|
"@mozilla/readability": "0.6.0",
|
|
77
77
|
"@opentelemetry/api": "1.9.1",
|
|
@@ -119,7 +119,7 @@
|
|
|
119
119
|
"@csstools/css-parser-algorithms": "4.0.0",
|
|
120
120
|
"@csstools/css-syntax-patches-for-csstree": "1.1.8",
|
|
121
121
|
"@csstools/css-tokenizer": "4.0.0",
|
|
122
|
-
"@earendil-works/pi-telemetry": "npm:@code-yeongyu/senpi-telemetry@2026.
|
|
122
|
+
"@earendil-works/pi-telemetry": "npm:@code-yeongyu/senpi-telemetry@2026.9.2-3",
|
|
123
123
|
"@exodus/bytes": "1.15.1",
|
|
124
124
|
"@google/genai": "2.18.0",
|
|
125
125
|
"@hono/node-server": "2.1.1",
|