@astralyn/pi 0.84.3 → 0.84.4
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 +24 -0
- package/dist/cli/project-trust.d.ts.map +1 -1
- package/dist/cli/project-trust.js +1 -4
- package/dist/cli/project-trust.js.map +1 -1
- package/dist/core/extensions/index.d.ts +1 -1
- package/dist/core/extensions/index.d.ts.map +1 -1
- package/dist/core/extensions/index.js.map +1 -1
- package/dist/core/extensions/types.d.ts +2 -13
- package/dist/core/extensions/types.d.ts.map +1 -1
- package/dist/core/extensions/types.js.map +1 -1
- package/dist/extensions/subagent/agents-command.d.ts +4 -0
- package/dist/extensions/subagent/agents-command.d.ts.map +1 -0
- package/dist/extensions/subagent/agents-command.js +230 -0
- package/dist/extensions/subagent/agents-command.js.map +1 -0
- package/dist/extensions/subagent/agents.d.ts.map +1 -1
- package/dist/extensions/subagent/agents.js +2 -0
- package/dist/extensions/subagent/agents.js.map +1 -1
- package/dist/extensions/subagent/display-name.d.ts +6 -0
- package/dist/extensions/subagent/display-name.d.ts.map +1 -0
- package/dist/extensions/subagent/display-name.js +13 -0
- package/dist/extensions/subagent/display-name.js.map +1 -0
- package/dist/extensions/subagent/index.d.ts.map +1 -1
- package/dist/extensions/subagent/index.js +2 -127
- package/dist/extensions/subagent/index.js.map +1 -1
- package/dist/extensions/subagent/render.d.ts.map +1 -1
- package/dist/extensions/subagent/render.js +1 -10
- package/dist/extensions/subagent/render.js.map +1 -1
- package/dist/extensions/subagent/settings.d.ts +0 -1
- package/dist/extensions/subagent/settings.d.ts.map +1 -1
- package/dist/extensions/subagent/settings.js +3 -7
- package/dist/extensions/subagent/settings.js.map +1 -1
- package/dist/extensions/subagent/types.d.ts +2 -0
- package/dist/extensions/subagent/types.d.ts.map +1 -1
- package/dist/extensions/subagent/types.js.map +1 -1
- package/dist/extensions/subagent/ui/model-list.d.ts +67 -0
- package/dist/extensions/subagent/ui/model-list.d.ts.map +1 -0
- package/dist/extensions/subagent/ui/model-list.js +242 -0
- package/dist/extensions/subagent/ui/model-list.js.map +1 -0
- package/dist/extensions/subagent/ui/profile-editor.d.ts +54 -0
- package/dist/extensions/subagent/ui/profile-editor.d.ts.map +1 -0
- package/dist/extensions/subagent/ui/profile-editor.js +154 -0
- package/dist/extensions/subagent/ui/profile-editor.js.map +1 -0
- package/dist/extensions/subagent/ui/profile-picker.d.ts +32 -0
- package/dist/extensions/subagent/ui/profile-picker.d.ts.map +1 -0
- package/dist/extensions/subagent/ui/profile-picker.js +149 -0
- package/dist/extensions/subagent/ui/profile-picker.js.map +1 -0
- package/dist/extensions/todo/constants.d.ts +6 -17
- package/dist/extensions/todo/constants.d.ts.map +1 -1
- package/dist/extensions/todo/constants.js +20 -31
- package/dist/extensions/todo/constants.js.map +1 -1
- package/dist/extensions/todo/index.d.ts.map +1 -1
- package/dist/extensions/todo/index.js +36 -57
- package/dist/extensions/todo/index.js.map +1 -1
- package/dist/extensions/todo/schema.d.ts +20 -59
- package/dist/extensions/todo/schema.d.ts.map +1 -1
- package/dist/extensions/todo/schema.js +23 -69
- package/dist/extensions/todo/schema.js.map +1 -1
- package/dist/extensions/todo/state.d.ts +23 -65
- package/dist/extensions/todo/state.d.ts.map +1 -1
- package/dist/extensions/todo/state.js +238 -1262
- package/dist/extensions/todo/state.js.map +1 -1
- package/dist/extensions/todo/view.d.ts +19 -10
- package/dist/extensions/todo/view.d.ts.map +1 -1
- package/dist/extensions/todo/view.js +411 -463
- package/dist/extensions/todo/view.js.map +1 -1
- package/dist/extensions/todo/widget.d.ts +15 -0
- package/dist/extensions/todo/widget.d.ts.map +1 -0
- package/dist/extensions/todo/widget.js +50 -0
- package/dist/extensions/todo/widget.js.map +1 -0
- package/dist/modes/interactive/components/extension-selector.d.ts +1 -2
- package/dist/modes/interactive/components/extension-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/extension-selector.js +5 -11
- package/dist/modes/interactive/components/extension-selector.js.map +1 -1
- package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-mode.js.map +1 -1
- package/dist/modes/rpc/rpc-mode.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-mode.js +1 -8
- package/dist/modes/rpc/rpc-mode.js.map +1 -1
- package/docs/bundled/README.md +1 -1
- package/docs/bundled/extensions/subagent.md +19 -4
- package/docs/bundled/extensions/todo.md +84 -24
- package/docs/bundled/tool-presentation.md +1 -1
- package/npm-shrinkwrap.json +2 -2
- package/package.json +1 -1
- package/dist/extensions/subagent/picker.d.ts +0 -31
- package/dist/extensions/subagent/picker.d.ts.map +0 -1
- package/dist/extensions/subagent/picker.js +0 -109
- package/dist/extensions/subagent/picker.js.map +0 -1
- package/dist/extensions/todo/overlay.d.ts +0 -24
- package/dist/extensions/todo/overlay.d.ts.map +0 -1
- package/dist/extensions/todo/overlay.js +0 -135
- package/dist/extensions/todo/overlay.js.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agents-command.js","sourceRoot":"","sources":["../../../src/extensions/subagent/agents-command.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,kBAAkB,EAAE,0BAA0B,EAAE,MAAM,8BAA8B,CAAC;AAC9F,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAE9C,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAC7C,OAAO,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AACjD,OAAO,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AACrD,OAAO,EAAE,kBAAkB,EAAE,qBAAqB,EAAE,MAAM,eAAe,CAAC;AAE1E,OAAO,EAAE,sBAAsB,EAA4B,MAAM,wBAAwB,CAAC;AAC1F,OAAO,EAAE,sBAAsB,EAA4B,MAAM,wBAAwB,CAAC;AAE1F,MAAM,wBAAwB,GAAG,MAAM,CAAC;AACxC,MAAM,eAAe,GAAG,EAAE,CAAC;AAC3B,MAAM,qB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ClD,KAAK,EAAE,eAAe;YACtB,QAAQ,EAAE,eAAe,CAAC,GAAG,CAAC,qBAAqB,CAAC;SACpD,CAAC,CAAC;IACJ,CAAC;AACF,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,iBAAiB,CAAC,GAA4B,EAAE,eAA8B;IACnG,IAAI,CAAC,GAAG,CAAC,KAAK,EAAE,CAAC;QAChB,GAAG,CAAC,EAAE,CAAC,MAAM,CAAC,qCAAqC,EAAE,SAAS,CAAC,CAAC;QAChE,OAAO;IACR,CAAC;IACD,IAAI,GAAG,CAAC,IAAI,KAAK,KAAK;QAAE,MAAM,oBAAoB,CAAC,GAAG,EAAE,eAAe,CAAC,CAAC;;QACpE,MAAM,uBAAuB,CAAC,GAAG,EAAE,eAAe,CAAC,CAAC;AAC1D,CAAC","sourcesContent":["import type { ThinkingLevel } from \"@earendil-works/pi-agent-core\";\nimport type { Api, Model } from \"@earendil-works/pi-ai\";\nimport { clampThinkingLevel, getSupportedThinkingLevels } from \"@earendil-works/pi-ai/compat\";\nimport { getAgentDir } from \"../../config.ts\";\nimport type { ExtensionCommandContext } from \"../../core/extensions/types.ts\";\nimport { discoverAgents } from \"./agents.ts\";\nimport { THINKING_LEVELS } from \"./constants.ts\";\nimport { displayAgentName } from \"./display-name.ts\";\nimport { loadSubagentConfig, updateProfileOverride } from \"./settings.ts\";\nimport type { AgentDefinition, AgentDiagnostic, SubagentProfileOverride } from \"./types.ts\";\nimport { ProfileEditorComponent, type ProfileEditorResult } from \"./ui/profile-editor.ts\";\nimport { ProfilePickerComponent, type ProfilePickerResult } from \"./ui/profile-picker.ts\";\n\nconst MODEL_REFRESH_TIMEOUT_MS = 15_000;\nconst MAX_DIAGNOSTICS = 20;\nconst MAX_DIAGNOSTIC_LENGTH = 240;\nconst MAX_REFRESH_ERROR_LENGTH = 240;\n\nfunction compareAgentNames(left: AgentDefinition, right: AgentDefinition): number {\n\tif (left.name < right.name) return -1;\n\tif (left.name > right.name) return 1;\n\treturn 0;\n}\n\nfunction modelId(model: Pick<Model<Api>, \"provider\" | \"id\"> | undefined): string {\n\treturn model ? `${model.provider}/${model.id}` : \"none\";\n}\n\nfunction findModel(models: readonly Model<Api>[], value: string | undefined): Model<Api> | undefined {\n\tif (!value) return undefined;\n\treturn models.find((model) => `${model.provider}/${model.id}` === value);\n}\n\nfunction boundText(value: string, limit: number): string {\n\tconst characters = [...value];\n\treturn characters.length <= limit ? value : `${characters.slice(0, Math.max(0, limit - 1)).join(\"\")}…`;\n}\n\nfunction formatDiagnostics(diagnostics: readonly AgentDiagnostic[]): string {\n\tconst visible = diagnostics\n\t\t.slice(0, MAX_DIAGNOSTICS)\n\t\t.map((diagnostic) => boundText(`${diagnostic.path}: ${diagnostic.message}`, MAX_DIAGNOSTIC_LENGTH));\n\tif (diagnostics.length > visible.length) {\n\t\tvisible.push(\n\t\t\t`… ${diagnostics.length - visible.length} more issue${diagnostics.length - visible.length === 1 ? \"\" : \"s\"}`,\n\t\t);\n\t}\n\treturn visible.join(\"\\n\");\n}\n\nfunction overridesEqual(override: SubagentProfileOverride | undefined, result: ProfileEditorResult): boolean {\n\treturn override?.model === result.model && override?.thinking === result.thinking;\n}\n\nasync function saveProfileResult(\n\tctx: ExtensionCommandContext,\n\tprofileName: string,\n\toverride: SubagentProfileOverride | undefined,\n\tresult: ProfileEditorResult,\n): Promise<void> {\n\tif (overridesEqual(override, result)) return;\n\ttry {\n\t\tawait updateProfileOverride(profileName, { model: result.model, thinking: result.thinking }, getAgentDir());\n\t} catch (error) {\n\t\tctx.ui.notify(\n\t\t\t`Could not save ${displayAgentName(profileName)} settings: ${error instanceof Error ? error.message : String(error)}`,\n\t\t\t\"error\",\n\t\t);\n\t}\n}\n\nfunction refreshFailureMessage(providerIds: readonly string[]): string {\n\tif (providerIds.length === 1) return `Could not refresh ${providerIds[0]}; showing cached models.`;\n\tconst visible = providerIds.slice(0, 3);\n\tconst omitted = providerIds.length - visible.length;\n\tconst suffix = omitted > 0 ? `, +${omitted} more` : \"\";\n\treturn `Could not refresh ${providerIds.length} model catalogs (${visible.join(\", \")}${suffix}); showing cached models.`;\n}\n\nasync function refreshEditorModels(ctx: ExtensionCommandContext, editor: ProfileEditorComponent): Promise<void> {\n\tlet timedOut = false;\n\tconst timeout = setTimeout(() => {\n\t\ttimedOut = true;\n\t\teditor.cancelRefresh();\n\t}, MODEL_REFRESH_TIMEOUT_MS);\n\ttimeout.unref?.();\n\ttry {\n\t\tconst result = await ctx.modelRegistry.refresh({ signal: editor.refreshSignal });\n\t\tif (editor.refreshSignal.aborted && !timedOut) return;\n\t\teditor.updateModels(ctx.modelRegistry.getAvailable());\n\t\tif (result.aborted && timedOut) {\n\t\t\teditor.setRefreshStatus(\"Model refresh timed out; showing cached models.\", \"error\");\n\t\t\treturn;\n\t\t}\n\t\tconst providerIds = [...result.errors.keys()];\n\t\tif (providerIds.length > 0) {\n\t\t\teditor.setRefreshStatus(refreshFailureMessage(providerIds), \"error\");\n\t\t\treturn;\n\t\t}\n\t\tconst registryError = ctx.modelRegistry.getError();\n\t\tif (registryError) {\n\t\t\teditor.setRefreshStatus(boundText(registryError, MAX_REFRESH_ERROR_LENGTH), \"error\");\n\t\t\treturn;\n\t\t}\n\t\teditor.setRefreshStatus(\"Model catalogs refreshed.\", \"success\");\n\t} catch (error) {\n\t\tif (editor.refreshSignal.aborted && !timedOut) return;\n\t\tconst message = timedOut\n\t\t\t? \"Model refresh timed out; showing cached models.\"\n\t\t\t: `Could not refresh model catalogs: ${error instanceof Error ? error.message : String(error)}`;\n\t\teditor.setRefreshStatus(boundText(message, MAX_REFRESH_ERROR_LENGTH), \"error\");\n\t} finally {\n\t\tclearTimeout(timeout);\n\t}\n}\n\nasync function showTuiAgentsCommand(ctx: ExtensionCommandContext, currentThinking: ThinkingLevel): Promise<void> {\n\tconst agentDir = getAgentDir();\n\tlet selectedProfileName: string | undefined;\n\twhile (true) {\n\t\tconst discovery = discoverAgents(ctx.cwd, { projectTrusted: ctx.isProjectTrusted(), agentDir });\n\t\tconst picked = await ctx.ui.custom<ProfilePickerResult>(\n\t\t\t(_tui, theme, keybindings, done) =>\n\t\t\t\tnew ProfilePickerComponent(\n\t\t\t\t\ttheme,\n\t\t\t\t\tkeybindings,\n\t\t\t\t\tdiscovery.agents,\n\t\t\t\t\tdiscovery.diagnostics,\n\t\t\t\t\tdone,\n\t\t\t\t\tselectedProfileName,\n\t\t\t\t),\n\t\t);\n\t\tif (!picked) return;\n\t\tif (picked.kind === \"diagnostics\") {\n\t\t\tctx.ui.notify(formatDiagnostics(discovery.diagnostics), \"warning\");\n\t\t\tcontinue;\n\t\t}\n\n\t\tselectedProfileName = picked.name;\n\t\tconst agent = discovery.agents.find((candidate) => candidate.name === picked.name);\n\t\tif (!agent) continue;\n\t\tconst config = await loadSubagentConfig(agentDir);\n\t\tconst override = config.profiles[agent.name];\n\t\tconst edited = await ctx.ui.custom<ProfileEditorResult | undefined>((tui, theme, keybindings, done) => {\n\t\t\tconst editor = new ProfileEditorComponent({\n\t\t\t\ttui,\n\t\t\t\ttheme,\n\t\t\t\tkeybindings,\n\t\t\t\tagent,\n\t\t\t\toverride,\n\t\t\t\tmodels: ctx.modelRegistry.getAvailable(),\n\t\t\t\tscopedModels: ctx.scopedModels,\n\t\t\t\tcurrentSessionModel: ctx.model,\n\t\t\t\tcurrentThinking,\n\t\t\t\tonDone: done,\n\t\t\t});\n\t\t\teditor.setRefreshStatus(\"Refreshing model catalogs…\");\n\t\t\tvoid refreshEditorModels(ctx, editor);\n\t\t\treturn editor;\n\t\t});\n\t\tif (!edited) continue;\n\t\tawait saveProfileResult(ctx, agent.name, override, edited);\n\t}\n}\n\nfunction uniqueProfileLabels(agents: readonly AgentDefinition[]): Map<string, AgentDefinition> {\n\tconst sorted = [...agents].sort(compareAgentNames);\n\tconst counts = new Map<string, number>();\n\tfor (const agent of sorted) {\n\t\tconst display = displayAgentName(agent.name);\n\t\tcounts.set(display, (counts.get(display) ?? 0) + 1);\n\t}\n\treturn new Map(\n\t\tsorted.map((agent) => {\n\t\t\tconst display = displayAgentName(agent.name);\n\t\t\treturn [counts.get(display) === 1 ? display : `${display} (${agent.name})`, agent];\n\t\t}),\n\t);\n}\n\nasync function showDialogAgentsCommand(ctx: ExtensionCommandContext, currentThinking: ThinkingLevel): Promise<void> {\n\tconst agentDir = getAgentDir();\n\twhile (true) {\n\t\tconst discovery = discoverAgents(ctx.cwd, { projectTrusted: ctx.isProjectTrusted(), agentDir });\n\t\tconst labels = uniqueProfileLabels(discovery.agents);\n\t\tconst diagnosticsLabel = discovery.diagnostics.length\n\t\t\t? `View ${discovery.diagnostics.length} agent file issue${discovery.diagnostics.length === 1 ? \"\" : \"s\"}`\n\t\t\t: undefined;\n\t\tconst selectedLabel = await ctx.ui.select(\"Agents\", [\n\t\t\t...labels.keys(),\n\t\t\t...(diagnosticsLabel ? [diagnosticsLabel] : []),\n\t\t]);\n\t\tif (!selectedLabel) return;\n\t\tif (selectedLabel === diagnosticsLabel) {\n\t\t\tctx.ui.notify(formatDiagnostics(discovery.diagnostics), \"warning\");\n\t\t\tcontinue;\n\t\t}\n\t\tconst agent = labels.get(selectedLabel);\n\t\tif (!agent) continue;\n\n\t\tconst config = await loadSubagentConfig(agentDir);\n\t\tconst override = config.profiles[agent.name];\n\t\tconst models = ctx.modelRegistry.getAvailable().sort((left, right) => {\n\t\t\tconst provider = left.provider.localeCompare(right.provider);\n\t\t\treturn provider !== 0 ? provider : left.id.localeCompare(right.id);\n\t\t});\n\t\tconst modelChoices = new Map<string, string | undefined>();\n\t\tconst inheritModelLabel = `inherit (${modelId(ctx.model)})${override?.model ? \"\" : \" ✓\"}`;\n\t\tmodelChoices.set(inheritModelLabel, undefined);\n\t\tif (override?.model && !findModel(models, override.model)) {\n\t\t\tmodelChoices.set(`${override.model} [unavailable] ✓`, override.model);\n\t\t}\n\t\tfor (const model of models) {\n\t\t\tconst id = modelId(model);\n\t\t\tmodelChoices.set(`${id}${override?.model === id ? \" ✓\" : \"\"}`, id);\n\t\t}\n\t\tconst selectedModelLabel = await ctx.ui.select(`Model for ${displayAgentName(agent.name)}`, [\n\t\t\t...modelChoices.keys(),\n\t\t]);\n\t\tif (!selectedModelLabel) continue;\n\t\tconst selectedModelId = modelChoices.get(selectedModelLabel);\n\t\tconst effectiveModel = selectedModelId ? findModel(models, selectedModelId) : ctx.model;\n\t\tconst levels = effectiveModel\n\t\t\t? (getSupportedThinkingLevels(effectiveModel) as ThinkingLevel[])\n\t\t\t: [...THINKING_LEVELS];\n\t\tconst inheritedThinking = effectiveModel\n\t\t\t? (clampThinkingLevel(effectiveModel, currentThinking) as ThinkingLevel)\n\t\t\t: currentThinking;\n\t\tconst thinkingChoices = new Map<string, ThinkingLevel | undefined>();\n\t\tthinkingChoices.set(`inherit (${inheritedThinking})${override?.thinking ? \"\" : \" ✓\"}`, undefined);\n\t\tfor (const level of levels) {\n\t\t\tthinkingChoices.set(`${level}${override?.thinking === level ? \" ✓\" : \"\"}`, level);\n\t\t}\n\t\tconst selectedThinkingLabel = await ctx.ui.select(`Thinking for ${displayAgentName(agent.name)}`, [\n\t\t\t...thinkingChoices.keys(),\n\t\t]);\n\t\tif (!selectedThinkingLabel) continue;\n\t\tawait saveProfileResult(ctx, agent.name, override, {\n\t\t\tmodel: selectedModelId,\n\t\t\tthinking: thinkingChoices.get(selectedThinkingLabel),\n\t\t});\n\t}\n}\n\nexport async function showAgentsCommand(ctx: ExtensionCommandContext, currentThinking: ThinkingLevel): Promise<void> {\n\tif (!ctx.hasUI) {\n\t\tctx.ui.notify(\"/agents requires an interactive UI.\", \"warning\");\n\t\treturn;\n\t}\n\tif (ctx.mode === \"tui\") await showTuiAgentsCommand(ctx, currentThinking);\n\telse await showDialogAgentsCommand(ctx, currentThinking);\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agents.d.ts","sourceRoot":"","sources":["../../../src/extensions/subagent/agents.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAoC,oBAAoB,EAAe,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"agents.d.ts","sourceRoot":"","sources":["../../../src/extensions/subagent/agents.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAoC,oBAAoB,EAAe,MAAM,YAAY,CAAC;AA+ItG,wBAAgB,cAAc,CAC7B,GAAG,EAAE,MAAM,EACX,OAAO,EAAE;IAAE,cAAc,EAAE,OAAO,CAAC;IAAC,QAAQ,CAAC,EAAE,MAAM,CAAA;CAAE,GACrD,oBAAoB,CAiBtB;AAED,wBAAgB,uBAAuB,CAAC,SAAS,EAAE,oBAAoB,GAAG,MAAM,CAqD/E"}
|
|
@@ -12,6 +12,7 @@ const BUILTIN_AGENTS = [
|
|
|
12
12
|
{
|
|
13
13
|
name: "general",
|
|
14
14
|
description: "Implementation agent for bounded coding tasks: edits, fixes, refactors, and verification in a scoped area. Use when the task changes files; use explorer for read-only questions",
|
|
15
|
+
uiDescription: "Implementation agent for bounded coding tasks: edits, fixes, refactors, and verification in a scoped area.",
|
|
15
16
|
tools: [...DEFAULT_AGENT_TOOLS],
|
|
16
17
|
systemPrompt: [
|
|
17
18
|
"Work independently on the delegated task from start to finish.",
|
|
@@ -26,6 +27,7 @@ const BUILTIN_AGENTS = [
|
|
|
26
27
|
{
|
|
27
28
|
name: "explorer",
|
|
28
29
|
description: 'Fast read-only agent for finding files, searching code, and answering codebase questions. Can inspect git history (log, blame, diff) via read-only bash. State thoroughness in the prompt: "quick" for a targeted lookup, "medium" for checking likely related locations, or "very thorough" for exhaustive sweeps across locations and naming conventions',
|
|
30
|
+
uiDescription: "Fast read-only agent for finding files, searching code, and answering codebase questions.",
|
|
29
31
|
tools: [...EXPLORER_TOOLS],
|
|
30
32
|
systemPrompt: [
|
|
31
33
|
"You are a fast read-only exploration agent; return findings as quickly as possible.",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agents.js","sourceRoot":"","sources":["../../../src/extensions/subagent/agents.ts"],"names":[],"mappings":"AAAA,O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A+J;KAC/J,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AACd,CAAC","sourcesContent":["import { type Dirent, existsSync, readdirSync, readFileSync, statSync } from \"node:fs\";\nimport { dirname, join } from \"node:path\";\nimport { CONFIG_DIR_NAME, getAgentDir } from \"../../config.ts\";\nimport { parseFrontmatter } from \"../../utils/frontmatter.ts\";\nimport { utf8Prefix } from \"./activity.ts\";\nimport { BUILTIN_TOOL_NAMES, DEFAULT_AGENT_TOOLS, EXPLORER_TOOLS, MAX_CONCURRENCY, MAX_TASKS } from \"./constants.ts\";\nimport type { AgentDefinition, AgentDiagnostic, AgentDiscoveryResult, AgentSource } from \"./types.ts\";\n\nconst AGENT_NAME_PATTERN = /^[a-z0-9][a-z0-9_-]{0,79}$/u;\nconst BUILTIN_TOOL_SET = new Set<string>(BUILTIN_TOOL_NAMES);\nconst TOOL_DESCRIPTION_AGENT_LIST_LIMIT = 8_000;\nconst TOOL_DESCRIPTION_AGENT_SUMMARY_LIMIT = 480;\n\nconst BUILTIN_AGENTS: AgentDefinition[] = [\n\t{\n\t\tname: \"general\",\n\t\tdescription:\n\t\t\t\"Implementation agent for bounded coding tasks: edits, fixes, refactors, and verification in a scoped area. Use when the task changes files; use explorer for read-only questions\",\n\t\ttools: [...DEFAULT_AGENT_TOOLS],\n\t\tsystemPrompt: [\n\t\t\t\"Work independently on the delegated task from start to finish.\",\n\t\t\t\"Inspect relevant repository instructions before changing files.\",\n\t\t\t\"Prefer editing existing files; never create documentation files unless the task explicitly asks for them.\",\n\t\t\t\"Keep changes focused, run appropriate verification, and report exact paths, checks, blockers, and remaining risks.\",\n\t\t].join(\"\\n\"),\n\t\tsource: \"builtin\",\n\t\tfilePath: \"<builtin:general>\",\n\t\tbackend: \"sdk\",\n\t},\n\t{\n\t\tname: \"explorer\",\n\t\tdescription:\n\t\t\t'Fast read-only agent for finding files, searching code, and answering codebase questions. Can inspect git history (log, blame, diff) via read-only bash. State thoroughness in the prompt: \"quick\" for a targeted lookup, \"medium\" for checking likely related locations, or \"very thorough\" for exhaustive sweeps across locations and naming conventions',\n\t\ttools: [...EXPLORER_TOOLS],\n\t\tsystemPrompt: [\n\t\t\t\"You are a fast read-only exploration agent; return findings as quickly as possible.\",\n\t\t\t\"Explore the delegated question without modifying files.\",\n\t\t\t\"Use read and search tools to gather exact evidence, batching independent searches and reads instead of running them one at a time.\",\n\t\t\t\"bash is for read-only inspection only: git log/diff/blame/show/status, ls, wc, head, tail, cat, and similar.\",\n\t\t\t\"Never run anything that modifies state: no file creation or deletion, no redirect (>, >>) or heredoc writes, no temp files, no git commands that write (add, commit, checkout, restore, stash, clean), no installs, no network access.\",\n\t\t\t\"Match the depth the caller requested: quick targets the direct question, medium checks likely related locations, and very thorough sweeps multiple locations and naming conventions.\",\n\t\t\t\"Return concise findings with precise paths, symbols, relationships, and unresolved uncertainties.\",\n\t\t].join(\"\\n\"),\n\t\tsource: \"builtin\",\n\t\tfilePath: \"<builtin:explorer>\",\n\t\tbackend: \"sdk\",\n\t\tomitContextFiles: true,\n\t},\n];\n\nfunction isDirectory(path: string): boolean {\n\ttry {\n\t\treturn statSync(path).isDirectory();\n\t} catch {\n\t\treturn false;\n\t}\n}\n\nfunction findNearestProjectAgentsDir(cwd: string): string | undefined {\n\tlet current = cwd;\n\twhile (true) {\n\t\tconst candidate = join(current, CONFIG_DIR_NAME, \"agents\");\n\t\tif (isDirectory(candidate)) return candidate;\n\t\tconst parent = dirname(current);\n\t\tif (parent === current) return undefined;\n\t\tcurrent = parent;\n\t}\n}\n\nfunction parseTools(raw: string | undefined, filePath: string): string[] {\n\tif (!raw?.trim()) return [...DEFAULT_AGENT_TOOLS];\n\tconst tools = [\n\t\t...new Set(\n\t\t\traw\n\t\t\t\t.split(\",\")\n\t\t\t\t.map((tool) => tool.trim())\n\t\t\t\t.filter(Boolean),\n\t\t),\n\t];\n\tconst unsupported = tools.filter((tool) => !BUILTIN_TOOL_SET.has(tool));\n\tif (unsupported.length > 0) {\n\t\tthrow new Error(`Unsupported tool(s) ${unsupported.join(\", \")} in ${filePath}.`);\n\t}\n\treturn tools;\n}\n\n// Frontmatter model/thinking keys are intentionally ignored: agent files\n// travel across machines (project repos), so a pinned model rarely exists\n// in the reader's environment. Model and thinking come from /agents\n// overrides or default to the parent session.\nfunction parseAgentFile(filePath: string, source: Exclude<AgentSource, \"builtin\">): AgentDefinition {\n\tconst content = readFileSync(filePath, \"utf8\");\n\tconst { frontmatter, body } = parseFrontmatter<Record<string, string>>(content);\n\tconst name = frontmatter.name?.trim() ?? \"\";\n\tconst description = frontmatter.description?.trim() ?? \"\";\n\tif (!name) throw new Error(\"Missing required frontmatter field: name.\");\n\tif (!AGENT_NAME_PATTERN.test(name)) {\n\t\tthrow new Error(`Agent name \"${name}\" must use lowercase letters, digits, hyphens, or underscores.`);\n\t}\n\tif (!description) throw new Error(\"Missing required frontmatter field: description.\");\n\tif (!body.trim()) throw new Error(\"Agent prompt body must not be empty.\");\n\tconst backend = frontmatter.backend?.trim();\n\tif (backend && backend !== \"sdk\") throw new Error(`Backend \"${backend}\" is not implemented; use \"sdk\".`);\n\treturn {\n\t\tname,\n\t\tdescription,\n\t\ttools: parseTools(frontmatter.tools, filePath),\n\t\tsystemPrompt: body.trim(),\n\t\tsource,\n\t\tfilePath,\n\t\tbackend: \"sdk\",\n\t};\n}\n\nfunction loadAgentDirectory(\n\tdir: string,\n\tsource: Exclude<AgentSource, \"builtin\">,\n): { agents: AgentDefinition[]; diagnostics: AgentDiagnostic[] } {\n\tif (!existsSync(dir)) return { agents: [], diagnostics: [] };\n\tlet entries: Dirent[];\n\ttry {\n\t\tentries = readdirSync(dir, { withFileTypes: true }).sort((left, right) => left.name.localeCompare(right.name));\n\t} catch (error) {\n\t\treturn {\n\t\t\tagents: [],\n\t\t\tdiagnostics: [{ path: dir, source, message: error instanceof Error ? error.message : String(error) }],\n\t\t};\n\t}\n\tconst agents: AgentDefinition[] = [];\n\tconst diagnostics: AgentDiagnostic[] = [];\n\tfor (const entry of entries) {\n\t\tif (!entry.name.endsWith(\".md\") || (!entry.isFile() && !entry.isSymbolicLink())) continue;\n\t\tconst filePath = join(dir, entry.name);\n\t\ttry {\n\t\t\tagents.push(parseAgentFile(filePath, source));\n\t\t} catch (error) {\n\t\t\tdiagnostics.push({\n\t\t\t\tpath: filePath,\n\t\t\t\tsource,\n\t\t\t\tmessage: error instanceof Error ? error.message : String(error),\n\t\t\t});\n\t\t}\n\t}\n\treturn { agents, diagnostics };\n}\n\nexport function discoverAgents(\n\tcwd: string,\n\toptions: { projectTrusted: boolean; agentDir?: string },\n): AgentDiscoveryResult {\n\tconst userDir = join(options.agentDir ?? getAgentDir(), \"agents\");\n\tconst projectAgentsDir = findNearestProjectAgentsDir(cwd);\n\tconst user = loadAgentDirectory(userDir, \"user\");\n\tconst project =\n\t\toptions.projectTrusted && projectAgentsDir\n\t\t\t? loadAgentDirectory(projectAgentsDir, \"project\")\n\t\t\t: { agents: [], diagnostics: [] };\n\tconst agents = new Map(BUILTIN_AGENTS.map((agent) => [agent.name, { ...agent, tools: [...agent.tools] }]));\n\tfor (const agent of user.agents) agents.set(agent.name, agent);\n\tfor (const agent of project.agents) agents.set(agent.name, agent);\n\treturn {\n\t\tagents: [...agents.values()],\n\t\tdiagnostics: [...user.diagnostics, ...project.diagnostics],\n\t\tprojectAgentsDir,\n\t\tprojectAgentsTrusted: options.projectTrusted,\n\t};\n}\n\nexport function subagentToolDescription(discovery: AgentDiscoveryResult): string {\n\tconst agentLines: string[] = [];\n\tlet agentListLength = 0;\n\tfor (const [index, agent] of discovery.agents.entries()) {\n\t\tconst normalizedDescription = agent.description.replace(/\\s+/gu, \" \").trim();\n\t\tconst description =\n\t\t\tBuffer.byteLength(normalizedDescription, \"utf8\") <= TOOL_DESCRIPTION_AGENT_SUMMARY_LIMIT\n\t\t\t\t? normalizedDescription\n\t\t\t\t: `${utf8Prefix(normalizedDescription, TOOL_DESCRIPTION_AGENT_SUMMARY_LIMIT - Buffer.byteLength(\"…\", \"utf8\"))}…`;\n\t\tconst defaultLabel = agent.name === \"general\" ? \" (default)\" : \"\";\n\t\tconst tools = agent.tools.length > 0 ? agent.tools.join(\", \") : \"none\";\n\t\tconst line = `- ${agent.name}${defaultLabel}: ${description} (Tools: ${tools})`;\n\t\tconst lineLength = Buffer.byteLength(line, \"utf8\") + 1;\n\t\tif (agentListLength + lineLength > TOOL_DESCRIPTION_AGENT_LIST_LIMIT) {\n\t\t\tlet omitted = discovery.agents.length - index;\n\t\t\tlet notice = `- ${omitted} additional profile${omitted === 1 ? \"\" : \"s\"} omitted from this bounded description; /agents lists every profile.`;\n\t\t\twhile (\n\t\t\t\tagentLines.length > 0 &&\n\t\t\t\tagentListLength + Buffer.byteLength(notice, \"utf8\") + 1 > TOOL_DESCRIPTION_AGENT_LIST_LIMIT\n\t\t\t) {\n\t\t\t\tconst removed = agentLines.pop();\n\t\t\t\tif (!removed) break;\n\t\t\t\tagentListLength -= Buffer.byteLength(removed, \"utf8\") + 1;\n\t\t\t\tomitted++;\n\t\t\t\tnotice = `- ${omitted} additional profile${omitted === 1 ? \"\" : \"s\"} omitted from this bounded description; /agents lists every profile.`;\n\t\t\t}\n\t\t\tagentLines.push(notice);\n\t\t\tbreak;\n\t\t}\n\t\tagentLines.push(line);\n\t\tagentListLength += lineLength;\n\t}\n\n\treturn [\n\t\t`Delegate bounded work to isolated one-shot subagents. Delegation keeps intermediate tool output (file dumps, search results) out of your context: you receive only the final report. Choose exactly one mode: prompt for one task, or tasks for independent parallel work (up to ${MAX_TASKS} per call; ${MAX_CONCURRENCY} run concurrently, the rest queue). For sequential work, call this tool again with the previous result folded into the next briefing.`,\n\t\t\"\",\n\t\t\"Available agent profiles:\",\n\t\t...agentLines,\n\t\t\"\",\n\t\t\"When not to delegate:\",\n\t\t\"- Read a known file directly with read, or search for a known symbol directly with grep.\",\n\t\t\"- Prefer direct tools when a directed lookup answers the question; delegate when the investigation will clearly take more than ~3 searches or would flood your context with intermediate output.\",\n\t\t\"- Do not delegate a trivial task when the coordination overhead exceeds the work.\",\n\t\t\"\",\n\t\t\"Writing the briefing:\",\n\t\t\"- Brief the worker like a capable colleague entering the project now: include the objective, relevant context, exact paths or symbols already known, constraints, and expected output.\",\n\t\t\"- Never delegate understanding with vague instructions such as 'fix this based on your findings'; state what must be investigated or changed and whether the worker should research, implement, or review.\",\n\t\t\"- Lookups: hand over the exact command or file. Investigations: hand over the question — prescribed steps become dead weight when the premise is wrong.\",\n\t\t'- If you need a short answer, say so (e.g. \"report in under 200 words\"). Workers cannot see the parent conversation or ask the end user questions.',\n\t\t'- Example briefing (explorer): \"Quick: which commit introduced the retry loop in src/net/client.ts? Use git log/blame; report the hash and a one-line summary.\"',\n\t\t\"\",\n\t\t\"The subagent's report is not shown to the user. Interpret it and relay the important findings, changes, verification, and unresolved risks in your own reply.\",\n\t].join(\"\\n\");\n}\n"]}
|
|
1
|
+
{"version":3,"file":"agents.js","sourceRoot":"","sources":["../../../src/extensions/subagent/agents.ts"],"names":[],"mappings":"AAAA,OAAO,EAAe,UAAU,EAAE,WAAW,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AACvF,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,eAAe,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAC/D,OAAO,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAC;AAC9D,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAC3C,OAAO,EAAE,kBAAkB,EAAE,mBAAmB,EAAE,cAAc,EAAE,eAAe,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAGrH,MAAM,kBAAkB,GAAG,6BAA6B,CAAC;AACzD,MAAM,gBAAgB,GAAG,IAAI,GAAG,CAAS,kBAAkB,CAAC,CAAC;AAC7D,MAAM,iCAAiC,GAAG,KAAK,CAAC;AAChD,MAAM,oCAAoC,GAAG,GAAG,CAAC;AAEjD,MA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Ae,IAAI,MAAM,CAAC,UAAU,CAAC,OAAO,EAAE,MAAM,CAAC,GAAG,CAAC,CAAC;gBAC1D,OAAO,EAAE,CAAC;gBACV,MAAM,GAAG,KAAK,OAAO,sBAAsB,OAAO,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,sEAAsE,CAAC;YAC3I,CAAC;YACD,UAAU,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;YACxB,MAAM;QACP,CAAC;QACD,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACtB,eAAe,IAAI,UAAU,CAAC;IAC/B,CAAC;IAED,OAAO;QACN,oRAAoR,SAAS,cAAc,eAAe,uIAAuI;QACjc,EAAE;QACF,2BAA2B;QAC3B,GAAG,UAAU;QACb,EAAE;QACF,uBAAuB;QACvB,0FAA0F;QAC1F,kMAAkM;QAClM,mFAAmF;QACnF,EAAE;QACF,uBAAuB;QACvB,wLAAwL;QACxL,4MAA4M;QAC5M,yJAAyJ;QACzJ,oJAAoJ;QACpJ,iKAAiK;QACjK,EAAE;QACF,+JAA+J;KAC/J,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AACd,CAAC","sourcesContent":["import { type Dirent, existsSync, readdirSync, readFileSync, statSync } from \"node:fs\";\nimport { dirname, join } from \"node:path\";\nimport { CONFIG_DIR_NAME, getAgentDir } from \"../../config.ts\";\nimport { parseFrontmatter } from \"../../utils/frontmatter.ts\";\nimport { utf8Prefix } from \"./activity.ts\";\nimport { BUILTIN_TOOL_NAMES, DEFAULT_AGENT_TOOLS, EXPLORER_TOOLS, MAX_CONCURRENCY, MAX_TASKS } from \"./constants.ts\";\nimport type { AgentDefinition, AgentDiagnostic, AgentDiscoveryResult, AgentSource } from \"./types.ts\";\n\nconst AGENT_NAME_PATTERN = /^[a-z0-9][a-z0-9_-]{0,79}$/u;\nconst BUILTIN_TOOL_SET = new Set<string>(BUILTIN_TOOL_NAMES);\nconst TOOL_DESCRIPTION_AGENT_LIST_LIMIT = 8_000;\nconst TOOL_DESCRIPTION_AGENT_SUMMARY_LIMIT = 480;\n\nconst BUILTIN_AGENTS: AgentDefinition[] = [\n\t{\n\t\tname: \"general\",\n\t\tdescription:\n\t\t\t\"Implementation agent for bounded coding tasks: edits, fixes, refactors, and verification in a scoped area. Use when the task changes files; use explorer for read-only questions\",\n\t\tuiDescription:\n\t\t\t\"Implementation agent for bounded coding tasks: edits, fixes, refactors, and verification in a scoped area.\",\n\t\ttools: [...DEFAULT_AGENT_TOOLS],\n\t\tsystemPrompt: [\n\t\t\t\"Work independently on the delegated task from start to finish.\",\n\t\t\t\"Inspect relevant repository instructions before changing files.\",\n\t\t\t\"Prefer editing existing files; never create documentation files unless the task explicitly asks for them.\",\n\t\t\t\"Keep changes focused, run appropriate verification, and report exact paths, checks, blockers, and remaining risks.\",\n\t\t].join(\"\\n\"),\n\t\tsource: \"builtin\",\n\t\tfilePath: \"<builtin:general>\",\n\t\tbackend: \"sdk\",\n\t},\n\t{\n\t\tname: \"explorer\",\n\t\tdescription:\n\t\t\t'Fast read-only agent for finding files, searching code, and answering codebase questions. Can inspect git history (log, blame, diff) via read-only bash. State thoroughness in the prompt: \"quick\" for a targeted lookup, \"medium\" for checking likely related locations, or \"very thorough\" for exhaustive sweeps across locations and naming conventions',\n\t\tuiDescription: \"Fast read-only agent for finding files, searching code, and answering codebase questions.\",\n\t\ttools: [...EXPLORER_TOOLS],\n\t\tsystemPrompt: [\n\t\t\t\"You are a fast read-only exploration agent; return findings as quickly as possible.\",\n\t\t\t\"Explore the delegated question without modifying files.\",\n\t\t\t\"Use read and search tools to gather exact evidence, batching independent searches and reads instead of running them one at a time.\",\n\t\t\t\"bash is for read-only inspection only: git log/diff/blame/show/status, ls, wc, head, tail, cat, and similar.\",\n\t\t\t\"Never run anything that modifies state: no file creation or deletion, no redirect (>, >>) or heredoc writes, no temp files, no git commands that write (add, commit, checkout, restore, stash, clean), no installs, no network access.\",\n\t\t\t\"Match the depth the caller requested: quick targets the direct question, medium checks likely related locations, and very thorough sweeps multiple locations and naming conventions.\",\n\t\t\t\"Return concise findings with precise paths, symbols, relationships, and unresolved uncertainties.\",\n\t\t].join(\"\\n\"),\n\t\tsource: \"builtin\",\n\t\tfilePath: \"<builtin:explorer>\",\n\t\tbackend: \"sdk\",\n\t\tomitContextFiles: true,\n\t},\n];\n\nfunction isDirectory(path: string): boolean {\n\ttry {\n\t\treturn statSync(path).isDirectory();\n\t} catch {\n\t\treturn false;\n\t}\n}\n\nfunction findNearestProjectAgentsDir(cwd: string): string | undefined {\n\tlet current = cwd;\n\twhile (true) {\n\t\tconst candidate = join(current, CONFIG_DIR_NAME, \"agents\");\n\t\tif (isDirectory(candidate)) return candidate;\n\t\tconst parent = dirname(current);\n\t\tif (parent === current) return undefined;\n\t\tcurrent = parent;\n\t}\n}\n\nfunction parseTools(raw: string | undefined, filePath: string): string[] {\n\tif (!raw?.trim()) return [...DEFAULT_AGENT_TOOLS];\n\tconst tools = [\n\t\t...new Set(\n\t\t\traw\n\t\t\t\t.split(\",\")\n\t\t\t\t.map((tool) => tool.trim())\n\t\t\t\t.filter(Boolean),\n\t\t),\n\t];\n\tconst unsupported = tools.filter((tool) => !BUILTIN_TOOL_SET.has(tool));\n\tif (unsupported.length > 0) {\n\t\tthrow new Error(`Unsupported tool(s) ${unsupported.join(\", \")} in ${filePath}.`);\n\t}\n\treturn tools;\n}\n\n// Frontmatter model/thinking keys are intentionally ignored: agent files\n// travel across machines (project repos), so a pinned model rarely exists\n// in the reader's environment. Model and thinking come from /agents\n// overrides or default to the parent session.\nfunction parseAgentFile(filePath: string, source: Exclude<AgentSource, \"builtin\">): AgentDefinition {\n\tconst content = readFileSync(filePath, \"utf8\");\n\tconst { frontmatter, body } = parseFrontmatter<Record<string, string>>(content);\n\tconst name = frontmatter.name?.trim() ?? \"\";\n\tconst description = frontmatter.description?.trim() ?? \"\";\n\tif (!name) throw new Error(\"Missing required frontmatter field: name.\");\n\tif (!AGENT_NAME_PATTERN.test(name)) {\n\t\tthrow new Error(`Agent name \"${name}\" must use lowercase letters, digits, hyphens, or underscores.`);\n\t}\n\tif (!description) throw new Error(\"Missing required frontmatter field: description.\");\n\tif (!body.trim()) throw new Error(\"Agent prompt body must not be empty.\");\n\tconst backend = frontmatter.backend?.trim();\n\tif (backend && backend !== \"sdk\") throw new Error(`Backend \"${backend}\" is not implemented; use \"sdk\".`);\n\treturn {\n\t\tname,\n\t\tdescription,\n\t\ttools: parseTools(frontmatter.tools, filePath),\n\t\tsystemPrompt: body.trim(),\n\t\tsource,\n\t\tfilePath,\n\t\tbackend: \"sdk\",\n\t};\n}\n\nfunction loadAgentDirectory(\n\tdir: string,\n\tsource: Exclude<AgentSource, \"builtin\">,\n): { agents: AgentDefinition[]; diagnostics: AgentDiagnostic[] } {\n\tif (!existsSync(dir)) return { agents: [], diagnostics: [] };\n\tlet entries: Dirent[];\n\ttry {\n\t\tentries = readdirSync(dir, { withFileTypes: true }).sort((left, right) => left.name.localeCompare(right.name));\n\t} catch (error) {\n\t\treturn {\n\t\t\tagents: [],\n\t\t\tdiagnostics: [{ path: dir, source, message: error instanceof Error ? error.message : String(error) }],\n\t\t};\n\t}\n\tconst agents: AgentDefinition[] = [];\n\tconst diagnostics: AgentDiagnostic[] = [];\n\tfor (const entry of entries) {\n\t\tif (!entry.name.endsWith(\".md\") || (!entry.isFile() && !entry.isSymbolicLink())) continue;\n\t\tconst filePath = join(dir, entry.name);\n\t\ttry {\n\t\t\tagents.push(parseAgentFile(filePath, source));\n\t\t} catch (error) {\n\t\t\tdiagnostics.push({\n\t\t\t\tpath: filePath,\n\t\t\t\tsource,\n\t\t\t\tmessage: error instanceof Error ? error.message : String(error),\n\t\t\t});\n\t\t}\n\t}\n\treturn { agents, diagnostics };\n}\n\nexport function discoverAgents(\n\tcwd: string,\n\toptions: { projectTrusted: boolean; agentDir?: string },\n): AgentDiscoveryResult {\n\tconst userDir = join(options.agentDir ?? getAgentDir(), \"agents\");\n\tconst projectAgentsDir = findNearestProjectAgentsDir(cwd);\n\tconst user = loadAgentDirectory(userDir, \"user\");\n\tconst project =\n\t\toptions.projectTrusted && projectAgentsDir\n\t\t\t? loadAgentDirectory(projectAgentsDir, \"project\")\n\t\t\t: { agents: [], diagnostics: [] };\n\tconst agents = new Map(BUILTIN_AGENTS.map((agent) => [agent.name, { ...agent, tools: [...agent.tools] }]));\n\tfor (const agent of user.agents) agents.set(agent.name, agent);\n\tfor (const agent of project.agents) agents.set(agent.name, agent);\n\treturn {\n\t\tagents: [...agents.values()],\n\t\tdiagnostics: [...user.diagnostics, ...project.diagnostics],\n\t\tprojectAgentsDir,\n\t\tprojectAgentsTrusted: options.projectTrusted,\n\t};\n}\n\nexport function subagentToolDescription(discovery: AgentDiscoveryResult): string {\n\tconst agentLines: string[] = [];\n\tlet agentListLength = 0;\n\tfor (const [index, agent] of discovery.agents.entries()) {\n\t\tconst normalizedDescription = agent.description.replace(/\\s+/gu, \" \").trim();\n\t\tconst description =\n\t\t\tBuffer.byteLength(normalizedDescription, \"utf8\") <= TOOL_DESCRIPTION_AGENT_SUMMARY_LIMIT\n\t\t\t\t? normalizedDescription\n\t\t\t\t: `${utf8Prefix(normalizedDescription, TOOL_DESCRIPTION_AGENT_SUMMARY_LIMIT - Buffer.byteLength(\"…\", \"utf8\"))}…`;\n\t\tconst defaultLabel = agent.name === \"general\" ? \" (default)\" : \"\";\n\t\tconst tools = agent.tools.length > 0 ? agent.tools.join(\", \") : \"none\";\n\t\tconst line = `- ${agent.name}${defaultLabel}: ${description} (Tools: ${tools})`;\n\t\tconst lineLength = Buffer.byteLength(line, \"utf8\") + 1;\n\t\tif (agentListLength + lineLength > TOOL_DESCRIPTION_AGENT_LIST_LIMIT) {\n\t\t\tlet omitted = discovery.agents.length - index;\n\t\t\tlet notice = `- ${omitted} additional profile${omitted === 1 ? \"\" : \"s\"} omitted from this bounded description; /agents lists every profile.`;\n\t\t\twhile (\n\t\t\t\tagentLines.length > 0 &&\n\t\t\t\tagentListLength + Buffer.byteLength(notice, \"utf8\") + 1 > TOOL_DESCRIPTION_AGENT_LIST_LIMIT\n\t\t\t) {\n\t\t\t\tconst removed = agentLines.pop();\n\t\t\t\tif (!removed) break;\n\t\t\t\tagentListLength -= Buffer.byteLength(removed, \"utf8\") + 1;\n\t\t\t\tomitted++;\n\t\t\t\tnotice = `- ${omitted} additional profile${omitted === 1 ? \"\" : \"s\"} omitted from this bounded description; /agents lists every profile.`;\n\t\t\t}\n\t\t\tagentLines.push(notice);\n\t\t\tbreak;\n\t\t}\n\t\tagentLines.push(line);\n\t\tagentListLength += lineLength;\n\t}\n\n\treturn [\n\t\t`Delegate bounded work to isolated one-shot subagents. Delegation keeps intermediate tool output (file dumps, search results) out of your context: you receive only the final report. Choose exactly one mode: prompt for one task, or tasks for independent parallel work (up to ${MAX_TASKS} per call; ${MAX_CONCURRENCY} run concurrently, the rest queue). For sequential work, call this tool again with the previous result folded into the next briefing.`,\n\t\t\"\",\n\t\t\"Available agent profiles:\",\n\t\t...agentLines,\n\t\t\"\",\n\t\t\"When not to delegate:\",\n\t\t\"- Read a known file directly with read, or search for a known symbol directly with grep.\",\n\t\t\"- Prefer direct tools when a directed lookup answers the question; delegate when the investigation will clearly take more than ~3 searches or would flood your context with intermediate output.\",\n\t\t\"- Do not delegate a trivial task when the coordination overhead exceeds the work.\",\n\t\t\"\",\n\t\t\"Writing the briefing:\",\n\t\t\"- Brief the worker like a capable colleague entering the project now: include the objective, relevant context, exact paths or symbols already known, constraints, and expected output.\",\n\t\t\"- Never delegate understanding with vague instructions such as 'fix this based on your findings'; state what must be investigated or changed and whether the worker should research, implement, or review.\",\n\t\t\"- Lookups: hand over the exact command or file. Investigations: hand over the question — prescribed steps become dead weight when the premise is wrong.\",\n\t\t'- If you need a short answer, say so (e.g. \"report in under 200 words\"). Workers cannot see the parent conversation or ask the end user questions.',\n\t\t'- Example briefing (explorer): \"Quick: which commit introduced the retry loop in src/net/client.ts? Use git log/blame; report the hash and a one-line summary.\"',\n\t\t\"\",\n\t\t\"The subagent's report is not shown to the user. Interpret it and relay the important findings, changes, verification, and unresolved risks in your own reply.\",\n\t].join(\"\\n\");\n}\n"]}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { AgentDefinition } from "./types.ts";
|
|
2
|
+
/** Convert a lowercase profile identifier into its display-only title. */
|
|
3
|
+
export declare function displayAgentName(name: string): string;
|
|
4
|
+
/** Keep model-facing usage guidance separate from concise built-in UI copy. */
|
|
5
|
+
export declare function displayAgentDescription(agent: AgentDefinition): string;
|
|
6
|
+
//# sourceMappingURL=display-name.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"display-name.d.ts","sourceRoot":"","sources":["../../../src/extensions/subagent/display-name.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAElD,0EAA0E;AAC1E,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAMrD;AAED,+EAA+E;AAC/E,wBAAgB,uBAAuB,CAAC,KAAK,EAAE,eAAe,GAAG,MAAM,CAEtE"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/** Convert a lowercase profile identifier into its display-only title. */
|
|
2
|
+
export function displayAgentName(name) {
|
|
3
|
+
return name
|
|
4
|
+
.split(/[-_]/u)
|
|
5
|
+
.filter(Boolean)
|
|
6
|
+
.map((word) => `${word[0]?.toUpperCase() ?? ""}${word.slice(1)}`)
|
|
7
|
+
.join(" ");
|
|
8
|
+
}
|
|
9
|
+
/** Keep model-facing usage guidance separate from concise built-in UI copy. */
|
|
10
|
+
export function displayAgentDescription(agent) {
|
|
11
|
+
return agent.uiDescription ?? agent.description;
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=display-name.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"display-name.js","sourceRoot":"","sources":["../../../src/extensions/subagent/display-name.ts"],"names":[],"mappings":"AAEA,0EAA0E;AAC1E,MAAM,UAAU,gBAAgB,CAAC,IAAY;IAC5C,OAAO,IAAI;SACT,KAAK,CAAC,OAAO,CAAC;SACd,MAAM,CAAC,OAAO,CAAC;SACf,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC,EAAE,WAAW,EAAE,IAAI,EAAE,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC;SAChE,IAAI,CAAC,GAAG,CAAC,CAAC;AACb,CAAC;AAED,+EAA+E;AAC/E,MAAM,UAAU,uBAAuB,CAAC,KAAsB;IAC7D,OAAO,KAAK,CAAC,aAAa,IAAI,KAAK,CAAC,WAAW,CAAC;AACjD,CAAC","sourcesContent":["import type { AgentDefinition } from \"./types.ts\";\n\n/** Convert a lowercase profile identifier into its display-only title. */\nexport function displayAgentName(name: string): string {\n\treturn name\n\t\t.split(/[-_]/u)\n\t\t.filter(Boolean)\n\t\t.map((word) => `${word[0]?.toUpperCase() ?? \"\"}${word.slice(1)}`)\n\t\t.join(\" \");\n}\n\n/** Keep model-facing usage guidance separate from concise built-in UI copy. */\nexport function displayAgentDescription(agent: AgentDefinition): string {\n\treturn agent.uiDescription ?? agent.description;\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/extensions/subagent/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/extensions/subagent/index.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAEX,YAAY,EAGZ,MAAM,gCAAgC,CAAC;AACxC,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC;AAClE,OAAO,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAmH3D,wBAAsB,mBAAmB,CACxC,OAAO,EAAE,YAAY,EACrB,QAAQ,EAAE,aAAa,EACvB,SAAS,EAAE,GAAG,CAAC,MAAM,CAAC,EACtB,aAAa,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,GAChC,OAAO,CAAC,IAAI,CAAC,CAWf;AAED,MAAM,CAAC,OAAO,UAAU,QAAQ,CAAC,EAAE,EAAE,YAAY,GAAG,IAAI,CAqHvD"}
|
|
@@ -1,18 +1,13 @@
|
|
|
1
1
|
import { join } from "node:path";
|
|
2
|
-
import { getSupportedThinkingLevels } from "@earendil-works/pi-ai/compat";
|
|
3
2
|
import { getAgentDir } from "../../config.js";
|
|
4
3
|
import { ModelRuntime } from "../../core/model-runtime.js";
|
|
5
4
|
import { emptyUsage } from "./activity.js";
|
|
6
5
|
import { discoverAgents, subagentToolDescription } from "./agents.js";
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
6
|
+
import { showAgentsCommand } from "./agents-command.js";
|
|
7
|
+
import { SUBAGENT_COMMAND_NAME, SUBAGENT_TOOL_LABEL, SUBAGENT_TOOL_NAME } from "./constants.js";
|
|
9
8
|
import { renderSubagentCall, renderSubagentResult } from "./render.js";
|
|
10
9
|
import { ConcurrencyGate, isSubagentError, runSubagentInvocation, statusSummary } from "./runner.js";
|
|
11
10
|
import { SubagentParamsSchema } from "./schema.js";
|
|
12
|
-
import { loadSubagentConfig, resetProfileOverrides, updateProfileOverride } from "./settings.js";
|
|
13
|
-
function formatParentModel(model) {
|
|
14
|
-
return model ? `${model.provider}/${model.id}` : "none";
|
|
15
|
-
}
|
|
16
11
|
// Re-render live elapsed time and activity tails once per second while the
|
|
17
12
|
// result is still partial; the first settled render clears the timer.
|
|
18
13
|
function scheduleLiveRefresh(context, isPartial) {
|
|
@@ -32,84 +27,6 @@ function scheduleLiveRefresh(context, isPartial) {
|
|
|
32
27
|
state.refreshTimer = undefined;
|
|
33
28
|
}
|
|
34
29
|
}
|
|
35
|
-
// Settings resolve in two layers: a saved override wins, otherwise the
|
|
36
|
-
// profile inherits the parent session. Inherited rows show the value
|
|
37
|
-
// currently in effect so the menu doubles as a status view.
|
|
38
|
-
function effectiveSettings(override, ctx, parentThinking) {
|
|
39
|
-
return {
|
|
40
|
-
model: override?.model ?? `inherit (${formatParentModel(ctx.model)})`,
|
|
41
|
-
thinking: override?.thinking ?? `inherit (${parentThinking})`,
|
|
42
|
-
};
|
|
43
|
-
}
|
|
44
|
-
// The thinking picker lists what the effective model actually supports;
|
|
45
|
-
// if the saved override names a model that is unavailable right now,
|
|
46
|
-
// every level shows and the runtime clamp decides.
|
|
47
|
-
function effectiveModelFor(ctx, override) {
|
|
48
|
-
if (override?.model) {
|
|
49
|
-
const separator = override.model.indexOf("/");
|
|
50
|
-
if (separator <= 0)
|
|
51
|
-
return undefined;
|
|
52
|
-
return ctx.modelRegistry.find(override.model.slice(0, separator), override.model.slice(separator + 1));
|
|
53
|
-
}
|
|
54
|
-
return ctx.model;
|
|
55
|
-
}
|
|
56
|
-
async function pickModel(ctx, profileName, override) {
|
|
57
|
-
const items = [
|
|
58
|
-
{
|
|
59
|
-
value: null,
|
|
60
|
-
label: "inherit",
|
|
61
|
-
detail: `Follow the parent session (${formatParentModel(ctx.model)})`,
|
|
62
|
-
current: !override?.model,
|
|
63
|
-
},
|
|
64
|
-
...ctx.modelRegistry.getAvailable().map((model) => ({
|
|
65
|
-
value: `${model.provider}/${model.id}`,
|
|
66
|
-
label: `${model.provider}/${model.id}`,
|
|
67
|
-
detail: model.name && model.name !== model.id ? model.name : undefined,
|
|
68
|
-
current: override?.model === `${model.provider}/${model.id}`,
|
|
69
|
-
})),
|
|
70
|
-
];
|
|
71
|
-
const selected = await ctx.ui.custom((_tui, theme, _keybindings, done) => new SearchPickerComponent(theme, `Model for ${profileName}`, items, done));
|
|
72
|
-
if (selected === undefined)
|
|
73
|
-
return;
|
|
74
|
-
await updateProfileOverride(profileName, { model: selected ?? undefined }, getAgentDir());
|
|
75
|
-
}
|
|
76
|
-
async function pickThinking(ctx, profileName, override, parentThinking) {
|
|
77
|
-
const model = effectiveModelFor(ctx, override);
|
|
78
|
-
const levels = model ? getSupportedThinkingLevels(model) : [...THINKING_LEVELS];
|
|
79
|
-
const items = [
|
|
80
|
-
{
|
|
81
|
-
value: null,
|
|
82
|
-
label: "inherit",
|
|
83
|
-
detail: `Follow the parent session (${parentThinking})`,
|
|
84
|
-
current: !override?.thinking,
|
|
85
|
-
},
|
|
86
|
-
...levels.map((level) => ({ value: level, label: level, current: override?.thinking === level })),
|
|
87
|
-
];
|
|
88
|
-
const selected = await ctx.ui.custom((_tui, theme, _keybindings, done) => new SearchPickerComponent(theme, `Thinking for ${profileName}`, items, done));
|
|
89
|
-
if (selected === undefined)
|
|
90
|
-
return;
|
|
91
|
-
await updateProfileOverride(profileName, { thinking: selected ?? undefined }, getAgentDir());
|
|
92
|
-
}
|
|
93
|
-
async function configureProfile(ctx, agent, parentThinking) {
|
|
94
|
-
const agentDir = getAgentDir();
|
|
95
|
-
while (true) {
|
|
96
|
-
const config = await loadSubagentConfig(agentDir);
|
|
97
|
-
const override = config.profiles[agent.name];
|
|
98
|
-
const effective = effectiveSettings(override, ctx, parentThinking);
|
|
99
|
-
const action = await ctx.ui.select(`${agent.name} — ${agent.description}`, [
|
|
100
|
-
`Model: ${effective.model}`,
|
|
101
|
-
`Thinking: ${effective.thinking}`,
|
|
102
|
-
"Back",
|
|
103
|
-
]);
|
|
104
|
-
if (!action || action === "Back")
|
|
105
|
-
return;
|
|
106
|
-
if (action.startsWith("Model:")) {
|
|
107
|
-
await pickModel(ctx, agent.name, override);
|
|
108
|
-
continue;
|
|
109
|
-
}
|
|
110
|
-
await pickThinking(ctx, agent.name, override, parentThinking);
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
30
|
// Parent tool calls execute in parallel by default, so every sync targeting
|
|
114
31
|
// the same child runtime must observe and update the tracking state in order.
|
|
115
32
|
const providerSyncQueues = new WeakMap();
|
|
@@ -203,48 +120,6 @@ export async function syncParentProviders(runtime, registry, syncedIds, syncedAp
|
|
|
203
120
|
providerSyncQueues.delete(runtime);
|
|
204
121
|
}
|
|
205
122
|
}
|
|
206
|
-
async function showAgentsCommand(ctx, parentThinking) {
|
|
207
|
-
if (!ctx.hasUI) {
|
|
208
|
-
ctx.ui.notify("/agents requires an interactive UI.", "warning");
|
|
209
|
-
return;
|
|
210
|
-
}
|
|
211
|
-
const agentDir = getAgentDir();
|
|
212
|
-
const reset = "Reset all overrides";
|
|
213
|
-
const done = "Done";
|
|
214
|
-
while (true) {
|
|
215
|
-
const discovery = discoverAgents(ctx.cwd, { projectTrusted: ctx.isProjectTrusted(), agentDir });
|
|
216
|
-
const config = await loadSubagentConfig(agentDir);
|
|
217
|
-
const rows = discovery.agents.map((agent) => {
|
|
218
|
-
const effective = effectiveSettings(config.profiles[agent.name], ctx, parentThinking);
|
|
219
|
-
return `${agent.name} — model: ${effective.model} · thinking: ${effective.thinking}`;
|
|
220
|
-
});
|
|
221
|
-
const issueCount = discovery.diagnostics.length;
|
|
222
|
-
const issues = issueCount ? [`Show ${issueCount} agent file issue${issueCount === 1 ? "" : "s"}`] : [];
|
|
223
|
-
const action = await ctx.ui.select("Subagent profiles — select one to configure", [
|
|
224
|
-
...rows,
|
|
225
|
-
...issues,
|
|
226
|
-
reset,
|
|
227
|
-
done,
|
|
228
|
-
]);
|
|
229
|
-
if (!action || action === done)
|
|
230
|
-
return;
|
|
231
|
-
if (action === reset) {
|
|
232
|
-
const confirmed = await ctx.ui.confirm("Reset profile overrides?", "Clear every saved Subagent model and thinking override?");
|
|
233
|
-
if (confirmed) {
|
|
234
|
-
await resetProfileOverrides(agentDir);
|
|
235
|
-
ctx.ui.notify("All profiles now inherit the parent session.", "info");
|
|
236
|
-
}
|
|
237
|
-
continue;
|
|
238
|
-
}
|
|
239
|
-
if (issues.length > 0 && action === issues[0]) {
|
|
240
|
-
ctx.ui.notify(discovery.diagnostics.map((diagnostic) => `${diagnostic.path}: ${diagnostic.message}`).join("\n"), "warning");
|
|
241
|
-
continue;
|
|
242
|
-
}
|
|
243
|
-
const agent = discovery.agents.find((candidate) => action.startsWith(`${candidate.name} — `));
|
|
244
|
-
if (agent)
|
|
245
|
-
await configureProfile(ctx, agent, parentThinking);
|
|
246
|
-
}
|
|
247
|
-
}
|
|
248
123
|
export default function subagent(pi) {
|
|
249
124
|
const gate = new ConcurrencyGate();
|
|
250
125
|
const activeAborters = new Set();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/extensions/subagent/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAGjC,OAAO,EAAE,0BAA0B,EAAE,MAAM,8BAA8B,CAAC;AAC1E,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAS9C,OAAO,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAC3D,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAC3C,OAAO,EAAE,cAAc,EAAE,uBAAuB,EAAE,MAAM,aAAa,CAAC;AACtE,OAAO,EAAE,qBAAqB,EAAE,mBAAmB,EAAE,kBAAkB,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AACjH,OAAO,EAAmB,qBAAqB,EAAE,MAAM,aAAa,CAAC;AACrE,OAAO,EAAE,kBAAkB,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AAEvE,OAAO,EAAE,eAAe,EAAE,eAAe,EAAE,qBAAqB,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AACrG,OAAO,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AACnD,OAAO,EAAE,kBAAkB,EAAE,qBAAqB,EAAE,qBAAqB,EAAE,MAAM,eAAe,CAAC;AAGjG,SAAS,iBAAiB,CAAC,KAAmD;IAC7E,OAAO,KAAK,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC,QAAQ,IAAI,KAAK,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC;AACzD,CAAC;AAMD,2EAA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AC,GAAG,EAAE,EAAE,cAAc,EAAE,GAAG,CAAC,gBAAgB,EAAE,EAAE,QAAQ,EAAE,WAAW,EAAE,EAAE,CAAC,CAC5F,CAAC;IACH,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,eAAe,CAAC,qBAAqB,EAAE;QACzC,WAAW,EAAE,0DAA0D;QACvE,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,GAAG,EAAE,EAAE,CAAC,iBAAiB,CAAC,GAAG,EAAE,EAAE,CAAC,gBAAgB,EAAE,CAAC;KAC5E,CAAC,CAAC;IAEH,EAAE,CAAC,EAAE,CAAC,aAAa,EAAE,KAAK,EAAE,KAAK,EAAE,EAAE;QACpC,IAAI,KAAK,CAAC,QAAQ,KAAK,kBAAkB;YAAE,OAAO;QAClD,MAAM,OAAO,GAAG,KAAK,CAAC,OAAsC,CAAC;QAC7D,IAAI,OAAO,IAAI,eAAe,CAAC,OAAO,CAAC;YAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;IACnE,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,EAAE,CAAC,kBAAkB,EAAE,KAAK,IAAI,EAAE;QACpC,MAAM,OAAO,CAAC,UAAU,CAAC,CAAC,GAAG,cAAc,CAAC,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC;QACtE,cAAc,CAAC,KAAK,EAAE,CAAC;IACxB,CAAC,CAAC,CAAC;AACJ,CAAC","sourcesContent":["import { join } from \"node:path\";\nimport type { ThinkingLevel } from \"@earendil-works/pi-agent-core\";\nimport type { Api, Model } from \"@earendil-works/pi-ai\";\nimport { getSupportedThinkingLevels } from \"@earendil-works/pi-ai/compat\";\nimport { getAgentDir } from \"../../config.ts\";\nimport type {\n\tAgentToolResult,\n\tExtensionAPI,\n\tExtensionCommandContext,\n\tExtensionContext,\n\tToolRenderContext,\n} from \"../../core/extensions/types.ts\";\nimport type { ModelRegistry } from \"../../core/model-registry.ts\";\nimport { ModelRuntime } from \"../../core/model-runtime.ts\";\nimport { emptyUsage } from \"./activity.ts\";\nimport { discoverAgents, subagentToolDescription } from \"./agents.ts\";\nimport { SUBAGENT_COMMAND_NAME, SUBAGENT_TOOL_LABEL, SUBAGENT_TOOL_NAME, THINKING_LEVELS } from \"./constants.ts\";\nimport { type PickerItem, SearchPickerComponent } from \"./picker.ts\";\nimport { renderSubagentCall, renderSubagentResult } from \"./render.ts\";\nimport type { ParentModelContext } from \"./resolve.ts\";\nimport { ConcurrencyGate, isSubagentError, runSubagentInvocation, statusSummary } from \"./runner.ts\";\nimport { SubagentParamsSchema } from \"./schema.ts\";\nimport { loadSubagentConfig, resetProfileOverrides, updateProfileOverride } from \"./settings.ts\";\nimport type { AgentDefinition, AgentDiscoveryResult, SubagentDetails, SubagentProfileOverride } from \"./types.ts\";\n\nfunction formatParentModel(model: { provider: string; id: string } | undefined): string {\n\treturn model ? `${model.provider}/${model.id}` : \"none\";\n}\n\ninterface SubagentRenderState {\n\trefreshTimer?: ReturnType<typeof setTimeout>;\n}\n\n// Re-render live elapsed time and activity tails once per second while the\n// result is still partial; the first settled render clears the timer.\nfunction scheduleLiveRefresh(context: ToolRenderContext<SubagentRenderState>, isPartial: boolean): void {\n\tconst state = context.state;\n\tif (isPartial) {\n\t\tif (state.refreshTimer === undefined) {\n\t\t\tstate.refreshTimer = setTimeout(() => {\n\t\t\t\tstate.refreshTimer = undefined;\n\t\t\t\tcontext.invalidate();\n\t\t\t}, 1000);\n\t\t\tstate.refreshTimer.unref?.();\n\t\t}\n\t\treturn;\n\t}\n\tif (state.refreshTimer !== undefined) {\n\t\tclearTimeout(state.refreshTimer);\n\t\tstate.refreshTimer = undefined;\n\t}\n}\n\n// Settings resolve in two layers: a saved override wins, otherwise the\n// profile inherits the parent session. Inherited rows show the value\n// currently in effect so the menu doubles as a status view.\nfunction effectiveSettings(\n\toverride: SubagentProfileOverride | undefined,\n\tctx: ExtensionCommandContext,\n\tparentThinking: string,\n): { model: string; thinking: string } {\n\treturn {\n\t\tmodel: override?.model ?? `inherit (${formatParentModel(ctx.model)})`,\n\t\tthinking: override?.thinking ?? `inherit (${parentThinking})`,\n\t};\n}\n\n// The thinking picker lists what the effective model actually supports;\n// if the saved override names a model that is unavailable right now,\n// every level shows and the runtime clamp decides.\nfunction effectiveModelFor(\n\tctx: ExtensionCommandContext,\n\toverride: SubagentProfileOverride | undefined,\n): Model<Api> | undefined {\n\tif (override?.model) {\n\t\tconst separator = override.model.indexOf(\"/\");\n\t\tif (separator <= 0) return undefined;\n\t\treturn ctx.modelRegistry.find(override.model.slice(0, separator), override.model.slice(separator + 1));\n\t}\n\treturn ctx.model;\n}\n\nasync function pickModel(\n\tctx: ExtensionCommandContext,\n\tprofileName: string,\n\toverride: SubagentProfileOverride | undefined,\n): Promise<void> {\n\tconst items: PickerItem<string | null>[] = [\n\t\t{\n\t\t\tvalue: null,\n\t\t\tlabel: \"inherit\",\n\t\t\tdetail: `Follow the parent session (${formatParentModel(ctx.model)})`,\n\t\t\tcurrent: !override?.model,\n\t\t},\n\t\t...ctx.modelRegistry.getAvailable().map((model) => ({\n\t\t\tvalue: `${model.provider}/${model.id}`,\n\t\t\tlabel: `${model.provider}/${model.id}`,\n\t\t\tdetail: model.name && model.name !== model.id ? model.name : undefined,\n\t\t\tcurrent: override?.model === `${model.provider}/${model.id}`,\n\t\t})),\n\t];\n\tconst selected = await ctx.ui.custom<string | null | undefined>(\n\t\t(_tui, theme, _keybindings, done) => new SearchPickerComponent(theme, `Model for ${profileName}`, items, done),\n\t);\n\tif (selected === undefined) return;\n\tawait updateProfileOverride(profileName, { model: selected ?? undefined }, getAgentDir());\n}\n\nasync function pickThinking(\n\tctx: ExtensionCommandContext,\n\tprofileName: string,\n\toverride: SubagentProfileOverride | undefined,\n\tparentThinking: string,\n): Promise<void> {\n\tconst model = effectiveModelFor(ctx, override);\n\tconst levels = model ? (getSupportedThinkingLevels(model) as ThinkingLevel[]) : [...THINKING_LEVELS];\n\tconst items: PickerItem<ThinkingLevel | null>[] = [\n\t\t{\n\t\t\tvalue: null,\n\t\t\tlabel: \"inherit\",\n\t\t\tdetail: `Follow the parent session (${parentThinking})`,\n\t\t\tcurrent: !override?.thinking,\n\t\t},\n\t\t...levels.map((level) => ({ value: level, label: level, current: override?.thinking === level })),\n\t];\n\tconst selected = await ctx.ui.custom<ThinkingLevel | null | undefined>(\n\t\t(_tui, theme, _keybindings, done) => new SearchPickerComponent(theme, `Thinking for ${profileName}`, items, done),\n\t);\n\tif (selected === undefined) return;\n\tawait updateProfileOverride(profileName, { thinking: selected ?? undefined }, getAgentDir());\n}\n\nasync function configureProfile(\n\tctx: ExtensionCommandContext,\n\tagent: AgentDefinition,\n\tparentThinking: string,\n): Promise<void> {\n\tconst agentDir = getAgentDir();\n\twhile (true) {\n\t\tconst config = await loadSubagentConfig(agentDir);\n\t\tconst override = config.profiles[agent.name];\n\t\tconst effective = effectiveSettings(override, ctx, parentThinking);\n\t\tconst action = await ctx.ui.select(`${agent.name} — ${agent.description}`, [\n\t\t\t`Model: ${effective.model}`,\n\t\t\t`Thinking: ${effective.thinking}`,\n\t\t\t\"Back\",\n\t\t]);\n\t\tif (!action || action === \"Back\") return;\n\t\tif (action.startsWith(\"Model:\")) {\n\t\t\tawait pickModel(ctx, agent.name, override);\n\t\t\tcontinue;\n\t\t}\n\t\tawait pickThinking(ctx, agent.name, override, parentThinking);\n\t}\n}\n\n// Parent tool calls execute in parallel by default, so every sync targeting\n// the same child runtime must observe and update the tracking state in order.\nconst providerSyncQueues = new WeakMap<ModelRuntime, Promise<void>>();\n\n// Provider configs are mostly JSON data, but stream, refresh, and OAuth hooks\n// are functions whose identity is behaviorally significant. Compare enumerable\n// values recursively so callback-only re-registrations propagate as well.\nfunction providerConfigValuesEqual(\n\tleft: unknown,\n\tright: unknown,\n\tseen = new WeakMap<object, WeakSet<object>>(),\n): boolean {\n\tif (Object.is(left, right)) return true;\n\tif (typeof left !== \"object\" || left === null || typeof right !== \"object\" || right === null) return false;\n\tif (Array.isArray(left) !== Array.isArray(right)) return false;\n\tif (Array.isArray(left) && left.length !== (right as unknown[]).length) return false;\n\n\tconst comparedRights = seen.get(left);\n\tif (comparedRights?.has(right)) return true;\n\tif (comparedRights) comparedRights.add(right);\n\telse seen.set(left, new WeakSet([right]));\n\n\tconst leftRecord = left as Record<string, unknown>;\n\tconst rightRecord = right as Record<string, unknown>;\n\tconst leftKeys = Object.keys(leftRecord).sort();\n\tconst rightKeys = Object.keys(rightRecord).sort();\n\tif (leftKeys.length !== rightKeys.length) return false;\n\tfor (let index = 0; index < leftKeys.length; index++) {\n\t\tconst key = leftKeys[index];\n\t\tif (key === undefined || key !== rightKeys[index]) return false;\n\t\tif (!providerConfigValuesEqual(leftRecord[key], rightRecord[key], seen)) return false;\n\t}\n\treturn true;\n}\n\nasync function syncParentProvidersNow(\n\truntime: ModelRuntime,\n\tregistry: ModelRegistry,\n\tsyncedIds: Set<string>,\n\tsyncedApiKeys: Map<string, string>,\n): Promise<void> {\n\tconst nextIds = new Set(registry.getRegisteredProviderIds());\n\tfor (const id of [...syncedIds]) {\n\t\tif (!nextIds.has(id)) {\n\t\t\truntime.unregisterProvider(id);\n\t\t\tif (syncedApiKeys.has(id)) {\n\t\t\t\tawait runtime.removeRuntimeApiKey(id);\n\t\t\t\tsyncedApiKeys.delete(id);\n\t\t\t}\n\t\t\tsyncedIds.delete(id);\n\t\t}\n\t}\n\tfor (const id of nextIds) {\n\t\tconst native = registry.getRegisteredNativeProvider(id);\n\t\tif (native) {\n\t\t\tif (runtime.getRegisteredNativeProvider(id) !== native) runtime.registerNativeProvider(native);\n\t\t} else {\n\t\t\tconst config = registry.getRegisteredProviderConfig(id);\n\t\t\tif (config && !providerConfigValuesEqual(runtime.getRegisteredProviderConfig(id), config)) {\n\t\t\t\truntime.registerProvider(id, config);\n\t\t\t}\n\t\t}\n\t\t// Record the provider as soon as its registration is known to be in the\n\t\t// child runtime. If auth lookup then fails, a later removal can still\n\t\t// clean up this partially synchronized provider.\n\t\tsyncedIds.add(id);\n\t\tconst auth = await registry.getProviderAuth(id);\n\t\tconst apiKey = auth?.auth.apiKey;\n\t\tif (apiKey && syncedApiKeys.get(id) !== apiKey) {\n\t\t\t// pi-ai 0.84 AuthOperationOptions carries only signal; the runtime's\n\t\t\t// credential sync hardcodes allowNetwork: false.\n\t\t\tawait runtime.setRuntimeApiKey(id, apiKey);\n\t\t\tsyncedApiKeys.set(id, apiKey);\n\t\t} else if (!apiKey && syncedApiKeys.has(id)) {\n\t\t\tawait runtime.removeRuntimeApiKey(id);\n\t\t\tsyncedApiKeys.delete(id);\n\t\t}\n\t}\n}\n\nexport async function syncParentProviders(\n\truntime: ModelRuntime,\n\tregistry: ModelRegistry,\n\tsyncedIds: Set<string>,\n\tsyncedApiKeys: Map<string, string>,\n): Promise<void> {\n\tconst previous = providerSyncQueues.get(runtime) ?? Promise.resolve();\n\tconst current = previous\n\t\t.catch(() => undefined)\n\t\t.then(() => syncParentProvidersNow(runtime, registry, syncedIds, syncedApiKeys));\n\tproviderSyncQueues.set(runtime, current);\n\ttry {\n\t\tawait current;\n\t} finally {\n\t\tif (providerSyncQueues.get(runtime) === current) providerSyncQueues.delete(runtime);\n\t}\n}\n\nasync function showAgentsCommand(ctx: ExtensionCommandContext, parentThinking: string): Promise<void> {\n\tif (!ctx.hasUI) {\n\t\tctx.ui.notify(\"/agents requires an interactive UI.\", \"warning\");\n\t\treturn;\n\t}\n\tconst agentDir = getAgentDir();\n\tconst reset = \"Reset all overrides\";\n\tconst done = \"Done\";\n\twhile (true) {\n\t\tconst discovery = discoverAgents(ctx.cwd, { projectTrusted: ctx.isProjectTrusted(), agentDir });\n\t\tconst config = await loadSubagentConfig(agentDir);\n\t\tconst rows = discovery.agents.map((agent) => {\n\t\t\tconst effective = effectiveSettings(config.profiles[agent.name], ctx, parentThinking);\n\t\t\treturn `${agent.name} — model: ${effective.model} · thinking: ${effective.thinking}`;\n\t\t});\n\t\tconst issueCount = discovery.diagnostics.length;\n\t\tconst issues = issueCount ? [`Show ${issueCount} agent file issue${issueCount === 1 ? \"\" : \"s\"}`] : [];\n\t\tconst action = await ctx.ui.select(\"Subagent profiles — select one to configure\", [\n\t\t\t...rows,\n\t\t\t...issues,\n\t\t\treset,\n\t\t\tdone,\n\t\t]);\n\t\tif (!action || action === done) return;\n\t\tif (action === reset) {\n\t\t\tconst confirmed = await ctx.ui.confirm(\n\t\t\t\t\"Reset profile overrides?\",\n\t\t\t\t\"Clear every saved Subagent model and thinking override?\",\n\t\t\t);\n\t\t\tif (confirmed) {\n\t\t\t\tawait resetProfileOverrides(agentDir);\n\t\t\t\tctx.ui.notify(\"All profiles now inherit the parent session.\", \"info\");\n\t\t\t}\n\t\t\tcontinue;\n\t\t}\n\t\tif (issues.length > 0 && action === issues[0]) {\n\t\t\tctx.ui.notify(\n\t\t\t\tdiscovery.diagnostics.map((diagnostic) => `${diagnostic.path}: ${diagnostic.message}`).join(\"\\n\"),\n\t\t\t\t\"warning\",\n\t\t\t);\n\t\t\tcontinue;\n\t\t}\n\t\tconst agent = discovery.agents.find((candidate) => action.startsWith(`${candidate.name} — `));\n\t\tif (agent) await configureProfile(ctx, agent, parentThinking);\n\t}\n}\n\nexport default function subagent(pi: ExtensionAPI): void {\n\tconst gate = new ConcurrencyGate();\n\tconst activeAborters = new Set<() => Promise<void>>();\n\tconst syncedProviderIds = new Set<string>();\n\tconst syncedProviderApiKeys = new Map<string, string>();\n\tlet modelRuntimePromise: Promise<ModelRuntime> | undefined;\n\n\tconst getModelRuntime = async (ctx: ExtensionContext): Promise<ModelRuntime> => {\n\t\tif (!modelRuntimePromise) {\n\t\t\tconst agentDir = getAgentDir();\n\t\t\tconst created = ModelRuntime.create({\n\t\t\t\tauthPath: join(agentDir, \"auth.json\"),\n\t\t\t\tmodelsPath: join(agentDir, \"models.json\"),\n\t\t\t});\n\t\t\t// A transient failure (network, filesystem) must not brick the tool\n\t\t\t// for the rest of the session: drop the rejected promise so the\n\t\t\t// next invocation retries creation.\n\t\t\tcreated.catch(() => {\n\t\t\t\tif (modelRuntimePromise === created) modelRuntimePromise = undefined;\n\t\t\t});\n\t\t\tmodelRuntimePromise = created;\n\t\t}\n\t\tconst runtime = await modelRuntimePromise;\n\t\tawait syncParentProviders(runtime, ctx.modelRegistry, syncedProviderIds, syncedProviderApiKeys);\n\t\treturn runtime;\n\t};\n\n\tconst registerSubagentTool = (discovery: AgentDiscoveryResult): void => {\n\t\tpi.registerTool<typeof SubagentParamsSchema, SubagentDetails, SubagentRenderState>({\n\t\t\tname: SUBAGENT_TOOL_NAME,\n\t\t\tlabel: SUBAGENT_TOOL_LABEL,\n\t\t\tdescription: subagentToolDescription(discovery),\n\t\t\tpromptSnippet: \"Delegate focused research, review, or implementation tasks to isolated subagents\",\n\t\t\tpromptGuidelines: [\n\t\t\t\t\"Use subagent when a bounded task benefits from isolated context or parallel investigation; choose a profile and write its briefing using the tool description.\",\n\t\t\t],\n\t\t\tparameters: SubagentParamsSchema,\n\t\t\tasync execute(_toolCallId, params, signal, onUpdate, ctx): Promise<AgentToolResult<SubagentDetails>> {\n\t\t\t\t// First paint before any await: model-runtime creation and task\n\t\t\t\t// resolution can stall on first use (network, filesystem), and\n\t\t\t\t// the transcript card must not sit empty while they do.\n\t\t\t\tonUpdate?.({\n\t\t\t\t\tcontent: [{ type: \"text\", text: \"Initializing…\" }],\n\t\t\t\t\tdetails: {\n\t\t\t\t\t\tmode: params.tasks ? \"parallel\" : \"single\",\n\t\t\t\t\t\tstatus: \"running\",\n\t\t\t\t\t\truns: [],\n\t\t\t\t\t\tstartedAt: Date.now(),\n\t\t\t\t\t\tusage: emptyUsage(),\n\t\t\t\t\t},\n\t\t\t\t});\n\t\t\t\tconst discovery = discoverAgents(ctx.cwd, {\n\t\t\t\t\tprojectTrusted: ctx.isProjectTrusted(),\n\t\t\t\t\tagentDir: getAgentDir(),\n\t\t\t\t});\n\t\t\t\tconst runtime = await getModelRuntime(ctx);\n\t\t\t\tconst parent: ParentModelContext = {\n\t\t\t\t\tmodel: ctx.model,\n\t\t\t\t\tthinking: pi.getThinkingLevel(),\n\t\t\t\t\tmodelRegistry: ctx.modelRegistry,\n\t\t\t\t};\n\t\t\t\tconst execution = await runSubagentInvocation({\n\t\t\t\t\tparams,\n\t\t\t\t\tparentCwd: ctx.cwd,\n\t\t\t\t\tagents: discovery.agents,\n\t\t\t\t\tparent,\n\t\t\t\t\tmodelRuntime: runtime,\n\t\t\t\t\tagentDir: getAgentDir(),\n\t\t\t\t\tprojectTrusted: ctx.isProjectTrusted(),\n\t\t\t\t\tsignal,\n\t\t\t\t\tgate,\n\t\t\t\t\tonUpdate: (details) => {\n\t\t\t\t\t\tonUpdate?.({ content: [{ type: \"text\", text: statusSummary(details) }], details });\n\t\t\t\t\t},\n\t\t\t\t\tregisterAbort: (abort) => {\n\t\t\t\t\t\tactiveAborters.add(abort);\n\t\t\t\t\t\treturn () => activeAborters.delete(abort);\n\t\t\t\t\t},\n\t\t\t\t});\n\t\t\t\treturn {\n\t\t\t\t\tcontent: [{ type: \"text\", text: execution.content }],\n\t\t\t\t\tdetails: execution.details,\n\t\t\t\t\tusage: execution.usage,\n\t\t\t\t};\n\t\t\t},\n\t\t\trenderCall(args, theme) {\n\t\t\t\treturn renderSubagentCall(args, theme);\n\t\t\t},\n\t\t\trenderResult(result, options, theme, context) {\n\t\t\t\tscheduleLiveRefresh(context, options.isPartial);\n\t\t\t\treturn renderSubagentResult(result, options, theme, context.isError);\n\t\t\t},\n\t\t});\n\t};\n\n\tregisterSubagentTool(discoverAgents(process.cwd(), { projectTrusted: false, agentDir: getAgentDir() }));\n\tpi.on(\"session_start\", (_event, ctx) => {\n\t\tregisterSubagentTool(\n\t\t\tdiscoverAgents(ctx.cwd, { projectTrusted: ctx.isProjectTrusted(), agentDir: getAgentDir() }),\n\t\t);\n\t});\n\n\tpi.registerCommand(SUBAGENT_COMMAND_NAME, {\n\t\tdescription: \"Configure Subagent profiles, models, and thinking levels\",\n\t\thandler: async (_args, ctx) => showAgentsCommand(ctx, pi.getThinkingLevel()),\n\t});\n\n\tpi.on(\"tool_result\", async (event) => {\n\t\tif (event.toolName !== SUBAGENT_TOOL_NAME) return;\n\t\tconst details = event.details as SubagentDetails | undefined;\n\t\tif (details && isSubagentError(details)) return { isError: true };\n\t});\n\n\tpi.on(\"session_shutdown\", async () => {\n\t\tawait Promise.allSettled([...activeAborters].map((abort) => abort()));\n\t\tactiveAborters.clear();\n\t});\n}\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/extensions/subagent/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAQ9C,OAAO,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAC3D,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAC3C,OAAO,EAAE,cAAc,EAAE,uBAAuB,EAAE,MAAM,aAAa,CAAC;AACtE,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,EAAE,qBAAqB,EAAE,mBAAmB,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AAChG,OAAO,EAAE,kBAAkB,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AAEvE,OAAO,EAAE,eAAe,EAAE,eAAe,EAAE,qBAAqB,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AACrG,OAAO,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AAOnD,2EAA2E;AAC3E,sEAAsE;AACtE,SAAS,mBAAmB,CAAC,OAA+C,EAAE,SAAkB;IAC/F,MAAM,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC;IAC5B,IAAI,SAAS,EAAE,CAAC;QACf,IAAI,KAAK,CAAC,YAAY,KAAK,SAAS,EAAE,CAAC;YACtC,KAAK,CAAC,YAAY,GA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C,gBAAgB,EAAE,CAAC;KAC5E,CAAC,CAAC;IAEH,EAAE,CAAC,EAAE,CAAC,aAAa,EAAE,KAAK,EAAE,KAAK,EAAE,EAAE;QACpC,IAAI,KAAK,CAAC,QAAQ,KAAK,kBAAkB;YAAE,OAAO;QAClD,MAAM,OAAO,GAAG,KAAK,CAAC,OAAsC,CAAC;QAC7D,IAAI,OAAO,IAAI,eAAe,CAAC,OAAO,CAAC;YAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;IACnE,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,EAAE,CAAC,kBAAkB,EAAE,KAAK,IAAI,EAAE;QACpC,MAAM,OAAO,CAAC,UAAU,CAAC,CAAC,GAAG,cAAc,CAAC,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC;QACtE,cAAc,CAAC,KAAK,EAAE,CAAC;IACxB,CAAC,CAAC,CAAC;AACJ,CAAC","sourcesContent":["import { join } from \"node:path\";\nimport { getAgentDir } from \"../../config.ts\";\nimport type {\n\tAgentToolResult,\n\tExtensionAPI,\n\tExtensionContext,\n\tToolRenderContext,\n} from \"../../core/extensions/types.ts\";\nimport type { ModelRegistry } from \"../../core/model-registry.ts\";\nimport { ModelRuntime } from \"../../core/model-runtime.ts\";\nimport { emptyUsage } from \"./activity.ts\";\nimport { discoverAgents, subagentToolDescription } from \"./agents.ts\";\nimport { showAgentsCommand } from \"./agents-command.ts\";\nimport { SUBAGENT_COMMAND_NAME, SUBAGENT_TOOL_LABEL, SUBAGENT_TOOL_NAME } from \"./constants.ts\";\nimport { renderSubagentCall, renderSubagentResult } from \"./render.ts\";\nimport type { ParentModelContext } from \"./resolve.ts\";\nimport { ConcurrencyGate, isSubagentError, runSubagentInvocation, statusSummary } from \"./runner.ts\";\nimport { SubagentParamsSchema } from \"./schema.ts\";\nimport type { AgentDiscoveryResult, SubagentDetails } from \"./types.ts\";\n\ninterface SubagentRenderState {\n\trefreshTimer?: ReturnType<typeof setTimeout>;\n}\n\n// Re-render live elapsed time and activity tails once per second while the\n// result is still partial; the first settled render clears the timer.\nfunction scheduleLiveRefresh(context: ToolRenderContext<SubagentRenderState>, isPartial: boolean): void {\n\tconst state = context.state;\n\tif (isPartial) {\n\t\tif (state.refreshTimer === undefined) {\n\t\t\tstate.refreshTimer = setTimeout(() => {\n\t\t\t\tstate.refreshTimer = undefined;\n\t\t\t\tcontext.invalidate();\n\t\t\t}, 1000);\n\t\t\tstate.refreshTimer.unref?.();\n\t\t}\n\t\treturn;\n\t}\n\tif (state.refreshTimer !== undefined) {\n\t\tclearTimeout(state.refreshTimer);\n\t\tstate.refreshTimer = undefined;\n\t}\n}\n\n// Parent tool calls execute in parallel by default, so every sync targeting\n// the same child runtime must observe and update the tracking state in order.\nconst providerSyncQueues = new WeakMap<ModelRuntime, Promise<void>>();\n\n// Provider configs are mostly JSON data, but stream, refresh, and OAuth hooks\n// are functions whose identity is behaviorally significant. Compare enumerable\n// values recursively so callback-only re-registrations propagate as well.\nfunction providerConfigValuesEqual(\n\tleft: unknown,\n\tright: unknown,\n\tseen = new WeakMap<object, WeakSet<object>>(),\n): boolean {\n\tif (Object.is(left, right)) return true;\n\tif (typeof left !== \"object\" || left === null || typeof right !== \"object\" || right === null) return false;\n\tif (Array.isArray(left) !== Array.isArray(right)) return false;\n\tif (Array.isArray(left) && left.length !== (right as unknown[]).length) return false;\n\n\tconst comparedRights = seen.get(left);\n\tif (comparedRights?.has(right)) return true;\n\tif (comparedRights) comparedRights.add(right);\n\telse seen.set(left, new WeakSet([right]));\n\n\tconst leftRecord = left as Record<string, unknown>;\n\tconst rightRecord = right as Record<string, unknown>;\n\tconst leftKeys = Object.keys(leftRecord).sort();\n\tconst rightKeys = Object.keys(rightRecord).sort();\n\tif (leftKeys.length !== rightKeys.length) return false;\n\tfor (let index = 0; index < leftKeys.length; index++) {\n\t\tconst key = leftKeys[index];\n\t\tif (key === undefined || key !== rightKeys[index]) return false;\n\t\tif (!providerConfigValuesEqual(leftRecord[key], rightRecord[key], seen)) return false;\n\t}\n\treturn true;\n}\n\nasync function syncParentProvidersNow(\n\truntime: ModelRuntime,\n\tregistry: ModelRegistry,\n\tsyncedIds: Set<string>,\n\tsyncedApiKeys: Map<string, string>,\n): Promise<void> {\n\tconst nextIds = new Set(registry.getRegisteredProviderIds());\n\tfor (const id of [...syncedIds]) {\n\t\tif (!nextIds.has(id)) {\n\t\t\truntime.unregisterProvider(id);\n\t\t\tif (syncedApiKeys.has(id)) {\n\t\t\t\tawait runtime.removeRuntimeApiKey(id);\n\t\t\t\tsyncedApiKeys.delete(id);\n\t\t\t}\n\t\t\tsyncedIds.delete(id);\n\t\t}\n\t}\n\tfor (const id of nextIds) {\n\t\tconst native = registry.getRegisteredNativeProvider(id);\n\t\tif (native) {\n\t\t\tif (runtime.getRegisteredNativeProvider(id) !== native) runtime.registerNativeProvider(native);\n\t\t} else {\n\t\t\tconst config = registry.getRegisteredProviderConfig(id);\n\t\t\tif (config && !providerConfigValuesEqual(runtime.getRegisteredProviderConfig(id), config)) {\n\t\t\t\truntime.registerProvider(id, config);\n\t\t\t}\n\t\t}\n\t\t// Record the provider as soon as its registration is known to be in the\n\t\t// child runtime. If auth lookup then fails, a later removal can still\n\t\t// clean up this partially synchronized provider.\n\t\tsyncedIds.add(id);\n\t\tconst auth = await registry.getProviderAuth(id);\n\t\tconst apiKey = auth?.auth.apiKey;\n\t\tif (apiKey && syncedApiKeys.get(id) !== apiKey) {\n\t\t\t// pi-ai 0.84 AuthOperationOptions carries only signal; the runtime's\n\t\t\t// credential sync hardcodes allowNetwork: false.\n\t\t\tawait runtime.setRuntimeApiKey(id, apiKey);\n\t\t\tsyncedApiKeys.set(id, apiKey);\n\t\t} else if (!apiKey && syncedApiKeys.has(id)) {\n\t\t\tawait runtime.removeRuntimeApiKey(id);\n\t\t\tsyncedApiKeys.delete(id);\n\t\t}\n\t}\n}\n\nexport async function syncParentProviders(\n\truntime: ModelRuntime,\n\tregistry: ModelRegistry,\n\tsyncedIds: Set<string>,\n\tsyncedApiKeys: Map<string, string>,\n): Promise<void> {\n\tconst previous = providerSyncQueues.get(runtime) ?? Promise.resolve();\n\tconst current = previous\n\t\t.catch(() => undefined)\n\t\t.then(() => syncParentProvidersNow(runtime, registry, syncedIds, syncedApiKeys));\n\tproviderSyncQueues.set(runtime, current);\n\ttry {\n\t\tawait current;\n\t} finally {\n\t\tif (providerSyncQueues.get(runtime) === current) providerSyncQueues.delete(runtime);\n\t}\n}\n\nexport default function subagent(pi: ExtensionAPI): void {\n\tconst gate = new ConcurrencyGate();\n\tconst activeAborters = new Set<() => Promise<void>>();\n\tconst syncedProviderIds = new Set<string>();\n\tconst syncedProviderApiKeys = new Map<string, string>();\n\tlet modelRuntimePromise: Promise<ModelRuntime> | undefined;\n\n\tconst getModelRuntime = async (ctx: ExtensionContext): Promise<ModelRuntime> => {\n\t\tif (!modelRuntimePromise) {\n\t\t\tconst agentDir = getAgentDir();\n\t\t\tconst created = ModelRuntime.create({\n\t\t\t\tauthPath: join(agentDir, \"auth.json\"),\n\t\t\t\tmodelsPath: join(agentDir, \"models.json\"),\n\t\t\t});\n\t\t\t// A transient failure (network, filesystem) must not brick the tool\n\t\t\t// for the rest of the session: drop the rejected promise so the\n\t\t\t// next invocation retries creation.\n\t\t\tcreated.catch(() => {\n\t\t\t\tif (modelRuntimePromise === created) modelRuntimePromise = undefined;\n\t\t\t});\n\t\t\tmodelRuntimePromise = created;\n\t\t}\n\t\tconst runtime = await modelRuntimePromise;\n\t\tawait syncParentProviders(runtime, ctx.modelRegistry, syncedProviderIds, syncedProviderApiKeys);\n\t\treturn runtime;\n\t};\n\n\tconst registerSubagentTool = (discovery: AgentDiscoveryResult): void => {\n\t\tpi.registerTool<typeof SubagentParamsSchema, SubagentDetails, SubagentRenderState>({\n\t\t\tname: SUBAGENT_TOOL_NAME,\n\t\t\tlabel: SUBAGENT_TOOL_LABEL,\n\t\t\tdescription: subagentToolDescription(discovery),\n\t\t\tpromptSnippet: \"Delegate focused research, review, or implementation tasks to isolated subagents\",\n\t\t\tpromptGuidelines: [\n\t\t\t\t\"Use subagent when a bounded task benefits from isolated context or parallel investigation; choose a profile and write its briefing using the tool description.\",\n\t\t\t],\n\t\t\tparameters: SubagentParamsSchema,\n\t\t\tasync execute(_toolCallId, params, signal, onUpdate, ctx): Promise<AgentToolResult<SubagentDetails>> {\n\t\t\t\t// First paint before any await: model-runtime creation and task\n\t\t\t\t// resolution can stall on first use (network, filesystem), and\n\t\t\t\t// the transcript card must not sit empty while they do.\n\t\t\t\tonUpdate?.({\n\t\t\t\t\tcontent: [{ type: \"text\", text: \"Initializing…\" }],\n\t\t\t\t\tdetails: {\n\t\t\t\t\t\tmode: params.tasks ? \"parallel\" : \"single\",\n\t\t\t\t\t\tstatus: \"running\",\n\t\t\t\t\t\truns: [],\n\t\t\t\t\t\tstartedAt: Date.now(),\n\t\t\t\t\t\tusage: emptyUsage(),\n\t\t\t\t\t},\n\t\t\t\t});\n\t\t\t\tconst discovery = discoverAgents(ctx.cwd, {\n\t\t\t\t\tprojectTrusted: ctx.isProjectTrusted(),\n\t\t\t\t\tagentDir: getAgentDir(),\n\t\t\t\t});\n\t\t\t\tconst runtime = await getModelRuntime(ctx);\n\t\t\t\tconst parent: ParentModelContext = {\n\t\t\t\t\tmodel: ctx.model,\n\t\t\t\t\tthinking: pi.getThinkingLevel(),\n\t\t\t\t\tmodelRegistry: ctx.modelRegistry,\n\t\t\t\t};\n\t\t\t\tconst execution = await runSubagentInvocation({\n\t\t\t\t\tparams,\n\t\t\t\t\tparentCwd: ctx.cwd,\n\t\t\t\t\tagents: discovery.agents,\n\t\t\t\t\tparent,\n\t\t\t\t\tmodelRuntime: runtime,\n\t\t\t\t\tagentDir: getAgentDir(),\n\t\t\t\t\tprojectTrusted: ctx.isProjectTrusted(),\n\t\t\t\t\tsignal,\n\t\t\t\t\tgate,\n\t\t\t\t\tonUpdate: (details) => {\n\t\t\t\t\t\tonUpdate?.({ content: [{ type: \"text\", text: statusSummary(details) }], details });\n\t\t\t\t\t},\n\t\t\t\t\tregisterAbort: (abort) => {\n\t\t\t\t\t\tactiveAborters.add(abort);\n\t\t\t\t\t\treturn () => activeAborters.delete(abort);\n\t\t\t\t\t},\n\t\t\t\t});\n\t\t\t\treturn {\n\t\t\t\t\tcontent: [{ type: \"text\", text: execution.content }],\n\t\t\t\t\tdetails: execution.details,\n\t\t\t\t\tusage: execution.usage,\n\t\t\t\t};\n\t\t\t},\n\t\t\trenderCall(args, theme) {\n\t\t\t\treturn renderSubagentCall(args, theme);\n\t\t\t},\n\t\t\trenderResult(result, options, theme, context) {\n\t\t\t\tscheduleLiveRefresh(context, options.isPartial);\n\t\t\t\treturn renderSubagentResult(result, options, theme, context.isError);\n\t\t\t},\n\t\t});\n\t};\n\n\tregisterSubagentTool(discoverAgents(process.cwd(), { projectTrusted: false, agentDir: getAgentDir() }));\n\tpi.on(\"session_start\", (_event, ctx) => {\n\t\tregisterSubagentTool(\n\t\t\tdiscoverAgents(ctx.cwd, { projectTrusted: ctx.isProjectTrusted(), agentDir: getAgentDir() }),\n\t\t);\n\t});\n\n\tpi.registerCommand(SUBAGENT_COMMAND_NAME, {\n\t\tdescription: \"Configure Subagent profiles, models, and thinking levels\",\n\t\thandler: async (_args, ctx) => showAgentsCommand(ctx, pi.getThinkingLevel()),\n\t});\n\n\tpi.on(\"tool_result\", async (event) => {\n\t\tif (event.toolName !== SUBAGENT_TOOL_NAME) return;\n\t\tconst details = event.details as SubagentDetails | undefined;\n\t\tif (details && isSubagentError(details)) return { isError: true };\n\t});\n\n\tpi.on(\"session_shutdown\", async () => {\n\t\tawait Promise.allSettled([...activeAborters].map((abort) => abort()));\n\t\tactiveAborters.clear();\n\t});\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"render.d.ts","sourceRoot":"","sources":["../../../src/extensions/subagent/render.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,SAAS,EAAqC,MAAM,wBAAwB,CAAC;AAC3F,OAAO,KAAK,EAAE,eAAe,EAAE,uBAAuB,EAAE,MAAM,gCAAgC,CAAC;AAE/F,OAAO,EAAoB,KAAK,KAAK,EAAE,MAAM,wCAAwC,CAAC;
|
|
1
|
+
{"version":3,"file":"render.d.ts","sourceRoot":"","sources":["../../../src/extensions/subagent/render.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,SAAS,EAAqC,MAAM,wBAAwB,CAAC;AAC3F,OAAO,KAAK,EAAE,eAAe,EAAE,uBAAuB,EAAE,MAAM,gCAAgC,CAAC;AAE/F,OAAO,EAAoB,KAAK,KAAK,EAAE,MAAM,wCAAwC,CAAC;AAItF,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAClD,OAAO,KAAK,EAAE,eAAe,EAAyC,MAAM,YAAY,CAAC;AAkkBzF,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,cAAc,EAAE,KAAK,EAAE,KAAK,GAAG,SAAS,CAqBhF;AAED,wBAAgB,oBAAoB,CACnC,MAAM,EAAE,eAAe,CAAC,eAAe,CAAC,EACxC,OAAO,EAAE,uBAAuB,EAChC,KAAK,EAAE,KAAK,EACZ,OAAO,EAAE,OAAO,GACd,SAAS,CAiEX"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { Container, Markdown, Spacer, Text } from "@earendil-works/pi-tui";
|
|
2
2
|
import { keyHint } from "../../modes/interactive/components/keybinding-hints.js";
|
|
3
3
|
import { getMarkdownTheme } from "../../modes/interactive/theme/theme.js";
|
|
4
|
+
import { displayAgentName } from "./display-name.js";
|
|
4
5
|
import { getSubagentRetryView } from "./retry.js";
|
|
5
6
|
import { statusSummary } from "./runner.js";
|
|
6
7
|
const SINGLE_EXCERPT_LIMIT = 200;
|
|
@@ -31,16 +32,6 @@ class IndentedText {
|
|
|
31
32
|
this.text.invalidate();
|
|
32
33
|
}
|
|
33
34
|
}
|
|
34
|
-
// Display-only: profile names stay lowercase everywhere the model sees
|
|
35
|
-
// them; the transcript shows "general" as "General", "code-reviewer" as
|
|
36
|
-
// "Code Reviewer".
|
|
37
|
-
function displayAgentName(name) {
|
|
38
|
-
return name
|
|
39
|
-
.split(/[-_]/u)
|
|
40
|
-
.filter(Boolean)
|
|
41
|
-
.map((word) => `${word[0]?.toUpperCase() ?? ""}${word.slice(1)}`)
|
|
42
|
-
.join(" ");
|
|
43
|
-
}
|
|
44
35
|
function singleAgentName(args) {
|
|
45
36
|
return displayAgentName(args.agent ?? "general");
|
|
46
37
|
}
|