@bastani/atomic 0.9.13-alpha.2 → 0.9.13-alpha.3
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 +14 -0
- package/README.md +1 -1
- package/dist/builtin/i-have-adhd/package.json +1 -1
- package/dist/builtin/intercom/CHANGELOG.md +14 -0
- package/dist/builtin/intercom/README.md +12 -12
- package/dist/builtin/intercom/incoming-message-delivery.ts +1 -1
- package/dist/builtin/intercom/index.ts +1 -1
- package/dist/builtin/intercom/intercom-tool.ts +1 -1
- package/dist/builtin/intercom/intercom-utils.ts +3 -6
- package/dist/builtin/intercom/package.json +1 -1
- package/dist/builtin/intercom/result-renderers.ts +1 -1
- package/dist/builtin/intercom/session-target.ts +1 -15
- package/dist/builtin/intercom/skills/intercom/SKILL.md +6 -6
- package/dist/builtin/intercom/terminal-ordering-barrier.ts +2 -2
- package/dist/builtin/intercom/ui/inline-message.ts +7 -5
- package/dist/builtin/intercom/ui/session-list.ts +23 -10
- package/dist/builtin/mcp/package.json +1 -1
- package/dist/builtin/subagents/CHANGELOG.md +19 -0
- package/dist/builtin/subagents/README.md +29 -73
- package/dist/builtin/subagents/package.json +2 -2
- package/dist/builtin/subagents/prompts/parallel-cleanup.md +1 -1
- package/dist/builtin/subagents/prompts/parallel-review.md +1 -1
- package/dist/builtin/subagents/prompts/review-loop.md +2 -2
- package/dist/builtin/subagents/skills/subagent/SKILL.md +23 -59
- package/dist/builtin/subagents/skills/tmux/SKILL.md +1 -1
- package/dist/builtin/subagents/src/extension/control-notices.ts +2 -3
- package/dist/builtin/subagents/src/extension/doctor.ts +2 -14
- package/dist/builtin/subagents/src/extension/fanout-child.ts +1 -17
- package/dist/builtin/subagents/src/extension/index.ts +9 -70
- package/dist/builtin/subagents/src/extension/notification-content.ts +1 -1
- package/dist/builtin/subagents/src/extension/prompt-guidance.ts +2 -2
- package/dist/builtin/subagents/src/extension/schemas.ts +2 -8
- package/dist/builtin/subagents/src/extension/tool-description.ts +2 -3
- package/dist/builtin/subagents/src/intercom/intercom-bridge.ts +1 -1
- package/dist/builtin/subagents/src/intercom/result-intercom.ts +5 -46
- package/dist/builtin/subagents/src/runs/{background → foreground}/completion-notification.ts +2 -2
- package/dist/builtin/subagents/src/runs/foreground/inprocess-run-sync.ts +25 -88
- package/dist/builtin/subagents/src/runs/{background → foreground}/notify.ts +5 -5
- package/dist/builtin/subagents/src/runs/foreground/subagent-executor-context.ts +11 -28
- package/dist/builtin/subagents/src/runs/foreground/subagent-executor-parallel-task.ts +3 -0
- package/dist/builtin/subagents/src/runs/foreground/subagent-executor-parallel.ts +2 -0
- package/dist/builtin/subagents/src/runs/foreground/subagent-executor-runtime.ts +0 -5
- package/dist/builtin/subagents/src/runs/foreground/subagent-executor-single.ts +30 -20
- package/dist/builtin/subagents/src/runs/foreground/subagent-executor-status.ts +4 -4
- package/dist/builtin/subagents/src/runs/foreground/subagent-executor-types.ts +0 -13
- package/dist/builtin/subagents/src/runs/foreground/subagent-executor.ts +104 -48
- package/dist/builtin/subagents/src/runs/inprocess/index.ts +1 -1
- package/dist/builtin/subagents/src/runs/inprocess/runner.ts +5 -5
- package/dist/builtin/subagents/src/runs/inprocess/runtime-support/nested-api.ts +0 -7
- package/dist/builtin/subagents/src/runs/inprocess/runtime-support/nested-core.ts +0 -10
- package/dist/builtin/subagents/src/runs/inprocess/runtime-support/nested-projection.ts +3 -108
- package/dist/builtin/subagents/src/runs/inprocess/runtime-support/nested-sanitize.ts +0 -4
- package/dist/builtin/subagents/src/runs/shared/subagent-control.ts +1 -1
- package/dist/builtin/subagents/src/shared/formatters.ts +3 -5
- package/dist/builtin/subagents/src/shared/model-resolution.ts +78 -0
- package/dist/builtin/subagents/src/shared/status-format.ts +4 -11
- package/dist/builtin/subagents/src/shared/types-config.ts +10 -9
- package/dist/builtin/subagents/src/shared/types-nested.ts +127 -0
- package/dist/builtin/subagents/src/shared/types-results.ts +2 -8
- package/dist/builtin/subagents/src/shared/types-runtime.ts +0 -9
- package/dist/builtin/subagents/src/shared/types.ts +1 -1
- package/dist/builtin/subagents/src/shared/utils.ts +1 -109
- package/dist/builtin/subagents/src/slash/slash-commands.ts +7 -17
- package/dist/builtin/subagents/src/tui/render-event-formatting.ts +2 -252
- package/dist/builtin/subagents/src/tui/render-layout.ts +4 -4
- package/dist/builtin/subagents/src/tui/render-result.ts +0 -9
- package/dist/builtin/subagents/src/tui/render-stable-output.ts +1 -34
- package/dist/builtin/subagents/src/tui/render.ts +0 -2
- package/dist/builtin/web-access/package.json +1 -1
- package/dist/builtin/workflows/CHANGELOG.md +12 -0
- package/dist/builtin/workflows/README.md +3 -3
- package/dist/builtin/workflows/package.json +1 -1
- package/dist/builtin/workflows/src/durable/backend.ts +11 -0
- package/dist/builtin/workflows/src/durable/completed-catalog-stage-groups.ts +63 -25
- package/dist/builtin/workflows/src/durable/completed-catalog.ts +166 -25
- package/dist/builtin/workflows/src/durable/dbos-backend.ts +42 -24
- package/dist/builtin/workflows/src/durable/dbos-envelope.ts +2 -1
- package/dist/builtin/workflows/src/durable/run-timing.ts +28 -7
- package/dist/builtin/workflows/src/durable/scoped-backend.ts +4 -0
- package/dist/builtin/workflows/src/durable/targeted-inspection.ts +110 -0
- package/dist/builtin/workflows/src/engine/run-durable-stage-session.ts +2 -2
- package/dist/builtin/workflows/src/engine/runtime.ts +19 -2
- package/dist/builtin/workflows/src/extension/extension-runtime-state.ts +3 -0
- package/dist/builtin/workflows/src/extension/index.bundle.mjs +680 -152
- package/dist/builtin/workflows/src/extension/runtime-durable-resume.ts +6 -0
- package/dist/builtin/workflows/src/extension/ui-surface.ts +2 -0
- package/dist/builtin/workflows/src/extension/workflow-command-registration.ts +6 -1
- package/dist/builtin/workflows/src/extension/workflow-targets.ts +18 -10
- package/dist/builtin/workflows/src/extension/workflow-tool-inspection.ts +31 -16
- package/dist/builtin/workflows/src/extension/workflow-tool-send.ts +75 -3
- package/dist/builtin/workflows/src/extension/workflow-tool.ts +53 -6
- package/dist/builtin/workflows/src/runs/background/run-inspect.ts +5 -1
- package/dist/builtin/workflows/src/runs/foreground/executor-stage-call.ts +94 -60
- package/dist/builtin/workflows/src/runs/foreground/executor-stage-context.ts +1 -1
- package/dist/builtin/workflows/src/runs/foreground/executor-stage-control.ts +7 -7
- package/dist/builtin/workflows/src/runs/foreground/executor-stage-factory.ts +25 -4
- package/dist/builtin/workflows/src/runs/foreground/executor-stage-types.ts +4 -1
- package/dist/builtin/workflows/src/runs/foreground/executor-types.ts +2 -0
- package/dist/builtin/workflows/src/runs/foreground/stage-runner-controller.ts +142 -4
- package/dist/builtin/workflows/src/runs/foreground/stage-runner-types.ts +2 -0
- package/dist/builtin/workflows/src/runs/foreground/stage-session-heartbeat.ts +88 -0
- package/dist/builtin/workflows/src/tui/run-detail.ts +25 -12
- package/dist/builtin/workflows/src/tui/workflow-resume-selector.ts +1 -0
- package/dist/core/agent-session-events.d.ts.map +1 -1
- package/dist/core/agent-session-events.js +16 -5
- package/dist/core/agent-session-events.js.map +1 -1
- package/dist/core/agent-session-export.d.ts.map +1 -1
- package/dist/core/agent-session-export.js +2 -1
- package/dist/core/agent-session-export.js.map +1 -1
- package/dist/core/agent-session-methods.d.ts +8 -4
- 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 +5 -0
- package/dist/core/agent-session-prompt.js.map +1 -1
- package/dist/core/agent-session-summary.d.ts +21 -0
- package/dist/core/agent-session-summary.d.ts.map +1 -0
- package/dist/core/agent-session-summary.js +156 -0
- package/dist/core/agent-session-summary.js.map +1 -0
- package/dist/core/agent-session-tool-registry.d.ts.map +1 -1
- package/dist/core/agent-session-tool-registry.js +0 -4
- package/dist/core/agent-session-tool-registry.js.map +1 -1
- package/dist/core/agent-session-transfer.d.ts.map +1 -1
- package/dist/core/agent-session-transfer.js +0 -2
- package/dist/core/agent-session-transfer.js.map +1 -1
- package/dist/core/agent-session-tree.d.ts.map +1 -1
- package/dist/core/agent-session-tree.js +6 -0
- package/dist/core/agent-session-tree.js.map +1 -1
- package/dist/core/agent-session.d.ts +7 -3
- package/dist/core/agent-session.d.ts.map +1 -1
- package/dist/core/agent-session.js +8 -5
- package/dist/core/agent-session.js.map +1 -1
- package/dist/core/atomic-guide-command.js +2 -2
- package/dist/core/atomic-guide-command.js.map +1 -1
- package/dist/core/compaction/branch-summarization.d.ts.map +1 -1
- package/dist/core/compaction/branch-summarization.js +1 -0
- package/dist/core/compaction/branch-summarization.js.map +1 -1
- package/dist/core/compaction/index.d.ts +1 -0
- package/dist/core/compaction/index.d.ts.map +1 -1
- package/dist/core/compaction/index.js +1 -0
- package/dist/core/compaction/index.js.map +1 -1
- package/dist/core/compaction/session-summarization.d.ts +41 -0
- package/dist/core/compaction/session-summarization.d.ts.map +1 -0
- package/dist/core/compaction/session-summarization.js +97 -0
- package/dist/core/compaction/session-summarization.js.map +1 -0
- package/dist/core/extensions/ui-types.d.ts +2 -0
- package/dist/core/extensions/ui-types.d.ts.map +1 -1
- package/dist/core/extensions/ui-types.js.map +1 -1
- package/dist/core/session-manager-core.d.ts +3 -1
- package/dist/core/session-manager-core.d.ts.map +1 -1
- package/dist/core/session-manager-core.js +9 -1
- package/dist/core/session-manager-core.js.map +1 -1
- package/dist/core/session-manager-entries.d.ts +24 -1
- package/dist/core/session-manager-entries.d.ts.map +1 -1
- package/dist/core/session-manager-entries.js +48 -0
- package/dist/core/session-manager-entries.js.map +1 -1
- package/dist/core/session-manager-list.d.ts.map +1 -1
- package/dist/core/session-manager-list.js +10 -0
- package/dist/core/session-manager-list.js.map +1 -1
- package/dist/core/session-manager-types.d.ts +10 -1
- package/dist/core/session-manager-types.d.ts.map +1 -1
- package/dist/core/session-manager-types.js.map +1 -1
- package/dist/core/settings-manager-basic-accessors.d.ts +3 -0
- package/dist/core/settings-manager-basic-accessors.d.ts.map +1 -1
- package/dist/core/settings-manager-basic-accessors.js +5 -0
- package/dist/core/settings-manager-basic-accessors.js.map +1 -1
- package/dist/core/settings-manager.d.ts +1 -1
- package/dist/core/settings-manager.d.ts.map +1 -1
- package/dist/core/settings-manager.js.map +1 -1
- package/dist/core/settings-types.d.ts +4 -0
- package/dist/core/settings-types.d.ts.map +1 -1
- package/dist/core/settings-types.js.map +1 -1
- package/dist/core/slash-commands.js +2 -2
- package/dist/core/slash-commands.js.map +1 -1
- package/dist/core/tools/bash.d.ts +0 -15
- package/dist/core/tools/bash.d.ts.map +1 -1
- package/dist/core/tools/bash.js +3 -81
- package/dist/core/tools/bash.js.map +1 -1
- package/dist/core/tools/fetch-url.d.ts +12 -0
- package/dist/core/tools/fetch-url.d.ts.map +1 -1
- package/dist/core/tools/fetch-url.js +76 -10
- package/dist/core/tools/fetch-url.js.map +1 -1
- package/dist/core/tools/index.js +4 -4
- package/dist/core/tools/index.js.map +1 -1
- package/dist/core/tools/session-temp-dir.d.ts +2 -2
- package/dist/core/tools/session-temp-dir.d.ts.map +1 -1
- package/dist/core/tools/session-temp-dir.js +6 -7
- package/dist/core/tools/session-temp-dir.js.map +1 -1
- package/dist/core/usage-totals.js +1 -1
- package/dist/core/usage-totals.js.map +1 -1
- package/dist/modes/interactive/components/footer.js +1 -1
- package/dist/modes/interactive/components/footer.js.map +1 -1
- package/dist/modes/interactive/components/host-session-picker.d.ts.map +1 -1
- package/dist/modes/interactive/components/host-session-picker.js +1 -0
- package/dist/modes/interactive/components/host-session-picker.js.map +1 -1
- package/dist/modes/interactive/components/session-selector-list.d.ts.map +1 -1
- package/dist/modes/interactive/components/session-selector-list.js +29 -4
- package/dist/modes/interactive/components/session-selector-list.js.map +1 -1
- package/dist/modes/interactive/components/session-selector-search.js +1 -1
- package/dist/modes/interactive/components/session-selector-search.js.map +1 -1
- package/dist/modes/interactive/components/tree-selector-content.d.ts.map +1 -1
- package/dist/modes/interactive/components/tree-selector-content.js +6 -0
- package/dist/modes/interactive/components/tree-selector-content.js.map +1 -1
- package/dist/modes/interactive-engine/protocol.d.ts.map +1 -1
- package/dist/modes/interactive-engine/protocol.js +4 -1
- package/dist/modes/interactive-engine/protocol.js.map +1 -1
- package/docs/environment-variables.md +1 -1
- package/docs/intercom.md +20 -21
- package/docs/quickstart.md +5 -1
- package/docs/sdk.md +1 -1
- package/docs/session-format.md +15 -0
- package/docs/sessions.md +8 -0
- package/docs/settings.md +6 -0
- package/docs/subagents.md +19 -31
- package/docs/tools.md +3 -5
- package/docs/usage.md +1 -1
- package/docs/windows.md +1 -1
- package/docs/workflows.md +60 -32
- package/npm-shrinkwrap.json +29 -29
- package/package.json +2 -2
- package/dist/builtin/subagents/src/runs/background/async-job-tracker.ts +0 -331
- package/dist/builtin/subagents/src/runs/foreground/subagent-executor-async.ts +0 -161
- package/dist/builtin/subagents/src/runs/inprocess/background-single.ts +0 -195
- package/dist/builtin/subagents/src/runs/inprocess/background.ts +0 -90
- package/dist/builtin/subagents/src/shared/types-async.ts +0 -247
- package/dist/builtin/subagents/src/tui/render-widget-graph.ts +0 -217
- package/dist/builtin/subagents/src/tui/render-widget.ts +0 -366
- package/dist/core/async/format.d.ts +0 -3
- package/dist/core/async/format.d.ts.map +0 -1
- package/dist/core/async/format.js +0 -52
- package/dist/core/async/format.js.map +0 -1
- package/dist/core/async/job-manager.d.ts +0 -40
- package/dist/core/async/job-manager.d.ts.map +0 -1
- package/dist/core/async/job-manager.js +0 -293
- package/dist/core/async/job-manager.js.map +0 -1
- package/dist/core/async/session-manager.d.ts +0 -16
- package/dist/core/async/session-manager.d.ts.map +0 -1
- package/dist/core/async/session-manager.js +0 -34
- package/dist/core/async/session-manager.js.map +0 -1
- package/dist/core/async/types.d.ts +0 -23
- package/dist/core/async/types.d.ts.map +0 -1
- package/dist/core/async/types.js +0 -2
- package/dist/core/async/types.js.map +0 -1
- package/dist/core/tools/bash-async-execution.d.ts +0 -27
- package/dist/core/tools/bash-async-execution.d.ts.map +0 -1
- package/dist/core/tools/bash-async-execution.js +0 -81
- package/dist/core/tools/bash-async-execution.js.map +0 -1
- package/dist/core/tools/bash-async-jobs.d.ts +0 -30
- package/dist/core/tools/bash-async-jobs.d.ts.map +0 -1
- package/dist/core/tools/bash-async-jobs.js +0 -87
- package/dist/core/tools/bash-async-jobs.js.map +0 -1
- package/dist/core/tools/bash-async-output.d.ts +0 -13
- package/dist/core/tools/bash-async-output.d.ts.map +0 -1
- package/dist/core/tools/bash-async-output.js +0 -122
- package/dist/core/tools/bash-async-output.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agent-session-prompt.js","sourceRoot":"","sources":["../../src/core/agent-session-prompt.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAGvC,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAC3D,OAAO,EAAE,kCAAkC,EAAE,MAAM,wCAAwC,CAAC;AAG5F,OAAO,EACN,yBAAyB,EACzB,yBAAyB,EACzB,wBAAwB,EACxB,qBAAqB,EACrB,uBAAuB,EACvB,wBAAwB,GACxB,MAAM,2BAA2B,CAAC;AACnC,OAAO,EACN,0BAA0B,EAC1B,4BAA4B,EAC5B,4BAA4B,GAC5B,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AACrD,OAAO,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAC;AAa7D,oFAAoF;AACpF,MAAM,CAAC,KAAK,UAAU,6BAA6B,CAClD,OAA6F,EAC7F,IAAY;IAEZ,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC;QAAE,OAAO,KAAK,CAAC;IACxC,IAAI,MAAM,OAAO,CAAC,8BAA8B,CAAC,IAAI,CAAC;QAAE,OAAO,IAAI,CAAC;IACpE,OAAO,OAAO,CAAC,2BAA2B,CAAC,IAAI,CAAC,CAAC;AAClD,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,MAAM,CAA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I,CAAC,CAAC;QAC5B,IAAI,MAAM,CAAC,MAAM,KAAK,CAAC;YAAE,MAAM,GAAG,SAAS,CAAC;IAC7C,CAAC;IAED,kGAAkG;IAClG,6EAA6E;IAC7E,oEAAoE;IACpE,MAAM,IAAI,CAAC,MAAM,CAAC,IAAI,EAAE;QACvB,qBAAqB,EAAE,KAAK;QAC5B,iBAAiB,EAAE,OAAO,EAAE,SAAS;QACrC,MAAM;QACN,MAAM,EAAE,WAAW;QACnB,kBAAkB,EAAE,OAAO,EAAE,kBAAkB;KACV,CAAC,CAAC;AACzC,CAAC;AAED;;;;GAIG;AAEH,MAAM,CAAC,MAAM,yBAAyB,GAAG;IACxC,MAAM;IACN,eAAe;IACf,iBAAiB;IACjB,4BAA4B;IAC5B,8BAA8B;IAC9B,2BAA2B;IAC3B,mBAAmB;IACnB,KAAK;IACL,QAAQ;IACR,eAAe;CACf,CAAC","sourcesContent":["import { readFileSync } from \"node:fs\";\nimport type { AgentMessage } from \"@earendil-works/pi-agent-core\";\nimport type { ImageContent, TextContent } from \"@earendil-works/pi-ai/compat\";\nimport { stripFrontmatter } from \"../utils/frontmatter.ts\";\nimport { resolveWorkflowStageDeliveryTarget } from \"./agent-session-delivery-forwarding.ts\";\nimport type { AgentSessionInternalSurface as AgentSession } from \"./agent-session-methods.ts\";\nimport type { PromptOptions } from \"./agent-session-types.ts\";\nimport {\n\tATOMIC_GUIDE_COMMAND_NAME,\n\tATOMIC_GUIDE_HELP_CHOICES,\n\tatomicGuideModeForChoice,\n\tgetAtomicGuideMessage,\n\tisAtomicGuideHelpChoice,\n\tnormalizeAtomicGuideMode,\n} from \"./atomic-guide-command.ts\";\nimport {\n\tformatNoApiKeyFoundMessage,\n\tformatNoModelSelectedMessage,\n\tformatUnresolvedModelMessage,\n} from \"./auth-guidance.ts\";\nimport { runCallback } from \"./callback-activity.ts\";\nimport { expandPromptTemplate } from \"./prompt-templates.ts\";\n\ntype UserMessageDeliveryAction = \"prompt\" | \"steer\" | \"followUp\" | \"handled\";\n\ntype PromptOptionsWithWorkflowDelivery = PromptOptions & {\n\treadonly __workflowDelivery?: {\n\t\treadonly beforeDelivery?: () => void;\n\t\t/** Called only after an idle prompt has synchronously entered the agent turn. */\n\t\treadonly promptStarted?: () => void;\n\t\treadonly delivered?: (action: UserMessageDeliveryAction) => void;\n\t};\n};\n\n/** Dispatch registered slash commands without changing the raw queue pause gate. */\nexport async function tryExecuteSessionSlashCommand(\n\tsession: Pick<AgentSession, \"_tryExecuteBuiltinSlashCommand\" | \"_tryExecuteExtensionCommand\">,\n\ttext: string,\n): Promise<boolean> {\n\tif (!text.startsWith(\"/\")) return false;\n\tif (await session._tryExecuteBuiltinSlashCommand(text)) return true;\n\treturn session._tryExecuteExtensionCommand(text);\n}\n\nexport async function prompt(this: AgentSession, text: string, options?: PromptOptions): Promise<void> {\n\tconst owner = resolveWorkflowStageDeliveryTarget(this);\n\tif (owner !== this) return owner.prompt(text, options);\n\tconst expandPromptTemplates = options?.expandPromptTemplates ?? true;\n\tconst preflightResult = options?.preflightResult;\n\tconst workflowDelivery = (options as PromptOptionsWithWorkflowDelivery | undefined)?.__workflowDelivery;\n\tlet messages: AgentMessage[] | undefined;\n\n\ttry {\n\t\t// Authorize workflow delivery before commands or input extensions can perform side effects.\n\t\t// A later terminal transition cannot retroactively reject input accepted at this boundary.\n\t\tworkflowDelivery?.beforeDelivery?.();\n\t\t// Registered slash commands execute without releasing ordinary queued work.\n\t\t// Unknown slash input continues through the normal paused admission path.\n\t\tif (expandPromptTemplates && (await tryExecuteSessionSlashCommand(this, text))) {\n\t\t\tworkflowDelivery?.delivered?.(\"handled\");\n\t\t\tpreflightResult?.(true);\n\t\t\treturn;\n\t\t}\n\t\t// A controlled pause is an admission gate, including the idle gap after\n\t\t// abort settles. Preserve the raw user payload without running input hooks,\n\t\t// compaction, or a provider turn; explicit resume makes it eligible again.\n\t\tif (this._queuedMessagesPaused) {\n\t\t\tconst delivery = options?.streamingBehavior === \"followUp\" ? \"followUp\" : \"steer\";\n\t\t\tif (delivery === \"followUp\") await this._queueFollowUp(text, options?.images);\n\t\t\telse await this._queueSteer(text, options?.images);\n\t\t\tworkflowDelivery?.delivered?.(delivery);\n\t\t\tpreflightResult?.(true);\n\t\t\treturn;\n\t\t}\n\n\t\t// Emit input event for extension interception (before skill/template expansion)\n\t\tlet currentText = text;\n\t\tlet currentImages = options?.images;\n\t\tif (this._extensionRunner.hasHandlers(\"input\")) {\n\t\t\tconst inputResult = await this._extensionRunner.emitInput(\n\t\t\t\tcurrentText,\n\t\t\t\tcurrentImages,\n\t\t\t\toptions?.source ?? \"interactive\",\n\t\t\t\tthis.isStreaming ? options?.streamingBehavior : undefined,\n\t\t\t);\n\t\t\tif (inputResult.action === \"handled\") {\n\t\t\t\tworkflowDelivery?.delivered?.(\"handled\");\n\t\t\t\tpreflightResult?.(true);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (inputResult.action === \"transform\") {\n\t\t\t\tcurrentText = inputResult.text;\n\t\t\t\tcurrentImages = inputResult.images ?? currentImages;\n\t\t\t}\n\t\t}\n\n\t\t// Expand skill commands (/skill:name args) and prompt templates (/template args)\n\t\tlet expandedText = currentText;\n\t\tif (expandPromptTemplates) {\n\t\t\texpandedText = this._expandSkillCommand(expandedText);\n\t\t\texpandedText = expandPromptTemplate(expandedText, [...this.promptTemplates]);\n\t\t}\n\n\t\t// If streaming, queue via steer() or followUp() based on option\n\t\tif (this.isStreaming) {\n\t\t\tif (!options?.streamingBehavior) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t\"Agent is already processing. Specify streamingBehavior ('steer' or 'followUp') to queue the message.\",\n\t\t\t\t);\n\t\t\t}\n\t\t\tif (options.streamingBehavior === \"followUp\") {\n\t\t\t\tawait this._queueFollowUp(expandedText, currentImages);\n\t\t\t} else {\n\t\t\t\tawait this._queueSteer(expandedText, currentImages);\n\t\t\t}\n\t\t\tworkflowDelivery?.delivered?.(options.streamingBehavior);\n\t\t\tpreflightResult?.(true);\n\t\t\treturn;\n\t\t}\n\n\t\t// A fallback model is scoped to the failing turn. Restore the user-selected\n\t\t// model before validating credentials for the next idle prompt.\n\t\tif (typeof this._restoreFallbackModel === \"function\") await this._restoreFallbackModel();\n\t\t// Flush any pending bash messages before the new prompt\n\t\tthis._flushPendingBashMessages();\n\n\t\t// Validate model\n\t\tif (!this.model) {\n\t\t\tthrow new Error(formatNoModelSelectedMessage());\n\t\t}\n\n\t\t// Defensive guard: a model that never resolved to a real provider\n\t\t// (for example an unknown/unresolved model id that reached this path\n\t\t// as a bare string) has no `provider`, which would otherwise fail deep\n\t\t// in auth resolution as the confusing \"No API key found for undefined\".\n\t\t// Surface a clear, accurate \"unknown model\" error instead.\n\t\tconst resolvedProvider = (this.model as { provider?: unknown }).provider;\n\t\tif (typeof resolvedProvider !== \"string\" || resolvedProvider.length === 0) {\n\t\t\tthrow new Error(formatUnresolvedModelMessage(this.model));\n\t\t}\n\n\t\tif (!this._modelRuntime.hasConfiguredAuth(this.model.provider)) {\n\t\t\t// A failed credential-store load (for example auth.json briefly locked\n\t\t\t// by a concurrent process, or invalid JSON) leaves an empty in-memory\n\t\t\t// credential set. That would otherwise be misreported here as\n\t\t\t// \"No API key found\" even though the credentials exist on disk. Surface\n\t\t\t// the real load failure instead so configured providers are not falsely\n\t\t\t// reported as unauthenticated (issue #1431).\n\t\t\tconst isOAuth = this._modelRuntime.isUsingOAuth(this.model.provider);\n\t\t\tif (isOAuth) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`Authentication failed for \"${this.model.provider}\". ` +\n\t\t\t\t\t\t`Credentials may have expired or network is unavailable. ` +\n\t\t\t\t\t\t`Run '/login ${this.model.provider}' to re-authenticate.`,\n\t\t\t\t);\n\t\t\t}\n\t\t\tthrow new Error(formatNoApiKeyFoundMessage(this.model.provider));\n\t\t}\n\n\t\t// Check if we need to compact before sending (catches aborted responses)\n\t\tconst lastAssistant = this._findLastAssistantMessage();\n\t\tif (lastAssistant) {\n\t\t\tawait this._checkCompaction(lastAssistant, false);\n\t\t}\n\n\t\t// Build messages array (custom message if any, then user message)\n\t\tmessages = [];\n\n\t\t// Add user message\n\t\tconst userContent: (TextContent | ImageContent)[] = [{ type: \"text\", text: expandedText }];\n\t\tif (currentImages) {\n\t\t\tuserContent.push(...currentImages);\n\t\t}\n\t\tmessages.push({\n\t\t\trole: \"user\",\n\t\t\tcontent: userContent,\n\t\t\ttimestamp: Date.now(),\n\t\t});\n\n\t\t// Inject any pending \"nextTurn\" messages as context alongside the user message\n\t\tfor (const msg of this._pendingNextTurnMessages) {\n\t\t\tmessages.push(msg);\n\t\t}\n\t\tthis._pendingNextTurnMessages = [];\n\n\t\t// Emit before_agent_start extension event\n\t\tconst result = await this._extensionRunner.emitBeforeAgentStart(\n\t\t\texpandedText,\n\t\t\tcurrentImages,\n\t\t\tthis._baseSystemPrompt,\n\t\t\tthis._baseSystemPromptOptions,\n\t\t);\n\t\t// Add all custom messages from extensions\n\t\tif (result?.messages) {\n\t\t\tfor (const msg of result.messages) {\n\t\t\t\tmessages.push({\n\t\t\t\t\trole: \"custom\",\n\t\t\t\t\tcustomType: msg.customType,\n\t\t\t\t\tcontent: msg.content ?? [],\n\t\t\t\t\tdisplay: msg.display,\n\t\t\t\t\tdetails: msg.details,\n\t\t\t\t\ttimestamp: Date.now(),\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\t\t// Apply extension-modified system prompt, or reset to base\n\t\tif (result?.systemPrompt !== undefined) {\n\t\t\tthis._systemPromptOverride = result.systemPrompt;\n\t\t\tthis.agent.state.systemPrompt = result.systemPrompt;\n\t\t} else {\n\t\t\t// Ensure we're using the base prompt (in case previous turn had modifications)\n\t\t\tthis._systemPromptOverride = undefined;\n\t\t\tthis.agent.state.systemPrompt = this._baseSystemPrompt;\n\t\t}\n\t} catch (error) {\n\t\tpreflightResult?.(false);\n\t\tthrow error;\n\t}\n\n\tpreflightResult?.(true);\n\tconst turn = this._runAgentPrompt(messages, workflowDelivery?.promptStarted);\n\tworkflowDelivery?.delivered?.(\"prompt\");\n\tawait turn;\n}\n\nexport async function _runAgentPrompt(\n\tthis: AgentSession,\n\tmessages: AgentMessage | AgentMessage[],\n\tpromptStarted?: () => void,\n): Promise<void> {\n\tconst owner = resolveWorkflowStageDeliveryTarget(this);\n\tif (owner !== this) {\n\t\tif (owner._queuedMessagesPaused) {\n\t\t\tconst items = Array.isArray(messages) ? messages : [messages];\n\t\t\tfor (const message of items) owner._queueAgentMessage(message, \"steer\");\n\t\t\treturn;\n\t\t}\n\t\treturn owner._runAgentPrompt(messages, promptStarted);\n\t}\n\ttry {\n\t\tconst turn = this.agent.prompt(messages);\n\t\tif (this.isStreaming) promptStarted?.();\n\t\tawait turn;\n\t\tawait this.waitForRetry();\n\t\tawait this._continueQueuedAgentMessages();\n\t\tawait this._awaitPendingPostCompactionContinuation();\n\t} finally {\n\t\tthis._systemPromptOverride = undefined;\n\t\tawait this._agentEventQueue;\n\t\tif (typeof this._extensionRunner?.emit === \"function\") {\n\t\t\tawait this._extensionRunner.emit({ type: \"agent_settled\" });\n\t\t}\n\t\tthis._emit?.({ type: \"agent_settled\" });\n\t}\n}\n\nexport async function _runAgentContinue(this: AgentSession): Promise<void> {\n\tawait this.agent.continue();\n\tawait this.waitForRetry();\n\tawait this._continueQueuedAgentMessages();\n}\n\nexport async function _continueQueuedAgentMessages(this: AgentSession): Promise<void> {\n\tawait this._agentEventQueue;\n\n\twhile (!this._queuedMessagesPaused && this.agent.hasQueuedMessages()) {\n\t\tawait this.agent.continue();\n\t\tawait this.waitForRetry();\n\t\tawait this._agentEventQueue;\n\t}\n}\n\n/**\n * Try to execute a built-in slash command. Returns true if command was found and executed.\n */\n\nexport async function _tryExecuteBuiltinSlashCommand(this: AgentSession, text: string): Promise<boolean> {\n\tconst spaceIndex = text.indexOf(\" \");\n\tconst commandName = spaceIndex === -1 ? text.slice(1) : text.slice(1, spaceIndex);\n\tif (commandName !== ATOMIC_GUIDE_COMMAND_NAME) return false;\n\n\tconst args = spaceIndex === -1 ? \"\" : text.slice(spaceIndex + 1);\n\tconst mode = normalizeAtomicGuideMode(args);\n\tif (mode === \"help\" && this._extensionUIContext) {\n\t\tconst choice = await this._extensionUIContext.select(\"Atomic. Select where to start:\", [\n\t\t\t...ATOMIC_GUIDE_HELP_CHOICES,\n\t\t]);\n\t\tif (!choice || !isAtomicGuideHelpChoice(choice)) return true;\n\t\tawait this.sendCustomMessage(\n\t\t\t{\n\t\t\t\tcustomType: \"atomic\",\n\t\t\t\tcontent: getAtomicGuideMessage(atomicGuideModeForChoice(choice), this._cwd),\n\t\t\t\tdisplay: true,\n\t\t\t},\n\t\t\t{ triggerTurn: false },\n\t\t);\n\t\treturn true;\n\t}\n\n\tawait this.sendCustomMessage(\n\t\t{\n\t\t\tcustomType: \"atomic\",\n\t\t\tcontent: getAtomicGuideMessage(mode, this._cwd),\n\t\t\tdisplay: true,\n\t\t},\n\t\t{ triggerTurn: false },\n\t);\n\treturn true;\n}\n\n/**\n * Try to execute an extension command. Returns true if command was found and executed.\n */\n\nexport async function _tryExecuteExtensionCommand(this: AgentSession, text: string): Promise<boolean> {\n\t// Parse command name and args\n\tconst spaceIndex = text.indexOf(\" \");\n\tconst commandName = spaceIndex === -1 ? text.slice(1) : text.slice(1, spaceIndex);\n\tconst args = spaceIndex === -1 ? \"\" : text.slice(spaceIndex + 1);\n\n\tconst command = this._extensionRunner.getCommand(commandName);\n\tif (!command) return false;\n\n\t// Get command context from extension runner (includes session control methods)\n\tconst ctx = this._extensionRunner.createCommandContext();\n\n\ttry {\n\t\tawait runCallback(\n\t\t\t{ kind: \"extension.hook\", name: `command:${commandName}`, sourcePath: command.sourceInfo.path },\n\t\t\t() => command.handler(args, ctx),\n\t\t);\n\t\treturn true;\n\t} catch (err) {\n\t\t// Emit error via extension runner\n\t\tthis._extensionRunner.emitError({\n\t\t\textensionPath: `command:${commandName}`,\n\t\t\tevent: \"command\",\n\t\t\terror: err instanceof Error ? err.message : String(err),\n\t\t});\n\t\treturn true;\n\t}\n}\n\n/**\n * Expand skill commands (/skill:name args) to their full content.\n * Returns the expanded text, or the original text if not a skill command or skill not found.\n * Emits errors via extension runner if file read fails.\n */\n\nexport function _expandSkillCommand(this: AgentSession, text: string): string {\n\tif (!text.startsWith(\"/skill:\")) return text;\n\n\tconst spaceIndex = text.indexOf(\" \");\n\tconst skillName = spaceIndex === -1 ? text.slice(7) : text.slice(7, spaceIndex);\n\tconst args = spaceIndex === -1 ? \"\" : text.slice(spaceIndex + 1).trim();\n\n\tconst skill = this.resourceLoader.getSkills().skills.find((s) => s.name === skillName);\n\tif (!skill) return text; // Unknown skill, pass through\n\n\ttry {\n\t\tconst content = readFileSync(skill.filePath, \"utf-8\");\n\t\tconst body = stripFrontmatter(content).trim();\n\t\tconst skillBlock = `<skill name=\"${skill.name}\" location=\"${skill.filePath}\">\\nReferences are relative to ${skill.baseDir}.\\n\\n${body}\\n</skill>`;\n\t\treturn args ? `${skillBlock}\\n\\n${args}` : skillBlock;\n\t} catch (err) {\n\t\t// Emit error like extension commands do\n\t\tthis._extensionRunner.emitError({\n\t\t\textensionPath: skill.filePath,\n\t\t\tevent: \"skill_expansion\",\n\t\t\terror: err instanceof Error ? err.message : String(err),\n\t\t});\n\t\treturn text; // Return original on error\n\t}\n}\n\n/**\n * Queue a steering message while the agent is running.\n * Delivered after the current assistant turn finishes executing its tool calls,\n * before the next LLM call.\n * Expands skill commands and prompt templates. Errors on extension commands.\n * @param images Optional image attachments to include with the message\n * @throws Error if text is an extension command\n */\n\nexport async function steer(this: AgentSession, text: string, images?: ImageContent[]): Promise<void> {\n\t// Check for extension commands (cannot be queued)\n\tif (text.startsWith(\"/\")) {\n\t\tthis._throwIfExtensionCommand(text);\n\t}\n\n\t// Expand skill commands and prompt templates\n\tlet expandedText = this._expandSkillCommand(text);\n\texpandedText = expandPromptTemplate(expandedText, [...this.promptTemplates]);\n\n\tawait this._queueSteer(expandedText, images);\n}\n\n/**\n * Queue a follow-up message to be processed after the agent finishes.\n * Delivered only when agent has no more tool calls or steering messages.\n * Expands skill commands and prompt templates. Errors on extension commands.\n * @param images Optional image attachments to include with the message\n * @throws Error if text is an extension command\n */\n\nexport async function followUp(this: AgentSession, text: string, images?: ImageContent[]): Promise<void> {\n\t// Check for extension commands (cannot be queued)\n\tif (text.startsWith(\"/\")) {\n\t\tthis._throwIfExtensionCommand(text);\n\t}\n\n\t// Expand skill commands and prompt templates\n\tlet expandedText = this._expandSkillCommand(text);\n\texpandedText = expandPromptTemplate(expandedText, [...this.promptTemplates]);\n\n\tawait this._queueFollowUp(expandedText, images);\n}\n\n/**\n * Internal: Queue a steering message (already expanded, no extension command check).\n */\n\nexport async function sendUserMessage(\n\tthis: AgentSession,\n\tcontent: string | (TextContent | ImageContent)[],\n\toptions?: {\n\t\tdeliverAs?: \"steer\" | \"followUp\";\n\t\t__workflowDelivery?: PromptOptionsWithWorkflowDelivery[\"__workflowDelivery\"];\n\t},\n): Promise<void> {\n\t// Normalize content to text string + optional images\n\tlet text: string;\n\tlet images: ImageContent[] | undefined;\n\n\tif (typeof content === \"string\") {\n\t\ttext = content;\n\t} else {\n\t\tconst textParts: string[] = [];\n\t\timages = [];\n\t\tfor (const part of content) {\n\t\t\tif (part.type === \"text\") {\n\t\t\t\ttextParts.push(part.text);\n\t\t\t} else {\n\t\t\t\timages.push(part);\n\t\t\t}\n\t\t}\n\t\ttext = textParts.join(\"\\n\");\n\t\tif (images.length === 0) images = undefined;\n\t}\n\n\t// Use prompt() with expandPromptTemplates: false to skip command handling and template expansion.\n\t// The private delivery hook lets workflow routing report and gate the branch\n\t// selected after asynchronous input/compaction extension preflight.\n\tawait this.prompt(text, {\n\t\texpandPromptTemplates: false,\n\t\tstreamingBehavior: options?.deliverAs,\n\t\timages,\n\t\tsource: \"extension\",\n\t\t__workflowDelivery: options?.__workflowDelivery,\n\t} as PromptOptionsWithWorkflowDelivery);\n}\n\n/**\n * Clear all queued messages and return them.\n * Useful for restoring to editor when user aborts.\n * @returns Object with steering and followUp arrays\n */\n\nexport const agentSessionPromptMethods = {\n\tprompt,\n\t_runAgentPrompt,\n\t_runAgentContinue,\n\t_continueQueuedAgentMessages,\n\t_tryExecuteBuiltinSlashCommand,\n\t_tryExecuteExtensionCommand,\n\t_expandSkillCommand,\n\tsteer,\n\tfollowUp,\n\tsendUserMessage,\n};\n"]}
|
|
1
|
+
{"version":3,"file":"agent-session-prompt.js","sourceRoot":"","sources":["../../src/core/agent-session-prompt.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAGvC,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAC3D,OAAO,EAAE,kCAAkC,EAAE,MAAM,wCAAwC,CAAC;AAG5F,OAAO,EACN,yBAAyB,EACzB,yBAAyB,EACzB,wBAAwB,EACxB,qBAAqB,EACrB,uBAAuB,EACvB,wBAAwB,GACxB,MAAM,2BAA2B,CAAC;AACnC,OAAO,EACN,0BAA0B,EAC1B,4BAA4B,EAC5B,4BAA4B,GAC5B,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AACrD,OAAO,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAC;AAa7D,oFAAoF;AACpF,MAAM,CAAC,KAAK,UAAU,6BAA6B,CAClD,OAA6F,EAC7F,IAAY;IAEZ,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC;QAAE,OAAO,KAAK,CAAC;IACxC,IAAI,MAAM,OAAO,CAAC,8BAA8B,CAAC,IAAI,CAAC;QAAE,OAAO,IAAI,CAAC;IACpE,OAAO,OAAO,CAAC,2BAA2B,CAAC,IAAI,CAAC,CAAC;AAClD,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,MAAM,CAAqB,IAAY,EAAE,OAAuB;IACrF,MAAM,KAAK,GAAG,kCAAkC,CAAC,IAAI,CAAC,CAAC;IACvD,IAAI,KAAK,KAAK,IAAI;QAAE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AC5B,IAAI,MAAM,CAAC,MAAM,KAAK,CAAC;YAAE,MAAM,GAAG,SAAS,CAAC;IAC7C,CAAC;IAED,kGAAkG;IAClG,6EAA6E;IAC7E,oEAAoE;IACpE,MAAM,IAAI,CAAC,MAAM,CAAC,IAAI,EAAE;QACvB,qBAAqB,EAAE,KAAK;QAC5B,iBAAiB,EAAE,OAAO,EAAE,SAAS;QACrC,MAAM;QACN,MAAM,EAAE,WAAW;QACnB,kBAAkB,EAAE,OAAO,EAAE,kBAAkB;KACV,CAAC,CAAC;AACzC,CAAC;AAED;;;;GAIG;AAEH,MAAM,CAAC,MAAM,yBAAyB,GAAG;IACxC,MAAM;IACN,eAAe;IACf,iBAAiB;IACjB,4BAA4B;IAC5B,8BAA8B;IAC9B,2BAA2B;IAC3B,mBAAmB;IACnB,KAAK;IACL,QAAQ;IACR,eAAe;CACf,CAAC","sourcesContent":["import { readFileSync } from \"node:fs\";\nimport type { AgentMessage } from \"@earendil-works/pi-agent-core\";\nimport type { ImageContent, TextContent } from \"@earendil-works/pi-ai/compat\";\nimport { stripFrontmatter } from \"../utils/frontmatter.ts\";\nimport { resolveWorkflowStageDeliveryTarget } from \"./agent-session-delivery-forwarding.ts\";\nimport type { AgentSessionInternalSurface as AgentSession } from \"./agent-session-methods.ts\";\nimport type { PromptOptions } from \"./agent-session-types.ts\";\nimport {\n\tATOMIC_GUIDE_COMMAND_NAME,\n\tATOMIC_GUIDE_HELP_CHOICES,\n\tatomicGuideModeForChoice,\n\tgetAtomicGuideMessage,\n\tisAtomicGuideHelpChoice,\n\tnormalizeAtomicGuideMode,\n} from \"./atomic-guide-command.ts\";\nimport {\n\tformatNoApiKeyFoundMessage,\n\tformatNoModelSelectedMessage,\n\tformatUnresolvedModelMessage,\n} from \"./auth-guidance.ts\";\nimport { runCallback } from \"./callback-activity.ts\";\nimport { expandPromptTemplate } from \"./prompt-templates.ts\";\n\ntype UserMessageDeliveryAction = \"prompt\" | \"steer\" | \"followUp\" | \"handled\";\n\ntype PromptOptionsWithWorkflowDelivery = PromptOptions & {\n\treadonly __workflowDelivery?: {\n\t\treadonly beforeDelivery?: () => void;\n\t\t/** Called only after an idle prompt has synchronously entered the agent turn. */\n\t\treadonly promptStarted?: () => void;\n\t\treadonly delivered?: (action: UserMessageDeliveryAction) => void;\n\t};\n};\n\n/** Dispatch registered slash commands without changing the raw queue pause gate. */\nexport async function tryExecuteSessionSlashCommand(\n\tsession: Pick<AgentSession, \"_tryExecuteBuiltinSlashCommand\" | \"_tryExecuteExtensionCommand\">,\n\ttext: string,\n): Promise<boolean> {\n\tif (!text.startsWith(\"/\")) return false;\n\tif (await session._tryExecuteBuiltinSlashCommand(text)) return true;\n\treturn session._tryExecuteExtensionCommand(text);\n}\n\nexport async function prompt(this: AgentSession, text: string, options?: PromptOptions): Promise<void> {\n\tconst owner = resolveWorkflowStageDeliveryTarget(this);\n\tif (owner !== this) return owner.prompt(text, options);\n\tconst expandPromptTemplates = options?.expandPromptTemplates ?? true;\n\tconst preflightResult = options?.preflightResult;\n\tconst workflowDelivery = (options as PromptOptionsWithWorkflowDelivery | undefined)?.__workflowDelivery;\n\tlet messages: AgentMessage[] | undefined;\n\n\ttry {\n\t\t// Authorize workflow delivery before commands or input extensions can perform side effects.\n\t\t// A later terminal transition cannot retroactively reject input accepted at this boundary.\n\t\tworkflowDelivery?.beforeDelivery?.();\n\t\t// Registered slash commands execute without releasing ordinary queued work.\n\t\t// Unknown slash input continues through the normal paused admission path.\n\t\tif (expandPromptTemplates && (await tryExecuteSessionSlashCommand(this, text))) {\n\t\t\tworkflowDelivery?.delivered?.(\"handled\");\n\t\t\tpreflightResult?.(true);\n\t\t\treturn;\n\t\t}\n\t\t// Real user input is on its way in, so a summary describing the previous turn is about\n\t\t// to be stale; stop paying for it. Deliberately after the authorization boundary and\n\t\t// the slash-command path, both of which must observe an untouched session. The\n\t\t// generation discards itself via its token/anchor checks either way.\n\t\tthis.abortSessionSummary();\n\t\t// A controlled pause is an admission gate, including the idle gap after\n\t\t// abort settles. Preserve the raw user payload without running input hooks,\n\t\t// compaction, or a provider turn; explicit resume makes it eligible again.\n\t\tif (this._queuedMessagesPaused) {\n\t\t\tconst delivery = options?.streamingBehavior === \"followUp\" ? \"followUp\" : \"steer\";\n\t\t\tif (delivery === \"followUp\") await this._queueFollowUp(text, options?.images);\n\t\t\telse await this._queueSteer(text, options?.images);\n\t\t\tworkflowDelivery?.delivered?.(delivery);\n\t\t\tpreflightResult?.(true);\n\t\t\treturn;\n\t\t}\n\n\t\t// Emit input event for extension interception (before skill/template expansion)\n\t\tlet currentText = text;\n\t\tlet currentImages = options?.images;\n\t\tif (this._extensionRunner.hasHandlers(\"input\")) {\n\t\t\tconst inputResult = await this._extensionRunner.emitInput(\n\t\t\t\tcurrentText,\n\t\t\t\tcurrentImages,\n\t\t\t\toptions?.source ?? \"interactive\",\n\t\t\t\tthis.isStreaming ? options?.streamingBehavior : undefined,\n\t\t\t);\n\t\t\tif (inputResult.action === \"handled\") {\n\t\t\t\tworkflowDelivery?.delivered?.(\"handled\");\n\t\t\t\tpreflightResult?.(true);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (inputResult.action === \"transform\") {\n\t\t\t\tcurrentText = inputResult.text;\n\t\t\t\tcurrentImages = inputResult.images ?? currentImages;\n\t\t\t}\n\t\t}\n\n\t\t// Expand skill commands (/skill:name args) and prompt templates (/template args)\n\t\tlet expandedText = currentText;\n\t\tif (expandPromptTemplates) {\n\t\t\texpandedText = this._expandSkillCommand(expandedText);\n\t\t\texpandedText = expandPromptTemplate(expandedText, [...this.promptTemplates]);\n\t\t}\n\n\t\t// If streaming, queue via steer() or followUp() based on option\n\t\tif (this.isStreaming) {\n\t\t\tif (!options?.streamingBehavior) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t\"Agent is already processing. Specify streamingBehavior ('steer' or 'followUp') to queue the message.\",\n\t\t\t\t);\n\t\t\t}\n\t\t\tif (options.streamingBehavior === \"followUp\") {\n\t\t\t\tawait this._queueFollowUp(expandedText, currentImages);\n\t\t\t} else {\n\t\t\t\tawait this._queueSteer(expandedText, currentImages);\n\t\t\t}\n\t\t\tworkflowDelivery?.delivered?.(options.streamingBehavior);\n\t\t\tpreflightResult?.(true);\n\t\t\treturn;\n\t\t}\n\n\t\t// A fallback model is scoped to the failing turn. Restore the user-selected\n\t\t// model before validating credentials for the next idle prompt.\n\t\tif (typeof this._restoreFallbackModel === \"function\") await this._restoreFallbackModel();\n\t\t// Flush any pending bash messages before the new prompt\n\t\tthis._flushPendingBashMessages();\n\n\t\t// Validate model\n\t\tif (!this.model) {\n\t\t\tthrow new Error(formatNoModelSelectedMessage());\n\t\t}\n\n\t\t// Defensive guard: a model that never resolved to a real provider\n\t\t// (for example an unknown/unresolved model id that reached this path\n\t\t// as a bare string) has no `provider`, which would otherwise fail deep\n\t\t// in auth resolution as the confusing \"No API key found for undefined\".\n\t\t// Surface a clear, accurate \"unknown model\" error instead.\n\t\tconst resolvedProvider = (this.model as { provider?: unknown }).provider;\n\t\tif (typeof resolvedProvider !== \"string\" || resolvedProvider.length === 0) {\n\t\t\tthrow new Error(formatUnresolvedModelMessage(this.model));\n\t\t}\n\n\t\tif (!this._modelRuntime.hasConfiguredAuth(this.model.provider)) {\n\t\t\t// A failed credential-store load (for example auth.json briefly locked\n\t\t\t// by a concurrent process, or invalid JSON) leaves an empty in-memory\n\t\t\t// credential set. That would otherwise be misreported here as\n\t\t\t// \"No API key found\" even though the credentials exist on disk. Surface\n\t\t\t// the real load failure instead so configured providers are not falsely\n\t\t\t// reported as unauthenticated (issue #1431).\n\t\t\tconst isOAuth = this._modelRuntime.isUsingOAuth(this.model.provider);\n\t\t\tif (isOAuth) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`Authentication failed for \"${this.model.provider}\". ` +\n\t\t\t\t\t\t`Credentials may have expired or network is unavailable. ` +\n\t\t\t\t\t\t`Run '/login ${this.model.provider}' to re-authenticate.`,\n\t\t\t\t);\n\t\t\t}\n\t\t\tthrow new Error(formatNoApiKeyFoundMessage(this.model.provider));\n\t\t}\n\n\t\t// Check if we need to compact before sending (catches aborted responses)\n\t\tconst lastAssistant = this._findLastAssistantMessage();\n\t\tif (lastAssistant) {\n\t\t\tawait this._checkCompaction(lastAssistant, false);\n\t\t}\n\n\t\t// Build messages array (custom message if any, then user message)\n\t\tmessages = [];\n\n\t\t// Add user message\n\t\tconst userContent: (TextContent | ImageContent)[] = [{ type: \"text\", text: expandedText }];\n\t\tif (currentImages) {\n\t\t\tuserContent.push(...currentImages);\n\t\t}\n\t\tmessages.push({\n\t\t\trole: \"user\",\n\t\t\tcontent: userContent,\n\t\t\ttimestamp: Date.now(),\n\t\t});\n\n\t\t// Inject any pending \"nextTurn\" messages as context alongside the user message\n\t\tfor (const msg of this._pendingNextTurnMessages) {\n\t\t\tmessages.push(msg);\n\t\t}\n\t\tthis._pendingNextTurnMessages = [];\n\n\t\t// Emit before_agent_start extension event\n\t\tconst result = await this._extensionRunner.emitBeforeAgentStart(\n\t\t\texpandedText,\n\t\t\tcurrentImages,\n\t\t\tthis._baseSystemPrompt,\n\t\t\tthis._baseSystemPromptOptions,\n\t\t);\n\t\t// Add all custom messages from extensions\n\t\tif (result?.messages) {\n\t\t\tfor (const msg of result.messages) {\n\t\t\t\tmessages.push({\n\t\t\t\t\trole: \"custom\",\n\t\t\t\t\tcustomType: msg.customType,\n\t\t\t\t\tcontent: msg.content ?? [],\n\t\t\t\t\tdisplay: msg.display,\n\t\t\t\t\tdetails: msg.details,\n\t\t\t\t\ttimestamp: Date.now(),\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\t\t// Apply extension-modified system prompt, or reset to base\n\t\tif (result?.systemPrompt !== undefined) {\n\t\t\tthis._systemPromptOverride = result.systemPrompt;\n\t\t\tthis.agent.state.systemPrompt = result.systemPrompt;\n\t\t} else {\n\t\t\t// Ensure we're using the base prompt (in case previous turn had modifications)\n\t\t\tthis._systemPromptOverride = undefined;\n\t\t\tthis.agent.state.systemPrompt = this._baseSystemPrompt;\n\t\t}\n\t} catch (error) {\n\t\tpreflightResult?.(false);\n\t\tthrow error;\n\t}\n\n\tpreflightResult?.(true);\n\tconst turn = this._runAgentPrompt(messages, workflowDelivery?.promptStarted);\n\tworkflowDelivery?.delivered?.(\"prompt\");\n\tawait turn;\n}\n\nexport async function _runAgentPrompt(\n\tthis: AgentSession,\n\tmessages: AgentMessage | AgentMessage[],\n\tpromptStarted?: () => void,\n): Promise<void> {\n\tconst owner = resolveWorkflowStageDeliveryTarget(this);\n\tif (owner !== this) {\n\t\tif (owner._queuedMessagesPaused) {\n\t\t\tconst items = Array.isArray(messages) ? messages : [messages];\n\t\t\tfor (const message of items) owner._queueAgentMessage(message, \"steer\");\n\t\t\treturn;\n\t\t}\n\t\treturn owner._runAgentPrompt(messages, promptStarted);\n\t}\n\ttry {\n\t\tconst turn = this.agent.prompt(messages);\n\t\tif (this.isStreaming) promptStarted?.();\n\t\tawait turn;\n\t\tawait this.waitForRetry();\n\t\tawait this._continueQueuedAgentMessages();\n\t\tawait this._awaitPendingPostCompactionContinuation();\n\t} finally {\n\t\tthis._systemPromptOverride = undefined;\n\t\tawait this._agentEventQueue;\n\t\tif (typeof this._extensionRunner?.emit === \"function\") {\n\t\t\tawait this._extensionRunner.emit({ type: \"agent_settled\" });\n\t\t}\n\t\tthis._emit?.({ type: \"agent_settled\" });\n\t}\n}\n\nexport async function _runAgentContinue(this: AgentSession): Promise<void> {\n\tawait this.agent.continue();\n\tawait this.waitForRetry();\n\tawait this._continueQueuedAgentMessages();\n}\n\nexport async function _continueQueuedAgentMessages(this: AgentSession): Promise<void> {\n\tawait this._agentEventQueue;\n\n\twhile (!this._queuedMessagesPaused && this.agent.hasQueuedMessages()) {\n\t\tawait this.agent.continue();\n\t\tawait this.waitForRetry();\n\t\tawait this._agentEventQueue;\n\t}\n}\n\n/**\n * Try to execute a built-in slash command. Returns true if command was found and executed.\n */\n\nexport async function _tryExecuteBuiltinSlashCommand(this: AgentSession, text: string): Promise<boolean> {\n\tconst spaceIndex = text.indexOf(\" \");\n\tconst commandName = spaceIndex === -1 ? text.slice(1) : text.slice(1, spaceIndex);\n\tif (commandName !== ATOMIC_GUIDE_COMMAND_NAME) return false;\n\n\tconst args = spaceIndex === -1 ? \"\" : text.slice(spaceIndex + 1);\n\tconst mode = normalizeAtomicGuideMode(args);\n\tif (mode === \"help\" && this._extensionUIContext) {\n\t\tconst choice = await this._extensionUIContext.select(\"Atomic. Select where to start:\", [\n\t\t\t...ATOMIC_GUIDE_HELP_CHOICES,\n\t\t]);\n\t\tif (!choice || !isAtomicGuideHelpChoice(choice)) return true;\n\t\tawait this.sendCustomMessage(\n\t\t\t{\n\t\t\t\tcustomType: \"atomic\",\n\t\t\t\tcontent: getAtomicGuideMessage(atomicGuideModeForChoice(choice), this._cwd),\n\t\t\t\tdisplay: true,\n\t\t\t},\n\t\t\t{ triggerTurn: false },\n\t\t);\n\t\treturn true;\n\t}\n\n\tawait this.sendCustomMessage(\n\t\t{\n\t\t\tcustomType: \"atomic\",\n\t\t\tcontent: getAtomicGuideMessage(mode, this._cwd),\n\t\t\tdisplay: true,\n\t\t},\n\t\t{ triggerTurn: false },\n\t);\n\treturn true;\n}\n\n/**\n * Try to execute an extension command. Returns true if command was found and executed.\n */\n\nexport async function _tryExecuteExtensionCommand(this: AgentSession, text: string): Promise<boolean> {\n\t// Parse command name and args\n\tconst spaceIndex = text.indexOf(\" \");\n\tconst commandName = spaceIndex === -1 ? text.slice(1) : text.slice(1, spaceIndex);\n\tconst args = spaceIndex === -1 ? \"\" : text.slice(spaceIndex + 1);\n\n\tconst command = this._extensionRunner.getCommand(commandName);\n\tif (!command) return false;\n\n\t// Get command context from extension runner (includes session control methods)\n\tconst ctx = this._extensionRunner.createCommandContext();\n\n\ttry {\n\t\tawait runCallback(\n\t\t\t{ kind: \"extension.hook\", name: `command:${commandName}`, sourcePath: command.sourceInfo.path },\n\t\t\t() => command.handler(args, ctx),\n\t\t);\n\t\treturn true;\n\t} catch (err) {\n\t\t// Emit error via extension runner\n\t\tthis._extensionRunner.emitError({\n\t\t\textensionPath: `command:${commandName}`,\n\t\t\tevent: \"command\",\n\t\t\terror: err instanceof Error ? err.message : String(err),\n\t\t});\n\t\treturn true;\n\t}\n}\n\n/**\n * Expand skill commands (/skill:name args) to their full content.\n * Returns the expanded text, or the original text if not a skill command or skill not found.\n * Emits errors via extension runner if file read fails.\n */\n\nexport function _expandSkillCommand(this: AgentSession, text: string): string {\n\tif (!text.startsWith(\"/skill:\")) return text;\n\n\tconst spaceIndex = text.indexOf(\" \");\n\tconst skillName = spaceIndex === -1 ? text.slice(7) : text.slice(7, spaceIndex);\n\tconst args = spaceIndex === -1 ? \"\" : text.slice(spaceIndex + 1).trim();\n\n\tconst skill = this.resourceLoader.getSkills().skills.find((s) => s.name === skillName);\n\tif (!skill) return text; // Unknown skill, pass through\n\n\ttry {\n\t\tconst content = readFileSync(skill.filePath, \"utf-8\");\n\t\tconst body = stripFrontmatter(content).trim();\n\t\tconst skillBlock = `<skill name=\"${skill.name}\" location=\"${skill.filePath}\">\\nReferences are relative to ${skill.baseDir}.\\n\\n${body}\\n</skill>`;\n\t\treturn args ? `${skillBlock}\\n\\n${args}` : skillBlock;\n\t} catch (err) {\n\t\t// Emit error like extension commands do\n\t\tthis._extensionRunner.emitError({\n\t\t\textensionPath: skill.filePath,\n\t\t\tevent: \"skill_expansion\",\n\t\t\terror: err instanceof Error ? err.message : String(err),\n\t\t});\n\t\treturn text; // Return original on error\n\t}\n}\n\n/**\n * Queue a steering message while the agent is running.\n * Delivered after the current assistant turn finishes executing its tool calls,\n * before the next LLM call.\n * Expands skill commands and prompt templates. Errors on extension commands.\n * @param images Optional image attachments to include with the message\n * @throws Error if text is an extension command\n */\n\nexport async function steer(this: AgentSession, text: string, images?: ImageContent[]): Promise<void> {\n\t// Check for extension commands (cannot be queued)\n\tif (text.startsWith(\"/\")) {\n\t\tthis._throwIfExtensionCommand(text);\n\t}\n\n\t// Expand skill commands and prompt templates\n\tlet expandedText = this._expandSkillCommand(text);\n\texpandedText = expandPromptTemplate(expandedText, [...this.promptTemplates]);\n\n\tawait this._queueSteer(expandedText, images);\n}\n\n/**\n * Queue a follow-up message to be processed after the agent finishes.\n * Delivered only when agent has no more tool calls or steering messages.\n * Expands skill commands and prompt templates. Errors on extension commands.\n * @param images Optional image attachments to include with the message\n * @throws Error if text is an extension command\n */\n\nexport async function followUp(this: AgentSession, text: string, images?: ImageContent[]): Promise<void> {\n\t// Check for extension commands (cannot be queued)\n\tif (text.startsWith(\"/\")) {\n\t\tthis._throwIfExtensionCommand(text);\n\t}\n\n\t// Expand skill commands and prompt templates\n\tlet expandedText = this._expandSkillCommand(text);\n\texpandedText = expandPromptTemplate(expandedText, [...this.promptTemplates]);\n\n\tawait this._queueFollowUp(expandedText, images);\n}\n\n/**\n * Internal: Queue a steering message (already expanded, no extension command check).\n */\n\nexport async function sendUserMessage(\n\tthis: AgentSession,\n\tcontent: string | (TextContent | ImageContent)[],\n\toptions?: {\n\t\tdeliverAs?: \"steer\" | \"followUp\";\n\t\t__workflowDelivery?: PromptOptionsWithWorkflowDelivery[\"__workflowDelivery\"];\n\t},\n): Promise<void> {\n\t// Normalize content to text string + optional images\n\tlet text: string;\n\tlet images: ImageContent[] | undefined;\n\n\tif (typeof content === \"string\") {\n\t\ttext = content;\n\t} else {\n\t\tconst textParts: string[] = [];\n\t\timages = [];\n\t\tfor (const part of content) {\n\t\t\tif (part.type === \"text\") {\n\t\t\t\ttextParts.push(part.text);\n\t\t\t} else {\n\t\t\t\timages.push(part);\n\t\t\t}\n\t\t}\n\t\ttext = textParts.join(\"\\n\");\n\t\tif (images.length === 0) images = undefined;\n\t}\n\n\t// Use prompt() with expandPromptTemplates: false to skip command handling and template expansion.\n\t// The private delivery hook lets workflow routing report and gate the branch\n\t// selected after asynchronous input/compaction extension preflight.\n\tawait this.prompt(text, {\n\t\texpandPromptTemplates: false,\n\t\tstreamingBehavior: options?.deliverAs,\n\t\timages,\n\t\tsource: \"extension\",\n\t\t__workflowDelivery: options?.__workflowDelivery,\n\t} as PromptOptionsWithWorkflowDelivery);\n}\n\n/**\n * Clear all queued messages and return them.\n * Useful for restoring to editor when user aborts.\n * @returns Object with steering and followUp arrays\n */\n\nexport const agentSessionPromptMethods = {\n\tprompt,\n\t_runAgentPrompt,\n\t_runAgentContinue,\n\t_continueQueuedAgentMessages,\n\t_tryExecuteBuiltinSlashCommand,\n\t_tryExecuteExtensionCommand,\n\t_expandSkillCommand,\n\tsteer,\n\tfollowUp,\n\tsendUserMessage,\n};\n"]}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Session summary generation for the resume picker.
|
|
3
|
+
*
|
|
4
|
+
* Runs once the agent goes idle, decides whether a fresh summary is worth generating, and
|
|
5
|
+
* persists the result. Generation itself lives in core/compaction/session-summarization.ts.
|
|
6
|
+
*/
|
|
7
|
+
import type { AgentSessionInternalSurface as AgentSession } from "./agent-session-methods.ts";
|
|
8
|
+
/** A summary request in flight, published so a launch describing the same state can join it. */
|
|
9
|
+
export type SessionSummaryRun = {
|
|
10
|
+
/** The conversation state this request describes. */
|
|
11
|
+
readonly throughId: string;
|
|
12
|
+
/** Settles when the request finishes, whatever the outcome. */
|
|
13
|
+
readonly done: Promise<void>;
|
|
14
|
+
};
|
|
15
|
+
export declare function _maybeGenerateSessionSummary(this: AgentSession): Promise<void>;
|
|
16
|
+
export declare function abortSessionSummary(this: AgentSession): void;
|
|
17
|
+
export declare const agentSessionSummaryMethods: {
|
|
18
|
+
_maybeGenerateSessionSummary: typeof _maybeGenerateSessionSummary;
|
|
19
|
+
abortSessionSummary: typeof abortSessionSummary;
|
|
20
|
+
};
|
|
21
|
+
//# sourceMappingURL=agent-session-summary.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agent-session-summary.d.ts","sourceRoot":"","sources":["../../src/core/agent-session-summary.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,2BAA2B,IAAI,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAO9F,gGAAgG;AAChG,MAAM,MAAM,iBAAiB,GAAG;IAC/B,qDAAqD;IACrD,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,+DAA+D;IAC/D,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC,IAAI,CAAC,CAAC;CAC7B,CAAC;AAEF,wBAAsB,4BAA4B,CAAC,IAAI,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC,CA6HpF;AAED,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,YAAY,GAAG,IAAI,CAe5D;AAED,eAAO,MAAM,0BAA0B;;;CAAwD,CAAC"}
|
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Session summary generation for the resume picker.
|
|
3
|
+
*
|
|
4
|
+
* Runs once the agent goes idle, decides whether a fresh summary is worth generating, and
|
|
5
|
+
* persists the result. Generation itself lives in core/compaction/session-summarization.ts.
|
|
6
|
+
*/
|
|
7
|
+
import { generateSessionSummary } from "./compaction/index.js";
|
|
8
|
+
import { getLastConversationMessageId, getLatestSessionSummary } from "./session-manager-entries.js";
|
|
9
|
+
/** Sessions shorter than this are already legible from their first message. */
|
|
10
|
+
const MIN_ENTRIES_FOR_SUMMARY = 4;
|
|
11
|
+
export async function _maybeGenerateSessionSummary() {
|
|
12
|
+
// Held rather than read from the session in `finally`, so an early return can never clear a
|
|
13
|
+
// controller or run belonging to a different launch.
|
|
14
|
+
let controller;
|
|
15
|
+
let run;
|
|
16
|
+
let finish;
|
|
17
|
+
try {
|
|
18
|
+
// --- Bail-outs that cannot change while we wait ---------------------------------
|
|
19
|
+
if (this._disposed)
|
|
20
|
+
return;
|
|
21
|
+
if (!this.settingsManager.getSessionSummarySettings().enabled)
|
|
22
|
+
return;
|
|
23
|
+
// One-shot scripted runs should not pay for a background call; the process may exit before
|
|
24
|
+
// it lands. "tui" and "rpc" are the resumable, interactive modes.
|
|
25
|
+
if (this._extensionMode === "print" || this._extensionMode === "json")
|
|
26
|
+
return;
|
|
27
|
+
const model = this.model;
|
|
28
|
+
if (!model)
|
|
29
|
+
return;
|
|
30
|
+
// Workflow-stage sessions are excluded from /resume entirely.
|
|
31
|
+
if (this.sessionManager.getHeader()?.internal)
|
|
32
|
+
return;
|
|
33
|
+
// Claim the launch before waiting, so a later turn supersedes this one while both are
|
|
34
|
+
// parked below.
|
|
35
|
+
const sessionSummaryToken = ++this._sessionSummaryToken;
|
|
36
|
+
// `agent_end` fires while the agent still reports isStreaming, and that flag survives the
|
|
37
|
+
// entire microtask queue — it only clears a macrotask later. Testing it here without
|
|
38
|
+
// waiting made generation depend on whether `_checkCompaction` happened to cross a
|
|
39
|
+
// macrotask boundary: green under test, silently skipped in the real TUI, and nothing
|
|
40
|
+
// retries it.
|
|
41
|
+
await this.agent.waitForIdle();
|
|
42
|
+
if (this._disposed)
|
|
43
|
+
return;
|
|
44
|
+
if (this._sessionSummaryToken !== sessionSummaryToken)
|
|
45
|
+
return;
|
|
46
|
+
if (this.isStreaming || this.isCompacting)
|
|
47
|
+
return;
|
|
48
|
+
const branch = this.sessionManager.getBranch();
|
|
49
|
+
if (branch.length < MIN_ENTRIES_FOR_SUMMARY)
|
|
50
|
+
return;
|
|
51
|
+
const throughId = getLastConversationMessageId(branch);
|
|
52
|
+
if (!throughId)
|
|
53
|
+
return;
|
|
54
|
+
// On a resumed session the in-memory anchor starts empty, so fall back to the persisted
|
|
55
|
+
// summary. Without this the first idle after every resume regenerates a summary that is
|
|
56
|
+
// already current.
|
|
57
|
+
const lastSummarized = this._lastSummarizedMessageId ??
|
|
58
|
+
getLatestSessionSummary(this.sessionManager.getEntries())?.summarizedThroughId;
|
|
59
|
+
if (throughId === lastSummarized)
|
|
60
|
+
return;
|
|
61
|
+
// A request already covering this exact conversation state will store the line this launch
|
|
62
|
+
// would ask for, so wait for it instead of aborting it and paying for a second one.
|
|
63
|
+
// Overlap is routine rather than exceptional: every turn schedules a launch, and the
|
|
64
|
+
// previous turn's can still be in flight when the next one wakes.
|
|
65
|
+
const inFlight = this._sessionSummaryRun;
|
|
66
|
+
if (inFlight !== undefined && inFlight.throughId === throughId) {
|
|
67
|
+
await inFlight.done;
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
70
|
+
// Anything still running describes an older conversation state, so retire it and take the
|
|
71
|
+
// controller. Abort the previous one directly rather than via abortSessionSummary(), which
|
|
72
|
+
// bumps the token and would invalidate the claim made above. The controller lives on the
|
|
73
|
+
// session so the prompt, tree-navigation, and shutdown paths can reach it.
|
|
74
|
+
this._sessionSummaryAbortController?.abort();
|
|
75
|
+
controller = new AbortController();
|
|
76
|
+
this._sessionSummaryAbortController = controller;
|
|
77
|
+
const signal = controller.signal;
|
|
78
|
+
// Publish this run before the first await that another launch can overlap. From here on
|
|
79
|
+
// ownership of the slot, not the token, is what licenses a write: a joiner bumps the token
|
|
80
|
+
// on its way in, and must not invalidate the very run it is waiting for.
|
|
81
|
+
// Hand-rolled deferred rather than Promise.withResolvers: coding-agent is the one compiled
|
|
82
|
+
// package and its lib target predates ES2024, the same reason `_retryPromise` is built this
|
|
83
|
+
// way. The executor runs synchronously, so `finish` is assigned before the constructor returns.
|
|
84
|
+
const done = new Promise((resolve) => {
|
|
85
|
+
finish = resolve;
|
|
86
|
+
});
|
|
87
|
+
run = { throughId, done };
|
|
88
|
+
this._sessionSummaryRun = run;
|
|
89
|
+
const { apiKey, headers, baseUrl } = await this._getRequiredRequestAuth(model);
|
|
90
|
+
// Disposal or a newer turn can land while credentials resolve; nothing past this point
|
|
91
|
+
// should reach the provider.
|
|
92
|
+
if (this._disposed || signal.aborted)
|
|
93
|
+
return;
|
|
94
|
+
if (this._sessionSummaryRun !== run)
|
|
95
|
+
return;
|
|
96
|
+
const result = await generateSessionSummary(branch, {
|
|
97
|
+
model,
|
|
98
|
+
apiKey,
|
|
99
|
+
headers,
|
|
100
|
+
baseUrl,
|
|
101
|
+
signal,
|
|
102
|
+
streamFn: this.agent.streamFunction,
|
|
103
|
+
retry: this.settingsManager.getRetrySettings(),
|
|
104
|
+
});
|
|
105
|
+
// Failures stay silent: nothing awaits this, and the picker falls back on its own.
|
|
106
|
+
if (result.aborted || result.error || !result.summary)
|
|
107
|
+
return;
|
|
108
|
+
// Disposal, cancellation, a newer run, or a newer message all mean this summary no longer
|
|
109
|
+
// describes the session. The signal is checked directly as well as the token because a
|
|
110
|
+
// provider that ignores the signal still returns an ordinary result.
|
|
111
|
+
if (this._disposed)
|
|
112
|
+
return;
|
|
113
|
+
if (signal.aborted)
|
|
114
|
+
return;
|
|
115
|
+
if (this._sessionSummaryRun !== run)
|
|
116
|
+
return;
|
|
117
|
+
if (getLastConversationMessageId(this.sessionManager.getBranch()) !== throughId)
|
|
118
|
+
return;
|
|
119
|
+
this.sessionManager.appendSessionSummary(result.summary, throughId, result.usage);
|
|
120
|
+
this._lastSummarizedMessageId = throughId;
|
|
121
|
+
}
|
|
122
|
+
catch {
|
|
123
|
+
// Nothing awaits this call, so an escaping rejection would surface as an unhandled
|
|
124
|
+
// rejection and can take the process down. Credential resolution throws outright when no
|
|
125
|
+
// key is configured, which is an ordinary state for a session that never prompts.
|
|
126
|
+
}
|
|
127
|
+
finally {
|
|
128
|
+
if (controller !== undefined && this._sessionSummaryAbortController === controller) {
|
|
129
|
+
this._sessionSummaryAbortController = undefined;
|
|
130
|
+
}
|
|
131
|
+
if (run !== undefined && this._sessionSummaryRun === run) {
|
|
132
|
+
this._sessionSummaryRun = undefined;
|
|
133
|
+
}
|
|
134
|
+
// Settled on every path, including a throw and every early return above: a joiner parked
|
|
135
|
+
// on `done` has no other way out.
|
|
136
|
+
finish?.();
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
export function abortSessionSummary() {
|
|
140
|
+
// Bump the token as well as aborting: a launch parked on waitForIdle() has no controller yet,
|
|
141
|
+
// and would otherwise survive a prompt, a tree navigation, or disposal.
|
|
142
|
+
this._sessionSummaryToken++;
|
|
143
|
+
this._sessionSummaryAbortController?.abort();
|
|
144
|
+
this._sessionSummaryAbortController = undefined;
|
|
145
|
+
// Retire the published run too. It is what licenses a write once a request is in flight, so a
|
|
146
|
+
// provider that ignores its signal must still fail the ownership check, and a later launch
|
|
147
|
+
// must not join a run that has just been cancelled.
|
|
148
|
+
this._sessionSummaryRun = undefined;
|
|
149
|
+
// Drop the in-memory anchor as well. It is only a cache of the persisted state, and the
|
|
150
|
+
// persisted lookup is retirement-aware where the cache is not: after branchWithSummary()
|
|
151
|
+
// retires the stored summary, a cached anchor that still matches the last message id would
|
|
152
|
+
// skip regeneration and leave the picker on fallback text until the next real turn.
|
|
153
|
+
this._lastSummarizedMessageId = undefined;
|
|
154
|
+
}
|
|
155
|
+
export const agentSessionSummaryMethods = { _maybeGenerateSessionSummary, abortSessionSummary };
|
|
156
|
+
//# sourceMappingURL=agent-session-summary.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agent-session-summary.js","sourceRoot":"","sources":["../../src/core/agent-session-summary.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,EAAE,sBAAsB,EAAE,MAAM,uBAAuB,CAAC;AAC/D,OAAO,EAAE,4BAA4B,EAAE,uBAAuB,EAAE,MAAM,8BAA8B,CAAC;AAErG,+EAA+E;AAC/E,MAAM,uBAAuB,GAAG,CAAC,CAAC;AAUlC,MAAM,CAAC,KAAK,UAAU,4BAA4B;IACjD,4FAA4F;IAC5F,qDAAqD;IACrD,IAAI,UAAuC,CAAC;IAC5C,IAAI,GAAkC,CAAC;IACvC,IAAI,MAAgC,CAAC;IACrC,IAAI,CAAC;QACJ,mFAAmF;QACnF,IAAI,IAAI,CAAC,SAAS;YAAE,OAAO;QAC3B,IAAI,CAAC,IAAI,CAAC,eAAe,CAAC,yBAAyB,EAAE,CAAC,OAAO;YAAE,OAAO;QAEtE,2FAA2F;QAC3F,kEAAkE;QAClE,IAAI,IAAI,CAAC,cA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AC3F,oFAAoF;IACpF,IAAI,CAAC,wBAAwB,GAAG,SAAS,CAAC;AAC3C,CAAC;AAED,MAAM,CAAC,MAAM,0BAA0B,GAAG,EAAE,4BAA4B,EAAE,mBAAmB,EAAE,CAAC","sourcesContent":["/**\n * Session summary generation for the resume picker.\n *\n * Runs once the agent goes idle, decides whether a fresh summary is worth generating, and\n * persists the result. Generation itself lives in core/compaction/session-summarization.ts.\n */\n\nimport type { AgentSessionInternalSurface as AgentSession } from \"./agent-session-methods.ts\";\nimport { generateSessionSummary } from \"./compaction/index.ts\";\nimport { getLastConversationMessageId, getLatestSessionSummary } from \"./session-manager-entries.ts\";\n\n/** Sessions shorter than this are already legible from their first message. */\nconst MIN_ENTRIES_FOR_SUMMARY = 4;\n\n/** A summary request in flight, published so a launch describing the same state can join it. */\nexport type SessionSummaryRun = {\n\t/** The conversation state this request describes. */\n\treadonly throughId: string;\n\t/** Settles when the request finishes, whatever the outcome. */\n\treadonly done: Promise<void>;\n};\n\nexport async function _maybeGenerateSessionSummary(this: AgentSession): Promise<void> {\n\t// Held rather than read from the session in `finally`, so an early return can never clear a\n\t// controller or run belonging to a different launch.\n\tlet controller: AbortController | undefined;\n\tlet run: SessionSummaryRun | undefined;\n\tlet finish: (() => void) | undefined;\n\ttry {\n\t\t// --- Bail-outs that cannot change while we wait ---------------------------------\n\t\tif (this._disposed) return;\n\t\tif (!this.settingsManager.getSessionSummarySettings().enabled) return;\n\n\t\t// One-shot scripted runs should not pay for a background call; the process may exit before\n\t\t// it lands. \"tui\" and \"rpc\" are the resumable, interactive modes.\n\t\tif (this._extensionMode === \"print\" || this._extensionMode === \"json\") return;\n\n\t\tconst model = this.model;\n\t\tif (!model) return;\n\n\t\t// Workflow-stage sessions are excluded from /resume entirely.\n\t\tif (this.sessionManager.getHeader()?.internal) return;\n\n\t\t// Claim the launch before waiting, so a later turn supersedes this one while both are\n\t\t// parked below.\n\t\tconst sessionSummaryToken = ++this._sessionSummaryToken;\n\n\t\t// `agent_end` fires while the agent still reports isStreaming, and that flag survives the\n\t\t// entire microtask queue — it only clears a macrotask later. Testing it here without\n\t\t// waiting made generation depend on whether `_checkCompaction` happened to cross a\n\t\t// macrotask boundary: green under test, silently skipped in the real TUI, and nothing\n\t\t// retries it.\n\t\tawait this.agent.waitForIdle();\n\n\t\tif (this._disposed) return;\n\t\tif (this._sessionSummaryToken !== sessionSummaryToken) return;\n\t\tif (this.isStreaming || this.isCompacting) return;\n\n\t\tconst branch = this.sessionManager.getBranch();\n\t\tif (branch.length < MIN_ENTRIES_FOR_SUMMARY) return;\n\n\t\tconst throughId = getLastConversationMessageId(branch);\n\t\tif (!throughId) return;\n\n\t\t// On a resumed session the in-memory anchor starts empty, so fall back to the persisted\n\t\t// summary. Without this the first idle after every resume regenerates a summary that is\n\t\t// already current.\n\t\tconst lastSummarized =\n\t\t\tthis._lastSummarizedMessageId ??\n\t\t\tgetLatestSessionSummary(this.sessionManager.getEntries())?.summarizedThroughId;\n\t\tif (throughId === lastSummarized) return;\n\n\t\t// A request already covering this exact conversation state will store the line this launch\n\t\t// would ask for, so wait for it instead of aborting it and paying for a second one.\n\t\t// Overlap is routine rather than exceptional: every turn schedules a launch, and the\n\t\t// previous turn's can still be in flight when the next one wakes.\n\t\tconst inFlight = this._sessionSummaryRun;\n\t\tif (inFlight !== undefined && inFlight.throughId === throughId) {\n\t\t\tawait inFlight.done;\n\t\t\treturn;\n\t\t}\n\n\t\t// Anything still running describes an older conversation state, so retire it and take the\n\t\t// controller. Abort the previous one directly rather than via abortSessionSummary(), which\n\t\t// bumps the token and would invalidate the claim made above. The controller lives on the\n\t\t// session so the prompt, tree-navigation, and shutdown paths can reach it.\n\t\tthis._sessionSummaryAbortController?.abort();\n\t\tcontroller = new AbortController();\n\t\tthis._sessionSummaryAbortController = controller;\n\t\tconst signal = controller.signal;\n\n\t\t// Publish this run before the first await that another launch can overlap. From here on\n\t\t// ownership of the slot, not the token, is what licenses a write: a joiner bumps the token\n\t\t// on its way in, and must not invalidate the very run it is waiting for.\n\t\t// Hand-rolled deferred rather than Promise.withResolvers: coding-agent is the one compiled\n\t\t// package and its lib target predates ES2024, the same reason `_retryPromise` is built this\n\t\t// way. The executor runs synchronously, so `finish` is assigned before the constructor returns.\n\t\tconst done = new Promise<void>((resolve) => {\n\t\t\tfinish = resolve;\n\t\t});\n\t\trun = { throughId, done };\n\t\tthis._sessionSummaryRun = run;\n\n\t\tconst { apiKey, headers, baseUrl } = await this._getRequiredRequestAuth(model);\n\n\t\t// Disposal or a newer turn can land while credentials resolve; nothing past this point\n\t\t// should reach the provider.\n\t\tif (this._disposed || signal.aborted) return;\n\t\tif (this._sessionSummaryRun !== run) return;\n\n\t\tconst result = await generateSessionSummary(branch, {\n\t\t\tmodel,\n\t\t\tapiKey,\n\t\t\theaders,\n\t\t\tbaseUrl,\n\t\t\tsignal,\n\t\t\tstreamFn: this.agent.streamFunction,\n\t\t\tretry: this.settingsManager.getRetrySettings(),\n\t\t});\n\t\t// Failures stay silent: nothing awaits this, and the picker falls back on its own.\n\t\tif (result.aborted || result.error || !result.summary) return;\n\n\t\t// Disposal, cancellation, a newer run, or a newer message all mean this summary no longer\n\t\t// describes the session. The signal is checked directly as well as the token because a\n\t\t// provider that ignores the signal still returns an ordinary result.\n\t\tif (this._disposed) return;\n\t\tif (signal.aborted) return;\n\t\tif (this._sessionSummaryRun !== run) return;\n\t\tif (getLastConversationMessageId(this.sessionManager.getBranch()) !== throughId) return;\n\n\t\tthis.sessionManager.appendSessionSummary(result.summary, throughId, result.usage);\n\t\tthis._lastSummarizedMessageId = throughId;\n\t} catch {\n\t\t// Nothing awaits this call, so an escaping rejection would surface as an unhandled\n\t\t// rejection and can take the process down. Credential resolution throws outright when no\n\t\t// key is configured, which is an ordinary state for a session that never prompts.\n\t} finally {\n\t\tif (controller !== undefined && this._sessionSummaryAbortController === controller) {\n\t\t\tthis._sessionSummaryAbortController = undefined;\n\t\t}\n\t\tif (run !== undefined && this._sessionSummaryRun === run) {\n\t\t\tthis._sessionSummaryRun = undefined;\n\t\t}\n\t\t// Settled on every path, including a throw and every early return above: a joiner parked\n\t\t// on `done` has no other way out.\n\t\tfinish?.();\n\t}\n}\n\nexport function abortSessionSummary(this: AgentSession): void {\n\t// Bump the token as well as aborting: a launch parked on waitForIdle() has no controller yet,\n\t// and would otherwise survive a prompt, a tree navigation, or disposal.\n\tthis._sessionSummaryToken++;\n\tthis._sessionSummaryAbortController?.abort();\n\tthis._sessionSummaryAbortController = undefined;\n\t// Retire the published run too. It is what licenses a write once a request is in flight, so a\n\t// provider that ignores its signal must still fail the ownership check, and a later launch\n\t// must not join a run that has just been cancelled.\n\tthis._sessionSummaryRun = undefined;\n\t// Drop the in-memory anchor as well. It is only a cache of the persisted state, and the\n\t// persisted lookup is retirement-aware where the cache is not: after branchWithSummary()\n\t// retires the stored summary, a cached anchor that still matches the last message id would\n\t// skip regeneration and leave the picker on fallback text until the next real turn.\n\tthis._lastSummarizedMessageId = undefined;\n}\n\nexport const agentSessionSummaryMethods = { _maybeGenerateSessionSummary, abortSessionSummary };\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agent-session-tool-registry.d.ts","sourceRoot":"","sources":["../../src/core/agent-session-tool-registry.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,2BAA2B,IAAI,YAAY,EAAE,MAAM,4BAA4B,CAAC;
|
|
1
|
+
{"version":3,"file":"agent-session-tool-registry.d.ts","sourceRoot":"","sources":["../../src/core/agent-session-tool-registry.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,2BAA2B,IAAI,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAS9F,wBAAgB,oBAAoB,CACnC,IAAI,EAAE,YAAY,EAClB,OAAO,CAAC,EAAE;IAAE,eAAe,CAAC,EAAE,MAAM,EAAE,CAAC;IAAC,wBAAwB,CAAC,EAAE,OAAO,CAAA;CAAE,GAC1E,IAAI,CAkGN;AAED,wBAAgB,aAAa,CAC5B,IAAI,EAAE,YAAY,EAClB,OAAO,EAAE;IACR,eAAe,CAAC,EAAE,MAAM,EAAE,CAAC;IAC3B,UAAU,CAAC,EAAE,GAAG,CAAC,MAAM,EAAE,OAAO,GAAG,MAAM,CAAC,CAAC;IAC3C,wBAAwB,CAAC,EAAE,OAAO,CAAC;CACnC,GACC,IAAI,CA+EN;AAED,eAAO,MAAM,+BAA+B;;;CAG3C,CAAC"}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { createSessionAsyncDeliveryHandler } from "./async/session-manager.js";
|
|
2
1
|
import { ExtensionRunner, wrapRegisteredTools } from "./extensions/index.js";
|
|
3
2
|
import { ModelRegistry } from "./model-registry.js";
|
|
4
3
|
import { createSyntheticSourceInfo } from "./source-info.js";
|
|
@@ -114,9 +113,6 @@ export function _buildRuntime(options) {
|
|
|
114
113
|
shellPath,
|
|
115
114
|
interceptorEnabled: () => this.settingsManager.getBashInterceptorEnabled(),
|
|
116
115
|
availableTools: activeBuiltinTools,
|
|
117
|
-
asyncJobManager: this._asyncJobManager,
|
|
118
|
-
asyncJobDeliveryHandler: createSessionAsyncDeliveryHandler(this, this._asyncJobManager, this._asyncJobManagerSessionId),
|
|
119
|
-
asyncJobSessionId: this._asyncJobManagerSessionId,
|
|
120
116
|
// Resolved per execution so bash spill files follow the live
|
|
121
117
|
// transcript session across fork/branch/resume.
|
|
122
118
|
sessionTempDir: () => resolveSessionTempDirPath(this.sessionManager.getSessionId()),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agent-session-tool-registry.js","sourceRoot":"","sources":["../../src/core/agent-session-tool-registry.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,iCAAiC,EAAE,MAAM,4BAA4B,CAAC;AAC/E,OAAO,EAAE,eAAe,EAAuB,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAClG,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,EAAE,yBAAyB,EAAE,MAAM,kBAAk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AC,GAAG,CAAC,IAAI,CAAC,CAAC;QACtD,CAAC;IACF,CAAC;IAED,IAAI,CAAC,gBAAgB,GAAG,IAAI,eAAe,CAC1C,gBAAgB,CAAC,UAAU,EAC3B,gBAAgB,CAAC,OAAO,EACxB,IAAI,CAAC,IAAI,EACT,IAAI,CAAC,cAAc,EACnB,IAAI,aAAa,CAAC,IAAI,CAAC,aAAa,CAAC,EACrC,IAAI,CAAC,qBAAqB,EAC1B,IAAI,CAAC,eAAe,CACpB,CAAC;IACF,IAAI,IAAI,CAAC,mBAAmB,EAAE,CAAC;QAC9B,IAAI,CAAC,mBAAmB,CAAC,OAAO,GAAG,IAAI,CAAC,gBAAgB,CAAC;IAC1D,CAAC;IACD,IAAI,CAAC,kBAAkB,CAAC,IAAI,CAAC,gBAAgB,CAAC,CAAC;IAC/C,IAAI,CAAC,uBAAuB,CAAC,IAAI,CAAC,gBAAgB,CAAC,CAAC;IAEpD,MAAM,sBAAsB,GAAG,IAAI,CAAC,kBAAkB;QACrD,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,kBAAkB,CAAC;QACtC,CAAC,CAAC,CAAC,GAAG,gBAAgB,CAAC,CAAC;IACzB,MAAM,mBAAmB,GAAG,OAAO,CAAC,eAAe,IAAI,sBAAsB,CAAC;IAC9E,IAAI,CAAC,oBAAoB,CAAC;QACzB,eAAe,EAAE,mBAAmB;QACpC,wBAAwB,EAAE,OAAO,CAAC,wBAAwB;KAC1D,CAAC,CAAC;AACJ,CAAC;AAED,MAAM,CAAC,MAAM,+BAA+B,GAAG;IAC9C,oBAAoB;IACpB,aAAa;CACb,CAAC","sourcesContent":["import type { AgentTool } from \"@earendil-works/pi-agent-core\";\nimport type { AgentSessionInternalSurface as AgentSession } from \"./agent-session-methods.ts\";\nimport type { ToolDefinitionEntry } from \"./agent-session-types.ts\";\nimport { createSessionAsyncDeliveryHandler } from \"./async/session-manager.js\";\nimport { ExtensionRunner, type ToolDefinition, wrapRegisteredTools } from \"./extensions/index.ts\";\nimport { ModelRegistry } from \"./model-registry.ts\";\nimport { createSyntheticSourceInfo } from \"./source-info.ts\";\nimport { createAllToolDefinitions, defaultToolNames } from \"./tools/index.ts\";\nimport { resolveSessionTempDirPath } from \"./tools/session-temp-dir.ts\";\nimport { createToolDefinitionFromAgentTool } from \"./tools/tool-definition-wrapper.ts\";\n\nexport function _refreshToolRegistry(\n\tthis: AgentSession,\n\toptions?: { activeToolNames?: string[]; includeAllExtensionTools?: boolean },\n): void {\n\tconst previousRegistryNames = new Set(this._toolRegistry.keys());\n\tconst previousActiveToolNames = this.getActiveToolNames();\n\tconst allowedToolNames = this._allowedToolNames;\n\tconst excludedToolNames = this._excludedToolNames;\n\tconst isExposedTool = (name: string): boolean => {\n\t\tif (allowedToolNames && !allowedToolNames.has(name)) {\n\t\t\treturn false;\n\t\t}\n\t\tif (excludedToolNames?.has(name)) {\n\t\t\treturn false;\n\t\t}\n\t\treturn true;\n\t};\n\n\tconst registeredTools = this._extensionRunner.getAllRegisteredTools();\n\tconst allCustomTools = [\n\t\t...registeredTools,\n\t\t...this._customTools.map((definition) => ({\n\t\t\tdefinition,\n\t\t\tsourceInfo: createSyntheticSourceInfo(`<sdk:${definition.name}>`, { source: \"sdk\" }),\n\t\t})),\n\t].filter((tool) => isExposedTool(tool.definition.name));\n\tconst definitionRegistry = new Map<string, ToolDefinitionEntry>(\n\t\tArray.from(this._baseToolDefinitions.entries())\n\t\t\t.filter(([name]) => isExposedTool(name))\n\t\t\t.map(([name, definition]) => [\n\t\t\t\tname,\n\t\t\t\t{\n\t\t\t\t\tdefinition,\n\t\t\t\t\tsourceInfo: createSyntheticSourceInfo(`<builtin:${name}>`, { source: \"builtin\" }),\n\t\t\t\t},\n\t\t\t]),\n\t);\n\tfor (const tool of allCustomTools) {\n\t\tdefinitionRegistry.set(tool.definition.name, {\n\t\t\tdefinition: tool.definition,\n\t\t\tsourceInfo: tool.sourceInfo,\n\t\t});\n\t}\n\tthis._toolDefinitions = definitionRegistry;\n\tthis._toolPromptSnippets = new Map(\n\t\tArray.from(definitionRegistry.values())\n\t\t\t.map(({ definition }) => {\n\t\t\t\tconst snippet = this._normalizePromptSnippet(definition.promptSnippet);\n\t\t\t\treturn snippet ? ([definition.name, snippet] as const) : undefined;\n\t\t\t})\n\t\t\t.filter((entry): entry is readonly [string, string] => entry !== undefined),\n\t);\n\tthis._toolPromptGuidelines = new Map(\n\t\tArray.from(definitionRegistry.values())\n\t\t\t.map(({ definition }) => {\n\t\t\t\tconst guidelines = this._normalizePromptGuidelines(definition.promptGuidelines);\n\t\t\t\treturn guidelines.length > 0 ? ([definition.name, guidelines] as const) : undefined;\n\t\t\t})\n\t\t\t.filter((entry): entry is readonly [string, string[]] => entry !== undefined),\n\t);\n\tconst runner = this._extensionRunner;\n\tconst wrappedExtensionTools = wrapRegisteredTools(allCustomTools, runner);\n\tconst wrappedBuiltInTools = wrapRegisteredTools(\n\t\tArray.from(this._baseToolDefinitions.values())\n\t\t\t.filter((definition) => isExposedTool(definition.name))\n\t\t\t.map((definition) => ({\n\t\t\t\tdefinition,\n\t\t\t\tsourceInfo: createSyntheticSourceInfo(`<builtin:${definition.name}>`, { source: \"builtin\" }),\n\t\t\t})),\n\t\trunner,\n\t);\n\n\tconst toolRegistry = new Map(wrappedBuiltInTools.map((tool) => [tool.name, tool]));\n\tfor (const tool of wrappedExtensionTools as AgentTool[]) {\n\t\ttoolRegistry.set(tool.name, tool);\n\t}\n\tthis._toolRegistry = toolRegistry;\n\n\tconst nextActiveToolNames = (\n\t\toptions?.activeToolNames ? [...options.activeToolNames] : [...previousActiveToolNames]\n\t).filter((name) => isExposedTool(name));\n\n\tif (allowedToolNames) {\n\t\tfor (const toolName of this._toolRegistry.keys()) {\n\t\t\tif (allowedToolNames.has(toolName)) {\n\t\t\t\tnextActiveToolNames.push(toolName);\n\t\t\t}\n\t\t}\n\t} else if (options?.includeAllExtensionTools) {\n\t\tfor (const tool of wrappedExtensionTools) {\n\t\t\tnextActiveToolNames.push(tool.name);\n\t\t}\n\t} else if (!options?.activeToolNames) {\n\t\tfor (const toolName of this._toolRegistry.keys()) {\n\t\t\tif (!previousRegistryNames.has(toolName)) {\n\t\t\t\tnextActiveToolNames.push(toolName);\n\t\t\t}\n\t\t}\n\t}\n\n\tthis.setActiveToolsByName([...new Set(nextActiveToolNames)]);\n}\n\nexport function _buildRuntime(\n\tthis: AgentSession,\n\toptions: {\n\t\tactiveToolNames?: string[];\n\t\tflagValues?: Map<string, boolean | string>;\n\t\tincludeAllExtensionTools?: boolean;\n\t},\n): void {\n\tconst autoResizeImages = this.settingsManager.getImageAutoResize();\n\tconst shellCommandPrefix = this.settingsManager.getShellCommandPrefix();\n\tconst shellPath = this.settingsManager.getShellPath();\n\tconst isAllowedBuiltinTool = (name: string): boolean => {\n\t\tif (this._allowedToolNames && !this._allowedToolNames.has(name)) return false;\n\t\tif (this._excludedToolNames?.has(name)) return false;\n\t\treturn true;\n\t};\n\tconst activeBuiltinTools = (options.activeToolNames ?? [...defaultToolNames]).filter(isAllowedBuiltinTool);\n\tconst baseToolDefinitions = this._baseToolsOverride\n\t\t? Object.fromEntries(\n\t\t\t\tObject.entries(this._baseToolsOverride).map(([name, tool]) => [\n\t\t\t\t\tname,\n\t\t\t\t\tcreateToolDefinitionFromAgentTool(tool),\n\t\t\t\t]),\n\t\t\t)\n\t\t: createAllToolDefinitions(this._cwd, {\n\t\t\t\tread: { autoResizeImages },\n\t\t\t\tbash: {\n\t\t\t\t\tcommandPrefix: shellCommandPrefix,\n\t\t\t\t\tshellPath,\n\t\t\t\t\tinterceptorEnabled: () => this.settingsManager.getBashInterceptorEnabled(),\n\t\t\t\t\tavailableTools: activeBuiltinTools,\n\t\t\t\t\tasyncJobManager: this._asyncJobManager,\n\t\t\t\t\tasyncJobDeliveryHandler: createSessionAsyncDeliveryHandler(\n\t\t\t\t\t\tthis,\n\t\t\t\t\t\tthis._asyncJobManager,\n\t\t\t\t\t\tthis._asyncJobManagerSessionId,\n\t\t\t\t\t),\n\t\t\t\t\tasyncJobSessionId: this._asyncJobManagerSessionId,\n\t\t\t\t\t// Resolved per execution so bash spill files follow the live\n\t\t\t\t\t// transcript session across fork/branch/resume.\n\t\t\t\t\tsessionTempDir: () => resolveSessionTempDirPath(this.sessionManager.getSessionId()),\n\t\t\t\t\tinterceptor: async (context) => {\n\t\t\t\t\t\tconst result = await this._extensionRunner.emitUserBash({\n\t\t\t\t\t\t\ttype: \"user_bash\",\n\t\t\t\t\t\t\tcommand: context.command,\n\t\t\t\t\t\t\texcludeFromContext: false,\n\t\t\t\t\t\t\tcwd: context.cwd,\n\t\t\t\t\t\t});\n\t\t\t\t\t\treturn result;\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\tsearch: {\n\t\t\t\t\tcontextBefore: this.settingsManager.getSearchContextBefore(),\n\t\t\t\t\tcontextAfter: this.settingsManager.getSearchContextAfter(),\n\t\t\t\t},\n\t\t\t});\n\n\tthis._baseToolDefinitions = new Map(\n\t\tObject.entries(baseToolDefinitions).map(([name, tool]) => [name, tool as ToolDefinition]),\n\t);\n\n\tconst extensionsResult = this._resourceLoader.getExtensions();\n\tif (options.flagValues) {\n\t\tfor (const [name, value] of options.flagValues) {\n\t\t\textensionsResult.runtime.flagValues.set(name, value);\n\t\t\textensionsResult.runtime.explicitFlagNames ??= new Set();\n\t\t\textensionsResult.runtime.explicitFlagNames.add(name);\n\t\t}\n\t}\n\n\tthis._extensionRunner = new ExtensionRunner(\n\t\textensionsResult.extensions,\n\t\textensionsResult.runtime,\n\t\tthis._cwd,\n\t\tthis.sessionManager,\n\t\tnew ModelRegistry(this._modelRuntime),\n\t\tthis._orchestrationContext,\n\t\tthis._subagentPolicy,\n\t);\n\tif (this._extensionRunnerRef) {\n\t\tthis._extensionRunnerRef.current = this._extensionRunner;\n\t}\n\tthis._bindExtensionCore(this._extensionRunner);\n\tthis._applyExtensionBindings(this._extensionRunner);\n\n\tconst defaultActiveToolNames = this._baseToolsOverride\n\t\t? Object.keys(this._baseToolsOverride)\n\t\t: [...defaultToolNames];\n\tconst baseActiveToolNames = options.activeToolNames ?? defaultActiveToolNames;\n\tthis._refreshToolRegistry({\n\t\tactiveToolNames: baseActiveToolNames,\n\t\tincludeAllExtensionTools: options.includeAllExtensionTools,\n\t});\n}\n\nexport const agentSessionToolRegistryMethods = {\n\t_refreshToolRegistry,\n\t_buildRuntime,\n};\n"]}
|
|
1
|
+
{"version":3,"file":"agent-session-tool-registry.js","sourceRoot":"","sources":["../../src/core/agent-session-tool-registry.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,eAAe,EAAuB,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAClG,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,EAAE,yBAAyB,EAAE,MAAM,kBAAkB,CAAC;AAC7D,OAAO,EAAE,wBAAwB,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAC9E,OAAO,EAAE,yBAAyB,EAAE,MAAM,6BAA6B,CAAC;AACxE,OAAO,EAAE,iCAAiC,EAAE,MAAM,oCAAoC,CAAC;AAEvF,MAAM,UAAU,oBAAoB,CAEnC,OAA4E;IAE5E,MAAM,qBAAqB,GAAG,IAAI,GAAG,CAAC,IAAI,CAAC,aAAa,CAAC,IAAI,EAAE,CAAC,CAAC;IACjE,MAAM,uBAAuB,GAAG,IAAI,CAAC,kBAAkB,EAAE,CAAC;IAC1D,MAAM,gBAAgB,GAAG,IAAI,CAAC,iBAAiB,CAAC;IAChD,MAAM,iBAAiB,GAAG,IAAI,CAAC,kBAAkB,CAAC;IAClD,MAAM,aAAa,GAAG,CAAC,IAAY,EAAW,EAAE;QAC/C,IAAI,gBAAgB,IAAI,CAAC,gBAAgB,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC;YACrD,OAAO,KAAK,CAAC;QACd,CAAC;QACD,IAAI,iBAAiB,EAAE,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC;YAClC,OAA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AC1D,CAAC,CAAC;AACJ,CAAC;AAED,MAAM,CAAC,MAAM,+BAA+B,GAAG;IAC9C,oBAAoB;IACpB,aAAa;CACb,CAAC","sourcesContent":["import type { AgentTool } from \"@earendil-works/pi-agent-core\";\nimport type { AgentSessionInternalSurface as AgentSession } from \"./agent-session-methods.ts\";\nimport type { ToolDefinitionEntry } from \"./agent-session-types.ts\";\nimport { ExtensionRunner, type ToolDefinition, wrapRegisteredTools } from \"./extensions/index.ts\";\nimport { ModelRegistry } from \"./model-registry.ts\";\nimport { createSyntheticSourceInfo } from \"./source-info.ts\";\nimport { createAllToolDefinitions, defaultToolNames } from \"./tools/index.ts\";\nimport { resolveSessionTempDirPath } from \"./tools/session-temp-dir.ts\";\nimport { createToolDefinitionFromAgentTool } from \"./tools/tool-definition-wrapper.ts\";\n\nexport function _refreshToolRegistry(\n\tthis: AgentSession,\n\toptions?: { activeToolNames?: string[]; includeAllExtensionTools?: boolean },\n): void {\n\tconst previousRegistryNames = new Set(this._toolRegistry.keys());\n\tconst previousActiveToolNames = this.getActiveToolNames();\n\tconst allowedToolNames = this._allowedToolNames;\n\tconst excludedToolNames = this._excludedToolNames;\n\tconst isExposedTool = (name: string): boolean => {\n\t\tif (allowedToolNames && !allowedToolNames.has(name)) {\n\t\t\treturn false;\n\t\t}\n\t\tif (excludedToolNames?.has(name)) {\n\t\t\treturn false;\n\t\t}\n\t\treturn true;\n\t};\n\n\tconst registeredTools = this._extensionRunner.getAllRegisteredTools();\n\tconst allCustomTools = [\n\t\t...registeredTools,\n\t\t...this._customTools.map((definition) => ({\n\t\t\tdefinition,\n\t\t\tsourceInfo: createSyntheticSourceInfo(`<sdk:${definition.name}>`, { source: \"sdk\" }),\n\t\t})),\n\t].filter((tool) => isExposedTool(tool.definition.name));\n\tconst definitionRegistry = new Map<string, ToolDefinitionEntry>(\n\t\tArray.from(this._baseToolDefinitions.entries())\n\t\t\t.filter(([name]) => isExposedTool(name))\n\t\t\t.map(([name, definition]) => [\n\t\t\t\tname,\n\t\t\t\t{\n\t\t\t\t\tdefinition,\n\t\t\t\t\tsourceInfo: createSyntheticSourceInfo(`<builtin:${name}>`, { source: \"builtin\" }),\n\t\t\t\t},\n\t\t\t]),\n\t);\n\tfor (const tool of allCustomTools) {\n\t\tdefinitionRegistry.set(tool.definition.name, {\n\t\t\tdefinition: tool.definition,\n\t\t\tsourceInfo: tool.sourceInfo,\n\t\t});\n\t}\n\tthis._toolDefinitions = definitionRegistry;\n\tthis._toolPromptSnippets = new Map(\n\t\tArray.from(definitionRegistry.values())\n\t\t\t.map(({ definition }) => {\n\t\t\t\tconst snippet = this._normalizePromptSnippet(definition.promptSnippet);\n\t\t\t\treturn snippet ? ([definition.name, snippet] as const) : undefined;\n\t\t\t})\n\t\t\t.filter((entry): entry is readonly [string, string] => entry !== undefined),\n\t);\n\tthis._toolPromptGuidelines = new Map(\n\t\tArray.from(definitionRegistry.values())\n\t\t\t.map(({ definition }) => {\n\t\t\t\tconst guidelines = this._normalizePromptGuidelines(definition.promptGuidelines);\n\t\t\t\treturn guidelines.length > 0 ? ([definition.name, guidelines] as const) : undefined;\n\t\t\t})\n\t\t\t.filter((entry): entry is readonly [string, string[]] => entry !== undefined),\n\t);\n\tconst runner = this._extensionRunner;\n\tconst wrappedExtensionTools = wrapRegisteredTools(allCustomTools, runner);\n\tconst wrappedBuiltInTools = wrapRegisteredTools(\n\t\tArray.from(this._baseToolDefinitions.values())\n\t\t\t.filter((definition) => isExposedTool(definition.name))\n\t\t\t.map((definition) => ({\n\t\t\t\tdefinition,\n\t\t\t\tsourceInfo: createSyntheticSourceInfo(`<builtin:${definition.name}>`, { source: \"builtin\" }),\n\t\t\t})),\n\t\trunner,\n\t);\n\n\tconst toolRegistry = new Map(wrappedBuiltInTools.map((tool) => [tool.name, tool]));\n\tfor (const tool of wrappedExtensionTools as AgentTool[]) {\n\t\ttoolRegistry.set(tool.name, tool);\n\t}\n\tthis._toolRegistry = toolRegistry;\n\n\tconst nextActiveToolNames = (\n\t\toptions?.activeToolNames ? [...options.activeToolNames] : [...previousActiveToolNames]\n\t).filter((name) => isExposedTool(name));\n\n\tif (allowedToolNames) {\n\t\tfor (const toolName of this._toolRegistry.keys()) {\n\t\t\tif (allowedToolNames.has(toolName)) {\n\t\t\t\tnextActiveToolNames.push(toolName);\n\t\t\t}\n\t\t}\n\t} else if (options?.includeAllExtensionTools) {\n\t\tfor (const tool of wrappedExtensionTools) {\n\t\t\tnextActiveToolNames.push(tool.name);\n\t\t}\n\t} else if (!options?.activeToolNames) {\n\t\tfor (const toolName of this._toolRegistry.keys()) {\n\t\t\tif (!previousRegistryNames.has(toolName)) {\n\t\t\t\tnextActiveToolNames.push(toolName);\n\t\t\t}\n\t\t}\n\t}\n\n\tthis.setActiveToolsByName([...new Set(nextActiveToolNames)]);\n}\n\nexport function _buildRuntime(\n\tthis: AgentSession,\n\toptions: {\n\t\tactiveToolNames?: string[];\n\t\tflagValues?: Map<string, boolean | string>;\n\t\tincludeAllExtensionTools?: boolean;\n\t},\n): void {\n\tconst autoResizeImages = this.settingsManager.getImageAutoResize();\n\tconst shellCommandPrefix = this.settingsManager.getShellCommandPrefix();\n\tconst shellPath = this.settingsManager.getShellPath();\n\tconst isAllowedBuiltinTool = (name: string): boolean => {\n\t\tif (this._allowedToolNames && !this._allowedToolNames.has(name)) return false;\n\t\tif (this._excludedToolNames?.has(name)) return false;\n\t\treturn true;\n\t};\n\tconst activeBuiltinTools = (options.activeToolNames ?? [...defaultToolNames]).filter(isAllowedBuiltinTool);\n\tconst baseToolDefinitions = this._baseToolsOverride\n\t\t? Object.fromEntries(\n\t\t\t\tObject.entries(this._baseToolsOverride).map(([name, tool]) => [\n\t\t\t\t\tname,\n\t\t\t\t\tcreateToolDefinitionFromAgentTool(tool),\n\t\t\t\t]),\n\t\t\t)\n\t\t: createAllToolDefinitions(this._cwd, {\n\t\t\t\tread: { autoResizeImages },\n\t\t\t\tbash: {\n\t\t\t\t\tcommandPrefix: shellCommandPrefix,\n\t\t\t\t\tshellPath,\n\t\t\t\t\tinterceptorEnabled: () => this.settingsManager.getBashInterceptorEnabled(),\n\t\t\t\t\tavailableTools: activeBuiltinTools,\n\t\t\t\t\t// Resolved per execution so bash spill files follow the live\n\t\t\t\t\t// transcript session across fork/branch/resume.\n\t\t\t\t\tsessionTempDir: () => resolveSessionTempDirPath(this.sessionManager.getSessionId()),\n\t\t\t\t\tinterceptor: async (context) => {\n\t\t\t\t\t\tconst result = await this._extensionRunner.emitUserBash({\n\t\t\t\t\t\t\ttype: \"user_bash\",\n\t\t\t\t\t\t\tcommand: context.command,\n\t\t\t\t\t\t\texcludeFromContext: false,\n\t\t\t\t\t\t\tcwd: context.cwd,\n\t\t\t\t\t\t});\n\t\t\t\t\t\treturn result;\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\tsearch: {\n\t\t\t\t\tcontextBefore: this.settingsManager.getSearchContextBefore(),\n\t\t\t\t\tcontextAfter: this.settingsManager.getSearchContextAfter(),\n\t\t\t\t},\n\t\t\t});\n\n\tthis._baseToolDefinitions = new Map(\n\t\tObject.entries(baseToolDefinitions).map(([name, tool]) => [name, tool as ToolDefinition]),\n\t);\n\n\tconst extensionsResult = this._resourceLoader.getExtensions();\n\tif (options.flagValues) {\n\t\tfor (const [name, value] of options.flagValues) {\n\t\t\textensionsResult.runtime.flagValues.set(name, value);\n\t\t\textensionsResult.runtime.explicitFlagNames ??= new Set();\n\t\t\textensionsResult.runtime.explicitFlagNames.add(name);\n\t\t}\n\t}\n\n\tthis._extensionRunner = new ExtensionRunner(\n\t\textensionsResult.extensions,\n\t\textensionsResult.runtime,\n\t\tthis._cwd,\n\t\tthis.sessionManager,\n\t\tnew ModelRegistry(this._modelRuntime),\n\t\tthis._orchestrationContext,\n\t\tthis._subagentPolicy,\n\t);\n\tif (this._extensionRunnerRef) {\n\t\tthis._extensionRunnerRef.current = this._extensionRunner;\n\t}\n\tthis._bindExtensionCore(this._extensionRunner);\n\tthis._applyExtensionBindings(this._extensionRunner);\n\n\tconst defaultActiveToolNames = this._baseToolsOverride\n\t\t? Object.keys(this._baseToolsOverride)\n\t\t: [...defaultToolNames];\n\tconst baseActiveToolNames = options.activeToolNames ?? defaultActiveToolNames;\n\tthis._refreshToolRegistry({\n\t\tactiveToolNames: baseActiveToolNames,\n\t\tincludeAllExtensionTools: options.includeAllExtensionTools,\n\t});\n}\n\nexport const agentSessionToolRegistryMethods = {\n\t_refreshToolRegistry,\n\t_buildRuntime,\n};\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agent-session-transfer.d.ts","sourceRoot":"","sources":["../../src/core/agent-session-transfer.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,2BAA2B,IAAI,YAAY,EAAE,MAAM,4BAA4B,CAAC;
|
|
1
|
+
{"version":3,"file":"agent-session-transfer.d.ts","sourceRoot":"","sources":["../../src/core/agent-session-transfer.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,2BAA2B,IAAI,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAI9F,wGAAwG;AACxG,wBAAgB,iCAAiC,CAAC,IAAI,EAAE,YAAY,EAAE,MAAM,EAAE,MAAM,GAAG,IAAI,CAwD1F"}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { forwardWorkflowStageDeliveries, resolveWorkflowStageDeliveryTarget, } from "./agent-session-delivery-forwarding.js";
|
|
2
2
|
import { transferProtectedStreamingCustomMessages } from "./agent-session-persistent-custom-messages.js";
|
|
3
3
|
import { composePauseAbortBoundaries } from "./agent-session-queue-pause.js";
|
|
4
|
-
import { createSessionAsyncDeliveryHandler } from "./async/session-manager.js";
|
|
5
4
|
/** Atomically retire one stage session and prepend all of its delivery ownership to the replacement. */
|
|
6
5
|
export function transferWorkflowStageDeliveriesTo(target) {
|
|
7
6
|
const requestedTarget = target;
|
|
@@ -62,6 +61,5 @@ export function transferWorkflowStageDeliveriesTo(target) {
|
|
|
62
61
|
}
|
|
63
62
|
source._emitQueueUpdate();
|
|
64
63
|
next._emitQueueUpdate();
|
|
65
|
-
source._asyncJobManager.transferSessionDeliveries(source._asyncJobManagerSessionId, next._asyncJobManagerSessionId, createSessionAsyncDeliveryHandler(next, next._asyncJobManager, next._asyncJobManagerSessionId));
|
|
66
64
|
}
|
|
67
65
|
//# sourceMappingURL=agent-session-transfer.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agent-session-transfer.js","sourceRoot":"","sources":["../../src/core/agent-session-transfer.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,8BAA8B,EAC9B,kCAAkC,GAClC,MAAM,wCAAwC,CAAC;AAEhD,OAAO,EAAE,wCAAwC,EAAE,MAAM,+CAA+C,CAAC;AACzG,OAAO,EAAE,2BAA2B,EAAE,MAAM,gCAAgC,CAAC;
|
|
1
|
+
{"version":3,"file":"agent-session-transfer.js","sourceRoot":"","sources":["../../src/core/agent-session-transfer.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,8BAA8B,EAC9B,kCAAkC,GAClC,MAAM,wCAAwC,CAAC;AAEhD,OAAO,EAAE,wCAAwC,EAAE,MAAM,+CAA+C,CAAC;AACzG,OAAO,EAAE,2BAA2B,EAAE,MAAM,gCAAgC,CAAC;AAE7E,wGAAwG;AACxG,MAAM,UAAU,iCAAiC,CAAqB,MAAc;IACnF,MAAM,eAAe,GAAG,MAAsB,CAAC;IAC/C,MAAM,MAAM,GAAG,8BAA8B,CAAC,IAAI,EAAE,eAAe,CAAC,CAAC;IACrE,IAAI,MAAM,KAAK,SAAS;QAAE,OAAO;IACjC,MAAM,IAAI,GAAG,kCAAkC,CAAC,eAAe,CAAC,CAAC;IACjE,MAAM,YAAY,GAAG,MAAM,CAAC,qBAAqB,CAAC;IAClD,MAAM,YAAY,GAAG,IAAI,CAAC,qBAAqB,CAAC;IAChD,MAAM,oBAAoB,GAAG,MAAM,CAAC,uBAAuB,CAAC;IAC5D,MAAM,oBAAoB,GAAG,IAAI,CAAC,uBAA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QAC3E,IAAI,CAAC,yBAAyB,GAAG,WAAW,CAAC;IAC9C,CAAC;SAAM,CAAC;QACP,IAAI,CAAC,2BAA2B,CAAC,WAAW,CAAC,CAAC;IAC/C,CAAC;IACD,MAAM,CAAC,gBAAgB,EAAE,CAAC;IAC1B,IAAI,CAAC,gBAAgB,EAAE,CAAC;AACzB,CAAC","sourcesContent":["import {\n\tforwardWorkflowStageDeliveries,\n\tresolveWorkflowStageDeliveryTarget,\n} from \"./agent-session-delivery-forwarding.ts\";\nimport type { AgentSessionInternalSurface as AgentSession } from \"./agent-session-methods.ts\";\nimport { transferProtectedStreamingCustomMessages } from \"./agent-session-persistent-custom-messages.ts\";\nimport { composePauseAbortBoundaries } from \"./agent-session-queue-pause.ts\";\n\n/** Atomically retire one stage session and prepend all of its delivery ownership to the replacement. */\nexport function transferWorkflowStageDeliveriesTo(this: AgentSession, target: object): void {\n\tconst requestedTarget = target as AgentSession;\n\tconst source = forwardWorkflowStageDeliveries(this, requestedTarget);\n\tif (source === undefined) return;\n\tconst next = resolveWorkflowStageDeliveryTarget(requestedTarget);\n\tconst sourcePaused = source._queuedMessagesPaused;\n\tconst targetPaused = next._queuedMessagesPaused;\n\tconst sourceInterruptQueue = source._interruptDeliveryQueue;\n\tconst targetInterruptQueue = next._interruptDeliveryQueue;\n\tconst sourcePendingInterrupts = source._pendingInterruptDeliveries;\n\tconst sourceLive = source._drainQueuedAgentMessages();\n\tconst sourceAbortBoundary = source._queuedMessagesPauseAbortBoundary;\n\tconst targetAbortBoundary = next._queuedMessagesPauseAbortBoundary;\n\tconst targetLive = next._drainQueuedAgentMessages();\n\tconst sourceHeld = source._activeInterruptQueueHold ?? { steering: [], followUp: [] };\n\tconst targetHeld = next._activeInterruptQueueHold ?? { steering: [], followUp: [] };\n\tconst sourceQueues = {\n\t\tsteering: [...sourceHeld.steering, ...sourceLive.steering],\n\t\tfollowUp: [...sourceHeld.followUp, ...sourceLive.followUp],\n\t};\n\tconst transferred = {\n\t\tsteering: [...sourceQueues.steering, ...targetHeld.steering, ...targetLive.steering],\n\t\tfollowUp: [...sourceQueues.followUp, ...targetHeld.followUp, ...targetLive.followUp],\n\t};\n\ttransferProtectedStreamingCustomMessages(source, next, sourceQueues);\n\tnext._pendingNextTurnMessages.unshift(...source._pendingNextTurnMessages.splice(0));\n\tnext._steeringMessages = [...source._steeringMessages.splice(0), ...next._steeringMessages];\n\tnext._followUpMessages = [...source._followUpMessages.splice(0), ...next._followUpMessages];\n\tsource._activeInterruptQueueHold = undefined;\n\tsource._queuedMessagesPaused = false;\n\tsource._queuedMessagesPauseAbortBoundary = undefined;\n\tsource._pendingInterruptDeliveries = 0;\n\tif (sourcePendingInterrupts > 0) {\n\t\tnext._pendingInterruptDeliveries += sourcePendingInterrupts;\n\t\t// Existing source and replacement deliveries may already be running. Future\n\t\t// interrupts and resume must wait for both settlement chains without making\n\t\t// the forwarded source callback wait on a chain that contains itself.\n\t\tnext._interruptDeliveryQueue = Promise.all([sourceInterruptQueue, targetInterruptQueue])\n\t\t\t.then(() => undefined)\n\t\t\t.catch(() => undefined);\n\t}\n\tnext._activeInterruptQueueHold = undefined;\n\tconst transferredAbortBoundary = composePauseAbortBoundaries([sourceAbortBoundary, targetAbortBoundary]);\n\tnext._queuedMessagesPauseAbortBoundary = transferredAbortBoundary;\n\tif (transferredAbortBoundary !== undefined) void transferredAbortBoundary.catch(() => {});\n\tconst remainsPaused = sourcePaused || targetPaused;\n\tnext._queuedMessagesPaused = remainsPaused;\n\tif (remainsPaused || next._pendingInterruptDeliveries > 0) {\n\t\t// A transferred interrupt keeps exclusive ownership of the combined hold.\n\t\t// Its finalizer restores the hold only after the last live-owner delivery.\n\t\tnext._activeInterruptQueueHold = transferred;\n\t} else {\n\t\tnext._restoreQueuedAgentMessages(transferred);\n\t}\n\tsource._emitQueueUpdate();\n\tnext._emitQueueUpdate();\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agent-session-tree.d.ts","sourceRoot":"","sources":["../../src/core/agent-session-tree.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,2BAA2B,IAAI,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAG9F,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAG/D,wBAAgB,cAAc,CAAC,IAAI,EAAE,YAAY,EAAE,IAAI,EAAE,MAAM,GAAG,IAAI,CAKrE;AAMD;;;;;;;;;;GAUG;AAEH,wBAAsB,YAAY,CACjC,IAAI,EAAE,YAAY,EAClB,QAAQ,EAAE,MAAM,EAChB,OAAO,GAAE;IAAE,SAAS,CAAC,EAAE,OAAO,CAAC;IAAC,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAAC,mBAAmB,CAAC,EAAE,OAAO,CAAC;IAAC,KAAK,CAAC,EAAE,MAAM,CAAA;CAAO,GAC/G,OAAO,CAAC;IAAE,UAAU,CAAC,EAAE,MAAM,CAAC;IAAC,SAAS,EAAE,OAAO,CAAC;IAAC,OAAO,CAAC,EAAE,OAAO,CAAC;IAAC,YAAY,CAAC,EAAE,kBAAkB,CAAA;CAAE,CAAC,
|
|
1
|
+
{"version":3,"file":"agent-session-tree.d.ts","sourceRoot":"","sources":["../../src/core/agent-session-tree.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,2BAA2B,IAAI,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAG9F,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAG/D,wBAAgB,cAAc,CAAC,IAAI,EAAE,YAAY,EAAE,IAAI,EAAE,MAAM,GAAG,IAAI,CAKrE;AAMD;;;;;;;;;;GAUG;AAEH,wBAAsB,YAAY,CACjC,IAAI,EAAE,YAAY,EAClB,QAAQ,EAAE,MAAM,EAChB,OAAO,GAAE;IAAE,SAAS,CAAC,EAAE,OAAO,CAAC;IAAC,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAAC,mBAAmB,CAAC,EAAE,OAAO,CAAC;IAAC,KAAK,CAAC,EAAE,MAAM,CAAA;CAAO,GAC/G,OAAO,CAAC;IAAE,UAAU,CAAC,EAAE,MAAM,CAAC;IAAC,SAAS,EAAE,OAAO,CAAC;IAAC,OAAO,CAAC,EAAE,OAAO,CAAC;IAAC,YAAY,CAAC,EAAE,kBAAkB,CAAA;CAAE,CAAC,CA4M5G;AAED;;GAEG;AAEH,wBAAgB,yBAAyB,CAAC,IAAI,EAAE,YAAY,GAAG,KAAK,CAAC;IAAE,OAAO,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,CAAC,CAetG;AAED,wBAAgB,uBAAuB,CACtC,IAAI,EAAE,YAAY,EAClB,OAAO,EAAE,MAAM,GAAG,KAAK,CAAC;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,IAAI,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC,GACtD,MAAM,CASR;AAED;;GAEG;AAEH,eAAO,MAAM,uBAAuB;;;;;CAKnC,CAAC"}
|
|
@@ -55,6 +55,12 @@ export async function navigateTree(targetId, options = {}) {
|
|
|
55
55
|
replaceInstructions,
|
|
56
56
|
label,
|
|
57
57
|
};
|
|
58
|
+
// Moving the leaf invalidates any session summary still in flight: it was generated from the
|
|
59
|
+
// branch we are leaving. Its anchor can survive the move — a `branch_summary` is not a
|
|
60
|
+
// conversation message, and navigating to an existing assistant message leaves the last
|
|
61
|
+
// message id unchanged — so the anchor check alone would let it persist against the new
|
|
62
|
+
// branch. Cancelling here is what the signal check before persistence keys off.
|
|
63
|
+
this.abortSessionSummary();
|
|
58
64
|
// Set up abort controller for summarization
|
|
59
65
|
this._branchSummaryAbortController = new AbortController();
|
|
60
66
|
if (this._compactionReason === undefined)
|