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.
- package/README.md +2 -3
- package/agent-sdk/dist/bridge/account_metadata.js +6 -2
- package/agent-sdk/dist/bridge/agents.js +9 -3
- package/agent-sdk/dist/bridge/available_commands.js +13 -3
- package/agent-sdk/dist/bridge/command_lifecycle.js +79 -4
- package/agent-sdk/dist/bridge/command_scheduler.js +7 -2
- package/agent-sdk/dist/bridge/command_session_control.js +5 -1
- package/agent-sdk/dist/bridge/command_session_data.js +225 -10
- package/agent-sdk/dist/bridge/commands.js +48 -11
- package/agent-sdk/dist/bridge/error_classification.js +5 -1
- package/agent-sdk/dist/bridge/events.js +45 -7
- package/agent-sdk/dist/bridge/history.js +33 -10
- package/agent-sdk/dist/bridge/logger.js +19 -3
- package/agent-sdk/dist/bridge/mcp.js +7 -2
- package/agent-sdk/dist/bridge/mcp_auth_adapter.js +4 -2
- package/agent-sdk/dist/bridge/mcp_metadata.js +113 -39
- package/agent-sdk/dist/bridge/mcp_monitor.js +6 -1
- package/agent-sdk/dist/bridge/message_handlers.js +288 -66
- package/agent-sdk/dist/bridge/model_metadata.js +19 -6
- package/agent-sdk/dist/bridge/permissions.js +32 -8
- package/agent-sdk/dist/bridge/session_lifecycle.js +224 -45
- package/agent-sdk/dist/bridge/state_parsing.js +22 -8
- package/agent-sdk/dist/bridge/tasks.js +62 -22
- package/agent-sdk/dist/bridge/tool_calls.js +82 -25
- package/agent-sdk/dist/bridge/tooling.js +304 -86
- package/agent-sdk/dist/bridge/user_interaction.js +45 -13
- package/agent-sdk/dist/bridge.js +200 -104
- package/package.json +8 -8
|
@@ -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" ||
|
|
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)
|
|
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 ||
|
|
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
|
|
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
|
|
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
|
|
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") &&
|
|
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_")
|
|
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 [
|
|
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 [
|
|
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 [
|
|
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)
|
|
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
|
|
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" &&
|
|
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
|
-
|
|
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 =
|
|
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
|
}
|
|
@@ -651,7 +700,10 @@ export function extractText(value) {
|
|
|
651
700
|
if (typeof entry === "string") {
|
|
652
701
|
return entry;
|
|
653
702
|
}
|
|
654
|
-
if (entry &&
|
|
703
|
+
if (entry &&
|
|
704
|
+
typeof entry === "object" &&
|
|
705
|
+
"text" in entry &&
|
|
706
|
+
typeof entry.text === "string") {
|
|
655
707
|
return entry.text;
|
|
656
708
|
}
|
|
657
709
|
return "";
|
|
@@ -659,7 +711,10 @@ export function extractText(value) {
|
|
|
659
711
|
.filter((part) => part.length > 0)
|
|
660
712
|
.join("\n");
|
|
661
713
|
}
|
|
662
|
-
if (value &&
|
|
714
|
+
if (value &&
|
|
715
|
+
typeof value === "object" &&
|
|
716
|
+
"text" in value &&
|
|
717
|
+
typeof value.text === "string") {
|
|
663
718
|
return value.text;
|
|
664
719
|
}
|
|
665
720
|
return "";
|
|
@@ -744,7 +799,15 @@ function writeDiffFromInput(rawInput) {
|
|
|
744
799
|
if (!filePath || !content) {
|
|
745
800
|
return [];
|
|
746
801
|
}
|
|
747
|
-
return [
|
|
802
|
+
return [
|
|
803
|
+
{
|
|
804
|
+
type: "diff",
|
|
805
|
+
old_path: filePath,
|
|
806
|
+
new_path: filePath,
|
|
807
|
+
old: "",
|
|
808
|
+
new: content,
|
|
809
|
+
},
|
|
810
|
+
];
|
|
748
811
|
}
|
|
749
812
|
function editDiffFromInput(rawInput) {
|
|
750
813
|
const input = asRecordOrNull(rawInput);
|
|
@@ -765,7 +828,15 @@ function editDiffFromInput(rawInput) {
|
|
|
765
828
|
if (!filePath || (!oldText && !newText)) {
|
|
766
829
|
return [];
|
|
767
830
|
}
|
|
768
|
-
return [
|
|
831
|
+
return [
|
|
832
|
+
{
|
|
833
|
+
type: "diff",
|
|
834
|
+
old_path: filePath,
|
|
835
|
+
new_path: filePath,
|
|
836
|
+
old: oldText,
|
|
837
|
+
new: newText,
|
|
838
|
+
},
|
|
839
|
+
];
|
|
769
840
|
}
|
|
770
841
|
function writeDiffFromResult(rawContent) {
|
|
771
842
|
const candidates = Array.isArray(rawContent) ? rawContent : [rawContent];
|
|
@@ -780,15 +851,24 @@ function writeDiffFromResult(rawContent) {
|
|
|
780
851
|
? record.file_path
|
|
781
852
|
: "";
|
|
782
853
|
const content = typeof record.content === "string" ? record.content : "";
|
|
783
|
-
const originalRaw = "originalFile" in record
|
|
854
|
+
const originalRaw = "originalFile" in record
|
|
855
|
+
? record.originalFile
|
|
856
|
+
: "original_file" in record
|
|
857
|
+
? record.original_file
|
|
858
|
+
: undefined;
|
|
784
859
|
const gitDiff = asRecordOrNull(record.gitDiff);
|
|
785
|
-
const repository = typeof gitDiff?.repository === "string" &&
|
|
860
|
+
const repository = typeof gitDiff?.repository === "string" &&
|
|
861
|
+
gitDiff.repository.trim().length > 0
|
|
786
862
|
? gitDiff.repository.trim()
|
|
787
863
|
: undefined;
|
|
788
864
|
if (!filePath || !content || originalRaw === undefined) {
|
|
789
865
|
continue;
|
|
790
866
|
}
|
|
791
|
-
const original = typeof originalRaw === "string"
|
|
867
|
+
const original = typeof originalRaw === "string"
|
|
868
|
+
? originalRaw
|
|
869
|
+
: originalRaw === null
|
|
870
|
+
? ""
|
|
871
|
+
: "";
|
|
792
872
|
return [
|
|
793
873
|
{
|
|
794
874
|
type: "diff",
|
|
@@ -831,7 +911,8 @@ function editDiffFromResult(rawResult, rawInput) {
|
|
|
831
911
|
if (candidatePath && candidatePath !== filePath) {
|
|
832
912
|
continue;
|
|
833
913
|
}
|
|
834
|
-
const repository = typeof gitDiff?.repository === "string" &&
|
|
914
|
+
const repository = typeof gitDiff?.repository === "string" &&
|
|
915
|
+
gitDiff.repository.trim().length > 0
|
|
835
916
|
? gitDiff.repository.trim()
|
|
836
917
|
: undefined;
|
|
837
918
|
return [
|
|
@@ -921,12 +1002,17 @@ function firstSearchRecord(toolName, rawResult, rawContent) {
|
|
|
921
1002
|
return undefined;
|
|
922
1003
|
}
|
|
923
1004
|
const candidates = resultRecordCandidates(rawResult, rawContent);
|
|
924
|
-
for (const parsed of [
|
|
1005
|
+
for (const parsed of [
|
|
1006
|
+
parseJsonCandidate(rawResult),
|
|
1007
|
+
parseJsonCandidate(rawContent),
|
|
1008
|
+
]) {
|
|
925
1009
|
candidates.push(...resultRecordCandidates(parsed, undefined));
|
|
926
1010
|
}
|
|
927
1011
|
return candidates.find((candidate) => {
|
|
928
1012
|
if (toolName === "Glob") {
|
|
929
|
-
return Array.isArray(candidate.filenames) ||
|
|
1013
|
+
return (Array.isArray(candidate.filenames) ||
|
|
1014
|
+
"numFiles" in candidate ||
|
|
1015
|
+
"truncated" in candidate);
|
|
930
1016
|
}
|
|
931
1017
|
return (Array.isArray(candidate.filenames) ||
|
|
932
1018
|
"numFiles" in candidate ||
|
|
@@ -937,7 +1023,9 @@ function firstSearchRecord(toolName, rawResult, rawContent) {
|
|
|
937
1023
|
}
|
|
938
1024
|
function recordNumber(record, key) {
|
|
939
1025
|
const value = record[key];
|
|
940
|
-
return typeof value === "number" && Number.isFinite(value)
|
|
1026
|
+
return typeof value === "number" && Number.isFinite(value)
|
|
1027
|
+
? value
|
|
1028
|
+
: undefined;
|
|
941
1029
|
}
|
|
942
1030
|
function recordNonNegativeInteger(record, key) {
|
|
943
1031
|
return nonNegativeInteger(record[key]);
|
|
@@ -993,7 +1081,8 @@ function grepResultText(record) {
|
|
|
993
1081
|
const numFiles = totalFiles ??
|
|
994
1082
|
(legacyNumFiles !== 0 || !hasVisibleMatches ? legacyNumFiles : undefined) ??
|
|
995
1083
|
(filenames.length > 0 ? filenames.length : undefined);
|
|
996
|
-
const numLines = recordNonNegativeInteger(record, "totalLines") ??
|
|
1084
|
+
const numLines = recordNonNegativeInteger(record, "totalLines") ??
|
|
1085
|
+
recordNonNegativeInteger(record, "numLines");
|
|
997
1086
|
const numMatches = recordNumber(record, "numMatches");
|
|
998
1087
|
const appliedLimit = recordNumber(record, "appliedLimit");
|
|
999
1088
|
const appliedOffset = recordNumber(record, "appliedOffset");
|
|
@@ -1046,12 +1135,19 @@ function worktreeResultFields(toolName, rawResult, rawContent) {
|
|
|
1046
1135
|
return undefined;
|
|
1047
1136
|
}
|
|
1048
1137
|
const candidates = resultRecordCandidates(rawResult, rawContent);
|
|
1049
|
-
for (const parsed of [
|
|
1138
|
+
for (const parsed of [
|
|
1139
|
+
parseJsonCandidate(rawResult),
|
|
1140
|
+
parseJsonCandidate(rawContent),
|
|
1141
|
+
]) {
|
|
1050
1142
|
candidates.push(...resultRecordCandidates(parsed, undefined));
|
|
1051
1143
|
}
|
|
1052
1144
|
for (const candidate of candidates) {
|
|
1053
|
-
const branch = typeof candidate.worktreeBranch === "string"
|
|
1054
|
-
|
|
1145
|
+
const branch = typeof candidate.worktreeBranch === "string"
|
|
1146
|
+
? candidate.worktreeBranch.trim()
|
|
1147
|
+
: "";
|
|
1148
|
+
const path = typeof candidate.worktreePath === "string"
|
|
1149
|
+
? candidate.worktreePath.trim()
|
|
1150
|
+
: "";
|
|
1055
1151
|
const output = branch ? `Branch: ${branch}` : path ? `Path: ${path}` : "";
|
|
1056
1152
|
const isStructuredWorktreeOutput = "message" in candidate ||
|
|
1057
1153
|
"worktreeBranch" in candidate ||
|
|
@@ -1117,8 +1213,24 @@ const CRON_WEEKDAY_NAMES = [
|
|
|
1117
1213
|
"Friday",
|
|
1118
1214
|
"Saturday",
|
|
1119
1215
|
];
|
|
1120
|
-
const CRON_MONTH_ALIASES = new Map([
|
|
1121
|
-
|
|
1216
|
+
const CRON_MONTH_ALIASES = new Map([
|
|
1217
|
+
"JAN",
|
|
1218
|
+
"FEB",
|
|
1219
|
+
"MAR",
|
|
1220
|
+
"APR",
|
|
1221
|
+
"MAY",
|
|
1222
|
+
"JUN",
|
|
1223
|
+
"JUL",
|
|
1224
|
+
"AUG",
|
|
1225
|
+
"SEP",
|
|
1226
|
+
"OCT",
|
|
1227
|
+
"NOV",
|
|
1228
|
+
"DEC",
|
|
1229
|
+
].map((name, index) => [name, index + 1]));
|
|
1230
|
+
const CRON_WEEKDAY_ALIASES = new Map(["SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT"].map((name, index) => [
|
|
1231
|
+
name,
|
|
1232
|
+
index,
|
|
1233
|
+
]));
|
|
1122
1234
|
function parseCronValue(value, min, max, aliases) {
|
|
1123
1235
|
const normalized = value.trim().toUpperCase();
|
|
1124
1236
|
const aliased = aliases?.get(normalized);
|
|
@@ -1136,14 +1248,18 @@ function parseCronField(rawField, min, max, aliases) {
|
|
|
1136
1248
|
const stepMatch = raw.match(/^\*\/(\d+)$/);
|
|
1137
1249
|
if (stepMatch) {
|
|
1138
1250
|
const step = Number(stepMatch[1]);
|
|
1139
|
-
return Number.isInteger(step) && step > 0
|
|
1251
|
+
return Number.isInteger(step) && step > 0
|
|
1252
|
+
? { kind: "step", raw, step }
|
|
1253
|
+
: { kind: "unsupported", raw };
|
|
1140
1254
|
}
|
|
1141
1255
|
if (raw.includes(",")) {
|
|
1142
1256
|
const values = raw
|
|
1143
1257
|
.split(",")
|
|
1144
1258
|
.map((part) => parseCronValue(part, min, max, aliases))
|
|
1145
1259
|
.filter((value) => value !== undefined);
|
|
1146
|
-
return values.length === raw.split(",").length
|
|
1260
|
+
return values.length === raw.split(",").length
|
|
1261
|
+
? { kind: "list", raw, values }
|
|
1262
|
+
: { kind: "unsupported", raw };
|
|
1147
1263
|
}
|
|
1148
1264
|
const rangeMatch = raw.match(/^([^/-]+)-([^/-]+)$/);
|
|
1149
1265
|
if (rangeMatch) {
|
|
@@ -1154,7 +1270,9 @@ function parseCronField(rawField, min, max, aliases) {
|
|
|
1154
1270
|
: { kind: "unsupported", raw };
|
|
1155
1271
|
}
|
|
1156
1272
|
const value = parseCronValue(raw, min, max, aliases);
|
|
1157
|
-
return value !== undefined
|
|
1273
|
+
return value !== undefined
|
|
1274
|
+
? { kind: "single", raw, value }
|
|
1275
|
+
: { kind: "unsupported", raw };
|
|
1158
1276
|
}
|
|
1159
1277
|
function isCronAny(field) {
|
|
1160
1278
|
return field.kind === "any";
|
|
@@ -1195,12 +1313,16 @@ function weekdayDescription(field) {
|
|
|
1195
1313
|
return "day";
|
|
1196
1314
|
}
|
|
1197
1315
|
if (field.kind === "list") {
|
|
1198
|
-
const normalized = [
|
|
1316
|
+
const normalized = [
|
|
1317
|
+
...new Set(field.values.map((value) => (value === 7 ? 0 : value))),
|
|
1318
|
+
].sort((left, right) => left - right);
|
|
1199
1319
|
if (normalized.length === 2 && normalized[0] === 0 && normalized[1] === 6) {
|
|
1200
1320
|
return "weekend day";
|
|
1201
1321
|
}
|
|
1202
1322
|
const names = normalized.map(weekdayName);
|
|
1203
|
-
return names.every((name) => name !== undefined)
|
|
1323
|
+
return names.every((name) => name !== undefined)
|
|
1324
|
+
? joinEnglishList(names)
|
|
1325
|
+
: undefined;
|
|
1204
1326
|
}
|
|
1205
1327
|
return undefined;
|
|
1206
1328
|
}
|
|
@@ -1211,7 +1333,9 @@ function hourlyScheduleText(minute) {
|
|
|
1211
1333
|
if (minute.kind !== "single") {
|
|
1212
1334
|
return undefined;
|
|
1213
1335
|
}
|
|
1214
|
-
return minute.value === 0
|
|
1336
|
+
return minute.value === 0
|
|
1337
|
+
? "Every hour on the hour"
|
|
1338
|
+
: `Every hour at minute ${padCronNumber(minute.value)}`;
|
|
1215
1339
|
}
|
|
1216
1340
|
function cronScheduleFromExpression(cron) {
|
|
1217
1341
|
const parts = cron.trim().split(/\s+/);
|
|
@@ -1239,7 +1363,9 @@ function cronScheduleFromExpression(cron) {
|
|
|
1239
1363
|
return hourlyScheduleText(minute);
|
|
1240
1364
|
}
|
|
1241
1365
|
if (everyDay && minute.kind === "single" && hour.kind === "step") {
|
|
1242
|
-
const suffix = minute.value === 0
|
|
1366
|
+
const suffix = minute.value === 0
|
|
1367
|
+
? "on the hour"
|
|
1368
|
+
: `at minute ${padCronNumber(minute.value)}`;
|
|
1243
1369
|
return `Every ${hour.step} ${pluralUnit(hour.step, "hour")} ${suffix}`;
|
|
1244
1370
|
}
|
|
1245
1371
|
const time = cronTime(hour, minute);
|
|
@@ -1264,13 +1390,17 @@ function cronScheduleFromExpression(cron) {
|
|
|
1264
1390
|
if (dayOfMonth.kind === "single" && isCronAny(dayOfWeek)) {
|
|
1265
1391
|
if (month.kind === "single") {
|
|
1266
1392
|
const monthLabel = monthName(month.value);
|
|
1267
|
-
return monthLabel
|
|
1393
|
+
return monthLabel
|
|
1394
|
+
? `Every ${monthLabel} ${dayOfMonth.value} at ${time}`
|
|
1395
|
+
: undefined;
|
|
1268
1396
|
}
|
|
1269
1397
|
if (month.kind === "step") {
|
|
1270
1398
|
return `Every ${month.step} ${pluralUnit(month.step, "month")} on day ${dayOfMonth.value} at ${time}`;
|
|
1271
1399
|
}
|
|
1272
1400
|
}
|
|
1273
|
-
if (isCronAny(dayOfMonth) &&
|
|
1401
|
+
if (isCronAny(dayOfMonth) &&
|
|
1402
|
+
month.kind === "single" &&
|
|
1403
|
+
isCronAny(dayOfWeek)) {
|
|
1274
1404
|
const monthLabel = monthName(month.value);
|
|
1275
1405
|
return monthLabel ? `Every day in ${monthLabel} at ${time}` : undefined;
|
|
1276
1406
|
}
|
|
@@ -1285,7 +1415,11 @@ function normalizeHumanSchedule(value) {
|
|
|
1285
1415
|
if (hourlyMinute) {
|
|
1286
1416
|
const minute = Number(hourlyMinute[1]);
|
|
1287
1417
|
if (Number.isInteger(minute) && minute >= 0 && minute <= 59) {
|
|
1288
|
-
return hourlyScheduleText({
|
|
1418
|
+
return hourlyScheduleText({
|
|
1419
|
+
kind: "single",
|
|
1420
|
+
raw: hourlyMinute[1],
|
|
1421
|
+
value: minute,
|
|
1422
|
+
});
|
|
1289
1423
|
}
|
|
1290
1424
|
}
|
|
1291
1425
|
return text;
|
|
@@ -1317,13 +1451,17 @@ function cronCreateResultText(candidate, rawInput) {
|
|
|
1317
1451
|
return lines.join("\n");
|
|
1318
1452
|
}
|
|
1319
1453
|
function cronDeleteResultText(candidate) {
|
|
1320
|
-
return typeof candidate.id === "string"
|
|
1454
|
+
return typeof candidate.id === "string"
|
|
1455
|
+
? `Schedule ID: ${candidate.id}`
|
|
1456
|
+
: undefined;
|
|
1321
1457
|
}
|
|
1322
1458
|
function cronListResultText(candidate) {
|
|
1323
1459
|
if (!Array.isArray(candidate.jobs)) {
|
|
1324
1460
|
return undefined;
|
|
1325
1461
|
}
|
|
1326
|
-
const jobs = candidate.jobs
|
|
1462
|
+
const jobs = candidate.jobs
|
|
1463
|
+
.map(asRecordOrNull)
|
|
1464
|
+
.filter((job) => job !== null);
|
|
1327
1465
|
if (jobs.length === 0) {
|
|
1328
1466
|
return "Jobs: none";
|
|
1329
1467
|
}
|
|
@@ -1373,7 +1511,10 @@ function cronResultText(toolName, rawResult, rawContent, rawInput) {
|
|
|
1373
1511
|
return undefined;
|
|
1374
1512
|
}
|
|
1375
1513
|
const candidates = resultRecordCandidates(rawResult, rawContent);
|
|
1376
|
-
for (const parsed of [
|
|
1514
|
+
for (const parsed of [
|
|
1515
|
+
parseJsonCandidate(rawResult),
|
|
1516
|
+
parseJsonCandidate(rawContent),
|
|
1517
|
+
]) {
|
|
1377
1518
|
candidates.push(...resultRecordCandidates(parsed, undefined));
|
|
1378
1519
|
}
|
|
1379
1520
|
for (const candidate of candidates) {
|
|
@@ -1441,7 +1582,10 @@ function scheduleWakeupResultText(toolName, rawResult, rawContent) {
|
|
|
1441
1582
|
return undefined;
|
|
1442
1583
|
}
|
|
1443
1584
|
const candidates = resultRecordCandidates(rawResult, rawContent);
|
|
1444
|
-
for (const parsed of [
|
|
1585
|
+
for (const parsed of [
|
|
1586
|
+
parseJsonCandidate(rawResult),
|
|
1587
|
+
parseJsonCandidate(rawContent),
|
|
1588
|
+
]) {
|
|
1445
1589
|
candidates.push(...resultRecordCandidates(parsed, undefined));
|
|
1446
1590
|
}
|
|
1447
1591
|
for (const candidate of candidates) {
|
|
@@ -1451,7 +1595,9 @@ function scheduleWakeupResultText(toolName, rawResult, rawContent) {
|
|
|
1451
1595
|
const clampedDelaySeconds = typeof candidate.clampedDelaySeconds === "number"
|
|
1452
1596
|
? formatDurationSeconds(candidate.clampedDelaySeconds)
|
|
1453
1597
|
: undefined;
|
|
1454
|
-
if (!scheduledFor ||
|
|
1598
|
+
if (!scheduledFor ||
|
|
1599
|
+
!clampedDelaySeconds ||
|
|
1600
|
+
typeof candidate.wasClamped !== "boolean") {
|
|
1455
1601
|
continue;
|
|
1456
1602
|
}
|
|
1457
1603
|
return [
|
|
@@ -1480,7 +1626,10 @@ function pushNotificationResultText(toolName, rawResult, rawContent, rawInput) {
|
|
|
1480
1626
|
}
|
|
1481
1627
|
const inputMessage = nonEmptyString(asRecordOrNull(rawInput)?.message);
|
|
1482
1628
|
const candidates = resultRecordCandidates(rawResult, rawContent);
|
|
1483
|
-
for (const parsed of [
|
|
1629
|
+
for (const parsed of [
|
|
1630
|
+
parseJsonCandidate(rawResult),
|
|
1631
|
+
parseJsonCandidate(rawContent),
|
|
1632
|
+
]) {
|
|
1484
1633
|
candidates.push(...resultRecordCandidates(parsed, undefined));
|
|
1485
1634
|
}
|
|
1486
1635
|
for (const candidate of candidates) {
|
|
@@ -1505,7 +1654,8 @@ function pushNotificationResultText(toolName, rawResult, rawContent, rawInput) {
|
|
|
1505
1654
|
if (disabledReason) {
|
|
1506
1655
|
lines.push(`Disabled reason: ${disabledReason}`);
|
|
1507
1656
|
}
|
|
1508
|
-
if (typeof candidate.idleSec === "number" &&
|
|
1657
|
+
if (typeof candidate.idleSec === "number" &&
|
|
1658
|
+
Number.isFinite(candidate.idleSec)) {
|
|
1509
1659
|
lines.push(`Idle time: ${formatDurationSeconds(candidate.idleSec)}`);
|
|
1510
1660
|
}
|
|
1511
1661
|
pushBooleanField(lines, "App focused", candidate.hasFocus);
|
|
@@ -1555,11 +1705,15 @@ function remoteTriggerResultFields(toolName, rawResult, rawContent) {
|
|
|
1555
1705
|
return undefined;
|
|
1556
1706
|
}
|
|
1557
1707
|
const candidates = resultRecordCandidates(rawResult, rawContent);
|
|
1558
|
-
for (const parsed of [
|
|
1708
|
+
for (const parsed of [
|
|
1709
|
+
parseJsonCandidate(rawResult),
|
|
1710
|
+
parseJsonCandidate(rawContent),
|
|
1711
|
+
]) {
|
|
1559
1712
|
candidates.push(...resultRecordCandidates(parsed, undefined));
|
|
1560
1713
|
}
|
|
1561
1714
|
for (const candidate of candidates) {
|
|
1562
|
-
if (typeof candidate.status !== "number" ||
|
|
1715
|
+
if (typeof candidate.status !== "number" ||
|
|
1716
|
+
typeof candidate.json !== "string") {
|
|
1563
1717
|
continue;
|
|
1564
1718
|
}
|
|
1565
1719
|
const lines = [`Status: ${candidate.status}`];
|
|
@@ -1567,11 +1721,9 @@ function remoteTriggerResultFields(toolName, rawResult, rawContent) {
|
|
|
1567
1721
|
if (summary) {
|
|
1568
1722
|
lines.push(`Summary: ${summary}`);
|
|
1569
1723
|
}
|
|
1570
|
-
|
|
1571
|
-
|
|
1572
|
-
|
|
1573
|
-
lines.push(`Response: ${response}`);
|
|
1574
|
-
}
|
|
1724
|
+
const response = compactParsedJsonString(candidate.json);
|
|
1725
|
+
if (response) {
|
|
1726
|
+
lines.push(`Response: ${response}`);
|
|
1575
1727
|
}
|
|
1576
1728
|
return { output: lines.join("\n"), failed: candidate.status >= 400 };
|
|
1577
1729
|
}
|
|
@@ -1601,7 +1753,10 @@ function replResultFields(toolName, rawResult, rawContent) {
|
|
|
1601
1753
|
return undefined;
|
|
1602
1754
|
}
|
|
1603
1755
|
const candidates = resultRecordCandidates(rawResult, rawContent);
|
|
1604
|
-
for (const parsed of [
|
|
1756
|
+
for (const parsed of [
|
|
1757
|
+
parseJsonCandidate(rawResult),
|
|
1758
|
+
parseJsonCandidate(rawContent),
|
|
1759
|
+
]) {
|
|
1605
1760
|
candidates.push(...resultRecordCandidates(parsed, undefined));
|
|
1606
1761
|
}
|
|
1607
1762
|
for (const candidate of candidates) {
|
|
@@ -1647,7 +1802,10 @@ function replResultFields(toolName, rawResult, rawContent) {
|
|
|
1647
1802
|
}
|
|
1648
1803
|
function collectResultCandidates(rawResult, rawContent) {
|
|
1649
1804
|
const candidates = resultRecordCandidates(rawResult, rawContent);
|
|
1650
|
-
for (const parsed of [
|
|
1805
|
+
for (const parsed of [
|
|
1806
|
+
parseJsonCandidate(rawResult),
|
|
1807
|
+
parseJsonCandidate(rawContent),
|
|
1808
|
+
]) {
|
|
1651
1809
|
candidates.push(...resultRecordCandidates(parsed, undefined));
|
|
1652
1810
|
}
|
|
1653
1811
|
return candidates;
|
|
@@ -1666,7 +1824,8 @@ function parseSkillResult(toolName, rawResult, rawContent) {
|
|
|
1666
1824
|
if (!agentId || typeof candidate.result !== "string") {
|
|
1667
1825
|
continue;
|
|
1668
1826
|
}
|
|
1669
|
-
if (candidate.background !== undefined &&
|
|
1827
|
+
if (candidate.background !== undefined &&
|
|
1828
|
+
typeof candidate.background !== "boolean") {
|
|
1670
1829
|
continue;
|
|
1671
1830
|
}
|
|
1672
1831
|
return {
|
|
@@ -1703,7 +1862,8 @@ function monitorResultFields(toolName, rawResult, rawContent) {
|
|
|
1703
1862
|
}
|
|
1704
1863
|
for (const candidate of collectResultCandidates(rawResult, rawContent)) {
|
|
1705
1864
|
const taskId = nonEmptyString(candidate.taskId);
|
|
1706
|
-
const timeoutMs = typeof candidate.timeoutMs === "number" &&
|
|
1865
|
+
const timeoutMs = typeof candidate.timeoutMs === "number" &&
|
|
1866
|
+
Number.isFinite(candidate.timeoutMs)
|
|
1707
1867
|
? Math.max(0, Math.trunc(candidate.timeoutMs))
|
|
1708
1868
|
: undefined;
|
|
1709
1869
|
const persistent = typeof candidate.persistent === "boolean"
|
|
@@ -1713,7 +1873,9 @@ function monitorResultFields(toolName, rawResult, rawContent) {
|
|
|
1713
1873
|
: timeoutMs !== undefined
|
|
1714
1874
|
? false
|
|
1715
1875
|
: undefined;
|
|
1716
|
-
const isStructuredMonitorOutput = taskId !== undefined ||
|
|
1876
|
+
const isStructuredMonitorOutput = taskId !== undefined ||
|
|
1877
|
+
timeoutMs !== undefined ||
|
|
1878
|
+
persistent !== undefined;
|
|
1717
1879
|
if (!isStructuredMonitorOutput) {
|
|
1718
1880
|
continue;
|
|
1719
1881
|
}
|
|
@@ -1832,7 +1994,10 @@ function enterPlanModeStructuredOutputHandled(toolName, rawResult, rawContent) {
|
|
|
1832
1994
|
return false;
|
|
1833
1995
|
}
|
|
1834
1996
|
const candidates = resultRecordCandidates(rawResult, rawContent);
|
|
1835
|
-
for (const parsed of [
|
|
1997
|
+
for (const parsed of [
|
|
1998
|
+
parseJsonCandidate(rawResult),
|
|
1999
|
+
parseJsonCandidate(rawContent),
|
|
2000
|
+
]) {
|
|
1836
2001
|
candidates.push(...resultRecordCandidates(parsed, undefined));
|
|
1837
2002
|
}
|
|
1838
2003
|
for (const candidate of candidates) {
|
|
@@ -1882,10 +2047,12 @@ function webFetchResultText(toolName, rawResult, rawContent) {
|
|
|
1882
2047
|
const codeText = nonEmptyString(candidate.codeText);
|
|
1883
2048
|
lines.push(`Status: ${candidate.code}${codeText ? ` ${codeText}` : ""}`);
|
|
1884
2049
|
}
|
|
1885
|
-
if (typeof candidate.bytes === "number" &&
|
|
2050
|
+
if (typeof candidate.bytes === "number" &&
|
|
2051
|
+
Number.isFinite(candidate.bytes)) {
|
|
1886
2052
|
lines.push(`Bytes: ${Math.max(0, Math.trunc(candidate.bytes))}`);
|
|
1887
2053
|
}
|
|
1888
|
-
if (typeof candidate.durationMs === "number" &&
|
|
2054
|
+
if (typeof candidate.durationMs === "number" &&
|
|
2055
|
+
Number.isFinite(candidate.durationMs)) {
|
|
1889
2056
|
lines.push(`Duration: ${Math.max(0, Math.trunc(candidate.durationMs))}ms`);
|
|
1890
2057
|
}
|
|
1891
2058
|
return lines.length > 0 ? lines.join("\n") : undefined;
|
|
@@ -1901,7 +2068,9 @@ export function buildToolResultFields(isError, rawContent, base, rawResult, _con
|
|
|
1901
2068
|
if (outputMetadata) {
|
|
1902
2069
|
fields.output_metadata = outputMetadata;
|
|
1903
2070
|
}
|
|
1904
|
-
const skillResult = !isError
|
|
2071
|
+
const skillResult = !isError
|
|
2072
|
+
? parseSkillResult(toolName, rawResult, rawContent)
|
|
2073
|
+
: undefined;
|
|
1905
2074
|
if (skillResult) {
|
|
1906
2075
|
fields.title = `${SKILL_TOOL_NAME}: ${skillDisplayName(skillResult.commandName)}`;
|
|
1907
2076
|
if (!skillResult.success) {
|
|
@@ -1914,7 +2083,9 @@ export function buildToolResultFields(isError, rawContent, base, rawResult, _con
|
|
|
1914
2083
|
const output = skillResult.result.trim();
|
|
1915
2084
|
if (output) {
|
|
1916
2085
|
fields.raw_output = output;
|
|
1917
|
-
fields.content = [
|
|
2086
|
+
fields.content = [
|
|
2087
|
+
{ type: "content", content: { type: "text", text: output } },
|
|
2088
|
+
];
|
|
1918
2089
|
}
|
|
1919
2090
|
return fields;
|
|
1920
2091
|
}
|
|
@@ -1924,13 +2095,19 @@ export function buildToolResultFields(isError, rawContent, base, rawResult, _con
|
|
|
1924
2095
|
: undefined;
|
|
1925
2096
|
if (imageReadText !== undefined) {
|
|
1926
2097
|
fields.raw_output = imageReadText;
|
|
1927
|
-
fields.content = [
|
|
2098
|
+
fields.content = [
|
|
2099
|
+
{ type: "content", content: { type: "text", text: imageReadText } },
|
|
2100
|
+
];
|
|
1928
2101
|
return fields;
|
|
1929
2102
|
}
|
|
1930
|
-
const fileUnchangedText = !isError && toolName === "Read"
|
|
2103
|
+
const fileUnchangedText = !isError && toolName === "Read"
|
|
2104
|
+
? fileUnchangedResultText(rawResult, rawContent)
|
|
2105
|
+
: "";
|
|
1931
2106
|
if (fileUnchangedText) {
|
|
1932
2107
|
fields.raw_output = fileUnchangedText;
|
|
1933
|
-
fields.content = [
|
|
2108
|
+
fields.content = [
|
|
2109
|
+
{ type: "content", content: { type: "text", text: fileUnchangedText } },
|
|
2110
|
+
];
|
|
1934
2111
|
return fields;
|
|
1935
2112
|
}
|
|
1936
2113
|
const agentTitle = !isError && toolName === "Agent"
|
|
@@ -1943,7 +2120,12 @@ export function buildToolResultFields(isError, rawContent, base, rawResult, _con
|
|
|
1943
2120
|
if (readMcpResourceError) {
|
|
1944
2121
|
fields.status = "failed";
|
|
1945
2122
|
fields.raw_output = readMcpResourceError;
|
|
1946
|
-
fields.content = [
|
|
2123
|
+
fields.content = [
|
|
2124
|
+
{
|
|
2125
|
+
type: "content",
|
|
2126
|
+
content: { type: "text", text: readMcpResourceError },
|
|
2127
|
+
},
|
|
2128
|
+
];
|
|
1947
2129
|
return fields;
|
|
1948
2130
|
}
|
|
1949
2131
|
const readMcpResourceDirOutput = !isError
|
|
@@ -1952,20 +2134,31 @@ export function buildToolResultFields(isError, rawContent, base, rawResult, _con
|
|
|
1952
2134
|
if (readMcpResourceDirOutput !== undefined) {
|
|
1953
2135
|
fields.raw_output = readMcpResourceDirOutput;
|
|
1954
2136
|
fields.content = [
|
|
1955
|
-
{
|
|
2137
|
+
{
|
|
2138
|
+
type: "content",
|
|
2139
|
+
content: { type: "text", text: readMcpResourceDirOutput },
|
|
2140
|
+
},
|
|
1956
2141
|
];
|
|
1957
2142
|
return fields;
|
|
1958
2143
|
}
|
|
1959
|
-
const searchOutput = !isError
|
|
2144
|
+
const searchOutput = !isError
|
|
2145
|
+
? searchResultText(toolName, rawResult, rawContent)
|
|
2146
|
+
: undefined;
|
|
1960
2147
|
if (searchOutput !== undefined) {
|
|
1961
2148
|
fields.raw_output = searchOutput;
|
|
1962
|
-
fields.content = [
|
|
2149
|
+
fields.content = [
|
|
2150
|
+
{ type: "content", content: { type: "text", text: searchOutput } },
|
|
2151
|
+
];
|
|
1963
2152
|
return fields;
|
|
1964
2153
|
}
|
|
1965
|
-
const webFetchOutput = !isError
|
|
2154
|
+
const webFetchOutput = !isError
|
|
2155
|
+
? webFetchResultText(toolName, rawResult, rawContent)
|
|
2156
|
+
: undefined;
|
|
1966
2157
|
if (webFetchOutput !== undefined) {
|
|
1967
2158
|
fields.raw_output = webFetchOutput;
|
|
1968
|
-
fields.content = [
|
|
2159
|
+
fields.content = [
|
|
2160
|
+
{ type: "content", content: { type: "text", text: webFetchOutput } },
|
|
2161
|
+
];
|
|
1969
2162
|
return fields;
|
|
1970
2163
|
}
|
|
1971
2164
|
const worktreeOutput = !isError
|
|
@@ -1975,7 +2168,10 @@ export function buildToolResultFields(isError, rawContent, base, rawResult, _con
|
|
|
1975
2168
|
if (worktreeOutput.output) {
|
|
1976
2169
|
fields.raw_output = worktreeOutput.output;
|
|
1977
2170
|
fields.content = [
|
|
1978
|
-
{
|
|
2171
|
+
{
|
|
2172
|
+
type: "content",
|
|
2173
|
+
content: { type: "text", text: worktreeOutput.output },
|
|
2174
|
+
},
|
|
1979
2175
|
];
|
|
1980
2176
|
}
|
|
1981
2177
|
return fields;
|
|
@@ -1985,7 +2181,9 @@ export function buildToolResultFields(isError, rawContent, base, rawResult, _con
|
|
|
1985
2181
|
: undefined;
|
|
1986
2182
|
if (cronOutput !== undefined) {
|
|
1987
2183
|
fields.raw_output = cronOutput;
|
|
1988
|
-
fields.content = [
|
|
2184
|
+
fields.content = [
|
|
2185
|
+
{ type: "content", content: { type: "text", text: cronOutput } },
|
|
2186
|
+
];
|
|
1989
2187
|
return fields;
|
|
1990
2188
|
}
|
|
1991
2189
|
const scheduleWakeupOutput = !isError
|
|
@@ -1994,7 +2192,10 @@ export function buildToolResultFields(isError, rawContent, base, rawResult, _con
|
|
|
1994
2192
|
if (scheduleWakeupOutput !== undefined) {
|
|
1995
2193
|
fields.raw_output = scheduleWakeupOutput;
|
|
1996
2194
|
fields.content = [
|
|
1997
|
-
{
|
|
2195
|
+
{
|
|
2196
|
+
type: "content",
|
|
2197
|
+
content: { type: "text", text: scheduleWakeupOutput },
|
|
2198
|
+
},
|
|
1998
2199
|
];
|
|
1999
2200
|
return fields;
|
|
2000
2201
|
}
|
|
@@ -2004,7 +2205,10 @@ export function buildToolResultFields(isError, rawContent, base, rawResult, _con
|
|
|
2004
2205
|
if (pushNotificationOutput !== undefined) {
|
|
2005
2206
|
fields.raw_output = pushNotificationOutput;
|
|
2006
2207
|
fields.content = [
|
|
2007
|
-
{
|
|
2208
|
+
{
|
|
2209
|
+
type: "content",
|
|
2210
|
+
content: { type: "text", text: pushNotificationOutput },
|
|
2211
|
+
},
|
|
2008
2212
|
];
|
|
2009
2213
|
return fields;
|
|
2010
2214
|
}
|
|
@@ -2020,7 +2224,10 @@ export function buildToolResultFields(isError, rawContent, base, rawResult, _con
|
|
|
2020
2224
|
if (remoteTriggerOutput.output) {
|
|
2021
2225
|
fields.raw_output = remoteTriggerOutput.output;
|
|
2022
2226
|
fields.content = [
|
|
2023
|
-
{
|
|
2227
|
+
{
|
|
2228
|
+
type: "content",
|
|
2229
|
+
content: { type: "text", text: remoteTriggerOutput.output },
|
|
2230
|
+
},
|
|
2024
2231
|
];
|
|
2025
2232
|
}
|
|
2026
2233
|
return fields;
|
|
@@ -2050,7 +2257,10 @@ export function buildToolResultFields(isError, rawContent, base, rawResult, _con
|
|
|
2050
2257
|
if (backgroundLaunchOutput.output) {
|
|
2051
2258
|
fields.raw_output = backgroundLaunchOutput.output;
|
|
2052
2259
|
fields.content = [
|
|
2053
|
-
{
|
|
2260
|
+
{
|
|
2261
|
+
type: "content",
|
|
2262
|
+
content: { type: "text", text: backgroundLaunchOutput.output },
|
|
2263
|
+
},
|
|
2054
2264
|
];
|
|
2055
2265
|
}
|
|
2056
2266
|
return fields;
|
|
@@ -2066,15 +2276,21 @@ export function buildToolResultFields(isError, rawContent, base, rawResult, _con
|
|
|
2066
2276
|
fields.raw_output = rawOutput;
|
|
2067
2277
|
}
|
|
2068
2278
|
if (!isError && isTaskToolName(toolName)) {
|
|
2069
|
-
if (toolName === "TaskUpdate" &&
|
|
2279
|
+
if (toolName === "TaskUpdate" &&
|
|
2280
|
+
taskUpdateSucceeded(rawResult, rawContent) === false) {
|
|
2070
2281
|
fields.status = "failed";
|
|
2071
2282
|
}
|
|
2072
2283
|
const taskOutput = taskToolResultText(toolName, rawResult, rawContent, base?.raw_input);
|
|
2073
2284
|
if (taskOutput) {
|
|
2074
|
-
fields.content = [
|
|
2285
|
+
fields.content = [
|
|
2286
|
+
{ type: "content", content: { type: "text", text: taskOutput } },
|
|
2287
|
+
];
|
|
2075
2288
|
return fields;
|
|
2076
2289
|
}
|
|
2077
|
-
if (toolName === "TaskCreate" ||
|
|
2290
|
+
if (toolName === "TaskCreate" ||
|
|
2291
|
+
toolName === "TaskUpdate" ||
|
|
2292
|
+
toolName === "TaskOutput" ||
|
|
2293
|
+
toolName === "TaskStop") {
|
|
2078
2294
|
return fields;
|
|
2079
2295
|
}
|
|
2080
2296
|
}
|
|
@@ -2108,7 +2324,9 @@ export function buildToolResultFields(isError, rawContent, base, rawResult, _con
|
|
|
2108
2324
|
}
|
|
2109
2325
|
}
|
|
2110
2326
|
if (rawOutput) {
|
|
2111
|
-
fields.content = [
|
|
2327
|
+
fields.content = [
|
|
2328
|
+
{ type: "content", content: { type: "text", text: rawOutput } },
|
|
2329
|
+
];
|
|
2112
2330
|
}
|
|
2113
2331
|
return fields;
|
|
2114
2332
|
}
|