@serene-pub/sdk 0.6.0-pr-2 → 0.6.0-pr-5

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 (186) hide show
  1. package/README.md +24 -20
  2. package/dist/actions.d.ts +150 -68
  3. package/dist/actions.js +90 -36
  4. package/dist/annexFields.d.ts +8 -4
  5. package/dist/annexFields.js +5 -2
  6. package/dist/announce.d.ts +78 -28
  7. package/dist/announce.js +14 -5
  8. package/dist/attributes.d.ts +9 -6
  9. package/dist/attributes.js +9 -5
  10. package/dist/bands.d.ts +41 -6
  11. package/dist/bands.js +83 -33
  12. package/dist/builder.d.ts +161 -58
  13. package/dist/builder.js +128 -22
  14. package/dist/candidates.d.ts +5 -3
  15. package/dist/candidates.js +3 -2
  16. package/dist/clauses.d.ts +2 -1
  17. package/dist/clauses.js +2 -1
  18. package/dist/component.d.ts +24 -7
  19. package/dist/component.js +16 -6
  20. package/dist/componentBuild.d.ts +16 -5
  21. package/dist/componentBuild.js +14 -5
  22. package/dist/componentClient.d.ts +61 -30
  23. package/dist/componentClient.js +11 -1
  24. package/dist/componentImports.d.ts +8 -5
  25. package/dist/componentImports.js +23 -4
  26. package/dist/componentModule.js +2 -1
  27. package/dist/componentWire.d.ts +2 -1
  28. package/dist/componentWire.js +34 -2
  29. package/dist/config.d.ts +28 -14
  30. package/dist/config.js +20 -10
  31. package/dist/connections.d.ts +9 -4
  32. package/dist/connections.js +7 -4
  33. package/dist/declarations.d.ts +46 -17
  34. package/dist/declarations.js +46 -15
  35. package/dist/descriptors.d.ts +242 -97
  36. package/dist/descriptors.js +145 -41
  37. package/dist/dev.d.ts +6 -5
  38. package/dist/dev.js +6 -5
  39. package/dist/document.d.ts +74 -25
  40. package/dist/document.js +32 -11
  41. package/dist/dowry.d.ts +241 -0
  42. package/dist/dowry.js +315 -0
  43. package/dist/engines.d.ts +16 -7
  44. package/dist/engines.js +6 -4
  45. package/dist/eventMapLaws.d.ts +19 -8
  46. package/dist/eventMapLaws.js +9 -6
  47. package/dist/events.d.ts +101 -39
  48. package/dist/events.js +106 -33
  49. package/dist/executor.d.ts +122 -41
  50. package/dist/executor.js +195 -96
  51. package/dist/extension.d.ts +99 -35
  52. package/dist/extension.js +43 -9
  53. package/dist/facets.d.ts +2 -1
  54. package/dist/facets.js +4 -2
  55. package/dist/foldedSections.d.ts +4 -2
  56. package/dist/foldedSections.js +2 -1
  57. package/dist/genres.d.ts +123 -41
  58. package/dist/genres.js +127 -22
  59. package/dist/guardedConnection.d.ts +4 -3
  60. package/dist/guardedConnection.js +4 -3
  61. package/dist/handlebarsReach.d.ts +1 -1
  62. package/dist/handlebarsReach.js +1 -1
  63. package/dist/hash.d.ts +16 -5
  64. package/dist/hash.js +14 -4
  65. package/dist/hookGrants.d.ts +3 -2
  66. package/dist/hookGrants.js +6 -4
  67. package/dist/hooks.d.ts +21 -16
  68. package/dist/hooks.js +12 -10
  69. package/dist/hostElements.d.ts +41 -17
  70. package/dist/hostElements.js +49 -17
  71. package/dist/i18n.d.ts +5 -3
  72. package/dist/i18n.js +5 -3
  73. package/dist/identity.d.ts +5 -4
  74. package/dist/identity.js +5 -4
  75. package/dist/index.d.ts +5 -0
  76. package/dist/index.js +15 -0
  77. package/dist/layout.d.ts +36 -15
  78. package/dist/layout.js +2 -2
  79. package/dist/loadouts.d.ts +97 -0
  80. package/dist/loadouts.js +81 -0
  81. package/dist/media.d.ts +26 -4
  82. package/dist/media.js +2 -1
  83. package/dist/messageBlocks.d.ts +44 -32
  84. package/dist/messageBlocks.js +23 -18
  85. package/dist/migration.d.ts +16 -8
  86. package/dist/migration.js +14 -8
  87. package/dist/names.d.ts +2 -1
  88. package/dist/names.js +2 -1
  89. package/dist/nodeInput.d.ts +2 -1
  90. package/dist/nodeInput.js +2 -1
  91. package/dist/participants.d.ts +22 -15
  92. package/dist/participants.js +14 -12
  93. package/dist/personGate.d.ts +2 -1
  94. package/dist/personGate.js +2 -1
  95. package/dist/pluginHarness.d.ts +8 -3
  96. package/dist/pluginHarness.js +4 -2
  97. package/dist/pluginPermissions.d.ts +2 -1
  98. package/dist/pluginPermissions.js +12 -1
  99. package/dist/pluginRuleRef.d.ts +2 -2
  100. package/dist/pluginRuleRef.js +1 -1
  101. package/dist/predicates.d.ts +16 -11
  102. package/dist/predicates.js +7 -6
  103. package/dist/preview.d.ts +8 -3
  104. package/dist/preview.js +2 -1
  105. package/dist/promptBlocks.d.ts +5 -3
  106. package/dist/promptBlocks.js +5 -3
  107. package/dist/rankingDecisions.d.ts +2 -1
  108. package/dist/rankingDecisions.js +2 -1
  109. package/dist/receipt.d.ts +65 -29
  110. package/dist/receipt.js +9 -4
  111. package/dist/receiverRules.js +3 -2
  112. package/dist/refs.d.ts +34 -9
  113. package/dist/refs.js +33 -13
  114. package/dist/registry.d.ts +42 -23
  115. package/dist/registry.js +7 -5
  116. package/dist/review.d.ts +16 -5
  117. package/dist/review.js +11 -4
  118. package/dist/sampling.d.ts +54 -0
  119. package/dist/sampling.js +95 -3
  120. package/dist/sceneSettings.d.ts +312 -0
  121. package/dist/sceneSettings.js +425 -0
  122. package/dist/scope.d.ts +6 -4
  123. package/dist/scope.js +4 -3
  124. package/dist/scripts.d.ts +81 -14
  125. package/dist/scripts.js +90 -11
  126. package/dist/sessionDossier.d.ts +521 -0
  127. package/dist/sessionDossier.js +33 -0
  128. package/dist/sessionLayout.d.ts +303 -19
  129. package/dist/sessionLayout.js +354 -40
  130. package/dist/sessionSettings.d.ts +8 -5
  131. package/dist/settings.d.ts +45 -20
  132. package/dist/settings.js +19 -12
  133. package/dist/settingsSlot.d.ts +11 -8
  134. package/dist/settingsSlot.js +11 -8
  135. package/dist/shapes.d.ts +103 -41
  136. package/dist/shapes.js +105 -40
  137. package/dist/sheets.d.ts +4 -2
  138. package/dist/sheets.js +6 -3
  139. package/dist/statShapes.d.ts +2 -1
  140. package/dist/statShapes.js +2 -1
  141. package/dist/status.d.ts +13 -9
  142. package/dist/status.js +8 -6
  143. package/dist/storage.d.ts +2 -1
  144. package/dist/storage.js +2 -1
  145. package/dist/storyTime.d.ts +13 -7
  146. package/dist/storyTime.js +11 -6
  147. package/dist/strokes.d.ts +176 -0
  148. package/dist/strokes.js +281 -0
  149. package/dist/surfaces.d.ts +54 -25
  150. package/dist/surfaces.js +3 -3
  151. package/dist/template.d.ts +9 -5
  152. package/dist/template.js +5 -3
  153. package/dist/templateCheck.d.ts +2 -2
  154. package/dist/templateCheck.js +2 -2
  155. package/dist/templateFit.d.ts +37 -8
  156. package/dist/templateFit.js +92 -8
  157. package/dist/templateIds.d.ts +3 -3
  158. package/dist/templateIds.js +3 -3
  159. package/dist/templateScopeAt.d.ts +21 -11
  160. package/dist/templateScopeAt.js +21 -11
  161. package/dist/testing.d.ts +11 -4
  162. package/dist/testing.js +13 -5
  163. package/dist/tokenizers.d.ts +2 -2
  164. package/dist/tokenizers.js +2 -2
  165. package/dist/turnLock.d.ts +4 -2
  166. package/dist/turnLock.js +2 -1
  167. package/dist/turnOrder.d.ts +17 -11
  168. package/dist/turnOrder.js +9 -5
  169. package/dist/validate.d.ts +11 -8
  170. package/dist/validate.js +81 -10
  171. package/dist/values.d.ts +17 -8
  172. package/dist/values.js +11 -6
  173. package/dist/variables.d.ts +46 -7
  174. package/dist/variables.js +87 -6
  175. package/dist/verdicts.d.ts +20 -13
  176. package/dist/verdicts.js +17 -11
  177. package/dist/widgetDecls.d.ts +8 -4
  178. package/dist/widgetDecls.js +4 -2
  179. package/dist/widgets.d.ts +987 -94
  180. package/dist/widgets.js +93 -18
  181. package/dist/wire.d.ts +13 -6
  182. package/dist/wire.js +3 -3
  183. package/dist/worldinfo.d.ts +11 -6
  184. package/dist/worldinfo.js +8 -4
  185. package/host-elements.d.ts +13 -0
  186. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -44,6 +44,9 @@ export * from './engines.js';
44
44
  // and the declaration a plugin ships one under (R19). Beside engines because the
45
45
  // two share the `template` kind segment and must be read together.
46
46
  export * from './templateIds.js';
47
+ // Loadouts (I12): the third model layer — a declaration a package ships, the
48
+ // `loadout-ref` value a node's `loadout` slot holds, and `prefers`.
49
+ export * from './loadouts.js';
47
50
  export * from './variables.js';
48
51
  // Bands as template variables (typed templates P2): a source declares the
49
52
  // bands it publishes; `rendersAt` is what a node's variables slot renders.
@@ -66,11 +69,20 @@ export * from './attributes.js';
66
69
  // Beside attributes because it is the same registry discipline one level up:
67
70
  // a slot says what one value is, a sheet says which values a thing has.
68
71
  export * from './sheets.js';
72
+ // Card strokes — a card's description and personality as ordered prose
73
+ // pieces, and the card dowry — the stats a card carries between installs.
74
+ // Beside sheets because the dowry is sheets and slots on the card; strokes
75
+ // sit with it because both live on the card and nowhere else.
76
+ export * from './strokes.js';
77
+ export * from './dowry.js';
69
78
  // Stat shapes — the named FieldDecls a slot's value may take, and the story
70
79
  // time a clock/date stat holds. Beside sheets: the same registry discipline,
71
80
  // one level down (a sheet names slots, a slot names its shape).
72
81
  export * from './statShapes.js';
73
82
  export * from './storyTime.js';
83
+ // 🚧 Scene settings (live scenes §4–§5): how a session places its scene
84
+ // boundaries and when a scene's summary runs; `SessionShape.scenes`.
85
+ export * from './sceneSettings.js';
74
86
  // The turn lock — whether the numbers written for one speaker are still open.
75
87
  // In the SDK because the host's write gate, a plugin proposing a change and
76
88
  // the client drawing the ledger must answer it identically; see the file.
@@ -101,6 +113,9 @@ export * from './worldinfo.js';
101
113
  // native and frame alike. Before surfaces because the frame wire carries these
102
114
  // shapes; `widgets.ts` imports nothing, so neither direction can cycle.
103
115
  export * from './widgets.js';
116
+ // The conversation dossier (`session_full.v1`, C4): the one scoped section
117
+ // whose shape is large enough for a file of its own. Imports nothing.
118
+ export * from './sessionDossier.js';
104
119
  // The person gate on a widget's invoke of a message-changing core verb — the
105
120
  // page's and the harness's one table (imports nothing).
106
121
  export * from './personGate.js';
package/dist/layout.d.ts CHANGED
@@ -9,20 +9,23 @@
9
9
  * `descriptors.ts` can name `WidgetDecl` without a cycle.
10
10
  *
11
11
  * The file kept its name when the retired layout document (LayoutDoc v2) and
12
- * its machinery left it (plan `PLAN-layout-one-format-2026-09-28`, brief 1):
13
- * the widget half is what stayed.
12
+ * its machinery left it: the widget half is what stayed.
13
+ * @ruling PLAN-layout-one-format-2026-09-28 brief 1
14
14
  */
15
15
  import type { I18n } from './i18n.js';
16
16
  import type { SettingsSchema } from './settings.js';
17
- import type { WidgetBaseSection, WidgetSectionScope } from './widgets.js';
17
+ import type { WidgetBaseSection, WidgetSectionScope, WidgetWriteGrant } from './widgets.js';
18
18
  /**
19
19
  * Data a widget requests access to (grant-gated, host-enforced at
20
20
  * projection): a scope that delivers a scoped section — the SDK's one table,
21
21
  * `WidgetScopedSections` (`session:full`, `session:state`, `persona`,
22
- * `characters`, `lore`) — or a `channel:<slug>`.
22
+ * `characters`, `lore`) — or a `channel:<slug>`; or a **write grant** on one
23
+ * (`session:state:write`, `channel:<slug>:write`, {@link WidgetWriteGrant}),
24
+ * a permission apart from the read that lets a plugin's widget ask the
25
+ * request kinds that change it (`set-attribute-value`, `send`, `draft`).
23
26
  * @experimental
24
27
  */
25
- export type WidgetScope = WidgetSectionScope | `channel:${string}`;
28
+ export type WidgetScope = WidgetSectionScope | `channel:${string}` | WidgetWriteGrant;
26
29
  /** An external plugin dependency; the CLI captures pkg/range from the imports. @experimental */
27
30
  export interface WidgetDependency {
28
31
  /** The depended-on plugin's stable manifest id. */
@@ -71,10 +74,11 @@ export declare function systemStyleSlug(widgetId: string, presetSlug: string): s
71
74
  /**
72
75
  * What a widget renders, resolved — the host's switch. `remote` is a
73
76
  * component running in its owner's UI worker, mirrored through the
74
- * vocabulary (§3.5) — core's own components as much as a plugin's (R79).
77
+ * vocabulary — core's own components as much as a plugin's.
75
78
  * A real document goes INSIDE the component, as an `sp-frame`; a widget is
76
79
  * never a bare frame (the `surface` shortcut retired 2026-10-02).
77
80
  * @experimental
81
+ * @ruling §3.5, R79
78
82
  */
79
83
  export type WidgetSurface = {
80
84
  kind: 'remote';
@@ -91,18 +95,22 @@ export type WidgetSurface = {
91
95
  export declare function resolveWidgetSurface(decl: Pick<WidgetDecl, 'component'>, owner: string): WidgetSurface | null;
92
96
  /**
93
97
  * One **widget** a session offers: the conversation, a portrait column, a
94
- * plugin's board. Every widget names a component (R25); a plugin that needs a
98
+ * plugin's board. Every widget names a component; a plugin that needs a
95
99
  * real document places an `sp-frame` inside that component.
96
100
  *
97
101
  * Declaring a widget makes it *addable*. Where an instance of it sits is the
98
102
  * **session layout**'s business (`SessionLayoutV1`): any widget may sit in any
99
103
  * zone, as many times as the layout places it (`maxInstances` aside).
100
104
  * @experimental
105
+ * @ruling R25
101
106
  */
102
107
  export interface WidgetDecl {
103
108
  /** Stable id — a layout's widget instance ids and `surface:open` intents key on this. */
104
109
  id: string;
105
- /** Human title shown in the widget's chrome and the tray — a string or a locale map (R-20). */
110
+ /**
111
+ * Human title shown in the widget's chrome and the tray — a string or a locale map.
112
+ * @ruling R-20
113
+ */
106
114
  title: I18n;
107
115
  /** Optional icon name (the app maps it to its icon set). */
108
116
  icon?: string;
@@ -115,28 +123,34 @@ export interface WidgetDecl {
115
123
  */
116
124
  role?: 'primary' | 'secondary';
117
125
  /**
118
- * The genres whose sessions offer it (R71), by id — `widget()` reads
126
+ * The genres whose sessions offer it, by id — `widget()` reads
119
127
  * genre values down to these. Absent = every genre. A genre may still
120
128
  * withhold it (`GenreDecl.omitWidgets`).
129
+ * @ruling R71
121
130
  */
122
131
  genres?: string[];
123
132
  /**
124
133
  * What renders inside: the slug of a {@link ComponentDecl} in the same
125
- * package (R25). Core's widgets name core components. A document the
134
+ * package. Core's widgets name core components. A document the
126
135
  * widget needs goes inside that component, as an `sp-frame`.
136
+ * @ruling R25
127
137
  */
128
138
  component: string;
129
- /** Which channels feed it (20 §4/§7). A widget is a view onto its channels. */
139
+ /**
140
+ * Which channels feed it. A widget is a view onto its channels.
141
+ * @ruling 20 §4/§7
142
+ */
130
143
  channels?: string[];
131
144
  /** Data the widget requests; each entry is a grant an admin can deny. */
132
145
  scopes?: WidgetScope[];
133
146
  /**
134
- * The BASE sections this widget reads (R75) — `messages`, `settings`, … —
147
+ * The BASE sections this widget reads — `messages`, `settings`, … —
135
148
  * and so the only ones its host sends it: a widget that does not read
136
149
  * `messages` is never handed the log again on every token. Absent means
137
- * every base section, which is what a widget declared before R75 reads.
150
+ * every base section, which is what a widget declared before `reads` existed reads.
138
151
  * A name outside `WIDGET_BASE_SECTIONS` is refused where the widget is
139
152
  * declared. Scoped sections are not named here — `scopes` asks for them.
153
+ * @ruling R75
140
154
  */
141
155
  reads?: WidgetBaseSection[];
142
156
  /** External plugin dependencies (CLI-captured into the manifest). */
@@ -173,7 +187,7 @@ export interface WidgetDecl {
173
187
  * reads: the column span a widget asks for, its minimum box, whether it may
174
188
  * collapse or close, and whether it prefers the drawer. The layout
175
189
  * document's replacements for them (`placement`, `cells`, `fold`) retired
176
- * with it (owner L1, 2026-09-28), so these stand until the session layout
190
+ * with it (owner ruling 2026-09-28), so these stand until the session layout
177
191
  * states sizes of its own.
178
192
  */
179
193
  layout?: {
@@ -188,7 +202,14 @@ export interface WidgetDecl {
188
202
  closable?: boolean;
189
203
  prefer?: 'grid' | 'drawer';
190
204
  };
191
- /** Seed this widget into a new session's default layout. Default false. */
205
+ /**
206
+ * ⏳ Read by nothing since 2026-10-10: whether a widget
207
+ * starts on is a LAYOUT fact — it is on in a session exactly when that
208
+ * session's layout draws it, so a genre that wants it on places it in its
209
+ * layout (`GenreDecl.layouts`). Kept so a declaration that carries it still
210
+ * type-checks; it goes in 0.7.0.
211
+ * @ruling widget consolidation C2
212
+ */
192
213
  defaultActive?: boolean;
193
214
  }
194
215
  //# sourceMappingURL=layout.d.ts.map
package/dist/layout.js CHANGED
@@ -9,8 +9,8 @@
9
9
  * `descriptors.ts` can name `WidgetDecl` without a cycle.
10
10
  *
11
11
  * The file kept its name when the retired layout document (LayoutDoc v2) and
12
- * its machinery left it (plan `PLAN-layout-one-format-2026-09-28`, brief 1):
13
- * the widget half is what stayed.
12
+ * its machinery left it: the widget half is what stayed.
13
+ * @ruling PLAN-layout-one-format-2026-09-28 brief 1
14
14
  */
15
15
  /**
16
16
  * The globally-unique, reseed-stable slug for a widget's built-in style. This is
@@ -0,0 +1,97 @@
1
+ /**
2
+ * **Loadouts** — the third model layer.
3
+ *
4
+ * A loadout says what an ENGINE is and how it is driven: the pair
5
+ * `(connection, model)`, a sampling config by reference, and — when the pair's
6
+ * drawing sheet takes a template payload — a workflow. It never says what a
7
+ * step MEANS (prompts, parameters, template, settings stay on the node).
8
+ *
9
+ * A package ships a loadout as a **declaration** — never a pair (plugins never
10
+ * see connections: the pair is the one blank a person fills). At boot the instance turns it into a row
11
+ * with an empty pair: **unfilled**. A node names one on its oracle's `loadout`
12
+ * slot, and the host resolves per value:
13
+ *
14
+ * node's explicit slot → its loadout (following merges to the root) →
15
+ * if that loadout is unfilled, the transform's default loadout.
16
+ *
17
+ * ```ts
18
+ * .preset('default', { label: 'Default', default: true }, (p) =>
19
+ * p.loadout('summarize', slot.loadout('core:loadout/extraction@1')))
20
+ * ```
21
+ * @experimental
22
+ * @ruling DESIGN-image-generation §13 (2026-10-12)
23
+ */
24
+ import type { TransformId } from './capabilities.js';
25
+ /**
26
+ * The grammar, one kind segment over from a template id:
27
+ * `core:loadout/extraction@1` · `acme.rp:loadout/extract@1`.
28
+ * A person's own loadout reads `pub:loadout/<slug>` and carries no major.
29
+ * @experimental
30
+ */
31
+ export declare const LOADOUT_ID: RegExp;
32
+ /**
33
+ * A loadout id as a type. Shipped ids carry `@N`; a pub loadout does not.
34
+ * @experimental
35
+ */
36
+ export type LoadoutId = `${string}:loadout/${string}`;
37
+ /** `fast` · `cheap` · `best` — a soft preference, never a gate. @experimental */
38
+ export type LoadoutTier = 'fast' | 'cheap' | 'best';
39
+ /** @experimental */
40
+ export declare const LOADOUT_TIERS: readonly LoadoutTier[];
41
+ /**
42
+ * The value a `loadout-ref` control holds and a `loadout` slot resolves to.
43
+ * @experimental
44
+ */
45
+ export interface LoadoutRef {
46
+ id: LoadoutId;
47
+ }
48
+ /**
49
+ * A shipped loadout. **Never a pair** — the pair is the one field a person
50
+ * fills. `sampling` names a seeded sampling preset by seed key (the row's id
51
+ * differs per install); `workflow` names a starter workflow the same way.
52
+ * @experimental
53
+ */
54
+ export interface LoadoutDecl {
55
+ /** `<owner>:loadout/<kebab-name>@<major>`. */
56
+ id: string;
57
+ /** The title a person sees (*Extraction*). */
58
+ name: string;
59
+ /** Free prose: what is recommended and why. */
60
+ description: string;
61
+ /** The transform this loadout does — which default an unfilled one falls back to. */
62
+ transform: TransformId;
63
+ /** A seeded sampling preset, by seed key (`sampling-extraction`). */
64
+ sampling?: string;
65
+ tier?: LoadoutTier;
66
+ /** A starter workflow, by seed key — only meaningful on a `text->image` loadout. */
67
+ workflow?: string;
68
+ }
69
+ /**
70
+ * What a step would run best on — the soft twin of `requires`. Grades and
71
+ * suggestions read it; nothing refuses on it. Everything else (schema door,
72
+ * native tools, vision, references) is DERIVED from wiring, so it is not here.
73
+ * @experimental
74
+ * @ruling DESIGN-image-generation §12 suggestion 1
75
+ */
76
+ export interface Prefers {
77
+ /** A seeded sampling preset, by seed key. */
78
+ sampling?: string;
79
+ tier?: LoadoutTier;
80
+ }
81
+ /** Type guard: a well-formed loadout id. @experimental */
82
+ export declare function isLoadoutId(value: unknown): value is LoadoutId;
83
+ /** Split a loadout id, or `null` when it is not one. @experimental */
84
+ export declare function parseLoadoutId(value: unknown): {
85
+ owner: string;
86
+ name: string;
87
+ major: number | null;
88
+ } | null;
89
+ /** Is this a `loadout-ref` value? @experimental */
90
+ export declare function isLoadoutRef(value: unknown): value is LoadoutRef;
91
+ /**
92
+ * Why a shipped loadout declaration would be refused, one sentence each.
93
+ * `owner` is the declaring package (`core` for core's own set).
94
+ * @experimental
95
+ */
96
+ export declare function loadoutDeclProblems(d: LoadoutDecl, owner: string): string[];
97
+ //# sourceMappingURL=loadouts.d.ts.map
@@ -0,0 +1,81 @@
1
+ /**
2
+ * **Loadouts** — the third model layer.
3
+ *
4
+ * A loadout says what an ENGINE is and how it is driven: the pair
5
+ * `(connection, model)`, a sampling config by reference, and — when the pair's
6
+ * drawing sheet takes a template payload — a workflow. It never says what a
7
+ * step MEANS (prompts, parameters, template, settings stay on the node).
8
+ *
9
+ * A package ships a loadout as a **declaration** — never a pair (plugins never
10
+ * see connections: the pair is the one blank a person fills). At boot the instance turns it into a row
11
+ * with an empty pair: **unfilled**. A node names one on its oracle's `loadout`
12
+ * slot, and the host resolves per value:
13
+ *
14
+ * node's explicit slot → its loadout (following merges to the root) →
15
+ * if that loadout is unfilled, the transform's default loadout.
16
+ *
17
+ * ```ts
18
+ * .preset('default', { label: 'Default', default: true }, (p) =>
19
+ * p.loadout('summarize', slot.loadout('core:loadout/extraction@1')))
20
+ * ```
21
+ * @experimental
22
+ * @ruling DESIGN-image-generation §13 (2026-10-12)
23
+ */
24
+ /**
25
+ * The grammar, one kind segment over from a template id:
26
+ * `core:loadout/extraction@1` · `acme.rp:loadout/extract@1`.
27
+ * A person's own loadout reads `pub:loadout/<slug>` and carries no major.
28
+ * @experimental
29
+ */
30
+ export const LOADOUT_ID = /^[a-z0-9]+(?:[.-][a-z0-9]+)*:loadout\/[a-z0-9]+(?:-[a-z0-9]+)*(?:@\d+)?$/;
31
+ /** @experimental */
32
+ export const LOADOUT_TIERS = ['fast', 'cheap', 'best'];
33
+ /** Type guard: a well-formed loadout id. @experimental */
34
+ export function isLoadoutId(value) {
35
+ return typeof value === 'string' && LOADOUT_ID.test(value);
36
+ }
37
+ /** Split a loadout id, or `null` when it is not one. @experimental */
38
+ export function parseLoadoutId(value) {
39
+ if (!isLoadoutId(value))
40
+ return null;
41
+ const [owner, rest] = value.split(':');
42
+ const [name, major] = rest.slice('loadout/'.length).split('@');
43
+ return { owner, name, major: major === undefined ? null : Number(major) };
44
+ }
45
+ /** Is this a `loadout-ref` value? @experimental */
46
+ export function isLoadoutRef(value) {
47
+ return (typeof value === 'object' &&
48
+ value !== null &&
49
+ isLoadoutId(value.id));
50
+ }
51
+ /**
52
+ * Why a shipped loadout declaration would be refused, one sentence each.
53
+ * `owner` is the declaring package (`core` for core's own set).
54
+ * @experimental
55
+ */
56
+ export function loadoutDeclProblems(d, owner) {
57
+ const problems = [];
58
+ const parts = parseLoadoutId(d.id);
59
+ if (!parts || parts.major === null) {
60
+ problems.push(`loadout id '${d.id}' is not a loadout id — it must read ` +
61
+ `'${owner}:loadout/<kebab-name>@<major>' (e.g. '${owner}:loadout/extract@1').`);
62
+ }
63
+ else if (parts.owner !== owner) {
64
+ problems.push(parts.owner === 'core' || parts.owner === 'pub'
65
+ ? `loadout '${d.id}' claims the '${parts.owner}' namespace, which is reserved. ` +
66
+ `Name it '${owner}:loadout/${parts.name}@${parts.major}'.`
67
+ : `loadout '${d.id}' sits under namespace '${parts.owner}', not '${owner}'.`);
68
+ }
69
+ if (typeof d.name !== 'string' || !d.name.trim())
70
+ problems.push(`loadout '${d.id}' has no name — the name is the title a person picks it by.`);
71
+ if (typeof d.description !== 'string')
72
+ problems.push(`loadout '${d.id}' has no description — say what is recommended and why.`);
73
+ if (typeof d.transform !== 'string' || !d.transform.includes('->'))
74
+ problems.push(`loadout '${d.id}' names no transform — an unfilled loadout falls back to its transform's default.`);
75
+ if (d.tier !== undefined && !LOADOUT_TIERS.includes(d.tier))
76
+ problems.push(`loadout '${d.id}' tier '${String(d.tier)}' is not one of ${LOADOUT_TIERS.join(', ')}.`);
77
+ if ('connection' in d || 'model' in d)
78
+ problems.push(`loadout '${d.id}' carries a pair — a shipped loadout never does; the pair is the field a person fills.`);
79
+ return problems;
80
+ }
81
+ //# sourceMappingURL=loadouts.js.map
package/dist/media.d.ts CHANGED
@@ -10,7 +10,7 @@
10
10
  * — the combinatorial growth this SDK avoids everywhere else by declaring data
11
11
  * rather than switching on it. The contracts file opens by noting that the LLM,
12
12
  * TTS and image-gen providers are structurally identical precisely *because*
13
- * nothing switches on modality (17 §1); sibling media shapes would undo that.
13
+ * nothing switches on modality; sibling media shapes would undo that.
14
14
  *
15
15
  * ## Why not simply "file", either
16
16
  *
@@ -24,6 +24,7 @@
24
24
  * accept stays specific (a real check). This is the same split the app's own
25
25
  * `files` table already makes — a coarse `kind` derived from the mime and
26
26
  * stored, so "every document" is an index scan rather than a string parse.
27
+ * @ruling 17 §1
27
28
  */
28
29
  /**
29
30
  * The coarse classification, matching the app's `files.kind` exactly so a blob
@@ -83,7 +84,26 @@ export interface MediaRef {
83
84
  text?: string;
84
85
  }
85
86
  /**
86
- * 🚧 One file attached to one history message (PLAN-composer-attachments §3.5)
87
+ * 🚧 One picture an image step is asked for — an entry of
88
+ * `core:shape/image-series@1`, the `series` in-port of
89
+ * `core:oracle/generate-image@1`.
90
+ *
91
+ * `key` names the picture on the way out: every media item the step returns
92
+ * for this entry carries it, so a consumer (a sprite set's label, a
93
+ * candidate's slot) never has to guess which picture is which from its
94
+ * order or its pixels. Keys are sanitised by the host before rendering
95
+ * (trimmed, case-folded, spaces to `-`, collisions suffixed). `vars` are in
96
+ * scope when the prompt rows render for this entry — the phrase a template
97
+ * reads comes from here, never from the key.
98
+ * @experimental
99
+ * @ruling DESIGN-image-generation §4.7, §4.11
100
+ */
101
+ export interface ImageSeriesItemV1 {
102
+ key: string;
103
+ vars?: Record<string, unknown>;
104
+ }
105
+ /**
106
+ * 🚧 One file attached to one history message
87
107
  * — an entry of `core:shape/media-by-message@1`, which
88
108
  * `core:query/history-attachments@1` publishes keyed by message id.
89
109
  *
@@ -93,6 +113,7 @@ export interface MediaRef {
93
113
  * a text file, its **body**, because a text file reaches every model as text
94
114
  * and a pure placement step cannot read a disk.
95
115
  * @experimental
116
+ * @ruling PLAN-composer-attachments §3.5
96
117
  */
97
118
  export interface HistoryAttachmentV1 extends MediaRef {
98
119
  /** `image` / `text` / `pdf`, decided from the stored mime; `null` for any
@@ -104,12 +125,13 @@ export interface HistoryAttachmentV1 extends MediaRef {
104
125
  bodyTruncated?: boolean;
105
126
  }
106
127
  /**
107
- * 🚧 What the pair behind a connection slot reads (PLAN-composer-attachments
108
- * §5.2) — `metadata.reads` on a resolved connection descriptor, computed by the
128
+ * 🚧 What the pair behind a connection slot reads —
129
+ * `metadata.reads` on a resolved connection descriptor, computed by the
109
130
  * host's ONE reading predicate (the same answer the composer's readers line
110
131
  * shows). A placement step reads it the way `assemble` reads
111
132
  * `metadata.promptFormat`, so it stays pure.
112
133
  * @experimental
134
+ * @ruling PLAN-composer-attachments §5.2
113
135
  */
114
136
  export interface ConnectionReadsV1 {
115
137
  /** The pair sends images to its model on its wire mode. */
package/dist/media.js CHANGED
@@ -10,7 +10,7 @@
10
10
  * — the combinatorial growth this SDK avoids everywhere else by declaring data
11
11
  * rather than switching on it. The contracts file opens by noting that the LLM,
12
12
  * TTS and image-gen providers are structurally identical precisely *because*
13
- * nothing switches on modality (17 §1); sibling media shapes would undo that.
13
+ * nothing switches on modality; sibling media shapes would undo that.
14
14
  *
15
15
  * ## Why not simply "file", either
16
16
  *
@@ -24,6 +24,7 @@
24
24
  * accept stays specific (a real check). This is the same split the app's own
25
25
  * `files` table already makes — a coarse `kind` derived from the mime and
26
26
  * stored, so "every document" is an index scan rather than a string parse.
27
+ * @ruling 17 §1
27
28
  */
28
29
  /**
29
30
  * The coarse classification, matching the app's `files.kind` exactly so a blob