@serene-pub/sdk 0.6.0-pr-1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (187) hide show
  1. package/LICENSE +202 -0
  2. package/NOTICE +17 -0
  3. package/README.md +368 -0
  4. package/dist/actions.d.ts +572 -0
  5. package/dist/actions.js +829 -0
  6. package/dist/annexFields.d.ts +234 -0
  7. package/dist/annexFields.js +413 -0
  8. package/dist/announce.d.ts +464 -0
  9. package/dist/announce.js +426 -0
  10. package/dist/attributes.d.ts +670 -0
  11. package/dist/attributes.js +904 -0
  12. package/dist/bands.d.ts +125 -0
  13. package/dist/bands.js +256 -0
  14. package/dist/builder.d.ts +683 -0
  15. package/dist/builder.js +677 -0
  16. package/dist/candidates.d.ts +109 -0
  17. package/dist/candidates.js +118 -0
  18. package/dist/capabilities.d.ts +744 -0
  19. package/dist/capabilities.js +679 -0
  20. package/dist/channels.d.ts +106 -0
  21. package/dist/channels.js +129 -0
  22. package/dist/clauses.d.ts +40 -0
  23. package/dist/clauses.js +43 -0
  24. package/dist/component.d.ts +33 -0
  25. package/dist/component.js +27 -0
  26. package/dist/componentBuild.d.ts +48 -0
  27. package/dist/componentBuild.js +84 -0
  28. package/dist/componentClient.d.ts +100 -0
  29. package/dist/componentClient.js +13 -0
  30. package/dist/componentImports.d.ts +51 -0
  31. package/dist/componentImports.js +106 -0
  32. package/dist/componentModule.d.ts +8 -0
  33. package/dist/componentModule.js +270 -0
  34. package/dist/componentWire.d.ts +130 -0
  35. package/dist/componentWire.js +280 -0
  36. package/dist/config.d.ts +295 -0
  37. package/dist/config.js +231 -0
  38. package/dist/connections.d.ts +89 -0
  39. package/dist/connections.js +131 -0
  40. package/dist/declarations.d.ts +290 -0
  41. package/dist/declarations.js +794 -0
  42. package/dist/descriptors.d.ts +1774 -0
  43. package/dist/descriptors.js +1329 -0
  44. package/dist/dev.d.ts +136 -0
  45. package/dist/dev.js +161 -0
  46. package/dist/document.d.ts +202 -0
  47. package/dist/document.js +312 -0
  48. package/dist/engines.d.ts +117 -0
  49. package/dist/engines.js +203 -0
  50. package/dist/eventMapLaws.d.ts +63 -0
  51. package/dist/eventMapLaws.js +128 -0
  52. package/dist/events.d.ts +554 -0
  53. package/dist/events.js +633 -0
  54. package/dist/executor.d.ts +771 -0
  55. package/dist/executor.js +1829 -0
  56. package/dist/extension.d.ts +448 -0
  57. package/dist/extension.js +315 -0
  58. package/dist/facets.d.ts +53 -0
  59. package/dist/facets.js +60 -0
  60. package/dist/foldedSections.d.ts +74 -0
  61. package/dist/foldedSections.js +161 -0
  62. package/dist/genres.d.ts +507 -0
  63. package/dist/genres.js +633 -0
  64. package/dist/guardedConnection.d.ts +138 -0
  65. package/dist/guardedConnection.js +341 -0
  66. package/dist/handlebarsReach.d.ts +122 -0
  67. package/dist/handlebarsReach.js +222 -0
  68. package/dist/hash.d.ts +146 -0
  69. package/dist/hash.js +166 -0
  70. package/dist/hookGrants.d.ts +47 -0
  71. package/dist/hookGrants.js +68 -0
  72. package/dist/hooks.d.ts +290 -0
  73. package/dist/hooks.js +113 -0
  74. package/dist/hostElements.d.ts +447 -0
  75. package/dist/hostElements.js +702 -0
  76. package/dist/i18n.d.ts +94 -0
  77. package/dist/i18n.js +123 -0
  78. package/dist/identity.d.ts +93 -0
  79. package/dist/identity.js +135 -0
  80. package/dist/index.d.ts +85 -0
  81. package/dist/index.js +176 -0
  82. package/dist/layout.d.ts +194 -0
  83. package/dist/layout.js +40 -0
  84. package/dist/media.d.ts +202 -0
  85. package/dist/media.js +70 -0
  86. package/dist/messageBlocks.d.ts +487 -0
  87. package/dist/messageBlocks.js +683 -0
  88. package/dist/migration.d.ts +128 -0
  89. package/dist/migration.js +261 -0
  90. package/dist/names.d.ts +78 -0
  91. package/dist/names.js +136 -0
  92. package/dist/nodeInput.d.ts +399 -0
  93. package/dist/nodeInput.js +178 -0
  94. package/dist/participants.d.ts +291 -0
  95. package/dist/participants.js +252 -0
  96. package/dist/personGate.d.ts +62 -0
  97. package/dist/personGate.js +77 -0
  98. package/dist/pick.d.ts +84 -0
  99. package/dist/pick.js +103 -0
  100. package/dist/pluginHarness.d.ts +235 -0
  101. package/dist/pluginHarness.js +558 -0
  102. package/dist/pluginPermissions.d.ts +25 -0
  103. package/dist/pluginPermissions.js +97 -0
  104. package/dist/pluginRuleRef.d.ts +13 -0
  105. package/dist/pluginRuleRef.js +10 -0
  106. package/dist/predicates.d.ts +182 -0
  107. package/dist/predicates.js +249 -0
  108. package/dist/preview.d.ts +120 -0
  109. package/dist/preview.js +82 -0
  110. package/dist/promptBlocks.d.ts +130 -0
  111. package/dist/promptBlocks.js +197 -0
  112. package/dist/rankingDecisions.d.ts +60 -0
  113. package/dist/rankingDecisions.js +48 -0
  114. package/dist/receipt.d.ts +313 -0
  115. package/dist/receipt.js +60 -0
  116. package/dist/receiverRules.d.ts +24 -0
  117. package/dist/receiverRules.js +94 -0
  118. package/dist/refs.d.ts +117 -0
  119. package/dist/refs.js +137 -0
  120. package/dist/registry.d.ts +230 -0
  121. package/dist/registry.js +273 -0
  122. package/dist/review.d.ts +108 -0
  123. package/dist/review.js +97 -0
  124. package/dist/sampling.d.ts +152 -0
  125. package/dist/sampling.js +712 -0
  126. package/dist/scope.d.ts +65 -0
  127. package/dist/scope.js +128 -0
  128. package/dist/scripts.d.ts +243 -0
  129. package/dist/scripts.js +326 -0
  130. package/dist/sessionLayout.d.ts +339 -0
  131. package/dist/sessionLayout.js +503 -0
  132. package/dist/sessionSettings.d.ts +70 -0
  133. package/dist/sessionSettings.js +2 -0
  134. package/dist/settings.d.ts +501 -0
  135. package/dist/settings.js +604 -0
  136. package/dist/settingsSlot.d.ts +108 -0
  137. package/dist/settingsSlot.js +166 -0
  138. package/dist/shapes.d.ts +373 -0
  139. package/dist/shapes.js +408 -0
  140. package/dist/sheets.d.ts +165 -0
  141. package/dist/sheets.js +251 -0
  142. package/dist/statShapes.d.ts +96 -0
  143. package/dist/statShapes.js +112 -0
  144. package/dist/status.d.ts +103 -0
  145. package/dist/status.js +125 -0
  146. package/dist/storage.d.ts +145 -0
  147. package/dist/storage.js +33 -0
  148. package/dist/storyTime.d.ts +308 -0
  149. package/dist/storyTime.js +560 -0
  150. package/dist/surfaces.d.ts +501 -0
  151. package/dist/surfaces.js +292 -0
  152. package/dist/template.d.ts +312 -0
  153. package/dist/template.js +554 -0
  154. package/dist/templateCheck.d.ts +60 -0
  155. package/dist/templateCheck.js +516 -0
  156. package/dist/templateFit.d.ts +157 -0
  157. package/dist/templateFit.js +349 -0
  158. package/dist/templateIds.d.ts +138 -0
  159. package/dist/templateIds.js +144 -0
  160. package/dist/templateScopeAt.d.ts +131 -0
  161. package/dist/templateScopeAt.js +354 -0
  162. package/dist/testing.d.ts +177 -0
  163. package/dist/testing.js +383 -0
  164. package/dist/tokenizers.d.ts +113 -0
  165. package/dist/tokenizers.js +184 -0
  166. package/dist/turnLock.d.ts +96 -0
  167. package/dist/turnLock.js +79 -0
  168. package/dist/turnOrder.d.ts +143 -0
  169. package/dist/turnOrder.js +128 -0
  170. package/dist/validate.d.ts +74 -0
  171. package/dist/validate.js +1399 -0
  172. package/dist/values.d.ts +212 -0
  173. package/dist/values.js +390 -0
  174. package/dist/variables.d.ts +493 -0
  175. package/dist/variables.js +662 -0
  176. package/dist/verdicts.d.ts +275 -0
  177. package/dist/verdicts.js +348 -0
  178. package/dist/widgetDecls.d.ts +88 -0
  179. package/dist/widgetDecls.js +119 -0
  180. package/dist/widgets.d.ts +1527 -0
  181. package/dist/widgets.js +208 -0
  182. package/dist/wire.d.ts +126 -0
  183. package/dist/wire.js +140 -0
  184. package/dist/worldinfo.d.ts +150 -0
  185. package/dist/worldinfo.js +212 -0
  186. package/host-elements.d.ts +914 -0
  187. package/package.json +67 -0
@@ -0,0 +1,65 @@
1
+ /**
2
+ * The typed chain scope — `$.history.messages` instead of `$ref('history', 'messages')`.
3
+ *
4
+ * Why this is worth machinery. `$ref` takes two strings, and strings are where the
5
+ * remaining classes of authoring mistake live in this SDK: a mistyped node key, a
6
+ * mistyped port, a reference to a node that does not exist *yet*. All three were
7
+ * publish-time findings. With a scope object accumulated as the chain is built, all
8
+ * three become **compile errors**, which is the same move the kind-named methods made
9
+ * for the five laws they enforce (04 §4a).
10
+ *
11
+ * The one that matters most is the third. `$` contains only the nodes declared *above*
12
+ * the call, so a reference to a later node does not type-check — **"no back-edges" (F9)
13
+ * stops being a rule the validator checks and becomes a thing you cannot write.**
14
+ *
15
+ * Nothing about the compiled document changes. A scope access produces exactly the
16
+ * `DataRef` that `$ref` produces, so the rows, the edges and the canonical hash are
17
+ * byte-identical (F3, F6). This is authoring sugar over an unchanged value.
18
+ */
19
+ import { type DataRef } from './refs.js';
20
+ import type { PortDecl } from './descriptors.js';
21
+ /**
22
+ * A node accessor. It **is** a ref to `main`, and property access refines the port —
23
+ * so `$.generate` and `$.generate.text` are both legal and mean what they look like.
24
+ * @experimental
25
+ */
26
+ export type NodeAccessor<Out extends PortDecl> = DataRef & {
27
+ readonly [K in keyof Out]: DataRef;
28
+ };
29
+ /**
30
+ * Node keys accumulate **flat and dotted** — `'gather.semantic.embed'` — because that is
31
+ * exactly what the row's `node_key` is (F21). The scope then expands them back into a
32
+ * nested shape, so `$.gather.semantic.embed.vector` reads like the key it compiles to.
33
+ *
34
+ * Blocks are not nodes, so a block name alone is not a ref: `$.gather` is a path, and
35
+ * only the leaf carries the accessor. That falls out of the split below rather than
36
+ * needing a rule.
37
+ */
38
+ type Head<K extends string> = K extends `${infer H}.${string}` ? H : K;
39
+ type ChildrenOf<N, H extends string> = {
40
+ [K in keyof N & string as K extends `${H}.${infer R}` ? R : never]: N[K];
41
+ };
42
+ type Nested<N> = {
43
+ readonly [H in Head<keyof N & string>]: (H extends keyof N ? NodeAccessor<N[H] extends PortDecl ? N[H] : PortDecl> : unknown) & Nested<ChildrenOf<N, H>>;
44
+ };
45
+ /**
46
+ * What the callback receives. `Nodes` is accumulated by the builder, one entry per
47
+ * declared node, so autocomplete lists exactly the nodes that exist at this point in
48
+ * the chain — and nothing later.
49
+ * @experimental
50
+ */
51
+ export type Scope<Nodes extends Record<string, PortDecl>> = Nested<Nodes>;
52
+ /**
53
+ * Build the scope for a call site.
54
+ *
55
+ * @param knownKeys every node key declared so far, fully qualified
56
+ * @param localPrefix inside a block chain, the qualifier its members share — so a
57
+ * sibling can be named by its short key (`$.embed`) while an outside node is still
58
+ * reachable by its full path (`$.gather.semantic.embed`).
59
+ * @experimental
60
+ */
61
+ export declare function makeScope(knownKeys: Set<string>, localPrefix?: string, clauseId?: string): any;
62
+ /** The current item inside a map, addressed without knowing the block's key. @experimental */
63
+ export declare const ITEM = "$item";
64
+ export {};
65
+ //# sourceMappingURL=scope.d.ts.map
package/dist/scope.js ADDED
@@ -0,0 +1,128 @@
1
+ /**
2
+ * The typed chain scope — `$.history.messages` instead of `$ref('history', 'messages')`.
3
+ *
4
+ * Why this is worth machinery. `$ref` takes two strings, and strings are where the
5
+ * remaining classes of authoring mistake live in this SDK: a mistyped node key, a
6
+ * mistyped port, a reference to a node that does not exist *yet*. All three were
7
+ * publish-time findings. With a scope object accumulated as the chain is built, all
8
+ * three become **compile errors**, which is the same move the kind-named methods made
9
+ * for the five laws they enforce (04 §4a).
10
+ *
11
+ * The one that matters most is the third. `$` contains only the nodes declared *above*
12
+ * the call, so a reference to a later node does not type-check — **"no back-edges" (F9)
13
+ * stops being a rule the validator checks and becomes a thing you cannot write.**
14
+ *
15
+ * Nothing about the compiled document changes. A scope access produces exactly the
16
+ * `DataRef` that `$ref` produces, so the rows, the edges and the canonical hash are
17
+ * byte-identical (F3, F6). This is authoring sugar over an unchanged value.
18
+ */
19
+ import { $ref } from './refs.js';
20
+ const REF_KEYS = new Set(['__ref', 'node', 'port']);
21
+ /**
22
+ * A ref that can be refined. The proxy target is a real `DataRef`, so `JSON.stringify`,
23
+ * `Object.entries` and `collectDataRefs` all see a plain object — the proxy is invisible
24
+ * to everything downstream of authoring.
25
+ */
26
+ function refAccessor(node, port = 'main') {
27
+ const target = $ref(node, port);
28
+ return new Proxy(target, {
29
+ get(t, prop, recv) {
30
+ if (typeof prop !== 'string')
31
+ return Reflect.get(t, prop, recv);
32
+ if (REF_KEYS.has(prop) || prop === 'toJSON' || prop === 'then')
33
+ return Reflect.get(t, prop, recv);
34
+ // Object internals must pass through untouched, or deep-equality, logging and
35
+ // anything else that probes an object turns into a port reference.
36
+ if (prop in Object.prototype)
37
+ return Reflect.get(t, prop, recv);
38
+ // Refining an already-refined ref is a mistake worth catching early:
39
+ // `$.a.b.c` has no meaning — ports are flat.
40
+ if (port !== 'main') {
41
+ throw new Error(`'${node}.${port}.${prop}' — ports are flat, so a ref cannot be refined twice. ` +
42
+ `Reference the port you want directly, or reach inside the payload in the node's own hook.`);
43
+ }
44
+ return refAccessor(node, prop);
45
+ },
46
+ });
47
+ }
48
+ /**
49
+ * Build the scope for a call site.
50
+ *
51
+ * @param knownKeys every node key declared so far, fully qualified
52
+ * @param localPrefix inside a block chain, the qualifier its members share — so a
53
+ * sibling can be named by its short key (`$.embed`) while an outside node is still
54
+ * reachable by its full path (`$.gather.semantic.embed`).
55
+ * @experimental
56
+ */
57
+ export function makeScope(knownKeys, localPrefix, clauseId) {
58
+ /** A sibling inside the same chain wins over a same-named outside key. */
59
+ const resolveKey = (joined) => {
60
+ if (localPrefix && knownKeys.has(`${localPrefix}.${joined}`))
61
+ return `${localPrefix}.${joined}`;
62
+ return knownKeys.has(joined) ? joined : undefined;
63
+ };
64
+ const isPrefix = (joined) => [...knownKeys].some((k) => k.startsWith(`${joined}.`) ||
65
+ (!!localPrefix && k.startsWith(`${localPrefix}.${joined}.`)));
66
+ /**
67
+ * A path segment can be three things at once, and the order matters:
68
+ *
69
+ * 1. a **step toward** a longer key — `gather` on the way to `gather.semantic.embed`
70
+ * 2. a **key in its own right** — a block publishes under its own id, so `$.gather`
71
+ * is also a real reference
72
+ * 3. a **port** on the key we already have — `$.history.messages`
73
+ *
74
+ * Walking wins over porting, because a block id being addressable must not shadow the
75
+ * nodes underneath it. Only when nothing deeper can match is the segment a port.
76
+ */
77
+ const walk = (path) => {
78
+ const joined = path.join('.');
79
+ const selfKey = joined ? resolveKey(joined) : undefined;
80
+ // `$.block.item`, written from inside that block, is the iteration item when
81
+ // used as a *value* — while staying a step on the walk to the chain's inner
82
+ // nodes (`$.agent.item.turn` still reaches the node). Without this the path
83
+ // was a bare prefix, so the reference silently serialized to nothing: the
84
+ // one wiring mistake that produces plausible output against missing input.
85
+ const itemKey = !selfKey && clauseId && joined === `${clauseId}.item` ? `${clauseId}.${ITEM}` : undefined;
86
+ const target = selfKey
87
+ ? $ref(selfKey, 'main')
88
+ : itemKey
89
+ ? $ref(itemKey, 'main')
90
+ : Object.create(null);
91
+ return new Proxy(target, {
92
+ get(t, prop, recv) {
93
+ if (typeof prop !== 'string')
94
+ return Reflect.get(t, prop, recv);
95
+ if (REF_KEYS.has(prop) || prop === 'toJSON' || prop === 'then')
96
+ return Reflect.get(t, prop, recv);
97
+ if (prop in Object.prototype)
98
+ return Reflect.get(t, prop, recv);
99
+ // Inside a map or loop, the current item is addressable without naming the
100
+ // block — its key is bookkeeping the author should not have to repeat.
101
+ if (prop === ITEM && clauseId && path.length === 0)
102
+ return refAccessor(`${clauseId}.${ITEM}`);
103
+ const next = [...path, prop];
104
+ const nextJoined = next.join('.');
105
+ // Inside a block, `block.item` is always a walkable path — the chain
106
+ // itself — even before any inner node is declared. Without this,
107
+ // authoring `$.drafting.item` while *declaring* the first inner node
108
+ // fell through to the port branch and quietly produced an edge from
109
+ // the block's (not yet existing) `item` port.
110
+ if (resolveKey(nextJoined) ||
111
+ isPrefix(nextJoined) ||
112
+ (clauseId && nextJoined === `${clauseId}.item`))
113
+ return walk(next);
114
+ if (selfKey)
115
+ return refAccessor(selfKey, prop);
116
+ throw new Error(`'${nextJoined}' is not a node declared before this point.` +
117
+ (knownKeys.size
118
+ ? ` Available: ${[...knownKeys].join(', ')}.`
119
+ : ' No nodes are declared yet — the Input comes first (01 §2).') +
120
+ ` Pipelines have no back-edges (F9), so a node cannot reference one declared later.`);
121
+ },
122
+ });
123
+ };
124
+ return walk([]);
125
+ }
126
+ /** The current item inside a map, addressed without knowing the block's key. @experimental */
127
+ export const ITEM = '$item';
128
+ //# sourceMappingURL=scope.js.map
@@ -0,0 +1,243 @@
1
+ /**
2
+ * Script **types** — the fourth paradigm's contracts (18 §1–§3).
3
+ *
4
+ * A script is user-authored, typed text that transforms data at a declared
5
+ * point in a run: no SDK, no manifest, no build step. This module declares the
6
+ * *contracts* those texts conform to, not the texts themselves. The split is
7
+ * the same one prompts and prompt slots already have, and 18 §2 states it
8
+ * plainly: few types, declared by core and extensions and versioned by a
9
+ * content hash; many scripts, authored by users and stored as rows.
10
+ *
11
+ * Structured like the other declared-thing registries beside it — `engines.ts`,
12
+ * `variables.ts` — so a plugin reading the registry sees core's declarations on
13
+ * the same terms as its own, and `snapshotRegistry` projects these into the
14
+ * type registry with `kind: 'script'` under the same sync, conflict-refusal and
15
+ * re-projection rules as node types.
16
+ *
17
+ * ## Why the id grows a segment
18
+ *
19
+ * `<namespace>:script:<content>/<operation>@<major>`
20
+ *
21
+ * The content segment is structural, not decorative: hook matching, chain
22
+ * homogeneity, panel grouping and import validation all read it, which is why
23
+ * it earns a delimiter rather than a hyphen convention. `text/stop` is
24
+ * filterable; `text-stop` is a naming habit (18 §1).
25
+ *
26
+ * ⚠ This is the **one** compound kind, and the extension stops here. Node kinds
27
+ * are already segmented by kind and never grow qualifiers; scripts are
28
+ * segmented by payload because that is what decides which chain a link may join
29
+ * and which hook may accept it. Generalizing the grammar further is a non-goal.
30
+ *
31
+ * ⚠ The grammar is hard-frozen once the SDK publishes (07 §0g). Scripts are
32
+ * unshipped, so this is the free moment to extend it additively.
33
+ */
34
+ import type { I18n } from './descriptors.js';
35
+ import type { ShapeId } from './shapes.js';
36
+ /** `core:script:text/stop@1` — namespaced, segmented by payload, pinned. @experimental */
37
+ export type ScriptKindId = string;
38
+ /**
39
+ * What a chain of this operation *does* with what its links return (18 §5).
40
+ *
41
+ * Declared per operation rather than per hook, because it is a property of the
42
+ * contract: two `text` operations differ precisely in whether their return
43
+ * flows onward or is consumed as a judgement.
44
+ * @experimental
45
+ */
46
+ export type ChainSemantics =
47
+ /**
48
+ * The return merges back into the flowing variable bag, in order. Each link
49
+ * receives its declared ins and merges only its declared outs; everything
50
+ * else passes through untouched.
51
+ */
52
+ 'transform'
53
+ /**
54
+ * The return is a verdict the hook consumes and never merges. Verdicts are
55
+ * reduced, not folded — `text/stop` takes the minimum index — which is what
56
+ * makes merging chains from several scopes well-defined with no precedence
57
+ * fight.
58
+ */
59
+ | 'verdict';
60
+ /** @experimental */
61
+ export interface ScriptKindDecl {
62
+ id: ScriptKindId;
63
+ i18n?: {
64
+ name?: I18n;
65
+ description?: I18n;
66
+ };
67
+ /**
68
+ * What a script of this type is able to do, in the words the panel badges
69
+ * it with. Display text: stripped from the content hash like `i18n`, for
70
+ * the same reason — copyediting a warning is not a contract change.
71
+ *
72
+ * Present on every type and deliberately blunt. Operations within a content
73
+ * scope *are* the permission granularity (18 §3): `messages/inject` split
74
+ * from `messages/transform` so a cautious user can accept injection chains
75
+ * while refusing rewrites, and that choice is only meaningful if the
76
+ * difference is stated where the choice is made.
77
+ */
78
+ blastRadius: I18n;
79
+ semantics: ChainSemantics;
80
+ /**
81
+ * The shapes this operation reads and produces.
82
+ *
83
+ * The *contract*, not the hook's variable space. A hook decides which
84
+ * variables exist at its point and what extras it supplies; the type says
85
+ * what kind of thing flows. One `text/transform` therefore serves the input
86
+ * hook, the write hook and the display hook — placement is the hook's
87
+ * property, not the type's (18 §3).
88
+ *
89
+ * A `verdict` operation declares `out` as what the hook consumes, which is
90
+ * never merged downstream.
91
+ */
92
+ ports: {
93
+ in: Record<string, ShapeId>;
94
+ out: Record<string, ShapeId>;
95
+ };
96
+ }
97
+ /** A parsed script id. The segments callers actually branch on. @experimental */
98
+ export interface ParsedScriptKindId {
99
+ namespace: string;
100
+ /** e.g. `text`, `messages`, `candidates`, `context`. */
101
+ content: string;
102
+ /** e.g. `transform`, `stop`, `inject`, `filter`, `rescore`. */
103
+ operation: string;
104
+ version: number;
105
+ /** `content/operation` — the chain-homogeneity key, computed once here. */
106
+ space: string;
107
+ }
108
+ /** Is this a script id at all? Cheap enough to call in a filter. @experimental */
109
+ export declare const isScriptKindId: (id: string) => boolean;
110
+ /**
111
+ * Parse, or throw with the grammar spelled out.
112
+ *
113
+ * Throwing beats returning null here for the reason 12 §2a gives about template
114
+ * engines: a caller that gets `undefined` from a malformed id writes a fallback,
115
+ * and a fallback that half-works is how a script ends up attached to a hook
116
+ * nobody meant. An id is either well-formed or it is a bug in the thing that
117
+ * produced it.
118
+ * @internal
119
+ */
120
+ export declare function parseScriptKindId(id: string): ParsedScriptKindId;
121
+ /**
122
+ * `content/operation` — what every link in one chain must share (18 §5).
123
+ *
124
+ * Checkable off the id, which is the point of putting content in the grammar: a
125
+ * `candidates` script dropped into a `text/transform` chain refuses at attach
126
+ * rather than at run time, and neither the registry nor the script body has to
127
+ * be consulted to know it.
128
+ * @experimental
129
+ */
130
+ export declare const scriptSpace: (id: ScriptKindId) => string;
131
+ /**
132
+ * Register a script type.
133
+ *
134
+ * The same two refusals as every other registry here — an id has exactly one
135
+ * owner, and the grammar is checked at the door rather than trusted. The second
136
+ * matters more for scripts than elsewhere: these ids are matched by *segment*,
137
+ * so a malformed one does not fail loudly, it quietly belongs to no chain and
138
+ * no hook.
139
+ * @experimental
140
+ */
141
+ export declare function defineScriptKind(decl: ScriptKindDecl): ScriptKindDecl;
142
+ /**
143
+ * The plugin-facing door. Same registration, minus the ability to claim core's
144
+ * namespace — checked here rather than in `defineScriptKind` so core's own
145
+ * declarations do not have to argue past their own guard.
146
+ * @experimental
147
+ */
148
+ export declare function definePluginScriptKind(pluginId: string, decl: ScriptKindDecl): ScriptKindDecl;
149
+ /** @internal */
150
+ export declare const getScriptKind: (id: ScriptKindId) => ScriptKindDecl | undefined;
151
+ /** @experimental */
152
+ export declare const allScriptKinds: () => ScriptKindDecl[];
153
+ /** @internal */
154
+ export declare function _clearScriptKinds(): void;
155
+ /** @experimental */
156
+ export declare const textTransform: ScriptKindDecl;
157
+ /**
158
+ * ⚠ A verdict, not a transform, and the difference is load-bearing.
159
+ *
160
+ * A stop script never rewrites the stream — it answers "where, in the text you
161
+ * have been shown, should this end?" That makes the answer a **min-reduction**:
162
+ * every attached script evaluates independently and the earliest index wins.
163
+ * Order-free and commutative, which is exactly what makes merging the
164
+ * connection's chain with the pipeline's and the chat's well-defined without a
165
+ * precedence rule nobody would remember (18 §5).
166
+ *
167
+ * It is also the one type with a conformance law attached (S1): the verdict is
168
+ * a function of the accumulated text only, never of chunk boundaries, or a
169
+ * reply replays differently than it streamed.
170
+ * @experimental
171
+ */
172
+ export declare const textStop: ScriptKindDecl;
173
+ /**
174
+ * Additive only, and split from `messages/transform` on purpose.
175
+ *
176
+ * Same content, different blast radius: injection cannot touch what is already
177
+ * there, so a cautious user can accept injection chains while refusing
178
+ * rewrites. That choice only exists because the two are separate operations —
179
+ * a single `messages/edit` would have made "add a reminder at depth 2" and
180
+ * "delete half the history" the same permission.
181
+ * @experimental
182
+ */
183
+ export declare const messagesInject: ScriptKindDecl;
184
+ /** @experimental */
185
+ export declare const messagesTransform: ScriptKindDecl;
186
+ /** @experimental */
187
+ export declare const candidatesFilter: ScriptKindDecl;
188
+ /** @experimental */
189
+ export declare const candidatesRescore: ScriptKindDecl;
190
+ /** @experimental */
191
+ export declare const contextTransform: ScriptKindDecl;
192
+ /**
193
+ * The extracted cast, after the model has answered and the host has parsed.
194
+ *
195
+ * Its own content scope rather than a `context` operation, because chain
196
+ * homogeneity is keyed on content (18 §5) and a cast is not a template
197
+ * context — a chain that could hold both would let a context edit land on a
198
+ * cast list by attachment mistake, silently. The scope is what makes the
199
+ * mistake refusable at attach.
200
+ *
201
+ * The flowing value is what `core:oracle/extract-cast@1` publishes on its
202
+ * `cast` port: `{ participants, mentioned }`. Scripts here rename, merge
203
+ * aliases, drop a junk detection, or add someone the model missed — the
204
+ * paste-rung half of replaceable cast extraction. The other half is the node
205
+ * rebind: a whole different extractor is a same-shaped provider, never a
206
+ * script, because scripts are pure compute and extraction calls a model.
207
+ * @experimental
208
+ */
209
+ export declare const castTransform: ScriptKindDecl;
210
+ /**
211
+ * Who speaks next, as a script (plans/19 §5, second half; ruled 2026-09-21).
212
+ *
213
+ * The one seam a plugin — or an admin, in the Scripts panel with no plugin at
214
+ * all — has for turn detection of its own. Core's `core:task/turn-scripted@1`
215
+ * declares this kind at its `select` point and hands the chain a
216
+ * **selection**: `{ speaker, candidates, lastSpeaker, sinceUser }` — the pick so
217
+ * far (null until a link decides), every seat a strategy may seat (characters
218
+ * and in-turn envoys, each a participant reference with its position and name),
219
+ * who spoke last, and how many replies have landed since the person last
220
+ * spoke. A link returns the selection with `speaker` set, or nothing to leave
221
+ * the decision to the next link. The host seats only a reference that is in
222
+ * `candidates`; anything else is recorded and ignored, so a script can never
223
+ * seat somebody the cast does not hold.
224
+ *
225
+ * A transform rather than a verdict: the chain's *order* is its precedence —
226
+ * "the mentioned character, else whoever is due" is two links — and a verdict
227
+ * reduction would need a rule for which reference wins that no reduction states
228
+ * naturally. Its own content scope for the reason `cast` has one: chain
229
+ * homogeneity is keyed on content, and a selection is not a cast.
230
+ * @experimental
231
+ */
232
+ export declare const turnSelect: ScriptKindDecl;
233
+ /**
234
+ * Every content scope core ships, in panel order.
235
+ *
236
+ * Derived from the registry rather than restated, so a scope arrives the moment
237
+ * a type using it is declared — including an extension's. A hand-written list
238
+ * is the thing 18 §1 rule 3 warns against: a second taxonomy of what data is,
239
+ * kept in step by hand.
240
+ * @experimental
241
+ */
242
+ export declare const scriptContentScopes: () => string[];
243
+ //# sourceMappingURL=scripts.d.ts.map