@wowok/agent-mcp 2.4.3 → 2.5.1

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 +1412 -6
  253. package/dist/schema/project/index.js +441 -3
  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 +1809 -336
  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 +578 -579
  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 +0 -514
  277. package/dist/schemas/onchain_operations_permission.schema.json +0 -514
  278. package/dist/schemas/onchain_operations_personal.schema.json +0 -514
  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 +918 -0
  287. package/dist/schemas/project_operation.schema.json +474 -3
  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 +262 -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 +96 -25
  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
@@ -1,4 +1,65 @@
1
1
  import { z } from "zod";
2
+ const IndustryEnum = z.enum([
3
+ "general",
4
+ "retail",
5
+ "service",
6
+ "rental",
7
+ "freelance",
8
+ "education",
9
+ "travel",
10
+ "subscription",
11
+ "custom",
12
+ ]);
13
+ export const ProjectObjectTypeEnum = z.enum([
14
+ "service",
15
+ "machine",
16
+ "guard",
17
+ "permission",
18
+ "reward",
19
+ "arb",
20
+ "progress",
21
+ "treasury",
22
+ "demand",
23
+ "repository",
24
+ "contact",
25
+ "order",
26
+ "allocation",
27
+ "personal",
28
+ "payment",
29
+ "proof",
30
+ ]);
31
+ export const EdgeKindEnum = z.enum([
32
+ "machine",
33
+ "order_allocators",
34
+ "arbitrations",
35
+ "compensation_fund",
36
+ "rewards",
37
+ "buy_guard",
38
+ "permission",
39
+ "guard",
40
+ "prev",
41
+ "next",
42
+ "forward",
43
+ "parent",
44
+ "service",
45
+ "progress",
46
+ "arbitration",
47
+ "sub_order",
48
+ "references",
49
+ ]);
50
+ const PuzzleEntrySchema = z
51
+ .object({
52
+ puzzle: z
53
+ .record(z.unknown())
54
+ .describe("Per-object puzzle snapshot. Shape varies per object_type — see knowledge/<obj>-puzzle.ts."),
55
+ completeness: z
56
+ .record(z.unknown())
57
+ .describe("Completeness assessment from checkPuzzleCompleteness(). Shape varies per object."),
58
+ missing_dimensions: z
59
+ .array(z.string())
60
+ .describe("Dimensions still missing for this object (e.g. ['A','B'])."),
61
+ })
62
+ .strict();
2
63
  export const ProjectOperationInputSchema = z
3
64
  .object({
4
65
  action: z
@@ -13,20 +74,397 @@ export const ProjectOperationInputSchema = z
13
74
  "graph_stats",
14
75
  "save_graph",
15
76
  "load_graph",
77
+ "analyze_intent",
78
+ "aggregate_risks",
79
+ "generate_deployment_doc",
80
+ "trace_substeps",
16
81
  ])
17
- .describe("Query/action to perform"),
82
+ .describe("Action to perform. Two categories:\n" +
83
+ "1. Graph Query (10): list_projects, list_objects, shareable, dependencies, referenced_by, pre_publish_check, cross_project_refs, graph_stats, save_graph, load_graph.\n" +
84
+ "2. Project-Based Deployment 5-Stage (4): Call IN ORDER — analyze_intent (Stage 2) → aggregate_risks (Stage 3) → generate_deployment_doc (Stage 4) → trace_substeps (Stage 5). Each action's output includes `next_action` telling you which action to call next. Stage 1 (Project Naming) uses the `project` + `version` params."),
18
85
  project: z
19
86
  .string()
20
87
  .optional()
21
- .describe("Project prefix (for list_objects)"),
88
+ .describe("Project prefix (for list_objects and C1-C4 actions)"),
89
+ version: z
90
+ .string()
91
+ .regex(/^v\d+$/)
92
+ .optional()
93
+ .describe("Project version (e.g. 'v1'). Required for C1-C4 actions."),
22
94
  object: z
23
95
  .string()
24
96
  .optional()
25
97
  .describe("Object name or address (for dependencies / referenced_by / pre_publish_check)"),
98
+ user_intent: z
99
+ .string()
100
+ .min(1)
101
+ .max(2000)
102
+ .optional()
103
+ .describe("Natural-language business intent for analyze_intent (stage 2). Required when action='analyze_intent'."),
104
+ industry: IndustryEnum.optional().describe("Industry hint — drives template defaults. Used by analyze_intent and aggregate_risks."),
105
+ target_objects: z
106
+ .array(z.string())
107
+ .optional()
108
+ .describe("Optional explicit target objects (entry_ids or object_type names) for analyze_intent."),
109
+ puzzles: z
110
+ .record(z.string(), PuzzleEntrySchema)
111
+ .optional()
112
+ .describe("Per-object puzzle snapshots keyed by object_type. Required for aggregate_risks and generate_deployment_doc."),
113
+ severity_threshold: z
114
+ .enum(["CRITICAL", "HIGH", "MEDIUM", "LOW", "INFO"])
115
+ .optional()
116
+ .describe("Severity threshold for aggregate_risks. Risks at or above this level are flagged."),
117
+ user_confirmed_high_risks: z
118
+ .array(z.string())
119
+ .optional()
120
+ .describe("IDs of HIGH risks the user has already confirmed (suppressed in subsequent aggregate_risks)."),
121
+ business_intent: z
122
+ .string()
123
+ .min(1)
124
+ .max(500)
125
+ .optional()
126
+ .describe("One-line business intent description for the deployment doc. Required when action='generate_deployment_doc'."),
127
+ author: z
128
+ .string()
129
+ .optional()
130
+ .describe("Optional author name for the deployment doc meta section."),
131
+ objects: z
132
+ .array(z
133
+ .object({
134
+ entry_id: z.string().describe("Stable id '<object_type>:<name>'"),
135
+ object_type: ProjectObjectTypeEnum,
136
+ name: z.string(),
137
+ reused_from: z
138
+ .string()
139
+ .optional()
140
+ .describe("Existing on-chain address or local name if reused"),
141
+ publish_required: z
142
+ .boolean()
143
+ .describe("Whether publish is required (only Service/Machine)"),
144
+ description: z.string().optional(),
145
+ })
146
+ .strict())
147
+ .optional()
148
+ .describe("Deployment objects for generate_deployment_doc."),
149
+ edges: z
150
+ .array(z
151
+ .object({
152
+ from: z.string(),
153
+ to: z.string(),
154
+ edge_kind: EdgeKindEnum,
155
+ field_path: z.string(),
156
+ required_at_publish: z.boolean(),
157
+ })
158
+ .strict())
159
+ .optional()
160
+ .describe("Dependency graph edges for generate_deployment_doc."),
161
+ steps: z
162
+ .array(z
163
+ .object({
164
+ step: z.number().int().positive(),
165
+ object_type: ProjectObjectTypeEnum,
166
+ operation: z.string(),
167
+ substep_count: z.number().int().nonnegative(),
168
+ depends_on: z.array(z.number().int()),
169
+ entry_id: z.string(),
170
+ network_phase: z.enum(["testnet", "mainnet", "both"]),
171
+ })
172
+ .strict())
173
+ .optional()
174
+ .describe("Topological execution plan for generate_deployment_doc."),
175
+ scenarios: z
176
+ .array(z
177
+ .object({
178
+ scenario_id: z.string(),
179
+ description: z.string(),
180
+ primary_object: z.string(),
181
+ supporting_objects: z.array(z.string()),
182
+ test_step_refs: z.array(z.string()).optional(),
183
+ })
184
+ .strict())
185
+ .optional()
186
+ .describe("Business scenarios for generate_deployment_doc §7."),
187
+ risk_status: z
188
+ .enum(["RISK_PASSED", "RISK_BLOCKED", "RISK_PENDING_CONFIRM", "RISK_CANCELLED"])
189
+ .optional()
190
+ .describe("Risk status from aggregate_risks (for D-16 check)."),
191
+ risk_critical_count: z
192
+ .number()
193
+ .int()
194
+ .nonnegative()
195
+ .optional()
196
+ .describe("CRITICAL risk count from aggregate_risks."),
197
+ risk_high_count: z
198
+ .number()
199
+ .int()
200
+ .nonnegative()
201
+ .optional()
202
+ .describe("HIGH risk count from aggregate_risks."),
203
+ run_scanner: z
204
+ .boolean()
205
+ .optional()
206
+ .describe("Whether to run deployment-scanner validation after generating the doc. Defaults to true."),
207
+ network: z
208
+ .enum(["testnet", "mainnet"])
209
+ .optional()
210
+ .describe("Target network for trace_substeps."),
211
+ substeps: z
212
+ .array(z
213
+ .object({
214
+ step_id: z.string().regex(/^T\d+\.\d+$/),
215
+ parent_step: z.string().regex(/^T\d+$/),
216
+ object_type: ProjectObjectTypeEnum,
217
+ entry_id: z.string(),
218
+ operation_type: z.string(),
219
+ network: z.enum(["testnet", "mainnet"]),
220
+ input: z.object({
221
+ data: z.record(z.unknown()),
222
+ input_refs: z.array(z.string()),
223
+ }),
224
+ output: z
225
+ .object({
226
+ object_id: z.string().optional(),
227
+ tx_digest: z.string().optional(),
228
+ })
229
+ .partial()
230
+ .optional(),
231
+ timestamp: z.number().int(),
232
+ status: z.enum(["PENDING", "SUCCESS", "FAILED", "SKIPPED"]),
233
+ failure_reason: z.string().optional(),
234
+ dependencies: z.object({
235
+ input_refs: z.array(z.string()),
236
+ output_refs: z.array(z.object({
237
+ substep_id: z.string(),
238
+ field_path: z.string(),
239
+ })),
240
+ }),
241
+ retry_info: z
242
+ .object({
243
+ original_step_id: z.string(),
244
+ retry_count: z.number().int().nonnegative(),
245
+ retry_reason: z.string(),
246
+ })
247
+ .optional(),
248
+ })
249
+ .strict())
250
+ .optional()
251
+ .describe("Substep records for trace_substeps."),
252
+ })
253
+ .strict();
254
+ const ItemsResult = (action) => z.object({
255
+ action: z.literal(action),
256
+ items: z
257
+ .array(z.record(z.unknown()))
258
+ .describe("List of result items. Each item is an untyped record — shape varies per query."),
259
+ });
260
+ const AnalyzeIntentResultSchema = z
261
+ .object({
262
+ action: z.literal("analyze_intent"),
263
+ intent_parsed: z.object({
264
+ primary_object: z.string(),
265
+ secondary_objects: z.array(z.string()),
266
+ detected_scenes: z.array(z.object({
267
+ object: z.string(),
268
+ scene_id: z.string(),
269
+ })),
270
+ industry: z.string(),
271
+ keyword_matches: z.array(z.object({
272
+ keyword: z.string(),
273
+ category: z.string(),
274
+ matched_objects: z.array(z.string()),
275
+ required_level: z.enum(["R", "C", "OPTIONAL"]),
276
+ match_count: z.number().int(),
277
+ })),
278
+ }),
279
+ puzzles: z.record(z.string(), PuzzleEntrySchema),
280
+ overall_completeness: z.enum(["complete", "partial", "empty"]),
281
+ next_step: z.string(),
282
+ next_action: z
283
+ .enum(["aggregate_risks", "none"])
284
+ .describe("Next project_operation action to call. 'aggregate_risks' when puzzles are complete enough; 'none' if user must fill missing fields first."),
285
+ warnings: z.array(z.string()),
286
+ })
287
+ .strict();
288
+ const AggregateRisksResultSchema = z
289
+ .object({
290
+ action: z.literal("aggregate_risks"),
291
+ namespace: z.object({
292
+ prefix: z.string(),
293
+ version: z.string(),
294
+ industry: z.string().optional(),
295
+ }),
296
+ findings: z.array(z.object({
297
+ risk_rule_id: z.string(),
298
+ object_type: z.string(),
299
+ entry_id: z.string(),
300
+ severity: z.enum(["CRITICAL", "HIGH", "MEDIUM", "LOW", "INFO"]),
301
+ message: z.string(),
302
+ fix_suggestion: z.string(),
303
+ details: z
304
+ .object({
305
+ field_path: z.string().optional(),
306
+ rule_source: z.string().optional(),
307
+ })
308
+ .partial()
309
+ .optional(),
310
+ })),
311
+ severity_summary: z.object({
312
+ CRITICAL: z.number().int(),
313
+ HIGH: z.number().int(),
314
+ MEDIUM: z.number().int(),
315
+ LOW: z.number().int(),
316
+ INFO: z.number().int(),
317
+ }),
318
+ status: z.enum([
319
+ "RISK_PASSED",
320
+ "RISK_BLOCKED",
321
+ "RISK_PENDING_CONFIRM",
322
+ "RISK_CANCELLED",
323
+ ]),
324
+ pending_confirmations: z
325
+ .array(z.object({
326
+ risk_rule_id: z.string(),
327
+ description: z.string(),
328
+ fix_suggestion: z.string(),
329
+ object_type: z.string(),
330
+ entry_id: z.string(),
331
+ }))
332
+ .optional(),
333
+ calibrated_at: z.number().int(),
334
+ warnings: z.array(z.string()),
335
+ can_proceed: z
336
+ .boolean()
337
+ .describe("Whether the user can proceed to the next stage. False only when CRITICAL risks exist."),
338
+ next_action: z
339
+ .enum(["generate_deployment_doc", "fix_risks", "none"])
340
+ .describe("Next project_operation action. 'generate_deployment_doc' when can_proceed=true; 'fix_risks' when CRITICAL risks exist; 'none' for other cases."),
341
+ user_action_required: z
342
+ .string()
343
+ .describe("Human-readable next-step guidance."),
344
+ })
345
+ .strict();
346
+ const GenerateDeploymentDocResultSchema = z
347
+ .object({
348
+ action: z.literal("generate_deployment_doc"),
349
+ markdown: z.string().describe("Complete deployment MD document (§0-§7)"),
350
+ meta: z.object({
351
+ project_prefix: z.string(),
352
+ version: z.string(),
353
+ generated_at: z.string().describe("ISO timestamp"),
354
+ object_count: z.number().int(),
355
+ step_count: z.number().int(),
356
+ }),
357
+ validation: z
358
+ .object({
359
+ valid: z.boolean(),
360
+ checks: z.array(z.object({
361
+ check_id: z.string(),
362
+ description: z.string(),
363
+ status: z.enum(["PASS", "FAIL", "WARN"]),
364
+ notes: z.string().optional(),
365
+ })),
366
+ errors: z.array(z.string()),
367
+ })
368
+ .optional()
369
+ .describe("Scanner validation result. Present when run_scanner=true."),
370
+ can_proceed: z
371
+ .boolean()
372
+ .describe("Whether the user can proceed to stage 5. False when D-errors exist."),
373
+ next_action: z
374
+ .enum(["trace_substeps", "fix_doc_errors", "none"])
375
+ .describe("Next project_operation action. 'trace_substeps' when can_proceed=true; 'fix_doc_errors' when D-errors exist; 'none' for other cases."),
376
+ user_action_required: z.string(),
377
+ })
378
+ .strict();
379
+ const TraceSubstepsResultSchema = z
380
+ .object({
381
+ action: z.literal("trace_substeps"),
382
+ namespace: z.object({
383
+ prefix: z.string(),
384
+ version: z.string(),
385
+ }),
386
+ network: z.enum(["testnet", "mainnet"]),
387
+ coherent: z
388
+ .boolean()
389
+ .describe("True when no dangling/circular/missing/cross-step issues."),
390
+ dangling_inputs: z.array(z.object({
391
+ substep_id: z.string(),
392
+ missing_ref: z.string(),
393
+ field_path: z.string(),
394
+ })),
395
+ circular_refs: z.array(z.object({
396
+ cycle: z.array(z.string()),
397
+ })),
398
+ missing_outputs: z.array(z.object({
399
+ substep_id: z.string(),
400
+ expected_field: z.string(),
401
+ dependent_substeps: z.array(z.string()),
402
+ })),
403
+ cross_step_breaks: z.array(z.object({
404
+ source_step: z.string(),
405
+ target_step: z.string(),
406
+ missing_field: z.string(),
407
+ })),
408
+ step_details: z.array(z.object({
409
+ parent_step: z.string(),
410
+ total_substeps: z.number().int(),
411
+ successful: z.number().int(),
412
+ failed: z.number().int(),
413
+ pending: z.number().int(),
414
+ skipped: z.number().int(),
415
+ substep_ids: z.array(z.string()),
416
+ })),
417
+ topological_order: z.array(z.string()),
418
+ d10_check: z.object({
419
+ check_id: z.literal("D-10"),
420
+ description: z.string(),
421
+ status: z.enum(["PASS", "FAIL", "WARN"]),
422
+ }),
423
+ can_proceed: z
424
+ .boolean()
425
+ .describe("Whether deployment can complete. False when D-10 fails or substeps FAILED."),
426
+ next_action: z
427
+ .enum(["deploy", "fix_substeps", "none"])
428
+ .describe("Next action. 'deploy' when can_proceed=true (execute substeps via onchain_operations); 'fix_substeps' when issues exist; 'none' when done."),
429
+ user_action_required: z.string(),
26
430
  })
27
431
  .strict();
28
432
  export const ProjectOperationOutputSchema = z
29
433
  .object({
30
- result: z.any().describe("Query result — shape depends on action"),
434
+ result: z.discriminatedUnion("action", [
435
+ ItemsResult("list_projects"),
436
+ ItemsResult("list_objects"),
437
+ ItemsResult("shareable"),
438
+ ItemsResult("dependencies"),
439
+ ItemsResult("referenced_by"),
440
+ z.object({
441
+ action: z.literal("pre_publish_check"),
442
+ warnings: z
443
+ .array(z.string())
444
+ .describe("Pre-publish warnings. Empty array means no issues detected."),
445
+ }),
446
+ ItemsResult("cross_project_refs"),
447
+ z.object({
448
+ action: z.literal("graph_stats"),
449
+ stats: z
450
+ .record(z.unknown())
451
+ .describe("Object dependency graph statistics (counts, depth, etc.)."),
452
+ }),
453
+ z.object({
454
+ action: z.literal("save_graph"),
455
+ saved: z.literal(true).describe("Always true — confirms the graph was saved."),
456
+ path: z.string().describe("Filesystem path where the graph was saved."),
457
+ }),
458
+ z.object({
459
+ action: z.literal("load_graph"),
460
+ loaded: z
461
+ .boolean()
462
+ .describe("Whether the graph was successfully loaded from disk."),
463
+ }),
464
+ AnalyzeIntentResultSchema,
465
+ AggregateRisksResultSchema,
466
+ GenerateDeploymentDocResultSchema,
467
+ TraceSubstepsResultSchema,
468
+ ]).describe("Query result — shape depends on action"),
31
469
  })
32
470
  .strict();