@agenticprimitives/orchestration 0.0.0-alpha.1 → 0.0.0-alpha.11

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.
Files changed (114) hide show
  1. package/README.md +2 -0
  2. package/dist/admission.d.ts +127 -0
  3. package/dist/admission.d.ts.map +1 -0
  4. package/dist/admission.js +355 -0
  5. package/dist/admission.js.map +1 -0
  6. package/dist/answer-quality.d.ts +80 -0
  7. package/dist/answer-quality.d.ts.map +1 -0
  8. package/dist/answer-quality.js +97 -0
  9. package/dist/answer-quality.js.map +1 -0
  10. package/dist/artifacts.d.ts +137 -0
  11. package/dist/artifacts.d.ts.map +1 -0
  12. package/dist/artifacts.js +232 -0
  13. package/dist/artifacts.js.map +1 -0
  14. package/dist/authority.d.ts +465 -0
  15. package/dist/authority.d.ts.map +1 -0
  16. package/dist/authority.js +2 -0
  17. package/dist/authority.js.map +1 -0
  18. package/dist/conformance.d.ts +66 -0
  19. package/dist/conformance.d.ts.map +1 -0
  20. package/dist/conformance.js +140 -0
  21. package/dist/conformance.js.map +1 -0
  22. package/dist/derivation.d.ts +21 -0
  23. package/dist/derivation.d.ts.map +1 -0
  24. package/dist/derivation.js +31 -0
  25. package/dist/derivation.js.map +1 -0
  26. package/dist/durable.d.ts +44 -0
  27. package/dist/durable.d.ts.map +1 -0
  28. package/dist/durable.js +15 -0
  29. package/dist/durable.js.map +1 -0
  30. package/dist/export-port.d.ts +13 -0
  31. package/dist/export-port.d.ts.map +1 -0
  32. package/dist/export-port.js +2 -0
  33. package/dist/export-port.js.map +1 -0
  34. package/dist/flow-trace.d.ts +105 -0
  35. package/dist/flow-trace.d.ts.map +1 -0
  36. package/dist/flow-trace.js +60 -0
  37. package/dist/flow-trace.js.map +1 -0
  38. package/dist/index.d.ts +37 -4
  39. package/dist/index.d.ts.map +1 -1
  40. package/dist/index.js +44 -3
  41. package/dist/index.js.map +1 -1
  42. package/dist/input.d.ts +165 -0
  43. package/dist/input.d.ts.map +1 -0
  44. package/dist/input.js +33 -0
  45. package/dist/input.js.map +1 -0
  46. package/dist/intent.d.ts +37 -0
  47. package/dist/intent.d.ts.map +1 -0
  48. package/dist/intent.js +46 -0
  49. package/dist/intent.js.map +1 -0
  50. package/dist/judgment.d.ts +131 -0
  51. package/dist/judgment.d.ts.map +1 -0
  52. package/dist/judgment.js +249 -0
  53. package/dist/judgment.js.map +1 -0
  54. package/dist/loop.d.ts +155 -6
  55. package/dist/loop.d.ts.map +1 -1
  56. package/dist/loop.js +905 -32
  57. package/dist/loop.js.map +1 -1
  58. package/dist/metrics.d.ts +35 -0
  59. package/dist/metrics.d.ts.map +1 -0
  60. package/dist/metrics.js +98 -0
  61. package/dist/metrics.js.map +1 -0
  62. package/dist/outcome.d.ts +223 -0
  63. package/dist/outcome.d.ts.map +1 -0
  64. package/dist/outcome.js +325 -0
  65. package/dist/outcome.js.map +1 -0
  66. package/dist/plan-digest.d.ts +6 -0
  67. package/dist/plan-digest.d.ts.map +1 -0
  68. package/dist/plan-digest.js +35 -0
  69. package/dist/plan-digest.js.map +1 -0
  70. package/dist/planner-wire.d.ts +11 -0
  71. package/dist/planner-wire.d.ts.map +1 -0
  72. package/dist/planner-wire.js +53 -0
  73. package/dist/planner-wire.js.map +1 -0
  74. package/dist/planner.d.ts +51 -0
  75. package/dist/planner.d.ts.map +1 -1
  76. package/dist/planner.js +74 -0
  77. package/dist/planner.js.map +1 -1
  78. package/dist/reconcile.d.ts +41 -0
  79. package/dist/reconcile.d.ts.map +1 -0
  80. package/dist/reconcile.js +20 -0
  81. package/dist/reconcile.js.map +1 -0
  82. package/dist/record.d.ts +238 -0
  83. package/dist/record.d.ts.map +1 -0
  84. package/dist/record.js +116 -0
  85. package/dist/record.js.map +1 -0
  86. package/dist/regression.d.ts +109 -0
  87. package/dist/regression.d.ts.map +1 -0
  88. package/dist/regression.js +97 -0
  89. package/dist/regression.js.map +1 -0
  90. package/dist/selection.d.ts +334 -0
  91. package/dist/selection.d.ts.map +1 -0
  92. package/dist/selection.js +481 -0
  93. package/dist/selection.js.map +1 -0
  94. package/dist/spans.d.ts +262 -0
  95. package/dist/spans.d.ts.map +1 -0
  96. package/dist/spans.js +589 -0
  97. package/dist/spans.js.map +1 -0
  98. package/dist/tool-invoker.d.ts +61 -3
  99. package/dist/tool-invoker.d.ts.map +1 -1
  100. package/dist/tool-invoker.js +26 -1
  101. package/dist/tool-invoker.js.map +1 -1
  102. package/dist/trace-context.d.ts +26 -0
  103. package/dist/trace-context.d.ts.map +1 -0
  104. package/dist/trace-context.js +59 -0
  105. package/dist/trace-context.js.map +1 -0
  106. package/dist/trace-facts.d.ts +84 -0
  107. package/dist/trace-facts.d.ts.map +1 -0
  108. package/dist/trace-facts.js +82 -0
  109. package/dist/trace-facts.js.map +1 -0
  110. package/dist/types.d.ts +265 -3
  111. package/dist/types.d.ts.map +1 -1
  112. package/dist/types.js +4 -0
  113. package/dist/types.js.map +1 -1
  114. package/package.json +19 -7
@@ -0,0 +1,325 @@
1
+ // OUTCOME-DIRECTED INTENT — spec 417. A person does not want a skill; they want an OUTCOME, and the domain's data graph
2
+ // already says which skill PRODUCES which class and which classes it CONSUMES. So selection splits by logic:
3
+ //
4
+ // what outcome is wanted a JUDGMENT (probabilistic): the terminal skill, read as the outcome it produces, and — in
5
+ // the same call — which consumed classes the request itself supplies (typed yes-no, J9);
6
+ // how it is reached a RULE (exact): back from the terminal skill through `consumes` — a class the request
7
+ // supplies or the asker HOLDS needs nothing; one another skill produces prepends that skill;
8
+ // anything else is MISSING and named. Context shortens the path; it never lengthens it.
9
+ //
10
+ // A judge picks the outcome; a rule over the ontology builds the path; neither allows — every step of a chain still runs
11
+ // every gate. Pure: the harness passes the asker's held classes in; nothing is read here.
12
+ import { judgeQuestions, structuredCallDecisionModel, applyDecisionRule, explainAnswer, NOT_APPLICABLE } from './judgment.js';
13
+ import { inferIntent, renderReading, skillCard } from './intent.js';
14
+ export const OUTCOME_JUDGE = { name: 'ap.outcome-judge.v1', kind: 'model' };
15
+ /** The dataflow graph of a skill set. Deterministic: the same tools give the same graph. */
16
+ export function outcomeGraphOf(tools) {
17
+ const producersOf = {};
18
+ const consumesOf = {};
19
+ const labels = {};
20
+ const parties = {};
21
+ const necessity = {};
22
+ for (const t of [...tools].sort((a, b) => a.id.localeCompare(b.id))) {
23
+ for (const c of t.produces ?? []) {
24
+ (producersOf[c.iri] ??= []).push(t.id);
25
+ labels[c.iri] = c.label;
26
+ if (c.about)
27
+ parties[`${t.id}|produces|${c.iri}`] = c.about.iri;
28
+ }
29
+ consumesOf[t.id] = (t.consumes ?? []).map((c) => { labels[c.iri] = c.label; if (c.about)
30
+ parties[`${t.id}|consumes|${c.iri}`] = c.about.iri; if (c.necessity)
31
+ necessity[`${t.id}|${c.iri}`] = c.necessity; return c.iri; }).sort();
32
+ }
33
+ return { producersOf, consumesOf, labels, parties, necessity };
34
+ }
35
+ /** Every arrow of the graph: `producer` makes the `class` that `consumer` works from. What a request may confirm. */
36
+ export function edgesOf(graph) {
37
+ return Object.entries(graph.consumesOf).flatMap(([consumer, cs]) => cs.flatMap((c) => (graph.producersOf[c] ?? []).filter((p) => p !== consumer).map((producer) => ({ producer, class: c, consumer }))));
38
+ }
39
+ export const edgeKey = (e) => `${e.producer}|${e.class}|${e.consumer}`;
40
+ /** Spec 418 §1 — THE RULE ON AN ARROW, from whose each end is: both ends qualified ⇒ the arrow holds exactly when the
41
+ * parties agree (our own scorecard never feeds a grantee's diligence); either end unqualified ⇒ undecided (`null`), and
42
+ * only then is the request asked. */
43
+ export function edgeByParty(graph, e) {
44
+ const made = graph.parties[`${e.producer}|produces|${e.class}`];
45
+ const wanted = graph.parties[`${e.consumer}|consumes|${e.class}`];
46
+ return made && wanted ? made === wanted : null;
47
+ }
48
+ /** Every class some skill consumes — what "does the request supply it?" is asked about. */
49
+ export function consumedClassesOf(graph) {
50
+ return [...new Set(Object.values(graph.consumesOf).flat())].sort();
51
+ }
52
+ export const DEFAULT_OUTCOME_BOUNDS = { maxDepth: 3, maxSteps: 4 };
53
+ /**
54
+ * THE RULE: the minimal path to `terminal`'s outcome. Each consumed class is satisfied, in this order, by the request,
55
+ * by what the asker holds, by a producer already on the path, by a new producer (recursing, bounded, no cycles), or
56
+ * named missing. Deterministic.
57
+ */
58
+ export function planForOutcome(graph, terminal, have, bounds = DEFAULT_OUTCOME_BOUNDS) {
59
+ const steps = [];
60
+ const satisfied = {};
61
+ const missing = new Set();
62
+ const ambiguous = new Set();
63
+ const optional = new Set();
64
+ let tooLong = false;
65
+ const onPath = new Set();
66
+ const visit = (tool, depth, forClass) => {
67
+ onPath.add(tool);
68
+ const from = [];
69
+ for (const c of graph.consumesOf[tool] ?? []) {
70
+ const was = satisfied[c];
71
+ if (was !== undefined) {
72
+ if (typeof was === 'object')
73
+ from.push({ tool: was.step, class: c });
74
+ continue;
75
+ }
76
+ if (have.supplied.has(c)) {
77
+ satisfied[c] = 'request';
78
+ continue;
79
+ }
80
+ if (have.held.has(c)) {
81
+ satisfied[c] = 'held';
82
+ continue;
83
+ }
84
+ // An ENRICHING input is produced only when the request says it is absent; otherwise the step stands without it.
85
+ const enriching = graph.necessity[`${tool}|${c}`] === 'enriching';
86
+ if (enriching && !have.absent?.has(c)) {
87
+ optional.add(c);
88
+ continue;
89
+ }
90
+ // A TYPE says a producer could make the class; the REQUEST says whether it would make THIS one (the grantee's
91
+ // scorecard is not the one our own assessment produces). An edge the request does not confirm is not taken.
92
+ const producers = (graph.producersOf[c] ?? []).filter((p) => p !== tool && !onPath.has(p) && (have.edgeFits?.({ producer: p, class: c, consumer: tool }) ?? true));
93
+ if (!producers.length) {
94
+ if (enriching)
95
+ optional.add(c);
96
+ else
97
+ missing.add(c);
98
+ continue;
99
+ }
100
+ if (depth + 1 > bounds.maxDepth) {
101
+ tooLong = true;
102
+ continue;
103
+ }
104
+ if (producers.length > 1)
105
+ ambiguous.add(c);
106
+ const p = producers[0];
107
+ visit(p, depth + 1, c);
108
+ satisfied[c] = { step: p };
109
+ from.push({ tool: p, class: c });
110
+ }
111
+ steps.push({ tool, ...(forClass ? { for: forClass } : {}), ...(from.length ? { from } : {}) });
112
+ };
113
+ visit(terminal, 0);
114
+ if (steps.length > bounds.maxSteps)
115
+ tooLong = true;
116
+ return { kind: tooLong ? 'too-long' : 'plan', steps, satisfied, missing: [...missing].sort(), ambiguous: [...ambiguous].sort(), ...(optional.size ? { optional: [...optional].sort() } : {}) };
117
+ }
118
+ /** A class named for a light model: its label and — from the domain lexicon — up to three of its other words
119
+ * ("Deployment Inventory (also: inventory of AI, list of AI tools)"). A bare class name is opaque without the cards. */
120
+ export function glossOf(iri, label, lexicon) {
121
+ const e = lexicon?.find((x) => x.iri === iri);
122
+ const also = (e?.terms ?? []).filter((t) => t.toLowerCase() !== label.toLowerCase()).slice(0, 3);
123
+ return also.length ? `${label} (also: ${also.join(', ')})` : label;
124
+ }
125
+ /** The enriching-input question, by wording version. */
126
+ export function absenceStatement(classText, wording = 'v1') {
127
+ return wording === 'v2'
128
+ ? `The request wants the ${classText} made or worked out as a step of its own before the rest — it asks for it to be taken stock of, listed, sorted or built first — or says it does not exist yet or is unknown (not merely that it was not mentioned).`
129
+ : `The request says the ${classText} does not exist yet, is unknown, or has to be worked out first (not merely that it was not mentioned).`;
130
+ }
131
+ // The supplied and edge floors sit ABOVE 0.5: an unrelated arrow comes back at exactly 0.5 ("can't tell"), and a coin is not a
132
+ // confirmation (probe 2026-09-27, before any measured run).
133
+ export const DEFAULT_OUTCOME_PARAMS = { floor: 0.5, margin: 0.15, suppliedFloor: 0.6, edgeFloor: 0.6, bounds: DEFAULT_OUTCOME_BOUNDS, maxEdgeQuestions: 12, partyRule: true };
134
+ const outcomeOption = (c) => {
135
+ const card = skillCard(c);
136
+ const makes = (c.produces ?? []).map((k) => k.label).join(', ');
137
+ const needs = (c.consumes ?? []).map((k) => k.label).join(', ');
138
+ return `${card}${makes ? ` Results in: ${makes}.` : ''}${needs ? ` Works from: ${needs}.` : ''}`;
139
+ };
140
+ /**
141
+ * THE OUTCOME SELECTION: one structured call (the light model; the cards the stable prefix) answering
142
+ * outcome choice over the outcomes the skills produce (+ none) — what the person wants to end up with;
143
+ * supplied:<c> yes-no per consumed class — does the request itself give it?
144
+ * then the rule builds the path from the asker's held classes. One model call, whatever the chain's length.
145
+ */
146
+ export async function selectByOutcome(ask, candidates, call, params = {}, ctx = {}) {
147
+ const p = { ...DEFAULT_OUTCOME_PARAMS, ...params };
148
+ const base = { judge: OUTCOME_JUDGE, params: { floor: p.floor, margin: p.margin, suppliedFloor: p.suppliedFloor, edgeFloor: p.edgeFloor } };
149
+ if (!call)
150
+ return { chose: null, hold: 'judge-error', error: 'no model is configured', distribution: {}, supplied: {}, ...base };
151
+ const graph = outcomeGraphOf(candidates);
152
+ const consumed = consumedClassesOf(graph);
153
+ const absentAsked = consumed.filter((c) => Object.entries(graph.necessity).some(([k, v]) => v === 'enriching' && k.endsWith(`|${c}`)) && (graph.producersOf[c]?.length ?? 0) > 0);
154
+ // Arrows the ontology decides (both ends qualified) are not asked: the rule answers them exactly, for no tokens.
155
+ const allEdges = edgesOf(graph);
156
+ const ruled = new Map(allEdges.map((e) => [edgeKey(e), p.partyRule ? edgeByParty(graph, e) : null]));
157
+ const edges = allEdges.filter((e) => ruled.get(edgeKey(e)) === null);
158
+ const purposeOf = new Map(candidates.map((c) => [c.id, c.description.split(/[.—]/)[0].replace(/\s+/g, ' ').trim().slice(0, 70)]));
159
+ const nameOf = (id) => `${id} ("${purposeOf.get(id) ?? id}")`;
160
+ const labels = new Map([...(ctx.lexicon ?? []).map((e) => [e.iri, e.label]), ...Object.entries(graph.labels), ...candidates.flatMap((c) => [...(c.covers ?? []), ...(c.excludes ?? [])].map((k) => [k.iri, k.label]))]);
161
+ const labelOf = (iri) => labels.get(iri) ?? iri.split('#').pop() ?? iri;
162
+ const reading = inferIntent(ask, candidates.map((c) => ({ id: c.id, covers: c.covers ?? [], ...(c.excludes ? { excludes: c.excludes } : {}) })), ctx.lexicon, ctx.asker);
163
+ const questions = [
164
+ { id: 'outcome', kind: 'choice', question: 'What does the person want to END UP WITH? Choose the ONE skill whose result that is.', options: candidates.map((c) => ({ id: c.id, describe: outcomeOption(c) })), notApplicable: 'Nothing these skills result in — the request is for something else.' },
165
+ // Question ids are SHORT and neutral (`s1`, `e1`): a provider's tool schema takes them as property names, and an IRI's
166
+ // `/` and `#` there made the light model answer in prose (2026-09-27, every run). Mapped back below.
167
+ ...consumed.map((c, i) => ({ id: `s${i + 1}`, kind: 'yes-no', statement: `The request itself gives the ${glossOf(c, labelOf(c), ctx.lexicon)} (its actual details — not merely a mention that one exists).` })),
168
+ // Spec 418 D4 — for each ENRICHING input some skill can produce: does the request say it is ABSENT? (Only then is it
169
+ // worth a chain step; "not mentioned" is not "absent".)
170
+ ...absentAsked.map((c, i) => ({ id: `a${i + 1}`, kind: 'yes-no', statement: absenceStatement(glossOf(c, labelOf(c), ctx.lexicon), p.absenceWording) })),
171
+ // Each arrow, confirmed for THIS request — asked in the same call (a domain with more arrows than the bound asks none,
172
+ // and every type-level arrow stands: said on the result).
173
+ ...(edges.length <= p.maxEdgeQuestions ? edges.map((e, i) => ({ id: `e${i + 1}`, kind: 'yes-no', statement: `If the outcome is the result of ${nameOf(e.consumer)}, the ${labelOf(e.class)} it works from would be one that ${nameOf(e.producer)} produces when run for this same request — the same organization and situation (not, say, another organization's).` })) : []),
174
+ ];
175
+ const j = await judgeQuestions(renderReading(ask, reading, labelOf), questions, structuredCallDecisionModel(call, { name: OUTCOME_JUDGE.name, stablePrefix: true }));
176
+ if (j.error !== undefined)
177
+ return { chose: null, hold: 'judge-error', error: j.error, distribution: {}, supplied: {}, ...base };
178
+ const a = j.answers['outcome'];
179
+ if (!a)
180
+ return { chose: null, hold: 'malformed', distribution: {}, supplied: {}, ...base };
181
+ const distribution = Object.fromEntries(Object.entries(a.distribution).map(([k, v]) => [k === NOT_APPLICABLE ? 'none' : k, v]));
182
+ const supplied = Object.fromEntries(consumed.flatMap((c, i) => { const s = j.answers[`s${i + 1}`]; return s ? [[c, Number((s.distribution['true'] ?? 0).toFixed(4))]] : []; }));
183
+ const absentP = Object.fromEntries(absentAsked.flatMap((c, i) => { const x = j.answers[`a${i + 1}`]; return x ? [[c, Number((x.distribution['true'] ?? 0).toFixed(4))]] : []; }));
184
+ const edgeP = Object.fromEntries(edges.flatMap((e, i) => { const x = j.answers[`e${i + 1}`]; return x ? [[edgeKey(e), Number((x.distribution['true'] ?? 0).toFixed(4))]] : []; }));
185
+ const reason = explainAnswer(a, (o) => (o === NOT_APPLICABLE ? 'none' : o));
186
+ const d = applyDecisionRule(a, p);
187
+ if (d.decided === null) {
188
+ const hold = d.because === 'not-applicable' ? 'none-fits' : d.because === 'unreadable' ? 'malformed' : d.because;
189
+ return { chose: null, hold, distribution, supplied, ...(Object.keys(edgeP).length ? { edges: edgeP } : {}), reason, ...base };
190
+ }
191
+ const held = new Set((ctx.asker?.heldClasses ?? []).filter((c) => consumed.includes(c)));
192
+ const edgeFits = (e) => { const r = ruled.get(edgeKey(e)); return r !== null && r !== undefined ? r : edgeP[edgeKey(e)] !== undefined ? edgeP[edgeKey(e)] >= p.edgeFloor : true; };
193
+ const absent = new Set(Object.entries(absentP).filter(([, v]) => v >= p.suppliedFloor).map(([k]) => k));
194
+ const plan = planForOutcome(graph, d.decided, { supplied: new Set(Object.entries(supplied).filter(([, v]) => v >= p.suppliedFloor).map(([k]) => k)), held, edgeFits, absent }, p.bounds);
195
+ const byRule = Object.fromEntries([...ruled].filter(([, v]) => v !== null));
196
+ const ex = { ...(Object.keys(absentP).length ? { absent: absentP } : {}), ...(Object.keys(edgeP).length ? { edges: edgeP } : {}), ...(Object.keys(byRule).length ? { edgesByRule: byRule } : {}) };
197
+ if (plan.kind === 'too-long')
198
+ return { chose: null, hold: 'too-long', plan, distribution, supplied, ...ex, reason, ...base };
199
+ return { chose: d.decided, plan, distribution, supplied, ...ex, reason, ...base };
200
+ }
201
+ /** The plan as orchestration steps: each producer's answer is `$ref`'d into the next step as its material. */
202
+ export function outcomeSteps(plan, ask, labelOf, opts = {}) {
203
+ const held = Object.entries(plan.satisfied).filter(([, s]) => s === 'held').map(([c]) => labelOf(c));
204
+ const heldNote = held.length ? `\n\n(The person already holds, in their own records: ${held.join(', ')}.)` : '';
205
+ const missingNote = plan.missing.length ? `\n\n(Not given and not produced here: ${plan.missing.map(labelOf).join(', ')} — ask for it rather than invent it.)` : '';
206
+ const refOf = new Map(plan.steps.map((s, i) => [s.tool, `o${i}`]));
207
+ return plan.steps.map((s, i) => {
208
+ const from = s.from ?? [];
209
+ const fromNote = from.length ? `\n\n(The material is what earlier steps produced for this request: ${from.map((f) => `the ${labelOf(f.class)}`).join('; ')}.)` : '';
210
+ const question = s.for
211
+ ? `Produce the ${labelOf(s.for)} this request will need${opts.briefIntermediate ? ` — ONLY that ${labelOf(s.for)}, as a compact working artifact the next step builds on (no introduction, no guidance beyond it)` : ''}.\n\nThe request: ${ask}${heldNote}${fromNote}`
212
+ : `${ask}${heldNote}${missingNote}${fromNote}`;
213
+ const material = from.map((f) => ({ $ref: `${refOf.get(f.tool)}.answer` }));
214
+ return { toolId: s.tool, id: `s${i}`, ref: `o${i}`, args: { question, ...(material.length === 1 ? { material: material[0] } : material.length ? { material } : {}), ...(opts.briefIntermediate && s.for ? { brief: true } : {}) } };
215
+ });
216
+ }
217
+ // ── SELECTIVE OUTCOME READING (spec 418 D6). The full outcome judgment pays for the dataflow questions on EVERY ask,
218
+ // but across three sets a chain or a missing input mattered in a handful of cases (ledger, 2026-09-27: +124–174% pick
219
+ // tokens for no significant gain). So: the cheap one-skill pick first; the dataflow questions only when the PICKED
220
+ // skill has an input some other skill can produce for it (after the party rule) that the asker does not already hold —
221
+ // and then only about that skill's inputs, in one small call. No such input ⇒ no second call at all.
222
+ export const OUTCOME_JUDGE_SELECTIVE = { name: 'ap.outcome-judge.selective.v1', kind: 'model' };
223
+ /** Spec 418 — the picked skill's DOWNSTREAM: skills that consume what the pick produces (the party rule not refusing the
224
+ * arrow). A request that names the first step ("work out which deadline is next") may want the next one ("and draft it"). */
225
+ export function downstreamOf(graph, pick) {
226
+ const out = [];
227
+ for (const [consumer, cs] of Object.entries(graph.consumesOf)) {
228
+ if (consumer === pick)
229
+ continue;
230
+ for (const c of cs)
231
+ if ((graph.producersOf[c] ?? []).includes(pick) && edgeByParty(graph, { producer: pick, class: c, consumer }) !== false)
232
+ out.push({ consumer, class: c });
233
+ }
234
+ return out.sort((a, b) => (a.consumer + a.class).localeCompare(b.consumer + b.class));
235
+ }
236
+ /** The picked skill's inputs worth asking about: a producer exists whose arrow the party rule does not refuse. */
237
+ export function upstreamInputsOf(graph, pick, held) {
238
+ return (graph.consumesOf[pick] ?? []).filter((c) => !held.has(c) && (graph.producersOf[c] ?? []).some((p) => p !== pick && edgeByParty(graph, { producer: p, class: c, consumer: pick }) !== false));
239
+ }
240
+ /** Selective reading asks only about producible inputs, so it names nothing missing it did not ask about (a measured
241
+ * trade-off: the full outcome judgment also names missing REQUIRED inputs). */
242
+ const askedOnly = (plan, asked) => ({ ...plan, missing: plan.missing.filter((c) => asked.includes(c)) });
243
+ /** Given the one-skill pick, decide its plan: no call when nothing upstream is producible; else one call about only its inputs. */
244
+ export async function planForPicked(ask, pick, candidates, call, params = {}, ctx = {}) {
245
+ const p = { ...DEFAULT_OUTCOME_PARAMS, ...params };
246
+ const graph = outcomeGraphOf(candidates);
247
+ const held = new Set(ctx.asker?.heldClasses ?? []);
248
+ const upstream = upstreamInputsOf(graph, pick, held);
249
+ const down = params.downstream ? downstreamOf(graph, pick) : [];
250
+ const ruled = Object.fromEntries(edgesOf(graph).filter((e) => e.consumer === pick).flatMap((e) => { const r = edgeByParty(graph, e); return r === null ? [] : [[edgeKey(e), r]]; }));
251
+ const base = { judge: OUTCOME_JUDGE_SELECTIVE, ...(Object.keys(ruled).length ? { edgesByRule: ruled } : {}) };
252
+ if ((!upstream.length && !down.length) || !call) {
253
+ return { asked: false, plan: askedOnly(planForOutcome(graph, pick, { supplied: new Set(), held, absent: new Set(), edgeFits: (e) => edgeByParty(graph, e) ?? true }, p.bounds), []), supplied: {}, ...base };
254
+ }
255
+ const labels = new Map([...(ctx.lexicon ?? []).map((e) => [e.iri, e.label]), ...Object.entries(graph.labels)]);
256
+ const labelOf = (iri) => labels.get(iri) ?? iri.split('#').pop() ?? iri;
257
+ const enriching = (c) => graph.necessity[`${pick}|${c}`] === 'enriching';
258
+ const undecided = edgesOf(graph).filter((e) => e.consumer === pick && upstream.includes(e.class) && edgeByParty(graph, e) === null);
259
+ const nameOf = (id) => `${id} ("${(candidates.find((c) => c.id === id)?.description ?? id).split(/[.—]/)[0].replace(/\s+/g, ' ').trim().slice(0, 70)}")`;
260
+ const questions = [
261
+ ...upstream.map((c, i) => ({ id: `s${i + 1}`, kind: 'yes-no', statement: `The request itself gives the ${glossOf(c, labelOf(c), ctx.lexicon)} (its actual details — not merely a mention that one exists).` })),
262
+ ...upstream.filter(enriching).map((c, i) => ({ id: `a${i + 1}`, kind: 'yes-no', statement: absenceStatement(glossOf(c, labelOf(c), ctx.lexicon), p.absenceWording) })),
263
+ ...down.map((x, i) => ({ id: `d${i + 1}`, kind: 'yes-no', statement: `Beyond the ${glossOf(x.class, labelOf(x.class), ctx.lexicon)}, the request also asks for what ${nameOf(x.consumer)} makes from it (the next step, not only this one).` })),
264
+ ...undecided.map((e, i) => ({ id: `e${i + 1}`, kind: 'yes-no', statement: `The ${labelOf(e.class)} that ${nameOf(pick)} works from would be one that ${nameOf(e.producer)} produces when run for this same request — the same organization and situation.` })),
265
+ ];
266
+ const j = await judgeQuestions(`Request:\n${ask}\n\nThe skill chosen for it: ${nameOf(pick)}.`, questions, structuredCallDecisionModel(call, { name: OUTCOME_JUDGE_SELECTIVE.name, stablePrefix: true }));
267
+ if (j.error !== undefined)
268
+ return { asked: true, plan: askedOnly(planForOutcome(graph, pick, { supplied: new Set(), held, absent: new Set(), edgeFits: (e) => edgeByParty(graph, e) ?? true }, p.bounds), []), supplied: {}, error: j.error, ...base };
269
+ const yes = (id) => Number((j.answers[id]?.distribution['true'] ?? 0).toFixed(4));
270
+ const supplied = Object.fromEntries(upstream.map((c, i) => [c, yes(`s${i + 1}`)]));
271
+ const absent = Object.fromEntries(upstream.filter(enriching).map((c, i) => [c, yes(`a${i + 1}`)]));
272
+ const edges = Object.fromEntries(undecided.map((e, i) => [edgeKey(e), yes(`e${i + 1}`)]));
273
+ const downstream = Object.fromEntries(down.map((x, i) => [`${x.consumer}|${x.class}`, yes(`d${i + 1}`)]));
274
+ const next = down.map((x, i) => ({ ...x, p: yes(`d${i + 1}`) })).filter((x) => x.p >= p.suppliedFloor).sort((a, b) => b.p - a.p)[0];
275
+ if (next) {
276
+ // The request wants the downstream result: the plan ends there, and its input is produced by the pick (declared absent).
277
+ const ext = planForOutcome(graph, next.consumer, { supplied: new Set(), held, absent: new Set([next.class]), edgeFits: (e) => (e.class === next.class ? e.producer === pick : edgeByParty(graph, e) ?? true) }, p.bounds);
278
+ return { asked: true, plan: askedOnly(ext, upstream), supplied: Object.fromEntries(upstream.map((c, i) => [c, yes(`s${i + 1}`)])), downstream, extendedTo: next.consumer, ...base };
279
+ }
280
+ const plan = planForOutcome(graph, pick, {
281
+ supplied: new Set(Object.entries(supplied).filter(([, v]) => v >= p.suppliedFloor).map(([k]) => k)), held,
282
+ absent: new Set(Object.entries(absent).filter(([, v]) => v >= p.suppliedFloor).map(([k]) => k)),
283
+ edgeFits: (e) => { const r = edgeByParty(graph, e); return r !== null ? r : edges[edgeKey(e)] !== undefined ? edges[edgeKey(e)] >= p.edgeFloor : true; },
284
+ }, p.bounds);
285
+ return { asked: true, plan: askedOnly(plan, upstream), supplied, ...(Object.keys(absent).length ? { absent } : {}), ...(Object.keys(edges).length ? { edges } : {}), ...(Object.keys(downstream).length ? { downstream } : {}), ...base };
286
+ }
287
+ // ── PLAN CHOICE (spec 418 §11). Yes-no questions around a single pick failed both ways on the chain panels: the pick
288
+ // lands on the FIRST step of a chain ("list the deadlines, then draft") as often as on the LAST ("…then build the response
289
+ // plan" picked with no upstream step). So the RULE enumerates the few plans the ontology allows around the pick — the pick
290
+ // alone, producer → pick, pick → consumer (party rule applied, held inputs pruned) — and the JUDGE picks ONE plan, in words.
291
+ export const PLAN_CHOICE_JUDGE = { name: 'ap.plan-choice-judge.v1', kind: 'model' };
292
+ /** The candidate plans around a pick: alone, each allowed upstream producer, each allowed downstream consumer. */
293
+ export function planOptionsAround(graph, pick, held, purposeOf, labelOf) {
294
+ const opts = [{ id: 'p0', steps: [pick], describe: `Only this: ${purposeOf(pick)}.` }];
295
+ for (const c of upstreamInputsOf(graph, pick, held)) {
296
+ for (const p of (graph.producersOf[c] ?? []).filter((x) => x !== pick && edgeByParty(graph, { producer: x, class: c, consumer: pick }) !== false)) {
297
+ opts.push({ id: `p${opts.length}`, steps: [p, pick], via: c, describe: `Two steps: first ${purposeOf(p)} — to make the ${labelOf(c)} — then ${purposeOf(pick)} from it.` });
298
+ }
299
+ }
300
+ for (const d of downstreamOf(graph, pick)) {
301
+ opts.push({ id: `p${opts.length}`, steps: [pick, d.consumer], via: d.class, describe: `Two steps: first ${purposeOf(pick)} — making the ${labelOf(d.class)} — then ${purposeOf(d.consumer)} from it.` });
302
+ }
303
+ return opts;
304
+ }
305
+ /** One choice among the rule's candidate plans; a single option (nothing connected) makes no call. */
306
+ export async function choosePlanAround(ask, pick, candidates, call, ctx = {}) {
307
+ const graph = outcomeGraphOf(candidates);
308
+ const held = new Set(ctx.asker?.heldClasses ?? []);
309
+ const labels = new Map([...(ctx.lexicon ?? []).map((e) => [e.iri, e.label]), ...Object.entries(graph.labels)]);
310
+ const labelOf = (iri) => glossOf(iri, labels.get(iri) ?? iri.split('#').pop() ?? iri, ctx.lexicon);
311
+ const purposeOf = (id) => (candidates.find((c) => c.id === id)?.description ?? id).split(/[.—]/)[0].replace(/\s+/g, ' ').trim().toLowerCase().slice(0, 90);
312
+ const options = planOptionsAround(graph, pick, held, purposeOf, labelOf);
313
+ const toPlan = (o) => ({ kind: 'plan', steps: o.steps.map((t, i) => (i < o.steps.length - 1 ? { tool: t, for: o.via } : { tool: t, ...(i > 0 ? { from: [{ tool: o.steps[i - 1], class: o.via }] } : {}) })), satisfied: o.via && o.steps.length > 1 ? { [o.via]: { step: o.steps[0] } } : {}, missing: [], ambiguous: [] });
314
+ const base = { options, judge: PLAN_CHOICE_JUDGE };
315
+ if (options.length === 1 || !call)
316
+ return { asked: false, chosen: options[0], plan: toPlan(options[0]), ...base };
317
+ const q = { id: 'plan', kind: 'choice', question: 'Which plan does the request ask for? A two-step plan only if the request wants BOTH results (or needs the first to make the second); otherwise only the one step.', options: options.map((o) => ({ id: o.id, describe: o.describe })) };
318
+ const j = await judgeQuestions(`Request:\n${ask}`, [q], structuredCallDecisionModel(call, { name: PLAN_CHOICE_JUDGE.name, stablePrefix: true }));
319
+ const a = j.answers['plan'];
320
+ if (j.error !== undefined || !a)
321
+ return { asked: true, chosen: options[0], plan: toPlan(options[0]), ...base, ...(j.error ? { error: j.error } : {}) };
322
+ const chosen = options.find((o) => o.id === a.top) ?? options[0];
323
+ return { asked: true, distribution: { ...a.distribution }, chosen, plan: toPlan(chosen), ...base };
324
+ }
325
+ //# sourceMappingURL=outcome.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"outcome.js","sourceRoot":"","sources":["../src/outcome.ts"],"names":[],"mappings":"AAAA,wHAAwH;AACxH,6GAA6G;AAC7G,EAAE;AACF,uHAAuH;AACvH,oHAAoH;AACpH,mHAAmH;AACnH,wHAAwH;AACxH,mHAAmH;AACnH,EAAE;AACF,yHAAyH;AACzH,0FAA0F;AAC1F,OAAO,EAAE,cAAc,EAAE,2BAA2B,EAAE,iBAAiB,EAAE,aAAa,EAAE,cAAc,EAA2B,MAAM,eAAe,CAAC;AACvJ,OAAO,EAAE,WAAW,EAAE,aAAa,EAAE,SAAS,EAAuB,MAAM,aAAa,CAAC;AAGzF,MAAM,CAAC,MAAM,aAAa,GAAG,EAAE,IAAI,E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,IAAI,EAAE,iBAAiB,CAAC,IAAI,EAAE,YAAY,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC;IACjJ,MAAM,CAAC,GAAG,CAAC,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;IAC5B,IAAI,CAAC,CAAC,KAAK,KAAK,SAAS,IAAI,CAAC,CAAC;QAAE,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC,CAAE,EAAE,IAAI,EAAE,MAAM,CAAC,OAAO,CAAC,CAAC,CAAE,CAAC,EAAE,GAAG,IAAI,EAAE,GAAG,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC;IACzJ,MAAM,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC,GAAG,CAAC,IAAI,OAAO,CAAC,CAAC,CAAE,CAAC;IAClE,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,YAAY,EAAE,EAAE,GAAG,CAAC,CAAC,YAAY,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,CAAC,MAAM,CAAC,EAAE,GAAG,IAAI,EAAE,CAAC;AACrG,CAAC"}
@@ -0,0 +1,6 @@
1
+ import type { Plan, PlanStep } from './types.js';
2
+ /** The part of a step that is the person's to approve: never a result, never a resolved value. */
3
+ export declare function planStepAsWritten(step: PlanStep, index: number): Record<string, unknown>;
4
+ /** `0x` + 64 hex: the digest of the plan as written. Deterministic across runtimes for the same plan. */
5
+ export declare function planDigest(plan: Plan): Promise<`0x${string}`>;
6
+ //# sourceMappingURL=plan-digest.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"plan-digest.d.ts","sourceRoot":"","sources":["../src/plan-digest.ts"],"names":[],"mappings":"AAYA,OAAO,KAAK,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAoBjD,kGAAkG;AAClG,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAWxF;AAED,yGAAyG;AACzG,wBAAsB,UAAU,CAAC,IAAI,EAAE,IAAI,GAAG,OAAO,CAAC,KAAK,MAAM,EAAE,CAAC,CAEnE"}
@@ -0,0 +1,35 @@
1
+ const sha256 = async (s) => {
2
+ const bytes = new Uint8Array(await crypto.subtle.digest('SHA-256', new TextEncoder().encode(s)));
3
+ return Array.from(bytes, (b) => b.toString(16).padStart(2, '0')).join('');
4
+ };
5
+ const canonical = (v) => JSON.stringify(v, (_k, x) => {
6
+ if (typeof x === 'bigint')
7
+ return x.toString();
8
+ if (x && typeof x === 'object' && !Array.isArray(x)) {
9
+ return Object.keys(x).sort().reduce((o, k) => {
10
+ const val = x[k];
11
+ if (val !== undefined)
12
+ o[k] = val;
13
+ return o;
14
+ }, {});
15
+ }
16
+ return x;
17
+ });
18
+ /** The part of a step that is the person's to approve: never a result, never a resolved value. */
19
+ export function planStepAsWritten(step, index) {
20
+ return {
21
+ id: step.id ?? `s${index}`,
22
+ toolId: step.toolId,
23
+ args: step.args ?? {},
24
+ ...(step.ref ? { ref: step.ref } : {}),
25
+ ...(step.executor ? { executor: step.executor } : {}),
26
+ ...(step.forEach ? { forEach: step.forEach } : {}),
27
+ ...(step.after?.length ? { after: [...step.after] } : {}),
28
+ ...(step.when ? { when: step.when } : {}),
29
+ };
30
+ }
31
+ /** `0x` + 64 hex: the digest of the plan as written. Deterministic across runtimes for the same plan. */
32
+ export async function planDigest(plan) {
33
+ return `0x${await sha256(canonical({ steps: plan.steps.map(planStepAsWritten) }))}`;
34
+ }
35
+ //# sourceMappingURL=plan-digest.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"plan-digest.js","sourceRoot":"","sources":["../src/plan-dig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;QACL,EAAE,EAAE,IAAI,CAAC,EAAE,IAAI,IAAI,KAAK,EAAE;QAC1B,MAAM,EAAE,IAAI,CAAC,MAAM;QACnB,IAAI,EAAE,IAAI,CAAC,IAAI,IAAI,EAAE;QACrB,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,GAAG,EAAE,IAAI,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QACtC,GAAG,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,EAAE,QAAQ,EAAE,IAAI,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QACrD,GAAG,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,IAAI,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QAClD,GAAG,CAAC,IAAI,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QACzD,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;KAC1C,CAAC;AACJ,CAAC;AAED,yGAAyG;AACzG,MAAM,CAAC,KAAK,UAAU,UAAU,CAAC,IAAU;IACzC,OAAO,KAAK,MAAM,MAAM,CAAC,SAAS,CAAC,EAAE,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,iBAAiB,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC;AACtF,CAAC"}
@@ -0,0 +1,11 @@
1
+ import { type PlanStep, type ToolSpec } from './types.js';
2
+ /** The API-safe name for a tool id. Deterministic; not unique on its own — see `toolNameMap`. */
3
+ export declare function wireNameFor(id: string): string;
4
+ /** Both directions of the id ↔ wire-name map for one tool set. Throws `planner_failed` on a collision. */
5
+ export declare function toolNameMap(tools: ToolSpec[]): {
6
+ toWire: Map<string, string>;
7
+ fromWire: Map<string, string>;
8
+ };
9
+ /** One `PlanStep` from a tool call's raw arguments: the convention keys lifted out, the rest kept as args. */
10
+ export declare function planStepFromToolArgs(toolId: string, raw: Record<string, unknown>): PlanStep;
11
+ //# sourceMappingURL=planner-wire.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"planner-wire.d.ts","sourceRoot":"","sources":["../src/planner-wire.ts"],"names":[],"mappings":"AAgBA,OAAO,EAAsB,KAAK,QAAQ,EAAE,KAAK,QAAQ,EAAE,MAAM,YAAY,CAAC;AAE9E,iGAAiG;AACjG,wBAAgB,WAAW,CAAC,EAAE,EAAE,MAAM,GAAG,MAAM,CAE9C;AAED,0GAA0G;AAC1G,wBAAgB,WAAW,CAAC,KAAK,EAAE,QAAQ,EAAE,GAAG;IAAE,MAAM,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAAC,QAAQ,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;CAAE,CAW7G;AAED,8GAA8G;AAC9G,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,QAAQ,CAe3F"}
@@ -0,0 +1,53 @@
1
+ // THE PLAN-SHAPE CONVENTION ON A VENDOR'S WIRE — shared by every LLM adapter (spec 377 §2).
2
+ //
3
+ // Two things every tool-calling API forces on a planner, neither of which is a vendor detail:
4
+ //
5
+ // 1. Tool NAMES on the wire are restricted (`^[a-zA-Z0-9_-]{1,128}$` on every serious API), while capability
6
+ // ids are DOTTED by vocabulary (`treasury.payment.execute`, ADR-0051). The wire name is derived here and
7
+ // mapped BACK on the way out, so the plan still names the tool by its id. Bijective by construction: two
8
+ // ids that derive the same wire name are refused rather than silently merged.
9
+ // 2. A tool call carries ONLY arguments, so the plan-shape fields the loop reads — `$ref` (bind this result
10
+ // under a name), `$forEach` (fan out over a prior result's array), `$after` (ids of steps this one waits
11
+ // for), `$when` (a declared branch on a prior result) — ride INSIDE the args (spec 358 W4, spec 370 P3).
12
+ // They are lifted into the `PlanStep` fields here; `$item` placeholders stay in args for the loop's
13
+ // per-item substitution. A malformed form is ignored, and admission then refuses the undecidable step.
14
+ //
15
+ // This lived in the Anthropic adapter first. It moved here the day a second adapter needed it verbatim: the
16
+ // convention belongs to the loop that reads it, not to whichever vendor shipped first.
17
+ import { OrchestrationError } from './types.js';
18
+ /** The API-safe name for a tool id. Deterministic; not unique on its own — see `toolNameMap`. */
19
+ export function wireNameFor(id) {
20
+ return id.replace(/[^a-zA-Z0-9_-]/g, '_').slice(0, 128) || '_';
21
+ }
22
+ /** Both directions of the id ↔ wire-name map for one tool set. Throws `planner_failed` on a collision. */
23
+ export function toolNameMap(tools) {
24
+ const toWire = new Map();
25
+ const fromWire = new Map();
26
+ for (const t of tools) {
27
+ const w = wireNameFor(t.id);
28
+ const prior = fromWire.get(w);
29
+ if (prior && prior !== t.id)
30
+ throw new OrchestrationError('planner_failed', `tool ids "${prior}" and "${t.id}" collide on the API tool name "${w}"`);
31
+ toWire.set(t.id, w);
32
+ fromWire.set(w, t.id);
33
+ }
34
+ return { toWire, fromWire };
35
+ }
36
+ /** One `PlanStep` from a tool call's raw arguments: the convention keys lifted out, the rest kept as args. */
37
+ export function planStepFromToolArgs(toolId, raw) {
38
+ const { $ref, $forEach, $after, $when, $executor, ...args } = raw;
39
+ const after = Array.isArray($after) ? $after.filter((x) => typeof x === 'string') : typeof $after === 'string' ? [$after] : [];
40
+ const when = $when && typeof $when === 'object' && typeof $when.ref === 'string' ? $when : undefined;
41
+ return {
42
+ toolId,
43
+ args,
44
+ ...(typeof $ref === 'string' && $ref ? { ref: $ref } : {}),
45
+ ...(typeof $forEach === 'string' && $forEach ? { forEach: { ref: $forEach } } : {}),
46
+ ...(after.length ? { after } : {}),
47
+ // Spec 376 W2 — WHO IS TO DO IT, as the person said it ("have runtime-c3s0.svc pay …"): the words, which
48
+ // the harness resolves in the asker's own tier before the step runs, never an address the model chose.
49
+ ...(typeof $executor === 'string' && $executor.trim() ? { executor: $executor.trim() } : {}),
50
+ ...(when ? { when: { ref: when.ref, ...(when.exists !== undefined ? { exists: !!when.exists } : {}), ...(when.equals !== undefined ? { equals: when.equals } : {}) } } : {}),
51
+ };
52
+ }
53
+ //# sourceMappingURL=planner-wire.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"planner-wire.js","sourceRoot":"","sources":["../src/planner-wire.ts"],"names":[],"mappings":"AAAA,4FAA4F;AAC5F,EAAE;AACF,8FAA8F;AAC9F,EAAE;AACF,+GAA+G;AAC/G,8GAA8G;AAC9G,8GAA8G;AAC9G,mFAAmF;AACnF,8GAA8G;AAC9G,8GAA8G;AAC9G,8GAA8G;AAC9G,yGAAyG;AACzG,4GAA4G;AAC5G,EAAE;AACF,4GAA4G;AAC5G,uFAAuF;AACvF,OAAO,EAAE,kBAAkB,EAAgC,MAAM,YAAY,CAAC;AAE9E,iGAAiG;AACjG,MAAM,UAAU,WAAW,CAAC,EAAU;IACpC,OAAO,EAAE,CAAC,OAAO,CAAC,iBAAiB,EAAE,GAAG,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,GAAG,CAAC,IAAI,GAAG,CAAC;AACjE,CAAC;AAED,0GAA0G;AAC1G,MAAM,UAAU,WAAW,CAAC,KAAiB;IAC3C,MAAM,MAAM,GAAG,IAAI,GAAG,EAAkB,CAAC;IACzC,MAAM,QAAQ,GAAG,IAAI,GAAG,EAAkB,CAAC;IAC3C,KAAK,MAAM,CAAC,IAAI,KAAK,EAAE,CAAC;QACtB,MAAM,CAAC,GAAG,WAAW,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;QAC5B,MAAM,KAAK,GAAG,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;QAC9B,IAAI,KAAK,IAAI,KAAK,KAAK,CAAC,CAAC,E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G,EAAE,QAAQ,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QACnF,GAAG,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QAClC,yGAAyG;QACzG,uGAAuG;QACvG,GAAG,CAAC,OAAO,SAAS,KAAK,QAAQ,IAAI,SAAS,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE,QAAQ,EAAE,SAAS,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QAC5F,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,EAAE,GAAG,EAAE,IAAI,CAAC,GAAG,EAAE,GAAG,CAAC,IAAI,CAAC,MAAM,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,GAAG,CAAC,IAAI,CAAC,MAAM,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,IAAI,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;KAC7K,CAAC;AACJ,CAAC"}
package/dist/planner.d.ts CHANGED
@@ -1,3 +1,4 @@
1
+ import type { EvidenceItemV1 } from './artifacts.js';
1
2
  import type { Intent, Plan, PlanStep, ToolSpec, StepObservation } from './types.js';
2
3
  /** What a planner is given to produce (or re-produce) a plan. */
3
4
  export interface PlanInput {
@@ -6,11 +7,61 @@ export interface PlanInput {
6
7
  tools: ToolSpec[];
7
8
  /** Prior step observations, present only on a re-plan (empty / undefined on the first plan). */
8
9
  observations?: StepObservation[];
10
+ /** Spec 421 W1 — this call CONTINUES a plan: `observations` are what the reads returned (successes included), shown
11
+ * to the planner as data to plan the rest from — never as instructions (other people's words are data). A failure
12
+ * re-plan leaves this unset. */
13
+ continuation?: boolean;
9
14
  }
15
+ /**
16
+ * Spec 421 W1 — the continuation turn, rendered ONCE for every adapter: what the reads returned, each labelled by whose
17
+ * words it holds, framed as DATA. A result that carries `untrusted: true` (another person's message, a web page, a
18
+ * published work) is said to be so; nothing in any observation is an instruction — the Goal is the only instruction.
19
+ * Bounded per observation and in total so a long inbox cannot crowd out the goal.
20
+ */
21
+ /** A result FITTED for a continuation: every array's items kept in order (each string field clipped), until `cap` characters;
22
+ * what did not fit is counted, never silently dropped. A summary of the first three titles is what a re-plan gets
23
+ * (spec 391) — a continuation that must find "who asked about Sunday" needs the items themselves. */
24
+ export declare function fitForContinuation(result: unknown, cap: number, fieldClip?: number): string;
25
+ export declare function renderContinuation(observations: ReadonlyArray<StepObservation>, opts?: {
26
+ perObservation?: number;
27
+ total?: number;
28
+ }): string;
10
29
  /** The injected planning port: turn a goal + the available tools into an ordered tool composition. */
11
30
  export interface Planner {
12
31
  plan(input: PlanInput): Promise<Plan>;
13
32
  }
33
+ /** What an answer is composed FROM. Deliberately only the ask and what the tools actually returned: an
34
+ * answer that cannot be traced to an observation is a guess wearing a sentence. */
35
+ export interface ComposeInput {
36
+ intent: Intent;
37
+ observations: StepObservation[];
38
+ /** Spec 358 W3 — a prior composition's claims exceeded its evidence, and these say exactly how. A
39
+ * composer given corrections is being asked AGAIN, once; what it returns is re-checked, and the caller
40
+ * falls back to stating the evidence rather than asking a third time. */
41
+ corrections?: string[];
42
+ /** Spec 391 — the evidence ALREADY FITTED to the composer's budget by the caller (`fitEvidence`), so the drops
43
+ * are on the trace and the governor knows what the model saw. Absent ⇒ the composer fits the observations
44
+ * itself (never slices). */
45
+ evidence?: EvidenceItemV1[];
46
+ }
47
+ /**
48
+ * The injected ANSWERING port — the other half of the loop's model use. `Planner` decides what to do;
49
+ * this turns what came back into something a person can read.
50
+ *
51
+ * Three rules it exists to enforce, none of which the loop can check for the implementer:
52
+ * • GROUNDED — only what the observations contain. No recalled facts, no plausible filler; "the
53
+ * directory does not say" is a correct answer and the expected one when the rows are empty.
54
+ * • NOT EVIDENCE — the receipts are the evidence and the observations are the record. This produces a
55
+ * RENDERING of them; nothing downstream may treat the prose as a fact that happened.
56
+ * • ANSWERS ONLY — it never runs over an action's result. What an action did is stated from the
57
+ * receipt (what was created, at what address, in which transaction), where precision is the point
58
+ * and a paraphrase is a liability.
59
+ */
60
+ export interface AnswerComposer {
61
+ compose(input: ComposeInput): Promise<string>;
62
+ /** Spec 391 — how many characters of evidence this composer will carry, so the caller can fit to it. */
63
+ evidenceBudget?: number;
64
+ }
14
65
  /** One deterministic rule. When the goal matches, emit either a single step (`toolId` + `args`) OR a
15
66
  * multi-step plan (`steps`) — later steps may reference earlier results via `{ $ref: 'name.path' }`. A rule
16
67
  * is SKIPPED if any tool it names is not in the provided `tools` (fail-closed; the next rule is tried). */
@@ -1 +1 @@
1
- {"version":3,"file":"planner.d.ts","sourceRoot":"","sources":["../src/planner.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,QAAQ,EAAE,QAAQ,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAGpF,iEAAiE;AACjE,MAAM,WAAW,SAAS;IACxB,MAAM,EAAE,MAAM,CAAC;IACf,8FAA8F;IAC9F,KAAK,EAAE,QAAQ,EAAE,CAAC;IAClB,gGAAgG;IAChG,YAAY,CAAC,EAAE,eAAe,EAAE,CAAC;CAClC;AAED,sGAAsG;AACtG,MAAM,WAAW,OAAO;IACtB,IAAI,CAAC,KAAK,EAAE,SAAS,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CACvC;AAED;;4GAE4G;AAC5G,MAAM,WAAW,QAAQ;IACvB,kFAAkF;IAClF,KAAK,EAAE,MAAM,GAAG,CAAC,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC,CAAC;IAC5C,gEAAgE;IAChE,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,wFAAwF;IACxF,IAAI,CAAC,EAAE,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