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

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 (61) hide show
  1. package/dist/admission.d.ts +87 -0
  2. package/dist/admission.d.ts.map +1 -0
  3. package/dist/admission.js +193 -0
  4. package/dist/admission.js.map +1 -0
  5. package/dist/artifacts.d.ts +137 -0
  6. package/dist/artifacts.d.ts.map +1 -0
  7. package/dist/artifacts.js +232 -0
  8. package/dist/artifacts.js.map +1 -0
  9. package/dist/authority.d.ts +431 -0
  10. package/dist/authority.d.ts.map +1 -0
  11. package/dist/authority.js +2 -0
  12. package/dist/authority.js.map +1 -0
  13. package/dist/durable.d.ts +44 -0
  14. package/dist/durable.d.ts.map +1 -0
  15. package/dist/durable.js +15 -0
  16. package/dist/durable.js.map +1 -0
  17. package/dist/flow-trace.d.ts +105 -0
  18. package/dist/flow-trace.d.ts.map +1 -0
  19. package/dist/flow-trace.js +60 -0
  20. package/dist/flow-trace.js.map +1 -0
  21. package/dist/index.d.ts +20 -1
  22. package/dist/index.d.ts.map +1 -1
  23. package/dist/index.js +21 -1
  24. package/dist/index.js.map +1 -1
  25. package/dist/input.d.ts +165 -0
  26. package/dist/input.d.ts.map +1 -0
  27. package/dist/input.js +33 -0
  28. package/dist/input.js.map +1 -0
  29. package/dist/loop.d.ts +115 -3
  30. package/dist/loop.d.ts.map +1 -1
  31. package/dist/loop.js +656 -30
  32. package/dist/loop.js.map +1 -1
  33. package/dist/metrics.d.ts +35 -0
  34. package/dist/metrics.d.ts.map +1 -0
  35. package/dist/metrics.js +98 -0
  36. package/dist/metrics.js.map +1 -0
  37. package/dist/planner-wire.d.ts +11 -0
  38. package/dist/planner-wire.d.ts.map +1 -0
  39. package/dist/planner-wire.js +53 -0
  40. package/dist/planner-wire.js.map +1 -0
  41. package/dist/planner.d.ts +33 -0
  42. package/dist/planner.d.ts.map +1 -1
  43. package/dist/planner.js.map +1 -1
  44. package/dist/record.d.ts +151 -0
  45. package/dist/record.d.ts.map +1 -0
  46. package/dist/record.js +72 -0
  47. package/dist/record.js.map +1 -0
  48. package/dist/spans.d.ts +200 -0
  49. package/dist/spans.d.ts.map +1 -0
  50. package/dist/spans.js +522 -0
  51. package/dist/spans.js.map +1 -0
  52. package/dist/tool-invoker.d.ts +7 -0
  53. package/dist/tool-invoker.d.ts.map +1 -1
  54. package/dist/trace-context.d.ts +26 -0
  55. package/dist/trace-context.d.ts.map +1 -0
  56. package/dist/trace-context.js +59 -0
  57. package/dist/trace-context.js.map +1 -0
  58. package/dist/types.d.ts +180 -3
  59. package/dist/types.d.ts.map +1 -1
  60. package/dist/types.js.map +1 -1
  61. package/package.json +4 -1
@@ -0,0 +1,431 @@
1
+ import type { Intent, PlanStep, ToolSpec } from './types.js';
2
+ import type { StepRiskClass } from '@agenticprimitives/tool-policy';
3
+ /** What the caller presented as its authority. OPAQUE to the loop — it is handed to the verifier and
4
+ * never inspected here. A `delegation` wire, a session leaf, anything the verifier understands. */
5
+ export interface MandatePresentation {
6
+ /** A stable reference the receipt carries (normally the delegation hash). */
7
+ ref: string;
8
+ /** The wire itself. The loop passes it through untouched. */
9
+ wire: unknown;
10
+ }
11
+ /** A step as the authority layer sees it: the plan's step joined to its tool's DECLARATION. Capability and
12
+ * risk come from the tool, not the plan — a planner cannot lower a risk by describing a step differently. */
13
+ export interface ResolvedStep {
14
+ runRef: string;
15
+ stepRef: string;
16
+ index: number;
17
+ step: PlanStep;
18
+ tool: ToolSpec;
19
+ /** Args with `{ $ref }` placeholders resolved. */
20
+ args: Record<string, unknown>;
21
+ /** The capability the step exercises, from `tool.capability`, with `resource` and `authority` read out
22
+ * of args. `authority` is the party whose mandate this step needs — the payer, the parent — when that
23
+ * is not the resource itself. */
24
+ capability: {
25
+ id: string;
26
+ action: string;
27
+ resource?: string;
28
+ authority?: string;
29
+ };
30
+ /** `tool-policy.StepRiskClass` — informational when the tool declares no capability. */
31
+ risk: StepRiskClass;
32
+ /** Present when the risk class demands one (medium+). Defaults to `${runRef}:${stepRef}`. */
33
+ idempotencyKey?: string;
34
+ }
35
+ export interface StepAuthorityRequest {
36
+ intent: Intent;
37
+ presented: MandatePresentation | null;
38
+ step: ResolvedStep;
39
+ /** Whether this check follows an approval. A verifier may not need to know; a receipt does. */
40
+ afterApproval: boolean;
41
+ }
42
+ /** An UNSATISFIED condition attached to the authority. Not a UI prompt. */
43
+ export interface Obligation {
44
+ kind: 'second-party-approval' | 'quorum' | 'fresh-authorization' | 'disclosure' | (string & {});
45
+ dischargeableBy: {
46
+ role?: string;
47
+ agents?: string[];
48
+ threshold?: number;
49
+ };
50
+ /** What imposed it, by reference — the caveat, the policy, the risk class. */
51
+ imposedBy: string;
52
+ }
53
+ export interface DecisionReason {
54
+ code: string;
55
+ message: string;
56
+ }
57
+ /** Inspectable evidence for the receipt. Shape mirrors `delegation.DecisionEvidence` so an adapter can
58
+ * pass it straight through. */
59
+ export interface DecisionEvidence {
60
+ mandateRef: string;
61
+ intentDigest: string;
62
+ evaluatedAt: number;
63
+ verdicts: Array<{
64
+ enforcer: string;
65
+ allowed: boolean;
66
+ reason?: string;
67
+ }>;
68
+ /** Spec 383 — the authority chain the leaf descends from, verified whole by the verifier (structural mirror
69
+ * of `delegation.AuthorityChainV1`): every grant by reference, leaf first; the accountability root; the
70
+ * acting agent. A receipt three hops away names each actor and grant from this, never from the last link. */
71
+ chain?: {
72
+ profile: string;
73
+ links: Array<{
74
+ ref: string;
75
+ delegator: string;
76
+ delegate: string;
77
+ parentRef: string | null;
78
+ }>;
79
+ accountabilityRoot: string;
80
+ actingAgent: string;
81
+ depth: number;
82
+ chainDigest: string;
83
+ };
84
+ }
85
+ export type MandateDecision = {
86
+ decision: 'allow';
87
+ obligations: Obligation[];
88
+ evidence: DecisionEvidence;
89
+ } | {
90
+ decision: 'approval-required';
91
+ obligations: Obligation[];
92
+ evidence: DecisionEvidence;
93
+ } | {
94
+ decision: 'deny';
95
+ reasons: DecisionReason[];
96
+ evidence: DecisionEvidence;
97
+ };
98
+ export interface MandateVerifier {
99
+ verify(req: StepAuthorityRequest): Promise<MandateDecision>;
100
+ }
101
+ /** Policy: WHAT RULES govern exercising authority the mandate grants. Distinct from the mandate (what was
102
+ * granted) and from approval (what remains unsatisfied). Returns obligations to ADD; it never removes one
103
+ * the verifier attached. */
104
+ export interface PolicyEvaluator {
105
+ evaluate(req: StepAuthorityRequest & {
106
+ decision: MandateDecision;
107
+ }): Promise<{
108
+ obligations: Obligation[];
109
+ }>;
110
+ }
111
+ export interface ApprovalRequest {
112
+ runRef: string;
113
+ stepRef: string;
114
+ intent: Intent;
115
+ step: ResolvedStep;
116
+ obligations: Obligation[];
117
+ /** The evidence the verifier produced — so the approver sees the EFFECTIVE authority, never a summary. */
118
+ evidence: DecisionEvidence;
119
+ }
120
+ export type ApprovalOutcome = {
121
+ status: 'discharged';
122
+ records: string[];
123
+ } | {
124
+ status: 'refused';
125
+ by?: string;
126
+ reason?: string;
127
+ } | {
128
+ status: 'pending';
129
+ resumeToken: string;
130
+ prompt?: import('./input.js').InputRequestV1;
131
+ };
132
+ /** Discharge obligations. A durable implementation checkpoints and returns `pending`; the run suspends and
133
+ * resumes later — through the verifier AGAIN, because an approval is an input to it, not a bypass. */
134
+ export interface ApprovalPort {
135
+ request(req: ApprovalRequest): Promise<ApprovalOutcome>;
136
+ }
137
+ export type StepReceiptStatus = 'authorized' | 'executed' | 'failed' | 'denied' | 'cancelled' | 'compensated' | 'suspended' | 'authority-required' | 'skipped';
138
+ /** The loop's record of one step. A sink turns it into signed evidence (`service-agent.ExecutionReceiptV2`,
139
+ * `verification-receipts`); the loop only guarantees the binding is complete. */
140
+ /**
141
+ * Spec 367 §5 — THE EXECUTION BINDING: what the operation was admitted AS, pinned onto its receipt so the
142
+ * executor cannot silently substitute a different organization, treasury, recipient or operation after
143
+ * admission. Evidence only (capability-architecture §8 invariant 13): no gate reads it.
144
+ */
145
+ export interface ExecutionBindingV1 {
146
+ /** keccak256 of the ExecutionIntent (goal + context) this step served. */
147
+ intentDigest: string;
148
+ /** The person the run acts for, and the role they act in when the harness knows it. */
149
+ principal?: string;
150
+ actingRole?: string;
151
+ /** The agent this step is ABOUT (the tool's `subject` argument, resolved), when it declares one. */
152
+ subject?: string;
153
+ /** The resource the capability acts on and whose authority it spends, read from the resolved args. */
154
+ resource?: string;
155
+ authority?: string;
156
+ /** The outcome class this step was expected to establish (`ToolSpec.establishes`). */
157
+ expectedOutcome: import('./types.js').OutcomeClass;
158
+ /** The stable logical operation identity — a retry must locate THIS, never perform it again (§8). */
159
+ operationId: string;
160
+ /** WHERE each bound party came from (spec 367 §3): the person's words, application context, a decision rule, memory, the resolver. */
161
+ argSources?: Record<string, 'said' | 'context' | 'standing' | 'decision' | 'memory' | 'resolver' | 'disclosed'>;
162
+ /** Spec 367 §8 — the causal chain across agents. `inResponseTo` on the receiver's receipt names the request
163
+ * it answered (R → S); `delegatedTo` on the sender's names the answer it got back (S → T). Never circular. */
164
+ correlation?: {
165
+ inResponseTo?: {
166
+ agent: string;
167
+ operationId: string;
168
+ runRef: string;
169
+ stepRef: string;
170
+ };
171
+ delegatedTo?: {
172
+ agent: string;
173
+ runRef: string;
174
+ };
175
+ };
176
+ /** Spec 383 (ADR-0052 roles) — WHO IS ACTING, FOR WHOM, and who started it: the actor context of this hop,
177
+ * so a receipt reads "alice's agent, for Missio Nexus, run at runtime-c3s0.svc". `rootPrincipal` is the
178
+ * person the run acts for; `originatingAgent` the agent that started the overall task (the requester of
179
+ * a routed step, else the principal's own agent); `actingAgent` the agent whose harness ran this hop.
180
+ * The accountability root — whose authority was spent — is the verified chain's root delegator, on the
181
+ * decision's evidence, never restated here. Evidence only; no gate reads it. */
182
+ /** Spec 383 W2 — the STANDING this hop ran under, as a named link: for whom (`subject`), by whom
183
+
184
+ * (`principal`), the relation the receiver derived, and — for a steward — the stewardship wire it verified,
185
+
186
+ * by digest. Evidence beside the mandate chain; no verifier reads it. */
187
+ standing?: {
188
+ relation: 'self' | 'steward' | 'member' | 'none';
189
+ subject: string;
190
+ principal: string;
191
+ because: string;
192
+ wireRef?: string;
193
+ };
194
+ actor?: {
195
+ rootPrincipal?: string;
196
+ originatingAgent?: string;
197
+ actingAgent: string;
198
+ };
199
+ }
200
+ export interface StepReceipt {
201
+ /** Spec 367 §5 — the admitted binding this step ran under. */
202
+ binding?: ExecutionBindingV1;
203
+ /** Spec 360 — what followed the act, per declared effect. `ok:false` is a disclosure that failed while
204
+ * the act stood: visible evidence, never a reason to unwind the step (the loop isolates the throw). */
205
+ effects?: Array<{
206
+ produces: string;
207
+ ok: boolean;
208
+ error?: string;
209
+ }>;
210
+ runRef: string;
211
+ stepRef: string;
212
+ index: number;
213
+ toolId: string;
214
+ capability?: {
215
+ id: string;
216
+ action: string;
217
+ resource?: string;
218
+ };
219
+ risk: ResolvedStep['risk'];
220
+ status: StepReceiptStatus;
221
+ /** From the verifier. Absent for informational steps (nothing was verified — and that is recorded). */
222
+ authority?: {
223
+ presentedRef: string | null;
224
+ decision: MandateDecision;
225
+ afterApproval: boolean;
226
+ };
227
+ /**
228
+ * Spec 363 W6 — WHAT THIS STEP DECIDED FOR THE PERSON, and on what basis.
229
+ *
230
+ * A receipt already says what authorized an act. It said nothing about the choices made on the way to
231
+ * it: which of six accounts paid, which Sarah was meant. Those were decided by rules over modelled
232
+ * facts, and a run that can be audited for its authority but not its DECISIONS is half-legible —
233
+ * "why did it pay from that one" was answerable only by re-deriving it and hoping nothing had changed.
234
+ *
235
+ * Display and audit only. No verifier reads it, and recording a decision grants nothing: the mandate
236
+ * still decided what may happen (spec 363 §2).
237
+ */
238
+ decisions?: Array<{
239
+ /** The decision point (`payment.sourceAccount`). */
240
+ point: string;
241
+ /** The rule that answered (`marked-primary-payer`). */
242
+ ruleId: string;
243
+ /** The argument it filled. */
244
+ arg: string;
245
+ /** What it chose. */
246
+ chose: string;
247
+ /** The rule's own words — never composed. */
248
+ because: string;
249
+ }>;
250
+ approvalRecords?: string[];
251
+ idempotencyKey?: string;
252
+ inputDigest?: string;
253
+ outputDigest?: string;
254
+ error?: string;
255
+ /** Spec 350 §3.4 — set when `status === 'suspended'` because the tool asked the person for something: the
256
+ * kind of prompt and, for a signature, what must be signed by whom. Never the answers. */
257
+ pendingInput?: {
258
+ kind: 'data' | 'signature' | 'confirmation' | 'commitment' | 'authority';
259
+ digest?: string;
260
+ signer?: string;
261
+ fields?: string[];
262
+ };
263
+ /** Spec 354 §4.5 — the playbook (skill/archetype) that shaped this step: canonical id + version +
264
+ * content commitment (the definition digest). Absent when the agent runs the bare harness (no
265
+ * archetype assigned). Names WHICH PROCEDURE the step followed — the behavior dimension of the
266
+ * receipt chain, verifiable against the corpus. Grants nothing; a playbook is never authority. */
267
+ skillRef?: {
268
+ skillId: string;
269
+ version: string;
270
+ commitment: string;
271
+ };
272
+ startedAt: number;
273
+ completedAt: number;
274
+ }
275
+ export interface ReceiptSink {
276
+ record(receipt: StepReceipt): Promise<void>;
277
+ }
278
+ /** Spec 390 W3 — every event carries WHEN (ms since the epoch), stamped by the loop as it emits, so the
279
+ * authority stages, the planner's call and the outcome can be projected as spans AFTER the fact from the
280
+ * record alone (no inline instrumentation). Optional on the type because records written before this
281
+ * wave carry none; a projection that needs two stamps and has one emits nothing for that stage. */
282
+ export type RunEventStamp = {
283
+ at?: number;
284
+ };
285
+ export type RunEvent = RunEventStamp & ({
286
+ type: 'RunStarted';
287
+ runRef: string;
288
+ intent: Intent;
289
+ presentedRef: string | null;
290
+ } | {
291
+ type: 'PlanCreated';
292
+ runRef: string;
293
+ steps: number;
294
+ rationale?: string;
295
+ }
296
+ /** Spec 367 W1 — admission refused the plan; `replanning` says whether one more plan will be tried. */
297
+ | {
298
+ type: 'PlanRefused';
299
+ runRef: string;
300
+ violations: Array<{
301
+ code: string;
302
+ message: string;
303
+ stepIndex?: number;
304
+ toolId?: string;
305
+ }>;
306
+ replanning: boolean;
307
+ } | {
308
+ type: 'StepProposed';
309
+ runRef: string;
310
+ stepRef: string;
311
+ toolId: string;
312
+ risk: ResolvedStep['risk'];
313
+ } | {
314
+ type: 'MandateChecked';
315
+ runRef: string;
316
+ stepRef: string;
317
+ decision: MandateDecision['decision'];
318
+ afterApproval: boolean;
319
+ } | {
320
+ type: 'MandateDenied';
321
+ runRef: string;
322
+ stepRef: string;
323
+ reasons: DecisionReason[];
324
+ } | {
325
+ type: 'ApprovalRequested';
326
+ runRef: string;
327
+ stepRef: string;
328
+ obligations: Obligation[];
329
+ } | {
330
+ type: 'ApprovalDischarged';
331
+ runRef: string;
332
+ stepRef: string;
333
+ records: string[];
334
+ } | {
335
+ type: 'ApprovalRefused';
336
+ runRef: string;
337
+ stepRef: string;
338
+ reason?: string;
339
+ } | {
340
+ type: 'RunSuspended';
341
+ runRef: string;
342
+ stepRef: string;
343
+ resumeToken: string;
344
+ } | {
345
+ type: 'ToolInvoked';
346
+ runRef: string;
347
+ stepRef: string;
348
+ toolId: string;
349
+ ok: boolean;
350
+ }
351
+ /** Spec 370 P1 — a completed step's recorded outcome stood in for running it again (a resume). */
352
+ | {
353
+ type: 'StepReplayed';
354
+ runRef: string;
355
+ stepRef: string;
356
+ toolId: string;
357
+ }
358
+ /** Spec 370 P3 — a declared branch was not taken: the step's `when` did not hold. */
359
+ | {
360
+ type: 'StepSkipped';
361
+ runRef: string;
362
+ stepRef: string;
363
+ toolId: string;
364
+ because: string;
365
+ } | {
366
+ type: 'StepCompensated';
367
+ runRef: string;
368
+ stepRef: string;
369
+ by: string;
370
+ ok: boolean;
371
+ } | {
372
+ type: 'ReceiptCreated';
373
+ runRef: string;
374
+ stepRef: string;
375
+ status: StepReceiptStatus;
376
+ }
377
+ /** Spec 360 — a declared effect could not be discharged. Its OWN fact: the step it followed stands. */
378
+ | {
379
+ type: 'EffectFailed';
380
+ runRef: string;
381
+ stepRef: string;
382
+ error: string;
383
+ } | {
384
+ type: 'RunCompleted';
385
+ runRef: string;
386
+ } | {
387
+ type: 'RunFailed';
388
+ runRef: string;
389
+ error: string;
390
+ });
391
+ export type RunEventSink = (event: RunEvent) => void;
392
+ /**
393
+ * WHAT FOLLOWS A SUCCESSFUL STEP — spec 360. The playbook DECLARES a consequence (a payment leaves a
394
+ * receipt the parties hold); this discharges it.
395
+ *
396
+ * The loop stays domain-free: it knows THAT a definition declared an effect and WHEN to discharge it. It
397
+ * does not know what a PaymentReceipt is, who a payee is, or where a record lives — the app binds that,
398
+ * exactly as it binds invokers.
399
+ *
400
+ * MAY NOT FAIL THE STEP. The act already happened, possibly on chain. A receipt that could un-do a
401
+ * payment would be worse than no receipt, so the loop isolates a throw here and records it as its own
402
+ * fact: the step stays `executed`, and the failure to disclose is reported separately.
403
+ */
404
+ export interface EffectSink {
405
+ discharge(e: {
406
+ runRef: string;
407
+ stepRef: string;
408
+ /** The effect as the definition declared it. Opaque to the loop beyond being passed through. */
409
+ effect: unknown;
410
+ step: ResolvedStep;
411
+ /** What the invoker returned — the receipt is built from THIS, never from model prose. */
412
+ result: unknown;
413
+ receipt: StepReceipt;
414
+ }): Promise<void>;
415
+ }
416
+ export interface OrchestrationPorts {
417
+ /** REQUIRED once any tool declares a capability. A run that reaches such a step without one fails closed. */
418
+ mandateVerifier?: MandateVerifier;
419
+ policyEvaluator?: PolicyEvaluator;
420
+ approvalPort?: ApprovalPort;
421
+ /** Every step emits a receipt; absent ⇒ receipts are kept on the RunResult only. */
422
+ receiptSink?: ReceiptSink;
423
+ /** Spec 360 — discharges a playbook's declared consequences after a step succeeds. Absent ⇒ declared
424
+ * effects are not discharged, and that is visible: the promise is in the definition either way. */
425
+ effectSink?: EffectSink;
426
+ /** Spec 367 W1 — judges the plan's SHAPE before any step runs (the verifier judges authority). Absent ⇒
427
+ * every well-formed plan is executed, which is the behaviour every run had before the port existed. */
428
+ planAdmission?: import('./admission.js').PlanAdmission;
429
+ events?: RunEventSink;
430
+ }
431
+ //# sourceMappingURL=authority.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"authority.d.ts","sour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E,MAAM,CAAC;QAChB,gGAAgG;QAChG,MAAM,EAAE,OAAO,CAAC;QAChB,IAAI,EAAE,YAAY,CAAC;QACnB,0FAA0F;QAC1F,MAAM,EAAE,OAAO,CAAC;QAChB,OAAO,EAAE,WAAW,CAAC;KACtB,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CACnB;AAED,MAAM,WAAW,kBAAkB;IACjC,6GAA6G;IAC7G,eAAe,CAAC,EAAE,eAAe,CAAC;IAClC,eAAe,CAAC,EAAE,eAAe,CAAC;IAClC,YAAY,CAAC,EAAE,YAAY,CAAC;IAC5B,oFAAoF;IACpF,WAAW,CAAC,EAAE,WAAW,CAAC;IAC1B;wGACoG;IACpG,UAAU,CAAC,EAAE,UAAU,CAAC;IACxB;4GACwG;IACxG,aAAa,CAAC,EAAE,OAAO,gBAAgB,EAAE,aAAa,CAAC;IACvD,MAAM,CAAC,EAAE,YAAY,CAAC;CACvB"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=authority.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"authority.js","sourceRoot":"","sources":["../src/authority.ts"],"names":[],"mappings":""}
@@ -0,0 +1,44 @@
1
+ type Hex = `0x${string}`;
2
+ /**
3
+ * A vendor-neutral view of a durable engine's step machinery. No `WorkflowStep`, no bindings, no DO
4
+ * storage APIs — a binding adapts one engine to this and nothing in Ring 0 knows which.
5
+ */
6
+ export interface DurableStepPort {
7
+ /** Persist-on-success execution of ONE WHOLE ATTEMPT. The name must be deterministic (the engine
8
+ * keys its checkpoint by it); the callback must be reconcile→verify→act, indivisible. */
9
+ attempt<T>(name: string, fn: () => Promise<T>): Promise<T>;
10
+ /** Durable suspension until a matching external event, or throw on timeout. The event carries an
11
+ * EVIDENCE REFERENCE ("relevant evidence may now be available") — never permission. */
12
+ waitForEvent<T>(name: string, opts: {
13
+ type: string;
14
+ timeoutMs: number;
15
+ }): Promise<T>;
16
+ /** Durable suspension until a wall-clock time. */
17
+ sleepUntil(name: string, at: Date): Promise<void>;
18
+ }
19
+ /**
20
+ * An authority DENIAL is not weather. Retrying a revocation as though it were an intermittent network
21
+ * error is the anti-pattern by name; a binding maps this to its engine's non-retry mechanism
22
+ * (Cloudflare `NonRetryableError`) or a terminal domain outcome. Only a NEW authorization decision —
23
+ * a fresh mandate, a discharged obligation — makes another attempt meaningful.
24
+ */
25
+ export declare class TerminalDenial extends Error {
26
+ readonly reason: 'denied' | 'revoked' | 'expired' | 'intent-mismatch';
27
+ constructor(message: string, reason?: 'denied' | 'revoked' | 'expired' | 'intent-mismatch');
28
+ }
29
+ /** ONE EXECUTOR PER RUN. The run record pins which engine advances it; the other entry path refuses.
30
+ * Never a fallback pair: "Workflows looked unavailable so the DO path started the same action" is two
31
+ * executors later advancing one operation. Migration is an explicit ownership transfer, not discovery. */
32
+ export type RunExecutor = 'client' | 'workflow';
33
+ /** What an approval event may carry: a REFERENCE to evidence the resume then verifies through the same
34
+ * ports as ever (ERC-1271, digest binding, deadline). Anything more — `{ approved: true }` — is a
35
+ * client-submitted assertion, and the resume must treat it as exactly that. */
36
+ export interface ApprovalEventV1 {
37
+ type: 'custodian-decision';
38
+ /** The approval record's digest/reference — located and VERIFIED on resume, never trusted. */
39
+ approvalRef: Hex | string;
40
+ /** Who claims to have decided. Display until verified. */
41
+ approver?: string;
42
+ }
43
+ export {};
44
+ //# sourceMappingURL=durable.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"durable.d.ts","sourceRoot":"","sources":["../src/durable.ts"],"names":[],"mappings":"AAiBA,KAAK,GAAG,GAAG,KAAK,MAAM,EAAE,CAAC;AAEzB;;;GAGG;AACH,MAAM,WAAW,eAAe;IAC9B;8FAC0F;IAC1F,OAAO,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC;IAC3D;4FACwF;IACxF,YAAY,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,SAAS,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC;IACrF,kDAAkD;IAClD,UAAU,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CACnD;AAED;;;;;GAKG;AACH,qBAAa,cAAe,SAAQ,KAAK;IACV,QAAQ,CAAC,MAAM,EAAE,QAAQ,GAAG,SAAS,GAAG,SAAS,GAAG,iBAAiB;gBAAtF,OAAO,EAAE,MAAM,EAAW,MAAM,GAAE,QAAQ,GAAG,SAAS,GAAG,SAAS,GAAG,iBAA4B;CAI9G;AAED;;2GAE2G;AAC3G,MAAM,MAAM,WAAW,GAAG,QAAQ,GAAG,UAAU,CAAC;AAEhD;;gFAEgF;AAChF,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,oBAAoB,CAAC;IAC3B,8FAA8F;IAC9F,WAAW,EAAE,GAAG,GAAG,MAAM,CAAC;IAC1B,0DAA0D;IAC1D,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB"}
@@ -0,0 +1,15 @@
1
+ /**
2
+ * An authority DENIAL is not weather. Retrying a revocation as though it were an intermittent network
3
+ * error is the anti-pattern by name; a binding maps this to its engine's non-retry mechanism
4
+ * (Cloudflare `NonRetryableError`) or a terminal domain outcome. Only a NEW authorization decision —
5
+ * a fresh mandate, a discharged obligation — makes another attempt meaningful.
6
+ */
7
+ export class TerminalDenial extends Error {
8
+ reason;
9
+ constructor(message, reason = 'denied') {
10
+ super(message);
11
+ this.reason = reason;
12
+ this.name = 'TerminalDenial';
13
+ }
14
+ }
15
+ //# sourceMappingURL=durable.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"durable.js","sourceRoot":"","sources":["../src/durable.ts"],"names":[],"mappings":"AAkCA;;;;;GAKG;AACH,MAAM,OAAO,cAAe,SAAQ,KAAK;IACD;IAAtC,YAAY,OAAe,EAAW,SAA+D,QAAQ;QAC3G,KAAK,CAAC,OAAO,CAAC,CAAC;QADqB,WAAM,GAAN,MAAM,CAAiE;QAE3G,IAAI,CAAC,IAAI,GAAG,gBAAgB,CAAC;IAC/B,CAAC;CACF"}
@@ -0,0 +1,105 @@
1
+ import type { RunEvent } from './authority.js';
2
+ export interface FlowStepV1 {
3
+ stepRef?: string;
4
+ toolId: string;
5
+ ok: boolean;
6
+ replayed?: boolean;
7
+ skipped?: string;
8
+ args?: Record<string, unknown>;
9
+ /** What the step returned, summarized: a catalog read's count/total/source, a refusal, an error. */
10
+ output?: Record<string, unknown>;
11
+ }
12
+ export interface FlowTraceV1 {
13
+ kind: 'ap.flow-trace.v1';
14
+ hop: 'agent';
15
+ flowId: string | null;
16
+ /** Spec 390 W2 — the W3C trace id this run's spans belong to (the caller's `traceparent`), or null when it derived its own. */
17
+ traceId?: string | null;
18
+ runRef: string;
19
+ agent: string;
20
+ asker: string;
21
+ playbook: {
22
+ archetypeId: string;
23
+ archetypeVersion: string;
24
+ digest: string;
25
+ } | null;
26
+ planner: {
27
+ kind: string;
28
+ model?: string;
29
+ toolsExposed: string[];
30
+ plan: Array<{
31
+ toolId: string;
32
+ args: Record<string, unknown>;
33
+ }>;
34
+ admission?: unknown[]; /** Spec 388 — which provider carried the planner and the composer, and why. */
35
+ route?: unknown;
36
+ } | null;
37
+ steps: FlowStepV1[];
38
+ reply: {
39
+ kind: string;
40
+ chars: number;
41
+ artifacts: string[];
42
+ };
43
+ /** Spec 387 W3 — how the caller found this agent: the registry and its receipt, as the caller said it. Evidence, never authority. */
44
+ referral?: ReferralV1;
45
+ /** Spec 387 W3 — this turn continued a parked run rather than starting one. */
46
+ continued?: boolean;
47
+ events: Array<{
48
+ type: string;
49
+ stepRef?: string;
50
+ toolId?: string;
51
+ ok?: boolean;
52
+ because?: string;
53
+ error?: string;
54
+ }>;
55
+ ms: number;
56
+ }
57
+ export interface ReferralV1 {
58
+ registry: string;
59
+ receipt?: string;
60
+ }
61
+ /** The caller's referral from the message metadata: which registry pointed it here and the receipt it cites — echoed as
62
+ * said (short strings only), verified by nobody here: how a caller found an agent grants nothing. */
63
+ export declare function referralOf(message: {
64
+ metadata?: Record<string, unknown>;
65
+ } | undefined): ReferralV1 | null;
66
+ /** The caller's flow id from the message metadata, or null — never a value we would not echo verbatim. */
67
+ export declare function flowIdOf(message: {
68
+ metadata?: Record<string, unknown>;
69
+ } | undefined): string | null;
70
+ /** A result's summary: numbers, flags and sources, never the rows (those are the `results` artifact's). */
71
+ export declare function summarizeOutput(result: unknown): Record<string, unknown> | undefined;
72
+ export declare function buildFlowTrace(input: {
73
+ flowId: string | null;
74
+ runRef: string;
75
+ agent: string;
76
+ asker: string;
77
+ startedAt: number;
78
+ reply: {
79
+ kind: string;
80
+ text?: string;
81
+ plannerTrace?: {
82
+ planner?: string;
83
+ model?: string;
84
+ toolsExposed?: string[];
85
+ plan?: Array<{
86
+ toolId: string;
87
+ args: Record<string, unknown>;
88
+ }>;
89
+ playbook?: FlowTraceV1['playbook'];
90
+ admission?: unknown[];
91
+ route?: unknown;
92
+ };
93
+ results?: Array<{
94
+ toolId: string;
95
+ result: unknown;
96
+ }>;
97
+ };
98
+ events?: RunEvent[];
99
+ artifacts: string[];
100
+ referral?: ReferralV1;
101
+ continued?: boolean;
102
+ /** Spec 390 W2 — the W3C trace id the request arrived with (the caller's), when one did. Correlation only. */
103
+ traceId?: string | null;
104
+ }): FlowTraceV1;
105
+ //# sourceMappingURL=flow-trace.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"flow-trace.d.ts","sourceRoot":"","sources":["../src/flow-trace.ts"],"names":[],"mappings":"AAYA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC/C,MAAM,WAAW,UAAU;IACzB,OAAO,CAAC,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAC;IAAC,EAAE,EAAE,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