@principal-ai/principal-view-core 0.28.11 → 0.28.12
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.
|
@@ -3,14 +3,14 @@ import { NodePathNormalizationAdapter, accumulateEvents, collectRepositories, no
|
|
|
3
3
|
export { NodePathNormalizationAdapter, normalizeEvents, normalizeEventsWithAdapter, accumulateEvents, collectRepositories, };
|
|
4
4
|
/**
|
|
5
5
|
* Shared, agent-agnostic session access: list + fetch across Cline, opencode,
|
|
6
|
-
* pi, and
|
|
6
|
+
* pi, Grok, and Codex, normalizing raw events into repo-aware universal events.
|
|
7
7
|
*
|
|
8
8
|
* This is the single source of truth for CLI and trail-viewer session pulling.
|
|
9
9
|
* opencode listing delegates to `OpenCodeEventStore.listSessionsWithSummaries()`,
|
|
10
10
|
* which already builds parent/child groups and excludes subagent (child) sessions
|
|
11
11
|
* from the standalone list.
|
|
12
12
|
*/
|
|
13
|
-
export type SupportedSessionAgent = "cline" | "opencode" | "pi" | "grok" | "unknown";
|
|
13
|
+
export type SupportedSessionAgent = "cline" | "codex" | "opencode" | "pi" | "grok" | "unknown";
|
|
14
14
|
export interface AgentSessionSummary {
|
|
15
15
|
agent: SupportedSessionAgent;
|
|
16
16
|
sessionId: string;
|
|
@@ -31,15 +31,15 @@ export declare function listAgentSessions(options?: {
|
|
|
31
31
|
dbPath?: string;
|
|
32
32
|
}): AgentSessionSummary[];
|
|
33
33
|
/** Detect which agent a session id belongs to. */
|
|
34
|
-
export declare function detectAgent(sessionId: string): "cline" | "opencode" | "pi" | "grok";
|
|
34
|
+
export declare function detectAgent(sessionId: string): "cline" | "opencode" | "pi" | "grok" | "codex";
|
|
35
35
|
/**
|
|
36
36
|
* Fetch a session's raw universal events from the appropriate source.
|
|
37
37
|
*/
|
|
38
38
|
export declare function fetchRawEvents(sessionId: string, options?: {
|
|
39
|
-
agent?: "cline" | "opencode" | "pi" | "grok";
|
|
39
|
+
agent?: "cline" | "codex" | "opencode" | "pi" | "grok";
|
|
40
40
|
dbPath?: string;
|
|
41
41
|
}): {
|
|
42
|
-
agent: "cline" | "opencode" | "pi" | "grok";
|
|
42
|
+
agent: "cline" | "codex" | "opencode" | "pi" | "grok";
|
|
43
43
|
events: UniversalAgentSessionEvent[];
|
|
44
44
|
sessionMeta: AgentSessionMeta;
|
|
45
45
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agent-sessions.d.ts","sourceRoot":"","sources":["../../src/opencode/agent-sessions.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"agent-sessions.d.ts","sourceRoot":"","sources":["../../src/opencode/agent-sessions.ts"],"names":[],"mappings":"AAAA,OAAO,EAKL,KAAK,0BAA0B,EAChC,MAAM,gCAAgC,CAAC;AAExC,OAAO,EACL,4BAA4B,EAC5B,gBAAgB,EAChB,mBAAmB,EACnB,eAAe,EACf,0BAA0B,EAE3B,MAAM,YAAY,CAAC;AAEpB,OAAO,EACL,4BAA4B,EAC5B,eAAe,EACf,0BAA0B,EAC1B,gBAAgB,EAChB,mBAAmB,GACpB,CAAC;AAEF;;;;;;;;GAQG;AAEH,MAAM,MAAM,qBAAqB,GAC7B,OAAO,GACP,OAAO,GACP,UAAU,GACV,IAAI,GACJ,MAAM,GACN,SAAS,CAAC;AAEd,MAAM,WAAW,mBAAmB;IAClC,KAAK,EAAE,qBAAqB,CAAC;IAC7B,SAAS,EAAE,MAAM,CAAC;IAClB,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,OAAO,CAAC;IACpB,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,WAAW,gBAAgB;IAC/B,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,EAAE,MAAM,CAAC;IACpB,gBAAgB,EAAE,MAAM,CAAC;IACzB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAqID,0EAA0E;AAC1E,wBAAgB,iBAAiB,CAC/B,OAAO,GAAE;IAAE,MAAM,CAAC,EAAE,MAAM,CAAA;CAAO,GAChC,mBAAmB,EAAE,CAgCvB;AAED,kDAAkD;AAClD,wBAAgB,WAAW,CACzB,SAAS,EAAE,MAAM,GAChB,OAAO,GAAG,UAAU,GAAG,IAAI,GAAG,MAAM,GAAG,OAAO,CAMhD;AAED;;GAEG;AACH,wBAAgB,cAAc,CAC5B,SAAS,EAAE,MAAM,EACjB,OAAO,GAAE;IACP,KAAK,CAAC,EAAE,OAAO,GAAG,OAAO,GAAG,UAAU,GAAG,IAAI,GAAG,MAAM,CAAC;IACvD,MAAM,CAAC,EAAE,MAAM,CAAC;CACZ,GACL;IACD,KAAK,EAAE,OAAO,GAAG,OAAO,GAAG,UAAU,GAAG,IAAI,GAAG,MAAM,CAAC;IACtD,MAAM,EAAE,0BAA0B,EAAE,CAAC;IACrC,WAAW,EAAE,gBAAgB,CAAC;CAC/B,CAiFA"}
|
|
@@ -12,6 +12,7 @@ Object.defineProperty(exports, "normalizeEventsWithAdapter", { enumerable: true,
|
|
|
12
12
|
const clineReader = new agent_monitoring_1.ClineSessionReader();
|
|
13
13
|
const piReader = new agent_monitoring_1.PiSessionReader();
|
|
14
14
|
const grokReader = new agent_monitoring_1.GrokSessionReader();
|
|
15
|
+
const codexReader = new agent_monitoring_1.CodexSessionReader();
|
|
15
16
|
function isClineSession(sessionId) {
|
|
16
17
|
return clineReader.readSession(sessionId) !== null;
|
|
17
18
|
}
|
|
@@ -21,6 +22,9 @@ function isPiSession(sessionId) {
|
|
|
21
22
|
function isGrokSession(sessionId) {
|
|
22
23
|
return grokReader.readSession(sessionId) !== null;
|
|
23
24
|
}
|
|
25
|
+
function isCodexSession(sessionId) {
|
|
26
|
+
return codexReader.readSession(sessionId) !== null;
|
|
27
|
+
}
|
|
24
28
|
/** List Cline CLI sessions from the durable on-disk transcript. */
|
|
25
29
|
function listClineSessions() {
|
|
26
30
|
return clineReader.listSessions().map((record) => {
|
|
@@ -76,6 +80,19 @@ function listGrokSessions() {
|
|
|
76
80
|
};
|
|
77
81
|
});
|
|
78
82
|
}
|
|
83
|
+
/** List Codex sessions from durable rollout JSONL. */
|
|
84
|
+
function listCodexSessions() {
|
|
85
|
+
return codexReader.listSessions().map((record) => ({
|
|
86
|
+
agent: "codex",
|
|
87
|
+
sessionId: record.sessionId,
|
|
88
|
+
title: record.firstPrompt || "Codex session",
|
|
89
|
+
createdAt: typeof record.meta.timestamp === "string"
|
|
90
|
+
? record.meta.timestamp
|
|
91
|
+
: new Date(record.lastActivity).toISOString(),
|
|
92
|
+
eventCount: record.messageCount,
|
|
93
|
+
isFinished: false,
|
|
94
|
+
}));
|
|
95
|
+
}
|
|
79
96
|
/**
|
|
80
97
|
* List opencode sessions, top-level only by default. Delegates to the store's
|
|
81
98
|
* grouped `listSessionsWithSummaries()` which excludes subagent (child) sessions.
|
|
@@ -134,6 +151,13 @@ function listAgentSessions(options = {}) {
|
|
|
134
151
|
if (!firstError)
|
|
135
152
|
firstError = err;
|
|
136
153
|
}
|
|
154
|
+
try {
|
|
155
|
+
all.push(...listCodexSessions());
|
|
156
|
+
}
|
|
157
|
+
catch (err) {
|
|
158
|
+
if (!firstError)
|
|
159
|
+
firstError = err;
|
|
160
|
+
}
|
|
137
161
|
if (all.length === 0 && firstError) {
|
|
138
162
|
throw firstError;
|
|
139
163
|
}
|
|
@@ -148,6 +172,8 @@ function detectAgent(sessionId) {
|
|
|
148
172
|
return "pi";
|
|
149
173
|
if (isGrokSession(sessionId))
|
|
150
174
|
return "grok";
|
|
175
|
+
if (isCodexSession(sessionId))
|
|
176
|
+
return "codex";
|
|
151
177
|
return "opencode";
|
|
152
178
|
}
|
|
153
179
|
exports.detectAgent = detectAgent;
|
|
@@ -196,6 +222,23 @@ function fetchRawEvents(sessionId, options = {}) {
|
|
|
196
222
|
},
|
|
197
223
|
};
|
|
198
224
|
}
|
|
225
|
+
if (agent === "codex") {
|
|
226
|
+
const record = codexReader.readSession(sessionId);
|
|
227
|
+
const promptText = (record?.firstPrompt ?? "").trim();
|
|
228
|
+
return {
|
|
229
|
+
agent,
|
|
230
|
+
events: codexReader.toUniversalEvents(sessionId),
|
|
231
|
+
sessionMeta: {
|
|
232
|
+
sessionName: "codex",
|
|
233
|
+
sessionTask: (promptText.length > 80 ? `${promptText.slice(0, 80)}…` : promptText) ||
|
|
234
|
+
"Codex session",
|
|
235
|
+
workingDirectory: record?.cwd ?? "",
|
|
236
|
+
createdAt: typeof record?.meta.timestamp === "string"
|
|
237
|
+
? record.meta.timestamp
|
|
238
|
+
: undefined,
|
|
239
|
+
},
|
|
240
|
+
};
|
|
241
|
+
}
|
|
199
242
|
const store = new OpenCodeEventStore_1.OpenCodeEventStore({ dbPath: options.dbPath });
|
|
200
243
|
try {
|
|
201
244
|
const { events } = store.readAggregate(sessionId, { limit: 10000 });
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agent-sessions.js","sourceRoot":"","sources":["../../src/opencode/agent-sessions.ts"],"names":[],"mappings":";;;AAAA,
|
|
1
|
+
{"version":3,"file":"agent-sessions.js","sourceRoot":"","sources":["../../src/opencode/agent-sessions.ts"],"names":[],"mappings":";;;AAAA,qEAMwC;AACxC,6DAA0D;AAC1D,yCAOoB;AAGlB,6GATA,uCAA4B,OASA;AAG5B,iGAXA,2BAAgB,OAWA;AAChB,oGAXA,8BAAmB,OAWA;AAHnB,gGAPA,0BAAe,OAOA;AACf,2GAPA,qCAA0B,OAOA;AAwC5B,MAAM,WAAW,GAAG,IAAI,qCAAkB,EAAE,CAAC;AAC7C,MAAM,QAAQ,GAAG,IAAI,kCAAe,EAAE,CAAC;AACvC,MAAM,UAAU,GAAG,IAAI,oCAAiB,EAAE,CAAC;AAC3C,MAAM,WAAW,GAAG,IAAI,qCAAkB,EAAE,CAAC;AAE7C,SAAS,cAAc,CAAC,SAAiB;IACvC,OAAO,WAAW,CAAC,WAAW,CAAC,SAA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2
2
|
"name": "@principal-ai/principal-view-core",
|
|
3
|
-
"version": "0.28.
|
|
3
|
+
"version": "0.28.12",
|
|
4
4
|
"description": "Core logic and types for graph-based principal view framework",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
@@ -48,7 +48,6 @@
|
|
|
48
48
|
"@opentelemetry/resources": "2.2.0",
|
|
49
49
|
"@opentelemetry/sdk-trace-base": "2.2.0",
|
|
50
50
|
"@opentelemetry/semantic-conventions": "1.38.0",
|
|
51
|
-
"@principal-ai/agent-monitoring": "^0.3.31",
|
|
52
51
|
"@principal-ai/repository-abstraction": "^0.5.7",
|
|
53
52
|
"better-sqlite3": "^13.0.0",
|
|
54
53
|
"date-fns": "3.0.0",
|
|
@@ -57,9 +56,11 @@
|
|
|
57
56
|
"zod": "3.22.0"
|
|
58
57
|
},
|
|
59
58
|
"peerDependencies": {
|
|
59
|
+
"@principal-ai/agent-monitoring": "^0.3.31",
|
|
60
60
|
"@principal-ai/codebase-composition": "^0.2.43"
|
|
61
61
|
},
|
|
62
62
|
"devDependencies": {
|
|
63
|
+
"@principal-ai/agent-monitoring": "^0.3.35",
|
|
63
64
|
"@principal-ai/codebase-composition": "^0.2.43",
|
|
64
65
|
"@principal-ai/principal-view-core": "0.24.10",
|
|
65
66
|
"@types/better-sqlite3": "^7.6.13",
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
ClineSessionReader,
|
|
3
|
+
CodexSessionReader,
|
|
3
4
|
GrokSessionReader,
|
|
4
5
|
PiSessionReader,
|
|
5
6
|
type UniversalAgentSessionEvent,
|
|
@@ -24,7 +25,7 @@ export {
|
|
|
24
25
|
|
|
25
26
|
/**
|
|
26
27
|
* Shared, agent-agnostic session access: list + fetch across Cline, opencode,
|
|
27
|
-
* pi, and
|
|
28
|
+
* pi, Grok, and Codex, normalizing raw events into repo-aware universal events.
|
|
28
29
|
*
|
|
29
30
|
* This is the single source of truth for CLI and trail-viewer session pulling.
|
|
30
31
|
* opencode listing delegates to `OpenCodeEventStore.listSessionsWithSummaries()`,
|
|
@@ -32,7 +33,13 @@ export {
|
|
|
32
33
|
* from the standalone list.
|
|
33
34
|
*/
|
|
34
35
|
|
|
35
|
-
export type SupportedSessionAgent =
|
|
36
|
+
export type SupportedSessionAgent =
|
|
37
|
+
| "cline"
|
|
38
|
+
| "codex"
|
|
39
|
+
| "opencode"
|
|
40
|
+
| "pi"
|
|
41
|
+
| "grok"
|
|
42
|
+
| "unknown";
|
|
36
43
|
|
|
37
44
|
export interface AgentSessionSummary {
|
|
38
45
|
agent: SupportedSessionAgent;
|
|
@@ -54,6 +61,7 @@ export interface AgentSessionMeta {
|
|
|
54
61
|
const clineReader = new ClineSessionReader();
|
|
55
62
|
const piReader = new PiSessionReader();
|
|
56
63
|
const grokReader = new GrokSessionReader();
|
|
64
|
+
const codexReader = new CodexSessionReader();
|
|
57
65
|
|
|
58
66
|
function isClineSession(sessionId: string): boolean {
|
|
59
67
|
return clineReader.readSession(sessionId) !== null;
|
|
@@ -67,6 +75,10 @@ function isGrokSession(sessionId: string): boolean {
|
|
|
67
75
|
return grokReader.readSession(sessionId) !== null;
|
|
68
76
|
}
|
|
69
77
|
|
|
78
|
+
function isCodexSession(sessionId: string): boolean {
|
|
79
|
+
return codexReader.readSession(sessionId) !== null;
|
|
80
|
+
}
|
|
81
|
+
|
|
70
82
|
/** List Cline CLI sessions from the durable on-disk transcript. */
|
|
71
83
|
function listClineSessions(): AgentSessionSummary[] {
|
|
72
84
|
return clineReader.listSessions().map((record) => {
|
|
@@ -127,6 +139,21 @@ function listGrokSessions(): AgentSessionSummary[] {
|
|
|
127
139
|
});
|
|
128
140
|
}
|
|
129
141
|
|
|
142
|
+
/** List Codex sessions from durable rollout JSONL. */
|
|
143
|
+
function listCodexSessions(): AgentSessionSummary[] {
|
|
144
|
+
return codexReader.listSessions().map((record) => ({
|
|
145
|
+
agent: "codex" as const,
|
|
146
|
+
sessionId: record.sessionId,
|
|
147
|
+
title: record.firstPrompt || "Codex session",
|
|
148
|
+
createdAt:
|
|
149
|
+
typeof record.meta.timestamp === "string"
|
|
150
|
+
? record.meta.timestamp
|
|
151
|
+
: new Date(record.lastActivity).toISOString(),
|
|
152
|
+
eventCount: record.messageCount,
|
|
153
|
+
isFinished: false,
|
|
154
|
+
}));
|
|
155
|
+
}
|
|
156
|
+
|
|
130
157
|
/**
|
|
131
158
|
* List opencode sessions, top-level only by default. Delegates to the store's
|
|
132
159
|
* grouped `listSessionsWithSummaries()` which excludes subagent (child) sessions.
|
|
@@ -188,6 +215,11 @@ export function listAgentSessions(
|
|
|
188
215
|
} catch (err) {
|
|
189
216
|
if (!firstError) firstError = err as Error;
|
|
190
217
|
}
|
|
218
|
+
try {
|
|
219
|
+
all.push(...listCodexSessions());
|
|
220
|
+
} catch (err) {
|
|
221
|
+
if (!firstError) firstError = err as Error;
|
|
222
|
+
}
|
|
191
223
|
if (all.length === 0 && firstError) {
|
|
192
224
|
throw firstError;
|
|
193
225
|
}
|
|
@@ -197,10 +229,11 @@ export function listAgentSessions(
|
|
|
197
229
|
/** Detect which agent a session id belongs to. */
|
|
198
230
|
export function detectAgent(
|
|
199
231
|
sessionId: string,
|
|
200
|
-
): "cline" | "opencode" | "pi" | "grok" {
|
|
232
|
+
): "cline" | "opencode" | "pi" | "grok" | "codex" {
|
|
201
233
|
if (isClineSession(sessionId)) return "cline";
|
|
202
234
|
if (isPiSession(sessionId)) return "pi";
|
|
203
235
|
if (isGrokSession(sessionId)) return "grok";
|
|
236
|
+
if (isCodexSession(sessionId)) return "codex";
|
|
204
237
|
return "opencode";
|
|
205
238
|
}
|
|
206
239
|
|
|
@@ -210,11 +243,11 @@ export function detectAgent(
|
|
|
210
243
|
export function fetchRawEvents(
|
|
211
244
|
sessionId: string,
|
|
212
245
|
options: {
|
|
213
|
-
agent?: "cline" | "opencode" | "pi" | "grok";
|
|
246
|
+
agent?: "cline" | "codex" | "opencode" | "pi" | "grok";
|
|
214
247
|
dbPath?: string;
|
|
215
248
|
} = {},
|
|
216
249
|
): {
|
|
217
|
-
agent: "cline" | "opencode" | "pi" | "grok";
|
|
250
|
+
agent: "cline" | "codex" | "opencode" | "pi" | "grok";
|
|
218
251
|
events: UniversalAgentSessionEvent[];
|
|
219
252
|
sessionMeta: AgentSessionMeta;
|
|
220
253
|
} {
|
|
@@ -261,6 +294,25 @@ export function fetchRawEvents(
|
|
|
261
294
|
},
|
|
262
295
|
};
|
|
263
296
|
}
|
|
297
|
+
if (agent === "codex") {
|
|
298
|
+
const record = codexReader.readSession(sessionId);
|
|
299
|
+
const promptText = (record?.firstPrompt ?? "").trim();
|
|
300
|
+
return {
|
|
301
|
+
agent,
|
|
302
|
+
events: codexReader.toUniversalEvents(sessionId),
|
|
303
|
+
sessionMeta: {
|
|
304
|
+
sessionName: "codex",
|
|
305
|
+
sessionTask:
|
|
306
|
+
(promptText.length > 80 ? `${promptText.slice(0, 80)}…` : promptText) ||
|
|
307
|
+
"Codex session",
|
|
308
|
+
workingDirectory: record?.cwd ?? "",
|
|
309
|
+
createdAt:
|
|
310
|
+
typeof record?.meta.timestamp === "string"
|
|
311
|
+
? record.meta.timestamp
|
|
312
|
+
: undefined,
|
|
313
|
+
},
|
|
314
|
+
};
|
|
315
|
+
}
|
|
264
316
|
const store = new OpenCodeEventStore({ dbPath: options.dbPath });
|
|
265
317
|
try {
|
|
266
318
|
const { events } = store.readAggregate(sessionId, { limit: 10000 });
|