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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/pi-sessions.ts +16 -9
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ework-web",
3
- "version": "0.10.90",
3
+ "version": "0.10.91",
4
4
  "type": "module",
5
5
  "description": "ework-web — standalone multi-project issue tracker. Local SQLite-backed, no external API dependency. Bun + TypeScript + SSR HTML.",
6
6
  "license": "MIT",
@@ -10,7 +10,10 @@ interface PiEvent {
10
10
  timestamp?: string;
11
11
  message?: {
12
12
  role?: string;
13
- content?: Array<{ type?: string; text?: string; thinking?: string; name?: string; arguments?: unknown; toolCallId?: string; output?: unknown }>;
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.toolCallId ?? `t${openTools.size}`,
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
- for (const p of m.content ?? []) {
168
- if (p.type === "toolResult") {
169
- const key = p.toolCallId ?? [...openTools.keys()].pop();
170
- const tc = key ? openTools.get(key) : undefined;
171
- if (tc) tc.result = resultText(p.output);
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
  }