@belticlabs/agent-risk-sdk 0.3.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.
- package/dist/{adapter-BEpzr2R3.d.ts → adapter-DEdhsNt-.d.ts} +3 -10
- package/dist/ai/index.d.ts +2 -2
- package/dist/ai/index.js +6 -8
- package/dist/{chunk-46QN2KEZ.js → chunk-4BUUPU3O.js} +0 -9
- package/dist/chunk-GM4KEEZB.js +163 -0
- package/dist/chunk-JSE6JQJC.js +530 -0
- package/dist/index.d.ts +11 -33
- package/dist/index.js +40 -335
- package/dist/protocol/index.d.ts +2 -2
- package/dist/protocol/index.js +1 -5
- package/dist/{session-DsBWEP8d.d.ts → session-D9E-efc0.d.ts} +74 -97
- package/dist/{verdict-6vCyoAHE.d.ts → verdict-DMnbFuS5.d.ts} +1 -17
- package/dist/x402/hono.d.ts +16 -5
- package/dist/x402/hono.js +14 -8
- package/dist/x402/index.d.ts +15 -27
- package/dist/x402/index.js +15 -59
- package/package.json +2 -30
- package/dist/chunk-4MG6VNAU.js +0 -276
- package/dist/chunk-7G5EHNVW.js +0 -17
- package/dist/chunk-FAQ442YH.js +0 -24
- package/dist/chunk-LM4NIYE5.js +0 -92
- package/dist/chunk-NJVO2WIV.js +0 -17
- package/dist/chunk-OKC6VMFH.js +0 -84
- package/dist/mcp/index.d.ts +0 -58
- package/dist/mcp/index.js +0 -135
- package/dist/middleware-9gI0ou2i.d.ts +0 -15
- package/dist/seller/anti-fraud-gateway.d.ts +0 -40
- package/dist/seller/anti-fraud-gateway.js +0 -38
- package/dist/x402/express.d.ts +0 -13
- package/dist/x402/express.js +0 -27
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import {
|
|
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);
|
|
5
|
-
* the platform signs its own PLATFORM chain
|
|
6
|
-
*
|
|
5
|
+
* the platform signs its own PLATFORM chain. Both are the same operation
|
|
6
|
+
* over different keys, so one interface.
|
|
7
7
|
*/
|
|
8
8
|
interface Signer {
|
|
9
9
|
/** Raw 32-byte Ed25519 public key. */
|
|
@@ -16,9 +16,8 @@ interface Signer {
|
|
|
16
16
|
interface ApiClientOptions {
|
|
17
17
|
baseUrl: string;
|
|
18
18
|
apiKey: string;
|
|
19
|
-
fetch?: typeof globalThis.fetch;
|
|
20
|
-
|
|
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
|
|
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
|
-
|
|
83
|
-
|
|
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
|
-
|
|
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
|
-
|
|
106
|
-
|
|
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;
|
|
@@ -139,71 +128,66 @@ declare class Transport {
|
|
|
139
128
|
*
|
|
140
129
|
* @belticlabs/agent-risk-sdk/ai → middleware(session), wrapTools(session, …)
|
|
141
130
|
* @belticlabs/agent-risk-sdk/x402 → belticFetch(session), x402Summary(…), attachX402(beltic, …)
|
|
142
|
-
* @belticlabs/agent-risk-sdk/hono → belticPaymentMiddleware(beltic, …)
|
|
143
|
-
* @belticlabs/agent-risk-sdk/mcp → wrapClient(session, …), wrapServer(beltic, …)
|
|
131
|
+
* @belticlabs/agent-risk-sdk/hono → belticPaymentMiddleware(beltic, …)
|
|
144
132
|
*
|
|
145
133
|
* Neither half decides risk locally: verdicts are platform-side.
|
|
146
134
|
*
|
|
147
135
|
* A host that runs its own agent loop takes `beltic.run(key)` — a `Run`
|
|
148
136
|
* keyed by its own session id that owns spans, verdicts and the mandate
|
|
149
137
|
* (GAP-79); every integration above accepts a `Run` where it accepts a
|
|
150
|
-
* `Session`. `Beltic.fromEnv()` reads `BELTIC_
|
|
151
|
-
*
|
|
152
|
-
* 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).
|
|
153
140
|
*
|
|
154
|
-
* Evidence is a side channel of the work it observes. With `failOpen`
|
|
155
|
-
*
|
|
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
|
|
156
143
|
* answers `false`, `sessions.open` answers `null`, `evaluate` answers
|
|
157
144
|
* `null` — never an invented verdict; the host decides what to do without
|
|
158
|
-
* one (
|
|
159
|
-
*
|
|
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.
|
|
160
149
|
*/
|
|
161
150
|
|
|
162
|
-
declare const SDK_VERSION = "0.
|
|
151
|
+
declare const SDK_VERSION = "0.5.0";
|
|
163
152
|
type Env = Record<string, string | undefined>;
|
|
164
|
-
interface BelticOptions
|
|
165
|
-
|
|
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. */
|
|
166
158
|
identity?: AgentIdentity | undefined;
|
|
167
|
-
transport?: Partial<
|
|
159
|
+
transport?: Partial<TransportTuning> | undefined;
|
|
168
160
|
/** What a synchronous seller hook does with REVIEW (GAP-52). */
|
|
169
161
|
onReview?: OnReview | undefined;
|
|
170
|
-
|
|
171
|
-
redact?: RedactFn | undefined;
|
|
172
|
-
now?: (() => Date) | undefined;
|
|
173
|
-
/** 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). */
|
|
174
163
|
failOpen?: boolean | undefined;
|
|
175
|
-
/** Where fail-open failures
|
|
164
|
+
/** Where fail-open failures and transport delivery failures go. Default: `console.error`. */
|
|
176
165
|
onError?: ((err: Error) => void) | undefined;
|
|
177
|
-
/** Fail-open only: how long `sessions.open` answers null after the platform
|
|
166
|
+
/** Fail-open only: how long `sessions.open` answers null after the platform could not open a session (GAP-71). */
|
|
178
167
|
openRetryMs?: number | undefined;
|
|
179
|
-
/** `false` is what `Beltic.disabled()` sets: no platform is ever called (GAP-78). */
|
|
180
|
-
enabled?: boolean | undefined;
|
|
181
168
|
}
|
|
169
|
+
/** What `fromEnv` takes besides the environment: everything the variables do not say. */
|
|
170
|
+
type FromEnvOptions = Omit<BelticOptions, 'apiKey' | 'baseUrl' | 'identity'>;
|
|
182
171
|
/** The platform's answer, with the verdict as a value the caller can ask `blocks(onReview)`. */
|
|
183
172
|
type Evaluation = EvaluateOutput & {
|
|
184
173
|
verdict: Verdict;
|
|
185
174
|
};
|
|
186
175
|
declare class Beltic {
|
|
187
|
-
readonly api: ApiClient;
|
|
188
176
|
readonly transport: Transport;
|
|
189
177
|
readonly sessions: Sessions;
|
|
190
178
|
readonly identity: AgentIdentity | undefined;
|
|
191
|
-
readonly correlation: CorrelationStore;
|
|
192
179
|
readonly onReview: OnReview;
|
|
193
180
|
readonly failOpen: boolean;
|
|
194
|
-
|
|
195
|
-
readonly enabled: boolean;
|
|
181
|
+
private readonly api;
|
|
196
182
|
private readonly onError;
|
|
197
183
|
private readonly runs;
|
|
198
184
|
/**
|
|
199
185
|
* The client the environment describes: `BELTIC_API_KEY`,
|
|
200
186
|
* `BELTIC_BASE_URL`, `BELTIC_AGENT_SEED` (64 hex) and optionally
|
|
201
|
-
* `BELTIC_AGENT_CREDENTIAL
|
|
202
|
-
*
|
|
187
|
+
* `BELTIC_AGENT_CREDENTIAL`. Any of the three missing is a configuration
|
|
188
|
+
* error, thrown (GAP-78).
|
|
203
189
|
*/
|
|
204
|
-
static fromEnv(env?: Env, opts?:
|
|
205
|
-
/** A client that records nothing and never throws into the work: the null object for "no evidence stream" (GAP-78). */
|
|
206
|
-
static disabled(opts?: Partial<BelticOptions>): Beltic;
|
|
190
|
+
static fromEnv(env?: Env, opts?: FromEnvOptions): Beltic;
|
|
207
191
|
constructor(opts: BelticOptions);
|
|
208
192
|
/**
|
|
209
193
|
* The platform's verdict on a payment — the seller's before it verifies,
|
|
@@ -211,7 +195,7 @@ declare class Beltic {
|
|
|
211
195
|
* is flushed first so the platform judges what the caller already saw
|
|
212
196
|
* (GAP-16). A recorded moment is accepted as is: only its comparable core
|
|
213
197
|
* (payee, amount, payer) is sent. `null` only under `failOpen`, when the
|
|
214
|
-
* platform could not be
|
|
198
|
+
* platform could not be reached.
|
|
215
199
|
*/
|
|
216
200
|
evaluate(sessionId: string, payment: PaymentSummary | PaymentMomentPayload): Promise<Evaluation | null>;
|
|
217
201
|
private decide;
|
|
@@ -225,7 +209,6 @@ declare class Beltic {
|
|
|
225
209
|
/** `process.env` where there is a `process` (Node); `{}` on workerd, where the shell passes its `env`. */
|
|
226
210
|
private static processEnv;
|
|
227
211
|
}
|
|
228
|
-
declare function createBeltic(opts: BelticOptions): Beltic;
|
|
229
212
|
|
|
230
213
|
/**
|
|
231
214
|
* The platform's verdict on one payment as a value the host can ask
|
|
@@ -347,26 +330,24 @@ declare class Run {
|
|
|
347
330
|
*
|
|
348
331
|
* `seq` is handed out only when the transport has room for the event
|
|
349
332
|
* (GAP-38): a dropped event never leaves a hole — the next accepted event
|
|
350
|
-
* is preceded by a `transport.gap` that counts the drops.
|
|
351
|
-
*
|
|
333
|
+
* is preceded by a `transport.gap` that counts the drops. Payloads ship
|
|
334
|
+
* whole (GAP-33).
|
|
352
335
|
*
|
|
353
336
|
* Evidence is a side channel of the agent's work: with `failOpen` an emit
|
|
354
|
-
*
|
|
355
|
-
*
|
|
356
|
-
*
|
|
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).
|
|
357
340
|
*/
|
|
358
341
|
|
|
359
|
-
type RedactFn = (kind: WireEvidenceKind, payload: JsonObject) => JsonObject;
|
|
360
342
|
/** Who created the session — the seller half treats a bound session as buyer-born. */
|
|
361
343
|
type SessionBorn = 'buyer' | 'seller';
|
|
362
344
|
interface SessionDeps {
|
|
363
345
|
transport: Transport;
|
|
364
346
|
signer?: Signer | undefined;
|
|
365
|
-
redact?: RedactFn | undefined;
|
|
366
347
|
now?: (() => Date) | undefined;
|
|
367
348
|
/** Called once the session closed, so the registry can forget it. */
|
|
368
349
|
onClosed?: ((session: Session) => void) | undefined;
|
|
369
|
-
/** Report instead of throw when
|
|
350
|
+
/** Report instead of throw when the platform is unreachable (GAP-70). */
|
|
370
351
|
failOpen?: boolean | undefined;
|
|
371
352
|
onError?: ((err: Error) => void) | undefined;
|
|
372
353
|
}
|
|
@@ -406,7 +387,7 @@ declare class Session {
|
|
|
406
387
|
/**
|
|
407
388
|
* Resolves once the event is sequenced and buffered — not once it is
|
|
408
389
|
* acknowledged. `false` when the event was dropped, or (fail-open) when
|
|
409
|
-
* the chain
|
|
390
|
+
* the chain halted on an outage.
|
|
410
391
|
*/
|
|
411
392
|
emit<K extends WireEvidenceKind>(kind: K, payload: PayloadByKind[K]): Promise<boolean>;
|
|
412
393
|
/** The tool call whose `execute` the host runs itself; see `ToolCallSpan`. */
|
|
@@ -429,22 +410,17 @@ interface StartSessionInput {
|
|
|
429
410
|
/** What `open` sends when it actually opens: a value, or a resolver run only then. */
|
|
430
411
|
type OpenSessionInput = StartSessionInput | (() => StartSessionInput | Promise<StartSessionInput>);
|
|
431
412
|
/** What an integration takes: a session, or the run that owns one — resolved by `Sessions.resolve`. */
|
|
432
|
-
type SessionSource = Session | Run
|
|
413
|
+
type SessionSource = Session | Run;
|
|
433
414
|
interface SessionsDeps {
|
|
434
415
|
api: ApiClient;
|
|
435
416
|
transport: Transport;
|
|
436
|
-
/** A disabled client (GAP-78): `open` answers null, `start`/`ensure` throw, nothing is posted. */
|
|
437
|
-
enabled?: boolean | undefined;
|
|
438
417
|
identity?: AgentIdentity | undefined;
|
|
439
|
-
redact?: RedactFn | undefined;
|
|
440
|
-
now?: (() => Date) | undefined;
|
|
441
418
|
sdkVersion: string;
|
|
442
419
|
failOpen?: boolean | undefined;
|
|
443
420
|
onError?: ((err: Error) => void) | undefined;
|
|
444
|
-
/** Fail-open only: after the platform
|
|
421
|
+
/** Fail-open only: after the platform could not open a session, `open` resolves null for this long (GAP-71). */
|
|
445
422
|
openRetryMs?: number | undefined;
|
|
446
423
|
}
|
|
447
|
-
declare const DEFAULT_OPEN_RETRY_MS = 60000;
|
|
448
424
|
declare class Sessions {
|
|
449
425
|
private readonly deps;
|
|
450
426
|
/**
|
|
@@ -458,17 +434,18 @@ declare class Sessions {
|
|
|
458
434
|
private readonly opened;
|
|
459
435
|
private retryAt;
|
|
460
436
|
constructor(deps: SessionsDeps);
|
|
461
|
-
/** The session behind a source: itself, or the one the run opens (null when
|
|
437
|
+
/** The session behind a source: itself, or the one the run opens (null when the run has none). */
|
|
462
438
|
static resolve(source: SessionSource): Promise<Session | null>;
|
|
463
439
|
/**
|
|
464
440
|
* Buyer half: the evidence session for a key of the host's own (its
|
|
465
441
|
* session, run or conversation id), opened on first use and reused
|
|
466
442
|
* after. A halted chain is reopened as a fresh session that continues
|
|
467
|
-
* the same key; a closed key is forgotten. When the platform
|
|
468
|
-
*
|
|
469
|
-
* evidence — until `openRetryMs` has passed (GAP-71); otherwise
|
|
470
|
-
*
|
|
471
|
-
*
|
|
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.
|
|
472
449
|
*/
|
|
473
450
|
open(key: string, input?: OpenSessionInput): Promise<Session | null>;
|
|
474
451
|
private forget;
|
|
@@ -482,4 +459,4 @@ declare class Sessions {
|
|
|
482
459
|
private attach;
|
|
483
460
|
}
|
|
484
461
|
|
|
485
|
-
export { type AgentIdentity as A, Beltic as B, ChainRejectedError as C,
|
|
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 };
|
|
@@ -318,22 +318,6 @@ declare const EvaluateOutputSchema: z.ZodObject<{
|
|
|
318
318
|
decisionId: z.ZodUUID;
|
|
319
319
|
}, z.core.$strict>;
|
|
320
320
|
type EvaluateOutput = z.infer<typeof EvaluateOutputSchema>;
|
|
321
|
-
declare const AnchorEntrySchema: z.ZodObject<{
|
|
322
|
-
epoch: z.ZodString;
|
|
323
|
-
root: z.ZodString;
|
|
324
|
-
sig: z.ZodString;
|
|
325
|
-
chainRef: z.ZodOptional<z.ZodString>;
|
|
326
|
-
}, z.core.$strict>;
|
|
327
|
-
type AnchorEntry = z.infer<typeof AnchorEntrySchema>;
|
|
328
|
-
declare const AnchorsOutputSchema: z.ZodObject<{
|
|
329
|
-
entries: z.ZodArray<z.ZodObject<{
|
|
330
|
-
epoch: z.ZodString;
|
|
331
|
-
root: z.ZodString;
|
|
332
|
-
sig: z.ZodString;
|
|
333
|
-
chainRef: z.ZodOptional<z.ZodString>;
|
|
334
|
-
}, z.core.$strict>>;
|
|
335
|
-
}, z.core.$strict>;
|
|
336
|
-
type AnchorsOutput = z.infer<typeof AnchorsOutputSchema>;
|
|
337
321
|
/** Non-RFC admin surface (GAP-53). */
|
|
338
322
|
declare const CreatePolicyInputSchema: z.ZodObject<{
|
|
339
323
|
rules: z.ZodObject<{
|
|
@@ -568,4 +552,4 @@ declare class Verdict {
|
|
|
568
552
|
effective(onReview: OnReview): Decision;
|
|
569
553
|
}
|
|
570
554
|
|
|
571
|
-
export {
|
|
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 };
|
package/dist/x402/hono.d.ts
CHANGED
|
@@ -1,11 +1,22 @@
|
|
|
1
|
-
import { RoutesConfig, x402ResourceServer } from '@x402/core/server';
|
|
1
|
+
import { PaywallConfig, RoutesConfig, x402ResourceServer } from '@x402/core/server';
|
|
2
2
|
import { MiddlewareHandler } from 'hono';
|
|
3
|
-
import { B as Beltic } from '../session-
|
|
4
|
-
import {
|
|
5
|
-
export { a as attachX402 } from '../adapter-
|
|
6
|
-
import '../verdict-
|
|
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
|
+
/**
|
|
10
|
+
* The seller half as one middleware: the framework's `@x402/*` payment
|
|
11
|
+
* middleware over an `x402HTTPResourceServer` with the Beltic hooks
|
|
12
|
+
* attached. `@belticlabs/agent-risk-sdk/hono` hands in its framework's
|
|
13
|
+
* `paymentMiddlewareFromHTTPServer`.
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
type GuardedMiddlewareOptions = AttachOptions & {
|
|
17
|
+
paywall?: PaywallConfig | undefined;
|
|
18
|
+
};
|
|
19
|
+
|
|
9
20
|
/** Seller half for hono: `@x402/hono`'s payment middleware with the Beltic hooks attached. */
|
|
10
21
|
|
|
11
22
|
declare function belticPaymentMiddleware(beltic: Beltic, routes: RoutesConfig, server: x402ResourceServer, opts?: GuardedMiddlewareOptions): MiddlewareHandler;
|
package/dist/x402/hono.js
CHANGED
|
@@ -1,17 +1,23 @@
|
|
|
1
|
-
import {
|
|
2
|
-
guardedPaymentMiddleware
|
|
3
|
-
} from "../chunk-NJVO2WIV.js";
|
|
4
1
|
import {
|
|
5
2
|
attachX402
|
|
6
|
-
} from "../chunk-
|
|
7
|
-
import "../chunk-FAQ442YH.js";
|
|
8
|
-
import "../chunk-X3W2Z5GC.js";
|
|
9
|
-
import "../chunk-46QN2KEZ.js";
|
|
10
|
-
import "../chunk-LM4NIYE5.js";
|
|
3
|
+
} from "../chunk-GM4KEEZB.js";
|
|
11
4
|
import "../chunk-FQDHFTVR.js";
|
|
5
|
+
import "../chunk-X3W2Z5GC.js";
|
|
12
6
|
|
|
13
7
|
// src/x402/hono.ts
|
|
14
8
|
import { paymentMiddlewareFromHTTPServer } from "@x402/hono";
|
|
9
|
+
|
|
10
|
+
// src/x402/middleware.ts
|
|
11
|
+
import {
|
|
12
|
+
x402HTTPResourceServer
|
|
13
|
+
} from "@x402/core/server";
|
|
14
|
+
function guardedPaymentMiddleware(fromHTTPServer, beltic, routes, server, opts = {}) {
|
|
15
|
+
const http = new x402HTTPResourceServer(server, routes);
|
|
16
|
+
attachX402(beltic, server, http, opts);
|
|
17
|
+
return fromHTTPServer(http, opts.paywall);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
// src/x402/hono.ts
|
|
15
21
|
function belticPaymentMiddleware(beltic, routes, server, opts) {
|
|
16
22
|
return guardedPaymentMiddleware(paymentMiddlewareFromHTTPServer, beltic, routes, server, opts);
|
|
17
23
|
}
|
package/dist/x402/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
export { A as AttachOptions, b as AttachedX402,
|
|
2
|
-
import { S as SessionSource } from '../session-
|
|
3
|
-
import {
|
|
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
|
|
|
@@ -14,16 +14,13 @@ import 'zod';
|
|
|
14
14
|
declare const SESSION_EXTENSION = "beltic.sessionId";
|
|
15
15
|
declare const SESSION_HEADER = "Beltic-Session-Id";
|
|
16
16
|
declare const DECISION_EXTENSION = "beltic.decisionId";
|
|
17
|
-
declare const DECISION_HEADER = "Beltic-Decision-Id";
|
|
18
17
|
declare function sessionIdOf(extensions: Readonly<Record<string, unknown>> | undefined): string | null;
|
|
19
18
|
declare function decisionIdOf(extensions: Readonly<Record<string, unknown>> | undefined): string | null;
|
|
20
19
|
|
|
21
20
|
/**
|
|
22
|
-
* The paying fetch, observed. Takes a session or the run that owns one;
|
|
23
|
-
*
|
|
24
|
-
*
|
|
25
|
-
* per request when the run has no session yet — so a host wires it
|
|
26
|
-
* 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.
|
|
27
24
|
*/
|
|
28
25
|
declare function belticFetch(source: SessionSource, inner?: typeof globalThis.fetch): typeof globalThis.fetch;
|
|
29
26
|
|
|
@@ -59,20 +56,19 @@ declare function x402Intent(input: X402IntentInput): DeclaredIntent;
|
|
|
59
56
|
declare function x402Currency(network: string, asset: string): string;
|
|
60
57
|
/**
|
|
61
58
|
* The minimum an `accepts` entry needs to become a moment; unknown parts
|
|
62
|
-
* are named, never dropped.
|
|
59
|
+
* are named, never dropped.
|
|
63
60
|
*/
|
|
64
61
|
interface AcceptsLike {
|
|
65
62
|
payTo?: string | undefined;
|
|
66
63
|
amount?: string | undefined;
|
|
67
|
-
maxAmountRequired?: string | undefined;
|
|
68
64
|
network?: string | undefined;
|
|
69
65
|
asset?: string | undefined;
|
|
70
66
|
}
|
|
71
67
|
/**
|
|
72
|
-
* A 402 challenge and a presented payment
|
|
73
|
-
*
|
|
74
|
-
*
|
|
75
|
-
*
|
|
68
|
+
* A 402 challenge and a presented payment, as far as a moment needs them.
|
|
69
|
+
* `@x402/core`'s `PaymentRequired` and `PaymentPayload` satisfy these
|
|
70
|
+
* structurally, so the seller adapter passes its typed values through and
|
|
71
|
+
* the buyer needs no `@x402/*` types.
|
|
76
72
|
*/
|
|
77
73
|
interface PaymentRequiredLike {
|
|
78
74
|
x402Version?: number | undefined;
|
|
@@ -81,8 +77,6 @@ interface PaymentRequiredLike {
|
|
|
81
77
|
interface PaymentPayloadLike {
|
|
82
78
|
x402Version?: number | undefined;
|
|
83
79
|
accepted?: AcceptsLike | undefined;
|
|
84
|
-
/** v1 names the network here, beside the payload, and nowhere else. */
|
|
85
|
-
network?: string | undefined;
|
|
86
80
|
payload?: Readonly<Record<string, unknown>> | undefined;
|
|
87
81
|
extensions?: Readonly<Record<string, unknown>> | undefined;
|
|
88
82
|
}
|
|
@@ -97,20 +91,14 @@ declare function x402Summary(accepts: AcceptsLike | undefined, opts?: {
|
|
|
97
91
|
/** The payer is scheme-specific; the common EVM shapes are read, anything else stays in `raw`. */
|
|
98
92
|
declare function payerOf(payload: PaymentPayloadLike): string | undefined;
|
|
99
93
|
declare const x402Moments: {
|
|
100
|
-
/** The 402 challenge as the buyer saw it,
|
|
94
|
+
/** The 402 challenge as the buyer saw it, from the `PAYMENT-REQUIRED` header. */
|
|
101
95
|
required(required: PaymentRequiredLike): PaymentMomentPayload;
|
|
102
96
|
/** The requirements the seller's resource server resolved for a request. */
|
|
103
97
|
requirements(req: AcceptsLike): PaymentMomentPayload;
|
|
104
98
|
/** A route's static `accepts` config, before any payment header exists. */
|
|
105
99
|
route(route: unknown, raw: JsonObject): PaymentMomentPayload;
|
|
106
|
-
/**
|
|
107
|
-
|
|
108
|
-
/**
|
|
109
|
-
* The signed payment the buyer presented. A v2 payload carries the
|
|
110
|
-
* requirement it accepted; a v1 payload does not, so the caller passes
|
|
111
|
-
* the `accepts` entry it answered.
|
|
112
|
-
*/
|
|
113
|
-
payload(payload: PaymentPayloadLike, accepts?: AcceptsLike | undefined): PaymentMomentPayload;
|
|
100
|
+
/** The signed payment the buyer presented, with the requirement it accepted. */
|
|
101
|
+
payload(payload: PaymentPayloadLike): PaymentMomentPayload;
|
|
114
102
|
};
|
|
115
103
|
|
|
116
|
-
export { type AcceptsLike, DECISION_EXTENSION,
|
|
104
|
+
export { type AcceptsLike, DECISION_EXTENSION, type PaymentPayloadLike, type PaymentRequiredLike, SESSION_EXTENSION, SESSION_HEADER, type X402IntentInput, belticFetch, decisionIdOf, payerOf, sessionIdOf, x402Currency, x402Intent, x402Moments, x402Summary };
|