@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,109 @@
1
+ /**
2
+ * The wire value of `core:shape/context-candidates@1`, and the one thing it
3
+ * carries besides candidates: each source's **band intent**.
4
+ *
5
+ * ## Queries declare, the ranker resolves (16 §5a; R-7 P5, ruled 2026-09-15)
6
+ *
7
+ * *Per-source* intent — how much of the window a source wants (`share`), the
8
+ * most entries it may contribute (`maxEntries`), the fewest it keeps when room
9
+ * is tight (`minEntries`), and how strongly it resists being trimmed
10
+ * (`priority`) — is declared on the **retrieval definition** that produces
11
+ * the source, as ordinary `params`, and travels to the ranker as metadata on
12
+ * the candidates it publishes. The ranker declares only what is
13
+ * *cross-source*: how mechanisms and signals weigh, and how the shares
14
+ * normalise. A per-source map on the ranker is the design 16 §5a rejected: it
15
+ * goes stale when a source is added, and a plugin source cannot participate
16
+ * without somebody editing it.
17
+ *
18
+ * ## The shape, and why it is still a flat list
19
+ *
20
+ * The value stays an **array** — every consumer that iterates candidates, the
21
+ * `candidates/filter` and `candidates/rescore` script kinds included, keeps
22
+ * its contract — and each source's intent rides in it as one element of its
23
+ * own, ahead of that source's items:
24
+ *
25
+ * [ { band: 'worldLore', intent: { share: 0.1667, maxEntries: 20, priority: 'normal' } },
26
+ * { id: 12, source: 'worldLore', tokens: 40, signals: {…} },
27
+ * … ]
28
+ *
29
+ * An element, not a field on every candidate, for one reason that decides it:
30
+ * **a source that found nothing this turn still has a share.** Under
31
+ * share-first allocation an empty band's slice is reserved and then swept to
32
+ * whoever can use it, which is a different allocation from the band not
33
+ * existing — so the intent has to reach the ranker whether or not any item
34
+ * does, and only a thing that is not an item can carry it there. It is also
35
+ * why a `session-history` source that ranks no candidates at all can still
36
+ * publish the transcript's slice of the window on a `band` port.
37
+ *
38
+ * `concat-candidates` keeps the first intent per band and hoists them ahead of
39
+ * the items; `merge-candidates` lifts them out before it fuses ranks and puts
40
+ * them back; a script chain over a `candidates` port never sees them. The
41
+ * ranker reads them, resolves its bands from them, and ranks the items alone
42
+ * — a band no source declared falls back to the ranker's own table for the
43
+ * five core bands and is excluded with a receipt for any other, which is what
44
+ * makes a plugin source's participation a matter of publishing one element.
45
+ */
46
+ /**
47
+ * How strongly a band resists being trimmed once its minimum is met.
48
+ *
49
+ * `normal` is what every source ships at and is arithmetically no ordering at
50
+ * all: the ranker's sweep of leftover tokens walks candidates in score order
51
+ * alone, exactly as it always has. `high` and `low` sort a band's candidates
52
+ * ahead of or behind the others in that sweep before score is consulted;
53
+ * `always` takes every candidate of the band ahead of the scored fill, window
54
+ * permitting, the way a pinned entry is taken — *never dropped* is what the
55
+ * word promises, and the window is the one thing that can still say no.
56
+ * @experimental
57
+ */
58
+ export declare const BAND_PRIORITIES: readonly ['low', 'normal', 'high', 'always'];
59
+ /** @experimental */
60
+ export type BandPriority = (typeof BAND_PRIORITIES)[number];
61
+ /** @internal */
62
+ export declare const isBandPriority: (v: unknown) => v is BandPriority;
63
+ /** What one source says about its own place in the window. @experimental */
64
+ export interface BandIntentFields {
65
+ /**
66
+ * The band's slice of the window, relative to every other band's. `0` is
67
+ * the band's off switch. NOMENCLATURE §7: a share, never a weight.
68
+ */
69
+ share?: number;
70
+ /** The most entries this band may contribute. Absent means no ceiling. */
71
+ maxEntries?: number;
72
+ /** The fewest entries kept when room is tight — a minimum, honoured before the shares. */
73
+ minEntries?: number;
74
+ priority?: BandPriority;
75
+ }
76
+ /** One source's declared intent, as it travels in a candidates list. @experimental */
77
+ export interface BandIntent {
78
+ /** The band this speaks for — `worldLore`, `messages`, a plugin's own key. */
79
+ band: string;
80
+ intent: BandIntentFields;
81
+ }
82
+ /** Build one, dropping fields the source left unset. @public */
83
+ export declare function bandIntent(band: string, fields: BandIntentFields): BandIntent;
84
+ /**
85
+ * Is this element a band's intent rather than a candidate?
86
+ *
87
+ * A candidate names its band as `source` and never carries `intent`; an
88
+ * intent names it as `band` and carries nothing else. Both keys are checked
89
+ * so a candidate a plugin happens to give a `band` field is not mistaken for
90
+ * one.
91
+ * @internal
92
+ */
93
+ export declare const isBandIntent: (v: unknown) => v is BandIntent;
94
+ /**
95
+ * A candidates list, split: the intents (first per band wins) and the items,
96
+ * each in the order they arrived.
97
+ * @public
98
+ */
99
+ export declare function splitCandidates<T = unknown>(list: readonly unknown[] | null | undefined): {
100
+ intents: BandIntent[];
101
+ items: T[];
102
+ };
103
+ /**
104
+ * Put a list back together the way every core candidate source publishes it:
105
+ * intents first, then items.
106
+ * @internal
107
+ */
108
+ export declare function withBandIntents<T>(intents: readonly BandIntent[], items: readonly T[]): Array<BandIntent | T>;
109
+ //# sourceMappingURL=candidates.d.ts.map
@@ -0,0 +1,118 @@
1
+ /**
2
+ * The wire value of `core:shape/context-candidates@1`, and the one thing it
3
+ * carries besides candidates: each source's **band intent**.
4
+ *
5
+ * ## Queries declare, the ranker resolves (16 §5a; R-7 P5, ruled 2026-09-15)
6
+ *
7
+ * *Per-source* intent — how much of the window a source wants (`share`), the
8
+ * most entries it may contribute (`maxEntries`), the fewest it keeps when room
9
+ * is tight (`minEntries`), and how strongly it resists being trimmed
10
+ * (`priority`) — is declared on the **retrieval definition** that produces
11
+ * the source, as ordinary `params`, and travels to the ranker as metadata on
12
+ * the candidates it publishes. The ranker declares only what is
13
+ * *cross-source*: how mechanisms and signals weigh, and how the shares
14
+ * normalise. A per-source map on the ranker is the design 16 §5a rejected: it
15
+ * goes stale when a source is added, and a plugin source cannot participate
16
+ * without somebody editing it.
17
+ *
18
+ * ## The shape, and why it is still a flat list
19
+ *
20
+ * The value stays an **array** — every consumer that iterates candidates, the
21
+ * `candidates/filter` and `candidates/rescore` script kinds included, keeps
22
+ * its contract — and each source's intent rides in it as one element of its
23
+ * own, ahead of that source's items:
24
+ *
25
+ * [ { band: 'worldLore', intent: { share: 0.1667, maxEntries: 20, priority: 'normal' } },
26
+ * { id: 12, source: 'worldLore', tokens: 40, signals: {…} },
27
+ * … ]
28
+ *
29
+ * An element, not a field on every candidate, for one reason that decides it:
30
+ * **a source that found nothing this turn still has a share.** Under
31
+ * share-first allocation an empty band's slice is reserved and then swept to
32
+ * whoever can use it, which is a different allocation from the band not
33
+ * existing — so the intent has to reach the ranker whether or not any item
34
+ * does, and only a thing that is not an item can carry it there. It is also
35
+ * why a `session-history` source that ranks no candidates at all can still
36
+ * publish the transcript's slice of the window on a `band` port.
37
+ *
38
+ * `concat-candidates` keeps the first intent per band and hoists them ahead of
39
+ * the items; `merge-candidates` lifts them out before it fuses ranks and puts
40
+ * them back; a script chain over a `candidates` port never sees them. The
41
+ * ranker reads them, resolves its bands from them, and ranks the items alone
42
+ * — a band no source declared falls back to the ranker's own table for the
43
+ * five core bands and is excluded with a receipt for any other, which is what
44
+ * makes a plugin source's participation a matter of publishing one element.
45
+ */
46
+ /**
47
+ * How strongly a band resists being trimmed once its minimum is met.
48
+ *
49
+ * `normal` is what every source ships at and is arithmetically no ordering at
50
+ * all: the ranker's sweep of leftover tokens walks candidates in score order
51
+ * alone, exactly as it always has. `high` and `low` sort a band's candidates
52
+ * ahead of or behind the others in that sweep before score is consulted;
53
+ * `always` takes every candidate of the band ahead of the scored fill, window
54
+ * permitting, the way a pinned entry is taken — *never dropped* is what the
55
+ * word promises, and the window is the one thing that can still say no.
56
+ * @experimental
57
+ */
58
+ export const BAND_PRIORITIES = ['low', 'normal', 'high', 'always'];
59
+ /** @internal */
60
+ export const isBandPriority = (v) => typeof v === 'string' && BAND_PRIORITIES.includes(v);
61
+ /** Build one, dropping fields the source left unset. @public */
62
+ export function bandIntent(band, fields) {
63
+ const intent = {};
64
+ if (typeof fields.share === 'number' && Number.isFinite(fields.share))
65
+ intent.share = Math.max(0, fields.share);
66
+ if (typeof fields.maxEntries === 'number' && Number.isFinite(fields.maxEntries))
67
+ intent.maxEntries = Math.max(0, Math.floor(fields.maxEntries));
68
+ if (typeof fields.minEntries === 'number' && Number.isFinite(fields.minEntries))
69
+ intent.minEntries = Math.max(0, Math.floor(fields.minEntries));
70
+ if (isBandPriority(fields.priority))
71
+ intent.priority = fields.priority;
72
+ return { band, intent };
73
+ }
74
+ /**
75
+ * Is this element a band's intent rather than a candidate?
76
+ *
77
+ * A candidate names its band as `source` and never carries `intent`; an
78
+ * intent names it as `band` and carries nothing else. Both keys are checked
79
+ * so a candidate a plugin happens to give a `band` field is not mistaken for
80
+ * one.
81
+ * @internal
82
+ */
83
+ export const isBandIntent = (v) => typeof v === 'object' &&
84
+ v !== null &&
85
+ typeof v.band === 'string' &&
86
+ typeof v.intent === 'object' &&
87
+ v.intent !== null &&
88
+ !('source' in v);
89
+ /**
90
+ * A candidates list, split: the intents (first per band wins) and the items,
91
+ * each in the order they arrived.
92
+ * @public
93
+ */
94
+ export function splitCandidates(list) {
95
+ const intents = [];
96
+ const seen = new Set();
97
+ const items = [];
98
+ for (const el of list ?? []) {
99
+ if (isBandIntent(el)) {
100
+ if (seen.has(el.band))
101
+ continue;
102
+ seen.add(el.band);
103
+ intents.push(el);
104
+ }
105
+ else
106
+ items.push(el);
107
+ }
108
+ return { intents, items };
109
+ }
110
+ /**
111
+ * Put a list back together the way every core candidate source publishes it:
112
+ * intents first, then items.
113
+ * @internal
114
+ */
115
+ export function withBandIntents(intents, items) {
116
+ return [...intents, ...items];
117
+ }
118
+ //# sourceMappingURL=candidates.js.map