@belticlabs/agent-risk-sdk 0.1.0 → 0.2.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-CF-cUYSA.d.ts +28 -0
- package/dist/ai/index.d.ts +6 -6
- package/dist/ai/index.js +4 -3
- package/dist/{chunk-GCKCAKHA.js → chunk-46QN2KEZ.js} +199 -33
- package/dist/chunk-GSH5APZW.js +39 -0
- package/dist/{chunk-U5Z5Z2BQ.js → chunk-LM4NIYE5.js} +26 -20
- package/dist/{chunk-YVMJ5CZX.js → chunk-SO6HPRJT.js} +10 -23
- package/dist/chunk-U7HM37CB.js +17 -0
- package/dist/client-C-mV_3A0.d.ts +91 -0
- package/dist/index-Bjs3BPPU.d.ts +547 -0
- package/dist/index.d.ts +10 -8
- package/dist/index.js +117 -16
- package/dist/mcp/index.d.ts +6 -5
- package/dist/mcp/index.js +11 -8
- package/dist/middleware-BwAYpBTl.d.ts +15 -0
- package/dist/protocol/index.d.ts +158 -0
- package/dist/protocol/index.js +152 -0
- package/dist/seller/anti-fraud-gateway.d.ts +14 -4
- package/dist/seller/anti-fraud-gateway.js +13 -14
- package/dist/{session-BMNB1N1g.d.ts → session-5TClPLI4.d.ts} +70 -4
- package/dist/verdict-BAahb5po.d.ts +26 -0
- package/dist/x402/express.d.ts +7 -6
- package/dist/x402/express.js +6 -5
- package/dist/x402/hono.d.ts +7 -6
- package/dist/x402/hono.js +6 -5
- package/dist/x402/index.d.ts +95 -19
- package/dist/x402/index.js +83 -32
- package/package.json +5 -1
- package/dist/chunk-5TWO73OD.js +0 -35
- package/dist/client-CVx9LgJC.d.ts +0 -63
- package/dist/middleware-_DSwvNIx.d.ts +0 -40
|
@@ -0,0 +1,547 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Wire contract — `EvidenceEvent` (Fraud SDK RFC › Wire contract).
|
|
5
|
+
*
|
|
6
|
+
* Evidence is the agent log shipped whole: full payloads, not summaries.
|
|
7
|
+
* Each event commits to its predecessor (`prevHash`), so a session's
|
|
8
|
+
* evidence is a per-(sessionId, source) chain and the chain head
|
|
9
|
+
* fingerprints all of it.
|
|
10
|
+
*
|
|
11
|
+
* `source` is provenance, not artifact type. `PLATFORM` exists only inside
|
|
12
|
+
* the platform (detector observations) and never travels this wire —
|
|
13
|
+
* GAP-08 names the internal kinds it carries.
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
declare const WIRE_SOURCES: readonly ["AGENT_TRACE", "INTERNAL_NETWORK"];
|
|
17
|
+
declare const ALL_SOURCES: readonly ["AGENT_TRACE", "INTERNAL_NETWORK", "PLATFORM"];
|
|
18
|
+
declare const EvidenceSourceSchema: z.ZodEnum<{
|
|
19
|
+
AGENT_TRACE: "AGENT_TRACE";
|
|
20
|
+
INTERNAL_NETWORK: "INTERNAL_NETWORK";
|
|
21
|
+
}>;
|
|
22
|
+
declare const EvidenceSourceAllSchema: z.ZodEnum<{
|
|
23
|
+
AGENT_TRACE: "AGENT_TRACE";
|
|
24
|
+
INTERNAL_NETWORK: "INTERNAL_NETWORK";
|
|
25
|
+
PLATFORM: "PLATFORM";
|
|
26
|
+
}>;
|
|
27
|
+
type EvidenceSource = z.infer<typeof EvidenceSourceSchema>;
|
|
28
|
+
type EvidenceSourceAll = z.infer<typeof EvidenceSourceAllSchema>;
|
|
29
|
+
/** Order used when a session root is built over its source roots (GAP-29). */
|
|
30
|
+
declare const SOURCE_ORDER: Record<EvidenceSourceAll, number>;
|
|
31
|
+
/** The one order evidence is ever listed in: by source (SOURCE_ORDER), then seq. */
|
|
32
|
+
declare function compareBySourceSeq(a: {
|
|
33
|
+
source: EvidenceSourceAll;
|
|
34
|
+
seq: number;
|
|
35
|
+
}, b: {
|
|
36
|
+
source: EvidenceSourceAll;
|
|
37
|
+
seq: number;
|
|
38
|
+
}): number;
|
|
39
|
+
/** Commitments across sessions: by sessionId, then source. */
|
|
40
|
+
declare function compareBySessionSource(a: {
|
|
41
|
+
sessionId: string;
|
|
42
|
+
source: EvidenceSourceAll;
|
|
43
|
+
}, b: {
|
|
44
|
+
sessionId: string;
|
|
45
|
+
source: EvidenceSourceAll;
|
|
46
|
+
}): number;
|
|
47
|
+
/**
|
|
48
|
+
* Kinds are protocol moments, not protocol artifacts. `transport.gap` is
|
|
49
|
+
* not in the RFC: it is how an SDK whose buffer overflowed says so without
|
|
50
|
+
* leaving a hole in the chain (GAP-38).
|
|
51
|
+
*/
|
|
52
|
+
declare const WIRE_KINDS: readonly ["session.open", "session.close", "intent.declared", "llm_call.start", "llm_call.end", "tool_call.start", "tool_call.end", "payment.requested", "payment.presented", "gateway.decision", "transport.gap"];
|
|
53
|
+
/** Written only by the platform itself (`observe()`, Collector anomalies). GAP-08. */
|
|
54
|
+
declare const PLATFORM_KINDS: readonly ["platform.observation", "platform.anomaly"];
|
|
55
|
+
declare const WireEvidenceKindSchema: z.ZodEnum<{
|
|
56
|
+
"session.open": "session.open";
|
|
57
|
+
"session.close": "session.close";
|
|
58
|
+
"intent.declared": "intent.declared";
|
|
59
|
+
"llm_call.start": "llm_call.start";
|
|
60
|
+
"llm_call.end": "llm_call.end";
|
|
61
|
+
"tool_call.start": "tool_call.start";
|
|
62
|
+
"tool_call.end": "tool_call.end";
|
|
63
|
+
"payment.requested": "payment.requested";
|
|
64
|
+
"payment.presented": "payment.presented";
|
|
65
|
+
"gateway.decision": "gateway.decision";
|
|
66
|
+
"transport.gap": "transport.gap";
|
|
67
|
+
}>;
|
|
68
|
+
declare const PlatformEvidenceKindSchema: z.ZodEnum<{
|
|
69
|
+
"platform.observation": "platform.observation";
|
|
70
|
+
"platform.anomaly": "platform.anomaly";
|
|
71
|
+
}>;
|
|
72
|
+
declare const EvidenceKindSchema: z.ZodEnum<{
|
|
73
|
+
"session.open": "session.open";
|
|
74
|
+
"session.close": "session.close";
|
|
75
|
+
"intent.declared": "intent.declared";
|
|
76
|
+
"llm_call.start": "llm_call.start";
|
|
77
|
+
"llm_call.end": "llm_call.end";
|
|
78
|
+
"tool_call.start": "tool_call.start";
|
|
79
|
+
"tool_call.end": "tool_call.end";
|
|
80
|
+
"payment.requested": "payment.requested";
|
|
81
|
+
"payment.presented": "payment.presented";
|
|
82
|
+
"gateway.decision": "gateway.decision";
|
|
83
|
+
"transport.gap": "transport.gap";
|
|
84
|
+
"platform.observation": "platform.observation";
|
|
85
|
+
"platform.anomaly": "platform.anomaly";
|
|
86
|
+
}>;
|
|
87
|
+
type WireEvidenceKind = z.infer<typeof WireEvidenceKindSchema>;
|
|
88
|
+
type PlatformEvidenceKind = z.infer<typeof PlatformEvidenceKindSchema>;
|
|
89
|
+
type EvidenceKind = z.infer<typeof EvidenceKindSchema>;
|
|
90
|
+
/** 32-byte digest, exactly 64 lowercase hex chars (GAP-03). Uppercase is rejected on purpose. */
|
|
91
|
+
declare const Hex64Schema: z.ZodString;
|
|
92
|
+
type Hex64 = z.infer<typeof Hex64Schema>;
|
|
93
|
+
/** `ed25519:` + base64url (no padding) of a 64-byte signature (GAP-03). */
|
|
94
|
+
declare const SigSchema: z.ZodString;
|
|
95
|
+
type Sig = z.infer<typeof SigSchema>;
|
|
96
|
+
declare const SessionIdSchema: z.ZodUUID;
|
|
97
|
+
declare const SeqSchema: z.ZodNumber;
|
|
98
|
+
declare const TimestampSchema: z.ZodISODateTime;
|
|
99
|
+
/** JSON value that survives RFC 8785 canonicalization unchanged. */
|
|
100
|
+
declare const JsonValueSchema: z.ZodType<JsonValue>;
|
|
101
|
+
type JsonValue = null | boolean | number | string | JsonValue[] | {
|
|
102
|
+
[key: string]: JsonValue;
|
|
103
|
+
};
|
|
104
|
+
type JsonObject = {
|
|
105
|
+
[key: string]: JsonValue;
|
|
106
|
+
};
|
|
107
|
+
declare const EvidenceEventSchema: z.ZodObject<{
|
|
108
|
+
sessionId: z.ZodUUID;
|
|
109
|
+
source: z.ZodEnum<{
|
|
110
|
+
AGENT_TRACE: "AGENT_TRACE";
|
|
111
|
+
INTERNAL_NETWORK: "INTERNAL_NETWORK";
|
|
112
|
+
}>;
|
|
113
|
+
seq: z.ZodNumber;
|
|
114
|
+
ts: z.ZodISODateTime;
|
|
115
|
+
kind: z.ZodEnum<{
|
|
116
|
+
"session.open": "session.open";
|
|
117
|
+
"session.close": "session.close";
|
|
118
|
+
"intent.declared": "intent.declared";
|
|
119
|
+
"llm_call.start": "llm_call.start";
|
|
120
|
+
"llm_call.end": "llm_call.end";
|
|
121
|
+
"tool_call.start": "tool_call.start";
|
|
122
|
+
"tool_call.end": "tool_call.end";
|
|
123
|
+
"payment.requested": "payment.requested";
|
|
124
|
+
"payment.presented": "payment.presented";
|
|
125
|
+
"gateway.decision": "gateway.decision";
|
|
126
|
+
"transport.gap": "transport.gap";
|
|
127
|
+
}>;
|
|
128
|
+
payload: z.ZodRecord<z.ZodString, z.ZodType<JsonValue, unknown, z.core.$ZodTypeInternals<JsonValue, unknown>>>;
|
|
129
|
+
prevHash: z.ZodString;
|
|
130
|
+
sig: z.ZodOptional<z.ZodString>;
|
|
131
|
+
}, z.core.$strict>;
|
|
132
|
+
type EvidenceEvent = z.infer<typeof EvidenceEventSchema>;
|
|
133
|
+
/**
|
|
134
|
+
* What the platform keeps of an event once the payload body has been moved
|
|
135
|
+
* to the content-addressed store: the envelope, with `payload` replaced by
|
|
136
|
+
* its digest. This is the shape `eventDigest` is computed over (GAP-02),
|
|
137
|
+
* for every source including PLATFORM.
|
|
138
|
+
*/
|
|
139
|
+
interface EvidenceEnvelope {
|
|
140
|
+
sessionId: string;
|
|
141
|
+
source: EvidenceSourceAll;
|
|
142
|
+
seq: number;
|
|
143
|
+
ts: string;
|
|
144
|
+
kind: EvidenceKind;
|
|
145
|
+
payloadDigest: Hex64;
|
|
146
|
+
prevHash: Hex64;
|
|
147
|
+
sig?: Sig | undefined;
|
|
148
|
+
}
|
|
149
|
+
/** The fields of the envelope that `eventDigest` commits to, in the RFC's order (GAP-02). */
|
|
150
|
+
type DigestedEnvelope = Pick<EvidenceEnvelope, 'sessionId' | 'source' | 'seq' | 'ts' | 'kind' | 'prevHash'> & {
|
|
151
|
+
payload: Hex64;
|
|
152
|
+
};
|
|
153
|
+
interface ChainHead {
|
|
154
|
+
seq: number;
|
|
155
|
+
digest: Hex64;
|
|
156
|
+
}
|
|
157
|
+
declare function isWireKind(kind: string): kind is WireEvidenceKind;
|
|
158
|
+
declare function isPlatformKind(kind: string): kind is PlatformEvidenceKind;
|
|
159
|
+
|
|
160
|
+
declare const AmountSchema: z.ZodObject<{
|
|
161
|
+
value: z.ZodString;
|
|
162
|
+
currency: z.ZodString;
|
|
163
|
+
}, z.core.$strict>;
|
|
164
|
+
type Amount = z.infer<typeof AmountSchema>;
|
|
165
|
+
declare const DeclaredIntentSchema: z.ZodObject<{
|
|
166
|
+
mandate: z.ZodString;
|
|
167
|
+
maxAmount: z.ZodOptional<z.ZodObject<{
|
|
168
|
+
value: z.ZodString;
|
|
169
|
+
currency: z.ZodString;
|
|
170
|
+
}, z.core.$strict>>;
|
|
171
|
+
merchantAllowlist: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
172
|
+
validUntil: z.ZodISODateTime;
|
|
173
|
+
}, z.core.$strict>;
|
|
174
|
+
type DeclaredIntent = z.infer<typeof DeclaredIntentSchema>;
|
|
175
|
+
declare const CreateSessionInputSchema: z.ZodObject<{
|
|
176
|
+
source: z.ZodEnum<{
|
|
177
|
+
AGENT_TRACE: "AGENT_TRACE";
|
|
178
|
+
INTERNAL_NETWORK: "INTERNAL_NETWORK";
|
|
179
|
+
}>;
|
|
180
|
+
agent: z.ZodOptional<z.ZodObject<{
|
|
181
|
+
did: z.ZodString;
|
|
182
|
+
credential: z.ZodString;
|
|
183
|
+
}, z.core.$strict>>;
|
|
184
|
+
intent: z.ZodOptional<z.ZodObject<{
|
|
185
|
+
mandate: z.ZodString;
|
|
186
|
+
maxAmount: z.ZodOptional<z.ZodObject<{
|
|
187
|
+
value: z.ZodString;
|
|
188
|
+
currency: z.ZodString;
|
|
189
|
+
}, z.core.$strict>>;
|
|
190
|
+
merchantAllowlist: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
191
|
+
validUntil: z.ZodISODateTime;
|
|
192
|
+
}, z.core.$strict>>;
|
|
193
|
+
}, z.core.$strict>;
|
|
194
|
+
type CreateSessionInput = z.infer<typeof CreateSessionInputSchema>;
|
|
195
|
+
declare const CreateSessionOutputSchema: z.ZodObject<{
|
|
196
|
+
sessionId: z.ZodUUID;
|
|
197
|
+
expiresAt: z.ZodISODateTime;
|
|
198
|
+
}, z.core.$strict>;
|
|
199
|
+
type CreateSessionOutput = z.infer<typeof CreateSessionOutputSchema>;
|
|
200
|
+
declare const MAX_BATCH_EVENTS = 500;
|
|
201
|
+
declare const EvidenceBatchInputSchema: z.ZodArray<z.ZodObject<{
|
|
202
|
+
sessionId: z.ZodUUID;
|
|
203
|
+
source: z.ZodEnum<{
|
|
204
|
+
AGENT_TRACE: "AGENT_TRACE";
|
|
205
|
+
INTERNAL_NETWORK: "INTERNAL_NETWORK";
|
|
206
|
+
}>;
|
|
207
|
+
seq: z.ZodNumber;
|
|
208
|
+
ts: z.ZodISODateTime;
|
|
209
|
+
kind: z.ZodEnum<{
|
|
210
|
+
"session.open": "session.open";
|
|
211
|
+
"session.close": "session.close";
|
|
212
|
+
"intent.declared": "intent.declared";
|
|
213
|
+
"llm_call.start": "llm_call.start";
|
|
214
|
+
"llm_call.end": "llm_call.end";
|
|
215
|
+
"tool_call.start": "tool_call.start";
|
|
216
|
+
"tool_call.end": "tool_call.end";
|
|
217
|
+
"payment.requested": "payment.requested";
|
|
218
|
+
"payment.presented": "payment.presented";
|
|
219
|
+
"gateway.decision": "gateway.decision";
|
|
220
|
+
"transport.gap": "transport.gap";
|
|
221
|
+
}>;
|
|
222
|
+
payload: z.ZodRecord<z.ZodString, z.ZodType<JsonValue, unknown, z.core.$ZodTypeInternals<JsonValue, unknown>>>;
|
|
223
|
+
prevHash: z.ZodString;
|
|
224
|
+
sig: z.ZodOptional<z.ZodString>;
|
|
225
|
+
}, z.core.$strict>>;
|
|
226
|
+
type EvidenceBatchInput = z.infer<typeof EvidenceBatchInputSchema>;
|
|
227
|
+
declare const EventResultStatusSchema: z.ZodEnum<{
|
|
228
|
+
ok: "ok";
|
|
229
|
+
duplicate: "duplicate";
|
|
230
|
+
fork: "fork";
|
|
231
|
+
rejected: "rejected";
|
|
232
|
+
}>;
|
|
233
|
+
type EventResultStatus = z.infer<typeof EventResultStatusSchema>;
|
|
234
|
+
/** Per-event outcome of a batch (GAP-17). `seq` is null when the event could not be parsed. */
|
|
235
|
+
declare const EventResultSchema: z.ZodObject<{
|
|
236
|
+
index: z.ZodNumber;
|
|
237
|
+
sessionId: z.ZodNullable<z.ZodUUID>;
|
|
238
|
+
source: z.ZodNullable<z.ZodEnum<{
|
|
239
|
+
AGENT_TRACE: "AGENT_TRACE";
|
|
240
|
+
INTERNAL_NETWORK: "INTERNAL_NETWORK";
|
|
241
|
+
}>>;
|
|
242
|
+
seq: z.ZodNullable<z.ZodNumber>;
|
|
243
|
+
status: z.ZodEnum<{
|
|
244
|
+
ok: "ok";
|
|
245
|
+
duplicate: "duplicate";
|
|
246
|
+
fork: "fork";
|
|
247
|
+
rejected: "rejected";
|
|
248
|
+
}>;
|
|
249
|
+
code: z.ZodOptional<z.ZodString>;
|
|
250
|
+
eventDigest: z.ZodOptional<z.ZodString>;
|
|
251
|
+
}, z.core.$strict>;
|
|
252
|
+
type EventResult = z.infer<typeof EventResultSchema>;
|
|
253
|
+
declare const ChainHeadSchema: z.ZodObject<{
|
|
254
|
+
seq: z.ZodNumber;
|
|
255
|
+
digest: z.ZodString;
|
|
256
|
+
}, z.core.$strict>;
|
|
257
|
+
declare const EvidenceAckSchema: z.ZodObject<{
|
|
258
|
+
results: z.ZodArray<z.ZodObject<{
|
|
259
|
+
index: z.ZodNumber;
|
|
260
|
+
sessionId: z.ZodNullable<z.ZodUUID>;
|
|
261
|
+
source: z.ZodNullable<z.ZodEnum<{
|
|
262
|
+
AGENT_TRACE: "AGENT_TRACE";
|
|
263
|
+
INTERNAL_NETWORK: "INTERNAL_NETWORK";
|
|
264
|
+
}>>;
|
|
265
|
+
seq: z.ZodNullable<z.ZodNumber>;
|
|
266
|
+
status: z.ZodEnum<{
|
|
267
|
+
ok: "ok";
|
|
268
|
+
duplicate: "duplicate";
|
|
269
|
+
fork: "fork";
|
|
270
|
+
rejected: "rejected";
|
|
271
|
+
}>;
|
|
272
|
+
code: z.ZodOptional<z.ZodString>;
|
|
273
|
+
eventDigest: z.ZodOptional<z.ZodString>;
|
|
274
|
+
}, z.core.$strict>>;
|
|
275
|
+
heads: z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
276
|
+
seq: z.ZodNumber;
|
|
277
|
+
digest: z.ZodString;
|
|
278
|
+
}, z.core.$strict>>;
|
|
279
|
+
}, z.core.$strict>;
|
|
280
|
+
type EvidenceAck = z.infer<typeof EvidenceAckSchema>;
|
|
281
|
+
declare const PaymentSummarySchema: z.ZodObject<{
|
|
282
|
+
protocol: z.ZodString;
|
|
283
|
+
payee: z.ZodString;
|
|
284
|
+
amount: z.ZodObject<{
|
|
285
|
+
value: z.ZodString;
|
|
286
|
+
currency: z.ZodString;
|
|
287
|
+
}, z.core.$strict>;
|
|
288
|
+
payer: z.ZodOptional<z.ZodString>;
|
|
289
|
+
}, z.core.$strict>;
|
|
290
|
+
type PaymentSummary = z.infer<typeof PaymentSummarySchema>;
|
|
291
|
+
declare const EvaluateInputSchema: z.ZodObject<{
|
|
292
|
+
sessionId: z.ZodUUID;
|
|
293
|
+
payment: z.ZodObject<{
|
|
294
|
+
protocol: z.ZodString;
|
|
295
|
+
payee: z.ZodString;
|
|
296
|
+
amount: z.ZodObject<{
|
|
297
|
+
value: z.ZodString;
|
|
298
|
+
currency: z.ZodString;
|
|
299
|
+
}, z.core.$strict>;
|
|
300
|
+
payer: z.ZodOptional<z.ZodString>;
|
|
301
|
+
}, z.core.$strict>;
|
|
302
|
+
}, z.core.$strict>;
|
|
303
|
+
type EvaluateInput = z.infer<typeof EvaluateInputSchema>;
|
|
304
|
+
declare const DecisionSchema: z.ZodEnum<{
|
|
305
|
+
DENY: "DENY";
|
|
306
|
+
REVIEW: "REVIEW";
|
|
307
|
+
ALLOW: "ALLOW";
|
|
308
|
+
}>;
|
|
309
|
+
type Decision = z.infer<typeof DecisionSchema>;
|
|
310
|
+
declare const EvaluateOutputSchema: z.ZodObject<{
|
|
311
|
+
decision: z.ZodEnum<{
|
|
312
|
+
DENY: "DENY";
|
|
313
|
+
REVIEW: "REVIEW";
|
|
314
|
+
ALLOW: "ALLOW";
|
|
315
|
+
}>;
|
|
316
|
+
reasonCodes: z.ZodArray<z.ZodString>;
|
|
317
|
+
sessionId: z.ZodUUID;
|
|
318
|
+
decisionId: z.ZodUUID;
|
|
319
|
+
}, z.core.$strict>;
|
|
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
|
+
/** Non-RFC admin surface (GAP-53). */
|
|
338
|
+
declare const CreatePolicyInputSchema: z.ZodObject<{
|
|
339
|
+
rules: z.ZodObject<{
|
|
340
|
+
rules: z.ZodArray<z.ZodObject<{
|
|
341
|
+
id: z.ZodString;
|
|
342
|
+
primitive: z.ZodEnum<{
|
|
343
|
+
THRESHOLD: "THRESHOLD";
|
|
344
|
+
MEMBERSHIP: "MEMBERSHIP";
|
|
345
|
+
MATCH: "MATCH";
|
|
346
|
+
PRESENCE: "PRESENCE";
|
|
347
|
+
FRESHNESS: "FRESHNESS";
|
|
348
|
+
}>;
|
|
349
|
+
selector: z.ZodString;
|
|
350
|
+
params: z.ZodRecord<z.ZodString, z.ZodType<JsonValue, unknown, z.core.$ZodTypeInternals<JsonValue, unknown>>>;
|
|
351
|
+
onFail: z.ZodEnum<{
|
|
352
|
+
DENY: "DENY";
|
|
353
|
+
REVIEW: "REVIEW";
|
|
354
|
+
}>;
|
|
355
|
+
onMissing: z.ZodOptional<z.ZodEnum<{
|
|
356
|
+
DENY: "DENY";
|
|
357
|
+
REVIEW: "REVIEW";
|
|
358
|
+
skip: "skip";
|
|
359
|
+
}>>;
|
|
360
|
+
code: z.ZodString;
|
|
361
|
+
}, z.core.$strict>>;
|
|
362
|
+
scoreThresholds: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodNumber>>;
|
|
363
|
+
}, z.core.$strict>;
|
|
364
|
+
}, z.core.$strict>;
|
|
365
|
+
type CreatePolicyInput = z.infer<typeof CreatePolicyInputSchema>;
|
|
366
|
+
declare const CreatePolicyOutputSchema: z.ZodObject<{
|
|
367
|
+
policyId: z.ZodUUID;
|
|
368
|
+
version: z.ZodNumber;
|
|
369
|
+
status: z.ZodEnum<{
|
|
370
|
+
ACTIVE: "ACTIVE";
|
|
371
|
+
SUPERSEDED: "SUPERSEDED";
|
|
372
|
+
DRAFT: "DRAFT";
|
|
373
|
+
}>;
|
|
374
|
+
}, z.core.$strict>;
|
|
375
|
+
type CreatePolicyOutput = z.infer<typeof CreatePolicyOutputSchema>;
|
|
376
|
+
/** Error envelope (GAP-20). */
|
|
377
|
+
declare const ApiErrorSchema: z.ZodObject<{
|
|
378
|
+
error: z.ZodObject<{
|
|
379
|
+
code: z.ZodString;
|
|
380
|
+
message: z.ZodString;
|
|
381
|
+
details: z.ZodOptional<z.ZodType<JsonValue, unknown, z.core.$ZodTypeInternals<JsonValue, unknown>>>;
|
|
382
|
+
request_id: z.ZodOptional<z.ZodString>;
|
|
383
|
+
}, z.core.$strict>;
|
|
384
|
+
}, z.core.$strict>;
|
|
385
|
+
type ApiError = z.infer<typeof ApiErrorSchema>;
|
|
386
|
+
|
|
387
|
+
declare const SessionOpenPayloadSchema: z.ZodObject<{
|
|
388
|
+
runtime: z.ZodObject<{
|
|
389
|
+
sdk: z.ZodString;
|
|
390
|
+
version: z.ZodString;
|
|
391
|
+
framework: z.ZodOptional<z.ZodString>;
|
|
392
|
+
model: z.ZodOptional<z.ZodString>;
|
|
393
|
+
}, z.core.$loose>;
|
|
394
|
+
attestations: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodType<JsonValue, unknown, z.core.$ZodTypeInternals<JsonValue, unknown>>>>;
|
|
395
|
+
}, z.core.$loose>;
|
|
396
|
+
declare const SESSION_CLOSE_REASONS: readonly ["completed", "settled", "aborted", "expired"];
|
|
397
|
+
declare const SessionClosePayloadSchema: z.ZodObject<{
|
|
398
|
+
reason: z.ZodEnum<{
|
|
399
|
+
completed: "completed";
|
|
400
|
+
settled: "settled";
|
|
401
|
+
aborted: "aborted";
|
|
402
|
+
expired: "expired";
|
|
403
|
+
}>;
|
|
404
|
+
transaction: z.ZodOptional<z.ZodString>;
|
|
405
|
+
}, z.core.$loose>;
|
|
406
|
+
declare const IntentDeclaredPayloadSchema: z.ZodObject<{
|
|
407
|
+
mandate: z.ZodString;
|
|
408
|
+
maxAmount: z.ZodOptional<z.ZodObject<{
|
|
409
|
+
value: z.ZodString;
|
|
410
|
+
currency: z.ZodString;
|
|
411
|
+
}, z.core.$strict>>;
|
|
412
|
+
merchantAllowlist: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
413
|
+
validUntil: z.ZodISODateTime;
|
|
414
|
+
}, z.core.$loose>;
|
|
415
|
+
declare const LlmCallStartPayloadSchema: z.ZodObject<{
|
|
416
|
+
callId: z.ZodString;
|
|
417
|
+
provider: z.ZodString;
|
|
418
|
+
modelId: z.ZodString;
|
|
419
|
+
params: z.ZodRecord<z.ZodString, z.ZodType<JsonValue, unknown, z.core.$ZodTypeInternals<JsonValue, unknown>>>;
|
|
420
|
+
}, z.core.$loose>;
|
|
421
|
+
declare const LlmCallEndPayloadSchema: z.ZodObject<{
|
|
422
|
+
callId: z.ZodString;
|
|
423
|
+
content: z.ZodOptional<z.ZodType<JsonValue, unknown, z.core.$ZodTypeInternals<JsonValue, unknown>>>;
|
|
424
|
+
finishReason: z.ZodOptional<z.ZodString>;
|
|
425
|
+
usage: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodType<JsonValue, unknown, z.core.$ZodTypeInternals<JsonValue, unknown>>>>;
|
|
426
|
+
durationMs: z.ZodNumber;
|
|
427
|
+
error: z.ZodOptional<z.ZodObject<{
|
|
428
|
+
name: z.ZodString;
|
|
429
|
+
message: z.ZodString;
|
|
430
|
+
}, z.core.$loose>>;
|
|
431
|
+
}, z.core.$loose>;
|
|
432
|
+
declare const ToolCallStartPayloadSchema: z.ZodObject<{
|
|
433
|
+
callId: z.ZodString;
|
|
434
|
+
toolName: z.ZodString;
|
|
435
|
+
input: z.ZodType<JsonValue, unknown, z.core.$ZodTypeInternals<JsonValue, unknown>>;
|
|
436
|
+
transport: z.ZodOptional<z.ZodEnum<{
|
|
437
|
+
local: "local";
|
|
438
|
+
mcp: "mcp";
|
|
439
|
+
}>>;
|
|
440
|
+
server: z.ZodOptional<z.ZodString>;
|
|
441
|
+
}, z.core.$loose>;
|
|
442
|
+
declare const ToolCallEndPayloadSchema: z.ZodObject<{
|
|
443
|
+
callId: z.ZodString;
|
|
444
|
+
output: z.ZodOptional<z.ZodType<JsonValue, unknown, z.core.$ZodTypeInternals<JsonValue, unknown>>>;
|
|
445
|
+
error: z.ZodOptional<z.ZodObject<{
|
|
446
|
+
name: z.ZodString;
|
|
447
|
+
message: z.ZodString;
|
|
448
|
+
}, z.core.$loose>>;
|
|
449
|
+
durationMs: z.ZodNumber;
|
|
450
|
+
}, z.core.$loose>;
|
|
451
|
+
declare const PAYMENT_ARTIFACTS: readonly ["http-402", "mrtr-input-required", "payment-signature", "checkout-url"];
|
|
452
|
+
/**
|
|
453
|
+
* A payment moment, normalized across protocols so the engine can compare
|
|
454
|
+
* the two sides of the same purchase (`EVIDENCE_MISMATCH`, GAP-50). `raw` is
|
|
455
|
+
* the protocol artifact as seen — the log, not a digest of it.
|
|
456
|
+
*/
|
|
457
|
+
declare const PaymentMomentPayloadSchema: z.ZodObject<{
|
|
458
|
+
protocol: z.ZodString;
|
|
459
|
+
payee: z.ZodString;
|
|
460
|
+
amount: z.ZodObject<{
|
|
461
|
+
value: z.ZodString;
|
|
462
|
+
currency: z.ZodString;
|
|
463
|
+
}, z.core.$loose>;
|
|
464
|
+
payer: z.ZodOptional<z.ZodString>;
|
|
465
|
+
artifact: z.ZodEnum<{
|
|
466
|
+
"http-402": "http-402";
|
|
467
|
+
"mrtr-input-required": "mrtr-input-required";
|
|
468
|
+
"payment-signature": "payment-signature";
|
|
469
|
+
"checkout-url": "checkout-url";
|
|
470
|
+
}>;
|
|
471
|
+
raw: z.ZodRecord<z.ZodString, z.ZodType<JsonValue, unknown, z.core.$ZodTypeInternals<JsonValue, unknown>>>;
|
|
472
|
+
}, z.core.$loose>;
|
|
473
|
+
declare const GatewayDecisionPayloadSchema: z.ZodObject<{
|
|
474
|
+
gateway: z.ZodString;
|
|
475
|
+
call: z.ZodObject<{
|
|
476
|
+
tool: z.ZodString;
|
|
477
|
+
args: z.ZodOptional<z.ZodType<JsonValue, unknown, z.core.$ZodTypeInternals<JsonValue, unknown>>>;
|
|
478
|
+
}, z.core.$loose>;
|
|
479
|
+
decision: z.ZodEnum<{
|
|
480
|
+
DENY: "DENY";
|
|
481
|
+
REVIEW: "REVIEW";
|
|
482
|
+
ALLOW: "ALLOW";
|
|
483
|
+
CHALLENGE: "CHALLENGE";
|
|
484
|
+
}>;
|
|
485
|
+
reasonCodes: z.ZodArray<z.ZodString>;
|
|
486
|
+
record: z.ZodRecord<z.ZodString, z.ZodType<JsonValue, unknown, z.core.$ZodTypeInternals<JsonValue, unknown>>>;
|
|
487
|
+
}, z.core.$loose>;
|
|
488
|
+
/** Emitted by the SDK after its transport buffer overflowed (GAP-38). */
|
|
489
|
+
declare const TransportGapPayloadSchema: z.ZodObject<{
|
|
490
|
+
dropped: z.ZodNumber;
|
|
491
|
+
firstTs: z.ZodString;
|
|
492
|
+
lastTs: z.ZodString;
|
|
493
|
+
}, z.core.$loose>;
|
|
494
|
+
/** Exactly `{ origin, params, response }` so its digest is the Observation digest (GAP-39). */
|
|
495
|
+
declare const PlatformObservationPayloadSchema: z.ZodObject<{
|
|
496
|
+
origin: z.ZodString;
|
|
497
|
+
params: z.ZodType<JsonValue, unknown, z.core.$ZodTypeInternals<JsonValue, unknown>>;
|
|
498
|
+
response: z.ZodType<JsonValue, unknown, z.core.$ZodTypeInternals<JsonValue, unknown>>;
|
|
499
|
+
}, z.core.$strict>;
|
|
500
|
+
declare const ANOMALY_TYPES: readonly ["fork", "seq_gap", "prev_hash_mismatch", "bad_sig", "clock_skew", "source_conflict"];
|
|
501
|
+
declare const PlatformAnomalyPayloadSchema: z.ZodObject<{
|
|
502
|
+
type: z.ZodEnum<{
|
|
503
|
+
fork: "fork";
|
|
504
|
+
seq_gap: "seq_gap";
|
|
505
|
+
prev_hash_mismatch: "prev_hash_mismatch";
|
|
506
|
+
bad_sig: "bad_sig";
|
|
507
|
+
clock_skew: "clock_skew";
|
|
508
|
+
source_conflict: "source_conflict";
|
|
509
|
+
}>;
|
|
510
|
+
source: z.ZodEnum<{
|
|
511
|
+
AGENT_TRACE: "AGENT_TRACE";
|
|
512
|
+
INTERNAL_NETWORK: "INTERNAL_NETWORK";
|
|
513
|
+
PLATFORM: "PLATFORM";
|
|
514
|
+
}>;
|
|
515
|
+
seq: z.ZodNullable<z.ZodNumber>;
|
|
516
|
+
detail: z.ZodRecord<z.ZodString, z.ZodType<JsonValue, unknown, z.core.$ZodTypeInternals<JsonValue, unknown>>>;
|
|
517
|
+
}, z.core.$loose>;
|
|
518
|
+
type SessionOpenPayload = z.infer<typeof SessionOpenPayloadSchema>;
|
|
519
|
+
type SessionClosePayload = z.infer<typeof SessionClosePayloadSchema>;
|
|
520
|
+
type IntentDeclaredPayload = z.infer<typeof IntentDeclaredPayloadSchema>;
|
|
521
|
+
type LlmCallStartPayload = z.infer<typeof LlmCallStartPayloadSchema>;
|
|
522
|
+
type LlmCallEndPayload = z.infer<typeof LlmCallEndPayloadSchema>;
|
|
523
|
+
type ToolCallStartPayload = z.infer<typeof ToolCallStartPayloadSchema>;
|
|
524
|
+
type ToolCallEndPayload = z.infer<typeof ToolCallEndPayloadSchema>;
|
|
525
|
+
type PaymentMomentPayload = z.infer<typeof PaymentMomentPayloadSchema>;
|
|
526
|
+
type GatewayDecisionPayload = z.infer<typeof GatewayDecisionPayloadSchema>;
|
|
527
|
+
type TransportGapPayload = z.infer<typeof TransportGapPayloadSchema>;
|
|
528
|
+
type PlatformObservationPayload = z.infer<typeof PlatformObservationPayloadSchema>;
|
|
529
|
+
type PlatformAnomalyPayload = z.infer<typeof PlatformAnomalyPayloadSchema>;
|
|
530
|
+
declare function payloadSchemaFor(kind: EvidenceKind): z.ZodType;
|
|
531
|
+
interface PayloadByKind {
|
|
532
|
+
'session.open': SessionOpenPayload;
|
|
533
|
+
'session.close': SessionClosePayload;
|
|
534
|
+
'intent.declared': IntentDeclaredPayload;
|
|
535
|
+
'llm_call.start': LlmCallStartPayload;
|
|
536
|
+
'llm_call.end': LlmCallEndPayload;
|
|
537
|
+
'tool_call.start': ToolCallStartPayload;
|
|
538
|
+
'tool_call.end': ToolCallEndPayload;
|
|
539
|
+
'payment.requested': PaymentMomentPayload;
|
|
540
|
+
'payment.presented': PaymentMomentPayload;
|
|
541
|
+
'gateway.decision': GatewayDecisionPayload;
|
|
542
|
+
'transport.gap': TransportGapPayload;
|
|
543
|
+
'platform.observation': PlatformObservationPayload;
|
|
544
|
+
'platform.anomaly': PlatformAnomalyPayload;
|
|
545
|
+
}
|
|
546
|
+
|
|
547
|
+
export { Hex64Schema as $, ALL_SOURCES as A, type EvaluateOutput as B, type ChainHead as C, type Decision as D, type EvidenceSourceAll as E, EvaluateOutputSchema as F, type EventResult as G, EventResultSchema as H, type EventResultStatus as I, type JsonObject as J, EventResultStatusSchema as K, type EvidenceAck as L, EvidenceAckSchema as M, type EvidenceBatchInput as N, EvidenceBatchInputSchema as O, type PaymentMomentPayload as P, type EvidenceEnvelope as Q, type EvidenceEvent as R, EvidenceEventSchema as S, type EvidenceKind as T, EvidenceKindSchema as U, type EvidenceSource as V, EvidenceSourceAllSchema as W, EvidenceSourceSchema as X, type GatewayDecisionPayload as Y, GatewayDecisionPayloadSchema as Z, type Hex64 as _, type PaymentSummary as a, type IntentDeclaredPayload as a0, IntentDeclaredPayloadSchema as a1, JsonValueSchema as a2, type LlmCallEndPayload as a3, LlmCallEndPayloadSchema as a4, type LlmCallStartPayload as a5, LlmCallStartPayloadSchema as a6, MAX_BATCH_EVENTS as a7, PAYMENT_ARTIFACTS as a8, PLATFORM_KINDS as a9, WIRE_KINDS as aA, WIRE_SOURCES as aB, type WireEvidenceKind as aC, WireEvidenceKindSchema as aD, compareBySessionSource as aE, compareBySourceSeq as aF, isPlatformKind as aG, isWireKind as aH, payloadSchemaFor as aI, type PayloadByKind as aa, PaymentMomentPayloadSchema as ab, PaymentSummarySchema as ac, type PlatformAnomalyPayload as ad, PlatformAnomalyPayloadSchema as ae, type PlatformEvidenceKind as af, PlatformEvidenceKindSchema as ag, type PlatformObservationPayload as ah, PlatformObservationPayloadSchema as ai, SESSION_CLOSE_REASONS as aj, SOURCE_ORDER as ak, SeqSchema as al, type SessionClosePayload as am, SessionClosePayloadSchema as an, SessionIdSchema as ao, type SessionOpenPayload as ap, SessionOpenPayloadSchema as aq, type Sig as ar, SigSchema as as, TimestampSchema as at, type ToolCallEndPayload as au, ToolCallEndPayloadSchema as av, type ToolCallStartPayload as aw, ToolCallStartPayloadSchema as ax, type TransportGapPayload as ay, TransportGapPayloadSchema as az, type JsonValue as b, ANOMALY_TYPES as c, type Amount as d, AmountSchema as e, type AnchorEntry as f, AnchorEntrySchema as g, type AnchorsOutput as h, AnchorsOutputSchema as i, type ApiError as j, ApiErrorSchema as k, ChainHeadSchema as l, type CreatePolicyInput as m, CreatePolicyInputSchema as n, type CreatePolicyOutput as o, CreatePolicyOutputSchema as p, type CreateSessionInput as q, CreateSessionInputSchema as r, type CreateSessionOutput as s, CreateSessionOutputSchema as t, DecisionSchema as u, type DeclaredIntent as v, DeclaredIntentSchema as w, type DigestedEnvelope as x, type EvaluateInput as y, EvaluateInputSchema as z };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
export { B as Beltic, a as BelticOptions, C as CorrelationStore, M as MemoryCorrelationStore, S as SDK_VERSION, c as createBeltic } from './client-
|
|
2
|
-
import { S as Session } from './session-
|
|
3
|
-
export { A as AgentIdentity, a as ApiClient, b as ApiClientOptions, B as BelticApiError, C as ChainRejectedError, D as DEFAULT_TRANSPORT, R as RedactFn,
|
|
4
|
-
import { PaymentSummary, JsonObject, PaymentMomentPayload } from './
|
|
5
|
-
import './
|
|
1
|
+
export { B as Beltic, a as BelticOptions, C as CorrelationStore, E as Evaluation, M as MemoryCorrelationStore, S as SDK_VERSION, c as createBeltic } from './client-C-mV_3A0.js';
|
|
2
|
+
import { S as Session } from './session-5TClPLI4.js';
|
|
3
|
+
export { A as AgentIdentity, a as ApiClient, b as ApiClientOptions, B as BelticApiError, C as ChainRejectedError, D as DEFAULT_OPEN_RETRY_MS, c as DEFAULT_TRANSPORT, O as OpenSessionInput, R as RedactFn, d as SessionBorn, e as Sessions, f as StartSessionInput, T as ToolCallSpan, g as Transport, h as TransportClosedError, i as TransportOptions, j as ephemeralIdentity, k as fileIdentity, l as identityFromSeed } from './session-5TClPLI4.js';
|
|
4
|
+
import { a as PaymentSummary, J as JsonObject, P as PaymentMomentPayload } from './index-Bjs3BPPU.js';
|
|
5
|
+
import './verdict-BAahb5po.js';
|
|
6
|
+
import 'zod';
|
|
6
7
|
|
|
7
8
|
/**
|
|
8
9
|
* The shape the platform judges (`PaymentSummary`) and the shape the record
|
|
@@ -11,15 +12,16 @@ import './base58.js';
|
|
|
11
12
|
* sides of one purchase compare (`EVIDENCE_MISMATCH`, GAP-50).
|
|
12
13
|
*/
|
|
13
14
|
|
|
14
|
-
declare function summaryOf(m: PaymentMomentPayload): PaymentSummary;
|
|
15
|
+
declare function summaryOf(m: PaymentSummary | PaymentMomentPayload): PaymentSummary;
|
|
15
16
|
/** A presentation the seller side saw as a signed payment, in any protocol. */
|
|
16
17
|
declare function presentedFrom(summary: PaymentSummary, raw: JsonObject): PaymentMomentPayload;
|
|
17
18
|
|
|
18
19
|
/**
|
|
19
20
|
* One instrumented call = a `*.start` event, the work, a `*.end` event
|
|
20
21
|
* carrying the outcome or the error (GAP-07 correlates them by `callId`).
|
|
21
|
-
*
|
|
22
|
-
*
|
|
22
|
+
* `openCall` is the span; `recordCall` runs the work inside one. The AI
|
|
23
|
+
* middleware, the tool wrapper, the MCP client and a host's own tool loop
|
|
24
|
+
* (`Session.toolCall`) all record the same way.
|
|
23
25
|
*/
|
|
24
26
|
|
|
25
27
|
type CallKind = 'llm_call' | 'tool_call';
|