@serene-pub/sdk 0.6.0-pr-1

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 (187) hide show
  1. package/LICENSE +202 -0
  2. package/NOTICE +17 -0
  3. package/README.md +368 -0
  4. package/dist/actions.d.ts +572 -0
  5. package/dist/actions.js +829 -0
  6. package/dist/annexFields.d.ts +234 -0
  7. package/dist/annexFields.js +413 -0
  8. package/dist/announce.d.ts +464 -0
  9. package/dist/announce.js +426 -0
  10. package/dist/attributes.d.ts +670 -0
  11. package/dist/attributes.js +904 -0
  12. package/dist/bands.d.ts +125 -0
  13. package/dist/bands.js +256 -0
  14. package/dist/builder.d.ts +683 -0
  15. package/dist/builder.js +677 -0
  16. package/dist/candidates.d.ts +109 -0
  17. package/dist/candidates.js +118 -0
  18. package/dist/capabilities.d.ts +744 -0
  19. package/dist/capabilities.js +679 -0
  20. package/dist/channels.d.ts +106 -0
  21. package/dist/channels.js +129 -0
  22. package/dist/clauses.d.ts +40 -0
  23. package/dist/clauses.js +43 -0
  24. package/dist/component.d.ts +33 -0
  25. package/dist/component.js +27 -0
  26. package/dist/componentBuild.d.ts +48 -0
  27. package/dist/componentBuild.js +84 -0
  28. package/dist/componentClient.d.ts +100 -0
  29. package/dist/componentClient.js +13 -0
  30. package/dist/componentImports.d.ts +51 -0
  31. package/dist/componentImports.js +106 -0
  32. package/dist/componentModule.d.ts +8 -0
  33. package/dist/componentModule.js +270 -0
  34. package/dist/componentWire.d.ts +130 -0
  35. package/dist/componentWire.js +280 -0
  36. package/dist/config.d.ts +295 -0
  37. package/dist/config.js +231 -0
  38. package/dist/connections.d.ts +89 -0
  39. package/dist/connections.js +131 -0
  40. package/dist/declarations.d.ts +290 -0
  41. package/dist/declarations.js +794 -0
  42. package/dist/descriptors.d.ts +1774 -0
  43. package/dist/descriptors.js +1329 -0
  44. package/dist/dev.d.ts +136 -0
  45. package/dist/dev.js +161 -0
  46. package/dist/document.d.ts +202 -0
  47. package/dist/document.js +312 -0
  48. package/dist/engines.d.ts +117 -0
  49. package/dist/engines.js +203 -0
  50. package/dist/eventMapLaws.d.ts +63 -0
  51. package/dist/eventMapLaws.js +128 -0
  52. package/dist/events.d.ts +554 -0
  53. package/dist/events.js +633 -0
  54. package/dist/executor.d.ts +771 -0
  55. package/dist/executor.js +1829 -0
  56. package/dist/extension.d.ts +448 -0
  57. package/dist/extension.js +315 -0
  58. package/dist/facets.d.ts +53 -0
  59. package/dist/facets.js +60 -0
  60. package/dist/foldedSections.d.ts +74 -0
  61. package/dist/foldedSections.js +161 -0
  62. package/dist/genres.d.ts +507 -0
  63. package/dist/genres.js +633 -0
  64. package/dist/guardedConnection.d.ts +138 -0
  65. package/dist/guardedConnection.js +341 -0
  66. package/dist/handlebarsReach.d.ts +122 -0
  67. package/dist/handlebarsReach.js +222 -0
  68. package/dist/hash.d.ts +146 -0
  69. package/dist/hash.js +166 -0
  70. package/dist/hookGrants.d.ts +47 -0
  71. package/dist/hookGrants.js +68 -0
  72. package/dist/hooks.d.ts +290 -0
  73. package/dist/hooks.js +113 -0
  74. package/dist/hostElements.d.ts +447 -0
  75. package/dist/hostElements.js +702 -0
  76. package/dist/i18n.d.ts +94 -0
  77. package/dist/i18n.js +123 -0
  78. package/dist/identity.d.ts +93 -0
  79. package/dist/identity.js +135 -0
  80. package/dist/index.d.ts +85 -0
  81. package/dist/index.js +176 -0
  82. package/dist/layout.d.ts +194 -0
  83. package/dist/layout.js +40 -0
  84. package/dist/media.d.ts +202 -0
  85. package/dist/media.js +70 -0
  86. package/dist/messageBlocks.d.ts +487 -0
  87. package/dist/messageBlocks.js +683 -0
  88. package/dist/migration.d.ts +128 -0
  89. package/dist/migration.js +261 -0
  90. package/dist/names.d.ts +78 -0
  91. package/dist/names.js +136 -0
  92. package/dist/nodeInput.d.ts +399 -0
  93. package/dist/nodeInput.js +178 -0
  94. package/dist/participants.d.ts +291 -0
  95. package/dist/participants.js +252 -0
  96. package/dist/personGate.d.ts +62 -0
  97. package/dist/personGate.js +77 -0
  98. package/dist/pick.d.ts +84 -0
  99. package/dist/pick.js +103 -0
  100. package/dist/pluginHarness.d.ts +235 -0
  101. package/dist/pluginHarness.js +558 -0
  102. package/dist/pluginPermissions.d.ts +25 -0
  103. package/dist/pluginPermissions.js +97 -0
  104. package/dist/pluginRuleRef.d.ts +13 -0
  105. package/dist/pluginRuleRef.js +10 -0
  106. package/dist/predicates.d.ts +182 -0
  107. package/dist/predicates.js +249 -0
  108. package/dist/preview.d.ts +120 -0
  109. package/dist/preview.js +82 -0
  110. package/dist/promptBlocks.d.ts +130 -0
  111. package/dist/promptBlocks.js +197 -0
  112. package/dist/rankingDecisions.d.ts +60 -0
  113. package/dist/rankingDecisions.js +48 -0
  114. package/dist/receipt.d.ts +313 -0
  115. package/dist/receipt.js +60 -0
  116. package/dist/receiverRules.d.ts +24 -0
  117. package/dist/receiverRules.js +94 -0
  118. package/dist/refs.d.ts +117 -0
  119. package/dist/refs.js +137 -0
  120. package/dist/registry.d.ts +230 -0
  121. package/dist/registry.js +273 -0
  122. package/dist/review.d.ts +108 -0
  123. package/dist/review.js +97 -0
  124. package/dist/sampling.d.ts +152 -0
  125. package/dist/sampling.js +712 -0
  126. package/dist/scope.d.ts +65 -0
  127. package/dist/scope.js +128 -0
  128. package/dist/scripts.d.ts +243 -0
  129. package/dist/scripts.js +326 -0
  130. package/dist/sessionLayout.d.ts +339 -0
  131. package/dist/sessionLayout.js +503 -0
  132. package/dist/sessionSettings.d.ts +70 -0
  133. package/dist/sessionSettings.js +2 -0
  134. package/dist/settings.d.ts +501 -0
  135. package/dist/settings.js +604 -0
  136. package/dist/settingsSlot.d.ts +108 -0
  137. package/dist/settingsSlot.js +166 -0
  138. package/dist/shapes.d.ts +373 -0
  139. package/dist/shapes.js +408 -0
  140. package/dist/sheets.d.ts +165 -0
  141. package/dist/sheets.js +251 -0
  142. package/dist/statShapes.d.ts +96 -0
  143. package/dist/statShapes.js +112 -0
  144. package/dist/status.d.ts +103 -0
  145. package/dist/status.js +125 -0
  146. package/dist/storage.d.ts +145 -0
  147. package/dist/storage.js +33 -0
  148. package/dist/storyTime.d.ts +308 -0
  149. package/dist/storyTime.js +560 -0
  150. package/dist/surfaces.d.ts +501 -0
  151. package/dist/surfaces.js +292 -0
  152. package/dist/template.d.ts +312 -0
  153. package/dist/template.js +554 -0
  154. package/dist/templateCheck.d.ts +60 -0
  155. package/dist/templateCheck.js +516 -0
  156. package/dist/templateFit.d.ts +157 -0
  157. package/dist/templateFit.js +349 -0
  158. package/dist/templateIds.d.ts +138 -0
  159. package/dist/templateIds.js +144 -0
  160. package/dist/templateScopeAt.d.ts +131 -0
  161. package/dist/templateScopeAt.js +354 -0
  162. package/dist/testing.d.ts +177 -0
  163. package/dist/testing.js +383 -0
  164. package/dist/tokenizers.d.ts +113 -0
  165. package/dist/tokenizers.js +184 -0
  166. package/dist/turnLock.d.ts +96 -0
  167. package/dist/turnLock.js +79 -0
  168. package/dist/turnOrder.d.ts +143 -0
  169. package/dist/turnOrder.js +128 -0
  170. package/dist/validate.d.ts +74 -0
  171. package/dist/validate.js +1399 -0
  172. package/dist/values.d.ts +212 -0
  173. package/dist/values.js +390 -0
  174. package/dist/variables.d.ts +493 -0
  175. package/dist/variables.js +662 -0
  176. package/dist/verdicts.d.ts +275 -0
  177. package/dist/verdicts.js +348 -0
  178. package/dist/widgetDecls.d.ts +88 -0
  179. package/dist/widgetDecls.js +119 -0
  180. package/dist/widgets.d.ts +1527 -0
  181. package/dist/widgets.js +208 -0
  182. package/dist/wire.d.ts +126 -0
  183. package/dist/wire.js +140 -0
  184. package/dist/worldinfo.d.ts +150 -0
  185. package/dist/worldinfo.js +212 -0
  186. package/host-elements.d.ts +914 -0
  187. package/package.json +67 -0
@@ -0,0 +1,501 @@
1
+ /**
2
+ * Plugin settings — the schema an extension declares, and the four things core does
3
+ * with it (12 §6).
4
+ *
5
+ * 12 §6 promises "the same schema strategy as node config and review steps — one
6
+ * renderer, three uses." That promise is only real if it is literally the same
7
+ * declaration, so `FieldDecl` here is the same shape node `params` use, plus the two
8
+ * fields that only mean something for plugin settings (`scope`, `side`). An extension
9
+ * author who has written a node's `params` schema already knows this one.
10
+ *
11
+ * One declaration, four uses:
12
+ *
13
+ * 1. **The form** core renders in plugin settings — no UI work by the author.
14
+ * 2. **Validation** of stored values, on save and on update.
15
+ * 3. **The manifest entry**, extracted statically by the compiler — never by running
16
+ * the author's code (F6, 03 §3).
17
+ * 4. **Typed access** from the extension's own hooks: `settings.values` is inferred,
18
+ * so `apiKey` is a `SecretValue` and a mistyped key does not compile.
19
+ *
20
+ * ## The `secret` field, and why it is typed
21
+ *
22
+ * The ruling that produced this reads backwards at first. "SP declines custody of plugin
23
+ * secrets" sounds safer than storing them — but an extension keeping credentials in its
24
+ * own data directory has no key and no crypto facility, so the realistic outcome is
25
+ * plaintext on the user's disk, unencrypted *and* unauditable. Declining custody produced
26
+ * the worse result (13 §6).
27
+ *
28
+ * What makes accepting it defensible is that the field is **typed**, which is what lets
29
+ * core mechanically redact it from receipts (F16), exclude it from export (12 §7) and
30
+ * keep it write-only in the UI. A free-form column cannot tell a key from a note.
31
+ */
32
+ import type { MediaKind } from './media.js';
33
+ import { type I18nText } from './i18n.js';
34
+ /** @experimental */
35
+ export interface SecretValue {
36
+ readonly $secret: true;
37
+ /** Ciphertext at rest; plaintext exists only inside the owning hook's invocation. */
38
+ readonly value: string;
39
+ }
40
+ /** @experimental */
41
+ export declare const secret: (value: string) => SecretValue;
42
+ /** @internal */
43
+ export declare const isSecret: (v: unknown) => v is SecretValue;
44
+ /**
45
+ * The one field language, for real this time.
46
+ *
47
+ * This file used to claim `FieldDecl` was "the same shape node `params` use,
48
+ * plus `scope` and `side`". It was not: node params (`ParamDecl`) had `share`
49
+ * and `perMember` and no `text`; settings had `text` and neither of the others;
50
+ * one keyed its label `i18n`, the other `label`; and nothing anywhere converted
51
+ * between them. Two languages, one promise, no adapter — so a control that
52
+ * rendered plugin settings could not render node params, and a session mode
53
+ * (whose `fields` are a `SettingsSchema`) could not declare a `share` control
54
+ * that a node beside it could.
55
+ *
56
+ * This type is the merge of both, and `label` is the one display key.
57
+ * @experimental
58
+ */
59
+ export type FieldType = 'string' | 'text' | 'number' | 'integer' | 'boolean' | 'enum' | 'string[]' | 'secret'
60
+ /** Normalised `Record<string, number>` over `members` — ratios only, always
61
+ * totalling 100%, so there is no invalid state to explain. Zero is a
62
+ * member's off switch. */
63
+ | 'share'
64
+ /** A plain number per band over `members` — a ceiling, a minimum, a count. */
65
+ | 'perMember'
66
+ /**
67
+ * An **independent** `0..1` strength per member, drawn as one bar each.
68
+ *
69
+ * Deliberately not a `share` with the normalisation switched off, and the
70
+ * difference is the whole reason it is its own type. A share divides one
71
+ * finite thing between its members, so raising one member necessarily
72
+ * lowers the others and the total is always 100%. A strength answers "how
73
+ * much does this count" one member at a time: every member may be 1 at
74
+ * once, and turning one up takes nothing away from anything.
75
+ *
76
+ * Drawing them alike would teach the reader the wrong arithmetic — which is
77
+ * exactly the confusion this type exists to prevent where the two sit on one
78
+ * screen. `perMember` is the third of the family and the one with no range
79
+ * at all: a count, a ceiling, a floor.
80
+ */
81
+ | 'strengths'
82
+ /**
83
+ * A reference to stored media, by uuid. `accepts` narrows which kinds the
84
+ * picker offers; absent means images, which is what almost every such field
85
+ * wants and what makes the common declaration short.
86
+ */
87
+ | 'media'
88
+ /**
89
+ * An **ordered list** of values, each satisfying one declaration (`item`).
90
+ *
91
+ * Ordered, and that is the whole reason it is not `string[]` with a wider
92
+ * element type: the order *is* part of the value. A chain of scripts, the
93
+ * blocks a prompt is assembled from, a fallback sequence of connections —
94
+ * every one of those is a list somebody reorders, and a control that
95
+ * rendered it as a set would drop the one thing being configured.
96
+ *
97
+ * The element declaration is a `FieldDecl` like any other, so a list of
98
+ * numbers, a list of enums and a list of objects are one type rather than
99
+ * three. Which is what keeps this general: node params, genre fields and
100
+ * widget settings all speak this vocabulary, and none of them had a way to
101
+ * say "several of these, in this order" until now.
102
+ */
103
+ | 'list'
104
+ /**
105
+ * A fixed-key record whose members are themselves declarations (`fields`).
106
+ *
107
+ * Deliberately **fixed-key**: the members are declared, so a form can be
108
+ * rendered from them and a stored value can be checked against them. A
109
+ * free-form map is `text` with `format: 'json'`, which is what that escape
110
+ * hatch is for — and the difference is exactly whether anything can tell a
111
+ * mistyped key from a deliberate one.
112
+ */
113
+ | 'object';
114
+ export type { I18nText } from './i18n.js';
115
+ /** One band of a `share` / `perMember` / `strengths` control, or a labelled `enum` choice. @experimental */
116
+ export interface MemberDecl {
117
+ /** The key inside the parameter's value object. */
118
+ key: string;
119
+ label?: I18nText;
120
+ description?: I18nText;
121
+ /**
122
+ * Which colour this band takes, as an index rather than a value. The
123
+ * declaration says *which* band this is; the client's palette says what
124
+ * that looks like in the current theme. Out-of-range wraps.
125
+ */
126
+ tone?: number;
127
+ }
128
+ /** @experimental */
129
+ export interface FieldDecl<T extends FieldType = FieldType, O extends readonly string[] = readonly string[]> {
130
+ type: T;
131
+ label?: I18nText;
132
+ description?: I18nText;
133
+ default?: unknown;
134
+ /**
135
+ * One of the few settings people actually change on this node.
136
+ *
137
+ * A panel that lists every declared setting equally makes the reader find
138
+ * the prompt among the thresholds every time. The author knows which few
139
+ * are reached for; a client heuristic would be wrong differently on every
140
+ * plugin. Presentation, not permission — nothing is hidden by it.
141
+ */
142
+ quick?: boolean;
143
+ /**
144
+ * Which lens renders this one field (05 §3), when it is not the slot's.
145
+ *
146
+ * A slot carries a `facet` and every field of it lands there — which is
147
+ * right for a `params` slot of tunables and wrong for the substrate's
148
+ * `settings` slot, whose `review` has always had a heading of its own
149
+ * beside `enabled`'s. Declared on the field rather than special-cased in
150
+ * the panel, so a plugin whose one slot holds a weight and a switch can
151
+ * say the same thing. Absent means the slot's.
152
+ */
153
+ facet?: string;
154
+ /**
155
+ * For `share`, `perMember` and `strengths`: the bands, in render order.
156
+ *
157
+ * For an `enum`: each option's display text — `{ key, label, description? }`,
158
+ * `key` the stored value. Declared **beside** `of` (which keeps the stored
159
+ * values, their order, the inferred value type and the value check) or
160
+ * **instead of** it (`of` is then derived from the keys). It is the one way
161
+ * to say what a stored value like `oldest-first` reads as; a renderer shows
162
+ * an option with no member, or a member with no label, as its value
163
+ * humanised ("Oldest first"), never raw. Optional, and hashed wherever the
164
+ * field's own `label` is — a create spec inlines its genre's fields, so
165
+ * adding or rewording one moves that spec's pin.
166
+ */
167
+ members?: readonly MemberDecl[];
168
+ /**
169
+ * For `secret`: lend it to this package's nodes when they run in another
170
+ * package's pipeline (R63). Off by default — a node you made public runs
171
+ * for other packages without your keys unless you lend them. Either way
172
+ * the code holds a **secret handle**, never the value: `ctx.fetch` fills it
173
+ * in at the network boundary, for your declared hosts only.
174
+ */
175
+ lend?: boolean;
176
+ /**
177
+ * For `list`: the declaration every element satisfies.
178
+ *
179
+ * A separate key rather than reusing `of`, which is an `enum`'s **options**
180
+ * and is typed `readonly string[]` everywhere that reads it. Widening that
181
+ * key to also mean "the element declaration" would make `of` two things at
182
+ * once and break the inference every enum in every contract depends on.
183
+ *
184
+ * `min`/`max` on a `list` are the element **count**, not a numeric range.
185
+ */
186
+ item?: FieldDecl;
187
+ /**
188
+ * For `object`: the member declarations, in render order.
189
+ *
190
+ * A `SettingsSchema` by construction — the same map a plugin's settings, a
191
+ * genre's fields and a node's params are all declared as — so nesting costs
192
+ * no second vocabulary and a renderer that can draw a form can draw a row.
193
+ */
194
+ fields?: Record<string, FieldDecl>;
195
+ /** For `media`: which kinds the picker offers. Absent means `['image']`. */
196
+ accepts?: readonly MediaKind[];
197
+ min?: number;
198
+ max?: number;
199
+ of?: O;
200
+ /** Options sourced from the live connection, e.g. `'connection.voices'` (17 §2b). */
201
+ from?: string;
202
+ /**
203
+ * Blocks activation when unset. The plugin is **not broken** — it is installed,
204
+ * listed, and telling the admin exactly what it is waiting for (§ needsConfiguration).
205
+ */
206
+ required?: boolean;
207
+ /** Who may write it. Admin-only is the right default; display preferences are per-user. */
208
+ scope?: 'pub' | 'user';
209
+ /**
210
+ * `extension` is requestable through the SDK at any time; `component` is fed in at
211
+ * render and arrives through `ctx`. A secret may never be component-side — a
212
+ * component runs in the browser.
213
+ */
214
+ side?: 'extension' | 'component';
215
+ /** Form grouping and ordering. Cosmetic, and cheap to get right now. */
216
+ group?: string;
217
+ /**
218
+ * The four orthogonal decisions about what a field is *for*, following
219
+ * Elasticsearch's `index` / `doc_values` / `store` / `_source` split.
220
+ *
221
+ * They are four because collapsing them into one boolean loses information
222
+ * every system at this job's scale has eventually needed: a field can be
223
+ * worth filtering on and meaningless to sort by, worth putting in front of
224
+ * the model and actively harmful inside an embedding. `priority` is the
225
+ * example that makes it concrete — queryable, sortable, injected, and *not*
226
+ * embedded, because "1" contributes nothing to a cosine and dilutes what
227
+ * does.
228
+ *
229
+ * All four default to off. A field nobody declared queryable is one the
230
+ * projection builds no index for and a filter cannot name — which is the
231
+ * point: **the declaration says `queryable`; the projection picks the
232
+ * strategy.** Leak "this is a column" into the declaration and storage
233
+ * layout becomes a public contract.
234
+ *
235
+ * Read by entry types (`Descriptor.entryShape.fields`); harmless and unset
236
+ * on plugin settings and node params, which have nothing to index.
237
+ */
238
+ queryable?: boolean;
239
+ /** May results be ordered by it. Independent of `queryable`: a filterable
240
+ * field is not automatically a sensible sort key. */
241
+ sortable?: boolean;
242
+ /** Does its value form part of the text an embedding is computed over. */
243
+ embedded?: boolean;
244
+ /** Does its value reach the model in the assembled prompt. */
245
+ injected?: boolean;
246
+ /** Show only when another field has a given value. One level; not a rules engine. */
247
+ showIf?: {
248
+ field: string;
249
+ equals: unknown;
250
+ };
251
+ /**
252
+ * The field this one narrows: it may hold a value only while that one
253
+ * does, as a day narrows a month (the story-time rule, `storyTimeProblem`).
254
+ * A fact about one stored value, not about a form — so, unlike `showIf`,
255
+ * an entry type's constraint projection makes it part of the type's
256
+ * database CHECK. Names another field of the same schema, never itself;
257
+ * `describeEntryType` refuses either.
258
+ *
259
+ * Read by entry types (`Descriptor.entryShape.fields`); unset on plugin
260
+ * settings and node params.
261
+ */
262
+ narrows?: string;
263
+ /**
264
+ * A node `params` field several nodes of one spec hold **in common**, and
265
+ * therefore resolve at ONE owner's address (R-7 P2, one owner per setting
266
+ * per spec; refined 2026-09-16, plans/30 U3b).
267
+ *
268
+ * Where a node's `params` slot is a reference — `slot.params({ node })` —
269
+ * the executor resolves its fields in two halves: a field marked `shared`
270
+ * is read from the **owner** node's declared default and stored value
271
+ * (the three lore lanes' scan depth is one number for all three); a field
272
+ * left unmarked is the node's **own**, read at its own address even
273
+ * through the reference (each lane's `share` of the window is its own).
274
+ * The panel draws the same line — a shared field renders once, on the
275
+ * owner; an own field renders on every node that declares it.
276
+ *
277
+ * ⚠ It is a property of the *declaration*, not of the spec: the definition
278
+ * says which of its settings are the same setting wherever two of it run
279
+ * side by side, and a spec that references an owner gets exactly those.
280
+ * A spec referencing an owner whose schema marks nothing `shared` has
281
+ * written a reference that resolves nothing, and `validate()` says so.
282
+ * `validate()`'s P2 diagnostic is keyed on it as well: two own-node
283
+ * `params` owners in one spec that both declare a `shared` field under the
284
+ * same name are two addresses for one setting.
285
+ *
286
+ * Unset on plugin settings, genre fields and entry shapes, where there is
287
+ * no second node to share with.
288
+ */
289
+ shared?: boolean;
290
+ /**
291
+ * For `text` fields holding structured data a form cannot decompose: the
292
+ * renderer shows JSON and the submit path parses it back. Produced by
293
+ * `inferSchema` for nested payloads; an author declaring settings should
294
+ * declare real fields instead.
295
+ *
296
+ * `'story-time'` (🚧): a `string` holding a position on the story
297
+ * calendar in its canonical line (`412-03-05 22:30`, `storyTime.ts`) — the
298
+ * field a clock/date stat is declared as (`core:stat-shape/story-time@1`).
299
+ */
300
+ format?: 'json' | 'story-time';
301
+ }
302
+ /** @public */
303
+ export type SettingsSchema = Record<string, FieldDecl>;
304
+ /**
305
+ * The label to render, resolved through `i18nText` in `language` — a bare
306
+ * string is itself, a map answers the locale or falls back to `en`.
307
+ * @internal
308
+ */
309
+ export declare function fieldLabel(decl: {
310
+ label?: I18nText;
311
+ }, language?: string): string | undefined;
312
+ /**
313
+ * Every display-text fault in one settings schema (R-20), as sentences that
314
+ * name the field: each field's `label` and its `description`; each
315
+ * `members[]` band's label and description; and the
316
+ * same for a `list`'s `item` and an `object`'s `fields`, recursively. A schema
317
+ * that is not an object is one finding. Run at every door a schema arrives
318
+ * through — `register()` for node params, `genre()` for a shape's fields,
319
+ * a widget's `settings`, `validate()` for a document — so a blank label is
320
+ * refused where the author is and never reaches a form.
321
+ *
322
+ * `of` stays unread: an enum's options are stored values, not display text,
323
+ * and their labels live on `members[]`.
324
+ * @experimental
325
+ */
326
+ export declare function settingsSchemaFindings(schema: unknown, where: string): string[];
327
+ /** The media kinds a `media` field offers. Images unless it says otherwise. @experimental */
328
+ export declare function fieldAccepts(decl: FieldDecl): readonly MediaKind[];
329
+ type ValueOf<F> = F extends {
330
+ type: 'secret';
331
+ } ? SecretValue : F extends {
332
+ type: 'list';
333
+ item: infer I;
334
+ } ? Array<ValueOf<I>> : F extends {
335
+ type: 'object';
336
+ fields: infer M;
337
+ } ? M extends SettingsSchema ? SettingsValues<M> : Record<string, unknown> : F extends {
338
+ type: 'enum';
339
+ of: readonly (infer O)[];
340
+ } ? O : F extends {
341
+ type: 'boolean';
342
+ } ? boolean : F extends {
343
+ type: 'number' | 'integer';
344
+ } ? number : F extends {
345
+ type: 'string[]';
346
+ } ? string[] : string;
347
+ type RequiredKeys<S> = {
348
+ [K in keyof S]: S[K] extends {
349
+ required: true;
350
+ } ? K : never;
351
+ }[keyof S];
352
+ /** @public */
353
+ export type SettingsValues<S extends SettingsSchema> = {
354
+ [K in RequiredKeys<S>]: ValueOf<S[K]>;
355
+ } & {
356
+ [K in Exclude<keyof S, RequiredKeys<S>>]?: ValueOf<S[K]>;
357
+ };
358
+ /** @experimental */
359
+ export interface SettingsFinding {
360
+ field?: string;
361
+ severity: 'error' | 'warning';
362
+ message: string;
363
+ /** What to do instead — required, like every other finding in this SDK (15 §1.3). */
364
+ fix: string;
365
+ }
366
+ /** Mistakes that would otherwise become silent leaks or dead form fields. @experimental */
367
+ export declare function checkSchema(schema: SettingsSchema): SettingsFinding[];
368
+ /** @internal */
369
+ export declare function checkValues(schema: SettingsSchema, values: Record<string, unknown>): SettingsFinding[];
370
+ /** @experimental */
371
+ export interface Reconciled {
372
+ values: Record<string, unknown>;
373
+ /** Stored values the new schema no longer declares. **Never deleted** (12 §6, 02 §7). */
374
+ orphaned: Array<{
375
+ field: string;
376
+ value: unknown;
377
+ reason: string;
378
+ }>;
379
+ findings: SettingsFinding[];
380
+ }
381
+ /**
382
+ * What an update does to values that already exist.
383
+ *
384
+ * The rule is the one 12 §5 already applies to a node swap's orphaned slots: **unmigrated
385
+ * values land in diagnostics rather than disappearing.** An author who renames a field
386
+ * and an admin who then downgrades should both get their data back; silently dropping it
387
+ * makes the update irreversible in the one direction that matters.
388
+ * @internal
389
+ */
390
+ export declare function reconcile(schema: SettingsSchema, stored: Record<string, unknown>): Reconciled;
391
+ /** What the settings form sends back. A secret reports only whether it is set. @internal */
392
+ export declare function forClient(schema: SettingsSchema, values: Record<string, unknown>): Record<string, unknown>;
393
+ /** What an export carries. Secrets never leave, on the same footing as credentials. @experimental */
394
+ export declare function forExport(schema: SettingsSchema, values: Record<string, unknown>): Record<string, unknown>;
395
+ /**
396
+ * What the declaring extension's own hook receives — the only place plaintext appears,
397
+ * and only for the extension that owns the field. Same shape as F18's per-call injection
398
+ * of connection material.
399
+ */
400
+ /**
401
+ * The handle plugin code holds for a secret setting — never its value (R63).
402
+ * `nonce` is minted by the host per plugin load, so a handle cannot be forged
403
+ * from text that came from anywhere but the host.
404
+ * @experimental
405
+ */
406
+ export declare const secretHandle: (key: string, nonce: string) => string;
407
+ /** A secret's key, as a handle can carry it. @experimental */
408
+ export declare const SECRET_KEY: RegExp;
409
+ /**
410
+ * What a hook's `settings` carries (R63): every value, and a **secret handle**
411
+ * in place of each secret — so the plugin's code never holds a key — beside
412
+ * the plaintext the host keeps for the fetch bridge and the scrub, and the
413
+ * keys the package lends to its nodes in other packages' pipelines.
414
+ * @internal
415
+ */
416
+ export declare function forOwningHookSplit(schema: SettingsSchema, values: Record<string, unknown>, decrypt: (cipher: string) => string, nonce: string): {
417
+ settings: Record<string, unknown>;
418
+ secrets: Record<string, string>;
419
+ lent: string[];
420
+ };
421
+ /** What a component receives at render — extension-side fields never reach the browser. @experimental */
422
+ export declare function forComponent(schema: SettingsSchema, values: Record<string, unknown>): Record<string, unknown>;
423
+ /** @internal */
424
+ export type PluginConfigState = {
425
+ state: 'ready';
426
+ }
427
+ /**
428
+ * Installed, listed, and waiting on the admin — **not `broken`**. The distinction is
429
+ * the difference between filing a bug against the author and typing an API key, and a
430
+ * plugin that silently does nothing is the worst of both.
431
+ */
432
+ | {
433
+ state: 'needs-configuration';
434
+ missing: string[];
435
+ message: string;
436
+ };
437
+ /** @internal */
438
+ export declare function configState(schema: SettingsSchema, values: Record<string, unknown>): PluginConfigState;
439
+ /** @experimental */
440
+ export interface FormGroup {
441
+ group: string;
442
+ fields: Array<{
443
+ key: string;
444
+ decl: FieldDecl;
445
+ }>;
446
+ }
447
+ /** Declaration order within a group; group order is first appearance. @experimental */
448
+ export declare function formLayout(schema: SettingsSchema): FormGroup[];
449
+ /** Is this field currently shown, given the values? One level of `showIf`, no rules engine. @experimental */
450
+ export declare const isVisible: (decl: FieldDecl, values: Record<string, unknown>) => boolean;
451
+ /** @experimental */
452
+ export interface PluginSettings<S extends SettingsSchema> {
453
+ schema: S;
454
+ /** Phantom, for `typeof s.values` in the extension's own code. Never populated. */
455
+ readonly values?: SettingsValues<S>;
456
+ defaults(): Record<string, unknown>;
457
+ layout(): FormGroup[];
458
+ check(values: Record<string, unknown>): SettingsFinding[];
459
+ reconcile(stored: Record<string, unknown>): Reconciled;
460
+ state(values: Record<string, unknown>): PluginConfigState;
461
+ forClient(values: Record<string, unknown>): Record<string, unknown>;
462
+ forExport(values: Record<string, unknown>): Record<string, unknown>;
463
+ forComponent(values: Record<string, unknown>): Record<string, unknown>;
464
+ }
465
+ /** @experimental */
466
+ export declare class SettingsError extends Error {
467
+ }
468
+ /**
469
+ * Declare a plugin's settings. The compiler extracts this statically into the manifest,
470
+ * so it must be a literal — a schema assembled at runtime cannot be read without running
471
+ * the author's code, which the packager never does (F6, 03 §3).
472
+ * @public
473
+ */
474
+ export declare function defineSettings<const S extends SettingsSchema>(schema: S): PluginSettings<S>;
475
+ /**
476
+ * A `SettingsSchema` inferred from a payload — the review gate's form producer.
477
+ *
478
+ * One field language for everything a person edits in a generated form: an
479
+ * extension's declared settings, an extension's arbitrary forms, and a paused
480
+ * node's payload all render through the same schema and the same renderer. A
481
+ * review form is therefore 100% defined by the data the node received: a
482
+ * string is a text field, a number is a number field, a flag is a checkbox,
483
+ * and structure a form cannot decompose arrives as JSON rather than being
484
+ * silently dropped — an edit surface that hides part of the payload is a
485
+ * review gate a write can sneak past.
486
+ * @experimental
487
+ */
488
+ export declare function inferSchema(payload: unknown): SettingsSchema;
489
+ /** The payload as form values — JSON-format fields serialized for editing. @internal */
490
+ export declare function valuesForForm(schema: SettingsSchema, payload: unknown): Record<string, unknown>;
491
+ /**
492
+ * Fold edited form values back into the payload shape the node expects.
493
+ *
494
+ * The inverse of `valuesForForm`: JSON-format fields parse back (an
495
+ * unparseable edit throws with the field named rather than committing a
496
+ * string where an object stood), untouched keys keep their original values —
497
+ * a form is an edit surface, never a filter.
498
+ * @internal
499
+ */
500
+ export declare function applyFormValues(schema: SettingsSchema, payload: unknown, edited: Record<string, unknown>): unknown;
501
+ //# sourceMappingURL=settings.d.ts.map