claude-code-rust 0.14.3 → 0.14.5

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.
@@ -50,14 +50,18 @@ export function isToolSearchToolResultType(blockType) {
50
50
  return blockType === "tool_search_tool_result";
51
51
  }
52
52
  export function isToolUseBlockType(blockType) {
53
- return blockType === "tool_use" || blockType === "server_tool_use" || blockType === "mcp_tool_use";
53
+ return (blockType === "tool_use" ||
54
+ blockType === "server_tool_use" ||
55
+ blockType === "mcp_tool_use");
54
56
  }
55
57
  function inputString(input, key) {
56
58
  return typeof input[key] === "string" ? input[key].trim() : "";
57
59
  }
58
60
  function inputNumber(input, key) {
59
61
  const value = input[key];
60
- return typeof value === "number" && Number.isFinite(value) ? value : undefined;
62
+ return typeof value === "number" && Number.isFinite(value)
63
+ ? value
64
+ : undefined;
61
65
  }
62
66
  function inputBoolean(input, key) {
63
67
  return typeof input[key] === "boolean" ? input[key] : undefined;
@@ -69,7 +73,8 @@ export function isShellToolName(name) {
69
73
  return name === "Bash" || name === "PowerShell";
70
74
  }
71
75
  function isMcpResourceReadToolName(name) {
72
- return name === READ_MCP_RESOURCE_TOOL_NAME || name === READ_MCP_RESOURCE_DIR_TOOL_NAME;
76
+ return (name === READ_MCP_RESOURCE_TOOL_NAME ||
77
+ name === READ_MCP_RESOURCE_DIR_TOOL_NAME);
73
78
  }
74
79
  function agentInputTitle(name, input) {
75
80
  if (!isAgentLikeToolName(name)) {
@@ -278,7 +283,9 @@ export function toolTitle(name, input, context = {}) {
278
283
  }
279
284
  if (name === REMOTE_TRIGGER_TOOL_NAME) {
280
285
  const action = typeof input.action === "string" ? input.action.trim() : "";
281
- return action ? `${REMOTE_TRIGGER_TOOL_NAME}: ${action}` : REMOTE_TRIGGER_TOOL_NAME;
286
+ return action
287
+ ? `${REMOTE_TRIGGER_TOOL_NAME}: ${action}`
288
+ : REMOTE_TRIGGER_TOOL_NAME;
282
289
  }
283
290
  if (name === ENTER_PLAN_MODE_TOOL_NAME) {
284
291
  return name;
@@ -289,11 +296,15 @@ export function toolTitle(name, input, context = {}) {
289
296
  }
290
297
  if (name === MONITOR_TOOL_NAME) {
291
298
  const description = nonEmptyString(input.description);
292
- return description ? `${MONITOR_TOOL_NAME}: ${description}` : MONITOR_TOOL_NAME;
299
+ return description
300
+ ? `${MONITOR_TOOL_NAME}: ${description}`
301
+ : MONITOR_TOOL_NAME;
293
302
  }
294
303
  if (name === WORKFLOW_TOOL_NAME) {
295
304
  const workflowName = nonEmptyString(input.name);
296
- return workflowName ? `${WORKFLOW_TOOL_NAME}: ${workflowName}` : WORKFLOW_TOOL_NAME;
305
+ return workflowName
306
+ ? `${WORKFLOW_TOOL_NAME}: ${workflowName}`
307
+ : WORKFLOW_TOOL_NAME;
297
308
  }
298
309
  if (name === PROJECTS_TOOL_NAME) {
299
310
  return formatProjectsTitle(input);
@@ -318,7 +329,8 @@ export function toolTitle(name, input, context = {}) {
318
329
  if (name === "ExitWorktree") {
319
330
  return "ExitWorktree";
320
331
  }
321
- if ((name === "Read" || name === "Write" || name === "Edit") && typeof input.file_path === "string") {
332
+ if ((name === "Read" || name === "Write" || name === "Edit") &&
333
+ typeof input.file_path === "string") {
322
334
  return `${name} ${input.file_path}`;
323
335
  }
324
336
  if (isMcpResourceReadToolName(name)) {
@@ -335,7 +347,9 @@ export function toolTitle(name, input, context = {}) {
335
347
  }
336
348
  function formatProjectsTitle(input) {
337
349
  const method = nonEmptyString(input.method);
338
- const action = method?.startsWith("project_") ? method.slice("project_".length) : method;
350
+ const action = method?.startsWith("project_")
351
+ ? method.slice("project_".length)
352
+ : method;
339
353
  const suffix = nonEmptyString(input.path) ?? nonEmptyString(input.query);
340
354
  const base = action ? `${PROJECTS_TOOL_NAME}: ${action}` : PROJECTS_TOOL_NAME;
341
355
  return suffix ? `${base} ${suffix}` : base;
@@ -351,14 +365,30 @@ function editDiffContent(name, input) {
351
365
  if (!oldText && !newText) {
352
366
  return [];
353
367
  }
354
- return [{ type: "diff", old_path: filePath, new_path: filePath, old: oldText, new: newText }];
368
+ return [
369
+ {
370
+ type: "diff",
371
+ old_path: filePath,
372
+ new_path: filePath,
373
+ old: oldText,
374
+ new: newText,
375
+ },
376
+ ];
355
377
  }
356
378
  if (name === "Write") {
357
379
  const newText = typeof input.content === "string" ? input.content : "";
358
380
  if (!newText) {
359
381
  return [];
360
382
  }
361
- return [{ type: "diff", old_path: filePath, new_path: filePath, old: "", new: newText }];
383
+ return [
384
+ {
385
+ type: "diff",
386
+ old_path: filePath,
387
+ new_path: filePath,
388
+ old: "",
389
+ new: newText,
390
+ },
391
+ ];
362
392
  }
363
393
  return [];
364
394
  }
@@ -462,11 +492,18 @@ function pushStructuredRecordCandidates(candidates, value) {
462
492
  }
463
493
  function mcpResourceContentFromResult(rawResult, rawContent) {
464
494
  const candidates = [];
465
- for (const candidate of [rawResult, rawContent, parseJsonCandidate(rawResult), parseJsonCandidate(rawContent)]) {
495
+ for (const candidate of [
496
+ rawResult,
497
+ rawContent,
498
+ parseJsonCandidate(rawResult),
499
+ parseJsonCandidate(rawContent),
500
+ ]) {
466
501
  pushStructuredRecordCandidates(candidates, candidate);
467
502
  }
468
503
  for (const candidate of candidates) {
469
- const contents = Array.isArray(candidate.contents) ? candidate.contents : null;
504
+ const contents = Array.isArray(candidate.contents)
505
+ ? candidate.contents
506
+ : null;
470
507
  if (!contents || contents.length === 0) {
471
508
  continue;
472
509
  }
@@ -480,11 +517,14 @@ function mcpResourceContentFromResult(rawResult, rawContent) {
480
517
  if (!uri) {
481
518
  continue;
482
519
  }
483
- const text = typeof record.text === "string" && record.text.length > 0 ? record.text : undefined;
520
+ const text = typeof record.text === "string" && record.text.length > 0
521
+ ? record.text
522
+ : undefined;
484
523
  const mimeType = typeof record.mimeType === "string" && record.mimeType.trim().length > 0
485
524
  ? record.mimeType.trim()
486
525
  : undefined;
487
- const blobSavedTo = typeof record.blobSavedTo === "string" && record.blobSavedTo.trim().length > 0
526
+ const blobSavedTo = typeof record.blobSavedTo === "string" &&
527
+ record.blobSavedTo.trim().length > 0
488
528
  ? record.blobSavedTo.trim()
489
529
  : undefined;
490
530
  if (!text && !blobSavedTo) {
@@ -543,10 +583,15 @@ function extractToolOutputMetadata(toolName, rawResult, rawContent) {
543
583
  const hasAssistantAutoBackgrounded = typeof candidate.assistantAutoBackgrounded === "boolean";
544
584
  const timedOutAfterMs = nonNegativeInteger(candidate.timedOutAfterMs);
545
585
  const backgroundCwdHint = nonEmptyString(candidate.backgroundCwdHint);
546
- if (hasAssistantAutoBackgrounded || timedOutAfterMs !== undefined || backgroundCwdHint) {
586
+ const hasBackgroundEndsWithFinalResponse = typeof candidate.backgroundEndsWithFinalResponse === "boolean";
587
+ if (hasAssistantAutoBackgrounded ||
588
+ timedOutAfterMs !== undefined ||
589
+ backgroundCwdHint ||
590
+ hasBackgroundEndsWithFinalResponse) {
547
591
  const bashMetadata = {};
548
592
  if (hasAssistantAutoBackgrounded) {
549
- bashMetadata.assistant_auto_backgrounded = candidate.assistantAutoBackgrounded;
593
+ bashMetadata.assistant_auto_backgrounded =
594
+ candidate.assistantAutoBackgrounded;
550
595
  }
551
596
  if (timedOutAfterMs !== undefined) {
552
597
  bashMetadata.timed_out_after_ms = timedOutAfterMs;
@@ -554,6 +599,10 @@ function extractToolOutputMetadata(toolName, rawResult, rawContent) {
554
599
  if (backgroundCwdHint) {
555
600
  bashMetadata.background_cwd_hint = backgroundCwdHint;
556
601
  }
602
+ if (hasBackgroundEndsWithFinalResponse) {
603
+ bashMetadata.background_ends_with_final_response =
604
+ candidate.backgroundEndsWithFinalResponse;
605
+ }
557
606
  metadata.bash = bashMetadata;
558
607
  break;
559
608
  }
@@ -578,9 +627,14 @@ function extractToolOutputMetadata(toolName, rawResult, rawContent) {
578
627
  const artifactRead = asRecordOrNull(candidate.artifactRead);
579
628
  const slug = nonEmptyString(artifactRead?.slug);
580
629
  const ver = nonEmptyString(artifactRead?.ver);
581
- if (slug && ver) {
630
+ const seeded = artifactRead?.seeded === false ? false : undefined;
631
+ if (slug) {
582
632
  const webFetchMetadata = {
583
- artifact_read: { slug, ver },
633
+ artifact_read: {
634
+ slug,
635
+ ...(ver ? { ver } : {}),
636
+ ...(seeded === false ? { seeded } : {}),
637
+ },
584
638
  };
585
639
  metadata.web_fetch = webFetchMetadata;
586
640
  break;
@@ -651,7 +705,10 @@ export function extractText(value) {
651
705
  if (typeof entry === "string") {
652
706
  return entry;
653
707
  }
654
- if (entry && typeof entry === "object" && "text" in entry && typeof entry.text === "string") {
708
+ if (entry &&
709
+ typeof entry === "object" &&
710
+ "text" in entry &&
711
+ typeof entry.text === "string") {
655
712
  return entry.text;
656
713
  }
657
714
  return "";
@@ -659,7 +716,10 @@ export function extractText(value) {
659
716
  .filter((part) => part.length > 0)
660
717
  .join("\n");
661
718
  }
662
- if (value && typeof value === "object" && "text" in value && typeof value.text === "string") {
719
+ if (value &&
720
+ typeof value === "object" &&
721
+ "text" in value &&
722
+ typeof value.text === "string") {
663
723
  return value.text;
664
724
  }
665
725
  return "";
@@ -744,7 +804,15 @@ function writeDiffFromInput(rawInput) {
744
804
  if (!filePath || !content) {
745
805
  return [];
746
806
  }
747
- return [{ type: "diff", old_path: filePath, new_path: filePath, old: "", new: content }];
807
+ return [
808
+ {
809
+ type: "diff",
810
+ old_path: filePath,
811
+ new_path: filePath,
812
+ old: "",
813
+ new: content,
814
+ },
815
+ ];
748
816
  }
749
817
  function editDiffFromInput(rawInput) {
750
818
  const input = asRecordOrNull(rawInput);
@@ -765,7 +833,15 @@ function editDiffFromInput(rawInput) {
765
833
  if (!filePath || (!oldText && !newText)) {
766
834
  return [];
767
835
  }
768
- return [{ type: "diff", old_path: filePath, new_path: filePath, old: oldText, new: newText }];
836
+ return [
837
+ {
838
+ type: "diff",
839
+ old_path: filePath,
840
+ new_path: filePath,
841
+ old: oldText,
842
+ new: newText,
843
+ },
844
+ ];
769
845
  }
770
846
  function writeDiffFromResult(rawContent) {
771
847
  const candidates = Array.isArray(rawContent) ? rawContent : [rawContent];
@@ -780,15 +856,24 @@ function writeDiffFromResult(rawContent) {
780
856
  ? record.file_path
781
857
  : "";
782
858
  const content = typeof record.content === "string" ? record.content : "";
783
- const originalRaw = "originalFile" in record ? record.originalFile : "original_file" in record ? record.original_file : undefined;
859
+ const originalRaw = "originalFile" in record
860
+ ? record.originalFile
861
+ : "original_file" in record
862
+ ? record.original_file
863
+ : undefined;
784
864
  const gitDiff = asRecordOrNull(record.gitDiff);
785
- const repository = typeof gitDiff?.repository === "string" && gitDiff.repository.trim().length > 0
865
+ const repository = typeof gitDiff?.repository === "string" &&
866
+ gitDiff.repository.trim().length > 0
786
867
  ? gitDiff.repository.trim()
787
868
  : undefined;
788
869
  if (!filePath || !content || originalRaw === undefined) {
789
870
  continue;
790
871
  }
791
- const original = typeof originalRaw === "string" ? originalRaw : originalRaw === null ? "" : "";
872
+ const original = typeof originalRaw === "string"
873
+ ? originalRaw
874
+ : originalRaw === null
875
+ ? ""
876
+ : "";
792
877
  return [
793
878
  {
794
879
  type: "diff",
@@ -831,7 +916,8 @@ function editDiffFromResult(rawResult, rawInput) {
831
916
  if (candidatePath && candidatePath !== filePath) {
832
917
  continue;
833
918
  }
834
- const repository = typeof gitDiff?.repository === "string" && gitDiff.repository.trim().length > 0
919
+ const repository = typeof gitDiff?.repository === "string" &&
920
+ gitDiff.repository.trim().length > 0
835
921
  ? gitDiff.repository.trim()
836
922
  : undefined;
837
923
  return [
@@ -921,12 +1007,17 @@ function firstSearchRecord(toolName, rawResult, rawContent) {
921
1007
  return undefined;
922
1008
  }
923
1009
  const candidates = resultRecordCandidates(rawResult, rawContent);
924
- for (const parsed of [parseJsonCandidate(rawResult), parseJsonCandidate(rawContent)]) {
1010
+ for (const parsed of [
1011
+ parseJsonCandidate(rawResult),
1012
+ parseJsonCandidate(rawContent),
1013
+ ]) {
925
1014
  candidates.push(...resultRecordCandidates(parsed, undefined));
926
1015
  }
927
1016
  return candidates.find((candidate) => {
928
1017
  if (toolName === "Glob") {
929
- return Array.isArray(candidate.filenames) || "numFiles" in candidate || "truncated" in candidate;
1018
+ return (Array.isArray(candidate.filenames) ||
1019
+ "numFiles" in candidate ||
1020
+ "truncated" in candidate);
930
1021
  }
931
1022
  return (Array.isArray(candidate.filenames) ||
932
1023
  "numFiles" in candidate ||
@@ -937,7 +1028,9 @@ function firstSearchRecord(toolName, rawResult, rawContent) {
937
1028
  }
938
1029
  function recordNumber(record, key) {
939
1030
  const value = record[key];
940
- return typeof value === "number" && Number.isFinite(value) ? value : undefined;
1031
+ return typeof value === "number" && Number.isFinite(value)
1032
+ ? value
1033
+ : undefined;
941
1034
  }
942
1035
  function recordNonNegativeInteger(record, key) {
943
1036
  return nonNegativeInteger(record[key]);
@@ -993,7 +1086,8 @@ function grepResultText(record) {
993
1086
  const numFiles = totalFiles ??
994
1087
  (legacyNumFiles !== 0 || !hasVisibleMatches ? legacyNumFiles : undefined) ??
995
1088
  (filenames.length > 0 ? filenames.length : undefined);
996
- const numLines = recordNonNegativeInteger(record, "totalLines") ?? recordNonNegativeInteger(record, "numLines");
1089
+ const numLines = recordNonNegativeInteger(record, "totalLines") ??
1090
+ recordNonNegativeInteger(record, "numLines");
997
1091
  const numMatches = recordNumber(record, "numMatches");
998
1092
  const appliedLimit = recordNumber(record, "appliedLimit");
999
1093
  const appliedOffset = recordNumber(record, "appliedOffset");
@@ -1046,12 +1140,19 @@ function worktreeResultFields(toolName, rawResult, rawContent) {
1046
1140
  return undefined;
1047
1141
  }
1048
1142
  const candidates = resultRecordCandidates(rawResult, rawContent);
1049
- for (const parsed of [parseJsonCandidate(rawResult), parseJsonCandidate(rawContent)]) {
1143
+ for (const parsed of [
1144
+ parseJsonCandidate(rawResult),
1145
+ parseJsonCandidate(rawContent),
1146
+ ]) {
1050
1147
  candidates.push(...resultRecordCandidates(parsed, undefined));
1051
1148
  }
1052
1149
  for (const candidate of candidates) {
1053
- const branch = typeof candidate.worktreeBranch === "string" ? candidate.worktreeBranch.trim() : "";
1054
- const path = typeof candidate.worktreePath === "string" ? candidate.worktreePath.trim() : "";
1150
+ const branch = typeof candidate.worktreeBranch === "string"
1151
+ ? candidate.worktreeBranch.trim()
1152
+ : "";
1153
+ const path = typeof candidate.worktreePath === "string"
1154
+ ? candidate.worktreePath.trim()
1155
+ : "";
1055
1156
  const output = branch ? `Branch: ${branch}` : path ? `Path: ${path}` : "";
1056
1157
  const isStructuredWorktreeOutput = "message" in candidate ||
1057
1158
  "worktreeBranch" in candidate ||
@@ -1117,8 +1218,24 @@ const CRON_WEEKDAY_NAMES = [
1117
1218
  "Friday",
1118
1219
  "Saturday",
1119
1220
  ];
1120
- const CRON_MONTH_ALIASES = new Map(["JAN", "FEB", "MAR", "APR", "MAY", "JUN", "JUL", "AUG", "SEP", "OCT", "NOV", "DEC"].map((name, index) => [name, index + 1]));
1121
- const CRON_WEEKDAY_ALIASES = new Map(["SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT"].map((name, index) => [name, index]));
1221
+ const CRON_MONTH_ALIASES = new Map([
1222
+ "JAN",
1223
+ "FEB",
1224
+ "MAR",
1225
+ "APR",
1226
+ "MAY",
1227
+ "JUN",
1228
+ "JUL",
1229
+ "AUG",
1230
+ "SEP",
1231
+ "OCT",
1232
+ "NOV",
1233
+ "DEC",
1234
+ ].map((name, index) => [name, index + 1]));
1235
+ const CRON_WEEKDAY_ALIASES = new Map(["SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT"].map((name, index) => [
1236
+ name,
1237
+ index,
1238
+ ]));
1122
1239
  function parseCronValue(value, min, max, aliases) {
1123
1240
  const normalized = value.trim().toUpperCase();
1124
1241
  const aliased = aliases?.get(normalized);
@@ -1136,14 +1253,18 @@ function parseCronField(rawField, min, max, aliases) {
1136
1253
  const stepMatch = raw.match(/^\*\/(\d+)$/);
1137
1254
  if (stepMatch) {
1138
1255
  const step = Number(stepMatch[1]);
1139
- return Number.isInteger(step) && step > 0 ? { kind: "step", raw, step } : { kind: "unsupported", raw };
1256
+ return Number.isInteger(step) && step > 0
1257
+ ? { kind: "step", raw, step }
1258
+ : { kind: "unsupported", raw };
1140
1259
  }
1141
1260
  if (raw.includes(",")) {
1142
1261
  const values = raw
1143
1262
  .split(",")
1144
1263
  .map((part) => parseCronValue(part, min, max, aliases))
1145
1264
  .filter((value) => value !== undefined);
1146
- return values.length === raw.split(",").length ? { kind: "list", raw, values } : { kind: "unsupported", raw };
1265
+ return values.length === raw.split(",").length
1266
+ ? { kind: "list", raw, values }
1267
+ : { kind: "unsupported", raw };
1147
1268
  }
1148
1269
  const rangeMatch = raw.match(/^([^/-]+)-([^/-]+)$/);
1149
1270
  if (rangeMatch) {
@@ -1154,7 +1275,9 @@ function parseCronField(rawField, min, max, aliases) {
1154
1275
  : { kind: "unsupported", raw };
1155
1276
  }
1156
1277
  const value = parseCronValue(raw, min, max, aliases);
1157
- return value !== undefined ? { kind: "single", raw, value } : { kind: "unsupported", raw };
1278
+ return value !== undefined
1279
+ ? { kind: "single", raw, value }
1280
+ : { kind: "unsupported", raw };
1158
1281
  }
1159
1282
  function isCronAny(field) {
1160
1283
  return field.kind === "any";
@@ -1195,12 +1318,16 @@ function weekdayDescription(field) {
1195
1318
  return "day";
1196
1319
  }
1197
1320
  if (field.kind === "list") {
1198
- const normalized = [...new Set(field.values.map((value) => (value === 7 ? 0 : value)))].sort((left, right) => left - right);
1321
+ const normalized = [
1322
+ ...new Set(field.values.map((value) => (value === 7 ? 0 : value))),
1323
+ ].sort((left, right) => left - right);
1199
1324
  if (normalized.length === 2 && normalized[0] === 0 && normalized[1] === 6) {
1200
1325
  return "weekend day";
1201
1326
  }
1202
1327
  const names = normalized.map(weekdayName);
1203
- return names.every((name) => name !== undefined) ? joinEnglishList(names) : undefined;
1328
+ return names.every((name) => name !== undefined)
1329
+ ? joinEnglishList(names)
1330
+ : undefined;
1204
1331
  }
1205
1332
  return undefined;
1206
1333
  }
@@ -1211,7 +1338,9 @@ function hourlyScheduleText(minute) {
1211
1338
  if (minute.kind !== "single") {
1212
1339
  return undefined;
1213
1340
  }
1214
- return minute.value === 0 ? "Every hour on the hour" : `Every hour at minute ${padCronNumber(minute.value)}`;
1341
+ return minute.value === 0
1342
+ ? "Every hour on the hour"
1343
+ : `Every hour at minute ${padCronNumber(minute.value)}`;
1215
1344
  }
1216
1345
  function cronScheduleFromExpression(cron) {
1217
1346
  const parts = cron.trim().split(/\s+/);
@@ -1239,7 +1368,9 @@ function cronScheduleFromExpression(cron) {
1239
1368
  return hourlyScheduleText(minute);
1240
1369
  }
1241
1370
  if (everyDay && minute.kind === "single" && hour.kind === "step") {
1242
- const suffix = minute.value === 0 ? "on the hour" : `at minute ${padCronNumber(minute.value)}`;
1371
+ const suffix = minute.value === 0
1372
+ ? "on the hour"
1373
+ : `at minute ${padCronNumber(minute.value)}`;
1243
1374
  return `Every ${hour.step} ${pluralUnit(hour.step, "hour")} ${suffix}`;
1244
1375
  }
1245
1376
  const time = cronTime(hour, minute);
@@ -1264,13 +1395,17 @@ function cronScheduleFromExpression(cron) {
1264
1395
  if (dayOfMonth.kind === "single" && isCronAny(dayOfWeek)) {
1265
1396
  if (month.kind === "single") {
1266
1397
  const monthLabel = monthName(month.value);
1267
- return monthLabel ? `Every ${monthLabel} ${dayOfMonth.value} at ${time}` : undefined;
1398
+ return monthLabel
1399
+ ? `Every ${monthLabel} ${dayOfMonth.value} at ${time}`
1400
+ : undefined;
1268
1401
  }
1269
1402
  if (month.kind === "step") {
1270
1403
  return `Every ${month.step} ${pluralUnit(month.step, "month")} on day ${dayOfMonth.value} at ${time}`;
1271
1404
  }
1272
1405
  }
1273
- if (isCronAny(dayOfMonth) && month.kind === "single" && isCronAny(dayOfWeek)) {
1406
+ if (isCronAny(dayOfMonth) &&
1407
+ month.kind === "single" &&
1408
+ isCronAny(dayOfWeek)) {
1274
1409
  const monthLabel = monthName(month.value);
1275
1410
  return monthLabel ? `Every day in ${monthLabel} at ${time}` : undefined;
1276
1411
  }
@@ -1285,7 +1420,11 @@ function normalizeHumanSchedule(value) {
1285
1420
  if (hourlyMinute) {
1286
1421
  const minute = Number(hourlyMinute[1]);
1287
1422
  if (Number.isInteger(minute) && minute >= 0 && minute <= 59) {
1288
- return hourlyScheduleText({ kind: "single", raw: hourlyMinute[1], value: minute });
1423
+ return hourlyScheduleText({
1424
+ kind: "single",
1425
+ raw: hourlyMinute[1],
1426
+ value: minute,
1427
+ });
1289
1428
  }
1290
1429
  }
1291
1430
  return text;
@@ -1317,13 +1456,17 @@ function cronCreateResultText(candidate, rawInput) {
1317
1456
  return lines.join("\n");
1318
1457
  }
1319
1458
  function cronDeleteResultText(candidate) {
1320
- return typeof candidate.id === "string" ? `Schedule ID: ${candidate.id}` : undefined;
1459
+ return typeof candidate.id === "string"
1460
+ ? `Schedule ID: ${candidate.id}`
1461
+ : undefined;
1321
1462
  }
1322
1463
  function cronListResultText(candidate) {
1323
1464
  if (!Array.isArray(candidate.jobs)) {
1324
1465
  return undefined;
1325
1466
  }
1326
- const jobs = candidate.jobs.map(asRecordOrNull).filter((job) => job !== null);
1467
+ const jobs = candidate.jobs
1468
+ .map(asRecordOrNull)
1469
+ .filter((job) => job !== null);
1327
1470
  if (jobs.length === 0) {
1328
1471
  return "Jobs: none";
1329
1472
  }
@@ -1373,7 +1516,10 @@ function cronResultText(toolName, rawResult, rawContent, rawInput) {
1373
1516
  return undefined;
1374
1517
  }
1375
1518
  const candidates = resultRecordCandidates(rawResult, rawContent);
1376
- for (const parsed of [parseJsonCandidate(rawResult), parseJsonCandidate(rawContent)]) {
1519
+ for (const parsed of [
1520
+ parseJsonCandidate(rawResult),
1521
+ parseJsonCandidate(rawContent),
1522
+ ]) {
1377
1523
  candidates.push(...resultRecordCandidates(parsed, undefined));
1378
1524
  }
1379
1525
  for (const candidate of candidates) {
@@ -1441,7 +1587,10 @@ function scheduleWakeupResultText(toolName, rawResult, rawContent) {
1441
1587
  return undefined;
1442
1588
  }
1443
1589
  const candidates = resultRecordCandidates(rawResult, rawContent);
1444
- for (const parsed of [parseJsonCandidate(rawResult), parseJsonCandidate(rawContent)]) {
1590
+ for (const parsed of [
1591
+ parseJsonCandidate(rawResult),
1592
+ parseJsonCandidate(rawContent),
1593
+ ]) {
1445
1594
  candidates.push(...resultRecordCandidates(parsed, undefined));
1446
1595
  }
1447
1596
  for (const candidate of candidates) {
@@ -1451,7 +1600,9 @@ function scheduleWakeupResultText(toolName, rawResult, rawContent) {
1451
1600
  const clampedDelaySeconds = typeof candidate.clampedDelaySeconds === "number"
1452
1601
  ? formatDurationSeconds(candidate.clampedDelaySeconds)
1453
1602
  : undefined;
1454
- if (!scheduledFor || !clampedDelaySeconds || typeof candidate.wasClamped !== "boolean") {
1603
+ if (!scheduledFor ||
1604
+ !clampedDelaySeconds ||
1605
+ typeof candidate.wasClamped !== "boolean") {
1455
1606
  continue;
1456
1607
  }
1457
1608
  return [
@@ -1480,7 +1631,10 @@ function pushNotificationResultText(toolName, rawResult, rawContent, rawInput) {
1480
1631
  }
1481
1632
  const inputMessage = nonEmptyString(asRecordOrNull(rawInput)?.message);
1482
1633
  const candidates = resultRecordCandidates(rawResult, rawContent);
1483
- for (const parsed of [parseJsonCandidate(rawResult), parseJsonCandidate(rawContent)]) {
1634
+ for (const parsed of [
1635
+ parseJsonCandidate(rawResult),
1636
+ parseJsonCandidate(rawContent),
1637
+ ]) {
1484
1638
  candidates.push(...resultRecordCandidates(parsed, undefined));
1485
1639
  }
1486
1640
  for (const candidate of candidates) {
@@ -1505,7 +1659,8 @@ function pushNotificationResultText(toolName, rawResult, rawContent, rawInput) {
1505
1659
  if (disabledReason) {
1506
1660
  lines.push(`Disabled reason: ${disabledReason}`);
1507
1661
  }
1508
- if (typeof candidate.idleSec === "number" && Number.isFinite(candidate.idleSec)) {
1662
+ if (typeof candidate.idleSec === "number" &&
1663
+ Number.isFinite(candidate.idleSec)) {
1509
1664
  lines.push(`Idle time: ${formatDurationSeconds(candidate.idleSec)}`);
1510
1665
  }
1511
1666
  pushBooleanField(lines, "App focused", candidate.hasFocus);
@@ -1555,11 +1710,15 @@ function remoteTriggerResultFields(toolName, rawResult, rawContent) {
1555
1710
  return undefined;
1556
1711
  }
1557
1712
  const candidates = resultRecordCandidates(rawResult, rawContent);
1558
- for (const parsed of [parseJsonCandidate(rawResult), parseJsonCandidate(rawContent)]) {
1713
+ for (const parsed of [
1714
+ parseJsonCandidate(rawResult),
1715
+ parseJsonCandidate(rawContent),
1716
+ ]) {
1559
1717
  candidates.push(...resultRecordCandidates(parsed, undefined));
1560
1718
  }
1561
1719
  for (const candidate of candidates) {
1562
- if (typeof candidate.status !== "number" || typeof candidate.json !== "string") {
1720
+ if (typeof candidate.status !== "number" ||
1721
+ typeof candidate.json !== "string") {
1563
1722
  continue;
1564
1723
  }
1565
1724
  const lines = [`Status: ${candidate.status}`];
@@ -1567,11 +1726,9 @@ function remoteTriggerResultFields(toolName, rawResult, rawContent) {
1567
1726
  if (summary) {
1568
1727
  lines.push(`Summary: ${summary}`);
1569
1728
  }
1570
- else {
1571
- const response = compactParsedJsonString(candidate.json);
1572
- if (response) {
1573
- lines.push(`Response: ${response}`);
1574
- }
1729
+ const response = compactParsedJsonString(candidate.json);
1730
+ if (response) {
1731
+ lines.push(`Response: ${response}`);
1575
1732
  }
1576
1733
  return { output: lines.join("\n"), failed: candidate.status >= 400 };
1577
1734
  }
@@ -1601,7 +1758,10 @@ function replResultFields(toolName, rawResult, rawContent) {
1601
1758
  return undefined;
1602
1759
  }
1603
1760
  const candidates = resultRecordCandidates(rawResult, rawContent);
1604
- for (const parsed of [parseJsonCandidate(rawResult), parseJsonCandidate(rawContent)]) {
1761
+ for (const parsed of [
1762
+ parseJsonCandidate(rawResult),
1763
+ parseJsonCandidate(rawContent),
1764
+ ]) {
1605
1765
  candidates.push(...resultRecordCandidates(parsed, undefined));
1606
1766
  }
1607
1767
  for (const candidate of candidates) {
@@ -1647,7 +1807,10 @@ function replResultFields(toolName, rawResult, rawContent) {
1647
1807
  }
1648
1808
  function collectResultCandidates(rawResult, rawContent) {
1649
1809
  const candidates = resultRecordCandidates(rawResult, rawContent);
1650
- for (const parsed of [parseJsonCandidate(rawResult), parseJsonCandidate(rawContent)]) {
1810
+ for (const parsed of [
1811
+ parseJsonCandidate(rawResult),
1812
+ parseJsonCandidate(rawContent),
1813
+ ]) {
1651
1814
  candidates.push(...resultRecordCandidates(parsed, undefined));
1652
1815
  }
1653
1816
  return candidates;
@@ -1666,7 +1829,8 @@ function parseSkillResult(toolName, rawResult, rawContent) {
1666
1829
  if (!agentId || typeof candidate.result !== "string") {
1667
1830
  continue;
1668
1831
  }
1669
- if (candidate.background !== undefined && typeof candidate.background !== "boolean") {
1832
+ if (candidate.background !== undefined &&
1833
+ typeof candidate.background !== "boolean") {
1670
1834
  continue;
1671
1835
  }
1672
1836
  return {
@@ -1703,7 +1867,8 @@ function monitorResultFields(toolName, rawResult, rawContent) {
1703
1867
  }
1704
1868
  for (const candidate of collectResultCandidates(rawResult, rawContent)) {
1705
1869
  const taskId = nonEmptyString(candidate.taskId);
1706
- const timeoutMs = typeof candidate.timeoutMs === "number" && Number.isFinite(candidate.timeoutMs)
1870
+ const timeoutMs = typeof candidate.timeoutMs === "number" &&
1871
+ Number.isFinite(candidate.timeoutMs)
1707
1872
  ? Math.max(0, Math.trunc(candidate.timeoutMs))
1708
1873
  : undefined;
1709
1874
  const persistent = typeof candidate.persistent === "boolean"
@@ -1713,7 +1878,9 @@ function monitorResultFields(toolName, rawResult, rawContent) {
1713
1878
  : timeoutMs !== undefined
1714
1879
  ? false
1715
1880
  : undefined;
1716
- const isStructuredMonitorOutput = taskId !== undefined || timeoutMs !== undefined || persistent !== undefined;
1881
+ const isStructuredMonitorOutput = taskId !== undefined ||
1882
+ timeoutMs !== undefined ||
1883
+ persistent !== undefined;
1717
1884
  if (!isStructuredMonitorOutput) {
1718
1885
  continue;
1719
1886
  }
@@ -1832,7 +1999,10 @@ function enterPlanModeStructuredOutputHandled(toolName, rawResult, rawContent) {
1832
1999
  return false;
1833
2000
  }
1834
2001
  const candidates = resultRecordCandidates(rawResult, rawContent);
1835
- for (const parsed of [parseJsonCandidate(rawResult), parseJsonCandidate(rawContent)]) {
2002
+ for (const parsed of [
2003
+ parseJsonCandidate(rawResult),
2004
+ parseJsonCandidate(rawContent),
2005
+ ]) {
1836
2006
  candidates.push(...resultRecordCandidates(parsed, undefined));
1837
2007
  }
1838
2008
  for (const candidate of candidates) {
@@ -1882,10 +2052,12 @@ function webFetchResultText(toolName, rawResult, rawContent) {
1882
2052
  const codeText = nonEmptyString(candidate.codeText);
1883
2053
  lines.push(`Status: ${candidate.code}${codeText ? ` ${codeText}` : ""}`);
1884
2054
  }
1885
- if (typeof candidate.bytes === "number" && Number.isFinite(candidate.bytes)) {
2055
+ if (typeof candidate.bytes === "number" &&
2056
+ Number.isFinite(candidate.bytes)) {
1886
2057
  lines.push(`Bytes: ${Math.max(0, Math.trunc(candidate.bytes))}`);
1887
2058
  }
1888
- if (typeof candidate.durationMs === "number" && Number.isFinite(candidate.durationMs)) {
2059
+ if (typeof candidate.durationMs === "number" &&
2060
+ Number.isFinite(candidate.durationMs)) {
1889
2061
  lines.push(`Duration: ${Math.max(0, Math.trunc(candidate.durationMs))}ms`);
1890
2062
  }
1891
2063
  return lines.length > 0 ? lines.join("\n") : undefined;
@@ -1901,7 +2073,9 @@ export function buildToolResultFields(isError, rawContent, base, rawResult, _con
1901
2073
  if (outputMetadata) {
1902
2074
  fields.output_metadata = outputMetadata;
1903
2075
  }
1904
- const skillResult = !isError ? parseSkillResult(toolName, rawResult, rawContent) : undefined;
2076
+ const skillResult = !isError
2077
+ ? parseSkillResult(toolName, rawResult, rawContent)
2078
+ : undefined;
1905
2079
  if (skillResult) {
1906
2080
  fields.title = `${SKILL_TOOL_NAME}: ${skillDisplayName(skillResult.commandName)}`;
1907
2081
  if (!skillResult.success) {
@@ -1914,7 +2088,9 @@ export function buildToolResultFields(isError, rawContent, base, rawResult, _con
1914
2088
  const output = skillResult.result.trim();
1915
2089
  if (output) {
1916
2090
  fields.raw_output = output;
1917
- fields.content = [{ type: "content", content: { type: "text", text: output } }];
2091
+ fields.content = [
2092
+ { type: "content", content: { type: "text", text: output } },
2093
+ ];
1918
2094
  }
1919
2095
  return fields;
1920
2096
  }
@@ -1924,13 +2100,19 @@ export function buildToolResultFields(isError, rawContent, base, rawResult, _con
1924
2100
  : undefined;
1925
2101
  if (imageReadText !== undefined) {
1926
2102
  fields.raw_output = imageReadText;
1927
- fields.content = [{ type: "content", content: { type: "text", text: imageReadText } }];
2103
+ fields.content = [
2104
+ { type: "content", content: { type: "text", text: imageReadText } },
2105
+ ];
1928
2106
  return fields;
1929
2107
  }
1930
- const fileUnchangedText = !isError && toolName === "Read" ? fileUnchangedResultText(rawResult, rawContent) : "";
2108
+ const fileUnchangedText = !isError && toolName === "Read"
2109
+ ? fileUnchangedResultText(rawResult, rawContent)
2110
+ : "";
1931
2111
  if (fileUnchangedText) {
1932
2112
  fields.raw_output = fileUnchangedText;
1933
- fields.content = [{ type: "content", content: { type: "text", text: fileUnchangedText } }];
2113
+ fields.content = [
2114
+ { type: "content", content: { type: "text", text: fileUnchangedText } },
2115
+ ];
1934
2116
  return fields;
1935
2117
  }
1936
2118
  const agentTitle = !isError && toolName === "Agent"
@@ -1943,7 +2125,12 @@ export function buildToolResultFields(isError, rawContent, base, rawResult, _con
1943
2125
  if (readMcpResourceError) {
1944
2126
  fields.status = "failed";
1945
2127
  fields.raw_output = readMcpResourceError;
1946
- fields.content = [{ type: "content", content: { type: "text", text: readMcpResourceError } }];
2128
+ fields.content = [
2129
+ {
2130
+ type: "content",
2131
+ content: { type: "text", text: readMcpResourceError },
2132
+ },
2133
+ ];
1947
2134
  return fields;
1948
2135
  }
1949
2136
  const readMcpResourceDirOutput = !isError
@@ -1952,20 +2139,31 @@ export function buildToolResultFields(isError, rawContent, base, rawResult, _con
1952
2139
  if (readMcpResourceDirOutput !== undefined) {
1953
2140
  fields.raw_output = readMcpResourceDirOutput;
1954
2141
  fields.content = [
1955
- { type: "content", content: { type: "text", text: readMcpResourceDirOutput } },
2142
+ {
2143
+ type: "content",
2144
+ content: { type: "text", text: readMcpResourceDirOutput },
2145
+ },
1956
2146
  ];
1957
2147
  return fields;
1958
2148
  }
1959
- const searchOutput = !isError ? searchResultText(toolName, rawResult, rawContent) : undefined;
2149
+ const searchOutput = !isError
2150
+ ? searchResultText(toolName, rawResult, rawContent)
2151
+ : undefined;
1960
2152
  if (searchOutput !== undefined) {
1961
2153
  fields.raw_output = searchOutput;
1962
- fields.content = [{ type: "content", content: { type: "text", text: searchOutput } }];
2154
+ fields.content = [
2155
+ { type: "content", content: { type: "text", text: searchOutput } },
2156
+ ];
1963
2157
  return fields;
1964
2158
  }
1965
- const webFetchOutput = !isError ? webFetchResultText(toolName, rawResult, rawContent) : undefined;
2159
+ const webFetchOutput = !isError
2160
+ ? webFetchResultText(toolName, rawResult, rawContent)
2161
+ : undefined;
1966
2162
  if (webFetchOutput !== undefined) {
1967
2163
  fields.raw_output = webFetchOutput;
1968
- fields.content = [{ type: "content", content: { type: "text", text: webFetchOutput } }];
2164
+ fields.content = [
2165
+ { type: "content", content: { type: "text", text: webFetchOutput } },
2166
+ ];
1969
2167
  return fields;
1970
2168
  }
1971
2169
  const worktreeOutput = !isError
@@ -1975,7 +2173,10 @@ export function buildToolResultFields(isError, rawContent, base, rawResult, _con
1975
2173
  if (worktreeOutput.output) {
1976
2174
  fields.raw_output = worktreeOutput.output;
1977
2175
  fields.content = [
1978
- { type: "content", content: { type: "text", text: worktreeOutput.output } },
2176
+ {
2177
+ type: "content",
2178
+ content: { type: "text", text: worktreeOutput.output },
2179
+ },
1979
2180
  ];
1980
2181
  }
1981
2182
  return fields;
@@ -1985,7 +2186,9 @@ export function buildToolResultFields(isError, rawContent, base, rawResult, _con
1985
2186
  : undefined;
1986
2187
  if (cronOutput !== undefined) {
1987
2188
  fields.raw_output = cronOutput;
1988
- fields.content = [{ type: "content", content: { type: "text", text: cronOutput } }];
2189
+ fields.content = [
2190
+ { type: "content", content: { type: "text", text: cronOutput } },
2191
+ ];
1989
2192
  return fields;
1990
2193
  }
1991
2194
  const scheduleWakeupOutput = !isError
@@ -1994,7 +2197,10 @@ export function buildToolResultFields(isError, rawContent, base, rawResult, _con
1994
2197
  if (scheduleWakeupOutput !== undefined) {
1995
2198
  fields.raw_output = scheduleWakeupOutput;
1996
2199
  fields.content = [
1997
- { type: "content", content: { type: "text", text: scheduleWakeupOutput } },
2200
+ {
2201
+ type: "content",
2202
+ content: { type: "text", text: scheduleWakeupOutput },
2203
+ },
1998
2204
  ];
1999
2205
  return fields;
2000
2206
  }
@@ -2004,7 +2210,10 @@ export function buildToolResultFields(isError, rawContent, base, rawResult, _con
2004
2210
  if (pushNotificationOutput !== undefined) {
2005
2211
  fields.raw_output = pushNotificationOutput;
2006
2212
  fields.content = [
2007
- { type: "content", content: { type: "text", text: pushNotificationOutput } },
2213
+ {
2214
+ type: "content",
2215
+ content: { type: "text", text: pushNotificationOutput },
2216
+ },
2008
2217
  ];
2009
2218
  return fields;
2010
2219
  }
@@ -2020,7 +2229,10 @@ export function buildToolResultFields(isError, rawContent, base, rawResult, _con
2020
2229
  if (remoteTriggerOutput.output) {
2021
2230
  fields.raw_output = remoteTriggerOutput.output;
2022
2231
  fields.content = [
2023
- { type: "content", content: { type: "text", text: remoteTriggerOutput.output } },
2232
+ {
2233
+ type: "content",
2234
+ content: { type: "text", text: remoteTriggerOutput.output },
2235
+ },
2024
2236
  ];
2025
2237
  }
2026
2238
  return fields;
@@ -2050,7 +2262,10 @@ export function buildToolResultFields(isError, rawContent, base, rawResult, _con
2050
2262
  if (backgroundLaunchOutput.output) {
2051
2263
  fields.raw_output = backgroundLaunchOutput.output;
2052
2264
  fields.content = [
2053
- { type: "content", content: { type: "text", text: backgroundLaunchOutput.output } },
2265
+ {
2266
+ type: "content",
2267
+ content: { type: "text", text: backgroundLaunchOutput.output },
2268
+ },
2054
2269
  ];
2055
2270
  }
2056
2271
  return fields;
@@ -2066,15 +2281,21 @@ export function buildToolResultFields(isError, rawContent, base, rawResult, _con
2066
2281
  fields.raw_output = rawOutput;
2067
2282
  }
2068
2283
  if (!isError && isTaskToolName(toolName)) {
2069
- if (toolName === "TaskUpdate" && taskUpdateSucceeded(rawResult, rawContent) === false) {
2284
+ if (toolName === "TaskUpdate" &&
2285
+ taskUpdateSucceeded(rawResult, rawContent) === false) {
2070
2286
  fields.status = "failed";
2071
2287
  }
2072
2288
  const taskOutput = taskToolResultText(toolName, rawResult, rawContent, base?.raw_input);
2073
2289
  if (taskOutput) {
2074
- fields.content = [{ type: "content", content: { type: "text", text: taskOutput } }];
2290
+ fields.content = [
2291
+ { type: "content", content: { type: "text", text: taskOutput } },
2292
+ ];
2075
2293
  return fields;
2076
2294
  }
2077
- if (toolName === "TaskCreate" || toolName === "TaskUpdate" || toolName === "TaskOutput" || toolName === "TaskStop") {
2295
+ if (toolName === "TaskCreate" ||
2296
+ toolName === "TaskUpdate" ||
2297
+ toolName === "TaskOutput" ||
2298
+ toolName === "TaskStop") {
2078
2299
  return fields;
2079
2300
  }
2080
2301
  }
@@ -2108,7 +2329,9 @@ export function buildToolResultFields(isError, rawContent, base, rawResult, _con
2108
2329
  }
2109
2330
  }
2110
2331
  if (rawOutput) {
2111
- fields.content = [{ type: "content", content: { type: "text", text: rawOutput } }];
2332
+ fields.content = [
2333
+ { type: "content", content: { type: "text", text: rawOutput } },
2334
+ ];
2112
2335
  }
2113
2336
  return fields;
2114
2337
  }