@bastani/atomic 0.9.27 → 0.9.28-alpha.2
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 +61 -0
- package/dist/builtin/intercom/CHANGELOG.md +6 -0
- package/dist/builtin/intercom/broker/broker.ts +13 -1
- package/dist/builtin/intercom/package.json +2 -2
- package/dist/builtin/mcp/CHANGELOG.md +6 -0
- package/dist/builtin/mcp/package.json +1 -1
- package/dist/builtin/subagents/package.json +3 -3
- package/dist/builtin/web-access/index.bundle.mjs +194 -44
- package/dist/builtin/web-access/package.json +3 -3
- package/dist/builtin/workflows/CHANGELOG.md +31 -0
- package/dist/builtin/workflows/builtin/{chunk-gw7rghda.js → chunk-aqv8ny38.js} +257 -259
- package/dist/builtin/workflows/builtin/{chunk-gts8wgjr.js → chunk-br4ac9a3.js} +1 -1
- package/dist/builtin/workflows/builtin/{chunk-9bhs02gm.js → chunk-p3xmajmj.js} +439 -40
- package/dist/builtin/workflows/builtin/chunk-p6jagvyf.js +8 -0
- package/dist/builtin/workflows/builtin/goal.js +2 -2
- package/dist/builtin/workflows/builtin/index.js +4 -4
- package/dist/builtin/workflows/builtin/ralph.js +2 -2
- package/dist/builtin/workflows/package.json +2 -2
- package/dist/builtin/workflows/src/authoring.d.ts +14 -0
- package/dist/builtin/workflows/src/extension/index.bundle.mjs +108110 -107201
- package/dist/builtin/workflows/src/index.js +42226 -41077
- package/dist/builtin/workflows/src/shared/authoring-contract-stage.d.ts +16 -11
- package/dist/builtin/workflows/src/shared/authoring-contract-ui.d.ts +16 -1
- package/dist/cli/args.d.ts +1 -0
- package/dist/cli/args.d.ts.map +1 -1
- package/dist/cli/args.js +12 -5
- package/dist/cli/args.js.map +1 -1
- package/dist/cli/credential-print.d.ts +1 -1
- package/dist/cli/credential-print.d.ts.map +1 -1
- package/dist/cli/credential-print.js +2 -56
- package/dist/cli/credential-print.js.map +1 -1
- package/dist/codemode-worker.js +99 -3
- package/dist/core/agent-session-accessors.d.ts.map +1 -1
- package/dist/core/agent-session-accessors.js +6 -1
- package/dist/core/agent-session-accessors.js.map +1 -1
- package/dist/core/agent-session-compaction.d.ts.map +1 -1
- package/dist/core/agent-session-compaction.js +20 -3
- package/dist/core/agent-session-compaction.js.map +1 -1
- package/dist/core/agent-session-events.d.ts.map +1 -1
- package/dist/core/agent-session-events.js +3 -2
- package/dist/core/agent-session-events.js.map +1 -1
- package/dist/core/agent-session-extension-bindings.d.ts +6 -0
- package/dist/core/agent-session-extension-bindings.d.ts.map +1 -1
- package/dist/core/agent-session-extension-bindings.js +96 -12
- package/dist/core/agent-session-extension-bindings.js.map +1 -1
- package/dist/core/agent-session-methods.d.ts +4 -1
- 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-prompt.d.ts.map +1 -1
- package/dist/core/agent-session-prompt.js +19 -3
- package/dist/core/agent-session-prompt.js.map +1 -1
- package/dist/core/agent-session-services.d.ts +1 -0
- package/dist/core/agent-session-services.d.ts.map +1 -1
- package/dist/core/agent-session-services.js +1 -0
- package/dist/core/agent-session-services.js.map +1 -1
- package/dist/core/agent-session-state.d.ts.map +1 -1
- package/dist/core/agent-session-state.js +3 -2
- package/dist/core/agent-session-state.js.map +1 -1
- package/dist/core/agent-session-tool-registry.d.ts.map +1 -1
- package/dist/core/agent-session-tool-registry.js +11 -16
- package/dist/core/agent-session-tool-registry.js.map +1 -1
- package/dist/core/agent-session-types.d.ts +1 -0
- package/dist/core/agent-session-types.d.ts.map +1 -1
- package/dist/core/agent-session-types.js.map +1 -1
- package/dist/core/agent-session.d.ts +2 -0
- package/dist/core/agent-session.d.ts.map +1 -1
- package/dist/core/agent-session.js +5 -0
- package/dist/core/agent-session.js.map +1 -1
- package/dist/core/auth-storage-backends.d.ts.map +1 -1
- package/dist/core/auth-storage-backends.js +2 -1
- package/dist/core/auth-storage-backends.js.map +1 -1
- package/dist/core/auth-storage.d.ts +1 -1
- package/dist/core/auth-storage.d.ts.map +1 -1
- package/dist/core/auth-storage.js +15 -7
- package/dist/core/auth-storage.js.map +1 -1
- package/dist/core/azure-provider-compat.d.ts +8 -0
- package/dist/core/azure-provider-compat.d.ts.map +1 -0
- package/dist/core/azure-provider-compat.js +65 -0
- package/dist/core/azure-provider-compat.js.map +1 -0
- package/dist/core/child-session-options.d.ts +1 -1
- package/dist/core/child-session-options.d.ts.map +1 -1
- package/dist/core/child-session-options.js +11 -2
- package/dist/core/child-session-options.js.map +1 -1
- package/dist/core/compaction/classifier-compaction.d.ts +13 -0
- package/dist/core/compaction/classifier-compaction.d.ts.map +1 -0
- package/dist/core/compaction/classifier-compaction.js +110 -0
- package/dist/core/compaction/classifier-compaction.js.map +1 -0
- package/dist/core/compaction/compaction-boundary.d.ts.map +1 -1
- package/dist/core/compaction/compaction-boundary.js +2 -6
- package/dist/core/compaction/compaction-boundary.js.map +1 -1
- package/dist/core/compaction/compaction-runner.d.ts +16 -1
- package/dist/core/compaction/compaction-runner.d.ts.map +1 -1
- package/dist/core/compaction/compaction-runner.js +97 -12
- package/dist/core/compaction/compaction-runner.js.map +1 -1
- package/dist/core/compaction/compaction-types.d.ts +18 -1
- package/dist/core/compaction/compaction-types.d.ts.map +1 -1
- package/dist/core/compaction/compaction-types.js +1 -1
- package/dist/core/compaction/compaction-types.js.map +1 -1
- package/dist/core/compaction/fallback-planner.d.ts +1 -0
- package/dist/core/compaction/fallback-planner.d.ts.map +1 -1
- package/dist/core/compaction/fallback-planner.js +2 -0
- package/dist/core/compaction/fallback-planner.js.map +1 -1
- package/dist/core/compaction/index.d.ts +3 -0
- package/dist/core/compaction/index.d.ts.map +1 -1
- package/dist/core/compaction/index.js +3 -0
- package/dist/core/compaction/index.js.map +1 -1
- package/dist/core/compaction/model-resolver.d.ts +16 -0
- package/dist/core/compaction/model-resolver.d.ts.map +1 -0
- package/dist/core/compaction/model-resolver.js +18 -0
- package/dist/core/compaction/model-resolver.js.map +1 -0
- package/dist/core/compaction/morph-compaction.d.ts +14 -0
- package/dist/core/compaction/morph-compaction.d.ts.map +1 -0
- package/dist/core/compaction/morph-compaction.js +99 -0
- package/dist/core/compaction/morph-compaction.js.map +1 -0
- package/dist/core/compaction/pi-summary-fallback.d.ts +34 -0
- package/dist/core/compaction/pi-summary-fallback.d.ts.map +1 -0
- package/dist/core/compaction/pi-summary-fallback.js +357 -0
- package/dist/core/compaction/pi-summary-fallback.js.map +1 -0
- package/dist/core/compaction/planner-outcome.d.ts +10 -6
- package/dist/core/compaction/planner-outcome.d.ts.map +1 -1
- package/dist/core/compaction/planner-outcome.js +11 -4
- package/dist/core/compaction/planner-outcome.js.map +1 -1
- package/dist/core/compaction/range-planner-diagnostics.d.ts +3 -1
- package/dist/core/compaction/range-planner-diagnostics.d.ts.map +1 -1
- package/dist/core/compaction/range-planner-diagnostics.js +11 -0
- package/dist/core/compaction/range-planner-diagnostics.js.map +1 -1
- package/dist/core/compaction/range-planner.d.ts +3 -3
- package/dist/core/compaction/range-planner.d.ts.map +1 -1
- package/dist/core/compaction/range-planner.js +59 -28
- package/dist/core/compaction/range-planner.js.map +1 -1
- package/dist/core/compaction/region-trimming.d.ts.map +1 -1
- package/dist/core/compaction/region-trimming.js +7 -0
- package/dist/core/compaction/region-trimming.js.map +1 -1
- package/dist/core/compaction/structured-compaction-input.d.ts +19 -0
- package/dist/core/compaction/structured-compaction-input.d.ts.map +1 -0
- package/dist/core/compaction/structured-compaction-input.js +70 -0
- package/dist/core/compaction/structured-compaction-input.js.map +1 -0
- package/dist/core/compaction/transcript-serialization.d.ts +1 -0
- package/dist/core/compaction/transcript-serialization.d.ts.map +1 -1
- package/dist/core/compaction/transcript-serialization.js +26 -0
- package/dist/core/compaction/transcript-serialization.js.map +1 -1
- package/dist/core/extensions/api-types.d.ts +3 -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 +1 -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/loader-api.d.ts.map +1 -1
- package/dist/core/extensions/loader-api.js +5 -0
- package/dist/core/extensions/loader-api.js.map +1 -1
- package/dist/core/extensions/loader-host-modules.d.ts +1 -0
- package/dist/core/extensions/loader-host-modules.d.ts.map +1 -1
- package/dist/core/extensions/loader-host-modules.js +12 -0
- package/dist/core/extensions/loader-host-modules.js.map +1 -1
- package/dist/core/extensions/runner-context.d.ts +10 -4
- package/dist/core/extensions/runner-context.d.ts.map +1 -1
- package/dist/core/extensions/runner-context.js +47 -3
- package/dist/core/extensions/runner-context.js.map +1 -1
- package/dist/core/extensions/runner.d.ts +11 -4
- package/dist/core/extensions/runner.d.ts.map +1 -1
- package/dist/core/extensions/runner.js +38 -9
- package/dist/core/extensions/runner.js.map +1 -1
- package/dist/core/extensions/tool-types.d.ts +2 -0
- package/dist/core/extensions/tool-types.d.ts.map +1 -1
- package/dist/core/extensions/tool-types.js.map +1 -1
- package/dist/core/extensions/workflow-events.d.ts +49 -0
- package/dist/core/extensions/workflow-events.d.ts.map +1 -1
- package/dist/core/extensions/workflow-events.js.map +1 -1
- package/dist/core/extensions/workflow-run-control-hub.d.ts +16 -4
- package/dist/core/extensions/workflow-run-control-hub.d.ts.map +1 -1
- package/dist/core/extensions/workflow-run-control-hub.js +72 -1
- package/dist/core/extensions/workflow-run-control-hub.js.map +1 -1
- package/dist/core/extensions/workflow-run-control.d.ts +11 -3
- package/dist/core/extensions/workflow-run-control.d.ts.map +1 -1
- package/dist/core/extensions/workflow-run-control.js.map +1 -1
- package/dist/core/fast-model-variants.d.ts +1 -1
- package/dist/core/fast-model-variants.js +1 -1
- package/dist/core/fast-model-variants.js.map +1 -1
- package/dist/core/keybindings.d.ts +4 -4
- package/dist/core/messages.d.ts +1 -0
- package/dist/core/messages.d.ts.map +1 -1
- package/dist/core/messages.js +5 -1
- package/dist/core/messages.js.map +1 -1
- package/dist/core/model-config.d.ts.map +1 -1
- package/dist/core/model-config.js +2 -1
- package/dist/core/model-config.js.map +1 -1
- package/dist/core/model-fallback-failures.d.ts.map +1 -1
- package/dist/core/model-fallback-failures.js +5 -1
- package/dist/core/model-fallback-failures.js.map +1 -1
- package/dist/core/model-resolver-cli.d.ts.map +1 -1
- package/dist/core/model-resolver-cli.js +5 -1
- package/dist/core/model-resolver-cli.js.map +1 -1
- package/dist/core/model-resolver-defaults.js +1 -1
- package/dist/core/model-resolver-defaults.js.map +1 -1
- package/dist/core/model-resolver-initial.d.ts.map +1 -1
- package/dist/core/model-resolver-initial.js +6 -1
- package/dist/core/model-resolver-initial.js.map +1 -1
- package/dist/core/model-resolver-patterns.d.ts.map +1 -1
- package/dist/core/model-resolver-patterns.js +2 -1
- package/dist/core/model-resolver-patterns.js.map +1 -1
- package/dist/core/model-resolver-scope.d.ts.map +1 -1
- package/dist/core/model-resolver-scope.js +3 -1
- package/dist/core/model-resolver-scope.js.map +1 -1
- package/dist/core/model-runtime-streaming.d.ts.map +1 -1
- package/dist/core/model-runtime-streaming.js +2 -0
- package/dist/core/model-runtime-streaming.js.map +1 -1
- package/dist/core/model-runtime.d.ts.map +1 -1
- package/dist/core/model-runtime.js +48 -22
- 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 +4 -1
- package/dist/core/provider-composer-internal.js.map +1 -1
- package/dist/core/provider-display-names.js +1 -1
- package/dist/core/provider-display-names.js.map +1 -1
- package/dist/core/remote-catalog-provider.d.ts.map +1 -1
- package/dist/core/remote-catalog-provider.js +3 -0
- package/dist/core/remote-catalog-provider.js.map +1 -1
- package/dist/core/resource-loader-core.d.ts +1 -0
- package/dist/core/resource-loader-core.d.ts.map +1 -1
- package/dist/core/resource-loader-core.js +4 -0
- package/dist/core/resource-loader-core.js.map +1 -1
- package/dist/core/resource-loader-internals.d.ts +1 -0
- package/dist/core/resource-loader-internals.d.ts.map +1 -1
- package/dist/core/resource-loader-internals.js.map +1 -1
- package/dist/core/resource-loader-reload.d.ts.map +1 -1
- package/dist/core/resource-loader-reload.js +28 -5
- package/dist/core/resource-loader-reload.js.map +1 -1
- package/dist/core/resource-loader-types.d.ts +2 -0
- package/dist/core/resource-loader-types.d.ts.map +1 -1
- package/dist/core/resource-loader-types.js.map +1 -1
- package/dist/core/sdk-types.d.ts +6 -4
- package/dist/core/sdk-types.d.ts.map +1 -1
- package/dist/core/sdk-types.js.map +1 -1
- package/dist/core/sdk.d.ts.map +1 -1
- package/dist/core/sdk.js +5 -3
- package/dist/core/sdk.js.map +1 -1
- package/dist/core/session-lifecycle-work.d.ts +2 -1
- package/dist/core/session-lifecycle-work.d.ts.map +1 -1
- package/dist/core/session-lifecycle-work.js +15 -1
- package/dist/core/session-lifecycle-work.js.map +1 -1
- package/dist/core/session-manager-history.d.ts.map +1 -1
- package/dist/core/session-manager-history.js +4 -2
- package/dist/core/session-manager-history.js.map +1 -1
- package/dist/core/settings-manager-basic-accessors.d.ts +2 -0
- package/dist/core/settings-manager-basic-accessors.d.ts.map +1 -1
- package/dist/core/settings-manager-basic-accessors.js +33 -4
- package/dist/core/settings-manager-basic-accessors.js.map +1 -1
- package/dist/core/settings-manager-core.d.ts.map +1 -1
- package/dist/core/settings-manager-core.js +2 -0
- package/dist/core/settings-manager-core.js.map +1 -1
- package/dist/core/settings-storage.d.ts.map +1 -1
- package/dist/core/settings-storage.js +2 -1
- package/dist/core/settings-storage.js.map +1 -1
- package/dist/core/settings-types.d.ts +1 -0
- 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 +3 -1
- package/dist/core/skills.js.map +1 -1
- package/dist/core/system-prompt.d.ts +3 -0
- package/dist/core/system-prompt.d.ts.map +1 -1
- package/dist/core/system-prompt.js +7 -3
- package/dist/core/system-prompt.js.map +1 -1
- package/dist/core/tool-loadout.d.ts.map +1 -1
- package/dist/core/tool-loadout.js +8 -1
- package/dist/core/tool-loadout.js.map +1 -1
- package/dist/core/tool-selection.d.ts +13 -0
- package/dist/core/tool-selection.d.ts.map +1 -0
- package/dist/core/tool-selection.js +43 -0
- package/dist/core/tool-selection.js.map +1 -0
- package/dist/core/tools/read.d.ts +7 -0
- package/dist/core/tools/read.d.ts.map +1 -1
- package/dist/core/tools/read.js +11 -1
- package/dist/core/tools/read.js.map +1 -1
- package/dist/core/transcript.d.ts +58 -0
- package/dist/core/transcript.d.ts.map +1 -0
- package/dist/core/transcript.js +185 -0
- package/dist/core/transcript.js.map +1 -0
- package/dist/extensions/codemode/execute.d.ts.map +1 -1
- package/dist/extensions/codemode/execute.js +2 -1
- package/dist/extensions/codemode/execute.js.map +1 -1
- package/dist/extensions/codemode/index.d.ts.map +1 -1
- package/dist/extensions/codemode/index.js +1 -0
- package/dist/extensions/codemode/index.js.map +1 -1
- package/dist/extensions/codemode/tool.d.ts +4 -1
- package/dist/extensions/codemode/tool.d.ts.map +1 -1
- package/dist/extensions/codemode/tool.js +6 -3
- package/dist/extensions/codemode/tool.js.map +1 -1
- package/dist/extensions/herdr/index.d.ts.map +1 -1
- package/dist/extensions/herdr/index.js +15 -10
- package/dist/extensions/herdr/index.js.map +1 -1
- package/dist/extensions/herdr/pane-owner.d.ts +6 -2
- package/dist/extensions/herdr/pane-owner.d.ts.map +1 -1
- package/dist/extensions/herdr/pane-owner.js +19 -4
- package/dist/extensions/herdr/pane-owner.js.map +1 -1
- package/dist/extensions/mcp/client/oauth/flow.d.ts.map +1 -1
- package/dist/extensions/mcp/client/oauth/flow.js +14 -1
- package/dist/extensions/mcp/client/oauth/flow.js.map +1 -1
- package/dist/extensions/mcp/client/oauth/types.d.ts +1 -0
- package/dist/extensions/mcp/client/oauth/types.d.ts.map +1 -1
- package/dist/extensions/mcp/client/oauth/types.js.map +1 -1
- package/dist/extensions/mcp/index.js.map +1 -1
- package/dist/extensions/mcp/runtime.d.ts +5 -2
- package/dist/extensions/mcp/runtime.d.ts.map +1 -1
- package/dist/extensions/mcp/runtime.js +18 -4
- package/dist/extensions/mcp/runtime.js.map +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/dist/main.d.ts.map +1 -1
- package/dist/main.js +2 -0
- package/dist/main.js.map +1 -1
- package/dist/migrations-azure.d.ts +4 -0
- package/dist/migrations-azure.d.ts.map +1 -0
- package/dist/migrations-azure.js +41 -0
- package/dist/migrations-azure.js.map +1 -0
- package/dist/migrations.d.ts.map +1 -1
- package/dist/migrations.js +2 -0
- package/dist/migrations.js.map +1 -1
- package/dist/modes/interactive/components/chat-session-host-state.d.ts.map +1 -1
- package/dist/modes/interactive/components/chat-session-host-state.js +2 -1
- package/dist/modes/interactive/components/chat-session-host-state.js.map +1 -1
- package/dist/modes/interactive/components/chat-transcript.d.ts +2 -0
- package/dist/modes/interactive/components/chat-transcript.d.ts.map +1 -1
- package/dist/modes/interactive/components/chat-transcript.js +9 -3
- package/dist/modes/interactive/components/chat-transcript.js.map +1 -1
- package/dist/modes/interactive/components/compaction-boundary-message.d.ts +2 -0
- package/dist/modes/interactive/components/compaction-boundary-message.d.ts.map +1 -1
- package/dist/modes/interactive/components/compaction-boundary-message.js +15 -3
- package/dist/modes/interactive/components/compaction-boundary-message.js.map +1 -1
- package/dist/modes/interactive/components/settings-selector-items.d.ts.map +1 -1
- package/dist/modes/interactive/components/settings-selector-items.js +43 -0
- package/dist/modes/interactive/components/settings-selector-items.js.map +1 -1
- package/dist/modes/interactive/components/settings-selector-types.d.ts +6 -0
- package/dist/modes/interactive/components/settings-selector-types.d.ts.map +1 -1
- package/dist/modes/interactive/components/settings-selector-types.js.map +1 -1
- package/dist/modes/interactive/interactive-prompt-turn.js +6 -4
- package/dist/modes/interactive/interactive-prompt-turn.js.map +1 -1
- package/dist/modes/interactive/interactive-render-chat.js +13 -1
- package/dist/modes/interactive/interactive-render-chat.js.map +1 -1
- package/dist/modes/interactive/interactive-selectors.js +8 -0
- package/dist/modes/interactive/interactive-selectors.js.map +1 -1
- package/dist/modes/interactive/interactive-session-runtime.js +2 -0
- package/dist/modes/interactive/interactive-session-runtime.js.map +1 -1
- package/dist/modes/interactive/interactive-startup.js +1 -1
- package/dist/modes/interactive/interactive-startup.js.map +1 -1
- package/dist/modes/interactive/theme/tui-theme.d.ts.map +1 -1
- package/dist/modes/interactive/theme/tui-theme.js +1 -0
- package/dist/modes/interactive/theme/tui-theme.js.map +1 -1
- package/dist/modes/interactive-engine/engine-args.d.ts.map +1 -1
- package/dist/modes/interactive-engine/engine-args.js +1 -0
- package/dist/modes/interactive-engine/engine-args.js.map +1 -1
- package/dist/utils/credential-redaction.d.ts +2 -0
- package/dist/utils/credential-redaction.d.ts.map +1 -0
- package/dist/utils/credential-redaction.js +20 -0
- package/dist/utils/credential-redaction.js.map +1 -0
- package/dist/utils/syntax-highlight.d.ts.map +1 -1
- package/dist/utils/syntax-highlight.js +6 -1
- package/dist/utils/syntax-highlight.js.map +1 -1
- package/docs/codemode.md +3 -2
- package/docs/compaction/reference.md +10 -4
- package/docs/compaction.md +40 -8
- package/docs/docs.json +1 -0
- package/docs/extensions/api-reference.md +18 -0
- package/docs/extensions/authoring.md +1 -1
- package/docs/extensions/events.md +2 -2
- package/docs/extensions.md +2 -0
- package/docs/keybindings.md +9 -9
- package/docs/mcp-servers.md +4 -0
- package/docs/providers.md +33 -3
- package/docs/reference/cli.md +10 -3
- package/docs/sdk/reference.md +16 -1
- package/docs/sdk/web-server.md +325 -0
- package/docs/sdk.md +83 -1
- package/docs/security.md +1 -1
- package/docs/workflows/api-reference.md +74 -4
- package/docs/workflows/authoring.md +6 -2
- package/docs/workflows/builtins.md +4 -0
- package/docs/workflows/operations.md +12 -4
- package/npm-shrinkwrap.json +78 -74
- package/package.json +9 -9
|
@@ -4,6 +4,52 @@ export type WorkflowRunStatus = "pending" | "running" | "paused" | "completed" |
|
|
|
4
4
|
export type WorkflowStageStatus = "pending" | "running" | "awaiting_input" | "paused" | "blocked" | "completed" | "failed" | "skipped";
|
|
5
5
|
export type WorkflowToolNodeStatus = "pending" | "running" | "completed" | "failed" | "cached" | "cancelled";
|
|
6
6
|
export type WorkflowControlAction = "quit" | "kill" | "pause" | "resume";
|
|
7
|
+
/** Snapshot-safe descriptor of a human-input prompt waiting on a workflow graph node. */
|
|
8
|
+
export interface WorkflowGraphNodePrompt {
|
|
9
|
+
id: string;
|
|
10
|
+
kind: "input" | "confirm" | "select" | "editor" | "custom";
|
|
11
|
+
message: string;
|
|
12
|
+
choices?: readonly string[];
|
|
13
|
+
createdAt: number;
|
|
14
|
+
}
|
|
15
|
+
interface WorkflowGraphNodeBase {
|
|
16
|
+
/** Graph-unique node id: run-local in the root run, `${runId}:${nodeId}` inside nested child runs. */
|
|
17
|
+
id: string;
|
|
18
|
+
/** Run that owns the node. */
|
|
19
|
+
runId: string;
|
|
20
|
+
/** Run-local stage id or tool node id. */
|
|
21
|
+
nodeId: string;
|
|
22
|
+
name: string;
|
|
23
|
+
/** Graph-unique ids of the node's parents. */
|
|
24
|
+
parentIds: readonly string[];
|
|
25
|
+
/** Admission order shared by stages and tool nodes within one run. */
|
|
26
|
+
executionOrder?: number;
|
|
27
|
+
/** Nested workflow depth; 0 for the root run. */
|
|
28
|
+
depth: number;
|
|
29
|
+
}
|
|
30
|
+
export interface WorkflowGraphStageNode extends WorkflowGraphNodeBase {
|
|
31
|
+
kind: "stage";
|
|
32
|
+
status: WorkflowStageStatus;
|
|
33
|
+
pendingPrompt?: WorkflowGraphNodePrompt;
|
|
34
|
+
}
|
|
35
|
+
export interface WorkflowGraphToolNode extends WorkflowGraphNodeBase {
|
|
36
|
+
kind: "tool";
|
|
37
|
+
status: WorkflowToolNodeStatus;
|
|
38
|
+
/** Invocation ordinal of this `ctx.tool` call within its run. */
|
|
39
|
+
ordinal: number;
|
|
40
|
+
}
|
|
41
|
+
export type WorkflowGraphNode = WorkflowGraphStageNode | WorkflowGraphToolNode;
|
|
42
|
+
/** A human-input prompt raised by a run itself rather than by one of its stages. */
|
|
43
|
+
export interface WorkflowGraphRunPrompt extends WorkflowGraphNodePrompt {
|
|
44
|
+
/** Run that owns the prompt. */
|
|
45
|
+
runId: string;
|
|
46
|
+
}
|
|
47
|
+
/** Expanded graph of one root run, including nested child workflow runs. */
|
|
48
|
+
export interface WorkflowRootGraph {
|
|
49
|
+
nodes: readonly WorkflowGraphNode[];
|
|
50
|
+
/** Run-level prompts awaiting an answer; absent when there are none. */
|
|
51
|
+
runPrompts?: readonly WorkflowGraphRunPrompt[];
|
|
52
|
+
}
|
|
7
53
|
export interface WorkflowRootActivity {
|
|
8
54
|
rootRunId: string;
|
|
9
55
|
ownerSessionId: string;
|
|
@@ -12,6 +58,8 @@ export interface WorkflowRootActivity {
|
|
|
12
58
|
activeExecutionCount: number;
|
|
13
59
|
actionableBlockCount: number;
|
|
14
60
|
needsAttention: boolean;
|
|
61
|
+
/** Graph topology and node statuses; absent when the publisher reports no graph. */
|
|
62
|
+
graph?: WorkflowRootGraph;
|
|
15
63
|
}
|
|
16
64
|
export interface WorkflowObservationCursor {
|
|
17
65
|
epoch: string;
|
|
@@ -115,4 +163,5 @@ export interface WorkflowObservationDiagnostic {
|
|
|
115
163
|
kind: "ObserverDisposed" | "SourceRecovering" | "SourceUnavailable" | "ObserverDeliveryFailed" | "ObserverOverflow" | "PublisherFenced";
|
|
116
164
|
cursor: WorkflowObservationCursor;
|
|
117
165
|
}
|
|
166
|
+
export {};
|
|
118
167
|
//# sourceMappingURL=workflow-events.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"workflow-events.d.ts","sourceRoot":"","sources":["../../../src/core/extensions/workflow-events.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,qBAAqB,GAAG,SAAS,GAAG,MAAM,GAAG,SAAS,CAAC;AACnE,MAAM,MAAM,sBAAsB,GAC/B,WAAW,GACX,wBAAwB,GACxB,UAAU,GACV,UAAU,GACV,gBAAgB,GAChB,qBAAqB,GACrB,QAAQ,GACR,WAAW,CAAC;AAGf,MAAM,MAAM,iBAAiB,GAC1B,SAAS,GACT,SAAS,GACT,QAAQ,GACR,WAAW,GACX,SAAS,GACT,WAAW,GACX,SAAS,GACT,QAAQ,GACR,QAAQ,CAAC;AACZ,MAAM,MAAM,mBAAmB,GAC5B,SAAS,GACT,SAAS,GACT,gBAAgB,GAChB,QAAQ,GACR,SAAS,GACT,WAAW,GACX,QAAQ,GACR,SAAS,CAAC;AACb,MAAM,MAAM,sBAAsB,GAAG,SAAS,GAAG,SAAS,GAAG,WAAW,GAAG,QAAQ,GAAG,QAAQ,GAAG,WAAW,CAAC;AAC7G,MAAM,MAAM,qBAAqB,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,QAAQ,CAAC;AAEzE,MAAM,WAAW,oBAAoB;IACpC,SAAS,EAAE,MAAM,CAAC;IAClB,cAAc,EAAE,MAAM,CAAC;IACvB,KAAK,EAAE,qBAAqB,CAAC;IAC7B,MAAM,EAAE,sBAAsB,CAAC;IAC/B,oBAAoB,EAAE,MAAM,CAAC;IAC7B,oBAAoB,EAAE,MAAM,CAAC;IAC7B,cAAc,EAAE,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"workflow-events.d.ts","sourceRoot":"","sources":["../../../src/core/extensions/workflow-events.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,qBAAqB,GAAG,SAAS,GAAG,MAAM,GAAG,SAAS,CAAC;AACnE,MAAM,MAAM,sBAAsB,GAC/B,WAAW,GACX,wBAAwB,GACxB,UAAU,GACV,UAAU,GACV,gBAAgB,GAChB,qBAAqB,GACrB,QAAQ,GACR,WAAW,CAAC;AAGf,MAAM,MAAM,iBAAiB,GAC1B,SAAS,GACT,SAAS,GACT,QAAQ,GACR,WAAW,GACX,SAAS,GACT,WAAW,GACX,SAAS,GACT,QAAQ,GACR,QAAQ,CAAC;AACZ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CAAC,GAAG,IAAI,CAAC;IACtE,gBAAgB,CAAC,KAAK,EAAE,sBAAsB,GAAG,IAAI,CAAC;IACtD,OAAO,IAAI,IAAI,CAAC;CAChB;AACD,MAAM,WAAW,6BAA6B;IAC7C,IAAI,EACD,kBAAkB,GAClB,kBAAkB,GAClB,mBAAmB,GACnB,wBAAwB,GACxB,kBAAkB,GAClB,iBAAiB,CAAC;IACrB,MAAM,EAAE,yBAAyB,CAAC;CAClC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"workflow-events.js","sourceRoot":"","sources":["../../../src/core/extensions/workflow-events.ts"],"names":[],"mappings":"","sourcesContent":["export type WorkflowActivityState = \"working\" | \"idle\" | \"blocked\";\nexport type WorkflowActivityReason =\n\t| \"executing\"\n\t| \"automatic_continuation\"\n\t| \"retrying\"\n\t| \"stopping\"\n\t| \"awaiting_input\"\n\t| \"manual_intervention\"\n\t| \"paused\"\n\t| \"quiescent\";\n\n// Kept in sync with workflows/shared/store-types without a host runtime dependency.\nexport type WorkflowRunStatus =\n\t| \"pending\"\n\t| \"running\"\n\t| \"paused\"\n\t| \"completed\"\n\t| \"skipped\"\n\t| \"cancelled\"\n\t| \"blocked\"\n\t| \"failed\"\n\t| \"killed\";\nexport type WorkflowStageStatus =\n\t| \"pending\"\n\t| \"running\"\n\t| \"awaiting_input\"\n\t| \"paused\"\n\t| \"blocked\"\n\t| \"completed\"\n\t| \"failed\"\n\t| \"skipped\";\nexport type WorkflowToolNodeStatus = \"pending\" | \"running\" | \"completed\" | \"failed\" | \"cached\" | \"cancelled\";\nexport type WorkflowControlAction = \"quit\" | \"kill\" | \"pause\" | \"resume\";\n\nexport interface WorkflowRootActivity {\n\trootRunId: string;\n\townerSessionId: string;\n\tstate: WorkflowActivityState;\n\treason: WorkflowActivityReason;\n\tactiveExecutionCount: number;\n\tactionableBlockCount: number;\n\tneedsAttention: boolean;\n}\nexport interface WorkflowObservationCursor {\n\tepoch: string;\n\trevision: number;\n}\nexport type WorkflowActivitySnapshotInput =\n\t| { availability: \"ready\"; roots: readonly WorkflowRootActivity[] }\n\t| { availability: \"recovering\" | \"unavailable\" };\nexport type WorkflowActivitySnapshotFrame = WorkflowActivitySnapshotInput & {\n\tkind: \"snapshot\";\n\tcursor: WorkflowObservationCursor;\n};\nexport type WorkflowActivityFrame =\n\t| WorkflowActivitySnapshotFrame\n\t| { kind: \"changed\"; cursor: WorkflowObservationCursor; root: WorkflowRootActivity }\n\t| { kind: \"removed\"; cursor: WorkflowObservationCursor; rootRunId: string };\nexport type WorkflowActivityObserver = (frame: WorkflowActivityFrame) => void | Promise<void>;\nexport interface WorkflowActivitySubscription {\n\tdispose(): void;\n}\nexport type WorkflowLifecycleDelivery = \"live\" | \"replay\";\nexport type WorkflowLifecycleTarget =\n\t| {\n\t\t\tkind: \"run\";\n\t\t\trunId: string;\n\t\t\tpreviousStatus?: WorkflowRunStatus;\n\t\t\tstatus: WorkflowRunStatus;\n\t\t\taction?: WorkflowControlAction;\n\t }\n\t| {\n\t\t\tkind: \"stage\";\n\t\t\trunId: string;\n\t\t\tstageId: string;\n\t\t\tstageName: string;\n\t\t\tpreviousStatus?: WorkflowStageStatus;\n\t\t\tstatus: WorkflowStageStatus;\n\t }\n\t| {\n\t\t\tkind: \"tool\";\n\t\t\trunId: string;\n\t\t\ttoolNodeId: string;\n\t\t\ttoolName: string;\n\t\t\tpreviousStatus?: WorkflowToolNodeStatus;\n\t\t\tstatus: WorkflowToolNodeStatus;\n\t }\n\t| { kind: \"prompt\"; runId: string; stageId?: string; promptId: string; status: \"opened\" | \"answered\" | \"cancelled\" };\nexport interface WorkflowLifecycleEvent {\n\ttype: \"workflow_lifecycle\";\n\teventId: string;\n\tcursor: WorkflowObservationCursor;\n\trunId: string;\n\trootRunId: string;\n\townerSessionId: string;\n\toccurredAt: number;\n\tobservedAt: number;\n\tdelivery: WorkflowLifecycleDelivery;\n\ttarget: WorkflowLifecycleTarget;\n\tattribution?: \"user\" | \"agent\" | \"scheduler\" | \"recovery\" | \"unknown\";\n}\nexport interface WorkflowStageCompletedEvent extends Omit<WorkflowLifecycleEvent, \"type\" | \"target\"> {\n\ttype: \"workflow_stage_completed\";\n\ttarget: Extract<WorkflowLifecycleTarget, { kind: \"stage\" }> & { status: \"completed\" };\n}\nexport interface WorkflowActivityChangedEvent {\n\ttype: \"workflow_activity_changed\";\n\tcursor: WorkflowObservationCursor;\n\troot: WorkflowRootActivity;\n}\nexport interface WorkflowHeartbeatEvent {\n\ttype: \"workflow_heartbeat\";\n\trunId: string;\n\trootRunId: string;\n\townerSessionId: string;\n\tscheduledAt: number;\n\tintervalMinutes: number;\n}\nexport type WorkflowEvent =\n\t| WorkflowLifecycleEvent\n\t| WorkflowStageCompletedEvent\n\t| WorkflowActivityChangedEvent\n\t| WorkflowHeartbeatEvent;\nexport interface WorkflowActivityPublisher {\n\tpublishSnapshot(input: WorkflowActivitySnapshotInput): void;\n\tpublishChanged(root: WorkflowRootActivity): void;\n\tpublishRemoved(rootRunId: string): void;\n\tpublishLifecycle(event: Omit<WorkflowLifecycleEvent, \"cursor\">): void;\n\tpublishHeartbeat(event: WorkflowHeartbeatEvent): void;\n\tdispose(): void;\n}\nexport interface WorkflowObservationDiagnostic {\n\tkind:\n\t\t| \"ObserverDisposed\"\n\t\t| \"SourceRecovering\"\n\t\t| \"SourceUnavailable\"\n\t\t| \"ObserverDeliveryFailed\"\n\t\t| \"ObserverOverflow\"\n\t\t| \"PublisherFenced\";\n\tcursor: WorkflowObservationCursor;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"workflow-events.js","sourceRoot":"","sources":["../../../src/core/extensions/workflow-events.ts"],"names":[],"mappings":"","sourcesContent":["export type WorkflowActivityState = \"working\" | \"idle\" | \"blocked\";\nexport type WorkflowActivityReason =\n\t| \"executing\"\n\t| \"automatic_continuation\"\n\t| \"retrying\"\n\t| \"stopping\"\n\t| \"awaiting_input\"\n\t| \"manual_intervention\"\n\t| \"paused\"\n\t| \"quiescent\";\n\n// Kept in sync with workflows/shared/store-types without a host runtime dependency.\nexport type WorkflowRunStatus =\n\t| \"pending\"\n\t| \"running\"\n\t| \"paused\"\n\t| \"completed\"\n\t| \"skipped\"\n\t| \"cancelled\"\n\t| \"blocked\"\n\t| \"failed\"\n\t| \"killed\";\nexport type WorkflowStageStatus =\n\t| \"pending\"\n\t| \"running\"\n\t| \"awaiting_input\"\n\t| \"paused\"\n\t| \"blocked\"\n\t| \"completed\"\n\t| \"failed\"\n\t| \"skipped\";\nexport type WorkflowToolNodeStatus = \"pending\" | \"running\" | \"completed\" | \"failed\" | \"cached\" | \"cancelled\";\nexport type WorkflowControlAction = \"quit\" | \"kill\" | \"pause\" | \"resume\";\n\n/** Snapshot-safe descriptor of a human-input prompt waiting on a workflow graph node. */\nexport interface WorkflowGraphNodePrompt {\n\tid: string;\n\tkind: \"input\" | \"confirm\" | \"select\" | \"editor\" | \"custom\";\n\tmessage: string;\n\tchoices?: readonly string[];\n\tcreatedAt: number;\n}\ninterface WorkflowGraphNodeBase {\n\t/** Graph-unique node id: run-local in the root run, `${runId}:${nodeId}` inside nested child runs. */\n\tid: string;\n\t/** Run that owns the node. */\n\trunId: string;\n\t/** Run-local stage id or tool node id. */\n\tnodeId: string;\n\tname: string;\n\t/** Graph-unique ids of the node's parents. */\n\tparentIds: readonly string[];\n\t/** Admission order shared by stages and tool nodes within one run. */\n\texecutionOrder?: number;\n\t/** Nested workflow depth; 0 for the root run. */\n\tdepth: number;\n}\nexport interface WorkflowGraphStageNode extends WorkflowGraphNodeBase {\n\tkind: \"stage\";\n\tstatus: WorkflowStageStatus;\n\tpendingPrompt?: WorkflowGraphNodePrompt;\n}\nexport interface WorkflowGraphToolNode extends WorkflowGraphNodeBase {\n\tkind: \"tool\";\n\tstatus: WorkflowToolNodeStatus;\n\t/** Invocation ordinal of this `ctx.tool` call within its run. */\n\tordinal: number;\n}\nexport type WorkflowGraphNode = WorkflowGraphStageNode | WorkflowGraphToolNode;\n/** A human-input prompt raised by a run itself rather than by one of its stages. */\nexport interface WorkflowGraphRunPrompt extends WorkflowGraphNodePrompt {\n\t/** Run that owns the prompt. */\n\trunId: string;\n}\n/** Expanded graph of one root run, including nested child workflow runs. */\nexport interface WorkflowRootGraph {\n\tnodes: readonly WorkflowGraphNode[];\n\t/** Run-level prompts awaiting an answer; absent when there are none. */\n\trunPrompts?: readonly WorkflowGraphRunPrompt[];\n}\n\nexport interface WorkflowRootActivity {\n\trootRunId: string;\n\townerSessionId: string;\n\tstate: WorkflowActivityState;\n\treason: WorkflowActivityReason;\n\tactiveExecutionCount: number;\n\tactionableBlockCount: number;\n\tneedsAttention: boolean;\n\t/** Graph topology and node statuses; absent when the publisher reports no graph. */\n\tgraph?: WorkflowRootGraph;\n}\nexport interface WorkflowObservationCursor {\n\tepoch: string;\n\trevision: number;\n}\nexport type WorkflowActivitySnapshotInput =\n\t| { availability: \"ready\"; roots: readonly WorkflowRootActivity[] }\n\t| { availability: \"recovering\" | \"unavailable\" };\nexport type WorkflowActivitySnapshotFrame = WorkflowActivitySnapshotInput & {\n\tkind: \"snapshot\";\n\tcursor: WorkflowObservationCursor;\n};\nexport type WorkflowActivityFrame =\n\t| WorkflowActivitySnapshotFrame\n\t| { kind: \"changed\"; cursor: WorkflowObservationCursor; root: WorkflowRootActivity }\n\t| { kind: \"removed\"; cursor: WorkflowObservationCursor; rootRunId: string };\nexport type WorkflowActivityObserver = (frame: WorkflowActivityFrame) => void | Promise<void>;\nexport interface WorkflowActivitySubscription {\n\tdispose(): void;\n}\nexport type WorkflowLifecycleDelivery = \"live\" | \"replay\";\nexport type WorkflowLifecycleTarget =\n\t| {\n\t\t\tkind: \"run\";\n\t\t\trunId: string;\n\t\t\tpreviousStatus?: WorkflowRunStatus;\n\t\t\tstatus: WorkflowRunStatus;\n\t\t\taction?: WorkflowControlAction;\n\t }\n\t| {\n\t\t\tkind: \"stage\";\n\t\t\trunId: string;\n\t\t\tstageId: string;\n\t\t\tstageName: string;\n\t\t\tpreviousStatus?: WorkflowStageStatus;\n\t\t\tstatus: WorkflowStageStatus;\n\t }\n\t| {\n\t\t\tkind: \"tool\";\n\t\t\trunId: string;\n\t\t\ttoolNodeId: string;\n\t\t\ttoolName: string;\n\t\t\tpreviousStatus?: WorkflowToolNodeStatus;\n\t\t\tstatus: WorkflowToolNodeStatus;\n\t }\n\t| { kind: \"prompt\"; runId: string; stageId?: string; promptId: string; status: \"opened\" | \"answered\" | \"cancelled\" };\nexport interface WorkflowLifecycleEvent {\n\ttype: \"workflow_lifecycle\";\n\teventId: string;\n\tcursor: WorkflowObservationCursor;\n\trunId: string;\n\trootRunId: string;\n\townerSessionId: string;\n\toccurredAt: number;\n\tobservedAt: number;\n\tdelivery: WorkflowLifecycleDelivery;\n\ttarget: WorkflowLifecycleTarget;\n\tattribution?: \"user\" | \"agent\" | \"scheduler\" | \"recovery\" | \"unknown\";\n}\nexport interface WorkflowStageCompletedEvent extends Omit<WorkflowLifecycleEvent, \"type\" | \"target\"> {\n\ttype: \"workflow_stage_completed\";\n\ttarget: Extract<WorkflowLifecycleTarget, { kind: \"stage\" }> & { status: \"completed\" };\n}\nexport interface WorkflowActivityChangedEvent {\n\ttype: \"workflow_activity_changed\";\n\tcursor: WorkflowObservationCursor;\n\troot: WorkflowRootActivity;\n}\nexport interface WorkflowHeartbeatEvent {\n\ttype: \"workflow_heartbeat\";\n\trunId: string;\n\trootRunId: string;\n\townerSessionId: string;\n\tscheduledAt: number;\n\tintervalMinutes: number;\n}\nexport type WorkflowEvent =\n\t| WorkflowLifecycleEvent\n\t| WorkflowStageCompletedEvent\n\t| WorkflowActivityChangedEvent\n\t| WorkflowHeartbeatEvent;\nexport interface WorkflowActivityPublisher {\n\tpublishSnapshot(input: WorkflowActivitySnapshotInput): void;\n\tpublishChanged(root: WorkflowRootActivity): void;\n\tpublishRemoved(rootRunId: string): void;\n\tpublishLifecycle(event: Omit<WorkflowLifecycleEvent, \"cursor\">): void;\n\tpublishHeartbeat(event: WorkflowHeartbeatEvent): void;\n\tdispose(): void;\n}\nexport interface WorkflowObservationDiagnostic {\n\tkind:\n\t\t| \"ObserverDisposed\"\n\t\t| \"SourceRecovering\"\n\t\t| \"SourceUnavailable\"\n\t\t| \"ObserverDeliveryFailed\"\n\t\t| \"ObserverOverflow\"\n\t\t| \"PublisherFenced\";\n\tcursor: WorkflowObservationCursor;\n}\n"]}
|
|
@@ -1,17 +1,29 @@
|
|
|
1
|
-
import
|
|
1
|
+
import type { WorkflowActivityObserver, WorkflowActivitySnapshotFrame, WorkflowActivitySubscription } from "./workflow-events.js";
|
|
2
|
+
import { type SessionWorkflows, type WorkflowRunAllTarget, type WorkflowRunControl, type WorkflowRunControlOutcome, type WorkflowRunControlRegistration, type WorkflowRunDetail, type WorkflowRunListFilter, type WorkflowRunPauseOptions, type WorkflowRunResumeOptions, type WorkflowRunStageSummary, type WorkflowRunSummary, type WorkflowStageListFilter } from "./workflow-run-control.js";
|
|
2
3
|
/** Holds the run-control implementation that the workflows extension registers for one extension generation. */
|
|
3
4
|
export declare class WorkflowRunControlHub {
|
|
4
5
|
private control;
|
|
5
6
|
private disposed;
|
|
6
|
-
register(control:
|
|
7
|
-
current():
|
|
7
|
+
register(control: WorkflowRunControl): WorkflowRunControlRegistration;
|
|
8
|
+
current(): WorkflowRunControl | undefined;
|
|
8
9
|
dispose(): void;
|
|
9
10
|
}
|
|
11
|
+
export type ObserveWorkflowActivity = (observer: WorkflowActivityObserver) => WorkflowActivitySubscription;
|
|
10
12
|
/** Stable per-session handle that follows the current extension generation across reloads. */
|
|
11
13
|
export declare class SessionWorkflowsHandle implements SessionWorkflows {
|
|
12
14
|
private readonly resolve;
|
|
13
|
-
|
|
15
|
+
private readonly resolveObserve;
|
|
16
|
+
private readonly observers;
|
|
17
|
+
constructor(resolve: () => WorkflowRunControl | undefined, resolveObserve: () => ObserveWorkflowActivity | undefined);
|
|
14
18
|
private control;
|
|
19
|
+
observe(observer: WorkflowActivityObserver): WorkflowActivitySubscription;
|
|
20
|
+
/** Move every observer to the current extension generation; each receives that generation's snapshot first. */
|
|
21
|
+
rebindObservers(): void;
|
|
22
|
+
/**
|
|
23
|
+
* Release every observer when the session closes. Each first receives `last` as an `unavailable`
|
|
24
|
+
* snapshot, after any callback already in flight, so hosts never keep showing a closed session's runs.
|
|
25
|
+
*/
|
|
26
|
+
disposeObservers(last: WorkflowActivitySnapshotFrame): Promise<void>;
|
|
15
27
|
listRuns(filter?: WorkflowRunListFilter): Promise<readonly WorkflowRunSummary[]>;
|
|
16
28
|
getRun(runId: string): Promise<WorkflowRunDetail>;
|
|
17
29
|
getStages(runId: string, filter?: WorkflowStageListFilter): Promise<readonly WorkflowRunStageSummary[]>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"workflow-run-control-hub.d.ts","sourceRoot":"","sources":["../../../src/core/extensions/workflow-run-control-hub.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,KAAK,gBAAgB,EACrB,KAAK,oBAAoB,EACzB,KAAK,yBAAyB,EAC9B,KAAK,8BAA8B,EAEnC,KAAK,iBAAiB,EACtB,KAAK,qBAAqB,EAC1B,KAAK,uBAAuB,EAC5B,KAAK,wBAAwB,EAC7B,KAAK,uBAAuB,EAC5B,KAAK,kBAAkB,EACvB,KAAK,uBAAuB,EAC5B,MAAM,2BAA2B,CAAC;
|
|
1
|
+
{"version":3,"file":"workflow-run-control-hub.d.ts","sourceRoot":"","sources":["../../../src/core/extensions/workflow-run-control-hub.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACX,wBAAwB,EACxB,6BAA6B,EAC7B,4BAA4B,EAC5B,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EACN,KAAK,gBAAgB,EACrB,KAAK,oBAAoB,EACzB,KAAK,kBAAkB,EACvB,KAAK,yBAAyB,EAC9B,KAAK,8BAA8B,EAEnC,KAAK,iBAAiB,EACtB,KAAK,qBAAqB,EAC1B,KAAK,uBAAuB,EAC5B,KAAK,wBAAwB,EAC7B,KAAK,uBAAu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M,EAAE,OAAO,CAAC,EAAE,uBAAuB,GAAG,OAAO,CAAC,yBAAyB,CAAC,CAAC;IAC5F,KAAK,CAAC,MAAM,EAAE,oBAAoB,GAAG,OAAO,CAAC,yBAAyB,CAAC,CAAC;IASlE,IAAI,CAAC,MAAM,EAAE,MAAM,GAAG,oBAAoB,GAAG,OAAO,CAAC,yBAAyB,CAAC,CAEpF;IAEK,MAAM,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,wBAAwB,GAAG,OAAO,CAAC,yBAAyB,CAAC,CAElG;CACD"}
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import { WorkflowRunControlUnavailableError, } from "./workflow-run-control.js";
|
|
2
|
+
/** Session disposal waits at most this long for observers to receive the final `unavailable` snapshot. */
|
|
3
|
+
const OBSERVER_FINAL_DELIVERY_TIMEOUT_MS = 5_000;
|
|
2
4
|
/** Holds the run-control implementation that the workflows extension registers for one extension generation. */
|
|
3
5
|
export class WorkflowRunControlHub {
|
|
4
6
|
control;
|
|
@@ -25,8 +27,11 @@ export class WorkflowRunControlHub {
|
|
|
25
27
|
/** Stable per-session handle that follows the current extension generation across reloads. */
|
|
26
28
|
export class SessionWorkflowsHandle {
|
|
27
29
|
resolve;
|
|
28
|
-
|
|
30
|
+
resolveObserve;
|
|
31
|
+
observers = new Set();
|
|
32
|
+
constructor(resolve, resolveObserve) {
|
|
29
33
|
this.resolve = resolve;
|
|
34
|
+
this.resolveObserve = resolveObserve;
|
|
30
35
|
}
|
|
31
36
|
control() {
|
|
32
37
|
const control = this.resolve();
|
|
@@ -34,6 +39,72 @@ export class SessionWorkflowsHandle {
|
|
|
34
39
|
throw new WorkflowRunControlUnavailableError();
|
|
35
40
|
return control;
|
|
36
41
|
}
|
|
42
|
+
observe(observer) {
|
|
43
|
+
const observe = this.resolveObserve();
|
|
44
|
+
if (observe === undefined)
|
|
45
|
+
throw new WorkflowRunControlUnavailableError();
|
|
46
|
+
let active = true;
|
|
47
|
+
let previous = Promise.resolve();
|
|
48
|
+
// Each generation delivers independently; chain them so a reload never overlaps two callbacks.
|
|
49
|
+
const deliver = (frame) => {
|
|
50
|
+
const delivery = previous.then(() => (active ? observer(frame) : undefined));
|
|
51
|
+
previous = delivery.catch(() => { });
|
|
52
|
+
return delivery;
|
|
53
|
+
};
|
|
54
|
+
const lease = {
|
|
55
|
+
deliver,
|
|
56
|
+
close: () => {
|
|
57
|
+
if (!active)
|
|
58
|
+
return;
|
|
59
|
+
active = false;
|
|
60
|
+
lease.subscription.dispose();
|
|
61
|
+
},
|
|
62
|
+
subscription: observe(deliver),
|
|
63
|
+
};
|
|
64
|
+
this.observers.add(lease);
|
|
65
|
+
return {
|
|
66
|
+
// Close even after session disposal took the lease out of the set, so a queued final callback is skipped.
|
|
67
|
+
dispose: () => {
|
|
68
|
+
this.observers.delete(lease);
|
|
69
|
+
lease.close();
|
|
70
|
+
},
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
/** Move every observer to the current extension generation; each receives that generation's snapshot first. */
|
|
74
|
+
rebindObservers() {
|
|
75
|
+
const observe = this.resolveObserve();
|
|
76
|
+
for (const lease of this.observers) {
|
|
77
|
+
lease.subscription.dispose();
|
|
78
|
+
lease.subscription = observe?.(lease.deliver) ?? { dispose: () => { } };
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Release every observer when the session closes. Each first receives `last` as an `unavailable`
|
|
83
|
+
* snapshot, after any callback already in flight, so hosts never keep showing a closed session's runs.
|
|
84
|
+
*/
|
|
85
|
+
async disposeObservers(last) {
|
|
86
|
+
const terminal = last.availability === "unavailable"
|
|
87
|
+
? last
|
|
88
|
+
: {
|
|
89
|
+
kind: "snapshot",
|
|
90
|
+
cursor: { ...last.cursor, revision: last.cursor.revision + 1 },
|
|
91
|
+
availability: "unavailable",
|
|
92
|
+
};
|
|
93
|
+
const leases = [...this.observers];
|
|
94
|
+
this.observers.clear();
|
|
95
|
+
for (const lease of leases)
|
|
96
|
+
lease.subscription.dispose();
|
|
97
|
+
let timer;
|
|
98
|
+
await Promise.race([
|
|
99
|
+
Promise.all(leases.map((lease) => Promise.resolve(lease.deliver(structuredClone(terminal))).catch(() => { }))),
|
|
100
|
+
new Promise((resolve) => {
|
|
101
|
+
timer = setTimeout(resolve, OBSERVER_FINAL_DELIVERY_TIMEOUT_MS);
|
|
102
|
+
}),
|
|
103
|
+
]);
|
|
104
|
+
clearTimeout(timer);
|
|
105
|
+
for (const lease of leases)
|
|
106
|
+
lease.close();
|
|
107
|
+
}
|
|
37
108
|
async listRuns(filter) {
|
|
38
109
|
return this.control().listRuns(filter);
|
|
39
110
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"workflow-run-control-hub.js","sourceRoot":"","sources":["../../../src/core/extensions/workflow-run-control-hub.ts"],"names":[],"mappings":"AAAA,OAAO,EAKN,kCAAkC,GAQlC,MAAM,2BAA2B,CAAC;AAEnC,gHAAgH;AAChH,MAAM,OAAO,qBAAqB;IACzB,OAAO,CAA+B;IACtC,QAAQ,GAAG,KAAK,CAAC;IAEzB,QAAQ,CAAC,OAAyB;QACjC,IAAI,IAAI,CAAC,QAAQ;YAAE,OAAO,EAAE,OAAO,EAAE,GAAG,EAAE,GAAE,CAAC,EAAE,CAAC;QAChD,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACvB,OAAO;YACN,OAAO,EAAE,GAAG,EAAE;gBACb,IAAI,IAAI,CAAC,OAAO,KAAK,OAAO;oBAAE,IAAI,CAAC,OAAO,GAAG,SAAS,CAAC;YACxD,CAAC;SACD,CAAC;IACH,CAAC;IAED,OAAO;QACN,OAAO,IAAI,CAAC,OAAO,CAAC;IACrB,CAAC;IAED,OAAO;QACN,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC;QACrB,IAAI,CAAC,OAAO,GAAG,SAAS,CAAC;IAC1B,CAAC;CACD;AAED,8FAA8F;AAC9F,MAAM,OAAO,sBAAsB;IACjB,OAAO,C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ype WorkflowRunAllTarget,\n\ttype WorkflowRunControlOutcome,\n\ttype WorkflowRunControlRegistration,\n\tWorkflowRunControlUnavailableError,\n\ttype WorkflowRunDetail,\n\ttype WorkflowRunListFilter,\n\ttype WorkflowRunPauseOptions,\n\ttype WorkflowRunResumeOptions,\n\ttype WorkflowRunStageSummary,\n\ttype WorkflowRunSummary,\n\ttype WorkflowStageListFilter,\n} from \"./workflow-run-control.js\";\n\n/** Holds the run-control implementation that the workflows extension registers for one extension generation. */\nexport class WorkflowRunControlHub {\n\tprivate control: SessionWorkflows | undefined;\n\tprivate disposed = false;\n\n\tregister(control: SessionWorkflows): WorkflowRunControlRegistration {\n\t\tif (this.disposed) return { dispose: () => {} };\n\t\tthis.control = control;\n\t\treturn {\n\t\t\tdispose: () => {\n\t\t\t\tif (this.control === control) this.control = undefined;\n\t\t\t},\n\t\t};\n\t}\n\n\tcurrent(): SessionWorkflows | undefined {\n\t\treturn this.control;\n\t}\n\n\tdispose(): void {\n\t\tthis.disposed = true;\n\t\tthis.control = undefined;\n\t}\n}\n\n/** Stable per-session handle that follows the current extension generation across reloads. */\nexport class SessionWorkflowsHandle implements SessionWorkflows {\n\tprivate readonly resolve: () => SessionWorkflows | undefined;\n\n\tconstructor(resolve: () => SessionWorkflows | undefined) {\n\t\tthis.resolve = resolve;\n\t}\n\n\tprivate control(): SessionWorkflows {\n\t\tconst control = this.resolve();\n\t\tif (control === undefined) throw new WorkflowRunControlUnavailableError();\n\t\treturn control;\n\t}\n\n\tasync listRuns(filter?: WorkflowRunListFilter): Promise<readonly WorkflowRunSummary[]> {\n\t\treturn this.control().listRuns(filter);\n\t}\n\n\tasync getRun(runId: string): Promise<WorkflowRunDetail> {\n\t\treturn this.control().getRun(runId);\n\t}\n\n\tasync getStages(runId: string, filter?: WorkflowStageListFilter): Promise<readonly WorkflowRunStageSummary[]> {\n\t\treturn this.control().getStages(runId, filter);\n\t}\n\n\tpause(runId: string, options?: WorkflowRunPauseOptions): Promise<WorkflowRunControlOutcome>;\n\tpause(target: WorkflowRunAllTarget): Promise<WorkflowRunControlOutcome>;\n\tasync pause(\n\t\ttarget: string | WorkflowRunAllTarget,\n\t\toptions?: WorkflowRunPauseOptions,\n\t): Promise<WorkflowRunControlOutcome> {\n\t\tconst control = this.control();\n\t\treturn typeof target === \"string\" ? control.pause(target, options) : control.pause(target);\n\t}\n\n\tasync quit(target: string | WorkflowRunAllTarget): Promise<WorkflowRunControlOutcome> {\n\t\treturn this.control().quit(target);\n\t}\n\n\tasync resume(runId: string, options?: WorkflowRunResumeOptions): Promise<WorkflowRunControlOutcome> {\n\t\treturn this.control().resume(runId, options);\n\t}\n}\n"]}
|
|
1
|
+
{"version":3,"file":"workflow-run-control-hub.js","sourceRoot":"","sources":["../../../src/core/extensions/workflow-run-control-hub.ts"],"names":[],"mappings":"AAKA,OAAO,EAMN,kCAAkC,GAQlC,MAAM,2BAA2B,CAAC;AAEnC,0GAA0G;AAC1G,MAAM,kCAAkC,GAAG,KAAK,CAAC;AAEjD,gHAAgH;AAChH,MAAM,OAAO,qBAAqB;IACzB,OAAO,CAAiC;IACxC,QAAQ,GAAG,KAAK,CAAC;IAEzB,QAAQ,CAAC,OAA2B;QACnC,IAAI,IAAI,CAAC,QAAQ;YAAE,OAAO,EAAE,OAAO,EAAE,GAAG,EAAE,GAAE,CAAC,EAAE,CAAC;QAChD,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACvB,OAAO;YACN,OAAO,EAAE,GAAG,EAAE;gBACb,IAAI,IAAI,CAAC,OAAO,KAAK,OAAO;oBAAE,IAAI,CAAC,OAAO,GAAG,SAAS,CAAC;YACxD,CAAC;SACD,CAAC;IACH,CAAC;IAED,OAAO;QACN,OAAO,IAAI,CAAC,OAAO,CAAC;IACrB,CAAC;IAED,OAAO;QACN,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC;QACrB,IAAI,CAAC,OAAO,GAAG,SAAS,CAAC;IAC1B,CAAC;CACD;AAWD,8FAA8F;AAC9F,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AM,CAAC,CAAC;IACpC,CAAC;IAED,KAAK,CAAC,MAAM,CAAC,KAAa,EAAE,OAAkC;QAC7D,OAAO,IAAI,CAAC,OAAO,EAAE,CAAC,MAAM,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;IAC9C,CAAC;CACD","sourcesContent":["import type {\n\tWorkflowActivityObserver,\n\tWorkflowActivitySnapshotFrame,\n\tWorkflowActivitySubscription,\n} from \"./workflow-events.js\";\nimport {\n\ttype SessionWorkflows,\n\ttype WorkflowRunAllTarget,\n\ttype WorkflowRunControl,\n\ttype WorkflowRunControlOutcome,\n\ttype WorkflowRunControlRegistration,\n\tWorkflowRunControlUnavailableError,\n\ttype WorkflowRunDetail,\n\ttype WorkflowRunListFilter,\n\ttype WorkflowRunPauseOptions,\n\ttype WorkflowRunResumeOptions,\n\ttype WorkflowRunStageSummary,\n\ttype WorkflowRunSummary,\n\ttype WorkflowStageListFilter,\n} from \"./workflow-run-control.js\";\n\n/** Session disposal waits at most this long for observers to receive the final `unavailable` snapshot. */\nconst OBSERVER_FINAL_DELIVERY_TIMEOUT_MS = 5_000;\n\n/** Holds the run-control implementation that the workflows extension registers for one extension generation. */\nexport class WorkflowRunControlHub {\n\tprivate control: WorkflowRunControl | undefined;\n\tprivate disposed = false;\n\n\tregister(control: WorkflowRunControl): WorkflowRunControlRegistration {\n\t\tif (this.disposed) return { dispose: () => {} };\n\t\tthis.control = control;\n\t\treturn {\n\t\t\tdispose: () => {\n\t\t\t\tif (this.control === control) this.control = undefined;\n\t\t\t},\n\t\t};\n\t}\n\n\tcurrent(): WorkflowRunControl | undefined {\n\t\treturn this.control;\n\t}\n\n\tdispose(): void {\n\t\tthis.disposed = true;\n\t\tthis.control = undefined;\n\t}\n}\n\nexport type ObserveWorkflowActivity = (observer: WorkflowActivityObserver) => WorkflowActivitySubscription;\n\ninterface SessionObserverLease {\n\t/** Serialized delivery shared by every generation this observer is bound to. */\n\treadonly deliver: WorkflowActivityObserver;\n\treadonly close: () => void;\n\tsubscription: WorkflowActivitySubscription;\n}\n\n/** Stable per-session handle that follows the current extension generation across reloads. */\nexport class SessionWorkflowsHandle implements SessionWorkflows {\n\tprivate readonly resolve: () => WorkflowRunControl | undefined;\n\tprivate readonly resolveObserve: () => ObserveWorkflowActivity | undefined;\n\tprivate readonly observers = new Set<SessionObserverLease>();\n\n\tconstructor(\n\t\tresolve: () => WorkflowRunControl | undefined,\n\t\tresolveObserve: () => ObserveWorkflowActivity | undefined,\n\t) {\n\t\tthis.resolve = resolve;\n\t\tthis.resolveObserve = resolveObserve;\n\t}\n\n\tprivate control(): WorkflowRunControl {\n\t\tconst control = this.resolve();\n\t\tif (control === undefined) throw new WorkflowRunControlUnavailableError();\n\t\treturn control;\n\t}\n\n\tobserve(observer: WorkflowActivityObserver): WorkflowActivitySubscription {\n\t\tconst observe = this.resolveObserve();\n\t\tif (observe === undefined) throw new WorkflowRunControlUnavailableError();\n\t\tlet active = true;\n\t\tlet previous: Promise<void> = Promise.resolve();\n\t\t// Each generation delivers independently; chain them so a reload never overlaps two callbacks.\n\t\tconst deliver: WorkflowActivityObserver = (frame) => {\n\t\t\tconst delivery = previous.then(() => (active ? observer(frame) : undefined));\n\t\t\tprevious = delivery.catch(() => {});\n\t\t\treturn delivery;\n\t\t};\n\t\tconst lease: SessionObserverLease = {\n\t\t\tdeliver,\n\t\t\tclose: () => {\n\t\t\t\tif (!active) return;\n\t\t\t\tactive = false;\n\t\t\t\tlease.subscription.dispose();\n\t\t\t},\n\t\t\tsubscription: observe(deliver),\n\t\t};\n\t\tthis.observers.add(lease);\n\t\treturn {\n\t\t\t// Close even after session disposal took the lease out of the set, so a queued final callback is skipped.\n\t\t\tdispose: () => {\n\t\t\t\tthis.observers.delete(lease);\n\t\t\t\tlease.close();\n\t\t\t},\n\t\t};\n\t}\n\n\t/** Move every observer to the current extension generation; each receives that generation's snapshot first. */\n\trebindObservers(): void {\n\t\tconst observe = this.resolveObserve();\n\t\tfor (const lease of this.observers) {\n\t\t\tlease.subscription.dispose();\n\t\t\tlease.subscription = observe?.(lease.deliver) ?? { dispose: () => {} };\n\t\t}\n\t}\n\n\t/**\n\t * Release every observer when the session closes. Each first receives `last` as an `unavailable`\n\t * snapshot, after any callback already in flight, so hosts never keep showing a closed session's runs.\n\t */\n\tasync disposeObservers(last: WorkflowActivitySnapshotFrame): Promise<void> {\n\t\tconst terminal: WorkflowActivitySnapshotFrame =\n\t\t\tlast.availability === \"unavailable\"\n\t\t\t\t? last\n\t\t\t\t: {\n\t\t\t\t\t\tkind: \"snapshot\",\n\t\t\t\t\t\tcursor: { ...last.cursor, revision: last.cursor.revision + 1 },\n\t\t\t\t\t\tavailability: \"unavailable\",\n\t\t\t\t\t};\n\t\tconst leases = [...this.observers];\n\t\tthis.observers.clear();\n\t\tfor (const lease of leases) lease.subscription.dispose();\n\t\tlet timer: ReturnType<typeof setTimeout> | undefined;\n\t\tawait Promise.race([\n\t\t\tPromise.all(leases.map((lease) => Promise.resolve(lease.deliver(structuredClone(terminal))).catch(() => {}))),\n\t\t\tnew Promise<void>((resolve) => {\n\t\t\t\ttimer = setTimeout(resolve, OBSERVER_FINAL_DELIVERY_TIMEOUT_MS);\n\t\t\t}),\n\t\t]);\n\t\tclearTimeout(timer);\n\t\tfor (const lease of leases) lease.close();\n\t}\n\n\tasync listRuns(filter?: WorkflowRunListFilter): Promise<readonly WorkflowRunSummary[]> {\n\t\treturn this.control().listRuns(filter);\n\t}\n\n\tasync getRun(runId: string): Promise<WorkflowRunDetail> {\n\t\treturn this.control().getRun(runId);\n\t}\n\n\tasync getStages(runId: string, filter?: WorkflowStageListFilter): Promise<readonly WorkflowRunStageSummary[]> {\n\t\treturn this.control().getStages(runId, filter);\n\t}\n\n\tpause(runId: string, options?: WorkflowRunPauseOptions): Promise<WorkflowRunControlOutcome>;\n\tpause(target: WorkflowRunAllTarget): Promise<WorkflowRunControlOutcome>;\n\tasync pause(\n\t\ttarget: string | WorkflowRunAllTarget,\n\t\toptions?: WorkflowRunPauseOptions,\n\t): Promise<WorkflowRunControlOutcome> {\n\t\tconst control = this.control();\n\t\treturn typeof target === \"string\" ? control.pause(target, options) : control.pause(target);\n\t}\n\n\tasync quit(target: string | WorkflowRunAllTarget): Promise<WorkflowRunControlOutcome> {\n\t\treturn this.control().quit(target);\n\t}\n\n\tasync resume(runId: string, options?: WorkflowRunResumeOptions): Promise<WorkflowRunControlOutcome> {\n\t\treturn this.control().resume(runId, options);\n\t}\n}\n"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { WorkflowRunStatus, WorkflowStageStatus } from "./workflow-events.js";
|
|
1
|
+
import type { WorkflowActivityObserver, WorkflowActivitySubscription, WorkflowRunStatus, WorkflowStageStatus } from "./workflow-events.js";
|
|
2
2
|
export type WorkflowRunJsonValue = string | number | boolean | null | readonly WorkflowRunJsonValue[] | WorkflowRunJsonObject;
|
|
3
3
|
export interface WorkflowRunJsonObject {
|
|
4
4
|
readonly [key: string]: WorkflowRunJsonValue | undefined;
|
|
@@ -105,8 +105,8 @@ export interface WorkflowRunControlOutcome {
|
|
|
105
105
|
readonly abandoned?: boolean;
|
|
106
106
|
readonly failedRuns?: readonly WorkflowRunControlFailedRun[];
|
|
107
107
|
}
|
|
108
|
-
/** Typed run management for the workflow runs owned by one session. */
|
|
109
|
-
export interface
|
|
108
|
+
/** Typed run management for the workflow runs owned by one session, as registered by the workflows extension. */
|
|
109
|
+
export interface WorkflowRunControl {
|
|
110
110
|
listRuns(filter?: WorkflowRunListFilter): Promise<readonly WorkflowRunSummary[]>;
|
|
111
111
|
getRun(runId: string): Promise<WorkflowRunDetail>;
|
|
112
112
|
getStages(runId: string, filter?: WorkflowStageListFilter): Promise<readonly WorkflowRunStageSummary[]>;
|
|
@@ -115,6 +115,14 @@ export interface SessionWorkflows {
|
|
|
115
115
|
quit(target: string | WorkflowRunAllTarget): Promise<WorkflowRunControlOutcome>;
|
|
116
116
|
resume(runId: string, options?: WorkflowRunResumeOptions): Promise<WorkflowRunControlOutcome>;
|
|
117
117
|
}
|
|
118
|
+
/** `session.workflows`: run management plus observation of the workflow runs owned by one session. */
|
|
119
|
+
export interface SessionWorkflows extends WorkflowRunControl {
|
|
120
|
+
/**
|
|
121
|
+
* Follow root activity and graph changes. Delivers a snapshot frame first, then FIFO
|
|
122
|
+
* `changed` and `removed` frames; the subscription follows extension reloads.
|
|
123
|
+
*/
|
|
124
|
+
observe(observer: WorkflowActivityObserver): WorkflowActivitySubscription;
|
|
125
|
+
}
|
|
118
126
|
export interface WorkflowRunControlRegistration {
|
|
119
127
|
dispose(): void;
|
|
120
128
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"workflow-run-control.d.ts","sourceRoot":"","sources":["../../../src/core/extensions/workflow-run-control.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"workflow-run-control.d.ts","sourceRoot":"","sources":["../../../src/core/extensions/workflow-run-control.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACX,wBAAwB,EACxB,4BAA4B,EAC5B,iBAAiB,EACjB,mBAAmB,EACnB,MAAM,sBAAsB,CAAC;AAE9B,MAAM,MAAM,oBAAoB,GAC7B,MAAM,GACN,MAAM,GACN,OAAO,GACP,IAAI,GACJ,SAAS,oBAAoB,EAAE,GAC/B,qBAAqB,CAAC;AAEzB,MAAM,WAAW,qBAAqB;IACrC,QAAQ,EAAE,GAAG,EAAE,MAAM,GAAG,oBAAoB,GAAG,SAAS,CAAC;CACzD;AAED,MAAM,MAAM,uBAAuB,GAAG,iBAAiB,GAAG,mBAAmB,GAAG,gBAAgB,CAAC;AAEjG,MAAM,WAAW,qBAAqB;IACrC,4FAA4F;IAC5F,QAAQ,CAAC,MAAM,CAAC,EAAE,uBAAuB,CAAC;CAC1C;AAED,MAAM,WAAW,uBAAuB;IACvC,QAAQ,CAAC,MAAM,CAAC,EAAE,mBAAmB,CAAC;CACtC;AAED,MAAM,WAAW,sBAAsB;IACtC,QAAQ,CAA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AgE;AAChE,qBAAa,wBAAyB,SAAQ,uBAAuB;IACpE,YAAY,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,8BAA8B,EAGpE;CACD;AAED,yFAAyF;AACzF,qBAAa,yBAA0B,SAAQ,uBAAuB;IACrE,YAAY,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,8BAA8B,EAGpE;CACD;AAED,mGAAmG;AACnG,qBAAa,4BAA6B,SAAQ,uBAAuB;IACxE,YAAY,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,8BAA8B,EAGpE;CACD;AAED,qEAAqE;AACrE,qBAAa,0BAA2B,SAAQ,uBAAuB;IACtE,YAAY,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,8BAA8B,EAGpE;CACD;AAED,sGAAsG;AACtG,qBAAa,2BAA4B,SAAQ,uBAAuB;IACvE,YAAY,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,8BAA8B,EAGpE;CACD;AAED,qFAAqF;AACrF,qBAAa,mCAAoC,SAAQ,uBAAuB;IAC/E,YAAY,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,8BAA8B,EAGpE;CACD;AAED,mFAAmF;AACnF,qBAAa,wBAAyB,SAAQ,uBAAuB;IACpE,YAAY,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,8BAA8B,EAGpE;CACD;AAED,2FAA2F;AAC3F,qBAAa,kCAAmC,SAAQ,uBAAuB;IAC9E,YACC,OAAO,SAA0D,EACjE,OAAO,CAAC,EAAE,8BAA8B,EAIxC;CACD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"workflow-run-control.js","sourceRoot":"","sources":["../../../src/core/extensions/workflow-run-control.ts"],"names":[],"mappings":"AA+JA,2FAA2F;AAC3F,MAAM,OAAO,uBAAwB,SAAQ,KAAK;IACxC,IAAI,CAA8B;IAClC,KAAK,CAAU;IACxB,mFAAmF;IAC1E,UAAU,CAA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AC;IAC1C,CAAC;CACD;AAED,sGAAsG;AACtG,MAAM,OAAO,2BAA4B,SAAQ,uBAAuB;IACvE,YAAY,OAAe,EAAE,OAAwC;QACpE,KAAK,CAAC,0BAA0B,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC;QACpD,IAAI,CAAC,IAAI,GAAG,6BAA6B,CAAC;IAC3C,CAAC;CACD;AAED,qFAAqF;AACrF,MAAM,OAAO,mCAAoC,SAAQ,uBAAuB;IAC/E,YAAY,OAAe,EAAE,OAAwC;QACpE,KAAK,CAAC,mCAAmC,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC;QAC7D,IAAI,CAAC,IAAI,GAAG,qCAAqC,CAAC;IACnD,CAAC;CACD;AAED,mFAAmF;AACnF,MAAM,OAAO,wBAAyB,SAAQ,uBAAuB;IACpE,YAAY,OAAe,EAAE,OAAwC;QACpE,KAAK,CAAC,uBAAuB,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC;QACjD,IAAI,CAAC,IAAI,GAAG,0BAA0B,CAAC;IACxC,CAAC;CACD;AAED,2FAA2F;AAC3F,MAAM,OAAO,kCAAmC,SAAQ,uBAAuB;IAC9E,YACC,OAAO,GAAG,uDAAuD,EACjE,OAAwC;QAExC,KAAK,CAAC,kCAAkC,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC;QAC5D,IAAI,CAAC,IAAI,GAAG,oCAAoC,CAAC;IAClD,CAAC;CACD","sourcesContent":["import type { WorkflowRunStatus, WorkflowStageStatus } from \"./workflow-events.js\";\n\nexport type WorkflowRunJsonValue =\n\t| string\n\t| number\n\t| boolean\n\t| null\n\t| readonly WorkflowRunJsonValue[]\n\t| WorkflowRunJsonObject;\n\nexport interface WorkflowRunJsonObject {\n\treadonly [key: string]: WorkflowRunJsonValue | undefined;\n}\n\nexport type WorkflowRunFilterStatus = WorkflowRunStatus | WorkflowStageStatus | \"awaiting_input\";\n\nexport interface WorkflowRunListFilter {\n\t/** Run statuses match directly; `awaiting_input` selects runs with an unanswered prompt. */\n\treadonly status?: WorkflowRunFilterStatus;\n}\n\nexport interface WorkflowStageListFilter {\n\treadonly status?: WorkflowStageStatus;\n}\n\nexport interface WorkflowRunActiveStage {\n\treadonly stageId: string;\n\treadonly name: string;\n\treadonly status: WorkflowStageStatus;\n}\n\nexport interface WorkflowRunAwaitingInput {\n\treadonly stageId?: string;\n\treadonly stageName?: string;\n\treadonly promptId?: string;\n\treadonly promptKind?: string;\n\treadonly message?: string;\n}\n\n/** The concise per-run data that the `workflow` tool's `status` action lists. */\nexport interface WorkflowRunSummary {\n\treadonly runId: string;\n\treadonly name: string;\n\treadonly status: WorkflowRunStatus;\n\treadonly startedAt: number;\n\treadonly endedAt?: number;\n\treadonly elapsedMs: number;\n\treadonly activeStages: readonly WorkflowRunActiveStage[];\n\treadonly awaitingInputCount: number;\n\treadonly awaitingInput: readonly WorkflowRunAwaitingInput[];\n\treadonly exitReason?: string;\n\treadonly error?: string;\n}\n\nexport interface WorkflowRunStageSummary {\n\treadonly id: string;\n\treadonly name: string;\n\treadonly status: WorkflowStageStatus;\n\treadonly sessionId?: string;\n\treadonly error?: string;\n\treadonly skippedReason?: string;\n\treadonly awaitingInputSince?: number;\n}\n\n/** The per-run detail that the `workflow` tool's `status` action returns for one run id. */\nexport interface WorkflowRunDetail {\n\treadonly runId: string;\n\treadonly rootRunId?: string;\n\treadonly name: string;\n\treadonly status: WorkflowRunStatus | \"crashed\";\n\treadonly startedAt: number;\n\treadonly endedAt?: number;\n\treadonly durationMs?: number;\n\treadonly inputs: WorkflowRunJsonObject;\n\treadonly stages: readonly WorkflowRunStageSummary[];\n\treadonly result?: WorkflowRunJsonObject;\n\treadonly error?: string;\n\treadonly exitReason?: string;\n\treadonly resumable?: boolean;\n\treadonly resumeGuidance?: string;\n\treadonly ownerActiveElsewhere?: boolean;\n}\n\nexport interface WorkflowRunAllTarget {\n\treadonly all: true;\n}\n\nexport interface WorkflowRunPauseOptions {\n\t/** Pause one stage instead of the whole run. */\n\treadonly stageId?: string;\n}\n\nexport interface WorkflowRunResumeOptions {\n\t/** Resume one paused stage instead of the whole run. */\n\treadonly stageId?: string;\n\t/** Message delivered to each resumed stage. */\n\treadonly message?: string;\n\treadonly legacyRecovery?: { readonly olderWorkersStopped: true };\n}\n\nexport type WorkflowRunControlStatus = \"ok\" | \"running\" | \"paused\" | \"partial\" | \"noop\" | \"cancelled\";\n\n/** A run that a batch pause or quit could not stop; it may still be active. */\nexport interface WorkflowRunControlFailedRun {\n\treadonly runId: string;\n\t/** Machine-readable refusal, such as `not_found`, `no_active_stages` or `pause_failed`. */\n\treadonly reason: string;\n\treadonly message?: string;\n}\n\n/**\n * The acknowledged result of a pause, quit or resume request, as the `workflow`\n * tool reports it. `runId` is `--all` for a batch request. `noop` means the request was\n * understood and found nothing to change; `partial` means only part of the\n * request took effect. For a batch pause or quit, `failedRuns` names every run that\n * could not be stopped, so a `partial` outcome is never a complete stop.\n */\nexport interface WorkflowRunControlOutcome {\n\treadonly action: \"pause\" | \"quit\" | \"resume\";\n\treadonly runId: string;\n\treadonly status: WorkflowRunControlStatus;\n\treadonly message: string;\n\treadonly stageId?: string;\n\treadonly workflowStatus?: WorkflowRunStatus;\n\treadonly abandoned?: boolean;\n\treadonly failedRuns?: readonly WorkflowRunControlFailedRun[];\n}\n\n/** Typed run management for the workflow runs owned by one session. */\nexport interface SessionWorkflows {\n\tlistRuns(filter?: WorkflowRunListFilter): Promise<readonly WorkflowRunSummary[]>;\n\tgetRun(runId: string): Promise<WorkflowRunDetail>;\n\tgetStages(runId: string, filter?: WorkflowStageListFilter): Promise<readonly WorkflowRunStageSummary[]>;\n\tpause(runId: string, options?: WorkflowRunPauseOptions): Promise<WorkflowRunControlOutcome>;\n\tpause(target: WorkflowRunAllTarget): Promise<WorkflowRunControlOutcome>;\n\tquit(target: string | WorkflowRunAllTarget): Promise<WorkflowRunControlOutcome>;\n\tresume(runId: string, options?: WorkflowRunResumeOptions): Promise<WorkflowRunControlOutcome>;\n}\n\nexport interface WorkflowRunControlRegistration {\n\tdispose(): void;\n}\n\nexport type WorkflowRunControlErrorCode =\n\t| \"WORKFLOW_RUN_NOT_FOUND\"\n\t| \"WORKFLOW_RUN_OWNED_ELSEWHERE\"\n\t| \"WORKFLOW_RUN_NOT_RESUMABLE\"\n\t| \"WORKFLOW_STAGE_NOT_FOUND\"\n\t| \"WORKFLOW_STAGE_AMBIGUOUS\"\n\t| \"WORKFLOW_STAGE_RESUME_UNSUPPORTED\"\n\t| \"WORKFLOW_RUN_DATABASE\"\n\t| \"WORKFLOW_RUN_CONTROL_FAILED\"\n\t| \"WORKFLOW_RUN_CONTROL_UNAVAILABLE\";\n\nexport interface WorkflowRunControlErrorOptions extends ErrorOptions {\n\treadonly runId?: string;\n\treadonly failedRuns?: readonly WorkflowRunControlFailedRun[];\n}\n\n/** Base class for every failure reported by {@link SessionWorkflows}; branch on `code`. */\nexport class WorkflowRunControlError extends Error {\n\treadonly code: WorkflowRunControlErrorCode;\n\treadonly runId?: string;\n\t/** Runs a batch pause or quit could not stop, when the whole batch was refused. */\n\treadonly failedRuns?: readonly WorkflowRunControlFailedRun[];\n\n\tconstructor(code: WorkflowRunControlErrorCode, message: string, options: WorkflowRunControlErrorOptions = {}) {\n\t\tsuper(message, options);\n\t\tthis.name = \"WorkflowRunControlError\";\n\t\tthis.code = code;\n\t\tif (options.runId !== undefined) this.runId = options.runId;\n\t\tif (options.failedRuns !== undefined) this.failedRuns = options.failedRuns;\n\t}\n}\n\n/** The run id is unknown, malformed, or an ambiguous prefix. */\nexport class WorkflowRunNotFoundError extends WorkflowRunControlError {\n\tconstructor(message: string, options?: WorkflowRunControlErrorOptions) {\n\t\tsuper(\"WORKFLOW_RUN_NOT_FOUND\", message, options);\n\t\tthis.name = \"WorkflowRunNotFoundError\";\n\t}\n}\n\n/** The run belongs to another session or is executing in another live Atomic process. */\nexport class WorkflowRunOwnershipError extends WorkflowRunControlError {\n\tconstructor(message: string, options?: WorkflowRunControlErrorOptions) {\n\t\tsuper(\"WORKFLOW_RUN_OWNED_ELSEWHERE\", message, options);\n\t\tthis.name = \"WorkflowRunOwnershipError\";\n\t}\n}\n\n/** The run has no continuation to resume: it completed, was killed, or has no durable progress. */\nexport class WorkflowRunNotResumableError extends WorkflowRunControlError {\n\tconstructor(message: string, options?: WorkflowRunControlErrorOptions) {\n\t\tsuper(\"WORKFLOW_RUN_NOT_RESUMABLE\", message, options);\n\t\tthis.name = \"WorkflowRunNotResumableError\";\n\t}\n}\n\n/** The stage identifier matches no stage or tool node of the run. */\nexport class WorkflowStageNotFoundError extends WorkflowRunControlError {\n\tconstructor(message: string, options?: WorkflowRunControlErrorOptions) {\n\t\tsuper(\"WORKFLOW_STAGE_NOT_FOUND\", message, options);\n\t\tthis.name = \"WorkflowStageNotFoundError\";\n\t}\n}\n\n/** The stage identifier matches more than one stage or tool node; pass a more specific identifier. */\nexport class WorkflowStageAmbiguousError extends WorkflowRunControlError {\n\tconstructor(message: string, options?: WorkflowRunControlErrorOptions) {\n\t\tsuper(\"WORKFLOW_STAGE_AMBIGUOUS\", message, options);\n\t\tthis.name = \"WorkflowStageAmbiguousError\";\n\t}\n}\n\n/** A durable run can only be resumed whole; resume it without a stage identifier. */\nexport class WorkflowStageResumeUnsupportedError extends WorkflowRunControlError {\n\tconstructor(message: string, options?: WorkflowRunControlErrorOptions) {\n\t\tsuper(\"WORKFLOW_STAGE_RESUME_UNSUPPORTED\", message, options);\n\t\tthis.name = \"WorkflowStageResumeUnsupportedError\";\n\t}\n}\n\n/** Workflow durability (the run database) is unavailable, shut down, or failed. */\nexport class WorkflowRunDatabaseError extends WorkflowRunControlError {\n\tconstructor(message: string, options?: WorkflowRunControlErrorOptions) {\n\t\tsuper(\"WORKFLOW_RUN_DATABASE\", message, options);\n\t\tthis.name = \"WorkflowRunDatabaseError\";\n\t}\n}\n\n/** The workflows extension is not loaded for this session, or the session was disposed. */\nexport class WorkflowRunControlUnavailableError extends WorkflowRunControlError {\n\tconstructor(\n\t\tmessage = \"Workflow run control is unavailable for this session.\",\n\t\toptions?: WorkflowRunControlErrorOptions,\n\t) {\n\t\tsuper(\"WORKFLOW_RUN_CONTROL_UNAVAILABLE\", message, options);\n\t\tthis.name = \"WorkflowRunControlUnavailableError\";\n\t}\n}\n"]}
|
|
1
|
+
{"version":3,"file":"workflow-run-control.js","sourceRoot":"","sources":["../../../src/core/extensions/workflow-run-control.ts"],"names":[],"mappings":"AA6KA,2FAA2F;AAC3F,MAAM,OAAO,uBAAwB,SAAQ,KAAK;IACxC,IAAI,CAA8B;IAClC,KAAK,CAAU;IACxB,mFAAmF;IAC1E,UAAU,CAA0C;IAE7D,YAAY,IAAiC,EAAE,OAAe,EAAE,OAAO,GAAmC,EAAE;QAC3G,KAAK,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;QACxB,IAAI,CAAC,IAAI,GAAG,yBAAyB,CAAC;QACtC,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,OAAO,CAAC,KAAK,KAAK,SAAS;YAAE,IAAI,CAAC,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC;QAC5D,IAAI,OAAO,CAAC,UAAU,KAAK,SAAS;YAAE,IAAI,CAAC,UAAU,GAAG,OAAO,CAAC,UAAU,CAAC;IAC5E,CAAC;CACD;AAED,gEAAgE;AAChE,MAAM,OAAO,wBAAyB,SAAQ,uBAAuB;IACpE,YAAY,OAAe,EAAE,OAAwC;QACpE,KAAK,CAAC,wBAAwB,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC;QAClD,IAAI,CAAC,IAAI,GAAG,0BAA0B,CAAC;IACxC,CAAC;CACD;AAED,yFAAyF;AACzF,MAAM,OAAO,yBAA0B,SAAQ,uBAAuB;IACrE,YAAY,OAAe,EAAE,OAAwC;QACpE,KAAK,CAAC,8BAA8B,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC;QACxD,IAAI,CAAC,IAAI,GAAG,2BAA2B,CAAC;IACzC,CAAC;CACD;AAED,mGAAmG;AACnG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AAG,oCAAoC,CAAC;IAClD,CAAC;CACD","sourcesContent":["import type {\n\tWorkflowActivityObserver,\n\tWorkflowActivitySubscription,\n\tWorkflowRunStatus,\n\tWorkflowStageStatus,\n} from \"./workflow-events.js\";\n\nexport type WorkflowRunJsonValue =\n\t| string\n\t| number\n\t| boolean\n\t| null\n\t| readonly WorkflowRunJsonValue[]\n\t| WorkflowRunJsonObject;\n\nexport interface WorkflowRunJsonObject {\n\treadonly [key: string]: WorkflowRunJsonValue | undefined;\n}\n\nexport type WorkflowRunFilterStatus = WorkflowRunStatus | WorkflowStageStatus | \"awaiting_input\";\n\nexport interface WorkflowRunListFilter {\n\t/** Run statuses match directly; `awaiting_input` selects runs with an unanswered prompt. */\n\treadonly status?: WorkflowRunFilterStatus;\n}\n\nexport interface WorkflowStageListFilter {\n\treadonly status?: WorkflowStageStatus;\n}\n\nexport interface WorkflowRunActiveStage {\n\treadonly stageId: string;\n\treadonly name: string;\n\treadonly status: WorkflowStageStatus;\n}\n\nexport interface WorkflowRunAwaitingInput {\n\treadonly stageId?: string;\n\treadonly stageName?: string;\n\treadonly promptId?: string;\n\treadonly promptKind?: string;\n\treadonly message?: string;\n}\n\n/** The concise per-run data that the `workflow` tool's `status` action lists. */\nexport interface WorkflowRunSummary {\n\treadonly runId: string;\n\treadonly name: string;\n\treadonly status: WorkflowRunStatus;\n\treadonly startedAt: number;\n\treadonly endedAt?: number;\n\treadonly elapsedMs: number;\n\treadonly activeStages: readonly WorkflowRunActiveStage[];\n\treadonly awaitingInputCount: number;\n\treadonly awaitingInput: readonly WorkflowRunAwaitingInput[];\n\treadonly exitReason?: string;\n\treadonly error?: string;\n}\n\nexport interface WorkflowRunStageSummary {\n\treadonly id: string;\n\treadonly name: string;\n\treadonly status: WorkflowStageStatus;\n\treadonly sessionId?: string;\n\treadonly error?: string;\n\treadonly skippedReason?: string;\n\treadonly awaitingInputSince?: number;\n}\n\n/** The per-run detail that the `workflow` tool's `status` action returns for one run id. */\nexport interface WorkflowRunDetail {\n\treadonly runId: string;\n\treadonly rootRunId?: string;\n\treadonly name: string;\n\treadonly status: WorkflowRunStatus | \"crashed\";\n\treadonly startedAt: number;\n\treadonly endedAt?: number;\n\treadonly durationMs?: number;\n\treadonly inputs: WorkflowRunJsonObject;\n\treadonly stages: readonly WorkflowRunStageSummary[];\n\treadonly result?: WorkflowRunJsonObject;\n\treadonly error?: string;\n\treadonly exitReason?: string;\n\treadonly resumable?: boolean;\n\treadonly resumeGuidance?: string;\n\treadonly ownerActiveElsewhere?: boolean;\n}\n\nexport interface WorkflowRunAllTarget {\n\treadonly all: true;\n}\n\nexport interface WorkflowRunPauseOptions {\n\t/** Pause one stage instead of the whole run. */\n\treadonly stageId?: string;\n}\n\nexport interface WorkflowRunResumeOptions {\n\t/** Resume one paused stage instead of the whole run. */\n\treadonly stageId?: string;\n\t/** Message delivered to each resumed stage. */\n\treadonly message?: string;\n\treadonly legacyRecovery?: { readonly olderWorkersStopped: true };\n}\n\nexport type WorkflowRunControlStatus = \"ok\" | \"running\" | \"paused\" | \"partial\" | \"noop\" | \"cancelled\";\n\n/** A run that a batch pause or quit could not stop; it may still be active. */\nexport interface WorkflowRunControlFailedRun {\n\treadonly runId: string;\n\t/** Machine-readable refusal, such as `not_found`, `no_active_stages` or `pause_failed`. */\n\treadonly reason: string;\n\treadonly message?: string;\n}\n\n/**\n * The acknowledged result of a pause, quit or resume request, as the `workflow`\n * tool reports it. `runId` is `--all` for a batch request. `noop` means the request was\n * understood and found nothing to change; `partial` means only part of the\n * request took effect. For a batch pause or quit, `failedRuns` names every run that\n * could not be stopped, so a `partial` outcome is never a complete stop.\n */\nexport interface WorkflowRunControlOutcome {\n\treadonly action: \"pause\" | \"quit\" | \"resume\";\n\treadonly runId: string;\n\treadonly status: WorkflowRunControlStatus;\n\treadonly message: string;\n\treadonly stageId?: string;\n\treadonly workflowStatus?: WorkflowRunStatus;\n\treadonly abandoned?: boolean;\n\treadonly failedRuns?: readonly WorkflowRunControlFailedRun[];\n}\n\n/** Typed run management for the workflow runs owned by one session, as registered by the workflows extension. */\nexport interface WorkflowRunControl {\n\tlistRuns(filter?: WorkflowRunListFilter): Promise<readonly WorkflowRunSummary[]>;\n\tgetRun(runId: string): Promise<WorkflowRunDetail>;\n\tgetStages(runId: string, filter?: WorkflowStageListFilter): Promise<readonly WorkflowRunStageSummary[]>;\n\tpause(runId: string, options?: WorkflowRunPauseOptions): Promise<WorkflowRunControlOutcome>;\n\tpause(target: WorkflowRunAllTarget): Promise<WorkflowRunControlOutcome>;\n\tquit(target: string | WorkflowRunAllTarget): Promise<WorkflowRunControlOutcome>;\n\tresume(runId: string, options?: WorkflowRunResumeOptions): Promise<WorkflowRunControlOutcome>;\n}\n\n/** `session.workflows`: run management plus observation of the workflow runs owned by one session. */\nexport interface SessionWorkflows extends WorkflowRunControl {\n\t/**\n\t * Follow root activity and graph changes. Delivers a snapshot frame first, then FIFO\n\t * `changed` and `removed` frames; the subscription follows extension reloads.\n\t */\n\tobserve(observer: WorkflowActivityObserver): WorkflowActivitySubscription;\n}\n\nexport interface WorkflowRunControlRegistration {\n\tdispose(): void;\n}\n\nexport type WorkflowRunControlErrorCode =\n\t| \"WORKFLOW_RUN_NOT_FOUND\"\n\t| \"WORKFLOW_RUN_OWNED_ELSEWHERE\"\n\t| \"WORKFLOW_RUN_NOT_RESUMABLE\"\n\t| \"WORKFLOW_STAGE_NOT_FOUND\"\n\t| \"WORKFLOW_STAGE_AMBIGUOUS\"\n\t| \"WORKFLOW_STAGE_RESUME_UNSUPPORTED\"\n\t| \"WORKFLOW_RUN_DATABASE\"\n\t| \"WORKFLOW_RUN_CONTROL_FAILED\"\n\t| \"WORKFLOW_RUN_CONTROL_UNAVAILABLE\";\n\nexport interface WorkflowRunControlErrorOptions extends ErrorOptions {\n\treadonly runId?: string;\n\treadonly failedRuns?: readonly WorkflowRunControlFailedRun[];\n}\n\n/** Base class for every failure reported by {@link SessionWorkflows}; branch on `code`. */\nexport class WorkflowRunControlError extends Error {\n\treadonly code: WorkflowRunControlErrorCode;\n\treadonly runId?: string;\n\t/** Runs a batch pause or quit could not stop, when the whole batch was refused. */\n\treadonly failedRuns?: readonly WorkflowRunControlFailedRun[];\n\n\tconstructor(code: WorkflowRunControlErrorCode, message: string, options: WorkflowRunControlErrorOptions = {}) {\n\t\tsuper(message, options);\n\t\tthis.name = \"WorkflowRunControlError\";\n\t\tthis.code = code;\n\t\tif (options.runId !== undefined) this.runId = options.runId;\n\t\tif (options.failedRuns !== undefined) this.failedRuns = options.failedRuns;\n\t}\n}\n\n/** The run id is unknown, malformed, or an ambiguous prefix. */\nexport class WorkflowRunNotFoundError extends WorkflowRunControlError {\n\tconstructor(message: string, options?: WorkflowRunControlErrorOptions) {\n\t\tsuper(\"WORKFLOW_RUN_NOT_FOUND\", message, options);\n\t\tthis.name = \"WorkflowRunNotFoundError\";\n\t}\n}\n\n/** The run belongs to another session or is executing in another live Atomic process. */\nexport class WorkflowRunOwnershipError extends WorkflowRunControlError {\n\tconstructor(message: string, options?: WorkflowRunControlErrorOptions) {\n\t\tsuper(\"WORKFLOW_RUN_OWNED_ELSEWHERE\", message, options);\n\t\tthis.name = \"WorkflowRunOwnershipError\";\n\t}\n}\n\n/** The run has no continuation to resume: it completed, was killed, or has no durable progress. */\nexport class WorkflowRunNotResumableError extends WorkflowRunControlError {\n\tconstructor(message: string, options?: WorkflowRunControlErrorOptions) {\n\t\tsuper(\"WORKFLOW_RUN_NOT_RESUMABLE\", message, options);\n\t\tthis.name = \"WorkflowRunNotResumableError\";\n\t}\n}\n\n/** The stage identifier matches no stage or tool node of the run. */\nexport class WorkflowStageNotFoundError extends WorkflowRunControlError {\n\tconstructor(message: string, options?: WorkflowRunControlErrorOptions) {\n\t\tsuper(\"WORKFLOW_STAGE_NOT_FOUND\", message, options);\n\t\tthis.name = \"WorkflowStageNotFoundError\";\n\t}\n}\n\n/** The stage identifier matches more than one stage or tool node; pass a more specific identifier. */\nexport class WorkflowStageAmbiguousError extends WorkflowRunControlError {\n\tconstructor(message: string, options?: WorkflowRunControlErrorOptions) {\n\t\tsuper(\"WORKFLOW_STAGE_AMBIGUOUS\", message, options);\n\t\tthis.name = \"WorkflowStageAmbiguousError\";\n\t}\n}\n\n/** A durable run can only be resumed whole; resume it without a stage identifier. */\nexport class WorkflowStageResumeUnsupportedError extends WorkflowRunControlError {\n\tconstructor(message: string, options?: WorkflowRunControlErrorOptions) {\n\t\tsuper(\"WORKFLOW_STAGE_RESUME_UNSUPPORTED\", message, options);\n\t\tthis.name = \"WorkflowStageResumeUnsupportedError\";\n\t}\n}\n\n/** Workflow durability (the run database) is unavailable, shut down, or failed. */\nexport class WorkflowRunDatabaseError extends WorkflowRunControlError {\n\tconstructor(message: string, options?: WorkflowRunControlErrorOptions) {\n\t\tsuper(\"WORKFLOW_RUN_DATABASE\", message, options);\n\t\tthis.name = \"WorkflowRunDatabaseError\";\n\t}\n}\n\n/** The workflows extension is not loaded for this session, or the session was disposed. */\nexport class WorkflowRunControlUnavailableError extends WorkflowRunControlError {\n\tconstructor(\n\t\tmessage = \"Workflow run control is unavailable for this session.\",\n\t\toptions?: WorkflowRunControlErrorOptions,\n\t) {\n\t\tsuper(\"WORKFLOW_RUN_CONTROL_UNAVAILABLE\", message, options);\n\t\tthis.name = \"WorkflowRunControlUnavailableError\";\n\t}\n}\n"]}
|
|
@@ -66,7 +66,7 @@ export declare function isNativeFastRouteApi(api: Api): api is "openai-responses
|
|
|
66
66
|
* OpenAI-style fast routing keeps the base upstream model ID and adds a priority service tier.
|
|
67
67
|
*
|
|
68
68
|
* Eligibility requires both a first-party provider ID and an adapter that serializes
|
|
69
|
-
* `service_tier`. A renamed provider, proxy, Azure
|
|
69
|
+
* `service_tier`. A renamed provider, proxy, Azure (`azure`), OpenRouter
|
|
70
70
|
* (`openai-completions`), and generic OpenAI-compatible providers do not qualify. An `openai` or
|
|
71
71
|
* `openai-codex` model on an adapter that cannot carry `service_tier` must not offer a fast variant,
|
|
72
72
|
* because selecting it would send an ordinary request under a name that promises otherwise.
|
|
@@ -35,7 +35,7 @@ export function isNativeFastRouteApi(api) {
|
|
|
35
35
|
* OpenAI-style fast routing keeps the base upstream model ID and adds a priority service tier.
|
|
36
36
|
*
|
|
37
37
|
* Eligibility requires both a first-party provider ID and an adapter that serializes
|
|
38
|
-
* `service_tier`. A renamed provider, proxy, Azure
|
|
38
|
+
* `service_tier`. A renamed provider, proxy, Azure (`azure`), OpenRouter
|
|
39
39
|
* (`openai-completions`), and generic OpenAI-compatible providers do not qualify. An `openai` or
|
|
40
40
|
* `openai-codex` model on an adapter that cannot carry `service_tier` must not offer a fast variant,
|
|
41
41
|
* because selecting it would send an ordinary request under a name that promises otherwise.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fast-model-variants.js","sourceRoot":"","sources":["../../src/core/fast-model-variants.ts"],"names":[],"mappings":"AAAA,OAAO,EAGN,kBAAkB,GAIlB,MAAM,gBAAgB,CAAC;AAExB,OAAO,EAAE,kBAAkB,EAAE,MAAM,iCAAiC,CAAC;AAErE,oEAAoE;AACpE,MAAM,CAAC,MAAM,oBAAoB,GAAG,OAAO,CAAC;AAE5C,qEAAqE;AACrE,MAAM,CAAC,MAAM,uBAAuB,GAAG,UAAmB,CAAC;AAE3D,wGAAwG;AACxG,MAAM,CAAC,MAAM,yBAAyB,GAAG,YAAY,CAAC;AACtD,MAAM,CAAC,MAAM,4BAA4B,GAAG,WAAoB,CAAC;AAEjE,2EAA2E;AAC3E,MAAM,CAAC,MAAM,gBAAgB,GAAG,MAAe,CAAC;AAEhD;;;;GAIG;AACH,MAAM,CAAC,MAAM,6BAA6B,GAAwB,IAAI,GAAG,CAAC;IACzE,iBAAiB;IACjB,eAAe;IACf,iBAAiB;CACjB,CAAC,CAAC;AA6CH,oEAAoE;AACpE,MAAM,UAAU,WAAW,CAAC,WAAmB;IAC9C,OAAO,GAAG,WAAW,GAAG,oBAAoB,EAAE,CAAC;AAChD,CAAC;AAED;;;;GAIG;AACH,MA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etServiceTierCost,\n\ttype Model,\n\ttype ModelFastRoute,\n\ttype Provider,\n} from \"@bastani/pi-ai\";\nimport type { ModelsJsonModelOverride } from \"./model-config.ts\";\nimport { applyModelOverride } from \"./provider-composer-internal.ts\";\n\n/** Canonical suffix every selectable fast model variant carries. */\nexport const FAST_MODEL_ID_SUFFIX = \"-fast\";\n\n/** Service tier OpenAI-style providers use to route fast traffic. */\nexport const FAST_MODEL_SERVICE_TIER = \"priority\" as const;\n\n/** Codex's Ultrafast tier, offered only for models that advertise it; access depends on the account. */\nexport const ULTRAFAST_MODEL_ID_SUFFIX = \"-ultrafast\";\nexport const ULTRAFAST_MODEL_SERVICE_TIER = \"ultrafast\" as const;\n\n/** Inference speed Anthropic's Messages API uses to route fast traffic. */\nexport const FAST_MODEL_SPEED = \"fast\" as const;\n\n/**\n * Claude models Anthropic's fast mode accepts. Requesting `speed: \"fast\"` on any other model is an\n * error, so the list is explicit rather than a family-name pattern.\n * https://platform.claude.com/docs/en/build-with-claude/fast-mode#supported-models\n */\nexport const ANTHROPIC_FAST_MODE_MODEL_IDS: ReadonlySet<string> = new Set([\n\t\"claude-opus-5-5\",\n\t\"claude-opus-5\",\n\t\"claude-opus-4-8\",\n]);\n\n/** A derived fast variant that was suppressed because something already owns its exact model ID. */\nexport interface FastModelVariantDiagnostic {\n\tprovider: string;\n\t/** The exact selectable model ID that collided. */\n\tmodelId: string;\n\tmessage: string;\n}\n\nexport interface FastModelVariantDerivation {\n\tmodels: readonly Model<Api>[];\n\tdiagnostics: readonly FastModelVariantDiagnostic[];\n}\n\nexport interface DeriveFastModelVariantsOptions {\n\t/** Exact fast model IDs the stored GitHub Copilot credential advertises for this account. */\n\tcopilotFastModelIds?: readonly string[];\n\t/** `models.json` `modelOverrides` for this provider, applied to derived entries by their exact `-fast` ID. */\n\tmodelOverrides?: Readonly<Record<string, ModelsJsonModelOverride>>;\n\t/** APIs whose transport a registered extension owns for this provider. No variant is derived for them. */\n\textensionOwnedApis?: ReadonlySet<Api>;\n\t/** IDs explicitly declared in this provider's models.json models array. Never derive siblings for them. */\n\tcustomModelIds?: ReadonlySet<string>;\n}\n\nexport interface FastModelVariantsOptions {\n\t/**\n\t * Synchronous read of the exact fast model IDs the stored GitHub Copilot credential advertises.\n\t * Read per call so a credential that lands after provider composition still takes effect.\n\t */\n\tgetCopilotFastModelIds?: () => readonly string[] | undefined;\n\t/** Synchronous read of this provider's `models.json` `modelOverrides`, so a reload takes effect. */\n\tgetModelOverrides?: () => Readonly<Record<string, ModelsJsonModelOverride>> | undefined;\n\t/** Read current custom model IDs per pass so models.json reloads update eligibility. */\n\tgetCustomModelIds?: () => ReadonlySet<string>;\n\t/**\n\t * Synchronous read of the APIs a registered extension supplies a stream function for. Read per call\n\t * because extensions register after initial composition on some paths.\n\t */\n\tgetExtensionOwnedApis?: () => ReadonlySet<Api> | undefined;\n\t/** Called after every derivation pass with the complete diagnostic list for this provider. */\n\tonDiagnostics?: (providerId: string, diagnostics: readonly FastModelVariantDiagnostic[]) => void;\n}\n\n/** Canonical selectable ID of the fast variant of `baseModelId`. */\nexport function fastModelId(baseModelId: string): string {\n\treturn `${baseModelId}${FAST_MODEL_ID_SUFFIX}`;\n}\n\n/**\n * The two pi-ai adapters that serialize `service_tier`. `azure-openai-responses` and\n * `openai-completions` have no such option, and `streamSimple` drops it, so a service-tier route on\n * any other API would silently degrade to an ordinary request.\n */\nexport function isNativeFastRouteApi(api: Api): api is \"openai-responses\" | \"openai-codex-responses\" {\n\treturn api === \"openai-responses\" || api === \"openai-codex-responses\";\n}\n\n/**\n * OpenAI-style fast routing keeps the base upstream model ID and adds a priority service tier.\n *\n * Eligibility requires both a first-party provider ID and an adapter that serializes\n * `service_tier`. A renamed provider, proxy, Azure OpenAI (`azure-openai-responses`), OpenRouter\n * (`openai-completions`), and generic OpenAI-compatible providers do not qualify. An `openai` or\n * `openai-codex` model on an adapter that cannot carry `service_tier` must not offer a fast variant,\n * because selecting it would send an ordinary request under a name that promises otherwise.\n */\nexport function usesOpenAIFastServiceTier(model: Pick<Model<Api>, \"api\" | \"provider\">): boolean {\n\treturn isNativeFastRouteApi(model.api) && (model.provider === \"openai\" || model.provider === \"openai-codex\");\n}\n\n/**\n * xAI Priority Processing keeps the base upstream Grok model ID and adds the same\n * `service_tier: \"priority\"` field on the Responses API. xAI has no `-fast` model slugs for current\n * Grok models; priority is billed at twice the standard token rates, and only when the response\n * confirms the tier. https://docs.x.ai/developers/advanced-api-usage/priority-processing\n *\n * Eligibility requires the first-party `xai` provider on `openai-responses`. OpenRouter, Vercel AI\n * Gateway, and renamed or proxied xAI-compatible providers do not qualify.\n */\nexport function usesXaiFastServiceTier(model: Pick<Model<Api>, \"api\" | \"provider\">): boolean {\n\treturn model.api === \"openai-responses\" && model.provider === \"xai\";\n}\n\n/** GitHub Copilot advertises real fast sibling model IDs per account; it never uses a service tier. */\nexport function isGitHubCopilotModel(model: Pick<Model<Api>, \"provider\">): boolean {\n\treturn model.provider === \"github-copilot\";\n}\n\n/**\n * Anthropic fast mode keeps the base upstream model ID and adds `speed: \"fast\"` with the fast-mode beta.\n *\n * Eligibility requires the first-party `anthropic` provider on the Messages API and a supported model.\n * Fast mode is not offered through Amazon Bedrock, Google Vertex, GitHub Copilot, OpenRouter, or a\n * renamed or proxied Anthropic-compatible provider.\n */\nexport function usesAnthropicFastMode(model: Pick<Model<Api>, \"api\" | \"id\" | \"provider\">): boolean {\n\treturn (\n\t\tmodel.api === \"anthropic-messages\" &&\n\t\tmodel.provider === \"anthropic\" &&\n\t\tANTHROPIC_FAST_MODE_MODEL_IDS.has(model.id)\n\t);\n}\n\nfunction advertisedModelIds(value: unknown): readonly string[] | undefined {\n\tif (!Array.isArray(value) || !value.every((entry) => typeof entry === \"string\")) return undefined;\n\treturn value;\n}\n\n/** Read the exact fast model IDs a stored GitHub Copilot OAuth credential advertises. */\nexport function copilotAdvertisedFastModelIds(credential: Credential | undefined): readonly string[] | undefined {\n\tif (credential?.type !== \"oauth\") return undefined;\n\treturn advertisedModelIds(credential.fastModelIds);\n}\n\n/**\n * Whether a stored GitHub Copilot OAuth credential advertises this exact model ID at all — as a\n * selectable picker/policy model or as a fast sibling.\n *\n * Copilot's per-account advertisement is the authority the provider's own `filterModels` uses, so\n * restoration consults the same lists. An ID the account advertises as an ordinary model is ordinary,\n * whatever its name ends in.\n */\nexport function copilotAdvertisesModelId(credential: Credential | undefined, modelId: string): boolean {\n\tif (credential?.type !== \"oauth\") return false;\n\treturn (\n\t\tadvertisedModelIds(credential.availableModelIds)?.includes(modelId) === true ||\n\t\tadvertisedModelIds(credential.fastModelIds)?.includes(modelId) === true\n\t);\n}\n\n/** A model without tier metadata keeps offering Fast; one that lists its tiers must advertise it, as in Codex. */\nfunction advertisesFastServiceTier(model: Model<Api>): boolean {\n\treturn model.serviceTiers === undefined || getServiceTierCost(model, FAST_MODEL_SERVICE_TIER) !== undefined;\n}\n\nfunction fastRouteForBaseModel(\n\tmodel: Model<Api>,\n\tentitledCopilotFastModelIds: ReadonlySet<string>,\n): ModelFastRoute | undefined {\n\tif (usesOpenAIFastServiceTier(model)) {\n\t\treturn advertisesFastServiceTier(model)\n\t\t\t? { baseModelId: model.id, upstreamModelId: model.id, serviceTier: FAST_MODEL_SERVICE_TIER }\n\t\t\t: undefined;\n\t}\n\tif (usesXaiFastServiceTier(model)) {\n\t\treturn { baseModelId: model.id, upstreamModelId: model.id, serviceTier: FAST_MODEL_SERVICE_TIER };\n\t}\n\tif (usesAnthropicFastMode(model)) {\n\t\treturn { baseModelId: model.id, upstreamModelId: model.id, speed: FAST_MODEL_SPEED };\n\t}\n\tif (isGitHubCopilotModel(model)) {\n\t\tconst advertisedId = fastModelId(model.id);\n\t\treturn entitledCopilotFastModelIds.has(advertisedId)\n\t\t\t? { baseModelId: model.id, upstreamModelId: advertisedId }\n\t\t\t: undefined;\n\t}\n\treturn undefined;\n}\n\n/**\n * Add a selectable `<base-model-id>-fast` entry for every eligible model, carrying the explicit\n * {@link ModelFastRoute} metadata that gives it fast semantics. The input list is preserved verbatim\n * and in order; each derived entry is appended directly after the model it derives from.\n *\n * A model whose exact `-fast` ID is already owned by the provider, a `models.json` custom model, or an\n * extension wins: derivation is suppressed for it and a diagnostic is recorded. The owning model keeps\n * whatever semantics it declares, because fast behavior comes only from `fastRoute`, never from the\n * `-fast` suffix. For the same reason a base model whose ID already ends in `-fast` is never used to\n * derive a `-fast-fast` variant: that is not a canonical ID this scheme defines.\n *\n * A derived entry is a real catalog model, so a `modelOverrides` entry keyed on its exact `-fast` ID\n * applies to it after derivation. Without that pass the derived entry would inherit the *base* model's\n * overrides and its own would be silently inert.\n *\n * No variant is derived for an API whose transport a registered extension owns, because Atomic cannot\n * enforce the route through a transport it does not serialize.\n */\nexport function deriveFastModelVariants(\n\tproviderId: string,\n\tmodels: readonly Model<Api>[],\n\toptions: DeriveFastModelVariantsOptions = {},\n): FastModelVariantDerivation {\n\tconst ownedModelIds = new Set(models.map((model) => model.id));\n\tconst entitledCopilotFastModelIds = new Set(options.copilotFastModelIds ?? []);\n\tconst derived: Model<Api>[] = [];\n\tconst diagnostics: FastModelVariantDiagnostic[] = [];\n\tlet changed = false;\n\tfor (const model of models) {\n\t\tderived.push(model);\n\t\tif (\n\t\t\tmodel.fastRoute !== undefined ||\n\t\t\tmodel.id.endsWith(FAST_MODEL_ID_SUFFIX) ||\n\t\t\tmodel.id.endsWith(ULTRAFAST_MODEL_ID_SUFFIX)\n\t\t)\n\t\t\tcontinue;\n\t\tif (options.customModelIds?.has(model.id)) continue;\n\t\t// An extension that supplies this API's stream function owns its serialization, so Atomic cannot\n\t\t// guarantee the route reaches the wire. Publishing a `-fast` choice it may not honor is the same\n\t\t// hazard as publishing one for an adapter that cannot carry the tier.\n\t\tif (options.extensionOwnedApis?.has(model.api) === true) continue;\n\t\tconst fastRoute = fastRouteForBaseModel(model, entitledCopilotFastModelIds);\n\t\tconst routes: Array<{ suffix: string; label: string; route: ModelFastRoute }> = [];\n\t\tif (fastRoute) routes.push({ suffix: FAST_MODEL_ID_SUFFIX, label: \"fast\", route: fastRoute });\n\t\tif (usesOpenAIFastServiceTier(model) && getServiceTierCost(model, ULTRAFAST_MODEL_SERVICE_TIER)) {\n\t\t\troutes.push({\n\t\t\t\tsuffix: ULTRAFAST_MODEL_ID_SUFFIX,\n\t\t\t\tlabel: \"ultrafast\",\n\t\t\t\troute: { baseModelId: model.id, upstreamModelId: model.id, serviceTier: ULTRAFAST_MODEL_SERVICE_TIER },\n\t\t\t});\n\t\t}\n\t\tfor (const { suffix, label, route } of routes) {\n\t\t\tconst variantId = `${model.id}${suffix}`;\n\t\t\tif (ownedModelIds.has(variantId)) {\n\t\t\t\tdiagnostics.push({\n\t\t\t\t\tprovider: providerId,\n\t\t\t\t\tmodelId: variantId,\n\t\t\t\t\tmessage:\n\t\t\t\t\t\t`Model \"${providerId}/${variantId}\" is already defined by the provider, models.json, or an extension, ` +\n\t\t\t\t\t\t`so Atomic did not derive a ${label} variant of \"${providerId}/${model.id}\". ` +\n\t\t\t\t\t\t`That model routes exactly as declared. Rename or remove it to get the derived ${label} variant instead.`,\n\t\t\t\t});\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tconst override = options.modelOverrides?.[variantId];\n\t\t\tconst variant: Model<Api> = { ...model, id: variantId, name: `${model.name} (${label})`, fastRoute: route };\n\t\t\tderived.push(override ? applyModelOverride(variant, override) : variant);\n\t\t\tchanged = true;\n\t\t}\n\t}\n\tif (!changed && diagnostics.length === 0) return { models, diagnostics };\n\treturn { models: derived, diagnostics };\n}\n\n/**\n * Overlay derived fast model variants onto a composed provider. Apply this after built-in,\n * `models.json`, extension, and `modelOverrides` composition so exact user-owned `-fast` IDs are\n * already present and win the collision.\n */\nexport function withFastModelVariants(provider: Provider, options: FastModelVariantsOptions = {}): Provider {\n\treturn {\n\t\t...provider,\n\t\tgetModels: () => {\n\t\t\tconst { models, diagnostics } = deriveFastModelVariants(provider.id, provider.getModels(), {\n\t\t\t\tcopilotFastModelIds: isGitHubCopilotModel({ provider: provider.id })\n\t\t\t\t\t? options.getCopilotFastModelIds?.()\n\t\t\t\t\t: undefined,\n\t\t\t\tmodelOverrides: options.getModelOverrides?.(),\n\t\t\t\textensionOwnedApis: options.getExtensionOwnedApis?.(),\n\t\t\t\tcustomModelIds: options.getCustomModelIds?.(),\n\t\t\t});\n\t\t\toptions.onDiagnostics?.(provider.id, diagnostics);\n\t\t\treturn models;\n\t\t},\n\t};\n}\n"]}
|
|
1
|
+
{"version":3,"file":"fast-model-variants.js","sourceRoot":"","sources":["../../src/core/fast-model-variants.ts"],"names":[],"mappings":"AAAA,OAAO,EAGN,kBAAkB,GAIlB,MAAM,gBAAgB,CAAC;AAExB,OAAO,EAAE,kBAAkB,EAAE,MAAM,iCAAiC,CAAC;AAErE,oEAAoE;AACpE,MAAM,CAAC,MAAM,oBAAoB,GAAG,OAAO,CAAC;AAE5C,qEAAqE;AACrE,MAAM,CAAC,MAAM,uBAAuB,GAAG,UAAmB,CAAC;AAE3D,wGAAwG;AACxG,MAAM,CAAC,MAAM,yBAAyB,GAAG,YAAY,CAAC;AACtD,MAAM,CAAC,MAAM,4BAA4B,GAAG,WAAoB,CAAC;AAEjE,2EAA2E;AAC3E,MAAM,CAAC,MAAM,gBAAgB,GAAG,MAAe,CAAC;AAEhD;;;;GAIG;AACH,MAAM,CAAC,MAAM,6BAA6B,GAAwB,IAAI,GAAG,CAAC;IACzE,iBAAiB;IACjB,eAAe;IACf,iBAAiB;CACjB,CAAC,CAAC;AA6CH,oEAAoE;AACpE,MAAM,UAAU,WAAW,CAAC,WAAmB;IAC9C,OAAO,GAAG,WAAW,GAAG,oBAAoB,EAAE,CAAC;AAChD,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,oBAAoB,CAAC,GAAQ;IAC5C,OAAO,GAAG,KAAK,kBAAkB,IAAI,GAAG,KAAK,wBAAwB,CAAC;AACvE,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,UAAU,yBAAyB,CAAC,KAA2C;IACpF,OAAO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AQ,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC;YACzE,OAAO,GAAG,IAAI,CAAC;QAChB,CAAC;IACF,CAAC;IACD,IAAI,CAAC,OAAO,IAAI,WAAW,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,CAAC;IACzE,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,WAAW,EAAE,CAAC;AACzC,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,qBAAqB,CAAC,QAAkB,EAAE,OAAO,GAA6B,EAAE;IAC/F,OAAO;QACN,GAAG,QAAQ;QACX,SAAS,EAAE,GAAG,EAAE;YACf,MAAM,EAAE,MAAM,EAAE,WAAW,EAAE,GAAG,uBAAuB,CAAC,QAAQ,CAAC,EAAE,EAAE,QAAQ,CAAC,SAAS,EAAE,EAAE;gBAC1F,mBAAmB,EAAE,oBAAoB,CAAC,EAAE,QAAQ,EAAE,QAAQ,CAAC,EAAE,EAAE,CAAC;oBACnE,CAAC,CAAC,OAAO,CAAC,sBAAsB,EAAE,EAAE;oBACpC,CAAC,CAAC,SAAS;gBACZ,cAAc,EAAE,OAAO,CAAC,iBAAiB,EAAE,EAAE;gBAC7C,kBAAkB,EAAE,OAAO,CAAC,qBAAqB,EAAE,EAAE;gBACrD,cAAc,EAAE,OAAO,CAAC,iBAAiB,EAAE,EAAE;aAC7C,CAAC,CAAC;YACH,OAAO,CAAC,aAAa,EAAE,CAAC,QAAQ,CAAC,EAAE,EAAE,WAAW,CAAC,CAAC;YAClD,OAAO,MAAM,CAAC;QACf,CAAC;KACD,CAAC;AACH,CAAC","sourcesContent":["import {\n\ttype Api,\n\ttype Credential,\n\tgetServiceTierCost,\n\ttype Model,\n\ttype ModelFastRoute,\n\ttype Provider,\n} from \"@bastani/pi-ai\";\nimport type { ModelsJsonModelOverride } from \"./model-config.ts\";\nimport { applyModelOverride } from \"./provider-composer-internal.ts\";\n\n/** Canonical suffix every selectable fast model variant carries. */\nexport const FAST_MODEL_ID_SUFFIX = \"-fast\";\n\n/** Service tier OpenAI-style providers use to route fast traffic. */\nexport const FAST_MODEL_SERVICE_TIER = \"priority\" as const;\n\n/** Codex's Ultrafast tier, offered only for models that advertise it; access depends on the account. */\nexport const ULTRAFAST_MODEL_ID_SUFFIX = \"-ultrafast\";\nexport const ULTRAFAST_MODEL_SERVICE_TIER = \"ultrafast\" as const;\n\n/** Inference speed Anthropic's Messages API uses to route fast traffic. */\nexport const FAST_MODEL_SPEED = \"fast\" as const;\n\n/**\n * Claude models Anthropic's fast mode accepts. Requesting `speed: \"fast\"` on any other model is an\n * error, so the list is explicit rather than a family-name pattern.\n * https://platform.claude.com/docs/en/build-with-claude/fast-mode#supported-models\n */\nexport const ANTHROPIC_FAST_MODE_MODEL_IDS: ReadonlySet<string> = new Set([\n\t\"claude-opus-5-5\",\n\t\"claude-opus-5\",\n\t\"claude-opus-4-8\",\n]);\n\n/** A derived fast variant that was suppressed because something already owns its exact model ID. */\nexport interface FastModelVariantDiagnostic {\n\tprovider: string;\n\t/** The exact selectable model ID that collided. */\n\tmodelId: string;\n\tmessage: string;\n}\n\nexport interface FastModelVariantDerivation {\n\tmodels: readonly Model<Api>[];\n\tdiagnostics: readonly FastModelVariantDiagnostic[];\n}\n\nexport interface DeriveFastModelVariantsOptions {\n\t/** Exact fast model IDs the stored GitHub Copilot credential advertises for this account. */\n\tcopilotFastModelIds?: readonly string[];\n\t/** `models.json` `modelOverrides` for this provider, applied to derived entries by their exact `-fast` ID. */\n\tmodelOverrides?: Readonly<Record<string, ModelsJsonModelOverride>>;\n\t/** APIs whose transport a registered extension owns for this provider. No variant is derived for them. */\n\textensionOwnedApis?: ReadonlySet<Api>;\n\t/** IDs explicitly declared in this provider's models.json models array. Never derive siblings for them. */\n\tcustomModelIds?: ReadonlySet<string>;\n}\n\nexport interface FastModelVariantsOptions {\n\t/**\n\t * Synchronous read of the exact fast model IDs the stored GitHub Copilot credential advertises.\n\t * Read per call so a credential that lands after provider composition still takes effect.\n\t */\n\tgetCopilotFastModelIds?: () => readonly string[] | undefined;\n\t/** Synchronous read of this provider's `models.json` `modelOverrides`, so a reload takes effect. */\n\tgetModelOverrides?: () => Readonly<Record<string, ModelsJsonModelOverride>> | undefined;\n\t/** Read current custom model IDs per pass so models.json reloads update eligibility. */\n\tgetCustomModelIds?: () => ReadonlySet<string>;\n\t/**\n\t * Synchronous read of the APIs a registered extension supplies a stream function for. Read per call\n\t * because extensions register after initial composition on some paths.\n\t */\n\tgetExtensionOwnedApis?: () => ReadonlySet<Api> | undefined;\n\t/** Called after every derivation pass with the complete diagnostic list for this provider. */\n\tonDiagnostics?: (providerId: string, diagnostics: readonly FastModelVariantDiagnostic[]) => void;\n}\n\n/** Canonical selectable ID of the fast variant of `baseModelId`. */\nexport function fastModelId(baseModelId: string): string {\n\treturn `${baseModelId}${FAST_MODEL_ID_SUFFIX}`;\n}\n\n/**\n * The two pi-ai adapters that serialize `service_tier`. `azure-openai-responses` and\n * `openai-completions` have no such option, and `streamSimple` drops it, so a service-tier route on\n * any other API would silently degrade to an ordinary request.\n */\nexport function isNativeFastRouteApi(api: Api): api is \"openai-responses\" | \"openai-codex-responses\" {\n\treturn api === \"openai-responses\" || api === \"openai-codex-responses\";\n}\n\n/**\n * OpenAI-style fast routing keeps the base upstream model ID and adds a priority service tier.\n *\n * Eligibility requires both a first-party provider ID and an adapter that serializes\n * `service_tier`. A renamed provider, proxy, Azure (`azure`), OpenRouter\n * (`openai-completions`), and generic OpenAI-compatible providers do not qualify. An `openai` or\n * `openai-codex` model on an adapter that cannot carry `service_tier` must not offer a fast variant,\n * because selecting it would send an ordinary request under a name that promises otherwise.\n */\nexport function usesOpenAIFastServiceTier(model: Pick<Model<Api>, \"api\" | \"provider\">): boolean {\n\treturn isNativeFastRouteApi(model.api) && (model.provider === \"openai\" || model.provider === \"openai-codex\");\n}\n\n/**\n * xAI Priority Processing keeps the base upstream Grok model ID and adds the same\n * `service_tier: \"priority\"` field on the Responses API. xAI has no `-fast` model slugs for current\n * Grok models; priority is billed at twice the standard token rates, and only when the response\n * confirms the tier. https://docs.x.ai/developers/advanced-api-usage/priority-processing\n *\n * Eligibility requires the first-party `xai` provider on `openai-responses`. OpenRouter, Vercel AI\n * Gateway, and renamed or proxied xAI-compatible providers do not qualify.\n */\nexport function usesXaiFastServiceTier(model: Pick<Model<Api>, \"api\" | \"provider\">): boolean {\n\treturn model.api === \"openai-responses\" && model.provider === \"xai\";\n}\n\n/** GitHub Copilot advertises real fast sibling model IDs per account; it never uses a service tier. */\nexport function isGitHubCopilotModel(model: Pick<Model<Api>, \"provider\">): boolean {\n\treturn model.provider === \"github-copilot\";\n}\n\n/**\n * Anthropic fast mode keeps the base upstream model ID and adds `speed: \"fast\"` with the fast-mode beta.\n *\n * Eligibility requires the first-party `anthropic` provider on the Messages API and a supported model.\n * Fast mode is not offered through Amazon Bedrock, Google Vertex, GitHub Copilot, OpenRouter, or a\n * renamed or proxied Anthropic-compatible provider.\n */\nexport function usesAnthropicFastMode(model: Pick<Model<Api>, \"api\" | \"id\" | \"provider\">): boolean {\n\treturn (\n\t\tmodel.api === \"anthropic-messages\" &&\n\t\tmodel.provider === \"anthropic\" &&\n\t\tANTHROPIC_FAST_MODE_MODEL_IDS.has(model.id)\n\t);\n}\n\nfunction advertisedModelIds(value: unknown): readonly string[] | undefined {\n\tif (!Array.isArray(value) || !value.every((entry) => typeof entry === \"string\")) return undefined;\n\treturn value;\n}\n\n/** Read the exact fast model IDs a stored GitHub Copilot OAuth credential advertises. */\nexport function copilotAdvertisedFastModelIds(credential: Credential | undefined): readonly string[] | undefined {\n\tif (credential?.type !== \"oauth\") return undefined;\n\treturn advertisedModelIds(credential.fastModelIds);\n}\n\n/**\n * Whether a stored GitHub Copilot OAuth credential advertises this exact model ID at all — as a\n * selectable picker/policy model or as a fast sibling.\n *\n * Copilot's per-account advertisement is the authority the provider's own `filterModels` uses, so\n * restoration consults the same lists. An ID the account advertises as an ordinary model is ordinary,\n * whatever its name ends in.\n */\nexport function copilotAdvertisesModelId(credential: Credential | undefined, modelId: string): boolean {\n\tif (credential?.type !== \"oauth\") return false;\n\treturn (\n\t\tadvertisedModelIds(credential.availableModelIds)?.includes(modelId) === true ||\n\t\tadvertisedModelIds(credential.fastModelIds)?.includes(modelId) === true\n\t);\n}\n\n/** A model without tier metadata keeps offering Fast; one that lists its tiers must advertise it, as in Codex. */\nfunction advertisesFastServiceTier(model: Model<Api>): boolean {\n\treturn model.serviceTiers === undefined || getServiceTierCost(model, FAST_MODEL_SERVICE_TIER) !== undefined;\n}\n\nfunction fastRouteForBaseModel(\n\tmodel: Model<Api>,\n\tentitledCopilotFastModelIds: ReadonlySet<string>,\n): ModelFastRoute | undefined {\n\tif (usesOpenAIFastServiceTier(model)) {\n\t\treturn advertisesFastServiceTier(model)\n\t\t\t? { baseModelId: model.id, upstreamModelId: model.id, serviceTier: FAST_MODEL_SERVICE_TIER }\n\t\t\t: undefined;\n\t}\n\tif (usesXaiFastServiceTier(model)) {\n\t\treturn { baseModelId: model.id, upstreamModelId: model.id, serviceTier: FAST_MODEL_SERVICE_TIER };\n\t}\n\tif (usesAnthropicFastMode(model)) {\n\t\treturn { baseModelId: model.id, upstreamModelId: model.id, speed: FAST_MODEL_SPEED };\n\t}\n\tif (isGitHubCopilotModel(model)) {\n\t\tconst advertisedId = fastModelId(model.id);\n\t\treturn entitledCopilotFastModelIds.has(advertisedId)\n\t\t\t? { baseModelId: model.id, upstreamModelId: advertisedId }\n\t\t\t: undefined;\n\t}\n\treturn undefined;\n}\n\n/**\n * Add a selectable `<base-model-id>-fast` entry for every eligible model, carrying the explicit\n * {@link ModelFastRoute} metadata that gives it fast semantics. The input list is preserved verbatim\n * and in order; each derived entry is appended directly after the model it derives from.\n *\n * A model whose exact `-fast` ID is already owned by the provider, a `models.json` custom model, or an\n * extension wins: derivation is suppressed for it and a diagnostic is recorded. The owning model keeps\n * whatever semantics it declares, because fast behavior comes only from `fastRoute`, never from the\n * `-fast` suffix. For the same reason a base model whose ID already ends in `-fast` is never used to\n * derive a `-fast-fast` variant: that is not a canonical ID this scheme defines.\n *\n * A derived entry is a real catalog model, so a `modelOverrides` entry keyed on its exact `-fast` ID\n * applies to it after derivation. Without that pass the derived entry would inherit the *base* model's\n * overrides and its own would be silently inert.\n *\n * No variant is derived for an API whose transport a registered extension owns, because Atomic cannot\n * enforce the route through a transport it does not serialize.\n */\nexport function deriveFastModelVariants(\n\tproviderId: string,\n\tmodels: readonly Model<Api>[],\n\toptions: DeriveFastModelVariantsOptions = {},\n): FastModelVariantDerivation {\n\tconst ownedModelIds = new Set(models.map((model) => model.id));\n\tconst entitledCopilotFastModelIds = new Set(options.copilotFastModelIds ?? []);\n\tconst derived: Model<Api>[] = [];\n\tconst diagnostics: FastModelVariantDiagnostic[] = [];\n\tlet changed = false;\n\tfor (const model of models) {\n\t\tderived.push(model);\n\t\tif (\n\t\t\tmodel.fastRoute !== undefined ||\n\t\t\tmodel.id.endsWith(FAST_MODEL_ID_SUFFIX) ||\n\t\t\tmodel.id.endsWith(ULTRAFAST_MODEL_ID_SUFFIX)\n\t\t)\n\t\t\tcontinue;\n\t\tif (options.customModelIds?.has(model.id)) continue;\n\t\t// An extension that supplies this API's stream function owns its serialization, so Atomic cannot\n\t\t// guarantee the route reaches the wire. Publishing a `-fast` choice it may not honor is the same\n\t\t// hazard as publishing one for an adapter that cannot carry the tier.\n\t\tif (options.extensionOwnedApis?.has(model.api) === true) continue;\n\t\tconst fastRoute = fastRouteForBaseModel(model, entitledCopilotFastModelIds);\n\t\tconst routes: Array<{ suffix: string; label: string; route: ModelFastRoute }> = [];\n\t\tif (fastRoute) routes.push({ suffix: FAST_MODEL_ID_SUFFIX, label: \"fast\", route: fastRoute });\n\t\tif (usesOpenAIFastServiceTier(model) && getServiceTierCost(model, ULTRAFAST_MODEL_SERVICE_TIER)) {\n\t\t\troutes.push({\n\t\t\t\tsuffix: ULTRAFAST_MODEL_ID_SUFFIX,\n\t\t\t\tlabel: \"ultrafast\",\n\t\t\t\troute: { baseModelId: model.id, upstreamModelId: model.id, serviceTier: ULTRAFAST_MODEL_SERVICE_TIER },\n\t\t\t});\n\t\t}\n\t\tfor (const { suffix, label, route } of routes) {\n\t\t\tconst variantId = `${model.id}${suffix}`;\n\t\t\tif (ownedModelIds.has(variantId)) {\n\t\t\t\tdiagnostics.push({\n\t\t\t\t\tprovider: providerId,\n\t\t\t\t\tmodelId: variantId,\n\t\t\t\t\tmessage:\n\t\t\t\t\t\t`Model \"${providerId}/${variantId}\" is already defined by the provider, models.json, or an extension, ` +\n\t\t\t\t\t\t`so Atomic did not derive a ${label} variant of \"${providerId}/${model.id}\". ` +\n\t\t\t\t\t\t`That model routes exactly as declared. Rename or remove it to get the derived ${label} variant instead.`,\n\t\t\t\t});\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tconst override = options.modelOverrides?.[variantId];\n\t\t\tconst variant: Model<Api> = { ...model, id: variantId, name: `${model.name} (${label})`, fastRoute: route };\n\t\t\tderived.push(override ? applyModelOverride(variant, override) : variant);\n\t\t\tchanged = true;\n\t\t}\n\t}\n\tif (!changed && diagnostics.length === 0) return { models, diagnostics };\n\treturn { models: derived, diagnostics };\n}\n\n/**\n * Overlay derived fast model variants onto a composed provider. Apply this after built-in,\n * `models.json`, extension, and `modelOverrides` composition so exact user-owned `-fast` IDs are\n * already present and win the collision.\n */\nexport function withFastModelVariants(provider: Provider, options: FastModelVariantsOptions = {}): Provider {\n\treturn {\n\t\t...provider,\n\t\tgetModels: () => {\n\t\t\tconst { models, diagnostics } = deriveFastModelVariants(provider.id, provider.getModels(), {\n\t\t\t\tcopilotFastModelIds: isGitHubCopilotModel({ provider: provider.id })\n\t\t\t\t\t? options.getCopilotFastModelIds?.()\n\t\t\t\t\t: undefined,\n\t\t\t\tmodelOverrides: options.getModelOverrides?.(),\n\t\t\t\textensionOwnedApis: options.getExtensionOwnedApis?.(),\n\t\t\t\tcustomModelIds: options.getCustomModelIds?.(),\n\t\t\t});\n\t\t\toptions.onDiagnostics?.(provider.id, diagnostics);\n\t\t\treturn models;\n\t\t},\n\t};\n}\n"]}
|
|
@@ -89,11 +89,11 @@ export declare const KEYBINDINGS: {
|
|
|
89
89
|
readonly description: "Move cursor word right";
|
|
90
90
|
};
|
|
91
91
|
readonly "tui.editor.cursorLineStart": {
|
|
92
|
-
readonly defaultKeys: ["home", "ctrl+
|
|
92
|
+
readonly defaultKeys: ["home", "ctrl+a"];
|
|
93
93
|
readonly description: "Move to line start";
|
|
94
94
|
};
|
|
95
95
|
readonly "tui.editor.cursorLineEnd": {
|
|
96
|
-
readonly defaultKeys: ["end", "ctrl+
|
|
96
|
+
readonly defaultKeys: ["end", "ctrl+e"];
|
|
97
97
|
readonly description: "Move to line end";
|
|
98
98
|
};
|
|
99
99
|
readonly "tui.editor.jumpForward": {
|
|
@@ -209,11 +209,11 @@ export declare const KEYBINDINGS: {
|
|
|
209
209
|
readonly description: "Scroll viewport down one line";
|
|
210
210
|
};
|
|
211
211
|
readonly "tui.altScreen.top": {
|
|
212
|
-
readonly defaultKeys: "home";
|
|
212
|
+
readonly defaultKeys: "ctrl+home";
|
|
213
213
|
readonly description: "Scroll viewport to top";
|
|
214
214
|
};
|
|
215
215
|
readonly "tui.altScreen.bottom": {
|
|
216
|
-
readonly defaultKeys: "end";
|
|
216
|
+
readonly defaultKeys: "ctrl+end";
|
|
217
217
|
readonly description: "Scroll viewport to bottom";
|
|
218
218
|
};
|
|
219
219
|
readonly "app.workflows.scrollUp": {
|
package/dist/core/messages.d.ts
CHANGED
|
@@ -66,6 +66,7 @@ export declare function messageIsLlmVisible(message: AgentMessage, deletedBlockI
|
|
|
66
66
|
*/
|
|
67
67
|
export declare function bashExecutionToText(msg: BashExecutionMessage): string;
|
|
68
68
|
export declare const VERBATIM_COMPACTION_PREFIX = "The earlier conversation was compacted. Below is the verbatim transcript of the retained lines; elided spans are marked \"(filtered N lines)\".\n\n";
|
|
69
|
+
export declare const SUMMARY_COMPACTION_PREFIX = "The following is a summary of the earlier conversation:\n\n";
|
|
69
70
|
export declare function isVerbatimCompactionMessage(message: CustomMessage): boolean;
|
|
70
71
|
/**
|
|
71
72
|
* Create the visible custom-role boundary used to replay a verbatim compaction.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"messages.d.ts","sourceRoot":"","sources":["../../src/core/messages.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,OAAO,EAAE,WAAW,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AACnG,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,+BAA+B,CAAC;AAGlE,eAAO,MAAM,qBAAqB,iGAGjC,CAAC;AAEF,eAAO,MAAM,qBAAqB,eAAe,CAAC;AAElD;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACpC,IAAI,EAAE,eAAe,CAAC;IACtB,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,MAAM,GAAG,SAAS,CAAC;IAC7B,SAAS,EAAE,OAAO,CAAC;IACnB,SAAS,EAAE,OAAO,CAAC;IACnB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,SAAS,EAAE,MAAM,CAAC;IAClB,qEAAqE;IACrE,kBAAkB,CAAC,EAAE,OAAO,CAAC;CAC7B;AAED;;;GAGG;AAEH,MAAM,WAAW,aAAa,CAAC,CAAC,GAAG,OAAO;IACzC,IAAI,EAAE,QAAQ,CAAC;IACf,UAAU,EAAE,MAAM,CAAC;IACnB,OAAO,EAAE,MAAM,GAAG,CAAC,WAAW,GAAG,YAAY,CAAC,EAAE,CAAC;IACjD,OAAO,EAAE,OAAO,CAAC;IACjB,OAAO,CAAC,EAAE,CAAC,CAAC;IACZ,SAAS,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,MAAM,0BAA0B,CAAC,CAAC,GAAG,OAAO,IAAI,aAAa,CAAC,CAAC,CAAC,GAAG;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