ework-web 0.10.90 → 0.10.92
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/package.json +1 -1
- package/src/pi-sessions.ts +22 -10
package/package.json
CHANGED
package/src/pi-sessions.ts
CHANGED
|
@@ -10,7 +10,10 @@ interface PiEvent {
|
|
|
10
10
|
timestamp?: string;
|
|
11
11
|
message?: {
|
|
12
12
|
role?: string;
|
|
13
|
-
|
|
13
|
+
toolCallId?: string;
|
|
14
|
+
toolName?: string;
|
|
15
|
+
isError?: boolean;
|
|
16
|
+
content?: Array<{ type?: string; text?: string; thinking?: string; name?: string; arguments?: unknown; id?: string; output?: unknown }>;
|
|
14
17
|
usage?: { input?: number; output?: number; cacheRead?: number; totalTokens?: number };
|
|
15
18
|
model?: string;
|
|
16
19
|
};
|
|
@@ -79,7 +82,11 @@ function resultText(output: unknown): string {
|
|
|
79
82
|
|
|
80
83
|
function toolCard(t: PiToolCall): string {
|
|
81
84
|
const argStr = t.args.length > 600 ? t.args.slice(0, 600) + "…" : t.args;
|
|
82
|
-
|
|
85
|
+
const argsBlock = t.args && t.args !== "{}"
|
|
86
|
+
? `<div class="pi-io-label">完整参数</div><pre>${escapeHtml(t.args.length > 20000 ? t.args.slice(0, 20000) + "\n…(截断)" : t.args)}</pre>`
|
|
87
|
+
: "";
|
|
88
|
+
const resultBlock = `<div class="pi-io-label">返回</div><pre>${escapeHtml(t.result ?? "(无返回)")}</pre>`;
|
|
89
|
+
return `<details class="pi-tool"><summary>🔧 ${escapeHtml(t.name)}<span class="pi-tool-args">${escapeHtml(argStr)}</span></summary><div class="tool-io">${argsBlock}${resultBlock}</div></details>`;
|
|
83
90
|
}
|
|
84
91
|
|
|
85
92
|
function renderCard(c: PiCard): string {
|
|
@@ -154,7 +161,7 @@ export function buildPiSessionPage(sessionId: string, limit: number, asc = false
|
|
|
154
161
|
else if (p.type === "text" && p.text) card.textParts.push(p.text);
|
|
155
162
|
else if (p.type === "toolCall") {
|
|
156
163
|
const tc: PiToolCall = {
|
|
157
|
-
id: p.
|
|
164
|
+
id: p.id ?? `t${openTools.size}`,
|
|
158
165
|
name: p.name ?? "?",
|
|
159
166
|
args: (() => { try { return typeof p.arguments === "string" ? p.arguments : JSON.stringify(p.arguments ?? {}); } catch { return "{}"; } })(),
|
|
160
167
|
};
|
|
@@ -163,13 +170,17 @@ export function buildPiSessionPage(sessionId: string, limit: number, asc = false
|
|
|
163
170
|
}
|
|
164
171
|
}
|
|
165
172
|
cards.push(card);
|
|
166
|
-
} else {
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
+
} else if (m.role === "toolResult") {
|
|
174
|
+
const payload = (m.content ?? []).filter(p => p.type === "text").map(p => p.text ?? "").join("\n");
|
|
175
|
+
const key = m.toolCallId ?? [...openTools.keys()].pop();
|
|
176
|
+
const tc = key ? openTools.get(key) : undefined;
|
|
177
|
+
const text = (payload || resultText(m.content)).slice(0, 4000);
|
|
178
|
+
const stamped = m.isError ? `⚠️ ${text}` : text;
|
|
179
|
+
if (tc) tc.result = stamped;
|
|
180
|
+
else {
|
|
181
|
+
const orphan: PiToolCall = { id: m.toolCallId ?? `t${openTools.size}`, name: m.toolName ?? "tool", args: "", result: stamped };
|
|
182
|
+
openTools.set(orphan.id, orphan);
|
|
183
|
+
cards.push({ ts: e.timestamp ?? "", role: "assistant", textParts: [], reasoning: [], tools: [orphan] });
|
|
173
184
|
}
|
|
174
185
|
}
|
|
175
186
|
}
|
|
@@ -227,6 +238,7 @@ export function buildPiSessionPage(sessionId: string, limit: number, asc = false
|
|
|
227
238
|
.mb .tool-io{position:relative;padding:.5rem .6rem}
|
|
228
239
|
.mb .tool-io pre{margin:.2rem 0}
|
|
229
240
|
.pi-tool summary .pi-tool-args{font-family:ui-monospace,monospace;font-size:11px;color:var(--text-muted);overflow:hidden;text-overflow:ellipsis;white-space:nowrap;max-width:60%}
|
|
241
|
+
.pi-io-label{font-size:11px;color:var(--text-muted);margin:6px 0 2px;font-weight:600}
|
|
230
242
|
.more-bar{max-width:900px;margin:1rem auto 0;padding:.8rem 1rem;text-align:center;border:1px dashed var(--border);border-radius:8px;color:var(--text-muted);font-size:13px}
|
|
231
243
|
.more-bar a{font-weight:600}
|
|
232
244
|
</style></head><body>
|