@belticlabs/agent-risk-sdk 0.6.0 → 0.8.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.
@@ -1,8 +1,49 @@
1
- import { J as JsonValue, E as EvidenceSourceAll, D as Decision } from '../index-IfY4XCvJ.js';
2
- export { A as ALL_SOURCES, a as ANOMALY_TYPES, b as Amount, c as AmountSchema, d as ApiError, e as ApiErrorSchema, C as ChainHead, f as ChainHeadSchema, g as CreatePolicyInput, h as CreatePolicyInputSchema, i as CreatePolicyOutput, j as CreatePolicyOutputSchema, k as CreateSessionInput, l as CreateSessionInputSchema, m as CreateSessionOutput, n as CreateSessionOutputSchema, o as DecisionSchema, p as DeclaredIntent, q as DeclaredIntentSchema, r as DigestedEnvelope, s as EvaluateInput, t as EvaluateInputSchema, u as EvaluateOutput, v as EvaluateOutputSchema, w as EventResult, x as EventResultSchema, y as EventResultStatus, z as EventResultStatusSchema, B as EvidenceAck, F as EvidenceAckSchema, G as EvidenceBatchInput, H as EvidenceBatchInputSchema, I as EvidenceEnvelope, K as EvidenceEvent, L as EvidenceEventSchema, M as EvidenceKind, N as EvidenceKindSchema, O as EvidenceSource, P as EvidenceSourceAllSchema, Q as EvidenceSourceSchema, R as GatewayDecisionPayload, S as GatewayDecisionPayloadSchema, T as Hex64, U as Hex64Schema, V as IntentDeclaredPayload, W as IntentDeclaredPayloadSchema, X as JsonObject, Y as JsonValueSchema, Z as LlmCallEndPayload, _ as LlmCallEndPayloadSchema, $ as LlmCallStartPayload, a0 as LlmCallStartPayloadSchema, a1 as MAX_BATCH_EVENTS, a2 as PAYMENT_ARTIFACTS, a3 as PLATFORM_KINDS, a4 as PayloadByKind, a5 as PaymentMomentPayload, a6 as PaymentMomentPayloadSchema, a7 as PaymentSummary, a8 as PaymentSummarySchema, a9 as PlatformAnomalyPayload, aa as PlatformAnomalyPayloadSchema, ab as PlatformEvidenceKind, ac as PlatformEvidenceKindSchema, ad as PlatformObservationPayload, ae as PlatformObservationPayloadSchema, af as SESSION_CLOSE_REASONS, ag as SOURCE_ORDER, ah as SeqSchema, ai as SessionClosePayload, aj as SessionClosePayloadSchema, ak as SessionIdSchema, al as SessionOpenPayload, am as SessionOpenPayloadSchema, an as Sig, ao as SigSchema, ap as TimestampSchema, aq as ToolCallEndPayload, ar as ToolCallEndPayloadSchema, as as ToolCallStartPayload, at as ToolCallStartPayloadSchema, au as TransportGapPayload, av as TransportGapPayloadSchema, aw as WIRE_KINDS, ax as WIRE_SOURCES, ay as WireEvidenceKind, az as WireEvidenceKindSchema, aA as compareBySessionSource, aB as compareBySourceSeq, aC as isPlatformKind, aD as isWireKind, aE as payloadSchemaFor } from '../index-IfY4XCvJ.js';
1
+ import { J as JsonValue, E as EvidenceSourceAll, D as Decision } from '../index-CBUSXzgG.js';
2
+ export { A as ALL_SOURCES, a as ApiError, b as ApiErrorSchema, C as CatalogEndpoint, c as CatalogOffer, d as CatalogOutput, e as CatalogQuery, f as CatalogQuerySchema, g as CatalogSourceReport, h as CatalogVendor, i as ChainHead, j as CreatePolicyInputSchema, k as CreatePolicyOutput, l as CreateSessionInput, m as CreateSessionInputSchema, n as CreateSessionOutput, o as DeclaredIntent, p as DeclaredIntentSchema, q as DigestedEnvelope, r as EvaluateInput, s as EvaluateInputSchema, t as EvaluateOutput, u as EventResult, v as EvidenceAck, w as EvidenceBatchInputSchema, x as EvidenceEnvelope, y as EvidenceEvent, z as EvidenceEventSchema, B as EvidenceKind, F as EvidenceSource, G as EvidenceSourceAllSchema, H as EvidenceSourceSchema, I as GatewayDecisionPayload, K as Hex64, L as Hex64Schema, M as IntentDeclaredPayload, N as JsonObject, O as JsonValueSchema, P as LlmCallEndPayload, Q as LlmCallParams, R as LlmCallStartPayload, S as MAX_BATCH_EVENTS, T as MAX_CATALOG_RESULTS, U as PayloadByKind, V as PaymentMomentPayload, W as PaymentSummary, X as PaymentSummarySchema, Y as PlatformAnomalyPayload, Z as PlatformEvidenceKind, _ as PlatformObservationPayload, $ as PromptBase, a0 as PromptDelta, a1 as SESSION_ID_CHARS, a2 as SESSION_ID_PREFIX, a3 as SOURCE_ORDER, a4 as SessionClosePayload, a5 as SessionIdSchema, a6 as SessionOpenPayload, a7 as Sig, a8 as TimestampSchema, a9 as ToolCallEndPayload, aa as ToolCallStartPayload, ab as TransportGapPayload, ac as WireEvidenceKind, ad as chainKey, ae as compareByArrival, af as compareBySessionSource, ag as compareBySourceSeq, ah as compareRootFirst, ai as payloadSchemaFor, aj as withinHeads } from '../index-CBUSXzgG.js';
3
3
  import { z } from 'zod';
4
4
 
5
- declare const PRIMITIVES: readonly ["THRESHOLD", "MEMBERSHIP", "MATCH", "PRESENCE", "FRESHNESS"];
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"). Three families, kept separate so the
77
- * type system knows which layer may emit which.
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", "CREDENTIAL_REVOKED", "SESSION_INVALID", "PRINCIPAL_FLAGGED"];
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
- declare const COLLECTOR_CODES: readonly ["SCHEMA_INVALID", "SESSION_UNKNOWN", "SESSION_CLOSED", "SESSION_EXPIRED", "SOURCE_FORBIDDEN", "KIND_FORBIDDEN", "SEQ_GAP", "PREV_HASH_MISMATCH", "SIG_MISSING", "SIG_INVALID", "PAYLOAD_INVALID", "EVENT_TOO_LARGE"];
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); a synchronous seller hook turns
160
- * REVIEW into a stop or a pass according to its `onReview` (GAP-52). Both
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 AnnotationCode, COLLECTOR_CODES, type CollectorCode, DEFAULT_RULE_CODES, Decision, type DefaultRuleCode, EvidenceSourceAll, INDICATOR_CODES, type IndicatorCode, JsonValue, type OnReview, PRIMITIVES, type PathSegment, type PolicyRules, PolicyRulesSchema, type Primitive, PrimitiveSchema, REASON_CODE_PATTERN, type ReasonCode, type Rule, RuleSchema, type RuleVerdict, RuleVerdictSchema, type Selector, SelectorStringSchema, SelectorSyntaxError, Verdict, formatSelector, isSelectorRef, parseSelector, parseSelectorRef, walkPath };
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 };