@bastani/atomic 0.9.9 → 0.9.10-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +66 -0
- package/README.md +2 -0
- package/dist/builtin/cursor/CHANGELOG.md +6 -0
- package/dist/builtin/cursor/package.json +3 -3
- package/dist/builtin/intercom/CHANGELOG.md +15 -0
- package/dist/builtin/intercom/README.md +12 -4
- package/dist/builtin/intercom/broker/broker.ts +96 -14
- package/dist/builtin/intercom/broker/client-message-validation.ts +39 -0
- package/dist/builtin/intercom/broker/client.ts +101 -92
- package/dist/builtin/intercom/broker/group-isolation.ts +28 -0
- package/dist/builtin/intercom/broker/send-handler.ts +62 -10
- package/dist/builtin/intercom/broker/send-signature.ts +3 -0
- package/dist/builtin/intercom/broker/supervisor-channel.ts +126 -0
- package/dist/builtin/intercom/closed-workflow-stage-message.ts +66 -0
- package/dist/builtin/intercom/config.ts +10 -0
- package/dist/builtin/intercom/contact-supervisor-tool.ts +14 -10
- package/dist/builtin/intercom/foreground-detach-handoff.ts +12 -2
- package/dist/builtin/intercom/group.ts +46 -0
- package/dist/builtin/intercom/inbound-message-admission.ts +79 -0
- package/dist/builtin/intercom/incoming-message-delivery.ts +49 -0
- package/dist/builtin/intercom/index-heavy.ts +148 -94
- package/dist/builtin/intercom/index.ts +66 -4
- package/dist/builtin/intercom/intercom-test-seams.ts +6 -0
- package/dist/builtin/intercom/intercom-tool.ts +71 -20
- package/dist/builtin/intercom/intercom-utils.ts +15 -2
- package/dist/builtin/intercom/late-stage-message-router.ts +148 -0
- package/dist/builtin/intercom/lifecycle.ts +10 -4
- package/dist/builtin/intercom/package.json +2 -2
- package/dist/builtin/intercom/reconnect-backoff.ts +6 -0
- package/dist/builtin/intercom/reply-tracker.ts +8 -0
- package/dist/builtin/intercom/skills/intercom/SKILL.md +2 -0
- package/dist/builtin/intercom/stable-delivery-retry.ts +32 -0
- package/dist/builtin/intercom/subagent-relay.ts +67 -14
- package/dist/builtin/intercom/supervisor-authorization-registry.ts +22 -0
- package/dist/builtin/intercom/terminal-ordering-barrier.ts +144 -25
- package/dist/builtin/intercom/types.ts +18 -5
- package/dist/builtin/intercom/workflow-reply-tracker.ts +19 -0
- package/dist/builtin/intercom/workflow-stage-admission.ts +43 -0
- package/dist/builtin/intercom/workflow-stage-delivery-failure.ts +77 -0
- package/dist/builtin/mcp/CHANGELOG.md +11 -0
- package/dist/builtin/mcp/README.md +6 -2
- package/dist/builtin/mcp/config.ts +8 -8
- package/dist/builtin/mcp/direct-tool-executor.ts +7 -6
- package/dist/builtin/mcp/package.json +3 -3
- package/dist/builtin/mcp/proxy-call.ts +5 -4
- package/dist/builtin/mcp/sampling-handler.ts +7 -2
- package/dist/builtin/mcp/tool-call-timeout.ts +101 -0
- package/dist/builtin/mcp/tool-result-renderer.ts +3 -2
- package/dist/builtin/mcp/types.ts +5 -0
- package/dist/builtin/mcp/ui-server.ts +3 -2
- package/dist/builtin/subagents/CHANGELOG.md +21 -0
- package/dist/builtin/subagents/README.md +6 -3
- package/dist/builtin/subagents/agents/code-simplifier.md +1 -1
- package/dist/builtin/subagents/agents/codebase-analyzer.md +1 -1
- package/dist/builtin/subagents/agents/codebase-locator.md +1 -1
- package/dist/builtin/subagents/agents/codebase-online-researcher.md +1 -1
- package/dist/builtin/subagents/agents/codebase-pattern-finder.md +1 -1
- package/dist/builtin/subagents/agents/codebase-research-analyzer.md +1 -1
- package/dist/builtin/subagents/agents/codebase-research-locator.md +1 -1
- package/dist/builtin/subagents/agents/debugger.md +1 -1
- package/dist/builtin/subagents/agents/worker.md +1 -1
- package/dist/builtin/subagents/package.json +4 -4
- package/dist/builtin/subagents/skills/subagent/SKILL.md +1 -1
- package/dist/builtin/subagents/src/extension/index.ts +37 -61
- package/dist/builtin/subagents/src/extension/notification-content.ts +80 -0
- package/dist/builtin/subagents/src/extension/schemas.ts +9 -0
- package/dist/builtin/subagents/src/extension/tool-description.ts +1 -0
- package/dist/builtin/subagents/src/intercom/supervisor-authorization.ts +23 -0
- package/dist/builtin/subagents/src/runs/background/async-execution-chain.ts +4 -0
- package/dist/builtin/subagents/src/runs/background/async-execution-single.ts +2 -0
- package/dist/builtin/subagents/src/runs/background/async-execution-types.ts +4 -0
- package/dist/builtin/subagents/src/runs/background/async-job-tracker.ts +75 -13
- package/dist/builtin/subagents/src/runs/background/async-status.ts +19 -0
- package/dist/builtin/subagents/src/runs/background/completion-notification.ts +4 -3
- package/dist/builtin/subagents/src/runs/background/notify.ts +76 -15
- package/dist/builtin/subagents/src/runs/background/stale-run-reconciler.ts +1 -1
- package/dist/builtin/subagents/src/runs/background/subagent-runner-dynamic.ts +13 -0
- package/dist/builtin/subagents/src/runs/background/subagent-runner-parallel.ts +1 -0
- package/dist/builtin/subagents/src/runs/background/subagent-runner-sequential.ts +1 -0
- package/dist/builtin/subagents/src/runs/background/subagent-runner-step.ts +2 -1
- package/dist/builtin/subagents/src/runs/background/subagent-runner-types.ts +4 -0
- package/dist/builtin/subagents/src/runs/foreground/chain-execution-parallel-runner.ts +13 -0
- package/dist/builtin/subagents/src/runs/foreground/chain-execution-parallel-step.ts +19 -2
- package/dist/builtin/subagents/src/runs/foreground/detached-cleanup-barrier.ts +26 -0
- package/dist/builtin/subagents/src/runs/foreground/execution-attempt.ts +19 -30
- package/dist/builtin/subagents/src/runs/foreground/execution-intercom-detach.ts +47 -0
- package/dist/builtin/subagents/src/runs/foreground/subagent-executor-async.ts +60 -2
- package/dist/builtin/subagents/src/runs/foreground/subagent-executor-parallel-task.ts +21 -0
- package/dist/builtin/subagents/src/runs/foreground/subagent-executor-parallel.ts +21 -2
- package/dist/builtin/subagents/src/runs/foreground/subagent-executor-resume.ts +6 -1
- package/dist/builtin/subagents/src/runs/foreground/subagent-executor-single.ts +2 -0
- package/dist/builtin/subagents/src/runs/foreground/subagent-executor-types.ts +2 -0
- package/dist/builtin/subagents/src/runs/foreground/subagent-executor.ts +1 -1
- package/dist/builtin/subagents/src/runs/shared/intercom-group.ts +50 -0
- package/dist/builtin/subagents/src/runs/shared/pi-args.ts +16 -0
- package/dist/builtin/subagents/src/runs/shared/worktree-post-create.ts +75 -0
- package/dist/builtin/subagents/src/runs/shared/worktree-root.ts +51 -0
- package/dist/builtin/subagents/src/runs/shared/worktree.ts +69 -77
- package/dist/builtin/subagents/src/shared/types-config.ts +6 -0
- package/dist/builtin/subagents/src/slash/slash-commands.ts +3 -2
- package/dist/builtin/subagents/src/tui/render-result-compact.ts +5 -3
- package/dist/builtin/subagents/src/tui/render-result.ts +5 -3
- package/dist/builtin/subagents/src/tui/render-widget-graph.ts +7 -4
- package/dist/builtin/web-access/CHANGELOG.md +11 -0
- package/dist/builtin/web-access/extract-frames.ts +14 -13
- package/dist/builtin/web-access/extract.ts +2 -2
- package/dist/builtin/web-access/gemini-api.ts +0 -3
- package/dist/builtin/web-access/gemini-web-config.ts +1 -3
- package/dist/builtin/web-access/gemini-web.ts +1 -0
- package/dist/builtin/web-access/package.json +2 -2
- package/dist/builtin/web-access/perplexity.ts +0 -3
- package/dist/builtin/web-access/result-renderers.ts +7 -5
- package/dist/builtin/web-access/subprocess.ts +100 -0
- package/dist/builtin/web-access/summary-review.ts +14 -3
- package/dist/builtin/web-access/video-extract.ts +12 -17
- package/dist/builtin/web-access/web-search-browser.ts +18 -10
- package/dist/builtin/web-access/web-search-summary.ts +9 -2
- package/dist/builtin/web-access/youtube-extract.ts +22 -25
- package/dist/builtin/workflows/CHANGELOG.md +77 -0
- package/dist/builtin/workflows/README.md +76 -38
- package/dist/builtin/workflows/ambient.d.ts +30 -0
- package/dist/builtin/workflows/builtin/adversarial-verification-prompts.ts +15 -0
- package/dist/builtin/workflows/builtin/adversarial-verification-runner.ts +93 -0
- package/dist/builtin/workflows/builtin/adversarial-verification.d.ts +11 -0
- package/dist/builtin/workflows/builtin/adversarial-verification.ts +24 -0
- package/dist/builtin/workflows/builtin/classify-and-act-prompts.ts +11 -0
- package/dist/builtin/workflows/builtin/classify-and-act-runner.ts +110 -0
- package/dist/builtin/workflows/builtin/classify-and-act.d.ts +24 -0
- package/dist/builtin/workflows/builtin/classify-and-act.ts +35 -0
- package/dist/builtin/workflows/builtin/deep-research-codebase-utils.ts +8 -2
- package/dist/builtin/workflows/builtin/fan-out-and-synthesize-prompts.ts +11 -0
- package/dist/builtin/workflows/builtin/fan-out-and-synthesize-runner.ts +96 -0
- package/dist/builtin/workflows/builtin/fan-out-and-synthesize.d.ts +23 -0
- package/dist/builtin/workflows/builtin/fan-out-and-synthesize.ts +32 -0
- package/dist/builtin/workflows/builtin/generate-and-filter-prompts.ts +15 -0
- package/dist/builtin/workflows/builtin/generate-and-filter-runner.ts +75 -0
- package/dist/builtin/workflows/builtin/generate-and-filter.d.ts +11 -0
- package/dist/builtin/workflows/builtin/generate-and-filter.ts +26 -0
- package/dist/builtin/workflows/builtin/goal-models.ts +72 -0
- package/dist/builtin/workflows/builtin/goal-runner.ts +2 -64
- package/dist/builtin/workflows/builtin/index.d.ts +44 -0
- package/dist/builtin/workflows/builtin/index.ts +6 -0
- package/dist/builtin/workflows/builtin/loop-until-done-prompts.ts +79 -0
- package/dist/builtin/workflows/builtin/loop-until-done-runner.ts +189 -0
- package/dist/builtin/workflows/builtin/loop-until-done.d.ts +34 -0
- package/dist/builtin/workflows/builtin/loop-until-done.ts +31 -0
- package/dist/builtin/workflows/builtin/open-claude-design-runner.ts +6 -1
- package/dist/builtin/workflows/builtin/pattern-artifact-root.ts +28 -0
- package/dist/builtin/workflows/builtin/ralph-models.ts +26 -5
- package/dist/builtin/workflows/builtin/ralph-runner.ts +1 -0
- package/dist/builtin/workflows/builtin/tournament-prompts.ts +79 -0
- package/dist/builtin/workflows/builtin/tournament-runner.ts +188 -0
- package/dist/builtin/workflows/builtin/tournament.d.ts +33 -0
- package/dist/builtin/workflows/builtin/tournament.ts +34 -0
- package/dist/builtin/workflows/package.json +2 -2
- package/dist/builtin/workflows/src/authoring.d.ts +2 -6
- package/dist/builtin/workflows/src/durable/backend.ts +163 -120
- package/dist/builtin/workflows/src/durable/completed-catalog.ts +37 -64
- package/dist/builtin/workflows/src/durable/completed-inspection.ts +4 -72
- package/dist/builtin/workflows/src/durable/dbos-backend.ts +242 -195
- package/dist/builtin/workflows/src/durable/dbos-embedded-postgres.ts +207 -0
- package/dist/builtin/workflows/src/durable/dbos-envelope.ts +42 -42
- package/dist/builtin/workflows/src/durable/dbos-lifecycle.ts +155 -0
- package/dist/builtin/workflows/src/durable/dbos-local-postgres.ts +126 -0
- package/dist/builtin/workflows/src/durable/dbos-metadata.ts +105 -58
- package/dist/builtin/workflows/src/durable/dbos-prompt-reservations.ts +320 -0
- package/dist/builtin/workflows/src/durable/dbos-sdk-handle.ts +161 -0
- package/dist/builtin/workflows/src/durable/dbos-status-transition.ts +62 -0
- package/dist/builtin/workflows/src/durable/dbos-tombstone.ts +2 -2
- package/dist/builtin/workflows/src/durable/durable-hash.ts +20 -0
- package/dist/builtin/workflows/src/durable/factory.ts +23 -83
- package/dist/builtin/workflows/src/durable/format-version.ts +4 -10
- package/dist/builtin/workflows/src/durable/index.ts +16 -20
- package/dist/builtin/workflows/src/durable/local-command.ts +63 -0
- package/dist/builtin/workflows/src/durable/prompt-reservation-state.ts +177 -0
- package/dist/builtin/workflows/src/durable/prompt-reservations.ts +36 -0
- package/dist/builtin/workflows/src/durable/resume-catalog.ts +2 -200
- package/dist/builtin/workflows/src/durable/resume-eligibility.ts +42 -2
- package/dist/builtin/workflows/src/durable/resume-runtime.ts +121 -118
- package/dist/builtin/workflows/src/durable/retention-policy.ts +42 -0
- package/dist/builtin/workflows/src/durable/run-timing.ts +98 -0
- package/dist/builtin/workflows/src/durable/scoped-backend.ts +62 -14
- package/dist/builtin/workflows/src/durable/stage-primitive.ts +15 -2
- package/dist/builtin/workflows/src/durable/tool-primitive.ts +11 -7
- package/dist/builtin/workflows/src/durable/types.ts +25 -18
- package/dist/builtin/workflows/src/durable/ui-primitive.ts +117 -29
- package/dist/builtin/workflows/src/durable/workflow-status-transition.ts +30 -0
- package/dist/builtin/workflows/src/engine/primitives/parallel.ts +20 -5
- package/dist/builtin/workflows/src/engine/primitives/task.ts +3 -2
- package/dist/builtin/workflows/src/engine/primitives/ui.ts +6 -3
- package/dist/builtin/workflows/src/engine/run-durable-finalize.ts +14 -22
- package/dist/builtin/workflows/src/engine/run-durable-stage-session.ts +14 -14
- package/dist/builtin/workflows/src/engine/run.ts +35 -37
- package/dist/builtin/workflows/src/engine/runtime.ts +3 -0
- package/dist/builtin/workflows/src/engine/workflow-activity.ts +9 -0
- package/dist/builtin/workflows/src/extension/completed-stage-intercom-ask.ts +155 -0
- package/dist/builtin/workflows/src/extension/config-file-loader.ts +13 -0
- package/dist/builtin/workflows/src/extension/config-loader.ts +20 -0
- package/dist/builtin/workflows/src/extension/dispatcher.ts +56 -17
- package/dist/builtin/workflows/src/extension/extension-factory.ts +13 -10
- package/dist/builtin/workflows/src/extension/extension-lifecycle.ts +37 -59
- package/dist/builtin/workflows/src/extension/extension-runtime-state.ts +16 -18
- package/dist/builtin/workflows/src/extension/lifecycle-notification-delivery.ts +83 -0
- package/dist/builtin/workflows/src/extension/lifecycle-notifications.ts +80 -41
- package/dist/builtin/workflows/src/extension/postmortem-deps.ts +73 -0
- package/dist/builtin/workflows/src/extension/public-types.ts +11 -51
- package/dist/builtin/workflows/src/extension/render-call.ts +3 -9
- package/dist/builtin/workflows/src/extension/render-result.ts +22 -7
- package/dist/builtin/workflows/src/extension/runtime-active-block-claim.ts +78 -0
- package/dist/builtin/workflows/src/extension/runtime-durable-resume.ts +50 -29
- package/dist/builtin/workflows/src/extension/runtime.ts +70 -219
- package/dist/builtin/workflows/src/extension/ui-surface.ts +107 -3
- package/dist/builtin/workflows/src/extension/wiring.ts +76 -7
- package/dist/builtin/workflows/src/extension/workflow-command-completions.ts +10 -5
- package/dist/builtin/workflows/src/extension/workflow-command-registration.ts +27 -5
- package/dist/builtin/workflows/src/extension/workflow-durable-resume-command.ts +49 -19
- package/dist/builtin/workflows/src/extension/workflow-prompts.ts +8 -8
- package/dist/builtin/workflows/src/extension/workflow-resume-picker-rows.ts +81 -0
- package/dist/builtin/workflows/src/extension/workflow-resume-shadow.ts +55 -0
- package/dist/builtin/workflows/src/extension/workflow-run-control-command.ts +193 -145
- package/dist/builtin/workflows/src/extension/workflow-schema.ts +9 -133
- package/dist/builtin/workflows/src/extension/workflow-status-summary.ts +189 -0
- package/dist/builtin/workflows/src/extension/workflow-targets.ts +1 -1
- package/dist/builtin/workflows/src/extension/workflow-tool-content.ts +78 -3
- package/dist/builtin/workflows/src/extension/workflow-tool-control.ts +185 -89
- package/dist/builtin/workflows/src/extension/workflow-tool-send.ts +92 -11
- package/dist/builtin/workflows/src/extension/workflow-tool.ts +18 -24
- package/dist/builtin/workflows/src/runs/background/durable-resume-transition.ts +63 -0
- package/dist/builtin/workflows/src/runs/background/quit.ts +139 -29
- package/dist/builtin/workflows/src/runs/background/resume-acknowledgements.ts +97 -0
- package/dist/builtin/workflows/src/runs/background/run-inspect.ts +111 -0
- package/dist/builtin/workflows/src/runs/background/runner.ts +46 -17
- package/dist/builtin/workflows/src/runs/background/startup-admission.ts +77 -0
- package/dist/builtin/workflows/src/runs/background/status.ts +133 -224
- package/dist/builtin/workflows/src/runs/background/workflow-lifecycle-aggregate.ts +44 -0
- package/dist/builtin/workflows/src/runs/foreground/executor-direct-helpers.ts +57 -256
- package/dist/builtin/workflows/src/runs/foreground/executor-hil.ts +7 -4
- package/dist/builtin/workflows/src/runs/foreground/executor-lifecycle.ts +12 -1
- package/dist/builtin/workflows/src/runs/foreground/executor-prompt-nodes.ts +39 -0
- package/dist/builtin/workflows/src/runs/foreground/executor-queued-user-message.ts +75 -0
- package/dist/builtin/workflows/src/runs/foreground/executor-stage-call.ts +44 -12
- package/dist/builtin/workflows/src/runs/foreground/executor-stage-control.ts +63 -12
- package/dist/builtin/workflows/src/runs/foreground/executor-stage-factory.ts +30 -4
- package/dist/builtin/workflows/src/runs/foreground/executor-stage-replay.ts +3 -0
- package/dist/builtin/workflows/src/runs/foreground/executor-stage-types.ts +4 -1
- package/dist/builtin/workflows/src/runs/foreground/executor-task-prompts.ts +0 -67
- package/dist/builtin/workflows/src/runs/foreground/executor-types.ts +6 -0
- package/dist/builtin/workflows/src/runs/foreground/executor.ts +0 -1
- package/dist/builtin/workflows/src/runs/foreground/postmortem-stage-chat.ts +169 -0
- package/dist/builtin/workflows/src/runs/foreground/stage-control-registry.ts +38 -1
- package/dist/builtin/workflows/src/runs/foreground/stage-runner-candidate.ts +21 -0
- package/dist/builtin/workflows/src/runs/foreground/stage-runner-context.ts +21 -3
- package/dist/builtin/workflows/src/runs/foreground/stage-runner-controller.ts +85 -84
- package/dist/builtin/workflows/src/runs/foreground/stage-runner-message-admission.ts +195 -0
- package/dist/builtin/workflows/src/runs/foreground/stage-runner-options.ts +12 -5
- package/dist/builtin/workflows/src/runs/foreground/stage-runner-replacement.ts +42 -0
- package/dist/builtin/workflows/src/runs/foreground/stage-runner-send-user-message.ts +100 -8
- package/dist/builtin/workflows/src/runs/foreground/stage-runner-session-options.ts +51 -0
- package/dist/builtin/workflows/src/runs/foreground/stage-runner-session.ts +19 -0
- package/dist/builtin/workflows/src/runs/foreground/stage-runner-types.ts +28 -2
- package/dist/builtin/workflows/src/runs/shared/prompt-callsite.ts +4 -6
- package/dist/builtin/workflows/src/runs/shared/worktree-git-runner.ts +89 -0
- package/dist/builtin/workflows/src/runs/shared/worktree-git.ts +29 -133
- package/dist/builtin/workflows/src/runs/shared/worktree-post-create.ts +130 -0
- package/dist/builtin/workflows/src/runs/shared/worktree-root.ts +84 -0
- package/dist/builtin/workflows/src/runs/shared/worktree-setup.ts +77 -63
- package/dist/builtin/workflows/src/runs/shared/worktree-types.ts +4 -0
- package/dist/builtin/workflows/src/sdk-surface.ts +1 -1
- package/dist/builtin/workflows/src/shared/authoring-contract-stage.d.ts +29 -22
- package/dist/builtin/workflows/src/shared/authoring-contract-stage.ts +26 -24
- package/dist/builtin/workflows/src/shared/authoring-contract-ui.d.ts +5 -0
- package/dist/builtin/workflows/src/shared/authoring-contract-ui.ts +5 -0
- package/dist/builtin/workflows/src/shared/intercom-group.ts +51 -0
- package/dist/builtin/workflows/src/shared/persistence-restore-helpers.ts +6 -0
- package/dist/builtin/workflows/src/shared/persistence-restore.ts +4 -0
- package/dist/builtin/workflows/src/shared/persistence-session-entries.ts +3 -0
- package/dist/builtin/workflows/src/shared/prompt-callsite-context.ts +13 -0
- package/dist/builtin/workflows/src/shared/returned-run-status.ts +2 -1
- package/dist/builtin/workflows/src/shared/session-transcript.ts +74 -0
- package/dist/builtin/workflows/src/shared/store-stage-methods.ts +1 -0
- package/dist/builtin/workflows/src/shared/store-types.ts +8 -0
- package/dist/builtin/workflows/src/shared/timing.ts +4 -1
- package/dist/builtin/workflows/src/shared/types.ts +2 -6
- package/dist/builtin/workflows/src/tui/chat-surface-message.ts +2 -42
- package/dist/builtin/workflows/src/tui/dispatch-confirm.ts +2 -2
- package/dist/builtin/workflows/src/tui/graph-view-constants.ts +7 -3
- package/dist/builtin/workflows/src/tui/graph-view-input.ts +29 -67
- package/dist/builtin/workflows/src/tui/graph-view-render-helpers.ts +15 -10
- package/dist/builtin/workflows/src/tui/graph-view-state.ts +0 -2
- package/dist/builtin/workflows/src/tui/graph-view-types.ts +3 -9
- package/dist/builtin/workflows/src/tui/host-input-form.ts +62 -0
- package/dist/builtin/workflows/src/tui/mouse-input.ts +63 -0
- package/dist/builtin/workflows/src/tui/node-card.ts +1 -0
- package/dist/builtin/workflows/src/tui/overlay-adapter.ts +67 -42
- package/dist/builtin/workflows/src/tui/overlay-terminal-modes.ts +49 -0
- package/dist/builtin/workflows/src/tui/session-overlays.ts +3 -104
- package/dist/builtin/workflows/src/tui/session-picker.ts +3 -12
- package/dist/builtin/workflows/src/tui/stage-chat-composer-drafts.ts +19 -0
- package/dist/builtin/workflows/src/tui/stage-chat-view-archive-history.ts +30 -10
- package/dist/builtin/workflows/src/tui/stage-chat-view-footer-status.ts +19 -9
- package/dist/builtin/workflows/src/tui/stage-chat-view-input.ts +25 -38
- package/dist/builtin/workflows/src/tui/stage-chat-view-render-helpers.ts +1 -1
- package/dist/builtin/workflows/src/tui/stage-chat-view-state.ts +7 -6
- package/dist/builtin/workflows/src/tui/stage-chat-view-types.ts +7 -1
- package/dist/builtin/workflows/src/tui/stage-chat-view.ts +3 -1
- package/dist/builtin/workflows/src/tui/store-widget-installer.ts +19 -20
- package/dist/builtin/workflows/src/tui/switcher.ts +4 -4
- package/dist/builtin/workflows/src/tui/widget.ts +46 -33
- package/dist/builtin/workflows/src/tui/workflow-attach-pane-handle.ts +26 -0
- package/dist/builtin/workflows/src/tui/workflow-attach-pane-types.ts +14 -2
- package/dist/builtin/workflows/src/tui/workflow-attach-pane.ts +26 -27
- package/dist/builtin/workflows/src/tui/workflow-resume-selector.ts +208 -69
- package/dist/bun/cli.js +3 -0
- package/dist/bun/cli.js.map +1 -1
- package/dist/cli/session-picker.d.ts.map +1 -1
- package/dist/cli/session-picker.js +3 -0
- package/dist/cli/session-picker.js.map +1 -1
- package/dist/core/agent-session-auto-compaction.d.ts.map +1 -1
- package/dist/core/agent-session-auto-compaction.js +19 -2
- package/dist/core/agent-session-auto-compaction.js.map +1 -1
- package/dist/core/agent-session-compaction.js +2 -2
- package/dist/core/agent-session-compaction.js.map +1 -1
- package/dist/core/agent-session-events.d.ts.map +1 -1
- package/dist/core/agent-session-events.js +5 -3
- package/dist/core/agent-session-events.js.map +1 -1
- package/dist/core/agent-session-export.js +1 -1
- package/dist/core/agent-session-export.js.map +1 -1
- package/dist/core/agent-session-extension-bindings.d.ts +2 -4
- package/dist/core/agent-session-extension-bindings.d.ts.map +1 -1
- package/dist/core/agent-session-extension-bindings.js +9 -2
- package/dist/core/agent-session-extension-bindings.js.map +1 -1
- package/dist/core/agent-session-message-queue.d.ts +6 -0
- package/dist/core/agent-session-message-queue.d.ts.map +1 -1
- package/dist/core/agent-session-message-queue.js +107 -36
- package/dist/core/agent-session-message-queue.js.map +1 -1
- package/dist/core/agent-session-methods.d.ts +18 -7
- package/dist/core/agent-session-methods.d.ts.map +1 -1
- package/dist/core/agent-session-methods.js.map +1 -1
- package/dist/core/agent-session-models.d.ts +3 -1
- package/dist/core/agent-session-models.d.ts.map +1 -1
- package/dist/core/agent-session-models.js +1 -1
- package/dist/core/agent-session-models.js.map +1 -1
- package/dist/core/agent-session-post-tool-compaction.d.ts +16 -0
- package/dist/core/agent-session-post-tool-compaction.d.ts.map +1 -0
- package/dist/core/agent-session-post-tool-compaction.js +113 -0
- package/dist/core/agent-session-post-tool-compaction.js.map +1 -0
- package/dist/core/agent-session-prompt.d.ts +12 -1
- package/dist/core/agent-session-prompt.d.ts.map +1 -1
- package/dist/core/agent-session-prompt.js +22 -5
- package/dist/core/agent-session-prompt.js.map +1 -1
- package/dist/core/agent-session-runtime.d.ts.map +1 -1
- package/dist/core/agent-session-runtime.js +3 -0
- package/dist/core/agent-session-runtime.js.map +1 -1
- package/dist/core/agent-session-tool-hooks.d.ts.map +1 -1
- package/dist/core/agent-session-tool-hooks.js +21 -0
- package/dist/core/agent-session-tool-hooks.js.map +1 -1
- package/dist/core/agent-session-tree.d.ts.map +1 -1
- package/dist/core/agent-session-tree.js +2 -1
- package/dist/core/agent-session-tree.js.map +1 -1
- package/dist/core/agent-session-types.d.ts +7 -0
- package/dist/core/agent-session-types.d.ts.map +1 -1
- package/dist/core/agent-session-types.js.map +1 -1
- package/dist/core/agent-session.d.ts +6 -0
- package/dist/core/agent-session.d.ts.map +1 -1
- package/dist/core/agent-session.js +18 -1
- package/dist/core/agent-session.js.map +1 -1
- package/dist/core/async/job-manager.d.ts +1 -0
- package/dist/core/async/job-manager.d.ts.map +1 -1
- package/dist/core/async/job-manager.js +29 -5
- package/dist/core/async/job-manager.js.map +1 -1
- package/dist/core/async/session-manager.d.ts +2 -4
- package/dist/core/async/session-manager.d.ts.map +1 -1
- package/dist/core/async/session-manager.js +5 -32
- package/dist/core/async/session-manager.js.map +1 -1
- package/dist/core/atomic-guide-command.d.ts.map +1 -1
- package/dist/core/atomic-guide-command.js +2 -0
- package/dist/core/atomic-guide-command.js.map +1 -1
- package/dist/core/auth-storage.d.ts +20 -10
- package/dist/core/auth-storage.d.ts.map +1 -1
- package/dist/core/auth-storage.js +151 -92
- package/dist/core/auth-storage.js.map +1 -1
- package/dist/core/callback-activity.d.ts +27 -0
- package/dist/core/callback-activity.d.ts.map +1 -0
- package/dist/core/callback-activity.js +44 -0
- package/dist/core/callback-activity.js.map +1 -0
- package/dist/core/compaction/branch-summarization.d.ts +4 -1
- package/dist/core/compaction/branch-summarization.d.ts.map +1 -1
- package/dist/core/compaction/branch-summarization.js +4 -3
- package/dist/core/compaction/branch-summarization.js.map +1 -1
- package/dist/core/compaction/compaction-boundary.d.ts +1 -1
- package/dist/core/compaction/compaction-boundary.d.ts.map +1 -1
- package/dist/core/compaction/compaction-boundary.js +10 -23
- package/dist/core/compaction/compaction-boundary.js.map +1 -1
- package/dist/core/compaction/compaction-runner.d.ts +4 -1
- package/dist/core/compaction/compaction-runner.d.ts.map +1 -1
- package/dist/core/compaction/compaction-runner.js +1 -1
- package/dist/core/compaction/compaction-runner.js.map +1 -1
- package/dist/core/compaction/compaction-types.d.ts +3 -2
- package/dist/core/compaction/compaction-types.d.ts.map +1 -1
- package/dist/core/compaction/compaction-types.js.map +1 -1
- package/dist/core/compaction/compaction.d.ts +6 -6
- package/dist/core/compaction/compaction.d.ts.map +1 -1
- package/dist/core/compaction/compaction.js +12 -9
- package/dist/core/compaction/compaction.js.map +1 -1
- package/dist/core/compaction/index.d.ts +1 -0
- package/dist/core/compaction/index.d.ts.map +1 -1
- package/dist/core/compaction/index.js +1 -0
- package/dist/core/compaction/index.js.map +1 -1
- package/dist/core/compaction/range-planner-diagnostics.d.ts +101 -0
- package/dist/core/compaction/range-planner-diagnostics.d.ts.map +1 -0
- package/dist/core/compaction/range-planner-diagnostics.js +116 -0
- package/dist/core/compaction/range-planner-diagnostics.js.map +1 -0
- package/dist/core/compaction/range-planner.d.ts +13 -3
- package/dist/core/compaction/range-planner.d.ts.map +1 -1
- package/dist/core/compaction/range-planner.js +117 -68
- package/dist/core/compaction/range-planner.js.map +1 -1
- package/dist/core/compaction/truncated-range-recovery.d.ts +47 -0
- package/dist/core/compaction/truncated-range-recovery.d.ts.map +1 -0
- package/dist/core/compaction/truncated-range-recovery.js +112 -0
- package/dist/core/compaction/truncated-range-recovery.js.map +1 -0
- package/dist/core/extensions/api-types.d.ts +2 -2
- package/dist/core/extensions/api-types.d.ts.map +1 -1
- package/dist/core/extensions/api-types.js.map +1 -1
- package/dist/core/extensions/context-types.d.ts +23 -1
- package/dist/core/extensions/context-types.d.ts.map +1 -1
- package/dist/core/extensions/context-types.js.map +1 -1
- package/dist/core/extensions/index.d.ts +1 -1
- package/dist/core/extensions/index.d.ts.map +1 -1
- package/dist/core/extensions/index.js.map +1 -1
- package/dist/core/extensions/loader-api.js +2 -2
- package/dist/core/extensions/loader-api.js.map +1 -1
- package/dist/core/extensions/loader-core.d.ts.map +1 -1
- package/dist/core/extensions/loader-core.js +8 -1
- package/dist/core/extensions/loader-core.js.map +1 -1
- package/dist/core/extensions/loader-virtual-modules.d.ts.map +1 -1
- package/dist/core/extensions/loader-virtual-modules.js +9 -6
- package/dist/core/extensions/loader-virtual-modules.js.map +1 -1
- package/dist/core/extensions/message-types.d.ts +17 -0
- package/dist/core/extensions/message-types.d.ts.map +1 -1
- package/dist/core/extensions/message-types.js.map +1 -1
- package/dist/core/extensions/provider-types.d.ts +3 -0
- package/dist/core/extensions/provider-types.d.ts.map +1 -1
- package/dist/core/extensions/provider-types.js.map +1 -1
- package/dist/core/extensions/runner-events.d.ts.map +1 -1
- package/dist/core/extensions/runner-events.js +11 -10
- package/dist/core/extensions/runner-events.js.map +1 -1
- package/dist/core/extensions/runtime-types.d.ts +2 -2
- package/dist/core/extensions/runtime-types.d.ts.map +1 -1
- package/dist/core/extensions/runtime-types.js.map +1 -1
- package/dist/core/extensions/ui-types.d.ts +78 -0
- package/dist/core/extensions/ui-types.d.ts.map +1 -1
- package/dist/core/extensions/ui-types.js.map +1 -1
- package/dist/core/model-registry-auth.d.ts +2 -1
- package/dist/core/model-registry-auth.d.ts.map +1 -1
- package/dist/core/model-registry-auth.js +25 -6
- package/dist/core/model-registry-auth.js.map +1 -1
- package/dist/core/model-registry-builtins.d.ts +3 -2
- package/dist/core/model-registry-builtins.d.ts.map +1 -1
- package/dist/core/model-registry-builtins.js +12 -6
- package/dist/core/model-registry-builtins.js.map +1 -1
- package/dist/core/model-registry-dynamic.d.ts +1 -0
- package/dist/core/model-registry-dynamic.d.ts.map +1 -1
- package/dist/core/model-registry-dynamic.js +53 -13
- package/dist/core/model-registry-dynamic.js.map +1 -1
- package/dist/core/model-registry-loader.d.ts +2 -1
- package/dist/core/model-registry-loader.d.ts.map +1 -1
- package/dist/core/model-registry-loader.js +2 -2
- package/dist/core/model-registry-loader.js.map +1 -1
- package/dist/core/model-registry-types.d.ts +10 -3
- package/dist/core/model-registry-types.d.ts.map +1 -1
- package/dist/core/model-registry-types.js.map +1 -1
- package/dist/core/model-registry.d.ts +15 -1
- package/dist/core/model-registry.d.ts.map +1 -1
- package/dist/core/model-registry.js +214 -30
- package/dist/core/model-registry.js.map +1 -1
- package/dist/core/models-store.d.ts +25 -0
- package/dist/core/models-store.d.ts.map +1 -0
- package/dist/core/models-store.js +73 -0
- package/dist/core/models-store.js.map +1 -0
- package/dist/core/oauth-compat.d.ts +17 -0
- package/dist/core/oauth-compat.d.ts.map +1 -0
- package/dist/core/oauth-compat.js +2 -0
- package/dist/core/oauth-compat.js.map +1 -0
- package/dist/core/oauth-provider-bridge.d.ts +40 -0
- package/dist/core/oauth-provider-bridge.d.ts.map +1 -0
- package/dist/core/oauth-provider-bridge.js +169 -0
- package/dist/core/oauth-provider-bridge.js.map +1 -0
- package/dist/core/output-guard.d.ts +2 -0
- package/dist/core/output-guard.d.ts.map +1 -1
- package/dist/core/output-guard.js +14 -0
- package/dist/core/output-guard.js.map +1 -1
- package/dist/core/remote-catalog-provider.d.ts +5 -0
- package/dist/core/remote-catalog-provider.d.ts.map +1 -0
- package/dist/core/remote-catalog-provider.js +138 -0
- package/dist/core/remote-catalog-provider.js.map +1 -0
- package/dist/core/sdk.d.ts.map +1 -1
- package/dist/core/sdk.js +8 -3
- package/dist/core/sdk.js.map +1 -1
- package/dist/core/session-manager-core.d.ts +1 -1
- package/dist/core/session-manager-core.d.ts.map +1 -1
- package/dist/core/session-manager-core.js +1 -1
- package/dist/core/session-manager-core.js.map +1 -1
- package/dist/core/session-manager-entries.d.ts +1 -1
- package/dist/core/session-manager-entries.d.ts.map +1 -1
- package/dist/core/session-manager-entries.js.map +1 -1
- package/dist/core/session-manager-history.d.ts +2 -2
- package/dist/core/session-manager-history.js +2 -2
- package/dist/core/session-manager-history.js.map +1 -1
- package/dist/core/session-manager-list.d.ts.map +1 -1
- package/dist/core/session-manager-list.js +65 -23
- package/dist/core/session-manager-list.js.map +1 -1
- package/dist/core/session-manager-types.d.ts +3 -2
- package/dist/core/session-manager-types.d.ts.map +1 -1
- package/dist/core/session-manager-types.js.map +1 -1
- package/dist/core/slash-commands.d.ts.map +1 -1
- package/dist/core/slash-commands.js +9 -5
- package/dist/core/slash-commands.js.map +1 -1
- package/dist/core/tools/bash.d.ts.map +1 -1
- package/dist/core/tools/bash.js +2 -3
- package/dist/core/tools/bash.js.map +1 -1
- package/dist/core/tools/find.js +2 -2
- package/dist/core/tools/find.js.map +1 -1
- package/dist/core/tools/grep.js +2 -2
- package/dist/core/tools/grep.js.map +1 -1
- package/dist/core/tools/ls.js +2 -2
- package/dist/core/tools/ls.js.map +1 -1
- package/dist/core/tools/read.d.ts.map +1 -1
- package/dist/core/tools/read.js +4 -3
- package/dist/core/tools/read.js.map +1 -1
- package/dist/core/tools/todos-render.d.ts.map +1 -1
- package/dist/core/tools/todos-render.js +3 -2
- package/dist/core/tools/todos-render.js.map +1 -1
- package/dist/core/tools/tool-definition-wrapper.d.ts.map +1 -1
- package/dist/core/tools/tool-definition-wrapper.js +3 -2
- package/dist/core/tools/tool-definition-wrapper.js.map +1 -1
- package/dist/core/tools/write.js +2 -2
- package/dist/core/tools/write.js.map +1 -1
- package/dist/core/workflow-stage-admission.d.ts +29 -0
- package/dist/core/workflow-stage-admission.d.ts.map +1 -0
- package/dist/core/workflow-stage-admission.js +81 -0
- package/dist/core/workflow-stage-admission.js.map +1 -0
- package/dist/index-extensions.d.ts +1 -1
- package/dist/index-extensions.d.ts.map +1 -1
- package/dist/index-extensions.js.map +1 -1
- package/dist/index.d.ts +4 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -1
- package/dist/index.js.map +1 -1
- package/dist/main-types.d.ts +13 -0
- package/dist/main-types.d.ts.map +1 -0
- package/dist/main-types.js +2 -0
- package/dist/main-types.js.map +1 -0
- package/dist/main.d.ts +2 -5
- package/dist/main.d.ts.map +1 -1
- package/dist/main.js +25 -17
- package/dist/main.js.map +1 -1
- package/dist/modes/interactive/components/assistant-message.d.ts.map +1 -1
- package/dist/modes/interactive/components/assistant-message.js +17 -12
- package/dist/modes/interactive/components/assistant-message.js.map +1 -1
- package/dist/modes/interactive/components/atomic-banner.d.ts +7 -0
- package/dist/modes/interactive/components/atomic-banner.d.ts.map +1 -1
- package/dist/modes/interactive/components/atomic-banner.js +20 -0
- package/dist/modes/interactive/components/atomic-banner.js.map +1 -1
- package/dist/modes/interactive/components/bash-execution.d.ts.map +1 -1
- package/dist/modes/interactive/components/bash-execution.js +5 -3
- package/dist/modes/interactive/components/bash-execution.js.map +1 -1
- package/dist/modes/interactive/components/branch-summary-message.d.ts.map +1 -1
- package/dist/modes/interactive/components/branch-summary-message.js +3 -4
- package/dist/modes/interactive/components/branch-summary-message.js.map +1 -1
- package/dist/modes/interactive/components/chat-message-renderer.d.ts +4 -0
- package/dist/modes/interactive/components/chat-message-renderer.d.ts.map +1 -1
- package/dist/modes/interactive/components/chat-message-renderer.js +4 -0
- package/dist/modes/interactive/components/chat-message-renderer.js.map +1 -1
- package/dist/modes/interactive/components/chat-session-host-events.d.ts.map +1 -1
- package/dist/modes/interactive/components/chat-session-host-events.js +79 -8
- package/dist/modes/interactive/components/chat-session-host-events.js.map +1 -1
- package/dist/modes/interactive/components/chat-session-host-rendering.d.ts.map +1 -1
- package/dist/modes/interactive/components/chat-session-host-rendering.js +4 -2
- package/dist/modes/interactive/components/chat-session-host-rendering.js.map +1 -1
- package/dist/modes/interactive/components/chat-session-host.d.ts +1 -0
- package/dist/modes/interactive/components/chat-session-host.d.ts.map +1 -1
- package/dist/modes/interactive/components/chat-session-host.js +4 -1
- package/dist/modes/interactive/components/chat-session-host.js.map +1 -1
- package/dist/modes/interactive/components/compaction-boundary-message.d.ts.map +1 -1
- package/dist/modes/interactive/components/compaction-boundary-message.js +3 -4
- package/dist/modes/interactive/components/compaction-boundary-message.js.map +1 -1
- package/dist/modes/interactive/components/host-input-form-mount.d.ts +14 -0
- package/dist/modes/interactive/components/host-input-form-mount.d.ts.map +1 -0
- package/dist/modes/interactive/components/host-input-form-mount.js +79 -0
- package/dist/modes/interactive/components/host-input-form-mount.js.map +1 -0
- package/dist/modes/interactive/components/host-input-form.d.ts +52 -0
- package/dist/modes/interactive/components/host-input-form.d.ts.map +1 -0
- package/dist/modes/interactive/components/host-input-form.js +278 -0
- package/dist/modes/interactive/components/host-input-form.js.map +1 -0
- package/dist/modes/interactive/components/host-session-picker.d.ts +46 -0
- package/dist/modes/interactive/components/host-session-picker.d.ts.map +1 -0
- package/dist/modes/interactive/components/host-session-picker.js +183 -0
- package/dist/modes/interactive/components/host-session-picker.js.map +1 -0
- package/dist/modes/interactive/components/index.d.ts +1 -1
- package/dist/modes/interactive/components/index.d.ts.map +1 -1
- package/dist/modes/interactive/components/index.js +1 -1
- package/dist/modes/interactive/components/index.js.map +1 -1
- package/dist/modes/interactive/components/keybinding-hints.d.ts +2 -0
- package/dist/modes/interactive/components/keybinding-hints.d.ts.map +1 -1
- package/dist/modes/interactive/components/keybinding-hints.js +12 -0
- package/dist/modes/interactive/components/keybinding-hints.js.map +1 -1
- package/dist/modes/interactive/components/login-dialog.d.ts +3 -1
- package/dist/modes/interactive/components/login-dialog.d.ts.map +1 -1
- package/dist/modes/interactive/components/login-dialog.js +8 -2
- package/dist/modes/interactive/components/login-dialog.js.map +1 -1
- package/dist/modes/interactive/components/model-selector.d.ts +7 -1
- package/dist/modes/interactive/components/model-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/model-selector.js +57 -10
- package/dist/modes/interactive/components/model-selector.js.map +1 -1
- package/dist/modes/interactive/components/session-selector.d.ts +15 -0
- package/dist/modes/interactive/components/session-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/session-selector.js +35 -3
- package/dist/modes/interactive/components/session-selector.js.map +1 -1
- package/dist/modes/interactive/components/skill-invocation-message.d.ts.map +1 -1
- package/dist/modes/interactive/components/skill-invocation-message.js +3 -2
- package/dist/modes/interactive/components/skill-invocation-message.js.map +1 -1
- package/dist/modes/interactive/components/tool-execution.d.ts.map +1 -1
- package/dist/modes/interactive/components/tool-execution.js +9 -0
- package/dist/modes/interactive/components/tool-execution.js.map +1 -1
- package/dist/modes/interactive/interactive-agent-events.js +24 -10
- package/dist/modes/interactive/interactive-agent-events.js.map +1 -1
- package/dist/modes/interactive/interactive-auth-login.js +7 -1
- package/dist/modes/interactive/interactive-auth-login.js.map +1 -1
- package/dist/modes/interactive/interactive-auth-routing.js +3 -3
- package/dist/modes/interactive/interactive-auth-routing.js.map +1 -1
- package/dist/modes/interactive/interactive-autocomplete.js +49 -0
- package/dist/modes/interactive/interactive-autocomplete.js.map +1 -1
- package/dist/modes/interactive/interactive-bash-compact.js +2 -0
- package/dist/modes/interactive/interactive-bash-compact.js.map +1 -1
- package/dist/modes/interactive/interactive-extension-context.js +14 -0
- package/dist/modes/interactive/interactive-extension-context.js.map +1 -1
- package/dist/modes/interactive/interactive-extension-runtime.js +1 -1
- package/dist/modes/interactive/interactive-extension-runtime.js.map +1 -1
- package/dist/modes/interactive/interactive-global-clear.d.ts +13 -0
- package/dist/modes/interactive/interactive-global-clear.d.ts.map +1 -0
- package/dist/modes/interactive/interactive-global-clear.js +11 -0
- package/dist/modes/interactive/interactive-global-clear.js.map +1 -0
- package/dist/modes/interactive/interactive-input-handling.js +17 -10
- package/dist/modes/interactive/interactive-input-handling.js.map +1 -1
- package/dist/modes/interactive/interactive-mode-base.d.ts +6 -1
- package/dist/modes/interactive/interactive-mode-base.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-mode-base.js +25 -2
- package/dist/modes/interactive/interactive-mode-base.js.map +1 -1
- package/dist/modes/interactive/interactive-mode-deps.d.ts +4 -3
- package/dist/modes/interactive/interactive-mode-deps.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-mode-deps.js +2 -2
- package/dist/modes/interactive/interactive-mode-deps.js.map +1 -1
- package/dist/modes/interactive/interactive-mode-helpers.d.ts +4 -1
- package/dist/modes/interactive/interactive-mode-helpers.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-mode-helpers.js +14 -1
- package/dist/modes/interactive/interactive-mode-helpers.js.map +1 -1
- package/dist/modes/interactive/interactive-mode-surface.d.ts +3 -2
- package/dist/modes/interactive/interactive-mode-surface.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-mode-surface.js.map +1 -1
- package/dist/modes/interactive/interactive-mode-types.d.ts +3 -0
- package/dist/modes/interactive/interactive-mode-types.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-mode-types.js.map +1 -1
- package/dist/modes/interactive/interactive-model-routing.js +7 -4
- package/dist/modes/interactive/interactive-model-routing.js.map +1 -1
- package/dist/modes/interactive/interactive-queueing.js +2 -2
- package/dist/modes/interactive/interactive-queueing.js.map +1 -1
- package/dist/modes/interactive/interactive-render-chat.js +25 -4
- package/dist/modes/interactive/interactive-render-chat.js.map +1 -1
- package/dist/modes/interactive/interactive-session-routing.js +3 -0
- package/dist/modes/interactive/interactive-session-routing.js.map +1 -1
- package/dist/modes/interactive/interactive-slash-commands.js +5 -2
- package/dist/modes/interactive/interactive-slash-commands.js.map +1 -1
- package/dist/modes/interactive/interactive-startup.d.ts +1 -1
- package/dist/modes/interactive/interactive-startup.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-startup.js +22 -9
- package/dist/modes/interactive/interactive-startup.js.map +1 -1
- package/dist/modes/interactive/interactive-terminal-title.d.ts +6 -0
- package/dist/modes/interactive/interactive-terminal-title.d.ts.map +1 -0
- package/dist/modes/interactive/interactive-terminal-title.js +7 -0
- package/dist/modes/interactive/interactive-terminal-title.js.map +1 -0
- package/dist/modes/interactive-engine/activity-watchdog.d.ts +45 -0
- package/dist/modes/interactive-engine/activity-watchdog.d.ts.map +1 -0
- package/dist/modes/interactive-engine/activity-watchdog.js +74 -0
- package/dist/modes/interactive-engine/activity-watchdog.js.map +1 -0
- package/dist/modes/interactive-engine/create-isolated-runtime.d.ts +14 -0
- package/dist/modes/interactive-engine/create-isolated-runtime.d.ts.map +1 -0
- package/dist/modes/interactive-engine/create-isolated-runtime.js +56 -0
- package/dist/modes/interactive-engine/create-isolated-runtime.js.map +1 -0
- package/dist/modes/interactive-engine/engine-args.d.ts +10 -0
- package/dist/modes/interactive-engine/engine-args.d.ts.map +1 -0
- package/dist/modes/interactive-engine/engine-args.js +55 -0
- package/dist/modes/interactive-engine/engine-args.js.map +1 -0
- package/dist/modes/interactive-engine/engine-child-liveness.d.ts +7 -0
- package/dist/modes/interactive-engine/engine-child-liveness.d.ts.map +1 -0
- package/dist/modes/interactive-engine/engine-child-liveness.js +50 -0
- package/dist/modes/interactive-engine/engine-child-liveness.js.map +1 -0
- package/dist/modes/interactive-engine/engine-custom-ui.d.ts +47 -0
- package/dist/modes/interactive-engine/engine-custom-ui.d.ts.map +1 -0
- package/dist/modes/interactive-engine/engine-custom-ui.js +276 -0
- package/dist/modes/interactive-engine/engine-custom-ui.js.map +1 -0
- package/dist/modes/interactive-engine/engine-input-form.d.ts +13 -0
- package/dist/modes/interactive-engine/engine-input-form.d.ts.map +1 -0
- package/dist/modes/interactive-engine/engine-input-form.js +49 -0
- package/dist/modes/interactive-engine/engine-input-form.js.map +1 -0
- package/dist/modes/interactive-engine/engine-monitor.d.ts +18 -0
- package/dist/modes/interactive-engine/engine-monitor.d.ts.map +1 -0
- package/dist/modes/interactive-engine/engine-monitor.js +63 -0
- package/dist/modes/interactive-engine/engine-monitor.js.map +1 -0
- package/dist/modes/interactive-engine/engine-render-service.d.ts +17 -0
- package/dist/modes/interactive-engine/engine-render-service.d.ts.map +1 -0
- package/dist/modes/interactive-engine/engine-render-service.js +150 -0
- package/dist/modes/interactive-engine/engine-render-service.js.map +1 -0
- package/dist/modes/interactive-engine/engine-session-picker.d.ts +22 -0
- package/dist/modes/interactive-engine/engine-session-picker.d.ts.map +1 -0
- package/dist/modes/interactive-engine/engine-session-picker.js +106 -0
- package/dist/modes/interactive-engine/engine-session-picker.js.map +1 -0
- package/dist/modes/interactive-engine/extension-ui-bridge.d.ts +23 -0
- package/dist/modes/interactive-engine/extension-ui-bridge.d.ts.map +1 -0
- package/dist/modes/interactive-engine/extension-ui-bridge.js +126 -0
- package/dist/modes/interactive-engine/extension-ui-bridge.js.map +1 -0
- package/dist/modes/interactive-engine/input-form-host.d.ts +15 -0
- package/dist/modes/interactive-engine/input-form-host.d.ts.map +1 -0
- package/dist/modes/interactive-engine/input-form-host.js +44 -0
- package/dist/modes/interactive-engine/input-form-host.js.map +1 -0
- package/dist/modes/interactive-engine/isolated-runtime.d.ts +75 -0
- package/dist/modes/interactive-engine/isolated-runtime.d.ts.map +1 -0
- package/dist/modes/interactive-engine/isolated-runtime.js +448 -0
- package/dist/modes/interactive-engine/isolated-runtime.js.map +1 -0
- package/dist/modes/interactive-engine/protocol.d.ts +184 -0
- package/dist/modes/interactive-engine/protocol.d.ts.map +1 -0
- package/dist/modes/interactive-engine/protocol.js +254 -0
- package/dist/modes/interactive-engine/protocol.js.map +1 -0
- package/dist/modes/interactive-engine/remote-command-catalog.d.ts +33 -0
- package/dist/modes/interactive-engine/remote-command-catalog.d.ts.map +1 -0
- package/dist/modes/interactive-engine/remote-command-catalog.js +51 -0
- package/dist/modes/interactive-engine/remote-command-catalog.js.map +1 -0
- package/dist/modes/interactive-engine/remote-component.d.ts +16 -0
- package/dist/modes/interactive-engine/remote-component.d.ts.map +1 -0
- package/dist/modes/interactive-engine/remote-component.js +209 -0
- package/dist/modes/interactive-engine/remote-component.js.map +1 -0
- package/dist/modes/interactive-engine/remote-frame-clamp.d.ts +25 -0
- package/dist/modes/interactive-engine/remote-frame-clamp.d.ts.map +1 -0
- package/dist/modes/interactive-engine/remote-frame-clamp.js +43 -0
- package/dist/modes/interactive-engine/remote-frame-clamp.js.map +1 -0
- package/dist/modes/interactive-engine/remote-renderer.d.ts +59 -0
- package/dist/modes/interactive-engine/remote-renderer.d.ts.map +1 -0
- package/dist/modes/interactive-engine/remote-renderer.js +123 -0
- package/dist/modes/interactive-engine/remote-renderer.js.map +1 -0
- package/dist/modes/interactive-engine/session-picker-host.d.ts +25 -0
- package/dist/modes/interactive-engine/session-picker-host.d.ts.map +1 -0
- package/dist/modes/interactive-engine/session-picker-host.js +75 -0
- package/dist/modes/interactive-engine/session-picker-host.js.map +1 -0
- package/dist/modes/interactive-engine/terminal-mode-controller.d.ts +43 -0
- package/dist/modes/interactive-engine/terminal-mode-controller.d.ts.map +1 -0
- package/dist/modes/interactive-engine/terminal-mode-controller.js +109 -0
- package/dist/modes/interactive-engine/terminal-mode-controller.js.map +1 -0
- package/dist/modes/rpc/bounded-writer.d.ts +27 -0
- package/dist/modes/rpc/bounded-writer.d.ts.map +1 -0
- package/dist/modes/rpc/bounded-writer.js +103 -0
- package/dist/modes/rpc/bounded-writer.js.map +1 -0
- package/dist/modes/rpc/jsonl.d.ts +15 -12
- package/dist/modes/rpc/jsonl.d.ts.map +1 -1
- package/dist/modes/rpc/jsonl.js +102 -28
- package/dist/modes/rpc/jsonl.js.map +1 -1
- package/dist/modes/rpc/rpc-client-api.d.ts +83 -0
- package/dist/modes/rpc/rpc-client-api.d.ts.map +1 -0
- package/dist/modes/rpc/rpc-client-api.js +64 -0
- package/dist/modes/rpc/rpc-client-api.js.map +1 -0
- package/dist/modes/rpc/rpc-client-process.d.ts +19 -0
- package/dist/modes/rpc/rpc-client-process.d.ts.map +1 -0
- package/dist/modes/rpc/rpc-client-process.js +79 -0
- package/dist/modes/rpc/rpc-client-process.js.map +1 -0
- package/dist/modes/rpc/rpc-client-waits.d.ts +8 -0
- package/dist/modes/rpc/rpc-client-waits.d.ts.map +1 -0
- package/dist/modes/rpc/rpc-client-waits.js +33 -0
- package/dist/modes/rpc/rpc-client-waits.js.map +1 -0
- package/dist/modes/rpc/rpc-client.d.ts +48 -124
- package/dist/modes/rpc/rpc-client.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-client.js +295 -249
- package/dist/modes/rpc/rpc-client.js.map +1 -1
- package/dist/modes/rpc/rpc-command-handler.d.ts +5 -1
- package/dist/modes/rpc/rpc-command-handler.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-command-handler.js +79 -3
- package/dist/modes/rpc/rpc-command-handler.js.map +1 -1
- package/dist/modes/rpc/rpc-event-buffer.d.ts +11 -0
- package/dist/modes/rpc/rpc-event-buffer.d.ts.map +1 -0
- package/dist/modes/rpc/rpc-event-buffer.js +30 -0
- package/dist/modes/rpc/rpc-event-buffer.js.map +1 -0
- package/dist/modes/rpc/rpc-extension-ui.d.ts +7 -1
- package/dist/modes/rpc/rpc-extension-ui.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-extension-ui.js +54 -32
- package/dist/modes/rpc/rpc-extension-ui.js.map +1 -1
- package/dist/modes/rpc/rpc-input-scheduler.d.ts +16 -0
- package/dist/modes/rpc/rpc-input-scheduler.d.ts.map +1 -0
- package/dist/modes/rpc/rpc-input-scheduler.js +69 -0
- package/dist/modes/rpc/rpc-input-scheduler.js.map +1 -0
- package/dist/modes/rpc/rpc-input.d.ts +2 -1
- package/dist/modes/rpc/rpc-input.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-input.js +4 -9
- package/dist/modes/rpc/rpc-input.js.map +1 -1
- package/dist/modes/rpc/rpc-keybindings-reload.d.ts +27 -0
- package/dist/modes/rpc/rpc-keybindings-reload.d.ts.map +1 -0
- package/dist/modes/rpc/rpc-keybindings-reload.js +69 -0
- package/dist/modes/rpc/rpc-keybindings-reload.js.map +1 -0
- package/dist/modes/rpc/rpc-mode.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-mode.js +63 -8
- package/dist/modes/rpc/rpc-mode.js.map +1 -1
- package/dist/modes/rpc/rpc-output-buffer.d.ts +10 -0
- package/dist/modes/rpc/rpc-output-buffer.d.ts.map +1 -0
- package/dist/modes/rpc/rpc-output-buffer.js +70 -0
- package/dist/modes/rpc/rpc-output-buffer.js.map +1 -0
- package/dist/modes/rpc/rpc-session-binding.d.ts +16 -1
- package/dist/modes/rpc/rpc-session-binding.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-session-binding.js +16 -3
- package/dist/modes/rpc/rpc-session-binding.js.map +1 -1
- package/dist/modes/rpc/rpc-types.d.ts +109 -0
- package/dist/modes/rpc/rpc-types.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-types.js.map +1 -1
- package/dist/package-manager-cli-parser.d.ts +2 -0
- package/dist/package-manager-cli-parser.d.ts.map +1 -1
- package/dist/package-manager-cli-parser.js +24 -5
- package/dist/package-manager-cli-parser.js.map +1 -1
- package/dist/package-manager-cli.d.ts +7 -0
- package/dist/package-manager-cli.d.ts.map +1 -1
- package/dist/package-manager-cli.js +65 -1
- package/dist/package-manager-cli.js.map +1 -1
- package/dist/utils/shell.d.ts +1 -0
- package/dist/utils/shell.d.ts.map +1 -1
- package/dist/utils/shell.js +46 -0
- package/dist/utils/shell.js.map +1 -1
- package/docs/changelog.mdx +11 -0
- package/docs/compaction.md +53 -17
- package/docs/custom-provider.md +24 -5
- package/docs/development.md +9 -7
- package/docs/docs.json +1 -0
- package/docs/extensions.md +30 -16
- package/docs/intercom.md +489 -0
- package/docs/json.md +1 -1
- package/docs/keybindings.md +1 -1
- package/docs/packages.md +1 -0
- package/docs/quickstart.md +11 -5
- package/docs/rpc.md +9 -7
- package/docs/sdk.md +6 -0
- package/docs/session-format.md +7 -6
- package/docs/sessions.md +4 -2
- package/docs/settings.md +2 -2
- package/docs/subagents.md +7 -2
- package/docs/tui.md +61 -2
- package/docs/usage.md +6 -5
- package/docs/workflows.md +2572 -1379
- package/examples/extensions/handoff.ts +1 -1
- package/examples/extensions/qna.ts +1 -1
- package/examples/extensions/summarize.ts +1 -1
- package/npm-shrinkwrap.json +225 -76
- package/package.json +7 -6
- package/dist/builtin/workflows/src/durable/file-backend.ts +0 -439
- package/dist/builtin/workflows/src/durable/file-lock.ts +0 -153
- package/dist/builtin/workflows/src/durable/file-state.ts +0 -104
- package/dist/builtin/workflows/src/extension/runtime-direct.ts +0 -96
- package/dist/builtin/workflows/src/extension/workflow-tool-helpers.ts +0 -66
- package/dist/builtin/workflows/src/runs/foreground/executor-direct-output.ts +0 -91
- package/dist/builtin/workflows/src/runs/foreground/executor-direct.ts +0 -282
- package/dist/builtin/workflows/src/shared/resumable-workflow-notices.ts +0 -43
- package/dist/builtin/workflows/src/tui/session-confirm.ts +0 -299
|
@@ -0,0 +1,209 @@
|
|
|
1
|
+
import { TerminalModeController } from "./terminal-mode-controller.js";
|
|
2
|
+
import { RemoteFrameWidthClamp } from "./remote-frame-clamp.js";
|
|
3
|
+
class RemoteComponent {
|
|
4
|
+
constructor(componentId, runtime, requestRender, getRows) {
|
|
5
|
+
this.wantsKeyRelease = true;
|
|
6
|
+
this.lines = ["Loading remote component…"];
|
|
7
|
+
this.width = 0;
|
|
8
|
+
this.requestId = 0;
|
|
9
|
+
this.appliedRequestId = 0;
|
|
10
|
+
this.dirty = true;
|
|
11
|
+
this.disposed = false;
|
|
12
|
+
this.frameClamp = new RemoteFrameWidthClamp();
|
|
13
|
+
this.componentId = componentId;
|
|
14
|
+
this.runtime = runtime;
|
|
15
|
+
this.requestRender = requestRender;
|
|
16
|
+
this.getRows = getRows;
|
|
17
|
+
}
|
|
18
|
+
render(width) {
|
|
19
|
+
if (!this.disposed && (this.dirty || width !== this.width)) {
|
|
20
|
+
this.width = width;
|
|
21
|
+
this.dirty = false;
|
|
22
|
+
this.runtime.sendEngineCommand({
|
|
23
|
+
type: "engine_custom_render",
|
|
24
|
+
componentId: this.componentId,
|
|
25
|
+
requestId: ++this.requestId,
|
|
26
|
+
width,
|
|
27
|
+
rows: this.getRows(),
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
// The engine child re-renders asynchronously; until the fresh frame
|
|
31
|
+
// arrives, the previous frame may be wrapped for an older terminal
|
|
32
|
+
// width. Clamp so a resize never replays overflowing lines (pi-tui
|
|
33
|
+
// crashes on any rendered line wider than the terminal).
|
|
34
|
+
return this.frameClamp.clamp(this.lines, width);
|
|
35
|
+
}
|
|
36
|
+
handleInput(data) {
|
|
37
|
+
if (this.disposed)
|
|
38
|
+
return;
|
|
39
|
+
this.runtime.sendEngineCommand({ type: "engine_custom_input", componentId: this.componentId, data });
|
|
40
|
+
// Engine commands are delivered in order, so a frame requested now is
|
|
41
|
+
// rendered by the child only AFTER it has applied this input. Pipelining
|
|
42
|
+
// the request keeps keypress latency at a single round trip and repaints
|
|
43
|
+
// components that never self-invalidate, instead of waiting for a
|
|
44
|
+
// child-side invalidate (or an unrelated refresh) to trigger a frame.
|
|
45
|
+
this.dirty = true;
|
|
46
|
+
this.requestRender();
|
|
47
|
+
}
|
|
48
|
+
invalidate() {
|
|
49
|
+
this.dirty = true;
|
|
50
|
+
}
|
|
51
|
+
applyFrame(requestId, lines) {
|
|
52
|
+
if (this.disposed || requestId < this.appliedRequestId)
|
|
53
|
+
return;
|
|
54
|
+
this.appliedRequestId = requestId;
|
|
55
|
+
this.lines = lines;
|
|
56
|
+
this.requestRender();
|
|
57
|
+
}
|
|
58
|
+
requestRemoteRender() {
|
|
59
|
+
if (this.disposed)
|
|
60
|
+
return;
|
|
61
|
+
this.dirty = true;
|
|
62
|
+
this.requestRender();
|
|
63
|
+
}
|
|
64
|
+
dispose() {
|
|
65
|
+
if (this.disposed)
|
|
66
|
+
return;
|
|
67
|
+
this.disposed = true;
|
|
68
|
+
this.runtime.sendEngineCommand({ type: "engine_custom_dispose", componentId: this.componentId });
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
function overlayOptions(options) {
|
|
72
|
+
return options;
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Resolve the real host terminal from the pi-tui TUI handed to the overlay
|
|
76
|
+
* factory. Optional: some hosts / test seams do not surface `tui.terminal`, in
|
|
77
|
+
* which case terminal-mode controls harmlessly no-op.
|
|
78
|
+
*/
|
|
79
|
+
function hostTerminal(tui) {
|
|
80
|
+
const terminal = tui.terminal;
|
|
81
|
+
return typeof terminal?.write === "function"
|
|
82
|
+
? terminal
|
|
83
|
+
: { write: () => { } };
|
|
84
|
+
}
|
|
85
|
+
export class RemoteComponentController {
|
|
86
|
+
constructor(runtime, ui) {
|
|
87
|
+
this.mounted = new Map();
|
|
88
|
+
this.terminalModes = new TerminalModeController();
|
|
89
|
+
this.runtime = runtime;
|
|
90
|
+
this.ui = ui;
|
|
91
|
+
this.unsubscribe = runtime.onEngineMessage((message) => this.handleMessage(message));
|
|
92
|
+
}
|
|
93
|
+
dispose() {
|
|
94
|
+
this.unsubscribe();
|
|
95
|
+
this.terminalModes.resetAll();
|
|
96
|
+
for (const record of this.mounted.values()) {
|
|
97
|
+
if (record.widgetKey)
|
|
98
|
+
this.ui.setWidget(record.widgetKey, undefined);
|
|
99
|
+
record.component.dispose();
|
|
100
|
+
}
|
|
101
|
+
this.mounted.clear();
|
|
102
|
+
}
|
|
103
|
+
handleMessage(message) {
|
|
104
|
+
switch (message.type) {
|
|
105
|
+
case "engine_ready":
|
|
106
|
+
// A fresh engine generation replaced the child: any terminal modes
|
|
107
|
+
// the dead generation left on are stale. Reset them so a crashed or
|
|
108
|
+
// restarted overlay never strands the host TTY in mouse-reporting
|
|
109
|
+
// or autowrap-off mode; the new generation re-asserts on remount.
|
|
110
|
+
this.terminalModes.resetAll();
|
|
111
|
+
break;
|
|
112
|
+
case "engine_custom_open":
|
|
113
|
+
this.open(message.componentId, message.overlay, message.deferInlineCustomUiFocus, message.overlayOptions, message.widgetKey, message.widgetPlacement);
|
|
114
|
+
break;
|
|
115
|
+
case "engine_custom_close":
|
|
116
|
+
this.close(message.componentId);
|
|
117
|
+
break;
|
|
118
|
+
case "engine_custom_frame":
|
|
119
|
+
this.mounted.get(message.componentId)?.component.applyFrame(message.requestId, message.lines);
|
|
120
|
+
break;
|
|
121
|
+
case "engine_custom_invalidate":
|
|
122
|
+
this.mounted.get(message.componentId)?.component.requestRemoteRender();
|
|
123
|
+
break;
|
|
124
|
+
case "engine_custom_terminal":
|
|
125
|
+
this.terminalModes.applyControl(message.componentId, message.control);
|
|
126
|
+
break;
|
|
127
|
+
case "engine_custom_done": {
|
|
128
|
+
const record = this.mounted.get(message.componentId);
|
|
129
|
+
if (record) {
|
|
130
|
+
record.engineDone = true;
|
|
131
|
+
record.done(message.result);
|
|
132
|
+
}
|
|
133
|
+
break;
|
|
134
|
+
}
|
|
135
|
+
case "engine_custom_control":
|
|
136
|
+
this.control(message.componentId, message.action);
|
|
137
|
+
break;
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
open(componentId, overlay, deferInlineCustomUiFocus, options, widgetKey, widgetPlacement) {
|
|
141
|
+
if (this.mounted.has(componentId))
|
|
142
|
+
return;
|
|
143
|
+
if (widgetKey) {
|
|
144
|
+
let rows = 24;
|
|
145
|
+
const component = new RemoteComponent(componentId, this.runtime, () => this.ui.requestRender(), () => rows);
|
|
146
|
+
this.mounted.set(componentId, { component, done: () => { }, engineDone: false, widgetKey });
|
|
147
|
+
this.ui.setWidget(widgetKey, (tui) => {
|
|
148
|
+
rows = tui.terminal.rows;
|
|
149
|
+
return component;
|
|
150
|
+
}, { placement: widgetPlacement });
|
|
151
|
+
return;
|
|
152
|
+
}
|
|
153
|
+
let mounted;
|
|
154
|
+
void this.ui.custom((tui, _theme, _keybindings, done) => {
|
|
155
|
+
const component = new RemoteComponent(componentId, this.runtime, () => this.ui.requestRender(), () => tui.terminal.rows);
|
|
156
|
+
mounted = { component, done, engineDone: false };
|
|
157
|
+
this.mounted.set(componentId, mounted);
|
|
158
|
+
// Bind this component to the real host terminal so buffered/pending
|
|
159
|
+
// terminal-mode controls (e.g. mouse-scroll reporting the overlay
|
|
160
|
+
// enabled before the mount frame) apply to the host TTY.
|
|
161
|
+
this.terminalModes.onMount(componentId, hostTerminal(tui));
|
|
162
|
+
return component;
|
|
163
|
+
}, {
|
|
164
|
+
overlay,
|
|
165
|
+
deferInlineCustomUiFocus,
|
|
166
|
+
overlayOptions: overlayOptions(options),
|
|
167
|
+
onHandle: (handle) => { if (mounted)
|
|
168
|
+
mounted.handle = handle; },
|
|
169
|
+
}).catch(() => undefined).finally(() => {
|
|
170
|
+
this.terminalModes.onUnmount(componentId);
|
|
171
|
+
const record = this.mounted.get(componentId);
|
|
172
|
+
if (!record)
|
|
173
|
+
return;
|
|
174
|
+
this.mounted.delete(componentId);
|
|
175
|
+
if (!record.engineDone)
|
|
176
|
+
record.component.dispose();
|
|
177
|
+
});
|
|
178
|
+
}
|
|
179
|
+
close(componentId) {
|
|
180
|
+
const record = this.mounted.get(componentId);
|
|
181
|
+
if (!record)
|
|
182
|
+
return;
|
|
183
|
+
this.terminalModes.onUnmount(componentId);
|
|
184
|
+
this.mounted.delete(componentId);
|
|
185
|
+
if (record.widgetKey)
|
|
186
|
+
this.ui.setWidget(record.widgetKey, undefined);
|
|
187
|
+
record.component.dispose();
|
|
188
|
+
}
|
|
189
|
+
control(componentId, action) {
|
|
190
|
+
const handle = this.mounted.get(componentId)?.handle;
|
|
191
|
+
if (!handle)
|
|
192
|
+
return;
|
|
193
|
+
switch (action) {
|
|
194
|
+
case "focus":
|
|
195
|
+
handle.focus();
|
|
196
|
+
break;
|
|
197
|
+
case "hide":
|
|
198
|
+
handle.setHidden(true);
|
|
199
|
+
break;
|
|
200
|
+
case "show":
|
|
201
|
+
handle.setHidden(false);
|
|
202
|
+
break;
|
|
203
|
+
case "unfocus":
|
|
204
|
+
handle.unfocus();
|
|
205
|
+
break;
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
//# sourceMappingURL=remote-component.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"remote-component.js","sourceRoot":"","sources":["../../../src/modes/interactive-engine/remote-component.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,sBAAsB,EAAE,MAAM,+BAA+B,CAAC;AACvE,OAAO,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAUhE,MAAM,eAAe;IAepB,YACC,WAAmB,EACnB,OAAmC,EACnC,aAAyB,EACzB,OAAqB;QAlBtB,oBAAe,GAAG,IAAI,CAAC;QACf,UAAK,GAAG,CAAC,2BAA2B,CAAC,CAAC;QACtC,UAAK,GAAG,CAAC,CAAC;QACV,cAAS,GAAG,CAAC,CAAC;QACd,qBAAgB,GAAG,CAAC,CAAC;QACrB,UAAK,GAAG,IAAI,CAAC;QACb,aAAQ,GAAG,KAAK,CAAC;QACR,eAAU,GAAG,IAAI,qBAAqB,EAAE,CAAC;QAazD,IAAI,CAAC,WAAW,GAAG,WAAW,CAAC;QAC/B,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACvB,IAAI,CAAC,aAAa,GAAG,aAAa,CAAC;QACnC,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;IACxB,CAAC;IAED,MAAM,CAAC,KAAa;QACnB,IAAI,CAAC,IAAI,CAAC,QAAQ,IAAI,CAAC,IAAI,CAAC,KAAK,IAAI,KAAK,KAAK,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC;YAC5D,IAAI,CAAC,KAAK,GAAG,KAAK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C;IAEO,KAAK,CAAC,WAAmB;QAChC,MAAM,MAAM,GAAG,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC;QAC7C,IAAI,CAAC,MAAM;YAAE,OAAO;QACpB,IAAI,CAAC,aAAa,CAAC,SAAS,CAAC,WAAW,CAAC,CAAC;QAC1C,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC;QACjC,IAAI,MAAM,CAAC,SAAS;YAAE,IAAI,CAAC,EAAE,CAAC,SAAS,CAAC,MAAM,CAAC,SAAS,EAAE,SAAS,CAAC,CAAC;QACrE,MAAM,CAAC,SAAS,CAAC,OAAO,EAAE,CAAC;IAC5B,CAAC;IAEO,OAAO,CAAC,WAAmB,EAAE,MAA6C;QACjF,MAAM,MAAM,GAAG,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,WAAW,CAAC,EAAE,MAAM,CAAC;QACrD,IAAI,CAAC,MAAM;YAAE,OAAO;QACpB,QAAQ,MAAM,EAAE,CAAC;YAChB,KAAK,OAAO;gBAAE,MAAM,CAAC,KAAK,EAAE,CAAC;gBAAC,MAAM;YACpC,KAAK,MAAM;gBAAE,MAAM,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;gBAAC,MAAM;YAC3C,KAAK,MAAM;gBAAE,MAAM,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;gBAAC,MAAM;YAC5C,KAAK,SAAS;gBAAE,MAAM,CAAC,OAAO,EAAE,CAAC;gBAAC,MAAM;QACzC,CAAC;IACF,CAAC;CACD","sourcesContent":["import type { Component, OverlayHandle, OverlayOptions, TUI } from \"@earendil-works/pi-tui\";\nimport type { ExtensionUIContext } from \"../../core/extensions/index.ts\";\nimport type { IsolatedInteractiveRuntime } from \"./isolated-runtime.ts\";\nimport type { InteractiveEngineMessage, JsonValue, SerializableOverlayOptions } from \"./protocol.ts\";\nimport { TerminalModeController } from \"./terminal-mode-controller.ts\";\nimport { RemoteFrameWidthClamp } from \"./remote-frame-clamp.ts\";\n\ninterface MountedRemoteComponent {\n\tcomponent: RemoteComponent;\n\tdone: (result: JsonValue | undefined) => void;\n\tengineDone: boolean;\n\thandle?: OverlayHandle;\n\twidgetKey?: string;\n}\n\nclass RemoteComponent implements Component {\n\twantsKeyRelease = true;\n\tprivate lines = [\"Loading remote component…\"];\n\tprivate width = 0;\n\tprivate requestId = 0;\n\tprivate appliedRequestId = 0;\n\tprivate dirty = true;\n\tprivate disposed = false;\n\tprivate readonly frameClamp = new RemoteFrameWidthClamp();\n\n\tprivate readonly componentId: string;\n\tprivate readonly runtime: IsolatedInteractiveRuntime;\n\tprivate readonly requestRender: () => void;\n\tprivate readonly getRows: () => number;\n\n\tconstructor(\n\t\tcomponentId: string,\n\t\truntime: IsolatedInteractiveRuntime,\n\t\trequestRender: () => void,\n\t\tgetRows: () => number,\n\t) {\n\t\tthis.componentId = componentId;\n\t\tthis.runtime = runtime;\n\t\tthis.requestRender = requestRender;\n\t\tthis.getRows = getRows;\n\t}\n\n\trender(width: number): string[] {\n\t\tif (!this.disposed && (this.dirty || width !== this.width)) {\n\t\t\tthis.width = width;\n\t\t\tthis.dirty = false;\n\t\t\tthis.runtime.sendEngineCommand({\n\t\t\t\ttype: \"engine_custom_render\",\n\t\t\t\tcomponentId: this.componentId,\n\t\t\t\trequestId: ++this.requestId,\n\t\t\t\twidth,\n\t\t\t\trows: this.getRows(),\n\t\t\t});\n\t\t}\n\t\t// The engine child re-renders asynchronously; until the fresh frame\n\t\t// arrives, the previous frame may be wrapped for an older terminal\n\t\t// width. Clamp so a resize never replays overflowing lines (pi-tui\n\t\t// crashes on any rendered line wider than the terminal).\n\t\treturn this.frameClamp.clamp(this.lines, width);\n\t}\n\n\thandleInput(data: string): void {\n\t\tif (this.disposed) return;\n\t\tthis.runtime.sendEngineCommand({ type: \"engine_custom_input\", componentId: this.componentId, data });\n\t\t// Engine commands are delivered in order, so a frame requested now is\n\t\t// rendered by the child only AFTER it has applied this input. Pipelining\n\t\t// the request keeps keypress latency at a single round trip and repaints\n\t\t// components that never self-invalidate, instead of waiting for a\n\t\t// child-side invalidate (or an unrelated refresh) to trigger a frame.\n\t\tthis.dirty = true;\n\t\tthis.requestRender();\n\t}\n\n\tinvalidate(): void {\n\t\tthis.dirty = true;\n\t}\n\n\tapplyFrame(requestId: number, lines: string[]): void {\n\t\tif (this.disposed || requestId < this.appliedRequestId) return;\n\t\tthis.appliedRequestId = requestId;\n\t\tthis.lines = lines;\n\t\tthis.requestRender();\n\t}\n\n\trequestRemoteRender(): void {\n\t\tif (this.disposed) return;\n\t\tthis.dirty = true;\n\t\tthis.requestRender();\n\t}\n\n\tdispose(): void {\n\t\tif (this.disposed) return;\n\t\tthis.disposed = true;\n\t\tthis.runtime.sendEngineCommand({ type: \"engine_custom_dispose\", componentId: this.componentId });\n\t}\n}\n\nfunction overlayOptions(options: SerializableOverlayOptions | undefined): OverlayOptions | undefined {\n\treturn options as OverlayOptions | undefined;\n}\n\n/**\n * Resolve the real host terminal from the pi-tui TUI handed to the overlay\n * factory. Optional: some hosts / test seams do not surface `tui.terminal`, in\n * which case terminal-mode controls harmlessly no-op.\n */\nfunction hostTerminal(tui: TUI): { write(data: string): void } {\n\tconst terminal = (tui as { terminal?: { write?(data: string): void } }).terminal;\n\treturn typeof terminal?.write === \"function\"\n\t\t? (terminal as { write(data: string): void })\n\t\t: { write: () => {} };\n}\n\nexport class RemoteComponentController {\n\tprivate readonly mounted = new Map<string, MountedRemoteComponent>();\n\tprivate readonly unsubscribe: () => void;\n\tprivate readonly terminalModes = new TerminalModeController();\n\n\tprivate readonly runtime: IsolatedInteractiveRuntime;\n\tprivate readonly ui: ExtensionUIContext;\n\n\tconstructor(\n\t\truntime: IsolatedInteractiveRuntime,\n\t\tui: ExtensionUIContext,\n\t) {\n\t\tthis.runtime = runtime;\n\t\tthis.ui = ui;\n\t\tthis.unsubscribe = runtime.onEngineMessage((message) => this.handleMessage(message));\n\t}\n\n\tdispose(): void {\n\t\tthis.unsubscribe();\n\t\tthis.terminalModes.resetAll();\n\t\tfor (const record of this.mounted.values()) {\n\t\t\tif (record.widgetKey) this.ui.setWidget(record.widgetKey, undefined);\n\t\t\trecord.component.dispose();\n\t\t}\n\t\tthis.mounted.clear();\n\t}\n\n\tprivate handleMessage(message: InteractiveEngineMessage): void {\n\t\tswitch (message.type) {\n\t\t\tcase \"engine_ready\":\n\t\t\t\t// A fresh engine generation replaced the child: any terminal modes\n\t\t\t\t// the dead generation left on are stale. Reset them so a crashed or\n\t\t\t\t// restarted overlay never strands the host TTY in mouse-reporting\n\t\t\t\t// or autowrap-off mode; the new generation re-asserts on remount.\n\t\t\t\tthis.terminalModes.resetAll();\n\t\t\t\tbreak;\n\t\t\tcase \"engine_custom_open\":\n\t\t\t\tthis.open(message.componentId, message.overlay, message.deferInlineCustomUiFocus, message.overlayOptions, message.widgetKey, message.widgetPlacement);\n\t\t\t\tbreak;\n\t\t\tcase \"engine_custom_close\":\n\t\t\t\tthis.close(message.componentId);\n\t\t\t\tbreak;\n\t\t\tcase \"engine_custom_frame\":\n\t\t\t\tthis.mounted.get(message.componentId)?.component.applyFrame(message.requestId, message.lines);\n\t\t\t\tbreak;\n\t\t\tcase \"engine_custom_invalidate\":\n\t\t\t\tthis.mounted.get(message.componentId)?.component.requestRemoteRender();\n\t\t\t\tbreak;\n\t\t\tcase \"engine_custom_terminal\":\n\t\t\t\tthis.terminalModes.applyControl(message.componentId, message.control);\n\t\t\t\tbreak;\n\t\t\tcase \"engine_custom_done\": {\n\t\t\t\tconst record = this.mounted.get(message.componentId);\n\t\t\t\tif (record) {\n\t\t\t\t\trecord.engineDone = true;\n\t\t\t\t\trecord.done(message.result);\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase \"engine_custom_control\":\n\t\t\t\tthis.control(message.componentId, message.action);\n\t\t\t\tbreak;\n\t\t}\n\t}\n\n\tprivate open(\n\t\tcomponentId: string,\n\t\toverlay: boolean,\n\t\tdeferInlineCustomUiFocus: boolean | undefined,\n\t\toptions: SerializableOverlayOptions | undefined,\n\t\twidgetKey?: string,\n\t\twidgetPlacement?: \"aboveEditor\" | \"belowEditor\",\n\t): void {\n\t\tif (this.mounted.has(componentId)) return;\n\t\tif (widgetKey) {\n\t\t\tlet rows = 24;\n\t\t\tconst component = new RemoteComponent(componentId, this.runtime, () => this.ui.requestRender(), () => rows);\n\t\t\tthis.mounted.set(componentId, { component, done: () => {}, engineDone: false, widgetKey });\n\t\t\tthis.ui.setWidget(widgetKey, (tui) => {\n\t\t\t\trows = tui.terminal.rows;\n\t\t\t\treturn component;\n\t\t\t}, { placement: widgetPlacement });\n\t\t\treturn;\n\t\t}\n\t\tlet mounted: MountedRemoteComponent | undefined;\n\t\tvoid this.ui.custom<JsonValue | undefined>(\n\t\t\t(tui, _theme, _keybindings, done) => {\n\t\t\t\tconst component = new RemoteComponent(\n\t\t\t\t\tcomponentId, this.runtime, () => this.ui.requestRender(), () => tui.terminal.rows,\n\t\t\t\t);\n\t\t\t\tmounted = { component, done, engineDone: false };\n\t\t\t\tthis.mounted.set(componentId, mounted);\n\t\t\t\t// Bind this component to the real host terminal so buffered/pending\n\t\t\t\t// terminal-mode controls (e.g. mouse-scroll reporting the overlay\n\t\t\t\t// enabled before the mount frame) apply to the host TTY.\n\t\t\t\tthis.terminalModes.onMount(componentId, hostTerminal(tui));\n\t\t\t\treturn component;\n\t\t\t},\n\t\t\t{\n\t\t\t\toverlay,\n\t\t\t\tdeferInlineCustomUiFocus,\n\t\t\t\toverlayOptions: overlayOptions(options),\n\t\t\t\tonHandle: (handle) => { if (mounted) mounted.handle = handle; },\n\t\t\t},\n\t\t).catch(() => undefined).finally(() => {\n\t\t\tthis.terminalModes.onUnmount(componentId);\n\t\t\tconst record = this.mounted.get(componentId);\n\t\t\tif (!record) return;\n\t\t\tthis.mounted.delete(componentId);\n\t\t\tif (!record.engineDone) record.component.dispose();\n\t\t});\n\t}\n\n\tprivate close(componentId: string): void {\n\t\tconst record = this.mounted.get(componentId);\n\t\tif (!record) return;\n\t\tthis.terminalModes.onUnmount(componentId);\n\t\tthis.mounted.delete(componentId);\n\t\tif (record.widgetKey) this.ui.setWidget(record.widgetKey, undefined);\n\t\trecord.component.dispose();\n\t}\n\n\tprivate control(componentId: string, action: \"focus\" | \"hide\" | \"show\" | \"unfocus\"): void {\n\t\tconst handle = this.mounted.get(componentId)?.handle;\n\t\tif (!handle) return;\n\t\tswitch (action) {\n\t\t\tcase \"focus\": handle.focus(); break;\n\t\t\tcase \"hide\": handle.setHidden(true); break;\n\t\t\tcase \"show\": handle.setHidden(false); break;\n\t\t\tcase \"unfocus\": handle.unfocus(); break;\n\t\t}\n\t}\n}\n"]}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Width clamp for frames rendered out-of-process by the isolated interactive
|
|
3
|
+
* engine.
|
|
4
|
+
*
|
|
5
|
+
* Remote components ({@link RemoteRenderer}, {@link RemoteComponent}) request a
|
|
6
|
+
* re-render from the engine child asynchronously and keep returning the last
|
|
7
|
+
* applied frame until the fresh one arrives. Across a terminal resize this
|
|
8
|
+
* replays lines wrapped at the previous width; pi-tui's differential renderer
|
|
9
|
+
* treats any rendered line wider than the terminal as a fatal invariant
|
|
10
|
+
* violation and crashes the whole TUI (uncaughtException in doRender).
|
|
11
|
+
*
|
|
12
|
+
* Clamping the stale frame to the currently requested width keeps every
|
|
13
|
+
* returned line legal while the engine catches up; the properly re-wrapped
|
|
14
|
+
* frame replaces the clamped one as soon as it is applied.
|
|
15
|
+
*
|
|
16
|
+
* The result is memoized on (frame identity, width) so steady-state renders
|
|
17
|
+
* cost one identity check and re-scans happen only on resize or frame change.
|
|
18
|
+
*/
|
|
19
|
+
export declare class RemoteFrameWidthClamp {
|
|
20
|
+
private source;
|
|
21
|
+
private width;
|
|
22
|
+
private clamped;
|
|
23
|
+
clamp(lines: string[], width: number): string[];
|
|
24
|
+
}
|
|
25
|
+
//# sourceMappingURL=remote-frame-clamp.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"remote-frame-clamp.d.ts","sourceRoot":"","sources":["../../../src/modes/interactive-engine/remote-frame-clamp.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;;;GAiBG;AACH,qBAAa,qBAAqB;IACjC,OAAO,CAAC,MAAM,CAAgC;IAC9C,OAAO,CAAC,KAAK,CAAM;IACnB,OAAO,CAAC,OAAO,CAAuB;IAEtC,KAAK,CAAC,KAAK,EAAE,MAAM,EAAE,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,EAAE,CAmB9C;CACD"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { truncateToWidth, visibleWidth } from "@earendil-works/pi-tui";
|
|
2
|
+
/**
|
|
3
|
+
* Width clamp for frames rendered out-of-process by the isolated interactive
|
|
4
|
+
* engine.
|
|
5
|
+
*
|
|
6
|
+
* Remote components ({@link RemoteRenderer}, {@link RemoteComponent}) request a
|
|
7
|
+
* re-render from the engine child asynchronously and keep returning the last
|
|
8
|
+
* applied frame until the fresh one arrives. Across a terminal resize this
|
|
9
|
+
* replays lines wrapped at the previous width; pi-tui's differential renderer
|
|
10
|
+
* treats any rendered line wider than the terminal as a fatal invariant
|
|
11
|
+
* violation and crashes the whole TUI (uncaughtException in doRender).
|
|
12
|
+
*
|
|
13
|
+
* Clamping the stale frame to the currently requested width keeps every
|
|
14
|
+
* returned line legal while the engine catches up; the properly re-wrapped
|
|
15
|
+
* frame replaces the clamped one as soon as it is applied.
|
|
16
|
+
*
|
|
17
|
+
* The result is memoized on (frame identity, width) so steady-state renders
|
|
18
|
+
* cost one identity check and re-scans happen only on resize or frame change.
|
|
19
|
+
*/
|
|
20
|
+
export class RemoteFrameWidthClamp {
|
|
21
|
+
constructor() {
|
|
22
|
+
this.width = -1;
|
|
23
|
+
}
|
|
24
|
+
clamp(lines, width) {
|
|
25
|
+
if (this.clamped !== undefined && this.source === lines && this.width === width) {
|
|
26
|
+
return this.clamped;
|
|
27
|
+
}
|
|
28
|
+
let result = lines;
|
|
29
|
+
if (width > 0) {
|
|
30
|
+
for (const line of lines) {
|
|
31
|
+
if (visibleWidth(line) > width) {
|
|
32
|
+
result = lines.map((frameLine) => visibleWidth(frameLine) > width ? truncateToWidth(frameLine, width, "") : frameLine);
|
|
33
|
+
break;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
this.source = lines;
|
|
38
|
+
this.width = width;
|
|
39
|
+
this.clamped = result;
|
|
40
|
+
return result;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
//# sourceMappingURL=remote-frame-clamp.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"remote-frame-clamp.js","sourceRoot":"","sources":["../../../src/modes/interactive-engine/remote-frame-clamp.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAEvE;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,OAAO,qBAAqB;IAAlC;QAES,UAAK,GAAG,CAAC,CAAC,CAAC;IAuBpB,CAAC;IApBA,KAAK,CAAC,KAAe,EAAE,KAAa;QACnC,IAAI,IAAI,CAAC,OAAO,KAAK,SAAS,IAAI,IAAI,CAAC,MAAM,KAAK,KAAK,IAAI,IAAI,CAAC,KAAK,KAAK,KAAK,EAAE,CAAC;YACjF,OAAO,IAAI,CAAC,OAAO,CAAC;QACrB,CAAC;QACD,IAAI,MAAM,GAAG,KAAK,CAAC;QACnB,IAAI,KAAK,GAAG,CAAC,EAAE,CAAC;YACf,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;gBAC1B,IAAI,YAAY,CAAC,IAAI,CAAC,GAAG,KAAK,EAAE,CAAC;oBAChC,MAAM,GAAG,KAAK,CAAC,GAAG,CAAC,CAAC,SAAS,EAAE,EAAE,CAChC,YAAY,CAAC,SAAS,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC,eAAe,CAAC,SAAS,EAAE,KAAK,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,SAAS,CACnF,CAAC;oBACF,MAAM;gBACP,CAAC;YACF,CAAC;QACF,CAAC;QACD,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC;QACpB,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;QACnB,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC;QACtB,OAAO,MAAM,CAAC;IACf,CAAC;CACD","sourcesContent":["import { truncateToWidth, visibleWidth } from \"@earendil-works/pi-tui\";\n\n/**\n * Width clamp for frames rendered out-of-process by the isolated interactive\n * engine.\n *\n * Remote components ({@link RemoteRenderer}, {@link RemoteComponent}) request a\n * re-render from the engine child asynchronously and keep returning the last\n * applied frame until the fresh one arrives. Across a terminal resize this\n * replays lines wrapped at the previous width; pi-tui's differential renderer\n * treats any rendered line wider than the terminal as a fatal invariant\n * violation and crashes the whole TUI (uncaughtException in doRender).\n *\n * Clamping the stale frame to the currently requested width keeps every\n * returned line legal while the engine catches up; the properly re-wrapped\n * frame replaces the clamped one as soon as it is applied.\n *\n * The result is memoized on (frame identity, width) so steady-state renders\n * cost one identity check and re-scans happen only on resize or frame change.\n */\nexport class RemoteFrameWidthClamp {\n\tprivate source: readonly string[] | undefined;\n\tprivate width = -1;\n\tprivate clamped: string[] | undefined;\n\n\tclamp(lines: string[], width: number): string[] {\n\t\tif (this.clamped !== undefined && this.source === lines && this.width === width) {\n\t\t\treturn this.clamped;\n\t\t}\n\t\tlet result = lines;\n\t\tif (width > 0) {\n\t\t\tfor (const line of lines) {\n\t\t\t\tif (visibleWidth(line) > width) {\n\t\t\t\t\tresult = lines.map((frameLine) =>\n\t\t\t\t\t\tvisibleWidth(frameLine) > width ? truncateToWidth(frameLine, width, \"\") : frameLine,\n\t\t\t\t\t);\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tthis.source = lines;\n\t\tthis.width = width;\n\t\tthis.clamped = result;\n\t\treturn result;\n\t}\n}\n"]}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import type { Component } from "@earendil-works/pi-tui";
|
|
2
|
+
import type { CustomMessage } from "../../core/messages.ts";
|
|
3
|
+
import type { ToolExecutionComponent } from "../interactive/components/tool-execution.ts";
|
|
4
|
+
import type { IsolatedInteractiveRuntime } from "./isolated-runtime.ts";
|
|
5
|
+
import type { InteractiveEngineCommand } from "./protocol.ts";
|
|
6
|
+
type RenderableToolResult = Parameters<ToolExecutionComponent["updateResult"]>[0];
|
|
7
|
+
declare abstract class RemoteRenderer implements Component {
|
|
8
|
+
protected readonly componentId: string;
|
|
9
|
+
private lines;
|
|
10
|
+
private width;
|
|
11
|
+
private requestId;
|
|
12
|
+
private appliedRequestId;
|
|
13
|
+
private dirty;
|
|
14
|
+
private disposed;
|
|
15
|
+
private readonly frameClamp;
|
|
16
|
+
private readonly unsubscribe;
|
|
17
|
+
protected readonly runtime: IsolatedInteractiveRuntime;
|
|
18
|
+
private readonly requestRender;
|
|
19
|
+
constructor(runtime: IsolatedInteractiveRuntime, requestRender: () => void);
|
|
20
|
+
render(width: number): string[];
|
|
21
|
+
invalidate(): void;
|
|
22
|
+
dispose(): void;
|
|
23
|
+
protected changed(): void;
|
|
24
|
+
protected abstract command(requestId: number, width: number): InteractiveEngineCommand;
|
|
25
|
+
private markDirty;
|
|
26
|
+
}
|
|
27
|
+
export declare class RemoteToolExecutionComponent extends RemoteRenderer {
|
|
28
|
+
private readonly toolName;
|
|
29
|
+
private readonly toolCallId;
|
|
30
|
+
private args;
|
|
31
|
+
private result;
|
|
32
|
+
private executionStarted;
|
|
33
|
+
private argsComplete;
|
|
34
|
+
private isPartial;
|
|
35
|
+
private expanded;
|
|
36
|
+
private showImages;
|
|
37
|
+
private imageWidthCells;
|
|
38
|
+
constructor(toolName: string, toolCallId: string, args: unknown, options: {
|
|
39
|
+
showImages?: boolean;
|
|
40
|
+
imageWidthCells?: number;
|
|
41
|
+
}, runtime: IsolatedInteractiveRuntime, requestRender: () => void);
|
|
42
|
+
updateArgs(args: unknown): void;
|
|
43
|
+
markExecutionStarted(): void;
|
|
44
|
+
setArgsComplete(): void;
|
|
45
|
+
updateResult(result: RenderableToolResult, isPartial?: boolean): void;
|
|
46
|
+
setExpanded(expanded: boolean): void;
|
|
47
|
+
setShowImages(show: boolean): void;
|
|
48
|
+
setImageWidthCells(width: number): void;
|
|
49
|
+
protected command(requestId: number, width: number): InteractiveEngineCommand;
|
|
50
|
+
}
|
|
51
|
+
export declare class RemoteCustomMessageComponent extends RemoteRenderer {
|
|
52
|
+
private readonly message;
|
|
53
|
+
private expanded;
|
|
54
|
+
constructor(message: CustomMessage<unknown>, runtime: IsolatedInteractiveRuntime, requestRender: () => void);
|
|
55
|
+
setExpanded(expanded: boolean): void;
|
|
56
|
+
protected command(requestId: number, width: number): InteractiveEngineCommand;
|
|
57
|
+
}
|
|
58
|
+
export {};
|
|
59
|
+
//# sourceMappingURL=remote-renderer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"remote-renderer.d.ts","sourceRoot":"","sources":["../../../src/modes/interactive-engine/remote-renderer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AACxD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAC5D,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,6CAA6C,CAAC;AAC1F,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,uBAAuB,CAAC;AACxE,OAAO,KAAK,EAAE,wBAAwB,EAAyB,MAAM,eAAe,CAAC;AAGrF,KAAK,oBAAoB,GAAG,UAAU,CAAC,sBAAsB,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AAUlF,uBAAe,cAAe,YAAW,SAAS;IACjD,SAAS,CAAC,QAAQ,CAAC,WAAW,SAA+C;IAC7E,OAAO,CAAC,K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QAAC,eAAe,CAAC,EAAE,MAAM,CAAA;KAAE,EAC3D,OAAO,EAAE,0BAA0B,EACnC,aAAa,EAAE,MAAM,IAAI,EAQzB;IAED,UAAU,CAAC,IAAI,EAAE,OAAO,GAAG,IAAI,CAAsC;IACrE,oBAAoB,IAAI,IAAI,CAAkD;IAC9E,eAAe,IAAI,IAAI,CAA8C;IACrE,YAAY,CAAC,MAAM,EAAE,oBAAoB,EAAE,SAAS,UAAQ,GAAG,IAAI,CAIlE;IACD,WAAW,CAAC,QAAQ,EAAE,OAAO,GAAG,IAAI,CAA8C;IAClF,aAAa,CAAC,IAAI,EAAE,OAAO,GAAG,IAAI,CAA4C;IAC9E,kBAAkB,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAA2E;IAElH,SAAS,CAAC,OAAO,CAAC,SAAS,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,wBAAwB,CAiB5E;CACD;AAED,qBAAa,4BAA6B,SAAQ,cAAc;IAC/D,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAyB;IACjD,OAAO,CAAC,QAAQ,CAAS;IACzB,YACC,OAAO,EAAE,aAAa,CAAC,OAAO,CAAC,EAC/B,OAAO,EAAE,0BAA0B,EACnC,aAAa,EAAE,MAAM,IAAI,EAIzB;IAED,WAAW,CAAC,QAAQ,EAAE,OAAO,GAAG,IAAI,CAA8C;IAElF,SAAS,CAAC,OAAO,CAAC,SAAS,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,wBAAwB,CAS5E;CACD"}
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
import { RemoteFrameWidthClamp } from "./remote-frame-clamp.js";
|
|
2
|
+
let nextRemoteRendererId = 0;
|
|
3
|
+
function jsonValue(value) {
|
|
4
|
+
if (value === undefined)
|
|
5
|
+
return null;
|
|
6
|
+
const encoded = JSON.stringify(value);
|
|
7
|
+
return encoded === undefined ? null : JSON.parse(encoded);
|
|
8
|
+
}
|
|
9
|
+
class RemoteRenderer {
|
|
10
|
+
constructor(runtime, requestRender) {
|
|
11
|
+
this.componentId = `remote_renderer_${++nextRemoteRendererId}`;
|
|
12
|
+
this.lines = ["Loading isolated renderer…"];
|
|
13
|
+
this.width = 0;
|
|
14
|
+
this.requestId = 0;
|
|
15
|
+
this.appliedRequestId = 0;
|
|
16
|
+
this.dirty = true;
|
|
17
|
+
this.disposed = false;
|
|
18
|
+
this.frameClamp = new RemoteFrameWidthClamp();
|
|
19
|
+
this.runtime = runtime;
|
|
20
|
+
this.requestRender = requestRender;
|
|
21
|
+
this.unsubscribe = runtime.onEngineMessage((message) => {
|
|
22
|
+
if (!("componentId" in message) || message.componentId !== this.componentId)
|
|
23
|
+
return;
|
|
24
|
+
if (message.type === "engine_custom_frame") {
|
|
25
|
+
if (message.requestId < this.appliedRequestId)
|
|
26
|
+
return;
|
|
27
|
+
this.appliedRequestId = message.requestId;
|
|
28
|
+
this.lines = message.lines;
|
|
29
|
+
this.requestRender();
|
|
30
|
+
}
|
|
31
|
+
else if (message.type === "engine_custom_invalidate") {
|
|
32
|
+
this.markDirty();
|
|
33
|
+
}
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
render(width) {
|
|
37
|
+
if (!this.disposed && (this.dirty || width !== this.width)) {
|
|
38
|
+
this.width = width;
|
|
39
|
+
this.dirty = false;
|
|
40
|
+
this.runtime.sendEngineCommand(this.command(++this.requestId, width));
|
|
41
|
+
}
|
|
42
|
+
// The engine child re-renders asynchronously; until the fresh frame
|
|
43
|
+
// arrives, the previous frame may be wrapped for an older terminal
|
|
44
|
+
// width. Clamp so a resize never replays overflowing lines (pi-tui
|
|
45
|
+
// crashes on any rendered line wider than the terminal).
|
|
46
|
+
return this.frameClamp.clamp(this.lines, width);
|
|
47
|
+
}
|
|
48
|
+
invalidate() { this.markDirty(); }
|
|
49
|
+
dispose() {
|
|
50
|
+
if (this.disposed)
|
|
51
|
+
return;
|
|
52
|
+
this.disposed = true;
|
|
53
|
+
this.unsubscribe();
|
|
54
|
+
this.runtime.sendEngineCommand({ type: "engine_render_dispose", componentId: this.componentId });
|
|
55
|
+
}
|
|
56
|
+
changed() {
|
|
57
|
+
this.markDirty();
|
|
58
|
+
this.requestRender();
|
|
59
|
+
}
|
|
60
|
+
markDirty() { this.dirty = true; }
|
|
61
|
+
}
|
|
62
|
+
export class RemoteToolExecutionComponent extends RemoteRenderer {
|
|
63
|
+
constructor(toolName, toolCallId, args, options, runtime, requestRender) {
|
|
64
|
+
super(runtime, requestRender);
|
|
65
|
+
this.executionStarted = false;
|
|
66
|
+
this.argsComplete = false;
|
|
67
|
+
this.isPartial = true;
|
|
68
|
+
this.expanded = false;
|
|
69
|
+
this.toolName = toolName;
|
|
70
|
+
this.toolCallId = toolCallId;
|
|
71
|
+
this.args = args;
|
|
72
|
+
this.showImages = options.showImages ?? true;
|
|
73
|
+
this.imageWidthCells = options.imageWidthCells ?? 60;
|
|
74
|
+
}
|
|
75
|
+
updateArgs(args) { this.args = args; this.changed(); }
|
|
76
|
+
markExecutionStarted() { this.executionStarted = true; this.changed(); }
|
|
77
|
+
setArgsComplete() { this.argsComplete = true; this.changed(); }
|
|
78
|
+
updateResult(result, isPartial = false) {
|
|
79
|
+
this.result = result;
|
|
80
|
+
this.isPartial = isPartial;
|
|
81
|
+
this.changed();
|
|
82
|
+
}
|
|
83
|
+
setExpanded(expanded) { this.expanded = expanded; this.changed(); }
|
|
84
|
+
setShowImages(show) { this.showImages = show; this.changed(); }
|
|
85
|
+
setImageWidthCells(width) { this.imageWidthCells = Math.max(1, Math.floor(width)); this.changed(); }
|
|
86
|
+
command(requestId, width) {
|
|
87
|
+
return {
|
|
88
|
+
type: "engine_tool_render",
|
|
89
|
+
componentId: this.componentId,
|
|
90
|
+
requestId,
|
|
91
|
+
width,
|
|
92
|
+
toolName: this.toolName,
|
|
93
|
+
toolCallId: this.toolCallId,
|
|
94
|
+
args: jsonValue(this.args),
|
|
95
|
+
result: this.result ? jsonValue(this.result) : undefined,
|
|
96
|
+
executionStarted: this.executionStarted,
|
|
97
|
+
argsComplete: this.argsComplete,
|
|
98
|
+
isPartial: this.isPartial,
|
|
99
|
+
expanded: this.expanded,
|
|
100
|
+
showImages: this.showImages,
|
|
101
|
+
imageWidthCells: this.imageWidthCells,
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
export class RemoteCustomMessageComponent extends RemoteRenderer {
|
|
106
|
+
constructor(message, runtime, requestRender) {
|
|
107
|
+
super(runtime, requestRender);
|
|
108
|
+
this.expanded = false;
|
|
109
|
+
this.message = message;
|
|
110
|
+
}
|
|
111
|
+
setExpanded(expanded) { this.expanded = expanded; this.changed(); }
|
|
112
|
+
command(requestId, width) {
|
|
113
|
+
return {
|
|
114
|
+
type: "engine_message_render",
|
|
115
|
+
componentId: this.componentId,
|
|
116
|
+
requestId,
|
|
117
|
+
width,
|
|
118
|
+
message: jsonValue(this.message),
|
|
119
|
+
expanded: this.expanded,
|
|
120
|
+
};
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
//# sourceMappingURL=remote-renderer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"remote-renderer.js","sourceRoot":"","sources":["../../../src/modes/interactive-engine/remote-renderer.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAIhE,IAAI,oBAAoB,GAAG,CAAC,CAAC;AAE7B,SAAS,SAAS,CAAC,KAAc;IAChC,IAAI,KAAK,KAAK,SAAS;QAAE,OAAO,IAAI,CAAC;IACrC,MAAM,OAAO,GAAG,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;IACtC,OAAO,OAAO,KAAK,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,OAAO,CAAc,CAAC;AACxE,CAAC;AAED,MAAe,cAAc;IAc5B,YACC,OAAmC,EACnC,aAAyB;QAfP,gBAAW,GAAG,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E,IAAI,CAAC,UAAU;YAC3B,IAAI,EAAE,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC;YAC1B,MAAM,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,SAAS,CAAC,IAAI,CAAC,MAAM,CAAe,CAAC,CAAC,CAAC,SAAS;YACtE,gBAAgB,EAAE,IAAI,CAAC,gBAAgB;YACvC,YAAY,EAAE,IAAI,CAAC,YAAY;YAC/B,SAAS,EAAE,IAAI,CAAC,SAAS;YACzB,QAAQ,EAAE,IAAI,CAAC,QAAQ;YACvB,UAAU,EAAE,IAAI,CAAC,UAAU;YAC3B,eAAe,EAAE,IAAI,CAAC,eAAe;SACrC,CAAC;IACH,CAAC;CACD;AAED,MAAM,OAAO,4BAA6B,SAAQ,cAAc;IAG/D,YACC,OAA+B,EAC/B,OAAmC,EACnC,aAAyB;QAEzB,KAAK,CAAC,OAAO,EAAE,aAAa,CAAC,CAAC;QANvB,aAAQ,GAAG,KAAK,CAAC;QAOxB,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;IACxB,CAAC;IAED,WAAW,CAAC,QAAiB,IAAU,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC,CAAC,IAAI,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC;IAExE,OAAO,CAAC,SAAiB,EAAE,KAAa;QACjD,OAAO;YACN,IAAI,EAAE,uBAAuB;YAC7B,WAAW,EAAE,IAAI,CAAC,WAAW;YAC7B,SAAS;YACT,KAAK;YACL,OAAO,EAAE,SAAS,CAAC,IAAI,CAAC,OAAO,CAAe;YAC9C,QAAQ,EAAE,IAAI,CAAC,QAAQ;SACvB,CAAC;IACH,CAAC;CACD","sourcesContent":["import type { Component } from \"@earendil-works/pi-tui\";\nimport type { CustomMessage } from \"../../core/messages.ts\";\nimport type { ToolExecutionComponent } from \"../interactive/components/tool-execution.ts\";\nimport type { IsolatedInteractiveRuntime } from \"./isolated-runtime.ts\";\nimport type { InteractiveEngineCommand, JsonObject, JsonValue } from \"./protocol.ts\";\nimport { RemoteFrameWidthClamp } from \"./remote-frame-clamp.ts\";\n\ntype RenderableToolResult = Parameters<ToolExecutionComponent[\"updateResult\"]>[0];\n\nlet nextRemoteRendererId = 0;\n\nfunction jsonValue(value: unknown): JsonValue {\n\tif (value === undefined) return null;\n\tconst encoded = JSON.stringify(value);\n\treturn encoded === undefined ? null : JSON.parse(encoded) as JsonValue;\n}\n\nabstract class RemoteRenderer implements Component {\n\tprotected readonly componentId = `remote_renderer_${++nextRemoteRendererId}`;\n\tprivate lines = [\"Loading isolated renderer…\"];\n\tprivate width = 0;\n\tprivate requestId = 0;\n\tprivate appliedRequestId = 0;\n\tprivate dirty = true;\n\tprivate disposed = false;\n\tprivate readonly frameClamp = new RemoteFrameWidthClamp();\n\tprivate readonly unsubscribe: () => void;\n\n\tprotected readonly runtime: IsolatedInteractiveRuntime;\n\tprivate readonly requestRender: () => void;\n\n\tconstructor(\n\t\truntime: IsolatedInteractiveRuntime,\n\t\trequestRender: () => void,\n\t) {\n\t\tthis.runtime = runtime;\n\t\tthis.requestRender = requestRender;\n\t\tthis.unsubscribe = runtime.onEngineMessage((message) => {\n\t\t\tif (!(\"componentId\" in message) || message.componentId !== this.componentId) return;\n\t\t\tif (message.type === \"engine_custom_frame\") {\n\t\t\t\tif (message.requestId < this.appliedRequestId) return;\n\t\t\t\tthis.appliedRequestId = message.requestId;\n\t\t\t\tthis.lines = message.lines;\n\t\t\t\tthis.requestRender();\n\t\t\t} else if (message.type === \"engine_custom_invalidate\") {\n\t\t\t\tthis.markDirty();\n\t\t\t}\n\t\t});\n\t}\n\n\trender(width: number): string[] {\n\t\tif (!this.disposed && (this.dirty || width !== this.width)) {\n\t\t\tthis.width = width;\n\t\t\tthis.dirty = false;\n\t\t\tthis.runtime.sendEngineCommand(this.command(++this.requestId, width));\n\t\t}\n\t\t// The engine child re-renders asynchronously; until the fresh frame\n\t\t// arrives, the previous frame may be wrapped for an older terminal\n\t\t// width. Clamp so a resize never replays overflowing lines (pi-tui\n\t\t// crashes on any rendered line wider than the terminal).\n\t\treturn this.frameClamp.clamp(this.lines, width);\n\t}\n\n\tinvalidate(): void { this.markDirty(); }\n\n\tdispose(): void {\n\t\tif (this.disposed) return;\n\t\tthis.disposed = true;\n\t\tthis.unsubscribe();\n\t\tthis.runtime.sendEngineCommand({ type: \"engine_render_dispose\", componentId: this.componentId });\n\t}\n\n\tprotected changed(): void {\n\t\tthis.markDirty();\n\t\tthis.requestRender();\n\t}\n\n\tprotected abstract command(requestId: number, width: number): InteractiveEngineCommand;\n\n\tprivate markDirty(): void { this.dirty = true; }\n}\n\nexport class RemoteToolExecutionComponent extends RemoteRenderer {\n\tprivate readonly toolName: string;\n\tprivate readonly toolCallId: string;\n\tprivate args: unknown;\n\tprivate result: RenderableToolResult | undefined;\n\tprivate executionStarted = false;\n\tprivate argsComplete = false;\n\tprivate isPartial = true;\n\tprivate expanded = false;\n\tprivate showImages: boolean;\n\tprivate imageWidthCells: number;\n\n\tconstructor(\n\t\ttoolName: string,\n\t\ttoolCallId: string,\n\t\targs: unknown,\n\t\toptions: { showImages?: boolean; imageWidthCells?: number },\n\t\truntime: IsolatedInteractiveRuntime,\n\t\trequestRender: () => void,\n\t) {\n\t\tsuper(runtime, requestRender);\n\t\tthis.toolName = toolName;\n\t\tthis.toolCallId = toolCallId;\n\t\tthis.args = args;\n\t\tthis.showImages = options.showImages ?? true;\n\t\tthis.imageWidthCells = options.imageWidthCells ?? 60;\n\t}\n\n\tupdateArgs(args: unknown): void { this.args = args; this.changed(); }\n\tmarkExecutionStarted(): void { this.executionStarted = true; this.changed(); }\n\tsetArgsComplete(): void { this.argsComplete = true; this.changed(); }\n\tupdateResult(result: RenderableToolResult, isPartial = false): void {\n\t\tthis.result = result;\n\t\tthis.isPartial = isPartial;\n\t\tthis.changed();\n\t}\n\tsetExpanded(expanded: boolean): void { this.expanded = expanded; this.changed(); }\n\tsetShowImages(show: boolean): void { this.showImages = show; this.changed(); }\n\tsetImageWidthCells(width: number): void { this.imageWidthCells = Math.max(1, Math.floor(width)); this.changed(); }\n\n\tprotected command(requestId: number, width: number): InteractiveEngineCommand {\n\t\treturn {\n\t\t\ttype: \"engine_tool_render\",\n\t\t\tcomponentId: this.componentId,\n\t\t\trequestId,\n\t\t\twidth,\n\t\t\ttoolName: this.toolName,\n\t\t\ttoolCallId: this.toolCallId,\n\t\t\targs: jsonValue(this.args),\n\t\t\tresult: this.result ? jsonValue(this.result) as JsonObject : undefined,\n\t\t\texecutionStarted: this.executionStarted,\n\t\t\targsComplete: this.argsComplete,\n\t\t\tisPartial: this.isPartial,\n\t\t\texpanded: this.expanded,\n\t\t\tshowImages: this.showImages,\n\t\t\timageWidthCells: this.imageWidthCells,\n\t\t};\n\t}\n}\n\nexport class RemoteCustomMessageComponent extends RemoteRenderer {\n\tprivate readonly message: CustomMessage<unknown>;\n\tprivate expanded = false;\n\tconstructor(\n\t\tmessage: CustomMessage<unknown>,\n\t\truntime: IsolatedInteractiveRuntime,\n\t\trequestRender: () => void,\n\t) {\n\t\tsuper(runtime, requestRender);\n\t\tthis.message = message;\n\t}\n\n\tsetExpanded(expanded: boolean): void { this.expanded = expanded; this.changed(); }\n\n\tprotected command(requestId: number, width: number): InteractiveEngineCommand {\n\t\treturn {\n\t\t\ttype: \"engine_message_render\",\n\t\t\tcomponentId: this.componentId,\n\t\t\trequestId,\n\t\t\twidth,\n\t\t\tmessage: jsonValue(this.message) as JsonObject,\n\t\t\texpanded: this.expanded,\n\t\t};\n\t}\n}\n"]}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { ExtensionUIContext } from "../../core/extensions/index.ts";
|
|
2
|
+
import type { IsolatedInteractiveRuntime } from "./isolated-runtime.ts";
|
|
3
|
+
/**
|
|
4
|
+
* Host-side half of the engine session picker channel.
|
|
5
|
+
*
|
|
6
|
+
* Mounts a REAL `SessionSelectorComponent` in the terminal host when the engine
|
|
7
|
+
* child opens a picker, so arrow-key navigation, search, and repaints are
|
|
8
|
+
* zero-IPC (unlike remote-rendered `ctx.ui.custom` components, which round-trip
|
|
9
|
+
* every keypress). Only semantic events cross the protocol: the child pushes
|
|
10
|
+
* open/update/error/close, the host sends select/cancel/delete. Deletion is
|
|
11
|
+
* child-owned — the host never removes a row locally; it waits for the child's
|
|
12
|
+
* `update` (row removed) or `error` reply.
|
|
13
|
+
*/
|
|
14
|
+
export declare class SessionPickerHostController {
|
|
15
|
+
private readonly mounted;
|
|
16
|
+
private readonly unsubscribe;
|
|
17
|
+
private readonly runtime;
|
|
18
|
+
private readonly ui;
|
|
19
|
+
constructor(runtime: IsolatedInteractiveRuntime, ui: ExtensionUIContext);
|
|
20
|
+
dispose(): void;
|
|
21
|
+
private handleMessage;
|
|
22
|
+
private open;
|
|
23
|
+
private disposeAll;
|
|
24
|
+
}
|
|
25
|
+
//# sourceMappingURL=session-picker-host.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"session-picker-host.d.ts","sourceRoot":"","sources":["../../../src/modes/interactive-engine/session-picker-host.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAwB,MAAM,gCAAgC,CAAC;AAM/F,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,uBAAuB,CAAC;AAGxE;;;;;;;;;;GAUG;AACH,qBAAa,2BAA2B;IACvC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAA6C;IACrE,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAa;IAEzC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAA6B;IACrD,OAAO,CAAC,QAAQ,CAAC,EAAE,CAAqB;IAExC,YAAY,OAAO,EAAE,0BAA0B,EAAE,EAAE,EAAE,kBAAkB,EAItE;IAED,OAAO,IAAI,IAAI,CAGd;IAED,OAAO,CAAC,aAAa;IA2BrB,OAAO,CAAC,IAAI;IAkBZ,OAAO,CAAC,UAAU;CAIlB"}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { mountHostSessionPicker, sessionInfoFromPickerRow, } from "../interactive/components/host-session-picker.js";
|
|
2
|
+
/**
|
|
3
|
+
* Host-side half of the engine session picker channel.
|
|
4
|
+
*
|
|
5
|
+
* Mounts a REAL `SessionSelectorComponent` in the terminal host when the engine
|
|
6
|
+
* child opens a picker, so arrow-key navigation, search, and repaints are
|
|
7
|
+
* zero-IPC (unlike remote-rendered `ctx.ui.custom` components, which round-trip
|
|
8
|
+
* every keypress). Only semantic events cross the protocol: the child pushes
|
|
9
|
+
* open/update/error/close, the host sends select/cancel/delete. Deletion is
|
|
10
|
+
* child-owned — the host never removes a row locally; it waits for the child's
|
|
11
|
+
* `update` (row removed) or `error` reply.
|
|
12
|
+
*/
|
|
13
|
+
export class SessionPickerHostController {
|
|
14
|
+
constructor(runtime, ui) {
|
|
15
|
+
this.mounted = new Map();
|
|
16
|
+
this.runtime = runtime;
|
|
17
|
+
this.ui = ui;
|
|
18
|
+
this.unsubscribe = runtime.onEngineMessage((message) => this.handleMessage(message));
|
|
19
|
+
}
|
|
20
|
+
dispose() {
|
|
21
|
+
this.unsubscribe();
|
|
22
|
+
this.disposeAll();
|
|
23
|
+
}
|
|
24
|
+
handleMessage(message) {
|
|
25
|
+
switch (message.type) {
|
|
26
|
+
case "engine_ready":
|
|
27
|
+
// A fresh engine generation replaced the child: its pickers are gone
|
|
28
|
+
// and the componentIds are meaningless to the new generation, so
|
|
29
|
+
// unmount silently (no cancel command).
|
|
30
|
+
this.disposeAll();
|
|
31
|
+
break;
|
|
32
|
+
case "engine_session_picker_open":
|
|
33
|
+
this.open(message.componentId, message.sessions, message.showRenameHint === true);
|
|
34
|
+
break;
|
|
35
|
+
case "engine_session_picker_update":
|
|
36
|
+
this.mounted.get(message.componentId)?.setRows(message.sessions.map(sessionInfoFromPickerRow));
|
|
37
|
+
break;
|
|
38
|
+
case "engine_session_picker_error":
|
|
39
|
+
this.mounted.get(message.componentId)?.showError(message.message);
|
|
40
|
+
break;
|
|
41
|
+
case "engine_session_picker_close": {
|
|
42
|
+
const mount = this.mounted.get(message.componentId);
|
|
43
|
+
if (!mount)
|
|
44
|
+
break;
|
|
45
|
+
this.mounted.delete(message.componentId);
|
|
46
|
+
mount.close();
|
|
47
|
+
break;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
open(componentId, sessions, showRenameHint) {
|
|
52
|
+
if (this.mounted.has(componentId))
|
|
53
|
+
return;
|
|
54
|
+
const mount = mountHostSessionPicker(this.ui, sessions.map(sessionInfoFromPickerRow), showRenameHint, {
|
|
55
|
+
onSelect: (path) => {
|
|
56
|
+
this.mounted.delete(componentId);
|
|
57
|
+
this.runtime.sendEngineCommand({ type: "engine_session_picker_select", componentId, path });
|
|
58
|
+
},
|
|
59
|
+
onCancel: () => {
|
|
60
|
+
this.mounted.delete(componentId);
|
|
61
|
+
this.runtime.sendEngineCommand({ type: "engine_session_picker_cancel", componentId });
|
|
62
|
+
},
|
|
63
|
+
onDelete: (path) => {
|
|
64
|
+
this.runtime.sendEngineCommand({ type: "engine_session_picker_delete", componentId, path });
|
|
65
|
+
},
|
|
66
|
+
});
|
|
67
|
+
this.mounted.set(componentId, mount);
|
|
68
|
+
}
|
|
69
|
+
disposeAll() {
|
|
70
|
+
for (const mount of this.mounted.values())
|
|
71
|
+
mount.close();
|
|
72
|
+
this.mounted.clear();
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
//# sourceMappingURL=session-picker-host.js.map
|