@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.
- package/LICENSE +202 -0
- package/NOTICE +17 -0
- package/README.md +368 -0
- package/dist/actions.d.ts +572 -0
- package/dist/actions.js +829 -0
- package/dist/annexFields.d.ts +234 -0
- package/dist/annexFields.js +413 -0
- package/dist/announce.d.ts +464 -0
- package/dist/announce.js +426 -0
- package/dist/attributes.d.ts +670 -0
- package/dist/attributes.js +904 -0
- package/dist/bands.d.ts +125 -0
- package/dist/bands.js +256 -0
- package/dist/builder.d.ts +683 -0
- package/dist/builder.js +677 -0
- package/dist/candidates.d.ts +109 -0
- package/dist/candidates.js +118 -0
- package/dist/capabilities.d.ts +744 -0
- package/dist/capabilities.js +679 -0
- package/dist/channels.d.ts +106 -0
- package/dist/channels.js +129 -0
- package/dist/clauses.d.ts +40 -0
- package/dist/clauses.js +43 -0
- package/dist/component.d.ts +33 -0
- package/dist/component.js +27 -0
- package/dist/componentBuild.d.ts +48 -0
- package/dist/componentBuild.js +84 -0
- package/dist/componentClient.d.ts +100 -0
- package/dist/componentClient.js +13 -0
- package/dist/componentImports.d.ts +51 -0
- package/dist/componentImports.js +106 -0
- package/dist/componentModule.d.ts +8 -0
- package/dist/componentModule.js +270 -0
- package/dist/componentWire.d.ts +130 -0
- package/dist/componentWire.js +280 -0
- package/dist/config.d.ts +295 -0
- package/dist/config.js +231 -0
- package/dist/connections.d.ts +89 -0
- package/dist/connections.js +131 -0
- package/dist/declarations.d.ts +290 -0
- package/dist/declarations.js +794 -0
- package/dist/descriptors.d.ts +1774 -0
- package/dist/descriptors.js +1329 -0
- package/dist/dev.d.ts +136 -0
- package/dist/dev.js +161 -0
- package/dist/document.d.ts +202 -0
- package/dist/document.js +312 -0
- package/dist/engines.d.ts +117 -0
- package/dist/engines.js +203 -0
- package/dist/eventMapLaws.d.ts +63 -0
- package/dist/eventMapLaws.js +128 -0
- package/dist/events.d.ts +554 -0
- package/dist/events.js +633 -0
- package/dist/executor.d.ts +771 -0
- package/dist/executor.js +1829 -0
- package/dist/extension.d.ts +448 -0
- package/dist/extension.js +315 -0
- package/dist/facets.d.ts +53 -0
- package/dist/facets.js +60 -0
- package/dist/foldedSections.d.ts +74 -0
- package/dist/foldedSections.js +161 -0
- package/dist/genres.d.ts +507 -0
- package/dist/genres.js +633 -0
- package/dist/guardedConnection.d.ts +138 -0
- package/dist/guardedConnection.js +341 -0
- package/dist/handlebarsReach.d.ts +122 -0
- package/dist/handlebarsReach.js +222 -0
- package/dist/hash.d.ts +146 -0
- package/dist/hash.js +166 -0
- package/dist/hookGrants.d.ts +47 -0
- package/dist/hookGrants.js +68 -0
- package/dist/hooks.d.ts +290 -0
- package/dist/hooks.js +113 -0
- package/dist/hostElements.d.ts +447 -0
- package/dist/hostElements.js +702 -0
- package/dist/i18n.d.ts +94 -0
- package/dist/i18n.js +123 -0
- package/dist/identity.d.ts +93 -0
- package/dist/identity.js +135 -0
- package/dist/index.d.ts +85 -0
- package/dist/index.js +176 -0
- package/dist/layout.d.ts +194 -0
- package/dist/layout.js +40 -0
- package/dist/media.d.ts +202 -0
- package/dist/media.js +70 -0
- package/dist/messageBlocks.d.ts +487 -0
- package/dist/messageBlocks.js +683 -0
- package/dist/migration.d.ts +128 -0
- package/dist/migration.js +261 -0
- package/dist/names.d.ts +78 -0
- package/dist/names.js +136 -0
- package/dist/nodeInput.d.ts +399 -0
- package/dist/nodeInput.js +178 -0
- package/dist/participants.d.ts +291 -0
- package/dist/participants.js +252 -0
- package/dist/personGate.d.ts +62 -0
- package/dist/personGate.js +77 -0
- package/dist/pick.d.ts +84 -0
- package/dist/pick.js +103 -0
- package/dist/pluginHarness.d.ts +235 -0
- package/dist/pluginHarness.js +558 -0
- package/dist/pluginPermissions.d.ts +25 -0
- package/dist/pluginPermissions.js +97 -0
- package/dist/pluginRuleRef.d.ts +13 -0
- package/dist/pluginRuleRef.js +10 -0
- package/dist/predicates.d.ts +182 -0
- package/dist/predicates.js +249 -0
- package/dist/preview.d.ts +120 -0
- package/dist/preview.js +82 -0
- package/dist/promptBlocks.d.ts +130 -0
- package/dist/promptBlocks.js +197 -0
- package/dist/rankingDecisions.d.ts +60 -0
- package/dist/rankingDecisions.js +48 -0
- package/dist/receipt.d.ts +313 -0
- package/dist/receipt.js +60 -0
- package/dist/receiverRules.d.ts +24 -0
- package/dist/receiverRules.js +94 -0
- package/dist/refs.d.ts +117 -0
- package/dist/refs.js +137 -0
- package/dist/registry.d.ts +230 -0
- package/dist/registry.js +273 -0
- package/dist/review.d.ts +108 -0
- package/dist/review.js +97 -0
- package/dist/sampling.d.ts +152 -0
- package/dist/sampling.js +712 -0
- package/dist/scope.d.ts +65 -0
- package/dist/scope.js +128 -0
- package/dist/scripts.d.ts +243 -0
- package/dist/scripts.js +326 -0
- package/dist/sessionLayout.d.ts +339 -0
- package/dist/sessionLayout.js +503 -0
- package/dist/sessionSettings.d.ts +70 -0
- package/dist/sessionSettings.js +2 -0
- package/dist/settings.d.ts +501 -0
- package/dist/settings.js +604 -0
- package/dist/settingsSlot.d.ts +108 -0
- package/dist/settingsSlot.js +166 -0
- package/dist/shapes.d.ts +373 -0
- package/dist/shapes.js +408 -0
- package/dist/sheets.d.ts +165 -0
- package/dist/sheets.js +251 -0
- package/dist/statShapes.d.ts +96 -0
- package/dist/statShapes.js +112 -0
- package/dist/status.d.ts +103 -0
- package/dist/status.js +125 -0
- package/dist/storage.d.ts +145 -0
- package/dist/storage.js +33 -0
- package/dist/storyTime.d.ts +308 -0
- package/dist/storyTime.js +560 -0
- package/dist/surfaces.d.ts +501 -0
- package/dist/surfaces.js +292 -0
- package/dist/template.d.ts +312 -0
- package/dist/template.js +554 -0
- package/dist/templateCheck.d.ts +60 -0
- package/dist/templateCheck.js +516 -0
- package/dist/templateFit.d.ts +157 -0
- package/dist/templateFit.js +349 -0
- package/dist/templateIds.d.ts +138 -0
- package/dist/templateIds.js +144 -0
- package/dist/templateScopeAt.d.ts +131 -0
- package/dist/templateScopeAt.js +354 -0
- package/dist/testing.d.ts +177 -0
- package/dist/testing.js +383 -0
- package/dist/tokenizers.d.ts +113 -0
- package/dist/tokenizers.js +184 -0
- package/dist/turnLock.d.ts +96 -0
- package/dist/turnLock.js +79 -0
- package/dist/turnOrder.d.ts +143 -0
- package/dist/turnOrder.js +128 -0
- package/dist/validate.d.ts +74 -0
- package/dist/validate.js +1399 -0
- package/dist/values.d.ts +212 -0
- package/dist/values.js +390 -0
- package/dist/variables.d.ts +493 -0
- package/dist/variables.js +662 -0
- package/dist/verdicts.d.ts +275 -0
- package/dist/verdicts.js +348 -0
- package/dist/widgetDecls.d.ts +88 -0
- package/dist/widgetDecls.js +119 -0
- package/dist/widgets.d.ts +1527 -0
- package/dist/widgets.js +208 -0
- package/dist/wire.d.ts +126 -0
- package/dist/wire.js +140 -0
- package/dist/worldinfo.d.ts +150 -0
- package/dist/worldinfo.js +212 -0
- package/host-elements.d.ts +914 -0
- 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
|