@bastani/atomic 0.9.18-alpha.5 → 0.9.18-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 +88 -0
- package/README.md +3 -3
- package/dist/builtin/intercom/CHANGELOG.md +39 -0
- package/dist/builtin/intercom/README.md +22 -2
- package/dist/builtin/intercom/broker/broker.ts +676 -128
- package/dist/builtin/intercom/broker/client.ts +151 -35
- package/dist/builtin/intercom/broker/delivered-message-cache.ts +497 -37
- package/dist/builtin/intercom/broker/framing.ts +4 -2
- package/dist/builtin/intercom/broker/paths.ts +10 -0
- package/dist/builtin/intercom/broker/pending-send-registry.ts +1 -2
- package/dist/builtin/intercom/broker/send-handler.ts +311 -52
- package/dist/builtin/intercom/broker/send-signature.ts +4 -2
- package/dist/builtin/intercom/broker/socket-writes.ts +103 -0
- package/dist/builtin/intercom/broker/spawn.ts +9 -4
- package/dist/builtin/intercom/index.bundle.mjs +1410 -212
- package/dist/builtin/intercom/package.json +2 -2
- package/dist/builtin/intercom/recoverable-disconnect.ts +52 -0
- package/dist/builtin/intercom/retry-policy.ts +8 -0
- package/dist/builtin/intercom/skills/intercom/SKILL.md +17 -9
- package/dist/builtin/intercom/types.ts +27 -8
- package/dist/builtin/intercom/workflow-stage-path-matching.ts +90 -0
- package/dist/builtin/intercom/workflow-stage-target.ts +57 -0
- package/dist/builtin/mcp/index.bundle.mjs +427 -126
- package/dist/builtin/mcp/package.json +2 -2
- package/dist/builtin/subagents/CHANGELOG.md +19 -0
- package/dist/builtin/subagents/README.md +3 -3
- package/dist/builtin/subagents/agents/code-simplifier.md +2 -2
- package/dist/builtin/subagents/agents/codebase-analyzer.md +2 -2
- package/dist/builtin/subagents/agents/codebase-locator.md +2 -2
- package/dist/builtin/subagents/agents/codebase-online-researcher.md +11 -11
- package/dist/builtin/subagents/agents/codebase-pattern-finder.md +2 -2
- package/dist/builtin/subagents/agents/codebase-research-analyzer.md +2 -2
- package/dist/builtin/subagents/agents/codebase-research-locator.md +2 -2
- package/dist/builtin/subagents/agents/debugger.md +3 -3
- package/dist/builtin/subagents/agents/worker.md +2 -2
- package/dist/builtin/subagents/package.json +3 -3
- package/dist/builtin/subagents/skills/qlty/SKILL.md +29 -101
- package/dist/builtin/subagents/skills/qlty/references/manual-configuration.md +52 -0
- package/dist/builtin/subagents/skills/subagent/SKILL.md +11 -11
- package/dist/builtin/subagents/src/extension/index.bundle.mjs +49 -132
- package/dist/builtin/web-access/package.json +2 -2
- package/dist/builtin/workflows/CHANGELOG.md +46 -0
- package/dist/builtin/workflows/README.md +7 -7
- package/dist/builtin/workflows/builtin/adversarial-verification.js +2 -2
- package/dist/builtin/workflows/builtin/{chunk-szz1ajz9.js → chunk-42s7sw0b.js} +9 -2
- package/dist/builtin/workflows/builtin/{chunk-2dqb5s2q.js → chunk-79fjkcvh.js} +1 -1
- package/dist/builtin/workflows/builtin/{chunk-n58a7v26.js → chunk-b0v2xab1.js} +181 -10
- package/dist/builtin/workflows/builtin/{chunk-fghhy2a5.js → chunk-ed4jfn5t.js} +23 -5
- package/dist/builtin/workflows/builtin/{chunk-h3r2vkzc.js → chunk-hqpe2cyx.js} +60 -21
- package/dist/builtin/workflows/builtin/{chunk-hzzn6adg.js → chunk-k3w87x8y.js} +1 -1
- package/dist/builtin/workflows/builtin/{chunk-82ha8p41.js → chunk-n8h4yyew.js} +1 -1
- package/dist/builtin/workflows/builtin/{chunk-qwzvgxnq.js → chunk-reqr3sr3.js} +1 -1
- package/dist/builtin/workflows/builtin/{chunk-c53y8bdh.js → chunk-wgccch41.js} +1 -1
- package/dist/builtin/workflows/builtin/{chunk-0x6e303p.js → chunk-zbekjqew.js} +20 -7
- package/dist/builtin/workflows/builtin/{chunk-29wrp38a.js → chunk-ze5x3d1r.js} +1 -1
- package/dist/builtin/workflows/builtin/classify-and-act.js +2 -2
- package/dist/builtin/workflows/builtin/fan-out-and-synthesize.js +2 -2
- package/dist/builtin/workflows/builtin/generate-and-filter.js +2 -2
- package/dist/builtin/workflows/builtin/goal.js +3 -3
- package/dist/builtin/workflows/builtin/index.js +11 -11
- package/dist/builtin/workflows/builtin/loop-until-done.js +2 -2
- package/dist/builtin/workflows/builtin/open-claude-design.js +2 -2
- package/dist/builtin/workflows/builtin/ralph.js +3 -3
- package/dist/builtin/workflows/builtin/steering-context.js +1 -1
- package/dist/builtin/workflows/builtin/tournament.js +2 -2
- package/dist/builtin/workflows/package.json +2 -2
- package/dist/builtin/workflows/skills/prompt-engineer/SKILL.md +39 -52
- package/dist/builtin/workflows/skills/prompt-engineer/references/advanced_patterns.md +9 -37
- package/dist/builtin/workflows/skills/prompt-engineer/references/claude_fable_5.md +49 -0
- package/dist/builtin/workflows/skills/prompt-engineer/references/claude_fable_5_1.md +57 -0
- package/dist/builtin/workflows/skills/prompt-engineer/references/claude_opus_4_8.md +57 -0
- package/dist/builtin/workflows/skills/prompt-engineer/references/claude_opus_5.md +47 -0
- package/dist/builtin/workflows/skills/prompt-engineer/references/claude_sonnet_5.md +57 -0
- package/dist/builtin/workflows/skills/prompt-engineer/references/gpt_5_5.md +60 -0
- package/dist/builtin/workflows/skills/prompt-engineer/references/gpt_5_6.md +58 -0
- package/dist/builtin/workflows/skills/prompt-engineer/references/gpt_6_astra.md +58 -0
- package/dist/builtin/workflows/skills/prompt-engineer/references/quality_improvement.md +18 -4
- package/dist/builtin/workflows/src/extension/index.bundle.mjs +3194 -737
- package/dist/builtin/workflows/src/index.js +899 -436
- package/dist/builtin/workflows/src/shared/authoring-contract-stage.d.ts +0 -10
- package/dist/cli/list-models.d.ts.map +1 -1
- package/dist/cli/list-models.js +4 -0
- package/dist/cli/list-models.js.map +1 -1
- package/dist/client/index.d.ts +1 -2
- package/dist/client/index.d.ts.map +1 -1
- package/dist/client/index.js +1 -2
- package/dist/client/index.js.map +1 -1
- package/dist/config.d.ts +0 -9
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +0 -45
- package/dist/config.js.map +1 -1
- package/dist/core/agent-session-compaction.d.ts.map +1 -1
- package/dist/core/agent-session-compaction.js +8 -6
- package/dist/core/agent-session-compaction.js.map +1 -1
- package/dist/core/agent-session-methods.d.ts +1 -0
- 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.map +1 -1
- package/dist/core/agent-session-models.js +3 -4
- package/dist/core/agent-session-models.js.map +1 -1
- package/dist/core/agent-session-queue-pause.d.ts.map +1 -1
- package/dist/core/agent-session-queue-pause.js +6 -0
- package/dist/core/agent-session-queue-pause.js.map +1 -1
- package/dist/core/agent-session-runtime.d.ts.map +1 -1
- package/dist/core/agent-session-runtime.js +13 -5
- package/dist/core/agent-session-runtime.js.map +1 -1
- package/dist/core/agent-session-tool-hooks.js +1 -1
- package/dist/core/agent-session-tool-hooks.js.map +1 -1
- package/dist/core/agent-session-tree.d.ts.map +1 -1
- package/dist/core/agent-session-tree.js +8 -0
- package/dist/core/agent-session-tree.js.map +1 -1
- package/dist/core/agent-session.d.ts +2 -0
- package/dist/core/agent-session.d.ts.map +1 -1
- package/dist/core/agent-session.js +2 -0
- package/dist/core/agent-session.js.map +1 -1
- package/dist/core/compaction/branch-summarization.d.ts +2 -2
- package/dist/core/compaction/branch-summarization.d.ts.map +1 -1
- package/dist/core/compaction/branch-summarization.js +4 -4
- package/dist/core/compaction/branch-summarization.js.map +1 -1
- package/dist/core/extensions/api-types.d.ts +8 -2
- package/dist/core/extensions/api-types.d.ts.map +1 -1
- package/dist/core/extensions/api-types.js.map +1 -1
- package/dist/core/extensions/context-types.d.ts +12 -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/runner-shortcuts.d.ts.map +1 -1
- package/dist/core/extensions/runner-shortcuts.js +0 -1
- package/dist/core/extensions/runner-shortcuts.js.map +1 -1
- package/dist/core/fast-model-routing-transport.d.ts +12 -0
- package/dist/core/fast-model-routing-transport.d.ts.map +1 -0
- package/dist/core/{codex-fast-mode-transport.js → fast-model-routing-transport.js} +29 -29
- package/dist/core/fast-model-routing-transport.js.map +1 -0
- package/dist/core/fast-model-routing.d.ts +57 -0
- package/dist/core/fast-model-routing.d.ts.map +1 -0
- package/dist/core/fast-model-routing.js +201 -0
- package/dist/core/fast-model-routing.js.map +1 -0
- package/dist/core/fast-model-variants.d.ts +98 -0
- package/dist/core/fast-model-variants.d.ts.map +1 -0
- package/dist/core/fast-model-variants.js +148 -0
- package/dist/core/fast-model-variants.js.map +1 -0
- package/dist/core/http-dispatcher.d.ts.map +1 -1
- package/dist/core/http-dispatcher.js +4 -2
- package/dist/core/http-dispatcher.js.map +1 -1
- package/dist/core/keybindings.d.ts +0 -10
- package/dist/core/keybindings.d.ts.map +1 -1
- package/dist/core/keybindings.js +0 -8
- package/dist/core/keybindings.js.map +1 -1
- package/dist/core/messages.d.ts +1 -1
- package/dist/core/messages.d.ts.map +1 -1
- package/dist/core/messages.js.map +1 -1
- package/dist/core/model-config.d.ts +15 -0
- package/dist/core/model-config.d.ts.map +1 -1
- package/dist/core/model-config.js +3 -0
- package/dist/core/model-config.js.map +1 -1
- package/dist/core/model-resolver-initial.js +1 -1
- package/dist/core/model-resolver-initial.js.map +1 -1
- package/dist/core/model-runtime-streaming.d.ts +14 -1
- package/dist/core/model-runtime-streaming.d.ts.map +1 -1
- package/dist/core/model-runtime-streaming.js +25 -3
- package/dist/core/model-runtime-streaming.js.map +1 -1
- package/dist/core/model-runtime.d.ts +39 -2
- package/dist/core/model-runtime.d.ts.map +1 -1
- package/dist/core/model-runtime.js +91 -7
- package/dist/core/model-runtime.js.map +1 -1
- package/dist/core/provider-composer-internal.d.ts.map +1 -1
- package/dist/core/provider-composer-internal.js +8 -2
- package/dist/core/provider-composer-internal.js.map +1 -1
- package/dist/core/sdk.d.ts.map +1 -1
- package/dist/core/sdk.js +18 -18
- package/dist/core/sdk.js.map +1 -1
- package/dist/core/session-manager-archive.d.ts.map +1 -1
- package/dist/core/session-manager-archive.js +25 -2
- package/dist/core/session-manager-archive.js.map +1 -1
- package/dist/core/settings-manager-core.d.ts +0 -2
- package/dist/core/settings-manager-core.d.ts.map +1 -1
- package/dist/core/settings-manager-core.js +2 -9
- package/dist/core/settings-manager-core.js.map +1 -1
- package/dist/core/settings-manager-internals.d.ts +0 -1
- package/dist/core/settings-manager-internals.d.ts.map +1 -1
- package/dist/core/settings-manager-internals.js.map +1 -1
- package/dist/core/settings-manager-ui-accessors.d.ts +0 -8
- package/dist/core/settings-manager-ui-accessors.d.ts.map +1 -1
- package/dist/core/settings-manager-ui-accessors.js +0 -53
- package/dist/core/settings-manager-ui-accessors.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-types.d.ts +0 -5
- package/dist/core/settings-types.d.ts.map +1 -1
- package/dist/core/settings-types.js.map +1 -1
- package/dist/core/skills.d.ts +1 -1
- package/dist/core/skills.d.ts.map +1 -1
- package/dist/core/skills.js +4 -2
- package/dist/core/skills.js.map +1 -1
- package/dist/core/slash-commands.d.ts.map +1 -1
- package/dist/core/slash-commands.js +0 -1
- package/dist/core/slash-commands.js.map +1 -1
- package/dist/core/system-prompt.js +7 -7
- package/dist/core/system-prompt.js.map +1 -1
- package/dist/core/tools/edit.d.ts +1 -1
- package/dist/core/tools/edit.d.ts.map +1 -1
- package/dist/core/tools/edit.js +128 -3
- package/dist/core/tools/edit.js.map +1 -1
- package/dist/core/tools/hashline.d.ts +2 -2
- package/dist/core/tools/hashline.d.ts.map +1 -1
- package/dist/core/tools/hashline.js +40 -10
- package/dist/core/tools/hashline.js.map +1 -1
- package/dist/core/tools/write.d.ts.map +1 -1
- package/dist/core/tools/write.js +8 -8
- package/dist/core/tools/write.js.map +1 -1
- package/dist/core/workflow-stage-admission.d.ts +6 -0
- package/dist/core/workflow-stage-admission.d.ts.map +1 -1
- package/dist/core/workflow-stage-admission.js +14 -0
- package/dist/core/workflow-stage-admission.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 +5 -5
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -5
- package/dist/index.js.map +1 -1
- package/dist/modes/interactive/components/atomic-working-status.d.ts +4 -0
- package/dist/modes/interactive/components/atomic-working-status.d.ts.map +1 -1
- package/dist/modes/interactive/components/atomic-working-status.js +26 -1
- package/dist/modes/interactive/components/atomic-working-status.js.map +1 -1
- package/dist/modes/interactive/components/custom-editor.d.ts +7 -0
- package/dist/modes/interactive/components/custom-editor.d.ts.map +1 -1
- package/dist/modes/interactive/components/custom-editor.js +43 -0
- package/dist/modes/interactive/components/custom-editor.js.map +1 -1
- package/dist/modes/interactive/components/footer.d.ts.map +1 -1
- package/dist/modes/interactive/components/footer.js +0 -6
- package/dist/modes/interactive/components/footer.js.map +1 -1
- package/dist/modes/interactive/components/index.d.ts +1 -2
- package/dist/modes/interactive/components/index.d.ts.map +1 -1
- package/dist/modes/interactive/components/index.js +0 -1
- package/dist/modes/interactive/components/index.js.map +1 -1
- package/dist/modes/interactive/components/model-selector.d.ts +1 -1
- package/dist/modes/interactive/components/model-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/model-selector.js +6 -11
- package/dist/modes/interactive/components/model-selector.js.map +1 -1
- package/dist/modes/interactive/components/scoped-models-selector.d.ts +2 -5
- package/dist/modes/interactive/components/scoped-models-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/scoped-models-selector.js +3 -19
- package/dist/modes/interactive/components/scoped-models-selector.js.map +1 -1
- package/dist/modes/interactive/components/settings-selector-items.js +1 -1
- package/dist/modes/interactive/components/settings-selector-items.js.map +1 -1
- package/dist/modes/interactive/components/thinking-selector.d.ts +1 -2
- package/dist/modes/interactive/components/thinking-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/thinking-selector.js +4 -11
- package/dist/modes/interactive/components/thinking-selector.js.map +1 -1
- package/dist/modes/interactive/components/transcript-follow-indicator.js +3 -3
- package/dist/modes/interactive/components/transcript-follow-indicator.js.map +1 -1
- package/dist/modes/interactive/interactive-agent-events.js +8 -8
- package/dist/modes/interactive/interactive-agent-events.js.map +1 -1
- package/dist/modes/interactive/interactive-autocomplete.js +5 -16
- package/dist/modes/interactive/interactive-autocomplete.js.map +1 -1
- package/dist/modes/interactive/interactive-bash-compact.js +2 -9
- 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 +3 -0
- package/dist/modes/interactive/interactive-deferred-startup.js.map +1 -1
- package/dist/modes/interactive/interactive-editor-actions.js +2 -2
- package/dist/modes/interactive/interactive-editor-actions.js.map +1 -1
- package/dist/modes/interactive/interactive-extension-custom-ui.js +1 -0
- package/dist/modes/interactive/interactive-extension-custom-ui.js.map +1 -1
- package/dist/modes/interactive/interactive-extension-dialogs.js +7 -0
- package/dist/modes/interactive/interactive-extension-dialogs.js.map +1 -1
- package/dist/modes/interactive/interactive-extension-runtime.js +20 -10
- package/dist/modes/interactive/interactive-extension-runtime.js.map +1 -1
- package/dist/modes/interactive/interactive-hotkeys-debug.js +1 -5
- package/dist/modes/interactive/interactive-hotkeys-debug.js.map +1 -1
- package/dist/modes/interactive/interactive-initial-session-binding.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-initial-session-binding.js +3 -0
- package/dist/modes/interactive/interactive-initial-session-binding.js.map +1 -1
- package/dist/modes/interactive/interactive-input-handling.js +0 -8
- package/dist/modes/interactive/interactive-input-handling.js.map +1 -1
- package/dist/modes/interactive/interactive-mode-base.d.ts +5 -1
- package/dist/modes/interactive/interactive-mode-base.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-mode-base.js +15 -9
- package/dist/modes/interactive/interactive-mode-base.js.map +1 -1
- package/dist/modes/interactive/interactive-mode-deps.d.ts +1 -3
- package/dist/modes/interactive/interactive-mode-deps.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-mode-deps.js +1 -3
- package/dist/modes/interactive/interactive-mode-deps.js.map +1 -1
- package/dist/modes/interactive/interactive-mode-surface.d.ts +9 -12
- 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-model-routing.js +10 -13
- package/dist/modes/interactive/interactive-model-routing.js.map +1 -1
- package/dist/modes/interactive/interactive-render-chat.js +29 -0
- package/dist/modes/interactive/interactive-render-chat.js.map +1 -1
- package/dist/modes/interactive/interactive-selectors.js +2 -32
- package/dist/modes/interactive/interactive-selectors.js.map +1 -1
- package/dist/modes/interactive/interactive-session-routing.js +1 -5
- package/dist/modes/interactive/interactive-session-routing.js.map +1 -1
- package/dist/modes/interactive/interactive-session-runtime.js +1 -5
- package/dist/modes/interactive/interactive-session-runtime.js.map +1 -1
- package/dist/modes/interactive/interactive-slash-commands.js +6 -13
- package/dist/modes/interactive/interactive-slash-commands.js.map +1 -1
- package/dist/modes/interactive/interactive-startup.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-startup.js +19 -13
- package/dist/modes/interactive/interactive-startup.js.map +1 -1
- package/dist/modes/interactive/interactive-tui.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-tui.js +27 -3
- package/dist/modes/interactive/interactive-tui.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 +1 -0
- package/dist/modes/interactive-engine/engine-custom-ui.js.map +1 -1
- package/dist/modes/interactive-engine/isolated-runtime.d.ts.map +1 -1
- package/dist/modes/interactive-engine/isolated-runtime.js +4 -1
- package/dist/modes/interactive-engine/isolated-runtime.js.map +1 -1
- package/dist/utils/child-process.d.ts.map +1 -1
- package/dist/utils/child-process.js +13 -6
- package/dist/utils/child-process.js.map +1 -1
- package/dist/utils/exif-orientation.d.ts.map +1 -1
- package/dist/utils/exif-orientation.js +2 -3
- package/dist/utils/exif-orientation.js.map +1 -1
- package/dist/utils/tools-manager.d.ts +1 -0
- package/dist/utils/tools-manager.d.ts.map +1 -1
- package/dist/utils/tools-manager.js +33 -18
- package/dist/utils/tools-manager.js.map +1 -1
- package/docs/custom-provider.md +2 -0
- package/docs/development.md +17 -0
- package/docs/docs.json +14 -2
- package/docs/extensions.md +9 -4
- package/docs/intercom.md +41 -7
- package/docs/keybindings.md +8 -6
- package/docs/models/evals.md +394 -0
- package/docs/models/model-selection.md +54 -27
- package/docs/models/pareto-efficiency.md +33 -16
- package/docs/models.md +37 -1
- package/docs/packages.md +2 -2
- package/docs/providers.md +44 -20
- package/docs/quickstart.md +8 -6
- package/docs/rpc.md +3 -3
- package/docs/sdk.md +2 -16
- package/docs/settings.md +19 -22
- package/docs/skills.md +4 -2
- package/docs/subagents.md +9 -3
- package/docs/tools/edit.md +373 -0
- package/docs/tools.md +3 -7
- package/docs/tui.md +2 -1
- package/docs/usage.md +3 -5
- package/docs/workflows/api-reference.md +1395 -0
- package/docs/workflows/authoring.md +678 -0
- package/docs/workflows/builtins.md +245 -0
- package/docs/workflows/operations.md +811 -0
- package/docs/workflows/reliable-design.md +2099 -0
- package/docs/workflows/verification.md +62 -0
- package/docs/workflows.md +15 -5183
- package/npm-shrinkwrap.json +584 -69
- package/package.json +7 -7
- package/dist/client/remote-session.d.ts +0 -64
- package/dist/client/remote-session.d.ts.map +0 -1
- package/dist/client/remote-session.js +0 -351
- package/dist/client/remote-session.js.map +0 -1
- package/dist/client/transcript.d.ts +0 -12
- package/dist/client/transcript.d.ts.map +0 -1
- package/dist/client/transcript.js +0 -98
- package/dist/client/transcript.js.map +0 -1
- package/dist/core/codex-fast-mode-transport.d.ts +0 -12
- package/dist/core/codex-fast-mode-transport.d.ts.map +0 -1
- package/dist/core/codex-fast-mode-transport.js.map +0 -1
- package/dist/core/codex-fast-mode.d.ts +0 -53
- package/dist/core/codex-fast-mode.d.ts.map +0 -1
- package/dist/core/codex-fast-mode.js +0 -249
- package/dist/core/codex-fast-mode.js.map +0 -1
- package/dist/modes/interactive/components/fast-mode-selector.d.ts +0 -27
- package/dist/modes/interactive/components/fast-mode-selector.d.ts.map +0 -1
- package/dist/modes/interactive/components/fast-mode-selector.js +0 -107
- package/dist/modes/interactive/components/fast-mode-selector.js.map +0 -1
- package/dist/server/create-harness.d.ts +0 -53
- package/dist/server/create-harness.d.ts.map +0 -1
- package/dist/server/create-harness.js +0 -360
- package/dist/server/create-harness.js.map +0 -1
- package/docs/models/artificial-analysis-index.md +0 -83
|
@@ -116,13 +116,6 @@ export interface WorkflowScopedModel {
|
|
|
116
116
|
/** @deprecated Prefer suffixing model/fallbackModels entries with `:level`; removal is deferred. */
|
|
117
117
|
readonly thinkingLevel?: WorkflowThinkingLevel;
|
|
118
118
|
}
|
|
119
|
-
export interface WorkflowFastModeSettings extends WorkflowSerializableObject {
|
|
120
|
-
readonly enabled?: boolean;
|
|
121
|
-
readonly model?: string;
|
|
122
|
-
}
|
|
123
|
-
export interface WorkflowFastModeSettingsManager {
|
|
124
|
-
getCodexFastModeSettings(): WorkflowFastModeSettings;
|
|
125
|
-
}
|
|
126
119
|
export interface StageOptions<TSchemaDef extends TSchema | undefined = TSchema | undefined> extends WorkflowModelFallbackFields {
|
|
127
120
|
/** Optional structured final-answer schema. When set, the stage receives a schema-specific final-answer tool. */
|
|
128
121
|
readonly schema?: TSchemaDef;
|
|
@@ -234,7 +227,6 @@ export interface StageSessionRuntime {
|
|
|
234
227
|
readonly messages: readonly WorkflowSerializableValue[];
|
|
235
228
|
readonly isStreaming: boolean;
|
|
236
229
|
readonly pendingMessageCount?: number;
|
|
237
|
-
readonly settingsManager?: WorkflowFastModeSettingsManager;
|
|
238
230
|
navigateTree(targetId: string, options?: {
|
|
239
231
|
readonly summarize?: boolean;
|
|
240
232
|
readonly customInstructions?: string;
|
|
@@ -253,7 +245,6 @@ export interface StageSessionRuntime {
|
|
|
253
245
|
export type StageSessionCreateOptions = StageOptions;
|
|
254
246
|
export interface StageSessionCreateResult {
|
|
255
247
|
readonly session: StageSessionRuntime;
|
|
256
|
-
readonly settingsManager?: WorkflowFastModeSettingsManager;
|
|
257
248
|
}
|
|
258
249
|
export interface StageExecutionMeta {
|
|
259
250
|
readonly runId: string;
|
|
@@ -336,7 +327,6 @@ export interface WorkflowTaskResult extends WorkflowTaskContext {
|
|
|
336
327
|
readonly sessionFile?: string;
|
|
337
328
|
readonly artifacts?: readonly WorkflowArtifact[];
|
|
338
329
|
readonly model?: string;
|
|
339
|
-
readonly fastMode?: boolean;
|
|
340
330
|
readonly attemptedModels?: readonly string[];
|
|
341
331
|
readonly modelAttempts?: readonly WorkflowModelAttempt[];
|
|
342
332
|
readonly warnings?: readonly string[];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"list-models.d.ts","sourceRoot":"","sources":["../../src/cli/list-models.ts"],"names":[],"mappings":"AAAA;;GAEG;AAMH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AAiB7D;;GAEG;AACH,wBAAsB,UAAU,CAAC,YAAY,EAAE,YAAY,EAAE,aAAa,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,
|
|
1
|
+
{"version":3,"file":"list-models.d.ts","sourceRoot":"","sources":["../../src/cli/list-models.ts"],"names":[],"mappings":"AAAA;;GAEG;AAMH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AAiB7D;;GAEG;AACH,wBAAsB,UAAU,CAAC,YAAY,EAAE,YAAY,EAAE,aAAa,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAsFlG"}
|
package/dist/cli/list-models.js
CHANGED
|
@@ -26,6 +26,10 @@ export async function listModels(modelRuntime, searchPattern) {
|
|
|
26
26
|
if (loadError) {
|
|
27
27
|
console.error(chalk.yellow(`Warning: errors loading models.json:\n${loadError}`));
|
|
28
28
|
}
|
|
29
|
+
const catalogWarning = modelRuntime.getWarning();
|
|
30
|
+
if (catalogWarning) {
|
|
31
|
+
console.error(chalk.yellow(`Warning: ${catalogWarning}`));
|
|
32
|
+
}
|
|
29
33
|
const models = modelRuntime.getAvailableSnapshot();
|
|
30
34
|
if (models.length === 0) {
|
|
31
35
|
console.log(formatNoModelsAvailableMessage());
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"list-models.js","sourceRoot":"","sources":["../../src/cli/list-models.ts"],"names":[],"mappings":"AAAA;;GAEG;AAGH,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AACrD,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,8BAA8B,EAAE,MAAM,0BAA0B,CAAC;AAG1E;;GAEG;AACH,SAAS,gBAAgB,CAAC,KAAa;IACtC,IAAI,KAAK,IAAI,SAAS,EAAE,CAAC;QACxB,MAAM,QAAQ,GAAG,KAAK,GAAG,SAAS,CAAC;QACnC,OAAO,QAAQ,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,GAAG,QAAQ,GAAG,CAAC,CAAC,CAAC,GAAG,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,CAAC;IACxE,CAAC;IACD,IAAI,KAAK,IAAI,KAAK,EAAE,CAAC;QACpB,MAAM,SAAS,GAAG,KAAK,GAAG,KAAK,CAAC;QAChC,OAAO,SAAS,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,GAAG,SAAS,GAAG,CAAC,CAAC,CAAC,GAAG,SAAS,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,CAAC;IAC3E,CAAC;IACD,OAAO,KAAK,CAAC,QAAQ,EAAE,CAAC;AACzB,CAAC;AAED;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,UAAU,CAAC,YAA0B,EAAE,aAAsB;IAClF,MAAM,SAAS,GAAG,YAAY,CAAC,QAAQ,EAAE,CAA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,CAAC,OAAO,CAAC;YAClC,GAAG,CAAC,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC;YAChC,GAAG,CAAC,QAAQ,CAAC,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC;YACpC,GAAG,CAAC,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC;SAChC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACb,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;IACnB,CAAC;AACF,CAAC","sourcesContent":["/**\n * List available models with optional fuzzy search\n */\n\nimport type { Api, Model } from \"@bastani/pi-ai/compat\";\nimport { fuzzyFilter } from \"@earendil-works/pi-tui\";\nimport chalk from \"chalk\";\nimport { formatNoModelsAvailableMessage } from \"../core/auth-guidance.ts\";\nimport type { ModelRuntime } from \"../core/model-runtime.js\";\n\n/**\n * Format a number as human-readable (e.g., 200000 -> \"200K\", 1000000 -> \"1M\")\n */\nfunction formatTokenCount(count: number): string {\n\tif (count >= 1_000_000) {\n\t\tconst millions = count / 1_000_000;\n\t\treturn millions % 1 === 0 ? `${millions}M` : `${millions.toFixed(1)}M`;\n\t}\n\tif (count >= 1_000) {\n\t\tconst thousands = count / 1_000;\n\t\treturn thousands % 1 === 0 ? `${thousands}K` : `${thousands.toFixed(1)}K`;\n\t}\n\treturn count.toString();\n}\n\n/**\n * List available models, optionally filtered by search pattern\n */\nexport async function listModels(modelRuntime: ModelRuntime, searchPattern?: string): Promise<void> {\n\tconst loadError = modelRuntime.getError();\n\tif (loadError) {\n\t\tconsole.error(chalk.yellow(`Warning: errors loading models.json:\\n${loadError}`));\n\t}\n\n\tconst models = modelRuntime.getAvailableSnapshot();\n\n\tif (models.length === 0) {\n\t\tconsole.log(formatNoModelsAvailableMessage());\n\t\treturn;\n\t}\n\n\t// Apply fuzzy filter if search pattern provided\n\tlet filteredModels: Model<Api>[] = [...models];\n\tif (searchPattern) {\n\t\tfilteredModels = fuzzyFilter([...models], searchPattern, (m) => `${m.provider} ${m.id}`);\n\t}\n\n\tif (filteredModels.length === 0) {\n\t\tconsole.log(`No models matching \"${searchPattern}\"`);\n\t\treturn;\n\t}\n\n\t// Sort by provider, then by model id\n\tfilteredModels.sort((a, b) => {\n\t\tconst providerCmp = a.provider.localeCompare(b.provider);\n\t\tif (providerCmp !== 0) return providerCmp;\n\t\treturn a.id.localeCompare(b.id);\n\t});\n\n\t// Calculate column widths\n\tconst rows = filteredModels.map((m) => ({\n\t\tprovider: m.provider,\n\t\tmodel: m.id,\n\t\tcontext: formatTokenCount(m.contextWindow),\n\t\tmaxOut: formatTokenCount(m.maxTokens),\n\t\tthinking: m.reasoning ? \"yes\" : \"no\",\n\t\timages: m.input.includes(\"image\") ? \"yes\" : \"no\",\n\t}));\n\n\tconst headers = {\n\t\tprovider: \"provider\",\n\t\tmodel: \"model\",\n\t\tcontext: \"context\",\n\t\tmaxOut: \"max-out\",\n\t\tthinking: \"thinking\",\n\t\timages: \"images\",\n\t};\n\n\tconst widths = {\n\t\tprovider: Math.max(headers.provider.length, ...rows.map((r) => r.provider.length)),\n\t\tmodel: Math.max(headers.model.length, ...rows.map((r) => r.model.length)),\n\t\tcontext: Math.max(headers.context.length, ...rows.map((r) => r.context.length)),\n\t\tmaxOut: Math.max(headers.maxOut.length, ...rows.map((r) => r.maxOut.length)),\n\t\tthinking: Math.max(headers.thinking.length, ...rows.map((r) => r.thinking.length)),\n\t\timages: Math.max(headers.images.length, ...rows.map((r) => r.images.length)),\n\t};\n\n\t// Print header\n\tconst headerLine = [\n\t\theaders.provider.padEnd(widths.provider),\n\t\theaders.model.padEnd(widths.model),\n\t\theaders.context.padEnd(widths.context),\n\t\theaders.maxOut.padEnd(widths.maxOut),\n\t\theaders.thinking.padEnd(widths.thinking),\n\t\theaders.images.padEnd(widths.images),\n\t].join(\" \");\n\tconsole.log(headerLine);\n\n\t// Print rows\n\tfor (const row of rows) {\n\t\tconst line = [\n\t\t\trow.provider.padEnd(widths.provider),\n\t\t\trow.model.padEnd(widths.model),\n\t\t\trow.context.padEnd(widths.context),\n\t\t\trow.maxOut.padEnd(widths.maxOut),\n\t\t\trow.thinking.padEnd(widths.thinking),\n\t\t\trow.images.padEnd(widths.images),\n\t\t].join(\" \");\n\t\tconsole.log(line);\n\t}\n}\n"]}
|
|
1
|
+
{"version":3,"file":"list-models.js","sourceRoot":"","sources":["../../src/cli/list-models.ts"],"names":[],"mappings":"AAAA;;GAEG;AAGH,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AACrD,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,8BAA8B,EAAE,MAAM,0BAA0B,CAAC;AAG1E;;GAEG;AACH,SAAS,gBAAgB,CAAC,KAAa;IACtC,IAAI,KAAK,IAAI,SAAS,EAAE,CAAC;QACxB,MAAM,QAAQ,GAAG,KAAK,GAAG,SAAS,CAAC;QACnC,OAAO,QAAQ,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,GAAG,QAAQ,GAAG,CAAC,CAAC,CAAC,GAAG,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,CAAC;IACxE,CAAC;IACD,IAAI,KAAK,IAAI,KAAK,EAAE,CAAC;QACpB,MAAM,SAAS,GAAG,KAAK,GAAG,KAAK,CAAC;QAChC,OAAO,SAAS,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,GAAG,SAAS,GAAG,CAAC,CAAC,CAAC,GAAG,SAAS,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,CAAC;IAC3E,CAAC;IACD,OAAO,KAAK,CAAC,QAAQ,EAAE,CAAC;AACzB,CAAC;AAED;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,UAAU,CAAC,YAA0B,EAAE,aAAsB;IAClF,MAAM,SAAS,GAAG,YAAY,CAAC,QAAQ,EAAE,CAAC;IAC1C,IAAI,SAAS,EAAE,CAAC;QACf,OAAO,CAAC,KAAK,CAAC,KAAK,CA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;YACpC,GAAG,CAAC,KAAK,CAAC,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC;YAC9B,GAAG,CAAC,OAAO,CAAC,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC;YAClC,GAAG,CAAC,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC;YAChC,GAAG,CAAC,QAAQ,CAAC,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC;YACpC,GAAG,CAAC,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC;SAChC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACb,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;IACnB,CAAC;AACF,CAAC","sourcesContent":["/**\n * List available models with optional fuzzy search\n */\n\nimport type { Api, Model } from \"@bastani/pi-ai/compat\";\nimport { fuzzyFilter } from \"@earendil-works/pi-tui\";\nimport chalk from \"chalk\";\nimport { formatNoModelsAvailableMessage } from \"../core/auth-guidance.ts\";\nimport type { ModelRuntime } from \"../core/model-runtime.js\";\n\n/**\n * Format a number as human-readable (e.g., 200000 -> \"200K\", 1000000 -> \"1M\")\n */\nfunction formatTokenCount(count: number): string {\n\tif (count >= 1_000_000) {\n\t\tconst millions = count / 1_000_000;\n\t\treturn millions % 1 === 0 ? `${millions}M` : `${millions.toFixed(1)}M`;\n\t}\n\tif (count >= 1_000) {\n\t\tconst thousands = count / 1_000;\n\t\treturn thousands % 1 === 0 ? `${thousands}K` : `${thousands.toFixed(1)}K`;\n\t}\n\treturn count.toString();\n}\n\n/**\n * List available models, optionally filtered by search pattern\n */\nexport async function listModels(modelRuntime: ModelRuntime, searchPattern?: string): Promise<void> {\n\tconst loadError = modelRuntime.getError();\n\tif (loadError) {\n\t\tconsole.error(chalk.yellow(`Warning: errors loading models.json:\\n${loadError}`));\n\t}\n\tconst catalogWarning = modelRuntime.getWarning();\n\tif (catalogWarning) {\n\t\tconsole.error(chalk.yellow(`Warning: ${catalogWarning}`));\n\t}\n\n\tconst models = modelRuntime.getAvailableSnapshot();\n\n\tif (models.length === 0) {\n\t\tconsole.log(formatNoModelsAvailableMessage());\n\t\treturn;\n\t}\n\n\t// Apply fuzzy filter if search pattern provided\n\tlet filteredModels: Model<Api>[] = [...models];\n\tif (searchPattern) {\n\t\tfilteredModels = fuzzyFilter([...models], searchPattern, (m) => `${m.provider} ${m.id}`);\n\t}\n\n\tif (filteredModels.length === 0) {\n\t\tconsole.log(`No models matching \"${searchPattern}\"`);\n\t\treturn;\n\t}\n\n\t// Sort by provider, then by model id\n\tfilteredModels.sort((a, b) => {\n\t\tconst providerCmp = a.provider.localeCompare(b.provider);\n\t\tif (providerCmp !== 0) return providerCmp;\n\t\treturn a.id.localeCompare(b.id);\n\t});\n\n\t// Calculate column widths\n\tconst rows = filteredModels.map((m) => ({\n\t\tprovider: m.provider,\n\t\tmodel: m.id,\n\t\tcontext: formatTokenCount(m.contextWindow),\n\t\tmaxOut: formatTokenCount(m.maxTokens),\n\t\tthinking: m.reasoning ? \"yes\" : \"no\",\n\t\timages: m.input.includes(\"image\") ? \"yes\" : \"no\",\n\t}));\n\n\tconst headers = {\n\t\tprovider: \"provider\",\n\t\tmodel: \"model\",\n\t\tcontext: \"context\",\n\t\tmaxOut: \"max-out\",\n\t\tthinking: \"thinking\",\n\t\timages: \"images\",\n\t};\n\n\tconst widths = {\n\t\tprovider: Math.max(headers.provider.length, ...rows.map((r) => r.provider.length)),\n\t\tmodel: Math.max(headers.model.length, ...rows.map((r) => r.model.length)),\n\t\tcontext: Math.max(headers.context.length, ...rows.map((r) => r.context.length)),\n\t\tmaxOut: Math.max(headers.maxOut.length, ...rows.map((r) => r.maxOut.length)),\n\t\tthinking: Math.max(headers.thinking.length, ...rows.map((r) => r.thinking.length)),\n\t\timages: Math.max(headers.images.length, ...rows.map((r) => r.images.length)),\n\t};\n\n\t// Print header\n\tconst headerLine = [\n\t\theaders.provider.padEnd(widths.provider),\n\t\theaders.model.padEnd(widths.model),\n\t\theaders.context.padEnd(widths.context),\n\t\theaders.maxOut.padEnd(widths.maxOut),\n\t\theaders.thinking.padEnd(widths.thinking),\n\t\theaders.images.padEnd(widths.images),\n\t].join(\" \");\n\tconsole.log(headerLine);\n\n\t// Print rows\n\tfor (const row of rows) {\n\t\tconst line = [\n\t\t\trow.provider.padEnd(widths.provider),\n\t\t\trow.model.padEnd(widths.model),\n\t\t\trow.context.padEnd(widths.context),\n\t\t\trow.maxOut.padEnd(widths.maxOut),\n\t\t\trow.thinking.padEnd(widths.thinking),\n\t\t\trow.images.padEnd(widths.images),\n\t\t].join(\" \");\n\t\tconsole.log(line);\n\t}\n}\n"]}
|
package/dist/client/index.d.ts
CHANGED
|
@@ -1,3 +1,2 @@
|
|
|
1
|
-
export
|
|
2
|
-
export { applyTranscriptProgress, applyTranscriptSnapshot, createTranscriptState, selectTranscript, type TranscriptState, } from "./transcript.ts";
|
|
1
|
+
export * from "@earendil-works/pi-client";
|
|
3
2
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/client/index.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/client/index.ts"],"names":[],"mappings":"AAAA,cAAc,2BAA2B,CAAC"}
|
package/dist/client/index.js
CHANGED
package/dist/client/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/client/index.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/client/index.ts"],"names":[],"mappings":"AAAA,cAAc,2BAA2B,CAAC","sourcesContent":["export * from \"@earendil-works/pi-client\";\n"]}
|
package/dist/config.d.ts
CHANGED
|
@@ -72,16 +72,7 @@ export declare const ENV_SHARE_VIEWER_URL: string;
|
|
|
72
72
|
export declare const ENV_CLEAR_ON_SHRINK: string;
|
|
73
73
|
export declare const ENV_HARDWARE_CURSOR: string;
|
|
74
74
|
export declare const ENV_TIMING: string;
|
|
75
|
-
export declare const ENV_CODEX_FAST_MODE: string;
|
|
76
75
|
export declare const WORKFLOW_STAGE_SUBAGENT_GUARD_ENV: string;
|
|
77
|
-
export interface CodexFastModeEnvironmentSettings {
|
|
78
|
-
chat?: boolean;
|
|
79
|
-
workflow?: boolean;
|
|
80
|
-
}
|
|
81
|
-
export declare function serializeCodexFastModeEnvironmentSettings(settings: Required<CodexFastModeEnvironmentSettings>): string;
|
|
82
|
-
export declare function parseCodexFastModeEnvironmentSettings(value: string | undefined): CodexFastModeEnvironmentSettings | undefined;
|
|
83
|
-
export declare function getCodexFastModeEnvironmentSettings(): CodexFastModeEnvironmentSettings | undefined;
|
|
84
|
-
export declare function setCodexFastModeEnvironmentSettings(settings: Required<CodexFastModeEnvironmentSettings>): void;
|
|
85
76
|
export declare function getEnvNames(name: string): string[];
|
|
86
77
|
export declare function getEnvValue(name: string): string | undefined;
|
|
87
78
|
export declare function hasEnvValue(name: string): boolean;
|
package/dist/config.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAuBA,eAAO,MAAM,WAAW,SAItB,CAAC;AAEH;;;;GAIG;AACH,eAAO,MAAM,cAAc,SAA2C,CAAC;AAEvE,gEAAgE;AAChE,eAAO,MAAM,YAAY,SAAyB,CAAC;AAcnD,YAAY,EAAE,aAAa,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAWlG,wBAAgB,mBAAmB,IAAI,OAAO,yBAAyB,EAAE,aAAa,CAErF;AAED,wBAAgB,oBAAoB,CACnC,WAAW,EAAE,MAAM,EACnB,UAAU,CAAC,EAAE,MAAM,EAAE,EACrB,YAAY,GAAE,OAAO,yBAAyB,EAAE,gBAA4D,GAC1G,OAAO,yBAAyB,EAAE,iBA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,MAAM,EAAE,GAAG,MAAM,EAAE,CAElF;AAED,2GAA2G;AAC3G,wBAAgB,oBAAoB,CAAC,GAAG,EAAE,MAAM,EAAE,QAAQ,GAAE,MAAsB,EAAE,cAAc,UAAO,GAAG,MAAM,EAAE,CAWnH;AAED,iDAAiD;AACjD,wBAAgB,kBAAkB,IAAI,MAAM,CAE3C;AAED,8BAA8B;AAC9B,wBAAgB,aAAa,IAAI,MAAM,CAEtC;AAED,4BAA4B;AAC5B,wBAAgB,WAAW,IAAI,MAAM,CAEpC;AAED,gCAAgC;AAChC,wBAAgB,eAAe,IAAI,MAAM,CAExC;AAED,kCAAkC;AAClC,wBAAgB,WAAW,IAAI,MAAM,CAEpC;AAED,sDAAsD;AACtD,wBAAgB,SAAS,IAAI,MAAM,CAElC;AAED;;;GAGG;AACH,wBAAgB,6BAA6B,IAAI,MAAM,CAEtD;AAED,6CAA6C;AAC7C,wBAAgB,aAAa,IAAI,MAAM,CAEtC;AAED,qCAAqC;AACrC,wBAAgB,cAAc,IAAI,MAAM,CAEvC;AAED,iCAAiC;AACjC,wBAAgB,eAAe,IAAI,MAAM,CAExC"}
|
package/dist/config.js
CHANGED
|
@@ -197,52 +197,7 @@ export const ENV_SHARE_VIEWER_URL = `${ENV_PREFIX}_SHARE_VIEWER_URL`;
|
|
|
197
197
|
export const ENV_CLEAR_ON_SHRINK = `${ENV_PREFIX}_CLEAR_ON_SHRINK`;
|
|
198
198
|
export const ENV_HARDWARE_CURSOR = `${ENV_PREFIX}_HARDWARE_CURSOR`;
|
|
199
199
|
export const ENV_TIMING = `${ENV_PREFIX}_TIMING`;
|
|
200
|
-
export const ENV_CODEX_FAST_MODE = `${ENV_PREFIX}_CODEX_FAST_MODE`;
|
|
201
200
|
export const WORKFLOW_STAGE_SUBAGENT_GUARD_ENV = `${ENV_PREFIX}_WORKFLOW_STAGE_SUBAGENT_GUARD`;
|
|
202
|
-
function parseCodexFastModeEnvBoolean(value) {
|
|
203
|
-
switch (value?.trim().toLowerCase()) {
|
|
204
|
-
case "1":
|
|
205
|
-
case "true":
|
|
206
|
-
case "enabled":
|
|
207
|
-
case "on":
|
|
208
|
-
return true;
|
|
209
|
-
case "0":
|
|
210
|
-
case "false":
|
|
211
|
-
case "disabled":
|
|
212
|
-
case "off":
|
|
213
|
-
return false;
|
|
214
|
-
default:
|
|
215
|
-
return undefined;
|
|
216
|
-
}
|
|
217
|
-
}
|
|
218
|
-
export function serializeCodexFastModeEnvironmentSettings(settings) {
|
|
219
|
-
return `chat=${settings.chat ? "1" : "0"};workflow=${settings.workflow ? "1" : "0"}`;
|
|
220
|
-
}
|
|
221
|
-
export function parseCodexFastModeEnvironmentSettings(value) {
|
|
222
|
-
if (!value)
|
|
223
|
-
return undefined;
|
|
224
|
-
const settings = {};
|
|
225
|
-
for (const part of value.split(/[;,]/)) {
|
|
226
|
-
const separatorIndex = part.indexOf("=");
|
|
227
|
-
if (separatorIndex === -1)
|
|
228
|
-
continue;
|
|
229
|
-
const key = part.slice(0, separatorIndex).trim();
|
|
230
|
-
const parsedValue = parseCodexFastModeEnvBoolean(part.slice(separatorIndex + 1));
|
|
231
|
-
if (parsedValue === undefined)
|
|
232
|
-
continue;
|
|
233
|
-
if (key === "chat")
|
|
234
|
-
settings.chat = parsedValue;
|
|
235
|
-
if (key === "workflow")
|
|
236
|
-
settings.workflow = parsedValue;
|
|
237
|
-
}
|
|
238
|
-
return settings.chat !== undefined || settings.workflow !== undefined ? settings : undefined;
|
|
239
|
-
}
|
|
240
|
-
export function getCodexFastModeEnvironmentSettings() {
|
|
241
|
-
return parseCodexFastModeEnvironmentSettings(getEnvValue(ENV_CODEX_FAST_MODE));
|
|
242
|
-
}
|
|
243
|
-
export function setCodexFastModeEnvironmentSettings(settings) {
|
|
244
|
-
setEnvValue(ENV_CODEX_FAST_MODE, serializeCodexFastModeEnvironmentSettings(settings));
|
|
245
|
-
}
|
|
246
201
|
export function getEnvNames(name) {
|
|
247
202
|
if (ENV_PREFIX === LEGACY_ENV_PREFIX || !name.startsWith(`${ENV_PREFIX}_`))
|
|
248
203
|
return [name];
|
package/dist/config.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,IAAI,CAAC;AAC9C,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AAC9C,OAAO,EAAE,qBAAqB,EAAE,MAAM,8BAA8B,CAAC;AACrE,OAAO,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAC7D,OAAO,EAAE,sBAAsB,EAAE,qBAAqB,EAAE,MAAM,2BAA2B,CAAC;AAC1F,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAE3C,gFAAgF;AAChF,oBAAoB;AACpB,gFAAgF;AAEhF,MAAM,UAAU,GAAG,qBAAqB,CAAC,OAAO,IAAI,CAAC,GAAG,EAAE,QAAQ,CAAC,CAAC;AACpE,MAAM,SAAS,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC;AAEtC;;;;GAIG;AACH,MAAM,YAAY,GAAG,CAAC,QAAQ,EAAE,MAAM,EAAE,QAAQ,CAAC,CAAC;AAClD,+EAA+E;AAC/E,8EAA8E;AAC9E,wCAAwC;AACxC,MAAM,CAAC,MAAM,WAAW,GACvB,sBAAsB,EAAE;IACxB,CAAC,OAAO,IAAI,CAAC,GAAG,EAAE,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,SAAS,EAAE,EAAE,CAC3D,YAAY,CAAC,IAAI,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,SAAS,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,CACzD,CAAC;AAEH;;;;GAIG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,OAAO,CAAC,GAA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,IAAI,CAAC,WAAW,EAAE,EAAE,OAAO,CAAC,CAAC;AACrC,CAAC;AAED,sDAAsD;AACtD,MAAM,UAAU,SAAS;IACxB,OAAO,IAAI,CAAC,WAAW,EAAE,EAAE,KAAK,CAAC,CAAC;AACnC,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,6BAA6B;IAC5C,OAAO,IAAI,CAAC,WAAW,EAAE,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC;AACtD,CAAC;AAED,6CAA6C;AAC7C,MAAM,UAAU,aAAa;IAC5B,OAAO,IAAI,CAAC,WAAW,EAAE,EAAE,SAAS,CAAC,CAAC;AACvC,CAAC;AAED,qCAAqC;AACrC,MAAM,UAAU,cAAc;IAC7B,OAAO,IAAI,CAAC,WAAW,EAAE,EAAE,UAAU,CAAC,CAAC;AACxC,CAAC;AAED,iCAAiC;AACjC,MAAM,UAAU,eAAe;IAC9B,OAAO,IAAI,CAAC,WAAW,EAAE,EAAE,GAAG,QAAQ,YAAY,CAAC,CAAC;AACrD,CAAC","sourcesContent":["import { existsSync, readFileSync } from \"fs\";\nimport { dirname, join, resolve } from \"path\";\nimport { resolvePackageDirFrom } from \"./config-package-identity.ts\";\nimport { getHomeDir, normalizePath } from \"./utils/paths.ts\";\nimport { isSplitLauncherRuntime, moduleFileFromMetaUrl } from \"./utils/split-launcher.ts\";\nimport { stripBom } from \"./utils/text.ts\";\n\n// =============================================================================\n// Package Detection\n// =============================================================================\n\nconst __filename = moduleFileFromMetaUrl(import.meta.url, \"app.js\");\nconst __dirname = dirname(__filename);\n\n/**\n * Detect if we're running as a Bun compiled binary.\n * Bun binaries have import.meta.url containing \"$bunfs\", \"~BUN\", or \"%7EBUN\" (Bun's virtual filesystem path).\n * Split Windows/macOS/Linux release launchers also set ATOMIC_CODING_AGENT before importing the sidecar app bundle.\n */\nconst bunFsMarkers = [\"$bunfs\", \"~BUN\", \"%7EBUN\"];\n// Check process.argv[1] as well as import.meta.url: in a CJS (bytecode) bundle\n// import.meta.url is rewritten to the original source path, but argv[1] still\n// points into Bun's virtual filesystem.\nexport const isBunBinary =\n\tisSplitLauncherRuntime() ||\n\t[import.meta.url, process.argv[1] ?? \"\"].some((candidate) =>\n\t\tbunFsMarkers.some((marker) => candidate.includes(marker)),\n\t);\n\n/**\n * Detect if we're running from a single-file bundle produced by `bun run bundle:dev`.\n * The bundle build inlines this env var via `--define`, so it is a compile-time\n * constant there and undefined everywhere else.\n */\nexport const isBundledBuild = process.env.ATOMIC_BUNDLED_BUILD === \"1\";\n\n/** Detect if Bun is the runtime (compiled binary or bun run) */\nexport const isBunRuntime = !!process.versions.bun;\n\n// =============================================================================\n// Install Method Detection\n// =============================================================================\n\nimport {\n\tdetectInstallMethodForRuntime,\n\tgetSelfUpdateCommandForRuntime,\n\tgetSelfUpdateUnavailableInstructionForRuntime,\n\tgetUpdateInstructionForRuntime,\n\ttype SelfUpdateRuntime,\n} from \"./config-self-update.ts\";\n\nexport type { InstallMethod, SelfUpdateCommand, SelfUpdateTarget } from \"./config-self-update.ts\";\n\nfunction selfUpdateRuntime(): SelfUpdateRuntime {\n\treturn {\n\t\tisBunBinary,\n\t\tisBunRuntime,\n\t\tmoduleDir: __dirname,\n\t\tgetPackageDir,\n\t};\n}\n\nexport function detectInstallMethod(): import(\"./config-self-update.ts\").InstallMethod {\n\treturn detectInstallMethodForRuntime(selfUpdateRuntime());\n}\n\nexport function getSelfUpdateCommand(\n\tpackageName: string,\n\tnpmCommand?: string[],\n\tupdateTarget: import(\"./config-self-update.ts\").SelfUpdateTarget = { packageName, installSpec: packageName },\n): import(\"./config-self-update.ts\").SelfUpdateCommand | undefined {\n\treturn getSelfUpdateCommandForRuntime(selfUpdateRuntime(), packageName, npmCommand, updateTarget);\n}\n\nexport function getSelfUpdateUnavailableInstruction(\n\tpackageName: string,\n\tnpmCommand?: string[],\n\tupdateTarget: import(\"./config-self-update.ts\").SelfUpdateTarget = { packageName, installSpec: packageName },\n): string {\n\treturn getSelfUpdateUnavailableInstructionForRuntime(selfUpdateRuntime(), packageName, npmCommand, updateTarget);\n}\n\nexport function getUpdateInstruction(packageName: string): string {\n\treturn getUpdateInstructionForRuntime(selfUpdateRuntime(), packageName);\n}\n\n// =============================================================================\n// Package Asset Paths (shipped with executable)\n// =============================================================================\n\n/**\n * Get the base directory for resolving package assets (themes, package.json, README.md, CHANGELOG.md).\n * - For Bun binary: returns the directory containing the executable\n * - For Node.js (dist/): returns __dirname (the dist/ directory)\n * - For tsx (src/): returns parent directory (the package root)\n */\nexport function getPackageDir(): string {\n\t// Allow override via environment variable (useful for Nix/Guix where store paths tokenize poorly).\n\t// This runs before package.json app config is read, so the env var name is hardcoded.\n\tconst envDir = process.env.ATOMIC_PACKAGE_DIR ?? process.env.PI_PACKAGE_DIR;\n\tif (envDir) {\n\t\treturn normalizePath(envDir);\n\t}\n\n\tif (isBunBinary) {\n\t\t// Bun binary: process.execPath points to the compiled executable\n\t\treturn dirname(process.execPath);\n\t}\n\t// Node.js: walk up from __dirname to the Atomic app package. Prebundled\n\t// companion extensions ship under dist/builtin/<name>/ with their own\n\t// package.json; stopping at the first one made APP_NAME \"workflows\".\n\treturn resolvePackageDirFrom(__dirname);\n}\n\n/**\n * Resolve the root that contains source-layout assets for non-binary runtimes.\n * Ordinary source and compiled modules already live in src/ or dist/, so use\n * their module directory directly. Bundled development builds and explicit\n * package-directory overrides instead need to select a package-root layout.\n */\nfunction getModuleAssetRoot(): string {\n\tconst hasPackageDirOverride = !!(process.env.ATOMIC_PACKAGE_DIR || process.env.PI_PACKAGE_DIR);\n\tif (!isBundledBuild && !hasPackageDirOverride) {\n\t\treturn __dirname;\n\t}\n\tconst packageDir = getPackageDir();\n\treturn join(packageDir, existsSync(join(packageDir, \"src\")) ? \"src\" : \"dist\");\n}\n\n/**\n * Get path to built-in themes directory (shipped with package)\n * - For Bun binary: theme/ next to executable\n * - For Node.js (dist/): dist/modes/interactive/theme/\n * - For tsx (src/): src/modes/interactive/theme/\n */\nexport function getThemesDir(): string {\n\tif (isBunBinary) {\n\t\treturn join(getPackageDir(), \"theme\");\n\t}\n\treturn join(getModuleAssetRoot(), \"modes\", \"interactive\", \"theme\");\n}\n\n/**\n * Get path to HTML export template directory (shipped with package)\n * - For Bun binary: export-html/ next to executable\n * - For Node.js (dist/): dist/core/export-html/\n * - For tsx (src/): src/core/export-html/\n */\nexport function getExportTemplateDir(): string {\n\tif (isBunBinary) {\n\t\treturn join(getPackageDir(), \"export-html\");\n\t}\n\treturn join(getModuleAssetRoot(), \"core\", \"export-html\");\n}\n\n/** Get path to package.json */\nexport function getPackageJsonPath(): string {\n\treturn join(getPackageDir(), \"package.json\");\n}\n\n/** Get path to README.md */\nexport function getReadmePath(): string {\n\treturn resolve(join(getPackageDir(), \"README.md\"));\n}\n\n/** Get path to docs directory */\nexport function getDocsPath(): string {\n\treturn resolve(join(getPackageDir(), \"docs\"));\n}\n\n/** Get path to examples directory */\nexport function getExamplesPath(): string {\n\treturn resolve(join(getPackageDir(), \"examples\"));\n}\n\n/** Get path to CHANGELOG.md */\nexport function getChangelogPath(): string {\n\treturn resolve(join(getPackageDir(), \"CHANGELOG.md\"));\n}\n\n/**\n * Get path to built-in interactive assets directory.\n * - For Bun binary: assets/ next to executable\n * - For Node.js (dist/): dist/modes/interactive/assets/\n * - For tsx (src/): src/modes/interactive/assets/\n */\nexport function getInteractiveAssetsDir(): string {\n\tif (isBunBinary) {\n\t\treturn join(getPackageDir(), \"assets\");\n\t}\n\treturn join(getModuleAssetRoot(), \"modes\", \"interactive\", \"assets\");\n}\n\n/** Get path to a bundled interactive asset */\nexport function getBundledInteractiveAssetPath(name: string): string {\n\treturn join(getInteractiveAssetsDir(), name);\n}\n\n// =============================================================================\n// App Config (from package.json <appName>Config, with piConfig as a legacy shim)\n// =============================================================================\n\ninterface AppConfig {\n\tname?: string;\n\tconfigDir?: string;\n\tchangelogUrl?: string;\n}\n\ninterface PackageJson extends Record<string, unknown> {\n\tname?: string;\n\tversion?: string;\n\tpiConfig?: AppConfig;\n}\n\nlet pkg: PackageJson = {};\ntry {\n\tpkg = JSON.parse(stripBom(readFileSync(getPackageJsonPath(), \"utf-8\"))) as PackageJson;\n} catch (e: unknown) {\n\tconst err = e as NodeJS.ErrnoException;\n\tif (err.code !== \"ENOENT\") throw e;\n}\n\nfunction appNameFromPackageName(packageName: string | undefined): string | undefined {\n\tconst localName = packageName?.split(\"/\").pop()?.trim();\n\treturn localName && localName.length > 0 ? localName : undefined;\n}\n\nfunction readAppConfig(packageJson: PackageJson, appName: string | undefined): AppConfig | undefined {\n\tif (appName) {\n\t\tconst appConfig = packageJson[`${appName}Config`];\n\t\tif (appConfig && typeof appConfig === \"object\" && !Array.isArray(appConfig)) {\n\t\t\treturn appConfig as AppConfig;\n\t\t}\n\t}\n\treturn packageJson.piConfig;\n}\n\nexport const PACKAGE_NAME: string = pkg.name || \"@bastani/atomic\";\nconst packageAppName = appNameFromPackageName(PACKAGE_NAME);\nconst appConfig = readAppConfig(pkg, packageAppName);\nexport const APP_NAME: string = appConfig?.name || packageAppName || \"pi\";\nexport const APP_TITLE: string = appConfig?.name !== undefined || APP_NAME !== \"pi\" ? APP_NAME : \"π\";\nexport const CONFIG_DIR_NAME: string = appConfig?.configDir || (APP_NAME === \"pi\" ? \".pi\" : `.${APP_NAME}`);\nexport const LEGACY_CONFIG_DIR_NAME = \".pi\";\nexport const CONFIG_DIR_NAMES: readonly string[] =\n\tCONFIG_DIR_NAME === LEGACY_CONFIG_DIR_NAME ? [CONFIG_DIR_NAME] : [CONFIG_DIR_NAME, LEGACY_CONFIG_DIR_NAME];\nexport const VERSION: string = pkg.version || \"0.0.0\";\nexport const CHANGELOG_URL: string | undefined = appConfig?.changelogUrl?.trim() || undefined;\n\nconst ENV_PREFIX = APP_NAME.toUpperCase();\nexport const LEGACY_ENV_PREFIX = \"PI\";\n\n// e.g., ATOMIC_CODING_AGENT_DIR (with PI_CODING_AGENT_DIR as a compatibility alias)\nexport const ENV_AGENT_DIR = `${ENV_PREFIX}_CODING_AGENT_DIR`;\nexport const ENV_SESSION_DIR = `${ENV_PREFIX}_CODING_AGENT_SESSION_DIR`;\nexport const ENV_PACKAGE_DIR = `${ENV_PREFIX}_PACKAGE_DIR`;\nexport const ENV_OFFLINE = `${ENV_PREFIX}_OFFLINE`;\nexport const ENV_SKIP_VERSION_CHECK = `${ENV_PREFIX}_SKIP_VERSION_CHECK`;\nexport const ENV_STARTUP_BENCHMARK = `${ENV_PREFIX}_STARTUP_BENCHMARK`;\nexport const ENV_TELEMETRY = `${ENV_PREFIX}_TELEMETRY`;\nexport const ENV_SHARE_VIEWER_URL = `${ENV_PREFIX}_SHARE_VIEWER_URL`;\nexport const ENV_CLEAR_ON_SHRINK = `${ENV_PREFIX}_CLEAR_ON_SHRINK`;\nexport const ENV_HARDWARE_CURSOR = `${ENV_PREFIX}_HARDWARE_CURSOR`;\nexport const ENV_TIMING = `${ENV_PREFIX}_TIMING`;\nexport const ENV_CODEX_FAST_MODE = `${ENV_PREFIX}_CODEX_FAST_MODE`;\nexport const WORKFLOW_STAGE_SUBAGENT_GUARD_ENV = `${ENV_PREFIX}_WORKFLOW_STAGE_SUBAGENT_GUARD`;\n\nexport interface CodexFastModeEnvironmentSettings {\n\tchat?: boolean;\n\tworkflow?: boolean;\n}\n\nfunction parseCodexFastModeEnvBoolean(value: string | undefined): boolean | undefined {\n\tswitch (value?.trim().toLowerCase()) {\n\t\tcase \"1\":\n\t\tcase \"true\":\n\t\tcase \"enabled\":\n\t\tcase \"on\":\n\t\t\treturn true;\n\t\tcase \"0\":\n\t\tcase \"false\":\n\t\tcase \"disabled\":\n\t\tcase \"off\":\n\t\t\treturn false;\n\t\tdefault:\n\t\t\treturn undefined;\n\t}\n}\n\nexport function serializeCodexFastModeEnvironmentSettings(\n\tsettings: Required<CodexFastModeEnvironmentSettings>,\n): string {\n\treturn `chat=${settings.chat ? \"1\" : \"0\"};workflow=${settings.workflow ? \"1\" : \"0\"}`;\n}\n\nexport function parseCodexFastModeEnvironmentSettings(\n\tvalue: string | undefined,\n): CodexFastModeEnvironmentSettings | undefined {\n\tif (!value) return undefined;\n\tconst settings: CodexFastModeEnvironmentSettings = {};\n\tfor (const part of value.split(/[;,]/)) {\n\t\tconst separatorIndex = part.indexOf(\"=\");\n\t\tif (separatorIndex === -1) continue;\n\t\tconst key = part.slice(0, separatorIndex).trim();\n\t\tconst parsedValue = parseCodexFastModeEnvBoolean(part.slice(separatorIndex + 1));\n\t\tif (parsedValue === undefined) continue;\n\t\tif (key === \"chat\") settings.chat = parsedValue;\n\t\tif (key === \"workflow\") settings.workflow = parsedValue;\n\t}\n\treturn settings.chat !== undefined || settings.workflow !== undefined ? settings : undefined;\n}\n\nexport function getCodexFastModeEnvironmentSettings(): CodexFastModeEnvironmentSettings | undefined {\n\treturn parseCodexFastModeEnvironmentSettings(getEnvValue(ENV_CODEX_FAST_MODE));\n}\n\nexport function setCodexFastModeEnvironmentSettings(settings: Required<CodexFastModeEnvironmentSettings>): void {\n\tsetEnvValue(ENV_CODEX_FAST_MODE, serializeCodexFastModeEnvironmentSettings(settings));\n}\n\nexport function getEnvNames(name: string): string[] {\n\tif (ENV_PREFIX === LEGACY_ENV_PREFIX || !name.startsWith(`${ENV_PREFIX}_`)) return [name];\n\treturn [name, `${LEGACY_ENV_PREFIX}_${name.slice(ENV_PREFIX.length + 1)}`];\n}\n\nexport function getEnvValue(name: string): string | undefined {\n\tfor (const candidate of getEnvNames(name)) {\n\t\tconst value = process.env[candidate];\n\t\tif (value !== undefined) return value;\n\t}\n\treturn undefined;\n}\n\nexport function hasEnvValue(name: string): boolean {\n\treturn getEnvValue(name) !== undefined;\n}\n\nexport function setEnvValue(name: string, value: string): void {\n\tprocess.env[name] = value;\n}\n\nexport function expandTildePath(path: string): string {\n\treturn normalizePath(path);\n}\n\nconst DEFAULT_SHARE_VIEWER_URL = \"https://pi.dev/session/\";\n\n/** Get the share viewer URL for a gist ID */\nexport function getShareViewerUrl(gistId: string): string {\n\tconst baseUrl = getEnvValue(ENV_SHARE_VIEWER_URL) || DEFAULT_SHARE_VIEWER_URL;\n\treturn `${baseUrl}#${gistId}`;\n}\n\n// =============================================================================\n// User Config Paths (~/.atomic/agent/*)\n// =============================================================================\n\n/** Get the agent config directory (e.g., ~/.atomic/agent/) */\nexport function getAgentDir(): string {\n\tconst envDir = getEnvValue(ENV_AGENT_DIR);\n\tif (envDir) {\n\t\treturn expandTildePath(envDir);\n\t}\n\treturn join(getHomeDir(), CONFIG_DIR_NAME, \"agent\");\n}\n\n/** Get the legacy pi agent config directory (e.g., ~/.pi/agent/) */\nexport function getLegacyAgentDir(): string {\n\treturn join(getHomeDir(), LEGACY_CONFIG_DIR_NAME, \"agent\");\n}\n\n/** Get agent config directories in precedence order (primary first, then legacy). */\nexport function getAgentDirs(): string[] {\n\tconst primary = getAgentDir();\n\tif (hasEnvValue(ENV_AGENT_DIR) || CONFIG_DIR_NAME === LEGACY_CONFIG_DIR_NAME) {\n\t\treturn [primary];\n\t}\n\tconst legacy = getLegacyAgentDir();\n\treturn legacy === primary ? [primary] : [primary, legacy];\n}\n\n/** Get user config root directories in precedence order (primary first, then legacy). */\nexport function getUserConfigDirs(): string[] {\n\treturn CONFIG_DIR_NAMES.map((name) => join(getHomeDir(), name));\n}\n\n/** Get project config directories in precedence order (primary first, then legacy). */\nexport function getProjectConfigDirs(cwd: string): string[] {\n\treturn CONFIG_DIR_NAMES.map((name) => join(cwd, name));\n}\n\n/** Get a path inside every user config root directory. */\nexport function getUserConfigPaths(...segments: string[]): string[] {\n\treturn getUserConfigDirs().map((dir) => join(dir, ...segments));\n}\n\n/** Get a path inside every agent config directory. */\nexport function getAgentConfigPaths(...segments: string[]): string[] {\n\treturn getAgentDirs().map((dir) => join(dir, ...segments));\n}\n\n/** Get a path inside every project config directory. */\nexport function getProjectConfigPaths(cwd: string, ...segments: string[]): string[] {\n\treturn getProjectConfigDirs(cwd).map((dir) => join(dir, ...segments));\n}\n\n/** Model config paths from highest to lowest precedence: Atomic project/global, then Pi project/global. */\nexport function getModelsConfigPaths(cwd: string, agentDir: string = getAgentDir(), includeProject = true): string[] {\n\tconst globalPaths =\n\t\tagentDir === getAgentDir() ? getAgentConfigPaths(\"models.json\") : [join(agentDir, \"models.json\")];\n\tif (!includeProject) return globalPaths;\n\tconst projectPaths = getProjectConfigPaths(cwd, \"models.json\");\n\tconst paths: string[] = [];\n\tfor (let index = 0; index < Math.max(projectPaths.length, globalPaths.length); index++) {\n\t\tif (projectPaths[index]) paths.push(projectPaths[index]);\n\t\tif (globalPaths[index]) paths.push(globalPaths[index]);\n\t}\n\treturn [...new Set(paths)];\n}\n\n/** Get path to user's custom themes directory */\nexport function getCustomThemesDir(): string {\n\treturn join(getAgentDir(), \"themes\");\n}\n\n/** Get path to models.json */\nexport function getModelsPath(): string {\n\treturn join(getAgentDir(), \"models.json\");\n}\n\n/** Get path to auth.json */\nexport function getAuthPath(): string {\n\treturn join(getAgentDir(), \"auth.json\");\n}\n\n/** Get path to settings.json */\nexport function getSettingsPath(): string {\n\treturn join(getAgentDir(), \"settings.json\");\n}\n\n/** Get path to tools directory */\nexport function getToolsDir(): string {\n\treturn join(getAgentDir(), \"tools\");\n}\n\n/** Get path to managed binaries directory (fd, rg) */\nexport function getBinDir(): string {\n\treturn join(getAgentDir(), \"bin\");\n}\n\n/**\n * Get path to the extension transpile cache directory (jiti fsCache).\n * Scoped by version so release upgrades never read stale transpiled output.\n */\nexport function getExtensionTranspileCacheDir(): string {\n\treturn join(getAgentDir(), \"cache\", \"jiti\", VERSION);\n}\n\n/** Get path to prompt templates directory */\nexport function getPromptsDir(): string {\n\treturn join(getAgentDir(), \"prompts\");\n}\n\n/** Get path to sessions directory */\nexport function getSessionsDir(): string {\n\treturn join(getAgentDir(), \"sessions\");\n}\n\n/** Get path to debug log file */\nexport function getDebugLogPath(): string {\n\treturn join(getAgentDir(), `${APP_NAME}-debug.log`);\n}\n"]}
|
|
1
|
+
{"version":3,"file":"config.js","sourceRoot":"","sources":["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["import { existsSync, readFileSync } from \"fs\";\nimport { dirname, join, resolve } from \"path\";\nimport { resolvePackageDirFrom } from \"./config-package-identity.ts\";\nimport { getHomeDir, normalizePath } from \"./utils/paths.ts\";\nimport { isSplitLauncherRuntime, moduleFileFromMetaUrl } from \"./utils/split-launcher.ts\";\nimport { stripBom } from \"./utils/text.ts\";\n\n// =============================================================================\n// Package Detection\n// =============================================================================\n\nconst __filename = moduleFileFromMetaUrl(import.meta.url, \"app.js\");\nconst __dirname = dirname(__filename);\n\n/**\n * Detect if we're running as a Bun compiled binary.\n * Bun binaries have import.meta.url containing \"$bunfs\", \"~BUN\", or \"%7EBUN\" (Bun's virtual filesystem path).\n * Split Windows/macOS/Linux release launchers also set ATOMIC_CODING_AGENT before importing the sidecar app bundle.\n */\nconst bunFsMarkers = [\"$bunfs\", \"~BUN\", \"%7EBUN\"];\n// Check process.argv[1] as well as import.meta.url: in a CJS (bytecode) bundle\n// import.meta.url is rewritten to the original source path, but argv[1] still\n// points into Bun's virtual filesystem.\nexport const isBunBinary =\n\tisSplitLauncherRuntime() ||\n\t[import.meta.url, process.argv[1] ?? \"\"].some((candidate) =>\n\t\tbunFsMarkers.some((marker) => candidate.includes(marker)),\n\t);\n\n/**\n * Detect if we're running from a single-file bundle produced by `bun run bundle:dev`.\n * The bundle build inlines this env var via `--define`, so it is a compile-time\n * constant there and undefined everywhere else.\n */\nexport const isBundledBuild = process.env.ATOMIC_BUNDLED_BUILD === \"1\";\n\n/** Detect if Bun is the runtime (compiled binary or bun run) */\nexport const isBunRuntime = !!process.versions.bun;\n\n// =============================================================================\n// Install Method Detection\n// =============================================================================\n\nimport {\n\tdetectInstallMethodForRuntime,\n\tgetSelfUpdateCommandForRuntime,\n\tgetSelfUpdateUnavailableInstructionForRuntime,\n\tgetUpdateInstructionForRuntime,\n\ttype SelfUpdateRuntime,\n} from \"./config-self-update.ts\";\n\nexport type { InstallMethod, SelfUpdateCommand, SelfUpdateTarget } from \"./config-self-update.ts\";\n\nfunction selfUpdateRuntime(): SelfUpdateRuntime {\n\treturn {\n\t\tisBunBinary,\n\t\tisBunRuntime,\n\t\tmoduleDir: __dirname,\n\t\tgetPackageDir,\n\t};\n}\n\nexport function detectInstallMethod(): import(\"./config-self-update.ts\").InstallMethod {\n\treturn detectInstallMethodForRuntime(selfUpdateRuntime());\n}\n\nexport function getSelfUpdateCommand(\n\tpackageName: string,\n\tnpmCommand?: string[],\n\tupdateTarget: import(\"./config-self-update.ts\").SelfUpdateTarget = { packageName, installSpec: packageName },\n): import(\"./config-self-update.ts\").SelfUpdateCommand | undefined {\n\treturn getSelfUpdateCommandForRuntime(selfUpdateRuntime(), packageName, npmCommand, updateTarget);\n}\n\nexport function getSelfUpdateUnavailableInstruction(\n\tpackageName: string,\n\tnpmCommand?: string[],\n\tupdateTarget: import(\"./config-self-update.ts\").SelfUpdateTarget = { packageName, installSpec: packageName },\n): string {\n\treturn getSelfUpdateUnavailableInstructionForRuntime(selfUpdateRuntime(), packageName, npmCommand, updateTarget);\n}\n\nexport function getUpdateInstruction(packageName: string): string {\n\treturn getUpdateInstructionForRuntime(selfUpdateRuntime(), packageName);\n}\n\n// =============================================================================\n// Package Asset Paths (shipped with executable)\n// =============================================================================\n\n/**\n * Get the base directory for resolving package assets (themes, package.json, README.md, CHANGELOG.md).\n * - For Bun binary: returns the directory containing the executable\n * - For Node.js (dist/): returns __dirname (the dist/ directory)\n * - For tsx (src/): returns parent directory (the package root)\n */\nexport function getPackageDir(): string {\n\t// Allow override via environment variable (useful for Nix/Guix where store paths tokenize poorly).\n\t// This runs before package.json app config is read, so the env var name is hardcoded.\n\tconst envDir = process.env.ATOMIC_PACKAGE_DIR ?? process.env.PI_PACKAGE_DIR;\n\tif (envDir) {\n\t\treturn normalizePath(envDir);\n\t}\n\n\tif (isBunBinary) {\n\t\t// Bun binary: process.execPath points to the compiled executable\n\t\treturn dirname(process.execPath);\n\t}\n\t// Node.js: walk up from __dirname to the Atomic app package. Prebundled\n\t// companion extensions ship under dist/builtin/<name>/ with their own\n\t// package.json; stopping at the first one made APP_NAME \"workflows\".\n\treturn resolvePackageDirFrom(__dirname);\n}\n\n/**\n * Resolve the root that contains source-layout assets for non-binary runtimes.\n * Ordinary source and compiled modules already live in src/ or dist/, so use\n * their module directory directly. Bundled development builds and explicit\n * package-directory overrides instead need to select a package-root layout.\n */\nfunction getModuleAssetRoot(): string {\n\tconst hasPackageDirOverride = !!(process.env.ATOMIC_PACKAGE_DIR || process.env.PI_PACKAGE_DIR);\n\tif (!isBundledBuild && !hasPackageDirOverride) {\n\t\treturn __dirname;\n\t}\n\tconst packageDir = getPackageDir();\n\treturn join(packageDir, existsSync(join(packageDir, \"src\")) ? \"src\" : \"dist\");\n}\n\n/**\n * Get path to built-in themes directory (shipped with package)\n * - For Bun binary: theme/ next to executable\n * - For Node.js (dist/): dist/modes/interactive/theme/\n * - For tsx (src/): src/modes/interactive/theme/\n */\nexport function getThemesDir(): string {\n\tif (isBunBinary) {\n\t\treturn join(getPackageDir(), \"theme\");\n\t}\n\treturn join(getModuleAssetRoot(), \"modes\", \"interactive\", \"theme\");\n}\n\n/**\n * Get path to HTML export template directory (shipped with package)\n * - For Bun binary: export-html/ next to executable\n * - For Node.js (dist/): dist/core/export-html/\n * - For tsx (src/): src/core/export-html/\n */\nexport function getExportTemplateDir(): string {\n\tif (isBunBinary) {\n\t\treturn join(getPackageDir(), \"export-html\");\n\t}\n\treturn join(getModuleAssetRoot(), \"core\", \"export-html\");\n}\n\n/** Get path to package.json */\nexport function getPackageJsonPath(): string {\n\treturn join(getPackageDir(), \"package.json\");\n}\n\n/** Get path to README.md */\nexport function getReadmePath(): string {\n\treturn resolve(join(getPackageDir(), \"README.md\"));\n}\n\n/** Get path to docs directory */\nexport function getDocsPath(): string {\n\treturn resolve(join(getPackageDir(), \"docs\"));\n}\n\n/** Get path to examples directory */\nexport function getExamplesPath(): string {\n\treturn resolve(join(getPackageDir(), \"examples\"));\n}\n\n/** Get path to CHANGELOG.md */\nexport function getChangelogPath(): string {\n\treturn resolve(join(getPackageDir(), \"CHANGELOG.md\"));\n}\n\n/**\n * Get path to built-in interactive assets directory.\n * - For Bun binary: assets/ next to executable\n * - For Node.js (dist/): dist/modes/interactive/assets/\n * - For tsx (src/): src/modes/interactive/assets/\n */\nexport function getInteractiveAssetsDir(): string {\n\tif (isBunBinary) {\n\t\treturn join(getPackageDir(), \"assets\");\n\t}\n\treturn join(getModuleAssetRoot(), \"modes\", \"interactive\", \"assets\");\n}\n\n/** Get path to a bundled interactive asset */\nexport function getBundledInteractiveAssetPath(name: string): string {\n\treturn join(getInteractiveAssetsDir(), name);\n}\n\n// =============================================================================\n// App Config (from package.json <appName>Config, with piConfig as a legacy shim)\n// =============================================================================\n\ninterface AppConfig {\n\tname?: string;\n\tconfigDir?: string;\n\tchangelogUrl?: string;\n}\n\ninterface PackageJson extends Record<string, unknown> {\n\tname?: string;\n\tversion?: string;\n\tpiConfig?: AppConfig;\n}\n\nlet pkg: PackageJson = {};\ntry {\n\tpkg = JSON.parse(stripBom(readFileSync(getPackageJsonPath(), \"utf-8\"))) as PackageJson;\n} catch (e: unknown) {\n\tconst err = e as NodeJS.ErrnoException;\n\tif (err.code !== \"ENOENT\") throw e;\n}\n\nfunction appNameFromPackageName(packageName: string | undefined): string | undefined {\n\tconst localName = packageName?.split(\"/\").pop()?.trim();\n\treturn localName && localName.length > 0 ? localName : undefined;\n}\n\nfunction readAppConfig(packageJson: PackageJson, appName: string | undefined): AppConfig | undefined {\n\tif (appName) {\n\t\tconst appConfig = packageJson[`${appName}Config`];\n\t\tif (appConfig && typeof appConfig === \"object\" && !Array.isArray(appConfig)) {\n\t\t\treturn appConfig as AppConfig;\n\t\t}\n\t}\n\treturn packageJson.piConfig;\n}\n\nexport const PACKAGE_NAME: string = pkg.name || \"@bastani/atomic\";\nconst packageAppName = appNameFromPackageName(PACKAGE_NAME);\nconst appConfig = readAppConfig(pkg, packageAppName);\nexport const APP_NAME: string = appConfig?.name || packageAppName || \"pi\";\nexport const APP_TITLE: string = appConfig?.name !== undefined || APP_NAME !== \"pi\" ? APP_NAME : \"π\";\nexport const CONFIG_DIR_NAME: string = appConfig?.configDir || (APP_NAME === \"pi\" ? \".pi\" : `.${APP_NAME}`);\nexport const LEGACY_CONFIG_DIR_NAME = \".pi\";\nexport const CONFIG_DIR_NAMES: readonly string[] =\n\tCONFIG_DIR_NAME === LEGACY_CONFIG_DIR_NAME ? [CONFIG_DIR_NAME] : [CONFIG_DIR_NAME, LEGACY_CONFIG_DIR_NAME];\nexport const VERSION: string = pkg.version || \"0.0.0\";\nexport const CHANGELOG_URL: string | undefined = appConfig?.changelogUrl?.trim() || undefined;\n\nconst ENV_PREFIX = APP_NAME.toUpperCase();\nexport const LEGACY_ENV_PREFIX = \"PI\";\n\n// e.g., ATOMIC_CODING_AGENT_DIR (with PI_CODING_AGENT_DIR as a compatibility alias)\nexport const ENV_AGENT_DIR = `${ENV_PREFIX}_CODING_AGENT_DIR`;\nexport const ENV_SESSION_DIR = `${ENV_PREFIX}_CODING_AGENT_SESSION_DIR`;\nexport const ENV_PACKAGE_DIR = `${ENV_PREFIX}_PACKAGE_DIR`;\nexport const ENV_OFFLINE = `${ENV_PREFIX}_OFFLINE`;\nexport const ENV_SKIP_VERSION_CHECK = `${ENV_PREFIX}_SKIP_VERSION_CHECK`;\nexport const ENV_STARTUP_BENCHMARK = `${ENV_PREFIX}_STARTUP_BENCHMARK`;\nexport const ENV_TELEMETRY = `${ENV_PREFIX}_TELEMETRY`;\nexport const ENV_SHARE_VIEWER_URL = `${ENV_PREFIX}_SHARE_VIEWER_URL`;\nexport const ENV_CLEAR_ON_SHRINK = `${ENV_PREFIX}_CLEAR_ON_SHRINK`;\nexport const ENV_HARDWARE_CURSOR = `${ENV_PREFIX}_HARDWARE_CURSOR`;\nexport const ENV_TIMING = `${ENV_PREFIX}_TIMING`;\nexport const WORKFLOW_STAGE_SUBAGENT_GUARD_ENV = `${ENV_PREFIX}_WORKFLOW_STAGE_SUBAGENT_GUARD`;\nexport function getEnvNames(name: string): string[] {\n\tif (ENV_PREFIX === LEGACY_ENV_PREFIX || !name.startsWith(`${ENV_PREFIX}_`)) return [name];\n\treturn [name, `${LEGACY_ENV_PREFIX}_${name.slice(ENV_PREFIX.length + 1)}`];\n}\n\nexport function getEnvValue(name: string): string | undefined {\n\tfor (const candidate of getEnvNames(name)) {\n\t\tconst value = process.env[candidate];\n\t\tif (value !== undefined) return value;\n\t}\n\treturn undefined;\n}\n\nexport function hasEnvValue(name: string): boolean {\n\treturn getEnvValue(name) !== undefined;\n}\n\nexport function setEnvValue(name: string, value: string): void {\n\tprocess.env[name] = value;\n}\n\nexport function expandTildePath(path: string): string {\n\treturn normalizePath(path);\n}\n\nconst DEFAULT_SHARE_VIEWER_URL = \"https://pi.dev/session/\";\n\n/** Get the share viewer URL for a gist ID */\nexport function getShareViewerUrl(gistId: string): string {\n\tconst baseUrl = getEnvValue(ENV_SHARE_VIEWER_URL) || DEFAULT_SHARE_VIEWER_URL;\n\treturn `${baseUrl}#${gistId}`;\n}\n\n// =============================================================================\n// User Config Paths (~/.atomic/agent/*)\n// =============================================================================\n\n/** Get the agent config directory (e.g., ~/.atomic/agent/) */\nexport function getAgentDir(): string {\n\tconst envDir = getEnvValue(ENV_AGENT_DIR);\n\tif (envDir) {\n\t\treturn expandTildePath(envDir);\n\t}\n\treturn join(getHomeDir(), CONFIG_DIR_NAME, \"agent\");\n}\n\n/** Get the legacy pi agent config directory (e.g., ~/.pi/agent/) */\nexport function getLegacyAgentDir(): string {\n\treturn join(getHomeDir(), LEGACY_CONFIG_DIR_NAME, \"agent\");\n}\n\n/** Get agent config directories in precedence order (primary first, then legacy). */\nexport function getAgentDirs(): string[] {\n\tconst primary = getAgentDir();\n\tif (hasEnvValue(ENV_AGENT_DIR) || CONFIG_DIR_NAME === LEGACY_CONFIG_DIR_NAME) {\n\t\treturn [primary];\n\t}\n\tconst legacy = getLegacyAgentDir();\n\treturn legacy === primary ? [primary] : [primary, legacy];\n}\n\n/** Get user config root directories in precedence order (primary first, then legacy). */\nexport function getUserConfigDirs(): string[] {\n\treturn CONFIG_DIR_NAMES.map((name) => join(getHomeDir(), name));\n}\n\n/** Get project config directories in precedence order (primary first, then legacy). */\nexport function getProjectConfigDirs(cwd: string): string[] {\n\treturn CONFIG_DIR_NAMES.map((name) => join(cwd, name));\n}\n\n/** Get a path inside every user config root directory. */\nexport function getUserConfigPaths(...segments: string[]): string[] {\n\treturn getUserConfigDirs().map((dir) => join(dir, ...segments));\n}\n\n/** Get a path inside every agent config directory. */\nexport function getAgentConfigPaths(...segments: string[]): string[] {\n\treturn getAgentDirs().map((dir) => join(dir, ...segments));\n}\n\n/** Get a path inside every project config directory. */\nexport function getProjectConfigPaths(cwd: string, ...segments: string[]): string[] {\n\treturn getProjectConfigDirs(cwd).map((dir) => join(dir, ...segments));\n}\n\n/** Model config paths from highest to lowest precedence: Atomic project/global, then Pi project/global. */\nexport function getModelsConfigPaths(cwd: string, agentDir: string = getAgentDir(), includeProject = true): string[] {\n\tconst globalPaths =\n\t\tagentDir === getAgentDir() ? getAgentConfigPaths(\"models.json\") : [join(agentDir, \"models.json\")];\n\tif (!includeProject) return globalPaths;\n\tconst projectPaths = getProjectConfigPaths(cwd, \"models.json\");\n\tconst paths: string[] = [];\n\tfor (let index = 0; index < Math.max(projectPaths.length, globalPaths.length); index++) {\n\t\tif (projectPaths[index]) paths.push(projectPaths[index]);\n\t\tif (globalPaths[index]) paths.push(globalPaths[index]);\n\t}\n\treturn [...new Set(paths)];\n}\n\n/** Get path to user's custom themes directory */\nexport function getCustomThemesDir(): string {\n\treturn join(getAgentDir(), \"themes\");\n}\n\n/** Get path to models.json */\nexport function getModelsPath(): string {\n\treturn join(getAgentDir(), \"models.json\");\n}\n\n/** Get path to auth.json */\nexport function getAuthPath(): string {\n\treturn join(getAgentDir(), \"auth.json\");\n}\n\n/** Get path to settings.json */\nexport function getSettingsPath(): string {\n\treturn join(getAgentDir(), \"settings.json\");\n}\n\n/** Get path to tools directory */\nexport function getToolsDir(): string {\n\treturn join(getAgentDir(), \"tools\");\n}\n\n/** Get path to managed binaries directory (fd, rg) */\nexport function getBinDir(): string {\n\treturn join(getAgentDir(), \"bin\");\n}\n\n/**\n * Get path to the extension transpile cache directory (jiti fsCache).\n * Scoped by version so release upgrades never read stale transpiled output.\n */\nexport function getExtensionTranspileCacheDir(): string {\n\treturn join(getAgentDir(), \"cache\", \"jiti\", VERSION);\n}\n\n/** Get path to prompt templates directory */\nexport function getPromptsDir(): string {\n\treturn join(getAgentDir(), \"prompts\");\n}\n\n/** Get path to sessions directory */\nexport function getSessionsDir(): string {\n\treturn join(getAgentDir(), \"sessions\");\n}\n\n/** Get path to debug log file */\nexport function getDebugLogPath(): string {\n\treturn join(getAgentDir(), `${APP_NAME}-debug.log`);\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agent-session-compaction.d.ts","sourceRoot":"","sources":["../../src/core/agent-session-compaction.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACX,2BAA2B,IAAI,YAAY,EAC3C,8BAA8B,EAC9B,MAAM,4BAA4B,CAAC;AAEpC,OAAO,EAWN,KAAK,4BAA4B,EAEjC,KAAK,wBAAwB,EAE7B,MAAM,uBAAuB,CAAC;AAC/B,OAAO,KAAK,EAIX,yBAAyB,EACzB,MAAM,uBAAuB,CAAC;AAiD/B,wBAAsB,wBAAwB,CAC7C,IAAI,EAAE,YAAY,EAClB,OAAO,EAAE,8BAA8B,GACrC,OAAO,CAAC,wBAAwB,GAAG,SAAS,CAAC,CAmK/C;AAED,wBAAsB,wBAAwB,CAC7C,OAAO,EAAE,YAAY,EACrB,KAAK,EAAE,IAAI,CAAC,yBAAyB,EAAE,MAAM,CAAC,GAC5C,OAAO,CAAC,IAAI,CAAC,CAIf;AA4ED;;;;;;;GAOG;AACH,wBAAgB,OAAO,CACtB,IAAI,EAAE,YAAY,EAClB,OAAO,GAAE,OAAO,CAAC,4BAA4B,CAAM,GACjD,OAAO,CAAC,wBAAwB,CAAC,
|
|
1
|
+
{"version":3,"file":"agent-session-compaction.d.ts","sourceRoot":"","sources":["../../src/core/agent-session-compaction.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACX,2BAA2B,IAAI,YAAY,EAC3C,8BAA8B,EAC9B,MAAM,4BAA4B,CAAC;AAEpC,OAAO,EAWN,KAAK,4BAA4B,EAEjC,KAAK,wBAAwB,EAE7B,MAAM,uBAAuB,CAAC;AAC/B,OAAO,KAAK,EAIX,yBAAyB,EACzB,MAAM,uBAAuB,CAAC;AAiD/B,wBAAsB,wBAAwB,CAC7C,IAAI,EAAE,YAAY,EAClB,OAAO,EAAE,8BAA8B,GACrC,OAAO,CAAC,wBAAwB,GAAG,SAAS,CAAC,CAmK/C;AAED,wBAAsB,wBAAwB,CAC7C,OAAO,EAAE,YAAY,EACrB,KAAK,EAAE,IAAI,CAAC,yBAAyB,EAAE,MAAM,CAAC,GAC5C,OAAO,CAAC,IAAI,CAAC,CAIf;AA4ED;;;;;;;GAOG;AACH,wBAAgB,OAAO,CACtB,IAAI,EAAE,YAAY,EAClB,OAAO,GAAE,OAAO,CAAC,4BAA4B,CAAM,GACjD,OAAO,CAAC,wBAAwB,CAAC,CA8CnC;AAED,wBAAgB,eAAe,CAAC,IAAI,EAAE,YAAY,GAAG,IAAI,CAGxD;AACD,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,YAAY,GAAG,IAAI,CAE3D;AACD,wBAAgB,wBAAwB,CAAC,IAAI,EAAE,YAAY,EAAE,OAAO,EAAE,OAAO,GAAG,IAAI,CAEnF;AAED,eAAO,MAAM,6BAA6B;;;;;;CAMzC,CAAC"}
|
|
@@ -277,17 +277,19 @@ export function compact(options = {}) {
|
|
|
277
277
|
// retry. Invalidate its timer before this run claims compaction ownership.
|
|
278
278
|
this._postCompactionContinuationToken += 1;
|
|
279
279
|
this._pendingPostCompactionContinuation = undefined;
|
|
280
|
-
const controller = new AbortController();
|
|
281
|
-
this._compactionAbortController = controller;
|
|
282
|
-
this._compactionReason = "manual";
|
|
283
280
|
const automaticCompletion = this._autoCompactionCompletion;
|
|
284
281
|
// The manual request wins. Abort the active automatic planner now, before the
|
|
285
282
|
// next microtask can admit a post-tool or threshold boundary, then wait for
|
|
286
|
-
// its owner to settle before mutating the transcript ourselves.
|
|
283
|
+
// its owner to settle before mutating the transcript ourselves. Start the
|
|
284
|
+
// session abort before publishing this new manual owner so abort() cancels
|
|
285
|
+
// prior work rather than cancelling or waiting on the compaction being started.
|
|
287
286
|
this._autoCompactionAbortController?.abort();
|
|
288
287
|
const abortBoundary = this.abort();
|
|
289
|
-
|
|
290
|
-
|
|
288
|
+
const controller = new AbortController();
|
|
289
|
+
this._compactionAbortController = controller;
|
|
290
|
+
this._compactionReason = "manual";
|
|
291
|
+
// Handle rejection now so a failing event drain cannot become unhandled
|
|
292
|
+
// while an automatic run finishes.
|
|
291
293
|
void abortBoundary.catch(() => { });
|
|
292
294
|
let flight;
|
|
293
295
|
// Start the owned run in a microtask so both single-flight fields are
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agent-session-compaction.js","sourceRoot":"","sources":["../../src/core/agent-session-compaction.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,4BAA4B,EAAE,MAAM,oBAAoB,CAAC;AAClE,OAAO,EAKN,wBAAwB,EACxB,yBAAyB,EACzB,qBAAqB,EACrB,kCAAkC,EAClC,4BAA4B,GAM5B,MAAM,uBAAuB,CAAC;AAQ/B,OAAO,EAAE,iCAAiC,EAAE,MAAM,0BAA0B,CAAC;AAE7E,SAAS,wBAAwB;IAChC,MAAM,IAAI,SAAS,CAAC,6CAA6C,CAAC,CAAC;AACpE,CAAC;AAED,SAAS,UAAU,CAAI,KAAQ;IAC9B,IAAI,CAAC,KAAK,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC;QAAE,OAAO,KAAK,CAAC;IAChF,IAAI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C;SACD,OAAO,CAAC,GAAG,EAAE;QACb,+BAA+B,CAAC,IAAI,CAAC,IAAI,EAAE,UAAU,CAAC,CAAC;QACvD,IAAI,IAAI,CAAC,wBAAwB,KAAK,MAAM;YAAE,IAAI,CAAC,wBAAwB,GAAG,SAAS,CAAC;IACzF,CAAC,CAAC,CAAC;IACJ,IAAI,CAAC,wBAAwB,GAAG,MAAM,CAAC;IACvC,OAAO,MAAM,CAAC;AACf,CAAC;AAED,MAAM,UAAU,eAAe;IAC9B,IAAI,CAAC,0BAA0B,EAAE,KAAK,EAAE,CAAC;IACzC,IAAI,CAAC,8BAA8B,EAAE,KAAK,EAAE,CAAC;AAC9C,CAAC;AACD,MAAM,UAAU,kBAAkB;IACjC,IAAI,CAAC,6BAA6B,EAAE,KAAK,EAAE,CAAC;AAC7C,CAAC;AACD,MAAM,UAAU,wBAAwB,CAAqB,OAAgB;IAC5E,IAAI,CAAC,eAAe,CAAC,oBAAoB,CAAC,OAAO,CAAC,CAAC;AACpD,CAAC;AAED,MAAM,CAAC,MAAM,6BAA6B,GAAG;IAC5C,wBAAwB;IACxB,OAAO;IACP,eAAe;IACf,kBAAkB;IAClB,wBAAwB;CACxB,CAAC","sourcesContent":["import type { Usage } from \"@bastani/pi-ai/compat\";\nimport type {\n\tAgentSessionInternalSurface as AgentSession,\n\tVerbatimCompactionApplyOptions,\n} from \"./agent-session-methods.ts\";\nimport { formatNoModelSelectedMessage } from \"./auth-guidance.ts\";\nimport {\n\ttype CompactionPlannerModel,\n\ttype CompactionPlanOptions,\n\ttype CompactionRung,\n\ttype FallbackPlannerContext,\n\tgetKeptTailTokenEstimate,\n\tprepareCompactionBoundary,\n\trunVerbatimCompaction,\n\tVERBATIM_COMPACTION_PROMPT_VERSION,\n\tVERBATIM_COMPACTION_STRATEGY,\n\ttype VerbatimCompactionDetails,\n\ttype VerbatimCompactionParameters,\n\ttype VerbatimCompactionPreparation,\n\ttype VerbatimCompactionResult,\n\ttype VerbatimCompactionStats,\n} from \"./compaction/index.ts\";\nimport type {\n\tSessionBeforeCompactEvent,\n\tSessionBeforeCompactResult,\n\tSessionCompactEvent,\n\tSessionCompactFailedEvent,\n} from \"./extensions/index.ts\";\nimport type { CompactionEntry } from \"./session-manager.ts\";\nimport { createSummarizationRetryCallbacks } from \"./summarization-retry.ts\";\n\nfunction frozenCollectionMutation(): never {\n\tthrow new TypeError(\"Cannot mutate frozen compaction preparation\");\n}\n\nfunction deepFreeze<T>(value: T): T {\n\tif (!value || typeof value !== \"object\" || Object.isFrozen(value)) return value;\n\tif (value instanceof Map) {\n\t\tfor (const [key, nested] of value) {\n\t\t\tdeepFreeze(key);\n\t\t\tdeepFreeze(nested);\n\t\t}\n\t\tObject.defineProperties(value, {\n\t\t\tset: { value: frozenCollectionMutation },\n\t\t\tdelete: { value: frozenCollectionMutation },\n\t\t\tclear: { value: frozenCollectionMutation },\n\t\t});\n\t} else if (value instanceof Set) {\n\t\tfor (const nested of value) deepFreeze(nested);\n\t\tObject.defineProperties(value, {\n\t\t\tadd: { value: frozenCollectionMutation },\n\t\t\tdelete: { value: frozenCollectionMutation },\n\t\t\tclear: { value: frozenCollectionMutation },\n\t\t});\n\t} else {\n\t\tfor (const nested of Object.values(value)) deepFreeze(nested);\n\t}\n\treturn Object.freeze(value);\n}\n\nfunction extensionStats(preparation: VerbatimCompactionPreparation, compactedText: string): VerbatimCompactionStats {\n\tconst linesBefore = preparation.region.lines.length;\n\tconst linesKept = compactedText.split(\"\\n\").length;\n\tconst tokensAfter = Math.ceil(compactedText.length / 4) + getKeptTailTokenEstimate(preparation);\n\treturn {\n\t\tlinesBefore,\n\t\tlinesDeleted: Math.max(0, linesBefore - linesKept),\n\t\tlinesKept,\n\t\trangeCount: 0,\n\t\ttokensBefore: preparation.tokensBefore,\n\t\ttokensAfter,\n\t\tpercentReduction:\n\t\t\tpreparation.tokensBefore === 0 ? 0 : Math.round((1 - tokensAfter / preparation.tokensBefore) * 1000) / 10,\n\t};\n}\n\nexport async function _applyVerbatimCompaction(\n\tthis: AgentSession,\n\toptions: VerbatimCompactionApplyOptions,\n): Promise<VerbatimCompactionResult | undefined> {\n\tif (!this.model) throw new Error(formatNoModelSelectedMessage());\n\tconst model = this.model;\n\tconst pathEntries = this.sessionManager.getBranch();\n\tconst settings = this.settingsManager.getCompactionSettings();\n\t// A sub-minimum region is admitted only when the caller already knows the\n\t// context does not fit: overflow recovery, or a post-tool preflight over the\n\t// provider hard input limit. A threshold crossing that still fits must not\n\t// clear context — its follow-up request can be sent as-is. `load_bearing`\n\t// alone does not mean \"must destroy context\".\n\tconst allowSmallRegion = options.urgency === \"load_bearing\" && options.allowSmallRegion === true;\n\tconst preparation = prepareCompactionBoundary(\n\t\tpathEntries,\n\t\tsettings,\n\t\t{\n\t\t\t...(options.compression_ratio === undefined ? {} : { compression_ratio: options.compression_ratio }),\n\t\t\t...(options.preserve_recent === undefined ? {} : { preserve_recent: options.preserve_recent }),\n\t\t\t...(options.query === undefined ? {} : { query: options.query }),\n\t\t},\n\t\t{ allowSmallRegion },\n\t);\n\tif (!preparation) {\n\t\t// Mid-turn threshold preflight needs the load-bearing planner fallback if\n\t\t// a region exists, but a context that still fits is safe to send unchanged.\n\t\t// True overflow and a hard-limit preflight have no such escape hatch.\n\t\tconst mustFreeContext = options.urgency === \"load_bearing\" && (options.reason === \"overflow\" || allowSmallRegion);\n\t\tif (mustFreeContext) {\n\t\t\tthrow new Error(\n\t\t\t\t\"Context compaction found no compactable transcript entries; nothing more was safely deletable\",\n\t\t\t);\n\t\t}\n\t\treturn undefined;\n\t}\n\n\tconst plan: CompactionPlanOptions = {\n\t\tstreamFn: this.agent.streamFunction,\n\t\tsessionFilePath: this.sessionManager.getSessionFile(),\n\t\tretry: this.settingsManager.getRetrySettings(),\n\t\tcallbacks: createSummarizationRetryCallbacks(this, { source: \"compaction\", reason: options.reason }),\n\t};\n\tlet fromExtension = false;\n\tlet compacted:\n\t\t| {\n\t\t\t\ttext: string;\n\t\t\t\tstats: VerbatimCompactionStats;\n\t\t\t\trung: CompactionRung;\n\t\t\t\tplannerModel?: CompactionPlannerModel;\n\t\t\t\tkeptTail: boolean;\n\t\t\t\tusage?: Usage;\n\t\t }\n\t\t| undefined;\n\n\tif (this._extensionRunner.hasHandlers(\"session_before_compact\")) {\n\t\tlet snapshot: VerbatimCompactionPreparation;\n\t\ttry {\n\t\t\tsnapshot = deepFreeze(structuredClone(preparation));\n\t\t} catch (error) {\n\t\t\tthrow new Error(\n\t\t\t\t`Failed to snapshot transcript for compaction extensions: ${error instanceof Error ? error.message : String(error)}`,\n\t\t\t);\n\t\t}\n\t\tconst hookResult = (await this._extensionRunner.emit({\n\t\t\ttype: \"session_before_compact\",\n\t\t\treason: options.reason,\n\t\t\tparameters: preparation.parameters,\n\t\t\tpreparation: snapshot,\n\t\t\tbranchEntries: pathEntries,\n\t\t\tsignal: options.abortController.signal,\n\t\t} satisfies SessionBeforeCompactEvent)) as SessionBeforeCompactResult | undefined;\n\t\tif (hookResult?.cancel) throw new Error(\"Compaction cancelled\");\n\t\tif (hookResult?.compactedText !== undefined) {\n\t\t\tif (hookResult.compactedText.trim().length === 0) throw new Error(\"No compacted text provided by extension\");\n\t\t\tcompacted = {\n\t\t\t\ttext: hookResult.compactedText,\n\t\t\t\tstats: extensionStats(preparation, hookResult.compactedText),\n\t\t\t\trung: \"extension\",\n\t\t\t\tkeptTail: true,\n\t\t\t};\n\t\t\tfromExtension = true;\n\t\t\toptions.onCompactionSource?.(true);\n\t\t}\n\t}\n\n\tif (!compacted) {\n\t\t// Borrowing walks the session's *effective* fallback list, which SDK\n\t\t// options may override, and resolves credentials per candidate. It never\n\t\t// touches session model state or the main chat's attempted-key set.\n\t\tconst fallback: FallbackPlannerContext = {\n\t\t\tfallbackModels: this._fallbackModels,\n\t\t\tregistry: this._modelRuntime,\n\t\t\tpreferredProvider: model.provider,\n\t\t\tsessionThinkingLevel: this.thinkingLevel,\n\t\t};\n\t\tconst run = await runVerbatimCompaction(preparation, model, {\n\t\t\t...plan,\n\t\t\tresolveAuth: options.resolvePlannerAuth,\n\t\t\tsignal: options.abortController.signal,\n\t\t\tthinkingLevel: this.thinkingLevel,\n\t\t\turgency: options.urgency,\n\t\t\tfallback,\n\t\t});\n\t\tcompacted = {\n\t\t\ttext: run.text,\n\t\t\tstats: run.stats,\n\t\t\trung: run.rung,\n\t\t\t...(run.plannerModel ? { plannerModel: run.plannerModel } : {}),\n\t\t\t...(run.usage ? { usage: run.usage } : {}),\n\t\t\tkeptTail: run.keptTail,\n\t\t};\n\t}\n\tif (options.abortController.signal.aborted) throw new Error(\"Compaction cancelled\");\n\n\t// A fresh rung that had to drop the protected tail persists no tail boundary.\n\tconst firstKeptEntryId = compacted.keptTail ? preparation.firstKeptEntryId : null;\n\tconst backupPath = this.sessionManager.writeBackupSnapshot(options.backupLabel);\n\tconst details: VerbatimCompactionDetails = {\n\t\tstrategy: VERBATIM_COMPACTION_STRATEGY,\n\t\tpromptVersion: VERBATIM_COMPACTION_PROMPT_VERSION,\n\t\tparameters: preparation.parameters,\n\t\tstats: compacted.stats,\n\t\trung: compacted.rung,\n\t\t...(compacted.plannerModel ? { plannerModel: compacted.plannerModel } : {}),\n\t\t...(backupPath ? { backupPath } : {}),\n\t};\n\tconst entryId = this.sessionManager.appendCompaction(\n\t\tcompacted.text,\n\t\tfirstKeptEntryId,\n\t\tpreparation.tokensBefore,\n\t\tdetails,\n\t\tcompacted.usage,\n\t);\n\tthis.agent.state.messages = this.sessionManager.buildSessionContext().messages;\n\tconst result: VerbatimCompactionResult = {\n\t\tcompactedText: compacted.text,\n\t\tfirstKeptEntryId,\n\t\ttokensBefore: preparation.tokensBefore,\n\t\tstats: compacted.stats,\n\t\tparameters: preparation.parameters,\n\t\tpromptVersion: VERBATIM_COMPACTION_PROMPT_VERSION,\n\t\trung: compacted.rung,\n\t\t...(compacted.plannerModel ? { plannerModel: compacted.plannerModel } : {}),\n\t\t...(compacted.usage ? { usage: compacted.usage } : {}),\n\t\t...(backupPath ? { backupPath } : {}),\n\t};\n\tconst compactionEntry = this.sessionManager.getEntry(entryId) as CompactionEntry<VerbatimCompactionDetails>;\n\ttry {\n\t\tawait this._extensionRunner.emit({\n\t\t\ttype: \"session_compact\",\n\t\t\treason: options.reason,\n\t\t\tparameters: preparation.parameters,\n\t\t\tresult,\n\t\t\tcompactionEntry,\n\t\t\tfromExtension,\n\t\t} satisfies SessionCompactEvent);\n\t} catch (error) {\n\t\tthis._extensionRunner.emitError({\n\t\t\textensionPath: \"<session_compact>\",\n\t\t\tevent: \"session_compact\",\n\t\t\terror: error instanceof Error ? error.message : String(error),\n\t\t\tstack: error instanceof Error ? error.stack : undefined,\n\t\t});\n\t}\n\treturn result;\n}\n\nexport async function emitSessionCompactFailed(\n\tsession: AgentSession,\n\tevent: Omit<SessionCompactFailedEvent, \"type\">,\n): Promise<void> {\n\tif (session._extensionRunner?.hasHandlers(\"session_compact_failed\")) {\n\t\tawait session._extensionRunner.emit({ type: \"session_compact_failed\", ...event });\n\t}\n}\n\nfunction clearOwnedManualCompactionState(this: AgentSession, controller: AbortController): void {\n\tif (this._compactionAbortController !== controller) return;\n\tthis._compactionAbortController = undefined;\n\tif (this._compactionReason === \"manual\") this._compactionReason = undefined;\n\t// Lifecycle listeners run synchronously. Once the manual end event is\n\t// emitted, a new /compact must own a new run rather than join the settled one.\n\tthis._manualCompactionPromise = undefined;\n}\n\nasync function emitManualCompactionFailure(\n\tthis: AgentSession,\n\tcontroller: AbortController,\n\terror: unknown,\n\tfromExtension: boolean,\n): Promise<void> {\n\tconst message = error instanceof Error ? error.message : String(error);\n\tconst aborted = message === \"Compaction cancelled\" || (error instanceof Error && error.name === \"AbortError\");\n\tconst errorMessage = aborted ? undefined : `Compaction failed: ${message}`;\n\tclearOwnedManualCompactionState.call(this, controller);\n\tthis._emit({\n\t\ttype: \"compaction_end\",\n\t\treason: \"manual\",\n\t\tresult: undefined,\n\t\taborted,\n\t\twillRetry: false,\n\t\terrorMessage,\n\t});\n\tawait emitSessionCompactFailed(this, {\n\t\treason: \"manual\",\n\t\terrorMessage,\n\t\taborted,\n\t\twillRetry: false,\n\t\tfromExtension,\n\t});\n}\n\nasync function runOwnedManualCompaction(\n\tthis: AgentSession,\n\tcontroller: AbortController,\n\toptions: Partial<VerbatimCompactionParameters>,\n): Promise<VerbatimCompactionResult> {\n\tthis._emit({ type: \"compaction_start\", reason: \"manual\" });\n\tlet fromExtension = false;\n\ttry {\n\t\tif (!this.model) throw new Error(formatNoModelSelectedMessage());\n\t\tconst result = await this._applyVerbatimCompaction({\n\t\t\t// Caller parameters are projected explicitly, so no extra runtime\n\t\t\t// property survives. A widened or cast object could otherwise carry\n\t\t\t// `urgency: \"load_bearing\"` through a public `session.compact()` call and\n\t\t\t// reach the context-destroying rung, which manual compaction must never do.\n\t\t\t...(options.compression_ratio === undefined ? {} : { compression_ratio: options.compression_ratio }),\n\t\t\t...(options.preserve_recent === undefined ? {} : { preserve_recent: options.preserve_recent }),\n\t\t\t...(options.query === undefined ? {} : { query: options.query }),\n\t\t\tresolvePlannerAuth: (candidate) => this._getRequiredRequestAuth(candidate),\n\t\t\tabortController: controller,\n\t\t\tbackupLabel: \"compact\",\n\t\t\treason: \"manual\",\n\t\t\turgency: \"recoverable\",\n\t\t\tonCompactionSource: (value) => {\n\t\t\t\tfromExtension = value;\n\t\t\t},\n\t\t});\n\t\tif (!result) throw new Error(\"Nothing to compact (session too small)\");\n\t\t// compaction_end listeners synchronously flush queued prompts, so they must\n\t\t// observe an idle session before dispatching the next user turn.\n\t\tclearOwnedManualCompactionState.call(this, controller);\n\t\tthis._emit({ type: \"compaction_end\", reason: \"manual\", result, aborted: false, willRetry: false });\n\t\treturn result;\n\t} catch (error) {\n\t\tawait emitManualCompactionFailure.call(this, controller, error, fromExtension);\n\t\tthrow error;\n\t}\n}\n\n/**\n * Persist one verbatim line-subset compaction boundary.\n *\n * Re-entrancy safe: a call made while a manual compaction is still in flight\n * joins that run instead of starting a second one. Manual compaction aborts an\n * active agent run before it starts, while agent event delivery remains live so\n * a pending threshold check cannot race the requested manual boundary.\n */\nexport function compact(\n\tthis: AgentSession,\n\toptions: Partial<VerbatimCompactionParameters> = {},\n): Promise<VerbatimCompactionResult> {\n\tconst inFlight = this._manualCompactionPromise;\n\tif (inFlight) return inFlight;\n\n\t// A manual boundary replaces the automatic turn that scheduled any pending\n\t// retry. Invalidate its timer before this run claims compaction ownership.\n\tthis._postCompactionContinuationToken += 1;\n\tthis._pendingPostCompactionContinuation = undefined;\n\n\tconst controller = new AbortController();\n\tthis._compactionAbortController = controller;\n\tthis._compactionReason = \"manual\";\n\tconst automaticCompletion = this._autoCompactionCompletion;\n\t// The manual request wins. Abort the active automatic planner now, before the\n\t// next microtask can admit a post-tool or threshold boundary, then wait for\n\t// its owner to settle before mutating the transcript ourselves.\n\tthis._autoCompactionAbortController?.abort();\n\tconst abortBoundary = this.abort();\n\t// This settles only after any active automatic run. Handle its rejection now\n\t// so a failing event drain cannot become unhandled while that run finishes.\n\tvoid abortBoundary.catch(() => {});\n\tlet flight!: Promise<VerbatimCompactionResult>;\n\t// Start the owned run in a microtask so both single-flight fields are\n\t// published before any joiner can observe a partially claimed compaction.\n\tflight = Promise.resolve()\n\t\t.then(async () => {\n\t\t\ttry {\n\t\t\t\tif (automaticCompletion !== undefined) await automaticCompletion;\n\t\t\t\tawait abortBoundary;\n\t\t\t} catch (error) {\n\t\t\t\t// The abort drain can fail before the planner starts. Finish the\n\t\t\t\t// manual lifecycle so event consumers can release queued input.\n\t\t\t\tawait emitManualCompactionFailure.call(this, controller, error, false);\n\t\t\t\tthrow error;\n\t\t\t}\n\t\t\treturn runOwnedManualCompaction.call(this, controller, options);\n\t\t})\n\t\t.finally(() => {\n\t\t\tclearOwnedManualCompactionState.call(this, controller);\n\t\t\tif (this._manualCompactionPromise === flight) this._manualCompactionPromise = undefined;\n\t\t});\n\tthis._manualCompactionPromise = flight;\n\treturn flight;\n}\n\nexport function abortCompaction(this: AgentSession): void {\n\tthis._compactionAbortController?.abort();\n\tthis._autoCompactionAbortController?.abort();\n}\nexport function abortBranchSummary(this: AgentSession): void {\n\tthis._branchSummaryAbortController?.abort();\n}\nexport function setAutoCompactionEnabled(this: AgentSession, enabled: boolean): void {\n\tthis.settingsManager.setCompactionEnabled(enabled);\n}\n\nexport const agentSessionCompactionMethods = {\n\t_applyVerbatimCompaction,\n\tcompact,\n\tabortCompaction,\n\tabortBranchSummary,\n\tsetAutoCompactionEnabled,\n};\n"]}
|
|
1
|
+
{"version":3,"file":"agent-session-compaction.js","sourceRoot":"","sources":["../../src/core/agent-session-compaction.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,4BAA4B,EAAE,MAAM,oBAAoB,CAAC;AAClE,OAAO,EAKN,wBAAwB,EACxB,yBAAyB,EACzB,qBAAqB,EACrB,kCAAkC,EAClC,4BAA4B,GAM5B,MAAM,uBAAuB,CAAC;AAQ/B,OAAO,EAAE,iCAAiC,EAAE,MAAM,0BAA0B,CAAC;AAE7E,SAAS,wBAAwB;IAChC,MAAM,IAAI,SAAS,CAAC,6CAA6C,CAAC,CAAC;AACpE,CAAC;AAED,SAAS,UAAU,CAAI,KAAQ;IAC9B,IAAI,CAAC,KAAK,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC;QAAE,OAAO,KAAK,CAAC;IAChF,IAAI,KAAK,YAAY,GAAG,EAAE,CAAC;QAC1B,KAAK,MAAM,CAAC,GAAG,EAAE,MAAM,CAAC,IAAI,KAAK,EAAE,CAAC;YACnC,UAAU,CAAC,GAAG,CAAC,CAAC;YAChB,UAAU,CAAC,MAAM,CAAC,CAAC;QACpB,CAAC;QACD,MAAM,CAAC,gBAAgB,CAAC,KAAK,EAAE;YAC9B,GAAG,EAAE,EAAE,KAAK,EAAE,wBAAwB,EAAE;YACxC,MAAM,EAAE,EAAE,KAAK,EAAE,wBAAwB,EAAE;YAC3C,KAAK,EAAE,EAAE,KAAK,EAAE,wBAAwB,EA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,CAAC;IACzC,IAAI,CAAC,8BAA8B,EAAE,KAAK,EAAE,CAAC;AAC9C,CAAC;AACD,MAAM,UAAU,kBAAkB;IACjC,IAAI,CAAC,6BAA6B,EAAE,KAAK,EAAE,CAAC;AAC7C,CAAC;AACD,MAAM,UAAU,wBAAwB,CAAqB,OAAgB;IAC5E,IAAI,CAAC,eAAe,CAAC,oBAAoB,CAAC,OAAO,CAAC,CAAC;AACpD,CAAC;AAED,MAAM,CAAC,MAAM,6BAA6B,GAAG;IAC5C,wBAAwB;IACxB,OAAO;IACP,eAAe;IACf,kBAAkB;IAClB,wBAAwB;CACxB,CAAC","sourcesContent":["import type { Usage } from \"@bastani/pi-ai/compat\";\nimport type {\n\tAgentSessionInternalSurface as AgentSession,\n\tVerbatimCompactionApplyOptions,\n} from \"./agent-session-methods.ts\";\nimport { formatNoModelSelectedMessage } from \"./auth-guidance.ts\";\nimport {\n\ttype CompactionPlannerModel,\n\ttype CompactionPlanOptions,\n\ttype CompactionRung,\n\ttype FallbackPlannerContext,\n\tgetKeptTailTokenEstimate,\n\tprepareCompactionBoundary,\n\trunVerbatimCompaction,\n\tVERBATIM_COMPACTION_PROMPT_VERSION,\n\tVERBATIM_COMPACTION_STRATEGY,\n\ttype VerbatimCompactionDetails,\n\ttype VerbatimCompactionParameters,\n\ttype VerbatimCompactionPreparation,\n\ttype VerbatimCompactionResult,\n\ttype VerbatimCompactionStats,\n} from \"./compaction/index.ts\";\nimport type {\n\tSessionBeforeCompactEvent,\n\tSessionBeforeCompactResult,\n\tSessionCompactEvent,\n\tSessionCompactFailedEvent,\n} from \"./extensions/index.ts\";\nimport type { CompactionEntry } from \"./session-manager.ts\";\nimport { createSummarizationRetryCallbacks } from \"./summarization-retry.ts\";\n\nfunction frozenCollectionMutation(): never {\n\tthrow new TypeError(\"Cannot mutate frozen compaction preparation\");\n}\n\nfunction deepFreeze<T>(value: T): T {\n\tif (!value || typeof value !== \"object\" || Object.isFrozen(value)) return value;\n\tif (value instanceof Map) {\n\t\tfor (const [key, nested] of value) {\n\t\t\tdeepFreeze(key);\n\t\t\tdeepFreeze(nested);\n\t\t}\n\t\tObject.defineProperties(value, {\n\t\t\tset: { value: frozenCollectionMutation },\n\t\t\tdelete: { value: frozenCollectionMutation },\n\t\t\tclear: { value: frozenCollectionMutation },\n\t\t});\n\t} else if (value instanceof Set) {\n\t\tfor (const nested of value) deepFreeze(nested);\n\t\tObject.defineProperties(value, {\n\t\t\tadd: { value: frozenCollectionMutation },\n\t\t\tdelete: { value: frozenCollectionMutation },\n\t\t\tclear: { value: frozenCollectionMutation },\n\t\t});\n\t} else {\n\t\tfor (const nested of Object.values(value)) deepFreeze(nested);\n\t}\n\treturn Object.freeze(value);\n}\n\nfunction extensionStats(preparation: VerbatimCompactionPreparation, compactedText: string): VerbatimCompactionStats {\n\tconst linesBefore = preparation.region.lines.length;\n\tconst linesKept = compactedText.split(\"\\n\").length;\n\tconst tokensAfter = Math.ceil(compactedText.length / 4) + getKeptTailTokenEstimate(preparation);\n\treturn {\n\t\tlinesBefore,\n\t\tlinesDeleted: Math.max(0, linesBefore - linesKept),\n\t\tlinesKept,\n\t\trangeCount: 0,\n\t\ttokensBefore: preparation.tokensBefore,\n\t\ttokensAfter,\n\t\tpercentReduction:\n\t\t\tpreparation.tokensBefore === 0 ? 0 : Math.round((1 - tokensAfter / preparation.tokensBefore) * 1000) / 10,\n\t};\n}\n\nexport async function _applyVerbatimCompaction(\n\tthis: AgentSession,\n\toptions: VerbatimCompactionApplyOptions,\n): Promise<VerbatimCompactionResult | undefined> {\n\tif (!this.model) throw new Error(formatNoModelSelectedMessage());\n\tconst model = this.model;\n\tconst pathEntries = this.sessionManager.getBranch();\n\tconst settings = this.settingsManager.getCompactionSettings();\n\t// A sub-minimum region is admitted only when the caller already knows the\n\t// context does not fit: overflow recovery, or a post-tool preflight over the\n\t// provider hard input limit. A threshold crossing that still fits must not\n\t// clear context — its follow-up request can be sent as-is. `load_bearing`\n\t// alone does not mean \"must destroy context\".\n\tconst allowSmallRegion = options.urgency === \"load_bearing\" && options.allowSmallRegion === true;\n\tconst preparation = prepareCompactionBoundary(\n\t\tpathEntries,\n\t\tsettings,\n\t\t{\n\t\t\t...(options.compression_ratio === undefined ? {} : { compression_ratio: options.compression_ratio }),\n\t\t\t...(options.preserve_recent === undefined ? {} : { preserve_recent: options.preserve_recent }),\n\t\t\t...(options.query === undefined ? {} : { query: options.query }),\n\t\t},\n\t\t{ allowSmallRegion },\n\t);\n\tif (!preparation) {\n\t\t// Mid-turn threshold preflight needs the load-bearing planner fallback if\n\t\t// a region exists, but a context that still fits is safe to send unchanged.\n\t\t// True overflow and a hard-limit preflight have no such escape hatch.\n\t\tconst mustFreeContext = options.urgency === \"load_bearing\" && (options.reason === \"overflow\" || allowSmallRegion);\n\t\tif (mustFreeContext) {\n\t\t\tthrow new Error(\n\t\t\t\t\"Context compaction found no compactable transcript entries; nothing more was safely deletable\",\n\t\t\t);\n\t\t}\n\t\treturn undefined;\n\t}\n\n\tconst plan: CompactionPlanOptions = {\n\t\tstreamFn: this.agent.streamFunction,\n\t\tsessionFilePath: this.sessionManager.getSessionFile(),\n\t\tretry: this.settingsManager.getRetrySettings(),\n\t\tcallbacks: createSummarizationRetryCallbacks(this, { source: \"compaction\", reason: options.reason }),\n\t};\n\tlet fromExtension = false;\n\tlet compacted:\n\t\t| {\n\t\t\t\ttext: string;\n\t\t\t\tstats: VerbatimCompactionStats;\n\t\t\t\trung: CompactionRung;\n\t\t\t\tplannerModel?: CompactionPlannerModel;\n\t\t\t\tkeptTail: boolean;\n\t\t\t\tusage?: Usage;\n\t\t }\n\t\t| undefined;\n\n\tif (this._extensionRunner.hasHandlers(\"session_before_compact\")) {\n\t\tlet snapshot: VerbatimCompactionPreparation;\n\t\ttry {\n\t\t\tsnapshot = deepFreeze(structuredClone(preparation));\n\t\t} catch (error) {\n\t\t\tthrow new Error(\n\t\t\t\t`Failed to snapshot transcript for compaction extensions: ${error instanceof Error ? error.message : String(error)}`,\n\t\t\t);\n\t\t}\n\t\tconst hookResult = (await this._extensionRunner.emit({\n\t\t\ttype: \"session_before_compact\",\n\t\t\treason: options.reason,\n\t\t\tparameters: preparation.parameters,\n\t\t\tpreparation: snapshot,\n\t\t\tbranchEntries: pathEntries,\n\t\t\tsignal: options.abortController.signal,\n\t\t} satisfies SessionBeforeCompactEvent)) as SessionBeforeCompactResult | undefined;\n\t\tif (hookResult?.cancel) throw new Error(\"Compaction cancelled\");\n\t\tif (hookResult?.compactedText !== undefined) {\n\t\t\tif (hookResult.compactedText.trim().length === 0) throw new Error(\"No compacted text provided by extension\");\n\t\t\tcompacted = {\n\t\t\t\ttext: hookResult.compactedText,\n\t\t\t\tstats: extensionStats(preparation, hookResult.compactedText),\n\t\t\t\trung: \"extension\",\n\t\t\t\tkeptTail: true,\n\t\t\t};\n\t\t\tfromExtension = true;\n\t\t\toptions.onCompactionSource?.(true);\n\t\t}\n\t}\n\n\tif (!compacted) {\n\t\t// Borrowing walks the session's *effective* fallback list, which SDK\n\t\t// options may override, and resolves credentials per candidate. It never\n\t\t// touches session model state or the main chat's attempted-key set.\n\t\tconst fallback: FallbackPlannerContext = {\n\t\t\tfallbackModels: this._fallbackModels,\n\t\t\tregistry: this._modelRuntime,\n\t\t\tpreferredProvider: model.provider,\n\t\t\tsessionThinkingLevel: this.thinkingLevel,\n\t\t};\n\t\tconst run = await runVerbatimCompaction(preparation, model, {\n\t\t\t...plan,\n\t\t\tresolveAuth: options.resolvePlannerAuth,\n\t\t\tsignal: options.abortController.signal,\n\t\t\tthinkingLevel: this.thinkingLevel,\n\t\t\turgency: options.urgency,\n\t\t\tfallback,\n\t\t});\n\t\tcompacted = {\n\t\t\ttext: run.text,\n\t\t\tstats: run.stats,\n\t\t\trung: run.rung,\n\t\t\t...(run.plannerModel ? { plannerModel: run.plannerModel } : {}),\n\t\t\t...(run.usage ? { usage: run.usage } : {}),\n\t\t\tkeptTail: run.keptTail,\n\t\t};\n\t}\n\tif (options.abortController.signal.aborted) throw new Error(\"Compaction cancelled\");\n\n\t// A fresh rung that had to drop the protected tail persists no tail boundary.\n\tconst firstKeptEntryId = compacted.keptTail ? preparation.firstKeptEntryId : null;\n\tconst backupPath = this.sessionManager.writeBackupSnapshot(options.backupLabel);\n\tconst details: VerbatimCompactionDetails = {\n\t\tstrategy: VERBATIM_COMPACTION_STRATEGY,\n\t\tpromptVersion: VERBATIM_COMPACTION_PROMPT_VERSION,\n\t\tparameters: preparation.parameters,\n\t\tstats: compacted.stats,\n\t\trung: compacted.rung,\n\t\t...(compacted.plannerModel ? { plannerModel: compacted.plannerModel } : {}),\n\t\t...(backupPath ? { backupPath } : {}),\n\t};\n\tconst entryId = this.sessionManager.appendCompaction(\n\t\tcompacted.text,\n\t\tfirstKeptEntryId,\n\t\tpreparation.tokensBefore,\n\t\tdetails,\n\t\tcompacted.usage,\n\t);\n\tthis.agent.state.messages = this.sessionManager.buildSessionContext().messages;\n\tconst result: VerbatimCompactionResult = {\n\t\tcompactedText: compacted.text,\n\t\tfirstKeptEntryId,\n\t\ttokensBefore: preparation.tokensBefore,\n\t\tstats: compacted.stats,\n\t\tparameters: preparation.parameters,\n\t\tpromptVersion: VERBATIM_COMPACTION_PROMPT_VERSION,\n\t\trung: compacted.rung,\n\t\t...(compacted.plannerModel ? { plannerModel: compacted.plannerModel } : {}),\n\t\t...(compacted.usage ? { usage: compacted.usage } : {}),\n\t\t...(backupPath ? { backupPath } : {}),\n\t};\n\tconst compactionEntry = this.sessionManager.getEntry(entryId) as CompactionEntry<VerbatimCompactionDetails>;\n\ttry {\n\t\tawait this._extensionRunner.emit({\n\t\t\ttype: \"session_compact\",\n\t\t\treason: options.reason,\n\t\t\tparameters: preparation.parameters,\n\t\t\tresult,\n\t\t\tcompactionEntry,\n\t\t\tfromExtension,\n\t\t} satisfies SessionCompactEvent);\n\t} catch (error) {\n\t\tthis._extensionRunner.emitError({\n\t\t\textensionPath: \"<session_compact>\",\n\t\t\tevent: \"session_compact\",\n\t\t\terror: error instanceof Error ? error.message : String(error),\n\t\t\tstack: error instanceof Error ? error.stack : undefined,\n\t\t});\n\t}\n\treturn result;\n}\n\nexport async function emitSessionCompactFailed(\n\tsession: AgentSession,\n\tevent: Omit<SessionCompactFailedEvent, \"type\">,\n): Promise<void> {\n\tif (session._extensionRunner?.hasHandlers(\"session_compact_failed\")) {\n\t\tawait session._extensionRunner.emit({ type: \"session_compact_failed\", ...event });\n\t}\n}\n\nfunction clearOwnedManualCompactionState(this: AgentSession, controller: AbortController): void {\n\tif (this._compactionAbortController !== controller) return;\n\tthis._compactionAbortController = undefined;\n\tif (this._compactionReason === \"manual\") this._compactionReason = undefined;\n\t// Lifecycle listeners run synchronously. Once the manual end event is\n\t// emitted, a new /compact must own a new run rather than join the settled one.\n\tthis._manualCompactionPromise = undefined;\n}\n\nasync function emitManualCompactionFailure(\n\tthis: AgentSession,\n\tcontroller: AbortController,\n\terror: unknown,\n\tfromExtension: boolean,\n): Promise<void> {\n\tconst message = error instanceof Error ? error.message : String(error);\n\tconst aborted = message === \"Compaction cancelled\" || (error instanceof Error && error.name === \"AbortError\");\n\tconst errorMessage = aborted ? undefined : `Compaction failed: ${message}`;\n\tclearOwnedManualCompactionState.call(this, controller);\n\tthis._emit({\n\t\ttype: \"compaction_end\",\n\t\treason: \"manual\",\n\t\tresult: undefined,\n\t\taborted,\n\t\twillRetry: false,\n\t\terrorMessage,\n\t});\n\tawait emitSessionCompactFailed(this, {\n\t\treason: \"manual\",\n\t\terrorMessage,\n\t\taborted,\n\t\twillRetry: false,\n\t\tfromExtension,\n\t});\n}\n\nasync function runOwnedManualCompaction(\n\tthis: AgentSession,\n\tcontroller: AbortController,\n\toptions: Partial<VerbatimCompactionParameters>,\n): Promise<VerbatimCompactionResult> {\n\tthis._emit({ type: \"compaction_start\", reason: \"manual\" });\n\tlet fromExtension = false;\n\ttry {\n\t\tif (!this.model) throw new Error(formatNoModelSelectedMessage());\n\t\tconst result = await this._applyVerbatimCompaction({\n\t\t\t// Caller parameters are projected explicitly, so no extra runtime\n\t\t\t// property survives. A widened or cast object could otherwise carry\n\t\t\t// `urgency: \"load_bearing\"` through a public `session.compact()` call and\n\t\t\t// reach the context-destroying rung, which manual compaction must never do.\n\t\t\t...(options.compression_ratio === undefined ? {} : { compression_ratio: options.compression_ratio }),\n\t\t\t...(options.preserve_recent === undefined ? {} : { preserve_recent: options.preserve_recent }),\n\t\t\t...(options.query === undefined ? {} : { query: options.query }),\n\t\t\tresolvePlannerAuth: (candidate) => this._getRequiredRequestAuth(candidate),\n\t\t\tabortController: controller,\n\t\t\tbackupLabel: \"compact\",\n\t\t\treason: \"manual\",\n\t\t\turgency: \"recoverable\",\n\t\t\tonCompactionSource: (value) => {\n\t\t\t\tfromExtension = value;\n\t\t\t},\n\t\t});\n\t\tif (!result) throw new Error(\"Nothing to compact (session too small)\");\n\t\t// compaction_end listeners synchronously flush queued prompts, so they must\n\t\t// observe an idle session before dispatching the next user turn.\n\t\tclearOwnedManualCompactionState.call(this, controller);\n\t\tthis._emit({ type: \"compaction_end\", reason: \"manual\", result, aborted: false, willRetry: false });\n\t\treturn result;\n\t} catch (error) {\n\t\tawait emitManualCompactionFailure.call(this, controller, error, fromExtension);\n\t\tthrow error;\n\t}\n}\n\n/**\n * Persist one verbatim line-subset compaction boundary.\n *\n * Re-entrancy safe: a call made while a manual compaction is still in flight\n * joins that run instead of starting a second one. Manual compaction aborts an\n * active agent run before it starts, while agent event delivery remains live so\n * a pending threshold check cannot race the requested manual boundary.\n */\nexport function compact(\n\tthis: AgentSession,\n\toptions: Partial<VerbatimCompactionParameters> = {},\n): Promise<VerbatimCompactionResult> {\n\tconst inFlight = this._manualCompactionPromise;\n\tif (inFlight) return inFlight;\n\n\t// A manual boundary replaces the automatic turn that scheduled any pending\n\t// retry. Invalidate its timer before this run claims compaction ownership.\n\tthis._postCompactionContinuationToken += 1;\n\tthis._pendingPostCompactionContinuation = undefined;\n\n\tconst automaticCompletion = this._autoCompactionCompletion;\n\t// The manual request wins. Abort the active automatic planner now, before the\n\t// next microtask can admit a post-tool or threshold boundary, then wait for\n\t// its owner to settle before mutating the transcript ourselves. Start the\n\t// session abort before publishing this new manual owner so abort() cancels\n\t// prior work rather than cancelling or waiting on the compaction being started.\n\tthis._autoCompactionAbortController?.abort();\n\tconst abortBoundary = this.abort();\n\n\tconst controller = new AbortController();\n\tthis._compactionAbortController = controller;\n\tthis._compactionReason = \"manual\";\n\t// Handle rejection now so a failing event drain cannot become unhandled\n\t// while an automatic run finishes.\n\tvoid abortBoundary.catch(() => {});\n\tlet flight!: Promise<VerbatimCompactionResult>;\n\t// Start the owned run in a microtask so both single-flight fields are\n\t// published before any joiner can observe a partially claimed compaction.\n\tflight = Promise.resolve()\n\t\t.then(async () => {\n\t\t\ttry {\n\t\t\t\tif (automaticCompletion !== undefined) await automaticCompletion;\n\t\t\t\tawait abortBoundary;\n\t\t\t} catch (error) {\n\t\t\t\t// The abort drain can fail before the planner starts. Finish the\n\t\t\t\t// manual lifecycle so event consumers can release queued input.\n\t\t\t\tawait emitManualCompactionFailure.call(this, controller, error, false);\n\t\t\t\tthrow error;\n\t\t\t}\n\t\t\treturn runOwnedManualCompaction.call(this, controller, options);\n\t\t})\n\t\t.finally(() => {\n\t\t\tclearOwnedManualCompactionState.call(this, controller);\n\t\t\tif (this._manualCompactionPromise === flight) this._manualCompactionPromise = undefined;\n\t\t});\n\tthis._manualCompactionPromise = flight;\n\treturn flight;\n}\n\nexport function abortCompaction(this: AgentSession): void {\n\tthis._compactionAbortController?.abort();\n\tthis._autoCompactionAbortController?.abort();\n}\nexport function abortBranchSummary(this: AgentSession): void {\n\tthis._branchSummaryAbortController?.abort();\n}\nexport function setAutoCompactionEnabled(this: AgentSession, enabled: boolean): void {\n\tthis.settingsManager.setCompactionEnabled(enabled);\n}\n\nexport const agentSessionCompactionMethods = {\n\t_applyVerbatimCompaction,\n\tcompact,\n\tabortCompaction,\n\tabortBranchSummary,\n\tsetAutoCompactionEnabled,\n};\n"]}
|
|
@@ -327,6 +327,7 @@ export interface AgentSessionInternalSurface extends AgentSessionMethodSurface,
|
|
|
327
327
|
_recoverableLengthRecoveryAttempted: boolean;
|
|
328
328
|
_contextOverflowUnresolved: boolean;
|
|
329
329
|
_branchSummaryAbortController: AbortController | undefined;
|
|
330
|
+
_branchSummaryCompletion: Promise<void> | undefined;
|
|
330
331
|
_retryAbortController: AbortController | undefined;
|
|
331
332
|
_retryAttempt: number;
|
|
332
333
|
_retryPromise: Promise<void> | undefined;
|