aws-runtime-bridge 1.8.0 → 1.8.1
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/adapter/AcodeSdkAdapter.d.ts.map +1 -1
- package/dist/adapter/AcodeSdkAdapter.js +36 -2
- package/dist/adapter/AcodeSdkAdapter.test.js +184 -2
- package/dist/adapter/types.d.ts.map +1 -1
- package/dist/adapter/types.js +7 -3
- package/dist/routes/ai-sources.js +5 -1
- package/dist/routes/ai-sources.test.js +21 -0
- package/dist/routes/terminal.d.ts +2 -0
- package/dist/routes/terminal.d.ts.map +1 -1
- package/dist/routes/terminal.js +109 -7
- package/dist/routes/terminal.test.js +118 -1
- package/dist/services/session-output.d.ts +7 -3
- package/dist/services/session-output.d.ts.map +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AcodeSdkAdapter.d.ts","sourceRoot":"","sources":["../../src/adapter/AcodeSdkAdapter.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAkB3C,OAAO,KAAK,EAEV,oBAAoB,EACpB,mBAAmB,EACnB,mBAAmB,EAEnB,aAAa,
|
|
1
|
+
{"version":3,"file":"AcodeSdkAdapter.d.ts","sourceRoot":"","sources":["../../src/adapter/AcodeSdkAdapter.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAkB3C,OAAO,KAAK,EAEV,oBAAoB,EACpB,mBAAmB,EACnB,mBAAmB,EAEnB,aAAa,EAEd,MAAM,YAAY,CAAC;AAEpB,KAAK,UAAU,GAAG;IAChB,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAC/B,CAAC;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O,CAAC,uCAAuC;CAehD"}
|
|
@@ -77,6 +77,12 @@ function toAcodeMcpActionDetail(actionDetail, server, tool) {
|
|
|
77
77
|
}
|
|
78
78
|
return getCanonicalMcpDetail(actionDetail.replace("/", "__"));
|
|
79
79
|
}
|
|
80
|
+
function isAcodeSemanticToolAction(actionType) {
|
|
81
|
+
return (actionType === "read_file" ||
|
|
82
|
+
actionType === "edit_file" ||
|
|
83
|
+
actionType === "write_file" ||
|
|
84
|
+
actionType === "bash");
|
|
85
|
+
}
|
|
80
86
|
export class AcodeSdkAdapter extends EventEmitter {
|
|
81
87
|
constructor() {
|
|
82
88
|
super(...arguments);
|
|
@@ -280,6 +286,9 @@ export class AcodeSdkAdapter extends EventEmitter {
|
|
|
280
286
|
}
|
|
281
287
|
if (event.type === "assistant_delta") {
|
|
282
288
|
const text = typeof event.data.text === "string" ? event.data.text : "";
|
|
289
|
+
if (entry.autoPollActive) {
|
|
290
|
+
entry.autoPollObservedAssistantText = true;
|
|
291
|
+
}
|
|
283
292
|
entry.adapterSession.messages.push({
|
|
284
293
|
id: uuidv4(),
|
|
285
294
|
sessionId: event.sessionId,
|
|
@@ -354,6 +363,13 @@ export class AcodeSdkAdapter extends EventEmitter {
|
|
|
354
363
|
this.emit("status-change", event.sessionId, "waiting_input", {
|
|
355
364
|
usage: entry.adapterSession.totalUsage,
|
|
356
365
|
});
|
|
366
|
+
if (entry.autoPollActive &&
|
|
367
|
+
entry.autoPollObservedAssistantText &&
|
|
368
|
+
!entry.autoPollObservedPollingTool) {
|
|
369
|
+
entry.stopAutoPollAfterCurrentTurn = true;
|
|
370
|
+
console.warn(`[${this.displayName}] Auto-poll turn produced assistant text without calling poll_message; stopping auto-poll rearm for session ${event.sessionId}`);
|
|
371
|
+
return;
|
|
372
|
+
}
|
|
357
373
|
this.armIdleLoopOrAutoPoll(event.sessionId);
|
|
358
374
|
return;
|
|
359
375
|
}
|
|
@@ -415,8 +431,16 @@ export class AcodeSdkAdapter extends EventEmitter {
|
|
|
415
431
|
const server = typeof event.data.server === "string" ? event.data.server : "mcp";
|
|
416
432
|
const tool = typeof event.data.tool === "string" ? event.data.tool : "";
|
|
417
433
|
const toolName = server && tool ? `${server}__${tool}` : tool || server;
|
|
418
|
-
const
|
|
419
|
-
|
|
434
|
+
const toolInput = event.data.arguments && typeof event.data.arguments === "object" && !Array.isArray(event.data.arguments)
|
|
435
|
+
? event.data.arguments
|
|
436
|
+
: undefined;
|
|
437
|
+
const actionInfo = getToolActionInfo(toolName, toolInput);
|
|
438
|
+
if (entry.autoPollActive && actionInfo.actionType === "idle") {
|
|
439
|
+
entry.autoPollObservedPollingTool = true;
|
|
440
|
+
}
|
|
441
|
+
const actionDetail = isAcodeSemanticToolAction(actionInfo.actionType)
|
|
442
|
+
? actionInfo.actionDetail || toAcodeMcpActionDetail(undefined, server, tool)
|
|
443
|
+
: toAcodeMcpActionDetail(actionInfo.actionDetail, server, tool);
|
|
420
444
|
const toolUseId = typeof event.data.toolUseId === "string"
|
|
421
445
|
? event.data.toolUseId
|
|
422
446
|
: undefined;
|
|
@@ -425,6 +449,7 @@ export class AcodeSdkAdapter extends EventEmitter {
|
|
|
425
449
|
actionType: actionInfo.actionType,
|
|
426
450
|
actionLabel: actionInfo.actionLabel,
|
|
427
451
|
actionDetail,
|
|
452
|
+
...(toolInput ? { toolInput } : {}),
|
|
428
453
|
...(toolUseId ? { toolUseId, actionId: toolUseId } : {}),
|
|
429
454
|
};
|
|
430
455
|
if (event.data.action === "tool_result") {
|
|
@@ -489,6 +514,9 @@ export class AcodeSdkAdapter extends EventEmitter {
|
|
|
489
514
|
if (!entry || this.isTerminalStatus(entry.adapterSession.status))
|
|
490
515
|
return;
|
|
491
516
|
entry.autoPollActive = true;
|
|
517
|
+
entry.autoPollObservedPollingTool = false;
|
|
518
|
+
entry.autoPollObservedAssistantText = false;
|
|
519
|
+
entry.stopAutoPollAfterCurrentTurn = false;
|
|
492
520
|
entry.adapterSession.status = "thinking";
|
|
493
521
|
this.emit("status-change", sessionId, "thinking");
|
|
494
522
|
void entry.runtime
|
|
@@ -511,6 +539,12 @@ export class AcodeSdkAdapter extends EventEmitter {
|
|
|
511
539
|
latestEntry.failedTurnRecoveryScheduled = false;
|
|
512
540
|
return;
|
|
513
541
|
}
|
|
542
|
+
if (latestEntry.stopAutoPollAfterCurrentTurn) {
|
|
543
|
+
latestEntry.stopAutoPollAfterCurrentTurn = false;
|
|
544
|
+
latestEntry.autoPollObservedPollingTool = false;
|
|
545
|
+
latestEntry.autoPollObservedAssistantText = false;
|
|
546
|
+
return;
|
|
547
|
+
}
|
|
514
548
|
if (latestEntry.adapterSession.status === "error") {
|
|
515
549
|
this.recoverTurnFailure(sessionId, latestEntry);
|
|
516
550
|
return;
|
|
@@ -46,6 +46,30 @@ class McpStatusRuntime extends EventEmitter {
|
|
|
46
46
|
async abort() { }
|
|
47
47
|
async stop() { }
|
|
48
48
|
}
|
|
49
|
+
class BuiltinReadStatusRuntime extends EventEmitter {
|
|
50
|
+
constructor(config) {
|
|
51
|
+
super();
|
|
52
|
+
this.config = config;
|
|
53
|
+
}
|
|
54
|
+
async start() { }
|
|
55
|
+
async submit(_message) {
|
|
56
|
+
this.emit("event", {
|
|
57
|
+
type: "mcp_status",
|
|
58
|
+
sessionId: this.config.sessionId,
|
|
59
|
+
timestamp: new Date(0).toISOString(),
|
|
60
|
+
data: {
|
|
61
|
+
action: "call_tool",
|
|
62
|
+
server: "builtin",
|
|
63
|
+
tool: "read_file",
|
|
64
|
+
exposedName: "builtin/read_file",
|
|
65
|
+
toolUseId: "tool-read-1",
|
|
66
|
+
arguments: { path: "src/views/App.vue" },
|
|
67
|
+
},
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
async abort() { }
|
|
71
|
+
async stop() { }
|
|
72
|
+
}
|
|
49
73
|
class McpResultRuntime extends EventEmitter {
|
|
50
74
|
constructor(config) {
|
|
51
75
|
super();
|
|
@@ -294,6 +318,56 @@ class AutoPollRuntime extends EventEmitter {
|
|
|
294
318
|
async stop() { }
|
|
295
319
|
}
|
|
296
320
|
AutoPollRuntime.submitMessages = [];
|
|
321
|
+
class NonPollingAutoPollRuntime extends EventEmitter {
|
|
322
|
+
constructor(config) {
|
|
323
|
+
super();
|
|
324
|
+
this.config = config;
|
|
325
|
+
}
|
|
326
|
+
async start() { }
|
|
327
|
+
async submit(message) {
|
|
328
|
+
NonPollingAutoPollRuntime.submitMessages.push(message);
|
|
329
|
+
this.emit("event", {
|
|
330
|
+
type: "assistant_delta",
|
|
331
|
+
sessionId: this.config.sessionId,
|
|
332
|
+
timestamp: new Date(0).toISOString(),
|
|
333
|
+
data: { text: "I cannot call poll_message." },
|
|
334
|
+
});
|
|
335
|
+
this.emit("event", {
|
|
336
|
+
type: "turn_complete",
|
|
337
|
+
sessionId: this.config.sessionId,
|
|
338
|
+
timestamp: new Date(0).toISOString(),
|
|
339
|
+
data: { usage: { inputTokens: 1, outputTokens: 1 } },
|
|
340
|
+
});
|
|
341
|
+
}
|
|
342
|
+
async abort() { }
|
|
343
|
+
async stop() { }
|
|
344
|
+
}
|
|
345
|
+
NonPollingAutoPollRuntime.submitMessages = [];
|
|
346
|
+
class PollingAutoPollRuntime extends EventEmitter {
|
|
347
|
+
constructor(config) {
|
|
348
|
+
super();
|
|
349
|
+
this.config = config;
|
|
350
|
+
}
|
|
351
|
+
async start() { }
|
|
352
|
+
async submit(message) {
|
|
353
|
+
PollingAutoPollRuntime.submitMessages.push(message);
|
|
354
|
+
this.emit("event", {
|
|
355
|
+
type: "mcp_status",
|
|
356
|
+
sessionId: this.config.sessionId,
|
|
357
|
+
timestamp: new Date(0).toISOString(),
|
|
358
|
+
data: { action: "call_tool", server: "aws-mcp", tool: "poll_message" },
|
|
359
|
+
});
|
|
360
|
+
this.emit("event", {
|
|
361
|
+
type: "turn_complete",
|
|
362
|
+
sessionId: this.config.sessionId,
|
|
363
|
+
timestamp: new Date(0).toISOString(),
|
|
364
|
+
data: { usage: { inputTokens: 1, outputTokens: 1 } },
|
|
365
|
+
});
|
|
366
|
+
}
|
|
367
|
+
async abort() { }
|
|
368
|
+
async stop() { }
|
|
369
|
+
}
|
|
370
|
+
PollingAutoPollRuntime.submitMessages = [];
|
|
297
371
|
class TerminalAfterTurnRuntime extends EventEmitter {
|
|
298
372
|
constructor(config) {
|
|
299
373
|
super();
|
|
@@ -633,6 +707,42 @@ describe("AcodeSdkAdapter turn completion state", () => {
|
|
|
633
707
|
});
|
|
634
708
|
expect(adapter.getSessionStatus("session-mcp")).toBe("waiting_input");
|
|
635
709
|
});
|
|
710
|
+
it("preserves built-in file tool arguments in ACode provider events and statuses", async () => {
|
|
711
|
+
const adapter = new AcodeSdkAdapter();
|
|
712
|
+
adapter.setRuntimeConstructorForTest(BuiltinReadStatusRuntime);
|
|
713
|
+
const events = [];
|
|
714
|
+
const statuses = [];
|
|
715
|
+
adapter.on("event", (event) => events.push(event));
|
|
716
|
+
adapter.on("status-change", (_sessionId, status, actionInfo) => {
|
|
717
|
+
statuses.push({
|
|
718
|
+
status,
|
|
719
|
+
actionType: actionInfo?.actionType,
|
|
720
|
+
actionDetail: actionInfo?.actionDetail,
|
|
721
|
+
});
|
|
722
|
+
});
|
|
723
|
+
await adapter.startSession("session-builtin-read", {
|
|
724
|
+
command: "acode",
|
|
725
|
+
workingDirectory: process.cwd(),
|
|
726
|
+
autoAccept: true,
|
|
727
|
+
extraMcpServers: {},
|
|
728
|
+
envOverrides: {},
|
|
729
|
+
});
|
|
730
|
+
await adapter.sendMessage("session-builtin-read", "read file");
|
|
731
|
+
expect(events.map((event) => event.type)).toEqual(["tool_use_start"]);
|
|
732
|
+
expect(events[0]?.data).toMatchObject({
|
|
733
|
+
actionType: "read_file",
|
|
734
|
+
actionLabel: "读取文件",
|
|
735
|
+
actionDetail: "src/views/App.vue",
|
|
736
|
+
actionId: "tool-read-1",
|
|
737
|
+
toolUseId: "tool-read-1",
|
|
738
|
+
toolInput: { path: "src/views/App.vue" },
|
|
739
|
+
});
|
|
740
|
+
expect(statuses.at(-2)).toEqual({
|
|
741
|
+
status: "tool_using",
|
|
742
|
+
actionType: "read_file",
|
|
743
|
+
actionDetail: "src/views/App.vue",
|
|
744
|
+
});
|
|
745
|
+
});
|
|
636
746
|
it("clears active MCP tool status when ACode reports a tool result", async () => {
|
|
637
747
|
const adapter = new AcodeSdkAdapter();
|
|
638
748
|
adapter.setRuntimeConstructorForTest(McpResultRuntime);
|
|
@@ -942,6 +1052,78 @@ describe("AcodeSdkAdapter turn completion state", () => {
|
|
|
942
1052
|
adapter.cleanup();
|
|
943
1053
|
}
|
|
944
1054
|
});
|
|
1055
|
+
it("stops re-arming auto-poll when the model answers without calling poll_message", async () => {
|
|
1056
|
+
vi.useFakeTimers();
|
|
1057
|
+
NonPollingAutoPollRuntime.submitMessages = [];
|
|
1058
|
+
const adapter = new AcodeSdkAdapter();
|
|
1059
|
+
adapter.setRuntimeConstructorForTest(NonPollingAutoPollRuntime);
|
|
1060
|
+
try {
|
|
1061
|
+
await adapter.startSession("session-non-polling-auto-poll", {
|
|
1062
|
+
command: "acode",
|
|
1063
|
+
workingDirectory: process.cwd(),
|
|
1064
|
+
autoAccept: true,
|
|
1065
|
+
extraMcpServers: {},
|
|
1066
|
+
envOverrides: {},
|
|
1067
|
+
});
|
|
1068
|
+
await vi.advanceTimersByTimeAsync(250);
|
|
1069
|
+
expect(NonPollingAutoPollRuntime.submitMessages).toHaveLength(1);
|
|
1070
|
+
expect(NonPollingAutoPollRuntime.submitMessages[0]).toContain("poll_message");
|
|
1071
|
+
await vi.advanceTimersByTimeAsync(5_000);
|
|
1072
|
+
expect(NonPollingAutoPollRuntime.submitMessages).toHaveLength(1);
|
|
1073
|
+
expect(adapter.getSessionStatus("session-non-polling-auto-poll")).toBe("waiting_input");
|
|
1074
|
+
}
|
|
1075
|
+
finally {
|
|
1076
|
+
vi.useRealTimers();
|
|
1077
|
+
adapter.cleanup();
|
|
1078
|
+
}
|
|
1079
|
+
});
|
|
1080
|
+
it("keeps re-arming auto-poll when the model actually calls poll_message", async () => {
|
|
1081
|
+
vi.useFakeTimers();
|
|
1082
|
+
PollingAutoPollRuntime.submitMessages = [];
|
|
1083
|
+
const adapter = new AcodeSdkAdapter();
|
|
1084
|
+
adapter.setRuntimeConstructorForTest(PollingAutoPollRuntime);
|
|
1085
|
+
try {
|
|
1086
|
+
await adapter.startSession("session-polling-auto-poll", {
|
|
1087
|
+
command: "acode",
|
|
1088
|
+
workingDirectory: process.cwd(),
|
|
1089
|
+
autoAccept: true,
|
|
1090
|
+
extraMcpServers: {},
|
|
1091
|
+
envOverrides: {},
|
|
1092
|
+
});
|
|
1093
|
+
await vi.advanceTimersByTimeAsync(250);
|
|
1094
|
+
expect(PollingAutoPollRuntime.submitMessages).toHaveLength(1);
|
|
1095
|
+
await vi.advanceTimersByTimeAsync(250);
|
|
1096
|
+
expect(PollingAutoPollRuntime.submitMessages).toHaveLength(2);
|
|
1097
|
+
}
|
|
1098
|
+
finally {
|
|
1099
|
+
vi.useRealTimers();
|
|
1100
|
+
adapter.cleanup();
|
|
1101
|
+
}
|
|
1102
|
+
});
|
|
1103
|
+
it("keeps re-arming auto-poll when a poll turn completes without assistant text", async () => {
|
|
1104
|
+
vi.useFakeTimers();
|
|
1105
|
+
AutoPollRuntime.submitMessages = [];
|
|
1106
|
+
const adapter = new AcodeSdkAdapter();
|
|
1107
|
+
adapter.setRuntimeConstructorForTest(AutoPollRuntime);
|
|
1108
|
+
try {
|
|
1109
|
+
await adapter.startSession("session-empty-auto-poll-turn", {
|
|
1110
|
+
command: "acode",
|
|
1111
|
+
workingDirectory: process.cwd(),
|
|
1112
|
+
autoAccept: true,
|
|
1113
|
+
extraMcpServers: {},
|
|
1114
|
+
envOverrides: {},
|
|
1115
|
+
});
|
|
1116
|
+
await vi.advanceTimersByTimeAsync(250);
|
|
1117
|
+
expect(AutoPollRuntime.submitMessages).toHaveLength(1);
|
|
1118
|
+
await vi.advanceTimersByTimeAsync(250);
|
|
1119
|
+
expect(AutoPollRuntime.submitMessages).toHaveLength(2);
|
|
1120
|
+
expect(AutoPollRuntime.submitMessages[1]).toContain("poll_message");
|
|
1121
|
+
}
|
|
1122
|
+
finally {
|
|
1123
|
+
vi.useRealTimers();
|
|
1124
|
+
adapter.cleanup();
|
|
1125
|
+
}
|
|
1126
|
+
});
|
|
945
1127
|
it("cancels a pending auto-poll when a user message arrives", async () => {
|
|
946
1128
|
vi.useFakeTimers();
|
|
947
1129
|
AutoPollRuntime.submitMessages = [];
|
|
@@ -1014,8 +1196,8 @@ describe("AcodeSdkAdapter turn completion state", () => {
|
|
|
1014
1196
|
await vi.advanceTimersByTimeAsync(250);
|
|
1015
1197
|
// Status sequence: starting -> waiting_input (startSession) ->
|
|
1016
1198
|
// thinking (auto-poll fires) -> waiting_input (turn_complete success
|
|
1017
|
-
// re-arms the loop).
|
|
1018
|
-
//
|
|
1199
|
+
// re-arms the loop). Empty turns are allowed to retry because only a
|
|
1200
|
+
// plain-text assistant answer indicates the model ignored poll_message.
|
|
1019
1201
|
expect(AutoPollRuntime.submitMessages).toHaveLength(1);
|
|
1020
1202
|
expect(AutoPollRuntime.submitMessages[0]).toContain("poll_message");
|
|
1021
1203
|
expect(statuses).toEqual([
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/adapter/types.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAI3C,MAAM,MAAM,aAAa,GACrB,UAAU,GACV,UAAU,GACV,YAAY,GACZ,eAAe,GACf,WAAW,GACX,YAAY,GACZ,OAAO,CAAC;AAIZ,MAAM,MAAM,iBAAiB,GACzB,YAAY,GACZ,YAAY,GACZ,UAAU,GACV,gBAAgB,GAChB,cAAc,GACd,oBAAoB,GACpB,mBAAmB,GACnB,gBAAgB,GAChB,eAAe,GACf,kBAAkB,GAClB,OAAO,CAAC;AAIZ;;;GAGG;AACH,MAAM,MAAM,cAA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AG,aAAa,GAAG,SAAS;IAEvE;;OAEG;IACH,QAAQ,CAAC,aAAa,CAAC,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS;IAE9D;;OAEG;IACH,QAAQ,CAAC,OAAO,IAAI,IAAI;CACzB"}
|
package/dist/adapter/types.js
CHANGED
|
@@ -132,9 +132,13 @@ export function getToolActionInfo(toolName, toolInput, metadata) {
|
|
|
132
132
|
const normalizedName = name.replace(/[_-]/g, "");
|
|
133
133
|
const semanticToolName = name.startsWith("mcp__")
|
|
134
134
|
? name.split("__").slice(2).join("__")
|
|
135
|
-
: name.
|
|
136
|
-
? name.slice(
|
|
137
|
-
: name
|
|
135
|
+
: name.startsWith("builtin__")
|
|
136
|
+
? name.split("__").slice(1).join("__")
|
|
137
|
+
: name.includes("-mcp__")
|
|
138
|
+
? name.slice(name.indexOf("-mcp__") + 6)
|
|
139
|
+
: name.includes("/")
|
|
140
|
+
? name.split("/").filter(Boolean).at(-1) || name
|
|
141
|
+
: name;
|
|
138
142
|
const normalizedSemanticToolName = semanticToolName.replace(/[_-]/g, "");
|
|
139
143
|
const normalizeSkillList = (value) => {
|
|
140
144
|
if (!Array.isArray(value)) {
|
|
@@ -59,7 +59,7 @@ async function fetchRemoteModelList(baseUrl, apiKey) {
|
|
|
59
59
|
return normalizeListedModels(anthropicResponse.data);
|
|
60
60
|
}
|
|
61
61
|
aiSourcesRouter.post('/cc-switch/apply-ai-sources', validateToken, async (req, res) => {
|
|
62
|
-
const { agentId, template, ccSwitchEnabledTools, acodeTemplateId, claudecodeTemplateId, codexTemplateId, opencodeTemplateId, acode, claudecode, codex, opencode, } = req.body || {};
|
|
62
|
+
const { agentId, template, ccSwitchEnabledTools, acodeTemplateId, claudecodeTemplateId, codexTemplateId, opencodeTemplateId, acodeModelEffort, claudecodeModelEffort, codexModelEffort, opencodeModelEffort, acode, claudecode, codex, opencode, } = req.body || {};
|
|
63
63
|
if (!agentId) {
|
|
64
64
|
res.status(400).json({ error: 'agentId is required' });
|
|
65
65
|
return;
|
|
@@ -81,6 +81,10 @@ aiSourcesRouter.post('/cc-switch/apply-ai-sources', validateToken, async (req, r
|
|
|
81
81
|
claudecodeTemplateId: String(claudecodeTemplateId || ''),
|
|
82
82
|
codexTemplateId: String(codexTemplateId || ''),
|
|
83
83
|
opencodeTemplateId: String(opencodeTemplateId || ''),
|
|
84
|
+
acodeModelEffort: String(acodeModelEffort || ''),
|
|
85
|
+
claudecodeModelEffort: String(claudecodeModelEffort || ''),
|
|
86
|
+
codexModelEffort: String(codexModelEffort || ''),
|
|
87
|
+
opencodeModelEffort: String(opencodeModelEffort || ''),
|
|
84
88
|
generatedFromUnifiedTemplate: appliedSummary.generatedFromUnifiedTemplate,
|
|
85
89
|
applied: appliedSummary.applied,
|
|
86
90
|
skippedTools: appliedSummary.skippedTools,
|
|
@@ -76,6 +76,14 @@ function buildModelListCandidates(baseUrl, protocol) {
|
|
|
76
76
|
: [`${normalizedBaseUrl}/models`, `${normalizedBaseUrl}/v1/models`];
|
|
77
77
|
return [...openAiCandidates, `${normalizedBaseUrl}/v1/models`];
|
|
78
78
|
}
|
|
79
|
+
function buildApplyAiSourcesResponse(body) {
|
|
80
|
+
return {
|
|
81
|
+
acodeModelEffort: String(body.acodeModelEffort || ''),
|
|
82
|
+
claudecodeModelEffort: String(body.claudecodeModelEffort || ''),
|
|
83
|
+
codexModelEffort: String(body.codexModelEffort || ''),
|
|
84
|
+
opencodeModelEffort: String(body.opencodeModelEffort || ''),
|
|
85
|
+
};
|
|
86
|
+
}
|
|
79
87
|
describe('ai source unified config generation', () => {
|
|
80
88
|
it('builds tool-specific configs from unified template fields', () => {
|
|
81
89
|
assert.deepEqual(buildUnifiedToolConfig({
|
|
@@ -145,4 +153,17 @@ describe('ai source unified config generation', () => {
|
|
|
145
153
|
model: 'gpt-test',
|
|
146
154
|
}).opencode.provider.default.options.baseURL).toBe('https://octopus.721579.xyz/v1');
|
|
147
155
|
});
|
|
156
|
+
it('echoes selected model effort metadata in apply-ai-sources responses', () => {
|
|
157
|
+
expect(buildApplyAiSourcesResponse({
|
|
158
|
+
acodeModelEffort: 'xhigh',
|
|
159
|
+
claudecodeModelEffort: 'high',
|
|
160
|
+
codexModelEffort: 'max',
|
|
161
|
+
opencodeModelEffort: 'high',
|
|
162
|
+
})).toEqual({
|
|
163
|
+
acodeModelEffort: 'xhigh',
|
|
164
|
+
claudecodeModelEffort: 'high',
|
|
165
|
+
codexModelEffort: 'max',
|
|
166
|
+
opencodeModelEffort: 'high',
|
|
167
|
+
});
|
|
168
|
+
});
|
|
148
169
|
});
|
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
*/
|
|
7
7
|
import { TextDecoder } from "node:util";
|
|
8
8
|
import { type AdapterSessionConfig, type ProviderEvent, type RuntimeStatusActionInfo } from "../adapter/index.js";
|
|
9
|
+
import { type RuntimeOutputMetadata } from "../services/session-output.js";
|
|
9
10
|
import type { PersistedSession } from "../types.js";
|
|
10
11
|
export declare const terminalRouter: import("express-serve-static-core").Router;
|
|
11
12
|
export interface SdkSessionEntry {
|
|
@@ -91,6 +92,7 @@ export declare function buildClaudeCodeLaunchConfig(savedClaudeConfig: {
|
|
|
91
92
|
*/
|
|
92
93
|
export declare function buildToolResultTimelineActionInfo(event: ProviderEvent): RuntimeStatusActionInfo | undefined;
|
|
93
94
|
export declare function formatSdkOutputEvent(event: ProviderEvent): string | undefined;
|
|
95
|
+
export declare function buildSdkOutputMetadata(event: ProviderEvent): RuntimeOutputMetadata;
|
|
94
96
|
/**
|
|
95
97
|
* 主干流程:把 provider 事件转换为面板运行状态。
|
|
96
98
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"terminal.d.ts","sourceRoot":"","sources":["../../src/routes/terminal.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAMH,OAAO,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AAKxC,OAAO,EAOL,KAAK,oBAAoB,EAEzB,KAAK,aAAa,EAClB,KA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AC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GACrC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CA+BxB;AAYD;;;GAGG;AACH,wBAAsB,sBAAsB,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAAC,MAAM,CAAC,CAY5E;AAED,MAAM,WAAW,sBAAsB;IACrC,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACrC,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED;;GAEG;AACH,wBAAgB,2BAA2B,CACzC,iBAAiB,EAAE;IAAE,GAAG,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;CAAE,GAAG,IAAI,GAAG,SAAS,EACvE,mBAAmB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAC5C,sBAAsB,CAyBxB;AAoDD;;;GAGG;AACH,wBAAgB,iCAAiC,CAC/C,KAAK,EAAE,aAAa,GACnB,uBAAuB,GAAG,SAAS,CAyCrC;AAED,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,aAAa,GAAG,MAAM,GAAG,SAAS,CAwB7E;AAED,wBAAgB,sBAAsB,CACpC,KAAK,EAAE,aAAa,GACnB,qBAAqB,CAYvB;AAsJD;;;;;GAKG;AACH,wBAAgB,qCAAqC,CAAC,KAAK,EAAE,aAAa,GACtE;IACE,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,CAAC,EAAE,uBAAuB,CAAC;CACtC,GACD,SAAS,CAyEZ;AAsBD,wBAAgB,oBAAoB,CAAC,OAAO,CAAC,EAAE,MAAM,GAAG,MAAM,CAE7D"}
|
package/dist/routes/terminal.js
CHANGED
|
@@ -573,6 +573,111 @@ export function formatSdkOutputEvent(event) {
|
|
|
573
573
|
}
|
|
574
574
|
return undefined;
|
|
575
575
|
}
|
|
576
|
+
export function buildSdkOutputMetadata(event) {
|
|
577
|
+
const logMessage = formatSdkLogMessage(event);
|
|
578
|
+
return {
|
|
579
|
+
sourceEventType: event.type,
|
|
580
|
+
logCategory: "acode",
|
|
581
|
+
...(logMessage
|
|
582
|
+
? {
|
|
583
|
+
logLevel: event.type === "error" ? "error" : "info",
|
|
584
|
+
logMessage,
|
|
585
|
+
}
|
|
586
|
+
: {}),
|
|
587
|
+
};
|
|
588
|
+
}
|
|
589
|
+
function formatSdkLogMessage(event) {
|
|
590
|
+
if (event.type === "ai_request") {
|
|
591
|
+
const model = event.data.model || "unknown-model";
|
|
592
|
+
const endpoint = event.data.endpoint ? ` @ ${event.data.endpoint}` : "";
|
|
593
|
+
const toolCount = typeof event.data.toolCount === "number"
|
|
594
|
+
? `, tools=${event.data.toolCount}`
|
|
595
|
+
: "";
|
|
596
|
+
return `AI request started: ${model}${endpoint}${toolCount}`;
|
|
597
|
+
}
|
|
598
|
+
if (event.type === "tool_use_start") {
|
|
599
|
+
return formatSdkToolLogMessage(event, "开始");
|
|
600
|
+
}
|
|
601
|
+
if (event.type === "tool_use_end") {
|
|
602
|
+
return formatSdkToolLogMessage(event, "完成");
|
|
603
|
+
}
|
|
604
|
+
if (event.type === "turn_complete") {
|
|
605
|
+
const finishReason = event.data.finishReason
|
|
606
|
+
? `, finish=${event.data.finishReason}`
|
|
607
|
+
: "";
|
|
608
|
+
return `Turn completed${finishReason}`;
|
|
609
|
+
}
|
|
610
|
+
if (event.type === "session_complete") {
|
|
611
|
+
return `Session completed: exitCode=${event.data.exitCode ?? 0}`;
|
|
612
|
+
}
|
|
613
|
+
if (event.type === "error") {
|
|
614
|
+
return event.data.text || "ACode runtime error";
|
|
615
|
+
}
|
|
616
|
+
return undefined;
|
|
617
|
+
}
|
|
618
|
+
function formatSdkToolLogMessage(event, phaseLabel) {
|
|
619
|
+
const actionInfo = getToolActionInfo(event.data.toolName, event.data.toolInput);
|
|
620
|
+
const actionLabel = event.data.actionLabel || actionInfo.actionLabel || "调用工具";
|
|
621
|
+
const detail = resolveSdkToolLogDetail(event, actionInfo);
|
|
622
|
+
return detail
|
|
623
|
+
? `${phaseLabel}${actionLabel}: ${detail}`
|
|
624
|
+
: `${phaseLabel}${actionLabel}: ${event.data.actionDetail || event.data.toolName || "tool"}`;
|
|
625
|
+
}
|
|
626
|
+
function resolveSdkToolLogDetail(event, actionInfo) {
|
|
627
|
+
const input = event.data.toolInput;
|
|
628
|
+
if (actionInfo.actionType === "bash") {
|
|
629
|
+
return getCommandDisplayDetail(input) || event.data.actionDetail || actionInfo.actionDetail;
|
|
630
|
+
}
|
|
631
|
+
if (actionInfo.actionType === "read_file" ||
|
|
632
|
+
actionInfo.actionType === "edit_file" ||
|
|
633
|
+
actionInfo.actionType === "write_file") {
|
|
634
|
+
return getFileDisplayDetail(input) || event.data.actionDetail || actionInfo.actionDetail;
|
|
635
|
+
}
|
|
636
|
+
return event.data.actionDetail || actionInfo.actionDetail;
|
|
637
|
+
}
|
|
638
|
+
function getCommandDisplayDetail(input) {
|
|
639
|
+
const command = firstDisplayString(input?.command, input?.cmd);
|
|
640
|
+
if (command)
|
|
641
|
+
return command;
|
|
642
|
+
if (Array.isArray(input?.argv)) {
|
|
643
|
+
const argv = input.argv
|
|
644
|
+
.map((item) => String(item ?? "").trim())
|
|
645
|
+
.filter(Boolean)
|
|
646
|
+
.join(" ");
|
|
647
|
+
return argv ? redactTransientClipboardPastePaths(argv) : undefined;
|
|
648
|
+
}
|
|
649
|
+
return firstDisplayString(input?.args);
|
|
650
|
+
}
|
|
651
|
+
function getFileDisplayDetail(input) {
|
|
652
|
+
const paths = displayStringList(input?.paths);
|
|
653
|
+
if (paths.length > 0) {
|
|
654
|
+
return paths.length === 1
|
|
655
|
+
? paths[0]
|
|
656
|
+
: `${paths.length}个文件: ${paths.join(", ")}`;
|
|
657
|
+
}
|
|
658
|
+
return firstDisplayString(input?.file_path, input?.filePath, input?.path, input?.target_file, input?.targetFile);
|
|
659
|
+
}
|
|
660
|
+
function firstDisplayString(...values) {
|
|
661
|
+
for (const value of values) {
|
|
662
|
+
if (typeof value === "string" && value.trim()) {
|
|
663
|
+
return redactTransientClipboardPastePaths(value.trim());
|
|
664
|
+
}
|
|
665
|
+
if (Array.isArray(value)) {
|
|
666
|
+
const first = displayStringList(value)[0];
|
|
667
|
+
if (first)
|
|
668
|
+
return first;
|
|
669
|
+
}
|
|
670
|
+
}
|
|
671
|
+
return undefined;
|
|
672
|
+
}
|
|
673
|
+
function displayStringList(value) {
|
|
674
|
+
if (!Array.isArray(value))
|
|
675
|
+
return [];
|
|
676
|
+
return value
|
|
677
|
+
.map((item) => (typeof item === "string" ? item.trim() : ""))
|
|
678
|
+
.filter(Boolean)
|
|
679
|
+
.map((item) => redactTransientClipboardPastePaths(item));
|
|
680
|
+
}
|
|
576
681
|
function formatAiRequestDetail(data) {
|
|
577
682
|
const lines = [
|
|
578
683
|
data.model ? `模型: ${data.model}` : undefined,
|
|
@@ -617,6 +722,7 @@ export function resolveRuntimeStatusFromProviderEvent(event) {
|
|
|
617
722
|
}
|
|
618
723
|
if (event.type === "tool_use_start") {
|
|
619
724
|
const inferredAction = getToolActionInfo(event.data.toolName, event.data.toolInput);
|
|
725
|
+
const actionDetail = resolveSdkToolLogDetail(event, inferredAction);
|
|
620
726
|
if (event.data.actionType === "idle" ||
|
|
621
727
|
inferredAction.actionType === "idle") {
|
|
622
728
|
return {
|
|
@@ -624,9 +730,7 @@ export function resolveRuntimeStatusFromProviderEvent(event) {
|
|
|
624
730
|
actionInfo: {
|
|
625
731
|
actionType: event.data.actionType || inferredAction.actionType,
|
|
626
732
|
actionLabel: event.data.actionLabel || inferredAction.actionLabel,
|
|
627
|
-
actionDetail: event.data.actionDetail ||
|
|
628
|
-
inferredAction.actionDetail ||
|
|
629
|
-
event.data.toolName,
|
|
733
|
+
actionDetail: actionDetail || event.data.actionDetail || inferredAction.actionDetail || event.data.toolName,
|
|
630
734
|
actionId: event.data.actionId || event.data.toolUseId,
|
|
631
735
|
},
|
|
632
736
|
};
|
|
@@ -636,9 +740,7 @@ export function resolveRuntimeStatusFromProviderEvent(event) {
|
|
|
636
740
|
actionInfo: {
|
|
637
741
|
actionType: event.data.actionType || inferredAction.actionType,
|
|
638
742
|
actionLabel: event.data.actionLabel || inferredAction.actionLabel,
|
|
639
|
-
actionDetail: event.data.actionDetail ||
|
|
640
|
-
inferredAction.actionDetail ||
|
|
641
|
-
event.data.toolName,
|
|
743
|
+
actionDetail: actionDetail || event.data.actionDetail || inferredAction.actionDetail || event.data.toolName,
|
|
642
744
|
actionId: event.data.actionId || event.data.toolUseId,
|
|
643
745
|
},
|
|
644
746
|
};
|
|
@@ -670,7 +772,7 @@ function forwardSdkOutputEvent(event, entry) {
|
|
|
670
772
|
return;
|
|
671
773
|
}
|
|
672
774
|
entry.seq += 1;
|
|
673
|
-
void sendOutput(entry.agentId, output, event.sessionId, entry.seq,
|
|
775
|
+
void sendOutput(entry.agentId, output, event.sessionId, entry.seq, buildSdkOutputMetadata(event), { runtimeAccessToken: entry.runtimeAccessToken });
|
|
674
776
|
}
|
|
675
777
|
export function resolveSdkProviderId(command) {
|
|
676
778
|
return resolveSdkProviderIdByCommand(command);
|
|
@@ -3,7 +3,7 @@ import os from "node:os";
|
|
|
3
3
|
import path from "node:path";
|
|
4
4
|
import { describe, expect, it } from "vitest";
|
|
5
5
|
import { SDK_PROVIDER_DEFINITIONS } from "../adapter/SdkProviderSpi.js";
|
|
6
|
-
import { buildAcodeCommandOutputPath, buildClaudeCodeLaunchConfig, buildRuntimeEnv, buildToolResultTimelineActionInfo, countTerminalOutputLines, createTerminalOutputDecoder, decodeTerminalOutputChunk, evaluatePersistedSessionReuse, formatCommandInactivityTimeoutNotice, formatCommandOutputSpilloverNotice, formatTerminalPrompt, formatSdkOutputEvent, normalizeTerminalCommandInput, parseTerminalDirectoryChangeTarget, resolveSdkInputMessage, resolveTerminalOutputEncoding, resolveSdkProviderId, resolveSdkSessionDisplayStatus, resolveRuntimeStatusFromProviderEvent, resolveStatusChangeUsage, } from "./terminal.js";
|
|
6
|
+
import { buildAcodeCommandOutputPath, buildClaudeCodeLaunchConfig, buildRuntimeEnv, buildSdkOutputMetadata, buildToolResultTimelineActionInfo, countTerminalOutputLines, createTerminalOutputDecoder, decodeTerminalOutputChunk, evaluatePersistedSessionReuse, formatCommandInactivityTimeoutNotice, formatCommandOutputSpilloverNotice, formatTerminalPrompt, formatSdkOutputEvent, normalizeTerminalCommandInput, parseTerminalDirectoryChangeTarget, resolveSdkInputMessage, resolveTerminalOutputEncoding, resolveSdkProviderId, resolveSdkSessionDisplayStatus, resolveRuntimeStatusFromProviderEvent, resolveStatusChangeUsage, } from "./terminal.js";
|
|
7
7
|
describe("terminal route validation", () => {
|
|
8
8
|
it("requires agentId and workspacePath for start", () => {
|
|
9
9
|
const validateStartRequest = (body) => {
|
|
@@ -377,6 +377,44 @@ describe("SDK status usage forwarding", () => {
|
|
|
377
377
|
},
|
|
378
378
|
});
|
|
379
379
|
});
|
|
380
|
+
it("includes file paths and commands in tool status action details", () => {
|
|
381
|
+
expect(resolveRuntimeStatusFromProviderEvent({
|
|
382
|
+
type: "tool_use_start",
|
|
383
|
+
sessionId: "session-1",
|
|
384
|
+
timestamp: new Date(0).toISOString(),
|
|
385
|
+
data: {
|
|
386
|
+
toolName: "builtin/read_file",
|
|
387
|
+
toolInput: { path: "src/views/App.vue" },
|
|
388
|
+
toolUseId: "tool-read",
|
|
389
|
+
},
|
|
390
|
+
})).toEqual({
|
|
391
|
+
status: "tool_using",
|
|
392
|
+
actionInfo: {
|
|
393
|
+
actionType: "read_file",
|
|
394
|
+
actionLabel: "读取文件",
|
|
395
|
+
actionDetail: "src/views/App.vue",
|
|
396
|
+
actionId: "tool-read",
|
|
397
|
+
},
|
|
398
|
+
});
|
|
399
|
+
expect(resolveRuntimeStatusFromProviderEvent({
|
|
400
|
+
type: "tool_use_start",
|
|
401
|
+
sessionId: "session-1",
|
|
402
|
+
timestamp: new Date(0).toISOString(),
|
|
403
|
+
data: {
|
|
404
|
+
toolName: "bash",
|
|
405
|
+
toolInput: { command: "npm run test:agent-timeline-panel" },
|
|
406
|
+
toolUseId: "tool-bash",
|
|
407
|
+
},
|
|
408
|
+
})).toEqual({
|
|
409
|
+
status: "tool_using",
|
|
410
|
+
actionInfo: {
|
|
411
|
+
actionType: "bash",
|
|
412
|
+
actionLabel: "执行命令",
|
|
413
|
+
actionDetail: "npm run test:agent-timeline-panel",
|
|
414
|
+
actionId: "tool-bash",
|
|
415
|
+
},
|
|
416
|
+
});
|
|
417
|
+
});
|
|
380
418
|
});
|
|
381
419
|
describe("SDK output forwarding", () => {
|
|
382
420
|
it("formats assistant text provider events for the terminal output callback path", () => {
|
|
@@ -425,6 +463,85 @@ describe("SDK output forwarding", () => {
|
|
|
425
463
|
};
|
|
426
464
|
expect(formatSdkOutputEvent(requestEvent)).toBe("\r\n[ACode] 正在请求模型 test-model:inspect status\r\n");
|
|
427
465
|
});
|
|
466
|
+
it("builds ACode log metadata for output callbacks", () => {
|
|
467
|
+
const requestEvent = {
|
|
468
|
+
type: "ai_request",
|
|
469
|
+
sessionId: "session-1",
|
|
470
|
+
timestamp: new Date(0).toISOString(),
|
|
471
|
+
data: { model: "test-model", endpoint: "openai-compatible", toolCount: 2 },
|
|
472
|
+
};
|
|
473
|
+
const errorEvent = {
|
|
474
|
+
type: "error",
|
|
475
|
+
sessionId: "session-1",
|
|
476
|
+
timestamp: new Date(0).toISOString(),
|
|
477
|
+
data: { text: "provider failed" },
|
|
478
|
+
};
|
|
479
|
+
expect(buildSdkOutputMetadata(requestEvent)).toEqual({
|
|
480
|
+
sourceEventType: "ai_request",
|
|
481
|
+
logCategory: "acode",
|
|
482
|
+
logLevel: "info",
|
|
483
|
+
logMessage: "AI request started: test-model @ openai-compatible, tools=2",
|
|
484
|
+
});
|
|
485
|
+
expect(buildSdkOutputMetadata(errorEvent)).toEqual({
|
|
486
|
+
sourceEventType: "error",
|
|
487
|
+
logCategory: "acode",
|
|
488
|
+
logLevel: "error",
|
|
489
|
+
logMessage: "provider failed",
|
|
490
|
+
});
|
|
491
|
+
});
|
|
492
|
+
it("does not mark streaming text chunks as standalone ACode log rows", () => {
|
|
493
|
+
const metadata = buildSdkOutputMetadata({
|
|
494
|
+
type: "text_delta",
|
|
495
|
+
sessionId: "session-1",
|
|
496
|
+
data: { text: "word" },
|
|
497
|
+
});
|
|
498
|
+
expect(metadata).toEqual({
|
|
499
|
+
sourceEventType: "text_delta",
|
|
500
|
+
logCategory: "acode",
|
|
501
|
+
});
|
|
502
|
+
});
|
|
503
|
+
it("includes file paths and commands in ACode tool log metadata", () => {
|
|
504
|
+
const readEvent = {
|
|
505
|
+
type: "tool_use_start",
|
|
506
|
+
sessionId: "session-1",
|
|
507
|
+
timestamp: new Date(0).toISOString(),
|
|
508
|
+
data: {
|
|
509
|
+
toolName: "read_file",
|
|
510
|
+
toolInput: { path: "src/index.ts" },
|
|
511
|
+
},
|
|
512
|
+
};
|
|
513
|
+
const editEvent = {
|
|
514
|
+
type: "tool_use_start",
|
|
515
|
+
sessionId: "session-1",
|
|
516
|
+
timestamp: new Date(0).toISOString(),
|
|
517
|
+
data: {
|
|
518
|
+
toolName: "edit",
|
|
519
|
+
toolInput: { file_path: "src/app.ts" },
|
|
520
|
+
},
|
|
521
|
+
};
|
|
522
|
+
const writeEvent = {
|
|
523
|
+
type: "tool_use_end",
|
|
524
|
+
sessionId: "session-1",
|
|
525
|
+
timestamp: new Date(0).toISOString(),
|
|
526
|
+
data: {
|
|
527
|
+
toolName: "write_file",
|
|
528
|
+
toolInput: { path: "src/new-file.ts" },
|
|
529
|
+
},
|
|
530
|
+
};
|
|
531
|
+
const bashEvent = {
|
|
532
|
+
type: "tool_use_start",
|
|
533
|
+
sessionId: "session-1",
|
|
534
|
+
timestamp: new Date(0).toISOString(),
|
|
535
|
+
data: {
|
|
536
|
+
toolName: "bash",
|
|
537
|
+
toolInput: { command: "npm run build -- --mode production" },
|
|
538
|
+
},
|
|
539
|
+
};
|
|
540
|
+
expect(buildSdkOutputMetadata(readEvent).logMessage).toBe("开始读取文件: src/index.ts");
|
|
541
|
+
expect(buildSdkOutputMetadata(editEvent).logMessage).toBe("开始编辑文件: src/app.ts");
|
|
542
|
+
expect(buildSdkOutputMetadata(writeEvent).logMessage).toBe("完成写入文件: src/new-file.ts");
|
|
543
|
+
expect(buildSdkOutputMetadata(bashEvent).logMessage).toBe("开始执行命令: npm run build -- --mode production");
|
|
544
|
+
});
|
|
428
545
|
});
|
|
429
546
|
describe("SDK tool result timeline action info", () => {
|
|
430
547
|
it("keeps MCP tool results on MCP timeline events", () => {
|
|
@@ -15,6 +15,12 @@ interface RuntimeStatusActionInfo {
|
|
|
15
15
|
export interface RuntimeCallbackAuthOptions {
|
|
16
16
|
runtimeAccessToken?: string;
|
|
17
17
|
}
|
|
18
|
+
export interface RuntimeOutputMetadata {
|
|
19
|
+
sourceEventType?: string;
|
|
20
|
+
logLevel?: "info" | "warn" | "error";
|
|
21
|
+
logMessage?: string;
|
|
22
|
+
logCategory?: string;
|
|
23
|
+
}
|
|
18
24
|
/** 活跃会话存储 */
|
|
19
25
|
export declare const sessions: Map<string, Session>;
|
|
20
26
|
/**
|
|
@@ -37,9 +43,7 @@ export declare function sendStatus(agentId: string, sessionId: string | null, st
|
|
|
37
43
|
* @param sessionId - 会话 ID
|
|
38
44
|
* @param seq - 序列号
|
|
39
45
|
*/
|
|
40
|
-
export declare function sendOutput(agentId: string, output: string, sessionId: string, seq: number, metadata?:
|
|
41
|
-
sourceEventType?: string;
|
|
42
|
-
}, authOptions?: RuntimeCallbackAuthOptions): Promise<void>;
|
|
46
|
+
export declare function sendOutput(agentId: string, output: string, sessionId: string, seq: number, metadata?: RuntimeOutputMetadata, authOptions?: RuntimeCallbackAuthOptions): Promise<void>;
|
|
43
47
|
/**
|
|
44
48
|
* 发送 AskUserQuestion 事件到调度器。
|
|
45
49
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"session-output.d.ts","sourceRoot":"","sources":["../../src/services/session-output.ts"],"names":[],"mappings":"AAA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