@opencow-ai/opencow-agent-sdk 0.4.6 → 0.4.7
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/dist/capabilities/mcp/types.d.ts +1 -1
- package/dist/capabilities/tools/AgentTool/agentMerge.d.ts +8 -0
- package/dist/capabilities/tools/AgentTool/builtInAgents.d.ts +15 -0
- package/dist/capabilities/tools/AgentTool/runAgent.d.ts +13 -2
- package/dist/cli.mjs +343 -105
- package/dist/client.d.ts +10 -0
- package/dist/client.js +332 -77
- package/dist/constants/tools.d.ts +1 -1
- package/dist/controller/hooks.d.ts +17 -2
- package/dist/controller/loop.d.ts +2 -5
- package/dist/entrypoints/sdk/controlSchemas.d.ts +73 -1
- package/dist/entrypoints/sdk/coreSchemas.d.ts +17 -1
- package/dist/entrypoints/sdk/runtimeTypes.d.ts +22 -0
- package/dist/lib/envDynamic.d.ts +1 -1
- package/dist/providers/anthropic/teleport/api.d.ts +1 -1
- package/dist/providers/openai/shim.d.ts +2 -5
- package/dist/providers/provider.d.ts +2 -5
- package/dist/providers/shared/clientFactory.d.ts +2 -5
- package/dist/providers/shared/routing.d.ts +37 -6
- package/dist/sdk.js +332 -77
- package/dist/session/backgroundAbortRegistry.d.ts +23 -0
- package/dist/types/toolRuntime.d.ts +8 -5
- package/package.json +1 -1
package/dist/cli.mjs
CHANGED
|
@@ -51282,7 +51282,7 @@ function extractMcpToolDisplayName(userFacingName) {
|
|
|
51282
51282
|
var init_mcpStringUtils = () => {};
|
|
51283
51283
|
|
|
51284
51284
|
// src/constants/toolNames.ts
|
|
51285
|
-
var
|
|
51285
|
+
var AGENT_TOOL_NAME = "Agent", ASK_USER_QUESTION_TOOL_NAME = "AskUserQuestion", BASH_TOOL_NAME = "Bash", ENTER_PLAN_MODE_TOOL_NAME = "EnterPlanMode", ENTER_WORKTREE_TOOL_NAME = "EnterWorktree", EXIT_PLAN_MODE_TOOL_NAME = "ExitPlanMode", EXIT_PLAN_MODE_V2_TOOL_NAME = "ExitPlanMode", EXIT_WORKTREE_TOOL_NAME = "ExitWorktree", FILE_EDIT_TOOL_NAME = "Edit", FILE_READ_TOOL_NAME = "Read", FILE_WRITE_TOOL_NAME = "Write", GLOB_TOOL_NAME = "Glob", GREP_TOOL_NAME = "Grep", LEGACY_AGENT_TOOL_NAME = "Task", NOTEBOOK_EDIT_TOOL_NAME = "NotebookEdit", POWERSHELL_TOOL_NAME = "PowerShell", REPL_TOOL_NAME = "REPL", SEND_MESSAGE_TOOL_NAME = "SendMessage", SKILL_TOOL_NAME = "Skill", SLEEP_TOOL_NAME = "Sleep", SYNTHETIC_OUTPUT_TOOL_NAME = "StructuredOutput", TASK_CREATE_TOOL_NAME = "TaskCreate", TASK_GET_TOOL_NAME = "TaskGet", TASK_LIST_TOOL_NAME = "TaskList", TASK_OUTPUT_TOOL_NAME = "TaskOutput", TASK_STOP_TOOL_NAME = "TaskStop", TASK_UPDATE_TOOL_NAME = "TaskUpdate", TEAM_CREATE_TOOL_NAME = "TeamCreate", TEAM_DELETE_TOOL_NAME = "TeamDelete", TODO_WRITE_TOOL_NAME = "TodoWrite", TOOL_SEARCH_TOOL_NAME = "ToolSearch", EXPLORE_AGENT_TYPE = "Explore", PLAN_AGENT_TYPE = "Plan", WEB_FETCH_TOOL_NAME = "WebFetch", WEB_SEARCH_TOOL_NAME = "WebSearch";
|
|
51286
51286
|
|
|
51287
51287
|
// src/permissions/permissionRuleParser.ts
|
|
51288
51288
|
function normalizeLegacyToolName(name) {
|
|
@@ -51367,7 +51367,7 @@ function findLastUnescapedChar(str, char) {
|
|
|
51367
51367
|
var LEGACY_TOOL_NAME_ALIASES;
|
|
51368
51368
|
var init_permissionRuleParser = __esm(() => {
|
|
51369
51369
|
LEGACY_TOOL_NAME_ALIASES = {
|
|
51370
|
-
Task:
|
|
51370
|
+
Task: AGENT_TOOL_NAME,
|
|
51371
51371
|
KillShell: TASK_STOP_TOOL_NAME,
|
|
51372
51372
|
AgentOutputTool: TASK_OUTPUT_TOOL_NAME,
|
|
51373
51373
|
BashOutputTool: TASK_OUTPUT_TOOL_NAME,
|
|
@@ -85870,7 +85870,8 @@ class OpenAIShimMessages {
|
|
|
85870
85870
|
const self2 = this;
|
|
85871
85871
|
let httpResponse;
|
|
85872
85872
|
const promise2 = (async () => {
|
|
85873
|
-
const
|
|
85873
|
+
const overrideTransport = self2.providerOverride?.transport === "anthropic" ? undefined : self2.providerOverride?.transport;
|
|
85874
|
+
const request = resolveProviderRequest({ model: self2.providerOverride?.model ?? params.model, baseUrl: self2.providerOverride?.baseURL, reasoningEffortOverride: self2.reasoningEffort, transportOverride: overrideTransport });
|
|
85874
85875
|
const response = await self2._doRequest(request, params, options);
|
|
85875
85876
|
httpResponse = response;
|
|
85876
85877
|
if (params.stream) {
|
|
@@ -85895,7 +85896,7 @@ class OpenAIShimMessages {
|
|
|
85895
85896
|
}
|
|
85896
85897
|
async _doRequest(request, params, options) {
|
|
85897
85898
|
if (request.transport === "openai_responses") {
|
|
85898
|
-
const credentials = resolveOpenAIResponsesCredentials();
|
|
85899
|
+
const credentials = this.providerOverride?.apiKey ? { apiKey: this.providerOverride.apiKey, source: "env-openai" } : resolveOpenAIResponsesCredentials();
|
|
85899
85900
|
if (!credentials.apiKey) {
|
|
85900
85901
|
const safeModel = redactSecretValueForDisplay(request.requestedModel, process.env) ?? "the requested model";
|
|
85901
85902
|
const codexAuthHint = credentials.authPath ? `, set CODEX_API_KEY, or place a Codex auth.json at ${credentials.authPath}` : " or set CODEX_API_KEY";
|
|
@@ -85914,7 +85915,7 @@ class OpenAIShimMessages {
|
|
|
85914
85915
|
...options?.headers ?? {}
|
|
85915
85916
|
},
|
|
85916
85917
|
signal: options?.signal,
|
|
85917
|
-
providerSpecific: readOpenAIResponsesProviderSpecific()
|
|
85918
|
+
providerSpecific: this.providerOverride?.providerSpecific?.openaiResponses ?? readOpenAIResponsesProviderSpecific()
|
|
85918
85919
|
});
|
|
85919
85920
|
}
|
|
85920
85921
|
return this._doOpenAIRequest(request, params, options);
|
|
@@ -86221,7 +86222,6 @@ async function getNormalizedClient({
|
|
|
86221
86222
|
}
|
|
86222
86223
|
};
|
|
86223
86224
|
if (providerOverride) {
|
|
86224
|
-
const { createOpenAIShimClient: createOpenAIShimClient2 } = await Promise.resolve().then(() => (init_shim2(), exports_shim));
|
|
86225
86225
|
const safeHeaders = {};
|
|
86226
86226
|
for (const [k, v] of Object.entries(defaultHeaders)) {
|
|
86227
86227
|
const lower = k.toLowerCase();
|
|
@@ -86229,6 +86229,18 @@ async function getNormalizedClient({
|
|
|
86229
86229
|
continue;
|
|
86230
86230
|
safeHeaders[k] = v;
|
|
86231
86231
|
}
|
|
86232
|
+
if (providerOverride.transport === "anthropic") {
|
|
86233
|
+
const overrideToken = providerOverride.apiKey ?? getQueryEnvVar("ANTHROPIC_AUTH_TOKEN");
|
|
86234
|
+
return new Anthropic({
|
|
86235
|
+
apiKey: null,
|
|
86236
|
+
...overrideToken ? { authToken: overrideToken } : {},
|
|
86237
|
+
...providerOverride.baseURL ? { baseURL: providerOverride.baseURL } : {},
|
|
86238
|
+
...ARGS,
|
|
86239
|
+
defaultHeaders: safeHeaders,
|
|
86240
|
+
...isDebugToStdErr() && { logger: createStderrLogger() }
|
|
86241
|
+
});
|
|
86242
|
+
}
|
|
86243
|
+
const { createOpenAIShimClient: createOpenAIShimClient2 } = await Promise.resolve().then(() => (init_shim2(), exports_shim));
|
|
86232
86244
|
return createOpenAIShimClient2({
|
|
86233
86245
|
defaultHeaders: safeHeaders,
|
|
86234
86246
|
maxRetries,
|
|
@@ -86706,6 +86718,13 @@ function resolveProviderFromEnv(envOverride) {
|
|
|
86706
86718
|
const model = readEnv2(envOverride, "OPENAI_MODEL")?.trim() ?? "";
|
|
86707
86719
|
return model && isCodexAlias(model) ? providers.codex() : providers.openai();
|
|
86708
86720
|
}
|
|
86721
|
+
const transport = readEnv2(envOverride, QUERY_ENV_KEY_TRANSPORT_OVERRIDE)?.trim();
|
|
86722
|
+
if (transport === "openai_responses" || transport === "codex_responses") {
|
|
86723
|
+
return providers.codex();
|
|
86724
|
+
}
|
|
86725
|
+
if (transport === "chat_completions") {
|
|
86726
|
+
return providers.openai();
|
|
86727
|
+
}
|
|
86709
86728
|
if (envOverride) {
|
|
86710
86729
|
const hasOAuthToken = Boolean(readEnv2(envOverride, "CLAUDE_CODE_OAUTH_TOKEN"));
|
|
86711
86730
|
return providers.anthropic({
|
|
@@ -94361,7 +94380,7 @@ function printStartupScreen() {
|
|
|
94361
94380
|
const sLen = ` ● ${sL} Ready — type /help to begin`.length;
|
|
94362
94381
|
out.push(boxRow(sRow, W2, sLen));
|
|
94363
94382
|
out.push(`${rgb(...BORDER)}╚${"═".repeat(W2 - 2)}╝${RESET}`);
|
|
94364
|
-
out.push(` ${DIM}${rgb(...DIMCOL)}opencow ${RESET}${rgb(...ACCENT)}v${"0.4.
|
|
94383
|
+
out.push(` ${DIM}${rgb(...DIMCOL)}opencow ${RESET}${rgb(...ACCENT)}v${"0.4.7"}${RESET}`);
|
|
94365
94384
|
out.push("");
|
|
94366
94385
|
process.stdout.write(out.join(`
|
|
94367
94386
|
`) + `
|
|
@@ -97579,7 +97598,7 @@ var init_paths2 = __esm(() => {
|
|
|
97579
97598
|
});
|
|
97580
97599
|
|
|
97581
97600
|
// src/capabilities/tools/AgentTool/constants.ts
|
|
97582
|
-
var
|
|
97601
|
+
var AGENT_TOOL_NAME2 = "Agent", LEGACY_AGENT_TOOL_NAME2 = "Task", VERIFICATION_AGENT_TYPE = "verification", ONE_SHOT_BUILTIN_AGENT_TYPES;
|
|
97583
97602
|
var init_constants4 = __esm(() => {
|
|
97584
97603
|
ONE_SHOT_BUILTIN_AGENT_TYPES = new Set([
|
|
97585
97604
|
"Explore",
|
|
@@ -97691,7 +97710,7 @@ function getDescription() {
|
|
|
97691
97710
|
- Supports full regex syntax (e.g., "log.*Error", "function\\s+\\w+")
|
|
97692
97711
|
- Filter files with glob parameter (e.g., "*.js", "**/*.tsx") or type parameter (e.g., "js", "py", "rust")
|
|
97693
97712
|
- Output modes: "content" shows matching lines, "files_with_matches" shows only file paths (default), "count" shows match counts
|
|
97694
|
-
- Use ${
|
|
97713
|
+
- Use ${AGENT_TOOL_NAME2} tool for open-ended searches requiring multiple rounds
|
|
97695
97714
|
- Pattern syntax: Uses ripgrep (not grep) - literal braces need escaping (use \`interface\\{\\}\` to find \`interface{}\` in Go code)
|
|
97696
97715
|
- Multiline matching: By default patterns match within single lines only. For cross-line patterns like \`struct \\{[\\s\\S]*?field\`, use \`multiline: true\`
|
|
97697
97716
|
`;
|
|
@@ -97728,7 +97747,7 @@ var init_constants5 = __esm(() => {
|
|
|
97728
97747
|
GREP_TOOL_NAME2,
|
|
97729
97748
|
BASH_TOOL_NAME2,
|
|
97730
97749
|
NOTEBOOK_EDIT_TOOL_NAME2,
|
|
97731
|
-
|
|
97750
|
+
AGENT_TOOL_NAME2
|
|
97732
97751
|
]);
|
|
97733
97752
|
});
|
|
97734
97753
|
|
|
@@ -113824,7 +113843,7 @@ function toComparable(p) {
|
|
|
113824
113843
|
return IS_WINDOWS ? posixForm.toLowerCase() : posixForm;
|
|
113825
113844
|
}
|
|
113826
113845
|
function detectSessionFileType(filePath) {
|
|
113827
|
-
const configDir =
|
|
113846
|
+
const configDir = resolveConfigHomeDir();
|
|
113828
113847
|
const normalized = toComparable(filePath);
|
|
113829
113848
|
const configDirCmp = toComparable(configDir);
|
|
113830
113849
|
if (!normalized.startsWith(configDirCmp)) {
|
|
@@ -113952,6 +113971,7 @@ var init_memoryFileDetection = __esm(() => {
|
|
|
113952
113971
|
init_agentMemory();
|
|
113953
113972
|
init_state2();
|
|
113954
113973
|
init_paths();
|
|
113974
|
+
init_envUtils();
|
|
113955
113975
|
init_windowsPaths();
|
|
113956
113976
|
IS_WINDOWS = process.platform === "win32";
|
|
113957
113977
|
});
|
|
@@ -145544,7 +145564,7 @@ var init_exploreAgent = __esm(() => {
|
|
|
145544
145564
|
agentType: "Explore",
|
|
145545
145565
|
whenToUse: EXPLORE_WHEN_TO_USE,
|
|
145546
145566
|
disallowedTools: [
|
|
145547
|
-
|
|
145567
|
+
AGENT_TOOL_NAME,
|
|
145548
145568
|
EXIT_PLAN_MODE_TOOL_NAME,
|
|
145549
145569
|
FILE_EDIT_TOOL_NAME,
|
|
145550
145570
|
FILE_WRITE_TOOL_NAME,
|
|
@@ -145650,7 +145670,7 @@ var init_planAgent = __esm(() => {
|
|
|
145650
145670
|
agentType: "Plan",
|
|
145651
145671
|
whenToUse: "Software architect agent for designing implementation plans. Use this when you need to plan the implementation strategy for a task. Returns step-by-step plans, identifies critical files, and considers architectural trade-offs.",
|
|
145652
145672
|
disallowedTools: [
|
|
145653
|
-
|
|
145673
|
+
AGENT_TOOL_NAME2,
|
|
145654
145674
|
EXIT_PLAN_MODE_TOOL_NAME,
|
|
145655
145675
|
FILE_EDIT_TOOL_NAME,
|
|
145656
145676
|
FILE_WRITE_TOOL_NAME,
|
|
@@ -145938,9 +145958,20 @@ Use the literal string \`VERDICT: \` followed by exactly one of \`PASS\`, \`FAIL
|
|
|
145938
145958
|
- **PARTIAL**: what was verified, what could not be and why (missing tool/env), what the implementer should know.`;
|
|
145939
145959
|
});
|
|
145940
145960
|
|
|
145961
|
+
// src/capabilities/tools/AgentTool/agentMerge.ts
|
|
145962
|
+
function mergeAgentsByType(base2, override) {
|
|
145963
|
+
const byType = new Map;
|
|
145964
|
+
for (const agent of base2)
|
|
145965
|
+
byType.set(agent.agentType, agent);
|
|
145966
|
+
for (const agent of override)
|
|
145967
|
+
byType.set(agent.agentType, agent);
|
|
145968
|
+
return [...byType.values()];
|
|
145969
|
+
}
|
|
145970
|
+
|
|
145941
145971
|
// src/capabilities/tools/AgentTool/builtInAgents.ts
|
|
145942
145972
|
var exports_builtInAgents = {};
|
|
145943
145973
|
__export(exports_builtInAgents, {
|
|
145974
|
+
resolveSdkAgents: () => resolveSdkAgents,
|
|
145944
145975
|
getBuiltInAgents: () => getBuiltInAgents,
|
|
145945
145976
|
areExplorePlanAgentsEnabled: () => areExplorePlanAgentsEnabled
|
|
145946
145977
|
});
|
|
@@ -145967,6 +145998,9 @@ function getBuiltInAgents() {
|
|
|
145967
145998
|
if (false) {}
|
|
145968
145999
|
return agents;
|
|
145969
146000
|
}
|
|
146001
|
+
function resolveSdkAgents(hostAgents) {
|
|
146002
|
+
return mergeAgentsByType(getBuiltInAgents(), hostAgents);
|
|
146003
|
+
}
|
|
145970
146004
|
var init_builtInAgents = __esm(() => {
|
|
145971
146005
|
init_state();
|
|
145972
146006
|
init_envUtils();
|
|
@@ -239690,7 +239724,7 @@ var init_tools = __esm(() => {
|
|
|
239690
239724
|
TASK_OUTPUT_TOOL_NAME,
|
|
239691
239725
|
EXIT_PLAN_MODE_V2_TOOL_NAME,
|
|
239692
239726
|
ENTER_PLAN_MODE_TOOL_NAME,
|
|
239693
|
-
...process.env.USER_TYPE === "ant" ? [] : [
|
|
239727
|
+
...process.env.USER_TYPE === "ant" ? [] : [AGENT_TOOL_NAME],
|
|
239694
239728
|
ASK_USER_QUESTION_TOOL_NAME,
|
|
239695
239729
|
TASK_STOP_TOOL_NAME,
|
|
239696
239730
|
...[]
|
|
@@ -239724,7 +239758,7 @@ var init_tools = __esm(() => {
|
|
|
239724
239758
|
...[]
|
|
239725
239759
|
]);
|
|
239726
239760
|
COORDINATOR_MODE_ALLOWED_TOOLS = new Set([
|
|
239727
|
-
|
|
239761
|
+
AGENT_TOOL_NAME,
|
|
239728
239762
|
TASK_STOP_TOOL_NAME,
|
|
239729
239763
|
SEND_MESSAGE_TOOL_NAME,
|
|
239730
239764
|
SYNTHETIC_OUTPUT_TOOL_NAME
|
|
@@ -244170,7 +244204,7 @@ function getAnthropicEnvMetadata() {
|
|
|
244170
244204
|
function getBuildAgeMinutes() {
|
|
244171
244205
|
if (false)
|
|
244172
244206
|
;
|
|
244173
|
-
const buildTime = new Date("2026-06-
|
|
244207
|
+
const buildTime = new Date("2026-06-10T13:40:16.658Z").getTime();
|
|
244174
244208
|
if (isNaN(buildTime))
|
|
244175
244209
|
return;
|
|
244176
244210
|
return Math.floor((Date.now() - buildTime) / 60000);
|
|
@@ -247155,6 +247189,34 @@ var init_registerFrontmatterHooks = __esm(() => {
|
|
|
247155
247189
|
init_sessionHooks();
|
|
247156
247190
|
});
|
|
247157
247191
|
|
|
247192
|
+
// src/session/backgroundAbortRegistry.ts
|
|
247193
|
+
function registerBackgroundAgentAbort(agentId, controller) {
|
|
247194
|
+
runs.set(agentId, { controller, stopFired: false });
|
|
247195
|
+
}
|
|
247196
|
+
function unregisterBackgroundAgentAbort(agentId) {
|
|
247197
|
+
runs.delete(agentId);
|
|
247198
|
+
}
|
|
247199
|
+
function abortBackgroundAgentById(agentId) {
|
|
247200
|
+
const run = runs.get(agentId);
|
|
247201
|
+
if (!run)
|
|
247202
|
+
return false;
|
|
247203
|
+
run.controller.abort();
|
|
247204
|
+
return true;
|
|
247205
|
+
}
|
|
247206
|
+
function markSubagentStopFired(agentId) {
|
|
247207
|
+
const run = runs.get(agentId);
|
|
247208
|
+
if (run) {
|
|
247209
|
+
run.stopFired = true;
|
|
247210
|
+
}
|
|
247211
|
+
}
|
|
247212
|
+
function hasSubagentStopFired(agentId) {
|
|
247213
|
+
return runs.get(agentId)?.stopFired ?? false;
|
|
247214
|
+
}
|
|
247215
|
+
var runs;
|
|
247216
|
+
var init_backgroundAbortRegistry = __esm(() => {
|
|
247217
|
+
runs = new Map;
|
|
247218
|
+
});
|
|
247219
|
+
|
|
247158
247220
|
// src/providers/shared/model/agent.ts
|
|
247159
247221
|
function getDefaultSubagentModel() {
|
|
247160
247222
|
return "inherit";
|
|
@@ -247237,6 +247299,12 @@ var init_agent = __esm(() => {
|
|
|
247237
247299
|
});
|
|
247238
247300
|
|
|
247239
247301
|
// src/providers/shared/routing.ts
|
|
247302
|
+
function resolveModelProvider(model, modelProviders) {
|
|
247303
|
+
const config2 = modelProviders?.[model];
|
|
247304
|
+
if (!config2)
|
|
247305
|
+
return null;
|
|
247306
|
+
return { model, ...config2 };
|
|
247307
|
+
}
|
|
247240
247308
|
function normalize10(key) {
|
|
247241
247309
|
return key.toLowerCase().replace(/[-_]/g, "");
|
|
247242
247310
|
}
|
|
@@ -247542,6 +247610,12 @@ var init_caching = __esm(() => {
|
|
|
247542
247610
|
});
|
|
247543
247611
|
|
|
247544
247612
|
// src/providers/shared/model/antModels.ts
|
|
247613
|
+
function getAntModelOverrideConfig2() {
|
|
247614
|
+
if (process.env.USER_TYPE !== "ant") {
|
|
247615
|
+
return null;
|
|
247616
|
+
}
|
|
247617
|
+
return getFeatureValue_CACHED_MAY_BE_STALE("tengu_ant_model_override", null);
|
|
247618
|
+
}
|
|
247545
247619
|
var init_antModels = () => {};
|
|
247546
247620
|
|
|
247547
247621
|
// src/permissions/bashClassifier.ts
|
|
@@ -247646,7 +247720,7 @@ function filterToolsForAgent({
|
|
|
247646
247720
|
}
|
|
247647
247721
|
if (isAsync2 && !ASYNC_AGENT_ALLOWED_TOOLS.has(tool.name)) {
|
|
247648
247722
|
if (isAgentSwarmsEnabled() && isInProcessTeammate()) {
|
|
247649
|
-
if (toolMatchesName(tool,
|
|
247723
|
+
if (toolMatchesName(tool, AGENT_TOOL_NAME2)) {
|
|
247650
247724
|
return true;
|
|
247651
247725
|
}
|
|
247652
247726
|
if (IN_PROCESS_TEAMMATE_ALLOWED_TOOLS.has(tool.name)) {
|
|
@@ -247696,7 +247770,7 @@ function resolveAgentTools(agentDefinition, availableTools, isAsync2 = false, is
|
|
|
247696
247770
|
let allowedAgentTypes;
|
|
247697
247771
|
for (const toolSpec of agentTools) {
|
|
247698
247772
|
const { toolName, ruleContent } = permissionRuleValueFromString(toolSpec);
|
|
247699
|
-
if (toolName ===
|
|
247773
|
+
if (toolName === AGENT_TOOL_NAME2) {
|
|
247700
247774
|
if (ruleContent) {
|
|
247701
247775
|
allowedAgentTypes = ruleContent.split(",").map((s) => s.trim());
|
|
247702
247776
|
}
|
|
@@ -247915,6 +247989,8 @@ async function runAsyncAgentLifecycle({
|
|
|
247915
247989
|
return;
|
|
247916
247990
|
}
|
|
247917
247991
|
const msg = errorMessage(error41);
|
|
247992
|
+
logForDebugging2(`Background agent ${taskId} failed: ${msg}
|
|
247993
|
+
${error41 instanceof Error ? error41.stack ?? "" : ""}`, { level: "error" });
|
|
247918
247994
|
failAgentTask(taskId, msg, rootSetAppState);
|
|
247919
247995
|
const worktreeResult = await getWorktreeResult();
|
|
247920
247996
|
enqueueAgentNotification({
|
|
@@ -248069,6 +248145,49 @@ async function initializeAgentMcpServers(agentDefinition, parentClients) {
|
|
|
248069
248145
|
function isRecordableMessage(msg) {
|
|
248070
248146
|
return msg.type === "assistant" || msg.type === "user" || msg.type === "progress" || msg.type === "system" && "subtype" in msg && msg.subtype === "compact_boundary";
|
|
248071
248147
|
}
|
|
248148
|
+
function simplifySubagentMessageBlocks(msg) {
|
|
248149
|
+
const content = msg.message.content;
|
|
248150
|
+
if (!Array.isArray(content))
|
|
248151
|
+
return [];
|
|
248152
|
+
const out = [];
|
|
248153
|
+
for (const raw of content) {
|
|
248154
|
+
if (!raw || typeof raw !== "object")
|
|
248155
|
+
continue;
|
|
248156
|
+
const block2 = raw;
|
|
248157
|
+
switch (block2.type) {
|
|
248158
|
+
case "text":
|
|
248159
|
+
if (typeof block2.text === "string" && block2.text) {
|
|
248160
|
+
out.push({ type: "text", text: block2.text });
|
|
248161
|
+
}
|
|
248162
|
+
break;
|
|
248163
|
+
case "thinking":
|
|
248164
|
+
if (typeof block2.thinking === "string" && block2.thinking) {
|
|
248165
|
+
out.push({ type: "thinking", thinking: block2.thinking });
|
|
248166
|
+
}
|
|
248167
|
+
break;
|
|
248168
|
+
case "tool_use":
|
|
248169
|
+
out.push({
|
|
248170
|
+
type: "tool_use",
|
|
248171
|
+
tool_use_id: block2.id,
|
|
248172
|
+
name: block2.name,
|
|
248173
|
+
input: block2.input ?? {}
|
|
248174
|
+
});
|
|
248175
|
+
break;
|
|
248176
|
+
case "tool_result": {
|
|
248177
|
+
const c6 = block2.content;
|
|
248178
|
+
const text = typeof c6 === "string" ? c6 : Array.isArray(c6) ? c6.map((p) => p && typeof p === "object" && p.type === "text" ? String(p.text ?? "") : "").join("") : "";
|
|
248179
|
+
out.push({
|
|
248180
|
+
type: "tool_result",
|
|
248181
|
+
tool_use_id: block2.tool_use_id,
|
|
248182
|
+
content: text,
|
|
248183
|
+
is_error: Boolean(block2.is_error)
|
|
248184
|
+
});
|
|
248185
|
+
break;
|
|
248186
|
+
}
|
|
248187
|
+
}
|
|
248188
|
+
}
|
|
248189
|
+
return out;
|
|
248190
|
+
}
|
|
248072
248191
|
async function* runAgent({
|
|
248073
248192
|
agentDefinition,
|
|
248074
248193
|
promptMessages,
|
|
@@ -248091,13 +248210,14 @@ async function* runAgent({
|
|
|
248091
248210
|
description,
|
|
248092
248211
|
transcriptSubdir,
|
|
248093
248212
|
onQueryProgress,
|
|
248213
|
+
onPartialAssistant,
|
|
248094
248214
|
agentName
|
|
248095
248215
|
}) {
|
|
248096
248216
|
const appState = toolUseContext.getAppState();
|
|
248097
248217
|
const permissionMode = appState.toolPermissionContext.mode;
|
|
248098
248218
|
const rootSetAppState = toolUseContext.setAppStateForTasks ?? toolUseContext.setAppState;
|
|
248099
248219
|
const resolvedAgentModel = getAgentModel(agentDefinition.model, toolUseContext.options.mainLoopModel, model, permissionMode);
|
|
248100
|
-
const providerOverride = resolveAgentProvider(agentName, agentDefinition.agentType, getInitialSettings());
|
|
248220
|
+
const providerOverride = resolveAgentProvider(agentName, agentDefinition.agentType, getInitialSettings()) ?? resolveModelProvider(resolvedAgentModel, toolUseContext.options.modelProviders);
|
|
248101
248221
|
const effectiveModel = providerOverride ? providerOverride.model : resolvedAgentModel;
|
|
248102
248222
|
const agentId = override?.agentId ? override.agentId : createAgentId();
|
|
248103
248223
|
if (transcriptSubdir) {
|
|
@@ -248168,8 +248288,11 @@ async function* runAgent({
|
|
|
248168
248288
|
const additionalWorkingDirectories = Array.from(appState.toolPermissionContext.additionalWorkingDirectories.keys());
|
|
248169
248289
|
const agentSystemPrompt = override?.systemPrompt ? override.systemPrompt : asSystemPrompt(await getAgentSystemPrompt(agentDefinition, toolUseContext, resolvedAgentModel, additionalWorkingDirectories, resolvedTools));
|
|
248170
248290
|
const agentAbortController = override?.abortController ? override.abortController : isAsync2 ? new AbortController : toolUseContext.abortController;
|
|
248291
|
+
if (isAsync2) {
|
|
248292
|
+
registerBackgroundAgentAbort(agentId, agentAbortController);
|
|
248293
|
+
}
|
|
248171
248294
|
const additionalContexts = [];
|
|
248172
|
-
for await (const hookResult of executeSubagentStartHooks(agentId, agentDefinition.agentType, agentAbortController.signal)) {
|
|
248295
|
+
for await (const hookResult of executeSubagentStartHooks(agentId, agentDefinition.agentType, agentAbortController.signal, undefined, toolUseContext.toolUseId, isAsync2)) {
|
|
248173
248296
|
if (hookResult.additionalContexts && hookResult.additionalContexts.length > 0) {
|
|
248174
248297
|
additionalContexts.push(...hookResult.additionalContexts);
|
|
248175
248298
|
}
|
|
@@ -248234,7 +248357,7 @@ async function* runAgent({
|
|
|
248234
248357
|
verbose: toolUseContext.options.verbose,
|
|
248235
248358
|
mainLoopModel: effectiveModel,
|
|
248236
248359
|
providerOverride: providerOverride ?? undefined,
|
|
248237
|
-
thinkingConfig:
|
|
248360
|
+
thinkingConfig: toolUseContext.options.thinkingConfig,
|
|
248238
248361
|
mcpClients: mergedMcpClients,
|
|
248239
248362
|
mcpResources: toolUseContext.options.mcpResources,
|
|
248240
248363
|
agentDefinitions: toolUseContext.options.agentDefinitions,
|
|
@@ -248272,6 +248395,12 @@ async function* runAgent({
|
|
|
248272
248395
|
...description && { description }
|
|
248273
248396
|
}).catch((_err) => logForDebugging2(`Failed to write agent metadata: ${_err}`));
|
|
248274
248397
|
let lastRecordedUuid = initialMessages.at(-1)?.uuid ?? null;
|
|
248398
|
+
let partialBaseMessage = null;
|
|
248399
|
+
const partialTextByIndex = new Map;
|
|
248400
|
+
const PARTIAL_PROGRESS_HOOK_INTERVAL_MS = 100;
|
|
248401
|
+
let lastPartialProgressHookAt = 0;
|
|
248402
|
+
let lastAssistantForFallback = null;
|
|
248403
|
+
let agentRunError;
|
|
248275
248404
|
try {
|
|
248276
248405
|
for await (const message of query({
|
|
248277
248406
|
messages: initialMessages,
|
|
@@ -248284,8 +248413,37 @@ async function* runAgent({
|
|
|
248284
248413
|
maxTurns: maxTurns ?? agentDefinition.maxTurns
|
|
248285
248414
|
})) {
|
|
248286
248415
|
onQueryProgress?.();
|
|
248287
|
-
if (message.type === "stream_event"
|
|
248288
|
-
|
|
248416
|
+
if (message.type === "stream_event") {
|
|
248417
|
+
const ev = message.event;
|
|
248418
|
+
if (ev.type === "message_start") {
|
|
248419
|
+
if (message.ttftMs != null) {
|
|
248420
|
+
toolUseContext.pushApiMetricsEntry?.(message.ttftMs);
|
|
248421
|
+
}
|
|
248422
|
+
if ((onPartialAssistant || isAsync2) && ev.message) {
|
|
248423
|
+
partialBaseMessage = ev.message;
|
|
248424
|
+
partialTextByIndex.clear();
|
|
248425
|
+
}
|
|
248426
|
+
} else if ((onPartialAssistant || isAsync2) && partialBaseMessage && ev.type === "content_block_delta" && ev.delta?.type === "text_delta" && typeof ev.delta.text === "string") {
|
|
248427
|
+
const idx = ev.index ?? 0;
|
|
248428
|
+
const acc = (partialTextByIndex.get(idx) ?? "") + ev.delta.text;
|
|
248429
|
+
partialTextByIndex.set(idx, acc);
|
|
248430
|
+
onPartialAssistant?.({
|
|
248431
|
+
type: "assistant",
|
|
248432
|
+
message: {
|
|
248433
|
+
...partialBaseMessage,
|
|
248434
|
+
content: [{ type: "text", text: acc, citations: null }]
|
|
248435
|
+
},
|
|
248436
|
+
uuid: randomUUID10(),
|
|
248437
|
+
timestamp: new Date().toISOString()
|
|
248438
|
+
});
|
|
248439
|
+
if (isAsync2) {
|
|
248440
|
+
const now = Date.now();
|
|
248441
|
+
if (now - lastPartialProgressHookAt >= PARTIAL_PROGRESS_HOOK_INTERVAL_MS) {
|
|
248442
|
+
lastPartialProgressHookAt = now;
|
|
248443
|
+
executeSubagentProgressHooks(agentId, agentDefinition.agentType, partialBaseMessage.id, toolUseContext.toolUseId, [{ type: "text", text: acc }]).catch(() => {});
|
|
248444
|
+
}
|
|
248445
|
+
}
|
|
248446
|
+
}
|
|
248289
248447
|
continue;
|
|
248290
248448
|
}
|
|
248291
248449
|
if (message.type === "attachment") {
|
|
@@ -248310,6 +248468,16 @@ async function* runAgent({
|
|
|
248310
248468
|
if (message.type !== "progress") {
|
|
248311
248469
|
lastRecordedUuid = message.uuid;
|
|
248312
248470
|
}
|
|
248471
|
+
if (isAsync2 && message.type === "assistant" && message.message.content.some((b) => b.type === "text" && b.text.trim().length > 0)) {
|
|
248472
|
+
lastAssistantForFallback = message;
|
|
248473
|
+
}
|
|
248474
|
+
if (isAsync2 && (message.type === "assistant" || message.type === "user")) {
|
|
248475
|
+
const blocks = simplifySubagentMessageBlocks(message);
|
|
248476
|
+
if (blocks.length > 0) {
|
|
248477
|
+
const messageId = (message.type === "assistant" ? message.message.id : undefined) ?? message.uuid;
|
|
248478
|
+
executeSubagentProgressHooks(agentId, agentDefinition.agentType, messageId, toolUseContext.toolUseId, blocks).catch(() => {});
|
|
248479
|
+
}
|
|
248480
|
+
}
|
|
248313
248481
|
yield message;
|
|
248314
248482
|
}
|
|
248315
248483
|
}
|
|
@@ -248319,7 +248487,30 @@ async function* runAgent({
|
|
|
248319
248487
|
if (isBuiltInAgent(agentDefinition) && agentDefinition.callback) {
|
|
248320
248488
|
agentDefinition.callback();
|
|
248321
248489
|
}
|
|
248490
|
+
} catch (err2) {
|
|
248491
|
+
agentRunError = err2;
|
|
248492
|
+
throw err2;
|
|
248322
248493
|
} finally {
|
|
248494
|
+
const naturalStopAlreadyFired = isAsync2 && hasSubagentStopFired(agentId);
|
|
248495
|
+
if (isAsync2) {
|
|
248496
|
+
unregisterBackgroundAgentAbort(agentId);
|
|
248497
|
+
}
|
|
248498
|
+
if (isAsync2 && agentRunError !== undefined) {
|
|
248499
|
+
logForDebugging2(`Background agent ${agentId} crashed: ${errorMessage(agentRunError)}
|
|
248500
|
+
${agentRunError instanceof Error ? agentRunError.stack ?? "" : ""}`, { level: "error" });
|
|
248501
|
+
}
|
|
248502
|
+
if (isAsync2 && !naturalStopAlreadyFired) {
|
|
248503
|
+
try {
|
|
248504
|
+
const fallbackAppState = agentToolRuntimeContext.getAppState();
|
|
248505
|
+
const terminal = agentAbortController.signal.aborted ? { status: "stopped" } : agentRunError !== undefined ? { status: "failed", errorMessage: errorMessage(agentRunError) } : { status: "completed" };
|
|
248506
|
+
const fallbackStop = executeStopHooks(fallbackAppState.toolPermissionContext.mode, undefined, undefined, false, agentId, agentToolRuntimeContext, lastAssistantForFallback ? [lastAssistantForFallback] : undefined, agentDefinition.agentType, undefined, terminal);
|
|
248507
|
+
for await (const evt of fallbackStop) {}
|
|
248508
|
+
} catch (err2) {
|
|
248509
|
+
logForDebugging2(`Fallback SubagentStop failed for ${agentId}: ${err2}`, {
|
|
248510
|
+
level: "warn"
|
|
248511
|
+
});
|
|
248512
|
+
}
|
|
248513
|
+
}
|
|
248323
248514
|
await mcpCleanup();
|
|
248324
248515
|
if (agentDefinition.hooks) {
|
|
248325
248516
|
clearSessionHooks(rootSetAppState, agentId);
|
|
@@ -248415,6 +248606,7 @@ var init_runAgent = __esm(() => {
|
|
|
248415
248606
|
init_registerFrontmatterHooks();
|
|
248416
248607
|
init_sessionHooks();
|
|
248417
248608
|
init_hooks2();
|
|
248609
|
+
init_backgroundAbortRegistry();
|
|
248418
248610
|
init_messages4();
|
|
248419
248611
|
init_agent();
|
|
248420
248612
|
init_settings2();
|
|
@@ -248820,7 +249012,7 @@ var init_TodoWriteTool = __esm(() => {
|
|
|
248820
249012
|
const base2 = `Todos have been modified successfully. Ensure that you continue to use the todo list to track your progress. Please proceed with the current tasks if applicable`;
|
|
248821
249013
|
const nudge = verificationNudgeNeeded ? `
|
|
248822
249014
|
|
|
248823
|
-
NOTE: You just closed out 3+ tasks and none of them was a verification step. Before writing your final summary, spawn the verification agent (subagent_type="${
|
|
249015
|
+
NOTE: You just closed out 3+ tasks and none of them was a verification step. Before writing your final summary, spawn the verification agent (subagent_type="${VERIFICATION_AGENT_TYPE}"). You cannot self-assign PARTIAL by listing caveats in your summary — only the verifier issues a verdict.` : "";
|
|
248824
249016
|
return {
|
|
248825
249017
|
tool_use_id: toolUseID,
|
|
248826
249018
|
type: "tool_result",
|
|
@@ -251569,7 +251761,9 @@ var init_coreSchemas = __esm(() => {
|
|
|
251569
251761
|
SubagentStartHookInputSchema = lazySchema(() => BaseHookInputSchema().and(exports_external.object({
|
|
251570
251762
|
hook_event_name: exports_external.literal("SubagentStart"),
|
|
251571
251763
|
agent_id: exports_external.string(),
|
|
251572
|
-
agent_type: exports_external.string()
|
|
251764
|
+
agent_type: exports_external.string(),
|
|
251765
|
+
tool_use_id: exports_external.string().optional().describe("tool_use id of the Agent tool call that launched this subagent. " + "Lets hosts correlate the subagent lifecycle back to the launching " + "tool call (e.g. to render an inline running indicator on its pill)."),
|
|
251766
|
+
is_background: exports_external.boolean().optional().describe("True when the subagent was launched with run_in_background (async). " + "Lets hosts scope background-specific UI/notifications to async agents.")
|
|
251573
251767
|
})));
|
|
251574
251768
|
SubagentStopHookInputSchema = lazySchema(() => BaseHookInputSchema().and(exports_external.object({
|
|
251575
251769
|
hook_event_name: exports_external.literal("SubagentStop"),
|
|
@@ -251577,7 +251771,9 @@ var init_coreSchemas = __esm(() => {
|
|
|
251577
251771
|
agent_id: exports_external.string(),
|
|
251578
251772
|
agent_transcript_path: exports_external.string(),
|
|
251579
251773
|
agent_type: exports_external.string(),
|
|
251580
|
-
last_assistant_message: exports_external.string().optional().describe("Text content of the last assistant message before stopping. " + "Avoids the need to read and parse the transcript file.")
|
|
251774
|
+
last_assistant_message: exports_external.string().optional().describe("Text content of the last assistant message before stopping. " + "Avoids the need to read and parse the transcript file."),
|
|
251775
|
+
status: exports_external.enum(["completed", "failed", "stopped"]).optional().describe("Terminal outcome carried by the guaranteed terminal delivery for " + "background subagents (fired from the run teardown). Absent on the " + "natural-stop path — hosts treat a missing status as completed."),
|
|
251776
|
+
error_message: exports_external.string().optional().describe("Present when status is failed: the error that aborted the run.")
|
|
251581
251777
|
})));
|
|
251582
251778
|
PreCompactHookInputSchema = lazySchema(() => BaseHookInputSchema().and(exports_external.object({
|
|
251583
251779
|
hook_event_name: exports_external.literal("PreCompact"),
|
|
@@ -264458,7 +264654,7 @@ ${forkEnabled ? "For fresh agents, terse" : "Terse"} command-style prompts produ
|
|
|
264458
264654
|
<example>
|
|
264459
264655
|
user: "What's left on this branch before we can ship?"
|
|
264460
264656
|
assistant: <thinking>Forking this — it's a survey question. I want the punch list, not the git output in my context.</thinking>
|
|
264461
|
-
${
|
|
264657
|
+
${AGENT_TOOL_NAME2}({
|
|
264462
264658
|
name: "ship-audit",
|
|
264463
264659
|
description: "Branch ship-readiness audit",
|
|
264464
264660
|
prompt: "Audit what's left before this branch can ship. Check: uncommitted changes, commits ahead of main, whether tests exist, whether the GrowthBook gate is wired up, whether CI-relevant files changed. Report a punch list — done vs. missing. Under 200 words."
|
|
@@ -264485,7 +264681,7 @@ assistant: <thinking>I'll ask the code-reviewer agent — it won't see my analys
|
|
|
264485
264681
|
<commentary>
|
|
264486
264682
|
A subagent_type is specified, so the agent starts fresh. It needs full context in the prompt. The briefing explains what to assess and why.
|
|
264487
264683
|
</commentary>
|
|
264488
|
-
${
|
|
264684
|
+
${AGENT_TOOL_NAME2}({
|
|
264489
264685
|
name: "migration-review",
|
|
264490
264686
|
description: "Independent migration review",
|
|
264491
264687
|
subagent_type: "code-reviewer",
|
|
@@ -264515,7 +264711,7 @@ function isPrime(n) {
|
|
|
264515
264711
|
<commentary>
|
|
264516
264712
|
Since a significant piece of code was written and the task was completed, now use the test-runner agent to run the tests
|
|
264517
264713
|
</commentary>
|
|
264518
|
-
assistant: Uses the ${
|
|
264714
|
+
assistant: Uses the ${AGENT_TOOL_NAME2} tool to launch the test-runner agent
|
|
264519
264715
|
</example>
|
|
264520
264716
|
|
|
264521
264717
|
<example>
|
|
@@ -264523,7 +264719,7 @@ user: "Hello"
|
|
|
264523
264719
|
<commentary>
|
|
264524
264720
|
Since the user is greeting, use the greeting-responder agent to respond with a friendly joke
|
|
264525
264721
|
</commentary>
|
|
264526
|
-
assistant: "I'm going to use the ${
|
|
264722
|
+
assistant: "I'm going to use the ${AGENT_TOOL_NAME2} tool to launch the greeting-responder agent"
|
|
264527
264723
|
</example>
|
|
264528
264724
|
`;
|
|
264529
264725
|
const listViaAttachment = shouldInjectAgentListInMessages();
|
|
@@ -264532,11 +264728,11 @@ ${effectiveAgents.map((agent) => formatAgentLine(agent)).join(`
|
|
|
264532
264728
|
`)}`;
|
|
264533
264729
|
const shared2 = `Launch a new agent to handle complex, multi-step tasks autonomously.
|
|
264534
264730
|
|
|
264535
|
-
The ${
|
|
264731
|
+
The ${AGENT_TOOL_NAME2} tool launches specialized agents (subprocesses) that autonomously handle complex tasks. Each agent type has specific capabilities and tools available to it.
|
|
264536
264732
|
|
|
264537
264733
|
${agentListSection}
|
|
264538
264734
|
|
|
264539
|
-
${forkEnabled ? `When using the ${
|
|
264735
|
+
${forkEnabled ? `When using the ${AGENT_TOOL_NAME2} tool, specify a subagent_type to use a specialized agent, or omit it to fork yourself — a fork inherits your full conversation context.` : `When using the ${AGENT_TOOL_NAME2} tool, specify a subagent_type parameter to select which agent type to use. If omitted, the general-purpose agent is used.`}`;
|
|
264540
264736
|
if (isCoordinator) {
|
|
264541
264737
|
return shared2;
|
|
264542
264738
|
}
|
|
@@ -264544,10 +264740,10 @@ ${forkEnabled ? `When using the ${AGENT_TOOL_NAME3} tool, specify a subagent_typ
|
|
|
264544
264740
|
const fileSearchHint = embedded ? "`find` via the Bash tool" : `the ${GLOB_TOOL_NAME2} tool`;
|
|
264545
264741
|
const contentSearchHint = embedded ? "`grep` via the Bash tool" : `the ${GLOB_TOOL_NAME2} tool`;
|
|
264546
264742
|
const whenNotToUseSection = forkEnabled ? "" : `
|
|
264547
|
-
When NOT to use the ${
|
|
264548
|
-
- If you want to read a specific file path, use the ${FILE_READ_TOOL_NAME2} tool or ${fileSearchHint} instead of the ${
|
|
264743
|
+
When NOT to use the ${AGENT_TOOL_NAME2} tool:
|
|
264744
|
+
- If you want to read a specific file path, use the ${FILE_READ_TOOL_NAME2} tool or ${fileSearchHint} instead of the ${AGENT_TOOL_NAME2} tool, to find the match more quickly
|
|
264549
264745
|
- If you are searching for a specific class definition like "class Foo", use ${contentSearchHint} instead, to find the match more quickly
|
|
264550
|
-
- If you are searching for code within a specific file or set of 2-3 files, use the ${FILE_READ_TOOL_NAME2} tool instead of the ${
|
|
264746
|
+
- If you are searching for code within a specific file or set of 2-3 files, use the ${FILE_READ_TOOL_NAME2} tool instead of the ${AGENT_TOOL_NAME2} tool, to find the match more quickly
|
|
264551
264747
|
- Other tasks that are not related to the agent descriptions above
|
|
264552
264748
|
`;
|
|
264553
264749
|
const concurrencyNote = !listViaAttachment && getSubscriptionType() !== "pro" ? `
|
|
@@ -264564,7 +264760,7 @@ Usage notes:
|
|
|
264564
264760
|
- The agent's outputs should generally be trusted
|
|
264565
264761
|
- Clearly tell the agent whether you expect it to write code or just to do research (search, file reads, web fetches, etc.)${forkEnabled ? "" : ", since it is not aware of the user's intent"}
|
|
264566
264762
|
- If the agent description mentions that it should be used proactively, then you should try your best to use it without the user having to ask for it first. Use your judgement.
|
|
264567
|
-
- If the user specifies that they want you to run agents "in parallel", you MUST send a single message with multiple ${
|
|
264763
|
+
- If the user specifies that they want you to run agents "in parallel", you MUST send a single message with multiple ${AGENT_TOOL_NAME2} tool use content blocks. For example, if you need to launch both a build-validator agent and a test-runner agent in parallel, send a single message with both tool calls.
|
|
264568
264764
|
- You can optionally set \`isolation: "worktree"\` to run the agent in a temporary git worktree, giving it an isolated copy of the repository. The worktree is automatically cleaned up if the agent makes no changes; if changes are made, the worktree path and branch are returned in the result.${process.env.USER_TYPE === "ant" ? `
|
|
264569
264765
|
- You can set \`isolation: "remote"\` to run the agent in a remote CCR environment. This is always a background task; you'll be notified when it completes. Use for long-running tasks that need a fresh sandbox.` : ""}${isInProcessTeammate() ? `
|
|
264570
264766
|
- The run_in_background, name, team_name, and mode parameters are not available in this context. Only synchronous subagents are supported.` : isTeammate() ? `
|
|
@@ -264714,11 +264910,11 @@ var init_AgentTool = __esm(() => {
|
|
|
264714
264910
|
}
|
|
264715
264911
|
}
|
|
264716
264912
|
const agentsWithMcpRequirementsMet = filterAgentsByMcpRequirements(agents, mcpServersWithTools);
|
|
264717
|
-
const filteredAgents = filterDeniedAgents(agentsWithMcpRequirementsMet, toolPermissionContext,
|
|
264913
|
+
const filteredAgents = filterDeniedAgents(agentsWithMcpRequirementsMet, toolPermissionContext, AGENT_TOOL_NAME2);
|
|
264718
264914
|
const isCoordinator = false;
|
|
264719
264915
|
return await getPrompt3(filteredAgents, isCoordinator, allowedAgentTypes);
|
|
264720
264916
|
},
|
|
264721
|
-
name:
|
|
264917
|
+
name: AGENT_TOOL_NAME2,
|
|
264722
264918
|
searchHint: "delegate work to a subagent",
|
|
264723
264919
|
aliases: [LEGACY_AGENT_TOOL_NAME2],
|
|
264724
264920
|
maxResultSizeChars: 1e5,
|
|
@@ -264798,13 +264994,13 @@ var init_AgentTool = __esm(() => {
|
|
|
264798
264994
|
const {
|
|
264799
264995
|
allowedAgentTypes
|
|
264800
264996
|
} = toolUseContext.options.agentDefinitions;
|
|
264801
|
-
const agents = filterDeniedAgents(allowedAgentTypes ? allAgents.filter((a2) => allowedAgentTypes.includes(a2.agentType)) : allAgents, appState.toolPermissionContext,
|
|
264997
|
+
const agents = filterDeniedAgents(allowedAgentTypes ? allAgents.filter((a2) => allowedAgentTypes.includes(a2.agentType)) : allAgents, appState.toolPermissionContext, AGENT_TOOL_NAME2);
|
|
264802
264998
|
const found = agents.find((agent) => agent.agentType === effectiveType);
|
|
264803
264999
|
if (!found) {
|
|
264804
265000
|
const agentExistsButDenied = allAgents.find((agent) => agent.agentType === effectiveType);
|
|
264805
265001
|
if (agentExistsButDenied) {
|
|
264806
|
-
const denyRule = getDenyRuleForAgent(appState.toolPermissionContext,
|
|
264807
|
-
throw new Error(`Agent type '${effectiveType}' has been denied by permission rule '${
|
|
265002
|
+
const denyRule = getDenyRuleForAgent(appState.toolPermissionContext, AGENT_TOOL_NAME2, effectiveType);
|
|
265003
|
+
throw new Error(`Agent type '${effectiveType}' has been denied by permission rule '${AGENT_TOOL_NAME2}(${effectiveType})' from ${denyRule?.source ?? "settings"}.`);
|
|
264808
265004
|
}
|
|
264809
265005
|
throw new Error(`Agent type '${effectiveType}' not found. Available agents: ${agents.map((a2) => a2.agentType).join(", ")}`);
|
|
264810
265006
|
}
|
|
@@ -265175,6 +265371,19 @@ ${reasons}`);
|
|
|
265175
265371
|
...runAgentParams.override,
|
|
265176
265372
|
agentId: syncAgentId
|
|
265177
265373
|
},
|
|
265374
|
+
onPartialAssistant: onProgress ? (partial2) => {
|
|
265375
|
+
if (partial2.message.content.length === 0)
|
|
265376
|
+
return;
|
|
265377
|
+
onProgress({
|
|
265378
|
+
toolUseID: `agent_${assistantMessage.message.id}`,
|
|
265379
|
+
data: {
|
|
265380
|
+
message: partial2,
|
|
265381
|
+
type: "agent_progress",
|
|
265382
|
+
prompt: "",
|
|
265383
|
+
agentId: syncAgentId
|
|
265384
|
+
}
|
|
265385
|
+
});
|
|
265386
|
+
} : undefined,
|
|
265178
265387
|
onCacheSafeParams: summaryTaskId && getSdkAgentProgressSummariesEnabled() ? (params) => {
|
|
265179
265388
|
const {
|
|
265180
265389
|
stop
|
|
@@ -265357,21 +265566,16 @@ ${reasons}`);
|
|
|
265357
265566
|
}
|
|
265358
265567
|
const normalizedNew = normalizeMessages([message]);
|
|
265359
265568
|
for (const m of normalizedNew) {
|
|
265360
|
-
|
|
265361
|
-
|
|
265362
|
-
|
|
265363
|
-
|
|
265364
|
-
|
|
265365
|
-
|
|
265366
|
-
|
|
265367
|
-
|
|
265368
|
-
|
|
265369
|
-
|
|
265370
|
-
prompt: "",
|
|
265371
|
-
agentId: syncAgentId
|
|
265372
|
-
}
|
|
265373
|
-
});
|
|
265374
|
-
}
|
|
265569
|
+
if (onProgress && m.message.content.length > 0) {
|
|
265570
|
+
onProgress({
|
|
265571
|
+
toolUseID: `agent_${assistantMessage.message.id}`,
|
|
265572
|
+
data: {
|
|
265573
|
+
message: m,
|
|
265574
|
+
type: "agent_progress",
|
|
265575
|
+
prompt: "",
|
|
265576
|
+
agentId: syncAgentId
|
|
265577
|
+
}
|
|
265578
|
+
});
|
|
265375
265579
|
}
|
|
265376
265580
|
}
|
|
265377
265581
|
}
|
|
@@ -265519,10 +265723,9 @@ Briefly tell the user what you launched and end your response.`
|
|
|
265519
265723
|
if (data.status === "async_launched") {
|
|
265520
265724
|
const prefix = `Async agent launched successfully.
|
|
265521
265725
|
agentId: ${data.agentId} (internal ID - do not mention to user. Use SendMessage with to: '${data.agentId}' to continue this agent.)
|
|
265522
|
-
The agent is working in the background.
|
|
265523
|
-
const instructions =
|
|
265524
|
-
|
|
265525
|
-
If asked, you can check progress before completion by using ${FILE_READ_TOOL_NAME2} or ${BASH_TOOL_NAME2} tail on the output file.` : `Briefly tell the user what you launched and end your response. Do not generate any other text — agent results will arrive in a subsequent message.`;
|
|
265726
|
+
The agent is working in the background. Its result will be delivered to you automatically when it completes.`;
|
|
265727
|
+
const instructions = `Do not duplicate this agent's work — avoid working with the same files or topics it is using. Work on non-overlapping tasks, or briefly tell the user what you launched and end your response.
|
|
265728
|
+
Do NOT read its output/transcript file to check progress — its result will arrive automatically in a subsequent message.`;
|
|
265526
265729
|
const text = `${prefix}
|
|
265527
265730
|
${instructions}`;
|
|
265528
265731
|
return {
|
|
@@ -276167,7 +276370,7 @@ Git Safety Protocol:
|
|
|
276167
276370
|
|
|
276168
276371
|
Important notes:
|
|
276169
276372
|
- NEVER run additional commands to read or explore code, besides git bash commands
|
|
276170
|
-
- NEVER use the ${TodoWriteTool.name} or ${
|
|
276373
|
+
- NEVER use the ${TodoWriteTool.name} or ${AGENT_TOOL_NAME2} tools
|
|
276171
276374
|
- DO NOT push to the remote repository unless the user explicitly asks you to do so
|
|
276172
276375
|
- IMPORTANT: Never use git commands with the -i flag (like git rebase -i or git add -i) since they require interactive input which is not supported.
|
|
276173
276376
|
- IMPORTANT: Do not use --no-edit with git rebase commands, as the --no-edit flag is not a valid option for git rebase.
|
|
@@ -276213,7 +276416,7 @@ EOF
|
|
|
276213
276416
|
</example>
|
|
276214
276417
|
|
|
276215
276418
|
Important:
|
|
276216
|
-
- DO NOT use the ${TodoWriteTool.name} or ${
|
|
276419
|
+
- DO NOT use the ${TodoWriteTool.name} or ${AGENT_TOOL_NAME2} tools
|
|
276217
276420
|
- Return the PR URL when you're done, so the user can see it
|
|
276218
276421
|
|
|
276219
276422
|
# Other common operations
|
|
@@ -300174,7 +300377,7 @@ function getDeferredToolsDeltaAttachment(tools, model, messages, scanContext) {
|
|
|
300174
300377
|
function getAgentListingDeltaAttachment(toolUseContext, messages) {
|
|
300175
300378
|
if (!shouldInjectAgentListInMessages())
|
|
300176
300379
|
return [];
|
|
300177
|
-
if (!toolUseContext.options.tools.some((t) => toolMatchesName2(t,
|
|
300380
|
+
if (!toolUseContext.options.tools.some((t) => toolMatchesName2(t, AGENT_TOOL_NAME))) {
|
|
300178
300381
|
return [];
|
|
300179
300382
|
}
|
|
300180
300383
|
const { activeAgents, allowedAgentTypes } = toolUseContext.options.agentDefinitions;
|
|
@@ -300185,7 +300388,7 @@ function getAgentListingDeltaAttachment(toolUseContext, messages) {
|
|
|
300185
300388
|
mcpServers.add(info.serverName);
|
|
300186
300389
|
}
|
|
300187
300390
|
const permissionContext = toolUseContext.getAppState().toolPermissionContext;
|
|
300188
|
-
let filtered = filterDeniedAgents(filterAgentsByMcpRequirements(activeAgents, [...mcpServers]), permissionContext,
|
|
300391
|
+
let filtered = filterDeniedAgents(filterAgentsByMcpRequirements(activeAgents, [...mcpServers]), permissionContext, AGENT_TOOL_NAME);
|
|
300189
300392
|
if (allowedAgentTypes) {
|
|
300190
300393
|
filtered = filtered.filter((a2) => allowedAgentTypes.includes(a2.agentType));
|
|
300191
300394
|
}
|
|
@@ -305854,7 +306057,7 @@ function getAntModelOverrideSection() {
|
|
|
305854
306057
|
return null;
|
|
305855
306058
|
if (isUndercover())
|
|
305856
306059
|
return null;
|
|
305857
|
-
return
|
|
306060
|
+
return getAntModelOverrideConfig2()?.defaultSystemPromptSuffix || null;
|
|
305858
306061
|
}
|
|
305859
306062
|
function getLanguageSection(languagePreference) {
|
|
305860
306063
|
if (!languagePreference)
|
|
@@ -306273,6 +306476,7 @@ var init_prompts2 = __esm(() => {
|
|
|
306273
306476
|
init_debug();
|
|
306274
306477
|
init_memdir();
|
|
306275
306478
|
init_mcpInstructionsDelta();
|
|
306479
|
+
init_antModels();
|
|
306276
306480
|
init_state2();
|
|
306277
306481
|
CLAUDE_4_5_OR_4_6_MODEL_IDS = {
|
|
306278
306482
|
opus: "claude-opus-4-6",
|
|
@@ -306698,7 +306902,7 @@ var init_api3 = __esm(() => {
|
|
|
306698
306902
|
init_zodToJsonSchema2();
|
|
306699
306903
|
SWARM_FIELDS_BY_TOOL = {
|
|
306700
306904
|
[EXIT_PLAN_MODE_V2_TOOL_NAME]: ["launchSwarm", "teammateCount"],
|
|
306701
|
-
[
|
|
306905
|
+
[AGENT_TOOL_NAME]: ["name", "team_name", "mode"]
|
|
306702
306906
|
};
|
|
306703
306907
|
});
|
|
306704
306908
|
|
|
@@ -309627,7 +309831,7 @@ function isDangerousPowerShellPermission(toolName, ruleContent) {
|
|
|
309627
309831
|
return false;
|
|
309628
309832
|
}
|
|
309629
309833
|
function isDangerousTaskPermission(toolName, _ruleContent) {
|
|
309630
|
-
return normalizeLegacyToolName(toolName) ===
|
|
309834
|
+
return normalizeLegacyToolName(toolName) === AGENT_TOOL_NAME;
|
|
309631
309835
|
}
|
|
309632
309836
|
function formatPermissionSource(source) {
|
|
309633
309837
|
if (SETTING_SOURCES.includes(source)) {
|
|
@@ -313318,7 +313522,7 @@ ${attachment.removedNames.join(`
|
|
|
313318
313522
|
}
|
|
313319
313523
|
case "verify_plan_reminder": {
|
|
313320
313524
|
const toolName = resolveEnvVar("VERIFY_PLAN") === "true" ? "VerifyPlanExecution" : "";
|
|
313321
|
-
const content = `You have completed implementing the plan. Please call the "${toolName}" tool directly (NOT the ${
|
|
313525
|
+
const content = `You have completed implementing the plan. Please call the "${toolName}" tool directly (NOT the ${AGENT_TOOL_NAME} tool or an agent) to verify that all plan items were completed correctly.`;
|
|
313322
313526
|
return wrapMessagesInSystemReminder([
|
|
313323
313527
|
createUserMessage({ content, isMeta: true })
|
|
313324
313528
|
]);
|
|
@@ -320064,6 +320268,7 @@ __export(exports_hooks, {
|
|
|
320064
320268
|
executeTaskCreatedHooks: () => executeTaskCreatedHooks,
|
|
320065
320269
|
executeTaskCompletedHooks: () => executeTaskCompletedHooks,
|
|
320066
320270
|
executeSubagentStartHooks: () => executeSubagentStartHooks,
|
|
320271
|
+
executeSubagentProgressHooks: () => executeSubagentProgressHooks,
|
|
320067
320272
|
executeStopHooks: () => executeStopHooks,
|
|
320068
320273
|
executeStopFailureHooks: () => executeStopFailureHooks,
|
|
320069
320274
|
executeStatusLineCommand: () => executeStatusLineCommand,
|
|
@@ -322124,13 +322329,16 @@ async function executeStopFailureHooks(lastMessage, toolUseContext, timeoutMs =
|
|
|
322124
322329
|
matchQuery: error41
|
|
322125
322330
|
});
|
|
322126
322331
|
}
|
|
322127
|
-
async function* executeStopHooks(permissionMode, signal, timeoutMs = TOOL_HOOK_EXECUTION_TIMEOUT_MS, stopHookActive = false, subagentId, toolUseContext, messages, agentType, requestPrompt) {
|
|
322332
|
+
async function* executeStopHooks(permissionMode, signal, timeoutMs = TOOL_HOOK_EXECUTION_TIMEOUT_MS, stopHookActive = false, subagentId, toolUseContext, messages, agentType, requestPrompt, terminal2) {
|
|
322128
322333
|
const hookEvent = subagentId ? "SubagentStop" : "Stop";
|
|
322129
322334
|
const appState = toolUseContext?.getAppState();
|
|
322130
322335
|
const sessionId = toolUseContext?.agentId ?? getSessionId();
|
|
322131
322336
|
if (!hasHookForEvent(hookEvent, appState, sessionId)) {
|
|
322132
322337
|
return;
|
|
322133
322338
|
}
|
|
322339
|
+
if (subagentId) {
|
|
322340
|
+
markSubagentStopFired(subagentId);
|
|
322341
|
+
}
|
|
322134
322342
|
const lastAssistantMessage = messages ? getLastAssistantMessage(messages) : undefined;
|
|
322135
322343
|
const lastAssistantText = lastAssistantMessage ? extractTextContent(lastAssistantMessage.message.content, `
|
|
322136
322344
|
`).trim() || undefined : undefined;
|
|
@@ -322141,7 +322349,8 @@ async function* executeStopHooks(permissionMode, signal, timeoutMs = TOOL_HOOK_E
|
|
|
322141
322349
|
agent_id: subagentId,
|
|
322142
322350
|
agent_transcript_path: getAgentTranscriptPath(subagentId),
|
|
322143
322351
|
agent_type: agentType ?? "",
|
|
322144
|
-
last_assistant_message: lastAssistantText
|
|
322352
|
+
last_assistant_message: lastAssistantText,
|
|
322353
|
+
...terminal2 ? { status: terminal2.status, error_message: terminal2.errorMessage } : {}
|
|
322145
322354
|
} : {
|
|
322146
322355
|
...createBaseHookInput(permissionMode),
|
|
322147
322356
|
hook_event_name: "Stop",
|
|
@@ -322260,12 +322469,14 @@ async function* executeSetupHooks(trigger, signal, timeoutMs = TOOL_HOOK_EXECUTI
|
|
|
322260
322469
|
forceSyncExecution
|
|
322261
322470
|
});
|
|
322262
322471
|
}
|
|
322263
|
-
async function* executeSubagentStartHooks(agentId, agentType, signal, timeoutMs = TOOL_HOOK_EXECUTION_TIMEOUT_MS) {
|
|
322472
|
+
async function* executeSubagentStartHooks(agentId, agentType, signal, timeoutMs = TOOL_HOOK_EXECUTION_TIMEOUT_MS, toolUseId, isBackground) {
|
|
322264
322473
|
const hookInput = {
|
|
322265
322474
|
...createBaseHookInput(undefined),
|
|
322266
322475
|
hook_event_name: "SubagentStart",
|
|
322267
322476
|
agent_id: agentId,
|
|
322268
|
-
agent_type: agentType
|
|
322477
|
+
agent_type: agentType,
|
|
322478
|
+
...toolUseId !== undefined ? { tool_use_id: toolUseId } : {},
|
|
322479
|
+
...isBackground !== undefined ? { is_background: isBackground } : {}
|
|
322269
322480
|
};
|
|
322270
322481
|
yield* executeHooks({
|
|
322271
322482
|
hookInput,
|
|
@@ -322275,6 +322486,24 @@ async function* executeSubagentStartHooks(agentId, agentType, signal, timeoutMs
|
|
|
322275
322486
|
timeoutMs
|
|
322276
322487
|
});
|
|
322277
322488
|
}
|
|
322489
|
+
async function executeSubagentProgressHooks(agentId, agentType, messageId, parentToolUseId, blocks, signal) {
|
|
322490
|
+
const hookInput = {
|
|
322491
|
+
...createBaseHookInput(undefined),
|
|
322492
|
+
hook_event_name: "SubagentProgress",
|
|
322493
|
+
agent_id: agentId,
|
|
322494
|
+
agent_type: agentType,
|
|
322495
|
+
message_id: messageId,
|
|
322496
|
+
...parentToolUseId !== undefined ? { parent_tool_use_id: parentToolUseId } : {},
|
|
322497
|
+
blocks
|
|
322498
|
+
};
|
|
322499
|
+
for await (const _hookResult of executeHooks({
|
|
322500
|
+
hookInput,
|
|
322501
|
+
toolUseID: randomUUID21(),
|
|
322502
|
+
matchQuery: agentType,
|
|
322503
|
+
signal,
|
|
322504
|
+
timeoutMs: TOOL_HOOK_EXECUTION_TIMEOUT_MS
|
|
322505
|
+
})) {}
|
|
322506
|
+
}
|
|
322278
322507
|
async function executePreCompactHooks(compactData, signal, timeoutMs = TOOL_HOOK_EXECUTION_TIMEOUT_MS) {
|
|
322279
322508
|
const hookInput = {
|
|
322280
322509
|
...createBaseHookInput(undefined),
|
|
@@ -322914,6 +323143,7 @@ var init_hooks2 = __esm(() => {
|
|
|
322914
323143
|
init_envUtils();
|
|
322915
323144
|
init_errors2();
|
|
322916
323145
|
init_state2();
|
|
323146
|
+
init_backgroundAbortRegistry();
|
|
322917
323147
|
TOOL_HOOK_EXECUTION_TIMEOUT_MS = 10 * 60 * 1000;
|
|
322918
323148
|
});
|
|
322919
323149
|
|
|
@@ -385519,7 +385749,7 @@ var init_handle2 = __esm(() => {
|
|
|
385519
385749
|
// src/session/messages/systemInit.ts
|
|
385520
385750
|
import { randomUUID as randomUUID22 } from "crypto";
|
|
385521
385751
|
function sdkCompatToolName(name) {
|
|
385522
|
-
return name ===
|
|
385752
|
+
return name === AGENT_TOOL_NAME2 ? LEGACY_AGENT_TOOL_NAME2 : name;
|
|
385523
385753
|
}
|
|
385524
385754
|
function buildSystemInitMessage(inputs) {
|
|
385525
385755
|
const settings = getSettings_DEPRECATED();
|
|
@@ -387188,7 +387418,7 @@ var init_ExitPlanModeV2Tool = __esm(() => {
|
|
|
387188
387418
|
}
|
|
387189
387419
|
};
|
|
387190
387420
|
});
|
|
387191
|
-
const hasTaskTool = isAgentSwarmsEnabled() && context5.options.tools.some((t) => toolMatchesName(t,
|
|
387421
|
+
const hasTaskTool = isAgentSwarmsEnabled() && context5.options.tools.some((t) => toolMatchesName(t, AGENT_TOOL_NAME2));
|
|
387192
387422
|
return {
|
|
387193
387423
|
data: {
|
|
387194
387424
|
plan,
|
|
@@ -427627,9 +427857,9 @@ var init_autoUpdater = __esm(() => {
|
|
|
427627
427857
|
});
|
|
427628
427858
|
|
|
427629
427859
|
// missing-module-stub:/home/runner/work/opencow-agent-sdk/opencow-agent-sdk/src/debug.js
|
|
427630
|
-
var noop22 = () => null,
|
|
427860
|
+
var noop22 = () => null, logForDebugging8;
|
|
427631
427861
|
var init_debug2 = __esm(() => {
|
|
427632
|
-
|
|
427862
|
+
logForDebugging8 = noop22;
|
|
427633
427863
|
});
|
|
427634
427864
|
|
|
427635
427865
|
// missing-module-stub:/home/runner/work/opencow-agent-sdk/opencow-agent-sdk/src/execFileNoThrow.js
|
|
@@ -427651,7 +427881,7 @@ function isDistroFamily(osRelease3, families) {
|
|
|
427651
427881
|
function detectMise() {
|
|
427652
427882
|
const execPath2 = process.execPath || process.argv[0] || "";
|
|
427653
427883
|
if (/[/\\]mise[/\\]installs[/\\]/i.test(execPath2)) {
|
|
427654
|
-
|
|
427884
|
+
logForDebugging8(`Detected mise installation: ${execPath2}`);
|
|
427655
427885
|
return true;
|
|
427656
427886
|
}
|
|
427657
427887
|
return false;
|
|
@@ -427659,7 +427889,7 @@ function detectMise() {
|
|
|
427659
427889
|
function detectAsdf() {
|
|
427660
427890
|
const execPath2 = process.execPath || process.argv[0] || "";
|
|
427661
427891
|
if (/[/\\]\.?asdf[/\\]installs[/\\]/i.test(execPath2)) {
|
|
427662
|
-
|
|
427892
|
+
logForDebugging8(`Detected asdf installation: ${execPath2}`);
|
|
427663
427893
|
return true;
|
|
427664
427894
|
}
|
|
427665
427895
|
return false;
|
|
@@ -427671,7 +427901,7 @@ function detectHomebrew() {
|
|
|
427671
427901
|
}
|
|
427672
427902
|
const execPath2 = process.execPath || process.argv[0] || "";
|
|
427673
427903
|
if (execPath2.includes("/Caskroom/")) {
|
|
427674
|
-
|
|
427904
|
+
logForDebugging8(`Detected Homebrew cask installation: ${execPath2}`);
|
|
427675
427905
|
return true;
|
|
427676
427906
|
}
|
|
427677
427907
|
return false;
|
|
@@ -427688,7 +427918,7 @@ function detectWinget() {
|
|
|
427688
427918
|
];
|
|
427689
427919
|
for (const pattern of wingetPatterns) {
|
|
427690
427920
|
if (pattern.test(execPath2)) {
|
|
427691
|
-
|
|
427921
|
+
logForDebugging8(`Detected winget installation: ${execPath2}`);
|
|
427692
427922
|
return true;
|
|
427693
427923
|
}
|
|
427694
427924
|
}
|
|
@@ -427729,7 +427959,7 @@ var init_packageManagers = __esm(() => {
|
|
|
427729
427959
|
useCwd: false
|
|
427730
427960
|
});
|
|
427731
427961
|
if (result.code === 0 && result.stdout) {
|
|
427732
|
-
|
|
427962
|
+
logForDebugging8(`Detected pacman installation: ${result.stdout.trim()}`);
|
|
427733
427963
|
return true;
|
|
427734
427964
|
}
|
|
427735
427965
|
return false;
|
|
@@ -427749,7 +427979,7 @@ var init_packageManagers = __esm(() => {
|
|
|
427749
427979
|
useCwd: false
|
|
427750
427980
|
});
|
|
427751
427981
|
if (result.code === 0 && result.stdout) {
|
|
427752
|
-
|
|
427982
|
+
logForDebugging8(`Detected deb installation: ${result.stdout.trim()}`);
|
|
427753
427983
|
return true;
|
|
427754
427984
|
}
|
|
427755
427985
|
return false;
|
|
@@ -427769,7 +427999,7 @@ var init_packageManagers = __esm(() => {
|
|
|
427769
427999
|
useCwd: false
|
|
427770
428000
|
});
|
|
427771
428001
|
if (result.code === 0 && result.stdout) {
|
|
427772
|
-
|
|
428002
|
+
logForDebugging8(`Detected rpm installation: ${result.stdout.trim()}`);
|
|
427773
428003
|
return true;
|
|
427774
428004
|
}
|
|
427775
428005
|
return false;
|
|
@@ -427789,7 +428019,7 @@ var init_packageManagers = __esm(() => {
|
|
|
427789
428019
|
useCwd: false
|
|
427790
428020
|
});
|
|
427791
428021
|
if (result.code === 0 && result.stdout) {
|
|
427792
|
-
|
|
428022
|
+
logForDebugging8(`Detected apk installation: ${result.stdout.trim()}`);
|
|
427793
428023
|
return true;
|
|
427794
428024
|
}
|
|
427795
428025
|
return false;
|
|
@@ -444572,7 +444802,7 @@ function UltraplanSessionDetail(t0) {
|
|
|
444572
444802
|
}
|
|
444573
444803
|
calls++;
|
|
444574
444804
|
lastBlock = block2;
|
|
444575
|
-
if (block2.name ===
|
|
444805
|
+
if (block2.name === AGENT_TOOL_NAME || block2.name === LEGACY_AGENT_TOOL_NAME) {
|
|
444576
444806
|
spawns++;
|
|
444577
444807
|
}
|
|
444578
444808
|
}
|
|
@@ -479310,7 +479540,7 @@ function buildPrimarySection() {
|
|
|
479310
479540
|
}, undefined, false, undefined, this);
|
|
479311
479541
|
return [{
|
|
479312
479542
|
label: "Version",
|
|
479313
|
-
value: "0.4.
|
|
479543
|
+
value: "0.4.7"
|
|
479314
479544
|
}, {
|
|
479315
479545
|
label: "Session name",
|
|
479316
479546
|
value: nameValue
|
|
@@ -521599,6 +521829,9 @@ async function stopTask(taskId, context7) {
|
|
|
521599
521829
|
const appState = getAppState();
|
|
521600
521830
|
const task = appState.tasks?.[taskId];
|
|
521601
521831
|
if (!task) {
|
|
521832
|
+
if (abortBackgroundAgentById(taskId)) {
|
|
521833
|
+
return { taskId, taskType: "local_agent", command: undefined };
|
|
521834
|
+
}
|
|
521602
521835
|
throw new StopTaskError(`No task found with ID: ${taskId}`, "not_found");
|
|
521603
521836
|
}
|
|
521604
521837
|
if (task.status !== "running") {
|
|
@@ -521639,6 +521872,7 @@ var StopTaskError;
|
|
|
521639
521872
|
var init_stopTask = __esm(() => {
|
|
521640
521873
|
init_registry4();
|
|
521641
521874
|
init_sdkEventQueue();
|
|
521875
|
+
init_backgroundAbortRegistry();
|
|
521642
521876
|
StopTaskError = class StopTaskError extends Error {
|
|
521643
521877
|
code;
|
|
521644
521878
|
constructor(message, code) {
|
|
@@ -529927,7 +530161,7 @@ function ToolSelector(t0) {
|
|
|
529927
530161
|
if (toolBuckets.EXECUTION.toolNames.has(tool.name)) {
|
|
529928
530162
|
buckets.execution.push(tool);
|
|
529929
530163
|
} else {
|
|
529930
|
-
if (tool.name !==
|
|
530164
|
+
if (tool.name !== AGENT_TOOL_NAME) {
|
|
529931
530165
|
buckets.other.push(tool);
|
|
529932
530166
|
}
|
|
529933
530167
|
}
|
|
@@ -532680,14 +532914,14 @@ When a user describes what they want an agent to do, you will:
|
|
|
532680
532914
|
assistant: "Here is the relevant function: "
|
|
532681
532915
|
<function call omitted for brevity only for this example>
|
|
532682
532916
|
<commentary>
|
|
532683
|
-
Since a significant piece of code was written, use the ${
|
|
532917
|
+
Since a significant piece of code was written, use the ${AGENT_TOOL_NAME} tool to launch the test-runner agent to run the tests.
|
|
532684
532918
|
</commentary>
|
|
532685
532919
|
assistant: "Now let me use the test-runner agent to run the tests"
|
|
532686
532920
|
</example>
|
|
532687
532921
|
- <example>
|
|
532688
532922
|
Context: User is creating an agent to respond to the word "hello" with a friendly jok.
|
|
532689
532923
|
user: "Hello"
|
|
532690
|
-
assistant: "I'm going to use the ${
|
|
532924
|
+
assistant: "I'm going to use the ${AGENT_TOOL_NAME} tool to launch the greeting-responder agent to respond with a friendly joke"
|
|
532691
532925
|
<commentary>
|
|
532692
532926
|
Since the user is greeting, use the greeting-responder agent to respond with a friendly joke.
|
|
532693
532927
|
</commentary>
|
|
@@ -535628,7 +535862,7 @@ var init_bridge_kick = __esm(() => {
|
|
|
535628
535862
|
var call58 = async () => {
|
|
535629
535863
|
return {
|
|
535630
535864
|
type: "text",
|
|
535631
|
-
value: `${"99.0.0"} (built ${"2026-06-
|
|
535865
|
+
value: `${"99.0.0"} (built ${"2026-06-10T13:40:16.658Z"})`
|
|
535632
535866
|
};
|
|
535633
535867
|
}, version2, version_default;
|
|
535634
535868
|
var init_version = __esm(() => {
|
|
@@ -539452,14 +539686,14 @@ var init_statusline = __esm(() => {
|
|
|
539452
539686
|
aliases: [],
|
|
539453
539687
|
name: "statusline",
|
|
539454
539688
|
progressMessage: "setting up statusLine",
|
|
539455
|
-
allowedTools: [
|
|
539689
|
+
allowedTools: [AGENT_TOOL_NAME, "Read(~/**)", "Edit(~/.claude/settings.json)"],
|
|
539456
539690
|
source: "builtin",
|
|
539457
539691
|
disableNonInteractive: true,
|
|
539458
539692
|
async getPromptForCommand(args) {
|
|
539459
539693
|
const prompt = args.trim() || "Configure my statusLine from my shell PS1 configuration";
|
|
539460
539694
|
return [{
|
|
539461
539695
|
type: "text",
|
|
539462
|
-
text: `Create an ${
|
|
539696
|
+
text: `Create an ${AGENT_TOOL_NAME} with subagent_type "statusline-setup" and the prompt "${prompt}"`
|
|
539463
539697
|
}];
|
|
539464
539698
|
}
|
|
539465
539699
|
};
|
|
@@ -542934,7 +543168,7 @@ function extractToolStats(log2) {
|
|
|
542934
543168
|
if (block2.type === "tool_use" && "name" in block2) {
|
|
542935
543169
|
const toolName = block2.name;
|
|
542936
543170
|
toolCounts[toolName] = (toolCounts[toolName] || 0) + 1;
|
|
542937
|
-
if (toolName ===
|
|
543171
|
+
if (toolName === AGENT_TOOL_NAME2 || toolName === LEGACY_AGENT_TOOL_NAME2)
|
|
542938
543172
|
usesTaskAgent = true;
|
|
542939
543173
|
if (toolName.startsWith("mcp__"))
|
|
542940
543174
|
usesMcp = true;
|
|
@@ -548246,7 +548480,7 @@ Task completed. Call TaskList now to find your next available task or see if you
|
|
|
548246
548480
|
if (verificationNudgeNeeded) {
|
|
548247
548481
|
resultContent += `
|
|
548248
548482
|
|
|
548249
|
-
NOTE: You just closed out 3+ tasks and none of them was a verification step. Before writing your final summary, spawn the verification agent (subagent_type="${
|
|
548483
|
+
NOTE: You just closed out 3+ tasks and none of them was a verification step. Before writing your final summary, spawn the verification agent (subagent_type="${VERIFICATION_AGENT_TYPE}"). You cannot self-assign PARTIAL by listing caveats in your summary — only the verifier issues a verdict.`;
|
|
548250
548484
|
}
|
|
548251
548485
|
return {
|
|
548252
548486
|
tool_use_id: toolUseID,
|
|
@@ -557738,7 +557972,7 @@ function WelcomeV2() {
|
|
|
557738
557972
|
dimColor: true,
|
|
557739
557973
|
children: [
|
|
557740
557974
|
"v",
|
|
557741
|
-
"0.4.
|
|
557975
|
+
"0.4.7",
|
|
557742
557976
|
" "
|
|
557743
557977
|
]
|
|
557744
557978
|
}, undefined, true, undefined, this)
|
|
@@ -557938,7 +558172,7 @@ function WelcomeV2() {
|
|
|
557938
558172
|
dimColor: true,
|
|
557939
558173
|
children: [
|
|
557940
558174
|
"v",
|
|
557941
|
-
"0.4.
|
|
558175
|
+
"0.4.7",
|
|
557942
558176
|
" "
|
|
557943
558177
|
]
|
|
557944
558178
|
}, undefined, true, undefined, this)
|
|
@@ -558164,7 +558398,7 @@ function AppleTerminalWelcomeV2(t0) {
|
|
|
558164
558398
|
dimColor: true,
|
|
558165
558399
|
children: [
|
|
558166
558400
|
"v",
|
|
558167
|
-
"0.4.
|
|
558401
|
+
"0.4.7",
|
|
558168
558402
|
" "
|
|
558169
558403
|
]
|
|
558170
558404
|
}, undefined, true, undefined, this);
|
|
@@ -558418,7 +558652,7 @@ function AppleTerminalWelcomeV2(t0) {
|
|
|
558418
558652
|
dimColor: true,
|
|
558419
558653
|
children: [
|
|
558420
558654
|
"v",
|
|
558421
|
-
"0.4.
|
|
558655
|
+
"0.4.7",
|
|
558422
558656
|
" "
|
|
558423
558657
|
]
|
|
558424
558658
|
}, undefined, true, undefined, this);
|
|
@@ -561776,7 +562010,7 @@ Call the \`${ENTER_PLAN_MODE_TOOL_NAME2}\` tool now to enter plan mode, then:
|
|
|
561776
562010
|
|
|
561777
562011
|
## Phase 2: Spawn Workers (After Plan Approval)
|
|
561778
562012
|
|
|
561779
|
-
Once the plan is approved, spawn one background agent per work unit using the \`${
|
|
562013
|
+
Once the plan is approved, spawn one background agent per work unit using the \`${AGENT_TOOL_NAME2}\` tool. **All agents must use \`isolation: "worktree"\` and \`run_in_background: true\`.** Launch them all in a single message block so they run in parallel.
|
|
561780
562014
|
|
|
561781
562015
|
For each agent, the prompt must be fully self-contained. Include:
|
|
561782
562016
|
- The overall goal (the user's instruction)
|
|
@@ -562453,7 +562687,7 @@ Run \`git diff\` (or \`git diff HEAD\` if there are staged changes) to see what
|
|
|
562453
562687
|
|
|
562454
562688
|
## Phase 2: Launch Three Review Agents in Parallel
|
|
562455
562689
|
|
|
562456
|
-
Use the ${
|
|
562690
|
+
Use the ${AGENT_TOOL_NAME2} tool to launch all three agents concurrently in a single message. Pass each agent the full diff so it has the complete context.
|
|
562457
562691
|
|
|
562458
562692
|
### Agent 1: Code Reuse Review
|
|
562459
562693
|
|
|
@@ -569124,7 +569358,8 @@ class QueryEngine {
|
|
|
569124
569358
|
theme: resolveThemeSetting(getGlobalConfig().theme),
|
|
569125
569359
|
maxBudgetUsd,
|
|
569126
569360
|
maxOutputTokens,
|
|
569127
|
-
contextWindow
|
|
569361
|
+
contextWindow,
|
|
569362
|
+
modelProviders: this.config.modelProviders
|
|
569128
569363
|
},
|
|
569129
569364
|
getAppState,
|
|
569130
569365
|
setAppState,
|
|
@@ -569226,7 +569461,8 @@ class QueryEngine {
|
|
|
569226
569461
|
agentDefinitions: { activeAgents: agents2, allAgents: [] },
|
|
569227
569462
|
maxBudgetUsd,
|
|
569228
569463
|
maxOutputTokens,
|
|
569229
|
-
contextWindow
|
|
569464
|
+
contextWindow,
|
|
569465
|
+
modelProviders: this.config.modelProviders
|
|
569230
569466
|
},
|
|
569231
569467
|
getAppState,
|
|
569232
569468
|
setAppState,
|
|
@@ -569721,6 +569957,7 @@ async function* ask({
|
|
|
569721
569957
|
appendSystemPrompt,
|
|
569722
569958
|
userSpecifiedModel,
|
|
569723
569959
|
fallbackModel,
|
|
569960
|
+
modelProviders,
|
|
569724
569961
|
jsonSchema,
|
|
569725
569962
|
getAppState,
|
|
569726
569963
|
setAppState,
|
|
@@ -569748,6 +569985,7 @@ async function* ask({
|
|
|
569748
569985
|
appendSystemPrompt,
|
|
569749
569986
|
userSpecifiedModel,
|
|
569750
569987
|
fallbackModel,
|
|
569988
|
+
modelProviders,
|
|
569751
569989
|
thinkingConfig,
|
|
569752
569990
|
maxTurns,
|
|
569753
569991
|
maxBudgetUsd,
|
|
@@ -579264,7 +579502,7 @@ Usage: claude --remote "your task description"`, () => gracefulShutdown(1));
|
|
|
579264
579502
|
pendingHookMessages
|
|
579265
579503
|
}, renderAndRun);
|
|
579266
579504
|
}
|
|
579267
|
-
}).version("0.4.
|
|
579505
|
+
}).version("0.4.7 (OpenCow)", "-v, --version", "Output the version number");
|
|
579268
579506
|
program2.option("-w, --worktree [name]", "Create a new git worktree for this session (optionally specify a name)");
|
|
579269
579507
|
program2.option("--tmux", "Create a tmux session for the worktree (requires --worktree). Uses iTerm2 native panes when available; use --tmux=classic for traditional tmux.");
|
|
579270
579508
|
if (canUserConfigureAdvisor()) {
|
|
@@ -579910,7 +580148,7 @@ if (false) {}
|
|
|
579910
580148
|
async function main2() {
|
|
579911
580149
|
const args = process.argv.slice(2);
|
|
579912
580150
|
if (args.length === 1 && (args[0] === "--version" || args[0] === "-v" || args[0] === "-V")) {
|
|
579913
|
-
console.log(`${"0.4.
|
|
580151
|
+
console.log(`${"0.4.7"} (OpenCow)`);
|
|
579914
580152
|
return;
|
|
579915
580153
|
}
|
|
579916
580154
|
if (args.includes("--provider")) {
|
|
@@ -580028,4 +580266,4 @@ async function main2() {
|
|
|
580028
580266
|
}
|
|
580029
580267
|
main2();
|
|
580030
580268
|
|
|
580031
|
-
//# debugId=
|
|
580269
|
+
//# debugId=40ABDFB36DE9867464756E2164756E21
|