@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.
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # @crediolabs/policy-builder-mcp
2
2
 
3
- MCP server exposing the OctoGate policy toolchain to agents. It wraps
3
+ MCP server exposing the OZ Policy Builder toolchain to agents. It wraps
4
4
  [`@crediolabs/policy-synth`](https://www.npmjs.com/package/@crediolabs/policy-synth):
5
5
  an agent records a Soroban transaction, synthesises the minimal policy that
6
6
  permits exactly that flow, verifies and simulates it, and receives an
@@ -54,8 +54,11 @@ branch on them.
54
54
  non-loopback host; it serves `127.0.0.1`, `::1` or `localhost` unless the
55
55
  embedding caller explicitly opts out (`allowExternalHost: true` via the
56
56
  programmatic API), because the surface is unauthenticated by design.
57
- - The on-chain interpreter the policies target is **unaudited**; see the
58
- [architecture document](https://github.com/untangledfinance/octogate/blob/main/docs/architecture.md).
57
+ - See the
58
+ [architecture document](https://github.com/untangledfinance/oz-policy-builder/blob/main/docs/architecture.md)
59
+ for what the on-chain interpreter does and does not enforce, and the
60
+ [repository README](https://github.com/untangledfinance/oz-policy-builder#readme)
61
+ for the contracts' audit status.
59
62
 
60
63
  ## License
61
64
 
@@ -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()`
@@ -20,14 +20,14 @@
20
20
  // `ZodEffects`, which has no `.shape`). They MUST stay in lockstep with
21
21
  // the strict schemas - a drift in field type or optionality breaks the
22
22
  // SDK's emitted JSON Schema.
23
- import { ComposeUserResponsesSchema, GetInterpreterInfoInputSchema, InstallPolicyInputSchema, InterpreterOptionsSchema, MandateSpecSchema, NetworkSchema, OraclePriceFixtureSchema, OzAdapterConfigSchema, PredicateNodeSchema, RecordedTransactionSchema, RecordTransactionInputSchema, RevokePolicyInputSchema, SimulatePolicyInputSchema, SynthesizePolicyInputSchema, ToolErrorSchema, VerifyPolicyInputSchema, } from '@crediolabs/policy-synth/run';
23
+ import { ComposeUserResponsesSchema, GetInterpreterInfoInputSchema, InstallPolicyInputSchema, InterpreterOptionsSchema, NetworkSchema, PredicateNodeSchema, RecordedTransactionSchema, RecordTransactionInputSchema, RevokePolicyInputSchema, SynthesizePolicyInputSchema, ToolErrorSchema, } from '@crediolabs/policy-synth/run';
24
24
  import { z } from 'zod';
25
25
  // Re-export the strict schemas so MCP package consumers (and existing tests)
26
26
  // still get them from this module. The canonical home is
27
27
  // `@crediolabs/policy-synth/run`; the re-exports here are a shim kept for
28
28
  // backward compatibility with downstream callers that imported from the MCP
29
29
  // package directly.
30
- export { ComposeUserResponsesSchema, GetInterpreterInfoInputSchema, InstallPolicyInputSchema, InterpreterOptionsSchema, MandateSpecSchema, NetworkSchema, OraclePriceFixtureSchema, OzAdapterConfigSchema, PredicateNodeSchema, RecordedTransactionSchema, RecordTransactionInputSchema, RevokePolicyInputSchema, SimulatePolicyInputSchema, SynthesizePolicyInputSchema, ToolErrorSchema, VerifyPolicyInputSchema, };
30
+ export { ComposeUserResponsesSchema, GetInterpreterInfoInputSchema, InstallPolicyInputSchema, InterpreterOptionsSchema, NetworkSchema, PredicateNodeSchema, RecordedTransactionSchema, RecordTransactionInputSchema, RevokePolicyInputSchema, SynthesizePolicyInputSchema, ToolErrorSchema, };
31
31
  /** Flat ZodRawShape used for the MCP SDK tool registration. The body
32
32
  * re-validates against `RecordTransactionInputSchema` so the mutual-exclusion
33
33
  * rule still fires (the SDK does not invoke `.refine()` at registration time). */
@@ -38,17 +38,15 @@ export const RecordTransactionToolShape = {
38
38
  confidenceOverride: z.number().min(0).max(1).optional(),
39
39
  };
40
40
  /** Flat ZodRawShape used for MCP tool registration. Every field is optional
41
- * so the JSON-Schema the SDK exposes to clients does not forbid either
42
- * front-end; the body re-validates against the discriminated union. */
41
+ * so the JSON-Schema the SDK exposes to clients stays permissive; the body
42
+ * re-validates against the strict schema. */
43
43
  export const SynthesizePolicyToolShape = {
44
- source: z.enum(['mandate', 'recording']).optional(),
45
- mandate: MandateSpecSchema.optional(),
44
+ source: z.literal('recording').optional(),
46
45
  recordedTx: RecordedTransactionSchema.optional(),
47
46
  network: NetworkSchema.optional(),
48
47
  userResponses: ComposeUserResponsesSchema.optional(),
49
48
  confidenceOverride: z.object({ threshold: z.number().min(0).max(1) }).optional(),
50
49
  interpreter: InterpreterOptionsSchema.optional(),
51
- ozConfig: OzAdapterConfigSchema.optional(),
52
50
  // Without this the tool chain has no join. A ProposedPolicy carries
53
51
  // `policyDocuments[].encodedPredicate` (canonical ScVal bytes), while
54
52
  // `simulate_policy` and `verify_policy` both want the PredicateNode TREE,
@@ -58,30 +56,16 @@ export const SynthesizePolicyToolShape = {
58
56
  // which skips the interpreter predicate entirely.
59
57
  explain: z.boolean().optional(),
60
58
  };
61
- /** Flat ZodRawShape for `simulate_policy`. The `predicate` is typed as
62
- * `z.unknown()` at the tool boundary because the recursive
63
- * `PredicateNodeSchema` is a `z.lazy()` union (the SDK does not accept
64
- * unions at the tool-registration boundary); the body re-validates
65
- * against `SimulatePolicyInputSchema`, which fails closed on a
66
- * malformed predicate. `predicate` is nullable here (vs required for
67
- * verify_policy) so the SDK-emitted JSON Schema mirrors the engine's
68
- * "OZ-only / no interpreter predicate" contract. */
69
- export const SimulatePolicyToolShape = {
70
- predicate: z.unknown().nullable().optional(),
59
+ /** `simulate_policy` and `verify_policy` share their input: the predicate tree
60
+ * (from `synthesize_policy` under `explain`) plus the recording it was
61
+ * synthesised from. */
62
+ const PolicyCheckToolShape = {
63
+ predicate: PredicateNodeSchema,
71
64
  permitTx: RecordedTransactionSchema,
72
65
  validUntilLedger: z.number().int().positive().optional(),
73
- oraclePricesByAsset: z.record(z.string(), OraclePriceFixtureSchema).optional(),
74
- };
75
- /** Flat ZodRawShape for `verify_policy`. Same `z.unknown()` boundary
76
- * trick for `predicate` as `SimulatePolicyToolShape`; `predicate` is
77
- * required at the strict-schema level (`VerifyPolicyInputSchema`) so
78
- * the body fails closed on a missing predicate. */
79
- export const VerifyPolicyToolShape = {
80
- predicate: z.unknown(),
81
- permitTx: RecordedTransactionSchema,
82
- validUntilLedger: z.number().int().positive().optional(),
83
- oraclePricesByAsset: z.record(z.string(), OraclePriceFixtureSchema).optional(),
84
66
  };
67
+ export const SimulatePolicyToolShape = { ...PolicyCheckToolShape };
68
+ export const VerifyPolicyToolShape = { ...PolicyCheckToolShape };
85
69
  /** Common base for `install_policy` and `revoke_policy`: smartAccount,
86
70
  * sourceAccount, optional RPC URL, optional base fee. Both share the
87
71
  * same smart-account context, so the SDK-emitted JSON Schema stays
@@ -29,9 +29,9 @@ export function createMcpServer() {
29
29
  /** Idempotent registration of the T1 tool set on the given server. */
30
30
  export function registerTools(server) {
31
31
  server.tool('record_transaction', 'Decode a Soroban transaction (on-chain hash OR base64 envelope XDR) into a RecordedTransaction. Returns a machine-readable ToolError on validation failure.', RecordTransactionToolShape, (args) => runRecordTransaction(args).then(toCallToolResult));
32
- server.tool('synthesize_policy', 'Synthesize a ProposedPolicy from either a deterministic MandateSpec (`source: mandate`) or a RecordedTransaction (`source: recording`). The discriminated `source` field selects the front-end.', SynthesizePolicyToolShape, (args) => runSynthesizePolicy(args).then(toCallToolResult));
33
- server.tool('simulate_policy', 'Replay a RecordedTransaction against a proposed PredicateNode (or null for an OZ-only policy) and emit the SimulationResult envelope (permit verdict + deny-case battery). Returns a SIMULATION_ERROR ToolError on runtime evaluation failure.', SimulatePolicyToolShape, (args) => runSimulatePolicy(args).then(toCallToolResult));
34
- server.tool('verify_policy', 'Run the static minimality check on a proposed PredicateNode against a RecordedTransaction (no conjunct is load-bearing-free). Returns VERIFICATION_FAILED with the dropped-constraint fingerprints when the predicate is over-broad.', VerifyPolicyToolShape, (args) => runVerifyPolicy(args).then(toCallToolResult));
32
+ server.tool('synthesize_policy', 'Synthesize a ProposedPolicy from a RecordedTransaction (`source: recording`).', SynthesizePolicyToolShape, (args) => runSynthesizePolicy(args).then(toCallToolResult));
33
+ server.tool('simulate_policy', 'Evaluate a predicate against one recorded call and report permit/deny with the deny reason. The evaluator is a second implementation of the on-chain semantics, cross-checked against the Rust interpreter by the conformance harness, so a verdict here is a claim about what the contract would do. Pass the `predicate` returned by `synthesize_policy` under `explain`.', SimulatePolicyToolShape, (args) => toCallToolResult(runSimulatePolicy(args)));
34
+ server.tool('verify_policy', 'Check a predicate against the transaction it was synthesised from, plus a generated deny case per dimension. Reports `ok` only when the permit case is permitted AND every deny case is denied - a denied permit case means the policy is too strict, a permitted deny case means it is too loose.', VerifyPolicyToolShape, (args) => toCallToolResult(runVerifyPolicy(args)));
35
35
  server.tool('install_policy', 'Build an UNSIGNED Soroban transaction XDR for `account.add_context_rule(...)` that installs a new policy rule on the given smart account. The wallet signs the returned XDR - the signature IS the user-confirmation step (this server is stateless and holds no key material, so there is no two-call confirm pair). Only CALL 1 is emitted; the interpreter `install` follow-up needs the rule id the account assigns in call 1 and is documented in `followUp` in the response.', InstallPolicyToolShape, (args) => runInstallPolicy(args).then(toCallToolResult));
36
36
  server.tool('revoke_policy', 'Build an UNSIGNED Soroban transaction XDR for `account.remove_context_rule(ruleId)` that removes a policy rule from the given smart account. The smart account handles uninstalling each attached policy itself. Auth is master-only - the source account MUST be the master signer set; delegated signers cannot uninstall.', RevokePolicyToolShape, (args) => runRevokePolicy(args).then(toCallToolResult));
37
37
  server.tool('get_interpreter_info', 'Read-only fingerprint lookup for the policy interpreter contract: returns the pinned address, grammar version, and wasm sha256 (from the pinned constants + SELF_VERSION). When `verifyLive=true`, performs an additional `grammar_version()` RPC call against the pinned address and reports whether the deployed contract matches the pin - a live mismatch check is more useful than a fabricated audit field.', GetInterpreterInfoToolShape, (args) => runGetInterpreterInfo(args).then(toCallToolResult));