claude-code-rust 0.14.3 → 0.14.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -17,7 +17,9 @@ function nonNegativeNumberField(record, ...keys) {
17
17
  }
18
18
  export function nonNegativeIntegerField(record, ...keys) {
19
19
  const value = numberField(record, ...keys);
20
- return value !== undefined && value >= 0 && Number.isInteger(value) ? value : undefined;
20
+ return value !== undefined && value >= 0 && Number.isInteger(value)
21
+ ? value
22
+ : undefined;
21
23
  }
22
24
  export function buildSubagentRetryUpdate(message) {
23
25
  const retry = asRecordOrNull(message.subagent_retry);
@@ -27,7 +29,9 @@ export function buildSubagentRetryUpdate(message) {
27
29
  const attempt = nonNegativeIntegerField(retry, "attempt");
28
30
  const maxRetries = nonNegativeIntegerField(retry, "max_retries", "maxRetries");
29
31
  const retryDelayMs = nonNegativeIntegerField(retry, "retry_delay_ms", "retryDelayMs");
30
- if (attempt === undefined || maxRetries === undefined || retryDelayMs === undefined) {
32
+ if (attempt === undefined ||
33
+ maxRetries === undefined ||
34
+ retryDelayMs === undefined) {
31
35
  return null;
32
36
  }
33
37
  const agentId = typeof retry.agent_id === "string" ? retry.agent_id.trim() : "";
@@ -57,7 +61,9 @@ export function parseFastModeDisabledReason(value) {
57
61
  return reason.length > 0 ? reason : undefined;
58
62
  }
59
63
  export function parseRateLimitStatus(value) {
60
- if (value === "allowed" || value === "allowed_warning" || value === "rejected") {
64
+ if (value === "allowed" ||
65
+ value === "allowed_warning" ||
66
+ value === "rejected") {
61
67
  return value;
62
68
  }
63
69
  return null;
@@ -119,7 +125,8 @@ export function buildRateLimitUpdate(rateLimitInfo) {
119
125
  if (overageResetsAt !== undefined) {
120
126
  update.overage_resets_at = overageResetsAt;
121
127
  }
122
- if (typeof info.overageDisabledReason === "string" && info.overageDisabledReason.length > 0) {
128
+ if (typeof info.overageDisabledReason === "string" &&
129
+ info.overageDisabledReason.length > 0) {
123
130
  update.overage_disabled_reason = info.overageDisabledReason;
124
131
  }
125
132
  if (typeof info.overageInUse === "boolean") {
@@ -136,7 +143,8 @@ export function buildRateLimitUpdate(rateLimitInfo) {
136
143
  update.can_user_purchase_credits = info.canUserPurchaseCredits;
137
144
  }
138
145
  if (typeof info.hasChargeableSavedPaymentMethod === "boolean") {
139
- update.has_chargeable_saved_payment_method = info.hasChargeableSavedPaymentMethod;
146
+ update.has_chargeable_saved_payment_method =
147
+ info.hasChargeableSavedPaymentMethod;
140
148
  }
141
149
  return update;
142
150
  }
@@ -144,11 +152,15 @@ export function buildApiRetryUpdate(message) {
144
152
  const attempt = numberField(message, "attempt");
145
153
  const maxRetries = numberField(message, "max_retries", "maxRetries");
146
154
  const retryDelayMs = nonNegativeNumberField(message, "retry_delay_ms", "retryDelayMs");
147
- if (attempt === undefined || maxRetries === undefined || retryDelayMs === undefined) {
155
+ if (attempt === undefined ||
156
+ maxRetries === undefined ||
157
+ retryDelayMs === undefined) {
148
158
  return null;
149
159
  }
150
160
  const rawStatus = message.error_status ?? message.errorStatus;
151
- const errorStatus = typeof rawStatus === "number" && Number.isFinite(rawStatus) ? rawStatus : null;
161
+ const errorStatus = typeof rawStatus === "number" && Number.isFinite(rawStatus)
162
+ ? rawStatus
163
+ : null;
152
164
  return {
153
165
  type: "api_retry_update",
154
166
  attempt,
@@ -168,7 +180,9 @@ export function normalizeSettingsParseError(value) {
168
180
  return null;
169
181
  }
170
182
  const path = typeof record.path === "string" ? record.path : "";
171
- const file = typeof record.file === "string" && record.file.trim() ? record.file : undefined;
183
+ const file = typeof record.file === "string" && record.file.trim()
184
+ ? record.file
185
+ : undefined;
172
186
  return {
173
187
  ...(file ? { file } : {}),
174
188
  path,
@@ -72,7 +72,9 @@ function jsonRecord(value) {
72
72
  : undefined;
73
73
  }
74
74
  function nonEmptyString(value) {
75
- return typeof value === "string" && value.trim().length > 0 ? value : undefined;
75
+ return typeof value === "string" && value.trim().length > 0
76
+ ? value
77
+ : undefined;
76
78
  }
77
79
  function stringArray(value) {
78
80
  if (!Array.isArray(value)) {
@@ -200,7 +202,9 @@ function humanizeFieldLabel(key) {
200
202
  if (word === "id") {
201
203
  return "ID";
202
204
  }
203
- return index === 0 ? `${word.charAt(0).toUpperCase()}${word.slice(1)}` : word;
205
+ return index === 0
206
+ ? `${word.charAt(0).toUpperCase()}${word.slice(1)}`
207
+ : word;
204
208
  })
205
209
  .join(" ");
206
210
  }
@@ -210,7 +214,9 @@ function displayScalarValue(value) {
210
214
  if (!trimmed) {
211
215
  return undefined;
212
216
  }
213
- return /^[a-z][a-z0-9]*(?:_[a-z0-9]+)+$/u.test(trimmed) ? trimmed.replace(/_/g, " ") : trimmed;
217
+ return /^[a-z][a-z0-9]*(?:_[a-z0-9]+)+$/u.test(trimmed)
218
+ ? trimmed.replace(/_/g, " ")
219
+ : trimmed;
214
220
  }
215
221
  if (typeof value === "boolean") {
216
222
  return value ? "yes" : "no";
@@ -224,13 +230,17 @@ function decodeXmlText(value) {
224
230
  return value.replace(/&(?:#(\d+)|#x([0-9a-fA-F]+)|amp|lt|gt|quot|apos);/g, (match, dec, hex) => {
225
231
  if (typeof dec === "string" && dec.length > 0) {
226
232
  const codePoint = Number.parseInt(dec, 10);
227
- return Number.isInteger(codePoint) && codePoint >= 0 && codePoint <= 0x10ffff
233
+ return Number.isInteger(codePoint) &&
234
+ codePoint >= 0 &&
235
+ codePoint <= 0x10ffff
228
236
  ? String.fromCodePoint(codePoint)
229
237
  : match;
230
238
  }
231
239
  if (typeof hex === "string" && hex.length > 0) {
232
240
  const codePoint = Number.parseInt(hex, 16);
233
- return Number.isInteger(codePoint) && codePoint >= 0 && codePoint <= 0x10ffff
241
+ return Number.isInteger(codePoint) &&
242
+ codePoint >= 0 &&
243
+ codePoint <= 0x10ffff
234
244
  ? String.fromCodePoint(codePoint)
235
245
  : match;
236
246
  }
@@ -242,7 +252,7 @@ function decodeXmlText(value) {
242
252
  case "&gt;":
243
253
  return ">";
244
254
  case "&quot;":
245
- return "\"";
255
+ return '"';
246
256
  case "&apos;":
247
257
  return "'";
248
258
  default:
@@ -261,7 +271,9 @@ function xmlLeafFields(text) {
261
271
  break;
262
272
  }
263
273
  const [, key, rawValue] = match;
264
- if (!key || rawValue === undefined || /<[A-Za-z][\w.-]{0,79}[\s>]/u.test(rawValue)) {
274
+ if (!key ||
275
+ rawValue === undefined ||
276
+ /<[A-Za-z][\w.-]{0,79}[\s>]/u.test(rawValue)) {
265
277
  continue;
266
278
  }
267
279
  const value = decodeXmlText(rawValue).trim();
@@ -277,7 +289,8 @@ function firstTaskRecord(candidates) {
277
289
  if (nestedTask && typeof nestedTask.id === "string") {
278
290
  return nestedTask;
279
291
  }
280
- if (typeof candidate.id === "string" && typeof candidate.subject === "string") {
292
+ if (typeof candidate.id === "string" &&
293
+ typeof candidate.subject === "string") {
281
294
  return candidate;
282
295
  }
283
296
  }
@@ -287,7 +300,8 @@ function firstRecordWithTaskProperty(candidates) {
287
300
  return candidates.find((candidate) => Object.hasOwn(candidate, "task"));
288
301
  }
289
302
  function firstTaskUpdateOutput(candidates) {
290
- return candidates.find((candidate) => typeof candidate.success === "boolean" && typeof candidate.taskId === "string");
303
+ return candidates.find((candidate) => typeof candidate.success === "boolean" &&
304
+ typeof candidate.taskId === "string");
291
305
  }
292
306
  function firstTaskListOutput(candidates) {
293
307
  return candidates.find((candidate) => Array.isArray(candidate.tasks));
@@ -449,7 +463,9 @@ function taskCreatePatch(taskRecord, input, toolUseId) {
449
463
  const metadata = jsonValue(input.metadata);
450
464
  return {
451
465
  task_id: taskId,
452
- subject: nonEmptyString(taskRecord.subject) ?? nonEmptyString(input.subject) ?? taskId,
466
+ subject: nonEmptyString(taskRecord.subject) ??
467
+ nonEmptyString(input.subject) ??
468
+ taskId,
453
469
  description: nonEmptyString(input.description),
454
470
  active_form: nonEmptyString(input.activeForm),
455
471
  status: "pending",
@@ -462,7 +478,8 @@ function taskCreatePatch(taskRecord, input, toolUseId) {
462
478
  function taskUpdatePatch(session, taskId, input, output) {
463
479
  const existing = session.tasksById.get(taskId);
464
480
  const metadata = mergeMetadata(existing?.metadata, jsonRecord(input.metadata));
465
- const status = normalizeTaskStatus(input.status) ?? normalizeTaskStatus(asRecordOrNull(output.statusChange)?.to);
481
+ const status = normalizeTaskStatus(input.status) ??
482
+ normalizeTaskStatus(asRecordOrNull(output.statusChange)?.to);
466
483
  const addBlocks = stringArray(input.addBlocks);
467
484
  const addBlockedBy = stringArray(input.addBlockedBy);
468
485
  const patch = {
@@ -472,7 +489,9 @@ function taskUpdatePatch(session, taskId, input, output) {
472
489
  active_form: nonEmptyString(input.activeForm),
473
490
  status,
474
491
  owner: nonEmptyString(input.owner),
475
- blocks: addBlocks.length > 0 ? uniqueStrings([...(existing?.blocks ?? []), ...addBlocks]) : undefined,
492
+ blocks: addBlocks.length > 0
493
+ ? uniqueStrings([...(existing?.blocks ?? []), ...addBlocks])
494
+ : undefined,
476
495
  blocked_by: addBlockedBy.length > 0
477
496
  ? uniqueStrings([...(existing?.blocked_by ?? []), ...addBlockedBy])
478
497
  : undefined,
@@ -573,7 +592,9 @@ function taskStatusMarker(status) {
573
592
  }
574
593
  }
575
594
  function taskRecordLine(record) {
576
- const subject = typeof record.subject === "string" && record.subject.trim() ? record.subject : "Task";
595
+ const subject = typeof record.subject === "string" && record.subject.trim()
596
+ ? record.subject
597
+ : "Task";
577
598
  return `${taskStatusMarker(record.status)} ${subject}`;
578
599
  }
579
600
  function taskListWindow(lines) {
@@ -604,7 +625,9 @@ export function taskToolResultText(toolName, rawResult, rawContent, rawInput) {
604
625
  return "";
605
626
  }
606
627
  if (output.success !== true) {
607
- const error = typeof output.error === "string" && output.error.trim() ? output.error : "Task update failed";
628
+ const error = typeof output.error === "string" && output.error.trim()
629
+ ? output.error
630
+ : "Task update failed";
608
631
  return error;
609
632
  }
610
633
  return "";
@@ -663,7 +686,8 @@ export function taskToolResultText(toolName, rawResult, rawContent, rawInput) {
663
686
  return "";
664
687
  }
665
688
  export function taskUpdateSucceeded(rawResult, rawContent) {
666
- return firstTaskUpdateOutput(resultCandidates(rawResult, rawContent))?.success;
689
+ return firstTaskUpdateOutput(resultCandidates(rawResult, rawContent))
690
+ ?.success;
667
691
  }
668
692
  export function applyTaskToolResult(session, toolUseId, isError, rawContent, rawResult) {
669
693
  if (isError) {
@@ -678,7 +702,9 @@ export function applyTaskToolResult(session, toolUseId, isError, rawContent, raw
678
702
  const candidates = resultCandidates(rawResult, rawContent);
679
703
  if (toolName === "TaskCreate") {
680
704
  const taskRecord = firstTaskRecord(candidates);
681
- const patch = taskRecord ? taskCreatePatch(taskRecord, input, toolUseId) : undefined;
705
+ const patch = taskRecord
706
+ ? taskCreatePatch(taskRecord, input, toolUseId)
707
+ : undefined;
682
708
  if (!patch) {
683
709
  return;
684
710
  }
@@ -730,7 +756,9 @@ export function applyTaskToolResult(session, toolUseId, isError, rawContent, raw
730
756
  .map((entry) => {
731
757
  const record = asRecordOrNull(entry);
732
758
  const taskId = nonEmptyString(record?.id);
733
- return record ? taskListPatch(record, taskId ? session.tasksById.get(taskId) : undefined) : undefined;
759
+ return record
760
+ ? taskListPatch(record, taskId ? session.tasksById.get(taskId) : undefined)
761
+ : undefined;
734
762
  })
735
763
  .filter((patch) => Boolean(patch));
736
764
  const snapshot = replaceTaskSnapshot(session, patches);
@@ -757,12 +785,17 @@ export function applyTaskToolResult(session, toolUseId, isError, rawContent, raw
757
785
  const metadata = mergeMetadata(existing?.metadata, {
758
786
  terminal_status: "stopped",
759
787
  task_type: output.task_type,
760
- ...(typeof output.command === "string" ? { command: output.command } : {}),
788
+ ...(typeof output.command === "string"
789
+ ? { command: output.command }
790
+ : {}),
761
791
  });
762
792
  emitTaskStateUpdate(session, "task_lifecycle", [
763
793
  upsertTask(session, {
764
794
  task_id: taskId,
765
- subject: existing?.subject ?? nonEmptyString(output.command) ?? nonEmptyString(output.task_type) ?? taskId,
795
+ subject: existing?.subject ??
796
+ nonEmptyString(output.command) ??
797
+ nonEmptyString(output.task_type) ??
798
+ taskId,
766
799
  status: "completed",
767
800
  metadata,
768
801
  source_tool_call_id: sourceToolCallId,
@@ -773,7 +806,8 @@ export function applyTaskToolResult(session, toolUseId, isError, rawContent, raw
773
806
  }
774
807
  function lifecycleTaskStatus(subtype, msg) {
775
808
  const patch = asRecordOrNull(msg.patch);
776
- const explicit = normalizeLifecycleTaskStatus(msg.status) ?? normalizeLifecycleTaskStatus(patch?.status);
809
+ const explicit = normalizeLifecycleTaskStatus(msg.status) ??
810
+ normalizeLifecycleTaskStatus(patch?.status);
777
811
  if (explicit) {
778
812
  return explicit;
779
813
  }
@@ -834,7 +868,9 @@ export function applyTaskLifecycleState(session, subtype, msg) {
834
868
  }
835
869
  const existing = session.tasksById.get(taskId);
836
870
  const status = lifecycleTaskStatus(subtype, msg);
837
- const description = nonEmptyString(patch?.description) ?? nonEmptyString(msg.description) ?? nonEmptyString(msg.summary);
871
+ const description = nonEmptyString(patch?.description) ??
872
+ nonEmptyString(msg.description) ??
873
+ nonEmptyString(msg.summary);
838
874
  const activeForm = nonEmptyString(patch?.activeForm);
839
875
  const subject = nonEmptyString(patch?.subject) ??
840
876
  nonEmptyString(msg.subject) ??
@@ -845,7 +881,11 @@ export function applyTaskLifecycleState(session, subtype, msg) {
845
881
  taskId;
846
882
  const metadata = mergeMetadata(existing?.metadata, lifecycleMetadata(msg));
847
883
  const sourceToolCallId = session.taskToolUseIds.get(taskId);
848
- if (!status && !description && !activeForm && metadata === existing?.metadata && !sourceToolCallId) {
884
+ if (!status &&
885
+ !description &&
886
+ !activeForm &&
887
+ metadata === existing?.metadata &&
888
+ !sourceToolCallId) {
849
889
  return;
850
890
  }
851
891
  emitTaskStateUpdate(session, "task_lifecycle", [
@@ -2,10 +2,21 @@ import { emitSessionUpdate } from "./events.js";
2
2
  import { bridgeLogger, LOG_TARGETS } from "./logger.js";
3
3
  import { asRecordOrNull } from "./shared.js";
4
4
  import { applyTaskToolResult } from "./tasks.js";
5
- import { activeTaskIdForToolUse, linkTaskToolUse, unlinkTaskToolUse } from "./task_links.js";
5
+ import { activeTaskIdForToolUse, linkTaskToolUse, unlinkTaskToolUse, } from "./task_links.js";
6
6
  import { applyToolNonExecutionMetadata, backgroundToolLaunchTaskIdFromResult, buildToolResultFields, createToolCall, } from "./tooling.js";
7
- const TOOL_SUMMARY_TOOL_NAMES = new Set(["Agent", "Task", "WebSearch", "WebFetch", "ExitPlanMode"]);
8
- const TASK_LIFECYCLE_TOOL_NAMES = new Set(["Agent", "Task", "Monitor", "Workflow"]);
7
+ const TOOL_SUMMARY_TOOL_NAMES = new Set([
8
+ "Agent",
9
+ "Task",
10
+ "WebSearch",
11
+ "WebFetch",
12
+ "ExitPlanMode",
13
+ ]);
14
+ const TASK_LIFECYCLE_TOOL_NAMES = new Set([
15
+ "Agent",
16
+ "Task",
17
+ "Monitor",
18
+ "Workflow",
19
+ ]);
9
20
  function jsonSize(value) {
10
21
  if (value === undefined) {
11
22
  return undefined;
@@ -21,8 +32,16 @@ function toolNameFromMeta(meta) {
21
32
  if (!meta || typeof meta !== "object") {
22
33
  return undefined;
23
34
  }
24
- const claudeCode = "claudeCode" in meta && meta.claudeCode && typeof meta.claudeCode === "object" ? meta.claudeCode : undefined;
25
- const toolName = claudeCode && "toolName" in claudeCode && typeof claudeCode.toolName === "string" ? claudeCode.toolName : "";
35
+ const claudeCode = "claudeCode" in meta &&
36
+ meta.claudeCode &&
37
+ typeof meta.claudeCode === "object"
38
+ ? meta.claudeCode
39
+ : undefined;
40
+ const toolName = claudeCode &&
41
+ "toolName" in claudeCode &&
42
+ typeof claudeCode.toolName === "string"
43
+ ? claudeCode.toolName
44
+ : "";
26
45
  return toolName || undefined;
27
46
  }
28
47
  function toolName(base, fields) {
@@ -82,20 +101,32 @@ function parentToolUseIdFromMeta(meta) {
82
101
  if (!meta || typeof meta !== "object") {
83
102
  return null;
84
103
  }
85
- const claudeCode = "claudeCode" in meta && meta.claudeCode && typeof meta.claudeCode === "object" ? meta.claudeCode : undefined;
86
- const parentToolUseId = claudeCode && "parentToolUseId" in claudeCode && typeof claudeCode.parentToolUseId === "string"
104
+ const claudeCode = "claudeCode" in meta &&
105
+ meta.claudeCode &&
106
+ typeof meta.claudeCode === "object"
107
+ ? meta.claudeCode
108
+ : undefined;
109
+ const parentToolUseId = claudeCode &&
110
+ "parentToolUseId" in claudeCode &&
111
+ typeof claudeCode.parentToolUseId === "string"
87
112
  ? claudeCode.parentToolUseId
88
113
  : null;
89
114
  return parentToolUseId;
90
115
  }
91
116
  function applyToolCorrelationMetadata(toolCall, metadata) {
92
- if (!metadata?.requestId && !metadata?.subagentType && !metadata?.taskDescription) {
117
+ if (!metadata?.requestId &&
118
+ !metadata?.subagentType &&
119
+ !metadata?.taskDescription) {
93
120
  return;
94
121
  }
95
- const meta = toolCall.meta && typeof toolCall.meta === "object" && !Array.isArray(toolCall.meta)
122
+ const meta = toolCall.meta &&
123
+ typeof toolCall.meta === "object" &&
124
+ !Array.isArray(toolCall.meta)
96
125
  ? toolCall.meta
97
126
  : {};
98
- const claudeCode = meta.claudeCode && typeof meta.claudeCode === "object" && !Array.isArray(meta.claudeCode)
127
+ const claudeCode = meta.claudeCode &&
128
+ typeof meta.claudeCode === "object" &&
129
+ !Array.isArray(meta.claudeCode)
99
130
  ? meta.claudeCode
100
131
  : {};
101
132
  toolCall.meta = {
@@ -104,7 +135,9 @@ function applyToolCorrelationMetadata(toolCall, metadata) {
104
135
  ...claudeCode,
105
136
  ...(metadata.requestId ? { requestId: metadata.requestId } : {}),
106
137
  ...(metadata.subagentType ? { subagentType: metadata.subagentType } : {}),
107
- ...(metadata.taskDescription ? { taskDescription: metadata.taskDescription } : {}),
138
+ ...(metadata.taskDescription
139
+ ? { taskDescription: metadata.taskDescription }
140
+ : {}),
108
141
  },
109
142
  };
110
143
  }
@@ -176,7 +209,9 @@ function logToolCallSubmitted(sessionId, toolCall, updateKind) {
176
209
  }
177
210
  function logToolCallUpdateEmitted(sessionId, toolUseId, fields, base, updateKind) {
178
211
  const nextStatus = fields.status ?? base?.status;
179
- const rawOutput = typeof fields.raw_output === "string" ? fields.raw_output : base?.raw_output;
212
+ const rawOutput = typeof fields.raw_output === "string"
213
+ ? fields.raw_output
214
+ : base?.raw_output;
180
215
  const failureKind = nextStatus === "failed" ? classifyFailureKind(rawOutput) : undefined;
181
216
  const commonEvent = {
182
217
  target: LOG_TARGETS.APP_TOOL,
@@ -195,7 +230,8 @@ function logToolCallUpdateEmitted(sessionId, toolUseId, fields, base, updateKind
195
230
  content_block_count: fields.content?.length,
196
231
  location_count: fields.locations?.length,
197
232
  raw_output_chars: rawOutput?.length,
198
- has_output_metadata: fields.output_metadata !== undefined || base?.output_metadata !== undefined,
233
+ has_output_metadata: fields.output_metadata !== undefined ||
234
+ base?.output_metadata !== undefined,
199
235
  has_task_metadata: fields.task_metadata !== undefined || base?.task_metadata !== undefined,
200
236
  failure_kind: failureKind,
201
237
  },
@@ -217,7 +253,10 @@ function logToolCallUpdateEmitted(sessionId, toolUseId, fields, base, updateKind
217
253
  function emitInitialToolCall(session, toolCall, updateKind = "initial") {
218
254
  session.toolCalls.set(toolCall.tool_call_id, toolCall);
219
255
  logToolCallSubmitted(session.sessionId, toolCall, updateKind);
220
- emitSessionUpdate(session.sessionId, { type: "tool_call", tool_call: toolCall });
256
+ emitSessionUpdate(session.sessionId, {
257
+ type: "tool_call",
258
+ tool_call: toolCall,
259
+ });
221
260
  }
222
261
  function taskTitleContext(session, name, input) {
223
262
  const taskId = name === "TaskUpdate"
@@ -242,7 +281,9 @@ function taskTitleContext(session, name, input) {
242
281
  export function emitToolCallUpdate(session, toolUseId, fields, updateKind, sourceMessageUuid) {
243
282
  const base = session.toolCalls.get(toolUseId);
244
283
  const nextStatus = fields.status ?? base?.status;
245
- const terminal = nextStatus === "completed" || nextStatus === "failed" || nextStatus === "killed";
284
+ const terminal = nextStatus === "completed" ||
285
+ nextStatus === "failed" ||
286
+ nextStatus === "killed";
246
287
  const hasActiveRetry = base?.task_metadata?.subagent_retry?.state === "waiting" ||
247
288
  fields.task_metadata?.subagent_retry?.state === "waiting";
248
289
  if (terminal && hasActiveRetry) {
@@ -333,7 +374,8 @@ export function finalizeOpenToolCalls(session, status) {
333
374
  if (toolCall.status !== "pending" && toolCall.status !== "in_progress") {
334
375
  continue;
335
376
  }
336
- if (toolAcceptsTaskLifecycle(toolCall) && activeTaskIdForToolUse(session, toolUseId)) {
377
+ if (toolAcceptsTaskLifecycle(toolCall) &&
378
+ activeTaskIdForToolUse(session, toolUseId)) {
337
379
  continue;
338
380
  }
339
381
  emitToolCallUpdate(session, toolUseId, { status }, "finalize");
@@ -360,7 +402,8 @@ export function emitToolProgressUpdate(session, toolUseId, progress = {}) {
360
402
  existing.task_metadata?.subagent_retry?.state === "waiting") {
361
403
  taskMetadata.subagent_retry = progress.subagentRetry;
362
404
  }
363
- if (progress.subagentType && progress.subagentType !== existing.task_metadata?.subagent_type) {
405
+ if (progress.subagentType &&
406
+ progress.subagentType !== existing.task_metadata?.subagent_type) {
364
407
  taskMetadata.subagent_type = progress.subagentType;
365
408
  }
366
409
  const fields = {};
@@ -383,7 +426,9 @@ export function emitToolSummaryUpdate(session, toolUseId, summary) {
383
426
  return;
384
427
  }
385
428
  const fields = {
386
- status: base.status === "failed" || base.status === "killed" ? base.status : "completed",
429
+ status: base.status === "failed" || base.status === "killed"
430
+ ? base.status
431
+ : "completed",
387
432
  raw_output: summary,
388
433
  content: [{ type: "content", content: { type: "text", text: summary } }],
389
434
  };
@@ -397,7 +442,9 @@ export function setToolCallStatus(session, toolUseId, status, message) {
397
442
  const fields = { status };
398
443
  if (message && message.length > 0) {
399
444
  fields.raw_output = message;
400
- fields.content = [{ type: "content", content: { type: "text", text: message } }];
445
+ fields.content = [
446
+ { type: "content", content: { type: "text", text: message } },
447
+ ];
401
448
  }
402
449
  emitToolCallUpdate(session, toolUseId, fields, "status");
403
450
  }
@@ -448,7 +495,9 @@ function buildTaskMetadata(patch) {
448
495
  if (typeof patch.is_backgrounded === "boolean") {
449
496
  taskMetadata.is_backgrounded = patch.is_backgrounded;
450
497
  }
451
- if (typeof patch.end_time === "number" && Number.isFinite(patch.end_time) && patch.end_time >= 0) {
498
+ if (typeof patch.end_time === "number" &&
499
+ Number.isFinite(patch.end_time) &&
500
+ patch.end_time >= 0) {
452
501
  taskMetadata.end_time = Math.trunc(patch.end_time);
453
502
  }
454
503
  if (typeof patch.total_paused_ms === "number" &&
@@ -456,19 +505,23 @@ function buildTaskMetadata(patch) {
456
505
  patch.total_paused_ms >= 0) {
457
506
  taskMetadata.total_paused_ms = Math.trunc(patch.total_paused_ms);
458
507
  }
459
- if (typeof patch.status === "string" && ["completed", "failed", "killed"].includes(patch.status)) {
508
+ if (typeof patch.status === "string" &&
509
+ ["completed", "failed", "killed"].includes(patch.status)) {
460
510
  taskMetadata.terminal_status = patch.status;
461
511
  }
462
512
  if (typeof patch.blocked === "boolean") {
463
513
  taskMetadata.blocked = patch.blocked;
464
514
  }
465
- if (typeof patch.parent_agent_id === "string" && patch.parent_agent_id.length > 0) {
515
+ if (typeof patch.parent_agent_id === "string" &&
516
+ patch.parent_agent_id.length > 0) {
466
517
  taskMetadata.parent_agent_id = patch.parent_agent_id;
467
518
  }
468
519
  return Object.keys(taskMetadata).length > 0 ? taskMetadata : undefined;
469
520
  }
470
521
  export function taskUpdatedFields(msg) {
471
- const patch = msg.patch && typeof msg.patch === "object" ? msg.patch : {};
522
+ const patch = msg.patch && typeof msg.patch === "object"
523
+ ? msg.patch
524
+ : {};
472
525
  const fields = {};
473
526
  const status = taskPatchStatus(patch.status);
474
527
  const description = typeof patch.description === "string" ? patch.description : "";
@@ -478,11 +531,15 @@ export function taskUpdatedFields(msg) {
478
531
  }
479
532
  if (description) {
480
533
  fields.raw_output = description;
481
- fields.content = [{ type: "content", content: { type: "text", text: description } }];
534
+ fields.content = [
535
+ { type: "content", content: { type: "text", text: description } },
536
+ ];
482
537
  }
483
538
  else if ((status === "failed" || status === "killed") && error) {
484
539
  fields.raw_output = error;
485
- fields.content = [{ type: "content", content: { type: "text", text: error } }];
540
+ fields.content = [
541
+ { type: "content", content: { type: "text", text: error } },
542
+ ];
486
543
  }
487
544
  const taskMetadata = buildTaskMetadata(patch);
488
545
  if (taskMetadata) {