@wacry/codeks-bridge 0.0.16 → 0.0.18
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/NOTICE +3 -2
- package/README.md +1 -1
- package/catalog/README.md +11 -6
- package/catalog/codex-auto-review.json +4 -2
- package/catalog/gpt-5.5.json +3 -2
- package/catalog/gpt-5.6-luna.json +4 -2
- package/catalog/gpt-5.6-sol.json +4 -2
- package/catalog/gpt-5.6-terra.json +4 -2
- package/catalog/gpt-6-astra.json +4 -2
- package/catalog/gpt-6-luna.json +4 -2
- package/catalog/gpt-6-sol.json +4 -2
- package/catalog/gpt-6.1-sol.json +4 -2
- package/catalog/gpt-6.1-terra.json +143 -0
- package/catalog/gpt-daybreak-blue-latest.json +4 -2
- package/catalog/gpt-daybreak-red-latest.json +4 -2
- package/catalog/gpt-reserve.json +3 -2
- package/dist/inspect/view.d.ts +21 -0
- package/dist/inspect/view.js +90 -1
- package/dist/model-catalog.d.ts +1 -1
- package/dist/model-catalog.js +1 -1
- package/dist/tool-calls.d.ts +5 -0
- package/dist/tool-calls.js +8 -0
- package/docs/config.md +1 -1
- package/docs/design.md +1 -1
- package/docs/inspect.md +20 -2
- package/package.json +1 -1
- package/ui/app.css +1 -0
- package/ui/detail.js +45 -25
- package/ui/events.js +1 -1
- package/ui/labels.js +13 -2
- package/ui/list.js +11 -13
- package/ui/status.js +49 -0
package/dist/inspect/view.d.ts
CHANGED
|
@@ -6,6 +6,18 @@ export interface SseRecord {
|
|
|
6
6
|
data: string;
|
|
7
7
|
}
|
|
8
8
|
type Outcome = "active" | "completed" | "incomplete" | "failed" | "error" | "aborted";
|
|
9
|
+
interface Failure {
|
|
10
|
+
kind: "http" | "protocol" | "transport";
|
|
11
|
+
message: string | null;
|
|
12
|
+
}
|
|
13
|
+
export interface ToolDiagnostic {
|
|
14
|
+
target: "client.request" | "client.response";
|
|
15
|
+
pointer: string;
|
|
16
|
+
event?: number;
|
|
17
|
+
call_id: string;
|
|
18
|
+
name: string;
|
|
19
|
+
message: string;
|
|
20
|
+
}
|
|
9
21
|
export interface Annotation {
|
|
10
22
|
target: "client.request" | "client.response";
|
|
11
23
|
pointer: string;
|
|
@@ -42,6 +54,7 @@ export declare function summary(exchange: Exchange): {
|
|
|
42
54
|
outcome: Outcome;
|
|
43
55
|
error: string | null;
|
|
44
56
|
usage: unknown;
|
|
57
|
+
tool_error_count: number;
|
|
45
58
|
thread: {
|
|
46
59
|
session_id: string | null;
|
|
47
60
|
thread_id: string | null;
|
|
@@ -52,6 +65,7 @@ export declare function summary(exchange: Exchange): {
|
|
|
52
65
|
input_items: number | null;
|
|
53
66
|
preview: string | null;
|
|
54
67
|
upstream_calls: {
|
|
68
|
+
failure?: Failure | undefined;
|
|
55
69
|
label: string;
|
|
56
70
|
status: number | null;
|
|
57
71
|
end: import("./capture.ts").EndKind;
|
|
@@ -108,6 +122,7 @@ export declare function detail(exchange: Exchange): {
|
|
|
108
122
|
ended_ms: number | null;
|
|
109
123
|
end: import("./capture.ts").EndKind;
|
|
110
124
|
error: string | null;
|
|
125
|
+
failure: Failure | null;
|
|
111
126
|
body: {
|
|
112
127
|
text: string;
|
|
113
128
|
bytes: number;
|
|
@@ -135,6 +150,7 @@ export declare function detail(exchange: Exchange): {
|
|
|
135
150
|
ended_ms: number | null;
|
|
136
151
|
end: import("./capture.ts").EndKind;
|
|
137
152
|
error: string | null;
|
|
153
|
+
failure: Failure | null;
|
|
138
154
|
body: {
|
|
139
155
|
text: string;
|
|
140
156
|
bytes: number;
|
|
@@ -143,6 +159,7 @@ export declare function detail(exchange: Exchange): {
|
|
|
143
159
|
} | null;
|
|
144
160
|
}[];
|
|
145
161
|
annotations: Annotation[];
|
|
162
|
+
tool_diagnostics: ToolDiagnostic[];
|
|
146
163
|
id: string;
|
|
147
164
|
seq: number;
|
|
148
165
|
rev: number;
|
|
@@ -159,6 +176,7 @@ export declare function detail(exchange: Exchange): {
|
|
|
159
176
|
outcome: Outcome;
|
|
160
177
|
error: string | null;
|
|
161
178
|
usage: unknown;
|
|
179
|
+
tool_error_count: number;
|
|
162
180
|
thread: {
|
|
163
181
|
session_id: string | null;
|
|
164
182
|
thread_id: string | null;
|
|
@@ -169,6 +187,7 @@ export declare function detail(exchange: Exchange): {
|
|
|
169
187
|
input_items: number | null;
|
|
170
188
|
preview: string | null;
|
|
171
189
|
upstream_calls: {
|
|
190
|
+
failure?: Failure | undefined;
|
|
172
191
|
label: string;
|
|
173
192
|
status: number | null;
|
|
174
193
|
end: import("./capture.ts").EndKind;
|
|
@@ -219,6 +238,7 @@ export declare function listView(inspector: Inspector, since: number): {
|
|
|
219
238
|
outcome: Outcome;
|
|
220
239
|
error: string | null;
|
|
221
240
|
usage: unknown;
|
|
241
|
+
tool_error_count: number;
|
|
222
242
|
thread: {
|
|
223
243
|
session_id: string | null;
|
|
224
244
|
thread_id: string | null;
|
|
@@ -229,6 +249,7 @@ export declare function listView(inspector: Inspector, since: number): {
|
|
|
229
249
|
input_items: number | null;
|
|
230
250
|
preview: string | null;
|
|
231
251
|
upstream_calls: {
|
|
252
|
+
failure?: Failure | undefined;
|
|
232
253
|
label: string;
|
|
233
254
|
status: number | null;
|
|
234
255
|
end: import("./capture.ts").EndKind;
|
package/dist/inspect/view.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { decodeCompaction, decodeReasoning } from "../carrier.js";
|
|
2
2
|
import { resolveModel, upstreamBaseUrl } from "../config.js";
|
|
3
3
|
import { replaysReasoning, restoresNativeCompaction } from "../history.js";
|
|
4
|
+
import { toolCallDiagnostic } from "../tool-calls.js";
|
|
4
5
|
/** Splits timed text into SSE events. An event takes the time of the part that completed it. */
|
|
5
6
|
export function sseEvents(parts, finished = true) {
|
|
6
7
|
const events = [];
|
|
@@ -84,6 +85,43 @@ function terminal(data, status) {
|
|
|
84
85
|
return undefined;
|
|
85
86
|
}
|
|
86
87
|
const results = new WeakMap();
|
|
88
|
+
const failures = new WeakMap();
|
|
89
|
+
/** A connection close must not hide an error already reported on that response. */
|
|
90
|
+
function responseFailure(response) {
|
|
91
|
+
if (failures.has(response))
|
|
92
|
+
return failures.get(response);
|
|
93
|
+
let failure = null;
|
|
94
|
+
if ((response.status ?? 0) >= 400) {
|
|
95
|
+
const body = parse(response.text());
|
|
96
|
+
const message = body?.error?.message ?? (typeof body?.error === "string" ? body.error : null);
|
|
97
|
+
const error = message ?? response.text().slice(0, 200);
|
|
98
|
+
failure = { diagnostic: { kind: "http", message: error }, result: { outcome: "error", error, usage: null } };
|
|
99
|
+
}
|
|
100
|
+
else if (response.end === "error") {
|
|
101
|
+
const error = response.error ?? null;
|
|
102
|
+
failure = { diagnostic: { kind: "transport", message: error }, result: { outcome: "error", error, usage: null } };
|
|
103
|
+
}
|
|
104
|
+
else {
|
|
105
|
+
const data = isSse(response)
|
|
106
|
+
? sseEvents(response.parts, response.end === "complete" || response.end === "unread").map(event => parse(event.data))
|
|
107
|
+
: [parse(response.text())];
|
|
108
|
+
for (let i = data.length - 1; i >= 0; i--) {
|
|
109
|
+
const found = terminal(data[i], response.status);
|
|
110
|
+
if (found?.outcome === "failed" || found?.outcome === "error") {
|
|
111
|
+
failure = { diagnostic: { kind: "protocol", message: found.error }, result: found };
|
|
112
|
+
break;
|
|
113
|
+
}
|
|
114
|
+
if (typeof data[i]?.error === "string" || (data[i]?.error && typeof data[i].error === "object")) {
|
|
115
|
+
const error = typeof data[i].error === "string" ? data[i].error : data[i].error.message ?? null;
|
|
116
|
+
failure = { diagnostic: { kind: "protocol", message: error }, result: { outcome: "error", error, usage: null } };
|
|
117
|
+
break;
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
if (response.end !== "active")
|
|
122
|
+
failures.set(response, failure);
|
|
123
|
+
return failure;
|
|
124
|
+
}
|
|
87
125
|
/** What the client saw, from its terminal event or JSON body. */
|
|
88
126
|
function result(exchange) {
|
|
89
127
|
if (!exchange.closed)
|
|
@@ -92,8 +130,11 @@ function result(exchange) {
|
|
|
92
130
|
if (cached)
|
|
93
131
|
return cached;
|
|
94
132
|
const response = exchange.response;
|
|
133
|
+
const failure = responseFailure(response);
|
|
95
134
|
let value;
|
|
96
|
-
if (
|
|
135
|
+
if (failure)
|
|
136
|
+
value = failure.result;
|
|
137
|
+
else if (response.end === "cancelled")
|
|
97
138
|
value = { outcome: "aborted", error: response.error ?? null, usage: null };
|
|
98
139
|
else if (response.status === undefined)
|
|
99
140
|
value = { outcome: "error", error: "No response was written", usage: null };
|
|
@@ -118,6 +159,50 @@ function result(exchange) {
|
|
|
118
159
|
results.set(exchange, value);
|
|
119
160
|
return value;
|
|
120
161
|
}
|
|
162
|
+
const toolNotes = new WeakMap();
|
|
163
|
+
function toolDiagnostics(exchange) {
|
|
164
|
+
const cached = toolNotes.get(exchange);
|
|
165
|
+
if (cached)
|
|
166
|
+
return cached;
|
|
167
|
+
const notes = [];
|
|
168
|
+
const outputCalls = new Set();
|
|
169
|
+
const add = (item, target, pointer, event) => {
|
|
170
|
+
if (!item || typeof item !== "object")
|
|
171
|
+
return;
|
|
172
|
+
const diagnostic = toolCallDiagnostic(item);
|
|
173
|
+
if (!diagnostic)
|
|
174
|
+
return;
|
|
175
|
+
if (target === "client.response") {
|
|
176
|
+
if (!["function_call", "custom_tool_call"].includes(item.type) || outputCalls.has(item.call_id))
|
|
177
|
+
return;
|
|
178
|
+
outputCalls.add(item.call_id);
|
|
179
|
+
}
|
|
180
|
+
notes.push({ target, pointer, ...(event === undefined ? {} : { event }), call_id: item.call_id, ...diagnostic });
|
|
181
|
+
};
|
|
182
|
+
if (exchange.requestText?.includes("cxbt1_")) {
|
|
183
|
+
const input = parse(exchange.requestText)?.input;
|
|
184
|
+
if (Array.isArray(input))
|
|
185
|
+
input.forEach((item, index) => add(item, "client.request", `/input/${index}`));
|
|
186
|
+
}
|
|
187
|
+
if (exchange.response.text().includes("cxbt1_")) {
|
|
188
|
+
if (isSse(exchange.response)) {
|
|
189
|
+
sseEvents(exchange.response.parts, exchange.response.end === "complete").forEach((event, index) => {
|
|
190
|
+
const data = parse(event.data);
|
|
191
|
+
// Added/delta events are tentative; codeks persists completed items only.
|
|
192
|
+
if (data?.type === "response.output_item.done")
|
|
193
|
+
add(data.item, "client.response", "/item", index);
|
|
194
|
+
});
|
|
195
|
+
}
|
|
196
|
+
else {
|
|
197
|
+
const output = parse(exchange.response.text())?.output;
|
|
198
|
+
if (Array.isArray(output))
|
|
199
|
+
output.forEach((item, index) => add(item, "client.response", `/output/${index}`));
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
if (exchange.closed)
|
|
203
|
+
toolNotes.set(exchange, notes);
|
|
204
|
+
return notes;
|
|
205
|
+
}
|
|
121
206
|
const originNames = new WeakMap();
|
|
122
207
|
/** Maps source fingerprints back to the aliases that produce them. */
|
|
123
208
|
function aliases(inspector) {
|
|
@@ -167,6 +252,7 @@ export function summary(exchange) {
|
|
|
167
252
|
outcome,
|
|
168
253
|
error,
|
|
169
254
|
usage,
|
|
255
|
+
tool_error_count: toolDiagnostics(exchange).filter(note => note.target === "client.response").length,
|
|
170
256
|
thread: {
|
|
171
257
|
session_id: header(exchange, "session-id") ?? header(exchange, "session_id"),
|
|
172
258
|
thread_id: header(exchange, "thread-id") ?? header(exchange, "thread_id"),
|
|
@@ -180,6 +266,7 @@ export function summary(exchange) {
|
|
|
180
266
|
label: call.label,
|
|
181
267
|
status: call.response?.status ?? null,
|
|
182
268
|
end: call.response?.end ?? (call.error !== undefined ? "error" : "active"),
|
|
269
|
+
...(call.response && responseFailure(call.response) ? { failure: responseFailure(call.response).diagnostic } : {}),
|
|
183
270
|
})),
|
|
184
271
|
bytes: {
|
|
185
272
|
request: exchange.requestBytes,
|
|
@@ -222,6 +309,7 @@ function messageView(message) {
|
|
|
222
309
|
ended_ms: message.endedMs ?? null,
|
|
223
310
|
end: message.end,
|
|
224
311
|
error: message.error ?? null,
|
|
312
|
+
failure: responseFailure(message)?.diagnostic ?? null,
|
|
225
313
|
body: { text: message.text(), bytes: message.bytes },
|
|
226
314
|
events: isSse(message) ? sseEvents(message.parts, message.end !== "active") : null,
|
|
227
315
|
};
|
|
@@ -345,6 +433,7 @@ export function detail(exchange) {
|
|
|
345
433
|
response: messageView(call.response),
|
|
346
434
|
})),
|
|
347
435
|
annotations: annotations(exchange, client),
|
|
436
|
+
tool_diagnostics: toolDiagnostics(exchange),
|
|
348
437
|
};
|
|
349
438
|
}
|
|
350
439
|
export function stateView(inspector) {
|
package/dist/model-catalog.d.ts
CHANGED
|
@@ -18,6 +18,6 @@ export interface CatalogEntry {
|
|
|
18
18
|
max_output_tokens?: number;
|
|
19
19
|
model: Record<string, any>;
|
|
20
20
|
}
|
|
21
|
-
export declare const catalogKeys: readonly ["gpt-6-astra", "gpt-6.1-sol", "gpt-6-sol", "gpt-6-luna", "gpt-5.6-sol", "gpt-5.6-terra", "gpt-5.6-luna", "gpt-5.5", "gpt-daybreak-blue-latest", "gpt-daybreak-red-latest", "codex-auto-review", "gpt-reserve", "claude-opus-5-5", "claude-sonnet-5-5", "claude-haiku-5-5", "deepseek-flash"];
|
|
21
|
+
export declare const catalogKeys: readonly ["gpt-6-astra", "gpt-6.1-sol", "gpt-6.1-terra", "gpt-6-sol", "gpt-6-luna", "gpt-5.6-sol", "gpt-5.6-terra", "gpt-5.6-luna", "gpt-5.5", "gpt-daybreak-blue-latest", "gpt-daybreak-red-latest", "codex-auto-review", "gpt-reserve", "claude-opus-5-5", "claude-sonnet-5-5", "claude-haiku-5-5", "deepseek-flash"];
|
|
22
22
|
/** Each alias gets its own copy of the reviewed entry. */
|
|
23
23
|
export declare function getCatalogEntry(key: string): CatalogEntry;
|
package/dist/model-catalog.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { readFileSync } from "node:fs";
|
|
2
2
|
import { BridgeError } from "./errors.js";
|
|
3
3
|
export const catalogKeys = [
|
|
4
|
-
"gpt-6-astra", "gpt-6.1-sol", "gpt-6-sol", "gpt-6-luna", "gpt-5.6-sol", "gpt-5.6-terra", "gpt-5.6-luna",
|
|
4
|
+
"gpt-6-astra", "gpt-6.1-sol", "gpt-6.1-terra", "gpt-6-sol", "gpt-6-luna", "gpt-5.6-sol", "gpt-5.6-terra", "gpt-5.6-luna",
|
|
5
5
|
"gpt-5.5", "gpt-daybreak-blue-latest", "gpt-daybreak-red-latest", "codex-auto-review", "gpt-reserve",
|
|
6
6
|
"claude-opus-5-5", "claude-sonnet-5-5", "claude-haiku-5-5", "deepseek-flash",
|
|
7
7
|
];
|
package/dist/tool-calls.d.ts
CHANGED
|
@@ -7,6 +7,11 @@ export type ClientToolCall = {
|
|
|
7
7
|
kind: "custom";
|
|
8
8
|
call: CustomToolCallItem;
|
|
9
9
|
};
|
|
10
|
+
/** Read only diagnostics explicitly recorded by the bridge, not tool-result text. */
|
|
11
|
+
export declare function toolCallDiagnostic(item: Record<string, any>): {
|
|
12
|
+
name: string;
|
|
13
|
+
message: string;
|
|
14
|
+
} | undefined;
|
|
10
15
|
/** Resolve a model's name without changing the declared tool table. */
|
|
11
16
|
export declare function prepareToolCall(tools: ToolSet, id: string, name: string, args: Record<string, unknown>, argumentsText?: string): ClientToolCall;
|
|
12
17
|
export declare function writeToolCall(writer: ResponseWriter, prepared: ClientToolCall): void;
|
package/dist/tool-calls.js
CHANGED
|
@@ -16,6 +16,14 @@ function decode(id) {
|
|
|
16
16
|
}
|
|
17
17
|
catch { /* Unrecognized ids remain opaque. */ }
|
|
18
18
|
}
|
|
19
|
+
/** Read only diagnostics explicitly recorded by the bridge, not tool-result text. */
|
|
20
|
+
export function toolCallDiagnostic(item) {
|
|
21
|
+
if (!["function_call", "custom_tool_call", "function_call_output", "custom_tool_call_output"].includes(item.type))
|
|
22
|
+
return;
|
|
23
|
+
const wire = decode(item.call_id);
|
|
24
|
+
if (wire?.error !== undefined)
|
|
25
|
+
return { name: wire.name, message: wire.error };
|
|
26
|
+
}
|
|
19
27
|
/** Resolve a model's name without changing the declared tool table. */
|
|
20
28
|
export function prepareToolCall(tools, id, name, args, argumentsText = JSON.stringify(args)) {
|
|
21
29
|
if (typeof id !== "string" || !id || typeof name !== "string" || !name) {
|
package/docs/config.md
CHANGED
|
@@ -330,7 +330,7 @@ GPT 将透传项保留在 Responses `input` 中,包括其 `id`;Claude/DeepSe
|
|
|
330
330
|
|
|
331
331
|
bridge 的 `GET /v1/models` 返回 Codex 专用的 `{"models": [...]}`,每项包含完整提示词、窗口、工具、多代理和 reasoning 元数据。它与经典 OpenAI 的 `{"object":"list","data":[...]}` 格式不同。仅列出配置中的别名,不暴露上游连接、实际部署名或凭据设置。
|
|
332
332
|
|
|
333
|
-
这些条目来自仓库内已审阅的 [catalog](../catalog/README.md),运行时只展开别名和显式配置覆盖。GPT
|
|
333
|
+
这些条目来自仓库内已审阅的 [catalog](../catalog/README.md),运行时只展开别名和显式配置覆盖。GPT 优先使用自己的 Codex 源码条目,源码尚未收录的模型使用已审阅订阅快照;Claude 和 DeepSeek 使用经过精调的 GPT-6.1 Sol 模板。不会启动 codeks 导出模板,也不请求订阅账号的模型目录。目录版本随 bridge 代码更新,升级客户端不会自动改写它。
|
|
334
334
|
|
|
335
335
|
### HTTP 发现
|
|
336
336
|
|
package/docs/design.md
CHANGED
|
@@ -30,7 +30,7 @@ Lite 仍调用 `/responses` 并返回 Responses SSE。完整工具 schema 位于
|
|
|
30
30
|
|
|
31
31
|
## 有限目录与显式精调
|
|
32
32
|
|
|
33
|
-
项目只支持明确列出的模型。`catalog/` 保存每个模型的完整条目及来源;GPT 分别使用 Codex 源码中各自的版本,保留提示词、默认 effort
|
|
33
|
+
项目只支持明确列出的模型。`catalog/` 保存每个模型的完整条目及来源;GPT 分别使用 Codex 源码中各自的版本,保留提示词、默认 effort、摘要、窗口和工具元数据的差异,所有 GPT 统一使用 `shell_type: "unified_exec"`;旧 shell 名称的等价转换、GPT-5.5 的 Lite 调整及用户指定的窗口调整均记录在各条目的 `adjustments`。源码尚未收录的 GPT-6.1 Terra、GPT-Reserve 使用取得并审阅的订阅目录快照,记录端点、取得日期与客户端版本;具体来源与公开信息处理见[模型目录](../catalog/README.md)。Claude 与 DeepSeek 从 GPT-6.1 Sol 模板开始,只替换底层模型身份(如 `You are Codex, an agent based on Claude.`),保留 Codex 代理角色及 `As Codex` 人格说明;参数和确有差异的能力逐项精调,记录在条目的 `adjustments`。摘要默认值继续使用模板的 `none`,是否展示由客户端配置决定,不为第三方模型强制打开。
|
|
34
34
|
|
|
35
35
|
导入脚本只生成独立候选文件,供人或 Agent 对比审阅。运行时使用已提交的完整条目,不自动导入、不猜测未知模型,也不从 ChatGPT 订阅获取目录。这样更新仍有工具辅助,同时提示词和能力变化可审查、可追踪。来源及更新步骤见[模型目录](../catalog/README.md)。
|
|
36
36
|
|
package/docs/inspect.md
CHANGED
|
@@ -41,7 +41,7 @@ codeks-bridge serve --config /absolute/path/bridge.json --capture
|
|
|
41
41
|
|
|
42
42
|
## 使用页面
|
|
43
43
|
|
|
44
|
-
左侧列表每行是一次交换,显示开始时间、模型别名和 adapter、类型(轮次、压缩、搜索或图片生成)、每个上游调用的状态、token 用量、子代理与父线程标记和预览。顶部可以按文字筛选(按 `/`
|
|
44
|
+
左侧列表每行是一次交换,显示开始时间、模型别名和 adapter、类型(轮次、压缩、搜索或图片生成)、每个上游调用的状态、token 用量、子代理与父线程标记和预览。顶部可以按文字筛选(按 `/` 聚焦),或只看需关注、压缩、进行中的交换;“需关注”包括失败、断开、未完成及本次无效工具调用。“按线程分组”把同一线程的请求放在一起。`↑`/`↓` 切换选中项。列表每 1.5 秒刷新,标签页隐藏时暂停。
|
|
45
45
|
|
|
46
46
|
右侧顶部的卡片按数据流排列:① codeks → bridge,② bridge → 上游,③ 上游 → bridge,④ bridge → codeks。每个实际上游调用各占一行,并显示 `main`、`summary`、`native`、`handoff`、`search` 或 `image_generation` 标签。点击卡片查看这一段的正文,Shift+点击在右侧并排打开第二段。每段正文有几种视图:
|
|
47
47
|
|
|
@@ -93,7 +93,25 @@ codeks-bridge serve --config /absolute/path/bridge.json --capture
|
|
|
93
93
|
| `cancelled` | 客户端断开;仍在进行的上游调用随之标记为 `cancelled` |
|
|
94
94
|
| `error` | 传输出错,`error` 字段给出原因 |
|
|
95
95
|
|
|
96
|
-
交换的 `outcome` 来自写回 codeks
|
|
96
|
+
交换的 `outcome` 来自写回 codeks 的内容:流式响应取终止事件(`response.completed`、`response.incomplete`、`response.failed`、`error`),非流式 Responses 响应取 JSON 的 `status`,独立搜索和图片等普通 JSON 响应按 HTTP 状态判断。明确的 HTTP、协议或传输失败优先保留,即使随后连接关闭也不降为普通断开。没有已知失败的客户端断开为 `aborted`;没有写出响应或流结束却没有终止事件时为 `error`。
|
|
97
|
+
|
|
98
|
+
## 响应状态与工具诊断
|
|
99
|
+
|
|
100
|
+
HTTP 200 只表示响应头已成功返回。检查器分别展示响应完成状态和本次工具诊断,不用一个颜色代表所有层次:
|
|
101
|
+
|
|
102
|
+
| 证据 | 展示 |
|
|
103
|
+
| --- | --- |
|
|
104
|
+
| 响应正常完成 | 绿色“响应完成”,HTTP 状态单独显示 |
|
|
105
|
+
| 客户端提前断开,没有明确失败 | 黄色“客户端断开”;仍可用“需关注”筛选 |
|
|
106
|
+
| HTTP 错误、明确协议失败或传输异常 | 红色错误,保留原始详情 |
|
|
107
|
+
| 本次完成响应包含无效工具调用 | 保留响应完成,另加红色“无效工具调用”计数 |
|
|
108
|
+
| 请求输入含此前的无效调用 | 在对应输入项标注“历史工具诊断”,不影响本次响应状态 |
|
|
109
|
+
|
|
110
|
+
这里的客户端是 codeks。用户停止、子代理消息到达后的重新采样或网络中断,都可能表现为连接提前关闭;bridge 没有收到取消原因,因此不会依据请求间隔、下一条请求或错误文字猜测“正常取消”。没有终止事件时,结构视图明确显示“未完成响应快照”,保留原始 `in_progress` 等字段,不补造成功结果。
|
|
111
|
+
|
|
112
|
+
工具诊断复用 bridge 工具载体的解析逻辑,只识别合法 `cxbt1_` 载体中明确保存的 `error`,展示原始工具名和完整诊断。成功识别的别名也会使用这个前缀,前缀本身不代表错误。普通工具输出中出现 `error` 或 `unsupported call` 等文字不会触发自动标红。
|
|
113
|
+
|
|
114
|
+
本次计数只取已交付的 `output_item.done` 或完整 JSON 输出,按 call ID 去重;开始生成但未交付的工具调用不计入。输入里的失败调用与结果分别定位,作为历史诊断展示,不让同一错误反复影响后续请求。检查器显示和导出的诊断是旁注,原始请求、响应与工具执行行为保持原样。
|
|
97
115
|
|
|
98
116
|
## 状态标注
|
|
99
117
|
|
package/package.json
CHANGED
package/ui/app.css
CHANGED
|
@@ -42,6 +42,7 @@ h3, h4 { margin: 0; }
|
|
|
42
42
|
.mono, .tree, .raw, .sv-text, .ev-list, .diff-tree, .fields, .kv td { font-family: var(--mono); font-size: 12px; }
|
|
43
43
|
.dim { color: var(--fg2); }
|
|
44
44
|
.err { color: var(--bad); }
|
|
45
|
+
.warning-text { color: var(--warn); }
|
|
45
46
|
.grow { flex: 1 1 auto; }
|
|
46
47
|
.note { padding: 4px 8px; margin: 0 0 8px; background: var(--info-bg); border-left: 3px solid var(--info); border-radius: 3px; font-size: 12px; }
|
|
47
48
|
.server-transformations { margin-bottom: 12px; }
|
package/ui/detail.js
CHANGED
|
@@ -6,7 +6,8 @@ import { structureView, newStructState, focusPointer } from './structure.js';
|
|
|
6
6
|
import { eventsView, newEventsState, finalObject, inputTransformationReports, parseEvents, usageText } from './events.js';
|
|
7
7
|
import { diffView } from './diff.js';
|
|
8
8
|
import { annChip, annDetail, annIndex, callLabel, decisionClass, decisionText, END_LABEL, INPUT_TRANSFORMATION_LABEL, KIND_LABEL, KIND_TEXT, OUTCOME_LABEL, reasonText, sourceText } from './labels.js';
|
|
9
|
-
import {
|
|
9
|
+
import { threadKey, byNewest } from './list.js';
|
|
10
|
+
import { exchangeClass, responseClass as respClass, responseFailure } from './status.js';
|
|
10
11
|
import { exportDoc } from './api.js';
|
|
11
12
|
import { responseLatency } from './latency.js';
|
|
12
13
|
|
|
@@ -38,7 +39,7 @@ export function stagesOf(d) {
|
|
|
38
39
|
out.push({ key: `upres:${keys[i]}`, type: 'response', num: '③', title: '上游 → bridge', sub: label, call, resp: call.response ?? null });
|
|
39
40
|
});
|
|
40
41
|
out.push({ key: 'res', type: 'response', num: '④', title: 'bridge → codeks', sub: '客户端响应', target: 'client.response', resp: d.client?.response ?? null });
|
|
41
|
-
out.push({ key: 'ann', type: 'ann', title:
|
|
42
|
+
out.push({ key: 'ann', type: 'ann', title: '标注与工具诊断' });
|
|
42
43
|
out.push({ key: 'diff', type: 'diff', title: '对比' });
|
|
43
44
|
return out;
|
|
44
45
|
}
|
|
@@ -52,25 +53,20 @@ export function parseBody(body) {
|
|
|
52
53
|
return r;
|
|
53
54
|
}
|
|
54
55
|
|
|
55
|
-
const respSig = (r) => (r ? `${r.status}|${r.end}|${r.ended_ms}|${r.body?.bytes}|${r.events?.length}|${r.error}` : 'none');
|
|
56
|
+
const respSig = (r) => (r ? `${r.status}|${r.end}|${r.ended_ms}|${r.body?.bytes}|${r.events?.length}|${r.error}|${JSON.stringify(r.failure)}` : 'none');
|
|
56
57
|
|
|
57
58
|
function paneSig(stage, d) {
|
|
58
59
|
if (!stage) return 'missing';
|
|
59
60
|
switch (stage.type) {
|
|
60
|
-
case 'request': return `${stage.msg?.body?.bytes}|${stage.call?.error ?? ''}|${stage.call?.response ? 1 : 0}`;
|
|
61
|
-
case 'response': return `${respSig(stage.resp)}|${stage.call?.error ?? ''}|${d.annotations?.length}`;
|
|
61
|
+
case 'request': return `${stage.msg?.body?.bytes}|${stage.call?.error ?? ''}|${stage.call?.response ? 1 : 0}|${d.tool_diagnostics?.length}`;
|
|
62
|
+
case 'response': return `${respSig(stage.resp)}|${stage.call?.error ?? ''}|${d.annotations?.length}|${d.tool_diagnostics?.length}`;
|
|
62
63
|
case 'diff': return 'diff';
|
|
63
64
|
default: return `${d.rev}|${respSig(d.client?.response)}|${(d.upstream ?? []).map((c) => respSig(c.response)).join(',')}|${d.annotations?.length}`;
|
|
64
65
|
}
|
|
65
66
|
}
|
|
66
67
|
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
if (!r) return 'dim';
|
|
70
|
-
if (r.end === 'active') return 'info';
|
|
71
|
-
if (r.end === 'cancelled') return 'warn';
|
|
72
|
-
return 'ok';
|
|
73
|
-
};
|
|
68
|
+
// Reuse item/event annotation placement without merging tool errors into replay decisions.
|
|
69
|
+
const rowAnnotations = (d) => [...(d.annotations ?? []), ...(d.tool_diagnostics ?? []).map(a => ({ ...a, kind: 'tool_error' }))];
|
|
74
70
|
|
|
75
71
|
// ---------- small renderers ----------
|
|
76
72
|
|
|
@@ -125,6 +121,7 @@ const SUMMARY_HINTS = {
|
|
|
125
121
|
id: 'ID', seq: '序号', rev: '版本', started_at: '开始', duration_ms: '耗时', active: '进行中', model: '模型别名', adapter: '适配器', api: 'API',
|
|
126
122
|
upstream: '上游配置', upstream_model: '上游模型', kind: '类型', stream: '流式', status: '状态码', outcome: '结果', error: '错误', usage: '用量',
|
|
127
123
|
thread: '线程', input_items: 'input 项数', preview: '预览', upstream_calls: '上游调用', bytes: '大小',
|
|
124
|
+
tool_error_count: '本次无效工具调用数',
|
|
128
125
|
};
|
|
129
126
|
|
|
130
127
|
function headersTable(headers, first) {
|
|
@@ -162,7 +159,7 @@ function rawView(text, name, isJson, ext) {
|
|
|
162
159
|
/** Annotation pointers usable in the structure view of the client response. */
|
|
163
160
|
function responsePointers(d) {
|
|
164
161
|
const resp = d.client?.response;
|
|
165
|
-
const { byPointer, byEvent } = annIndex(d
|
|
162
|
+
const { byPointer, byEvent } = annIndex(rowAnnotations(d), 'client.response');
|
|
166
163
|
if (!byEvent.size) return byPointer;
|
|
167
164
|
const events = parseEvents(resp) ?? [];
|
|
168
165
|
const out = new Map(byPointer);
|
|
@@ -302,12 +299,16 @@ export class DetailView {
|
|
|
302
299
|
h('span', { class: 'mono' }, fmtDateTime(d.started_at)),
|
|
303
300
|
h('span', { class: `chip kind k-${d.kind}` }, KIND_LABEL[d.kind] ?? d.kind),
|
|
304
301
|
h('span', { class: 'd-model' }, d.model ?? '(无模型)', d.adapter ? ` → ${d.adapter}` : '', d.upstream_model ? h('span', { class: 'dim' }, ` (${d.upstream_model})`) : null),
|
|
305
|
-
h('span', { class: `chip ${
|
|
302
|
+
h('span', { class: `chip ${exchangeClass(d)}` }, OUTCOME_LABEL[d.outcome] ?? d.outcome),
|
|
303
|
+
d.status != null ? h('span', { class: 'chip dim', title: 'HTTP 状态码不代表流式响应已完成' }, `HTTP ${d.status}`) : null,
|
|
304
|
+
d.tool_error_count > 0 ? h('button', { class: 'chip bad click', onclick: () => this.open('ann') }, `无效工具调用 ${d.tool_error_count}`) : null,
|
|
306
305
|
h('span', { class: 'mono' }, d.active ? '进行中…' : fmtDur(d.duration_ms)),
|
|
307
306
|
usage ? h('span', { class: 'mono dim', title: JSON.stringify(d.usage, null, 1) }, usage) : null,
|
|
308
307
|
this.gone ? h('span', { class: 'chip warn', title: '已从 bridge 清空或淘汰;这里显示的是浏览器缓存' }, '已从 bridge 移除') : null,
|
|
309
308
|
h('span', { class: 'grow' }), actions),
|
|
310
|
-
threadChips.some(Boolean) || d.error ? h('div', { class: 'd-line' }, threadChips,
|
|
309
|
+
threadChips.some(Boolean) || d.error ? h('div', { class: 'd-line' }, threadChips,
|
|
310
|
+
d.error ? h('span', { class: exchangeClass(d) === 'warn' ? 'warning-text' : 'err', title: d.error },
|
|
311
|
+
d.outcome === 'aborted' && exchangeClass(d) === 'warn' ? '客户端连接已断开,原因未确定。' : d.error) : null) : null);
|
|
311
312
|
}
|
|
312
313
|
|
|
313
314
|
renderNav(stages) {
|
|
@@ -326,7 +327,7 @@ export class DetailView {
|
|
|
326
327
|
const req = get('req');
|
|
327
328
|
const res = get('res');
|
|
328
329
|
const reqSub = [fmtBytes(req.msg?.body?.bytes), d.input_items != null ? `${d.input_items} 项` : null].filter(Boolean).join(' · ');
|
|
329
|
-
const respSub = (r, err) => (err ? '传输错误' : r ? [r.status
|
|
330
|
+
const respSub = (r, err) => (err && !r ? '传输错误' : r ? [r.status != null ? `HTTP ${r.status}` : '–', responseFailure(r, err) ? '失败' : END_LABEL[r.end] ?? r.end, r.events ? `${fmtInt(r.events.length)} 事件` : fmtBytes(r.body?.bytes)].join(' · ') : '无响应');
|
|
330
331
|
const calls = stages.filter((s) => s.key.startsWith('up:'));
|
|
331
332
|
const callBox = h('div', { class: 'pipe-calls' }, calls.length ? calls.map((s) => {
|
|
332
333
|
const r = get(`upres:${s.key.slice(3)}`);
|
|
@@ -337,6 +338,7 @@ export class DetailView {
|
|
|
337
338
|
card(r, `③ 上游 → bridge`, respSub(r.resp, s.call.error), respClass(r.resp, s.call.error)));
|
|
338
339
|
}) : h('span', { class: 'dim' }, '(没有上游调用)'));
|
|
339
340
|
const annCount = d.annotations?.length ?? 0;
|
|
341
|
+
const diagnosticCount = d.tool_diagnostics?.length ?? 0;
|
|
340
342
|
const routeSub = d.route ? `${d.route.alias ?? ''} · ${d.route.compaction_mode ?? ''}` : '无路由';
|
|
341
343
|
fill(this.navEl,
|
|
342
344
|
h('div', { class: 'pipe-side' }, card(get('overview'), '概要', null, 'mini', routeSub), card(get('diff'), '对比', null, 'mini', '与同线程上一轮或任选两条比较')),
|
|
@@ -344,7 +346,7 @@ export class DetailView {
|
|
|
344
346
|
h('span', { class: 'arrow' }, '→'), callBox, h('span', { class: 'arrow' }, '→'),
|
|
345
347
|
card(res, '④ bridge → codeks', respSub(res.resp), respClass(res.resp)),
|
|
346
348
|
h('span', { class: 'grow' }),
|
|
347
|
-
card(get('ann'), `标注 ${annCount}`, annCount ? annSummary(d.annotations) : '无', `narrow${annCount ? ' info' : ''}`),
|
|
349
|
+
card(get('ann'), `标注 ${annCount} · 诊断 ${diagnosticCount}`, d.tool_error_count > 0 ? `本次无效工具调用 ${d.tool_error_count}` : diagnosticCount ? '历史工具诊断' : annCount ? annSummary(d.annotations) : '无', `narrow${d.tool_error_count > 0 ? ' bad' : diagnosticCount ? ' warn' : annCount ? ' info' : ''}`),
|
|
348
350
|
this.panes[1] ? btn('✕ 关闭并排', () => this.closeSecond(), 'close2') : null);
|
|
349
351
|
}
|
|
350
352
|
|
|
@@ -401,12 +403,13 @@ export class DetailView {
|
|
|
401
403
|
const r = stage.resp;
|
|
402
404
|
if (!r) put(out, h('span', { class: 'dim' }, stage.call?.error ? `传输错误:${stage.call.error}` : '尚无响应'));
|
|
403
405
|
else {
|
|
404
|
-
|
|
405
|
-
|
|
406
|
+
const failure = responseFailure(r, stage.call?.error);
|
|
407
|
+
put(out, h('span', { class: 'chip dim' }, `HTTP ${r.status ?? '–'} ${r.status_text ?? ''}`.trim()),
|
|
408
|
+
h('span', { class: `chip ${respClass(r, stage.call?.error)}`, title: `end: ${r.end}` }, failure ? '失败' : r.end === 'cancelled' && stage.target === 'client.response' ? '客户端断开' : END_LABEL[r.end] ?? r.end ?? '–'),
|
|
406
409
|
r.headers_ms != null ? h('span', { class: 'dim', title: '自请求开始到响应头的时间' }, `响应头 ${fmtDur(r.headers_ms)}`) : null,
|
|
407
410
|
r.ended_ms != null ? h('span', { class: 'dim', title: '自请求开始到结束的时间' }, `结束 ${fmtDur(r.ended_ms)}`) : null,
|
|
408
411
|
r.events ? h('span', { class: 'dim' }, `${fmtInt(r.events.length)} 事件`) : h('span', { class: 'dim' }, '非 SSE'),
|
|
409
|
-
|
|
412
|
+
failure ? h('span', { class: 'chip bad', title: failure.message ?? failure.kind }, oneLine(`错误:${failure.message ?? failure.kind}`, 80)) : null);
|
|
410
413
|
}
|
|
411
414
|
}
|
|
412
415
|
if (body) {
|
|
@@ -436,11 +439,11 @@ export class DetailView {
|
|
|
436
439
|
return headersTable(msg?.headers, [['请求', h('span', { class: 'mono' }, `${msg?.method ?? ''} ${msg?.url ?? msg?.path ?? ''}`)]]);
|
|
437
440
|
}
|
|
438
441
|
if (mode === 'raw') return body ? rawView(body.text, this.fileName(stage, 'body'), parseBody(body).ok, resp?.events ? 'sse.txt' : 'json') : h('div', { class: 'dim' }, '没有正文');
|
|
439
|
-
const ann = stage.target === 'client.request' ? annIndex(d
|
|
442
|
+
const ann = stage.target === 'client.request' ? annIndex(rowAnnotations(d), 'client.request').byPointer
|
|
440
443
|
: stage.target === 'client.response' ? responsePointers(d) : null;
|
|
441
444
|
const chip = (a, onClick) => annChip(a, onClick);
|
|
442
445
|
if (mode === 'events' && resp?.events) {
|
|
443
|
-
const { byEvent } = annIndex(d
|
|
446
|
+
const { byEvent } = annIndex(rowAnnotations(d), stage.target === 'client.response' ? 'client.response' : '-');
|
|
444
447
|
return eventsView(resp, {
|
|
445
448
|
state: this.viewState(stage.key, 'events', newEventsState), prefs: this.ctx.prefs,
|
|
446
449
|
onPrefs: () => { this.ctx.savePrefs(); for (const p of this.panes) { if (this.modeOf(this.stages.get(p.key) ?? {}) === 'events') this.renderPane(p, true); } },
|
|
@@ -494,13 +497,14 @@ export class DetailView {
|
|
|
494
497
|
h('td', { class: 'mono' }, r?.ended_ms != null ? fmtDur(r.ended_ms) : '–'),
|
|
495
498
|
h('td', { class: 'mono' }, fmtBytes(c.body?.bytes)),
|
|
496
499
|
h('td', { class: 'mono' }, fmtBytes(r?.body?.bytes)),
|
|
497
|
-
h('td', { class: 'err' }, c.error
|
|
500
|
+
h('td', { class: 'err' }, responseFailure(r, c.error)?.message ?? ''));
|
|
498
501
|
return tr;
|
|
499
502
|
}))));
|
|
500
503
|
}
|
|
501
504
|
if (d.annotations?.length) {
|
|
502
505
|
put(box, h('h4', null, '标注'), h('div', null, h('span', { class: 'chip info' }, annSummary(d.annotations)), ' ', btn('查看全部标注', () => this.open('ann'))));
|
|
503
506
|
}
|
|
507
|
+
if (d.tool_diagnostics?.length) put(box, this.toolDiagnostics());
|
|
504
508
|
for (const [i, call] of (d.upstream ?? []).entries()) {
|
|
505
509
|
const reports = serverTransformations(call.response);
|
|
506
510
|
if (reports) {
|
|
@@ -508,7 +512,7 @@ export class DetailView {
|
|
|
508
512
|
btn('查看上游响应', () => this.open(`upres:${keys[i]}`)), reports);
|
|
509
513
|
}
|
|
510
514
|
}
|
|
511
|
-
put(box, h('h4', null, '记录字段'), fieldsTable(d, SUMMARY_HINTS, ['route', 'client', 'upstream', 'annotations']));
|
|
515
|
+
put(box, h('h4', null, '记录字段'), fieldsTable(d, SUMMARY_HINTS, ['route', 'client', 'upstream', 'annotations', 'tool_diagnostics']));
|
|
512
516
|
return box;
|
|
513
517
|
}
|
|
514
518
|
|
|
@@ -555,10 +559,25 @@ export class DetailView {
|
|
|
555
559
|
|
|
556
560
|
// ---------- annotations ----------
|
|
557
561
|
|
|
562
|
+
toolDiagnostics() {
|
|
563
|
+
const list = this.detail.tool_diagnostics ?? [];
|
|
564
|
+
if (!list.length) return null;
|
|
565
|
+
return h('section', null,
|
|
566
|
+
h('h4', null, '工具诊断'),
|
|
567
|
+
h('div', { class: 'note' }, '本次输出的无效调用与响应是否完成分别显示。历史输入中的诊断仅用于回溯,不计入本次无效调用数。'),
|
|
568
|
+
list.map(item => {
|
|
569
|
+
const a = { ...item, kind: 'tool_error' };
|
|
570
|
+
return h('details', { class: 'transformation-entry' },
|
|
571
|
+
h('summary', null, annChip(a), ' ', h('span', { class: 'mono dim' }, `${a.pointer}${a.event != null ? ` · 事件 #${a.event}` : ''}`), ' ',
|
|
572
|
+
btn('定位', e => { e.preventDefault(); this.locate(a); })),
|
|
573
|
+
annDetail(a));
|
|
574
|
+
}));
|
|
575
|
+
}
|
|
576
|
+
|
|
558
577
|
annotations() {
|
|
559
578
|
const d = this.detail;
|
|
560
579
|
const list = d.annotations ?? [];
|
|
561
|
-
if (!list.length) return h('div', { class: 'empty small' }, '
|
|
580
|
+
if (!list.length) return this.toolDiagnostics() ?? h('div', { class: 'empty small' }, '这条记录没有回放标注或工具诊断');
|
|
562
581
|
const tbody = h('tbody');
|
|
563
582
|
list.forEach((a, i) => {
|
|
564
583
|
const where = `${a.target === 'client.request' ? '① 请求' : '④ 响应'}${a.event != null ? ` 事件 #${a.event}` : ''} ${a.pointer ?? ''}`;
|
|
@@ -580,6 +599,7 @@ export class DetailView {
|
|
|
580
599
|
put(tbody, tr);
|
|
581
600
|
});
|
|
582
601
|
return h('div', null,
|
|
602
|
+
this.toolDiagnostics(),
|
|
583
603
|
h('div', { class: 'note' }, `bridge 按真实回放规则计算:${annSummary(list)}。点击行查看解码后的载荷,“定位”跳到对应项。`),
|
|
584
604
|
h('table', { class: 'anns' }, h('thead', null, h('tr', null, ['#', '位置', '类型', '决定', '原因', '来源', '格式', ''].map((x) => h('th', null, x)))), tbody));
|
|
585
605
|
}
|
package/ui/events.js
CHANGED
|
@@ -308,7 +308,7 @@ function fromResponses(data) {
|
|
|
308
308
|
}
|
|
309
309
|
const created = data.find((e) => e.json.type === 'response.created')?.json.response ?? {};
|
|
310
310
|
const errors = data.filter((e) => e.json.type === 'error').map((e) => e.json);
|
|
311
|
-
return { value: { ...created, output, ...(errors.length ? { errors } : {}) }, note: '
|
|
311
|
+
return { value: { ...created, output, ...(errors.length ? { errors } : {}) }, note: '未完成响应快照:没有收到终止事件,由 response.created 与 output_item.done 合成;status 保留上游原值,不表示仍在生成。' };
|
|
312
312
|
}
|
|
313
313
|
|
|
314
314
|
function fromMessages(data) {
|
package/ui/labels.js
CHANGED
|
@@ -11,8 +11,8 @@ export const INPUT_TRANSFORMATION_LABEL = {
|
|
|
11
11
|
};
|
|
12
12
|
|
|
13
13
|
export const KIND_LABEL = { turn: '轮次', compaction: '压缩', search: '独立搜索', image_generation: '图片生成', invalid: '无效' };
|
|
14
|
-
export const OUTCOME_LABEL = { active: '进行中', completed: '
|
|
15
|
-
export const END_LABEL = { active: '传输中', complete: '完整', cancelled: '
|
|
14
|
+
export const OUTCOME_LABEL = { active: '进行中', completed: '响应完成', incomplete: '未完成', failed: '失败', error: '错误', aborted: '客户端断开' };
|
|
15
|
+
export const END_LABEL = { active: '传输中', complete: '完整', cancelled: '连接提前结束', error: '出错', unread: '终止事件后停止读取' };
|
|
16
16
|
|
|
17
17
|
const DECISION = { replay: '回放', passthrough: '原样透传', drop: '丢弃', native: '恢复原生', summary: '文字摘要', handoff: '按需文字交接', reject: '拒绝', output: '输出' };
|
|
18
18
|
const DECISION_CLASS = { replay: 'ok', passthrough: 'info', native: 'ok', drop: 'warn', summary: 'warn', handoff: 'warn', reject: 'bad', output: 'info' };
|
|
@@ -57,6 +57,11 @@ export function sourceText(src) {
|
|
|
57
57
|
}
|
|
58
58
|
|
|
59
59
|
export function annChip(a, onClick) {
|
|
60
|
+
if (a.kind === 'tool_error') return h('span', {
|
|
61
|
+
class: `chip ann ${a.target === 'client.request' ? 'warn' : 'bad'}${onClick ? ' click' : ''}`,
|
|
62
|
+
title: a.message,
|
|
63
|
+
onclick: onClick ? (e) => { e.stopPropagation(); onClick(a, e); } : null,
|
|
64
|
+
}, `${a.target === 'client.request' ? '历史工具诊断' : '无效工具调用'} · ${a.name}`);
|
|
60
65
|
const source = a.source ? sourceText(a.source)
|
|
61
66
|
: (a.decision === 'output' || (a.kind === 'compaction' && a.reason === 'no_native') ? null : '来源未知');
|
|
62
67
|
const parts = [KIND_TEXT[a.kind] ?? a.kind, source, reasonText(a)].filter(Boolean);
|
|
@@ -69,6 +74,12 @@ export function annChip(a, onClick) {
|
|
|
69
74
|
|
|
70
75
|
/** Full annotation card: fields, compaction summary text and decoded carrier tree. */
|
|
71
76
|
export function annDetail(a) {
|
|
77
|
+
if (a.kind === 'tool_error') return h('div', { class: 'ann-detail' },
|
|
78
|
+
kvTable([
|
|
79
|
+
['范围', a.target === 'client.request' ? '历史输入,不计入本次输出的无效工具调用' : '本次输出;响应完成不代表工具调用有效'],
|
|
80
|
+
['位置', `${a.target}${a.event != null ? ` · 事件 #${a.event}` : ''} · ${a.pointer}`],
|
|
81
|
+
['原始工具名', a.name], ['调用 ID', a.call_id],
|
|
82
|
+
]), strBlock(a.message, { name: 'tool diagnostic' }));
|
|
72
83
|
const src = a.source;
|
|
73
84
|
const rows = [
|
|
74
85
|
['位置', `${a.target}${a.event != null ? ` · 事件 #${a.event}` : ''} · ${a.pointer ?? '–'}`],
|