@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/scripts.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Script **types** — the fourth paradigm's contracts
|
|
2
|
+
* Script **types** — the fourth paradigm's contracts.
|
|
3
3
|
*
|
|
4
4
|
* A script is user-authored, typed text that transforms data at a declared
|
|
5
5
|
* point in a run: no SDK, no manifest, no build step. This module declares the
|
|
6
6
|
* *contracts* those texts conform to, not the texts themselves. The split is
|
|
7
|
-
* the same one prompts and prompt slots already have,
|
|
7
|
+
* the same one prompts and prompt slots already have, stated
|
|
8
8
|
* plainly: few types, declared by core and extensions and versioned by a
|
|
9
9
|
* content hash; many scripts, authored by users and stored as rows.
|
|
10
10
|
*
|
|
@@ -21,27 +21,29 @@
|
|
|
21
21
|
* The content segment is structural, not decorative: hook matching, chain
|
|
22
22
|
* homogeneity, panel grouping and import validation all read it, which is why
|
|
23
23
|
* it earns a delimiter rather than a hyphen convention. `text/stop` is
|
|
24
|
-
* filterable; `text-stop` is a naming habit
|
|
24
|
+
* filterable; `text-stop` is a naming habit.
|
|
25
25
|
*
|
|
26
26
|
* ⚠ This is the **one** compound kind, and the extension stops here. Node kinds
|
|
27
27
|
* are already segmented by kind and never grow qualifiers; scripts are
|
|
28
28
|
* segmented by payload because that is what decides which chain a link may join
|
|
29
29
|
* and which hook may accept it. Generalizing the grammar further is a non-goal.
|
|
30
30
|
*
|
|
31
|
-
* ⚠ The grammar is hard-frozen once the SDK publishes
|
|
31
|
+
* ⚠ The grammar is hard-frozen once the SDK publishes. Scripts are
|
|
32
32
|
* unshipped, so this is the free moment to extend it additively.
|
|
33
|
+
* @ruling 18 §1–§3, 18 §2, 18 §1, 07 §0g
|
|
33
34
|
*/
|
|
34
35
|
import type { I18n } from './descriptors.js';
|
|
35
36
|
import type { ShapeId } from './shapes.js';
|
|
36
37
|
/** `core:script:text/stop@1` — namespaced, segmented by payload, pinned. @experimental */
|
|
37
38
|
export type ScriptKindId = string;
|
|
38
39
|
/**
|
|
39
|
-
* What a chain of this operation *does* with what its links return
|
|
40
|
+
* What a chain of this operation *does* with what its links return.
|
|
40
41
|
*
|
|
41
42
|
* Declared per operation rather than per hook, because it is a property of the
|
|
42
43
|
* contract: two `text` operations differ precisely in whether their return
|
|
43
44
|
* flows onward or is consumed as a judgement.
|
|
44
45
|
* @experimental
|
|
46
|
+
* @ruling 18 §5
|
|
45
47
|
*/
|
|
46
48
|
export type ChainSemantics =
|
|
47
49
|
/**
|
|
@@ -70,10 +72,11 @@ export interface ScriptKindDecl {
|
|
|
70
72
|
* the same reason — copyediting a warning is not a contract change.
|
|
71
73
|
*
|
|
72
74
|
* Present on every type and deliberately blunt. Operations within a content
|
|
73
|
-
* scope *are* the permission granularity
|
|
75
|
+
* scope *are* the permission granularity: `messages/inject` split
|
|
74
76
|
* from `messages/transform` so a cautious user can accept injection chains
|
|
75
77
|
* while refusing rewrites, and that choice is only meaningful if the
|
|
76
78
|
* difference is stated where the choice is made.
|
|
79
|
+
* @ruling 18 §3
|
|
77
80
|
*/
|
|
78
81
|
blastRadius: I18n;
|
|
79
82
|
semantics: ChainSemantics;
|
|
@@ -84,10 +87,11 @@ export interface ScriptKindDecl {
|
|
|
84
87
|
* variables exist at its point and what extras it supplies; the type says
|
|
85
88
|
* what kind of thing flows. One `text/transform` therefore serves the input
|
|
86
89
|
* hook, the write hook and the display hook — placement is the hook's
|
|
87
|
-
* property, not the type's
|
|
90
|
+
* property, not the type's.
|
|
88
91
|
*
|
|
89
92
|
* A `verdict` operation declares `out` as what the hook consumes, which is
|
|
90
93
|
* never merged downstream.
|
|
94
|
+
* @ruling 18 §3
|
|
91
95
|
*/
|
|
92
96
|
ports: {
|
|
93
97
|
in: Record<string, ShapeId>;
|
|
@@ -110,22 +114,24 @@ export declare const isScriptKindId: (id: string) => boolean;
|
|
|
110
114
|
/**
|
|
111
115
|
* Parse, or throw with the grammar spelled out.
|
|
112
116
|
*
|
|
113
|
-
* Throwing beats returning null here for the reason
|
|
117
|
+
* Throwing beats returning null here for the same reason it does in template
|
|
114
118
|
* engines: a caller that gets `undefined` from a malformed id writes a fallback,
|
|
115
119
|
* and a fallback that half-works is how a script ends up attached to a hook
|
|
116
120
|
* nobody meant. An id is either well-formed or it is a bug in the thing that
|
|
117
121
|
* produced it.
|
|
118
122
|
* @internal
|
|
123
|
+
* @ruling 12 §2a
|
|
119
124
|
*/
|
|
120
125
|
export declare function parseScriptKindId(id: string): ParsedScriptKindId;
|
|
121
126
|
/**
|
|
122
|
-
* `content/operation` — what every link in one chain must share
|
|
127
|
+
* `content/operation` — what every link in one chain must share.
|
|
123
128
|
*
|
|
124
129
|
* Checkable off the id, which is the point of putting content in the grammar: a
|
|
125
130
|
* `candidates` script dropped into a `text/transform` chain refuses at attach
|
|
126
131
|
* rather than at run time, and neither the registry nor the script body has to
|
|
127
132
|
* be consulted to know it.
|
|
128
133
|
* @experimental
|
|
134
|
+
* @ruling 18 §5
|
|
129
135
|
*/
|
|
130
136
|
export declare const scriptSpace: (id: ScriptKindId) => string;
|
|
131
137
|
/**
|
|
@@ -154,6 +160,13 @@ export declare const allScriptKinds: () => ScriptKindDecl[];
|
|
|
154
160
|
export declare function _clearScriptKinds(): void;
|
|
155
161
|
/** @experimental */
|
|
156
162
|
export declare const textTransform: ScriptKindDecl;
|
|
163
|
+
/**
|
|
164
|
+
* The generic link: any JSON value in, any JSON value out. The body of a
|
|
165
|
+
* script step (`core:task/run-script@1`) — the one kind with no content scope
|
|
166
|
+
* of its own, so a step can carry a computation core never named.
|
|
167
|
+
* @experimental
|
|
168
|
+
*/
|
|
169
|
+
export declare const dataTransform: ScriptKindDecl;
|
|
157
170
|
/**
|
|
158
171
|
* ⚠ A verdict, not a transform, and the difference is load-bearing.
|
|
159
172
|
*
|
|
@@ -162,12 +175,13 @@ export declare const textTransform: ScriptKindDecl;
|
|
|
162
175
|
* every attached script evaluates independently and the earliest index wins.
|
|
163
176
|
* Order-free and commutative, which is exactly what makes merging the
|
|
164
177
|
* connection's chain with the pipeline's and the chat's well-defined without a
|
|
165
|
-
* precedence rule nobody would remember
|
|
178
|
+
* precedence rule nobody would remember.
|
|
166
179
|
*
|
|
167
|
-
* It is also the one type with a conformance law attached
|
|
180
|
+
* It is also the one type with a conformance law attached: the verdict is
|
|
168
181
|
* a function of the accumulated text only, never of chunk boundaries, or a
|
|
169
182
|
* reply replays differently than it streamed.
|
|
170
183
|
* @experimental
|
|
184
|
+
* @ruling 18 §5, S1
|
|
171
185
|
*/
|
|
172
186
|
export declare const textStop: ScriptKindDecl;
|
|
173
187
|
/**
|
|
@@ -193,7 +207,7 @@ export declare const contextTransform: ScriptKindDecl;
|
|
|
193
207
|
* The extracted cast, after the model has answered and the host has parsed.
|
|
194
208
|
*
|
|
195
209
|
* Its own content scope rather than a `context` operation, because chain
|
|
196
|
-
* homogeneity is keyed on content
|
|
210
|
+
* homogeneity is keyed on content and a cast is not a template
|
|
197
211
|
* context — a chain that could hold both would let a context edit land on a
|
|
198
212
|
* cast list by attachment mistake, silently. The scope is what makes the
|
|
199
213
|
* mistake refusable at attach.
|
|
@@ -205,10 +219,11 @@ export declare const contextTransform: ScriptKindDecl;
|
|
|
205
219
|
* rebind: a whole different extractor is a same-shaped provider, never a
|
|
206
220
|
* script, because scripts are pure compute and extraction calls a model.
|
|
207
221
|
* @experimental
|
|
222
|
+
* @ruling 18 §5
|
|
208
223
|
*/
|
|
209
224
|
export declare const castTransform: ScriptKindDecl;
|
|
210
225
|
/**
|
|
211
|
-
* Who speaks next, as a script
|
|
226
|
+
* Who speaks next, as a script.
|
|
212
227
|
*
|
|
213
228
|
* The one seam a plugin — or an admin, in the Scripts panel with no plugin at
|
|
214
229
|
* all — has for turn detection of its own. Core's `core:task/turn-scripted@1`
|
|
@@ -228,6 +243,7 @@ export declare const castTransform: ScriptKindDecl;
|
|
|
228
243
|
* naturally. Its own content scope for the reason `cast` has one: chain
|
|
229
244
|
* homogeneity is keyed on content, and a selection is not a cast.
|
|
230
245
|
* @experimental
|
|
246
|
+
* @ruling plans/19 §5 (second half; ruled 2026-09-21)
|
|
231
247
|
*/
|
|
232
248
|
export declare const turnSelect: ScriptKindDecl;
|
|
233
249
|
/**
|
|
@@ -235,9 +251,60 @@ export declare const turnSelect: ScriptKindDecl;
|
|
|
235
251
|
*
|
|
236
252
|
* Derived from the registry rather than restated, so a scope arrives the moment
|
|
237
253
|
* a type using it is declared — including an extension's. A hand-written list
|
|
238
|
-
* is the thing
|
|
254
|
+
* is the thing to avoid: a second taxonomy of what data is,
|
|
239
255
|
* kept in step by hand.
|
|
240
256
|
* @experimental
|
|
257
|
+
* @ruling 18 §1 rule 3
|
|
241
258
|
*/
|
|
242
259
|
export declare const scriptContentScopes: () => string[];
|
|
260
|
+
/**
|
|
261
|
+
* A **seam** — a place a script chain may run — spelled as one string.
|
|
262
|
+
*
|
|
263
|
+
* Three forms, one per kind of seam:
|
|
264
|
+
*
|
|
265
|
+
* - `in:<port>` — a `scripts` slot with `phase: 'before'` on in-port
|
|
266
|
+
* `<port>`: the chain runs over the value entering the binding
|
|
267
|
+
* (`create-message` → `in:text`).
|
|
268
|
+
* - `out:<port>` — a `scripts` slot with `phase: 'after'` on out-port
|
|
269
|
+
* `<port>`: the chain runs over what the binding published
|
|
270
|
+
* (`user-message` → `out:text`, `extract-cast`'s `castScripts` → `out:cast`).
|
|
271
|
+
* - `<pointKey>` — an interior point (`scriptPoints`), invoked by the binding
|
|
272
|
+
* through `ctx.scripts` (`each-draft`).
|
|
273
|
+
*
|
|
274
|
+
* The address is a *name*, not a storage address: chains stay stored at
|
|
275
|
+
* `config[nodeKey][slotName]['']` and `config[nodeKey].scripts[point]`.
|
|
276
|
+
* Typed as a plain string on its third branch, because a point key is any
|
|
277
|
+
* key a definition declares; `parseSeamAddress` is the reader.
|
|
278
|
+
* @experimental
|
|
279
|
+
*/
|
|
280
|
+
export type SeamAddress = `in:${string}` | `out:${string}` | string;
|
|
281
|
+
/** A parsed seam address. @experimental */
|
|
282
|
+
export interface ParsedSeamAddress {
|
|
283
|
+
kind: 'in' | 'out' | 'point';
|
|
284
|
+
/** The port for `in`/`out`; the point key for `point`. */
|
|
285
|
+
name: string;
|
|
286
|
+
}
|
|
287
|
+
/** A `scripts` slot's placement, as the seam address reads it. Structural, so a registry row's slot fits. @experimental */
|
|
288
|
+
export interface SeamSlotPlacement {
|
|
289
|
+
port?: string;
|
|
290
|
+
phase?: 'before' | 'after' | string;
|
|
291
|
+
}
|
|
292
|
+
/** An interior point, as the seam address reads it. @experimental */
|
|
293
|
+
export interface SeamPointPlacement {
|
|
294
|
+
key: string;
|
|
295
|
+
}
|
|
296
|
+
/**
|
|
297
|
+
* The seam address of a declaration: a `scripts` slot `{ port, phase }`
|
|
298
|
+
* (defaults `'main'` and `'before'`, the executor's) or an interior point
|
|
299
|
+
* `{ key }`. The one place the spelling is computed.
|
|
300
|
+
* @experimental
|
|
301
|
+
*/
|
|
302
|
+
export declare function seamAddressOf(decl: SeamSlotPlacement | SeamPointPlacement): SeamAddress;
|
|
303
|
+
/**
|
|
304
|
+
* Parse a seam address, or throw with the grammar spelled out — for the
|
|
305
|
+
* reason `parseScriptKindId` gives: a fallback that half-works is how a chain
|
|
306
|
+
* ends up somewhere nobody meant.
|
|
307
|
+
* @experimental
|
|
308
|
+
*/
|
|
309
|
+
export declare function parseSeamAddress(at: string): ParsedSeamAddress;
|
|
243
310
|
//# sourceMappingURL=scripts.d.ts.map
|
package/dist/scripts.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Script **types** — the fourth paradigm's contracts
|
|
2
|
+
* Script **types** — the fourth paradigm's contracts.
|
|
3
3
|
*
|
|
4
4
|
* A script is user-authored, typed text that transforms data at a declared
|
|
5
5
|
* point in a run: no SDK, no manifest, no build step. This module declares the
|
|
6
6
|
* *contracts* those texts conform to, not the texts themselves. The split is
|
|
7
|
-
* the same one prompts and prompt slots already have,
|
|
7
|
+
* the same one prompts and prompt slots already have, stated
|
|
8
8
|
* plainly: few types, declared by core and extensions and versioned by a
|
|
9
9
|
* content hash; many scripts, authored by users and stored as rows.
|
|
10
10
|
*
|
|
@@ -21,15 +21,16 @@
|
|
|
21
21
|
* The content segment is structural, not decorative: hook matching, chain
|
|
22
22
|
* homogeneity, panel grouping and import validation all read it, which is why
|
|
23
23
|
* it earns a delimiter rather than a hyphen convention. `text/stop` is
|
|
24
|
-
* filterable; `text-stop` is a naming habit
|
|
24
|
+
* filterable; `text-stop` is a naming habit.
|
|
25
25
|
*
|
|
26
26
|
* ⚠ This is the **one** compound kind, and the extension stops here. Node kinds
|
|
27
27
|
* are already segmented by kind and never grow qualifiers; scripts are
|
|
28
28
|
* segmented by payload because that is what decides which chain a link may join
|
|
29
29
|
* and which hook may accept it. Generalizing the grammar further is a non-goal.
|
|
30
30
|
*
|
|
31
|
-
* ⚠ The grammar is hard-frozen once the SDK publishes
|
|
31
|
+
* ⚠ The grammar is hard-frozen once the SDK publishes. Scripts are
|
|
32
32
|
* unshipped, so this is the free moment to extend it additively.
|
|
33
|
+
* @ruling 18 §1–§3, 18 §2, 18 §1, 07 §0g
|
|
33
34
|
*/
|
|
34
35
|
import { i18nFindings } from './i18n.js';
|
|
35
36
|
import { refuseUnlessIdentical } from './hash.js';
|
|
@@ -39,12 +40,13 @@ export const isScriptKindId = (id) => SCRIPT_ID.test(id);
|
|
|
39
40
|
/**
|
|
40
41
|
* Parse, or throw with the grammar spelled out.
|
|
41
42
|
*
|
|
42
|
-
* Throwing beats returning null here for the reason
|
|
43
|
+
* Throwing beats returning null here for the same reason it does in template
|
|
43
44
|
* engines: a caller that gets `undefined` from a malformed id writes a fallback,
|
|
44
45
|
* and a fallback that half-works is how a script ends up attached to a hook
|
|
45
46
|
* nobody meant. An id is either well-formed or it is a bug in the thing that
|
|
46
47
|
* produced it.
|
|
47
48
|
* @internal
|
|
49
|
+
* @ruling 12 §2a
|
|
48
50
|
*/
|
|
49
51
|
export function parseScriptKindId(id) {
|
|
50
52
|
const m = SCRIPT_ID.exec(id);
|
|
@@ -65,13 +67,14 @@ export function parseScriptKindId(id) {
|
|
|
65
67
|
};
|
|
66
68
|
}
|
|
67
69
|
/**
|
|
68
|
-
* `content/operation` — what every link in one chain must share
|
|
70
|
+
* `content/operation` — what every link in one chain must share.
|
|
69
71
|
*
|
|
70
72
|
* Checkable off the id, which is the point of putting content in the grammar: a
|
|
71
73
|
* `candidates` script dropped into a `text/transform` chain refuses at attach
|
|
72
74
|
* rather than at run time, and neither the registry nor the script body has to
|
|
73
75
|
* be consulted to know it.
|
|
74
76
|
* @experimental
|
|
77
|
+
* @ruling 18 §5
|
|
75
78
|
*/
|
|
76
79
|
export const scriptSpace = (id) => parseScriptKindId(id).space;
|
|
77
80
|
const scriptTypes = new Map();
|
|
@@ -155,6 +158,24 @@ export const textTransform = defineScriptKind({
|
|
|
155
158
|
semantics: 'transform',
|
|
156
159
|
ports: { in: { text: TEXT }, out: { text: TEXT } },
|
|
157
160
|
});
|
|
161
|
+
/**
|
|
162
|
+
* The generic link: any JSON value in, any JSON value out. The body of a
|
|
163
|
+
* script step (`core:task/run-script@1`) — the one kind with no content scope
|
|
164
|
+
* of its own, so a step can carry a computation core never named.
|
|
165
|
+
* @experimental
|
|
166
|
+
*/
|
|
167
|
+
export const dataTransform = defineScriptKind({
|
|
168
|
+
id: 'core:script:data/transform@1',
|
|
169
|
+
i18n: {
|
|
170
|
+
name: { en: 'Transform data' },
|
|
171
|
+
description: {
|
|
172
|
+
en: 'Takes a JSON value and returns a JSON value — the body of a script step.',
|
|
173
|
+
},
|
|
174
|
+
},
|
|
175
|
+
blastRadius: { en: 'Rewrites one value' },
|
|
176
|
+
semantics: 'transform',
|
|
177
|
+
ports: { in: { value: JSON_SHAPE }, out: { value: JSON_SHAPE } },
|
|
178
|
+
});
|
|
158
179
|
/**
|
|
159
180
|
* ⚠ A verdict, not a transform, and the difference is load-bearing.
|
|
160
181
|
*
|
|
@@ -163,12 +184,13 @@ export const textTransform = defineScriptKind({
|
|
|
163
184
|
* every attached script evaluates independently and the earliest index wins.
|
|
164
185
|
* Order-free and commutative, which is exactly what makes merging the
|
|
165
186
|
* connection's chain with the pipeline's and the chat's well-defined without a
|
|
166
|
-
* precedence rule nobody would remember
|
|
187
|
+
* precedence rule nobody would remember.
|
|
167
188
|
*
|
|
168
|
-
* It is also the one type with a conformance law attached
|
|
189
|
+
* It is also the one type with a conformance law attached: the verdict is
|
|
169
190
|
* a function of the accumulated text only, never of chunk boundaries, or a
|
|
170
191
|
* reply replays differently than it streamed.
|
|
171
192
|
* @experimental
|
|
193
|
+
* @ruling 18 §5, S1
|
|
172
194
|
*/
|
|
173
195
|
export const textStop = defineScriptKind({
|
|
174
196
|
id: 'core:script:text/stop@1',
|
|
@@ -252,7 +274,7 @@ export const contextTransform = defineScriptKind({
|
|
|
252
274
|
* The extracted cast, after the model has answered and the host has parsed.
|
|
253
275
|
*
|
|
254
276
|
* Its own content scope rather than a `context` operation, because chain
|
|
255
|
-
* homogeneity is keyed on content
|
|
277
|
+
* homogeneity is keyed on content and a cast is not a template
|
|
256
278
|
* context — a chain that could hold both would let a context edit land on a
|
|
257
279
|
* cast list by attachment mistake, silently. The scope is what makes the
|
|
258
280
|
* mistake refusable at attach.
|
|
@@ -264,6 +286,7 @@ export const contextTransform = defineScriptKind({
|
|
|
264
286
|
* rebind: a whole different extractor is a same-shaped provider, never a
|
|
265
287
|
* script, because scripts are pure compute and extraction calls a model.
|
|
266
288
|
* @experimental
|
|
289
|
+
* @ruling 18 §5
|
|
267
290
|
*/
|
|
268
291
|
export const castTransform = defineScriptKind({
|
|
269
292
|
id: 'core:script:cast/transform@1',
|
|
@@ -278,7 +301,7 @@ export const castTransform = defineScriptKind({
|
|
|
278
301
|
ports: { in: { cast: JSON_SHAPE }, out: { cast: JSON_SHAPE } },
|
|
279
302
|
});
|
|
280
303
|
/**
|
|
281
|
-
* Who speaks next, as a script
|
|
304
|
+
* Who speaks next, as a script.
|
|
282
305
|
*
|
|
283
306
|
* The one seam a plugin — or an admin, in the Scripts panel with no plugin at
|
|
284
307
|
* all — has for turn detection of its own. Core's `core:task/turn-scripted@1`
|
|
@@ -298,6 +321,7 @@ export const castTransform = defineScriptKind({
|
|
|
298
321
|
* naturally. Its own content scope for the reason `cast` has one: chain
|
|
299
322
|
* homogeneity is keyed on content, and a selection is not a cast.
|
|
300
323
|
* @experimental
|
|
324
|
+
* @ruling plans/19 §5 (second half; ruled 2026-09-21)
|
|
301
325
|
*/
|
|
302
326
|
export const turnSelect = defineScriptKind({
|
|
303
327
|
id: 'core:script:turn/select@1',
|
|
@@ -316,11 +340,66 @@ export const turnSelect = defineScriptKind({
|
|
|
316
340
|
*
|
|
317
341
|
* Derived from the registry rather than restated, so a scope arrives the moment
|
|
318
342
|
* a type using it is declared — including an extension's. A hand-written list
|
|
319
|
-
* is the thing
|
|
343
|
+
* is the thing to avoid: a second taxonomy of what data is,
|
|
320
344
|
* kept in step by hand.
|
|
321
345
|
* @experimental
|
|
346
|
+
* @ruling 18 §1 rule 3
|
|
322
347
|
*/
|
|
323
348
|
export const scriptContentScopes = () => [
|
|
324
349
|
...new Set(allScriptKinds().map((t) => parseScriptKindId(t.id).content)),
|
|
325
350
|
];
|
|
351
|
+
// Loose on purpose: ports and point keys are whatever a definition declares, and
|
|
352
|
+
// the executor resolves seams through this reader, so a stricter grammar would
|
|
353
|
+
// refuse a run over a name `register()` accepted. Only what would make the
|
|
354
|
+
// address ambiguous is refused: empty, whitespace, a second ':'.
|
|
355
|
+
const SEAM_NAME = /^[^\s:]+$/;
|
|
356
|
+
const seamGrammar = (at) => `'${at}' is not a valid seam address. The grammar is 'in:<port>' (a scripts slot, ` +
|
|
357
|
+
`phase 'before', on that in-port), 'out:<port>' (phase 'after', on that out-port) ` +
|
|
358
|
+
`or a bare '<pointKey>' (an interior script point) — 'in:text', 'out:cast', 'each-draft'. ` +
|
|
359
|
+
`A port name or point key is non-empty, with no whitespace and no ':'.`;
|
|
360
|
+
/**
|
|
361
|
+
* The seam address of a declaration: a `scripts` slot `{ port, phase }`
|
|
362
|
+
* (defaults `'main'` and `'before'`, the executor's) or an interior point
|
|
363
|
+
* `{ key }`. The one place the spelling is computed.
|
|
364
|
+
* @experimental
|
|
365
|
+
*/
|
|
366
|
+
export function seamAddressOf(decl) {
|
|
367
|
+
if ('key' in decl && typeof decl.key === 'string') {
|
|
368
|
+
const key = decl.key;
|
|
369
|
+
parseSeamAddress(key);
|
|
370
|
+
if (key.includes(':'))
|
|
371
|
+
throw new Error(seamGrammar(key));
|
|
372
|
+
return key;
|
|
373
|
+
}
|
|
374
|
+
const slot = decl;
|
|
375
|
+
const port = slot.port ?? 'main';
|
|
376
|
+
const phase = slot.phase ?? 'before';
|
|
377
|
+
if (phase !== 'before' && phase !== 'after')
|
|
378
|
+
throw new Error(`A scripts slot's phase is 'before' or 'after', not '${String(phase)}' — ` +
|
|
379
|
+
`'before' runs over the in-port's value, 'after' over the out-port's.`);
|
|
380
|
+
const at = `${phase === 'before' ? 'in' : 'out'}:${port}`;
|
|
381
|
+
parseSeamAddress(at);
|
|
382
|
+
return at;
|
|
383
|
+
}
|
|
384
|
+
/**
|
|
385
|
+
* Parse a seam address, or throw with the grammar spelled out — for the
|
|
386
|
+
* reason `parseScriptKindId` gives: a fallback that half-works is how a chain
|
|
387
|
+
* ends up somewhere nobody meant.
|
|
388
|
+
* @experimental
|
|
389
|
+
*/
|
|
390
|
+
export function parseSeamAddress(at) {
|
|
391
|
+
if (typeof at !== 'string' || at.length === 0)
|
|
392
|
+
throw new Error(seamGrammar(String(at)));
|
|
393
|
+
const colon = at.indexOf(':');
|
|
394
|
+
if (colon === -1) {
|
|
395
|
+
if (!SEAM_NAME.test(at))
|
|
396
|
+
throw new Error(seamGrammar(at));
|
|
397
|
+
return { kind: 'point', name: at };
|
|
398
|
+
}
|
|
399
|
+
const head = at.slice(0, colon);
|
|
400
|
+
const name = at.slice(colon + 1);
|
|
401
|
+
if ((head !== 'in' && head !== 'out') || !SEAM_NAME.test(name))
|
|
402
|
+
throw new Error(seamGrammar(at));
|
|
403
|
+
return { kind: head, name };
|
|
404
|
+
}
|
|
326
405
|
//# sourceMappingURL=scripts.js.map
|