@serene-pub/sdk 0.6.0-pr-5 โ†’ 0.6.0-pr-7

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 (144) hide show
  1. package/dist/actions.d.ts +52 -2
  2. package/dist/actions.js +56 -6
  3. package/dist/annexFields.d.ts +32 -2
  4. package/dist/annexFields.js +48 -5
  5. package/dist/announce.d.ts +142 -2
  6. package/dist/announce.js +198 -2
  7. package/dist/attributes.d.ts +331 -6
  8. package/dist/attributes.js +339 -27
  9. package/dist/bridges.d.ts +61 -0
  10. package/dist/bridges.js +112 -0
  11. package/dist/builder.d.ts +278 -51
  12. package/dist/builder.js +267 -30
  13. package/dist/cadences.d.ts +585 -0
  14. package/dist/cadences.js +1118 -0
  15. package/dist/capabilities.d.ts +106 -17
  16. package/dist/capabilities.js +85 -7
  17. package/dist/checkMethods.d.ts +240 -0
  18. package/dist/checkMethods.js +362 -0
  19. package/dist/component.d.ts +6 -1
  20. package/dist/componentClient.d.ts +42 -6
  21. package/dist/componentWire.js +22 -4
  22. package/dist/composerStates.d.ts +96 -0
  23. package/dist/composerStates.js +190 -0
  24. package/dist/conditions.d.ts +424 -0
  25. package/dist/conditions.js +521 -0
  26. package/dist/config.d.ts +42 -6
  27. package/dist/config.js +48 -20
  28. package/dist/conversions.d.ts +41 -0
  29. package/dist/conversions.js +50 -0
  30. package/dist/declarations.d.ts +40 -2
  31. package/dist/declarations.js +178 -10
  32. package/dist/descriptors.d.ts +287 -4
  33. package/dist/descriptors.js +281 -18
  34. package/dist/document.d.ts +47 -2
  35. package/dist/document.js +46 -14
  36. package/dist/entities.d.ts +156 -0
  37. package/dist/entities.js +259 -0
  38. package/dist/events.d.ts +711 -1
  39. package/dist/events.js +412 -1
  40. package/dist/executor.d.ts +4 -3
  41. package/dist/executor.js +22 -8
  42. package/dist/exposure.d.ts +128 -0
  43. package/dist/exposure.js +168 -0
  44. package/dist/extension.d.ts +127 -3
  45. package/dist/extension.js +43 -0
  46. package/dist/fit.d.ts +198 -0
  47. package/dist/fit.js +351 -0
  48. package/dist/functions.d.ts +554 -0
  49. package/dist/functions.js +712 -0
  50. package/dist/genres.d.ts +303 -89
  51. package/dist/genres.js +335 -100
  52. package/dist/hookGrants.d.ts +15 -1
  53. package/dist/hookGrants.js +11 -10
  54. package/dist/hooks.d.ts +34 -5
  55. package/dist/hooks.js +5 -2
  56. package/dist/hostElements.d.ts +7 -1
  57. package/dist/hostElements.js +20 -1
  58. package/dist/hostState.d.ts +110 -0
  59. package/dist/hostState.js +140 -0
  60. package/dist/identity.d.ts +1 -1
  61. package/dist/identity.js +1 -1
  62. package/dist/index.d.ts +25 -0
  63. package/dist/index.js +48 -0
  64. package/dist/jsonSchema.d.ts +178 -0
  65. package/dist/jsonSchema.js +570 -0
  66. package/dist/libraryDraft.d.ts +27 -0
  67. package/dist/libraryDraft.js +25 -0
  68. package/dist/lorebookFile.d.ts +44 -0
  69. package/dist/lorebookFile.js +202 -0
  70. package/dist/media.d.ts +127 -12
  71. package/dist/media.js +45 -1
  72. package/dist/messageBlocks.d.ts +179 -5
  73. package/dist/messageBlocks.js +208 -6
  74. package/dist/participants.d.ts +32 -9
  75. package/dist/participants.js +13 -2
  76. package/dist/pluginHarness.d.ts +63 -33
  77. package/dist/pluginHarness.js +78 -144
  78. package/dist/pluginPermissions.d.ts +15 -1
  79. package/dist/pluginPermissions.js +29 -2
  80. package/dist/preview.d.ts +45 -4
  81. package/dist/preview.js +52 -12
  82. package/dist/primers.d.ts +177 -0
  83. package/dist/primers.js +265 -0
  84. package/dist/receipt.d.ts +11 -0
  85. package/dist/receiverRules.js +9 -0
  86. package/dist/refs.d.ts +9 -1
  87. package/dist/refs.js +12 -0
  88. package/dist/registrations.d.ts +384 -0
  89. package/dist/registrations.js +625 -0
  90. package/dist/repertoires.d.ts +502 -0
  91. package/dist/repertoires.js +666 -0
  92. package/dist/rulesetDocument.d.ts +116 -0
  93. package/dist/rulesetDocument.js +252 -0
  94. package/dist/rulesetSections.d.ts +631 -0
  95. package/dist/rulesetSections.js +1288 -0
  96. package/dist/rulesetTemplates.d.ts +161 -0
  97. package/dist/rulesetTemplates.js +242 -0
  98. package/dist/rulesets.d.ts +899 -0
  99. package/dist/rulesets.js +1378 -0
  100. package/dist/sceneSettings.d.ts +8 -0
  101. package/dist/sceneSettings.js +10 -2
  102. package/dist/scope.d.ts +44 -3
  103. package/dist/scope.js +18 -0
  104. package/dist/scripts.d.ts +31 -8
  105. package/dist/scripts.js +45 -8
  106. package/dist/sessionDossier.d.ts +157 -7
  107. package/dist/sessionLayout.d.ts +291 -138
  108. package/dist/sessionLayout.js +504 -211
  109. package/dist/sessionSettings.d.ts +24 -0
  110. package/dist/settings.d.ts +95 -4
  111. package/dist/settings.js +293 -4
  112. package/dist/shapes.d.ts +80 -1
  113. package/dist/shapes.js +100 -5
  114. package/dist/speech.d.ts +333 -0
  115. package/dist/speech.js +199 -0
  116. package/dist/statShapes.d.ts +8 -1
  117. package/dist/statShapes.js +8 -1
  118. package/dist/status.d.ts +14 -0
  119. package/dist/status.js +12 -0
  120. package/dist/storage.d.ts +53 -66
  121. package/dist/storage.js +7 -12
  122. package/dist/storyTime.d.ts +25 -1
  123. package/dist/storyTime.js +42 -2
  124. package/dist/surfaces.d.ts +15 -2
  125. package/dist/template.d.ts +19 -1
  126. package/dist/template.js +25 -11
  127. package/dist/templateScopeAt.d.ts +1 -1
  128. package/dist/templateScopeAt.js +11 -8
  129. package/dist/ties.d.ts +211 -0
  130. package/dist/ties.js +301 -0
  131. package/dist/turnOrder.d.ts +25 -14
  132. package/dist/turnOrder.js +21 -8
  133. package/dist/userAnnex.d.ts +126 -0
  134. package/dist/userAnnex.js +214 -0
  135. package/dist/validate.js +114 -19
  136. package/dist/values.js +6 -0
  137. package/dist/vocabularies.d.ts +192 -0
  138. package/dist/vocabularies.js +326 -0
  139. package/dist/widgetDecls.d.ts +12 -0
  140. package/dist/widgetDecls.js +2 -0
  141. package/dist/widgets.d.ts +1062 -29
  142. package/dist/widgets.js +218 -3
  143. package/host-elements.d.ts +90 -0
  144. package/package.json +1 -1
package/dist/builder.d.ts CHANGED
@@ -27,6 +27,8 @@ import { type I18n } from './i18n.js';
27
27
  import type { VariableDecl, VariableId } from './variables.js';
28
28
  import { type ActionDecl } from './actions.js';
29
29
  import { type BoundaryTriggerDecl } from './sceneSettings.js';
30
+ import { type EventDef } from './events.js';
31
+ import { type ActionHandle } from './registrations.js';
30
32
  /** @experimental */
31
33
  export interface SpecMeta {
32
34
  /**
@@ -224,6 +226,8 @@ export interface BuiltNode {
224
226
  status?: I18n;
225
227
  label?: I18n;
226
228
  purpose?: I18n;
229
+ /** ๐Ÿšง R54: the owner chooses this step's prompt (among those not hidden) โ€” see `NodeOpts.expose.promptReach`. */
230
+ promptReach?: 'owner';
227
231
  };
228
232
  /** The placement's `prefers`, when stated โ€” see `NodeOpts.prefers`. */
229
233
  prefers?: Prefers;
@@ -418,9 +422,44 @@ export interface BuiltSpec {
418
422
  event?: string;
419
423
  events?: string[];
420
424
  };
425
+ /**
426
+ * ๐Ÿšง The events this pipeline **suits** โ€” hints for pickers only, never a
427
+ * subscription (PLAN-layering D3, ยง2): what runs a pipeline is a
428
+ * registration. Set by `.inlet(key, node, { suits })`, and by the โณ lock
429
+ * form (`{ genre, event(s) }`, an alias to 0.7), which records its events
430
+ * here too. A document carries `suits` only for the new form โ€” a locked
431
+ * spec's are its lock's (`suitsOf`), so its hash does not move.
432
+ * @ruling R6, ยง2
433
+ */
434
+ suits?: string[];
435
+ /**
436
+ * ๐Ÿšง The events this pipeline **emits** (R6) โ€” recorded by the host, so a
437
+ * registration may listen to them and the door can refuse a cycle (A12).
438
+ * Set by `.emits(โ€ฆ)`; carried in the document when stated.
439
+ * @ruling R6, A12
440
+ */
441
+ emits?: string[];
442
+ /** ๐Ÿšง `false`: the events its ruleset functions raise are never emitted (`.functionEvents(false)`, D3). */
443
+ functionEvents?: false;
421
444
  }
422
- /** What a node method accepts: the value, or a function of the scope that returns it. @experimental */
423
- export type NodeArg<N, Nodes extends Record<string, PortDecl>> = N | (($: Scope<Nodes>) => N);
445
+ /**
446
+ * A built spec with its **action handles**: `spec.actions.<key>` for every
447
+ * action it contributes, typed from the declarations โ€” what `register()`
448
+ * takes to make an action pipeline (derive, don't spell). Not part of the
449
+ * document: the handles are read off `contributes`.
450
+ * @experimental
451
+ * @ruling A18, D3
452
+ */
453
+ export type BuiltSpecWithActions<A extends string = string> = BuiltSpec & {
454
+ readonly actions: Readonly<Record<A, ActionHandle>>;
455
+ };
456
+ /**
457
+ * What a node method accepts: the value, or a function of the scope that returns it.
458
+ * `Prefix` is the chain's qualifier: inside a clause chain its own nodes are named by
459
+ * their short keys too (A18).
460
+ * @experimental
461
+ */
462
+ export type NodeArg<N, Nodes extends Record<string, PortDecl>, Prefix extends string = ''> = N | (($: Scope<Nodes, Prefix>) => N);
424
463
  /**
425
464
  * The optional third argument of a node method:
426
465
  * `{ expose: { session: true } }` marks the node's controls as a declared
@@ -455,6 +494,15 @@ export interface NodeOpts {
455
494
  label?: I18n;
456
495
  /** The step purpose: what this model call is for, under its settings heading โ€” see `BuiltNode.expose`. */
457
496
  purpose?: I18n;
497
+ /**
498
+ * ๐Ÿšง **The prompt choice's reach** (R54, 2026-10-21): `'owner'` offers
499
+ * the session's owner a choice of this step's prompt โ€” among the
500
+ * prompts of its slot's pool an administrator has not hidden โ€” as a
501
+ * setting of the pipeline. Never the prompt's text: members never edit
502
+ * a prompt. Only on a step whose definition declares a `prompts` slot.
503
+ * Absent: an administrator's choice alone.
504
+ */
505
+ promptReach?: 'owner';
458
506
  };
459
507
  /**
460
508
  * What this step runs best on โ€” overrides the definition's own
@@ -505,7 +553,7 @@ export type NodeOf<K extends Kind> = NodeSpec<Descriptor<any, any> & {
505
553
  * type โ€” the exact thing this whole change exists to prevent.
506
554
  * @experimental
507
555
  */
508
- export type EachOver<Nodes extends Record<string, PortDecl>> = (($: Scope<Nodes>) => DataRef) | DataRef | readonly unknown[];
556
+ export type EachOver<Nodes extends Record<string, PortDecl>, Prefix extends string = ''> = (($: Scope<Nodes, Prefix>) => DataRef) | DataRef | readonly unknown[];
509
557
  /**
510
558
  * Node keys accumulate **fully qualified**, exactly as they land in the rows โ€” so
511
559
  * a node declared inside a clause enters the scope as `gather.semantic.embed`, and the
@@ -520,8 +568,53 @@ type Add<Nodes extends Record<string, PortDecl>, K extends string, N> = Nodes &
520
568
  type AddPorts<Nodes extends Record<string, PortDecl>, K extends string, P extends PortDecl> = Nodes & {
521
569
  [X in K]: P;
522
570
  };
523
- /** Pull the accumulated node map back out of a builder the author handed us. @experimental */
524
- export type NodesOf<B> = B extends ChainBuilder<infer M, any> ? M : B extends GatherBuilder<infer M, any> ? M : never;
571
+ /**
572
+ * Pull the accumulated node map back out of a builder the author handed us โ€” a
573
+ * chain's, a gather's, or a junction's branches (A18: a junction's result keeps
574
+ * the nodes its branches declared, so what follows it is typed).
575
+ * @experimental
576
+ */
577
+ export type NodesOf<B> = B extends ChainBuilder<infer M, any> ? M : B extends GatherBuilder<infer M, any> ? M : B extends JunctionBuilder<any, any, infer M> ? M : never;
578
+ /**
579
+ * ๐Ÿšง The node map after a junction (A18): the nodes before it, every node its
580
+ * branches declared โ€” **optional**, because a branch that did not fire publishes
581
+ * `halt('not selected')` and a read of its node is absent at run time โ€” and the
582
+ * junction's own result ports under its id.
583
+ * @experimental
584
+ * @ruling A18, M4
585
+ */
586
+ export type JunctionNodes<Nodes extends Record<string, PortDecl>, R, Id extends string> = Nodes & Partial<NodesOf<R>> & {
587
+ [X in Id]: JunctionPorts;
588
+ };
589
+ /**
590
+ * ๐Ÿšง A **typed path** into a junction's value (A18): `(v: Reckoned) => v.scripts`
591
+ * โ€” the property chain read off a value whose TypeScript type the author names, so
592
+ * a typo is a compile error. The string (`'scripts'`) is still the STORED form:
593
+ * the builder records the chain once, at declaration, and stores the dotted
594
+ * path. The parameter is `never` until annotated, so an unannotated
595
+ * `(v) => v.x` does not compile โ€” a typed path states the type it reads.
596
+ * @experimental
597
+ * @ruling A18
598
+ */
599
+ export type TypedPath = (value: never) => unknown;
600
+ /**
601
+ * ๐Ÿšง A branch's condition as `.when()` takes it: the stored `JunctionPredicate`
602
+ * (less `default`, which is `.otherwise()`), with `path` and `equalsPath` given
603
+ * as the stored dotted string or as a `TypedPath`.
604
+ * @experimental
605
+ * @ruling A18
606
+ */
607
+ export type JunctionWhen = Omit<JunctionPredicate, 'default' | 'path' | 'equalsPath'> & {
608
+ path?: string | TypedPath;
609
+ equalsPath?: string | TypedPath;
610
+ };
611
+ /**
612
+ * The dotted path a `TypedPath` reads โ€” `(v: T) => v.call.tool` โ†’ `'call.tool'` โ€”
613
+ * recorded by walking it once over a proxy. A function that does anything but
614
+ * read one chain of properties is refused, naming the form.
615
+ * @internal
616
+ */
617
+ export declare function typedPathOf(read: TypedPath, where: string): string;
525
618
  /**
526
619
  * What a clause publishes. Addressable like a node, because it is the only well-defined
527
620
  * handle on a construct that ran more than once โ€” "whichever iteration happened to run
@@ -538,7 +631,9 @@ export type BranchPorts = {
538
631
  * What a junction publishes: the clause ports,
539
632
  * and the fired branch's own ports beside them โ€” `$.decide.order`. Open at
540
633
  * the type level (any port name reads); `validate()` holds the document to
541
- * ports every branch's last node actually publishes, with one shape.
634
+ * ports every branch's last node actually publishes, with one shape โ€” or
635
+ * shapes that agree on one of them (๐Ÿšง `agreedShape`, RF fix 3: a
636
+ * text-stream and a text hand on a text).
542
637
  * @experimental
543
638
  * @ruling M4, PLAN-turn-order ยง4.14
544
639
  */
@@ -564,8 +659,8 @@ declare class ChainBuilder<Nodes extends Record<string, PortDecl> = {}, Prefix e
564
659
  chain: string;
565
660
  } | undefined);
566
661
  /** Resolve the callback form against the nodes declared so far. */
567
- protected resolve<N>(arg: NodeArg<N, Nodes>): N;
568
- protected add(kind: Kind, key: string, arg: NodeArg<NodeSpec<any>, Nodes>, opts?: NodeOpts): any;
662
+ protected resolve<N>(arg: NodeArg<N, Nodes, Prefix>): N;
663
+ protected add(kind: Kind, key: string, arg: NodeArg<NodeSpec<any>, Nodes, Prefix>, opts?: NodeOpts): this;
569
664
  protected qualify(key: string): string;
570
665
  /** Where a clause declared here sits, so clauses nest exactly as nodes do. */
571
666
  protected declareClause(b: Omit<BuiltClause, 'clauseId' | 'clauseChain' | 'position'>): BuiltClause;
@@ -584,7 +679,7 @@ declare class ChainBuilder<Nodes extends Record<string, PortDecl> = {}, Prefix e
584
679
  * @ruling 01 ยง4
585
680
  */
586
681
  each<Id extends string, R extends ChainBuilder<any, any>>(id: Id, opts: {
587
- over: EachOver<Nodes>;
682
+ over: EachOver<Nodes, Prefix>;
588
683
  max: number;
589
684
  mode?: 'sequential' | 'parallel';
590
685
  }, fn: (c: ChainBuilder<Nodes & {
@@ -601,14 +696,35 @@ declare class ChainBuilder<Nodes extends Record<string, PortDecl> = {}, Prefix e
601
696
  * instead of a list length.
602
697
  *
603
698
  * Always sequential โ€” each iteration depends on the last, so `mode` would be a lie.
604
- * @ruling 01 ยง4a
699
+ *
700
+ * The predicate is stated in one of two places (A18): in `opts.repeatWhile`, where
701
+ * `$` is typed against the nodes declared BEFORE the loop (by their full keys โ€” a
702
+ * body node is reachable there only untyped, the way it always was); or at the end
703
+ * of the body, `.repeatWhile(($) => $.parse.call)`, where `$` is typed against the
704
+ * body's own nodes. Either way it is resolved after the body and stored on the
705
+ * clause the same way, so the document does not change. Not both.
706
+ *
707
+ * The body reads the loop's own carry โ€” `$.tools.values`, what the passes so
708
+ * far published โ€” so its `$` holds the clause's ports under its id as well
709
+ * (A18, lane 4: the runtime always resolved it; the type now says so).
710
+ * @ruling 01 ยง4a, A18
605
711
  */
606
712
  loop<Id extends string, R extends ChainBuilder<any, any>>(id: Id, opts: {
607
- repeatWhile: (($: Scope<any>) => DataRef) | DataRef;
713
+ repeatWhile?: (($: Scope<Nodes>) => DataRef) | DataRef;
608
714
  max: number;
609
- }, fn: (c: ChainBuilder<Nodes, `${Qualify<Prefix, Id>}.item`>) => R): ChainBuilder<AddPorts<NodesOf<R>, Qualify<Prefix, Id>, BranchPorts>, Prefix>;
715
+ }, fn: (c: ChainBuilder<AddPorts<Nodes, Qualify<Prefix, Id>, BranchPorts>, `${Qualify<Prefix, Id>}.item`>) => R): ChainBuilder<AddPorts<NodesOf<R>, Qualify<Prefix, Id>, BranchPorts>, Prefix>;
716
+ /**
717
+ * ๐Ÿšง A loop's predicate, stated at the END of its body (A18) โ€” `$` typed against
718
+ * the body's own nodes, by their short keys too:
719
+ * `.loop('tools', { max: 4 }, (l) => l.task('parse', โ€ฆ).repeatWhile(($) => $.parse.call))`.
720
+ * Stored exactly as `opts.repeatWhile` is (the clause's `repeatWhile`), so the
721
+ * document is the one the options form writes. Refused anywhere but a loop's body,
722
+ * and when the loop's options state one too.
723
+ * @ruling 01 ยง4a, A18
724
+ */
725
+ repeatWhile(predicate: (($: Scope<Nodes, Prefix>) => DataRef) | DataRef): this;
610
726
  /** Internal: the callback resolver, reachable from `loop` after the body is built. */
611
- resolvePublic<N>(arg: NodeArg<N, any>): N;
727
+ resolvePublic<N>(arg: NodeArg<N, Nodes, Prefix>): N;
612
728
  /**
613
729
  * A **junction** clause (was `.route()`): branches selected by declared
614
730
  * predicates over a value on the spine. Any subset fires โ€” one,
@@ -625,14 +741,14 @@ declare class ChainBuilder<Nodes extends Record<string, PortDecl> = {}, Prefix e
625
741
  * downstream folds see what ran, in declaration order.
626
742
  * @ruling 20 ยง10, 01 ยง4 amended, 13 ยง1
627
743
  */
628
- junction<Id extends string, R extends JunctionBuilder<any, any>>(id: Id, opts: {
629
- on: (($: Scope<any>) => DataRef) | DataRef;
744
+ junction<Id extends string, R extends JunctionBuilder<any, any, any>>(id: Id, opts: {
745
+ on: (($: Scope<Nodes, Prefix>) => DataRef) | DataRef;
630
746
  mode?: 'sequential' | 'parallel';
631
- }, fn: (r: JunctionBuilder<Nodes, Qualify<Prefix, Id>>) => R): ChainBuilder<AddPorts<NodesOf<R>, Qualify<Prefix, Id>, JunctionPorts>, Prefix>;
632
- query<K extends string, N extends NodeOf<'query'>>(key: K, node: NodeArg<N, Nodes>, opts?: NodeOpts): ChainBuilder<Add<Nodes, Qualify<Prefix, K>, N>, Prefix>;
633
- task<K extends string, N extends NodeOf<'task'>>(key: K, node: NodeArg<N, Nodes>, opts?: NodeOpts): ChainBuilder<Add<Nodes, Qualify<Prefix, K>, N>, Prefix>;
634
- oracle<K extends string, N extends NodeOf<'oracle'>>(key: K, node: NodeArg<N, Nodes>, opts?: NodeOpts): ChainBuilder<Add<Nodes, Qualify<Prefix, K>, N>, Prefix>;
635
- outlet<K extends string, N extends NodeOf<'outlet'>>(key: K, node: NodeArg<N, Nodes>, opts?: NodeOpts): ChainBuilder<Add<Nodes, Qualify<Prefix, K>, N>, Prefix>;
747
+ }, fn: (r: JunctionBuilder<Nodes, Qualify<Prefix, Id>>) => R): ChainBuilder<JunctionNodes<Nodes, R, Qualify<Prefix, Id>>, Prefix>;
748
+ query<K extends string, N extends NodeOf<'query'>>(key: K, node: NodeArg<N, Nodes, Prefix>, opts?: NodeOpts): ChainBuilder<Add<Nodes, Qualify<Prefix, K>, N>, Prefix>;
749
+ task<K extends string, N extends NodeOf<'task'>>(key: K, node: NodeArg<N, Nodes, Prefix>, opts?: NodeOpts): ChainBuilder<Add<Nodes, Qualify<Prefix, K>, N>, Prefix>;
750
+ oracle<K extends string, N extends NodeOf<'oracle'>>(key: K, node: NodeArg<N, Nodes, Prefix>, opts?: NodeOpts): ChainBuilder<Add<Nodes, Qualify<Prefix, K>, N>, Prefix>;
751
+ outlet<K extends string, N extends NodeOf<'outlet'>>(key: K, node: NodeArg<N, Nodes, Prefix>, opts?: NodeOpts): ChainBuilder<Add<Nodes, Qualify<Prefix, K>, N>, Prefix>;
636
752
  }
637
753
  declare class GatherBuilder<Nodes extends Record<string, PortDecl> = {}, Id extends string = string> {
638
754
  private spec;
@@ -651,15 +767,23 @@ declare class GatherBuilder<Nodes extends Record<string, PortDecl> = {}, Id exte
651
767
  * condition cannot be written at all.
652
768
  * @experimental
653
769
  */
654
- export declare class JunctionBuilder<Nodes extends Record<string, PortDecl> = {}, Id extends string = string> {
770
+ export declare class JunctionBuilder<Nodes extends Record<string, PortDecl> = {}, Id extends string = string,
771
+ /** ๐Ÿšง The nodes the branches declared so far (A18) โ€” what the junction's result carries, optional. */
772
+ Branches extends Record<string, PortDecl> = {}> {
655
773
  private spec;
656
774
  private clauseId;
657
775
  private clause;
658
776
  constructor(spec: BuiltSpec, clauseId: string, clause: BuiltClause);
659
- /** A branch that fires when its predicate matches the junction's value. */
660
- when<Name extends string, R extends ChainBuilder<any, any>>(name: Name, predicate: Omit<JunctionPredicate, 'default'>, fn: (c: ChainBuilder<Nodes, Qualify<Id, Name>>) => R): JunctionBuilder<NodesOf<R>, Id>;
777
+ /**
778
+ * A branch that fires when its predicate matches the junction's value. `path`
779
+ * and `equalsPath` are the stored dotted strings, or `TypedPath`s โ€”
780
+ * `{ path: (v: Reckoned) => v.scripts, truthy: true }` โ€” recorded to the same
781
+ * string (A18). Each branch's `$` sees the nodes before the junction (and its
782
+ * own, by short key); a sibling branch's nodes are not its to read.
783
+ */
784
+ when<Name extends string, R extends ChainBuilder<any, any>>(name: Name, predicate: JunctionWhen, fn: (c: ChainBuilder<Nodes, Qualify<Id, Name>>) => R): JunctionBuilder<Nodes, Id, Branches & NodesOf<R>>;
661
785
  /** The branch that fires exactly when nothing else did. At most one. */
662
- otherwise<Name extends string, R extends ChainBuilder<any, any>>(name: Name, fn: (c: ChainBuilder<Nodes, Qualify<Id, Name>>) => R): JunctionBuilder<NodesOf<R>, Id>;
786
+ otherwise<Name extends string, R extends ChainBuilder<any, any>>(name: Name, fn: (c: ChainBuilder<Nodes, Qualify<Id, Name>>) => R): JunctionBuilder<Nodes, Id, Branches & NodesOf<R>>;
663
787
  }
664
788
  /**
665
789
  * Slot-named methods, for the same reason the chain has kind-named ones: the
@@ -681,10 +805,23 @@ export declare class PresetBuilder<Nodes extends Record<string, PortDecl> = {}>
681
805
  prompts(nodeKey: keyof Nodes & string, value: Record<string, unknown>): this;
682
806
  /** A template **and its engine** โ€” the engine travels on the value (src/engines.ts). */
683
807
  template(nodeKey: keyof Nodes & string, value: TemplateValue): this;
684
- /** Generation parameters: a reference to a named config, or field overrides on top. */
808
+ /** Generation parameters: a reference to a named config, `{ seedKey }`. */
685
809
  sampling(nodeKey: keyof Nodes & string, value: Record<string, unknown>): this;
686
810
  /** Node toggles and the review position. */
687
811
  settings(nodeKey: keyof Nodes & string, value: Record<string, unknown>): this;
812
+ /**
813
+ * ๐Ÿšง Script chains, named by **seed key** โ€” `{ seedKey }` per link, in
814
+ * order. A chain stores script row ids, and a row id is an instance fact a
815
+ * shipped document cannot know, so an author names the row the way it
816
+ * names a seeded sampling config: the host resolves each key to the row it
817
+ * seeded (`CORE_SCRIPTS`) when it writes the shipped config, and a key it
818
+ * seeded no row for is dropped from the chain with a warning.
819
+ *
820
+ * An array is a `scripts`-kind slot's whole chain; an object keys chains
821
+ * by **interior point** (`{ select: [...] }` for `turn-scripted`'s
822
+ * `select`), the address the executor reads them at.
823
+ */
824
+ scripts(nodeKey: keyof Nodes & string, value: ScriptChainRef[] | Record<string, ScriptChainRef[]>): this;
688
825
  /**
689
826
  * The **loadout** this model call runs on โ€” `slot.loadout(id)` or the
690
827
  * id itself. Unlike a connection this is allowed in an author preset: a
@@ -693,14 +830,22 @@ export declare class PresetBuilder<Nodes extends Record<string, PortDecl> = {}>
693
830
  */
694
831
  loadout(nodeKey: keyof Nodes & string, value: LoadoutRef | LoadoutId): this;
695
832
  }
833
+ /**
834
+ * ๐Ÿšง One link of a shipped script chain, by the seeded row's key
835
+ * (`PresetBuilder.scripts`).
836
+ * @experimental
837
+ */
838
+ export interface ScriptChainRef {
839
+ seedKey: string;
840
+ }
696
841
  /** @experimental */
697
- export declare class SpecBuilder<Nodes extends Record<string, PortDecl> = {}> extends ChainBuilder<Nodes> {
842
+ export declare class SpecBuilder<Nodes extends Record<string, PortDecl> = {}, A extends string = string> extends ChainBuilder<Nodes> {
698
843
  private inletDone;
699
844
  constructor(rawId: string, meta: SpecMeta);
700
- query<K extends string, N extends NodeOf<'query'>>(key: K, node: NodeArg<N, Nodes>, opts?: NodeOpts): SpecBuilder<Add<Nodes, K, N>>;
701
- task<K extends string, N extends NodeOf<'task'>>(key: K, node: NodeArg<N, Nodes>, opts?: NodeOpts): SpecBuilder<Add<Nodes, K, N>>;
702
- oracle<K extends string, N extends NodeOf<'oracle'>>(key: K, node: NodeArg<N, Nodes>, opts?: NodeOpts): SpecBuilder<Add<Nodes, K, N>>;
703
- outlet<K extends string, N extends NodeOf<'outlet'>>(key: K, node: NodeArg<N, Nodes>, opts?: NodeOpts): SpecBuilder<Add<Nodes, K, N>>;
845
+ query<K extends string, N extends NodeOf<'query'>>(key: K, node: NodeArg<N, Nodes>, opts?: NodeOpts): SpecBuilder<Add<Nodes, K, N>, A>;
846
+ task<K extends string, N extends NodeOf<'task'>>(key: K, node: NodeArg<N, Nodes>, opts?: NodeOpts): SpecBuilder<Add<Nodes, K, N>, A>;
847
+ oracle<K extends string, N extends NodeOf<'oracle'>>(key: K, node: NodeArg<N, Nodes>, opts?: NodeOpts): SpecBuilder<Add<Nodes, K, N>, A>;
848
+ outlet<K extends string, N extends NodeOf<'outlet'>>(key: K, node: NodeArg<N, Nodes>, opts?: NodeOpts): SpecBuilder<Add<Nodes, K, N>, A>;
704
849
  /**
705
850
  * A named configuration the spec ships with. Declared **after** the nodes,
706
851
  * so the node keys it addresses are the ones that exist โ€” same accumulation the
@@ -712,6 +857,11 @@ export declare class SpecBuilder<Nodes extends Record<string, PortDecl> = {}> ex
712
857
  * .prompts ('generate', { system: LORE_SYSTEM })
713
858
  * .template('prompt', jinja(LORE_ASSEMBLY)))
714
859
  * ```
860
+ * @deprecated โณ Retiring with pipeline configurations (R38, PLAN-layering
861
+ * D5): only a `default: true` preset is read โ€” as the pipeline's declared
862
+ * defaults; declare those with `.defaults(d => โ€ฆ)`. Every other author
863
+ * preset is ignored (`pipelineDefaultsFindings` names it); a preset's
864
+ * registration `values` change a pipeline's defaults instead. Kept to 0.7.
715
865
  * @ruling 12 ยง3a
716
866
  */
717
867
  preset(slug: string, meta: {
@@ -720,52 +870,129 @@ export declare class SpecBuilder<Nodes extends Record<string, PortDecl> = {}> ex
720
870
  default?: boolean;
721
871
  owner?: string;
722
872
  }, fn: (p: PresetBuilder<Nodes>) => unknown): this;
873
+ /**
874
+ * ๐Ÿšง The pipeline's **declared defaults** (R38, PLAN-layering D5) โ€” the
875
+ * bottom of the value cascade (`author`): which prompt, template,
876
+ * sampling and loadout each step uses, and its parameters, settings and
877
+ * script chains. Declared after the nodes, so the step keys it names are
878
+ * the ones that exist. A registration's `values` change them per preset
879
+ * or genre; nothing else does (configurations retire).
880
+ *
881
+ * ```ts
882
+ * .defaults((d) => d
883
+ * .prompts('generate', { system: STORY_SYSTEM })
884
+ * .sampling('generate', { seedKey: 'sampling-default' }))
885
+ * ```
886
+ * Stored where the shipped default author preset always was
887
+ * (`presets[slug: 'default', default: true]`), so a host reading that
888
+ * keeps reading it.
889
+ * @experimental
890
+ * @ruling R38
891
+ */
892
+ defaults(fn: (d: PresetBuilder<Nodes>) => unknown): this;
893
+ /**
894
+ * ๐Ÿšง The events this pipeline **emits** (R6) โ€” recorded by the host so a
895
+ * registration in any preset of the genre may listen, and so the
896
+ * registration door can refuse a cycle among emitted events (A12). Pass
897
+ * the event objects (`coreEvents.โ€ฆ`, a package's `defineSessionEvent`).
898
+ * Replaces `defineExtension({ events, recordedBy })` for the events a
899
+ * pipeline emits; host moments stay host-published.
900
+ * @experimental
901
+ * @ruling R6, A12
902
+ */
903
+ emits(...events: ReadonlyArray<EventDef | SessionEventDecl | string>): this;
904
+ /**
905
+ * ๐Ÿšง Whether the events a ruleset's functions raise in this pipeline's
906
+ * resolve steps are emitted after its receipt (D3, 2026-10-23). On by
907
+ * default; `.functionEvents(false)` reports them on the steps' facts and
908
+ * emits none, whatever a step's own `emits` parameter says.
909
+ * @experimental
910
+ */
911
+ functionEvents(on: boolean): this;
723
912
  /**
724
913
  * Exactly one **inlet**, positionally first. Enforced here rather than
725
914
  * by the validator, so it is a throw at authoring time.
726
915
  *
727
- * The optional third argument is the **usage lock**: the session
728
- * event this inlet answers and the genre it serves. A session-event spec
729
- * without it does not compile โ€” required for now, and relaxing later
730
- * (`genre: string[]`, `"*"`) is additive, never breaking. **The lock is the
731
- * only subscription**: `.on()` and `subscribes` were deleted
732
- * 2026-09-16 โ€” nothing read them at dispatch.
916
+ * ๐Ÿšง The optional third argument names the events the pipeline
917
+ * **suits** โ€” hints for pickers only (PLAN-layering D3, ยง2). A pipeline is
918
+ * mounted, it does not lock: what runs it is a **registration**
919
+ * (`register(trigger, pipeline)`) in the genre's defaults, a preset or a
920
+ * session, and whether it may is **fit**, derived from what its steps read.
921
+ * @experimental
922
+ * @ruling ยง2, D3
923
+ */
924
+ inlet<K extends string, N extends NodeOf<'inlet'>>(key: K, node: N, opts?: {
925
+ suits?: ReadonlyArray<EventDef | SessionEventDecl | string>;
926
+ }): SpecBuilder<Add<Nodes, K, N>, A>;
927
+ /**
928
+ * The **usage lock** โ€” the session event this inlet answers and the genre it serves.
929
+ * @deprecated โณ An alias to 0.7 (PLAN-layering D3): inlet locks retire.
930
+ * Pass `{ suits: [events] }` and register the pipeline on its events
931
+ * (`register(coreEvents.โ€ฆ, spec)`). The lock still writes `input` exactly
932
+ * as it did โ€” a locked spec's hash does not move โ€” and its events are
933
+ * read as `suits`; a host derives default registrations from it for a
934
+ * package that declares none (D7).
733
935
  * @ruling 01 ยง2, 24 ยง4, R-4, 09-B B5
734
936
  */
735
- inlet<K extends string, N extends NodeOf<'inlet'>>(key: K, node: N, binding?: {
937
+ inlet<K extends string, N extends NodeOf<'inlet'>>(key: K, node: N, binding: {
736
938
  genre: GenreDecl | ExternalRef;
737
- event: string | SessionEventDecl;
939
+ event: string | SessionEventDecl | EventDef;
738
940
  } | {
739
941
  genre: GenreDecl | ExternalRef;
740
- events: Array<string | SessionEventDecl>;
741
- }): SpecBuilder<Add<Nodes, K, N>>;
942
+ events: Array<string | SessionEventDecl | EventDef>;
943
+ }): SpecBuilder<Add<Nodes, K, N>, A>;
742
944
  gather<Id extends string, R extends GatherBuilder<any, any>>(id: Id, opts: {
743
945
  mode?: 'sequential' | 'parallel';
744
- }, fn: (b: GatherBuilder<Nodes, Id>) => R): SpecBuilder<AddPorts<NodesOf<R>, Id, BranchPorts>>;
946
+ }, fn: (b: GatherBuilder<Nodes, Id>) => R): SpecBuilder<AddPorts<NodesOf<R>, Id, BranchPorts>, A>;
745
947
  each<Id extends string, R extends ChainBuilder<any, any>>(id: Id, opts: {
746
948
  over: EachOver<Nodes>;
747
949
  max: number;
748
950
  mode?: 'sequential' | 'parallel';
749
951
  }, fn: (c: ChainBuilder<Nodes & {
750
952
  [ITEM]: PortDecl;
751
- }, `${Id}.item`>) => R): SpecBuilder<AddPorts<NodesOf<R>, Id, BranchPorts>>;
953
+ }, `${Id}.item`>) => R): SpecBuilder<AddPorts<NodesOf<R>, Id, BranchPorts>, A>;
752
954
  loop<Id extends string, R extends ChainBuilder<any, any>>(id: Id, opts: {
753
- repeatWhile: (($: Scope<any>) => DataRef) | DataRef;
955
+ repeatWhile?: (($: Scope<Nodes>) => DataRef) | DataRef;
754
956
  max: number;
755
- }, fn: (c: ChainBuilder<Nodes, `${Id}.item`>) => R): SpecBuilder<AddPorts<NodesOf<R>, Id, BranchPorts>>;
756
- junction<Id extends string, R extends JunctionBuilder<any, any>>(id: Id, opts: {
757
- on: (($: Scope<any>) => DataRef) | DataRef;
957
+ }, fn: (c: ChainBuilder<AddPorts<Nodes, Id, BranchPorts>, `${Id}.item`>) => R): SpecBuilder<AddPorts<NodesOf<R>, Id, BranchPorts>, A>;
958
+ junction<Id extends string, R extends JunctionBuilder<any, any, any>>(id: Id, opts: {
959
+ on: (($: Scope<Nodes>) => DataRef) | DataRef;
758
960
  mode?: 'sequential' | 'parallel';
759
- }, fn: (r: JunctionBuilder<Nodes, Id>) => R): SpecBuilder<AddPorts<NodesOf<R>, Id, JunctionPorts>>;
961
+ }, fn: (r: JunctionBuilder<Nodes, Id>) => R): SpecBuilder<JunctionNodes<Nodes, R, Id>, A>;
760
962
  /**
761
963
  * Compile-time include โ€” expanded here, so rows hold the flat chain.
762
964
  * @ruling 16 ยง3a
763
965
  */
764
- include<K extends string, F extends Fragment<any>>(key: K, fragment: F): SpecBuilder<Nodes & Prefixed<K, F extends Fragment<infer M> ? M : {}>>;
765
- build(): BuiltSpec;
966
+ include<K extends string, F extends Fragment<any>>(key: K, fragment: F): SpecBuilder<Nodes & Prefixed<K, F extends Fragment<infer M> ? M : {}>, A>;
967
+ build(): BuiltSpecWithActions<A>;
766
968
  }
767
- /** @public */
768
- export declare function spec(id: string, meta: SpecMeta): SpecBuilder<{}>;
969
+ /** The slug the declared defaults are stored under (`.defaults()`). @internal */
970
+ export declare const DEFAULTS_SLUG = "default";
971
+ /**
972
+ * ๐Ÿšง The events a pipeline suits โ€” its document's `suits`, else its โณ
973
+ * lock's events (D3). Hints for pickers only.
974
+ * @experimental
975
+ */
976
+ export declare function suitsOf(s: {
977
+ suits?: readonly string[];
978
+ input?: {
979
+ event?: string;
980
+ events?: string[];
981
+ };
982
+ }): string[];
983
+ /**
984
+ * `meta` is `SpecMeta` with each contributed action's `key` captured as `A`
985
+ * โ€” what types `spec.actions.<key>` from the declarations (derive, don't
986
+ * spell). Spelled inline so the frozen signature names no new type.
987
+ * @public
988
+ */
989
+ export declare function spec<const A extends string = string>(id: string, meta: Omit<SpecMeta, 'contributes'> & {
990
+ contributes?: Omit<NonNullable<SpecMeta['contributes']>, 'actions'> & {
991
+ actions?: Array<NonNullable<NonNullable<SpecMeta['contributes']>['actions']>[number] & {
992
+ key: A;
993
+ }>;
994
+ };
995
+ }): SpecBuilder<{}, A>;
769
996
  /**
770
997
  * A fragment carries its node map in its type, so `.include('ctx', contextInfill)` puts
771
998
  * `ctx.embed`, `ctx.search`, `ctx.merge` into the including spec's scope โ€” namespaced by