@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,1527 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The widget data contract — ONE envelope every session widget receives,
|
|
3
|
+
* native and frame alike (PLAN 25, ruled 2026-08-30).
|
|
4
|
+
*
|
|
5
|
+
* A native widget reads these sections through the host's in-document context
|
|
6
|
+
* (live, reactive); a frame receives the same sections snapshotted over its
|
|
7
|
+
* port. Field-for-field identical: reactivity is the native analog of a push,
|
|
8
|
+
* and that is the whole of the difference. The declarations live here so the
|
|
9
|
+
* two deliveries cannot drift — a plugin compiled against this package sees
|
|
10
|
+
* exactly the shapes an instance sends.
|
|
11
|
+
*
|
|
12
|
+
* These types are TRANSPORT-NEUTRAL. The frame wire that carries them is
|
|
13
|
+
* `surfaces.ts` (`HostFrameMessage` / `FrameHostMessage`); the host internals
|
|
14
|
+
* that produce them — measuring a box, deciding a grant — are core's and are
|
|
15
|
+
* not declared here.
|
|
16
|
+
*
|
|
17
|
+
* ## Two version clocks
|
|
18
|
+
*
|
|
19
|
+
* - `WIDGET_PROTOCOL` versions the TRANSPORT — the verbs (`action` / `invoke`
|
|
20
|
+
* / `request` / `menu` / `on`) and the message kinds. Rev only when the wire
|
|
21
|
+
* itself changes.
|
|
22
|
+
* - Each DATA section is a bag of versioned shapes (`layout: { v1 }`, …). When
|
|
23
|
+
* a pre-existing key inside a section changes meaning, emit `v2` alongside
|
|
24
|
+
* `v1` for a transition window; old widgets read `.v1`, new ones read `.v2`.
|
|
25
|
+
* ADDITIVE keys go straight into the existing `v1` — no bump.
|
|
26
|
+
*
|
|
27
|
+
* ## Base vs scoped
|
|
28
|
+
*
|
|
29
|
+
* Base sections ({@link WIDGET_BASE_SECTIONS}: layout / session / channels /
|
|
30
|
+
* messages / props / actions / settings / annex / locale / viewer /
|
|
31
|
+
* turnOrder) are delivered to every widget that READS them (R75,
|
|
32
|
+
* `WidgetDecl.reads`; a declaration without `reads` reads all of them, which
|
|
33
|
+
* is every widget written before R75). Scoped sections
|
|
34
|
+
* ({@link WidgetScopedSections}, the one table) appear ONLY when the widget
|
|
35
|
+
* declared the scope AND it was granted — the same deny-by-default a frame
|
|
36
|
+
* gets, applied at projection so a native widget is no more privileged.
|
|
37
|
+
* Absence means "not granted", never a silent empty — or "not posted yet":
|
|
38
|
+
* which of the two, the host says with `grants` (the scopes the widget
|
|
39
|
+
* holds, on mount and on every change), so a widget draws "not granted"
|
|
40
|
+
* rather than loading forever.
|
|
41
|
+
*/
|
|
42
|
+
import type { TurnOrderV1 } from './turnOrder.js';
|
|
43
|
+
import type { SlotAppliesTo, SlotType, SlotValue } from './attributes.js';
|
|
44
|
+
import type { FieldDecl } from './settings.js';
|
|
45
|
+
import type { StatusText, WidgetActionReason } from './status.js';
|
|
46
|
+
import type { EnabledWhen } from './predicates.js';
|
|
47
|
+
/** Free-form data riding beside a verb or an event. Keys are the sender's. @experimental */
|
|
48
|
+
export type WidgetPayload = Record<string, unknown>;
|
|
49
|
+
/**
|
|
50
|
+
* The width class of a widget's own box.
|
|
51
|
+
*
|
|
52
|
+
* A fact about the widget's box, not the window: a widget in a 240px rail is
|
|
53
|
+
* `compact` however wide the viewport is, and that is what it reflows against.
|
|
54
|
+
* @experimental
|
|
55
|
+
*/
|
|
56
|
+
export type WidgetTier = 'compact' | 'cozy' | 'roomy' | 'wide';
|
|
57
|
+
/** Where this widget sits, and what the host is painting around it. @experimental */
|
|
58
|
+
export interface LayoutV1 {
|
|
59
|
+
/**
|
|
60
|
+
* Which zone in the page-level zone grid (identity + totals).
|
|
61
|
+
*
|
|
62
|
+
* Cell counts of the zone's grid — the session layout's whole cells. Read
|
|
63
|
+
* them for where the widget sits, never for its size: `tier`, `box.px`,
|
|
64
|
+
* `box.edges` and `chrome` are the fields a widget sizes itself by.
|
|
65
|
+
*/
|
|
66
|
+
zone: {
|
|
67
|
+
columns: number;
|
|
68
|
+
column: number;
|
|
69
|
+
rows: number;
|
|
70
|
+
row: number;
|
|
71
|
+
};
|
|
72
|
+
/** Where this widget sits within its zone. */
|
|
73
|
+
box: {
|
|
74
|
+
/** Width in the zone's cells. See `zone`. */
|
|
75
|
+
cols: number;
|
|
76
|
+
/**
|
|
77
|
+
* Height in the zone's cells, or null when the widget grows / is
|
|
78
|
+
* unbounded. See `zone`.
|
|
79
|
+
*/
|
|
80
|
+
rows: number | null;
|
|
81
|
+
/** Which zone edges the widget touches. */
|
|
82
|
+
edges: {
|
|
83
|
+
top: boolean;
|
|
84
|
+
right: boolean;
|
|
85
|
+
bottom: boolean;
|
|
86
|
+
left: boolean;
|
|
87
|
+
};
|
|
88
|
+
/**
|
|
89
|
+
* The widget box as the host MEASURED it, in CSS pixels.
|
|
90
|
+
*
|
|
91
|
+
* The size a widget can actually draw against: whatever the browser
|
|
92
|
+
* resolved for the widget's box, so the number is the answer rather
|
|
93
|
+
* than a cell count multiplied by the cell module.
|
|
94
|
+
*
|
|
95
|
+
* Absent when the host has not measured this mount — a widget in a
|
|
96
|
+
* pop-over, a first frame before layout settles, a host that measures
|
|
97
|
+
* width alone. Absent is "unknown", never zero, so a widget reads
|
|
98
|
+
* `tier` when it is missing rather than reflowing against a 0.
|
|
99
|
+
*/
|
|
100
|
+
px?: {
|
|
101
|
+
width: number;
|
|
102
|
+
height: number;
|
|
103
|
+
};
|
|
104
|
+
};
|
|
105
|
+
/** The width class of this widget's own box. */
|
|
106
|
+
tier: WidgetTier;
|
|
107
|
+
/** Guaranteed-visible: placed in the grid, not collapsible/closable away. */
|
|
108
|
+
pinned: boolean;
|
|
109
|
+
collapsed: boolean;
|
|
110
|
+
drawered: boolean;
|
|
111
|
+
/**
|
|
112
|
+
* Decoration the HOST is painting, so the widget suppresses its own and
|
|
113
|
+
* never double-draws (a widget renders its own backdrop only where false).
|
|
114
|
+
*/
|
|
115
|
+
chrome: {
|
|
116
|
+
background: boolean;
|
|
117
|
+
wrapper: boolean;
|
|
118
|
+
titleBar: boolean;
|
|
119
|
+
padding: boolean;
|
|
120
|
+
/**
|
|
121
|
+
* @experimental Is the host drawing its **card** around this widget —
|
|
122
|
+
* a surface, a border and (outside a tab group) a title bar?
|
|
123
|
+
*
|
|
124
|
+
* Off by default for a widget placed in a zone: it sits flush in its
|
|
125
|
+
* cell and its own style decides whether it has a surface. On when the
|
|
126
|
+
* person turned on the widget's **Card** setting (`hostCard`), and
|
|
127
|
+
* always on while the widget is momentarily opened over the session (a
|
|
128
|
+
* pop-over, a flyout, the phone's panel sheet). When it is on,
|
|
129
|
+
* `background` and `wrapper` are true as well.
|
|
130
|
+
*
|
|
131
|
+
* The page also marks the widget's box `data-sp-card="on"` or `"off"`,
|
|
132
|
+
* so a stylesheet can key off the same fact without reading this.
|
|
133
|
+
*/
|
|
134
|
+
card: boolean;
|
|
135
|
+
};
|
|
136
|
+
}
|
|
137
|
+
/** The session a widget is drawn in, as much of it as every widget may see. @experimental */
|
|
138
|
+
export interface SessionV1 {
|
|
139
|
+
id: number;
|
|
140
|
+
name: string | null;
|
|
141
|
+
}
|
|
142
|
+
/**
|
|
143
|
+
* @experimental One message as a widget sees it (🚧 `parts`).
|
|
144
|
+
*
|
|
145
|
+
* The host posts the session's message rows, so what arrives is a row: `id`,
|
|
146
|
+
* `role` and `content` are on every one of them, and the rest is present when
|
|
147
|
+
* the row carries it. The index signature is the honest part of the shape —
|
|
148
|
+
* the host forwards the row, less only its bookkeeping (below), so columns
|
|
149
|
+
* not named here ride along at the top level, and a widget that reaches for one is
|
|
150
|
+
* reading something core may narrow without notice.
|
|
151
|
+
*
|
|
152
|
+
* A widget renders from the named fields. `extras` is the row's own bag, not a
|
|
153
|
+
* catch-all for the unnamed ones.
|
|
154
|
+
*
|
|
155
|
+
* Withheld, though the stored row carries them: `userId` (a widget never
|
|
156
|
+
* compares user ids — the host answers "may this viewer act" itself),
|
|
157
|
+
* `queueItemId`, `debugMeta` (the compiled prompt — admins read it through
|
|
158
|
+
* the host's `prompt-details`), `embedding` (the row's vector),
|
|
159
|
+
* `embeddingModel`, `embeddingSourceHash` and `embedTextHash` (the hashes the
|
|
160
|
+
* embedding queue compares), `vectorizedAt` and `version`. They are host
|
|
161
|
+
* bookkeeping, listed once in {@link MESSAGE_HOST_FIELDS}: a host strips them
|
|
162
|
+
* from every row it posts ({@link projectMessageRow}), so a widget never
|
|
163
|
+
* receives them.
|
|
164
|
+
*/
|
|
165
|
+
export interface MessageV1 {
|
|
166
|
+
/** The row's id. What every verb taking a `messageId` wants. */
|
|
167
|
+
id: number;
|
|
168
|
+
/** The session this row belongs to. */
|
|
169
|
+
sessionId?: number;
|
|
170
|
+
/**
|
|
171
|
+
* The lane this row is on, canonically (`main`, `text-messages:2`).
|
|
172
|
+
*
|
|
173
|
+
* The LANE rides inside this string — `<slug>:<lane>`, with a bare slug
|
|
174
|
+
* meaning lane 1 — and `parseChannel` takes it apart. Absent reads as
|
|
175
|
+
* `main`.
|
|
176
|
+
*/
|
|
177
|
+
channel?: string;
|
|
178
|
+
/** `user` · `assistant` · `system` — the chat-completions vocabulary. */
|
|
179
|
+
role: string;
|
|
180
|
+
/** The rendered text of the message. */
|
|
181
|
+
content: string;
|
|
182
|
+
/**
|
|
183
|
+
* Who spoke, as the host resolved it for display: a character's name, a
|
|
184
|
+
* persona's, the narrator's. Null when the host has no name for the row.
|
|
185
|
+
*/
|
|
186
|
+
speakerLabel?: string | null;
|
|
187
|
+
/** The speaking character, when one spoke. */
|
|
188
|
+
characterId?: number | null;
|
|
189
|
+
/** The speaking persona, when one spoke. */
|
|
190
|
+
personaId?: number | null;
|
|
191
|
+
/** True for a narrator turn: no character, no persona, `role: assistant`. */
|
|
192
|
+
isNarratorResponse?: boolean;
|
|
193
|
+
/** The row's kind, where a host distinguishes several. */
|
|
194
|
+
kind?: string;
|
|
195
|
+
/**
|
|
196
|
+
* 🚧 Provisional. The parts-native half of the message model: the parts a
|
|
197
|
+
* renderer composes, blocks included, each at its step and revision — the
|
|
198
|
+
* row shows, per step, the revision `activeRevisions` names. The row's
|
|
199
|
+
* `content` is the flattened text of the same thing and stays
|
|
200
|
+
* authoritative for a widget that only draws prose. Absent on a row the
|
|
201
|
+
* host has not projected yet (one written mid-run).
|
|
202
|
+
*/
|
|
203
|
+
parts?: MessagePartV1[];
|
|
204
|
+
/** When the row was written, as a string on the wire. */
|
|
205
|
+
createdAt?: string;
|
|
206
|
+
/** When the row last changed — a timestamp, as a string on the wire. */
|
|
207
|
+
updatedAt?: string;
|
|
208
|
+
/** A person has edited this row's text. */
|
|
209
|
+
isEdited?: boolean;
|
|
210
|
+
/** The host is not showing this row. */
|
|
211
|
+
isHidden?: boolean;
|
|
212
|
+
/** A run is filling this row right now. */
|
|
213
|
+
isGenerating?: boolean;
|
|
214
|
+
/**
|
|
215
|
+
* How the last generation on this row ended, when it did not end normally
|
|
216
|
+
* — `stopped` for a reply a person stopped, leaving the partial text.
|
|
217
|
+
* Null or absent for a reply that finished.
|
|
218
|
+
*/
|
|
219
|
+
generationOutcome?: string | null;
|
|
220
|
+
/**
|
|
221
|
+
* What the run filling this row is doing right now (R-19) — *{speaker} is
|
|
222
|
+
* typing* — as display text with its variables filled, NOT a string:
|
|
223
|
+
* resolve it with `renderStatusText`. Null or absent when nothing runs.
|
|
224
|
+
*/
|
|
225
|
+
generationStatus?: StatusText | null;
|
|
226
|
+
/** Why the last run on this row failed, when it did — shown in place of text. */
|
|
227
|
+
error?: MessageErrorV1 | null;
|
|
228
|
+
/**
|
|
229
|
+
* Per step (`"0"`, `"1"`, …), the revision of that step's parts the row
|
|
230
|
+
* shows — the swipe cursor of the parts-native model (`{ "0": 1 }`).
|
|
231
|
+
*/
|
|
232
|
+
activeRevisions?: Record<string, number>;
|
|
233
|
+
/** The row's own metadata bag — the keys a widget reads are named in {@link MessageMetadataV1}. */
|
|
234
|
+
metadata?: MessageMetadataV1;
|
|
235
|
+
/** Whatever else the host attached to the row for a widget to read. */
|
|
236
|
+
extras?: WidgetPayload;
|
|
237
|
+
/**
|
|
238
|
+
* The host forwards the row, less {@link MESSAGE_HOST_FIELDS}, so columns
|
|
239
|
+
* this interface does not name arrive at the top level beside the ones it
|
|
240
|
+
* does.
|
|
241
|
+
*/
|
|
242
|
+
[k: string]: unknown;
|
|
243
|
+
}
|
|
244
|
+
/**
|
|
245
|
+
* @experimental The message-row columns a host never posts to a widget — the
|
|
246
|
+
* bookkeeping {@link MessageV1} withholds. The one list: a host's projection
|
|
247
|
+
* ({@link projectMessageRow}) and `MessageV1`'s doc comment both follow it.
|
|
248
|
+
*/
|
|
249
|
+
export declare const MESSAGE_HOST_FIELDS: readonly ["userId", "queueItemId", "debugMeta", "embedding", "embeddingModel", "embeddingSourceHash", "embedTextHash", "vectorizedAt", "version"];
|
|
250
|
+
/** @experimental One of {@link MESSAGE_HOST_FIELDS}. */
|
|
251
|
+
export type MessageHostField = (typeof MESSAGE_HOST_FIELDS)[number];
|
|
252
|
+
/**
|
|
253
|
+
* @experimental A message row as it may cross to a widget: a shallow copy
|
|
254
|
+
* without {@link MESSAGE_HOST_FIELDS}. Every road a row takes to a widget —
|
|
255
|
+
* the `messages` post, a `channel` post, a `messages` page — goes through
|
|
256
|
+
* this. A non-object is returned as it is.
|
|
257
|
+
*/
|
|
258
|
+
export declare function projectMessageRow<T>(row: T): Omit<T, MessageHostField>;
|
|
259
|
+
/** A failed run, as the row carries it. @experimental */
|
|
260
|
+
export interface MessageErrorV1 {
|
|
261
|
+
message: string;
|
|
262
|
+
code?: string;
|
|
263
|
+
/**
|
|
264
|
+
* The connection the run failed on — its identity, which only an
|
|
265
|
+
* administrator is sent: for everyone else the whole bag is absent. Any
|
|
266
|
+
* field may be null (a connection deleted since, a model never named).
|
|
267
|
+
*/
|
|
268
|
+
connection?: MessageErrorConnectionV1;
|
|
269
|
+
}
|
|
270
|
+
/** @experimental A failed run's connection identity (administrators only; see {@link MessageErrorV1}). */
|
|
271
|
+
export interface MessageErrorConnectionV1 {
|
|
272
|
+
id?: number | null;
|
|
273
|
+
name?: string | null;
|
|
274
|
+
/** The model the connection names — a file path, on a managed connection. */
|
|
275
|
+
model?: string | null;
|
|
276
|
+
/** The adapter kind: `koboldcpp`, `openai-chat`. */
|
|
277
|
+
type?: string | null;
|
|
278
|
+
/** What the service itself said, verbatim. */
|
|
279
|
+
detail?: string;
|
|
280
|
+
}
|
|
281
|
+
/**
|
|
282
|
+
* @experimental 🚧 One part of a message (the parts-native model): a typed piece at a
|
|
283
|
+
* `step`, in one `revision` of that step, in `ordinal` order.
|
|
284
|
+
*/
|
|
285
|
+
export interface MessagePartV1 {
|
|
286
|
+
id: number;
|
|
287
|
+
messageId: number;
|
|
288
|
+
step: number;
|
|
289
|
+
revision: number;
|
|
290
|
+
ordinal: number;
|
|
291
|
+
/**
|
|
292
|
+
* `core:markdown` · `core:reasoning` (the reply's reasoning) ·
|
|
293
|
+
* `core:section` · `core:image` · … or a plugin's namespaced type.
|
|
294
|
+
*/
|
|
295
|
+
type: string;
|
|
296
|
+
/**
|
|
297
|
+
* The text, for a textual type. A `core:section` holds its section's text
|
|
298
|
+
* here — for a list, the items as a markdown bullet list, so a renderer
|
|
299
|
+
* that knows nothing of `items` still shows something readable.
|
|
300
|
+
*/
|
|
301
|
+
content: string | null;
|
|
302
|
+
/**
|
|
303
|
+
* Structure, for a type that has any. A `core:section` carries
|
|
304
|
+
* {@link FoldedSectionPartDataV1}: its `title`, and — for a folded section —
|
|
305
|
+
* its `kind`, and `items` when it is a list.
|
|
306
|
+
*/
|
|
307
|
+
data: Record<string, unknown> | null;
|
|
308
|
+
}
|
|
309
|
+
/**
|
|
310
|
+
* @experimental 🚧 A **folded section**: a named piece of a reply shown
|
|
311
|
+
* collapsed beside its body, never as the body — a narrator's Plan (beats and
|
|
312
|
+
* speakers, as a list), a step's notes (B4; decision D5, 2026-09-27). What the
|
|
313
|
+
* `sections` in-port of `core:outlet/create-message@1` and
|
|
314
|
+
* `core:outlet/update-message@1` takes, as a list, and what the host stores per
|
|
315
|
+
* swipe and serves to widgets as a `core:section` part.
|
|
316
|
+
*
|
|
317
|
+
* Exactly one of `content` and `items`. A folded section never enters the
|
|
318
|
+
* prompt transcript, and neither does the reply's reasoning: both are for the
|
|
319
|
+
* person reading, never re-sent to the model.
|
|
320
|
+
*
|
|
321
|
+
* ⚠ Not a layout **fold** (a unit or zone giving way at a size), and not the
|
|
322
|
+
* model's reasoning trace — that is the `reasoning` in-port, stored as a
|
|
323
|
+
* `core:reasoning` part.
|
|
324
|
+
*/
|
|
325
|
+
export interface FoldedSectionV1 {
|
|
326
|
+
/**
|
|
327
|
+
* What the section holds, as a lowercase slug — `plan`, `notes`, or a
|
|
328
|
+
* plugin's own. Chooses the glyph; never shown.
|
|
329
|
+
*/
|
|
330
|
+
kind: string;
|
|
331
|
+
/** The heading on the section's disclosure button, in sentence case: `Plan`. */
|
|
332
|
+
label: string;
|
|
333
|
+
/** The section's text (markdown). */
|
|
334
|
+
content?: string;
|
|
335
|
+
/** The section as a list, one entry per line — rendered as a list, never as JSON. */
|
|
336
|
+
items?: string[];
|
|
337
|
+
}
|
|
338
|
+
/**
|
|
339
|
+
* @experimental The `data` of a `core:section` part. `title` is the heading;
|
|
340
|
+
* `kind` and `items` are present on a folded section ({@link FoldedSectionV1}).
|
|
341
|
+
*/
|
|
342
|
+
export interface FoldedSectionPartDataV1 {
|
|
343
|
+
title: string;
|
|
344
|
+
kind?: string;
|
|
345
|
+
items?: string[];
|
|
346
|
+
}
|
|
347
|
+
/** @experimental The metadata keys a message widget reads; others ride along. */
|
|
348
|
+
export interface MessageMetadataV1 {
|
|
349
|
+
isGreeting?: boolean;
|
|
350
|
+
/** Alternative replies: their texts, and which one is shown. */
|
|
351
|
+
swipes?: MessageSwipesV1;
|
|
352
|
+
narratorName?: string;
|
|
353
|
+
narratorInstructions?: string;
|
|
354
|
+
/**
|
|
355
|
+
* The model's reasoning for the shown swipe, when it shared any — written
|
|
356
|
+
* on every streamed frame, so it fills while the reply is still reasoning.
|
|
357
|
+
*/
|
|
358
|
+
reasoning?: string | null;
|
|
359
|
+
/**
|
|
360
|
+
* The row's folded sections while it has no alternatives; once it has,
|
|
361
|
+
* `swipes.sectionsHistory` holds each one's. A widget reads the
|
|
362
|
+
* `core:section` parts instead.
|
|
363
|
+
*/
|
|
364
|
+
sections?: FoldedSectionV1[] | null;
|
|
365
|
+
/** The expression sprite shown beside the row. */
|
|
366
|
+
sprite?: unknown;
|
|
367
|
+
/** Who spoke, as the speaker envoy recorded it. */
|
|
368
|
+
speaker?: unknown;
|
|
369
|
+
/** The form this row answers: the message carrying it, and the block. */
|
|
370
|
+
answersForm?: {
|
|
371
|
+
messageId: number;
|
|
372
|
+
blockId: string;
|
|
373
|
+
};
|
|
374
|
+
[k: string]: unknown;
|
|
375
|
+
}
|
|
376
|
+
/** @experimental A row's alternative replies (`metadata.swipes`). */
|
|
377
|
+
export interface MessageSwipesV1 {
|
|
378
|
+
/** Which of `history` is shown; null before the first. */
|
|
379
|
+
currentIdx: number | null;
|
|
380
|
+
/** Every reply's text, oldest first. */
|
|
381
|
+
history: string[];
|
|
382
|
+
/** The reasoning each reply carried, parallel to `history`. */
|
|
383
|
+
reasoningHistory?: (string | null)[];
|
|
384
|
+
/**
|
|
385
|
+
* The folded sections each reply carried, parallel to `history`. Absent
|
|
386
|
+
* until a write gives a later alternative sections; until then the first
|
|
387
|
+
* alternative's are the row's `sections`.
|
|
388
|
+
*/
|
|
389
|
+
sectionsHistory?: (FoldedSectionV1[] | null)[];
|
|
390
|
+
[k: string]: unknown;
|
|
391
|
+
}
|
|
392
|
+
/** Who is looking — what a widget needs to know about the viewer, and no more. @experimental */
|
|
393
|
+
export interface ViewerV1 {
|
|
394
|
+
userId: number | null;
|
|
395
|
+
isAdmin: boolean;
|
|
396
|
+
/** A guest seat: may read, may not write. */
|
|
397
|
+
isGuest: boolean;
|
|
398
|
+
}
|
|
399
|
+
/**
|
|
400
|
+
* One action as a venue lists it (plans/29 R-15) — transport-neutral here so a
|
|
401
|
+
* frame and a native widget read the same rows. `specSlug` is `core` for one
|
|
402
|
+
* of core's own message verbs.
|
|
403
|
+
* @experimental
|
|
404
|
+
*/
|
|
405
|
+
export interface WidgetAction {
|
|
406
|
+
key: string;
|
|
407
|
+
specSlug: string;
|
|
408
|
+
name: string;
|
|
409
|
+
/** What it does, one sentence — every contributed and core action declares one (2026-09-28). */
|
|
410
|
+
description?: string;
|
|
411
|
+
icon?: string;
|
|
412
|
+
/**
|
|
413
|
+
* What the icon says standing alone — the accessible name of an
|
|
414
|
+
* icon-only control. Absent: `name`.
|
|
415
|
+
* @experimental
|
|
416
|
+
*/
|
|
417
|
+
iconAlt?: string;
|
|
418
|
+
slash: string;
|
|
419
|
+
quick: boolean;
|
|
420
|
+
audience: {
|
|
421
|
+
see: string[];
|
|
422
|
+
act: string[];
|
|
423
|
+
};
|
|
424
|
+
venue: string;
|
|
425
|
+
channel?: string;
|
|
426
|
+
origin: 'core' | 'companion' | 'foreign';
|
|
427
|
+
floor: boolean;
|
|
428
|
+
canAct: boolean;
|
|
429
|
+
itemGated: boolean;
|
|
430
|
+
isNew: boolean;
|
|
431
|
+
/**
|
|
432
|
+
* The enabled-when verdict (U5e), beside `canAct` — both shown, neither
|
|
433
|
+
* hides the action: every predicate the host could judge over the
|
|
434
|
+
* session's published values holds. The `item.*` ones are not among
|
|
435
|
+
* them (`itemPredicates`). The host always sends it; absent (a fixture,
|
|
436
|
+
* a host before U5e) reads as enabled.
|
|
437
|
+
*/
|
|
438
|
+
enabled?: boolean;
|
|
439
|
+
/** Why it is grey when `enabled` is false — resolve with `renderStatusText`. */
|
|
440
|
+
reason?: WidgetActionReason;
|
|
441
|
+
/**
|
|
442
|
+
* The predicates over `item.*` — the message the action is pressed on —
|
|
443
|
+
* which a widget judges per row with `evaluateEnabledWhen`. Message venue
|
|
444
|
+
* only; absent when there are none.
|
|
445
|
+
*/
|
|
446
|
+
itemPredicates?: EnabledWhen[];
|
|
447
|
+
}
|
|
448
|
+
/**
|
|
449
|
+
* The session's actions per **venue**, each a primary set plus an overflow
|
|
450
|
+
* that lists every enabled action (F38). Keyed by venue kind (`composer`,
|
|
451
|
+
* `message`, `extra`, `widget`, …); a widget reads the venues it draws —
|
|
452
|
+
* `widget` for its own controls, `message` when it renders a message's menu —
|
|
453
|
+
* and fires one through `invoke(key)`. Empty venues when the host has no list
|
|
454
|
+
* yet.
|
|
455
|
+
* @experimental
|
|
456
|
+
*/
|
|
457
|
+
export type ActionsV1 = Record<string, {
|
|
458
|
+
primary: WidgetAction[];
|
|
459
|
+
overflow: WidgetAction[];
|
|
460
|
+
}>;
|
|
461
|
+
/** The transport-neutral data half — the versioned sections. */
|
|
462
|
+
/**
|
|
463
|
+
* What this viewer may see of the session annex (R57): per owner, the values
|
|
464
|
+
* whose audience holds for them — never the annex itself. A value stored for
|
|
465
|
+
* pipelines only is never here.
|
|
466
|
+
* @experimental
|
|
467
|
+
*/
|
|
468
|
+
export type AnnexV1 = Record<string, Record<string, unknown>>;
|
|
469
|
+
/**
|
|
470
|
+
* 🚧 The session's stats and states, as a widget reads them —
|
|
471
|
+
* `session_state.v1` (R72: a SCOPED section, scope `session:state`, which a
|
|
472
|
+
* plugin's widget is granted as `widget:session:state`, reviewed like
|
|
473
|
+
* `session:full`). The viewer's view of the one resolved read (`state:get`):
|
|
474
|
+
* what every member of the session reads today, until state gets per-viewer
|
|
475
|
+
* audiences.
|
|
476
|
+
*
|
|
477
|
+
* `resolved`, never `state`: `state` on a component's context is the view
|
|
478
|
+
* state it saved.
|
|
479
|
+
* @experimental
|
|
480
|
+
*/
|
|
481
|
+
export interface SessionStateV1 {
|
|
482
|
+
/** The session this answers for. */
|
|
483
|
+
sessionId: number;
|
|
484
|
+
/** The first read has landed. Before it, empty means "not yet", never "nothing". */
|
|
485
|
+
loaded: boolean;
|
|
486
|
+
/**
|
|
487
|
+
* Why the last READ failed, in words; null when it did not. A write a
|
|
488
|
+
* widget asked for fails as that request's own rejection — errors are
|
|
489
|
+
* per widget (R77), never one line every state widget shows.
|
|
490
|
+
*/
|
|
491
|
+
error: string | null;
|
|
492
|
+
/** The values, resolved: what a template reads as `state`. */
|
|
493
|
+
resolved: SessionResolvedStateV1;
|
|
494
|
+
/** Every slot this install declares, as a widget has to draw it. */
|
|
495
|
+
slots: SessionStateSlotV1[];
|
|
496
|
+
/** Every owner this session's values belong to: the world, and each cast member. */
|
|
497
|
+
owners: SessionStateOwnerV1[];
|
|
498
|
+
}
|
|
499
|
+
/**
|
|
500
|
+
* The resolved values — the object a template reads as `state`. Each bag is
|
|
501
|
+
* keyed by a slot's QUALIFIED key (`SessionStateSlotV1.qualifiedKey`), the
|
|
502
|
+
* key every value is filed under.
|
|
503
|
+
* @experimental
|
|
504
|
+
*/
|
|
505
|
+
export interface SessionResolvedStateV1 {
|
|
506
|
+
/** The world's values. */
|
|
507
|
+
world: Record<string, unknown>;
|
|
508
|
+
/** Each cast member's values, by owner key (`SessionStateOwnerV1.key`). */
|
|
509
|
+
cast: Record<string, Record<string, unknown>>;
|
|
510
|
+
/**
|
|
511
|
+
* 🚧 Each location's values, by owner key (`SessionStateOwnerV1.key`, a
|
|
512
|
+
* `session_location` owner) — attributes phase 4. Absent from a host
|
|
513
|
+
* that predates locations holding state.
|
|
514
|
+
*/
|
|
515
|
+
locations?: Record<string, Record<string, unknown>>;
|
|
516
|
+
/** The session's state version (U5f): moved by every applied change. */
|
|
517
|
+
version?: number;
|
|
518
|
+
}
|
|
519
|
+
/**
|
|
520
|
+
* What a slot IS, for a widget that draws it: `14` is a bar only because the
|
|
521
|
+
* slot is an integer with a floor and a ceiling, `wary` a chip only because
|
|
522
|
+
* the slot is an enum. ⚠ Never the slot's `descriptor` — that is the
|
|
523
|
+
* sentence the MODEL reads, and a widget drawing it would put prompt text on
|
|
524
|
+
* a bar.
|
|
525
|
+
* @experimental
|
|
526
|
+
*/
|
|
527
|
+
export interface SessionStateSlotV1 {
|
|
528
|
+
/** `owner:slot/name@N` — what `set-attribute-value` names. */
|
|
529
|
+
slotId: string;
|
|
530
|
+
/** The key a person reads (`hp`): the first claimant's, so a display name, not an address. */
|
|
531
|
+
key: string;
|
|
532
|
+
/** The key every value is filed under in `resolved` — the one to look a value up by. */
|
|
533
|
+
qualifiedKey: string;
|
|
534
|
+
label: string;
|
|
535
|
+
description?: string;
|
|
536
|
+
type: SlotType;
|
|
537
|
+
/**
|
|
538
|
+
* 🚧 The catalogue stat shape the slot names (`core:stat-shape/list@1`),
|
|
539
|
+
* when it names one; absent for a slot shaped inline or by `type` alone.
|
|
540
|
+
*/
|
|
541
|
+
shape?: string;
|
|
542
|
+
/**
|
|
543
|
+
* 🚧 What the value IS, in the field language (`FieldDecl`): the stat
|
|
544
|
+
* shape's field — what decides a bar, a chip, a list or a story time
|
|
545
|
+
* (`statShapeKindOf`). Absent from a host that predates shapes, and for a
|
|
546
|
+
* derived slot: read the field off `type` then (`fieldForSlotType`).
|
|
547
|
+
*/
|
|
548
|
+
field?: FieldDecl;
|
|
549
|
+
appliesTo: SlotAppliesTo[];
|
|
550
|
+
/** A sheet says a session of this shape must have a value (R7): shown, never enforced here. */
|
|
551
|
+
required?: boolean;
|
|
552
|
+
/** Retired (R3): its values still resolve and nothing new is written; drawn greyed, never dropped. */
|
|
553
|
+
retired?: boolean;
|
|
554
|
+
/** The sheet that first named it, when one did. */
|
|
555
|
+
sheetId?: string;
|
|
556
|
+
}
|
|
557
|
+
/**
|
|
558
|
+
* An owner a session's values belong to — the world (`kind: 'session'`), a
|
|
559
|
+
* cast member (`session_cast`) or 🚧 a location (`session_location`, whose
|
|
560
|
+
* `id` is the location's lore entry) — keyed exactly as `resolved` keys it.
|
|
561
|
+
* `key` is the lookup; `kind` and `id` are what `set-attribute-value` names.
|
|
562
|
+
* @experimental
|
|
563
|
+
*/
|
|
564
|
+
export interface SessionStateOwnerV1 {
|
|
565
|
+
/** `world`, the cast member's key in `resolved.cast`, or the location's in `resolved.locations`. */
|
|
566
|
+
key: string;
|
|
567
|
+
kind: 'session' | 'session_cast' | 'session_location';
|
|
568
|
+
id: number;
|
|
569
|
+
label: string;
|
|
570
|
+
/**
|
|
571
|
+
* The configuration in force per slot id — a bar's bounds, a chip's
|
|
572
|
+
* options. Only the slots this owner may carry appear, so a slot is this
|
|
573
|
+
* owner's exactly when its id is a key here.
|
|
574
|
+
*/
|
|
575
|
+
configs: Record<string, Record<string, unknown>>;
|
|
576
|
+
}
|
|
577
|
+
/**
|
|
578
|
+
* 🚧 The session's cast, as a widget draws it — `characters.v1` (R76) — with
|
|
579
|
+
* the scene images they picture riding along: images ride with their parent.
|
|
580
|
+
* @experimental
|
|
581
|
+
*/
|
|
582
|
+
export interface SessionCharactersV1 {
|
|
583
|
+
/** Everyone still in the session: its characters, then its personas. */
|
|
584
|
+
members: SessionCharacterV1[];
|
|
585
|
+
/** The portraits pinned beside the conversation, one per side; null for an empty side. */
|
|
586
|
+
sceneImages: {
|
|
587
|
+
left: SessionSceneImageV1 | null;
|
|
588
|
+
right: SessionSceneImageV1 | null;
|
|
589
|
+
};
|
|
590
|
+
}
|
|
591
|
+
/**
|
|
592
|
+
* One cast member, **cascaded cast over card** (R76): the character card's
|
|
593
|
+
* fields overlaid by the cast member's, and **the cast member wins wherever
|
|
594
|
+
* both speak** — its name, its face, its sprite set. The card owns the art;
|
|
595
|
+
* the cast member picks the set. The host merges; a widget reads the merged
|
|
596
|
+
* value and never resolves the cascade itself.
|
|
597
|
+
*
|
|
598
|
+
* The host also resolves every URL and the current sprite, so a widget draws
|
|
599
|
+
* what it is handed and asks nothing of the page but its verbs.
|
|
600
|
+
* @experimental
|
|
601
|
+
*/
|
|
602
|
+
export interface SessionCharacterV1 {
|
|
603
|
+
/**
|
|
604
|
+
* `character:<id>` — a persona's too: a persona is a character row
|
|
605
|
+
* (`isPersona` says which), so its reference is the same grammar
|
|
606
|
+
* (`TurnCandidateV1.ref` reads it the same way).
|
|
607
|
+
*/
|
|
608
|
+
ref: `character:${number}`;
|
|
609
|
+
characterId: number;
|
|
610
|
+
/** A persona — a person's own character — rather than one of the cast. */
|
|
611
|
+
isPersona: boolean;
|
|
612
|
+
/**
|
|
613
|
+
* The viewer's own persona in this session: what a widget draws for "your
|
|
614
|
+
* persona" (R77 — the viewer's, never merely the first one listed).
|
|
615
|
+
*/
|
|
616
|
+
mine: boolean;
|
|
617
|
+
/** The name to show: the cast member's (a nickname) over the card's. */
|
|
618
|
+
name: string;
|
|
619
|
+
/** The member's avatar, resolved (a same-origin media URL); null when there is none. */
|
|
620
|
+
face: string | null;
|
|
621
|
+
/**
|
|
622
|
+
* The member's CURRENT sprite — the one on the newest line it spoke, in
|
|
623
|
+
* `spriteSet` — resolved; null when the card has no sprites.
|
|
624
|
+
*/
|
|
625
|
+
sprite: string | null;
|
|
626
|
+
/** The card's sprite sets, by name, in the card's order. */
|
|
627
|
+
spriteSets: string[];
|
|
628
|
+
/** The set this member shows: the session's choice over the card's; null when neither names one. */
|
|
629
|
+
spriteSet: string | null;
|
|
630
|
+
/**
|
|
631
|
+
* 🚧 The session's own choice alone (`set-sprite-set`): the set this
|
|
632
|
+
* session overrides the story's with, null when it follows the story. What
|
|
633
|
+
* a sprite-set menu marks as picked, where "as the story has it" is the
|
|
634
|
+
* absence of an override rather than the card's default set. Optional
|
|
635
|
+
* (additive): absent reads as null.
|
|
636
|
+
*/
|
|
637
|
+
spriteSetOverride?: string | null;
|
|
638
|
+
/**
|
|
639
|
+
* The viewer may switch this member's set (`set-sprite-set`) — the
|
|
640
|
+
* server's rule (the session's owner or the character's), answered by the
|
|
641
|
+
* host so a menu is offered only where it will be allowed (R77).
|
|
642
|
+
*/
|
|
643
|
+
canChangeSpriteSet: boolean;
|
|
644
|
+
}
|
|
645
|
+
/** A portrait pinned to one side of the conversation. @experimental */
|
|
646
|
+
export interface SessionSceneImageV1 {
|
|
647
|
+
/** The image, as the host resolved it. */
|
|
648
|
+
src: string;
|
|
649
|
+
/**
|
|
650
|
+
* The member it pictures, when the host can tell — a pin is stored as an
|
|
651
|
+
* image, so it is matched by face; null for an image pinned from anywhere
|
|
652
|
+
* else.
|
|
653
|
+
*/
|
|
654
|
+
ref: `character:${number}` | null;
|
|
655
|
+
}
|
|
656
|
+
/**
|
|
657
|
+
* 🚧 **The** table of scoped sections: each widget scope that delivers data,
|
|
658
|
+
* the name its section is posted under, and that section's `v1` shape.
|
|
659
|
+
* Every other spelling is derived from this one — `WidgetScope`,
|
|
660
|
+
* `WidgetData`'s scoped keys, `ComponentSections.scoped`, the frame's
|
|
661
|
+
* `scoped` message, the component wire's receiver — so a scoped section is
|
|
662
|
+
* added by one entry here and one in {@link WIDGET_SCOPED_SECTIONS}, which
|
|
663
|
+
* the compiler holds to this.
|
|
664
|
+
*
|
|
665
|
+
* A scoped section appears ONLY when the widget declared the scope AND it was
|
|
666
|
+
* granted (a plugin's as `widget:<scope>`, reviewed and deniable; core's own
|
|
667
|
+
* widgets hold every scope). Absence means "not granted", never a silent
|
|
668
|
+
* empty — or, before the first post, "not yet"; the host's `grants`
|
|
669
|
+
* (frame message `grants`, `ComponentContext.grants` / `granted(scope)`)
|
|
670
|
+
* says which.
|
|
671
|
+
* @experimental
|
|
672
|
+
*/
|
|
673
|
+
export interface WidgetScopedSections {
|
|
674
|
+
/** 🚧 The whole conversation as core's own conversation sees it (the dossier); its shape settles with C7. */
|
|
675
|
+
'session:full': {
|
|
676
|
+
section: 'session_full';
|
|
677
|
+
v1: unknown;
|
|
678
|
+
};
|
|
679
|
+
/** 🚧 The session's stats and states (R72). */
|
|
680
|
+
'session:state': {
|
|
681
|
+
section: 'session_state';
|
|
682
|
+
v1: SessionStateV1;
|
|
683
|
+
};
|
|
684
|
+
/** 🚧 The viewer's persona. Declared; no host supplies it yet. */
|
|
685
|
+
persona: {
|
|
686
|
+
section: 'persona';
|
|
687
|
+
v1: unknown;
|
|
688
|
+
};
|
|
689
|
+
/** 🚧 The session's cast, cast over card, and the scene images they picture (R76). */
|
|
690
|
+
characters: {
|
|
691
|
+
section: 'characters';
|
|
692
|
+
v1: SessionCharactersV1;
|
|
693
|
+
};
|
|
694
|
+
/**
|
|
695
|
+
* 🚧 The session's lore. Declared and never pushed: it is the grant a
|
|
696
|
+
* plugin's widget holds to ask `session-entries` (the lore is paged by
|
|
697
|
+
* request, as messages are).
|
|
698
|
+
*/
|
|
699
|
+
lore: {
|
|
700
|
+
section: 'lore';
|
|
701
|
+
v1: unknown;
|
|
702
|
+
};
|
|
703
|
+
}
|
|
704
|
+
/** A widget scope that delivers a scoped section — every scope but `channel:<slug>`. @experimental */
|
|
705
|
+
export type WidgetSectionScope = keyof WidgetScopedSections;
|
|
706
|
+
/** A scoped section's name as posted: `session_full`, `session_state`, `persona`, `characters`, `lore`. @experimental */
|
|
707
|
+
export type WidgetScopedSectionName = WidgetScopedSections[WidgetSectionScope]['section'];
|
|
708
|
+
/** Each scoped section's `v1`, by its posted name. @experimental */
|
|
709
|
+
export type WidgetScopedSectionValues = {
|
|
710
|
+
[S in WidgetSectionScope as WidgetScopedSections[S]['section']]: WidgetScopedSections[S]['v1'];
|
|
711
|
+
};
|
|
712
|
+
/** The envelope's scoped half: each section a `{ v1 }` bag, present iff declared and granted. @experimental */
|
|
713
|
+
export type WidgetScopedData = {
|
|
714
|
+
[N in WidgetScopedSectionName]?: {
|
|
715
|
+
v1: WidgetScopedSectionValues[N];
|
|
716
|
+
};
|
|
717
|
+
};
|
|
718
|
+
/**
|
|
719
|
+
* {@link WidgetScopedSections} at runtime: scope → the name its section is
|
|
720
|
+
* posted under. Typed off the table, so a scope missing here, or a name that
|
|
721
|
+
* disagrees with it, does not compile.
|
|
722
|
+
* @experimental
|
|
723
|
+
*/
|
|
724
|
+
export declare const WIDGET_SCOPED_SECTIONS: {
|
|
725
|
+
readonly [S in WidgetSectionScope]: WidgetScopedSections[S]['section'];
|
|
726
|
+
};
|
|
727
|
+
/** Is this a scoped section's posted name — what a receiver checks an incoming `scoped` message against. @experimental */
|
|
728
|
+
export declare const isWidgetScopedSectionName: (name: unknown) => name is WidgetScopedSectionName;
|
|
729
|
+
/**
|
|
730
|
+
* The transport-neutral data half — the versioned sections: the base ones
|
|
731
|
+
* below, and the scoped half ({@link WidgetScopedData}) the table above
|
|
732
|
+
* derives.
|
|
733
|
+
*
|
|
734
|
+
* A base section a widget does not READ (`WidgetDecl.reads`, R75) is never
|
|
735
|
+
* sent to it: a remote or a frame never receives it, and a native widget is
|
|
736
|
+
* handed its empty value (`[]`, `{}`) and never re-projected for it — so a
|
|
737
|
+
* widget that does not read `messages` is not handed the log again on every
|
|
738
|
+
* token.
|
|
739
|
+
* @experimental
|
|
740
|
+
*/
|
|
741
|
+
export interface WidgetData extends WidgetScopedData {
|
|
742
|
+
layout: {
|
|
743
|
+
v1: LayoutV1;
|
|
744
|
+
};
|
|
745
|
+
session: {
|
|
746
|
+
v1: SessionV1;
|
|
747
|
+
};
|
|
748
|
+
channels: {
|
|
749
|
+
v1: string[];
|
|
750
|
+
};
|
|
751
|
+
messages: {
|
|
752
|
+
v1: MessageV1[];
|
|
753
|
+
};
|
|
754
|
+
props: {
|
|
755
|
+
v1: WidgetPayload;
|
|
756
|
+
};
|
|
757
|
+
/**
|
|
758
|
+
* The action model's venues (R-15) — base, so a widget need not declare a
|
|
759
|
+
* scope to offer a control.
|
|
760
|
+
*/
|
|
761
|
+
actions: {
|
|
762
|
+
v1: ActionsV1;
|
|
763
|
+
};
|
|
764
|
+
/**
|
|
765
|
+
* This instance's effective settings: every field the widget declares
|
|
766
|
+
* (`WidgetDecl.settings`), defaults filled in, with the user's deviations
|
|
767
|
+
* over them. Complete by construction, so a widget reads a value rather
|
|
768
|
+
* than re-deriving its own defaults. Empty for a widget that declares none.
|
|
769
|
+
*/
|
|
770
|
+
settings: {
|
|
771
|
+
v1: WidgetPayload;
|
|
772
|
+
};
|
|
773
|
+
/** The viewer's view of the session annex (R57) — `{}` when there is nothing to see. */
|
|
774
|
+
annex: {
|
|
775
|
+
v1: AnnexV1;
|
|
776
|
+
};
|
|
777
|
+
/**
|
|
778
|
+
* The viewer's language code (`en`, `fr`, …), so a widget renders a locale
|
|
779
|
+
* map (`i18nText(text, locale.v1)`) in the language the page speaks.
|
|
780
|
+
*/
|
|
781
|
+
locale: {
|
|
782
|
+
v1: string;
|
|
783
|
+
};
|
|
784
|
+
/** 🚧 Who is looking (C0b). */
|
|
785
|
+
viewer: {
|
|
786
|
+
v1: ViewerV1;
|
|
787
|
+
};
|
|
788
|
+
/**
|
|
789
|
+
* The session's turn order (C5): who is due to speak, in order, and who
|
|
790
|
+
* could — the stored order core and every strategy write (A9), never
|
|
791
|
+
* recomputed by a reader. What the page already shows every member in
|
|
792
|
+
* its "next" line; `EMPTY_TURN_ORDER` before the first recompute. An
|
|
793
|
+
* entry is open: a strategy may add keys (a `reason`, …) and they arrive.
|
|
794
|
+
*/
|
|
795
|
+
turnOrder: {
|
|
796
|
+
v1: TurnOrderV1;
|
|
797
|
+
};
|
|
798
|
+
}
|
|
799
|
+
/** A base section's name — what a widget lists in `WidgetDecl.reads` (R75). @experimental */
|
|
800
|
+
export type WidgetBaseSection = Exclude<keyof WidgetData, WidgetScopedSectionName>;
|
|
801
|
+
/**
|
|
802
|
+
* The base sections, in the order the envelope declares them (R75): what
|
|
803
|
+
* `WidgetDecl.reads` may name, and what a widget reads when it names none.
|
|
804
|
+
* @experimental
|
|
805
|
+
*/
|
|
806
|
+
export declare const WIDGET_BASE_SECTIONS: readonly WidgetBaseSection[];
|
|
807
|
+
/** A menu for the host to render at a point the widget names. @experimental */
|
|
808
|
+
export interface MenuSpec {
|
|
809
|
+
at: {
|
|
810
|
+
x: number;
|
|
811
|
+
y: number;
|
|
812
|
+
};
|
|
813
|
+
items: Array<{
|
|
814
|
+
id: string;
|
|
815
|
+
label: string;
|
|
816
|
+
icon?: string;
|
|
817
|
+
disabled?: boolean;
|
|
818
|
+
}>;
|
|
819
|
+
}
|
|
820
|
+
/** What a person picked out of a `MenuSpec`. @experimental */
|
|
821
|
+
export interface MenuResult {
|
|
822
|
+
id: string;
|
|
823
|
+
}
|
|
824
|
+
/**
|
|
825
|
+
* 🚧 What a widget may ASK the host for (C0b) — by kind, with its params and
|
|
826
|
+
* what comes back. A request is not a grant: the host may decline, and the
|
|
827
|
+
* promise rejects. The host-UI kinds open something of the host's own (a
|
|
828
|
+
* panel, a viewer, a picker) and resolve once it is shown; the widget never
|
|
829
|
+
* sees what the host draws.
|
|
830
|
+
* @experimental
|
|
831
|
+
*/
|
|
832
|
+
export interface WidgetRequests {
|
|
833
|
+
/** A page of a lane's messages, older than `cursor`. */
|
|
834
|
+
messages: {
|
|
835
|
+
params: {
|
|
836
|
+
channel?: string;
|
|
837
|
+
cursor?: string;
|
|
838
|
+
limit?: number;
|
|
839
|
+
};
|
|
840
|
+
result: {
|
|
841
|
+
rows: MessageV1[];
|
|
842
|
+
nextCursor?: string;
|
|
843
|
+
};
|
|
844
|
+
};
|
|
845
|
+
/** The character's sheet in the host's panel. */
|
|
846
|
+
'open-character': {
|
|
847
|
+
params: {
|
|
848
|
+
characterId: number;
|
|
849
|
+
};
|
|
850
|
+
result: void;
|
|
851
|
+
};
|
|
852
|
+
/** A participant's avatar, full size. */
|
|
853
|
+
'view-avatar': {
|
|
854
|
+
params: {
|
|
855
|
+
ref: string;
|
|
856
|
+
};
|
|
857
|
+
result: void;
|
|
858
|
+
};
|
|
859
|
+
/**
|
|
860
|
+
* An image a message shows, full size, in the page's lightbox. 🚧 `gallery`
|
|
861
|
+
* (composer attachments §3.4): the other images it sits with — a message's
|
|
862
|
+
* media strip — so the lightbox pages through them (←/→, swipe); `index` is
|
|
863
|
+
* where `src` sits in `srcs`, `captions` what each is called. Without it
|
|
864
|
+
* the lightbox shows the one image.
|
|
865
|
+
*/
|
|
866
|
+
'view-image': {
|
|
867
|
+
params: {
|
|
868
|
+
src: string;
|
|
869
|
+
gallery?: {
|
|
870
|
+
srcs: string[];
|
|
871
|
+
index: number;
|
|
872
|
+
captions?: string[];
|
|
873
|
+
};
|
|
874
|
+
};
|
|
875
|
+
result: void;
|
|
876
|
+
};
|
|
877
|
+
/** The lore panel at a history entry, a scene, or a new history entry. */
|
|
878
|
+
'open-lore': {
|
|
879
|
+
params: {
|
|
880
|
+
lorebookId?: number;
|
|
881
|
+
scope: 'history' | 'scenes';
|
|
882
|
+
entryId?: number;
|
|
883
|
+
sceneId?: number;
|
|
884
|
+
create?: boolean;
|
|
885
|
+
};
|
|
886
|
+
result: void;
|
|
887
|
+
};
|
|
888
|
+
/** The prompt a message was generated from (admins, when context debugging is on). */
|
|
889
|
+
'prompt-details': {
|
|
890
|
+
params: {
|
|
891
|
+
messageId: number;
|
|
892
|
+
};
|
|
893
|
+
result: void;
|
|
894
|
+
};
|
|
895
|
+
/** The run that wrote a message, in the run inspector (admins). */
|
|
896
|
+
'inspect-run': {
|
|
897
|
+
params: {
|
|
898
|
+
messageId: number;
|
|
899
|
+
};
|
|
900
|
+
result: void;
|
|
901
|
+
};
|
|
902
|
+
/** The host's "who speaks next" picker; resolves once a turn was fired or it was closed. */
|
|
903
|
+
'pick-turn': {
|
|
904
|
+
params: Record<string, never>;
|
|
905
|
+
result: void;
|
|
906
|
+
};
|
|
907
|
+
/** The host's sprite picker for a character's line (DESIGN-sprites §6). */
|
|
908
|
+
'change-sprite': {
|
|
909
|
+
params: {
|
|
910
|
+
messageId: number;
|
|
911
|
+
};
|
|
912
|
+
result: void;
|
|
913
|
+
};
|
|
914
|
+
/** The viewer has now seen these newly offered actions (their "new" mark clears). */
|
|
915
|
+
'actions-seen': {
|
|
916
|
+
params: {
|
|
917
|
+
keys: string[];
|
|
918
|
+
};
|
|
919
|
+
result: void;
|
|
920
|
+
};
|
|
921
|
+
/** Summarize the selected messages into a scene, world lore or a character's lore. */
|
|
922
|
+
summarize: {
|
|
923
|
+
params: {
|
|
924
|
+
kind: 'scene' | 'world' | 'character';
|
|
925
|
+
messageIds: number[];
|
|
926
|
+
};
|
|
927
|
+
result: void;
|
|
928
|
+
};
|
|
929
|
+
/**
|
|
930
|
+
* 🚧 Core's own composer (C0b): send the viewer's line, as the persona and
|
|
931
|
+
* on the lane named. A host answers it for core's widget only — a
|
|
932
|
+
* plugin's widget writes through its own actions.
|
|
933
|
+
*/
|
|
934
|
+
send: {
|
|
935
|
+
params: {
|
|
936
|
+
content: string;
|
|
937
|
+
personaId: number | null;
|
|
938
|
+
channel: string;
|
|
939
|
+
/**
|
|
940
|
+
* 🚧 The composer's **tray items** to send as this line's
|
|
941
|
+
* attachments (composer attachments §3.1), in tray order. With
|
|
942
|
+
* any, `content` may be empty. The host refuses the whole line
|
|
943
|
+
* when one is not ready; the tray then stays as it was.
|
|
944
|
+
*/
|
|
945
|
+
trayItemIds?: string[];
|
|
946
|
+
};
|
|
947
|
+
result: void;
|
|
948
|
+
};
|
|
949
|
+
/**
|
|
950
|
+
* 🚧 Core's composer (composer attachments §3.3): upload these files into
|
|
951
|
+
* the session's composer tray — the files a person picked, dropped or
|
|
952
|
+
* pasted (`sp-file-picker`, `sp-drop-zone`). Resolves once they are
|
|
953
|
+
* queued; their progress, readiness and refusals arrive in the dossier's
|
|
954
|
+
* `composer.tray`, never in the reply.
|
|
955
|
+
*/
|
|
956
|
+
'attach-files': {
|
|
957
|
+
params: {
|
|
958
|
+
files: File[];
|
|
959
|
+
};
|
|
960
|
+
result: void;
|
|
961
|
+
};
|
|
962
|
+
/** 🚧 Core's composer: take one tray item out of the tray (its upload stops; nothing is sent). */
|
|
963
|
+
'remove-tray-item': {
|
|
964
|
+
params: {
|
|
965
|
+
trayItemId: string;
|
|
966
|
+
};
|
|
967
|
+
result: void;
|
|
968
|
+
};
|
|
969
|
+
/**
|
|
970
|
+
* 🚧 Core's conversation (composer attachments D9, remove only): take one
|
|
971
|
+
* attachment — a `core:image` / `core:file` part, by its id — off a sent
|
|
972
|
+
* message. Whoever may edit the message may; the file itself stays.
|
|
973
|
+
*/
|
|
974
|
+
'remove-attachment': {
|
|
975
|
+
params: {
|
|
976
|
+
messageId: number;
|
|
977
|
+
partId: number;
|
|
978
|
+
};
|
|
979
|
+
result: void;
|
|
980
|
+
};
|
|
981
|
+
/** 🚧 Core's composer: the draft changed (the host keeps it, and counts its tokens). */
|
|
982
|
+
draft: {
|
|
983
|
+
params: {
|
|
984
|
+
content: string;
|
|
985
|
+
};
|
|
986
|
+
result: void;
|
|
987
|
+
};
|
|
988
|
+
/** 🚧 Core's composer: write as another of the viewer's personas. */
|
|
989
|
+
'switch-persona': {
|
|
990
|
+
params: {
|
|
991
|
+
personaId: number;
|
|
992
|
+
};
|
|
993
|
+
result: void;
|
|
994
|
+
};
|
|
995
|
+
/** 🚧 Core's composer: the host's "add your persona" flow, for a guest with none. */
|
|
996
|
+
'add-persona': {
|
|
997
|
+
params: Record<string, never>;
|
|
998
|
+
result: void;
|
|
999
|
+
};
|
|
1000
|
+
/**
|
|
1001
|
+
* 🚧 Core's conversation: Continue — fire the first entry of the session's
|
|
1002
|
+
* turn order on `channel`, the channel of the composer it was pressed in
|
|
1003
|
+
* (lair re-plan R5, 2026-09-28). Absent, the host answers for its own
|
|
1004
|
+
* composer's channel.
|
|
1005
|
+
*/
|
|
1006
|
+
'fire-turn': {
|
|
1007
|
+
params: {
|
|
1008
|
+
channel?: string;
|
|
1009
|
+
};
|
|
1010
|
+
result: void;
|
|
1011
|
+
};
|
|
1012
|
+
/** 🚧 Core's conversation: accept or reject a proposed change to the session's state. */
|
|
1013
|
+
'decide-proposal': {
|
|
1014
|
+
params: {
|
|
1015
|
+
proposalId: number;
|
|
1016
|
+
accept: boolean;
|
|
1017
|
+
};
|
|
1018
|
+
result: void;
|
|
1019
|
+
};
|
|
1020
|
+
/**
|
|
1021
|
+
* 🚧 Core's state widgets (R21): set one owner's value for one slot, at
|
|
1022
|
+
* the session layer — the viewer's own edit, applied at once (the page's
|
|
1023
|
+
* `state:set`); `null` clears the session's value so the read inherits
|
|
1024
|
+
* again. The page names its own session. Resolves once written; the new
|
|
1025
|
+
* value arrives as a `session_state` push, never in the reply.
|
|
1026
|
+
*/
|
|
1027
|
+
'set-attribute-value': {
|
|
1028
|
+
params: {
|
|
1029
|
+
owner: {
|
|
1030
|
+
kind: 'session' | 'session_cast' | 'session_location';
|
|
1031
|
+
id: number;
|
|
1032
|
+
};
|
|
1033
|
+
slotId: string;
|
|
1034
|
+
/** A list is written whole — its items in order, words and lore references (`SlotListItem`). */
|
|
1035
|
+
value: SlotValue;
|
|
1036
|
+
};
|
|
1037
|
+
result: void;
|
|
1038
|
+
};
|
|
1039
|
+
/**
|
|
1040
|
+
* 🚧 Core's scene portraits (R21): show a character in another of its
|
|
1041
|
+
* sprite sets, for this session only; `null` goes back to the card's.
|
|
1042
|
+
* Offered where `SessionCharacterV1.canChangeSpriteSet` says so; the
|
|
1043
|
+
* server judges it again.
|
|
1044
|
+
*/
|
|
1045
|
+
'set-sprite-set': {
|
|
1046
|
+
params: {
|
|
1047
|
+
characterId: number;
|
|
1048
|
+
set: string | null;
|
|
1049
|
+
};
|
|
1050
|
+
result: void;
|
|
1051
|
+
};
|
|
1052
|
+
/**
|
|
1053
|
+
* 🚧 Core's scene portraits (R21): take down the portrait pinned on one
|
|
1054
|
+
* side — the page's own pin, which the page keeps (R77: the page and the
|
|
1055
|
+
* widget never disagree about what is pinned).
|
|
1056
|
+
*/
|
|
1057
|
+
'clear-scene-image': {
|
|
1058
|
+
params: {
|
|
1059
|
+
side: 'left' | 'right';
|
|
1060
|
+
};
|
|
1061
|
+
result: void;
|
|
1062
|
+
};
|
|
1063
|
+
/**
|
|
1064
|
+
* 🚧 A page of the session's lorebook, entry by entry, with what this
|
|
1065
|
+
* session's rankings made of each (R58) — searched by title and keys,
|
|
1066
|
+
* sorted, filtered, paged. The page names its own session. `lorebookId`
|
|
1067
|
+
* is null when the session reads into no book; `ownerOnly` when the viewer
|
|
1068
|
+
* is not the book's owner, and then `rows` is empty. `offset` is the page
|
|
1069
|
+
* actually served — pulled back when the one asked for ran past the end.
|
|
1070
|
+
*/
|
|
1071
|
+
'session-entries': {
|
|
1072
|
+
params: {
|
|
1073
|
+
/**
|
|
1074
|
+
* 🚧 Text an entry's title or one of its keys contains — the
|
|
1075
|
+
* search box's words, matched as they are (`%` and `_` are
|
|
1076
|
+
* literal). Never `query`, a retired word here — the node kind
|
|
1077
|
+
* owns it (NOMENCLATURE, Retired words): the page reconciles this
|
|
1078
|
+
* with its socket's spelling.
|
|
1079
|
+
*/
|
|
1080
|
+
titleOrKey?: string;
|
|
1081
|
+
sort?: 'name' | 'lastRead' | 'timesRead' | 'rank';
|
|
1082
|
+
filter?: 'all' | 'fired' | 'pinned' | 'off';
|
|
1083
|
+
/**
|
|
1084
|
+
* 🚧 Only entries of these entry types (`core:entry/item`, …) —
|
|
1085
|
+
* what a state widget's item picker asks for before the rest of
|
|
1086
|
+
* the book (attributes phase 3c). Absent or empty is every type.
|
|
1087
|
+
*/
|
|
1088
|
+
typeIds?: string[];
|
|
1089
|
+
offset?: number;
|
|
1090
|
+
limit?: number;
|
|
1091
|
+
};
|
|
1092
|
+
result: {
|
|
1093
|
+
lorebookId: number | null;
|
|
1094
|
+
bookName?: string;
|
|
1095
|
+
ownerOnly: boolean;
|
|
1096
|
+
rows: SessionEntryV1[];
|
|
1097
|
+
total: number;
|
|
1098
|
+
offset: number;
|
|
1099
|
+
};
|
|
1100
|
+
};
|
|
1101
|
+
/**
|
|
1102
|
+
* 🚧 Core's lore entries (R58): an entry's **Off** and **Pin** marks, and
|
|
1103
|
+
* nothing else — never a re-embed. Resolves with both marks as the session
|
|
1104
|
+
* reads the entry — its line, at its clock. For the book's owner and
|
|
1105
|
+
* admins; the server judges it.
|
|
1106
|
+
*
|
|
1107
|
+
* `heldBy` is present when a dated amendment still decides a mark asked
|
|
1108
|
+
* for, so it does not read as asked here: the entry itself was saved, and
|
|
1109
|
+
* the amendment wins from `date` on (spelled by the book's calendar).
|
|
1110
|
+
*/
|
|
1111
|
+
'set-entry-marks': {
|
|
1112
|
+
params: {
|
|
1113
|
+
entryId: number;
|
|
1114
|
+
off?: boolean;
|
|
1115
|
+
pinned?: boolean;
|
|
1116
|
+
};
|
|
1117
|
+
result: {
|
|
1118
|
+
off: boolean;
|
|
1119
|
+
pinned: boolean;
|
|
1120
|
+
heldBy?: {
|
|
1121
|
+
mark: 'off' | 'pinned';
|
|
1122
|
+
date: string;
|
|
1123
|
+
};
|
|
1124
|
+
};
|
|
1125
|
+
};
|
|
1126
|
+
/**
|
|
1127
|
+
* 🚧 Core's author's note widget (2026-10-02, AN1): the session's
|
|
1128
|
+
* author's note as it reads now, whether the viewer may change it, and
|
|
1129
|
+
* what the newest reply's prompt did with it. The page names its own
|
|
1130
|
+
* session.
|
|
1131
|
+
*/
|
|
1132
|
+
'authors-note': {
|
|
1133
|
+
params: Record<string, never>;
|
|
1134
|
+
result: AuthorsNoteV1;
|
|
1135
|
+
};
|
|
1136
|
+
/**
|
|
1137
|
+
* 🚧 Core's author's note widget: save the session's author's note,
|
|
1138
|
+
* whole. The session's owner only — the server judges it. Resolves with
|
|
1139
|
+
* the note as it now reads.
|
|
1140
|
+
*/
|
|
1141
|
+
'set-authors-note': {
|
|
1142
|
+
params: {
|
|
1143
|
+
note: AuthorsNoteValueV1;
|
|
1144
|
+
};
|
|
1145
|
+
result: AuthorsNoteV1;
|
|
1146
|
+
};
|
|
1147
|
+
}
|
|
1148
|
+
/**
|
|
1149
|
+
* 🚧 The session's author's note, as stored (2026-10-02, AN1) — the value of
|
|
1150
|
+
* a genre's `authorsNote` field (`AUTHORS_NOTE_FIELD` in core's catalogue).
|
|
1151
|
+
* Not the post-history reminder, which is the pipeline's and the card's.
|
|
1152
|
+
* @experimental
|
|
1153
|
+
*/
|
|
1154
|
+
export interface AuthorsNoteValueV1 {
|
|
1155
|
+
text: string;
|
|
1156
|
+
/** Messages before the reply it is placed; 0 is right before the reply. */
|
|
1157
|
+
depth: number;
|
|
1158
|
+
/** Added to every `interval`-th reply; 1 is every reply. */
|
|
1159
|
+
interval: number;
|
|
1160
|
+
role: 'system' | 'user' | 'assistant';
|
|
1161
|
+
}
|
|
1162
|
+
/**
|
|
1163
|
+
* 🚧 What the `authors-note` request answers (2026-10-02, AN1).
|
|
1164
|
+
* @experimental
|
|
1165
|
+
*/
|
|
1166
|
+
export interface AuthorsNoteV1 {
|
|
1167
|
+
/** The session's genre declares an author's note at all. False: nothing else here means anything. */
|
|
1168
|
+
offered: boolean;
|
|
1169
|
+
/** The viewer may change it (the session's owner). */
|
|
1170
|
+
canEdit: boolean;
|
|
1171
|
+
note: AuthorsNoteValueV1;
|
|
1172
|
+
/**
|
|
1173
|
+
* What the newest reply's prompt did with the note — Assemble's own
|
|
1174
|
+
* decision, off that run's receipt. Null when no reply has been written
|
|
1175
|
+
* with a note in scope yet.
|
|
1176
|
+
*/
|
|
1177
|
+
lastReply: {
|
|
1178
|
+
included: boolean;
|
|
1179
|
+
/** `included`, `empty` (no text), or `interval` (this reply was not one of every `interval`). */
|
|
1180
|
+
reason: 'included' | 'empty' | 'interval';
|
|
1181
|
+
depth: number;
|
|
1182
|
+
/** Where it landed among the messages the prompt carried, oldest first. */
|
|
1183
|
+
targetIndex: number;
|
|
1184
|
+
} | null;
|
|
1185
|
+
}
|
|
1186
|
+
/** @experimental */
|
|
1187
|
+
export type WidgetRequestKind = keyof WidgetRequests;
|
|
1188
|
+
/**
|
|
1189
|
+
* 🚧 One entry of the session's lorebook, with what this session's rankings
|
|
1190
|
+
* made of it — a row of `session-entries`.
|
|
1191
|
+
* @experimental
|
|
1192
|
+
*/
|
|
1193
|
+
export interface SessionEntryV1 {
|
|
1194
|
+
id: number;
|
|
1195
|
+
/** The entry type's id. */
|
|
1196
|
+
typeId: string;
|
|
1197
|
+
title: string;
|
|
1198
|
+
keys: string[];
|
|
1199
|
+
/** Marked **Off**: retrieval may not use it. */
|
|
1200
|
+
off: boolean;
|
|
1201
|
+
/** **Pinned**: in every prompt, whatever the ranking says. */
|
|
1202
|
+
pinned: boolean;
|
|
1203
|
+
/** How often this session's rankings judged it, and how often they included it. */
|
|
1204
|
+
timesJudged: number;
|
|
1205
|
+
timesIncluded: number;
|
|
1206
|
+
/** When a ranking last judged it (an ISO string on the wire); null when none has. */
|
|
1207
|
+
lastJudgedAt: string | null;
|
|
1208
|
+
/** Whether that last judgement included it, why, and at what rank. */
|
|
1209
|
+
lastIncluded: boolean | null;
|
|
1210
|
+
lastReason: string | null;
|
|
1211
|
+
lastRank: number | null;
|
|
1212
|
+
}
|
|
1213
|
+
/**
|
|
1214
|
+
* 🚧 Who a host answers a request kind for — its **askers** (F9):
|
|
1215
|
+
*
|
|
1216
|
+
* - `'any'` — any widget's, core's or a plugin's. The host still applies
|
|
1217
|
+
* its own rules (an admin's view, an image off the app's origin).
|
|
1218
|
+
* - `'core'` — core's own widgets only: a verb that acts as the viewer
|
|
1219
|
+
* (sends, writes, marks), which a plugin's widget does through its own
|
|
1220
|
+
* actions instead.
|
|
1221
|
+
* - `{ scope }` — core's, or a plugin's widget GRANTED that scope (reviewed
|
|
1222
|
+
* as `widget:<scope>`, carried as the bare scope): a request that READS
|
|
1223
|
+
* scoped data, so the scope that would have pushed it is what lets a
|
|
1224
|
+
* widget page it.
|
|
1225
|
+
* @experimental
|
|
1226
|
+
*/
|
|
1227
|
+
export type WidgetRequestAskers = 'any' | 'core' | {
|
|
1228
|
+
scope: WidgetSectionScope;
|
|
1229
|
+
};
|
|
1230
|
+
/**
|
|
1231
|
+
* The askers of every request kind — the marking a host enforces
|
|
1232
|
+
* ({@link widgetRequestRefusal}). Typed off {@link WidgetRequests}, so a kind
|
|
1233
|
+
* cannot be added without saying who may ask it.
|
|
1234
|
+
* @experimental
|
|
1235
|
+
*/
|
|
1236
|
+
export declare const WIDGET_REQUEST_ASKERS: {
|
|
1237
|
+
readonly [K in WidgetRequestKind]: WidgetRequestAskers;
|
|
1238
|
+
};
|
|
1239
|
+
/** Every request kind — what a host checks an incoming `request` against. @experimental */
|
|
1240
|
+
export declare const WIDGET_REQUEST_KINDS: readonly WidgetRequestKind[];
|
|
1241
|
+
/**
|
|
1242
|
+
* Why a host must decline this request from this widget, as a sentence — or
|
|
1243
|
+
* null when {@link WIDGET_REQUEST_ASKERS} lets it ask. `owner` is `'core'` or
|
|
1244
|
+
* the widget's plugin id; `grants` the scopes that widget was granted, as
|
|
1245
|
+
* BARE scopes (`'lore'`, `'session:state'`) — never the permission keys they
|
|
1246
|
+
* are reviewed as (`'widget:lore'`), which match nothing here. Core's widgets
|
|
1247
|
+
* hold every scope. A request is still not a grant: null means the host MAY
|
|
1248
|
+
* answer, never that it must. Grants that are not a list — a stored string,
|
|
1249
|
+
* whose `includes` would match a substring — grant nothing.
|
|
1250
|
+
* @experimental
|
|
1251
|
+
*/
|
|
1252
|
+
export declare function widgetRequestRefusal(kind: string, from: {
|
|
1253
|
+
owner: string;
|
|
1254
|
+
grants?: readonly string[];
|
|
1255
|
+
}): string | null;
|
|
1256
|
+
/** What rides beside an invocation: the subject message, entered values. @experimental */
|
|
1257
|
+
export interface WidgetInvokeArgs {
|
|
1258
|
+
messageId?: number;
|
|
1259
|
+
payload?: WidgetPayload;
|
|
1260
|
+
/**
|
|
1261
|
+
* The form the press answers — a block's id within `messageId` (R-15
|
|
1262
|
+
* *Forms*) — so the server reads the block off the row and holds the press
|
|
1263
|
+
* to its addressee. Absent on every other press.
|
|
1264
|
+
*
|
|
1265
|
+
* The `invoke` spelling of {@link WidgetVerbs.action}'s fifth argument: a
|
|
1266
|
+
* widget drawing a message's form presses it by the declaration's identity
|
|
1267
|
+
* like any other action, and the block it answers rides here rather than
|
|
1268
|
+
* forcing that one press back onto the deprecated verb.
|
|
1269
|
+
*/
|
|
1270
|
+
blockId?: string;
|
|
1271
|
+
/**
|
|
1272
|
+
* The text the press already supplies (lair pass S2): the composer's
|
|
1273
|
+
* **slash argument**, `/nudge go north` → `go north`. The host hands it
|
|
1274
|
+
* to an action that collects text, as if the collect modal had — and
|
|
1275
|
+
* refuses the press, firing nothing, when the action collects none. An
|
|
1276
|
+
* action that also collects recipients still opens its modal, prefilled.
|
|
1277
|
+
*/
|
|
1278
|
+
text?: string;
|
|
1279
|
+
}
|
|
1280
|
+
/**
|
|
1281
|
+
* Something the host told this widget about.
|
|
1282
|
+
*
|
|
1283
|
+
* A discriminated union on `kind`. The last member is the ESCAPE HATCH and it
|
|
1284
|
+
* is namespaced on purpose: a bare `{ kind: string }` widened the union back to
|
|
1285
|
+
* "any string", so an author's typo compiled and every other member stopped
|
|
1286
|
+
* narrowing. A kind core does not ship is spelled `custom:<whatever>`, which
|
|
1287
|
+
* can never collide with a member added here later.
|
|
1288
|
+
* @experimental
|
|
1289
|
+
*/
|
|
1290
|
+
export type WidgetEvent = {
|
|
1291
|
+
kind: 'message:created';
|
|
1292
|
+
/** The channel as stored — canonical, so lane 1 is the bare slug. */
|
|
1293
|
+
channel: string;
|
|
1294
|
+
/** …taken apart, so a widget need not parse it (ruling 2026-09-09). */
|
|
1295
|
+
slug: string;
|
|
1296
|
+
lane: number;
|
|
1297
|
+
messageId: number;
|
|
1298
|
+
}
|
|
1299
|
+
/**
|
|
1300
|
+
* A row this widget can see changed in a way that is not an arriving
|
|
1301
|
+
* delta — an edit, a hide, a swipe, a re-stamped metadata bag.
|
|
1302
|
+
*
|
|
1303
|
+
* `channel` is the row's, canonically, so the host can narrow this to the
|
|
1304
|
+
* widgets that declared it; absent from a host that does not know which
|
|
1305
|
+
* channel the row was on, which reaches every widget as before.
|
|
1306
|
+
*/
|
|
1307
|
+
| {
|
|
1308
|
+
kind: 'message:updated';
|
|
1309
|
+
messageId: number;
|
|
1310
|
+
channel?: string;
|
|
1311
|
+
}
|
|
1312
|
+
/** A row this widget can see is gone. `channel` as `message:updated`. */
|
|
1313
|
+
| {
|
|
1314
|
+
kind: 'message:deleted';
|
|
1315
|
+
messageId: number;
|
|
1316
|
+
channel?: string;
|
|
1317
|
+
}
|
|
1318
|
+
/**
|
|
1319
|
+
* Text was appended to a row being generated — `delta` is the appended
|
|
1320
|
+
* text alone, never the row's whole content. Emitted per arrival, so a
|
|
1321
|
+
* listener doing real work per delta is doing it once per chunk.
|
|
1322
|
+
* `channel` as `message:updated`.
|
|
1323
|
+
*/
|
|
1324
|
+
| {
|
|
1325
|
+
kind: 'message:delta';
|
|
1326
|
+
messageId: number;
|
|
1327
|
+
delta: string;
|
|
1328
|
+
channel?: string;
|
|
1329
|
+
}
|
|
1330
|
+
/**
|
|
1331
|
+
* A reply started filling. Carries the row when the host knows which one
|
|
1332
|
+
* (it usually does — the row exists before its first token).
|
|
1333
|
+
*
|
|
1334
|
+
* Names no channel on purpose: a generation is session news, not channel
|
|
1335
|
+
* news, and reaches every widget.
|
|
1336
|
+
*/
|
|
1337
|
+
| {
|
|
1338
|
+
kind: 'generation:start';
|
|
1339
|
+
messageId?: number;
|
|
1340
|
+
}
|
|
1341
|
+
/**
|
|
1342
|
+
* …and stopped. `aborted` is true for a reply a person stopped, leaving
|
|
1343
|
+
* the partial text — the `stopped` outcome, not an error.
|
|
1344
|
+
*/
|
|
1345
|
+
| {
|
|
1346
|
+
kind: 'generation:end';
|
|
1347
|
+
messageId?: number;
|
|
1348
|
+
aborted: boolean;
|
|
1349
|
+
} | {
|
|
1350
|
+
kind: 'channel:activated';
|
|
1351
|
+
channel: string;
|
|
1352
|
+
slug: string;
|
|
1353
|
+
lane: number;
|
|
1354
|
+
}
|
|
1355
|
+
/**
|
|
1356
|
+
* 🚧 Provisional — DECLARED, NOT PRODUCED (2026-09-17). No host ships a
|
|
1357
|
+
* single "the selected message"; the session page's only selection is the
|
|
1358
|
+
* summarization mode's SET of rows, which this member cannot describe and
|
|
1359
|
+
* must not be bent into. A widget may subscribe, and will hear nothing
|
|
1360
|
+
* until a host has one selected message to announce; the shape may change
|
|
1361
|
+
* when one does. Do not read absence as "nothing is selected".
|
|
1362
|
+
*/
|
|
1363
|
+
| {
|
|
1364
|
+
kind: 'selection:changed';
|
|
1365
|
+
messageId: number | null;
|
|
1366
|
+
}
|
|
1367
|
+
/**
|
|
1368
|
+
* This widget's placement changed — it moved, resized, changed tier, or was
|
|
1369
|
+
* collapsed/drawered. The new `layout.v1` rides along so a listener needs no
|
|
1370
|
+
* second read; a native consumer can equally read `layout.v1` off its own
|
|
1371
|
+
* context, which is already reactive. It exists for the frame lane, where a
|
|
1372
|
+
* push is the only reactivity there is, and is emitted on both so the two
|
|
1373
|
+
* stay field-for-field identical.
|
|
1374
|
+
*/
|
|
1375
|
+
| {
|
|
1376
|
+
kind: 'layout:changed';
|
|
1377
|
+
layout: LayoutV1;
|
|
1378
|
+
}
|
|
1379
|
+
/**
|
|
1380
|
+
* A package's event was recorded in this session (R56) — everything in the
|
|
1381
|
+
* session hears it, so every widget does. `event` is its id (compare with
|
|
1382
|
+
* the declaration: `e.event === guessed.id`); `payload` is what the
|
|
1383
|
+
* recording wrote; `at` the instant it was recorded. Names no channel: an
|
|
1384
|
+
* event is session news. Core's own events reach widgets as the members
|
|
1385
|
+
* above, never as this one.
|
|
1386
|
+
*/
|
|
1387
|
+
| {
|
|
1388
|
+
kind: 'event:recorded';
|
|
1389
|
+
event: string;
|
|
1390
|
+
payload: unknown;
|
|
1391
|
+
at: number;
|
|
1392
|
+
}
|
|
1393
|
+
/**
|
|
1394
|
+
* 🚧 A turn in this session ranked its lore (R81): what the rankings made
|
|
1395
|
+
* of the session's lore entries was written — the rollup `session-entries`
|
|
1396
|
+
* reads moved — so a lore reader asks again now, and only now. Carries
|
|
1397
|
+
* nothing: the rows are the request's. Sent after the write, never before
|
|
1398
|
+
* it. Heard by core's widgets and by a plugin's widget granted `lore`
|
|
1399
|
+
* ({@link WIDGET_EVENT_SCOPES}); names no channel.
|
|
1400
|
+
*/
|
|
1401
|
+
| {
|
|
1402
|
+
kind: 'lore:ranked';
|
|
1403
|
+
}
|
|
1404
|
+
/**
|
|
1405
|
+
* 🚧 A lore entry of the session's book changed — its marks (pinned, off)
|
|
1406
|
+
* or anything else a save wrote — by this viewer, in any of their tabs,
|
|
1407
|
+
* widgets or the lorebook's editors. A lore reader showing `entryId` asks
|
|
1408
|
+
* again, so a mark set in one place is never stale in another; one showing
|
|
1409
|
+
* only pinned or off entries asks again whatever the id, since the entry
|
|
1410
|
+
* may have joined. Carries the id only — not how the session reads the
|
|
1411
|
+
* entry now: the row is the request's. Sent after the write. Scoped like
|
|
1412
|
+
* `lore:ranked` ({@link WIDGET_EVENT_SCOPES}); names no channel.
|
|
1413
|
+
*/
|
|
1414
|
+
| {
|
|
1415
|
+
kind: 'lore:marked';
|
|
1416
|
+
entryId: number;
|
|
1417
|
+
}
|
|
1418
|
+
/**
|
|
1419
|
+
* 🚧 The session's stored **genre fields** changed (history window lane,
|
|
1420
|
+
* 2026-10-03) — Edit Session › Settings saved one, or a widget wrote one
|
|
1421
|
+
* (the Author's note's `set-authors-note`), in any of the owner's tabs. A
|
|
1422
|
+
* widget showing a genre field's value asks again; carries nothing — the
|
|
1423
|
+
* value is the request's. Sent after the write, to the session's owner's
|
|
1424
|
+
* page only (the one person who may change them); names no channel.
|
|
1425
|
+
*/
|
|
1426
|
+
| {
|
|
1427
|
+
kind: 'genreFields:changed';
|
|
1428
|
+
}
|
|
1429
|
+
/** Anything core does not ship. Namespaced so it cannot shadow a member. */
|
|
1430
|
+
| {
|
|
1431
|
+
kind: `custom:${string}`;
|
|
1432
|
+
payload?: WidgetPayload;
|
|
1433
|
+
};
|
|
1434
|
+
/** Every event kind a widget may subscribe to, the custom namespace included. @experimental */
|
|
1435
|
+
export type WidgetEventKind = WidgetEvent['kind'];
|
|
1436
|
+
/**
|
|
1437
|
+
* 🚧 The scope a widget must hold to HEAR an event kind (R81) — a kind not
|
|
1438
|
+
* listed is heard by every widget its channel reaches. An event about scoped
|
|
1439
|
+
* data is scoped data: a widget that may not read the lore is not told when
|
|
1440
|
+
* it moved. Read by {@link widgetEventHeard}, which every host delivery of
|
|
1441
|
+
* widget events asks.
|
|
1442
|
+
* @experimental
|
|
1443
|
+
*/
|
|
1444
|
+
export declare const WIDGET_EVENT_SCOPES: {
|
|
1445
|
+
readonly [K in WidgetEventKind]?: WidgetSectionScope;
|
|
1446
|
+
};
|
|
1447
|
+
/**
|
|
1448
|
+
* Is this widget told of an event of this kind? Core's widgets hold every
|
|
1449
|
+
* scope; a plugin's hears a scoped kind only when granted its scope — as
|
|
1450
|
+
* BARE scopes (`'lore'`), never the permission keys (`'widget:lore'`); grants
|
|
1451
|
+
* that are not a list grant nothing (the rule {@link widgetRequestRefusal}
|
|
1452
|
+
* holds a request to).
|
|
1453
|
+
* @experimental
|
|
1454
|
+
*/
|
|
1455
|
+
export declare function widgetEventHeard(kind: string, to: {
|
|
1456
|
+
owner: string;
|
|
1457
|
+
grants?: readonly string[];
|
|
1458
|
+
}): boolean;
|
|
1459
|
+
/** What a widget can DO — the transport half of the envelope. @experimental */
|
|
1460
|
+
export interface WidgetVerbs {
|
|
1461
|
+
/**
|
|
1462
|
+
* ⏳ Fire an action by its bare **key**.
|
|
1463
|
+
*
|
|
1464
|
+
* @deprecated Use {@link WidgetVerbs.invoke}. A press names a DECLARATION
|
|
1465
|
+
* by its identity: a bare key is resolved by the server to the genre's
|
|
1466
|
+
* sole declarer of it and refused — naming the identities — when several
|
|
1467
|
+
* specs declare it (plans/31 V2). Accepted for one release; `invoke`
|
|
1468
|
+
* resolves the identity for you.
|
|
1469
|
+
*
|
|
1470
|
+
* `action` is the identity of the declaration being fired
|
|
1471
|
+
* (`<spec slug>#<key>`) when one is in hand — `invoke` always supplies it —
|
|
1472
|
+
* so the server checks THAT action's audience and enablement and runs THAT
|
|
1473
|
+
* spec.
|
|
1474
|
+
*/
|
|
1475
|
+
action(fn: string, messageId?: number, payload?: WidgetPayload, action?: string,
|
|
1476
|
+
/**
|
|
1477
|
+
* The form the press answers — a block's id within `messageId` (R-15
|
|
1478
|
+
* *Forms*) — so the server reads the block off the row and holds the
|
|
1479
|
+
* press to its addressee. Absent on every other press.
|
|
1480
|
+
*/
|
|
1481
|
+
blockId?: string): void;
|
|
1482
|
+
/**
|
|
1483
|
+
* Fire an action from `actions.v1` by its **identity** (`<spec slug>#<key>`)
|
|
1484
|
+
* or, when only one action carries it, its bare **key** (R-15
|
|
1485
|
+
* `invoke(id, args)`): the host resolves it to the declaration and routes it
|
|
1486
|
+
* — one of core's verbs to the host's real handler (an `extend` is an
|
|
1487
|
+
* extend, never a function fire), a contributed one to the audited fire
|
|
1488
|
+
* with its identity. A key no venue lists, or a bare key several actions
|
|
1489
|
+
* share, throws: a widget cannot fire something the session does not offer —
|
|
1490
|
+
* or something ambiguous — and believe it did.
|
|
1491
|
+
*/
|
|
1492
|
+
invoke(key: string, args?: WidgetInvokeArgs): void;
|
|
1493
|
+
/** Ask the host for something ({@link WidgetRequests}); rejects when it declines. */
|
|
1494
|
+
request<K extends WidgetRequestKind>(kind: K, params: WidgetRequests[K]['params']): Promise<WidgetRequests[K]['result']>;
|
|
1495
|
+
/**
|
|
1496
|
+
* 🚧 The viewer's translation of an English UI string (C0b) — synchronous,
|
|
1497
|
+
* the source itself until a translation arrives, then re-rendered. For
|
|
1498
|
+
* a widget's OWN literals; declared text (a label, a title) is a locale
|
|
1499
|
+
* map read with `i18nText(text, locale.v1)`.
|
|
1500
|
+
*/
|
|
1501
|
+
t(source: string): string;
|
|
1502
|
+
/** Host-rendered menu; resolves to the pick, or null if dismissed. */
|
|
1503
|
+
menu(spec: MenuSpec): Promise<MenuResult | null>;
|
|
1504
|
+
/**
|
|
1505
|
+
* Subscribe to a host event; returns an unsubscribe.
|
|
1506
|
+
*
|
|
1507
|
+
* `'*'` receives every event, which is how a widget forwards the lot —
|
|
1508
|
+
* into its own store, a log, a bridge — without enumerating a union it
|
|
1509
|
+
* would then have to keep in step. It is a SUBSCRIPTION, never a kind: no
|
|
1510
|
+
* event is ever delivered carrying `kind: '*'`.
|
|
1511
|
+
*/
|
|
1512
|
+
on(kind: WidgetEventKind | '*', cb: (e: WidgetEvent) => void): () => void;
|
|
1513
|
+
}
|
|
1514
|
+
/**
|
|
1515
|
+
* The version of the widget contract — the verbs above and the message kinds
|
|
1516
|
+
* that carry them.
|
|
1517
|
+
*
|
|
1518
|
+
* ONE number for both deliveries: native IS frame minus the iframe (ruled
|
|
1519
|
+
* 2026-09-08), so a second clock for the in-document lane would be a second
|
|
1520
|
+
* contract by accident. `FRAME_PROTOCOL` in `surfaces.ts` is this constant
|
|
1521
|
+
* under the name the frame wire spells it, and the frame's `init` carries it.
|
|
1522
|
+
* @experimental
|
|
1523
|
+
*/
|
|
1524
|
+
export declare const WIDGET_PROTOCOL: 2;
|
|
1525
|
+
/** A version of the widget contract a host and a frame can both speak. @experimental */
|
|
1526
|
+
export type WidgetProtocolVersion = 1 | 2;
|
|
1527
|
+
//# sourceMappingURL=widgets.d.ts.map
|