Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion apps/vis/server/src/lib/agent-record-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ export interface WireResponse {
sessionId: string;
agentId: string;
protocolVersion: string;
metadata: { protocolVersion: string; createdAt: number };
metadata: { protocolVersion: string; createdAt: number; appVersion?: string };
records: readonly WireEntry[];
warnings: string[];
}
Expand Down
5 changes: 3 additions & 2 deletions apps/vis/server/src/lib/wire-reader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import {
import type { AgentRecord, WireEntry } from './agent-record-types';

export interface WireReadResult {
metadata: { protocolVersion: string; createdAt: number };
metadata: { protocolVersion: string; createdAt: number; appVersion?: string };
records: ReadonlyArray<WireEntry>;
warnings: string[];
}
Expand Down Expand Up @@ -66,6 +66,7 @@ export async function readAgentWire(path: string): Promise<WireReadResult> {
}
const pv = parsed['protocol_version'];
const ca = parsed['created_at'];
const av = parsed['app_version'];
if (typeof pv !== 'string' || typeof ca !== 'number') {
throw new TypeError(`Wire metadata malformed at line ${lineNo}`);
}
Expand All @@ -77,7 +78,7 @@ export async function readAgentWire(path: string): Promise<WireReadResult> {
);
migrations = bestEffortMigrations();
}
metadata = { protocolVersion: pv, createdAt: ca };
metadata = { protocolVersion: pv, createdAt: ca, appVersion: typeof av === 'string' ? av : undefined };

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Use the latest metadata appVersion

For sessions created before app_version existed, AgentRecords.replay() can append a later metadata record with resumed: true and the current app_version when the app version changes, but this endpoint-level metadata is frozen from only the first header line. In that common resumed-session case the wire contains an app_version, yet /wire still returns metadata.appVersion as undefined or stale, defeating the new debug field; update the reader when subsequent metadata records are encountered or otherwise choose the newest metadata value.

Useful? React with 👍 / 👎.

continue;
}
const raw = parsed as Record<string, unknown>;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
{"type":"metadata","protocol_version":"1.1","created_at":1779256900000}
{"type":"metadata","protocol_version":"1.1","created_at":1779256900000,"app_version":"1.2.3"}
{"type":"config.update","cwd":"/tmp/work","profileName":"sub","systemPrompt":"You are a sub-agent.","time":1779256900001}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{"type":"metadata","protocol_version":"1.1","created_at":1779256791085}
{"type":"metadata","protocol_version":"1.1","created_at":1779256791085,"app_version":"1.2.3"}
{"type":"config.update","cwd":"/tmp/work","profileName":"agent","systemPrompt":"You are Kimi.","time":1779256791100}
{"type":"tools.set_active_tools","names":["Read","Write"],"time":1779256791101}
{"type":"permission.set_mode","mode":"manual","time":1779256791102}
Expand Down
1 change: 1 addition & 0 deletions apps/vis/server/test/lib/wire-reader.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ describe('wire-reader', () => {
cleanup = c;
const result = await readAgentWire(join(sessionDir, 'agents', 'main', 'wire.jsonl'));
expect(result.metadata.protocolVersion).toBe('1.1');
expect(result.metadata.appVersion).toBe('1.2.3');
expect(result.records[0]!.lineNo).toBe(2); // metadata is line 1, first record is line 2
expect(result.records.at(-1)!.lineNo).toBe(10);
expect(result.records.map((r) => r.data.type)).toEqual([
Expand Down
Loading