@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
@@ -1,5 +1,5 @@
1
1
  /**
2
- * The pipeline type registry — the ruling on 13 §10c.
2
+ * The pipeline type registry.
3
3
  *
4
4
  * ## Where a type's shape comes from, at three different moments
5
5
  *
@@ -10,11 +10,11 @@
10
10
  * | moment | source of truth | why |
11
11
  * |---|---|---|
12
12
  * | authoring | the `Descriptor` in code | the author is *defining* the type; nothing else knows it yet |
13
- * | compiling a spec | generated `/contracts` | frozen per release, so a pin resolves the same way forever (04 §2) |
13
+ * | compiling a spec | generated `/contracts` | frozen per release, so a pin resolves the same way forever |
14
14
  * | installing | **the registry row** | the only one core can read without executing the plugin |
15
15
  *
16
16
  * The third row is the whole point. Core must decide whether a plugin is installable
17
- * before it ever runs the plugin's code — F6 means core imports documents, never
17
+ * before it ever runs the plugin's code — core imports documents, never
18
18
  * authoring JS — so install-time validation reads two things that are both plain data:
19
19
  * the plugin's **manifest** (types summarized, permissions compiled from usage) and its
20
20
  * **documents** (nodes pinned by `definitionId@version`, edges carrying the shapes they were
@@ -27,6 +27,7 @@
27
27
  * every id still resolves but a port now produces a different shape. The document
28
28
  * records the shape each edge was compiled against, so comparing it to the registry
29
29
  * catches exactly that, and catches it at install rather than mid-run.
30
+ * @ruling 13 §10c, 04 §2, F6
30
31
  */
31
32
  import { type DefinitionPolicy, type Descriptor, type EntryShape, type ScriptPointDecl, type SlotDecl } from './descriptors.js';
32
33
  import type { MediaCapability } from './media.js';
@@ -34,15 +35,16 @@ import { type ScriptKindDecl } from './scripts.js';
34
35
  import type { SettingsSchema } from './settings.js';
35
36
  import type { SpecDocument } from './document.js';
36
37
  /**
37
- * A `pipeline_definition_registry` row (02 §3), as data.
38
+ * A `pipeline_definition_registry` row, as data.
38
39
  *
39
- * Two halves, and the row carries both (plans/31 V6): every **contract**
40
+ * Two halves, and the row carries both: every **contract**
40
41
  * field of the `Descriptor` (`DESCRIPTOR_CONTRACT_KEYS`) — so a row read back
41
42
  * hashes to the `content_hash` it was written under, and a plugin can be
42
- * judged against rows without being executed (F6) — and the **policy** half,
43
+ * judged against rows without being executed — and the **policy** half,
43
44
  * on `policy`, `i18n` and `public`, which the hash never sees and a sync
44
45
  * refreshes in place.
45
46
  * @internal
47
+ * @ruling 02 §3, plans/31 V6, F6
46
48
  */
47
49
  export interface RegistryEntry {
48
50
  id: string;
@@ -57,10 +59,11 @@ export interface RegistryEntry {
57
59
  optional?: boolean;
58
60
  /**
59
61
  * The four other contract flags and the three contract declarations that
60
- * had no column until plans/31 V6 — carried for the same reason `optional`
62
+ * once had no column — carried for the same reason `optional`
61
63
  * is: each is in the hash, and a hashed field the row cannot carry is a
62
64
  * row that cannot reproduce its own pointer. `review.fields` is also what
63
65
  * a `transport: process` outlet's gate form is read from.
66
+ * @ruling plans/31 V6
64
67
  */
65
68
  declaresRandomness?: boolean;
66
69
  earlyExit?: boolean;
@@ -72,21 +75,23 @@ export interface RegistryEntry {
72
75
  shape?: string;
73
76
  media?: MediaCapability;
74
77
  /**
75
- * Interior script points (18 §4e) — carried into the row for the same
78
+ * Interior script points — carried into the row for the same
76
79
  * reason `slots` is: the panel offers one chain option per point and must
77
- * render it without loading the plugin (F6). Keys and `accepts` are
80
+ * render it without loading the plugin. Keys and `accepts` are
78
81
  * contract and hash; labels are display text, stripped like `i18n`
79
82
  * everywhere else. Always the full shape — the projection copies through
80
83
  * `scriptPointsOf`, and `register()` refuses a bare string or a point
81
84
  * without `accepts`, so a row never carries one.
85
+ * @ruling 18 §4e, F6
82
86
  */
83
87
  scriptPoints?: ScriptPointDecl[];
84
88
  /**
85
- * The chat-shape contract (19 §1) — present only on mode-bearing input
89
+ * The chat-shape contract — present only on mode-bearing input
86
90
  * types. Carried for the reason `slots` is: the mode picker and the chat
87
- * settings render from rows (F6), never from a loaded spec. Hashed —
91
+ * settings render from rows, never from a loaded spec. Hashed —
88
92
  * widening a capability changes what existing sessions legally contain —
89
93
  * with any embedded `i18n`/`description` stripped like everywhere.
94
+ * @ruling 19 §1, F6
90
95
  */
91
96
  sessionShape?: unknown;
92
97
  ports: {
@@ -97,23 +102,24 @@ export interface RegistryEntry {
97
102
  * The **declarations**, not their names.
98
103
  *
99
104
  * This carried `string[]` until 0.6.0, and that quietly broke the promise the
100
- * column exists to keep. 12 §2 says slot declarations live in the type descriptor
105
+ * column exists to keep. The design says slot declarations live in the type descriptor
101
106
  * *"so a plugin Provider's prompt fields render next to core's automatically, with
102
107
  * no UI work"*, and the table above says the registry row is what core reads
103
108
  * **without executing the plugin**. A name list satisfies neither: a form
104
109
  * generator given `['prompts', 'params']` knows a form exists and nothing about
105
110
  * what is in it, so it has to fall back to the in-process descriptor map — which
106
111
  * exists for core types, does not exist for a `transport: 'process'` plugin type,
107
- * and is the exact thing F6 forbids reaching for.
112
+ * and is the exact thing core must never reach for.
108
113
  *
109
- * Storing the declaration makes the pipeline view (05 §0a) and the lens view
110
- * (05 §3) generated from rows, which is what lets a plugin's sliders appear beside
114
+ * Storing the declaration makes the pipeline view and the lens view
115
+ * generated from rows, which is what lets a plugin's sliders appear beside
111
116
  * core's with nothing authored twice.
112
117
  *
113
- * One of them the author did not write: `settings` (R-9), which the
118
+ * One of them the author did not write: `settings`, which the
114
119
  * projection derives from `optional` / `effects` / `reviewDefault` so the
115
120
  * panel finds the switch and the gate here like any slot. It is left out
116
121
  * of the content hash — `authoredSlots` — for the reason that file gives.
122
+ * @ruling 12 §2, F6, 05 §0a, 05 §3, R-9
117
123
  */
118
124
  slots: Record<string, SlotDecl>;
119
125
  /**
@@ -121,11 +127,12 @@ export interface RegistryEntry {
121
127
  * entry types. Carried for the reason `slots` is: the ranker, the assembler
122
128
  * and the constraint projection all read the declaration from **rows**, and
123
129
  * the row is the only source that exists for a type this process never
124
- * loaded (F6).
130
+ * loaded.
125
131
  *
126
132
  * Hashed whole. Roles decide where a row competes, how it sorts, who may
127
133
  * see it and where it renders, so moving one changes what an untouched
128
134
  * install does — `@N+1`, deliberately.
135
+ * @ruling F6
129
136
  */
130
137
  entryShape?: Omit<EntryShape, 'fields'>;
131
138
  /**
@@ -146,38 +153,47 @@ export interface RegistryEntry {
146
153
  * Outside the content hash, like every other piece of display text: naming
147
154
  * a node better is not a contract change. Carried in the row for the same
148
155
  * reason `slots` is — the pipeline builder renders from rows and never
149
- * loads the plugin (F6), so a name only the descriptor knows is a name no
156
+ * loads the plugin, so a name only the descriptor knows is a name no
150
157
  * plugin's node can have.
158
+ * @ruling F6
151
159
  */
152
160
  i18n?: unknown;
153
161
  /**
154
162
  * Script types only: how a chain of this operation treats what its links
155
163
  * return — `transform` folds into the flowing bag, `verdict` is consumed by
156
- * the hook and reduced (18 §5).
164
+ * the hook and reduced.
157
165
  *
158
166
  * Hashed, and it has to be. Flipping it moves no port and keeps every
159
167
  * attachment compiling, while turning "each link rewrites the text" into
160
168
  * "the earliest answer wins" — the same shape of silent behaviour change
161
169
  * `optional` was, and the reason that one is hashed.
170
+ * @ruling 18 §5
162
171
  */
163
172
  semantics?: string;
164
173
  effects?: string;
165
174
  causesEvent?: string;
166
175
  /** The in-port whose literal names the event a write causes. */
167
176
  causesEventFrom?: string;
168
- /** Inlet only: the event payloads it reads (R33) — hashed with the contract. */
177
+ /**
178
+ * Inlet only: the event payloads it reads — hashed with the contract.
179
+ * @ruling R33
180
+ */
169
181
  payloads?: string[];
170
182
  public?: boolean;
171
183
  /**
172
- * The policy half (plans/31 V6): `provisional` (plans/29 R-2 — the row
184
+ * The policy half: `provisional` (the row
173
185
  * also reads it as `status: 'provisional'`), `reviewDefault`,
174
186
  * `timeoutMs`, `timeoutKind`, `toggleable`. Never hashed; a sync writes
175
187
  * it on insert and refreshes it in place when it moves, so flipping a
176
188
  * flag reaches every install without a pointer move. Absent on a script
177
189
  * kind's row, which declares none of them.
190
+ * @ruling plans/31 V6, plans/29 R-2
178
191
  */
179
192
  policy?: DefinitionPolicy;
180
- /** Null for core types; the plugin slug for plugin types (12 §3b). */
193
+ /**
194
+ * Null for core types; the plugin slug for plugin types.
195
+ * @ruling 12 §3b
196
+ */
181
197
  owner?: string;
182
198
  /** Which SP release seeded this row. */
183
199
  release?: string;
@@ -194,7 +210,10 @@ export interface InstallFinding {
194
210
  severity: 'error' | 'warning';
195
211
  code: InstallCode;
196
212
  message: string;
197
- /** What the admin or author does about it. Never omitted (15 §1.3). */
213
+ /**
214
+ * What the admin or author does about it. Never omitted.
215
+ * @ruling 15 §1.3
216
+ */
198
217
  fix: string;
199
218
  where?: string;
200
219
  }
package/dist/registry.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * The pipeline type registry — the ruling on 13 §10c.
2
+ * The pipeline type registry.
3
3
  *
4
4
  * ## Where a type's shape comes from, at three different moments
5
5
  *
@@ -10,11 +10,11 @@
10
10
  * | moment | source of truth | why |
11
11
  * |---|---|---|
12
12
  * | authoring | the `Descriptor` in code | the author is *defining* the type; nothing else knows it yet |
13
- * | compiling a spec | generated `/contracts` | frozen per release, so a pin resolves the same way forever (04 §2) |
13
+ * | compiling a spec | generated `/contracts` | frozen per release, so a pin resolves the same way forever |
14
14
  * | installing | **the registry row** | the only one core can read without executing the plugin |
15
15
  *
16
16
  * The third row is the whole point. Core must decide whether a plugin is installable
17
- * before it ever runs the plugin's code — F6 means core imports documents, never
17
+ * before it ever runs the plugin's code — core imports documents, never
18
18
  * authoring JS — so install-time validation reads two things that are both plain data:
19
19
  * the plugin's **manifest** (types summarized, permissions compiled from usage) and its
20
20
  * **documents** (nodes pinned by `definitionId@version`, edges carrying the shapes they were
@@ -27,6 +27,7 @@
27
27
  * every id still resolves but a port now produces a different shape. The document
28
28
  * records the shape each edge was compiled against, so comparing it to the registry
29
29
  * catches exactly that, and catches it at install rather than mid-run.
30
+ * @ruling 13 §10c, 04 §2, F6
30
31
  */
31
32
  import { pluginRuleRef } from './pluginRuleRef.js';
32
33
  import { definitionPolicy, scriptPointsOf, } from './descriptors.js';
@@ -42,15 +43,16 @@ export function snapshotRegistry(types, meta = {}) {
42
43
  /**
43
44
  * A script type as a registry row.
44
45
  *
45
- * ⚠ Projected through the *same* function as node types, deliberately. 18 §2
46
+ * ⚠ Projected through the *same* function as node types, deliberately. The design
46
47
  * puts scripts "under the same sync, conflict-refusal and re-projection rules
47
48
  * as node types", and the cheapest way to keep that true is for there to be one
48
49
  * projection, one hash and one sync rather than a parallel set that drifts.
49
50
  *
50
51
  * `blastRadius` rides inside `i18n` rather than earning a column, because that
51
52
  * is what it is: display text, stripped from the hash, read from the row by a
52
- * panel that must not load the plugin to render a badge (F6). `semantics` does
53
+ * panel that must not load the plugin to render a badge. `semantics` does
53
54
  * earn one — it is contract.
55
+ * @ruling 18 §2, F6
54
56
  */
55
57
  function scriptEntry(d, meta) {
56
58
  return {
package/dist/review.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * The review gate (01 §7).
2
+ * The review gate.
3
3
  *
4
4
  * The gate lives in the executor substrate, below the type layer, and keys on
5
5
  * **declared effects rather than kind** — so an effectful Provider (an MCP tool that
@@ -9,6 +9,7 @@
9
9
  * · the gated party never implements the gate
10
10
  * · plugin code cannot decline it, detect it, or tell an approved payload from an edited one
11
11
  * · an author may default it **on** for their own node; forbidding it is not expressible
12
+ * @ruling 01 §7
12
13
  */
13
14
  import { type SettingsSchema } from './settings.js';
14
15
  /**
@@ -53,14 +54,18 @@ export interface ReviewRecord {
53
54
  by?: string;
54
55
  at?: number;
55
56
  }
56
- /** Resolver supplied by the host. `sync` parks on this promise; waiting is free (F13). @experimental */
57
+ /**
58
+ * Resolver supplied by the host. `sync` parks on this promise; waiting is free.
59
+ * @experimental
60
+ * @ruling F13
61
+ */
57
62
  export type Reviewer = (req: ReviewRequest) => Promise<ReviewDecision>;
58
63
  /**
59
64
  * The form a reviewer is shown for this node's payload.
60
65
  *
61
66
  * Inferred from the payload (`inferSchema`) — the one field language settings,
62
67
  * plugin forms and review pauses share — and then, when the definition
63
- * declares `review.fields`, narrowed to those names (U5b review C1). A
68
+ * declares `review.fields`, narrowed to those names. A
64
69
  * declared field the payload does not carry infers nothing and is simply
65
70
  * absent; an undeclared one is never offered. Absent declaration, the whole
66
71
  * payload is the form, as it always was.
@@ -71,6 +76,7 @@ export type Reviewer = (req: ReviewRequest) => Promise<ReviewDecision>;
71
76
  * in `undeclaredReviewFields` is the second, independent guard: a submission
72
77
  * naming one is refused outright rather than dropped in silence.
73
78
  * @internal
79
+ * @ruling U5b review C1
74
80
  */
75
81
  export declare function reviewSchemaFor(definition: {
76
82
  review?: {
@@ -91,8 +97,9 @@ export declare function undeclaredReviewFields(definition: {
91
97
  /**
92
98
  * There is deliberately no `'never'` position and no descriptor field that could produce
93
99
  * one. An author picks a default; the user's setting wins over it. Forbidding review is
94
- * not a value this type can hold, which is the enforcement (F14).
100
+ * not a value this type can hold, which is the enforcement.
95
101
  * @experimental
102
+ * @ruling F14
96
103
  */
97
104
  export declare const POSITIONS: readonly ReviewPosition[];
98
105
  /** @experimental */
@@ -103,6 +110,10 @@ export declare function hashPayload(v: unknown): string;
103
110
  * @experimental
104
111
  */
105
112
  export declare function resolvePosition(authorDefault: ReviewPosition | undefined, userSetting: unknown): ReviewPosition;
106
- /** Which nodes the gate applies to — effects, not kind (01 §7, 14 §4a). @experimental */
113
+ /**
114
+ * Which nodes the gate applies to — effects, not kind.
115
+ * @experimental
116
+ * @ruling 01 §7, 14 §4a
117
+ */
107
118
  export declare function isGated(effects: string | undefined): boolean;
108
119
  //# sourceMappingURL=review.d.ts.map
package/dist/review.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * The review gate (01 §7).
2
+ * The review gate.
3
3
  *
4
4
  * The gate lives in the executor substrate, below the type layer, and keys on
5
5
  * **declared effects rather than kind** — so an effectful Provider (an MCP tool that
@@ -9,6 +9,7 @@
9
9
  * · the gated party never implements the gate
10
10
  * · plugin code cannot decline it, detect it, or tell an approved payload from an edited one
11
11
  * · an author may default it **on** for their own node; forbidding it is not expressible
12
+ * @ruling 01 §7
12
13
  */
13
14
  import { inferSchema } from './settings.js';
14
15
  /**
@@ -16,7 +17,7 @@ import { inferSchema } from './settings.js';
16
17
  *
17
18
  * Inferred from the payload (`inferSchema`) — the one field language settings,
18
19
  * plugin forms and review pauses share — and then, when the definition
19
- * declares `review.fields`, narrowed to those names (U5b review C1). A
20
+ * declares `review.fields`, narrowed to those names. A
20
21
  * declared field the payload does not carry infers nothing and is simply
21
22
  * absent; an undeclared one is never offered. Absent declaration, the whole
22
23
  * payload is the form, as it always was.
@@ -27,6 +28,7 @@ import { inferSchema } from './settings.js';
27
28
  * in `undeclaredReviewFields` is the second, independent guard: a submission
28
29
  * naming one is refused outright rather than dropped in silence.
29
30
  * @internal
31
+ * @ruling U5b review C1
30
32
  */
31
33
  export function reviewSchemaFor(definition, payload) {
32
34
  const inferred = inferSchema(payload);
@@ -52,8 +54,9 @@ export function undeclaredReviewFields(definition, values) {
52
54
  /**
53
55
  * There is deliberately no `'never'` position and no descriptor field that could produce
54
56
  * one. An author picks a default; the user's setting wins over it. Forbidding review is
55
- * not a value this type can hold, which is the enforcement (F14).
57
+ * not a value this type can hold, which is the enforcement.
56
58
  * @experimental
59
+ * @ruling F14
57
60
  */
58
61
  export const POSITIONS = ['off', 'on'];
59
62
  /**
@@ -90,7 +93,11 @@ export function resolvePosition(authorDefault, userSetting) {
90
93
  return LEGACY_POSITIONS[authorDefault];
91
94
  return 'off';
92
95
  }
93
- /** Which nodes the gate applies to — effects, not kind (01 §7, 14 §4a). @experimental */
96
+ /**
97
+ * Which nodes the gate applies to — effects, not kind.
98
+ * @experimental
99
+ * @ruling 01 §7, 14 §4a
100
+ */
94
101
  export function isGated(effects) {
95
102
  return effects === 'write' || effects === 'external';
96
103
  }
@@ -41,6 +41,60 @@
41
41
  */
42
42
  import type { SettingsSchema } from './settings.js';
43
43
  import type { ShapeId } from './shapes.js';
44
+ /**
45
+ * One row of a logit bias list — the value of `logitBias` (`format:
46
+ * 'logit-bias'`) is an ordered list of these.
47
+ *
48
+ * `text` is what the row biases, in SillyTavern's syntax: a plain word is
49
+ * tokenized with a leading space, `{exact text}` verbatim, and `[1, 2]` is
50
+ * token ids as they stand. `value` is the bias every token of that sequence
51
+ * gets, `LOGIT_BIAS_MIN`…`LOGIT_BIAS_MAX`.
52
+ *
53
+ * Text rather than ids, because an id means something to one tokenizer only:
54
+ * the same list has to bias the same words on whichever model the config is
55
+ * pointed at. ⚠ A **logit bias entry**, never a bare _entry_ — that word is
56
+ * the lorebook's.
57
+ * @experimental
58
+ */
59
+ export interface LogitBiasEntry {
60
+ text: string;
61
+ value: number;
62
+ }
63
+ /** The lowest bias a logit bias entry holds: a ban, wherever the backend honours it. @experimental */
64
+ export declare const LOGIT_BIAS_MIN = -100;
65
+ /** The highest bias a logit bias entry holds. @experimental */
66
+ export declare const LOGIT_BIAS_MAX = 100;
67
+ /**
68
+ * The `logitBias` default: the "overthinking markers" — the words a reasoning
69
+ * model hedges and backtracks with — each nudged down by 2 (r/LocalLLaMA,
70
+ * u/am17an, after arXiv 2606.00206).
71
+ *
72
+ * A default, not a switch: `logitBias` is in no shipped config's `enabled`
73
+ * list, so this is what the editor starts from and what ticking the field
74
+ * sends — never what an untouched config sends. Plain words, so each is
75
+ * biased as " word" on whatever tokenizer the model uses.
76
+ * @experimental
77
+ */
78
+ export declare const LOGIT_BIAS_OVERTHINKING_MARKERS: readonly Readonly<LogitBiasEntry>[];
79
+ /**
80
+ * A stored or submitted `logitBias` value as logit bias entries, or `null`
81
+ * when it cannot be read as one.
82
+ *
83
+ * Three shapes reach it: the rows the editor writes; the legacy
84
+ * `{ "<id>": bias }` object the JSON textarea wrote, read as one `[<id>]` row
85
+ * per key, in key order; and either of those as a JSON string (a blank string
86
+ * is an empty list). Row by row it is lenient: a text that is not a string
87
+ * becomes one, llama.cpp's own `[id, bias]` / `["text", bias]` pair becomes
88
+ * `[id]` / `{text}`, a bias that is not a finite number becomes 0, and every
89
+ * bias clamps to `LOGIT_BIAS_MIN`…`LOGIT_BIAS_MAX`. A row whose text is empty
90
+ * or malformed is KEPT — the editor shows it with its error, and dropping it
91
+ * here would lose what somebody typed.
92
+ *
93
+ * `null` — any other value, or a string that is not JSON — is the caller's to
94
+ * report; normalization keeps such a value as it came rather than deleting it.
95
+ * @experimental
96
+ */
97
+ export declare function readLogitBiasValue(value: unknown): LogitBiasEntry[] | null;
44
98
  /**
45
99
  * Text generation — the union of what the shipped adapters can map.
46
100
  *
package/dist/sampling.js CHANGED
@@ -40,6 +40,92 @@
40
40
  * and report the rest as ignored.
41
41
  */
42
42
  import { S } from './shapes.js';
43
+ /** The lowest bias a logit bias entry holds: a ban, wherever the backend honours it. @experimental */
44
+ export const LOGIT_BIAS_MIN = -100;
45
+ /** The highest bias a logit bias entry holds. @experimental */
46
+ export const LOGIT_BIAS_MAX = 100;
47
+ /**
48
+ * The `logitBias` default: the "overthinking markers" — the words a reasoning
49
+ * model hedges and backtracks with — each nudged down by 2 (r/LocalLLaMA,
50
+ * u/am17an, after arXiv 2606.00206).
51
+ *
52
+ * A default, not a switch: `logitBias` is in no shipped config's `enabled`
53
+ * list, so this is what the editor starts from and what ticking the field
54
+ * sends — never what an untouched config sends. Plain words, so each is
55
+ * biased as " word" on whatever tokenizer the model uses.
56
+ * @experimental
57
+ */
58
+ export const LOGIT_BIAS_OVERTHINKING_MARKERS = `
59
+ perhaps maybe wait Wait actually hold Hmm hmm Alternatively alternatively
60
+ However however instead Instead But but though although yet rather unless
61
+ otherwise nonetheless nevertheless regardless still anyway Or or either
62
+ whether uncertain unsure possibly might could another different reconsider
63
+ rethink backtrack retry revisit doubt confused wrong mistake error incorrect
64
+ `
65
+ .trim()
66
+ .split(/\s+/)
67
+ .map((text) => ({ text, value: -2 }));
68
+ /**
69
+ * A stored or submitted `logitBias` value as logit bias entries, or `null`
70
+ * when it cannot be read as one.
71
+ *
72
+ * Three shapes reach it: the rows the editor writes; the legacy
73
+ * `{ "<id>": bias }` object the JSON textarea wrote, read as one `[<id>]` row
74
+ * per key, in key order; and either of those as a JSON string (a blank string
75
+ * is an empty list). Row by row it is lenient: a text that is not a string
76
+ * becomes one, llama.cpp's own `[id, bias]` / `["text", bias]` pair becomes
77
+ * `[id]` / `{text}`, a bias that is not a finite number becomes 0, and every
78
+ * bias clamps to `LOGIT_BIAS_MIN`…`LOGIT_BIAS_MAX`. A row whose text is empty
79
+ * or malformed is KEPT — the editor shows it with its error, and dropping it
80
+ * here would lose what somebody typed.
81
+ *
82
+ * `null` — any other value, or a string that is not JSON — is the caller's to
83
+ * report; normalization keeps such a value as it came rather than deleting it.
84
+ * @experimental
85
+ */
86
+ export function readLogitBiasValue(value) {
87
+ let parsed = value;
88
+ if (typeof value === 'string') {
89
+ if (!value.trim())
90
+ return [];
91
+ try {
92
+ parsed = JSON.parse(value);
93
+ }
94
+ catch {
95
+ return null;
96
+ }
97
+ }
98
+ if (Array.isArray(parsed))
99
+ return parsed.map(logitBiasRow);
100
+ if (parsed && typeof parsed === 'object')
101
+ return Object.entries(parsed).map(([id, bias]) => ({
102
+ text: `[${id}]`,
103
+ value: logitBiasNumber(bias),
104
+ }));
105
+ return null;
106
+ }
107
+ function logitBiasRow(row) {
108
+ if (Array.isArray(row) && row.length === 2) {
109
+ const [target, bias] = row;
110
+ // llama.cpp: `false` in place of a bias bans the token outright.
111
+ const value = bias === false ? LOGIT_BIAS_MIN : logitBiasNumber(bias);
112
+ if (typeof target === 'number')
113
+ return { text: `[${target}]`, value };
114
+ if (typeof target === 'string')
115
+ return { text: `{${target}}`, value };
116
+ }
117
+ if (row && typeof row === 'object' && !Array.isArray(row)) {
118
+ const { text, value } = row;
119
+ return { text: text == null ? '' : String(text), value: logitBiasNumber(value) };
120
+ }
121
+ // A bare string, number or id list typed without a bias: kept, at 0.
122
+ const text = typeof row === 'string' ? row : row == null ? '' : JSON.stringify(row);
123
+ return { text, value: 0 };
124
+ }
125
+ function logitBiasNumber(v) {
126
+ const n = typeof v === 'number' ? v : typeof v === 'string' && v.trim() ? Number(v) : NaN;
127
+ return Number.isFinite(n) ? clamp(n, LOGIT_BIAS_MIN, LOGIT_BIAS_MAX) : 0;
128
+ }
43
129
  // ── The vocabularies ────────────────────────────────────────────────────────
44
130
  /**
45
131
  * Text generation — the union of what the shipped adapters can map.
@@ -389,10 +475,11 @@ export const textSamplingSchema = {
389
475
  },
390
476
  logitBias: {
391
477
  type: 'text',
392
- format: 'json',
478
+ format: 'logit-bias',
393
479
  label: 'Logit Bias',
394
- description: 'Token id → bias, as JSON.',
395
- default: {},
480
+ description: 'Words, {exact text} or [token ids], each with a bias from −100 to 100.',
481
+ // Filled but not enabled: nothing is sent until the field is ticked.
482
+ default: LOGIT_BIAS_OVERTHINKING_MARKERS,
396
483
  group: 'Budget',
397
484
  },
398
485
  };
@@ -687,6 +774,11 @@ function coerce(value, decl) {
687
774
  case 'enum':
688
775
  return typeof value === 'string' ? value : String(value);
689
776
  case 'text':
777
+ // A logit bias list: rows, the legacy id → bias object, or either as
778
+ // JSON. One that cannot be read is kept as it came, for the editor
779
+ // to report — never deleted, which is what a bad `json` field gets.
780
+ if (decl.format === 'logit-bias')
781
+ return readLogitBiasValue(value) ?? value;
690
782
  // `format: 'json'` fields hold parsed data; the renderer stringifies
691
783
  // for display and parses on submit, so either side may arrive here.
692
784
  if (decl.format === 'json' && typeof value === 'string') {