@principal-ai/subsystems-core 0.51.7 → 0.51.8

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.
package/dist/index.d.ts CHANGED
@@ -14,7 +14,7 @@ export * from './types';
14
14
  export type { DraftTopic, TopicAsset, TopicCreator, TopicSubsystemModelRef, TopicReference, } from './storage/topic-types';
15
15
  export { formatTopicReferenceLink, parseTopicReferenceLink } from './storage/topic-reference-links';
16
16
  export { toSharedTopic } from './storage/topic-share';
17
- export type { SharedTopic, SharedTopicAsset, SharedTopicProjection } from './storage/topic-share';
17
+ export type { SharedTopic, SharedTopicAsset, SharedTopicProjection, SharedTopicReference } from './storage/topic-share';
18
18
  export * from './infra';
19
19
  export { validateSubsystemModelCrossField } from './validation';
20
20
  export type { SubsystemValidationProblem } from './validation';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,cAAc,SAAS,CAAC;AAExB,YAAY,EACV,UAAU,EACV,UAAU,EACV,YAAY,EACZ,sBAAsB,EACtB,cAAc,GACf,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,wBAAwB,EAAE,uBAAuB,EAAE,MAAM,iCAAiC,CAAC;AACpG,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AACtD,YAAY,EAAE,WAAW,EAAE,gBAAgB,EAAE,qBAAqB,EAAE,MAAM,uBAAuB,CAAC;AAIlG,cAAc,SAAS,CAAC;AAKxB,OAAO,EAAE,gCAAgC,EAAE,MAAM,cAAc,CAAC;AAChE,YAAY,EAAE,0BAA0B,EAAE,MAAM,cAAc,CAAC;AAI/D,cAAc,cAAc,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,cAAc,SAAS,CAAC;AAExB,YAAY,EACV,UAAU,EACV,UAAU,EACV,YAAY,EACZ,sBAAsB,EACtB,cAAc,GACf,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,wBAAwB,EAAE,uBAAuB,EAAE,MAAM,iCAAiC,CAAC;AACpG,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AACtD,YAAY,EAAE,WAAW,EAAE,gBAAgB,EAAE,qBAAqB,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAC;AAIxH,cAAc,SAAS,CAAC;AAKxB,OAAO,EAAE,gCAAgC,EAAE,MAAM,cAAc,CAAC;AAChE,YAAY,EAAE,0BAA0B,EAAE,MAAM,cAAc,CAAC;AAI/D,cAAc,cAAc,CAAC"}
package/dist/node.d.ts CHANGED
@@ -13,7 +13,7 @@ export type { TopicIndexEntry, TopicCreate, TopicUpdate, MigrationResult, } from
13
13
  export type { DraftTopic, TopicAsset, TopicCreator, TopicSubsystemModelRef, TopicReference, } from './storage/topic-types';
14
14
  export { formatTopicReferenceLink, parseTopicReferenceLink } from './storage/topic-reference-links';
15
15
  export { toSharedTopic } from './storage/topic-share';
16
- export type { SharedTopic, SharedTopicAsset, SharedTopicProjection } from './storage/topic-share';
16
+ export type { SharedTopic, SharedTopicAsset, SharedTopicProjection, SharedTopicReference } from './storage/topic-share';
17
17
  export { OpenCodeEventStore, defaultOpenCodeDBPath } from './opencode/OpenCodeEventStore';
18
18
  export type { OpenCodeRawEvent, OpenCodeSessionEvents, OpenCodeEventRetriever, OpenCodeStoreOptions, SessionSummary, SessionListResult, } from './opencode/types';
19
19
  export { listAgentSessions, detectAgent, fetchRawEvents } from './opencode/agent-sessions';
@@ -1 +1 @@
1
- {"version":3,"file":"node.d.ts","sourceRoot":"","sources":["../src/node.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,cAAc,SAAS,CAAC;AACxB,cAAc,SAAS,CAAC;AAGxB,OAAO,EACL,UAAU,EACV,aAAa,EACb,UAAU,EACV,kBAAkB,GACnB,MAAM,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 +2,21 @@
2
2
  * Portable projection of a topic for sharing outside the machine that authored
3
3
  * it. Browser-safe (no `node:*`).
4
4
  *
5
- * A {@link DraftTopic} carries fields that only mean something locally: store
6
- * ids of subsystem models, references to sketches/drawings/topics on disk, and
7
- * inline image bytes. {@link toSharedTopic} drops the local-only fields and
8
- * splits image bytes out so a host can upload each one separately.
5
+ * A {@link DraftTopic} carries fields that only mean something locally: inline
6
+ * image bytes, local asset origins and drawing references. {@link toSharedTopic}
7
+ * drops those and splits image bytes out so a host can upload each one
8
+ * separately.
9
+ *
10
+ * References to subsystem models, C4 sketches and other topics are kept as ids.
11
+ * A share is published under its local id, so a reader resolves the same id
12
+ * against the sharing service instead of the local store. A reference whose
13
+ * target was not shared (or not with the reader) is simply unavailable.
9
14
  */
10
- import type { DraftTopic, TopicCreator } from './topic-types';
15
+ import type { DraftTopic, TopicCreator, TopicReference, TopicSubsystemModelRef } from './topic-types';
16
+ /** A reference a shared topic can carry. Drawings have no shared form yet. */
17
+ export type SharedTopicReference = Exclude<TopicReference, {
18
+ kind: 'drawing';
19
+ }>;
11
20
  /** An image a shared topic refers to. Bytes travel separately, keyed by `id`. */
12
21
  export interface SharedTopicAsset {
13
22
  /** Content hash; the `asset://<id>` target in the description. */
@@ -20,9 +29,8 @@ export interface SharedTopicAsset {
20
29
  alt?: string;
21
30
  }
22
31
  /**
23
- * A topic as it leaves the authoring machine. No local store ids and no inline
24
- * bytes; `description` is unchanged, so `asset://<id>` links still resolve
25
- * against `assets`.
32
+ * A topic as it leaves the authoring machine. No inline bytes; `description`
33
+ * is unchanged, so `asset://<id>` links still resolve against `assets`.
26
34
  */
27
35
  export interface SharedTopic {
28
36
  id: string;
@@ -36,6 +44,10 @@ export interface SharedTopic {
36
44
  updatedAt: string;
37
45
  createdBy?: TopicCreator;
38
46
  assets?: SharedTopicAsset[];
47
+ /** Subsystem models the topic concerns, by share id (same as the local id). */
48
+ subsystemModels?: TopicSubsystemModelRef[];
49
+ /** Attached C4 sketches and related topics, by share id. */
50
+ references?: SharedTopicReference[];
39
51
  }
40
52
  export interface SharedTopicProjection {
41
53
  topic: SharedTopic;
@@ -49,9 +61,9 @@ export interface SharedTopicProjection {
49
61
  /**
50
62
  * Project a local topic into its shared form.
51
63
  *
52
- * Dropped: `subsystemModels` and `references` (local store ids), each asset's
53
- * `source` (local Storybook origin) and inline `data`. Assets with neither
54
- * `data` nor `url` cannot be resolved by a reader and are omitted.
64
+ * Dropped: drawing references (no shared form), each asset's `source` (local
65
+ * Storybook origin) and inline `data`. Assets with neither `data` nor `url`
66
+ * cannot be resolved by a reader and are omitted.
55
67
  */
56
68
  export declare function toSharedTopic(topic: DraftTopic): SharedTopicProjection;
57
69
  //# sourceMappingURL=topic-share.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"topic-share.d.ts","sourceRoot":"","sources":["../../src/storage/topic-share.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAc,YAAY,EAAE,MAAM,eAAe,CAAC;AAE1E,iFAAiF;AACjF,MAAM,WAAW,gBAAgB;IAC/B,kEAAkE;IAClE,EAAE,EAAE,MAAM,CAAC;IACX,mCAAmC;IACnC,IAAI,EAAE,MAAM,CAAC;IACb,oEAAoE;IACpE,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,yBAAyB;IACzB,GAAG,CAAC,EAAE,MAAM,CAAC;CACd;AAED;;;;GAIG;AACH,MAAM,WAAW,WAAW;IAC1B,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,oCAAoC;IACpC,KAAK,CAAC,EAAE,MAAM,EAAE,CAAC;IACjB,gBAAgB;IAChB,SAAS,EAAE,MAAM,CAAC;IAClB,gBAAgB;IAChB,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,CAAC,EAAE,YAAY,CAAC;IACzB,MAAM,CAAC,EAAE,gBAAgB,EAAE,CAAC;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AC/E,eAAe,CAAC,EAAE,sBAAsB,EAAE,CAAC;IAC3C,4DAA4D;IAC5D,UAAU,CAAC,EAAE,oBAAoB,EAAE,CAAC;CACrC;AAED,MAAM,WAAW,qBAAqB;IACpC,KAAK,EAAE,WAAW,CAAC;IACnB,mFAAmF;IACnF,OAAO,EAAE,KAAK,CAAC;QAAE,EAAE,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;CAC5D;AAED;;;;;;GAMG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,UAAU,GAAG,qBAAqB,CAwCtE"}
@@ -3,19 +3,24 @@
3
3
  * Portable projection of a topic for sharing outside the machine that authored
4
4
  * it. Browser-safe (no `node:*`).
5
5
  *
6
- * A {@link DraftTopic} carries fields that only mean something locally: store
7
- * ids of subsystem models, references to sketches/drawings/topics on disk, and
8
- * inline image bytes. {@link toSharedTopic} drops the local-only fields and
9
- * splits image bytes out so a host can upload each one separately.
6
+ * A {@link DraftTopic} carries fields that only mean something locally: inline
7
+ * image bytes, local asset origins and drawing references. {@link toSharedTopic}
8
+ * drops those and splits image bytes out so a host can upload each one
9
+ * separately.
10
+ *
11
+ * References to subsystem models, C4 sketches and other topics are kept as ids.
12
+ * A share is published under its local id, so a reader resolves the same id
13
+ * against the sharing service instead of the local store. A reference whose
14
+ * target was not shared (or not with the reader) is simply unavailable.
10
15
  */
11
16
  Object.defineProperty(exports, "__esModule", { value: true });
12
17
  exports.toSharedTopic = void 0;
13
18
  /**
14
19
  * Project a local topic into its shared form.
15
20
  *
16
- * Dropped: `subsystemModels` and `references` (local store ids), each asset's
17
- * `source` (local Storybook origin) and inline `data`. Assets with neither
18
- * `data` nor `url` cannot be resolved by a reader and are omitted.
21
+ * Dropped: drawing references (no shared form), each asset's `source` (local
22
+ * Storybook origin) and inline `data`. Assets with neither `data` nor `url`
23
+ * cannot be resolved by a reader and are omitted.
19
24
  */
20
25
  function toSharedTopic(topic) {
21
26
  const assets = [];
@@ -34,6 +39,11 @@ function toSharedTopic(topic) {
34
39
  if (asset.data)
35
40
  uploads.push({ id: asset.id, mime: asset.mime, data: asset.data });
36
41
  }
42
+ const subsystemModels = (topic.subsystemModels ?? []).map((ref) => ({
43
+ modelId: ref.modelId,
44
+ ...(ref.trailIds?.length ? { trailIds: [...ref.trailIds] } : {}),
45
+ }));
46
+ const references = (topic.references ?? []).filter((ref) => ref.kind !== 'drawing');
37
47
  return {
38
48
  topic: {
39
49
  id: topic.id,
@@ -44,6 +54,8 @@ function toSharedTopic(topic) {
44
54
  updatedAt: topic.updatedAt,
45
55
  ...(topic.createdBy ? { createdBy: { ...topic.createdBy } } : {}),
46
56
  ...(assets.length ? { assets } : {}),
57
+ ...(subsystemModels.length ? { subsystemModels } : {}),
58
+ ...(references.length ? { references: references.map((ref) => ({ ...ref })) } : {}),
47
59
  },
48
60
  uploads,
49
61
  };
@@ -1 +1 @@
1
- {"version":3,"file":"topic-share.js","sourceRoot":"","sources":["../../src/storage/topic-share.ts"],"names":[],"mappings":";AAAA;;;;;;;;GAQG;;;AAyCH;;;;;;GAMG;AACH,SAAgB,aAAa,CAAC,KAAiB;IAC7C,MAAM,MAAM,GAAuB,EAAE,CAAC;IACtC,MAAM,OAAO,GAAqC,EAAE,CAAC;IACrD,MAAM,IAAI,GAAG,IAAI,GAAG,EAAU,CAAC;IAE/B,KAAK,MAAM,KAAK,IAAI,KAAK,CAAC,MAAM,IAAI,EAAE,EAAE;QACtC,IAAI,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC,IAAI,CAAC,YAAY,CAAC,KAAK,CAAC;YAAE,SAAS;QACzD,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;QACnB,MAAM,CAAC,IAAI,CAAC;YACV,EAAE,EAAE,KAAK,CAAC,EAAE;YACZ,IAAI,EAAE,KAAK,CAAC,IAAI;YAChB,GAAG,CAAC,KAAK,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E,CAAC,CAAC,CAAC,EAAE,CAAC;YACtD,GAAG,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,UAAU,EAAE,UAAU,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC,EAAE,GAAG,GAAG,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;SACpF;QACD,OAAO;KACR,CAAC;AACJ,CAAC;AAxCD,sCAwCC;AAED,SAAS,YAAY,CAAC,KAAiB;IACrC,OAAO,OAAO,CAAC,KAAK,CAAC,IAAI,IAAI,KAAK,CAAC,GAAG,CAAC,CAAC;AAC1C,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@principal-ai/subsystems-core",
3
- "version": "0.51.7",
3
+ "version": "0.51.8",
4
4
  "description": "Subsystem model types and agent-session tooling for Principal AI",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",
package/src/index.ts CHANGED
@@ -22,7 +22,7 @@ export type {
22
22
  } from './storage/topic-types';
23
23
  export { formatTopicReferenceLink, parseTopicReferenceLink } from './storage/topic-reference-links';
24
24
  export { toSharedTopic } from './storage/topic-share';
25
- export type { SharedTopic, SharedTopicAsset, SharedTopicProjection } from './storage/topic-share';
25
+ export type { SharedTopic, SharedTopicAsset, SharedTopicProjection, SharedTopicReference } from './storage/topic-share';
26
26
 
27
27
  // Infrastructure-as-code read side: what wrangler / terraform declare, and the
28
28
  // shape a live-deployment observation takes. Pure — text and JSON in.
package/src/node.ts CHANGED
@@ -32,7 +32,7 @@ export type {
32
32
  } from './storage/topic-types';
33
33
  export { formatTopicReferenceLink, parseTopicReferenceLink } from './storage/topic-reference-links';
34
34
  export { toSharedTopic } from './storage/topic-share';
35
- export type { SharedTopic, SharedTopicAsset, SharedTopicProjection } from './storage/topic-share';
35
+ export type { SharedTopic, SharedTopicAsset, SharedTopicProjection, SharedTopicReference } from './storage/topic-share';
36
36
 
37
37
  // OpenCode event retrieval (Node.js only - SQLite)
38
38
  export { OpenCodeEventStore, defaultOpenCodeDBPath } from './opencode/OpenCodeEventStore';
@@ -19,11 +19,31 @@ describe('toSharedTopic', () => {
19
19
  expect(uploads).toEqual([]);
20
20
  });
21
21
 
22
- test('drops local store ids and references', () => {
22
+ test('keeps model, sketch and topic references by id and drops drawings', () => {
23
23
  const { topic } = toSharedTopic({
24
24
  ...base,
25
- subsystemModels: [{ modelId: 'sg-1', trailIds: ['wt-a'] }],
26
- references: [{ kind: 'c4-sketch', sketchId: 'c4s-1' }, { kind: 'topic', topicId: 'topic-2' }],
25
+ subsystemModels: [{ modelId: 'sg-1', trailIds: ['wt-a'] }, { modelId: 'sg-2', trailIds: [] }],
26
+ references: [
27
+ { kind: 'c4-sketch', sketchId: 'c4s-1' },
28
+ { kind: 'drawing', drawingId: 'd-1' },
29
+ { kind: 'topic', topicId: 'topic-2' },
30
+ ],
31
+ });
32
+ expect(topic.subsystemModels).toEqual([
33
+ { modelId: 'sg-1', trailIds: ['wt-a'] },
34
+ { modelId: 'sg-2' },
35
+ ]);
36
+ expect(topic.references).toEqual([
37
+ { kind: 'c4-sketch', sketchId: 'c4s-1' },
38
+ { kind: 'topic', topicId: 'topic-2' },
39
+ ]);
40
+ });
41
+
42
+ test('omits empty reference lists', () => {
43
+ const { topic } = toSharedTopic({
44
+ ...base,
45
+ subsystemModels: [],
46
+ references: [{ kind: 'drawing', drawingId: 'd-1' }],
27
47
  });
28
48
  expect(topic).not.toHaveProperty('subsystemModels');
29
49
  expect(topic).not.toHaveProperty('references');
@@ -2,13 +2,27 @@
2
2
  * Portable projection of a topic for sharing outside the machine that authored
3
3
  * it. Browser-safe (no `node:*`).
4
4
  *
5
- * A {@link DraftTopic} carries fields that only mean something locally: store
6
- * ids of subsystem models, references to sketches/drawings/topics on disk, and
7
- * inline image bytes. {@link toSharedTopic} drops the local-only fields and
8
- * splits image bytes out so a host can upload each one separately.
5
+ * A {@link DraftTopic} carries fields that only mean something locally: inline
6
+ * image bytes, local asset origins and drawing references. {@link toSharedTopic}
7
+ * drops those and splits image bytes out so a host can upload each one
8
+ * separately.
9
+ *
10
+ * References to subsystem models, C4 sketches and other topics are kept as ids.
11
+ * A share is published under its local id, so a reader resolves the same id
12
+ * against the sharing service instead of the local store. A reference whose
13
+ * target was not shared (or not with the reader) is simply unavailable.
9
14
  */
10
15
 
11
- import type { DraftTopic, TopicAsset, TopicCreator } from './topic-types';
16
+ import type {
17
+ DraftTopic,
18
+ TopicAsset,
19
+ TopicCreator,
20
+ TopicReference,
21
+ TopicSubsystemModelRef,
22
+ } from './topic-types';
23
+
24
+ /** A reference a shared topic can carry. Drawings have no shared form yet. */
25
+ export type SharedTopicReference = Exclude<TopicReference, { kind: 'drawing' }>;
12
26
 
13
27
  /** An image a shared topic refers to. Bytes travel separately, keyed by `id`. */
14
28
  export interface SharedTopicAsset {
@@ -23,9 +37,8 @@ export interface SharedTopicAsset {
23
37
  }
24
38
 
25
39
  /**
26
- * A topic as it leaves the authoring machine. No local store ids and no inline
27
- * bytes; `description` is unchanged, so `asset://<id>` links still resolve
28
- * against `assets`.
40
+ * A topic as it leaves the authoring machine. No inline bytes; `description`
41
+ * is unchanged, so `asset://<id>` links still resolve against `assets`.
29
42
  */
30
43
  export interface SharedTopic {
31
44
  id: string;
@@ -39,6 +52,10 @@ export interface SharedTopic {
39
52
  updatedAt: string;
40
53
  createdBy?: TopicCreator;
41
54
  assets?: SharedTopicAsset[];
55
+ /** Subsystem models the topic concerns, by share id (same as the local id). */
56
+ subsystemModels?: TopicSubsystemModelRef[];
57
+ /** Attached C4 sketches and related topics, by share id. */
58
+ references?: SharedTopicReference[];
42
59
  }
43
60
 
44
61
  export interface SharedTopicProjection {
@@ -50,9 +67,9 @@ export interface SharedTopicProjection {
50
67
  /**
51
68
  * Project a local topic into its shared form.
52
69
  *
53
- * Dropped: `subsystemModels` and `references` (local store ids), each asset's
54
- * `source` (local Storybook origin) and inline `data`. Assets with neither
55
- * `data` nor `url` cannot be resolved by a reader and are omitted.
70
+ * Dropped: drawing references (no shared form), each asset's `source` (local
71
+ * Storybook origin) and inline `data`. Assets with neither `data` nor `url`
72
+ * cannot be resolved by a reader and are omitted.
56
73
  */
57
74
  export function toSharedTopic(topic: DraftTopic): SharedTopicProjection {
58
75
  const assets: SharedTopicAsset[] = [];
@@ -71,6 +88,14 @@ export function toSharedTopic(topic: DraftTopic): SharedTopicProjection {
71
88
  if (asset.data) uploads.push({ id: asset.id, mime: asset.mime, data: asset.data });
72
89
  }
73
90
 
91
+ const subsystemModels = (topic.subsystemModels ?? []).map((ref) => ({
92
+ modelId: ref.modelId,
93
+ ...(ref.trailIds?.length ? { trailIds: [...ref.trailIds] } : {}),
94
+ }));
95
+ const references = (topic.references ?? []).filter(
96
+ (ref): ref is SharedTopicReference => ref.kind !== 'drawing',
97
+ );
98
+
74
99
  return {
75
100
  topic: {
76
101
  id: topic.id,
@@ -81,6 +106,8 @@ export function toSharedTopic(topic: DraftTopic): SharedTopicProjection {
81
106
  updatedAt: topic.updatedAt,
82
107
  ...(topic.createdBy ? { createdBy: { ...topic.createdBy } } : {}),
83
108
  ...(assets.length ? { assets } : {}),
109
+ ...(subsystemModels.length ? { subsystemModels } : {}),
110
+ ...(references.length ? { references: references.map((ref) => ({ ...ref })) } : {}),
84
111
  },
85
112
  uploads,
86
113
  };