@withgordon/core 0.1.1 → 0.1.2

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/README.md CHANGED
@@ -16,7 +16,6 @@ npm install @withgordon/core
16
16
  import { Gordon } from "@withgordon/core";
17
17
 
18
18
  const gordon = new Gordon({
19
- evaluatorUrl: "https://evaluator.withgordon.ai",
20
19
  platformUrl: "https://api.withgordon.ai",
21
20
  agentApiKey: process.env.GORDON_AGENT_KEY!,
22
21
  agentApiSecret: process.env.GORDON_AGENT_SECRET!,
@@ -65,6 +64,7 @@ const result = await gordon.fetch(url, options);
65
64
  | `operationId` | `string` | Catalog operation ID, such as `search.web` or `scrape.url`. |
66
65
  | `maxPaymentUnits` | `number` | Maximum spend for this call. `1_000_000 = $1.00`. Defaults to `$0.10`. |
67
66
  | `idempotencyKey` | `string` | Stable key for safe retries without double-paying. |
67
+ | `replayKey` | `string` | Optional one-shot key for the Platform's short-TTL replay guard. |
68
68
  | `targetUrl` | `string` | For scrape/crawl calls, the customer URL being scraped. Used for domain policy. |
69
69
  | `allowUnconfirmed` | `boolean` | Development escape hatch for providers that return `2xx` without x402 receipt proof. Leave false in production. |
70
70
 
@@ -85,29 +85,48 @@ When payment succeeds, `receipt` contains:
85
85
 
86
86
  `confirmed: true` means the provider returned payment proof and the Platform accepted completion.
87
87
 
88
- ## Policy Guard
88
+ ## Approvals
89
89
 
90
- The SDK also exposes the lower-level policy evaluator guard:
90
+ When a payment exceeds the agent's per-service approval threshold (or trips an
91
+ `approval_required` rule), the Platform escalates instead of paying:
92
+ `gordon.fetch()` throws `GordonPaymentError` carrying an `approval_id` in its
93
+ `body`. A human resolves it from the dashboard's Approvals queue; the agent polls
94
+ until it clears, then retries the same call to settle.
91
95
 
92
96
  ```ts
93
- import { Gordon, GordonBlockedError, GordonEscalateError } from "@withgordon/core";
94
-
95
- await gordon.guard(
96
- {
97
- action_type: "purchase",
98
- vendor: "example.com",
99
- amount: 45_000_000, // $45.00
100
- currency: "USD",
101
- category: "software",
102
- metadata: { invoice: "inv_123" },
103
- },
104
- async () => {
105
- // Only runs when policy allows.
106
- return doThePurchase();
107
- },
108
- );
97
+ import { Gordon, GordonPaymentError } from "@withgordon/core";
98
+
99
+ try {
100
+ await gordon.fetch(url, opts);
101
+ } catch (err) {
102
+ if (err instanceof GordonPaymentError && err.body?.approval_id) {
103
+ const approvalId = err.body.approval_id as string;
104
+
105
+ // Poll until a human approves or denies in the dashboard.
106
+ let status = await gordon.checkApproval(approvalId);
107
+ while (status.status === "pending") {
108
+ await new Promise((r) => setTimeout(r, 5_000));
109
+ status = await gordon.checkApproval(approvalId);
110
+ }
111
+
112
+ if (status.status === "approved") {
113
+ // Retry the same call — the Platform settles against the approval
114
+ // exactly once (a second retry is rejected as a replay).
115
+ await gordon.fetch(url, opts);
116
+ }
117
+ }
118
+ }
109
119
  ```
110
120
 
121
+ `checkApproval()` returns `{ status, resolvedAt, resolvedBy }` and reports
122
+ `pending` for unknown ids (the approval cache has a 7-day TTL).
123
+
124
+ > The lower-level payment-agnostic policy guard (`gordon.evaluate()` /
125
+ > `gordon.guard()`) and the standalone evaluator service were removed
126
+ > 2026-06-05 — all governance now runs through the Platform's x402 surface
127
+ > above. To restore the payment-agnostic surface, see `CLAUDE.md` (recovery
128
+ > pointer to commit `bb4cffa`).
129
+
111
130
  ## Money Units
112
131
 
113
132
  Gordon uses integer micro-units:
@@ -1,8 +1,13 @@
1
- import type { TransactionRequest, Decision, EvaluateResponse, ApprovalStatus } from '../types.js';
1
+ import type { ApprovalStatus } from '../types.js';
2
2
  export interface GordonConfig {
3
- evaluatorUrl: string;
4
- /** Platform API base URL (e.g. https://api.withgordon.ai). Required for gordon.fetch(). */
5
- platformUrl?: string;
3
+ /**
4
+ * Platform API base URL (e.g. https://api.withgordon.ai). Required Gordon's
5
+ * governance runs entirely through the platform's x402 surface
6
+ * (gordon.fetch + gordon.checkApproval). The standalone evaluator and the
7
+ * payment-agnostic gordon.evaluate()/guard() were removed 2026-06-05; see
8
+ * CLAUDE.md (recovery pointer to commit bb4cffa) to restore them.
9
+ */
10
+ platformUrl: string;
6
11
  agentApiKey: string;
7
12
  agentApiSecret: string;
8
13
  fetch?: typeof fetch;
@@ -18,6 +23,11 @@ export interface GordonFetchOptions extends RequestInit {
18
23
  * Defaults to a random UUID per call if not provided.
19
24
  */
20
25
  idempotencyKey?: string;
26
+ /**
27
+ * Optional one-shot key used by the Platform's short-TTL replay guard.
28
+ * Do not reuse it for a distinct authorization attempt.
29
+ */
30
+ replayKey?: string;
21
31
  /**
22
32
  * Maximum amount (micro-units, 1,000,000 = $1.00) this call is allowed to spend.
23
33
  * Gordon rejects any 402 whose amount exceeds this ceiling.
@@ -57,58 +67,24 @@ export interface GordonFetchResult {
57
67
  confirmed: boolean;
58
68
  } | null;
59
69
  }
60
- /** Body fields the agent supplies to /evaluate. `agent_id` comes from the
61
- * Bearer credential; `timestamp` is server-stamped (closes audit gap #4). */
62
- export type RequestPayload = Omit<TransactionRequest, 'agent_id' | 'timestamp'>;
63
- export interface GuardOptions {
64
- /** Pass the approval_id from a prior `GordonEscalateError` to retry that
65
- * same logical transaction. The evaluator gates the call against the
66
- * approval's resolved state — see evaluator/server.ts for full semantics. */
67
- approvalId?: string;
68
- }
69
- export declare class GordonBlockedError extends Error {
70
- readonly decision: EvaluateResponse;
71
- readonly name = "GordonBlockedError";
72
- constructor(decision: EvaluateResponse);
73
- }
74
- export declare class GordonEscalateError extends Error {
75
- readonly decision: EvaluateResponse;
76
- readonly name = "GordonEscalateError";
77
- readonly approvalId: string | null;
78
- constructor(decision: EvaluateResponse);
79
- }
80
70
  /**
81
- * Gordon SDK — single HTTP call per transaction.
82
- *
83
- * The evaluator is the single source of truth for "this decision happened":
84
- * it generates the transaction_id (always) and approval_id (on escalate),
85
- * pushes the record to a Redis stream, and returns both IDs in the response.
86
- * The ledger worker drains the stream into Postgres asynchronously.
71
+ * Gordon SDK — the x402 payment intercept layer.
87
72
  *
88
- * Escalate retry pattern:
89
- * try { await gordon.guard(req, exec) }
90
- * catch (e) {
91
- * if (e instanceof GordonEscalateError) {
92
- * // poll until resolved (or webhook, or whatever the agent runtime supports)
93
- * while ((await gordon.checkApproval(e.approvalId!)).status === 'pending') {
94
- * await sleep(2000);
95
- * }
96
- * // retry with the approvalId — evaluator gates against the resolved state
97
- * await gordon.guard(req, exec, { approvalId: e.approvalId! });
98
- * }
99
- * }
73
+ * gordon.fetch() is a drop-in fetch that runs the x402 402->authorize->retry
74
+ * cycle through the platform; gordon.checkApproval() polls an approval the
75
+ * platform issued (the escalate->approve->retry loop). All governance runs IN
76
+ * the platform (the standalone evaluator + payment-agnostic gordon.evaluate()/
77
+ * guard() were removed 2026-06-05 - see CLAUDE.md recovery pointer to bb4cffa).
100
78
  */
101
79
  export declare class Gordon {
102
80
  private readonly cfg;
103
81
  private readonly fetchImpl;
104
82
  private readonly authHeader;
105
83
  constructor(cfg: GordonConfig);
106
- evaluate(request: RequestPayload, opts?: GuardOptions): Promise<EvaluateResponse>;
107
- guard<T>(request: RequestPayload, exec: () => Promise<T>, opts?: GuardOptions): Promise<T>;
108
84
  /**
109
- * Poll the status of an approval the evaluator previously issued.
110
- * Returns `{status: 'pending'}` for unknown ids — the worker may not have
111
- * drained yet, or the cache may have expired (7-day TTL).
85
+ * Poll the status of an approval the platform issued (on an x402 escalate).
86
+ * Returns `{status: 'pending'}` for unknown ids — the cache may have expired
87
+ * (7-day TTL) or the id is wrong.
112
88
  */
113
89
  checkApproval(approvalId: string): Promise<{
114
90
  status: ApprovalStatus;
@@ -137,5 +113,5 @@ export declare class GordonPaymentError extends Error {
137
113
  readonly name = "GordonPaymentError";
138
114
  constructor(message: string, statusCode?: number | undefined, body?: Record<string, unknown> | undefined);
139
115
  }
140
- export type { Decision, EvaluateResponse, ApprovalStatus };
116
+ export type { ApprovalStatus };
141
117
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot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AAC;KACpB,GAAG,IAAI,CAAC;CACV;AAED;;;;;;;;GAQG;AACH,qBAAa,MAAM;IAIL,OAAO,CAAC,QAAQ,CAAC,GAAG;IAHhC,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAe;IACzC,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAS;gBAEP,GAAG,EAAE,YAAY;IAc9C;;;;OAIG;IACG,aAAa,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC;QAC/C,MAAM,EAAE,cAAc,CAAC;QACvB,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;QAC1B,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;KAC3B,CAAC;IAiCF;;;;;;;;;;;;;OAaG;IACG,KAAK,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,GAAE,kBAAuB,GAAG,OAAO,CAAC,iBAAiB,CAAC;CAoLvF;AAED,qBAAa,kBAAmB,SAAQ,KAAK;IAIzC,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM;IAC5B,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;IAJzC,SAAkB,IAAI,wBAAwB;gBAE5C,OAAO,EAAE,MAAM,EACN,UAAU,CAAC,EAAE,MAAM,YAAA,EACnB,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,YAAA;CAI1C;AAGD,YAAY,EAAE,cAAc,EAAE,CAAC"}
package/dist/sdk/index.js CHANGED
@@ -1,51 +1,13 @@
1
1
  import { createHash, randomBytes } from 'node:crypto';
2
2
  import { normalizeX402PaymentRequirement } from '../types.js';
3
- export class GordonBlockedError extends Error {
4
- decision;
5
- name = 'GordonBlockedError';
6
- constructor(decision) {
7
- super(`gordon_blocked: ${decision.reason}`);
8
- this.decision = decision;
9
- }
10
- }
11
- export class GordonEscalateError extends Error {
12
- decision;
13
- name = 'GordonEscalateError';
14
- approvalId;
15
- constructor(decision) {
16
- super(`gordon_escalate: ${decision.reason}`);
17
- this.decision = decision;
18
- this.approvalId = decision.approval_id;
19
- }
20
- }
21
- const failClosed = (reason) => ({
22
- result: 'block',
23
- reason,
24
- rule_triggered: null,
25
- latency_ms: 0,
26
- transaction_id: '00000000-0000-0000-0000-000000000000',
27
- approval_id: null,
28
- });
29
3
  /**
30
- * Gordon SDK — single HTTP call per transaction.
4
+ * Gordon SDK — the x402 payment intercept layer.
31
5
  *
32
- * The evaluator is the single source of truth for "this decision happened":
33
- * it generates the transaction_id (always) and approval_id (on escalate),
34
- * pushes the record to a Redis stream, and returns both IDs in the response.
35
- * The ledger worker drains the stream into Postgres asynchronously.
36
- *
37
- * Escalate retry pattern:
38
- * try { await gordon.guard(req, exec) }
39
- * catch (e) {
40
- * if (e instanceof GordonEscalateError) {
41
- * // poll until resolved (or webhook, or whatever the agent runtime supports)
42
- * while ((await gordon.checkApproval(e.approvalId!)).status === 'pending') {
43
- * await sleep(2000);
44
- * }
45
- * // retry with the approvalId — evaluator gates against the resolved state
46
- * await gordon.guard(req, exec, { approvalId: e.approvalId! });
47
- * }
48
- * }
6
+ * gordon.fetch() is a drop-in fetch that runs the x402 402->authorize->retry
7
+ * cycle through the platform; gordon.checkApproval() polls an approval the
8
+ * platform issued (the escalate->approve->retry loop). All governance runs IN
9
+ * the platform (the standalone evaluator + payment-agnostic gordon.evaluate()/
10
+ * guard() were removed 2026-06-05 - see CLAUDE.md recovery pointer to bb4cffa).
49
11
  */
50
12
  export class Gordon {
51
13
  cfg;
@@ -65,43 +27,21 @@ export class Gordon {
65
27
  }
66
28
  this.authHeader = `Bearer ${cfg.agentApiKey}:${cfg.agentApiSecret}`;
67
29
  }
68
- async evaluate(request, opts) {
69
- try {
70
- const body = { request };
71
- if (opts?.approvalId)
72
- body.idempotency_key = opts.approvalId;
73
- const res = await this.fetchImpl(`${this.cfg.evaluatorUrl}/evaluate`, {
74
- method: 'POST',
75
- headers: {
76
- 'content-type': 'application/json',
77
- authorization: this.authHeader,
78
- },
79
- body: JSON.stringify(body),
80
- });
81
- if (!res.ok)
82
- return failClosed(`evaluator_status_${res.status}`);
83
- return (await res.json());
84
- }
85
- catch {
86
- return failClosed('evaluator_unreachable');
87
- }
88
- }
89
- async guard(request, exec, opts) {
90
- const decision = await this.evaluate(request, opts);
91
- if (decision.result === 'block')
92
- throw new GordonBlockedError(decision);
93
- if (decision.result === 'escalate')
94
- throw new GordonEscalateError(decision);
95
- return await exec();
96
- }
97
30
  /**
98
- * Poll the status of an approval the evaluator previously issued.
99
- * Returns `{status: 'pending'}` for unknown ids — the worker may not have
100
- * drained yet, or the cache may have expired (7-day TTL).
31
+ * Poll the status of an approval the platform issued (on an x402 escalate).
32
+ * Returns `{status: 'pending'}` for unknown ids — the cache may have expired
33
+ * (7-day TTL) or the id is wrong.
101
34
  */
102
35
  async checkApproval(approvalId) {
36
+ // Poll the PLATFORM's agent-facing /approvals/:id (the evaluator's
37
+ // equivalent was decommissioned 2026-06-05). gordon.fetch()'s x402 escalate
38
+ // flow returns an approval_id; poll here until approved, then retry the fetch.
39
+ const platformUrl = this.cfg.platformUrl;
40
+ if (!platformUrl) {
41
+ throw new Error('gordon.checkApproval() requires GordonConfig.platformUrl');
42
+ }
103
43
  try {
104
- const res = await this.fetchImpl(`${this.cfg.evaluatorUrl}/approvals/${encodeURIComponent(approvalId)}`, {
44
+ const res = await this.fetchImpl(`${platformUrl}/approvals/${encodeURIComponent(approvalId)}`, {
105
45
  method: 'GET',
106
46
  headers: { authorization: this.authHeader },
107
47
  });
@@ -141,7 +81,7 @@ export class Gordon {
141
81
  if (!platformUrl) {
142
82
  throw new Error('gordon.fetch() requires GordonConfig.platformUrl');
143
83
  }
144
- const { serviceId, operationId, idempotencyKey, maxPaymentUnits = 100_000, targetUrl, ...fetchOpts } = options;
84
+ const { serviceId, operationId, idempotencyKey, replayKey, maxPaymentUnits = 100_000, targetUrl, ...fetchOpts } = options;
145
85
  const idemKey = idempotencyKey ?? randomBytes(16).toString('hex');
146
86
  // ── 1. Initial request ──────────────────────────────────────────────
147
87
  const originalRes = await this.fetchImpl(url, fetchOpts);
@@ -155,18 +95,22 @@ export class Gordon {
155
95
  const paymentReqHeader = originalRes.headers.get('X-Payment-Required') ??
156
96
  originalRes.headers.get('x-payment-required') ??
157
97
  originalRes.headers.get('PAYMENT-REQUIRED');
98
+ // rawPaymentReq holds the original 402 body/header — passed as-is to the
99
+ // Platform so it can normalize once server-side (preserves `extra` fields
100
+ // and avoids the double-normalization bug that strips provider-specific
101
+ // fields needed for signature verification, e.g. Untitled Financial, Exa).
102
+ let rawPaymentReq;
158
103
  let paymentRequirement;
159
104
  try {
160
105
  if (paymentReqHeader) {
161
106
  // Header path (x402v1 or base64-encoded v2 header)
162
- let raw;
163
107
  try {
164
- raw = JSON.parse(Buffer.from(paymentReqHeader, 'base64url').toString('utf-8'));
108
+ rawPaymentReq = JSON.parse(Buffer.from(paymentReqHeader, 'base64url').toString('utf-8'));
165
109
  }
166
110
  catch {
167
- raw = JSON.parse(paymentReqHeader);
111
+ rawPaymentReq = JSON.parse(paymentReqHeader);
168
112
  }
169
- paymentRequirement = normalizeX402PaymentRequirement(raw);
113
+ paymentRequirement = normalizeX402PaymentRequirement(rawPaymentReq);
170
114
  }
171
115
  else {
172
116
  // Body path (x402v2 — parse response body as JSON payment requirement)
@@ -186,6 +130,7 @@ export class Gordon {
186
130
  if (!looksLikeX402) {
187
131
  return { response: originalRes, receipt: null };
188
132
  }
133
+ rawPaymentReq = bodyRaw;
189
134
  paymentRequirement = normalizeX402PaymentRequirement(bodyRaw);
190
135
  }
191
136
  }
@@ -217,10 +162,12 @@ export class Gordon {
217
162
  body_hash: bodyHash,
218
163
  ...(targetUrl ? { target_url: targetUrl } : {}),
219
164
  },
220
- payment_requirement: paymentRequirement,
165
+ // Pass the raw 402 body so the Platform normalizes once server-side.
166
+ payment_requirement: rawPaymentReq,
221
167
  max_payment_units: maxPaymentUnits,
222
168
  currency: 'USDC',
223
169
  idempotency_key: idemKey,
170
+ ...(replayKey ? { replay_key: replayKey } : {}),
224
171
  };
225
172
  const authorizeRes = await this.fetchImpl(`${platformUrl}/x402/authorize`, {
226
173
  method: 'POST',
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../sdk/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AACtD,OAAO,EAAE,+BAA+B,EAAE,MAAM,aAAa,CAAC;AAqF9D,MAAM,OAAO,kBAAmB,SAAQ,KAAK;IAEtB;IADH,IAAI,GAAG,oBAAoB,CAAC;IAC9C,YAAqB,QAA0B;QAC7C,KAAK,CAAC,mBAAmB,QAAQ,CAAC,MAAM,EAAE,CAAC,CAAC;QADzB,aAAQ,GAAR,QAAQ,CAAkB;IAE/C,CAAC;CACF;AAED,MAAM,OAAO,mBAAoB,SAAQ,KAAK;IAGvB;IAFH,IAAI,GAAG,qBAAqB,CAAC;IACtC,UAAU,CAAgB;IACnC,YAAqB,QAA0B;QAC7C,KAAK,CAAC,oBAAoB,QAAQ,CAAC,MAAM,EAAE,CAAC,CAAC;QAD1B,aAAQ,GAAR,QAAQ,CAAkB;QAE7C,IAAI,CAAC,UAAU,GAAG,QAAQ,CAAC,WAAW,CAAC;IACzC,CAAC;CACF;AAED,MAAM,UAAU,GAAG,CAAC,MAAc,EAAoB,EAAE,CAAC,CAAC;IACxD,MAAM,EAAE,OAAO;IACf,MAAM;IACN,cAAc,EAAE,IAAI;IACpB,UAAU,EAAE,CAAC;IACb,cAAc,EAAE,sCAAsC;IACtD,WAAW,EAAE,IAAI;CAClB,CAAC,CAAC;AAEH;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,MAAM,OAAO,MAAM;IAIY;IAHZ,SAAS,CAAe;IACxB,UAAU,CAAS;IAEpC,YAA6B,GAAiB;QAAjB,QAAG,GAAH,GAAG,CAAc;QAC5C,MAAM,WAAW,GAAG,UAAU,CAAC,KAAK,CAAC;QACrC,IAAI,GAAG,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;YACL,QAAQ,EAAE,WAAW;YACrB,OAAO,EAAE;gBACP,aAAa,EAAE,aAAa,CAAC,aAAa;gBAC1C,cAAc,EAAE,aAAa,CAAC,cAAc;gBAC5C,YAAY,EAAE,WAAW;gBACzB,OAAO,EAAE,kBAAkB,CAAC,OAAO;gBACnC,MAAM,EAAE,kBAAkB,CAAC,MAAM;gBACjC,SAAS;aACV;SACF,CAAC;IACJ,CAAC;CACF;AAED,MAAM,OAAO,kBAAmB,SAAQ,KAAK;IAIhC;IACA;IAJO,IAAI,GAAG,oBAAoB,CAAC;IAC9C,YACE,OAAe,EACN,UAAmB,EACnB,IAA8B;QAEvC,KAAK,CAAC,OAAO,CAAC,CAAC;QAHN,eAAU,GAAV,UAAU,CAAS;QACnB,SAAI,GAAJ,IAAI,CAA0B;IAGzC,CAAC;CACF"}
package/dist/types.d.ts CHANGED
@@ -1,3 +1,4 @@
1
+ import { z } from 'zod';
1
2
  export type ActionType = 'purchase' | 'service_call';
2
3
  export type ServiceCategory = 'search' | 'scrape' | 'ai' | 'data' | 'infrastructure' | 'security' | 'finance' | 'creative';
3
4
  /** State machine: listed → discovered → probe_passed → gordon_verified | disabled */
@@ -52,7 +53,8 @@ export interface X402AuthorizeRequest {
52
53
  */
53
54
  session_id?: string;
54
55
  };
55
- payment_requirement: X402PaymentRequirement;
56
+ /** Raw 402 body from the provider. Platform normalizes server-side so extra fields are preserved. */
57
+ payment_requirement: X402PaymentRequirement | Record<string, unknown>;
56
58
  /**
57
59
  * SDK-supplied ceiling in micro-units (1,000,000 = $1.00).
58
60
  * Platform will reject if the required amount exceeds this.
@@ -61,6 +63,12 @@ export interface X402AuthorizeRequest {
61
63
  currency: string;
62
64
  /** Caller-supplied UUID, stable across retries. */
63
65
  idempotency_key: string;
66
+ /**
67
+ * Optional one-shot replay key. The Platform rejects reuse by the same agent
68
+ * for a short TTL. Unlike idempotency_key, this protects a new authorization
69
+ * attempt and is not used to retrieve an existing settlement.
70
+ */
71
+ replay_key?: string;
64
72
  }
65
73
  /** Platform → SDK: payment approved and signed. SDK retries the original request. */
66
74
  export interface X402AuthorizeResponse {
@@ -80,7 +88,7 @@ export interface TransactionRequest {
80
88
  currency: string;
81
89
  category: string;
82
90
  metadata: Record<string, unknown>;
83
- /** Server-set: the evaluator's processing time (ms since epoch) — NOT
91
+ /** Server-set: the platform's processing time (ms since epoch) — NOT
84
92
  * agent-supplied. Used to compute the UTC daily/monthly spend bucket.
85
93
  * Closes audit gap #4 (no clock-skew exploit possible). */
86
94
  timestamp: number;
@@ -111,17 +119,19 @@ export interface Decision {
111
119
  latency_ms: number;
112
120
  }
113
121
  /**
114
- * The HTTP response body of POST /evaluate. Wraps a pure engine `Decision`
115
- * with identifiers generated by the evaluator's HTTP handler:
122
+ * A pure engine `Decision` wrapped with the identifiers the platform's x402
123
+ * governance path generates around it:
116
124
  * - `transaction_id`: always set; the eventual `transactions.id` row
117
- * - `approval_id`: set on initial escalate AND echoed back on retries
118
- * that carry an `idempotency_key` (so the agent keeps
119
- * polling the same approval). Null on plain allow/block.
125
+ * - `approval_id`: set on escalate (the approval the agent retries
126
+ * against). Null on plain allow/block.
120
127
  *
121
128
  * Both are pushed to the `ledger_stream` Redis stream and drained into
122
- * Postgres asynchronously by the ledger worker. The IDs are returned to
123
- * the caller immediately so the SDK can throw `GordonEscalateError` with
124
- * the approval id without waiting on the DB write.
129
+ * Postgres asynchronously by the ledger worker.
130
+ *
131
+ * NOTE: currently unreferenced this was the body of the removed payment-
132
+ * agnostic `POST /evaluate` (decommissioned 2026-06-05; recovery pointer in
133
+ * CLAUDE.md System A → commit `bb4cffa`). Retained as the canonical shape for
134
+ * that surface if it is ever restored.
125
135
  */
126
136
  export interface EvaluateResponse extends Decision {
127
137
  transaction_id: string;
@@ -129,9 +139,10 @@ export interface EvaluateResponse extends Decision {
129
139
  }
130
140
  export type ApprovalStatus = 'pending' | 'approved' | 'denied';
131
141
  /**
132
- * Response body of GET /approvals/:id on the evaluator. Backed by Redis —
133
- * see `evaluator/cache.ts → keys.approval`. Polled by agents after they
134
- * receive a `GordonEscalateError`.
142
+ * Response body of GET /approvals/:id on the platform (agent-key auth).
143
+ * Backed by Redis — see `engine/cache.ts → keys.approval`. Polled by agents
144
+ * via `gordon.checkApproval()` after an x402 escalate hands back an
145
+ * `approval_id` (surfaced as `GordonPaymentError.body.approval_id`).
135
146
  */
136
147
  export interface ApprovalStatusResponse {
137
148
  approval_id: string;
@@ -139,4 +150,285 @@ export interface ApprovalStatusResponse {
139
150
  resolved_at: number | null;
140
151
  resolved_by: string | null;
141
152
  }
153
+ export declare const RuleSchema: z.ZodObject<{
154
+ id: z.ZodString;
155
+ type: z.ZodEnum<["budget_limit", "vendor_allowlist", "category_block", "approval_required", "service_allowlist"]>;
156
+ scope: z.ZodEnum<["per_transaction", "daily", "monthly"]>;
157
+ value: z.ZodUnion<[z.ZodNumber, z.ZodArray<z.ZodString, "many">]>;
158
+ priority: z.ZodNumber;
159
+ }, "strip", z.ZodTypeAny, {
160
+ id: string;
161
+ type: "budget_limit" | "vendor_allowlist" | "category_block" | "approval_required" | "service_allowlist";
162
+ value: number | string[];
163
+ scope: "per_transaction" | "daily" | "monthly";
164
+ priority: number;
165
+ }, {
166
+ id: string;
167
+ type: "budget_limit" | "vendor_allowlist" | "category_block" | "approval_required" | "service_allowlist";
168
+ value: number | string[];
169
+ scope: "per_transaction" | "daily" | "monthly";
170
+ priority: number;
171
+ }>;
172
+ /** The provider's original request descriptor (drives vendor + domain checks). */
173
+ export declare const OriginalRequestSchema: z.ZodObject<{
174
+ url: z.ZodString;
175
+ method: z.ZodOptional<z.ZodString>;
176
+ body_hash: z.ZodOptional<z.ZodString>;
177
+ target_url: z.ZodOptional<z.ZodString>;
178
+ session_id: z.ZodOptional<z.ZodString>;
179
+ }, "strip", z.ZodTypeAny, {
180
+ url: string;
181
+ method?: string | undefined;
182
+ body_hash?: string | undefined;
183
+ target_url?: string | undefined;
184
+ session_id?: string | undefined;
185
+ }, {
186
+ url: string;
187
+ method?: string | undefined;
188
+ body_hash?: string | undefined;
189
+ target_url?: string | undefined;
190
+ session_id?: string | undefined;
191
+ }>;
192
+ /** Hypothetical spend/default context (simulator pretend-spend; dry-run). */
193
+ export declare const EvalContextOverrideSchema: z.ZodObject<{
194
+ spend_today: z.ZodOptional<z.ZodNumber>;
195
+ spend_this_month: z.ZodOptional<z.ZodNumber>;
196
+ default_decision: z.ZodOptional<z.ZodEnum<["allow", "block"]>>;
197
+ }, "strip", z.ZodTypeAny, {
198
+ spend_today?: number | undefined;
199
+ spend_this_month?: number | undefined;
200
+ default_decision?: "allow" | "block" | undefined;
201
+ }, {
202
+ spend_today?: number | undefined;
203
+ spend_this_month?: number | undefined;
204
+ default_decision?: "allow" | "block" | undefined;
205
+ }>;
206
+ /** Inline per-service caps (dry-run "what if these limits" testing). */
207
+ export declare const EnabledServiceInputSchema: z.ZodObject<{
208
+ max_per_call_units: z.ZodNumber;
209
+ max_per_day_units: z.ZodNumber;
210
+ require_approval_above_units: z.ZodNumber;
211
+ enabled_operations: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodString, "many">>>;
212
+ allowed_domains: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodString, "many">>>;
213
+ }, "strip", z.ZodTypeAny, {
214
+ max_per_call_units: number;
215
+ max_per_day_units: number;
216
+ require_approval_above_units: number;
217
+ enabled_operations?: string[] | null | undefined;
218
+ allowed_domains?: string[] | null | undefined;
219
+ }, {
220
+ max_per_call_units: number;
221
+ max_per_day_units: number;
222
+ require_approval_above_units: number;
223
+ enabled_operations?: string[] | null | undefined;
224
+ allowed_domains?: string[] | null | undefined;
225
+ }>;
226
+ /**
227
+ * The single locked request body for the four platform evaluation routes.
228
+ * Field PRESENCE requirements differ per route (enforced after parse):
229
+ * - /x402/authorize: payment_requirement + max_payment_units + idempotency_key required
230
+ * - /x402/check: payment_requirement + max_payment_units + replay_key required
231
+ * - /x402/authorize-test: amount required when payment_requirement is absent
232
+ * - /policies/dry-run: rules required
233
+ * `.strict()` rejects unknown keys so contract drift is caught at the door.
234
+ */
235
+ export declare const UnifiedAuthorizeRequestSchema: z.ZodObject<{
236
+ service_id: z.ZodOptional<z.ZodString>;
237
+ operation_id: z.ZodOptional<z.ZodString>;
238
+ original_request: z.ZodOptional<z.ZodObject<{
239
+ url: z.ZodString;
240
+ method: z.ZodOptional<z.ZodString>;
241
+ body_hash: z.ZodOptional<z.ZodString>;
242
+ target_url: z.ZodOptional<z.ZodString>;
243
+ session_id: z.ZodOptional<z.ZodString>;
244
+ }, "strip", z.ZodTypeAny, {
245
+ url: string;
246
+ method?: string | undefined;
247
+ body_hash?: string | undefined;
248
+ target_url?: string | undefined;
249
+ session_id?: string | undefined;
250
+ }, {
251
+ url: string;
252
+ method?: string | undefined;
253
+ body_hash?: string | undefined;
254
+ target_url?: string | undefined;
255
+ session_id?: string | undefined;
256
+ }>>;
257
+ payment_requirement: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
258
+ /** Micro-units (1,000,000 = $1). Required in test/dry-run when no payment_requirement. */
259
+ amount: z.ZodOptional<z.ZodNumber>;
260
+ max_payment_units: z.ZodOptional<z.ZodNumber>;
261
+ currency: z.ZodOptional<z.ZodString>;
262
+ idempotency_key: z.ZodOptional<z.ZodString>;
263
+ replay_key: z.ZodOptional<z.ZodString>;
264
+ /** Override vendor/category for test/dry-run; otherwise derived. */
265
+ vendor: z.ZodOptional<z.ZodString>;
266
+ category: z.ZodOptional<z.ZodString>;
267
+ /** Granted approval to execute against on a real /x402/authorize retry. */
268
+ approval_id: z.ZodOptional<z.ZodString>;
269
+ rules: z.ZodOptional<z.ZodArray<z.ZodObject<{
270
+ id: z.ZodString;
271
+ type: z.ZodEnum<["budget_limit", "vendor_allowlist", "category_block", "approval_required", "service_allowlist"]>;
272
+ scope: z.ZodEnum<["per_transaction", "daily", "monthly"]>;
273
+ value: z.ZodUnion<[z.ZodNumber, z.ZodArray<z.ZodString, "many">]>;
274
+ priority: z.ZodNumber;
275
+ }, "strip", z.ZodTypeAny, {
276
+ id: string;
277
+ type: "budget_limit" | "vendor_allowlist" | "category_block" | "approval_required" | "service_allowlist";
278
+ value: number | string[];
279
+ scope: "per_transaction" | "daily" | "monthly";
280
+ priority: number;
281
+ }, {
282
+ id: string;
283
+ type: "budget_limit" | "vendor_allowlist" | "category_block" | "approval_required" | "service_allowlist";
284
+ value: number | string[];
285
+ scope: "per_transaction" | "daily" | "monthly";
286
+ priority: number;
287
+ }>, "many">>;
288
+ context: z.ZodOptional<z.ZodObject<{
289
+ spend_today: z.ZodOptional<z.ZodNumber>;
290
+ spend_this_month: z.ZodOptional<z.ZodNumber>;
291
+ default_decision: z.ZodOptional<z.ZodEnum<["allow", "block"]>>;
292
+ }, "strip", z.ZodTypeAny, {
293
+ spend_today?: number | undefined;
294
+ spend_this_month?: number | undefined;
295
+ default_decision?: "allow" | "block" | undefined;
296
+ }, {
297
+ spend_today?: number | undefined;
298
+ spend_this_month?: number | undefined;
299
+ default_decision?: "allow" | "block" | undefined;
300
+ }>>;
301
+ enabled_service: z.ZodOptional<z.ZodNullable<z.ZodObject<{
302
+ max_per_call_units: z.ZodNumber;
303
+ max_per_day_units: z.ZodNumber;
304
+ require_approval_above_units: z.ZodNumber;
305
+ enabled_operations: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodString, "many">>>;
306
+ allowed_domains: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodString, "many">>>;
307
+ }, "strip", z.ZodTypeAny, {
308
+ max_per_call_units: number;
309
+ max_per_day_units: number;
310
+ require_approval_above_units: number;
311
+ enabled_operations?: string[] | null | undefined;
312
+ allowed_domains?: string[] | null | undefined;
313
+ }, {
314
+ max_per_call_units: number;
315
+ max_per_day_units: number;
316
+ require_approval_above_units: number;
317
+ enabled_operations?: string[] | null | undefined;
318
+ allowed_domains?: string[] | null | undefined;
319
+ }>>>;
320
+ /** dry-run / authorize-test (JWT auth) supply the target agent in the body. */
321
+ agent_id: z.ZodOptional<z.ZodString>;
322
+ }, "strict", z.ZodTypeAny, {
323
+ amount?: number | undefined;
324
+ service_id?: string | undefined;
325
+ operation_id?: string | undefined;
326
+ original_request?: {
327
+ url: string;
328
+ method?: string | undefined;
329
+ body_hash?: string | undefined;
330
+ target_url?: string | undefined;
331
+ session_id?: string | undefined;
332
+ } | undefined;
333
+ payment_requirement?: Record<string, unknown> | undefined;
334
+ max_payment_units?: number | undefined;
335
+ currency?: string | undefined;
336
+ idempotency_key?: string | undefined;
337
+ replay_key?: string | undefined;
338
+ vendor?: string | undefined;
339
+ category?: string | undefined;
340
+ approval_id?: string | undefined;
341
+ rules?: {
342
+ id: string;
343
+ type: "budget_limit" | "vendor_allowlist" | "category_block" | "approval_required" | "service_allowlist";
344
+ value: number | string[];
345
+ scope: "per_transaction" | "daily" | "monthly";
346
+ priority: number;
347
+ }[] | undefined;
348
+ context?: {
349
+ spend_today?: number | undefined;
350
+ spend_this_month?: number | undefined;
351
+ default_decision?: "allow" | "block" | undefined;
352
+ } | undefined;
353
+ enabled_service?: {
354
+ max_per_call_units: number;
355
+ max_per_day_units: number;
356
+ require_approval_above_units: number;
357
+ enabled_operations?: string[] | null | undefined;
358
+ allowed_domains?: string[] | null | undefined;
359
+ } | null | undefined;
360
+ agent_id?: string | undefined;
361
+ }, {
362
+ amount?: number | undefined;
363
+ service_id?: string | undefined;
364
+ operation_id?: string | undefined;
365
+ original_request?: {
366
+ url: string;
367
+ method?: string | undefined;
368
+ body_hash?: string | undefined;
369
+ target_url?: string | undefined;
370
+ session_id?: string | undefined;
371
+ } | undefined;
372
+ payment_requirement?: Record<string, unknown> | undefined;
373
+ max_payment_units?: number | undefined;
374
+ currency?: string | undefined;
375
+ idempotency_key?: string | undefined;
376
+ replay_key?: string | undefined;
377
+ vendor?: string | undefined;
378
+ category?: string | undefined;
379
+ approval_id?: string | undefined;
380
+ rules?: {
381
+ id: string;
382
+ type: "budget_limit" | "vendor_allowlist" | "category_block" | "approval_required" | "service_allowlist";
383
+ value: number | string[];
384
+ scope: "per_transaction" | "daily" | "monthly";
385
+ priority: number;
386
+ }[] | undefined;
387
+ context?: {
388
+ spend_today?: number | undefined;
389
+ spend_this_month?: number | undefined;
390
+ default_decision?: "allow" | "block" | undefined;
391
+ } | undefined;
392
+ enabled_service?: {
393
+ max_per_call_units: number;
394
+ max_per_day_units: number;
395
+ require_approval_above_units: number;
396
+ enabled_operations?: string[] | null | undefined;
397
+ allowed_domains?: string[] | null | undefined;
398
+ } | null | undefined;
399
+ agent_id?: string | undefined;
400
+ }>;
401
+ export type UnifiedAuthorizeRequest = z.infer<typeof UnifiedAuthorizeRequestSchema>;
402
+ export type EvalContextOverride = z.infer<typeof EvalContextOverrideSchema>;
403
+ export type EnabledServiceInput = z.infer<typeof EnabledServiceInputSchema>;
404
+ /**
405
+ * Response of POST /x402/authorize-test — a full real-state evaluation with NO
406
+ * side effects (no signing, settlement, spend, audit, or approval). Deliberately
407
+ * carries NO transaction_id/settlement_id/payment_headers.
408
+ */
409
+ export interface AuthorizeTestResponse {
410
+ test: true;
411
+ decision: Decision;
412
+ /** true iff every gate passed AND decision.result === 'allow'. */
413
+ would_authorize: boolean;
414
+ /** Convenience mirror of the outcome ('block' on a pre-eval reject). */
415
+ result: DecisionResult;
416
+ reason: string;
417
+ amount_units: number;
418
+ max_per_call_units: number | null;
419
+ max_per_day_units: number | null;
420
+ require_approval_above_units: number | null;
421
+ approval_required: boolean;
422
+ fraud: {
423
+ risk_score: number;
424
+ flags: string[];
425
+ };
426
+ /** Echo of the input slug + the resolved internal UUID (for debugging). */
427
+ service_id: string | null;
428
+ resolved_service_internal_id: string | null;
429
+ }
430
+ /** Agent-authenticated policy-only preflight. Carries no payment proof or IDs. */
431
+ export type X402CheckResponse = Omit<AuthorizeTestResponse, 'test'> & {
432
+ check: true;
433
+ };
142
434
  //# sourceMappingURL=types.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../types.ts"],"names":[],"mappings":"AA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AAG,CAAC,CAAC,KAAK,CAAC,OAAO,yBAAyB,CAAC,CAAC;AAE5E;;;;GAIG;AACH,MAAM,WAAW,qBAAqB;IACpC,IAAI,EAAE,IAAI,CAAC;IACX,QAAQ,EAAE,QAAQ,CAAC;IACnB,kEAAkE;IAClE,eAAe,EAAE,OAAO,CAAC;IACzB,wEAAwE;IACxE,MAAM,EAAE,cAAc,CAAC;IACvB,MAAM,EAAE,MAAM,CAAC;IACf,YAAY,EAAE,MAAM,CAAC;IACrB,kBAAkB,EAAE,MAAM,GAAG,IAAI,CAAC;IAClC,iBAAiB,EAAE,MAAM,GAAG,IAAI,CAAC;IACjC,4BAA4B,EAAE,MAAM,GAAG,IAAI,CAAC;IAC5C,iBAAiB,EAAE,OAAO,CAAC;IAC3B,KAAK,EAAE;QAAE,UAAU,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,EAAE,CAAA;KAAE,CAAC;IAC/C,2EAA2E;IAC3E,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,4BAA4B,EAAE,MAAM,GAAG,IAAI,CAAC;CAC7C;AAED,kFAAkF;AAClF,MAAM,MAAM,iBAAiB,GAAG,IAAI,CAAC,qBAAqB,EAAE,MAAM,CAAC,GAAG;IACpE,KAAK,EAAE,IAAI,CAAC;CACb,CAAC"}
package/dist/types.js CHANGED
@@ -1,3 +1,4 @@
1
+ import { z } from 'zod';
1
2
  // Known USDC ERC-20 contract addresses across supported chains.
2
3
  // Providers that use x402 v2 (e.g. Exa) send the contract address in the
3
4
  // `asset` field instead of the string "USDC". We normalize these back to
@@ -72,4 +73,86 @@ export function normalizeX402PaymentRequirement(raw) {
72
73
  raw,
73
74
  };
74
75
  }
76
+ // ── Unified evaluation request contract (PROJECT_TODOS #3) ──────────────────
77
+ // One validated request shape shared by the platform's three evaluation
78
+ // surfaces: POST /x402/authorize (real payment), POST /x402/check (agent-auth
79
+ // policy-only preflight), POST /x402/authorize-test
80
+ // (side-effect-free real-state simulation), and POST /policies/dry-run
81
+ // (hypothetical unsaved-rule testing). The CANONICAL `service_id`/`operation_id`
82
+ // on these platform paths is the human-readable SLUG; the handler resolves
83
+ // slug→UUID internally (the Redis SET stays UUID-keyed). The UUID-based
84
+ // payment-agnostic /evaluate was removed with the evaluator (2026-06-05), so
85
+ // slug is now the only convention on the surviving surfaces. zod gives us one
86
+ // enforced schema so a typo/drift on any surface fails loudly, not silently.
87
+ export const RuleSchema = z.object({
88
+ id: z.string(),
89
+ type: z.enum([
90
+ 'budget_limit',
91
+ 'vendor_allowlist',
92
+ 'category_block',
93
+ 'approval_required',
94
+ 'service_allowlist',
95
+ ]),
96
+ scope: z.enum(['per_transaction', 'daily', 'monthly']),
97
+ value: z.union([z.number(), z.array(z.string())]),
98
+ priority: z.number(),
99
+ });
100
+ /** The provider's original request descriptor (drives vendor + domain checks). */
101
+ export const OriginalRequestSchema = z.object({
102
+ url: z.string(),
103
+ method: z.string().optional(),
104
+ body_hash: z.string().optional(),
105
+ target_url: z.string().optional(),
106
+ session_id: z.string().optional(),
107
+ });
108
+ /** Hypothetical spend/default context (simulator pretend-spend; dry-run). */
109
+ export const EvalContextOverrideSchema = z.object({
110
+ spend_today: z.number().nonnegative().optional(),
111
+ spend_this_month: z.number().nonnegative().optional(),
112
+ default_decision: z.enum(['allow', 'block']).optional(),
113
+ });
114
+ /** Inline per-service caps (dry-run "what if these limits" testing). */
115
+ export const EnabledServiceInputSchema = z.object({
116
+ max_per_call_units: z.number(),
117
+ max_per_day_units: z.number(),
118
+ require_approval_above_units: z.number(),
119
+ enabled_operations: z.array(z.string()).nullable().optional(),
120
+ allowed_domains: z.array(z.string()).nullable().optional(),
121
+ });
122
+ /**
123
+ * The single locked request body for the four platform evaluation routes.
124
+ * Field PRESENCE requirements differ per route (enforced after parse):
125
+ * - /x402/authorize: payment_requirement + max_payment_units + idempotency_key required
126
+ * - /x402/check: payment_requirement + max_payment_units + replay_key required
127
+ * - /x402/authorize-test: amount required when payment_requirement is absent
128
+ * - /policies/dry-run: rules required
129
+ * `.strict()` rejects unknown keys so contract drift is caught at the door.
130
+ */
131
+ export const UnifiedAuthorizeRequestSchema = z
132
+ .object({
133
+ // ── identity (SLUG on platform paths) ──
134
+ service_id: z.string().optional(),
135
+ operation_id: z.string().optional(),
136
+ // ── payment / request descriptor ──
137
+ original_request: OriginalRequestSchema.optional(),
138
+ payment_requirement: z.record(z.string(), z.unknown()).optional(),
139
+ /** Micro-units (1,000,000 = $1). Required in test/dry-run when no payment_requirement. */
140
+ amount: z.number().int().nonnegative().optional(),
141
+ max_payment_units: z.number().int().positive().optional(),
142
+ currency: z.string().optional(),
143
+ idempotency_key: z.string().optional(),
144
+ replay_key: z.string().optional(),
145
+ /** Override vendor/category for test/dry-run; otherwise derived. */
146
+ vendor: z.string().optional(),
147
+ category: z.string().optional(),
148
+ /** Granted approval to execute against on a real /x402/authorize retry. */
149
+ approval_id: z.string().optional(),
150
+ // ── dry-run / test-only overrides ──
151
+ rules: z.array(RuleSchema).optional(),
152
+ context: EvalContextOverrideSchema.optional(),
153
+ enabled_service: EnabledServiceInputSchema.nullable().optional(),
154
+ /** dry-run / authorize-test (JWT auth) supply the target agent in the body. */
155
+ agent_id: z.string().optional(),
156
+ })
157
+ .strict();
75
158
  //# sourceMappingURL=types.js.map
package/dist/types.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../types.ts"],"names":[],"mappings":"AA8CA,gEAAgE;AAChE,yEAAyE;AACzE,yEAAyE;AACzE,uEAAuE;AACvE,qBAAqB;AACrB,MAAM,oBAAoB,GAAG,IAAI,GAAG,CAAC;IACnC,4CAA4C,EAAE,eAAe;IAC7D,4CAA4C,EAAE,eAAe;IAC7D,4CAA4C,EAAE,mBAAmB;IACjE,4CAA4C,EAAE,mBAAmB;CAClE,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,WAAW,EAAE,CAAC,CAAC,CAAC;AAE7B,SAAS,gBAAgB,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AM,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IAC7B,QAAQ,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IAC/B,2EAA2E;IAC3E,WAAW,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IAClC,sCAAsC;IACtC,KAAK,EAAE,CAAC,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC,QAAQ,EAAE;IACrC,OAAO,EAAE,yBAAyB,CAAC,QAAQ,EAAE;IAC7C,eAAe,EAAE,yBAAyB,CAAC,QAAQ,EAAE,CAAC,QAAQ,EAAE;IAChE,+EAA+E;IAC/E,QAAQ,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;CAChC,CAAC;KACD,MAAM,EAAE,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@withgordon/core",
3
- "version": "0.1.1",
3
+ "version": "0.1.2",
4
4
  "description": "Gordon SDK for policy-governed agent payments and x402 service settlement.",
5
5
  "type": "module",
6
6
  "main": "./dist/sdk/index.js",
@@ -36,7 +36,6 @@
36
36
  "test": "vitest run",
37
37
  "test:watch": "vitest",
38
38
  "typecheck": "tsc --noEmit",
39
- "evaluator:dev": "node --import tsx evaluator/index.ts",
40
39
  "platform:dev": "node --import tsx platform/index.ts",
41
40
  "worker:ledger:dev": "node --import tsx workers/index.ts",
42
41
  "db:init": "node --import tsx scripts/init-db.ts",
@@ -63,9 +62,9 @@
63
62
  "drizzle-orm": "^0.45.2",
64
63
  "express": "^5.2.1",
65
64
  "fast-jwt": "^6.2.4",
66
- "fastify": "^5.8.5",
67
65
  "ioredis": "^5.10.1",
68
66
  "nanoid": "^5.1.11",
69
- "pg": "^8.20.0"
67
+ "pg": "^8.20.0",
68
+ "zod": "^3.23.8"
70
69
  }
71
70
  }