@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.
- package/README.md +2 -0
- package/dist/admission.d.ts +127 -0
- package/dist/admission.d.ts.map +1 -0
- package/dist/admission.js +355 -0
- package/dist/admission.js.map +1 -0
- package/dist/answer-quality.d.ts +80 -0
- package/dist/answer-quality.d.ts.map +1 -0
- package/dist/answer-quality.js +97 -0
- package/dist/answer-quality.js.map +1 -0
- package/dist/artifacts.d.ts +137 -0
- package/dist/artifacts.d.ts.map +1 -0
- package/dist/artifacts.js +232 -0
- package/dist/artifacts.js.map +1 -0
- package/dist/authority.d.ts +465 -0
- package/dist/authority.d.ts.map +1 -0
- package/dist/authority.js +2 -0
- package/dist/authority.js.map +1 -0
- package/dist/conformance.d.ts +66 -0
- package/dist/conformance.d.ts.map +1 -0
- package/dist/conformance.js +140 -0
- package/dist/conformance.js.map +1 -0
- package/dist/derivation.d.ts +21 -0
- package/dist/derivation.d.ts.map +1 -0
- package/dist/derivation.js +31 -0
- package/dist/derivation.js.map +1 -0
- package/dist/durable.d.ts +44 -0
- package/dist/durable.d.ts.map +1 -0
- package/dist/durable.js +15 -0
- package/dist/durable.js.map +1 -0
- package/dist/export-port.d.ts +13 -0
- package/dist/export-port.d.ts.map +1 -0
- package/dist/export-port.js +2 -0
- package/dist/export-port.js.map +1 -0
- package/dist/flow-trace.d.ts +105 -0
- package/dist/flow-trace.d.ts.map +1 -0
- package/dist/flow-trace.js +60 -0
- package/dist/flow-trace.js.map +1 -0
- package/dist/index.d.ts +37 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +44 -3
- package/dist/index.js.map +1 -1
- package/dist/input.d.ts +165 -0
- package/dist/input.d.ts.map +1 -0
- package/dist/input.js +33 -0
- package/dist/input.js.map +1 -0
- package/dist/intent.d.ts +37 -0
- package/dist/intent.d.ts.map +1 -0
- package/dist/intent.js +46 -0
- package/dist/intent.js.map +1 -0
- package/dist/judgment.d.ts +131 -0
- package/dist/judgment.d.ts.map +1 -0
- package/dist/judgment.js +249 -0
- package/dist/judgment.js.map +1 -0
- package/dist/loop.d.ts +155 -6
- package/dist/loop.d.ts.map +1 -1
- package/dist/loop.js +905 -32
- package/dist/loop.js.map +1 -1
- package/dist/metrics.d.ts +35 -0
- package/dist/metrics.d.ts.map +1 -0
- package/dist/metrics.js +98 -0
- package/dist/metrics.js.map +1 -0
- package/dist/outcome.d.ts +223 -0
- package/dist/outcome.d.ts.map +1 -0
- package/dist/outcome.js +325 -0
- package/dist/outcome.js.map +1 -0
- package/dist/plan-digest.d.ts +6 -0
- package/dist/plan-digest.d.ts.map +1 -0
- package/dist/plan-digest.js +35 -0
- package/dist/plan-digest.js.map +1 -0
- package/dist/planner-wire.d.ts +11 -0
- package/dist/planner-wire.d.ts.map +1 -0
- package/dist/planner-wire.js +53 -0
- package/dist/planner-wire.js.map +1 -0
- package/dist/planner.d.ts +51 -0
- package/dist/planner.d.ts.map +1 -1
- package/dist/planner.js +74 -0
- package/dist/planner.js.map +1 -1
- package/dist/reconcile.d.ts +41 -0
- package/dist/reconcile.d.ts.map +1 -0
- package/dist/reconcile.js +20 -0
- package/dist/reconcile.js.map +1 -0
- package/dist/record.d.ts +238 -0
- package/dist/record.d.ts.map +1 -0
- package/dist/record.js +116 -0
- package/dist/record.js.map +1 -0
- package/dist/regression.d.ts +109 -0
- package/dist/regression.d.ts.map +1 -0
- package/dist/regression.js +97 -0
- package/dist/regression.js.map +1 -0
- package/dist/selection.d.ts +334 -0
- package/dist/selection.d.ts.map +1 -0
- package/dist/selection.js +481 -0
- package/dist/selection.js.map +1 -0
- package/dist/spans.d.ts +262 -0
- package/dist/spans.d.ts.map +1 -0
- package/dist/spans.js +589 -0
- package/dist/spans.js.map +1 -0
- package/dist/tool-invoker.d.ts +61 -3
- package/dist/tool-invoker.d.ts.map +1 -1
- package/dist/tool-invoker.js +26 -1
- package/dist/tool-invoker.js.map +1 -1
- package/dist/trace-context.d.ts +26 -0
- package/dist/trace-context.d.ts.map +1 -0
- package/dist/trace-context.js +59 -0
- package/dist/trace-context.js.map +1 -0
- package/dist/trace-facts.d.ts +84 -0
- package/dist/trace-facts.d.ts.map +1 -0
- package/dist/trace-facts.js +82 -0
- package/dist/trace-facts.js.map +1 -0
- package/dist/types.d.ts +265 -3
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +4 -0
- package/dist/types.js.map +1 -1
- package/package.json +19 -7
package/dist/types.d.ts
CHANGED
|
@@ -9,8 +9,64 @@ 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 type ExecutorInvokeV1 = {
|
|
44
|
+
/** An A2A executor: `message/send` as the principal, under a session minted for the executor's client. */
|
|
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
|
+
} | {
|
|
58
|
+
/** A stateless MCP server the operator maps by name (`kind: 'mcp'`): ONE `tools/call`, no session — a public
|
|
59
|
+
* read that decides nothing about anyone; what comes back is the server's answer, evidence with its source named. */
|
|
60
|
+
transport: 'mcp.tools-call';
|
|
61
|
+
/** A NAME the operator maps to { url } — never a URL (ADR-0021). */
|
|
62
|
+
executor: string;
|
|
63
|
+
/** The MCP tool name (`tools/call` → `params.name`). */
|
|
64
|
+
intent: string;
|
|
65
|
+
/** The capability's arg names forwarded as the tool's `arguments` (absent ⇒ every arg). */
|
|
66
|
+
args: {
|
|
67
|
+
arguments?: string[];
|
|
68
|
+
};
|
|
69
|
+
};
|
|
14
70
|
export interface ToolSpec {
|
|
15
71
|
/** Stable tool id (matches the invoker's dispatch key, e.g. an MCP tool name). */
|
|
16
72
|
id: string;
|
|
@@ -18,6 +74,137 @@ export interface ToolSpec {
|
|
|
18
74
|
description: string;
|
|
19
75
|
/** Optional JSON-Schema for the tool's args (the LLM planner uses it as the tool-use input schema). */
|
|
20
76
|
inputSchema?: Record<string, unknown>;
|
|
77
|
+
/**
|
|
78
|
+
* Spec 350 §3.1 — the capability this tool EXERCISES (ADR-0051 id). Declared on the TOOL, never on the
|
|
79
|
+
* plan: a planner that emits a step for this tool cannot describe its way out of needing authority.
|
|
80
|
+
* Absent ⇒ informational, no mandate needed. `resourceArg` names the arg that holds the resource the
|
|
81
|
+
* step acts on (the org, the token) so the verifier can bound it.
|
|
82
|
+
*
|
|
83
|
+
* `authorityArg` names the arg holding the party whose AUTHORITY the step needs — which is not always
|
|
84
|
+
* the resource. Chartering a team acts on the workspace and needs the workspace's authority (the same
|
|
85
|
+
* address); paying acts on a TOKEN and needs the PAYER's authority (a different one). Absent ⇒ the
|
|
86
|
+
* resource, then whoever was addressed. Getting this wrong asks a person to grant authority as an
|
|
87
|
+
* ERC-20 contract, which nothing can sign.
|
|
88
|
+
*/
|
|
89
|
+
capability?: {
|
|
90
|
+
id: string;
|
|
91
|
+
action: string;
|
|
92
|
+
resourceArg?: string;
|
|
93
|
+
authorityArg?: string;
|
|
94
|
+
/** Spec 408 §2.2 — this tool REDEEMS the mandate on chain (a payment, a chartered treasury's transfer):
|
|
95
|
+
* every enforcer fires at redemption, so a caveat with no off-chain judge may be recorded as enforced
|
|
96
|
+
* there. Absent ⇒ the step is judged strictly off chain. Declared on the tool, never by a plan. */
|
|
97
|
+
redeemsOnChain?: boolean;
|
|
98
|
+
};
|
|
99
|
+
/**
|
|
100
|
+
* Spec 366 — the argument naming the agent this act is ABOUT and is ANSWERED BY. When it resolves to an
|
|
101
|
+
* agent other than the one addressed, the step is not run here: it is routed to that agent's own
|
|
102
|
+
* harness, which verifies the asker's standing itself and answers under its own playbook. Declared on
|
|
103
|
+
* the tool (from the contract), never inferred from the sentence. Absent ⇒ the addressee answers.
|
|
104
|
+
*/
|
|
105
|
+
subject?: string;
|
|
106
|
+
/**
|
|
107
|
+
* Spec 367 W1 — the IMPERATIVES that name this act ("send", "pay", "create a team"). A sentence that opens
|
|
108
|
+
* with one is an instruction, and plan admission refuses a plan for it that contains no act. Declared
|
|
109
|
+
* beside the capability (from the contract's utterances when compiled). A READ may claim a verb too ("ask
|
|
110
|
+
* <agent> …", spec 379): an instruction opening with a verb a lookup in the plan claims is discharged by
|
|
111
|
+
* that lookup — the verb names a consultation, not an act.
|
|
112
|
+
*/
|
|
113
|
+
verbs?: string[];
|
|
114
|
+
/** Spec 371 — the FACT WORDS a question uses to name what this read answers ("balance", "how much").
|
|
115
|
+
* A read's twin of an act's `verbs`: question admission requires the plan to include the tool that
|
|
116
|
+
* answers a fact the sentence names. Behaviour, never authority. */
|
|
117
|
+
answers?: string[];
|
|
118
|
+
/** Spec 371 — the domain author's sentence for this read's result (`{{field}}`; once per `items[]`
|
|
119
|
+
* element when the result carries a list). Rendered instead of composed: the person's unit. */
|
|
120
|
+
answer?: string;
|
|
121
|
+
/**
|
|
122
|
+
* Spec 367 §6 — WHAT A SUCCESSFUL STEP OF THIS TOOL ESTABLISHES about the requested outcome:
|
|
123
|
+
* lookup who or what was meant (a roster, a relationship) — never that anything was done
|
|
124
|
+
* submission acceptance or pending execution (an invitation recorded, a request asked) — not the outcome
|
|
125
|
+
* authoritative the outcome itself, with its evidence (a mined transfer, a written record)
|
|
126
|
+
* Admission asks whether some step's class CAN discharge an instruction; fulfillment asks what the
|
|
127
|
+
* evidence DID establish, and the reply may claim only that. Absent ⇒ lookup for a tool with no
|
|
128
|
+
* capability, authoritative for one with. Declared on the contract; never lowered by a plan.
|
|
129
|
+
*/
|
|
130
|
+
establishes?: OutcomeClass;
|
|
131
|
+
/** The tool's risk tier (`tool-policy.RiskTier`). Meaningful only with `capability`; defaults to `low`. */
|
|
132
|
+
risk?: import('@agenticprimitives/tool-policy').RiskTier;
|
|
133
|
+
/**
|
|
134
|
+
* SELF-ACTING: this capability touches ONLY the run's own principal's records, so the SESSION that
|
|
135
|
+
* proved who is asking is the authority and no mandate is verified.
|
|
136
|
+
*
|
|
137
|
+
* WHY THE MODEL NEEDED THIS. Until now every capability step required a presented mandate, so the
|
|
138
|
+
* only way to express "change your own email" was to demand a signature the Home's own form does not
|
|
139
|
+
* ask for — teaching people that talking to their agent is the expensive way to do the same thing.
|
|
140
|
+
* The alternative was worse: declaring such a tool informational, which would have hidden a WRITE
|
|
141
|
+
* from the authority plane entirely.
|
|
142
|
+
*
|
|
143
|
+
* 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
|
|
144
|
+
* TARGET — that there is no second party whose authority could be needed, because the actor, the
|
|
145
|
+
* owner and the beneficiary are the same principal. An invoker for such a tool MUST take its subject
|
|
146
|
+
* from the run's principal and never from an argument; the moment it can be pointed at someone else's
|
|
147
|
+
* record, this flag is a lie and the capability needs a mandate like everything else.
|
|
148
|
+
*
|
|
149
|
+
* It is declared on the BUILT-IN tool and never merged from a contract (a contract may describe an
|
|
150
|
+
* act, never weaken its gate — spec 361 §3), and the receipt records `self` as the basis so a reader
|
|
151
|
+
* can tell an act authorized by a session from one authorized by a signature.
|
|
152
|
+
*/
|
|
153
|
+
selfAuthorized?: true;
|
|
154
|
+
/**
|
|
155
|
+
* Spec 426 — this tool is an EXECUTOR INVOKE: it has no built-in invoker; the one generic invoker reads this
|
|
156
|
+
* block, calls the resolved executor as the run's principal, and returns its receipt. Compiled from the
|
|
157
|
+
* contract's `invoke` declaration (the only place a tool gains a behaviour by declaration, not runtime code).
|
|
158
|
+
* Its presence IMPLIES `selfAuthorized` (v1 is self-acting); a value-moving or cross-principal invoke is out of
|
|
159
|
+
* scope and keeps its own mandate-gated tool. The generic invoker, not this field, is the gate.
|
|
160
|
+
*/
|
|
161
|
+
invoke?: ExecutorInvokeV1;
|
|
162
|
+
/** Spec 420 — this tool's invoker honours `ctx.dryRun` (checks its preconditions, writes nothing), so a comparison may
|
|
163
|
+
* INVOKE it instead of holding it before invocation — its refusal ("nothing I remember contains …") is then testable. */
|
|
164
|
+
dryRun?: 'invoke';
|
|
165
|
+
/**
|
|
166
|
+
* Spec 363 W5 — the DECISION POINTS this capability consults, by id.
|
|
167
|
+
*
|
|
168
|
+
* Behaviour, never authority: consulting one lets the substrate answer a question ("which of your
|
|
169
|
+
* accounts pays?") from a modelled fact instead of interrupting, and every answer cites the rule that
|
|
170
|
+
* gave it. A capability that names none asks, which is the default and the safe one.
|
|
171
|
+
*
|
|
172
|
+
* The loop does not read this — normalisation does, where decisions are made. It rides the ToolSpec
|
|
173
|
+
* because that is where a CONTRACT's declaration lands (`mergeContractTool`), and a decision a domain
|
|
174
|
+
* author did not ask for should not happen because some app-side branch remembered a capability id.
|
|
175
|
+
*/
|
|
176
|
+
decisions?: readonly string[];
|
|
177
|
+
/** Compensation for a run that fails AFTER this tool executed: the tool to invoke, with args derived
|
|
178
|
+
* from the original args (+ the result under `$result`). Declared, never improvised. */
|
|
179
|
+
compensation?: {
|
|
180
|
+
toolId: string;
|
|
181
|
+
args: Record<string, unknown>;
|
|
182
|
+
};
|
|
183
|
+
/** Spec 410 §2 — what this tool's ADAPTER declares about the effect it makes. Required of every tool that
|
|
184
|
+
* submits or commits (`establishes` ≠ lookup); a generated surface may say "cancel" only when
|
|
185
|
+
* `cancellation` is not `none`. Declared, never inferred from a response. */
|
|
186
|
+
adapter?: AdapterDeclarationV1;
|
|
187
|
+
/** Spec 410 §7 — WHAT THIS TOOL'S WRITE CARRIES, per argument, as ontology classes (`{ body: ['apvault:ContactEmail'] }`).
|
|
188
|
+
* The information-flow caveat on a mandate names what a write may carry; the verifier compares the classes of
|
|
189
|
+
* the arguments a step presents against it. Declared by the adapter's author, never inferred from a value. */
|
|
190
|
+
carries?: Readonly<Record<string, readonly string[]>>;
|
|
191
|
+
/** An irreversible action: imposes `fresh-authorization` whatever the tier. */
|
|
192
|
+
irreversible?: boolean;
|
|
193
|
+
/** Spec 358 W4 — this tool's result ENUMERATES the objects of a domain relation (an ontology IRI,
|
|
194
|
+
* e.g. aporg:memberAgent). Declaring it is what makes the result fan-out-able: a `forEach` over a
|
|
195
|
+
* result whose tool declares nothing is refused, because an array being array-shaped says nothing
|
|
196
|
+
* about whether iterating it is meaningful — a search page is not a payee list. */
|
|
197
|
+
enumerates?: {
|
|
198
|
+
relation: string;
|
|
199
|
+
};
|
|
200
|
+
/** Spec 361 — the interaction binding a playbook contract declared (editor/review/result names + a
|
|
201
|
+
* navigation route key). DATA carried for surfaces to resolve; the loop never reads it. */
|
|
202
|
+
interaction?: {
|
|
203
|
+
editor?: string;
|
|
204
|
+
review?: string;
|
|
205
|
+
result?: string;
|
|
206
|
+
navigationTarget?: string;
|
|
207
|
+
};
|
|
21
208
|
}
|
|
22
209
|
/** One step of a plan: invoke `toolId` with `args`; optionally bind the result under `ref` for later steps. */
|
|
23
210
|
export interface PlanStep {
|
|
@@ -25,8 +212,42 @@ export interface PlanStep {
|
|
|
25
212
|
args: Record<string, unknown>;
|
|
26
213
|
/** Name to store this step's result under; later steps reference it via `{ $ref: name }` in their args. */
|
|
27
214
|
ref?: string;
|
|
215
|
+
/** Spec 350 — optional stable id (defaults to `s<index>`); the receipt and the idempotency key carry it. */
|
|
216
|
+
id?: string;
|
|
217
|
+
/** Spec 376 — the AGENT that runs this step, when it is not this harness: a hand-off. The step runs
|
|
218
|
+
* there under a CHILD mandate attenuated from the one this run presented; this run records the
|
|
219
|
+
* hand-off and resumes on what comes back. Absent ⇒ this harness. */
|
|
220
|
+
executor?: string;
|
|
221
|
+
/** Caller-supplied idempotency key for a retry of THIS step; defaults to `${runRef}:${stepId}`. */
|
|
222
|
+
idempotencyKey?: string;
|
|
223
|
+
/** Spec 358 W4 — fan this step out over an ARRAY a prior step produced (`ref` is a `name.path` into
|
|
224
|
+
* that step's result). Each element becomes its OWN step — its own receipt, its own idempotency key,
|
|
225
|
+
* and its own pass through the verifier: a mandate per item, never one verdict stretched over N.
|
|
226
|
+
* `$item` / `{ $item: 'path' }` placeholders in `args` are substituted per element. Fail-closed: the
|
|
227
|
+
* producing step's tool must declare `enumerates`, and the relation must be bound fan-out-able. */
|
|
228
|
+
forEach?: {
|
|
229
|
+
ref: string;
|
|
230
|
+
};
|
|
231
|
+
/** Spec 370 P3 — run only AFTER these steps (by id) have completed. Steps with no edge between them and
|
|
232
|
+
* no `$ref` into each other's results are independent; the loop runs independent INFORMATIONAL steps
|
|
233
|
+
* concurrently, each through its own gates. A step that exercises a capability never runs beside
|
|
234
|
+
* another: two userOps from one account race on its nonce, and one verdict is one step's. */
|
|
235
|
+
after?: string[];
|
|
236
|
+
/** Spec 370 P3 — a DECLARED branch: run this step only when a prior result satisfies the condition.
|
|
237
|
+
* `ref` is a `name.path` into a prior step's result; `exists` = present and, for an array, non-empty;
|
|
238
|
+
* `equals` = deep-equal to the value. A step whose condition fails is SKIPPED, with a receipt saying so —
|
|
239
|
+
* the plan does not need a second planner call to take a branch. Undecidable at admission (a ref no
|
|
240
|
+
* earlier step produces) is refused, never guessed. */
|
|
241
|
+
when?: {
|
|
242
|
+
ref: string;
|
|
243
|
+
exists?: boolean;
|
|
244
|
+
equals?: unknown;
|
|
245
|
+
};
|
|
28
246
|
}
|
|
29
247
|
/** The ordered tool composition the planner produced for an intent. */
|
|
248
|
+
/** Spec 421 W1 — the reserved continuation step ("show me what these reads return, then I will plan the rest"). A plan
|
|
249
|
+
* node, never a tool the loop invokes or a verifier judges. */
|
|
250
|
+
export declare const CONTINUE_STEP_ID = "plan.continue";
|
|
30
251
|
export interface Plan {
|
|
31
252
|
steps: PlanStep[];
|
|
32
253
|
/** Optional one-line reasoning (audit/telemetry only — never trusted as authority). */
|
|
@@ -38,8 +259,21 @@ export interface StepObservation {
|
|
|
38
259
|
ok: boolean;
|
|
39
260
|
result?: unknown;
|
|
40
261
|
error?: string;
|
|
262
|
+
/** Spec 370 P1 — the step's stable reference (`id` or `s<index>`), so a checkpoint can name what ran. */
|
|
263
|
+
stepRef?: string;
|
|
264
|
+
/** Spec 370 P1 — this observation was REPLAYED from a checkpoint on a resume: nothing was invoked and
|
|
265
|
+
* nothing re-verified, because there was no new attempt (spec 362 §0.1, gate 4). */
|
|
266
|
+
replayed?: boolean;
|
|
267
|
+
/** Spec 370 P3 — the step's `when` did not hold: nothing ran, and the receipt says so. */
|
|
268
|
+
skipped?: boolean;
|
|
41
269
|
}
|
|
42
|
-
|
|
270
|
+
/** `denied`: an authority decision refused a step (never re-planned around — a denial is not a tool
|
|
271
|
+
* failure). `suspended`: an approval is pending OR a tool asked the person for an input (`prompt`);
|
|
272
|
+
* resume later, through the verifier again. `authority-required`: the plan needs a mandate the caller did
|
|
273
|
+
* not present — nothing was verified, nothing ran; the caller may come back WITH one (opt-in via
|
|
274
|
+
* `onMissingMandate: 'report'`; the default is still to throw). It is 401, never 403: no authority was
|
|
275
|
+
* judged, so this is not a denial and must never be reported as one. */
|
|
276
|
+
export type RunOutcome = 'completed' | 'failed' | 'denied' | 'suspended' | 'authority-required';
|
|
43
277
|
/** The result of running an intent to completion (or fail-closed). */
|
|
44
278
|
export interface RunResult {
|
|
45
279
|
outcome: RunOutcome;
|
|
@@ -49,11 +283,39 @@ export interface RunResult {
|
|
|
49
283
|
steps: StepObservation[];
|
|
50
284
|
/** The last successful step's result — the composed answer returned to the caller. */
|
|
51
285
|
result?: unknown;
|
|
52
|
-
/** Set when `outcome === 'failed'`. */
|
|
286
|
+
/** Set when `outcome === 'failed'` or `'denied'`. */
|
|
53
287
|
error?: string;
|
|
288
|
+
/** Spec 350 — the run's reference (the A2A taskId when run inside `A2aTaskDO`). */
|
|
289
|
+
runRef: string;
|
|
290
|
+
/** Every step's receipt, informational ones included. The sink (if any) has the same list. */
|
|
291
|
+
receipts: import('./authority.js').StepReceipt[];
|
|
292
|
+
/** Set when `outcome === 'suspended'`: what to hand back to resume. */
|
|
293
|
+
resumeToken?: string;
|
|
294
|
+
/** Set when `outcome === 'suspended'` because a tool asked the person for something (spec 350 §3.4).
|
|
295
|
+
* The surface renders it; the answers come back as `RunIntentOpts.supplied` on the resume. */
|
|
296
|
+
prompt?: import('./input.js').InputRequestV1;
|
|
297
|
+
/** Set when `outcome === 'authority-required'`: the step the plan reached that needs a mandate. The
|
|
298
|
+
* caller turns it into a requirement in ITS vocabulary (`harness.mandateRequirementForStep`) — this
|
|
299
|
+
* layer names the step, never the grant. */
|
|
300
|
+
required?: {
|
|
301
|
+
stepRef: string;
|
|
302
|
+
toolId: string;
|
|
303
|
+
capability: {
|
|
304
|
+
id: string;
|
|
305
|
+
action: string;
|
|
306
|
+
resource?: string;
|
|
307
|
+
authority?: string;
|
|
308
|
+
};
|
|
309
|
+
risk: import('./authority.js').ResolvedStep['risk'];
|
|
310
|
+
args: Record<string, unknown>;
|
|
311
|
+
/** Spec 410 §7 — what the tool declares its inputs carry, so the requirement can name what the write may carry. */
|
|
312
|
+
carries?: ToolSpec['carries'];
|
|
313
|
+
/** Spec 421 W2 — whose words each argument came from (the planner's raw values, before resolution). */
|
|
314
|
+
derivation?: Record<string, import('./derivation.js').ArgDerivationV1>;
|
|
315
|
+
};
|
|
54
316
|
}
|
|
55
317
|
/** 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';
|
|
318
|
+
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
319
|
export declare class OrchestrationError extends Error {
|
|
58
320
|
readonly code: OrchestrationErrorCode;
|
|
59
321
|
constructor(code: OrchestrationErrorCode, message: string);
|
package/dist/types.d.ts.map
CHANGED
|
@@ -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;
|
|
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;IAClC;;;qFAGiF;IACjF,QAAQ,CAAC,EAAE;QAAE,sBAAsB,EAAE,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e,CAAC,CAAC;KACxE,CAAC;CACH;AAED,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;
|
|
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;AAqOlE,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.
|
|
3
|
+
"version": "0.0.0-alpha.11",
|
|
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.
|
|
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",
|