@each1024/pi-mini-mode 2.0.17 → 2.0.19

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.
@@ -139,12 +139,23 @@ export function piLoopSummary(question: string): string | undefined {
139
139
  return prompt ? `${title} · ${prompt}` : title;
140
140
  }
141
141
 
142
+ function entryTimestamp(entry: { timestamp?: unknown; message?: { timestamp?: unknown } } | null | undefined): number | undefined {
143
+ for (const cand of [entry?.message?.timestamp, entry?.timestamp]) {
144
+ if (typeof cand === "number" && Number.isFinite(cand)) return cand;
145
+ if (typeof cand === "string") {
146
+ const t = Date.parse(cand);
147
+ if (Number.isFinite(t)) return t;
148
+ }
149
+ }
150
+ return undefined;
151
+ }
152
+
142
153
  /** Rebuild turns on the selected session branch. */
143
154
  export function minimalTurnsFromBranch(branch: readonly unknown[]): MinimalTurn[] {
144
155
  const turns: MinimalTurn[] = [];
145
156
  let turn: MinimalTurn | undefined;
146
157
  for (const rawEntry of branch) {
147
- const entry = rawEntry as { type?: string; message?: { role?: string; content?: unknown; usage?: UsageLike; stopReason?: string; errorMessage?: string } } | null;
158
+ const entry = rawEntry as { timestamp?: unknown; type?: string; message?: { timestamp?: unknown; role?: string; content?: unknown; usage?: UsageLike; stopReason?: string; errorMessage?: string } } | null;
148
159
  if (entry?.type !== "message" || !entry.message) continue;
149
160
  const { role, content } = entry.message;
150
161
  if (role === "user") {
@@ -162,6 +173,8 @@ export function minimalTurnsFromBranch(branch: readonly unknown[]): MinimalTurn[
162
173
  if (call) {
163
174
  call.state = result.isError ? "error" : "done";
164
175
  call.output = contentText(content) || "Call returned (no text output)";
176
+ const endedAt = entryTimestamp(entry);
177
+ if (endedAt !== undefined) call.endedAt = endedAt;
165
178
  continue;
166
179
  }
167
180
  pushProcess(turn, "output", content);
@@ -178,7 +191,10 @@ export function minimalTurnsFromBranch(branch: readonly unknown[]): MinimalTurn[
178
191
  && (entry.message.stopReason === "error" || entry.message.stopReason === "aborted") ? entry.message.stopReason : "done";
179
192
  } else if (item.type === "toolCall") {
180
193
  if (item.name) {
181
- (turn.agentCalls ??= []).push(agentCall(String(item.id), String(item.name), item.arguments ?? item.input));
194
+ const created = agentCall(String(item.id), String(item.name), item.arguments ?? item.input);
195
+ const startedAt = entryTimestamp(entry);
196
+ if (startedAt !== undefined) created.startedAt = startedAt;
197
+ (turn.agentCalls ??= []).push(created);
182
198
  pushProcess(turn, "call", String(item.id));
183
199
  const path = (item.arguments as { path?: string })?.path;
184
200
  if (path && /(?:^|\/)SKILL\.md$/i.test(path)) pushProcess(turn, "skill", path.split("/").at(-2));