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

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 +253 -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
package/dist/types.d.ts CHANGED
@@ -9,8 +9,52 @@ export interface Intent {
9
9
  constraints?: Record<string, unknown>;
10
10
  /** Optional context the planner may use (principal handle, locale…). Opaque to the loop. */
11
11
  context?: Record<string, unknown>;
12
+ /** Spec 410 §5 — the versions this intent is acted under: the ontology manifest digest and the compiled
13
+ * definition's digest. Set by the runtime before the intent is offered for a mandate; the intent digest
14
+ * (RFC 8785 over the whole object) then binds them, and the verifier recomputes under the versions it
15
+ * runs with. Opaque to the loop; the shape is `delegation.VersionBindingV1`. */
16
+ versions?: {
17
+ ontologyManifestDigest: string;
18
+ semanticsDigest: string;
19
+ };
12
20
  }
13
21
  /** A capability the agent MAY compose. The planner picks from these; the loop refuses any other tool id. */
22
+ export type OutcomeClass = 'lookup' | 'submission' | 'authoritative';
23
+ /**
24
+ * Spec 410 §2 — the adapter's declaration, on the tool contract. `verificationWindow` is the time between the
25
+ * harness's check and the provider's commit, as an ISO 8601 duration (`PT30S`) or the word `unbounded` — a
26
+ * legal and visible answer. `retry` says what a second identical call does; `cancellation` what a cancel can
27
+ * do — `none` means the word is absent from every projection of this tool.
28
+ */
29
+ export interface AdapterDeclarationV1 {
30
+ verificationWindow: string;
31
+ retry: 'idempotent-by-key' | 'never' | 'compensating';
32
+ cancellation: 'none' | 'before-commit' | 'compensating';
33
+ }
34
+ /**
35
+ * Spec 426 — AN EXECUTOR INVOKE DECLARATION: "call executor E's skill S as me, and hand me back its receipt."
36
+ * A capability carrying this is dispatched by ONE generic invoker (no runtime tool per domain): it resolves
37
+ * `executor` to a URL + client through OPERATOR CONFIG (never a hardcoded host — `executor` is a NAME, not a
38
+ * URL), obtains a session for the RUN'S PRINCIPAL, sends one A2A `message/send` carrying `metadata.skill =
39
+ * intent`, and records the receipt in `run.provenance`. An `invoke` block IMPLIES self-acting (v1): the write
40
+ * is to the principal's own domain, so the session is the authority and no mandate is minted — the generic
41
+ * invoker takes the session from the principal structurally, never from an arg (§6; `check:invoke-is-self-acting`).
42
+ */
43
+ export interface ExecutorInvokeV1 {
44
+ /** v1's only transport. */
45
+ transport: 'a2a.message-send';
46
+ /** A NAME the operator maps to { url, client } — never a URL (ADR-0021: no host in a tool or a package). */
47
+ executor: string;
48
+ /** The executor's skill id → `metadata.skill`: which of its skills it runs. */
49
+ intent: string;
50
+ /** How the capability's args map onto the message. */
51
+ args: {
52
+ /** The arg holding the free-text part ("what happened, in my words") → the message text. */
53
+ goal: string;
54
+ /** Args passed through as message metadata. */
55
+ metadata?: string[];
56
+ };
57
+ }
14
58
  export interface ToolSpec {
15
59
  /** Stable tool id (matches the invoker's dispatch key, e.g. an MCP tool name). */
16
60
  id: string;
@@ -18,6 +62,137 @@ export interface ToolSpec {
18
62
  description: string;
19
63
  /** Optional JSON-Schema for the tool's args (the LLM planner uses it as the tool-use input schema). */
20
64
  inputSchema?: Record<string, unknown>;
65
+ /**
66
+ * Spec 350 §3.1 — the capability this tool EXERCISES (ADR-0051 id). Declared on the TOOL, never on the
67
+ * plan: a planner that emits a step for this tool cannot describe its way out of needing authority.
68
+ * Absent ⇒ informational, no mandate needed. `resourceArg` names the arg that holds the resource the
69
+ * step acts on (the org, the token) so the verifier can bound it.
70
+ *
71
+ * `authorityArg` names the arg holding the party whose AUTHORITY the step needs — which is not always
72
+ * the resource. Chartering a team acts on the workspace and needs the workspace's authority (the same
73
+ * address); paying acts on a TOKEN and needs the PAYER's authority (a different one). Absent ⇒ the
74
+ * resource, then whoever was addressed. Getting this wrong asks a person to grant authority as an
75
+ * ERC-20 contract, which nothing can sign.
76
+ */
77
+ capability?: {
78
+ id: string;
79
+ action: string;
80
+ resourceArg?: string;
81
+ authorityArg?: string;
82
+ /** Spec 408 §2.2 — this tool REDEEMS the mandate on chain (a payment, a chartered treasury's transfer):
83
+ * every enforcer fires at redemption, so a caveat with no off-chain judge may be recorded as enforced
84
+ * there. Absent ⇒ the step is judged strictly off chain. Declared on the tool, never by a plan. */
85
+ redeemsOnChain?: boolean;
86
+ };
87
+ /**
88
+ * Spec 366 — the argument naming the agent this act is ABOUT and is ANSWERED BY. When it resolves to an
89
+ * agent other than the one addressed, the step is not run here: it is routed to that agent's own
90
+ * harness, which verifies the asker's standing itself and answers under its own playbook. Declared on
91
+ * the tool (from the contract), never inferred from the sentence. Absent ⇒ the addressee answers.
92
+ */
93
+ subject?: string;
94
+ /**
95
+ * Spec 367 W1 — the IMPERATIVES that name this act ("send", "pay", "create a team"). A sentence that opens
96
+ * with one is an instruction, and plan admission refuses a plan for it that contains no act. Declared
97
+ * beside the capability (from the contract's utterances when compiled). A READ may claim a verb too ("ask
98
+ * <agent> …", spec 379): an instruction opening with a verb a lookup in the plan claims is discharged by
99
+ * that lookup — the verb names a consultation, not an act.
100
+ */
101
+ verbs?: string[];
102
+ /** Spec 371 — the FACT WORDS a question uses to name what this read answers ("balance", "how much").
103
+ * A read's twin of an act's `verbs`: question admission requires the plan to include the tool that
104
+ * answers a fact the sentence names. Behaviour, never authority. */
105
+ answers?: string[];
106
+ /** Spec 371 — the domain author's sentence for this read's result (`{{field}}`; once per `items[]`
107
+ * element when the result carries a list). Rendered instead of composed: the person's unit. */
108
+ answer?: string;
109
+ /**
110
+ * Spec 367 §6 — WHAT A SUCCESSFUL STEP OF THIS TOOL ESTABLISHES about the requested outcome:
111
+ * lookup who or what was meant (a roster, a relationship) — never that anything was done
112
+ * submission acceptance or pending execution (an invitation recorded, a request asked) — not the outcome
113
+ * authoritative the outcome itself, with its evidence (a mined transfer, a written record)
114
+ * Admission asks whether some step's class CAN discharge an instruction; fulfillment asks what the
115
+ * evidence DID establish, and the reply may claim only that. Absent ⇒ lookup for a tool with no
116
+ * capability, authoritative for one with. Declared on the contract; never lowered by a plan.
117
+ */
118
+ establishes?: OutcomeClass;
119
+ /** The tool's risk tier (`tool-policy.RiskTier`). Meaningful only with `capability`; defaults to `low`. */
120
+ risk?: import('@agenticprimitives/tool-policy').RiskTier;
121
+ /**
122
+ * SELF-ACTING: this capability touches ONLY the run's own principal's records, so the SESSION that
123
+ * proved who is asking is the authority and no mandate is verified.
124
+ *
125
+ * WHY THE MODEL NEEDED THIS. Until now every capability step required a presented mandate, so the
126
+ * only way to express "change your own email" was to demand a signature the Home's own form does not
127
+ * ask for — teaching people that talking to their agent is the expensive way to do the same thing.
128
+ * The alternative was worse: declaring such a tool informational, which would have hidden a WRITE
129
+ * from the authority plane entirely.
130
+ *
131
+ * WHAT IT IS NOT. It is not "low risk", and it is not a way to skip a gate. It is a claim about the
132
+ * TARGET — that there is no second party whose authority could be needed, because the actor, the
133
+ * owner and the beneficiary are the same principal. An invoker for such a tool MUST take its subject
134
+ * from the run's principal and never from an argument; the moment it can be pointed at someone else's
135
+ * record, this flag is a lie and the capability needs a mandate like everything else.
136
+ *
137
+ * It is declared on the BUILT-IN tool and never merged from a contract (a contract may describe an
138
+ * act, never weaken its gate — spec 361 §3), and the receipt records `self` as the basis so a reader
139
+ * can tell an act authorized by a session from one authorized by a signature.
140
+ */
141
+ selfAuthorized?: true;
142
+ /**
143
+ * Spec 426 — this tool is an EXECUTOR INVOKE: it has no built-in invoker; the one generic invoker reads this
144
+ * block, calls the resolved executor as the run's principal, and returns its receipt. Compiled from the
145
+ * contract's `invoke` declaration (the only place a tool gains a behaviour by declaration, not runtime code).
146
+ * Its presence IMPLIES `selfAuthorized` (v1 is self-acting); a value-moving or cross-principal invoke is out of
147
+ * scope and keeps its own mandate-gated tool. The generic invoker, not this field, is the gate.
148
+ */
149
+ invoke?: ExecutorInvokeV1;
150
+ /** Spec 420 — this tool's invoker honours `ctx.dryRun` (checks its preconditions, writes nothing), so a comparison may
151
+ * INVOKE it instead of holding it before invocation — its refusal ("nothing I remember contains …") is then testable. */
152
+ dryRun?: 'invoke';
153
+ /**
154
+ * Spec 363 W5 — the DECISION POINTS this capability consults, by id.
155
+ *
156
+ * Behaviour, never authority: consulting one lets the substrate answer a question ("which of your
157
+ * accounts pays?") from a modelled fact instead of interrupting, and every answer cites the rule that
158
+ * gave it. A capability that names none asks, which is the default and the safe one.
159
+ *
160
+ * The loop does not read this — normalisation does, where decisions are made. It rides the ToolSpec
161
+ * because that is where a CONTRACT's declaration lands (`mergeContractTool`), and a decision a domain
162
+ * author did not ask for should not happen because some app-side branch remembered a capability id.
163
+ */
164
+ decisions?: readonly string[];
165
+ /** Compensation for a run that fails AFTER this tool executed: the tool to invoke, with args derived
166
+ * from the original args (+ the result under `$result`). Declared, never improvised. */
167
+ compensation?: {
168
+ toolId: string;
169
+ args: Record<string, unknown>;
170
+ };
171
+ /** Spec 410 §2 — what this tool's ADAPTER declares about the effect it makes. Required of every tool that
172
+ * submits or commits (`establishes` ≠ lookup); a generated surface may say "cancel" only when
173
+ * `cancellation` is not `none`. Declared, never inferred from a response. */
174
+ adapter?: AdapterDeclarationV1;
175
+ /** Spec 410 §7 — WHAT THIS TOOL'S WRITE CARRIES, per argument, as ontology classes (`{ body: ['apvault:ContactEmail'] }`).
176
+ * The information-flow caveat on a mandate names what a write may carry; the verifier compares the classes of
177
+ * the arguments a step presents against it. Declared by the adapter's author, never inferred from a value. */
178
+ carries?: Readonly<Record<string, readonly string[]>>;
179
+ /** An irreversible action: imposes `fresh-authorization` whatever the tier. */
180
+ irreversible?: boolean;
181
+ /** Spec 358 W4 — this tool's result ENUMERATES the objects of a domain relation (an ontology IRI,
182
+ * e.g. aporg:memberAgent). Declaring it is what makes the result fan-out-able: a `forEach` over a
183
+ * result whose tool declares nothing is refused, because an array being array-shaped says nothing
184
+ * about whether iterating it is meaningful — a search page is not a payee list. */
185
+ enumerates?: {
186
+ relation: string;
187
+ };
188
+ /** Spec 361 — the interaction binding a playbook contract declared (editor/review/result names + a
189
+ * navigation route key). DATA carried for surfaces to resolve; the loop never reads it. */
190
+ interaction?: {
191
+ editor?: string;
192
+ review?: string;
193
+ result?: string;
194
+ navigationTarget?: string;
195
+ };
21
196
  }
22
197
  /** One step of a plan: invoke `toolId` with `args`; optionally bind the result under `ref` for later steps. */
23
198
  export interface PlanStep {
@@ -25,8 +200,42 @@ export interface PlanStep {
25
200
  args: Record<string, unknown>;
26
201
  /** Name to store this step's result under; later steps reference it via `{ $ref: name }` in their args. */
27
202
  ref?: string;
203
+ /** Spec 350 — optional stable id (defaults to `s<index>`); the receipt and the idempotency key carry it. */
204
+ id?: string;
205
+ /** Spec 376 — the AGENT that runs this step, when it is not this harness: a hand-off. The step runs
206
+ * there under a CHILD mandate attenuated from the one this run presented; this run records the
207
+ * hand-off and resumes on what comes back. Absent ⇒ this harness. */
208
+ executor?: string;
209
+ /** Caller-supplied idempotency key for a retry of THIS step; defaults to `${runRef}:${stepId}`. */
210
+ idempotencyKey?: string;
211
+ /** Spec 358 W4 — fan this step out over an ARRAY a prior step produced (`ref` is a `name.path` into
212
+ * that step's result). Each element becomes its OWN step — its own receipt, its own idempotency key,
213
+ * and its own pass through the verifier: a mandate per item, never one verdict stretched over N.
214
+ * `$item` / `{ $item: 'path' }` placeholders in `args` are substituted per element. Fail-closed: the
215
+ * producing step's tool must declare `enumerates`, and the relation must be bound fan-out-able. */
216
+ forEach?: {
217
+ ref: string;
218
+ };
219
+ /** Spec 370 P3 — run only AFTER these steps (by id) have completed. Steps with no edge between them and
220
+ * no `$ref` into each other's results are independent; the loop runs independent INFORMATIONAL steps
221
+ * concurrently, each through its own gates. A step that exercises a capability never runs beside
222
+ * another: two userOps from one account race on its nonce, and one verdict is one step's. */
223
+ after?: string[];
224
+ /** Spec 370 P3 — a DECLARED branch: run this step only when a prior result satisfies the condition.
225
+ * `ref` is a `name.path` into a prior step's result; `exists` = present and, for an array, non-empty;
226
+ * `equals` = deep-equal to the value. A step whose condition fails is SKIPPED, with a receipt saying so —
227
+ * the plan does not need a second planner call to take a branch. Undecidable at admission (a ref no
228
+ * earlier step produces) is refused, never guessed. */
229
+ when?: {
230
+ ref: string;
231
+ exists?: boolean;
232
+ equals?: unknown;
233
+ };
28
234
  }
29
235
  /** The ordered tool composition the planner produced for an intent. */
236
+ /** Spec 421 W1 — the reserved continuation step ("show me what these reads return, then I will plan the rest"). A plan
237
+ * node, never a tool the loop invokes or a verifier judges. */
238
+ export declare const CONTINUE_STEP_ID = "plan.continue";
30
239
  export interface Plan {
31
240
  steps: PlanStep[];
32
241
  /** Optional one-line reasoning (audit/telemetry only — never trusted as authority). */
@@ -38,8 +247,21 @@ export interface StepObservation {
38
247
  ok: boolean;
39
248
  result?: unknown;
40
249
  error?: string;
250
+ /** Spec 370 P1 — the step's stable reference (`id` or `s<index>`), so a checkpoint can name what ran. */
251
+ stepRef?: string;
252
+ /** Spec 370 P1 — this observation was REPLAYED from a checkpoint on a resume: nothing was invoked and
253
+ * nothing re-verified, because there was no new attempt (spec 362 §0.1, gate 4). */
254
+ replayed?: boolean;
255
+ /** Spec 370 P3 — the step's `when` did not hold: nothing ran, and the receipt says so. */
256
+ skipped?: boolean;
41
257
  }
42
- export type RunOutcome = 'completed' | 'failed';
258
+ /** `denied`: an authority decision refused a step (never re-planned around — a denial is not a tool
259
+ * failure). `suspended`: an approval is pending OR a tool asked the person for an input (`prompt`);
260
+ * resume later, through the verifier again. `authority-required`: the plan needs a mandate the caller did
261
+ * not present — nothing was verified, nothing ran; the caller may come back WITH one (opt-in via
262
+ * `onMissingMandate: 'report'`; the default is still to throw). It is 401, never 403: no authority was
263
+ * judged, so this is not a denial and must never be reported as one. */
264
+ export type RunOutcome = 'completed' | 'failed' | 'denied' | 'suspended' | 'authority-required';
43
265
  /** The result of running an intent to completion (or fail-closed). */
44
266
  export interface RunResult {
45
267
  outcome: RunOutcome;
@@ -49,11 +271,39 @@ export interface RunResult {
49
271
  steps: StepObservation[];
50
272
  /** The last successful step's result — the composed answer returned to the caller. */
51
273
  result?: unknown;
52
- /** Set when `outcome === 'failed'`. */
274
+ /** Set when `outcome === 'failed'` or `'denied'`. */
53
275
  error?: string;
276
+ /** Spec 350 — the run's reference (the A2A taskId when run inside `A2aTaskDO`). */
277
+ runRef: string;
278
+ /** Every step's receipt, informational ones included. The sink (if any) has the same list. */
279
+ receipts: import('./authority.js').StepReceipt[];
280
+ /** Set when `outcome === 'suspended'`: what to hand back to resume. */
281
+ resumeToken?: string;
282
+ /** Set when `outcome === 'suspended'` because a tool asked the person for something (spec 350 §3.4).
283
+ * The surface renders it; the answers come back as `RunIntentOpts.supplied` on the resume. */
284
+ prompt?: import('./input.js').InputRequestV1;
285
+ /** Set when `outcome === 'authority-required'`: the step the plan reached that needs a mandate. The
286
+ * caller turns it into a requirement in ITS vocabulary (`harness.mandateRequirementForStep`) — this
287
+ * layer names the step, never the grant. */
288
+ required?: {
289
+ stepRef: string;
290
+ toolId: string;
291
+ capability: {
292
+ id: string;
293
+ action: string;
294
+ resource?: string;
295
+ authority?: string;
296
+ };
297
+ risk: import('./authority.js').ResolvedStep['risk'];
298
+ args: Record<string, unknown>;
299
+ /** Spec 410 §7 — what the tool declares its inputs carry, so the requirement can name what the write may carry. */
300
+ carries?: ToolSpec['carries'];
301
+ /** Spec 421 W2 — whose words each argument came from (the planner's raw values, before resolution). */
302
+ derivation?: Record<string, import('./derivation.js').ArgDerivationV1>;
303
+ };
54
304
  }
55
305
  /** Stable error codes the loop / planners raise (fail-closed; never a silent empty success). */
56
- export type OrchestrationErrorCode = 'no_plan' | 'unknown_tool' | 'empty_plan' | 'max_steps' | 'planner_failed';
306
+ export type OrchestrationErrorCode = 'no_plan' | 'reconcile_indeterminate' | 'unknown_tool' | 'empty_plan' | 'max_steps' | 'planner_failed' | 'no_authority_port' | 'no_approval_port' | 'no_mandate_presented' | 'keyring_needs_selector' | 'fan_out_unbound' | 'fan_out_not_array' | 'fan_out_refused' | 'resume_integrity' | 'fan_out_over_limit';
57
307
  export declare class OrchestrationError extends Error {
58
308
  readonly code: OrchestrationErrorCode;
59
309
  constructor(code: OrchestrationErrorCode, message: string);
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAQA,eAAO,MAAM,YAAY,EAAG,kCAA2C,CAAC;AACxE,eAAO,MAAM,cAAc,EAAG,SAAkB,CAAC;AACjD,eAAO,MAAM,QAAQ,EAAG,gCAAyC,CAAC;AAElE,sGAAsG;AACtG,MAAM,WAAW,MAAM;IACrB,4EAA4E;IAC5E,IAAI,EAAE,MAAM,CAAC;IACb,wGAAwG;IACxG,WAAW,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACtC,4FAA4F;IAC5F,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACnC;AAED,4GAA4G;AAC5G,MAAM,WAAW,QAAQ;IACvB,kFAAkF;IAClF,EAAE,EAAE,MAAM,CAAC;IACX,uGAAuG;IACvG,WAAW,EAAE,MAAM,CAAC;IACpB,uGAAuG;IACvG,WAAW,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACvC;AAED,+GAA+G;AAC/G,MAAM,WAAW,QAAQ;IACvB,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,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ED,gGAAgG;AAChG,MAAM,MAAM,sBAAsB,GAC9B,SAAS,GACT,yBAAyB,GACzB,cAAc,GACd,YAAY,GACZ,WAAW,GACX,gBAAgB,GAChB,mBAAmB,GACnB,kBAAkB,GAClB,sBAAsB,GACtB,wBAAwB,GACxB,iBAAiB,GACjB,mBAAmB,GACnB,iBAAiB,GACjB,kBAAkB,GAClB,oBAAoB,CAAC;AAEzB,qBAAa,kBAAmB,SAAQ,KAAK;aAEzB,IAAI,EAAE,sBAAsB;gBAA5B,IAAI,EAAE,sBAAsB,EAC5C,OAAO,EAAE,MAAM;CAKlB"}
package/dist/types.js CHANGED
@@ -8,6 +8,10 @@
8
8
  export const PACKAGE_NAME = '@agenticprimitives/orchestration';
9
9
  export const PACKAGE_STATUS = 'w1-core';
10
10
  export const SPEC_REF = 'packages/orchestration/spec.md';
11
+ /** The ordered tool composition the planner produced for an intent. */
12
+ /** Spec 421 W1 — the reserved continuation step ("show me what these reads return, then I will plan the rest"). A plan
13
+ * node, never a tool the loop invokes or a verifier judges. */
14
+ export const CONTINUE_STEP_ID = 'plan.continue';
11
15
  export class OrchestrationError extends Error {
12
16
  code;
13
17
  constructor(code, message) {
package/dist/types.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,sGAAsG;AACtG,EAAE;AACF,+FAA+F;AAC/F,2GAA2G;AAC3G,6GAA6G;AAC7G,6GAA6G;AAC7G,+GAA+G;AAE/G,MAAM,CAAC,MAAM,YAAY,GAAG,kCAA2C,CAAC;AACxE,MAAM,CAAC,MAAM,cAAc,GAAG,SAAkB,CAAC;AACjD,MAAM,CAAC,MAAM,QAAQ,GAAG,gCAAyC,CAAC;AAoElE,MAAM,OAAO,kBAAmB,SAAQ,KAAK;IAEzB;IADlB,YACkB,IAA4B,EAC5C,OAAe;QAEf,KAAK,CAAC,OAAO,CAAC,CAAC;QAHC,SAAI,GAAJ,IAAI,CAAwB;QAI5C,IAAI,CAAC,IAAI,GAAG,oBAAoB,CAAC;IACnC,CAAC;CACF"}
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,sGAAsG;AACtG,EAAE;AACF,+FAA+F;AAC/F,2GAA2G;AAC3G,6GAA6G;AAC7G,6GAA6G;AAC7G,+GAA+G;AAE/G,MAAM,CAAC,MAAM,YAAY,GAAG,kCAA2C,CAAC;AACxE,MAAM,CAAC,MAAM,cAAc,GAAG,SAAkB,CAAC;AACjD,MAAM,CAAC,MAAM,QAAQ,GAAG,gCAAyC,CAAC;AAyNlE,uEAAuE;AACvE;gEACgE;AAChE,MAAM,CAAC,MAAM,gBAAgB,GAAG,eAAe,CAAC;AAqFhD,MAAM,OAAO,kBAAmB,SAAQ,KAAK;IAEzB;IADlB,YACkB,IAA4B,EAC5C,OAAe;QAEf,KAAK,CAAC,OAAO,CAAC,CAAC;QAHC,SAAI,GAAJ,IAAI,CAAwB;QAI5C,IAAI,CAAC,IAAI,GAAG,oBAAoB,CAAC;IACnC,CAAC;CACF"}
package/package.json CHANGED
@@ -1,17 +1,21 @@
1
1
  {
2
2
  "name": "@agenticprimitives/orchestration",
3
- "version": "0.0.0-alpha.1",
3
+ "version": "0.0.0-alpha.10",
4
4
  "description": "The Ring-0 agentic orchestration core (ADR-0044): the intent→plan→execute→observe loop, the Planner + ToolInvoker ports, and a deterministic rule-based planner. A first-party app expresses a goal; the loop plans which tools compose to satisfy it and runs them through an injected invoker. Pure leaf — no transport, no LLM SDK, no chain; the concrete LLM binding lives behind the Planner port in orchestration-anthropic.",
5
+ "homepage": "https://agenticprimitives.dev",
6
+ "bugs": {
7
+ "url": "https://github.com/agentictrustlabs/agenticprimitives/issues"
8
+ },
9
+ "author": {
10
+ "name": "Agentic Trust Labs",
11
+ "url": "https://agenticprimitives.dev"
12
+ },
5
13
  "license": "MIT",
6
14
  "repository": {
7
15
  "type": "git",
8
16
  "url": "git+https://github.com/agentictrustlabs/agenticprimitives.git",
9
17
  "directory": "packages/orchestration"
10
18
  },
11
- "homepage": "https://github.com/agentictrustlabs/agenticprimitives/tree/master/packages/orchestration",
12
- "bugs": {
13
- "url": "https://github.com/agentictrustlabs/agenticprimitives/issues"
14
- },
15
19
  "type": "module",
16
20
  "main": "./dist/index.js",
17
21
  "types": "./dist/index.d.ts",
@@ -31,7 +35,7 @@
31
35
  "access": "public"
32
36
  },
33
37
  "devDependencies": {
34
- "vitest": "^4.1.8"
38
+ "vitest": "^4.1.11"
35
39
  },
36
40
  "keywords": [
37
41
  "agentic",
@@ -39,8 +43,16 @@
39
43
  "orchestration",
40
44
  "planner",
41
45
  "intent",
42
- "agentic-loop"
46
+ "agentic-loop",
47
+ "agentic-primitives",
48
+ "agenticprimitives",
49
+ "ai-agents",
50
+ "agent-authority",
51
+ "agentic-trust"
43
52
  ],
53
+ "dependencies": {
54
+ "@agenticprimitives/tool-policy": "1.0.0-alpha.31"
55
+ },
44
56
  "scripts": {
45
57
  "build": "tsc -p tsconfig.build.json",
46
58
  "typecheck": "tsc -p tsconfig.json --noEmit",