ework-web 0.10.90 → 0.10.91
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 +16 -9
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
|
};
|
|
@@ -154,7 +157,7 @@ export function buildPiSessionPage(sessionId: string, limit: number, asc = false
|
|
|
154
157
|
else if (p.type === "text" && p.text) card.textParts.push(p.text);
|
|
155
158
|
else if (p.type === "toolCall") {
|
|
156
159
|
const tc: PiToolCall = {
|
|
157
|
-
id: p.
|
|
160
|
+
id: p.id ?? `t${openTools.size}`,
|
|
158
161
|
name: p.name ?? "?",
|
|
159
162
|
args: (() => { try { return typeof p.arguments === "string" ? p.arguments : JSON.stringify(p.arguments ?? {}); } catch { return "{}"; } })(),
|
|
160
163
|
};
|
|
@@ -163,13 +166,17 @@ export function buildPiSessionPage(sessionId: string, limit: number, asc = false
|
|
|
163
166
|
}
|
|
164
167
|
}
|
|
165
168
|
cards.push(card);
|
|
166
|
-
} else {
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
169
|
+
} else if (m.role === "toolResult") {
|
|
170
|
+
const payload = (m.content ?? []).filter(p => p.type === "text").map(p => p.text ?? "").join("\n");
|
|
171
|
+
const key = m.toolCallId ?? [...openTools.keys()].pop();
|
|
172
|
+
const tc = key ? openTools.get(key) : undefined;
|
|
173
|
+
const text = (payload || resultText(m.content)).slice(0, 4000);
|
|
174
|
+
const stamped = m.isError ? `⚠️ ${text}` : text;
|
|
175
|
+
if (tc) tc.result = stamped;
|
|
176
|
+
else {
|
|
177
|
+
const orphan: PiToolCall = { id: m.toolCallId ?? `t${openTools.size}`, name: m.toolName ?? "tool", args: "", result: stamped };
|
|
178
|
+
openTools.set(orphan.id, orphan);
|
|
179
|
+
cards.push({ ts: e.timestamp ?? "", role: "assistant", textParts: [], reasoning: [], tools: [orphan] });
|
|
173
180
|
}
|
|
174
181
|
}
|
|
175
182
|
}
|