@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.
- package/dist/admission.d.ts +87 -0
- package/dist/admission.d.ts.map +1 -0
- package/dist/admission.js +193 -0
- package/dist/admission.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 +431 -0
- package/dist/authority.d.ts.map +1 -0
- package/dist/authority.js +2 -0
- package/dist/authority.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/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 +20 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +21 -1
- 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/loop.d.ts +115 -3
- package/dist/loop.d.ts.map +1 -1
- package/dist/loop.js +656 -30
- 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/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 +33 -0
- package/dist/planner.d.ts.map +1 -1
- package/dist/planner.js.map +1 -1
- package/dist/record.d.ts +151 -0
- package/dist/record.d.ts.map +1 -0
- package/dist/record.js +72 -0
- package/dist/record.js.map +1 -0
- package/dist/spans.d.ts +200 -0
- package/dist/spans.d.ts.map +1 -0
- package/dist/spans.js +522 -0
- package/dist/spans.js.map +1 -0
- package/dist/tool-invoker.d.ts +7 -0
- package/dist/tool-invoker.d.ts.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/types.d.ts +180 -3
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js.map +1 -1
- package/package.json +4 -1
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
const FLOW_ID = /^[A-Za-z0-9_.:-]{4,64}$/;
|
|
2
|
+
/** The caller's referral from the message metadata: which registry pointed it here and the receipt it cites — echoed as
|
|
3
|
+
* said (short strings only), verified by nobody here: how a caller found an agent grants nothing. */
|
|
4
|
+
export function referralOf(message) {
|
|
5
|
+
const r = message?.metadata?.referral;
|
|
6
|
+
if (!r || typeof r.registry !== 'string' || !r.registry || r.registry.length > 200)
|
|
7
|
+
return null;
|
|
8
|
+
return { registry: r.registry, ...(typeof r.receipt === 'string' && r.receipt && r.receipt.length <= 400 ? { receipt: r.receipt } : {}) };
|
|
9
|
+
}
|
|
10
|
+
/** The caller's flow id from the message metadata, or null — never a value we would not echo verbatim. */
|
|
11
|
+
export function flowIdOf(message) {
|
|
12
|
+
const v = message?.metadata?.flowId;
|
|
13
|
+
return typeof v === 'string' && FLOW_ID.test(v) ? v : null;
|
|
14
|
+
}
|
|
15
|
+
/** A result's summary: numbers, flags and sources, never the rows (those are the `results` artifact's). */
|
|
16
|
+
export function summarizeOutput(result) {
|
|
17
|
+
if (!result || typeof result !== 'object')
|
|
18
|
+
return typeof result === 'string' ? { text: result.slice(0, 200) } : undefined;
|
|
19
|
+
const r = result;
|
|
20
|
+
const out = {};
|
|
21
|
+
for (const k of ['count', 'total', 'found', 'error', 'refused', 'source', 'interpretation', 'filters', 'types'])
|
|
22
|
+
if (r[k] !== undefined)
|
|
23
|
+
out[k] = r[k];
|
|
24
|
+
for (const k of ['resources', 'topics', 'members', 'agents', 'rows', 'items'])
|
|
25
|
+
if (Array.isArray(r[k]))
|
|
26
|
+
out[`${k}Count`] = r[k].length;
|
|
27
|
+
if (typeof out.interpretation === 'string')
|
|
28
|
+
out.interpretation = out.interpretation.slice(0, 240);
|
|
29
|
+
return Object.keys(out).length ? out : { keys: Object.keys(r).slice(0, 12) };
|
|
30
|
+
}
|
|
31
|
+
export function buildFlowTrace(input) {
|
|
32
|
+
const events = input.events ?? [];
|
|
33
|
+
const byTool = new Map();
|
|
34
|
+
for (const r of input.reply.results ?? [])
|
|
35
|
+
byTool.set(r.toolId, r.result);
|
|
36
|
+
const planArgs = new Map();
|
|
37
|
+
for (const p of input.reply.plannerTrace?.plan ?? [])
|
|
38
|
+
planArgs.set(p.toolId, p.args);
|
|
39
|
+
const steps = [];
|
|
40
|
+
for (const e of events) {
|
|
41
|
+
if (e.type === 'ToolInvoked')
|
|
42
|
+
steps.push({ stepRef: e.stepRef, toolId: e.toolId, ok: e.ok, ...(planArgs.has(e.toolId) ? { args: planArgs.get(e.toolId) } : {}), ...(byTool.has(e.toolId) ? { output: summarizeOutput(byTool.get(e.toolId)) } : {}) });
|
|
43
|
+
else if (e.type === 'StepReplayed')
|
|
44
|
+
steps.push({ stepRef: e.stepRef, toolId: e.toolId, ok: true, replayed: true });
|
|
45
|
+
else if (e.type === 'StepSkipped')
|
|
46
|
+
steps.push({ stepRef: e.stepRef, toolId: e.toolId, ok: true, skipped: e.because });
|
|
47
|
+
}
|
|
48
|
+
const pt = input.reply.plannerTrace;
|
|
49
|
+
return {
|
|
50
|
+
kind: 'ap.flow-trace.v1', hop: 'agent', flowId: input.flowId, traceId: input.traceId ?? null, runRef: input.runRef, agent: input.agent, asker: input.asker,
|
|
51
|
+
playbook: pt?.playbook ?? null,
|
|
52
|
+
planner: pt ? { kind: pt.planner ?? 'unknown', ...(pt.model ? { model: pt.model } : {}), toolsExposed: pt.toolsExposed ?? [], plan: pt.plan ?? [], ...(pt.admission?.length ? { admission: pt.admission } : {}), ...(pt.route ? { route: pt.route } : {}) } : null,
|
|
53
|
+
steps,
|
|
54
|
+
reply: { kind: input.reply.kind, chars: (input.reply.text ?? '').length, artifacts: input.artifacts },
|
|
55
|
+
...(input.referral ? { referral: input.referral } : {}), ...(input.continued ? { continued: true } : {}),
|
|
56
|
+
events: events.map((e) => ({ type: e.type, ...('stepRef' in e ? { stepRef: e.stepRef } : {}), ...('toolId' in e ? { toolId: e.toolId } : {}), ...('ok' in e ? { ok: e.ok } : {}), ...('because' in e ? { because: e.because } : {}), ...('error' in e ? { error: e.error } : {}) })),
|
|
57
|
+
ms: Date.now() - input.startedAt,
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
//# sourceMappingURL=flow-trace.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"flow-trace.js","sourceRoot":"","sources":["../src/flow-trace.ts"],"names":[],"mappings":"AAwCA,MAAM,OAAO,GAAG,yBAAyB,CAAC;AAE1C;sGACsG;AACtG,MAAM,UAAU,UAAU,CAAC,OAA2D;IACpF,MAAM,CAAC,GAAG,OAAO,EAAE,QAAQ,EAAE,QAAiE,CAAC;IAC/F,IAAI,CAAC,CAAC,IAAI,OAAO,CAAC,CAAC,QAAQ,KAAK,QAAQ,IAAI,CAAC,CAAC,CAAC,QAAQ,IAAI,CAAC,CAAC,QAAQ,CAAC,MAAM,GAAG,GAAG;QAAE,OAAO,IAAI,CAAC;IAChG,OAAO,EAAE,QAAQ,EAAE,CAAC,CAAC,QAAQ,EAAE,GAAG,CAAC,OAAO,CAAC,CAAC,OAAO,KAAK,QAAQ,IAAI,CAAC,CAAC,OAAO,IAAI,CAAC,CAAC,OAAO,CAAC,MAAM,IAAI,GAAG,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC;AAC5I,CAAC;AACD,0GAA0G;AAC1G,MAAM,U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G,CAAC,IAAI,IAAI,CAAC,CAAC,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,GAAG,CAAC,SAAS,IAAI,CAAC,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,GAAG,CAAC,OAAO,IAAI,CAAC,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC;QACpR,EAAE,EAAE,IAAI,CAAC,GAAG,EAAE,GAAG,KAAK,CAAC,SAAS;KACjC,CAAC;AACJ,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,8 +1,27 @@
|
|
|
1
1
|
export { PACKAGE_NAME, PACKAGE_STATUS, SPEC_REF, OrchestrationError } from './types.js';
|
|
2
2
|
export type { Intent, ToolSpec, PlanStep, Plan, StepObservation, RunOutcome, RunResult, OrchestrationErrorCode, } from './types.js';
|
|
3
3
|
export { createRuleBasedPlanner } from './planner.js';
|
|
4
|
-
export type { Planner, PlanInput, PlanRule } from './planner.js';
|
|
4
|
+
export type { Planner, PlanInput, PlanRule, AnswerComposer, ComposeInput } from './planner.js';
|
|
5
|
+
export { wireNameFor, toolNameMap, planStepFromToolArgs } from './planner-wire.js';
|
|
5
6
|
export type { ToolInvoker, InvokeContext } from './tool-invoker.js';
|
|
6
7
|
export { runIntent } from './loop.js';
|
|
8
|
+
export { planAdmission, externalExecutorsReadOnly, instructionNeedsAct, noPlaceholders, subjectNamedInAsk, dependenciesProvided, branchesDecidable, questionAnsweredByRead, capabilitiesAvailable, outcomeClassOf, squash as squashLabel } from './admission.js';
|
|
9
|
+
export type { PlanAdmission, AdmissionRule, AdmissionVerdict, AdmissionViolation, AdmissionInput, AdmissionCode } from './admission.js';
|
|
10
|
+
export type { ExecutionBindingV1 } from './authority.js';
|
|
11
|
+
export type { OutcomeClass } from './types.js';
|
|
7
12
|
export type { RunIntentOpts } from './loop.js';
|
|
13
|
+
export type { MandatePresentation, ResolvedStep, StepAuthorityRequest, Obligation, EffectSink, DecisionReason, DecisionEvidence, MandateDecision, MandateVerifier, PolicyEvaluator, ApprovalRequest, ApprovalOutcome, ApprovalPort, StepReceiptStatus, StepReceipt, ReceiptSink, RunEvent, RunEventStamp, RunEventSink, OrchestrationPorts, } from './authority.js';
|
|
14
|
+
export { InputRequired, isInputRequired, inputsFor, dataFor, signatureFor, receiptPending } from './input.js';
|
|
15
|
+
export type { InputRequestV1, InputFieldV1, InputFieldType, SuppliedInputV1, CommitmentRefV1 } from './input.js';
|
|
16
|
+
export { TerminalDenial, type DurableStepPort, type RunExecutor, type ApprovalEventV1 } from './durable.js';
|
|
17
|
+
export { recordOf, replayingInvoker, replayRun } from './record.js';
|
|
18
|
+
export type { RunRecordV1, RunPlannerSummaryV1, RunExportReportV1, ReplayReport, ReplayVerdict, RunBillV1 } from './record.js';
|
|
19
|
+
export { spansOf, assertFirewalled, otlpTracesOf, receiptDigest, provenanceOf, runProvenanceRecordKey, SPAN_ATTRIBUTE_ALLOWLIST, RUN_PROVENANCE_RECORD_PREFIX, provIds, traceIdOf, spanIdOf, PROV_ID_BASE, stageSpansOf, assertMetricsFirewalled } from './spans.js';
|
|
20
|
+
export { metricsOf, otlpMetricsOf, STEP_DURATION_BOUNDS_MS, type RunMetricsV1, type CounterPointV1, type HistogramPointV1, type MetricAttributes } from './metrics.js';
|
|
21
|
+
export type { SpanV1, RunProvenanceV1 } from './spans.js';
|
|
22
|
+
export { traceIdFor } from './spans.js';
|
|
23
|
+
export { parseTraceparent, formatTraceparent, withTracestateMember, tracestateMember, traceContextOf, type TraceContextV1 } from './trace-context.js';
|
|
24
|
+
export { ARTIFACT_REF_TYPE, OFFLOAD_THRESHOLD_CHARS, SUMMARY_MAX_CHARS, RUN_ARTIFACT_RECORD_PREFIX, runArtifactRecordKey, isArtifactRef, canonicalJson, summarizeResult, offloadObservations, offloadRunResult, refsReachedBy, rehydrateObservations, fitEvidence, compactObservations, resultFactsOf, RETAINED_RESULT_KEYS, type ArtifactRefV1, type RunArtifactRecordV1, type ArtifactStore, type OffloadReport, type EvidenceItemV1, type FittedEvidenceV1 } from './artifacts.js';
|
|
25
|
+
export { buildFlowTrace, flowIdOf, referralOf, summarizeOutput } from './flow-trace.js';
|
|
26
|
+
export type { FlowTraceV1, FlowStepV1, ReferralV1 } from './flow-trace.js';
|
|
8
27
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,YAAY,EAAE,cAAc,EAAE,QAAQ,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AACxF,YAAY,EACV,MAAM,EACN,QAAQ,EACR,QAAQ,EACR,IAAI,EACJ,eAAe,EACf,UAAU,EACV,SAAS,EACT,sBAAsB,GACvB,MAAM,YAAY,CAAC;AAEpB,OAAO,EAAE,sBAAsB,EAAE,MAAM,cAAc,CAAC;AACtD,YAAY,EAAE,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAE/F,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,oBAAoB,EAAE,MAAM,mBAAmB,CAAC;AAEnF,YAAY,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAEpE,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AACtC,OAAO,EAAE,aAAa,EAAE,yBAAyB,EAAE,mBAAmB,EAAE,cAAc,EAAE,iBAAiB,EAAE,oBAAoB,EAAE,iBAAiB,EAAE,sBAA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EAAE,4BAA4B,EAAE,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,YAAY,EAAE,YAAY,EAAE,uBAAuB,EAAE,MAAM,YAAY,CAAC;AAErQ,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,uBAAuB,EAAE,KAAK,YAAY,EAAE,KAAK,cAAc,EAAE,KAAK,gBAAgB,EAAE,KAAK,gBAAgB,EAAE,MAAM,cAAc,CAAC;AACvK,YAAY,EAAE,MAAM,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAC1D,OAAO,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAExC,OAAO,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,oBAAoB,EAAE,gBAAgB,EAAE,cAAc,EAAE,KAAK,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAEtJ,OAAO,EAAE,iBAAiB,EAAE,uBAAuB,EAAE,iBAAiB,EAAE,0BAA0B,EAAE,oBAAoB,EAAE,aAAa,EAAE,aAAa,EAAE,eAAe,EAAE,mBAAmB,EAAE,gBAAgB,EAAE,aAAa,EAAE,qBAAqB,EAAE,WAAW,EAAE,mBAAmB,EAAE,aAAa,EAAE,oBAAoB,EAAE,KAAK,aAAa,EAAE,KAAK,mBAAmB,EAAE,KAAK,aAAa,EAAE,KAAK,aAAa,EAAE,KAAK,cAAc,EAAE,KAAK,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAEtd,OAAO,EAAE,cAAc,EAAE,QAAQ,EAAE,UAAU,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AACxF,YAAY,EAAE,WAAW,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,7 +1,27 @@
|
|
|
1
1
|
// @agenticprimitives/orchestration — public API. The Ring-0 agentic loop: the intent→plan→execute→observe
|
|
2
2
|
// model, the Planner + ToolInvoker PORTS, and `runIntent`. Pure leaf — no transport, no LLM SDK, no chain.
|
|
3
|
-
// The LLM
|
|
3
|
+
// The LLM bindings live in sibling adapters behind the Planner port (`orchestration-anthropic`,
|
|
4
|
+
// `orchestration-openai-compat`). ADR-0044, spec 377.
|
|
4
5
|
export { PACKAGE_NAME, PACKAGE_STATUS, SPEC_REF, OrchestrationError } from './types.js';
|
|
5
6
|
export { createRuleBasedPlanner } from './planner.js';
|
|
7
|
+
// Spec 377 §2 — the plan-shape convention on a vendor's wire, shared by every LLM adapter.
|
|
8
|
+
export { wireNameFor, toolNameMap, planStepFromToolArgs } from './planner-wire.js';
|
|
6
9
|
export { runIntent } from './loop.js';
|
|
10
|
+
export { planAdmission, externalExecutorsReadOnly, instructionNeedsAct, noPlaceholders, subjectNamedInAsk, dependenciesProvided, branchesDecidable, questionAnsweredByRead, capabilitiesAvailable, outcomeClassOf, squash as squashLabel } from './admission.js';
|
|
11
|
+
// Spec 350 §3.4 — a tool may ask the person for what it lacks; the run suspends with the prompt.
|
|
12
|
+
export { InputRequired, isInputRequired, inputsFor, dataFor, signatureFor, receiptPending } from './input.js';
|
|
13
|
+
export { TerminalDenial } from './durable.js';
|
|
14
|
+
// Spec 370 P6 — the run record and its replay (verdicts re-derived, tools never re-run).
|
|
15
|
+
export { recordOf, replayingInvoker, replayRun } from './record.js';
|
|
16
|
+
// Spec 381 — the run, exported: firewalled spans + the durable half for the vault. Pure projections of a record.
|
|
17
|
+
export { spansOf, assertFirewalled, otlpTracesOf, receiptDigest, provenanceOf, runProvenanceRecordKey, SPAN_ATTRIBUTE_ALLOWLIST, RUN_PROVENANCE_RECORD_PREFIX, provIds, traceIdOf, spanIdOf, PROV_ID_BASE, stageSpansOf, assertMetricsFirewalled } from './spans.js';
|
|
18
|
+
// Spec 390 W4 — the run as metrics: four instruments from one record, the OTLP metrics body beside the traces body.
|
|
19
|
+
export { metricsOf, otlpMetricsOf, STEP_DURATION_BOUNDS_MS } from './metrics.js';
|
|
20
|
+
export { traceIdFor } from './spans.js';
|
|
21
|
+
// Spec 390 W2 — W3C Trace Context on the wire: parse, format, tracestate members. Correlation, never trust.
|
|
22
|
+
export { parseTraceparent, formatTraceparent, withTracestateMember, tracestateMember, traceContextOf } from './trace-context.js';
|
|
23
|
+
// Spec 391 — offloaded artifacts and fitted evidence: what outlives a turn is a reference; nothing is cut silently.
|
|
24
|
+
export { ARTIFACT_REF_TYPE, OFFLOAD_THRESHOLD_CHARS, SUMMARY_MAX_CHARS, RUN_ARTIFACT_RECORD_PREFIX, runArtifactRecordKey, isArtifactRef, canonicalJson, summarizeResult, offloadObservations, offloadRunResult, refsReachedBy, rehydrateObservations, fitEvidence, compactObservations, resultFactsOf, RETAINED_RESULT_KEYS } from './artifacts.js';
|
|
25
|
+
// Spec 387 W2 / spec 399 §4 — the flow trace: a run's story on its task, folded from RunEvents + the planner summary. Evidence, never authority.
|
|
26
|
+
export { buildFlowTrace, flowIdOf, referralOf, summarizeOutput } from './flow-trace.js';
|
|
7
27
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,0GAA0G;AAC1G,2GAA2G;AAC3G,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,0GAA0G;AAC1G,2GAA2G;AAC3G,gGAAgG;AAChG,sDAAsD;AAEtD,OAAO,EAAE,YAAY,EAAE,cAAc,EAAE,QAAQ,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAYxF,OAAO,EAAE,sBAAsB,EAAE,MAAM,cAAc,CAAC;AAEtD,2FAA2F;AAC3F,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,oBAAoB,EAAE,MAAM,mBAAmB,CAAC;AAInF,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AACtC,OAAO,EAAE,aAAa,EAAE,yBAAyB,EAAE,mBAAmB,EAAE,cAAc,EAAE,iBAAiB,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eAAe,EAAE,MAAM,iBAAiB,CAAC"}
|
package/dist/input.d.ts
ADDED
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
import type { StepReceipt } from './authority.js';
|
|
2
|
+
export type InputFieldType = 'text' | 'address' | 'number' | 'boolean' | 'choice' | 'credential';
|
|
3
|
+
export interface InputFieldV1 {
|
|
4
|
+
name: string;
|
|
5
|
+
label: string;
|
|
6
|
+
type: InputFieldType;
|
|
7
|
+
required?: boolean;
|
|
8
|
+
/** For `choice`. `hint` is what a person needs to tell two candidates APART — a label alone
|
|
9
|
+
* ("Nathan") is not a choice, it is the same word four times. */
|
|
10
|
+
choices?: Array<{
|
|
11
|
+
value: string;
|
|
12
|
+
label: string;
|
|
13
|
+
hint?: string;
|
|
14
|
+
}>;
|
|
15
|
+
/** For `choice`: the listed candidates are not the only possible answers, so the surface MUST also let
|
|
16
|
+
* the person type one. Set whenever the question itself admits that what they want may not be listed —
|
|
17
|
+
* a prompt saying "give it in full" beside a radio list with no text box is a dead end with
|
|
18
|
+
* instructions. */
|
|
19
|
+
allowOther?: boolean;
|
|
20
|
+
/** For `text`: a regular-expression source the surface may validate against before submitting. */
|
|
21
|
+
pattern?: string;
|
|
22
|
+
hint?: string;
|
|
23
|
+
}
|
|
24
|
+
/** A follow-up the surface may offer when a question has no good answer among what is on hand — "ask
|
|
25
|
+
* them for a way to reach it". The surface PREFILLS it; it never sends it. A question that leads
|
|
26
|
+
* nowhere is a dead end, and the way out is usually another ask the person did not know to phrase. */
|
|
27
|
+
export interface InputSuggestionV1 {
|
|
28
|
+
label: string;
|
|
29
|
+
/** The ask to prefill, in the person's own voice. */
|
|
30
|
+
message: string;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Spec 374 — WHAT ANOTHER AGENT OWES THIS RUN. A step whose subject is another agent was sent there (spec
|
|
34
|
+
* 366); that agent could not finish it for this asker and parked it for its own steward. This run holds
|
|
35
|
+
* the record — a `Commitment` in spec 340's sense: debtor, creditor, content, conditions, its own
|
|
36
|
+
* lifecycle — and waits. Evidence of where the act stands; never authority for it: no gate reads it.
|
|
37
|
+
*/
|
|
38
|
+
export interface CommitmentRefV1 {
|
|
39
|
+
/** The debtor's operation identity for this request — the correlation the answer will name. */
|
|
40
|
+
id: string;
|
|
41
|
+
/** Who owes the act (the subject's agent). */
|
|
42
|
+
debtor: string;
|
|
43
|
+
/** Who is owed it (the asker's agent). */
|
|
44
|
+
creditor: string;
|
|
45
|
+
content: {
|
|
46
|
+
capability: string;
|
|
47
|
+
args: Record<string, unknown>;
|
|
48
|
+
goal: string;
|
|
49
|
+
};
|
|
50
|
+
/** In words: "a steward of missio-nexus.org finishes it". */
|
|
51
|
+
conditions: string;
|
|
52
|
+
/** Spec 340 `CommitmentState`, the four this record can observe. `proposed` = asked and parked. */
|
|
53
|
+
state: 'proposed' | 'active' | 'discharged' | 'void';
|
|
54
|
+
/** The debtor's run, where the act actually waits. */
|
|
55
|
+
at: {
|
|
56
|
+
agent: string;
|
|
57
|
+
name?: string;
|
|
58
|
+
runRef: string;
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
export type InputRequestV1 = {
|
|
62
|
+
kind: 'data';
|
|
63
|
+
stepRef: string;
|
|
64
|
+
toolId: string;
|
|
65
|
+
prompt: string;
|
|
66
|
+
fields: InputFieldV1[];
|
|
67
|
+
suggest?: InputSuggestionV1;
|
|
68
|
+
/** Spec 385 — when this is an AMBIGUITY choice, the scope the answer confirms (word + capability + arg),
|
|
69
|
+
* so the trusted resume that supplies it can be remembered as a scoped preference. Display/memory only. */
|
|
70
|
+
scope?: {
|
|
71
|
+
word: string;
|
|
72
|
+
capability: string;
|
|
73
|
+
arg: string;
|
|
74
|
+
};
|
|
75
|
+
/** Spec 397 — the question is ANOTHER agent's (a routed step's target asked it): where it waits, and the step
|
|
76
|
+
* there the answer is for. The resume continues THAT run with the answer; this run only relays. */
|
|
77
|
+
at?: {
|
|
78
|
+
agent: string;
|
|
79
|
+
name?: string;
|
|
80
|
+
runRef: string;
|
|
81
|
+
stepRef?: string;
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
/** Spec 374 — the run waits on another agent's steward; only the debtor's answer resumes it. */
|
|
85
|
+
| {
|
|
86
|
+
kind: 'commitment';
|
|
87
|
+
stepRef: string;
|
|
88
|
+
toolId: string;
|
|
89
|
+
prompt: string;
|
|
90
|
+
commitment: CommitmentRefV1;
|
|
91
|
+
}
|
|
92
|
+
/** Spec 374 W2 — THE SUBJECT'S AUTHORITY REQUEST, RELAYED: the step was routed to another agent, which
|
|
93
|
+
* asked for a mandate the ASKER can grant (they steward it). The asker's surface mints it exactly as it
|
|
94
|
+
* would for a local step; on resume the mandate travels to the subject's parked run. `authority` is
|
|
95
|
+
* the receiver's own request, carried whole; `at` is where the step waits. */
|
|
96
|
+
| {
|
|
97
|
+
kind: 'authority';
|
|
98
|
+
stepRef: string;
|
|
99
|
+
toolId: string;
|
|
100
|
+
prompt: string;
|
|
101
|
+
authority: Record<string, unknown>;
|
|
102
|
+
at: {
|
|
103
|
+
agent: string;
|
|
104
|
+
name?: string;
|
|
105
|
+
runRef: string;
|
|
106
|
+
};
|
|
107
|
+
} | {
|
|
108
|
+
kind: 'signature';
|
|
109
|
+
stepRef: string;
|
|
110
|
+
toolId: string;
|
|
111
|
+
prompt: string;
|
|
112
|
+
/** The digest to sign, and who must sign it (the connected credential's address, or the SA it custodies). */
|
|
113
|
+
digest: string;
|
|
114
|
+
signer: string;
|
|
115
|
+
/** What is being signed, in the open — the surface shows it; the tool re-derives it on resume. */
|
|
116
|
+
payload?: unknown;
|
|
117
|
+
} | {
|
|
118
|
+
kind: 'confirmation';
|
|
119
|
+
stepRef: string;
|
|
120
|
+
toolId: string;
|
|
121
|
+
prompt: string;
|
|
122
|
+
summary: unknown;
|
|
123
|
+
};
|
|
124
|
+
/** What comes back. Keyed by the step that asked; a tool reads its own via `inputsFor`. */
|
|
125
|
+
export interface SuppliedInputV1 {
|
|
126
|
+
stepRef: string;
|
|
127
|
+
/** Answers to a `data` request, by field name. A `credential` field's value is the surface's own
|
|
128
|
+
* description of the connected credential, in whatever shape the tool documented. */
|
|
129
|
+
data?: Record<string, unknown>;
|
|
130
|
+
/** The answer to a `signature` request. `payload` echoes what was signed when the tool needs it back. */
|
|
131
|
+
signature?: {
|
|
132
|
+
digest: string;
|
|
133
|
+
signer: string;
|
|
134
|
+
signature: string;
|
|
135
|
+
payload?: unknown;
|
|
136
|
+
};
|
|
137
|
+
/** The answer to a `confirmation` request. */
|
|
138
|
+
confirmed?: boolean;
|
|
139
|
+
/** Spec 374 — the answer to a `commitment` request: what the debtor's agent delivered when its parked
|
|
140
|
+
* run finished. `outcome` is the debtor's word; `result` is the step's result when it answered. */
|
|
141
|
+
delivered?: {
|
|
142
|
+
outcome: 'answer' | 'refused' | 'error';
|
|
143
|
+
result?: unknown;
|
|
144
|
+
said?: string;
|
|
145
|
+
receipts?: unknown[];
|
|
146
|
+
runRef?: string;
|
|
147
|
+
};
|
|
148
|
+
}
|
|
149
|
+
/** Thrown by a tool invoker to suspend the run with a prompt. The loop recognises this class and ONLY this
|
|
150
|
+
* class — any other throw is a step failure. */
|
|
151
|
+
export declare class InputRequired extends Error {
|
|
152
|
+
readonly request: InputRequestV1;
|
|
153
|
+
constructor(request: InputRequestV1);
|
|
154
|
+
}
|
|
155
|
+
export declare function isInputRequired(e: unknown): e is InputRequired;
|
|
156
|
+
/** The inputs supplied for one step (a resume may answer several steps at once). */
|
|
157
|
+
export declare function inputsFor(supplied: readonly SuppliedInputV1[] | undefined, stepRef: string): SuppliedInputV1[];
|
|
158
|
+
/** The merged `data` answers for a step (later entries win). */
|
|
159
|
+
export declare function dataFor(supplied: readonly SuppliedInputV1[] | undefined, stepRef: string): Record<string, unknown>;
|
|
160
|
+
/** The supplied signature over `digest` for a step, if any. Case-insensitive on the digest. */
|
|
161
|
+
export declare function signatureFor(supplied: readonly SuppliedInputV1[] | undefined, stepRef: string, digest?: string): SuppliedInputV1['signature'] | undefined;
|
|
162
|
+
/** What a `suspended` receipt carries about the prompt — the kind and, for a signature, the digest; never
|
|
163
|
+
* the answers (those are the person's, and they arrive on the resume). */
|
|
164
|
+
export declare function receiptPending(req: InputRequestV1): NonNullable<StepReceipt['pendingInput']>;
|
|
165
|
+
//# sourceMappingURL=input.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"input.d.ts","sourceRoot":"","sources":["../src/input.ts"],"names":[],"mappings":"AAyBA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAElD,MAAM,MAAM,cAAc,GAAG,MAAM,GAAG,SAAS,GAAG,QAAQ,GAAG,SAAS,GAAG,QAAQ,GAAG,YAAY,CAAC;AAEjG,MAAM,WAAW,YAAY;IAC3B,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,cAAc,CAAC;IACrB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB;sEACkE;IAClE,OAAO,CAAC,EAAE,KAAK,CAAC;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAC;QAAC,IAAI,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IACjE;;;wBAGoB;IACpB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,kGAAkG;IAClG,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED;;uGAEuG;AACvG,MAAM,WAAW,iBAAiB;IAChC,KAAK,EAAE,MAAM,CAAC;IACd,qDAAqD;IACrD,OAAO,EAAE,MAAM,CAAC;CACjB;AAED;;;;;GAKG;AACH,MAAM,WAAW,eAAe;IAC9B,+FAA+F;IAC/F,EAAE,EAAE,MAAM,CAAC;IACX,8CAA8C;IAC9C,MAAM,EAAE,MAAM,CAAC;IACf,0CAA0C;IAC1C,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE;QAAE,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OAAO,EAAE,CAAC;QAAC,MAAM,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;CACjI;AAED;iDACiD;AACjD,qBAAa,aAAc,SAAQ,KAAK;IACtC,QAAQ,CAAC,OAAO,EAAE,cAAc,CAAC;gBACrB,OAAO,EAAE,cAAc;CAKpC;AAED,wBAAgB,eAAe,CAAC,CAAC,EAAE,OAAO,GAAG,CAAC,IAAI,aAAa,CAE9D;AAED,oFAAoF;AACpF,wBAAgB,SAAS,CAAC,QAAQ,EAAE,SAAS,eAAe,EAAE,GAAG,SAAS,EAAE,OAAO,EAAE,MAAM,GAAG,eAAe,EAAE,CAE9G;AAED,gEAAgE;AAChE,wBAAgB,OAAO,CAAC,QAAQ,EAAE,SAAS,eAAe,EAAE,GAAG,SAAS,EAAE,OAAO,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAElH;AAED,+FAA+F;AAC/F,wBAAgB,YAAY,CAAC,QAAQ,EAAE,SAAS,eAAe,EAAE,GAAG,SAAS,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,eAAe,CAAC,WAAW,CAAC,GAAG,SAAS,CAIzJ;AAED;2EAC2E;AAC3E,wBAAgB,cAAc,CAAC,GAAG,EAAE,cAAc,GAAG,WAAW,CAAC,WAAW,CAAC,cAAc,CAAC,CAAC,CAE5F"}
|
package/dist/input.js
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/** Thrown by a tool invoker to suspend the run with a prompt. The loop recognises this class and ONLY this
|
|
2
|
+
* class — any other throw is a step failure. */
|
|
3
|
+
export class InputRequired extends Error {
|
|
4
|
+
request;
|
|
5
|
+
constructor(request) {
|
|
6
|
+
super(`input required: ${request.kind} for ${request.toolId} (${request.stepRef})`);
|
|
7
|
+
this.name = 'InputRequired';
|
|
8
|
+
this.request = request;
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
export function isInputRequired(e) {
|
|
12
|
+
return e instanceof InputRequired || (typeof e === 'object' && e !== null && e.name === 'InputRequired' && 'request' in e);
|
|
13
|
+
}
|
|
14
|
+
/** The inputs supplied for one step (a resume may answer several steps at once). */
|
|
15
|
+
export function inputsFor(supplied, stepRef) {
|
|
16
|
+
return (supplied ?? []).filter((s) => s.stepRef === stepRef);
|
|
17
|
+
}
|
|
18
|
+
/** The merged `data` answers for a step (later entries win). */
|
|
19
|
+
export function dataFor(supplied, stepRef) {
|
|
20
|
+
return Object.assign({}, ...inputsFor(supplied, stepRef).map((s) => s.data ?? {}));
|
|
21
|
+
}
|
|
22
|
+
/** The supplied signature over `digest` for a step, if any. Case-insensitive on the digest. */
|
|
23
|
+
export function signatureFor(supplied, stepRef, digest) {
|
|
24
|
+
return inputsFor(supplied, stepRef)
|
|
25
|
+
.map((s) => s.signature)
|
|
26
|
+
.find((s) => !!s && (digest === undefined || s.digest.toLowerCase() === digest.toLowerCase()));
|
|
27
|
+
}
|
|
28
|
+
/** What a `suspended` receipt carries about the prompt — the kind and, for a signature, the digest; never
|
|
29
|
+
* the answers (those are the person's, and they arrive on the resume). */
|
|
30
|
+
export function receiptPending(req) {
|
|
31
|
+
return { kind: req.kind, ...(req.kind === 'signature' ? { digest: req.digest, signer: req.signer } : {}), ...(req.kind === 'data' ? { fields: req.fields.map((f) => f.name) } : {}) };
|
|
32
|
+
}
|
|
33
|
+
//# sourceMappingURL=input.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"input.js","sourceRoot":"","sources":["../src/input.ts"],"names":[],"mappings":"AAyHA;iDACiD;AACjD,MAAM,OAAO,aAAc,SAAQ,KAAK;IAC7B,OAAO,CAAiB;IACjC,YAAY,OAAuB;QACjC,KAAK,CAAC,mBAAmB,OAAO,CAAC,IAAI,QAAQ,OAAO,CAAC,MAAM,KAAK,OAAO,CAAC,OAAO,GAAG,CAAC,CAAC;QACpF,IAAI,CAAC,IAAI,GAAG,eAAe,CAAC;QAC5B,IAAI,CAAC,OAAO,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C,GAAG,CAAC,IAAI,KAAK,WAAW,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,GAAG,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,GAAG,CAAC,GAAG,CAAC,IAAI,KAAK,MAAM,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC;AACxL,CAAC"}
|
package/dist/loop.d.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
|
-
import type { Intent, RunResult, StepObservation, ToolSpec } from './types.js';
|
|
1
|
+
import type { Intent, Plan, PlanStep, RunResult, StepObservation, ToolSpec } from './types.js';
|
|
2
2
|
import type { Planner } from './planner.js';
|
|
3
3
|
import type { ToolInvoker } from './tool-invoker.js';
|
|
4
|
+
import { type SuppliedInputV1 } from './input.js';
|
|
5
|
+
import type { MandatePresentation, OrchestrationPorts, ResolvedStep, StepReceipt } from './authority.js';
|
|
4
6
|
export interface RunIntentOpts {
|
|
5
7
|
/** The injected planning port (deterministic default or the LLM adapter). */
|
|
6
8
|
planner: Planner;
|
|
@@ -14,12 +16,122 @@ export interface RunIntentOpts {
|
|
|
14
16
|
maxReplans?: number;
|
|
15
17
|
/** Optional observer for each executed step (telemetry; never authority). */
|
|
16
18
|
onObserve?: (obs: StepObservation) => void;
|
|
19
|
+
/** Spec 374 §1 — WHICH STEPS ARE JUDGED ELSEWHERE. Returns the agent a step is routed to when its
|
|
20
|
+
* resolved subject is another agent (spec 366 R1), else null. Such a step presents no mandate HERE:
|
|
21
|
+
* the subject's agent judges it, and this run records the step as routed and holds what it answers. */
|
|
22
|
+
authorityJudgedElsewhere?: (step: ResolvedStep) => string | null;
|
|
23
|
+
/** Spec 350 — the authority ports. Required once any tool declares a capability. */
|
|
24
|
+
ports?: OrchestrationPorts;
|
|
25
|
+
/** Spec 350 — what the caller presented as its authority. Opaque here; the verifier reads it.
|
|
26
|
+
* Spec 358 W4 — MAY be a list (a keyring): a fanned-out plan needs a mandate per item, and a caller
|
|
27
|
+
* that has gathered several presents them together. With more than one, `selectPresentation` is
|
|
28
|
+
* REQUIRED — the loop never tries mandates against a step until one sticks (ADR-0013: selection is
|
|
29
|
+
* deterministic and separate from verification, which still judges exactly one mandate). */
|
|
30
|
+
presented?: MandatePresentation | MandatePresentation[] | null;
|
|
31
|
+
/** Choose WHICH presented mandate this step is judged under (match by payee, resource…). `null` means
|
|
32
|
+
* none fits — the step reports authority-required naming its own args, exactly as if nothing had been
|
|
33
|
+
* presented for it. Ignored when zero or one mandate is presented. */
|
|
34
|
+
selectPresentation?: (step: ResolvedStep, all: MandatePresentation[]) => MandatePresentation | null;
|
|
35
|
+
/** Spec 358 W4 — is this relation fan-out-able, and over at most how many items? The binding lives in
|
|
36
|
+
* the ontology package; injecting it keeps this loop domain-free. Absent ⇒ every forEach is refused. */
|
|
37
|
+
fanOut?: (relation: string) => {
|
|
38
|
+
maxItems: number;
|
|
39
|
+
} | null;
|
|
40
|
+
/** The run's reference — the A2A taskId when run inside `A2aTaskDO`. Defaults to a random id. */
|
|
41
|
+
runRef?: string;
|
|
42
|
+
/**
|
|
43
|
+
* Spec 370 P1 — RESUME FROM A CHECKPOINT. `plan` is the plan the run was admitted with (the planner is
|
|
44
|
+
* not asked again — the intent is the same intent, and a second plan for it would be a second run);
|
|
45
|
+
* `completed` are the steps that already ran, by stepRef, with what they returned and the receipt
|
|
46
|
+
* that recorded them.
|
|
47
|
+
*
|
|
48
|
+
* A completed step REPLAYS: its observation is taken as recorded, its result feeds `$ref`s exactly as
|
|
49
|
+
* it did, its receipt is carried, and neither the invoker nor the verifier is called — there is no new
|
|
50
|
+
* attempt to authorize (spec 362 §0.1, gate 4). Every step that has NOT run goes through the verifier
|
|
51
|
+
* as if for the first time: the checkpoint carries what happened, never permission for what has not.
|
|
52
|
+
* The plan is re-admitted regardless (admission is deterministic and reads only declarations).
|
|
53
|
+
*/
|
|
54
|
+
resume?: {
|
|
55
|
+
plan: Plan;
|
|
56
|
+
completed: ReadonlyArray<{
|
|
57
|
+
stepRef: string;
|
|
58
|
+
result?: unknown;
|
|
59
|
+
receipt?: StepReceipt;
|
|
60
|
+
}>;
|
|
61
|
+
};
|
|
62
|
+
/** Spec 367 §5 — the execution binding for a resolved step, recorded on its receipt. */
|
|
63
|
+
bindingFor?: (step: ResolvedStep) => import('./authority.js').ExecutionBindingV1 | undefined;
|
|
64
|
+
/**
|
|
65
|
+
* Spec 360 — the playbook's declared consequences. A map keyed by capability id, OR a RESOLVER called
|
|
66
|
+
* per step.
|
|
67
|
+
*
|
|
68
|
+
* The resolver exists because an effect follows THE ACT, and the agent whose authority an act spends is
|
|
69
|
+
* not known until the step is resolved: a payment's receipt belongs to the treasury whose funds moved,
|
|
70
|
+
* not to whichever agent the person happened to be talking to. Passing a static map would tie every
|
|
71
|
+
* consequence to the addressee, which is the wrong agent for exactly the case the feature exists for.
|
|
72
|
+
*
|
|
73
|
+
* Either way the loop never reads INSIDE an effect — it obtains them and hands them to the sink.
|
|
74
|
+
*/
|
|
75
|
+
declaredEffects?: Record<string, unknown[]> | ((capabilityId: string, step: ResolvedStep) => unknown[] | Promise<unknown[]>);
|
|
76
|
+
/** Spec 354 §4.5 — the playbook that admitted this run (canonical id + version + definition digest).
|
|
77
|
+
* Stamped onto every receipt so a run's receipt names WHICH procedure shaped it. Injected — the loop
|
|
78
|
+
* stays domain-free and never reads a vault. Absent ⇒ the bare harness; receipts carry no skillRef. */
|
|
79
|
+
skillRef?: {
|
|
80
|
+
skillId: string;
|
|
81
|
+
version: string;
|
|
82
|
+
commitment: string;
|
|
83
|
+
};
|
|
84
|
+
/** Unix-seconds clock, injected so receipts are deterministic in tests. */
|
|
85
|
+
now?: () => number;
|
|
86
|
+
/** What to do when a step needs a mandate and none was presented. `'throw'` (the default, unchanged)
|
|
87
|
+
* fails closed with `no_mandate_presented`. `'report'` returns `outcome: 'authority-required'` naming
|
|
88
|
+
* the step, so an Ask surface can tell the person what authority it would need instead of refusing —
|
|
89
|
+
* it grants nothing: the caller must come back with a mandate, which is then verified as always. */
|
|
90
|
+
onMissingMandate?: 'throw' | 'report';
|
|
91
|
+
/**
|
|
92
|
+
* Normalise a step's args before ANYTHING judges them — spec 350 §3.1.
|
|
93
|
+
*
|
|
94
|
+
* A planner writes what the person said: `payee: "alice2.treasury"`, `asset: "usdc"`. Those are correct
|
|
95
|
+
* English and cannot be verified against anything: an allowlist holds addresses. Normalising later (when
|
|
96
|
+
* a mandate is minted, say) fixes the display and leaves the RUN judging the words — which denied a
|
|
97
|
+
* payment whose mandate was correct, for a target that was never really wrong.
|
|
98
|
+
*
|
|
99
|
+
* So the substrate gets one place to turn the person's language into its own, ahead of the capability
|
|
100
|
+
* extraction, the verifier and the invoker alike. It may not change WHICH tool runs or WHAT it is
|
|
101
|
+
* allowed to do: resolving a name is reading an argument, not widening a grant.
|
|
102
|
+
*/
|
|
103
|
+
normalizeArgs?: (input: {
|
|
104
|
+
toolId: string;
|
|
105
|
+
tool: ToolSpec;
|
|
106
|
+
args: Record<string, unknown>;
|
|
107
|
+
}) => Promise<Record<string, unknown>>;
|
|
108
|
+
/** Spec 376 W2 — a step's `executor` as the plan named it (a person's words, "runtime-c3s0.svc") turned into
|
|
109
|
+
* the agent's address in the asker's own tier, or a question when several answer to it. `undefined` ⇒ the
|
|
110
|
+
* step runs here. Called for every step that names one; may throw `InputRequired` like `normalizeArgs`. */
|
|
111
|
+
resolveExecutor?: (input: {
|
|
112
|
+
step: PlanStep;
|
|
113
|
+
tool: ToolSpec;
|
|
114
|
+
}) => Promise<string | undefined>;
|
|
115
|
+
/**
|
|
116
|
+
* Spec 363 W6 — the DECISIONS made while normalising this step, for its receipt.
|
|
117
|
+
*
|
|
118
|
+
* The loop does not decide anything: normalisation is where words become canonical values, and where a
|
|
119
|
+
* decision point answers instead of asking. So the caller that ran it is the one that knows, and this
|
|
120
|
+
* is how it says — a port, like every other thing the loop does not own.
|
|
121
|
+
*/
|
|
122
|
+
decisionsFor?: (toolId: string, args: Record<string, unknown>) => ReadonlyArray<NonNullable<StepReceipt['decisions']>[number]>;
|
|
123
|
+
/** Spec 350 §3.4 — answers to prompts an earlier run of THIS intent raised (a resume). Handed to each
|
|
124
|
+
* tool by stepRef. A resume is a full re-run: every step passes the verifier again, and a step that
|
|
125
|
+
* already executed is re-invoked under the same idempotency key (an invoker makes it a no-op). */
|
|
126
|
+
supplied?: SuppliedInputV1[];
|
|
17
127
|
}
|
|
18
128
|
/**
|
|
19
129
|
* Run an intent to a terminal result. Plans, executes the steps in order (threading `ref` results into later
|
|
20
130
|
* args), observes, and re-plans (bounded) when a step throws. Returns `completed` with the last successful
|
|
21
|
-
* step's result,
|
|
22
|
-
*
|
|
131
|
+
* step's result, `failed` with the error, `denied` when authority refused a step, or `suspended` when an
|
|
132
|
+
* approval is pending. Fail-closed throughout: an unknown tool, an empty plan, no plan, an exhausted step
|
|
133
|
+
* budget, a capability step with no verifier, or a denial all produce a non-completed RunResult — never a
|
|
134
|
+
* misleading empty success.
|
|
23
135
|
*/
|
|
24
136
|
export declare function runIntent(intent: Intent, opts: RunIntentOpts): Promise<RunResult>;
|
|
25
137
|
//# sourceMappingURL=loop.d.ts.map
|
package/dist/loop.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"loop.d.ts","sourceRoot":"","sources":["../src/loop.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"loop.d.ts","sourceRoot":"","sources":["../src/loop.ts"],"names":[],"mappings":"AAkBA,OAAO,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,QAAQ,EAAE,SAAS,EAAE,eAAe,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAE/F,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,c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