@belticlabs/agent-risk-sdk 0.2.0 → 0.4.0

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/index.js CHANGED
@@ -1,21 +1,22 @@
1
1
  import {
2
- openCall,
2
+ Verdict
3
+ } from "./chunk-4BUUPU3O.js";
4
+ import {
5
+ BelticDisabledError,
6
+ DEFAULT_OPEN_RETRY_MS,
7
+ Session,
8
+ Sessions,
3
9
  recordCall
4
- } from "./chunk-GSH5APZW.js";
10
+ } from "./chunk-4MG6VNAU.js";
5
11
  import {
6
- Chain,
12
+ canonicalBytes,
13
+ canonicalize,
7
14
  didKeyFromEd25519,
8
15
  fromHex,
9
16
  memorySigner,
17
+ sha256,
10
18
  toHex
11
- } from "./chunk-SFGM7KOG.js";
12
- import {
13
- Verdict
14
- } from "./chunk-46QN2KEZ.js";
15
- import {
16
- presentedFrom,
17
- summaryOf
18
- } from "./chunk-7G5EHNVW.js";
19
+ } from "./chunk-X3W2Z5GC.js";
19
20
 
20
21
  // src/core/api-client.ts
21
22
  var BelticApiError = class extends Error {
@@ -115,212 +116,269 @@ var MemoryCorrelationStore = class {
115
116
  }
116
117
  };
117
118
 
118
- // src/core/session.ts
119
- var Session = class {
120
- constructor(deps, id, source, expiresAt, born) {
121
- this.deps = deps;
122
- this.id = id;
123
- this.source = source;
124
- this.expiresAt = expiresAt;
125
- this.born = born;
126
- this.chain = Chain.genesis(id, source);
127
- this.now = deps.now ?? (() => /* @__PURE__ */ new Date());
128
- }
129
- chain;
130
- building = Promise.resolve();
131
- dropped = 0;
132
- droppedFirstTs = null;
133
- droppedLastTs = null;
134
- closed = false;
135
- now;
136
- get head() {
137
- return this.chain.head;
119
+ // src/core/identity.ts
120
+ import { mkdirSync, readFileSync, writeFileSync } from "fs";
121
+ import { dirname } from "path";
122
+ function identityFromSeed(seed, credential) {
123
+ const signer = memorySigner(seed);
124
+ const did = didKeyFromEd25519(signer.publicKey);
125
+ return { did, signer: { ...signer, keyId: did }, ...credential ? { credential } : {} };
126
+ }
127
+ function ephemeralIdentity(credential) {
128
+ return identityFromSeed(memorySigner().seed, credential);
129
+ }
130
+ function fileIdentity(path, credential) {
131
+ let seed;
132
+ try {
133
+ seed = fromHex(JSON.parse(readFileSync(path, "utf8")).seed);
134
+ } catch {
135
+ seed = memorySigner().seed;
136
+ mkdirSync(dirname(path), { recursive: true });
137
+ writeFileSync(path, `${JSON.stringify({ seed: toHex(seed) })}
138
+ `, { mode: 384 });
139
+ }
140
+ return identityFromSeed(seed, credential);
141
+ }
142
+
143
+ // src/core/payment-moment.ts
144
+ function summaryOf(m) {
145
+ return {
146
+ protocol: m.protocol,
147
+ payee: m.payee,
148
+ amount: { value: m.amount.value, currency: m.amount.currency },
149
+ ...m.payer ? { payer: m.payer } : {}
150
+ };
151
+ }
152
+ function presentedFrom(summary, raw) {
153
+ return { ...summary, artifact: "payment-signature", raw };
154
+ }
155
+
156
+ // src/core/decision.ts
157
+ var Decision = class _Decision {
158
+ constructor(evaluation) {
159
+ this.evaluation = evaluation;
138
160
  }
139
- get droppedCount() {
140
- return this.dropped;
161
+ static ABSENT = new _Decision(null);
162
+ static of(evaluation) {
163
+ return new _Decision(evaluation);
141
164
  }
142
- /**
143
- * Resolves once the event is sequenced and buffered — not once it is
144
- * acknowledged. `false` when the event was dropped, or (fail-open) when
145
- * the chain can no longer take it.
146
- */
147
- async emit(kind, payload) {
148
- if (!this.deps.failOpen) return this.chainEvent(kind, payload);
149
- try {
150
- return await this.chainEvent(kind, payload);
151
- } catch (err) {
152
- this.deps.onError?.(err);
153
- return false;
154
- }
165
+ static absent() {
166
+ return _Decision.ABSENT;
155
167
  }
156
- /** The tool call whose `execute` the host runs itself; see `ToolCallSpan`. */
157
- toolCall(call) {
158
- const { callId, ...start } = call;
159
- return openCall(this, "tool_call", callId, { transport: "local", ...start });
160
- }
161
- async chainEvent(kind, payload) {
162
- const halted = this.deps.transport.haltedError(this.id, this.source);
163
- if (halted) throw halted;
164
- const ts = this.now().toISOString();
165
- if (!this.deps.transport.hasRoom()) {
166
- this.dropped++;
167
- this.droppedFirstTs ??= ts;
168
- this.droppedLastTs = ts;
169
- return false;
170
- }
171
- if (this.dropped > 0) {
172
- this.deps.transport.enqueue(
173
- await this.next(
174
- "transport.gap",
175
- { dropped: this.dropped, firstTs: this.droppedFirstTs, lastTs: this.droppedLastTs },
176
- ts
177
- )
178
- );
179
- this.dropped = 0;
180
- this.droppedFirstTs = this.droppedLastTs = null;
181
- }
182
- const body = payload;
183
- this.deps.transport.enqueue(
184
- await this.next(kind, this.deps.redact ? this.deps.redact(kind, body) : body, ts)
185
- );
186
- return true;
168
+ get value() {
169
+ return this.evaluation?.decision ?? null;
187
170
  }
188
- async close(reason = "completed", extra = {}) {
189
- if (this.closed) return;
190
- this.closed = true;
191
- await this.emit("session.close", { reason, ...extra });
192
- await this.flush();
193
- this.deps.onClosed?.(this);
171
+ get reasonCodes() {
172
+ return this.evaluation?.reasonCodes ?? [];
194
173
  }
195
- /** Read-your-writes: the platform must hold the evidence before anyone judges it (GAP-16/66). */
196
- flush() {
197
- return this.deps.transport.flush();
198
- }
199
- /** Serialized: two concurrent emits get consecutive seqs, never the same one. */
200
- next(kind, payload, ts) {
201
- const run = this.building.then(async () => {
202
- const built = await this.chain.append({ ts, kind, payload }, this.deps.signer);
203
- this.chain = built.chain;
204
- return built.event;
205
- });
206
- this.building = run.catch(() => void 0);
207
- return run;
174
+ get decisionId() {
175
+ return this.evaluation?.decisionId ?? null;
176
+ }
177
+ get allowed() {
178
+ return this.value === "ALLOW";
179
+ }
180
+ get denied() {
181
+ return this.value === "DENY";
182
+ }
183
+ get review() {
184
+ return this.value === "REVIEW";
185
+ }
186
+ get absent() {
187
+ return this.evaluation === null;
188
+ }
189
+ /** Whether a gate must stop the payment (GAP-52); an absent verdict never blocks. */
190
+ blocks(onReview) {
191
+ return this.evaluation ? Verdict.of(this.evaluation.decision).blocks(onReview) : false;
192
+ }
193
+ /** One sentence for the agent or the person: what Beltic said and why. */
194
+ explain() {
195
+ if (!this.evaluation) return "Beltic could not be asked about this payment.";
196
+ const verb = this.denied ? "denied" : this.review ? "asked for review of" : "allowed";
197
+ const why = this.reasonCodes.length > 0 ? ` (${this.reasonCodes.join(", ")})` : "";
198
+ return `Beltic ${verb} this payment${why}.`;
208
199
  }
209
200
  };
210
- var DEFAULT_OPEN_RETRY_MS = 6e4;
211
- var Sessions = class {
212
- constructor(deps) {
201
+
202
+ // src/core/run.ts
203
+ var MEMORY = 256;
204
+ var Memory = class {
205
+ map = /* @__PURE__ */ new Map();
206
+ get(key) {
207
+ return this.map.get(key);
208
+ }
209
+ set(key, value) {
210
+ this.map.delete(key);
211
+ this.map.set(key, value);
212
+ if (this.map.size > MEMORY) this.map.delete(this.map.keys().next().value);
213
+ }
214
+ };
215
+ var Run = class _Run {
216
+ constructor(deps, key, opts = {}) {
213
217
  this.deps = deps;
218
+ this.key = key;
219
+ this.opts = opts;
220
+ }
221
+ opened = null;
222
+ current = null;
223
+ /** JCS hash of the mandate on the chain, and of the one the open input carried. */
224
+ declared = null;
225
+ openedWith = null;
226
+ closed = false;
227
+ timer = null;
228
+ calls = new Memory();
229
+ decisions = new Memory();
230
+ byPayment = new Memory();
231
+ /** The session this run records into — opened on first use, `null` when there is none. */
232
+ session() {
233
+ const next = this.deps.sessions.open(this.key, this.opener);
234
+ this.opened = next;
235
+ return next.then((session) => {
236
+ if (session !== this.current) {
237
+ this.current = session;
238
+ this.declared = this.openedWith;
239
+ }
240
+ return session;
241
+ });
242
+ }
243
+ opener = async () => {
244
+ const open = this.opts.open;
245
+ const input = typeof open === "function" ? await open() : open ?? {};
246
+ this.openedWith = input.intent ? _Run.hash(input.intent) : null;
247
+ return input;
248
+ };
249
+ /** `intent.declared`, unless the mandate is the one already on the chain. */
250
+ async declare(intent) {
251
+ const session = await this.session();
252
+ if (!session) return false;
253
+ const hash = _Run.hash(intent);
254
+ if (hash === this.declared) return false;
255
+ const ok = await session.emit("intent.declared", intent);
256
+ if (ok) this.declared = hash;
257
+ this.touch();
258
+ return ok;
214
259
  }
215
260
  /**
216
- * One session object per (session, source) per process: a chain's head
217
- * lives in it, so two objects for the same chain would both start at
218
- * seq 0 and fork it. Closed sessions are forgotten; a process restart
219
- * mid-session still loses the head (GAP-67).
261
+ * The platform's verdict on a payment about to be presented. Asked once
262
+ * per call id: a host that re-runs its approval step reads the same
263
+ * `Decision`. An absent verdict is not memoized, so the next attempt
264
+ * asks again.
220
265
  */
221
- attached = /* @__PURE__ */ new Map();
222
- /** Buyer sessions by the host's own key (GAP-71). */
223
- opened = /* @__PURE__ */ new Map();
224
- retryAt = 0;
266
+ async decide(payment, opts = {}) {
267
+ const known = opts.callId ? this.decisions.get(opts.callId) : void 0;
268
+ if (known) return known;
269
+ const session = await this.session();
270
+ if (!session) return Decision.absent();
271
+ if (opts.intent) await this.declare(opts.intent);
272
+ const summary = summaryOf(payment);
273
+ const evaluation = await this.deps.evaluate(session.id, summary);
274
+ if (!evaluation) return Decision.absent();
275
+ const decision = Decision.of(evaluation);
276
+ if (opts.callId) this.decisions.set(opts.callId, decision);
277
+ for (const key of _Run.paymentKeys(summary)) this.byPayment.set(key, decision);
278
+ const call = opts.callId ? this.calls.get(opts.callId)?.call : void 0;
279
+ await session.emit("gateway.decision", {
280
+ gateway: "beltic",
281
+ call: _Run.callOf(call),
282
+ decision: evaluation.decision,
283
+ reasonCodes: [...evaluation.reasonCodes],
284
+ record: {
285
+ decisionId: evaluation.decisionId,
286
+ callId: opts.callId ?? null,
287
+ payment: summary
288
+ }
289
+ });
290
+ this.touch();
291
+ return decision;
292
+ }
293
+ /** The decision given for a call id, or absent. */
294
+ decision(callId) {
295
+ return this.decisions.get(callId) ?? Decision.absent();
296
+ }
225
297
  /**
226
- * Buyer half: the evidence session for a key of the host's own (its
227
- * session, run or conversation id), opened on first use and reused
228
- * after. A halted chain is reopened as a fresh session that continues
229
- * the same key; a closed key is forgotten. When the platform refuses to
230
- * open one, a fail-open client resolves null — the host runs without
231
- * evidence — until `openRetryMs` has passed (GAP-71); otherwise the
232
- * refusal is thrown and the next call tries again. The identity is
233
- * required either way: that is configuration.
298
+ * The decision given for a payment with the same comparable core (payee,
299
+ * amount, payer or payee and amount when one side names no payer), or
300
+ * absent.
234
301
  */
235
- open(key, input = {}) {
236
- const prior = this.opened.get(key) ?? Promise.resolve(null);
237
- const next = prior.catch(() => null).then(
238
- (session) => session && !this.deps.transport.haltedError(session.id, session.source) ? session : this.openFresh(input, () => this.forget(key, next))
239
- );
240
- this.opened.set(key, next);
241
- next.catch(() => this.forget(key, next));
242
- return next;
243
- }
244
- forget(key, entry) {
245
- if (this.opened.get(key) === entry) this.opened.delete(key);
246
- }
247
- async openFresh(input, onClosed) {
248
- this.identityFor("open");
249
- const create = async () => this.create(typeof input === "function" ? await input() : input, onClosed);
250
- if (!this.deps.failOpen) return create();
251
- if (Date.now() < this.retryAt) return null;
252
- try {
253
- const session = await create();
254
- this.retryAt = 0;
255
- return session;
256
- } catch (err) {
257
- this.retryAt = Date.now() + (this.deps.openRetryMs ?? DEFAULT_OPEN_RETRY_MS);
258
- this.deps.onError?.(err);
259
- return null;
302
+ decisionFor(payment) {
303
+ for (const key of _Run.paymentKeys(summaryOf(payment))) {
304
+ const known = this.byPayment.get(key);
305
+ if (known) return known;
260
306
  }
261
- }
262
- /** Buyer half: create an AGENT_TRACE session bound to the agent identity, then announce it on the chain. */
263
- start(input = {}) {
264
- return this.create(input);
265
- }
266
- identityFor(entry) {
267
- const identity = this.deps.identity;
268
- if (!identity)
269
- throw new Error(`sessions.${entry} needs an agent identity (createBeltic({ identity }))`);
270
- return identity;
271
- }
272
- async create(input, onClosed) {
273
- const identity = this.identityFor("start");
274
- const body = {
275
- source: "AGENT_TRACE",
276
- agent: { did: identity.did, credential: identity.credential ?? identity.did },
277
- ...input.intent ? { intent: input.intent } : {}
278
- };
279
- const out = await this.deps.api.post("/v1/sessions", body);
280
- const session = this.attach(out.sessionId, "AGENT_TRACE", out.expiresAt, "buyer", onClosed);
281
- await session.emit("session.open", {
282
- runtime: {
283
- sdk: "@belticlabs/agent-risk-sdk",
284
- version: this.deps.sdkVersion,
285
- ...input.runtime
286
- },
287
- ...input.attestations ? { attestations: input.attestations } : {}
288
- });
289
- if (input.intent) await session.emit("intent.declared", input.intent);
290
- return session;
291
- }
292
- /** Seller half: emit INTERNAL_NETWORK evidence into a session the buyer bound, or open a seller-born one. */
293
- async ensure(sessionId) {
294
- if (sessionId) return this.attach(sessionId, "INTERNAL_NETWORK", null, "buyer");
295
- const out = await this.deps.api.post("/v1/sessions", {
296
- source: "INTERNAL_NETWORK"
307
+ return Decision.absent();
308
+ }
309
+ /** A tool call the host runs itself, reported as two events by its own call id. */
310
+ tools = {
311
+ start: async (call) => {
312
+ const session = await this.session();
313
+ if (!session) return false;
314
+ const span = session.toolCall(call);
315
+ this.calls.set(call.callId, { call, span });
316
+ this.touch();
317
+ return span.opened;
318
+ },
319
+ end: async (callId, outcome) => {
320
+ const span = this.take(callId);
321
+ if (!span) return false;
322
+ this.touch();
323
+ return span.end(outcome);
324
+ },
325
+ fail: async (callId, error, outcome) => {
326
+ const span = this.take(callId);
327
+ if (!span) return false;
328
+ this.touch();
329
+ return span.fail(error, outcome);
330
+ }
331
+ };
332
+ /** A person's answer about a call, as the decision it was (GAP-75). */
333
+ async humanDecided(callId, input) {
334
+ const session = await this.session();
335
+ if (!session) return false;
336
+ const ok = await session.emit("gateway.decision", {
337
+ gateway: "human",
338
+ call: _Run.callOf(this.calls.get(callId)?.call),
339
+ decision: input.allowed ? "ALLOW" : "DENY",
340
+ reasonCodes: [`USER_${input.outcome.toUpperCase().replace(/[^A-Z0-9]+/g, "_")}`],
341
+ record: {
342
+ callId,
343
+ outcome: input.outcome,
344
+ responder: input.responder ?? null,
345
+ ...input.record ?? {}
346
+ }
297
347
  });
298
- return this.attach(out.sessionId, "INTERNAL_NETWORK", out.expiresAt, "seller");
348
+ this.touch();
349
+ return ok;
299
350
  }
300
- attach(id, source, expiresAt, born, onClosed) {
301
- const key = `${id}:${source}`;
302
- const existing = this.attached.get(key);
303
- if (existing) return existing;
304
- const session = new Session(
305
- {
306
- transport: this.deps.transport,
307
- signer: source === "AGENT_TRACE" ? this.deps.identity?.signer : void 0,
308
- redact: this.deps.redact,
309
- now: this.deps.now,
310
- failOpen: this.deps.failOpen,
311
- onError: this.deps.onError,
312
- onClosed: () => {
313
- this.attached.delete(key);
314
- onClosed?.();
315
- }
316
- },
317
- id,
318
- source,
319
- expiresAt,
320
- born
321
- );
322
- this.attached.set(key, session);
323
- return session;
351
+ async close(reason = "completed") {
352
+ if (this.closed) return;
353
+ this.closed = true;
354
+ if (this.timer) clearTimeout(this.timer);
355
+ this.deps.onClosed(this);
356
+ const session = this.opened ? await this.opened.catch(() => null) : null;
357
+ await session?.close(reason);
358
+ }
359
+ take(callId) {
360
+ const known = this.calls.get(callId);
361
+ if (!known?.span) return null;
362
+ const { span } = known;
363
+ known.span = null;
364
+ return span;
365
+ }
366
+ touch() {
367
+ if (!this.opts.idleMs || this.closed) return;
368
+ if (this.timer) clearTimeout(this.timer);
369
+ this.timer = setTimeout(() => void this.close("expired"), this.opts.idleMs);
370
+ this.timer.unref?.();
371
+ }
372
+ static hash(intent) {
373
+ return toHex(sha256(canonicalBytes(intent)));
374
+ }
375
+ /** With the payer first, then without it. */
376
+ static paymentKeys(summary) {
377
+ const { payer, ...core } = summary;
378
+ return payer ? [canonicalize(summary), canonicalize(core)] : [canonicalize(core)];
379
+ }
380
+ static callOf(call) {
381
+ return call ? { tool: call.toolName, args: call.input } : { tool: "unknown" };
324
382
  }
325
383
  };
326
384
 
@@ -486,8 +544,10 @@ var Transport = class {
486
544
  };
487
545
 
488
546
  // src/client.ts
489
- var SDK_VERSION = "0.2.0";
490
- var Beltic = class {
547
+ var SDK_VERSION = "0.4.0";
548
+ var ENV_REQUIRED = ["BELTIC_API_KEY", "BELTIC_BASE_URL", "BELTIC_AGENT_SEED"];
549
+ var ENV_CREDENTIAL = "BELTIC_AGENT_CREDENTIAL";
550
+ var Beltic = class _Beltic {
491
551
  api;
492
552
  transport;
493
553
  sessions;
@@ -495,8 +555,43 @@ var Beltic = class {
495
555
  correlation;
496
556
  onReview;
497
557
  failOpen;
558
+ /** `false` for a disabled client (GAP-78): nothing is posted, `run`/`sessions.open` answer without a session. */
559
+ enabled;
498
560
  onError;
561
+ runs = /* @__PURE__ */ new Map();
562
+ /**
563
+ * The client the environment describes: `BELTIC_API_KEY`,
564
+ * `BELTIC_BASE_URL`, `BELTIC_AGENT_SEED` (64 hex) and optionally
565
+ * `BELTIC_AGENT_CREDENTIAL`, fail-open by default. None set → a disabled
566
+ * client; some set → a configuration error, thrown (GAP-78).
567
+ */
568
+ static fromEnv(env = _Beltic.processEnv(), opts = {}) {
569
+ const missing = ENV_REQUIRED.filter((name) => !env[name]);
570
+ if (missing.length === ENV_REQUIRED.length) return _Beltic.disabled(opts);
571
+ if (missing.length > 0)
572
+ throw new Error(
573
+ `Beltic.fromEnv: ${missing.join(", ")} missing \u2014 set all of ${ENV_REQUIRED.join(", ")}, or none to disable`
574
+ );
575
+ return new _Beltic({
576
+ failOpen: true,
577
+ ...opts,
578
+ apiKey: env.BELTIC_API_KEY,
579
+ baseUrl: env.BELTIC_BASE_URL,
580
+ identity: identityFromSeed(fromHex(env.BELTIC_AGENT_SEED), env[ENV_CREDENTIAL])
581
+ });
582
+ }
583
+ /** A client that records nothing and never throws into the work: the null object for "no evidence stream" (GAP-78). */
584
+ static disabled(opts = {}) {
585
+ return new _Beltic({
586
+ ...opts,
587
+ apiKey: "",
588
+ baseUrl: "http://beltic.disabled.invalid",
589
+ failOpen: true,
590
+ enabled: false
591
+ });
592
+ }
499
593
  constructor(opts) {
594
+ this.enabled = opts.enabled ?? true;
500
595
  this.failOpen = opts.failOpen ?? false;
501
596
  this.onError = opts.onError ?? ((err) => console.error("[beltic]", err));
502
597
  this.api = new ApiClient({ ...opts, userAgent: `@belticlabs/agent-risk-sdk/${SDK_VERSION}` });
@@ -514,7 +609,8 @@ var Beltic = class {
514
609
  now: opts.now,
515
610
  failOpen: this.failOpen,
516
611
  onError: this.onError,
517
- openRetryMs: opts.openRetryMs
612
+ openRetryMs: opts.openRetryMs,
613
+ enabled: this.enabled
518
614
  });
519
615
  this.identity = opts.identity;
520
616
  this.correlation = opts.correlation ?? new MemoryCorrelationStore();
@@ -529,6 +625,7 @@ var Beltic = class {
529
625
  * platform could not be asked.
530
626
  */
531
627
  async evaluate(sessionId, payment) {
628
+ if (!this.enabled) return null;
532
629
  const input = { sessionId, payment: summaryOf(payment) };
533
630
  if (!this.failOpen) return this.decide(input);
534
631
  try {
@@ -543,48 +640,52 @@ var Beltic = class {
543
640
  const out = await this.api.post("/v1/evaluate", input);
544
641
  return { ...out, verdict: Verdict.of(out.decision) };
545
642
  }
643
+ /**
644
+ * The run for a key of the host's own — one object per key until it
645
+ * closes (the options count on the first call only). See `Run`.
646
+ */
647
+ run(key, opts = {}) {
648
+ const existing = this.runs.get(key);
649
+ if (existing) return existing;
650
+ const run = new Run(
651
+ {
652
+ sessions: this.sessions,
653
+ evaluate: (sessionId, payment) => this.evaluate(sessionId, payment),
654
+ onClosed: (closed) => {
655
+ if (this.runs.get(key) === closed) this.runs.delete(key);
656
+ }
657
+ },
658
+ key,
659
+ opts
660
+ );
661
+ this.runs.set(key, run);
662
+ return run;
663
+ }
546
664
  flush() {
547
665
  return this.transport.flush();
548
666
  }
549
667
  shutdown() {
550
668
  return this.transport.close();
551
669
  }
670
+ /** `process.env` where there is a `process` (Node); `{}` on workerd, where the shell passes its `env`. */
671
+ static processEnv() {
672
+ return globalThis.process?.env ?? {};
673
+ }
552
674
  };
553
675
  function createBeltic(opts) {
554
676
  return new Beltic(opts);
555
677
  }
556
-
557
- // src/core/identity.ts
558
- import { mkdirSync, readFileSync, writeFileSync } from "fs";
559
- import { dirname } from "path";
560
- function identityFromSeed(seed, credential) {
561
- const signer = memorySigner(seed);
562
- const did = didKeyFromEd25519(signer.publicKey);
563
- return { did, signer: { ...signer, keyId: did }, ...credential ? { credential } : {} };
564
- }
565
- function ephemeralIdentity(credential) {
566
- return identityFromSeed(memorySigner().seed, credential);
567
- }
568
- function fileIdentity(path, credential) {
569
- let seed;
570
- try {
571
- seed = fromHex(JSON.parse(readFileSync(path, "utf8")).seed);
572
- } catch {
573
- seed = memorySigner().seed;
574
- mkdirSync(dirname(path), { recursive: true });
575
- writeFileSync(path, `${JSON.stringify({ seed: toHex(seed) })}
576
- `, { mode: 384 });
577
- }
578
- return identityFromSeed(seed, credential);
579
- }
580
678
  export {
581
679
  ApiClient,
582
680
  Beltic,
583
681
  BelticApiError,
682
+ BelticDisabledError,
584
683
  ChainRejectedError,
585
684
  DEFAULT_OPEN_RETRY_MS,
586
685
  DEFAULT_TRANSPORT,
686
+ Decision,
587
687
  MemoryCorrelationStore,
688
+ Run,
588
689
  SDK_VERSION,
589
690
  Session,
590
691
  Sessions,
@@ -1,7 +1,6 @@
1
- import { b as JsonValue, E as EvidenceSourceAll } from '../index-Bjs3BPPU.js';
2
- export { A as ALL_SOURCES, c as ANOMALY_TYPES, d as Amount, e as AmountSchema, f as AnchorEntry, g as AnchorEntrySchema, h as AnchorsOutput, i as AnchorsOutputSchema, j as ApiError, k as ApiErrorSchema, C as ChainHead, l as ChainHeadSchema, m as CreatePolicyInput, n as CreatePolicyInputSchema, o as CreatePolicyOutput, p as CreatePolicyOutputSchema, q as CreateSessionInput, r as CreateSessionInputSchema, s as CreateSessionOutput, t as CreateSessionOutputSchema, D as Decision, u as DecisionSchema, v as DeclaredIntent, w as DeclaredIntentSchema, x as DigestedEnvelope, y as EvaluateInput, z as EvaluateInputSchema, B as EvaluateOutput, F as EvaluateOutputSchema, G as EventResult, H as EventResultSchema, I as EventResultStatus, K as EventResultStatusSchema, L as EvidenceAck, M as EvidenceAckSchema, N as EvidenceBatchInput, O as EvidenceBatchInputSchema, Q as EvidenceEnvelope, R as EvidenceEvent, S as EvidenceEventSchema, T as EvidenceKind, U as EvidenceKindSchema, V as EvidenceSource, W as EvidenceSourceAllSchema, X as EvidenceSourceSchema, Y as GatewayDecisionPayload, Z as GatewayDecisionPayloadSchema, _ as Hex64, $ as Hex64Schema, a0 as IntentDeclaredPayload, a1 as IntentDeclaredPayloadSchema, J as JsonObject, a2 as JsonValueSchema, a3 as LlmCallEndPayload, a4 as LlmCallEndPayloadSchema, a5 as LlmCallStartPayload, a6 as LlmCallStartPayloadSchema, a7 as MAX_BATCH_EVENTS, a8 as PAYMENT_ARTIFACTS, a9 as PLATFORM_KINDS, aa as PayloadByKind, P as PaymentMomentPayload, ab as PaymentMomentPayloadSchema, a as PaymentSummary, ac as PaymentSummarySchema, ad as PlatformAnomalyPayload, ae as PlatformAnomalyPayloadSchema, af as PlatformEvidenceKind, ag as PlatformEvidenceKindSchema, ah as PlatformObservationPayload, ai as PlatformObservationPayloadSchema, aj as SESSION_CLOSE_REASONS, ak as SOURCE_ORDER, al as SeqSchema, am as SessionClosePayload, an as SessionClosePayloadSchema, ao as SessionIdSchema, ap as SessionOpenPayload, aq as SessionOpenPayloadSchema, ar as Sig, as as SigSchema, at as TimestampSchema, au as ToolCallEndPayload, av as ToolCallEndPayloadSchema, aw as ToolCallStartPayload, ax as ToolCallStartPayloadSchema, ay as TransportGapPayload, az as TransportGapPayloadSchema, aA as WIRE_KINDS, aB as WIRE_SOURCES, aC as WireEvidenceKind, aD as WireEvidenceKindSchema, aE as compareBySessionSource, aF as compareBySourceSeq, aG as isPlatformKind, aH as isWireKind, aI as payloadSchemaFor } from '../index-Bjs3BPPU.js';
1
+ import { b as JsonValue, E as EvidenceSourceAll } from '../verdict-CDAsxktI.js';
2
+ export { A as ALL_SOURCES, c as ANOMALY_TYPES, d as Amount, e as AmountSchema, f as ApiError, g as ApiErrorSchema, C as ChainHead, h as ChainHeadSchema, i as CreatePolicyInput, j as CreatePolicyInputSchema, k as CreatePolicyOutput, l as CreatePolicyOutputSchema, m as CreateSessionInput, n as CreateSessionInputSchema, o as CreateSessionOutput, p as CreateSessionOutputSchema, D as Decision, q as DecisionSchema, r as DeclaredIntent, s as DeclaredIntentSchema, t as DigestedEnvelope, u as EvaluateInput, v as EvaluateInputSchema, w as EvaluateOutput, x as EvaluateOutputSchema, y as EventResult, z as EventResultSchema, B as EventResultStatus, F as EventResultStatusSchema, G as EvidenceAck, H as EvidenceAckSchema, I as EvidenceBatchInput, K as EvidenceBatchInputSchema, L as EvidenceEnvelope, M as EvidenceEvent, N as EvidenceEventSchema, O as EvidenceKind, Q as EvidenceKindSchema, R as EvidenceSource, S as EvidenceSourceAllSchema, T as EvidenceSourceSchema, U as GatewayDecisionPayload, V as GatewayDecisionPayloadSchema, W as Hex64, X as Hex64Schema, Y as IntentDeclaredPayload, Z as IntentDeclaredPayloadSchema, J as JsonObject, _ as JsonValueSchema, $ as LlmCallEndPayload, a0 as LlmCallEndPayloadSchema, a1 as LlmCallStartPayload, a2 as LlmCallStartPayloadSchema, a3 as MAX_BATCH_EVENTS, a4 as OnReview, a5 as PAYMENT_ARTIFACTS, a6 as PLATFORM_KINDS, a7 as PayloadByKind, P as PaymentMomentPayload, a8 as PaymentMomentPayloadSchema, a as PaymentSummary, a9 as PaymentSummarySchema, aa as PlatformAnomalyPayload, ab as PlatformAnomalyPayloadSchema, ac as PlatformEvidenceKind, ad as PlatformEvidenceKindSchema, ae as PlatformObservationPayload, af as PlatformObservationPayloadSchema, ag as SESSION_CLOSE_REASONS, ah as SOURCE_ORDER, ai as SeqSchema, aj as SessionClosePayload, ak as SessionClosePayloadSchema, al as SessionIdSchema, am as SessionOpenPayload, an as SessionOpenPayloadSchema, ao as Sig, ap as SigSchema, aq as TimestampSchema, ar as ToolCallEndPayload, as as ToolCallEndPayloadSchema, at as ToolCallStartPayload, au as ToolCallStartPayloadSchema, av as TransportGapPayload, aw as TransportGapPayloadSchema, ax as Verdict, ay as WIRE_KINDS, az as WIRE_SOURCES, aA as WireEvidenceKind, aB as WireEvidenceKindSchema, aC as compareBySessionSource, aD as compareBySourceSeq, aE as isPlatformKind, aF as isWireKind, aG as payloadSchemaFor } from '../verdict-CDAsxktI.js';
3
3
  import { z } from 'zod';
4
- export { O as OnReview, V as Verdict } from '../verdict-BAahb5po.js';
5
4
 
6
5
  declare const PRIMITIVES: readonly ["THRESHOLD", "MEMBERSHIP", "MATCH", "PRESENCE", "FRESHNESS"];
7
6
  declare const PrimitiveSchema: z.ZodEnum<{