@belticlabs/agent-risk-sdk 0.4.0 → 0.6.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-AjCgj-KM.d.ts +6 -0
- package/dist/ai/index.d.ts +6 -16
- package/dist/ai/index.js +23 -32
- package/dist/{chunk-X3W2Z5GC.js → chunk-77D74TWX.js} +0 -1
- package/dist/{chunk-WY5ZX4BD.js → chunk-IUWC6HT5.js} +24 -57
- package/dist/chunk-M4I3FGZG.js +13 -0
- package/dist/chunk-ZMPKY7AX.js +39 -0
- package/dist/client-CgCjOrRP.d.ts +65 -0
- package/dist/{verdict-CDAsxktI.d.ts → index-IfY4XCvJ.d.ts} +1 -24
- package/dist/index.d.ts +12 -33
- package/dist/index.js +400 -366
- package/dist/protocol/index.d.ts +26 -3
- package/dist/protocol/index.js +487 -74
- package/dist/session-Dcof4UIn.d.ts +308 -0
- package/dist/x402/hono.d.ts +6 -17
- package/dist/x402/hono.js +7 -13
- package/dist/x402/index.d.ts +25 -44
- package/dist/x402/index.js +11 -32
- package/package.json +1 -1
- package/dist/adapter-CLy44CD2.d.ts +0 -29
- package/dist/chunk-4BUUPU3O.js +0 -558
- package/dist/chunk-4MG6VNAU.js +0 -276
- package/dist/session-gK51QVAM.d.ts +0 -484
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { x402ResourceServer, x402HTTPResourceServer } from '@x402/core/server';
|
|
2
|
+
import { B as Beltic } from './client-CgCjOrRP.js';
|
|
3
|
+
|
|
4
|
+
declare function attachX402(beltic: Beltic, server: x402ResourceServer, http?: x402HTTPResourceServer): void;
|
|
5
|
+
|
|
6
|
+
export { attachX402 as a };
|
package/dist/ai/index.d.ts
CHANGED
|
@@ -1,19 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import
|
|
1
|
+
import { LanguageModelMiddleware, ToolSet } from 'ai';
|
|
2
|
+
import { S as Session } from '../session-Dcof4UIn.js';
|
|
3
|
+
import '../index-IfY4XCvJ.js';
|
|
4
4
|
import 'zod';
|
|
5
5
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
presented?: PaymentMomentPayload;
|
|
9
|
-
}
|
|
10
|
-
interface WrapToolOptions<I = unknown, O = unknown> {
|
|
11
|
-
name?: string;
|
|
12
|
-
/** When the tool performs a purchase, map its input/output to the payment moments it produced. */
|
|
13
|
-
payment?: (input: I, output: O) => PaymentMoments | null;
|
|
14
|
-
}
|
|
15
|
-
declare function middleware(source: SessionSource): LanguageModelMiddleware;
|
|
16
|
-
declare function wrapTool<T extends Tool>(source: SessionSource, tool: T, opts?: WrapToolOptions): T;
|
|
17
|
-
declare function wrapTools<T extends ToolSet>(source: SessionSource, tools: T, opts?: Record<string, WrapToolOptions>): T;
|
|
6
|
+
declare function middleware(session: Session): LanguageModelMiddleware;
|
|
7
|
+
declare function wrapTools<T extends ToolSet>(session: Session, tools: T): T;
|
|
18
8
|
|
|
19
|
-
export {
|
|
9
|
+
export { middleware, wrapTools };
|
package/dist/ai/index.js
CHANGED
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
import {
|
|
2
|
-
Sessions,
|
|
3
2
|
recordCall
|
|
4
|
-
} from "../chunk-
|
|
3
|
+
} from "../chunk-ZMPKY7AX.js";
|
|
5
4
|
import {
|
|
6
5
|
toJson,
|
|
7
6
|
toJsonObject
|
|
8
7
|
} from "../chunk-FQDHFTVR.js";
|
|
9
8
|
import {
|
|
10
9
|
uuidv7
|
|
11
|
-
} from "../chunk-
|
|
10
|
+
} from "../chunk-77D74TWX.js";
|
|
12
11
|
|
|
13
12
|
// src/ai/index.ts
|
|
14
13
|
var PARAM_KEYS = [
|
|
@@ -23,14 +22,13 @@ var PARAM_KEYS = [
|
|
|
23
22
|
"responseFormat",
|
|
24
23
|
"stopSequences"
|
|
25
24
|
];
|
|
26
|
-
function middleware(
|
|
27
|
-
if (!source) return {};
|
|
25
|
+
function middleware(session) {
|
|
28
26
|
return {
|
|
29
27
|
wrapGenerate: async ({ doGenerate, params, model }) => {
|
|
30
|
-
const
|
|
31
|
-
if (!
|
|
28
|
+
const stream = await session.stream();
|
|
29
|
+
if (!stream) return doGenerate();
|
|
32
30
|
return recordCall(
|
|
33
|
-
|
|
31
|
+
stream,
|
|
34
32
|
"llm_call",
|
|
35
33
|
uuidv7(),
|
|
36
34
|
{ provider: model.provider, modelId: model.modelId, params: pick(params) },
|
|
@@ -44,11 +42,11 @@ function middleware(source) {
|
|
|
44
42
|
},
|
|
45
43
|
// A stream ends when it drains, not when doStream resolves — so its end is emitted at flush.
|
|
46
44
|
wrapStream: async ({ doStream, params, model }) => {
|
|
47
|
-
const
|
|
48
|
-
if (!
|
|
45
|
+
const evidence = await session.stream();
|
|
46
|
+
if (!evidence) return doStream();
|
|
49
47
|
const callId = uuidv7();
|
|
50
48
|
const started = Date.now();
|
|
51
|
-
await
|
|
49
|
+
await evidence.emit("llm_call.start", {
|
|
52
50
|
callId,
|
|
53
51
|
provider: model.provider,
|
|
54
52
|
modelId: model.modelId,
|
|
@@ -66,7 +64,7 @@ function middleware(source) {
|
|
|
66
64
|
controller.enqueue(part);
|
|
67
65
|
},
|
|
68
66
|
flush: async () => {
|
|
69
|
-
await
|
|
67
|
+
await evidence.emit("llm_call.end", {
|
|
70
68
|
callId,
|
|
71
69
|
content: toJson(parts),
|
|
72
70
|
...finish.finishReason ? { finishReason: finish.finishReason } : {},
|
|
@@ -79,38 +77,32 @@ function middleware(source) {
|
|
|
79
77
|
}
|
|
80
78
|
};
|
|
81
79
|
}
|
|
82
|
-
function
|
|
83
|
-
|
|
80
|
+
function wrapTools(session, tools) {
|
|
81
|
+
const out = {};
|
|
82
|
+
for (const [name, tool] of Object.entries(tools))
|
|
83
|
+
out[name] = wrapTool(session, name, tool);
|
|
84
|
+
return out;
|
|
85
|
+
}
|
|
86
|
+
function wrapTool(session, toolName, tool) {
|
|
87
|
+
if (!tool.execute) return tool;
|
|
84
88
|
const original = tool.execute;
|
|
85
|
-
const toolName = opts.name ?? tool.name ?? "tool";
|
|
86
89
|
const execute = async (input, options) => {
|
|
87
|
-
const
|
|
88
|
-
if (!
|
|
90
|
+
const stream = await session.stream();
|
|
91
|
+
if (!stream) return original(input, options);
|
|
89
92
|
return recordCall(
|
|
90
|
-
|
|
93
|
+
stream,
|
|
91
94
|
"tool_call",
|
|
92
|
-
options
|
|
95
|
+
options.toolCallId,
|
|
93
96
|
{ toolName, input: toJson(input), transport: "local" },
|
|
94
97
|
async () => {
|
|
95
98
|
const output = await original(input, options);
|
|
96
99
|
return output && typeof output === "object" && Symbol.asyncIterator in output ? collect(output) : output;
|
|
97
100
|
},
|
|
98
|
-
|
|
99
|
-
const moments = opts.payment?.(input, output) ?? null;
|
|
100
|
-
if (moments?.requested) await session.emit("payment.requested", moments.requested);
|
|
101
|
-
if (moments?.presented) await session.emit("payment.presented", moments.presented);
|
|
102
|
-
return { output: toJson(output) };
|
|
103
|
-
}
|
|
101
|
+
(output) => ({ output: toJson(output) })
|
|
104
102
|
);
|
|
105
103
|
};
|
|
106
104
|
return { ...tool, execute };
|
|
107
105
|
}
|
|
108
|
-
function wrapTools(source, tools, opts = {}) {
|
|
109
|
-
const out = {};
|
|
110
|
-
for (const [name, tool] of Object.entries(tools))
|
|
111
|
-
out[name] = wrapTool(source, tool, { name, ...opts[name] });
|
|
112
|
-
return out;
|
|
113
|
-
}
|
|
114
106
|
function pick(params) {
|
|
115
107
|
const out = {};
|
|
116
108
|
for (const k of PARAM_KEYS) {
|
|
@@ -126,6 +118,5 @@ async function collect(it) {
|
|
|
126
118
|
}
|
|
127
119
|
export {
|
|
128
120
|
middleware,
|
|
129
|
-
wrapTool,
|
|
130
121
|
wrapTools
|
|
131
122
|
};
|
|
@@ -1,22 +1,18 @@
|
|
|
1
|
+
import {
|
|
2
|
+
summaryOf
|
|
3
|
+
} from "./chunk-M4I3FGZG.js";
|
|
1
4
|
import {
|
|
2
5
|
toJsonObject
|
|
3
6
|
} from "./chunk-FQDHFTVR.js";
|
|
4
7
|
import {
|
|
5
8
|
payloadDigest
|
|
6
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-77D74TWX.js";
|
|
7
10
|
|
|
8
11
|
// src/x402/binding.ts
|
|
9
12
|
var SESSION_EXTENSION = "beltic.sessionId";
|
|
10
13
|
var SESSION_HEADER = "Beltic-Session-Id";
|
|
11
|
-
var DECISION_EXTENSION = "beltic.decisionId";
|
|
12
14
|
function sessionIdOf(extensions) {
|
|
13
|
-
|
|
14
|
-
}
|
|
15
|
-
function decisionIdOf(extensions) {
|
|
16
|
-
return stringAt(extensions, DECISION_EXTENSION);
|
|
17
|
-
}
|
|
18
|
-
function stringAt(extensions, key) {
|
|
19
|
-
const v = extensions?.[key];
|
|
15
|
+
const v = extensions?.[SESSION_EXTENSION];
|
|
20
16
|
return typeof v === "string" && v.length > 0 ? v : null;
|
|
21
17
|
}
|
|
22
18
|
|
|
@@ -95,24 +91,15 @@ function priceValue(price) {
|
|
|
95
91
|
}
|
|
96
92
|
|
|
97
93
|
// src/x402/adapter.ts
|
|
98
|
-
function attachX402(beltic, server, http
|
|
94
|
+
function attachX402(beltic, server, http) {
|
|
99
95
|
const inFlight = /* @__PURE__ */ new Map();
|
|
100
|
-
const resolveSession = async (bound, ctx) => {
|
|
101
|
-
const key = opts.correlate?.(ctx) ?? null;
|
|
102
|
-
return bound ?? (key ? await beltic.correlation.resolve(key) : null);
|
|
103
|
-
};
|
|
104
96
|
http?.onProtectedRequest(async (ctx, route) => {
|
|
105
97
|
if (ctx.paymentHeader) return;
|
|
106
98
|
const bound = ctx.adapter.getHeader(SESSION_HEADER) ?? ctx.adapter.getHeader(SESSION_HEADER.toLowerCase());
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
method: ctx.method,
|
|
110
|
-
header: (n) => ctx.adapter.getHeader(n)
|
|
111
|
-
});
|
|
112
|
-
if (!sessionId) return;
|
|
113
|
-
const session = await beltic.sessions.ensure(sessionId);
|
|
99
|
+
if (!bound) return;
|
|
100
|
+
const stream = await beltic.streams.ensure(bound);
|
|
114
101
|
const accepts = Array.isArray(route.accepts) ? route.accepts[0] : route.accepts;
|
|
115
|
-
await
|
|
102
|
+
await stream.emit(
|
|
116
103
|
"payment.requested",
|
|
117
104
|
x402Moments.route(accepts, {
|
|
118
105
|
path: ctx.path,
|
|
@@ -124,54 +111,34 @@ function attachX402(beltic, server, http, opts = {}) {
|
|
|
124
111
|
server.onBeforeVerify(async (ctx) => {
|
|
125
112
|
const payload = ctx.paymentPayload;
|
|
126
113
|
const requirements = ctx.requirements;
|
|
127
|
-
const
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
header: () => void 0
|
|
131
|
-
});
|
|
132
|
-
const session = await beltic.sessions.ensure(sessionId);
|
|
133
|
-
if (session.born === "seller")
|
|
134
|
-
await session.emit("payment.requested", x402Moments.requirements(requirements));
|
|
114
|
+
const stream = await beltic.streams.ensure(sessionIdOf(payload.extensions));
|
|
115
|
+
if (stream.born === "seller")
|
|
116
|
+
await stream.emit("payment.requested", x402Moments.requirements(requirements));
|
|
135
117
|
const presented = x402Moments.payload(payload);
|
|
136
|
-
await
|
|
137
|
-
inFlight.set(payloadDigest(payload),
|
|
138
|
-
const
|
|
139
|
-
if (
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
buyerDecisionId: decisionIdOf(payload.extensions)
|
|
146
|
-
});
|
|
147
|
-
if (out.verdict.blocks(beltic.onReview)) {
|
|
148
|
-
return {
|
|
149
|
-
abort: true,
|
|
150
|
-
reason: `BELTIC_${out.verdict.value}`,
|
|
151
|
-
message: out.reasonCodes.join(",")
|
|
152
|
-
};
|
|
153
|
-
}
|
|
154
|
-
return;
|
|
118
|
+
await stream.emit("payment.presented", presented);
|
|
119
|
+
inFlight.set(payloadDigest(payload), stream);
|
|
120
|
+
const decision = await beltic.evaluate(stream.id, summaryOf(presented));
|
|
121
|
+
if (decision.absent || decision.allowed) return;
|
|
122
|
+
return {
|
|
123
|
+
abort: true,
|
|
124
|
+
reason: `BELTIC_${decision.value}`,
|
|
125
|
+
message: decision.reasonCodes.join(",")
|
|
126
|
+
};
|
|
155
127
|
});
|
|
156
128
|
server.onAfterSettle(async (ctx) => {
|
|
157
129
|
const key = payloadDigest(ctx.paymentPayload);
|
|
158
|
-
const
|
|
159
|
-
if (!
|
|
130
|
+
const stream = inFlight.get(key);
|
|
131
|
+
if (!stream) return;
|
|
160
132
|
inFlight.delete(key);
|
|
161
|
-
if (ctx.result.success) await
|
|
133
|
+
if (ctx.result.success) await stream.close("settled", { transaction: ctx.result.transaction });
|
|
162
134
|
});
|
|
163
|
-
return { inFlight };
|
|
164
135
|
}
|
|
165
136
|
|
|
166
137
|
export {
|
|
167
138
|
SESSION_EXTENSION,
|
|
168
139
|
SESSION_HEADER,
|
|
169
|
-
DECISION_EXTENSION,
|
|
170
|
-
sessionIdOf,
|
|
171
|
-
decisionIdOf,
|
|
172
140
|
x402Currency,
|
|
173
141
|
x402Summary,
|
|
174
|
-
payerOf,
|
|
175
142
|
x402Moments,
|
|
176
143
|
attachX402
|
|
177
144
|
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
// src/core/payment-moment.ts
|
|
2
|
+
function summaryOf(m) {
|
|
3
|
+
return {
|
|
4
|
+
protocol: m.protocol,
|
|
5
|
+
payee: m.payee,
|
|
6
|
+
amount: { value: m.amount.value, currency: m.amount.currency },
|
|
7
|
+
...m.payer ? { payer: m.payer } : {}
|
|
8
|
+
};
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export {
|
|
12
|
+
summaryOf
|
|
13
|
+
};
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
// src/core/record.ts
|
|
2
|
+
function errorOf(err) {
|
|
3
|
+
const e = err;
|
|
4
|
+
return { name: String(e?.name ?? "Error"), message: String(e?.message ?? err) };
|
|
5
|
+
}
|
|
6
|
+
function openCall(stream, kind, callId, start) {
|
|
7
|
+
const started = Date.now();
|
|
8
|
+
const opened = stream.emit(`${kind}.start`, { callId, ...start });
|
|
9
|
+
const close = async (outcome) => {
|
|
10
|
+
await opened;
|
|
11
|
+
return stream.emit(
|
|
12
|
+
`${kind}.end`,
|
|
13
|
+
{ callId, ...outcome, durationMs: Date.now() - started }
|
|
14
|
+
);
|
|
15
|
+
};
|
|
16
|
+
return {
|
|
17
|
+
callId,
|
|
18
|
+
opened,
|
|
19
|
+
end: (outcome = {}) => close(outcome),
|
|
20
|
+
fail: (error, outcome = {}) => close({ error: errorOf(error), ...outcome })
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
async function recordCall(stream, kind, callId, start, run, end = () => ({})) {
|
|
24
|
+
const span = openCall(stream, kind, callId, start);
|
|
25
|
+
await span.opened;
|
|
26
|
+
try {
|
|
27
|
+
const result = await run();
|
|
28
|
+
await span.end(await end(result));
|
|
29
|
+
return result;
|
|
30
|
+
} catch (err) {
|
|
31
|
+
await span.fail(err);
|
|
32
|
+
throw err;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export {
|
|
37
|
+
openCall,
|
|
38
|
+
recordCall
|
|
39
|
+
};
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { a7 as PaymentSummary } from './index-IfY4XCvJ.js';
|
|
2
|
+
import { b as SessionOptions, S as Session, a as Decision } from './session-Dcof4UIn.js';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* One SDK, two halves (Fraud SDK RFC › Summary). `Beltic` is the single
|
|
6
|
+
* client: `session` for the buyer half, `evaluate` for whichever half is
|
|
7
|
+
* about to let a payment through. Protocol integrations are plain
|
|
8
|
+
* functions behind subpath exports, each pulling exactly one optional peer:
|
|
9
|
+
*
|
|
10
|
+
* @belticlabs/agent-risk-sdk/ai → middleware(session), wrapTools(session, …)
|
|
11
|
+
* @belticlabs/agent-risk-sdk/x402 → belticFetch(session), x402Summary(…), attachX402(beltic, …)
|
|
12
|
+
* @belticlabs/agent-risk-sdk/hono → belticPaymentMiddleware(beltic, …)
|
|
13
|
+
*
|
|
14
|
+
* Neither half decides risk locally: verdicts are platform-side.
|
|
15
|
+
*
|
|
16
|
+
* A client is configured or it is not constructed — `Beltic.fromEnv()`
|
|
17
|
+
* reads `BELTIC_*`, and there is no disabled client (GAP-78). Evidence is
|
|
18
|
+
* a side channel of the work it observes, so a platform outage never
|
|
19
|
+
* throws into that work (GAP-70): the transport waits it out, `session`
|
|
20
|
+
* runs without a stream, `evaluate` answers `Decision.absent()` — never an
|
|
21
|
+
* invented verdict. What the platform *rejects* (a 4xx, a forked chain)
|
|
22
|
+
* is the client's fault and throws.
|
|
23
|
+
*/
|
|
24
|
+
|
|
25
|
+
declare const SDK_VERSION = "0.6.0";
|
|
26
|
+
interface BelticOptions {
|
|
27
|
+
apiKey: string;
|
|
28
|
+
baseUrl: string;
|
|
29
|
+
/** The agent's 32-byte Ed25519 seed as 64 hex — the buyer half. Without it, `session` is unavailable; the seller half works. */
|
|
30
|
+
agentSeed?: string | undefined;
|
|
31
|
+
}
|
|
32
|
+
declare class Beltic {
|
|
33
|
+
private readonly api;
|
|
34
|
+
private readonly transport;
|
|
35
|
+
private readonly sessions;
|
|
36
|
+
/**
|
|
37
|
+
* The client the environment describes: `BELTIC_API_KEY` and
|
|
38
|
+
* `BELTIC_BASE_URL`, both required, and `BELTIC_AGENT_SEED` (64 hex) for
|
|
39
|
+
* the buyer half. A missing required variable is a configuration error,
|
|
40
|
+
* thrown (GAP-78).
|
|
41
|
+
*/
|
|
42
|
+
static fromEnv(env?: Record<string, string | undefined>): Beltic;
|
|
43
|
+
constructor(opts: BelticOptions);
|
|
44
|
+
/**
|
|
45
|
+
* The session for a key of the host's own (its session, run or
|
|
46
|
+
* conversation id) — one object per key until it closes; the options
|
|
47
|
+
* count on the first call only. See `Session`.
|
|
48
|
+
*/
|
|
49
|
+
session(key: string, opts?: SessionOptions): Session;
|
|
50
|
+
/**
|
|
51
|
+
* The platform's verdict on a payment — the seller's before it verifies,
|
|
52
|
+
* the buyer's before it presents (Fraud SDK RFC › Evaluation Client).
|
|
53
|
+
* Read-your-writes: the buffered evidence is flushed first so the
|
|
54
|
+
* platform judges what the caller already saw (GAP-16). Absent when the
|
|
55
|
+
* platform could not be reached (GAP-70).
|
|
56
|
+
*/
|
|
57
|
+
evaluate(sessionId: string, payment: PaymentSummary): Promise<Decision>;
|
|
58
|
+
/** Send everything buffered now and wait for that attempt. */
|
|
59
|
+
flush(): Promise<void>;
|
|
60
|
+
shutdown(): Promise<void>;
|
|
61
|
+
/** `process.env` where there is a `process` (Node); `{}` on workerd, where the shell passes its `env`. */
|
|
62
|
+
private static processEnv;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
export { Beltic as B, SDK_VERSION as S, type BelticOptions as a };
|
|
@@ -529,27 +529,4 @@ interface PayloadByKind {
|
|
|
529
529
|
'platform.anomaly': PlatformAnomalyPayload;
|
|
530
530
|
}
|
|
531
531
|
|
|
532
|
-
|
|
533
|
-
* The verdict as a value (Fraud Engine RFC › API: ALLOW | DENY | REVIEW).
|
|
534
|
-
* Layers combine by severity (GAP-45); a synchronous seller hook turns
|
|
535
|
-
* REVIEW into a stop or a pass according to its `onReview` (GAP-52). Both
|
|
536
|
-
* halves of the SDK and the engine share this one rule.
|
|
537
|
-
*/
|
|
538
|
-
|
|
539
|
-
type OnReview = 'abort' | 'allow';
|
|
540
|
-
declare class Verdict {
|
|
541
|
-
readonly value: Decision;
|
|
542
|
-
private constructor();
|
|
543
|
-
static readonly ALLOW: Verdict;
|
|
544
|
-
static readonly REVIEW: Verdict;
|
|
545
|
-
static readonly DENY: Verdict;
|
|
546
|
-
static of(value: Decision): Verdict;
|
|
547
|
-
/** The more severe of the two. */
|
|
548
|
-
atLeast(other: Verdict | Decision): Verdict;
|
|
549
|
-
/** Whether a synchronous gate must stop the call (GAP-52). */
|
|
550
|
-
blocks(onReview: OnReview): boolean;
|
|
551
|
-
/** What the gate effectively did: DENY when it blocked, else the verdict itself. */
|
|
552
|
-
effective(onReview: OnReview): Decision;
|
|
553
|
-
}
|
|
554
|
-
|
|
555
|
-
export { type LlmCallEndPayload as $, ALL_SOURCES as A, type EventResultStatus as B, type ChainHead as C, type Decision as D, type EvidenceSourceAll as E, EventResultStatusSchema as F, type EvidenceAck as G, EvidenceAckSchema as H, type EvidenceBatchInput as I, type JsonObject as J, EvidenceBatchInputSchema as K, type EvidenceEnvelope as L, type EvidenceEvent as M, EvidenceEventSchema as N, type EvidenceKind as O, type PaymentMomentPayload as P, EvidenceKindSchema as Q, type EvidenceSource as R, EvidenceSourceAllSchema as S, EvidenceSourceSchema as T, type GatewayDecisionPayload as U, GatewayDecisionPayloadSchema as V, type Hex64 as W, Hex64Schema as X, type IntentDeclaredPayload as Y, IntentDeclaredPayloadSchema as Z, JsonValueSchema as _, type PaymentSummary as a, LlmCallEndPayloadSchema as a0, type LlmCallStartPayload as a1, LlmCallStartPayloadSchema as a2, MAX_BATCH_EVENTS as a3, type OnReview as a4, PAYMENT_ARTIFACTS as a5, PLATFORM_KINDS as a6, type PayloadByKind as a7, PaymentMomentPayloadSchema as a8, PaymentSummarySchema as a9, type WireEvidenceKind as aA, WireEvidenceKindSchema as aB, compareBySessionSource as aC, compareBySourceSeq as aD, isPlatformKind as aE, isWireKind as aF, payloadSchemaFor as aG, type PlatformAnomalyPayload as aa, PlatformAnomalyPayloadSchema as ab, type PlatformEvidenceKind as ac, PlatformEvidenceKindSchema as ad, type PlatformObservationPayload as ae, PlatformObservationPayloadSchema as af, SESSION_CLOSE_REASONS as ag, SOURCE_ORDER as ah, SeqSchema as ai, type SessionClosePayload as aj, SessionClosePayloadSchema as ak, SessionIdSchema as al, type SessionOpenPayload as am, SessionOpenPayloadSchema as an, type Sig as ao, SigSchema as ap, TimestampSchema as aq, type ToolCallEndPayload as ar, ToolCallEndPayloadSchema as as, type ToolCallStartPayload as at, ToolCallStartPayloadSchema as au, type TransportGapPayload as av, TransportGapPayloadSchema as aw, Verdict as ax, WIRE_KINDS as ay, WIRE_SOURCES as az, type JsonValue as b, ANOMALY_TYPES as c, type Amount as d, AmountSchema as e, type ApiError as f, ApiErrorSchema as g, ChainHeadSchema as h, type CreatePolicyInput as i, CreatePolicyInputSchema as j, type CreatePolicyOutput as k, CreatePolicyOutputSchema as l, type CreateSessionInput as m, CreateSessionInputSchema as n, type CreateSessionOutput as o, CreateSessionOutputSchema as p, DecisionSchema as q, type DeclaredIntent as r, DeclaredIntentSchema as s, type DigestedEnvelope as t, type EvaluateInput as u, EvaluateInputSchema as v, type EvaluateOutput as w, EvaluateOutputSchema as x, type EventResult as y, EventResultSchema as z };
|
|
532
|
+
export { type LlmCallStartPayload 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, EvidenceSourceAllSchema as P, EvidenceSourceSchema as Q, type GatewayDecisionPayload as R, GatewayDecisionPayloadSchema as S, type Hex64 as T, Hex64Schema as U, type IntentDeclaredPayload as V, IntentDeclaredPayloadSchema as W, type JsonObject as X, JsonValueSchema as Y, type LlmCallEndPayload as Z, LlmCallEndPayloadSchema as _, ANOMALY_TYPES as a, LlmCallStartPayloadSchema as a0, MAX_BATCH_EVENTS as a1, PAYMENT_ARTIFACTS as a2, PLATFORM_KINDS as a3, type PayloadByKind as a4, type PaymentMomentPayload as a5, PaymentMomentPayloadSchema as a6, type PaymentSummary as a7, PaymentSummarySchema as a8, type PlatformAnomalyPayload as a9, compareBySessionSource as aA, compareBySourceSeq as aB, isPlatformKind as aC, isWireKind as aD, payloadSchemaFor as aE, PlatformAnomalyPayloadSchema as aa, type PlatformEvidenceKind as ab, PlatformEvidenceKindSchema as ac, type PlatformObservationPayload as ad, PlatformObservationPayloadSchema as ae, SESSION_CLOSE_REASONS as af, SOURCE_ORDER as ag, SeqSchema as ah, type SessionClosePayload as ai, SessionClosePayloadSchema as aj, SessionIdSchema as ak, type SessionOpenPayload as al, SessionOpenPayloadSchema as am, type Sig as an, SigSchema as ao, TimestampSchema as ap, type ToolCallEndPayload as aq, ToolCallEndPayloadSchema as ar, type ToolCallStartPayload as as, ToolCallStartPayloadSchema as at, type TransportGapPayload as au, TransportGapPayloadSchema as av, WIRE_KINDS as aw, WIRE_SOURCES as ax, type WireEvidenceKind as ay, WireEvidenceKindSchema 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/index.d.ts
CHANGED
|
@@ -1,39 +1,18 @@
|
|
|
1
|
-
|
|
2
|
-
export {
|
|
3
|
-
import
|
|
1
|
+
export { B as Beltic, a as BelticOptions, S as SDK_VERSION } from './client-CgCjOrRP.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-Dcof4UIn.js';
|
|
3
|
+
import './index-IfY4XCvJ.js';
|
|
4
4
|
import 'zod';
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
* no
|
|
10
|
-
*
|
|
7
|
+
* A client that is not configured is a fault of the host, not a state the
|
|
8
|
+
* SDK runs in: an empty API key, a base URL that does not parse, a buyer
|
|
9
|
+
* entry with no agent identity, a `BELTIC_*` variable missing. Thrown at
|
|
10
|
+
* construction or at the first entry that needs the missing piece, and
|
|
11
|
+
* never absorbed by `failOpen` (GAP-78).
|
|
11
12
|
*/
|
|
12
|
-
declare class
|
|
13
|
-
readonly code = "
|
|
14
|
-
constructor(
|
|
13
|
+
declare class BelticConfigError extends Error {
|
|
14
|
+
readonly code = "CONFIG";
|
|
15
|
+
constructor(message: string);
|
|
15
16
|
}
|
|
16
17
|
|
|
17
|
-
|
|
18
|
-
* The shape the platform judges (`PaymentSummary`) and the shape the record
|
|
19
|
-
* keeps (`PaymentMomentPayload`) share their comparable core: payee, amount,
|
|
20
|
-
* payer. Every protocol adapter builds moments through here so the two
|
|
21
|
-
* sides of one purchase compare (`EVIDENCE_MISMATCH`, GAP-50).
|
|
22
|
-
*/
|
|
23
|
-
|
|
24
|
-
declare function summaryOf(m: PaymentSummary | PaymentMomentPayload): PaymentSummary;
|
|
25
|
-
/** A presentation the seller side saw as a signed payment, in any protocol. */
|
|
26
|
-
declare function presentedFrom(summary: PaymentSummary, raw: JsonObject): PaymentMomentPayload;
|
|
27
|
-
|
|
28
|
-
/**
|
|
29
|
-
* One instrumented call = a `*.start` event, the work, a `*.end` event
|
|
30
|
-
* carrying the outcome or the error (GAP-07 correlates them by `callId`).
|
|
31
|
-
* `openCall` is the span; `recordCall` runs the work inside one. The AI
|
|
32
|
-
* middleware, the tool wrapper, the MCP client and a host's own tool loop
|
|
33
|
-
* (`Session.toolCall`) all record the same way.
|
|
34
|
-
*/
|
|
35
|
-
|
|
36
|
-
type CallKind = 'llm_call' | 'tool_call';
|
|
37
|
-
declare function recordCall<T>(session: Session, kind: CallKind, callId: string, start: JsonObject, run: () => PromiseLike<T>, end?: (result: T) => Promise<JsonObject> | JsonObject): Promise<T>;
|
|
38
|
-
|
|
39
|
-
export { BelticDisabledError, type CallKind, Session, presentedFrom, recordCall, summaryOf };
|
|
18
|
+
export { BelticConfigError };
|