@serene-pub/contracts 0.6.0-pr-5 → 0.6.0-pr-7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/inlets.d.ts +183 -0
- package/dist/inlets.js +350 -2
- package/dist/oracles.d.ts +317 -4
- package/dist/oracles.js +235 -10
- package/dist/outlets.d.ts +618 -2
- package/dist/outlets.js +667 -11
- package/dist/queries.d.ts +278 -1
- package/dist/queries.js +301 -4
- package/dist/tasks.d.ts +736 -7
- package/dist/tasks.js +527 -7
- package/package.json +3 -3
package/dist/tasks.js
CHANGED
|
@@ -8,6 +8,7 @@ import { S, tf, IoKinds } from '@serene-pub/sdk';
|
|
|
8
8
|
import { handlebars, liquid } from '@serene-pub/sdk';
|
|
9
9
|
import { describeTaskDefinition, pin } from '@serene-pub/sdk';
|
|
10
10
|
import { PROMPT_BLOCKS_DECL } from '@serene-pub/sdk';
|
|
11
|
+
import { ASTERISK_READINGS, CUE_VOICES, DEFAULT_CUE_VOICES, DEFAULT_QUOTE_STYLES } from '@serene-pub/sdk';
|
|
11
12
|
// ── Tasks ───────────────────────────────────────────────────────────────────
|
|
12
13
|
/** @public */
|
|
13
14
|
export const contextBudget = pin(describeTaskDefinition({
|
|
@@ -59,7 +60,32 @@ export const contextBudget = pin(describeTaskDefinition({
|
|
|
59
60
|
},
|
|
60
61
|
},
|
|
61
62
|
},
|
|
62
|
-
ports: {
|
|
63
|
+
ports: {
|
|
64
|
+
/**
|
|
65
|
+
* 🚧 `blocks` (optional, 2026-10-16 — rulesets programme W3-S;
|
|
66
|
+
* additive, so `@1` evolves in place): labelled prompt blocks to fit
|
|
67
|
+
* into what `available` leaves — each `{ key, text, tokens,
|
|
68
|
+
* priority, depth, min, max, depths }`, where `depths` holds the
|
|
69
|
+
* block's text and tokens at each render depth it has (`full`,
|
|
70
|
+
* `summary`, `index`). The rule is **degrade depth before
|
|
71
|
+
* dropping**: under pressure the lowest-priority block steps down a
|
|
72
|
+
* depth (full → summary → index) before any block is dropped, and a
|
|
73
|
+
* block is dropped only at its shallowest depth, never below its
|
|
74
|
+
* `min`. `fittedBlocks` is the same records at the depth each
|
|
75
|
+
* landed on, dropped ones left out; absent `blocks`, it is absent.
|
|
76
|
+
*/
|
|
77
|
+
in: { blocks: S.json },
|
|
78
|
+
/**
|
|
79
|
+
* 🚧 `reads` (O9, 2026-10-21; additive, `@1` evolves in place):
|
|
80
|
+
* what the pair behind `connection` reads, by media kind — the
|
|
81
|
+
* same `ConnectionReadsV1` placement reads off its own slot. The
|
|
82
|
+
* budget already resolves that pair for its window, so a step that
|
|
83
|
+
* must know what the call can hear BEFORE placement (the
|
|
84
|
+
* transcribe step) reads it here rather than resolving the call's
|
|
85
|
+
* pair a second time. Null for an unwired slot.
|
|
86
|
+
*/
|
|
87
|
+
out: { main: S.budget, available: S.budget, fittedBlocks: S.json, reads: S.json },
|
|
88
|
+
},
|
|
63
89
|
}));
|
|
64
90
|
/**
|
|
65
91
|
* Fuse two mechanisms that answered the same question into one ordering.
|
|
@@ -2069,7 +2095,7 @@ export const buildSideCharacterContext = pin(describeTaskDefinition({
|
|
|
2069
2095
|
* (2026-09-29) — the narrator modal's text,
|
|
2070
2096
|
* which feeds both of its halves. `{{turnDirection}}`, on the
|
|
2071
2097
|
* terms `build-narrator-context@1` states; wired by
|
|
2072
|
-
* `core:spec/
|
|
2098
|
+
* `core:spec/story-side-character` alone, so a genre's voices
|
|
2073
2099
|
* (whose composer text is a line somebody said) render
|
|
2074
2100
|
* nothing new.
|
|
2075
2101
|
*/
|
|
@@ -2716,6 +2742,10 @@ export const turnUserSplit = pin(turnStrategy('core:task/turn-user-split@1', 'Ro
|
|
|
2716
2742
|
* @experimental
|
|
2717
2743
|
*/
|
|
2718
2744
|
export const turnScripted = pin(turnStrategy('core:task/turn-scripted@1', 'Scripted', {
|
|
2745
|
+
// A select script runs in the sandbox: the node routinely takes
|
|
2746
|
+
// 0.6–1.4 s end to end (2026-10-17, a Dungeon Crawler round timed out
|
|
2747
|
+
// at the strategies' 1 s), so this one strategy gets five.
|
|
2748
|
+
timeoutMs: 5000,
|
|
2719
2749
|
scriptPoints: [
|
|
2720
2750
|
{
|
|
2721
2751
|
key: 'select',
|
|
@@ -2737,6 +2767,67 @@ export const turnManual = pin(turnStrategy('core:task/turn-manual@1', 'Manual'))
|
|
|
2737
2767
|
* @experimental
|
|
2738
2768
|
*/
|
|
2739
2769
|
export const turnNarrator = pin(turnStrategy('core:task/turn-narrator@1', 'Narrator replies'));
|
|
2770
|
+
/**
|
|
2771
|
+
* 🚧 **Unprompted turns** (PLAN-genre-restructure §4, the voices group; lane
|
|
2772
|
+
* 2, 2026-10-19): what a genre's background tasks add to the order a
|
|
2773
|
+
* strategy prepared, after the round. Canon A9 holds — who speaks is state,
|
|
2774
|
+
* written by the turn-order spec and fired by auto-advance; nothing reads the
|
|
2775
|
+
* history to decide a reply elsewhere.
|
|
2776
|
+
*
|
|
2777
|
+
* Only when the round has ended (no AI entry still to fire) and somebody has
|
|
2778
|
+
* answered the person since their line, it puts ONE entry at the head, at
|
|
2779
|
+
* most once per round each:
|
|
2780
|
+
*
|
|
2781
|
+
* · `side-cast` on — a seated character who did not speak last speaks up
|
|
2782
|
+
* again (`{ ref: 'character:<id>', via: 'unprompted' }`); once any
|
|
2783
|
+
* character has spoken twice since the person's line, it is done;
|
|
2784
|
+
* · `narrator-interjections` on — the narrator adds a line
|
|
2785
|
+
* (`{ ref: null, via: 'unprompted', subject: <params.narrate> }`, the
|
|
2786
|
+
* genre's narrate action; a plain narrator reply when unset), unless a
|
|
2787
|
+
* narration already landed since the person's line.
|
|
2788
|
+
*
|
|
2789
|
+
* `modes` is `{ 'side-cast': …, 'narrator-interjections': … }` — `full` or
|
|
2790
|
+
* `off` each, the genre's voices settings as the turn-order spec reads them
|
|
2791
|
+
* (`core:script/unprompted-modes`, 2026-10-20; was the retired background
|
|
2792
|
+
* tasks' modes); a key absent or `off` adds nothing, so the order passes
|
|
2793
|
+
* through untouched — a session with neither on gets exactly its strategy's
|
|
2794
|
+
* order. Pure.
|
|
2795
|
+
* @experimental
|
|
2796
|
+
*/
|
|
2797
|
+
export const turnUnprompted = pin(describeTaskDefinition({
|
|
2798
|
+
id: 'core:task/turn-unprompted@1',
|
|
2799
|
+
i18n: { name: { en: 'Unprompted turns' } },
|
|
2800
|
+
timeoutMs: 1000,
|
|
2801
|
+
slots: {
|
|
2802
|
+
params: {
|
|
2803
|
+
kind: 'parameters',
|
|
2804
|
+
facet: 'behavior',
|
|
2805
|
+
schema: {
|
|
2806
|
+
narrate: {
|
|
2807
|
+
type: 'string',
|
|
2808
|
+
default: '',
|
|
2809
|
+
label: { en: 'Narrator action' },
|
|
2810
|
+
description: {
|
|
2811
|
+
en: "The action a narrator's own line fires, as '<spec>#<key>'. Empty: an ordinary reply in the narrator's voice.",
|
|
2812
|
+
},
|
|
2813
|
+
},
|
|
2814
|
+
},
|
|
2815
|
+
},
|
|
2816
|
+
},
|
|
2817
|
+
ports: {
|
|
2818
|
+
in: {
|
|
2819
|
+
/** What the strategy prepared. */
|
|
2820
|
+
order: S.turnEntries,
|
|
2821
|
+
/** Who may be seated — the pool's output. */
|
|
2822
|
+
candidates: S.turnCandidates,
|
|
2823
|
+
/** The session's visible history, ascending. */
|
|
2824
|
+
messages: S.messages,
|
|
2825
|
+
/** `{ 'side-cast', 'narrator-interjections' }` → `full` | `off`: the genre's voices settings. */
|
|
2826
|
+
modes: S.json,
|
|
2827
|
+
},
|
|
2828
|
+
out: { main: S.turnEntries, order: S.turnEntries },
|
|
2829
|
+
},
|
|
2830
|
+
}));
|
|
2740
2831
|
/**
|
|
2741
2832
|
* The pool: who *may* be seated this recompute, from the settings
|
|
2742
2833
|
* document's cast and the history.
|
|
@@ -3309,7 +3400,7 @@ export const makeChoices = pin(describeTaskDefinition({
|
|
|
3309
3400
|
fn: S.text,
|
|
3310
3401
|
/**
|
|
3311
3402
|
* The identity of the declaration the options fire, when it is
|
|
3312
|
-
* another spec's (`core:spec/
|
|
3403
|
+
* another spec's (`core:spec/story-answer#answer`). Absent,
|
|
3313
3404
|
* the host stamps this spec's own declaration for `fn` at the
|
|
3314
3405
|
* write.
|
|
3315
3406
|
*/
|
|
@@ -4625,9 +4716,11 @@ export const runScript = pin(describeTaskDefinition({
|
|
|
4625
4716
|
* The time each script in the chain may take.
|
|
4626
4717
|
* Read by the HOST's script applier off the scope chain, not by the
|
|
4627
4718
|
* binding — the binding never sees the chain. A script past it is
|
|
4628
|
-
* stopped and recorded `err` with the time in its reason, and the
|
|
4629
|
-
*
|
|
4630
|
-
*
|
|
4719
|
+
* stopped and recorded `err` with the time in its reason, and 🚧 the
|
|
4720
|
+
* step HALTS with that reason (2026-10-19): a script step's answer
|
|
4721
|
+
* is its script's, and handing its own input on as that answer
|
|
4722
|
+
* reached the next step as nonsense. Unset, the seam default
|
|
4723
|
+
* applies (the same 250 ms).
|
|
4631
4724
|
*/
|
|
4632
4725
|
params: {
|
|
4633
4726
|
kind: 'parameters',
|
|
@@ -4640,7 +4733,7 @@ export const runScript = pin(describeTaskDefinition({
|
|
|
4640
4733
|
default: 250,
|
|
4641
4734
|
label: { en: 'Script time limit (ms)' },
|
|
4642
4735
|
description: {
|
|
4643
|
-
en: 'How long each script in this step may run. A script that runs longer is stopped, and the
|
|
4736
|
+
en: 'How long each script in this step may run. A script that runs longer is stopped, and the step stops with it.',
|
|
4644
4737
|
},
|
|
4645
4738
|
},
|
|
4646
4739
|
},
|
|
@@ -4651,4 +4744,431 @@ export const runScript = pin(describeTaskDefinition({
|
|
|
4651
4744
|
out: { main: S.json },
|
|
4652
4745
|
},
|
|
4653
4746
|
}));
|
|
4747
|
+
/**
|
|
4748
|
+
* 🚧 **Resolve a ruleset** — the one handler every genre calls to read and
|
|
4749
|
+
* apply a session's ruleset (rulesets programme, P1 contract stub).
|
|
4750
|
+
*
|
|
4751
|
+
* Ruleset-agnostic: it reads whichever ruleset the session has from the
|
|
4752
|
+
* registry (`defineRuleset`), at the rigour it is handed, in a fixed phase
|
|
4753
|
+
* order (base → piece effects → derived → bridges → prose render). A genre's
|
|
4754
|
+
* spec supplies only the moment:
|
|
4755
|
+
*
|
|
4756
|
+
* · `resolve` — before a model call: labelled prompt blocks and the facts a
|
|
4757
|
+
* step may need. No dice.
|
|
4758
|
+
* · `apply` — after the model proposes: validates the `deltas`, rolls what
|
|
4759
|
+
* must be rolled (seeded — hence `declaresRandomness`), and returns the
|
|
4760
|
+
* outcomes, the explain trace and the deltas it refused.
|
|
4761
|
+
* · `advance` — `apply` with no deltas and an `elapsed` amount (a rest, a
|
|
4762
|
+
* journey, a scene break).
|
|
4763
|
+
*
|
|
4764
|
+
* `blocks` is a record of labelled variables — `voice`, `sheet`, `pieces`,
|
|
4765
|
+
* `ties`, `outcomes`, `custom` — which a context template places by name;
|
|
4766
|
+
* the handler never writes into a prompt itself. `explain` is for receipts
|
|
4767
|
+
* and ledgers, never a prompt. Bound by the app since 2026-10-17 (no longer
|
|
4768
|
+
* provisional — the Dungeon Crawler create spec seeds it).
|
|
4769
|
+
* @experimental
|
|
4770
|
+
*/
|
|
4771
|
+
export const rulesetResolve = pin(describeTaskDefinition({
|
|
4772
|
+
id: 'core:task/ruleset-resolve@1',
|
|
4773
|
+
i18n: {
|
|
4774
|
+
name: { en: 'Resolve a ruleset' },
|
|
4775
|
+
description: {
|
|
4776
|
+
en: "Reads the session's ruleset for the owners it is given, at the rigour it is given: prompt blocks before a reply, validated changes and rolled outcomes after one.",
|
|
4777
|
+
},
|
|
4778
|
+
},
|
|
4779
|
+
timeoutMs: 5000,
|
|
4780
|
+
declaresRandomness: true,
|
|
4781
|
+
slots: {
|
|
4782
|
+
params: {
|
|
4783
|
+
kind: 'parameters',
|
|
4784
|
+
facet: 'behavior',
|
|
4785
|
+
schema: {
|
|
4786
|
+
/**
|
|
4787
|
+
* 🚧 D3 (2026-10-23): whether the events this step's
|
|
4788
|
+
* functions raise are emitted after the run's receipt. Off:
|
|
4789
|
+
* they are reported on `facts` and never emitted. The
|
|
4790
|
+
* pipeline's own switch (`SpecDocument.functionEvents`)
|
|
4791
|
+
* turns off every step's at once.
|
|
4792
|
+
*/
|
|
4793
|
+
emits: {
|
|
4794
|
+
type: 'boolean',
|
|
4795
|
+
default: true,
|
|
4796
|
+
label: { en: 'Emit what its functions raise' },
|
|
4797
|
+
description: {
|
|
4798
|
+
en: "The events the ruleset's functions raise in this step are emitted once the run is saved. Off: they are only reported.",
|
|
4799
|
+
},
|
|
4800
|
+
},
|
|
4801
|
+
},
|
|
4802
|
+
},
|
|
4803
|
+
},
|
|
4804
|
+
ports: {
|
|
4805
|
+
in: {
|
|
4806
|
+
/**
|
|
4807
|
+
* The session the call reads — its ruleset, setting values and
|
|
4808
|
+
* owners when `owners` names none. Added 2026-10-16 (W3-S) so a
|
|
4809
|
+
* call that is not handed owners still knows its session; `@1`
|
|
4810
|
+
* evolves in place.
|
|
4811
|
+
*/
|
|
4812
|
+
scope: S.sessionScope,
|
|
4813
|
+
/** The owners resolved this turn — the acting cast, the scene's place. */
|
|
4814
|
+
owners: S.json,
|
|
4815
|
+
/** `prose`, `mechanics` or `scripts`; else the session's rigour. */
|
|
4816
|
+
rigour: S.text,
|
|
4817
|
+
/**
|
|
4818
|
+
* `resolve`, `apply` or `advance` — or 🚧 `propose` (lane 2,
|
|
4819
|
+
* 2026-10-19): `apply` whose every change is filed for review
|
|
4820
|
+
* (`state_proposals`) rather than applied, for a task on Review.
|
|
4821
|
+
*/
|
|
4822
|
+
mode: S.text,
|
|
4823
|
+
/** The turn's declared actions — what selects the pieces in play. */
|
|
4824
|
+
actions: S.json,
|
|
4825
|
+
/** `apply`: the changes the model proposed, to validate. */
|
|
4826
|
+
deltas: S.json,
|
|
4827
|
+
/** `advance` (or `apply`): story time passed, in the ruleset's unit. */
|
|
4828
|
+
elapsed: S.json,
|
|
4829
|
+
/**
|
|
4830
|
+
* 🚧 **Whose eyes** the blocks are for (2026-10-17): a participant
|
|
4831
|
+
* reference, or `gm` for the game-master-facing step. Decides
|
|
4832
|
+
* what a repertoire's `earshot` and `gmOnly` let into `blocks` —
|
|
4833
|
+
* a holder's own pieces into their voice, the creatures a
|
|
4834
|
+
* player never reads into the Narrator's. Unwired: everyone's
|
|
4835
|
+
* view, which carries nothing marked for the holder or the GM.
|
|
4836
|
+
*/
|
|
4837
|
+
viewer: S.text,
|
|
4838
|
+
/**
|
|
4839
|
+
* 🚧 D3 (2026-10-23): the event that woke the step — `{ id,
|
|
4840
|
+
* payload }` — when a registration or routine runs it on one;
|
|
4841
|
+
* what a function's handler reads as `ctx.event`. Unwired: none.
|
|
4842
|
+
*/
|
|
4843
|
+
event: S.json,
|
|
4844
|
+
},
|
|
4845
|
+
out: {
|
|
4846
|
+
/** Labelled variables: `voice`, `sheet`, `pieces`, `ties`, `outcomes`, `custom`. */
|
|
4847
|
+
blocks: S.json,
|
|
4848
|
+
/** What a step may need: targets, what is equipped, what is allowed this turn. */
|
|
4849
|
+
facts: S.json,
|
|
4850
|
+
/** `apply` / `advance`: rolls, degrees and totals, each with its origins. */
|
|
4851
|
+
outcomes: S.json,
|
|
4852
|
+
/** How each number was reached — for receipts and ledgers, never a prompt. */
|
|
4853
|
+
explain: S.json,
|
|
4854
|
+
/** Proposed changes the mechanics refused, with why — review items, never silent corrections. */
|
|
4855
|
+
rejected: S.json,
|
|
4856
|
+
/**
|
|
4857
|
+
* 🚧 D7 (2026-10-23): the JSON Schema a reply that carries changes
|
|
4858
|
+
* answers against — `{ message, changes }`, built from the
|
|
4859
|
+
* session's ruleset (`facts.replySchema`) — when the step's
|
|
4860
|
+
* `actions` asked for it (`{ replyShape: true }`); else null.
|
|
4861
|
+
*/
|
|
4862
|
+
replySchema: S.json,
|
|
4863
|
+
},
|
|
4864
|
+
},
|
|
4865
|
+
}));
|
|
4866
|
+
/**
|
|
4867
|
+
* One duty a routine or a reply may be asked to do, as its pipeline's own
|
|
4868
|
+
* setting (PLAN-layering §5, R1, A6): a switch the session's owner sees
|
|
4869
|
+
* (`reach: 'owner'`), on or off. `on`/`off` only — *how* a duty's writes land
|
|
4870
|
+
* (applied, or held for review) is the routine's **mode** (R37), never the
|
|
4871
|
+
* duty's.
|
|
4872
|
+
*/
|
|
4873
|
+
const duty = (label, description, on) => ({
|
|
4874
|
+
type: 'boolean',
|
|
4875
|
+
default: on,
|
|
4876
|
+
reach: 'owner',
|
|
4877
|
+
label: { en: label },
|
|
4878
|
+
description: { en: description },
|
|
4879
|
+
});
|
|
4880
|
+
/**
|
|
4881
|
+
* The out-ports every duties step publishes: `modes` (each duty's key →
|
|
4882
|
+
* `full` · `review` · `off`, what a junction reads by `path` and a script by
|
|
4883
|
+
* key), `any` (true when any duty is on) and `main` (both, as one document).
|
|
4884
|
+
*/
|
|
4885
|
+
const dutyPorts = {
|
|
4886
|
+
in: {
|
|
4887
|
+
/**
|
|
4888
|
+
* The routine's firing (`core:inlet/routine@1`'s `routine` port) — its
|
|
4889
|
+
* `mode` is what an on duty runs at: `full` applies, `review` holds
|
|
4890
|
+
* each write for the owner. Unwired (a reply's duties): `full`.
|
|
4891
|
+
*/
|
|
4892
|
+
routine: S.json,
|
|
4893
|
+
},
|
|
4894
|
+
out: {
|
|
4895
|
+
main: S.json,
|
|
4896
|
+
/** `{ [duty key]: 'full' | 'review' | 'off' }`, keyed as the steps that read them name them. */
|
|
4897
|
+
modes: S.json,
|
|
4898
|
+
/** True when any duty is on — the routine has something to do. */
|
|
4899
|
+
any: S.json,
|
|
4900
|
+
},
|
|
4901
|
+
};
|
|
4902
|
+
/**
|
|
4903
|
+
* 🚧 **What a reply reads** (PLAN-layering §4, R1, A6; 2026-10-20) — the
|
|
4904
|
+
* reply's own duties, a switch each, read where the reply branches: *Read the
|
|
4905
|
+
* lorebook* gates what retrieval hands the ranker, *Read the scene* gates
|
|
4906
|
+
* what the context builder is told about where the story is. Neither costs a
|
|
4907
|
+
* call. 🚧 *Replies carry changes* (PLAN-rulesets-functions D7, R7;
|
|
4908
|
+
* 2026-10-23; off): the reply is one JSON object — its words and what the
|
|
4909
|
+
* scene changed of the rules' attributes and entries — and the rules apply
|
|
4910
|
+
* the changes (owner ruling 2026-10-23: no review of a reply's changes; how
|
|
4911
|
+
* strict the rules are and the lore write modes decide what lands, and a
|
|
4912
|
+
* replaced reply's changes go with it). Publishes `modes` keyed `lore-retrieval`,
|
|
4913
|
+
* `scene-reading` and `reply-changes` (each `full` or `off`). Pure; no
|
|
4914
|
+
* model call.
|
|
4915
|
+
*
|
|
4916
|
+
* Was the reply group of the retired background tasks (`resolve-tasks@1`):
|
|
4917
|
+
* a reply's settings belong to the reply (A6), so a preset that swaps the
|
|
4918
|
+
* reply for another shows that one's settings instead (§5).
|
|
4919
|
+
* @experimental
|
|
4920
|
+
*/
|
|
4921
|
+
export const replyDuties = pin(describeTaskDefinition({
|
|
4922
|
+
id: 'core:task/reply-duties@1',
|
|
4923
|
+
i18n: {
|
|
4924
|
+
name: { en: 'What the reply reads' },
|
|
4925
|
+
description: {
|
|
4926
|
+
en: 'Switches for what the reply reads besides the conversation: the lorebook, and where the story is. Neither costs a model call.',
|
|
4927
|
+
},
|
|
4928
|
+
},
|
|
4929
|
+
timeoutMs: 500,
|
|
4930
|
+
slots: {
|
|
4931
|
+
params: {
|
|
4932
|
+
kind: 'parameters',
|
|
4933
|
+
facet: 'behavior',
|
|
4934
|
+
schema: {
|
|
4935
|
+
lore: duty('Read the lorebook', 'Finds the lorebook entries the scene calls for and puts them in the reply’s context.', true),
|
|
4936
|
+
scene: duty('Read the scene', 'Puts where the story is — the place, what it is like, the ways out — into the reply’s context. Writes nothing.', true),
|
|
4937
|
+
changes: duty('Replies carry changes', 'The reply comes back with what the scene changed — a value up or down, something gained or lost — beside its words, and the rules apply it. Swiping, regenerating or deleting the reply takes it back.', false),
|
|
4938
|
+
},
|
|
4939
|
+
},
|
|
4940
|
+
},
|
|
4941
|
+
ports: dutyPorts,
|
|
4942
|
+
}));
|
|
4943
|
+
/**
|
|
4944
|
+
* 🚧 **Note what changed** (PLAN-layering §4, R5, R37; 2026-10-20; titled by
|
|
4945
|
+
* the routine's name since 2026-10-23, PLAN-genres-seams S7 — was *What the
|
|
4946
|
+
* reckoning keeps*) — the duties of a reckoning routine (Story's
|
|
4947
|
+
* `core:spec/story-reckoning`; the Lair's keeper titles its own card):
|
|
4948
|
+
* one JSON call after a turn or a round that notes what the story made true.
|
|
4949
|
+
* Each duty is a switch; the routine's mode decides whether what an on duty
|
|
4950
|
+
* finds is applied (`full`) or held for review (`review`). Publishes `modes`
|
|
4951
|
+
* keyed `attributes`, `conditions`, `time`, `places-on-move`, `timed-expiry`
|
|
4952
|
+
* — the keys the reckoning's scripts and junctions read — and `any`.
|
|
4953
|
+
*
|
|
4954
|
+
* *End what runs out* (`timed-expiry`) and *Track conditions* are also what
|
|
4955
|
+
* the ruleset handler's expiry reads (the host, lane 6). A duty that writes
|
|
4956
|
+
* a lorebook (*Describe new places*) reads Off in a session with none.
|
|
4957
|
+
* Pure; no model call.
|
|
4958
|
+
* @experimental
|
|
4959
|
+
*/
|
|
4960
|
+
export const reckoningDuties = pin(describeTaskDefinition({
|
|
4961
|
+
id: 'core:task/reckoning-duties@1',
|
|
4962
|
+
i18n: {
|
|
4963
|
+
name: { en: 'Note what changed' },
|
|
4964
|
+
description: {
|
|
4965
|
+
en: 'Switches for what is noted after the story moves: the sheets, conditions, the clock, new places, what runs out. How the changes land is the routine’s mode.',
|
|
4966
|
+
},
|
|
4967
|
+
},
|
|
4968
|
+
timeoutMs: 500,
|
|
4969
|
+
slots: {
|
|
4970
|
+
params: {
|
|
4971
|
+
kind: 'parameters',
|
|
4972
|
+
facet: 'behavior',
|
|
4973
|
+
schema: {
|
|
4974
|
+
attributes: duty('Keep the sheets', 'Notes what the story changed about health, mood, belongings and the place, and updates the sheets.', true),
|
|
4975
|
+
conditions: duty('Track conditions', 'Puts conditions on and takes them off: hurt, tired, poisoned, inspired.', true),
|
|
4976
|
+
time: duty('Move the clock', 'Moves the story clock by as much time as the story took.', true),
|
|
4977
|
+
placesOnMove: duty('Describe new places', 'When the story moves somewhere new, files the place and its ways out.', true),
|
|
4978
|
+
timedExpiry: duty('End what runs out', 'Ends conditions and effects when their time is up.', true),
|
|
4979
|
+
},
|
|
4980
|
+
},
|
|
4981
|
+
},
|
|
4982
|
+
ports: dutyPorts,
|
|
4983
|
+
}));
|
|
4984
|
+
/**
|
|
4985
|
+
* 🚧 **Look back over the story** (PLAN-layering §4, R5, R37; 2026-10-20;
|
|
4986
|
+
* titled by the routine's name since 2026-10-23, S7 — was *What the sweep
|
|
4987
|
+
* files*) — the duties of a sweep routine (Story's `core:spec/story-sweep`): ONE batched
|
|
4988
|
+
* JSON call every few turns that looks back over the story and files what is
|
|
4989
|
+
* worth keeping. Each duty is a switch; the routine's mode decides whether
|
|
4990
|
+
* what it files is written (`full`) or held for review (`review`). Publishes
|
|
4991
|
+
* `modes` keyed `summary`, `lore`, `cast`, `relationships`, `world-state`,
|
|
4992
|
+
* `scenes`, `goals`, `goal-reached`, `scene-moved-on` — the keys the sweep's scripts and
|
|
4993
|
+
* junctions read — and `any`. Duties that write a lorebook read Off in a
|
|
4994
|
+
* session with none. *Mark goals reached* (`goal-reached`) is read by the
|
|
4995
|
+
* host when the goals note moves (lane 6). Pure; no model call.
|
|
4996
|
+
* @experimental
|
|
4997
|
+
*/
|
|
4998
|
+
export const sweepDuties = pin(describeTaskDefinition({
|
|
4999
|
+
id: 'core:task/sweep-duties@1',
|
|
5000
|
+
i18n: {
|
|
5001
|
+
name: { en: 'Look back over the story' },
|
|
5002
|
+
description: {
|
|
5003
|
+
en: 'Switches for what is filed every few turns: a summary, lore, people, how they stand, the world, places, goals. How it lands is the routine’s mode.',
|
|
5004
|
+
},
|
|
5005
|
+
},
|
|
5006
|
+
timeoutMs: 500,
|
|
5007
|
+
slots: {
|
|
5008
|
+
params: {
|
|
5009
|
+
kind: 'parameters',
|
|
5010
|
+
facet: 'behavior',
|
|
5011
|
+
schema: {
|
|
5012
|
+
summary: duty('Summarize the story', 'Files a summary of what happened in the lorebook’s history.', true),
|
|
5013
|
+
lore: duty('Add to the lore', 'Files new facts the story established as lorebook entries.', true),
|
|
5014
|
+
cast: duty('Note new people', 'Files the people the story introduced as lorebook entries.', true),
|
|
5015
|
+
relationships: duty('Track relationships', 'Proposes how the characters now stand with each other, for you to look over.', false),
|
|
5016
|
+
worldState: duty('Keep the world', 'Updates the world’s state from what happened: where the story is, the time of day, the weather.', true),
|
|
5017
|
+
scenes: duty('File the places', 'Files each place the story used as a place in the lorebook.', false),
|
|
5018
|
+
goals: duty('Track goals', 'Keeps a running note of what the characters are after and how close they are.', false),
|
|
5019
|
+
goalReached: duty('Mark goals reached', 'When a goal in the goals note is ticked, says so in the story and tells everyone in the session.', false),
|
|
5020
|
+
sceneMovedOn: duty('Notice when the scene moves on', 'Looks over the lines since the last look for where the story moved on to a new scene, and suggests one there — or starts it, when this session’s scenes are Automatic.', true),
|
|
5021
|
+
},
|
|
5022
|
+
},
|
|
5023
|
+
},
|
|
5024
|
+
ports: {
|
|
5025
|
+
in: dutyPorts.in,
|
|
5026
|
+
out: {
|
|
5027
|
+
...dutyPorts.out,
|
|
5028
|
+
/** 🚧 A \`JudgedSceneCheck\` (pass 7, R-i): what *Notice when the scene moves on* may judge this run — not due when the duty is Off or the host's conditions do not hold. */
|
|
5029
|
+
sceneCheck: S.json,
|
|
5030
|
+
},
|
|
5031
|
+
},
|
|
5032
|
+
}));
|
|
5033
|
+
// ── 🚧 Speech (PLAN-speech-build S3, 2026-10-28) ────────────────────────────
|
|
5034
|
+
/** The three voices a cue may take, as the picker shows them. */
|
|
5035
|
+
const CUE_VOICE_MEMBERS = [
|
|
5036
|
+
{ key: 'speaker', label: { en: "The speaker's voice" } },
|
|
5037
|
+
{ key: 'narrator', label: { en: "The narrator's voice" } },
|
|
5038
|
+
{ key: 'silent', label: { en: 'Not spoken' } },
|
|
5039
|
+
];
|
|
5040
|
+
/**
|
|
5041
|
+
* 🚧 **Cue a line** — turn a line's text into the script it is spoken from
|
|
5042
|
+
* (`Cue[]`, PLAN-speech-connections-and-timbre §11.1). Pure and deterministic:
|
|
5043
|
+
* regex and locale tables, the same text giving the same cues, no model.
|
|
5044
|
+
*
|
|
5045
|
+
* - a quote opens **dialogue** (`quoteStyles`); `*…*` / `_…_` are **action**
|
|
5046
|
+
* (`asterisks`); `(…)` is an **aside**; the rest is **narration**;
|
|
5047
|
+
* - `Name:` at the start of a run, where the name is one of `cast`, switches
|
|
5048
|
+
* the cue's `speaker` (multi-voice lines);
|
|
5049
|
+
* - inline expression markers the model wrote — `[angry]`, `<laugh>`,
|
|
5050
|
+
* `*sighs*`, `(((word)))` — are lifted off the text into `markers`, never
|
|
5051
|
+
* spoken; a marker the shipped marker table knows sets that cue's
|
|
5052
|
+
* inflection, else the line's `inflection` label does (§11.2);
|
|
5053
|
+
* - `voices` maps each kind to a voice; code blocks are dropped.
|
|
5054
|
+
*
|
|
5055
|
+
* `inflection` takes a sprite pick as it is (`sprite-pick@1` is assignable to
|
|
5056
|
+
* `inflection@1`): the sprite a line was given is the inflection it is spoken with.
|
|
5057
|
+
* @experimental
|
|
5058
|
+
*/
|
|
5059
|
+
export const cueLines = pin(describeTaskDefinition({
|
|
5060
|
+
id: 'core:task/cue-lines@1',
|
|
5061
|
+
i18n: { name: { en: 'Cue a line' } },
|
|
5062
|
+
effects: 'none',
|
|
5063
|
+
timeoutMs: 1000,
|
|
5064
|
+
slots: {
|
|
5065
|
+
params: {
|
|
5066
|
+
kind: 'parameters',
|
|
5067
|
+
facet: 'behavior',
|
|
5068
|
+
schema: {
|
|
5069
|
+
quoteStyles: {
|
|
5070
|
+
type: 'list',
|
|
5071
|
+
item: { type: 'string' },
|
|
5072
|
+
default: DEFAULT_QUOTE_STYLES,
|
|
5073
|
+
label: { en: 'Quote marks' },
|
|
5074
|
+
description: {
|
|
5075
|
+
en: 'The marks that open and close dialogue — each entry is the opening mark then the closing one.',
|
|
5076
|
+
},
|
|
5077
|
+
},
|
|
5078
|
+
asterisks: {
|
|
5079
|
+
type: 'enum',
|
|
5080
|
+
of: ASTERISK_READINGS,
|
|
5081
|
+
default: 'action',
|
|
5082
|
+
members: [
|
|
5083
|
+
{ key: 'action', label: { en: 'Action' }, description: { en: '*waves* is something done, read in the narrator\'s voice.' } },
|
|
5084
|
+
{ key: 'emphasis', label: { en: 'Emphasis' }, description: { en: '*really* is a stressed word, read in the line\'s own voice.' } },
|
|
5085
|
+
{ key: 'ignore', label: { en: 'Ignore' }, description: { en: 'Asterisks are dropped and the words read as they stand.' } },
|
|
5086
|
+
],
|
|
5087
|
+
label: { en: 'Text between asterisks' },
|
|
5088
|
+
},
|
|
5089
|
+
voices: {
|
|
5090
|
+
type: 'object',
|
|
5091
|
+
label: { en: 'Who speaks what' },
|
|
5092
|
+
description: {
|
|
5093
|
+
en: 'Which voice reads dialogue, narration, actions and asides.',
|
|
5094
|
+
},
|
|
5095
|
+
default: DEFAULT_CUE_VOICES,
|
|
5096
|
+
fields: {
|
|
5097
|
+
dialogue: {
|
|
5098
|
+
type: 'enum',
|
|
5099
|
+
of: CUE_VOICES,
|
|
5100
|
+
default: DEFAULT_CUE_VOICES.dialogue,
|
|
5101
|
+
members: CUE_VOICE_MEMBERS,
|
|
5102
|
+
label: { en: 'Dialogue' },
|
|
5103
|
+
},
|
|
5104
|
+
narration: {
|
|
5105
|
+
type: 'enum',
|
|
5106
|
+
of: CUE_VOICES,
|
|
5107
|
+
default: DEFAULT_CUE_VOICES.narration,
|
|
5108
|
+
members: CUE_VOICE_MEMBERS,
|
|
5109
|
+
label: { en: 'Narration' },
|
|
5110
|
+
},
|
|
5111
|
+
action: {
|
|
5112
|
+
type: 'enum',
|
|
5113
|
+
of: CUE_VOICES,
|
|
5114
|
+
default: DEFAULT_CUE_VOICES.action,
|
|
5115
|
+
members: CUE_VOICE_MEMBERS,
|
|
5116
|
+
label: { en: 'Actions' },
|
|
5117
|
+
},
|
|
5118
|
+
aside: {
|
|
5119
|
+
type: 'enum',
|
|
5120
|
+
of: CUE_VOICES,
|
|
5121
|
+
default: DEFAULT_CUE_VOICES.aside,
|
|
5122
|
+
members: CUE_VOICE_MEMBERS,
|
|
5123
|
+
label: { en: 'Asides' },
|
|
5124
|
+
},
|
|
5125
|
+
},
|
|
5126
|
+
},
|
|
5127
|
+
language: {
|
|
5128
|
+
type: 'string',
|
|
5129
|
+
default: '',
|
|
5130
|
+
label: { en: 'Language' },
|
|
5131
|
+
description: {
|
|
5132
|
+
en: "ISO 639-1 code whose quote and number rules apply. Blank reads the line's own script.",
|
|
5133
|
+
},
|
|
5134
|
+
},
|
|
5135
|
+
},
|
|
5136
|
+
},
|
|
5137
|
+
},
|
|
5138
|
+
ports: {
|
|
5139
|
+
in: {
|
|
5140
|
+
/** The line's text, as written. */
|
|
5141
|
+
text: S.text,
|
|
5142
|
+
/** Whose line it is — the voice `speaker` cues take. */
|
|
5143
|
+
speaker: S.participantRef,
|
|
5144
|
+
/** The line's recorded inflection — a sprite pick wires in as it is. */
|
|
5145
|
+
inflection: S.inflection,
|
|
5146
|
+
/** `string[]` — the cast's names, which `Name:` may switch to. */
|
|
5147
|
+
cast: S.json,
|
|
5148
|
+
},
|
|
5149
|
+
out: {
|
|
5150
|
+
main: S.cues,
|
|
5151
|
+
cues: S.cues,
|
|
5152
|
+
},
|
|
5153
|
+
},
|
|
5154
|
+
}));
|
|
5155
|
+
/**
|
|
5156
|
+
* 🚧 **Read a drafted card or book** (M2c path B, owner ruling 2026-10-31): a reply that drafts a character card or
|
|
5157
|
+
* a lorebook ends with one hidden block — `<!--draft:character {…}-->` or `<!--draft:lorebook {…}-->`, an HTML
|
|
5158
|
+
* comment the message renderer never shows, even while the reply streams. This step takes every such block out of
|
|
5159
|
+
* the reply (`text`, what is saved) and reads the last one: `make` is `'character'`, `'lorebook'` or `''`, and
|
|
5160
|
+
* `draft` its JSON, for `create-character@1` / `create-lorebook@1` behind a junction on `make`. One model call per
|
|
5161
|
+
* turn — the reply's own — and no tool loop. Pure (the SDK's `readLibraryDraft`). ⚠ Not `parse-json@1` (a whole reply
|
|
5162
|
+
* read as JSON) and not `parse-tool-call@1`.
|
|
5163
|
+
* @experimental
|
|
5164
|
+
*/
|
|
5165
|
+
export const readLibraryDraft = pin(describeTaskDefinition({
|
|
5166
|
+
id: 'core:task/read-library-draft@1',
|
|
5167
|
+
i18n: { name: { en: 'Read a drafted card or book' } },
|
|
5168
|
+
timeoutMs: 500,
|
|
5169
|
+
ports: {
|
|
5170
|
+
in: { text: S.text },
|
|
5171
|
+
out: { main: S.json, text: S.text, make: S.text, draft: S.json },
|
|
5172
|
+
},
|
|
5173
|
+
}));
|
|
4654
5174
|
//# sourceMappingURL=tasks.js.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@serene-pub/contracts",
|
|
3
|
-
"version": "0.6.0-pr-
|
|
3
|
+
"version": "0.6.0-pr-7",
|
|
4
4
|
"description": "Generated, frozen type declarations for one Serene Pub release: @serene-pub/contracts@0.6.x compiles against Serene Pub 0.6.x.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"homepage": "https://github.com/SerenePub/serene-pub-sdk/tree/main/contracts#readme",
|
|
@@ -40,13 +40,13 @@
|
|
|
40
40
|
"./package.json": "./package.json"
|
|
41
41
|
},
|
|
42
42
|
"peerDependencies": {
|
|
43
|
-
"@serene-pub/sdk": "^0.6.0-pr-
|
|
43
|
+
"@serene-pub/sdk": "^0.6.0-pr-7"
|
|
44
44
|
},
|
|
45
45
|
"scripts": {
|
|
46
46
|
"build": "tsc -p tsconfig.build.json"
|
|
47
47
|
},
|
|
48
48
|
"devDependencies": {
|
|
49
|
-
"@serene-pub/sdk": "0.6.0-pr-
|
|
49
|
+
"@serene-pub/sdk": "0.6.0-pr-7"
|
|
50
50
|
},
|
|
51
51
|
"publishConfig": {
|
|
52
52
|
"access": "public",
|