@serene-pub/contracts 0.6.0-pr-2 → 0.6.0-pr-4

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/dist/inlets.js ADDED
@@ -0,0 +1,679 @@
1
+ /**
2
+ * Core's **inlet** node definitions — where a run enters.
3
+ *
4
+ * One file per node kind, with the helpers only that kind uses; `index.ts`
5
+ * re-exports them all.
6
+ */
7
+ import { S } from '@serene-pub/sdk';
8
+ import { describeInletDefinition, pin } from '@serene-pub/sdk';
9
+ // ── Inputs ──────────────────────────────────────────────────────────────────
10
+ /**
11
+ * What a turn is *about*: this chat, and whose turn it is.
12
+ *
13
+ * `sessionScope` bundles both and is what the queries take, but neither was
14
+ * readable on its own — so a node that needs only the speaker had to accept the
15
+ * whole scope and reach into it, and `currentCharacterId` ended up travelling
16
+ * on `HostScope` instead of through the graph because there was no port to
17
+ * carry it. Hidden state in a run that otherwise records everything.
18
+ *
19
+ * The two scalars are ports now. `sessionScope` stays: a query wanting both should
20
+ * take one thing, not reassemble it.
21
+ * @public
22
+ */
23
+ export const userMessage = pin(describeInletDefinition({
24
+ id: 'core:inlet/user-message@1',
25
+ // Display only, both keys: stripped from the content hash, refreshed on
26
+ // existing rows by the boot sync — so copyediting this is never a bump.
27
+ i18n: {
28
+ name: { en: 'Chat' },
29
+ description: {
30
+ en: 'The standard roleplay chat — bring characters and personas in any mix, attach a lorebook if you like, and type to talk.',
31
+ },
32
+ },
33
+ /**
34
+ * The standard chat's shape (19 §1) — today's behaviour, *stated*.
35
+ * This block is what makes the input type a **chat mode** (the F29
36
+ * floor: always present, special in availability and nothing else).
37
+ * Both participant systems are optional and unbounded above, lorebooks
38
+ * attach when wanted, the composer is a text box, and the seed line
39
+ * carries the speaking character's name. Duties and triggers are not
40
+ * here on purpose: the shape is owner-only, and the narrate button is
41
+ * the narrate spec's contribution, not this type's knowledge (19 §3).
42
+ */
43
+ sessionShape: {
44
+ characters: { min: 0 },
45
+ personas: { min: 0 },
46
+ lorebook: 'optional',
47
+ composer: 'text',
48
+ voice: 'character',
49
+ // Stated rather than assumed (20): a new chat seeds the cast's
50
+ // greetings on `main`. It is the default for any input node, so a
51
+ // custom mode reuses it for free; core declares it so the reusable
52
+ // case reads at a glance.
53
+ greeting: { enabled: true, channel: 'main' },
54
+ },
55
+ slots: {
56
+ /**
57
+ * The input hook (18 §4a): user chains over the triggering text,
58
+ * phase `after` on what this node publishes — which is what
59
+ * lorebook scanning and the prompt's seed see. The stored user
60
+ * message was written before the turn began and stays untouched
61
+ * by construction; the slot description says so because that is
62
+ * the question the control raises.
63
+ */
64
+ scripts: {
65
+ kind: 'scripts',
66
+ accepts: ['core:script:text/transform@1'],
67
+ port: 'text',
68
+ phase: 'after',
69
+ description: 'Scripts over the message that triggered this turn — expand shorthand, resolve dice notation — as retrieval and the prompt will see it. The stored message is not changed.',
70
+ },
71
+ },
72
+ ports: {
73
+ out: {
74
+ main: S.json,
75
+ text: S.text,
76
+ sessionScope: S.sessionScope,
77
+ sessionId: S.rowIds,
78
+ /**
79
+ * Whose turn it is, as a **participant reference** (R-18 (3)):
80
+ * `character:<id>` for a library character, `envoy:<slug>` for
81
+ * a speaker the genre brings with it. Null on a narrator turn —
82
+ * nobody in particular is speaking. One port answers "who is
83
+ * speaking" for both kinds, so nothing downstream branches on
84
+ * which it received; who *portrays* them this turn is the
85
+ * host's resolver's answer, pinned on the receipt (R-21 (4)).
86
+ */
87
+ speaker: S.participantRef,
88
+ /**
89
+ * @deprecated The same speaker as a bare character id (one
90
+ * release, from 2026-09-16). Null on a narrator turn, and null
91
+ * for an envoy — which is why it cannot stay the port: a
92
+ * reader keyed on it sees a genre's speaker as nobody. Read
93
+ * `speaker`; the turn strategies publish both meanwhile.
94
+ */
95
+ characterId: S.rowIds,
96
+ /**
97
+ * Who **pressed** — the reference of whoever sent the message
98
+ * or fired the action this run answers (G9, 2026-09-17).
99
+ *
100
+ * `user:<id>` for a person with no presence in the session,
101
+ * `character:<id>` when they hold a persona here — their
102
+ * persona is a character (0132), so a line written as them is
103
+ * written as that character — and, when an answer pipeline
104
+ * pressed on a participant's behalf, that participant's own
105
+ * reference, so the AI-portrayed presser is named rather than
106
+ * the machinery that spoke for them.
107
+ *
108
+ * ⚠ **Not `speaker`.** `speaker` is whose turn it is — who the
109
+ * reply comes out as — and on nearly every turn the two differ:
110
+ * a person types and a character answers. This is the other
111
+ * end of that sentence, and the port a spec wires into
112
+ * `core:outlet/create-message@1`'s `speaker` when it wants to
113
+ * write a line AS the person who pressed: the host already had
114
+ * the path (`speaker: 'user:<id>'` writes a user-role row) and
115
+ * no inlet carried the reference to put in it, so a plugin that
116
+ * wanted the player's own line had to ride it on the model's
117
+ * reply as a block (Battleship, plan §12).
118
+ *
119
+ * Never null on a turn or a fire: a run has an owner, and the
120
+ * owner is a person. Absent only where the inlet is resolved
121
+ * without one, which no shipped path does.
122
+ */
123
+ presser: S.participantRef,
124
+ /**
125
+ * The cast members a press collected (lair pass R3,
126
+ * 2026-09-28): `character:<id>` references, for an action
127
+ * declaring `collects.recipients` — picked in the collect
128
+ * modal, and validated by the host (seated and enabled, no
129
+ * duplicates, within the declared `min` and `max`) before
130
+ * the run starts. Absent on a turn and on every press of an
131
+ * action that collects none.
132
+ */
133
+ recipients: S.participantRefs,
134
+ /**
135
+ * Values for the mode's declared `fields` (19 §1), filtered to
136
+ * the declared schema keys — the supply side of the round
137
+ * trip: declaration → chat settings → chat row → this port →
138
+ * every downstream node.
139
+ */
140
+ fields: S.json,
141
+ /**
142
+ * Text an in-progress reply has already produced, when this turn
143
+ * is an **extend** (ruling 2026-09-08, D-2; the verb was `continue`
144
+ * until 2026-09-28).
145
+ *
146
+ * Empty on every other turn, which is nearly all of them. It is
147
+ * here rather than on an `extend`-only input type because an
148
+ * extend is the standard chat's own verb — it answers the same
149
+ * event, in the same session, from the same cast — and a second
150
+ * input type would restate this one's `sessionShape`, which is
151
+ * the thing `side-character-turn@1`'s note says a shape-bearing
152
+ * mode must never have copied.
153
+ *
154
+ * ⚠ It is not the triggering text and it is not a message. `text`
155
+ * stays what it would be on an ordinary turn, the row carrying
156
+ * this is excluded from every message read while it generates,
157
+ * and only `core:task/process-messages@1` consumes it — as the
158
+ * body of the seed line the model continues from.
159
+ */
160
+ continuationPrefill: S.text,
161
+ /**
162
+ * The reply row this turn re-drives, when it is a regenerate, a
163
+ * swipe or an extend of a message that already exists. Null on
164
+ * a fresh turn, which is nearly all of them.
165
+ *
166
+ * The pipeline owns its reply row (R-17): a fresh turn's row is
167
+ * created by the spec's own placeholder outlet, and a verb that
168
+ * re-drives an existing message hands that message to the same
169
+ * outlet through this port — so the outlet claims it as the
170
+ * run's live row instead of inserting a second one. It is data,
171
+ * recorded on the receipt, and never a scope read: "which row
172
+ * did this turn write" is answerable from the run afterwards.
173
+ */
174
+ messageId: S.rowIds,
175
+ /**
176
+ * What the built-ins did to this session since the last reply
177
+ * (R-15, 2026-09-16): a list of session changes — `[{ event:
178
+ * 'core:event/message-deleted@1', messageId, at, lost }, …]`,
179
+ * oldest first, capped at the newest fifty — so a pipeline
180
+ * knows the history it is about to read has moved: a line
181
+ * deleted with its content, a rewrite with the previous text,
182
+ * an alternative swiped in, a reply stopped short. Read once:
183
+ * the run that receives them consumes them — marked read
184
+ * after the run, and only when it produced a reply, so a run
185
+ * that fails leaves them for the next — and a preview sees
186
+ * them without consuming. Empty when nothing changed, which
187
+ * is nearly every turn. Past fifty, the newest fifty arrive
188
+ * and a last entry `{ event:
189
+ * 'core:event/session-changes-truncated@1', dropped }` says
190
+ * how many older ones did not.
191
+ *
192
+ * Was `changes` until 2026-09-16 (U5b review S4): that word is
193
+ * the state ledger's on `resolve-state-changes@1` and
194
+ * `set-state@1` — a list of value changes — and a session
195
+ * change is about a message, never a value (R1).
196
+ */
197
+ sessionChanges: S.json,
198
+ /**
199
+ * What an action's fire sent along (R-15 *Forms*; U5d,
200
+ * 2026-09-17): a form's answer — `{ choice }` for a choices
201
+ * block, the entered values for a form block — or a widget's
202
+ * `invoke(key, args)` arguments. Absent on a turn and on a
203
+ * bare press. A press on an **addressed** block arrives with
204
+ * `form` beside it (`core:task/read-answer@1` takes both and
205
+ * publishes the answer port by port). The host always
206
+ * supplied this under `payload`; declared 2026-09-17 so a
207
+ * spec can wire it.
208
+ */
209
+ payload: S.json,
210
+ /**
211
+ * The form a press answered, when it answered one — the block
212
+ * itself as stored, its id, the message and the addressee,
213
+ * read off the row by the host (never off the client):
214
+ * `{ blockId, messageId, kind, question, addressee, characterId,
215
+ * choice?, label? }`. Absent on every other fire.
216
+ */
217
+ form: S.json,
218
+ /**
219
+ * Which channel the message that triggered this turn is on
220
+ * (R-C, 2026-09-17) — the stored string, lane included:
221
+ * `main`, `manuscript`, `phone:3`.
222
+ *
223
+ * `main` when the trigger named none, which is every session
224
+ * whose genre declares no channel of its own. It is never a
225
+ * selector: `*` spans every channel for a *read* and is not
226
+ * somewhere a message can be, so it never appears here.
227
+ *
228
+ * ⚠ The run had no way to ask this before, and that is what
229
+ * kept a channel's declared `voice` half-wired: `voice: 'none'`
230
+ * could be read off the newest row, but `voice: 'narrator'`
231
+ * needs the channel the turn was triggered on even when that
232
+ * channel has no rows yet. It is a port rather than a scope
233
+ * read for the other half of the same reason — a genre that
234
+ * answers the manuscript differently from the conversation
235
+ * branches on it at a junction, and a junction can only read
236
+ * what a port carries.
237
+ */
238
+ /**
239
+ * The session's **settings document** (PLAN-turn-order §4.12,
240
+ * R13): every setting a person can see in session settings,
241
+ * resolved once per run by the host and handed in here —
242
+ * title, guests, genre fields (cascade applied, §4.13),
243
+ * scenario, lorebook, tags, channels, the cast with its
244
+ * envoys, the session-scope rebinds and param overrides per
245
+ * bound spec, the turn-order state, `metadata` (read-only)
246
+ * and the annex. `$.input.session.fields.tone` reads in any
247
+ * spec, and no node re-queries a table for a setting.
248
+ */
249
+ session: S.sessionSettings,
250
+ channel: S.text,
251
+ /**
252
+ * **How this turn was reached** (lair pass R8, 2026-09-28) —
253
+ * the fired turn entry's `via`: `strategy`, `script` or
254
+ * `voice` for a prepared turn, `pick` for one a person chose,
255
+ * and **`narrate`** when the press was the `core#narrate` turn
256
+ * control (the genre's own voice asked to narrate what happens
257
+ * next). A verb re-driving a row carries the `via` of the run
258
+ * that created it, so a regenerated narration narrates again.
259
+ * Empty when nothing says (an action's fire). A genre routes
260
+ * on it at a junction — the Lair narrates on `narrate` ahead
261
+ * of every other branch.
262
+ */
263
+ via: S.text,
264
+ },
265
+ },
266
+ }));
267
+ /**
268
+ * A built-in write's request (R-15, 2026-09-16) — what a person asked core to
269
+ * do to a message or a session: delete, hide, edit, swipe, branch.
270
+ *
271
+ * Core implements every state-altering write and runs each as its own
272
+ * one-node spec (`core:spec/builtin-delete` …) through the executor, so the
273
+ * write is receipted, gate-eligible and always emits what changed. This is
274
+ * that spec's inlet: the person's request, as the venue's handler shaped it
275
+ * after the permission checks it alone can make. No lock — a built-in serves
276
+ * every genre — and no shape: a request is not a session mode.
277
+ * @internal
278
+ */
279
+ export const builtInRequest = pin(describeInletDefinition({
280
+ id: 'core:inlet/built-in-request@1',
281
+ ports: {
282
+ out: {
283
+ main: S.json,
284
+ sessionScope: S.sessionScope,
285
+ sessionId: S.rowIds,
286
+ /** The message the write is about. Absent on a branch. */
287
+ target: S.rowIds,
288
+ /** An edit's new text; a swipe's alternative to record. */
289
+ text: S.text,
290
+ /** A hide's direction: hidden, or shown again. */
291
+ hidden: S.json,
292
+ /** A swipe's alternative to select, by index. */
293
+ index: S.json,
294
+ /** A branch's fork point — the last message the copy keeps. */
295
+ fromMessage: S.rowIds,
296
+ /**
297
+ * The session's **settings document** (PLAN-turn-order §4.12,
298
+ * R13): every setting a person can see in session settings,
299
+ * resolved once per run by the host and handed in here —
300
+ * title, guests, genre fields (cascade applied, §4.13),
301
+ * scenario, lorebook, tags, channels, the cast with its
302
+ * envoys, the session-scope rebinds and param overrides per
303
+ * bound spec, the turn-order state, `metadata` (read-only)
304
+ * and the annex. `$.input.session.fields.tone` reads in any
305
+ * spec, and no node re-queries a table for a setting.
306
+ */
307
+ session: S.sessionSettings,
308
+ /** A branch's name. */
309
+ title: S.text,
310
+ /**
311
+ * A person's sprite for the line: `{ set, label }`, or null to
312
+ * clear it (DESIGN-sprites §6) — a `sprite-pick@1`, the shape a
313
+ * picker publishes, so `core:outlet/show-sprite@1` takes one
314
+ * shape from both. Read by `core:spec/show-sprite`.
315
+ */
316
+ sprite: S.spritePick,
317
+ },
318
+ },
319
+ }));
320
+ // `core:inlet/message-created@1` stood here — an inlet no spec used and no
321
+ // event emitted (plans/29 §4c 4.1). Culled 2026-09-16 (R-4): an existing
322
+ // message's id arrives on `core:inlet/user-message@1`'s `messageId` port.
323
+ /**
324
+ * A session was just created — the create pipeline's trigger (24 §5, §12).
325
+ *
326
+ * The genre's one required pipeline answers this event and seeds the
327
+ * session's initial data: greetings per the genre's shape, initial channels,
328
+ * initial state. The payload is the create request itself — the genre, the
329
+ * chosen preset, the participants and initial field values — because what a
330
+ * create pipeline does is *finish* what the request began.
331
+ *
332
+ * Not `user-message`: reusing the turn input here welded creation to the
333
+ * chat turn's shape and was wrong (24 §12). A create run has no triggering
334
+ * text and no speaker; it has a request.
335
+ * @public
336
+ */
337
+ export const sessionCreated = pin(describeInletDefinition({
338
+ id: 'core:inlet/session-created@1',
339
+ i18n: {
340
+ name: { en: 'Session created' },
341
+ description: {
342
+ en: 'Fires once, when a session of this genre is created — the pipeline that answers it seeds greetings, channels and initial state.',
343
+ },
344
+ },
345
+ ports: {
346
+ out: {
347
+ main: S.json,
348
+ sessionScope: S.sessionScope,
349
+ sessionId: S.rowIds,
350
+ /**
351
+ * The create request: genre id, preset id, participant ids,
352
+ * lorebook, initial field values — everything the person chose
353
+ * before the session existed.
354
+ */
355
+ request: S.json,
356
+ /**
357
+ * The session's **settings document** (PLAN-turn-order §4.12,
358
+ * R13): every setting a person can see in session settings,
359
+ * resolved once per run by the host and handed in here —
360
+ * title, guests, genre fields (cascade applied, §4.13),
361
+ * scenario, lorebook, tags, channels, the cast with its
362
+ * envoys, the session-scope rebinds and param overrides per
363
+ * bound spec, the turn-order state, `metadata` (read-only)
364
+ * and the annex. `$.input.session.fields.tone` reads in any
365
+ * spec, and no node re-queries a table for a setting.
366
+ */
367
+ session: S.sessionSettings,
368
+ /** Values for the genre's declared fields, filtered to the schema. */
369
+ fields: S.json,
370
+ },
371
+ },
372
+ }));
373
+ /**
374
+ * A session event happened (PLAN-turn-order §4.1/§4.4, R1): the inlet every
375
+ * event-driven spec enters through, and the one core's turn-order spec
376
+ * uses.
377
+ *
378
+ * Locked over **several** events at once — `.inlet(key, node, { genre,
379
+ * events: [...] })` — because one spec answers nine of them identically:
380
+ * a send, an edit, a delete, a hide, a member change, a cast change, a
381
+ * settings save, a branch. A spec bound to N events has N binding rows and
382
+ * one document.
383
+ *
384
+ * `cause` is why it fired (`EventCause`: user · run · edit · settings ·
385
+ * system), and it is load-bearing beyond this node — the write this spec
386
+ * ends in carries it into `turn-order-changed`, where the auto-advance
387
+ * listener reads it to decide whether to fire the head turn (§4.6). A spec
388
+ * that drops it makes every recompute look like a system event.
389
+ * @experimental
390
+ */
391
+ export const sessionEvent = pin(describeInletDefinition({
392
+ id: 'core:inlet/session-event@1',
393
+ i18n: {
394
+ name: { en: 'Session event' },
395
+ description: {
396
+ en: 'Fires whenever something happens in a session — a message lands, the cast changes, a setting moves. The pipeline that answers it reads what happened and why.',
397
+ },
398
+ },
399
+ /**
400
+ * The event payloads this inlet reads: a spec may lock it to several
401
+ * events only when every one carries one of these. A session change, a
402
+ * cast change (member-added/-removed included), an annex change, and
403
+ * the envelope every event a package declared arrives in — its own
404
+ * payload is the envelope's `payload`.
405
+ */
406
+ payloads: [S.sessionChange, S.castChange, S.annexChange, S.recordedEvent],
407
+ ports: {
408
+ out: {
409
+ /** The event id that fired — `core:event/message-completed@1`. */
410
+ event: S.text,
411
+ sessionId: S.rowIds,
412
+ /** The event's own payload, as its registry entry's shape declares it. */
413
+ payload: S.json,
414
+ /** Why it fired (`EventCause`). Carried through to the write. */
415
+ cause: S.json,
416
+ /** When, as epoch milliseconds — what an order `basedOnAt` answers. */
417
+ at: S.json,
418
+ sessionScope: S.sessionScope,
419
+ /**
420
+ * The session's **settings document** (§4.12, R13), resolved
421
+ * once per run by the host after the write that caused this
422
+ * event — so the cast below is the cast as it is now, and no
423
+ * node needs a cast read of its own.
424
+ */
425
+ session: S.sessionSettings,
426
+ /**
427
+ * The settings document's **cast**, on its own port (PLAN
428
+ * §8 (17)): what `core:query/session-cast@1` publishes,
429
+ * envoys included, projected from `session` by the host.
430
+ *
431
+ * A port rather than a path, because an edge is `{ node,
432
+ * port }` and nothing in the graph addresses a field inside
433
+ * a port's value. §4.5 wires the pool's `cast` from the
434
+ * document; this is that wire, with the shape the pool's
435
+ * in-port declares.
436
+ */
437
+ cast: S.sessionCast,
438
+ },
439
+ },
440
+ }));
441
+ /**
442
+ * Who is about to speak, when the trigger picked somebody who is **not** in
443
+ * the cast — the side-character narration turn (ruling 2026-09-07).
444
+ *
445
+ * ## participant ≠ character
446
+ *
447
+ * A side character is a **participant without a turn slot**. The trigger's
448
+ * first step accepts either an existing character (`characterId`) or a name
449
+ * somebody typed (`speakerName` alone), and both are full participants *for
450
+ * that turn* — the prompt is written from their perspective and the seed line
451
+ * carries their name. Neither joins the session cast, and nothing here writes
452
+ * a `session_characters` row: this input publishes a fact about one turn, and
453
+ * a fact is not a membership.
454
+ *
455
+ * Its own type rather than a flag on `user-message@1`, for the reason that type
456
+ * already gives about the narrator: the type is the unit that declares a
457
+ * configurable surface, and `user-message` is the standard chat's **mode** —
458
+ * it carries the genre's `sessionShape`, which is exactly what a side-character
459
+ * turn must not restate. This one declares no shape, so it is an action input
460
+ * and never a session mode.
461
+ *
462
+ * ## The new-name hook (the fact, and only the fact)
463
+ *
464
+ * `sideCharacter` carries `known` — whether the chosen name matches anything in
465
+ * the session's lorebook — and the scripts hook below declares it as an **extra**,
466
+ * so a script attached there reads it through the one dispatch core scripts and
467
+ * extension hooks already share. Core states the fact and offers the hook; what
468
+ * a script *does* about an unknown name (suggest adding them, stay quiet, add a
469
+ * note to the prompt) is the script's business, not this declaration's. There is
470
+ * deliberately no second path: nothing here notifies, writes, or prompts.
471
+ * @experimental
472
+ */
473
+ export const sideCharacterTurn = pin(describeInletDefinition({
474
+ id: 'core:inlet/side-character-turn@1',
475
+ // Display only, both keys: stripped from the content hash, refreshed on
476
+ // existing rows by the boot sync — so copyediting this is never a bump.
477
+ i18n: {
478
+ name: { en: 'Side character' },
479
+ description: {
480
+ en: 'A turn spoken by somebody who is not in the cast — pick a character, or type a name. They speak once; they do not join the rotation.',
481
+ },
482
+ },
483
+ slots: {
484
+ /**
485
+ * The input hook (18 §4a), on the same terms as `user-message@1`:
486
+ * user chains over the triggering text, phase `after` on what this
487
+ * node publishes, which is what retrieval and the prompt see.
488
+ *
489
+ * ⚠ `extras` is what makes this the **new-name hook**. The three
490
+ * names below are read-only context supplied by the host at the
491
+ * hook (18 §6a) and are part of the fixed choice set the script
492
+ * editor offers — so "this name is new" is a declared read rather
493
+ * than a name typed on faith. `speakerIsKnown` is `false` exactly
494
+ * when a free-form name matched nothing in the session's lorebook.
495
+ */
496
+ scripts: {
497
+ kind: 'scripts',
498
+ accepts: ['core:script:text/transform@1'],
499
+ port: 'text',
500
+ phase: 'after',
501
+ extras: ['speakerName', 'speakerCharacterId', 'speakerIsKnown', 'castNames'],
502
+ description: 'Scripts over the instructions this turn was triggered with, as retrieval and the prompt will see them. The speaker rides along read-only — including whether the lorebook already knows them, so a script can offer to add somebody new.',
503
+ },
504
+ },
505
+ ports: {
506
+ out: {
507
+ main: S.json,
508
+ text: S.text,
509
+ sessionScope: S.sessionScope,
510
+ sessionId: S.rowIds,
511
+ /**
512
+ * Who is speaking, as a **participant reference** (R-18 (3)):
513
+ * `character:<id>` when the pick was a library character, null
514
+ * for a free-form name — a name is not a participant reference,
515
+ * and the fact below is where the name lives. On the same
516
+ * terms as `user-message@1`'s port of this name.
517
+ */
518
+ speaker: S.participantRef,
519
+ /**
520
+ * @deprecated The chosen character as a bare id, or null for a
521
+ * free-form name (one release, from 2026-09-16) — read
522
+ * `speaker`.
523
+ *
524
+ * ⚠ It is **not** a turn slot. It reaches character lore's
525
+ * visibility rule (an entry bound to this character becomes
526
+ * readable for this turn) and the prompt's perspective, and
527
+ * nothing else — round-robin selection reads the session's
528
+ * cast and its messages, neither of which this touches.
529
+ */
530
+ characterId: S.rowIds,
531
+ /**
532
+ * The side character as a whole fact: `{ name, characterId,
533
+ * known, character }`.
534
+ *
535
+ * A port rather than only an extra, because it is what the
536
+ * context builder is wired to and what the receipt records —
537
+ * "why did this turn sound like Vell" is answerable from the
538
+ * run afterwards rather than from the trigger that started it.
539
+ *
540
+ * Was `speaker` until 2026-09-16: that name is the participant
541
+ * reference now (R-18 (3), one word one meaning), and a fact
542
+ * carrying a free-form name is not a reference to anybody.
543
+ */
544
+ sideCharacter: S.json,
545
+ /**
546
+ * The session's **settings document** (PLAN-turn-order §4.12,
547
+ * R13): every setting a person can see in session settings,
548
+ * resolved once per run by the host and handed in here —
549
+ * title, guests, genre fields (cascade applied, §4.13),
550
+ * scenario, lorebook, tags, channels, the cast with its
551
+ * envoys, the session-scope rebinds and param overrides per
552
+ * bound spec, the turn-order state, `metadata` (read-only)
553
+ * and the annex. `$.input.session.fields.tone` reads in any
554
+ * spec, and no node re-queries a table for a setting.
555
+ */
556
+ session: S.sessionSettings,
557
+ /** Values for the genre's declared fields, filtered to the schema. */
558
+ fields: S.json,
559
+ /**
560
+ * The row this turn re-drives, on the same terms as
561
+ * `user-message@1`'s port of the same name: a regenerate, swipe
562
+ * or extend of a side character's line routes back to the
563
+ * narrate-character spec, and its placeholder claims the verb's
564
+ * row through this instead of inserting a second one. Null on
565
+ * a fresh turn.
566
+ */
567
+ messageId: S.rowIds,
568
+ /**
569
+ * The built-ins' session changes since the last reply, on the
570
+ * same terms as `user-message@1`'s port of this name (was
571
+ * `changes` until 2026-09-16, U5b review S4).
572
+ */
573
+ sessionChanges: S.json,
574
+ },
575
+ },
576
+ }));
577
+ // ── Forms (plans/29 R-15 *Forms* · *The line*; R-21 (5); 30 §U5d, 2026-09-17) ──
578
+ //
579
+ // A **form** is an action still awaiting its answer: a `choices` or `form`
580
+ // block a message carries, addressed to a participant. A person portraying
581
+ // the addressee answers by clicking; when the host's resolver says the AI
582
+ // portrays them this turn, core records `core:event/form-addressed@1` and the
583
+ // genre's answer pipeline runs — the four definitions below are its parts:
584
+ // the inlet the event lands on, the task that turns the form into a prompt
585
+ // context and a JSON Schema, the oracle (`generate-json@1`, already declared)
586
+ // that answers against the schema, and the outlet that commits the answer
587
+ // **exactly as a click would**. `make-choices@1` is the other direction: how
588
+ // a spec turns an oracle's JSON into a question with options; `read-answer@1`
589
+ // is how the action a form fires reads the answer port by port.
590
+ /**
591
+ * A form was addressed to a participant the AI portrays — the answer
592
+ * pipeline's trigger. The payload is `core:shape/form-addressed@1`; the
593
+ * ports below are it taken apart, with the block itself (`form`) and the
594
+ * addressee's character id (`characterId`, null for an envoy) beside them so
595
+ * the context builder can compile the addressee's card the way it compiles a
596
+ * speaker's. No shape — an event's inlet is never a session mode — and no
597
+ * lock here: the genre's answer spec declares its own `(genre, event)`.
598
+ * @experimental
599
+ */
600
+ export const formAddressed = pin(describeInletDefinition({
601
+ id: 'core:inlet/form-addressed@1',
602
+ i18n: {
603
+ name: { en: 'Form addressed' },
604
+ description: {
605
+ en: 'A question or form in a message was put to a participant the AI portrays this turn — the pipeline that answers it reads the addressee\'s card and the conversation, and answers against the form\'s schema.',
606
+ },
607
+ },
608
+ ports: {
609
+ out: {
610
+ main: S.formAddressed,
611
+ sessionScope: S.sessionScope,
612
+ sessionId: S.rowIds,
613
+ /**
614
+ * The session's **settings document** (PLAN-turn-order §4.12,
615
+ * R13): every setting a person can see in session settings,
616
+ * resolved once per run by the host and handed in here —
617
+ * title, guests, genre fields (cascade applied, §4.13),
618
+ * scenario, lorebook, tags, channels, the cast with its
619
+ * envoys, the session-scope rebinds and param overrides per
620
+ * bound spec, the turn-order state, `metadata` (read-only)
621
+ * and the annex. `$.input.session.fields.tone` reads in any
622
+ * spec, and no node re-queries a table for a setting.
623
+ */
624
+ session: S.sessionSettings,
625
+ /** The message carrying the block. */
626
+ messageId: S.rowIds,
627
+ /** The block's id within the message. */
628
+ blockId: S.text,
629
+ /** The block itself — a `choices` or `form` `MessageBlock`, as stored. */
630
+ form: S.json,
631
+ /** The identity of the action the form answers with — `<spec slug>#<key>`. */
632
+ action: S.text,
633
+ /** Who the form is put to, as a participant reference the resolver answered `ai` for. */
634
+ addressee: S.participantRef,
635
+ /** The addressee's character row, for the context builder; null for an envoy. */
636
+ characterId: S.rowIds,
637
+ /** Values for the genre's declared fields, as on a turn. */
638
+ fields: S.json,
639
+ },
640
+ },
641
+ }));
642
+ // ── Summarization ───────────────────────────────────────────────────────────
643
+ //
644
+ // Two phases, and the split is the whole design (see `utils/summarizer`):
645
+ // messages are cut into token-sized batches and each is drafted **on its own**,
646
+ // then the ordered drafts are merged into one narrative. Drafting a batch in
647
+ // isolation is what keeps a long chat summarizable at all — the model never
648
+ // sees more than one batch — and it is why the batch step is a `map` rather
649
+ // than a loop: the batches do not depend on each other, so nothing forces them
650
+ // to be sequential except the connection's own queue.
651
+ //
652
+ // Each step is its own Provider because each has its own prompt, connection and
653
+ // sampling config in the tables this replaces. That was already true; it was
654
+ // just spelled as `batch_system_prompt` / `synth_connection_id` columns rather
655
+ // than as nodes.
656
+ /** @internal */
657
+ export const summarizeRequest = pin(describeInletDefinition({
658
+ id: 'core:inlet/summarize-request@1',
659
+ ports: {
660
+ out: {
661
+ main: S.summarizeRequest,
662
+ scope: S.sessionScope,
663
+ /**
664
+ * The session's **settings document** (PLAN-turn-order §4.12,
665
+ * R13): every setting a person can see in session settings,
666
+ * resolved once per run by the host and handed in here —
667
+ * title, guests, genre fields (cascade applied, §4.13),
668
+ * scenario, lorebook, tags, channels, the cast with its
669
+ * envoys, the session-scope rebinds and param overrides per
670
+ * bound spec, the turn-order state, `metadata` (read-only)
671
+ * and the annex. `$.input.session.fields.tone` reads in any
672
+ * spec, and no node re-queries a table for a setting.
673
+ */
674
+ session: S.sessionSettings,
675
+ request: S.summarizeRequest,
676
+ },
677
+ },
678
+ }));
679
+ //# sourceMappingURL=inlets.js.map