@belticlabs/agent-risk-sdk 0.6.0 → 0.7.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/ai/index.d.ts +2 -2
- package/dist/ai/index.js +15 -18
- package/dist/chunk-FNU4CRJJ.js +547 -0
- package/dist/{chunk-IUWC6HT5.js → chunk-HI656UWG.js} +12 -14
- package/dist/{chunk-ZMPKY7AX.js → chunk-JGVVQUXQ.js} +1 -2
- package/dist/{chunk-77D74TWX.js → chunk-UXXSE643.js} +25 -22
- package/dist/{client-CgCjOrRP.d.ts → client-Xn9M58OJ.d.ts} +18 -12
- package/dist/{index-IfY4XCvJ.d.ts → index-DAVKGJs5.d.ts} +129 -139
- package/dist/index.d.ts +3 -3
- package/dist/index.js +351 -165
- package/dist/protocol/index.d.ts +51 -30
- package/dist/protocol/index.js +50 -529
- package/dist/{session-Dcof4UIn.d.ts → session-DAN29XoB.d.ts} +115 -43
- package/dist/x402/hono.d.ts +3 -4
- package/dist/x402/hono.js +3 -3
- package/dist/x402/index.d.ts +7 -22
- package/dist/x402/index.js +33 -24
- package/package.json +1 -1
- package/dist/adapter-AjCgj-KM.d.ts +0 -6
|
@@ -20,8 +20,7 @@ function openCall(stream, kind, callId, start) {
|
|
|
20
20
|
fail: (error, outcome = {}) => close({ error: errorOf(error), ...outcome })
|
|
21
21
|
};
|
|
22
22
|
}
|
|
23
|
-
async function recordCall(
|
|
24
|
-
const span = openCall(stream, kind, callId, start);
|
|
23
|
+
async function recordCall(span, run, end = () => ({})) {
|
|
25
24
|
await span.opened;
|
|
26
25
|
try {
|
|
27
26
|
const result = await run();
|
|
@@ -9,28 +9,6 @@ function uuidv7(now = Date.now()) {
|
|
|
9
9
|
return `${h.slice(0, 8)}-${h.slice(8, 12)}-${h.slice(12, 16)}-${h.slice(16, 20)}-${h.slice(20)}`;
|
|
10
10
|
}
|
|
11
11
|
|
|
12
|
-
// ../canon/src/base58.ts
|
|
13
|
-
var ALPHABET = "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";
|
|
14
|
-
var MAP = new Map([...ALPHABET].map((c, i) => [c, i]));
|
|
15
|
-
function base58Encode(bytes) {
|
|
16
|
-
let zeros = 0;
|
|
17
|
-
while (zeros < bytes.length && bytes[zeros] === 0) zeros++;
|
|
18
|
-
const digits = [];
|
|
19
|
-
for (let i = zeros; i < bytes.length; i++) {
|
|
20
|
-
let carry = bytes[i];
|
|
21
|
-
for (let j = 0; j < digits.length; j++) {
|
|
22
|
-
carry += digits[j] << 8;
|
|
23
|
-
digits[j] = carry % 58;
|
|
24
|
-
carry = carry / 58 | 0;
|
|
25
|
-
}
|
|
26
|
-
while (carry > 0) {
|
|
27
|
-
digits.push(carry % 58);
|
|
28
|
-
carry = carry / 58 | 0;
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
return "1".repeat(zeros) + digits.reverse().map((d) => ALPHABET[d]).join("");
|
|
32
|
-
}
|
|
33
|
-
|
|
34
12
|
// ../canon/src/encoding.ts
|
|
35
13
|
function toHex(buf) {
|
|
36
14
|
return Buffer.from(buf).toString("hex");
|
|
@@ -293,6 +271,28 @@ var Chain = class _Chain {
|
|
|
293
271
|
}
|
|
294
272
|
};
|
|
295
273
|
|
|
274
|
+
// ../canon/src/base58.ts
|
|
275
|
+
var ALPHABET = "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";
|
|
276
|
+
var MAP = new Map([...ALPHABET].map((c, i) => [c, i]));
|
|
277
|
+
function base58Encode(bytes) {
|
|
278
|
+
let zeros = 0;
|
|
279
|
+
while (zeros < bytes.length && bytes[zeros] === 0) zeros++;
|
|
280
|
+
const digits = [];
|
|
281
|
+
for (let i = zeros; i < bytes.length; i++) {
|
|
282
|
+
let carry = bytes[i];
|
|
283
|
+
for (let j = 0; j < digits.length; j++) {
|
|
284
|
+
carry += digits[j] << 8;
|
|
285
|
+
digits[j] = carry % 58;
|
|
286
|
+
carry = carry / 58 | 0;
|
|
287
|
+
}
|
|
288
|
+
while (carry > 0) {
|
|
289
|
+
digits.push(carry % 58);
|
|
290
|
+
carry = carry / 58 | 0;
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
return "1".repeat(zeros) + digits.reverse().map((d) => ALPHABET[d]).join("");
|
|
294
|
+
}
|
|
295
|
+
|
|
296
296
|
// ../canon/src/did-key.ts
|
|
297
297
|
var ED25519_PUB_MULTICODEC = Buffer.from([237, 1]);
|
|
298
298
|
var PREFIX = "did:key:z";
|
|
@@ -301,6 +301,9 @@ function didKeyFromEd25519(publicKey) {
|
|
|
301
301
|
return PREFIX + base58Encode(Buffer.concat([ED25519_PUB_MULTICODEC, Buffer.from(publicKey)]));
|
|
302
302
|
}
|
|
303
303
|
|
|
304
|
+
// ../canon/src/session-id.ts
|
|
305
|
+
import { randomBytes as randomBytes2 } from "crypto";
|
|
306
|
+
|
|
304
307
|
export {
|
|
305
308
|
toHex,
|
|
306
309
|
fromHex,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { b as SessionOptions, S as Session, a as Decision } from './session-
|
|
1
|
+
import { N as PaymentSummary } from './index-DAVKGJs5.js';
|
|
2
|
+
import { b as SessionOptions, S as Session, a as Decision } from './session-DAN29XoB.js';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* One SDK, two halves (Fraud SDK RFC › Summary). `Beltic` is the single
|
|
@@ -22,7 +22,7 @@ import { b as SessionOptions, S as Session, a as Decision } from './session-Dcof
|
|
|
22
22
|
* is the client's fault and throws.
|
|
23
23
|
*/
|
|
24
24
|
|
|
25
|
-
declare const SDK_VERSION = "0.
|
|
25
|
+
declare const SDK_VERSION = "0.7.0";
|
|
26
26
|
interface BelticOptions {
|
|
27
27
|
apiKey: string;
|
|
28
28
|
baseUrl: string;
|
|
@@ -32,6 +32,7 @@ interface BelticOptions {
|
|
|
32
32
|
declare class Beltic {
|
|
33
33
|
private readonly api;
|
|
34
34
|
private readonly transport;
|
|
35
|
+
/** Open handles by conversation id (GAP-84). */
|
|
35
36
|
private readonly sessions;
|
|
36
37
|
/**
|
|
37
38
|
* The client the environment describes: `BELTIC_API_KEY` and
|
|
@@ -42,20 +43,25 @@ declare class Beltic {
|
|
|
42
43
|
static fromEnv(env?: Record<string, string | undefined>): Beltic;
|
|
43
44
|
constructor(opts: BelticOptions);
|
|
44
45
|
/**
|
|
45
|
-
*
|
|
46
|
-
*
|
|
47
|
-
*
|
|
46
|
+
* A conversation: new without an id, resumed with one — the id `session.id()`
|
|
47
|
+
* answered in this or any earlier process (GAP-84). One handle per
|
|
48
|
+
* conversation in-process until it closes; the options count when a
|
|
49
|
+
* session is opened. See `Session`.
|
|
48
50
|
*/
|
|
49
|
-
session(
|
|
51
|
+
session(id?: string, opts?: SessionOptions): Session;
|
|
50
52
|
/**
|
|
51
53
|
* The platform's verdict on a payment — the seller's before it verifies,
|
|
52
54
|
* the buyer's before it presents (Fraud SDK RFC › Evaluation Client).
|
|
53
|
-
* Read-your-writes: the buffered evidence is flushed first so
|
|
54
|
-
* platform judges what the caller already saw (GAP-16).
|
|
55
|
-
* platform
|
|
55
|
+
* Read-your-writes: the session's buffered evidence is flushed first so
|
|
56
|
+
* the platform judges what the caller already saw (GAP-16/88). With a `callId`
|
|
57
|
+
* the platform answers the decision already taken for that call anywhere
|
|
58
|
+
* in the conversation (GAP-84). Absent when the platform could not be
|
|
59
|
+
* reached (GAP-70).
|
|
56
60
|
*/
|
|
57
|
-
evaluate(sessionId: string, payment: PaymentSummary
|
|
58
|
-
|
|
61
|
+
evaluate(sessionId: string, payment: PaymentSummary, opts?: {
|
|
62
|
+
callId?: string | undefined;
|
|
63
|
+
}): Promise<Decision>;
|
|
64
|
+
/** Send everything buffered now — every session's — and wait for that attempt. */
|
|
59
65
|
flush(): Promise<void>;
|
|
60
66
|
shutdown(): Promise<void>;
|
|
61
67
|
/** `process.env` where there is a `process` (Node); `{}` on workerd, where the shell passes its `env`. */
|
|
@@ -13,7 +13,6 @@ import { z } from 'zod';
|
|
|
13
13
|
* GAP-08 names the internal kinds it carries.
|
|
14
14
|
*/
|
|
15
15
|
|
|
16
|
-
declare const WIRE_SOURCES: readonly ["AGENT_TRACE", "INTERNAL_NETWORK"];
|
|
17
16
|
declare const ALL_SOURCES: readonly ["AGENT_TRACE", "INTERNAL_NETWORK", "PLATFORM"];
|
|
18
17
|
declare const EvidenceSourceSchema: z.ZodEnum<{
|
|
19
18
|
AGENT_TRACE: "AGENT_TRACE";
|
|
@@ -36,22 +35,50 @@ declare function compareBySourceSeq(a: {
|
|
|
36
35
|
source: EvidenceSourceAll;
|
|
37
36
|
seq: number;
|
|
38
37
|
}): number;
|
|
39
|
-
/**
|
|
40
|
-
declare function
|
|
38
|
+
/** One chain's key wherever heads are reported: `sessionId:source`. */
|
|
39
|
+
declare function chainKey(sessionId: string, source: EvidenceSourceAll): string;
|
|
40
|
+
/**
|
|
41
|
+
* The order a conversation is read in: when it happened, when the platform
|
|
42
|
+
* saw it, then by chain and seq — the one order that interleaves the
|
|
43
|
+
* chains of every session of a conversation (GAP-84).
|
|
44
|
+
*/
|
|
45
|
+
declare function compareByArrival(a: {
|
|
46
|
+
ts: string;
|
|
47
|
+
receivedAt: string;
|
|
41
48
|
sessionId: string;
|
|
42
49
|
source: EvidenceSourceAll;
|
|
50
|
+
seq: number;
|
|
43
51
|
}, b: {
|
|
52
|
+
ts: string;
|
|
53
|
+
receivedAt: string;
|
|
44
54
|
sessionId: string;
|
|
45
55
|
source: EvidenceSourceAll;
|
|
56
|
+
seq: number;
|
|
46
57
|
}): number;
|
|
58
|
+
/** The root of a conversation before its members; a store then orders the members its own way. */
|
|
59
|
+
declare function compareRootFirst(conversationId: string): (a: {
|
|
60
|
+
id: string;
|
|
61
|
+
}, b: {
|
|
62
|
+
id: string;
|
|
63
|
+
}) => number;
|
|
47
64
|
/**
|
|
48
|
-
*
|
|
49
|
-
*
|
|
50
|
-
*
|
|
65
|
+
* Whether a row is inside the heads a decision pinned (replay): its chain
|
|
66
|
+
* is among them and its seq is at or below that head. A chain the decision
|
|
67
|
+
* never saw is outside.
|
|
51
68
|
*/
|
|
52
|
-
declare
|
|
53
|
-
|
|
54
|
-
|
|
69
|
+
declare function withinHeads(heads: Readonly<Record<string, number>>): (e: {
|
|
70
|
+
sessionId: string;
|
|
71
|
+
source: EvidenceSourceAll;
|
|
72
|
+
seq: number;
|
|
73
|
+
}) => boolean;
|
|
74
|
+
/** Commitments across sessions: by sessionId, then source. */
|
|
75
|
+
declare function compareBySessionSource(a: {
|
|
76
|
+
sessionId: string;
|
|
77
|
+
source: EvidenceSourceAll;
|
|
78
|
+
}, b: {
|
|
79
|
+
sessionId: string;
|
|
80
|
+
source: EvidenceSourceAll;
|
|
81
|
+
}): number;
|
|
55
82
|
declare const WireEvidenceKindSchema: z.ZodEnum<{
|
|
56
83
|
"session.open": "session.open";
|
|
57
84
|
"session.close": "session.close";
|
|
@@ -93,8 +120,15 @@ type Hex64 = z.infer<typeof Hex64Schema>;
|
|
|
93
120
|
/** `ed25519:` + base64url (no padding) of a 64-byte signature (GAP-03). */
|
|
94
121
|
declare const SigSchema: z.ZodString;
|
|
95
122
|
type Sig = z.infer<typeof SigSchema>;
|
|
96
|
-
|
|
97
|
-
|
|
123
|
+
/**
|
|
124
|
+
* The public session id: what every event, ack, evaluate and binding
|
|
125
|
+
* names, and the only form the wire accepts. Minted by the platform
|
|
126
|
+
* (`sess_` + 22 base62 chars, 128 bits); the uuid primary key never
|
|
127
|
+
* leaves persistence (GAP-86).
|
|
128
|
+
*/
|
|
129
|
+
declare const SESSION_ID_PREFIX = "sess_";
|
|
130
|
+
declare const SESSION_ID_CHARS = 22;
|
|
131
|
+
declare const SessionIdSchema: z.ZodString;
|
|
98
132
|
declare const TimestampSchema: z.ZodISODateTime;
|
|
99
133
|
/** JSON value that survives RFC 8785 canonicalization unchanged. */
|
|
100
134
|
declare const JsonValueSchema: z.ZodType<JsonValue>;
|
|
@@ -105,7 +139,7 @@ type JsonObject = {
|
|
|
105
139
|
[key: string]: JsonValue;
|
|
106
140
|
};
|
|
107
141
|
declare const EvidenceEventSchema: z.ZodObject<{
|
|
108
|
-
sessionId: z.
|
|
142
|
+
sessionId: z.ZodString;
|
|
109
143
|
source: z.ZodEnum<{
|
|
110
144
|
AGENT_TRACE: "AGENT_TRACE";
|
|
111
145
|
INTERNAL_NETWORK: "INTERNAL_NETWORK";
|
|
@@ -154,14 +188,7 @@ interface ChainHead {
|
|
|
154
188
|
seq: number;
|
|
155
189
|
digest: Hex64;
|
|
156
190
|
}
|
|
157
|
-
declare function isWireKind(kind: string): kind is WireEvidenceKind;
|
|
158
|
-
declare function isPlatformKind(kind: string): kind is PlatformEvidenceKind;
|
|
159
191
|
|
|
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
192
|
declare const DeclaredIntentSchema: z.ZodObject<{
|
|
166
193
|
mandate: z.ZodString;
|
|
167
194
|
maxAmount: z.ZodOptional<z.ZodObject<{
|
|
@@ -190,94 +217,41 @@ declare const CreateSessionInputSchema: z.ZodObject<{
|
|
|
190
217
|
merchantAllowlist: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
191
218
|
validUntil: z.ZodISODateTime;
|
|
192
219
|
}, z.core.$strict>>;
|
|
220
|
+
resume: z.ZodOptional<z.ZodString>;
|
|
193
221
|
}, z.core.$strict>;
|
|
194
222
|
type CreateSessionInput = z.infer<typeof CreateSessionInputSchema>;
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
223
|
+
/** The conversation's last prompt as a base for deltas: the call it was recorded on, one digest per message (GAP-89). */
|
|
224
|
+
interface PromptBase {
|
|
225
|
+
prior: string;
|
|
226
|
+
digests: Hex64[];
|
|
227
|
+
}
|
|
228
|
+
interface CreateSessionOutput {
|
|
229
|
+
/** This session's public id — the `sessionId` of its events and of the x402 binding (GAP-86). */
|
|
230
|
+
sessionId: string;
|
|
231
|
+
/** The conversation this session belongs to: the root's public id, stable across resumes (GAP-84). */
|
|
232
|
+
conversationId: string;
|
|
233
|
+
expiresAt: string;
|
|
234
|
+
/** On a resume: the base the next `llm_call.start` may ship a delta against (GAP-89). */
|
|
235
|
+
prompt?: PromptBase;
|
|
236
|
+
}
|
|
200
237
|
declare const MAX_BATCH_EVENTS = 500;
|
|
201
|
-
|
|
202
|
-
|
|
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>;
|
|
238
|
+
/** The batch as the route takes it; each event is judged on its own by the Collector, with its own result (GAP-17). */
|
|
239
|
+
declare const EvidenceBatchInputSchema: z.ZodArray<z.ZodUnknown>;
|
|
234
240
|
/** Per-event outcome of a batch (GAP-17). `seq` is null when the event could not be parsed. */
|
|
235
|
-
|
|
236
|
-
index:
|
|
237
|
-
sessionId:
|
|
238
|
-
source:
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
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>;
|
|
241
|
+
interface EventResult {
|
|
242
|
+
index: number;
|
|
243
|
+
sessionId: string | null;
|
|
244
|
+
source: EvidenceSource | null;
|
|
245
|
+
seq: number | null;
|
|
246
|
+
status: 'ok' | 'duplicate' | 'fork' | 'rejected';
|
|
247
|
+
code?: string;
|
|
248
|
+
eventDigest?: Hex64;
|
|
249
|
+
}
|
|
250
|
+
interface EvidenceAck {
|
|
251
|
+
results: EventResult[];
|
|
252
|
+
/** Head of every chain touched by the batch, after the batch. Keyed `sessionId:source`. */
|
|
253
|
+
heads: Record<string, ChainHead>;
|
|
254
|
+
}
|
|
281
255
|
declare const PaymentSummarySchema: z.ZodObject<{
|
|
282
256
|
protocol: z.ZodString;
|
|
283
257
|
payee: z.ZodString;
|
|
@@ -289,7 +263,7 @@ declare const PaymentSummarySchema: z.ZodObject<{
|
|
|
289
263
|
}, z.core.$strict>;
|
|
290
264
|
type PaymentSummary = z.infer<typeof PaymentSummarySchema>;
|
|
291
265
|
declare const EvaluateInputSchema: z.ZodObject<{
|
|
292
|
-
sessionId: z.
|
|
266
|
+
sessionId: z.ZodString;
|
|
293
267
|
payment: z.ZodObject<{
|
|
294
268
|
protocol: z.ZodString;
|
|
295
269
|
payee: z.ZodString;
|
|
@@ -299,25 +273,17 @@ declare const EvaluateInputSchema: z.ZodObject<{
|
|
|
299
273
|
}, z.core.$strict>;
|
|
300
274
|
payer: z.ZodOptional<z.ZodString>;
|
|
301
275
|
}, z.core.$strict>;
|
|
276
|
+
callId: z.ZodOptional<z.ZodString>;
|
|
302
277
|
}, z.core.$strict>;
|
|
303
278
|
type EvaluateInput = z.infer<typeof EvaluateInputSchema>;
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
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>;
|
|
279
|
+
type Decision = 'ALLOW' | 'DENY' | 'REVIEW';
|
|
280
|
+
interface EvaluateOutput {
|
|
281
|
+
decision: Decision;
|
|
282
|
+
reasonCodes: string[];
|
|
283
|
+
sessionId: string;
|
|
284
|
+
/** Additive (GAP-21). */
|
|
285
|
+
decisionId: string;
|
|
286
|
+
}
|
|
321
287
|
/** Non-RFC admin surface (GAP-53). */
|
|
322
288
|
declare const CreatePolicyInputSchema: z.ZodObject<{
|
|
323
289
|
rules: z.ZodObject<{
|
|
@@ -343,20 +309,13 @@ declare const CreatePolicyInputSchema: z.ZodObject<{
|
|
|
343
309
|
}>>;
|
|
344
310
|
code: z.ZodString;
|
|
345
311
|
}, z.core.$strict>>;
|
|
346
|
-
scoreThresholds: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodNumber>>;
|
|
347
312
|
}, z.core.$strict>;
|
|
348
313
|
}, z.core.$strict>;
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
ACTIVE: "ACTIVE";
|
|
355
|
-
SUPERSEDED: "SUPERSEDED";
|
|
356
|
-
DRAFT: "DRAFT";
|
|
357
|
-
}>;
|
|
358
|
-
}, z.core.$strict>;
|
|
359
|
-
type CreatePolicyOutput = z.infer<typeof CreatePolicyOutputSchema>;
|
|
314
|
+
interface CreatePolicyOutput {
|
|
315
|
+
policyId: string;
|
|
316
|
+
version: number;
|
|
317
|
+
status: 'ACTIVE' | 'SUPERSEDED' | 'DRAFT';
|
|
318
|
+
}
|
|
360
319
|
/** Error envelope (GAP-20). */
|
|
361
320
|
declare const ApiErrorSchema: z.ZodObject<{
|
|
362
321
|
error: z.ZodObject<{
|
|
@@ -377,7 +336,6 @@ declare const SessionOpenPayloadSchema: z.ZodObject<{
|
|
|
377
336
|
}, z.core.$loose>;
|
|
378
337
|
attestations: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodType<JsonValue, unknown, z.core.$ZodTypeInternals<JsonValue, unknown>>>>;
|
|
379
338
|
}, z.core.$loose>;
|
|
380
|
-
declare const SESSION_CLOSE_REASONS: readonly ["completed", "settled", "aborted", "expired"];
|
|
381
339
|
declare const SessionClosePayloadSchema: z.ZodObject<{
|
|
382
340
|
reason: z.ZodEnum<{
|
|
383
341
|
completed: "completed";
|
|
@@ -396,11 +354,38 @@ declare const IntentDeclaredPayloadSchema: z.ZodObject<{
|
|
|
396
354
|
merchantAllowlist: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
397
355
|
validUntil: z.ZodISODateTime;
|
|
398
356
|
}, z.core.$loose>;
|
|
357
|
+
/**
|
|
358
|
+
* A prompt as the difference from an earlier call's (GAP-89): `prior` is
|
|
359
|
+
* the `callId` of the `llm_call.start` whose *unfolded* prompt this one
|
|
360
|
+
* extends, `shared` how many of its leading messages are equal (JCS +
|
|
361
|
+
* SHA-256 per message), `messages` the rest.
|
|
362
|
+
*/
|
|
363
|
+
declare const PromptDeltaSchema: z.ZodObject<{
|
|
364
|
+
prior: z.ZodString;
|
|
365
|
+
shared: z.ZodNumber;
|
|
366
|
+
messages: z.ZodArray<z.ZodType<JsonValue, unknown, z.core.$ZodTypeInternals<JsonValue, unknown>>>;
|
|
367
|
+
}, z.core.$strict>;
|
|
368
|
+
/** The provider-level call options (GAP-57); the prompt whole, or as a delta, never both. */
|
|
369
|
+
declare const LlmCallParamsSchema: z.ZodObject<{
|
|
370
|
+
prompt: z.ZodOptional<z.ZodType<JsonValue, unknown, z.core.$ZodTypeInternals<JsonValue, unknown>>>;
|
|
371
|
+
promptDelta: z.ZodOptional<z.ZodObject<{
|
|
372
|
+
prior: z.ZodString;
|
|
373
|
+
shared: z.ZodNumber;
|
|
374
|
+
messages: z.ZodArray<z.ZodType<JsonValue, unknown, z.core.$ZodTypeInternals<JsonValue, unknown>>>;
|
|
375
|
+
}, z.core.$strict>>;
|
|
376
|
+
}, z.core.$loose>;
|
|
399
377
|
declare const LlmCallStartPayloadSchema: z.ZodObject<{
|
|
400
378
|
callId: z.ZodString;
|
|
401
379
|
provider: z.ZodString;
|
|
402
380
|
modelId: z.ZodString;
|
|
403
|
-
params: z.
|
|
381
|
+
params: z.ZodObject<{
|
|
382
|
+
prompt: z.ZodOptional<z.ZodType<JsonValue, unknown, z.core.$ZodTypeInternals<JsonValue, unknown>>>;
|
|
383
|
+
promptDelta: z.ZodOptional<z.ZodObject<{
|
|
384
|
+
prior: z.ZodString;
|
|
385
|
+
shared: z.ZodNumber;
|
|
386
|
+
messages: z.ZodArray<z.ZodType<JsonValue, unknown, z.core.$ZodTypeInternals<JsonValue, unknown>>>;
|
|
387
|
+
}, z.core.$strict>>;
|
|
388
|
+
}, z.core.$loose>;
|
|
404
389
|
}, z.core.$loose>;
|
|
405
390
|
declare const LlmCallEndPayloadSchema: z.ZodObject<{
|
|
406
391
|
callId: z.ZodString;
|
|
@@ -432,7 +417,6 @@ declare const ToolCallEndPayloadSchema: z.ZodObject<{
|
|
|
432
417
|
}, z.core.$loose>>;
|
|
433
418
|
durationMs: z.ZodNumber;
|
|
434
419
|
}, z.core.$loose>;
|
|
435
|
-
declare const PAYMENT_ARTIFACTS: readonly ["http-402", "mrtr-input-required", "payment-signature", "checkout-url"];
|
|
436
420
|
/**
|
|
437
421
|
* A payment moment, normalized across protocols so the engine can compare
|
|
438
422
|
* the two sides of the same purchase (`EVIDENCE_MISMATCH`, GAP-50). `raw` is
|
|
@@ -470,9 +454,14 @@ declare const GatewayDecisionPayloadSchema: z.ZodObject<{
|
|
|
470
454
|
reasonCodes: z.ZodArray<z.ZodString>;
|
|
471
455
|
record: z.ZodRecord<z.ZodString, z.ZodType<JsonValue, unknown, z.core.$ZodTypeInternals<JsonValue, unknown>>>;
|
|
472
456
|
}, z.core.$loose>;
|
|
473
|
-
/**
|
|
457
|
+
/**
|
|
458
|
+
* Emitted by the SDK after it dropped events pre-sequencing (GAP-38): for
|
|
459
|
+
* lack of room in its buffer, or — `oversized` of them — because the
|
|
460
|
+
* platform would refuse them as too large (GAP-87).
|
|
461
|
+
*/
|
|
474
462
|
declare const TransportGapPayloadSchema: z.ZodObject<{
|
|
475
463
|
dropped: z.ZodNumber;
|
|
464
|
+
oversized: z.ZodOptional<z.ZodNumber>;
|
|
476
465
|
firstTs: z.ZodString;
|
|
477
466
|
lastTs: z.ZodString;
|
|
478
467
|
}, z.core.$loose>;
|
|
@@ -482,7 +471,6 @@ declare const PlatformObservationPayloadSchema: z.ZodObject<{
|
|
|
482
471
|
params: z.ZodType<JsonValue, unknown, z.core.$ZodTypeInternals<JsonValue, unknown>>;
|
|
483
472
|
response: z.ZodType<JsonValue, unknown, z.core.$ZodTypeInternals<JsonValue, unknown>>;
|
|
484
473
|
}, z.core.$strict>;
|
|
485
|
-
declare const ANOMALY_TYPES: readonly ["fork", "seq_gap", "prev_hash_mismatch", "bad_sig", "clock_skew", "source_conflict"];
|
|
486
474
|
declare const PlatformAnomalyPayloadSchema: z.ZodObject<{
|
|
487
475
|
type: z.ZodEnum<{
|
|
488
476
|
fork: "fork";
|
|
@@ -503,6 +491,8 @@ declare const PlatformAnomalyPayloadSchema: z.ZodObject<{
|
|
|
503
491
|
type SessionOpenPayload = z.infer<typeof SessionOpenPayloadSchema>;
|
|
504
492
|
type SessionClosePayload = z.infer<typeof SessionClosePayloadSchema>;
|
|
505
493
|
type IntentDeclaredPayload = z.infer<typeof IntentDeclaredPayloadSchema>;
|
|
494
|
+
type PromptDelta = z.infer<typeof PromptDeltaSchema>;
|
|
495
|
+
type LlmCallParams = z.infer<typeof LlmCallParamsSchema>;
|
|
506
496
|
type LlmCallStartPayload = z.infer<typeof LlmCallStartPayloadSchema>;
|
|
507
497
|
type LlmCallEndPayload = z.infer<typeof LlmCallEndPayloadSchema>;
|
|
508
498
|
type ToolCallStartPayload = z.infer<typeof ToolCallStartPayloadSchema>;
|
|
@@ -529,4 +519,4 @@ interface PayloadByKind {
|
|
|
529
519
|
'platform.anomaly': PlatformAnomalyPayload;
|
|
530
520
|
}
|
|
531
521
|
|
|
532
|
-
export { type
|
|
522
|
+
export { type Sig as $, ALL_SOURCES as A, type LlmCallParams as B, type ChainHead as C, type Decision as D, type EvidenceSourceAll as E, type LlmCallStartPayload as F, type GatewayDecisionPayload as G, type Hex64 as H, type IntentDeclaredPayload as I, type JsonValue as J, type PaymentMomentPayload as K, type LlmCallEndPayload as L, MAX_BATCH_EVENTS as M, type PaymentSummary as N, PaymentSummarySchema as O, type PayloadByKind as P, type PlatformAnomalyPayload as Q, type PlatformEvidenceKind as R, type PlatformObservationPayload as S, type PromptBase as T, type PromptDelta as U, SESSION_ID_CHARS as V, SESSION_ID_PREFIX as W, SOURCE_ORDER as X, type SessionClosePayload as Y, SessionIdSchema as Z, type SessionOpenPayload as _, type ApiError as a, TimestampSchema as a0, type ToolCallEndPayload as a1, type ToolCallStartPayload as a2, type TransportGapPayload as a3, type WireEvidenceKind as a4, chainKey as a5, compareByArrival as a6, compareBySessionSource as a7, compareBySourceSeq as a8, compareRootFirst as a9, payloadSchemaFor as aa, withinHeads as ab, ApiErrorSchema as b, CreatePolicyInputSchema as c, type CreatePolicyOutput as d, type CreateSessionInput as e, CreateSessionInputSchema as f, type CreateSessionOutput as g, type DeclaredIntent as h, DeclaredIntentSchema as i, type DigestedEnvelope as j, type EvaluateInput as k, EvaluateInputSchema as l, type EvaluateOutput as m, type EventResult as n, type EvidenceAck as o, EvidenceBatchInputSchema as p, type EvidenceEnvelope as q, type EvidenceEvent as r, EvidenceEventSchema as s, type EvidenceKind as t, type EvidenceSource as u, EvidenceSourceAllSchema as v, EvidenceSourceSchema as w, Hex64Schema as x, type JsonObject as y, JsonValueSchema as z };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
export { B as Beltic, a as BelticOptions, S as SDK_VERSION } from './client-
|
|
2
|
-
export { B as BelticApiError, C as ChainRejectedError, D as DecideOptions, a as Decision, H as HumanDecisionInput, S as Session, b as SessionOptions } from './session-
|
|
3
|
-
import './index-
|
|
1
|
+
export { B as Beltic, a as BelticOptions, S as SDK_VERSION } from './client-Xn9M58OJ.js';
|
|
2
|
+
export { B as BelticApiError, C as ChainRejectedError, D as DecideOptions, a as Decision, H as HumanDecisionInput, S as Session, b as SessionOptions } from './session-DAN29XoB.js';
|
|
3
|
+
import './index-DAVKGJs5.js';
|
|
4
4
|
import 'zod';
|
|
5
5
|
|
|
6
6
|
/**
|