@crediolabs/policy-builder-mcp 0.1.18 → 0.3.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.
@@ -2,8 +2,10 @@
2
2
  //
3
3
  // Streamable HTTP transport (hosted). Uses the Node http module directly so
4
4
  // the package stays thin - no express / hono dep. We run in STATELESS mode
5
- // (sessionIdGenerator: undefined) so each POST /mcp is its own transaction:
6
- // this matches the brief's "stateless across calls" invariant.
5
+ // (no sessionIdGenerator: the SDK disables session management when it is not
6
+ // provided) so each POST /mcp is its own transaction: this matches the
7
+ // brief's "stateless across calls" invariant. Stateless means a fresh server
8
+ // and transport per request - see the handler for why the SDK requires it.
7
9
  //
8
10
  // Single endpoint: POST /mcp (the SDK also accepts GET for SSE streaming, but
9
11
  // the T1 surface does not emit server-initiated messages so we omit it).
@@ -34,13 +36,6 @@ export async function startHttpServer(opts) {
34
36
  if (!LOOPBACK_HOSTS.has(host) && opts.allowExternalHost !== true) {
35
37
  throw new Error(`startHttpServer: refusing to bind host ${host}: the MCP surface is unauthenticated, so only loopback (127.0.0.1, ::1, localhost) is permitted by default. Pass \`allowExternalHost: true\` to opt in to a non-loopback bind.`);
36
38
  }
37
- const server = createMcpServer();
38
- // One transport per server (the SDK reuses the transport for every request
39
- // in stateless mode). We connect it once at startup and reuse it.
40
- const transport = new StreamableHTTPServerTransport({
41
- sessionIdGenerator: undefined,
42
- });
43
- await server.connect(transport);
44
39
  const httpServer = createServer(async (req, res) => {
45
40
  if (!req.url) {
46
41
  sendJson(res, 400, { error: 'missing url' });
@@ -86,7 +81,33 @@ export async function startHttpServer(opts) {
86
81
  });
87
82
  return;
88
83
  }
84
+ // A stateless transport handles exactly ONE request: the SDK refuses to
85
+ // reuse one ("Stateless transport cannot be reused across requests"),
86
+ // because a shared instance would let concurrent clients collide on
87
+ // JSON-RPC message ids. So the server and its transport are built here,
88
+ // per request, and torn down when the response closes.
89
+ // No `sessionIdGenerator`: the SDK disables session management when the
90
+ // option is absent, which is the stateless mode this surface wants.
91
+ // Passing an explicit `undefined` means the same thing to the SDK but is
92
+ // not assignable under `exactOptionalPropertyTypes`, so omission is both
93
+ // the type-correct and the documented spelling.
94
+ const server = createMcpServer();
95
+ const transport = new StreamableHTTPServerTransport();
96
+ // Registered before dispatch, not after: once the response has closed the
97
+ // event is gone, so a listener attached afterwards would never fire and
98
+ // the pair would leak.
99
+ res.on('close', () => {
100
+ void transport.close().catch(() => { });
101
+ void server.close().catch(() => { });
102
+ });
89
103
  try {
104
+ // The SDK declares `Transport.onclose` as an optional `() => void`, but
105
+ // exposes it on this class as an accessor pair typed `(() => void) |
106
+ // undefined`. Those are not assignable under `exactOptionalPropertyTypes`.
107
+ // The widening is upstream and structural only - the runtime object does
108
+ // satisfy `Transport` - so the assertion is narrowed to this one call
109
+ // rather than relaxing the compiler flag for the whole package.
110
+ await server.connect(transport);
90
111
  // `handleRequest` writes the response and returns once the message has
91
112
  // been dispatched. No shared state across calls in stateless mode.
92
113
  await transport.handleRequest(req, res, body);
@@ -119,10 +140,11 @@ export async function startHttpServer(opts) {
119
140
  port: opts.port,
120
141
  host,
121
142
  path,
143
+ // Nothing outlives a request, so closing the listener is the whole
144
+ // shutdown: each request's server and transport are already torn down by
145
+ // the `close` handler on its own response.
122
146
  close: async () => {
123
147
  await new Promise((resolve) => httpServer.close(() => resolve()));
124
- await transport.close().catch(() => { });
125
- await server.close().catch(() => { });
126
148
  },
127
149
  };
128
150
  }
@@ -1,6 +1,6 @@
1
- import { ComposeUserResponsesSchema, GetInterpreterInfoInputSchema, InstallPolicyInputSchema, InterpreterOptionsSchema, MandateSpecSchema, NetworkSchema, OraclePriceFixtureSchema, OzAdapterConfigSchema, PredicateNodeSchema, RecordedTransactionSchema, RecordTransactionInputSchema, RevokePolicyInputSchema, SimulatePolicyInputSchema, SynthesizePolicyInputSchema, ToolErrorSchema, VerifyPolicyInputSchema } from '@crediolabs/policy-synth/run';
1
+ import { ComposeUserResponsesSchema, GetInterpreterInfoInputSchema, InstallPolicyInputSchema, InterpreterOptionsSchema, NetworkSchema, PredicateNodeSchema, RecordedTransactionSchema, RecordTransactionInputSchema, RevokePolicyInputSchema, SynthesizePolicyInputSchema, ToolErrorSchema } from '@crediolabs/policy-synth/run';
2
2
  import { z } from 'zod';
3
- export { ComposeUserResponsesSchema, GetInterpreterInfoInputSchema, InstallPolicyInputSchema, InterpreterOptionsSchema, MandateSpecSchema, NetworkSchema, OraclePriceFixtureSchema, OzAdapterConfigSchema, PredicateNodeSchema, RecordedTransactionSchema, RecordTransactionInputSchema, RevokePolicyInputSchema, SimulatePolicyInputSchema, SynthesizePolicyInputSchema, ToolErrorSchema, VerifyPolicyInputSchema, };
3
+ export { ComposeUserResponsesSchema, GetInterpreterInfoInputSchema, InstallPolicyInputSchema, InterpreterOptionsSchema, NetworkSchema, PredicateNodeSchema, RecordedTransactionSchema, RecordTransactionInputSchema, RevokePolicyInputSchema, SynthesizePolicyInputSchema, ToolErrorSchema, };
4
4
  /** Flat ZodRawShape used for the MCP SDK tool registration. The body
5
5
  * re-validates against `RecordTransactionInputSchema` so the mutual-exclusion
6
6
  * rule still fires (the SDK does not invoke `.refine()` at registration time). */
@@ -11,156 +11,10 @@ export declare const RecordTransactionToolShape: {
11
11
  readonly confidenceOverride: z.ZodOptional<z.ZodNumber>;
12
12
  };
13
13
  /** Flat ZodRawShape used for MCP tool registration. Every field is optional
14
- * so the JSON-Schema the SDK exposes to clients does not forbid either
15
- * front-end; the body re-validates against the discriminated union. */
14
+ * so the JSON-Schema the SDK exposes to clients stays permissive; the body
15
+ * re-validates against the strict schema. */
16
16
  export declare const SynthesizePolicyToolShape: {
17
- readonly source: z.ZodOptional<z.ZodEnum<["mandate", "recording"]>>;
18
- readonly mandate: z.ZodOptional<z.ZodEffects<z.ZodObject<{
19
- chain: z.ZodLiteral<"stellar">;
20
- contract: z.ZodString;
21
- method: z.ZodOptional<z.ZodString>;
22
- spendingLimit: z.ZodOptional<z.ZodObject<{
23
- token: z.ZodString;
24
- limit: z.ZodString;
25
- windowSeconds: z.ZodNumber;
26
- }, "strip", z.ZodTypeAny, {
27
- token: string;
28
- limit: string;
29
- windowSeconds: number;
30
- }, {
31
- token: string;
32
- limit: string;
33
- windowSeconds: number;
34
- }>>;
35
- approvalThreshold: z.ZodOptional<z.ZodNumber>;
36
- recipients: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
37
- expiry: z.ZodOptional<z.ZodObject<{
38
- validUntilLedger: z.ZodOptional<z.ZodNumber>;
39
- validUntilUnixSeconds: z.ZodOptional<z.ZodNumber>;
40
- }, "strip", z.ZodTypeAny, {
41
- validUntilLedger?: number | undefined;
42
- validUntilUnixSeconds?: number | undefined;
43
- }, {
44
- validUntilLedger?: number | undefined;
45
- validUntilUnixSeconds?: number | undefined;
46
- }>>;
47
- }, "passthrough", z.ZodTypeAny, z.objectOutputType<{
48
- chain: z.ZodLiteral<"stellar">;
49
- contract: z.ZodString;
50
- method: z.ZodOptional<z.ZodString>;
51
- spendingLimit: z.ZodOptional<z.ZodObject<{
52
- token: z.ZodString;
53
- limit: z.ZodString;
54
- windowSeconds: z.ZodNumber;
55
- }, "strip", z.ZodTypeAny, {
56
- token: string;
57
- limit: string;
58
- windowSeconds: number;
59
- }, {
60
- token: string;
61
- limit: string;
62
- windowSeconds: number;
63
- }>>;
64
- approvalThreshold: z.ZodOptional<z.ZodNumber>;
65
- recipients: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
66
- expiry: z.ZodOptional<z.ZodObject<{
67
- validUntilLedger: z.ZodOptional<z.ZodNumber>;
68
- validUntilUnixSeconds: z.ZodOptional<z.ZodNumber>;
69
- }, "strip", z.ZodTypeAny, {
70
- validUntilLedger?: number | undefined;
71
- validUntilUnixSeconds?: number | undefined;
72
- }, {
73
- validUntilLedger?: number | undefined;
74
- validUntilUnixSeconds?: number | undefined;
75
- }>>;
76
- }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
77
- chain: z.ZodLiteral<"stellar">;
78
- contract: z.ZodString;
79
- method: z.ZodOptional<z.ZodString>;
80
- spendingLimit: z.ZodOptional<z.ZodObject<{
81
- token: z.ZodString;
82
- limit: z.ZodString;
83
- windowSeconds: z.ZodNumber;
84
- }, "strip", z.ZodTypeAny, {
85
- token: string;
86
- limit: string;
87
- windowSeconds: number;
88
- }, {
89
- token: string;
90
- limit: string;
91
- windowSeconds: number;
92
- }>>;
93
- approvalThreshold: z.ZodOptional<z.ZodNumber>;
94
- recipients: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
95
- expiry: z.ZodOptional<z.ZodObject<{
96
- validUntilLedger: z.ZodOptional<z.ZodNumber>;
97
- validUntilUnixSeconds: z.ZodOptional<z.ZodNumber>;
98
- }, "strip", z.ZodTypeAny, {
99
- validUntilLedger?: number | undefined;
100
- validUntilUnixSeconds?: number | undefined;
101
- }, {
102
- validUntilLedger?: number | undefined;
103
- validUntilUnixSeconds?: number | undefined;
104
- }>>;
105
- }, z.ZodTypeAny, "passthrough">>, z.objectOutputType<{
106
- chain: z.ZodLiteral<"stellar">;
107
- contract: z.ZodString;
108
- method: z.ZodOptional<z.ZodString>;
109
- spendingLimit: z.ZodOptional<z.ZodObject<{
110
- token: z.ZodString;
111
- limit: z.ZodString;
112
- windowSeconds: z.ZodNumber;
113
- }, "strip", z.ZodTypeAny, {
114
- token: string;
115
- limit: string;
116
- windowSeconds: number;
117
- }, {
118
- token: string;
119
- limit: string;
120
- windowSeconds: number;
121
- }>>;
122
- approvalThreshold: z.ZodOptional<z.ZodNumber>;
123
- recipients: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
124
- expiry: z.ZodOptional<z.ZodObject<{
125
- validUntilLedger: z.ZodOptional<z.ZodNumber>;
126
- validUntilUnixSeconds: z.ZodOptional<z.ZodNumber>;
127
- }, "strip", z.ZodTypeAny, {
128
- validUntilLedger?: number | undefined;
129
- validUntilUnixSeconds?: number | undefined;
130
- }, {
131
- validUntilLedger?: number | undefined;
132
- validUntilUnixSeconds?: number | undefined;
133
- }>>;
134
- }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
135
- chain: z.ZodLiteral<"stellar">;
136
- contract: z.ZodString;
137
- method: z.ZodOptional<z.ZodString>;
138
- spendingLimit: z.ZodOptional<z.ZodObject<{
139
- token: z.ZodString;
140
- limit: z.ZodString;
141
- windowSeconds: z.ZodNumber;
142
- }, "strip", z.ZodTypeAny, {
143
- token: string;
144
- limit: string;
145
- windowSeconds: number;
146
- }, {
147
- token: string;
148
- limit: string;
149
- windowSeconds: number;
150
- }>>;
151
- approvalThreshold: z.ZodOptional<z.ZodNumber>;
152
- recipients: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
153
- expiry: z.ZodOptional<z.ZodObject<{
154
- validUntilLedger: z.ZodOptional<z.ZodNumber>;
155
- validUntilUnixSeconds: z.ZodOptional<z.ZodNumber>;
156
- }, "strip", z.ZodTypeAny, {
157
- validUntilLedger?: number | undefined;
158
- validUntilUnixSeconds?: number | undefined;
159
- }, {
160
- validUntilLedger?: number | undefined;
161
- validUntilUnixSeconds?: number | undefined;
162
- }>>;
163
- }, z.ZodTypeAny, "passthrough">>>;
17
+ readonly source: z.ZodOptional<z.ZodLiteral<"recording">>;
164
18
  readonly recordedTx: z.ZodOptional<z.ZodObject<{
165
19
  network: z.ZodEnum<["mainnet", "testnet"]>;
166
20
  signers: z.ZodArray<z.ZodString, "many">;
@@ -171,15 +25,15 @@ export declare const SynthesizePolicyToolShape: {
171
25
  to: z.ZodString;
172
26
  amount: z.ZodString;
173
27
  }, "strip", z.ZodTypeAny, {
174
- amount: string;
175
- token: string;
176
28
  from: string;
177
29
  to: string;
178
- }, {
179
30
  amount: string;
180
31
  token: string;
32
+ }, {
181
33
  from: string;
182
34
  to: string;
35
+ amount: string;
36
+ token: string;
183
37
  }>, "many">;
184
38
  events: z.ZodArray<z.ZodObject<{
185
39
  contract: z.ZodString;
@@ -257,15 +111,15 @@ export declare const SynthesizePolicyToolShape: {
257
111
  to: z.ZodString;
258
112
  amount: z.ZodString;
259
113
  }, "strip", z.ZodTypeAny, {
260
- amount: string;
261
- token: string;
262
114
  from: string;
263
115
  to: string;
264
- }, {
265
116
  amount: string;
266
117
  token: string;
118
+ }, {
267
119
  from: string;
268
120
  to: string;
121
+ amount: string;
122
+ token: string;
269
123
  }>, "many">;
270
124
  events: z.ZodArray<z.ZodObject<{
271
125
  contract: z.ZodString;
@@ -343,15 +197,15 @@ export declare const SynthesizePolicyToolShape: {
343
197
  to: z.ZodString;
344
198
  amount: z.ZodString;
345
199
  }, "strip", z.ZodTypeAny, {
346
- amount: string;
347
- token: string;
348
200
  from: string;
349
201
  to: string;
350
- }, {
351
202
  amount: string;
352
203
  token: string;
204
+ }, {
353
205
  from: string;
354
206
  to: string;
207
+ amount: string;
208
+ token: string;
355
209
  }>, "many">;
356
210
  events: z.ZodArray<z.ZodObject<{
357
211
  contract: z.ZodString;
@@ -422,24 +276,18 @@ export declare const SynthesizePolicyToolShape: {
422
276
  }, z.ZodTypeAny, "passthrough">>>;
423
277
  readonly network: z.ZodOptional<z.ZodEnum<["mainnet", "testnet"]>>;
424
278
  readonly userResponses: z.ZodOptional<z.ZodObject<{
425
- windowSeconds: z.ZodOptional<z.ZodNumber>;
426
- validUntilLedger: z.ZodOptional<z.ZodNumber>;
427
- limitAmount: z.ZodOptional<z.ZodString>;
428
- invocationLimit: z.ZodOptional<z.ZodNumber>;
429
- swapRecipientAllowlist: z.ZodOptional<z.ZodArray<z.ZodEffects<z.ZodString, string, string>, "many">>;
430
- }, "passthrough", z.ZodTypeAny, z.objectOutputType<{
431
- windowSeconds: z.ZodOptional<z.ZodNumber>;
432
279
  validUntilLedger: z.ZodOptional<z.ZodNumber>;
433
280
  limitAmount: z.ZodOptional<z.ZodString>;
434
- invocationLimit: z.ZodOptional<z.ZodNumber>;
435
281
  swapRecipientAllowlist: z.ZodOptional<z.ZodArray<z.ZodEffects<z.ZodString, string, string>, "many">>;
436
- }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
437
- windowSeconds: z.ZodOptional<z.ZodNumber>;
438
- validUntilLedger: z.ZodOptional<z.ZodNumber>;
439
- limitAmount: z.ZodOptional<z.ZodString>;
440
- invocationLimit: z.ZodOptional<z.ZodNumber>;
441
- swapRecipientAllowlist: z.ZodOptional<z.ZodArray<z.ZodEffects<z.ZodString, string, string>, "many">>;
442
- }, z.ZodTypeAny, "passthrough">>>;
282
+ }, "strict", z.ZodTypeAny, {
283
+ limitAmount?: string | undefined;
284
+ validUntilLedger?: number | undefined;
285
+ swapRecipientAllowlist?: string[] | undefined;
286
+ }, {
287
+ limitAmount?: string | undefined;
288
+ validUntilLedger?: number | undefined;
289
+ swapRecipientAllowlist?: string[] | undefined;
290
+ }>>;
443
291
  readonly confidenceOverride: z.ZodOptional<z.ZodObject<{
444
292
  threshold: z.ZodNumber;
445
293
  }, "strip", z.ZodTypeAny, {
@@ -450,73 +298,17 @@ export declare const SynthesizePolicyToolShape: {
450
298
  readonly interpreter: z.ZodOptional<z.ZodObject<{
451
299
  smartAccountAddress: z.ZodString;
452
300
  installNonce: z.ZodOptional<z.ZodNumber>;
453
- oracleParams: z.ZodOptional<z.ZodObject<{
454
- maxStalenessSeconds: z.ZodOptional<z.ZodNumber>;
455
- maxDeviationBps: z.ZodOptional<z.ZodNumber>;
456
- }, "strip", z.ZodTypeAny, {
457
- maxStalenessSeconds?: number | undefined;
458
- maxDeviationBps?: number | undefined;
459
- }, {
460
- maxStalenessSeconds?: number | undefined;
461
- maxDeviationBps?: number | undefined;
462
- }>>;
463
301
  }, "strip", z.ZodTypeAny, {
464
302
  smartAccountAddress: string;
465
- oracleParams?: {
466
- maxStalenessSeconds?: number | undefined;
467
- maxDeviationBps?: number | undefined;
468
- } | undefined;
469
303
  installNonce?: number | undefined;
470
304
  }, {
471
305
  smartAccountAddress: string;
472
- oracleParams?: {
473
- maxStalenessSeconds?: number | undefined;
474
- maxDeviationBps?: number | undefined;
475
- } | undefined;
476
306
  installNonce?: number | undefined;
477
307
  }>>;
478
- readonly ozConfig: z.ZodOptional<z.ZodObject<{
479
- network: z.ZodEnum<["mainnet", "testnet"]>;
480
- instances: z.ZodObject<{
481
- spending_limit: z.ZodString;
482
- simple_threshold: z.ZodString;
483
- weighted_threshold: z.ZodString;
484
- }, "strip", z.ZodTypeAny, {
485
- spending_limit: string;
486
- simple_threshold: string;
487
- weighted_threshold: string;
488
- }, {
489
- spending_limit: string;
490
- simple_threshold: string;
491
- weighted_threshold: string;
492
- }>;
493
- }, "strip", z.ZodTypeAny, {
494
- network: "mainnet" | "testnet";
495
- instances: {
496
- spending_limit: string;
497
- simple_threshold: string;
498
- weighted_threshold: string;
499
- };
500
- }, {
501
- network: "mainnet" | "testnet";
502
- instances: {
503
- spending_limit: string;
504
- simple_threshold: string;
505
- weighted_threshold: string;
506
- };
507
- }>>;
508
308
  readonly explain: z.ZodOptional<z.ZodBoolean>;
509
309
  };
510
- /** Flat ZodRawShape for `simulate_policy`. The `predicate` is typed as
511
- * `z.unknown()` at the tool boundary because the recursive
512
- * `PredicateNodeSchema` is a `z.lazy()` union (the SDK does not accept
513
- * unions at the tool-registration boundary); the body re-validates
514
- * against `SimulatePolicyInputSchema`, which fails closed on a
515
- * malformed predicate. `predicate` is nullable here (vs required for
516
- * verify_policy) so the SDK-emitted JSON Schema mirrors the engine's
517
- * "OZ-only / no interpreter predicate" contract. */
518
310
  export declare const SimulatePolicyToolShape: {
519
- readonly predicate: z.ZodOptional<z.ZodNullable<z.ZodUnknown>>;
311
+ readonly predicate: z.ZodType<unknown, z.ZodTypeDef, unknown>;
520
312
  readonly permitTx: z.ZodObject<{
521
313
  network: z.ZodEnum<["mainnet", "testnet"]>;
522
314
  signers: z.ZodArray<z.ZodString, "many">;
@@ -527,15 +319,15 @@ export declare const SimulatePolicyToolShape: {
527
319
  to: z.ZodString;
528
320
  amount: z.ZodString;
529
321
  }, "strip", z.ZodTypeAny, {
530
- amount: string;
531
- token: string;
532
322
  from: string;
533
323
  to: string;
534
- }, {
535
324
  amount: string;
536
325
  token: string;
326
+ }, {
537
327
  from: string;
538
328
  to: string;
329
+ amount: string;
330
+ token: string;
539
331
  }>, "many">;
540
332
  events: z.ZodArray<z.ZodObject<{
541
333
  contract: z.ZodString;
@@ -613,15 +405,15 @@ export declare const SimulatePolicyToolShape: {
613
405
  to: z.ZodString;
614
406
  amount: z.ZodString;
615
407
  }, "strip", z.ZodTypeAny, {
616
- amount: string;
617
- token: string;
618
408
  from: string;
619
409
  to: string;
620
- }, {
621
410
  amount: string;
622
411
  token: string;
412
+ }, {
623
413
  from: string;
624
414
  to: string;
415
+ amount: string;
416
+ token: string;
625
417
  }>, "many">;
626
418
  events: z.ZodArray<z.ZodObject<{
627
419
  contract: z.ZodString;
@@ -699,15 +491,15 @@ export declare const SimulatePolicyToolShape: {
699
491
  to: z.ZodString;
700
492
  amount: z.ZodString;
701
493
  }, "strip", z.ZodTypeAny, {
702
- amount: string;
703
- token: string;
704
494
  from: string;
705
495
  to: string;
706
- }, {
707
496
  amount: string;
708
497
  token: string;
498
+ }, {
709
499
  from: string;
710
500
  to: string;
501
+ amount: string;
502
+ token: string;
711
503
  }>, "many">;
712
504
  events: z.ZodArray<z.ZodObject<{
713
505
  contract: z.ZodString;
@@ -777,29 +569,9 @@ export declare const SimulatePolicyToolShape: {
777
569
  sourceAccount: z.ZodString;
778
570
  }, z.ZodTypeAny, "passthrough">>;
779
571
  readonly validUntilLedger: z.ZodOptional<z.ZodNumber>;
780
- readonly oraclePricesByAsset: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<[z.ZodObject<{
781
- price: z.ZodString;
782
- timestampSeconds: z.ZodNumber;
783
- }, "strip", z.ZodTypeAny, {
784
- price: string;
785
- timestampSeconds: number;
786
- }, {
787
- price: string;
788
- timestampSeconds: number;
789
- }>, z.ZodObject<{
790
- error: z.ZodEnum<["stale", "missing", "deviation", "paused", "decimals", "fingerprint"]>;
791
- }, "strip", z.ZodTypeAny, {
792
- error: "stale" | "missing" | "deviation" | "paused" | "decimals" | "fingerprint";
793
- }, {
794
- error: "stale" | "missing" | "deviation" | "paused" | "decimals" | "fingerprint";
795
- }>]>>>;
796
572
  };
797
- /** Flat ZodRawShape for `verify_policy`. Same `z.unknown()` boundary
798
- * trick for `predicate` as `SimulatePolicyToolShape`; `predicate` is
799
- * required at the strict-schema level (`VerifyPolicyInputSchema`) so
800
- * the body fails closed on a missing predicate. */
801
573
  export declare const VerifyPolicyToolShape: {
802
- readonly predicate: z.ZodUnknown;
574
+ readonly predicate: z.ZodType<unknown, z.ZodTypeDef, unknown>;
803
575
  readonly permitTx: z.ZodObject<{
804
576
  network: z.ZodEnum<["mainnet", "testnet"]>;
805
577
  signers: z.ZodArray<z.ZodString, "many">;
@@ -810,15 +582,15 @@ export declare const VerifyPolicyToolShape: {
810
582
  to: z.ZodString;
811
583
  amount: z.ZodString;
812
584
  }, "strip", z.ZodTypeAny, {
813
- amount: string;
814
- token: string;
815
585
  from: string;
816
586
  to: string;
817
- }, {
818
587
  amount: string;
819
588
  token: string;
589
+ }, {
820
590
  from: string;
821
591
  to: string;
592
+ amount: string;
593
+ token: string;
822
594
  }>, "many">;
823
595
  events: z.ZodArray<z.ZodObject<{
824
596
  contract: z.ZodString;
@@ -896,15 +668,15 @@ export declare const VerifyPolicyToolShape: {
896
668
  to: z.ZodString;
897
669
  amount: z.ZodString;
898
670
  }, "strip", z.ZodTypeAny, {
899
- amount: string;
900
- token: string;
901
671
  from: string;
902
672
  to: string;
903
- }, {
904
673
  amount: string;
905
674
  token: string;
675
+ }, {
906
676
  from: string;
907
677
  to: string;
678
+ amount: string;
679
+ token: string;
908
680
  }>, "many">;
909
681
  events: z.ZodArray<z.ZodObject<{
910
682
  contract: z.ZodString;
@@ -982,15 +754,15 @@ export declare const VerifyPolicyToolShape: {
982
754
  to: z.ZodString;
983
755
  amount: z.ZodString;
984
756
  }, "strip", z.ZodTypeAny, {
985
- amount: string;
986
- token: string;
987
757
  from: string;
988
758
  to: string;
989
- }, {
990
759
  amount: string;
991
760
  token: string;
761
+ }, {
992
762
  from: string;
993
763
  to: string;
764
+ amount: string;
765
+ token: string;
994
766
  }>, "many">;
995
767
  events: z.ZodArray<z.ZodObject<{
996
768
  contract: z.ZodString;
@@ -1060,22 +832,6 @@ export declare const VerifyPolicyToolShape: {
1060
832
  sourceAccount: z.ZodString;
1061
833
  }, z.ZodTypeAny, "passthrough">>;
1062
834
  readonly validUntilLedger: z.ZodOptional<z.ZodNumber>;
1063
- readonly oraclePricesByAsset: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<[z.ZodObject<{
1064
- price: z.ZodString;
1065
- timestampSeconds: z.ZodNumber;
1066
- }, "strip", z.ZodTypeAny, {
1067
- price: string;
1068
- timestampSeconds: number;
1069
- }, {
1070
- price: string;
1071
- timestampSeconds: number;
1072
- }>, z.ZodObject<{
1073
- error: z.ZodEnum<["stale", "missing", "deviation", "paused", "decimals", "fingerprint"]>;
1074
- }, "strip", z.ZodTypeAny, {
1075
- error: "stale" | "missing" | "deviation" | "paused" | "decimals" | "fingerprint";
1076
- }, {
1077
- error: "stale" | "missing" | "deviation" | "paused" | "decimals" | "fingerprint";
1078
- }>]>>>;
1079
835
  };
1080
836
  export type { GetInterpreterInfoInput, InstallPolicyInput, RevokePolicyInput, SimulatePolicyInput, VerifyPolicyInput, } from '@crediolabs/policy-synth/run';
1081
837
  /** Flat ZodRawShape for `install_policy`. `rule` is typed as `z.unknown()`
@@ -22,24 +22,19 @@
22
22
  // the strict schemas - a drift in field type or optionality breaks the
23
23
  // SDK's emitted JSON Schema.
24
24
  Object.defineProperty(exports, "__esModule", { value: true });
25
- exports.GetInterpreterInfoToolShape = exports.RevokePolicyToolShape = exports.InstallPolicyToolShape = exports.VerifyPolicyToolShape = exports.SimulatePolicyToolShape = exports.SynthesizePolicyToolShape = exports.RecordTransactionToolShape = exports.VerifyPolicyInputSchema = exports.ToolErrorSchema = exports.SynthesizePolicyInputSchema = exports.SimulatePolicyInputSchema = exports.RevokePolicyInputSchema = exports.RecordTransactionInputSchema = exports.RecordedTransactionSchema = exports.PredicateNodeSchema = exports.OzAdapterConfigSchema = exports.OraclePriceFixtureSchema = exports.NetworkSchema = exports.MandateSpecSchema = exports.InterpreterOptionsSchema = exports.InstallPolicyInputSchema = exports.GetInterpreterInfoInputSchema = exports.ComposeUserResponsesSchema = void 0;
25
+ exports.GetInterpreterInfoToolShape = exports.RevokePolicyToolShape = exports.InstallPolicyToolShape = exports.VerifyPolicyToolShape = exports.SimulatePolicyToolShape = exports.SynthesizePolicyToolShape = exports.RecordTransactionToolShape = exports.ToolErrorSchema = exports.SynthesizePolicyInputSchema = exports.RevokePolicyInputSchema = exports.RecordTransactionInputSchema = exports.RecordedTransactionSchema = exports.PredicateNodeSchema = exports.NetworkSchema = exports.InterpreterOptionsSchema = exports.InstallPolicyInputSchema = exports.GetInterpreterInfoInputSchema = exports.ComposeUserResponsesSchema = void 0;
26
26
  const run_1 = require("@crediolabs/policy-synth/run");
27
27
  Object.defineProperty(exports, "ComposeUserResponsesSchema", { enumerable: true, get: function () { return run_1.ComposeUserResponsesSchema; } });
28
28
  Object.defineProperty(exports, "GetInterpreterInfoInputSchema", { enumerable: true, get: function () { return run_1.GetInterpreterInfoInputSchema; } });
29
29
  Object.defineProperty(exports, "InstallPolicyInputSchema", { enumerable: true, get: function () { return run_1.InstallPolicyInputSchema; } });
30
30
  Object.defineProperty(exports, "InterpreterOptionsSchema", { enumerable: true, get: function () { return run_1.InterpreterOptionsSchema; } });
31
- Object.defineProperty(exports, "MandateSpecSchema", { enumerable: true, get: function () { return run_1.MandateSpecSchema; } });
32
31
  Object.defineProperty(exports, "NetworkSchema", { enumerable: true, get: function () { return run_1.NetworkSchema; } });
33
- Object.defineProperty(exports, "OraclePriceFixtureSchema", { enumerable: true, get: function () { return run_1.OraclePriceFixtureSchema; } });
34
- Object.defineProperty(exports, "OzAdapterConfigSchema", { enumerable: true, get: function () { return run_1.OzAdapterConfigSchema; } });
35
32
  Object.defineProperty(exports, "PredicateNodeSchema", { enumerable: true, get: function () { return run_1.PredicateNodeSchema; } });
36
33
  Object.defineProperty(exports, "RecordedTransactionSchema", { enumerable: true, get: function () { return run_1.RecordedTransactionSchema; } });
37
34
  Object.defineProperty(exports, "RecordTransactionInputSchema", { enumerable: true, get: function () { return run_1.RecordTransactionInputSchema; } });
38
35
  Object.defineProperty(exports, "RevokePolicyInputSchema", { enumerable: true, get: function () { return run_1.RevokePolicyInputSchema; } });
39
- Object.defineProperty(exports, "SimulatePolicyInputSchema", { enumerable: true, get: function () { return run_1.SimulatePolicyInputSchema; } });
40
36
  Object.defineProperty(exports, "SynthesizePolicyInputSchema", { enumerable: true, get: function () { return run_1.SynthesizePolicyInputSchema; } });
41
37
  Object.defineProperty(exports, "ToolErrorSchema", { enumerable: true, get: function () { return run_1.ToolErrorSchema; } });
42
- Object.defineProperty(exports, "VerifyPolicyInputSchema", { enumerable: true, get: function () { return run_1.VerifyPolicyInputSchema; } });
43
38
  const zod_1 = require("zod");
44
39
  /** Flat ZodRawShape used for the MCP SDK tool registration. The body
45
40
  * re-validates against `RecordTransactionInputSchema` so the mutual-exclusion
@@ -51,17 +46,15 @@ exports.RecordTransactionToolShape = {
51
46
  confidenceOverride: zod_1.z.number().min(0).max(1).optional(),
52
47
  };
53
48
  /** Flat ZodRawShape used for MCP tool registration. Every field is optional
54
- * so the JSON-Schema the SDK exposes to clients does not forbid either
55
- * front-end; the body re-validates against the discriminated union. */
49
+ * so the JSON-Schema the SDK exposes to clients stays permissive; the body
50
+ * re-validates against the strict schema. */
56
51
  exports.SynthesizePolicyToolShape = {
57
- source: zod_1.z.enum(['mandate', 'recording']).optional(),
58
- mandate: run_1.MandateSpecSchema.optional(),
52
+ source: zod_1.z.literal('recording').optional(),
59
53
  recordedTx: run_1.RecordedTransactionSchema.optional(),
60
54
  network: run_1.NetworkSchema.optional(),
61
55
  userResponses: run_1.ComposeUserResponsesSchema.optional(),
62
56
  confidenceOverride: zod_1.z.object({ threshold: zod_1.z.number().min(0).max(1) }).optional(),
63
57
  interpreter: run_1.InterpreterOptionsSchema.optional(),
64
- ozConfig: run_1.OzAdapterConfigSchema.optional(),
65
58
  // Without this the tool chain has no join. A ProposedPolicy carries
66
59
  // `policyDocuments[].encodedPredicate` (canonical ScVal bytes), while
67
60
  // `simulate_policy` and `verify_policy` both want the PredicateNode TREE,
@@ -71,30 +64,16 @@ exports.SynthesizePolicyToolShape = {
71
64
  // which skips the interpreter predicate entirely.
72
65
  explain: zod_1.z.boolean().optional(),
73
66
  };
74
- /** Flat ZodRawShape for `simulate_policy`. The `predicate` is typed as
75
- * `z.unknown()` at the tool boundary because the recursive
76
- * `PredicateNodeSchema` is a `z.lazy()` union (the SDK does not accept
77
- * unions at the tool-registration boundary); the body re-validates
78
- * against `SimulatePolicyInputSchema`, which fails closed on a
79
- * malformed predicate. `predicate` is nullable here (vs required for
80
- * verify_policy) so the SDK-emitted JSON Schema mirrors the engine's
81
- * "OZ-only / no interpreter predicate" contract. */
82
- exports.SimulatePolicyToolShape = {
83
- predicate: zod_1.z.unknown().nullable().optional(),
67
+ /** `simulate_policy` and `verify_policy` share their input: the predicate tree
68
+ * (from `synthesize_policy` under `explain`) plus the recording it was
69
+ * synthesised from. */
70
+ const PolicyCheckToolShape = {
71
+ predicate: run_1.PredicateNodeSchema,
84
72
  permitTx: run_1.RecordedTransactionSchema,
85
73
  validUntilLedger: zod_1.z.number().int().positive().optional(),
86
- oraclePricesByAsset: zod_1.z.record(zod_1.z.string(), run_1.OraclePriceFixtureSchema).optional(),
87
- };
88
- /** Flat ZodRawShape for `verify_policy`. Same `z.unknown()` boundary
89
- * trick for `predicate` as `SimulatePolicyToolShape`; `predicate` is
90
- * required at the strict-schema level (`VerifyPolicyInputSchema`) so
91
- * the body fails closed on a missing predicate. */
92
- exports.VerifyPolicyToolShape = {
93
- predicate: zod_1.z.unknown(),
94
- permitTx: run_1.RecordedTransactionSchema,
95
- validUntilLedger: zod_1.z.number().int().positive().optional(),
96
- oraclePricesByAsset: zod_1.z.record(zod_1.z.string(), run_1.OraclePriceFixtureSchema).optional(),
97
74
  };
75
+ exports.SimulatePolicyToolShape = { ...PolicyCheckToolShape };
76
+ exports.VerifyPolicyToolShape = { ...PolicyCheckToolShape };
98
77
  /** Common base for `install_policy` and `revoke_policy`: smartAccount,
99
78
  * sourceAccount, optional RPC URL, optional base fee. Both share the
100
79
  * same smart-account context, so the SDK-emitted JSON Schema stays