@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.
- package/README.md +24 -20
- package/dist/actions.d.ts +150 -68
- package/dist/actions.js +90 -36
- package/dist/annexFields.d.ts +8 -4
- package/dist/annexFields.js +5 -2
- package/dist/announce.d.ts +78 -28
- package/dist/announce.js +14 -5
- package/dist/attributes.d.ts +9 -6
- package/dist/attributes.js +9 -5
- package/dist/bands.d.ts +41 -6
- package/dist/bands.js +83 -33
- package/dist/builder.d.ts +161 -58
- package/dist/builder.js +128 -22
- package/dist/candidates.d.ts +5 -3
- package/dist/candidates.js +3 -2
- package/dist/clauses.d.ts +2 -1
- package/dist/clauses.js +2 -1
- package/dist/component.d.ts +24 -7
- package/dist/component.js +16 -6
- package/dist/componentBuild.d.ts +16 -5
- package/dist/componentBuild.js +14 -5
- package/dist/componentClient.d.ts +61 -30
- package/dist/componentClient.js +11 -1
- package/dist/componentImports.d.ts +8 -5
- package/dist/componentImports.js +23 -4
- package/dist/componentModule.js +2 -1
- package/dist/componentWire.d.ts +2 -1
- package/dist/componentWire.js +34 -2
- package/dist/config.d.ts +28 -14
- package/dist/config.js +20 -10
- package/dist/connections.d.ts +9 -4
- package/dist/connections.js +7 -4
- package/dist/declarations.d.ts +46 -17
- package/dist/declarations.js +46 -15
- package/dist/descriptors.d.ts +242 -97
- package/dist/descriptors.js +145 -41
- package/dist/dev.d.ts +6 -5
- package/dist/dev.js +6 -5
- package/dist/document.d.ts +74 -25
- package/dist/document.js +32 -11
- package/dist/dowry.d.ts +241 -0
- package/dist/dowry.js +315 -0
- package/dist/engines.d.ts +16 -7
- package/dist/engines.js +6 -4
- package/dist/eventMapLaws.d.ts +19 -8
- package/dist/eventMapLaws.js +9 -6
- package/dist/events.d.ts +101 -39
- package/dist/events.js +106 -33
- package/dist/executor.d.ts +122 -41
- package/dist/executor.js +195 -96
- package/dist/extension.d.ts +99 -35
- package/dist/extension.js +43 -9
- package/dist/facets.d.ts +2 -1
- package/dist/facets.js +4 -2
- package/dist/foldedSections.d.ts +4 -2
- package/dist/foldedSections.js +2 -1
- package/dist/genres.d.ts +123 -41
- package/dist/genres.js +127 -22
- package/dist/guardedConnection.d.ts +4 -3
- package/dist/guardedConnection.js +4 -3
- package/dist/handlebarsReach.d.ts +1 -1
- package/dist/handlebarsReach.js +1 -1
- package/dist/hash.d.ts +16 -5
- package/dist/hash.js +14 -4
- package/dist/hookGrants.d.ts +3 -2
- package/dist/hookGrants.js +6 -4
- package/dist/hooks.d.ts +21 -16
- package/dist/hooks.js +12 -10
- package/dist/hostElements.d.ts +41 -17
- package/dist/hostElements.js +49 -17
- package/dist/i18n.d.ts +5 -3
- package/dist/i18n.js +5 -3
- package/dist/identity.d.ts +5 -4
- package/dist/identity.js +5 -4
- package/dist/index.d.ts +5 -0
- package/dist/index.js +15 -0
- package/dist/layout.d.ts +36 -15
- package/dist/layout.js +2 -2
- package/dist/loadouts.d.ts +97 -0
- package/dist/loadouts.js +81 -0
- package/dist/media.d.ts +26 -4
- package/dist/media.js +2 -1
- package/dist/messageBlocks.d.ts +44 -32
- package/dist/messageBlocks.js +23 -18
- package/dist/migration.d.ts +16 -8
- package/dist/migration.js +14 -8
- package/dist/names.d.ts +2 -1
- package/dist/names.js +2 -1
- package/dist/nodeInput.d.ts +2 -1
- package/dist/nodeInput.js +2 -1
- package/dist/participants.d.ts +22 -15
- package/dist/participants.js +14 -12
- package/dist/personGate.d.ts +2 -1
- package/dist/personGate.js +2 -1
- package/dist/pluginHarness.d.ts +8 -3
- package/dist/pluginHarness.js +4 -2
- package/dist/pluginPermissions.d.ts +2 -1
- package/dist/pluginPermissions.js +12 -1
- package/dist/pluginRuleRef.d.ts +2 -2
- package/dist/pluginRuleRef.js +1 -1
- package/dist/predicates.d.ts +16 -11
- package/dist/predicates.js +7 -6
- package/dist/preview.d.ts +8 -3
- package/dist/preview.js +2 -1
- package/dist/promptBlocks.d.ts +5 -3
- package/dist/promptBlocks.js +5 -3
- package/dist/rankingDecisions.d.ts +2 -1
- package/dist/rankingDecisions.js +2 -1
- package/dist/receipt.d.ts +65 -29
- package/dist/receipt.js +9 -4
- package/dist/receiverRules.js +3 -2
- package/dist/refs.d.ts +34 -9
- package/dist/refs.js +33 -13
- package/dist/registry.d.ts +42 -23
- package/dist/registry.js +7 -5
- package/dist/review.d.ts +16 -5
- package/dist/review.js +11 -4
- package/dist/sampling.d.ts +54 -0
- package/dist/sampling.js +95 -3
- package/dist/sceneSettings.d.ts +312 -0
- package/dist/sceneSettings.js +425 -0
- package/dist/scope.d.ts +6 -4
- package/dist/scope.js +4 -3
- package/dist/scripts.d.ts +81 -14
- package/dist/scripts.js +90 -11
- package/dist/sessionDossier.d.ts +521 -0
- package/dist/sessionDossier.js +33 -0
- package/dist/sessionLayout.d.ts +303 -19
- package/dist/sessionLayout.js +354 -40
- package/dist/sessionSettings.d.ts +8 -5
- package/dist/settings.d.ts +45 -20
- package/dist/settings.js +19 -12
- package/dist/settingsSlot.d.ts +11 -8
- package/dist/settingsSlot.js +11 -8
- package/dist/shapes.d.ts +103 -41
- package/dist/shapes.js +105 -40
- package/dist/sheets.d.ts +4 -2
- package/dist/sheets.js +6 -3
- package/dist/statShapes.d.ts +2 -1
- package/dist/statShapes.js +2 -1
- package/dist/status.d.ts +13 -9
- package/dist/status.js +8 -6
- package/dist/storage.d.ts +2 -1
- package/dist/storage.js +2 -1
- package/dist/storyTime.d.ts +13 -7
- package/dist/storyTime.js +11 -6
- package/dist/strokes.d.ts +176 -0
- package/dist/strokes.js +281 -0
- package/dist/surfaces.d.ts +54 -25
- package/dist/surfaces.js +3 -3
- package/dist/template.d.ts +9 -5
- package/dist/template.js +5 -3
- package/dist/templateCheck.d.ts +2 -2
- package/dist/templateCheck.js +2 -2
- package/dist/templateFit.d.ts +37 -8
- package/dist/templateFit.js +92 -8
- package/dist/templateIds.d.ts +3 -3
- package/dist/templateIds.js +3 -3
- package/dist/templateScopeAt.d.ts +21 -11
- package/dist/templateScopeAt.js +21 -11
- package/dist/testing.d.ts +11 -4
- package/dist/testing.js +13 -5
- package/dist/tokenizers.d.ts +2 -2
- package/dist/tokenizers.js +2 -2
- package/dist/turnLock.d.ts +4 -2
- package/dist/turnLock.js +2 -1
- package/dist/turnOrder.d.ts +17 -11
- package/dist/turnOrder.js +9 -5
- package/dist/validate.d.ts +11 -8
- package/dist/validate.js +81 -10
- package/dist/values.d.ts +17 -8
- package/dist/values.js +11 -6
- package/dist/variables.d.ts +46 -7
- package/dist/variables.js +87 -6
- package/dist/verdicts.d.ts +20 -13
- package/dist/verdicts.js +17 -11
- package/dist/widgetDecls.d.ts +8 -4
- package/dist/widgetDecls.js +4 -2
- package/dist/widgets.d.ts +987 -94
- package/dist/widgets.js +93 -18
- package/dist/wire.d.ts +13 -6
- package/dist/wire.js +3 -3
- package/dist/worldinfo.d.ts +11 -6
- package/dist/worldinfo.js +8 -4
- package/host-elements.d.ts +13 -0
- package/package.json +1 -1
package/dist/registry.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* The pipeline type registry
|
|
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
|
|
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 —
|
|
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
|
|
38
|
+
* A `pipeline_definition_registry` row, as data.
|
|
38
39
|
*
|
|
39
|
-
* Two halves, and the row carries both
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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.
|
|
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
|
|
112
|
+
* and is the exact thing core must never reach for.
|
|
108
113
|
*
|
|
109
|
-
* Storing the declaration makes the pipeline view
|
|
110
|
-
*
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
-
/**
|
|
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
|
|
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
|
-
/**
|
|
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
|
-
/**
|
|
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
|
|
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
|
|
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 —
|
|
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.
|
|
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
|
|
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
|
|
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
|
-
/**
|
|
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
|
|
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
|
|
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
|
-
/**
|
|
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
|
|
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
|
|
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
|
|
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
|
-
/**
|
|
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
|
}
|
package/dist/sampling.d.ts
CHANGED
|
@@ -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: '
|
|
478
|
+
format: 'logit-bias',
|
|
393
479
|
label: 'Logit Bias',
|
|
394
|
-
description: '
|
|
395
|
-
|
|
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') {
|