@bastani/atomic 0.9.25-alpha.1 → 0.9.25-alpha.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +36 -0
- package/dist/builtin/intercom/package.json +2 -2
- package/dist/builtin/mcp/CHANGELOG.md +13 -0
- package/dist/builtin/mcp/index.bundle.mjs +489 -208
- package/dist/builtin/mcp/package.json +2 -2
- package/dist/builtin/subagents/package.json +3 -3
- package/dist/builtin/web-access/package.json +2 -2
- package/dist/builtin/workflows/CHANGELOG.md +12 -0
- package/dist/builtin/workflows/builtin/{chunk-e1254zvd.js → chunk-kfsnh3w7.js} +40 -12
- package/dist/builtin/workflows/builtin/{chunk-cpw5gtzg.js → chunk-rqmasd3d.js} +1 -1
- package/dist/builtin/workflows/builtin/{chunk-qy6g0baf.js → chunk-wz783pvd.js} +1 -1
- package/dist/builtin/workflows/builtin/goal.js +2 -2
- package/dist/builtin/workflows/builtin/index.js +3 -3
- package/dist/builtin/workflows/builtin/ralph.js +2 -2
- package/dist/builtin/workflows/package.json +2 -2
- package/dist/builtin/workflows/src/extension/index.bundle.mjs +472 -88
- package/dist/builtin/workflows/src/index.js +65 -28
- package/dist/core/agent-session-accessors.d.ts.map +1 -1
- package/dist/core/agent-session-accessors.js +7 -0
- package/dist/core/agent-session-accessors.js.map +1 -1
- package/dist/core/agent-session-extension-bindings.d.ts.map +1 -1
- package/dist/core/agent-session-extension-bindings.js +16 -2
- package/dist/core/agent-session-extension-bindings.js.map +1 -1
- package/dist/core/agent-session-methods.d.ts +7 -1
- package/dist/core/agent-session-methods.d.ts.map +1 -1
- package/dist/core/agent-session-methods.js.map +1 -1
- package/dist/core/agent-session-state.d.ts.map +1 -1
- package/dist/core/agent-session-state.js +3 -2
- package/dist/core/agent-session-state.js.map +1 -1
- package/dist/core/agent-session-types.d.ts +1 -0
- package/dist/core/agent-session-types.d.ts.map +1 -1
- package/dist/core/agent-session-types.js.map +1 -1
- package/dist/core/agent-session.d.ts +3 -0
- package/dist/core/agent-session.d.ts.map +1 -1
- package/dist/core/agent-session.js +6 -0
- package/dist/core/agent-session.js.map +1 -1
- package/dist/core/builtin-resource-loader.d.ts.map +1 -1
- package/dist/core/builtin-resource-loader.js +13 -1
- package/dist/core/builtin-resource-loader.js.map +1 -1
- package/dist/core/extensions/api-types.d.ts +3 -0
- package/dist/core/extensions/api-types.d.ts.map +1 -1
- package/dist/core/extensions/api-types.js.map +1 -1
- package/dist/core/extensions/index.d.ts +2 -0
- package/dist/core/extensions/index.d.ts.map +1 -1
- package/dist/core/extensions/index.js +1 -0
- package/dist/core/extensions/index.js.map +1 -1
- package/dist/core/extensions/loader-api.d.ts.map +1 -1
- package/dist/core/extensions/loader-api.js +11 -0
- package/dist/core/extensions/loader-api.js.map +1 -1
- package/dist/core/extensions/loader-runtime.d.ts.map +1 -1
- package/dist/core/extensions/loader-runtime.js +3 -0
- package/dist/core/extensions/loader-runtime.js.map +1 -1
- package/dist/core/extensions/mcp-server-registry.d.ts.map +1 -1
- package/dist/core/extensions/mcp-server-registry.js +4 -0
- package/dist/core/extensions/mcp-server-registry.js.map +1 -1
- package/dist/core/extensions/runner.d.ts +3 -0
- package/dist/core/extensions/runner.d.ts.map +1 -1
- package/dist/core/extensions/runner.js +4 -0
- package/dist/core/extensions/runner.js.map +1 -1
- package/dist/core/extensions/runtime-types.d.ts +3 -0
- package/dist/core/extensions/runtime-types.d.ts.map +1 -1
- package/dist/core/extensions/runtime-types.js.map +1 -1
- package/dist/core/extensions/tool-types.d.ts +1 -0
- package/dist/core/extensions/tool-types.d.ts.map +1 -1
- package/dist/core/extensions/tool-types.js.map +1 -1
- package/dist/core/extensions/workflow-run-control-hub.d.ts +23 -0
- package/dist/core/extensions/workflow-run-control-hub.d.ts.map +1 -0
- package/dist/core/extensions/workflow-run-control-hub.js +57 -0
- package/dist/core/extensions/workflow-run-control-hub.js.map +1 -0
- package/dist/core/extensions/workflow-run-control.d.ts +163 -0
- package/dist/core/extensions/workflow-run-control.d.ts.map +1 -0
- package/dist/core/extensions/workflow-run-control.js +73 -0
- package/dist/core/extensions/workflow-run-control.js.map +1 -0
- package/dist/core/mandatory-resource-loader.d.ts.map +1 -1
- package/dist/core/mandatory-resource-loader.js +9 -0
- package/dist/core/mandatory-resource-loader.js.map +1 -1
- package/dist/core/mcp-servers.d.ts +4 -1
- package/dist/core/mcp-servers.d.ts.map +1 -1
- package/dist/core/mcp-servers.js.map +1 -1
- package/dist/core/oauth-provider-metadata.js +1 -1
- package/dist/core/oauth-provider-metadata.js.map +1 -1
- package/dist/core/remote-catalog-provider.d.ts.map +1 -1
- package/dist/core/remote-catalog-provider.js +4 -9
- package/dist/core/remote-catalog-provider.js.map +1 -1
- package/dist/core/resource-loader-types.d.ts +4 -0
- package/dist/core/resource-loader-types.d.ts.map +1 -1
- package/dist/core/resource-loader-types.js.map +1 -1
- package/dist/core/sdk.js +1 -0
- package/dist/core/sdk.js.map +1 -1
- package/dist/core/structured-output/index.d.ts.map +1 -1
- package/dist/core/structured-output/index.js +3 -1
- package/dist/core/structured-output/index.js.map +1 -1
- package/dist/core/tool-loadout.d.ts +1 -0
- package/dist/core/tool-loadout.d.ts.map +1 -1
- package/dist/core/tool-loadout.js +3 -0
- package/dist/core/tool-loadout.js.map +1 -1
- package/dist/core/tools/bash.d.ts.map +1 -1
- package/dist/core/tools/bash.js +11 -30
- package/dist/core/tools/bash.js.map +1 -1
- package/dist/extensions/codemode/execute.d.ts.map +1 -1
- package/dist/extensions/codemode/execute.js +26 -0
- package/dist/extensions/codemode/execute.js.map +1 -1
- package/dist/extensions/codemode/renderer.d.ts.map +1 -1
- package/dist/extensions/codemode/renderer.js +38 -23
- package/dist/extensions/codemode/renderer.js.map +1 -1
- package/dist/extensions/codemode/tool.d.ts.map +1 -1
- package/dist/extensions/codemode/tool.js +22 -10
- package/dist/extensions/codemode/tool.js.map +1 -1
- package/dist/extensions/tool-search/tool.d.ts +1 -1
- package/dist/extensions/tool-search/tool.d.ts.map +1 -1
- package/dist/extensions/tool-search/tool.js +3 -13
- package/dist/extensions/tool-search/tool.js.map +1 -1
- package/dist/index-extensions.d.ts +2 -1
- package/dist/index-extensions.d.ts.map +1 -1
- package/dist/index-extensions.js +1 -1
- package/dist/index-extensions.js.map +1 -1
- package/dist/modes/interactive/components/visual-truncate.d.ts +27 -3
- package/dist/modes/interactive/components/visual-truncate.d.ts.map +1 -1
- package/dist/modes/interactive/components/visual-truncate.js +39 -6
- package/dist/modes/interactive/components/visual-truncate.js.map +1 -1
- package/docs/extensions/events.md +2 -0
- package/docs/mcp-servers.md +47 -0
- package/docs/providers.md +9 -1
- package/docs/sdk/reference.md +22 -0
- package/docs/sdk/structured-decisions.md +2 -0
- package/docs/sdk.md +67 -1
- package/docs/settings.md +2 -0
- package/docs/tools.md +6 -0
- package/docs/workflows/operations.md +3 -1
- package/examples/extensions/built-in-tool-renderer.ts +16 -40
- package/examples/extensions/minimal-mode.ts +28 -108
- package/npm-shrinkwrap.json +69 -69
- package/package.json +8 -8
|
@@ -2,7 +2,7 @@ import { getCurrentSystemMessage } from "@bastani/pi-ai";
|
|
|
2
2
|
import { getCallableTools } from "./agent-session-nested-tools.js";
|
|
3
3
|
import { getSkillCatalog } from "./skill-catalog.js";
|
|
4
4
|
import { buildSystemPrompt, buildSystemPromptSections, diffSystemPromptSections, normalizeBuildSystemPromptOptions, } from "./system-prompt.js";
|
|
5
|
-
import { applyToolLoadout } from "./tool-loadout.js";
|
|
5
|
+
import { applyToolLoadout, isToolDeclarationHidden } from "./tool-loadout.js";
|
|
6
6
|
export function getActiveToolNames() {
|
|
7
7
|
return this.agent.state.tools.map((t) => t.name);
|
|
8
8
|
}
|
|
@@ -73,7 +73,7 @@ export function _rebuildSystemPrompt(toolNames) {
|
|
|
73
73
|
const toolSnippets = {};
|
|
74
74
|
for (const name of this._toolRegistry.keys()) {
|
|
75
75
|
const snippet = this._toolPromptSnippets.get(name);
|
|
76
|
-
if (snippet) {
|
|
76
|
+
if (snippet && !isToolDeclarationHidden(this, name)) {
|
|
77
77
|
toolSnippets[name] = snippet;
|
|
78
78
|
}
|
|
79
79
|
}
|
|
@@ -109,6 +109,7 @@ export function _preparePromptAndToolLoadout(options, messages = this.agent.stat
|
|
|
109
109
|
const recorded = (current?.toolsAdded ?? []).map((tool) => tool.name).filter((name) => selected.includes(name));
|
|
110
110
|
options.selectedTools = [...recorded, ...selected.filter((name) => !recorded.includes(name))];
|
|
111
111
|
options.selectedTools = applyToolLoadout(this, options.selectedTools).map((tool) => tool.name);
|
|
112
|
+
options.toolSnippets = Object.fromEntries(Object.entries(options.toolSnippets).filter(([name]) => !isToolDeclarationHidden(this, name)));
|
|
112
113
|
const sections = diffSystemPromptSections(current?.sections ?? {}, buildSystemPromptSections(options));
|
|
113
114
|
return sections ? { role: "system", content: "", sections, timestamp: Date.now() } : undefined;
|
|
114
115
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agent-session-state.js","sourceRoot":"","sources":["../../src/core/agent-session-state.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,uBAAuB,EAAsB,MAAM,gBAAgB,CAAC;AAI7E,OAAO,EAAE,gBAAgB,EAAE,MAAM,iCAAiC,CAAC;AAEnE,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AACrD,OAAO,EACN,iBAAiB,EACjB,yBAAyB,EACzB,wBAAwB,EAExB,iCAAiC,GACjC,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAErD,MAAM,UAAU,kBAAkB;IACjC,OAAO,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;AAClD,CAAC;AAED,MAAM,UAAU,oBAAoB;IACnC,OAAO,gBAAgB,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC,IAA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OAAO,QAAQ,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,OAAO,EAAE,EAAE,EAAE,QAAQ,EAAE,SAAS,EAAE,IAAI,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC;AAChG,CAAC;AAED,8FAA8F;AAC9F,MAAM,UAAU,2BAA2B;IAC1C,MAAM,OAAO,GAAG,uBAAuB,CAAC,IAAI,CAAC,cAAc,CAAC,mBAAmB,EAAE,CAAC,QAAQ,CAAC,CAAC;IAC5F,IAAI,CAAC,OAAO;QAAE,OAAO;IACrB,MAAM,KAAK,GAAG,CAAC,OAAO,CAAC,UAAU,IAAI,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,aAAa,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC;IACjH,IAAI,CAAC,oBAAoB,CAAC,KAAK,CAAC,CAAC;AAClC,CAAC;AAED,4EAA4E;AAC5E,YAAY;AACZ,4EAA4E;AAE5E;;;;;;;;GAQG;AAEH,MAAM,CAAC,MAAM,wBAAwB,GAAG;IACvC,kBAAkB;IAClB,oBAAoB;IACpB,WAAW;IACX,iBAAiB;IACjB,oBAAoB;IACpB,eAAe;IACf,uBAAuB;IACvB,0BAA0B;IAC1B,oBAAoB;IACpB,4BAA4B;IAC5B,2BAA2B;IAC3B,uCAAuC;CACvC,CAAC","sourcesContent":["import { getCurrentSystemMessage, 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 { getSkillCatalog } from \"./skill-catalog.ts\";\nimport {\n\tbuildSystemPrompt,\n\tbuildSystemPromptSections,\n\tdiffSystemPromptSections,\n\ttype NormalizedBuildSystemPromptOptions,\n\tnormalizeBuildSystemPromptOptions,\n} from \"./system-prompt.ts\";\nimport { applyToolLoadout } from \"./tool-loadout.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\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 tools = applyToolLoadout(this, toolNames);\n\tconst validToolNames = tools.map((tool) => tool.name);\n\n\tthis._rebuildSystemPrompt(validToolNames);\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\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\tconst sections = diffSystemPromptSections(current?.sections ?? {}, buildSystemPromptSections(options));\n\treturn sections ? { role: \"system\", content: \"\", sections, timestamp: Date.now() } : undefined;\n}\n\n/** Restore registered tools from the selected transcript, not another branch's live state. */\nexport function _restoreToolsFromTranscript(this: AgentSession): void {\n\tconst current = getCurrentSystemMessage(this.sessionManager.buildSessionContext().messages);\n\tif (!current) return;\n\tconst names = (current.toolsAdded ?? []).map((tool) => tool.name).filter((name) => this._toolRegistry.has(name));\n\tthis.setActiveToolsByName(names);\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\tsetActiveToolsByName,\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,EAAsB,MAAM,gBAAgB,CAAC;AAI7E,OAAO,EAAE,gBAAgB,EAAE,MAAM,iCAAiC,CAAC;AAEnE,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AACrD,OAAO,EACN,iBAAiB,EACjB,yBAAyB,EACzB,wBAAwB,EAExB,iCAAiC,GACjC,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,gBAAgB,EAAE,uBAAuB,EAAE,MAAM,mBAAmB,CAAC;AAE9E,MAAM,UAAU,kBAAkB;IACjC,OAAO,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;AAClD,CAAC;AAED,MAAM,UAAU,oBAAoB;IACnC,OAAO,gBAAgB,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AACxD,CAAC;AAED;;GAEG;AAEH,MAAM,UAAU,WAAW;IAC1B,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,gBAAgB,CAAC,MAAM,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,EAAE,UAAU,EAAE,UAAU,EAAE,EAAE,EAAE,CAAC,CAAC;QACtF,IAAI,EAAE,UAAU,CAAC,IAA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AC,CAAC,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,OAAO,EAAE,EAAE,EAAE,QAAQ,EAAE,SAAS,EAAE,IAAI,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC;AAChG,CAAC;AAED,8FAA8F;AAC9F,MAAM,UAAU,2BAA2B;IAC1C,MAAM,OAAO,GAAG,uBAAuB,CAAC,IAAI,CAAC,cAAc,CAAC,mBAAmB,EAAE,CAAC,QAAQ,CAAC,CAAC;IAC5F,IAAI,CAAC,OAAO;QAAE,OAAO;IACrB,MAAM,KAAK,GAAG,CAAC,OAAO,CAAC,UAAU,IAAI,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,aAAa,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC;IACjH,IAAI,CAAC,oBAAoB,CAAC,KAAK,CAAC,CAAC;AAClC,CAAC;AAED,4EAA4E;AAC5E,YAAY;AACZ,4EAA4E;AAE5E;;;;;;;;GAQG;AAEH,MAAM,CAAC,MAAM,wBAAwB,GAAG;IACvC,kBAAkB;IAClB,oBAAoB;IACpB,WAAW;IACX,iBAAiB;IACjB,oBAAoB;IACpB,eAAe;IACf,uBAAuB;IACvB,0BAA0B;IAC1B,oBAAoB;IACpB,4BAA4B;IAC5B,2BAA2B;IAC3B,uCAAuC;CACvC,CAAC","sourcesContent":["import { getCurrentSystemMessage, 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 { 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\";\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\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 tools = applyToolLoadout(this, toolNames);\n\tconst validToolNames = tools.map((tool) => tool.name);\n\n\tthis._rebuildSystemPrompt(validToolNames);\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 && !isToolDeclarationHidden(this, name)) {\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\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.toolSnippets = Object.fromEntries(\n\t\tObject.entries(options.toolSnippets).filter(([name]) => !isToolDeclarationHidden(this, name)),\n\t);\n\tconst sections = diffSystemPromptSections(current?.sections ?? {}, buildSystemPromptSections(options));\n\treturn sections ? { role: \"system\", content: \"\", sections, timestamp: Date.now() } : undefined;\n}\n\n/** Restore registered tools from the selected transcript, not another branch's live state. */\nexport function _restoreToolsFromTranscript(this: AgentSession): void {\n\tconst current = getCurrentSystemMessage(this.sessionManager.buildSessionContext().messages);\n\tif (!current) return;\n\tconst names = (current.toolsAdded ?? []).map((tool) => tool.name).filter((name) => this._toolRegistry.has(name));\n\tthis.setActiveToolsByName(names);\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\tsetActiveToolsByName,\n\tsetScopedModels,\n\t_normalizePromptSnippet,\n\t_normalizePromptGuidelines,\n\t_rebuildSystemPrompt,\n\t_preparePromptAndToolLoadout,\n\t_restoreToolsFromTranscript,\n\t_refreshBaseSystemPromptFromActiveTools,\n};\n"]}
|
|
@@ -138,6 +138,7 @@ export interface AgentSessionConfig {
|
|
|
138
138
|
cacheWarmer?: import("./cache-warmer.ts").CacheWarmer;
|
|
139
139
|
childSessionOptions?: import("./child-session-options.ts").ChildSessionOptionsResolver;
|
|
140
140
|
initialActiveToolNames?: string[];
|
|
141
|
+
usesDefaultTools?: boolean;
|
|
141
142
|
allowedToolNames?: string[];
|
|
142
143
|
excludedToolNames?: string[];
|
|
143
144
|
baseToolsOverride?: Record<string, AgentTool>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agent-session-types.d.ts","sourceRoot":"","sources":["../../src/core/agent-session-types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,gBAAgB,EAAE,YAAY,EAAE,KAAK,EAAE,WAAW,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC;AAC5G,OAAO,KAAK,EAAE,KAAK,EAAE,UAAU,EAAE,YAAY,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAC;AAC/G,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,uBAAuB,CAAC;AACtE,OAAO,KAAK,EACX,YAAY,EACZ,8BAA8B,EAC9B,sBAAsB,EACtB,aAAa,EACb,kBAAkB,EAClB,WAAW,EACX,oBAAoB,EACpB,iBAAiB,EACjB,eAAe,EACf,mBAAmB,EACnB,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AC,KAAK,EAAE,SAAS,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,KAAK,CAAC,CAAC;AAE5G,MAAM,UAAU,4BAA4B,CAAC,OAAsB;IAClE,OAAQ,OAA4D,CAAC,kBAAkB,KAAK,IAAI,CAAC;AAClG,CAAC","sourcesContent":["import type { Api, AssistantMessage, ImageContent, Model, TextContent, Usage } from \"@bastani/pi-ai/compat\";\nimport type { Agent, AgentEvent, AgentMessage, AgentTool, ThinkingLevel } from \"@earendil-works/pi-agent-core\";\nimport type { VerbatimCompactionResult } from \"./compaction/index.ts\";\nimport type {\n\tContextUsage,\n\tExtensionCommandContextActions,\n\tExtensionErrorListener,\n\tExtensionMode,\n\tExtensionUIContext,\n\tInputSource,\n\tOrchestrationContext,\n\tSessionStartEvent,\n\tShutdownHandler,\n\tSubagentChildPolicy,\n\tToolDefinition,\n} from \"./extensions/index.js\";\nimport type { CustomMessage } from \"./messages.ts\";\nimport type { ModelRuntime } from \"./model-runtime.js\";\nimport type { ResourceLoader } from \"./resource-loader.ts\";\nimport type { SessionManager } from \"./session-manager.ts\";\nimport type { SettingsManager } from \"./settings-manager.ts\";\nimport type { SourceInfo } from \"./source-info.ts\";\nexport type CompactionReason = \"manual\" | \"threshold\" | \"overflow\" | \"branchSummary\";\n\nexport type AgentSessionEvent =\n\t| (AgentEvent & { parentToolCallId?: string })\n\t| { type: \"agent_settled\" }\n\t| { type: \"entry_appended\"; entry: import(\"./session-manager.ts\").SessionEntry }\n\t| {\n\t\t\ttype: \"queue_update\";\n\t\t\tsteering: readonly string[];\n\t\t\tfollowUp: readonly string[];\n\t }\n\t| { type: \"compaction_start\"; reason: \"manual\" | \"threshold\" | \"overflow\"; midTurn?: boolean }\n\t| { type: \"session_info_changed\"; name: string | undefined }\n\t| {\n\t\t\ttype: \"model_changed\";\n\t\t\tmodel: Model<Api>;\n\t\t\tpreviousModel: Model<Api> | undefined;\n\t\t\tsource: \"set\" | \"cycle\" | \"restore\" | \"fallback\";\n\t }\n\t| { type: \"thinking_level_changed\"; level: ThinkingLevel }\n\t| {\n\t\t\ttype: \"compaction_end\";\n\t\t\treason: \"manual\" | \"threshold\" | \"overflow\";\n\t\t\tresult: VerbatimCompactionResult | undefined;\n\t\t\taborted: boolean;\n\t\t\twillRetry: boolean;\n\t\t\tunresolvedOverflow?: boolean;\n\t\t\terrorMessage?: string;\n\t\t\tmidTurn?: boolean;\n\t\t\t/** A manual request has claimed ownership and will emit its own completion. */\n\t\t\tmanualTakeoverPending?: boolean;\n\t }\n\t| { type: \"agent_continue_error\"; source: \"post_compaction\"; errorMessage: string }\n\t| { type: \"auto_retry_start\"; attempt: number; maxAttempts: number; delayMs: number; errorMessage: string }\n\t| { type: \"auto_retry_end\"; success: boolean; attempt: number; finalError?: string }\n\t| {\n\t\t\ttype: \"summarization_retry_scheduled\";\n\t\t\tattempt: number;\n\t\t\tmaxAttempts: number;\n\t\t\tdelayMs: number;\n\t\t\terrorMessage: string;\n\t }\n\t| { type: \"summarization_retry_attempt_start\"; source: \"branchSummary\" }\n\t| {\n\t\t\ttype: \"summarization_retry_attempt_start\";\n\t\t\tsource: \"compaction\";\n\t\t\treason: \"manual\" | \"threshold\" | \"overflow\";\n\t }\n\t| { type: \"summarization_retry_finished\" }\n\t| { type: \"bash_execution_update\"; id?: string; channel: \"stdout\" | \"stderr\"; delta: string }\n\t| { type: \"model_fallback_start\"; from: string; to: string; reason: string; attempt: number }\n\t| { type: \"model_fallback_end\"; success: boolean; from?: string; to?: string; finalError?: string };\n\nexport type AgentSessionEventListener = (event: AgentSessionEvent) => void;\n\nexport interface PendingAgentMessageQueue {\n\thasItems(): boolean;\n\tdrain(): AgentMessage[];\n}\n\nexport interface AgentQueueAccess {\n\treadonly steeringQueue?: PendingAgentMessageQueue;\n\treadonly followUpQueue?: PendingAgentMessageQueue;\n}\n\nexport interface DrainedAgentQueues {\n\treadonly steering: AgentMessage[];\n\treadonly followUp: AgentMessage[];\n}\n\nexport interface InterruptQueueHold {\n\treadonly steering: AgentMessage[];\n\treadonly followUp: AgentMessage[];\n}\n\n/** Insertion boundary after already admitted priority input in a queue hold. */\nexport const priorityHoldCounts = new WeakMap<InterruptQueueHold, number>();\n\nexport interface ClearQueueOptions {\n\tpreserveUnprotectedCustomMessages?: boolean;\n}\n\nexport function drainAgentMessageQueue(queue: PendingAgentMessageQueue | undefined): AgentMessage[] {\n\tif (!queue) return [];\n\tconst drained: AgentMessage[] = [];\n\twhile (queue.hasItems()) {\n\t\tdrained.push(...queue.drain());\n\t}\n\treturn drained;\n}\n\nexport function normalizeInterruptAbortMessage(value: string | undefined): string | undefined {\n\tconst trimmed = value?.trim();\n\treturn trimmed && trimmed.length > 0 ? trimmed : undefined;\n}\n\nexport function isGenericAbortText(value: string): boolean {\n\tconst normalized = value\n\t\t.trim()\n\t\t.toLowerCase()\n\t\t.replace(/[.!]+$/, \"\");\n\treturn (\n\t\tnormalized === \"operation aborted\" ||\n\t\tnormalized === \"the operation was aborted\" ||\n\t\tnormalized === \"request was aborted\" ||\n\t\tnormalized === \"this operation was aborted\" ||\n\t\tnormalized === \"extension custom ui aborted\"\n\t);\n}\n\nexport function isSingleGenericAbortTextContent(content: unknown): boolean {\n\treturn (\n\t\tArray.isArray(content) &&\n\t\tcontent.length === 1 &&\n\t\ttypeof content[0] === \"object\" &&\n\t\tcontent[0] !== null &&\n\t\t(content[0] as { type?: unknown }).type === \"text\" &&\n\t\ttypeof (content[0] as { text?: unknown }).text === \"string\" &&\n\t\tisGenericAbortText((content[0] as { text: string }).text)\n\t);\n}\n\nexport function replacementAbortContent(text: string): TextContent[] {\n\treturn [{ type: \"text\", text }];\n}\n\nexport interface AgentSessionConfig {\n\tagent: Agent;\n\tsessionManager: SessionManager;\n\tsettingsManager: SettingsManager;\n\tcwd: string;\n\tscopedModels?: Array<{ model: Model<Api>; thinkingLevel?: ThinkingLevel }>;\n\tfallbackModels?: string[];\n\tisFallbackModelAllowed?: (model: Model<Api>, effort: string | undefined) => boolean;\n\tresourceLoader: ResourceLoader;\n\tcustomTools?: ToolDefinition[];\n\tmodelRuntime: ModelRuntime;\n\tcacheWarmer?: import(\"./cache-warmer.ts\").CacheWarmer;\n\tchildSessionOptions?: import(\"./child-session-options.ts\").ChildSessionOptionsResolver;\n\tinitialActiveToolNames?: string[];\n\tallowedToolNames?: string[];\n\texcludedToolNames?: string[];\n\tbaseToolsOverride?: Record<string, AgentTool>;\n\textensionRunnerRef?: { current?: import(\"./extensions/index.js\").ExtensionRunner };\n\tsessionStartEvent?: SessionStartEvent;\n\tsubagentPolicy?: SubagentChildPolicy;\n\t/** Parent-issued shell task owner for an in-process subagent child. */\n\tparentCommandTaskOwner?: import(\"./tasks/child-command-owner.js\").ChildCommandTaskOwner;\n\tsystemPromptTransform?: (prompt: string) => string;\n\t/**\n\t * Transform the canonical session projection whenever it becomes the finalized\n\t * context (session construction, provider requests, boundaries, recovery). The\n\t * durable transcript stays unchanged; only derived context is filtered.\n\t */\n\tcontextProjectionTransform?: (messages: AgentMessage[]) => AgentMessage[];\n\torchestrationContext?: OrchestrationContext;\n}\n\nexport interface ExtensionBindings {\n\thumanInput?: import(\"./extensions/host-input.js\").HostInput | null;\n\tonDiagnostic?: (diagnostic: import(\"./extensions/host-input.js\").HostDiagnostic) => void;\n\tuiContext?: ExtensionUIContext;\n\tmode?: ExtensionMode;\n\tcommandContextActions?: ExtensionCommandContextActions;\n\tshutdownHandler?: ShutdownHandler;\n\tonError?: ExtensionErrorListener;\n}\n\nexport interface AgentSessionReloadOptions {\n\treason?: \"startup\" | \"reload\";\n\t/** Runs after resources and the extension runtime are rebuilt, immediately before session_start. */\n\tbeforeSessionStart?: () => void | Promise<void>;\n\t/** Leave the existing extension runner active unless every extension factory loaded successfully. */\n\tfailOnExtensionErrors?: boolean;\n}\n\nexport type QueuedInputDisposition = \"handled\" | \"queued\";\nexport type PromptDisposition = QueuedInputDisposition | \"started\";\n\nexport interface PromptOptions {\n\t/** Whether to dispatch extension commands and expand skill commands and prompt templates (default: true) */\n\texpandPromptTemplates?: boolean;\n\timages?: ImageContent[];\n\tstreamingBehavior?: \"steer\" | \"followUp\";\n\tsource?: InputSource;\n\t/** Called once when preflight accepts (`true`, with how the prompt was dispatched) or rejects (`false`) the prompt. */\n\tpreflightResult?: (success: boolean, disposition?: PromptDisposition) => void;\n}\n\nexport interface ModelMutationOptions {\n\tpersist?: boolean;\n}\n\nexport interface ModelCycleResult {\n\tmodel: Model<Api>;\n\tthinkingLevel: ThinkingLevel;\n\tisScoped: boolean;\n}\n\nexport interface SessionStats {\n\tsessionFile: string | undefined;\n\tsessionId: string;\n\tuserMessages: number;\n\tassistantMessages: number;\n\ttoolCalls: number;\n\ttoolResults: number;\n\ttotalMessages: number;\n\ttokens: {\n\t\tinput: number;\n\t\toutput: number;\n\t\tcacheRead: number;\n\t\tcacheWrite: number;\n\t\ttotal: number;\n\t};\n\tcost: number;\n\tcontextUsage?: ContextUsage;\n\t/** Usage of the newest assistant message, which the footer's cache-hit rate reads. */\n\tlatestAssistantUsage?: Usage;\n}\n\nexport interface ToolDefinitionEntry {\n\tdefinition: ToolDefinition;\n\tsourceInfo: SourceInfo;\n}\n\nexport const THINKING_LEVELS: ThinkingLevel[] = [\"off\", \"minimal\", \"low\", \"medium\", \"high\", \"xhigh\", \"max\"];\n\nexport function customMessageExcludesContext(message: CustomMessage): boolean {\n\treturn (message as CustomMessage & { excludeFromContext?: boolean }).excludeFromContext === true;\n}\n\nexport type AssistantMessageWithError = AssistantMessage;\n"]}
|
|
1
|
+
{"version":3,"file":"agent-session-types.js","sourceRoot":"","sources":["../../src/core/agent-session-types.ts"],"names":[],"mappings":"AAiGA,gFAAgF;AAChF,MAAM,CAAC,MAAM,kBAAkB,GAAG,IAAI,OAAO,EAA8B,CAAC;AAM5E,MAAM,UAAU,sBAAsB,CAAC,KAA2C;IACjF,IAAI,CAAC,KAAK;QAAE,OAAO,EAAE,CAAC;IACtB,MAAM,OAAO,GAAmB,EAAE,CAAC;IAC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C,CAAC;AACjC,CAAC;AAsGD,MAAM,CAAC,MAAM,eAAe,GAAoB,CAAC,KAAK,EAAE,SAAS,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,KAAK,CAAC,CAAC;AAE5G,MAAM,UAAU,4BAA4B,CAAC,OAAsB;IAClE,OAAQ,OAA4D,CAAC,kBAAkB,KAAK,IAAI,CAAC;AAClG,CAAC","sourcesContent":["import type { Api, AssistantMessage, ImageContent, Model, TextContent, Usage } from \"@bastani/pi-ai/compat\";\nimport type { Agent, AgentEvent, AgentMessage, AgentTool, ThinkingLevel } from \"@earendil-works/pi-agent-core\";\nimport type { VerbatimCompactionResult } from \"./compaction/index.ts\";\nimport type {\n\tContextUsage,\n\tExtensionCommandContextActions,\n\tExtensionErrorListener,\n\tExtensionMode,\n\tExtensionUIContext,\n\tInputSource,\n\tOrchestrationContext,\n\tSessionStartEvent,\n\tShutdownHandler,\n\tSubagentChildPolicy,\n\tToolDefinition,\n} from \"./extensions/index.js\";\nimport type { CustomMessage } from \"./messages.ts\";\nimport type { ModelRuntime } from \"./model-runtime.js\";\nimport type { ResourceLoader } from \"./resource-loader.ts\";\nimport type { SessionManager } from \"./session-manager.ts\";\nimport type { SettingsManager } from \"./settings-manager.ts\";\nimport type { SourceInfo } from \"./source-info.ts\";\nexport type CompactionReason = \"manual\" | \"threshold\" | \"overflow\" | \"branchSummary\";\n\nexport type AgentSessionEvent =\n\t| (AgentEvent & { parentToolCallId?: string })\n\t| { type: \"agent_settled\" }\n\t| { type: \"entry_appended\"; entry: import(\"./session-manager.ts\").SessionEntry }\n\t| {\n\t\t\ttype: \"queue_update\";\n\t\t\tsteering: readonly string[];\n\t\t\tfollowUp: readonly string[];\n\t }\n\t| { type: \"compaction_start\"; reason: \"manual\" | \"threshold\" | \"overflow\"; midTurn?: boolean }\n\t| { type: \"session_info_changed\"; name: string | undefined }\n\t| {\n\t\t\ttype: \"model_changed\";\n\t\t\tmodel: Model<Api>;\n\t\t\tpreviousModel: Model<Api> | undefined;\n\t\t\tsource: \"set\" | \"cycle\" | \"restore\" | \"fallback\";\n\t }\n\t| { type: \"thinking_level_changed\"; level: ThinkingLevel }\n\t| {\n\t\t\ttype: \"compaction_end\";\n\t\t\treason: \"manual\" | \"threshold\" | \"overflow\";\n\t\t\tresult: VerbatimCompactionResult | undefined;\n\t\t\taborted: boolean;\n\t\t\twillRetry: boolean;\n\t\t\tunresolvedOverflow?: boolean;\n\t\t\terrorMessage?: string;\n\t\t\tmidTurn?: boolean;\n\t\t\t/** A manual request has claimed ownership and will emit its own completion. */\n\t\t\tmanualTakeoverPending?: boolean;\n\t }\n\t| { type: \"agent_continue_error\"; source: \"post_compaction\"; errorMessage: string }\n\t| { type: \"auto_retry_start\"; attempt: number; maxAttempts: number; delayMs: number; errorMessage: string }\n\t| { type: \"auto_retry_end\"; success: boolean; attempt: number; finalError?: string }\n\t| {\n\t\t\ttype: \"summarization_retry_scheduled\";\n\t\t\tattempt: number;\n\t\t\tmaxAttempts: number;\n\t\t\tdelayMs: number;\n\t\t\terrorMessage: string;\n\t }\n\t| { type: \"summarization_retry_attempt_start\"; source: \"branchSummary\" }\n\t| {\n\t\t\ttype: \"summarization_retry_attempt_start\";\n\t\t\tsource: \"compaction\";\n\t\t\treason: \"manual\" | \"threshold\" | \"overflow\";\n\t }\n\t| { type: \"summarization_retry_finished\" }\n\t| { type: \"bash_execution_update\"; id?: string; channel: \"stdout\" | \"stderr\"; delta: string }\n\t| { type: \"model_fallback_start\"; from: string; to: string; reason: string; attempt: number }\n\t| { type: \"model_fallback_end\"; success: boolean; from?: string; to?: string; finalError?: string };\n\nexport type AgentSessionEventListener = (event: AgentSessionEvent) => void;\n\nexport interface PendingAgentMessageQueue {\n\thasItems(): boolean;\n\tdrain(): AgentMessage[];\n}\n\nexport interface AgentQueueAccess {\n\treadonly steeringQueue?: PendingAgentMessageQueue;\n\treadonly followUpQueue?: PendingAgentMessageQueue;\n}\n\nexport interface DrainedAgentQueues {\n\treadonly steering: AgentMessage[];\n\treadonly followUp: AgentMessage[];\n}\n\nexport interface InterruptQueueHold {\n\treadonly steering: AgentMessage[];\n\treadonly followUp: AgentMessage[];\n}\n\n/** Insertion boundary after already admitted priority input in a queue hold. */\nexport const priorityHoldCounts = new WeakMap<InterruptQueueHold, number>();\n\nexport interface ClearQueueOptions {\n\tpreserveUnprotectedCustomMessages?: boolean;\n}\n\nexport function drainAgentMessageQueue(queue: PendingAgentMessageQueue | undefined): AgentMessage[] {\n\tif (!queue) return [];\n\tconst drained: AgentMessage[] = [];\n\twhile (queue.hasItems()) {\n\t\tdrained.push(...queue.drain());\n\t}\n\treturn drained;\n}\n\nexport function normalizeInterruptAbortMessage(value: string | undefined): string | undefined {\n\tconst trimmed = value?.trim();\n\treturn trimmed && trimmed.length > 0 ? trimmed : undefined;\n}\n\nexport function isGenericAbortText(value: string): boolean {\n\tconst normalized = value\n\t\t.trim()\n\t\t.toLowerCase()\n\t\t.replace(/[.!]+$/, \"\");\n\treturn (\n\t\tnormalized === \"operation aborted\" ||\n\t\tnormalized === \"the operation was aborted\" ||\n\t\tnormalized === \"request was aborted\" ||\n\t\tnormalized === \"this operation was aborted\" ||\n\t\tnormalized === \"extension custom ui aborted\"\n\t);\n}\n\nexport function isSingleGenericAbortTextContent(content: unknown): boolean {\n\treturn (\n\t\tArray.isArray(content) &&\n\t\tcontent.length === 1 &&\n\t\ttypeof content[0] === \"object\" &&\n\t\tcontent[0] !== null &&\n\t\t(content[0] as { type?: unknown }).type === \"text\" &&\n\t\ttypeof (content[0] as { text?: unknown }).text === \"string\" &&\n\t\tisGenericAbortText((content[0] as { text: string }).text)\n\t);\n}\n\nexport function replacementAbortContent(text: string): TextContent[] {\n\treturn [{ type: \"text\", text }];\n}\n\nexport interface AgentSessionConfig {\n\tagent: Agent;\n\tsessionManager: SessionManager;\n\tsettingsManager: SettingsManager;\n\tcwd: string;\n\tscopedModels?: Array<{ model: Model<Api>; thinkingLevel?: ThinkingLevel }>;\n\tfallbackModels?: string[];\n\tisFallbackModelAllowed?: (model: Model<Api>, effort: string | undefined) => boolean;\n\tresourceLoader: ResourceLoader;\n\tcustomTools?: ToolDefinition[];\n\tmodelRuntime: ModelRuntime;\n\tcacheWarmer?: import(\"./cache-warmer.ts\").CacheWarmer;\n\tchildSessionOptions?: import(\"./child-session-options.ts\").ChildSessionOptionsResolver;\n\tinitialActiveToolNames?: string[];\n\tusesDefaultTools?: boolean;\n\tallowedToolNames?: string[];\n\texcludedToolNames?: string[];\n\tbaseToolsOverride?: Record<string, AgentTool>;\n\textensionRunnerRef?: { current?: import(\"./extensions/index.js\").ExtensionRunner };\n\tsessionStartEvent?: SessionStartEvent;\n\tsubagentPolicy?: SubagentChildPolicy;\n\t/** Parent-issued shell task owner for an in-process subagent child. */\n\tparentCommandTaskOwner?: import(\"./tasks/child-command-owner.js\").ChildCommandTaskOwner;\n\tsystemPromptTransform?: (prompt: string) => string;\n\t/**\n\t * Transform the canonical session projection whenever it becomes the finalized\n\t * context (session construction, provider requests, boundaries, recovery). The\n\t * durable transcript stays unchanged; only derived context is filtered.\n\t */\n\tcontextProjectionTransform?: (messages: AgentMessage[]) => AgentMessage[];\n\torchestrationContext?: OrchestrationContext;\n}\n\nexport interface ExtensionBindings {\n\thumanInput?: import(\"./extensions/host-input.js\").HostInput | null;\n\tonDiagnostic?: (diagnostic: import(\"./extensions/host-input.js\").HostDiagnostic) => void;\n\tuiContext?: ExtensionUIContext;\n\tmode?: ExtensionMode;\n\tcommandContextActions?: ExtensionCommandContextActions;\n\tshutdownHandler?: ShutdownHandler;\n\tonError?: ExtensionErrorListener;\n}\n\nexport interface AgentSessionReloadOptions {\n\treason?: \"startup\" | \"reload\";\n\t/** Runs after resources and the extension runtime are rebuilt, immediately before session_start. */\n\tbeforeSessionStart?: () => void | Promise<void>;\n\t/** Leave the existing extension runner active unless every extension factory loaded successfully. */\n\tfailOnExtensionErrors?: boolean;\n}\n\nexport type QueuedInputDisposition = \"handled\" | \"queued\";\nexport type PromptDisposition = QueuedInputDisposition | \"started\";\n\nexport interface PromptOptions {\n\t/** Whether to dispatch extension commands and expand skill commands and prompt templates (default: true) */\n\texpandPromptTemplates?: boolean;\n\timages?: ImageContent[];\n\tstreamingBehavior?: \"steer\" | \"followUp\";\n\tsource?: InputSource;\n\t/** Called once when preflight accepts (`true`, with how the prompt was dispatched) or rejects (`false`) the prompt. */\n\tpreflightResult?: (success: boolean, disposition?: PromptDisposition) => void;\n}\n\nexport interface ModelMutationOptions {\n\tpersist?: boolean;\n}\n\nexport interface ModelCycleResult {\n\tmodel: Model<Api>;\n\tthinkingLevel: ThinkingLevel;\n\tisScoped: boolean;\n}\n\nexport interface SessionStats {\n\tsessionFile: string | undefined;\n\tsessionId: string;\n\tuserMessages: number;\n\tassistantMessages: number;\n\ttoolCalls: number;\n\ttoolResults: number;\n\ttotalMessages: number;\n\ttokens: {\n\t\tinput: number;\n\t\toutput: number;\n\t\tcacheRead: number;\n\t\tcacheWrite: number;\n\t\ttotal: number;\n\t};\n\tcost: number;\n\tcontextUsage?: ContextUsage;\n\t/** Usage of the newest assistant message, which the footer's cache-hit rate reads. */\n\tlatestAssistantUsage?: Usage;\n}\n\nexport interface ToolDefinitionEntry {\n\tdefinition: ToolDefinition;\n\tsourceInfo: SourceInfo;\n}\n\nexport const THINKING_LEVELS: ThinkingLevel[] = [\"off\", \"minimal\", \"low\", \"medium\", \"high\", \"xhigh\", \"max\"];\n\nexport function customMessageExcludesContext(message: CustomMessage): boolean {\n\treturn (message as CustomMessage & { excludeFromContext?: boolean }).excludeFromContext === true;\n}\n\nexport type AssistantMessageWithError = AssistantMessage;\n"]}
|
|
@@ -139,6 +139,9 @@ declare class AgentSessionBase {
|
|
|
139
139
|
current?: ExtensionRunner;
|
|
140
140
|
};
|
|
141
141
|
protected _initialActiveToolNames?: string[];
|
|
142
|
+
protected _usesDefaultTools: boolean;
|
|
143
|
+
/** Resolved defaults last applied here, independent of shared settings publication. */
|
|
144
|
+
protected _appliedDefaultTools: Set<string>;
|
|
142
145
|
protected _subagentPolicy?: SubagentChildPolicy;
|
|
143
146
|
protected _allowedToolNames?: Set<string>;
|
|
144
147
|
protected _excludedToolNames?: Set<string>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agent-session.d.ts","sourceRoot":"","sources":["../../src/core/agent-session.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAGH,OAAO,KAAK,EAAE,GAAG,EAAE,gBAAgB,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC;AAC1E,OAAO,KAAK,EAAE,KAAK,EAAE,YAAY,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAC;AAWnG,OAAO,KAAK,EAAE,2BAA2B,EAAE,yBAAyB,EAAE,MAAM,4BAA4B,CAAC;AAEzG,OAAO,KAAK,EAAE,8BAA8B,EAAE,MAAM,yCAAyC,CAAC;AAK9F,OAAO,EAA8B,KAAK,iBAAiB,EAAE,MAAM,4BAA4B,CAAC;AAKhG,OAAO,KAAK,EACX,kBAAkB,EAClB,yBAAyB,EACzB,kBAAkB,EAClB,mBAAmB,EACnB,MAAM,0BAA0B,CAAC;AAClC,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,uBAAuB,CAAC;AACtE,OAAO,KAAK,EACX,oBAAoB,EACpB,8BAA8B,EAC9B,sBAAsB,EACtB,aAAa,EACb,eAAe,EACf,kBAAkB,EAClB,oBAAoB,EACpB,iBAAiB,EACjB,mBAAmB,EACnB,cAAc,EACd,MAAM,uBAAuB,CAAC;AAC/B,OAAO,KAAK,EAAE,oBAAoB,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AACzE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AACvD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAC3D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAC3D,OAAO,KAAK,EAAE,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AuB,EAAE,OAAO,gCAAgC,EAAE,qBAAqB,GAAG,SAAS,CAAC;IAC9G,SAAS,CAAC,eAAe,iBAAwB;IACjD,SAAS,CAAC,qBAAqB,EAAE,OAAO,uBAAuB,EAAE,oBAAoB,GAAG,SAAS,CAAC;IAClG,SAAS,CAAC,cAAc,EAAE,8BAA8B,GAAG,SAAS,CAAC;IACrE,SAAS,CAAC,YAAY,CAAC,EAAE,OAAO,mBAAmB,EAAE,WAAW,CAAC;IACjE,IAAI,kBAAkB,IAAI,OAAO,mBAAmB,EAAE,kBAAkB,GAAG,SAAS,CAEnF;IACD,mBAAmB,CAAC,IAAI,EAAE,OAAO,uBAAuB,EAAE,gBAAgB,GAAG,IAAI,CAGhF;IAED,YAAY,MAAM,EAAE,kBAAkB,EAgJrC;CACD;AAED,MAAM,WAAW,YAAa,SAAQ,gBAAgB,EAAE,yBAAyB;CAAG;AAEpF,eAAO,MAAM,YAAY,EAAkC;IAC1D,KAAK,MAAM,EAAE,kBAAkB,GAAG,YAAY,CAAC;IAC/C,QAAQ,CAAC,SAAS,EAAE,YAAY,CAAC;CACjC,CAAC"}
|
|
@@ -27,6 +27,7 @@ import { agentSessionToolHooksMethods } from "./agent-session-tool-hooks.js";
|
|
|
27
27
|
import { agentSessionToolRegistryMethods } from "./agent-session-tool-registry.js";
|
|
28
28
|
import { agentSessionTreeMethods } from "./agent-session-tree.js";
|
|
29
29
|
import { ChildTaskWaits } from "./tasks/child-command-owner.js";
|
|
30
|
+
import { getDefaultToolNames } from "./tools/index.js";
|
|
30
31
|
import { scheduleSessionTempCleanup } from "./tools/session-temp-cleanup.js";
|
|
31
32
|
import { acquireProtectedPaths, setActiveSessionTempId } from "./tools/session-temp-dir.js";
|
|
32
33
|
import { ToolExecutionScheduler } from "./tools/tool-concurrency.js";
|
|
@@ -137,6 +138,9 @@ class AgentSessionBase {
|
|
|
137
138
|
_cwd;
|
|
138
139
|
_extensionRunnerRef;
|
|
139
140
|
_initialActiveToolNames;
|
|
141
|
+
_usesDefaultTools;
|
|
142
|
+
/** Resolved defaults last applied here, independent of shared settings publication. */
|
|
143
|
+
_appliedDefaultTools;
|
|
140
144
|
_subagentPolicy;
|
|
141
145
|
_allowedToolNames;
|
|
142
146
|
_excludedToolNames;
|
|
@@ -201,6 +205,8 @@ class AgentSessionBase {
|
|
|
201
205
|
this._extensionProviderIds = new Set(config.resourceLoader.getExtensions().runtime.extensionProviderIds);
|
|
202
206
|
this._extensionRunnerRef = config.extensionRunnerRef;
|
|
203
207
|
this._initialActiveToolNames = config.initialActiveToolNames;
|
|
208
|
+
this._usesDefaultTools = config.usesDefaultTools ?? false;
|
|
209
|
+
this._appliedDefaultTools = new Set(this._usesDefaultTools ? (this.settingsManager.getDefaultTools() ?? getDefaultToolNames()) : []);
|
|
204
210
|
this._allowedToolNames = config.allowedToolNames ? new Set(config.allowedToolNames) : undefined;
|
|
205
211
|
this._excludedToolNames = config.excludedToolNames ? new Set(config.excludedToolNames) : undefined;
|
|
206
212
|
this._childSessionOptions = config.childSessionOptions;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agent-session.js","sourceRoot":"","sources":["../../src/core/agent-session.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAGjC,OAAO,EAAE,4BAA4B,EAAE,MAAM,8BAA8B,CAAC;AAC5E,OAAO,EAAE,iCAAiC,EAAE,MAAM,oCAAoC,CAAC;AACvF,OAAO,EAAE,uBAAuB,EAAE,MAAM,yBAAyB,CAAC;AAClE,OAAO,EAAE,2BAA2B,EAAE,MAAM,+BAA+B,CAAC;AAC5E,OAAO,EAAE,6BAA6B,EAAE,MAAM,+BAA+B,CAAC;AAC9E,OAAO,EAAE,sCAAsC,EAAE,MAAM,0CAA0C,CAAC;AAClG,OAAO,EAAE,yBAAyB,EAAE,MAAM,2BAA2B,CAAC;AACtE,OAAO,EAAE,yBAAyB,EAAE,MAAM,2BAA2B,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QAAQ,CAAC,MAAM;gBAClB,MAAM,MAAM,CAAC,MAAM,CAAC,IAAI,cAAc,CAAC,CAAC,KAAK,EAAE,GAAG,QAAQ,CAAC,EAAE,qCAAqC,CAAC,EAAE;oBACpG,IAAI,EAAE,gBAAgB;iBACtB,CAAC,CAAC;YACJ,MAAM,KAAK,CAAC;QACb,CAAC;IACF,CAAC;CACD;AAID,MAAM,CAAC,MAAM,YAAY,GAAG,gBAG3B,CAAC;AAEF,4BAA4B,CAAC,YAAY,CAAC,SAAmD,CAAC,CAAC;AAC/F,MAAM,CAAC,MAAM,CACZ,YAAY,CAAC,SAAS,EACtB,4BAA4B,EAC5B,2BAA2B,EAC3B,yBAAyB,EACzB,wBAAwB,EACxB,yBAAyB,EACzB,sCAAsC,EACtC,+BAA+B,EAC/B,yBAAyB,EACzB,6BAA6B,EAC7B,iCAAiC,EACjC,qCAAqC,EACrC,oCAAoC,EACpC,+BAA+B,EAC/B,wBAAwB,EACxB,uBAAuB,EACvB,uBAAuB,EACvB,yBAAyB,EACzB,0BAA0B,EAC1B,uBAAuB,CACvB,CAAC","sourcesContent":["/**\n * AgentSession - Core abstraction for agent lifecycle and session management.\n *\n * The historical import path is preserved here as a facade. Responsibilities are\n * implemented in sibling modules by lifecycle area so each authored source file\n * stays focused.\n */\n\nimport { join } from \"node:path\";\nimport type { Api, AssistantMessage, Model } from \"@bastani/pi-ai/compat\";\nimport type { Agent, AgentMessage, AgentTool, ThinkingLevel } from \"@earendil-works/pi-agent-core\";\nimport { installAgentSessionAccessors } from \"./agent-session-accessors.ts\";\nimport { agentSessionAutoCompactionMethods } from \"./agent-session-auto-compaction.ts\";\nimport { agentSessionBashMethods } from \"./agent-session-bash.ts\";\nimport { agentSessionBoundaryMethods } from \"./agent-session-boundaries.ts\";\nimport { agentSessionCompactionMethods } from \"./agent-session-compaction.ts\";\nimport { agentSessionCustomMessageCommitMethods } from \"./agent-session-custom-message-commit.ts\";\nimport { agentSessionEventsMethods } from \"./agent-session-events.ts\";\nimport { agentSessionExportMethods } from \"./agent-session-export.ts\";\nimport { agentSessionExtensionBindingsMethods } from \"./agent-session-extension-bindings.ts\";\nimport { agentSessionMessageQueueMethods } from \"./agent-session-message-queue.ts\";\nimport type { AgentSessionInternalSurface, AgentSessionPublicSurface } from \"./agent-session-methods.ts\";\nimport { agentSessionModelsMethods } from \"./agent-session-models.ts\";\nimport type { PendingPostToolCompactionGuard } from \"./agent-session-post-tool-compaction.ts\";\nimport { agentSessionPostToolCompactionMethods } from \"./agent-session-post-tool-compaction.ts\";\nimport { agentSessionPromptMethods } from \"./agent-session-prompt.ts\";\nimport { agentSessionRetryMethods } from \"./agent-session-retry.ts\";\nimport { agentSessionStateMethods } from \"./agent-session-state.ts\";\nimport { agentSessionSummaryMethods, type SessionSummaryRun } from \"./agent-session-summary.ts\";\nimport { agentSessionTaskMethods, isSubagentChildSession } from \"./agent-session-tasks.js\";\nimport { agentSessionToolHooksMethods } from \"./agent-session-tool-hooks.ts\";\nimport { agentSessionToolRegistryMethods } from \"./agent-session-tool-registry.ts\";\nimport { agentSessionTreeMethods } from \"./agent-session-tree.ts\";\nimport type {\n\tAgentSessionConfig,\n\tAgentSessionEventListener,\n\tInterruptQueueHold,\n\tToolDefinitionEntry,\n} from \"./agent-session-types.js\";\nimport type { VerbatimCompactionResult } from \"./compaction/index.ts\";\nimport type {\n\tAgentActivityOutcome,\n\tExtensionCommandContextActions,\n\tExtensionErrorListener,\n\tExtensionMode,\n\tExtensionRunner,\n\tExtensionUIContext,\n\tOrchestrationContext,\n\tSessionStartEvent,\n\tSubagentChildPolicy,\n\tToolDefinition,\n} from \"./extensions/index.js\";\nimport type { BashExecutionMessage, CustomMessage } from \"./messages.ts\";\nimport type { ModelRuntime } from \"./model-runtime.js\";\nimport type { ResourceLoader } from \"./resource-loader.ts\";\nimport type { SessionManager } from \"./session-manager.ts\";\nimport type { SettingsManager } from \"./settings-manager.ts\";\nimport type { NormalizedBuildSystemPromptOptions } from \"./system-prompt.ts\";\nimport { ChildTaskWaits } from \"./tasks/child-command-owner.js\";\nimport { scheduleSessionTempCleanup } from \"./tools/session-temp-cleanup.ts\";\nimport { acquireProtectedPaths, type ProtectedPathLease, setActiveSessionTempId } from \"./tools/session-temp-dir.ts\";\nimport { ToolExecutionScheduler } from \"./tools/tool-concurrency.ts\";\nimport { TOOL_RESULTS_SUBDIR } from \"./tools/tool-limits.js\";\nimport { WorkflowStageAdmissionBoundary } from \"./workflow-stage-admission.ts\";\n\nexport type { ParsedSkillBlock } from \"./agent-session-skill-block.ts\";\nexport { parseSkillBlock } from \"./agent-session-skill-block.ts\";\nexport type {\n\tAgentSessionConfig,\n\tAgentSessionEvent,\n\tAgentSessionEventListener,\n\tCompactionReason,\n\tExtensionBindings,\n\tModelCycleResult,\n\tPromptDisposition,\n\tPromptOptions,\n\tQueuedInputDisposition,\n\tSessionStats,\n} from \"./agent-session-types.js\";\n\nclass AgentSessionBase {\n\treadonly agent: Agent;\n\treadonly sessionManager: SessionManager;\n\treadonly settingsManager: SettingsManager;\n\n\tprotected _scopedModels: Array<{ model: Model<Api>; thinkingLevel?: ThinkingLevel }>;\n\tprotected _fallbackModels: string[];\n\tprotected _isFallbackModelAllowed?: (model: Model<Api>, effort: string | undefined) => boolean;\n\tprotected _fallbackAttemptedKeys: Set<string> = new Set();\n\t/** Models condemned for this turn by a failure retrying them cannot repair. */\n\tprotected _fallbackBlockedModels: Array<Model<Api>> = [];\n\tprotected _fallbackOriginModel: Model<Api> | undefined;\n\tprotected _fallbackOriginThinkingLevel: ThinkingLevel | undefined;\n\tprotected _fallbackScopeGeneration = 0;\n\tprotected _fallbackOriginGeneration: number | undefined;\n\tprotected _fallbackRestoreError: string | undefined;\n\tprotected _unsubscribeAgent?: () => void;\n\tprotected _eventListeners: AgentSessionEventListener[] = [];\n\tprotected _agentEventQueue: Promise<void> = Promise.resolve();\n\tprotected _steeringMessages: string[] = [];\n\tprotected _followUpMessages: string[] = [];\n\tprotected _interruptDeliveryQueue: Promise<void> = Promise.resolve();\n\tprotected _pendingInterruptDeliveries = 0;\n\tprotected _activeInterruptQueueHold: InterruptQueueHold | undefined = undefined;\n\tprotected _queuedMessagesPaused = false;\n\tprotected _queuedMessagesPauseAbortBoundary: Promise<void> | undefined = undefined;\n\t/**\n\t * Text of a queued steering/follow-up message the agent loop already admitted\n\t * into the transcript and that has not received an assistant reply yet. The\n\t * pause hold cannot reach such a message, so an interrupt would otherwise\n\t * strand it (issue #2362).\n\t */\n\tprotected _admittedQueuedMessageAwaitingReply: string | undefined = undefined;\n\t/**\n\t * Settlement boundary for the recovery turn that answers an already-admitted\n\t * queued message. It starts after the pause abort boundary resolves, so the\n\t * resume path must wait for it too or an ordinary submission made while it\n\t * streams is rejected by the streaming guard (issue #2362).\n\t */\n\tprotected _admittedRecoveryTurn: Promise<void> | undefined = undefined;\n\tprotected _workflowStageDeliveryForwardTarget: AgentSessionInternalSurface | undefined = undefined;\n\tprotected _activeInterruptAbortMessage: string | undefined = undefined;\n\t/** Priority input cancels the native operation, not the host-owned task. */\n\tprotected _priorityInterruptPending = false;\n\tprotected _activePromptCount = 0;\n\tprotected _agentRunAbortRequested = false;\n\tprotected _pendingNextTurnMessages: CustomMessage[] = [];\n\t/** Context-only custom messages queued during a run, flushed after the current turn's tool results. */\n\tprotected _pendingCustomMessages: CustomMessage[] = [];\n\tprotected _protectedStreamingCustomMessages: Array<{\n\t\tmessage: CustomMessage;\n\t\tdelivery: \"steer\" | \"followUp\";\n\t\tphase: \"queued\" | \"consumed-unpersisted\" | \"persistence-failed\";\n\t}> = [];\n\tprotected _compactionAbortController: AbortController | undefined = undefined;\n\tprotected _compactionReason: import(\"./agent-session-types.js\").CompactionReason | undefined = undefined;\n\tprotected _manualCompactionPromise: Promise<VerbatimCompactionResult> | undefined = undefined;\n\tprotected _autoCompactionAbortController: AbortController | undefined = undefined;\n\t/** Resolves when the current automatic compaction has settled. */\n\tprotected _autoCompactionCompletion: Promise<void> | undefined = undefined;\n\tprotected _overflowRecoveryAttempted = false;\n\tprotected _recoverableLengthRecoveryAttempted = false;\n\t/** Set when compaction cannot recover a context overflow on the current model. */\n\tprotected _contextOverflowUnresolved = false;\n\tprotected _pendingPostCompactionContinuation: Promise<void> | undefined = undefined;\n\tprotected _postCompactionContinuationToken = 0;\n\tprotected _lengthContinuationAttempts = 0;\n\tprotected _outputBudgetErrorContinuationAttempts = 0;\n\tprotected _postToolCompactionPreflightError: string | undefined = undefined;\n\tprotected _pendingPostToolCompactionGuard: PendingPostToolCompactionGuard | undefined = undefined;\n\tprotected _terminatingToolCallIds = new Set<string>();\n\t/** A positive stop callback keeps queued work pending until an explicit new run. */\n\tprotected _stopAfterTurnBlockedContinuation = false;\n\tprotected _disposed = false;\n\tprotected _branchSummaryAbortController: AbortController | undefined = undefined;\n\t/** Settles after the currently active branch-summary navigation finishes cleanup. */\n\tprotected _branchSummaryCompletion: Promise<void> | undefined = undefined;\n\tprotected _sessionSummaryAbortController: AbortController | undefined = undefined;\n\tprotected _sessionSummaryToken = 0;\n\t/** The summary request currently in flight, published so a later launch can join it. */\n\tprotected _sessionSummaryRun: SessionSummaryRun | undefined = undefined;\n\tprotected _lastSummarizedMessageId: string | undefined = undefined;\n\tprotected _retryAbortController: AbortController | undefined = undefined;\n\tprotected _retryAttempt = 0;\n\tprotected _retryPromise: Promise<void> | undefined = undefined;\n\tprotected _retryResolve: (() => void) | undefined = undefined;\n\tprotected _bashAbortControllers = new Map<string | symbol, Set<AbortController>>();\n\tprotected _pendingBashMessages: BashExecutionMessage[] = [];\n\tprotected _extensionRunner!: ExtensionRunner;\n\tprotected _turnIndex = 0;\n\t/** Source entry IDs for projected messages, so boundaries and omissions resolve provenance. */\n\tprotected readonly _entryIdsByMessage = new WeakMap<object, string>();\n\t/** Assistant messages whose actionable turn_end already ran from finishTurn. */\n\tprotected readonly _boundaryDispatchedMessages = new WeakSet<object>();\n\tprotected readonly _messagesAwaitingPersistence = new WeakSet<object>();\n\tprotected _lastAssistantToolResults: AgentMessage[] = [];\n\tprotected _lastActivityOutcome: AgentActivityOutcome = \"completed\";\n\tprotected _isBeforeSettle = false;\n\tprotected _abortDuringBeforeSettle = false;\n\tprotected _isEmittingAgentSettled = false;\n\tprotected readonly _deferredSettledActions: Array<() => Promise<void>> = [];\n\t/** Set when a caller's prepareNextTurnWithContext replaced the next request's context. */\n\tprotected _callerReplacedNextRequestContext = false;\n\tprotected _resourceLoader: ResourceLoader;\n\tprotected _customTools: ToolDefinition[];\n\tprotected _baseToolDefinitions: Map<string, ToolDefinition> = new Map();\n\tprotected _cwd: string;\n\tprotected _extensionRunnerRef?: { current?: ExtensionRunner };\n\tprotected _initialActiveToolNames?: string[];\n\tprotected _subagentPolicy?: SubagentChildPolicy;\n\tprotected _allowedToolNames?: Set<string>;\n\tprotected _excludedToolNames?: Set<string>;\n\tprotected _childSessionOptions?: import(\"./child-session-options.ts\").ChildSessionOptionsResolver;\n\tprotected _baseToolsOverride?: Record<string, AgentTool>;\n\tprotected _sessionStartEvent: SessionStartEvent;\n\tprotected _orchestrationContext?: OrchestrationContext;\n\tprotected _extensionUIContext?: ExtensionUIContext;\n\tprotected _extensionHumanInput?: import(\"./extensions/host-input.js\").HostInput | null;\n\tprotected _extensionDiagnosticListener?: (diagnostic: import(\"./extensions/host-input.js\").HostDiagnostic) => void;\n\tprotected _extensionMode: ExtensionMode = \"print\";\n\tprotected _extensionCommandContextActions?: ExtensionCommandContextActions;\n\tprotected _extensionShutdownHandler?: () => void;\n\tprotected _extensionErrorListener?: ExtensionErrorListener;\n\tprotected _extensionErrorUnsubscriber?: () => void;\n\tprotected _modelRuntime: ModelRuntime;\n\tprotected _extensionProviderIds = new Set<string>();\n\tprotected _toolRegistry: Map<string, AgentTool> = new Map();\n\tprotected readonly _toolExecutionScheduler = new ToolExecutionScheduler();\n\tprotected _toolDefinitions: Map<string, ToolDefinitionEntry> = new Map();\n\tprotected _toolPromptSnippets: Map<string, string> = new Map();\n\tprotected _toolPromptGuidelines: Map<string, string[]> = new Map();\n\tprotected _baseSystemPromptOptions!: NormalizedBuildSystemPromptOptions;\n\tprotected _systemPromptTransform?: (prompt: string) => string;\n\tprotected _contextProjectionTransform?: (messages: AgentMessage[]) => AgentMessage[];\n\tprotected _runSystemPromptOptions?: NormalizedBuildSystemPromptOptions;\n\tprotected _lastAssistantMessage: AssistantMessage | undefined = undefined;\n\t/** Protection claim on this session's temp tree and tool-results directory. */\n\tprotected _tempStorageLease: ProtectedPathLease | undefined;\n\tprotected _workflowStageAdmission: WorkflowStageAdmissionBoundary | undefined;\n\tprotected _subagentMessageAdmission: WorkflowStageAdmissionBoundary | undefined;\n\tprotected _agentTaskHost: import(\"./tasks/agent-adapter.js\").AgentTaskHost | undefined;\n\tprotected _parentCommandTaskOwner: import(\"./tasks/child-command-owner.js\").ChildCommandTaskOwner | undefined;\n\tprotected _childTaskWaits = new ChildTaskWaits();\n\tprotected _taskCompletionOutbox: import(\"./tasks/completion.js\").TaskCompletionOutbox | undefined;\n\tprotected _taskAdmission: WorkflowStageAdmissionBoundary | undefined;\n\tprotected _cacheWarmer?: import(\"./cache-warmer.ts\").CacheWarmer;\n\tget cacheWarmingStatus(): import(\"./cache-warmer.ts\").CacheWarmingStatus | undefined {\n\t\treturn this._cacheWarmer?.status;\n\t}\n\tsetCacheWarmingMode(mode: import(\"./settings-manager.ts\").CacheWarmingMode): void {\n\t\tthis.settingsManager.setCacheWarmingMode(mode);\n\t\tthis._cacheWarmer?.onModeChanged();\n\t}\n\n\tconstructor(config: AgentSessionConfig) {\n\t\tthis.agent = config.agent;\n\t\tthis.sessionManager = config.sessionManager;\n\t\tthis.settingsManager = config.settingsManager;\n\t\tthis._scopedModels = config.scopedModels ?? [];\n\t\tthis._fallbackModels = config.fallbackModels ?? [];\n\t\tthis._isFallbackModelAllowed = config.isFallbackModelAllowed;\n\t\tthis._resourceLoader = config.resourceLoader;\n\t\tthis._customTools = config.customTools ?? [];\n\t\tthis._cwd = config.cwd;\n\t\tthis._modelRuntime = config.modelRuntime;\n\t\tthis._cacheWarmer = config.cacheWarmer;\n\t\tif (this._cacheWarmer)\n\t\t\tthis._cacheWarmer.onWarmed = (entry) =>\n\t\t\t\t(this as unknown as import(\"./agent-session-methods.ts\").AgentSessionInternalSurface)._emit({\n\t\t\t\t\ttype: \"entry_appended\",\n\t\t\t\t\tentry,\n\t\t\t\t});\n\t\tthis._extensionProviderIds = new Set(config.resourceLoader.getExtensions().runtime.extensionProviderIds);\n\t\tthis._extensionRunnerRef = config.extensionRunnerRef;\n\t\tthis._initialActiveToolNames = config.initialActiveToolNames;\n\t\tthis._allowedToolNames = config.allowedToolNames ? new Set(config.allowedToolNames) : undefined;\n\t\tthis._excludedToolNames = config.excludedToolNames ? new Set(config.excludedToolNames) : undefined;\n\t\tthis._childSessionOptions = config.childSessionOptions;\n\t\tthis._baseToolsOverride = config.baseToolsOverride;\n\t\tthis._sessionStartEvent = config.sessionStartEvent ?? { type: \"session_start\", reason: \"startup\" };\n\t\tthis._orchestrationContext = config.orchestrationContext;\n\t\tthis._subagentPolicy = config.subagentPolicy;\n\t\tthis._parentCommandTaskOwner = config.parentCommandTaskOwner;\n\t\tlet removeExecutionEndedListener: (() => void) | undefined;\n\t\ttry {\n\t\t\tif (config.subagentPolicy?.executionEnded !== undefined) {\n\t\t\t\t// Reuse the stable-key admission/drain primitive, not workflow identity or task ownership.\n\t\t\t\tconst admission = WorkflowStageAdmissionBoundary.restore(this.sessionManager.getBranch());\n\t\t\t\tthis._subagentMessageAdmission = admission;\n\t\t\t\tthis._subagentPolicy = {\n\t\t\t\t\t...config.subagentPolicy,\n\t\t\t\t\tmessageAdmission: {\n\t\t\t\t\t\tisOpen: () => admission.isOpen(),\n\t\t\t\t\t\trun: (deliver) =>\n\t\t\t\t\t\t\tadmission.runMessageDelivery(deliver, () => {\n\t\t\t\t\t\t\t\tthrow new Error(\"Subagent execution is terminal and cannot accept messages\");\n\t\t\t\t\t\t\t}),\n\t\t\t\t\t},\n\t\t\t\t};\n\t\t\t\tconst ended = config.subagentPolicy.executionEnded;\n\t\t\t\tif (ended.aborted) admission.seal();\n\t\t\t\telse {\n\t\t\t\t\tconst seal = () => admission.seal();\n\t\t\t\t\tended.addEventListener(\"abort\", seal, { once: true });\n\t\t\t\t\tremoveExecutionEndedListener = () => ended.removeEventListener(\"abort\", seal);\n\t\t\t\t}\n\t\t\t}\n\t\t\tthis._systemPromptTransform = config.systemPromptTransform;\n\t\t\tthis._contextProjectionTransform = config.contextProjectionTransform;\n\t\t\tconst stageContext =\n\t\t\t\tconfig.orchestrationContext?.kind === \"workflow-stage\" ? config.orchestrationContext : undefined;\n\t\t\tthis._workflowStageAdmission =\n\t\t\t\tstageContext?.messageAdmission?.boundary ??\n\t\t\t\t(stageContext ? WorkflowStageAdmissionBoundary.restore(this.sessionManager.getBranch()) : undefined);\n\t\t\tif (stageContext) {\n\t\t\t\tthis._workflowStageAdmission?.bindTaskIdentity(\n\t\t\t\t\tthis.sessionManager.getSessionId(),\n\t\t\t\t\tstageContext.workflowRunId,\n\t\t\t\t\tstageContext.workflowStageId,\n\t\t\t\t);\n\t\t\t}\n\t\t\tif (this._workflowStageAdmission && stageContext && stageContext.messageAdmission === undefined) {\n\t\t\t\t(\n\t\t\t\t\tstageContext as {\n\t\t\t\t\t\tmessageAdmission?: {\n\t\t\t\t\t\t\tboundary: WorkflowStageAdmissionBoundary;\n\t\t\t\t\t\t\textensionState: Map<string, object>;\n\t\t\t\t\t\t\tisOpen(): boolean;\n\t\t\t\t\t\t};\n\t\t\t\t\t}\n\t\t\t\t).messageAdmission = {\n\t\t\t\t\tboundary: this._workflowStageAdmission,\n\t\t\t\t\textensionState: new Map(),\n\t\t\t\t\tisOpen: () => this._workflowStageAdmission?.isOpen() === true,\n\t\t\t\t};\n\t\t\t}\n\t\t\t// Claim this session's storage before any tool can spill into it, so the\n\t\t\t// sweeper below never reaps a directory this process is still writing to.\n\t\t\t// The claim is a lease, released in dispose(): a session that is gone must\n\t\t\t// stop protecting a tree the startup sweep exists to collect.\n\t\t\ttry {\n\t\t\t\tconst sessionId = this.sessionManager.getSessionId();\n\t\t\t\tconst sessionDir = this.sessionManager.getSessionDir() || undefined;\n\t\t\t\tthis._tempStorageLease = acquireProtectedPaths([\n\t\t\t\t\tsetActiveSessionTempId(sessionId),\n\t\t\t\t\t// A disk-backed session's results are read back by path, and a replayed\n\t\t\t\t\t// result reuses an old file without touching its mtime, so age alone\n\t\t\t\t\t// cannot keep it alive.\n\t\t\t\t\t...(sessionDir ? [join(sessionDir, TOOL_RESULTS_SUBDIR)] : []),\n\t\t\t\t]);\n\t\t\t\t// A custom `--session-dir` keeps its tool results directly under that\n\t\t\t\t// directory, outside the project-nested roots the default sweep walks,\n\t\t\t\t// so it has to be named as its own target.\n\t\t\t\tconst customSessionDir = this.sessionManager.usesDefaultSessionDir() ? undefined : sessionDir;\n\t\t\t\tscheduleSessionTempCleanup(customSessionDir ? { sessionDirs: [customSessionDir] } : {});\n\t\t\t} catch {\n\t\t\t\t// Temp-storage housekeeping must never block session construction.\n\t\t\t}\n\t\t\tconst internals = this as unknown as AgentSessionInternalSurface;\n\t\t\tinternals._handleAgentEvent = internals._handleAgentEvent.bind(this);\n\t\t\tthis._unsubscribeAgent = this.agent.subscribe(internals._handleAgentEvent);\n\t\t\tinternals._installAgentToolHooks();\n\t\t\tinternals._installAgentNextTurnRefresh();\n\t\t\tinternals._installAgentRequestProjection();\n\t\t\tinternals._installAgentBoundaryHooks();\n\t\t\tinternals._buildRuntime({\n\t\t\t\tactiveToolNames: this._initialActiveToolNames,\n\t\t\t\tincludeAllExtensionTools: true,\n\t\t\t});\n\t\t\tif (this._initialActiveToolNames === undefined) internals._restoreToolsFromTranscript();\n\t\t\tif (this._workflowStageAdmission?.hasAgentTaskHost() && !isSubagentChildSession(internals))\n\t\t\t\tinternals.getAgentTaskHost();\n\t\t} catch (error) {\n\t\t\t// No session escapes a failed constructor to release these acquisitions later.\n\t\t\tconst failures: unknown[] = [];\n\t\t\tfor (const release of [\n\t\t\t\t() => removeExecutionEndedListener?.(),\n\t\t\t\t() => this._unsubscribeAgent?.(),\n\t\t\t\t() => this._tempStorageLease?.release(),\n\t\t\t\t() => this._extensionRunner?.invalidate(\"Session construction failed\"),\n\t\t\t]) {\n\t\t\t\ttry {\n\t\t\t\t\trelease();\n\t\t\t\t} catch (cause) {\n\t\t\t\t\tfailures.push(cause);\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (this._extensionRunnerRef) this._extensionRunnerRef.current = undefined;\n\t\t\tif (failures.length)\n\t\t\t\tthrow Object.assign(new AggregateError([error, ...failures], \"Session construction cleanup failed\"), {\n\t\t\t\t\tcode: \"ShutdownFailed\",\n\t\t\t\t});\n\t\t\tthrow error;\n\t\t}\n\t}\n}\n\nexport interface AgentSession extends AgentSessionBase, AgentSessionPublicSurface {}\n\nexport const AgentSession = AgentSessionBase as unknown as {\n\tnew (config: AgentSessionConfig): AgentSession;\n\treadonly prototype: AgentSession;\n};\n\ninstallAgentSessionAccessors(AgentSession.prototype as unknown as AgentSessionInternalSurface);\nObject.assign(\n\tAgentSession.prototype,\n\tagentSessionToolHooksMethods,\n\tagentSessionBoundaryMethods,\n\tagentSessionEventsMethods,\n\tagentSessionStateMethods,\n\tagentSessionPromptMethods,\n\tagentSessionCustomMessageCommitMethods,\n\tagentSessionMessageQueueMethods,\n\tagentSessionModelsMethods,\n\tagentSessionCompactionMethods,\n\tagentSessionAutoCompactionMethods,\n\tagentSessionPostToolCompactionMethods,\n\tagentSessionExtensionBindingsMethods,\n\tagentSessionToolRegistryMethods,\n\tagentSessionRetryMethods,\n\tagentSessionBashMethods,\n\tagentSessionTreeMethods,\n\tagentSessionExportMethods,\n\tagentSessionSummaryMethods,\n\tagentSessionTaskMethods,\n);\n"]}
|
|
1
|
+
{"version":3,"file":"agent-session.js","sourceRoot":"","sources":["../../src/core/agent-session.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAGj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BAAwB,EACxB,yBAAyB,EACzB,sCAAsC,EACtC,+BAA+B,EAC/B,yBAAyB,EACzB,6BAA6B,EAC7B,iCAAiC,EACjC,qCAAqC,EACrC,oCAAoC,EACpC,+BAA+B,EAC/B,wBAAwB,EACxB,uBAAuB,EACvB,uBAAuB,EACvB,yBAAyB,EACzB,0BAA0B,EAC1B,uBAAuB,CACvB,CAAC","sourcesContent":["/**\n * AgentSession - Core abstraction for agent lifecycle and session management.\n *\n * The historical import path is preserved here as a facade. Responsibilities are\n * implemented in sibling modules by lifecycle area so each authored source file\n * stays focused.\n */\n\nimport { join } from \"node:path\";\nimport type { Api, AssistantMessage, Model } from \"@bastani/pi-ai/compat\";\nimport type { Agent, AgentMessage, AgentTool, ThinkingLevel } from \"@earendil-works/pi-agent-core\";\nimport { installAgentSessionAccessors } from \"./agent-session-accessors.ts\";\nimport { agentSessionAutoCompactionMethods } from \"./agent-session-auto-compaction.ts\";\nimport { agentSessionBashMethods } from \"./agent-session-bash.ts\";\nimport { agentSessionBoundaryMethods } from \"./agent-session-boundaries.ts\";\nimport { agentSessionCompactionMethods } from \"./agent-session-compaction.ts\";\nimport { agentSessionCustomMessageCommitMethods } from \"./agent-session-custom-message-commit.ts\";\nimport { agentSessionEventsMethods } from \"./agent-session-events.ts\";\nimport { agentSessionExportMethods } from \"./agent-session-export.ts\";\nimport { agentSessionExtensionBindingsMethods } from \"./agent-session-extension-bindings.ts\";\nimport { agentSessionMessageQueueMethods } from \"./agent-session-message-queue.ts\";\nimport type { AgentSessionInternalSurface, AgentSessionPublicSurface } from \"./agent-session-methods.ts\";\nimport { agentSessionModelsMethods } from \"./agent-session-models.ts\";\nimport type { PendingPostToolCompactionGuard } from \"./agent-session-post-tool-compaction.ts\";\nimport { agentSessionPostToolCompactionMethods } from \"./agent-session-post-tool-compaction.ts\";\nimport { agentSessionPromptMethods } from \"./agent-session-prompt.ts\";\nimport { agentSessionRetryMethods } from \"./agent-session-retry.ts\";\nimport { agentSessionStateMethods } from \"./agent-session-state.ts\";\nimport { agentSessionSummaryMethods, type SessionSummaryRun } from \"./agent-session-summary.ts\";\nimport { agentSessionTaskMethods, isSubagentChildSession } from \"./agent-session-tasks.js\";\nimport { agentSessionToolHooksMethods } from \"./agent-session-tool-hooks.ts\";\nimport { agentSessionToolRegistryMethods } from \"./agent-session-tool-registry.ts\";\nimport { agentSessionTreeMethods } from \"./agent-session-tree.ts\";\nimport type {\n\tAgentSessionConfig,\n\tAgentSessionEventListener,\n\tInterruptQueueHold,\n\tToolDefinitionEntry,\n} from \"./agent-session-types.js\";\nimport type { VerbatimCompactionResult } from \"./compaction/index.ts\";\nimport type {\n\tAgentActivityOutcome,\n\tExtensionCommandContextActions,\n\tExtensionErrorListener,\n\tExtensionMode,\n\tExtensionRunner,\n\tExtensionUIContext,\n\tOrchestrationContext,\n\tSessionStartEvent,\n\tSubagentChildPolicy,\n\tToolDefinition,\n} from \"./extensions/index.js\";\nimport type { BashExecutionMessage, CustomMessage } from \"./messages.ts\";\nimport type { ModelRuntime } from \"./model-runtime.js\";\nimport type { ResourceLoader } from \"./resource-loader.ts\";\nimport type { SessionManager } from \"./session-manager.ts\";\nimport type { SettingsManager } from \"./settings-manager.ts\";\nimport type { NormalizedBuildSystemPromptOptions } from \"./system-prompt.ts\";\nimport { ChildTaskWaits } from \"./tasks/child-command-owner.js\";\nimport { getDefaultToolNames } from \"./tools/index.ts\";\nimport { scheduleSessionTempCleanup } from \"./tools/session-temp-cleanup.ts\";\nimport { acquireProtectedPaths, type ProtectedPathLease, setActiveSessionTempId } from \"./tools/session-temp-dir.ts\";\nimport { ToolExecutionScheduler } from \"./tools/tool-concurrency.ts\";\nimport { TOOL_RESULTS_SUBDIR } from \"./tools/tool-limits.js\";\nimport { WorkflowStageAdmissionBoundary } from \"./workflow-stage-admission.ts\";\n\nexport type { ParsedSkillBlock } from \"./agent-session-skill-block.ts\";\nexport { parseSkillBlock } from \"./agent-session-skill-block.ts\";\nexport type {\n\tAgentSessionConfig,\n\tAgentSessionEvent,\n\tAgentSessionEventListener,\n\tCompactionReason,\n\tExtensionBindings,\n\tModelCycleResult,\n\tPromptDisposition,\n\tPromptOptions,\n\tQueuedInputDisposition,\n\tSessionStats,\n} from \"./agent-session-types.js\";\n\nclass AgentSessionBase {\n\treadonly agent: Agent;\n\treadonly sessionManager: SessionManager;\n\treadonly settingsManager: SettingsManager;\n\n\tprotected _scopedModels: Array<{ model: Model<Api>; thinkingLevel?: ThinkingLevel }>;\n\tprotected _fallbackModels: string[];\n\tprotected _isFallbackModelAllowed?: (model: Model<Api>, effort: string | undefined) => boolean;\n\tprotected _fallbackAttemptedKeys: Set<string> = new Set();\n\t/** Models condemned for this turn by a failure retrying them cannot repair. */\n\tprotected _fallbackBlockedModels: Array<Model<Api>> = [];\n\tprotected _fallbackOriginModel: Model<Api> | undefined;\n\tprotected _fallbackOriginThinkingLevel: ThinkingLevel | undefined;\n\tprotected _fallbackScopeGeneration = 0;\n\tprotected _fallbackOriginGeneration: number | undefined;\n\tprotected _fallbackRestoreError: string | undefined;\n\tprotected _unsubscribeAgent?: () => void;\n\tprotected _eventListeners: AgentSessionEventListener[] = [];\n\tprotected _agentEventQueue: Promise<void> = Promise.resolve();\n\tprotected _steeringMessages: string[] = [];\n\tprotected _followUpMessages: string[] = [];\n\tprotected _interruptDeliveryQueue: Promise<void> = Promise.resolve();\n\tprotected _pendingInterruptDeliveries = 0;\n\tprotected _activeInterruptQueueHold: InterruptQueueHold | undefined = undefined;\n\tprotected _queuedMessagesPaused = false;\n\tprotected _queuedMessagesPauseAbortBoundary: Promise<void> | undefined = undefined;\n\t/**\n\t * Text of a queued steering/follow-up message the agent loop already admitted\n\t * into the transcript and that has not received an assistant reply yet. The\n\t * pause hold cannot reach such a message, so an interrupt would otherwise\n\t * strand it (issue #2362).\n\t */\n\tprotected _admittedQueuedMessageAwaitingReply: string | undefined = undefined;\n\t/**\n\t * Settlement boundary for the recovery turn that answers an already-admitted\n\t * queued message. It starts after the pause abort boundary resolves, so the\n\t * resume path must wait for it too or an ordinary submission made while it\n\t * streams is rejected by the streaming guard (issue #2362).\n\t */\n\tprotected _admittedRecoveryTurn: Promise<void> | undefined = undefined;\n\tprotected _workflowStageDeliveryForwardTarget: AgentSessionInternalSurface | undefined = undefined;\n\tprotected _activeInterruptAbortMessage: string | undefined = undefined;\n\t/** Priority input cancels the native operation, not the host-owned task. */\n\tprotected _priorityInterruptPending = false;\n\tprotected _activePromptCount = 0;\n\tprotected _agentRunAbortRequested = false;\n\tprotected _pendingNextTurnMessages: CustomMessage[] = [];\n\t/** Context-only custom messages queued during a run, flushed after the current turn's tool results. */\n\tprotected _pendingCustomMessages: CustomMessage[] = [];\n\tprotected _protectedStreamingCustomMessages: Array<{\n\t\tmessage: CustomMessage;\n\t\tdelivery: \"steer\" | \"followUp\";\n\t\tphase: \"queued\" | \"consumed-unpersisted\" | \"persistence-failed\";\n\t}> = [];\n\tprotected _compactionAbortController: AbortController | undefined = undefined;\n\tprotected _compactionReason: import(\"./agent-session-types.js\").CompactionReason | undefined = undefined;\n\tprotected _manualCompactionPromise: Promise<VerbatimCompactionResult> | undefined = undefined;\n\tprotected _autoCompactionAbortController: AbortController | undefined = undefined;\n\t/** Resolves when the current automatic compaction has settled. */\n\tprotected _autoCompactionCompletion: Promise<void> | undefined = undefined;\n\tprotected _overflowRecoveryAttempted = false;\n\tprotected _recoverableLengthRecoveryAttempted = false;\n\t/** Set when compaction cannot recover a context overflow on the current model. */\n\tprotected _contextOverflowUnresolved = false;\n\tprotected _pendingPostCompactionContinuation: Promise<void> | undefined = undefined;\n\tprotected _postCompactionContinuationToken = 0;\n\tprotected _lengthContinuationAttempts = 0;\n\tprotected _outputBudgetErrorContinuationAttempts = 0;\n\tprotected _postToolCompactionPreflightError: string | undefined = undefined;\n\tprotected _pendingPostToolCompactionGuard: PendingPostToolCompactionGuard | undefined = undefined;\n\tprotected _terminatingToolCallIds = new Set<string>();\n\t/** A positive stop callback keeps queued work pending until an explicit new run. */\n\tprotected _stopAfterTurnBlockedContinuation = false;\n\tprotected _disposed = false;\n\tprotected _branchSummaryAbortController: AbortController | undefined = undefined;\n\t/** Settles after the currently active branch-summary navigation finishes cleanup. */\n\tprotected _branchSummaryCompletion: Promise<void> | undefined = undefined;\n\tprotected _sessionSummaryAbortController: AbortController | undefined = undefined;\n\tprotected _sessionSummaryToken = 0;\n\t/** The summary request currently in flight, published so a later launch can join it. */\n\tprotected _sessionSummaryRun: SessionSummaryRun | undefined = undefined;\n\tprotected _lastSummarizedMessageId: string | undefined = undefined;\n\tprotected _retryAbortController: AbortController | undefined = undefined;\n\tprotected _retryAttempt = 0;\n\tprotected _retryPromise: Promise<void> | undefined = undefined;\n\tprotected _retryResolve: (() => void) | undefined = undefined;\n\tprotected _bashAbortControllers = new Map<string | symbol, Set<AbortController>>();\n\tprotected _pendingBashMessages: BashExecutionMessage[] = [];\n\tprotected _extensionRunner!: ExtensionRunner;\n\tprotected _turnIndex = 0;\n\t/** Source entry IDs for projected messages, so boundaries and omissions resolve provenance. */\n\tprotected readonly _entryIdsByMessage = new WeakMap<object, string>();\n\t/** Assistant messages whose actionable turn_end already ran from finishTurn. */\n\tprotected readonly _boundaryDispatchedMessages = new WeakSet<object>();\n\tprotected readonly _messagesAwaitingPersistence = new WeakSet<object>();\n\tprotected _lastAssistantToolResults: AgentMessage[] = [];\n\tprotected _lastActivityOutcome: AgentActivityOutcome = \"completed\";\n\tprotected _isBeforeSettle = false;\n\tprotected _abortDuringBeforeSettle = false;\n\tprotected _isEmittingAgentSettled = false;\n\tprotected readonly _deferredSettledActions: Array<() => Promise<void>> = [];\n\t/** Set when a caller's prepareNextTurnWithContext replaced the next request's context. */\n\tprotected _callerReplacedNextRequestContext = false;\n\tprotected _resourceLoader: ResourceLoader;\n\tprotected _customTools: ToolDefinition[];\n\tprotected _baseToolDefinitions: Map<string, ToolDefinition> = new Map();\n\tprotected _cwd: string;\n\tprotected _extensionRunnerRef?: { current?: ExtensionRunner };\n\tprotected _initialActiveToolNames?: string[];\n\tprotected _usesDefaultTools: boolean;\n\t/** Resolved defaults last applied here, independent of shared settings publication. */\n\tprotected _appliedDefaultTools: Set<string>;\n\tprotected _subagentPolicy?: SubagentChildPolicy;\n\tprotected _allowedToolNames?: Set<string>;\n\tprotected _excludedToolNames?: Set<string>;\n\tprotected _childSessionOptions?: import(\"./child-session-options.ts\").ChildSessionOptionsResolver;\n\tprotected _baseToolsOverride?: Record<string, AgentTool>;\n\tprotected _sessionStartEvent: SessionStartEvent;\n\tprotected _orchestrationContext?: OrchestrationContext;\n\tprotected _extensionUIContext?: ExtensionUIContext;\n\tprotected _extensionHumanInput?: import(\"./extensions/host-input.js\").HostInput | null;\n\tprotected _extensionDiagnosticListener?: (diagnostic: import(\"./extensions/host-input.js\").HostDiagnostic) => void;\n\tprotected _extensionMode: ExtensionMode = \"print\";\n\tprotected _extensionCommandContextActions?: ExtensionCommandContextActions;\n\tprotected _extensionShutdownHandler?: () => void;\n\tprotected _extensionErrorListener?: ExtensionErrorListener;\n\tprotected _extensionErrorUnsubscriber?: () => void;\n\tprotected _modelRuntime: ModelRuntime;\n\tprotected _extensionProviderIds = new Set<string>();\n\tprotected _toolRegistry: Map<string, AgentTool> = new Map();\n\tprotected readonly _toolExecutionScheduler = new ToolExecutionScheduler();\n\tprotected _toolDefinitions: Map<string, ToolDefinitionEntry> = new Map();\n\tprotected _toolPromptSnippets: Map<string, string> = new Map();\n\tprotected _toolPromptGuidelines: Map<string, string[]> = new Map();\n\tprotected _baseSystemPromptOptions!: NormalizedBuildSystemPromptOptions;\n\tprotected _systemPromptTransform?: (prompt: string) => string;\n\tprotected _contextProjectionTransform?: (messages: AgentMessage[]) => AgentMessage[];\n\tprotected _runSystemPromptOptions?: NormalizedBuildSystemPromptOptions;\n\tprotected _lastAssistantMessage: AssistantMessage | undefined = undefined;\n\t/** Protection claim on this session's temp tree and tool-results directory. */\n\tprotected _tempStorageLease: ProtectedPathLease | undefined;\n\tprotected _workflowStageAdmission: WorkflowStageAdmissionBoundary | undefined;\n\tprotected _subagentMessageAdmission: WorkflowStageAdmissionBoundary | undefined;\n\tprotected _agentTaskHost: import(\"./tasks/agent-adapter.js\").AgentTaskHost | undefined;\n\tprotected _parentCommandTaskOwner: import(\"./tasks/child-command-owner.js\").ChildCommandTaskOwner | undefined;\n\tprotected _childTaskWaits = new ChildTaskWaits();\n\tprotected _taskCompletionOutbox: import(\"./tasks/completion.js\").TaskCompletionOutbox | undefined;\n\tprotected _taskAdmission: WorkflowStageAdmissionBoundary | undefined;\n\tprotected _cacheWarmer?: import(\"./cache-warmer.ts\").CacheWarmer;\n\tget cacheWarmingStatus(): import(\"./cache-warmer.ts\").CacheWarmingStatus | undefined {\n\t\treturn this._cacheWarmer?.status;\n\t}\n\tsetCacheWarmingMode(mode: import(\"./settings-manager.ts\").CacheWarmingMode): void {\n\t\tthis.settingsManager.setCacheWarmingMode(mode);\n\t\tthis._cacheWarmer?.onModeChanged();\n\t}\n\n\tconstructor(config: AgentSessionConfig) {\n\t\tthis.agent = config.agent;\n\t\tthis.sessionManager = config.sessionManager;\n\t\tthis.settingsManager = config.settingsManager;\n\t\tthis._scopedModels = config.scopedModels ?? [];\n\t\tthis._fallbackModels = config.fallbackModels ?? [];\n\t\tthis._isFallbackModelAllowed = config.isFallbackModelAllowed;\n\t\tthis._resourceLoader = config.resourceLoader;\n\t\tthis._customTools = config.customTools ?? [];\n\t\tthis._cwd = config.cwd;\n\t\tthis._modelRuntime = config.modelRuntime;\n\t\tthis._cacheWarmer = config.cacheWarmer;\n\t\tif (this._cacheWarmer)\n\t\t\tthis._cacheWarmer.onWarmed = (entry) =>\n\t\t\t\t(this as unknown as import(\"./agent-session-methods.ts\").AgentSessionInternalSurface)._emit({\n\t\t\t\t\ttype: \"entry_appended\",\n\t\t\t\t\tentry,\n\t\t\t\t});\n\t\tthis._extensionProviderIds = new Set(config.resourceLoader.getExtensions().runtime.extensionProviderIds);\n\t\tthis._extensionRunnerRef = config.extensionRunnerRef;\n\t\tthis._initialActiveToolNames = config.initialActiveToolNames;\n\t\tthis._usesDefaultTools = config.usesDefaultTools ?? false;\n\t\tthis._appliedDefaultTools = new Set(\n\t\t\tthis._usesDefaultTools ? (this.settingsManager.getDefaultTools() ?? getDefaultToolNames()) : [],\n\t\t);\n\t\tthis._allowedToolNames = config.allowedToolNames ? new Set(config.allowedToolNames) : undefined;\n\t\tthis._excludedToolNames = config.excludedToolNames ? new Set(config.excludedToolNames) : undefined;\n\t\tthis._childSessionOptions = config.childSessionOptions;\n\t\tthis._baseToolsOverride = config.baseToolsOverride;\n\t\tthis._sessionStartEvent = config.sessionStartEvent ?? { type: \"session_start\", reason: \"startup\" };\n\t\tthis._orchestrationContext = config.orchestrationContext;\n\t\tthis._subagentPolicy = config.subagentPolicy;\n\t\tthis._parentCommandTaskOwner = config.parentCommandTaskOwner;\n\t\tlet removeExecutionEndedListener: (() => void) | undefined;\n\t\ttry {\n\t\t\tif (config.subagentPolicy?.executionEnded !== undefined) {\n\t\t\t\t// Reuse the stable-key admission/drain primitive, not workflow identity or task ownership.\n\t\t\t\tconst admission = WorkflowStageAdmissionBoundary.restore(this.sessionManager.getBranch());\n\t\t\t\tthis._subagentMessageAdmission = admission;\n\t\t\t\tthis._subagentPolicy = {\n\t\t\t\t\t...config.subagentPolicy,\n\t\t\t\t\tmessageAdmission: {\n\t\t\t\t\t\tisOpen: () => admission.isOpen(),\n\t\t\t\t\t\trun: (deliver) =>\n\t\t\t\t\t\t\tadmission.runMessageDelivery(deliver, () => {\n\t\t\t\t\t\t\t\tthrow new Error(\"Subagent execution is terminal and cannot accept messages\");\n\t\t\t\t\t\t\t}),\n\t\t\t\t\t},\n\t\t\t\t};\n\t\t\t\tconst ended = config.subagentPolicy.executionEnded;\n\t\t\t\tif (ended.aborted) admission.seal();\n\t\t\t\telse {\n\t\t\t\t\tconst seal = () => admission.seal();\n\t\t\t\t\tended.addEventListener(\"abort\", seal, { once: true });\n\t\t\t\t\tremoveExecutionEndedListener = () => ended.removeEventListener(\"abort\", seal);\n\t\t\t\t}\n\t\t\t}\n\t\t\tthis._systemPromptTransform = config.systemPromptTransform;\n\t\t\tthis._contextProjectionTransform = config.contextProjectionTransform;\n\t\t\tconst stageContext =\n\t\t\t\tconfig.orchestrationContext?.kind === \"workflow-stage\" ? config.orchestrationContext : undefined;\n\t\t\tthis._workflowStageAdmission =\n\t\t\t\tstageContext?.messageAdmission?.boundary ??\n\t\t\t\t(stageContext ? WorkflowStageAdmissionBoundary.restore(this.sessionManager.getBranch()) : undefined);\n\t\t\tif (stageContext) {\n\t\t\t\tthis._workflowStageAdmission?.bindTaskIdentity(\n\t\t\t\t\tthis.sessionManager.getSessionId(),\n\t\t\t\t\tstageContext.workflowRunId,\n\t\t\t\t\tstageContext.workflowStageId,\n\t\t\t\t);\n\t\t\t}\n\t\t\tif (this._workflowStageAdmission && stageContext && stageContext.messageAdmission === undefined) {\n\t\t\t\t(\n\t\t\t\t\tstageContext as {\n\t\t\t\t\t\tmessageAdmission?: {\n\t\t\t\t\t\t\tboundary: WorkflowStageAdmissionBoundary;\n\t\t\t\t\t\t\textensionState: Map<string, object>;\n\t\t\t\t\t\t\tisOpen(): boolean;\n\t\t\t\t\t\t};\n\t\t\t\t\t}\n\t\t\t\t).messageAdmission = {\n\t\t\t\t\tboundary: this._workflowStageAdmission,\n\t\t\t\t\textensionState: new Map(),\n\t\t\t\t\tisOpen: () => this._workflowStageAdmission?.isOpen() === true,\n\t\t\t\t};\n\t\t\t}\n\t\t\t// Claim this session's storage before any tool can spill into it, so the\n\t\t\t// sweeper below never reaps a directory this process is still writing to.\n\t\t\t// The claim is a lease, released in dispose(): a session that is gone must\n\t\t\t// stop protecting a tree the startup sweep exists to collect.\n\t\t\ttry {\n\t\t\t\tconst sessionId = this.sessionManager.getSessionId();\n\t\t\t\tconst sessionDir = this.sessionManager.getSessionDir() || undefined;\n\t\t\t\tthis._tempStorageLease = acquireProtectedPaths([\n\t\t\t\t\tsetActiveSessionTempId(sessionId),\n\t\t\t\t\t// A disk-backed session's results are read back by path, and a replayed\n\t\t\t\t\t// result reuses an old file without touching its mtime, so age alone\n\t\t\t\t\t// cannot keep it alive.\n\t\t\t\t\t...(sessionDir ? [join(sessionDir, TOOL_RESULTS_SUBDIR)] : []),\n\t\t\t\t]);\n\t\t\t\t// A custom `--session-dir` keeps its tool results directly under that\n\t\t\t\t// directory, outside the project-nested roots the default sweep walks,\n\t\t\t\t// so it has to be named as its own target.\n\t\t\t\tconst customSessionDir = this.sessionManager.usesDefaultSessionDir() ? undefined : sessionDir;\n\t\t\t\tscheduleSessionTempCleanup(customSessionDir ? { sessionDirs: [customSessionDir] } : {});\n\t\t\t} catch {\n\t\t\t\t// Temp-storage housekeeping must never block session construction.\n\t\t\t}\n\t\t\tconst internals = this as unknown as AgentSessionInternalSurface;\n\t\t\tinternals._handleAgentEvent = internals._handleAgentEvent.bind(this);\n\t\t\tthis._unsubscribeAgent = this.agent.subscribe(internals._handleAgentEvent);\n\t\t\tinternals._installAgentToolHooks();\n\t\t\tinternals._installAgentNextTurnRefresh();\n\t\t\tinternals._installAgentRequestProjection();\n\t\t\tinternals._installAgentBoundaryHooks();\n\t\t\tinternals._buildRuntime({\n\t\t\t\tactiveToolNames: this._initialActiveToolNames,\n\t\t\t\tincludeAllExtensionTools: true,\n\t\t\t});\n\t\t\tif (this._initialActiveToolNames === undefined) internals._restoreToolsFromTranscript();\n\t\t\tif (this._workflowStageAdmission?.hasAgentTaskHost() && !isSubagentChildSession(internals))\n\t\t\t\tinternals.getAgentTaskHost();\n\t\t} catch (error) {\n\t\t\t// No session escapes a failed constructor to release these acquisitions later.\n\t\t\tconst failures: unknown[] = [];\n\t\t\tfor (const release of [\n\t\t\t\t() => removeExecutionEndedListener?.(),\n\t\t\t\t() => this._unsubscribeAgent?.(),\n\t\t\t\t() => this._tempStorageLease?.release(),\n\t\t\t\t() => this._extensionRunner?.invalidate(\"Session construction failed\"),\n\t\t\t]) {\n\t\t\t\ttry {\n\t\t\t\t\trelease();\n\t\t\t\t} catch (cause) {\n\t\t\t\t\tfailures.push(cause);\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (this._extensionRunnerRef) this._extensionRunnerRef.current = undefined;\n\t\t\tif (failures.length)\n\t\t\t\tthrow Object.assign(new AggregateError([error, ...failures], \"Session construction cleanup failed\"), {\n\t\t\t\t\tcode: \"ShutdownFailed\",\n\t\t\t\t});\n\t\t\tthrow error;\n\t\t}\n\t}\n}\n\nexport interface AgentSession extends AgentSessionBase, AgentSessionPublicSurface {}\n\nexport const AgentSession = AgentSessionBase as unknown as {\n\tnew (config: AgentSessionConfig): AgentSession;\n\treadonly prototype: AgentSession;\n};\n\ninstallAgentSessionAccessors(AgentSession.prototype as unknown as AgentSessionInternalSurface);\nObject.assign(\n\tAgentSession.prototype,\n\tagentSessionToolHooksMethods,\n\tagentSessionBoundaryMethods,\n\tagentSessionEventsMethods,\n\tagentSessionStateMethods,\n\tagentSessionPromptMethods,\n\tagentSessionCustomMessageCommitMethods,\n\tagentSessionMessageQueueMethods,\n\tagentSessionModelsMethods,\n\tagentSessionCompactionMethods,\n\tagentSessionAutoCompactionMethods,\n\tagentSessionPostToolCompactionMethods,\n\tagentSessionExtensionBindingsMethods,\n\tagentSessionToolRegistryMethods,\n\tagentSessionRetryMethods,\n\tagentSessionBashMethods,\n\tagentSessionTreeMethods,\n\tagentSessionExportMethods,\n\tagentSessionSummaryMethods,\n\tagentSessionTaskMethods,\n);\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"builtin-resource-loader.d.ts","sourceRoot":"","sources":["../../src/core/builtin-resource-loader.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAEX,cAAc,EAGd,MAAM,4BAA4B,CAAC;AACpC,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"builtin-resource-loader.d.ts","sourceRoot":"","sources":["../../src/core/builtin-resource-loader.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAEX,cAAc,EAGd,MAAM,4BAA4B,CAAC;AACpC,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAuRpD,wBAAsB,yBAAyB,CAC9C,MAAM,EAAE,cAAc,EACtB,GAAG,EAAE,MAAM,EACX,QAAQ,EAAE,MAAM,EAChB,QAAQ,CAAC,EAAE,OAAO,CAAC,MAAM,CAAC,aAAa,EAAE,OAAO,CAAC,CAAC,EAClD,wBAAwB,UAAQ,GAC9B,OAAO,CAAC,cAAc,CAAC,CAWzB"}
|
|
@@ -97,7 +97,19 @@ class BuiltinResourceLoader {
|
|
|
97
97
|
!locations.some((location) => (identities.has(location.packageName) ||
|
|
98
98
|
(this.disableWorkflowExtension && location.distDirName === "workflows")) &&
|
|
99
99
|
canonical(resource.path).startsWith(`${canonical(location.packageDir)}${sep}`)));
|
|
100
|
-
const
|
|
100
|
+
const mergeWorkflows = (caller) => {
|
|
101
|
+
const workflows = new Map();
|
|
102
|
+
for (const resource of [...resources.workflows, ...caller]) {
|
|
103
|
+
if (!this.isDisabledPath(resource.path))
|
|
104
|
+
workflows.set(canonical(resource.path), resource);
|
|
105
|
+
}
|
|
106
|
+
return [...workflows.values()];
|
|
107
|
+
};
|
|
108
|
+
const loaded = await loadExtensions(paths.map((resource) => resource.path), this.cwd, getExtensionRuntimeEventBus(target.runtime), {
|
|
109
|
+
get: () => mergeWorkflows(this.delegate.getWorkflowResources?.() ?? []),
|
|
110
|
+
refresh: async () => mergeWorkflows((await this.delegate.refreshWorkflowResources?.()) ?? this.delegate.getWorkflowResources?.() ?? []),
|
|
111
|
+
getMcpServers: () => this.delegate.getMcpServerContributions?.() ?? [],
|
|
112
|
+
}, target.runtime);
|
|
101
113
|
for (const extension of loaded.extensions)
|
|
102
114
|
markTrustedMandatoryRuntimeExtension(extension);
|
|
103
115
|
this.extensions = {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"builtin-resource-loader.js","sourceRo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,CAAC,CAAC;IACtG,MAAM,QAAQ,CAAC,UAAU,EAAE,CAAC;IAC5B,OAAO,QAAQ,CAAC;AACjB,CAAC","sourcesContent":["import { realpathSync } from \"node:fs\";\nimport { isAbsolute, relative, sep } from \"node:path\";\nimport { getAllBuiltinPackageLocations, getBuiltinPackageLocations } from \"./builtin-packages.ts\";\nimport { getExtensionRuntimeEventBus, instantiateExtensions, loadExtensions } from \"./extensions/loader.ts\";\nimport type { LoadExtensionsResult } from \"./extensions/types.ts\";\nimport { markTrustedMandatoryRuntimeExtension } from \"./mandatory-runtime-tools.ts\";\nimport { DefaultPackageManager, type ResolvedResource } from \"./package-manager.ts\";\nimport { DefaultResourceLoader } from \"./resource-loader.ts\";\nimport type {\n\tResourceExtensionPaths,\n\tResourceLoader,\n\tResourceLoaderReloadOptions,\n\tResourceLoaderReloadTransaction,\n} from \"./resource-loader-types.ts\";\nimport type { AtomicBuiltin } from \"./sdk-types.ts\";\nimport { lifecycleScopeForOwner, sessionLifecycleCreation, sessionLifecycleScopes } from \"./session-lifecycle-scope.ts\";\nimport { SettingsManager } from \"./settings-manager.ts\";\nimport { buildSkillCatalog } from \"./skill-catalog.ts\";\n\nfunction canonical(path: string): string {\n\ttry {\n\t\treturn realpathSync(path);\n\t} catch {\n\t\treturn path;\n\t}\n}\n\n/** Adds shipped resources without changing the caller's loader or its discovery options. */\nclass BuiltinResourceLoader implements ResourceLoader {\n\tprivate extensions!: LoadExtensionsResult;\n\tprivate assets: DefaultResourceLoader;\n\tprivate readonly delegate: ResourceLoader;\n\tprivate readonly cwd: string;\n\tprivate readonly agentDir: string;\n\tprivate readonly builtins: Partial<Record<AtomicBuiltin, boolean>>;\n\tprivate readonly disabledRoots: string[];\n\tprivate readonly disableWorkflowExtension: boolean;\n\tprivate readonly ownsDiscovery: boolean;\n\tprivate isDisabledPath(path: string): boolean {\n\t\treturn this.disabledRoots.some((root) => {\n\t\t\tconst child = relative(root, canonical(path));\n\t\t\treturn child !== \"..\" && !child.startsWith(`..${sep}`) && !isAbsolute(child);\n\t\t});\n\t}\n\tconstructor(\n\t\tdelegate: ResourceLoader,\n\t\tcwd: string,\n\t\tagentDir: string,\n\t\tbuiltins?: Partial<Record<AtomicBuiltin, boolean>>,\n\t\tdisableWorkflowExtension = false,\n\t\townsDiscovery?: boolean,\n\t) {\n\t\tconst scope = sessionLifecycleCreation.getStore()?.scope;\n\t\tthis.ownsDiscovery =\n\t\t\townsDiscovery ??\n\t\t\t(scope !== undefined && sessionLifecycleScopes.get(delegate.getExtensions().runtime) === scope);\n\t\tthis.disableWorkflowExtension = disableWorkflowExtension;\n\t\tthis.delegate = delegate;\n\t\tthis.cwd = cwd;\n\t\tthis.agentDir = agentDir;\n\t\tthis.builtins = {};\n\t\tfor (const name of [\"workflows\", \"subagents\", \"mcp\", \"web-access\", \"intercom\"] as const) {\n\t\t\tif (builtins && name in builtins) this.builtins[name] = builtins[name];\n\t\t}\n\t\tthis.disabledRoots = getAllBuiltinPackageLocations()\n\t\t\t.filter((location) => this.builtins[location.distDirName] === false)\n\t\t\t.map((location) => canonical(location.packageDir));\n\t\tthis.assets = new DefaultResourceLoader({\n\t\t\tcwd,\n\t\t\tagentDir,\n\t\t\tsettingsManager: SettingsManager.inMemory(),\n\t\t\tnoExtensions: true,\n\t\t\tnoSkills: true,\n\t\t\tnoPromptTemplates: true,\n\t\t\tnoThemes: true,\n\t\t\tnoContextFiles: true,\n\t\t});\n\t}\n\tasync initialize(): Promise<void> {\n\t\tconst locations = getBuiltinPackageLocations(true, this.builtins);\n\t\tconst discovered = this.delegate.getExtensions();\n\t\tconst scope = lifecycleScopeForOwner(this);\n\t\tconst identities = new Set<string>();\n\t\tconst selected = discovered.extensions.filter((extension) => {\n\t\t\tif (this.isDisabledPath(extension.resolvedPath)) return false;\n\t\t\tconst path = canonical(extension.resolvedPath);\n\t\t\tconst builtin = locations.find((location) => {\n\t\t\t\tconst child = relative(canonical(location.packageDir), path);\n\t\t\t\treturn child !== \"..\" && !child.startsWith(`..${sep}`) && !isAbsolute(child);\n\t\t\t});\n\t\t\tif (!builtin) return true;\n\t\t\tif (this.disableWorkflowExtension && builtin.distDirName === \"workflows\") return false;\n\t\t\tif (identities.has(builtin.packageName)) return false;\n\t\t\tidentities.add(builtin.packageName);\n\t\t\treturn true;\n\t\t});\n\t\tconst discovery = { ...discovered, extensions: selected };\n\t\tconst target =\n\t\t\tsessionLifecycleScopes.get(discovered.runtime) === scope\n\t\t\t\t? discovery\n\t\t\t\t: await sessionLifecycleCreation.run({ scope, claimed: true }, () =>\n\t\t\t\t\t\tinstantiateExtensions(discovery, this.cwd),\n\t\t\t\t\t);\n\t\tconst manager = new DefaultPackageManager({\n\t\t\tcwd: this.cwd,\n\t\t\tagentDir: this.agentDir,\n\t\t\tsettingsManager: SettingsManager.inMemory(),\n\t\t});\n\t\tconst resources = await manager.resolveExtensionSources(\n\t\t\tlocations.map((location) => location.packageDir),\n\t\t\t{ temporary: true },\n\t\t);\n\t\tconst paths = resources.extensions.filter(\n\t\t\t(resource) =>\n\t\t\t\tresource.enabled &&\n\t\t\t\t!locations.some(\n\t\t\t\t\t(location) =>\n\t\t\t\t\t\t(identities.has(location.packageName) ||\n\t\t\t\t\t\t\t(this.disableWorkflowExtension && location.distDirName === \"workflows\")) &&\n\t\t\t\t\t\tcanonical(resource.path).startsWith(`${canonical(location.packageDir)}${sep}`),\n\t\t\t\t),\n\t\t);\n\t\tconst loaded = await loadExtensions(\n\t\t\tpaths.map((resource) => resource.path),\n\t\t\tthis.cwd,\n\t\t\tgetExtensionRuntimeEventBus(target.runtime),\n\t\t\t{ get: () => resources.workflows, refresh: async () => resources.workflows },\n\t\t\ttarget.runtime,\n\t\t);\n\t\tfor (const extension of loaded.extensions) markTrustedMandatoryRuntimeExtension(extension);\n\t\tthis.extensions = {\n\t\t\t...target,\n\t\t\textensions: [...target.extensions, ...loaded.extensions],\n\t\t\terrors: [...target.errors, ...loaded.errors],\n\t\t};\n\t\tconst entries = (items: ResolvedResource[]) =>\n\t\t\titems\n\t\t\t\t.filter((item) => item.enabled)\n\t\t\t\t.map((item) => ({\n\t\t\t\t\tpath: item.path,\n\t\t\t\t\tmetadata: { ...item.metadata, configurationOrigin: \"bundled\" as const },\n\t\t\t\t}));\n\t\tawait this.assets.extendResources({\n\t\t\tskillPaths: entries(resources.skills),\n\t\t\tpromptPaths: entries(resources.prompts),\n\t\t\tthemePaths: entries(resources.themes),\n\t\t});\n\t}\n\tgetExtensions() {\n\t\treturn this.extensions;\n\t}\n\tgetSkills(): ReturnType<ResourceLoader[\"getSkills\"]> {\n\t\tconst caller = this.delegate.getSkills();\n\t\tconst builtin = this.assets.getSkills();\n\t\tconst skills = caller.skills.filter((skill) => !this.isDisabledPath(skill.filePath));\n\t\tconst paths = new Set(skills.map((skill) => canonical(skill.filePath)));\n\t\treturn {\n\t\t\tskills: [...skills, ...builtin.skills.filter((skill) => !paths.has(canonical(skill.filePath)))],\n\t\t\tdiagnostics: [...caller.diagnostics, ...builtin.diagnostics],\n\t\t};\n\t}\n\tgetSkillCatalog() {\n\t\treturn buildSkillCatalog(this.getSkills().skills);\n\t}\n\tgetPrompts(): ReturnType<ResourceLoader[\"getPrompts\"]> {\n\t\tconst caller = this.delegate.getPrompts();\n\t\tconst builtin = this.assets.getPrompts();\n\t\tconst prompts = caller.prompts.filter((prompt) => !this.isDisabledPath(prompt.filePath));\n\t\tconst paths = new Set(prompts.map((prompt) => canonical(prompt.filePath)));\n\t\treturn {\n\t\t\tprompts: [...prompts, ...builtin.prompts.filter((prompt) => !paths.has(canonical(prompt.filePath)))],\n\t\t\tdiagnostics: [...caller.diagnostics, ...builtin.diagnostics],\n\t\t};\n\t}\n\tgetThemes(): ReturnType<ResourceLoader[\"getThemes\"]> {\n\t\tconst caller = this.delegate.getThemes();\n\t\tconst builtin = this.assets.getThemes();\n\t\treturn {\n\t\t\tthemes: [\n\t\t\t\t...caller.themes.filter((theme) => !theme.sourcePath || !this.isDisabledPath(theme.sourcePath)),\n\t\t\t\t...builtin.themes,\n\t\t\t],\n\t\t\tdiagnostics: [...caller.diagnostics, ...builtin.diagnostics],\n\t\t};\n\t}\n\tgetAgentsFiles() {\n\t\treturn this.delegate.getAgentsFiles();\n\t}\n\tgetSystemPrompt() {\n\t\treturn this.delegate.getSystemPrompt();\n\t}\n\tgetSystemPromptSource() {\n\t\treturn this.delegate.getSystemPromptSource();\n\t}\n\tgetAppendSystemPrompt() {\n\t\treturn this.delegate.getAppendSystemPrompt();\n\t}\n\tgetAppendSystemPromptSources() {\n\t\treturn this.delegate.getAppendSystemPromptSources();\n\t}\n\tasync extendResources(paths: ResourceExtensionPaths): Promise<void> {\n\t\tconst bundled: ResourceExtensionPaths = {};\n\t\tconst caller: ResourceExtensionPaths = {};\n\t\tfor (const kind of [\"skillPaths\", \"promptPaths\", \"themePaths\"] as const) {\n\t\t\tbundled[kind] = paths[kind]?.filter(\n\t\t\t\t(entry) => !this.isDisabledPath(entry.path) && entry.metadata.configurationOrigin === \"bundled\",\n\t\t\t);\n\t\t\tcaller[kind] = paths[kind]?.filter(\n\t\t\t\t(entry) => !this.isDisabledPath(entry.path) && entry.metadata.configurationOrigin !== \"bundled\",\n\t\t\t);\n\t\t}\n\t\tif (this.ownsDiscovery) {\n\t\t\tawait this.delegate.extendResources(caller);\n\t\t} else {\n\t\t\t// Extension-discovered assets belong to this session, not borrowed discovery.\n\t\t\tfor (const kind of [\"skillPaths\", \"promptPaths\", \"themePaths\"] as const) {\n\t\t\t\tbundled[kind] = [...(bundled[kind] ?? []), ...(caller[kind] ?? [])];\n\t\t\t}\n\t\t}\n\t\tawait this.assets.extendResources(bundled);\n\t}\n\tasync reload(options?: ResourceLoaderReloadOptions): Promise<void> {\n\t\tawait this.delegate.reload(options);\n\t\tthis.assets = new DefaultResourceLoader({\n\t\t\tcwd: this.cwd,\n\t\t\tagentDir: this.agentDir,\n\t\t\tsettingsManager: SettingsManager.inMemory(),\n\t\t\tnoContextFiles: true,\n\t\t});\n\t\tawait this.initialize();\n\t}\n\tsupportsTransactionalReload(): boolean {\n\t\treturn this.delegate.prepareReload !== undefined && this.delegate.supportsTransactionalReload?.() !== false;\n\t}\n\tasync prepareReload(\n\t\tsettings: SettingsManager,\n\t\toptions?: ResourceLoaderReloadOptions,\n\t): Promise<ResourceLoaderReloadTransaction> {\n\t\tif (!this.delegate.prepareReload) throw new Error(\"Resource loader does not support transactional reload\");\n\t\tconst transaction = await this.delegate.prepareReload(settings, options);\n\t\tconst candidate = new BuiltinResourceLoader(\n\t\t\ttransaction.loader,\n\t\t\tthis.cwd,\n\t\t\tthis.agentDir,\n\t\t\tthis.builtins,\n\t\t\tthis.disableWorkflowExtension,\n\t\t\ttrue,\n\t\t);\n\t\tsessionLifecycleScopes.set(candidate, lifecycleScopeForOwner(this));\n\t\tawait candidate.initialize();\n\t\tconst publish = () => {\n\t\t\tthis.extensions = candidate.extensions;\n\t\t\tthis.assets = candidate.assets;\n\t\t};\n\t\treturn {\n\t\t\t...transaction,\n\t\t\tloader: candidate,\n\t\t\t...(transaction.prepareCommit\n\t\t\t\t? {\n\t\t\t\t\t\tprepareCommit: () => {\n\t\t\t\t\t\t\tconst prepared = transaction.prepareCommit!();\n\t\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\t\tcommit: () => {\n\t\t\t\t\t\t\t\t\tprepared.commit();\n\t\t\t\t\t\t\t\t\tpublish();\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\trollback: () => prepared.rollback(),\n\t\t\t\t\t\t\t};\n\t\t\t\t\t\t},\n\t\t\t\t\t}\n\t\t\t\t: {}),\n\t\t\tcommit: () => {\n\t\t\t\ttransaction.commit();\n\t\t\t\tpublish();\n\t\t\t},\n\t\t};\n\t}\n}\n\nexport async function withBuiltinResourceLoader(\n\tloader: ResourceLoader,\n\tcwd: string,\n\tagentDir: string,\n\tbuiltins?: Partial<Record<AtomicBuiltin, boolean>>,\n\tdisableWorkflowExtension = false,\n): Promise<ResourceLoader> {\n\tif (\n\t\tloader instanceof BuiltinResourceLoader &&\n\t\tbuiltins === undefined &&\n\t\t!disableWorkflowExtension &&\n\t\tsessionLifecycleScopes.get(loader) === sessionLifecycleCreation.getStore()?.scope\n\t)\n\t\treturn loader;\n\tconst composed = new BuiltinResourceLoader(loader, cwd, agentDir, builtins, disableWorkflowExtension);\n\tawait composed.initialize();\n\treturn composed;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"builtin-resource-loader.js","sourceRoot":"","sources":["../../src/core/builtin-resource-loader.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,GAAG,EAAE,MAAM,WAAW,CAAC;AACtD,OAAO,EAAE,6BAA6B,EAAE,0BAA0B,EAAE,MAAM,uBAAuB,CAAC;AAClG,OAAO,EAAE,2BAA2B,EAAE,qBAAqB,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAE5G,OAAO,EAAE,oCAAoC,EAAE,MAAM,8BAA8B,CAAC;AACpF,OAAO,EAAE,qBAAqB,EAAyB,MAAM,sBAAsB,CAAC;AACpF,OAAO,EAAE,qBAAqB,EAAE,MAAM,sBAAsB,CAAC;AAQ7D,OAAO,EAAE,sBAAsB,EAAE,wBAAwB,EAAE,sBAAsB,EAAE,MAAM,8BAA8B,CAAC;AACxH,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AACxD,OAAO,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AAEvD,SAAS,SAAS,CAAC,IAAY;IAC9B,IAAI,CAAC;QACJ,OAAO,YAAY,CAAC,IAAI,CAAC,CAAC;IAC3B,CAAC;IAAC,MAAM,CAAC;QACR,OAAO,IAAI,CAAC;IACb,CAAC;AACF,CAAC;AAED,4FAA4F;AAC5F,MAAM,qBAAqB;IAClB,UAAU,CAAwB;IAClC,MAAM,CAAwB;IACrB,QAAQ,CAAiB;IACzB,GAAG,CAAS;IACZ,QAAQ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QAChC,CAAC,CAAC;QACF,OAAO;YACN,GAAG,WAAW;YACd,MAAM,EAAE,SAAS;YACjB,GAAG,CAAC,WAAW,CAAC,aAAa;gBAC5B,CAAC,CAAC;oBACA,aAAa,EAAE,GAAG,EAAE;wBACnB,MAAM,QAAQ,GAAG,WAAW,CAAC,aAAc,EAAE,CAAC;wBAC9C,OAAO;4BACN,MAAM,EAAE,GAAG,EAAE;gCACZ,QAAQ,CAAC,MAAM,EAAE,CAAC;gCAClB,OAAO,EAAE,CAAC;4BACX,CAAC;4BACD,QAAQ,EAAE,GAAG,EAAE,CAAC,QAAQ,CAAC,QAAQ,EAAE;yBACnC,CAAC;oBACH,CAAC;iBACD;gBACF,CAAC,CAAC,EAAE,CAAC;YACN,MAAM,EAAE,GAAG,EAAE;gBACZ,WAAW,CAAC,MAAM,EAAE,CAAC;gBACrB,OAAO,EAAE,CAAC;YACX,CAAC;SACD,CAAC;IACH,CAAC;CACD;AAED,MAAM,CAAC,KAAK,UAAU,yBAAyB,CAC9C,MAAsB,EACtB,GAAW,EACX,QAAgB,EAChB,QAAkD,EAClD,wBAAwB,GAAG,KAAK;IAEhC,IACC,MAAM,YAAY,qBAAqB;QACvC,QAAQ,KAAK,SAAS;QACtB,CAAC,wBAAwB;QACzB,sBAAsB,CAAC,GAAG,CAAC,MAAM,CAAC,KAAK,wBAAwB,CAAC,QAAQ,EAAE,EAAE,KAAK;QAEjF,OAAO,MAAM,CAAC;IACf,MAAM,QAAQ,GAAG,IAAI,qBAAqB,CAAC,MAAM,EAAE,GAAG,EAAE,QAAQ,EAAE,QAAQ,EAAE,wBAAwB,CAAC,CAAC;IACtG,MAAM,QAAQ,CAAC,UAAU,EAAE,CAAC;IAC5B,OAAO,QAAQ,CAAC;AACjB,CAAC","sourcesContent":["import { realpathSync } from \"node:fs\";\nimport { isAbsolute, relative, sep } from \"node:path\";\nimport { getAllBuiltinPackageLocations, getBuiltinPackageLocations } from \"./builtin-packages.ts\";\nimport { getExtensionRuntimeEventBus, instantiateExtensions, loadExtensions } from \"./extensions/loader.ts\";\nimport type { LoadExtensionsResult } from \"./extensions/types.ts\";\nimport { markTrustedMandatoryRuntimeExtension } from \"./mandatory-runtime-tools.ts\";\nimport { DefaultPackageManager, type ResolvedResource } from \"./package-manager.ts\";\nimport { DefaultResourceLoader } from \"./resource-loader.ts\";\nimport type {\n\tResourceExtensionPaths,\n\tResourceLoader,\n\tResourceLoaderReloadOptions,\n\tResourceLoaderReloadTransaction,\n} from \"./resource-loader-types.ts\";\nimport type { AtomicBuiltin } from \"./sdk-types.ts\";\nimport { lifecycleScopeForOwner, sessionLifecycleCreation, sessionLifecycleScopes } from \"./session-lifecycle-scope.ts\";\nimport { SettingsManager } from \"./settings-manager.ts\";\nimport { buildSkillCatalog } from \"./skill-catalog.ts\";\n\nfunction canonical(path: string): string {\n\ttry {\n\t\treturn realpathSync(path);\n\t} catch {\n\t\treturn path;\n\t}\n}\n\n/** Adds shipped resources without changing the caller's loader or its discovery options. */\nclass BuiltinResourceLoader implements ResourceLoader {\n\tprivate extensions!: LoadExtensionsResult;\n\tprivate assets: DefaultResourceLoader;\n\tprivate readonly delegate: ResourceLoader;\n\tprivate readonly cwd: string;\n\tprivate readonly agentDir: string;\n\tprivate readonly builtins: Partial<Record<AtomicBuiltin, boolean>>;\n\tprivate readonly disabledRoots: string[];\n\tprivate readonly disableWorkflowExtension: boolean;\n\tprivate readonly ownsDiscovery: boolean;\n\tprivate isDisabledPath(path: string): boolean {\n\t\treturn this.disabledRoots.some((root) => {\n\t\t\tconst child = relative(root, canonical(path));\n\t\t\treturn child !== \"..\" && !child.startsWith(`..${sep}`) && !isAbsolute(child);\n\t\t});\n\t}\n\tconstructor(\n\t\tdelegate: ResourceLoader,\n\t\tcwd: string,\n\t\tagentDir: string,\n\t\tbuiltins?: Partial<Record<AtomicBuiltin, boolean>>,\n\t\tdisableWorkflowExtension = false,\n\t\townsDiscovery?: boolean,\n\t) {\n\t\tconst scope = sessionLifecycleCreation.getStore()?.scope;\n\t\tthis.ownsDiscovery =\n\t\t\townsDiscovery ??\n\t\t\t(scope !== undefined && sessionLifecycleScopes.get(delegate.getExtensions().runtime) === scope);\n\t\tthis.disableWorkflowExtension = disableWorkflowExtension;\n\t\tthis.delegate = delegate;\n\t\tthis.cwd = cwd;\n\t\tthis.agentDir = agentDir;\n\t\tthis.builtins = {};\n\t\tfor (const name of [\"workflows\", \"subagents\", \"mcp\", \"web-access\", \"intercom\"] as const) {\n\t\t\tif (builtins && name in builtins) this.builtins[name] = builtins[name];\n\t\t}\n\t\tthis.disabledRoots = getAllBuiltinPackageLocations()\n\t\t\t.filter((location) => this.builtins[location.distDirName] === false)\n\t\t\t.map((location) => canonical(location.packageDir));\n\t\tthis.assets = new DefaultResourceLoader({\n\t\t\tcwd,\n\t\t\tagentDir,\n\t\t\tsettingsManager: SettingsManager.inMemory(),\n\t\t\tnoExtensions: true,\n\t\t\tnoSkills: true,\n\t\t\tnoPromptTemplates: true,\n\t\t\tnoThemes: true,\n\t\t\tnoContextFiles: true,\n\t\t});\n\t}\n\tasync initialize(): Promise<void> {\n\t\tconst locations = getBuiltinPackageLocations(true, this.builtins);\n\t\tconst discovered = this.delegate.getExtensions();\n\t\tconst scope = lifecycleScopeForOwner(this);\n\t\tconst identities = new Set<string>();\n\t\tconst selected = discovered.extensions.filter((extension) => {\n\t\t\tif (this.isDisabledPath(extension.resolvedPath)) return false;\n\t\t\tconst path = canonical(extension.resolvedPath);\n\t\t\tconst builtin = locations.find((location) => {\n\t\t\t\tconst child = relative(canonical(location.packageDir), path);\n\t\t\t\treturn child !== \"..\" && !child.startsWith(`..${sep}`) && !isAbsolute(child);\n\t\t\t});\n\t\t\tif (!builtin) return true;\n\t\t\tif (this.disableWorkflowExtension && builtin.distDirName === \"workflows\") return false;\n\t\t\tif (identities.has(builtin.packageName)) return false;\n\t\t\tidentities.add(builtin.packageName);\n\t\t\treturn true;\n\t\t});\n\t\tconst discovery = { ...discovered, extensions: selected };\n\t\tconst target =\n\t\t\tsessionLifecycleScopes.get(discovered.runtime) === scope\n\t\t\t\t? discovery\n\t\t\t\t: await sessionLifecycleCreation.run({ scope, claimed: true }, () =>\n\t\t\t\t\t\tinstantiateExtensions(discovery, this.cwd),\n\t\t\t\t\t);\n\t\tconst manager = new DefaultPackageManager({\n\t\t\tcwd: this.cwd,\n\t\t\tagentDir: this.agentDir,\n\t\t\tsettingsManager: SettingsManager.inMemory(),\n\t\t});\n\t\tconst resources = await manager.resolveExtensionSources(\n\t\t\tlocations.map((location) => location.packageDir),\n\t\t\t{ temporary: true },\n\t\t);\n\t\tconst paths = resources.extensions.filter(\n\t\t\t(resource) =>\n\t\t\t\tresource.enabled &&\n\t\t\t\t!locations.some(\n\t\t\t\t\t(location) =>\n\t\t\t\t\t\t(identities.has(location.packageName) ||\n\t\t\t\t\t\t\t(this.disableWorkflowExtension && location.distDirName === \"workflows\")) &&\n\t\t\t\t\t\tcanonical(resource.path).startsWith(`${canonical(location.packageDir)}${sep}`),\n\t\t\t\t),\n\t\t);\n\t\tconst mergeWorkflows = (caller: ResolvedResource[]) => {\n\t\t\tconst workflows = new Map<string, ResolvedResource>();\n\t\t\tfor (const resource of [...resources.workflows, ...caller]) {\n\t\t\t\tif (!this.isDisabledPath(resource.path)) workflows.set(canonical(resource.path), resource);\n\t\t\t}\n\t\t\treturn [...workflows.values()];\n\t\t};\n\t\tconst loaded = await loadExtensions(\n\t\t\tpaths.map((resource) => resource.path),\n\t\t\tthis.cwd,\n\t\t\tgetExtensionRuntimeEventBus(target.runtime),\n\t\t\t{\n\t\t\t\tget: () => mergeWorkflows(this.delegate.getWorkflowResources?.() ?? []),\n\t\t\t\trefresh: async () =>\n\t\t\t\t\tmergeWorkflows(\n\t\t\t\t\t\t(await this.delegate.refreshWorkflowResources?.()) ?? this.delegate.getWorkflowResources?.() ?? [],\n\t\t\t\t\t),\n\t\t\t\tgetMcpServers: () => this.delegate.getMcpServerContributions?.() ?? [],\n\t\t\t},\n\t\t\ttarget.runtime,\n\t\t);\n\t\tfor (const extension of loaded.extensions) markTrustedMandatoryRuntimeExtension(extension);\n\t\tthis.extensions = {\n\t\t\t...target,\n\t\t\textensions: [...target.extensions, ...loaded.extensions],\n\t\t\terrors: [...target.errors, ...loaded.errors],\n\t\t};\n\t\tconst entries = (items: ResolvedResource[]) =>\n\t\t\titems\n\t\t\t\t.filter((item) => item.enabled)\n\t\t\t\t.map((item) => ({\n\t\t\t\t\tpath: item.path,\n\t\t\t\t\tmetadata: { ...item.metadata, configurationOrigin: \"bundled\" as const },\n\t\t\t\t}));\n\t\tawait this.assets.extendResources({\n\t\t\tskillPaths: entries(resources.skills),\n\t\t\tpromptPaths: entries(resources.prompts),\n\t\t\tthemePaths: entries(resources.themes),\n\t\t});\n\t}\n\tgetExtensions() {\n\t\treturn this.extensions;\n\t}\n\tgetSkills(): ReturnType<ResourceLoader[\"getSkills\"]> {\n\t\tconst caller = this.delegate.getSkills();\n\t\tconst builtin = this.assets.getSkills();\n\t\tconst skills = caller.skills.filter((skill) => !this.isDisabledPath(skill.filePath));\n\t\tconst paths = new Set(skills.map((skill) => canonical(skill.filePath)));\n\t\treturn {\n\t\t\tskills: [...skills, ...builtin.skills.filter((skill) => !paths.has(canonical(skill.filePath)))],\n\t\t\tdiagnostics: [...caller.diagnostics, ...builtin.diagnostics],\n\t\t};\n\t}\n\tgetSkillCatalog() {\n\t\treturn buildSkillCatalog(this.getSkills().skills);\n\t}\n\tgetPrompts(): ReturnType<ResourceLoader[\"getPrompts\"]> {\n\t\tconst caller = this.delegate.getPrompts();\n\t\tconst builtin = this.assets.getPrompts();\n\t\tconst prompts = caller.prompts.filter((prompt) => !this.isDisabledPath(prompt.filePath));\n\t\tconst paths = new Set(prompts.map((prompt) => canonical(prompt.filePath)));\n\t\treturn {\n\t\t\tprompts: [...prompts, ...builtin.prompts.filter((prompt) => !paths.has(canonical(prompt.filePath)))],\n\t\t\tdiagnostics: [...caller.diagnostics, ...builtin.diagnostics],\n\t\t};\n\t}\n\tgetThemes(): ReturnType<ResourceLoader[\"getThemes\"]> {\n\t\tconst caller = this.delegate.getThemes();\n\t\tconst builtin = this.assets.getThemes();\n\t\treturn {\n\t\t\tthemes: [\n\t\t\t\t...caller.themes.filter((theme) => !theme.sourcePath || !this.isDisabledPath(theme.sourcePath)),\n\t\t\t\t...builtin.themes,\n\t\t\t],\n\t\t\tdiagnostics: [...caller.diagnostics, ...builtin.diagnostics],\n\t\t};\n\t}\n\tgetAgentsFiles() {\n\t\treturn this.delegate.getAgentsFiles();\n\t}\n\tgetSystemPrompt() {\n\t\treturn this.delegate.getSystemPrompt();\n\t}\n\tgetSystemPromptSource() {\n\t\treturn this.delegate.getSystemPromptSource();\n\t}\n\tgetAppendSystemPrompt() {\n\t\treturn this.delegate.getAppendSystemPrompt();\n\t}\n\tgetAppendSystemPromptSources() {\n\t\treturn this.delegate.getAppendSystemPromptSources();\n\t}\n\tasync extendResources(paths: ResourceExtensionPaths): Promise<void> {\n\t\tconst bundled: ResourceExtensionPaths = {};\n\t\tconst caller: ResourceExtensionPaths = {};\n\t\tfor (const kind of [\"skillPaths\", \"promptPaths\", \"themePaths\"] as const) {\n\t\t\tbundled[kind] = paths[kind]?.filter(\n\t\t\t\t(entry) => !this.isDisabledPath(entry.path) && entry.metadata.configurationOrigin === \"bundled\",\n\t\t\t);\n\t\t\tcaller[kind] = paths[kind]?.filter(\n\t\t\t\t(entry) => !this.isDisabledPath(entry.path) && entry.metadata.configurationOrigin !== \"bundled\",\n\t\t\t);\n\t\t}\n\t\tif (this.ownsDiscovery) {\n\t\t\tawait this.delegate.extendResources(caller);\n\t\t} else {\n\t\t\t// Extension-discovered assets belong to this session, not borrowed discovery.\n\t\t\tfor (const kind of [\"skillPaths\", \"promptPaths\", \"themePaths\"] as const) {\n\t\t\t\tbundled[kind] = [...(bundled[kind] ?? []), ...(caller[kind] ?? [])];\n\t\t\t}\n\t\t}\n\t\tawait this.assets.extendResources(bundled);\n\t}\n\tasync reload(options?: ResourceLoaderReloadOptions): Promise<void> {\n\t\tawait this.delegate.reload(options);\n\t\tthis.assets = new DefaultResourceLoader({\n\t\t\tcwd: this.cwd,\n\t\t\tagentDir: this.agentDir,\n\t\t\tsettingsManager: SettingsManager.inMemory(),\n\t\t\tnoContextFiles: true,\n\t\t});\n\t\tawait this.initialize();\n\t}\n\tsupportsTransactionalReload(): boolean {\n\t\treturn this.delegate.prepareReload !== undefined && this.delegate.supportsTransactionalReload?.() !== false;\n\t}\n\tasync prepareReload(\n\t\tsettings: SettingsManager,\n\t\toptions?: ResourceLoaderReloadOptions,\n\t): Promise<ResourceLoaderReloadTransaction> {\n\t\tif (!this.delegate.prepareReload) throw new Error(\"Resource loader does not support transactional reload\");\n\t\tconst transaction = await this.delegate.prepareReload(settings, options);\n\t\tconst candidate = new BuiltinResourceLoader(\n\t\t\ttransaction.loader,\n\t\t\tthis.cwd,\n\t\t\tthis.agentDir,\n\t\t\tthis.builtins,\n\t\t\tthis.disableWorkflowExtension,\n\t\t\ttrue,\n\t\t);\n\t\tsessionLifecycleScopes.set(candidate, lifecycleScopeForOwner(this));\n\t\tawait candidate.initialize();\n\t\tconst publish = () => {\n\t\t\tthis.extensions = candidate.extensions;\n\t\t\tthis.assets = candidate.assets;\n\t\t};\n\t\treturn {\n\t\t\t...transaction,\n\t\t\tloader: candidate,\n\t\t\t...(transaction.prepareCommit\n\t\t\t\t? {\n\t\t\t\t\t\tprepareCommit: () => {\n\t\t\t\t\t\t\tconst prepared = transaction.prepareCommit!();\n\t\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\t\tcommit: () => {\n\t\t\t\t\t\t\t\t\tprepared.commit();\n\t\t\t\t\t\t\t\t\tpublish();\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\trollback: () => prepared.rollback(),\n\t\t\t\t\t\t\t};\n\t\t\t\t\t\t},\n\t\t\t\t\t}\n\t\t\t\t: {}),\n\t\t\tcommit: () => {\n\t\t\t\ttransaction.commit();\n\t\t\t\tpublish();\n\t\t\t},\n\t\t};\n\t}\n}\n\nexport async function withBuiltinResourceLoader(\n\tloader: ResourceLoader,\n\tcwd: string,\n\tagentDir: string,\n\tbuiltins?: Partial<Record<AtomicBuiltin, boolean>>,\n\tdisableWorkflowExtension = false,\n): Promise<ResourceLoader> {\n\tif (\n\t\tloader instanceof BuiltinResourceLoader &&\n\t\tbuiltins === undefined &&\n\t\t!disableWorkflowExtension &&\n\t\tsessionLifecycleScopes.get(loader) === sessionLifecycleCreation.getStore()?.scope\n\t)\n\t\treturn loader;\n\tconst composed = new BuiltinResourceLoader(loader, cwd, agentDir, builtins, disableWorkflowExtension);\n\tawait composed.initialize();\n\treturn composed;\n}\n"]}
|