@bastani/atomic 0.9.9 → 0.9.10
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 +132 -0
- package/README.md +2 -0
- package/dist/builtin/cursor/CHANGELOG.md +12 -0
- package/dist/builtin/cursor/package.json +3 -3
- package/dist/builtin/intercom/CHANGELOG.md +30 -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 +22 -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 +42 -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 +22 -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 +153 -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,278 @@
|
|
|
1
|
+
import { Editor, Input, Key, matchesKey, truncateToWidth, visibleWidth, wrapTextWithAnsi, } from "@earendil-works/pi-tui";
|
|
2
|
+
import { getEditorTheme } from "../theme/theme.js";
|
|
3
|
+
/** Indent (cells) for a field's control, description, and error rows so they align under the field name. */
|
|
4
|
+
const LABEL_INDENT = 2;
|
|
5
|
+
function isEditable(field) {
|
|
6
|
+
return field.type !== "select" && field.type !== "boolean";
|
|
7
|
+
}
|
|
8
|
+
/** Host-owned form: all key handling and mutable editing state stay in the terminal process. */
|
|
9
|
+
export class HostInputFormComponent {
|
|
10
|
+
constructor(tui, theme, keybindings, request, delegate) {
|
|
11
|
+
this.invalid = new Set();
|
|
12
|
+
this._focused = true;
|
|
13
|
+
this.title = request.title;
|
|
14
|
+
this.tui = tui;
|
|
15
|
+
this.theme = theme;
|
|
16
|
+
this.keybindings = keybindings;
|
|
17
|
+
this.delegate = delegate;
|
|
18
|
+
this.fields = request.fields.map((field) => ({ ...field, choices: field.choices ? [...field.choices] : undefined }));
|
|
19
|
+
this.values = this.fields.map((field) => field.initialValue);
|
|
20
|
+
this.editors = this.fields.map((field, index) => {
|
|
21
|
+
if (!isEditable(field))
|
|
22
|
+
return undefined;
|
|
23
|
+
if (field.type === "text") {
|
|
24
|
+
// Quiet the multi-line editor's top/bottom rules to the panel border tone
|
|
25
|
+
// so the inset text area blends with the form frame instead of shouting.
|
|
26
|
+
const editorTheme = { ...getEditorTheme(), borderColor: (segment) => theme.fg("border", segment) };
|
|
27
|
+
const editor = new Editor(tui, editorTheme, { paddingX: 0 });
|
|
28
|
+
editor.setText(field.initialValue);
|
|
29
|
+
editor.onChange = (text) => { this.values[index] = text; };
|
|
30
|
+
editor.disableSubmit = true;
|
|
31
|
+
return editor;
|
|
32
|
+
}
|
|
33
|
+
const input = new Input();
|
|
34
|
+
input.setValue(field.initialValue);
|
|
35
|
+
Reflect.set(input, "cursor", field.initialValue.length);
|
|
36
|
+
input.onSubmit = () => this.moveFocus(1);
|
|
37
|
+
input.onEscape = () => this.delegate.onCancel();
|
|
38
|
+
return input;
|
|
39
|
+
});
|
|
40
|
+
const firstInvalid = this.fields.findIndex((field, index) => this.invalidReason(field, this.values[index]) !== undefined);
|
|
41
|
+
this.focusedIndex = firstInvalid >= 0 ? firstInvalid : 0;
|
|
42
|
+
this.syncFocus();
|
|
43
|
+
}
|
|
44
|
+
get focused() { return this._focused; }
|
|
45
|
+
set focused(value) { this._focused = value; this.syncFocus(); }
|
|
46
|
+
handleInput(data) {
|
|
47
|
+
if (matchesKey(data, Key.escape) ||
|
|
48
|
+
matchesKey(data, Key.ctrl("c")) ||
|
|
49
|
+
this.keybindings.matches(data, "tui.select.cancel")) {
|
|
50
|
+
this.delegate.onCancel();
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
53
|
+
if (matchesKey(data, Key.shift("tab"))) {
|
|
54
|
+
this.moveFocus(-1);
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
if (matchesKey(data, Key.tab) || this.keybindings.matches(data, "tui.input.tab")) {
|
|
58
|
+
this.moveFocus(1);
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
61
|
+
if (this.focusedIndex === this.fields.length) {
|
|
62
|
+
this.handleSubmitRow(data);
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
65
|
+
const field = this.fields[this.focusedIndex];
|
|
66
|
+
if (!field)
|
|
67
|
+
return;
|
|
68
|
+
if (field.type === "select")
|
|
69
|
+
this.handleSelect(data, field);
|
|
70
|
+
else if (field.type === "boolean")
|
|
71
|
+
this.handleBoolean(data);
|
|
72
|
+
else
|
|
73
|
+
this.handleEditable(data, field);
|
|
74
|
+
this.tui.requestRender();
|
|
75
|
+
}
|
|
76
|
+
render(width) {
|
|
77
|
+
const boxWidth = Math.max(1, width);
|
|
78
|
+
const inner = Math.max(2, boxWidth - 2);
|
|
79
|
+
const cw = Math.max(8, inner - 2);
|
|
80
|
+
const controlWidth = Math.max(1, cw - LABEL_INDENT);
|
|
81
|
+
const indent = " ".repeat(LABEL_INDENT);
|
|
82
|
+
const body = [];
|
|
83
|
+
const fieldCount = `${this.fields.length} ${this.fields.length === 1 ? "field" : "fields"}`;
|
|
84
|
+
const nameBudget = Math.max(4, cw - fieldCount.length - 5);
|
|
85
|
+
body.push(this.theme.bold(this.theme.fg("text", truncateToWidth(this.title, nameBudget, "…"))) +
|
|
86
|
+
this.theme.fg("dim", ` · ${fieldCount}`));
|
|
87
|
+
body.push("");
|
|
88
|
+
for (let index = 0; index < this.fields.length; index += 1) {
|
|
89
|
+
const field = this.fields[index];
|
|
90
|
+
const active = index === this.focusedIndex;
|
|
91
|
+
body.push(this.labelRow(field, active, cw));
|
|
92
|
+
for (const line of this.renderField(field, index, controlWidth))
|
|
93
|
+
body.push(`${indent}${line}`);
|
|
94
|
+
if (field.description) {
|
|
95
|
+
for (const line of wrapTextWithAnsi(this.theme.fg("muted", field.description), Math.max(1, cw - LABEL_INDENT))) {
|
|
96
|
+
body.push(`${indent}${line}`);
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
if (this.invalid.has(index)) {
|
|
100
|
+
body.push(`${indent}${this.theme.fg("error", `✗ ${this.invalidReason(field, this.currentValue(index)) ?? "invalid"}`)}`);
|
|
101
|
+
}
|
|
102
|
+
body.push("");
|
|
103
|
+
}
|
|
104
|
+
body.push(this.submitRow());
|
|
105
|
+
body.push("");
|
|
106
|
+
body.push(this.footerRow());
|
|
107
|
+
return this.frame(body, inner, cw);
|
|
108
|
+
}
|
|
109
|
+
invalidate() { for (const editor of this.editors)
|
|
110
|
+
editor?.invalidate(); }
|
|
111
|
+
renderField(field, index, width) {
|
|
112
|
+
if (field.type === "select") {
|
|
113
|
+
const current = this.values[index];
|
|
114
|
+
return (field.choices ?? []).map((choice) => `${choice === current ? this.theme.fg("accent", "●") : this.theme.fg("dim", "○")} ${choice}`);
|
|
115
|
+
}
|
|
116
|
+
if (field.type === "boolean") {
|
|
117
|
+
return [this.values[index] === "true" ? this.theme.fg("accent", "● on") : "○ on", this.values[index] === "false" ? this.theme.fg("accent", "● off") : "○ off"];
|
|
118
|
+
}
|
|
119
|
+
const editor = this.editors[index];
|
|
120
|
+
if (!editor)
|
|
121
|
+
return [""];
|
|
122
|
+
const rendered = editor.render(width);
|
|
123
|
+
if (this.currentValue(index) === "" && field.placeholder && this.focusedIndex !== index)
|
|
124
|
+
return [this.theme.fg("dim", field.placeholder)];
|
|
125
|
+
return rendered.length > 0 ? rendered : [""];
|
|
126
|
+
}
|
|
127
|
+
handleEditable(data, field) {
|
|
128
|
+
const fieldIndex = this.focusedIndex;
|
|
129
|
+
const editor = this.editors[fieldIndex];
|
|
130
|
+
if (!editor)
|
|
131
|
+
return;
|
|
132
|
+
const verticalDirection = this.keybindings.matches(data, "tui.editor.cursorUp")
|
|
133
|
+
? -1
|
|
134
|
+
: this.keybindings.matches(data, "tui.editor.cursorDown")
|
|
135
|
+
? 1
|
|
136
|
+
: 0;
|
|
137
|
+
if (verticalDirection !== 0) {
|
|
138
|
+
if (field.type !== "text" || !(editor instanceof Editor)) {
|
|
139
|
+
this.moveFocus(verticalDirection);
|
|
140
|
+
return;
|
|
141
|
+
}
|
|
142
|
+
const before = editor.getCursor();
|
|
143
|
+
editor.handleInput(data);
|
|
144
|
+
const after = editor.getCursor();
|
|
145
|
+
if (after.line === before.line && after.col === before.col)
|
|
146
|
+
this.moveFocus(verticalDirection);
|
|
147
|
+
return;
|
|
148
|
+
}
|
|
149
|
+
const continues = this.keybindings.matches(data, "tui.input.submit") ||
|
|
150
|
+
this.keybindings.matches(data, "tui.input.newLine");
|
|
151
|
+
if (continues) {
|
|
152
|
+
if (field.type === "text" && editor instanceof Editor) {
|
|
153
|
+
editor.insertTextAtCursor("\n");
|
|
154
|
+
this.values[fieldIndex] = editor.getExpandedText();
|
|
155
|
+
}
|
|
156
|
+
else {
|
|
157
|
+
this.moveFocus(1);
|
|
158
|
+
}
|
|
159
|
+
return;
|
|
160
|
+
}
|
|
161
|
+
editor.handleInput(data);
|
|
162
|
+
this.values[fieldIndex] = editor instanceof Input ? editor.getValue() : editor.getExpandedText();
|
|
163
|
+
}
|
|
164
|
+
handleSelect(data, field) {
|
|
165
|
+
const choices = field.choices ?? [];
|
|
166
|
+
if (choices.length === 0)
|
|
167
|
+
return;
|
|
168
|
+
const current = Math.max(0, choices.indexOf(this.currentValue(this.focusedIndex)));
|
|
169
|
+
if (this.keybindings.matches(data, "tui.select.up") || this.keybindings.matches(data, "tui.editor.cursorLeft"))
|
|
170
|
+
this.values[this.focusedIndex] = choices[(current - 1 + choices.length) % choices.length];
|
|
171
|
+
else if (this.keybindings.matches(data, "tui.select.down") || this.keybindings.matches(data, "tui.editor.cursorRight") || matchesKey(data, Key.space))
|
|
172
|
+
this.values[this.focusedIndex] = choices[(current + 1) % choices.length];
|
|
173
|
+
else if (this.keybindings.matches(data, "tui.select.confirm") || this.keybindings.matches(data, "tui.input.submit"))
|
|
174
|
+
this.moveFocus(1);
|
|
175
|
+
}
|
|
176
|
+
handleBoolean(data) {
|
|
177
|
+
if (matchesKey(data, Key.space) || this.keybindings.matches(data, "tui.select.up") || this.keybindings.matches(data, "tui.select.down") || this.keybindings.matches(data, "tui.editor.cursorLeft") || this.keybindings.matches(data, "tui.editor.cursorRight"))
|
|
178
|
+
this.values[this.focusedIndex] = this.currentValue(this.focusedIndex) === "true" ? "false" : "true";
|
|
179
|
+
else if (this.keybindings.matches(data, "tui.select.confirm") || this.keybindings.matches(data, "tui.input.submit"))
|
|
180
|
+
this.moveFocus(1);
|
|
181
|
+
}
|
|
182
|
+
handleSubmitRow(data) {
|
|
183
|
+
if (this.keybindings.matches(data, "tui.select.up") || this.keybindings.matches(data, "tui.editor.cursorUp")) {
|
|
184
|
+
this.moveFocus(-1);
|
|
185
|
+
return;
|
|
186
|
+
}
|
|
187
|
+
if (this.keybindings.matches(data, "tui.select.down") || this.keybindings.matches(data, "tui.editor.cursorDown")) {
|
|
188
|
+
this.moveFocus(1);
|
|
189
|
+
return;
|
|
190
|
+
}
|
|
191
|
+
if (matchesKey(data, Key.enter) || this.keybindings.matches(data, "tui.select.confirm") || this.keybindings.matches(data, "tui.input.submit"))
|
|
192
|
+
this.submit();
|
|
193
|
+
}
|
|
194
|
+
submit() {
|
|
195
|
+
this.invalid = new Set();
|
|
196
|
+
for (let index = 0; index < this.fields.length; index += 1)
|
|
197
|
+
if (this.invalidReason(this.fields[index], this.currentValue(index)))
|
|
198
|
+
this.invalid.add(index);
|
|
199
|
+
if (this.invalid.size > 0) {
|
|
200
|
+
this.focusedIndex = this.invalid.values().next().value ?? 0;
|
|
201
|
+
this.syncFocus();
|
|
202
|
+
this.tui.requestRender();
|
|
203
|
+
return;
|
|
204
|
+
}
|
|
205
|
+
const values = Object.fromEntries(this.fields.map((field, index) => [field.name, this.currentValue(index)]));
|
|
206
|
+
this.delegate.onSubmit(values);
|
|
207
|
+
}
|
|
208
|
+
invalidReason(field, value) {
|
|
209
|
+
if (field.required && value.trim() === "")
|
|
210
|
+
return "required";
|
|
211
|
+
if (field.type === "select" && value !== "" && !(field.choices ?? []).includes(value))
|
|
212
|
+
return "not in choices";
|
|
213
|
+
if ((field.type === "number" || field.type === "integer") && value !== "" && !Number.isFinite(Number(value)))
|
|
214
|
+
return "must be a number";
|
|
215
|
+
return undefined;
|
|
216
|
+
}
|
|
217
|
+
moveFocus(delta) {
|
|
218
|
+
const count = this.fields.length + 1;
|
|
219
|
+
if (count <= 1)
|
|
220
|
+
return;
|
|
221
|
+
this.focusedIndex = (this.focusedIndex + delta + count) % count;
|
|
222
|
+
this.syncFocus();
|
|
223
|
+
this.tui.requestRender();
|
|
224
|
+
}
|
|
225
|
+
syncFocus() { this.editors.forEach((editor, index) => { if (editor)
|
|
226
|
+
editor.focused = this._focused && index === this.focusedIndex; }); }
|
|
227
|
+
currentValue(index) { const editor = this.editors[index]; return editor instanceof Input ? editor.getValue() : editor instanceof Editor ? editor.getExpandedText() : this.values[index] ?? ""; }
|
|
228
|
+
/** Field header: focus chevron + name (accent when active) with a right-aligned required/optional badge. */
|
|
229
|
+
labelRow(field, active, cw) {
|
|
230
|
+
const badgePlain = field.required ? "required" : "optional";
|
|
231
|
+
const marker = active ? this.theme.fg("accent", "▸") : " ";
|
|
232
|
+
const nameBudget = Math.max(4, cw - badgePlain.length - 3);
|
|
233
|
+
const nameShown = truncateToWidth(field.name, nameBudget, "…");
|
|
234
|
+
const nameStyled = active
|
|
235
|
+
? this.theme.fg("accent", this.theme.bold(nameShown))
|
|
236
|
+
: this.theme.fg("text", nameShown);
|
|
237
|
+
const badge = field.required
|
|
238
|
+
? this.theme.fg("warning", badgePlain)
|
|
239
|
+
: this.theme.fg("dim", badgePlain);
|
|
240
|
+
const gap = Math.max(1, cw - 2 - visibleWidth(nameShown) - badgePlain.length);
|
|
241
|
+
return `${marker} ${nameStyled}${" ".repeat(gap)}${badge}`;
|
|
242
|
+
}
|
|
243
|
+
/** Submit control rendered as a button pill; filled accent when focused, quiet outline otherwise. */
|
|
244
|
+
submitRow() {
|
|
245
|
+
const active = this.focusedIndex === this.fields.length;
|
|
246
|
+
const marker = active ? this.theme.fg("accent", "▸") : " ";
|
|
247
|
+
const pill = active
|
|
248
|
+
? this.theme.bg("selectedBg", this.theme.bold(this.theme.fg("accent", "[ Run workflow ]")))
|
|
249
|
+
: this.theme.fg("dim", "[ Run workflow ]");
|
|
250
|
+
return `${marker} ${pill}`;
|
|
251
|
+
}
|
|
252
|
+
/** Key-hint footer with accent key chips and muted verbs. */
|
|
253
|
+
footerRow() {
|
|
254
|
+
const key = (k) => this.theme.fg("accent", k);
|
|
255
|
+
const dim = (t) => this.theme.fg("dim", t);
|
|
256
|
+
const sep = dim(" · ");
|
|
257
|
+
return `${key("Tab")} ${dim("move")}${sep}${key("Enter")} ${dim("continue / run")}${sep}${key("Esc")} ${dim("cancel")}`;
|
|
258
|
+
}
|
|
259
|
+
/**
|
|
260
|
+
* Wrap the pre-built body rows in a rounded panel. The title rides the top
|
|
261
|
+
* border; each row gets one cell of interior padding on both sides. Rows are
|
|
262
|
+
* padded (not truncated) unless they overflow, so an embedded editor's inline
|
|
263
|
+
* cursor marker is never clipped away.
|
|
264
|
+
*/
|
|
265
|
+
frame(body, inner, cw) {
|
|
266
|
+
const border = (glyph) => this.theme.fg("border", glyph);
|
|
267
|
+
const title = ` ${this.theme.fg("accent", this.theme.bold("WORKFLOW INPUTS"))} `;
|
|
268
|
+
const top = `${border("╭")}${title}${border("─".repeat(Math.max(0, inner - visibleWidth(title))))}${border("╮")}`;
|
|
269
|
+
const rows = body.map((line) => {
|
|
270
|
+
const clipped = visibleWidth(line) > cw ? truncateToWidth(line, cw, "…") : line;
|
|
271
|
+
const pad = " ".repeat(Math.max(0, cw - visibleWidth(clipped)));
|
|
272
|
+
return `${border("│")} ${clipped}${pad} ${border("│")}`;
|
|
273
|
+
});
|
|
274
|
+
const bottom = `${border("╰")}${border("─".repeat(inner))}${border("╯")}`;
|
|
275
|
+
return [top, ...rows, bottom];
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
//# sourceMappingURL=host-input-form.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"host-input-form.js","sourceRoot":"","sources":["../../../../src/modes/interactive/components/host-input-form.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,MAAM,EACN,KAAK,EACL,GAAG,EACH,UAAU,EACV,eAAe,EACf,YAAY,EACZ,gBAAgB,GAIhB,MAAM,wBAAwB,CAAC;AAOhC,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAEnD,4GAA4G;AAC5G,MAAM,YAAY,GAAG,CAAC,CAAC;AASvB,SAAS,UAAU,CAAC,KAAyB;IAC5C,OAAO,KAAK,CAAC,IAAI,KAAK,QAAQ,IAAI,KAAK,CAAC,IAAI,KAAK,SAAS,CAAC;AAC5D,CAAC;AAED,gGAAgG;AAChG,MAAM,OAAO,sBAAsB;IAalC,YACC,GAAQ,EACR,KAAY,EACZ,WAA+B,EAC/B,OAA6B,EAC7B,QAA+B;QARxB,YAAO,GAAG,IAAI,GAAG,EAAU,CAAC;QAC5B,aAAQ,GAAG,IAAI,CAAC;QASvB,IAAI,CAAC,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC;QAC3B,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC;QACf,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;QACnB,IAAI,CAAC,WAAW,GAAG,WAAW,CAAC;QAC/B,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;QACzB,IAAI,CAAC,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC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,EAAE,EAAE;YAC9B,MAAM,OAAO,GAAG,YAAY,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC,eAAe,CAAC,IAAI,EAAE,EAAE,EAAE,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;YAChF,MAAM,GAAG,GAAG,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,EAAE,GAAG,YAAY,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;YAChE,OAAO,GAAG,MAAM,CAAC,GAAG,CAAC,IAAI,OAAO,GAAG,GAAG,IAAI,MAAM,CAAC,GAAG,CAAC,EAAE,CAAC;QACzD,CAAC,CAAC,CAAC;QACH,MAAM,MAAM,GAAG,GAAG,MAAM,CAAC,GAAG,CAAC,GAAG,MAAM,CAAC,GAAG,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,GAAG,MAAM,CAAC,GAAG,CAAC,EAAE,CAAC;QAC1E,OAAO,CAAC,GAAG,EAAE,GAAG,IAAI,EAAE,MAAM,CAAC,CAAC;IAC/B,CAAC;CACD","sourcesContent":["import {\n\tEditor,\n\tInput,\n\tKey,\n\tmatchesKey,\n\ttruncateToWidth,\n\tvisibleWidth,\n\twrapTextWithAnsi,\n\ttype Component,\n\ttype Focusable,\n\ttype TUI,\n} from \"@earendil-works/pi-tui\";\nimport type {\n\tHostInputFormField,\n\tHostInputFormRequest,\n} from \"../../../core/extensions/ui-types.ts\";\nimport type { KeybindingsManager } from \"../../../core/keybindings.ts\";\nimport type { Theme } from \"../theme/theme.ts\";\nimport { getEditorTheme } from \"../theme/theme.ts\";\n\n/** Indent (cells) for a field's control, description, and error rows so they align under the field name. */\nconst LABEL_INDENT = 2;\n\nexport interface HostInputFormDelegate {\n\tonSubmit(values: Record<string, string>): void;\n\tonCancel(): void;\n}\n\ntype Editable = Input | Editor;\n\nfunction isEditable(field: HostInputFormField): boolean {\n\treturn field.type !== \"select\" && field.type !== \"boolean\";\n}\n\n/** Host-owned form: all key handling and mutable editing state stay in the terminal process. */\nexport class HostInputFormComponent implements Component, Focusable {\n\tprivate readonly title: string;\n\tprivate readonly fields: HostInputFormField[];\n\tprivate readonly values: string[];\n\tprivate readonly editors: Array<Editable | undefined>;\n\tprivate readonly keybindings: KeybindingsManager;\n\tprivate readonly theme: Theme;\n\tprivate readonly tui: TUI;\n\tprivate readonly delegate: HostInputFormDelegate;\n\tprivate focusedIndex: number;\n\tprivate invalid = new Set<number>();\n\tprivate _focused = true;\n\n\tconstructor(\n\t\ttui: TUI,\n\t\ttheme: Theme,\n\t\tkeybindings: KeybindingsManager,\n\t\trequest: HostInputFormRequest,\n\t\tdelegate: HostInputFormDelegate,\n\t) {\n\t\tthis.title = request.title;\n\t\tthis.tui = tui;\n\t\tthis.theme = theme;\n\t\tthis.keybindings = keybindings;\n\t\tthis.delegate = delegate;\n\t\tthis.fields = request.fields.map((field) => ({ ...field, choices: field.choices ? [...field.choices] : undefined }));\n\t\tthis.values = this.fields.map((field) => field.initialValue);\n\t\tthis.editors = this.fields.map((field, index) => {\n\t\t\tif (!isEditable(field)) return undefined;\n\t\t\tif (field.type === \"text\") {\n\t\t\t\t// Quiet the multi-line editor's top/bottom rules to the panel border tone\n\t\t\t\t// so the inset text area blends with the form frame instead of shouting.\n\t\t\t\tconst editorTheme = { ...getEditorTheme(), borderColor: (segment: string) => theme.fg(\"border\", segment) };\n\t\t\t\tconst editor = new Editor(tui, editorTheme, { paddingX: 0 });\n\t\t\t\teditor.setText(field.initialValue);\n\t\t\t\teditor.onChange = (text) => { this.values[index] = text; };\n\t\t\t\teditor.disableSubmit = true;\n\t\t\t\treturn editor;\n\t\t\t}\n\t\t\tconst input = new Input();\n\t\t\tinput.setValue(field.initialValue);\n\t\t\tReflect.set(input, \"cursor\", field.initialValue.length);\n\t\t\tinput.onSubmit = () => this.moveFocus(1);\n\t\t\tinput.onEscape = () => this.delegate.onCancel();\n\t\t\treturn input;\n\t\t});\n\t\tconst firstInvalid = this.fields.findIndex((field, index) => this.invalidReason(field, this.values[index]!) !== undefined);\n\t\tthis.focusedIndex = firstInvalid >= 0 ? firstInvalid : 0;\n\t\tthis.syncFocus();\n\t}\n\n\tget focused(): boolean { return this._focused; }\n\tset focused(value: boolean) { this._focused = value; this.syncFocus(); }\n\n\thandleInput(data: string): void {\n\t\tif (\n\t\t\tmatchesKey(data, Key.escape) ||\n\t\t\tmatchesKey(data, Key.ctrl(\"c\")) ||\n\t\t\tthis.keybindings.matches(data, \"tui.select.cancel\")\n\t\t) {\n\t\t\tthis.delegate.onCancel();\n\t\t\treturn;\n\t\t}\n\t\tif (matchesKey(data, Key.shift(\"tab\"))) { this.moveFocus(-1); return; }\n\t\tif (matchesKey(data, Key.tab) || this.keybindings.matches(data, \"tui.input.tab\")) { this.moveFocus(1); return; }\n\t\tif (this.focusedIndex === this.fields.length) { this.handleSubmitRow(data); return; }\n\t\tconst field = this.fields[this.focusedIndex];\n\t\tif (!field) return;\n\t\tif (field.type === \"select\") this.handleSelect(data, field);\n\t\telse if (field.type === \"boolean\") this.handleBoolean(data);\n\t\telse this.handleEditable(data, field);\n\t\tthis.tui.requestRender();\n\t}\n\n\trender(width: number): string[] {\n\t\tconst boxWidth = Math.max(1, width);\n\t\tconst inner = Math.max(2, boxWidth - 2);\n\t\tconst cw = Math.max(8, inner - 2);\n\t\tconst controlWidth = Math.max(1, cw - LABEL_INDENT);\n\t\tconst indent = \" \".repeat(LABEL_INDENT);\n\t\tconst body: string[] = [];\n\n\t\tconst fieldCount = `${this.fields.length} ${this.fields.length === 1 ? \"field\" : \"fields\"}`;\n\t\tconst nameBudget = Math.max(4, cw - fieldCount.length - 5);\n\t\tbody.push(\n\t\t\tthis.theme.bold(this.theme.fg(\"text\", truncateToWidth(this.title, nameBudget, \"…\"))) +\n\t\t\t\tthis.theme.fg(\"dim\", ` · ${fieldCount}`),\n\t\t);\n\t\tbody.push(\"\");\n\n\t\tfor (let index = 0; index < this.fields.length; index += 1) {\n\t\t\tconst field = this.fields[index]!;\n\t\t\tconst active = index === this.focusedIndex;\n\t\t\tbody.push(this.labelRow(field, active, cw));\n\t\t\tfor (const line of this.renderField(field, index, controlWidth)) body.push(`${indent}${line}`);\n\t\t\tif (field.description) {\n\t\t\t\tfor (const line of wrapTextWithAnsi(this.theme.fg(\"muted\", field.description), Math.max(1, cw - LABEL_INDENT))) {\n\t\t\t\t\tbody.push(`${indent}${line}`);\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (this.invalid.has(index)) {\n\t\t\t\tbody.push(`${indent}${this.theme.fg(\"error\", `✗ ${this.invalidReason(field, this.currentValue(index)) ?? \"invalid\"}`)}`);\n\t\t\t}\n\t\t\tbody.push(\"\");\n\t\t}\n\n\t\tbody.push(this.submitRow());\n\t\tbody.push(\"\");\n\t\tbody.push(this.footerRow());\n\n\t\treturn this.frame(body, inner, cw);\n\t}\n\n\tinvalidate(): void { for (const editor of this.editors) editor?.invalidate(); }\n\n\tprivate renderField(field: HostInputFormField, index: number, width: number): string[] {\n\t\tif (field.type === \"select\") {\n\t\t\tconst current = this.values[index];\n\t\t\treturn (field.choices ?? []).map((choice) => `${choice === current ? this.theme.fg(\"accent\", \"●\") : this.theme.fg(\"dim\", \"○\")} ${choice}`);\n\t\t}\n\t\tif (field.type === \"boolean\") {\n\t\t\treturn [this.values[index] === \"true\" ? this.theme.fg(\"accent\", \"● on\") : \"○ on\", this.values[index] === \"false\" ? this.theme.fg(\"accent\", \"● off\") : \"○ off\"];\n\t\t}\n\t\tconst editor = this.editors[index];\n\t\tif (!editor) return [\"\"];\n\t\tconst rendered = editor.render(width);\n\t\tif (this.currentValue(index) === \"\" && field.placeholder && this.focusedIndex !== index) return [this.theme.fg(\"dim\", field.placeholder)];\n\t\treturn rendered.length > 0 ? rendered : [\"\"];\n\t}\n\n\tprivate handleEditable(data: string, field: HostInputFormField): void {\n\t\tconst fieldIndex = this.focusedIndex;\n\t\tconst editor = this.editors[fieldIndex];\n\t\tif (!editor) return;\n\t\tconst verticalDirection = this.keybindings.matches(data, \"tui.editor.cursorUp\")\n\t\t\t? -1\n\t\t\t: this.keybindings.matches(data, \"tui.editor.cursorDown\")\n\t\t\t\t? 1\n\t\t\t\t: 0;\n\t\tif (verticalDirection !== 0) {\n\t\t\tif (field.type !== \"text\" || !(editor instanceof Editor)) {\n\t\t\t\tthis.moveFocus(verticalDirection);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tconst before = editor.getCursor();\n\t\t\teditor.handleInput(data);\n\t\t\tconst after = editor.getCursor();\n\t\t\tif (after.line === before.line && after.col === before.col) this.moveFocus(verticalDirection);\n\t\t\treturn;\n\t\t}\n\t\tconst continues = this.keybindings.matches(data, \"tui.input.submit\") ||\n\t\t\tthis.keybindings.matches(data, \"tui.input.newLine\");\n\t\tif (continues) {\n\t\t\tif (field.type === \"text\" && editor instanceof Editor) {\n\t\t\t\teditor.insertTextAtCursor(\"\\n\");\n\t\t\t\tthis.values[fieldIndex] = editor.getExpandedText();\n\t\t\t} else {\n\t\t\t\tthis.moveFocus(1);\n\t\t\t}\n\t\t\treturn;\n\t\t}\n\t\teditor.handleInput(data);\n\t\tthis.values[fieldIndex] = editor instanceof Input ? editor.getValue() : editor.getExpandedText();\n\t}\n\n\tprivate handleSelect(data: string, field: HostInputFormField): void {\n\t\tconst choices = field.choices ?? [];\n\t\tif (choices.length === 0) return;\n\t\tconst current = Math.max(0, choices.indexOf(this.currentValue(this.focusedIndex)));\n\t\tif (this.keybindings.matches(data, \"tui.select.up\") || this.keybindings.matches(data, \"tui.editor.cursorLeft\")) this.values[this.focusedIndex] = choices[(current - 1 + choices.length) % choices.length]!;\n\t\telse if (this.keybindings.matches(data, \"tui.select.down\") || this.keybindings.matches(data, \"tui.editor.cursorRight\") || matchesKey(data, Key.space)) this.values[this.focusedIndex] = choices[(current + 1) % choices.length]!;\n\t\telse if (this.keybindings.matches(data, \"tui.select.confirm\") || this.keybindings.matches(data, \"tui.input.submit\")) this.moveFocus(1);\n\t}\n\n\tprivate handleBoolean(data: string): void {\n\t\tif (matchesKey(data, Key.space) || this.keybindings.matches(data, \"tui.select.up\") || this.keybindings.matches(data, \"tui.select.down\") || this.keybindings.matches(data, \"tui.editor.cursorLeft\") || this.keybindings.matches(data, \"tui.editor.cursorRight\")) this.values[this.focusedIndex] = this.currentValue(this.focusedIndex) === \"true\" ? \"false\" : \"true\";\n\t\telse if (this.keybindings.matches(data, \"tui.select.confirm\") || this.keybindings.matches(data, \"tui.input.submit\")) this.moveFocus(1);\n\t}\n\n\tprivate handleSubmitRow(data: string): void {\n\t\tif (this.keybindings.matches(data, \"tui.select.up\") || this.keybindings.matches(data, \"tui.editor.cursorUp\")) { this.moveFocus(-1); return; }\n\t\tif (this.keybindings.matches(data, \"tui.select.down\") || this.keybindings.matches(data, \"tui.editor.cursorDown\")) { this.moveFocus(1); return; }\n\t\tif (matchesKey(data, Key.enter) || this.keybindings.matches(data, \"tui.select.confirm\") || this.keybindings.matches(data, \"tui.input.submit\")) this.submit();\n\t}\n\n\tprivate submit(): void {\n\t\tthis.invalid = new Set<number>();\n\t\tfor (let index = 0; index < this.fields.length; index += 1) if (this.invalidReason(this.fields[index]!, this.currentValue(index))) this.invalid.add(index);\n\t\tif (this.invalid.size > 0) { this.focusedIndex = this.invalid.values().next().value ?? 0; this.syncFocus(); this.tui.requestRender(); return; }\n\t\tconst values: Record<string, string> = Object.fromEntries(\n\t\t\tthis.fields.map((field, index) => [field.name, this.currentValue(index)]),\n\t\t);\n\t\tthis.delegate.onSubmit(values);\n\t}\n\n\tprivate invalidReason(field: HostInputFormField, value: string): string | undefined {\n\t\tif (field.required && value.trim() === \"\") return \"required\";\n\t\tif (field.type === \"select\" && value !== \"\" && !(field.choices ?? []).includes(value)) return \"not in choices\";\n\t\tif ((field.type === \"number\" || field.type === \"integer\") && value !== \"\" && !Number.isFinite(Number(value))) return \"must be a number\";\n\t\treturn undefined;\n\t}\n\n\tprivate moveFocus(delta: number): void {\n\t\tconst count = this.fields.length + 1;\n\t\tif (count <= 1) return;\n\t\tthis.focusedIndex = (this.focusedIndex + delta + count) % count;\n\t\tthis.syncFocus();\n\t\tthis.tui.requestRender();\n\t}\n\tprivate syncFocus(): void { this.editors.forEach((editor, index) => { if (editor) editor.focused = this._focused && index === this.focusedIndex; }); }\n\tprivate currentValue(index: number): string { const editor = this.editors[index]; return editor instanceof Input ? editor.getValue() : editor instanceof Editor ? editor.getExpandedText() : this.values[index] ?? \"\"; }\n\t/** Field header: focus chevron + name (accent when active) with a right-aligned required/optional badge. */\n\tprivate labelRow(field: HostInputFormField, active: boolean, cw: number): string {\n\t\tconst badgePlain = field.required ? \"required\" : \"optional\";\n\t\tconst marker = active ? this.theme.fg(\"accent\", \"▸\") : \" \";\n\t\tconst nameBudget = Math.max(4, cw - badgePlain.length - 3);\n\t\tconst nameShown = truncateToWidth(field.name, nameBudget, \"…\");\n\t\tconst nameStyled = active\n\t\t\t? this.theme.fg(\"accent\", this.theme.bold(nameShown))\n\t\t\t: this.theme.fg(\"text\", nameShown);\n\t\tconst badge = field.required\n\t\t\t? this.theme.fg(\"warning\", badgePlain)\n\t\t\t: this.theme.fg(\"dim\", badgePlain);\n\t\tconst gap = Math.max(1, cw - 2 - visibleWidth(nameShown) - badgePlain.length);\n\t\treturn `${marker} ${nameStyled}${\" \".repeat(gap)}${badge}`;\n\t}\n\n\t/** Submit control rendered as a button pill; filled accent when focused, quiet outline otherwise. */\n\tprivate submitRow(): string {\n\t\tconst active = this.focusedIndex === this.fields.length;\n\t\tconst marker = active ? this.theme.fg(\"accent\", \"▸\") : \" \";\n\t\tconst pill = active\n\t\t\t? this.theme.bg(\"selectedBg\", this.theme.bold(this.theme.fg(\"accent\", \"[ Run workflow ]\")))\n\t\t\t: this.theme.fg(\"dim\", \"[ Run workflow ]\");\n\t\treturn `${marker} ${pill}`;\n\t}\n\n\t/** Key-hint footer with accent key chips and muted verbs. */\n\tprivate footerRow(): string {\n\t\tconst key = (k: string): string => this.theme.fg(\"accent\", k);\n\t\tconst dim = (t: string): string => this.theme.fg(\"dim\", t);\n\t\tconst sep = dim(\" · \");\n\t\treturn `${key(\"Tab\")} ${dim(\"move\")}${sep}${key(\"Enter\")} ${dim(\"continue / run\")}${sep}${key(\"Esc\")} ${dim(\"cancel\")}`;\n\t}\n\n\t/**\n\t * Wrap the pre-built body rows in a rounded panel. The title rides the top\n\t * border; each row gets one cell of interior padding on both sides. Rows are\n\t * padded (not truncated) unless they overflow, so an embedded editor's inline\n\t * cursor marker is never clipped away.\n\t */\n\tprivate frame(body: readonly string[], inner: number, cw: number): string[] {\n\t\tconst border = (glyph: string): string => this.theme.fg(\"border\", glyph);\n\t\tconst title = ` ${this.theme.fg(\"accent\", this.theme.bold(\"WORKFLOW INPUTS\"))} `;\n\t\tconst top = `${border(\"╭\")}${title}${border(\"─\".repeat(Math.max(0, inner - visibleWidth(title))))}${border(\"╮\")}`;\n\t\tconst rows = body.map((line) => {\n\t\t\tconst clipped = visibleWidth(line) > cw ? truncateToWidth(line, cw, \"…\") : line;\n\t\t\tconst pad = \" \".repeat(Math.max(0, cw - visibleWidth(clipped)));\n\t\t\treturn `${border(\"│\")} ${clipped}${pad} ${border(\"│\")}`;\n\t\t});\n\t\tconst bottom = `${border(\"╰\")}${border(\"─\".repeat(inner))}${border(\"╯\")}`;\n\t\treturn [top, ...rows, bottom];\n\t}\n}\n"]}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import type { ExtensionUIContext, HostSessionPickerHandle, HostSessionPickerRequest, HostSessionPickerRow } from "../../../core/extensions/ui-types.ts";
|
|
2
|
+
import type { SessionInfo } from "../../../core/session-manager.ts";
|
|
3
|
+
/** The subset of the host UI surface the picker mount needs. */
|
|
4
|
+
export type HostSessionPickerUi = Pick<ExtensionUIContext, "custom" | "requestRender">;
|
|
5
|
+
/** Deserialize a JSON-safe picker row back into a selector `SessionInfo`. */
|
|
6
|
+
export declare function sessionInfoFromPickerRow(row: HostSessionPickerRow): SessionInfo;
|
|
7
|
+
/**
|
|
8
|
+
* Owner callbacks for a mounted host session picker. `onSelect`/`onCancel`
|
|
9
|
+
* settle the mount (at most one of them fires, exactly once); `onDelete` may
|
|
10
|
+
* fire many times and never mutates rows — the owner replies through
|
|
11
|
+
* `setRows`/`showError`.
|
|
12
|
+
*/
|
|
13
|
+
export interface HostSessionPickerMountDelegate {
|
|
14
|
+
onSelect(path: string): void;
|
|
15
|
+
onCancel(): void;
|
|
16
|
+
onDelete(path: string): void;
|
|
17
|
+
}
|
|
18
|
+
/** Owner-side control surface for a mounted host session picker. */
|
|
19
|
+
export interface HostSessionPickerMount {
|
|
20
|
+
/** Replace the rows; selection/search state is preserved by the selector. */
|
|
21
|
+
setRows(rows: SessionInfo[]): void;
|
|
22
|
+
/** Surface a transient error in the picker header. */
|
|
23
|
+
showError(message: string): void;
|
|
24
|
+
/** Unmount without emitting `onCancel` (the owner already settled). */
|
|
25
|
+
close(): void;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Mount a REAL `SessionSelectorComponent` on the host UI (inline, replacing
|
|
29
|
+
* the editor like the built-in `/resume` picker). Navigation, search, and
|
|
30
|
+
* repaints are entirely host-local; the owner only observes semantic events
|
|
31
|
+
* through the delegate. Deletion is owner-owned: a confirmed Ctrl+D forwards
|
|
32
|
+
* `onDelete` and the row stays until the owner calls `setRows`/`showError`.
|
|
33
|
+
*
|
|
34
|
+
* Shared by the interactive-engine host controller (owner = engine child over
|
|
35
|
+
* the picker protocol) and the in-process `ctx.ui.hostSessionPicker`
|
|
36
|
+
* capability (owner = the extension itself, zero IPC).
|
|
37
|
+
*/
|
|
38
|
+
export declare function mountHostSessionPicker(ui: HostSessionPickerUi, initialRows: SessionInfo[], showRenameHint: boolean, delegate: HostSessionPickerMountDelegate): HostSessionPickerMount;
|
|
39
|
+
/**
|
|
40
|
+
* In-process implementation of `ctx.ui.hostSessionPicker` for hosts where
|
|
41
|
+
* extensions already run in the terminal process (non-isolated interactive
|
|
42
|
+
* mode): the selector mounts directly with no IPC, exposing the exact same
|
|
43
|
+
* capability API the isolated engine child sees, so callers never branch.
|
|
44
|
+
*/
|
|
45
|
+
export declare function openLocalHostSessionPicker(ui: HostSessionPickerUi, request: HostSessionPickerRequest): HostSessionPickerHandle;
|
|
46
|
+
//# sourceMappingURL=host-session-picker.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"host-session-picker.d.ts","sourceRoot":"","sources":["../../../../src/modes/interactive/components/host-session-picker.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACX,kBAAkB,EAClB,uBAAuB,EACvB,wBAAwB,EACxB,oBAAoB,EACpB,MAAM,sCAAsC,CAAC;AAC9C,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kCAAkC,CAAC;AAGpE,gEAAgE;AAChE,MAAM,MAAM,mBAAmB,GAAG,IAAI,CAAC,kBAAkB,EAAE,QAAQ,GAAG,eAAe,CAAC,CAAC;AAEvF,6EAA6E;AAC7E,wBAAgB,wBAAwB,CAAC,GAAG,EAAE,oBAAoB,GAAG,WAAW,CAa/E;AAED;;;;;GAKG;AACH,MAAM,WAAW,8BAA8B;IAC9C,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7B,QAAQ,IAAI,IAAI,CAAC;IACjB,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;CAC7B;AAED,oEAAoE;AACpE,MAAM,WAAW,sBAAsB;IACtC,6EAA6E;IAC7E,OAAO,CAAC,IAAI,EAAE,WAAW,EAAE,GAAG,IAAI,CAAC;IACnC,sDAAsD;IACtD,SAAS,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;IACjC,uEAAuE;IACvE,KAAK,IAAI,IAAI,CAAC;CACd;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,sBAAsB,CACrC,EAAE,EAAE,mBAAmB,EACvB,WAAW,EAAE,WAAW,EAAE,EAC1B,cAAc,EAAE,OAAO,EACvB,QAAQ,EAAE,8BAA8B,GACtC,sBAAsB,CAwHxB;AAED;;;;;GAKG;AACH,wBAAgB,0BAA0B,CACzC,EAAE,EAAE,mBAAmB,EACvB,OAAO,EAAE,wBAAwB,GAC/B,uBAAuB,CAuCzB"}
|
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
import { SessionSelectorComponent } from "./session-selector.js";
|
|
2
|
+
/** Deserialize a JSON-safe picker row back into a selector `SessionInfo`. */
|
|
3
|
+
export function sessionInfoFromPickerRow(row) {
|
|
4
|
+
return {
|
|
5
|
+
path: row.path,
|
|
6
|
+
id: row.id,
|
|
7
|
+
cwd: row.cwd,
|
|
8
|
+
created: new Date(row.createdAt),
|
|
9
|
+
modified: new Date(row.modifiedAt),
|
|
10
|
+
messageCount: row.messageCount,
|
|
11
|
+
firstMessage: row.firstMessage,
|
|
12
|
+
allMessagesText: row.allMessagesText ?? "",
|
|
13
|
+
...(row.name !== undefined ? { name: row.name } : {}),
|
|
14
|
+
...(row.messageColor !== undefined ? { messageColor: row.messageColor } : {}),
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Mount a REAL `SessionSelectorComponent` on the host UI (inline, replacing
|
|
19
|
+
* the editor like the built-in `/resume` picker). Navigation, search, and
|
|
20
|
+
* repaints are entirely host-local; the owner only observes semantic events
|
|
21
|
+
* through the delegate. Deletion is owner-owned: a confirmed Ctrl+D forwards
|
|
22
|
+
* `onDelete` and the row stays until the owner calls `setRows`/`showError`.
|
|
23
|
+
*
|
|
24
|
+
* Shared by the interactive-engine host controller (owner = engine child over
|
|
25
|
+
* the picker protocol) and the in-process `ctx.ui.hostSessionPicker`
|
|
26
|
+
* capability (owner = the extension itself, zero IPC).
|
|
27
|
+
*/
|
|
28
|
+
export function mountHostSessionPicker(ui, initialRows, showRenameHint, delegate) {
|
|
29
|
+
// Shared row/error state that outlives the (possibly asynchronous)
|
|
30
|
+
// `ui.custom` mount: a `setRows`/`showError` arriving before the factory
|
|
31
|
+
// runs must not be dropped, and the selector's own initial async load must
|
|
32
|
+
// resolve against the LATEST rows rather than a stale at-call snapshot
|
|
33
|
+
// (otherwise the initial load could clobber an update applied in between).
|
|
34
|
+
let currentRows = initialRows;
|
|
35
|
+
const pendingErrors = [];
|
|
36
|
+
let record;
|
|
37
|
+
let closedBeforeMount = false;
|
|
38
|
+
// Most recent loader read handed to the selector. A loader result is a
|
|
39
|
+
// snapshot fixed at resolve time, so an external `setRows` landing between
|
|
40
|
+
// the loader's resolution and the selector's write must re-assert itself
|
|
41
|
+
// BEHIND that write (continuations registered later run later).
|
|
42
|
+
let activeLoad;
|
|
43
|
+
void ui.custom((_tui, _theme, _keybindings, done) => {
|
|
44
|
+
const settle = (notify) => {
|
|
45
|
+
if (!record || record.settled)
|
|
46
|
+
return;
|
|
47
|
+
record.settled = true;
|
|
48
|
+
notify();
|
|
49
|
+
done(undefined);
|
|
50
|
+
};
|
|
51
|
+
// Defer the row read by one microtask so the load resolves with the
|
|
52
|
+
// rows current at resolution time, not at invocation time.
|
|
53
|
+
const loadRows = () => {
|
|
54
|
+
const load = Promise.resolve().then(() => [...currentRows]);
|
|
55
|
+
activeLoad = load;
|
|
56
|
+
return load;
|
|
57
|
+
};
|
|
58
|
+
const selector = new SessionSelectorComponent(loadRows, loadRows, (path) => settle(() => delegate.onSelect(path)), () => settle(() => delegate.onCancel()), () => settle(() => delegate.onCancel()), () => ui.requestRender(), { showRenameHint, initialSessions: [...currentRows] });
|
|
59
|
+
// Owner-owned deletion: forward the confirmed request and keep the
|
|
60
|
+
// row until the owner replies with setRows (or showError).
|
|
61
|
+
selector.getSessionList().onDeleteSession = async (path) => {
|
|
62
|
+
delegate.onDelete(path);
|
|
63
|
+
};
|
|
64
|
+
selector.focused = true;
|
|
65
|
+
record = { selector, done, settled: false };
|
|
66
|
+
if (closedBeforeMount) {
|
|
67
|
+
record.settled = true;
|
|
68
|
+
done(undefined);
|
|
69
|
+
}
|
|
70
|
+
else {
|
|
71
|
+
for (const message of pendingErrors.splice(0)) {
|
|
72
|
+
selector.getSessionList().onError?.(message);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
return selector;
|
|
76
|
+
}, { overlay: false }).catch(() => undefined).finally(() => {
|
|
77
|
+
if (!record) {
|
|
78
|
+
// The mount never materialized (factory threw or the host rejected
|
|
79
|
+
// the custom UI). Settle the owner so a child-side picker cannot
|
|
80
|
+
// hang forever waiting for a selection that can never happen.
|
|
81
|
+
if (!closedBeforeMount) {
|
|
82
|
+
closedBeforeMount = true;
|
|
83
|
+
delegate.onCancel();
|
|
84
|
+
}
|
|
85
|
+
return;
|
|
86
|
+
}
|
|
87
|
+
record.selector.dispose();
|
|
88
|
+
if (!record.settled) {
|
|
89
|
+
// Host-initiated teardown (abort/unmount without a selection).
|
|
90
|
+
record.settled = true;
|
|
91
|
+
delegate.onCancel();
|
|
92
|
+
}
|
|
93
|
+
});
|
|
94
|
+
return {
|
|
95
|
+
setRows: (rows) => {
|
|
96
|
+
if (closedBeforeMount || record?.settled)
|
|
97
|
+
return;
|
|
98
|
+
currentRows = rows;
|
|
99
|
+
// Pre-mount updates apply at mount via initialSessions/loadRows.
|
|
100
|
+
if (!record)
|
|
101
|
+
return;
|
|
102
|
+
const mounted = record;
|
|
103
|
+
mounted.selector.getSessionList().setSessions([...rows], true);
|
|
104
|
+
ui.requestRender();
|
|
105
|
+
// If a loader read is in flight, the selector will write that stale
|
|
106
|
+
// snapshot after this update; queue a re-assertion of the latest rows
|
|
107
|
+
// behind the selector's own continuation so external updates win.
|
|
108
|
+
const load = activeLoad;
|
|
109
|
+
if (load) {
|
|
110
|
+
void load.then(() => {
|
|
111
|
+
if (mounted.settled)
|
|
112
|
+
return;
|
|
113
|
+
mounted.selector.getSessionList().setSessions([...currentRows], true);
|
|
114
|
+
ui.requestRender();
|
|
115
|
+
});
|
|
116
|
+
}
|
|
117
|
+
},
|
|
118
|
+
showError: (message) => {
|
|
119
|
+
if (closedBeforeMount || record?.settled)
|
|
120
|
+
return;
|
|
121
|
+
if (!record) {
|
|
122
|
+
pendingErrors.push(message);
|
|
123
|
+
return;
|
|
124
|
+
}
|
|
125
|
+
record.selector.getSessionList().onError?.(message);
|
|
126
|
+
ui.requestRender();
|
|
127
|
+
},
|
|
128
|
+
close: () => {
|
|
129
|
+
if (!record) {
|
|
130
|
+
closedBeforeMount = true;
|
|
131
|
+
return;
|
|
132
|
+
}
|
|
133
|
+
if (record.settled)
|
|
134
|
+
return;
|
|
135
|
+
record.settled = true;
|
|
136
|
+
record.done(undefined);
|
|
137
|
+
},
|
|
138
|
+
};
|
|
139
|
+
}
|
|
140
|
+
/**
|
|
141
|
+
* In-process implementation of `ctx.ui.hostSessionPicker` for hosts where
|
|
142
|
+
* extensions already run in the terminal process (non-isolated interactive
|
|
143
|
+
* mode): the selector mounts directly with no IPC, exposing the exact same
|
|
144
|
+
* capability API the isolated engine child sees, so callers never branch.
|
|
145
|
+
*/
|
|
146
|
+
export function openLocalHostSessionPicker(ui, request) {
|
|
147
|
+
let resolveResult;
|
|
148
|
+
const result = new Promise((resolve) => { resolveResult = resolve; });
|
|
149
|
+
let settled = false;
|
|
150
|
+
const settle = (path) => {
|
|
151
|
+
if (settled)
|
|
152
|
+
return;
|
|
153
|
+
settled = true;
|
|
154
|
+
resolveResult(path);
|
|
155
|
+
};
|
|
156
|
+
const mount = mountHostSessionPicker(ui, request.sessions.map(sessionInfoFromPickerRow), request.showRenameHint === true, {
|
|
157
|
+
onSelect: (path) => settle(path),
|
|
158
|
+
onCancel: () => settle(undefined),
|
|
159
|
+
onDelete: (path) => {
|
|
160
|
+
const onDelete = request.onDelete;
|
|
161
|
+
if (!onDelete) {
|
|
162
|
+
mount.showError("Deletion is not supported for this picker");
|
|
163
|
+
return;
|
|
164
|
+
}
|
|
165
|
+
void Promise.resolve(onDelete(path)).catch((error) => {
|
|
166
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
167
|
+
mount.showError(`Failed to delete: ${message}`);
|
|
168
|
+
});
|
|
169
|
+
},
|
|
170
|
+
});
|
|
171
|
+
return {
|
|
172
|
+
result,
|
|
173
|
+
update: (sessions) => mount.setRows(sessions.map(sessionInfoFromPickerRow)),
|
|
174
|
+
error: (message) => mount.showError(message),
|
|
175
|
+
close: () => {
|
|
176
|
+
if (settled)
|
|
177
|
+
return;
|
|
178
|
+
mount.close();
|
|
179
|
+
settle(undefined);
|
|
180
|
+
},
|
|
181
|
+
};
|
|
182
|
+
}
|
|
183
|
+
//# sourceMappingURL=host-session-picker.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"host-session-picker.js","sourceRoot":"","sources":["../../../../src/modes/interactive/components/host-session-picker.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,wBAAwB,EAAE,MAAM,uBAAuB,CAAC;AAKjE,6EAA6E;AAC7E,MAAM,UAAU,wBAAwB,CAAC,GAAyB;IACjE,OAAO;QACN,IAAI,EAAE,GAAG,CAAC,IAAI;QACd,EAAE,EAAE,GAAG,CAAC,EAAE;QACV,GAAG,EAAE,GAAG,CAAC,GAAG;QACZ,OAAO,EAAE,IAAI,IAAI,CAAC,GAAG,CAAC,SAAS,CAAC;QAChC,QAAQ,EAAE,IAAI,IAAI,CAAC,GAAG,CAAC,UAAU,CAAC;QAClC,YAAY,EAAE,GAAG,CAAC,YAAY;QAC9B,YAAY,EAAE,GAAG,CAAC,YAAY;QAC9B,eAAe,EAAE,GAAG,CAAC,eAAe,IAAI,EAAE;QAC1C,GAAG,CAAC,GAAG,CAAC,IAAI,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,GAAG,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QACrD,GAAG,CAAC,GAAG,CAAC,YAAY,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,YAAY,EAAE,GAAG,CAAC,YAAY,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;KAC7E,CAAC;AACH,CAAC;AAwBD;;;;;;;;;;GAUG;AACH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C,CAAC;gBAC7D,OAAO;YACR,CAAC;YACD,KAAK,OAAO,CAAC,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,KAAc,EAAE,EAAE;gBAC7D,MAAM,OAAO,GAAG,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;gBACvE,KAAK,CAAC,SAAS,CAAC,qBAAqB,OAAO,EAAE,CAAC,CAAC;YACjD,CAAC,CAAC,CAAC;QACJ,CAAC;KACD,CACD,CAAC;IACF,OAAO;QACN,MAAM;QACN,MAAM,EAAE,CAAC,QAAQ,EAAE,EAAE,CAAC,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAC,wBAAwB,CAAC,CAAC;QAC3E,KAAK,EAAE,CAAC,OAAO,EAAE,EAAE,CAAC,KAAK,CAAC,SAAS,CAAC,OAAO,CAAC;QAC5C,KAAK,EAAE,GAAG,EAAE;YACX,IAAI,OAAO;gBAAE,OAAO;YACpB,KAAK,CAAC,KAAK,EAAE,CAAC;YACd,MAAM,CAAC,SAAS,CAAC,CAAC;QACnB,CAAC;KACD,CAAC;AACH,CAAC","sourcesContent":["import type {\n\tExtensionUIContext,\n\tHostSessionPickerHandle,\n\tHostSessionPickerRequest,\n\tHostSessionPickerRow,\n} from \"../../../core/extensions/ui-types.ts\";\nimport type { SessionInfo } from \"../../../core/session-manager.ts\";\nimport { SessionSelectorComponent } from \"./session-selector.ts\";\n\n/** The subset of the host UI surface the picker mount needs. */\nexport type HostSessionPickerUi = Pick<ExtensionUIContext, \"custom\" | \"requestRender\">;\n\n/** Deserialize a JSON-safe picker row back into a selector `SessionInfo`. */\nexport function sessionInfoFromPickerRow(row: HostSessionPickerRow): SessionInfo {\n\treturn {\n\t\tpath: row.path,\n\t\tid: row.id,\n\t\tcwd: row.cwd,\n\t\tcreated: new Date(row.createdAt),\n\t\tmodified: new Date(row.modifiedAt),\n\t\tmessageCount: row.messageCount,\n\t\tfirstMessage: row.firstMessage,\n\t\tallMessagesText: row.allMessagesText ?? \"\",\n\t\t...(row.name !== undefined ? { name: row.name } : {}),\n\t\t...(row.messageColor !== undefined ? { messageColor: row.messageColor } : {}),\n\t};\n}\n\n/**\n * Owner callbacks for a mounted host session picker. `onSelect`/`onCancel`\n * settle the mount (at most one of them fires, exactly once); `onDelete` may\n * fire many times and never mutates rows — the owner replies through\n * `setRows`/`showError`.\n */\nexport interface HostSessionPickerMountDelegate {\n\tonSelect(path: string): void;\n\tonCancel(): void;\n\tonDelete(path: string): void;\n}\n\n/** Owner-side control surface for a mounted host session picker. */\nexport interface HostSessionPickerMount {\n\t/** Replace the rows; selection/search state is preserved by the selector. */\n\tsetRows(rows: SessionInfo[]): void;\n\t/** Surface a transient error in the picker header. */\n\tshowError(message: string): void;\n\t/** Unmount without emitting `onCancel` (the owner already settled). */\n\tclose(): void;\n}\n\n/**\n * Mount a REAL `SessionSelectorComponent` on the host UI (inline, replacing\n * the editor like the built-in `/resume` picker). Navigation, search, and\n * repaints are entirely host-local; the owner only observes semantic events\n * through the delegate. Deletion is owner-owned: a confirmed Ctrl+D forwards\n * `onDelete` and the row stays until the owner calls `setRows`/`showError`.\n *\n * Shared by the interactive-engine host controller (owner = engine child over\n * the picker protocol) and the in-process `ctx.ui.hostSessionPicker`\n * capability (owner = the extension itself, zero IPC).\n */\nexport function mountHostSessionPicker(\n\tui: HostSessionPickerUi,\n\tinitialRows: SessionInfo[],\n\tshowRenameHint: boolean,\n\tdelegate: HostSessionPickerMountDelegate,\n): HostSessionPickerMount {\n\tinterface MountRecord {\n\t\tselector: SessionSelectorComponent;\n\t\tdone: (result: undefined) => void;\n\t\tsettled: boolean;\n\t}\n\t// Shared row/error state that outlives the (possibly asynchronous)\n\t// `ui.custom` mount: a `setRows`/`showError` arriving before the factory\n\t// runs must not be dropped, and the selector's own initial async load must\n\t// resolve against the LATEST rows rather than a stale at-call snapshot\n\t// (otherwise the initial load could clobber an update applied in between).\n\tlet currentRows = initialRows;\n\tconst pendingErrors: string[] = [];\n\tlet record: MountRecord | undefined;\n\tlet closedBeforeMount = false;\n\t// Most recent loader read handed to the selector. A loader result is a\n\t// snapshot fixed at resolve time, so an external `setRows` landing between\n\t// the loader's resolution and the selector's write must re-assert itself\n\t// BEHIND that write (continuations registered later run later).\n\tlet activeLoad: Promise<SessionInfo[]> | undefined;\n\tvoid ui.custom<undefined>(\n\t\t(_tui, _theme, _keybindings, done) => {\n\t\t\tconst settle = (notify: () => void): void => {\n\t\t\t\tif (!record || record.settled) return;\n\t\t\t\trecord.settled = true;\n\t\t\t\tnotify();\n\t\t\t\tdone(undefined);\n\t\t\t};\n\t\t\t// Defer the row read by one microtask so the load resolves with the\n\t\t\t// rows current at resolution time, not at invocation time.\n\t\t\tconst loadRows = (): Promise<SessionInfo[]> => {\n\t\t\t\tconst load = Promise.resolve().then(() => [...currentRows]);\n\t\t\t\tactiveLoad = load;\n\t\t\t\treturn load;\n\t\t\t};\n\t\t\tconst selector = new SessionSelectorComponent(\n\t\t\t\tloadRows,\n\t\t\t\tloadRows,\n\t\t\t\t(path) => settle(() => delegate.onSelect(path)),\n\t\t\t\t() => settle(() => delegate.onCancel()),\n\t\t\t\t() => settle(() => delegate.onCancel()),\n\t\t\t\t() => ui.requestRender(),\n\t\t\t\t{ showRenameHint, initialSessions: [...currentRows] },\n\t\t\t);\n\t\t\t// Owner-owned deletion: forward the confirmed request and keep the\n\t\t\t// row until the owner replies with setRows (or showError).\n\t\t\tselector.getSessionList().onDeleteSession = async (path) => {\n\t\t\t\tdelegate.onDelete(path);\n\t\t\t};\n\t\t\tselector.focused = true;\n\t\t\trecord = { selector, done, settled: false };\n\t\t\tif (closedBeforeMount) {\n\t\t\t\trecord.settled = true;\n\t\t\t\tdone(undefined);\n\t\t\t} else {\n\t\t\t\tfor (const message of pendingErrors.splice(0)) {\n\t\t\t\t\tselector.getSessionList().onError?.(message);\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn selector;\n\t\t},\n\t\t{ overlay: false },\n\t).catch(() => undefined).finally(() => {\n\t\tif (!record) {\n\t\t\t// The mount never materialized (factory threw or the host rejected\n\t\t\t// the custom UI). Settle the owner so a child-side picker cannot\n\t\t\t// hang forever waiting for a selection that can never happen.\n\t\t\tif (!closedBeforeMount) {\n\t\t\t\tclosedBeforeMount = true;\n\t\t\t\tdelegate.onCancel();\n\t\t\t}\n\t\t\treturn;\n\t\t}\n\t\trecord.selector.dispose();\n\t\tif (!record.settled) {\n\t\t\t// Host-initiated teardown (abort/unmount without a selection).\n\t\t\trecord.settled = true;\n\t\t\tdelegate.onCancel();\n\t\t}\n\t});\n\treturn {\n\t\tsetRows: (rows) => {\n\t\t\tif (closedBeforeMount || record?.settled) return;\n\t\t\tcurrentRows = rows;\n\t\t\t// Pre-mount updates apply at mount via initialSessions/loadRows.\n\t\t\tif (!record) return;\n\t\t\tconst mounted = record;\n\t\t\tmounted.selector.getSessionList().setSessions([...rows], true);\n\t\t\tui.requestRender();\n\t\t\t// If a loader read is in flight, the selector will write that stale\n\t\t\t// snapshot after this update; queue a re-assertion of the latest rows\n\t\t\t// behind the selector's own continuation so external updates win.\n\t\t\tconst load = activeLoad;\n\t\t\tif (load) {\n\t\t\t\tvoid load.then(() => {\n\t\t\t\t\tif (mounted.settled) return;\n\t\t\t\t\tmounted.selector.getSessionList().setSessions([...currentRows], true);\n\t\t\t\t\tui.requestRender();\n\t\t\t\t});\n\t\t\t}\n\t\t},\n\t\tshowError: (message) => {\n\t\t\tif (closedBeforeMount || record?.settled) return;\n\t\t\tif (!record) {\n\t\t\t\tpendingErrors.push(message);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\trecord.selector.getSessionList().onError?.(message);\n\t\t\tui.requestRender();\n\t\t},\n\t\tclose: () => {\n\t\t\tif (!record) {\n\t\t\t\tclosedBeforeMount = true;\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (record.settled) return;\n\t\t\trecord.settled = true;\n\t\t\trecord.done(undefined);\n\t\t},\n\t};\n}\n\n/**\n * In-process implementation of `ctx.ui.hostSessionPicker` for hosts where\n * extensions already run in the terminal process (non-isolated interactive\n * mode): the selector mounts directly with no IPC, exposing the exact same\n * capability API the isolated engine child sees, so callers never branch.\n */\nexport function openLocalHostSessionPicker(\n\tui: HostSessionPickerUi,\n\trequest: HostSessionPickerRequest,\n): HostSessionPickerHandle {\n\tlet resolveResult!: (path: string | undefined) => void;\n\tconst result = new Promise<string | undefined>((resolve) => { resolveResult = resolve; });\n\tlet settled = false;\n\tconst settle = (path: string | undefined): void => {\n\t\tif (settled) return;\n\t\tsettled = true;\n\t\tresolveResult(path);\n\t};\n\tconst mount = mountHostSessionPicker(\n\t\tui,\n\t\trequest.sessions.map(sessionInfoFromPickerRow),\n\t\trequest.showRenameHint === true,\n\t\t{\n\t\t\tonSelect: (path) => settle(path),\n\t\t\tonCancel: () => settle(undefined),\n\t\t\tonDelete: (path) => {\n\t\t\t\tconst onDelete = request.onDelete;\n\t\t\t\tif (!onDelete) {\n\t\t\t\t\tmount.showError(\"Deletion is not supported for this picker\");\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tvoid Promise.resolve(onDelete(path)).catch((error: unknown) => {\n\t\t\t\t\tconst message = error instanceof Error ? error.message : String(error);\n\t\t\t\t\tmount.showError(`Failed to delete: ${message}`);\n\t\t\t\t});\n\t\t\t},\n\t\t},\n\t);\n\treturn {\n\t\tresult,\n\t\tupdate: (sessions) => mount.setRows(sessions.map(sessionInfoFromPickerRow)),\n\t\terror: (message) => mount.showError(message),\n\t\tclose: () => {\n\t\t\tif (settled) return;\n\t\t\tmount.close();\n\t\t\tsettle(undefined);\n\t\t},\n\t};\n}\n"]}
|
|
@@ -17,7 +17,7 @@ export { ExtensionInputComponent } from "./extension-input.ts";
|
|
|
17
17
|
export { ExtensionSelectorComponent } from "./extension-selector.ts";
|
|
18
18
|
export { FastModeSelectorComponent, type FastModeSelectorCallbacks, type FastModeSelectorConfig, } from "./fast-mode-selector.ts";
|
|
19
19
|
export { FooterComponent, UsageMeterComponent } from "./footer.ts";
|
|
20
|
-
export { keyHint, keyText, rawKeyHint } from "./keybinding-hints.ts";
|
|
20
|
+
export { keyHint, keyHintIfBound, keyText, rawKeyHint } from "./keybinding-hints.ts";
|
|
21
21
|
export { LoginDialogComponent } from "./login-dialog.ts";
|
|
22
22
|
export { ModelSelectorComponent } from "./model-selector.ts";
|
|
23
23
|
export { OAuthSelectorComponent } from "./oauth-selector.ts";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/modes/interactive/components/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAC5C,OAAO,EAAE,yBAAyB,EAAE,MAAM,wBAAwB,CAAC;AACnE,OAAO,EAAE,sBAAsB,EAAE,MAAM,qBAAqB,CAAC;AAC7D,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EACL,4BAA4B,EAC5B,yBAAyB,EACzB,sBAAsB,EACtB,KAAK,gBAAgB,EACrB,KAAK,wBAAwB,GAC9B,MAAM,4BAA4B,CAAC;AACpC,OAAO,EACL,eAAe,EACf,KAAK,0BAA0B,EAC/B,KAAK,uBAAuB,EAC5B,KAAK,oBAAoB,EACzB,KAAK,mBAAmB,EACxB,KAAK,oBAAoB,GAC1B,MAAM,wBAAwB,CAAC;AAChC,OAAO,EACL,sBAAsB,EACtB,uBAAuB,EACvB,iCAAiC,EACjC,2BAA2B,EAC3B,KAAK,sBAAsB,EAC3B,KAAK,uBAAuB,EAC5B,KAAK,sBAAsB,EAC3B,KAAK,kBAAkB,GACxB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,6BAA6B,EAAE,MAAM,6BAA6B,CAAC;AAC5E,OAAO,EAAE,kCAAkC,EAAE,MAAM,kCAAkC,CAAC;AACtF,OAAO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