@opencow-ai/opencow-agent-sdk 0.4.5 → 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/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 AGENT_TOOL_NAME2 = "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";
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: AGENT_TOOL_NAME2,
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,
@@ -84304,7 +84304,8 @@ function sanitizeSchemaForOpenAICompat(schema) {
84304
84304
  }
84305
84305
  }
84306
84306
  if (Array.isArray(record2.required) && isSchemaRecord(record2.properties)) {
84307
- record2.required = record2.required.filter((value) => typeof value === "string" && (value in record2.properties));
84307
+ const properties = record2.properties;
84308
+ record2.required = record2.required.filter((value) => typeof value === "string" && (value in properties));
84308
84309
  }
84309
84310
  const schemaWithoutEnum = { ...record2 };
84310
84311
  delete schemaWithoutEnum.enum;
@@ -84323,6 +84324,77 @@ function sanitizeSchemaForOpenAICompat(schema) {
84323
84324
  }
84324
84325
  return record2;
84325
84326
  }
84327
+ function isEmptyStrictObject(schema) {
84328
+ if (schema.type !== "object" || schema.additionalProperties !== false) {
84329
+ return false;
84330
+ }
84331
+ const props = schema.properties;
84332
+ return !props || isSchemaRecord(props) && Object.keys(props).length === 0;
84333
+ }
84334
+ function strictifySchemaNode(schema, options, topLevel) {
84335
+ const {
84336
+ gemini = false,
84337
+ strict = true,
84338
+ stripUriFormat = false,
84339
+ dropEmptyObjectProperties = false,
84340
+ normalizeBareObjects = false
84341
+ } = options;
84342
+ let record2 = sanitizeSchemaForOpenAICompat(schema);
84343
+ if (gemini) {
84344
+ record2 = splitTypeArrayToAnyOf(record2);
84345
+ }
84346
+ if (stripUriFormat && record2.format === "uri") {
84347
+ delete record2.format;
84348
+ }
84349
+ if (record2.type === "object") {
84350
+ const props = isSchemaRecord(record2.properties) ? record2.properties : null;
84351
+ if (props) {
84352
+ const originalRequired = Array.isArray(record2.required) ? record2.required.filter((key) => typeof key === "string") : [];
84353
+ const enforcedProps = {};
84354
+ for (const [key, value] of Object.entries(props)) {
84355
+ const strictValue = strictifySchemaNode(value, options, false);
84356
+ if (dropEmptyObjectProperties && isEmptyStrictObject(strictValue)) {
84357
+ continue;
84358
+ }
84359
+ enforcedProps[key] = strictValue;
84360
+ }
84361
+ record2.properties = enforcedProps;
84362
+ if (strict) {
84363
+ record2.additionalProperties = false;
84364
+ record2.required = Object.keys(enforcedProps);
84365
+ if (topLevel) {
84366
+ const style = gemini ? "nullable" : "union";
84367
+ for (const key of Object.keys(enforcedProps)) {
84368
+ if (!originalRequired.includes(key)) {
84369
+ enforcedProps[key] = makeSchemaNullable(enforcedProps[key], style);
84370
+ }
84371
+ }
84372
+ }
84373
+ } else {
84374
+ record2.required = originalRequired.filter((key) => (key in enforcedProps));
84375
+ }
84376
+ } else if (normalizeBareObjects) {
84377
+ record2.additionalProperties = false;
84378
+ record2.required = [];
84379
+ }
84380
+ }
84381
+ if ("items" in record2) {
84382
+ if (Array.isArray(record2.items)) {
84383
+ record2.items = record2.items.map((item) => strictifySchemaNode(item, options, false));
84384
+ } else {
84385
+ record2.items = strictifySchemaNode(record2.items, options, false);
84386
+ }
84387
+ }
84388
+ for (const key of ["anyOf", "oneOf", "allOf"]) {
84389
+ if (key in record2 && Array.isArray(record2[key])) {
84390
+ record2[key] = record2[key].map((item) => strictifySchemaNode(item, options, false));
84391
+ }
84392
+ }
84393
+ return record2;
84394
+ }
84395
+ function strictifyJsonSchema(schema, options = {}) {
84396
+ return strictifySchemaNode(schema, options, true);
84397
+ }
84326
84398
  var OPENAI_INCOMPATIBLE_SCHEMA_KEYWORDS;
84327
84399
  var init_schemaSanitizer = __esm(() => {
84328
84400
  OPENAI_INCOMPATIBLE_SCHEMA_KEYWORDS = new Set([
@@ -84351,6 +84423,51 @@ var init_schema = __esm(() => {
84351
84423
  init_schemaSanitizer();
84352
84424
  });
84353
84425
 
84426
+ // src/providers/openai/capabilities.ts
84427
+ function supportsReasoningEffort(model) {
84428
+ return /^(o\d|gpt-5|gpt-4\.5)/i.test(model);
84429
+ }
84430
+ function isGeminiLikeModel(model) {
84431
+ const normalized = (model ?? "").trim().toLowerCase();
84432
+ return normalized.startsWith("gemini-") || normalized.includes("/gemini-");
84433
+ }
84434
+ function isGeminiTarget(model) {
84435
+ if (isEnvTruthy(getQueryEnvVar("CLAUDE_CODE_USE_GEMINI")))
84436
+ return true;
84437
+ return isGeminiLikeModel(model);
84438
+ }
84439
+ function supportsParallelToolCalls(model) {
84440
+ return !isGeminiTarget(model);
84441
+ }
84442
+ function getOpenAICompatMaxOutputTokens(model) {
84443
+ const max = getOpenAIMaxOutputTokens(model);
84444
+ if (max === undefined)
84445
+ return null;
84446
+ return { default: max, upperLimit: max };
84447
+ }
84448
+ function getOpenAICompatContextWindow(model) {
84449
+ return getOpenAIContextWindow(model) ?? null;
84450
+ }
84451
+ function openAICompatSupports(feature, model) {
84452
+ if (feature === "reasoning-effort")
84453
+ return supportsReasoningEffort(model);
84454
+ if (feature === "parallel-tool-calls")
84455
+ return supportsParallelToolCalls(model);
84456
+ return FEATURES_OPENAI_COMPAT.includes(feature);
84457
+ }
84458
+ var FEATURES_OPENAI_COMPAT;
84459
+ var init_capabilities2 = __esm(() => {
84460
+ init_openaiContextWindows();
84461
+ init_envUtils();
84462
+ init_state2();
84463
+ FEATURES_OPENAI_COMPAT = Object.freeze([
84464
+ "streaming",
84465
+ "tool-use",
84466
+ "image-input",
84467
+ "system-message-top-level"
84468
+ ]);
84469
+ });
84470
+
84354
84471
  // src/providers/codex/shim.ts
84355
84472
  function parseSseChunk(chunk) {
84356
84473
  const lines = chunk.split(`
@@ -84593,58 +84710,23 @@ function convertAnthropicMessagesToResponsesInput(messages) {
84593
84710
  }
84594
84711
  return items.filter((item) => item.type !== "message" || item.content.length > 0);
84595
84712
  }
84596
- function enforceStrictSchema(schema, topLevel = true) {
84597
- const record2 = sanitizeSchemaForOpenAICompat(schema);
84598
- if (record2.format === "uri") {
84599
- delete record2.format;
84600
- }
84601
- if (record2.type === "object") {
84602
- record2.additionalProperties = false;
84603
- if (record2.properties && typeof record2.properties === "object" && !Array.isArray(record2.properties)) {
84604
- const props = record2.properties;
84605
- const originalRequired = Array.isArray(record2.required) ? record2.required.filter((key) => typeof key === "string") : [];
84606
- const enforcedProps = {};
84607
- for (const [key, value] of Object.entries(props)) {
84608
- const strictValue = enforceStrictSchema(value, false);
84609
- if (strictValue && typeof strictValue === "object" && strictValue.type === "object" && strictValue.additionalProperties === false && (!strictValue.properties || Object.keys(strictValue.properties).length === 0)) {
84610
- continue;
84611
- }
84612
- enforcedProps[key] = strictValue;
84613
- }
84614
- record2.properties = enforcedProps;
84615
- record2.required = Object.keys(enforcedProps);
84616
- if (topLevel) {
84617
- for (const key of Object.keys(enforcedProps)) {
84618
- if (!originalRequired.includes(key)) {
84619
- enforcedProps[key] = makeSchemaNullable(enforcedProps[key]);
84620
- }
84621
- }
84622
- }
84623
- } else {
84624
- record2.required = [];
84625
- }
84626
- }
84627
- if ("items" in record2) {
84628
- if (Array.isArray(record2.items)) {
84629
- record2.items = record2.items.map((item) => enforceStrictSchema(item, false));
84630
- } else {
84631
- record2.items = enforceStrictSchema(record2.items, false);
84632
- }
84633
- }
84634
- for (const key of ["anyOf", "oneOf", "allOf"]) {
84635
- if (key in record2 && Array.isArray(record2[key])) {
84636
- record2[key] = record2[key].map((item) => enforceStrictSchema(item, false));
84637
- }
84638
- }
84639
- return record2;
84713
+ function toResponsesParameters(schema, geminiTarget) {
84714
+ return strictifyJsonSchema(schema, {
84715
+ strict: true,
84716
+ gemini: geminiTarget,
84717
+ stripUriFormat: true,
84718
+ dropEmptyObjectProperties: true,
84719
+ normalizeBareObjects: true
84720
+ });
84640
84721
  }
84641
- function convertToolsToResponsesTools(tools) {
84722
+ function convertToolsToResponsesTools(tools, model = "") {
84723
+ const geminiTarget = isGeminiTarget(model);
84642
84724
  return tools.flatMap((tool) => {
84643
84725
  if (tool.input_schema && (!tool.type || tool.type === "function")) {
84644
84726
  if (!tool.name || tool.name === "ToolSearchTool")
84645
84727
  return [];
84646
84728
  const rawParameters = tool.input_schema ?? { type: "object", properties: {} };
84647
- const parameters = enforceStrictSchema(rawParameters);
84729
+ const parameters = toResponsesParameters(rawParameters, geminiTarget);
84648
84730
  return [
84649
84731
  {
84650
84732
  type: "function",
@@ -84659,7 +84741,7 @@ function convertToolsToResponsesTools(tools) {
84659
84741
  return [tool];
84660
84742
  }
84661
84743
  if (tool.name && tool.name !== "ToolSearchTool" && (!tool.type || tool.type === "function")) {
84662
- const parameters = enforceStrictSchema({ type: "object", properties: {} });
84744
+ const parameters = toResponsesParameters({ type: "object", properties: {} }, geminiTarget);
84663
84745
  return [
84664
84746
  {
84665
84747
  type: "function",
@@ -84726,10 +84808,10 @@ async function performCodexRequest(options) {
84726
84808
  body.tool_choice = toolChoice;
84727
84809
  }
84728
84810
  if (options.params.tools && options.params.tools.length > 0) {
84729
- const convertedTools = convertToolsToResponsesTools(options.params.tools);
84811
+ const convertedTools = convertToolsToResponsesTools(options.params.tools, options.request.resolvedModel);
84730
84812
  if (convertedTools.length > 0) {
84731
84813
  body.tools = convertedTools;
84732
- body.parallel_tool_calls = true;
84814
+ body.parallel_tool_calls = !isGeminiTarget(options.request.resolvedModel);
84733
84815
  body.tool_choice ??= "auto";
84734
84816
  }
84735
84817
  }
@@ -85099,51 +85181,7 @@ function convertCodexResponseToAnthropicMessage(data, model) {
85099
85181
  var init_shim = __esm(() => {
85100
85182
  init_sdk();
85101
85183
  init_schema();
85102
- });
85103
-
85104
- // src/providers/openai/capabilities.ts
85105
- function supportsReasoningEffort(model) {
85106
- return /^(o\d|gpt-5|gpt-4\.5)/i.test(model);
85107
- }
85108
- function isGeminiLikeModel(model) {
85109
- const normalized = (model ?? "").trim().toLowerCase();
85110
- return normalized.startsWith("gemini-") || normalized.includes("/gemini-");
85111
- }
85112
- function isGeminiTarget(model) {
85113
- if (isEnvTruthy(getQueryEnvVar("CLAUDE_CODE_USE_GEMINI")))
85114
- return true;
85115
- return isGeminiLikeModel(model);
85116
- }
85117
- function supportsParallelToolCalls(model) {
85118
- return !isGeminiTarget(model);
85119
- }
85120
- function getOpenAICompatMaxOutputTokens(model) {
85121
- const max = getOpenAIMaxOutputTokens(model);
85122
- if (max === undefined)
85123
- return null;
85124
- return { default: max, upperLimit: max };
85125
- }
85126
- function getOpenAICompatContextWindow(model) {
85127
- return getOpenAIContextWindow(model) ?? null;
85128
- }
85129
- function openAICompatSupports(feature, model) {
85130
- if (feature === "reasoning-effort")
85131
- return supportsReasoningEffort(model);
85132
- if (feature === "parallel-tool-calls")
85133
- return supportsParallelToolCalls(model);
85134
- return FEATURES_OPENAI_COMPAT.includes(feature);
85135
- }
85136
- var FEATURES_OPENAI_COMPAT;
85137
- var init_capabilities2 = __esm(() => {
85138
- init_openaiContextWindows();
85139
- init_envUtils();
85140
- init_state2();
85141
- FEATURES_OPENAI_COMPAT = Object.freeze([
85142
- "streaming",
85143
- "tool-use",
85144
- "image-input",
85145
- "system-message-top-level"
85146
- ]);
85184
+ init_capabilities2();
85147
85185
  });
85148
85186
 
85149
85187
  // src/providers/openai/shim.ts
@@ -85373,49 +85411,6 @@ function convertMessages(messages, system) {
85373
85411
  }
85374
85412
  return result;
85375
85413
  }
85376
- function normalizeSchemaForOpenAI(schema, strict = true, topLevel = true, geminiTarget = false) {
85377
- let record2 = sanitizeSchemaForOpenAICompat(schema);
85378
- if (geminiTarget) {
85379
- record2 = splitTypeArrayToAnyOf(record2);
85380
- }
85381
- if (record2.type === "object" && record2.properties) {
85382
- const properties = record2.properties;
85383
- const existingRequired = Array.isArray(record2.required) ? record2.required : [];
85384
- const normalizedProps = {};
85385
- for (const [key, value] of Object.entries(properties)) {
85386
- normalizedProps[key] = normalizeSchemaForOpenAI(value, strict, false, geminiTarget);
85387
- }
85388
- record2.properties = normalizedProps;
85389
- if (strict) {
85390
- const allKeys = Object.keys(normalizedProps);
85391
- record2.required = Array.from(new Set([...existingRequired, ...allKeys]));
85392
- record2.additionalProperties = false;
85393
- if (topLevel) {
85394
- const style = geminiTarget ? "nullable" : "union";
85395
- for (const key of allKeys) {
85396
- if (!existingRequired.includes(key)) {
85397
- normalizedProps[key] = makeSchemaNullable(normalizedProps[key], style);
85398
- }
85399
- }
85400
- }
85401
- } else {
85402
- record2.required = existingRequired.filter((k) => (k in normalizedProps));
85403
- }
85404
- }
85405
- if ("items" in record2) {
85406
- if (Array.isArray(record2.items)) {
85407
- record2.items = record2.items.map((item) => normalizeSchemaForOpenAI(item, strict, false, geminiTarget));
85408
- } else {
85409
- record2.items = normalizeSchemaForOpenAI(record2.items, strict, false, geminiTarget);
85410
- }
85411
- }
85412
- for (const key of ["anyOf", "oneOf", "allOf"]) {
85413
- if (key in record2 && Array.isArray(record2[key])) {
85414
- record2[key] = record2[key].map((item) => normalizeSchemaForOpenAI(item, strict, false, geminiTarget));
85415
- }
85416
- }
85417
- return record2;
85418
- }
85419
85414
  function convertTools(tools, model = "") {
85420
85415
  const isGemini = isEnvTruthy(getQueryEnvVar("CLAUDE_CODE_USE_GEMINI"));
85421
85416
  const geminiTarget = isGeminiTarget(model);
@@ -85436,7 +85431,7 @@ function convertTools(tools, model = "") {
85436
85431
  function: {
85437
85432
  name: t.name,
85438
85433
  description: t.description ?? "",
85439
- parameters: normalizeSchemaForOpenAI(schema, !isGemini, true, geminiTarget)
85434
+ parameters: strictifyJsonSchema(schema, { strict: !isGemini, gemini: geminiTarget })
85440
85435
  }
85441
85436
  };
85442
85437
  });
@@ -85875,7 +85870,8 @@ class OpenAIShimMessages {
85875
85870
  const self2 = this;
85876
85871
  let httpResponse;
85877
85872
  const promise2 = (async () => {
85878
- const request = resolveProviderRequest({ model: self2.providerOverride?.model ?? params.model, baseUrl: self2.providerOverride?.baseURL, reasoningEffortOverride: self2.reasoningEffort });
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 });
85879
85875
  const response = await self2._doRequest(request, params, options);
85880
85876
  httpResponse = response;
85881
85877
  if (params.stream) {
@@ -85900,7 +85896,7 @@ class OpenAIShimMessages {
85900
85896
  }
85901
85897
  async _doRequest(request, params, options) {
85902
85898
  if (request.transport === "openai_responses") {
85903
- const credentials = resolveOpenAIResponsesCredentials();
85899
+ const credentials = this.providerOverride?.apiKey ? { apiKey: this.providerOverride.apiKey, source: "env-openai" } : resolveOpenAIResponsesCredentials();
85904
85900
  if (!credentials.apiKey) {
85905
85901
  const safeModel = redactSecretValueForDisplay(request.requestedModel, process.env) ?? "the requested model";
85906
85902
  const codexAuthHint = credentials.authPath ? `, set CODEX_API_KEY, or place a Codex auth.json at ${credentials.authPath}` : " or set CODEX_API_KEY";
@@ -85919,7 +85915,7 @@ class OpenAIShimMessages {
85919
85915
  ...options?.headers ?? {}
85920
85916
  },
85921
85917
  signal: options?.signal,
85922
- providerSpecific: readOpenAIResponsesProviderSpecific()
85918
+ providerSpecific: this.providerOverride?.providerSpecific?.openaiResponses ?? readOpenAIResponsesProviderSpecific()
85923
85919
  });
85924
85920
  }
85925
85921
  return this._doOpenAIRequest(request, params, options);
@@ -86226,7 +86222,6 @@ async function getNormalizedClient({
86226
86222
  }
86227
86223
  };
86228
86224
  if (providerOverride) {
86229
- const { createOpenAIShimClient: createOpenAIShimClient2 } = await Promise.resolve().then(() => (init_shim2(), exports_shim));
86230
86225
  const safeHeaders = {};
86231
86226
  for (const [k, v] of Object.entries(defaultHeaders)) {
86232
86227
  const lower = k.toLowerCase();
@@ -86234,6 +86229,18 @@ async function getNormalizedClient({
86234
86229
  continue;
86235
86230
  safeHeaders[k] = v;
86236
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));
86237
86244
  return createOpenAIShimClient2({
86238
86245
  defaultHeaders: safeHeaders,
86239
86246
  maxRetries,
@@ -86711,6 +86718,13 @@ function resolveProviderFromEnv(envOverride) {
86711
86718
  const model = readEnv2(envOverride, "OPENAI_MODEL")?.trim() ?? "";
86712
86719
  return model && isCodexAlias(model) ? providers.codex() : providers.openai();
86713
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
+ }
86714
86728
  if (envOverride) {
86715
86729
  const hasOAuthToken = Boolean(readEnv2(envOverride, "CLAUDE_CODE_OAUTH_TOKEN"));
86716
86730
  return providers.anthropic({
@@ -94366,7 +94380,7 @@ function printStartupScreen() {
94366
94380
  const sLen = ` ● ${sL} Ready — type /help to begin`.length;
94367
94381
  out.push(boxRow(sRow, W2, sLen));
94368
94382
  out.push(`${rgb(...BORDER)}╚${"═".repeat(W2 - 2)}╝${RESET}`);
94369
- out.push(` ${DIM}${rgb(...DIMCOL)}opencow ${RESET}${rgb(...ACCENT)}v${"0.4.5"}${RESET}`);
94383
+ out.push(` ${DIM}${rgb(...DIMCOL)}opencow ${RESET}${rgb(...ACCENT)}v${"0.4.7"}${RESET}`);
94370
94384
  out.push("");
94371
94385
  process.stdout.write(out.join(`
94372
94386
  `) + `
@@ -97584,7 +97598,7 @@ var init_paths2 = __esm(() => {
97584
97598
  });
97585
97599
 
97586
97600
  // src/capabilities/tools/AgentTool/constants.ts
97587
- var AGENT_TOOL_NAME3 = "Agent", LEGACY_AGENT_TOOL_NAME2 = "Task", VERIFICATION_AGENT_TYPE2 = "verification", ONE_SHOT_BUILTIN_AGENT_TYPES;
97601
+ var AGENT_TOOL_NAME2 = "Agent", LEGACY_AGENT_TOOL_NAME2 = "Task", VERIFICATION_AGENT_TYPE = "verification", ONE_SHOT_BUILTIN_AGENT_TYPES;
97588
97602
  var init_constants4 = __esm(() => {
97589
97603
  ONE_SHOT_BUILTIN_AGENT_TYPES = new Set([
97590
97604
  "Explore",
@@ -97696,7 +97710,7 @@ function getDescription() {
97696
97710
  - Supports full regex syntax (e.g., "log.*Error", "function\\s+\\w+")
97697
97711
  - Filter files with glob parameter (e.g., "*.js", "**/*.tsx") or type parameter (e.g., "js", "py", "rust")
97698
97712
  - Output modes: "content" shows matching lines, "files_with_matches" shows only file paths (default), "count" shows match counts
97699
- - Use ${AGENT_TOOL_NAME3} tool for open-ended searches requiring multiple rounds
97713
+ - Use ${AGENT_TOOL_NAME2} tool for open-ended searches requiring multiple rounds
97700
97714
  - Pattern syntax: Uses ripgrep (not grep) - literal braces need escaping (use \`interface\\{\\}\` to find \`interface{}\` in Go code)
97701
97715
  - Multiline matching: By default patterns match within single lines only. For cross-line patterns like \`struct \\{[\\s\\S]*?field\`, use \`multiline: true\`
97702
97716
  `;
@@ -97733,7 +97747,7 @@ var init_constants5 = __esm(() => {
97733
97747
  GREP_TOOL_NAME2,
97734
97748
  BASH_TOOL_NAME2,
97735
97749
  NOTEBOOK_EDIT_TOOL_NAME2,
97736
- AGENT_TOOL_NAME3
97750
+ AGENT_TOOL_NAME2
97737
97751
  ]);
97738
97752
  });
97739
97753
 
@@ -113829,7 +113843,7 @@ function toComparable(p) {
113829
113843
  return IS_WINDOWS ? posixForm.toLowerCase() : posixForm;
113830
113844
  }
113831
113845
  function detectSessionFileType(filePath) {
113832
- const configDir = getClaudeConfigHomeDir();
113846
+ const configDir = resolveConfigHomeDir();
113833
113847
  const normalized = toComparable(filePath);
113834
113848
  const configDirCmp = toComparable(configDir);
113835
113849
  if (!normalized.startsWith(configDirCmp)) {
@@ -113957,6 +113971,7 @@ var init_memoryFileDetection = __esm(() => {
113957
113971
  init_agentMemory();
113958
113972
  init_state2();
113959
113973
  init_paths();
113974
+ init_envUtils();
113960
113975
  init_windowsPaths();
113961
113976
  IS_WINDOWS = process.platform === "win32";
113962
113977
  });
@@ -145549,7 +145564,7 @@ var init_exploreAgent = __esm(() => {
145549
145564
  agentType: "Explore",
145550
145565
  whenToUse: EXPLORE_WHEN_TO_USE,
145551
145566
  disallowedTools: [
145552
- AGENT_TOOL_NAME2,
145567
+ AGENT_TOOL_NAME,
145553
145568
  EXIT_PLAN_MODE_TOOL_NAME,
145554
145569
  FILE_EDIT_TOOL_NAME,
145555
145570
  FILE_WRITE_TOOL_NAME,
@@ -145655,7 +145670,7 @@ var init_planAgent = __esm(() => {
145655
145670
  agentType: "Plan",
145656
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.",
145657
145672
  disallowedTools: [
145658
- AGENT_TOOL_NAME3,
145673
+ AGENT_TOOL_NAME2,
145659
145674
  EXIT_PLAN_MODE_TOOL_NAME,
145660
145675
  FILE_EDIT_TOOL_NAME,
145661
145676
  FILE_WRITE_TOOL_NAME,
@@ -145943,9 +145958,20 @@ Use the literal string \`VERDICT: \` followed by exactly one of \`PASS\`, \`FAIL
145943
145958
  - **PARTIAL**: what was verified, what could not be and why (missing tool/env), what the implementer should know.`;
145944
145959
  });
145945
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
+
145946
145971
  // src/capabilities/tools/AgentTool/builtInAgents.ts
145947
145972
  var exports_builtInAgents = {};
145948
145973
  __export(exports_builtInAgents, {
145974
+ resolveSdkAgents: () => resolveSdkAgents,
145949
145975
  getBuiltInAgents: () => getBuiltInAgents,
145950
145976
  areExplorePlanAgentsEnabled: () => areExplorePlanAgentsEnabled
145951
145977
  });
@@ -145972,6 +145998,9 @@ function getBuiltInAgents() {
145972
145998
  if (false) {}
145973
145999
  return agents;
145974
146000
  }
146001
+ function resolveSdkAgents(hostAgents) {
146002
+ return mergeAgentsByType(getBuiltInAgents(), hostAgents);
146003
+ }
145975
146004
  var init_builtInAgents = __esm(() => {
145976
146005
  init_state();
145977
146006
  init_envUtils();
@@ -239695,7 +239724,7 @@ var init_tools = __esm(() => {
239695
239724
  TASK_OUTPUT_TOOL_NAME,
239696
239725
  EXIT_PLAN_MODE_V2_TOOL_NAME,
239697
239726
  ENTER_PLAN_MODE_TOOL_NAME,
239698
- ...process.env.USER_TYPE === "ant" ? [] : [AGENT_TOOL_NAME2],
239727
+ ...process.env.USER_TYPE === "ant" ? [] : [AGENT_TOOL_NAME],
239699
239728
  ASK_USER_QUESTION_TOOL_NAME,
239700
239729
  TASK_STOP_TOOL_NAME,
239701
239730
  ...[]
@@ -239729,7 +239758,7 @@ var init_tools = __esm(() => {
239729
239758
  ...[]
239730
239759
  ]);
239731
239760
  COORDINATOR_MODE_ALLOWED_TOOLS = new Set([
239732
- AGENT_TOOL_NAME2,
239761
+ AGENT_TOOL_NAME,
239733
239762
  TASK_STOP_TOOL_NAME,
239734
239763
  SEND_MESSAGE_TOOL_NAME,
239735
239764
  SYNTHETIC_OUTPUT_TOOL_NAME
@@ -244175,7 +244204,7 @@ function getAnthropicEnvMetadata() {
244175
244204
  function getBuildAgeMinutes() {
244176
244205
  if (false)
244177
244206
  ;
244178
- const buildTime = new Date("2026-06-03T12:46:47.435Z").getTime();
244207
+ const buildTime = new Date("2026-06-10T13:40:16.658Z").getTime();
244179
244208
  if (isNaN(buildTime))
244180
244209
  return;
244181
244210
  return Math.floor((Date.now() - buildTime) / 60000);
@@ -247160,6 +247189,34 @@ var init_registerFrontmatterHooks = __esm(() => {
247160
247189
  init_sessionHooks();
247161
247190
  });
247162
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
+
247163
247220
  // src/providers/shared/model/agent.ts
247164
247221
  function getDefaultSubagentModel() {
247165
247222
  return "inherit";
@@ -247242,6 +247299,12 @@ var init_agent = __esm(() => {
247242
247299
  });
247243
247300
 
247244
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
+ }
247245
247308
  function normalize10(key) {
247246
247309
  return key.toLowerCase().replace(/[-_]/g, "");
247247
247310
  }
@@ -247547,6 +247610,12 @@ var init_caching = __esm(() => {
247547
247610
  });
247548
247611
 
247549
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
+ }
247550
247619
  var init_antModels = () => {};
247551
247620
 
247552
247621
  // src/permissions/bashClassifier.ts
@@ -247651,7 +247720,7 @@ function filterToolsForAgent({
247651
247720
  }
247652
247721
  if (isAsync2 && !ASYNC_AGENT_ALLOWED_TOOLS.has(tool.name)) {
247653
247722
  if (isAgentSwarmsEnabled() && isInProcessTeammate()) {
247654
- if (toolMatchesName(tool, AGENT_TOOL_NAME3)) {
247723
+ if (toolMatchesName(tool, AGENT_TOOL_NAME2)) {
247655
247724
  return true;
247656
247725
  }
247657
247726
  if (IN_PROCESS_TEAMMATE_ALLOWED_TOOLS.has(tool.name)) {
@@ -247701,7 +247770,7 @@ function resolveAgentTools(agentDefinition, availableTools, isAsync2 = false, is
247701
247770
  let allowedAgentTypes;
247702
247771
  for (const toolSpec of agentTools) {
247703
247772
  const { toolName, ruleContent } = permissionRuleValueFromString(toolSpec);
247704
- if (toolName === AGENT_TOOL_NAME3) {
247773
+ if (toolName === AGENT_TOOL_NAME2) {
247705
247774
  if (ruleContent) {
247706
247775
  allowedAgentTypes = ruleContent.split(",").map((s) => s.trim());
247707
247776
  }
@@ -247920,6 +247989,8 @@ async function runAsyncAgentLifecycle({
247920
247989
  return;
247921
247990
  }
247922
247991
  const msg = errorMessage(error41);
247992
+ logForDebugging2(`Background agent ${taskId} failed: ${msg}
247993
+ ${error41 instanceof Error ? error41.stack ?? "" : ""}`, { level: "error" });
247923
247994
  failAgentTask(taskId, msg, rootSetAppState);
247924
247995
  const worktreeResult = await getWorktreeResult();
247925
247996
  enqueueAgentNotification({
@@ -248074,6 +248145,49 @@ async function initializeAgentMcpServers(agentDefinition, parentClients) {
248074
248145
  function isRecordableMessage(msg) {
248075
248146
  return msg.type === "assistant" || msg.type === "user" || msg.type === "progress" || msg.type === "system" && "subtype" in msg && msg.subtype === "compact_boundary";
248076
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
+ }
248077
248191
  async function* runAgent({
248078
248192
  agentDefinition,
248079
248193
  promptMessages,
@@ -248096,13 +248210,14 @@ async function* runAgent({
248096
248210
  description,
248097
248211
  transcriptSubdir,
248098
248212
  onQueryProgress,
248213
+ onPartialAssistant,
248099
248214
  agentName
248100
248215
  }) {
248101
248216
  const appState = toolUseContext.getAppState();
248102
248217
  const permissionMode = appState.toolPermissionContext.mode;
248103
248218
  const rootSetAppState = toolUseContext.setAppStateForTasks ?? toolUseContext.setAppState;
248104
248219
  const resolvedAgentModel = getAgentModel(agentDefinition.model, toolUseContext.options.mainLoopModel, model, permissionMode);
248105
- const providerOverride = resolveAgentProvider(agentName, agentDefinition.agentType, getInitialSettings());
248220
+ const providerOverride = resolveAgentProvider(agentName, agentDefinition.agentType, getInitialSettings()) ?? resolveModelProvider(resolvedAgentModel, toolUseContext.options.modelProviders);
248106
248221
  const effectiveModel = providerOverride ? providerOverride.model : resolvedAgentModel;
248107
248222
  const agentId = override?.agentId ? override.agentId : createAgentId();
248108
248223
  if (transcriptSubdir) {
@@ -248173,8 +248288,11 @@ async function* runAgent({
248173
248288
  const additionalWorkingDirectories = Array.from(appState.toolPermissionContext.additionalWorkingDirectories.keys());
248174
248289
  const agentSystemPrompt = override?.systemPrompt ? override.systemPrompt : asSystemPrompt(await getAgentSystemPrompt(agentDefinition, toolUseContext, resolvedAgentModel, additionalWorkingDirectories, resolvedTools));
248175
248290
  const agentAbortController = override?.abortController ? override.abortController : isAsync2 ? new AbortController : toolUseContext.abortController;
248291
+ if (isAsync2) {
248292
+ registerBackgroundAgentAbort(agentId, agentAbortController);
248293
+ }
248176
248294
  const additionalContexts = [];
248177
- 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)) {
248178
248296
  if (hookResult.additionalContexts && hookResult.additionalContexts.length > 0) {
248179
248297
  additionalContexts.push(...hookResult.additionalContexts);
248180
248298
  }
@@ -248239,7 +248357,7 @@ async function* runAgent({
248239
248357
  verbose: toolUseContext.options.verbose,
248240
248358
  mainLoopModel: effectiveModel,
248241
248359
  providerOverride: providerOverride ?? undefined,
248242
- thinkingConfig: useExactTools ? toolUseContext.options.thinkingConfig : { type: "disabled" },
248360
+ thinkingConfig: toolUseContext.options.thinkingConfig,
248243
248361
  mcpClients: mergedMcpClients,
248244
248362
  mcpResources: toolUseContext.options.mcpResources,
248245
248363
  agentDefinitions: toolUseContext.options.agentDefinitions,
@@ -248277,6 +248395,12 @@ async function* runAgent({
248277
248395
  ...description && { description }
248278
248396
  }).catch((_err) => logForDebugging2(`Failed to write agent metadata: ${_err}`));
248279
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;
248280
248404
  try {
248281
248405
  for await (const message of query({
248282
248406
  messages: initialMessages,
@@ -248289,8 +248413,37 @@ async function* runAgent({
248289
248413
  maxTurns: maxTurns ?? agentDefinition.maxTurns
248290
248414
  })) {
248291
248415
  onQueryProgress?.();
248292
- if (message.type === "stream_event" && message.event.type === "message_start" && message.ttftMs != null) {
248293
- toolUseContext.pushApiMetricsEntry?.(message.ttftMs);
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
+ }
248294
248447
  continue;
248295
248448
  }
248296
248449
  if (message.type === "attachment") {
@@ -248315,6 +248468,16 @@ async function* runAgent({
248315
248468
  if (message.type !== "progress") {
248316
248469
  lastRecordedUuid = message.uuid;
248317
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
+ }
248318
248481
  yield message;
248319
248482
  }
248320
248483
  }
@@ -248324,7 +248487,30 @@ async function* runAgent({
248324
248487
  if (isBuiltInAgent(agentDefinition) && agentDefinition.callback) {
248325
248488
  agentDefinition.callback();
248326
248489
  }
248490
+ } catch (err2) {
248491
+ agentRunError = err2;
248492
+ throw err2;
248327
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
+ }
248328
248514
  await mcpCleanup();
248329
248515
  if (agentDefinition.hooks) {
248330
248516
  clearSessionHooks(rootSetAppState, agentId);
@@ -248420,6 +248606,7 @@ var init_runAgent = __esm(() => {
248420
248606
  init_registerFrontmatterHooks();
248421
248607
  init_sessionHooks();
248422
248608
  init_hooks2();
248609
+ init_backgroundAbortRegistry();
248423
248610
  init_messages4();
248424
248611
  init_agent();
248425
248612
  init_settings2();
@@ -248825,7 +249012,7 @@ var init_TodoWriteTool = __esm(() => {
248825
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`;
248826
249013
  const nudge = verificationNudgeNeeded ? `
248827
249014
 
248828
- 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_TYPE2}"). You cannot self-assign PARTIAL by listing caveats in your summary — only the verifier issues a verdict.` : "";
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.` : "";
248829
249016
  return {
248830
249017
  tool_use_id: toolUseID,
248831
249018
  type: "tool_result",
@@ -251574,7 +251761,9 @@ var init_coreSchemas = __esm(() => {
251574
251761
  SubagentStartHookInputSchema = lazySchema(() => BaseHookInputSchema().and(exports_external.object({
251575
251762
  hook_event_name: exports_external.literal("SubagentStart"),
251576
251763
  agent_id: exports_external.string(),
251577
- 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.")
251578
251767
  })));
251579
251768
  SubagentStopHookInputSchema = lazySchema(() => BaseHookInputSchema().and(exports_external.object({
251580
251769
  hook_event_name: exports_external.literal("SubagentStop"),
@@ -251582,7 +251771,9 @@ var init_coreSchemas = __esm(() => {
251582
251771
  agent_id: exports_external.string(),
251583
251772
  agent_transcript_path: exports_external.string(),
251584
251773
  agent_type: exports_external.string(),
251585
- 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.")
251586
251777
  })));
251587
251778
  PreCompactHookInputSchema = lazySchema(() => BaseHookInputSchema().and(exports_external.object({
251588
251779
  hook_event_name: exports_external.literal("PreCompact"),
@@ -264463,7 +264654,7 @@ ${forkEnabled ? "For fresh agents, terse" : "Terse"} command-style prompts produ
264463
264654
  <example>
264464
264655
  user: "What's left on this branch before we can ship?"
264465
264656
  assistant: <thinking>Forking this — it's a survey question. I want the punch list, not the git output in my context.</thinking>
264466
- ${AGENT_TOOL_NAME3}({
264657
+ ${AGENT_TOOL_NAME2}({
264467
264658
  name: "ship-audit",
264468
264659
  description: "Branch ship-readiness audit",
264469
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."
@@ -264490,7 +264681,7 @@ assistant: <thinking>I'll ask the code-reviewer agent — it won't see my analys
264490
264681
  <commentary>
264491
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.
264492
264683
  </commentary>
264493
- ${AGENT_TOOL_NAME3}({
264684
+ ${AGENT_TOOL_NAME2}({
264494
264685
  name: "migration-review",
264495
264686
  description: "Independent migration review",
264496
264687
  subagent_type: "code-reviewer",
@@ -264520,7 +264711,7 @@ function isPrime(n) {
264520
264711
  <commentary>
264521
264712
  Since a significant piece of code was written and the task was completed, now use the test-runner agent to run the tests
264522
264713
  </commentary>
264523
- assistant: Uses the ${AGENT_TOOL_NAME3} tool to launch the test-runner agent
264714
+ assistant: Uses the ${AGENT_TOOL_NAME2} tool to launch the test-runner agent
264524
264715
  </example>
264525
264716
 
264526
264717
  <example>
@@ -264528,7 +264719,7 @@ user: "Hello"
264528
264719
  <commentary>
264529
264720
  Since the user is greeting, use the greeting-responder agent to respond with a friendly joke
264530
264721
  </commentary>
264531
- assistant: "I'm going to use the ${AGENT_TOOL_NAME3} tool to launch the greeting-responder agent"
264722
+ assistant: "I'm going to use the ${AGENT_TOOL_NAME2} tool to launch the greeting-responder agent"
264532
264723
  </example>
264533
264724
  `;
264534
264725
  const listViaAttachment = shouldInjectAgentListInMessages();
@@ -264537,11 +264728,11 @@ ${effectiveAgents.map((agent) => formatAgentLine(agent)).join(`
264537
264728
  `)}`;
264538
264729
  const shared2 = `Launch a new agent to handle complex, multi-step tasks autonomously.
264539
264730
 
264540
- The ${AGENT_TOOL_NAME3} tool launches specialized agents (subprocesses) that autonomously handle complex tasks. Each agent type has specific capabilities and tools available to it.
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.
264541
264732
 
264542
264733
  ${agentListSection}
264543
264734
 
264544
- ${forkEnabled ? `When using the ${AGENT_TOOL_NAME3} 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_NAME3} tool, specify a subagent_type parameter to select which agent type to use. If omitted, the general-purpose agent is used.`}`;
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.`}`;
264545
264736
  if (isCoordinator) {
264546
264737
  return shared2;
264547
264738
  }
@@ -264549,10 +264740,10 @@ ${forkEnabled ? `When using the ${AGENT_TOOL_NAME3} tool, specify a subagent_typ
264549
264740
  const fileSearchHint = embedded ? "`find` via the Bash tool" : `the ${GLOB_TOOL_NAME2} tool`;
264550
264741
  const contentSearchHint = embedded ? "`grep` via the Bash tool" : `the ${GLOB_TOOL_NAME2} tool`;
264551
264742
  const whenNotToUseSection = forkEnabled ? "" : `
264552
- When NOT to use the ${AGENT_TOOL_NAME3} tool:
264553
- - If you want to read a specific file path, use the ${FILE_READ_TOOL_NAME2} tool or ${fileSearchHint} instead of the ${AGENT_TOOL_NAME3} tool, to find the match more quickly
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
264554
264745
  - If you are searching for a specific class definition like "class Foo", use ${contentSearchHint} instead, to find the match more quickly
264555
- - 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_NAME3} tool, to find the match more quickly
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
264556
264747
  - Other tasks that are not related to the agent descriptions above
264557
264748
  `;
264558
264749
  const concurrencyNote = !listViaAttachment && getSubscriptionType() !== "pro" ? `
@@ -264569,7 +264760,7 @@ Usage notes:
264569
264760
  - The agent's outputs should generally be trusted
264570
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"}
264571
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.
264572
- - If the user specifies that they want you to run agents "in parallel", you MUST send a single message with multiple ${AGENT_TOOL_NAME3} 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.
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.
264573
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" ? `
264574
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() ? `
264575
264766
  - The run_in_background, name, team_name, and mode parameters are not available in this context. Only synchronous subagents are supported.` : isTeammate() ? `
@@ -264719,11 +264910,11 @@ var init_AgentTool = __esm(() => {
264719
264910
  }
264720
264911
  }
264721
264912
  const agentsWithMcpRequirementsMet = filterAgentsByMcpRequirements(agents, mcpServersWithTools);
264722
- const filteredAgents = filterDeniedAgents(agentsWithMcpRequirementsMet, toolPermissionContext, AGENT_TOOL_NAME3);
264913
+ const filteredAgents = filterDeniedAgents(agentsWithMcpRequirementsMet, toolPermissionContext, AGENT_TOOL_NAME2);
264723
264914
  const isCoordinator = false;
264724
264915
  return await getPrompt3(filteredAgents, isCoordinator, allowedAgentTypes);
264725
264916
  },
264726
- name: AGENT_TOOL_NAME3,
264917
+ name: AGENT_TOOL_NAME2,
264727
264918
  searchHint: "delegate work to a subagent",
264728
264919
  aliases: [LEGACY_AGENT_TOOL_NAME2],
264729
264920
  maxResultSizeChars: 1e5,
@@ -264803,13 +264994,13 @@ var init_AgentTool = __esm(() => {
264803
264994
  const {
264804
264995
  allowedAgentTypes
264805
264996
  } = toolUseContext.options.agentDefinitions;
264806
- const agents = filterDeniedAgents(allowedAgentTypes ? allAgents.filter((a2) => allowedAgentTypes.includes(a2.agentType)) : allAgents, appState.toolPermissionContext, AGENT_TOOL_NAME3);
264997
+ const agents = filterDeniedAgents(allowedAgentTypes ? allAgents.filter((a2) => allowedAgentTypes.includes(a2.agentType)) : allAgents, appState.toolPermissionContext, AGENT_TOOL_NAME2);
264807
264998
  const found = agents.find((agent) => agent.agentType === effectiveType);
264808
264999
  if (!found) {
264809
265000
  const agentExistsButDenied = allAgents.find((agent) => agent.agentType === effectiveType);
264810
265001
  if (agentExistsButDenied) {
264811
- const denyRule = getDenyRuleForAgent(appState.toolPermissionContext, AGENT_TOOL_NAME3, effectiveType);
264812
- throw new Error(`Agent type '${effectiveType}' has been denied by permission rule '${AGENT_TOOL_NAME3}(${effectiveType})' from ${denyRule?.source ?? "settings"}.`);
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"}.`);
264813
265004
  }
264814
265005
  throw new Error(`Agent type '${effectiveType}' not found. Available agents: ${agents.map((a2) => a2.agentType).join(", ")}`);
264815
265006
  }
@@ -265180,6 +265371,19 @@ ${reasons}`);
265180
265371
  ...runAgentParams.override,
265181
265372
  agentId: syncAgentId
265182
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,
265183
265387
  onCacheSafeParams: summaryTaskId && getSdkAgentProgressSummariesEnabled() ? (params) => {
265184
265388
  const {
265185
265389
  stop
@@ -265362,21 +265566,16 @@ ${reasons}`);
265362
265566
  }
265363
265567
  const normalizedNew = normalizeMessages([message]);
265364
265568
  for (const m of normalizedNew) {
265365
- for (const content of m.message.content) {
265366
- if (content.type !== "tool_use" && content.type !== "tool_result") {
265367
- continue;
265368
- }
265369
- if (onProgress) {
265370
- onProgress({
265371
- toolUseID: `agent_${assistantMessage.message.id}`,
265372
- data: {
265373
- message: m,
265374
- type: "agent_progress",
265375
- prompt: "",
265376
- agentId: syncAgentId
265377
- }
265378
- });
265379
- }
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
+ });
265380
265579
  }
265381
265580
  }
265382
265581
  }
@@ -265524,10 +265723,9 @@ Briefly tell the user what you launched and end your response.`
265524
265723
  if (data.status === "async_launched") {
265525
265724
  const prefix = `Async agent launched successfully.
265526
265725
  agentId: ${data.agentId} (internal ID - do not mention to user. Use SendMessage with to: '${data.agentId}' to continue this agent.)
265527
- The agent is working in the background. You will be notified automatically when it completes.`;
265528
- const instructions = data.canReadOutputFile ? `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.
265529
- output_file: ${data.outputFile}
265530
- 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.`;
265531
265729
  const text = `${prefix}
265532
265730
  ${instructions}`;
265533
265731
  return {
@@ -276172,7 +276370,7 @@ Git Safety Protocol:
276172
276370
 
276173
276371
  Important notes:
276174
276372
  - NEVER run additional commands to read or explore code, besides git bash commands
276175
- - NEVER use the ${TodoWriteTool.name} or ${AGENT_TOOL_NAME3} tools
276373
+ - NEVER use the ${TodoWriteTool.name} or ${AGENT_TOOL_NAME2} tools
276176
276374
  - DO NOT push to the remote repository unless the user explicitly asks you to do so
276177
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.
276178
276376
  - IMPORTANT: Do not use --no-edit with git rebase commands, as the --no-edit flag is not a valid option for git rebase.
@@ -276218,7 +276416,7 @@ EOF
276218
276416
  </example>
276219
276417
 
276220
276418
  Important:
276221
- - DO NOT use the ${TodoWriteTool.name} or ${AGENT_TOOL_NAME3} tools
276419
+ - DO NOT use the ${TodoWriteTool.name} or ${AGENT_TOOL_NAME2} tools
276222
276420
  - Return the PR URL when you're done, so the user can see it
276223
276421
 
276224
276422
  # Other common operations
@@ -300179,7 +300377,7 @@ function getDeferredToolsDeltaAttachment(tools, model, messages, scanContext) {
300179
300377
  function getAgentListingDeltaAttachment(toolUseContext, messages) {
300180
300378
  if (!shouldInjectAgentListInMessages())
300181
300379
  return [];
300182
- if (!toolUseContext.options.tools.some((t) => toolMatchesName2(t, AGENT_TOOL_NAME2))) {
300380
+ if (!toolUseContext.options.tools.some((t) => toolMatchesName2(t, AGENT_TOOL_NAME))) {
300183
300381
  return [];
300184
300382
  }
300185
300383
  const { activeAgents, allowedAgentTypes } = toolUseContext.options.agentDefinitions;
@@ -300190,7 +300388,7 @@ function getAgentListingDeltaAttachment(toolUseContext, messages) {
300190
300388
  mcpServers.add(info.serverName);
300191
300389
  }
300192
300390
  const permissionContext = toolUseContext.getAppState().toolPermissionContext;
300193
- let filtered = filterDeniedAgents(filterAgentsByMcpRequirements(activeAgents, [...mcpServers]), permissionContext, AGENT_TOOL_NAME2);
300391
+ let filtered = filterDeniedAgents(filterAgentsByMcpRequirements(activeAgents, [...mcpServers]), permissionContext, AGENT_TOOL_NAME);
300194
300392
  if (allowedAgentTypes) {
300195
300393
  filtered = filtered.filter((a2) => allowedAgentTypes.includes(a2.agentType));
300196
300394
  }
@@ -305859,7 +306057,7 @@ function getAntModelOverrideSection() {
305859
306057
  return null;
305860
306058
  if (isUndercover())
305861
306059
  return null;
305862
- return getAntModelOverrideConfig()?.defaultSystemPromptSuffix || null;
306060
+ return getAntModelOverrideConfig2()?.defaultSystemPromptSuffix || null;
305863
306061
  }
305864
306062
  function getLanguageSection(languagePreference) {
305865
306063
  if (!languagePreference)
@@ -306278,6 +306476,7 @@ var init_prompts2 = __esm(() => {
306278
306476
  init_debug();
306279
306477
  init_memdir();
306280
306478
  init_mcpInstructionsDelta();
306479
+ init_antModels();
306281
306480
  init_state2();
306282
306481
  CLAUDE_4_5_OR_4_6_MODEL_IDS = {
306283
306482
  opus: "claude-opus-4-6",
@@ -306703,7 +306902,7 @@ var init_api3 = __esm(() => {
306703
306902
  init_zodToJsonSchema2();
306704
306903
  SWARM_FIELDS_BY_TOOL = {
306705
306904
  [EXIT_PLAN_MODE_V2_TOOL_NAME]: ["launchSwarm", "teammateCount"],
306706
- [AGENT_TOOL_NAME2]: ["name", "team_name", "mode"]
306905
+ [AGENT_TOOL_NAME]: ["name", "team_name", "mode"]
306707
306906
  };
306708
306907
  });
306709
306908
 
@@ -309632,7 +309831,7 @@ function isDangerousPowerShellPermission(toolName, ruleContent) {
309632
309831
  return false;
309633
309832
  }
309634
309833
  function isDangerousTaskPermission(toolName, _ruleContent) {
309635
- return normalizeLegacyToolName(toolName) === AGENT_TOOL_NAME2;
309834
+ return normalizeLegacyToolName(toolName) === AGENT_TOOL_NAME;
309636
309835
  }
309637
309836
  function formatPermissionSource(source) {
309638
309837
  if (SETTING_SOURCES.includes(source)) {
@@ -313323,7 +313522,7 @@ ${attachment.removedNames.join(`
313323
313522
  }
313324
313523
  case "verify_plan_reminder": {
313325
313524
  const toolName = resolveEnvVar("VERIFY_PLAN") === "true" ? "VerifyPlanExecution" : "";
313326
- const content = `You have completed implementing the plan. Please call the "${toolName}" tool directly (NOT the ${AGENT_TOOL_NAME2} tool or an agent) to verify that all plan items were completed correctly.`;
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.`;
313327
313526
  return wrapMessagesInSystemReminder([
313328
313527
  createUserMessage({ content, isMeta: true })
313329
313528
  ]);
@@ -320069,6 +320268,7 @@ __export(exports_hooks, {
320069
320268
  executeTaskCreatedHooks: () => executeTaskCreatedHooks,
320070
320269
  executeTaskCompletedHooks: () => executeTaskCompletedHooks,
320071
320270
  executeSubagentStartHooks: () => executeSubagentStartHooks,
320271
+ executeSubagentProgressHooks: () => executeSubagentProgressHooks,
320072
320272
  executeStopHooks: () => executeStopHooks,
320073
320273
  executeStopFailureHooks: () => executeStopFailureHooks,
320074
320274
  executeStatusLineCommand: () => executeStatusLineCommand,
@@ -322129,13 +322329,16 @@ async function executeStopFailureHooks(lastMessage, toolUseContext, timeoutMs =
322129
322329
  matchQuery: error41
322130
322330
  });
322131
322331
  }
322132
- 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) {
322133
322333
  const hookEvent = subagentId ? "SubagentStop" : "Stop";
322134
322334
  const appState = toolUseContext?.getAppState();
322135
322335
  const sessionId = toolUseContext?.agentId ?? getSessionId();
322136
322336
  if (!hasHookForEvent(hookEvent, appState, sessionId)) {
322137
322337
  return;
322138
322338
  }
322339
+ if (subagentId) {
322340
+ markSubagentStopFired(subagentId);
322341
+ }
322139
322342
  const lastAssistantMessage = messages ? getLastAssistantMessage(messages) : undefined;
322140
322343
  const lastAssistantText = lastAssistantMessage ? extractTextContent(lastAssistantMessage.message.content, `
322141
322344
  `).trim() || undefined : undefined;
@@ -322146,7 +322349,8 @@ async function* executeStopHooks(permissionMode, signal, timeoutMs = TOOL_HOOK_E
322146
322349
  agent_id: subagentId,
322147
322350
  agent_transcript_path: getAgentTranscriptPath(subagentId),
322148
322351
  agent_type: agentType ?? "",
322149
- last_assistant_message: lastAssistantText
322352
+ last_assistant_message: lastAssistantText,
322353
+ ...terminal2 ? { status: terminal2.status, error_message: terminal2.errorMessage } : {}
322150
322354
  } : {
322151
322355
  ...createBaseHookInput(permissionMode),
322152
322356
  hook_event_name: "Stop",
@@ -322265,12 +322469,14 @@ async function* executeSetupHooks(trigger, signal, timeoutMs = TOOL_HOOK_EXECUTI
322265
322469
  forceSyncExecution
322266
322470
  });
322267
322471
  }
322268
- 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) {
322269
322473
  const hookInput = {
322270
322474
  ...createBaseHookInput(undefined),
322271
322475
  hook_event_name: "SubagentStart",
322272
322476
  agent_id: agentId,
322273
- agent_type: agentType
322477
+ agent_type: agentType,
322478
+ ...toolUseId !== undefined ? { tool_use_id: toolUseId } : {},
322479
+ ...isBackground !== undefined ? { is_background: isBackground } : {}
322274
322480
  };
322275
322481
  yield* executeHooks({
322276
322482
  hookInput,
@@ -322280,6 +322486,24 @@ async function* executeSubagentStartHooks(agentId, agentType, signal, timeoutMs
322280
322486
  timeoutMs
322281
322487
  });
322282
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
+ }
322283
322507
  async function executePreCompactHooks(compactData, signal, timeoutMs = TOOL_HOOK_EXECUTION_TIMEOUT_MS) {
322284
322508
  const hookInput = {
322285
322509
  ...createBaseHookInput(undefined),
@@ -322919,6 +323143,7 @@ var init_hooks2 = __esm(() => {
322919
323143
  init_envUtils();
322920
323144
  init_errors2();
322921
323145
  init_state2();
323146
+ init_backgroundAbortRegistry();
322922
323147
  TOOL_HOOK_EXECUTION_TIMEOUT_MS = 10 * 60 * 1000;
322923
323148
  });
322924
323149
 
@@ -385524,7 +385749,7 @@ var init_handle2 = __esm(() => {
385524
385749
  // src/session/messages/systemInit.ts
385525
385750
  import { randomUUID as randomUUID22 } from "crypto";
385526
385751
  function sdkCompatToolName(name) {
385527
- return name === AGENT_TOOL_NAME3 ? LEGACY_AGENT_TOOL_NAME2 : name;
385752
+ return name === AGENT_TOOL_NAME2 ? LEGACY_AGENT_TOOL_NAME2 : name;
385528
385753
  }
385529
385754
  function buildSystemInitMessage(inputs) {
385530
385755
  const settings = getSettings_DEPRECATED();
@@ -387193,7 +387418,7 @@ var init_ExitPlanModeV2Tool = __esm(() => {
387193
387418
  }
387194
387419
  };
387195
387420
  });
387196
- const hasTaskTool = isAgentSwarmsEnabled() && context5.options.tools.some((t) => toolMatchesName(t, AGENT_TOOL_NAME3));
387421
+ const hasTaskTool = isAgentSwarmsEnabled() && context5.options.tools.some((t) => toolMatchesName(t, AGENT_TOOL_NAME2));
387197
387422
  return {
387198
387423
  data: {
387199
387424
  plan,
@@ -427632,9 +427857,9 @@ var init_autoUpdater = __esm(() => {
427632
427857
  });
427633
427858
 
427634
427859
  // missing-module-stub:/home/runner/work/opencow-agent-sdk/opencow-agent-sdk/src/debug.js
427635
- var noop22 = () => null, logForDebugging9;
427860
+ var noop22 = () => null, logForDebugging8;
427636
427861
  var init_debug2 = __esm(() => {
427637
- logForDebugging9 = noop22;
427862
+ logForDebugging8 = noop22;
427638
427863
  });
427639
427864
 
427640
427865
  // missing-module-stub:/home/runner/work/opencow-agent-sdk/opencow-agent-sdk/src/execFileNoThrow.js
@@ -427656,7 +427881,7 @@ function isDistroFamily(osRelease3, families) {
427656
427881
  function detectMise() {
427657
427882
  const execPath2 = process.execPath || process.argv[0] || "";
427658
427883
  if (/[/\\]mise[/\\]installs[/\\]/i.test(execPath2)) {
427659
- logForDebugging9(`Detected mise installation: ${execPath2}`);
427884
+ logForDebugging8(`Detected mise installation: ${execPath2}`);
427660
427885
  return true;
427661
427886
  }
427662
427887
  return false;
@@ -427664,7 +427889,7 @@ function detectMise() {
427664
427889
  function detectAsdf() {
427665
427890
  const execPath2 = process.execPath || process.argv[0] || "";
427666
427891
  if (/[/\\]\.?asdf[/\\]installs[/\\]/i.test(execPath2)) {
427667
- logForDebugging9(`Detected asdf installation: ${execPath2}`);
427892
+ logForDebugging8(`Detected asdf installation: ${execPath2}`);
427668
427893
  return true;
427669
427894
  }
427670
427895
  return false;
@@ -427676,7 +427901,7 @@ function detectHomebrew() {
427676
427901
  }
427677
427902
  const execPath2 = process.execPath || process.argv[0] || "";
427678
427903
  if (execPath2.includes("/Caskroom/")) {
427679
- logForDebugging9(`Detected Homebrew cask installation: ${execPath2}`);
427904
+ logForDebugging8(`Detected Homebrew cask installation: ${execPath2}`);
427680
427905
  return true;
427681
427906
  }
427682
427907
  return false;
@@ -427693,7 +427918,7 @@ function detectWinget() {
427693
427918
  ];
427694
427919
  for (const pattern of wingetPatterns) {
427695
427920
  if (pattern.test(execPath2)) {
427696
- logForDebugging9(`Detected winget installation: ${execPath2}`);
427921
+ logForDebugging8(`Detected winget installation: ${execPath2}`);
427697
427922
  return true;
427698
427923
  }
427699
427924
  }
@@ -427734,7 +427959,7 @@ var init_packageManagers = __esm(() => {
427734
427959
  useCwd: false
427735
427960
  });
427736
427961
  if (result.code === 0 && result.stdout) {
427737
- logForDebugging9(`Detected pacman installation: ${result.stdout.trim()}`);
427962
+ logForDebugging8(`Detected pacman installation: ${result.stdout.trim()}`);
427738
427963
  return true;
427739
427964
  }
427740
427965
  return false;
@@ -427754,7 +427979,7 @@ var init_packageManagers = __esm(() => {
427754
427979
  useCwd: false
427755
427980
  });
427756
427981
  if (result.code === 0 && result.stdout) {
427757
- logForDebugging9(`Detected deb installation: ${result.stdout.trim()}`);
427982
+ logForDebugging8(`Detected deb installation: ${result.stdout.trim()}`);
427758
427983
  return true;
427759
427984
  }
427760
427985
  return false;
@@ -427774,7 +427999,7 @@ var init_packageManagers = __esm(() => {
427774
427999
  useCwd: false
427775
428000
  });
427776
428001
  if (result.code === 0 && result.stdout) {
427777
- logForDebugging9(`Detected rpm installation: ${result.stdout.trim()}`);
428002
+ logForDebugging8(`Detected rpm installation: ${result.stdout.trim()}`);
427778
428003
  return true;
427779
428004
  }
427780
428005
  return false;
@@ -427794,7 +428019,7 @@ var init_packageManagers = __esm(() => {
427794
428019
  useCwd: false
427795
428020
  });
427796
428021
  if (result.code === 0 && result.stdout) {
427797
- logForDebugging9(`Detected apk installation: ${result.stdout.trim()}`);
428022
+ logForDebugging8(`Detected apk installation: ${result.stdout.trim()}`);
427798
428023
  return true;
427799
428024
  }
427800
428025
  return false;
@@ -444577,7 +444802,7 @@ function UltraplanSessionDetail(t0) {
444577
444802
  }
444578
444803
  calls++;
444579
444804
  lastBlock = block2;
444580
- if (block2.name === AGENT_TOOL_NAME2 || block2.name === LEGACY_AGENT_TOOL_NAME) {
444805
+ if (block2.name === AGENT_TOOL_NAME || block2.name === LEGACY_AGENT_TOOL_NAME) {
444581
444806
  spawns++;
444582
444807
  }
444583
444808
  }
@@ -479315,7 +479540,7 @@ function buildPrimarySection() {
479315
479540
  }, undefined, false, undefined, this);
479316
479541
  return [{
479317
479542
  label: "Version",
479318
- value: "0.4.5"
479543
+ value: "0.4.7"
479319
479544
  }, {
479320
479545
  label: "Session name",
479321
479546
  value: nameValue
@@ -521604,6 +521829,9 @@ async function stopTask(taskId, context7) {
521604
521829
  const appState = getAppState();
521605
521830
  const task = appState.tasks?.[taskId];
521606
521831
  if (!task) {
521832
+ if (abortBackgroundAgentById(taskId)) {
521833
+ return { taskId, taskType: "local_agent", command: undefined };
521834
+ }
521607
521835
  throw new StopTaskError(`No task found with ID: ${taskId}`, "not_found");
521608
521836
  }
521609
521837
  if (task.status !== "running") {
@@ -521644,6 +521872,7 @@ var StopTaskError;
521644
521872
  var init_stopTask = __esm(() => {
521645
521873
  init_registry4();
521646
521874
  init_sdkEventQueue();
521875
+ init_backgroundAbortRegistry();
521647
521876
  StopTaskError = class StopTaskError extends Error {
521648
521877
  code;
521649
521878
  constructor(message, code) {
@@ -529932,7 +530161,7 @@ function ToolSelector(t0) {
529932
530161
  if (toolBuckets.EXECUTION.toolNames.has(tool.name)) {
529933
530162
  buckets.execution.push(tool);
529934
530163
  } else {
529935
- if (tool.name !== AGENT_TOOL_NAME2) {
530164
+ if (tool.name !== AGENT_TOOL_NAME) {
529936
530165
  buckets.other.push(tool);
529937
530166
  }
529938
530167
  }
@@ -532685,14 +532914,14 @@ When a user describes what they want an agent to do, you will:
532685
532914
  assistant: "Here is the relevant function: "
532686
532915
  <function call omitted for brevity only for this example>
532687
532916
  <commentary>
532688
- Since a significant piece of code was written, use the ${AGENT_TOOL_NAME2} tool to launch the test-runner agent to run the tests.
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.
532689
532918
  </commentary>
532690
532919
  assistant: "Now let me use the test-runner agent to run the tests"
532691
532920
  </example>
532692
532921
  - <example>
532693
532922
  Context: User is creating an agent to respond to the word "hello" with a friendly jok.
532694
532923
  user: "Hello"
532695
- assistant: "I'm going to use the ${AGENT_TOOL_NAME2} tool to launch the greeting-responder agent to respond with a friendly joke"
532924
+ assistant: "I'm going to use the ${AGENT_TOOL_NAME} tool to launch the greeting-responder agent to respond with a friendly joke"
532696
532925
  <commentary>
532697
532926
  Since the user is greeting, use the greeting-responder agent to respond with a friendly joke.
532698
532927
  </commentary>
@@ -535633,7 +535862,7 @@ var init_bridge_kick = __esm(() => {
535633
535862
  var call58 = async () => {
535634
535863
  return {
535635
535864
  type: "text",
535636
- value: `${"99.0.0"} (built ${"2026-06-03T12:46:47.435Z"})`
535865
+ value: `${"99.0.0"} (built ${"2026-06-10T13:40:16.658Z"})`
535637
535866
  };
535638
535867
  }, version2, version_default;
535639
535868
  var init_version = __esm(() => {
@@ -539457,14 +539686,14 @@ var init_statusline = __esm(() => {
539457
539686
  aliases: [],
539458
539687
  name: "statusline",
539459
539688
  progressMessage: "setting up statusLine",
539460
- allowedTools: [AGENT_TOOL_NAME2, "Read(~/**)", "Edit(~/.claude/settings.json)"],
539689
+ allowedTools: [AGENT_TOOL_NAME, "Read(~/**)", "Edit(~/.claude/settings.json)"],
539461
539690
  source: "builtin",
539462
539691
  disableNonInteractive: true,
539463
539692
  async getPromptForCommand(args) {
539464
539693
  const prompt = args.trim() || "Configure my statusLine from my shell PS1 configuration";
539465
539694
  return [{
539466
539695
  type: "text",
539467
- text: `Create an ${AGENT_TOOL_NAME2} with subagent_type "statusline-setup" and the prompt "${prompt}"`
539696
+ text: `Create an ${AGENT_TOOL_NAME} with subagent_type "statusline-setup" and the prompt "${prompt}"`
539468
539697
  }];
539469
539698
  }
539470
539699
  };
@@ -542939,7 +543168,7 @@ function extractToolStats(log2) {
542939
543168
  if (block2.type === "tool_use" && "name" in block2) {
542940
543169
  const toolName = block2.name;
542941
543170
  toolCounts[toolName] = (toolCounts[toolName] || 0) + 1;
542942
- if (toolName === AGENT_TOOL_NAME3 || toolName === LEGACY_AGENT_TOOL_NAME2)
543171
+ if (toolName === AGENT_TOOL_NAME2 || toolName === LEGACY_AGENT_TOOL_NAME2)
542943
543172
  usesTaskAgent = true;
542944
543173
  if (toolName.startsWith("mcp__"))
542945
543174
  usesMcp = true;
@@ -548251,7 +548480,7 @@ Task completed. Call TaskList now to find your next available task or see if you
548251
548480
  if (verificationNudgeNeeded) {
548252
548481
  resultContent += `
548253
548482
 
548254
- 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_TYPE2}"). You cannot self-assign PARTIAL by listing caveats in your summary — only the verifier issues a verdict.`;
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.`;
548255
548484
  }
548256
548485
  return {
548257
548486
  tool_use_id: toolUseID,
@@ -557743,7 +557972,7 @@ function WelcomeV2() {
557743
557972
  dimColor: true,
557744
557973
  children: [
557745
557974
  "v",
557746
- "0.4.5",
557975
+ "0.4.7",
557747
557976
  " "
557748
557977
  ]
557749
557978
  }, undefined, true, undefined, this)
@@ -557943,7 +558172,7 @@ function WelcomeV2() {
557943
558172
  dimColor: true,
557944
558173
  children: [
557945
558174
  "v",
557946
- "0.4.5",
558175
+ "0.4.7",
557947
558176
  " "
557948
558177
  ]
557949
558178
  }, undefined, true, undefined, this)
@@ -558169,7 +558398,7 @@ function AppleTerminalWelcomeV2(t0) {
558169
558398
  dimColor: true,
558170
558399
  children: [
558171
558400
  "v",
558172
- "0.4.5",
558401
+ "0.4.7",
558173
558402
  " "
558174
558403
  ]
558175
558404
  }, undefined, true, undefined, this);
@@ -558423,7 +558652,7 @@ function AppleTerminalWelcomeV2(t0) {
558423
558652
  dimColor: true,
558424
558653
  children: [
558425
558654
  "v",
558426
- "0.4.5",
558655
+ "0.4.7",
558427
558656
  " "
558428
558657
  ]
558429
558658
  }, undefined, true, undefined, this);
@@ -561781,7 +562010,7 @@ Call the \`${ENTER_PLAN_MODE_TOOL_NAME2}\` tool now to enter plan mode, then:
561781
562010
 
561782
562011
  ## Phase 2: Spawn Workers (After Plan Approval)
561783
562012
 
561784
- Once the plan is approved, spawn one background agent per work unit using the \`${AGENT_TOOL_NAME3}\` 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.
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.
561785
562014
 
561786
562015
  For each agent, the prompt must be fully self-contained. Include:
561787
562016
  - The overall goal (the user's instruction)
@@ -562458,7 +562687,7 @@ Run \`git diff\` (or \`git diff HEAD\` if there are staged changes) to see what
562458
562687
 
562459
562688
  ## Phase 2: Launch Three Review Agents in Parallel
562460
562689
 
562461
- Use the ${AGENT_TOOL_NAME3} tool to launch all three agents concurrently in a single message. Pass each agent the full diff so it has the complete context.
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.
562462
562691
 
562463
562692
  ### Agent 1: Code Reuse Review
562464
562693
 
@@ -569129,7 +569358,8 @@ class QueryEngine {
569129
569358
  theme: resolveThemeSetting(getGlobalConfig().theme),
569130
569359
  maxBudgetUsd,
569131
569360
  maxOutputTokens,
569132
- contextWindow
569361
+ contextWindow,
569362
+ modelProviders: this.config.modelProviders
569133
569363
  },
569134
569364
  getAppState,
569135
569365
  setAppState,
@@ -569231,7 +569461,8 @@ class QueryEngine {
569231
569461
  agentDefinitions: { activeAgents: agents2, allAgents: [] },
569232
569462
  maxBudgetUsd,
569233
569463
  maxOutputTokens,
569234
- contextWindow
569464
+ contextWindow,
569465
+ modelProviders: this.config.modelProviders
569235
569466
  },
569236
569467
  getAppState,
569237
569468
  setAppState,
@@ -569726,6 +569957,7 @@ async function* ask({
569726
569957
  appendSystemPrompt,
569727
569958
  userSpecifiedModel,
569728
569959
  fallbackModel,
569960
+ modelProviders,
569729
569961
  jsonSchema,
569730
569962
  getAppState,
569731
569963
  setAppState,
@@ -569753,6 +569985,7 @@ async function* ask({
569753
569985
  appendSystemPrompt,
569754
569986
  userSpecifiedModel,
569755
569987
  fallbackModel,
569988
+ modelProviders,
569756
569989
  thinkingConfig,
569757
569990
  maxTurns,
569758
569991
  maxBudgetUsd,
@@ -579269,7 +579502,7 @@ Usage: claude --remote "your task description"`, () => gracefulShutdown(1));
579269
579502
  pendingHookMessages
579270
579503
  }, renderAndRun);
579271
579504
  }
579272
- }).version("0.4.5 (OpenCow)", "-v, --version", "Output the version number");
579505
+ }).version("0.4.7 (OpenCow)", "-v, --version", "Output the version number");
579273
579506
  program2.option("-w, --worktree [name]", "Create a new git worktree for this session (optionally specify a name)");
579274
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.");
579275
579508
  if (canUserConfigureAdvisor()) {
@@ -579915,7 +580148,7 @@ if (false) {}
579915
580148
  async function main2() {
579916
580149
  const args = process.argv.slice(2);
579917
580150
  if (args.length === 1 && (args[0] === "--version" || args[0] === "-v" || args[0] === "-V")) {
579918
- console.log(`${"0.4.5"} (OpenCow)`);
580151
+ console.log(`${"0.4.7"} (OpenCow)`);
579919
580152
  return;
579920
580153
  }
579921
580154
  if (args.includes("--provider")) {
@@ -580033,4 +580266,4 @@ async function main2() {
580033
580266
  }
580034
580267
  main2();
580035
580268
 
580036
- //# debugId=A32EDDBB8A04BA5B64756E2164756E21
580269
+ //# debugId=40ABDFB36DE9867464756E2164756E21