@serene-pub/sdk 0.6.0-pr-4 โ†’ 0.6.0-pr-6

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 (230) hide show
  1. package/README.md +23 -19
  2. package/dist/actions.d.ts +178 -69
  3. package/dist/actions.js +109 -40
  4. package/dist/annexFields.d.ts +12 -5
  5. package/dist/annexFields.js +6 -2
  6. package/dist/announce.d.ts +220 -30
  7. package/dist/announce.js +212 -7
  8. package/dist/attributes.d.ts +290 -11
  9. package/dist/attributes.js +317 -32
  10. package/dist/bands.d.ts +41 -6
  11. package/dist/bands.js +83 -33
  12. package/dist/bridges.d.ts +61 -0
  13. package/dist/bridges.js +112 -0
  14. package/dist/builder.d.ts +436 -106
  15. package/dist/builder.js +389 -46
  16. package/dist/cadences.d.ts +578 -0
  17. package/dist/cadences.js +1111 -0
  18. package/dist/candidates.d.ts +5 -3
  19. package/dist/candidates.js +3 -2
  20. package/dist/capabilities.d.ts +93 -15
  21. package/dist/capabilities.js +57 -6
  22. package/dist/checkMethods.d.ts +240 -0
  23. package/dist/checkMethods.js +362 -0
  24. package/dist/clauses.d.ts +2 -1
  25. package/dist/clauses.js +2 -1
  26. package/dist/component.d.ts +24 -7
  27. package/dist/component.js +16 -6
  28. package/dist/componentBuild.d.ts +16 -5
  29. package/dist/componentBuild.js +14 -5
  30. package/dist/componentClient.d.ts +61 -30
  31. package/dist/componentClient.js +11 -1
  32. package/dist/componentImports.d.ts +8 -5
  33. package/dist/componentImports.js +23 -4
  34. package/dist/componentModule.js +2 -1
  35. package/dist/componentWire.d.ts +2 -1
  36. package/dist/componentWire.js +34 -2
  37. package/dist/composerStates.d.ts +96 -0
  38. package/dist/composerStates.js +190 -0
  39. package/dist/conditions.d.ts +424 -0
  40. package/dist/conditions.js +521 -0
  41. package/dist/config.d.ts +69 -19
  42. package/dist/config.js +64 -26
  43. package/dist/connections.d.ts +9 -4
  44. package/dist/connections.js +7 -4
  45. package/dist/conversions.d.ts +41 -0
  46. package/dist/conversions.js +50 -0
  47. package/dist/declarations.d.ts +70 -18
  48. package/dist/declarations.js +194 -24
  49. package/dist/descriptors.d.ts +427 -100
  50. package/dist/descriptors.js +344 -59
  51. package/dist/dev.d.ts +6 -5
  52. package/dist/dev.js +6 -5
  53. package/dist/document.d.ts +121 -27
  54. package/dist/document.js +77 -24
  55. package/dist/dowry.d.ts +241 -0
  56. package/dist/dowry.js +315 -0
  57. package/dist/engines.d.ts +16 -7
  58. package/dist/engines.js +6 -4
  59. package/dist/entities.d.ts +156 -0
  60. package/dist/entities.js +259 -0
  61. package/dist/eventMapLaws.d.ts +19 -8
  62. package/dist/eventMapLaws.js +9 -6
  63. package/dist/events.d.ts +648 -40
  64. package/dist/events.js +451 -34
  65. package/dist/executor.d.ts +123 -41
  66. package/dist/executor.js +210 -103
  67. package/dist/exposure.d.ts +128 -0
  68. package/dist/exposure.js +168 -0
  69. package/dist/extension.d.ts +99 -35
  70. package/dist/extension.js +43 -9
  71. package/dist/facets.d.ts +2 -1
  72. package/dist/facets.js +4 -2
  73. package/dist/fit.d.ts +198 -0
  74. package/dist/fit.js +351 -0
  75. package/dist/foldedSections.d.ts +4 -2
  76. package/dist/foldedSections.js +2 -1
  77. package/dist/functions.d.ts +554 -0
  78. package/dist/functions.js +712 -0
  79. package/dist/genres.d.ts +408 -130
  80. package/dist/genres.js +412 -108
  81. package/dist/guardedConnection.d.ts +4 -3
  82. package/dist/guardedConnection.js +4 -3
  83. package/dist/handlebarsReach.d.ts +1 -1
  84. package/dist/handlebarsReach.js +1 -1
  85. package/dist/hash.d.ts +16 -5
  86. package/dist/hash.js +14 -4
  87. package/dist/hookGrants.d.ts +4 -3
  88. package/dist/hookGrants.js +7 -5
  89. package/dist/hooks.d.ts +42 -21
  90. package/dist/hooks.js +17 -12
  91. package/dist/hostElements.d.ts +47 -17
  92. package/dist/hostElements.js +62 -17
  93. package/dist/hostState.d.ts +110 -0
  94. package/dist/hostState.js +140 -0
  95. package/dist/i18n.d.ts +5 -3
  96. package/dist/i18n.js +5 -3
  97. package/dist/identity.d.ts +5 -4
  98. package/dist/identity.js +5 -4
  99. package/dist/index.d.ts +26 -0
  100. package/dist/index.js +55 -0
  101. package/dist/jsonSchema.d.ts +178 -0
  102. package/dist/jsonSchema.js +558 -0
  103. package/dist/layout.d.ts +36 -15
  104. package/dist/layout.js +2 -2
  105. package/dist/loadouts.d.ts +97 -0
  106. package/dist/loadouts.js +81 -0
  107. package/dist/media.d.ts +153 -16
  108. package/dist/media.js +47 -2
  109. package/dist/messageBlocks.d.ts +223 -37
  110. package/dist/messageBlocks.js +231 -24
  111. package/dist/migration.d.ts +16 -8
  112. package/dist/migration.js +14 -8
  113. package/dist/names.d.ts +2 -1
  114. package/dist/names.js +2 -1
  115. package/dist/nodeInput.d.ts +2 -1
  116. package/dist/nodeInput.js +2 -1
  117. package/dist/participants.d.ts +54 -24
  118. package/dist/participants.js +27 -14
  119. package/dist/personGate.d.ts +2 -1
  120. package/dist/personGate.js +2 -1
  121. package/dist/pluginHarness.d.ts +22 -35
  122. package/dist/pluginHarness.js +18 -143
  123. package/dist/pluginPermissions.d.ts +2 -1
  124. package/dist/pluginPermissions.js +13 -2
  125. package/dist/pluginRuleRef.d.ts +2 -2
  126. package/dist/pluginRuleRef.js +1 -1
  127. package/dist/predicates.d.ts +16 -11
  128. package/dist/predicates.js +7 -6
  129. package/dist/preview.d.ts +53 -7
  130. package/dist/preview.js +54 -13
  131. package/dist/primers.d.ts +177 -0
  132. package/dist/primers.js +265 -0
  133. package/dist/promptBlocks.d.ts +5 -3
  134. package/dist/promptBlocks.js +5 -3
  135. package/dist/rankingDecisions.d.ts +2 -1
  136. package/dist/rankingDecisions.js +2 -1
  137. package/dist/receipt.d.ts +76 -29
  138. package/dist/receipt.js +9 -4
  139. package/dist/receiverRules.js +3 -2
  140. package/dist/refs.d.ts +42 -9
  141. package/dist/refs.js +45 -13
  142. package/dist/registrations.d.ts +384 -0
  143. package/dist/registrations.js +625 -0
  144. package/dist/registry.d.ts +42 -23
  145. package/dist/registry.js +7 -5
  146. package/dist/repertoires.d.ts +502 -0
  147. package/dist/repertoires.js +666 -0
  148. package/dist/review.d.ts +16 -5
  149. package/dist/review.js +11 -4
  150. package/dist/rulesetDocument.d.ts +95 -0
  151. package/dist/rulesetDocument.js +190 -0
  152. package/dist/rulesetSections.d.ts +597 -0
  153. package/dist/rulesetSections.js +1249 -0
  154. package/dist/rulesetTemplates.d.ts +161 -0
  155. package/dist/rulesetTemplates.js +242 -0
  156. package/dist/rulesets.d.ts +899 -0
  157. package/dist/rulesets.js +1378 -0
  158. package/dist/sampling.d.ts +54 -0
  159. package/dist/sampling.js +95 -3
  160. package/dist/sceneSettings.d.ts +320 -0
  161. package/dist/sceneSettings.js +433 -0
  162. package/dist/scope.d.ts +50 -7
  163. package/dist/scope.js +22 -3
  164. package/dist/scripts.d.ts +112 -22
  165. package/dist/scripts.js +135 -19
  166. package/dist/sessionDossier.d.ts +638 -0
  167. package/dist/sessionDossier.js +33 -0
  168. package/dist/sessionLayout.d.ts +492 -55
  169. package/dist/sessionLayout.js +697 -90
  170. package/dist/sessionSettings.d.ts +32 -5
  171. package/dist/settings.d.ts +66 -20
  172. package/dist/settings.js +19 -12
  173. package/dist/settingsSlot.d.ts +11 -8
  174. package/dist/settingsSlot.js +11 -8
  175. package/dist/shapes.d.ts +139 -37
  176. package/dist/shapes.js +152 -38
  177. package/dist/sheets.d.ts +4 -2
  178. package/dist/sheets.js +6 -3
  179. package/dist/statShapes.d.ts +10 -2
  180. package/dist/statShapes.js +10 -2
  181. package/dist/status.d.ts +27 -9
  182. package/dist/status.js +20 -6
  183. package/dist/storage.d.ts +11 -67
  184. package/dist/storage.js +9 -13
  185. package/dist/storyTime.d.ts +13 -7
  186. package/dist/storyTime.js +11 -6
  187. package/dist/strokes.d.ts +176 -0
  188. package/dist/strokes.js +281 -0
  189. package/dist/surfaces.d.ts +54 -25
  190. package/dist/surfaces.js +3 -3
  191. package/dist/template.d.ts +9 -5
  192. package/dist/template.js +5 -3
  193. package/dist/templateCheck.d.ts +2 -2
  194. package/dist/templateCheck.js +2 -2
  195. package/dist/templateFit.d.ts +37 -8
  196. package/dist/templateFit.js +92 -8
  197. package/dist/templateIds.d.ts +3 -3
  198. package/dist/templateIds.js +3 -3
  199. package/dist/templateScopeAt.d.ts +22 -12
  200. package/dist/templateScopeAt.js +32 -19
  201. package/dist/testing.d.ts +11 -4
  202. package/dist/testing.js +13 -5
  203. package/dist/ties.d.ts +210 -0
  204. package/dist/ties.js +300 -0
  205. package/dist/tokenizers.d.ts +2 -2
  206. package/dist/tokenizers.js +2 -2
  207. package/dist/turnLock.d.ts +4 -2
  208. package/dist/turnLock.js +2 -1
  209. package/dist/turnOrder.d.ts +39 -22
  210. package/dist/turnOrder.js +30 -13
  211. package/dist/validate.d.ts +11 -8
  212. package/dist/validate.js +195 -29
  213. package/dist/values.d.ts +17 -8
  214. package/dist/values.js +11 -6
  215. package/dist/variables.d.ts +46 -7
  216. package/dist/variables.js +87 -6
  217. package/dist/verdicts.d.ts +20 -13
  218. package/dist/verdicts.js +17 -11
  219. package/dist/vocabularies.d.ts +192 -0
  220. package/dist/vocabularies.js +326 -0
  221. package/dist/widgetDecls.d.ts +20 -4
  222. package/dist/widgetDecls.js +6 -2
  223. package/dist/widgets.d.ts +1580 -111
  224. package/dist/widgets.js +113 -18
  225. package/dist/wire.d.ts +13 -6
  226. package/dist/wire.js +3 -3
  227. package/dist/worldinfo.d.ts +11 -6
  228. package/dist/worldinfo.js +8 -4
  229. package/host-elements.d.ts +101 -0
  230. package/package.json +1 -1
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
@@ -35,10 +36,28 @@
35
36
  * @experimental
36
37
  */
37
38
  export declare const MEDIA_KINDS: readonly ['image', 'audio', 'video', 'document'];
38
- /** @experimental */
39
- export type MediaKind = (typeof MEDIA_KINDS)[number];
40
- /** @experimental */
41
- export declare const isMediaKind: (v: unknown) => v is MediaKind;
39
+ /**
40
+ * ๐Ÿšง A media kind core knows by name โ€” one of `MEDIA_KINDS`, the KNOWN list.
41
+ * @experimental
42
+ * @ruling O1, LS4, R41
43
+ */
44
+ export type KnownMediaKind = (typeof MEDIA_KINDS)[number];
45
+ /**
46
+ * A media kind: one core knows (`MEDIA_KINDS`), or any other a plugin or a
47
+ * later release introduces (O1, LS4 โ€” owner, 2026-10-20: "nothing in 1.0 may
48
+ * assume the list of media kinds is closed"). Autocomplete still offers the
49
+ * known ones; an unknown kind passes through every SDK table untouched, and
50
+ * a table keyed by kind falls back where it has no row for one.
51
+ * @experimental
52
+ * @ruling O1, LS4, R41
53
+ */
54
+ export type MediaKind = KnownMediaKind | (string & {});
55
+ /**
56
+ * Is this a media kind core KNOWS โ€” one of `MEDIA_KINDS`? Still "known", not
57
+ * "well-formed": an unknown kind is a valid `MediaKind` and answers false here.
58
+ * @experimental
59
+ */
60
+ export declare const isMediaKind: (v: unknown) => v is KnownMediaKind;
42
61
  /**
43
62
  * A reference to stored media, as it travels on a port.
44
63
  *
@@ -83,7 +102,26 @@ export interface MediaRef {
83
102
  text?: string;
84
103
  }
85
104
  /**
86
- * ๐Ÿšง One file attached to one history message (PLAN-composer-attachments ยง3.5)
105
+ * ๐Ÿšง One picture an image step is asked for โ€” an entry of
106
+ * `core:shape/image-series@1`, the `series` in-port of
107
+ * `core:oracle/generate-image@1`.
108
+ *
109
+ * `key` names the picture on the way out: every media item the step returns
110
+ * for this entry carries it, so a consumer (a sprite set's label, a
111
+ * candidate's slot) never has to guess which picture is which from its
112
+ * order or its pixels. Keys are sanitised by the host before rendering
113
+ * (trimmed, case-folded, spaces to `-`, collisions suffixed). `vars` are in
114
+ * scope when the prompt rows render for this entry โ€” the phrase a template
115
+ * reads comes from here, never from the key.
116
+ * @experimental
117
+ * @ruling DESIGN-image-generation ยง4.7, ยง4.11
118
+ */
119
+ export interface ImageSeriesItemV1 {
120
+ key: string;
121
+ vars?: Record<string, unknown>;
122
+ }
123
+ /**
124
+ * ๐Ÿšง One file attached to one history message
87
125
  * โ€” an entry of `core:shape/media-by-message@1`, which
88
126
  * `core:query/history-attachments@1` publishes keyed by message id.
89
127
  *
@@ -93,37 +131,116 @@ export interface MediaRef {
93
131
  * a text file, its **body**, because a text file reaches every model as text
94
132
  * and a pure placement step cannot read a disk.
95
133
  * @experimental
134
+ * @ruling PLAN-composer-attachments ยง3.5
96
135
  */
97
136
  export interface HistoryAttachmentV1 extends MediaRef {
98
- /** `image` / `text` / `pdf`, decided from the stored mime; `null` for any
99
- * other file, which every call is shown as a name. */
100
- attachmentKind: 'image' | 'text' | 'pdf' | null;
137
+ /** `image` / `text` / `pdf` / `audio` / `video`, decided from the stored
138
+ * mime; `null` for any other file, which every call is shown as a name.
139
+ * `audio` and `video` since O2/O4 (2026-10-21). */
140
+ attachmentKind: 'image' | 'text' | 'pdf' | 'audio' | 'video' | null;
141
+ /**
142
+ * ๐Ÿšง What an audio (or video) file says, when a transcription step has
143
+ * heard it โ€” cached on the file, so it is heard once (O9). Placement
144
+ * writes it into the name a call that cannot hear the file is shown:
145
+ * `[audio: note.mp3 โ€” "โ€ฆ"]`. `text` carries the same words when the
146
+ * person gave no description of their own.
147
+ * @ruling O9
148
+ */
149
+ transcript?: string;
101
150
  /** A text file's body, read up to the query's cap. Absent for other files. */
102
151
  body?: string;
103
152
  /** True when `body` stopped at the query's cap rather than at the file's end. */
104
153
  bodyTruncated?: boolean;
105
154
  }
106
155
  /**
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
156
+ * ๐Ÿšง What the pair behind a connection slot reads โ€”
157
+ * `metadata.reads` on a resolved connection descriptor, computed by the
109
158
  * host's ONE reading predicate (the same answer the composer's readers line
110
159
  * shows). A placement step reads it the way `assemble` reads
111
160
  * `metadata.promptFormat`, so it stays pure.
112
161
  * @experimental
162
+ * @ruling PLAN-composer-attachments ยง5.2
113
163
  */
114
164
  export interface ConnectionReadsV1 {
115
- /** The pair sends images to its model on its wire mode. */
165
+ /**
166
+ * ๐Ÿšง What the pair reads, **by media kind** (O2, evolved in place
167
+ * 2026-10-20): for each kind the host has an answer for, whether the pair
168
+ * sends it to its model on its wire mode, why not (a sentence that names
169
+ * no connection), and what one placed item is estimated to cost. A kind
170
+ * with no row is not read โ€” `connectionReadsKind` answers that for you.
171
+ * Open by kind (O1): audio, video, and kinds a later release brings.
172
+ * @ruling O2, O1, O10
173
+ */
174
+ kinds: Partial<Record<MediaKind, ConnectionKindReadV1>>;
175
+ /**
176
+ * The pair sends images to its model on its wire mode.
177
+ * @deprecated โณ Read `kinds.image.reads` (O2). Kept readable for one release; hosts still write it.
178
+ */
116
179
  image: boolean;
117
- /** The pair sends PDFs to its model on its wire mode. */
180
+ /**
181
+ * The pair sends PDFs to its model on its wire mode.
182
+ * @deprecated โณ Read `kinds.document.reads` (O2). Kept readable for one release; hosts still write it.
183
+ */
118
184
  pdf: boolean;
119
- /** Why not, per kind โ€” a sentence that names no connection. */
185
+ /**
186
+ * Why not, per kind โ€” a sentence that names no connection.
187
+ * @deprecated โณ Read `kinds.<kind>.why` (O2). Kept readable for one release.
188
+ */
120
189
  why?: {
121
190
  image?: string;
122
191
  pdf?: string;
123
192
  };
124
- /** Estimated prompt tokens one placed image costs. An estimate, never a cap. */
193
+ /**
194
+ * Estimated prompt tokens one placed image costs. An estimate, never a cap.
195
+ * @deprecated โณ Read `kinds.image.cost.perItem` (O2, O10). Kept readable for one release.
196
+ */
125
197
  tokensPerImage?: number;
126
198
  }
199
+ /**
200
+ * ๐Ÿšง What a pair reads of one media kind โ€” a row of `ConnectionReadsV1.kinds`.
201
+ * @experimental
202
+ * @ruling O2, O10
203
+ */
204
+ export interface ConnectionKindReadV1 {
205
+ /** The pair sends this kind to its model on its wire mode. */
206
+ reads: boolean;
207
+ /** Why not โ€” a sentence that names no connection. Absent when it reads. */
208
+ why?: string;
209
+ /**
210
+ * Estimated prompt tokens one placed item costs: `perItem` for a picture
211
+ * or a page, `perSecond` for audio or video. An estimate, never a cap.
212
+ */
213
+ cost?: {
214
+ perItem?: number;
215
+ perSecond?: number;
216
+ };
217
+ /**
218
+ * ๐Ÿšง The pair also takes this kind back on the MODEL's own turns โ€” a
219
+ * spoken reply sent back as audio rather than as its transcript (O13).
220
+ * Absent: only on a person's turns, and a model's earlier audio goes
221
+ * back as the words it said.
222
+ * @ruling O13
223
+ */
224
+ assistantTurns?: boolean;
225
+ /**
226
+ * ๐Ÿšง The formats the pair takes of this kind, when it names them and
227
+ * nothing converts to them โ€” audio and video today (O4). A file of
228
+ * another format is not sent: placement names it, and a transcribe step
229
+ * hears it instead. Absent: every format of a read kind is sent.
230
+ * @ruling O4
231
+ */
232
+ accepts?: string[];
233
+ }
234
+ /**
235
+ * ๐Ÿšง The one reading of `ConnectionReadsV1` per kind (O2): the `kinds` row
236
+ * when there is one; else, for a value written before `kinds` existed, the
237
+ * deprecated `image` / `pdf` booleans (a PDF is the `document` kind); else
238
+ * not read. Placement, the composer line and fit ask this โ€” never the
239
+ * fields directly โ€” so the deprecated ones can leave without a hunt.
240
+ * @experimental
241
+ * @ruling O2
242
+ */
243
+ export declare function connectionReadsKind(reads: Partial<ConnectionReadsV1> | null | undefined, kind: MediaKind): ConnectionKindReadV1;
127
244
  /**
128
245
  * What a node, provider or connection will handle.
129
246
  *
@@ -137,7 +254,7 @@ export interface ConnectionReadsV1 {
137
254
  export interface MediaCapability {
138
255
  /** Kinds this can take as input. Absent or empty: text only. */
139
256
  accepts?: readonly MediaKind[];
140
- /** Kinds this can produce. Absent or empty: text only. */
257
+ /** Kinds this can produce. Absent or empty: text only. Open by kind (O1). */
141
258
  emits?: readonly MediaKind[];
142
259
  /** Mime allow-list, when a kind is too coarse โ€” e.g. a model that reads
143
260
  * `image/png` and `image/jpeg` but not `image/gif`. Absent means every
@@ -199,4 +316,24 @@ export type OutputPart = {
199
316
  export declare function partsToText(parts: readonly OutputPart[]): string;
200
317
  /** Every media reference in a part list, in order. @experimental */
201
318
  export declare function partsToMedia(parts: readonly OutputPart[]): MediaRef[];
319
+ /**
320
+ * ๐Ÿšง The message part types that show one stored file, by media kind (O5):
321
+ * a picture is `core:image`, a sound `core:audio`, a moving picture
322
+ * `core:video`, and every other kind โ€” a PDF, a text file, a kind a later
323
+ * release brings โ€” `core:file`. Every part carries `data.assetId`.
324
+ * @experimental
325
+ * @ruling O5
326
+ */
327
+ export declare const MEDIA_PART_TYPES: readonly ['core:image', 'core:audio', 'core:video', 'core:file'];
328
+ /** @experimental */
329
+ export type MediaPartType = (typeof MEDIA_PART_TYPES)[number];
330
+ /**
331
+ * ๐Ÿšง The part type a file of this kind is shown with โ€” unknown kinds are
332
+ * `core:file` (O1: a kind passes through, it is never refused here).
333
+ * @experimental
334
+ * @ruling O5
335
+ */
336
+ export declare function mediaPartTypeFor(kind: MediaKind | null | undefined): MediaPartType;
337
+ /** ๐Ÿšง Is this a part type that shows one stored file? @experimental */
338
+ export declare const isMediaPartType: (type: unknown) => type is MediaPartType;
202
339
  //# sourceMappingURL=media.d.ts.map
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
@@ -35,8 +36,32 @@
35
36
  * @experimental
36
37
  */
37
38
  export const MEDIA_KINDS = ['image', 'audio', 'video', 'document'];
38
- /** @experimental */
39
+ /**
40
+ * Is this a media kind core KNOWS โ€” one of `MEDIA_KINDS`? Still "known", not
41
+ * "well-formed": an unknown kind is a valid `MediaKind` and answers false here.
42
+ * @experimental
43
+ */
39
44
  export const isMediaKind = (v) => typeof v === 'string' && MEDIA_KINDS.includes(v);
45
+ /**
46
+ * ๐Ÿšง The one reading of `ConnectionReadsV1` per kind (O2): the `kinds` row
47
+ * when there is one; else, for a value written before `kinds` existed, the
48
+ * deprecated `image` / `pdf` booleans (a PDF is the `document` kind); else
49
+ * not read. Placement, the composer line and fit ask this โ€” never the
50
+ * fields directly โ€” so the deprecated ones can leave without a hunt.
51
+ * @experimental
52
+ * @ruling O2
53
+ */
54
+ export function connectionReadsKind(reads, kind) {
55
+ const row = reads?.kinds?.[kind];
56
+ if (row)
57
+ return row;
58
+ const legacy = kind === 'image' ? reads?.image : kind === 'document' ? reads?.pdf : undefined;
59
+ if (legacy === undefined)
60
+ return { reads: false };
61
+ const why = kind === 'image' ? reads?.why?.image : reads?.why?.pdf;
62
+ const cost = kind === 'image' && reads?.tokensPerImage !== undefined ? { cost: { perItem: reads.tokensPerImage } } : {};
63
+ return { reads: legacy === true, ...(why && legacy !== true ? { why } : {}), ...cost };
64
+ }
40
65
  /** Does `cap` accept this reference? The check a picker and a wire adapter
41
66
  * both need, written once so they cannot disagree.
42
67
  * @experimental
@@ -67,4 +92,24 @@ export function partsToMedia(parts) {
67
92
  .filter((p) => p.t === 'media')
68
93
  .map((p) => p.ref);
69
94
  }
95
+ /**
96
+ * ๐Ÿšง The message part types that show one stored file, by media kind (O5):
97
+ * a picture is `core:image`, a sound `core:audio`, a moving picture
98
+ * `core:video`, and every other kind โ€” a PDF, a text file, a kind a later
99
+ * release brings โ€” `core:file`. Every part carries `data.assetId`.
100
+ * @experimental
101
+ * @ruling O5
102
+ */
103
+ export const MEDIA_PART_TYPES = ['core:image', 'core:audio', 'core:video', 'core:file'];
104
+ /**
105
+ * ๐Ÿšง The part type a file of this kind is shown with โ€” unknown kinds are
106
+ * `core:file` (O1: a kind passes through, it is never refused here).
107
+ * @experimental
108
+ * @ruling O5
109
+ */
110
+ export function mediaPartTypeFor(kind) {
111
+ return kind === 'image' ? 'core:image' : kind === 'audio' ? 'core:audio' : kind === 'video' ? 'core:video' : 'core:file';
112
+ }
113
+ /** ๐Ÿšง Is this a part type that shows one stored file? @experimental */
114
+ export const isMediaPartType = (type) => typeof type === 'string' && MEDIA_PART_TYPES.includes(type);
70
115
  //# sourceMappingURL=media.js.map