@principal-ai/principal-view-core 0.28.8 → 0.28.10

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 (61) hide show
  1. package/dist/agent-sessions/fixture.d.ts +80 -0
  2. package/dist/agent-sessions/fixture.d.ts.map +1 -0
  3. package/dist/agent-sessions/fixture.js +130 -0
  4. package/dist/agent-sessions/fixture.js.map +1 -0
  5. package/dist/agent-sessions/index.d.ts +3 -0
  6. package/dist/agent-sessions/index.d.ts.map +1 -0
  7. package/dist/agent-sessions/index.js +6 -0
  8. package/dist/agent-sessions/index.js.map +1 -0
  9. package/dist/index.js +1 -0
  10. package/dist/index.js.map +1 -1
  11. package/dist/node.d.ts +8 -0
  12. package/dist/node.d.ts.map +1 -1
  13. package/dist/node.js +22 -2
  14. package/dist/node.js.map +1 -1
  15. package/dist/opencode/OpenCodeEventStore.d.ts +25 -0
  16. package/dist/opencode/OpenCodeEventStore.d.ts.map +1 -0
  17. package/dist/opencode/OpenCodeEventStore.js +182 -0
  18. package/dist/opencode/OpenCodeEventStore.js.map +1 -0
  19. package/dist/opencode/agent-sessions.d.ts +46 -0
  20. package/dist/opencode/agent-sessions.d.ts.map +1 -0
  21. package/dist/opencode/agent-sessions.js +219 -0
  22. package/dist/opencode/agent-sessions.js.map +1 -0
  23. package/dist/opencode/index.d.ts +6 -0
  24. package/dist/opencode/index.d.ts.map +1 -0
  25. package/dist/opencode/index.js +15 -0
  26. package/dist/opencode/index.js.map +1 -0
  27. package/dist/opencode/node-path-adapter.d.ts +25 -0
  28. package/dist/opencode/node-path-adapter.d.ts.map +1 -0
  29. package/dist/opencode/node-path-adapter.js +183 -0
  30. package/dist/opencode/node-path-adapter.js.map +1 -0
  31. package/dist/opencode/pipeline.d.ts +42 -0
  32. package/dist/opencode/pipeline.d.ts.map +1 -0
  33. package/dist/opencode/pipeline.js +90 -0
  34. package/dist/opencode/pipeline.js.map +1 -0
  35. package/dist/opencode/types.d.ts +39 -0
  36. package/dist/opencode/types.d.ts.map +1 -0
  37. package/dist/opencode/types.js +3 -0
  38. package/dist/opencode/types.js.map +1 -0
  39. package/dist/storage/topic-types.d.ts +14 -0
  40. package/dist/storage/topic-types.d.ts.map +1 -1
  41. package/dist/storage/topic-types.js +1 -0
  42. package/dist/storage/topic-types.js.map +1 -1
  43. package/dist/storage/topicStore.d.ts +1 -1
  44. package/dist/storage/topicStore.d.ts.map +1 -1
  45. package/package.json +10 -1
  46. package/src/agent-sessions/fixture.ts +225 -0
  47. package/src/agent-sessions/index.ts +10 -0
  48. package/src/index.ts +1 -0
  49. package/src/node.ts +31 -0
  50. package/src/opencode/EVENT_MAPPING.md +82 -0
  51. package/src/opencode/OpenCodeEventStore.ts +214 -0
  52. package/src/opencode/__fixtures__/event-shapes.json +443 -0
  53. package/src/opencode/__fixtures__/session-events.json +13491 -0
  54. package/src/opencode/agent-sessions.ts +282 -0
  55. package/src/opencode/index.ts +23 -0
  56. package/src/opencode/node-path-adapter.ts +199 -0
  57. package/src/opencode/pipeline.ts +141 -0
  58. package/src/opencode/types.ts +43 -0
  59. package/src/storage/topic-types.ts +15 -0
  60. package/src/storage/topicStore.test.ts +38 -1
  61. package/src/storage/topicStore.ts +1 -1
@@ -0,0 +1,90 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.collectRepositories = exports.accumulateEvents = exports.normalizeEventsWithAdapter = exports.normalizeEvents = exports.opencodeRowsToUniversalEvents = exports.NodePathNormalizationAdapter = void 0;
4
+ const agent_monitoring_1 = require("@principal-ai/agent-monitoring");
5
+ const node_path_adapter_1 = require("./node-path-adapter");
6
+ Object.defineProperty(exports, "NodePathNormalizationAdapter", { enumerable: true, get: function () { return node_path_adapter_1.NodePathNormalizationAdapter; } });
7
+ /**
8
+ * Convert raw opencode event rows into universal events. Handles both string
9
+ * (SQLite TEXT, unparsed) and already-parsed object `data` payloads.
10
+ */
11
+ function opencodeRowsToUniversalEvents(rows) {
12
+ const processor = new agent_monitoring_1.V1EventBridgeProcessor();
13
+ return rows.map((row) => processor.normalize({
14
+ type: row.type,
15
+ data: typeof row.data === "string"
16
+ ? JSON.parse(row.data)
17
+ : row.data,
18
+ id: row.id,
19
+ aggregateId: row.aggregateId,
20
+ seq: row.seq,
21
+ }));
22
+ }
23
+ exports.opencodeRowsToUniversalEvents = opencodeRowsToUniversalEvents;
24
+ /** Normalize raw universal events into repo-normalized universal events. */
25
+ async function normalizeEvents(events, workingDirectory = "", knownRoots) {
26
+ const { normalized } = await normalizeEventsWithAdapter(events, workingDirectory, knownRoots);
27
+ return normalized;
28
+ }
29
+ exports.normalizeEvents = normalizeEvents;
30
+ /**
31
+ * Like `normalizeEvents`, but also returns the adapter so callers can inspect
32
+ * `adapter.newlyDiscovered` for auto-registration of newly found git roots.
33
+ */
34
+ async function normalizeEventsWithAdapter(events, workingDirectory = "", knownRoots) {
35
+ const adapter = new node_path_adapter_1.NodePathNormalizationAdapter(knownRoots);
36
+ const service = new agent_monitoring_1.PathNormalizationService(adapter);
37
+ const normalized = await service.normalizePathsBatch(events, workingDirectory);
38
+ return { normalized, adapter };
39
+ }
40
+ exports.normalizeEventsWithAdapter = normalizeEventsWithAdapter;
41
+ /** Compute the accumulated agent-session event rows for a normalized session. */
42
+ function accumulateEvents(normalizedEvents, sessionTitle = "") {
43
+ const accState = (0, agent_monitoring_1.createAccumulatedState)(sessionTitle);
44
+ return normalizedEvents.map((normalizedEvent) => ({
45
+ normalized: normalizedEvent,
46
+ accumulated: (0, agent_monitoring_1.eventOp)(accState, normalizedEvent),
47
+ }));
48
+ }
49
+ exports.accumulateEvents = accumulateEvents;
50
+ /** Collect the distinct repositories referenced across a normalized session. */
51
+ function collectRepositories(normalizedEvents) {
52
+ const byRoot = new Map();
53
+ // Event-level repository context uses the RepositoryInfo shape (key: `root`).
54
+ const putEventRepo = (root, repo) => {
55
+ byRoot.set(root, {
56
+ root,
57
+ remoteUrl: repo.remoteUrl,
58
+ owner: repo.owner,
59
+ repo: repo.repo,
60
+ branch: repo.branch,
61
+ headCommit: repo.headCommit,
62
+ });
63
+ };
64
+ // Per-file repository uses the NormalizedPathInfo shape (key: `gitRoot`, no
65
+ // branch/headCommit). Normalize into the RepositoryInfo shape.
66
+ const putFileRepo = (root, repo) => {
67
+ const existing = byRoot.get(root);
68
+ byRoot.set(root, {
69
+ root,
70
+ remoteUrl: repo.remoteUrl ?? existing?.remoteUrl,
71
+ owner: repo.owner ?? existing?.owner,
72
+ repo: repo.repo ?? existing?.repo,
73
+ branch: existing?.branch,
74
+ headCommit: existing?.headCommit,
75
+ });
76
+ };
77
+ for (const event of normalizedEvents) {
78
+ if (event.repository?.root)
79
+ putEventRepo(event.repository.root, event.repository);
80
+ for (const file of event.files ?? []) {
81
+ const fileRepo = file.repository;
82
+ if (fileRepo?.gitRoot) {
83
+ putFileRepo(fileRepo.gitRoot, fileRepo);
84
+ }
85
+ }
86
+ }
87
+ return Array.from(byRoot.values());
88
+ }
89
+ exports.collectRepositories = collectRepositories;
90
+ //# sourceMappingURL=pipeline.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pipeline.js","sourceRoot":"","sources":["../../src/opencode/pipeline.ts"],"names":[],"mappings":";;;AAAA,qEAQwC;AACxC,2DAAmE;AAE1D,6GAFA,gDAA4B,OAEA;AAoBrC;;;GAGG;AACH,SAAgB,6BAA6B,CAC3C,IAAwB;IAExB,MAAM,SAAS,GAAG,IAAI,yCAAsB,EAAE,CAAC;IAC/C,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CACtB,SAAS,CAAC,SAAS,CAAC;QAClB,IAAI,EAAE,GAAG,CAAC,IAKa;QACvB,IAAI,EACF,OAAO,GAAG,CAAC,IAAI,KAAK,QAAQ;YAC1B,CAAC,CAAE,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,CAA6B;YACnD,CAAC,CAAC,GAAG,CAAC,IAAI;QACd,EAAE,EAAE,GAAG,CAAC,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,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC;AACrC,CAAC;AA5CD,kDA4CC"}
@@ -0,0 +1,39 @@
1
+ export interface OpenCodeRawEvent {
2
+ id: string;
3
+ aggregateId: string;
4
+ seq: number;
5
+ type: string;
6
+ data: Record<string, unknown>;
7
+ }
8
+ export interface OpenCodeSessionEvents {
9
+ sessionId: string;
10
+ events: OpenCodeRawEvent[];
11
+ hasMore: boolean;
12
+ }
13
+ export interface OpenCodeEventRetriever {
14
+ readAggregate(sessionId: string, options?: {
15
+ after?: number;
16
+ limit?: number;
17
+ }): OpenCodeSessionEvents;
18
+ }
19
+ export interface OpenCodeStoreOptions {
20
+ dbPath?: string;
21
+ }
22
+ export interface SessionSummary {
23
+ id: string;
24
+ title: string;
25
+ slug: string;
26
+ createdAt: string;
27
+ durationMs: number;
28
+ eventCount: number;
29
+ isFinished: boolean;
30
+ children: SessionSummary[];
31
+ }
32
+ export interface SessionListResult {
33
+ groups: Array<{
34
+ parent: SessionSummary;
35
+ children: SessionSummary[];
36
+ }>;
37
+ standalone: SessionSummary[];
38
+ }
39
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/opencode/types.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,gBAAgB;IAC/B,EAAE,EAAE,MAAM,CAAA;IACV,WAAW,EAAE,MAAM,CAAA;IACnB,GAAG,EAAE,MAAM,CAAA;IACX,IAAI,EAAE,MAAM,CAAA;IACZ,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;CAC9B;AAED,MAAM,WAAW,qBAAqB;IACpC,SAAS,EAAE,MAAM,CAAA;IACjB,MAAM,EAAE,gBAAgB,EAAE,CAAA;IAC1B,OAAO,EAAE,OAAO,CAAA;CACjB;AAED,MAAM,WAAW,sBAAsB;IACrC,aAAa,CACX,SAAS,EAAE,MAAM,EACjB,OAAO,CAAC,EAAE;QAAE,KAAK,CAAC,EAAE,MAAM,CAAC;QAAC,KAAK,CAAC,EAAE,MAAM,CAAA;KAAE,GAC3C,qBAAqB,CAAA;CACzB;AAED,MAAM,WAAW,oBAAoB;IACnC,MAAM,CAAC,EAAE,MAAM,CAAA;CAChB;AAED,MAAM,WAAW,cAAc;IAC7B,EAAE,EAAE,MAAM,CAAA;IACV,KAAK,EAAE,MAAM,CAAA;IACb,IAAI,EAAE,MAAM,CAAA;IACZ,SAAS,EAAE,MAAM,CAAA;IACjB,UAAU,EAAE,MAAM,CAAA;IAClB,UAAU,EAAE,MAAM,CAAA;IAClB,UAAU,EAAE,OAAO,CAAA;IACnB,QAAQ,EAAE,cAAc,EAAE,CAAA;CAC3B;AAED,MAAM,WAAW,iBAAiB;IAChC,MAAM,EAAE,KAAK,CAAC;QACZ,MAAM,EAAE,cAAc,CAAA;QACtB,QAAQ,EAAE,cAAc,EAAE,CAAA;KAC3B,CAAC,CAAA;IACF,UAAU,EAAE,cAAc,EAAE,CAAA;CAC7B"}
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/opencode/types.ts"],"names":[],"mappings":""}
@@ -116,6 +116,14 @@ export interface DraftTopic {
116
116
  description?: string;
117
117
  /** Ordered list of LOCAL trail ids — foreign keys into the local trail store. */
118
118
  trailIds: string[];
119
+ /**
120
+ * Repositories this topic is about, as PURL strings (e.g.
121
+ * `pkg:github/owner/repo`). The topic's own source of truth for "which repos"
122
+ * — portable and machine-independent, matching `WorkspaceMembership.repositoryId`.
123
+ * Machine-local clone paths stay a workspace-membership concern and never
124
+ * appear here, so this round-trips across machines on publish/fetch.
125
+ */
126
+ repos?: string[];
119
127
  /** ISO 8601. */
120
128
  createdAt: string;
121
129
  /** ISO 8601. */
@@ -145,6 +153,12 @@ export interface PublishedTopic {
145
153
  description: string;
146
154
  /** Ordered list of REMOTE trail ids. */
147
155
  trailIds: string[];
156
+ /**
157
+ * Repositories this topic is about, as PURL strings (e.g.
158
+ * `pkg:github/owner/repo`). Travels with the topic across the wire so a
159
+ * received shared topic carries its repos; preserved on publish/fetch.
160
+ */
161
+ repos?: string[];
148
162
  /** ISO 8601. */
149
163
  createdAt: string;
150
164
  /** ISO 8601. */
@@ -1 +1 @@
1
- {"version":3,"file":"topic-types.d.ts","sourceRoot":"","sources":["../../src/storage/topic-types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEH;;;;;;;;;;;GAWG;AACH,MAAM,WAAW,WAAW;IAC1B;;;;OAIG;IACH,KAAK,EACD,aAAa,GACb,SAAS,GACT,QAAQ,GACR,SAAS,GACT,cAAc,GACd,YAAY,GACZ,WAAW,CAAC;IAChB,wEAAwE;IACxE,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,0EAA0E;IAC1E,SAAS,CAAC,EAAE;QACV,gEAAgE;QAChE,IAAI,CAAC,EAAE,MAAM,CAAC;QACd,oDAAoD;QACpD,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,wEAAwE;QACxE,GAAG,CAAC,EAAE;YACJ,IAAI,EAAE,KAAK,GAAG,IAAI,GAAG,OAAO,GAAG,OAAO,GAAG,OAAO,CAAC;YACjD,8CAA8C;YAC9C,KAAK,EAAE,MAAM,CAAC;YACd,wCAAwC;YACxC,KAAK,CAAC,EAAE,MAAM,CAAC;SAChB,CAAC;KACH,CAAC;CACH;AAED;;;;;;;;;;GAUG;AACH,MAAM,WAAW,UAAU;IACzB,kEAAkE;IAClE,EAAE,EAAE,MAAM,CAAC;IACX,mCAAmC;IACnC,IAAI,EAAE,MAAM,CAAC;IACb,4DAA4D;IAC5D,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,uEAAuE;IACvE,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,yBAAyB;IACzB,GAAG,CAAC,EAAE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G;AACH,MAAM,WAAW,iBAAiB;IAChC,QAAQ,EAAE,MAAM,EAAE,CAAC;IACnB,SAAS,EAAE,YAAY,CAAC;IACxB,UAAU,EAAE,SAAS,GAAG,QAAQ,CAAC;CAClC;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,kBAAkB,CAChC,KAAK,EAAE,UAAU,EACjB,UAAU,EAAE,iBAAiB,GAC5B,cAAc,CAkBhB"}
1
+ {"version":3,"file":"topic-types.d.ts","sourceRoot":"","sources":["../../src/storage/topic-types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEH;;;;;;;;;;;GAWG;AACH,MAAM,WAAW,WAAW;IAC1B;;;;OAIG;IACH,KAAK,EACD,aAAa,GACb,SAAS,GACT,QAAQ,GACR,SAAS,GACT,cAAc,GACd,YAAY,GACZ,WAAW,CAAC;IAChB,wEAAwE;IACxE,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,0EAA0E;IAC1E,SAAS,CAAC,EAAE;QACV,gEAAgE;QAChE,IAAI,CAAC,EAAE,MAAM,CAAC;QACd,oDAAoD;QACpD,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,wEAAwE;QACxE,GAAG,CAAC,EAAE;YACJ,IAAI,EAAE,KAAK,GAAG,IAAI,GAAG,OAAO,GAAG,OAAO,GAAG,OAAO,CAAC;YACjD,8CAA8C;YAC9C,KAAK,EAAE,MAAM,CAAC;YACd,wCAAwC;YACxC,KAAK,CAAC,EAAE,MAAM,CAAC;SAChB,CAAC;KACH,CAAC;CACH;AAED;;;;;;;;;;GAUG;AACH,MAAM,WAAW,UAAU;IACzB,kEAAkE;IAClE,EAAE,EAAE,MAAM,CAAC;IACX,mCAAmC;IACnC,IAAI,EAAE,MAAM,CAAC;IACb,4DAA4D;IAC5D,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,uEAAuE;IACvE,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,yBAAyB;IACzB,GAAG,CAAC,EA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IACvE,MAAM,CAAC,EAAE,WAAW,CAAC;IACrB,8DAA8D;IAC9D,UAAU,EAAE,SAAS,GAAG,QAAQ,CAAC;CAClC;AAED;;;;;;;;GAQG;AACH,MAAM,WAAW,iBAAiB;IAChC,QAAQ,EAAE,MAAM,EAAE,CAAC;IACnB,SAAS,EAAE,YAAY,CAAC;IACxB,UAAU,EAAE,SAAS,GAAG,QAAQ,CAAC;CAClC;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,kBAAkB,CAChC,KAAK,EAAE,UAAU,EACjB,UAAU,EAAE,iBAAiB,GAC5B,cAAc,CAmBhB"}
@@ -48,6 +48,7 @@ function publishedFromDraft(draft, projection) {
48
48
  title: draft.title,
49
49
  description,
50
50
  trailIds: projection.trailIds,
51
+ ...(draft.repos !== undefined ? { repos: draft.repos } : {}),
51
52
  createdAt: draft.createdAt,
52
53
  updatedAt: draft.updatedAt,
53
54
  createdBy: projection.createdBy,
@@ -1 +1 @@
1
- {"version":3,"file":"topic-types.js","sourceRoot":"","sources":["../../src/storage/topic-types.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;;;AAkKH;;;;;;;;;;;;;;GAcG;AACH,SAAgB,kBAAkB,CAChC,KAAiB,EACjB,UAA6B;IAE7B,MAAM,WAAW,GAAG,CAAC,KAAK,CAAC,WAAW,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC;IACrD,IAAI,WAAW,CAAC,MAAM,KAAK,CAAC,EAAE;QAC5B,MAAM,IAAI,KAAK,CACb,SAAS,KAAK,CAAC,EAAE,4DAA4D,CAC9E,CAAC;KACH;IACD,OAAO;QACL,EAAE,EAAE,KAAK,CAAC,EAAE;QACZ,KAAK,EAAE,KAAK,CAAC,KAAK;QAClB,WAAW;QACX,QAAQ,EAAE,UAAU,CAAC,QAAQ;QAC7B,SAAS,EAAE,KAAK,CAAC,SAAS;QAC1B,SAAS,EAAE,KAAK,CAAC,SAAS;QAC1B,SAAS,EAAE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tBD,gDAsBC"}
@@ -69,7 +69,7 @@ export interface MigrationResult {
69
69
  * `trailIds` are not updatable here — use the trail-membership methods for
70
70
  * `trailIds`, and `id`/`createdAt` are immutable.
71
71
  */
72
- export type TopicUpdate = Partial<Pick<DraftTopic, 'title' | 'description' | 'status' | 'createdBy' | 'assets'>>;
72
+ export type TopicUpdate = Partial<Pick<DraftTopic, 'title' | 'description' | 'status' | 'createdBy' | 'assets' | 'repos'>>;
73
73
  /**
74
74
  * Fields a caller may set when creating a topic. `id`, `createdAt`,
75
75
  * `updatedAt` are filled in when omitted; passing `id` lets a caller control
@@ -1 +1 @@
1
- {"version":3,"file":"topicStore.d.ts","sourceRoot":"","sources":["../../src/storage/topicStore.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AAaH,OAAO,KAAK,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAE7D,gEAAgE;AAChE,eAAO,MAAM,aAAa,QAAgC,CAAC;AAC3D,gCAAgC;AAChC,eAAO,MAAM,UAAU,QAAgC,CAAC;AACxD,wDAAwD;AACxD,eAAO,MAAM,kBAAkB,QAAgD,CAAC;AAKhF;;;;GAIG;AACH,MAAM,WAAW,eAAe;IAC9B,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,kBAAkB,EAAE,MAAM,CAAC;IAC3B,UAAU,EAAE,MAAM,CAAC;IACnB,2EAA2E;IAC3E,KAAK,CAAC,EAAE,WAAW,CAAC,OAAO,CAAC,CAAC;IAC7B,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,CAAC,EAAE;QAAE,QAAQ,EAAE,MAAM,CAAC;QAAC,WAAW,EAAE,MAAM,CAAA;KAAE,CAAC;IACtD,SAAS,EAAE,OAAO,CAAC;IACnB,SAAS,EAAE,MAAM,CAAC;IAClB,kEAAkE;IAClE,QAAQ,EAAE,MAAM,CAAC;CAClB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AU,EAAE,CAAC;IAUlC,QAAQ,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,GAAG,IAAI,CAAC;IAOtD,wEAAwE;IAClE,IAAI,IAAI,OAAO,CAAC,eAAe,EAAE,CAAC;IAOlC,WAAW,CAAC,KAAK,EAAE,WAAW,GAAG,OAAO,CAAC,UAAU,CAAC;IAmBpD,WAAW,CAAC,EAAE,EAAE,MAAM,EAAE,OAAO,EAAE,WAAW,GAAG,OAAO,CAAC,UAAU,CAAC;IAelE,WAAW,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAazC,eAAe,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,CAAC;IAatE,oBAAoB,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,CAAC;IAa3E,kBAAkB,CAAC,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,UAAU,CAAC;IAmB5E,iBAAiB,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,EAAE,CAAC;IAO/D;;;;;;;;;;OAUG;IACG,qBAAqB,IAAI,OAAO,CAAC,eAAe,CAAC;YA8DzC,QAAQ;YAQR,YAAY;IAQ1B,4EAA4E;YAC9D,UAAU;YAaV,SAAS;YAUT,cAAc;YAWd,UAAU;YASV,SAAS;IAkBvB,2EAA2E;YAC7D,YAAY;IA4B1B,OAAO,CAAC,YAAY;CAWrB"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@principal-ai/principal-view-core",
3
- "version": "0.28.8",
3
+ "version": "0.28.10",
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",
@@ -16,6 +16,12 @@
16
16
  "import": "./dist/node.js",
17
17
  "require": "./dist/node.js",
18
18
  "default": "./dist/node.js"
19
+ },
20
+ "./pipeline": {
21
+ "types": "./dist/opencode/pipeline.d.ts",
22
+ "import": "./dist/opencode/pipeline.js",
23
+ "require": "./dist/opencode/pipeline.js",
24
+ "default": "./dist/opencode/pipeline.js"
19
25
  }
20
26
  },
21
27
  "files": [
@@ -42,7 +48,9 @@
42
48
  "@opentelemetry/resources": "2.2.0",
43
49
  "@opentelemetry/sdk-trace-base": "2.2.0",
44
50
  "@opentelemetry/semantic-conventions": "1.38.0",
51
+ "@principal-ai/agent-monitoring": "^0.3.31",
45
52
  "@principal-ai/repository-abstraction": "^0.5.7",
53
+ "better-sqlite3": "^13.0.0",
46
54
  "date-fns": "3.0.0",
47
55
  "handlebars": "^4.7.8",
48
56
  "js-yaml": "4.1.0",
@@ -54,6 +62,7 @@
54
62
  "devDependencies": {
55
63
  "@principal-ai/codebase-composition": "^0.2.43",
56
64
  "@principal-ai/principal-view-core": "0.24.10",
65
+ "@types/better-sqlite3": "^7.6.13",
57
66
  "@types/handlebars": "^4.1.0",
58
67
  "@types/jest": "30.0.0",
59
68
  "@types/js-yaml": "4.0.9",
@@ -0,0 +1,225 @@
1
+ import path from "node:path";
2
+ import {
3
+ accumulateToAgentSessionEvents,
4
+ type AgentSessionEvent,
5
+ type NormalizedPathInfo,
6
+ type RepoNormalizedUniversalAgentSessionEvent,
7
+ } from "@principal-ai/agent-monitoring";
8
+
9
+ /**
10
+ * Frozen File City agent-session fixture generation.
11
+ *
12
+ * Reproduces the shape the file-city-panel fixture loaders consume
13
+ * (`{ generatedFrom, session, events }`): repo-normalized universal events are
14
+ * accumulated into agent-session events, then layer item paths (repo-relative
15
+ * displayPaths) are rewritten back to absolute paths with a per-repo
16
+ * files/edits manifest. The result is a static snapshot — no pipeline runs at
17
+ * story time.
18
+ */
19
+
20
+ export interface AgentSessionFixtureMeta {
21
+ sessionName: string;
22
+ sessionTask: string;
23
+ workingDirectory: string;
24
+ createdAt?: string;
25
+ }
26
+
27
+ export interface AgentSessionFixtureRepo {
28
+ repo: string;
29
+ root: string;
30
+ files: number;
31
+ edits: number;
32
+ }
33
+
34
+ export interface AgentSessionFixtureSummary {
35
+ sessionId: string;
36
+ agent: string;
37
+ sessionName: string;
38
+ sessionTask: string;
39
+ workingDirectory: string;
40
+ rawEventCount: number;
41
+ agentEventCount: number;
42
+ repos: AgentSessionFixtureRepo[];
43
+ /** Distinct model ids the session used, in first-use order. */
44
+ models?: string[];
45
+ }
46
+
47
+ export interface FixtureLayerItem {
48
+ path: string;
49
+ type: "file" | "directory";
50
+ renderStrategy?: "border" | "fill" | "glow" | "pattern" | "cover" | "icon" | "custom";
51
+ }
52
+
53
+ export interface FixtureHighlightLayer {
54
+ id: string;
55
+ name: string;
56
+ enabled: boolean;
57
+ color: string;
58
+ opacity?: number;
59
+ borderWidth?: number;
60
+ priority: number;
61
+ dynamic?: boolean;
62
+ items: FixtureLayerItem[];
63
+ }
64
+
65
+ export interface FixtureAgentSessionEvent {
66
+ id: string;
67
+ timestamp: number;
68
+ sessionId: string;
69
+ sessionName: string;
70
+ sessionColor: string;
71
+ operation: AgentSessionEvent["operation"];
72
+ files: string[];
73
+ dependencies: string[];
74
+ description: string;
75
+ layers: FixtureHighlightLayer[];
76
+ contextTokens?: number;
77
+ subagentType?: string;
78
+ childSessionId?: string;
79
+ toolName?: string;
80
+ }
81
+
82
+ export interface AgentSessionFixture {
83
+ generatedFrom: string;
84
+ session: AgentSessionFixtureSummary;
85
+ events: FixtureAgentSessionEvent[];
86
+ }
87
+
88
+ function repoLabel(nf: { repository?: { gitRoot?: string; repo?: string } }): string {
89
+ if (nf.repository?.repo) return nf.repository.repo;
90
+ if (nf.repository?.gitRoot) return path.basename(nf.repository.gitRoot);
91
+ return "";
92
+ }
93
+
94
+ function repoRoot(nf: { repository?: { gitRoot?: string } }): string {
95
+ return nf.repository?.gitRoot ?? "";
96
+ }
97
+
98
+ /**
99
+ * Extract a model id from a model value — agents set it inconsistently
100
+ * (opencode stores `{ providerID, modelID }`-shaped objects, cline / grok /
101
+ * pi store a plain string id).
102
+ */
103
+ function modelIdOf(value: unknown): string | undefined {
104
+ if (typeof value === "string" && value.length > 0) return value;
105
+ if (value && typeof value === "object") {
106
+ const o = value as Record<string, unknown>;
107
+ for (const key of ["modelID", "id"]) {
108
+ if (typeof o[key] === "string" && (o[key] as string).length > 0) {
109
+ return o[key] as string;
110
+ }
111
+ }
112
+ }
113
+ return undefined;
114
+ }
115
+
116
+ /** Pull the model id from one event — normalized `data.model` first, then the
117
+ * raw opencode `info` blob (the bridge only copies `info.model` onto
118
+ * normalized events when the session's created event carried it). */
119
+ function eventModelId(e: RepoNormalizedUniversalAgentSessionEvent): string | undefined {
120
+ const direct = modelIdOf(e.data?.["model"]);
121
+ if (direct) return direct;
122
+ const raw = e.raw as { data?: { info?: { model?: unknown } } } | undefined;
123
+ return modelIdOf(raw?.data?.info?.model);
124
+ }
125
+
126
+ /** Distinct model ids across a session's events, in first-seen order. */
127
+ function collectModels(events: RepoNormalizedUniversalAgentSessionEvent[]): string[] {
128
+ const seen = new Set<string>();
129
+ const models: string[] = [];
130
+ for (const e of events) {
131
+ const id = eventModelId(e);
132
+ if (id && !seen.has(id)) {
133
+ seen.add(id);
134
+ models.push(id);
135
+ }
136
+ }
137
+ return models;
138
+ }
139
+
140
+ export function buildAgentSessionFixture(options: {
141
+ agent: string;
142
+ sessionId: string;
143
+ sessionMeta: AgentSessionFixtureMeta;
144
+ normalizedEvents: RepoNormalizedUniversalAgentSessionEvent[];
145
+ rawEventCount?: number;
146
+ }): AgentSessionFixture {
147
+ const { agent, sessionId, sessionMeta, normalizedEvents, rawEventCount } = options;
148
+ const sessionName = sessionMeta.sessionName || "opencode";
149
+ const agentEvents = accumulateToAgentSessionEvents(normalizedEvents, sessionName);
150
+
151
+ // Rewrite layer item paths (repo-relative displayPath) back to absolute
152
+ // paths. Layer snapshots reflect accumulated state across events, so build a
153
+ // global displayPath -> absolutePath map from every event's files/dependencies.
154
+ const repoBreakdown = new Map<string, { root: string; files: Set<string>; edits: Set<string> }>();
155
+ const displayToAbs = new Map<string, string>();
156
+
157
+ for (const e of agentEvents) {
158
+ for (const f of [...e.files, ...e.dependencies]) {
159
+ if (typeof f === "object" && f && "displayPath" in f) {
160
+ const nf = f as NormalizedPathInfo;
161
+ if (nf.displayPath && !displayToAbs.has(nf.displayPath)) {
162
+ displayToAbs.set(nf.displayPath, nf.absolutePath);
163
+ }
164
+ const label = repoLabel(nf);
165
+ if (!repoBreakdown.has(label)) {
166
+ repoBreakdown.set(label, { root: repoRoot(nf), files: new Set(), edits: new Set() });
167
+ }
168
+ repoBreakdown.get(label)!.files.add(nf.absolutePath);
169
+ if (!repoBreakdown.get(label)!.root) repoBreakdown.get(label)!.root = repoRoot(nf);
170
+ }
171
+ }
172
+ }
173
+
174
+ const events: FixtureAgentSessionEvent[] = agentEvents.map((e) => {
175
+ const files = e.files.map((f) =>
176
+ typeof f === "string" ? f : (f as NormalizedPathInfo).absolutePath,
177
+ );
178
+ const dependencies = e.dependencies.map((f) =>
179
+ typeof f === "string" ? f : (f as NormalizedPathInfo).absolutePath,
180
+ );
181
+
182
+ if (e.operation === "editing") {
183
+ for (const f of files) {
184
+ const label = [...repoBreakdown.entries()].find(([, v]) => v.files.has(f))?.[0] ?? "";
185
+ if (!repoBreakdown.has(label)) {
186
+ repoBreakdown.set(label, { root: "", files: new Set(), edits: new Set() });
187
+ }
188
+ repoBreakdown.get(label)!.edits.add(f);
189
+ }
190
+ }
191
+
192
+ const layers = e.layers.map((l) => ({
193
+ ...l,
194
+ items: l.items.map((item) => {
195
+ const abs = item.path.startsWith("/") ? item.path : displayToAbs.get(item.path) ?? item.path;
196
+ return { ...item, path: abs };
197
+ }),
198
+ }));
199
+
200
+ return { ...e, files, dependencies, layers };
201
+ });
202
+
203
+ const session: AgentSessionFixtureSummary = {
204
+ sessionId,
205
+ agent,
206
+ sessionName,
207
+ sessionTask: sessionMeta.sessionTask,
208
+ workingDirectory: sessionMeta.workingDirectory,
209
+ rawEventCount: rawEventCount ?? normalizedEvents.length,
210
+ agentEventCount: events.length,
211
+ repos: [...repoBreakdown.entries()].map(([repo, v]) => ({
212
+ repo,
213
+ root: v.root,
214
+ files: v.files.size,
215
+ edits: v.edits.size,
216
+ })),
217
+ models: collectModels(normalizedEvents),
218
+ };
219
+
220
+ return {
221
+ generatedFrom: `${agent} session ${sessionId}`,
222
+ session,
223
+ events,
224
+ };
225
+ }
@@ -0,0 +1,10 @@
1
+ export { buildAgentSessionFixture } from "./fixture";
2
+ export type {
3
+ AgentSessionFixture,
4
+ AgentSessionFixtureMeta,
5
+ AgentSessionFixtureRepo,
6
+ AgentSessionFixtureSummary,
7
+ FixtureAgentSessionEvent,
8
+ FixtureHighlightLayer,
9
+ FixtureLayerItem,
10
+ } from "./fixture";
package/src/index.ts CHANGED
@@ -549,6 +549,7 @@ export type {
549
549
  // Use '@principal-ai/principal-view-core/node' for Node.js-specific functionality:
550
550
  //
551
551
  // - EventProcessor, ValidationEngine, ConfigurationValidator (Node.js processing)
552
+ // - OpenCodeEventStore, OpenCodeEventRetriever (opencode event reading)
552
553
  // - GraphInstrumentationHelper (Node.js utilities)
553
554
  // - PathMatcher, GraphConverter (Node.js utilities)
554
555
  // - EventValidator, createValidatedEmitter (Node.js telemetry)
package/src/node.ts CHANGED
@@ -138,6 +138,37 @@ export { LibraryLoader } from './LibraryLoader';
138
138
  export { EventRegistry } from './registry/EventRegistry';
139
139
  export type { EventSource } from './registry/EventRegistry';
140
140
 
141
+ // Export opencode event retrieval (Node.js only - SQLite)
142
+ export { OpenCodeEventStore, defaultOpenCodeDBPath } from './opencode/OpenCodeEventStore';
143
+ export type { OpenCodeRawEvent, OpenCodeSessionEvents, OpenCodeEventRetriever, OpenCodeStoreOptions, SessionSummary, SessionListResult } from './opencode/types';
144
+
145
+ // Export shared, agent-agnostic session listing/fetch/normalization (Node.js only)
146
+ export { listAgentSessions, detectAgent, fetchRawEvents } from './opencode/agent-sessions';
147
+ export type { AgentSessionSummary, AgentSessionMeta, SupportedSessionAgent } from './opencode/agent-sessions';
148
+
149
+ // Export the frozen-fixture generator (Node.js only — runs git walk-up)
150
+ export { buildAgentSessionFixture } from './agent-sessions/fixture';
151
+ export type {
152
+ AgentSessionFixture,
153
+ AgentSessionFixtureMeta,
154
+ AgentSessionFixtureRepo,
155
+ AgentSessionFixtureSummary,
156
+ FixtureAgentSessionEvent,
157
+ FixtureHighlightLayer,
158
+ FixtureLayerItem,
159
+ } from './agent-sessions/fixture';
160
+
161
+ // Export the pure, runtime-agnostic session pipeline (no SQLite dependency)
162
+ export {
163
+ NodePathNormalizationAdapter,
164
+ normalizeEvents,
165
+ normalizeEventsWithAdapter,
166
+ accumulateEvents,
167
+ collectRepositories,
168
+ opencodeRowsToUniversalEvents,
169
+ } from './opencode/pipeline';
170
+ export type { OpenCodeEventRow } from './opencode/pipeline';
171
+
141
172
  // Re-export FileSystemAdapter from repository-abstraction
142
173
  export type { FileSystemAdapter } from '@principal-ai/repository-abstraction';
143
174
  export { InMemoryFileSystemAdapter } from '@principal-ai/repository-abstraction';
@@ -0,0 +1,82 @@
1
+ # opencode V1 Event → NormalizedEventType Mapping
2
+
3
+ ## Event-Level Mapping
4
+
5
+ | V1 event type | Suggested NormalizedEventType | Notes |
6
+ |---|---|---|
7
+ | `session.created.1` | `session-start` | Carries `SessionInfo` (directory, agent, model, title) |
8
+ | `session.updated.1` | `session-update` | Metadata/title/status changes mid-session |
9
+ | `session.deleted.1` | `session-end` | Not observed in local instance; may be rare |
10
+ | `message.updated.1` (role=user) | `user-prompt-submit` | Carries prompt text, format, agent config, system prompt |
11
+ | `message.updated.1` (role=assistant) | `message-display` | Carries message metadata, cost, tokens, error info |
12
+ | `message.removed.1` | `message-removed` | Rare (4 instances across 368 sessions) |
13
+
14
+ ## Part-Level Mapping (`message.part.updated.1`)
15
+
16
+ Each `message.part.updated.1` event carries a single `Part` discriminated by `type`. Below is the per-variant mapping.
17
+
18
+ ### tool — Tool call state machine
19
+
20
+ A single tool call produces **4 separate `part.updated` events** as it transitions. Each maps to a distinct normalized event type to preserve full temporal fidelity for visualization.
21
+
22
+ | Tool state | Suggested NormalizedEventType | Carrier fields |
23
+ |---|---|---|
24
+ | `pending` | `pre-tool-use` | `tool`, `callID`, `state.input`, `state.raw` |
25
+ | `running` | `tool-executing` | `tool`, `callID`, `state.title`, `state.time.start`, `state.metadata` |
26
+ | `completed` | `post-tool-use` | `tool`, `callID`, `state.output`, `state.title`, `state.time.start/end`, `state.attachments` |
27
+ | `error` | `post-tool-use-failure` | `tool`, `callID`, `state.error`, `state.time.start/end` |
28
+
29
+ All four carry `callID` for correlation. A visualization can group them by `callID` to show a single tool call expanding through its lifecycle.
30
+
31
+ ### text — Text output
32
+
33
+ | Part variant | Suggested NormalizedEventType | Carrier fields |
34
+ |---|---|---|
35
+ | `text` | `notification` | `text`, optional `time.start`/`time.end`, `synthetic`, `ignored`, `metadata` |
36
+
37
+ ### reasoning — Model reasoning text
38
+
39
+ | Part variant | Suggested NormalizedEventType | Carrier fields |
40
+ |---|---|---|
41
+ | `reasoning` | `model-reasoning` | `text`, `time.start`/`time.end`, `metadata` |
42
+
43
+ ### step-start / step-finish — Model thinking step boundaries
44
+
45
+ | Part variant | Suggested NormalizedEventType | Carrier fields |
46
+ |---|---|---|
47
+ | `step-start` | `step-start` | Optional `snapshot` |
48
+ | `step-finish` | `step-finish` | `reason` (e.g. `"tool-calls"`, `"stop"`), `cost`, `tokens{input,output,reasoning,cache}`, optional `snapshot` |
49
+
50
+ `step-finish` is the richest source for token/cost accounting. The `reason` field indicates what ended the step.
51
+
52
+ ### patch — File edits
53
+
54
+ | Part variant | Suggested NormalizedEventType | Carrier fields |
55
+ |---|---|---|
56
+ | `patch` | `file-changed` | `hash`, `files[]` (list of affected file paths) |
57
+
58
+ ### compaction — Context window compression
59
+
60
+ | Part variant | Suggested NormalizedEventType | Carrier fields |
61
+ |---|---|---|
62
+ | `compaction` | `post-compact` | `auto` (boolean), optional `overflow`, optional `tail_start_id` |
63
+
64
+ ## NormalizedEventType additions needed
65
+
66
+ Mapping at full fidelity requires adding these new types to the `NormalizedEventType` union in `AgentEventTypes.ts`:
67
+
68
+ ```
69
+ "session-update" // session.updated.1
70
+ "message-removed" // message.removed.1
71
+ "tool-executing" // tool part with state=running
72
+ "model-reasoning" // reasoning part
73
+ "step-start" // step-start part
74
+ "step-finish" // step-finish part (carries cost+tokens)
75
+ "post-tool-use-failure" // already exists
76
+ "file-changed" // already exists
77
+ "post-compact" // already exists
78
+ ```
79
+
80
+ ## Fixture reference
81
+
82
+ `__fixtures__/event-shapes.json` contains one representative sample of each of the 15 shapes listed above, extracted from a local opencode instance. Each entry is a full `EventV2.Payload` with the complete `data` blob intact.