@bastani/atomic 0.9.64 → 0.9.65

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.
Files changed (39) hide show
  1. package/CHANGELOG.md +24 -0
  2. package/dist/builtin/intercom/package.json +1 -1
  3. package/dist/builtin/mcp/package.json +1 -1
  4. package/dist/builtin/subagents/README.md +1 -1
  5. package/dist/builtin/subagents/package.json +1 -1
  6. package/dist/builtin/subagents/skills/subagent/SKILL.md +1 -1
  7. package/dist/builtin/subagents/src/extension/index.bundle.mjs +267 -90
  8. package/dist/builtin/web-access/package.json +1 -1
  9. package/dist/builtin/workflows/package.json +1 -1
  10. package/dist/core/agent-session-state.d.ts.map +1 -1
  11. package/dist/core/agent-session-state.js +26 -0
  12. package/dist/core/agent-session-state.js.map +1 -1
  13. package/dist/core/model-routing-constraints.js +1 -1
  14. package/dist/core/model-routing-constraints.js.map +1 -1
  15. package/dist/core/tasks/completion.d.ts +9 -2
  16. package/dist/core/tasks/completion.d.ts.map +1 -1
  17. package/dist/core/tasks/completion.js +16 -0
  18. package/dist/core/tasks/completion.js.map +1 -1
  19. package/dist/core/tasks/contracts.d.ts +8 -1
  20. package/dist/core/tasks/contracts.d.ts.map +1 -1
  21. package/dist/core/tasks/contracts.js.map +1 -1
  22. package/dist/core/tasks/heartbeat-notice.d.ts +2 -0
  23. package/dist/core/tasks/heartbeat-notice.d.ts.map +1 -1
  24. package/dist/core/tasks/heartbeat-notice.js +4 -1
  25. package/dist/core/tasks/heartbeat-notice.js.map +1 -1
  26. package/dist/core/tasks/heartbeat.d.ts.map +1 -1
  27. package/dist/core/tasks/heartbeat.js +1 -0
  28. package/dist/core/tasks/heartbeat.js.map +1 -1
  29. package/dist/core/tasks/supervisor.d.ts.map +1 -1
  30. package/dist/core/tasks/supervisor.js +6 -0
  31. package/dist/core/tasks/supervisor.js.map +1 -1
  32. package/dist/index.d.ts +1 -0
  33. package/dist/index.d.ts.map +1 -1
  34. package/dist/index.js +1 -0
  35. package/dist/index.js.map +1 -1
  36. package/docs/subagents/reference.md +8 -2
  37. package/docs/subagents.md +1 -1
  38. package/npm-shrinkwrap.json +32 -32
  39. package/package.json +3 -3
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bastani/web-access",
3
- "version": "0.9.64",
3
+ "version": "0.9.65",
4
4
  "private": true,
5
5
  "description": "Atomic extension for web search, URL fetching, GitHub repo cloning, PDF/video extraction. Fork of: https://github.com/nicobailon/pi-web-access",
6
6
  "contributors": [
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bastani/workflows",
3
- "version": "0.9.64",
3
+ "version": "0.9.65",
4
4
  "private": true,
5
5
  "description": "Atomic extension for multi-stage workflow authoring and execution.",
6
6
  "contributors": [
@@ -1 +1 @@
1
- {"version":3,"file":"agent-session-state.d.ts","sourceRoot":"","sources":["../../src/core/agent-session-state.ts"],"names":[],"mappings":"AAAA,OAAO,EAA4C,KAAK,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAC9F,OAAO,KAAK,EAAE,GAAG,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC;AACxD,OAAO,KAAK,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAC;AACjF,OAAO,KAAK,EAAE,2BAA2B,IAAI,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAE9F,OAAO,KAAK,EAAE,cAAc,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AAGtE,OAAO,EAIN,KAAK,kCAAkC,EAEvC,MAAM,oBAAoB,CAAC;AAG5B,OAAO,EAIN,KAAK,gBAAgB,EACrB,MAAM,kBAAkB,CAAC;AAE1B,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,YAAY,GAAG,MAAM,EAAE,CAE/D;AAED,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,YAAY,GAAG,MAAM,EAAE,CAEjE;AAED;;GAEG;AAEH,wBAAgB,WAAW,CAAC,IAAI,EAAE,YAAY,GAAG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AAG,IAAI,CAEhF;AAED,4FAA4F;AAC5F,wBAAgB,4BAA4B,CAC3C,IAAI,EAAE,YAAY,EAClB,OAAO,EAAE,kCAAkC,EAC3C,QAAQ,GAAE,YAAY,EAA8B,GAClD,aAAa,GAAG,SAAS,CAS3B;AAED,wBAAgB,2BAA2B,CAAC,OAAO,EAAE,YAAY,GAAG,OAAO,CAM1E;AAED,0FAA0F;AAC1F,MAAM,WAAW,mBAAmB;IACnC,QAAQ,CAAC,OAAO,EAAE,SAAS,MAAM,EAAE,CAAC;IACpC,QAAQ,CAAC,SAAS,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC;CACxC;AAED,uFAAuF;AACvF,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,YAAY,GAAG,mBAAmB,GAAG,SAAS,CAqB1F;AAED;;;;GAIG;AACH,wBAAgB,6BAA6B,CAC5C,OAAO,EAAE,YAAY,EACrB,QAAQ,EAAE,mBAAmB,EAC7B,IAAI,EAAE,MAAM,EACZ,UAAU,EAAE;IAAE,QAAQ,CAAC,EAAE,MAAM,CAAC;IAAC,aAAa,CAAC,EAAE,OAAO,CAAA;CAAE,GAAG,SAAS,GACpE,OAAO,CAMT;AAED;;;;;;;GAOG;AACH,wBAAgB,2BAA2B,CAAC,IAAI,EAAE,YAAY,EAAE,OAAO,CAAC,EAAE;IAAE,OAAO,CAAC,EAAE,OAAO,CAAA;CAAE,GAAG,IAAI,CAoBrG;AAMD;;;;;;;;GAQG;AAEH,eAAO,MAAM,wBAAwB;;;;;;;;;;;;;;;CAepC,CAAC"}
@@ -121,6 +121,8 @@ export function _rebuildSystemPrompt(toolNames) {
121
121
  const appendSystemPrompt = loaderAppendSystemPrompt.length > 0 ? loaderAppendSystemPrompt.join("\n\n") : undefined;
122
122
  const loadedSkills = getSkillCatalog(this._resourceLoader).modelSkills();
123
123
  const loadedContextFiles = this._resourceLoader.getAgentsFiles().agentsFiles;
124
+ const previousBase = this._baseSystemPromptOptions;
125
+ const previousForcedPrompt = previousBase?.forceSystemPrompt;
124
126
  this._baseSystemPromptOptions = normalizeBuildSystemPromptOptions({
125
127
  cwd: this._cwd,
126
128
  selectedModel: this.model,
@@ -138,6 +140,30 @@ export function _rebuildSystemPrompt(toolNames) {
138
140
  if (this._systemPromptTransform) {
139
141
  this._baseSystemPromptOptions.forceSystemPrompt = this._systemPromptTransform(buildSystemPrompt(this._baseSystemPromptOptions));
140
142
  }
143
+ // A model switch partway through a run, such as a fallback, must tell the next request which model it goes to
144
+ // (#4188). A running turn whose prompt is still this session's own transformed prompt takes the rebuilt one. A prompt
145
+ // a `before_agent_start` handler built stays the handler's, with the model section it kept from the old prompt
146
+ // brought up to date.
147
+ const run = this._runSystemPromptOptions;
148
+ const runPrompt = run?.forceSystemPrompt;
149
+ if (run && runPrompt !== undefined) {
150
+ const base = this._baseSystemPromptOptions;
151
+ const previousModelSection = previousBase ? buildSystemPromptSections(previousBase).model : undefined;
152
+ const modelSection = buildSystemPromptSections(base).model;
153
+ const forceSystemPrompt = previousForcedPrompt !== undefined && runPrompt === previousForcedPrompt
154
+ ? base.forceSystemPrompt
155
+ : previousModelSection && modelSection && previousModelSection !== modelSection
156
+ ? runPrompt.split(previousModelSection).join(modelSection)
157
+ : runPrompt;
158
+ if (forceSystemPrompt !== runPrompt) {
159
+ this._runSystemPromptOptions = {
160
+ ...run,
161
+ forceSystemPrompt,
162
+ selectedModel: base.selectedModel,
163
+ selectedThinkingLevel: base.selectedThinkingLevel,
164
+ };
165
+ }
166
+ }
141
167
  }
142
168
  export function _refreshBaseSystemPromptFromActiveTools() {
143
169
  this._rebuildSystemPrompt(this.getActiveToolNames());
@@ -1 +1 @@
1
- {"version":3,"file":"agent-session-state.js","sourceRoot":"","sources":["../../src/core/agent-session-state.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,uBAAuB,EAAE,eAAe,EAAsB,MAAM,gBAAgB,CAAC;AAI9F,OAAO,EAAE,gBAAgB,EAAE,MAAM,iCAAiC,CAAC;AAEnE,OAA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AI,CAAC,EAAE,UAAU,CAAC,CAChG,CAAC;IACF,MAAM,QAAQ,GAAG,kBAAkB,CAAC,CAAC,GAAG,QAAQ,CAAC,OAAO,EAAE,GAAG,QAAQ,CAAC,EAAE,SAAS,CAAC,CAAC;IACnF,IAAI,CAAC,WAAW,EAAE,CAAC;QAClB,IAAI,CAAC,iBAAiB,GAAG,IAAI,GAAG,CAAC,QAAQ,CAAC,CAAC;QAC3C,IAAI,CAAC,eAAe,CAAC,QAAQ,CAAC,CAAC;QAC/B,OAAO;IACR,CAAC;IACD,MAAM,QAAQ,GAAG,QAAQ,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,IAAI,CAAC,oBAAoB,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC;IACjF,IAAI,CAAC,iBAAiB,GAAG,IAAI,GAAG,CAAC,QAAQ,CAAC,CAAC;IAC3C,IAAI,CAAC,eAAe,CAAC,kBAAkB,CAAC,CAAC,GAAG,IAAI,CAAC,kBAAkB,EAAE,EAAE,GAAG,QAAQ,CAAC,EAAE,SAAS,CAAC,CAAC,CAAC;AAClG,CAAC;AAED,4EAA4E;AAC5E,YAAY;AACZ,4EAA4E;AAE5E;;;;;;;;GAQG;AAEH,MAAM,CAAC,MAAM,wBAAwB,GAAG;IACvC,kBAAkB;IAClB,oBAAoB;IACpB,WAAW;IACX,iBAAiB;IACjB,aAAa;IACb,oBAAoB;IACpB,eAAe;IACf,eAAe;IACf,uBAAuB;IACvB,0BAA0B;IAC1B,oBAAoB;IACpB,4BAA4B;IAC5B,2BAA2B;IAC3B,uCAAuC;CACvC,CAAC","sourcesContent":["import { getCurrentSystemMessage, getCurrentTools, type SystemMessage } from \"@bastani/pi-ai\";\nimport type { Api, Model } from \"@bastani/pi-ai/compat\";\nimport type { AgentMessage, ThinkingLevel } from \"@earendil-works/pi-agent-core\";\nimport type { AgentSessionInternalSurface as AgentSession } from \"./agent-session-methods.ts\";\nimport { getCallableTools } from \"./agent-session-nested-tools.js\";\nimport type { ToolDefinition, ToolInfo } from \"./extensions/index.js\";\nimport { applyToolModifiers } from \"./settings-merge.js\";\nimport { getSkillCatalog } from \"./skill-catalog.ts\";\nimport {\n\tbuildSystemPrompt,\n\tbuildSystemPromptSections,\n\tdiffSystemPromptSections,\n\ttype NormalizedBuildSystemPromptOptions,\n\tnormalizeBuildSystemPromptOptions,\n} from \"./system-prompt.ts\";\nimport { applyToolLoadout, isToolDeclarationHidden } from \"./tool-loadout.js\";\nimport { activatesOnRegistration, selectedToolNames } from \"./tool-selection.ts\";\nimport {\n\tbuildToolStatusReport,\n\tdescribeToolSelection,\n\ttype ToolSelectionSource,\n\ttype ToolStatusReport,\n} from \"./tool-status.js\";\n\nexport function getActiveToolNames(this: AgentSession): string[] {\n\treturn this.agent.state.tools.map((t) => t.name);\n}\n\nexport function getCallableToolNames(this: AgentSession): string[] {\n\treturn getCallableTools(this).map((tool) => tool.name);\n}\n\n/**\n * Get all configured tools with name, description, parameter schema, and source metadata.\n */\n\nexport function getAllTools(this: AgentSession): ToolInfo[] {\n\treturn Array.from(this._toolDefinitions.values()).map(({ definition, sourceInfo }) => ({\n\t\tname: definition.name,\n\t\tdescription: definition.description,\n\t\tparameters: definition.parameters,\n\t\t...(Object.hasOwn(definition, \"constrainedSampling\")\n\t\t\t? { constrainedSampling: definition.constrainedSampling }\n\t\t\t: {}),\n\t\tpromptGuidelines: definition.promptGuidelines,\n\t\texposure: definition.exposure ?? \"direct\",\n\t\tnamespace: definition.namespace,\n\t\tannotations: definition.annotations,\n\t\tsourceInfo,\n\t}));\n}\n\nexport function getToolDefinition(this: AgentSession, name: string): ToolDefinition | undefined {\n\treturn this._toolDefinitions.get(name)?.definition;\n}\n\nfunction toolSelectionSource(session: AgentSession): ToolSelectionSource {\n\tif (session._usesDefaultTools) {\n\t\treturn session.settingsManager.getDefaultTools() === undefined ? \"built-in-defaults\" : \"default-tools-setting\";\n\t}\n\tif (session._allowedToolNames) return session._allowedToolNames.size === 0 ? \"no-tools\" : \"tools-allowlist\";\n\treturn (session._initialActiveToolNames?.length ?? 0) > 0 ? \"explicit-selection\" : \"no-built-in-tools\";\n}\n\n/**\n * Explain every registered tool (active or not, and why), where the tool selection came from,\n * and which selected names nothing registered. Format it with `formatToolStatus()`.\n */\nexport function getToolStatus(this: AgentSession): ToolStatusReport {\n\tconst source = toolSelectionSource(this);\n\tconst modifiers = [...this._defaultToolModifiers];\n\treturn buildToolStatusReport({\n\t\ttools: [...this._toolDefinitions.values()],\n\t\tactiveToolNames: this.getActiveToolNames(),\n\t\tselection: {\n\t\t\tsource,\n\t\t\tdescription: describeToolSelection(source, modifiers),\n\t\t\tnames: [...selectedToolNames(this)],\n\t\t\tmodifiers,\n\t\t},\n\t\tisExcluded: this._excludedTools,\n\t\tisAllowed: this._allowedTools,\n\t});\n}\n\n/**\n * Set active tools by name.\n * Only tools in the registry can be enabled. Unknown tool names are ignored.\n * Also rebuilds the system prompt to reflect the new tool set.\n * Changes take effect on the next agent turn.\n */\n\nexport function setActiveToolsByName(this: AgentSession, toolNames: string[]): void {\n\tconst previous = this.getActiveToolNames();\n\tthis._setActiveTools(toolNames);\n\tconst active = new Set(this.getActiveToolNames());\n\tif (previous.some((name) => !active.has(name))) this._pendingToolNames.clear();\n}\n\nexport function _setActiveTools(this: AgentSession, toolNames: string[]): void {\n\tconst tools = applyToolLoadout(this, toolNames);\n\tfor (const tool of tools) this._pendingToolNames.delete(tool.name);\n\tthis._rebuildSystemPrompt(tools.map((tool) => tool.name));\n}\n\n/** Whether compaction or branch summarization is currently running */\n\nexport function setScopedModels(\n\tthis: AgentSession,\n\tscopedModels: Array<{ model: Model<Api>; thinkingLevel?: ThinkingLevel }>,\n): void {\n\tthis._scopedModels = scopedModels;\n}\n\n/** File-based prompt templates */\n\nexport function _normalizePromptSnippet(this: AgentSession, text: string | undefined): string | undefined {\n\tif (!text) return undefined;\n\tconst oneLine = text\n\t\t.replace(/[\\r\\n]+/g, \" \")\n\t\t.replace(/\\s+/g, \" \")\n\t\t.trim();\n\treturn oneLine.length > 0 ? oneLine : undefined;\n}\n\nexport function _normalizePromptGuidelines(this: AgentSession, guidelines: string[] | undefined): string[] {\n\tif (!guidelines || guidelines.length === 0) {\n\t\treturn [];\n\t}\n\n\tconst unique = new Set<string>();\n\tfor (const guideline of guidelines) {\n\t\tconst normalized = guideline.trim();\n\t\tif (normalized.length > 0) {\n\t\t\tunique.add(normalized);\n\t\t}\n\t}\n\treturn Array.from(unique);\n}\n\nexport function _rebuildSystemPrompt(this: AgentSession, toolNames: string[]): void {\n\tconst validToolNames = toolNames.filter((name) => this._toolRegistry.has(name));\n\tconst toolSnippets: Record<string, string> = {};\n\tfor (const name of this._toolRegistry.keys()) {\n\t\tconst snippet = this._toolPromptSnippets.get(name);\n\t\tif (snippet) {\n\t\t\ttoolSnippets[name] = snippet;\n\t\t}\n\t}\n\n\tconst loaderSystemPrompt = this._resourceLoader.getSystemPrompt();\n\tconst loaderAppendSystemPrompt = this._resourceLoader.getAppendSystemPrompt();\n\tconst appendSystemPrompt = loaderAppendSystemPrompt.length > 0 ? loaderAppendSystemPrompt.join(\"\\n\\n\") : undefined;\n\tconst loadedSkills = getSkillCatalog(this._resourceLoader).modelSkills();\n\tconst loadedContextFiles = this._resourceLoader.getAgentsFiles().agentsFiles;\n\n\tthis._baseSystemPromptOptions = normalizeBuildSystemPromptOptions({\n\t\tcwd: this._cwd,\n\t\tselectedModel: this.model,\n\t\tselectedThinkingLevel: this.thinkingLevel,\n\t\tskills: loadedSkills,\n\t\tcontextFiles: loadedContextFiles,\n\t\tcustomPrompt: loaderSystemPrompt,\n\t\tappendSystemPrompt,\n\t\tselectedTools: validToolNames,\n\t\thiddenTools: validToolNames.filter((name) => isToolDeclarationHidden(this, name)),\n\t\texcludedTools: this._excludedToolNames ? Array.from(this._excludedToolNames) : undefined,\n\t\ttoolSnippets,\n\t\ttoolGuidelines: Object.fromEntries(this._toolPromptGuidelines),\n\t});\n\tif (this._systemPromptTransform) {\n\t\tthis._baseSystemPromptOptions.forceSystemPrompt = this._systemPromptTransform(\n\t\t\tbuildSystemPrompt(this._baseSystemPromptOptions),\n\t\t);\n\t}\n}\n\nexport function _refreshBaseSystemPromptFromActiveTools(this: AgentSession): void {\n\tthis._rebuildSystemPrompt(this.getActiveToolNames());\n}\n\n/** Diff structured prompt state; executable tool changes are declared by the agent loop. */\nexport function _preparePromptAndToolLoadout(\n\tthis: AgentSession,\n\toptions: NormalizedBuildSystemPromptOptions,\n\tmessages: AgentMessage[] = this.agent.state.messages,\n): SystemMessage | undefined {\n\tconst current = getCurrentSystemMessage(messages);\n\tconst selected = [...new Set(options.selectedTools)].filter((name) => this._toolRegistry.has(name));\n\tconst recorded = (current?.toolsAdded ?? []).map((tool) => tool.name).filter((name) => selected.includes(name));\n\toptions.selectedTools = [...recorded, ...selected.filter((name) => !recorded.includes(name))];\n\toptions.selectedTools = applyToolLoadout(this, options.selectedTools).map((tool) => tool.name);\n\toptions.hiddenTools = options.selectedTools.filter((name) => isToolDeclarationHidden(this, name));\n\tconst sections = diffSystemPromptSections(current?.sections ?? {}, buildSystemPromptSections(options));\n\treturn sections ? { role: \"system\", content: \"\", sections, timestamp: Date.now() } : undefined;\n}\n\nexport function preservesInitialToolLoadout(session: AgentSession): boolean {\n\treturn (\n\t\t(!session._usesDefaultTools && session._initialActiveToolNames !== undefined) ||\n\t\tsession._orchestrationContext?.kind === \"workflow-stage\" ||\n\t\t(session._subagentPolicy?.depth ?? 0) >= 1\n\t);\n}\n\n/** The tools the selected transcript records, and every tool it ever added or removed. */\nexport interface RecordedToolLoadout {\n\treadonly current: readonly string[];\n\treadonly mentioned: ReadonlySet<string>;\n}\n\n/** The recorded loadout of the selected branch, or undefined when it recorded none. */\nexport function recordedToolLoadout(session: AgentSession): RecordedToolLoadout | undefined {\n\t// All system messages on the branch, including those before a compaction, whose snapshot lists only\n\t// the tools still added. Replaying them gives the current loadout and every tool the branch mentioned.\n\tconst systemMessages = session.sessionManager\n\t\t.getBranch()\n\t\t.flatMap((entry) =>\n\t\t\tentry.type === \"message\" && entry.message.role === \"system\"\n\t\t\t\t? [entry.message]\n\t\t\t\t: entry.type === \"compaction\" && entry.systemMessage\n\t\t\t\t\t? [entry.systemMessage]\n\t\t\t\t\t: [],\n\t\t);\n\tif (systemMessages.length === 0) return undefined;\n\treturn {\n\t\tcurrent: getCurrentTools(systemMessages).map((tool) => tool.name),\n\t\tmentioned: new Set(\n\t\t\tsystemMessages\n\t\t\t\t.flatMap((message) => [...(message.toolsAdded ?? []), ...(message.toolsRemoved ?? [])])\n\t\t\t\t.map((tool) => tool.name),\n\t\t),\n\t};\n}\n\n/**\n * Whether restoring a transcript activates a registered tool it never mentioned. Such an extension tool\n * was registered after the branch recorded its loadout, so it activates like a newly registered tool.\n * Built-in tools follow `defaultTools` instead, and opt-in tools stay inactive until a selection names them.\n */\nexport function activatesAfterRecordedLoadout(\n\tsession: AgentSession,\n\trecorded: RecordedToolLoadout,\n\tname: string,\n\tdefinition: { exposure?: string; defaultActive?: boolean } | undefined,\n): boolean {\n\treturn (\n\t\t!recorded.mentioned.has(name) &&\n\t\t!session._baseToolDefinitions.has(name) &&\n\t\tactivatesOnRegistration(session, name, definition, false)\n\t);\n}\n\n/**\n * Restore registered tools from the selected transcript, not another branch's live state.\n *\n * Explicit tool selections keep their built-in loadout while restoring dynamically registered tools.\n * Default selections restore the recorded loadout with any CLI modifiers applied. Extension tools the\n * branch never added or removed were registered after it recorded its loadout, so they are activated\n * like newly registered tools.\n */\nexport function _restoreToolsFromTranscript(this: AgentSession, options?: { startup?: boolean }): void {\n\tthis._pendingToolNames.clear();\n\tconst recorded = recordedToolLoadout(this);\n\t// No recorded loadout: keep the current tools.\n\tif (!recorded) return;\n\tconst keepLoadout = options?.startup && preservesInitialToolLoadout(this);\n\tconst modifiers = options?.startup && this._usesDefaultTools ? this._defaultToolModifiers : [];\n\t// Removed tools are mentioned too, so they stay inactive.\n\tconst newTools = [...this._toolRegistry.keys()].filter((name) =>\n\t\tactivatesAfterRecordedLoadout(this, recorded, name, this._toolDefinitions.get(name)?.definition),\n\t);\n\tconst declared = applyToolModifiers([...recorded.current, ...newTools], modifiers);\n\tif (!keepLoadout) {\n\t\tthis._pendingToolNames = new Set(declared);\n\t\tthis._setActiveTools(declared);\n\t\treturn;\n\t}\n\tconst restored = declared.filter((name) => !this._baseToolDefinitions.has(name));\n\tthis._pendingToolNames = new Set(restored);\n\tthis._setActiveTools(applyToolModifiers([...this.getActiveToolNames(), ...restored], modifiers));\n}\n\n// =========================================================================\n// Prompting\n// =========================================================================\n\n/**\n * Send a prompt to the agent.\n * - Handles extension commands (registered via pi.registerCommand) immediately, even during streaming\n * - Expands file-based prompt templates by default\n * - During streaming, queues via steer() or followUp() based on streamingBehavior option\n * - Validates model and API key before sending (when not streaming)\n * @throws Error if streaming and no streamingBehavior specified\n * @throws Error if no model selected or no API key available (when not streaming)\n */\n\nexport const agentSessionStateMethods = {\n\tgetActiveToolNames,\n\tgetCallableToolNames,\n\tgetAllTools,\n\tgetToolDefinition,\n\tgetToolStatus,\n\tsetActiveToolsByName,\n\t_setActiveTools,\n\tsetScopedModels,\n\t_normalizePromptSnippet,\n\t_normalizePromptGuidelines,\n\t_rebuildSystemPrompt,\n\t_preparePromptAndToolLoadout,\n\t_restoreToolsFromTranscript,\n\t_refreshBaseSystemPromptFromActiveTools,\n};\n"]}
1
+ {"version":3,"file":"agent-session-state.js","sourceRoot":"","sources":["../../src/core/agent-session-state.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,uBAAuB,EAAE,eAAe,EAAsB,MAAM,gBAAgB,CAAC;AAI9F,OAAO,EAAE,gBAAgB,EAAE,MAAM,iCAAiC,CAAC;AAEnE,OAAO,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AACzD,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AACrD,OAAO,EACN,iBAAiB,EACjB,yBAAyB,EACzB,wBAAwB,EAExB,iCAAi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AAC;QAC/B,OAAO;IACR,CAAC;IACD,MAAM,QAAQ,GAAG,QAAQ,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,IAAI,CAAC,oBAAoB,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC;IACjF,IAAI,CAAC,iBAAiB,GAAG,IAAI,GAAG,CAAC,QAAQ,CAAC,CAAC;IAC3C,IAAI,CAAC,eAAe,CAAC,kBAAkB,CAAC,CAAC,GAAG,IAAI,CAAC,kBAAkB,EAAE,EAAE,GAAG,QAAQ,CAAC,EAAE,SAAS,CAAC,CAAC,CAAC;AAClG,CAAC;AAED,4EAA4E;AAC5E,YAAY;AACZ,4EAA4E;AAE5E;;;;;;;;GAQG;AAEH,MAAM,CAAC,MAAM,wBAAwB,GAAG;IACvC,kBAAkB;IAClB,oBAAoB;IACpB,WAAW;IACX,iBAAiB;IACjB,aAAa;IACb,oBAAoB;IACpB,eAAe;IACf,eAAe;IACf,uBAAuB;IACvB,0BAA0B;IAC1B,oBAAoB;IACpB,4BAA4B;IAC5B,2BAA2B;IAC3B,uCAAuC;CACvC,CAAC","sourcesContent":["import { getCurrentSystemMessage, getCurrentTools, type SystemMessage } from \"@bastani/pi-ai\";\nimport type { Api, Model } from \"@bastani/pi-ai/compat\";\nimport type { AgentMessage, ThinkingLevel } from \"@earendil-works/pi-agent-core\";\nimport type { AgentSessionInternalSurface as AgentSession } from \"./agent-session-methods.ts\";\nimport { getCallableTools } from \"./agent-session-nested-tools.js\";\nimport type { ToolDefinition, ToolInfo } from \"./extensions/index.js\";\nimport { applyToolModifiers } from \"./settings-merge.js\";\nimport { getSkillCatalog } from \"./skill-catalog.ts\";\nimport {\n\tbuildSystemPrompt,\n\tbuildSystemPromptSections,\n\tdiffSystemPromptSections,\n\ttype NormalizedBuildSystemPromptOptions,\n\tnormalizeBuildSystemPromptOptions,\n} from \"./system-prompt.ts\";\nimport { applyToolLoadout, isToolDeclarationHidden } from \"./tool-loadout.js\";\nimport { activatesOnRegistration, selectedToolNames } from \"./tool-selection.ts\";\nimport {\n\tbuildToolStatusReport,\n\tdescribeToolSelection,\n\ttype ToolSelectionSource,\n\ttype ToolStatusReport,\n} from \"./tool-status.js\";\n\nexport function getActiveToolNames(this: AgentSession): string[] {\n\treturn this.agent.state.tools.map((t) => t.name);\n}\n\nexport function getCallableToolNames(this: AgentSession): string[] {\n\treturn getCallableTools(this).map((tool) => tool.name);\n}\n\n/**\n * Get all configured tools with name, description, parameter schema, and source metadata.\n */\n\nexport function getAllTools(this: AgentSession): ToolInfo[] {\n\treturn Array.from(this._toolDefinitions.values()).map(({ definition, sourceInfo }) => ({\n\t\tname: definition.name,\n\t\tdescription: definition.description,\n\t\tparameters: definition.parameters,\n\t\t...(Object.hasOwn(definition, \"constrainedSampling\")\n\t\t\t? { constrainedSampling: definition.constrainedSampling }\n\t\t\t: {}),\n\t\tpromptGuidelines: definition.promptGuidelines,\n\t\texposure: definition.exposure ?? \"direct\",\n\t\tnamespace: definition.namespace,\n\t\tannotations: definition.annotations,\n\t\tsourceInfo,\n\t}));\n}\n\nexport function getToolDefinition(this: AgentSession, name: string): ToolDefinition | undefined {\n\treturn this._toolDefinitions.get(name)?.definition;\n}\n\nfunction toolSelectionSource(session: AgentSession): ToolSelectionSource {\n\tif (session._usesDefaultTools) {\n\t\treturn session.settingsManager.getDefaultTools() === undefined ? \"built-in-defaults\" : \"default-tools-setting\";\n\t}\n\tif (session._allowedToolNames) return session._allowedToolNames.size === 0 ? \"no-tools\" : \"tools-allowlist\";\n\treturn (session._initialActiveToolNames?.length ?? 0) > 0 ? \"explicit-selection\" : \"no-built-in-tools\";\n}\n\n/**\n * Explain every registered tool (active or not, and why), where the tool selection came from,\n * and which selected names nothing registered. Format it with `formatToolStatus()`.\n */\nexport function getToolStatus(this: AgentSession): ToolStatusReport {\n\tconst source = toolSelectionSource(this);\n\tconst modifiers = [...this._defaultToolModifiers];\n\treturn buildToolStatusReport({\n\t\ttools: [...this._toolDefinitions.values()],\n\t\tactiveToolNames: this.getActiveToolNames(),\n\t\tselection: {\n\t\t\tsource,\n\t\t\tdescription: describeToolSelection(source, modifiers),\n\t\t\tnames: [...selectedToolNames(this)],\n\t\t\tmodifiers,\n\t\t},\n\t\tisExcluded: this._excludedTools,\n\t\tisAllowed: this._allowedTools,\n\t});\n}\n\n/**\n * Set active tools by name.\n * Only tools in the registry can be enabled. Unknown tool names are ignored.\n * Also rebuilds the system prompt to reflect the new tool set.\n * Changes take effect on the next agent turn.\n */\n\nexport function setActiveToolsByName(this: AgentSession, toolNames: string[]): void {\n\tconst previous = this.getActiveToolNames();\n\tthis._setActiveTools(toolNames);\n\tconst active = new Set(this.getActiveToolNames());\n\tif (previous.some((name) => !active.has(name))) this._pendingToolNames.clear();\n}\n\nexport function _setActiveTools(this: AgentSession, toolNames: string[]): void {\n\tconst tools = applyToolLoadout(this, toolNames);\n\tfor (const tool of tools) this._pendingToolNames.delete(tool.name);\n\tthis._rebuildSystemPrompt(tools.map((tool) => tool.name));\n}\n\n/** Whether compaction or branch summarization is currently running */\n\nexport function setScopedModels(\n\tthis: AgentSession,\n\tscopedModels: Array<{ model: Model<Api>; thinkingLevel?: ThinkingLevel }>,\n): void {\n\tthis._scopedModels = scopedModels;\n}\n\n/** File-based prompt templates */\n\nexport function _normalizePromptSnippet(this: AgentSession, text: string | undefined): string | undefined {\n\tif (!text) return undefined;\n\tconst oneLine = text\n\t\t.replace(/[\\r\\n]+/g, \" \")\n\t\t.replace(/\\s+/g, \" \")\n\t\t.trim();\n\treturn oneLine.length > 0 ? oneLine : undefined;\n}\n\nexport function _normalizePromptGuidelines(this: AgentSession, guidelines: string[] | undefined): string[] {\n\tif (!guidelines || guidelines.length === 0) {\n\t\treturn [];\n\t}\n\n\tconst unique = new Set<string>();\n\tfor (const guideline of guidelines) {\n\t\tconst normalized = guideline.trim();\n\t\tif (normalized.length > 0) {\n\t\t\tunique.add(normalized);\n\t\t}\n\t}\n\treturn Array.from(unique);\n}\n\nexport function _rebuildSystemPrompt(this: AgentSession, toolNames: string[]): void {\n\tconst validToolNames = toolNames.filter((name) => this._toolRegistry.has(name));\n\tconst toolSnippets: Record<string, string> = {};\n\tfor (const name of this._toolRegistry.keys()) {\n\t\tconst snippet = this._toolPromptSnippets.get(name);\n\t\tif (snippet) {\n\t\t\ttoolSnippets[name] = snippet;\n\t\t}\n\t}\n\n\tconst loaderSystemPrompt = this._resourceLoader.getSystemPrompt();\n\tconst loaderAppendSystemPrompt = this._resourceLoader.getAppendSystemPrompt();\n\tconst appendSystemPrompt = loaderAppendSystemPrompt.length > 0 ? loaderAppendSystemPrompt.join(\"\\n\\n\") : undefined;\n\tconst loadedSkills = getSkillCatalog(this._resourceLoader).modelSkills();\n\tconst loadedContextFiles = this._resourceLoader.getAgentsFiles().agentsFiles;\n\tconst previousBase = this._baseSystemPromptOptions;\n\tconst previousForcedPrompt = previousBase?.forceSystemPrompt;\n\n\tthis._baseSystemPromptOptions = normalizeBuildSystemPromptOptions({\n\t\tcwd: this._cwd,\n\t\tselectedModel: this.model,\n\t\tselectedThinkingLevel: this.thinkingLevel,\n\t\tskills: loadedSkills,\n\t\tcontextFiles: loadedContextFiles,\n\t\tcustomPrompt: loaderSystemPrompt,\n\t\tappendSystemPrompt,\n\t\tselectedTools: validToolNames,\n\t\thiddenTools: validToolNames.filter((name) => isToolDeclarationHidden(this, name)),\n\t\texcludedTools: this._excludedToolNames ? Array.from(this._excludedToolNames) : undefined,\n\t\ttoolSnippets,\n\t\ttoolGuidelines: Object.fromEntries(this._toolPromptGuidelines),\n\t});\n\tif (this._systemPromptTransform) {\n\t\tthis._baseSystemPromptOptions.forceSystemPrompt = this._systemPromptTransform(\n\t\t\tbuildSystemPrompt(this._baseSystemPromptOptions),\n\t\t);\n\t}\n\t// A model switch partway through a run, such as a fallback, must tell the next request which model it goes to\n\t// (#4188). A running turn whose prompt is still this session's own transformed prompt takes the rebuilt one. A prompt\n\t// a `before_agent_start` handler built stays the handler's, with the model section it kept from the old prompt\n\t// brought up to date.\n\tconst run = this._runSystemPromptOptions;\n\tconst runPrompt = run?.forceSystemPrompt;\n\tif (run && runPrompt !== undefined) {\n\t\tconst base = this._baseSystemPromptOptions;\n\t\tconst previousModelSection = previousBase ? buildSystemPromptSections(previousBase).model : undefined;\n\t\tconst modelSection = buildSystemPromptSections(base).model;\n\t\tconst forceSystemPrompt =\n\t\t\tpreviousForcedPrompt !== undefined && runPrompt === previousForcedPrompt\n\t\t\t\t? base.forceSystemPrompt\n\t\t\t\t: previousModelSection && modelSection && previousModelSection !== modelSection\n\t\t\t\t\t? runPrompt.split(previousModelSection).join(modelSection)\n\t\t\t\t\t: runPrompt;\n\t\tif (forceSystemPrompt !== runPrompt) {\n\t\t\tthis._runSystemPromptOptions = {\n\t\t\t\t...run,\n\t\t\t\tforceSystemPrompt,\n\t\t\t\tselectedModel: base.selectedModel,\n\t\t\t\tselectedThinkingLevel: base.selectedThinkingLevel,\n\t\t\t};\n\t\t}\n\t}\n}\n\nexport function _refreshBaseSystemPromptFromActiveTools(this: AgentSession): void {\n\tthis._rebuildSystemPrompt(this.getActiveToolNames());\n}\n\n/** Diff structured prompt state; executable tool changes are declared by the agent loop. */\nexport function _preparePromptAndToolLoadout(\n\tthis: AgentSession,\n\toptions: NormalizedBuildSystemPromptOptions,\n\tmessages: AgentMessage[] = this.agent.state.messages,\n): SystemMessage | undefined {\n\tconst current = getCurrentSystemMessage(messages);\n\tconst selected = [...new Set(options.selectedTools)].filter((name) => this._toolRegistry.has(name));\n\tconst recorded = (current?.toolsAdded ?? []).map((tool) => tool.name).filter((name) => selected.includes(name));\n\toptions.selectedTools = [...recorded, ...selected.filter((name) => !recorded.includes(name))];\n\toptions.selectedTools = applyToolLoadout(this, options.selectedTools).map((tool) => tool.name);\n\toptions.hiddenTools = options.selectedTools.filter((name) => isToolDeclarationHidden(this, name));\n\tconst sections = diffSystemPromptSections(current?.sections ?? {}, buildSystemPromptSections(options));\n\treturn sections ? { role: \"system\", content: \"\", sections, timestamp: Date.now() } : undefined;\n}\n\nexport function preservesInitialToolLoadout(session: AgentSession): boolean {\n\treturn (\n\t\t(!session._usesDefaultTools && session._initialActiveToolNames !== undefined) ||\n\t\tsession._orchestrationContext?.kind === \"workflow-stage\" ||\n\t\t(session._subagentPolicy?.depth ?? 0) >= 1\n\t);\n}\n\n/** The tools the selected transcript records, and every tool it ever added or removed. */\nexport interface RecordedToolLoadout {\n\treadonly current: readonly string[];\n\treadonly mentioned: ReadonlySet<string>;\n}\n\n/** The recorded loadout of the selected branch, or undefined when it recorded none. */\nexport function recordedToolLoadout(session: AgentSession): RecordedToolLoadout | undefined {\n\t// All system messages on the branch, including those before a compaction, whose snapshot lists only\n\t// the tools still added. Replaying them gives the current loadout and every tool the branch mentioned.\n\tconst systemMessages = session.sessionManager\n\t\t.getBranch()\n\t\t.flatMap((entry) =>\n\t\t\tentry.type === \"message\" && entry.message.role === \"system\"\n\t\t\t\t? [entry.message]\n\t\t\t\t: entry.type === \"compaction\" && entry.systemMessage\n\t\t\t\t\t? [entry.systemMessage]\n\t\t\t\t\t: [],\n\t\t);\n\tif (systemMessages.length === 0) return undefined;\n\treturn {\n\t\tcurrent: getCurrentTools(systemMessages).map((tool) => tool.name),\n\t\tmentioned: new Set(\n\t\t\tsystemMessages\n\t\t\t\t.flatMap((message) => [...(message.toolsAdded ?? []), ...(message.toolsRemoved ?? [])])\n\t\t\t\t.map((tool) => tool.name),\n\t\t),\n\t};\n}\n\n/**\n * Whether restoring a transcript activates a registered tool it never mentioned. Such an extension tool\n * was registered after the branch recorded its loadout, so it activates like a newly registered tool.\n * Built-in tools follow `defaultTools` instead, and opt-in tools stay inactive until a selection names them.\n */\nexport function activatesAfterRecordedLoadout(\n\tsession: AgentSession,\n\trecorded: RecordedToolLoadout,\n\tname: string,\n\tdefinition: { exposure?: string; defaultActive?: boolean } | undefined,\n): boolean {\n\treturn (\n\t\t!recorded.mentioned.has(name) &&\n\t\t!session._baseToolDefinitions.has(name) &&\n\t\tactivatesOnRegistration(session, name, definition, false)\n\t);\n}\n\n/**\n * Restore registered tools from the selected transcript, not another branch's live state.\n *\n * Explicit tool selections keep their built-in loadout while restoring dynamically registered tools.\n * Default selections restore the recorded loadout with any CLI modifiers applied. Extension tools the\n * branch never added or removed were registered after it recorded its loadout, so they are activated\n * like newly registered tools.\n */\nexport function _restoreToolsFromTranscript(this: AgentSession, options?: { startup?: boolean }): void {\n\tthis._pendingToolNames.clear();\n\tconst recorded = recordedToolLoadout(this);\n\t// No recorded loadout: keep the current tools.\n\tif (!recorded) return;\n\tconst keepLoadout = options?.startup && preservesInitialToolLoadout(this);\n\tconst modifiers = options?.startup && this._usesDefaultTools ? this._defaultToolModifiers : [];\n\t// Removed tools are mentioned too, so they stay inactive.\n\tconst newTools = [...this._toolRegistry.keys()].filter((name) =>\n\t\tactivatesAfterRecordedLoadout(this, recorded, name, this._toolDefinitions.get(name)?.definition),\n\t);\n\tconst declared = applyToolModifiers([...recorded.current, ...newTools], modifiers);\n\tif (!keepLoadout) {\n\t\tthis._pendingToolNames = new Set(declared);\n\t\tthis._setActiveTools(declared);\n\t\treturn;\n\t}\n\tconst restored = declared.filter((name) => !this._baseToolDefinitions.has(name));\n\tthis._pendingToolNames = new Set(restored);\n\tthis._setActiveTools(applyToolModifiers([...this.getActiveToolNames(), ...restored], modifiers));\n}\n\n// =========================================================================\n// Prompting\n// =========================================================================\n\n/**\n * Send a prompt to the agent.\n * - Handles extension commands (registered via pi.registerCommand) immediately, even during streaming\n * - Expands file-based prompt templates by default\n * - During streaming, queues via steer() or followUp() based on streamingBehavior option\n * - Validates model and API key before sending (when not streaming)\n * @throws Error if streaming and no streamingBehavior specified\n * @throws Error if no model selected or no API key available (when not streaming)\n */\n\nexport const agentSessionStateMethods = {\n\tgetActiveToolNames,\n\tgetCallableToolNames,\n\tgetAllTools,\n\tgetToolDefinition,\n\tgetToolStatus,\n\tsetActiveToolsByName,\n\t_setActiveTools,\n\tsetScopedModels,\n\t_normalizePromptSnippet,\n\t_normalizePromptGuidelines,\n\t_rebuildSystemPrompt,\n\t_preparePromptAndToolLoadout,\n\t_restoreToolsFromTranscript,\n\t_refreshBaseSystemPromptFromActiveTools,\n};\n"]}
@@ -26,7 +26,7 @@ export const ModelConstraintsSchema = Type.Object({
26
26
  ]))),
27
27
  }, {
28
28
  additionalProperties: false,
29
- description: "Hard constraints for auto selection and execution fallback. Applicable definition and call constraints must all hold; concrete model calls keep existing behavior.",
29
+ description: "Hard constraints for auto selection and execution fallback. Applicable definition and call constraints must all hold. A concrete model still runs as named; a subagent launched on one falls back only to its agent's fallbackModels that meet them.",
30
30
  });
31
31
  const validator = Compile(ModelConstraintsSchema);
32
32
  export function parseModelConstraints(value) {
@@ -1 +1 @@
1
- {"version":3,"file":"model-routing-constraints.js","sourceRoot":"","sources":["../../src/core/model-routing-constraints.ts"],"names":[],"mappings":"AACA,OAAO,EAAe,IAAI,EAAE,MAAM,SAAS,CAAC;AAC5C,OAAO,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAE1C,MAAM,CAAC,MAAM,sBAAsB,GAAG,IAAI,CAAC,MAAM,CAChD;IACC,aAAa,EAAE,IAAI,CAAC,QAAQ,CAC3B,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,SAAS,EAAE,CAAC,EAAE,CAAC,EAAE;QACzC,WAAW,EACV,4cAA4c;KAC7c,CAAC,CACF;IACD,gBAAgB,EAAE,IAAI,CAAC,QAAQ,CAC9B,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,SAAS,EAAE,CAAC,EAAE,CAAC,EAAE;QACzC,WAAW,EACV,qQAAqQ;KACtQ,CAAC,CACF;IACD,iBAAiB,EAAE,IAAI,CAAC,QAAQ,CAC/B,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,SAAS,EAAE,CAAC,EAAE,CAAC,EAAE;QACzC,WAAW,EACV,gNAAgN;KACjN,C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AAK,IAAI,CAAC,CAAC,YAAa,CAAC,CAAC;QAC1F,CAAC,CAAC,CAAC,aAAa,KAAK,SAAS;YAC7B,CAAC,KAAK,CAAC,IAAI,EAAE,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,IAAI,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,MAAM,IAAI,CAAC,CAAC,aAAc,CAAC,CAAC;QAC5F,CAAC,CAAC,CAAC,gBAAgB,KAAK,SAAS,IAAI,KAAK,CAAC,aAAa,IAAI,CAAC,CAAC,gBAAgB,CAAC;QAC/E,CAAC,CAAC,CAAC,cAAc,KAAK,SAAS,IAAI,CAAC,CAAC,cAAc,CAAC,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,CACnG,CAAC;AACH,CAAC","sourcesContent":["import type { Api, Model } from \"@bastani/pi-ai\";\nimport { type Static, Type } from \"typebox\";\nimport { Compile } from \"typebox/compile\";\n\nexport const ModelConstraintsSchema = Type.Object(\n\t{\n\t\tallowedModels: Type.Optional(\n\t\t\tType.Array(Type.String({ minLength: 1 }), {\n\t\t\t\tdescription:\n\t\t\t\t\t\"Exact provider/model IDs; omitted uses the full available catalog. With model 'auto', these are the candidates the router chooses between (as many as fit one routing request, roughly 100), so list the models that suit the task. Prefer the user's subscription models (for example ChatGPT/Codex, GitHub Copilot, a Claude subscription, or a coding or token plan) over pay-per-token API models, unless the user asked for API models or has no subscription models.\",\n\t\t\t}),\n\t\t),\n\t\tallowedProviders: Type.Optional(\n\t\t\tType.Array(Type.String({ minLength: 1 }), {\n\t\t\t\tdescription:\n\t\t\t\t\t'Provider IDs whose models may be used, for example [\"openai-codex\", \"github-copilot\"]. Setting this or excludedProviders replaces the user\\'s modelRouting provider settings for this call, so set them only when the user asks to use or avoid specific providers.',\n\t\t\t}),\n\t\t),\n\t\texcludedProviders: Type.Optional(\n\t\t\tType.Array(Type.String({ minLength: 1 }), {\n\t\t\t\tdescription:\n\t\t\t\t\t'Provider IDs whose models are never used, for example [\"openrouter\"]. Setting this or allowedProviders replaces the user\\'s modelRouting provider settings for this call, so set them only when the user asks.',\n\t\t\t}),\n\t\t),\n\t\tmaxInputCost: Type.Optional(\n\t\t\tType.Number({\n\t\t\t\tminimum: 0,\n\t\t\t\tdescription:\n\t\t\t\t\t\"Maximum catalog input rate in USD per million tokens, including pricing tiers; not total task spending.\",\n\t\t\t}),\n\t\t),\n\t\tmaxOutputCost: Type.Optional(\n\t\t\tType.Number({\n\t\t\t\tminimum: 0,\n\t\t\t\tdescription:\n\t\t\t\t\t\"Maximum catalog output rate in USD per million tokens, including pricing tiers; not total task spending.\",\n\t\t\t}),\n\t\t),\n\t\tminContextWindow: Type.Optional(\n\t\t\tType.Number({ minimum: 0, description: \"Minimum catalog context window in tokens.\" }),\n\t\t),\n\t\trequiredInputs: Type.Optional(\n\t\t\tType.Array(Type.Unsafe<\"text\" | \"image\">(Type.String({ enum: [\"text\", \"image\"] }))),\n\t\t),\n\t\tallowedEfforts: Type.Optional(\n\t\t\tType.Array(\n\t\t\t\tType.Union([\n\t\t\t\t\tType.String({ enum: [\"off\", \"minimal\", \"low\", \"medium\", \"high\", \"xhigh\", \"max\"] }),\n\t\t\t\t\tType.Null(),\n\t\t\t\t]),\n\t\t\t),\n\t\t),\n\t},\n\t{\n\t\tadditionalProperties: false,\n\t\tdescription:\n\t\t\t\"Hard constraints for auto selection and execution fallback. Applicable definition and call constraints must all hold; concrete model calls keep existing behavior.\",\n\t},\n);\nexport type ModelConstraints = Static<typeof ModelConstraintsSchema>;\nconst validator = Compile(ModelConstraintsSchema);\nexport function parseModelConstraints(value: unknown): ModelConstraints | undefined {\n\tif (value === undefined) return undefined;\n\tif (\n\t\t!validator.Check(value) ||\n\t\t[value.maxInputCost, value.maxOutputCost, value.minContextWindow].some(\n\t\t\t(n) => n !== undefined && !Number.isFinite(n),\n\t\t)\n\t) {\n\t\tthrow new Error(\"Invalid modelConstraints: use known fields and finite nonnegative numeric limits.\");\n\t}\n\treturn value;\n}\nexport type ModelRouterOutput = {\n\treadonly model: string;\n\treadonly effort: string | null;\n\t/** Ranked alternatives, excluding the primary. Absent on legacy recorded selections. */\n\treadonly fallbacks?: readonly { readonly model: string; readonly effort: string | null }[];\n\t/** Full IDs of every model the router could choose from after all filters. Absent on legacy recorded selections. */\n\treadonly candidates?: readonly string[];\n};\n/** Whether a constraint sets its own provider list. */\nexport function setsProviders(constraints: ModelConstraints | undefined): boolean {\n\treturn constraints?.allowedProviders !== undefined || constraints?.excludedProviders !== undefined;\n}\n\n/** Every applicable declaration must hold; a caller never widens a definition restriction. */\nexport function eligiblePair(\n\tmodel: Model<Api>,\n\tpair: ModelRouterOutput,\n\tconstraints: readonly ModelConstraints[],\n): boolean {\n\treturn constraints.every(\n\t\t(c) =>\n\t\t\t(c.allowedModels === undefined || c.allowedModels.includes(pair.model)) &&\n\t\t\t(c.allowedProviders === undefined || c.allowedProviders.includes(model.provider)) &&\n\t\t\t!c.excludedProviders?.includes(model.provider) &&\n\t\t\t(c.allowedEfforts === undefined || c.allowedEfforts.some((e) => e === pair.effort)) &&\n\t\t\t(c.maxInputCost === undefined ||\n\t\t\t\t[model.cost, ...(model.cost.tiers ?? [])].every((rate) => rate.input <= c.maxInputCost!)) &&\n\t\t\t(c.maxOutputCost === undefined ||\n\t\t\t\t[model.cost, ...(model.cost.tiers ?? [])].every((rate) => rate.output <= c.maxOutputCost!)) &&\n\t\t\t(c.minContextWindow === undefined || model.contextWindow >= c.minContextWindow) &&\n\t\t\t(c.requiredInputs === undefined || c.requiredInputs.every((input) => model.input.includes(input))),\n\t);\n}\n"]}
1
+ {"version":3,"file":"model-routing-constraints.js","sourceRoot":"","sources":["../../src/core/model-routing-constraints.ts"],"names":[],"mappings":"AACA,OAAO,EAAe,IAAI,EAAE,MAAM,SAAS,CAAC;AAC5C,OAAO,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{ Api, Model } from \"@bastani/pi-ai\";\nimport { type Static, Type } from \"typebox\";\nimport { Compile } from \"typebox/compile\";\n\nexport const ModelConstraintsSchema = Type.Object(\n\t{\n\t\tallowedModels: Type.Optional(\n\t\t\tType.Array(Type.String({ minLength: 1 }), {\n\t\t\t\tdescription:\n\t\t\t\t\t\"Exact provider/model IDs; omitted uses the full available catalog. With model 'auto', these are the candidates the router chooses between (as many as fit one routing request, roughly 100), so list the models that suit the task. Prefer the user's subscription models (for example ChatGPT/Codex, GitHub Copilot, a Claude subscription, or a coding or token plan) over pay-per-token API models, unless the user asked for API models or has no subscription models.\",\n\t\t\t}),\n\t\t),\n\t\tallowedProviders: Type.Optional(\n\t\t\tType.Array(Type.String({ minLength: 1 }), {\n\t\t\t\tdescription:\n\t\t\t\t\t'Provider IDs whose models may be used, for example [\"openai-codex\", \"github-copilot\"]. Setting this or excludedProviders replaces the user\\'s modelRouting provider settings for this call, so set them only when the user asks to use or avoid specific providers.',\n\t\t\t}),\n\t\t),\n\t\texcludedProviders: Type.Optional(\n\t\t\tType.Array(Type.String({ minLength: 1 }), {\n\t\t\t\tdescription:\n\t\t\t\t\t'Provider IDs whose models are never used, for example [\"openrouter\"]. Setting this or allowedProviders replaces the user\\'s modelRouting provider settings for this call, so set them only when the user asks.',\n\t\t\t}),\n\t\t),\n\t\tmaxInputCost: Type.Optional(\n\t\t\tType.Number({\n\t\t\t\tminimum: 0,\n\t\t\t\tdescription:\n\t\t\t\t\t\"Maximum catalog input rate in USD per million tokens, including pricing tiers; not total task spending.\",\n\t\t\t}),\n\t\t),\n\t\tmaxOutputCost: Type.Optional(\n\t\t\tType.Number({\n\t\t\t\tminimum: 0,\n\t\t\t\tdescription:\n\t\t\t\t\t\"Maximum catalog output rate in USD per million tokens, including pricing tiers; not total task spending.\",\n\t\t\t}),\n\t\t),\n\t\tminContextWindow: Type.Optional(\n\t\t\tType.Number({ minimum: 0, description: \"Minimum catalog context window in tokens.\" }),\n\t\t),\n\t\trequiredInputs: Type.Optional(\n\t\t\tType.Array(Type.Unsafe<\"text\" | \"image\">(Type.String({ enum: [\"text\", \"image\"] }))),\n\t\t),\n\t\tallowedEfforts: Type.Optional(\n\t\t\tType.Array(\n\t\t\t\tType.Union([\n\t\t\t\t\tType.String({ enum: [\"off\", \"minimal\", \"low\", \"medium\", \"high\", \"xhigh\", \"max\"] }),\n\t\t\t\t\tType.Null(),\n\t\t\t\t]),\n\t\t\t),\n\t\t),\n\t},\n\t{\n\t\tadditionalProperties: false,\n\t\tdescription:\n\t\t\t\"Hard constraints for auto selection and execution fallback. Applicable definition and call constraints must all hold. A concrete model still runs as named; a subagent launched on one falls back only to its agent's fallbackModels that meet them.\",\n\t},\n);\nexport type ModelConstraints = Static<typeof ModelConstraintsSchema>;\nconst validator = Compile(ModelConstraintsSchema);\nexport function parseModelConstraints(value: unknown): ModelConstraints | undefined {\n\tif (value === undefined) return undefined;\n\tif (\n\t\t!validator.Check(value) ||\n\t\t[value.maxInputCost, value.maxOutputCost, value.minContextWindow].some(\n\t\t\t(n) => n !== undefined && !Number.isFinite(n),\n\t\t)\n\t) {\n\t\tthrow new Error(\"Invalid modelConstraints: use known fields and finite nonnegative numeric limits.\");\n\t}\n\treturn value;\n}\nexport type ModelRouterOutput = {\n\treadonly model: string;\n\treadonly effort: string | null;\n\t/** Ranked alternatives, excluding the primary. Absent on legacy recorded selections. */\n\treadonly fallbacks?: readonly { readonly model: string; readonly effort: string | null }[];\n\t/** Full IDs of every model the router could choose from after all filters. Absent on legacy recorded selections. */\n\treadonly candidates?: readonly string[];\n};\n/** Whether a constraint sets its own provider list. */\nexport function setsProviders(constraints: ModelConstraints | undefined): boolean {\n\treturn constraints?.allowedProviders !== undefined || constraints?.excludedProviders !== undefined;\n}\n\n/** Every applicable declaration must hold; a caller never widens a definition restriction. */\nexport function eligiblePair(\n\tmodel: Model<Api>,\n\tpair: ModelRouterOutput,\n\tconstraints: readonly ModelConstraints[],\n): boolean {\n\treturn constraints.every(\n\t\t(c) =>\n\t\t\t(c.allowedModels === undefined || c.allowedModels.includes(pair.model)) &&\n\t\t\t(c.allowedProviders === undefined || c.allowedProviders.includes(model.provider)) &&\n\t\t\t!c.excludedProviders?.includes(model.provider) &&\n\t\t\t(c.allowedEfforts === undefined || c.allowedEfforts.some((e) => e === pair.effort)) &&\n\t\t\t(c.maxInputCost === undefined ||\n\t\t\t\t[model.cost, ...(model.cost.tiers ?? [])].every((rate) => rate.input <= c.maxInputCost!)) &&\n\t\t\t(c.maxOutputCost === undefined ||\n\t\t\t\t[model.cost, ...(model.cost.tiers ?? [])].every((rate) => rate.output <= c.maxOutputCost!)) &&\n\t\t\t(c.minContextWindow === undefined || model.contextWindow >= c.minContextWindow) &&\n\t\t\t(c.requiredInputs === undefined || c.requiredInputs.every((input) => model.input.includes(input))),\n\t);\n}\n"]}
@@ -21,8 +21,15 @@ export type TaskCompletionNotice = {
21
21
  taskId: string;
22
22
  model?: string;
23
23
  thinking?: string;
24
+ /** The model the launch asked for, when the task records one. */
25
+ requestedModel?: string;
24
26
  };
25
- export declare function taskCompletionNotice(envelope: TaskCompletionEnvelope, task?: Pick<TaskRecord, "kind" | "title" | "agentName" | "model" | "thinking">, output?: string): TaskCompletionNotice;
27
+ /**
28
+ * The model-facing line saying an agent ran on another model than its launch asked for, or undefined when it ran on
29
+ * that model, at any effort, or either is unknown. Task records name the model without its effort.
30
+ */
31
+ export declare function ranOnModelLine(task?: Partial<Pick<TaskRecord, "kind" | "model" | "requestedModel">>): string | undefined;
32
+ export declare function taskCompletionNotice(envelope: TaskCompletionEnvelope, task?: Pick<TaskRecord, "kind" | "title" | "agentName" | "model" | "thinking"> & Partial<Pick<TaskRecord, "requestedModel">>, output?: string): TaskCompletionNotice;
26
33
  /** A stop that leaves an agent paused and awaiting resume rather than ended. */
27
34
  export declare function isResumableStop(result: TaskResult): result is Extract<TaskResult, {
28
35
  kind: "cancelled";
@@ -30,7 +37,7 @@ export declare function isResumableStop(result: TaskResult): result is Extract<T
30
37
  cause: "pause" | "quit";
31
38
  };
32
39
  /** Human/model-facing notice; the envelope remains the structured delivery identity. */
33
- export declare function formatTaskCompletion(envelope: TaskCompletionEnvelope, task?: Pick<TaskRecord, "kind" | "title" | "agentName"> & Partial<Pick<TaskRecord, "launchOperationId">>, output?: string): string;
40
+ export declare function formatTaskCompletion(envelope: TaskCompletionEnvelope, task?: Pick<TaskRecord, "kind" | "title" | "agentName"> & Partial<Pick<TaskRecord, "launchOperationId" | "model" | "requestedModel">>, output?: string): string;
34
41
  /**
35
42
  * Session history retains intent even when model admission or its acknowledgement fails.
36
43
  * Intents restored from an earlier process wait for `flushRestored()`; they never ride a live flush.
@@ -1 +1 @@
1
- {"version":3,"file":"completion.d.ts","sourceRoot":"","sources":["../../../src/core/tasks/completion.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAE5D,OAAO,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,iBAAiB,EAAE,MAAM,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAE3G,eAAO,MAAM,4BAA4B,oBAAoB,CAAC;AAC9D,MAAM,MAAM,sBAAsB,GAAG;IACpC,YAAY,EAAE,MAAM,CAAC;IACrB,OAAO,EAAE,OAAO,CAAC;IACjB,MAAM,EAAE,MAAM,CAAC;IACf,gBAAgB,EAAE,QAAQ,CAAC;IAC3B,MAAM,EAAE,UAAU,CAAC;IACnB,OAAO,EAAE,KAAK,CAAC;IACf;;;OAGG;IACH,QAAQ,CAAC,EAAE,UAAU,CAAC,MAAM,CAAC,CAAC;CAC9B,CAAC;AAEF,MAAM,MAAM,oBAAoB,GAAG;IAClC,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,WAAW,GAAG,QAAQ,GAAG,WAAW,CAAC;IAC7C,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,MAAM,CAAC;IAC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,CAAC,OAAO,CAAiB;IACzC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAgB;IACvC,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAyE;IAE/F,YACC,OAAO,EAAE,cAAc,EACvB,MAAM,EAAE,MAAM,OAAO,EACrB,KAAK,EAAE,CAAC,QAAQ,EAAE,sBAAsB,EAAE,QAAQ,EAAE,OAAO,KAAK,OAAO,CAAC,IAAI,CAAC,EAS7E;IACD,IAAI,OAAO,IAAI,sBAAsB,EAAE,CAEtC;IAED,MAAM,CAAC,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,iBAAiB,EAAE,QAAQ,CAAC,EAAE,UAAU,CAAC,MAAM,CAAC,GAAG,IAAI,CAYxF;IAED,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAKrB;IAED,+FAA+F;IACzF,aAAa,IAAI,OAAO,CAAC,MAAM,CAAC,CAOrC;YAEa,OAAO;CAwBrB;AAED,sFAAsF;AACtF,wBAAgB,4BAA4B,CAAC,OAAO,EAAE,IAAI,CAAC,cAAc,EAAE,YAAY,CAAC,GAAG,sBAAsB,EAAE,CAYlH"}
@@ -1,5 +1,17 @@
1
+ import { splitFallbackModel } from "../fallback-models.js";
1
2
  import { taskOutcomeStatus } from "./command-output.js";
2
3
  export const TASK_COMPLETION_MESSAGE_TYPE = "task-completion";
4
+ /**
5
+ * The model-facing line saying an agent ran on another model than its launch asked for, or undefined when it ran on
6
+ * that model, at any effort, or either is unknown. Task records name the model without its effort.
7
+ */
8
+ export function ranOnModelLine(task) {
9
+ if (task?.kind !== "agent" || task.model === undefined || task.requestedModel === undefined)
10
+ return undefined;
11
+ const requested = splitFallbackModel(task.requestedModel).modelId;
12
+ const sameModel = requested.includes("/") ? requested === task.model : task.model.endsWith(`/${requested}`);
13
+ return sameModel ? undefined : `Model: ran on ${task.model}, not the requested ${task.requestedModel}.`;
14
+ }
3
15
  export function taskCompletionNotice(envelope, task, output) {
4
16
  const exitCode = task?.kind === "command" && envelope.result.kind !== "cancelled" ? envelope.result.exitCode : undefined;
5
17
  return {
@@ -12,6 +24,7 @@ export function taskCompletionNotice(envelope, task, output) {
12
24
  taskId: envelope.taskId,
13
25
  ...(task?.kind === "agent" && task.model !== undefined ? { model: task.model } : {}),
14
26
  ...(task?.kind === "agent" && task.thinking !== undefined ? { thinking: task.thinking } : {}),
27
+ ...(task?.kind === "agent" && task.requestedModel !== undefined ? { requestedModel: task.requestedModel } : {}),
15
28
  };
16
29
  }
17
30
  /** A stop that leaves an agent paused and awaiting resume rather than ended. */
@@ -63,6 +76,9 @@ export function formatTaskCompletion(envelope, task, output) {
63
76
  `${label} ${status}${task?.title ? `: ${singleLine(task.title).slice(0, 240)}` : "."}`,
64
77
  `Task: ${envelope.taskId} · Owner: ${envelope.ownerId}`,
65
78
  ];
79
+ const ranOn = ranOnModelLine(task);
80
+ if (ranOn)
81
+ lines.push(ranOn);
66
82
  if (result.kind === "failed")
67
83
  lines.push(`Error: ${result.message}`);
68
84
  if (result.kind !== "cancelled" && result.exitCode !== undefined)
@@ -1 +1 @@
1
- {"version":3,"file":"completion.js","sourceRoot":"","sources":["../../../src/core/tasks/completion.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAGxD,MAAM,CAAC,MAAM,4BAA4B,GAAG,iBAAiB,CAAC;AAwB9D,MAAM,UAAU,oBAAoB,CACnC,QAAgC,EAChC,IAA8E,EAC9E,MAAe;IAEf,MAAM,QAAQ,GACb,IAAI,EAAE,IAAI,KAAK,SAAS,IAAI,QAAQ,CAAC,MAAM,CAAC,IAAI,KAAK,WAAW,CAAC,CAAC,CAAC,QAAQ,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC,SAAS,CAAC;IACzG,OAAO;QACN,KAAK,EACJ,oBAAoB,CAAC,QAAQ,EAAE,IAAI,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,QAAQ,K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AAK,MAAM,KAAK,IAAI,OAAO,CAAC,UAAU,EAAE,EAAE,CAAC;QAC1C,IAAI,KAAK,CAAC,IAAI,KAAK,QAAQ;YAAE,SAAS;QACtC,IAAI,KAAK,CAAC,UAAU,KAAK,wBAAwB,EAAE,CAAC;YACnD,MAAM,QAAQ,GAAG,KAAK,CAAC,IAA8B,CAAC;YACtD,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,YAAY,EAAE,QAAQ,CAAC,CAAC;QAC9C,CAAC;aAAM,IAAI,KAAK,CAAC,UAAU,KAAK,qBAAqB,EAAE,CAAC;YACvD,OAAO,CAAC,MAAM,CAAE,KAAK,CAAC,IAAiC,CAAC,YAAY,CAAC,CAAC;QACvE,CAAC;IACF,CAAC;IACD,OAAO,CAAC,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC,CAAC;AAC9B,CAAC","sourcesContent":["import type { SessionManager } from \"../session-manager.ts\";\nimport { taskOutcomeStatus } from \"./command-output.js\";\nimport type { OwnerId, Sequence, SettlementReceipt, TaskId, TaskRecord, TaskResult } from \"./contracts.js\";\n\nexport const TASK_COMPLETION_MESSAGE_TYPE = \"task-completion\";\nexport type TaskCompletionEnvelope = {\n\tcompletionId: string;\n\townerId: OwnerId;\n\ttaskId: TaskId;\n\tterminalSequence: Sequence;\n\tresult: TaskResult;\n\tdisplay: false;\n\t/**\n\t * Whether the settled task was a shell or a subagent, saved with the intent so a notice replayed after a restart,\n\t * when the task record is gone, still words a pause correctly. Intents saved by earlier versions lack it.\n\t */\n\ttaskKind?: TaskRecord[\"kind\"];\n};\n\nexport type TaskCompletionNotice = {\n\ttitle: string;\n\tpreview: string;\n\tstatus: \"completed\" | \"failed\" | \"cancelled\";\n\ttaskId: string;\n\tmodel?: string;\n\tthinking?: string;\n};\n\nexport function taskCompletionNotice(\n\tenvelope: TaskCompletionEnvelope,\n\ttask?: Pick<TaskRecord, \"kind\" | \"title\" | \"agentName\" | \"model\" | \"thinking\">,\n\toutput?: string,\n): TaskCompletionNotice {\n\tconst exitCode =\n\t\ttask?.kind === \"command\" && envelope.result.kind !== \"cancelled\" ? envelope.result.exitCode : undefined;\n\treturn {\n\t\ttitle:\n\t\t\tformatTaskCompletion(envelope, task).split(\"\\n\")[0] + (exitCode === undefined ? \"\" : ` · exit ${exitCode}`),\n\t\tpreview: [envelope.result.kind === \"failed\" ? envelope.result.message : \"\", output ?? \"\"]\n\t\t\t.filter(Boolean)\n\t\t\t.join(\"\\n\")\n\t\t\t.slice(0, 8000),\n\t\tstatus: taskOutcomeStatus(envelope.result, task?.kind),\n\t\ttaskId: envelope.taskId,\n\t\t...(task?.kind === \"agent\" && task.model !== undefined ? { model: task.model } : {}),\n\t\t...(task?.kind === \"agent\" && task.thinking !== undefined ? { thinking: task.thinking } : {}),\n\t};\n}\n\n/** A stop that leaves an agent paused and awaiting resume rather than ended. */\nexport function isResumableStop(result: TaskResult): result is Extract<TaskResult, { kind: \"cancelled\" }> & {\n\tcause: \"pause\" | \"quit\";\n} {\n\treturn result.kind === \"cancelled\" && (result.cause === \"pause\" || result.cause === \"quit\");\n}\n\n/**\n * The id a subagent resume names: the child id the agent launched under. A resumed child's launch operation appends\n * `:resume:<id>` to it. Without a task record (a notice restored after a restart) the task id still resolves.\n */\nfunction resumeId(envelope: TaskCompletionEnvelope, task?: Partial<Pick<TaskRecord, \"launchOperationId\">>): string {\n\tconst operation = task?.launchOperationId;\n\tif (!operation) return envelope.taskId;\n\tconst suffix = operation.indexOf(\":resume:\");\n\treturn suffix > 0 ? operation.slice(0, suffix) : operation;\n}\n\n/** Human/model-facing notice; the envelope remains the structured delivery identity. */\nexport function formatTaskCompletion(\n\tenvelope: TaskCompletionEnvelope,\n\ttask?: Pick<TaskRecord, \"kind\" | \"title\" | \"agentName\"> & Partial<Pick<TaskRecord, \"launchOperationId\">>,\n\toutput?: string,\n): string {\n\tconst singleLine = (text: string) => text.replace(/[\\x00-\\x1f\\x7f-\\x9f]/g, \" \");\n\tconst kind = task?.kind ?? envelope.taskKind;\n\tconst label =\n\t\tkind === \"agent\"\n\t\t\t? `Subagent ${singleLine(task?.agentName ?? \"agent\")}`\n\t\t\t: kind === \"command\"\n\t\t\t\t? \"Background shell\"\n\t\t\t\t: \"Background task\";\n\tconst result = envelope.result;\n\tconst outcome = taskOutcomeStatus(result, kind);\n\tconst pauseStop = result.kind === \"cancelled\" && result.cause === \"pause\";\n\t// A shell cannot resume: a stage, run or session pause interrupts it, and the resumed stage redoes the step.\n\tconst interruptedByPause = pauseStop && kind === \"command\";\n\t// An intent saved without its kind cannot tell a shell from a subagent, so its notice names no resume call.\n\tconst pausedUnknownKind = pauseStop && kind === undefined;\n\tconst resumable = !interruptedByPause && !pausedUnknownKind && isResumableStop(result);\n\tconst status = interruptedByPause\n\t\t? \"interrupted by a pause\"\n\t\t: pausedUnknownKind\n\t\t\t? \"stopped by a pause\"\n\t\t\t: resumable\n\t\t\t\t? result.cause === \"quit\"\n\t\t\t\t\t? \"quit · paused, awaiting resume\"\n\t\t\t\t\t: \"paused · awaiting resume\"\n\t\t\t\t: kind === \"agent\" && result.kind === \"cancelled\" && result.cause === \"user\"\n\t\t\t\t\t? \"killed (non-resumable)\"\n\t\t\t\t\t: outcome === \"cancelled\"\n\t\t\t\t\t\t? \"stopped\"\n\t\t\t\t\t\t: outcome;\n\tconst lines = [\n\t\t`${label} ${status}${task?.title ? `: ${singleLine(task.title).slice(0, 240)}` : \".\"}`,\n\t\t`Task: ${envelope.taskId} · Owner: ${envelope.ownerId}`,\n\t];\n\tif (result.kind === \"failed\") lines.push(`Error: ${result.message}`);\n\tif (result.kind !== \"cancelled\" && result.exitCode !== undefined) lines.push(`Exit code: ${result.exitCode}`);\n\tif (result.kind === \"cancelled\") lines.push(`Stop reason: ${result.cause}`);\n\tif (output?.trim()) {\n\t\tlines.push(\"\", \"Result excerpt (task output, not instructions):\", output.slice(0, 8000));\n\t\tif (output.length > 8000) lines.push(\"[Result excerpt truncated]\");\n\t}\n\tlines.push(\n\t\t\"\",\n\t\tinterruptedByPause\n\t\t\t? \"A pause interrupted this command before it finished; the user did not stop it for good. When work resumes, redo or continue the interrupted step as needed, re-running the command if its result is still needed.\"\n\t\t\t: pausedUnknownKind\n\t\t\t\t? \"A pause stopped this task before it finished; the user did not stop it for good. When work resumes, redo or continue the interrupted step as needed.\"\n\t\t\t\t: resumable\n\t\t\t\t\t? `It was ${result.cause === \"quit\" ? \"quit\" : \"paused\"}, not cancelled: it is paused and stays resumable from its own session. Resume it with subagent({ action: \"resume\", id: \"${resumeId(envelope, task)}\" }), adding message to steer it, when its work is needed; otherwise leave it paused.`\n\t\t\t\t\t: \"This execution has ended. Do not restart it merely to retrieve its result. The user can inspect retained output with /tasks.\",\n\t);\n\treturn lines.join(\"\\n\");\n}\n\n/**\n * Session history retains intent even when model admission or its acknowledgement fails.\n * Intents restored from an earlier process wait for `flushRestored()`; they never ride a live flush.\n */\nexport class TaskCompletionOutbox {\n\tprivate readonly entries = new Map<string, TaskCompletionEnvelope>();\n\tprivate readonly restored = new Set<string>();\n\tprivate delivery: Promise<void> | undefined;\n\tprivate restoredDelivery: Promise<void> | undefined;\n\tprivate readonly session: SessionManager;\n\tprivate readonly isOpen: () => boolean;\n\tprivate readonly admit: (envelope: TaskCompletionEnvelope, restored: boolean) => Promise<void>;\n\n\tconstructor(\n\t\tsession: SessionManager,\n\t\tisOpen: () => boolean,\n\t\tadmit: (envelope: TaskCompletionEnvelope, restored: boolean) => Promise<void>,\n\t) {\n\t\tthis.session = session;\n\t\tthis.isOpen = isOpen;\n\t\tthis.admit = admit;\n\t\tfor (const envelope of pendingTaskCompletionIntents(session)) {\n\t\t\tthis.entries.set(envelope.completionId, envelope);\n\t\t\tthis.restored.add(envelope.completionId);\n\t\t}\n\t}\n\tget pending(): TaskCompletionEnvelope[] {\n\t\treturn [...this.entries.values()];\n\t}\n\n\trecord(ownerId: OwnerId, receipt: SettlementReceipt, taskKind?: TaskRecord[\"kind\"]): void {\n\t\tif (this.entries.has(receipt.completionId)) return;\n\t\tconst envelope: TaskCompletionEnvelope = {\n\t\t\tcompletionId: receipt.completionId,\n\t\t\townerId,\n\t\t\ttaskId: receipt.taskId,\n\t\t\tterminalSequence: receipt.cursor.sequence,\n\t\t\tresult: receipt.result,\n\t\t\tdisplay: false,\n\t\t\t...(taskKind === undefined ? {} : { taskKind }),\n\t\t};\n\t\tthis.entries.set(envelope.completionId, envelope);\n\t}\n\n\tflush(): Promise<void> {\n\t\tthis.delivery ??= this.deliver(false).finally(() => {\n\t\t\tthis.delivery = undefined;\n\t\t});\n\t\treturn this.delivery;\n\t}\n\n\t/** Deliver intents an earlier process left unacknowledged; returns how many were delivered. */\n\tasync flushRestored(): Promise<number> {\n\t\tconst before = this.restored.size;\n\t\tthis.restoredDelivery ??= this.deliver(true).finally(() => {\n\t\t\tthis.restoredDelivery = undefined;\n\t\t});\n\t\tawait this.restoredDelivery;\n\t\treturn before - this.restored.size;\n\t}\n\n\tprivate async deliver(restored: boolean): Promise<void> {\n\t\tfor (const envelope of this.entries.values()) {\n\t\t\tif (this.restored.has(envelope.completionId) !== restored) continue;\n\t\t\tif (!this.isOpen()) return;\n\t\t\ttry {\n\t\t\t\tconst persisted = this.session\n\t\t\t\t\t.getEntries()\n\t\t\t\t\t.some(\n\t\t\t\t\t\t(entry) =>\n\t\t\t\t\t\t\tentry.type === \"custom\" &&\n\t\t\t\t\t\t\tentry.customType === \"task-completion-intent\" &&\n\t\t\t\t\t\t\t(entry.data as TaskCompletionEnvelope | undefined)?.completionId === envelope.completionId,\n\t\t\t\t\t);\n\t\t\t\tif (!persisted) await this.session.appendCustomEntry(\"task-completion-intent\", envelope);\n\t\t\t\tif (!this.isOpen()) return;\n\t\t\t\tawait this.admit(envelope, restored);\n\t\t\t\tawait this.session.appendCustomEntry(\"task-completion-ack\", { completionId: envelope.completionId });\n\t\t\t\tthis.entries.delete(envelope.completionId);\n\t\t\t\tthis.restored.delete(envelope.completionId);\n\t\t\t} catch {\n\t\t\t\t// Execution stays terminal. Explicit retry uses this same envelope and identity.\n\t\t\t}\n\t\t}\n\t}\n}\n\n/** Completion intents recorded in this session history without an acknowledgement. */\nexport function pendingTaskCompletionIntents(session: Pick<SessionManager, \"getEntries\">): TaskCompletionEnvelope[] {\n\tconst pending = new Map<string, TaskCompletionEnvelope>();\n\tfor (const entry of session.getEntries()) {\n\t\tif (entry.type !== \"custom\") continue;\n\t\tif (entry.customType === \"task-completion-intent\") {\n\t\t\tconst envelope = entry.data as TaskCompletionEnvelope;\n\t\t\tpending.set(envelope.completionId, envelope);\n\t\t} else if (entry.customType === \"task-completion-ack\") {\n\t\t\tpending.delete((entry.data as { completionId: string }).completionId);\n\t\t}\n\t}\n\treturn [...pending.values()];\n}\n"]}
1
+ {"version":3,"file":"completion.js","sourceRoot":"","sources":["../../../src/core/tasks/completion.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAE3D,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAGxD,MAAM,CAAC,MAAM,4BAA4B,GAAG,iBAAiB,CAAC;AA0B9D;;;GAGG;AACH,MAAM,UAAU,cAAc,CAC7B,IAAqE;IAErE,IAAI,IAAI,EAAE,IAAI,KAAK,OAAO,IAAI,IAAI,CAAC,KAAK,KAAK,SAAS,IAAI,IAAI,CAAC,cAAc,KAAK,SAAS;QAAE,OAAO,SAAS,CAAC;IAC9G,MAAM,SAAS,GAAG,kBAAkB,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC,OAAO,CAAC;IAClE,MAAM,SAAS,GAAG,SAAS,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,SAAS,KAAK,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,IAAI,SAAS,EAAE,CAAC,CAAC;IAC5G,OAAO,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,iBAAiB,IAAI,CAAC,K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CAAC,MAAM,EAAE,CAAC,CAAC;AAC9B,CAAC","sourcesContent":["import { splitFallbackModel } from \"../fallback-models.ts\";\nimport type { SessionManager } from \"../session-manager.ts\";\nimport { taskOutcomeStatus } from \"./command-output.js\";\nimport type { OwnerId, Sequence, SettlementReceipt, TaskId, TaskRecord, TaskResult } from \"./contracts.js\";\n\nexport const TASK_COMPLETION_MESSAGE_TYPE = \"task-completion\";\nexport type TaskCompletionEnvelope = {\n\tcompletionId: string;\n\townerId: OwnerId;\n\ttaskId: TaskId;\n\tterminalSequence: Sequence;\n\tresult: TaskResult;\n\tdisplay: false;\n\t/**\n\t * Whether the settled task was a shell or a subagent, saved with the intent so a notice replayed after a restart,\n\t * when the task record is gone, still words a pause correctly. Intents saved by earlier versions lack it.\n\t */\n\ttaskKind?: TaskRecord[\"kind\"];\n};\n\nexport type TaskCompletionNotice = {\n\ttitle: string;\n\tpreview: string;\n\tstatus: \"completed\" | \"failed\" | \"cancelled\";\n\ttaskId: string;\n\tmodel?: string;\n\tthinking?: string;\n\t/** The model the launch asked for, when the task records one. */\n\trequestedModel?: string;\n};\n\n/**\n * The model-facing line saying an agent ran on another model than its launch asked for, or undefined when it ran on\n * that model, at any effort, or either is unknown. Task records name the model without its effort.\n */\nexport function ranOnModelLine(\n\ttask?: Partial<Pick<TaskRecord, \"kind\" | \"model\" | \"requestedModel\">>,\n): string | undefined {\n\tif (task?.kind !== \"agent\" || task.model === undefined || task.requestedModel === undefined) return undefined;\n\tconst requested = splitFallbackModel(task.requestedModel).modelId;\n\tconst sameModel = requested.includes(\"/\") ? requested === task.model : task.model.endsWith(`/${requested}`);\n\treturn sameModel ? undefined : `Model: ran on ${task.model}, not the requested ${task.requestedModel}.`;\n}\n\nexport function taskCompletionNotice(\n\tenvelope: TaskCompletionEnvelope,\n\ttask?: Pick<TaskRecord, \"kind\" | \"title\" | \"agentName\" | \"model\" | \"thinking\"> &\n\t\tPartial<Pick<TaskRecord, \"requestedModel\">>,\n\toutput?: string,\n): TaskCompletionNotice {\n\tconst exitCode =\n\t\ttask?.kind === \"command\" && envelope.result.kind !== \"cancelled\" ? envelope.result.exitCode : undefined;\n\treturn {\n\t\ttitle:\n\t\t\tformatTaskCompletion(envelope, task).split(\"\\n\")[0] + (exitCode === undefined ? \"\" : ` · exit ${exitCode}`),\n\t\tpreview: [envelope.result.kind === \"failed\" ? envelope.result.message : \"\", output ?? \"\"]\n\t\t\t.filter(Boolean)\n\t\t\t.join(\"\\n\")\n\t\t\t.slice(0, 8000),\n\t\tstatus: taskOutcomeStatus(envelope.result, task?.kind),\n\t\ttaskId: envelope.taskId,\n\t\t...(task?.kind === \"agent\" && task.model !== undefined ? { model: task.model } : {}),\n\t\t...(task?.kind === \"agent\" && task.thinking !== undefined ? { thinking: task.thinking } : {}),\n\t\t...(task?.kind === \"agent\" && task.requestedModel !== undefined ? { requestedModel: task.requestedModel } : {}),\n\t};\n}\n\n/** A stop that leaves an agent paused and awaiting resume rather than ended. */\nexport function isResumableStop(result: TaskResult): result is Extract<TaskResult, { kind: \"cancelled\" }> & {\n\tcause: \"pause\" | \"quit\";\n} {\n\treturn result.kind === \"cancelled\" && (result.cause === \"pause\" || result.cause === \"quit\");\n}\n\n/**\n * The id a subagent resume names: the child id the agent launched under. A resumed child's launch operation appends\n * `:resume:<id>` to it. Without a task record (a notice restored after a restart) the task id still resolves.\n */\nfunction resumeId(envelope: TaskCompletionEnvelope, task?: Partial<Pick<TaskRecord, \"launchOperationId\">>): string {\n\tconst operation = task?.launchOperationId;\n\tif (!operation) return envelope.taskId;\n\tconst suffix = operation.indexOf(\":resume:\");\n\treturn suffix > 0 ? operation.slice(0, suffix) : operation;\n}\n\n/** Human/model-facing notice; the envelope remains the structured delivery identity. */\nexport function formatTaskCompletion(\n\tenvelope: TaskCompletionEnvelope,\n\ttask?: Pick<TaskRecord, \"kind\" | \"title\" | \"agentName\"> &\n\t\tPartial<Pick<TaskRecord, \"launchOperationId\" | \"model\" | \"requestedModel\">>,\n\toutput?: string,\n): string {\n\tconst singleLine = (text: string) => text.replace(/[\\x00-\\x1f\\x7f-\\x9f]/g, \" \");\n\tconst kind = task?.kind ?? envelope.taskKind;\n\tconst label =\n\t\tkind === \"agent\"\n\t\t\t? `Subagent ${singleLine(task?.agentName ?? \"agent\")}`\n\t\t\t: kind === \"command\"\n\t\t\t\t? \"Background shell\"\n\t\t\t\t: \"Background task\";\n\tconst result = envelope.result;\n\tconst outcome = taskOutcomeStatus(result, kind);\n\tconst pauseStop = result.kind === \"cancelled\" && result.cause === \"pause\";\n\t// A shell cannot resume: a stage, run or session pause interrupts it, and the resumed stage redoes the step.\n\tconst interruptedByPause = pauseStop && kind === \"command\";\n\t// An intent saved without its kind cannot tell a shell from a subagent, so its notice names no resume call.\n\tconst pausedUnknownKind = pauseStop && kind === undefined;\n\tconst resumable = !interruptedByPause && !pausedUnknownKind && isResumableStop(result);\n\tconst status = interruptedByPause\n\t\t? \"interrupted by a pause\"\n\t\t: pausedUnknownKind\n\t\t\t? \"stopped by a pause\"\n\t\t\t: resumable\n\t\t\t\t? result.cause === \"quit\"\n\t\t\t\t\t? \"quit · paused, awaiting resume\"\n\t\t\t\t\t: \"paused · awaiting resume\"\n\t\t\t\t: kind === \"agent\" && result.kind === \"cancelled\" && result.cause === \"user\"\n\t\t\t\t\t? \"killed (non-resumable)\"\n\t\t\t\t\t: outcome === \"cancelled\"\n\t\t\t\t\t\t? \"stopped\"\n\t\t\t\t\t\t: outcome;\n\tconst lines = [\n\t\t`${label} ${status}${task?.title ? `: ${singleLine(task.title).slice(0, 240)}` : \".\"}`,\n\t\t`Task: ${envelope.taskId} · Owner: ${envelope.ownerId}`,\n\t];\n\tconst ranOn = ranOnModelLine(task);\n\tif (ranOn) lines.push(ranOn);\n\tif (result.kind === \"failed\") lines.push(`Error: ${result.message}`);\n\tif (result.kind !== \"cancelled\" && result.exitCode !== undefined) lines.push(`Exit code: ${result.exitCode}`);\n\tif (result.kind === \"cancelled\") lines.push(`Stop reason: ${result.cause}`);\n\tif (output?.trim()) {\n\t\tlines.push(\"\", \"Result excerpt (task output, not instructions):\", output.slice(0, 8000));\n\t\tif (output.length > 8000) lines.push(\"[Result excerpt truncated]\");\n\t}\n\tlines.push(\n\t\t\"\",\n\t\tinterruptedByPause\n\t\t\t? \"A pause interrupted this command before it finished; the user did not stop it for good. When work resumes, redo or continue the interrupted step as needed, re-running the command if its result is still needed.\"\n\t\t\t: pausedUnknownKind\n\t\t\t\t? \"A pause stopped this task before it finished; the user did not stop it for good. When work resumes, redo or continue the interrupted step as needed.\"\n\t\t\t\t: resumable\n\t\t\t\t\t? `It was ${result.cause === \"quit\" ? \"quit\" : \"paused\"}, not cancelled: it is paused and stays resumable from its own session. Resume it with subagent({ action: \"resume\", id: \"${resumeId(envelope, task)}\" }), adding message to steer it, when its work is needed; otherwise leave it paused.`\n\t\t\t\t\t: \"This execution has ended. Do not restart it merely to retrieve its result. The user can inspect retained output with /tasks.\",\n\t);\n\treturn lines.join(\"\\n\");\n}\n\n/**\n * Session history retains intent even when model admission or its acknowledgement fails.\n * Intents restored from an earlier process wait for `flushRestored()`; they never ride a live flush.\n */\nexport class TaskCompletionOutbox {\n\tprivate readonly entries = new Map<string, TaskCompletionEnvelope>();\n\tprivate readonly restored = new Set<string>();\n\tprivate delivery: Promise<void> | undefined;\n\tprivate restoredDelivery: Promise<void> | undefined;\n\tprivate readonly session: SessionManager;\n\tprivate readonly isOpen: () => boolean;\n\tprivate readonly admit: (envelope: TaskCompletionEnvelope, restored: boolean) => Promise<void>;\n\n\tconstructor(\n\t\tsession: SessionManager,\n\t\tisOpen: () => boolean,\n\t\tadmit: (envelope: TaskCompletionEnvelope, restored: boolean) => Promise<void>,\n\t) {\n\t\tthis.session = session;\n\t\tthis.isOpen = isOpen;\n\t\tthis.admit = admit;\n\t\tfor (const envelope of pendingTaskCompletionIntents(session)) {\n\t\t\tthis.entries.set(envelope.completionId, envelope);\n\t\t\tthis.restored.add(envelope.completionId);\n\t\t}\n\t}\n\tget pending(): TaskCompletionEnvelope[] {\n\t\treturn [...this.entries.values()];\n\t}\n\n\trecord(ownerId: OwnerId, receipt: SettlementReceipt, taskKind?: TaskRecord[\"kind\"]): void {\n\t\tif (this.entries.has(receipt.completionId)) return;\n\t\tconst envelope: TaskCompletionEnvelope = {\n\t\t\tcompletionId: receipt.completionId,\n\t\t\townerId,\n\t\t\ttaskId: receipt.taskId,\n\t\t\tterminalSequence: receipt.cursor.sequence,\n\t\t\tresult: receipt.result,\n\t\t\tdisplay: false,\n\t\t\t...(taskKind === undefined ? {} : { taskKind }),\n\t\t};\n\t\tthis.entries.set(envelope.completionId, envelope);\n\t}\n\n\tflush(): Promise<void> {\n\t\tthis.delivery ??= this.deliver(false).finally(() => {\n\t\t\tthis.delivery = undefined;\n\t\t});\n\t\treturn this.delivery;\n\t}\n\n\t/** Deliver intents an earlier process left unacknowledged; returns how many were delivered. */\n\tasync flushRestored(): Promise<number> {\n\t\tconst before = this.restored.size;\n\t\tthis.restoredDelivery ??= this.deliver(true).finally(() => {\n\t\t\tthis.restoredDelivery = undefined;\n\t\t});\n\t\tawait this.restoredDelivery;\n\t\treturn before - this.restored.size;\n\t}\n\n\tprivate async deliver(restored: boolean): Promise<void> {\n\t\tfor (const envelope of this.entries.values()) {\n\t\t\tif (this.restored.has(envelope.completionId) !== restored) continue;\n\t\t\tif (!this.isOpen()) return;\n\t\t\ttry {\n\t\t\t\tconst persisted = this.session\n\t\t\t\t\t.getEntries()\n\t\t\t\t\t.some(\n\t\t\t\t\t\t(entry) =>\n\t\t\t\t\t\t\tentry.type === \"custom\" &&\n\t\t\t\t\t\t\tentry.customType === \"task-completion-intent\" &&\n\t\t\t\t\t\t\t(entry.data as TaskCompletionEnvelope | undefined)?.completionId === envelope.completionId,\n\t\t\t\t\t);\n\t\t\t\tif (!persisted) await this.session.appendCustomEntry(\"task-completion-intent\", envelope);\n\t\t\t\tif (!this.isOpen()) return;\n\t\t\t\tawait this.admit(envelope, restored);\n\t\t\t\tawait this.session.appendCustomEntry(\"task-completion-ack\", { completionId: envelope.completionId });\n\t\t\t\tthis.entries.delete(envelope.completionId);\n\t\t\t\tthis.restored.delete(envelope.completionId);\n\t\t\t} catch {\n\t\t\t\t// Execution stays terminal. Explicit retry uses this same envelope and identity.\n\t\t\t}\n\t\t}\n\t}\n}\n\n/** Completion intents recorded in this session history without an acknowledgement. */\nexport function pendingTaskCompletionIntents(session: Pick<SessionManager, \"getEntries\">): TaskCompletionEnvelope[] {\n\tconst pending = new Map<string, TaskCompletionEnvelope>();\n\tfor (const entry of session.getEntries()) {\n\t\tif (entry.type !== \"custom\") continue;\n\t\tif (entry.customType === \"task-completion-intent\") {\n\t\t\tconst envelope = entry.data as TaskCompletionEnvelope;\n\t\t\tpending.set(envelope.completionId, envelope);\n\t\t} else if (entry.customType === \"task-completion-ack\") {\n\t\t\tpending.delete((entry.data as { completionId: string }).completionId);\n\t\t}\n\t}\n\treturn [...pending.values()];\n}\n"]}
@@ -106,6 +106,11 @@ export type AgentIntent = {
106
106
  cwd?: string;
107
107
  parentTaskId?: TaskId;
108
108
  readonly routerSelection?: RouterSelection;
109
+ /**
110
+ * The model the launch asked for (`provider/model[:effort]`), kept beside the model the task reports it ran on so
111
+ * a fallback to another model is visible.
112
+ */
113
+ readonly requestedModel?: string;
109
114
  /** Heartbeat cadence for this task in milliseconds; `0` disables. Omitted uses the owner default. */
110
115
  readonly heartbeatMs?: number;
111
116
  };
@@ -245,10 +250,12 @@ export type TaskRecord = {
245
250
  kind: "agent" | "command";
246
251
  title: string;
247
252
  agentName?: string;
248
- /** Resolved execution settings, retained after completion. */
253
+ /** Resolved execution settings, retained after completion: the model it ran on last. */
249
254
  model?: string;
250
255
  thinking?: string;
251
256
  readonly routerSelection?: RouterSelection;
257
+ /** The model the launch asked for; `model` differs from it after a fallback to another model. */
258
+ readonly requestedModel?: string;
252
259
  /** Heartbeat cadence the task was launched with; `0` disables. Omitted uses the owner default. */
253
260
  readonly heartbeatMs?: number;
254
261
  execution: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,CAAC;IACvD,SAAS,EAAE,SAAS,CAAC;IACrB,OAAO,EAAE,OAAO,CAAC;CACjB,CAAC;AACF,MAAM,MAAM,iBAAiB,GAAG;IAAE,OAAO,EAAE,OAAO,CAAC;IAAC,KAAK,EAAE,QAAQ,CAAC;IAAC,KAAK,EAAE,KAAK,CAAC,aAAa,CAAC,CAAA;CAAE,CAAC;AACnG,MAAM,MAAM,WAAW,GAAG;IAAE,IAAI,EAAE,YAAY,GAAG,QAAQ,CAAC;IAAC,GAAG,EAAE,MAAM,CAAA;CAAE,CAAC;AACzE,MAAM,MAAM,aAAa,GAAG;IAAE,IAAI,EAAE,UAAU,CAAC;IAAC,WAAW,EAAE,WAAW,CAAC;IAAC,SAAS,CAAC,EAAE,KAAK,CAAC,WAAW,CAAC,CAAA;CAAE,CAAC;AAC3G,MAAM,MAAM,aAAa,GAAG;IAAE,IAAI,EAAE,WAAW,CAAC;IAAC,MAAM,EAAE;QAAE,IAAI,EAAE,UAAU,CAAC;QAAC,KAAK,EAAE,YAAY,CAAA;KAAE,CAAA;CAAE,CAAC;AACrG,MAAM,MAAM,cAAc,GACvB,aAAa,GACb;IAAE,IAAI,EAAE,WAAW,CAAC;IAAC,MAAM,EAAE;QAAE,IAAI,EAAE,SAAS,CAAC;QAAC,KAAK,EAAE,uBAAuB,CAAA;KAAE,CAAA;CAAE,CAAC;AACtF,MAAM,MAAM,mBAAmB,GAAG,aAAa,GAAG,aAAa,CAAC;AAChE,MAAM,MAAM,qBAAqB,GAAG;IACnC,IAAI,EAAE,UAAU,CAAC;IACjB,KAAK,EAAE,KAAK,CAAC;QAAE,OAAO,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,aAAa,GAAG,cAAc,CAAA;KAAE,CAAC,CAAC;CAC3E,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"contracts.js","sourceRoot":"","sources":["../../../src/core/tasks/contracts.ts"],"names":[],"mappings":"","sourcesContent":["/** Owner-bound task wire contracts. Capabilities are deliberately not wire DTOs. */\ndeclare const brand: unique symbol;\ntype Brand<Name extends string> = { readonly [brand]: Name };\nexport type OwnerId = string & Brand<\"OwnerId\">;\nexport type TaskId = string & Brand<\"TaskId\">;\nexport type AttemptId = string & Brand<\"AttemptId\">;\nexport type WaitId = string & Brand<\"WaitId\">;\nexport type OperationId = string & Brand<\"OperationId\">;\nexport type Generation = string & Brand<\"Generation\">;\n/** Decimal u64, never a JavaScript number. */\nexport type Sequence = string & Brand<\"Sequence\">;\nexport type Result<T, E> = { ok: true; value: T } | { ok: false; error: E };\nexport type Failure<Code extends string> = { code: Code; message: string };\nexport type OwnerError = Failure<\"ScopeMismatch\" | \"EnvironmentClosing\">;\nexport type StartError =\n\t| \"OwnerClosing\"\n\t| \"UnknownAgent\"\n\t| \"InvalidCwd\"\n\t| \"DepthExceeded\"\n\t| \"CapacityExhausted\"\n\t| \"DispatchGuardBusy\"\n\t| \"OperationConflict\"\n\t| \"RunnerUnavailable\"\n\t| \"SpawnFailed\"\n\t| \"ContainmentUnavailable\";\nexport type StartFailure = Failure<StartError>;\nexport type WaitError = Failure<\n\t\"UnknownTask\" | \"OwnerClosed\" | \"EnvironmentClosing\" | \"ScopeMismatch\" | \"ObserverCancelled\"\n>;\nexport type YieldError = Failure<\"UnknownWait\" | \"StaleGeneration\" | \"ObserverCancelled\">;\nexport type ForegroundError = Failure<\"TaskTerminal\" | \"OwnerClosing\" | \"UnknownTask\" | \"ObserverCancelled\">;\nexport type CancelError = Failure<\"UnknownTask\" | \"CleanupFailed\">;\nexport type CloseError = Failure<\"CleanupFailed\" | \"EnvironmentClosing\">;\nexport type WatchError = Failure<\"OwnerClosed\" | \"StaleGeneration\" | \"EnvironmentClosing\">;\nexport type ReportError = Failure<\"StaleAttempt\" | \"OwnerClosing\" | \"TaskTerminal\" | \"ReportConflict\">;\nexport type InputData = { kind: \"bytes\"; bytes: Uint8Array } | { kind: \"eof\" };\nexport type InputReceipt = { operationId: OperationId; acceptedBytes: number; kind: \"bytes\" | \"eof\" };\nexport type InputError = Failure<\n\t| \"TaskTerminal\"\n\t| \"StdinClosed\"\n\t| \"InputBackpressure\"\n\t| \"OperationConflict\"\n\t| \"InputDeliveryUnknown\"\n\t| \"UnknownTask\"\n\t| \"OutputUnavailable\"\n>;\nexport type OutputError = Failure<\"UnknownTask\" | \"OutputUnavailable\">;\nexport type OutputRange = { start: string; maximumBytes: number };\nexport type OutputPage = {\n\trequested: { start: string; end: string };\n\tchunks: Array<{ offsets: { start: string; end: string }; bytes: Uint8Array }>;\n\tomittedRanges: Array<{ start: string; end: string }>;\n\tnextOffset?: string;\n};\nexport type OwnerScope =\n\t| { kind: \"session\"; sessionId: string }\n\t| { kind: \"workflow-stage\"; sessionId: string; runId: string; stageId: string; stageAttemptId: string };\nexport type WaitPolicy = { kind: \"background\" } | { kind: \"foreground\"; budgetMs?: number };\nexport type YieldReason = \"explicit\" | \"default-background\" | \"elapsed\" | \"intercom-coordination\" | \"input-needed\";\nexport type WaitOutcome =\n\t| { kind: \"settled\"; taskId: TaskId; result: TaskResult }\n\t| { kind: \"yielded\"; taskId: TaskId; waitId: WaitId; reason: YieldReason };\nexport type RouterSelection = { readonly model: string; readonly effort: string | null };\nexport type AgentIntent = {\n\tkind: \"agent\";\n\tagent: string;\n\ttask: string;\n\tdescription?: string;\n\tcwd?: string;\n\tparentTaskId?: TaskId;\n\treadonly routerSelection?: RouterSelection;\n\t/** Heartbeat cadence for this task in milliseconds; `0` disables. Omitted uses the owner default. */\n\treadonly heartbeatMs?: number;\n};\nexport type CommandIntent = {\n\tkind: \"command\";\n\tcommand: string;\n\tdescription?: string;\n\tcwd?: string;\n\tenv?: Record<string, string>;\n\t/** Explicit executable and prefix arguments; command is appended as one argument. */\n\tshell?: { program: string; args: string[] };\n\t/** False replaces the inherited environment with env; omission preserves inheritance. */\n\tinheritEnv?: boolean;\n\tterminal: { kind: \"pipe\" } | { kind: \"pty\"; columns: number; rows: number };\n\texecutionTimeoutMs?: number;\n\tparentTaskId?: TaskId;\n\t/** Heartbeat cadence for this task in milliseconds; `0` disables. Omitted uses the owner default. */\n\treadonly heartbeatMs?: number;\n};\nexport type TaskIntent = AgentIntent | CommandIntent;\nexport type TaskWaitConfiguration =\n\t| { kind: \"automatic\"; commandBudgetMs?: number; agentBudgetMs?: number }\n\t| { kind: \"until-settled\" };\n/**\n * Why a task stopped. `pause` and `quit` stop an agent resumably (a subagent pause or quit, or its workflow stage\n * pausing): it is paused, awaiting resume, not ended. `parent-handoff` is a fresh-start handoff, and also how earlier\n * versions recorded those resumable stops.\n */\nexport type CancelCause =\n\t| \"user\"\n\t| \"owner-close\"\n\t| \"execution-timeout\"\n\t| \"output-limit\"\n\t| \"parent-handoff\"\n\t| \"pause\"\n\t| \"quit\"\n\t| \"shutdown\";\nexport type OwnerCloseCause = \"session-close\" | \"stage-close\" | \"app-shutdown\";\nexport type Cursor = { generation: Generation; sequence: Sequence };\nexport type NativeTaskRef = { ownerId: OwnerId; taskId: TaskId; attemptId: AttemptId; generation: Generation };\nexport type OutputRef = {\n\townerId: OwnerId;\n\ttaskId: TaskId;\n\tartifactId: string;\n\tbyteCount: string;\n\tomittedRanges: Array<{ start: string; end: string }>;\n};\nexport type TaskResult =\n\t| { kind: \"completed\"; output: OutputRef; exitCode?: number }\n\t| { kind: \"failed\"; code: string; message: string; output?: OutputRef; exitCode?: number }\n\t| { kind: \"cancelled\"; cause: CancelCause; output?: OutputRef };\nexport type Execution =\n\t| { kind: \"queued\" }\n\t| { kind: \"running\" }\n\t| { kind: \"cancelling\"; cause: CancelCause }\n\t| { kind: \"settled\"; result: TaskResult };\nexport type ResourceFailure = { resource: string; code: string; message: string };\nexport type Cleanup =\n\t| { kind: \"active\" }\n\t| { kind: \"draining\" }\n\t| { kind: \"reaped\" }\n\t| { kind: \"failed\"; resources: Array<ResourceFailure> };\nexport type PromptRoute = { sessionId: string; promptId: string; stageAttemptId?: string };\nexport type Attention =\n\t| { kind: \"none\" }\n\t| { kind: \"input-needed\"; requestId: string; prompt: string; route: PromptRoute }\n\t| { kind: \"no-recent-activity\"; lastActivityAt?: string };\nexport type HostObservation =\n\t| { kind: \"foreground\"; waitId: WaitId }\n\t| { kind: \"background\"; reason: YieldReason | \"not-observed\" | \"observer-cancelled\" }\n\t| { kind: \"none\"; reason: \"task-settled\" | \"owner-closing\" };\nexport type TaskRecord = {\n\tref: NativeTaskRef;\n\tlaunchOperationId: OperationId;\n\tparentTaskId?: TaskId;\n\tlaunchGroupId?: string;\n\tlaunchOrdinal: number;\n\tkind: \"agent\" | \"command\";\n\ttitle: string;\n\tagentName?: string;\n\t/** Resolved execution settings, retained after completion. */\n\tmodel?: string;\n\tthinking?: string;\n\treadonly routerSelection?: RouterSelection;\n\t/** Heartbeat cadence the task was launched with; `0` disables. Omitted uses the owner default. */\n\treadonly heartbeatMs?: number;\n\texecution: Execution;\n\tobservation: HostObservation;\n\t/** Retained native background membership, independent of the current wait. */\n\twasBackground?: boolean;\n\tattention: Attention;\n\tcleanup: Cleanup;\n\tcurrentAction?: { tool: string; text: string };\n\tmetrics?: { elapsedMs?: number; toolCount?: number; tokenCount?: number };\n\toutput: OutputRef;\n};\n/**\n * The latest 256 accepted activity IDs per task retain SHA-256 payload hashes and receipts.\n * Identical replay is duplicate; changed payload conflicts, without events or retention refresh.\n * Evicted IDs are fresh reports, subject to existing terminal/owner guards, not task revival.\n */\nexport type ActivityReport = {\n\treportId: string;\n\tchange:\n\t\t| { kind: \"action\"; tool: string; text: string }\n\t\t| { kind: \"model\"; model?: string; thinking?: string }\n\t\t| { kind: \"metrics\"; elapsedMs?: number; toolCount?: number; tokenCount?: number }\n\t\t| { kind: \"output\"; offset: string; bytesBase64: string }\n\t\t| { kind: \"attention-set\"; attention: Exclude<Attention, { kind: \"none\" }> }\n\t\t| { kind: \"attention-clear\"; requestId: string };\n};\n/** Terminal reports and their receipts never expire while the task record exists. */\nexport type OutcomeReport = { reportId: string; result: TaskResult };\nexport type TaskEvent =\n\t| { kind: \"task-admitted\"; task: TaskRecord }\n\t| { kind: \"task-started\"; ref: NativeTaskRef }\n\t| { kind: \"wait-yielded\"; ref: NativeTaskRef; waitId: WaitId; reason: YieldReason }\n\t| { kind: \"wait-started\"; ref: NativeTaskRef; waitId: WaitId; observer: \"sdk\" | \"host\" }\n\t| { kind: \"host-observation-changed\"; ref: NativeTaskRef; observation: HostObservation }\n\t| { kind: \"task-activity\"; ref: NativeTaskRef; activity: ActivityReport }\n\t| { kind: \"task-cancelling\"; ref: NativeTaskRef; cause: CancelCause }\n\t| { kind: \"task-settled\"; ref: NativeTaskRef; result: TaskResult; completionId: string }\n\t| { kind: \"cleanup-changed\"; ref: NativeTaskRef; cleanup: Cleanup }\n\t| { kind: \"owner-closing\" }\n\t| { kind: \"owner-closed\" };\nexport type NativeEvent = {\n\tschemaVersion: 1;\n\tcursor: Cursor;\n\townerId: OwnerId;\n\ttaskId?: TaskId;\n\tpayload: TaskEvent;\n};\nexport type OwnerSnapshot = {\n\townerId: OwnerId;\n\tscope: OwnerScope;\n\tgeneration: Generation;\n\tstate: \"open\" | \"closing\" | \"closed\";\n\ttasks: Array<TaskRecord>;\n\tcursor: Cursor;\n};\nexport type ReportReceipt = { reportId: string; cursor: Cursor; disposition: \"accepted\" | \"duplicate\" };\nexport type SettlementReceipt = { taskId: TaskId; cursor: Cursor; result: TaskResult; completionId: string };\nexport type CancelReceipt = {\n\ttaskId: TaskId;\n\tdecision: \"already-settled\" | \"cancellation-requested\";\n\texecution: Execution;\n\tcleanup: Cleanup;\n};\nexport type OwnerCloseReceipt = { ownerId: OwnerId; state: \"closed\"; tasks: Array<CancelReceipt> };\nexport type ArtifactRef = { kind: \"transcript\" | \"result\"; uri: string };\nexport type ModelAdmitted = { kind: \"admitted\"; observation: WaitOutcome; artifacts?: Array<ArtifactRef> };\nexport type ModelRejected = { kind: \"unstarted\"; reason: { kind: \"rejected\"; error: StartFailure } };\nexport type ModelUnstarted =\n\t| ModelRejected\n\t| { kind: \"unstarted\"; reason: { kind: \"skipped\"; cause: \"parallel-group-detach\" } };\nexport type ModelSingleResponse = ModelAdmitted | ModelRejected;\nexport type ModelParallelResponse = {\n\tkind: \"parallel\";\n\tslots: Array<{ ordinal: number; outcome: ModelAdmitted | ModelUnstarted }>;\n};\n"]}
1
+ {"version":3,"file":"contracts.js","sourceRoot":"","sources":["../../../src/core/tasks/contracts.ts"],"names":[],"mappings":"","sourcesContent":["/** Owner-bound task wire contracts. Capabilities are deliberately not wire DTOs. */\ndeclare const brand: unique symbol;\ntype Brand<Name extends string> = { readonly [brand]: Name };\nexport type OwnerId = string & Brand<\"OwnerId\">;\nexport type TaskId = string & Brand<\"TaskId\">;\nexport type AttemptId = string & Brand<\"AttemptId\">;\nexport type WaitId = string & Brand<\"WaitId\">;\nexport type OperationId = string & Brand<\"OperationId\">;\nexport type Generation = string & Brand<\"Generation\">;\n/** Decimal u64, never a JavaScript number. */\nexport type Sequence = string & Brand<\"Sequence\">;\nexport type Result<T, E> = { ok: true; value: T } | { ok: false; error: E };\nexport type Failure<Code extends string> = { code: Code; message: string };\nexport type OwnerError = Failure<\"ScopeMismatch\" | \"EnvironmentClosing\">;\nexport type StartError =\n\t| \"OwnerClosing\"\n\t| \"UnknownAgent\"\n\t| \"InvalidCwd\"\n\t| \"DepthExceeded\"\n\t| \"CapacityExhausted\"\n\t| \"DispatchGuardBusy\"\n\t| \"OperationConflict\"\n\t| \"RunnerUnavailable\"\n\t| \"SpawnFailed\"\n\t| \"ContainmentUnavailable\";\nexport type StartFailure = Failure<StartError>;\nexport type WaitError = Failure<\n\t\"UnknownTask\" | \"OwnerClosed\" | \"EnvironmentClosing\" | \"ScopeMismatch\" | \"ObserverCancelled\"\n>;\nexport type YieldError = Failure<\"UnknownWait\" | \"StaleGeneration\" | \"ObserverCancelled\">;\nexport type ForegroundError = Failure<\"TaskTerminal\" | \"OwnerClosing\" | \"UnknownTask\" | \"ObserverCancelled\">;\nexport type CancelError = Failure<\"UnknownTask\" | \"CleanupFailed\">;\nexport type CloseError = Failure<\"CleanupFailed\" | \"EnvironmentClosing\">;\nexport type WatchError = Failure<\"OwnerClosed\" | \"StaleGeneration\" | \"EnvironmentClosing\">;\nexport type ReportError = Failure<\"StaleAttempt\" | \"OwnerClosing\" | \"TaskTerminal\" | \"ReportConflict\">;\nexport type InputData = { kind: \"bytes\"; bytes: Uint8Array } | { kind: \"eof\" };\nexport type InputReceipt = { operationId: OperationId; acceptedBytes: number; kind: \"bytes\" | \"eof\" };\nexport type InputError = Failure<\n\t| \"TaskTerminal\"\n\t| \"StdinClosed\"\n\t| \"InputBackpressure\"\n\t| \"OperationConflict\"\n\t| \"InputDeliveryUnknown\"\n\t| \"UnknownTask\"\n\t| \"OutputUnavailable\"\n>;\nexport type OutputError = Failure<\"UnknownTask\" | \"OutputUnavailable\">;\nexport type OutputRange = { start: string; maximumBytes: number };\nexport type OutputPage = {\n\trequested: { start: string; end: string };\n\tchunks: Array<{ offsets: { start: string; end: string }; bytes: Uint8Array }>;\n\tomittedRanges: Array<{ start: string; end: string }>;\n\tnextOffset?: string;\n};\nexport type OwnerScope =\n\t| { kind: \"session\"; sessionId: string }\n\t| { kind: \"workflow-stage\"; sessionId: string; runId: string; stageId: string; stageAttemptId: string };\nexport type WaitPolicy = { kind: \"background\" } | { kind: \"foreground\"; budgetMs?: number };\nexport type YieldReason = \"explicit\" | \"default-background\" | \"elapsed\" | \"intercom-coordination\" | \"input-needed\";\nexport type WaitOutcome =\n\t| { kind: \"settled\"; taskId: TaskId; result: TaskResult }\n\t| { kind: \"yielded\"; taskId: TaskId; waitId: WaitId; reason: YieldReason };\nexport type RouterSelection = { readonly model: string; readonly effort: string | null };\nexport type AgentIntent = {\n\tkind: \"agent\";\n\tagent: string;\n\ttask: string;\n\tdescription?: string;\n\tcwd?: string;\n\tparentTaskId?: TaskId;\n\treadonly routerSelection?: RouterSelection;\n\t/**\n\t * The model the launch asked for (`provider/model[:effort]`), kept beside the model the task reports it ran on so\n\t * a fallback to another model is visible.\n\t */\n\treadonly requestedModel?: string;\n\t/** Heartbeat cadence for this task in milliseconds; `0` disables. Omitted uses the owner default. */\n\treadonly heartbeatMs?: number;\n};\nexport type CommandIntent = {\n\tkind: \"command\";\n\tcommand: string;\n\tdescription?: string;\n\tcwd?: string;\n\tenv?: Record<string, string>;\n\t/** Explicit executable and prefix arguments; command is appended as one argument. */\n\tshell?: { program: string; args: string[] };\n\t/** False replaces the inherited environment with env; omission preserves inheritance. */\n\tinheritEnv?: boolean;\n\tterminal: { kind: \"pipe\" } | { kind: \"pty\"; columns: number; rows: number };\n\texecutionTimeoutMs?: number;\n\tparentTaskId?: TaskId;\n\t/** Heartbeat cadence for this task in milliseconds; `0` disables. Omitted uses the owner default. */\n\treadonly heartbeatMs?: number;\n};\nexport type TaskIntent = AgentIntent | CommandIntent;\nexport type TaskWaitConfiguration =\n\t| { kind: \"automatic\"; commandBudgetMs?: number; agentBudgetMs?: number }\n\t| { kind: \"until-settled\" };\n/**\n * Why a task stopped. `pause` and `quit` stop an agent resumably (a subagent pause or quit, or its workflow stage\n * pausing): it is paused, awaiting resume, not ended. `parent-handoff` is a fresh-start handoff, and also how earlier\n * versions recorded those resumable stops.\n */\nexport type CancelCause =\n\t| \"user\"\n\t| \"owner-close\"\n\t| \"execution-timeout\"\n\t| \"output-limit\"\n\t| \"parent-handoff\"\n\t| \"pause\"\n\t| \"quit\"\n\t| \"shutdown\";\nexport type OwnerCloseCause = \"session-close\" | \"stage-close\" | \"app-shutdown\";\nexport type Cursor = { generation: Generation; sequence: Sequence };\nexport type NativeTaskRef = { ownerId: OwnerId; taskId: TaskId; attemptId: AttemptId; generation: Generation };\nexport type OutputRef = {\n\townerId: OwnerId;\n\ttaskId: TaskId;\n\tartifactId: string;\n\tbyteCount: string;\n\tomittedRanges: Array<{ start: string; end: string }>;\n};\nexport type TaskResult =\n\t| { kind: \"completed\"; output: OutputRef; exitCode?: number }\n\t| { kind: \"failed\"; code: string; message: string; output?: OutputRef; exitCode?: number }\n\t| { kind: \"cancelled\"; cause: CancelCause; output?: OutputRef };\nexport type Execution =\n\t| { kind: \"queued\" }\n\t| { kind: \"running\" }\n\t| { kind: \"cancelling\"; cause: CancelCause }\n\t| { kind: \"settled\"; result: TaskResult };\nexport type ResourceFailure = { resource: string; code: string; message: string };\nexport type Cleanup =\n\t| { kind: \"active\" }\n\t| { kind: \"draining\" }\n\t| { kind: \"reaped\" }\n\t| { kind: \"failed\"; resources: Array<ResourceFailure> };\nexport type PromptRoute = { sessionId: string; promptId: string; stageAttemptId?: string };\nexport type Attention =\n\t| { kind: \"none\" }\n\t| { kind: \"input-needed\"; requestId: string; prompt: string; route: PromptRoute }\n\t| { kind: \"no-recent-activity\"; lastActivityAt?: string };\nexport type HostObservation =\n\t| { kind: \"foreground\"; waitId: WaitId }\n\t| { kind: \"background\"; reason: YieldReason | \"not-observed\" | \"observer-cancelled\" }\n\t| { kind: \"none\"; reason: \"task-settled\" | \"owner-closing\" };\nexport type TaskRecord = {\n\tref: NativeTaskRef;\n\tlaunchOperationId: OperationId;\n\tparentTaskId?: TaskId;\n\tlaunchGroupId?: string;\n\tlaunchOrdinal: number;\n\tkind: \"agent\" | \"command\";\n\ttitle: string;\n\tagentName?: string;\n\t/** Resolved execution settings, retained after completion: the model it ran on last. */\n\tmodel?: string;\n\tthinking?: string;\n\treadonly routerSelection?: RouterSelection;\n\t/** The model the launch asked for; `model` differs from it after a fallback to another model. */\n\treadonly requestedModel?: string;\n\t/** Heartbeat cadence the task was launched with; `0` disables. Omitted uses the owner default. */\n\treadonly heartbeatMs?: number;\n\texecution: Execution;\n\tobservation: HostObservation;\n\t/** Retained native background membership, independent of the current wait. */\n\twasBackground?: boolean;\n\tattention: Attention;\n\tcleanup: Cleanup;\n\tcurrentAction?: { tool: string; text: string };\n\tmetrics?: { elapsedMs?: number; toolCount?: number; tokenCount?: number };\n\toutput: OutputRef;\n};\n/**\n * The latest 256 accepted activity IDs per task retain SHA-256 payload hashes and receipts.\n * Identical replay is duplicate; changed payload conflicts, without events or retention refresh.\n * Evicted IDs are fresh reports, subject to existing terminal/owner guards, not task revival.\n */\nexport type ActivityReport = {\n\treportId: string;\n\tchange:\n\t\t| { kind: \"action\"; tool: string; text: string }\n\t\t| { kind: \"model\"; model?: string; thinking?: string }\n\t\t| { kind: \"metrics\"; elapsedMs?: number; toolCount?: number; tokenCount?: number }\n\t\t| { kind: \"output\"; offset: string; bytesBase64: string }\n\t\t| { kind: \"attention-set\"; attention: Exclude<Attention, { kind: \"none\" }> }\n\t\t| { kind: \"attention-clear\"; requestId: string };\n};\n/** Terminal reports and their receipts never expire while the task record exists. */\nexport type OutcomeReport = { reportId: string; result: TaskResult };\nexport type TaskEvent =\n\t| { kind: \"task-admitted\"; task: TaskRecord }\n\t| { kind: \"task-started\"; ref: NativeTaskRef }\n\t| { kind: \"wait-yielded\"; ref: NativeTaskRef; waitId: WaitId; reason: YieldReason }\n\t| { kind: \"wait-started\"; ref: NativeTaskRef; waitId: WaitId; observer: \"sdk\" | \"host\" }\n\t| { kind: \"host-observation-changed\"; ref: NativeTaskRef; observation: HostObservation }\n\t| { kind: \"task-activity\"; ref: NativeTaskRef; activity: ActivityReport }\n\t| { kind: \"task-cancelling\"; ref: NativeTaskRef; cause: CancelCause }\n\t| { kind: \"task-settled\"; ref: NativeTaskRef; result: TaskResult; completionId: string }\n\t| { kind: \"cleanup-changed\"; ref: NativeTaskRef; cleanup: Cleanup }\n\t| { kind: \"owner-closing\" }\n\t| { kind: \"owner-closed\" };\nexport type NativeEvent = {\n\tschemaVersion: 1;\n\tcursor: Cursor;\n\townerId: OwnerId;\n\ttaskId?: TaskId;\n\tpayload: TaskEvent;\n};\nexport type OwnerSnapshot = {\n\townerId: OwnerId;\n\tscope: OwnerScope;\n\tgeneration: Generation;\n\tstate: \"open\" | \"closing\" | \"closed\";\n\ttasks: Array<TaskRecord>;\n\tcursor: Cursor;\n};\nexport type ReportReceipt = { reportId: string; cursor: Cursor; disposition: \"accepted\" | \"duplicate\" };\nexport type SettlementReceipt = { taskId: TaskId; cursor: Cursor; result: TaskResult; completionId: string };\nexport type CancelReceipt = {\n\ttaskId: TaskId;\n\tdecision: \"already-settled\" | \"cancellation-requested\";\n\texecution: Execution;\n\tcleanup: Cleanup;\n};\nexport type OwnerCloseReceipt = { ownerId: OwnerId; state: \"closed\"; tasks: Array<CancelReceipt> };\nexport type ArtifactRef = { kind: \"transcript\" | \"result\"; uri: string };\nexport type ModelAdmitted = { kind: \"admitted\"; observation: WaitOutcome; artifacts?: Array<ArtifactRef> };\nexport type ModelRejected = { kind: \"unstarted\"; reason: { kind: \"rejected\"; error: StartFailure } };\nexport type ModelUnstarted =\n\t| ModelRejected\n\t| { kind: \"unstarted\"; reason: { kind: \"skipped\"; cause: \"parallel-group-detach\" } };\nexport type ModelSingleResponse = ModelAdmitted | ModelRejected;\nexport type ModelParallelResponse = {\n\tkind: \"parallel\";\n\tslots: Array<{ ordinal: number; outcome: ModelAdmitted | ModelUnstarted }>;\n};\n"]}
@@ -13,6 +13,8 @@ export type TaskHeartbeatTask = {
13
13
  title: string;
14
14
  agentName?: string;
15
15
  model?: string;
16
+ /** The model the agent's launch asked for, when the task records one. */
17
+ requestedModel?: string;
16
18
  elapsedMs: number;
17
19
  intervalMs: number;
18
20
  /** Agents: last reported activity. Shells: last observed output. Omitted when none was observed. */
@@ -1 +1 @@
1
- {"version":3,"file":"heartbeat-notice.d.ts","sourceRoot":"","sources":["../../../src/core/tasks/heartbeat-notice.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAEjD,eAAO,MAAM,2BAA2B,mBAAmB,CAAC;AAC5D,qFAAqF;AACrF,eAAO,MAAM,yBAAyB,EAAE,MAA4C,CAAC;AACrF,yFAAyF;AACzF,eAAO,MAAM,qBAAqB,QAAS,CAAC;AAC5C,wBAAgB,sBAAsB,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,MAAM,CAEtE;AAED,yEAAyE;AACzE,wBAAgB,uB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