@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/index.d.ts +9 -10588
- package/dist/index.js +9 -10233
- package/dist/inlets.d.ts +566 -0
- package/dist/inlets.js +679 -0
- package/dist/oracles.d.ts +1246 -0
- package/dist/oracles.js +1386 -0
- package/dist/outlets.d.ts +990 -0
- package/dist/outlets.js +1085 -0
- package/dist/queries.d.ts +3318 -0
- package/dist/queries.js +3175 -0
- package/dist/tasks.d.ts +4544 -0
- package/dist/tasks.js +4011 -0
- package/package.json +9 -4
package/dist/outlets.js
ADDED
|
@@ -0,0 +1,1085 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Core's **outlet** node definitions — writes, attaches, emits: where a run leaves
|
|
3
|
+
* into the world.
|
|
4
|
+
*
|
|
5
|
+
* One file per node kind, with the helpers only that kind uses; `index.ts`
|
|
6
|
+
* re-exports them all.
|
|
7
|
+
*/
|
|
8
|
+
import { S } from '@serene-pub/sdk';
|
|
9
|
+
import { describeOutletDefinition, pin } from '@serene-pub/sdk';
|
|
10
|
+
/**
|
|
11
|
+
* An author defaulting review ON for their own consumer — and unable to forbid it (F14).
|
|
12
|
+
*
|
|
13
|
+
* Bound 2026-09-17 (plans/29 R-2): the host's commit for it existed and no
|
|
14
|
+
* binding reached it. `target` is the row the part lands on — the same port
|
|
15
|
+
* `update-message` takes, fed from an earlier write in the document (the reply's
|
|
16
|
+
* placeholder, R-17) or from the inlet's `messageId`. An update whose target is
|
|
17
|
+
* an earlier write is the same row, so placing this after `create-message` is
|
|
18
|
+
* one live row, not two (F7). The host reads the id off `target`, or off the
|
|
19
|
+
* media reference's own `messageId` where a caller outside the graph set one.
|
|
20
|
+
* @experimental
|
|
21
|
+
*/
|
|
22
|
+
export const attachImage = pin(describeOutletDefinition({
|
|
23
|
+
id: 'core:outlet/attach-image@1',
|
|
24
|
+
effects: 'write',
|
|
25
|
+
/** The image is a reference to an asset this run rendered; nothing to retype (R-15 review fields). */
|
|
26
|
+
review: { fields: [] },
|
|
27
|
+
timeoutMs: 5000,
|
|
28
|
+
reviewDefault: 'on',
|
|
29
|
+
causesEvent: 'core:event/message-updated@1',
|
|
30
|
+
ports: { in: { target: S.rowIds, image: S.image }, out: { main: S.writeResult } },
|
|
31
|
+
}));
|
|
32
|
+
/**
|
|
33
|
+
* The create pipeline's write (24 §12, T8): seed the collected greetings as
|
|
34
|
+
* the session's first messages — one assistant message per entry, the full
|
|
35
|
+
* list as its swipe history, redirected to the genre's declared greeting
|
|
36
|
+
* channel when that is not `main`.
|
|
37
|
+
* @experimental
|
|
38
|
+
*/
|
|
39
|
+
export const seedGreetings = pin(describeOutletDefinition({
|
|
40
|
+
id: 'core:outlet/seed-greetings@1',
|
|
41
|
+
effects: 'write',
|
|
42
|
+
/** The greetings are the cards' own text and the channel the genre's: approve or refuse (R-15 review fields). */
|
|
43
|
+
review: { fields: [] },
|
|
44
|
+
timeoutMs: 5000,
|
|
45
|
+
causesEvent: 'core:event/message-created@1',
|
|
46
|
+
ports: {
|
|
47
|
+
in: {
|
|
48
|
+
greetings: S.json,
|
|
49
|
+
/**
|
|
50
|
+
* The channel the greetings land on (20 §7) — the genre's
|
|
51
|
+
* declared greeting channel, written by the create specs as a
|
|
52
|
+
* literal (`createChat.ts`, `adventure.ts`). Absent is `main`.
|
|
53
|
+
* Declared 2026-09-16 (U2 residual): the host read it off the
|
|
54
|
+
* payload while no declaration supplied it.
|
|
55
|
+
*/
|
|
56
|
+
channel: S.text,
|
|
57
|
+
},
|
|
58
|
+
out: { main: S.writeResult, messageIds: S.writeResult },
|
|
59
|
+
},
|
|
60
|
+
}));
|
|
61
|
+
/**
|
|
62
|
+
* Write a message — complete, or as the run's **placeholder** (R-17).
|
|
63
|
+
*
|
|
64
|
+
* A pipeline that wants a message creates it itself. The reply specs put this
|
|
65
|
+
* node straight after the inlet with `generating: true`: the row it inserts is
|
|
66
|
+
* empty and generating, it is the run's live row (`liveRow` — an oracle's
|
|
67
|
+
* stream lands in it, and Stop finalises it), and the spec's last node is an
|
|
68
|
+
* `update-message` that fills it. That create → update pair on one row inside
|
|
69
|
+
* one run is the run's **one live row** (F7). Without `generating` (or a
|
|
70
|
+
* claimed `row`) the message is complete, and an ordinary write — a pipeline
|
|
71
|
+
* may write as many as it likes, just never a second on the live row's
|
|
72
|
+
* channel. `message-created` fires on the create, which is now genuinely the
|
|
73
|
+
* moment the row exists.
|
|
74
|
+
*
|
|
75
|
+
* `reviewDefault: 'off'` — review of a reply, when an admin enables it, lands
|
|
76
|
+
* on the *update* of the primary row and never on this create by default
|
|
77
|
+
* (R-21 (3)): a placeholder is a write, and an admin who gates this node gets
|
|
78
|
+
* a run that shows nothing until approved, which is honest and rarely wanted.
|
|
79
|
+
* Turning it on is still the admin's to do.
|
|
80
|
+
* @public
|
|
81
|
+
*/
|
|
82
|
+
export const createMessage = pin(describeOutletDefinition({
|
|
83
|
+
id: 'core:outlet/create-message@1',
|
|
84
|
+
effects: 'write',
|
|
85
|
+
/** The text may be reviewed; who speaks, which row and which channel are the run's identity (R-15 review fields). */
|
|
86
|
+
review: { fields: ['text'] },
|
|
87
|
+
reviewDefault: 'off',
|
|
88
|
+
liveRow: true,
|
|
89
|
+
timeoutMs: 5000,
|
|
90
|
+
causesEvent: 'core:event/message-created@1',
|
|
91
|
+
slots: {
|
|
92
|
+
/**
|
|
93
|
+
* The write hook (18 §4a): one chain rewrites the final output, the
|
|
94
|
+
* other decides where a streamed reply stops. Stop is a verdict —
|
|
95
|
+
* min-reduction across every attached script, and the connection's
|
|
96
|
+
* own guards join the same union at dispatch (18 §4b), which is why
|
|
97
|
+
* order never needs ruling. `speakerName` and `castNames` are
|
|
98
|
+
* extras: readable, never writable, by construction (18 §6a).
|
|
99
|
+
*/
|
|
100
|
+
scripts: {
|
|
101
|
+
kind: 'scripts',
|
|
102
|
+
accepts: ['core:script:text/transform@1', 'core:script:text/stop@1'],
|
|
103
|
+
port: 'text',
|
|
104
|
+
phase: 'before',
|
|
105
|
+
extras: ['speakerName', 'castNames'],
|
|
106
|
+
description: 'Scripts over the reply as it is saved — clean up the text, or stop a streaming reply early.',
|
|
107
|
+
},
|
|
108
|
+
},
|
|
109
|
+
ports: {
|
|
110
|
+
in: {
|
|
111
|
+
text: S.text,
|
|
112
|
+
/**
|
|
113
|
+
* Media to post WITH the message, as references.
|
|
114
|
+
*
|
|
115
|
+
* Posting an image as a NEW message is one write, not a create
|
|
116
|
+
* followed by an `attach-image`: the answer is the same one
|
|
117
|
+
* streaming got — one node with a settled output, not two nodes
|
|
118
|
+
* and a hope. The write that creates the message is the write
|
|
119
|
+
* that attaches its images.
|
|
120
|
+
*/
|
|
121
|
+
media: S.mediaList,
|
|
122
|
+
/**
|
|
123
|
+
* Who is speaking, as a cast row — the inlet's `characterId`.
|
|
124
|
+
* Null or absent means nobody in particular: narration, or a
|
|
125
|
+
* message no character voices.
|
|
126
|
+
*/
|
|
127
|
+
characterId: S.rowIds,
|
|
128
|
+
/**
|
|
129
|
+
* The participant voicing this message when they are **not** a
|
|
130
|
+
* cast row — the side-character fact `{ name, characterId, known }`
|
|
131
|
+
* off `side-character-turn@1`'s `sideCharacter` port. Stored
|
|
132
|
+
* beside the message under `metadata.sideCharacter` (was
|
|
133
|
+
* `metadata.speaker` until U5g, 2026-09-16 — that key is the
|
|
134
|
+
* participant reference now, on the row as on the inlet, R1),
|
|
135
|
+
* where the run and the receipt read it from; it never writes a
|
|
136
|
+
* cast row and never enters the rotation.
|
|
137
|
+
*
|
|
138
|
+
* Was `speaker` until 2026-09-16 — the inlet's port of that
|
|
139
|
+
* name is a participant reference now (R-18 (3)).
|
|
140
|
+
*/
|
|
141
|
+
sideCharacter: S.json,
|
|
142
|
+
/**
|
|
143
|
+
* Who is speaking, as a **participant reference** (R-18 (3);
|
|
144
|
+
* U5g, 2026-09-16) — `character:<id>` or `envoy:<slug>`, the
|
|
145
|
+
* inlet's `speaker`. Stored beside the message as
|
|
146
|
+
* `metadata.speaker`; it is the only identity an envoy's turn
|
|
147
|
+
* carries, since an envoy has no row for `characterId` to name.
|
|
148
|
+
* Optional: a spec that wires only `characterId` writes the row
|
|
149
|
+
* it always wrote.
|
|
150
|
+
*/
|
|
151
|
+
speaker: S.participantRef,
|
|
152
|
+
/**
|
|
153
|
+
* Create the row as a **placeholder**: empty, generating, and the
|
|
154
|
+
* run's live row — filled by a later `update-message`, or
|
|
155
|
+
* finalised by core if the run stops first.
|
|
156
|
+
*
|
|
157
|
+
* A port, not a parameter, and the call site is what decides:
|
|
158
|
+
* the reply specs write `generating: true` as a literal into the
|
|
159
|
+
* node's config, in the same map as `text`, and `resolveInput`
|
|
160
|
+
* passes it through untouched — so the binding reads it exactly
|
|
161
|
+
* the way it reads a port (see `summarize-batch`'s `loreType`
|
|
162
|
+
* for the same reasoning at length). A `params` field would put
|
|
163
|
+
* a structural fact of the document in the panel as a knob.
|
|
164
|
+
*/
|
|
165
|
+
generating: S.json,
|
|
166
|
+
/**
|
|
167
|
+
* The message is **narration** — not a character's turn. Shown
|
|
168
|
+
* under the narrator's name, never counted by the rotation. A
|
|
169
|
+
* literal, on the same terms as `generating`. The name is the
|
|
170
|
+
* session's narrator name, or the `speaker`'s where one was
|
|
171
|
+
* named; the host resolves it at the write, which is where the
|
|
172
|
+
* row is.
|
|
173
|
+
*/
|
|
174
|
+
narration: S.json,
|
|
175
|
+
/**
|
|
176
|
+
* Instructions this message was asked for — a narrator's focus
|
|
177
|
+
* note. Stored beside the message and shown with it; never its
|
|
178
|
+
* text. Wired from the inlet's `text` on the narrate specs, which
|
|
179
|
+
* is what a narrator turn's triggering text is.
|
|
180
|
+
*/
|
|
181
|
+
instructions: S.text,
|
|
182
|
+
/**
|
|
183
|
+
* The channel the row lands on (20 §7). Absent is `main`, so a
|
|
184
|
+
* pipeline that has never heard of channels writes where it
|
|
185
|
+
* always did; a channel the session's genre never declared is
|
|
186
|
+
* refused at the write. Declared 2026-09-16 (U2 residual) for
|
|
187
|
+
* the same reason `seed-greetings` declares its own.
|
|
188
|
+
*/
|
|
189
|
+
channel: S.text,
|
|
190
|
+
/**
|
|
191
|
+
* An existing message row to take as the placeholder instead of
|
|
192
|
+
* inserting one — the inlet's `messageId` on a regenerate, swipe
|
|
193
|
+
* or extend. The row is reset to generating and becomes the
|
|
194
|
+
* run's live row; its text and swipe history stay as the verb
|
|
195
|
+
* left them. Absent on a fresh turn, which inserts.
|
|
196
|
+
*/
|
|
197
|
+
row: S.rowIds,
|
|
198
|
+
/**
|
|
199
|
+
* Message **blocks** to post with the row (20 §6; R-15
|
|
200
|
+
* *Forms*; U5d, 2026-09-17): a list of `MessageBlock` — text,
|
|
201
|
+
* tables, meters, and the two interactive kinds, `choices` and
|
|
202
|
+
* `form`, which are **forms** when they carry an `addressee`.
|
|
203
|
+
* The host validates the tree (`checkMessageBlocks`), refuses
|
|
204
|
+
* a block naming a function this spec declares no action for
|
|
205
|
+
* or one whose action is `world` (the effects line), stamps
|
|
206
|
+
* each form with the writing spec's action identity and an
|
|
207
|
+
* id, stores them as a `core:blocks` part, and — for a form
|
|
208
|
+
* whose addressee the run's pinned portrayals say the AI
|
|
209
|
+
* portrays — records `core:event/form-addressed@1` for the
|
|
210
|
+
* genre's answer pipeline once this run's receipt is saved.
|
|
211
|
+
* Absent on nearly every message.
|
|
212
|
+
*/
|
|
213
|
+
blocks: S.json,
|
|
214
|
+
/**
|
|
215
|
+
* **Folded sections** to show collapsed beside the text — a
|
|
216
|
+
* narrator's Plan, a step's notes (`FoldedSectionV1[]`: each
|
|
217
|
+
* `{ kind, label, content }` or `{ kind, label, items }`; at
|
|
218
|
+
* most `MAX_FOLDED_SECTIONS`). Stored with the row as
|
|
219
|
+
* `core:section` parts above the body; never the text, and
|
|
220
|
+
* never read into the prompt transcript. A malformed section
|
|
221
|
+
* is refused by position. Absent on nearly every message.
|
|
222
|
+
*/
|
|
223
|
+
sections: S.foldedSections,
|
|
224
|
+
/**
|
|
225
|
+
* 🚧 The **turn plan** this row carries (Lair character turns,
|
|
226
|
+
* owner ruling 2026-09-30): `{ plan, locationPassage? }`, where
|
|
227
|
+
* `plan` is a planner's document whose `speakers` (side-character
|
|
228
|
+
* facts — `{ name, intent }` or `{ characterId }`) name who takes
|
|
229
|
+
* a **character turn** next, in order, and `locationPassage` is
|
|
230
|
+
* prose that describes the room they are heading into. The host
|
|
231
|
+
* resolves each speaker to a seated cast member and stores the
|
|
232
|
+
* whole as `metadata.turnPlan` (`{ turns, plan, locationPassage? }`,
|
|
233
|
+
* `turns` the participant references in order). A turn-order
|
|
234
|
+
* strategy reads the **standing plan** off the history and
|
|
235
|
+
* prepares one entry per turn not yet taken (`via: 'plan'`); each
|
|
236
|
+
* character turn reads it back through `core:query/turn-plan@1`.
|
|
237
|
+
* Absent, or with no `plan`, the row plans nothing — which is
|
|
238
|
+
* every row but a planner's.
|
|
239
|
+
*/
|
|
240
|
+
turnPlan: S.json,
|
|
241
|
+
},
|
|
242
|
+
out: { main: S.writeResult, messageId: S.writeResult },
|
|
243
|
+
},
|
|
244
|
+
}));
|
|
245
|
+
/**
|
|
246
|
+
* Update an existing message — finish a placeholder, or edit a settled row.
|
|
247
|
+
*
|
|
248
|
+
* `target` takes `row-ids@1`, and a `write-result@1` from earlier in the same
|
|
249
|
+
* run is assignable to it (09-B B4): the reply specs wire `$.placeholder.messageId`
|
|
250
|
+
* here, which is the create → update pair that makes the pipeline own its row.
|
|
251
|
+
* The other case is unchanged — the id comes from outside the run because the
|
|
252
|
+
* user clicked a message, so it is on the inlet.
|
|
253
|
+
*
|
|
254
|
+
* Which of the two this is, the row decides: a target still **generating** — a
|
|
255
|
+
* placeholder this run created — is finished (the text lands, the generating
|
|
256
|
+
* state ends, the reasoning trace and the swipe slot are written); a settled
|
|
257
|
+
* target is edited and marked so. That is the row's own state, not a flag a
|
|
258
|
+
* spec could get wrong.
|
|
259
|
+
*
|
|
260
|
+
* Where review lands on a reply (R-21 (3)): when an admin turns review on
|
|
261
|
+
* for a reply's message writes, it is THIS node that parks — the placeholder
|
|
262
|
+
* ships `reviewDefault: 'off'` and declares no default here either, so nothing
|
|
263
|
+
* gates by default and a reviewer who asks for one sees the content, not an
|
|
264
|
+
* empty row. The executor's own rule (`resolvePosition`) is "the setting, else
|
|
265
|
+
* the author's default, else off", and this node leaves the default unset.
|
|
266
|
+
* @experimental
|
|
267
|
+
*/
|
|
268
|
+
export const updateMessage = pin(describeOutletDefinition({
|
|
269
|
+
id: 'core:outlet/update-message@1',
|
|
270
|
+
effects: 'write',
|
|
271
|
+
/** The text may be reviewed; the row may not, nor the reasoning trace (R-15 review fields). */
|
|
272
|
+
review: { fields: ['text'] },
|
|
273
|
+
timeoutMs: 5000,
|
|
274
|
+
causesEvent: 'core:event/message-updated@1',
|
|
275
|
+
slots: {
|
|
276
|
+
/** The same write hook as `create-message` — see it for the terms. */
|
|
277
|
+
scripts: {
|
|
278
|
+
kind: 'scripts',
|
|
279
|
+
accepts: ['core:script:text/transform@1', 'core:script:text/stop@1'],
|
|
280
|
+
port: 'text',
|
|
281
|
+
phase: 'before',
|
|
282
|
+
extras: ['speakerName', 'castNames'],
|
|
283
|
+
description: 'Scripts over the reply as it is saved — clean up the text, or stop a streaming reply early.',
|
|
284
|
+
},
|
|
285
|
+
},
|
|
286
|
+
ports: {
|
|
287
|
+
in: {
|
|
288
|
+
target: S.rowIds,
|
|
289
|
+
text: S.text,
|
|
290
|
+
/**
|
|
291
|
+
* The reasoning trace the oracle separated from its text, when
|
|
292
|
+
* the model produced one. Stored beside the message as the
|
|
293
|
+
* reasoning fold reads it; absent means none. Shown folded,
|
|
294
|
+
* and never re-sent to the model: the prompt transcript reads
|
|
295
|
+
* a row's text alone (decision D5, 2026-09-27).
|
|
296
|
+
*/
|
|
297
|
+
reasoning: S.text,
|
|
298
|
+
/**
|
|
299
|
+
* Blocks to append to the row — the same list, the same
|
|
300
|
+
* checks and the same stamping as `create-message`'s
|
|
301
|
+
* `blocks`; appended as a `core:blocks` part after the text
|
|
302
|
+
* lands, so a reply can end with a question put to the cast.
|
|
303
|
+
*/
|
|
304
|
+
blocks: S.json,
|
|
305
|
+
/**
|
|
306
|
+
* **Folded sections** for the reply — the same list and the
|
|
307
|
+
* same checks as `create-message`'s `sections`. Finishing a
|
|
308
|
+
* reply, they are the shown alternative's sections, whole: a
|
|
309
|
+
* regenerate replaces what the slot held, and a finish with
|
|
310
|
+
* none clears it, while every other alternative keeps its own.
|
|
311
|
+
* Editing a settled row, they replace the shown alternative's
|
|
312
|
+
* only when given. Like `reasoning`, never re-sent to the model.
|
|
313
|
+
*/
|
|
314
|
+
sections: S.foldedSections,
|
|
315
|
+
},
|
|
316
|
+
out: { main: S.writeResult, messageId: S.writeResult },
|
|
317
|
+
},
|
|
318
|
+
}));
|
|
319
|
+
// ── The built-in writes (R-15, ruled 2026-09-15, built 2026-09-16) ──────────
|
|
320
|
+
//
|
|
321
|
+
// *Anything that alters message state is a built-in*: core implements the
|
|
322
|
+
// write and it always emits an event carrying what changed and what was lost.
|
|
323
|
+
// Each of the five below is the write half of one message verb, run as its
|
|
324
|
+
// own one-node spec (`core:spec/builtin-*`) so it is receipted, gate-eligible
|
|
325
|
+
// (`reviewDefault: 'off'` — an admin may turn review on for a delete) and
|
|
326
|
+
// recorded in the session's changes for the next reply's inlet. The venue's
|
|
327
|
+
// handler makes the permission checks — that is the `item` audience rule,
|
|
328
|
+
// evaluated where the person is — and hands the request to the spec; the
|
|
329
|
+
// host's commit re-runs the same rule against the run's actor before it
|
|
330
|
+
// writes (U5b review C1), so a payload re-aimed between the two — at a review
|
|
331
|
+
// gate, by a spec that is not the built-in's own — is refused where the write
|
|
332
|
+
// happens. Each declares `review.fields`: what a reviewer may edit, and the
|
|
333
|
+
// row's identity is never among them.
|
|
334
|
+
//
|
|
335
|
+
// **Stop, branch and edit are floors**; delete, hide and swipe are built-ins a
|
|
336
|
+
// genre may switch off (`SessionShape.messageVerbs`). Stop has no outlet: it is
|
|
337
|
+
// the run-level guarantee (R-17) and emits `message-stopped` from the
|
|
338
|
+
// finalisation. Regenerate, extend and a swipe's fresh alternative are
|
|
339
|
+
// `update-message` with a `verb` — content the genre's pipeline produced,
|
|
340
|
+
// written by the outlet the reply already ends in.
|
|
341
|
+
/**
|
|
342
|
+
* Delete a message. Publishes `lost` — the content, role, speaker, channel
|
|
343
|
+
* and metadata the row held — beside the write result, so a listener (a
|
|
344
|
+
* plugin cleaning its rows, the next reply's inlet) knows what went.
|
|
345
|
+
* @experimental
|
|
346
|
+
*/
|
|
347
|
+
export const deleteMessage = pin(describeOutletDefinition({
|
|
348
|
+
id: 'core:outlet/delete-message@1',
|
|
349
|
+
effects: 'write',
|
|
350
|
+
reviewDefault: 'off',
|
|
351
|
+
// Nothing to edit at the gate: approve the delete or refuse it. The
|
|
352
|
+
// row it is about was judged by the handler (the item rule) before
|
|
353
|
+
// the run began, and a reviewer retyping `target` would re-aim the
|
|
354
|
+
// write at a row nobody judged (U5b review C1).
|
|
355
|
+
review: { fields: [] },
|
|
356
|
+
timeoutMs: 5000,
|
|
357
|
+
causesEvent: 'core:event/message-deleted@1',
|
|
358
|
+
ports: {
|
|
359
|
+
in: { target: S.rowIds },
|
|
360
|
+
out: { main: S.writeResult, messageId: S.writeResult, lost: S.json },
|
|
361
|
+
},
|
|
362
|
+
}));
|
|
363
|
+
/**
|
|
364
|
+
* Write the session's turn order (PLAN-turn-order §4.2, §4.4; R5) — the ONE
|
|
365
|
+
* write path for `sessions.metadata.turnOrder`, and the only outlet that
|
|
366
|
+
* writes `metadata` at all.
|
|
367
|
+
*
|
|
368
|
+
* Before writing it drops what cannot be fired, each with a receipt note:
|
|
369
|
+
* an entry whose `ref` is not among `candidates` (a script or a plugin
|
|
370
|
+
* strategy cannot seat somebody the pool did not admit), and an entry on a
|
|
371
|
+
* channel the session does not have. Then `writeTurnOrder`, which refuses
|
|
372
|
+
* an order answering an older event than the one already stored and says
|
|
373
|
+
* `stale` on the receipt rather than failing.
|
|
374
|
+
*
|
|
375
|
+
* `causesEvent` is how `turn-order-changed` reaches the auto-advance
|
|
376
|
+
* listener and the `sessions:turnOrder` push; the `cause` wired in here is
|
|
377
|
+
* the one that rides along, so the listener can tell a person's send from a
|
|
378
|
+
* migration's backfill.
|
|
379
|
+
* @experimental
|
|
380
|
+
*/
|
|
381
|
+
export const setTurnOrder = pin(describeOutletDefinition({
|
|
382
|
+
id: 'core:outlet/set-turn-order@1',
|
|
383
|
+
i18n: { name: { en: 'Set turn order' } },
|
|
384
|
+
effects: 'write',
|
|
385
|
+
reviewDefault: 'off',
|
|
386
|
+
// Nothing a reviewer could usefully retype: the order is computed
|
|
387
|
+
// from the rows, and a hand-edited entry would name a participant
|
|
388
|
+
// nobody pooled. Approve the recompute or refuse it.
|
|
389
|
+
review: { fields: [] },
|
|
390
|
+
timeoutMs: 2000,
|
|
391
|
+
causesEvent: 'core:event/turn-order-changed@1',
|
|
392
|
+
ports: {
|
|
393
|
+
in: {
|
|
394
|
+
order: S.turnEntries,
|
|
395
|
+
candidates: S.turnCandidates,
|
|
396
|
+
/** The instant the answered event happened — the staleness key. */
|
|
397
|
+
basedOnAt: S.json,
|
|
398
|
+
/** The event id this order answers. */
|
|
399
|
+
event: S.text,
|
|
400
|
+
/** The inlet's cause, carried into `turn-order-changed`. */
|
|
401
|
+
cause: S.json,
|
|
402
|
+
},
|
|
403
|
+
out: {
|
|
404
|
+
main: S.writeResult,
|
|
405
|
+
/** The document as written, or the stored one when this was stale. */
|
|
406
|
+
turnOrder: S.turnOrder,
|
|
407
|
+
},
|
|
408
|
+
},
|
|
409
|
+
}));
|
|
410
|
+
/**
|
|
411
|
+
* Write one owner's document into the session's annex (§4.3).
|
|
412
|
+
*
|
|
413
|
+
* Merged into what is there by default — a spec that keeps one key does not
|
|
414
|
+
* have to carry the rest — and written under
|
|
415
|
+
* `pg_advisory_xact_lock(hashtext('annex'), sessionId)` through `jsonb_set`,
|
|
416
|
+
* so two specs writing two owners' documents at once cannot lose each
|
|
417
|
+
* other's. Causes `core:event/annex-changed@1` (R30, the modder pass,
|
|
418
|
+
* reversing §4.3's "no causesEvent"): a package's state is the annex, and a
|
|
419
|
+
* genre that wants its turn order to answer that state binds the event in
|
|
420
|
+
* the open, where the event map draws it — not through a back door.
|
|
421
|
+
* @experimental
|
|
422
|
+
*/
|
|
423
|
+
export const setSessionAnnex = pin(describeOutletDefinition({
|
|
424
|
+
id: 'core:outlet/set-session-annex@1',
|
|
425
|
+
i18n: { name: { en: 'Set session annex' } },
|
|
426
|
+
effects: 'write',
|
|
427
|
+
/**
|
|
428
|
+
* "My state changed" as an event any genre may listen for. The host
|
|
429
|
+
* emits it only when the merged value differs from the stored one. A
|
|
430
|
+
* package that wants its own named happening declares an event and
|
|
431
|
+
* records it with `record-event`.
|
|
432
|
+
*/
|
|
433
|
+
causesEvent: 'core:event/annex-changed@1',
|
|
434
|
+
/**
|
|
435
|
+
* Who may see a value is the owner's **annex declaration**'s to say —
|
|
436
|
+
* each key's `annexField({ see })` — and the audience stored with a
|
|
437
|
+
* value is the declaration's. The step may write only keys its owner
|
|
438
|
+
* declares.
|
|
439
|
+
*/
|
|
440
|
+
reviewDefault: 'off',
|
|
441
|
+
review: { fields: ['value'] },
|
|
442
|
+
timeoutMs: 2000,
|
|
443
|
+
slots: {
|
|
444
|
+
params: {
|
|
445
|
+
kind: 'parameters',
|
|
446
|
+
facet: 'behavior',
|
|
447
|
+
schema: {
|
|
448
|
+
owner: {
|
|
449
|
+
type: 'string',
|
|
450
|
+
default: '',
|
|
451
|
+
label: { en: 'Owner' },
|
|
452
|
+
description: {
|
|
453
|
+
en: "Whose document to write. Blank means this pipeline's own.",
|
|
454
|
+
},
|
|
455
|
+
},
|
|
456
|
+
merge: {
|
|
457
|
+
type: 'boolean',
|
|
458
|
+
default: true,
|
|
459
|
+
label: { en: 'Merge' },
|
|
460
|
+
description: {
|
|
461
|
+
en: 'Keep the keys already there and write over the ones given. Off replaces the whole document.',
|
|
462
|
+
},
|
|
463
|
+
},
|
|
464
|
+
sharedAnnex: {
|
|
465
|
+
type: 'boolean',
|
|
466
|
+
default: false,
|
|
467
|
+
label: { en: 'Write another owner' },
|
|
468
|
+
description: {
|
|
469
|
+
en: "Allow writing a document this pipeline does not own. Off refuses, with a note on the receipt.",
|
|
470
|
+
},
|
|
471
|
+
},
|
|
472
|
+
},
|
|
473
|
+
},
|
|
474
|
+
},
|
|
475
|
+
ports: {
|
|
476
|
+
in: { value: S.json },
|
|
477
|
+
out: { main: S.writeResult, annex: S.json },
|
|
478
|
+
},
|
|
479
|
+
}));
|
|
480
|
+
/**
|
|
481
|
+
* Set one **annex field** (2026-09-26): the write behind every
|
|
482
|
+
* `annexField()` a package declares — core's one pipeline for them all,
|
|
483
|
+
* `core:spec/set-annex-field`.
|
|
484
|
+
*
|
|
485
|
+
* `payload` is `{ field, value }`: `field` the field's action identity
|
|
486
|
+
* (`<owner>:annex#<key>`), which the host's door put there after judging the
|
|
487
|
+
* press — who pressed, the plugin switch, the shape. The host reads the
|
|
488
|
+
* declaration again here rather than trusting the payload: an undeclared
|
|
489
|
+
* key, a value its shape refuses, a secret, or a declared audience that is
|
|
490
|
+
* not one is refused, and the run halts on it. What is written goes through
|
|
491
|
+
* the same annex write as `set-session-annex` — the lock, one audience per
|
|
492
|
+
* key, `annex-changed`, every viewer's view re-sent — into
|
|
493
|
+
* `annex[<owner>][<key>]`, under the audience the declaration names.
|
|
494
|
+
* @experimental
|
|
495
|
+
*/
|
|
496
|
+
export const setAnnexField = pin(describeOutletDefinition({
|
|
497
|
+
id: 'core:outlet/set-annex-field@1',
|
|
498
|
+
i18n: { name: { en: 'Set annex field' } },
|
|
499
|
+
effects: 'write',
|
|
500
|
+
causesEvent: 'core:event/annex-changed@1',
|
|
501
|
+
reviewDefault: 'off',
|
|
502
|
+
/** The payload was judged at the door and is judged again here — approve or refuse, never rewrite (R-15 review fields). */
|
|
503
|
+
review: { fields: [] },
|
|
504
|
+
timeoutMs: 2000,
|
|
505
|
+
ports: {
|
|
506
|
+
in: { payload: S.json },
|
|
507
|
+
out: { main: S.writeResult, annex: S.json },
|
|
508
|
+
},
|
|
509
|
+
}));
|
|
510
|
+
/**
|
|
511
|
+
* Record an event your package declared: something happened, and
|
|
512
|
+
* pipelines bound to it — plugin listeners, and widgets when the event is
|
|
513
|
+
* delivered to the session — hear it.
|
|
514
|
+
*
|
|
515
|
+
* `event` is the declaration value (`defineSessionEvent(…)`), written into
|
|
516
|
+
* the document as its id; it is never wired, so what a pipeline records is
|
|
517
|
+
* known before it runs. `payload` must carry the event's declared shape. The
|
|
518
|
+
* write is the `session_changes` row, and the event it causes is the one it
|
|
519
|
+
* names — so a recorded event is, like every event, the consequence of a
|
|
520
|
+
* write. It is never the live row; a run may record several.
|
|
521
|
+
*
|
|
522
|
+
* Who may record it is the declaring package's to say
|
|
523
|
+
* (`defineExtension({ events: [{ event, genre, recordedBy }] })`): the host
|
|
524
|
+
* refuses a recording from a pipeline outside that scope.
|
|
525
|
+
* @experimental
|
|
526
|
+
*/
|
|
527
|
+
export const recordEvent = pin(describeOutletDefinition({
|
|
528
|
+
id: 'core:outlet/record-event@1',
|
|
529
|
+
i18n: { name: { en: 'Record event' } },
|
|
530
|
+
effects: 'write',
|
|
531
|
+
causesEventFrom: 'event',
|
|
532
|
+
reviewDefault: 'off',
|
|
533
|
+
review: { fields: ['payload'] },
|
|
534
|
+
timeoutMs: 2000,
|
|
535
|
+
ports: {
|
|
536
|
+
in: {
|
|
537
|
+
/** The declared event's id — a literal, never wired. */
|
|
538
|
+
event: S.text,
|
|
539
|
+
payload: S.json,
|
|
540
|
+
},
|
|
541
|
+
out: { main: S.writeResult },
|
|
542
|
+
},
|
|
543
|
+
}));
|
|
544
|
+
/**
|
|
545
|
+
* Hide a message from the prompt, or show it again — a **ghost**. The row
|
|
546
|
+
* stays; `hidden` says which way it went.
|
|
547
|
+
* @experimental
|
|
548
|
+
*/
|
|
549
|
+
export const hideMessage = pin(describeOutletDefinition({
|
|
550
|
+
id: 'core:outlet/hide-message@1',
|
|
551
|
+
effects: 'write',
|
|
552
|
+
reviewDefault: 'off',
|
|
553
|
+
/** The direction may be reviewed; the row may not (see `delete-message`). */
|
|
554
|
+
review: { fields: ['hidden'] },
|
|
555
|
+
timeoutMs: 5000,
|
|
556
|
+
causesEvent: 'core:event/message-hidden@1',
|
|
557
|
+
ports: {
|
|
558
|
+
in: { target: S.rowIds, hidden: S.json },
|
|
559
|
+
out: { main: S.writeResult, messageId: S.writeResult, hidden: S.json },
|
|
560
|
+
},
|
|
561
|
+
}));
|
|
562
|
+
/**
|
|
563
|
+
* A person's rewrite of a **settled** row: the text replaces, the selected
|
|
564
|
+
* alternative follows it, the embedding is cleared for re-indexing, and the
|
|
565
|
+
* row is marked edited. Publishes `previous` — the content it replaced.
|
|
566
|
+
*
|
|
567
|
+
* Distinct from `update-message@1`, which finishes a *generating* row with
|
|
568
|
+
* what a pipeline produced. A floor: every genre has it.
|
|
569
|
+
* @experimental
|
|
570
|
+
*/
|
|
571
|
+
export const editMessage = pin(describeOutletDefinition({
|
|
572
|
+
id: 'core:outlet/edit-message@1',
|
|
573
|
+
effects: 'write',
|
|
574
|
+
reviewDefault: 'off',
|
|
575
|
+
/** The text may be reviewed; the row may not (see `delete-message`). */
|
|
576
|
+
review: { fields: ['text'] },
|
|
577
|
+
timeoutMs: 5000,
|
|
578
|
+
causesEvent: 'core:event/message-edited@1',
|
|
579
|
+
ports: {
|
|
580
|
+
in: { target: S.rowIds, text: S.text },
|
|
581
|
+
out: { main: S.writeResult, messageId: S.writeResult, previous: S.json },
|
|
582
|
+
},
|
|
583
|
+
}));
|
|
584
|
+
/**
|
|
585
|
+
* Move between a message's alternatives, or record a new one. `index`
|
|
586
|
+
* selects an alternative the row already holds; `text` records a new one and
|
|
587
|
+
* selects it — the reply road then fills an empty one it opened this way.
|
|
588
|
+
* Publishes `swipeIndex`, the alternative now showing, and `previous` — the
|
|
589
|
+
* content and index that were.
|
|
590
|
+
* @experimental
|
|
591
|
+
*/
|
|
592
|
+
export const swipeMessage = pin(describeOutletDefinition({
|
|
593
|
+
id: 'core:outlet/swipe-message@1',
|
|
594
|
+
effects: 'write',
|
|
595
|
+
reviewDefault: 'off',
|
|
596
|
+
/**
|
|
597
|
+
* A recorded alternative's text may be reviewed; neither the row nor
|
|
598
|
+
* the `index` — which alternative a navigation selects is as much the
|
|
599
|
+
* request's identity as the row is (see `delete-message`).
|
|
600
|
+
*/
|
|
601
|
+
review: { fields: ['text'] },
|
|
602
|
+
timeoutMs: 5000,
|
|
603
|
+
causesEvent: 'core:event/message-swiped@1',
|
|
604
|
+
ports: {
|
|
605
|
+
in: { target: S.rowIds, index: S.json, text: S.text },
|
|
606
|
+
out: {
|
|
607
|
+
main: S.writeResult,
|
|
608
|
+
messageId: S.writeResult,
|
|
609
|
+
swipeIndex: S.json,
|
|
610
|
+
previous: S.json,
|
|
611
|
+
},
|
|
612
|
+
},
|
|
613
|
+
}));
|
|
614
|
+
/**
|
|
615
|
+
* Branch a session at a message: a new session with the same cast, guests
|
|
616
|
+
* and tags and a copy of the history up to and including `fromMessage`, each
|
|
617
|
+
* copy keeping its channel. Publishes the new `sessionId`. A floor.
|
|
618
|
+
* @experimental
|
|
619
|
+
*/
|
|
620
|
+
export const branchSession = pin(describeOutletDefinition({
|
|
621
|
+
id: 'core:outlet/branch-session@1',
|
|
622
|
+
effects: 'write',
|
|
623
|
+
reviewDefault: 'off',
|
|
624
|
+
/** The title may be reviewed; the fork point may not (see `delete-message`). */
|
|
625
|
+
review: { fields: ['title'] },
|
|
626
|
+
timeoutMs: 30000,
|
|
627
|
+
causesEvent: 'core:event/session-branched@1',
|
|
628
|
+
ports: {
|
|
629
|
+
in: { fromMessage: S.rowIds, title: S.text },
|
|
630
|
+
out: { main: S.writeResult, sessionId: S.writeResult },
|
|
631
|
+
},
|
|
632
|
+
}));
|
|
633
|
+
// ── Sprites (DESIGN-sprites §5, 2026-09-24; in-pipeline 2026-10-05) ─────────
|
|
634
|
+
/**
|
|
635
|
+
* Record a line's **shown sprite**. Writes it on the line's ACTIVE swipe
|
|
636
|
+
* (`metadata.swipes.spriteHistory[currentIdx]`, mirrored to
|
|
637
|
+
* `metadata.sprite`), so each swipe keeps its own face.
|
|
638
|
+
*
|
|
639
|
+
* Who chose it is `source`, written by the spec as a literal: `picker` after
|
|
640
|
+
* a reply, `person` in `core:spec/show-sprite` (a person's pick from the
|
|
641
|
+
* message menu). A picker never overwrites a person's pick. A picker's null
|
|
642
|
+
* pick writes nothing — the line keeps what it shows; a person's null clears
|
|
643
|
+
* the line's sprite.
|
|
644
|
+
* @experimental
|
|
645
|
+
*/
|
|
646
|
+
export const showSprite = pin(describeOutletDefinition({
|
|
647
|
+
id: 'core:outlet/show-sprite@1',
|
|
648
|
+
effects: 'write',
|
|
649
|
+
reviewDefault: 'off',
|
|
650
|
+
review: { fields: [] },
|
|
651
|
+
timeoutMs: 5000,
|
|
652
|
+
causesEvent: 'core:event/sprite-shown@1',
|
|
653
|
+
ports: {
|
|
654
|
+
in: {
|
|
655
|
+
target: S.rowIds,
|
|
656
|
+
/** A `sprite-pick@1` — a picker's, or a person's; null for none. */
|
|
657
|
+
pick: S.spritePick,
|
|
658
|
+
/**
|
|
659
|
+
* Who chose the pick: `'picker'` or `'person'`.
|
|
660
|
+
*
|
|
661
|
+
* ## A port, not a parameter, and the call site is what decides
|
|
662
|
+
*
|
|
663
|
+
* A literal in the node's config, on `create-message`'s
|
|
664
|
+
* `generating` terms: the reply specs write `source: 'picker'`
|
|
665
|
+
* and `core:spec/show-sprite` writes `source: 'person'`. A
|
|
666
|
+
* `params` field would put a structural fact of the document
|
|
667
|
+
* in the panel as a knob. It was the host's to decide from the
|
|
668
|
+
* running spec's id until 2026-10-05; the document says it now.
|
|
669
|
+
*
|
|
670
|
+
* ⚠ Stated, not trusted: a host accepts `'person'` only from
|
|
671
|
+
* core's own `core:spec/show-sprite`, run for a person whose
|
|
672
|
+
* pick it checked against the item rule, as for an edit.
|
|
673
|
+
*/
|
|
674
|
+
source: S.text,
|
|
675
|
+
},
|
|
676
|
+
out: {
|
|
677
|
+
main: S.writeResult,
|
|
678
|
+
messageId: S.writeResult,
|
|
679
|
+
/** What the line now shows, or null. */
|
|
680
|
+
sprite: S.json,
|
|
681
|
+
/**
|
|
682
|
+
* True when nothing was written — a picker meeting a person's
|
|
683
|
+
* pick, a picker's null pick, or the sprite the line already
|
|
684
|
+
* shows.
|
|
685
|
+
*/
|
|
686
|
+
kept: S.json,
|
|
687
|
+
},
|
|
688
|
+
},
|
|
689
|
+
}));
|
|
690
|
+
// ── The story clock (DESIGN-story-time P3, 2026-09-28) ──────────────────────
|
|
691
|
+
/**
|
|
692
|
+
* Move a session's **story clock** — the session's own story now — by `by` of
|
|
693
|
+
* `unit`, through its lorebook's calendar (`advanceStoryTime`): carried by a
|
|
694
|
+
* declared calendar, and by the smallest-part rule in a free-form book.
|
|
695
|
+
* What "advance a minute per reply" places.
|
|
696
|
+
*
|
|
697
|
+
* Moves the session's clock only, never the book's or its line's present. A
|
|
698
|
+
* session with no clock of its own starts from its line's present. Refused
|
|
699
|
+
* with a sentence — the run halts — when the session has no lorebook, when
|
|
700
|
+
* there is no present to start from, and when the result does not land in
|
|
701
|
+
* the book's calendar; never clamped, never a silent no-op.
|
|
702
|
+
*
|
|
703
|
+
* `by` and `unit` in-ports, when wired, win over the parameters. To advance
|
|
704
|
+
* once per reply, place it in a spec bound to the reply's event, which runs
|
|
705
|
+
* after the reply is saved. (No ordering-only in-port: an unread port is a
|
|
706
|
+
* declared control no run consults — `declaredReads`.)
|
|
707
|
+
* @experimental
|
|
708
|
+
*/
|
|
709
|
+
export const advanceStoryClock = pin(describeOutletDefinition({
|
|
710
|
+
id: 'core:outlet/advance-story-clock@1',
|
|
711
|
+
i18n: { name: { en: 'Advance story clock' } },
|
|
712
|
+
effects: 'write',
|
|
713
|
+
reviewDefault: 'off',
|
|
714
|
+
review: { fields: [] },
|
|
715
|
+
timeoutMs: 2000,
|
|
716
|
+
causesEvent: 'core:event/session-updated@1',
|
|
717
|
+
slots: {
|
|
718
|
+
params: {
|
|
719
|
+
kind: 'parameters',
|
|
720
|
+
facet: 'behavior',
|
|
721
|
+
schema: {
|
|
722
|
+
by: {
|
|
723
|
+
type: 'integer',
|
|
724
|
+
default: 1,
|
|
725
|
+
label: { en: 'By' },
|
|
726
|
+
description: { en: 'How many units to move the clock. Negative goes back.' },
|
|
727
|
+
},
|
|
728
|
+
unit: {
|
|
729
|
+
type: 'enum',
|
|
730
|
+
of: ['minutes', 'hours', 'days', 'months', 'years'],
|
|
731
|
+
members: [
|
|
732
|
+
{ key: 'minutes', label: { en: 'Minutes' } },
|
|
733
|
+
{ key: 'hours', label: { en: 'Hours' } },
|
|
734
|
+
{ key: 'days', label: { en: 'Days' } },
|
|
735
|
+
{ key: 'months', label: { en: 'Months' } },
|
|
736
|
+
{ key: 'years', label: { en: 'Years' } },
|
|
737
|
+
],
|
|
738
|
+
default: 'hours',
|
|
739
|
+
label: { en: 'Unit' },
|
|
740
|
+
description: {
|
|
741
|
+
en: "What to count. In a free-form book only the part named moves: days never roll into a month.",
|
|
742
|
+
},
|
|
743
|
+
},
|
|
744
|
+
},
|
|
745
|
+
},
|
|
746
|
+
},
|
|
747
|
+
ports: {
|
|
748
|
+
in: {
|
|
749
|
+
/** A whole number; wins over the `by` parameter when wired. */
|
|
750
|
+
by: S.json,
|
|
751
|
+
/** One of the units; wins over the `unit` parameter when wired. */
|
|
752
|
+
unit: S.text,
|
|
753
|
+
},
|
|
754
|
+
out: {
|
|
755
|
+
main: S.writeResult,
|
|
756
|
+
/** The session's story clock as it now stands: `{ year, month?, day?, hour?, minute? }`. */
|
|
757
|
+
clock: S.json,
|
|
758
|
+
/** It spelled through the book's calendar. */
|
|
759
|
+
label: S.text,
|
|
760
|
+
},
|
|
761
|
+
},
|
|
762
|
+
}));
|
|
763
|
+
// ── Forms (plans/29 R-15 *Forms* · *The line*; R-21 (5); 30 §U5d, 2026-09-17) ──
|
|
764
|
+
/**
|
|
765
|
+
* Commit an oracle's answer to a form **exactly as a click would**.
|
|
766
|
+
*
|
|
767
|
+
* The host checks the answer against the form's schema, then fires the
|
|
768
|
+
* block's action through the same server path a press takes
|
|
769
|
+
* (`fireAction`): the run owner is the acting user, the actor portrays the
|
|
770
|
+
* addressee, the block's addressee is the audience, and the action's spec
|
|
771
|
+
* runs as a child of this run. It records `form-answered` in the session's
|
|
772
|
+
* changes with the answer and `answeredBy: 'oracle'`, so the next reply's
|
|
773
|
+
* inlet sees it. Refused outside a document on `core:inlet/form-addressed@1`
|
|
774
|
+
* (`validate()` and the host), refused when the addressee is not the AI's,
|
|
775
|
+
* and refused for a `world` action (the effects line — belt to the
|
|
776
|
+
* validator's braces). `reviewDefault: 'off'`; an admin may gate it, and the
|
|
777
|
+
* reviewer edits the `answer` alone.
|
|
778
|
+
* @experimental
|
|
779
|
+
*/
|
|
780
|
+
export const answerForm = pin(describeOutletDefinition({
|
|
781
|
+
id: 'core:outlet/answer-form@1',
|
|
782
|
+
i18n: { name: { en: 'Answer the form' } },
|
|
783
|
+
effects: 'write',
|
|
784
|
+
reviewDefault: 'off',
|
|
785
|
+
/** The answer may be corrected at the gate; which form, and who answers, may not (R-15 review fields). */
|
|
786
|
+
review: { fields: ['answer'] },
|
|
787
|
+
/**
|
|
788
|
+
* A write's timeout, not a run's (was 600000 until 2026-09-17, U5d
|
|
789
|
+
* review W2): the commit checks the answer, asks the cycle caps and
|
|
790
|
+
* **collects** the fire — the action's run is dispatched by the host
|
|
791
|
+
* after this run's receipt is saved, outside any node timeout, as
|
|
792
|
+
* this run's child. A grandchild parked at review parks nothing here.
|
|
793
|
+
*
|
|
794
|
+
* Thirty seconds rather than a write's usual five (U5d review S-a,
|
|
795
|
+
* the same day): the commit does database work of its own — the
|
|
796
|
+
* block off the row, the session, the routing, a cap refusal's
|
|
797
|
+
* receipt — and under PGlite contention (a full test run, a busy
|
|
798
|
+
* install) five seconds turned a legible **halt** into a timeout
|
|
799
|
+
* `err` with no sentence. The ceiling is still a write's order of
|
|
800
|
+
* magnitude, never a model call's: nothing here waits on an oracle.
|
|
801
|
+
*/
|
|
802
|
+
timeoutMs: 30000,
|
|
803
|
+
causesEvent: 'core:event/form-answered@1',
|
|
804
|
+
ports: {
|
|
805
|
+
in: {
|
|
806
|
+
/** The block, as the inlet published it. */
|
|
807
|
+
form: S.json,
|
|
808
|
+
/** The oracle's document — checked against `formAnswerSchema(form)`. */
|
|
809
|
+
answer: S.json,
|
|
810
|
+
messageId: S.rowIds,
|
|
811
|
+
blockId: S.text,
|
|
812
|
+
addressee: S.participantRef,
|
|
813
|
+
},
|
|
814
|
+
out: {
|
|
815
|
+
main: S.writeResult,
|
|
816
|
+
messageId: S.writeResult,
|
|
817
|
+
/** The answer as committed: `{ choice }` or the values. */
|
|
818
|
+
answer: S.json,
|
|
819
|
+
/** The identity of the action the answer fires — `<spec slug>#<key>`. */
|
|
820
|
+
firedAction: S.text,
|
|
821
|
+
/** The child run's id, chosen at the commit so this receipt can name it. */
|
|
822
|
+
firedRunId: S.text,
|
|
823
|
+
},
|
|
824
|
+
},
|
|
825
|
+
}));
|
|
826
|
+
/** The audio twin of `attach-image` — same `target`, same commit, bound the same day. @experimental */
|
|
827
|
+
export const attachAudio = pin(describeOutletDefinition({
|
|
828
|
+
id: 'core:outlet/attach-audio@1',
|
|
829
|
+
effects: 'write',
|
|
830
|
+
/** A reference to rendered audio; nothing to retype (R-15 review fields). */
|
|
831
|
+
review: { fields: [] },
|
|
832
|
+
timeoutMs: 5000,
|
|
833
|
+
causesEvent: 'core:event/message-updated@1',
|
|
834
|
+
ports: { in: { target: S.rowIds, audio: S.audio }, out: { main: S.writeResult } },
|
|
835
|
+
}));
|
|
836
|
+
// ── Summarization ───────────────────────────────────────────────────────────
|
|
837
|
+
/**
|
|
838
|
+
* Write the finished entry. Gate-eligible, so it publishes a write result.
|
|
839
|
+
*
|
|
840
|
+
* ## Which kind of entry — the pipeline's decision, at last (L3, 2026-09-17)
|
|
841
|
+
*
|
|
842
|
+
* The host's commit case has said since the four summarize namespaces were
|
|
843
|
+
* written that *which kind of entry comes from the pipeline that ran*. It did
|
|
844
|
+
* not: it wrote world lore whatever ran, because nothing on this declaration
|
|
845
|
+
* could say otherwise. `entryType` is that sentence made true — a declared
|
|
846
|
+
* entry type id (`core:entry/world-lore`, `core:entry/history`,
|
|
847
|
+
* `core:entry/location`), bare, the way `core:query/lorebook-entries@1` spells
|
|
848
|
+
* them; the version is the row's own column.
|
|
849
|
+
*
|
|
850
|
+
* A **param** and not an in-port, because the kind of thing a pipeline writes
|
|
851
|
+
* is a fact about the pipeline rather than about the turn — a summarizer
|
|
852
|
+
* writes history every time it runs, a room-builder writes locations every
|
|
853
|
+
* time — and a param is what a preset can set per session without the spec
|
|
854
|
+
* being rewired. An unknown id is refused at the commit with a sentence
|
|
855
|
+
* naming the declared types, never coerced to world lore: a typo that silently
|
|
856
|
+
* files rooms as world lore is the defect this replaces.
|
|
857
|
+
*
|
|
858
|
+
* Default world lore, the agnostic shape, so every spec written before this
|
|
859
|
+
* keeps doing exactly what it did.
|
|
860
|
+
*
|
|
861
|
+
* ## `links`, or a second write
|
|
862
|
+
*
|
|
863
|
+
* Linking a new entry takes one of two shapes, and both exist on purpose.
|
|
864
|
+
* (A pipeline may write many times — F7 limits only the live row — so
|
|
865
|
+
* `core:outlet/link-lore-entries@1` may also follow this outlet in the same
|
|
866
|
+
* run, each its own transaction.)
|
|
867
|
+
*
|
|
868
|
+
* - `links` — the links land in the **same transaction** as the row, keyed
|
|
869
|
+
* from the entry just written. A genre that builds a room with its exits
|
|
870
|
+
* does it in one run and one commit, and a link naming an entry that does
|
|
871
|
+
* not exist fails the row with it rather than writing half a room. This is
|
|
872
|
+
* the shape a builder wants.
|
|
873
|
+
* - `core:outlet/link-lore-entries@1` takes its `to` by **name**, so a later
|
|
874
|
+
* run can link what an earlier one created without holding an id. This is
|
|
875
|
+
* the shape a second turn wants.
|
|
876
|
+
*
|
|
877
|
+
* Each entry of `links` is a name or an entry id, or a `LoreLinkInput` —
|
|
878
|
+
* `{ to, linkType?, reverseLinkType?, name?, description? }` — for one that
|
|
879
|
+
* says more (places plan B2, 2026-09-29). Absent on nearly every write, and an
|
|
880
|
+
* empty list is the same as none. A link the list states twice, or one the
|
|
881
|
+
* session already reads, is written once: see `linkLoreEntries` on idempotence.
|
|
882
|
+
* @internal
|
|
883
|
+
*/
|
|
884
|
+
export const createLoreEntry = pin(describeOutletDefinition({
|
|
885
|
+
id: 'core:outlet/create-lore-entry@1',
|
|
886
|
+
i18n: { name: { en: 'Save the lore entry' } },
|
|
887
|
+
effects: 'write',
|
|
888
|
+
/**
|
|
889
|
+
* Both the name and the content may be edited before the entry lands
|
|
890
|
+
* (R-15 review fields). `links` is deliberately not among them: the
|
|
891
|
+
* gate's form edits values a reader can retype, and a list of
|
|
892
|
+
* references is not one — a reviewer who disagrees with a room's exits
|
|
893
|
+
* refuses the write.
|
|
894
|
+
*/
|
|
895
|
+
review: { fields: ['name', 'content'] },
|
|
896
|
+
timeoutMs: 10000,
|
|
897
|
+
causesEvent: 'core:event/lore-entry-created@1',
|
|
898
|
+
slots: {
|
|
899
|
+
params: {
|
|
900
|
+
kind: 'parameters',
|
|
901
|
+
schema: {
|
|
902
|
+
entryType: {
|
|
903
|
+
type: 'string',
|
|
904
|
+
default: 'core:entry/world-lore',
|
|
905
|
+
quick: true,
|
|
906
|
+
label: { en: 'Kind of entry' },
|
|
907
|
+
description: 'Which kind of lorebook entry this pipeline writes — world lore, history, a location. Leave it as world lore for anything that is simply about the world.',
|
|
908
|
+
},
|
|
909
|
+
},
|
|
910
|
+
},
|
|
911
|
+
},
|
|
912
|
+
ports: {
|
|
913
|
+
in: {
|
|
914
|
+
name: S.text,
|
|
915
|
+
content: S.text,
|
|
916
|
+
/**
|
|
917
|
+
* Links to write from this entry in the same commit — see the
|
|
918
|
+
* note above on F7. Names, entry ids, or `LoreLinkInput`s.
|
|
919
|
+
*/
|
|
920
|
+
links: S.json,
|
|
921
|
+
},
|
|
922
|
+
out: { main: S.writeResult, entryId: S.writeResult },
|
|
923
|
+
},
|
|
924
|
+
}));
|
|
925
|
+
/**
|
|
926
|
+
* Link two lore entries (L2, 2026-09-17).
|
|
927
|
+
*
|
|
928
|
+
* ## The gap it closes
|
|
929
|
+
*
|
|
930
|
+
* `create-lore-entry@1` takes a name and a body and nothing else, so a genre
|
|
931
|
+
* whose world has *shape* — a room with exits, a street that runs past a shop
|
|
932
|
+
* — had one place to put that shape: the prose. Lair shipped writing an
|
|
933
|
+
* `Exits:` line into the content and parsing it back out, which is a link with
|
|
934
|
+
* no foreign key, no cascade and no second reader. The rows have existed all
|
|
935
|
+
* along (an entry-ended `narrative_relationships` row, the same edge the
|
|
936
|
+
* lorebook's own graph draws); no pipeline could write one.
|
|
937
|
+
*
|
|
938
|
+
* ## Both ends, and the one scope
|
|
939
|
+
*
|
|
940
|
+
* `from` is an entry id — or, straight off `create-lore-entry@1`, its
|
|
941
|
+
* `entryId` write result, which is assignable to `row-ids@1` (09-B B4). `to`
|
|
942
|
+
* is an id **or a name**, resolved within the session's own lorebook, case
|
|
943
|
+
* and surrounding space ignored. A name is the half that makes the law below
|
|
944
|
+
* survivable, and it is also the half that can be wrong in two ways, so both
|
|
945
|
+
* are refused with a sentence: a name nothing answers to, and a name **two**
|
|
946
|
+
* entries answer to — the second never picks one, because picking would link
|
|
947
|
+
* the wrong room silently and a duplicate name is the author's to resolve.
|
|
948
|
+
*
|
|
949
|
+
* One lorebook, both ends. An edge whose ends live in two books belongs to
|
|
950
|
+
* neither and the row carries one `lorebook_id`, so a cross-book link is
|
|
951
|
+
* refused rather than repaired — the same rule the socket handlers hold, held
|
|
952
|
+
* again here because a pipeline does not come through them.
|
|
953
|
+
*
|
|
954
|
+
* ## After a create
|
|
955
|
+
*
|
|
956
|
+
* It may follow `core:outlet/create-lore-entry@1` in the same run (F7 limits
|
|
957
|
+
* only the live row), linking by name what that write created — which is why
|
|
958
|
+
* `to` takes one; a later run can do the same. Each write is its own
|
|
959
|
+
* transaction, so a failed link leaves the entry behind. When the entry and
|
|
960
|
+
* its links are one thought, `create-lore-entry`'s own `links` in-port writes
|
|
961
|
+
* the edges in the row's transaction instead — the shape a room-builder wants.
|
|
962
|
+
*
|
|
963
|
+
* ## What the link says (places plan B2, 2026-09-29)
|
|
964
|
+
*
|
|
965
|
+
* The row is a **relationship**, and it carries the relationship's whole
|
|
966
|
+
* descriptor — the same four words the lorebook's own link form edits:
|
|
967
|
+
*
|
|
968
|
+
* - `linkType` — the relationship type, read from the `from` end ("leads
|
|
969
|
+
* north to"). Free text in the row and free text here: the app's list is a
|
|
970
|
+
* vocabulary of *suggestions*, and nothing reads a relationship type
|
|
971
|
+
* semantically. The default is `leads to`.
|
|
972
|
+
* - `reverseLinkType` — the wording read from the `to` end ("leads south
|
|
973
|
+
* to"). **Empty is one way**, and one way is the default: direction is
|
|
974
|
+
* something a spec says, never a guess the host makes from the forward
|
|
975
|
+
* words. A symmetric wording repeats itself (`connects to` / `connects to`).
|
|
976
|
+
* - `name` — the relationship's own name ("the rusted iron door", "the King's
|
|
977
|
+
* Road"), empty for an unnamed way. ⚠ Something you can stand in is a place
|
|
978
|
+
* of its own, not a named link.
|
|
979
|
+
* - `description` — its description. (It was the port `label`; one column,
|
|
980
|
+
* one word, no alias.)
|
|
981
|
+
*
|
|
982
|
+
* ## Idempotent
|
|
983
|
+
*
|
|
984
|
+
* One way is one row, **as the session reads** (the app's
|
|
985
|
+
* `linksOnReadingThatWay`): a link the session already reads — on its own
|
|
986
|
+
* line or one it inherits, undated or dated at or before its moment — with
|
|
987
|
+
* the same name (case aside) that says **everything** this one would (the same
|
|
988
|
+
* words read from the same end, both ways when both are asked, or its true
|
|
989
|
+
* mirror drawn from the far end) is **the standing row**. The outlet returns
|
|
990
|
+
* its id and writes nothing, so a re-run, a swipe or a second turn never stacks
|
|
991
|
+
* a room's ways out; `fromEntryId` is the row's own `from`. The standing row is
|
|
992
|
+
* never rewritten: a pipeline's repeat does not edit a link a person may have
|
|
993
|
+
* drawn or worded. And because this run did not make the row, the host neither
|
|
994
|
+
* records it as the run's (an undo of the run must not delete it) nor reports a
|
|
995
|
+
* write (`written: false`, so no `core:event/lore-link-created@1`).
|
|
996
|
+
*
|
|
997
|
+
* Refused with a sentence instead: a link that says only PART of this one (a
|
|
998
|
+
* one-way door where both ways is asked — a second row would say that part
|
|
999
|
+
* twice), and one that says it all but no longer stands (resolved, broken,
|
|
1000
|
+
* secret) — nothing the session reads states it, and a pipeline does not
|
|
1001
|
+
* reopen or reveal it.
|
|
1002
|
+
* @internal
|
|
1003
|
+
*/
|
|
1004
|
+
export const linkLoreEntries = pin(describeOutletDefinition({
|
|
1005
|
+
id: 'core:outlet/link-lore-entries@1',
|
|
1006
|
+
i18n: {
|
|
1007
|
+
name: { en: 'Link the lore entries' },
|
|
1008
|
+
description: {
|
|
1009
|
+
en: 'Draws a link between two entries of this session’s lorebook — a room’s way out, who keeps what, what stands near what.',
|
|
1010
|
+
},
|
|
1011
|
+
},
|
|
1012
|
+
effects: 'write',
|
|
1013
|
+
/**
|
|
1014
|
+
* The link itself is what a reviewer judges, so its words both ways,
|
|
1015
|
+
* its name and its description may be retyped (R-15 review fields). The
|
|
1016
|
+
* two ends may not: they are the run's own identity, and a reviewer
|
|
1017
|
+
* re-aiming them would link a pair nobody judged — the rule
|
|
1018
|
+
* `delete-message@1` states.
|
|
1019
|
+
*/
|
|
1020
|
+
review: { fields: ['linkType', 'reverseLinkType', 'name', 'description'] },
|
|
1021
|
+
timeoutMs: 10000,
|
|
1022
|
+
causesEvent: 'core:event/lore-link-created@1',
|
|
1023
|
+
slots: {
|
|
1024
|
+
params: {
|
|
1025
|
+
kind: 'parameters',
|
|
1026
|
+
schema: {
|
|
1027
|
+
linkType: {
|
|
1028
|
+
type: 'string',
|
|
1029
|
+
default: 'leads to',
|
|
1030
|
+
quick: true,
|
|
1031
|
+
label: { en: 'Kind of link' },
|
|
1032
|
+
description: 'What the link says, read from the entry it starts at — “leads north to”, “connects to”, “is inside”, “keeper of”.',
|
|
1033
|
+
},
|
|
1034
|
+
reverseLinkType: {
|
|
1035
|
+
type: 'string',
|
|
1036
|
+
default: '',
|
|
1037
|
+
label: { en: 'From there it…' },
|
|
1038
|
+
description: 'What the link says read from the other end — “leads south to”, “holds”. Leave it empty for a way that only goes one way.',
|
|
1039
|
+
},
|
|
1040
|
+
},
|
|
1041
|
+
},
|
|
1042
|
+
},
|
|
1043
|
+
ports: {
|
|
1044
|
+
in: {
|
|
1045
|
+
/** The entry the link starts at — an id, or a write result. */
|
|
1046
|
+
from: S.rowIds,
|
|
1047
|
+
/**
|
|
1048
|
+
* The entry it ends at: an id, or a **name** resolved within
|
|
1049
|
+
* this session's lorebook. `json` because it is either — and
|
|
1050
|
+
* every shape is assignable into `json`, so an id port, a
|
|
1051
|
+
* write result and a text name all wire here.
|
|
1052
|
+
*/
|
|
1053
|
+
to: S.json,
|
|
1054
|
+
/** The relationship's own name — "the rusted iron door". Optional. */
|
|
1055
|
+
name: S.text,
|
|
1056
|
+
/** Its description. Optional. */
|
|
1057
|
+
description: S.text,
|
|
1058
|
+
},
|
|
1059
|
+
out: { main: S.writeResult, linkId: S.writeResult },
|
|
1060
|
+
},
|
|
1061
|
+
}));
|
|
1062
|
+
// ── Graph build ─────────────────────────────────────────────────────────────
|
|
1063
|
+
/**
|
|
1064
|
+
* The proposal, held for review.
|
|
1065
|
+
*
|
|
1066
|
+
* `effects: 'write'` and therefore gate-eligible, which is the mechanism behind
|
|
1067
|
+
* the rule that a graph build **stops at the review screen** and never applies
|
|
1068
|
+
* itself. Under `async` review the proposal is exactly that — a proposal — and
|
|
1069
|
+
* `write-result@1` is the shape that refuses to be mistaken for row ids.
|
|
1070
|
+
* @internal
|
|
1071
|
+
*/
|
|
1072
|
+
export const graphProposal = pin(describeOutletDefinition({
|
|
1073
|
+
id: 'core:outlet/graph-proposal@1',
|
|
1074
|
+
i18n: { name: { en: 'Propose graph changes' } },
|
|
1075
|
+
effects: 'write',
|
|
1076
|
+
/** The proposal is what the review screen exists to edit (R-15 review fields). */
|
|
1077
|
+
review: { fields: ['proposal'] },
|
|
1078
|
+
timeoutMs: 10000,
|
|
1079
|
+
causesEvent: 'core:event/graph-proposal-created@1',
|
|
1080
|
+
ports: {
|
|
1081
|
+
in: { proposal: S.json },
|
|
1082
|
+
out: { main: S.writeResult, proposalId: S.writeResult },
|
|
1083
|
+
},
|
|
1084
|
+
}));
|
|
1085
|
+
//# sourceMappingURL=outlets.js.map
|