weacpx 0.4.0-beta.0 → 0.4.0-beta.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bridge/bridge-main.js +67 -17
- package/dist/cli.js +643 -378
- package/dist/weixin/agent/interface.d.ts +8 -0
- package/package.json +1 -1
|
@@ -428,26 +428,32 @@ function formatToolCallEvent(update, sessionUpdate) {
|
|
|
428
428
|
if (title.length === 0)
|
|
429
429
|
return null;
|
|
430
430
|
const emoji = KIND_EMOJI[kind] ?? "\uD83D\uDD27";
|
|
431
|
-
const
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
}
|
|
435
|
-
if (sessionUpdate === "tool_call_update" || isGenericToolTitle(kind, title))
|
|
431
|
+
const inputSummary = summarizeToolInput(update.rawInput);
|
|
432
|
+
const status = readString(update, "status");
|
|
433
|
+
if (!inputSummary && isGenericToolTitle(kind, title))
|
|
436
434
|
return null;
|
|
437
|
-
|
|
435
|
+
const summaryText = inputSummary ? `: ${truncateToolDisplay(inputSummary)}` : "";
|
|
436
|
+
const statusText = status ? ` (${status})` : "";
|
|
437
|
+
return `${emoji} ${title}${statusText}${summaryText}`;
|
|
438
438
|
}
|
|
439
|
-
function
|
|
440
|
-
if (
|
|
441
|
-
return
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
return command;
|
|
439
|
+
function summarizeToolInput(rawInput) {
|
|
440
|
+
if (rawInput == null)
|
|
441
|
+
return;
|
|
442
|
+
if (typeof rawInput === "string" || typeof rawInput === "number" || typeof rawInput === "boolean") {
|
|
443
|
+
return String(rawInput);
|
|
445
444
|
}
|
|
446
|
-
|
|
447
|
-
|
|
445
|
+
if (!isRecord(rawInput))
|
|
446
|
+
return;
|
|
447
|
+
const command = readFirstString(rawInput, ["command", "cmd", "program"]);
|
|
448
|
+
const args = readFirstStringArray(rawInput, ["args", "arguments"]);
|
|
449
|
+
if (command) {
|
|
450
|
+
return [command, ...args ?? []].join(" ");
|
|
451
|
+
}
|
|
452
|
+
const parsedCmd = rawInput.parsed_cmd;
|
|
453
|
+
if (Array.isArray(parsedCmd) && parsedCmd.length > 0) {
|
|
448
454
|
const parts = [];
|
|
449
455
|
for (const entry of parsedCmd) {
|
|
450
|
-
if (entry && typeof entry.cmd === "string" && entry.cmd.length > 0) {
|
|
456
|
+
if (isRecord(entry) && typeof entry.cmd === "string" && entry.cmd.length > 0) {
|
|
451
457
|
parts.push(entry.cmd);
|
|
452
458
|
}
|
|
453
459
|
}
|
|
@@ -455,7 +461,51 @@ function getToolDisplayCommand(update) {
|
|
|
455
461
|
return parts.join(" ");
|
|
456
462
|
}
|
|
457
463
|
}
|
|
458
|
-
return
|
|
464
|
+
return readFirstString(rawInput, [
|
|
465
|
+
"path",
|
|
466
|
+
"file",
|
|
467
|
+
"filePath",
|
|
468
|
+
"filepath",
|
|
469
|
+
"target",
|
|
470
|
+
"uri",
|
|
471
|
+
"url",
|
|
472
|
+
"query",
|
|
473
|
+
"pattern",
|
|
474
|
+
"text",
|
|
475
|
+
"search",
|
|
476
|
+
"name",
|
|
477
|
+
"description"
|
|
478
|
+
]);
|
|
479
|
+
}
|
|
480
|
+
function readFirstString(record, keys) {
|
|
481
|
+
for (const key of keys) {
|
|
482
|
+
const value = record[key];
|
|
483
|
+
if (typeof value === "string" && value.trim().length > 0) {
|
|
484
|
+
return value.trim();
|
|
485
|
+
}
|
|
486
|
+
}
|
|
487
|
+
return;
|
|
488
|
+
}
|
|
489
|
+
function readFirstStringArray(record, keys) {
|
|
490
|
+
for (const key of keys) {
|
|
491
|
+
const value = record[key];
|
|
492
|
+
if (!Array.isArray(value))
|
|
493
|
+
continue;
|
|
494
|
+
const entries = value.map((entry) => typeof entry === "string" && entry.trim().length > 0 ? entry.trim() : undefined).filter((entry) => entry !== undefined);
|
|
495
|
+
if (entries.length > 0) {
|
|
496
|
+
return entries;
|
|
497
|
+
}
|
|
498
|
+
}
|
|
499
|
+
return;
|
|
500
|
+
}
|
|
501
|
+
function isRecord(value) {
|
|
502
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
503
|
+
}
|
|
504
|
+
function readString(rawInput, key) {
|
|
505
|
+
if (!isRecord(rawInput))
|
|
506
|
+
return;
|
|
507
|
+
const value = rawInput[key];
|
|
508
|
+
return typeof value === "string" && value.trim().length > 0 ? value.trim() : undefined;
|
|
459
509
|
}
|
|
460
510
|
function truncateToolDisplay(text) {
|
|
461
511
|
return text.length > 60 ? `${text.slice(0, 57)}...` : text;
|
|
@@ -1072,7 +1122,7 @@ class BridgeRuntime {
|
|
|
1072
1122
|
input.name,
|
|
1073
1123
|
...structuredPrompt ? ["--file", structuredPrompt.filePath] : [input.text]
|
|
1074
1124
|
]));
|
|
1075
|
-
const formatToolCalls = input.replyMode === "verbose";
|
|
1125
|
+
const formatToolCalls = (input.replyMode ?? "verbose") === "verbose";
|
|
1076
1126
|
try {
|
|
1077
1127
|
const result = onEvent ? await this.runPromptCommand(spawnSpec.command, spawnSpec.args, onEvent, { formatToolCalls }) : await this.run(spawnSpec.command, spawnSpec.args);
|
|
1078
1128
|
return { text: getPromptText(result) };
|