@serene-pub/contracts 0.6.0-pr-2 → 0.6.0-pr-5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +12 -10591
- package/dist/index.js +12 -10236
- package/dist/inlets.d.ts +628 -0
- package/dist/inlets.js +744 -0
- package/dist/oracles.d.ts +1535 -0
- package/dist/oracles.js +1634 -0
- package/dist/outlets.d.ts +1140 -0
- package/dist/outlets.js +1261 -0
- package/dist/queries.d.ts +3492 -0
- package/dist/queries.js +3335 -0
- package/dist/tasks.d.ts +5288 -0
- package/dist/tasks.js +4654 -0
- package/package.json +9 -4
package/dist/oracles.js
ADDED
|
@@ -0,0 +1,1634 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Core's **oracle** node definitions — calls out to an external, nondeterministic
|
|
3
|
+
* source: a model, TTS, image generation, embeddings, a person.
|
|
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, tf, IoKinds } from '@serene-pub/sdk';
|
|
9
|
+
import { jinja2 } from '@serene-pub/sdk';
|
|
10
|
+
import { describeOracleDefinition, pin } from '@serene-pub/sdk';
|
|
11
|
+
/**
|
|
12
|
+
* How a provider node wants its request sent.
|
|
13
|
+
*
|
|
14
|
+
* Two values, because only two are deliverable. `auto` defers to the
|
|
15
|
+
* CONNECTION, which already holds an answer and holds a different default per
|
|
16
|
+
* service; `off` forces the single-request branch every adapter has. There is
|
|
17
|
+
* no `on`: a connection whose adapter has no streaming branch could not honour
|
|
18
|
+
* one, and a control that silently means nothing on half the rows is the
|
|
19
|
+
* defect this vocabulary avoids.
|
|
20
|
+
*
|
|
21
|
+
* A factory rather than a shared constant so the four declarations are four
|
|
22
|
+
* objects — a descriptor is snapshotted into registry rows, and an alias
|
|
23
|
+
* shared across pins is one edit away from being four.
|
|
24
|
+
*/
|
|
25
|
+
const streamingParam = () => ({
|
|
26
|
+
type: 'enum',
|
|
27
|
+
of: ['auto', 'off'],
|
|
28
|
+
members: [
|
|
29
|
+
{
|
|
30
|
+
key: 'auto',
|
|
31
|
+
label: { en: 'Automatic' },
|
|
32
|
+
description: { en: "Keeps the connection's own Stream setting." },
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
key: 'off',
|
|
36
|
+
label: { en: 'Off' },
|
|
37
|
+
description: { en: 'Sends one request and waits — cheaper for background steps.' },
|
|
38
|
+
},
|
|
39
|
+
],
|
|
40
|
+
default: 'auto',
|
|
41
|
+
description: "Automatic keeps the connection's own Stream setting; Off sends one request and waits, which is cheaper for background steps.",
|
|
42
|
+
});
|
|
43
|
+
/**
|
|
44
|
+
* The **loadout** a model call runs on: pair, sampling and workflow by
|
|
45
|
+
* one id. Additive and optional — the `connection` and `sampling` slots
|
|
46
|
+
* beside it stay as per-value overrides, and resolution is: the node's
|
|
47
|
+
* explicit slot → its loadout (following merges) → the transform's default
|
|
48
|
+
* loadout when that one is unfilled. One constant, so every model-calling
|
|
49
|
+
* oracle declares the same slot.
|
|
50
|
+
* @ruling DESIGN-image-generation §11, §13
|
|
51
|
+
*/
|
|
52
|
+
const LOADOUT_SLOT = { kind: 'loadout', quick: true };
|
|
53
|
+
/**
|
|
54
|
+
* **The model decides who speaks**: the oracle on
|
|
55
|
+
* the turn-order spec's optional model path (`decide.model.advise`). Same
|
|
56
|
+
* ports as a strategy — candidates and the visible history in, prepared turn
|
|
57
|
+
* entries out on `main` and `order` — so the junction's result port reads
|
|
58
|
+
* the same whichever path fired. Its answer is held to the candidates: a
|
|
59
|
+
* ref the pool did not admit is dropped with a note, and an answer that
|
|
60
|
+
* names nobody (or no answer at all) falls back to round robin, noted —
|
|
61
|
+
* never a halt, so a model hiccup never leaves a session without an order.
|
|
62
|
+
*
|
|
63
|
+
* A plugin's own model strategy is a swap for this node: an oracle with
|
|
64
|
+
* these ports and these three slots (the fit check holds it to them).
|
|
65
|
+
* @experimental
|
|
66
|
+
*/
|
|
67
|
+
export const turnAdvise = pin(describeOracleDefinition({
|
|
68
|
+
id: 'core:oracle/turn-advise@1',
|
|
69
|
+
i18n: {
|
|
70
|
+
name: { en: 'Model decides who speaks' },
|
|
71
|
+
description: {
|
|
72
|
+
en: 'Asks the model who should speak next, from the cast that may be seated and the recent conversation. Falls back to round robin when the answer names nobody.',
|
|
73
|
+
},
|
|
74
|
+
},
|
|
75
|
+
shape: S.textGen,
|
|
76
|
+
effects: 'external',
|
|
77
|
+
review: { fields: [] },
|
|
78
|
+
timeoutMs: 60000,
|
|
79
|
+
usage: 'response.usage',
|
|
80
|
+
slots: {
|
|
81
|
+
loadout: LOADOUT_SLOT,
|
|
82
|
+
connection: {
|
|
83
|
+
kind: 'connection',
|
|
84
|
+
quick: true,
|
|
85
|
+
shape: S.textGen,
|
|
86
|
+
requires: [tf({ in: [IoKinds.text], out: [IoKinds.text] })],
|
|
87
|
+
/**
|
|
88
|
+
* Asked rather than required (the `ctx.can` ruling, as
|
|
89
|
+
* generate-json): the answer's schema goes out through the
|
|
90
|
+
* strongest door the connection has — json_schema (natively or
|
|
91
|
+
* as a grammar), then json_object — and the prompt's own
|
|
92
|
+
* words are the rung that works everywhere.
|
|
93
|
+
*/
|
|
94
|
+
optional: ['json_schema', 'json_object'],
|
|
95
|
+
},
|
|
96
|
+
sampling: { kind: 'sampling', quick: true, shape: S.textGen },
|
|
97
|
+
prompts: {
|
|
98
|
+
kind: 'prompts',
|
|
99
|
+
quick: true,
|
|
100
|
+
facet: 'prompts',
|
|
101
|
+
fields: { turnAdvice: { type: 'text' } },
|
|
102
|
+
},
|
|
103
|
+
},
|
|
104
|
+
ports: {
|
|
105
|
+
in: { candidates: S.turnCandidates, messages: S.messages },
|
|
106
|
+
out: { main: S.turnEntries, order: S.turnEntries },
|
|
107
|
+
},
|
|
108
|
+
}));
|
|
109
|
+
/**
|
|
110
|
+
* Run the tool the model asked for, and hand the answer back as text it can
|
|
111
|
+
* read on the next pass.
|
|
112
|
+
*
|
|
113
|
+
* ## Why this is a Provider and not a Task
|
|
114
|
+
*
|
|
115
|
+
* The two halves either side of it are pure and this one cannot be: a tool
|
|
116
|
+
* reads the session, or reaches an extension's sandboxed hook, which may in
|
|
117
|
+
* turn reach the network under its own grants. That is `effects: 'external'`
|
|
118
|
+
* exactly — and it is the kind that is handed `ctx.call`, so the tool's own
|
|
119
|
+
* dispatch stays behind the host seam where every other outward call lives.
|
|
120
|
+
* A Task with database access would be a second, unaudited read path.
|
|
121
|
+
*
|
|
122
|
+
* ## What it refuses, and what it never throws
|
|
123
|
+
*
|
|
124
|
+
* `tools` is the advertisement the model was actually given, so a name that
|
|
125
|
+
* was never offered is refused **by name** rather than resolved: a model
|
|
126
|
+
* inventing a tool must not be able to reach one that exists but was withheld
|
|
127
|
+
* from this step.
|
|
128
|
+
*
|
|
129
|
+
* A tool that fails is a **result, not an exception**. `main` is
|
|
130
|
+
* `{ tool, error }` and `text` renders it, because the model asking for a
|
|
131
|
+
* missing file needs to read "no such file" and try something else — a throw
|
|
132
|
+
* would end the run at the one moment the agent could have recovered. The
|
|
133
|
+
* type's `timeoutMs` is the time-box per call: one node invocation is one
|
|
134
|
+
* tool, so the executor's own timeout already is the tool's.
|
|
135
|
+
*
|
|
136
|
+
* `call` may be null — that is the ordinary last iteration, where the model
|
|
137
|
+
* answered in prose and the loop is about to stop. Nothing runs and `text` is
|
|
138
|
+
* empty.
|
|
139
|
+
* @experimental
|
|
140
|
+
*/
|
|
141
|
+
export const runTool = pin(describeOracleDefinition({
|
|
142
|
+
id: 'core:oracle/run-tool@1',
|
|
143
|
+
i18n: { name: { en: 'Run tool' } },
|
|
144
|
+
effects: 'external',
|
|
145
|
+
/** The call was the model's and the tool list the install's: approve or refuse. */
|
|
146
|
+
review: { fields: [] },
|
|
147
|
+
timeoutMs: 30000,
|
|
148
|
+
ports: {
|
|
149
|
+
// `call` is parse-tool-call's `{ tool, args } | null`; `tools` is
|
|
150
|
+
// advertise-tools' input, so refusal reads the same list the model
|
|
151
|
+
// saw; `text` is the prose parse-tool-call stripped the call out of.
|
|
152
|
+
in: { call: S.json, tools: S.json, text: S.text },
|
|
153
|
+
/**
|
|
154
|
+
* Three ports because an iteration produces up to three different
|
|
155
|
+
* things and one port carrying two of them is a port a downstream
|
|
156
|
+
* node has to interrogate.
|
|
157
|
+
*
|
|
158
|
+
* - `main` — `{ tool, result }` or `{ tool, error }`, or null when
|
|
159
|
+
* nothing was called. One shape, two arms, so nothing downstream
|
|
160
|
+
* decides what happened by looking for a missing key.
|
|
161
|
+
* - `text` — that rendered as the tool-result block **the next
|
|
162
|
+
* prompt carries**. Empty when nothing ran.
|
|
163
|
+
* - `answer` — what this iteration contributes to the
|
|
164
|
+
* **conversation**: the model's prose, and only on the iteration
|
|
165
|
+
* that called no tool, which is the one where the model stopped
|
|
166
|
+
* working and answered. Empty otherwise, so joining every
|
|
167
|
+
* iteration's `answer` yields the turn's reply and nothing else.
|
|
168
|
+
*/
|
|
169
|
+
out: { main: S.json, text: S.text, answer: S.text },
|
|
170
|
+
},
|
|
171
|
+
}));
|
|
172
|
+
// ── Providers — identical structure across three modalities (17 §2) ─────────
|
|
173
|
+
/** @experimental */
|
|
174
|
+
export const embedText = pin(describeOracleDefinition({
|
|
175
|
+
id: 'core:oracle/embed-text@1',
|
|
176
|
+
shape: S.embeddings,
|
|
177
|
+
effects: 'external',
|
|
178
|
+
/** Nothing to edit: an embedding of a text somebody else wrote. */
|
|
179
|
+
review: { fields: [] },
|
|
180
|
+
timeoutMs: 5000,
|
|
181
|
+
/**
|
|
182
|
+
* ⚠ **Producing nothing is a legitimate outcome, and this is what makes
|
|
183
|
+
* that structural rather than careful.**
|
|
184
|
+
*
|
|
185
|
+
* Embeddings are optional in this product by design: most installs have
|
|
186
|
+
* no model loaded, and the retrieval plan's second governing rule is an
|
|
187
|
+
* absolute — *an unavailable mechanism subtracts a signal; it never
|
|
188
|
+
* reroutes, disables a path, or excludes a candidate.* The host answers
|
|
189
|
+
* "no embedding model is loaded and validated" by **throwing**, which is
|
|
190
|
+
* the right answer to give a caller and the wrong thing to let end a
|
|
191
|
+
* turn.
|
|
192
|
+
*
|
|
193
|
+
* `optional` is what turns that error into an empty `ok` in the executor
|
|
194
|
+
* — recorded, with `recoveredAsEmpty` and the reason on the receipt, so
|
|
195
|
+
* it is tolerated rather than hidden. The binding's `enabled` parameter
|
|
196
|
+
* decides how *loudly*: `auto` treats an unavailable model as an absence
|
|
197
|
+
* and returns no vectors without calling it a failure, `on` lets the
|
|
198
|
+
* failure be recorded as one. Neither can cost somebody a reply, and
|
|
199
|
+
* that is the point of putting the guarantee here instead of in a
|
|
200
|
+
* `try`.
|
|
201
|
+
*
|
|
202
|
+
* It also earns the node a "Use this source" switch. ⚠ Not the semantic
|
|
203
|
+
* mechanism's switch: that is `core:task/query-windows@1`'s
|
|
204
|
+
* `searchByMeaning`, on the chain's first node, which cuts the probes
|
|
205
|
+
* before this node is reached. Off here (or `enabled: 'off'`) still
|
|
206
|
+
* spends nothing, and switches off every embed step that shares
|
|
207
|
+
* `enabled` — the entity-vector mechanism's too — but it leaves the
|
|
208
|
+
* semantic chain running on empty, and `vector-search` can only say
|
|
209
|
+
* nothing was embedded, not why.
|
|
210
|
+
*/
|
|
211
|
+
optional: true,
|
|
212
|
+
/**
|
|
213
|
+
* ⚠ **No `connection` slot** (removed 2026-10-05, owner ruling D-c). A
|
|
214
|
+
* pipeline never chooses its embedding connection: the host embeds
|
|
215
|
+
* through the install's one active embedding connection, whatever a
|
|
216
|
+
* step names. The slot it carried resolved a value into a port no host
|
|
217
|
+
* read — ten inert controls across five reply specs, held at the active
|
|
218
|
+
* connection only so Search by meaning's Automatic could read it.
|
|
219
|
+
* `core:task/query-windows@1` asks that question on its own slot now.
|
|
220
|
+
*/
|
|
221
|
+
slots: {
|
|
222
|
+
params: {
|
|
223
|
+
kind: 'parameters',
|
|
224
|
+
schema: {
|
|
225
|
+
/**
|
|
226
|
+
* `shared`: one switch for every embed step of a
|
|
227
|
+
* spec. `respond` puts it on the semantic mechanism's embed
|
|
228
|
+
* and the entity-vector mechanism's embed reads it through
|
|
229
|
+
* `slot.params({ node })` — an install with no embedding
|
|
230
|
+
* model switches both off in one place, which is the only
|
|
231
|
+
* reading of "embedding: off" a person means.
|
|
232
|
+
*/
|
|
233
|
+
enabled: {
|
|
234
|
+
type: 'enum',
|
|
235
|
+
of: ['auto', 'on', 'off'],
|
|
236
|
+
members: [
|
|
237
|
+
{
|
|
238
|
+
key: 'auto',
|
|
239
|
+
label: { en: 'Automatic' },
|
|
240
|
+
description: {
|
|
241
|
+
en: 'Embeds when a model is loaded; without one, retrieval goes on without vectors.',
|
|
242
|
+
},
|
|
243
|
+
},
|
|
244
|
+
{
|
|
245
|
+
key: 'on',
|
|
246
|
+
label: { en: 'On' },
|
|
247
|
+
description: {
|
|
248
|
+
en: 'Always embeds; a missing model is recorded as a failure, and the reply still goes out.',
|
|
249
|
+
},
|
|
250
|
+
},
|
|
251
|
+
{
|
|
252
|
+
key: 'off',
|
|
253
|
+
label: { en: 'Off' },
|
|
254
|
+
description: { en: 'Never embeds: semantic matching is switched off.' },
|
|
255
|
+
},
|
|
256
|
+
],
|
|
257
|
+
default: 'auto',
|
|
258
|
+
shared: true,
|
|
259
|
+
},
|
|
260
|
+
},
|
|
261
|
+
},
|
|
262
|
+
},
|
|
263
|
+
ports: {
|
|
264
|
+
in: {
|
|
265
|
+
text: S.text,
|
|
266
|
+
/** Batched: one call, one vector each, in order. */
|
|
267
|
+
texts: S.json,
|
|
268
|
+
},
|
|
269
|
+
out: { main: S.vector, vector: S.vector, vectors: S.json },
|
|
270
|
+
},
|
|
271
|
+
}));
|
|
272
|
+
/**
|
|
273
|
+
* An MCP tool call — the generic Provider for a tool on any MCP
|
|
274
|
+
* connection. The snapshot path projects each advertised tool as its
|
|
275
|
+
* own registry row under the connection's namespace, typed off the tool's
|
|
276
|
+
* declared input schema; this generic type is the escape hatch beneath them —
|
|
277
|
+
* pin it, choose the connection, name the tool in params.
|
|
278
|
+
*
|
|
279
|
+
* `effects: 'external'` unconditionally: MCP annotations (`readOnlyHint` and
|
|
280
|
+
* friends) are advisory by specification and are never trusted for gating
|
|
281
|
+
* The admin's per-tool classification lives on the snapshot rows;
|
|
282
|
+
* this generic type gates always, because through it any tool is reachable.
|
|
283
|
+
*
|
|
284
|
+
* The result carries the request and response verbatim in its output — which
|
|
285
|
+
* is the receipt, which is the pitch: no other MCP client can answer
|
|
286
|
+
* "what did this tool actually do, and did I approve it" from a row.
|
|
287
|
+
* @experimental
|
|
288
|
+
*/
|
|
289
|
+
export const mcpTool = pin(describeOracleDefinition({
|
|
290
|
+
id: 'core:oracle/mcp-tool@1',
|
|
291
|
+
i18n: {
|
|
292
|
+
name: { en: 'MCP tool' },
|
|
293
|
+
description: {
|
|
294
|
+
en: 'Call one tool on a Model Context Protocol server, recorded verbatim and gated like every effectful step.',
|
|
295
|
+
},
|
|
296
|
+
},
|
|
297
|
+
shape: S.mcp,
|
|
298
|
+
effects: 'external',
|
|
299
|
+
/** Declared, not bound — no handler exists for it yet. */
|
|
300
|
+
provisional: true,
|
|
301
|
+
/** The arguments are the model's invocation: approve or refuse it, never rewrite it. */
|
|
302
|
+
review: { fields: [] },
|
|
303
|
+
timeoutMs: 60000,
|
|
304
|
+
slots: {
|
|
305
|
+
connection: {
|
|
306
|
+
kind: 'connection',
|
|
307
|
+
quick: true,
|
|
308
|
+
shape: S.mcp,
|
|
309
|
+
/**
|
|
310
|
+
* ⚠ No `requires`, and that is deliberate rather than an omission.
|
|
311
|
+
*
|
|
312
|
+
* The capability space describes io TRANSFORMS — what a model can
|
|
313
|
+
* be handed and what it gives back. An MCP server is not one: it
|
|
314
|
+
* serves tools, it does not turn text into anything. The nearest
|
|
315
|
+
* id, `text->text`, would be false, and claiming it would make
|
|
316
|
+
* every chat connection in the install look offerable here.
|
|
317
|
+
*
|
|
318
|
+
* So this slot keeps filtering by `shape` alone, which is the
|
|
319
|
+
* right axis for it. `requires` is for slots whose answer is "what
|
|
320
|
+
* must this connection be able to DO".
|
|
321
|
+
*/
|
|
322
|
+
description: 'Which MCP server this step calls.',
|
|
323
|
+
},
|
|
324
|
+
params: {
|
|
325
|
+
kind: 'parameters',
|
|
326
|
+
schema: {
|
|
327
|
+
tool: {
|
|
328
|
+
type: 'string',
|
|
329
|
+
quick: true,
|
|
330
|
+
label: { en: 'Tool' },
|
|
331
|
+
description: {
|
|
332
|
+
en: 'The advertised tool name on the connected server.',
|
|
333
|
+
},
|
|
334
|
+
},
|
|
335
|
+
},
|
|
336
|
+
},
|
|
337
|
+
},
|
|
338
|
+
ports: {
|
|
339
|
+
in: {
|
|
340
|
+
/** Arguments for the tool, merged over any declared in params. */
|
|
341
|
+
args: S.json,
|
|
342
|
+
},
|
|
343
|
+
out: {
|
|
344
|
+
main: S.json,
|
|
345
|
+
text: S.text,
|
|
346
|
+
/** The content blocks exactly as the server returned them. */
|
|
347
|
+
content: S.json,
|
|
348
|
+
},
|
|
349
|
+
},
|
|
350
|
+
}));
|
|
351
|
+
/**
|
|
352
|
+
* An MCP resource read — a Provider, deliberately not a Query. A
|
|
353
|
+
* Query may not reach the network, and everything crossing the
|
|
354
|
+
* process boundary must be recorded verbatim so replay never re-infers;
|
|
355
|
+
* a resource is external state that can change between runs, and
|
|
356
|
+
* modelling it as a Query would quietly break both rules.
|
|
357
|
+
* @experimental
|
|
358
|
+
*/
|
|
359
|
+
export const mcpResource = pin(describeOracleDefinition({
|
|
360
|
+
id: 'core:oracle/mcp-resource@1',
|
|
361
|
+
i18n: {
|
|
362
|
+
name: { en: 'MCP resource' },
|
|
363
|
+
description: {
|
|
364
|
+
en: 'Read one resource from a Model Context Protocol server, recorded verbatim.',
|
|
365
|
+
},
|
|
366
|
+
},
|
|
367
|
+
shape: S.mcp,
|
|
368
|
+
effects: 'external',
|
|
369
|
+
/** Declared, not bound — no handler exists for it yet. */
|
|
370
|
+
provisional: true,
|
|
371
|
+
/** The uri is the invocation: approve or refuse. */
|
|
372
|
+
review: { fields: [] },
|
|
373
|
+
timeoutMs: 60000,
|
|
374
|
+
slots: {
|
|
375
|
+
connection: {
|
|
376
|
+
kind: 'connection',
|
|
377
|
+
quick: true,
|
|
378
|
+
shape: S.mcp,
|
|
379
|
+
// No `requires` — see the sibling MCP node above: a tool server is
|
|
380
|
+
// not an io transform, so `shape` is the right filter here.
|
|
381
|
+
description: 'Which MCP server this step reads from.',
|
|
382
|
+
},
|
|
383
|
+
params: {
|
|
384
|
+
kind: 'parameters',
|
|
385
|
+
schema: {
|
|
386
|
+
uri: {
|
|
387
|
+
type: 'string',
|
|
388
|
+
quick: true,
|
|
389
|
+
label: { en: 'Resource URI' },
|
|
390
|
+
description: {
|
|
391
|
+
en: 'The advertised resource URI on the connected server.',
|
|
392
|
+
},
|
|
393
|
+
},
|
|
394
|
+
},
|
|
395
|
+
},
|
|
396
|
+
},
|
|
397
|
+
ports: {
|
|
398
|
+
in: {
|
|
399
|
+
/** Overrides the declared URI when wired. */
|
|
400
|
+
uri: S.text,
|
|
401
|
+
},
|
|
402
|
+
out: {
|
|
403
|
+
main: S.json,
|
|
404
|
+
text: S.text,
|
|
405
|
+
content: S.json,
|
|
406
|
+
},
|
|
407
|
+
},
|
|
408
|
+
}));
|
|
409
|
+
/** @public */
|
|
410
|
+
export const generateText = pin(describeOracleDefinition({
|
|
411
|
+
id: 'core:oracle/generate-text@1',
|
|
412
|
+
i18n: { name: { en: 'Generate reply' } },
|
|
413
|
+
shape: S.textGen,
|
|
414
|
+
effects: 'external',
|
|
415
|
+
/** The payload is the compiled prompt; a prompt rewritten at the gate is one the receipt cannot explain — approve or refuse. */
|
|
416
|
+
review: { fields: [] },
|
|
417
|
+
timeoutMs: 120000,
|
|
418
|
+
timeoutKind: 'idle',
|
|
419
|
+
usage: 'response.usage',
|
|
420
|
+
slots: {
|
|
421
|
+
loadout: LOADOUT_SLOT,
|
|
422
|
+
connection: {
|
|
423
|
+
kind: 'connection',
|
|
424
|
+
quick: true,
|
|
425
|
+
shape: S.textGen,
|
|
426
|
+
/**
|
|
427
|
+
* What the connection must be able to do, as opposed to what it
|
|
428
|
+
* is called. `shape` above still types the SLOT; this types the
|
|
429
|
+
* connection, and it is what the picker filters on and what the
|
|
430
|
+
* bind check refuses by — naming "Chat" rather than an id.
|
|
431
|
+
*
|
|
432
|
+
* Only `requires`, deliberately — still, now that the binding DOES
|
|
433
|
+
* consume `attachments`. It is the Anthropic adapter that sends
|
|
434
|
+
* them today (as base64 content blocks on the last user turn); a
|
|
435
|
+
* connection whose adapter has no such code REFUSES a request
|
|
436
|
+
* carrying files rather than sending it without them, so the
|
|
437
|
+
* `attachments` port is honest without a slot-level requirement.
|
|
438
|
+
*
|
|
439
|
+
* An `optional` vision requirement would meanwhile put a "no
|
|
440
|
+
* vision" caveat on every text connection in the app, on every
|
|
441
|
+
* run — and the port is empty on nearly all of them.
|
|
442
|
+
*/
|
|
443
|
+
requires: [tf({ in: [IoKinds.text], out: [IoKinds.text] })],
|
|
444
|
+
description: 'Which model server this step sends its request to.',
|
|
445
|
+
},
|
|
446
|
+
sampling: {
|
|
447
|
+
kind: 'sampling',
|
|
448
|
+
quick: true,
|
|
449
|
+
shape: S.textGen,
|
|
450
|
+
description: 'The sampling settings — temperature and friends — used for this request.',
|
|
451
|
+
},
|
|
452
|
+
/**
|
|
453
|
+
* ⚠ No `prompts` slot, and there was one — `system` and
|
|
454
|
+
* `postHistory`, "the written instructions sent with every request
|
|
455
|
+
* from this step" (culled 2026-09-16). No handler read it:
|
|
456
|
+
* the instructions reach the model INSIDE the assembled context,
|
|
457
|
+
* through `core:task/assemble@2`'s own `prompts` slot, and this
|
|
458
|
+
* node sends what it is handed on `context`. Every shipped spec
|
|
459
|
+
* wired it as `slot.prompts({ node: 'context' })` for one reason
|
|
460
|
+
* only — so the panel would not render a second copy of the
|
|
461
|
+
* context builder's text — which is a declaration existing to hide
|
|
462
|
+
* itself. The same slot on `generate-with-tools@1` and
|
|
463
|
+
* `generate-json@1` went with it.
|
|
464
|
+
*/
|
|
465
|
+
/**
|
|
466
|
+
* ⚠ No `template` slot, and there was one — "how the assembled
|
|
467
|
+
* context is wrapped for this model before sending".
|
|
468
|
+
*
|
|
469
|
+
* Nothing read it and nothing seeded a row, so it rendered as an
|
|
470
|
+
* empty picker beside the settings that do work. Wrapping for the
|
|
471
|
+
* wire is the `wire` slot's job and the connection adapter's; a
|
|
472
|
+
* second, inert way to express it invited the two to disagree.
|
|
473
|
+
*/
|
|
474
|
+
params: {
|
|
475
|
+
kind: 'parameters',
|
|
476
|
+
facet: 'weights',
|
|
477
|
+
schema: {
|
|
478
|
+
stopSequences: {
|
|
479
|
+
type: 'string[]',
|
|
480
|
+
description: 'Sequences that end the reply the moment the model writes one. One per line.',
|
|
481
|
+
},
|
|
482
|
+
streaming: streamingParam(),
|
|
483
|
+
},
|
|
484
|
+
},
|
|
485
|
+
},
|
|
486
|
+
/**
|
|
487
|
+
* Vision and interleaved output, declared.
|
|
488
|
+
*
|
|
489
|
+
* `accepts` is what makes a multimodal model reachable at all: before
|
|
490
|
+
* this the only image ports in the whole graph pointed *outward*
|
|
491
|
+
* (render, attach), so an image could be produced and stored but never
|
|
492
|
+
* sent. `emits` says a reply may contain generated media — which is
|
|
493
|
+
* what a single call now routinely returns, interleaved with the prose
|
|
494
|
+
* rather than beside it.
|
|
495
|
+
*
|
|
496
|
+
* Declaring both here does not oblige a connection to do either; the
|
|
497
|
+
* adapter reports what its model actually supports and the two are
|
|
498
|
+
* resolved at bind time.
|
|
499
|
+
*/
|
|
500
|
+
media: {
|
|
501
|
+
accepts: ['image', 'document'],
|
|
502
|
+
emits: ['image'],
|
|
503
|
+
},
|
|
504
|
+
ports: {
|
|
505
|
+
in: {
|
|
506
|
+
context: S.assembled,
|
|
507
|
+
/**
|
|
508
|
+
* Whose reply is being generated — the stop-string exclusion:
|
|
509
|
+
* the speaking character's own name must not stop
|
|
510
|
+
* their own reply. The host already preferred a payload value
|
|
511
|
+
* over the run scope's; this port is what lets a spec supply
|
|
512
|
+
* one, so the exclusion follows the next-speaker node's output
|
|
513
|
+
* instead of the pre-run guess.
|
|
514
|
+
*/
|
|
515
|
+
currentCharacterId: S.rowIds,
|
|
516
|
+
/**
|
|
517
|
+
* Media travelling with the request — the page a user
|
|
518
|
+
* attached, the frame a vision step is asked about. A list
|
|
519
|
+
* because interleaving is ordered and a single ref could not
|
|
520
|
+
* express "these three, in this order".
|
|
521
|
+
*
|
|
522
|
+
* Optional, and never quietly ignored: the host forwards these
|
|
523
|
+
* references to the dispatch, which resolves each one to bytes
|
|
524
|
+
* (checking it belongs to this run's session or user) and hands
|
|
525
|
+
* them to the adapter in this order. A request whose connection
|
|
526
|
+
* has vision switched off, or whose adapter has no code that
|
|
527
|
+
* sends files, is REFUSED rather than sent without them —
|
|
528
|
+
* dropping a file is indistinguishable from a model ignoring it.
|
|
529
|
+
*/
|
|
530
|
+
attachments: S.mediaList,
|
|
531
|
+
},
|
|
532
|
+
/**
|
|
533
|
+
* `parts` is the honest shape of a completion: an ordered list of
|
|
534
|
+
* text, reasoning, generated media and tool calls. `main` and
|
|
535
|
+
* `text` stay exactly as they were — `part-stream` is assignable
|
|
536
|
+
* to `text-stream`, so every spec wired to them keeps working and
|
|
537
|
+
* degrades by concatenating the prose.
|
|
538
|
+
*
|
|
539
|
+
* `reasoning` is the reasoning trace the dispatch separated from
|
|
540
|
+
* the text before the text reached the port — published by the
|
|
541
|
+
* binding since it first stripped one, declared now that a
|
|
542
|
+
* downstream write (`update-message`) takes it. Empty when the
|
|
543
|
+
* model produced none.
|
|
544
|
+
*/
|
|
545
|
+
out: {
|
|
546
|
+
main: S.partStream,
|
|
547
|
+
text: S.textStream,
|
|
548
|
+
parts: S.partStream,
|
|
549
|
+
reasoning: S.text,
|
|
550
|
+
},
|
|
551
|
+
},
|
|
552
|
+
}));
|
|
553
|
+
/**
|
|
554
|
+
* Generate, with the tools on the wire — the native door.
|
|
555
|
+
*
|
|
556
|
+
* ## Why this is a second type rather than two ports on `generate-text`
|
|
557
|
+
*
|
|
558
|
+
* `core:oracle/generate-text@1` is published and frozen: a spec that pinned
|
|
559
|
+
* it must keep meaning what it meant. Adding ports would move its content hash
|
|
560
|
+
* and every install would need a re-projection to keep booting — for a
|
|
561
|
+
* capability most connections do not have. A new pin costs a row and conflicts
|
|
562
|
+
* with nothing.
|
|
563
|
+
*
|
|
564
|
+
* It is otherwise the same node: same shape, same slots, same `context` in and
|
|
565
|
+
* the same `main`/`text`/`parts` out. A spec swaps one for the other and
|
|
566
|
+
* nothing else changes.
|
|
567
|
+
*
|
|
568
|
+
* ## The two doors, and why only one of them parses
|
|
569
|
+
*
|
|
570
|
+
* `advertise-tools` publishes both: `prompt` for models that never heard of
|
|
571
|
+
* tools, `native` for APIs that take a declaration list. Wire `native` here and
|
|
572
|
+
* the adapter puts the tools in the field its service calls them — and reads
|
|
573
|
+
* the answer back out of the structured field, so `toolCall` arrives as data.
|
|
574
|
+
* **There is nothing for `parse-tool-call` to do on this door**: the loop's
|
|
575
|
+
* predicate is this node's own `toolCall`, and `run-tool` takes it directly.
|
|
576
|
+
* Parsing prose the API already parsed would be a second reading of one answer.
|
|
577
|
+
*
|
|
578
|
+
* A connection whose adapter cannot send tools REFUSES a request carrying them
|
|
579
|
+
* rather than sending it without: a model that was never offered a tool and a
|
|
580
|
+
* model that declined one produce the same empty `toolCall`, and dropping the
|
|
581
|
+
* declarations silently is indistinguishable from a model choosing not to call.
|
|
582
|
+
* @experimental
|
|
583
|
+
*/
|
|
584
|
+
export const generateWithTools = pin(describeOracleDefinition({
|
|
585
|
+
id: 'core:oracle/generate-with-tools@1',
|
|
586
|
+
i18n: { name: { en: 'Generate with tools' } },
|
|
587
|
+
shape: S.textGen,
|
|
588
|
+
effects: 'external',
|
|
589
|
+
/** The compiled prompt and the tool list: approve or refuse, as `generate-text`. */
|
|
590
|
+
review: { fields: [] },
|
|
591
|
+
timeoutMs: 120000,
|
|
592
|
+
timeoutKind: 'idle',
|
|
593
|
+
usage: 'response.usage',
|
|
594
|
+
slots: {
|
|
595
|
+
loadout: LOADOUT_SLOT,
|
|
596
|
+
connection: {
|
|
597
|
+
kind: 'connection',
|
|
598
|
+
quick: true,
|
|
599
|
+
shape: S.textGen,
|
|
600
|
+
requires: [tf({ in: [IoKinds.text], out: [IoKinds.text] })],
|
|
601
|
+
/**
|
|
602
|
+
* Asked rather than required, so this node is bindable to every
|
|
603
|
+
* text connection and the author decides what to do without one
|
|
604
|
+
* — which is the ruling on `optional` (`ctx.can`): the type
|
|
605
|
+
* system makes absence impossible to forget about, and the
|
|
606
|
+
* fallback is the author's to write. A spec that wants the
|
|
607
|
+
* emulated door instead wires `advertise-tools`' `prompt`.
|
|
608
|
+
*/
|
|
609
|
+
optional: ['tools'],
|
|
610
|
+
description: 'Which model server this step sends its request to.',
|
|
611
|
+
},
|
|
612
|
+
sampling: { kind: 'sampling', quick: true, shape: S.textGen },
|
|
613
|
+
// No `prompts` slot — see `generateText` (culled 2026-09-16, R-12).
|
|
614
|
+
params: {
|
|
615
|
+
kind: 'parameters',
|
|
616
|
+
facet: 'weights',
|
|
617
|
+
schema: {
|
|
618
|
+
stopSequences: {
|
|
619
|
+
type: 'string[]',
|
|
620
|
+
description: 'Sequences that end the reply the moment the model writes one. One per line.',
|
|
621
|
+
},
|
|
622
|
+
streaming: streamingParam(),
|
|
623
|
+
},
|
|
624
|
+
},
|
|
625
|
+
},
|
|
626
|
+
media: { accepts: ['image', 'document'], emits: ['image'] },
|
|
627
|
+
ports: {
|
|
628
|
+
in: {
|
|
629
|
+
context: S.assembled,
|
|
630
|
+
/** `advertise-tools`' `native` port — the declarations, verbatim. */
|
|
631
|
+
tools: S.json,
|
|
632
|
+
currentCharacterId: S.rowIds,
|
|
633
|
+
attachments: S.mediaList,
|
|
634
|
+
},
|
|
635
|
+
out: {
|
|
636
|
+
main: S.partStream,
|
|
637
|
+
text: S.textStream,
|
|
638
|
+
parts: S.partStream,
|
|
639
|
+
/**
|
|
640
|
+
* `{ tool, args }` when the model called one, null when it
|
|
641
|
+
* answered — the same shape `parse-tool-call` publishes, so
|
|
642
|
+
* `run-tool` and the loop's predicate take either door without
|
|
643
|
+
* knowing which was used.
|
|
644
|
+
*/
|
|
645
|
+
toolCall: S.json,
|
|
646
|
+
},
|
|
647
|
+
},
|
|
648
|
+
}));
|
|
649
|
+
/**
|
|
650
|
+
* Generate, with the ANSWER's shape on the wire — the structured door.
|
|
651
|
+
*
|
|
652
|
+
* ## Why a third generate type rather than a schema port on the other two
|
|
653
|
+
*
|
|
654
|
+
* The same reason `generate-with-tools` is a second one: `generate-text@1` is
|
|
655
|
+
* published and frozen, and a port added to it moves the content hash every
|
|
656
|
+
* spec in every install pins. But the stronger reason here is that this node
|
|
657
|
+
* does not make the same REQUEST. `generate-text` sends a turn — a speaker, a
|
|
658
|
+
* trailing assistant line the model continues — and this sends an instruction.
|
|
659
|
+
* A parameter cannot express that difference honestly: a node whose prompt is
|
|
660
|
+
* sometimes a turn and sometimes a question is two nodes with a flag between
|
|
661
|
+
* them, and the flag is the thing a reader has to find before the receipt makes
|
|
662
|
+
* sense.
|
|
663
|
+
*
|
|
664
|
+
* So: no `currentCharacterId` and no `attachments`, and neither is an omission.
|
|
665
|
+
* The first is the speaker whose reply is being written, and nobody's reply is
|
|
666
|
+
* being written. The second is files travelling with a turn.
|
|
667
|
+
*
|
|
668
|
+
* ⚠ **The trailing assistant line is the TRANSCRIPT's business, not this
|
|
669
|
+
* node's.** A prompt arrives here already rendered, and on a completion wire the
|
|
670
|
+
* seed is an open block inside one string that nothing can take back out. So the
|
|
671
|
+
* guarantee is made where the line is never written:
|
|
672
|
+
* `core:task/prose-transcript@1`, which is what a spec wires into the assemble
|
|
673
|
+
* step feeding this node.
|
|
674
|
+
*
|
|
675
|
+
* ## It parses, and that is not the Provider doing two jobs
|
|
676
|
+
*
|
|
677
|
+
* `parse-json@1`'s own header says why the reading is a separate Task *there*:
|
|
678
|
+
* `generate-text` publishes prose, so the reading is a second step over
|
|
679
|
+
* somebody else's output, and every way it can fail deserves its own node on
|
|
680
|
+
* the receipt. Here the structure IS the output — a request that named a schema
|
|
681
|
+
* and came back with a document has nothing left to interpret — so publishing
|
|
682
|
+
* prose and asking the next node to recover the document from it would be
|
|
683
|
+
* undoing the work this node exists to do.
|
|
684
|
+
*
|
|
685
|
+
* The failures still show. `json` is null and `parseError` carries the sentence
|
|
686
|
+
* when the answer could not be read, and `structured` says which door the
|
|
687
|
+
* request actually went out through, so "the model ignored the schema" and
|
|
688
|
+
* "this connection takes no schema, so there was none" are told apart by
|
|
689
|
+
* reading rather than by guessing.
|
|
690
|
+
*
|
|
691
|
+
* `parse-json@1` stays declared and unchanged: it is content-addressed, other
|
|
692
|
+
* specs pin it, and a reply from `generate-text` still needs it.
|
|
693
|
+
* @public
|
|
694
|
+
*/
|
|
695
|
+
export const generateJson = pin(describeOracleDefinition({
|
|
696
|
+
id: 'core:oracle/generate-json@1',
|
|
697
|
+
i18n: { name: { en: 'Generate JSON' } },
|
|
698
|
+
shape: S.textGen,
|
|
699
|
+
effects: 'external',
|
|
700
|
+
/** The compiled prompt and the schema: approve or refuse, as `generate-text`. */
|
|
701
|
+
review: { fields: [] },
|
|
702
|
+
timeoutMs: 120000,
|
|
703
|
+
timeoutKind: 'idle',
|
|
704
|
+
usage: 'response.usage',
|
|
705
|
+
/**
|
|
706
|
+
* An answer nobody can read costs the structure and nothing else.
|
|
707
|
+
*
|
|
708
|
+
* The same guarantee `parse-json@1` makes, kept here because this node
|
|
709
|
+
* replaced it in the chain: a planner whose document came back malformed
|
|
710
|
+
* should leave a turn with no plan, narrated anyway, rather than a turn
|
|
711
|
+
* that failed. The executor records `recoveredAsEmpty` and every
|
|
712
|
+
* downstream port reads absent, so a `map` over the missing list runs
|
|
713
|
+
* zero times.
|
|
714
|
+
*/
|
|
715
|
+
optional: true,
|
|
716
|
+
slots: {
|
|
717
|
+
loadout: LOADOUT_SLOT,
|
|
718
|
+
connection: {
|
|
719
|
+
kind: 'connection',
|
|
720
|
+
quick: true,
|
|
721
|
+
shape: S.textGen,
|
|
722
|
+
requires: [tf({ in: [IoKinds.text], out: [IoKinds.text] })],
|
|
723
|
+
/**
|
|
724
|
+
* Asked rather than required, which is the `ctx.can` ruling: the
|
|
725
|
+
* node binds to every text connection and the binding decides
|
|
726
|
+
* what to do without them. The ladder is `json_schema` (the
|
|
727
|
+
* shape on the wire, natively or compiled to a grammar), then
|
|
728
|
+
* `json_object` (JSON, shape unsaid), then a sentence in the
|
|
729
|
+
* prompt — and the last rung works everywhere, so an absence
|
|
730
|
+
* costs fidelity rather than the step.
|
|
731
|
+
*/
|
|
732
|
+
optional: ['json_schema', 'json_object'],
|
|
733
|
+
description: 'Which model server this step sends its request to.',
|
|
734
|
+
},
|
|
735
|
+
sampling: { kind: 'sampling', quick: true, shape: S.textGen },
|
|
736
|
+
// No `prompts` slot — see `generateText` (culled 2026-09-16, R-12).
|
|
737
|
+
params: {
|
|
738
|
+
kind: 'parameters',
|
|
739
|
+
facet: 'weights',
|
|
740
|
+
schema: {
|
|
741
|
+
/**
|
|
742
|
+
* Which value inside the answer reaches `value` and `items`.
|
|
743
|
+
*
|
|
744
|
+
* A data reference is `{node, port}` with no sub-path, so a
|
|
745
|
+
* downstream `map` cannot iterate `plan.speakers` off a port
|
|
746
|
+
* carrying the whole document — the same reason `parse-json`
|
|
747
|
+
* carries this parameter, and the same spelling.
|
|
748
|
+
*
|
|
749
|
+
* Several dotted paths separated by commas are read in order
|
|
750
|
+
* and their lists joined. That is what makes an answer split
|
|
751
|
+
* into arms wireable at all: a keeper reports
|
|
752
|
+
* `{values, inventory}` (its item arm, named for the stat
|
|
753
|
+
* it resolves onto) because a schema can only be strict
|
|
754
|
+
* about a list whose items are all one shape, and the node
|
|
755
|
+
* that resolves them takes one list.
|
|
756
|
+
*/
|
|
757
|
+
path: {
|
|
758
|
+
type: 'string',
|
|
759
|
+
quick: true,
|
|
760
|
+
description: 'Which value inside the answer to publish on `value` and `items`, as a dotted path. Several paths, separated by commas, are joined in order. Empty publishes the whole answer.',
|
|
761
|
+
},
|
|
762
|
+
stopSequences: {
|
|
763
|
+
type: 'string[]',
|
|
764
|
+
description: 'Sequences that end the reply the moment the model writes one. One per line.',
|
|
765
|
+
},
|
|
766
|
+
streaming: streamingParam(),
|
|
767
|
+
},
|
|
768
|
+
},
|
|
769
|
+
},
|
|
770
|
+
ports: {
|
|
771
|
+
in: {
|
|
772
|
+
context: S.assembled,
|
|
773
|
+
/**
|
|
774
|
+
* The shape the answer must take, as a JSON Schema document.
|
|
775
|
+
*
|
|
776
|
+
* Optional, and the node is useful without it: an unschema'd
|
|
777
|
+
* request still asks for JSON rather than prose. Supplied, it
|
|
778
|
+
* reaches whichever field the connection's service calls it —
|
|
779
|
+
* Ollama's `format`, OpenAI's `json_schema`, a GBNF grammar on
|
|
780
|
+
* the llama.cpp family — and a connection that takes none
|
|
781
|
+
* ignores it, which is the degradation rule the adapters
|
|
782
|
+
* already follow for `responseFormat`.
|
|
783
|
+
*/
|
|
784
|
+
schema: S.json,
|
|
785
|
+
},
|
|
786
|
+
out: {
|
|
787
|
+
/** The parsed document, which is what this node is for. */
|
|
788
|
+
main: S.json,
|
|
789
|
+
json: S.json,
|
|
790
|
+
/** The value at `path` — the document itself when `path` is empty. */
|
|
791
|
+
value: S.json,
|
|
792
|
+
/** That same value as a list, for a `map` to iterate. */
|
|
793
|
+
items: S.json,
|
|
794
|
+
/** What the model actually wrote, for a reader diagnosing the above. */
|
|
795
|
+
text: S.textStream,
|
|
796
|
+
},
|
|
797
|
+
},
|
|
798
|
+
}));
|
|
799
|
+
/** @experimental */
|
|
800
|
+
export const speak = pin(describeOracleDefinition({
|
|
801
|
+
id: 'core:oracle/speak@1',
|
|
802
|
+
i18n: { name: { en: 'Speak' } },
|
|
803
|
+
shape: S.tts,
|
|
804
|
+
effects: 'external',
|
|
805
|
+
/** Declared, not bound — no handler exists for it yet. */
|
|
806
|
+
provisional: true,
|
|
807
|
+
/** The words to be spoken may be corrected before the call. */
|
|
808
|
+
review: { fields: ['text'] },
|
|
809
|
+
timeoutMs: 60000,
|
|
810
|
+
slots: {
|
|
811
|
+
loadout: LOADOUT_SLOT,
|
|
812
|
+
connection: {
|
|
813
|
+
kind: 'connection',
|
|
814
|
+
quick: true,
|
|
815
|
+
shape: S.tts,
|
|
816
|
+
requires: [tf({ in: [IoKinds.text], out: [IoKinds.audio] })],
|
|
817
|
+
},
|
|
818
|
+
sampling: { kind: 'sampling', quick: true, shape: S.tts },
|
|
819
|
+
template: {
|
|
820
|
+
kind: 'template',
|
|
821
|
+
engine: jinja2.id,
|
|
822
|
+
facet: 'templates',
|
|
823
|
+
},
|
|
824
|
+
params: {
|
|
825
|
+
kind: 'parameters',
|
|
826
|
+
facet: 'weights',
|
|
827
|
+
schema: { skipCodeBlocks: { type: 'boolean', default: true } },
|
|
828
|
+
},
|
|
829
|
+
},
|
|
830
|
+
ports: { in: { text: S.text }, out: { main: S.audio, audio: S.audio } },
|
|
831
|
+
}));
|
|
832
|
+
/**
|
|
833
|
+
* Render an image.
|
|
834
|
+
*
|
|
835
|
+
* The structural twin of `generate-text` and `speak`, which is the whole point:
|
|
836
|
+
* one node KIND (`provider`), one type per modality, and the type's `shape`
|
|
837
|
+
* naming which one. That shape is what makes an image node offerable only an
|
|
838
|
+
* image connection and an image sampling config — and, just as importantly, what
|
|
839
|
+
* gives whatever is wired downstream a settled answer about what comes out of it.
|
|
840
|
+
* A single "generate anything" provider whose ports changed with its connection
|
|
841
|
+
* would be a node no spec could plan around.
|
|
842
|
+
*
|
|
843
|
+
* ## Nothing here belongs to one backend
|
|
844
|
+
*
|
|
845
|
+
* An A1111-compatible server takes width and height directly and names its
|
|
846
|
+
* schedulers its own way; ComfyUI takes a whole graph; a hosted API ignores seed
|
|
847
|
+
* and steps entirely. None
|
|
848
|
+
* of that appears in this declaration, because a slot only one backend honours is
|
|
849
|
+
* a control that does nothing on the other three. What a backend alone offers
|
|
850
|
+
* lives on its CONNECTION, declared by its adapter as a profile schema; what a
|
|
851
|
+
* person means lives here and in the sampling config, and the adapter translates
|
|
852
|
+
* — reporting whatever it could not carry across rather than dropping it quietly.
|
|
853
|
+
*
|
|
854
|
+
* ## Ports
|
|
855
|
+
*
|
|
856
|
+
* `media` carries references, never bytes (media.ts): the run stores the image
|
|
857
|
+
* and passes its uuid on, so a consumer that attaches it and a consumer that
|
|
858
|
+
* posts it both work from the same stored row rather than from a base64 string
|
|
859
|
+
* travelling through the graph. `image` is the first of them, for the common
|
|
860
|
+
* single-image wiring, and `caption` is the prompt that produced it — which is
|
|
861
|
+
* what a message posting the image usually wants as its text.
|
|
862
|
+
*
|
|
863
|
+
* `init` is declared now rather than added later: img2img changes nothing else
|
|
864
|
+
* about this contract, and retrofitting a port onto a published type costs a
|
|
865
|
+
* version bump for every spec pinning it.
|
|
866
|
+
*
|
|
867
|
+
* ## Widened in place (2026-10-12)
|
|
868
|
+
*
|
|
869
|
+
* Additive, so still `@1` — every new port is optional and every new param
|
|
870
|
+
* has a default that reproduces the old behaviour; the descriptor hash moves.
|
|
871
|
+
*
|
|
872
|
+
* - `references` — images the output should RESEMBLE (a likeness). Not
|
|
873
|
+
* `init` (the starting canvas) and not `mask` (where to paint): three
|
|
874
|
+
* different wire fields on every backend that has them.
|
|
875
|
+
* - `series` — the pictures wanted, each `{ key, vars }`. The prompt rows
|
|
876
|
+
* render once per item with `vars` in scope; every media item out carries
|
|
877
|
+
* its `key`. How many CALLS that is, is the host's packing (loop, batch,
|
|
878
|
+
* keyed graph) from the pair's drawing sheet — never the spec's.
|
|
879
|
+
* - `orientation` swaps the longer edge of the sampling's size; `free`
|
|
880
|
+
* takes it as-is.
|
|
881
|
+
* - `cutOut` asks for a transparent background: native where the pair
|
|
882
|
+
* draws one, else the media is flagged for the cut-out task
|
|
883
|
+
* (`native-or-task`), or the bind refuses (`native-only`).
|
|
884
|
+
* - `references: required` refuses a pair that takes no reference image;
|
|
885
|
+
* `preferred` (default) runs anyway, reports `references` as ignored, and
|
|
886
|
+
* says so on the action's form before the run.
|
|
887
|
+
*
|
|
888
|
+
* `requires` stays `[text->image]`: `requires` is a static list, so the gate
|
|
889
|
+
* for reference images is the drawing sheet, read at bind, not a transform.
|
|
890
|
+
* @experimental
|
|
891
|
+
*/
|
|
892
|
+
export const generateImage = pin(describeOracleDefinition({
|
|
893
|
+
id: 'core:oracle/generate-image@1',
|
|
894
|
+
i18n: { name: { en: 'Generate image' } },
|
|
895
|
+
shape: S.imageGen,
|
|
896
|
+
effects: 'external',
|
|
897
|
+
/** The prompt and the negative may be edited; `init` names an asset and may not. */
|
|
898
|
+
review: { fields: ['prompt', 'negative'] },
|
|
899
|
+
// Idle rather than wall: a render is minutes on modest hardware, and a
|
|
900
|
+
// backend still reporting progress is working, not hung.
|
|
901
|
+
timeoutMs: 600000,
|
|
902
|
+
timeoutKind: 'idle',
|
|
903
|
+
slots: {
|
|
904
|
+
loadout: LOADOUT_SLOT,
|
|
905
|
+
connection: {
|
|
906
|
+
kind: 'connection',
|
|
907
|
+
quick: true,
|
|
908
|
+
shape: S.imageGen,
|
|
909
|
+
/**
|
|
910
|
+
* The declaration that makes a KoboldCPP connection offerable
|
|
911
|
+
* here at all: its TYPE says text, and what it can do says
|
|
912
|
+
* otherwise.
|
|
913
|
+
*/
|
|
914
|
+
requires: [tf({ in: [IoKinds.text], out: [IoKinds.image] })],
|
|
915
|
+
description: 'Which image server this step sends its request to.',
|
|
916
|
+
},
|
|
917
|
+
sampling: {
|
|
918
|
+
kind: 'sampling',
|
|
919
|
+
quick: true,
|
|
920
|
+
shape: S.imageGen,
|
|
921
|
+
description: 'Steps, CFG, size, seed — the settings every image backend shares.',
|
|
922
|
+
},
|
|
923
|
+
/**
|
|
924
|
+
* 🚧 The graph a template-payload pair draws with (a ComfyUI
|
|
925
|
+
* workflow). Optional: flat dialects
|
|
926
|
+
* ignore it, and the host's bind guard requires it only when the
|
|
927
|
+
* resolved pair's drawing sheet says `payload: 'template'`.
|
|
928
|
+
*/
|
|
929
|
+
workflow: {
|
|
930
|
+
kind: 'workflow',
|
|
931
|
+
description: 'Which ComfyUI workflow this step draws with, when its image server runs workflows.',
|
|
932
|
+
},
|
|
933
|
+
prompts: {
|
|
934
|
+
kind: 'prompts',
|
|
935
|
+
quick: true,
|
|
936
|
+
facet: 'prompts',
|
|
937
|
+
description: 'How the incoming text becomes what the image model is asked for.',
|
|
938
|
+
fields: {
|
|
939
|
+
positive: { type: 'text' },
|
|
940
|
+
negative: { type: 'text' },
|
|
941
|
+
},
|
|
942
|
+
},
|
|
943
|
+
/**
|
|
944
|
+
* No `facet`, unlike the text nodes' `weights`: the one parameter
|
|
945
|
+
* here decides how the request is SENT, and the weights facet is
|
|
946
|
+
* where a person looks for what the model is asked for.
|
|
947
|
+
*
|
|
948
|
+
* On an image backend `off` is the difference between one request
|
|
949
|
+
* and a render polled for progress and previews, which is the
|
|
950
|
+
* whole of what a background step saves by turning it off.
|
|
951
|
+
*/
|
|
952
|
+
params: {
|
|
953
|
+
kind: 'parameters',
|
|
954
|
+
schema: {
|
|
955
|
+
streaming: streamingParam(),
|
|
956
|
+
orientation: {
|
|
957
|
+
type: 'enum',
|
|
958
|
+
of: ['free', 'square', 'portrait', 'landscape'],
|
|
959
|
+
members: [
|
|
960
|
+
{
|
|
961
|
+
key: 'free',
|
|
962
|
+
label: { en: 'As set' },
|
|
963
|
+
description: { en: "Takes the sampling's width and height as they are." },
|
|
964
|
+
},
|
|
965
|
+
{
|
|
966
|
+
key: 'square',
|
|
967
|
+
label: { en: 'Square' },
|
|
968
|
+
description: { en: 'Both edges become the shorter of the two.' },
|
|
969
|
+
},
|
|
970
|
+
{
|
|
971
|
+
key: 'portrait',
|
|
972
|
+
label: { en: 'Portrait' },
|
|
973
|
+
description: { en: 'Taller than wide: the longer edge is the height.' },
|
|
974
|
+
},
|
|
975
|
+
{
|
|
976
|
+
key: 'landscape',
|
|
977
|
+
label: { en: 'Landscape' },
|
|
978
|
+
description: { en: 'Wider than tall: the longer edge is the width.' },
|
|
979
|
+
},
|
|
980
|
+
],
|
|
981
|
+
default: 'free',
|
|
982
|
+
description: "Which way up the picture is drawn. As set takes the sampling's size unchanged.",
|
|
983
|
+
},
|
|
984
|
+
cutOut: {
|
|
985
|
+
type: 'enum',
|
|
986
|
+
of: ['off', 'native-or-task', 'native-only'],
|
|
987
|
+
members: [
|
|
988
|
+
{
|
|
989
|
+
key: 'off',
|
|
990
|
+
label: { en: 'Off' },
|
|
991
|
+
description: { en: 'Keeps the background the model draws.' },
|
|
992
|
+
},
|
|
993
|
+
{
|
|
994
|
+
key: 'native-or-task',
|
|
995
|
+
label: { en: 'Transparent when possible' },
|
|
996
|
+
description: {
|
|
997
|
+
en: 'Asks the model for a transparent background, or cuts one out afterwards when it cannot.',
|
|
998
|
+
},
|
|
999
|
+
},
|
|
1000
|
+
{
|
|
1001
|
+
key: 'native-only',
|
|
1002
|
+
label: { en: 'Transparent from the model' },
|
|
1003
|
+
description: { en: 'Only runs on a model that draws a transparent background itself.' },
|
|
1004
|
+
},
|
|
1005
|
+
],
|
|
1006
|
+
default: 'off',
|
|
1007
|
+
description: 'Whether the picture needs a transparent background, and where it may come from.',
|
|
1008
|
+
},
|
|
1009
|
+
references: {
|
|
1010
|
+
type: 'enum',
|
|
1011
|
+
of: ['preferred', 'required'],
|
|
1012
|
+
members: [
|
|
1013
|
+
{
|
|
1014
|
+
key: 'preferred',
|
|
1015
|
+
label: { en: 'Preferred' },
|
|
1016
|
+
description: {
|
|
1017
|
+
en: "Runs on a model that can't take a reference image, from the prompt alone, and says so first.",
|
|
1018
|
+
},
|
|
1019
|
+
},
|
|
1020
|
+
{
|
|
1021
|
+
key: 'required',
|
|
1022
|
+
label: { en: 'Required' },
|
|
1023
|
+
description: { en: 'Only runs on a model that takes reference images.' },
|
|
1024
|
+
},
|
|
1025
|
+
],
|
|
1026
|
+
default: 'preferred',
|
|
1027
|
+
description: 'What happens when the model cannot take the reference images wired to this step.',
|
|
1028
|
+
},
|
|
1029
|
+
/**
|
|
1030
|
+
* 🚧 One seed for the whole step:
|
|
1031
|
+
* `per-run` draws a seed once when the sampling's
|
|
1032
|
+
* seed is random and sends it with every call, so a
|
|
1033
|
+
* series drawn on an SD-class model coheres. A sampling
|
|
1034
|
+
* that fixes its own seed keeps it. Models that ignore
|
|
1035
|
+
* seeds ignore this too.
|
|
1036
|
+
*/
|
|
1037
|
+
seed: {
|
|
1038
|
+
type: 'enum',
|
|
1039
|
+
of: ['as-set', 'per-run'],
|
|
1040
|
+
members: [
|
|
1041
|
+
{
|
|
1042
|
+
key: 'as-set',
|
|
1043
|
+
label: { en: 'As set' },
|
|
1044
|
+
description: { en: "Uses the sampling's seed: random stays random for every picture." },
|
|
1045
|
+
},
|
|
1046
|
+
{
|
|
1047
|
+
key: 'per-run',
|
|
1048
|
+
label: { en: 'Same for every picture' },
|
|
1049
|
+
description: {
|
|
1050
|
+
en: 'Picks one seed per run and draws every picture with it, so a set looks alike.',
|
|
1051
|
+
},
|
|
1052
|
+
},
|
|
1053
|
+
],
|
|
1054
|
+
default: 'as-set',
|
|
1055
|
+
description: 'Whether every picture this step draws shares one seed.',
|
|
1056
|
+
},
|
|
1057
|
+
},
|
|
1058
|
+
},
|
|
1059
|
+
},
|
|
1060
|
+
media: { emits: ['image', 'video'] },
|
|
1061
|
+
ports: {
|
|
1062
|
+
in: {
|
|
1063
|
+
prompt: S.text,
|
|
1064
|
+
negative: S.text,
|
|
1065
|
+
/** The starting canvas, for an edit (img2img). Not a reference. */
|
|
1066
|
+
init: S.media,
|
|
1067
|
+
/** Where to paint, for inpainting. Absent edits the whole frame. */
|
|
1068
|
+
mask: S.image,
|
|
1069
|
+
/** Images the output should resemble — a likeness. Not `init`. */
|
|
1070
|
+
references: S.mediaList,
|
|
1071
|
+
/** The pictures wanted, each `{ key, vars }` (`ImageSeriesItemV1`). */
|
|
1072
|
+
series: S.imageSeries,
|
|
1073
|
+
},
|
|
1074
|
+
out: {
|
|
1075
|
+
/**
|
|
1076
|
+
* Each item is a `MediaRef` plus `key` — the series item it was
|
|
1077
|
+
* drawn for (`"1"` without a series). Several items may share a
|
|
1078
|
+
* key (variants); an item with no key is surplus the host kept.
|
|
1079
|
+
*/
|
|
1080
|
+
main: S.mediaList,
|
|
1081
|
+
media: S.mediaList,
|
|
1082
|
+
image: S.image,
|
|
1083
|
+
caption: S.text,
|
|
1084
|
+
},
|
|
1085
|
+
},
|
|
1086
|
+
}));
|
|
1087
|
+
/**
|
|
1088
|
+
* A plugin's own image provider, kept as the worked example of one: same shape,
|
|
1089
|
+
* same slots, a `params` schema of its own. Nothing in core dispatches it.
|
|
1090
|
+
* @internal
|
|
1091
|
+
*/
|
|
1092
|
+
export const renderImage = pin(describeOracleDefinition({
|
|
1093
|
+
id: 'chariot.comfy:render-image@1',
|
|
1094
|
+
shape: S.imageGen,
|
|
1095
|
+
effects: 'external',
|
|
1096
|
+
/** A sample plugin oracle: its payload is a compiled prompt — approve or refuse. */
|
|
1097
|
+
review: { fields: [] },
|
|
1098
|
+
timeoutMs: 300000,
|
|
1099
|
+
slots: {
|
|
1100
|
+
connection: {
|
|
1101
|
+
kind: 'connection',
|
|
1102
|
+
quick: true,
|
|
1103
|
+
shape: S.imageGen,
|
|
1104
|
+
requires: [tf({ in: [IoKinds.text], out: [IoKinds.image] })],
|
|
1105
|
+
},
|
|
1106
|
+
sampling: { kind: 'sampling', quick: true, shape: S.imageGen },
|
|
1107
|
+
prompts: {
|
|
1108
|
+
kind: 'prompts',
|
|
1109
|
+
quick: true,
|
|
1110
|
+
facet: 'prompts',
|
|
1111
|
+
fields: {
|
|
1112
|
+
positive: { type: 'text' },
|
|
1113
|
+
negative: { type: 'text' },
|
|
1114
|
+
},
|
|
1115
|
+
},
|
|
1116
|
+
params: {
|
|
1117
|
+
kind: 'parameters',
|
|
1118
|
+
facet: 'weights',
|
|
1119
|
+
schema: { steps: { type: 'integer', default: 25 } },
|
|
1120
|
+
},
|
|
1121
|
+
},
|
|
1122
|
+
ports: {
|
|
1123
|
+
in: { context: S.assembled },
|
|
1124
|
+
out: { main: S.image, image: S.image },
|
|
1125
|
+
},
|
|
1126
|
+
}));
|
|
1127
|
+
// ── Sprites (DESIGN-sprites §5, 2026-09-24; in-pipeline 2026-10-05) ─────────
|
|
1128
|
+
//
|
|
1129
|
+
// A **sprite** is one labelled image a card can show — an emotion, an outfit,
|
|
1130
|
+
// a pose. After a reply is saved, each reply spec chooses which one the line
|
|
1131
|
+
// shows in two steps it writes out itself: the **sprite picker**
|
|
1132
|
+
// (`core:oracle/pick-sprite@1`), handed the line's own text and whose line it
|
|
1133
|
+
// is, and `show-sprite`, which records the pick on the line.
|
|
1134
|
+
//
|
|
1135
|
+
// Until 2026-10-05 a core-catalog wrapper appended a hidden tail of four nodes
|
|
1136
|
+
// to five reply specs — `sprites-for` (which re-read the line from its message
|
|
1137
|
+
// id and embedded inside the host), a junction, a pure picker task and the
|
|
1138
|
+
// outlet — and the host read the picker's settings ahead of the run. The owner
|
|
1139
|
+
// ruled it in-pipeline: every input is visible where the spec places the step.
|
|
1140
|
+
/**
|
|
1141
|
+
* **The sprite picker** — which sprite a line shows, chosen in one step from
|
|
1142
|
+
* what the reply spec hands it: the line's text, whose line it is, and (when
|
|
1143
|
+
* the spec knows it) the sprite set.
|
|
1144
|
+
*
|
|
1145
|
+
* All in one (owner, 2026-10-05). The step reads what the speaker can show —
|
|
1146
|
+
* the set in force and that set's sprite labels, and the speaker's recent
|
|
1147
|
+
* faces — then embeds the line and the labels, and picks the label whose
|
|
1148
|
+
* vector is closest to the line's, with a small penalty on labels shown in the
|
|
1149
|
+
* speaker's recent lines and a **stickiness margin**: the last shown sprite is
|
|
1150
|
+
* kept unless the best beats it by `margin`, which stops a face flickering on
|
|
1151
|
+
* every line. The receipt answers "why this face": `choices` carries the set
|
|
1152
|
+
* and how it was decided, `pick` the label, its score, the runner-up and
|
|
1153
|
+
* whether stickiness held.
|
|
1154
|
+
*
|
|
1155
|
+
* ⚠ **An oracle, because it embeds.** An embedding model is an external,
|
|
1156
|
+
* nondeterministic source, and with an embedding service it is a provider
|
|
1157
|
+
* call — one per reply whose speaker has sprites, after the reply is saved, so
|
|
1158
|
+
* it never delays the reply. A task is pure and a query may not reach the
|
|
1159
|
+
* network; this step does both of the things they may not.
|
|
1160
|
+
*
|
|
1161
|
+
* ⚠ **No connection slot.** A pipeline never chooses its embedding connection:
|
|
1162
|
+
* the host embeds through the install's one active embedding connection, by
|
|
1163
|
+
* policy, as it does for `embed-text`. Label vectors are the host's to cache
|
|
1164
|
+
* per model.
|
|
1165
|
+
*
|
|
1166
|
+
* **Picks nothing** — null, and embeds nothing — when `enabled` is off, when
|
|
1167
|
+
* the speaker has no sprites (no `speaker`, an envoy, a card with no art), or
|
|
1168
|
+
* when no embedding model is set up: an absent mechanism subtracts a signal, it
|
|
1169
|
+
* never guesses. A fault here must never fail a delivered reply, so the
|
|
1170
|
+
* binding answers a failure with null rather than an error.
|
|
1171
|
+
*
|
|
1172
|
+
* Not `core:outlet/show-sprite@1`, which records a pick; not the sprite set
|
|
1173
|
+
* slot (`core:slot/sprite-set@1`), which is the session's override this step
|
|
1174
|
+
* reads.
|
|
1175
|
+
* @experimental
|
|
1176
|
+
*/
|
|
1177
|
+
export const pickSprite = pin(describeOracleDefinition({
|
|
1178
|
+
id: 'core:oracle/pick-sprite@1',
|
|
1179
|
+
i18n: { name: { en: 'Closest sprite' } },
|
|
1180
|
+
effects: 'external',
|
|
1181
|
+
/** Nothing to edit: a choice among the card's own sprites. */
|
|
1182
|
+
review: { fields: [] },
|
|
1183
|
+
timeoutMs: 5000,
|
|
1184
|
+
slots: {
|
|
1185
|
+
params: {
|
|
1186
|
+
kind: 'parameters',
|
|
1187
|
+
schema: {
|
|
1188
|
+
/**
|
|
1189
|
+
* Sprites off for this session (or instance): the picker
|
|
1190
|
+
* picks nothing and embeds nothing, and faces stay as they
|
|
1191
|
+
* are.
|
|
1192
|
+
*/
|
|
1193
|
+
enabled: {
|
|
1194
|
+
type: 'boolean',
|
|
1195
|
+
label: 'Choose sprites',
|
|
1196
|
+
description: "Choose a sprite for each character's line. Off leaves faces as they are.",
|
|
1197
|
+
default: true,
|
|
1198
|
+
},
|
|
1199
|
+
margin: {
|
|
1200
|
+
type: 'number',
|
|
1201
|
+
label: 'Stickiness',
|
|
1202
|
+
description: 'How much closer a new sprite must be before the face changes. Higher keeps faces steadier.',
|
|
1203
|
+
min: 0,
|
|
1204
|
+
max: 0.5,
|
|
1205
|
+
default: 0.04,
|
|
1206
|
+
},
|
|
1207
|
+
floor: {
|
|
1208
|
+
type: 'number',
|
|
1209
|
+
label: 'Minimum similarity',
|
|
1210
|
+
description: 'A line less similar than this to every sprite keeps the last one, or shows neutral.',
|
|
1211
|
+
min: 0,
|
|
1212
|
+
max: 1,
|
|
1213
|
+
default: 0.1,
|
|
1214
|
+
},
|
|
1215
|
+
},
|
|
1216
|
+
},
|
|
1217
|
+
},
|
|
1218
|
+
ports: {
|
|
1219
|
+
in: {
|
|
1220
|
+
/**
|
|
1221
|
+
* The line's own text — the reply string the spec saved, wired
|
|
1222
|
+
* from the step that produced it. Never re-read from the row:
|
|
1223
|
+
* that is the hidden read this step replaced.
|
|
1224
|
+
*/
|
|
1225
|
+
text: S.text,
|
|
1226
|
+
/**
|
|
1227
|
+
* Whose line it is, as a **participant reference** — the one the
|
|
1228
|
+
* spec wrote the reply row as (the inlet's `speaker`, or a
|
|
1229
|
+
* character turn's own). `character:<id>` has a card, and so may
|
|
1230
|
+
* have sprites; `envoy:<slug>`, or none at all (a narrator's
|
|
1231
|
+
* line), has none, and the pick is null.
|
|
1232
|
+
*/
|
|
1233
|
+
speaker: S.participantRef,
|
|
1234
|
+
/**
|
|
1235
|
+
* The session the line is in — where the set is decided (the
|
|
1236
|
+
* session's override, the cast member's set at the session's
|
|
1237
|
+
* reading) and the speaker's recent faces are found: their
|
|
1238
|
+
* lines in this session other than the one this run is
|
|
1239
|
+
* writing. ⚠ Never read for whose line it is; that is `speaker`.
|
|
1240
|
+
*/
|
|
1241
|
+
scope: S.sessionScope,
|
|
1242
|
+
/**
|
|
1243
|
+
* The sprite set to choose within, when the spec knows it.
|
|
1244
|
+
* Absent — every core spec — the set is decided from the
|
|
1245
|
+
* speaker, in one order: the session's override, then the cast
|
|
1246
|
+
* member's set, then the card's default set. A name the card
|
|
1247
|
+
* has no set by falls to the default set and says so on
|
|
1248
|
+
* `choices`, never silently.
|
|
1249
|
+
*/
|
|
1250
|
+
set: S.text,
|
|
1251
|
+
},
|
|
1252
|
+
out: {
|
|
1253
|
+
/** The pick, `sprite-pick@1`: `{ set, label, … }`, or null for none. */
|
|
1254
|
+
main: S.spritePick,
|
|
1255
|
+
pick: S.spritePick,
|
|
1256
|
+
/**
|
|
1257
|
+
* What the speaker could show, and how the set was decided
|
|
1258
|
+
* (`decidedBy`, `missing`) — for the receipt, never for the line.
|
|
1259
|
+
*/
|
|
1260
|
+
choices: S.spriteChoices,
|
|
1261
|
+
},
|
|
1262
|
+
},
|
|
1263
|
+
}));
|
|
1264
|
+
// ── Summarization ───────────────────────────────────────────────────────────
|
|
1265
|
+
/** Phase 1 — one batch, drafted without sight of any other. @internal */
|
|
1266
|
+
export const summarizeBatch = pin(describeOracleDefinition({
|
|
1267
|
+
id: 'core:oracle/summarize-batch@1',
|
|
1268
|
+
/** Runs best on a low-temperature, short-answer preset — a suggestion, never a gate. */
|
|
1269
|
+
prefers: { sampling: 'sampling-extraction' },
|
|
1270
|
+
i18n: { name: { en: 'Draft a batch' } },
|
|
1271
|
+
shape: S.textGen,
|
|
1272
|
+
effects: 'external',
|
|
1273
|
+
/** A drafting call over a batch: approve or refuse. */
|
|
1274
|
+
review: { fields: [] },
|
|
1275
|
+
timeoutMs: 120000,
|
|
1276
|
+
timeoutKind: 'idle',
|
|
1277
|
+
usage: 'response.usage',
|
|
1278
|
+
/**
|
|
1279
|
+
* The first interior point, and core dogfooding it:
|
|
1280
|
+
* every intermediate draft passes the user's chain before synthesis
|
|
1281
|
+
* reads it — slop killed in the material summaries are built *from*,
|
|
1282
|
+
* not only in final replies. Invoked by the binding via
|
|
1283
|
+
* `ctx.scripts.applyText('each-draft', …)`; recorded per application
|
|
1284
|
+
* as `appliedBy: 'binding'`. Declares what it accepts: a draft
|
|
1285
|
+
* is text, so text transforms — said here rather than assumed by the
|
|
1286
|
+
* broker, which is the difference between a point a plugin can shape
|
|
1287
|
+
* and a literal in the executor.
|
|
1288
|
+
*/
|
|
1289
|
+
scriptPoints: [
|
|
1290
|
+
{
|
|
1291
|
+
key: 'each-draft',
|
|
1292
|
+
accepts: ['core:script:text/transform@1'],
|
|
1293
|
+
label: { en: 'Each draft' },
|
|
1294
|
+
description: {
|
|
1295
|
+
en: 'Runs over every intermediate draft this step produces, before synthesis reads them.',
|
|
1296
|
+
},
|
|
1297
|
+
},
|
|
1298
|
+
],
|
|
1299
|
+
slots: {
|
|
1300
|
+
loadout: LOADOUT_SLOT,
|
|
1301
|
+
connection: {
|
|
1302
|
+
kind: 'connection',
|
|
1303
|
+
quick: true,
|
|
1304
|
+
shape: S.textGen,
|
|
1305
|
+
requires: [tf({ in: [IoKinds.text], out: [IoKinds.text] })],
|
|
1306
|
+
},
|
|
1307
|
+
sampling: { kind: 'sampling', quick: true, shape: S.textGen },
|
|
1308
|
+
prompts: {
|
|
1309
|
+
kind: 'prompts',
|
|
1310
|
+
quick: true,
|
|
1311
|
+
facet: 'prompts',
|
|
1312
|
+
fields: { batch: { type: 'text' } },
|
|
1313
|
+
},
|
|
1314
|
+
},
|
|
1315
|
+
ports: {
|
|
1316
|
+
// `request` carries what a person asked for — the topic line, most
|
|
1317
|
+
// visibly — so the drafting prompt can honour it. The whole request
|
|
1318
|
+
// object travels rather than a plucked field, because what the
|
|
1319
|
+
// request holds is the socket's contract with its modal, not this
|
|
1320
|
+
// node's to enumerate.
|
|
1321
|
+
in: {
|
|
1322
|
+
batch: S.messages,
|
|
1323
|
+
request: S.summarizeRequest,
|
|
1324
|
+
/**
|
|
1325
|
+
* Which kind of entry this pipeline writes — the word every
|
|
1326
|
+
* summarize prompt template branches on (D-I).
|
|
1327
|
+
*
|
|
1328
|
+
* ## A port, not a parameter, and the call site is what decides
|
|
1329
|
+
*
|
|
1330
|
+
* `summarizeSpec` writes it as a **literal into the node's
|
|
1331
|
+
* config**, in the same map as `batch` and `request` and
|
|
1332
|
+
* alongside them: `C.summarizeBatch.v1({ batch, request,
|
|
1333
|
+
* loreType, … })`. `resolveInput` passes a non-ref config value
|
|
1334
|
+
* through untouched, so the binding reads `input.loreType`
|
|
1335
|
+
* exactly the way it reads a port — same position, same access,
|
|
1336
|
+
* same absence-is-`undefined`. Declaring it as anything else
|
|
1337
|
+
* would describe a mechanism that is not the one running.
|
|
1338
|
+
*
|
|
1339
|
+
* A `params` field is the alternative, and it is the wrong one
|
|
1340
|
+
* twice over. It would move the read to `input.params.loreType`
|
|
1341
|
+
* — a different value from a different layer — and it would put
|
|
1342
|
+
* the control in the panel, stored per configuration and
|
|
1343
|
+
* layered instance → user → session like every other parameter.
|
|
1344
|
+
* `SummarizeShape` in the catalog already rules on that: this is
|
|
1345
|
+
* "the thing that distinguishes the four namespaces from one
|
|
1346
|
+
* another", and a user who changed it "would turn their scene
|
|
1347
|
+
* summarizer into a world summarizer without renaming
|
|
1348
|
+
* anything".
|
|
1349
|
+
*
|
|
1350
|
+
* ⚠ An in-port no edge feeds is not a contradiction here. A
|
|
1351
|
+
* port is a named input the node reads; where the value comes
|
|
1352
|
+
* from — an upstream node, or an author writing it down — is the
|
|
1353
|
+
* document's business. What the declaration buys is that the
|
|
1354
|
+
* name is now checkable: the app's binding types derive their
|
|
1355
|
+
* legal reads from `ports.in`, so `input.loreTypes` stops
|
|
1356
|
+
* compiling, and the panel and the plugin validator can both see
|
|
1357
|
+
* that this node takes one.
|
|
1358
|
+
*
|
|
1359
|
+
* `text` rather than an enum shape: a shape ids a payload, and
|
|
1360
|
+
* the four legal words are the prompt templates' vocabulary,
|
|
1361
|
+
* which a plugin summarizer is free to extend.
|
|
1362
|
+
*/
|
|
1363
|
+
loreType: S.text,
|
|
1364
|
+
},
|
|
1365
|
+
out: { main: S.textStream, draft: S.textStream },
|
|
1366
|
+
},
|
|
1367
|
+
}));
|
|
1368
|
+
/** Phase 2 — the ordered drafts merged into one past-tense narrative. @internal */
|
|
1369
|
+
export const summarizeSynth = pin(describeOracleDefinition({
|
|
1370
|
+
id: 'core:oracle/summarize-synth@1',
|
|
1371
|
+
/** Runs best on a low-temperature, short-answer preset — a suggestion, never a gate. */
|
|
1372
|
+
prefers: { sampling: 'sampling-extraction' },
|
|
1373
|
+
i18n: { name: { en: 'Synthesize the drafts' } },
|
|
1374
|
+
shape: S.textGen,
|
|
1375
|
+
effects: 'external',
|
|
1376
|
+
/** The merge call: approve or refuse. */
|
|
1377
|
+
review: { fields: [] },
|
|
1378
|
+
timeoutMs: 120000,
|
|
1379
|
+
timeoutKind: 'idle',
|
|
1380
|
+
usage: 'response.usage',
|
|
1381
|
+
slots: {
|
|
1382
|
+
loadout: LOADOUT_SLOT,
|
|
1383
|
+
connection: {
|
|
1384
|
+
kind: 'connection',
|
|
1385
|
+
quick: true,
|
|
1386
|
+
shape: S.textGen,
|
|
1387
|
+
requires: [tf({ in: [IoKinds.text], out: [IoKinds.text] })],
|
|
1388
|
+
},
|
|
1389
|
+
sampling: { kind: 'sampling', quick: true, shape: S.textGen },
|
|
1390
|
+
prompts: {
|
|
1391
|
+
kind: 'prompts',
|
|
1392
|
+
quick: true,
|
|
1393
|
+
facet: 'prompts',
|
|
1394
|
+
fields: { synth: { type: 'text' } },
|
|
1395
|
+
},
|
|
1396
|
+
},
|
|
1397
|
+
ports: {
|
|
1398
|
+
// Same `request` pass-through as the batch step: the topic reaches
|
|
1399
|
+
// synthesis too, or a focused summary drifts back to a general one
|
|
1400
|
+
// the moment the drafts are merged.
|
|
1401
|
+
in: {
|
|
1402
|
+
drafts: S.drafts,
|
|
1403
|
+
request: S.summarizeRequest,
|
|
1404
|
+
/** Authored on the node, exactly as on the batch step — see it. */
|
|
1405
|
+
loreType: S.text,
|
|
1406
|
+
},
|
|
1407
|
+
out: { main: S.textStream, content: S.textStream },
|
|
1408
|
+
},
|
|
1409
|
+
}));
|
|
1410
|
+
/** What the entry gets called. Its own step because it has its own prompt. @internal */
|
|
1411
|
+
export const nameEntry = pin(describeOracleDefinition({
|
|
1412
|
+
id: 'core:oracle/name-entry@1',
|
|
1413
|
+
/** Runs best on a low-temperature, short-answer preset — a suggestion, never a gate. */
|
|
1414
|
+
prefers: { sampling: 'sampling-extraction' },
|
|
1415
|
+
i18n: { name: { en: 'Name the entry' } },
|
|
1416
|
+
shape: S.textGen,
|
|
1417
|
+
effects: 'external',
|
|
1418
|
+
/** Approve or refuse; the name it produces is reviewed at the entry's write. */
|
|
1419
|
+
review: { fields: [] },
|
|
1420
|
+
timeoutMs: 60000,
|
|
1421
|
+
usage: 'response.usage',
|
|
1422
|
+
slots: {
|
|
1423
|
+
loadout: LOADOUT_SLOT,
|
|
1424
|
+
connection: {
|
|
1425
|
+
kind: 'connection',
|
|
1426
|
+
quick: true,
|
|
1427
|
+
shape: S.textGen,
|
|
1428
|
+
requires: [tf({ in: [IoKinds.text], out: [IoKinds.text] })],
|
|
1429
|
+
},
|
|
1430
|
+
sampling: { kind: 'sampling', quick: true, shape: S.textGen },
|
|
1431
|
+
prompts: {
|
|
1432
|
+
kind: 'prompts',
|
|
1433
|
+
quick: true,
|
|
1434
|
+
facet: 'prompts',
|
|
1435
|
+
fields: { name: { type: 'text' } },
|
|
1436
|
+
},
|
|
1437
|
+
},
|
|
1438
|
+
ports: {
|
|
1439
|
+
in: {
|
|
1440
|
+
content: S.text,
|
|
1441
|
+
/** Authored on the node, exactly as on the two steps above — see them. */
|
|
1442
|
+
loreType: S.text,
|
|
1443
|
+
},
|
|
1444
|
+
out: { main: S.textStream, name: S.textStream },
|
|
1445
|
+
},
|
|
1446
|
+
}));
|
|
1447
|
+
/**
|
|
1448
|
+
* Who was in the scene — scene summaries only.
|
|
1449
|
+
*
|
|
1450
|
+
* Present on one summarize pipeline and not the other three, which is exactly
|
|
1451
|
+
* why they are four specs rather than one spec with a flag. A flag would put the
|
|
1452
|
+
* difference in a condition somebody has to find; four specs put it in the shape.
|
|
1453
|
+
* @internal
|
|
1454
|
+
*/
|
|
1455
|
+
export const extractCast = pin(describeOracleDefinition({
|
|
1456
|
+
id: 'core:oracle/extract-cast@1',
|
|
1457
|
+
/** Runs best on a low-temperature, short-answer preset — a suggestion, never a gate. */
|
|
1458
|
+
prefers: { sampling: 'sampling-extraction' },
|
|
1459
|
+
i18n: { name: { en: 'Extract the cast' } },
|
|
1460
|
+
shape: S.textGen,
|
|
1461
|
+
effects: 'external',
|
|
1462
|
+
/** Approve or refuse. */
|
|
1463
|
+
review: { fields: [] },
|
|
1464
|
+
timeoutMs: 60000,
|
|
1465
|
+
usage: 'response.usage',
|
|
1466
|
+
slots: {
|
|
1467
|
+
loadout: LOADOUT_SLOT,
|
|
1468
|
+
connection: {
|
|
1469
|
+
kind: 'connection',
|
|
1470
|
+
quick: true,
|
|
1471
|
+
shape: S.textGen,
|
|
1472
|
+
requires: [tf({ in: [IoKinds.text], out: [IoKinds.text] })],
|
|
1473
|
+
},
|
|
1474
|
+
sampling: { kind: 'sampling', quick: true, shape: S.textGen },
|
|
1475
|
+
prompts: {
|
|
1476
|
+
kind: 'prompts',
|
|
1477
|
+
quick: true,
|
|
1478
|
+
facet: 'prompts',
|
|
1479
|
+
fields: { characterExtraction: { type: 'text' } },
|
|
1480
|
+
},
|
|
1481
|
+
/**
|
|
1482
|
+
* The two halves of a replaceable core function, on the scripts
|
|
1483
|
+
* rung. Scripts here *shape* the extraction — what the model reads,
|
|
1484
|
+
* what the pipeline keeps. Replacing the extractor itself is the
|
|
1485
|
+
* other rung: a same-shaped provider offered by the swap list,
|
|
1486
|
+
* because extraction calls a model and scripts are pure compute.
|
|
1487
|
+
*/
|
|
1488
|
+
scripts: {
|
|
1489
|
+
kind: 'scripts',
|
|
1490
|
+
accepts: ['core:script:text/transform@1'],
|
|
1491
|
+
port: 'content',
|
|
1492
|
+
phase: 'before',
|
|
1493
|
+
description: 'Scripts over the scene text before the extractor reads it — strip out-of-character chatter, normalise a nickname, redact.',
|
|
1494
|
+
},
|
|
1495
|
+
castScripts: {
|
|
1496
|
+
kind: 'scripts',
|
|
1497
|
+
accepts: ['core:script:cast/transform@1'],
|
|
1498
|
+
port: 'cast',
|
|
1499
|
+
phase: 'after',
|
|
1500
|
+
description: 'Scripts over the extracted cast — rename someone, merge aliases, drop a junk detection, add someone the model missed.',
|
|
1501
|
+
},
|
|
1502
|
+
},
|
|
1503
|
+
ports: {
|
|
1504
|
+
// `request` carries the known cast list ([id: N] entries) so the
|
|
1505
|
+
// extraction prompt can reference real ids — without it the model
|
|
1506
|
+
// invents castIds and the resolve step silently drops every one.
|
|
1507
|
+
//
|
|
1508
|
+
// ⚠ No `messages` in-port, and there was one (culled 2026-09-16,
|
|
1509
|
+
// R-12). `summarize` wired the transcript into it and the handler
|
|
1510
|
+
// never read it: the extractor works from `content` — the synthesised
|
|
1511
|
+
// summary — which is what the prompt builder takes. A port a spec
|
|
1512
|
+
// fills and nothing reads costs the run a copy of the transcript
|
|
1513
|
+
// and tells a reader the extractor sees it.
|
|
1514
|
+
in: {
|
|
1515
|
+
content: S.text,
|
|
1516
|
+
request: S.summarizeRequest,
|
|
1517
|
+
},
|
|
1518
|
+
out: { main: S.json, cast: S.json },
|
|
1519
|
+
},
|
|
1520
|
+
}));
|
|
1521
|
+
// ── Graph build ─────────────────────────────────────────────────────────────
|
|
1522
|
+
const graphStep = (id, label, field, extra = {}) => pin(describeOracleDefinition({
|
|
1523
|
+
id,
|
|
1524
|
+
i18n: { name: { en: label } },
|
|
1525
|
+
shape: S.textGen,
|
|
1526
|
+
effects: 'external',
|
|
1527
|
+
/** Each graph step sends a compiled prompt: approve or refuse. */
|
|
1528
|
+
review: { fields: [] },
|
|
1529
|
+
timeoutMs: extra.timeoutMs ?? 120000,
|
|
1530
|
+
timeoutKind: 'idle',
|
|
1531
|
+
usage: 'response.usage',
|
|
1532
|
+
slots: {
|
|
1533
|
+
loadout: LOADOUT_SLOT,
|
|
1534
|
+
connection: {
|
|
1535
|
+
kind: 'connection',
|
|
1536
|
+
quick: true,
|
|
1537
|
+
shape: S.textGen,
|
|
1538
|
+
requires: [tf({ in: [IoKinds.text], out: [IoKinds.text] })],
|
|
1539
|
+
},
|
|
1540
|
+
sampling: { kind: 'sampling', quick: true, shape: S.textGen },
|
|
1541
|
+
prompts: {
|
|
1542
|
+
kind: 'prompts',
|
|
1543
|
+
quick: true,
|
|
1544
|
+
facet: 'prompts',
|
|
1545
|
+
fields: { [field]: { type: 'text' } },
|
|
1546
|
+
},
|
|
1547
|
+
},
|
|
1548
|
+
ports: {
|
|
1549
|
+
in: { scenes: S.graphScenes },
|
|
1550
|
+
out: { main: S.json, result: S.json },
|
|
1551
|
+
},
|
|
1552
|
+
}));
|
|
1553
|
+
/** Which existing node a mentioned name refers to, or whether it is new. @internal */
|
|
1554
|
+
export const graphNodeResolution = graphStep('core:oracle/graph-node-resolution@1', 'Resolve nodes', 'nodeResolution');
|
|
1555
|
+
/** Drop what is not worth graphing before the expensive steps run. @internal */
|
|
1556
|
+
export const graphPreFilter = graphStep('core:oracle/graph-pre-filter@1', 'Pre-filter', 'preFilter');
|
|
1557
|
+
/** Whose account of the scene this is. @internal */
|
|
1558
|
+
export const graphPerspective = graphStep('core:oracle/graph-perspective@1', 'Perspective', 'perspective');
|
|
1559
|
+
/** The two-sentence introduction written for a newly discovered character. @internal */
|
|
1560
|
+
export const graphNodeDescription = graphStep('core:oracle/graph-node-description@1', 'Describe new nodes', 'nodeDescription');
|
|
1561
|
+
/** Did any present character reach a new lifecycle state this scene? @internal */
|
|
1562
|
+
export const graphStateDetection = graphStep('core:oracle/graph-state-detection@1', 'Detect state changes', 'stateDetection');
|
|
1563
|
+
/**
|
|
1564
|
+
* 🚧 **Describe image** — a model that reads pictures is shown one or more
|
|
1565
|
+
* images and asked one written question about them; its answer is the text
|
|
1566
|
+
* out (*Describe from image*, 2026-10-12).
|
|
1567
|
+
*
|
|
1568
|
+
* Not `generate-text`: that node sends an assembled TURN (a transcript, a
|
|
1569
|
+
* speaker, a reply being continued) and its connection requires only
|
|
1570
|
+
* `text->text`, so it resolves to the instance's chat default. This node
|
|
1571
|
+
* sends no transcript — one instruction plus the images — and its connection
|
|
1572
|
+
* REQUIRES `text+image->text`, so an unset slot resolves to the default of
|
|
1573
|
+
* that job (the model that reads pictures), never to the chat model.
|
|
1574
|
+
*
|
|
1575
|
+
* Not a caption either: `caption` is `generate-image`'s out-port (the text a
|
|
1576
|
+
* picture is posted with). This node's answer is whatever the instruction
|
|
1577
|
+
* asks for — a tag list of a person's look, for the likeness helper.
|
|
1578
|
+
*
|
|
1579
|
+
* The instruction is the `prompts` slot's `instruction` field (a prompt
|
|
1580
|
+
* row), so an admin rewrites the question in Admin › Pipelines.
|
|
1581
|
+
* @experimental
|
|
1582
|
+
*/
|
|
1583
|
+
export const describeImage = pin(describeOracleDefinition({
|
|
1584
|
+
id: 'core:oracle/describe-image@1',
|
|
1585
|
+
i18n: {
|
|
1586
|
+
name: { en: 'Describe image' },
|
|
1587
|
+
description: { en: 'Shows a model that reads pictures an image and asks it one question about it.' },
|
|
1588
|
+
},
|
|
1589
|
+
shape: S.textGen,
|
|
1590
|
+
effects: 'external',
|
|
1591
|
+
/** The instruction is config and the images are references: approve or refuse. */
|
|
1592
|
+
review: { fields: [] },
|
|
1593
|
+
timeoutMs: 120000,
|
|
1594
|
+
timeoutKind: 'idle',
|
|
1595
|
+
usage: 'response.usage',
|
|
1596
|
+
slots: {
|
|
1597
|
+
loadout: LOADOUT_SLOT,
|
|
1598
|
+
connection: {
|
|
1599
|
+
kind: 'connection',
|
|
1600
|
+
quick: true,
|
|
1601
|
+
shape: S.textGen,
|
|
1602
|
+
/** A model that reads images — the job default this resolves to when unset. */
|
|
1603
|
+
requires: [tf({ in: [IoKinds.text, IoKinds.image], out: [IoKinds.text] })],
|
|
1604
|
+
description: 'Which model reads the picture. It must be one that can see images.',
|
|
1605
|
+
},
|
|
1606
|
+
sampling: {
|
|
1607
|
+
kind: 'sampling',
|
|
1608
|
+
quick: true,
|
|
1609
|
+
shape: S.textGen,
|
|
1610
|
+
description: 'The sampling settings used for this request.',
|
|
1611
|
+
},
|
|
1612
|
+
prompts: {
|
|
1613
|
+
kind: 'prompts',
|
|
1614
|
+
quick: true,
|
|
1615
|
+
facet: 'prompts',
|
|
1616
|
+
description: 'The question the model is asked about the picture.',
|
|
1617
|
+
fields: {
|
|
1618
|
+
instruction: { type: 'text' },
|
|
1619
|
+
},
|
|
1620
|
+
},
|
|
1621
|
+
},
|
|
1622
|
+
media: { accepts: ['image'] },
|
|
1623
|
+
ports: {
|
|
1624
|
+
in: {
|
|
1625
|
+
/** The pictures to read, in order. Empty refuses: there is nothing to describe. */
|
|
1626
|
+
images: S.mediaList,
|
|
1627
|
+
},
|
|
1628
|
+
out: {
|
|
1629
|
+
main: S.text,
|
|
1630
|
+
text: S.text,
|
|
1631
|
+
},
|
|
1632
|
+
},
|
|
1633
|
+
}));
|
|
1634
|
+
//# sourceMappingURL=oracles.js.map
|