@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
package/dist/protocol/index.d.ts
CHANGED
|
@@ -1,8 +1,49 @@
|
|
|
1
|
-
import { J as JsonValue, E as EvidenceSourceAll, D as Decision } from '../index-
|
|
2
|
-
export { A as ALL_SOURCES, a as
|
|
1
|
+
import { J as JsonValue, E as EvidenceSourceAll, D as Decision } from '../index-DAVKGJs5.js';
|
|
2
|
+
export { A as ALL_SOURCES, a as ApiError, b as ApiErrorSchema, C as ChainHead, c as CreatePolicyInputSchema, d as CreatePolicyOutput, e as CreateSessionInput, f as CreateSessionInputSchema, g as CreateSessionOutput, h as DeclaredIntent, i as DeclaredIntentSchema, j as DigestedEnvelope, k as EvaluateInput, l as EvaluateInputSchema, m as EvaluateOutput, n as EventResult, o as EvidenceAck, p as EvidenceBatchInputSchema, q as EvidenceEnvelope, r as EvidenceEvent, s as EvidenceEventSchema, t as EvidenceKind, u as EvidenceSource, v as EvidenceSourceAllSchema, w as EvidenceSourceSchema, G as GatewayDecisionPayload, H as Hex64, x as Hex64Schema, I as IntentDeclaredPayload, y as JsonObject, z as JsonValueSchema, L as LlmCallEndPayload, B as LlmCallParams, F as LlmCallStartPayload, M as MAX_BATCH_EVENTS, P as PayloadByKind, K as PaymentMomentPayload, N as PaymentSummary, O as PaymentSummarySchema, Q as PlatformAnomalyPayload, R as PlatformEvidenceKind, S as PlatformObservationPayload, T as PromptBase, U as PromptDelta, V as SESSION_ID_CHARS, W as SESSION_ID_PREFIX, X as SOURCE_ORDER, Y as SessionClosePayload, Z as SessionIdSchema, _ as SessionOpenPayload, $ as Sig, a0 as TimestampSchema, a1 as ToolCallEndPayload, a2 as ToolCallStartPayload, a3 as TransportGapPayload, a4 as WireEvidenceKind, a5 as chainKey, a6 as compareByArrival, a7 as compareBySessionSource, a8 as compareBySourceSeq, a9 as compareRootFirst, aa as payloadSchemaFor, ab as withinHeads } from '../index-DAVKGJs5.js';
|
|
3
3
|
import { z } from 'zod';
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
/**
|
|
6
|
+
* Amounts are decimal strings, never floats (Fraud Engine RFC › API:
|
|
7
|
+
* `amount: { value: string; currency: string }`). One grammar for the wire
|
|
8
|
+
* and the engine, and one value object that compares and adds over scaled
|
|
9
|
+
* BigInts, so 0.1 + 0.2 is 0.3 and an atomic x402 amount of 18 digits
|
|
10
|
+
* keeps its precision. A currency mismatch is never coerced away (GAP-49):
|
|
11
|
+
* two amounts are comparable only when they name the same currency or one
|
|
12
|
+
* names none (a bare bound in a rule).
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
declare const DecimalStringSchema: z.ZodString;
|
|
16
|
+
type DecimalString = z.infer<typeof DecimalStringSchema>;
|
|
17
|
+
declare const AmountSchema: z.ZodObject<{
|
|
18
|
+
value: z.ZodString;
|
|
19
|
+
currency: z.ZodString;
|
|
20
|
+
}, z.core.$strict>;
|
|
21
|
+
type Amount = z.infer<typeof AmountSchema>;
|
|
22
|
+
declare class Money {
|
|
23
|
+
readonly value: DecimalString;
|
|
24
|
+
readonly currency: string | null;
|
|
25
|
+
private constructor();
|
|
26
|
+
static of(amount: Amount): Money;
|
|
27
|
+
/** A decimal with no currency: a bound in a rule, a running total. */
|
|
28
|
+
static bare(value: string): Money;
|
|
29
|
+
/** An x402 amount: atomic units of `asset` on `network`, its currency `<network>/<asset>` (GAP-49). */
|
|
30
|
+
static x402(network: string, asset: string, atomic: string | bigint): Money;
|
|
31
|
+
static x402Currency(network: string, asset: string): string;
|
|
32
|
+
/** Anything a selector or a rule param may resolve to; null when it is not an amount. */
|
|
33
|
+
static parse(v: unknown): Money | null;
|
|
34
|
+
comparable(other: Money): boolean;
|
|
35
|
+
compareTo(other: Money): -1 | 0 | 1;
|
|
36
|
+
exceeds(other: Money): boolean;
|
|
37
|
+
plus(other: Money): Money;
|
|
38
|
+
isZero(): boolean;
|
|
39
|
+
/** Numeric view for ratios; precision loss is acceptable for a ratio. */
|
|
40
|
+
toNumber(): number;
|
|
41
|
+
/** this / other, or null when `other` is zero. */
|
|
42
|
+
ratioTo(other: Money): number | null;
|
|
43
|
+
toAmount(): Amount;
|
|
44
|
+
private static scaled;
|
|
45
|
+
}
|
|
46
|
+
|
|
6
47
|
declare const PrimitiveSchema: z.ZodEnum<{
|
|
7
48
|
THRESHOLD: "THRESHOLD";
|
|
8
49
|
MEMBERSHIP: "MEMBERSHIP";
|
|
@@ -66,18 +107,17 @@ declare const PolicyRulesSchema: z.ZodObject<{
|
|
|
66
107
|
}>>;
|
|
67
108
|
code: z.ZodString;
|
|
68
109
|
}, z.core.$strict>>;
|
|
69
|
-
scoreThresholds: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodNumber>>;
|
|
70
110
|
}, z.core.$strict>;
|
|
71
111
|
type PolicyRules = z.infer<typeof PolicyRulesSchema>;
|
|
72
112
|
|
|
73
113
|
/**
|
|
74
114
|
* Reason codes are the only thing that crosses the verdict boundary besides
|
|
75
115
|
* the verdict itself (Fraud Engine RFC › API: "the seller receives a verdict
|
|
76
|
-
* and reasons — never the record").
|
|
77
|
-
*
|
|
116
|
+
* and reasons — never the record"). The platform's own codes are named here;
|
|
117
|
+
* an owner's rule codes are content, checked only against the pattern (GAP-44).
|
|
78
118
|
*/
|
|
79
119
|
/** Static platform policy — may DENY alone (Fraud Engine RFC › Fraud indicators). */
|
|
80
|
-
declare const INDICATOR_CODES: readonly ["CHAIN_BROKEN", "EVIDENCE_MISMATCH", "
|
|
120
|
+
declare const INDICATOR_CODES: readonly ["CHAIN_BROKEN", "EVIDENCE_MISMATCH", "SESSION_INVALID"];
|
|
81
121
|
type IndicatorCode = (typeof INDICATOR_CODES)[number];
|
|
82
122
|
/**
|
|
83
123
|
* Annotations describe the floor the decision was made on. They never change
|
|
@@ -85,14 +125,8 @@ type IndicatorCode = (typeof INDICATOR_CODES)[number];
|
|
|
85
125
|
* the owner's rules, not a denial (GAP-43).
|
|
86
126
|
*/
|
|
87
127
|
declare const ANNOTATION_CODES: readonly ["NO_AGENT_TRACE", "NO_POLICY"];
|
|
88
|
-
type AnnotationCode = (typeof ANNOTATION_CODES)[number];
|
|
89
128
|
/** Why the Collector refused or downgraded an event (per-event ack, GAP-17). */
|
|
90
|
-
|
|
91
|
-
type CollectorCode = (typeof COLLECTOR_CODES)[number];
|
|
92
|
-
/** Codes the platform default policy uses; owners may define their own (GAP-44). */
|
|
93
|
-
declare const DEFAULT_RULE_CODES: readonly ["CAP_EXCEEDED", "PAYEE_NOT_ALLOWED", "NO_INTENT", "INTENT_EXPIRED"];
|
|
94
|
-
type DefaultRuleCode = (typeof DEFAULT_RULE_CODES)[number];
|
|
95
|
-
type ReasonCode = IndicatorCode | AnnotationCode | DefaultRuleCode | (string & {});
|
|
129
|
+
type CollectorCode = 'SCHEMA_INVALID' | 'SESSION_UNKNOWN' | 'SESSION_CLOSED' | 'SESSION_EXPIRED' | 'SOURCE_FORBIDDEN' | 'SEQ_GAP' | 'PREV_HASH_MISMATCH' | 'SIG_MISSING' | 'SIG_INVALID' | 'PAYLOAD_INVALID' | 'EVENT_TOO_LARGE';
|
|
96
130
|
declare const REASON_CODE_PATTERN: RegExp;
|
|
97
131
|
|
|
98
132
|
/**
|
|
@@ -140,14 +174,7 @@ type Selector = {
|
|
|
140
174
|
all: boolean;
|
|
141
175
|
path: PathSegment[];
|
|
142
176
|
};
|
|
143
|
-
declare class SelectorSyntaxError extends Error {
|
|
144
|
-
readonly input: string;
|
|
145
|
-
readonly at: number;
|
|
146
|
-
readonly code = "SELECTOR_SYNTAX";
|
|
147
|
-
constructor(input: string, at: number, detail: string);
|
|
148
|
-
}
|
|
149
177
|
declare function parseSelector(input: string): Selector;
|
|
150
|
-
declare function formatSelector(sel: Selector): string;
|
|
151
178
|
declare function isSelectorRef(value: unknown): value is `@${string}`;
|
|
152
179
|
declare function parseSelectorRef(ref: string): Selector;
|
|
153
180
|
/** Walk a `path` over a value; `undefined` when any step is missing. */
|
|
@@ -156,12 +183,10 @@ declare const SelectorStringSchema: z.ZodString;
|
|
|
156
183
|
|
|
157
184
|
/**
|
|
158
185
|
* The verdict as a value (Fraud Engine RFC › API: ALLOW | DENY | REVIEW).
|
|
159
|
-
* Layers combine by severity (GAP-45)
|
|
160
|
-
*
|
|
161
|
-
* halves of the SDK and the engine share this one rule.
|
|
186
|
+
* Layers combine by severity (GAP-45): the decision is the most severe
|
|
187
|
+
* verdict any layer produced.
|
|
162
188
|
*/
|
|
163
189
|
|
|
164
|
-
type OnReview = 'abort' | 'allow';
|
|
165
190
|
declare class Verdict {
|
|
166
191
|
readonly value: Decision;
|
|
167
192
|
private constructor();
|
|
@@ -171,10 +196,6 @@ declare class Verdict {
|
|
|
171
196
|
static of(value: Decision): Verdict;
|
|
172
197
|
/** The more severe of the two. */
|
|
173
198
|
atLeast(other: Verdict | Decision): Verdict;
|
|
174
|
-
/** Whether a synchronous gate must stop the call (GAP-52). */
|
|
175
|
-
blocks(onReview: OnReview): boolean;
|
|
176
|
-
/** What the gate effectively did: DENY when it blocked, else the verdict itself. */
|
|
177
|
-
effective(onReview: OnReview): Decision;
|
|
178
199
|
}
|
|
179
200
|
|
|
180
|
-
export { ANNOTATION_CODES, type
|
|
201
|
+
export { ANNOTATION_CODES, type Amount, AmountSchema, type CollectorCode, type DecimalString, DecimalStringSchema, Decision, EvidenceSourceAll, INDICATOR_CODES, type IndicatorCode, JsonValue, Money, type PathSegment, type PolicyRules, PolicyRulesSchema, type Primitive, REASON_CODE_PATTERN, type Rule, type RuleVerdict, type Selector, SelectorStringSchema, Verdict, isSelectorRef, parseSelector, parseSelectorRef, walkPath };
|