@serene-pub/contracts 0.6.0-pr-7 → 0.6.0-pr-9

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/queries.js CHANGED
@@ -293,6 +293,69 @@ export const sessionHistory = pin(describeQueryDefinition({
293
293
  * The Dungeon Crawler's Planner reads its player's lane so.
294
294
  */
295
295
  channelLane: S.text,
296
+ /**
297
+ * 🚧 **Firsthand** (opt-in, 2026-11-15) — wired
298
+ * `$.input.characterId`, the character a reply is spoken by on
299
+ * its own turn, the rows this node returns leave out what that
300
+ * member was not there for. Unwired: no filter, the node reads
301
+ * as it always did. A card-less character seat's turn is read
302
+ * from the session scope's `currentCastMemberId`, so wire
303
+ * `scope` too. Wired to anything that is not one character id
304
+ * (a narrator's turn, an envoy's, several characters, null)
305
+ * on a turn whose scope names no such member: nothing is left
306
+ * out, and the run's receipt says so.
307
+ *
308
+ * The rule, for one cast member on its own turn:
309
+ * 1. By scene — a member was there for a scene if it spoke at
310
+ * least once in it (hidden, rewound and swiped-away lines do
311
+ * not count). Its own lines are always kept; messages in no
312
+ * scene are kept; the open scene is kept for its speaker.
313
+ * 2. By place, when `firsthandBy` names a cast-level state slot
314
+ * — a member was there for a message when its value of that
315
+ * slot in force at that message equals the message speaker's
316
+ * value in force at it (references compare by `entryId`;
317
+ * words trimmed and case-folded). Only values set in the
318
+ * session count; a value known only from the lorebook's
319
+ * timeline counts as missing. A message whose speaker has
320
+ * no value falls under rule 1. With a slot named, rule 2
321
+ * decides wherever both values exist.
322
+ * 3. The receipt says how many rows were left out and why.
323
+ *
324
+ * ⚠ Not Bench (a benched member is still in the scene), not a
325
+ * scene's cast. A port, not a parameter: a spec writes the slot name as
326
+ * a literal in the node's config (as `generating` on the reply
327
+ * outlets); a `params` field would put a structural fact of the
328
+ * document in the panel as a knob.
329
+ *
330
+ * ⏳ transitional: superseded for scenes and days by the
331
+ * `speakerInCast` param; kept because a pipeline of a user's own
332
+ * may wire it.
333
+ * @experimental
334
+ */
335
+ firsthandFor: S.rowIds,
336
+ /**
337
+ * 🚧 **Firsthand, by place** (opt-in, 2026-11-15) — the
338
+ * cast-level stat, by full id or local name (as
339
+ * `stat-trail@1`'s `slotId`), that rule 2 of `firsthandFor`
340
+ * compares. Read only with `firsthandFor`; unwired, the rule is
341
+ * by scene alone. Same ⚠ as `firsthandFor`.
342
+ *
343
+ * ⏳ transitional: superseded for scenes and days by the
344
+ * `speakerInCast` param; kept because a pipeline of a user's own
345
+ * may wire it.
346
+ * @experimental
347
+ */
348
+ firsthandBy: S.text,
349
+ /**
350
+ * 🚧 **Outcome numbers** — wired, the genre's own Show outcomes
351
+ * field: `false` reads each outcome row as its result in words
352
+ * with no number (`metadata.diceWords`, stamped on every
353
+ * outcome row); anything else reads rows as written. Unwired:
354
+ * ⏳ the host reads the session's `showDice` field for that
355
+ * read (to retire with 0.7). Each read's own wiring decides.
356
+ * The rows themselves are never changed.
357
+ */
358
+ outcomeNumbers: S.json,
296
359
  },
297
360
  out: {
298
361
  /**
@@ -615,6 +678,34 @@ const bandIntentFieldsOf = (band) => {
615
678
  [`${band}Priority`]: f.priority,
616
679
  };
617
680
  };
681
+ /**
682
+ * 🚧 (wt-1b-fix2, 2026-11-17; name provisional) The `speakerInCast` param as
683
+ * every read that can hand a run a history entry declares it: the same boolean,
684
+ * default on, the same label; only the sentence under it fits the read.
685
+ */
686
+ const speakerInCastParam = (description) => ({
687
+ type: 'boolean',
688
+ default: true,
689
+ label: { en: 'Only scenes the speaker was in' },
690
+ description,
691
+ });
692
+ /**
693
+ * 🚧 ★ (cm-1-w4, 2026-11-19; name and label provisional) The `speakerMemory`
694
+ * param, declared on every read that declares `speakerInCast`, right after it
695
+ * (and on the two relationship nodes, which carry no `speakerInCast`):
696
+ * the same boolean, default on; only the sentence under it fits the read. On, a
697
+ * speaking character whose cast version has a Memory reads as of it (its
698
+ * *Remembers as of* line and date, and nothing before its *Nothing before*).
699
+ * Off, the speaker reads as the session does. A lorebook with its Timeline off
700
+ * has no Memory to apply, and a turn no single character speaks, such as the
701
+ * narrator's, reads everything: off or on, no effect there.
702
+ */
703
+ const speakerMemoryParam = (description) => ({
704
+ type: 'boolean',
705
+ default: true,
706
+ label: { en: 'Read as the speaker remembers' },
707
+ description,
708
+ });
618
709
  /** @public */
619
710
  export const lorebookTriggers = pin(describeQueryDefinition({
620
711
  id: 'core:query/lorebook-triggers@1',
@@ -766,6 +857,31 @@ export const lorebookTriggers = pin(describeQueryDefinition({
766
857
  lexicalScoring: LEXICAL_SCORING,
767
858
  trigramFolding: TRIGRAM_FOLDING,
768
859
  titleWeight: TITLE_WEIGHT,
860
+ /**
861
+ * 🚧 (kn-2a, 2026-11-16; name provisional) An entry marked *not common
862
+ * knowledge* is left out unless the speaker has a knowledge tie to it (any active
863
+ * tie from its cast binding that reads on the reply's line at the reply's date and
864
+ * is not *kept from*) or it is the place the speaker stands in; an entry a *kept
865
+ * from* tie wins for is left out, marked or not. The speaker is this read's own
866
+ * `speaker` in-port when wired, else the character the run speaks as (`scope`); a
867
+ * run that speaks as nobody (a narrator's turn, a routine, an action, an envoy, a
868
+ * step writing for several characters) has no speaker and the read returns
869
+ * everything. `false` turns it off for this node.
870
+ */
871
+ knownToSpeaker: {
872
+ type: 'boolean',
873
+ default: true,
874
+ label: { en: 'Only what the speaker knows' },
875
+ description: 'Leaves out the entries the speaking character does not know (marked not common knowledge with no knowledge tie to it, or kept from it; the place it stands in always counts as known), and does nothing on a turn no single character speaks, such as the narrator’s.',
876
+ },
877
+ /**
878
+ * 🚧 (wt-1b-fix2, 2026-11-17; name provisional) The same switch as on `history-entries@1`: the
879
+ * host's lore read judges every history day against the stored cast of the scenes compiled
880
+ * into it, for the read that asked, so a pipeline that turns it off must turn it off on every
881
+ * read. `false` turns it off for this node.
882
+ */
883
+ speakerInCast: speakerInCastParam('Shows a history day the speaking character missed part of as the summaries of the scenes whose cast lists it, and leaves out one it was in none of, among the entries these keywords bring in, and does nothing on a turn no single character speaks, such as the narrator’s.'),
884
+ speakerMemory: speakerMemoryParam('A speaking character with a Memory reads the entries these keywords bring in as of its Memory: its line and date, and nothing before its *Nothing before*.'),
769
885
  },
770
886
  },
771
887
  },
@@ -967,6 +1083,31 @@ const loreSlots = (band, defaults) => ({
967
1083
  // the owner it is all the panel shows.
968
1084
  ...bandIntentFields(band, defaults),
969
1085
  ...loreScanFields(),
1086
+ /**
1087
+ * 🚧 (kn-2a, 2026-11-16; name provisional) An entry marked *not common
1088
+ * knowledge* is left out unless the speaker has a knowledge tie to it (any active
1089
+ * tie from its cast binding that reads on the reply's line at the reply's date and
1090
+ * is not *kept from*) or it is the place the speaker stands in; an entry a *kept
1091
+ * from* tie wins for is left out, marked or not. The speaker is this read's own
1092
+ * `speaker` in-port when wired, else the character the run speaks as (`scope`); a
1093
+ * run that speaks as nobody (a narrator's turn, a routine, an action, an envoy, a
1094
+ * step writing for several characters) has no speaker and the read returns
1095
+ * everything. `false` turns it off for this node.
1096
+ */
1097
+ knownToSpeaker: {
1098
+ type: 'boolean',
1099
+ default: true,
1100
+ label: { en: 'Only what the speaker knows' },
1101
+ description: 'Leaves out the entries the speaking character does not know (marked not common knowledge with no knowledge tie to it, or kept from it; the place it stands in always counts as known), and does nothing on a turn no single character speaks, such as the narrator’s.',
1102
+ },
1103
+ /**
1104
+ * 🚧 (wt-1b-fix2, 2026-11-17; name provisional) The same switch as on `history-entries@1`: the
1105
+ * host's lore read judges every history day against the stored cast of the scenes compiled
1106
+ * into it, for the read that asked, so a pipeline that turns it off must turn it off on every
1107
+ * read. `false` turns it off for this node.
1108
+ */
1109
+ speakerInCast: speakerInCastParam('Shows a history day the speaking character missed part of as the summaries of the scenes whose cast lists it, and leaves out one it was in none of, among the entries this lane reads, and does nothing on a turn no single character speaks, such as the narrator’s.'),
1110
+ speakerMemory: speakerMemoryParam('A speaking character with a Memory reads the entries this lane reads as of its Memory: its line and date, and nothing before its *Nothing before*.'),
970
1111
  },
971
1112
  },
972
1113
  });
@@ -1081,6 +1222,20 @@ export const characterLore = pin(describeQueryDefinition({
1081
1222
  * a comment in that file warns about. The corpus mirrors the three lanes now.
1082
1223
  *
1083
1224
  * Same retrieval as its two siblings: one scan, one filter.
1225
+ *
1226
+ * 🚧 Opting in to the firsthand option is wiring `firsthandFor` (⏳ transitional,
1227
+ * see `speakerInCast`).
1228
+ *
1229
+ * 🚧 `speakerInCast` (param, on by default; name provisional): for a compiled
1230
+ * day, if the speaker is in the stored cast (`scene_characters`, role
1231
+ * participant) of every scene of this session compiled into it, the day's own
1232
+ * text; if it misses any, the summaries of the scenes whose cast lists it, in
1233
+ * story order, under the day's date, every one of them. A day it is in none of, or
1234
+ * whose kept scenes have no summary, is left out of the read itself. The host's
1235
+ * lore read judges it, so it holds however the day is found. A day with none
1236
+ * of this session's scenes is untouched. The speaker is the character the
1237
+ * run speaks as; a run that speaks as nobody, or a card in no seat, reads
1238
+ * everything. `false` turns it off for this node.
1084
1239
  * @experimental
1085
1240
  */
1086
1241
  export const historyEntries = pin(describeQueryDefinition({
@@ -1096,7 +1251,41 @@ export const historyEntries = pin(describeQueryDefinition({
1096
1251
  ports: {
1097
1252
  // No `text` in-port — see `lorebookTriggers`: the scan reads its
1098
1253
  // window through `scope` (culled 2026-09-16, R-12).
1099
- in: { scope: S.sessionScope },
1254
+ in: {
1255
+ scope: S.sessionScope,
1256
+ /**
1257
+ * 🚧 **Firsthand** (opt-in, 2026-11-15) — wired
1258
+ * `$.input.characterId`, an entry is left out when a scene of
1259
+ * this session compiled into it is one that member was not
1260
+ * there for. The rule, the unwired and not-one-character cases,
1261
+ * and the ⚠ are those of `core:query/session-history@1`'s
1262
+ * `firsthandFor`, plus: a scene counts as "was there for" by
1263
+ * `core:query/earlier-scenes@1`'s rule, and an entry with none
1264
+ * of this session's scenes is kept. A left-out entry is
1265
+ * published on `exclusions` with the reason, so
1266
+ * `core:task/eligibility@1` marks it ineligible whichever
1267
+ * mechanism found it; `main` and `hits` are unchanged. Unwired,
1268
+ * nothing changes.
1269
+ *
1270
+ * ⏳ transitional: superseded for scenes and days by the
1271
+ * `speakerInCast` param; kept because a pipeline of a user's own
1272
+ * may wire it.
1273
+ * @experimental
1274
+ */
1275
+ firsthandFor: S.rowIds,
1276
+ /**
1277
+ * 🚧 **Firsthand, by place** (opt-in, 2026-11-15) — as
1278
+ * `core:query/session-history@1`'s `firsthandBy`: the
1279
+ * cast-level stat rule 2 compares, read only with
1280
+ * `firsthandFor`.
1281
+ *
1282
+ * ⏳ transitional: superseded for scenes and days by the
1283
+ * `speakerInCast` param; kept because a pipeline of a user's own
1284
+ * may wire it.
1285
+ * @experimental
1286
+ */
1287
+ firsthandBy: S.text,
1288
+ },
1100
1289
  // Both open with a band-intent element — this lane's own — ahead
1101
1290
  // of the items; readers call `splitCandidates()`.
1102
1291
  out: {
@@ -1165,6 +1354,368 @@ export const castPresences = pin(describeQueryDefinition({
1165
1354
  },
1166
1355
  },
1167
1356
  }));
1357
+ /**
1358
+ * 🚧 **Minutes a round is worth** — the session's round worth, as a whole
1359
+ * number and as a clock step.
1360
+ *
1361
+ * It reads the session's `roundWorth` genre field from the settings document
1362
+ * (the cascade applied: the session's value, else its preset's, else the
1363
+ * genre's, else the field's default). `minutes` is a whole number ≥ 0; `step`
1364
+ * is `{ by: minutes, unit: 'minutes' }`, exactly what `core:task/clock-step@1`'s
1365
+ * `step` in-port takes; `main` is `{ minutes, step }`. All of it is 0 when the
1366
+ * genre places no `roundWorth` field (it has not opted in) or the session sets
1367
+ * 0 (off).
1368
+ *
1369
+ * It never reads or moves the clock and does not say whether one is set: gate
1370
+ * on `core:query/cast-presences@1`'s `at` for that.
1371
+ *
1372
+ * ⚠ Not the Dungeon Crawler Planner's round minutes (the time one round took,
1373
+ * judged), and not `core:task/clock-step@1`.
1374
+ * @experimental
1375
+ */
1376
+ export const roundWorth = pin(describeQueryDefinition({
1377
+ id: 'core:query/round-worth@1',
1378
+ i18n: { name: { en: 'Minutes a round is worth' } },
1379
+ timeoutMs: 2000,
1380
+ ports: {
1381
+ in: { scope: S.sessionScope },
1382
+ out: {
1383
+ /** `{ minutes, step }`. */
1384
+ main: S.json,
1385
+ /** The round worth as a whole number of minutes, ≥ 0. */
1386
+ minutes: S.json,
1387
+ /** `{ by: minutes, unit: 'minutes' }`: what `clock-step@1`'s `step` in-port takes. */
1388
+ step: S.json,
1389
+ },
1390
+ },
1391
+ }));
1392
+ /**
1393
+ * 🚧 **Where scenes begin** — the scenes routine's code-only look back over
1394
+ * each of the session's story lanes (every name here is provisional): `main`,
1395
+ * and each channel the genre declares with `lore: 'story'`, each with its own
1396
+ * rounds, anchor, open scene and boundary triggers.
1397
+ *
1398
+ * It walks a lane's standing lines up to the newest line that is at least
1399
+ * `depth` rounds old (a round as the turn order counts it), evaluates the
1400
+ * session's enabled boundary triggers line by line, and returns
1401
+ * `SceneBoundary[]` with `main`'s first, then each other lane's, each in line
1402
+ * order. **A query writes nothing.**
1403
+ *
1404
+ * Where the walk starts is derived, never stored: after the latest of the
1405
+ * channel's latest scene boundary, its latest decided or offered scene cue, and
1406
+ * a branch's last copied line. `routine` is the routine inlet's `routine` port
1407
+ * (the firing); its cadence's `n` bounds how far back a session with none of
1408
+ * those looks. `depth` keeps a line that is swiped, retaken or taken back from
1409
+ * ever being read.
1410
+ *
1411
+ * ⚠ Not the judged scene check (the sweep's model question) and not
1412
+ * `core:outlet/propose-scene-cue@1` (which places).
1413
+ * @experimental
1414
+ */
1415
+ export const sceneBoundaries = pin(describeQueryDefinition({
1416
+ id: 'core:query/scene-boundaries@1',
1417
+ i18n: { name: { en: 'Where scenes begin' } },
1418
+ timeoutMs: 5000,
1419
+ slots: {
1420
+ params: {
1421
+ kind: 'parameters',
1422
+ facet: 'behavior',
1423
+ schema: {
1424
+ depth: {
1425
+ type: 'integer',
1426
+ default: 2,
1427
+ min: 1,
1428
+ max: 50,
1429
+ label: { en: 'Rounds it waits' },
1430
+ description: {
1431
+ en: 'Only lines at least this many rounds old are read, so a line that is swiped, retaken or taken back is never read.',
1432
+ },
1433
+ },
1434
+ },
1435
+ },
1436
+ },
1437
+ ports: {
1438
+ in: { scope: S.sessionScope, routine: S.json },
1439
+ out: { main: S.json },
1440
+ },
1441
+ }));
1442
+ /**
1443
+ * 🚧 **The scene due a summary** — the scene summaries routine's code-only look
1444
+ * at the session's `main` channel (every name here is provisional).
1445
+ *
1446
+ * `main` is **the oldest** finished scene on `main` that is due a summary, as
1447
+ * its scene id (a number), or `null` when none is due. Due: it closed at least
1448
+ * `depth` rounds ago (a round as the turn order counts it), it is not
1449
+ * summarized, and nobody has decided about it — a summary a person saved, a
1450
+ * review a person discarded, a failed run, a run going or a review waiting are
1451
+ * never taken; the session's **Summaries** is not *Never*; and no turns are
1452
+ * taken back. At most one scene per run. **A query writes nothing.**
1453
+ *
1454
+ * ⚠ Not *Summarize all* (the app's `scenesToSummarize`: every unsummarized
1455
+ * scene, a person's press) and not `core:outlet/summarize-finished-scene@1`
1456
+ * (which starts the summary).
1457
+ * @experimental
1458
+ */
1459
+ export const sceneSummaryDue = pin(describeQueryDefinition({
1460
+ id: 'core:query/scene-summary-due@1',
1461
+ i18n: { name: { en: 'The scene due a summary' } },
1462
+ timeoutMs: 5000,
1463
+ slots: {
1464
+ params: {
1465
+ kind: 'parameters',
1466
+ facet: 'behavior',
1467
+ schema: {
1468
+ depth: {
1469
+ type: 'integer',
1470
+ default: 6,
1471
+ min: 1,
1472
+ max: 50,
1473
+ label: { en: 'Rounds after it ends' },
1474
+ description: {
1475
+ en: 'A scene is summarized once it ended at least this many rounds ago, so its lines have stopped changing.',
1476
+ },
1477
+ },
1478
+ },
1479
+ },
1480
+ },
1481
+ ports: {
1482
+ in: { scope: S.sessionScope },
1483
+ out: { main: S.json },
1484
+ },
1485
+ }));
1486
+ /**
1487
+ * 🚧 **Earlier scenes** — the summaries of this session's finished scenes, for
1488
+ * the block *Earlier in the story* (every name here is provisional).
1489
+ *
1490
+ * `main` is `{ maxTokens: number | null, scenes: Array<{ sceneId: number,
1491
+ * name: string, summary: string, firstLineId: number }> }`: the session's
1492
+ * closed `main`-channel scenes with a usable summary (`summaryStatus =
1493
+ * 'done'`, a person's or the routine's) that are not compiled into a history
1494
+ * entry, in story order (oldest first, by where each scene starts: its opening
1495
+ * line, else its smallest selected line), at most the newest 200. `name` is
1496
+ * the scene's name as shown; `firstLineId` is its first line's message id.
1497
+ * Each scene also carries `openedStoryClock: { year, month, day, hour, minute } | null`:
1498
+ * the session's story clock when the scene opened (columns `opened_story_clock_*`),
1499
+ * `null` when it opened with no clock, and `null` when the lorebook keeps no
1500
+ * timeline, whatever is stored.
1501
+ * `maxTokens` is `floor(share × budget.total)`, or `null` when `budget` is
1502
+ * unwired (then the block is not capped).
1503
+ *
1504
+ * Opt-in: wire `firsthandFor` (and `firsthandBy`) and the scenes the speaking
1505
+ * cast member was not there for are left out of `scenes` (⏳ transitional,
1506
+ * see `speakerInCast`).
1507
+ *
1508
+ * 🚧 `speakerInCast` (param, on by default; name provisional): only the scenes
1509
+ * whose stored cast (`scene_characters`, role participant) lists the speaker
1510
+ * are returned. An open scene is kept; a scene whose cast was never worked out
1511
+ * (no stored cast at all) is kept; so is one whose worked-out cast lists
1512
+ * nobody. The speaker is the character the run speaks
1513
+ * as (`scope`); a run that speaks as nobody, or a card in no seat, reads
1514
+ * everything. `false` turns it off for this node.
1515
+ *
1516
+ * It reads the story channel named by `channel` (`main` when absent).
1517
+ *
1518
+ * It returns data, never rendered text: `core:task/assemble@2` decides which
1519
+ * scenes show (only those whose first line is older than the first line the
1520
+ * prompt keeps) and fits them to `maxTokens`.
1521
+ *
1522
+ * ⚠ Not `core:query/scene-summary-due@1` (the routine's look, one scene), not
1523
+ * `core:spec/scene-summaries` (the routine that writes the summaries) and not
1524
+ * `core:query/session-history@1`. **A query writes nothing.**
1525
+ * @experimental
1526
+ */
1527
+ export const earlierScenes = pin(describeQueryDefinition({
1528
+ id: 'core:query/earlier-scenes@1',
1529
+ i18n: { name: { en: 'Earlier scenes' } },
1530
+ timeoutMs: 2000,
1531
+ slots: {
1532
+ params: {
1533
+ kind: 'parameters',
1534
+ facet: 'weights',
1535
+ schema: {
1536
+ share: {
1537
+ type: 'number',
1538
+ min: 0,
1539
+ max: 1,
1540
+ default: 0.15,
1541
+ label: { en: 'Share — earlier scenes' },
1542
+ description: {
1543
+ en: 'How much of the context window the summaries of earlier scenes may take. When they do not fit, the oldest are left out first.',
1544
+ },
1545
+ },
1546
+ speakerInCast: {
1547
+ type: 'boolean',
1548
+ default: true,
1549
+ label: { en: 'Only scenes the speaker was in' },
1550
+ description: 'Leaves out the earlier scenes whose cast does not list the speaking character (an open scene, and one whose cast was never worked out, are kept), and does nothing on a turn no single character speaks, such as the narrator’s.',
1551
+ },
1552
+ speakerMemory: speakerMemoryParam('A speaking character with a Memory leaves out the scenes before its *Nothing before*.'),
1553
+ },
1554
+ },
1555
+ },
1556
+ ports: {
1557
+ in: {
1558
+ scope: S.sessionScope,
1559
+ budget: S.budget,
1560
+ /**
1561
+ * 🚧 **Firsthand** (opt-in, 2026-11-15) — wired
1562
+ * `$.input.characterId`, the summaries this node returns leave
1563
+ * out the scenes that member was not there for. The rule, the
1564
+ * unwired and not-one-character cases, and the ⚠ are those of
1565
+ * `core:query/session-history@1`'s `firsthandFor`, plus: a
1566
+ * summary is kept for a member that was there for the scene's last
1567
+ * message or more than half of its messages, else left out. The
1568
+ * receipt says how many summaries were left out and why.
1569
+ *
1570
+ * ⏳ transitional: superseded for scenes and days by the
1571
+ * `speakerInCast` param; kept because a pipeline of a user's own
1572
+ * may wire it.
1573
+ * @experimental
1574
+ */
1575
+ firsthandFor: S.rowIds,
1576
+ /**
1577
+ * 🚧 **Firsthand, by place** (opt-in, 2026-11-15) — as
1578
+ * `core:query/session-history@1`'s `firsthandBy`: the
1579
+ * cast-level stat rule 2 compares, read only with
1580
+ * `firsthandFor`.
1581
+ *
1582
+ * ⏳ transitional: superseded for scenes and days by the
1583
+ * `speakerInCast` param; kept because a pipeline of a user's own
1584
+ * may wire it.
1585
+ * @experimental
1586
+ */
1587
+ firsthandBy: S.text,
1588
+ /**
1589
+ * 🚧 The story channel whose earlier scenes are read; absent: `main`.
1590
+ * A summary of one story channel never enters another channel's block (CP8).
1591
+ * @experimental
1592
+ */
1593
+ channel: S.text,
1594
+ },
1595
+ out: { main: S.json },
1596
+ },
1597
+ }));
1598
+ /**
1599
+ * 🚧 **Entries the lines name** — the entries the session already has whose
1600
+ * name or key appears in the lines a step read (every name here is
1601
+ * provisional).
1602
+ *
1603
+ * `main` is `Array<{ entryId: number, entryType: string, name: string,
1604
+ * content: string, byPerson: boolean }>`: the entries of `entryTypes` the
1605
+ * session reads (its own book first, then the attached lorebook, each as the
1606
+ * session reads it, held changes included; switched-off, archived and unseen
1607
+ * entries left out), whose name or one of whose keys appears as whole words
1608
+ * in one of `messages` (the SDK's `namesName`), in that order, at most
1609
+ * `maxEntries`, and within `floor(share × budget.total)` tokens when `budget`
1610
+ * is wired (an entry too long for what is left is left out, the next one
1611
+ * still tried). `content` is the whole text as the session reads it.
1612
+ * `byPerson` is true for an entry a person wrote (`provenance: "human"`).
1613
+ * `ids` is the `entryId` of each row of `main`, in order: what a write passes
1614
+ * as `create-lore-entry@1`'s `shown`. Deterministic, no model.
1615
+ *
1616
+ * ⚠ Not `core:query/entity-search@1` (ranked retrieval by annotated entities
1617
+ * over its own window), not `core:query/lorebook-entries@1` (the listing).
1618
+ * **A query writes nothing.**
1619
+ * @experimental
1620
+ */
1621
+ export const entriesNamed = pin(describeQueryDefinition({
1622
+ id: 'core:query/entries-named@1',
1623
+ i18n: { name: { en: 'Entries the lines name' } },
1624
+ timeoutMs: 2000,
1625
+ slots: {
1626
+ params: {
1627
+ kind: 'parameters',
1628
+ schema: {
1629
+ entryTypes: {
1630
+ type: 'list',
1631
+ item: { type: 'text' },
1632
+ label: { en: 'Entry types looked for' },
1633
+ description: {
1634
+ en: 'Which kinds of entry to look for, by type id. Leave it empty for world lore.',
1635
+ },
1636
+ },
1637
+ maxEntries: {
1638
+ type: 'integer',
1639
+ min: 0,
1640
+ default: 12,
1641
+ label: { en: 'Entries shown at most' },
1642
+ description: {
1643
+ en: 'How many existing entries the model is shown before it writes. 0 shows none.',
1644
+ },
1645
+ },
1646
+ share: {
1647
+ type: 'number',
1648
+ min: 0,
1649
+ max: 1,
1650
+ default: 0.2,
1651
+ label: { en: 'Share — entries shown' },
1652
+ description: {
1653
+ en: 'How much of the context window the entries shown may take. An entry too long to show whole is left out.',
1654
+ },
1655
+ },
1656
+ /**
1657
+ * 🚧 (kn-2a, 2026-11-16; name provisional) An entry marked *not common
1658
+ * knowledge* is left out unless the speaker has a knowledge tie to it (any active
1659
+ * tie from its cast binding that reads on the reply's line at the reply's date and
1660
+ * is not *kept from*) or it is the place the speaker stands in; an entry a *kept
1661
+ * from* tie wins for is left out, marked or not. The speaker is this read's own
1662
+ * `speaker` in-port when wired, else the character the run speaks as (`scope`); a
1663
+ * run that speaks as nobody (a narrator's turn, a routine, an action, an envoy, a
1664
+ * step writing for several characters) has no speaker and the read returns
1665
+ * everything. `false` turns it off for this node.
1666
+ */
1667
+ knownToSpeaker: {
1668
+ type: 'boolean',
1669
+ default: true,
1670
+ label: { en: 'Only what the speaker knows' },
1671
+ description: 'Leaves out the entries the speaking character does not know (marked not common knowledge with no knowledge tie to it, or kept from it; the place it stands in always counts as known), and does nothing on a turn no single character speaks, such as the narrator’s.',
1672
+ },
1673
+ /**
1674
+ * 🚧 (wt-1b-fix2, 2026-11-17; name provisional) The same switch as on `history-entries@1`: the
1675
+ * host's lore read judges every history day against the stored cast of the scenes compiled
1676
+ * into it, for the read that asked, so a pipeline that turns it off must turn it off on every
1677
+ * read. `false` turns it off for this node.
1678
+ */
1679
+ speakerInCast: speakerInCastParam('Shows a history day the speaking character missed part of as the summaries of the scenes whose cast lists it, and leaves out one it was in none of, among the entries found by name, and does nothing on a turn no single character speaks, such as the narrator’s.'),
1680
+ speakerMemory: speakerMemoryParam('A speaking character with a Memory reads the entries found by name as of its Memory: its line and date, and nothing before its *Nothing before*.'),
1681
+ },
1682
+ },
1683
+ },
1684
+ ports: {
1685
+ in: { scope: S.sessionScope, messages: S.messages, budget: S.budget },
1686
+ out: { main: S.json, ids: S.json },
1687
+ },
1688
+ }));
1689
+ /**
1690
+ * 🚧 **One cast member**, as the scope session reads them — their line, their
1691
+ * clock, the session's own notes over the book.
1692
+ *
1693
+ * `member` is `seated-member:<castMemberId>`, `player-seat:<seatId>` (that
1694
+ * seat's cast member), or a cast member id (a number) of the session's
1695
+ * lorebook or its own. Anything else, a seat with no cast member, or a member
1696
+ * the session doesn't read is refused with a sentence.
1697
+ *
1698
+ * `main` is `CastMemberV1` (`@serene-pub/sdk`): the member, the card version
1699
+ * they follow, which fields they follow, and the character profile as the
1700
+ * session reads it.
1701
+ * @experimental
1702
+ */
1703
+ export const castMember = pin(describeQueryDefinition({
1704
+ id: 'core:query/cast-member@1',
1705
+ i18n: { name: { en: 'Cast member' } },
1706
+ timeoutMs: 2000,
1707
+ ports: {
1708
+ in: {
1709
+ scope: S.sessionScope,
1710
+ /** `seated-member:<id>`, `player-seat:<id>`, or a cast member id. */
1711
+ member: S.json,
1712
+ },
1713
+ out: {
1714
+ /** `CastMemberV1`. */
1715
+ main: S.json,
1716
+ },
1717
+ },
1718
+ }));
1168
1719
  /** @experimental */
1169
1720
  export const vectorSearch = pin(describeQueryDefinition({
1170
1721
  id: 'core:query/vector-search@1',
@@ -1284,6 +1835,31 @@ export const vectorSearch = pin(describeQueryDefinition({
1284
1835
  label: { en: 'Discount weak matches' },
1285
1836
  description: 'How sharply a loose resemblance counts for less than a close one. 1 takes the similarity as it comes; higher pushes vague matches down without ever removing them, so they can still be found by a keyword or a name.',
1286
1837
  },
1838
+ /**
1839
+ * 🚧 (kn-2a, 2026-11-16; name provisional) An entry marked *not common
1840
+ * knowledge* is left out unless the speaker has a knowledge tie to it (any active
1841
+ * tie from its cast binding that reads on the reply's line at the reply's date and
1842
+ * is not *kept from*) or it is the place the speaker stands in; an entry a *kept
1843
+ * from* tie wins for is left out, marked or not. The speaker is this read's own
1844
+ * `speaker` in-port when wired, else the character the run speaks as (`scope`); a
1845
+ * run that speaks as nobody (a narrator's turn, a routine, an action, an envoy, a
1846
+ * step writing for several characters) has no speaker and the read returns
1847
+ * everything. `false` turns it off for this node.
1848
+ */
1849
+ knownToSpeaker: {
1850
+ type: 'boolean',
1851
+ default: true,
1852
+ label: { en: 'Only what the speaker knows' },
1853
+ description: 'Leaves out the entries the speaking character does not know (marked not common knowledge with no knowledge tie to it, or kept from it; the place it stands in always counts as known), and does nothing on a turn no single character speaks, such as the narrator’s.',
1854
+ },
1855
+ /**
1856
+ * 🚧 (wt-1b-fix2, 2026-11-17; name provisional) The same switch as on `history-entries@1`: the
1857
+ * host's lore read judges every history day against the stored cast of the scenes compiled
1858
+ * into it, for the read that asked, so a pipeline that turns it off must turn it off on every
1859
+ * read. `false` turns it off for this node.
1860
+ */
1861
+ speakerInCast: speakerInCastParam('Shows a history day the speaking character missed part of as the summaries of the scenes whose cast lists it, and leaves out one it was in none of, among the entries found by meaning, and does nothing on a turn no single character speaks, such as the narrator’s.'),
1862
+ speakerMemory: speakerMemoryParam('A speaking character with a Memory reads the entries found by meaning as of its Memory: its line and date, and nothing before its *Nothing before*.'),
1287
1863
  },
1288
1864
  },
1289
1865
  },
@@ -1450,6 +2026,31 @@ export const entitySearch = pin(describeQueryDefinition({
1450
2026
  label: { en: 'Strength' },
1451
2027
  description: 'How much weight a shared name carries against the other ways an entry can be found. 0 leaves the arm finding things and ranking them last.',
1452
2028
  },
2029
+ /**
2030
+ * 🚧 (kn-2a, 2026-11-16; name provisional) An entry marked *not common
2031
+ * knowledge* is left out unless the speaker has a knowledge tie to it (any active
2032
+ * tie from its cast binding that reads on the reply's line at the reply's date and
2033
+ * is not *kept from*) or it is the place the speaker stands in; an entry a *kept
2034
+ * from* tie wins for is left out, marked or not. The speaker is this read's own
2035
+ * `speaker` in-port when wired, else the character the run speaks as (`scope`); a
2036
+ * run that speaks as nobody (a narrator's turn, a routine, an action, an envoy, a
2037
+ * step writing for several characters) has no speaker and the read returns
2038
+ * everything. `false` turns it off for this node.
2039
+ */
2040
+ knownToSpeaker: {
2041
+ type: 'boolean',
2042
+ default: true,
2043
+ label: { en: 'Only what the speaker knows' },
2044
+ description: 'Leaves out the entries the speaking character does not know (marked not common knowledge with no knowledge tie to it, or kept from it; the place it stands in always counts as known), and does nothing on a turn no single character speaks, such as the narrator’s.',
2045
+ },
2046
+ /**
2047
+ * 🚧 (wt-1b-fix2, 2026-11-17; name provisional) The same switch as on `history-entries@1`: the
2048
+ * host's lore read judges every history day against the stored cast of the scenes compiled
2049
+ * into it, for the read that asked, so a pipeline that turns it off must turn it off on every
2050
+ * read. `false` turns it off for this node.
2051
+ */
2052
+ speakerInCast: speakerInCastParam('Shows a history day the speaking character missed part of as the summaries of the scenes whose cast lists it, and leaves out one it was in none of, among the entries found by name or description, and does nothing on a turn no single character speaks, such as the narrator’s.'),
2053
+ speakerMemory: speakerMemoryParam('A speaking character with a Memory reads the entries found by name or description as of its Memory: its line and date, and nothing before its *Nothing before*.'),
1453
2054
  },
1454
2055
  },
1455
2056
  },
@@ -1715,6 +2316,31 @@ export const entityLink = pin(describeQueryDefinition({
1715
2316
  label: { en: 'Most entries linked' },
1716
2317
  description: 'A ceiling on how many entries one turn may have matched to a description. The best matches are kept; this never brings in an entry nothing else found, it only changes where one comes in the order.',
1717
2318
  },
2319
+ /**
2320
+ * 🚧 (kn-2a, 2026-11-16; name provisional) An entry marked *not common
2321
+ * knowledge* is left out unless the speaker has a knowledge tie to it (any active
2322
+ * tie from its cast binding that reads on the reply's line at the reply's date and
2323
+ * is not *kept from*) or it is the place the speaker stands in; an entry a *kept
2324
+ * from* tie wins for is left out, marked or not. The speaker is this read's own
2325
+ * `speaker` in-port when wired, else the character the run speaks as (`scope`); a
2326
+ * run that speaks as nobody (a narrator's turn, a routine, an action, an envoy, a
2327
+ * step writing for several characters) has no speaker and the read returns
2328
+ * everything. `false` turns it off for this node.
2329
+ */
2330
+ knownToSpeaker: {
2331
+ type: 'boolean',
2332
+ default: true,
2333
+ label: { en: 'Only what the speaker knows' },
2334
+ description: 'Leaves out the entries the speaking character does not know (marked not common knowledge with no knowledge tie to it, or kept from it; the place it stands in always counts as known), and does nothing on a turn no single character speaks, such as the narrator’s.',
2335
+ },
2336
+ /**
2337
+ * 🚧 (wt-1b-fix2, 2026-11-17; name provisional) The same switch as on `history-entries@1`: the
2338
+ * host's lore read judges every history day against the stored cast of the scenes compiled
2339
+ * into it, for the read that asked, so a pipeline that turns it off must turn it off on every
2340
+ * read. `false` turns it off for this node.
2341
+ */
2342
+ speakerInCast: speakerInCastParam('Shows a history day the speaking character missed part of as the summaries of the scenes whose cast lists it, and leaves out one it was in none of, among the entries matched to a description, and does nothing on a turn no single character speaks, such as the narrator’s.'),
2343
+ speakerMemory: speakerMemoryParam('A speaking character with a Memory reads the entries matched to a description as of its Memory: its line and date, and nothing before its *Nothing before*.'),
1718
2344
  },
1719
2345
  },
1720
2346
  },
@@ -1837,7 +2463,7 @@ export const sessionSettings = pin(describeQueryDefinition({
1837
2463
  * that reads well and does nothing, which is what `session-history@1`'s dead
1838
2464
  * `template` slot already cost this codebase once.
1839
2465
  */
1840
- const relationshipSlots = (what) => ({
2466
+ const relationshipSlots = (what, speakerMemoryDescription) => ({
1841
2467
  params: {
1842
2468
  kind: 'parameters',
1843
2469
  facet: 'weights',
@@ -1885,6 +2511,11 @@ const relationshipSlots = (what) => ({
1885
2511
  en: `A ceiling on how many ${what} reach the prompt, closest first. Leave it empty for no ceiling; 0 leaves the section out altogether.`,
1886
2512
  },
1887
2513
  },
2514
+ ...(speakerMemoryDescription === undefined
2515
+ ? {}
2516
+ : {
2517
+ speakerMemory: speakerMemoryParam(speakerMemoryDescription),
2518
+ }),
1888
2519
  },
1889
2520
  },
1890
2521
  });
@@ -1909,7 +2540,7 @@ export const relationshipsPerspectives = pin(describeQueryDefinition({
1909
2540
  },
1910
2541
  optional: true,
1911
2542
  timeoutMs: RELATIONSHIP_TIMEOUT,
1912
- slots: relationshipSlots('of their own views'),
2543
+ slots: relationshipSlots('of their own views', 'A speaking character with a Memory reads its own views of the others as of its Memory: its line and date.'),
1913
2544
  ports: {
1914
2545
  in: { scope: S.sessionScope },
1915
2546
  /**
@@ -1944,7 +2575,7 @@ export const relationshipsKnown = pin(describeQueryDefinition({
1944
2575
  },
1945
2576
  optional: true,
1946
2577
  timeoutMs: RELATIONSHIP_TIMEOUT,
1947
- slots: relationshipSlots('views of them'),
2578
+ slots: relationshipSlots('views of them', 'A speaking character with a Memory reads how the others regard it as of its Memory: its line and date.'),
1948
2579
  ports: {
1949
2580
  in: { scope: S.sessionScope },
1950
2581
  out: { main: S.json, relationshipsKnown: S.json },
@@ -2072,6 +2703,31 @@ export const relationshipSearch = pin(describeQueryDefinition({
2072
2703
  en: 'Also offer the links one step from the lore this turn found — a room’s ways out, what an item belongs to. Off keeps the band to relationships between characters.',
2073
2704
  },
2074
2705
  },
2706
+ /**
2707
+ * 🚧 (kn-2a, 2026-11-16; name provisional) An entry marked *not common
2708
+ * knowledge* is left out unless the speaker has a knowledge tie to it (any active
2709
+ * tie from its cast binding that reads on the reply's line at the reply's date and
2710
+ * is not *kept from*) or it is the place the speaker stands in; an entry a *kept
2711
+ * from* tie wins for is left out, marked or not. The speaker is this read's own
2712
+ * `speaker` in-port when wired, else the character the run speaks as (`scope`); a
2713
+ * run that speaks as nobody (a narrator's turn, a routine, an action, an envoy, a
2714
+ * step writing for several characters) has no speaker and the read returns
2715
+ * everything. `false` turns it off for this node.
2716
+ */
2717
+ knownToSpeaker: {
2718
+ type: 'boolean',
2719
+ default: true,
2720
+ label: { en: 'Only what the speaker knows' },
2721
+ description: 'Leaves out the entries the speaking character does not know, and the links that lead to them (an entry marked not common knowledge with no knowledge tie to it, or kept from it; the place it stands in always counts as known), and does nothing on a turn no single character speaks, such as the narrator’s.',
2722
+ },
2723
+ /**
2724
+ * 🚧 (wt-1b-fix2, 2026-11-17; name provisional) The same switch as on `history-entries@1`: the
2725
+ * host's lore read judges every history day against the stored cast of the scenes compiled
2726
+ * into it, for the read that asked, so a pipeline that turns it off must turn it off on every
2727
+ * read. `false` turns it off for this node.
2728
+ */
2729
+ speakerInCast: speakerInCastParam('Shows a history day the speaking character missed part of as the summaries of the scenes whose cast lists it, and leaves out one it was in none of, among the entries the links lead to, and does nothing on a turn no single character speaks, such as the narrator’s.'),
2730
+ speakerMemory: speakerMemoryParam('A speaking character with a Memory reads the entries the links lead to as of its Memory: its line and date, and nothing before its *Nothing before*.'),
2075
2731
  },
2076
2732
  },
2077
2733
  },
@@ -2746,6 +3402,14 @@ export const graphScenes = pin(describeQueryDefinition({
2746
3402
  * declaration default, with absence meaning **inherit** rather than zero, and
2747
3403
  * derived slots computed rather than read.
2748
3404
  *
3405
+ * 🚧 Each `cast.byId` entry carries `ref` (the seat's participant reference,
3406
+ * as the host fills it), `castMemberId` (the seat's cast member) and `cardId`
3407
+ * (the member's active card on the timeline; null when card-less). A reader
3408
+ * looks an entry up by `ref` or `castMemberId` (or takes the owner's `key` off
3409
+ * `session-state@1`'s owners), never by building or parsing the key: it is an
3410
+ * opaque owner key — `player_seat:<id>`, 🚧 `seated_member:<id>` from the
3411
+ * flip, ⏳ the card id before it.
3412
+ *
2749
3413
  * A Query, and a plain one: what it is is a read. There is no as-of parameter
2750
3414
  * — this is the `current` view, and the temporal registry that would give the
2751
3415
  * other one is not built (see docs/stats-and-states.md).
@@ -2888,7 +3552,8 @@ export const lorebookState = pin(describeQueryDefinition({
2888
3552
  /**
2889
3553
  * One owner: `"world"`, `{ kind: 'cast_member', id }` or
2890
3554
  * `{ kind: 'location', id }` (the session kinds `session`,
2891
- * `session_cast`, `session_location` are translated). Optional.
3555
+ * 🚧 `seated_member`, ⏳ `session_cast`, `session_location` are
3556
+ * translated). Optional.
2892
3557
  */
2893
3558
  owner: S.json,
2894
3559
  /** 🚧 `'main'`, `'mostRecent'`, `'session'` or a branch id of this book. Optional. */
@@ -2953,7 +3618,8 @@ export const channelLane = pin(describeQueryDefinition({
2953
3618
  * recorded is dropped here, since it is already one of its points.
2954
3619
  *
2955
3620
  * Each point: `{ value, layer: 'session' | 'timeline', anchor, provenance }` —
2956
- * `anchor` is `{ messageId }` or `{ historyEntryId, date }`; `provenance` is
3621
+ * `anchor` is `{ messageId }` or `{ historyEntryId, date }` (`date` is `null` when
3622
+ * the lorebook keeps no timeline, whatever is stored); `provenance` is
2957
3623
  * `{ updatedBy, sessionId, messageId, sceneId, note, createdAt }` (who wrote
2958
3624
  * it: `user`, `run:<id>`, or `session:<id>` for write-back). The document is
2959
3625
  * `{ lorebookId, sessionId, branchId, owner, slotId, mode, tracked, points }`;
@@ -3434,6 +4100,31 @@ export const lorebookEntries = pin(describeQueryDefinition({
3434
4100
  label: { en: 'With each entry’s links' },
3435
4101
  description: 'Also list, on each entry, the links that lead from it to other entries — a room’s ways out, what it is inside — each said from that entry.',
3436
4102
  },
4103
+ /**
4104
+ * 🚧 (kn-2a, 2026-11-16; name provisional) An entry marked *not common
4105
+ * knowledge* is left out unless the speaker has a knowledge tie to it (any active
4106
+ * tie from its cast binding that reads on the reply's line at the reply's date and
4107
+ * is not *kept from*) or it is the place the speaker stands in; an entry a *kept
4108
+ * from* tie wins for is left out, marked or not. The speaker is this read's own
4109
+ * `speaker` in-port when wired, else the character the run speaks as (`scope`); a
4110
+ * run that speaks as nobody (a narrator's turn, a routine, an action, an envoy, a
4111
+ * step writing for several characters) has no speaker and the read returns
4112
+ * everything. `false` turns it off for this node.
4113
+ */
4114
+ knownToSpeaker: {
4115
+ type: 'boolean',
4116
+ default: true,
4117
+ label: { en: 'Only what the speaker knows' },
4118
+ description: 'Leaves out the entries the speaking character does not know, and the links that name them (an entry marked not common knowledge with no knowledge tie to it, or kept from it; the place it stands in always counts as known), and does nothing on a turn no single character speaks, such as the narrator’s.',
4119
+ },
4120
+ /**
4121
+ * 🚧 (wt-1b-fix2, 2026-11-17; name provisional) The same switch as on `history-entries@1`: the
4122
+ * host's lore read judges every history day against the stored cast of the scenes compiled
4123
+ * into it, for the read that asked, so a pipeline that turns it off must turn it off on every
4124
+ * read. `false` turns it off for this node.
4125
+ */
4126
+ speakerInCast: speakerInCastParam('Shows a history day the speaking character missed part of as the summaries of the scenes whose cast lists it, and leaves out one it was in none of, among the entries this read lists, and does nothing on a turn no single character speaks, such as the narrator’s.'),
4127
+ speakerMemory: speakerMemoryParam('A speaking character with a Memory reads the entries this read lists as of its Memory: its line and date, and nothing before its *Nothing before*.'),
3437
4128
  },
3438
4129
  },
3439
4130
  },