@belticlabs/agent-risk-sdk 0.3.0 → 0.4.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-CLy44CD2.d.ts} +2 -2
- package/dist/ai/index.d.ts +2 -2
- package/dist/ai/index.js +3 -4
- package/dist/{chunk-46QN2KEZ.js → chunk-4BUUPU3O.js} +0 -9
- package/dist/chunk-WY5ZX4BD.js +177 -0
- package/dist/index.d.ts +3 -3
- package/dist/index.js +17 -8
- package/dist/protocol/index.d.ts +2 -2
- package/dist/protocol/index.js +1 -5
- package/dist/{session-DsBWEP8d.d.ts → session-gK51QVAM.d.ts} +5 -6
- package/dist/{verdict-6vCyoAHE.d.ts → verdict-CDAsxktI.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 +12 -22
- package/dist/x402/index.js +14 -57
- package/package.json +2 -30
- 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,6 +1,6 @@
|
|
|
1
|
-
import { D as Decision } from './verdict-
|
|
1
|
+
import { D as Decision } from './verdict-CDAsxktI.js';
|
|
2
2
|
import { x402ResourceServer, x402HTTPResourceServer } from '@x402/core/server';
|
|
3
|
-
import { B as Beltic, n as SessionBorn, a as Session } from './session-
|
|
3
|
+
import { B as Beltic, n as SessionBorn, a as Session } from './session-gK51QVAM.js';
|
|
4
4
|
|
|
5
5
|
interface CorrelationContext {
|
|
6
6
|
path: string;
|
package/dist/ai/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { P as PaymentMomentPayload } from '../verdict-
|
|
1
|
+
import { P as PaymentMomentPayload } from '../verdict-CDAsxktI.js';
|
|
2
2
|
import { LanguageModelMiddleware, Tool, ToolSet } from 'ai';
|
|
3
|
-
import { S as SessionSource } from '../session-
|
|
3
|
+
import { S as SessionSource } from '../session-gK51QVAM.js';
|
|
4
4
|
import 'zod';
|
|
5
5
|
|
|
6
6
|
interface PaymentMoments {
|
package/dist/ai/index.js
CHANGED
|
@@ -2,14 +2,13 @@ import {
|
|
|
2
2
|
Sessions,
|
|
3
3
|
recordCall
|
|
4
4
|
} from "../chunk-4MG6VNAU.js";
|
|
5
|
-
import {
|
|
6
|
-
uuidv7
|
|
7
|
-
} from "../chunk-X3W2Z5GC.js";
|
|
8
|
-
import "../chunk-46QN2KEZ.js";
|
|
9
5
|
import {
|
|
10
6
|
toJson,
|
|
11
7
|
toJsonObject
|
|
12
8
|
} from "../chunk-FQDHFTVR.js";
|
|
9
|
+
import {
|
|
10
|
+
uuidv7
|
|
11
|
+
} from "../chunk-X3W2Z5GC.js";
|
|
13
12
|
|
|
14
13
|
// src/ai/index.ts
|
|
15
14
|
var PARAM_KEYS = [
|
|
@@ -326,13 +326,6 @@ var EvaluateOutputSchema = z4.strictObject({
|
|
|
326
326
|
/** Additive (GAP-21). */
|
|
327
327
|
decisionId: z4.uuid()
|
|
328
328
|
});
|
|
329
|
-
var AnchorEntrySchema = z4.strictObject({
|
|
330
|
-
epoch: z4.string().min(1),
|
|
331
|
-
root: Hex64Schema,
|
|
332
|
-
sig: z4.string().min(1),
|
|
333
|
-
chainRef: z4.string().optional()
|
|
334
|
-
});
|
|
335
|
-
var AnchorsOutputSchema = z4.strictObject({ entries: z4.array(AnchorEntrySchema) });
|
|
336
329
|
var CreatePolicyInputSchema = z4.strictObject({ rules: PolicyRulesSchema });
|
|
337
330
|
var CreatePolicyOutputSchema = z4.strictObject({
|
|
338
331
|
policyId: z4.uuid(),
|
|
@@ -542,8 +535,6 @@ export {
|
|
|
542
535
|
EvaluateInputSchema,
|
|
543
536
|
DecisionSchema,
|
|
544
537
|
EvaluateOutputSchema,
|
|
545
|
-
AnchorEntrySchema,
|
|
546
|
-
AnchorsOutputSchema,
|
|
547
538
|
CreatePolicyInputSchema,
|
|
548
539
|
CreatePolicyOutputSchema,
|
|
549
540
|
ApiErrorSchema,
|
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
import {
|
|
2
|
+
toJsonObject
|
|
3
|
+
} from "./chunk-FQDHFTVR.js";
|
|
4
|
+
import {
|
|
5
|
+
payloadDigest
|
|
6
|
+
} from "./chunk-X3W2Z5GC.js";
|
|
7
|
+
|
|
8
|
+
// src/x402/binding.ts
|
|
9
|
+
var SESSION_EXTENSION = "beltic.sessionId";
|
|
10
|
+
var SESSION_HEADER = "Beltic-Session-Id";
|
|
11
|
+
var DECISION_EXTENSION = "beltic.decisionId";
|
|
12
|
+
function sessionIdOf(extensions) {
|
|
13
|
+
return stringAt(extensions, SESSION_EXTENSION);
|
|
14
|
+
}
|
|
15
|
+
function decisionIdOf(extensions) {
|
|
16
|
+
return stringAt(extensions, DECISION_EXTENSION);
|
|
17
|
+
}
|
|
18
|
+
function stringAt(extensions, key) {
|
|
19
|
+
const v = extensions?.[key];
|
|
20
|
+
return typeof v === "string" && v.length > 0 ? v : null;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
// src/x402/moments.ts
|
|
24
|
+
function x402Currency(network, asset) {
|
|
25
|
+
return `${network}/${asset}`;
|
|
26
|
+
}
|
|
27
|
+
function x402Summary(accepts, opts = {}) {
|
|
28
|
+
const payer = opts.payer?.toLowerCase();
|
|
29
|
+
return {
|
|
30
|
+
protocol: "x402",
|
|
31
|
+
payee: accepts?.payTo ?? "unknown",
|
|
32
|
+
amount: {
|
|
33
|
+
value: accepts?.amount ?? "0",
|
|
34
|
+
currency: accepts ? x402Currency(accepts.network ?? "unknown", accepts.asset ?? "unknown") : "unknown"
|
|
35
|
+
},
|
|
36
|
+
...payer ? { payer } : {}
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
function fromAccepts(a, artifact, raw, payer) {
|
|
40
|
+
return { ...x402Summary(a, { payer }), artifact, raw };
|
|
41
|
+
}
|
|
42
|
+
function payerOf(payload) {
|
|
43
|
+
const p = payload.payload ?? {};
|
|
44
|
+
const auth = p.authorization;
|
|
45
|
+
const candidates = [
|
|
46
|
+
auth?.from,
|
|
47
|
+
p.from,
|
|
48
|
+
p.payer,
|
|
49
|
+
p.signer,
|
|
50
|
+
p.permit?.owner
|
|
51
|
+
];
|
|
52
|
+
const hit = candidates.find((c) => typeof c === "string" && c.length > 0);
|
|
53
|
+
return typeof hit === "string" ? hit.toLowerCase() : void 0;
|
|
54
|
+
}
|
|
55
|
+
var x402Moments = {
|
|
56
|
+
/** The 402 challenge as the buyer saw it, from the `PAYMENT-REQUIRED` header. */
|
|
57
|
+
required(required) {
|
|
58
|
+
return fromAccepts(required.accepts?.[0], "http-402", toJsonObject(required));
|
|
59
|
+
},
|
|
60
|
+
/** The requirements the seller's resource server resolved for a request. */
|
|
61
|
+
requirements(req) {
|
|
62
|
+
return fromAccepts(req, "http-402", toJsonObject(req));
|
|
63
|
+
},
|
|
64
|
+
/** A route's static `accepts` config, before any payment header exists. */
|
|
65
|
+
route(route, raw) {
|
|
66
|
+
const accepts = route ?? {};
|
|
67
|
+
const extra = accepts.extra;
|
|
68
|
+
return fromAccepts(
|
|
69
|
+
{
|
|
70
|
+
payTo: typeof accepts.payTo === "string" ? accepts.payTo : "dynamic",
|
|
71
|
+
amount: priceValue(accepts.price),
|
|
72
|
+
network: accepts.network,
|
|
73
|
+
asset: extra?.asset ?? "route"
|
|
74
|
+
},
|
|
75
|
+
"http-402",
|
|
76
|
+
raw
|
|
77
|
+
);
|
|
78
|
+
},
|
|
79
|
+
/** The signed payment the buyer presented, with the requirement it accepted. */
|
|
80
|
+
payload(payload) {
|
|
81
|
+
return fromAccepts(
|
|
82
|
+
payload.accepted,
|
|
83
|
+
"payment-signature",
|
|
84
|
+
toJsonObject(payload),
|
|
85
|
+
payerOf(payload)
|
|
86
|
+
);
|
|
87
|
+
}
|
|
88
|
+
};
|
|
89
|
+
function priceValue(price) {
|
|
90
|
+
if (typeof price === "string") return price.replace(/[^0-9.]/g, "") || "0";
|
|
91
|
+
if (typeof price === "number") return String(price);
|
|
92
|
+
if (price && typeof price === "object" && typeof price.amount === "string")
|
|
93
|
+
return price.amount;
|
|
94
|
+
return "0";
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
// src/x402/adapter.ts
|
|
98
|
+
function attachX402(beltic, server, http, opts = {}) {
|
|
99
|
+
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
|
+
http?.onProtectedRequest(async (ctx, route) => {
|
|
105
|
+
if (ctx.paymentHeader) return;
|
|
106
|
+
const bound = ctx.adapter.getHeader(SESSION_HEADER) ?? ctx.adapter.getHeader(SESSION_HEADER.toLowerCase());
|
|
107
|
+
const sessionId = await resolveSession(bound ?? null, {
|
|
108
|
+
path: ctx.path,
|
|
109
|
+
method: ctx.method,
|
|
110
|
+
header: (n) => ctx.adapter.getHeader(n)
|
|
111
|
+
});
|
|
112
|
+
if (!sessionId) return;
|
|
113
|
+
const session = await beltic.sessions.ensure(sessionId);
|
|
114
|
+
const accepts = Array.isArray(route.accepts) ? route.accepts[0] : route.accepts;
|
|
115
|
+
await session.emit(
|
|
116
|
+
"payment.requested",
|
|
117
|
+
x402Moments.route(accepts, {
|
|
118
|
+
path: ctx.path,
|
|
119
|
+
method: ctx.method,
|
|
120
|
+
route: JSON.parse(JSON.stringify(route))
|
|
121
|
+
})
|
|
122
|
+
);
|
|
123
|
+
});
|
|
124
|
+
server.onBeforeVerify(async (ctx) => {
|
|
125
|
+
const payload = ctx.paymentPayload;
|
|
126
|
+
const requirements = ctx.requirements;
|
|
127
|
+
const sessionId = await resolveSession(sessionIdOf(payload.extensions), {
|
|
128
|
+
path: payload.resource?.url ?? "",
|
|
129
|
+
method: "PAY",
|
|
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));
|
|
135
|
+
const presented = x402Moments.payload(payload);
|
|
136
|
+
await session.emit("payment.presented", presented);
|
|
137
|
+
inFlight.set(payloadDigest(payload), session);
|
|
138
|
+
const out = await beltic.evaluate(session.id, presented);
|
|
139
|
+
if (!out) return;
|
|
140
|
+
opts.onDecision?.({
|
|
141
|
+
sessionId: session.id,
|
|
142
|
+
decision: out.decision,
|
|
143
|
+
reasonCodes: out.reasonCodes,
|
|
144
|
+
born: session.born,
|
|
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;
|
|
155
|
+
});
|
|
156
|
+
server.onAfterSettle(async (ctx) => {
|
|
157
|
+
const key = payloadDigest(ctx.paymentPayload);
|
|
158
|
+
const session = inFlight.get(key);
|
|
159
|
+
if (!session) return;
|
|
160
|
+
inFlight.delete(key);
|
|
161
|
+
if (ctx.result.success) await session.close("settled", { transaction: ctx.result.transaction });
|
|
162
|
+
});
|
|
163
|
+
return { inFlight };
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
export {
|
|
167
|
+
SESSION_EXTENSION,
|
|
168
|
+
SESSION_HEADER,
|
|
169
|
+
DECISION_EXTENSION,
|
|
170
|
+
sessionIdOf,
|
|
171
|
+
decisionIdOf,
|
|
172
|
+
x402Currency,
|
|
173
|
+
x402Summary,
|
|
174
|
+
payerOf,
|
|
175
|
+
x402Moments,
|
|
176
|
+
attachX402
|
|
177
|
+
};
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { a as Session } from './session-
|
|
2
|
-
export { A as AgentIdentity, b as ApiClient, c as ApiClientOptions, B as Beltic, d as BelticApiError, e as BelticOptions, C as ChainRejectedError, f as CorrelationStore, D as DEFAULT_OPEN_RETRY_MS, g as DEFAULT_TRANSPORT, h as DecideOptions, i as Decision, E as Env, j as Evaluation, H as HumanDecisionInput, M as MemoryCorrelationStore, O as OpenSessionInput, R as RedactFn, k as Run, l as RunOptions, m as SDK_VERSION, n as SessionBorn, S as SessionSource, o as Sessions, p as StartSessionInput, T as ToolCallSpan, q as Transport, r as TransportClosedError, s as TransportOptions, t as createBeltic, u as ephemeralIdentity, v as fileIdentity, w as identityFromSeed } from './session-
|
|
3
|
-
import { a as PaymentSummary, J as JsonObject, P as PaymentMomentPayload } from './verdict-
|
|
1
|
+
import { a as Session } from './session-gK51QVAM.js';
|
|
2
|
+
export { A as AgentIdentity, b as ApiClient, c as ApiClientOptions, B as Beltic, d as BelticApiError, e as BelticOptions, C as ChainRejectedError, f as CorrelationStore, D as DEFAULT_OPEN_RETRY_MS, g as DEFAULT_TRANSPORT, h as DecideOptions, i as Decision, E as Env, j as Evaluation, H as HumanDecisionInput, M as MemoryCorrelationStore, O as OpenSessionInput, R as RedactFn, k as Run, l as RunOptions, m as SDK_VERSION, n as SessionBorn, S as SessionSource, o as Sessions, p as StartSessionInput, T as ToolCallSpan, q as Transport, r as TransportClosedError, s as TransportOptions, t as createBeltic, u as ephemeralIdentity, v as fileIdentity, w as identityFromSeed } from './session-gK51QVAM.js';
|
|
3
|
+
import { a as PaymentSummary, J as JsonObject, P as PaymentMomentPayload } from './verdict-CDAsxktI.js';
|
|
4
4
|
import 'zod';
|
|
5
5
|
|
|
6
6
|
/**
|
package/dist/index.js
CHANGED
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Verdict
|
|
3
|
+
} from "./chunk-4BUUPU3O.js";
|
|
1
4
|
import {
|
|
2
5
|
BelticDisabledError,
|
|
3
6
|
DEFAULT_OPEN_RETRY_MS,
|
|
@@ -14,13 +17,6 @@ import {
|
|
|
14
17
|
sha256,
|
|
15
18
|
toHex
|
|
16
19
|
} from "./chunk-X3W2Z5GC.js";
|
|
17
|
-
import {
|
|
18
|
-
Verdict
|
|
19
|
-
} from "./chunk-46QN2KEZ.js";
|
|
20
|
-
import {
|
|
21
|
-
presentedFrom,
|
|
22
|
-
summaryOf
|
|
23
|
-
} from "./chunk-7G5EHNVW.js";
|
|
24
20
|
|
|
25
21
|
// src/core/api-client.ts
|
|
26
22
|
var BelticApiError = class extends Error {
|
|
@@ -144,6 +140,19 @@ function fileIdentity(path, credential) {
|
|
|
144
140
|
return identityFromSeed(seed, credential);
|
|
145
141
|
}
|
|
146
142
|
|
|
143
|
+
// src/core/payment-moment.ts
|
|
144
|
+
function summaryOf(m) {
|
|
145
|
+
return {
|
|
146
|
+
protocol: m.protocol,
|
|
147
|
+
payee: m.payee,
|
|
148
|
+
amount: { value: m.amount.value, currency: m.amount.currency },
|
|
149
|
+
...m.payer ? { payer: m.payer } : {}
|
|
150
|
+
};
|
|
151
|
+
}
|
|
152
|
+
function presentedFrom(summary, raw) {
|
|
153
|
+
return { ...summary, artifact: "payment-signature", raw };
|
|
154
|
+
}
|
|
155
|
+
|
|
147
156
|
// src/core/decision.ts
|
|
148
157
|
var Decision = class _Decision {
|
|
149
158
|
constructor(evaluation) {
|
|
@@ -535,7 +544,7 @@ var Transport = class {
|
|
|
535
544
|
};
|
|
536
545
|
|
|
537
546
|
// src/client.ts
|
|
538
|
-
var SDK_VERSION = "0.
|
|
547
|
+
var SDK_VERSION = "0.4.0";
|
|
539
548
|
var ENV_REQUIRED = ["BELTIC_API_KEY", "BELTIC_BASE_URL", "BELTIC_AGENT_SEED"];
|
|
540
549
|
var ENV_CREDENTIAL = "BELTIC_AGENT_CREDENTIAL";
|
|
541
550
|
var Beltic = class _Beltic {
|
package/dist/protocol/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { b as JsonValue, E as EvidenceSourceAll } from '../verdict-
|
|
2
|
-
export { A as ALL_SOURCES, c as ANOMALY_TYPES, d as Amount, e as AmountSchema, f as
|
|
1
|
+
import { b as JsonValue, E as EvidenceSourceAll } from '../verdict-CDAsxktI.js';
|
|
2
|
+
export { A as ALL_SOURCES, c as ANOMALY_TYPES, d as Amount, e as AmountSchema, f as ApiError, g as ApiErrorSchema, C as ChainHead, h as ChainHeadSchema, i as CreatePolicyInput, j as CreatePolicyInputSchema, k as CreatePolicyOutput, l as CreatePolicyOutputSchema, m as CreateSessionInput, n as CreateSessionInputSchema, o as CreateSessionOutput, p as CreateSessionOutputSchema, D as Decision, q as DecisionSchema, r as DeclaredIntent, s as DeclaredIntentSchema, t as DigestedEnvelope, u as EvaluateInput, v as EvaluateInputSchema, w as EvaluateOutput, x as EvaluateOutputSchema, y as EventResult, z as EventResultSchema, B as EventResultStatus, F as EventResultStatusSchema, G as EvidenceAck, H as EvidenceAckSchema, I as EvidenceBatchInput, K as EvidenceBatchInputSchema, L as EvidenceEnvelope, M as EvidenceEvent, N as EvidenceEventSchema, O as EvidenceKind, Q as EvidenceKindSchema, R as EvidenceSource, S as EvidenceSourceAllSchema, T as EvidenceSourceSchema, U as GatewayDecisionPayload, V as GatewayDecisionPayloadSchema, W as Hex64, X as Hex64Schema, Y as IntentDeclaredPayload, Z as IntentDeclaredPayloadSchema, J as JsonObject, _ as JsonValueSchema, $ as LlmCallEndPayload, a0 as LlmCallEndPayloadSchema, a1 as LlmCallStartPayload, a2 as LlmCallStartPayloadSchema, a3 as MAX_BATCH_EVENTS, a4 as OnReview, a5 as PAYMENT_ARTIFACTS, a6 as PLATFORM_KINDS, a7 as PayloadByKind, P as PaymentMomentPayload, a8 as PaymentMomentPayloadSchema, a as PaymentSummary, a9 as PaymentSummarySchema, aa as PlatformAnomalyPayload, ab as PlatformAnomalyPayloadSchema, ac as PlatformEvidenceKind, ad as PlatformEvidenceKindSchema, ae as PlatformObservationPayload, af as PlatformObservationPayloadSchema, ag as SESSION_CLOSE_REASONS, ah as SOURCE_ORDER, ai as SeqSchema, aj as SessionClosePayload, ak as SessionClosePayloadSchema, al as SessionIdSchema, am as SessionOpenPayload, an as SessionOpenPayloadSchema, ao as Sig, ap as SigSchema, aq as TimestampSchema, ar as ToolCallEndPayload, as as ToolCallEndPayloadSchema, at as ToolCallStartPayload, au as ToolCallStartPayloadSchema, av as TransportGapPayload, aw as TransportGapPayloadSchema, ax as Verdict, ay as WIRE_KINDS, az as WIRE_SOURCES, aA as WireEvidenceKind, aB as WireEvidenceKindSchema, aC as compareBySessionSource, aD as compareBySourceSeq, aE as isPlatformKind, aF as isWireKind, aG as payloadSchemaFor } from '../verdict-CDAsxktI.js';
|
|
3
3
|
import { z } from 'zod';
|
|
4
4
|
|
|
5
5
|
declare const PRIMITIVES: readonly ["THRESHOLD", "MEMBERSHIP", "MATCH", "PRESENCE", "FRESHNESS"];
|
package/dist/protocol/index.js
CHANGED
|
@@ -3,8 +3,6 @@ import {
|
|
|
3
3
|
ANNOTATION_CODES,
|
|
4
4
|
ANOMALY_TYPES,
|
|
5
5
|
AmountSchema,
|
|
6
|
-
AnchorEntrySchema,
|
|
7
|
-
AnchorsOutputSchema,
|
|
8
6
|
ApiErrorSchema,
|
|
9
7
|
COLLECTOR_CODES,
|
|
10
8
|
ChainHeadSchema,
|
|
@@ -73,14 +71,12 @@ import {
|
|
|
73
71
|
parseSelectorRef,
|
|
74
72
|
payloadSchemaFor,
|
|
75
73
|
walkPath
|
|
76
|
-
} from "../chunk-
|
|
74
|
+
} from "../chunk-4BUUPU3O.js";
|
|
77
75
|
export {
|
|
78
76
|
ALL_SOURCES,
|
|
79
77
|
ANNOTATION_CODES,
|
|
80
78
|
ANOMALY_TYPES,
|
|
81
79
|
AmountSchema,
|
|
82
|
-
AnchorEntrySchema,
|
|
83
|
-
AnchorsOutputSchema,
|
|
84
80
|
ApiErrorSchema,
|
|
85
81
|
COLLECTOR_CODES,
|
|
86
82
|
ChainHeadSchema,
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { G as EvidenceAck, y as EventResult, M as EvidenceEvent, w as EvaluateOutput, ax as Verdict, a4 as OnReview, a as PaymentSummary, P as PaymentMomentPayload, D as Decision$1, r as DeclaredIntent, at as ToolCallStartPayload, b as JsonValue, J as JsonObject, aj as SessionClosePayload, R as EvidenceSource, aA as WireEvidenceKind, C as ChainHead, a7 as PayloadByKind } from './verdict-CDAsxktI.js';
|
|
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. */
|
|
@@ -139,8 +139,7 @@ declare class Transport {
|
|
|
139
139
|
*
|
|
140
140
|
* @belticlabs/agent-risk-sdk/ai → middleware(session), wrapTools(session, …)
|
|
141
141
|
* @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, …)
|
|
142
|
+
* @belticlabs/agent-risk-sdk/hono → belticPaymentMiddleware(beltic, …)
|
|
144
143
|
*
|
|
145
144
|
* Neither half decides risk locally: verdicts are platform-side.
|
|
146
145
|
*
|
|
@@ -159,7 +158,7 @@ declare class Transport {
|
|
|
159
158
|
* they are the primitives the fail-open entries are built on.
|
|
160
159
|
*/
|
|
161
160
|
|
|
162
|
-
declare const SDK_VERSION = "0.
|
|
161
|
+
declare const SDK_VERSION = "0.4.0";
|
|
163
162
|
type Env = Record<string, string | undefined>;
|
|
164
163
|
interface BelticOptions extends Omit<ApiClientOptions, 'userAgent'> {
|
|
165
164
|
/** Buyer half. Without it, `sessions.start` is unavailable; the seller half works. */
|
|
@@ -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 { 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 };
|
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-gK51QVAM.js';
|
|
4
|
+
import { A as AttachOptions } from '../adapter-CLy44CD2.js';
|
|
5
|
+
export { a as attachX402 } from '../adapter-CLy44CD2.js';
|
|
6
|
+
import '../verdict-CDAsxktI.js';
|
|
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-WY5ZX4BD.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, C as CorrelationContext, a as attachX402 } from '../adapter-
|
|
2
|
-
import { S as SessionSource } from '../session-
|
|
3
|
-
import {
|
|
1
|
+
export { A as AttachOptions, b as AttachedX402, C as CorrelationContext, a as attachX402 } from '../adapter-CLy44CD2.js';
|
|
2
|
+
import { S as SessionSource } from '../session-gK51QVAM.js';
|
|
3
|
+
import { r as DeclaredIntent, P as PaymentMomentPayload, J as JsonObject, a as PaymentSummary } from '../verdict-CDAsxktI.js';
|
|
4
4
|
import '@x402/core/server';
|
|
5
5
|
import 'zod';
|
|
6
6
|
|
|
@@ -14,7 +14,6 @@ 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
|
|
|
@@ -59,20 +58,19 @@ declare function x402Intent(input: X402IntentInput): DeclaredIntent;
|
|
|
59
58
|
declare function x402Currency(network: string, asset: string): string;
|
|
60
59
|
/**
|
|
61
60
|
* The minimum an `accepts` entry needs to become a moment; unknown parts
|
|
62
|
-
* are named, never dropped.
|
|
61
|
+
* are named, never dropped.
|
|
63
62
|
*/
|
|
64
63
|
interface AcceptsLike {
|
|
65
64
|
payTo?: string | undefined;
|
|
66
65
|
amount?: string | undefined;
|
|
67
|
-
maxAmountRequired?: string | undefined;
|
|
68
66
|
network?: string | undefined;
|
|
69
67
|
asset?: string | undefined;
|
|
70
68
|
}
|
|
71
69
|
/**
|
|
72
|
-
* A 402 challenge and a presented payment
|
|
73
|
-
*
|
|
74
|
-
*
|
|
75
|
-
*
|
|
70
|
+
* A 402 challenge and a presented payment, as far as a moment needs them.
|
|
71
|
+
* `@x402/core`'s `PaymentRequired` and `PaymentPayload` satisfy these
|
|
72
|
+
* structurally, so the seller adapter passes its typed values through and
|
|
73
|
+
* the buyer needs no `@x402/*` types.
|
|
76
74
|
*/
|
|
77
75
|
interface PaymentRequiredLike {
|
|
78
76
|
x402Version?: number | undefined;
|
|
@@ -81,8 +79,6 @@ interface PaymentRequiredLike {
|
|
|
81
79
|
interface PaymentPayloadLike {
|
|
82
80
|
x402Version?: number | undefined;
|
|
83
81
|
accepted?: AcceptsLike | undefined;
|
|
84
|
-
/** v1 names the network here, beside the payload, and nowhere else. */
|
|
85
|
-
network?: string | undefined;
|
|
86
82
|
payload?: Readonly<Record<string, unknown>> | undefined;
|
|
87
83
|
extensions?: Readonly<Record<string, unknown>> | undefined;
|
|
88
84
|
}
|
|
@@ -97,20 +93,14 @@ declare function x402Summary(accepts: AcceptsLike | undefined, opts?: {
|
|
|
97
93
|
/** The payer is scheme-specific; the common EVM shapes are read, anything else stays in `raw`. */
|
|
98
94
|
declare function payerOf(payload: PaymentPayloadLike): string | undefined;
|
|
99
95
|
declare const x402Moments: {
|
|
100
|
-
/** The 402 challenge as the buyer saw it,
|
|
96
|
+
/** The 402 challenge as the buyer saw it, from the `PAYMENT-REQUIRED` header. */
|
|
101
97
|
required(required: PaymentRequiredLike): PaymentMomentPayload;
|
|
102
98
|
/** The requirements the seller's resource server resolved for a request. */
|
|
103
99
|
requirements(req: AcceptsLike): PaymentMomentPayload;
|
|
104
100
|
/** A route's static `accepts` config, before any payment header exists. */
|
|
105
101
|
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;
|
|
102
|
+
/** The signed payment the buyer presented, with the requirement it accepted. */
|
|
103
|
+
payload(payload: PaymentPayloadLike): PaymentMomentPayload;
|
|
114
104
|
};
|
|
115
105
|
|
|
116
|
-
export { type AcceptsLike, DECISION_EXTENSION,
|
|
106
|
+
export { type AcceptsLike, DECISION_EXTENSION, type PaymentPayloadLike, type PaymentRequiredLike, SESSION_EXTENSION, SESSION_HEADER, type X402IntentInput, belticFetch, decisionIdOf, payerOf, sessionIdOf, x402Currency, x402Intent, x402Moments, x402Summary };
|