@belticlabs/agent-risk-sdk 0.4.0 → 0.5.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.
@@ -1,4 +1,4 @@
1
- import { G as EvidenceAck, y as EventResult, M as EvidenceEvent, w as EvaluateOutput, ax as Verdict, a4 as OnReview, a as PaymentSummary, P as PaymentMomentPayload, D as Decision$1, r as DeclaredIntent, at as ToolCallStartPayload, b as JsonValue, J as JsonObject, aj as SessionClosePayload, R as EvidenceSource, aA as WireEvidenceKind, C as ChainHead, a7 as PayloadByKind } from './verdict-CDAsxktI.js';
1
+ import { w as EventResult, K as EvidenceEvent, u as EvaluateOutput, ax as Verdict, a3 as OnReview, a8 as PaymentSummary, P as PaymentMomentPayload, D as Decision$1, p as DeclaredIntent, at as ToolCallStartPayload, J as JsonValue, Y as JsonObject, aj as SessionClosePayload, O as EvidenceSource, C as ChainHead, aA as WireEvidenceKind, a6 as PayloadByKind } from './verdict-DMnbFuS5.js';
2
2
 
3
3
  /**
4
4
  * The edge signs event digests (Fraud SDK RFC › Modules › Identity Module);
@@ -16,9 +16,8 @@ interface Signer {
16
16
  interface ApiClientOptions {
17
17
  baseUrl: string;
18
18
  apiKey: string;
19
- fetch?: typeof globalThis.fetch;
20
- timeoutMs?: number;
21
- userAgent?: string;
19
+ fetch?: typeof globalThis.fetch | undefined;
20
+ userAgent?: string | undefined;
22
21
  }
23
22
  declare class BelticApiError extends Error {
24
23
  readonly status: number;
@@ -26,13 +25,12 @@ declare class BelticApiError extends Error {
26
25
  readonly details?: unknown | undefined;
27
26
  readonly requestId?: string | undefined;
28
27
  constructor(status: number, code: string, message: string, details?: unknown | undefined, requestId?: string | undefined);
29
- /** 5xx and network failures are retried by the transport; 4xx are not. */
28
+ /** 5xx, 429 and network failures are retried by the transport and absorbed by `failOpen`; 4xx are neither (GAP-70). */
30
29
  get retryable(): boolean;
31
30
  }
32
31
  declare class ApiClient {
33
32
  private readonly baseUrl;
34
33
  private readonly fetchImpl;
35
- private readonly timeoutMs;
36
34
  private readonly headers;
37
35
  constructor(opts: ApiClientOptions);
38
36
  post<T>(path: string, body: unknown, headers?: Record<string, string>): Promise<T>;
@@ -40,6 +38,12 @@ declare class ApiClient {
40
38
  private request;
41
39
  }
42
40
 
41
+ /**
42
+ * Identity Module (Fraud SDK RFC › Modules): the agent's credential (DID +
43
+ * VC) and the event-signing key. Phase 1 is did:key over Ed25519 (GAP-11):
44
+ * the DID *is* the public key, so the signer and the identity are one.
45
+ */
46
+
43
47
  interface AgentIdentity {
44
48
  did: string;
45
49
  signer: Signer;
@@ -47,28 +51,6 @@ interface AgentIdentity {
47
51
  credential?: string;
48
52
  }
49
53
  declare function identityFromSeed(seed: Uint8Array, credential?: string): AgentIdentity;
50
- declare function ephemeralIdentity(credential?: string): AgentIdentity;
51
- /** A JSON keystore on disk: `{ "seed": "<64 hex>" }`, created 0600 when missing. */
52
- declare function fileIdentity(path: string, credential?: string): AgentIdentity;
53
-
54
- /**
55
- * Correlation without binding (Fraud SDK RFC › Protocol Adapter — x402:
56
- * "binding travels on the call that initiates the purchase, not
57
- * necessarily on the payment artifact"). The merchant binds a key it will
58
- * see again (a checkout session id, a challenge nonce) to the buyer's
59
- * session; the adapter resolves it when the settlement arrives (GAP-31).
60
- */
61
- interface CorrelationStore {
62
- bind(key: string, sessionId: string, ttlMs?: number): Promise<void>;
63
- resolve(key: string): Promise<string | null>;
64
- }
65
- declare class MemoryCorrelationStore implements CorrelationStore {
66
- private readonly defaultTtlMs;
67
- private readonly entries;
68
- constructor(defaultTtlMs?: number);
69
- bind(key: string, sessionId: string, ttlMs?: number): Promise<void>;
70
- resolve(key: string): Promise<string | null>;
71
- }
72
54
 
73
55
  /**
74
56
  * Transport (Fraud SDK RFC › Modules: "buffering, batching, chained delivery
@@ -79,8 +61,8 @@ declare class MemoryCorrelationStore implements CorrelationStore {
79
61
  * keep chaining onto a head the platform never accepted.
80
62
  */
81
63
 
82
- interface TransportOptions {
83
- maxBatch: number;
64
+ /** What a host may tune; the defaults are `DEFAULT_TUNING`. */
65
+ interface TransportTuning {
84
66
  flushMs: number;
85
67
  /** Total buffered events across chains; beyond this new events are dropped (GAP-38). */
86
68
  maxBuffered: number;
@@ -89,21 +71,20 @@ interface TransportOptions {
89
71
  maxMs: number;
90
72
  maxAttempts: number;
91
73
  };
92
- onAck?: (ack: EvidenceAck) => void;
93
- onError?: (err: Error) => void;
94
- onChainHalted?: (err: ChainRejectedError) => void;
95
- setTimeout?: typeof globalThis.setTimeout;
96
- clearTimeout?: typeof globalThis.clearTimeout;
97
74
  }
98
- declare const DEFAULT_TRANSPORT: TransportOptions;
75
+ interface TransportOptions extends TransportTuning {
76
+ onError?: ((err: Error) => void) | undefined;
77
+ onChainHalted?: ((err: ChainRejectedError) => void) | undefined;
78
+ }
99
79
  declare class ChainRejectedError extends Error {
100
80
  readonly sessionId: string;
101
81
  readonly source: string;
102
82
  readonly result: EventResult;
103
- constructor(sessionId: string, source: string, result: EventResult);
104
- }
105
- declare class TransportClosedError extends Error {
106
- constructor();
83
+ constructor(sessionId: string, source: string, result: EventResult, options?: {
84
+ cause?: unknown;
85
+ });
86
+ /** Halted by retries exhausted on an outage — not by anything the platform rejected (GAP-70). */
87
+ get transient(): boolean;
107
88
  }
108
89
  declare class Transport {
109
90
  private readonly api;
@@ -115,6 +96,14 @@ declare class Transport {
115
96
  private inFlightCount;
116
97
  private drainWaiters;
117
98
  constructor(api: ApiClient, opts?: Partial<TransportOptions>);
99
+ /**
100
+ * What `failOpen` may absorb (GAP-70): the platform could not be reached
101
+ * or failed on its side — a network error, a 5xx, a 429, or a chain
102
+ * halted after exhausting its retries on those. Everything the platform
103
+ * *rejected* (a 4xx: bad key, unknown session, invalid payload; a `fork`
104
+ * or `rejected` ack) is a fault of the client and throws in both modes.
105
+ */
106
+ static outage(err: unknown): boolean;
118
107
  get size(): number;
119
108
  hasRoom(): boolean;
120
109
  haltedError(sessionId: string, source: string): ChainRejectedError | null;
@@ -146,63 +135,59 @@ declare class Transport {
146
135
  * A host that runs its own agent loop takes `beltic.run(key)` — a `Run`
147
136
  * keyed by its own session id that owns spans, verdicts and the mandate
148
137
  * (GAP-79); every integration above accepts a `Run` where it accepts a
149
- * `Session`. `Beltic.fromEnv()` reads `BELTIC_*` and, when none is set,
150
- * answers a disabled client that records nothing and never throws into
151
- * the work (GAP-78), so a host wires Beltic unconditionally.
138
+ * `Session`. `Beltic.fromEnv()` reads `BELTIC_*`; a client is configured
139
+ * or it is not constructed — there is no disabled client (GAP-78).
152
140
  *
153
- * Evidence is a side channel of the work it observes. With `failOpen`
154
- * nothing the SDK does throws into that work: `Session.emit` reports and
141
+ * Evidence is a side channel of the work it observes. With `failOpen` a
142
+ * platform outage never throws into that work: `Session.emit` reports and
155
143
  * answers `false`, `sessions.open` answers `null`, `evaluate` answers
156
144
  * `null` — never an invented verdict; the host decides what to do without
157
- * one (GAP-70). `sessions.start` and `sessions.ensure` throw either way:
158
- * they are the primitives the fail-open entries are built on.
145
+ * one. What the platform *rejects* (a 4xx, a forked chain) is the client's
146
+ * fault and throws in both modes (GAP-70). `sessions.start` and
147
+ * `sessions.ensure` throw either way: they are the primitives the fail-open
148
+ * entries are built on.
159
149
  */
160
150
 
161
- declare const SDK_VERSION = "0.4.0";
151
+ declare const SDK_VERSION = "0.5.0";
162
152
  type Env = Record<string, string | undefined>;
163
- interface BelticOptions extends Omit<ApiClientOptions, 'userAgent'> {
164
- /** Buyer half. Without it, `sessions.start` is unavailable; the seller half works. */
153
+ interface BelticOptions {
154
+ apiKey: string;
155
+ baseUrl: string;
156
+ fetch?: typeof globalThis.fetch | undefined;
157
+ /** Buyer half. Without it, `sessions.start` and `open` are unavailable; the seller half works. */
165
158
  identity?: AgentIdentity | undefined;
166
- transport?: Partial<TransportOptions> | undefined;
159
+ transport?: Partial<TransportTuning> | undefined;
167
160
  /** What a synchronous seller hook does with REVIEW (GAP-52). */
168
161
  onReview?: OnReview | undefined;
169
- correlation?: CorrelationStore | undefined;
170
- redact?: RedactFn | undefined;
171
- now?: (() => Date) | undefined;
172
- /** Evidence never fails the work it observes; see the module note (GAP-70). */
162
+ /** A platform outage never fails the work evidence observes; see the module note (GAP-70). */
173
163
  failOpen?: boolean | undefined;
174
- /** Where fail-open failures go (and transport delivery failures unless `transport` names its own). Default: `console.error`. */
164
+ /** Where fail-open failures and transport delivery failures go. Default: `console.error`. */
175
165
  onError?: ((err: Error) => void) | undefined;
176
- /** Fail-open only: how long `sessions.open` answers null after the platform refused to open a session (GAP-71). */
166
+ /** Fail-open only: how long `sessions.open` answers null after the platform could not open a session (GAP-71). */
177
167
  openRetryMs?: number | undefined;
178
- /** `false` is what `Beltic.disabled()` sets: no platform is ever called (GAP-78). */
179
- enabled?: boolean | undefined;
180
168
  }
169
+ /** What `fromEnv` takes besides the environment: everything the variables do not say. */
170
+ type FromEnvOptions = Omit<BelticOptions, 'apiKey' | 'baseUrl' | 'identity'>;
181
171
  /** The platform's answer, with the verdict as a value the caller can ask `blocks(onReview)`. */
182
172
  type Evaluation = EvaluateOutput & {
183
173
  verdict: Verdict;
184
174
  };
185
175
  declare class Beltic {
186
- readonly api: ApiClient;
187
176
  readonly transport: Transport;
188
177
  readonly sessions: Sessions;
189
178
  readonly identity: AgentIdentity | undefined;
190
- readonly correlation: CorrelationStore;
191
179
  readonly onReview: OnReview;
192
180
  readonly failOpen: boolean;
193
- /** `false` for a disabled client (GAP-78): nothing is posted, `run`/`sessions.open` answer without a session. */
194
- readonly enabled: boolean;
181
+ private readonly api;
195
182
  private readonly onError;
196
183
  private readonly runs;
197
184
  /**
198
185
  * The client the environment describes: `BELTIC_API_KEY`,
199
186
  * `BELTIC_BASE_URL`, `BELTIC_AGENT_SEED` (64 hex) and optionally
200
- * `BELTIC_AGENT_CREDENTIAL`, fail-open by default. None set → a disabled
201
- * client; some set → a configuration error, thrown (GAP-78).
187
+ * `BELTIC_AGENT_CREDENTIAL`. Any of the three missing is a configuration
188
+ * error, thrown (GAP-78).
202
189
  */
203
- static fromEnv(env?: Env, opts?: Partial<BelticOptions>): Beltic;
204
- /** A client that records nothing and never throws into the work: the null object for "no evidence stream" (GAP-78). */
205
- static disabled(opts?: Partial<BelticOptions>): Beltic;
190
+ static fromEnv(env?: Env, opts?: FromEnvOptions): Beltic;
206
191
  constructor(opts: BelticOptions);
207
192
  /**
208
193
  * The platform's verdict on a payment — the seller's before it verifies,
@@ -210,7 +195,7 @@ declare class Beltic {
210
195
  * is flushed first so the platform judges what the caller already saw
211
196
  * (GAP-16). A recorded moment is accepted as is: only its comparable core
212
197
  * (payee, amount, payer) is sent. `null` only under `failOpen`, when the
213
- * platform could not be asked.
198
+ * platform could not be reached.
214
199
  */
215
200
  evaluate(sessionId: string, payment: PaymentSummary | PaymentMomentPayload): Promise<Evaluation | null>;
216
201
  private decide;
@@ -224,7 +209,6 @@ declare class Beltic {
224
209
  /** `process.env` where there is a `process` (Node); `{}` on workerd, where the shell passes its `env`. */
225
210
  private static processEnv;
226
211
  }
227
- declare function createBeltic(opts: BelticOptions): Beltic;
228
212
 
229
213
  /**
230
214
  * The platform's verdict on one payment as a value the host can ask
@@ -346,26 +330,24 @@ declare class Run {
346
330
  *
347
331
  * `seq` is handed out only when the transport has room for the event
348
332
  * (GAP-38): a dropped event never leaves a hole — the next accepted event
349
- * is preceded by a `transport.gap` that counts the drops. `redact` is off
350
- * by default (GAP-33).
333
+ * is preceded by a `transport.gap` that counts the drops. Payloads ship
334
+ * whole (GAP-33).
351
335
  *
352
336
  * Evidence is a side channel of the agent's work: with `failOpen` an emit
353
- * that cannot be chained (halted chain, closed transport) is reported and
354
- * returns `false` instead of throwing into the model or tool call it
355
- * observes (GAP-70).
337
+ * refused because the platform is unreachable is reported and returns
338
+ * `false` instead of throwing into the model or tool call it observes;
339
+ * anything the platform rejected still throws (GAP-70).
356
340
  */
357
341
 
358
- type RedactFn = (kind: WireEvidenceKind, payload: JsonObject) => JsonObject;
359
342
  /** Who created the session — the seller half treats a bound session as buyer-born. */
360
343
  type SessionBorn = 'buyer' | 'seller';
361
344
  interface SessionDeps {
362
345
  transport: Transport;
363
346
  signer?: Signer | undefined;
364
- redact?: RedactFn | undefined;
365
347
  now?: (() => Date) | undefined;
366
348
  /** Called once the session closed, so the registry can forget it. */
367
349
  onClosed?: ((session: Session) => void) | undefined;
368
- /** Report instead of throw when an event cannot be chained (GAP-70). */
350
+ /** Report instead of throw when the platform is unreachable (GAP-70). */
369
351
  failOpen?: boolean | undefined;
370
352
  onError?: ((err: Error) => void) | undefined;
371
353
  }
@@ -405,7 +387,7 @@ declare class Session {
405
387
  /**
406
388
  * Resolves once the event is sequenced and buffered — not once it is
407
389
  * acknowledged. `false` when the event was dropped, or (fail-open) when
408
- * the chain can no longer take it.
390
+ * the chain halted on an outage.
409
391
  */
410
392
  emit<K extends WireEvidenceKind>(kind: K, payload: PayloadByKind[K]): Promise<boolean>;
411
393
  /** The tool call whose `execute` the host runs itself; see `ToolCallSpan`. */
@@ -428,22 +410,17 @@ interface StartSessionInput {
428
410
  /** What `open` sends when it actually opens: a value, or a resolver run only then. */
429
411
  type OpenSessionInput = StartSessionInput | (() => StartSessionInput | Promise<StartSessionInput>);
430
412
  /** What an integration takes: a session, or the run that owns one — resolved by `Sessions.resolve`. */
431
- type SessionSource = Session | Run | null | undefined;
413
+ type SessionSource = Session | Run;
432
414
  interface SessionsDeps {
433
415
  api: ApiClient;
434
416
  transport: Transport;
435
- /** A disabled client (GAP-78): `open` answers null, `start`/`ensure` throw, nothing is posted. */
436
- enabled?: boolean | undefined;
437
417
  identity?: AgentIdentity | undefined;
438
- redact?: RedactFn | undefined;
439
- now?: (() => Date) | undefined;
440
418
  sdkVersion: string;
441
419
  failOpen?: boolean | undefined;
442
420
  onError?: ((err: Error) => void) | undefined;
443
- /** Fail-open only: after the platform refused to open a session, `open` resolves null for this long (GAP-71). */
421
+ /** Fail-open only: after the platform could not open a session, `open` resolves null for this long (GAP-71). */
444
422
  openRetryMs?: number | undefined;
445
423
  }
446
- declare const DEFAULT_OPEN_RETRY_MS = 60000;
447
424
  declare class Sessions {
448
425
  private readonly deps;
449
426
  /**
@@ -457,17 +434,18 @@ declare class Sessions {
457
434
  private readonly opened;
458
435
  private retryAt;
459
436
  constructor(deps: SessionsDeps);
460
- /** The session behind a source: itself, or the one the run opens (null when there is none). */
437
+ /** The session behind a source: itself, or the one the run opens (null when the run has none). */
461
438
  static resolve(source: SessionSource): Promise<Session | null>;
462
439
  /**
463
440
  * Buyer half: the evidence session for a key of the host's own (its
464
441
  * session, run or conversation id), opened on first use and reused
465
442
  * after. A halted chain is reopened as a fresh session that continues
466
- * the same key; a closed key is forgotten. When the platform refuses to
467
- * open one, a fail-open client resolves null — the host runs without
468
- * evidence — until `openRetryMs` has passed (GAP-71); otherwise the
469
- * refusal is thrown and the next call tries again. The identity is
470
- * required either way: that is configuration.
443
+ * the same key; a closed key is forgotten. When the platform cannot be
444
+ * reached, a fail-open client resolves null — the host runs without
445
+ * evidence — until `openRetryMs` has passed (GAP-71); otherwise, and
446
+ * whenever the platform refused, the error is thrown and the next call
447
+ * tries again. The identity is configuration: missing, it throws either
448
+ * way.
471
449
  */
472
450
  open(key: string, input?: OpenSessionInput): Promise<Session | null>;
473
451
  private forget;
@@ -481,4 +459,4 @@ declare class Sessions {
481
459
  private attach;
482
460
  }
483
461
 
484
- export { type AgentIdentity as A, Beltic as B, ChainRejectedError as C, DEFAULT_OPEN_RETRY_MS as D, type Env as E, type HumanDecisionInput as H, MemoryCorrelationStore as M, type OpenSessionInput as O, type RedactFn as R, type SessionSource as S, type ToolCallSpan as T, Session as a, ApiClient as b, type ApiClientOptions as c, BelticApiError as d, type BelticOptions as e, type CorrelationStore as f, DEFAULT_TRANSPORT as g, type DecideOptions as h, Decision as i, type Evaluation as j, Run as k, type RunOptions as l, SDK_VERSION as m, type SessionBorn as n, Sessions as o, type StartSessionInput as p, Transport as q, TransportClosedError as r, type TransportOptions as s, createBeltic as t, ephemeralIdentity as u, fileIdentity as v, identityFromSeed as w };
462
+ export { type AgentIdentity as A, Beltic as B, ChainRejectedError as C, type DecideOptions as D, type Env as E, type FromEnvOptions as F, type HumanDecisionInput as H, type OpenSessionInput as O, Run as R, type SessionSource as S, type ToolCallSpan as T, ApiClient as a, type ApiClientOptions as b, BelticApiError as c, type BelticOptions as d, Decision as e, type Evaluation as f, type RunOptions as g, SDK_VERSION as h, Session as i, type SessionBorn as j, Sessions as k, type StartSessionInput as l, Transport as m, type TransportOptions as n, type TransportTuning as o, identityFromSeed as p };
@@ -552,4 +552,4 @@ declare class Verdict {
552
552
  effective(onReview: OnReview): Decision;
553
553
  }
554
554
 
555
- export { type LlmCallEndPayload as $, ALL_SOURCES as A, type EventResultStatus as B, type ChainHead as C, type Decision as D, type EvidenceSourceAll as E, EventResultStatusSchema as F, type EvidenceAck as G, EvidenceAckSchema as H, type EvidenceBatchInput as I, type JsonObject as J, EvidenceBatchInputSchema as K, type EvidenceEnvelope as L, type EvidenceEvent as M, EvidenceEventSchema as N, type EvidenceKind as O, type PaymentMomentPayload as P, EvidenceKindSchema as Q, type EvidenceSource as R, EvidenceSourceAllSchema as S, EvidenceSourceSchema as T, type GatewayDecisionPayload as U, GatewayDecisionPayloadSchema as V, type Hex64 as W, Hex64Schema as X, type IntentDeclaredPayload as Y, IntentDeclaredPayloadSchema as Z, JsonValueSchema as _, type PaymentSummary as a, LlmCallEndPayloadSchema as a0, type LlmCallStartPayload as a1, LlmCallStartPayloadSchema as a2, MAX_BATCH_EVENTS as a3, type OnReview as a4, PAYMENT_ARTIFACTS as a5, PLATFORM_KINDS as a6, type PayloadByKind as a7, PaymentMomentPayloadSchema as a8, PaymentSummarySchema as a9, type WireEvidenceKind as aA, WireEvidenceKindSchema as aB, compareBySessionSource as aC, compareBySourceSeq as aD, isPlatformKind as aE, isWireKind as aF, payloadSchemaFor as aG, type PlatformAnomalyPayload as aa, PlatformAnomalyPayloadSchema as ab, type PlatformEvidenceKind as ac, PlatformEvidenceKindSchema as ad, type PlatformObservationPayload as ae, PlatformObservationPayloadSchema as af, SESSION_CLOSE_REASONS as ag, SOURCE_ORDER as ah, SeqSchema as ai, type SessionClosePayload as aj, SessionClosePayloadSchema as ak, SessionIdSchema as al, type SessionOpenPayload as am, SessionOpenPayloadSchema as an, type Sig as ao, SigSchema as ap, TimestampSchema as aq, type ToolCallEndPayload as ar, ToolCallEndPayloadSchema as as, type ToolCallStartPayload as at, ToolCallStartPayloadSchema as au, type TransportGapPayload as av, TransportGapPayloadSchema as aw, Verdict as ax, WIRE_KINDS as ay, WIRE_SOURCES as az, type JsonValue as b, ANOMALY_TYPES as c, type Amount as d, AmountSchema as e, type ApiError as f, ApiErrorSchema as g, ChainHeadSchema as h, type CreatePolicyInput as i, CreatePolicyInputSchema as j, type CreatePolicyOutput as k, CreatePolicyOutputSchema as l, type CreateSessionInput as m, CreateSessionInputSchema as n, type CreateSessionOutput as o, CreateSessionOutputSchema as p, DecisionSchema as q, type DeclaredIntent as r, DeclaredIntentSchema as s, type DigestedEnvelope as t, type EvaluateInput as u, EvaluateInputSchema as v, type EvaluateOutput as w, EvaluateOutputSchema as x, type EventResult as y, EventResultSchema as z };
555
+ export { LlmCallEndPayloadSchema as $, ALL_SOURCES as A, type EvidenceAck as B, type ChainHead as C, type Decision as D, type EvidenceSourceAll as E, EvidenceAckSchema as F, type EvidenceBatchInput as G, EvidenceBatchInputSchema as H, type EvidenceEnvelope as I, type JsonValue as J, type EvidenceEvent as K, EvidenceEventSchema as L, type EvidenceKind as M, EvidenceKindSchema as N, type EvidenceSource as O, type PaymentMomentPayload as P, EvidenceSourceAllSchema as Q, EvidenceSourceSchema as R, type GatewayDecisionPayload as S, GatewayDecisionPayloadSchema as T, type Hex64 as U, Hex64Schema as V, type IntentDeclaredPayload as W, IntentDeclaredPayloadSchema as X, type JsonObject as Y, JsonValueSchema as Z, type LlmCallEndPayload as _, ANOMALY_TYPES as a, type LlmCallStartPayload as a0, LlmCallStartPayloadSchema as a1, MAX_BATCH_EVENTS as a2, type OnReview as a3, PAYMENT_ARTIFACTS as a4, PLATFORM_KINDS as a5, type PayloadByKind as a6, PaymentMomentPayloadSchema as a7, type PaymentSummary as a8, PaymentSummarySchema as a9, type WireEvidenceKind as aA, WireEvidenceKindSchema as aB, compareBySessionSource as aC, compareBySourceSeq as aD, isPlatformKind as aE, isWireKind as aF, payloadSchemaFor as aG, type PlatformAnomalyPayload as aa, PlatformAnomalyPayloadSchema as ab, type PlatformEvidenceKind as ac, PlatformEvidenceKindSchema as ad, type PlatformObservationPayload as ae, PlatformObservationPayloadSchema as af, SESSION_CLOSE_REASONS as ag, SOURCE_ORDER as ah, SeqSchema as ai, type SessionClosePayload as aj, SessionClosePayloadSchema as ak, SessionIdSchema as al, type SessionOpenPayload as am, SessionOpenPayloadSchema as an, type Sig as ao, SigSchema as ap, TimestampSchema as aq, type ToolCallEndPayload as ar, ToolCallEndPayloadSchema as as, type ToolCallStartPayload as at, ToolCallStartPayloadSchema as au, type TransportGapPayload as av, TransportGapPayloadSchema as aw, Verdict as ax, WIRE_KINDS as ay, WIRE_SOURCES as az, type Amount as b, AmountSchema as c, type ApiError as d, ApiErrorSchema as e, ChainHeadSchema as f, type CreatePolicyInput as g, CreatePolicyInputSchema as h, type CreatePolicyOutput as i, CreatePolicyOutputSchema as j, type CreateSessionInput as k, CreateSessionInputSchema as l, type CreateSessionOutput as m, CreateSessionOutputSchema as n, DecisionSchema as o, type DeclaredIntent as p, DeclaredIntentSchema as q, type DigestedEnvelope as r, type EvaluateInput as s, EvaluateInputSchema as t, type EvaluateOutput as u, EvaluateOutputSchema as v, type EventResult as w, EventResultSchema as x, type EventResultStatus as y, EventResultStatusSchema as z };
@@ -1,9 +1,9 @@
1
1
  import { PaywallConfig, RoutesConfig, x402ResourceServer } from '@x402/core/server';
2
2
  import { MiddlewareHandler } from 'hono';
3
- import { B as Beltic } from '../session-gK51QVAM.js';
4
- import { A as AttachOptions } from '../adapter-CLy44CD2.js';
5
- export { a as attachX402 } from '../adapter-CLy44CD2.js';
6
- import '../verdict-CDAsxktI.js';
3
+ import { B as Beltic } from '../session-D9E-efc0.js';
4
+ import { A as AttachOptions } from '../adapter-DEdhsNt-.js';
5
+ export { a as attachX402 } from '../adapter-DEdhsNt-.js';
6
+ import '../verdict-DMnbFuS5.js';
7
7
  import 'zod';
8
8
 
9
9
  /**
package/dist/x402/hono.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  attachX402
3
- } from "../chunk-WY5ZX4BD.js";
3
+ } from "../chunk-GM4KEEZB.js";
4
4
  import "../chunk-FQDHFTVR.js";
5
5
  import "../chunk-X3W2Z5GC.js";
6
6
 
@@ -1,6 +1,6 @@
1
- export { A as AttachOptions, b as AttachedX402, C as CorrelationContext, a as attachX402 } from '../adapter-CLy44CD2.js';
2
- import { S as SessionSource } from '../session-gK51QVAM.js';
3
- import { r as DeclaredIntent, P as PaymentMomentPayload, J as JsonObject, a as PaymentSummary } from '../verdict-CDAsxktI.js';
1
+ export { A as AttachOptions, b as AttachedX402, a as attachX402 } from '../adapter-DEdhsNt-.js';
2
+ import { S as SessionSource } from '../session-D9E-efc0.js';
3
+ import { p as DeclaredIntent, P as PaymentMomentPayload, Y as JsonObject, a8 as PaymentSummary } from '../verdict-DMnbFuS5.js';
4
4
  import '@x402/core/server';
5
5
  import 'zod';
6
6
 
@@ -18,11 +18,9 @@ declare function sessionIdOf(extensions: Readonly<Record<string, unknown>> | und
18
18
  declare function decisionIdOf(extensions: Readonly<Record<string, unknown>> | undefined): string | null;
19
19
 
20
20
  /**
21
- * The paying fetch, observed. Takes a session or the run that owns one;
22
- * without either (the evidence stream is not configured, or the platform
23
- * refused to open one) the inner fetch is returned as is — or runs as is
24
- * per request when the run has no session yet — so a host wires it
25
- * unconditionally.
21
+ * The paying fetch, observed. Takes a session or the run that owns one; a
22
+ * request made while a fail-open run has no session (the platform could
23
+ * not open one, GAP-70) goes through the inner fetch unrecorded.
26
24
  */
27
25
  declare function belticFetch(source: SessionSource, inner?: typeof globalThis.fetch): typeof globalThis.fetch;
28
26
 
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  Session,
3
3
  Sessions
4
- } from "../chunk-4MG6VNAU.js";
4
+ } from "../chunk-JSE6JQJC.js";
5
5
  import {
6
6
  DECISION_EXTENSION,
7
7
  SESSION_EXTENSION,
@@ -13,14 +13,13 @@ import {
13
13
  x402Currency,
14
14
  x402Moments,
15
15
  x402Summary
16
- } from "../chunk-WY5ZX4BD.js";
16
+ } from "../chunk-GM4KEEZB.js";
17
17
  import "../chunk-FQDHFTVR.js";
18
18
  import "../chunk-X3W2Z5GC.js";
19
19
 
20
20
  // src/x402/fetch.ts
21
21
  var BASE64 = /^[A-Za-z0-9+/]*={0,2}$/;
22
22
  function belticFetch(source, inner = globalThis.fetch) {
23
- if (!source) return inner;
24
23
  const run = source instanceof Session ? null : source;
25
24
  return async (input, init) => {
26
25
  const session = await Sessions.resolve(source);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@belticlabs/agent-risk-sdk",
3
- "version": "0.4.0",
3
+ "version": "0.5.0",
4
4
  "description": "The Beltic Agent Risk SDK — one client, two halves: instrument the buyer agent (AI SDK, x402 fetch) and guard the seller boundary (x402 over hono, evaluate).",
5
5
  "license": "UNLICENSED",
6
6
  "repository": {