@bastani/atomic 0.9.11-alpha.5 → 0.9.11-alpha.7
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 +63 -0
- package/README.md +12 -5
- package/dist/builtin/intercom/package.json +2 -2
- package/dist/builtin/mcp/CHANGELOG.md +6 -0
- package/dist/builtin/mcp/README.md +3 -3
- package/dist/builtin/mcp/cli.js +0 -1
- package/dist/builtin/mcp/config.ts +0 -2
- package/dist/builtin/mcp/package.json +3 -3
- package/dist/builtin/mcp/types.ts +0 -1
- package/dist/builtin/subagents/CHANGELOG.md +12 -0
- package/dist/builtin/subagents/README.md +1 -1
- package/dist/builtin/subagents/agents/code-simplifier.md +47 -102
- package/dist/builtin/subagents/agents/codebase-analyzer.md +27 -130
- package/dist/builtin/subagents/agents/codebase-locator.md +24 -83
- package/dist/builtin/subagents/agents/codebase-online-researcher.md +60 -259
- package/dist/builtin/subagents/agents/codebase-pattern-finder.md +29 -207
- package/dist/builtin/subagents/agents/codebase-research-analyzer.md +28 -150
- package/dist/builtin/subagents/agents/codebase-research-locator.md +21 -118
- package/dist/builtin/subagents/agents/debugger.md +27 -65
- package/dist/builtin/subagents/agents/worker.md +23 -30
- package/dist/builtin/subagents/package.json +4 -4
- package/dist/builtin/subagents/prompts/gather-context-and-clarify.md +18 -11
- package/dist/builtin/subagents/prompts/parallel-cleanup.md +34 -33
- package/dist/builtin/subagents/prompts/parallel-context-build.md +22 -36
- package/dist/builtin/subagents/prompts/parallel-handoff-plan.md +20 -52
- package/dist/builtin/subagents/prompts/parallel-research.md +17 -41
- package/dist/builtin/subagents/prompts/parallel-review.md +23 -28
- package/dist/builtin/subagents/prompts/review-loop.md +18 -27
- package/dist/builtin/subagents/src/extension/prompt-guidance.ts +1 -1
- package/dist/builtin/subagents/src/runs/background/async-execution-chain.ts +23 -4
- package/dist/builtin/subagents/src/runs/background/async-execution-single.ts +2 -0
- package/dist/builtin/subagents/src/runs/background/async-execution-types.ts +10 -0
- package/dist/builtin/subagents/src/runs/background/subagent-runner-step.ts +1 -0
- package/dist/builtin/subagents/src/runs/foreground/chain-execution-dynamic-step.ts +2 -0
- package/dist/builtin/subagents/src/runs/foreground/chain-execution-parallel-runner.ts +8 -0
- package/dist/builtin/subagents/src/runs/foreground/chain-execution-parallel-step.ts +1 -0
- package/dist/builtin/subagents/src/runs/foreground/chain-execution-sequential-step.ts +6 -0
- package/dist/builtin/subagents/src/runs/foreground/chain-execution-types.ts +2 -0
- package/dist/builtin/subagents/src/runs/foreground/subagent-executor-async.ts +7 -0
- package/dist/builtin/subagents/src/runs/foreground/subagent-executor-chain.ts +1 -0
- package/dist/builtin/subagents/src/runs/foreground/subagent-executor-resume.ts +3 -0
- package/dist/builtin/subagents/src/runs/shared/mcp-direct-tool-allowlist.ts +1 -2
- package/dist/builtin/subagents/src/runs/shared/parallel-utils.ts +1 -0
- package/dist/builtin/subagents/src/runs/shared/pi-args.ts +5 -3
- package/dist/builtin/subagents/src/shared/settings.ts +4 -0
- package/dist/builtin/web-access/package.json +2 -2
- package/dist/builtin/workflows/CHANGELOG.md +44 -0
- package/dist/builtin/workflows/README.md +72 -70
- package/dist/builtin/workflows/ambient.d.ts +0 -5
- package/dist/builtin/workflows/builtin/adversarial-verification-prompts.ts +7 -4
- package/dist/builtin/workflows/builtin/adversarial-verification-runner.ts +1 -1
- package/dist/builtin/workflows/builtin/adversarial-verification.ts +2 -1
- package/dist/builtin/workflows/builtin/classify-and-act-prompts.ts +5 -2
- package/dist/builtin/workflows/builtin/classify-and-act-runner.ts +5 -7
- package/dist/builtin/workflows/builtin/classify-and-act.ts +3 -2
- package/dist/builtin/workflows/builtin/fan-out-and-synthesize-prompts.ts +6 -3
- package/dist/builtin/workflows/builtin/fan-out-and-synthesize-runner.ts +5 -5
- package/dist/builtin/workflows/builtin/fan-out-and-synthesize.ts +3 -2
- package/dist/builtin/workflows/builtin/generate-and-filter-prompts.ts +7 -4
- package/dist/builtin/workflows/builtin/generate-and-filter-runner.ts +6 -3
- package/dist/builtin/workflows/builtin/generate-and-filter.ts +3 -2
- package/dist/builtin/workflows/builtin/goal-models.ts +14 -18
- package/dist/builtin/workflows/builtin/goal-orchestrator-prompts.ts +39 -78
- package/dist/builtin/workflows/builtin/goal-prompts.ts +64 -244
- package/dist/builtin/workflows/builtin/goal-runner.ts +32 -64
- package/dist/builtin/workflows/builtin/goal.ts +2 -1
- package/dist/builtin/workflows/builtin/index.d.ts +17 -112
- package/dist/builtin/workflows/builtin/index.ts +1 -2
- package/dist/builtin/workflows/builtin/loop-until-done-prompts.ts +20 -12
- package/dist/builtin/workflows/builtin/loop-until-done-runner.ts +3 -0
- package/dist/builtin/workflows/builtin/loop-until-done.ts +3 -2
- package/dist/builtin/workflows/builtin/open-claude-design-phases.ts +52 -55
- package/dist/builtin/workflows/builtin/open-claude-design-runner.ts +45 -52
- package/dist/builtin/workflows/builtin/open-claude-design-setup.ts +41 -46
- package/dist/builtin/workflows/builtin/open-claude-design-utils.ts +16 -21
- package/dist/builtin/workflows/builtin/open-claude-design.ts +2 -1
- package/dist/builtin/workflows/builtin/ralph-core.ts +61 -57
- package/dist/builtin/workflows/builtin/ralph-forked-prompts.ts +41 -45
- package/dist/builtin/workflows/builtin/ralph-models.ts +33 -43
- package/dist/builtin/workflows/builtin/ralph-reviewer-prompt.ts +35 -120
- package/dist/builtin/workflows/builtin/ralph-runner.ts +81 -108
- package/dist/builtin/workflows/builtin/ralph.ts +2 -1
- package/dist/builtin/workflows/builtin/shared-prompts.ts +110 -93
- package/dist/builtin/workflows/builtin/steering-context.ts +51 -0
- package/dist/builtin/workflows/builtin/tournament-prompts.ts +21 -12
- package/dist/builtin/workflows/builtin/tournament-runner.ts +3 -0
- package/dist/builtin/workflows/builtin/tournament.ts +3 -2
- package/dist/builtin/workflows/package.json +2 -2
- package/dist/builtin/workflows/skills/create-spec/SKILL.md +1 -1
- package/dist/builtin/workflows/skills/impeccable/SKILL.md +33 -129
- package/dist/builtin/workflows/skills/impeccable/agents/impeccable_asset_producer.toml +11 -3
- package/dist/builtin/workflows/skills/impeccable/agents/impeccable_documenter.toml +26 -0
- package/dist/builtin/workflows/skills/impeccable/agents/impeccable_finish_reviewer.toml +35 -0
- package/dist/builtin/workflows/skills/impeccable/reference/android.md +1 -1
- package/dist/builtin/workflows/skills/impeccable/reference/animate.md +72 -189
- package/dist/builtin/workflows/skills/impeccable/reference/audit.md +10 -9
- package/dist/builtin/workflows/skills/impeccable/reference/audit.native.md +2 -2
- package/dist/builtin/workflows/skills/impeccable/reference/bolder.md +19 -108
- package/dist/builtin/workflows/skills/impeccable/reference/clarify.md +59 -253
- package/dist/builtin/workflows/skills/impeccable/reference/colorize.md +51 -222
- package/dist/builtin/workflows/skills/impeccable/reference/craft-floor.md +45 -0
- package/dist/builtin/workflows/skills/impeccable/reference/craft.md +3 -121
- package/dist/builtin/workflows/skills/impeccable/reference/critique.md +28 -20
- package/dist/builtin/workflows/skills/impeccable/reference/degraded/asset-producer.md +97 -0
- package/dist/builtin/workflows/skills/impeccable/reference/degraded/documenter.md +23 -0
- package/dist/builtin/workflows/skills/impeccable/reference/degraded/finish-reviewer.md +32 -0
- package/dist/builtin/workflows/skills/impeccable/reference/degraded/manual-edit-applier.md +92 -0
- package/dist/builtin/workflows/skills/impeccable/reference/delight.md +47 -279
- package/dist/builtin/workflows/skills/impeccable/reference/distill.md +2 -2
- package/dist/builtin/workflows/skills/impeccable/reference/doctor.md +53 -0
- package/dist/builtin/workflows/skills/impeccable/reference/document.md +60 -73
- package/dist/builtin/workflows/skills/impeccable/reference/harden.md +1 -12
- package/dist/builtin/workflows/skills/impeccable/reference/hooks.md +23 -12
- package/dist/builtin/workflows/skills/impeccable/reference/init.md +64 -163
- package/dist/builtin/workflows/skills/impeccable/reference/ios.md +1 -1
- package/dist/builtin/workflows/skills/impeccable/reference/layout.md +52 -153
- package/dist/builtin/workflows/skills/impeccable/reference/live.md +47 -36
- package/dist/builtin/workflows/skills/impeccable/reference/new-work.md +105 -0
- package/dist/builtin/workflows/skills/impeccable/reference/{product.md → operate.md} +6 -5
- package/dist/builtin/workflows/skills/impeccable/reference/optimize.md +4 -4
- package/dist/builtin/workflows/skills/impeccable/reference/overdrive.md +1 -4
- package/dist/builtin/workflows/skills/impeccable/reference/polish.md +68 -212
- package/dist/builtin/workflows/skills/impeccable/reference/quieter.md +3 -3
- package/dist/builtin/workflows/skills/impeccable/reference/routing.md +18 -0
- package/dist/builtin/workflows/skills/impeccable/reference/shape.md +38 -144
- package/dist/builtin/workflows/skills/impeccable/reference/typeset.md +48 -269
- package/dist/builtin/workflows/skills/impeccable/reference/visualize.md +38 -0
- package/dist/builtin/workflows/skills/impeccable/scripts/command-metadata.json +1 -1
- package/dist/builtin/workflows/skills/impeccable/scripts/concept-seed.mjs +584 -0
- package/dist/builtin/workflows/skills/impeccable/scripts/context-signals.mjs +117 -9
- package/dist/builtin/workflows/skills/impeccable/scripts/context.mjs +486 -59
- package/dist/builtin/workflows/skills/impeccable/scripts/critique-storage.mjs +16 -45
- package/dist/builtin/workflows/skills/impeccable/scripts/detector/browser/injected/index.mjs +96 -10
- package/dist/builtin/workflows/skills/impeccable/scripts/detector/cli/main.mjs +143 -26
- package/dist/builtin/workflows/skills/impeccable/scripts/detector/design-system.mjs +181 -12
- package/dist/builtin/workflows/skills/impeccable/scripts/detector/detect-antipatterns-browser.js +3187 -182
- package/dist/builtin/workflows/skills/impeccable/scripts/detector/engines/browser/detect-url.mjs +102 -7
- package/dist/builtin/workflows/skills/impeccable/scripts/detector/engines/regex/detect-text.mjs +282 -70
- package/dist/builtin/workflows/skills/impeccable/scripts/detector/engines/static-html/css-cascade.mjs +183 -15
- package/dist/builtin/workflows/skills/impeccable/scripts/detector/engines/static-html/detect-html.mjs +22 -7
- package/dist/builtin/workflows/skills/impeccable/scripts/detector/findings.mjs +7 -1
- package/dist/builtin/workflows/skills/impeccable/scripts/detector/node/file-system.mjs +16 -2
- package/dist/builtin/workflows/skills/impeccable/scripts/detector/registry/antipatterns.mjs +155 -42
- package/dist/builtin/workflows/skills/impeccable/scripts/detector/rules/checks.mjs +2988 -155
- package/dist/builtin/workflows/skills/impeccable/scripts/detector/shared/constants.mjs +11 -0
- package/dist/builtin/workflows/skills/impeccable/scripts/doctor.mjs +336 -0
- package/dist/builtin/workflows/skills/impeccable/scripts/generate-image.mjs +232 -0
- package/dist/builtin/workflows/skills/impeccable/scripts/hook-admin.mjs +92 -30
- package/dist/builtin/workflows/skills/impeccable/scripts/hook-lib.mjs +414 -120
- package/dist/builtin/workflows/skills/impeccable/scripts/hook.mjs +25 -8
- package/dist/builtin/workflows/skills/impeccable/scripts/lib/artifact-schema.mjs +93 -0
- package/dist/builtin/workflows/skills/impeccable/scripts/lib/composition-catalog.mjs +165 -0
- package/dist/builtin/workflows/skills/impeccable/scripts/lib/concept-catalog.mjs +329 -0
- package/dist/builtin/workflows/skills/impeccable/scripts/lib/impeccable-config.mjs +20 -5
- package/dist/builtin/workflows/skills/impeccable/scripts/lib/impeccable-paths.mjs +16 -8
- package/dist/builtin/workflows/skills/impeccable/scripts/lib/provider.mjs +1 -0
- package/dist/builtin/workflows/skills/impeccable/scripts/lib/staleness-deep.mjs +455 -0
- package/dist/builtin/workflows/skills/impeccable/scripts/lib/staleness-notice.mjs +169 -0
- package/dist/builtin/workflows/skills/impeccable/scripts/lib/staleness.mjs +457 -0
- package/dist/builtin/workflows/skills/impeccable/scripts/lib/surface-briefs.mjs +151 -0
- package/dist/builtin/workflows/skills/impeccable/scripts/lib/target-slug.mjs +33 -0
- package/dist/builtin/workflows/skills/impeccable/scripts/lib/template-extensions.mjs +146 -0
- package/dist/builtin/workflows/skills/impeccable/scripts/live/completion.mjs +10 -1
- package/dist/builtin/workflows/skills/impeccable/scripts/live/event-validation.mjs +15 -0
- package/dist/builtin/workflows/skills/impeccable/scripts/live/generation-preflight.mjs +149 -0
- package/dist/builtin/workflows/skills/impeccable/scripts/live/poll-lanes.mjs +14 -0
- package/dist/builtin/workflows/skills/impeccable/scripts/live/session-store.mjs +109 -32
- package/dist/builtin/workflows/skills/impeccable/scripts/live/source-lock.mjs +105 -0
- package/dist/builtin/workflows/skills/impeccable/scripts/live/source-search.mjs +105 -0
- package/dist/builtin/workflows/skills/impeccable/scripts/live/sveltekit-adapter.mjs +8 -6
- package/dist/builtin/workflows/skills/impeccable/scripts/live/tanstack-adapter.mjs +280 -0
- package/dist/builtin/workflows/skills/impeccable/scripts/live-accept.mjs +208 -68
- package/dist/builtin/workflows/skills/impeccable/scripts/live-browser.js +565 -115
- package/dist/builtin/workflows/skills/impeccable/scripts/live-commit-manual-edits.mjs +3 -0
- package/dist/builtin/workflows/skills/impeccable/scripts/live-inject.mjs +198 -14
- package/dist/builtin/workflows/skills/impeccable/scripts/live-insert.mjs +24 -6
- package/dist/builtin/workflows/skills/impeccable/scripts/live-manual-edit-evidence.mjs +6 -1
- package/dist/builtin/workflows/skills/impeccable/scripts/live-poll.mjs +44 -14
- package/dist/builtin/workflows/skills/impeccable/scripts/live-server.mjs +398 -33
- package/dist/builtin/workflows/skills/impeccable/scripts/live-status.mjs +9 -5
- package/dist/builtin/workflows/skills/impeccable/scripts/live-wrap.mjs +81 -67
- package/dist/builtin/workflows/skills/impeccable/scripts/live.mjs +7 -2
- package/dist/builtin/workflows/skills/impeccable/scripts/palette.mjs +76 -81
- package/dist/builtin/workflows/skills/impeccable/scripts/pin.mjs +4 -4
- package/dist/builtin/workflows/skills/impeccable/scripts/serve-question.mjs +890 -0
- package/dist/builtin/workflows/skills/impeccable/scripts/surface-brief.mjs +74 -0
- package/dist/builtin/workflows/skills/prompt-engineer/SKILL.md +57 -252
- package/dist/builtin/workflows/skills/prompt-engineer/references/advanced_patterns.md +70 -226
- package/dist/builtin/workflows/skills/prompt-engineer/references/core_prompting.md +64 -103
- package/dist/builtin/workflows/skills/prompt-engineer/references/quality_improvement.md +81 -155
- package/dist/builtin/workflows/src/authoring.d.ts +5 -1
- package/dist/builtin/workflows/src/durable/backend.ts +68 -9
- package/dist/builtin/workflows/src/durable/boundary-lifecycle.ts +148 -0
- package/dist/builtin/workflows/src/durable/boundary-topology.ts +420 -0
- package/dist/builtin/workflows/src/durable/child-invocation.ts +14 -0
- package/dist/builtin/workflows/src/durable/child-primitive.ts +74 -44
- package/dist/builtin/workflows/src/durable/completed-catalog-stage-groups.ts +250 -0
- package/dist/builtin/workflows/src/durable/completed-catalog.ts +205 -131
- package/dist/builtin/workflows/src/durable/completed-inspection.ts +8 -2
- package/dist/builtin/workflows/src/durable/completed-subtree.ts +31 -0
- package/dist/builtin/workflows/src/durable/dbos-backend.ts +28 -24
- package/dist/builtin/workflows/src/durable/dbos-envelope.ts +130 -3
- package/dist/builtin/workflows/src/durable/dbos-metadata.ts +18 -0
- package/dist/builtin/workflows/src/durable/scoped-backend.ts +64 -17
- package/dist/builtin/workflows/src/durable/stage-primitive.ts +60 -60
- package/dist/builtin/workflows/src/durable/stage-topology-validation.ts +234 -0
- package/dist/builtin/workflows/src/durable/stage-topology.ts +53 -0
- package/dist/builtin/workflows/src/durable/tool-failure-checkpoint.ts +49 -0
- package/dist/builtin/workflows/src/durable/tool-outcome.ts +120 -0
- package/dist/builtin/workflows/src/durable/tool-primitive.ts +367 -58
- package/dist/builtin/workflows/src/durable/types.ts +97 -0
- package/dist/builtin/workflows/src/durable/ui-primitive.ts +46 -0
- package/dist/builtin/workflows/src/durable/workflow-child-result.ts +58 -0
- package/dist/builtin/workflows/src/engine/options.ts +1 -0
- package/dist/builtin/workflows/src/engine/primitives/workflow.ts +19 -10
- package/dist/builtin/workflows/src/engine/run-durable-finalize.ts +11 -1
- package/dist/builtin/workflows/src/engine/run-durable-topology.ts +190 -18
- package/dist/builtin/workflows/src/engine/run-terminal-event.ts +37 -0
- package/dist/builtin/workflows/src/engine/run-terminal-failure.ts +50 -0
- package/dist/builtin/workflows/src/engine/run-tool-execution-tracker.ts +152 -0
- package/dist/builtin/workflows/src/engine/run-tool-node-lifecycle.ts +87 -0
- package/dist/builtin/workflows/src/engine/run.ts +111 -110
- package/dist/builtin/workflows/src/engine/runtime.ts +15 -2
- package/dist/builtin/workflows/src/extension/extension-factory.ts +1 -0
- package/dist/builtin/workflows/src/extension/extension-runtime-state.ts +11 -0
- package/dist/builtin/workflows/src/extension/index.bundle.mjs +6710 -4810
- package/dist/builtin/workflows/src/extension/lifecycle-notifications.ts +16 -5
- package/dist/builtin/workflows/src/extension/render-result.ts +16 -2
- package/dist/builtin/workflows/src/extension/runtime-durable-resume.ts +3 -0
- package/dist/builtin/workflows/src/extension/runtime.ts +4 -0
- package/dist/builtin/workflows/src/extension/wiring.ts +3 -1
- package/dist/builtin/workflows/src/extension/workflow-command-surfaces.ts +1 -0
- package/dist/builtin/workflows/src/extension/workflow-durable-resume-command.ts +9 -3
- package/dist/builtin/workflows/src/extension/workflow-module-loader.ts +18 -3
- package/dist/builtin/workflows/src/extension/workflow-prompts.ts +22 -11
- package/dist/builtin/workflows/src/extension/workflow-status-summary.ts +43 -0
- package/dist/builtin/workflows/src/extension/workflow-targets.ts +34 -30
- package/dist/builtin/workflows/src/extension/workflow-tool-content.ts +12 -5
- package/dist/builtin/workflows/src/extension/workflow-tool-send.ts +162 -63
- package/dist/builtin/workflows/src/runs/background/run-inspect.ts +7 -1
- package/dist/builtin/workflows/src/runs/background/status.ts +18 -8
- package/dist/builtin/workflows/src/runs/background/workflow-lifecycle-aggregate.ts +3 -11
- package/dist/builtin/workflows/src/runs/foreground/executor-child-boundary.ts +24 -21
- package/dist/builtin/workflows/src/runs/foreground/executor-hil.ts +1 -1
- package/dist/builtin/workflows/src/runs/foreground/executor-lifecycle.ts +30 -13
- package/dist/builtin/workflows/src/runs/foreground/executor-prompt-nodes.ts +102 -53
- package/dist/builtin/workflows/src/runs/foreground/executor-stage-call.ts +13 -5
- package/dist/builtin/workflows/src/runs/foreground/executor-stage-control.ts +49 -17
- package/dist/builtin/workflows/src/runs/foreground/executor-stage-factory.ts +11 -4
- package/dist/builtin/workflows/src/runs/foreground/executor-stage-replay.ts +1 -0
- package/dist/builtin/workflows/src/runs/foreground/executor-stage-types.ts +4 -1
- package/dist/builtin/workflows/src/runs/foreground/executor-types.ts +7 -1
- package/dist/builtin/workflows/src/runs/foreground/postmortem-stage-chat.ts +53 -4
- package/dist/builtin/workflows/src/runs/foreground/stage-control-registry.ts +146 -17
- package/dist/builtin/workflows/src/runs/foreground/stage-delivery-activity.ts +86 -0
- package/dist/builtin/workflows/src/runs/foreground/stage-runner-context.ts +18 -6
- package/dist/builtin/workflows/src/runs/foreground/stage-runner-controller.ts +45 -46
- package/dist/builtin/workflows/src/runs/foreground/stage-runner-options.ts +5 -1
- package/dist/builtin/workflows/src/runs/foreground/stage-runner-pause.ts +195 -0
- package/dist/builtin/workflows/src/runs/foreground/stage-runner-send-user-message.ts +8 -0
- package/dist/builtin/workflows/src/runs/foreground/stage-runner-session-options.ts +0 -13
- package/dist/builtin/workflows/src/runs/foreground/stage-runner-types.ts +30 -2
- package/dist/builtin/workflows/src/runs/shared/model-fallback-candidates.ts +3 -143
- package/dist/builtin/workflows/src/sdk-surface.ts +1 -1
- package/dist/builtin/workflows/src/shared/authoring-contract-stage.d.ts +6 -11
- package/dist/builtin/workflows/src/shared/authoring-contract-stage.ts +6 -11
- package/dist/builtin/workflows/src/shared/authoring-contract-ui.d.ts +57 -6
- package/dist/builtin/workflows/src/shared/authoring-contract-ui.ts +76 -11
- package/dist/builtin/workflows/src/shared/expanded-workflow-graph.ts +206 -116
- package/dist/builtin/workflows/src/shared/intercom-group.ts +17 -10
- package/dist/builtin/workflows/src/shared/persistence-restore-helpers.ts +30 -0
- package/dist/builtin/workflows/src/shared/persistence-session-entries.ts +5 -0
- package/dist/builtin/workflows/src/shared/render-inputs-schema.ts +3 -3
- package/dist/builtin/workflows/src/shared/store-factory.ts +2 -0
- package/dist/builtin/workflows/src/shared/store-internal.ts +8 -0
- package/dist/builtin/workflows/src/shared/store-public-types.ts +8 -0
- package/dist/builtin/workflows/src/shared/store-run-methods.ts +9 -0
- package/dist/builtin/workflows/src/shared/store-stage-methods.ts +2 -0
- package/dist/builtin/workflows/src/shared/store-tool-node-methods.ts +46 -0
- package/dist/builtin/workflows/src/shared/store-types.ts +34 -0
- package/dist/builtin/workflows/src/shared/types.ts +14 -24
- package/dist/builtin/workflows/src/shared/workflow-failures-classifier.ts +11 -5
- package/dist/builtin/workflows/src/shared/workflow-failures-signals.ts +58 -0
- package/dist/builtin/workflows/src/shared/workflow-run-ownership.ts +53 -0
- package/dist/builtin/workflows/src/tui/graph-view-input.ts +2 -8
- package/dist/builtin/workflows/src/tui/graph-view-render-helpers.ts +11 -4
- package/dist/builtin/workflows/src/tui/graph-view-render.ts +1 -0
- package/dist/builtin/workflows/src/tui/graph-view-state.ts +27 -9
- package/dist/builtin/workflows/src/tui/graph-view-types.ts +4 -3
- package/dist/builtin/workflows/src/tui/node-card.ts +4 -3
- package/dist/builtin/workflows/src/tui/overlay-adapter.ts +0 -4
- package/dist/builtin/workflows/src/tui/run-detail.ts +53 -17
- package/dist/builtin/workflows/src/tui/session-list.ts +8 -4
- package/dist/builtin/workflows/src/tui/stage-chat-view-delivery-activity.ts +121 -0
- package/dist/builtin/workflows/src/tui/stage-chat-view-live-events.ts +42 -0
- package/dist/builtin/workflows/src/tui/stage-chat-view-render-helpers.ts +12 -0
- package/dist/builtin/workflows/src/tui/stage-chat-view-render-settings.ts +21 -1
- package/dist/builtin/workflows/src/tui/stage-chat-view-state.ts +19 -19
- package/dist/builtin/workflows/src/tui/stage-chat-view-types.ts +4 -0
- package/dist/builtin/workflows/src/tui/stage-chat-view.ts +4 -2
- package/dist/builtin/workflows/src/tui/switcher.ts +13 -3
- package/dist/builtin/workflows/src/tui/workflow-attach-pane-handle.ts +1 -1
- package/dist/builtin/workflows/src/tui/workflow-attach-pane-types.ts +0 -9
- package/dist/builtin/workflows/src/tui/workflow-attach-pane.ts +16 -49
- package/dist/builtin/workflows/src/tui/workflow-status.ts +7 -0
- package/dist/builtin/workflows/src/workflows/identity.ts +1 -1
- package/dist/cli/args.d.ts +0 -1
- package/dist/cli/args.d.ts.map +1 -1
- package/dist/cli/args.js +1 -20
- package/dist/cli/args.js.map +1 -1
- package/dist/cli/config-selector.js +1 -1
- package/dist/cli/config-selector.js.map +1 -1
- package/dist/cli/list-models.d.ts.map +1 -1
- package/dist/cli/list-models.js +1 -2
- package/dist/cli/list-models.js.map +1 -1
- package/dist/cli/session-picker.d.ts.map +1 -1
- package/dist/cli/session-picker.js +2 -1
- package/dist/cli/session-picker.js.map +1 -1
- package/dist/cli/startup-ui.js +2 -2
- package/dist/cli/startup-ui.js.map +1 -1
- package/dist/config-self-update.js +1 -1
- package/dist/config-self-update.js.map +1 -1
- package/dist/config.d.ts +2 -0
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +34 -10
- package/dist/config.js.map +1 -1
- package/dist/core/agent-session-accessors.d.ts.map +1 -1
- package/dist/core/agent-session-accessors.js +2 -1
- package/dist/core/agent-session-accessors.js.map +1 -1
- package/dist/core/agent-session-auto-compaction.d.ts +4 -3
- package/dist/core/agent-session-auto-compaction.d.ts.map +1 -1
- package/dist/core/agent-session-auto-compaction.js +55 -59
- package/dist/core/agent-session-auto-compaction.js.map +1 -1
- package/dist/core/agent-session-bash.d.ts +9 -6
- package/dist/core/agent-session-bash.d.ts.map +1 -1
- package/dist/core/agent-session-bash.js +32 -13
- package/dist/core/agent-session-bash.js.map +1 -1
- package/dist/core/agent-session-compaction.d.ts +11 -1
- package/dist/core/agent-session-compaction.d.ts.map +1 -1
- package/dist/core/agent-session-compaction.js +87 -19
- package/dist/core/agent-session-compaction.js.map +1 -1
- package/dist/core/agent-session-custom-message-commit.d.ts +14 -0
- package/dist/core/agent-session-custom-message-commit.d.ts.map +1 -0
- package/dist/core/agent-session-custom-message-commit.js +141 -0
- package/dist/core/agent-session-custom-message-commit.js.map +1 -0
- package/dist/core/agent-session-delivery-forwarding.d.ts +9 -0
- package/dist/core/agent-session-delivery-forwarding.d.ts.map +1 -0
- package/dist/core/agent-session-delivery-forwarding.js +36 -0
- package/dist/core/agent-session-delivery-forwarding.js.map +1 -0
- package/dist/core/agent-session-events.d.ts +1 -1
- package/dist/core/agent-session-events.d.ts.map +1 -1
- package/dist/core/agent-session-events.js +45 -14
- package/dist/core/agent-session-events.js.map +1 -1
- package/dist/core/agent-session-extension-bindings.d.ts +2 -6
- package/dist/core/agent-session-extension-bindings.d.ts.map +1 -1
- package/dist/core/agent-session-extension-bindings.js +18 -11
- package/dist/core/agent-session-extension-bindings.js.map +1 -1
- package/dist/core/agent-session-message-queue.d.ts +5 -2
- package/dist/core/agent-session-message-queue.d.ts.map +1 -1
- package/dist/core/agent-session-message-queue.js +91 -97
- package/dist/core/agent-session-message-queue.js.map +1 -1
- package/dist/core/agent-session-methods.d.ts +47 -39
- 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 +2 -38
- package/dist/core/agent-session-models.d.ts.map +1 -1
- package/dist/core/agent-session-models.js +5 -147
- package/dist/core/agent-session-models.js.map +1 -1
- package/dist/core/agent-session-persistent-custom-messages.d.ts +47 -0
- package/dist/core/agent-session-persistent-custom-messages.d.ts.map +1 -0
- package/dist/core/agent-session-persistent-custom-messages.js +267 -0
- package/dist/core/agent-session-persistent-custom-messages.js.map +1 -0
- package/dist/core/agent-session-post-tool-compaction.d.ts.map +1 -1
- package/dist/core/agent-session-post-tool-compaction.js +34 -9
- package/dist/core/agent-session-post-tool-compaction.js.map +1 -1
- package/dist/core/agent-session-prompt.d.ts +2 -0
- package/dist/core/agent-session-prompt.d.ts.map +1 -1
- package/dist/core/agent-session-prompt.js +42 -16
- package/dist/core/agent-session-prompt.js.map +1 -1
- package/dist/core/agent-session-queue-pause.d.ts +10 -0
- package/dist/core/agent-session-queue-pause.d.ts.map +1 -0
- package/dist/core/agent-session-queue-pause.js +86 -0
- package/dist/core/agent-session-queue-pause.js.map +1 -0
- package/dist/core/agent-session-retry.d.ts +0 -11
- package/dist/core/agent-session-retry.d.ts.map +1 -1
- package/dist/core/agent-session-retry.js +8 -57
- package/dist/core/agent-session-retry.js.map +1 -1
- package/dist/core/agent-session-runtime-auth.d.ts +6 -0
- package/dist/core/agent-session-runtime-auth.d.ts.map +1 -0
- package/dist/core/agent-session-runtime-auth.js +26 -0
- package/dist/core/agent-session-runtime-auth.js.map +1 -0
- package/dist/core/agent-session-runtime.d.ts +13 -2
- package/dist/core/agent-session-runtime.d.ts.map +1 -1
- package/dist/core/agent-session-runtime.js +32 -6
- package/dist/core/agent-session-runtime.js.map +1 -1
- package/dist/core/agent-session-services.d.ts +0 -2
- package/dist/core/agent-session-services.d.ts.map +1 -1
- package/dist/core/agent-session-services.js +6 -7
- package/dist/core/agent-session-services.js.map +1 -1
- package/dist/core/agent-session-state.d.ts.map +1 -1
- package/dist/core/agent-session-state.js +3 -0
- package/dist/core/agent-session-state.js.map +1 -1
- package/dist/core/agent-session-tool-hooks.d.ts.map +1 -1
- package/dist/core/agent-session-tool-hooks.js +6 -1
- package/dist/core/agent-session-tool-hooks.js.map +1 -1
- package/dist/core/agent-session-tool-registry.d.ts.map +1 -1
- package/dist/core/agent-session-tool-registry.js +2 -18
- package/dist/core/agent-session-tool-registry.js.map +1 -1
- package/dist/core/agent-session-transfer.d.ts +4 -0
- package/dist/core/agent-session-transfer.d.ts.map +1 -0
- package/dist/core/agent-session-transfer.js +71 -0
- package/dist/core/agent-session-transfer.js.map +1 -0
- package/dist/core/agent-session-tree.js +1 -1
- package/dist/core/agent-session-tree.js.map +1 -1
- package/dist/core/agent-session-types.d.ts +5 -11
- package/dist/core/agent-session-types.d.ts.map +1 -1
- package/dist/core/agent-session-types.js +0 -3
- package/dist/core/agent-session-types.js.map +1 -1
- package/dist/core/agent-session.d.ts +12 -2
- package/dist/core/agent-session.d.ts.map +1 -1
- package/dist/core/agent-session.js +8 -2
- package/dist/core/agent-session.js.map +1 -1
- package/dist/core/atomic-guide-command.d.ts.map +1 -1
- package/dist/core/atomic-guide-command.js +31 -33
- package/dist/core/atomic-guide-command.js.map +1 -1
- package/dist/core/auth-storage.js +2 -2
- package/dist/core/auth-storage.js.map +1 -1
- package/dist/core/bash-executor.d.ts +5 -3
- package/dist/core/bash-executor.d.ts.map +1 -1
- package/dist/core/bash-executor.js +5 -4
- package/dist/core/bash-executor.js.map +1 -1
- package/dist/core/builtin-packages.d.ts.map +1 -1
- package/dist/core/builtin-packages.js +0 -6
- package/dist/core/builtin-packages.js.map +1 -1
- package/dist/core/compaction/branch-summarization.d.ts +8 -3
- package/dist/core/compaction/branch-summarization.d.ts.map +1 -1
- package/dist/core/compaction/branch-summarization.js +17 -6
- package/dist/core/compaction/branch-summarization.js.map +1 -1
- package/dist/core/compaction/compaction-boundary.d.ts +18 -1
- package/dist/core/compaction/compaction-boundary.d.ts.map +1 -1
- package/dist/core/compaction/compaction-boundary.js +2 -2
- package/dist/core/compaction/compaction-boundary.js.map +1 -1
- package/dist/core/compaction/compaction-runner.d.ts +61 -6
- package/dist/core/compaction/compaction-runner.d.ts.map +1 -1
- package/dist/core/compaction/compaction-runner.js +242 -18
- package/dist/core/compaction/compaction-runner.js.map +1 -1
- package/dist/core/compaction/compaction-types.d.ts +53 -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/fallback-planner.d.ts +64 -0
- package/dist/core/compaction/fallback-planner.d.ts.map +1 -0
- package/dist/core/compaction/fallback-planner.js +75 -0
- package/dist/core/compaction/fallback-planner.js.map +1 -0
- package/dist/core/compaction/index.d.ts +3 -0
- package/dist/core/compaction/index.d.ts.map +1 -1
- package/dist/core/compaction/index.js +3 -0
- package/dist/core/compaction/index.js.map +1 -1
- package/dist/core/compaction/planner-outcome.d.ts +86 -0
- package/dist/core/compaction/planner-outcome.d.ts.map +1 -0
- package/dist/core/compaction/planner-outcome.js +122 -0
- package/dist/core/compaction/planner-outcome.js.map +1 -0
- package/dist/core/compaction/range-planner-diagnostics.d.ts +58 -6
- package/dist/core/compaction/range-planner-diagnostics.d.ts.map +1 -1
- package/dist/core/compaction/range-planner-diagnostics.js +69 -31
- package/dist/core/compaction/range-planner-diagnostics.js.map +1 -1
- package/dist/core/compaction/range-planner.d.ts +36 -8
- package/dist/core/compaction/range-planner.d.ts.map +1 -1
- package/dist/core/compaction/range-planner.js +136 -51
- package/dist/core/compaction/range-planner.js.map +1 -1
- package/dist/core/compaction/region-trimming.d.ts +34 -0
- package/dist/core/compaction/region-trimming.d.ts.map +1 -0
- package/dist/core/compaction/region-trimming.js +73 -0
- package/dist/core/compaction/region-trimming.js.map +1 -0
- package/dist/core/compaction/transcript-serialization.d.ts +8 -1
- package/dist/core/compaction/transcript-serialization.d.ts.map +1 -1
- package/dist/core/compaction/transcript-serialization.js +78 -27
- package/dist/core/compaction/transcript-serialization.js.map +1 -1
- package/dist/core/context-tool-pairing.d.ts +19 -0
- package/dist/core/context-tool-pairing.d.ts.map +1 -0
- package/dist/core/context-tool-pairing.js +50 -0
- package/dist/core/context-tool-pairing.js.map +1 -0
- package/dist/core/diagnostics.d.ts +8 -0
- package/dist/core/diagnostics.d.ts.map +1 -1
- package/dist/core/diagnostics.js.map +1 -1
- package/dist/core/extensions/context-types.d.ts +3 -0
- 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 +2 -0
- 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.d.ts.map +1 -1
- package/dist/core/extensions/loader-api.js +48 -27
- package/dist/core/extensions/loader-api.js.map +1 -1
- package/dist/core/extensions/loader-runtime.d.ts +2 -4
- package/dist/core/extensions/loader-runtime.d.ts.map +1 -1
- package/dist/core/extensions/loader-runtime.js +199 -18
- package/dist/core/extensions/loader-runtime.js.map +1 -1
- package/dist/core/extensions/message-types.d.ts +7 -4
- 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 +9 -4
- 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-context.d.ts +2 -0
- package/dist/core/extensions/runner-context.d.ts.map +1 -1
- package/dist/core/extensions/runner-context.js +4 -0
- package/dist/core/extensions/runner-context.js.map +1 -1
- package/dist/core/extensions/runner.d.ts +1 -0
- package/dist/core/extensions/runner.d.ts.map +1 -1
- package/dist/core/extensions/runner.js +28 -20
- package/dist/core/extensions/runner.js.map +1 -1
- package/dist/core/extensions/runtime-types.d.ts +25 -0
- 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/tool-types.d.ts +7 -3
- package/dist/core/extensions/tool-types.d.ts.map +1 -1
- package/dist/core/extensions/tool-types.js.map +1 -1
- package/dist/core/extensions/ui-types.d.ts +14 -4
- package/dist/core/extensions/ui-types.d.ts.map +1 -1
- package/dist/core/extensions/ui-types.js.map +1 -1
- package/dist/core/fallback-models.d.ts +37 -0
- package/dist/core/fallback-models.d.ts.map +1 -0
- package/dist/core/fallback-models.js +48 -0
- package/dist/core/fallback-models.js.map +1 -0
- package/dist/core/flattened-tool-arguments.d.ts +4 -7
- package/dist/core/flattened-tool-arguments.d.ts.map +1 -1
- package/dist/core/flattened-tool-arguments.js +4 -7
- package/dist/core/flattened-tool-arguments.js.map +1 -1
- package/dist/core/http-dispatcher.d.ts.map +1 -1
- package/dist/core/http-dispatcher.js +0 -5
- package/dist/core/http-dispatcher.js.map +1 -1
- package/dist/core/messages.d.ts +14 -2
- package/dist/core/messages.d.ts.map +1 -1
- package/dist/core/messages.js +28 -4
- package/dist/core/messages.js.map +1 -1
- package/dist/core/model-capabilities.d.ts +18 -0
- package/dist/core/model-capabilities.d.ts.map +1 -0
- package/dist/core/model-capabilities.js +23 -0
- package/dist/core/model-capabilities.js.map +1 -0
- package/dist/core/model-registry-auth.d.ts.map +1 -1
- package/dist/core/model-registry-auth.js +0 -2
- package/dist/core/model-registry-auth.js.map +1 -1
- package/dist/core/model-registry-builtins.d.ts +0 -2
- package/dist/core/model-registry-builtins.d.ts.map +1 -1
- package/dist/core/model-registry-builtins.js +9 -76
- package/dist/core/model-registry-builtins.js.map +1 -1
- package/dist/core/model-registry-custom-loader.d.ts.map +1 -1
- package/dist/core/model-registry-custom-loader.js +1 -12
- package/dist/core/model-registry-custom-loader.js.map +1 -1
- package/dist/core/model-registry-dynamic.d.ts.map +1 -1
- package/dist/core/model-registry-dynamic.js +3 -15
- package/dist/core/model-registry-dynamic.js.map +1 -1
- package/dist/core/model-registry-extension-refresh.d.ts +23 -0
- package/dist/core/model-registry-extension-refresh.d.ts.map +1 -0
- package/dist/core/model-registry-extension-refresh.js +32 -0
- package/dist/core/model-registry-extension-refresh.js.map +1 -0
- package/dist/core/model-registry-schemas.d.ts +118 -9
- package/dist/core/model-registry-schemas.d.ts.map +1 -1
- package/dist/core/model-registry-schemas.js +10 -3
- package/dist/core/model-registry-schemas.js.map +1 -1
- package/dist/core/model-registry-types.d.ts +5 -5
- 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-validation.d.ts +7 -0
- package/dist/core/model-registry-validation.d.ts.map +1 -0
- package/dist/core/model-registry-validation.js +12 -0
- package/dist/core/model-registry-validation.js.map +1 -0
- package/dist/core/model-registry.d.ts +5 -3
- package/dist/core/model-registry.d.ts.map +1 -1
- package/dist/core/model-registry.js +34 -33
- package/dist/core/model-registry.js.map +1 -1
- package/dist/core/model-resolver-defaults.d.ts.map +1 -1
- package/dist/core/model-resolver-defaults.js +0 -1
- package/dist/core/model-resolver-defaults.js.map +1 -1
- package/dist/core/model-resolver-initial.d.ts.map +1 -1
- package/dist/core/model-resolver-initial.js +9 -0
- package/dist/core/model-resolver-initial.js.map +1 -1
- package/dist/core/model-resolver-patterns.d.ts.map +1 -1
- package/dist/core/model-resolver-patterns.js +0 -2
- package/dist/core/model-resolver-patterns.js.map +1 -1
- package/dist/core/model-resolver-scope.d.ts +2 -0
- package/dist/core/model-resolver-scope.d.ts.map +1 -1
- package/dist/core/model-resolver-scope.js +18 -4
- package/dist/core/model-resolver-scope.js.map +1 -1
- package/dist/core/model-resolver-types.d.ts +2 -0
- package/dist/core/model-resolver-types.d.ts.map +1 -1
- package/dist/core/model-resolver-types.js.map +1 -1
- package/dist/core/oauth-provider-bridge.d.ts +21 -0
- package/dist/core/oauth-provider-bridge.d.ts.map +1 -1
- package/dist/core/oauth-provider-bridge.js +68 -7
- package/dist/core/oauth-provider-bridge.js.map +1 -1
- package/dist/core/package-manager-auto-resources.d.ts.map +1 -1
- package/dist/core/package-manager-auto-resources.js +12 -4
- package/dist/core/package-manager-auto-resources.js.map +1 -1
- package/dist/core/package-manager-resolver.d.ts.map +1 -1
- package/dist/core/package-manager-resolver.js +42 -11
- package/dist/core/package-manager-resolver.js.map +1 -1
- package/dist/core/package-manager-types.d.ts +2 -0
- package/dist/core/package-manager-types.d.ts.map +1 -1
- package/dist/core/package-manager-types.js.map +1 -1
- package/dist/core/package-manager.d.ts +1 -1
- package/dist/core/package-manager.d.ts.map +1 -1
- package/dist/core/package-manager.js.map +1 -1
- package/dist/core/remote-catalog-provider.d.ts +1 -1
- package/dist/core/remote-catalog-provider.d.ts.map +1 -1
- package/dist/core/remote-catalog-provider.js +17 -11
- package/dist/core/remote-catalog-provider.js.map +1 -1
- package/dist/core/resource-loader-assets.d.ts.map +1 -1
- package/dist/core/resource-loader-assets.js +30 -4
- package/dist/core/resource-loader-assets.js.map +1 -1
- package/dist/core/resource-loader-context-files.d.ts.map +1 -1
- package/dist/core/resource-loader-context-files.js +3 -1
- package/dist/core/resource-loader-context-files.js.map +1 -1
- package/dist/core/resource-loader-core.d.ts +2 -1
- package/dist/core/resource-loader-core.d.ts.map +1 -1
- package/dist/core/resource-loader-core.js +3 -0
- package/dist/core/resource-loader-core.js.map +1 -1
- package/dist/core/resource-loader-extensions.d.ts +1 -0
- package/dist/core/resource-loader-extensions.d.ts.map +1 -1
- package/dist/core/resource-loader-extensions.js +120 -7
- package/dist/core/resource-loader-extensions.js.map +1 -1
- package/dist/core/resource-loader-package-resources.d.ts.map +1 -1
- package/dist/core/resource-loader-package-resources.js +14 -1
- package/dist/core/resource-loader-package-resources.js.map +1 -1
- package/dist/core/resource-loader-reload.d.ts.map +1 -1
- package/dist/core/resource-loader-reload.js +2 -1
- package/dist/core/resource-loader-reload.js.map +1 -1
- package/dist/core/resource-loader-source-info.d.ts.map +1 -1
- package/dist/core/resource-loader-source-info.js +6 -3
- package/dist/core/resource-loader-source-info.js.map +1 -1
- package/dist/core/sdk-types.d.ts +11 -10
- package/dist/core/sdk-types.d.ts.map +1 -1
- package/dist/core/sdk-types.js.map +1 -1
- package/dist/core/sdk.d.ts +1 -0
- package/dist/core/sdk.d.ts.map +1 -1
- package/dist/core/sdk.js +13 -84
- package/dist/core/sdk.js.map +1 -1
- package/dist/core/session-manager-core.d.ts +3 -3
- package/dist/core/session-manager-core.d.ts.map +1 -1
- package/dist/core/session-manager-core.js +18 -25
- package/dist/core/session-manager-core.js.map +1 -1
- package/dist/core/session-manager-entries.d.ts +2 -5
- package/dist/core/session-manager-entries.d.ts.map +1 -1
- package/dist/core/session-manager-entries.js +2 -8
- package/dist/core/session-manager-entries.js.map +1 -1
- package/dist/core/session-manager-history.d.ts +3 -3
- package/dist/core/session-manager-history.d.ts.map +1 -1
- package/dist/core/session-manager-history.js +49 -27
- package/dist/core/session-manager-history.js.map +1 -1
- package/dist/core/session-manager-storage.d.ts +6 -0
- package/dist/core/session-manager-storage.d.ts.map +1 -1
- package/dist/core/session-manager-storage.js +38 -5
- package/dist/core/session-manager-storage.js.map +1 -1
- package/dist/core/session-manager-types.d.ts +6 -6
- package/dist/core/session-manager-types.d.ts.map +1 -1
- package/dist/core/session-manager-types.js.map +1 -1
- package/dist/core/session-manager.d.ts +1 -1
- package/dist/core/session-manager.d.ts.map +1 -1
- package/dist/core/session-manager.js.map +1 -1
- package/dist/core/settings-manager-basic-accessors.d.ts +0 -4
- package/dist/core/settings-manager-basic-accessors.d.ts.map +1 -1
- package/dist/core/settings-manager-basic-accessors.js +0 -50
- package/dist/core/settings-manager-basic-accessors.js.map +1 -1
- package/dist/core/settings-manager-core.d.ts +2 -4
- package/dist/core/settings-manager-core.d.ts.map +1 -1
- package/dist/core/settings-manager-core.js +5 -51
- package/dist/core/settings-manager-core.js.map +1 -1
- package/dist/core/settings-manager.d.ts +1 -1
- package/dist/core/settings-manager.d.ts.map +1 -1
- package/dist/core/settings-manager.js.map +1 -1
- package/dist/core/settings-storage.d.ts +3 -1
- package/dist/core/settings-storage.d.ts.map +1 -1
- package/dist/core/settings-storage.js +22 -0
- package/dist/core/settings-storage.js.map +1 -1
- package/dist/core/settings-types.d.ts +2 -4
- package/dist/core/settings-types.d.ts.map +1 -1
- package/dist/core/settings-types.js.map +1 -1
- package/dist/core/slash-commands.d.ts.map +1 -1
- package/dist/core/slash-commands.js +68 -22
- package/dist/core/slash-commands.js.map +1 -1
- package/dist/core/source-info.d.ts +3 -1
- package/dist/core/source-info.d.ts.map +1 -1
- package/dist/core/source-info.js +2 -0
- package/dist/core/source-info.js.map +1 -1
- package/dist/core/tools/ask-user-question/ask-user-question.js +1 -1
- package/dist/core/tools/ask-user-question/ask-user-question.js.map +1 -1
- package/dist/core/tools/bash-session-environment.d.ts +13 -0
- package/dist/core/tools/bash-session-environment.d.ts.map +1 -0
- package/dist/core/tools/bash-session-environment.js +35 -0
- package/dist/core/tools/bash-session-environment.js.map +1 -0
- package/dist/core/tools/bash.d.ts +4 -1
- package/dist/core/tools/bash.d.ts.map +1 -1
- package/dist/core/tools/bash.js +16 -8
- package/dist/core/tools/bash.js.map +1 -1
- package/dist/core/tools/tool-definition-wrapper.d.ts +3 -0
- package/dist/core/tools/tool-definition-wrapper.d.ts.map +1 -1
- package/dist/core/tools/tool-definition-wrapper.js +10 -2
- package/dist/core/tools/tool-definition-wrapper.js.map +1 -1
- package/dist/extensions/index.js +1 -1
- package/dist/extensions/index.js.map +1 -1
- package/dist/extensions/llama/provider.d.ts +3 -2
- package/dist/extensions/llama/provider.d.ts.map +1 -1
- package/dist/extensions/llama/provider.js +9 -3
- package/dist/extensions/llama/provider.js.map +1 -1
- 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 +2 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -2
- package/dist/index.js.map +1 -1
- package/dist/main-session-options.d.ts.map +1 -1
- package/dist/main-session-options.js +0 -4
- package/dist/main-session-options.js.map +1 -1
- package/dist/main-session.d.ts.map +1 -1
- package/dist/main-session.js +2 -1
- package/dist/main-session.js.map +1 -1
- package/dist/main.d.ts.map +1 -1
- package/dist/main.js +1 -17
- package/dist/main.js.map +1 -1
- package/dist/modes/index.d.ts +1 -1
- package/dist/modes/index.d.ts.map +1 -1
- package/dist/modes/index.js.map +1 -1
- package/dist/modes/interactive/chat-input-actions.d.ts +1 -1
- package/dist/modes/interactive/chat-input-actions.d.ts.map +1 -1
- package/dist/modes/interactive/chat-input-actions.js +14 -96
- package/dist/modes/interactive/chat-input-actions.js.map +1 -1
- package/dist/modes/interactive/components/atomic-banner.d.ts +9 -8
- package/dist/modes/interactive/components/atomic-banner.d.ts.map +1 -1
- package/dist/modes/interactive/components/atomic-banner.js +68 -24
- package/dist/modes/interactive/components/atomic-banner.js.map +1 -1
- package/dist/modes/interactive/components/atomic-working-status.d.ts +52 -0
- package/dist/modes/interactive/components/atomic-working-status.d.ts.map +1 -0
- package/dist/modes/interactive/components/atomic-working-status.js +202 -0
- package/dist/modes/interactive/components/atomic-working-status.js.map +1 -0
- package/dist/modes/interactive/components/chat-message-renderer.js +1 -1
- package/dist/modes/interactive/components/chat-message-renderer.js.map +1 -1
- package/dist/modes/interactive/components/chat-session-host-actions.d.ts.map +1 -1
- package/dist/modes/interactive/components/chat-session-host-actions.js +87 -7
- package/dist/modes/interactive/components/chat-session-host-actions.js.map +1 -1
- package/dist/modes/interactive/components/chat-session-host-editor.js +3 -3
- package/dist/modes/interactive/components/chat-session-host-editor.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 +61 -9
- 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 +23 -7
- package/dist/modes/interactive/components/chat-session-host-rendering.js.map +1 -1
- package/dist/modes/interactive/components/chat-session-host-runtime.d.ts +27 -0
- package/dist/modes/interactive/components/chat-session-host-runtime.d.ts.map +1 -1
- package/dist/modes/interactive/components/chat-session-host-runtime.js +120 -18
- package/dist/modes/interactive/components/chat-session-host-runtime.js.map +1 -1
- package/dist/modes/interactive/components/chat-session-host-state.d.ts +9 -0
- package/dist/modes/interactive/components/chat-session-host-state.d.ts.map +1 -1
- package/dist/modes/interactive/components/chat-session-host-state.js +5 -0
- package/dist/modes/interactive/components/chat-session-host-state.js.map +1 -1
- package/dist/modes/interactive/components/chat-session-host-types.d.ts +10 -0
- package/dist/modes/interactive/components/chat-session-host-types.d.ts.map +1 -1
- package/dist/modes/interactive/components/chat-session-host-types.js.map +1 -1
- package/dist/modes/interactive/components/chat-session-host.d.ts +13 -0
- package/dist/modes/interactive/components/chat-session-host.d.ts.map +1 -1
- package/dist/modes/interactive/components/chat-session-host.js +22 -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 +2 -1
- package/dist/modes/interactive/components/compaction-boundary-message.js.map +1 -1
- package/dist/modes/interactive/components/custom-message.d.ts +3 -1
- package/dist/modes/interactive/components/custom-message.d.ts.map +1 -1
- package/dist/modes/interactive/components/custom-message.js +9 -2
- package/dist/modes/interactive/components/custom-message.js.map +1 -1
- package/dist/modes/interactive/components/extension-editor.d.ts +3 -2
- package/dist/modes/interactive/components/extension-editor.d.ts.map +1 -1
- package/dist/modes/interactive/components/extension-editor.js +14 -43
- package/dist/modes/interactive/components/extension-editor.js.map +1 -1
- package/dist/modes/interactive/components/scoped-models-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/scoped-models-selector.js +18 -13
- package/dist/modes/interactive/components/scoped-models-selector.js.map +1 -1
- package/dist/modes/interactive/components/startup-identity.d.ts +22 -0
- package/dist/modes/interactive/components/startup-identity.d.ts.map +1 -0
- package/dist/modes/interactive/components/startup-identity.js +58 -0
- package/dist/modes/interactive/components/startup-identity.js.map +1 -0
- package/dist/modes/interactive/components/tree-selector-content.d.ts.map +1 -1
- package/dist/modes/interactive/components/tree-selector-content.js +0 -6
- package/dist/modes/interactive/components/tree-selector-content.js.map +1 -1
- package/dist/modes/interactive/components/tree-selector-model.d.ts.map +1 -1
- package/dist/modes/interactive/components/tree-selector-model.js +0 -1
- package/dist/modes/interactive/components/tree-selector-model.js.map +1 -1
- package/dist/modes/interactive/components/working-status.d.ts +5 -11
- package/dist/modes/interactive/components/working-status.d.ts.map +1 -1
- package/dist/modes/interactive/components/working-status.js +14 -15
- package/dist/modes/interactive/components/working-status.js.map +1 -1
- package/dist/modes/interactive/external-editor.d.ts +23 -0
- package/dist/modes/interactive/external-editor.d.ts.map +1 -0
- package/dist/modes/interactive/external-editor.js +120 -0
- package/dist/modes/interactive/external-editor.js.map +1 -0
- package/dist/modes/interactive/interactive-agent-events.js +33 -22
- package/dist/modes/interactive/interactive-agent-events.js.map +1 -1
- package/dist/modes/interactive/interactive-auth-login.js +16 -6
- package/dist/modes/interactive/interactive-auth-login.js.map +1 -1
- package/dist/modes/interactive/interactive-auth-routing.js +3 -0
- package/dist/modes/interactive/interactive-auth-routing.js.map +1 -1
- package/dist/modes/interactive/interactive-bash-compact.d.ts +2 -1
- package/dist/modes/interactive/interactive-bash-compact.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-bash-compact.js +8 -0
- package/dist/modes/interactive/interactive-bash-compact.js.map +1 -1
- package/dist/modes/interactive/interactive-deferred-startup.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-deferred-startup.js +49 -19
- package/dist/modes/interactive/interactive-deferred-startup.js.map +1 -1
- package/dist/modes/interactive/interactive-editor-actions.js +4 -3
- package/dist/modes/interactive/interactive-editor-actions.js.map +1 -1
- package/dist/modes/interactive/interactive-extension-dialogs.js +1 -1
- package/dist/modes/interactive/interactive-extension-dialogs.js.map +1 -1
- package/dist/modes/interactive/interactive-extension-runtime.js +3 -2
- package/dist/modes/interactive/interactive-extension-runtime.js.map +1 -1
- package/dist/modes/interactive/interactive-initial-session-binding.d.ts +4 -0
- package/dist/modes/interactive/interactive-initial-session-binding.d.ts.map +1 -0
- package/dist/modes/interactive/interactive-initial-session-binding.js +23 -0
- package/dist/modes/interactive/interactive-initial-session-binding.js.map +1 -0
- package/dist/modes/interactive/interactive-input-handling.d.ts +2 -1
- package/dist/modes/interactive/interactive-input-handling.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-input-handling.js +27 -51
- package/dist/modes/interactive/interactive-input-handling.js.map +1 -1
- package/dist/modes/interactive/interactive-mode-base.d.ts +11 -7
- package/dist/modes/interactive/interactive-mode-base.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-mode-base.js +14 -6
- package/dist/modes/interactive/interactive-mode-base.js.map +1 -1
- package/dist/modes/interactive/interactive-mode-deps.d.ts +2 -4
- package/dist/modes/interactive/interactive-mode-deps.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-mode-deps.js +2 -4
- package/dist/modes/interactive/interactive-mode-deps.js.map +1 -1
- package/dist/modes/interactive/interactive-mode-surface.d.ts +9 -8
- 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.d.ts +1 -0
- package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-mode.js +1 -0
- package/dist/modes/interactive/interactive-mode.js.map +1 -1
- package/dist/modes/interactive/interactive-model-catalog-startup.d.ts +2 -3
- package/dist/modes/interactive/interactive-model-catalog-startup.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-model-catalog-startup.js +3 -6
- package/dist/modes/interactive/interactive-model-catalog-startup.js.map +1 -1
- package/dist/modes/interactive/interactive-model-routing.js +26 -97
- package/dist/modes/interactive/interactive-model-routing.js.map +1 -1
- package/dist/modes/interactive/interactive-pause.d.ts +4 -0
- package/dist/modes/interactive/interactive-pause.d.ts.map +1 -0
- package/dist/modes/interactive/interactive-pause.js +8 -0
- package/dist/modes/interactive/interactive-pause.js.map +1 -0
- package/dist/modes/interactive/interactive-process-lifecycle.js +5 -4
- package/dist/modes/interactive/interactive-process-lifecycle.js.map +1 -1
- package/dist/modes/interactive/interactive-prompt-turn.d.ts +2 -0
- package/dist/modes/interactive/interactive-prompt-turn.d.ts.map +1 -0
- package/dist/modes/interactive/interactive-prompt-turn.js +41 -0
- package/dist/modes/interactive/interactive-prompt-turn.js.map +1 -0
- package/dist/modes/interactive/interactive-render-chat.js +20 -8
- package/dist/modes/interactive/interactive-render-chat.js.map +1 -1
- package/dist/modes/interactive/interactive-resource-paths.js +11 -2
- package/dist/modes/interactive/interactive-resource-paths.js.map +1 -1
- package/dist/modes/interactive/interactive-resource-rendering.js +99 -0
- package/dist/modes/interactive/interactive-resource-rendering.js.map +1 -1
- package/dist/modes/interactive/interactive-session-runtime.js +1 -1
- package/dist/modes/interactive/interactive-session-runtime.js.map +1 -1
- package/dist/modes/interactive/interactive-slash-commands.js +1 -1
- package/dist/modes/interactive/interactive-slash-commands.js.map +1 -1
- package/dist/modes/interactive/interactive-startup-chat-container.d.ts +20 -0
- package/dist/modes/interactive/interactive-startup-chat-container.d.ts.map +1 -0
- package/dist/modes/interactive/interactive-startup-chat-container.js +26 -0
- package/dist/modes/interactive/interactive-startup-chat-container.js.map +1 -0
- 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 +30 -25
- package/dist/modes/interactive/interactive-startup.js.map +1 -1
- package/dist/modes/interactive/interactive-summarization-retry-events.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-summarization-retry-events.js +9 -3
- package/dist/modes/interactive/interactive-summarization-retry-events.js.map +1 -1
- package/dist/modes/interactive/theme/catppuccin-frappe.json +1 -1
- package/dist/modes/interactive/theme/catppuccin-latte.json +1 -1
- package/dist/modes/interactive/theme/catppuccin-macchiato.json +1 -1
- package/dist/modes/interactive/theme/catppuccin-mocha.json +9 -1
- package/dist/modes/interactive/theme/dark.json +1 -1
- package/dist/modes/interactive/theme/light.json +1 -1
- package/dist/modes/interactive/theme/theme-class.d.ts +4 -0
- package/dist/modes/interactive/theme/theme-class.d.ts.map +1 -1
- package/dist/modes/interactive/theme/theme-class.js +7 -0
- package/dist/modes/interactive/theme/theme-class.js.map +1 -1
- package/dist/modes/interactive/theme/theme-loading.d.ts.map +1 -1
- package/dist/modes/interactive/theme/theme-loading.js +4 -0
- package/dist/modes/interactive/theme/theme-loading.js.map +1 -1
- package/dist/modes/interactive/theme/theme-schema.d.ts +32 -0
- package/dist/modes/interactive/theme/theme-schema.d.ts.map +1 -1
- package/dist/modes/interactive/theme/theme-schema.js +8 -0
- package/dist/modes/interactive/theme/theme-schema.js.map +1 -1
- package/dist/modes/interactive/theme/theme-schema.json +15 -2
- package/dist/modes/interactive/whimsical-messages.d.ts +1 -0
- package/dist/modes/interactive/whimsical-messages.d.ts.map +1 -1
- package/dist/modes/interactive/whimsical-messages.js +2 -2
- package/dist/modes/interactive/whimsical-messages.js.map +1 -1
- package/dist/modes/interactive-engine/create-isolated-runtime.d.ts.map +1 -1
- package/dist/modes/interactive-engine/create-isolated-runtime.js +3 -1
- package/dist/modes/interactive-engine/create-isolated-runtime.js.map +1 -1
- package/dist/modes/interactive-engine/engine-args.d.ts.map +1 -1
- package/dist/modes/interactive-engine/engine-args.js +0 -1
- package/dist/modes/interactive-engine/engine-args.js.map +1 -1
- package/dist/modes/interactive-engine/engine-custom-ui.d.ts.map +1 -1
- package/dist/modes/interactive-engine/engine-custom-ui.js +5 -17
- package/dist/modes/interactive-engine/engine-custom-ui.js.map +1 -1
- package/dist/modes/interactive-engine/engine-render-service.d.ts.map +1 -1
- package/dist/modes/interactive-engine/engine-render-service.js +8 -19
- package/dist/modes/interactive-engine/engine-render-service.js.map +1 -1
- package/dist/modes/interactive-engine/extension-ui-bridge.d.ts +2 -0
- package/dist/modes/interactive-engine/extension-ui-bridge.d.ts.map +1 -1
- package/dist/modes/interactive-engine/extension-ui-bridge.js +3 -0
- package/dist/modes/interactive-engine/extension-ui-bridge.js.map +1 -1
- package/dist/modes/interactive-engine/isolated-auth.d.ts +10 -0
- package/dist/modes/interactive-engine/isolated-auth.d.ts.map +1 -0
- package/dist/modes/interactive-engine/isolated-auth.js +14 -0
- package/dist/modes/interactive-engine/isolated-auth.js.map +1 -0
- package/dist/modes/interactive-engine/isolated-runtime.d.ts +9 -1
- package/dist/modes/interactive-engine/isolated-runtime.d.ts.map +1 -1
- package/dist/modes/interactive-engine/isolated-runtime.js +46 -34
- package/dist/modes/interactive-engine/isolated-runtime.js.map +1 -1
- package/dist/modes/interactive-engine/protocol.d.ts +1 -1
- package/dist/modes/interactive-engine/protocol.d.ts.map +1 -1
- package/dist/modes/interactive-engine/protocol.js +3 -10
- package/dist/modes/interactive-engine/protocol.js.map +1 -1
- package/dist/modes/interactive-engine/remote-model-catalog.d.ts +1 -0
- package/dist/modes/interactive-engine/remote-model-catalog.d.ts.map +1 -1
- package/dist/modes/interactive-engine/remote-model-catalog.js +10 -1
- package/dist/modes/interactive-engine/remote-model-catalog.js.map +1 -1
- package/dist/modes/interactive-engine/remote-queue-pause.d.ts +13 -0
- package/dist/modes/interactive-engine/remote-queue-pause.d.ts.map +1 -0
- package/dist/modes/interactive-engine/remote-queue-pause.js +38 -0
- package/dist/modes/interactive-engine/remote-queue-pause.js.map +1 -0
- package/dist/modes/interactive-engine/remote-renderer.d.ts +3 -1
- package/dist/modes/interactive-engine/remote-renderer.d.ts.map +1 -1
- package/dist/modes/interactive-engine/remote-renderer.js +4 -1
- package/dist/modes/interactive-engine/remote-renderer.js.map +1 -1
- package/dist/modes/print-mode.d.ts.map +1 -1
- package/dist/modes/print-mode.js +5 -0
- package/dist/modes/print-mode.js.map +1 -1
- package/dist/modes/rpc/jsonl.d.ts +2 -7
- package/dist/modes/rpc/jsonl.d.ts.map +1 -1
- package/dist/modes/rpc/jsonl.js +7 -24
- package/dist/modes/rpc/jsonl.js.map +1 -1
- package/dist/modes/rpc/queued-writer.d.ts +19 -0
- package/dist/modes/rpc/queued-writer.d.ts.map +1 -0
- package/dist/modes/rpc/{bounded-writer.js → queued-writer.js} +7 -30
- package/dist/modes/rpc/queued-writer.js.map +1 -0
- package/dist/modes/rpc/rpc-bash-request-owners.d.ts +24 -0
- package/dist/modes/rpc/rpc-bash-request-owners.d.ts.map +1 -0
- package/dist/modes/rpc/rpc-bash-request-owners.js +45 -0
- package/dist/modes/rpc/rpc-bash-request-owners.js.map +1 -0
- package/dist/modes/rpc/rpc-client-api.d.ts +8 -5
- package/dist/modes/rpc/rpc-client-api.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-client-api.js +10 -11
- package/dist/modes/rpc/rpc-client-api.js.map +1 -1
- package/dist/modes/rpc/rpc-client-process.d.ts +1 -4
- package/dist/modes/rpc/rpc-client-process.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-client-process.js +2 -14
- package/dist/modes/rpc/rpc-client-process.js.map +1 -1
- package/dist/modes/rpc/rpc-client.d.ts +8 -4
- package/dist/modes/rpc/rpc-client.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-client.js +21 -30
- package/dist/modes/rpc/rpc-client.js.map +1 -1
- package/dist/modes/rpc/rpc-command-handler.d.ts +7 -4
- package/dist/modes/rpc/rpc-command-handler.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-command-handler.js +76 -93
- package/dist/modes/rpc/rpc-command-handler.js.map +1 -1
- package/dist/modes/rpc/rpc-input-scheduler.d.ts +3 -3
- package/dist/modes/rpc/rpc-input-scheduler.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-input-scheduler.js +7 -4
- package/dist/modes/rpc/rpc-input-scheduler.js.map +1 -1
- package/dist/modes/rpc/rpc-mode.d.ts +1 -1
- package/dist/modes/rpc/rpc-mode.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-mode.js +5 -5
- package/dist/modes/rpc/rpc-mode.js.map +1 -1
- package/dist/modes/rpc/rpc-model-fallback-prompt.d.ts +4 -0
- package/dist/modes/rpc/rpc-model-fallback-prompt.d.ts.map +1 -0
- package/dist/modes/rpc/rpc-model-fallback-prompt.js +11 -0
- package/dist/modes/rpc/rpc-model-fallback-prompt.js.map +1 -0
- package/dist/modes/rpc/rpc-oauth-client.d.ts +22 -0
- package/dist/modes/rpc/rpc-oauth-client.d.ts.map +1 -0
- package/dist/modes/rpc/rpc-oauth-client.js +74 -0
- package/dist/modes/rpc/rpc-oauth-client.js.map +1 -0
- package/dist/modes/rpc/rpc-oauth-interaction.d.ts +9 -0
- package/dist/modes/rpc/rpc-oauth-interaction.d.ts.map +1 -0
- package/dist/modes/rpc/rpc-oauth-interaction.js +49 -0
- package/dist/modes/rpc/rpc-oauth-interaction.js.map +1 -0
- package/dist/modes/rpc/rpc-output-buffer.d.ts +2 -1
- package/dist/modes/rpc/rpc-output-buffer.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-output-buffer.js +4 -39
- package/dist/modes/rpc/rpc-output-buffer.js.map +1 -1
- package/dist/modes/rpc/rpc-provider-auth.d.ts +23 -0
- package/dist/modes/rpc/rpc-provider-auth.d.ts.map +1 -0
- package/dist/modes/rpc/rpc-provider-auth.js +145 -0
- package/dist/modes/rpc/rpc-provider-auth.js.map +1 -0
- package/dist/modes/rpc/rpc-responses.d.ts +0 -1
- package/dist/modes/rpc/rpc-responses.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-responses.js +0 -14
- package/dist/modes/rpc/rpc-responses.js.map +1 -1
- package/dist/modes/rpc/rpc-types.d.ts +83 -27
- package/dist/modes/rpc/rpc-types.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-types.js.map +1 -1
- package/dist/utils/clipboard.d.ts.map +1 -1
- package/dist/utils/clipboard.js +21 -8
- package/dist/utils/clipboard.js.map +1 -1
- package/dist/utils/version-check.d.ts.map +1 -1
- package/dist/utils/version-check.js +3 -1
- package/dist/utils/version-check.js.map +1 -1
- package/docs/changelog.mdx +12 -1
- package/docs/compaction.md +101 -18
- package/docs/custom-provider.md +13 -4
- package/docs/docs.json +1 -0
- package/docs/environment-variables.md +37 -0
- package/docs/extensions.md +45 -9
- package/docs/index.md +1 -0
- package/docs/intercom.md +1 -1
- package/docs/json.md +4 -4
- package/docs/keybindings.md +4 -2
- package/docs/llama-cpp.md +3 -1
- package/docs/models.md +29 -43
- package/docs/providers.md +18 -24
- package/docs/quickstart.md +19 -16
- package/docs/rpc.md +38 -85
- package/docs/sdk.md +15 -22
- package/docs/session-format.md +2 -15
- package/docs/sessions.md +1 -1
- package/docs/settings.md +10 -15
- package/docs/skills.md +8 -0
- package/docs/subagents.md +17 -9
- package/docs/themes.md +10 -1
- package/docs/tui.md +10 -5
- package/docs/usage.md +21 -2
- package/docs/windows.md +1 -1
- package/docs/workflows.md +1096 -518
- package/examples/extensions/README.md +1 -1
- package/examples/extensions/handoff.ts +8 -1
- package/examples/extensions/message-renderer.ts +2 -2
- package/examples/extensions/summarize.ts +3 -0
- package/examples/extensions/working-indicator.ts +2 -2
- package/npm-shrinkwrap.json +40 -46
- package/package.json +9 -7
- package/dist/builtin/cursor/CHANGELOG.md +0 -281
- package/dist/builtin/cursor/LICENSE +0 -26
- package/dist/builtin/cursor/README.md +0 -24
- package/dist/builtin/cursor/index.ts +0 -9
- package/dist/builtin/cursor/package.json +0 -47
- package/dist/builtin/cursor/src/auth.ts +0 -352
- package/dist/builtin/cursor/src/catalog-cache.ts +0 -155
- package/dist/builtin/cursor/src/config.ts +0 -123
- package/dist/builtin/cursor/src/conversation-state.ts +0 -135
- package/dist/builtin/cursor/src/cursor-models-raw.json +0 -412
- package/dist/builtin/cursor/src/model-mapper.ts +0 -369
- package/dist/builtin/cursor/src/model-reference.ts +0 -282
- package/dist/builtin/cursor/src/models.ts +0 -54
- package/dist/builtin/cursor/src/native-loader.ts +0 -71
- package/dist/builtin/cursor/src/proto/README.md +0 -34
- package/dist/builtin/cursor/src/proto/agent_pb.ts +0 -15294
- package/dist/builtin/cursor/src/proto/protobuf-codec-base64.ts +0 -22
- package/dist/builtin/cursor/src/proto/protobuf-codec-json.ts +0 -44
- package/dist/builtin/cursor/src/proto/protobuf-codec-request.ts +0 -311
- package/dist/builtin/cursor/src/proto/protobuf-codec-wire.ts +0 -248
- package/dist/builtin/cursor/src/proto/protobuf-codec.ts +0 -200
- package/dist/builtin/cursor/src/provider.ts +0 -301
- package/dist/builtin/cursor/src/stream.ts +0 -494
- package/dist/builtin/cursor/src/transport-errors.ts +0 -74
- package/dist/builtin/cursor/src/transport-frame.ts +0 -56
- package/dist/builtin/cursor/src/transport-http2.ts +0 -122
- package/dist/builtin/cursor/src/transport-native-client.ts +0 -161
- package/dist/builtin/cursor/src/transport-run-stream.ts +0 -188
- package/dist/builtin/cursor/src/transport-timeouts.ts +0 -87
- package/dist/builtin/cursor/src/transport-types.ts +0 -143
- package/dist/builtin/cursor/src/transport.ts +0 -26
- package/dist/builtin/workflows/builtin/deep-research-codebase-runner.ts +0 -492
- package/dist/builtin/workflows/builtin/deep-research-codebase-utils.ts +0 -383
- package/dist/builtin/workflows/builtin/deep-research-codebase.d.ts +0 -35
- package/dist/builtin/workflows/builtin/deep-research-codebase.ts +0 -47
- package/dist/builtin/workflows/skills/impeccable/reference/brand.md +0 -108
- package/dist/builtin/workflows/skills/impeccable/reference/codex.md +0 -105
- package/dist/builtin/workflows/skills/impeccable/reference/interaction-design.md +0 -189
- package/dist/builtin/workflows/skills/impeccable/scripts/hook-before-edit.mjs +0 -516
- package/dist/core/context-window.d.ts +0 -54
- package/dist/core/context-window.d.ts.map +0 -1
- package/dist/core/context-window.js +0 -110
- package/dist/core/context-window.js.map +0 -1
- package/dist/core/copilot-anthropic-sse-repair.d.ts +0 -23
- package/dist/core/copilot-anthropic-sse-repair.d.ts.map +0 -1
- package/dist/core/copilot-anthropic-sse-repair.js +0 -340
- package/dist/core/copilot-anthropic-sse-repair.js.map +0 -1
- package/dist/core/copilot-errors.d.ts +0 -9
- package/dist/core/copilot-errors.d.ts.map +0 -1
- package/dist/core/copilot-errors.js +0 -32
- package/dist/core/copilot-errors.js.map +0 -1
- package/dist/core/copilot-gemini-payload-sanitizer.d.ts +0 -72
- package/dist/core/copilot-gemini-payload-sanitizer.d.ts.map +0 -1
- package/dist/core/copilot-gemini-payload-sanitizer.js +0 -296
- package/dist/core/copilot-gemini-payload-sanitizer.js.map +0 -1
- package/dist/core/copilot-gemini-reasoning.d.ts +0 -126
- package/dist/core/copilot-gemini-reasoning.d.ts.map +0 -1
- package/dist/core/copilot-gemini-reasoning.js +0 -265
- package/dist/core/copilot-gemini-reasoning.js.map +0 -1
- package/dist/core/copilot-gemini-tool-arguments.d.ts +0 -42
- package/dist/core/copilot-gemini-tool-arguments.d.ts.map +0 -1
- package/dist/core/copilot-gemini-tool-arguments.js +0 -159
- package/dist/core/copilot-gemini-tool-arguments.js.map +0 -1
- package/dist/core/copilot-hosts.d.ts +0 -12
- package/dist/core/copilot-hosts.d.ts.map +0 -1
- package/dist/core/copilot-hosts.js +0 -33
- package/dist/core/copilot-hosts.js.map +0 -1
- package/dist/core/copilot-model-catalog.d.ts +0 -114
- package/dist/core/copilot-model-catalog.d.ts.map +0 -1
- package/dist/core/copilot-model-catalog.js +0 -392
- package/dist/core/copilot-model-catalog.js.map +0 -1
- package/dist/core/copilot-model-static-fallbacks.d.ts +0 -43
- package/dist/core/copilot-model-static-fallbacks.d.ts.map +0 -1
- package/dist/core/copilot-model-static-fallbacks.js +0 -50
- package/dist/core/copilot-model-static-fallbacks.js.map +0 -1
- package/dist/core/copilot-model-synthesis.d.ts +0 -10
- package/dist/core/copilot-model-synthesis.d.ts.map +0 -1
- package/dist/core/copilot-model-synthesis.js +0 -91
- package/dist/core/copilot-model-synthesis.js.map +0 -1
- package/dist/modes/interactive/components/context-window-selector.d.ts +0 -53
- package/dist/modes/interactive/components/context-window-selector.d.ts.map +0 -1
- package/dist/modes/interactive/components/context-window-selector.js +0 -136
- package/dist/modes/interactive/components/context-window-selector.js.map +0 -1
- package/dist/modes/rpc/bounded-writer.d.ts +0 -27
- package/dist/modes/rpc/bounded-writer.d.ts.map +0 -1
- package/dist/modes/rpc/bounded-writer.js.map +0 -1
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import type { DrainedAgentQueues } from "./agent-session-types.ts";
|
|
2
|
+
import type { AgentSessionInternalSurface as AgentSession } from "./agent-session-methods.ts";
|
|
3
|
+
import type { CustomMessage } from "./messages.ts";
|
|
4
|
+
type ProtectedDelivery = "steer" | "followUp";
|
|
5
|
+
type ProtectedPhase = "queued" | "consumed-unpersisted" | "persistence-failed";
|
|
6
|
+
export declare const PROTECTED_RECONCILIATION_CUSTOM_TYPE = "atomic:protected-streaming-reconciliation";
|
|
7
|
+
export interface ProtectedStreamingCustomMessage {
|
|
8
|
+
message: CustomMessage;
|
|
9
|
+
delivery: ProtectedDelivery;
|
|
10
|
+
phase: ProtectedPhase;
|
|
11
|
+
}
|
|
12
|
+
/** Requeue each durable card intent that has no persisted hidden completion. */
|
|
13
|
+
export declare function recoverProtectedStreamingCustomMessages(session: AgentSession): number;
|
|
14
|
+
/** Persist one visible card and register its hidden model-facing turn. */
|
|
15
|
+
export declare function admitProtectedStreamingCustomMessage(session: AgentSession, message: CustomMessage, delivery: ProtectedDelivery): Promise<CustomMessage>;
|
|
16
|
+
/** Queue one hidden turn before public listeners can transfer its ownership. */
|
|
17
|
+
export declare function queueProtectedStreamingCustomMessage(session: AgentSession, message: CustomMessage, delivery: ProtectedDelivery): Promise<void>;
|
|
18
|
+
/** Queue a whole hidden batch before public listeners can transfer ownership. */
|
|
19
|
+
export declare function queueProtectedStreamingCustomMessages(session: AgentSession, messages: CustomMessage[], delivery: ProtectedDelivery): Promise<void>;
|
|
20
|
+
/** Start or queue an idle protected batch before exposing its display cards. */
|
|
21
|
+
export declare function triggerProtectedStreamingCustomMessages(session: AgentSession, messages: CustomMessage[], delivery: ProtectedDelivery): Promise<void>;
|
|
22
|
+
/** Record that agent-core drained and consumed the hidden reconciliation. */
|
|
23
|
+
export declare function markProtectedStreamingCustomMessageConsumed(session: AgentSession, message: CustomMessage): boolean;
|
|
24
|
+
export declare function markProtectedStreamingCustomMessagePersistenceFailed(session: AgentSession, message: CustomMessage): void;
|
|
25
|
+
export declare function isProtectedStreamingCustomMessage(session: AgentSession, message: CustomMessage): boolean;
|
|
26
|
+
/**
|
|
27
|
+
* Persist a consumed hidden reconciliation exactly once. Its visible card was
|
|
28
|
+
* already committed at admission, so a transient failure never re-adds a card
|
|
29
|
+
* or re-injects another provider message.
|
|
30
|
+
*/
|
|
31
|
+
export declare function persistProtectedStreamingCustomMessage(session: AgentSession, message: CustomMessage): boolean;
|
|
32
|
+
/** Retry only hidden reconciliation persistence; never queue another alias. */
|
|
33
|
+
export declare function retryConsumedProtectedStreamingCustomMessages(session: AgentSession): void;
|
|
34
|
+
/** Flush consumed reconciliations before session state can be discarded. */
|
|
35
|
+
export declare function flushConsumedProtectedStreamingCustomMessages(session: AgentSession): void;
|
|
36
|
+
/**
|
|
37
|
+
* Persist only reconciliation input already sealed inside an accepted pause
|
|
38
|
+
* hold. Other queued input can still race an active protocol turn and must keep
|
|
39
|
+
* the historical fail-closed disposal behavior.
|
|
40
|
+
*/
|
|
41
|
+
export declare function prepareProtectedStreamingCustomMessagesForDisposal(session: AgentSession): void;
|
|
42
|
+
/** Restore only protected references actually removed from native queues/hold. */
|
|
43
|
+
export declare function restoreProtectedStreamingCustomMessages(session: AgentSession, removed: DrainedAgentQueues): void;
|
|
44
|
+
/** Move protection only for message references that transfer with native queues. */
|
|
45
|
+
export declare function transferProtectedStreamingCustomMessages(source: AgentSession, target: AgentSession, transferred: DrainedAgentQueues): void;
|
|
46
|
+
export {};
|
|
47
|
+
//# sourceMappingURL=agent-session-persistent-custom-messages.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agent-session-persistent-custom-messages.d.ts","sourceRoot":"","sources":["../../src/core/agent-session-persistent-custom-messages.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AACnE,OAAO,KAAK,EAAE,2BAA2B,IAAI,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAE9F,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAGnD,KAAK,iBAAiB,GAAG,OAAO,GAAG,UAAU,CAAC;AAC9C,KAAK,cAAc,GAAG,QAAQ,GAAG,sBAAsB,GAAG,oBAAoB,CAAC;AAE/E,eAAO,MAAM,oCAAoC,8CAA8C,CAAC;AAMhG,MAAM,WAAW,+BAA+B;IAC/C,OAAO,EAAE,aAAa,CAAC;IACvB,QAAQ,EAAE,iBAAiB,CAAC;IAC5B,KAAK,EAAE,cAAc,CAAC;CACtB;AA6DD,gFAAgF;AAChF,wBAAgB,uCAAuC,CAAC,OAAO,EAAE,YAAY,GAAG,MAAM,CA+BrF;AAsCD,0EAA0E;AAC1E,wBAAsB,oCAAoC,CACzD,OAAO,EAAE,YAAY,EACrB,OAAO,EAAE,aAAa,EACtB,QAAQ,EAAE,iBAAiB,GACzB,OAAO,CAAC,aAAa,CAAC,CAIxB;AAED,gFAAgF;AACh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Y,EACpB,MAAM,EAAE,YAAY,EACpB,WAAW,EAAE,kBAAkB,GAC7B,IAAI,CAUN"}
|
|
@@ -0,0 +1,267 @@
|
|
|
1
|
+
import { customMessageExcludesContext } from "./agent-session-types.js";
|
|
2
|
+
import { resolveWorkflowStageDeliveryTarget } from "./agent-session-delivery-forwarding.js";
|
|
3
|
+
export const PROTECTED_RECONCILIATION_CUSTOM_TYPE = "atomic:protected-streaming-reconciliation";
|
|
4
|
+
function protectedMessages(session) {
|
|
5
|
+
return session._protectedStreamingCustomMessages ??= [];
|
|
6
|
+
}
|
|
7
|
+
function appendDurableDisplayCard(session, message, delivery) {
|
|
8
|
+
const card = { ...message, excludeFromContext: true };
|
|
9
|
+
// The card and recovery marker share one append, so either both survive a
|
|
10
|
+
// process exit or neither does.
|
|
11
|
+
const intentEntryId = session.sessionManager.appendCustomMessageEntry(card.customType, card.content, card.display, card.details, true, { delivery });
|
|
12
|
+
session.agent.state.messages.push(card);
|
|
13
|
+
return { card, intentEntryId };
|
|
14
|
+
}
|
|
15
|
+
function emitDurableDisplayCard(session, card) {
|
|
16
|
+
// The card is already live and file-backed, and its protected reconciliation
|
|
17
|
+
// is registered. Public listeners remain fallible, but their errors cannot
|
|
18
|
+
// revoke admission or make the producer retry this committed occurrence.
|
|
19
|
+
try {
|
|
20
|
+
session._emit({ type: "message_start", message: card });
|
|
21
|
+
}
|
|
22
|
+
catch { }
|
|
23
|
+
try {
|
|
24
|
+
session._emit({ type: "message_end", message: card });
|
|
25
|
+
}
|
|
26
|
+
catch { }
|
|
27
|
+
}
|
|
28
|
+
function createProtectedReconciliation(message, intentEntryId) {
|
|
29
|
+
return {
|
|
30
|
+
role: "custom",
|
|
31
|
+
customType: PROTECTED_RECONCILIATION_CUSTOM_TYPE,
|
|
32
|
+
content: message.content,
|
|
33
|
+
display: false,
|
|
34
|
+
details: { protectedReconciliationOf: intentEntryId },
|
|
35
|
+
timestamp: message.timestamp,
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
function completedReconciliationIntent(details) {
|
|
39
|
+
if (details === null || typeof details !== "object")
|
|
40
|
+
return undefined;
|
|
41
|
+
const intent = details.protectedReconciliationOf;
|
|
42
|
+
return typeof intent === "string" ? intent : undefined;
|
|
43
|
+
}
|
|
44
|
+
function protectedDelivery(marker) {
|
|
45
|
+
if (marker === null || typeof marker !== "object")
|
|
46
|
+
return undefined;
|
|
47
|
+
const delivery = marker.delivery;
|
|
48
|
+
return delivery === "steer" || delivery === "followUp" ? delivery : undefined;
|
|
49
|
+
}
|
|
50
|
+
/** Requeue each durable card intent that has no persisted hidden completion. */
|
|
51
|
+
export function recoverProtectedStreamingCustomMessages(session) {
|
|
52
|
+
const branch = session.sessionManager.getBranch();
|
|
53
|
+
const completed = new Set(branch.flatMap((entry) => entry.type === "custom_message" && entry.customType === PROTECTED_RECONCILIATION_CUSTOM_TYPE
|
|
54
|
+
? [completedReconciliationIntent(entry.details)].filter((intent) => intent !== undefined)
|
|
55
|
+
: []));
|
|
56
|
+
const scheduled = new Set(protectedMessages(session).flatMap((entry) => {
|
|
57
|
+
const intent = completedReconciliationIntent(entry.message.details);
|
|
58
|
+
return intent === undefined ? [] : [intent];
|
|
59
|
+
}));
|
|
60
|
+
let recovered = 0;
|
|
61
|
+
for (const entry of branch) {
|
|
62
|
+
if (entry.type !== "custom_message")
|
|
63
|
+
continue;
|
|
64
|
+
const delivery = protectedDelivery(entry.protectedReconciliation);
|
|
65
|
+
if (delivery === undefined || completed.has(entry.id) || scheduled.has(entry.id))
|
|
66
|
+
continue;
|
|
67
|
+
const parsedTimestamp = Date.parse(entry.timestamp);
|
|
68
|
+
const card = {
|
|
69
|
+
role: "custom",
|
|
70
|
+
customType: entry.customType,
|
|
71
|
+
content: entry.content,
|
|
72
|
+
display: entry.display,
|
|
73
|
+
details: entry.details,
|
|
74
|
+
timestamp: Number.isFinite(parsedTimestamp) ? parsedTimestamp : Date.now(),
|
|
75
|
+
};
|
|
76
|
+
const reconciliation = createProtectedReconciliation(card, entry.id);
|
|
77
|
+
protectedMessages(session).push({ message: reconciliation, delivery, phase: "queued" });
|
|
78
|
+
session._queueAgentMessage(reconciliation, delivery);
|
|
79
|
+
recovered += 1;
|
|
80
|
+
}
|
|
81
|
+
return recovered;
|
|
82
|
+
}
|
|
83
|
+
async function prepareProtectedAdmission(session, messages, delivery) {
|
|
84
|
+
// While the initiating workflow tool is still executing, its assistant call
|
|
85
|
+
// may be ahead of SessionManager's async event writer. Wait only in that
|
|
86
|
+
// protocol-sensitive phase; at ordinary turn boundaries the hidden steer must
|
|
87
|
+
// be queued synchronously so agent-core's next native poll observes it.
|
|
88
|
+
if (session.agent.state.pendingToolCalls.size > 0)
|
|
89
|
+
await session._agentEventQueue;
|
|
90
|
+
const owner = resolveWorkflowStageDeliveryTarget(session);
|
|
91
|
+
const prepared = messages.map((message) => {
|
|
92
|
+
const { card, intentEntryId } = appendDurableDisplayCard(owner, message, delivery);
|
|
93
|
+
return { card, reconciliation: createProtectedReconciliation(message, intentEntryId) };
|
|
94
|
+
});
|
|
95
|
+
const cards = prepared.map((entry) => entry.card);
|
|
96
|
+
const reconciliations = prepared.map((entry) => entry.reconciliation);
|
|
97
|
+
protectedMessages(owner).push(...reconciliations.map((message) => ({ message, delivery, phase: "queued" })));
|
|
98
|
+
return { owner, cards, reconciliations };
|
|
99
|
+
}
|
|
100
|
+
function emitProtectedAdmission(admission) {
|
|
101
|
+
let owner = admission.owner;
|
|
102
|
+
for (const card of admission.cards) {
|
|
103
|
+
owner = resolveWorkflowStageDeliveryTarget(owner);
|
|
104
|
+
emitDurableDisplayCard(owner, card);
|
|
105
|
+
}
|
|
106
|
+
return resolveWorkflowStageDeliveryTarget(owner);
|
|
107
|
+
}
|
|
108
|
+
/** Persist one visible card and register its hidden model-facing turn. */
|
|
109
|
+
export async function admitProtectedStreamingCustomMessage(session, message, delivery) {
|
|
110
|
+
const admission = await prepareProtectedAdmission(session, [message], delivery);
|
|
111
|
+
emitProtectedAdmission(admission);
|
|
112
|
+
return admission.reconciliations[0];
|
|
113
|
+
}
|
|
114
|
+
/** Queue one hidden turn before public listeners can transfer its ownership. */
|
|
115
|
+
export async function queueProtectedStreamingCustomMessage(session, message, delivery) {
|
|
116
|
+
const admission = await prepareProtectedAdmission(session, [message], delivery);
|
|
117
|
+
admission.owner._queueAgentMessage(admission.reconciliations[0], delivery);
|
|
118
|
+
emitProtectedAdmission(admission);
|
|
119
|
+
}
|
|
120
|
+
/** Queue a whole hidden batch before public listeners can transfer ownership. */
|
|
121
|
+
export async function queueProtectedStreamingCustomMessages(session, messages, delivery) {
|
|
122
|
+
const admission = await prepareProtectedAdmission(session, messages, delivery);
|
|
123
|
+
for (const reconciliation of admission.reconciliations) {
|
|
124
|
+
admission.owner._queueAgentMessage(reconciliation, delivery);
|
|
125
|
+
}
|
|
126
|
+
emitProtectedAdmission(admission);
|
|
127
|
+
}
|
|
128
|
+
/** Start or queue an idle protected batch before exposing its display cards. */
|
|
129
|
+
export async function triggerProtectedStreamingCustomMessages(session, messages, delivery) {
|
|
130
|
+
const admission = await prepareProtectedAdmission(session, messages, delivery);
|
|
131
|
+
for (const reconciliation of admission.reconciliations) {
|
|
132
|
+
admission.owner._queueAgentMessage(reconciliation, delivery);
|
|
133
|
+
}
|
|
134
|
+
const owner = emitProtectedAdmission(admission);
|
|
135
|
+
if (owner.isStreaming || owner._queuedMessagesPaused)
|
|
136
|
+
return;
|
|
137
|
+
for (const reconciliation of admission.reconciliations) {
|
|
138
|
+
removeQueuedProtectedReference(owner, reconciliation);
|
|
139
|
+
}
|
|
140
|
+
const turn = owner._runAgentPrompt(admission.reconciliations);
|
|
141
|
+
void turn.catch(() => { });
|
|
142
|
+
}
|
|
143
|
+
/** Record that agent-core drained and consumed the hidden reconciliation. */
|
|
144
|
+
export function markProtectedStreamingCustomMessageConsumed(session, message) {
|
|
145
|
+
const entry = protectedMessages(session).find((candidate) => candidate.message === message);
|
|
146
|
+
if (!entry)
|
|
147
|
+
return false;
|
|
148
|
+
entry.phase = "consumed-unpersisted";
|
|
149
|
+
return true;
|
|
150
|
+
}
|
|
151
|
+
export function markProtectedStreamingCustomMessagePersistenceFailed(session, message) {
|
|
152
|
+
const entry = protectedMessages(session).find((candidate) => candidate.message === message);
|
|
153
|
+
if (entry?.phase === "consumed-unpersisted")
|
|
154
|
+
entry.phase = "persistence-failed";
|
|
155
|
+
}
|
|
156
|
+
export function isProtectedStreamingCustomMessage(session, message) {
|
|
157
|
+
return protectedMessages(session).some((entry) => entry.message === message);
|
|
158
|
+
}
|
|
159
|
+
/**
|
|
160
|
+
* Persist a consumed hidden reconciliation exactly once. Its visible card was
|
|
161
|
+
* already committed at admission, so a transient failure never re-adds a card
|
|
162
|
+
* or re-injects another provider message.
|
|
163
|
+
*/
|
|
164
|
+
export function persistProtectedStreamingCustomMessage(session, message) {
|
|
165
|
+
const pending = protectedMessages(session);
|
|
166
|
+
const index = pending.findIndex((entry) => entry.message === message);
|
|
167
|
+
if (index === -1)
|
|
168
|
+
return false;
|
|
169
|
+
const entry = pending[index];
|
|
170
|
+
if (entry.phase !== "consumed-unpersisted" && entry.phase !== "persistence-failed")
|
|
171
|
+
return true;
|
|
172
|
+
session.sessionManager.appendCustomMessageEntry(message.customType, message.content, message.display, message.details, customMessageExcludesContext(message));
|
|
173
|
+
pending.splice(index, 1);
|
|
174
|
+
return true;
|
|
175
|
+
}
|
|
176
|
+
/** Retry only hidden reconciliation persistence; never queue another alias. */
|
|
177
|
+
export function retryConsumedProtectedStreamingCustomMessages(session) {
|
|
178
|
+
for (const entry of [...protectedMessages(session)]) {
|
|
179
|
+
if (entry.phase !== "persistence-failed")
|
|
180
|
+
continue;
|
|
181
|
+
try {
|
|
182
|
+
persistProtectedStreamingCustomMessage(session, entry.message);
|
|
183
|
+
}
|
|
184
|
+
catch {
|
|
185
|
+
// The visible lifecycle card is already durable. Keep this consumed phase
|
|
186
|
+
// for a later event rather than duplicating either the card or model turn.
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
/** Flush consumed reconciliations before session state can be discarded. */
|
|
191
|
+
export function flushConsumedProtectedStreamingCustomMessages(session) {
|
|
192
|
+
for (const entry of [...protectedMessages(session)]) {
|
|
193
|
+
if (entry.phase === "queued")
|
|
194
|
+
continue;
|
|
195
|
+
// Do not swallow the final write failure: callers must keep this session
|
|
196
|
+
// alive rather than discard the only remaining recovery state.
|
|
197
|
+
persistProtectedStreamingCustomMessage(session, entry.message);
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
function removeReference(items, message) {
|
|
201
|
+
let index = items.indexOf(message);
|
|
202
|
+
while (index >= 0) {
|
|
203
|
+
items.splice(index, 1);
|
|
204
|
+
index = items.indexOf(message);
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
function removeQueuedProtectedReference(session, message) {
|
|
208
|
+
const hold = session._activeInterruptQueueHold;
|
|
209
|
+
if (hold !== undefined) {
|
|
210
|
+
removeReference(hold.steering, message);
|
|
211
|
+
removeReference(hold.followUp, message);
|
|
212
|
+
}
|
|
213
|
+
const queues = session._drainQueuedAgentMessages();
|
|
214
|
+
session._restoreQueuedAgentMessages({
|
|
215
|
+
steering: queues.steering.filter((candidate) => candidate !== message),
|
|
216
|
+
followUp: queues.followUp.filter((candidate) => candidate !== message),
|
|
217
|
+
});
|
|
218
|
+
}
|
|
219
|
+
function isPausedHeldProtectedReference(session, message) {
|
|
220
|
+
const hold = session._activeInterruptQueueHold;
|
|
221
|
+
return session._queuedMessagesPaused && hold !== undefined &&
|
|
222
|
+
(hold.steering.includes(message) || hold.followUp.includes(message));
|
|
223
|
+
}
|
|
224
|
+
/**
|
|
225
|
+
* Persist only reconciliation input already sealed inside an accepted pause
|
|
226
|
+
* hold. Other queued input can still race an active protocol turn and must keep
|
|
227
|
+
* the historical fail-closed disposal behavior.
|
|
228
|
+
*/
|
|
229
|
+
export function prepareProtectedStreamingCustomMessagesForDisposal(session) {
|
|
230
|
+
const pending = protectedMessages(session);
|
|
231
|
+
const queued = pending.filter((entry) => entry.phase === "queued");
|
|
232
|
+
if (queued.some((entry) => !isPausedHeldProtectedReference(session, entry.message))) {
|
|
233
|
+
throw new Error("Cannot dispose a session with a queued protected reconciliation");
|
|
234
|
+
}
|
|
235
|
+
for (const entry of queued) {
|
|
236
|
+
session.sessionManager.appendCustomMessageEntry(entry.message.customType, entry.message.content, entry.message.display, entry.message.details, customMessageExcludesContext(entry.message));
|
|
237
|
+
removeQueuedProtectedReference(session, entry.message);
|
|
238
|
+
const index = pending.indexOf(entry);
|
|
239
|
+
if (index >= 0)
|
|
240
|
+
pending.splice(index, 1);
|
|
241
|
+
}
|
|
242
|
+
flushConsumedProtectedStreamingCustomMessages(session);
|
|
243
|
+
}
|
|
244
|
+
/** Restore only protected references actually removed from native queues/hold. */
|
|
245
|
+
export function restoreProtectedStreamingCustomMessages(session, removed) {
|
|
246
|
+
const removedReferences = new Set([...removed.steering, ...removed.followUp]);
|
|
247
|
+
for (const entry of protectedMessages(session)) {
|
|
248
|
+
if (entry.phase === "queued" && removedReferences.has(entry.message)) {
|
|
249
|
+
session._queueAgentMessage(entry.message, entry.delivery);
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
/** Move protection only for message references that transfer with native queues. */
|
|
254
|
+
export function transferProtectedStreamingCustomMessages(source, target, transferred) {
|
|
255
|
+
const transferredReferences = new Set([...transferred.steering, ...transferred.followUp]);
|
|
256
|
+
const retained = [];
|
|
257
|
+
const moved = [];
|
|
258
|
+
for (const entry of protectedMessages(source)) {
|
|
259
|
+
if (entry.phase === "queued" && transferredReferences.has(entry.message))
|
|
260
|
+
moved.push(entry);
|
|
261
|
+
else
|
|
262
|
+
retained.push(entry);
|
|
263
|
+
}
|
|
264
|
+
source._protectedStreamingCustomMessages = retained;
|
|
265
|
+
protectedMessages(target).unshift(...moved);
|
|
266
|
+
}
|
|
267
|
+
//# sourceMappingURL=agent-session-persistent-custom-messages.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agent-session-persistent-custom-messages.js","sourceRoot":"","sources":["../../src/core/agent-session-persistent-custom-messages.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,4BAA4B,EAAE,MAAM,0BAA0B,CAAC;AAExE,OAAO,EAAE,kCAAkC,EAAE,MAAM,wCAAwC,CAAC;AAK5F,MAAM,CAAC,MAAM,oCAAoC,GAAG,2CAA2C,CAAC;AAYhG,SAAS,iBAAiB,CAAC,OAAqB;IAC/C,OAAO,OAAO,CAAC,iCAAiC,KAAK,EAAE,CAAC;AACzD,CAAC;AAED,SAAS,wBAAwB,CAChC,OAAqB,EACrB,OAAsB,EACtB,QAA2B;IAE3B,MAAM,IAAI,GAAG,EAAE,GAAG,OAAO,EAAE,kBAAkB,EAAE,IAAI,EAAyD,CAAC;IAC7G,0EAA0E;IAC1E,gCAAgC;IAChC,MAAM,aAAa,GAAG,OAAO,CAAC,cAAc,CAAC,wBAAwB,CACpE,IAAI,CAAC,UAAU,EACf,IAAI,CAAC,OAAO,EACZ,IAAI,CAAC,OAAO,EACZ,IAAI,CAAC,OAAO,EACZ,IAAI,EACJ,EAAE,QAAQ,EAAE,CACZ,CAAC;IACF,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACxC,OAAO,EAAE,IAAI,EAAE,aAAa,EAAE,CAAC;AAChC,CAAC;AAED,SAAS,sBAAsB,CAAC,OAAqB,EAAE,IAAmB;IACzE,6EAA6E;IAC7E,2EAA2E;IAC3E,yEAAyE;IACzE,IAAI,CAAC;QACJ,OAAO,CAAC,KAAK,CAAC,EAAE,IAAI,EAAE,eAAe,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC;IACzD,CAAC;IAAC,MAAM,CAAC,CAAA,CAAC;IACV,IAAI,CAAC;QACJ,OAAO,CAAC,KAAK,CAAC,EAAE,IAAI,EAAE,aAAa,EAAE,OAAO,EAAE,IAAI,EAAE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,CAAC,CAAC,GAAG,WAAW,CAAC,QAAQ,EAAE,GAAG,WAAW,CAAC,QAAQ,CAAC,CAAC,CAAC;IAC1F,MAAM,QAAQ,GAAsC,EAAE,CAAC;IACvD,MAAM,KAAK,GAAsC,EAAE,CAAC;IACpD,KAAK,MAAM,KAAK,IAAI,iBAAiB,CAAC,MAAM,CAAC,EAAE,CAAC;QAC/C,IAAI,KAAK,CAAC,KAAK,KAAK,QAAQ,IAAI,qBAAqB,CAAC,GAAG,CAAC,KAAK,CAAC,OAAO,CAAC;YAAE,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;;YACvF,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IAC3B,CAAC;IACD,MAAM,CAAC,iCAAiC,GAAG,QAAQ,CAAC;IACpD,iBAAiB,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC,GAAG,KAAK,CAAC,CAAC;AAC7C,CAAC","sourcesContent":["import type { DrainedAgentQueues } from \"./agent-session-types.ts\";\nimport type { AgentSessionInternalSurface as AgentSession } from \"./agent-session-methods.ts\";\nimport { customMessageExcludesContext } from \"./agent-session-types.ts\";\nimport type { CustomMessage } from \"./messages.ts\";\nimport { resolveWorkflowStageDeliveryTarget } from \"./agent-session-delivery-forwarding.ts\";\n\ntype ProtectedDelivery = \"steer\" | \"followUp\";\ntype ProtectedPhase = \"queued\" | \"consumed-unpersisted\" | \"persistence-failed\";\n\nexport const PROTECTED_RECONCILIATION_CUSTOM_TYPE = \"atomic:protected-streaming-reconciliation\";\n\ninterface ProtectedReconciliationDetails {\n\tprotectedReconciliationOf: string;\n}\n\nexport interface ProtectedStreamingCustomMessage {\n\tmessage: CustomMessage;\n\tdelivery: ProtectedDelivery;\n\tphase: ProtectedPhase;\n}\n\nfunction protectedMessages(session: AgentSession): ProtectedStreamingCustomMessage[] {\n\treturn session._protectedStreamingCustomMessages ??= [];\n}\n\nfunction appendDurableDisplayCard(\n\tsession: AgentSession,\n\tmessage: CustomMessage,\n\tdelivery: ProtectedDelivery,\n): { readonly card: CustomMessage & { excludeFromContext: true }; readonly intentEntryId: string } {\n\tconst card = { ...message, excludeFromContext: true } satisfies CustomMessage & { excludeFromContext: true };\n\t// The card and recovery marker share one append, so either both survive a\n\t// process exit or neither does.\n\tconst intentEntryId = session.sessionManager.appendCustomMessageEntry(\n\t\tcard.customType,\n\t\tcard.content,\n\t\tcard.display,\n\t\tcard.details,\n\t\ttrue,\n\t\t{ delivery },\n\t);\n\tsession.agent.state.messages.push(card);\n\treturn { card, intentEntryId };\n}\n\nfunction emitDurableDisplayCard(session: AgentSession, card: CustomMessage): void {\n\t// The card is already live and file-backed, and its protected reconciliation\n\t// is registered. Public listeners remain fallible, but their errors cannot\n\t// revoke admission or make the producer retry this committed occurrence.\n\ttry {\n\t\tsession._emit({ type: \"message_start\", message: card });\n\t} catch {}\n\ttry {\n\t\tsession._emit({ type: \"message_end\", message: card });\n\t} catch {}\n}\n\nfunction createProtectedReconciliation(message: CustomMessage, intentEntryId: string): CustomMessage {\n\treturn {\n\t\trole: \"custom\",\n\t\tcustomType: PROTECTED_RECONCILIATION_CUSTOM_TYPE,\n\t\tcontent: message.content,\n\t\tdisplay: false,\n\t\tdetails: { protectedReconciliationOf: intentEntryId } satisfies ProtectedReconciliationDetails,\n\t\ttimestamp: message.timestamp,\n\t};\n}\n\nfunction completedReconciliationIntent(details: unknown): string | undefined {\n\tif (details === null || typeof details !== \"object\") return undefined;\n\tconst intent = (details as { protectedReconciliationOf?: unknown }).protectedReconciliationOf;\n\treturn typeof intent === \"string\" ? intent : undefined;\n}\n\nfunction protectedDelivery(marker: unknown): ProtectedDelivery | undefined {\n\tif (marker === null || typeof marker !== \"object\") return undefined;\n\tconst delivery = (marker as { delivery?: unknown }).delivery;\n\treturn delivery === \"steer\" || delivery === \"followUp\" ? delivery : undefined;\n}\n\n/** Requeue each durable card intent that has no persisted hidden completion. */\nexport function recoverProtectedStreamingCustomMessages(session: AgentSession): number {\n\tconst branch = session.sessionManager.getBranch();\n\tconst completed = new Set(branch.flatMap((entry) =>\n\t\tentry.type === \"custom_message\" && entry.customType === PROTECTED_RECONCILIATION_CUSTOM_TYPE\n\t\t\t? [completedReconciliationIntent(entry.details)].filter((intent): intent is string => intent !== undefined)\n\t\t\t: []\n\t));\n\tconst scheduled = new Set(protectedMessages(session).flatMap((entry) => {\n\t\tconst intent = completedReconciliationIntent(entry.message.details);\n\t\treturn intent === undefined ? [] : [intent];\n\t}));\n\tlet recovered = 0;\n\tfor (const entry of branch) {\n\t\tif (entry.type !== \"custom_message\") continue;\n\t\tconst delivery = protectedDelivery(entry.protectedReconciliation);\n\t\tif (delivery === undefined || completed.has(entry.id) || scheduled.has(entry.id)) continue;\n\t\tconst parsedTimestamp = Date.parse(entry.timestamp);\n\t\tconst card: CustomMessage = {\n\t\t\trole: \"custom\",\n\t\t\tcustomType: entry.customType,\n\t\t\tcontent: entry.content,\n\t\t\tdisplay: entry.display,\n\t\t\tdetails: entry.details,\n\t\t\ttimestamp: Number.isFinite(parsedTimestamp) ? parsedTimestamp : Date.now(),\n\t\t};\n\t\tconst reconciliation = createProtectedReconciliation(card, entry.id);\n\t\tprotectedMessages(session).push({ message: reconciliation, delivery, phase: \"queued\" });\n\t\tsession._queueAgentMessage(reconciliation, delivery);\n\t\trecovered += 1;\n\t}\n\treturn recovered;\n}\n\ninterface ProtectedAdmission {\n\towner: AgentSession;\n\tcards: CustomMessage[];\n\treconciliations: CustomMessage[];\n}\n\nasync function prepareProtectedAdmission(\n\tsession: AgentSession,\n\tmessages: CustomMessage[],\n\tdelivery: ProtectedDelivery,\n): Promise<ProtectedAdmission> {\n\t// While the initiating workflow tool is still executing, its assistant call\n\t// may be ahead of SessionManager's async event writer. Wait only in that\n\t// protocol-sensitive phase; at ordinary turn boundaries the hidden steer must\n\t// be queued synchronously so agent-core's next native poll observes it.\n\tif (session.agent.state.pendingToolCalls.size > 0) await session._agentEventQueue;\n\tconst owner = resolveWorkflowStageDeliveryTarget(session);\n\tconst prepared = messages.map((message) => {\n\t\tconst { card, intentEntryId } = appendDurableDisplayCard(owner, message, delivery);\n\t\treturn { card, reconciliation: createProtectedReconciliation(message, intentEntryId) };\n\t});\n\tconst cards = prepared.map((entry) => entry.card);\n\tconst reconciliations = prepared.map((entry) => entry.reconciliation);\n\tprotectedMessages(owner).push(...reconciliations.map((message) => ({ message, delivery, phase: \"queued\" as const })));\n\treturn { owner, cards, reconciliations };\n}\n\nfunction emitProtectedAdmission(admission: ProtectedAdmission): AgentSession {\n\tlet owner = admission.owner;\n\tfor (const card of admission.cards) {\n\t\towner = resolveWorkflowStageDeliveryTarget(owner);\n\t\temitDurableDisplayCard(owner, card);\n\t}\n\treturn resolveWorkflowStageDeliveryTarget(owner);\n}\n\n/** Persist one visible card and register its hidden model-facing turn. */\nexport async function admitProtectedStreamingCustomMessage(\n\tsession: AgentSession,\n\tmessage: CustomMessage,\n\tdelivery: ProtectedDelivery,\n): Promise<CustomMessage> {\n\tconst admission = await prepareProtectedAdmission(session, [message], delivery);\n\temitProtectedAdmission(admission);\n\treturn admission.reconciliations[0]!;\n}\n\n/** Queue one hidden turn before public listeners can transfer its ownership. */\nexport async function queueProtectedStreamingCustomMessage(\n\tsession: AgentSession,\n\tmessage: CustomMessage,\n\tdelivery: ProtectedDelivery,\n): Promise<void> {\n\tconst admission = await prepareProtectedAdmission(session, [message], delivery);\n\tadmission.owner._queueAgentMessage(admission.reconciliations[0]!, delivery);\n\temitProtectedAdmission(admission);\n}\n\n/** Queue a whole hidden batch before public listeners can transfer ownership. */\nexport async function queueProtectedStreamingCustomMessages(\n\tsession: AgentSession,\n\tmessages: CustomMessage[],\n\tdelivery: ProtectedDelivery,\n): Promise<void> {\n\tconst admission = await prepareProtectedAdmission(session, messages, delivery);\n\tfor (const reconciliation of admission.reconciliations) {\n\t\tadmission.owner._queueAgentMessage(reconciliation, delivery);\n\t}\n\temitProtectedAdmission(admission);\n}\n\n/** Start or queue an idle protected batch before exposing its display cards. */\nexport async function triggerProtectedStreamingCustomMessages(\n\tsession: AgentSession,\n\tmessages: CustomMessage[],\n\tdelivery: ProtectedDelivery,\n): Promise<void> {\n\tconst admission = await prepareProtectedAdmission(session, messages, delivery);\n\tfor (const reconciliation of admission.reconciliations) {\n\t\tadmission.owner._queueAgentMessage(reconciliation, delivery);\n\t}\n\tconst owner = emitProtectedAdmission(admission);\n\tif (owner.isStreaming || owner._queuedMessagesPaused) return;\n\tfor (const reconciliation of admission.reconciliations) {\n\t\tremoveQueuedProtectedReference(owner, reconciliation);\n\t}\n\tconst turn = owner._runAgentPrompt(admission.reconciliations);\n\tvoid turn.catch(() => {});\n}\n\n/** Record that agent-core drained and consumed the hidden reconciliation. */\nexport function markProtectedStreamingCustomMessageConsumed(\n\tsession: AgentSession,\n\tmessage: CustomMessage,\n): boolean {\n\tconst entry = protectedMessages(session).find((candidate) => candidate.message === message);\n\tif (!entry) return false;\n\tentry.phase = \"consumed-unpersisted\";\n\treturn true;\n}\n\nexport function markProtectedStreamingCustomMessagePersistenceFailed(\n\tsession: AgentSession,\n\tmessage: CustomMessage,\n): void {\n\tconst entry = protectedMessages(session).find((candidate) => candidate.message === message);\n\tif (entry?.phase === \"consumed-unpersisted\") entry.phase = \"persistence-failed\";\n}\n\nexport function isProtectedStreamingCustomMessage(session: AgentSession, message: CustomMessage): boolean {\n\treturn protectedMessages(session).some((entry) => entry.message === message);\n}\n\n/**\n * Persist a consumed hidden reconciliation exactly once. Its visible card was\n * already committed at admission, so a transient failure never re-adds a card\n * or re-injects another provider message.\n */\nexport function persistProtectedStreamingCustomMessage(\n\tsession: AgentSession,\n\tmessage: CustomMessage,\n): boolean {\n\tconst pending = protectedMessages(session);\n\tconst index = pending.findIndex((entry) => entry.message === message);\n\tif (index === -1) return false;\n\tconst entry = pending[index];\n\tif (entry.phase !== \"consumed-unpersisted\" && entry.phase !== \"persistence-failed\") return true;\n\tsession.sessionManager.appendCustomMessageEntry(\n\t\tmessage.customType,\n\t\tmessage.content,\n\t\tmessage.display,\n\t\tmessage.details,\n\t\tcustomMessageExcludesContext(message),\n\t);\n\tpending.splice(index, 1);\n\treturn true;\n}\n\n/** Retry only hidden reconciliation persistence; never queue another alias. */\nexport function retryConsumedProtectedStreamingCustomMessages(session: AgentSession): void {\n\tfor (const entry of [...protectedMessages(session)]) {\n\t\tif (entry.phase !== \"persistence-failed\") continue;\n\t\ttry {\n\t\t\tpersistProtectedStreamingCustomMessage(session, entry.message);\n\t\t} catch {\n\t\t\t// The visible lifecycle card is already durable. Keep this consumed phase\n\t\t\t// for a later event rather than duplicating either the card or model turn.\n\t\t}\n\t}\n}\n\n/** Flush consumed reconciliations before session state can be discarded. */\nexport function flushConsumedProtectedStreamingCustomMessages(session: AgentSession): void {\n\tfor (const entry of [...protectedMessages(session)]) {\n\t\tif (entry.phase === \"queued\") continue;\n\t\t// Do not swallow the final write failure: callers must keep this session\n\t\t// alive rather than discard the only remaining recovery state.\n\t\tpersistProtectedStreamingCustomMessage(session, entry.message);\n\t}\n}\n\nfunction removeReference<T>(items: T[], message: T): void {\n\tlet index = items.indexOf(message);\n\twhile (index >= 0) {\n\t\titems.splice(index, 1);\n\t\tindex = items.indexOf(message);\n\t}\n}\n\nfunction removeQueuedProtectedReference(session: AgentSession, message: CustomMessage): void {\n\tconst hold = session._activeInterruptQueueHold;\n\tif (hold !== undefined) {\n\t\tremoveReference(hold.steering, message);\n\t\tremoveReference(hold.followUp, message);\n\t}\n\tconst queues = session._drainQueuedAgentMessages();\n\tsession._restoreQueuedAgentMessages({\n\t\tsteering: queues.steering.filter((candidate) => candidate !== message),\n\t\tfollowUp: queues.followUp.filter((candidate) => candidate !== message),\n\t});\n}\n\nfunction isPausedHeldProtectedReference(session: AgentSession, message: CustomMessage): boolean {\n\tconst hold = session._activeInterruptQueueHold;\n\treturn session._queuedMessagesPaused && hold !== undefined &&\n\t\t(hold.steering.includes(message) || hold.followUp.includes(message));\n}\n\n/**\n * Persist only reconciliation input already sealed inside an accepted pause\n * hold. Other queued input can still race an active protocol turn and must keep\n * the historical fail-closed disposal behavior.\n */\nexport function prepareProtectedStreamingCustomMessagesForDisposal(session: AgentSession): void {\n\tconst pending = protectedMessages(session);\n\tconst queued = pending.filter((entry) => entry.phase === \"queued\");\n\tif (queued.some((entry) => !isPausedHeldProtectedReference(session, entry.message))) {\n\t\tthrow new Error(\"Cannot dispose a session with a queued protected reconciliation\");\n\t}\n\tfor (const entry of queued) {\n\t\tsession.sessionManager.appendCustomMessageEntry(\n\t\t\tentry.message.customType,\n\t\t\tentry.message.content,\n\t\t\tentry.message.display,\n\t\t\tentry.message.details,\n\t\t\tcustomMessageExcludesContext(entry.message),\n\t\t);\n\t\tremoveQueuedProtectedReference(session, entry.message);\n\t\tconst index = pending.indexOf(entry);\n\t\tif (index >= 0) pending.splice(index, 1);\n\t}\n\tflushConsumedProtectedStreamingCustomMessages(session);\n}\n\n/** Restore only protected references actually removed from native queues/hold. */\nexport function restoreProtectedStreamingCustomMessages(\n\tsession: AgentSession,\n\tremoved: DrainedAgentQueues,\n): void {\n\tconst removedReferences = new Set([...removed.steering, ...removed.followUp]);\n\tfor (const entry of protectedMessages(session)) {\n\t\tif (entry.phase === \"queued\" && removedReferences.has(entry.message)) {\n\t\t\tsession._queueAgentMessage(entry.message, entry.delivery);\n\t\t}\n\t}\n}\n\n/** Move protection only for message references that transfer with native queues. */\nexport function transferProtectedStreamingCustomMessages(\n\tsource: AgentSession,\n\ttarget: AgentSession,\n\ttransferred: DrainedAgentQueues,\n): void {\n\tconst transferredReferences = new Set([...transferred.steering, ...transferred.followUp]);\n\tconst retained: ProtectedStreamingCustomMessage[] = [];\n\tconst moved: ProtectedStreamingCustomMessage[] = [];\n\tfor (const entry of protectedMessages(source)) {\n\t\tif (entry.phase === \"queued\" && transferredReferences.has(entry.message)) moved.push(entry);\n\t\telse retained.push(entry);\n\t}\n\tsource._protectedStreamingCustomMessages = retained;\n\tprotectedMessages(target).unshift(...moved);\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agent-session-post-tool-compaction.d.ts","sourceRoot":"","sources":["../../src/core/agent-session-post-tool-compaction.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,+BAA+B,CAAC;
|
|
1
|
+
{"version":3,"file":"agent-session-post-tool-compaction.d.ts","sourceRoot":"","sources":["../../src/core/agent-session-post-tool-compaction.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,+BAA+B,CAAC;AAClE,OAAO,EAAwC,KAAK,wBAAwB,EAAE,MAAM,uBAAuB,CAAC;AAC5G,OAAO,KAAK,EAAE,2BAA2B,IAAI,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAY9F,oFAAoF;AACpF,wBAAsB,yBAAyB,CAC9C,IAAI,EAAE,YAAY,EAClB,QAAQ,EAAE,YAAY,EAAE,EACxB,MAAM,CAAC,EAAE,WAAW,GAClB,OAAO,CAAC,YAAY,EAAE,CAAC,CA2FzB;AAED,mFAAmF;AACnF,wBAAgB,kCAAkC,CACjD,IAAI,EAAE,YAAY,EAClB,QAAQ,EAAE,YAAY,EAAE,GACtB,YAAY,EAAE,CA+BhB;AAED,MAAM,WAAW,8BAA8B;IAC9C,cAAc,EAAE,MAAM,CAAC;IACvB,MAAM,EAAE,wBAAwB,CAAC;CACjC;AAED,eAAO,MAAM,qCAAqC;;;CAGjD,CAAC"}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { getEffectiveInputBudget } from "./context-window.js";
|
|
2
1
|
import { estimateContextTokens, shouldCompact } from "./compaction/index.js";
|
|
3
2
|
import { scrubPreCompactionAssistantUsage } from "./provider-context-usage.js";
|
|
4
3
|
function postToolFailureMessage(error) {
|
|
@@ -14,9 +13,14 @@ export async function _preflightPostToolContext(messages, signal) {
|
|
|
14
13
|
const settings = this.settingsManager.getCompactionSettings();
|
|
15
14
|
if (!model || !settings.enabled)
|
|
16
15
|
return messages;
|
|
17
|
-
const hardInputLimit =
|
|
18
|
-
|
|
16
|
+
const hardInputLimit = model.contextWindow;
|
|
17
|
+
const projectedTokens = estimateContextTokens(messages).tokens;
|
|
18
|
+
if (!shouldCompact(projectedTokens, hardInputLimit, settings))
|
|
19
19
|
return messages;
|
|
20
|
+
// Only a context that genuinely will not fit may clear a sub-minimum region.
|
|
21
|
+
// The threshold sits at `contextWindow - reserveTokens`, well below the hard
|
|
22
|
+
// limit, so a crossing alone is no reason to destroy context.
|
|
23
|
+
const overHardLimit = hardInputLimit > 0 && projectedTokens > hardInputLimit;
|
|
20
24
|
// Tool-result persistence is ordered on AgentSession's event queue, while Pi
|
|
21
25
|
// may reach its next-turn hook as soon as its own listener barrier settles.
|
|
22
26
|
await this._agentEventQueue;
|
|
@@ -34,20 +38,41 @@ export async function _preflightPostToolContext(messages, signal) {
|
|
|
34
38
|
this._emit({ type: "compaction_start", reason: "threshold", midTurn: true });
|
|
35
39
|
try {
|
|
36
40
|
const result = await this._applyVerbatimCompaction({
|
|
37
|
-
resolvePlannerAuth: async () => {
|
|
38
|
-
const auth = await this._modelRegistry.getApiKeyAndHeaders(
|
|
39
|
-
return auth.ok && auth.apiKey
|
|
41
|
+
resolvePlannerAuth: async (candidate) => {
|
|
42
|
+
const auth = await this._modelRegistry.getApiKeyAndHeaders(candidate);
|
|
43
|
+
return auth.ok && (auth.apiKey || auth.headers)
|
|
40
44
|
? { apiKey: auth.apiKey, headers: auth.headers, baseUrl: auth.baseUrl }
|
|
41
45
|
: undefined;
|
|
42
46
|
},
|
|
43
47
|
abortController,
|
|
44
48
|
backupLabel: "auto-compact",
|
|
45
49
|
reason: "threshold",
|
|
50
|
+
// Mid-turn: a compaction failure here kills the active turn.
|
|
51
|
+
urgency: "load_bearing",
|
|
52
|
+
...(overHardLimit ? { allowSmallRegion: true } : {}),
|
|
46
53
|
});
|
|
47
|
-
if (!result)
|
|
48
|
-
|
|
54
|
+
if (!result) {
|
|
55
|
+
// Nothing was compactable and the projected context still fits, so the
|
|
56
|
+
// follow-up request can be sent unchanged. That is a successful no-op,
|
|
57
|
+
// not a failure: raising here is what killed the active turn.
|
|
58
|
+
this._emit({
|
|
59
|
+
type: "compaction_end",
|
|
60
|
+
reason: "threshold",
|
|
61
|
+
result: undefined,
|
|
62
|
+
aborted: false,
|
|
63
|
+
willRetry: false,
|
|
64
|
+
midTurn: true,
|
|
65
|
+
});
|
|
66
|
+
return messages;
|
|
67
|
+
}
|
|
49
68
|
this._pendingPostToolCompactionGuard = { hardInputLimit, result };
|
|
50
|
-
|
|
69
|
+
// `AgentState.messages` has an asymmetric accessor pair: the setter copies, the
|
|
70
|
+
// getter hands back the live internal array. Returning it directly would make the
|
|
71
|
+
// agent loop's `currentContext.messages` an alias of `agent.state.messages`, and
|
|
72
|
+
// from the next turn on both writers (`runLoop` and the `message_end` reducer)
|
|
73
|
+
// would append every message twice — duplicate `tool_result` blocks for one
|
|
74
|
+
// `tool_use` id, which the provider rejects with an unrecoverable 400.
|
|
75
|
+
return this.agent.state.messages.slice();
|
|
51
76
|
}
|
|
52
77
|
catch (error) {
|
|
53
78
|
const detail = error instanceof Error ? error.message : String(error);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agent-session-post-tool-compaction.js","sourceRoot":"","sources":["../../src/core/agent-session-post-tool-compaction.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,uBAAuB,EAAE,MAAM,qBAAqB,CAAC;AAC9D,OAAO,EAAE,qBAAqB,EAAE,aAAa,EAAiC,MAAM,uBAAuB,CAAC;AAE5G,OAAO,EAAE,gCAAgC,EAAE,MAAM,6BAA6B,CAAC;AAE/E,SAAS,sBAAsB,CAAC,KAAc;IAC7C,MAAM,MAAM,GAAG,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IACtE,OAAO,yEAAyE,MAAM,EAAE,CAAC;AAC1F,CAAC;AAED,SAAS,gBAAgB,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d,SAAS,EAAE,KAAK;YAChB,OAAO,EAAE,IAAI;YACb,YAAY;SACZ,CAAC,CAAC;QACH,MAAM,IAAI,KAAK,CAAC,YAAY,CAAC,CAAC;IAC/B,CAAC;IAED,IAAI,CAAC,KAAK,CAAC;QACV,IAAI,EAAE,gBAAgB;QACtB,MAAM,EAAE,WAAW;QACnB,MAAM,EAAE,OAAO,CAAC,MAAM;QACtB,OAAO,EAAE,KAAK;QACd,SAAS,EAAE,KAAK;QAChB,OAAO,EAAE,IAAI;KACb,CAAC,CAAC;IACH,OAAO,qBAAqB,CAAC;AAC9B,CAAC;AAOD,MAAM,CAAC,MAAM,qCAAqC,GAAG;IACpD,yBAAyB;IACzB,kCAAkC;CAClC,CAAC","sourcesContent":["import type { AgentMessage } from \"@earendil-works/pi-agent-core\";\nimport { getEffectiveInputBudget } from \"./context-window.ts\";\nimport { estimateContextTokens, shouldCompact, type VerbatimCompactionResult } from \"./compaction/index.ts\";\nimport type { AgentSessionInternalSurface as AgentSession } from \"./agent-session-methods.ts\";\nimport { scrubPreCompactionAssistantUsage } from \"./provider-context-usage.ts\";\n\nfunction postToolFailureMessage(error: unknown): string {\n\tconst detail = error instanceof Error ? error.message : String(error);\n\treturn `Post-tool context compaction failed before the next provider request: ${detail}`;\n}\n\nfunction hardLimitMessage(projectedTokens: number, hardInputLimit: number): string {\n\treturn `Post-tool context remains over the provider hard input limit after compaction (${projectedTokens} > ${hardInputLimit} tokens); the next provider request was not sent.`;\n}\n\n/** Compact tool-expanded context without scheduling a second Agent continuation. */\nexport async function _preflightPostToolContext(\n\tthis: AgentSession,\n\tmessages: AgentMessage[],\n\tsignal?: AbortSignal,\n): Promise<AgentMessage[]> {\n\tconst model = this.model;\n\tconst settings = this.settingsManager.getCompactionSettings();\n\tif (!model || !settings.enabled) return messages;\n\n\tconst hardInputLimit = getEffectiveInputBudget(model);\n\tif (!shouldCompact(estimateContextTokens(messages).tokens, hardInputLimit, settings)) return messages;\n\n\t// Tool-result persistence is ordered on AgentSession's event queue, while Pi\n\t// may reach its next-turn hook as soon as its own listener barrier settles.\n\tawait this._agentEventQueue;\n\tif (this._autoCompactionAbortController) {\n\t\tconst message = postToolFailureMessage(\"another automatic compaction is already active\");\n\t\tthis._postToolCompactionPreflightError = message;\n\t\tthrow new Error(message);\n\t}\n\n\tconst abortController = new AbortController();\n\tconst relayAbort = () => abortController.abort();\n\tsignal?.addEventListener(\"abort\", relayAbort, { once: true });\n\tif (signal?.aborted) abortController.abort();\n\tthis._autoCompactionAbortController = abortController;\n\tthis._emit({ type: \"compaction_start\", reason: \"threshold\", midTurn: true });\n\n\ttry {\n\t\tconst result = await this._applyVerbatimCompaction({\n\t\t\tresolvePlannerAuth: async () => {\n\t\t\t\tconst auth = await this._modelRegistry.getApiKeyAndHeaders(model);\n\t\t\t\treturn auth.ok && auth.apiKey\n\t\t\t\t\t? { apiKey: auth.apiKey, headers: auth.headers, baseUrl: auth.baseUrl }\n\t\t\t\t\t: undefined;\n\t\t\t},\n\t\t\tabortController,\n\t\t\tbackupLabel: \"auto-compact\",\n\t\t\treason: \"threshold\",\n\t\t});\n\t\tif (!result) throw new Error(\"no compactable transcript entries were available\");\n\n\t\tthis._pendingPostToolCompactionGuard = { hardInputLimit, result };\n\t\treturn this.agent.state.messages;\n\t} catch (error) {\n\t\tconst detail = error instanceof Error ? error.message : String(error);\n\t\tconst aborted =\n\t\t\tabortController.signal.aborted ||\n\t\t\tdetail === \"Compaction cancelled\" ||\n\t\t\t(error instanceof Error && error.name === \"AbortError\");\n\t\tconst errorMessage = aborted\n\t\t\t? \"Post-tool context compaction was cancelled before the next provider request.\"\n\t\t\t: postToolFailureMessage(error);\n\t\tthis._postToolCompactionPreflightError = errorMessage;\n\t\tthis._emit({\n\t\t\ttype: \"compaction_end\",\n\t\t\treason: \"threshold\",\n\t\t\tresult: undefined,\n\t\t\taborted,\n\t\t\twillRetry: false,\n\t\t\tmidTurn: true,\n\t\t\t...(aborted ? {} : { errorMessage }),\n\t\t});\n\t\tthrow new Error(errorMessage, { cause: error });\n\t} finally {\n\t\tsignal?.removeEventListener(\"abort\", relayAbort);\n\t\tthis._autoCompactionAbortController = undefined;\n\t}\n}\n\n/** Gate the transformed message context immediately before provider conversion. */\nexport function _finishPostToolCompactionPreflight(\n\tthis: AgentSession,\n\tmessages: AgentMessage[],\n): AgentMessage[] {\n\tconst pending = this._pendingPostToolCompactionGuard;\n\tif (!pending) return messages;\n\tthis._pendingPostToolCompactionGuard = undefined;\n\n\tconst providerBoundMessages = scrubPreCompactionAssistantUsage(messages, this.sessionManager.getBranch());\n\tconst projectedTokens = estimateContextTokens(providerBoundMessages).tokens;\n\tif (projectedTokens > pending.hardInputLimit) {\n\t\tconst errorMessage = hardLimitMessage(projectedTokens, pending.hardInputLimit);\n\t\tthis._postToolCompactionPreflightError = errorMessage;\n\t\tthis._emit({\n\t\t\ttype: \"compaction_end\",\n\t\t\treason: \"threshold\",\n\t\t\tresult: pending.result,\n\t\t\taborted: false,\n\t\t\twillRetry: false,\n\t\t\tmidTurn: true,\n\t\t\terrorMessage,\n\t\t});\n\t\tthrow new Error(errorMessage);\n\t}\n\n\tthis._emit({\n\t\ttype: \"compaction_end\",\n\t\treason: \"threshold\",\n\t\tresult: pending.result,\n\t\taborted: false,\n\t\twillRetry: false,\n\t\tmidTurn: true,\n\t});\n\treturn providerBoundMessages;\n}\n\nexport interface PendingPostToolCompactionGuard {\n\thardInputLimit: number;\n\tresult: VerbatimCompactionResult;\n}\n\nexport const agentSessionPostToolCompactionMethods = {\n\t_preflightPostToolContext,\n\t_finishPostToolCompactionPreflight,\n};\n"]}
|
|
1
|
+
{"version":3,"file":"agent-session-post-tool-compaction.js","sourceRoot":"","sources":["../../src/core/agent-session-post-tool-compaction.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,qBAAqB,EAAE,aAAa,EAAiC,MAAM,uBAAuB,CAAC;AAE5G,OAAO,EAAE,gCAAgC,EAAE,MAAM,6BAA6B,CAAC;AAE/E,SAAS,sBA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CAAC;IACH,OAAO,qBAAqB,CAAC;AAC9B,CAAC;AAOD,MAAM,CAAC,MAAM,qCAAqC,GAAG;IACpD,yBAAyB;IACzB,kCAAkC;CAClC,CAAC","sourcesContent":["import type { AgentMessage } from \"@earendil-works/pi-agent-core\";\nimport { estimateContextTokens, shouldCompact, type VerbatimCompactionResult } from \"./compaction/index.ts\";\nimport type { AgentSessionInternalSurface as AgentSession } from \"./agent-session-methods.ts\";\nimport { scrubPreCompactionAssistantUsage } from \"./provider-context-usage.ts\";\n\nfunction postToolFailureMessage(error: unknown): string {\n\tconst detail = error instanceof Error ? error.message : String(error);\n\treturn `Post-tool context compaction failed before the next provider request: ${detail}`;\n}\n\nfunction hardLimitMessage(projectedTokens: number, hardInputLimit: number): string {\n\treturn `Post-tool context remains over the provider hard input limit after compaction (${projectedTokens} > ${hardInputLimit} tokens); the next provider request was not sent.`;\n}\n\n/** Compact tool-expanded context without scheduling a second Agent continuation. */\nexport async function _preflightPostToolContext(\n\tthis: AgentSession,\n\tmessages: AgentMessage[],\n\tsignal?: AbortSignal,\n): Promise<AgentMessage[]> {\n\tconst model = this.model;\n\tconst settings = this.settingsManager.getCompactionSettings();\n\tif (!model || !settings.enabled) return messages;\n\n\tconst hardInputLimit = model.contextWindow;\n\tconst projectedTokens = estimateContextTokens(messages).tokens;\n\tif (!shouldCompact(projectedTokens, hardInputLimit, settings)) return messages;\n\t// Only a context that genuinely will not fit may clear a sub-minimum region.\n\t// The threshold sits at `contextWindow - reserveTokens`, well below the hard\n\t// limit, so a crossing alone is no reason to destroy context.\n\tconst overHardLimit = hardInputLimit > 0 && projectedTokens > hardInputLimit;\n\n\t// Tool-result persistence is ordered on AgentSession's event queue, while Pi\n\t// may reach its next-turn hook as soon as its own listener barrier settles.\n\tawait this._agentEventQueue;\n\tif (this._autoCompactionAbortController) {\n\t\tconst message = postToolFailureMessage(\"another automatic compaction is already active\");\n\t\tthis._postToolCompactionPreflightError = message;\n\t\tthrow new Error(message);\n\t}\n\n\tconst abortController = new AbortController();\n\tconst relayAbort = () => abortController.abort();\n\tsignal?.addEventListener(\"abort\", relayAbort, { once: true });\n\tif (signal?.aborted) abortController.abort();\n\tthis._autoCompactionAbortController = abortController;\n\tthis._emit({ type: \"compaction_start\", reason: \"threshold\", midTurn: true });\n\n\ttry {\n\t\tconst result = await this._applyVerbatimCompaction({\n\t\t\tresolvePlannerAuth: async (candidate) => {\n\t\t\t\tconst auth = await this._modelRegistry.getApiKeyAndHeaders(candidate);\n\t\t\t\treturn auth.ok && (auth.apiKey || auth.headers)\n\t\t\t\t\t? { apiKey: auth.apiKey, headers: auth.headers, baseUrl: auth.baseUrl }\n\t\t\t\t\t: undefined;\n\t\t\t},\n\t\t\tabortController,\n\t\t\tbackupLabel: \"auto-compact\",\n\t\t\treason: \"threshold\",\n\t\t\t// Mid-turn: a compaction failure here kills the active turn.\n\t\t\turgency: \"load_bearing\",\n\t\t\t...(overHardLimit ? { allowSmallRegion: true } : {}),\n\t\t});\n\t\tif (!result) {\n\t\t\t// Nothing was compactable and the projected context still fits, so the\n\t\t\t// follow-up request can be sent unchanged. That is a successful no-op,\n\t\t\t// not a failure: raising here is what killed the active turn.\n\t\t\tthis._emit({\n\t\t\t\ttype: \"compaction_end\",\n\t\t\t\treason: \"threshold\",\n\t\t\t\tresult: undefined,\n\t\t\t\taborted: false,\n\t\t\t\twillRetry: false,\n\t\t\t\tmidTurn: true,\n\t\t\t});\n\t\t\treturn messages;\n\t\t}\n\n\t\tthis._pendingPostToolCompactionGuard = { hardInputLimit, result };\n\t\t// `AgentState.messages` has an asymmetric accessor pair: the setter copies, the\n\t\t// getter hands back the live internal array. Returning it directly would make the\n\t\t// agent loop's `currentContext.messages` an alias of `agent.state.messages`, and\n\t\t// from the next turn on both writers (`runLoop` and the `message_end` reducer)\n\t\t// would append every message twice — duplicate `tool_result` blocks for one\n\t\t// `tool_use` id, which the provider rejects with an unrecoverable 400.\n\t\treturn this.agent.state.messages.slice();\n\t} catch (error) {\n\t\tconst detail = error instanceof Error ? error.message : String(error);\n\t\tconst aborted =\n\t\t\tabortController.signal.aborted ||\n\t\t\tdetail === \"Compaction cancelled\" ||\n\t\t\t(error instanceof Error && error.name === \"AbortError\");\n\t\tconst errorMessage = aborted\n\t\t\t? \"Post-tool context compaction was cancelled before the next provider request.\"\n\t\t\t: postToolFailureMessage(error);\n\t\tthis._postToolCompactionPreflightError = errorMessage;\n\t\tthis._emit({\n\t\t\ttype: \"compaction_end\",\n\t\t\treason: \"threshold\",\n\t\t\tresult: undefined,\n\t\t\taborted,\n\t\t\twillRetry: false,\n\t\t\tmidTurn: true,\n\t\t\t...(aborted ? {} : { errorMessage }),\n\t\t});\n\t\tthrow new Error(errorMessage, { cause: error });\n\t} finally {\n\t\tsignal?.removeEventListener(\"abort\", relayAbort);\n\t\tthis._autoCompactionAbortController = undefined;\n\t}\n}\n\n/** Gate the transformed message context immediately before provider conversion. */\nexport function _finishPostToolCompactionPreflight(\n\tthis: AgentSession,\n\tmessages: AgentMessage[],\n): AgentMessage[] {\n\tconst pending = this._pendingPostToolCompactionGuard;\n\tif (!pending) return messages;\n\tthis._pendingPostToolCompactionGuard = undefined;\n\n\tconst providerBoundMessages = scrubPreCompactionAssistantUsage(messages, this.sessionManager.getBranch());\n\tconst projectedTokens = estimateContextTokens(providerBoundMessages).tokens;\n\tif (projectedTokens > pending.hardInputLimit) {\n\t\tconst errorMessage = hardLimitMessage(projectedTokens, pending.hardInputLimit);\n\t\tthis._postToolCompactionPreflightError = errorMessage;\n\t\tthis._emit({\n\t\t\ttype: \"compaction_end\",\n\t\t\treason: \"threshold\",\n\t\t\tresult: pending.result,\n\t\t\taborted: false,\n\t\t\twillRetry: false,\n\t\t\tmidTurn: true,\n\t\t\terrorMessage,\n\t\t});\n\t\tthrow new Error(errorMessage);\n\t}\n\n\tthis._emit({\n\t\ttype: \"compaction_end\",\n\t\treason: \"threshold\",\n\t\tresult: pending.result,\n\t\taborted: false,\n\t\twillRetry: false,\n\t\tmidTurn: true,\n\t});\n\treturn providerBoundMessages;\n}\n\nexport interface PendingPostToolCompactionGuard {\n\thardInputLimit: number;\n\tresult: VerbatimCompactionResult;\n}\n\nexport const agentSessionPostToolCompactionMethods = {\n\t_preflightPostToolContext,\n\t_finishPostToolCompactionPreflight,\n};\n"]}
|
|
@@ -11,6 +11,8 @@ type PromptOptionsWithWorkflowDelivery = PromptOptions & {
|
|
|
11
11
|
readonly delivered?: (action: UserMessageDeliveryAction) => void;
|
|
12
12
|
};
|
|
13
13
|
};
|
|
14
|
+
/** Dispatch registered slash commands without changing the raw queue pause gate. */
|
|
15
|
+
export declare function tryExecuteSessionSlashCommand(session: Pick<AgentSession, "_tryExecuteBuiltinSlashCommand" | "_tryExecuteExtensionCommand">, text: string): Promise<boolean>;
|
|
14
16
|
export declare function prompt(this: AgentSession, text: string, options?: PromptOptions): Promise<void>;
|
|
15
17
|
export declare function _runAgentPrompt(this: AgentSession, messages: AgentMessage | AgentMessage[], promptStarted?: () => void): Promise<void>;
|
|
16
18
|
export declare function _runAgentContinue(this: AgentSession): Promise<void>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agent-session-prompt.d.ts","sourceRoot":"","sources":["../../src/core/agent-session-prompt.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,+BAA+B,CAAC;AAClE,OAAO,KAAK,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAC;AAM9E,OAAO,KAAK,EAAE,2BAA2B,IAAI,YAAY,EAAE,MAAM,4BAA4B,CAAC;
|
|
1
|
+
{"version":3,"file":"agent-session-prompt.d.ts","sourceRoot":"","sources":["../../src/core/agent-session-prompt.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,+BAA+B,CAAC;AAClE,OAAO,KAAK,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAC;AAM9E,OAAO,KAAK,EAAE,2BAA2B,IA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CvG;AAED;;GAEG;AAEH,wBAAsB,2BAA2B,CAAC,IAAI,EAAE,YAAY,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CA2BpG;AAED;;;;GAIG;AAEH,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,YAAY,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,CAwB5E;AAED;;;;;;;GAOG;AAEH,wBAAsB,KAAK,CAAC,IAAI,EAAE,YAAY,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,YAAY,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAWpG;AAED;;;;;;GAMG;AAEH,wBAAsB,QAAQ,CAAC,IAAI,EAAE,YAAY,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,YAAY,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAWvG;AAED;;GAEG;AAEH,wBAAsB,eAAe,CAAC,IAAI,EAAE,YAAY,EACvD,OAAO,EAAE,MAAM,GAAG,CAAC,WAAW,GAAG,YAAY,CAAC,EAAE,EAChD,OAAO,CAAC,EAAE;IACT,SAAS,CAAC,EAAE,OAAO,GAAG,UAAU,CAAC;IACjC,kBAAkB,CAAC,EAAE,iCAAiC,CAAC,oBAAoB,CAAC,CAAC;CAC7E,GACC,OAAO,CAAC,IAAI,CAAC,CA+Bf;AAED;;;;GAIG;AAEH,eAAO,MAAM,yBAAyB;;;;;;;;;;;CAWrC,CAAC"}
|
|
@@ -4,7 +4,19 @@ import { ATOMIC_GUIDE_COMMAND_NAME, ATOMIC_GUIDE_HELP_CHOICES, atomicGuideModeFo
|
|
|
4
4
|
import { formatAuthStorageLoadFailedMessage, formatNoApiKeyFoundMessage, formatNoModelSelectedMessage, formatUnresolvedModelMessage } from "./auth-guidance.js";
|
|
5
5
|
import { expandPromptTemplate } from "./prompt-templates.js";
|
|
6
6
|
import { stripFrontmatter } from "../utils/frontmatter.js";
|
|
7
|
+
import { resolveWorkflowStageDeliveryTarget } from "./agent-session-delivery-forwarding.js";
|
|
8
|
+
/** Dispatch registered slash commands without changing the raw queue pause gate. */
|
|
9
|
+
export async function tryExecuteSessionSlashCommand(session, text) {
|
|
10
|
+
if (!text.startsWith("/"))
|
|
11
|
+
return false;
|
|
12
|
+
if (await session._tryExecuteBuiltinSlashCommand(text))
|
|
13
|
+
return true;
|
|
14
|
+
return session._tryExecuteExtensionCommand(text);
|
|
15
|
+
}
|
|
7
16
|
export async function prompt(text, options) {
|
|
17
|
+
const owner = resolveWorkflowStageDeliveryTarget(this);
|
|
18
|
+
if (owner !== this)
|
|
19
|
+
return owner.prompt(text, options);
|
|
8
20
|
const expandPromptTemplates = options?.expandPromptTemplates ?? true;
|
|
9
21
|
const preflightResult = options?.preflightResult;
|
|
10
22
|
const workflowDelivery = options?.__workflowDelivery;
|
|
@@ -13,21 +25,25 @@ export async function prompt(text, options) {
|
|
|
13
25
|
// Authorize workflow delivery before commands or input extensions can perform side effects.
|
|
14
26
|
// A later terminal transition cannot retroactively reject input accepted at this boundary.
|
|
15
27
|
workflowDelivery?.beforeDelivery?.();
|
|
16
|
-
//
|
|
17
|
-
//
|
|
18
|
-
if (expandPromptTemplates && text
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
28
|
+
// Registered slash commands execute without releasing ordinary queued work.
|
|
29
|
+
// Unknown slash input continues through the normal paused admission path.
|
|
30
|
+
if (expandPromptTemplates && await tryExecuteSessionSlashCommand(this, text)) {
|
|
31
|
+
workflowDelivery?.delivered?.("handled");
|
|
32
|
+
preflightResult?.(true);
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
// A controlled pause is an admission gate, including the idle gap after
|
|
36
|
+
// abort settles. Preserve the raw user payload without running input hooks,
|
|
37
|
+
// compaction, or a provider turn; explicit resume makes it eligible again.
|
|
38
|
+
if (this._queuedMessagesPaused) {
|
|
39
|
+
const delivery = options?.streamingBehavior === "followUp" ? "followUp" : "steer";
|
|
40
|
+
if (delivery === "followUp")
|
|
41
|
+
await this._queueFollowUp(text, options?.images);
|
|
42
|
+
else
|
|
43
|
+
await this._queueSteer(text, options?.images);
|
|
44
|
+
workflowDelivery?.delivered?.(delivery);
|
|
45
|
+
preflightResult?.(true);
|
|
46
|
+
return;
|
|
31
47
|
}
|
|
32
48
|
// Emit input event for extension interception (before skill/template expansion)
|
|
33
49
|
let currentText = text;
|
|
@@ -157,6 +173,16 @@ export async function prompt(text, options) {
|
|
|
157
173
|
await turn;
|
|
158
174
|
}
|
|
159
175
|
export async function _runAgentPrompt(messages, promptStarted) {
|
|
176
|
+
const owner = resolveWorkflowStageDeliveryTarget(this);
|
|
177
|
+
if (owner !== this) {
|
|
178
|
+
if (owner._queuedMessagesPaused) {
|
|
179
|
+
const items = Array.isArray(messages) ? messages : [messages];
|
|
180
|
+
for (const message of items)
|
|
181
|
+
owner._queueAgentMessage(message, "steer");
|
|
182
|
+
return;
|
|
183
|
+
}
|
|
184
|
+
return owner._runAgentPrompt(messages, promptStarted);
|
|
185
|
+
}
|
|
160
186
|
try {
|
|
161
187
|
const turn = this.agent.prompt(messages);
|
|
162
188
|
if (this.isStreaming)
|
|
@@ -182,7 +208,7 @@ export async function _runAgentContinue() {
|
|
|
182
208
|
}
|
|
183
209
|
export async function _continueQueuedAgentMessages() {
|
|
184
210
|
await this._agentEventQueue;
|
|
185
|
-
while (this.agent.hasQueuedMessages()) {
|
|
211
|
+
while (!this._queuedMessagesPaused && this.agent.hasQueuedMessages()) {
|
|
186
212
|
await this.agent.continue();
|
|
187
213
|
await this.waitForRetry();
|
|
188
214
|
await this._agentEventQueue;
|