@reinconsole/core 0.1.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/LICENSE +21 -0
- package/README.md +44 -0
- package/dist/index.cjs +498 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +2588 -0
- package/dist/index.d.ts +2588 -0
- package/dist/index.js +444 -0
- package/dist/index.js.map +1 -0
- package/package.json +60 -0
package/dist/index.js
ADDED
|
@@ -0,0 +1,444 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
|
|
3
|
+
// src/chain.ts
|
|
4
|
+
var Chain = z.enum(["base", "solana", "polygon", "bnb"]);
|
|
5
|
+
var Asset = z.enum(["USDC", "USDT", "EURC"]);
|
|
6
|
+
var DecimalString = z.string().regex(/^\d+(\.\d+)?$/, 'must be a non-negative decimal string, e.g. "5.00"');
|
|
7
|
+
var DECIMAL_RE = /^\d+(\.\d+)?$/;
|
|
8
|
+
function isValidDecimal(value) {
|
|
9
|
+
return DECIMAL_RE.test(value);
|
|
10
|
+
}
|
|
11
|
+
function assertDecimal(value) {
|
|
12
|
+
if (!isValidDecimal(value)) {
|
|
13
|
+
throw new TypeError(`invalid decimal string: ${JSON.stringify(value)}`);
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
function fractionLength(value) {
|
|
17
|
+
const dot = value.indexOf(".");
|
|
18
|
+
return dot === -1 ? 0 : value.length - dot - 1;
|
|
19
|
+
}
|
|
20
|
+
function toScaled(value, scale) {
|
|
21
|
+
const dot = value.indexOf(".");
|
|
22
|
+
const intPart = dot === -1 ? value : value.slice(0, dot);
|
|
23
|
+
const fracPart = dot === -1 ? "" : value.slice(dot + 1);
|
|
24
|
+
const paddedFrac = (fracPart + "0".repeat(scale)).slice(0, scale);
|
|
25
|
+
return BigInt(intPart + paddedFrac);
|
|
26
|
+
}
|
|
27
|
+
function fromScaled(scaled, scale) {
|
|
28
|
+
if (scale === 0) return scaled.toString();
|
|
29
|
+
const digits = scaled.toString().padStart(scale + 1, "0");
|
|
30
|
+
const intPart = digits.slice(0, digits.length - scale);
|
|
31
|
+
const fracPart = digits.slice(digits.length - scale).replace(/0+$/, "");
|
|
32
|
+
return fracPart.length > 0 ? `${intPart}.${fracPart}` : intPart;
|
|
33
|
+
}
|
|
34
|
+
function compareDecimal(a, b) {
|
|
35
|
+
assertDecimal(a);
|
|
36
|
+
assertDecimal(b);
|
|
37
|
+
const scale = Math.max(fractionLength(a), fractionLength(b));
|
|
38
|
+
const av = toScaled(a, scale);
|
|
39
|
+
const bv = toScaled(b, scale);
|
|
40
|
+
return av < bv ? -1 : av > bv ? 1 : 0;
|
|
41
|
+
}
|
|
42
|
+
function sumDecimal(values) {
|
|
43
|
+
if (values.length === 0) return "0";
|
|
44
|
+
let scale = 0;
|
|
45
|
+
for (const v of values) {
|
|
46
|
+
assertDecimal(v);
|
|
47
|
+
scale = Math.max(scale, fractionLength(v));
|
|
48
|
+
}
|
|
49
|
+
let total = 0n;
|
|
50
|
+
for (const v of values) total += toScaled(v, scale);
|
|
51
|
+
return fromScaled(total, scale);
|
|
52
|
+
}
|
|
53
|
+
function mulDecimal(a, b) {
|
|
54
|
+
assertDecimal(a);
|
|
55
|
+
assertDecimal(b);
|
|
56
|
+
const scaleA = fractionLength(a);
|
|
57
|
+
const scaleB = fractionLength(b);
|
|
58
|
+
const product = toScaled(a, scaleA) * toScaled(b, scaleB);
|
|
59
|
+
return fromScaled(product, scaleA + scaleB);
|
|
60
|
+
}
|
|
61
|
+
function gt(a, b) {
|
|
62
|
+
return compareDecimal(a, b) === 1;
|
|
63
|
+
}
|
|
64
|
+
function lt(a, b) {
|
|
65
|
+
return compareDecimal(a, b) === -1;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
// src/glob.ts
|
|
69
|
+
function globMatch(pattern, value) {
|
|
70
|
+
const escaped = pattern.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
71
|
+
const withWildcard = escaped.replace(/\\\*/g, ".*");
|
|
72
|
+
return new RegExp(`^${withWildcard}$`).test(value);
|
|
73
|
+
}
|
|
74
|
+
function globMatchAny(patterns, value) {
|
|
75
|
+
return patterns.some((p) => globMatch(p, value));
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
// src/ulid.ts
|
|
79
|
+
var ENCODING = "0123456789ABCDEFGHJKMNPQRSTVWXYZ";
|
|
80
|
+
var TIME_LEN = 10;
|
|
81
|
+
var RANDOM_LEN = 16;
|
|
82
|
+
function randomBytes(length) {
|
|
83
|
+
const bytes = new Uint8Array(length);
|
|
84
|
+
globalThis.crypto.getRandomValues(bytes);
|
|
85
|
+
return bytes;
|
|
86
|
+
}
|
|
87
|
+
function encodeTime(now) {
|
|
88
|
+
let time = now;
|
|
89
|
+
let out = "";
|
|
90
|
+
for (let i = TIME_LEN - 1; i >= 0; i--) {
|
|
91
|
+
out = ENCODING.charAt(time % 32) + out;
|
|
92
|
+
time = Math.floor(time / 32);
|
|
93
|
+
}
|
|
94
|
+
return out;
|
|
95
|
+
}
|
|
96
|
+
function encodeRandom() {
|
|
97
|
+
let out = "";
|
|
98
|
+
for (const byte of randomBytes(RANDOM_LEN)) {
|
|
99
|
+
out += ENCODING.charAt(byte % 32);
|
|
100
|
+
}
|
|
101
|
+
return out;
|
|
102
|
+
}
|
|
103
|
+
function ulid(seedTime = Date.now()) {
|
|
104
|
+
return encodeTime(seedTime) + encodeRandom();
|
|
105
|
+
}
|
|
106
|
+
function newId(prefix) {
|
|
107
|
+
return `${prefix}_${ulid()}`;
|
|
108
|
+
}
|
|
109
|
+
var ULID_BODY = "[0-9A-HJKMNP-TV-Z]{26}";
|
|
110
|
+
function prefixedId(prefix) {
|
|
111
|
+
return z.string().regex(new RegExp(`^${prefix}_${ULID_BODY}$`), `expected a "${prefix}_" prefixed id`);
|
|
112
|
+
}
|
|
113
|
+
var OrgId = prefixedId("org");
|
|
114
|
+
var AgentId = prefixedId("agt");
|
|
115
|
+
var PolicyId = prefixedId("pol");
|
|
116
|
+
var IntentId = prefixedId("int");
|
|
117
|
+
var DecisionId = prefixedId("dec");
|
|
118
|
+
var ReceiptId = prefixedId("rcp");
|
|
119
|
+
var SessionId = prefixedId("ses");
|
|
120
|
+
var GateReceiptId = prefixedId("grc");
|
|
121
|
+
var EnforcementMode = z.enum(["observed", "sdk", "session-key"]);
|
|
122
|
+
var AgentWallet = z.object({
|
|
123
|
+
chain: Chain,
|
|
124
|
+
address: z.string().min(1),
|
|
125
|
+
mode: EnforcementMode
|
|
126
|
+
});
|
|
127
|
+
var AgentStatus = z.enum(["active", "frozen"]);
|
|
128
|
+
var Agent = z.object({
|
|
129
|
+
id: AgentId,
|
|
130
|
+
orgId: OrgId,
|
|
131
|
+
name: z.string().min(1).max(200),
|
|
132
|
+
/** On-chain ERC-8004 identity, if the agent is registered. */
|
|
133
|
+
erc8004Id: z.string().optional(),
|
|
134
|
+
wallets: z.array(AgentWallet).default([]),
|
|
135
|
+
status: AgentStatus.default("active"),
|
|
136
|
+
createdAt: z.coerce.date()
|
|
137
|
+
});
|
|
138
|
+
var REGISTRY_PATTERN = /^0x[0-9a-fA-F]{40}$/;
|
|
139
|
+
var ID_PATTERN = /^eip155:(\d+):(0x[0-9a-fA-F]{40})\/(\d+)$/;
|
|
140
|
+
function formatErc8004Id(ref) {
|
|
141
|
+
if (!Number.isSafeInteger(ref.chainId) || ref.chainId < 1) {
|
|
142
|
+
throw new RangeError(`erc8004: bad chainId ${ref.chainId}`);
|
|
143
|
+
}
|
|
144
|
+
if (!REGISTRY_PATTERN.test(ref.registry)) {
|
|
145
|
+
throw new RangeError(`erc8004: bad registry address ${ref.registry}`);
|
|
146
|
+
}
|
|
147
|
+
if (typeof ref.tokenId !== "bigint" || ref.tokenId < 0n) {
|
|
148
|
+
throw new RangeError(`erc8004: bad tokenId ${ref.tokenId}`);
|
|
149
|
+
}
|
|
150
|
+
return `eip155:${ref.chainId}:${ref.registry.toLowerCase()}/${ref.tokenId}`;
|
|
151
|
+
}
|
|
152
|
+
function parseErc8004Id(value) {
|
|
153
|
+
const match = ID_PATTERN.exec(value);
|
|
154
|
+
if (!match) return void 0;
|
|
155
|
+
const chainId = Number(match[1]);
|
|
156
|
+
if (!Number.isSafeInteger(chainId) || chainId < 1) return void 0;
|
|
157
|
+
return {
|
|
158
|
+
chainId,
|
|
159
|
+
registry: match[2].toLowerCase(),
|
|
160
|
+
tokenId: BigInt(match[3])
|
|
161
|
+
};
|
|
162
|
+
}
|
|
163
|
+
var Erc8004Id = z.string().refine((value) => parseErc8004Id(value) !== void 0, {
|
|
164
|
+
message: 'expected "eip155:{chainId}:{registry}/{tokenId}"'
|
|
165
|
+
});
|
|
166
|
+
var Vendor = z.object({
|
|
167
|
+
host: z.string().min(1),
|
|
168
|
+
address: z.string().min(1),
|
|
169
|
+
erc8004Id: z.string().optional()
|
|
170
|
+
});
|
|
171
|
+
var TaskContext = z.object({
|
|
172
|
+
taskId: z.string().optional(),
|
|
173
|
+
parentRunId: z.string().optional(),
|
|
174
|
+
purpose: z.string().max(500).optional()
|
|
175
|
+
});
|
|
176
|
+
var PaymentIntent = z.object({
|
|
177
|
+
id: IntentId,
|
|
178
|
+
agentId: AgentId,
|
|
179
|
+
vendor: Vendor,
|
|
180
|
+
resource: z.string(),
|
|
181
|
+
amount: DecimalString,
|
|
182
|
+
asset: Asset,
|
|
183
|
+
chain: Chain,
|
|
184
|
+
taskContext: TaskContext.default({}),
|
|
185
|
+
nonce: z.string().min(1),
|
|
186
|
+
createdAt: z.coerce.date()
|
|
187
|
+
});
|
|
188
|
+
var DecisionOutcome = z.enum(["allow", "deny", "escalate"]);
|
|
189
|
+
var Decision = z.object({
|
|
190
|
+
id: DecisionId,
|
|
191
|
+
intentId: IntentId,
|
|
192
|
+
/**
|
|
193
|
+
* sha256 of the intent's canonical content (see canonical.ts). Binds the
|
|
194
|
+
* decision to the exact transfer it judged — amount, recipient, asset,
|
|
195
|
+
* chain — so a signer can verify an {intent, decision} pair offline as a
|
|
196
|
+
* self-contained spend voucher, not just a reference by id.
|
|
197
|
+
*/
|
|
198
|
+
intentHash: z.string(),
|
|
199
|
+
outcome: DecisionOutcome,
|
|
200
|
+
/** Ids of the rules that fired, for explainability. */
|
|
201
|
+
matchedRules: z.array(z.string()).default([]),
|
|
202
|
+
/** Human-readable explanation surfaced in the dashboard. */
|
|
203
|
+
reason: z.string().optional(),
|
|
204
|
+
policyId: z.string(),
|
|
205
|
+
policyVersion: z.string(),
|
|
206
|
+
/** Hash of the previous decision in the chain (tamper-evident log). */
|
|
207
|
+
prevHash: z.string(),
|
|
208
|
+
/** Hash of this decision's canonical content. */
|
|
209
|
+
hash: z.string(),
|
|
210
|
+
/** Service signing-key signature over `hash`. */
|
|
211
|
+
signature: z.string(),
|
|
212
|
+
latencyMs: z.number().nonnegative(),
|
|
213
|
+
decidedAt: z.coerce.date()
|
|
214
|
+
});
|
|
215
|
+
|
|
216
|
+
// src/canonical.ts
|
|
217
|
+
function canonicalIntent(intent) {
|
|
218
|
+
return JSON.stringify({
|
|
219
|
+
id: intent.id,
|
|
220
|
+
agentId: intent.agentId,
|
|
221
|
+
vendor: {
|
|
222
|
+
host: intent.vendor.host,
|
|
223
|
+
address: intent.vendor.address,
|
|
224
|
+
erc8004Id: intent.vendor.erc8004Id ?? null
|
|
225
|
+
},
|
|
226
|
+
resource: intent.resource,
|
|
227
|
+
amount: intent.amount,
|
|
228
|
+
asset: intent.asset,
|
|
229
|
+
chain: intent.chain,
|
|
230
|
+
taskContext: {
|
|
231
|
+
taskId: intent.taskContext.taskId ?? null,
|
|
232
|
+
parentRunId: intent.taskContext.parentRunId ?? null,
|
|
233
|
+
purpose: intent.taskContext.purpose ?? null
|
|
234
|
+
},
|
|
235
|
+
nonce: intent.nonce,
|
|
236
|
+
createdAt: intent.createdAt.toISOString()
|
|
237
|
+
});
|
|
238
|
+
}
|
|
239
|
+
function canonicalDecision(d) {
|
|
240
|
+
return JSON.stringify({
|
|
241
|
+
intentId: d.intentId,
|
|
242
|
+
intentHash: d.intentHash,
|
|
243
|
+
outcome: d.outcome,
|
|
244
|
+
matchedRules: d.matchedRules,
|
|
245
|
+
policyId: d.policyId,
|
|
246
|
+
policyVersion: d.policyVersion,
|
|
247
|
+
prevHash: d.prevHash,
|
|
248
|
+
decidedAt: d.decidedAt.toISOString()
|
|
249
|
+
});
|
|
250
|
+
}
|
|
251
|
+
var Session = z.object({
|
|
252
|
+
id: SessionId,
|
|
253
|
+
agentId: AgentId,
|
|
254
|
+
/** sha256 hex of the bearer token. */
|
|
255
|
+
tokenHash: z.string(),
|
|
256
|
+
/** Cumulative ceiling across the session's lifetime. Absent = uncapped. */
|
|
257
|
+
capAmount: DecimalString.optional(),
|
|
258
|
+
/** Ceiling per individual signature. Absent = uncapped. */
|
|
259
|
+
maxPerPayment: DecimalString.optional(),
|
|
260
|
+
expiresAt: z.coerce.date(),
|
|
261
|
+
createdAt: z.coerce.date(),
|
|
262
|
+
revokedAt: z.coerce.date().optional()
|
|
263
|
+
});
|
|
264
|
+
var SettledPayment = z.object({
|
|
265
|
+
intentId: IntentId,
|
|
266
|
+
txHash: z.string(),
|
|
267
|
+
chain: Chain,
|
|
268
|
+
blockNumber: z.coerce.bigint(),
|
|
269
|
+
facilitator: z.string().optional(),
|
|
270
|
+
feePaid: DecimalString.optional(),
|
|
271
|
+
confirmedAt: z.coerce.date()
|
|
272
|
+
});
|
|
273
|
+
var ReceiptSettlement = z.object({
|
|
274
|
+
txHash: z.string().optional(),
|
|
275
|
+
networkId: z.string().optional(),
|
|
276
|
+
/** Raw header payload, kept for forensics until the indexer confirms. */
|
|
277
|
+
raw: z.string().optional()
|
|
278
|
+
});
|
|
279
|
+
var Receipt = z.object({
|
|
280
|
+
id: ReceiptId,
|
|
281
|
+
agentId: AgentId,
|
|
282
|
+
intentId: IntentId,
|
|
283
|
+
decisionId: DecisionId,
|
|
284
|
+
outcome: DecisionOutcome,
|
|
285
|
+
/** The URL the agent actually fetched (the paywalled resource). */
|
|
286
|
+
url: z.string(),
|
|
287
|
+
method: z.string().default("GET"),
|
|
288
|
+
vendorHost: z.string(),
|
|
289
|
+
amount: DecimalString,
|
|
290
|
+
asset: Asset,
|
|
291
|
+
chain: Chain,
|
|
292
|
+
taskContext: TaskContext.default({}),
|
|
293
|
+
/** Human-readable explanation copied from the decision. */
|
|
294
|
+
reason: z.string().optional(),
|
|
295
|
+
/** Present only once a payment was made and the vendor confirmed it. */
|
|
296
|
+
settlement: ReceiptSettlement.optional(),
|
|
297
|
+
createdAt: z.coerce.date()
|
|
298
|
+
});
|
|
299
|
+
var GateReceipt = z.object({
|
|
300
|
+
id: GateReceiptId,
|
|
301
|
+
at: z.coerce.date(),
|
|
302
|
+
/** The route pattern that priced this request, e.g. "/api/reports/*". */
|
|
303
|
+
route: z.string().min(1),
|
|
304
|
+
/** The concrete resource paid for (URL path actually requested). */
|
|
305
|
+
resource: z.string().min(1),
|
|
306
|
+
method: z.string().min(1),
|
|
307
|
+
/** The paying wallet address, as asserted by the settled payment. */
|
|
308
|
+
payer: z.string().min(1),
|
|
309
|
+
payTo: z.string().min(1),
|
|
310
|
+
/** Human-unit decimal amount, e.g. "0.05". */
|
|
311
|
+
amount: DecimalString,
|
|
312
|
+
/** The same amount in the asset's atomic units, e.g. "50000". */
|
|
313
|
+
amountAtomic: z.string().regex(/^\d+$/, "atomic amount must be an integer string"),
|
|
314
|
+
/** Token symbol or contract address, exactly as quoted in the requirement. */
|
|
315
|
+
asset: z.string().min(1),
|
|
316
|
+
network: z.string().min(1),
|
|
317
|
+
/** Settlement transaction hash (mock ledger or on-chain). */
|
|
318
|
+
transaction: z.string().min(1)
|
|
319
|
+
});
|
|
320
|
+
var Window = z.string().regex(/^\d+[smhd]$/, 'window must be like "30s", "15m", "1h", or "7d"');
|
|
321
|
+
var Multiplier = z.string().regex(/^\d+(\.\d+)?x$/, 'multiplier must be like "3x"');
|
|
322
|
+
var Condition = z.object({
|
|
323
|
+
/** Per-transaction amount exceeds this value. */
|
|
324
|
+
amountGt: DecimalString.optional(),
|
|
325
|
+
/** Sum of spend in a rolling window exceeds `gt`. */
|
|
326
|
+
rollingSum: z.object({ window: Window, gt: DecimalString }).optional(),
|
|
327
|
+
/** Transaction count in a rolling window exceeds `gt`. */
|
|
328
|
+
txCount: z.object({ window: Window, gt: z.number().int().nonnegative() }).optional(),
|
|
329
|
+
/** Vendor host matches one of these patterns (supports `*` globs). */
|
|
330
|
+
vendorHostIn: z.array(z.string()).optional(),
|
|
331
|
+
/** First time Rein has seen this vendor for the agent. */
|
|
332
|
+
vendorFirstSeen: z.boolean().optional(),
|
|
333
|
+
/** Vendor reputation score is below this threshold (Phase 3 hook). */
|
|
334
|
+
vendorReputationLt: z.number().min(0).max(100).optional(),
|
|
335
|
+
/** Amount is more than `gt`-times the observed median for this resource. */
|
|
336
|
+
amountVsResourceMedian: z.object({ gt: Multiplier }).optional()
|
|
337
|
+
}).refine((c) => Object.values(c).some((v) => v !== void 0), {
|
|
338
|
+
message: "a condition must specify at least one predicate"
|
|
339
|
+
});
|
|
340
|
+
var Rule = z.object({
|
|
341
|
+
id: z.string().min(1),
|
|
342
|
+
allow: Condition.optional(),
|
|
343
|
+
deny: Condition.optional(),
|
|
344
|
+
escalate: Condition.optional()
|
|
345
|
+
}).refine((r) => [r.allow, r.deny, r.escalate].filter((v) => v !== void 0).length === 1, {
|
|
346
|
+
message: "a rule must specify exactly one of allow / deny / escalate"
|
|
347
|
+
});
|
|
348
|
+
var PolicyDefault = z.enum(["allow", "deny"]);
|
|
349
|
+
var AppliesTo = z.object({
|
|
350
|
+
/** Agent id patterns (supports `*` globs, e.g. "agt_research_*"). */
|
|
351
|
+
agents: z.array(z.string()).optional(),
|
|
352
|
+
chains: z.array(Chain).optional()
|
|
353
|
+
});
|
|
354
|
+
var Escalation = z.object({
|
|
355
|
+
approvers: z.array(z.string()).default([]),
|
|
356
|
+
timeoutAction: PolicyDefault.default("deny"),
|
|
357
|
+
timeoutMin: z.number().int().positive().default(15)
|
|
358
|
+
});
|
|
359
|
+
var Policy = z.object({
|
|
360
|
+
policyId: z.string().min(1),
|
|
361
|
+
version: z.string().default("1"),
|
|
362
|
+
appliesTo: AppliesTo.default({}),
|
|
363
|
+
rules: z.array(Rule).default([]),
|
|
364
|
+
default: PolicyDefault.default("deny"),
|
|
365
|
+
/** Below this amount, fail-open is permitted during a policy-service outage. */
|
|
366
|
+
denyFloor: DecimalString.default("0.05"),
|
|
367
|
+
escalation: Escalation.optional()
|
|
368
|
+
});
|
|
369
|
+
var ReputationSubject = z.object({
|
|
370
|
+
kind: z.enum(["agent", "vendor"]),
|
|
371
|
+
id: z.string()
|
|
372
|
+
});
|
|
373
|
+
var ReputationComponents = z.object({
|
|
374
|
+
volume: z.number(),
|
|
375
|
+
longevity: z.number(),
|
|
376
|
+
disputeRate: z.number(),
|
|
377
|
+
counterpartyQuality: z.number(),
|
|
378
|
+
settlementReliability: z.number()
|
|
379
|
+
});
|
|
380
|
+
var ReputationScore = z.object({
|
|
381
|
+
subject: ReputationSubject,
|
|
382
|
+
score: z.number().min(0).max(100),
|
|
383
|
+
components: ReputationComponents,
|
|
384
|
+
confidence: z.number().min(0).max(1),
|
|
385
|
+
asOf: z.coerce.date(),
|
|
386
|
+
/** Hash-anchored attestation, optionally published on-chain (ERC-8004). */
|
|
387
|
+
evidenceUri: z.string().optional()
|
|
388
|
+
});
|
|
389
|
+
var ReinEvent = z.discriminatedUnion("type", [
|
|
390
|
+
z.object({ type: z.literal("intent.created"), at: z.coerce.date(), intent: PaymentIntent }),
|
|
391
|
+
z.object({ type: z.literal("decision.made"), at: z.coerce.date(), decision: Decision }),
|
|
392
|
+
z.object({ type: z.literal("payment.settled"), at: z.coerce.date(), payment: SettledPayment }),
|
|
393
|
+
z.object({
|
|
394
|
+
type: z.literal("shadow.spend"),
|
|
395
|
+
at: z.coerce.date(),
|
|
396
|
+
agentId: AgentId,
|
|
397
|
+
txHash: z.string(),
|
|
398
|
+
chain: Chain,
|
|
399
|
+
amount: DecimalString
|
|
400
|
+
}),
|
|
401
|
+
z.object({
|
|
402
|
+
type: z.literal("signature.released"),
|
|
403
|
+
at: z.coerce.date(),
|
|
404
|
+
sessionId: SessionId,
|
|
405
|
+
agentId: AgentId,
|
|
406
|
+
intentId: IntentId,
|
|
407
|
+
decisionId: DecisionId,
|
|
408
|
+
amount: DecimalString
|
|
409
|
+
}),
|
|
410
|
+
z.object({
|
|
411
|
+
type: z.literal("signature.refused"),
|
|
412
|
+
at: z.coerce.date(),
|
|
413
|
+
/** Refusal code, e.g. "decision_replayed" (see @reinconsole/signer). */
|
|
414
|
+
code: z.string(),
|
|
415
|
+
reason: z.string(),
|
|
416
|
+
sessionId: SessionId.optional(),
|
|
417
|
+
agentId: AgentId.optional(),
|
|
418
|
+
intentId: IntentId.optional()
|
|
419
|
+
}),
|
|
420
|
+
z.object({
|
|
421
|
+
type: z.literal("gate.quoted"),
|
|
422
|
+
at: z.coerce.date(),
|
|
423
|
+
resource: z.string(),
|
|
424
|
+
method: z.string(),
|
|
425
|
+
amount: DecimalString,
|
|
426
|
+
asset: z.string(),
|
|
427
|
+
network: z.string()
|
|
428
|
+
}),
|
|
429
|
+
z.object({ type: z.literal("gate.settled"), at: z.coerce.date(), receipt: GateReceipt }),
|
|
430
|
+
z.object({
|
|
431
|
+
type: z.literal("gate.refused"),
|
|
432
|
+
at: z.coerce.date(),
|
|
433
|
+
/** Refusal code, e.g. "payment_replayed" (see @reinconsole/gate). */
|
|
434
|
+
code: z.string(),
|
|
435
|
+
reason: z.string(),
|
|
436
|
+
resource: z.string(),
|
|
437
|
+
/** Known only when the payment header decoded far enough to name a payer. */
|
|
438
|
+
payer: z.string().optional()
|
|
439
|
+
})
|
|
440
|
+
]);
|
|
441
|
+
|
|
442
|
+
export { Agent, AgentId, AgentStatus, AgentWallet, AppliesTo, Asset, Chain, Condition, DecimalString, Decision, DecisionId, DecisionOutcome, EnforcementMode, Erc8004Id, Escalation, GateReceipt, GateReceiptId, IntentId, Multiplier, OrgId, PaymentIntent, Policy, PolicyDefault, PolicyId, Receipt, ReceiptId, ReceiptSettlement, ReinEvent, ReputationComponents, ReputationScore, ReputationSubject, Rule, Session, SessionId, SettledPayment, TaskContext, Vendor, Window, canonicalDecision, canonicalIntent, compareDecimal, formatErc8004Id, globMatch, globMatchAny, gt, isValidDecimal, lt, mulDecimal, newId, parseErc8004Id, prefixedId, sumDecimal, ulid };
|
|
443
|
+
//# sourceMappingURL=index.js.map
|
|
444
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/chain.ts","../src/money.ts","../src/glob.ts","../src/ulid.ts","../src/ids.ts","../src/agent.ts","../src/erc8004.ts","../src/intent.ts","../src/decision.ts","../src/canonical.ts","../src/session.ts","../src/payment.ts","../src/receipt.ts","../src/gate-receipt.ts","../src/policy.ts","../src/reputation.ts","../src/events.ts"],"names":["z"],"mappings":";;;AAOO,IAAM,KAAA,GAAQ,EAAE,IAAA,CAAK,CAAC,QAAQ,QAAA,EAAU,SAAA,EAAW,KAAK,CAAC;AAIzD,IAAM,QAAQ,CAAA,CAAE,IAAA,CAAK,CAAC,MAAA,EAAQ,MAAA,EAAQ,MAAM,CAAC;ACH7C,IAAM,gBAAgBA,CAAAA,CAC1B,MAAA,EAAO,CACP,KAAA,CAAM,iBAAiB,oDAAoD;AAG9E,IAAM,UAAA,GAAa,eAAA;AAEZ,SAAS,eAAe,KAAA,EAAwB;AACrD,EAAA,OAAO,UAAA,CAAW,KAAK,KAAK,CAAA;AAC9B;AAEA,SAAS,cAAc,KAAA,EAAqB;AAC1C,EAAA,IAAI,CAAC,cAAA,CAAe,KAAK,CAAA,EAAG;AAC1B,IAAA,MAAM,IAAI,SAAA,CAAU,CAAA,wBAAA,EAA2B,KAAK,SAAA,CAAU,KAAK,CAAC,CAAA,CAAE,CAAA;AAAA,EACxE;AACF;AAEA,SAAS,eAAe,KAAA,EAAuB;AAC7C,EAAA,MAAM,GAAA,GAAM,KAAA,CA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,EAAE,MAAA,EAAO;AAAA,IACjB,MAAA,EAAQ,aAAA;AAAA,IACR,KAAA,EAAOA,EAAE,MAAA,EAAO;AAAA,IAChB,OAAA,EAASA,EAAE,MAAA;AAAO,GACnB,CAAA;AAAA,EACDA,CAAAA,CAAE,MAAA,CAAO,EAAE,IAAA,EAAMA,EAAE,OAAA,CAAQ,cAAc,CAAA,EAAG,EAAA,EAAIA,EAAE,MAAA,CAAO,IAAA,EAAK,EAAG,OAAA,EAAS,aAAa,CAAA;AAAA,EACvFA,EAAE,MAAA,CAAO;AAAA,IACP,IAAA,EAAMA,CAAAA,CAAE,OAAA,CAAQ,cAAc,CAAA;AAAA,IAC9B,EAAA,EAAIA,CAAAA,CAAE,MAAA,CAAO,IAAA,EAAK;AAAA;AAAA,IAElB,IAAA,EAAMA,EAAE,MAAA,EAAO;AAAA,IACf,MAAA,EAAQA,EAAE,MAAA,EAAO;AAAA,IACjB,QAAA,EAAUA,EAAE,MAAA,EAAO;AAAA;AAAA,IAEnB,KAAA,EAAOA,CAAAA,CAAE,MAAA,EAAO,CAAE,QAAA;AAAS,GAC5B;AACH,CAAC","file":"index.js","sourcesContent":["import { z } from 'zod';\n\n/**\n * Chains Rein observes/governs. x402 is multi-chain; Base and Solana ship\n * first, Polygon and BNB follow. The policy/ledger domain is rail-agnostic —\n * this enum is the only place chains are enumerated.\n */\nexport const Chain = z.enum(['base', 'solana', 'polygon', 'bnb']);\nexport type Chain = z.infer<typeof Chain>;\n\n/** Stablecoins settled over x402. */\nexport const Asset = z.enum(['USDC', 'USDT', 'EURC']);\nexport type Asset = z.infer<typeof Asset>;\n","import { z } from 'zod';\n\n/**\n * Monetary amounts in Rein are always non-negative **decimal strings**, never\n * floats. Float arithmetic silently loses precision on values like 0.1 + 0.2,\n * which is unacceptable for money. All comparison/aggregation goes through the\n * BigInt-backed helpers below.\n */\nexport const DecimalString = z\n .string()\n .regex(/^\\d+(\\.\\d+)?$/, 'must be a non-negative decimal string, e.g. \"5.00\"');\nexport type DecimalString = z.infer<typeof DecimalString>;\n\nconst DECIMAL_RE = /^\\d+(\\.\\d+)?$/;\n\nexport function isValidDecimal(value: string): boolean {\n return DECIMAL_RE.test(value);\n}\n\nfunction assertDecimal(value: string): void {\n if (!isValidDecimal(value)) {\n throw new TypeError(`invalid decimal string: ${JSON.stringify(value)}`);\n }\n}\n\nfunction fractionLength(value: string): number {\n const dot = value.indexOf('.');\n return dot === -1 ? 0 : value.length - dot - 1;\n}\n\n/** Scale a decimal string into an integer BigInt at a fixed number of fraction digits. */\nfunction toScaled(value: string, scale: number): bigint {\n const dot = value.indexOf('.');\n const intPart = dot === -1 ? value : value.slice(0, dot);\n const fracPart = dot === -1 ? '' : value.slice(dot + 1);\n const paddedFrac = (fracPart + '0'.repeat(scale)).slice(0, scale);\n return BigInt(intPart + paddedFrac);\n}\n\n/** Render a scaled BigInt back to a normalized decimal string (no trailing zeros). */\nfunction fromScaled(scaled: bigint, scale: number): string {\n if (scale === 0) return scaled.toString();\n const digits = scaled.toString().padStart(scale + 1, '0');\n const intPart = digits.slice(0, digits.length - scale);\n const fracPart = digits.slice(digits.length - scale).replace(/0+$/, '');\n return fracPart.length > 0 ? `${intPart}.${fracPart}` : intPart;\n}\n\n/** Compare two decimal strings. Returns -1 (a<b), 0 (a==b), or 1 (a>b). */\nexport function compareDecimal(a: string, b: string): -1 | 0 | 1 {\n assertDecimal(a);\n assertDecimal(b);\n const scale = Math.max(fractionLength(a), fractionLength(b));\n const av = toScaled(a, scale);\n const bv = toScaled(b, scale);\n return av < bv ? -1 : av > bv ? 1 : 0;\n}\n\n/** Sum a list of decimal strings without floating-point error. */\nexport function sumDecimal(values: readonly string[]): string {\n if (values.length === 0) return '0';\n let scale = 0;\n for (const v of values) {\n assertDecimal(v);\n scale = Math.max(scale, fractionLength(v));\n }\n let total = 0n;\n for (const v of values) total += toScaled(v, scale);\n return fromScaled(total, scale);\n}\n\n/** Multiply two decimal strings exactly (e.g. median * \"3\" for price-sanity). */\nexport function mulDecimal(a: string, b: string): string {\n assertDecimal(a);\n assertDecimal(b);\n const scaleA = fractionLength(a);\n const scaleB = fractionLength(b);\n const product = toScaled(a, scaleA) * toScaled(b, scaleB);\n return fromScaled(product, scaleA + scaleB);\n}\n\n/** Convenience: a > b. */\nexport function gt(a: string, b: string): boolean {\n return compareDecimal(a, b) === 1;\n}\n\n/** Convenience: a < b. */\nexport function lt(a: string, b: string): boolean {\n return compareDecimal(a, b) === -1;\n}\n","/**\n * Minimal, safe glob matcher supporting only the `*` wildcard (matches any run\n * of characters, including none). Used for vendor host allowlists\n * (e.g. \"*.trusted.io\"), agent-id targeting (e.g. \"agt_research_*\"), and\n * Gate route pricing (e.g. \"/api/reports/*\").\n *\n * Deliberately NOT a regex from user input — the pattern is escaped so a\n * malicious policy value cannot inject regex behavior (ReDoS, etc.).\n */\nexport function globMatch(pattern: string, value: string): boolean {\n const escaped = pattern.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\$&'); // escape regex metachars\n const withWildcard = escaped.replace(/\\\\\\*/g, '.*'); // re-enable only `*`\n return new RegExp(`^${withWildcard}$`).test(value);\n}\n\n/** True if `value` matches any pattern in the list. */\nexport function globMatchAny(patterns: readonly string[], value: string): boolean {\n return patterns.some((p) => globMatch(p, value));\n}\n","/**\n * Minimal ULID generation, dependency-free. ULIDs are lexicographically\n * sortable (time-prefixed) and url-safe, which is why Rein uses them for all\n * primary keys instead of UUIDs. Works in Node 22 and modern browsers/edge via\n * the WebCrypto `globalThis.crypto`.\n */\n\n// Crockford's base32 alphabet (excludes I, L, O, U to avoid ambiguity).\nconst ENCODING = '0123456789ABCDEFGHJKMNPQRSTVWXYZ';\nconst TIME_LEN = 10;\nconst RANDOM_LEN = 16;\n\nfunction randomBytes(length: number): Uint8Array {\n const bytes = new Uint8Array(length);\n globalThis.crypto.getRandomValues(bytes);\n return bytes;\n}\n\nfunction encodeTime(now: number): string {\n let time = now;\n let out = '';\n for (let i = TIME_LEN - 1; i >= 0; i--) {\n out = ENCODING.charAt(time % 32) + out;\n time = Math.floor(time / 32);\n }\n return out;\n}\n\nfunction encodeRandom(): string {\n let out = '';\n for (const byte of randomBytes(RANDOM_LEN)) {\n out += ENCODING.charAt(byte % 32);\n }\n return out;\n}\n\n/** Generate a 26-character ULID. */\nexport function ulid(seedTime: number = Date.now()): string {\n return encodeTime(seedTime) + encodeRandom();\n}\n\n/** Generate a Stripe-style prefixed id, e.g. `newId('agt')` -> `agt_01J...`. */\nexport function newId<P extends string>(prefix: P): `${P}_${string}` {\n return `${prefix}_${ulid()}`;\n}\n","import { z } from 'zod';\n\n/** Crockford base32 ULID body (26 chars), as produced by `ulid()`. */\nconst ULID_BODY = '[0-9A-HJKMNP-TV-Z]{26}';\n\n/**\n * A zod schema for a Stripe-style prefixed ULID, e.g. `agt_01J7...`.\n * Centralizing this keeps id formats consistent across DB rows, API payloads,\n * and SDK types.\n */\nexport function prefixedId(prefix: string) {\n return z\n .string()\n .regex(new RegExp(`^${prefix}_${ULID_BODY}$`), `expected a \"${prefix}_\" prefixed id`);\n}\n\nexport const OrgId = prefixedId('org');\nexport const AgentId = prefixedId('agt');\nexport const PolicyId = prefixedId('pol');\nexport const IntentId = prefixedId('int');\nexport const DecisionId = prefixedId('dec');\nexport const ReceiptId = prefixedId('rcp');\nexport const SessionId = prefixedId('ses');\nexport const GateReceiptId = prefixedId('grc');\n\nexport type OrgId = z.infer<typeof OrgId>;\nexport type AgentId = z.infer<typeof AgentId>;\nexport type PolicyId = z.infer<typeof PolicyId>;\nexport type IntentId = z.infer<typeof IntentId>;\nexport type DecisionId = z.infer<typeof DecisionId>;\nexport type ReceiptId = z.infer<typeof ReceiptId>;\nexport type SessionId = z.infer<typeof SessionId>;\nexport type GateReceiptId = z.infer<typeof GateReceiptId>;\n","import { z } from 'zod';\nimport { AgentId, OrgId } from './ids.js';\nimport { Chain } from './chain.js';\n\n/**\n * Enforcement tier of a given agent wallet:\n * - `observed` — Rein sees spend on-chain but has no control (no SDK either).\n * - `sdk` — agent uses @reinconsole/sdk; advisory + observability (bypassable).\n * - `session-key` — signer-level scope; out-of-policy txs cannot be signed.\n */\nexport const EnforcementMode = z.enum(['observed', 'sdk', 'session-key']);\nexport type EnforcementMode = z.infer<typeof EnforcementMode>;\n\nexport const AgentWallet = z.object({\n chain: Chain,\n address: z.string().min(1),\n mode: EnforcementMode,\n});\nexport type AgentWallet = z.infer<typeof AgentWallet>;\n\nexport const AgentStatus = z.enum(['active', 'frozen']);\nexport type AgentStatus = z.infer<typeof AgentStatus>;\n\nexport const Agent = z.object({\n id: AgentId,\n orgId: OrgId,\n name: z.string().min(1).max(200),\n /** On-chain ERC-8004 identity, if the agent is registered. */\n erc8004Id: z.string().optional(),\n wallets: z.array(AgentWallet).default([]),\n status: AgentStatus.default('active'),\n createdAt: z.coerce.date(),\n});\nexport type Agent = z.infer<typeof Agent>;\n","import { z } from 'zod';\n\n/**\n * The canonical string form of an ERC-8004 agent identity:\n *\n * eip155:{chainId}:{identityRegistry}/{tokenId}\n *\n * The part before the `/` is the spec's registry reference verbatim (the\n * `agentRegistry` field of a registration file, CAIP-10 account form); the\n * tokenId is the ERC-721 id the Identity Registry minted (`agentId` in the\n * spec). This exact string is what `Agent.erc8004Id` / `Vendor.erc8004Id`\n * carry, AND the reputation-subject id a registered agent's evidence keys by.\n *\n * Casing is load-bearing: reputation subject keys for agent-kind ids are\n * case-sensitive unless they start with `0x` (see @reinconsole/graph\n * `normalizeSubject`), and an eip155 string does not. `formatErc8004Id`\n * therefore always emits the registry address in lowercase, and consumers must\n * never hand-build the string — parse then re-format to normalize.\n */\n\nexport interface Erc8004Ref {\n /** EIP-155 chain id (e.g. 8453 Base, 84532 Base Sepolia). */\n chainId: number;\n /** Identity Registry contract address, lowercase 0x-hex. */\n registry: string;\n /** ERC-721 tokenId — the spec's `agentId`. bigint: token ids exceed 2^53. */\n tokenId: bigint;\n}\n\nconst REGISTRY_PATTERN = /^0x[0-9a-fA-F]{40}$/;\nconst ID_PATTERN = /^eip155:(\\d+):(0x[0-9a-fA-F]{40})\\/(\\d+)$/;\n\n/** Build the canonical id string. Throws on a malformed ref (programmer error). */\nexport function formatErc8004Id(ref: Erc8004Ref): string {\n if (!Number.isSafeInteger(ref.chainId) || ref.chainId < 1) {\n throw new RangeError(`erc8004: bad chainId ${ref.chainId}`);\n }\n if (!REGISTRY_PATTERN.test(ref.registry)) {\n throw new RangeError(`erc8004: bad registry address ${ref.registry}`);\n }\n if (typeof ref.tokenId !== 'bigint' || ref.tokenId < 0n) {\n // The typeof guard matters for plain-JS callers: 1.5 < 0n is legal JS and\n // false, and would mint the unparseable \"…/1.5\".\n throw new RangeError(`erc8004: bad tokenId ${ref.tokenId}`);\n }\n return `eip155:${ref.chainId}:${ref.registry.toLowerCase()}/${ref.tokenId}`;\n}\n\n/**\n * Parse a canonical (or hand-written) id string. Accepts any address casing\n * and returns a lowercase ref, or undefined when malformed — so\n * `formatErc8004Id(parseErc8004Id(x)!)` is the normalization step.\n */\nexport function parseErc8004Id(value: string): Erc8004Ref | undefined {\n const match = ID_PATTERN.exec(value);\n if (!match) return undefined;\n const chainId = Number(match[1]);\n if (!Number.isSafeInteger(chainId) || chainId < 1) return undefined;\n return {\n chainId,\n registry: match[2]!.toLowerCase(),\n tokenId: BigInt(match[3]!),\n };\n}\n\n/** Strict boundary schema for the id string (the fields themselves stay free-form). */\nexport const Erc8004Id = z\n .string()\n .refine((value) => parseErc8004Id(value) !== undefined, {\n message: 'expected \"eip155:{chainId}:{registry}/{tokenId}\"',\n });\nexport type Erc8004Id = z.infer<typeof Erc8004Id>;\n","import { z } from 'zod';\nimport { AgentId, IntentId } from './ids.js';\nimport { Chain, Asset } from './chain.js';\nimport { DecimalString } from './money.js';\n\nexport const Vendor = z.object({\n host: z.string().min(1),\n address: z.string().min(1),\n erc8004Id: z.string().optional(),\n});\nexport type Vendor = z.infer<typeof Vendor>;\n\n/**\n * The observability gold: links every micro-payment back to the task and run\n * that caused it, so finance teams can answer \"what was this spend for?\".\n */\nexport const TaskContext = z.object({\n taskId: z.string().optional(),\n parentRunId: z.string().optional(),\n purpose: z.string().max(500).optional(),\n});\nexport type TaskContext = z.infer<typeof TaskContext>;\n\n/**\n * A request to spend, submitted to the policy engine BEFORE any signature is\n * released. The `nonce` provides replay protection on the signer path.\n */\nexport const PaymentIntent = z.object({\n id: IntentId,\n agentId: AgentId,\n vendor: Vendor,\n resource: z.string(),\n amount: DecimalString,\n asset: Asset,\n chain: Chain,\n taskContext: TaskContext.default({}),\n nonce: z.string().min(1),\n createdAt: z.coerce.date(),\n});\nexport type PaymentIntent = z.infer<typeof PaymentIntent>;\n","import { z } from 'zod';\nimport { DecisionId, IntentId } from './ids.js';\n\nexport const DecisionOutcome = z.enum(['allow', 'deny', 'escalate']);\nexport type DecisionOutcome = z.infer<typeof DecisionOutcome>;\n\n/**\n * The signed, hash-chained record of a single policy evaluation. Written BEFORE\n * any signature is released. `prevHash` + `hash` form a tamper-evident chain;\n * `signature` is the policy service's signing key over `hash`. The eventual\n * on-chain `txHash` is attached later by the indexer (see SettledPayment).\n */\nexport const Decision = z.object({\n id: DecisionId,\n intentId: IntentId,\n /**\n * sha256 of the intent's canonical content (see canonical.ts). Binds the\n * decision to the exact transfer it judged — amount, recipient, asset,\n * chain — so a signer can verify an {intent, decision} pair offline as a\n * self-contained spend voucher, not just a reference by id.\n */\n intentHash: z.string(),\n outcome: DecisionOutcome,\n /** Ids of the rules that fired, for explainability. */\n matchedRules: z.array(z.string()).default([]),\n /** Human-readable explanation surfaced in the dashboard. */\n reason: z.string().optional(),\n policyId: z.string(),\n policyVersion: z.string(),\n /** Hash of the previous decision in the chain (tamper-evident log). */\n prevHash: z.string(),\n /** Hash of this decision's canonical content. */\n hash: z.string(),\n /** Service signing-key signature over `hash`. */\n signature: z.string(),\n latencyMs: z.number().nonnegative(),\n decidedAt: z.coerce.date(),\n});\nexport type Decision = z.infer<typeof Decision>;\n","import type { PaymentIntent } from './intent.js';\nimport type { DecisionOutcome } from './decision.js';\n\n/**\n * Canonical byte forms shared by the policy engine (which hashes and signs\n * them) and the signer (which verifies them offline). Field order is fixed,\n * dates are ISO strings, and absent optionals are explicit nulls, so the same\n * parsed object always canonicalizes to the same bytes — including after a\n * JSON round-trip over HTTP.\n *\n * These builders are pure (no node:crypto) so @reinconsole/core stays loadable in a\n * browser; services hash the strings with whatever sha256 they have.\n */\n\n/** Canonical form of an intent — what `Decision.intentHash` commits to. */\nexport function canonicalIntent(intent: PaymentIntent): string {\n return JSON.stringify({\n id: intent.id,\n agentId: intent.agentId,\n vendor: {\n host: intent.vendor.host,\n address: intent.vendor.address,\n erc8004Id: intent.vendor.erc8004Id ?? null,\n },\n resource: intent.resource,\n amount: intent.amount,\n asset: intent.asset,\n chain: intent.chain,\n taskContext: {\n taskId: intent.taskContext.taskId ?? null,\n parentRunId: intent.taskContext.parentRunId ?? null,\n purpose: intent.taskContext.purpose ?? null,\n },\n nonce: intent.nonce,\n createdAt: intent.createdAt.toISOString(),\n });\n}\n\n/** The decision fields covered by `Decision.hash` (and thus its signature). */\nexport interface DecisionContent {\n intentId: string;\n intentHash: string;\n outcome: DecisionOutcome;\n matchedRules: string[];\n policyId: string;\n policyVersion: string;\n prevHash: string;\n decidedAt: Date;\n}\n\n/** Canonical form of a decision — what `Decision.hash` is computed over. */\nexport function canonicalDecision(d: DecisionContent): string {\n return JSON.stringify({\n intentId: d.intentId,\n intentHash: d.intentHash,\n outcome: d.outcome,\n matchedRules: d.matchedRules,\n policyId: d.policyId,\n policyVersion: d.policyVersion,\n prevHash: d.prevHash,\n decidedAt: d.decidedAt.toISOString(),\n });\n}\n","import { z } from 'zod';\nimport { AgentId, SessionId } from './ids.js';\nimport { DecimalString } from './money.js';\n\n/**\n * A session-key grant: the signer tier's unit of delegated authority. The\n * agent process holds only the bearer token — the wallet key never leaves the\n * signer — and the stored record keeps a hash of the token, never the token\n * itself (it is returned exactly once, at creation).\n *\n * Caps here are the signer-side backstop UNDER whatever policy says: a\n * signature is released only when the engine allowed the intent AND the\n * session has room. Amounts are decimal strings in the asset's human units.\n */\nexport const Session = z.object({\n id: SessionId,\n agentId: AgentId,\n /** sha256 hex of the bearer token. */\n tokenHash: z.string(),\n /** Cumulative ceiling across the session's lifetime. Absent = uncapped. */\n capAmount: DecimalString.optional(),\n /** Ceiling per individual signature. Absent = uncapped. */\n maxPerPayment: DecimalString.optional(),\n expiresAt: z.coerce.date(),\n createdAt: z.coerce.date(),\n revokedAt: z.coerce.date().optional(),\n});\nexport type Session = z.infer<typeof Session>;\n","import { z } from 'zod';\nimport { IntentId } from './ids.js';\nimport { Chain } from './chain.js';\nimport { DecimalString } from './money.js';\n\n/**\n * On-chain confirmation of a settled payment, reconciled by the indexer against\n * the originating intent (amount + recipient + nonce, or facilitator webhook).\n */\nexport const SettledPayment = z.object({\n intentId: IntentId,\n txHash: z.string(),\n chain: Chain,\n blockNumber: z.coerce.bigint(),\n facilitator: z.string().optional(),\n feePaid: DecimalString.optional(),\n confirmedAt: z.coerce.date(),\n});\nexport type SettledPayment = z.infer<typeof SettledPayment>;\n","import { z } from 'zod';\nimport { ReceiptId, IntentId, DecisionId, AgentId } from './ids.js';\nimport { Chain, Asset } from './chain.js';\nimport { DecimalString } from './money.js';\nimport { TaskContext } from './intent.js';\nimport { DecisionOutcome } from './decision.js';\n\n/**\n * What the SDK reports back after settlement: the `X-PAYMENT-RESPONSE` header\n * a vendor returns once payment clears. Mock facilitators fill this in v0.1;\n * the indexer reconciles it against on-chain truth later (see SettledPayment).\n */\nexport const ReceiptSettlement = z.object({\n txHash: z.string().optional(),\n networkId: z.string().optional(),\n /** Raw header payload, kept for forensics until the indexer confirms. */\n raw: z.string().optional(),\n});\nexport type ReceiptSettlement = z.infer<typeof ReceiptSettlement>;\n\n/**\n * The SDK-side record of one guarded payment attempt: which request triggered\n * it, what the engine decided, and (if allowed and paid) how it settled.\n * Receipts are the observability primitive — every 402 the guard touches\n * produces exactly one, whether the payment was allowed or blocked.\n */\nexport const Receipt = z.object({\n id: ReceiptId,\n agentId: AgentId,\n intentId: IntentId,\n decisionId: DecisionId,\n outcome: DecisionOutcome,\n /** The URL the agent actually fetched (the paywalled resource). */\n url: z.string(),\n method: z.string().default('GET'),\n vendorHost: z.string(),\n amount: DecimalString,\n asset: Asset,\n chain: Chain,\n taskContext: TaskContext.default({}),\n /** Human-readable explanation copied from the decision. */\n reason: z.string().optional(),\n /** Present only once a payment was made and the vendor confirmed it. */\n settlement: ReceiptSettlement.optional(),\n createdAt: z.coerce.date(),\n});\nexport type Receipt = z.infer<typeof Receipt>;\n","import { z } from 'zod';\nimport { GateReceiptId } from './ids.js';\nimport { DecimalString } from './money.js';\n\n/**\n * The vendor-side twin of `Receipt`: one settled x402 payment as the GATE saw\n * it — who paid, for which priced route, and the settlement transaction. The\n * agent-side Receipt records what an agent tried to spend; a GateReceipt\n * records what a vendor actually earned.\n */\nexport const GateReceipt = z.object({\n id: GateReceiptId,\n at: z.coerce.date(),\n /** The route pattern that priced this request, e.g. \"/api/reports/*\". */\n route: z.string().min(1),\n /** The concrete resource paid for (URL path actually requested). */\n resource: z.string().min(1),\n method: z.string().min(1),\n /** The paying wallet address, as asserted by the settled payment. */\n payer: z.string().min(1),\n payTo: z.string().min(1),\n /** Human-unit decimal amount, e.g. \"0.05\". */\n amount: DecimalString,\n /** The same amount in the asset's atomic units, e.g. \"50000\". */\n amountAtomic: z.string().regex(/^\\d+$/, 'atomic amount must be an integer string'),\n /** Token symbol or contract address, exactly as quoted in the requirement. */\n asset: z.string().min(1),\n network: z.string().min(1),\n /** Settlement transaction hash (mock ledger or on-chain). */\n transaction: z.string().min(1),\n});\nexport type GateReceipt = z.infer<typeof GateReceipt>;\n","import { z } from 'zod';\nimport { Chain } from './chain.js';\nimport { DecimalString } from './money.js';\n\n/** A rolling-window spec, e.g. \"24h\", \"1h\", \"30m\", \"7d\". */\nexport const Window = z\n .string()\n .regex(/^\\d+[smhd]$/, 'window must be like \"30s\", \"15m\", \"1h\", or \"7d\"');\nexport type Window = z.infer<typeof Window>;\n\n/** A relative multiplier, e.g. \"3x\" (used for price-sanity checks). */\nexport const Multiplier = z.string().regex(/^\\d+(\\.\\d+)?x$/, 'multiplier must be like \"3x\"');\nexport type Multiplier = z.infer<typeof Multiplier>;\n\n/**\n * The set of predicates a rule can test. Multiple predicates in one condition\n * are ANDed together. Each maps to an evaluator in the policy engine.\n */\nexport const Condition = z\n .object({\n /** Per-transaction amount exceeds this value. */\n amountGt: DecimalString.optional(),\n /** Sum of spend in a rolling window exceeds `gt`. */\n rollingSum: z.object({ window: Window, gt: DecimalString }).optional(),\n /** Transaction count in a rolling window exceeds `gt`. */\n txCount: z.object({ window: Window, gt: z.number().int().nonnegative() }).optional(),\n /** Vendor host matches one of these patterns (supports `*` globs). */\n vendorHostIn: z.array(z.string()).optional(),\n /** First time Rein has seen this vendor for the agent. */\n vendorFirstSeen: z.boolean().optional(),\n /** Vendor reputation score is below this threshold (Phase 3 hook). */\n vendorReputationLt: z.number().min(0).max(100).optional(),\n /** Amount is more than `gt`-times the observed median for this resource. */\n amountVsResourceMedian: z.object({ gt: Multiplier }).optional(),\n })\n .refine((c) => Object.values(c).some((v) => v !== undefined), {\n message: 'a condition must specify at least one predicate',\n });\nexport type Condition = z.infer<typeof Condition>;\n\n/**\n * A single rule: an id plus exactly one action (allow / deny / escalate) whose\n * value is the condition that triggers it.\n */\nexport const Rule = z\n .object({\n id: z.string().min(1),\n allow: Condition.optional(),\n deny: Condition.optional(),\n escalate: Condition.optional(),\n })\n .refine((r) => [r.allow, r.deny, r.escalate].filter((v) => v !== undefined).length === 1, {\n message: 'a rule must specify exactly one of allow / deny / escalate',\n });\nexport type Rule = z.infer<typeof Rule>;\n\nexport const PolicyDefault = z.enum(['allow', 'deny']);\nexport type PolicyDefault = z.infer<typeof PolicyDefault>;\n\nexport const AppliesTo = z.object({\n /** Agent id patterns (supports `*` globs, e.g. \"agt_research_*\"). */\n agents: z.array(z.string()).optional(),\n chains: z.array(Chain).optional(),\n});\nexport type AppliesTo = z.infer<typeof AppliesTo>;\n\nexport const Escalation = z.object({\n approvers: z.array(z.string()).default([]),\n timeoutAction: PolicyDefault.default('deny'),\n timeoutMin: z.number().int().positive().default(15),\n});\nexport type Escalation = z.infer<typeof Escalation>;\n\n/**\n * A declarative, versioned, immutable-once-active policy. Evaluation order in\n * the engine is: explicit DENY > ESCALATE > ALLOW > `default`.\n */\nexport const Policy = z.object({\n policyId: z.string().min(1),\n version: z.string().default('1'),\n appliesTo: AppliesTo.default({}),\n rules: z.array(Rule).default([]),\n default: PolicyDefault.default('deny'),\n /** Below this amount, fail-open is permitted during a policy-service outage. */\n denyFloor: DecimalString.default('0.05'),\n escalation: Escalation.optional(),\n});\nexport type Policy = z.infer<typeof Policy>;\n","import { z } from 'zod';\n\nexport const ReputationSubject = z.object({\n kind: z.enum(['agent', 'vendor']),\n id: z.string(),\n});\nexport type ReputationSubject = z.infer<typeof ReputationSubject>;\n\nexport const ReputationComponents = z.object({\n volume: z.number(),\n longevity: z.number(),\n disputeRate: z.number(),\n counterpartyQuality: z.number(),\n settlementReliability: z.number(),\n});\nexport type ReputationComponents = z.infer<typeof ReputationComponents>;\n\n/**\n * A reputation score for an agent or vendor (Phase 3 — Graph). `confidence` is\n * first-class: a thin-history subject returns LOW confidence rather than a\n * misleadingly high score, so policy can avoid both false trust and unfair\n * freezing.\n */\nexport const ReputationScore = z.object({\n subject: ReputationSubject,\n score: z.number().min(0).max(100),\n components: ReputationComponents,\n confidence: z.number().min(0).max(1),\n asOf: z.coerce.date(),\n /** Hash-anchored attestation, optionally published on-chain (ERC-8004). */\n evidenceUri: z.string().optional(),\n});\nexport type ReputationScore = z.infer<typeof ReputationScore>;\n","import { z } from 'zod';\nimport { AgentId, DecisionId, IntentId, SessionId } from './ids.js';\nimport { Chain } from './chain.js';\nimport { DecimalString } from './money.js';\nimport { PaymentIntent } from './intent.js';\nimport { Decision } from './decision.js';\nimport { SettledPayment } from './payment.js';\nimport { GateReceipt } from './gate-receipt.js';\n\n/**\n * The canonical event envelope published on the bus (NATS in production).\n * `shadow.spend` is emitted when the indexer sees on-chain spend from a managed\n * wallet with NO corresponding ALLOW decision — the bypass signal that catches\n * SDK-mode evasion and drives the upgrade to the signer tier.\n * `signature.released` / `signature.refused` are that tier's heartbeat: every\n * time the signer does or does not put a key to work, the bus knows why.\n * `gate.*` is the vendor side of the wire: every quote a Gate issues, every\n * payment it accepts, every payment it turns away.\n */\nexport const ReinEvent = z.discriminatedUnion('type', [\n z.object({ type: z.literal('intent.created'), at: z.coerce.date(), intent: PaymentIntent }),\n z.object({ type: z.literal('decision.made'), at: z.coerce.date(), decision: Decision }),\n z.object({ type: z.literal('payment.settled'), at: z.coerce.date(), payment: SettledPayment }),\n z.object({\n type: z.literal('shadow.spend'),\n at: z.coerce.date(),\n agentId: AgentId,\n txHash: z.string(),\n chain: Chain,\n amount: DecimalString,\n }),\n z.object({\n type: z.literal('signature.released'),\n at: z.coerce.date(),\n sessionId: SessionId,\n agentId: AgentId,\n intentId: IntentId,\n decisionId: DecisionId,\n amount: DecimalString,\n }),\n z.object({\n type: z.literal('signature.refused'),\n at: z.coerce.date(),\n /** Refusal code, e.g. \"decision_replayed\" (see @reinconsole/signer). */\n code: z.string(),\n reason: z.string(),\n sessionId: SessionId.optional(),\n agentId: AgentId.optional(),\n intentId: IntentId.optional(),\n }),\n z.object({\n type: z.literal('gate.quoted'),\n at: z.coerce.date(),\n resource: z.string(),\n method: z.string(),\n amount: DecimalString,\n asset: z.string(),\n network: z.string(),\n }),\n z.object({ type: z.literal('gate.settled'), at: z.coerce.date(), receipt: GateReceipt }),\n z.object({\n type: z.literal('gate.refused'),\n at: z.coerce.date(),\n /** Refusal code, e.g. \"payment_replayed\" (see @reinconsole/gate). */\n code: z.string(),\n reason: z.string(),\n resource: z.string(),\n /** Known only when the payment header decoded far enough to name a payer. */\n payer: z.string().optional(),\n }),\n]);\nexport type ReinEvent = z.infer<typeof ReinEvent>;\n"]}
|
package/package.json
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@reinconsole/core",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Canonical zod schemas and shared types for Rein — the single source of truth for DB rows, API payloads, and SDK types.",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"homepage": "https://github.com/bugiiiii11/rein#readme",
|
|
7
|
+
"repository": {
|
|
8
|
+
"type": "git",
|
|
9
|
+
"url": "git+https://github.com/bugiiiii11/rein.git",
|
|
10
|
+
"directory": "packages/core"
|
|
11
|
+
},
|
|
12
|
+
"bugs": "https://github.com/bugiiiii11/rein/issues",
|
|
13
|
+
"keywords": [
|
|
14
|
+
"rein",
|
|
15
|
+
"x402",
|
|
16
|
+
"ai-agents",
|
|
17
|
+
"agent-payments",
|
|
18
|
+
"payments",
|
|
19
|
+
"zod",
|
|
20
|
+
"schemas"
|
|
21
|
+
],
|
|
22
|
+
"engines": {
|
|
23
|
+
"node": ">=22"
|
|
24
|
+
},
|
|
25
|
+
"publishConfig": {
|
|
26
|
+
"access": "public"
|
|
27
|
+
},
|
|
28
|
+
"type": "module",
|
|
29
|
+
"sideEffects": false,
|
|
30
|
+
"exports": {
|
|
31
|
+
".": {
|
|
32
|
+
"types": "./dist/index.d.ts",
|
|
33
|
+
"import": "./dist/index.js",
|
|
34
|
+
"require": "./dist/index.cjs"
|
|
35
|
+
}
|
|
36
|
+
},
|
|
37
|
+
"main": "./dist/index.cjs",
|
|
38
|
+
"module": "./dist/index.js",
|
|
39
|
+
"types": "./dist/index.d.ts",
|
|
40
|
+
"files": [
|
|
41
|
+
"dist"
|
|
42
|
+
],
|
|
43
|
+
"dependencies": {
|
|
44
|
+
"zod": "^3.24.1"
|
|
45
|
+
},
|
|
46
|
+
"devDependencies": {
|
|
47
|
+
"@types/node": "^22.10.0",
|
|
48
|
+
"tsup": "^8.3.5",
|
|
49
|
+
"typescript": "^5.7.2",
|
|
50
|
+
"vitest": "^2.1.8"
|
|
51
|
+
},
|
|
52
|
+
"scripts": {
|
|
53
|
+
"build": "tsup",
|
|
54
|
+
"dev": "tsup --watch",
|
|
55
|
+
"typecheck": "tsc --noEmit",
|
|
56
|
+
"test": "vitest run",
|
|
57
|
+
"test:watch": "vitest",
|
|
58
|
+
"clean": "rimraf dist .turbo"
|
|
59
|
+
}
|
|
60
|
+
}
|