@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,280 @@
|
|
|
1
|
+
import { WIDGET_SCOPED_SECTIONS, isWidgetScopedSectionName } from './widgets.js';
|
|
2
|
+
/** The handle key a function is replaced by on the wire. @experimental */
|
|
3
|
+
export const FN = '__spFn';
|
|
4
|
+
/** @experimental */
|
|
5
|
+
export const isFnHandle = (v) => !!v && typeof v === 'object' && typeof v[FN] === 'number';
|
|
6
|
+
/**
|
|
7
|
+
* 🚧 The error a component's `request` rejects with when the host declines:
|
|
8
|
+
* the host's sentence as `message`, and its {@link RequestDeclineCode} as
|
|
9
|
+
* `code` when it gave one (`unmounted` for every request still pending when
|
|
10
|
+
* the component is unmounted). Test `code`, never the sentence.
|
|
11
|
+
* @experimental
|
|
12
|
+
*/
|
|
13
|
+
export class RequestDeclined extends Error {
|
|
14
|
+
code;
|
|
15
|
+
constructor(message, code) {
|
|
16
|
+
super(message);
|
|
17
|
+
this.name = 'RequestDeclined';
|
|
18
|
+
if (code !== undefined)
|
|
19
|
+
this.code = code;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Replace every function in a value with a handle, registering it. Walks
|
|
24
|
+
* arrays and plain objects; everything else passes as is.
|
|
25
|
+
* @experimental
|
|
26
|
+
*/
|
|
27
|
+
export function encodeFns(value, register) {
|
|
28
|
+
if (typeof value === 'function')
|
|
29
|
+
return { [FN]: register(value) };
|
|
30
|
+
if (Array.isArray(value))
|
|
31
|
+
return value.map((v) => encodeFns(v, register));
|
|
32
|
+
if (value && typeof value === 'object') {
|
|
33
|
+
const out = {};
|
|
34
|
+
for (const [k, v] of Object.entries(value))
|
|
35
|
+
out[k] = encodeFns(v, register);
|
|
36
|
+
return out;
|
|
37
|
+
}
|
|
38
|
+
return value;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* The worker side of a mount's widget-protocol port: the same sections a
|
|
42
|
+
* native widget reads off its context and a frame is posted, and the same
|
|
43
|
+
* verbs back. Runs where the component runs — no page, no network, nothing
|
|
44
|
+
* but this port.
|
|
45
|
+
* @experimental
|
|
46
|
+
*/
|
|
47
|
+
export function createComponentContext(port) {
|
|
48
|
+
const data = { channels: {}, suspended: false, scoped: {} };
|
|
49
|
+
// Requests in flight, by id; the host answers each once (`page` / `response`).
|
|
50
|
+
const pending = new Map();
|
|
51
|
+
let nextRequest = 0;
|
|
52
|
+
// Translations the host sent, and the misses not yet asked for — asked in
|
|
53
|
+
// one batch per task, as the app's own `t()` does.
|
|
54
|
+
const strings = new Map();
|
|
55
|
+
const asked = new Set();
|
|
56
|
+
let misses = [];
|
|
57
|
+
const askLater = () => {
|
|
58
|
+
if (misses.length !== 1)
|
|
59
|
+
return;
|
|
60
|
+
setTimeout(() => {
|
|
61
|
+
const sources = misses;
|
|
62
|
+
misses = [];
|
|
63
|
+
if (sources.length)
|
|
64
|
+
port.postMessage({ t: 'translate', sources });
|
|
65
|
+
}, 0);
|
|
66
|
+
};
|
|
67
|
+
const subs = new Set();
|
|
68
|
+
const eventSubs = new Set();
|
|
69
|
+
const notify = (section) => {
|
|
70
|
+
for (const fn of subs) {
|
|
71
|
+
try {
|
|
72
|
+
fn(section);
|
|
73
|
+
}
|
|
74
|
+
catch (e) {
|
|
75
|
+
console.error(e);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
};
|
|
79
|
+
port.onmessage = (e) => {
|
|
80
|
+
const m = e.data;
|
|
81
|
+
if (!m || typeof m !== 'object')
|
|
82
|
+
return;
|
|
83
|
+
switch (m.t) {
|
|
84
|
+
case 'session':
|
|
85
|
+
data.session = m.session;
|
|
86
|
+
return notify('session');
|
|
87
|
+
case 'messages':
|
|
88
|
+
data.messages = m.messages;
|
|
89
|
+
return notify('messages');
|
|
90
|
+
case 'channel':
|
|
91
|
+
data.channels = { ...data.channels, [String(m.channel)]: m.messages };
|
|
92
|
+
return notify('channels');
|
|
93
|
+
case 'settings':
|
|
94
|
+
data.settings = m.settings;
|
|
95
|
+
return notify('settings');
|
|
96
|
+
case 'actions':
|
|
97
|
+
data.actions = m.actions;
|
|
98
|
+
return notify('actions');
|
|
99
|
+
case 'annex':
|
|
100
|
+
data.annex = m.annex;
|
|
101
|
+
return notify('annex');
|
|
102
|
+
case 'props':
|
|
103
|
+
data.props = m.props;
|
|
104
|
+
return notify('props');
|
|
105
|
+
case 'theme':
|
|
106
|
+
data.theme = { theme: String(m.theme ?? ''), mode: m.mode === 'dark' ? 'dark' : 'light' };
|
|
107
|
+
return notify('theme');
|
|
108
|
+
case 'scoped': {
|
|
109
|
+
const name = m.section;
|
|
110
|
+
// A name the table does not carry is not a section this widget can hold.
|
|
111
|
+
if (isWidgetScopedSectionName(name)) {
|
|
112
|
+
// `null` withdraws it: the grant went away.
|
|
113
|
+
const { [name]: _gone, ...rest } = data.scoped;
|
|
114
|
+
data.scoped = (m.value === null ? rest : { ...rest, [name]: m.value });
|
|
115
|
+
}
|
|
116
|
+
return notify('scoped');
|
|
117
|
+
}
|
|
118
|
+
case 'grants': {
|
|
119
|
+
// A list, or nothing new; only a scope the table names is kept.
|
|
120
|
+
if (!Array.isArray(m.grants))
|
|
121
|
+
return;
|
|
122
|
+
data.grants = m.grants.filter((g) => typeof g === 'string' && Object.hasOwn(WIDGET_SCOPED_SECTIONS, g));
|
|
123
|
+
return notify('grants');
|
|
124
|
+
}
|
|
125
|
+
case 'viewer':
|
|
126
|
+
data.viewer = m.viewer;
|
|
127
|
+
return notify('viewer');
|
|
128
|
+
case 'turn-order':
|
|
129
|
+
data.turnOrder = m.turnOrder;
|
|
130
|
+
return notify('turnOrder');
|
|
131
|
+
case 'page':
|
|
132
|
+
case 'response': {
|
|
133
|
+
const waiting = pending.get(String(m.requestId));
|
|
134
|
+
if (!waiting)
|
|
135
|
+
return;
|
|
136
|
+
pending.delete(String(m.requestId));
|
|
137
|
+
if (m.t === 'page')
|
|
138
|
+
return waiting.resolve({ rows: m.rows, nextCursor: m.nextCursor });
|
|
139
|
+
return m.ok
|
|
140
|
+
? waiting.resolve(m.result)
|
|
141
|
+
: waiting.reject(new RequestDeclined(String(m.error ?? 'the host declined'), m.code === 'unmounted' ? 'unmounted' : undefined));
|
|
142
|
+
}
|
|
143
|
+
case 'strings':
|
|
144
|
+
for (const [k, v] of Object.entries((m.strings ?? {})))
|
|
145
|
+
if (typeof v === 'string')
|
|
146
|
+
strings.set(k, v);
|
|
147
|
+
return notify('strings');
|
|
148
|
+
case 'locale':
|
|
149
|
+
data.locale = String(m.locale ?? 'en');
|
|
150
|
+
return notify('locale');
|
|
151
|
+
case 'layout':
|
|
152
|
+
data.layout = m.layout;
|
|
153
|
+
return notify('layout');
|
|
154
|
+
case 'state':
|
|
155
|
+
data.state = m.state;
|
|
156
|
+
return notify('state');
|
|
157
|
+
case 'suspend':
|
|
158
|
+
case 'resume':
|
|
159
|
+
data.suspended = m.t === 'suspend';
|
|
160
|
+
return notify('suspended');
|
|
161
|
+
case 'event':
|
|
162
|
+
for (const fn of eventSubs) {
|
|
163
|
+
try {
|
|
164
|
+
fn(m.event);
|
|
165
|
+
}
|
|
166
|
+
catch (e) {
|
|
167
|
+
console.error(e);
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
return notify('event');
|
|
171
|
+
// `style` is the host's: applied to the box, never to worker code.
|
|
172
|
+
}
|
|
173
|
+
};
|
|
174
|
+
const ctx = {
|
|
175
|
+
get session() {
|
|
176
|
+
return data.session;
|
|
177
|
+
},
|
|
178
|
+
get messages() {
|
|
179
|
+
return data.messages;
|
|
180
|
+
},
|
|
181
|
+
get channels() {
|
|
182
|
+
return data.channels;
|
|
183
|
+
},
|
|
184
|
+
get settings() {
|
|
185
|
+
return data.settings;
|
|
186
|
+
},
|
|
187
|
+
get actions() {
|
|
188
|
+
return data.actions;
|
|
189
|
+
},
|
|
190
|
+
get annex() {
|
|
191
|
+
return data.annex;
|
|
192
|
+
},
|
|
193
|
+
get props() {
|
|
194
|
+
return data.props;
|
|
195
|
+
},
|
|
196
|
+
get theme() {
|
|
197
|
+
return data.theme;
|
|
198
|
+
},
|
|
199
|
+
get locale() {
|
|
200
|
+
return data.locale;
|
|
201
|
+
},
|
|
202
|
+
get layout() {
|
|
203
|
+
return data.layout;
|
|
204
|
+
},
|
|
205
|
+
get state() {
|
|
206
|
+
return data.state;
|
|
207
|
+
},
|
|
208
|
+
get suspended() {
|
|
209
|
+
return data.suspended;
|
|
210
|
+
},
|
|
211
|
+
subscribe(fn) {
|
|
212
|
+
subs.add(fn);
|
|
213
|
+
return () => subs.delete(fn);
|
|
214
|
+
},
|
|
215
|
+
onEvent(fn) {
|
|
216
|
+
eventSubs.add(fn);
|
|
217
|
+
return () => eventSubs.delete(fn);
|
|
218
|
+
},
|
|
219
|
+
invoke(key, args = {}) {
|
|
220
|
+
port.postMessage({ t: 'invoke', key, ...args });
|
|
221
|
+
},
|
|
222
|
+
saveState(state) {
|
|
223
|
+
port.postMessage({ t: 'save-state', state });
|
|
224
|
+
},
|
|
225
|
+
error(message, fatal = false) {
|
|
226
|
+
port.postMessage({ t: 'error', message: String(message), fatal });
|
|
227
|
+
},
|
|
228
|
+
get scoped() {
|
|
229
|
+
return data.scoped;
|
|
230
|
+
},
|
|
231
|
+
action(fn, messageId, payload, action, blockId) {
|
|
232
|
+
port.postMessage({ t: 'action', fn, messageId, payload, action, blockId });
|
|
233
|
+
},
|
|
234
|
+
request(kind, params) {
|
|
235
|
+
const requestId = `r${++nextRequest}`;
|
|
236
|
+
return new Promise((resolve, reject) => {
|
|
237
|
+
pending.set(requestId, { resolve, reject });
|
|
238
|
+
port.postMessage(kind === 'messages'
|
|
239
|
+
? { t: 'request', requestId, what: 'messages', ...params }
|
|
240
|
+
: { t: 'request', requestId, what: kind, params });
|
|
241
|
+
});
|
|
242
|
+
},
|
|
243
|
+
t(source) {
|
|
244
|
+
const hit = strings.get(source);
|
|
245
|
+
if (hit !== undefined)
|
|
246
|
+
return hit;
|
|
247
|
+
if (!asked.has(source)) {
|
|
248
|
+
asked.add(source);
|
|
249
|
+
misses.push(source);
|
|
250
|
+
askLater();
|
|
251
|
+
}
|
|
252
|
+
return source;
|
|
253
|
+
},
|
|
254
|
+
get viewer() {
|
|
255
|
+
return data.viewer;
|
|
256
|
+
},
|
|
257
|
+
get turnOrder() {
|
|
258
|
+
return data.turnOrder;
|
|
259
|
+
},
|
|
260
|
+
get grants() {
|
|
261
|
+
return data.grants;
|
|
262
|
+
},
|
|
263
|
+
granted(scope) {
|
|
264
|
+
return data.grants === undefined ? undefined : data.grants.includes(scope);
|
|
265
|
+
},
|
|
266
|
+
ready() {
|
|
267
|
+
port.postMessage({ t: 'ready' });
|
|
268
|
+
},
|
|
269
|
+
close() {
|
|
270
|
+
for (const w of pending.values())
|
|
271
|
+
w.reject(new RequestDeclined('the component was unmounted', 'unmounted'));
|
|
272
|
+
pending.clear();
|
|
273
|
+
subs.clear();
|
|
274
|
+
eventSubs.clear();
|
|
275
|
+
port.close();
|
|
276
|
+
}
|
|
277
|
+
};
|
|
278
|
+
return ctx;
|
|
279
|
+
}
|
|
280
|
+
//# sourceMappingURL=componentWire.js.map
|
package/dist/config.d.ts
ADDED
|
@@ -0,0 +1,295 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Configuration resolution (12 §2). Four layers, first hit wins, evaluated
|
|
3
|
+
* independently per path — which is what makes an admin's connection change reach a
|
|
4
|
+
* user who has customized their prompts (F20).
|
|
5
|
+
*
|
|
6
|
+
* ## The chain (R-10, ruled 2026-09-15; 09-B B8)
|
|
7
|
+
*
|
|
8
|
+
* **`session · config · defaults · author`.**
|
|
9
|
+
*
|
|
10
|
+
* - `session` — a session's own override of a value (the *chat override* of
|
|
11
|
+
* 12 §2's "pipeline → config → chat override").
|
|
12
|
+
* - `config` — the rows of the **selected config**: the config IS the
|
|
13
|
+
* instance's tuning. An administrator's edit lands in the config (ruled
|
|
14
|
+
* 2026-08-24), so there is no separate `instance` layer for it to be shadowed
|
|
15
|
+
* by, and no `user` layer — a preference that differs per user is a session's
|
|
16
|
+
* to hold.
|
|
17
|
+
* - `defaults` — values a host *projects* rather than values anyone decided:
|
|
18
|
+
* system settings, connection defaults, a legacy layer. Nothing interactive
|
|
19
|
+
* writes here (it appears in no write matrix row).
|
|
20
|
+
* - `author` — the definition's declared parameter defaults; the floor.
|
|
21
|
+
*
|
|
22
|
+
* `user` and `instance` stood in this list until 2026-09-16 and were pushed by
|
|
23
|
+
* nothing: `world.ts` never projected a row at either (plans/29a §3). Their
|
|
24
|
+
* semantics fold into `config` — the config an admin edits is the instance's
|
|
25
|
+
* configuration — which is the 2026-08-24 ruling stated as a constant.
|
|
26
|
+
*
|
|
27
|
+
* Resolved run-wide *before* execution, which is why referencing another node's
|
|
28
|
+
* config is not a data edge (F35).
|
|
29
|
+
*
|
|
30
|
+
* ## `config`, not `preset` (R1)
|
|
31
|
+
*
|
|
32
|
+
* Two other things are called a preset — a **session preset** (the bundle a
|
|
33
|
+
* session is born on) and an author's `.preset(…)` on a spec — and neither is
|
|
34
|
+
* this layer, so the scope takes the canon's word for what it holds: the
|
|
35
|
+
* **config**.
|
|
36
|
+
*/
|
|
37
|
+
import type { CapabilitySet } from './capabilities.js';
|
|
38
|
+
/** @experimental */
|
|
39
|
+
export type ScopeKind = 'session' | 'config' | 'defaults' | 'author';
|
|
40
|
+
/** @internal */
|
|
41
|
+
export declare const SCOPE_ORDER: ScopeKind[];
|
|
42
|
+
/**
|
|
43
|
+
* A row's scope kind. Anything that is not a `ScopeKind` is `undefined` — a
|
|
44
|
+
* row at a scope nobody resolves at, which resolution skips rather than
|
|
45
|
+
* guesses about.
|
|
46
|
+
* @experimental 🚧
|
|
47
|
+
*/
|
|
48
|
+
export declare function scopeKindOf(raw: unknown): ScopeKind | undefined;
|
|
49
|
+
/** @experimental */
|
|
50
|
+
export interface OverrideRow {
|
|
51
|
+
nodeKey: string;
|
|
52
|
+
slot: string;
|
|
53
|
+
path: string;
|
|
54
|
+
value: unknown;
|
|
55
|
+
scopeKind: ScopeKind;
|
|
56
|
+
scopeId?: string | number;
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* The path a REF slot's single value lives at.
|
|
60
|
+
*
|
|
61
|
+
* A `connection` or `sampling` slot holds exactly one thing — the id of a row in
|
|
62
|
+
* its own table — so it has no sub-paths and its address is the empty one.
|
|
63
|
+
*
|
|
64
|
+
* This constant exists because that fact was written down three different ways
|
|
65
|
+
* and the three never met. The panel wrote `''`, the app's legacy projection
|
|
66
|
+
* wrote `'ref'`, and this file's own executor read `'$ref'`; resolution below is
|
|
67
|
+
* exact-match on `(nodeKey, slot, path)`, so the three were unrelated addresses
|
|
68
|
+
* that could never collide and never warn. A pick made in the config panel was
|
|
69
|
+
* saved, shown back, and read by nobody — for as long as the feature has existed.
|
|
70
|
+
*
|
|
71
|
+
* `''` is the winner because it is what the writer already emits, so it is what
|
|
72
|
+
* is already in every user's `pipeline_config_values`. Any other choice would
|
|
73
|
+
* migrate live data to match a convention only the reader believed in.
|
|
74
|
+
*
|
|
75
|
+
* @internal
|
|
76
|
+
*/
|
|
77
|
+
export declare const SLOT_VALUE: '';
|
|
78
|
+
/** @experimental */
|
|
79
|
+
export interface SamplingConfig {
|
|
80
|
+
id: string;
|
|
81
|
+
name: string;
|
|
82
|
+
/** Which vocabulary `values` speaks — a `SAMPLING_SCHEMAS` key (sampling.ts). */
|
|
83
|
+
shape: string;
|
|
84
|
+
values: Record<string, unknown>;
|
|
85
|
+
/**
|
|
86
|
+
* Which of `values` is actually switched on.
|
|
87
|
+
*
|
|
88
|
+
* Without this the world could carry a config's values but not its
|
|
89
|
+
* switchboard, so slot resolution had no choice but to hand every stored
|
|
90
|
+
* value to the provider — including the ones a person had switched off. A
|
|
91
|
+
* sampler turned off in the sidebar went on being sent, and the only symptom
|
|
92
|
+
* was generation that did not match the settings on screen.
|
|
93
|
+
*
|
|
94
|
+
* Absent (as opposed to empty) means a world that predates the distinction:
|
|
95
|
+
* every value is treated as on, which is what resolution did before.
|
|
96
|
+
*/
|
|
97
|
+
enabled?: string[];
|
|
98
|
+
}
|
|
99
|
+
/** @experimental */
|
|
100
|
+
export interface ConnectionRecord {
|
|
101
|
+
id: string;
|
|
102
|
+
name: string;
|
|
103
|
+
kind: string;
|
|
104
|
+
/** Readable — not a credential (01 §10). */
|
|
105
|
+
metadata: {
|
|
106
|
+
contextLength?: number;
|
|
107
|
+
tokenizer?: string;
|
|
108
|
+
model?: string;
|
|
109
|
+
supportedSamplers?: string[];
|
|
110
|
+
};
|
|
111
|
+
/** Never readable by any node. Injected per call by the executor. */
|
|
112
|
+
material: Record<string, string>;
|
|
113
|
+
/**
|
|
114
|
+
* What this connection can actually do (capabilities.ts), resolved.
|
|
115
|
+
*
|
|
116
|
+
* Readable, and on the same side of the line as `metadata`: a binding asking
|
|
117
|
+
* whether it may send an image is asking about the wire protocol, not about a
|
|
118
|
+
* credential. Absent or empty means **undetermined** — what a connection
|
|
119
|
+
* nobody has tested yet looks like — and never "this connection can do
|
|
120
|
+
* nothing"; a caller that reads it as a denial will hide working connections.
|
|
121
|
+
*/
|
|
122
|
+
capabilities?: CapabilitySet;
|
|
123
|
+
enabled?: boolean;
|
|
124
|
+
}
|
|
125
|
+
/**
|
|
126
|
+
* What a `connection` slot STORES at {@link SLOT_VALUE} — one endpoint, and
|
|
127
|
+
* optionally one of the models that endpoint reaches.
|
|
128
|
+
*
|
|
129
|
+
* A pick is a **pair**, not an id. The endpoint says where the compute is; the
|
|
130
|
+
* model says which of the several things behind it answers. The two halves
|
|
131
|
+
* travel together or the second is lost, and losing it is silent — the request
|
|
132
|
+
* still goes to the right server and comes back from a different model.
|
|
133
|
+
*
|
|
134
|
+
* The shape lives here, beside the constant that names its address, because the
|
|
135
|
+
* executor and every host that writes a pick have to agree on it and there is
|
|
136
|
+
* nowhere else both can see. It was spelled twice and the two spellings
|
|
137
|
+
* disagreed: this file's executor compared the *whole stored value* with a
|
|
138
|
+
* connection id, so an object pair stringified to `[object Object]`, matched no
|
|
139
|
+
* connection, and fell through to the instance default. No error, no log line,
|
|
140
|
+
* and on most installs the default is the very connection that was picked — so
|
|
141
|
+
* the pick appeared to work right up until it didn't.
|
|
142
|
+
*
|
|
143
|
+
* ⚠ **Backward compatible by construction.** Every value written before the
|
|
144
|
+
* pair existed is one of `12`, `'12'`, `{ref: 12}` or `{id: 12}`, and all four
|
|
145
|
+
* still mean the same thing: this endpoint, no model named. A pair adds one
|
|
146
|
+
* key. So nothing stored needs migrating and no reader needs a version check.
|
|
147
|
+
*
|
|
148
|
+
* ⚠ Naming **no** model is not naming a *default* model. An endpoint has no
|
|
149
|
+
* model it is presumed to mean; what a host does with a half-named pair —
|
|
150
|
+
* resolve a default of its own, or refuse it as unconfigured — is the host's
|
|
151
|
+
* ruling. This type's only job is to say which half is absent.
|
|
152
|
+
* @internal
|
|
153
|
+
*/
|
|
154
|
+
export type ConnectionSlotValue = string | number | {
|
|
155
|
+
ref?: string | number;
|
|
156
|
+
id?: string | number;
|
|
157
|
+
modelId?: string | number | null;
|
|
158
|
+
};
|
|
159
|
+
/**
|
|
160
|
+
* The endpoint half of a connection slot's value, or null when it names none.
|
|
161
|
+
*
|
|
162
|
+
* Returns the id **exactly as stored** — a string stays a string, a number
|
|
163
|
+
* stays a number. Row ids belong to the host, and this package has no business
|
|
164
|
+
* ruling that they are one or the other; the string/number divide is reconciled
|
|
165
|
+
* where the comparison happens, not here.
|
|
166
|
+
* @internal
|
|
167
|
+
*/
|
|
168
|
+
export declare function slotConnectionId(value: unknown): string | number | null;
|
|
169
|
+
/**
|
|
170
|
+
* The model half of a connection slot's value, or null when it names no model.
|
|
171
|
+
*
|
|
172
|
+
* Null for every value written before the pair existed, which is the whole
|
|
173
|
+
* compatibility story — and null is *absence*, never a model the endpoint is
|
|
174
|
+
* taken to mean. Same id-type rule as {@link slotConnectionId}: stored as
|
|
175
|
+
* given, back as stored.
|
|
176
|
+
* @internal
|
|
177
|
+
*/
|
|
178
|
+
export declare function slotConnectionModelId(value: unknown): string | number | null;
|
|
179
|
+
/**
|
|
180
|
+
* A resolved `connection` slot, as a binding receives it.
|
|
181
|
+
*
|
|
182
|
+
* `metadata` only — `material` is a credential and is injected by the executor
|
|
183
|
+
* at call time (01 §10), so no node ever sees it.
|
|
184
|
+
*
|
|
185
|
+
* `modelId` is the model half of the pair the slot named, carried through so a
|
|
186
|
+
* host can honour the pick instead of reducing it to an endpoint. Null means
|
|
187
|
+
* the slot named no model, and that **includes** the case where nothing was
|
|
188
|
+
* picked at all and `activeConnection` answered: that map is keyed by shape and
|
|
189
|
+
* holds an endpoint id alone, so there is no model half here to carry. A host
|
|
190
|
+
* whose own defaults are pairs resolves that half for itself, from the store
|
|
191
|
+
* the default came out of.
|
|
192
|
+
* @experimental
|
|
193
|
+
*/
|
|
194
|
+
export interface ResolvedConnection {
|
|
195
|
+
id: string;
|
|
196
|
+
kind: string;
|
|
197
|
+
metadata: ConnectionRecord['metadata'];
|
|
198
|
+
modelId: string | number | null;
|
|
199
|
+
/**
|
|
200
|
+
* The named model's own context window, when the host records one
|
|
201
|
+
* (`ConfigWorld.models`); null when the slot named no model or the model
|
|
202
|
+
* states none, in which case the sampling config's window decides.
|
|
203
|
+
*
|
|
204
|
+
* Carried here so the ONE window computation (R-8) can read it off the
|
|
205
|
+
* same resolved slot the request is sent with — a budget sized to the
|
|
206
|
+
* sampling config's window while the request went to a model with a
|
|
207
|
+
* smaller one was wrong in the direction that truncates.
|
|
208
|
+
*/
|
|
209
|
+
contextWindow: number | null;
|
|
210
|
+
}
|
|
211
|
+
/** @experimental */
|
|
212
|
+
export interface ConfigWorld {
|
|
213
|
+
overrides: OverrideRow[];
|
|
214
|
+
samplingConfigs: SamplingConfig[];
|
|
215
|
+
connections: ConnectionRecord[];
|
|
216
|
+
/**
|
|
217
|
+
* The models the host knows per connection, for the facts a resolved pair
|
|
218
|
+
* carries beyond the endpoint's metadata — today only the context window.
|
|
219
|
+
* Optional: a host that publishes none resolves every pair with
|
|
220
|
+
* `contextWindow: null`, exactly as before this existed.
|
|
221
|
+
*/
|
|
222
|
+
models?: Array<{
|
|
223
|
+
id: string;
|
|
224
|
+
connectionId: string;
|
|
225
|
+
contextWindow?: number | null;
|
|
226
|
+
}>;
|
|
227
|
+
/** Singleton kinds, e.g. embeddings (01 §10). */
|
|
228
|
+
activeConnection: Record<string, string | null>;
|
|
229
|
+
/**
|
|
230
|
+
* The instance's default sampling config per kind — the same keys
|
|
231
|
+
* `activeConnection` uses, and the same job.
|
|
232
|
+
*
|
|
233
|
+
* ⚠ Its absence was an asymmetry, not a decision. A `connection` slot with
|
|
234
|
+
* no pick falls through to `activeConnection[kind]` here *and* falls through
|
|
235
|
+
* to the instance default at dispatch, so the two agree. A `sampling` slot
|
|
236
|
+
* with no pick resolved to `{}` here while dispatch still sent the instance
|
|
237
|
+
* default's window — so a node that READS the resolved values (the batch
|
|
238
|
+
* cutter, which has to fit a prompt into that window) computed against
|
|
239
|
+
* nothing while the prompt went out against something. A budget computed
|
|
240
|
+
* against one window and a prompt sent against another is wrong in the
|
|
241
|
+
* direction that truncates, silently.
|
|
242
|
+
*
|
|
243
|
+
* Optional, so a host that does not publish it behaves exactly as before.
|
|
244
|
+
*/
|
|
245
|
+
activeSampling?: Record<string, string | null>;
|
|
246
|
+
authorDefaults?: Record<string, Record<string, Record<string, unknown>>>;
|
|
247
|
+
}
|
|
248
|
+
/** @experimental */
|
|
249
|
+
export type ResolvedConfig = Record<string, Record<string, Record<string, unknown>>>;
|
|
250
|
+
/**
|
|
251
|
+
* A resolved value **and the layer it won at**.
|
|
252
|
+
*
|
|
253
|
+
* The layer is not decoration. *"I changed this and nothing happened"* is the
|
|
254
|
+
* most common support question this system can produce, and it is unanswerable
|
|
255
|
+
* from the value alone — the answer is always "something above you set it too",
|
|
256
|
+
* and only this says which something.
|
|
257
|
+
* @experimental
|
|
258
|
+
*/
|
|
259
|
+
export interface ResolvedSource {
|
|
260
|
+
value: unknown;
|
|
261
|
+
/** Which layer won. `author` means the declared default was never overridden. */
|
|
262
|
+
scopeKind: ScopeKind | 'author';
|
|
263
|
+
/** The user or chat the winning row belonged to, where one applies. */
|
|
264
|
+
scopeId?: string | number;
|
|
265
|
+
}
|
|
266
|
+
/** @experimental */
|
|
267
|
+
export type ResolvedConfigSources = Record<string, Record<string, Record<string, ResolvedSource>>>;
|
|
268
|
+
/**
|
|
269
|
+
* Effective config **with provenance** = base ⊕ overrides, per (nodeKey, slot, path).
|
|
270
|
+
*
|
|
271
|
+
* This is the primitive; `resolveConfig` is derived from it rather than written
|
|
272
|
+
* beside it. Two implementations of a five-layer walk are two implementations
|
|
273
|
+
* that eventually disagree about which layer wins — and the one that disagrees
|
|
274
|
+
* silently is whichever one the UI is not using.
|
|
275
|
+
* @internal
|
|
276
|
+
*/
|
|
277
|
+
export declare function resolveConfigSources(world: ConfigWorld, nodeKeys: string[]): ResolvedConfigSources;
|
|
278
|
+
/** Effective config = base ⊕ overrides, per (nodeKey, slot, path). @internal */
|
|
279
|
+
export declare function resolveConfig(world: ConfigWorld, nodeKeys: string[]): ResolvedConfig;
|
|
280
|
+
/**
|
|
281
|
+
* Which scopes may write which slot (12 §4). The admin cascade needs no mechanism:
|
|
282
|
+
* connection has no writable scope below the config for a non-admin, so an
|
|
283
|
+
* admin's choice reaches everyone automatically.
|
|
284
|
+
*
|
|
285
|
+
* `config` here is the selected config — the one place an administrator's
|
|
286
|
+
* edit lands (R-10 folded `instance` into it, 2026-09-16). A slot a session may
|
|
287
|
+
* not write is a slot only the config carries.
|
|
288
|
+
* @internal
|
|
289
|
+
*/
|
|
290
|
+
export declare const WRITE_MATRIX: Record<string, ScopeKind[]>;
|
|
291
|
+
/** @internal */
|
|
292
|
+
export declare function mayWrite(slot: string, scope: ScopeKind): boolean;
|
|
293
|
+
/** Reject a write the matrix forbids, with the reason (15 §1.3). @experimental */
|
|
294
|
+
export declare function assertWritable(slot: string, scope: ScopeKind): void;
|
|
295
|
+
//# sourceMappingURL=config.d.ts.map
|