@belticlabs/agent-risk-sdk 0.5.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.
@@ -12,6 +12,21 @@ var SOURCE_ORDER = {
12
12
  function compareBySourceSeq(a, b) {
13
13
  return SOURCE_ORDER[a.source] - SOURCE_ORDER[b.source] || a.seq - b.seq;
14
14
  }
15
+ function chainKey(sessionId, source) {
16
+ return `${sessionId}:${source}`;
17
+ }
18
+ function compareByArrival(a, b) {
19
+ return a.ts.localeCompare(b.ts) || a.receivedAt.localeCompare(b.receivedAt) || a.sessionId.localeCompare(b.sessionId) || compareBySourceSeq(a, b);
20
+ }
21
+ function compareRootFirst(conversationId) {
22
+ return (a, b) => Number(b.id === conversationId) - Number(a.id === conversationId);
23
+ }
24
+ function withinHeads(heads) {
25
+ return (e) => {
26
+ const cap = heads[chainKey(e.sessionId, e.source)];
27
+ return cap !== void 0 && e.seq <= cap;
28
+ };
29
+ }
15
30
  function compareBySessionSource(a, b) {
16
31
  return a.sessionId < b.sessionId ? -1 : a.sessionId > b.sessionId ? 1 : SOURCE_ORDER[a.source] - SOURCE_ORDER[b.source];
17
32
  }
@@ -34,7 +49,12 @@ var PlatformEvidenceKindSchema = z.enum(PLATFORM_KINDS);
34
49
  var EvidenceKindSchema = z.enum([...WIRE_KINDS, ...PLATFORM_KINDS]);
35
50
  var Hex64Schema = z.string().regex(/^[0-9a-f]{64}$/, "expected 64 lowercase hex chars");
36
51
  var SigSchema = z.string().regex(/^ed25519:[A-Za-z0-9_-]{86}$/, "expected ed25519:<base64url>");
37
- var SessionIdSchema = z.uuid();
52
+ var SESSION_ID_PREFIX = "sess_";
53
+ var SESSION_ID_CHARS = 22;
54
+ var SessionIdSchema = z.string().regex(
55
+ new RegExp(`^${SESSION_ID_PREFIX}[0-9A-Za-z]{${SESSION_ID_CHARS}}$`),
56
+ `expected ${SESSION_ID_PREFIX} followed by ${SESSION_ID_CHARS} base62 chars`
57
+ );
38
58
  var SeqSchema = z.number().int().min(0);
39
59
  var TimestampSchema = z.iso.datetime({ offset: false });
40
60
  var JsonValueSchema = z.lazy(
@@ -57,46 +77,99 @@ var EvidenceEventSchema = z.strictObject({
57
77
  prevHash: Hex64Schema,
58
78
  sig: SigSchema.optional()
59
79
  });
60
- function isWireKind(kind) {
61
- return WIRE_KINDS.includes(kind);
62
- }
63
- function isPlatformKind(kind) {
64
- return PLATFORM_KINDS.includes(kind);
65
- }
80
+
81
+ // ../protocol/src/money.ts
82
+ import { z as z2 } from "zod";
83
+ var DecimalStringSchema = z2.string().regex(/^\d+(\.\d+)?$/, "expected a decimal string");
84
+ var AmountSchema = z2.strictObject({
85
+ /** Decimal string — never a float. For x402 this is the atomic amount (GAP-49). */
86
+ value: DecimalStringSchema,
87
+ /** ISO code, or `<network>/<asset>` for on-chain rails (GAP-49). */
88
+ currency: z2.string().min(1).max(128)
89
+ });
90
+ var ComparableSchema = z2.union([
91
+ DecimalStringSchema.transform((value) => ({ value, currency: null })),
92
+ z2.number().finite().transform(String).pipe(DecimalStringSchema).transform((value) => ({ value, currency: null })),
93
+ z2.object({ value: DecimalStringSchema, currency: z2.string().optional() }).transform((a) => ({ value: a.value, currency: a.currency ?? null }))
94
+ ]);
95
+ var Money = class _Money {
96
+ constructor(value, currency) {
97
+ this.value = value;
98
+ this.currency = currency;
99
+ }
100
+ static of(amount) {
101
+ return new _Money(DecimalStringSchema.parse(amount.value), amount.currency);
102
+ }
103
+ /** A decimal with no currency: a bound in a rule, a running total. */
104
+ static bare(value) {
105
+ return new _Money(DecimalStringSchema.parse(value), null);
106
+ }
107
+ /** An x402 amount: atomic units of `asset` on `network`, its currency `<network>/<asset>` (GAP-49). */
108
+ static x402(network, asset, atomic) {
109
+ return new _Money(
110
+ DecimalStringSchema.parse(atomic.toString()),
111
+ _Money.x402Currency(network, asset)
112
+ );
113
+ }
114
+ static x402Currency(network, asset) {
115
+ return `${network}/${asset}`;
116
+ }
117
+ /** Anything a selector or a rule param may resolve to; null when it is not an amount. */
118
+ static parse(v) {
119
+ const r = ComparableSchema.safeParse(v);
120
+ return r.success ? new _Money(r.data.value, r.data.currency) : null;
121
+ }
122
+ comparable(other) {
123
+ return this.currency === null || other.currency === null || this.currency === other.currency;
124
+ }
125
+ compareTo(other) {
126
+ const [a, b] = _Money.scaled(this.value, other.value);
127
+ return a < b ? -1 : a > b ? 1 : 0;
128
+ }
129
+ exceeds(other) {
130
+ return this.compareTo(other) > 0;
131
+ }
132
+ plus(other) {
133
+ const [a, b, scale] = _Money.scaled(this.value, other.value);
134
+ const digits = (a + b).toString().padStart(scale + 1, "0");
135
+ const int = digits.slice(0, digits.length - scale);
136
+ const frac = digits.slice(digits.length - scale);
137
+ return new _Money(scale ? `${int}.${frac}` : int, this.currency);
138
+ }
139
+ isZero() {
140
+ return this.toNumber() === 0;
141
+ }
142
+ /** Numeric view for ratios; precision loss is acceptable for a ratio. */
143
+ toNumber() {
144
+ return Number(this.value);
145
+ }
146
+ /** this / other, or null when `other` is zero. */
147
+ ratioTo(other) {
148
+ return other.isZero() ? null : this.toNumber() / other.toNumber();
149
+ }
150
+ toAmount() {
151
+ if (this.currency === null) throw new TypeError("an amount needs a currency");
152
+ return { value: this.value, currency: this.currency };
153
+ }
154
+ static scaled(a, b) {
155
+ const [ai, af = ""] = a.split(".");
156
+ const [bi, bf = ""] = b.split(".");
157
+ const scale = Math.max(af.length, bf.length);
158
+ return [
159
+ BigInt(`${ai}${af.padEnd(scale, "0")}`),
160
+ BigInt(`${bi}${bf.padEnd(scale, "0")}`),
161
+ scale
162
+ ];
163
+ }
164
+ };
66
165
 
67
166
  // ../protocol/src/reason-codes.ts
68
- var INDICATOR_CODES = [
69
- "CHAIN_BROKEN",
70
- "EVIDENCE_MISMATCH",
71
- "CREDENTIAL_REVOKED",
72
- "SESSION_INVALID",
73
- "PRINCIPAL_FLAGGED"
74
- ];
167
+ var INDICATOR_CODES = ["CHAIN_BROKEN", "EVIDENCE_MISMATCH", "SESSION_INVALID"];
75
168
  var ANNOTATION_CODES = ["NO_AGENT_TRACE", "NO_POLICY"];
76
- var COLLECTOR_CODES = [
77
- "SCHEMA_INVALID",
78
- "SESSION_UNKNOWN",
79
- "SESSION_CLOSED",
80
- "SESSION_EXPIRED",
81
- "SOURCE_FORBIDDEN",
82
- "KIND_FORBIDDEN",
83
- "SEQ_GAP",
84
- "PREV_HASH_MISMATCH",
85
- "SIG_MISSING",
86
- "SIG_INVALID",
87
- "PAYLOAD_INVALID",
88
- "EVENT_TOO_LARGE"
89
- ];
90
- var DEFAULT_RULE_CODES = [
91
- "CAP_EXCEEDED",
92
- "PAYEE_NOT_ALLOWED",
93
- "NO_INTENT",
94
- "INTENT_EXPIRED"
95
- ];
96
169
  var REASON_CODE_PATTERN = /^[A-Z][A-Z0-9_]{1,63}$/;
97
170
 
98
171
  // ../protocol/src/selector.ts
99
- import { z as z2 } from "zod";
172
+ import { z as z3 } from "zod";
100
173
  var SelectorSyntaxError = class extends Error {
101
174
  constructor(input, at, detail) {
102
175
  super(`invalid selector "${input}" at ${at}: ${detail}`);
@@ -192,20 +265,6 @@ function parseSelector(input) {
192
265
  "unknown root (payment | intent | session | signal[name=\u2026] | evidence[\u2026])"
193
266
  );
194
267
  }
195
- function formatSelector(sel) {
196
- const path = sel.path.map((p) => "key" in p ? `.${p.key}` : `[${p.index}]`).join("");
197
- switch (sel.root) {
198
- case "payment":
199
- case "intent":
200
- case "session":
201
- return `${sel.root}${path}`;
202
- case "signal":
203
- return `signal[name=${sel.name}]${path}`;
204
- case "evidence":
205
- if (sel.kind === "*") return `evidence[*]${path}`;
206
- return `evidence[kind=${sel.kind}${sel.source ? `,source=${sel.source}` : ""}]${sel.all ? "[*]" : ""}${path}`;
207
- }
208
- }
209
268
  function isSelectorRef(value) {
210
269
  return typeof value === "string" && value.startsWith("@") && value.length > 1;
211
270
  }
@@ -226,7 +285,7 @@ function walkPath(value, path) {
226
285
  }
227
286
  return cur;
228
287
  }
229
- var SelectorStringSchema = z2.string().refine(
288
+ var SelectorStringSchema = z3.string().refine(
230
289
  (s) => {
231
290
  try {
232
291
  parseSelector(s);
@@ -239,156 +298,126 @@ var SelectorStringSchema = z2.string().refine(
239
298
  );
240
299
 
241
300
  // ../protocol/src/policy.ts
242
- import { z as z3 } from "zod";
243
- var PRIMITIVES = ["THRESHOLD", "MEMBERSHIP", "MATCH", "PRESENCE", "FRESHNESS"];
244
- var PrimitiveSchema = z3.enum(PRIMITIVES);
245
- var RuleVerdictSchema = z3.enum(["DENY", "REVIEW"]);
246
- var RuleSchema = z3.strictObject({
247
- id: z3.string().min(1).max(64),
301
+ import { z as z4 } from "zod";
302
+ var PrimitiveSchema = z4.enum(["THRESHOLD", "MEMBERSHIP", "MATCH", "PRESENCE", "FRESHNESS"]);
303
+ var RuleVerdictSchema = z4.enum(["DENY", "REVIEW"]);
304
+ var RuleSchema = z4.strictObject({
305
+ id: z4.string().min(1).max(64),
248
306
  primitive: PrimitiveSchema,
249
307
  selector: SelectorStringSchema,
250
- params: z3.record(z3.string(), JsonValueSchema),
308
+ params: z4.record(z4.string(), JsonValueSchema),
251
309
  onFail: RuleVerdictSchema,
252
310
  /** What to do when the selector (or a `@ref`) resolves to nothing. Default: skip (GAP-44). */
253
- onMissing: z3.enum(["skip", "DENY", "REVIEW"]).optional(),
311
+ onMissing: z4.enum(["skip", "DENY", "REVIEW"]).optional(),
254
312
  /** Reason code surfaced to the caller when the rule fails (GAP-44). */
255
- code: z3.string().regex(REASON_CODE_PATTERN)
313
+ code: z4.string().regex(REASON_CODE_PATTERN)
256
314
  });
257
- var PolicyRulesSchema = z3.strictObject({
258
- rules: z3.array(RuleSchema).max(200).refine((rules) => new Set(rules.map((r) => r.id)).size === rules.length, {
315
+ var PolicyRulesSchema = z4.strictObject({
316
+ rules: z4.array(RuleSchema).max(200).refine((rules) => new Set(rules.map((r) => r.id)).size === rules.length, {
259
317
  message: "rule ids must be unique"
260
- }),
261
- /** Domain-score thresholds — the only configurable part of the scores layer. */
262
- scoreThresholds: z3.record(z3.string(), z3.number().min(0).max(1)).optional()
318
+ })
263
319
  });
264
320
 
265
321
  // ../protocol/src/api.ts
266
- import { z as z4 } from "zod";
267
- var AmountSchema = z4.strictObject({
268
- /** Decimal string — never a float. For x402 this is the atomic amount (GAP-49). */
269
- value: z4.string().regex(/^\d+(\.\d+)?$/, "expected a decimal string"),
270
- /** ISO code, or `<network>/<asset>` for on-chain rails (GAP-49). */
271
- currency: z4.string().min(1).max(128)
272
- });
273
- var DeclaredIntentSchema = z4.strictObject({
274
- mandate: z4.string().min(1).max(4e3),
322
+ import { z as z5 } from "zod";
323
+ var DeclaredIntentSchema = z5.strictObject({
324
+ mandate: z5.string().min(1).max(4e3),
275
325
  maxAmount: AmountSchema.optional(),
276
- merchantAllowlist: z4.array(z4.string().min(1)).optional(),
326
+ merchantAllowlist: z5.array(z5.string().min(1)).optional(),
277
327
  validUntil: TimestampSchema
278
328
  });
279
- var CreateSessionInputSchema = z4.strictObject({
329
+ var CreateSessionInputSchema = z5.strictObject({
280
330
  source: EvidenceSourceSchema,
281
- /** Buyer-born sessions. `credential` is opaque this phase (GAP-11). */
282
- agent: z4.strictObject({ did: z4.string().min(1), credential: z4.string().min(1) }).optional(),
283
- intent: DeclaredIntentSchema.optional()
284
- });
285
- var CreateSessionOutputSchema = z4.strictObject({
286
- sessionId: SessionIdSchema,
287
- expiresAt: TimestampSchema
288
- });
331
+ /** Buyer-born sessions. `credential` is accepted and not kept: the DID is the credential (GAP-11). */
332
+ agent: z5.strictObject({ did: z5.string().min(1), credential: z5.string().min(1) }).optional(),
333
+ intent: DeclaredIntentSchema.optional(),
334
+ /** Any session of a conversation to continue: the new session joins it as a fresh chain (GAP-84). AGENT_TRACE only. */
335
+ resume: SessionIdSchema.optional()
336
+ }).describe("session input");
289
337
  var MAX_BATCH_EVENTS = 500;
290
- var EvidenceBatchInputSchema = z4.array(EvidenceEventSchema).min(1).max(MAX_BATCH_EVENTS);
291
- var EventResultStatusSchema = z4.enum(["ok", "duplicate", "fork", "rejected"]);
292
- var EventResultSchema = z4.strictObject({
293
- index: z4.number().int().min(0),
294
- sessionId: SessionIdSchema.nullable(),
295
- source: EvidenceSourceSchema.nullable(),
296
- seq: z4.number().int().min(0).nullable(),
297
- status: EventResultStatusSchema,
298
- code: z4.string().optional(),
299
- eventDigest: Hex64Schema.optional()
300
- });
301
- var ChainHeadSchema = z4.strictObject({
302
- seq: z4.number().int().min(0),
303
- digest: Hex64Schema
304
- });
305
- var EvidenceAckSchema = z4.strictObject({
306
- results: z4.array(EventResultSchema),
307
- /** Head of every chain touched by the batch, after the batch. Keyed `sessionId:source`. */
308
- heads: z4.record(z4.string(), ChainHeadSchema)
309
- });
310
- var PaymentSummarySchema = z4.strictObject({
311
- protocol: z4.string().min(1),
312
- payee: z4.string().min(1),
338
+ var EvidenceBatchInputSchema = z5.array(z5.unknown()).min(1).max(MAX_BATCH_EVENTS).describe("evidence batch");
339
+ var PaymentSummarySchema = z5.strictObject({
340
+ protocol: z5.string().min(1),
341
+ payee: z5.string().min(1),
313
342
  amount: AmountSchema,
314
343
  /** Not in the RFC; needed by `principal-links` and `EVIDENCE_MISMATCH` (GAP-06). */
315
- payer: z4.string().min(1).optional()
316
- });
317
- var EvaluateInputSchema = z4.strictObject({
318
- sessionId: SessionIdSchema,
319
- payment: PaymentSummarySchema
344
+ payer: z5.string().min(1).optional()
320
345
  });
321
- var DecisionSchema = z4.enum(["ALLOW", "DENY", "REVIEW"]);
322
- var EvaluateOutputSchema = z4.strictObject({
323
- decision: DecisionSchema,
324
- reasonCodes: z4.array(z4.string().regex(REASON_CODE_PATTERN)),
346
+ var EvaluateInputSchema = z5.strictObject({
325
347
  sessionId: SessionIdSchema,
326
- /** Additive (GAP-21). */
327
- decisionId: z4.uuid()
328
- });
329
- var CreatePolicyInputSchema = z4.strictObject({ rules: PolicyRulesSchema });
330
- var CreatePolicyOutputSchema = z4.strictObject({
331
- policyId: z4.uuid(),
332
- version: z4.number().int().min(1),
333
- status: z4.enum(["ACTIVE", "SUPERSEDED", "DRAFT"])
334
- });
335
- var ApiErrorSchema = z4.strictObject({
336
- error: z4.strictObject({
337
- code: z4.string().min(1),
338
- message: z4.string().min(1),
348
+ payment: PaymentSummarySchema,
349
+ /** The caller's own id for the call under decision: the same id within one conversation reads the decision already taken (GAP-84). */
350
+ callId: z5.string().min(1).max(256).optional()
351
+ }).describe("evaluate input");
352
+ var CreatePolicyInputSchema = z5.strictObject({ rules: PolicyRulesSchema }).describe("policy input");
353
+ var ApiErrorSchema = z5.strictObject({
354
+ error: z5.strictObject({
355
+ code: z5.string().min(1),
356
+ message: z5.string().min(1),
339
357
  details: JsonValueSchema.optional(),
340
- request_id: z4.string().optional()
358
+ request_id: z5.string().optional()
341
359
  })
342
360
  });
343
361
 
344
362
  // ../protocol/src/payloads/index.ts
345
- import { z as z5 } from "zod";
363
+ import { z as z6 } from "zod";
346
364
  var Json = JsonValueSchema;
347
- var JsonRecord = z5.record(z5.string(), Json);
348
- var SessionOpenPayloadSchema = z5.looseObject({
349
- runtime: z5.looseObject({
350
- sdk: z5.string().min(1),
351
- version: z5.string().min(1),
352
- framework: z5.string().optional(),
353
- model: z5.string().optional()
365
+ var JsonRecord = z6.record(z6.string(), Json);
366
+ var SessionOpenPayloadSchema = z6.looseObject({
367
+ runtime: z6.looseObject({
368
+ sdk: z6.string().min(1),
369
+ version: z6.string().min(1),
370
+ framework: z6.string().optional(),
371
+ model: z6.string().optional()
354
372
  }),
355
373
  /** Runtime / repo attestations read by the (staged) Attestation Assurance score. */
356
374
  attestations: JsonRecord.optional()
357
375
  });
358
376
  var SESSION_CLOSE_REASONS = ["completed", "settled", "aborted", "expired"];
359
- var SessionClosePayloadSchema = z5.looseObject({
360
- reason: z5.enum(SESSION_CLOSE_REASONS),
361
- transaction: z5.string().optional()
377
+ var SessionClosePayloadSchema = z6.looseObject({
378
+ reason: z6.enum(SESSION_CLOSE_REASONS),
379
+ transaction: z6.string().optional()
362
380
  });
363
381
  var IntentDeclaredPayloadSchema = DeclaredIntentSchema.loose();
364
- var LlmCallStartPayloadSchema = z5.looseObject({
365
- callId: z5.string().min(1),
382
+ var PromptDeltaSchema = z6.strictObject({
383
+ prior: z6.string().min(1),
384
+ shared: z6.number().int().min(0),
385
+ messages: z6.array(Json)
386
+ });
387
+ var LlmCallParamsSchema = z6.looseObject({
388
+ prompt: Json.optional(),
389
+ promptDelta: PromptDeltaSchema.optional()
390
+ }).refine((p) => p.prompt === void 0 || p.promptDelta === void 0, {
391
+ message: "params carries prompt or promptDelta, not both"
392
+ });
393
+ var LlmCallStartPayloadSchema = z6.looseObject({
394
+ callId: z6.string().min(1),
366
395
  // GAP-07
367
- provider: z5.string().min(1),
368
- modelId: z5.string().min(1),
369
- params: JsonRecord
396
+ provider: z6.string().min(1),
397
+ modelId: z6.string().min(1),
398
+ params: LlmCallParamsSchema
370
399
  });
371
- var LlmCallEndPayloadSchema = z5.looseObject({
372
- callId: z5.string().min(1),
400
+ var LlmCallEndPayloadSchema = z6.looseObject({
401
+ callId: z6.string().min(1),
373
402
  content: Json.optional(),
374
- finishReason: z5.string().optional(),
403
+ finishReason: z6.string().optional(),
375
404
  usage: JsonRecord.optional(),
376
- durationMs: z5.number().int().min(0),
377
- error: z5.looseObject({ name: z5.string(), message: z5.string() }).optional()
405
+ durationMs: z6.number().int().min(0),
406
+ error: z6.looseObject({ name: z6.string(), message: z6.string() }).optional()
378
407
  });
379
- var ToolCallStartPayloadSchema = z5.looseObject({
380
- callId: z5.string().min(1),
408
+ var ToolCallStartPayloadSchema = z6.looseObject({
409
+ callId: z6.string().min(1),
381
410
  // GAP-07
382
- toolName: z5.string().min(1),
411
+ toolName: z6.string().min(1),
383
412
  input: Json,
384
- transport: z5.enum(["local", "mcp"]).optional(),
385
- server: z5.string().optional()
413
+ transport: z6.enum(["local", "mcp"]).optional(),
414
+ server: z6.string().optional()
386
415
  });
387
- var ToolCallEndPayloadSchema = z5.looseObject({
388
- callId: z5.string().min(1),
416
+ var ToolCallEndPayloadSchema = z6.looseObject({
417
+ callId: z6.string().min(1),
389
418
  output: Json.optional(),
390
- error: z5.looseObject({ name: z5.string(), message: z5.string() }).optional(),
391
- durationMs: z5.number().int().min(0)
419
+ error: z6.looseObject({ name: z6.string(), message: z6.string() }).optional(),
420
+ durationMs: z6.number().int().min(0)
392
421
  });
393
422
  var PAYMENT_ARTIFACTS = [
394
423
  "http-402",
@@ -396,29 +425,30 @@ var PAYMENT_ARTIFACTS = [
396
425
  "payment-signature",
397
426
  "checkout-url"
398
427
  ];
399
- var PaymentMomentPayloadSchema = z5.looseObject({
400
- protocol: z5.string().min(1),
401
- payee: z5.string().min(1),
402
- amount: z5.looseObject({ value: z5.string().min(1), currency: z5.string().min(1) }),
403
- payer: z5.string().optional(),
404
- artifact: z5.enum(PAYMENT_ARTIFACTS),
428
+ var PaymentMomentPayloadSchema = z6.looseObject({
429
+ protocol: z6.string().min(1),
430
+ payee: z6.string().min(1),
431
+ amount: z6.looseObject({ value: z6.string().min(1), currency: z6.string().min(1) }),
432
+ payer: z6.string().optional(),
433
+ artifact: z6.enum(PAYMENT_ARTIFACTS),
405
434
  raw: JsonRecord
406
435
  });
407
- var GatewayDecisionPayloadSchema = z5.looseObject({
408
- gateway: z5.string().min(1),
409
- call: z5.looseObject({ tool: z5.string().min(1), args: Json.optional() }),
410
- decision: z5.enum(["ALLOW", "DENY", "REVIEW", "CHALLENGE"]),
411
- reasonCodes: z5.array(z5.string()),
436
+ var GatewayDecisionPayloadSchema = z6.looseObject({
437
+ gateway: z6.string().min(1),
438
+ call: z6.looseObject({ tool: z6.string().min(1), args: Json.optional() }),
439
+ decision: z6.enum(["ALLOW", "DENY", "REVIEW", "CHALLENGE"]),
440
+ reasonCodes: z6.array(z6.string()),
412
441
  /** The gateway's own record of what it decided on — a black box to the platform. */
413
442
  record: JsonRecord
414
443
  });
415
- var TransportGapPayloadSchema = z5.looseObject({
416
- dropped: z5.number().int().min(1),
417
- firstTs: z5.string(),
418
- lastTs: z5.string()
444
+ var TransportGapPayloadSchema = z6.looseObject({
445
+ dropped: z6.number().int().min(1),
446
+ oversized: z6.number().int().min(0).optional(),
447
+ firstTs: z6.string(),
448
+ lastTs: z6.string()
419
449
  });
420
- var PlatformObservationPayloadSchema = z5.strictObject({
421
- origin: z5.string().min(1),
450
+ var PlatformObservationPayloadSchema = z6.strictObject({
451
+ origin: z6.string().min(1),
422
452
  params: Json,
423
453
  response: Json
424
454
  });
@@ -430,10 +460,10 @@ var ANOMALY_TYPES = [
430
460
  "clock_skew",
431
461
  "source_conflict"
432
462
  ];
433
- var PlatformAnomalyPayloadSchema = z5.looseObject({
434
- type: z5.enum(ANOMALY_TYPES),
463
+ var PlatformAnomalyPayloadSchema = z6.looseObject({
464
+ type: z6.enum(ANOMALY_TYPES),
435
465
  source: EvidenceSourceAllSchema,
436
- seq: z5.number().int().min(0).nullable(),
466
+ seq: z6.number().int().min(0).nullable(),
437
467
  detail: JsonRecord
438
468
  });
439
469
  var REGISTRY = {
@@ -472,87 +502,46 @@ var Verdict = class _Verdict {
472
502
  const o = typeof other === "string" ? _Verdict.of(other) : other;
473
503
  return SEVERITY[o.value] > SEVERITY[this.value] ? o : this;
474
504
  }
475
- /** Whether a synchronous gate must stop the call (GAP-52). */
476
- blocks(onReview) {
477
- return this.value === "DENY" || this.value === "REVIEW" && onReview === "abort";
478
- }
479
- /** What the gate effectively did: DENY when it blocked, else the verdict itself. */
480
- effective(onReview) {
481
- return this.blocks(onReview) ? "DENY" : this.value;
482
- }
483
505
  };
484
506
 
485
507
  export {
486
- WIRE_SOURCES,
487
508
  ALL_SOURCES,
488
509
  EvidenceSourceSchema,
489
510
  EvidenceSourceAllSchema,
490
511
  SOURCE_ORDER,
491
512
  compareBySourceSeq,
513
+ chainKey,
514
+ compareByArrival,
515
+ compareRootFirst,
516
+ withinHeads,
492
517
  compareBySessionSource,
493
- WIRE_KINDS,
494
- PLATFORM_KINDS,
495
- WireEvidenceKindSchema,
496
- PlatformEvidenceKindSchema,
497
- EvidenceKindSchema,
498
518
  Hex64Schema,
499
- SigSchema,
519
+ SESSION_ID_PREFIX,
520
+ SESSION_ID_CHARS,
500
521
  SessionIdSchema,
501
- SeqSchema,
502
522
  TimestampSchema,
503
523
  JsonValueSchema,
504
524
  EvidenceEventSchema,
505
- isWireKind,
506
- isPlatformKind,
525
+ DecimalStringSchema,
526
+ AmountSchema,
527
+ Money,
507
528
  INDICATOR_CODES,
508
529
  ANNOTATION_CODES,
509
- COLLECTOR_CODES,
510
- DEFAULT_RULE_CODES,
511
530
  REASON_CODE_PATTERN,
512
- SelectorSyntaxError,
513
531
  parseSelector,
514
- formatSelector,
515
532
  isSelectorRef,
516
533
  parseSelectorRef,
517
534
  walkPath,
518
535
  SelectorStringSchema,
519
- PRIMITIVES,
520
- PrimitiveSchema,
521
- RuleVerdictSchema,
522
- RuleSchema,
523
536
  PolicyRulesSchema,
524
- AmountSchema,
525
537
  DeclaredIntentSchema,
526
538
  CreateSessionInputSchema,
527
- CreateSessionOutputSchema,
528
539
  MAX_BATCH_EVENTS,
529
540
  EvidenceBatchInputSchema,
530
- EventResultStatusSchema,
531
- EventResultSchema,
532
- ChainHeadSchema,
533
- EvidenceAckSchema,
534
541
  PaymentSummarySchema,
535
542
  EvaluateInputSchema,
536
- DecisionSchema,
537
- EvaluateOutputSchema,
538
543
  CreatePolicyInputSchema,
539
- CreatePolicyOutputSchema,
540
544
  ApiErrorSchema,
541
- SessionOpenPayloadSchema,
542
- SESSION_CLOSE_REASONS,
543
- SessionClosePayloadSchema,
544
- IntentDeclaredPayloadSchema,
545
- LlmCallStartPayloadSchema,
546
- LlmCallEndPayloadSchema,
547
- ToolCallStartPayloadSchema,
548
- ToolCallEndPayloadSchema,
549
- PAYMENT_ARTIFACTS,
550
- PaymentMomentPayloadSchema,
551
- GatewayDecisionPayloadSchema,
552
- TransportGapPayloadSchema,
553
- PlatformObservationPayloadSchema,
554
- ANOMALY_TYPES,
555
- PlatformAnomalyPayloadSchema,
556
545
  payloadSchemaFor,
557
546
  Verdict
558
547
  };