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

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,744 @@
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 — today's behaviour, *stated*.
35
+ * This block is what makes the input type a **chat mode** (the
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.
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: 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**:
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.
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 (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 (as the Battleship plugin did).
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
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
+ * 🚧 The **clock step** a press collected (2026-10-13):
136
+ * `{ by, unit }` — a whole number other than zero, signed
137
+ * (back is negative), and one of the story-time units — for
138
+ * an action declaring `collects.clockStep`, picked on the
139
+ * collect modal's stepper and checked by the host before the
140
+ * run starts. Absent on a turn and on every press of an
141
+ * action that collects none. Core's *Time passes…* hands it
142
+ * to `core:task/clock-step@1`.
143
+ */
144
+ clockStep: S.json,
145
+ /**
146
+ * Values for the mode's declared `fields`, filtered to
147
+ * the declared schema keys — the supply side of the round
148
+ * trip: declaration → chat settings → chat row → this port →
149
+ * every downstream node.
150
+ */
151
+ fields: S.json,
152
+ /**
153
+ * Text an in-progress reply has already produced, when this turn
154
+ * is an **extend** (ruling 2026-09-08; the verb was `continue`
155
+ * until 2026-09-28).
156
+ *
157
+ * Empty on every other turn, which is nearly all of them. It is
158
+ * here rather than on an `extend`-only input type because an
159
+ * extend is the standard chat's own verb — it answers the same
160
+ * event, in the same session, from the same cast — and a second
161
+ * input type would restate this one's `sessionShape`, which is
162
+ * the thing `side-character-turn@1`'s note says a shape-bearing
163
+ * mode must never have copied.
164
+ *
165
+ * ⚠ It is not the triggering text and it is not a message. `text`
166
+ * stays what it would be on an ordinary turn, the row carrying
167
+ * this is excluded from every message read while it generates,
168
+ * and only `core:task/process-messages@1` consumes it — as the
169
+ * body of the seed line the model continues from.
170
+ */
171
+ continuationPrefill: S.text,
172
+ /**
173
+ * The reply row this turn re-drives, when it is a regenerate, a
174
+ * swipe or an extend of a message that already exists. Null on
175
+ * a fresh turn, which is nearly all of them.
176
+ *
177
+ * The pipeline owns its reply row: a fresh turn's row is
178
+ * created by the spec's own placeholder outlet, and a verb that
179
+ * re-drives an existing message hands that message to the same
180
+ * outlet through this port — so the outlet claims it as the
181
+ * run's live row instead of inserting a second one. It is data,
182
+ * recorded on the receipt, and never a scope read: "which row
183
+ * did this turn write" is answerable from the run afterwards.
184
+ */
185
+ messageId: S.rowIds,
186
+ /**
187
+ * What the built-ins did to this session since the last reply
188
+ * (2026-09-16): a list of session changes — `[{ event:
189
+ * 'core:event/message-deleted@1', messageId, at, lost }, …]`,
190
+ * oldest first, capped at the newest fifty — so a pipeline
191
+ * knows the history it is about to read has moved: a line
192
+ * deleted with its content, a rewrite with the previous text,
193
+ * an alternative swiped in, a reply stopped short. Read once:
194
+ * the run that receives them consumes them — marked read
195
+ * after the run, and only when it produced a reply, so a run
196
+ * that fails leaves them for the next — and a preview sees
197
+ * them without consuming. Empty when nothing changed, which
198
+ * is nearly every turn. Past fifty, the newest fifty arrive
199
+ * and a last entry `{ event:
200
+ * 'core:event/session-changes-truncated@1', dropped }` says
201
+ * how many older ones did not.
202
+ *
203
+ * Was `changes` until 2026-09-16: that word is
204
+ * the state ledger's on `resolve-state-changes@1` and
205
+ * `set-state@1` — a list of value changes — and a session
206
+ * change is about a message, never a value (one word, one meaning).
207
+ */
208
+ sessionChanges: S.json,
209
+ /**
210
+ * What an action's fire sent along
211
+ * (2026-09-17): a form's answer — `{ choice }` for a choices
212
+ * block, the entered values for a form block — or a widget's
213
+ * `invoke(key, args)` arguments. Absent on a turn and on a
214
+ * bare press. A press on an **addressed** block arrives with
215
+ * `form` beside it (`core:task/read-answer@1` takes both and
216
+ * publishes the answer port by port). The host always
217
+ * supplied this under `payload`; declared 2026-09-17 so a
218
+ * spec can wire it.
219
+ */
220
+ payload: S.json,
221
+ /**
222
+ * The form a press answered, when it answered one — the block
223
+ * itself as stored, its id, the message and the addressee,
224
+ * read off the row by the host (never off the client):
225
+ * `{ blockId, messageId, kind, question, addressee, characterId,
226
+ * choice?, label? }`. Absent on every other fire.
227
+ */
228
+ form: S.json,
229
+ /**
230
+ * Which channel the message that triggered this turn is on
231
+ * (2026-09-17) — the stored string, lane included:
232
+ * `main`, `manuscript`, `phone:3`.
233
+ *
234
+ * `main` when the trigger named none, which is every session
235
+ * whose genre declares no channel of its own. It is never a
236
+ * selector: `*` spans every channel for a *read* and is not
237
+ * somewhere a message can be, so it never appears here.
238
+ *
239
+ * ⚠ The run had no way to ask this before, and that is what
240
+ * kept a channel's declared `voice` half-wired: `voice: 'none'`
241
+ * could be read off the newest row, but `voice: 'narrator'`
242
+ * needs the channel the turn was triggered on even when that
243
+ * channel has no rows yet. It is a port rather than a scope
244
+ * read for the other half of the same reason — a genre that
245
+ * answers the manuscript differently from the conversation
246
+ * branches on it at a junction, and a junction can only read
247
+ * what a port carries.
248
+ */
249
+ /**
250
+ * The session's **settings document**:
251
+ * every setting a person can see in session settings,
252
+ * resolved once per run by the host and handed in here —
253
+ * title, guests, genre fields (cascade applied),
254
+ * scenario, lorebook, tags, channels, the cast with its
255
+ * envoys, the session-scope rebinds and param overrides per
256
+ * bound spec, the turn-order state, `metadata` (read-only)
257
+ * and the annex. `$.input.session.fields.tone` reads in any
258
+ * spec, and no node re-queries a table for a setting.
259
+ */
260
+ session: S.sessionSettings,
261
+ channel: S.text,
262
+ /**
263
+ * **How this turn was reached** (2026-09-28) —
264
+ * the fired turn entry's `via`: `strategy`, `script` or
265
+ * `voice` for a prepared turn, `pick` for one a person chose,
266
+ * and **`narrate`** when the press was the `core#narrate` turn
267
+ * control (the genre's own voice asked to narrate what happens
268
+ * next). A verb re-driving a row carries the `via` of the run
269
+ * that created it, so a regenerated narration narrates again.
270
+ * Empty when nothing says (an action's fire). A genre routes
271
+ * on it at a junction — the Lair narrates on `narrate` ahead
272
+ * of every other branch.
273
+ */
274
+ via: S.text,
275
+ },
276
+ },
277
+ }));
278
+ /**
279
+ * A built-in write's request (2026-09-16) — what a person asked core to
280
+ * do to a message or a session: delete, hide, edit, swipe, branch.
281
+ *
282
+ * Core implements every state-altering write and runs each as its own
283
+ * one-node spec (`core:spec/builtin-delete` …) through the executor, so the
284
+ * write is receipted, gate-eligible and always emits what changed. This is
285
+ * that spec's inlet: the person's request, as the venue's handler shaped it
286
+ * after the permission checks it alone can make. No lock — a built-in serves
287
+ * every genre — and no shape: a request is not a session mode.
288
+ * @internal
289
+ */
290
+ export const builtInRequest = pin(describeInletDefinition({
291
+ id: 'core:inlet/built-in-request@1',
292
+ ports: {
293
+ out: {
294
+ main: S.json,
295
+ sessionScope: S.sessionScope,
296
+ sessionId: S.rowIds,
297
+ /** The message the write is about. Absent on a branch. */
298
+ target: S.rowIds,
299
+ /** An edit's new text; a swipe's alternative to record. */
300
+ text: S.text,
301
+ /** A hide's direction: hidden, or shown again. */
302
+ hidden: S.json,
303
+ /** A swipe's alternative to select, by index. */
304
+ index: S.json,
305
+ /** A branch's fork point — the last message the copy keeps. */
306
+ fromMessage: S.rowIds,
307
+ /**
308
+ * The session's **settings document**:
309
+ * every setting a person can see in session settings,
310
+ * resolved once per run by the host and handed in here —
311
+ * title, guests, genre fields (cascade applied),
312
+ * scenario, lorebook, tags, channels, the cast with its
313
+ * envoys, the session-scope rebinds and param overrides per
314
+ * bound spec, the turn-order state, `metadata` (read-only)
315
+ * and the annex. `$.input.session.fields.tone` reads in any
316
+ * spec, and no node re-queries a table for a setting.
317
+ */
318
+ session: S.sessionSettings,
319
+ /** A branch's name. */
320
+ title: S.text,
321
+ /**
322
+ * A person's sprite for the line: `{ set, label }`, or null to
323
+ * clear it — a `sprite-pick@1`, the shape a
324
+ * picker publishes, so `core:outlet/show-sprite@1` takes one
325
+ * shape from both. Read by `core:spec/show-sprite`.
326
+ */
327
+ sprite: S.spritePick,
328
+ },
329
+ },
330
+ }));
331
+ // `core:inlet/message-created@1` stood here — an inlet no spec used and no
332
+ // event emitted (plans/29 §4c 4.1). Culled 2026-09-16 (R-4): an existing
333
+ // message's id arrives on `core:inlet/user-message@1`'s `messageId` port.
334
+ /**
335
+ * A session was just created — the create pipeline's trigger.
336
+ *
337
+ * The genre's one required pipeline answers this event and seeds the
338
+ * session's initial data: greetings per the genre's shape, initial channels,
339
+ * initial state. The payload is the create request itself — the genre, the
340
+ * chosen preset, the participants and initial field values — because what a
341
+ * create pipeline does is *finish* what the request began.
342
+ *
343
+ * Not `user-message`: reusing the turn input here welded creation to the
344
+ * chat turn's shape and was wrong. A create run has no triggering
345
+ * text and no speaker; it has a request.
346
+ * @public
347
+ */
348
+ export const sessionCreated = pin(describeInletDefinition({
349
+ id: 'core:inlet/session-created@1',
350
+ i18n: {
351
+ name: { en: 'Session created' },
352
+ description: {
353
+ en: 'Fires once, when a session of this genre is created — the pipeline that answers it seeds greetings, channels and initial state.',
354
+ },
355
+ },
356
+ ports: {
357
+ out: {
358
+ main: S.json,
359
+ sessionScope: S.sessionScope,
360
+ sessionId: S.rowIds,
361
+ /**
362
+ * The create request: genre id, preset id, participant ids,
363
+ * lorebook, initial field values — everything the person chose
364
+ * before the session existed.
365
+ */
366
+ request: S.json,
367
+ /**
368
+ * The session's **settings document**:
369
+ * every setting a person can see in session settings,
370
+ * resolved once per run by the host and handed in here —
371
+ * title, guests, genre fields (cascade applied),
372
+ * scenario, lorebook, tags, channels, the cast with its
373
+ * envoys, the session-scope rebinds and param overrides per
374
+ * bound spec, the turn-order state, `metadata` (read-only)
375
+ * and the annex. `$.input.session.fields.tone` reads in any
376
+ * spec, and no node re-queries a table for a setting.
377
+ */
378
+ session: S.sessionSettings,
379
+ /** Values for the genre's declared fields, filtered to the schema. */
380
+ fields: S.json,
381
+ },
382
+ },
383
+ }));
384
+ /**
385
+ * A session event happened: the inlet every
386
+ * event-driven spec enters through, and the one core's turn-order spec
387
+ * uses.
388
+ *
389
+ * Locked over **several** events at once — `.inlet(key, node, { genre,
390
+ * events: [...] })` — because one spec answers nine of them identically:
391
+ * a send, an edit, a delete, a hide, a member change, a cast change, a
392
+ * settings save, a branch. A spec bound to N events has N binding rows and
393
+ * one document.
394
+ *
395
+ * `cause` is why it fired (`EventCause`: user · run · edit · settings ·
396
+ * system), and it is load-bearing beyond this node — the write this spec
397
+ * ends in carries it into `turn-order-changed`, where the auto-advance
398
+ * listener reads it to decide whether to fire the head turn. A spec
399
+ * that drops it makes every recompute look like a system event.
400
+ * @experimental
401
+ */
402
+ export const sessionEvent = pin(describeInletDefinition({
403
+ id: 'core:inlet/session-event@1',
404
+ i18n: {
405
+ name: { en: 'Session event' },
406
+ description: {
407
+ 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.',
408
+ },
409
+ },
410
+ /**
411
+ * The event payloads this inlet reads: a spec may lock it to several
412
+ * events only when every one carries one of these. A session change, a
413
+ * cast change (member-added/-removed included), an annex change, and
414
+ * the envelope every event a package declared arrives in — its own
415
+ * payload is the envelope's `payload`.
416
+ */
417
+ payloads: [S.sessionChange, S.castChange, S.annexChange, S.recordedEvent],
418
+ ports: {
419
+ out: {
420
+ /** The event id that fired — `core:event/message-completed@1`. */
421
+ event: S.text,
422
+ sessionId: S.rowIds,
423
+ /** The event's own payload, as its registry entry's shape declares it. */
424
+ payload: S.json,
425
+ /** Why it fired (`EventCause`). Carried through to the write. */
426
+ cause: S.json,
427
+ /** When, as epoch milliseconds — what an order `basedOnAt` answers. */
428
+ at: S.json,
429
+ sessionScope: S.sessionScope,
430
+ /**
431
+ * The session's **settings document**, resolved
432
+ * once per run by the host after the write that caused this
433
+ * event — so the cast below is the cast as it is now, and no
434
+ * node needs a cast read of its own.
435
+ */
436
+ session: S.sessionSettings,
437
+ /**
438
+ * The settings document's **cast**, on its own port:
439
+ * what `core:query/session-cast@1` publishes,
440
+ * envoys included, projected from `session` by the host.
441
+ *
442
+ * A port rather than a path, because an edge is `{ node,
443
+ * port }` and nothing in the graph addresses a field inside
444
+ * a port's value. Core's turn-order spec wires the pool's `cast` from the
445
+ * document; this is that wire, with the shape the pool's
446
+ * in-port declares.
447
+ */
448
+ cast: S.sessionCast,
449
+ },
450
+ },
451
+ }));
452
+ /**
453
+ * Who is about to speak, when the trigger picked somebody who is **not** in
454
+ * the cast — the side-character narration turn (ruling 2026-09-07).
455
+ *
456
+ * ## participant ≠ character
457
+ *
458
+ * A side character is a **participant without a turn slot**. The trigger's
459
+ * first step accepts either an existing character (`characterId`) or a name
460
+ * somebody typed (`speakerName` alone), and both are full participants *for
461
+ * that turn* — the prompt is written from their perspective and the seed line
462
+ * carries their name. Neither joins the session cast, and nothing here writes
463
+ * a `session_characters` row: this input publishes a fact about one turn, and
464
+ * a fact is not a membership.
465
+ *
466
+ * Its own type rather than a flag on `user-message@1`, for the reason that type
467
+ * already gives about the narrator: the type is the unit that declares a
468
+ * configurable surface, and `user-message` is the standard chat's **mode** —
469
+ * it carries the genre's `sessionShape`, which is exactly what a side-character
470
+ * turn must not restate. This one declares no shape, so it is an action input
471
+ * and never a session mode.
472
+ *
473
+ * ## The new-name hook (the fact, and only the fact)
474
+ *
475
+ * `sideCharacter` carries `known` — whether the chosen name matches anything in
476
+ * the session's lorebook — and the scripts hook below declares it as an **extra**,
477
+ * so a script attached there reads it through the one dispatch core scripts and
478
+ * extension hooks already share. Core states the fact and offers the hook; what
479
+ * a script *does* about an unknown name (suggest adding them, stay quiet, add a
480
+ * note to the prompt) is the script's business, not this declaration's. There is
481
+ * deliberately no second path: nothing here notifies, writes, or prompts.
482
+ * @experimental
483
+ */
484
+ export const sideCharacterTurn = pin(describeInletDefinition({
485
+ id: 'core:inlet/side-character-turn@1',
486
+ // Display only, both keys: stripped from the content hash, refreshed on
487
+ // existing rows by the boot sync — so copyediting this is never a bump.
488
+ i18n: {
489
+ name: { en: 'Side character' },
490
+ description: {
491
+ 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.',
492
+ },
493
+ },
494
+ slots: {
495
+ /**
496
+ * The input hook, on the same terms as `user-message@1`:
497
+ * user chains over the triggering text, phase `after` on what this
498
+ * node publishes, which is what retrieval and the prompt see.
499
+ *
500
+ * ⚠ `extras` is what makes this the **new-name hook**. The three
501
+ * names below are read-only context supplied by the host at the
502
+ * hook and are part of the fixed choice set the script
503
+ * editor offers — so "this name is new" is a declared read rather
504
+ * than a name typed on faith. `speakerIsKnown` is `false` exactly
505
+ * when a free-form name matched nothing in the session's lorebook.
506
+ */
507
+ scripts: {
508
+ kind: 'scripts',
509
+ accepts: ['core:script:text/transform@1'],
510
+ port: 'text',
511
+ phase: 'after',
512
+ extras: ['speakerName', 'speakerCharacterId', 'speakerIsKnown', 'castNames'],
513
+ 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.',
514
+ },
515
+ },
516
+ ports: {
517
+ out: {
518
+ main: S.json,
519
+ text: S.text,
520
+ sessionScope: S.sessionScope,
521
+ sessionId: S.rowIds,
522
+ /**
523
+ * Who is speaking, as a **participant reference**:
524
+ * `character:<id>` when the pick was a library character, null
525
+ * for a free-form name — a name is not a participant reference,
526
+ * and the fact below is where the name lives. On the same
527
+ * terms as `user-message@1`'s port of this name.
528
+ */
529
+ speaker: S.participantRef,
530
+ /**
531
+ * @deprecated The chosen character as a bare id, or null for a
532
+ * free-form name (one release, from 2026-09-16) — read
533
+ * `speaker`.
534
+ *
535
+ * ⚠ It is **not** a turn slot. It reaches character lore's
536
+ * visibility rule (an entry bound to this character becomes
537
+ * readable for this turn) and the prompt's perspective, and
538
+ * nothing else — round-robin selection reads the session's
539
+ * cast and its messages, neither of which this touches.
540
+ */
541
+ characterId: S.rowIds,
542
+ /**
543
+ * The side character as a whole fact: `{ name, characterId,
544
+ * known, character }`.
545
+ *
546
+ * A port rather than only an extra, because it is what the
547
+ * context builder is wired to and what the receipt records —
548
+ * "why did this turn sound like Vell" is answerable from the
549
+ * run afterwards rather than from the trigger that started it.
550
+ *
551
+ * Was `speaker` until 2026-09-16: that name is the participant
552
+ * reference now (one word, one meaning), and a fact
553
+ * carrying a free-form name is not a reference to anybody.
554
+ */
555
+ sideCharacter: S.json,
556
+ /**
557
+ * The session's **settings document**:
558
+ * every setting a person can see in session settings,
559
+ * resolved once per run by the host and handed in here —
560
+ * title, guests, genre fields (cascade applied),
561
+ * scenario, lorebook, tags, channels, the cast with its
562
+ * envoys, the session-scope rebinds and param overrides per
563
+ * bound spec, the turn-order state, `metadata` (read-only)
564
+ * and the annex. `$.input.session.fields.tone` reads in any
565
+ * spec, and no node re-queries a table for a setting.
566
+ */
567
+ session: S.sessionSettings,
568
+ /** Values for the genre's declared fields, filtered to the schema. */
569
+ fields: S.json,
570
+ /**
571
+ * The row this turn re-drives, on the same terms as
572
+ * `user-message@1`'s port of the same name: a regenerate, swipe
573
+ * or extend of a side character's line routes back to the
574
+ * narrate-character spec, and its placeholder claims the verb's
575
+ * row through this instead of inserting a second one. Null on
576
+ * a fresh turn.
577
+ */
578
+ messageId: S.rowIds,
579
+ /**
580
+ * The built-ins' session changes since the last reply, on the
581
+ * same terms as `user-message@1`'s port of this name (was
582
+ * `changes` until 2026-09-16).
583
+ */
584
+ sessionChanges: S.json,
585
+ },
586
+ },
587
+ }));
588
+ // ── Forms (plans/29 R-15 *Forms* · *The line*; R-21 (5); 30 §U5d, 2026-09-17) ──
589
+ //
590
+ // A **form** is an action still awaiting its answer: a `choices` or `form`
591
+ // block a message carries, addressed to a participant. A person portraying
592
+ // the addressee answers by clicking; when the host's resolver says the AI
593
+ // portrays them this turn, core records `core:event/form-addressed@1` and the
594
+ // genre's answer pipeline runs — the four definitions below are its parts:
595
+ // the inlet the event lands on, the task that turns the form into a prompt
596
+ // context and a JSON Schema, the oracle (`generate-json@1`, already declared)
597
+ // that answers against the schema, and the outlet that commits the answer
598
+ // **exactly as a click would**. `make-choices@1` is the other direction: how
599
+ // a spec turns an oracle's JSON into a question with options; `read-answer@1`
600
+ // is how the action a form fires reads the answer port by port.
601
+ /**
602
+ * A form was addressed to a participant the AI portrays — the answer
603
+ * pipeline's trigger. The payload is `core:shape/form-addressed@1`; the
604
+ * ports below are it taken apart, with the block itself (`form`) and the
605
+ * addressee's character id (`characterId`, null for an envoy) beside them so
606
+ * the context builder can compile the addressee's card the way it compiles a
607
+ * speaker's. No shape — an event's inlet is never a session mode — and no
608
+ * lock here: the genre's answer spec declares its own `(genre, event)`.
609
+ * @experimental
610
+ */
611
+ export const formAddressed = pin(describeInletDefinition({
612
+ id: 'core:inlet/form-addressed@1',
613
+ i18n: {
614
+ name: { en: 'Form addressed' },
615
+ description: {
616
+ 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.',
617
+ },
618
+ },
619
+ ports: {
620
+ out: {
621
+ main: S.formAddressed,
622
+ sessionScope: S.sessionScope,
623
+ sessionId: S.rowIds,
624
+ /**
625
+ * The session's **settings document**:
626
+ * every setting a person can see in session settings,
627
+ * resolved once per run by the host and handed in here —
628
+ * title, guests, genre fields (cascade applied),
629
+ * scenario, lorebook, tags, channels, the cast with its
630
+ * envoys, the session-scope rebinds and param overrides per
631
+ * bound spec, the turn-order state, `metadata` (read-only)
632
+ * and the annex. `$.input.session.fields.tone` reads in any
633
+ * spec, and no node re-queries a table for a setting.
634
+ */
635
+ session: S.sessionSettings,
636
+ /** The message carrying the block. */
637
+ messageId: S.rowIds,
638
+ /** The block's id within the message. */
639
+ blockId: S.text,
640
+ /** The block itself — a `choices` or `form` `MessageBlock`, as stored. */
641
+ form: S.json,
642
+ /** The identity of the action the form answers with — `<spec slug>#<key>`. */
643
+ action: S.text,
644
+ /** Who the form is put to, as a participant reference the resolver answered `ai` for. */
645
+ addressee: S.participantRef,
646
+ /** The addressee's character row, for the context builder; null for an envoy. */
647
+ characterId: S.rowIds,
648
+ /** Values for the genre's declared fields, as on a turn. */
649
+ fields: S.json,
650
+ },
651
+ },
652
+ }));
653
+ // ── Summarization ───────────────────────────────────────────────────────────
654
+ //
655
+ // Two phases, and the split is the whole design (see `utils/summarizer`):
656
+ // messages are cut into token-sized batches and each is drafted **on its own**,
657
+ // then the ordered drafts are merged into one narrative. Drafting a batch in
658
+ // isolation is what keeps a long chat summarizable at all — the model never
659
+ // sees more than one batch — and it is why the batch step is a `map` rather
660
+ // than a loop: the batches do not depend on each other, so nothing forces them
661
+ // to be sequential except the connection's own queue.
662
+ //
663
+ // Each step is its own Provider because each has its own prompt, connection and
664
+ // sampling config in the tables this replaces. That was already true; it was
665
+ // just spelled as `batch_system_prompt` / `synth_connection_id` columns rather
666
+ // than as nodes.
667
+ /** @internal */
668
+ export const summarizeRequest = pin(describeInletDefinition({
669
+ id: 'core:inlet/summarize-request@1',
670
+ ports: {
671
+ out: {
672
+ main: S.summarizeRequest,
673
+ scope: S.sessionScope,
674
+ /**
675
+ * The session's **settings document**:
676
+ * every setting a person can see in session settings,
677
+ * resolved once per run by the host and handed in here —
678
+ * title, guests, genre fields (cascade applied),
679
+ * scenario, lorebook, tags, channels, the cast with its
680
+ * envoys, the session-scope rebinds and param overrides per
681
+ * bound spec, the turn-order state, `metadata` (read-only)
682
+ * and the annex. `$.input.session.fields.tone` reads in any
683
+ * spec, and no node re-queries a table for a setting.
684
+ */
685
+ session: S.sessionSettings,
686
+ request: S.summarizeRequest,
687
+ },
688
+ },
689
+ }));
690
+ // ── A card's own action (image generation I5, 2026-10-12) ──────────────────
691
+ /**
692
+ * 🚧 A person pressed an action on a **card** — the Characters view, not a
693
+ * session: *Fill empty sprites* on the
694
+ * Sprites tab, and *Generate portrait* on the Gallery tab (`count`, widened
695
+ * in place 2026-10-12).
696
+ *
697
+ * ## No session
698
+ *
699
+ * A card action runs with no session in scope: nothing here is a session's,
700
+ * no live row is filled, no session event is written. The host checks the
701
+ * person may act on the card (its owner, or an admin) before the run starts,
702
+ * and resolves the card ONCE, here — its likeness as text and as the
703
+ * reference image — so no node re-reads the character for a setting.
704
+ *
705
+ * ## The form's answers
706
+ *
707
+ * `fields` is the whole of what the action's form collected. The fields a
708
+ * core action asks are also their own ports (`setName`, `labels`) because a
709
+ * data edge addresses a port, never a field inside one; another card action
710
+ * widens this in place with its own, every one optional.
711
+ *
712
+ * No lock and no shape: a card action is not a session mode, and no genre
713
+ * owns a card.
714
+ * @experimental
715
+ */
716
+ export const cardAction = pin(describeInletDefinition({
717
+ id: 'core:inlet/card-action@1',
718
+ ports: {
719
+ out: {
720
+ main: S.json,
721
+ /** The card the action was pressed on. */
722
+ characterId: S.rowIds,
723
+ /** The card's likeness prompt — its look as a tag line; empty when unset. */
724
+ likeness: S.text,
725
+ /** The card's likeness negative; empty when unset. */
726
+ likenessNegative: S.text,
727
+ /**
728
+ * The likeness image as a one-item media list (the likeness
729
+ * image, else the avatar); empty when the card has neither.
730
+ * What a picture step's `references` port takes.
731
+ */
732
+ likenessImage: S.mediaList,
733
+ /** The form's answers, whole. */
734
+ fields: S.json,
735
+ /** Sprite set fill: the sprite set to fill, by name. */
736
+ setName: S.text,
737
+ /** Sprite set fill: the sprite labels to draw. */
738
+ labels: S.json,
739
+ /** 🚧 Portrait: how many pictures to offer (a whole number, 1–4 on the form). */
740
+ count: S.json,
741
+ },
742
+ },
743
+ }));
744
+ //# sourceMappingURL=inlets.js.map