@wowok/agent-mcp 2.4.3 → 2.5.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.
Files changed (317) hide show
  1. package/dist/config/runtime.d.ts +4 -0
  2. package/dist/config/runtime.js +29 -5
  3. package/dist/harness/auto-escalation.d.ts +27 -0
  4. package/dist/harness/auto-escalation.js +68 -0
  5. package/dist/index.js +21 -0
  6. package/dist/knowledge/allocation-confirm.d.ts +115 -0
  7. package/dist/knowledge/allocation-confirm.js +534 -0
  8. package/dist/knowledge/allocation-context.d.ts +58 -0
  9. package/dist/knowledge/allocation-context.js +249 -0
  10. package/dist/knowledge/allocation-ledger.d.ts +67 -0
  11. package/dist/knowledge/allocation-ledger.js +463 -0
  12. package/dist/knowledge/allocation-puzzle.d.ts +135 -0
  13. package/dist/knowledge/allocation-puzzle.js +298 -0
  14. package/dist/knowledge/allocation-risk.d.ts +78 -0
  15. package/dist/knowledge/allocation-risk.js +568 -0
  16. package/dist/knowledge/allocation-templates.d.ts +38 -0
  17. package/dist/knowledge/allocation-templates.js +970 -0
  18. package/dist/knowledge/allocation-translation.d.ts +72 -0
  19. package/dist/knowledge/allocation-translation.js +585 -0
  20. package/dist/knowledge/arb-risk.d.ts +37 -0
  21. package/dist/knowledge/arb-risk.js +210 -0
  22. package/dist/knowledge/arbitration-confirm.d.ts +135 -0
  23. package/dist/knowledge/arbitration-confirm.js +559 -0
  24. package/dist/knowledge/arbitration-context.d.ts +81 -0
  25. package/dist/knowledge/arbitration-context.js +505 -0
  26. package/dist/knowledge/arbitration-ledger.d.ts +62 -0
  27. package/dist/knowledge/arbitration-ledger.js +521 -0
  28. package/dist/knowledge/arbitration-puzzle.d.ts +84 -0
  29. package/dist/knowledge/arbitration-puzzle.js +304 -0
  30. package/dist/knowledge/arbitration-risk.d.ts +112 -0
  31. package/dist/knowledge/arbitration-risk.js +433 -0
  32. package/dist/knowledge/arbitration-templates.d.ts +38 -0
  33. package/dist/knowledge/arbitration-templates.js +276 -0
  34. package/dist/knowledge/arbitration-translation.d.ts +91 -0
  35. package/dist/knowledge/arbitration-translation.js +487 -0
  36. package/dist/knowledge/bridge-risk.d.ts +36 -0
  37. package/dist/knowledge/bridge-risk.js +263 -0
  38. package/dist/knowledge/contact-risk.d.ts +32 -0
  39. package/dist/knowledge/contact-risk.js +200 -0
  40. package/dist/knowledge/demand-confirm.d.ts +32 -0
  41. package/dist/knowledge/demand-confirm.js +206 -0
  42. package/dist/knowledge/demand-risk.d.ts +30 -0
  43. package/dist/knowledge/demand-risk.js +240 -0
  44. package/dist/knowledge/demand-translation.d.ts +55 -0
  45. package/dist/knowledge/demand-translation.js +354 -0
  46. package/dist/knowledge/deployment-scanner.d.ts +63 -0
  47. package/dist/knowledge/deployment-scanner.js +762 -0
  48. package/dist/knowledge/examples-scanner-cli.d.ts +1 -0
  49. package/dist/knowledge/examples-scanner-cli.js +26 -0
  50. package/dist/knowledge/examples-scanner.d.ts +121 -0
  51. package/dist/knowledge/examples-scanner.js +825 -0
  52. package/dist/knowledge/flywheel-loop.d.ts +3 -0
  53. package/dist/knowledge/flywheel-loop.js +32 -3
  54. package/dist/knowledge/glossary.js +3 -1
  55. package/dist/knowledge/guard-confirm.d.ts +86 -0
  56. package/dist/knowledge/guard-confirm.js +406 -0
  57. package/dist/knowledge/guard-context.d.ts +56 -0
  58. package/dist/knowledge/guard-context.js +287 -0
  59. package/dist/knowledge/guard-design-patterns.d.ts +37 -0
  60. package/dist/knowledge/guard-design-patterns.js +257 -0
  61. package/dist/knowledge/guard-puzzle.js +3 -2
  62. package/dist/knowledge/guard-risk.d.ts +1 -1
  63. package/dist/knowledge/guard-risk.js +12 -14
  64. package/dist/knowledge/guard-templates.js +1 -1
  65. package/dist/knowledge/guard-translation.js +6 -5
  66. package/dist/knowledge/index.d.ts +342 -0
  67. package/dist/knowledge/index.js +344 -0
  68. package/dist/knowledge/machine-confirm.d.ts +102 -0
  69. package/dist/knowledge/machine-confirm.js +559 -0
  70. package/dist/knowledge/machine-context.d.ts +160 -0
  71. package/dist/knowledge/machine-context.js +812 -0
  72. package/dist/knowledge/machine-ledger.d.ts +41 -0
  73. package/dist/knowledge/machine-ledger.js +315 -0
  74. package/dist/knowledge/machine-puzzle.d.ts +206 -0
  75. package/dist/knowledge/machine-puzzle.js +494 -0
  76. package/dist/knowledge/machine-risk.d.ts +75 -0
  77. package/dist/knowledge/machine-risk.js +644 -0
  78. package/dist/knowledge/machine-templates.d.ts +92 -0
  79. package/dist/knowledge/machine-templates.js +1592 -0
  80. package/dist/knowledge/machine-topology.d.ts +57 -0
  81. package/dist/knowledge/machine-topology.js +234 -0
  82. package/dist/knowledge/machine-translation.d.ts +96 -0
  83. package/dist/knowledge/machine-translation.js +513 -0
  84. package/dist/knowledge/mcp-schema-audit-cli.d.ts +1 -0
  85. package/dist/knowledge/mcp-schema-audit-cli.js +45 -0
  86. package/dist/knowledge/mcp-schema-audit.d.ts +90 -0
  87. package/dist/knowledge/mcp-schema-audit.js +772 -0
  88. package/dist/knowledge/onchain-constants.d.ts +4 -0
  89. package/dist/knowledge/onchain-constants.js +35 -0
  90. package/dist/knowledge/order-confirm.d.ts +115 -0
  91. package/dist/knowledge/order-confirm.js +573 -0
  92. package/dist/knowledge/order-context.d.ts +66 -0
  93. package/dist/knowledge/order-context.js +390 -0
  94. package/dist/knowledge/order-ledger.d.ts +69 -0
  95. package/dist/knowledge/order-ledger.js +341 -0
  96. package/dist/knowledge/order-puzzle.d.ts +159 -0
  97. package/dist/knowledge/order-puzzle.js +255 -0
  98. package/dist/knowledge/order-risk.d.ts +66 -0
  99. package/dist/knowledge/order-risk.js +653 -0
  100. package/dist/knowledge/order-templates.d.ts +50 -0
  101. package/dist/knowledge/order-templates.js +368 -0
  102. package/dist/knowledge/order-translation.d.ts +78 -0
  103. package/dist/knowledge/order-translation.js +550 -0
  104. package/dist/knowledge/passport-confirm.d.ts +130 -0
  105. package/dist/knowledge/passport-confirm.js +531 -0
  106. package/dist/knowledge/passport-context.d.ts +59 -0
  107. package/dist/knowledge/passport-context.js +306 -0
  108. package/dist/knowledge/passport-ledger.d.ts +48 -0
  109. package/dist/knowledge/passport-ledger.js +282 -0
  110. package/dist/knowledge/passport-puzzle.d.ts +108 -0
  111. package/dist/knowledge/passport-puzzle.js +333 -0
  112. package/dist/knowledge/passport-risk.d.ts +70 -0
  113. package/dist/knowledge/passport-risk.js +450 -0
  114. package/dist/knowledge/passport-templates.d.ts +40 -0
  115. package/dist/knowledge/passport-templates.js +568 -0
  116. package/dist/knowledge/passport-translation.d.ts +68 -0
  117. package/dist/knowledge/passport-translation.js +516 -0
  118. package/dist/knowledge/payment-risk.d.ts +33 -0
  119. package/dist/knowledge/payment-risk.js +182 -0
  120. package/dist/knowledge/permission-confirm.d.ts +110 -0
  121. package/dist/knowledge/permission-confirm.js +426 -0
  122. package/dist/knowledge/permission-context.d.ts +58 -0
  123. package/dist/knowledge/permission-context.js +224 -0
  124. package/dist/knowledge/permission-ledger.d.ts +38 -0
  125. package/dist/knowledge/permission-ledger.js +403 -0
  126. package/dist/knowledge/permission-puzzle.d.ts +122 -0
  127. package/dist/knowledge/permission-puzzle.js +173 -0
  128. package/dist/knowledge/permission-risk.d.ts +76 -0
  129. package/dist/knowledge/permission-risk.js +411 -0
  130. package/dist/knowledge/permission-templates.d.ts +38 -0
  131. package/dist/knowledge/permission-templates.js +234 -0
  132. package/dist/knowledge/permission-translation.d.ts +57 -0
  133. package/dist/knowledge/permission-translation.js +350 -0
  134. package/dist/knowledge/personal-risk.d.ts +36 -0
  135. package/dist/knowledge/personal-risk.js +212 -0
  136. package/dist/knowledge/progress-confirm.d.ts +108 -0
  137. package/dist/knowledge/progress-confirm.js +456 -0
  138. package/dist/knowledge/progress-context.d.ts +123 -0
  139. package/dist/knowledge/progress-context.js +452 -0
  140. package/dist/knowledge/progress-ledger.d.ts +63 -0
  141. package/dist/knowledge/progress-ledger.js +327 -0
  142. package/dist/knowledge/progress-puzzle.d.ts +82 -0
  143. package/dist/knowledge/progress-puzzle.js +219 -0
  144. package/dist/knowledge/progress-risk.d.ts +74 -0
  145. package/dist/knowledge/progress-risk.js +461 -0
  146. package/dist/knowledge/progress-templates.d.ts +38 -0
  147. package/dist/knowledge/progress-templates.js +228 -0
  148. package/dist/knowledge/progress-translation.d.ts +52 -0
  149. package/dist/knowledge/progress-translation.js +401 -0
  150. package/dist/knowledge/proof-confirm.d.ts +31 -0
  151. package/dist/knowledge/proof-confirm.js +187 -0
  152. package/dist/knowledge/proof-risk.d.ts +33 -0
  153. package/dist/knowledge/proof-risk.js +207 -0
  154. package/dist/knowledge/proof-translation.d.ts +52 -0
  155. package/dist/knowledge/proof-translation.js +283 -0
  156. package/dist/knowledge/registrar-risk.d.ts +34 -0
  157. package/dist/knowledge/registrar-risk.js +217 -0
  158. package/dist/knowledge/repository-confirm.d.ts +36 -0
  159. package/dist/knowledge/repository-confirm.js +242 -0
  160. package/dist/knowledge/repository-risk.d.ts +40 -0
  161. package/dist/knowledge/repository-risk.js +312 -0
  162. package/dist/knowledge/repository-translation.d.ts +58 -0
  163. package/dist/knowledge/repository-translation.js +422 -0
  164. package/dist/knowledge/resource-risk.d.ts +32 -0
  165. package/dist/knowledge/resource-risk.js +157 -0
  166. package/dist/knowledge/reward-confirm.d.ts +113 -0
  167. package/dist/knowledge/reward-confirm.js +496 -0
  168. package/dist/knowledge/reward-context.d.ts +127 -0
  169. package/dist/knowledge/reward-context.js +504 -0
  170. package/dist/knowledge/reward-ledger.d.ts +96 -0
  171. package/dist/knowledge/reward-ledger.js +502 -0
  172. package/dist/knowledge/reward-puzzle.d.ts +97 -0
  173. package/dist/knowledge/reward-puzzle.js +288 -0
  174. package/dist/knowledge/reward-risk.d.ts +84 -0
  175. package/dist/knowledge/reward-risk.js +545 -0
  176. package/dist/knowledge/reward-translation.d.ts +58 -0
  177. package/dist/knowledge/reward-translation.js +501 -0
  178. package/dist/knowledge/safety-rules.js +11 -3
  179. package/dist/knowledge/scenario-modes.d.ts +53 -0
  180. package/dist/knowledge/scenario-modes.js +302 -0
  181. package/dist/knowledge/service-confirm.d.ts +152 -0
  182. package/dist/knowledge/service-confirm.js +699 -0
  183. package/dist/knowledge/service-context.d.ts +66 -0
  184. package/dist/knowledge/service-context.js +403 -0
  185. package/dist/knowledge/service-ledger.d.ts +71 -0
  186. package/dist/knowledge/service-ledger.js +609 -0
  187. package/dist/knowledge/service-puzzle.d.ts +158 -0
  188. package/dist/knowledge/service-puzzle.js +236 -0
  189. package/dist/knowledge/service-risk.d.ts +108 -0
  190. package/dist/knowledge/service-risk.js +615 -0
  191. package/dist/knowledge/service-templates.d.ts +39 -0
  192. package/dist/knowledge/service-templates.js +418 -0
  193. package/dist/knowledge/service-translation.d.ts +103 -0
  194. package/dist/knowledge/service-translation.js +622 -0
  195. package/dist/knowledge/tools-reference.d.ts +17 -0
  196. package/dist/knowledge/tools-reference.js +151 -0
  197. package/dist/knowledge/treasury-confirm.d.ts +133 -0
  198. package/dist/knowledge/treasury-confirm.js +512 -0
  199. package/dist/knowledge/treasury-context.d.ts +64 -0
  200. package/dist/knowledge/treasury-context.js +363 -0
  201. package/dist/knowledge/treasury-ledger.d.ts +42 -0
  202. package/dist/knowledge/treasury-ledger.js +300 -0
  203. package/dist/knowledge/treasury-puzzle.d.ts +163 -0
  204. package/dist/knowledge/treasury-puzzle.js +216 -0
  205. package/dist/knowledge/treasury-risk.d.ts +86 -0
  206. package/dist/knowledge/treasury-risk.js +440 -0
  207. package/dist/knowledge/treasury-templates.d.ts +38 -0
  208. package/dist/knowledge/treasury-templates.js +316 -0
  209. package/dist/knowledge/treasury-translation.d.ts +78 -0
  210. package/dist/knowledge/treasury-translation.js +498 -0
  211. package/dist/knowledge/util-risk.d.ts +30 -0
  212. package/dist/knowledge/util-risk.js +135 -0
  213. package/dist/project/business-puzzle.d.ts +47 -0
  214. package/dist/project/business-puzzle.js +372 -0
  215. package/dist/project/deployment-doc.d.ts +61 -0
  216. package/dist/project/deployment-doc.js +432 -0
  217. package/dist/project/risk-aggregator.d.ts +50 -0
  218. package/dist/project/risk-aggregator.js +280 -0
  219. package/dist/project/substep-trace.d.ts +130 -0
  220. package/dist/project/substep-trace.js +332 -0
  221. package/dist/schema/call/allocation.d.ts +34 -34
  222. package/dist/schema/call/arbitration.d.ts +141 -141
  223. package/dist/schema/call/base.d.ts +386 -386
  224. package/dist/schema/call/base.js +3 -3
  225. package/dist/schema/call/bridge-handler.d.ts +5 -2
  226. package/dist/schema/call/bridge.d.ts +159 -159
  227. package/dist/schema/call/contact.d.ts +110 -110
  228. package/dist/schema/call/demand.d.ts +76 -76
  229. package/dist/schema/call/handler.d.ts +2 -3
  230. package/dist/schema/call/handler.js +1 -1
  231. package/dist/schema/call/machine.d.ts +58 -58
  232. package/dist/schema/call/order.d.ts +98 -110
  233. package/dist/schema/call/permission-handler.d.ts +5 -0
  234. package/dist/schema/call/permission-handler.js +54 -0
  235. package/dist/schema/call/permission.d.ts +108 -108
  236. package/dist/schema/call/personal.d.ts +14 -14
  237. package/dist/schema/call/progress.d.ts +57 -72
  238. package/dist/schema/call/progress.js +7 -4
  239. package/dist/schema/call/proof.d.ts +18 -18
  240. package/dist/schema/call/proof.js +12 -7
  241. package/dist/schema/call/repository.d.ts +154 -154
  242. package/dist/schema/call/reward.d.ts +55 -55
  243. package/dist/schema/call/service.d.ts +231 -231
  244. package/dist/schema/call/treasury.d.ts +93 -93
  245. package/dist/schema/config/index.d.ts +178 -5
  246. package/dist/schema/config/index.js +52 -1
  247. package/dist/schema/local/index.d.ts +3554 -836
  248. package/dist/schema/local/index.js +2 -1
  249. package/dist/schema/messenger/index.d.ts +162 -162
  250. package/dist/schema/operations.d.ts +1058 -1074
  251. package/dist/schema/operations.js +7 -1
  252. package/dist/schema/project/index.d.ts +1392 -6
  253. package/dist/schema/project/index.js +426 -2
  254. package/dist/schema/query/index.d.ts +672 -672
  255. package/dist/schema/schema-query/index.d.ts +23 -3
  256. package/dist/schema/schema-query/index.js +13 -2
  257. package/dist/schema/sync-layer4.d.ts +21 -0
  258. package/dist/schema/sync-layer4.js +261 -0
  259. package/dist/schema/trust/index.d.ts +26 -26
  260. package/dist/schemas/account_operation.output.json +718 -0
  261. package/dist/schemas/config_operation.output.json +173 -0
  262. package/dist/schemas/index.json +9 -1
  263. package/dist/schemas/local_info_operation.output.json +718 -0
  264. package/dist/schemas/local_mark_operation.output.json +718 -0
  265. package/dist/schemas/onchain_operations.output.json +3 -2
  266. package/dist/schemas/onchain_operations.schema.json +1802 -313
  267. package/dist/schemas/onchain_operations_allocation.schema.json +2 -1
  268. package/dist/schemas/onchain_operations_arbitration.schema.json +2 -1
  269. package/dist/schemas/onchain_operations_contact.schema.json +2 -1
  270. package/dist/schemas/onchain_operations_demand.schema.json +2 -1
  271. package/dist/schemas/onchain_operations_gen_passport.schema.json +878 -872
  272. package/dist/schemas/onchain_operations_gen_proof.schema.json +273 -0
  273. package/dist/schemas/onchain_operations_guard.schema.json +584 -70
  274. package/dist/schemas/onchain_operations_machine.schema.json +2 -1
  275. package/dist/schemas/onchain_operations_order.schema.json +13 -9
  276. package/dist/schemas/onchain_operations_payment.schema.json +2 -1
  277. package/dist/schemas/onchain_operations_permission.schema.json +2 -1
  278. package/dist/schemas/onchain_operations_personal.schema.json +2 -1
  279. package/dist/schemas/onchain_operations_progress.schema.json +14 -10
  280. package/dist/schemas/onchain_operations_proof.schema.json +699 -0
  281. package/dist/schemas/onchain_operations_repository.schema.json +2 -1
  282. package/dist/schemas/onchain_operations_reward.schema.json +2 -1
  283. package/dist/schemas/onchain_operations_service.schema.json +2 -1
  284. package/dist/schemas/onchain_operations_treasury.schema.json +2 -1
  285. package/dist/schemas/onchain_table_data.schema.json +32 -1
  286. package/dist/schemas/project_operation.output.json +879 -0
  287. package/dist/schemas/project_operation.schema.json +473 -2
  288. package/dist/schemas/query_toolkit.output.json +14906 -6
  289. package/dist/schemas/schema_query.output.json +38 -1
  290. package/dist/telemetry/index.d.ts +1 -1
  291. package/dist/tools/handlers/config.d.ts +1 -1
  292. package/dist/tools/handlers/config.js +21 -18
  293. package/dist/tools/handlers/file-export.d.ts +2 -2
  294. package/dist/tools/handlers/local.d.ts +3 -30
  295. package/dist/tools/handlers/local.js +14 -3
  296. package/dist/tools/handlers/messenger.d.ts +1 -1
  297. package/dist/tools/handlers/messenger.js +2 -1
  298. package/dist/tools/handlers/onchain.d.ts +1 -1
  299. package/dist/tools/handlers/onchain.js +24 -22
  300. package/dist/tools/handlers/project.d.ts +1 -1
  301. package/dist/tools/handlers/project.js +258 -18
  302. package/dist/tools/handlers/query.d.ts +4 -4
  303. package/dist/tools/handlers/schema-query.d.ts +1 -1
  304. package/dist/tools/handlers/schema-query.js +21 -20
  305. package/dist/tools/handlers/trust.d.ts +1 -1
  306. package/dist/tools/handlers/trust.js +2 -2
  307. package/dist/tools/handlers/wip.d.ts +1 -1
  308. package/dist/tools/handlers/wip.js +1 -1
  309. package/dist/tools/index.d.ts +1 -1
  310. package/dist/tools/index.js +55 -8
  311. package/dist/tools/rules-hook.d.ts +1 -1
  312. package/dist/tools/rules-hook.js +3 -2
  313. package/dist/tools/shared.d.ts +13 -22
  314. package/dist/tools/types.d.ts +5 -5
  315. package/dist/tools/wrap.d.ts +10 -2
  316. package/dist/tools/wrap.js +212 -0
  317. package/package.json +3 -3
@@ -0,0 +1,108 @@
1
+ import { type PassportConsumerObject, type PassportLifecycleStage, type ImpackRole, type ReliesLogic } from "./passport-ledger.js";
2
+ export interface PassportIntentPuzzle {
3
+ protected_operation: string;
4
+ consumer_object: PassportConsumerObject;
5
+ verification_rules: string[];
6
+ failure_conditions: string[];
7
+ }
8
+ export interface PassportBindingPuzzle {
9
+ guard_objects: string[];
10
+ impack_flags: boolean[];
11
+ relies_dependencies: string[][];
12
+ relies_logic: ReliesLogic[];
13
+ topological_order: string[];
14
+ }
15
+ export interface SubmissionEntry {
16
+ guard: string;
17
+ identifier: number;
18
+ value: string;
19
+ value_type: string;
20
+ estimated_size: number;
21
+ }
22
+ export interface PassportSubmissionPuzzle {
23
+ submissions: SubmissionEntry[];
24
+ max_entry_size: number;
25
+ size_ok: boolean;
26
+ }
27
+ export interface PassportVerifyPuzzle {
28
+ tx_hash_binding: true;
29
+ has_verified: boolean;
30
+ verify_flow: {
31
+ step: 1 | 2 | 3 | 4 | 5 | 6 | 7;
32
+ action: "pre_check" | "iterate_guards" | "calc_relies_result" | "verify_guard_native" | "check_submission_size" | "impack_decision" | "finalize";
33
+ description: string;
34
+ }[];
35
+ }
36
+ export interface PassportResultPuzzle {
37
+ decision_rule: "impack_mechanism";
38
+ impack_guards: string[];
39
+ per_guard_logic: {
40
+ guard: string;
41
+ impack: ImpackRole;
42
+ relies_logic: ReliesLogic;
43
+ relies_guards: string[];
44
+ computation: string;
45
+ }[];
46
+ overall_formula: string;
47
+ }
48
+ export interface PassportLifecyclePuzzle {
49
+ stages: {
50
+ stage: PassportLifecycleStage;
51
+ description: string;
52
+ completed: boolean;
53
+ }[];
54
+ terminal_state: "freeze" | "destroy" | "undecided";
55
+ destroy_before_freeze: true;
56
+ }
57
+ export type PassportPuzzleDimension = "A" | "B" | "C" | "D" | "E" | "F";
58
+ export interface PassportPuzzle {
59
+ intent?: PassportIntentPuzzle;
60
+ binding?: PassportBindingPuzzle;
61
+ submission?: PassportSubmissionPuzzle;
62
+ verify?: PassportVerifyPuzzle;
63
+ result?: PassportResultPuzzle;
64
+ lifecycle?: PassportLifecyclePuzzle;
65
+ }
66
+ export interface PassportPuzzleCompleteness {
67
+ dimensions: PassportPuzzleDimension[];
68
+ missing: PassportPuzzleDimension[];
69
+ missing_details: {
70
+ dimension: PassportPuzzleDimension;
71
+ reason: string;
72
+ }[];
73
+ complete: boolean;
74
+ next_step: string;
75
+ }
76
+ export interface InitPuzzleInput {
77
+ protected_operation?: string;
78
+ consumer_object?: PassportConsumerObject;
79
+ verification_rules?: string[];
80
+ failure_conditions?: string[];
81
+ }
82
+ export declare function initPuzzleFromIntent(intent: InitPuzzleInput): PassportPuzzle;
83
+ export declare function checkPuzzleCompleteness(puzzle: PassportPuzzle): PassportPuzzleCompleteness;
84
+ export interface PassportConstraintViolation {
85
+ constraint_id: string;
86
+ severity: "CRITICAL" | "HIGH" | "MEDIUM" | "LOW";
87
+ message: string;
88
+ current_value?: string | number;
89
+ limit?: string | number;
90
+ related_move_error?: string;
91
+ }
92
+ export declare function validateConstraints(puzzle: PassportPuzzle): PassportConstraintViolation[];
93
+ export declare function buildResultPuzzle(binding: PassportBindingPuzzle): PassportResultPuzzle;
94
+ export declare function buildDefaultVerifyFlow(): PassportVerifyPuzzle["verify_flow"];
95
+ export declare function buildDefaultLifecycleStages(): PassportLifecyclePuzzle["stages"];
96
+ export declare function generateConfirmationText(puzzle: PassportPuzzle): string;
97
+ export declare function buildPassportPuzzle(input: {
98
+ intent: InitPuzzleInput;
99
+ binding: {
100
+ guard_objects: string[];
101
+ impack_flags: boolean[];
102
+ relies_dependencies?: string[][];
103
+ relies_logic?: ReliesLogic[];
104
+ };
105
+ submission: SubmissionEntry[];
106
+ terminal_state?: "freeze" | "destroy" | "undecided";
107
+ }): PassportPuzzle;
108
+ export declare const PASSPORT_PUZZLE_VERSION = "1.0.0";
@@ -0,0 +1,333 @@
1
+ import { MAX_GUARD_COUNT_PASSPORT, MAX_SUBMISSION_SIZE_PASSPORT, } from "./passport-ledger.js";
2
+ export function initPuzzleFromIntent(intent) {
3
+ const puzzle = {};
4
+ if (intent.protected_operation || intent.verification_rules || intent.consumer_object) {
5
+ puzzle.intent = {
6
+ protected_operation: intent.protected_operation ?? "",
7
+ consumer_object: intent.consumer_object ?? "Service",
8
+ verification_rules: intent.verification_rules ?? [],
9
+ failure_conditions: intent.failure_conditions ?? [],
10
+ };
11
+ }
12
+ puzzle.verify = {
13
+ tx_hash_binding: true,
14
+ has_verified: false,
15
+ verify_flow: buildDefaultVerifyFlow(),
16
+ };
17
+ puzzle.lifecycle = {
18
+ stages: buildDefaultLifecycleStages(),
19
+ terminal_state: "undecided",
20
+ destroy_before_freeze: true,
21
+ };
22
+ return puzzle;
23
+ }
24
+ export function checkPuzzleCompleteness(puzzle) {
25
+ const missing = [];
26
+ const missing_details = [];
27
+ if (!puzzle.intent) {
28
+ missing.push("A");
29
+ missing_details.push({ dimension: "A", reason: "Intent not specified (protected_operation + verification_rules)" });
30
+ }
31
+ else if (!puzzle.intent.protected_operation) {
32
+ missing.push("A");
33
+ missing_details.push({ dimension: "A", reason: "protected_operation is empty" });
34
+ }
35
+ else if (puzzle.intent.verification_rules.length === 0) {
36
+ missing.push("A");
37
+ missing_details.push({ dimension: "A", reason: "verification_rules is empty — what should each Guard check?" });
38
+ }
39
+ if (!puzzle.binding) {
40
+ missing.push("B");
41
+ missing_details.push({ dimension: "B", reason: "Binding not specified (guard_objects + impack_flags + relies)" });
42
+ }
43
+ else if (puzzle.binding.guard_objects.length === 0) {
44
+ missing.push("B");
45
+ missing_details.push({ dimension: "B", reason: "guard_objects is empty — at least 1 Guard required" });
46
+ }
47
+ else if (!puzzle.binding.impack_flags.some(f => f)) {
48
+ missing.push("B");
49
+ missing_details.push({ dimension: "B", reason: "No impack=true Guard — at least 1 required (E_IMPACK_GUARD_NOT_FOUND)" });
50
+ }
51
+ else if (puzzle.binding.guard_objects.length > MAX_GUARD_COUNT_PASSPORT) {
52
+ missing.push("B");
53
+ missing_details.push({ dimension: "B", reason: `guard_objects count ${puzzle.binding.guard_objects.length} > MAX_GUARD_COUNT_PASSPORT=${MAX_GUARD_COUNT_PASSPORT}` });
54
+ }
55
+ if (!puzzle.submission) {
56
+ missing.push("C");
57
+ missing_details.push({ dimension: "C", reason: "Submission not specified (per-Guard identifier + value + value_type)" });
58
+ }
59
+ else if (!puzzle.submission.size_ok) {
60
+ missing.push("C");
61
+ missing_details.push({
62
+ dimension: "C",
63
+ reason: `max_entry_size ${puzzle.submission.max_entry_size} > MAX_SUBMISSION_SIZE_PASSPORT=${MAX_SUBMISSION_SIZE_PASSPORT}`,
64
+ });
65
+ }
66
+ if (!puzzle.verify) {
67
+ missing.push("D");
68
+ missing_details.push({ dimension: "D", reason: "Verify dimension not initialized (should be auto-filled)" });
69
+ }
70
+ if (!puzzle.result) {
71
+ missing.push("E");
72
+ missing_details.push({ dimension: "E", reason: "Result computation not derived (call buildResultPuzzle from binding)" });
73
+ }
74
+ if (!puzzle.lifecycle) {
75
+ missing.push("F");
76
+ missing_details.push({ dimension: "F", reason: "Lifecycle not initialized (should be auto-filled)" });
77
+ }
78
+ return {
79
+ dimensions: ["A", "B", "C", "D", "E", "F"],
80
+ missing,
81
+ missing_details,
82
+ complete: missing.length === 0,
83
+ next_step: missing.length === 0
84
+ ? "Puzzle complete — ready for confirmation text generation"
85
+ : `Next: complete dimension ${missing[0]} — ${missing_details[0].reason}`,
86
+ };
87
+ }
88
+ export function validateConstraints(puzzle) {
89
+ const violations = [];
90
+ if (puzzle.binding && puzzle.binding.guard_objects.length > MAX_GUARD_COUNT_PASSPORT) {
91
+ violations.push({
92
+ constraint_id: "F-PASS-04",
93
+ severity: "CRITICAL",
94
+ message: `Guard count ${puzzle.binding.guard_objects.length} exceeds MAX_GUARD_COUNT_PASSPORT=${MAX_GUARD_COUNT_PASSPORT}`,
95
+ current_value: puzzle.binding.guard_objects.length,
96
+ limit: MAX_GUARD_COUNT_PASSPORT,
97
+ related_move_error: "E_GUARD_COUNT_EXCEEDED (1)",
98
+ });
99
+ }
100
+ if (puzzle.binding && !puzzle.binding.impack_flags.some(f => f)) {
101
+ violations.push({
102
+ constraint_id: "F-PASS-07",
103
+ severity: "CRITICAL",
104
+ message: "No impack=true Guard — verify() will abort E_IMPACK_GUARD_NOT_FOUND",
105
+ related_move_error: "E_IMPACK_GUARD_NOT_FOUND (9)",
106
+ });
107
+ }
108
+ if (puzzle.binding) {
109
+ const added = new Set();
110
+ for (let i = 0; i < puzzle.binding.guard_objects.length; i++) {
111
+ const guard = puzzle.binding.guard_objects[i];
112
+ const relies = puzzle.binding.relies_dependencies[i] ?? [];
113
+ for (const rely of relies) {
114
+ if (!added.has(rely)) {
115
+ violations.push({
116
+ constraint_id: "F-PASS-06",
117
+ severity: "HIGH",
118
+ message: `Guard ${guard} (index ${i}) relies on ${rely}, but ${rely} is not added before it (topological order violated)`,
119
+ related_move_error: "E_RELIES_GUARD_NOT_ADDED (2)",
120
+ });
121
+ }
122
+ }
123
+ added.add(guard);
124
+ }
125
+ }
126
+ if (puzzle.submission && !puzzle.submission.size_ok) {
127
+ violations.push({
128
+ constraint_id: "F-PASS-05",
129
+ severity: "HIGH",
130
+ message: `Submission max entry size ${puzzle.submission.max_entry_size} > MAX_SUBMISSION_SIZE_PASSPORT=${MAX_SUBMISSION_SIZE_PASSPORT}`,
131
+ current_value: puzzle.submission.max_entry_size,
132
+ limit: MAX_SUBMISSION_SIZE_PASSPORT,
133
+ related_move_error: "E_SUBMISSION_SIZE_EXCEEDED (3)",
134
+ });
135
+ }
136
+ if (puzzle.binding) {
137
+ const guardToRelies = new Map();
138
+ for (let i = 0; i < puzzle.binding.guard_objects.length; i++) {
139
+ guardToRelies.set(puzzle.binding.guard_objects[i], puzzle.binding.relies_dependencies[i] ?? []);
140
+ }
141
+ for (let i = 0; i < puzzle.binding.guard_objects.length; i++) {
142
+ const guard = puzzle.binding.guard_objects[i];
143
+ const relies = puzzle.binding.relies_dependencies[i] ?? [];
144
+ for (const rely of relies) {
145
+ const relyOfRely = guardToRelies.get(rely) ?? [];
146
+ if (relyOfRely.length > 0) {
147
+ violations.push({
148
+ constraint_id: "F-PASS-12",
149
+ severity: "LOW",
150
+ message: `Guard ${guard} relies on ${rely}, but ${rely} itself has relies ${JSON.stringify(relyOfRely)} — transitive dependencies are not allowed`,
151
+ });
152
+ }
153
+ }
154
+ }
155
+ }
156
+ return violations;
157
+ }
158
+ export function buildResultPuzzle(binding) {
159
+ const impackGuards = binding.guard_objects.filter((_, i) => binding.impack_flags[i]);
160
+ const perGuardLogic = binding.guard_objects.map((guard, i) => {
161
+ const impack = binding.impack_flags[i] ? "impack" : "non_impack";
162
+ const logic = binding.relies_logic[i] ?? "AND";
163
+ const relies = binding.relies_dependencies[i] ?? [];
164
+ const relyPart = relies.length === 0
165
+ ? "(no relies)"
166
+ : relies.map(r => `${r}.result`).join(` ${logic} `);
167
+ const computation = relies.length === 0
168
+ ? `${guard}.result (standalone)`
169
+ : `${relyPart} ${logic} ${guard}.result`;
170
+ return { guard, impack, relies_logic: logic, relies_guards: relies, computation };
171
+ });
172
+ const overallFormula = impackGuards.length === 0
173
+ ? "result = false (no impack Guard — E_IMPACK_GUARD_NOT_FOUND)"
174
+ : `result = AND(${impackGuards.map(g => `${g}.result`).join(", ")})`;
175
+ return {
176
+ decision_rule: "impack_mechanism",
177
+ impack_guards: impackGuards,
178
+ per_guard_logic: perGuardLogic,
179
+ overall_formula: overallFormula,
180
+ };
181
+ }
182
+ export function buildDefaultVerifyFlow() {
183
+ return [
184
+ { step: 1, action: "pre_check", description: "assert !has_verified (E_HAS_VERIFIED), tx_hash matches (E_DIGEST_NOT_MATCH)" },
185
+ { step: 2, action: "iterate_guards", description: "for each GuardInfo in self.guard (in addition order)" },
186
+ { step: 3, action: "calc_relies_result", description: "calculate relies result via AND/OR logic; short-circuit on AND-false or OR-true" },
187
+ { step: 4, action: "verify_guard_native", description: "guard::verify_guard(guard, submission, impack) — native function, opaque" },
188
+ { step: 5, action: "check_submission_size", description: "assert BCS submission size ≤ MAX_SUBMISSION_SIZE_PASSPORT=256 (E_SUBMISSION_SIZE_EXCEEDED)" },
189
+ { step: 6, action: "impack_decision", description: "if impack=true and result=false → set self.result=false, return immediately" },
190
+ { step: 7, action: "finalize", description: "assert at least 1 impack Guard (E_IMPACK_GUARD_NOT_FOUND); set has_verified=true, self.result=true" },
191
+ ];
192
+ }
193
+ export function buildDefaultLifecycleStages() {
194
+ return [
195
+ { stage: "new", description: "passport::new(clock, ctx) — create Passport, bind tx_hash", completed: false },
196
+ { stage: "guard_add", description: "passport::guard_add(self, guard, identifiers, values, impack, ctx) — add Guards (repeatable, pre-verify)", completed: false },
197
+ { stage: "verify", description: "passport::verify(self, ctx) — one-time verification, sets has_verified=true", completed: false },
198
+ { stage: "use", description: "passport::result / result_for_guard / result_for_permission / submission_get — query results", completed: false },
199
+ { stage: "freeze_or_destroy", description: "passport::freezen(self) [permanent] OR passport::destroy(self) [release]", completed: false },
200
+ ];
201
+ }
202
+ export function generateConfirmationText(puzzle) {
203
+ const lines = [];
204
+ lines.push("═══ Passport Confirmation ═══");
205
+ lines.push("");
206
+ if (puzzle.intent) {
207
+ lines.push("─ A. Intent ──────────────");
208
+ lines.push(`Protected operation: ${puzzle.intent.protected_operation}`);
209
+ lines.push(`Consumer object: ${puzzle.intent.consumer_object}`);
210
+ if (puzzle.intent.verification_rules.length > 0) {
211
+ lines.push("Verification rules:");
212
+ for (const r of puzzle.intent.verification_rules)
213
+ lines.push(` - ${r}`);
214
+ }
215
+ if (puzzle.intent.failure_conditions.length > 0) {
216
+ lines.push("Failure conditions:");
217
+ for (const fc of puzzle.intent.failure_conditions)
218
+ lines.push(` - ${fc}`);
219
+ }
220
+ lines.push("");
221
+ }
222
+ if (puzzle.binding) {
223
+ const b = puzzle.binding;
224
+ lines.push("─ B. Binding ──────────────");
225
+ lines.push(`Guards (${b.guard_objects.length}/${MAX_GUARD_COUNT_PASSPORT}):`);
226
+ b.guard_objects.forEach((g, i) => {
227
+ const impack = b.impack_flags[i] ? "IMPACK" : "non-impack";
228
+ const relies = b.relies_dependencies[i] ?? [];
229
+ const logic = b.relies_logic[i] ?? "AND";
230
+ const relyStr = relies.length === 0 ? "" : ` relies=${JSON.stringify(relies)} (${logic})`;
231
+ lines.push(` [${i}] ${g} — ${impack}${relyStr}`);
232
+ });
233
+ if (b.topological_order.length > 0) {
234
+ lines.push(`Topological order: ${b.topological_order.join(" → ")}`);
235
+ }
236
+ lines.push("");
237
+ }
238
+ if (puzzle.submission) {
239
+ const s = puzzle.submission;
240
+ lines.push("─ C. Submission ──────────────");
241
+ lines.push(`Entries: ${s.submissions.length}, max entry size: ${s.max_entry_size}/${MAX_SUBMISSION_SIZE_PASSPORT} bytes (${s.size_ok ? "OK" : "EXCEEDS"})`);
242
+ for (const sub of s.submissions) {
243
+ lines.push(` - guard=${sub.guard}, identifier=${sub.identifier}, value_type=${sub.value_type}, size=${sub.estimated_size}`);
244
+ }
245
+ lines.push("");
246
+ }
247
+ if (puzzle.verify) {
248
+ const v = puzzle.verify;
249
+ lines.push("─ D. Verify ──────────────");
250
+ lines.push(`tx_hash binding: ${v.tx_hash_binding ? "YES (Move-level hard-coded)" : "NO"}`);
251
+ lines.push(`has_verified: ${v.has_verified}`);
252
+ lines.push(`Verify flow (${v.verify_flow.length} steps):`);
253
+ for (const step of v.verify_flow) {
254
+ lines.push(` ${step.step}. ${step.action}: ${step.description}`);
255
+ }
256
+ lines.push("");
257
+ }
258
+ if (puzzle.result) {
259
+ const r = puzzle.result;
260
+ lines.push("─ E. Result ──────────────");
261
+ lines.push(`Decision rule: ${r.decision_rule}`);
262
+ lines.push(`impack Guards: ${r.impack_guards.length === 0 ? "(none — will fail verify)" : r.impack_guards.join(", ")}`);
263
+ lines.push(`Overall formula: ${r.overall_formula}`);
264
+ if (r.per_guard_logic.length > 0) {
265
+ lines.push("Per-Guard logic:");
266
+ for (const pgl of r.per_guard_logic) {
267
+ lines.push(` - ${pgl.guard} (${pgl.impack}, ${pgl.relies_logic}): ${pgl.computation}`);
268
+ }
269
+ }
270
+ lines.push("");
271
+ }
272
+ if (puzzle.lifecycle) {
273
+ const l = puzzle.lifecycle;
274
+ lines.push("─ F. Lifecycle ──────────────");
275
+ lines.push(`Terminal state: ${l.terminal_state}`);
276
+ for (const stage of l.stages) {
277
+ const mark = stage.completed ? "✓" : "○";
278
+ lines.push(` ${mark} ${stage.stage}: ${stage.description}`);
279
+ }
280
+ lines.push("");
281
+ }
282
+ const violations = validateConstraints(puzzle);
283
+ if (violations.length > 0) {
284
+ lines.push("─ Constraint Violations ──────────────");
285
+ for (const v of violations) {
286
+ lines.push(` [${v.severity}] ${v.constraint_id}: ${v.message}`);
287
+ }
288
+ lines.push("");
289
+ }
290
+ return lines.join("\n");
291
+ }
292
+ export function buildPassportPuzzle(input) {
293
+ const puzzle = initPuzzleFromIntent(input.intent);
294
+ const topological_order = computeTopologicalOrder(input.binding.guard_objects, input.binding.relies_dependencies ?? input.binding.guard_objects.map(() => []));
295
+ puzzle.binding = {
296
+ guard_objects: input.binding.guard_objects,
297
+ impack_flags: input.binding.impack_flags,
298
+ relies_dependencies: input.binding.relies_dependencies ?? input.binding.guard_objects.map(() => []),
299
+ relies_logic: input.binding.relies_logic ?? input.binding.guard_objects.map(() => "AND"),
300
+ topological_order,
301
+ };
302
+ const maxEntrySize = input.submission.reduce((max, s) => Math.max(max, s.estimated_size), 0);
303
+ puzzle.submission = {
304
+ submissions: input.submission,
305
+ max_entry_size: maxEntrySize,
306
+ size_ok: maxEntrySize <= MAX_SUBMISSION_SIZE_PASSPORT,
307
+ };
308
+ puzzle.result = buildResultPuzzle(puzzle.binding);
309
+ if (input.terminal_state) {
310
+ puzzle.lifecycle.terminal_state = input.terminal_state;
311
+ }
312
+ return puzzle;
313
+ }
314
+ function computeTopologicalOrder(guard_objects, relies_dependencies) {
315
+ const order = [];
316
+ const added = new Set();
317
+ for (let i = 0; i < guard_objects.length; i++) {
318
+ const guard = guard_objects[i];
319
+ const relies = relies_dependencies[i] ?? [];
320
+ for (const rely of relies) {
321
+ if (!added.has(rely) && guard_objects.includes(rely)) {
322
+ order.push(rely);
323
+ added.add(rely);
324
+ }
325
+ }
326
+ if (!added.has(guard)) {
327
+ order.push(guard);
328
+ added.add(guard);
329
+ }
330
+ }
331
+ return order;
332
+ }
333
+ export const PASSPORT_PUZZLE_VERSION = "1.0.0";
@@ -0,0 +1,70 @@
1
+ import { PASSPORT_ERROR_CODES, type PassportScenario } from "./passport-ledger.js";
2
+ export type PassportRiskLevel = "CRITICAL" | "HIGH" | "MEDIUM" | "LOW" | "INFO";
3
+ export type PassportRiskCategory = "structural" | "lifecycle" | "logic" | "operational" | "knowledge";
4
+ export type PassportStakeholder = "creator" | "consumer" | "guard_owner" | "system";
5
+ export interface PassportRisk {
6
+ id: string;
7
+ level: PassportRiskLevel;
8
+ category: PassportRiskCategory;
9
+ title: string;
10
+ description: string;
11
+ affected_stakeholders: PassportStakeholder[];
12
+ scenario: string;
13
+ mitigation: string;
14
+ evidence?: string;
15
+ related_move_error?: string;
16
+ related_risk?: string;
17
+ resolved?: boolean;
18
+ auto_fixable: boolean;
19
+ }
20
+ export interface PassportRiskRule {
21
+ id: string;
22
+ category: PassportRiskCategory;
23
+ trigger: string;
24
+ check: (ctx: PassportRiskCheckContext) => PassportRisk | null;
25
+ }
26
+ export interface PassportRiskCheckContext {
27
+ object?: string | null;
28
+ guard_config?: {
29
+ guard: {
30
+ object: string;
31
+ impack: boolean;
32
+ }[];
33
+ submission?: {
34
+ guard: string;
35
+ submission: {
36
+ identifier: number;
37
+ value: unknown;
38
+ value_type: string;
39
+ }[];
40
+ }[];
41
+ };
42
+ has_verified?: boolean;
43
+ guard_count?: number;
44
+ has_impack_guard?: boolean;
45
+ max_submission_size?: number;
46
+ relies_map?: Record<string, string[]>;
47
+ has_transitive_relies?: boolean;
48
+ operation_type?: "create" | "guard_add" | "guard_clear" | "verify" | "use" | "freezen" | "destroy" | "query";
49
+ is_frozen?: boolean;
50
+ matched_scenario?: PassportScenario;
51
+ constants_synced?: boolean;
52
+ knowledge_files_present?: boolean;
53
+ }
54
+ export declare const PASSPORT_RISK_VERSION = "1.0.0";
55
+ export declare function getAllRiskRules(): PassportRiskRule[];
56
+ export declare function getRiskRulesCount(): number;
57
+ export declare function getRiskRulesByCategory(category: PassportRiskCategory): PassportRiskRule[];
58
+ export interface PassportRiskAssessment {
59
+ summary: string;
60
+ scenario?: PassportScenario;
61
+ risks: PassportRisk[];
62
+ overall_risk: PassportRiskLevel;
63
+ risks_by_category: Partial<Record<PassportRiskCategory, number>>;
64
+ risks_by_level: Partial<Record<PassportRiskLevel, number>>;
65
+ stakeholder_advice: Partial<Record<PassportStakeholder, string[]>>;
66
+ needs_human_review: boolean;
67
+ blocks_publish: boolean;
68
+ }
69
+ export declare function assessPassportRisks(ctx: PassportRiskCheckContext): PassportRiskAssessment;
70
+ export { PASSPORT_ERROR_CODES };