@bastani/atomic 0.9.9 → 0.9.10-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +66 -0
- package/README.md +2 -0
- package/dist/builtin/cursor/CHANGELOG.md +6 -0
- package/dist/builtin/cursor/package.json +3 -3
- package/dist/builtin/intercom/CHANGELOG.md +15 -0
- package/dist/builtin/intercom/README.md +12 -4
- package/dist/builtin/intercom/broker/broker.ts +96 -14
- package/dist/builtin/intercom/broker/client-message-validation.ts +39 -0
- package/dist/builtin/intercom/broker/client.ts +101 -92
- package/dist/builtin/intercom/broker/group-isolation.ts +28 -0
- package/dist/builtin/intercom/broker/send-handler.ts +62 -10
- package/dist/builtin/intercom/broker/send-signature.ts +3 -0
- package/dist/builtin/intercom/broker/supervisor-channel.ts +126 -0
- package/dist/builtin/intercom/closed-workflow-stage-message.ts +66 -0
- package/dist/builtin/intercom/config.ts +10 -0
- package/dist/builtin/intercom/contact-supervisor-tool.ts +14 -10
- package/dist/builtin/intercom/foreground-detach-handoff.ts +12 -2
- package/dist/builtin/intercom/group.ts +46 -0
- package/dist/builtin/intercom/inbound-message-admission.ts +79 -0
- package/dist/builtin/intercom/incoming-message-delivery.ts +49 -0
- package/dist/builtin/intercom/index-heavy.ts +148 -94
- package/dist/builtin/intercom/index.ts +66 -4
- package/dist/builtin/intercom/intercom-test-seams.ts +6 -0
- package/dist/builtin/intercom/intercom-tool.ts +71 -20
- package/dist/builtin/intercom/intercom-utils.ts +15 -2
- package/dist/builtin/intercom/late-stage-message-router.ts +148 -0
- package/dist/builtin/intercom/lifecycle.ts +10 -4
- package/dist/builtin/intercom/package.json +2 -2
- package/dist/builtin/intercom/reconnect-backoff.ts +6 -0
- package/dist/builtin/intercom/reply-tracker.ts +8 -0
- package/dist/builtin/intercom/skills/intercom/SKILL.md +2 -0
- package/dist/builtin/intercom/stable-delivery-retry.ts +32 -0
- package/dist/builtin/intercom/subagent-relay.ts +67 -14
- package/dist/builtin/intercom/supervisor-authorization-registry.ts +22 -0
- package/dist/builtin/intercom/terminal-ordering-barrier.ts +144 -25
- package/dist/builtin/intercom/types.ts +18 -5
- package/dist/builtin/intercom/workflow-reply-tracker.ts +19 -0
- package/dist/builtin/intercom/workflow-stage-admission.ts +43 -0
- package/dist/builtin/intercom/workflow-stage-delivery-failure.ts +77 -0
- package/dist/builtin/mcp/CHANGELOG.md +11 -0
- package/dist/builtin/mcp/README.md +6 -2
- package/dist/builtin/mcp/config.ts +8 -8
- package/dist/builtin/mcp/direct-tool-executor.ts +7 -6
- package/dist/builtin/mcp/package.json +3 -3
- package/dist/builtin/mcp/proxy-call.ts +5 -4
- package/dist/builtin/mcp/sampling-handler.ts +7 -2
- package/dist/builtin/mcp/tool-call-timeout.ts +101 -0
- package/dist/builtin/mcp/tool-result-renderer.ts +3 -2
- package/dist/builtin/mcp/types.ts +5 -0
- package/dist/builtin/mcp/ui-server.ts +3 -2
- package/dist/builtin/subagents/CHANGELOG.md +21 -0
- package/dist/builtin/subagents/README.md +6 -3
- package/dist/builtin/subagents/agents/code-simplifier.md +1 -1
- package/dist/builtin/subagents/agents/codebase-analyzer.md +1 -1
- package/dist/builtin/subagents/agents/codebase-locator.md +1 -1
- package/dist/builtin/subagents/agents/codebase-online-researcher.md +1 -1
- package/dist/builtin/subagents/agents/codebase-pattern-finder.md +1 -1
- package/dist/builtin/subagents/agents/codebase-research-analyzer.md +1 -1
- package/dist/builtin/subagents/agents/codebase-research-locator.md +1 -1
- package/dist/builtin/subagents/agents/debugger.md +1 -1
- package/dist/builtin/subagents/agents/worker.md +1 -1
- package/dist/builtin/subagents/package.json +4 -4
- package/dist/builtin/subagents/skills/subagent/SKILL.md +1 -1
- package/dist/builtin/subagents/src/extension/index.ts +37 -61
- package/dist/builtin/subagents/src/extension/notification-content.ts +80 -0
- package/dist/builtin/subagents/src/extension/schemas.ts +9 -0
- package/dist/builtin/subagents/src/extension/tool-description.ts +1 -0
- package/dist/builtin/subagents/src/intercom/supervisor-authorization.ts +23 -0
- package/dist/builtin/subagents/src/runs/background/async-execution-chain.ts +4 -0
- package/dist/builtin/subagents/src/runs/background/async-execution-single.ts +2 -0
- package/dist/builtin/subagents/src/runs/background/async-execution-types.ts +4 -0
- package/dist/builtin/subagents/src/runs/background/async-job-tracker.ts +75 -13
- package/dist/builtin/subagents/src/runs/background/async-status.ts +19 -0
- package/dist/builtin/subagents/src/runs/background/completion-notification.ts +4 -3
- package/dist/builtin/subagents/src/runs/background/notify.ts +76 -15
- package/dist/builtin/subagents/src/runs/background/stale-run-reconciler.ts +1 -1
- package/dist/builtin/subagents/src/runs/background/subagent-runner-dynamic.ts +13 -0
- package/dist/builtin/subagents/src/runs/background/subagent-runner-parallel.ts +1 -0
- package/dist/builtin/subagents/src/runs/background/subagent-runner-sequential.ts +1 -0
- package/dist/builtin/subagents/src/runs/background/subagent-runner-step.ts +2 -1
- package/dist/builtin/subagents/src/runs/background/subagent-runner-types.ts +4 -0
- package/dist/builtin/subagents/src/runs/foreground/chain-execution-parallel-runner.ts +13 -0
- package/dist/builtin/subagents/src/runs/foreground/chain-execution-parallel-step.ts +19 -2
- package/dist/builtin/subagents/src/runs/foreground/detached-cleanup-barrier.ts +26 -0
- package/dist/builtin/subagents/src/runs/foreground/execution-attempt.ts +19 -30
- package/dist/builtin/subagents/src/runs/foreground/execution-intercom-detach.ts +47 -0
- package/dist/builtin/subagents/src/runs/foreground/subagent-executor-async.ts +60 -2
- package/dist/builtin/subagents/src/runs/foreground/subagent-executor-parallel-task.ts +21 -0
- package/dist/builtin/subagents/src/runs/foreground/subagent-executor-parallel.ts +21 -2
- package/dist/builtin/subagents/src/runs/foreground/subagent-executor-resume.ts +6 -1
- package/dist/builtin/subagents/src/runs/foreground/subagent-executor-single.ts +2 -0
- package/dist/builtin/subagents/src/runs/foreground/subagent-executor-types.ts +2 -0
- package/dist/builtin/subagents/src/runs/foreground/subagent-executor.ts +1 -1
- package/dist/builtin/subagents/src/runs/shared/intercom-group.ts +50 -0
- package/dist/builtin/subagents/src/runs/shared/pi-args.ts +16 -0
- package/dist/builtin/subagents/src/runs/shared/worktree-post-create.ts +75 -0
- package/dist/builtin/subagents/src/runs/shared/worktree-root.ts +51 -0
- package/dist/builtin/subagents/src/runs/shared/worktree.ts +69 -77
- package/dist/builtin/subagents/src/shared/types-config.ts +6 -0
- package/dist/builtin/subagents/src/slash/slash-commands.ts +3 -2
- package/dist/builtin/subagents/src/tui/render-result-compact.ts +5 -3
- package/dist/builtin/subagents/src/tui/render-result.ts +5 -3
- package/dist/builtin/subagents/src/tui/render-widget-graph.ts +7 -4
- package/dist/builtin/web-access/CHANGELOG.md +11 -0
- package/dist/builtin/web-access/extract-frames.ts +14 -13
- package/dist/builtin/web-access/extract.ts +2 -2
- package/dist/builtin/web-access/gemini-api.ts +0 -3
- package/dist/builtin/web-access/gemini-web-config.ts +1 -3
- package/dist/builtin/web-access/gemini-web.ts +1 -0
- package/dist/builtin/web-access/package.json +2 -2
- package/dist/builtin/web-access/perplexity.ts +0 -3
- package/dist/builtin/web-access/result-renderers.ts +7 -5
- package/dist/builtin/web-access/subprocess.ts +100 -0
- package/dist/builtin/web-access/summary-review.ts +14 -3
- package/dist/builtin/web-access/video-extract.ts +12 -17
- package/dist/builtin/web-access/web-search-browser.ts +18 -10
- package/dist/builtin/web-access/web-search-summary.ts +9 -2
- package/dist/builtin/web-access/youtube-extract.ts +22 -25
- package/dist/builtin/workflows/CHANGELOG.md +77 -0
- package/dist/builtin/workflows/README.md +76 -38
- package/dist/builtin/workflows/ambient.d.ts +30 -0
- package/dist/builtin/workflows/builtin/adversarial-verification-prompts.ts +15 -0
- package/dist/builtin/workflows/builtin/adversarial-verification-runner.ts +93 -0
- package/dist/builtin/workflows/builtin/adversarial-verification.d.ts +11 -0
- package/dist/builtin/workflows/builtin/adversarial-verification.ts +24 -0
- package/dist/builtin/workflows/builtin/classify-and-act-prompts.ts +11 -0
- package/dist/builtin/workflows/builtin/classify-and-act-runner.ts +110 -0
- package/dist/builtin/workflows/builtin/classify-and-act.d.ts +24 -0
- package/dist/builtin/workflows/builtin/classify-and-act.ts +35 -0
- package/dist/builtin/workflows/builtin/deep-research-codebase-utils.ts +8 -2
- package/dist/builtin/workflows/builtin/fan-out-and-synthesize-prompts.ts +11 -0
- package/dist/builtin/workflows/builtin/fan-out-and-synthesize-runner.ts +96 -0
- package/dist/builtin/workflows/builtin/fan-out-and-synthesize.d.ts +23 -0
- package/dist/builtin/workflows/builtin/fan-out-and-synthesize.ts +32 -0
- package/dist/builtin/workflows/builtin/generate-and-filter-prompts.ts +15 -0
- package/dist/builtin/workflows/builtin/generate-and-filter-runner.ts +75 -0
- package/dist/builtin/workflows/builtin/generate-and-filter.d.ts +11 -0
- package/dist/builtin/workflows/builtin/generate-and-filter.ts +26 -0
- package/dist/builtin/workflows/builtin/goal-models.ts +72 -0
- package/dist/builtin/workflows/builtin/goal-runner.ts +2 -64
- package/dist/builtin/workflows/builtin/index.d.ts +44 -0
- package/dist/builtin/workflows/builtin/index.ts +6 -0
- package/dist/builtin/workflows/builtin/loop-until-done-prompts.ts +79 -0
- package/dist/builtin/workflows/builtin/loop-until-done-runner.ts +189 -0
- package/dist/builtin/workflows/builtin/loop-until-done.d.ts +34 -0
- package/dist/builtin/workflows/builtin/loop-until-done.ts +31 -0
- package/dist/builtin/workflows/builtin/open-claude-design-runner.ts +6 -1
- package/dist/builtin/workflows/builtin/pattern-artifact-root.ts +28 -0
- package/dist/builtin/workflows/builtin/ralph-models.ts +26 -5
- package/dist/builtin/workflows/builtin/ralph-runner.ts +1 -0
- package/dist/builtin/workflows/builtin/tournament-prompts.ts +79 -0
- package/dist/builtin/workflows/builtin/tournament-runner.ts +188 -0
- package/dist/builtin/workflows/builtin/tournament.d.ts +33 -0
- package/dist/builtin/workflows/builtin/tournament.ts +34 -0
- package/dist/builtin/workflows/package.json +2 -2
- package/dist/builtin/workflows/src/authoring.d.ts +2 -6
- package/dist/builtin/workflows/src/durable/backend.ts +163 -120
- package/dist/builtin/workflows/src/durable/completed-catalog.ts +37 -64
- package/dist/builtin/workflows/src/durable/completed-inspection.ts +4 -72
- package/dist/builtin/workflows/src/durable/dbos-backend.ts +242 -195
- package/dist/builtin/workflows/src/durable/dbos-embedded-postgres.ts +207 -0
- package/dist/builtin/workflows/src/durable/dbos-envelope.ts +42 -42
- package/dist/builtin/workflows/src/durable/dbos-lifecycle.ts +155 -0
- package/dist/builtin/workflows/src/durable/dbos-local-postgres.ts +126 -0
- package/dist/builtin/workflows/src/durable/dbos-metadata.ts +105 -58
- package/dist/builtin/workflows/src/durable/dbos-prompt-reservations.ts +320 -0
- package/dist/builtin/workflows/src/durable/dbos-sdk-handle.ts +161 -0
- package/dist/builtin/workflows/src/durable/dbos-status-transition.ts +62 -0
- package/dist/builtin/workflows/src/durable/dbos-tombstone.ts +2 -2
- package/dist/builtin/workflows/src/durable/durable-hash.ts +20 -0
- package/dist/builtin/workflows/src/durable/factory.ts +23 -83
- package/dist/builtin/workflows/src/durable/format-version.ts +4 -10
- package/dist/builtin/workflows/src/durable/index.ts +16 -20
- package/dist/builtin/workflows/src/durable/local-command.ts +63 -0
- package/dist/builtin/workflows/src/durable/prompt-reservation-state.ts +177 -0
- package/dist/builtin/workflows/src/durable/prompt-reservations.ts +36 -0
- package/dist/builtin/workflows/src/durable/resume-catalog.ts +2 -200
- package/dist/builtin/workflows/src/durable/resume-eligibility.ts +42 -2
- package/dist/builtin/workflows/src/durable/resume-runtime.ts +121 -118
- package/dist/builtin/workflows/src/durable/retention-policy.ts +42 -0
- package/dist/builtin/workflows/src/durable/run-timing.ts +98 -0
- package/dist/builtin/workflows/src/durable/scoped-backend.ts +62 -14
- package/dist/builtin/workflows/src/durable/stage-primitive.ts +15 -2
- package/dist/builtin/workflows/src/durable/tool-primitive.ts +11 -7
- package/dist/builtin/workflows/src/durable/types.ts +25 -18
- package/dist/builtin/workflows/src/durable/ui-primitive.ts +117 -29
- package/dist/builtin/workflows/src/durable/workflow-status-transition.ts +30 -0
- package/dist/builtin/workflows/src/engine/primitives/parallel.ts +20 -5
- package/dist/builtin/workflows/src/engine/primitives/task.ts +3 -2
- package/dist/builtin/workflows/src/engine/primitives/ui.ts +6 -3
- package/dist/builtin/workflows/src/engine/run-durable-finalize.ts +14 -22
- package/dist/builtin/workflows/src/engine/run-durable-stage-session.ts +14 -14
- package/dist/builtin/workflows/src/engine/run.ts +35 -37
- package/dist/builtin/workflows/src/engine/runtime.ts +3 -0
- package/dist/builtin/workflows/src/engine/workflow-activity.ts +9 -0
- package/dist/builtin/workflows/src/extension/completed-stage-intercom-ask.ts +155 -0
- package/dist/builtin/workflows/src/extension/config-file-loader.ts +13 -0
- package/dist/builtin/workflows/src/extension/config-loader.ts +20 -0
- package/dist/builtin/workflows/src/extension/dispatcher.ts +56 -17
- package/dist/builtin/workflows/src/extension/extension-factory.ts +13 -10
- package/dist/builtin/workflows/src/extension/extension-lifecycle.ts +37 -59
- package/dist/builtin/workflows/src/extension/extension-runtime-state.ts +16 -18
- package/dist/builtin/workflows/src/extension/lifecycle-notification-delivery.ts +83 -0
- package/dist/builtin/workflows/src/extension/lifecycle-notifications.ts +80 -41
- package/dist/builtin/workflows/src/extension/postmortem-deps.ts +73 -0
- package/dist/builtin/workflows/src/extension/public-types.ts +11 -51
- package/dist/builtin/workflows/src/extension/render-call.ts +3 -9
- package/dist/builtin/workflows/src/extension/render-result.ts +22 -7
- package/dist/builtin/workflows/src/extension/runtime-active-block-claim.ts +78 -0
- package/dist/builtin/workflows/src/extension/runtime-durable-resume.ts +50 -29
- package/dist/builtin/workflows/src/extension/runtime.ts +70 -219
- package/dist/builtin/workflows/src/extension/ui-surface.ts +107 -3
- package/dist/builtin/workflows/src/extension/wiring.ts +76 -7
- package/dist/builtin/workflows/src/extension/workflow-command-completions.ts +10 -5
- package/dist/builtin/workflows/src/extension/workflow-command-registration.ts +27 -5
- package/dist/builtin/workflows/src/extension/workflow-durable-resume-command.ts +49 -19
- package/dist/builtin/workflows/src/extension/workflow-prompts.ts +8 -8
- package/dist/builtin/workflows/src/extension/workflow-resume-picker-rows.ts +81 -0
- package/dist/builtin/workflows/src/extension/workflow-resume-shadow.ts +55 -0
- package/dist/builtin/workflows/src/extension/workflow-run-control-command.ts +193 -145
- package/dist/builtin/workflows/src/extension/workflow-schema.ts +9 -133
- package/dist/builtin/workflows/src/extension/workflow-status-summary.ts +189 -0
- package/dist/builtin/workflows/src/extension/workflow-targets.ts +1 -1
- package/dist/builtin/workflows/src/extension/workflow-tool-content.ts +78 -3
- package/dist/builtin/workflows/src/extension/workflow-tool-control.ts +185 -89
- package/dist/builtin/workflows/src/extension/workflow-tool-send.ts +92 -11
- package/dist/builtin/workflows/src/extension/workflow-tool.ts +18 -24
- package/dist/builtin/workflows/src/runs/background/durable-resume-transition.ts +63 -0
- package/dist/builtin/workflows/src/runs/background/quit.ts +139 -29
- package/dist/builtin/workflows/src/runs/background/resume-acknowledgements.ts +97 -0
- package/dist/builtin/workflows/src/runs/background/run-inspect.ts +111 -0
- package/dist/builtin/workflows/src/runs/background/runner.ts +46 -17
- package/dist/builtin/workflows/src/runs/background/startup-admission.ts +77 -0
- package/dist/builtin/workflows/src/runs/background/status.ts +133 -224
- package/dist/builtin/workflows/src/runs/background/workflow-lifecycle-aggregate.ts +44 -0
- package/dist/builtin/workflows/src/runs/foreground/executor-direct-helpers.ts +57 -256
- package/dist/builtin/workflows/src/runs/foreground/executor-hil.ts +7 -4
- package/dist/builtin/workflows/src/runs/foreground/executor-lifecycle.ts +12 -1
- package/dist/builtin/workflows/src/runs/foreground/executor-prompt-nodes.ts +39 -0
- package/dist/builtin/workflows/src/runs/foreground/executor-queued-user-message.ts +75 -0
- package/dist/builtin/workflows/src/runs/foreground/executor-stage-call.ts +44 -12
- package/dist/builtin/workflows/src/runs/foreground/executor-stage-control.ts +63 -12
- package/dist/builtin/workflows/src/runs/foreground/executor-stage-factory.ts +30 -4
- package/dist/builtin/workflows/src/runs/foreground/executor-stage-replay.ts +3 -0
- package/dist/builtin/workflows/src/runs/foreground/executor-stage-types.ts +4 -1
- package/dist/builtin/workflows/src/runs/foreground/executor-task-prompts.ts +0 -67
- package/dist/builtin/workflows/src/runs/foreground/executor-types.ts +6 -0
- package/dist/builtin/workflows/src/runs/foreground/executor.ts +0 -1
- package/dist/builtin/workflows/src/runs/foreground/postmortem-stage-chat.ts +169 -0
- package/dist/builtin/workflows/src/runs/foreground/stage-control-registry.ts +38 -1
- package/dist/builtin/workflows/src/runs/foreground/stage-runner-candidate.ts +21 -0
- package/dist/builtin/workflows/src/runs/foreground/stage-runner-context.ts +21 -3
- package/dist/builtin/workflows/src/runs/foreground/stage-runner-controller.ts +85 -84
- package/dist/builtin/workflows/src/runs/foreground/stage-runner-message-admission.ts +195 -0
- package/dist/builtin/workflows/src/runs/foreground/stage-runner-options.ts +12 -5
- package/dist/builtin/workflows/src/runs/foreground/stage-runner-replacement.ts +42 -0
- package/dist/builtin/workflows/src/runs/foreground/stage-runner-send-user-message.ts +100 -8
- package/dist/builtin/workflows/src/runs/foreground/stage-runner-session-options.ts +51 -0
- package/dist/builtin/workflows/src/runs/foreground/stage-runner-session.ts +19 -0
- package/dist/builtin/workflows/src/runs/foreground/stage-runner-types.ts +28 -2
- package/dist/builtin/workflows/src/runs/shared/prompt-callsite.ts +4 -6
- package/dist/builtin/workflows/src/runs/shared/worktree-git-runner.ts +89 -0
- package/dist/builtin/workflows/src/runs/shared/worktree-git.ts +29 -133
- package/dist/builtin/workflows/src/runs/shared/worktree-post-create.ts +130 -0
- package/dist/builtin/workflows/src/runs/shared/worktree-root.ts +84 -0
- package/dist/builtin/workflows/src/runs/shared/worktree-setup.ts +77 -63
- package/dist/builtin/workflows/src/runs/shared/worktree-types.ts +4 -0
- package/dist/builtin/workflows/src/sdk-surface.ts +1 -1
- package/dist/builtin/workflows/src/shared/authoring-contract-stage.d.ts +29 -22
- package/dist/builtin/workflows/src/shared/authoring-contract-stage.ts +26 -24
- package/dist/builtin/workflows/src/shared/authoring-contract-ui.d.ts +5 -0
- package/dist/builtin/workflows/src/shared/authoring-contract-ui.ts +5 -0
- package/dist/builtin/workflows/src/shared/intercom-group.ts +51 -0
- package/dist/builtin/workflows/src/shared/persistence-restore-helpers.ts +6 -0
- package/dist/builtin/workflows/src/shared/persistence-restore.ts +4 -0
- package/dist/builtin/workflows/src/shared/persistence-session-entries.ts +3 -0
- package/dist/builtin/workflows/src/shared/prompt-callsite-context.ts +13 -0
- package/dist/builtin/workflows/src/shared/returned-run-status.ts +2 -1
- package/dist/builtin/workflows/src/shared/session-transcript.ts +74 -0
- package/dist/builtin/workflows/src/shared/store-stage-methods.ts +1 -0
- package/dist/builtin/workflows/src/shared/store-types.ts +8 -0
- package/dist/builtin/workflows/src/shared/timing.ts +4 -1
- package/dist/builtin/workflows/src/shared/types.ts +2 -6
- package/dist/builtin/workflows/src/tui/chat-surface-message.ts +2 -42
- package/dist/builtin/workflows/src/tui/dispatch-confirm.ts +2 -2
- package/dist/builtin/workflows/src/tui/graph-view-constants.ts +7 -3
- package/dist/builtin/workflows/src/tui/graph-view-input.ts +29 -67
- package/dist/builtin/workflows/src/tui/graph-view-render-helpers.ts +15 -10
- package/dist/builtin/workflows/src/tui/graph-view-state.ts +0 -2
- package/dist/builtin/workflows/src/tui/graph-view-types.ts +3 -9
- package/dist/builtin/workflows/src/tui/host-input-form.ts +62 -0
- package/dist/builtin/workflows/src/tui/mouse-input.ts +63 -0
- package/dist/builtin/workflows/src/tui/node-card.ts +1 -0
- package/dist/builtin/workflows/src/tui/overlay-adapter.ts +67 -42
- package/dist/builtin/workflows/src/tui/overlay-terminal-modes.ts +49 -0
- package/dist/builtin/workflows/src/tui/session-overlays.ts +3 -104
- package/dist/builtin/workflows/src/tui/session-picker.ts +3 -12
- package/dist/builtin/workflows/src/tui/stage-chat-composer-drafts.ts +19 -0
- package/dist/builtin/workflows/src/tui/stage-chat-view-archive-history.ts +30 -10
- package/dist/builtin/workflows/src/tui/stage-chat-view-footer-status.ts +19 -9
- package/dist/builtin/workflows/src/tui/stage-chat-view-input.ts +25 -38
- package/dist/builtin/workflows/src/tui/stage-chat-view-render-helpers.ts +1 -1
- package/dist/builtin/workflows/src/tui/stage-chat-view-state.ts +7 -6
- package/dist/builtin/workflows/src/tui/stage-chat-view-types.ts +7 -1
- package/dist/builtin/workflows/src/tui/stage-chat-view.ts +3 -1
- package/dist/builtin/workflows/src/tui/store-widget-installer.ts +19 -20
- package/dist/builtin/workflows/src/tui/switcher.ts +4 -4
- package/dist/builtin/workflows/src/tui/widget.ts +46 -33
- package/dist/builtin/workflows/src/tui/workflow-attach-pane-handle.ts +26 -0
- package/dist/builtin/workflows/src/tui/workflow-attach-pane-types.ts +14 -2
- package/dist/builtin/workflows/src/tui/workflow-attach-pane.ts +26 -27
- package/dist/builtin/workflows/src/tui/workflow-resume-selector.ts +208 -69
- package/dist/bun/cli.js +3 -0
- package/dist/bun/cli.js.map +1 -1
- package/dist/cli/session-picker.d.ts.map +1 -1
- package/dist/cli/session-picker.js +3 -0
- package/dist/cli/session-picker.js.map +1 -1
- package/dist/core/agent-session-auto-compaction.d.ts.map +1 -1
- package/dist/core/agent-session-auto-compaction.js +19 -2
- package/dist/core/agent-session-auto-compaction.js.map +1 -1
- package/dist/core/agent-session-compaction.js +2 -2
- package/dist/core/agent-session-compaction.js.map +1 -1
- package/dist/core/agent-session-events.d.ts.map +1 -1
- package/dist/core/agent-session-events.js +5 -3
- package/dist/core/agent-session-events.js.map +1 -1
- package/dist/core/agent-session-export.js +1 -1
- package/dist/core/agent-session-export.js.map +1 -1
- package/dist/core/agent-session-extension-bindings.d.ts +2 -4
- package/dist/core/agent-session-extension-bindings.d.ts.map +1 -1
- package/dist/core/agent-session-extension-bindings.js +9 -2
- package/dist/core/agent-session-extension-bindings.js.map +1 -1
- package/dist/core/agent-session-message-queue.d.ts +6 -0
- package/dist/core/agent-session-message-queue.d.ts.map +1 -1
- package/dist/core/agent-session-message-queue.js +107 -36
- package/dist/core/agent-session-message-queue.js.map +1 -1
- package/dist/core/agent-session-methods.d.ts +18 -7
- package/dist/core/agent-session-methods.d.ts.map +1 -1
- package/dist/core/agent-session-methods.js.map +1 -1
- package/dist/core/agent-session-models.d.ts +3 -1
- package/dist/core/agent-session-models.d.ts.map +1 -1
- package/dist/core/agent-session-models.js +1 -1
- package/dist/core/agent-session-models.js.map +1 -1
- package/dist/core/agent-session-post-tool-compaction.d.ts +16 -0
- package/dist/core/agent-session-post-tool-compaction.d.ts.map +1 -0
- package/dist/core/agent-session-post-tool-compaction.js +113 -0
- package/dist/core/agent-session-post-tool-compaction.js.map +1 -0
- package/dist/core/agent-session-prompt.d.ts +12 -1
- package/dist/core/agent-session-prompt.d.ts.map +1 -1
- package/dist/core/agent-session-prompt.js +22 -5
- package/dist/core/agent-session-prompt.js.map +1 -1
- package/dist/core/agent-session-runtime.d.ts.map +1 -1
- package/dist/core/agent-session-runtime.js +3 -0
- package/dist/core/agent-session-runtime.js.map +1 -1
- package/dist/core/agent-session-tool-hooks.d.ts.map +1 -1
- package/dist/core/agent-session-tool-hooks.js +21 -0
- package/dist/core/agent-session-tool-hooks.js.map +1 -1
- package/dist/core/agent-session-tree.d.ts.map +1 -1
- package/dist/core/agent-session-tree.js +2 -1
- package/dist/core/agent-session-tree.js.map +1 -1
- package/dist/core/agent-session-types.d.ts +7 -0
- package/dist/core/agent-session-types.d.ts.map +1 -1
- package/dist/core/agent-session-types.js.map +1 -1
- package/dist/core/agent-session.d.ts +6 -0
- package/dist/core/agent-session.d.ts.map +1 -1
- package/dist/core/agent-session.js +18 -1
- package/dist/core/agent-session.js.map +1 -1
- package/dist/core/async/job-manager.d.ts +1 -0
- package/dist/core/async/job-manager.d.ts.map +1 -1
- package/dist/core/async/job-manager.js +29 -5
- package/dist/core/async/job-manager.js.map +1 -1
- package/dist/core/async/session-manager.d.ts +2 -4
- package/dist/core/async/session-manager.d.ts.map +1 -1
- package/dist/core/async/session-manager.js +5 -32
- package/dist/core/async/session-manager.js.map +1 -1
- package/dist/core/atomic-guide-command.d.ts.map +1 -1
- package/dist/core/atomic-guide-command.js +2 -0
- package/dist/core/atomic-guide-command.js.map +1 -1
- package/dist/core/auth-storage.d.ts +20 -10
- package/dist/core/auth-storage.d.ts.map +1 -1
- package/dist/core/auth-storage.js +151 -92
- package/dist/core/auth-storage.js.map +1 -1
- package/dist/core/callback-activity.d.ts +27 -0
- package/dist/core/callback-activity.d.ts.map +1 -0
- package/dist/core/callback-activity.js +44 -0
- package/dist/core/callback-activity.js.map +1 -0
- package/dist/core/compaction/branch-summarization.d.ts +4 -1
- package/dist/core/compaction/branch-summarization.d.ts.map +1 -1
- package/dist/core/compaction/branch-summarization.js +4 -3
- package/dist/core/compaction/branch-summarization.js.map +1 -1
- package/dist/core/compaction/compaction-boundary.d.ts +1 -1
- package/dist/core/compaction/compaction-boundary.d.ts.map +1 -1
- package/dist/core/compaction/compaction-boundary.js +10 -23
- package/dist/core/compaction/compaction-boundary.js.map +1 -1
- package/dist/core/compaction/compaction-runner.d.ts +4 -1
- package/dist/core/compaction/compaction-runner.d.ts.map +1 -1
- package/dist/core/compaction/compaction-runner.js +1 -1
- package/dist/core/compaction/compaction-runner.js.map +1 -1
- package/dist/core/compaction/compaction-types.d.ts +3 -2
- package/dist/core/compaction/compaction-types.d.ts.map +1 -1
- package/dist/core/compaction/compaction-types.js.map +1 -1
- package/dist/core/compaction/compaction.d.ts +6 -6
- package/dist/core/compaction/compaction.d.ts.map +1 -1
- package/dist/core/compaction/compaction.js +12 -9
- package/dist/core/compaction/compaction.js.map +1 -1
- package/dist/core/compaction/index.d.ts +1 -0
- package/dist/core/compaction/index.d.ts.map +1 -1
- package/dist/core/compaction/index.js +1 -0
- package/dist/core/compaction/index.js.map +1 -1
- package/dist/core/compaction/range-planner-diagnostics.d.ts +101 -0
- package/dist/core/compaction/range-planner-diagnostics.d.ts.map +1 -0
- package/dist/core/compaction/range-planner-diagnostics.js +116 -0
- package/dist/core/compaction/range-planner-diagnostics.js.map +1 -0
- package/dist/core/compaction/range-planner.d.ts +13 -3
- package/dist/core/compaction/range-planner.d.ts.map +1 -1
- package/dist/core/compaction/range-planner.js +117 -68
- package/dist/core/compaction/range-planner.js.map +1 -1
- package/dist/core/compaction/truncated-range-recovery.d.ts +47 -0
- package/dist/core/compaction/truncated-range-recovery.d.ts.map +1 -0
- package/dist/core/compaction/truncated-range-recovery.js +112 -0
- package/dist/core/compaction/truncated-range-recovery.js.map +1 -0
- package/dist/core/extensions/api-types.d.ts +2 -2
- package/dist/core/extensions/api-types.d.ts.map +1 -1
- package/dist/core/extensions/api-types.js.map +1 -1
- package/dist/core/extensions/context-types.d.ts +23 -1
- package/dist/core/extensions/context-types.d.ts.map +1 -1
- package/dist/core/extensions/context-types.js.map +1 -1
- package/dist/core/extensions/index.d.ts +1 -1
- package/dist/core/extensions/index.d.ts.map +1 -1
- package/dist/core/extensions/index.js.map +1 -1
- package/dist/core/extensions/loader-api.js +2 -2
- package/dist/core/extensions/loader-api.js.map +1 -1
- package/dist/core/extensions/loader-core.d.ts.map +1 -1
- package/dist/core/extensions/loader-core.js +8 -1
- package/dist/core/extensions/loader-core.js.map +1 -1
- package/dist/core/extensions/loader-virtual-modules.d.ts.map +1 -1
- package/dist/core/extensions/loader-virtual-modules.js +9 -6
- package/dist/core/extensions/loader-virtual-modules.js.map +1 -1
- package/dist/core/extensions/message-types.d.ts +17 -0
- package/dist/core/extensions/message-types.d.ts.map +1 -1
- package/dist/core/extensions/message-types.js.map +1 -1
- package/dist/core/extensions/provider-types.d.ts +3 -0
- package/dist/core/extensions/provider-types.d.ts.map +1 -1
- package/dist/core/extensions/provider-types.js.map +1 -1
- package/dist/core/extensions/runner-events.d.ts.map +1 -1
- package/dist/core/extensions/runner-events.js +11 -10
- package/dist/core/extensions/runner-events.js.map +1 -1
- package/dist/core/extensions/runtime-types.d.ts +2 -2
- package/dist/core/extensions/runtime-types.d.ts.map +1 -1
- package/dist/core/extensions/runtime-types.js.map +1 -1
- package/dist/core/extensions/ui-types.d.ts +78 -0
- package/dist/core/extensions/ui-types.d.ts.map +1 -1
- package/dist/core/extensions/ui-types.js.map +1 -1
- package/dist/core/model-registry-auth.d.ts +2 -1
- package/dist/core/model-registry-auth.d.ts.map +1 -1
- package/dist/core/model-registry-auth.js +25 -6
- package/dist/core/model-registry-auth.js.map +1 -1
- package/dist/core/model-registry-builtins.d.ts +3 -2
- package/dist/core/model-registry-builtins.d.ts.map +1 -1
- package/dist/core/model-registry-builtins.js +12 -6
- package/dist/core/model-registry-builtins.js.map +1 -1
- package/dist/core/model-registry-dynamic.d.ts +1 -0
- package/dist/core/model-registry-dynamic.d.ts.map +1 -1
- package/dist/core/model-registry-dynamic.js +53 -13
- package/dist/core/model-registry-dynamic.js.map +1 -1
- package/dist/core/model-registry-loader.d.ts +2 -1
- package/dist/core/model-registry-loader.d.ts.map +1 -1
- package/dist/core/model-registry-loader.js +2 -2
- package/dist/core/model-registry-loader.js.map +1 -1
- package/dist/core/model-registry-types.d.ts +10 -3
- package/dist/core/model-registry-types.d.ts.map +1 -1
- package/dist/core/model-registry-types.js.map +1 -1
- package/dist/core/model-registry.d.ts +15 -1
- package/dist/core/model-registry.d.ts.map +1 -1
- package/dist/core/model-registry.js +214 -30
- package/dist/core/model-registry.js.map +1 -1
- package/dist/core/models-store.d.ts +25 -0
- package/dist/core/models-store.d.ts.map +1 -0
- package/dist/core/models-store.js +73 -0
- package/dist/core/models-store.js.map +1 -0
- package/dist/core/oauth-compat.d.ts +17 -0
- package/dist/core/oauth-compat.d.ts.map +1 -0
- package/dist/core/oauth-compat.js +2 -0
- package/dist/core/oauth-compat.js.map +1 -0
- package/dist/core/oauth-provider-bridge.d.ts +40 -0
- package/dist/core/oauth-provider-bridge.d.ts.map +1 -0
- package/dist/core/oauth-provider-bridge.js +169 -0
- package/dist/core/oauth-provider-bridge.js.map +1 -0
- package/dist/core/output-guard.d.ts +2 -0
- package/dist/core/output-guard.d.ts.map +1 -1
- package/dist/core/output-guard.js +14 -0
- package/dist/core/output-guard.js.map +1 -1
- package/dist/core/remote-catalog-provider.d.ts +5 -0
- package/dist/core/remote-catalog-provider.d.ts.map +1 -0
- package/dist/core/remote-catalog-provider.js +138 -0
- package/dist/core/remote-catalog-provider.js.map +1 -0
- package/dist/core/sdk.d.ts.map +1 -1
- package/dist/core/sdk.js +8 -3
- package/dist/core/sdk.js.map +1 -1
- package/dist/core/session-manager-core.d.ts +1 -1
- package/dist/core/session-manager-core.d.ts.map +1 -1
- package/dist/core/session-manager-core.js +1 -1
- package/dist/core/session-manager-core.js.map +1 -1
- package/dist/core/session-manager-entries.d.ts +1 -1
- package/dist/core/session-manager-entries.d.ts.map +1 -1
- package/dist/core/session-manager-entries.js.map +1 -1
- package/dist/core/session-manager-history.d.ts +2 -2
- package/dist/core/session-manager-history.js +2 -2
- package/dist/core/session-manager-history.js.map +1 -1
- package/dist/core/session-manager-list.d.ts.map +1 -1
- package/dist/core/session-manager-list.js +65 -23
- package/dist/core/session-manager-list.js.map +1 -1
- package/dist/core/session-manager-types.d.ts +3 -2
- package/dist/core/session-manager-types.d.ts.map +1 -1
- package/dist/core/session-manager-types.js.map +1 -1
- package/dist/core/slash-commands.d.ts.map +1 -1
- package/dist/core/slash-commands.js +9 -5
- package/dist/core/slash-commands.js.map +1 -1
- package/dist/core/tools/bash.d.ts.map +1 -1
- package/dist/core/tools/bash.js +2 -3
- package/dist/core/tools/bash.js.map +1 -1
- package/dist/core/tools/find.js +2 -2
- package/dist/core/tools/find.js.map +1 -1
- package/dist/core/tools/grep.js +2 -2
- package/dist/core/tools/grep.js.map +1 -1
- package/dist/core/tools/ls.js +2 -2
- package/dist/core/tools/ls.js.map +1 -1
- package/dist/core/tools/read.d.ts.map +1 -1
- package/dist/core/tools/read.js +4 -3
- package/dist/core/tools/read.js.map +1 -1
- package/dist/core/tools/todos-render.d.ts.map +1 -1
- package/dist/core/tools/todos-render.js +3 -2
- package/dist/core/tools/todos-render.js.map +1 -1
- package/dist/core/tools/tool-definition-wrapper.d.ts.map +1 -1
- package/dist/core/tools/tool-definition-wrapper.js +3 -2
- package/dist/core/tools/tool-definition-wrapper.js.map +1 -1
- package/dist/core/tools/write.js +2 -2
- package/dist/core/tools/write.js.map +1 -1
- package/dist/core/workflow-stage-admission.d.ts +29 -0
- package/dist/core/workflow-stage-admission.d.ts.map +1 -0
- package/dist/core/workflow-stage-admission.js +81 -0
- package/dist/core/workflow-stage-admission.js.map +1 -0
- package/dist/index-extensions.d.ts +1 -1
- package/dist/index-extensions.d.ts.map +1 -1
- package/dist/index-extensions.js.map +1 -1
- package/dist/index.d.ts +4 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -1
- package/dist/index.js.map +1 -1
- package/dist/main-types.d.ts +13 -0
- package/dist/main-types.d.ts.map +1 -0
- package/dist/main-types.js +2 -0
- package/dist/main-types.js.map +1 -0
- package/dist/main.d.ts +2 -5
- package/dist/main.d.ts.map +1 -1
- package/dist/main.js +25 -17
- package/dist/main.js.map +1 -1
- package/dist/modes/interactive/components/assistant-message.d.ts.map +1 -1
- package/dist/modes/interactive/components/assistant-message.js +17 -12
- package/dist/modes/interactive/components/assistant-message.js.map +1 -1
- package/dist/modes/interactive/components/atomic-banner.d.ts +7 -0
- package/dist/modes/interactive/components/atomic-banner.d.ts.map +1 -1
- package/dist/modes/interactive/components/atomic-banner.js +20 -0
- package/dist/modes/interactive/components/atomic-banner.js.map +1 -1
- package/dist/modes/interactive/components/bash-execution.d.ts.map +1 -1
- package/dist/modes/interactive/components/bash-execution.js +5 -3
- package/dist/modes/interactive/components/bash-execution.js.map +1 -1
- package/dist/modes/interactive/components/branch-summary-message.d.ts.map +1 -1
- package/dist/modes/interactive/components/branch-summary-message.js +3 -4
- package/dist/modes/interactive/components/branch-summary-message.js.map +1 -1
- package/dist/modes/interactive/components/chat-message-renderer.d.ts +4 -0
- package/dist/modes/interactive/components/chat-message-renderer.d.ts.map +1 -1
- package/dist/modes/interactive/components/chat-message-renderer.js +4 -0
- package/dist/modes/interactive/components/chat-message-renderer.js.map +1 -1
- package/dist/modes/interactive/components/chat-session-host-events.d.ts.map +1 -1
- package/dist/modes/interactive/components/chat-session-host-events.js +79 -8
- package/dist/modes/interactive/components/chat-session-host-events.js.map +1 -1
- package/dist/modes/interactive/components/chat-session-host-rendering.d.ts.map +1 -1
- package/dist/modes/interactive/components/chat-session-host-rendering.js +4 -2
- package/dist/modes/interactive/components/chat-session-host-rendering.js.map +1 -1
- package/dist/modes/interactive/components/chat-session-host.d.ts +1 -0
- package/dist/modes/interactive/components/chat-session-host.d.ts.map +1 -1
- package/dist/modes/interactive/components/chat-session-host.js +4 -1
- package/dist/modes/interactive/components/chat-session-host.js.map +1 -1
- package/dist/modes/interactive/components/compaction-boundary-message.d.ts.map +1 -1
- package/dist/modes/interactive/components/compaction-boundary-message.js +3 -4
- package/dist/modes/interactive/components/compaction-boundary-message.js.map +1 -1
- package/dist/modes/interactive/components/host-input-form-mount.d.ts +14 -0
- package/dist/modes/interactive/components/host-input-form-mount.d.ts.map +1 -0
- package/dist/modes/interactive/components/host-input-form-mount.js +79 -0
- package/dist/modes/interactive/components/host-input-form-mount.js.map +1 -0
- package/dist/modes/interactive/components/host-input-form.d.ts +52 -0
- package/dist/modes/interactive/components/host-input-form.d.ts.map +1 -0
- package/dist/modes/interactive/components/host-input-form.js +278 -0
- package/dist/modes/interactive/components/host-input-form.js.map +1 -0
- package/dist/modes/interactive/components/host-session-picker.d.ts +46 -0
- package/dist/modes/interactive/components/host-session-picker.d.ts.map +1 -0
- package/dist/modes/interactive/components/host-session-picker.js +183 -0
- package/dist/modes/interactive/components/host-session-picker.js.map +1 -0
- package/dist/modes/interactive/components/index.d.ts +1 -1
- package/dist/modes/interactive/components/index.d.ts.map +1 -1
- package/dist/modes/interactive/components/index.js +1 -1
- package/dist/modes/interactive/components/index.js.map +1 -1
- package/dist/modes/interactive/components/keybinding-hints.d.ts +2 -0
- package/dist/modes/interactive/components/keybinding-hints.d.ts.map +1 -1
- package/dist/modes/interactive/components/keybinding-hints.js +12 -0
- package/dist/modes/interactive/components/keybinding-hints.js.map +1 -1
- package/dist/modes/interactive/components/login-dialog.d.ts +3 -1
- package/dist/modes/interactive/components/login-dialog.d.ts.map +1 -1
- package/dist/modes/interactive/components/login-dialog.js +8 -2
- package/dist/modes/interactive/components/login-dialog.js.map +1 -1
- package/dist/modes/interactive/components/model-selector.d.ts +7 -1
- package/dist/modes/interactive/components/model-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/model-selector.js +57 -10
- package/dist/modes/interactive/components/model-selector.js.map +1 -1
- package/dist/modes/interactive/components/session-selector.d.ts +15 -0
- package/dist/modes/interactive/components/session-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/session-selector.js +35 -3
- package/dist/modes/interactive/components/session-selector.js.map +1 -1
- package/dist/modes/interactive/components/skill-invocation-message.d.ts.map +1 -1
- package/dist/modes/interactive/components/skill-invocation-message.js +3 -2
- package/dist/modes/interactive/components/skill-invocation-message.js.map +1 -1
- package/dist/modes/interactive/components/tool-execution.d.ts.map +1 -1
- package/dist/modes/interactive/components/tool-execution.js +9 -0
- package/dist/modes/interactive/components/tool-execution.js.map +1 -1
- package/dist/modes/interactive/interactive-agent-events.js +24 -10
- package/dist/modes/interactive/interactive-agent-events.js.map +1 -1
- package/dist/modes/interactive/interactive-auth-login.js +7 -1
- package/dist/modes/interactive/interactive-auth-login.js.map +1 -1
- package/dist/modes/interactive/interactive-auth-routing.js +3 -3
- package/dist/modes/interactive/interactive-auth-routing.js.map +1 -1
- package/dist/modes/interactive/interactive-autocomplete.js +49 -0
- package/dist/modes/interactive/interactive-autocomplete.js.map +1 -1
- package/dist/modes/interactive/interactive-bash-compact.js +2 -0
- package/dist/modes/interactive/interactive-bash-compact.js.map +1 -1
- package/dist/modes/interactive/interactive-extension-context.js +14 -0
- package/dist/modes/interactive/interactive-extension-context.js.map +1 -1
- package/dist/modes/interactive/interactive-extension-runtime.js +1 -1
- package/dist/modes/interactive/interactive-extension-runtime.js.map +1 -1
- package/dist/modes/interactive/interactive-global-clear.d.ts +13 -0
- package/dist/modes/interactive/interactive-global-clear.d.ts.map +1 -0
- package/dist/modes/interactive/interactive-global-clear.js +11 -0
- package/dist/modes/interactive/interactive-global-clear.js.map +1 -0
- package/dist/modes/interactive/interactive-input-handling.js +17 -10
- package/dist/modes/interactive/interactive-input-handling.js.map +1 -1
- package/dist/modes/interactive/interactive-mode-base.d.ts +6 -1
- package/dist/modes/interactive/interactive-mode-base.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-mode-base.js +25 -2
- package/dist/modes/interactive/interactive-mode-base.js.map +1 -1
- package/dist/modes/interactive/interactive-mode-deps.d.ts +4 -3
- package/dist/modes/interactive/interactive-mode-deps.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-mode-deps.js +2 -2
- package/dist/modes/interactive/interactive-mode-deps.js.map +1 -1
- package/dist/modes/interactive/interactive-mode-helpers.d.ts +4 -1
- package/dist/modes/interactive/interactive-mode-helpers.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-mode-helpers.js +14 -1
- package/dist/modes/interactive/interactive-mode-helpers.js.map +1 -1
- package/dist/modes/interactive/interactive-mode-surface.d.ts +3 -2
- package/dist/modes/interactive/interactive-mode-surface.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-mode-surface.js.map +1 -1
- package/dist/modes/interactive/interactive-mode-types.d.ts +3 -0
- package/dist/modes/interactive/interactive-mode-types.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-mode-types.js.map +1 -1
- package/dist/modes/interactive/interactive-model-routing.js +7 -4
- package/dist/modes/interactive/interactive-model-routing.js.map +1 -1
- package/dist/modes/interactive/interactive-queueing.js +2 -2
- package/dist/modes/interactive/interactive-queueing.js.map +1 -1
- package/dist/modes/interactive/interactive-render-chat.js +25 -4
- package/dist/modes/interactive/interactive-render-chat.js.map +1 -1
- package/dist/modes/interactive/interactive-session-routing.js +3 -0
- package/dist/modes/interactive/interactive-session-routing.js.map +1 -1
- package/dist/modes/interactive/interactive-slash-commands.js +5 -2
- package/dist/modes/interactive/interactive-slash-commands.js.map +1 -1
- package/dist/modes/interactive/interactive-startup.d.ts +1 -1
- package/dist/modes/interactive/interactive-startup.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-startup.js +22 -9
- package/dist/modes/interactive/interactive-startup.js.map +1 -1
- package/dist/modes/interactive/interactive-terminal-title.d.ts +6 -0
- package/dist/modes/interactive/interactive-terminal-title.d.ts.map +1 -0
- package/dist/modes/interactive/interactive-terminal-title.js +7 -0
- package/dist/modes/interactive/interactive-terminal-title.js.map +1 -0
- package/dist/modes/interactive-engine/activity-watchdog.d.ts +45 -0
- package/dist/modes/interactive-engine/activity-watchdog.d.ts.map +1 -0
- package/dist/modes/interactive-engine/activity-watchdog.js +74 -0
- package/dist/modes/interactive-engine/activity-watchdog.js.map +1 -0
- package/dist/modes/interactive-engine/create-isolated-runtime.d.ts +14 -0
- package/dist/modes/interactive-engine/create-isolated-runtime.d.ts.map +1 -0
- package/dist/modes/interactive-engine/create-isolated-runtime.js +56 -0
- package/dist/modes/interactive-engine/create-isolated-runtime.js.map +1 -0
- package/dist/modes/interactive-engine/engine-args.d.ts +10 -0
- package/dist/modes/interactive-engine/engine-args.d.ts.map +1 -0
- package/dist/modes/interactive-engine/engine-args.js +55 -0
- package/dist/modes/interactive-engine/engine-args.js.map +1 -0
- package/dist/modes/interactive-engine/engine-child-liveness.d.ts +7 -0
- package/dist/modes/interactive-engine/engine-child-liveness.d.ts.map +1 -0
- package/dist/modes/interactive-engine/engine-child-liveness.js +50 -0
- package/dist/modes/interactive-engine/engine-child-liveness.js.map +1 -0
- package/dist/modes/interactive-engine/engine-custom-ui.d.ts +47 -0
- package/dist/modes/interactive-engine/engine-custom-ui.d.ts.map +1 -0
- package/dist/modes/interactive-engine/engine-custom-ui.js +276 -0
- package/dist/modes/interactive-engine/engine-custom-ui.js.map +1 -0
- package/dist/modes/interactive-engine/engine-input-form.d.ts +13 -0
- package/dist/modes/interactive-engine/engine-input-form.d.ts.map +1 -0
- package/dist/modes/interactive-engine/engine-input-form.js +49 -0
- package/dist/modes/interactive-engine/engine-input-form.js.map +1 -0
- package/dist/modes/interactive-engine/engine-monitor.d.ts +18 -0
- package/dist/modes/interactive-engine/engine-monitor.d.ts.map +1 -0
- package/dist/modes/interactive-engine/engine-monitor.js +63 -0
- package/dist/modes/interactive-engine/engine-monitor.js.map +1 -0
- package/dist/modes/interactive-engine/engine-render-service.d.ts +17 -0
- package/dist/modes/interactive-engine/engine-render-service.d.ts.map +1 -0
- package/dist/modes/interactive-engine/engine-render-service.js +150 -0
- package/dist/modes/interactive-engine/engine-render-service.js.map +1 -0
- package/dist/modes/interactive-engine/engine-session-picker.d.ts +22 -0
- package/dist/modes/interactive-engine/engine-session-picker.d.ts.map +1 -0
- package/dist/modes/interactive-engine/engine-session-picker.js +106 -0
- package/dist/modes/interactive-engine/engine-session-picker.js.map +1 -0
- package/dist/modes/interactive-engine/extension-ui-bridge.d.ts +23 -0
- package/dist/modes/interactive-engine/extension-ui-bridge.d.ts.map +1 -0
- package/dist/modes/interactive-engine/extension-ui-bridge.js +126 -0
- package/dist/modes/interactive-engine/extension-ui-bridge.js.map +1 -0
- package/dist/modes/interactive-engine/input-form-host.d.ts +15 -0
- package/dist/modes/interactive-engine/input-form-host.d.ts.map +1 -0
- package/dist/modes/interactive-engine/input-form-host.js +44 -0
- package/dist/modes/interactive-engine/input-form-host.js.map +1 -0
- package/dist/modes/interactive-engine/isolated-runtime.d.ts +75 -0
- package/dist/modes/interactive-engine/isolated-runtime.d.ts.map +1 -0
- package/dist/modes/interactive-engine/isolated-runtime.js +448 -0
- package/dist/modes/interactive-engine/isolated-runtime.js.map +1 -0
- package/dist/modes/interactive-engine/protocol.d.ts +184 -0
- package/dist/modes/interactive-engine/protocol.d.ts.map +1 -0
- package/dist/modes/interactive-engine/protocol.js +254 -0
- package/dist/modes/interactive-engine/protocol.js.map +1 -0
- package/dist/modes/interactive-engine/remote-command-catalog.d.ts +33 -0
- package/dist/modes/interactive-engine/remote-command-catalog.d.ts.map +1 -0
- package/dist/modes/interactive-engine/remote-command-catalog.js +51 -0
- package/dist/modes/interactive-engine/remote-command-catalog.js.map +1 -0
- package/dist/modes/interactive-engine/remote-component.d.ts +16 -0
- package/dist/modes/interactive-engine/remote-component.d.ts.map +1 -0
- package/dist/modes/interactive-engine/remote-component.js +209 -0
- package/dist/modes/interactive-engine/remote-component.js.map +1 -0
- package/dist/modes/interactive-engine/remote-frame-clamp.d.ts +25 -0
- package/dist/modes/interactive-engine/remote-frame-clamp.d.ts.map +1 -0
- package/dist/modes/interactive-engine/remote-frame-clamp.js +43 -0
- package/dist/modes/interactive-engine/remote-frame-clamp.js.map +1 -0
- package/dist/modes/interactive-engine/remote-renderer.d.ts +59 -0
- package/dist/modes/interactive-engine/remote-renderer.d.ts.map +1 -0
- package/dist/modes/interactive-engine/remote-renderer.js +123 -0
- package/dist/modes/interactive-engine/remote-renderer.js.map +1 -0
- package/dist/modes/interactive-engine/session-picker-host.d.ts +25 -0
- package/dist/modes/interactive-engine/session-picker-host.d.ts.map +1 -0
- package/dist/modes/interactive-engine/session-picker-host.js +75 -0
- package/dist/modes/interactive-engine/session-picker-host.js.map +1 -0
- package/dist/modes/interactive-engine/terminal-mode-controller.d.ts +43 -0
- package/dist/modes/interactive-engine/terminal-mode-controller.d.ts.map +1 -0
- package/dist/modes/interactive-engine/terminal-mode-controller.js +109 -0
- package/dist/modes/interactive-engine/terminal-mode-controller.js.map +1 -0
- package/dist/modes/rpc/bounded-writer.d.ts +27 -0
- package/dist/modes/rpc/bounded-writer.d.ts.map +1 -0
- package/dist/modes/rpc/bounded-writer.js +103 -0
- package/dist/modes/rpc/bounded-writer.js.map +1 -0
- package/dist/modes/rpc/jsonl.d.ts +15 -12
- package/dist/modes/rpc/jsonl.d.ts.map +1 -1
- package/dist/modes/rpc/jsonl.js +102 -28
- package/dist/modes/rpc/jsonl.js.map +1 -1
- package/dist/modes/rpc/rpc-client-api.d.ts +83 -0
- package/dist/modes/rpc/rpc-client-api.d.ts.map +1 -0
- package/dist/modes/rpc/rpc-client-api.js +64 -0
- package/dist/modes/rpc/rpc-client-api.js.map +1 -0
- package/dist/modes/rpc/rpc-client-process.d.ts +19 -0
- package/dist/modes/rpc/rpc-client-process.d.ts.map +1 -0
- package/dist/modes/rpc/rpc-client-process.js +79 -0
- package/dist/modes/rpc/rpc-client-process.js.map +1 -0
- package/dist/modes/rpc/rpc-client-waits.d.ts +8 -0
- package/dist/modes/rpc/rpc-client-waits.d.ts.map +1 -0
- package/dist/modes/rpc/rpc-client-waits.js +33 -0
- package/dist/modes/rpc/rpc-client-waits.js.map +1 -0
- package/dist/modes/rpc/rpc-client.d.ts +48 -124
- package/dist/modes/rpc/rpc-client.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-client.js +295 -249
- package/dist/modes/rpc/rpc-client.js.map +1 -1
- package/dist/modes/rpc/rpc-command-handler.d.ts +5 -1
- package/dist/modes/rpc/rpc-command-handler.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-command-handler.js +79 -3
- package/dist/modes/rpc/rpc-command-handler.js.map +1 -1
- package/dist/modes/rpc/rpc-event-buffer.d.ts +11 -0
- package/dist/modes/rpc/rpc-event-buffer.d.ts.map +1 -0
- package/dist/modes/rpc/rpc-event-buffer.js +30 -0
- package/dist/modes/rpc/rpc-event-buffer.js.map +1 -0
- package/dist/modes/rpc/rpc-extension-ui.d.ts +7 -1
- package/dist/modes/rpc/rpc-extension-ui.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-extension-ui.js +54 -32
- package/dist/modes/rpc/rpc-extension-ui.js.map +1 -1
- package/dist/modes/rpc/rpc-input-scheduler.d.ts +16 -0
- package/dist/modes/rpc/rpc-input-scheduler.d.ts.map +1 -0
- package/dist/modes/rpc/rpc-input-scheduler.js +69 -0
- package/dist/modes/rpc/rpc-input-scheduler.js.map +1 -0
- package/dist/modes/rpc/rpc-input.d.ts +2 -1
- package/dist/modes/rpc/rpc-input.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-input.js +4 -9
- package/dist/modes/rpc/rpc-input.js.map +1 -1
- package/dist/modes/rpc/rpc-keybindings-reload.d.ts +27 -0
- package/dist/modes/rpc/rpc-keybindings-reload.d.ts.map +1 -0
- package/dist/modes/rpc/rpc-keybindings-reload.js +69 -0
- package/dist/modes/rpc/rpc-keybindings-reload.js.map +1 -0
- package/dist/modes/rpc/rpc-mode.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-mode.js +63 -8
- package/dist/modes/rpc/rpc-mode.js.map +1 -1
- package/dist/modes/rpc/rpc-output-buffer.d.ts +10 -0
- package/dist/modes/rpc/rpc-output-buffer.d.ts.map +1 -0
- package/dist/modes/rpc/rpc-output-buffer.js +70 -0
- package/dist/modes/rpc/rpc-output-buffer.js.map +1 -0
- package/dist/modes/rpc/rpc-session-binding.d.ts +16 -1
- package/dist/modes/rpc/rpc-session-binding.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-session-binding.js +16 -3
- package/dist/modes/rpc/rpc-session-binding.js.map +1 -1
- package/dist/modes/rpc/rpc-types.d.ts +109 -0
- package/dist/modes/rpc/rpc-types.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-types.js.map +1 -1
- package/dist/package-manager-cli-parser.d.ts +2 -0
- package/dist/package-manager-cli-parser.d.ts.map +1 -1
- package/dist/package-manager-cli-parser.js +24 -5
- package/dist/package-manager-cli-parser.js.map +1 -1
- package/dist/package-manager-cli.d.ts +7 -0
- package/dist/package-manager-cli.d.ts.map +1 -1
- package/dist/package-manager-cli.js +65 -1
- package/dist/package-manager-cli.js.map +1 -1
- package/dist/utils/shell.d.ts +1 -0
- package/dist/utils/shell.d.ts.map +1 -1
- package/dist/utils/shell.js +46 -0
- package/dist/utils/shell.js.map +1 -1
- package/docs/changelog.mdx +11 -0
- package/docs/compaction.md +53 -17
- package/docs/custom-provider.md +24 -5
- package/docs/development.md +9 -7
- package/docs/docs.json +1 -0
- package/docs/extensions.md +30 -16
- package/docs/intercom.md +489 -0
- package/docs/json.md +1 -1
- package/docs/keybindings.md +1 -1
- package/docs/packages.md +1 -0
- package/docs/quickstart.md +11 -5
- package/docs/rpc.md +9 -7
- package/docs/sdk.md +6 -0
- package/docs/session-format.md +7 -6
- package/docs/sessions.md +4 -2
- package/docs/settings.md +2 -2
- package/docs/subagents.md +7 -2
- package/docs/tui.md +61 -2
- package/docs/usage.md +6 -5
- package/docs/workflows.md +2572 -1379
- package/examples/extensions/handoff.ts +1 -1
- package/examples/extensions/qna.ts +1 -1
- package/examples/extensions/summarize.ts +1 -1
- package/npm-shrinkwrap.json +225 -76
- package/package.json +7 -6
- package/dist/builtin/workflows/src/durable/file-backend.ts +0 -439
- package/dist/builtin/workflows/src/durable/file-lock.ts +0 -153
- package/dist/builtin/workflows/src/durable/file-state.ts +0 -104
- package/dist/builtin/workflows/src/extension/runtime-direct.ts +0 -96
- package/dist/builtin/workflows/src/extension/workflow-tool-helpers.ts +0 -66
- package/dist/builtin/workflows/src/runs/foreground/executor-direct-output.ts +0 -91
- package/dist/builtin/workflows/src/runs/foreground/executor-direct.ts +0 -282
- package/dist/builtin/workflows/src/shared/resumable-workflow-notices.ts +0 -43
- package/dist/builtin/workflows/src/tui/session-confirm.ts +0 -299
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"session-picker-host.js","sourceRoot":"","sources":["../../../src/modes/interactive-engine/session-picker-host.ts"],"names":[],"mappings":"AACA,OAAO,EACN,sBAAsB,EACtB,wBAAwB,GAExB,MAAM,kDAAkD,CAAC;AAI1D;;;;;;;;;;GAUG;AACH,MAAM,OAAO,2BAA2B;IAOvC,YAAY,OAAmC,EAAE,EAAsB;QANtD,YAAO,GAAG,IAAI,GAAG,EAAkC,CAAC;QAOpE,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACvB,IAAI,CAAC,EAAE,GAAG,EAAE,CAAC;QACb,IAAI,CAAC,WAAW,GAAG,OAAO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E,cAAuB;QAC1F,IAAI,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,WAAW,CAAC;YAAE,OAAO;QAC1C,MAAM,KAAK,GAAG,sBAAsB,CAAC,IAAI,CAAC,EAAE,EAAE,QAAQ,CAAC,GAAG,CAAC,wBAAwB,CAAC,EAAE,cAAc,EAAE;YACrG,QAAQ,EAAE,CAAC,IAAI,EAAE,EAAE;gBAClB,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC;gBACjC,IAAI,CAAC,OAAO,CAAC,iBAAiB,CAAC,EAAE,IAAI,EAAE,8BAA8B,EAAE,WAAW,EAAE,IAAI,EAAE,CAAC,CAAC;YAC7F,CAAC;YACD,QAAQ,EAAE,GAAG,EAAE;gBACd,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC;gBACjC,IAAI,CAAC,OAAO,CAAC,iBAAiB,CAAC,EAAE,IAAI,EAAE,8BAA8B,EAAE,WAAW,EAAE,CAAC,CAAC;YACvF,CAAC;YACD,QAAQ,EAAE,CAAC,IAAI,EAAE,EAAE;gBAClB,IAAI,CAAC,OAAO,CAAC,iBAAiB,CAAC,EAAE,IAAI,EAAE,8BAA8B,EAAE,WAAW,EAAE,IAAI,EAAE,CAAC,CAAC;YAC7F,CAAC;SACD,CAAC,CAAC;QACH,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,WAAW,EAAE,KAAK,CAAC,CAAC;IACtC,CAAC;IAEO,UAAU;QACjB,KAAK,MAAM,KAAK,IAAI,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE;YAAE,KAAK,CAAC,KAAK,EAAE,CAAC;QACzD,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,CAAC;IACtB,CAAC;CACD","sourcesContent":["import type { ExtensionUIContext, HostSessionPickerRow } from \"../../core/extensions/index.ts\";\nimport {\n\tmountHostSessionPicker,\n\tsessionInfoFromPickerRow,\n\ttype HostSessionPickerMount,\n} from \"../interactive/components/host-session-picker.ts\";\nimport type { IsolatedInteractiveRuntime } from \"./isolated-runtime.ts\";\nimport type { InteractiveEngineMessage } from \"./protocol.ts\";\n\n/**\n * Host-side half of the engine session picker channel.\n *\n * Mounts a REAL `SessionSelectorComponent` in the terminal host when the engine\n * child opens a picker, so arrow-key navigation, search, and repaints are\n * zero-IPC (unlike remote-rendered `ctx.ui.custom` components, which round-trip\n * every keypress). Only semantic events cross the protocol: the child pushes\n * open/update/error/close, the host sends select/cancel/delete. Deletion is\n * child-owned — the host never removes a row locally; it waits for the child's\n * `update` (row removed) or `error` reply.\n */\nexport class SessionPickerHostController {\n\tprivate readonly mounted = new Map<string, HostSessionPickerMount>();\n\tprivate readonly unsubscribe: () => void;\n\n\tprivate readonly runtime: IsolatedInteractiveRuntime;\n\tprivate readonly ui: ExtensionUIContext;\n\n\tconstructor(runtime: IsolatedInteractiveRuntime, ui: ExtensionUIContext) {\n\t\tthis.runtime = runtime;\n\t\tthis.ui = ui;\n\t\tthis.unsubscribe = runtime.onEngineMessage((message) => this.handleMessage(message));\n\t}\n\n\tdispose(): void {\n\t\tthis.unsubscribe();\n\t\tthis.disposeAll();\n\t}\n\n\tprivate handleMessage(message: InteractiveEngineMessage): void {\n\t\tswitch (message.type) {\n\t\t\tcase \"engine_ready\":\n\t\t\t\t// A fresh engine generation replaced the child: its pickers are gone\n\t\t\t\t// and the componentIds are meaningless to the new generation, so\n\t\t\t\t// unmount silently (no cancel command).\n\t\t\t\tthis.disposeAll();\n\t\t\t\tbreak;\n\t\t\tcase \"engine_session_picker_open\":\n\t\t\t\tthis.open(message.componentId, message.sessions, message.showRenameHint === true);\n\t\t\t\tbreak;\n\t\t\tcase \"engine_session_picker_update\":\n\t\t\t\tthis.mounted.get(message.componentId)?.setRows(message.sessions.map(sessionInfoFromPickerRow));\n\t\t\t\tbreak;\n\t\t\tcase \"engine_session_picker_error\":\n\t\t\t\tthis.mounted.get(message.componentId)?.showError(message.message);\n\t\t\t\tbreak;\n\t\t\tcase \"engine_session_picker_close\": {\n\t\t\t\tconst mount = this.mounted.get(message.componentId);\n\t\t\t\tif (!mount) break;\n\t\t\t\tthis.mounted.delete(message.componentId);\n\t\t\t\tmount.close();\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate open(componentId: string, sessions: HostSessionPickerRow[], showRenameHint: boolean): void {\n\t\tif (this.mounted.has(componentId)) return;\n\t\tconst mount = mountHostSessionPicker(this.ui, sessions.map(sessionInfoFromPickerRow), showRenameHint, {\n\t\t\tonSelect: (path) => {\n\t\t\t\tthis.mounted.delete(componentId);\n\t\t\t\tthis.runtime.sendEngineCommand({ type: \"engine_session_picker_select\", componentId, path });\n\t\t\t},\n\t\t\tonCancel: () => {\n\t\t\t\tthis.mounted.delete(componentId);\n\t\t\t\tthis.runtime.sendEngineCommand({ type: \"engine_session_picker_cancel\", componentId });\n\t\t\t},\n\t\t\tonDelete: (path) => {\n\t\t\t\tthis.runtime.sendEngineCommand({ type: \"engine_session_picker_delete\", componentId, path });\n\t\t\t},\n\t\t});\n\t\tthis.mounted.set(componentId, mount);\n\t}\n\n\tprivate disposeAll(): void {\n\t\tfor (const mount of this.mounted.values()) mount.close();\n\t\tthis.mounted.clear();\n\t}\n}\n"]}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import type { EngineTerminalControl } from "./protocol.ts";
|
|
2
|
+
/**
|
|
3
|
+
* Host-side terminal-mode arbiter for remote custom components.
|
|
4
|
+
*
|
|
5
|
+
* Remote components (running in the engine child) cannot touch the host TTY —
|
|
6
|
+
* their stdout is the JSONL transport, not a terminal. Instead they send typed
|
|
7
|
+
* {@link EngineTerminalControl} intents; this controller owns the concrete
|
|
8
|
+
* escape sequences and applies them to the real host terminal associated with
|
|
9
|
+
* the mounted component. Never a raw byte channel: only the two allowlisted
|
|
10
|
+
* modes below can ever reach the terminal.
|
|
11
|
+
*
|
|
12
|
+
* Guarantees:
|
|
13
|
+
* - Controls that arrive before the component mounts are buffered and flushed
|
|
14
|
+
* on mount (the child enables mouse reporting inside the overlay factory,
|
|
15
|
+
* which runs before the mount `engine_custom_open` on the wire).
|
|
16
|
+
* - Every mode a component turns on is reset to its safe default when that
|
|
17
|
+
* component unmounts, or when the whole controller is reset (engine
|
|
18
|
+
* crash / restart / generation replacement / host shutdown).
|
|
19
|
+
* - State is component-scoped: a stale child cannot reset or alter a mode
|
|
20
|
+
* owned by the currently mounted component.
|
|
21
|
+
*/
|
|
22
|
+
export declare const HOST_MOUSE_SCROLL_TRACKING_ON = "\u001B[?1000h\u001B[?1002h\u001B[?1006h";
|
|
23
|
+
export declare const HOST_MOUSE_SCROLL_TRACKING_OFF = "\u001B[?1006l\u001B[?1002l\u001B[?1000l";
|
|
24
|
+
export declare const HOST_TERMINAL_AUTOWRAP_ON = "\u001B[?7h";
|
|
25
|
+
export declare const HOST_TERMINAL_AUTOWRAP_OFF = "\u001B[?7l";
|
|
26
|
+
export interface HostTerminalWriter {
|
|
27
|
+
write(data: string): void;
|
|
28
|
+
}
|
|
29
|
+
export declare class TerminalModeController {
|
|
30
|
+
private readonly components;
|
|
31
|
+
/** Apply (or buffer) a typed control for a component. */
|
|
32
|
+
applyControl(componentId: string, control: EngineTerminalControl): void;
|
|
33
|
+
/** Register the host terminal for a component and flush buffered controls. */
|
|
34
|
+
onMount(componentId: string, terminal: HostTerminalWriter): void;
|
|
35
|
+
/** Reset and forget a single component's terminal modes. */
|
|
36
|
+
onUnmount(componentId: string): void;
|
|
37
|
+
/** Reset every component (engine crash/restart/generation swap/shutdown). */
|
|
38
|
+
resetAll(): void;
|
|
39
|
+
private ensure;
|
|
40
|
+
private write;
|
|
41
|
+
private reset;
|
|
42
|
+
}
|
|
43
|
+
//# sourceMappingURL=terminal-mode-controller.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"terminal-mode-controller.d.ts","sourceRoot":"","sources":["../../../src/modes/interactive-engine/terminal-mode-controller.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,eAAe,CAAC;AAE3D;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,eAAO,MAAM,6BAA6B,4CAAsC,CAAC;AACjF,eAAO,MAAM,8BAA8B,4CAAsC,CAAC;AAClF,eAAO,MAAM,yBAAyB,eAAa,CAAC;AACpD,eAAO,MAAM,0BAA0B,eAAa,CAAC;AAErD,MAAM,WAAW,kBAAkB;IAClC,KAAK,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;CAC1B;AAYD,qBAAa,sBAAsB;IAClC,OAAO,CAAC,QAAQ,CAAC,UAAU,CAA6C;IAExE,yDAAyD;IACzD,YAAY,CAAC,WAAW,EAAE,MAAM,EAAE,OAAO,EAAE,qBAAqB,GAAG,IAAI,CActE;IAED,8EAA8E;IAC9E,OAAO,CAAC,WAAW,EAAE,MAAM,EAAE,QAAQ,EAAE,kBAAkB,GAAG,IAAI,CAI/D;IAED,4DAA4D;IAC5D,SAAS,CAAC,WAAW,EAAE,MAAM,GAAG,IAAI,CAKnC;IAED,6EAA6E;IAC7E,QAAQ,IAAI,IAAI,CAGf;IAED,OAAO,CAAC,MAAM;IASd,OAAO,CAAC,KAAK;IAeb,OAAO,CAAC,KAAK;CAUb"}
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Host-side terminal-mode arbiter for remote custom components.
|
|
3
|
+
*
|
|
4
|
+
* Remote components (running in the engine child) cannot touch the host TTY —
|
|
5
|
+
* their stdout is the JSONL transport, not a terminal. Instead they send typed
|
|
6
|
+
* {@link EngineTerminalControl} intents; this controller owns the concrete
|
|
7
|
+
* escape sequences and applies them to the real host terminal associated with
|
|
8
|
+
* the mounted component. Never a raw byte channel: only the two allowlisted
|
|
9
|
+
* modes below can ever reach the terminal.
|
|
10
|
+
*
|
|
11
|
+
* Guarantees:
|
|
12
|
+
* - Controls that arrive before the component mounts are buffered and flushed
|
|
13
|
+
* on mount (the child enables mouse reporting inside the overlay factory,
|
|
14
|
+
* which runs before the mount `engine_custom_open` on the wire).
|
|
15
|
+
* - Every mode a component turns on is reset to its safe default when that
|
|
16
|
+
* component unmounts, or when the whole controller is reset (engine
|
|
17
|
+
* crash / restart / generation replacement / host shutdown).
|
|
18
|
+
* - State is component-scoped: a stale child cannot reset or alter a mode
|
|
19
|
+
* owned by the currently mounted component.
|
|
20
|
+
*/
|
|
21
|
+
export const HOST_MOUSE_SCROLL_TRACKING_ON = "\x1b[?1000h\x1b[?1002h\x1b[?1006h";
|
|
22
|
+
export const HOST_MOUSE_SCROLL_TRACKING_OFF = "\x1b[?1006l\x1b[?1002l\x1b[?1000l";
|
|
23
|
+
export const HOST_TERMINAL_AUTOWRAP_ON = "\x1b[?7h";
|
|
24
|
+
export const HOST_TERMINAL_AUTOWRAP_OFF = "\x1b[?7l";
|
|
25
|
+
export class TerminalModeController {
|
|
26
|
+
constructor() {
|
|
27
|
+
this.components = new Map();
|
|
28
|
+
}
|
|
29
|
+
/** Apply (or buffer) a typed control for a component. */
|
|
30
|
+
applyControl(componentId, control) {
|
|
31
|
+
let state = this.components.get(componentId);
|
|
32
|
+
if (!state) {
|
|
33
|
+
// A control from an unmounted (late/stale) component that only restores
|
|
34
|
+
// the default mode has nothing to reset — ignore it rather than leak a
|
|
35
|
+
// dead entry or let a stale child perturb terminal-mode bookkeeping.
|
|
36
|
+
if (isDefaultControl(control))
|
|
37
|
+
return;
|
|
38
|
+
state = this.ensure(componentId);
|
|
39
|
+
}
|
|
40
|
+
if (!state.terminal) {
|
|
41
|
+
state.buffered.push(control);
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
this.write(state, control);
|
|
45
|
+
}
|
|
46
|
+
/** Register the host terminal for a component and flush buffered controls. */
|
|
47
|
+
onMount(componentId, terminal) {
|
|
48
|
+
const state = this.ensure(componentId);
|
|
49
|
+
state.terminal = terminal;
|
|
50
|
+
for (const control of state.buffered.splice(0))
|
|
51
|
+
this.write(state, control);
|
|
52
|
+
}
|
|
53
|
+
/** Reset and forget a single component's terminal modes. */
|
|
54
|
+
onUnmount(componentId) {
|
|
55
|
+
const state = this.components.get(componentId);
|
|
56
|
+
if (!state)
|
|
57
|
+
return;
|
|
58
|
+
this.reset(state);
|
|
59
|
+
this.components.delete(componentId);
|
|
60
|
+
}
|
|
61
|
+
/** Reset every component (engine crash/restart/generation swap/shutdown). */
|
|
62
|
+
resetAll() {
|
|
63
|
+
for (const state of this.components.values())
|
|
64
|
+
this.reset(state);
|
|
65
|
+
this.components.clear();
|
|
66
|
+
}
|
|
67
|
+
ensure(componentId) {
|
|
68
|
+
let state = this.components.get(componentId);
|
|
69
|
+
if (!state) {
|
|
70
|
+
state = { mouse: false, autowrapDisabled: false, buffered: [] };
|
|
71
|
+
this.components.set(componentId, state);
|
|
72
|
+
}
|
|
73
|
+
return state;
|
|
74
|
+
}
|
|
75
|
+
write(state, control) {
|
|
76
|
+
const terminal = state.terminal;
|
|
77
|
+
if (!terminal)
|
|
78
|
+
return;
|
|
79
|
+
if (control.kind === "mouse-scroll-tracking") {
|
|
80
|
+
if (control.enabled === state.mouse)
|
|
81
|
+
return;
|
|
82
|
+
state.mouse = control.enabled;
|
|
83
|
+
terminal.write(control.enabled ? HOST_MOUSE_SCROLL_TRACKING_ON : HOST_MOUSE_SCROLL_TRACKING_OFF);
|
|
84
|
+
return;
|
|
85
|
+
}
|
|
86
|
+
const disabled = !control.enabled;
|
|
87
|
+
if (disabled === state.autowrapDisabled)
|
|
88
|
+
return;
|
|
89
|
+
state.autowrapDisabled = disabled;
|
|
90
|
+
terminal.write(control.enabled ? HOST_TERMINAL_AUTOWRAP_ON : HOST_TERMINAL_AUTOWRAP_OFF);
|
|
91
|
+
}
|
|
92
|
+
reset(state) {
|
|
93
|
+
const terminal = state.terminal;
|
|
94
|
+
if (terminal) {
|
|
95
|
+
if (state.mouse)
|
|
96
|
+
terminal.write(HOST_MOUSE_SCROLL_TRACKING_OFF);
|
|
97
|
+
if (state.autowrapDisabled)
|
|
98
|
+
terminal.write(HOST_TERMINAL_AUTOWRAP_ON);
|
|
99
|
+
}
|
|
100
|
+
state.mouse = false;
|
|
101
|
+
state.autowrapDisabled = false;
|
|
102
|
+
state.buffered = [];
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
/** Whether a control merely restores a mode's safe default (mouse off / autowrap on). */
|
|
106
|
+
function isDefaultControl(control) {
|
|
107
|
+
return control.kind === "mouse-scroll-tracking" ? !control.enabled : control.enabled;
|
|
108
|
+
}
|
|
109
|
+
//# sourceMappingURL=terminal-mode-controller.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"terminal-mode-controller.js","sourceRoot":"","sources":["../../../src/modes/interactive-engine/terminal-mode-controller.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,MAAM,CAAC,MAAM,6BAA6B,GAAG,mCAAmC,CAAC;AACjF,MAAM,CAAC,MAAM,8BAA8B,GAAG,mCAAmC,CAAC;AAClF,MAAM,CAAC,MAAM,yBAAyB,GAAG,UAAU,CAAC;AACpD,MAAM,CAAC,MAAM,0BAA0B,GAAG,UAAU,CAAC;AAgBrD,MAAM,OAAO,sBAAsB;IAAnC;QACkB,eAAU,GAAG,IAAI,GAAG,EAAkC,CAAC;IA0EzE,CAAC;IAxEA,yDAAyD;IACzD,YAAY,CAAC,WAAmB,EAAE,OAA8B;QAC/D,IAAI,KAAK,GAAG,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC;QAC7C,IAAI,CAAC,KAAK,EAAE,CAAC;YACZ,wEAAwE;YACxE,uEAAuE;YACvE,qEAAqE;YACrE,IAAI,gBAAgB,CAAC,OAAO,CAAC;gBAAE,OAAO;YACtC,KAAK,GAAG,IAAI,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC;QAClC,CAAC;QACD,IAAI,CAAC,KAAK,CAAC,QAAQ,EAAE,CAAC;YACrB,KAAK,CAAC,QAAQ,CAAC,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;AACzF,SAAS,gBAAgB,CAAC,OAA8B;IACvD,OAAO,OAAO,CAAC,IAAI,KAAK,uBAAuB,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC;AACtF,CAAC","sourcesContent":["import type { EngineTerminalControl } from \"./protocol.ts\";\n\n/**\n * Host-side terminal-mode arbiter for remote custom components.\n *\n * Remote components (running in the engine child) cannot touch the host TTY —\n * their stdout is the JSONL transport, not a terminal. Instead they send typed\n * {@link EngineTerminalControl} intents; this controller owns the concrete\n * escape sequences and applies them to the real host terminal associated with\n * the mounted component. Never a raw byte channel: only the two allowlisted\n * modes below can ever reach the terminal.\n *\n * Guarantees:\n * - Controls that arrive before the component mounts are buffered and flushed\n * on mount (the child enables mouse reporting inside the overlay factory,\n * which runs before the mount `engine_custom_open` on the wire).\n * - Every mode a component turns on is reset to its safe default when that\n * component unmounts, or when the whole controller is reset (engine\n * crash / restart / generation replacement / host shutdown).\n * - State is component-scoped: a stale child cannot reset or alter a mode\n * owned by the currently mounted component.\n */\n\nexport const HOST_MOUSE_SCROLL_TRACKING_ON = \"\\x1b[?1000h\\x1b[?1002h\\x1b[?1006h\";\nexport const HOST_MOUSE_SCROLL_TRACKING_OFF = \"\\x1b[?1006l\\x1b[?1002l\\x1b[?1000l\";\nexport const HOST_TERMINAL_AUTOWRAP_ON = \"\\x1b[?7h\";\nexport const HOST_TERMINAL_AUTOWRAP_OFF = \"\\x1b[?7l\";\n\nexport interface HostTerminalWriter {\n\twrite(data: string): void;\n}\n\ninterface ComponentTerminalState {\n\tterminal?: HostTerminalWriter;\n\t/** Component currently has mouse-scroll reporting enabled. */\n\tmouse: boolean;\n\t/** Component currently has autowrap disabled (its non-default state). */\n\tautowrapDisabled: boolean;\n\t/** Controls received before the component mounted. */\n\tbuffered: EngineTerminalControl[];\n}\n\nexport class TerminalModeController {\n\tprivate readonly components = new Map<string, ComponentTerminalState>();\n\n\t/** Apply (or buffer) a typed control for a component. */\n\tapplyControl(componentId: string, control: EngineTerminalControl): void {\n\t\tlet state = this.components.get(componentId);\n\t\tif (!state) {\n\t\t\t// A control from an unmounted (late/stale) component that only restores\n\t\t\t// the default mode has nothing to reset — ignore it rather than leak a\n\t\t\t// dead entry or let a stale child perturb terminal-mode bookkeeping.\n\t\t\tif (isDefaultControl(control)) return;\n\t\t\tstate = this.ensure(componentId);\n\t\t}\n\t\tif (!state.terminal) {\n\t\t\tstate.buffered.push(control);\n\t\t\treturn;\n\t\t}\n\t\tthis.write(state, control);\n\t}\n\n\t/** Register the host terminal for a component and flush buffered controls. */\n\tonMount(componentId: string, terminal: HostTerminalWriter): void {\n\t\tconst state = this.ensure(componentId);\n\t\tstate.terminal = terminal;\n\t\tfor (const control of state.buffered.splice(0)) this.write(state, control);\n\t}\n\n\t/** Reset and forget a single component's terminal modes. */\n\tonUnmount(componentId: string): void {\n\t\tconst state = this.components.get(componentId);\n\t\tif (!state) return;\n\t\tthis.reset(state);\n\t\tthis.components.delete(componentId);\n\t}\n\n\t/** Reset every component (engine crash/restart/generation swap/shutdown). */\n\tresetAll(): void {\n\t\tfor (const state of this.components.values()) this.reset(state);\n\t\tthis.components.clear();\n\t}\n\n\tprivate ensure(componentId: string): ComponentTerminalState {\n\t\tlet state = this.components.get(componentId);\n\t\tif (!state) {\n\t\t\tstate = { mouse: false, autowrapDisabled: false, buffered: [] };\n\t\t\tthis.components.set(componentId, state);\n\t\t}\n\t\treturn state;\n\t}\n\n\tprivate write(state: ComponentTerminalState, control: EngineTerminalControl): void {\n\t\tconst terminal = state.terminal;\n\t\tif (!terminal) return;\n\t\tif (control.kind === \"mouse-scroll-tracking\") {\n\t\t\tif (control.enabled === state.mouse) return;\n\t\t\tstate.mouse = control.enabled;\n\t\t\tterminal.write(control.enabled ? HOST_MOUSE_SCROLL_TRACKING_ON : HOST_MOUSE_SCROLL_TRACKING_OFF);\n\t\t\treturn;\n\t\t}\n\t\tconst disabled = !control.enabled;\n\t\tif (disabled === state.autowrapDisabled) return;\n\t\tstate.autowrapDisabled = disabled;\n\t\tterminal.write(control.enabled ? HOST_TERMINAL_AUTOWRAP_ON : HOST_TERMINAL_AUTOWRAP_OFF);\n\t}\n\n\tprivate reset(state: ComponentTerminalState): void {\n\t\tconst terminal = state.terminal;\n\t\tif (terminal) {\n\t\t\tif (state.mouse) terminal.write(HOST_MOUSE_SCROLL_TRACKING_OFF);\n\t\t\tif (state.autowrapDisabled) terminal.write(HOST_TERMINAL_AUTOWRAP_ON);\n\t\t}\n\t\tstate.mouse = false;\n\t\tstate.autowrapDisabled = false;\n\t\tstate.buffered = [];\n\t}\n}\n\n/** Whether a control merely restores a mode's safe default (mouse off / autowrap on). */\nfunction isDefaultControl(control: EngineTerminalControl): boolean {\n\treturn control.kind === \"mouse-scroll-tracking\" ? !control.enabled : control.enabled;\n}\n"]}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { Writable } from "node:stream";
|
|
2
|
+
export interface BoundedWriterOptions {
|
|
3
|
+
maxFrameBytes: number;
|
|
4
|
+
maxQueuedBytes: number;
|
|
5
|
+
}
|
|
6
|
+
/** A byte-accounted, one-write-at-a-time stream writer with replaceable updates. */
|
|
7
|
+
export declare class BoundedWriter {
|
|
8
|
+
private readonly critical;
|
|
9
|
+
private readonly coalesced;
|
|
10
|
+
private readonly capacityWaiters;
|
|
11
|
+
private queuedBytes;
|
|
12
|
+
private pumping;
|
|
13
|
+
private closedError;
|
|
14
|
+
private readonly stream;
|
|
15
|
+
private readonly options;
|
|
16
|
+
constructor(stream: Writable, options: BoundedWriterOptions);
|
|
17
|
+
get pendingBytes(): number;
|
|
18
|
+
write(text: string): Promise<void>;
|
|
19
|
+
offerLatest(key: string, text: string): boolean;
|
|
20
|
+
close(error?: Error): void;
|
|
21
|
+
private frame;
|
|
22
|
+
private next;
|
|
23
|
+
private pump;
|
|
24
|
+
private runPump;
|
|
25
|
+
private wakeCapacityWaiters;
|
|
26
|
+
}
|
|
27
|
+
//# sourceMappingURL=bounded-writer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bounded-writer.d.ts","sourceRoot":"","sources":["../../../src/modes/rpc/bounded-writer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAS5C,MAAM,WAAW,oBAAoB;IACpC,aAAa,EAAE,MAAM,CAAC;IACtB,cAAc,EAAE,MAAM,CAAC;CACvB;AAED,oFAAoF;AACpF,qBAAa,aAAa;IACzB,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAsB;IAC/C,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAmC;IAC7D,OAAO,CAAC,QAAQ,CAAC,eAAe,CAAyB;IACzD,OAAO,CAAC,WAAW,CAAK;IACxB,OAAO,CAAC,OAAO,CAAS;IACxB,OAAO,CAAC,WAAW,CAAoB;IAEvC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAW;IAClC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAuB;IAE/C,YACC,MAAM,EAAE,QAAQ,EAChB,OAAO,EAAE,oBAAoB,EAI7B;IAED,IAAI,YAAY,IAAI,MAAM,CAA6B;IAEjD,KAAK,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAWvC;IAED,WAAW,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAW9C;IAED,KAAK,CAAC,KAAK,QAAiC,GAAG,IAAI,CAOlD;IAED,OAAO,CAAC,KAAK;IASb,OAAO,CAAC,IAAI;IASZ,OAAO,CAAC,IAAI;YAME,OAAO;IAoBrB,OAAO,CAAC,mBAAmB;CAI3B"}
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
/** A byte-accounted, one-write-at-a-time stream writer with replaceable updates. */
|
|
2
|
+
export class BoundedWriter {
|
|
3
|
+
constructor(stream, options) {
|
|
4
|
+
this.critical = [];
|
|
5
|
+
this.coalesced = new Map();
|
|
6
|
+
this.capacityWaiters = new Set();
|
|
7
|
+
this.queuedBytes = 0;
|
|
8
|
+
this.pumping = false;
|
|
9
|
+
this.stream = stream;
|
|
10
|
+
this.options = options;
|
|
11
|
+
}
|
|
12
|
+
get pendingBytes() { return this.queuedBytes; }
|
|
13
|
+
async write(text) {
|
|
14
|
+
const bytes = this.frame(text);
|
|
15
|
+
while (!this.closedError && this.queuedBytes + bytes.length > this.options.maxQueuedBytes) {
|
|
16
|
+
await new Promise((resolve) => this.capacityWaiters.add(resolve));
|
|
17
|
+
}
|
|
18
|
+
if (this.closedError)
|
|
19
|
+
throw this.closedError;
|
|
20
|
+
await new Promise((resolve, reject) => {
|
|
21
|
+
this.critical.push({ bytes, resolve, reject });
|
|
22
|
+
this.queuedBytes += bytes.length;
|
|
23
|
+
this.pump();
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
offerLatest(key, text) {
|
|
27
|
+
if (this.closedError)
|
|
28
|
+
return false;
|
|
29
|
+
const bytes = this.frame(text);
|
|
30
|
+
const previous = this.coalesced.get(key);
|
|
31
|
+
const nextBytes = this.queuedBytes - (previous?.bytes.length ?? 0) + bytes.length;
|
|
32
|
+
if (nextBytes > this.options.maxQueuedBytes)
|
|
33
|
+
return false;
|
|
34
|
+
if (previous)
|
|
35
|
+
this.queuedBytes -= previous.bytes.length;
|
|
36
|
+
this.coalesced.set(key, { bytes, key });
|
|
37
|
+
this.queuedBytes += bytes.length;
|
|
38
|
+
this.pump();
|
|
39
|
+
return true;
|
|
40
|
+
}
|
|
41
|
+
close(error = new Error("RPC writer closed")) {
|
|
42
|
+
if (this.closedError)
|
|
43
|
+
return;
|
|
44
|
+
this.closedError = error;
|
|
45
|
+
for (const frame of this.critical.splice(0))
|
|
46
|
+
frame.reject?.(error);
|
|
47
|
+
this.coalesced.clear();
|
|
48
|
+
this.queuedBytes = 0;
|
|
49
|
+
this.wakeCapacityWaiters();
|
|
50
|
+
}
|
|
51
|
+
frame(text) {
|
|
52
|
+
const bytes = Buffer.from(text, "utf8");
|
|
53
|
+
const payloadBytes = bytes.at(-1) === 0x0a ? bytes.length - 1 : bytes.length;
|
|
54
|
+
if (payloadBytes > this.options.maxFrameBytes) {
|
|
55
|
+
throw new Error(`RPC frame exceeds ${this.options.maxFrameBytes} bytes`);
|
|
56
|
+
}
|
|
57
|
+
return bytes;
|
|
58
|
+
}
|
|
59
|
+
next() {
|
|
60
|
+
const critical = this.critical.shift();
|
|
61
|
+
if (critical)
|
|
62
|
+
return critical;
|
|
63
|
+
const entry = this.coalesced.entries().next().value;
|
|
64
|
+
if (!entry)
|
|
65
|
+
return undefined;
|
|
66
|
+
this.coalesced.delete(entry[0]);
|
|
67
|
+
return entry[1];
|
|
68
|
+
}
|
|
69
|
+
pump() {
|
|
70
|
+
if (this.pumping)
|
|
71
|
+
return;
|
|
72
|
+
this.pumping = true;
|
|
73
|
+
void this.runPump();
|
|
74
|
+
}
|
|
75
|
+
async runPump() {
|
|
76
|
+
try {
|
|
77
|
+
let frame;
|
|
78
|
+
while (!this.closedError && (frame = this.next())) {
|
|
79
|
+
this.queuedBytes -= frame.bytes.length;
|
|
80
|
+
this.wakeCapacityWaiters();
|
|
81
|
+
await new Promise((resolve, reject) => {
|
|
82
|
+
this.stream.write(frame.bytes, (error) => error ? reject(error) : resolve());
|
|
83
|
+
});
|
|
84
|
+
frame.resolve?.();
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
catch (error) {
|
|
88
|
+
const failure = error instanceof Error ? error : new Error(String(error));
|
|
89
|
+
this.close(failure);
|
|
90
|
+
}
|
|
91
|
+
finally {
|
|
92
|
+
this.pumping = false;
|
|
93
|
+
if (!this.closedError && (this.critical.length > 0 || this.coalesced.size > 0))
|
|
94
|
+
this.pump();
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
wakeCapacityWaiters() {
|
|
98
|
+
for (const resolve of this.capacityWaiters)
|
|
99
|
+
resolve();
|
|
100
|
+
this.capacityWaiters.clear();
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
//# sourceMappingURL=bounded-writer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bounded-writer.js","sourceRoot":"","sources":["../../../src/modes/rpc/bounded-writer.ts"],"names":[],"mappings":"AAcA,oFAAoF;AACpF,MAAM,OAAO,aAAa;IAWzB,YACC,MAAgB,EAChB,OAA6B;QAZb,aAAQ,GAAmB,EAAE,CAAC;QAC9B,cAAS,GAAG,IAAI,GAAG,EAAwB,CAAC;QAC5C,oBAAe,GAAG,IAAI,GAAG,EAAc,CAAC;QACjD,gBAAW,GAAG,CAAC,CAAC;QAChB,YAAO,GAAG,KAAK,CAAC;QAUvB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;IACxB,CAAC;IAED,IAAI,YAAY,KAAa,OAAO,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC;IAEvD,KAAK,CAAC,KAAK,CAAC,IAAY;QACvB,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;QAC/B,OAAO,CAAC,IAAI,CAAC,WAAW,IAAI,IAAI,CAAC,WAAW,GAAG,KAAK,CAAC,MAAM,GAAG,IAAI,CAAC,OAAO,CAAC,cAAc,EAAE,CAAC;YAC3F,MAAM,IAAI,OAAO,CAAO,CAAC,OAAO,EAAE,EAAE,CAAC,IAAI,CAAC,eAAe,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC;QACzE,CAAC;QACD,IAAI,IAAI,CAAC,WAAW;YAAE,MAAM,IAAI,CAAC,WAAW,CAAC;QAC7C,MAAM,IAAI,OAAO,CAAO,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;YAC3C,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,EAAE,CAAC,CAAC;YAC/C,IAAI,CAAC,W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E,CAAC,EAAE,CAAC;gBACnD,IAAI,CAAC,WAAW,IAAI,KAAK,CAAC,KAAK,CAAC,MAAM,CAAC;gBACvC,IAAI,CAAC,mBAAmB,EAAE,CAAC;gBAC3B,MAAM,IAAI,OAAO,CAAO,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;oBAC3C,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,KAAM,CAAC,KAAK,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,OAAO,EAAE,CAAC,CAAC;gBAC/E,CAAC,CAAC,CAAC;gBACH,KAAK,CAAC,OAAO,EAAE,EAAE,CAAC;YACnB,CAAC;QACF,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YAChB,MAAM,OAAO,GAAG,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC;YAC1E,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;QACrB,CAAC;gBAAS,CAAC;YACV,IAAI,CAAC,OAAO,GAAG,KAAK,CAAC;YACrB,IAAI,CAAC,IAAI,CAAC,WAAW,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,MAAM,GAAG,CAAC,IAAI,IAAI,CAAC,SAAS,CAAC,IAAI,GAAG,CAAC,CAAC;gBAAE,IAAI,CAAC,IAAI,EAAE,CAAC;QAC7F,CAAC;IACF,CAAC;IAEO,mBAAmB;QAC1B,KAAK,MAAM,OAAO,IAAI,IAAI,CAAC,eAAe;YAAE,OAAO,EAAE,CAAC;QACtD,IAAI,CAAC,eAAe,CAAC,KAAK,EAAE,CAAC;IAC9B,CAAC;CACD","sourcesContent":["import type { Writable } from \"node:stream\";\n\ninterface PendingFrame {\n\tbytes: Buffer;\n\tresolve?: () => void;\n\treject?: (error: Error) => void;\n\tkey?: string;\n}\n\nexport interface BoundedWriterOptions {\n\tmaxFrameBytes: number;\n\tmaxQueuedBytes: number;\n}\n\n/** A byte-accounted, one-write-at-a-time stream writer with replaceable updates. */\nexport class BoundedWriter {\n\tprivate readonly critical: PendingFrame[] = [];\n\tprivate readonly coalesced = new Map<string, PendingFrame>();\n\tprivate readonly capacityWaiters = new Set<() => void>();\n\tprivate queuedBytes = 0;\n\tprivate pumping = false;\n\tprivate closedError: Error | undefined;\n\n\tprivate readonly stream: Writable;\n\tprivate readonly options: BoundedWriterOptions;\n\n\tconstructor(\n\t\tstream: Writable,\n\t\toptions: BoundedWriterOptions,\n\t) {\n\t\tthis.stream = stream;\n\t\tthis.options = options;\n\t}\n\n\tget pendingBytes(): number { return this.queuedBytes; }\n\n\tasync write(text: string): Promise<void> {\n\t\tconst bytes = this.frame(text);\n\t\twhile (!this.closedError && this.queuedBytes + bytes.length > this.options.maxQueuedBytes) {\n\t\t\tawait new Promise<void>((resolve) => this.capacityWaiters.add(resolve));\n\t\t}\n\t\tif (this.closedError) throw this.closedError;\n\t\tawait new Promise<void>((resolve, reject) => {\n\t\t\tthis.critical.push({ bytes, resolve, reject });\n\t\t\tthis.queuedBytes += bytes.length;\n\t\t\tthis.pump();\n\t\t});\n\t}\n\n\tofferLatest(key: string, text: string): boolean {\n\t\tif (this.closedError) return false;\n\t\tconst bytes = this.frame(text);\n\t\tconst previous = this.coalesced.get(key);\n\t\tconst nextBytes = this.queuedBytes - (previous?.bytes.length ?? 0) + bytes.length;\n\t\tif (nextBytes > this.options.maxQueuedBytes) return false;\n\t\tif (previous) this.queuedBytes -= previous.bytes.length;\n\t\tthis.coalesced.set(key, { bytes, key });\n\t\tthis.queuedBytes += bytes.length;\n\t\tthis.pump();\n\t\treturn true;\n\t}\n\n\tclose(error = new Error(\"RPC writer closed\")): void {\n\t\tif (this.closedError) return;\n\t\tthis.closedError = error;\n\t\tfor (const frame of this.critical.splice(0)) frame.reject?.(error);\n\t\tthis.coalesced.clear();\n\t\tthis.queuedBytes = 0;\n\t\tthis.wakeCapacityWaiters();\n\t}\n\n\tprivate frame(text: string): Buffer {\n\t\tconst bytes = Buffer.from(text, \"utf8\");\n\t\tconst payloadBytes = bytes.at(-1) === 0x0a ? bytes.length - 1 : bytes.length;\n\t\tif (payloadBytes > this.options.maxFrameBytes) {\n\t\t\tthrow new Error(`RPC frame exceeds ${this.options.maxFrameBytes} bytes`);\n\t\t}\n\t\treturn bytes;\n\t}\n\n\tprivate next(): PendingFrame | undefined {\n\t\tconst critical = this.critical.shift();\n\t\tif (critical) return critical;\n\t\tconst entry = this.coalesced.entries().next().value as [string, PendingFrame] | undefined;\n\t\tif (!entry) return undefined;\n\t\tthis.coalesced.delete(entry[0]);\n\t\treturn entry[1];\n\t}\n\n\tprivate pump(): void {\n\t\tif (this.pumping) return;\n\t\tthis.pumping = true;\n\t\tvoid this.runPump();\n\t}\n\n\tprivate async runPump(): Promise<void> {\n\t\ttry {\n\t\t\tlet frame: PendingFrame | undefined;\n\t\t\twhile (!this.closedError && (frame = this.next())) {\n\t\t\t\tthis.queuedBytes -= frame.bytes.length;\n\t\t\t\tthis.wakeCapacityWaiters();\n\t\t\t\tawait new Promise<void>((resolve, reject) => {\n\t\t\t\t\tthis.stream.write(frame!.bytes, (error) => error ? reject(error) : resolve());\n\t\t\t\t});\n\t\t\t\tframe.resolve?.();\n\t\t\t}\n\t\t} catch (error) {\n\t\t\tconst failure = error instanceof Error ? error : new Error(String(error));\n\t\t\tthis.close(failure);\n\t\t} finally {\n\t\t\tthis.pumping = false;\n\t\t\tif (!this.closedError && (this.critical.length > 0 || this.coalesced.size > 0)) this.pump();\n\t\t}\n\t}\n\n\tprivate wakeCapacityWaiters(): void {\n\t\tfor (const resolve of this.capacityWaiters) resolve();\n\t\tthis.capacityWaiters.clear();\n\t}\n}\n"]}
|
|
@@ -1,17 +1,20 @@
|
|
|
1
1
|
import type { Readable } from "node:stream";
|
|
2
|
+
/** Serialize one LF-delimited JSON record. */
|
|
3
|
+
export declare function serializeJsonLine(value: object | boolean | null | number | string): string;
|
|
4
|
+
export interface JsonlReaderOptions {
|
|
5
|
+
maxBytesPerTurn?: number;
|
|
6
|
+
maxFrameBytes?: number;
|
|
7
|
+
/** @deprecated Use maxFrameBytes. Retained for source compatibility; measured as UTF-8 bytes. */
|
|
8
|
+
maxLineChars?: number;
|
|
9
|
+
maxLinesPerTurn?: number;
|
|
10
|
+
onOversizedLine?: () => void;
|
|
11
|
+
}
|
|
2
12
|
/**
|
|
3
|
-
*
|
|
13
|
+
* Attach a strict LF-only, UTF-8 byte-bounded JSONL reader.
|
|
4
14
|
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
15
|
+
* The stream is paused before queued chunks are drained, so one turn cannot parse
|
|
16
|
+
* an unbounded number of frames. Oversized records are discarded through their LF;
|
|
17
|
+
* the next bounded record remains readable.
|
|
7
18
|
*/
|
|
8
|
-
export declare function
|
|
9
|
-
/**
|
|
10
|
-
* Attach an LF-only JSONL reader to a stream.
|
|
11
|
-
*
|
|
12
|
-
* This intentionally does not use Node readline. Readline splits on additional
|
|
13
|
-
* Unicode separators that are valid inside JSON strings and therefore does not
|
|
14
|
-
* implement strict JSONL framing.
|
|
15
|
-
*/
|
|
16
|
-
export declare function attachJsonlLineReader(stream: Readable, onLine: (line: string) => void): () => void;
|
|
19
|
+
export declare function attachJsonlLineReader(stream: Readable, onLine: (line: string) => void, options?: JsonlReaderOptions): () => void;
|
|
17
20
|
//# sourceMappingURL=jsonl.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"jsonl.d.ts","sourceRoot":"","sources":["../../../src/modes/rpc/jsonl.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"jsonl.d.ts","sourceRoot":"","sources":["../../../src/modes/rpc/jsonl.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAE5C,8CAA8C;AAC9C,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,GAAG,IAAI,GAAG,MAAM,GAAG,MAAM,GAAG,MAAM,CAE1F;AAED,MAAM,WAAW,kBAAkB;IAClC,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,iGAAiG;IACjG,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,eAAe,CAAC,EAAE,MAAM,IAAI,CAAC;CAC7B;AAED;;;;;;GAMG;AACH,wBAAgB,qBAAqB,CACpC,MAAM,EAAE,QAAQ,EAChB,MAAM,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,EAC9B,OAAO,GAAE,kBAAuB,GAC9B,MAAM,IAAI,CAqGZ"}
|
package/dist/modes/rpc/jsonl.js
CHANGED
|
@@ -1,49 +1,123 @@
|
|
|
1
|
-
|
|
2
|
-
/**
|
|
3
|
-
* Serialize a single strict JSONL record.
|
|
4
|
-
*
|
|
5
|
-
* Framing is LF-only. Payload strings may contain other Unicode separators such as
|
|
6
|
-
* U+2028 and U+2029. Clients must split records on `\n` only.
|
|
7
|
-
*/
|
|
1
|
+
/** Serialize one LF-delimited JSON record. */
|
|
8
2
|
export function serializeJsonLine(value) {
|
|
9
3
|
return `${JSON.stringify(value)}\n`;
|
|
10
4
|
}
|
|
11
5
|
/**
|
|
12
|
-
* Attach
|
|
6
|
+
* Attach a strict LF-only, UTF-8 byte-bounded JSONL reader.
|
|
13
7
|
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
8
|
+
* The stream is paused before queued chunks are drained, so one turn cannot parse
|
|
9
|
+
* an unbounded number of frames. Oversized records are discarded through their LF;
|
|
10
|
+
* the next bounded record remains readable.
|
|
17
11
|
*/
|
|
18
|
-
export function attachJsonlLineReader(stream, onLine) {
|
|
19
|
-
const
|
|
20
|
-
|
|
21
|
-
const
|
|
22
|
-
|
|
12
|
+
export function attachJsonlLineReader(stream, onLine, options = {}) {
|
|
13
|
+
const maxFrameBytes = options.maxFrameBytes ?? options.maxLineChars ?? Number.POSITIVE_INFINITY;
|
|
14
|
+
const maxBytesPerTurn = options.maxBytesPerTurn ?? Number.POSITIVE_INFINITY;
|
|
15
|
+
const maxLinesPerTurn = options.maxLinesPerTurn ?? Number.POSITIVE_INFINITY;
|
|
16
|
+
const chunks = [];
|
|
17
|
+
let frameParts = [];
|
|
18
|
+
let frameBytes = 0;
|
|
19
|
+
let discarding = false;
|
|
20
|
+
let scheduled;
|
|
21
|
+
let ended = false;
|
|
22
|
+
let detached = false;
|
|
23
|
+
const finishFrame = () => {
|
|
24
|
+
if (discarding) {
|
|
25
|
+
discarding = false;
|
|
26
|
+
frameParts = [];
|
|
27
|
+
frameBytes = 0;
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
30
|
+
const frame = Buffer.concat(frameParts, frameBytes);
|
|
31
|
+
frameParts = [];
|
|
32
|
+
frameBytes = 0;
|
|
33
|
+
const withoutCr = frame.at(-1) === 0x0d ? frame.subarray(0, -1) : frame;
|
|
34
|
+
onLine(withoutCr.toString("utf8"));
|
|
23
35
|
};
|
|
24
|
-
const
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
36
|
+
const consume = (chunk, byteBudget, lineBudget) => {
|
|
37
|
+
let offset = 0;
|
|
38
|
+
let lines = 0;
|
|
39
|
+
while (offset < chunk.length && offset < byteBudget && lines < lineBudget) {
|
|
40
|
+
const budgetEnd = Math.min(chunk.length, offset + (byteBudget - offset));
|
|
41
|
+
const newline = chunk.indexOf(0x0a, offset);
|
|
42
|
+
const end = newline !== -1 && newline < budgetEnd ? newline : budgetEnd;
|
|
43
|
+
const part = chunk.subarray(offset, end);
|
|
44
|
+
if (!discarding && frameBytes + part.length <= maxFrameBytes) {
|
|
45
|
+
if (part.length > 0)
|
|
46
|
+
frameParts.push(part);
|
|
47
|
+
frameBytes += part.length;
|
|
48
|
+
}
|
|
49
|
+
else if (!discarding) {
|
|
50
|
+
discarding = true;
|
|
51
|
+
frameParts = [];
|
|
52
|
+
frameBytes = 0;
|
|
53
|
+
options.onOversizedLine?.();
|
|
54
|
+
}
|
|
55
|
+
offset = end;
|
|
56
|
+
if (newline === end) {
|
|
57
|
+
offset += 1;
|
|
58
|
+
finishFrame();
|
|
59
|
+
lines += 1;
|
|
30
60
|
}
|
|
31
|
-
|
|
32
|
-
|
|
61
|
+
if (end === budgetEnd && newline !== end)
|
|
62
|
+
break;
|
|
33
63
|
}
|
|
64
|
+
return { offset, lines };
|
|
65
|
+
};
|
|
66
|
+
const schedule = () => {
|
|
67
|
+
if (!scheduled && !detached)
|
|
68
|
+
scheduled = setImmediate(drain);
|
|
69
|
+
};
|
|
70
|
+
const drain = () => {
|
|
71
|
+
scheduled = undefined;
|
|
72
|
+
let bytes = 0;
|
|
73
|
+
let lines = 0;
|
|
74
|
+
while (chunks.length > 0 && bytes < maxBytesPerTurn && lines < maxLinesPerTurn) {
|
|
75
|
+
const chunk = chunks[0];
|
|
76
|
+
const result = consume(chunk, maxBytesPerTurn - bytes, maxLinesPerTurn - lines);
|
|
77
|
+
bytes += result.offset;
|
|
78
|
+
lines += result.lines;
|
|
79
|
+
if (result.offset === chunk.length)
|
|
80
|
+
chunks.shift();
|
|
81
|
+
else {
|
|
82
|
+
chunks[0] = chunk.subarray(result.offset);
|
|
83
|
+
break;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
if (chunks.length > 0)
|
|
87
|
+
schedule();
|
|
88
|
+
else if (ended) {
|
|
89
|
+
if (!discarding && frameBytes > 0)
|
|
90
|
+
finishFrame();
|
|
91
|
+
frameParts = [];
|
|
92
|
+
frameBytes = 0;
|
|
93
|
+
}
|
|
94
|
+
else
|
|
95
|
+
stream.resume();
|
|
96
|
+
};
|
|
97
|
+
const onData = (chunk) => {
|
|
98
|
+
stream.pause();
|
|
99
|
+
chunks.push(typeof chunk === "string" ? Buffer.from(chunk) : chunk);
|
|
100
|
+
schedule();
|
|
34
101
|
};
|
|
35
102
|
const onEnd = () => {
|
|
36
|
-
|
|
37
|
-
if (
|
|
38
|
-
|
|
39
|
-
|
|
103
|
+
ended = true;
|
|
104
|
+
if (scheduled) {
|
|
105
|
+
clearImmediate(scheduled);
|
|
106
|
+
scheduled = undefined;
|
|
107
|
+
drain();
|
|
40
108
|
}
|
|
109
|
+
else if (chunks.length === 0 && !discarding && frameBytes > 0)
|
|
110
|
+
finishFrame();
|
|
41
111
|
};
|
|
42
112
|
stream.on("data", onData);
|
|
43
113
|
stream.on("end", onEnd);
|
|
44
114
|
return () => {
|
|
115
|
+
detached = true;
|
|
116
|
+
if (scheduled)
|
|
117
|
+
clearImmediate(scheduled);
|
|
45
118
|
stream.off("data", onData);
|
|
46
119
|
stream.off("end", onEnd);
|
|
120
|
+
chunks.length = 0;
|
|
47
121
|
};
|
|
48
122
|
}
|
|
49
123
|
//# sourceMappingURL=jsonl.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"jsonl.js","sourceRoot":"","sources":["../../../src/modes/rpc/jsonl.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"jsonl.js","sourceRoot":"","sources":["../../../src/modes/rpc/jsonl.ts"],"names":[],"mappings":"AAEA,8CAA8C;AAC9C,MAAM,UAAU,iBAAiB,CAAC,KAAgD;IACjF,OAAO,GAAG,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,IAAI,CAAC;AACrC,CAAC;AAWD;;;;;;GAMG;AACH,MAAM,UAAU,qBAAqB,CACpC,MAAgB,EAChB,MAA8B,EAC9B,OAAO,GAAuB,EAAE;IAEhC,MAAM,aAAa,GAAG,OAAO,CAAC,aAAa,IAAI,OAAO,CAAC,YAAY,IAAI,MAAM,CAAC,iBAAiB,CAAC;IAChG,MAAM,eAAe,GAAG,OAAO,CAAC,eAAe,IAAI,M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AC,KAAK,CAAC,CAAC;QACpE,QAAQ,EAAE,CAAC;IACZ,CAAC,CAAC;IACF,MAAM,KAAK,GAAG,GAAS,EAAE;QACxB,KAAK,GAAG,IAAI,CAAC;QACb,IAAI,SAAS,EAAE,CAAC;YACf,cAAc,CAAC,SAAS,CAAC,CAAC;YAC1B,SAAS,GAAG,SAAS,CAAC;YACtB,KAAK,EAAE,CAAC;QACT,CAAC;aAAM,IAAI,MAAM,CAAC,MAAM,KAAK,CAAC,IAAI,CAAC,UAAU,IAAI,UAAU,GAAG,CAAC;YAAE,WAAW,EAAE,CAAC;IAChF,CAAC,CAAC;IACF,MAAM,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC1B,MAAM,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;IACxB,OAAO,GAAG,EAAE;QACX,QAAQ,GAAG,IAAI,CAAC;QAChB,IAAI,SAAS;YAAE,cAAc,CAAC,SAAS,CAAC,CAAC;QACzC,MAAM,CAAC,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;QAC3B,MAAM,CAAC,GAAG,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;QACzB,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC;IACnB,CAAC,CAAC;AACH,CAAC","sourcesContent":["import type { Readable } from \"node:stream\";\n\n/** Serialize one LF-delimited JSON record. */\nexport function serializeJsonLine(value: object | boolean | null | number | string): string {\n\treturn `${JSON.stringify(value)}\\n`;\n}\n\nexport interface JsonlReaderOptions {\n\tmaxBytesPerTurn?: number;\n\tmaxFrameBytes?: number;\n\t/** @deprecated Use maxFrameBytes. Retained for source compatibility; measured as UTF-8 bytes. */\n\tmaxLineChars?: number;\n\tmaxLinesPerTurn?: number;\n\tonOversizedLine?: () => void;\n}\n\n/**\n * Attach a strict LF-only, UTF-8 byte-bounded JSONL reader.\n *\n * The stream is paused before queued chunks are drained, so one turn cannot parse\n * an unbounded number of frames. Oversized records are discarded through their LF;\n * the next bounded record remains readable.\n */\nexport function attachJsonlLineReader(\n\tstream: Readable,\n\tonLine: (line: string) => void,\n\toptions: JsonlReaderOptions = {},\n): () => void {\n\tconst maxFrameBytes = options.maxFrameBytes ?? options.maxLineChars ?? Number.POSITIVE_INFINITY;\n\tconst maxBytesPerTurn = options.maxBytesPerTurn ?? Number.POSITIVE_INFINITY;\n\tconst maxLinesPerTurn = options.maxLinesPerTurn ?? Number.POSITIVE_INFINITY;\n\tconst chunks: Buffer[] = [];\n\tlet frameParts: Buffer[] = [];\n\tlet frameBytes = 0;\n\tlet discarding = false;\n\tlet scheduled: ReturnType<typeof setImmediate> | undefined;\n\tlet ended = false;\n\tlet detached = false;\n\n\tconst finishFrame = (): void => {\n\t\tif (discarding) {\n\t\t\tdiscarding = false;\n\t\t\tframeParts = [];\n\t\t\tframeBytes = 0;\n\t\t\treturn;\n\t\t}\n\t\tconst frame = Buffer.concat(frameParts, frameBytes);\n\t\tframeParts = [];\n\t\tframeBytes = 0;\n\t\tconst withoutCr = frame.at(-1) === 0x0d ? frame.subarray(0, -1) : frame;\n\t\tonLine(withoutCr.toString(\"utf8\"));\n\t};\n\n\tconst consume = (chunk: Buffer, byteBudget: number, lineBudget: number): { offset: number; lines: number } => {\n\t\tlet offset = 0;\n\t\tlet lines = 0;\n\t\twhile (offset < chunk.length && offset < byteBudget && lines < lineBudget) {\n\t\t\tconst budgetEnd = Math.min(chunk.length, offset + (byteBudget - offset));\n\t\t\tconst newline = chunk.indexOf(0x0a, offset);\n\t\t\tconst end = newline !== -1 && newline < budgetEnd ? newline : budgetEnd;\n\t\t\tconst part = chunk.subarray(offset, end);\n\t\t\tif (!discarding && frameBytes + part.length <= maxFrameBytes) {\n\t\t\t\tif (part.length > 0) frameParts.push(part);\n\t\t\t\tframeBytes += part.length;\n\t\t\t} else if (!discarding) {\n\t\t\t\tdiscarding = true;\n\t\t\t\tframeParts = [];\n\t\t\t\tframeBytes = 0;\n\t\t\t\toptions.onOversizedLine?.();\n\t\t\t}\n\t\t\toffset = end;\n\t\t\tif (newline === end) {\n\t\t\t\toffset += 1;\n\t\t\t\tfinishFrame();\n\t\t\t\tlines += 1;\n\t\t\t}\n\t\t\tif (end === budgetEnd && newline !== end) break;\n\t\t}\n\t\treturn { offset, lines };\n\t};\n\n\tconst schedule = (): void => {\n\t\tif (!scheduled && !detached) scheduled = setImmediate(drain);\n\t};\n\tconst drain = (): void => {\n\t\tscheduled = undefined;\n\t\tlet bytes = 0;\n\t\tlet lines = 0;\n\t\twhile (chunks.length > 0 && bytes < maxBytesPerTurn && lines < maxLinesPerTurn) {\n\t\t\tconst chunk = chunks[0]!;\n\t\t\tconst result = consume(chunk, maxBytesPerTurn - bytes, maxLinesPerTurn - lines);\n\t\t\tbytes += result.offset;\n\t\t\tlines += result.lines;\n\t\t\tif (result.offset === chunk.length) chunks.shift();\n\t\t\telse {\n\t\t\t\tchunks[0] = chunk.subarray(result.offset);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t\tif (chunks.length > 0) schedule();\n\t\telse if (ended) {\n\t\t\tif (!discarding && frameBytes > 0) finishFrame();\n\t\t\tframeParts = [];\n\t\t\tframeBytes = 0;\n\t\t} else stream.resume();\n\t};\n\tconst onData = (chunk: string | Buffer): void => {\n\t\tstream.pause();\n\t\tchunks.push(typeof chunk === \"string\" ? Buffer.from(chunk) : chunk);\n\t\tschedule();\n\t};\n\tconst onEnd = (): void => {\n\t\tended = true;\n\t\tif (scheduled) {\n\t\t\tclearImmediate(scheduled);\n\t\t\tscheduled = undefined;\n\t\t\tdrain();\n\t\t} else if (chunks.length === 0 && !discarding && frameBytes > 0) finishFrame();\n\t};\n\tstream.on(\"data\", onData);\n\tstream.on(\"end\", onEnd);\n\treturn () => {\n\t\tdetached = true;\n\t\tif (scheduled) clearImmediate(scheduled);\n\t\tstream.off(\"data\", onData);\n\t\tstream.off(\"end\", onEnd);\n\t\tchunks.length = 0;\n\t};\n}\n"]}
|