@wowok/agent-mcp 2.3.18 → 2.4.3

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.
Files changed (121) hide show
  1. package/dist/customer/industry-risks.js +31 -31
  2. package/dist/customer/order-monitor.js +57 -57
  3. package/dist/customer/order-strategy.js +89 -89
  4. package/dist/customer/post-purchase.js +97 -97
  5. package/dist/customer/reminder-system.js +26 -26
  6. package/dist/customer/risk-assessment.js +46 -46
  7. package/dist/customer/types.d.ts +4 -4
  8. package/dist/customer/types.js +4 -4
  9. package/dist/customer/user-preferences.js +50 -50
  10. package/dist/experience/intent-distill.js +6 -6
  11. package/dist/index.d.ts +2 -2
  12. package/dist/index.js +11 -1624
  13. package/dist/knowledge/acquisition-flywheel.js +64 -64
  14. package/dist/knowledge/arbitration-trust.js +10 -10
  15. package/dist/knowledge/demand-matching.js +8 -8
  16. package/dist/knowledge/dynamic-pricing.js +18 -18
  17. package/dist/knowledge/flywheel-loop.js +11 -11
  18. package/dist/knowledge/glossary.js +22 -22
  19. package/dist/knowledge/guard-ledger.d.ts +1 -1
  20. package/dist/knowledge/guard-ledger.js +145 -104
  21. package/dist/knowledge/guard-lint.d.ts +77 -0
  22. package/dist/knowledge/guard-lint.js +670 -0
  23. package/dist/knowledge/guard-migration.d.ts +48 -0
  24. package/dist/knowledge/guard-migration.js +228 -0
  25. package/dist/knowledge/guard-puzzle.d.ts +109 -14
  26. package/dist/knowledge/guard-puzzle.js +627 -101
  27. package/dist/knowledge/guard-risk.d.ts +10 -1
  28. package/dist/knowledge/guard-risk.js +1634 -292
  29. package/dist/knowledge/guard-templates.d.ts +38 -0
  30. package/dist/knowledge/guard-templates.js +605 -0
  31. package/dist/knowledge/guard-translation.d.ts +14 -2
  32. package/dist/knowledge/guard-translation.js +825 -194
  33. package/dist/knowledge/index.d.ts +8 -4
  34. package/dist/knowledge/index.js +9 -5
  35. package/dist/knowledge/industry-evolution.js +29 -29
  36. package/dist/knowledge/industry-generalizer.js +52 -52
  37. package/dist/knowledge/industry-registry.js +20 -33
  38. package/dist/knowledge/intent-metrics.js +67 -67
  39. package/dist/knowledge/process-model.js +80 -80
  40. package/dist/knowledge/reputation-rules.js +9 -9
  41. package/dist/knowledge/reward-templates.js +51 -51
  42. package/dist/knowledge/safety-rules.js +3 -3
  43. package/dist/knowledge/tool-constraints.js +20 -4
  44. package/dist/knowledge/trust-metrics.js +26 -26
  45. package/dist/project/graph.d.ts +1 -0
  46. package/dist/project/graph.js +27 -1
  47. package/dist/project/index.d.ts +1 -0
  48. package/dist/project/index.js +39 -2
  49. package/dist/project/namespace.d.ts +11 -1
  50. package/dist/project/namespace.js +27 -2
  51. package/dist/project/query.d.ts +2 -0
  52. package/dist/project/query.js +56 -15
  53. package/dist/rules.d.ts +12 -0
  54. package/dist/rules.js +9 -0
  55. package/dist/schema/call/allocation.d.ts +10 -10
  56. package/dist/schema/call/base.js +19 -19
  57. package/dist/schema/call/bridge.d.ts +32 -32
  58. package/dist/schema/call/demand.d.ts +84 -84
  59. package/dist/schema/call/guard.d.ts +153 -0
  60. package/dist/schema/call/guard.js +50 -0
  61. package/dist/schema/call/machine.d.ts +38 -38
  62. package/dist/schema/call/permission.d.ts +78 -78
  63. package/dist/schema/call/repository.d.ts +22 -22
  64. package/dist/schema/call/semantic.js +229 -25
  65. package/dist/schema/call/service.d.ts +7 -7
  66. package/dist/schema/local/wip.d.ts +39 -19
  67. package/dist/schema/local/wip.js +5 -5
  68. package/dist/schema/messenger/index.d.ts +26 -26
  69. package/dist/schema/messenger/index.js +2 -2
  70. package/dist/schema/operations.d.ts +270 -192
  71. package/dist/schema/query/index.d.ts +184 -184
  72. package/dist/schema/query/index.js +15 -9
  73. package/dist/schema/trust/index.d.ts +4 -4
  74. package/dist/schema/utils/guard-parser.js +4 -4
  75. package/dist/schema/utils/guard-query-utils.d.ts +7 -0
  76. package/dist/schema/utils/guard-query-utils.js +14 -1
  77. package/dist/schema/utils/node-parser.js +14 -14
  78. package/dist/schemas/bridge_operation.output.json +15 -15
  79. package/dist/schemas/index.json +1 -1
  80. package/dist/schemas/messenger_operation.output.json +18 -16
  81. package/dist/schemas/onchain_events.output.json +15 -15
  82. package/dist/schemas/onchain_operations.output.json +16 -16
  83. package/dist/schemas/onchain_operations.schema.json +11 -20
  84. package/dist/schemas/onchain_operations_allocation.schema.json +7 -10
  85. package/dist/schemas/onchain_operations_machine.schema.json +2 -5
  86. package/dist/schemas/onchain_operations_service.schema.json +2 -5
  87. package/dist/schemas/onchain_table_data.output.json +20 -26
  88. package/dist/schemas/wip_file.output.json +24 -1
  89. package/dist/tools/handlers/bridge.d.ts +1 -0
  90. package/dist/tools/handlers/bridge.js +1 -0
  91. package/dist/tools/handlers/config.d.ts +2 -0
  92. package/dist/tools/handlers/config.js +71 -0
  93. package/dist/tools/handlers/file-export.d.ts +3 -0
  94. package/dist/tools/handlers/file-export.js +90 -0
  95. package/dist/tools/handlers/local.d.ts +30 -0
  96. package/dist/tools/handlers/local.js +27 -0
  97. package/dist/tools/handlers/messenger.d.ts +16 -0
  98. package/dist/tools/handlers/messenger.js +187 -0
  99. package/dist/tools/handlers/onchain.d.ts +2 -0
  100. package/dist/tools/handlers/onchain.js +246 -0
  101. package/dist/tools/handlers/project.d.ts +2 -0
  102. package/dist/tools/handlers/project.js +53 -0
  103. package/dist/tools/handlers/query.d.ts +5 -0
  104. package/dist/tools/handlers/query.js +256 -0
  105. package/dist/tools/handlers/schema-query.d.ts +2 -0
  106. package/dist/tools/handlers/schema-query.js +92 -0
  107. package/dist/tools/handlers/trust.d.ts +2 -0
  108. package/dist/tools/handlers/trust.js +194 -0
  109. package/dist/tools/handlers/wip.d.ts +2 -0
  110. package/dist/tools/handlers/wip.js +44 -0
  111. package/dist/tools/index.d.ts +13 -0
  112. package/dist/tools/index.js +479 -0
  113. package/dist/tools/rules-hook.d.ts +2 -0
  114. package/dist/tools/rules-hook.js +22 -0
  115. package/dist/tools/shared.d.ts +29 -0
  116. package/dist/tools/shared.js +130 -0
  117. package/dist/tools/types.d.ts +35 -0
  118. package/dist/tools/types.js +1 -0
  119. package/dist/tools/wrap.d.ts +6 -0
  120. package/dist/tools/wrap.js +55 -0
  121. package/package.json +19 -5
@@ -257,7 +257,7 @@ export declare const PoliciesAddSetSchema: z.ZodObject<{
257
257
  id_from_submission?: number | undefined;
258
258
  data_from_submission?: number | undefined;
259
259
  }[];
260
- id_from: 0 | 1 | 2 | "none" | "Signer" | "Clock" | "signer" | "None" | "clock";
260
+ id_from: 0 | 1 | 2 | "none" | "Signer" | "Clock" | "signer" | "clock" | "None";
261
261
  quote_guard?: string | null | undefined;
262
262
  }, {
263
263
  value_type: "string" | "Bool" | "Address" | "String" | "U8" | "U16" | "U32" | "U64" | "U128" | "U256" | "VecBool" | "VecAddress" | "VecString" | "VecU8" | "VecU16" | "VecU32" | "VecU64" | "VecU128" | "VecU256" | "VecVecU8" | import("@wowok/wowok").ValueType | "bool" | "address" | "u8" | "u16" | "u32" | "u64" | "u128" | "u256" | "vecbool" | "vecaddress" | "vecstring" | "vecu8" | "vecu16" | "vecu32" | "vecu64" | "vecu128" | "vecu256" | "vecvecu8" | "Value";
@@ -268,7 +268,7 @@ export declare const PoliciesAddSetSchema: z.ZodObject<{
268
268
  id_from_submission?: number | undefined;
269
269
  data_from_submission?: number | undefined;
270
270
  }[];
271
- id_from: 0 | 1 | 2 | "none" | "Signer" | "Clock" | "signer" | "None" | "clock";
271
+ id_from: 0 | 1 | 2 | "none" | "Signer" | "Clock" | "signer" | "clock" | "None";
272
272
  quote_guard?: string | null | undefined;
273
273
  }>, "many">;
274
274
  }, "strict", z.ZodTypeAny, {
@@ -282,7 +282,7 @@ export declare const PoliciesAddSetSchema: z.ZodObject<{
282
282
  id_from_submission?: number | undefined;
283
283
  data_from_submission?: number | undefined;
284
284
  }[];
285
- id_from: 0 | 1 | 2 | "none" | "Signer" | "Clock" | "signer" | "None" | "clock";
285
+ id_from: 0 | 1 | 2 | "none" | "Signer" | "Clock" | "signer" | "clock" | "None";
286
286
  quote_guard?: string | null | undefined;
287
287
  }[];
288
288
  }, {
@@ -296,7 +296,7 @@ export declare const PoliciesAddSetSchema: z.ZodObject<{
296
296
  id_from_submission?: number | undefined;
297
297
  data_from_submission?: number | undefined;
298
298
  }[];
299
- id_from: 0 | 1 | 2 | "none" | "Signer" | "Clock" | "signer" | "None" | "clock";
299
+ id_from: 0 | 1 | 2 | "none" | "Signer" | "Clock" | "signer" | "clock" | "None";
300
300
  quote_guard?: string | null | undefined;
301
301
  }[];
302
302
  }>;
@@ -347,7 +347,7 @@ export declare const PoliciesSchema: z.ZodDiscriminatedUnion<"op", [z.ZodObject<
347
347
  id_from_submission?: number | undefined;
348
348
  data_from_submission?: number | undefined;
349
349
  }[];
350
- id_from: 0 | 1 | 2 | "none" | "Signer" | "Clock" | "signer" | "None" | "clock";
350
+ id_from: 0 | 1 | 2 | "none" | "Signer" | "Clock" | "signer" | "clock" | "None";
351
351
  quote_guard?: string | null | undefined;
352
352
  }, {
353
353
  value_type: "string" | "Bool" | "Address" | "String" | "U8" | "U16" | "U32" | "U64" | "U128" | "U256" | "VecBool" | "VecAddress" | "VecString" | "VecU8" | "VecU16" | "VecU32" | "VecU64" | "VecU128" | "VecU256" | "VecVecU8" | import("@wowok/wowok").ValueType | "bool" | "address" | "u8" | "u16" | "u32" | "u64" | "u128" | "u256" | "vecbool" | "vecaddress" | "vecstring" | "vecu8" | "vecu16" | "vecu32" | "vecu64" | "vecu128" | "vecu256" | "vecvecu8" | "Value";
@@ -358,7 +358,7 @@ export declare const PoliciesSchema: z.ZodDiscriminatedUnion<"op", [z.ZodObject<
358
358
  id_from_submission?: number | undefined;
359
359
  data_from_submission?: number | undefined;
360
360
  }[];
361
- id_from: 0 | 1 | 2 | "none" | "Signer" | "Clock" | "signer" | "None" | "clock";
361
+ id_from: 0 | 1 | 2 | "none" | "Signer" | "Clock" | "signer" | "clock" | "None";
362
362
  quote_guard?: string | null | undefined;
363
363
  }>, "many">;
364
364
  }, "strict", z.ZodTypeAny, {
@@ -372,7 +372,7 @@ export declare const PoliciesSchema: z.ZodDiscriminatedUnion<"op", [z.ZodObject<
372
372
  id_from_submission?: number | undefined;
373
373
  data_from_submission?: number | undefined;
374
374
  }[];
375
- id_from: 0 | 1 | 2 | "none" | "Signer" | "Clock" | "signer" | "None" | "clock";
375
+ id_from: 0 | 1 | 2 | "none" | "Signer" | "Clock" | "signer" | "clock" | "None";
376
376
  quote_guard?: string | null | undefined;
377
377
  }[];
378
378
  }, {
@@ -386,7 +386,7 @@ export declare const PoliciesSchema: z.ZodDiscriminatedUnion<"op", [z.ZodObject<
386
386
  id_from_submission?: number | undefined;
387
387
  data_from_submission?: number | undefined;
388
388
  }[];
389
- id_from: 0 | 1 | 2 | "none" | "Signer" | "Clock" | "signer" | "None" | "clock";
389
+ id_from: 0 | 1 | 2 | "none" | "Signer" | "Clock" | "signer" | "clock" | "None";
390
390
  quote_guard?: string | null | undefined;
391
391
  }[];
392
392
  }>, z.ZodObject<{
@@ -800,7 +800,7 @@ export declare const CallRepository_DataSchema: z.ZodObject<{
800
800
  id_from_submission?: number | undefined;
801
801
  data_from_submission?: number | undefined;
802
802
  }[];
803
- id_from: 0 | 1 | 2 | "none" | "Signer" | "Clock" | "signer" | "None" | "clock";
803
+ id_from: 0 | 1 | 2 | "none" | "Signer" | "Clock" | "signer" | "clock" | "None";
804
804
  quote_guard?: string | null | undefined;
805
805
  }, {
806
806
  value_type: "string" | "Bool" | "Address" | "String" | "U8" | "U16" | "U32" | "U64" | "U128" | "U256" | "VecBool" | "VecAddress" | "VecString" | "VecU8" | "VecU16" | "VecU32" | "VecU64" | "VecU128" | "VecU256" | "VecVecU8" | import("@wowok/wowok").ValueType | "bool" | "address" | "u8" | "u16" | "u32" | "u64" | "u128" | "u256" | "vecbool" | "vecaddress" | "vecstring" | "vecu8" | "vecu16" | "vecu32" | "vecu64" | "vecu128" | "vecu256" | "vecvecu8" | "Value";
@@ -811,7 +811,7 @@ export declare const CallRepository_DataSchema: z.ZodObject<{
811
811
  id_from_submission?: number | undefined;
812
812
  data_from_submission?: number | undefined;
813
813
  }[];
814
- id_from: 0 | 1 | 2 | "none" | "Signer" | "Clock" | "signer" | "None" | "clock";
814
+ id_from: 0 | 1 | 2 | "none" | "Signer" | "Clock" | "signer" | "clock" | "None";
815
815
  quote_guard?: string | null | undefined;
816
816
  }>, "many">;
817
817
  }, "strict", z.ZodTypeAny, {
@@ -825,7 +825,7 @@ export declare const CallRepository_DataSchema: z.ZodObject<{
825
825
  id_from_submission?: number | undefined;
826
826
  data_from_submission?: number | undefined;
827
827
  }[];
828
- id_from: 0 | 1 | 2 | "none" | "Signer" | "Clock" | "signer" | "None" | "clock";
828
+ id_from: 0 | 1 | 2 | "none" | "Signer" | "Clock" | "signer" | "clock" | "None";
829
829
  quote_guard?: string | null | undefined;
830
830
  }[];
831
831
  }, {
@@ -839,7 +839,7 @@ export declare const CallRepository_DataSchema: z.ZodObject<{
839
839
  id_from_submission?: number | undefined;
840
840
  data_from_submission?: number | undefined;
841
841
  }[];
842
- id_from: 0 | 1 | 2 | "none" | "Signer" | "Clock" | "signer" | "None" | "clock";
842
+ id_from: 0 | 1 | 2 | "none" | "Signer" | "Clock" | "signer" | "clock" | "None";
843
843
  quote_guard?: string | null | undefined;
844
844
  }[];
845
845
  }>, z.ZodObject<{
@@ -1184,7 +1184,7 @@ export declare const CallRepository_DataSchema: z.ZodObject<{
1184
1184
  id_from_submission?: number | undefined;
1185
1185
  data_from_submission?: number | undefined;
1186
1186
  }[];
1187
- id_from: 0 | 1 | 2 | "none" | "Signer" | "Clock" | "signer" | "None" | "clock";
1187
+ id_from: 0 | 1 | 2 | "none" | "Signer" | "Clock" | "signer" | "clock" | "None";
1188
1188
  quote_guard?: string | null | undefined;
1189
1189
  }[];
1190
1190
  } | {
@@ -1272,7 +1272,7 @@ export declare const CallRepository_DataSchema: z.ZodObject<{
1272
1272
  id_from_submission?: number | undefined;
1273
1273
  data_from_submission?: number | undefined;
1274
1274
  }[];
1275
- id_from: 0 | 1 | 2 | "none" | "Signer" | "Clock" | "signer" | "None" | "clock";
1275
+ id_from: 0 | 1 | 2 | "none" | "Signer" | "Clock" | "signer" | "clock" | "None";
1276
1276
  quote_guard?: string | null | undefined;
1277
1277
  }[];
1278
1278
  } | {
@@ -1396,7 +1396,7 @@ export declare const CallRepository_InputSchema: z.ZodObject<{
1396
1396
  id_from_submission?: number | undefined;
1397
1397
  data_from_submission?: number | undefined;
1398
1398
  }[];
1399
- id_from: 0 | 1 | 2 | "none" | "Signer" | "Clock" | "signer" | "None" | "clock";
1399
+ id_from: 0 | 1 | 2 | "none" | "Signer" | "Clock" | "signer" | "clock" | "None";
1400
1400
  quote_guard?: string | null | undefined;
1401
1401
  }, {
1402
1402
  value_type: "string" | "Bool" | "Address" | "String" | "U8" | "U16" | "U32" | "U64" | "U128" | "U256" | "VecBool" | "VecAddress" | "VecString" | "VecU8" | "VecU16" | "VecU32" | "VecU64" | "VecU128" | "VecU256" | "VecVecU8" | import("@wowok/wowok").ValueType | "bool" | "address" | "u8" | "u16" | "u32" | "u64" | "u128" | "u256" | "vecbool" | "vecaddress" | "vecstring" | "vecu8" | "vecu16" | "vecu32" | "vecu64" | "vecu128" | "vecu256" | "vecvecu8" | "Value";
@@ -1407,7 +1407,7 @@ export declare const CallRepository_InputSchema: z.ZodObject<{
1407
1407
  id_from_submission?: number | undefined;
1408
1408
  data_from_submission?: number | undefined;
1409
1409
  }[];
1410
- id_from: 0 | 1 | 2 | "none" | "Signer" | "Clock" | "signer" | "None" | "clock";
1410
+ id_from: 0 | 1 | 2 | "none" | "Signer" | "Clock" | "signer" | "clock" | "None";
1411
1411
  quote_guard?: string | null | undefined;
1412
1412
  }>, "many">;
1413
1413
  }, "strict", z.ZodTypeAny, {
@@ -1421,7 +1421,7 @@ export declare const CallRepository_InputSchema: z.ZodObject<{
1421
1421
  id_from_submission?: number | undefined;
1422
1422
  data_from_submission?: number | undefined;
1423
1423
  }[];
1424
- id_from: 0 | 1 | 2 | "none" | "Signer" | "Clock" | "signer" | "None" | "clock";
1424
+ id_from: 0 | 1 | 2 | "none" | "Signer" | "Clock" | "signer" | "clock" | "None";
1425
1425
  quote_guard?: string | null | undefined;
1426
1426
  }[];
1427
1427
  }, {
@@ -1435,7 +1435,7 @@ export declare const CallRepository_InputSchema: z.ZodObject<{
1435
1435
  id_from_submission?: number | undefined;
1436
1436
  data_from_submission?: number | undefined;
1437
1437
  }[];
1438
- id_from: 0 | 1 | 2 | "none" | "Signer" | "Clock" | "signer" | "None" | "clock";
1438
+ id_from: 0 | 1 | 2 | "none" | "Signer" | "Clock" | "signer" | "clock" | "None";
1439
1439
  quote_guard?: string | null | undefined;
1440
1440
  }[];
1441
1441
  }>, z.ZodObject<{
@@ -1780,7 +1780,7 @@ export declare const CallRepository_InputSchema: z.ZodObject<{
1780
1780
  id_from_submission?: number | undefined;
1781
1781
  data_from_submission?: number | undefined;
1782
1782
  }[];
1783
- id_from: 0 | 1 | 2 | "none" | "Signer" | "Clock" | "signer" | "None" | "clock";
1783
+ id_from: 0 | 1 | 2 | "none" | "Signer" | "Clock" | "signer" | "clock" | "None";
1784
1784
  quote_guard?: string | null | undefined;
1785
1785
  }[];
1786
1786
  } | {
@@ -1868,7 +1868,7 @@ export declare const CallRepository_InputSchema: z.ZodObject<{
1868
1868
  id_from_submission?: number | undefined;
1869
1869
  data_from_submission?: number | undefined;
1870
1870
  }[];
1871
- id_from: 0 | 1 | 2 | "none" | "Signer" | "Clock" | "signer" | "None" | "clock";
1871
+ id_from: 0 | 1 | 2 | "none" | "Signer" | "Clock" | "signer" | "clock" | "None";
1872
1872
  quote_guard?: string | null | undefined;
1873
1873
  }[];
1874
1874
  } | {
@@ -2172,7 +2172,7 @@ export declare const CallRepository_InputSchema: z.ZodObject<{
2172
2172
  id_from_submission?: number | undefined;
2173
2173
  data_from_submission?: number | undefined;
2174
2174
  }[];
2175
- id_from: 0 | 1 | 2 | "none" | "Signer" | "Clock" | "signer" | "None" | "clock";
2175
+ id_from: 0 | 1 | 2 | "none" | "Signer" | "Clock" | "signer" | "clock" | "None";
2176
2176
  quote_guard?: string | null | undefined;
2177
2177
  }[];
2178
2178
  } | {
@@ -2301,7 +2301,7 @@ export declare const CallRepository_InputSchema: z.ZodObject<{
2301
2301
  id_from_submission?: number | undefined;
2302
2302
  data_from_submission?: number | undefined;
2303
2303
  }[];
2304
- id_from: 0 | 1 | 2 | "none" | "Signer" | "Clock" | "signer" | "None" | "clock";
2304
+ id_from: 0 | 1 | 2 | "none" | "Signer" | "Clock" | "signer" | "clock" | "None";
2305
2305
  quote_guard?: string | null | undefined;
2306
2306
  }[];
2307
2307
  } | {
@@ -5,7 +5,11 @@ import { generateReminders } from "../../customer/index.js";
5
5
  import { getProfile } from "../../experience/user-profile.js";
6
6
  import { injectEvolutionContext, recordIndustrySignal } from "../../knowledge/flywheel-loop.js";
7
7
  import { WException, getMoveErrorDescription, WErrors } from "@wowok/wowok";
8
+ import { GUARDQUERY } from "@wowok/wowok";
8
9
  import { assessGuardRisksForOperation, getRiskSummary } from "../../knowledge/guard-risk.js";
10
+ import { derivePuzzleFromCallData, getPuzzleStatusBooleans, getPendingQuestions, generateConfirmationText, } from "../../knowledge/guard-puzzle.js";
11
+ import { inferSceneFromAction } from "../../knowledge/guard-ledger.js";
12
+ import { matchSemanticPattern } from "../../knowledge/guard-translation.js";
9
13
  function booleanFromSignals(positive, negative) {
10
14
  if (positive)
11
15
  return true;
@@ -515,7 +519,7 @@ export function tagObjectRoles(objectChanges) {
515
519
  };
516
520
  });
517
521
  }
518
- const GAS_COIN_PATTERNS = [/::sui::SUI$/i, /::wow::WOW$/i];
522
+ const GAS_COIN_PATTERNS = [/::wow::WOW$/i];
519
523
  const SMALL_AMOUNT_THRESHOLD = BigInt(1_000_000);
520
524
  function isNegative(amount) {
521
525
  return String(amount ?? "0").startsWith("-");
@@ -1102,11 +1106,11 @@ function buildCustomerAdvice(operation_type, data, safeResult) {
1102
1106
  if (r.action)
1103
1107
  recommendations.push(r.action);
1104
1108
  }
1105
- if (noArbitration && !recommendations.some((r) => r.includes("仲裁"))) {
1106
- recommendations.push("要求商家配置 Arbitration 服务后再下单");
1109
+ if (noArbitration && !recommendations.some((r) => r.includes("arbitration"))) {
1110
+ recommendations.push("Require the merchant to configure an Arbitration service before placing the order");
1107
1111
  }
1108
- if (noCompensation && !recommendations.some((r) => r.includes("赔偿金"))) {
1109
- recommendations.push("要求商家设置 compensation_fund(赔偿金)以保障订单失败时自动赔付");
1112
+ if (noCompensation && !recommendations.some((r) => r.includes("compensation"))) {
1113
+ recommendations.push("Require the merchant to set a compensation_fund to guarantee automatic payout when the order fails");
1110
1114
  }
1111
1115
  const advice = {
1112
1116
  recommendations,
@@ -1127,24 +1131,7 @@ function buildCustomerAdvice(operation_type, data, safeResult) {
1127
1131
  function buildGuardAdvice(operation_type, data, safeResult) {
1128
1132
  try {
1129
1133
  if (operation_type === "guard") {
1130
- const assessment = assessGuardRisksForOperation(operation_type, data);
1131
- if (assessment) {
1132
- const summary = getRiskSummary(assessment);
1133
- const riskWarnings = assessment.risks.map((r) => `[${r.level.toUpperCase()}] ${r.title}: ${r.description}`);
1134
- return {
1135
- current_round: "R7",
1136
- risk_assessment: {
1137
- overall_risk: summary.risk_count > 0 ? assessment.overall_risk : "info",
1138
- risk_count: summary.risk_count,
1139
- critical_count: summary.critical_count,
1140
- high_count: summary.high_count,
1141
- needs_human_review: summary.needs_human_review,
1142
- top_risks: summary.top_risks,
1143
- stakeholder_advice: assessment.stakeholder_advice,
1144
- },
1145
- risk_warnings: riskWarnings.length > 0 ? riskWarnings : undefined,
1146
- };
1147
- }
1134
+ return buildGuardCreateAdvice(data);
1148
1135
  }
1149
1136
  if (operation_type === "gen_passport") {
1150
1137
  const status = safeResult?.error ? "fail" : "pass";
@@ -1163,8 +1150,8 @@ function buildGuardAdvice(operation_type, data, safeResult) {
1163
1150
  if (errorStr.includes("GUARD") || errorStr.includes("Guard") || errorStr.includes("guard")) {
1164
1151
  return {
1165
1152
  risk_warnings: [
1166
- `Guard 验证失败: ${errorStr.slice(0, 200)}`,
1167
- "建议: 检查提交数据是否符合 Guard table 声明,或查询 Guard 定义了解所需 submission",
1153
+ `Guard verification failed: ${errorStr.slice(0, 200)}`,
1154
+ "Suggestion: check whether the submission data matches the Guard table declaration, or query the Guard definition to learn the required submission",
1168
1155
  ],
1169
1156
  };
1170
1157
  }
@@ -1174,6 +1161,223 @@ function buildGuardAdvice(operation_type, data, safeResult) {
1174
1161
  return undefined;
1175
1162
  }
1176
1163
  }
1164
+ function buildGuardCreateAdvice(data) {
1165
+ if (!data)
1166
+ return undefined;
1167
+ const puzzleInput = convertCallDataToPuzzleInput(data);
1168
+ const puzzle = derivePuzzleFromCallData(puzzleInput);
1169
+ const puzzleStatusBooleans = getPuzzleStatusBooleans(puzzle);
1170
+ let matchedScene;
1171
+ let sceneDescription;
1172
+ let sceneConstraints;
1173
+ if (data.binding_hint?.action) {
1174
+ matchedScene = inferSceneFromAction(data.binding_hint.action);
1175
+ if (matchedScene) {
1176
+ sceneDescription = matchedScene.name;
1177
+ sceneConstraints = matchedScene.special_constraints;
1178
+ }
1179
+ }
1180
+ let suggestedPatterns;
1181
+ const intentText = data.binding_hint?.rule_sentence
1182
+ || data.binding_hint?.action
1183
+ || "";
1184
+ if (intentText) {
1185
+ const matched = matchSemanticPattern(intentText);
1186
+ if (matched.length > 0) {
1187
+ suggestedPatterns = matched.map((m) => `${m.id}: ${m.pattern_name}`);
1188
+ }
1189
+ }
1190
+ let confirmationText;
1191
+ try {
1192
+ const text = generateConfirmationText(puzzle);
1193
+ if (!text.startsWith("[Puzzle incomplete]")) {
1194
+ confirmationText = text;
1195
+ }
1196
+ }
1197
+ catch {
1198
+ }
1199
+ let pendingQuestions;
1200
+ const pendingQs = getPendingQuestions(puzzle);
1201
+ if (pendingQs.length > 0) {
1202
+ pendingQuestions = pendingQs;
1203
+ }
1204
+ let availableQueries;
1205
+ if (matchedScene) {
1206
+ const sceneObjectType = mapSceneToObjectType(matchedScene);
1207
+ if (sceneObjectType) {
1208
+ const filtered = GUARDQUERY
1209
+ .filter((q) => q.objectType === sceneObjectType)
1210
+ .slice(0, 10)
1211
+ .map((q) => ({
1212
+ id: q.id,
1213
+ name: q.name,
1214
+ objectType: String(q.objectType),
1215
+ returnType: String(q.return),
1216
+ description: q.description,
1217
+ }));
1218
+ if (filtered.length > 0) {
1219
+ availableQueries = filtered;
1220
+ }
1221
+ }
1222
+ }
1223
+ const assessment = assessGuardRisksForOperation("guard", data);
1224
+ let riskAssessment;
1225
+ let riskWarnings;
1226
+ if (assessment) {
1227
+ const summary = getRiskSummary(assessment);
1228
+ riskAssessment = {
1229
+ overall_risk: summary.risk_count > 0 ? assessment.overall_risk : "info",
1230
+ risk_count: summary.risk_count,
1231
+ critical_count: summary.critical_count,
1232
+ high_count: summary.high_count,
1233
+ needs_human_review: summary.needs_human_review,
1234
+ top_risks: summary.top_risks,
1235
+ stakeholder_advice: assessment.stakeholder_advice,
1236
+ };
1237
+ const warnings = assessment.risks.map((r) => `[${r.level.toUpperCase()}] ${r.title}: ${r.description}`);
1238
+ if (warnings.length > 0) {
1239
+ riskWarnings = warnings;
1240
+ }
1241
+ }
1242
+ const advice = {
1243
+ current_round: "R7",
1244
+ puzzle_status: puzzleStatusBooleans,
1245
+ };
1246
+ if (matchedScene)
1247
+ advice.matched_scene = matchedScene.id;
1248
+ if (sceneDescription)
1249
+ advice.scene_description = sceneDescription;
1250
+ if (sceneConstraints)
1251
+ advice.scene_constraints = sceneConstraints;
1252
+ if (suggestedPatterns)
1253
+ advice.suggested_patterns = suggestedPatterns;
1254
+ if (availableQueries)
1255
+ advice.available_queries = availableQueries;
1256
+ if (riskWarnings)
1257
+ advice.risk_warnings = riskWarnings;
1258
+ if (pendingQuestions)
1259
+ advice.pending_questions = pendingQuestions;
1260
+ if (confirmationText)
1261
+ advice.confirmation_text = confirmationText;
1262
+ if (riskAssessment)
1263
+ advice.risk_assessment = riskAssessment;
1264
+ return advice;
1265
+ }
1266
+ function convertCallDataToPuzzleInput(data) {
1267
+ const result = {};
1268
+ if (Array.isArray(data.table)) {
1269
+ result.table = data.table.map((item) => ({
1270
+ identifier: item.identifier,
1271
+ b_submission: item.b_submission,
1272
+ value_type: typeof item.value_type === "string" ? item.value_type : String(item.value_type),
1273
+ value: convertValueSnapshot(item.value),
1274
+ name: item.name ?? "",
1275
+ object_type: item.object_type,
1276
+ }));
1277
+ }
1278
+ if (data.root && typeof data.root === "object") {
1279
+ const rootObj = data.root;
1280
+ if (rootObj.type !== "file" && rootObj.type !== "node") {
1281
+ result.root = convertNodeToSnapshot(data.root);
1282
+ }
1283
+ else if (rootObj.type === "node" && data.root.node) {
1284
+ result.root = convertNodeToSnapshot(data.root.node);
1285
+ }
1286
+ }
1287
+ if (data.rely && Array.isArray(data.rely.guards)) {
1288
+ result.rely = {
1289
+ guards: data.rely.guards.map((g) => typeof g === "string" ? g : String(g)),
1290
+ logic_or: data.rely.logic_or,
1291
+ };
1292
+ }
1293
+ if (data.binding_hint) {
1294
+ const bh = data.binding_hint;
1295
+ const bindingHint = {
1296
+ action: bh.action,
1297
+ host_object: bh.host_object,
1298
+ binding_field: bh.binding_field,
1299
+ };
1300
+ if (bh.rule_sentence !== undefined)
1301
+ bindingHint.rule_sentence = bh.rule_sentence;
1302
+ if (bh.failure_conditions !== undefined)
1303
+ bindingHint.failure_conditions = bh.failure_conditions;
1304
+ if (bh.circular_reference !== undefined)
1305
+ bindingHint.circular_reference = bh.circular_reference;
1306
+ result.binding_hint = bindingHint;
1307
+ }
1308
+ return result;
1309
+ }
1310
+ function convertNodeToSnapshot(node) {
1311
+ if (!node || typeof node !== "object") {
1312
+ return { type: "unknown" };
1313
+ }
1314
+ const snapshot = {
1315
+ type: String(node.type ?? "unknown"),
1316
+ };
1317
+ if (typeof node.identifier === "number") {
1318
+ snapshot.identifier = node.identifier;
1319
+ }
1320
+ if (node.query !== undefined) {
1321
+ snapshot.query = typeof node.query === "number" ? node.query : String(node.query);
1322
+ }
1323
+ if (node.object && typeof node.object === "object") {
1324
+ const obj = {
1325
+ identifier: Number(node.object.identifier),
1326
+ };
1327
+ if (typeof node.object.convert_witness === "number") {
1328
+ obj.convert_witness = node.object.convert_witness;
1329
+ }
1330
+ snapshot.object = obj;
1331
+ }
1332
+ if (Array.isArray(node.parameters)) {
1333
+ snapshot.parameters = node.parameters.map((p) => convertNodeToSnapshot(p));
1334
+ }
1335
+ if (typeof node.context === "string") {
1336
+ const ctxValue = node.context;
1337
+ if (ctxValue === "Clock" || ctxValue === "Guard" || ctxValue === "Signer") {
1338
+ snapshot.context = ctxValue;
1339
+ }
1340
+ }
1341
+ if (Array.isArray(node.nodes)) {
1342
+ snapshot.nodes = node.nodes.map((n) => convertNodeToSnapshot(n));
1343
+ }
1344
+ if (node.node) {
1345
+ snapshot.node = convertNodeToSnapshot(node.node);
1346
+ }
1347
+ if (node.nodeLeft) {
1348
+ snapshot.nodeLeft = convertNodeToSnapshot(node.nodeLeft);
1349
+ }
1350
+ if (node.nodeRight) {
1351
+ snapshot.nodeRight = convertNodeToSnapshot(node.nodeRight);
1352
+ }
1353
+ return snapshot;
1354
+ }
1355
+ function convertValueSnapshot(value) {
1356
+ if (value === undefined || value === null)
1357
+ return undefined;
1358
+ if (typeof value === "string" || typeof value === "number" || typeof value === "boolean") {
1359
+ return value;
1360
+ }
1361
+ if (Array.isArray(value)) {
1362
+ const allString = value.every((v) => typeof v === "string");
1363
+ if (allString)
1364
+ return value;
1365
+ const allNumber = value.every((v) => typeof v === "number");
1366
+ if (allNumber)
1367
+ return value;
1368
+ const allBool = value.every((v) => typeof v === "boolean");
1369
+ if (allBool)
1370
+ return value;
1371
+ return JSON.stringify(value);
1372
+ }
1373
+ return JSON.stringify(value);
1374
+ }
1375
+ function mapSceneToObjectType(scene) {
1376
+ const hostObject = scene.host_object;
1377
+ if (hostObject === "Standalone")
1378
+ return undefined;
1379
+ return hostObject;
1380
+ }
1177
1381
  export function buildSemantic(safeResult, context) {
1178
1382
  if (!context)
1179
1383
  return undefined;
@@ -1025,7 +1025,7 @@ export declare const CallService_DataSchema: z.ZodObject<{
1025
1025
  customer_required: z.ZodOptional<z.ZodArray<z.ZodEffects<z.ZodString, string, string>, "many">>;
1026
1026
  order_allocators: z.ZodOptional<z.ZodUnion<[z.ZodObject<{
1027
1027
  description: z.ZodEffects<z.ZodString, string, string>;
1028
- threshold: z.ZodUnion<[z.ZodNumber, z.ZodString]>;
1028
+ threshold: z.ZodDefault<z.ZodUnion<[z.ZodNumber, z.ZodString]>>;
1029
1029
  allocators: z.ZodArray<z.ZodObject<{
1030
1030
  guard: z.ZodEffects<z.ZodString, string, string>;
1031
1031
  sharing: z.ZodArray<z.ZodObject<{
@@ -1155,7 +1155,6 @@ export declare const CallService_DataSchema: z.ZodObject<{
1155
1155
  }[];
1156
1156
  }, {
1157
1157
  description: string;
1158
- threshold: string | number;
1159
1158
  allocators: {
1160
1159
  guard: string;
1161
1160
  sharing: {
@@ -1175,6 +1174,7 @@ export declare const CallService_DataSchema: z.ZodObject<{
1175
1174
  max?: string | number | null | undefined;
1176
1175
  fix?: string | number | undefined;
1177
1176
  }[];
1177
+ threshold?: string | number | undefined;
1178
1178
  }>, z.ZodNull]>>;
1179
1179
  buy_guard: z.ZodOptional<z.ZodUnion<[z.ZodEffects<z.ZodString, string, string>, z.ZodNull]>>;
1180
1180
  compensation_fund_add: z.ZodOptional<z.ZodUnion<[z.ZodObject<{
@@ -1485,7 +1485,6 @@ export declare const CallService_DataSchema: z.ZodObject<{
1485
1485
  machine?: string | null | undefined;
1486
1486
  order_allocators?: {
1487
1487
  description: string;
1488
- threshold: string | number;
1489
1488
  allocators: {
1490
1489
  guard: string;
1491
1490
  sharing: {
@@ -1505,6 +1504,7 @@ export declare const CallService_DataSchema: z.ZodObject<{
1505
1504
  max?: string | number | null | undefined;
1506
1505
  fix?: string | number | undefined;
1507
1506
  }[];
1507
+ threshold?: string | number | undefined;
1508
1508
  } | null | undefined;
1509
1509
  sales?: {
1510
1510
  op: "add";
@@ -2204,7 +2204,7 @@ export declare const CallService_InputSchema: z.ZodObject<{
2204
2204
  customer_required: z.ZodOptional<z.ZodArray<z.ZodEffects<z.ZodString, string, string>, "many">>;
2205
2205
  order_allocators: z.ZodOptional<z.ZodUnion<[z.ZodObject<{
2206
2206
  description: z.ZodEffects<z.ZodString, string, string>;
2207
- threshold: z.ZodUnion<[z.ZodNumber, z.ZodString]>;
2207
+ threshold: z.ZodDefault<z.ZodUnion<[z.ZodNumber, z.ZodString]>>;
2208
2208
  allocators: z.ZodArray<z.ZodObject<{
2209
2209
  guard: z.ZodEffects<z.ZodString, string, string>;
2210
2210
  sharing: z.ZodArray<z.ZodObject<{
@@ -2334,7 +2334,6 @@ export declare const CallService_InputSchema: z.ZodObject<{
2334
2334
  }[];
2335
2335
  }, {
2336
2336
  description: string;
2337
- threshold: string | number;
2338
2337
  allocators: {
2339
2338
  guard: string;
2340
2339
  sharing: {
@@ -2354,6 +2353,7 @@ export declare const CallService_InputSchema: z.ZodObject<{
2354
2353
  max?: string | number | null | undefined;
2355
2354
  fix?: string | number | undefined;
2356
2355
  }[];
2356
+ threshold?: string | number | undefined;
2357
2357
  }>, z.ZodNull]>>;
2358
2358
  buy_guard: z.ZodOptional<z.ZodUnion<[z.ZodEffects<z.ZodString, string, string>, z.ZodNull]>>;
2359
2359
  compensation_fund_add: z.ZodOptional<z.ZodUnion<[z.ZodObject<{
@@ -2664,7 +2664,6 @@ export declare const CallService_InputSchema: z.ZodObject<{
2664
2664
  machine?: string | null | undefined;
2665
2665
  order_allocators?: {
2666
2666
  description: string;
2667
- threshold: string | number;
2668
2667
  allocators: {
2669
2668
  guard: string;
2670
2669
  sharing: {
@@ -2684,6 +2683,7 @@ export declare const CallService_InputSchema: z.ZodObject<{
2684
2683
  max?: string | number | null | undefined;
2685
2684
  fix?: string | number | undefined;
2686
2685
  }[];
2686
+ threshold?: string | number | undefined;
2687
2687
  } | null | undefined;
2688
2688
  sales?: {
2689
2689
  op: "add";
@@ -3305,7 +3305,6 @@ export declare const CallService_InputSchema: z.ZodObject<{
3305
3305
  machine?: string | null | undefined;
3306
3306
  order_allocators?: {
3307
3307
  description: string;
3308
- threshold: string | number;
3309
3308
  allocators: {
3310
3309
  guard: string;
3311
3310
  sharing: {
@@ -3325,6 +3324,7 @@ export declare const CallService_InputSchema: z.ZodObject<{
3325
3324
  max?: string | number | null | undefined;
3326
3325
  fix?: string | number | undefined;
3327
3326
  }[];
3327
+ threshold?: string | number | undefined;
3328
3328
  } | null | undefined;
3329
3329
  sales?: {
3330
3330
  op: "add";