@wowok/agent-mcp 2.6.0 → 2.6.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 (186) hide show
  1. package/README.md +5 -3
  2. package/dist/customer/info-puzzle.d.ts +1 -1
  3. package/dist/customer/info-puzzle.js +4 -2
  4. package/dist/customer/risk-assessment.js +26 -4
  5. package/dist/customer/types.d.ts +2 -0
  6. package/dist/examples/guard-template-balance-check.json +38 -0
  7. package/dist/examples/guard-template-time-lock.json +39 -0
  8. package/dist/examples/machine-template-7node-rental.json +114 -0
  9. package/dist/examples/rental-ziroom-machine-create.json +137 -0
  10. package/dist/examples/rental-ziroom-permission-create.json +35 -0
  11. package/dist/examples/rental-ziroom-service-create.json +80 -0
  12. package/dist/examples/retail-myshop-service-create.json +88 -0
  13. package/dist/extensions/capability-manifest.d.ts +125 -0
  14. package/dist/extensions/capability-manifest.js +594 -0
  15. package/dist/extensions/constraint-registry.d.ts +24 -0
  16. package/dist/extensions/constraint-registry.js +196 -0
  17. package/dist/extensions/index.d.ts +12 -0
  18. package/dist/extensions/index.js +6 -0
  19. package/dist/extensions/metric-registry.d.ts +26 -0
  20. package/dist/extensions/metric-registry.js +257 -0
  21. package/dist/extensions/mode-evaluator.d.ts +15 -0
  22. package/dist/extensions/mode-evaluator.js +170 -0
  23. package/dist/extensions/modes.d.ts +2 -0
  24. package/dist/extensions/modes.js +493 -0
  25. package/dist/extensions/registry.d.ts +50 -0
  26. package/dist/extensions/registry.js +662 -0
  27. package/dist/extensions/types.d.ts +219 -0
  28. package/dist/extensions/types.js +1 -0
  29. package/dist/index.js +50 -0
  30. package/dist/knowledge/deployment-scanner.d.ts +3 -0
  31. package/dist/knowledge/deployment-scanner.js +64 -3
  32. package/dist/knowledge/fund-layer.d.ts +72 -0
  33. package/dist/knowledge/fund-layer.js +420 -0
  34. package/dist/knowledge/guard-render.d.ts +57 -0
  35. package/dist/knowledge/guard-render.js +700 -0
  36. package/dist/knowledge/guard-risk.d.ts +13 -0
  37. package/dist/knowledge/guard-risk.js +57 -0
  38. package/dist/knowledge/guard-submission-prompt.d.ts +31 -0
  39. package/dist/knowledge/guard-submission-prompt.js +171 -0
  40. package/dist/knowledge/guard-templates.js +278 -0
  41. package/dist/knowledge/machine-ledger.js +1 -1
  42. package/dist/knowledge/machine-render.d.ts +41 -0
  43. package/dist/knowledge/machine-render.js +565 -0
  44. package/dist/knowledge/machine-templates.js +24 -5
  45. package/dist/knowledge/reward-confirm.js +2 -2
  46. package/dist/knowledge/reward-puzzle.js +1 -1
  47. package/dist/knowledge/reward-risk.js +9 -9
  48. package/dist/knowledge/reward-templates.js +2 -2
  49. package/dist/knowledge/service-confirm.d.ts +15 -6
  50. package/dist/knowledge/service-confirm.js +119 -11
  51. package/dist/knowledge/service-context.js +1 -1
  52. package/dist/knowledge/service-ledger.js +1 -1
  53. package/dist/knowledge/service-risk.d.ts +1 -1
  54. package/dist/knowledge/service-risk.js +3 -3
  55. package/dist/knowledge/service-templates.js +2 -2
  56. package/dist/knowledge/service-translation.d.ts +1 -1
  57. package/dist/knowledge/service-translation.js +7 -7
  58. package/dist/knowledge/tool-constraints.js +6 -2
  59. package/dist/project/deployment-bridge.d.ts +1 -1
  60. package/dist/project/deployment-bridge.js +31 -7
  61. package/dist/project/deployment-doc.d.ts +3 -0
  62. package/dist/project/deployment-doc.js +76 -14
  63. package/dist/project/edit-planner.d.ts +123 -0
  64. package/dist/project/edit-planner.js +1371 -0
  65. package/dist/project/evaluation.d.ts +2 -0
  66. package/dist/project/evaluation.js +873 -88
  67. package/dist/project/graph-builder.d.ts +4 -1
  68. package/dist/project/graph-builder.js +132 -62
  69. package/dist/project/graph.d.ts +1 -0
  70. package/dist/project/handlers.d.ts +317 -6
  71. package/dist/project/handlers.js +1171 -19
  72. package/dist/project/stage-gate.d.ts +4 -0
  73. package/dist/project/stage-gate.js +64 -5
  74. package/dist/project/task-tracker.d.ts +26 -0
  75. package/dist/project/task-tracker.js +78 -0
  76. package/dist/safety/preview.js +16 -0
  77. package/dist/schema/call/allocation.d.ts +16 -16
  78. package/dist/schema/call/allocation.js +2 -2
  79. package/dist/schema/call/arbitration.js +19 -6
  80. package/dist/schema/call/base.d.ts +21 -13
  81. package/dist/schema/call/base.js +27 -6
  82. package/dist/schema/call/bridge.d.ts +5 -5
  83. package/dist/schema/call/bridge.js +3 -1
  84. package/dist/schema/call/contact.js +2 -2
  85. package/dist/schema/call/demand.d.ts +23 -31
  86. package/dist/schema/call/demand.js +2 -2
  87. package/dist/schema/call/guard.js +2 -2
  88. package/dist/schema/call/machine.d.ts +1976 -752
  89. package/dist/schema/call/machine.js +50 -4
  90. package/dist/schema/call/order.d.ts +149 -228
  91. package/dist/schema/call/order.js +4 -3
  92. package/dist/schema/call/payment.d.ts +183 -3
  93. package/dist/schema/call/payment.js +21 -3
  94. package/dist/schema/call/permission.js +2 -2
  95. package/dist/schema/call/personal.d.ts +241 -52
  96. package/dist/schema/call/progress.d.ts +53 -61
  97. package/dist/schema/call/progress.js +18 -4
  98. package/dist/schema/call/repository.d.ts +23 -31
  99. package/dist/schema/call/repository.js +2 -2
  100. package/dist/schema/call/reward.js +3 -3
  101. package/dist/schema/call/semantic.d.ts +1 -1
  102. package/dist/schema/call/semantic.js +37 -2
  103. package/dist/schema/call/service.d.ts +275 -127
  104. package/dist/schema/call/service.js +89 -13
  105. package/dist/schema/call/treasury.js +3 -3
  106. package/dist/schema/common/index.d.ts +13 -2
  107. package/dist/schema/common/index.js +80 -15
  108. package/dist/schema/local/index.d.ts +32 -35
  109. package/dist/schema/local/index.js +28 -6
  110. package/dist/schema/messenger/index.d.ts +274 -46
  111. package/dist/schema/operations.d.ts +1264 -544
  112. package/dist/schema/operations.js +65 -7
  113. package/dist/schema/project/index.d.ts +2846 -167
  114. package/dist/schema/project/index.js +570 -16
  115. package/dist/schema/query/index.d.ts +922 -349
  116. package/dist/schema/query/index.js +205 -42
  117. package/dist/schema/schema-query/index.d.ts +65 -3
  118. package/dist/schema/schema-query/index.js +38 -5
  119. package/dist/schema/utils/node-parser.js +20 -4
  120. package/dist/schema/utils/object-type-utils.d.ts +12 -0
  121. package/dist/schema/utils/object-type-utils.js +35 -0
  122. package/dist/schema/utils/permission-machine-check.d.ts +49 -0
  123. package/dist/schema/utils/permission-machine-check.js +121 -0
  124. package/dist/schema/utils/skills-recommendation.d.ts +2 -0
  125. package/dist/schema/utils/skills-recommendation.js +76 -0
  126. package/dist/schema-query/index.d.ts +20 -1
  127. package/dist/schema-query/index.js +306 -4
  128. package/dist/schemas/account_operation.output.json +7 -1
  129. package/dist/schemas/account_operation.schema.json +3 -3
  130. package/dist/schemas/bridge_operation.output.json +6 -0
  131. package/dist/schemas/bridge_operation.schema.json +1 -1
  132. package/dist/schemas/guard-templates.json +379 -0
  133. package/dist/schemas/guard2file.schema.json +1 -1
  134. package/dist/schemas/index.json +1 -1
  135. package/dist/schemas/local_info_operation.output.json +6 -0
  136. package/dist/schemas/local_mark_operation.output.json +7 -1
  137. package/dist/schemas/local_mark_operation.schema.json +1 -1
  138. package/dist/schemas/machineNode2file.schema.json +1 -1
  139. package/dist/schemas/messenger_operation.schema.json +4 -4
  140. package/dist/schemas/onchain_events.output.json +1 -1
  141. package/dist/schemas/onchain_operations.output.json +2820 -0
  142. package/dist/schemas/onchain_operations.schema.json +444 -330
  143. package/dist/schemas/onchain_operations_allocation.schema.json +37 -28
  144. package/dist/schemas/onchain_operations_arbitration.schema.json +16 -14
  145. package/dist/schemas/onchain_operations_contact.schema.json +10 -10
  146. package/dist/schemas/onchain_operations_demand.schema.json +10 -10
  147. package/dist/schemas/onchain_operations_gen_passport.schema.json +16 -16
  148. package/dist/schemas/onchain_operations_gen_proof.schema.json +2 -2
  149. package/dist/schemas/onchain_operations_guard.schema.json +2 -2
  150. package/dist/schemas/onchain_operations_machine.schema.json +43 -35
  151. package/dist/schemas/onchain_operations_order.schema.json +72 -78
  152. package/dist/schemas/onchain_operations_payment.schema.json +141 -111
  153. package/dist/schemas/onchain_operations_permission.schema.json +3 -3
  154. package/dist/schemas/onchain_operations_personal.schema.json +7 -7
  155. package/dist/schemas/onchain_operations_progress.schema.json +9 -9
  156. package/dist/schemas/onchain_operations_proof.schema.json +8 -8
  157. package/dist/schemas/onchain_operations_repository.schema.json +10 -10
  158. package/dist/schemas/onchain_operations_reward.schema.json +14 -14
  159. package/dist/schemas/onchain_operations_service.schema.json +119 -48
  160. package/dist/schemas/onchain_operations_treasury.schema.json +11 -11
  161. package/dist/schemas/onchain_table_data.output.json +33 -25
  162. package/dist/schemas/onchain_table_data.schema.json +22 -21
  163. package/dist/schemas/project_operation.output.json +2194 -23
  164. package/dist/schemas/project_operation.schema.json +84 -6
  165. package/dist/schemas/query_toolkit.output.json +108 -80
  166. package/dist/schemas/query_toolkit.schema.json +12 -12
  167. package/dist/schemas/schema_query.output.json +70 -3
  168. package/dist/schemas/schema_query.schema.json +18 -3
  169. package/dist/schemas/wowok_buildin_info.output.json +81 -8
  170. package/dist/schemas/wowok_buildin_info.schema.json +46 -2
  171. package/dist/tools/handlers/local.js +20 -5
  172. package/dist/tools/handlers/onchain.js +594 -6
  173. package/dist/tools/handlers/project.js +76 -4
  174. package/dist/tools/handlers/query.js +27 -0
  175. package/dist/tools/handlers/schema-query.js +43 -1
  176. package/dist/tools/handlers/task-status.d.ts +170 -0
  177. package/dist/tools/handlers/task-status.js +55 -0
  178. package/dist/tools/handlers/wip.js +47 -1
  179. package/dist/tools/index.d.ts +8 -0
  180. package/dist/tools/index.js +387 -12
  181. package/dist/tools/retry.d.ts +8 -0
  182. package/dist/tools/retry.js +85 -0
  183. package/dist/tools/wip-deploy-assist.d.ts +28 -0
  184. package/dist/tools/wip-deploy-assist.js +278 -0
  185. package/package.json +2 -2
  186. package/dist/schemas/guard-node-examples.md +0 -199
@@ -2,6 +2,7 @@ import { z } from "zod";
2
2
  const IndustryEnum = z.enum([
3
3
  "general",
4
4
  "retail",
5
+ "retail_d2c",
5
6
  "service",
6
7
  "rental",
7
8
  "freelance",
@@ -69,15 +70,30 @@ export const ProjectOperationInputSchema = z
69
70
  "get_object_diff",
70
71
  "delete_project",
71
72
  "assemble_context",
73
+ "get_machine_graph",
74
+ "get_guard_graph",
72
75
  "generate_deployment_doc",
76
+ "pre_evaluate_check",
77
+ "verify_deployment",
78
+ "clone_project_to_network",
79
+ "migrate_network",
80
+ "migrate_to_mainnet",
81
+ "plan_object_edit",
82
+ "apply_object_edit",
83
+ "patch_machine_nodes",
84
+ "patch_guard_tree",
73
85
  ])
74
86
  .describe("Action to perform. Two categories:\n" +
75
87
  "1. Project Entity + Evaluation (15, GLM6): list_projects, create_project, create_project_from_onchain, update_project, get_project_detail, add_object, remove_object, create_version, build_graph, get_graph, evaluate_project, save_evaluation, compare_projects, refresh_objects, get_object_diff. Projects are first-class entities with SQLite persistence, rigid project-object relationships, three-pathway graph construction, and a dual rule-based + LLM-assisted evaluation engine.\n" +
76
- "2. Context Assembly (1): assemble_context (query on-chain object states + extract embedded history + optional events, and assemble a structured semantic context for LLM consumption). Required input: context_objects (array of object IDs/names). Optional: include_events (query recent state-transition events)."),
88
+ "2. Context Assembly (1): assemble_context (query on-chain object states + extract embedded history + optional events, and assemble a structured semantic context for LLM consumption). Required input: context_objects (array of object IDs/names). Optional: include_events (query recent state-transition events).\n" +
89
+ "3. Cross-Network Migration (FIX-012): clone_project_to_network (or its alias migrate_network) copies a source project's object metadata to a new project bound to target_network. The 5-step migration workflow: 1) call clone_project_to_network (or migrate_network) with target_network to copy metadata, 2) re-run onchain_operations with env.network=target_network to deploy objects on-chain, 3) re-register LocalMark names with the SAME names on the target network (FIX-011 cross-network consistency), 4) update_project to set service_address on the new project, 5) build_graph to construct the new project's relationship graph."),
77
90
  project: z
78
91
  .string()
79
92
  .optional()
80
- .describe("Project prefix (human-readable unique identifier). Used by create_version, build_graph, evaluate_project, etc. Takes precedence resolution: project_id > project (prefix)."),
93
+ .describe("Project prefix (human-readable unique identifier). " +
94
+ "For create_project: OPTIONAL — if omitted, auto-derived from project_name (e.g. 'Twitch Service' → 'twitch_service'). " +
95
+ "For other actions (build_graph, evaluate_project, etc.): used to identify the project. " +
96
+ "Takes precedence resolution: project_id > project (prefix)."),
81
97
  version: z
82
98
  .string()
83
99
  .regex(/^v\d+$/)
@@ -118,7 +134,18 @@ export const ProjectOperationInputSchema = z
118
134
  .max(2000)
119
135
  .optional()
120
136
  .describe("Project description for create_project / update_project."),
121
- project_industry: IndustryEnum.optional().describe("Industry tag for create_project. Drives template defaults."),
137
+ project_industry: IndustryEnum.optional().describe("Industry tag for create_project. Drives template defaults — when set " +
138
+ "(and not 'general'), the system auto-applies an industry blueprint " +
139
+ "with ~10 draft objects (Permission, Service, Machine, Guard, Treasury, " +
140
+ "Allocation, etc.) + graph edges, ready for deployment. " +
141
+ "Supported industries: 'general' (no template), 'retail', 'retail_d2c' " +
142
+ "(Direct-to-Consumer, e.g., Shopify — Allocation escrow + 2 Guards), 'service', " +
143
+ "'rental', 'freelance', 'education', 'travel', 'subscription', 'custom'. " +
144
+ "Each industry preset embeds risk constraints (e.g., 'freelance' does " +
145
+ "NOT require compensation_fund, while 'rental'/'travel' do). " +
146
+ "Example: project_industry='freelance' creates a freelance-style " +
147
+ "blueprint with setting_locked_time ≥ 7d. " +
148
+ "Set skip_templates=true to bypass template application."),
122
149
  project_perspective: z
123
150
  .enum(["producer", "consumer", "both"])
124
151
  .optional()
@@ -135,6 +162,13 @@ export const ProjectOperationInputSchema = z
135
162
  .enum(["testnet", "mainnet"])
136
163
  .optional()
137
164
  .describe("Network the project is bound to. A Service deployed to different networks are different projects. Defaults to 'testnet'."),
165
+ skip_templates: z
166
+ .boolean()
167
+ .optional()
168
+ .describe("When true, create_project skips applying the industry template (no draft:* blueprint objects). " +
169
+ "Use this when you want a clean project with no pre-filled blueprint objects — useful for " +
170
+ "custom architectures that do not match any industry mode, or to avoid draft objects " +
171
+ "appearing in build_graph / evaluate_project before deployment. Defaults to false (templates applied)."),
138
172
  project_id: z
139
173
  .string()
140
174
  .optional()
@@ -143,10 +177,20 @@ export const ProjectOperationInputSchema = z
143
177
  .enum(["draft", "active", "inactive", "archived"])
144
178
  .optional()
145
179
  .describe("New status for update_project. 'active' projects are live, 'archived' are read-only."),
180
+ target_network: z
181
+ .enum(["testnet", "mainnet"])
182
+ .optional()
183
+ .describe("Target network for clone_project_to_network (or its alias migrate_network). " +
184
+ "The source project's objects are copied to a new project bound to this network. " +
185
+ "The new project's prefix is '<source_prefix>_<target_network>' to avoid collision. " +
186
+ "See the action description for the full 5-step migration workflow (FIX-012)."),
146
187
  object_address: z
147
188
  .string()
148
189
  .optional()
149
- .describe("On-chain object address (0x...) for add_object / remove_object. For add_object, alternatively use object_name to resolve via LocalMark."),
190
+ .describe("On-chain object address (0x followed by 32-64 hex chars) for add_object / remove_object. " +
191
+ "Also accepts the internal 'draft:<name>' sentinel used by create_project for blueprint objects not yet on-chain. " +
192
+ "For add_object, alternatively use object_name_add to resolve via LocalMark. " +
193
+ "H-06 fix: invalid formats are rejected at the handler level with a descriptive error."),
150
194
  object_name_add: z
151
195
  .string()
152
196
  .optional()
@@ -207,6 +251,13 @@ export const ProjectOperationInputSchema = z
207
251
  .max(5)
208
252
  .optional()
209
253
  .describe("Max recursion depth for Pathway 1 (internal reference derivation) in build_graph. Default 3."),
254
+ depth: z
255
+ .number()
256
+ .int()
257
+ .min(1)
258
+ .max(5)
259
+ .optional()
260
+ .describe("Alias for max_depth (build_graph). When both are set, max_depth takes precedence. Default 3."),
210
261
  enable_registrar: z
211
262
  .boolean()
212
263
  .optional()
@@ -215,6 +266,13 @@ export const ProjectOperationInputSchema = z
215
266
  .boolean()
216
267
  .optional()
217
268
  .describe("Enable Pathway 3 (potential relationship detection) in build_graph. Default false."),
269
+ async_mode: z
270
+ .boolean()
271
+ .optional()
272
+ .describe("When true, build_graph / evaluate_project runs in the background and returns { task_id } immediately. " +
273
+ "Poll query_task_status(task_id) to check progress and retrieve the result. " +
274
+ "Default false (synchronous). Use async_mode=true for large projects with enable_potential=true " +
275
+ "where build may take >10s."),
218
276
  evaluation_type: z
219
277
  .enum(["risk", "trust", "completeness", "value", "worth_buying"])
220
278
  .optional()
@@ -222,7 +280,11 @@ export const ProjectOperationInputSchema = z
222
280
  refresh_before_eval: z
223
281
  .boolean()
224
282
  .optional()
225
- .describe("When true, evaluate_project refreshes object cache from chain before evaluating. Default false."),
283
+ .describe("When true (DEFAULT), evaluate_project refreshes object cache from chain before evaluating. " +
284
+ "Set to false ONLY for read-only checks where staleness is acceptable (e.g., quick comparisons). " +
285
+ "BUG-P0-2 fix: previously defaulted to false, causing stale Machine node_count and other " +
286
+ "dynamic-field-derived fields to produce false findings (e.g., 'Machine has no nodes'). " +
287
+ "Now defaults to true — set refresh_before_eval=false explicitly to skip refresh."),
226
288
  eval_score: z
227
289
  .number()
228
290
  .min(0)
@@ -265,6 +327,64 @@ export const ProjectOperationInputSchema = z
265
327
  .boolean()
266
328
  .optional()
267
329
  .describe("When true (default), persist the generated MD to SQLite project_documents table for generate_deployment_doc."),
330
+ detail_level: z
331
+ .enum(["summary", "detailed", "full"])
332
+ .optional()
333
+ .describe("P2-03: Deployment document detail level (only for generate_deployment_doc). " +
334
+ "'summary' (default): object name + type + key bindings (machine, permission, buy_guard, order_allocators). " +
335
+ "'detailed': adds sale list, arbitration list, reward list. " +
336
+ "'full': complete fields including stock, price, wip_hash, all config. " +
337
+ "Use 'summary' for quick review; request 'detailed' or 'full' only when deeper inspection is needed."),
338
+ object_kind: z
339
+ .enum(["machine", "guard"])
340
+ .optional()
341
+ .describe("Object kind for plan_object_edit. 'machine' = Machine workflow directed graph (cycles allowed), 'guard' = Guard computation tree. " +
342
+ "Required when action='plan_object_edit'. Inferred from action for patch_machine_nodes (always 'machine') " +
343
+ "and patch_guard_tree (always 'guard')."),
344
+ edit_format: z
345
+ .enum(["tree_outline", "json"])
346
+ .optional()
347
+ .describe("Format of the edited content for plan_object_edit. " +
348
+ "'tree_outline' (default): the indented Markdown outline produced by get_machine_graph / get_guard_graph (human-editable). " +
349
+ "'json': raw JSON (machine-readable, for programmatic edits). " +
350
+ "Both formats are bidirectional with the parse functions in knowledge/machine-render.ts / guard-render.ts."),
351
+ edited_content: z
352
+ .string()
353
+ .optional()
354
+ .describe("Edited content for plan_object_edit. Must be in the format specified by edit_format. " +
355
+ "For 'tree_outline': the full tree_outline string from get_machine_graph/get_guard_graph with user edits. " +
356
+ "For 'json': a JSON string matching the Machine/Guard schema. " +
357
+ "The content is parsed + validated + diffed against the current on-chain state."),
358
+ plan_id: z
359
+ .string()
360
+ .optional()
361
+ .describe("Plan ID returned by plan_object_edit. Required for apply_object_edit. " +
362
+ "The plan is short-lived (10-minute TTL) and stored in-memory."),
363
+ expected_hash: z
364
+ .string()
365
+ .optional()
366
+ .describe("Expected hash returned by plan_object_edit. Required for apply_object_edit. " +
367
+ "Used for optimistic concurrency control: if the on-chain state changed between plan and apply, " +
368
+ "the hash will mismatch and apply will refuse to proceed (stale edit protection)."),
369
+ patch_operations: z
370
+ .array(z.string())
371
+ .optional()
372
+ .describe("Patch operations for patch_machine_nodes / patch_guard_tree. Each string is a single patch operation.\n" +
373
+ "Machine operations (13 total):\n" +
374
+ " 'add node <name>' | 'remove node <name>' | 'set description <node_name> <text...>'\n" +
375
+ " 'add edge <from> <to>' | 'remove edge <from> <to>' | 'set threshold <edge_from> <edge_to> <value>'\n" +
376
+ " 'add forward <edge_from> <edge_to> <forward_name>' | 'remove forward <edge_from> <edge_to> <forward_name>'\n" +
377
+ " 'set guard <edge_from> <edge_to> <forward_name> <guard_addr_or_name|none>'\n" +
378
+ " 'set permission <edge_from> <edge_to> <forward_name> <perm_index>'\n" +
379
+ " 'set operator <edge_from> <edge_to> <forward_name> <named_operator|none>'\n" +
380
+ " 'set weight <edge_from> <edge_to> <forward_name> <weight>'\n" +
381
+ " 'set retained_submission <edge_from> <edge_to> <forward_name> <comma_separated_indices|none>'\n" +
382
+ "Guard operations (8 total — see patch_guard_tree):\n" +
383
+ " 'add table <identifier> <name|none> <value_type> <b_submission> [json_value]'\n" +
384
+ " 'remove table <identifier>' | 'set table_value <identifier> [json_value|none]'\n" +
385
+ " 'set table_name <identifier> <name|none>' | 'set table_submission <identifier> <true|false>'\n" +
386
+ " 'set root <json_node>' | 'set rely <comma_separated_guard_addresses|none>'\n" +
387
+ "Operations are applied in order. Both patches are validated (validateMachine/validateGuard) before execution."),
268
388
  })
269
389
  .strict();
270
390
  const AssembleContextResultSchema = z
@@ -314,10 +434,10 @@ const ProjectObjectSchema = z
314
434
  .object({
315
435
  id: z.string().describe("ProjectObject UUID (project_objects.id)."),
316
436
  projectId: z.string().describe("Owning project UUID."),
317
- objectAddress: z.string().describe("On-chain object address (0x...)."),
437
+ objectAddress: z.string().describe("On-chain object address (0x...) or 'draft:<name>' sentinel for blueprint objects."),
318
438
  objectType: z.string().nullable().describe("Object type (Service, Machine, etc.) or null if unknown."),
319
439
  objectName: z.string().nullable().describe("LocalMark name or null."),
320
- role: z.enum(["core", "dependency", "reference"]).describe("Object role in project."),
440
+ role: z.string().describe("Object role in project. Valid values: 'core' (the Service), 'dependency' (required binding), 'reference' (optional/auxiliary). Other values indicate data corruption — see objectGroups.other bucket."),
321
441
  tags: z.array(z.string()).nullable().describe("Tags array or null."),
322
442
  addedAt: z.number().describe("Timestamp (ms) when added to project."),
323
443
  metadata: z.record(z.unknown()).nullable().describe("Arbitrary metadata key-value pairs or null."),
@@ -354,8 +474,31 @@ const ListProjectsResultSchema = z
354
474
  total: z.number().describe("Total number of projects returned."),
355
475
  })
356
476
  .strict();
477
+ const RecommendedCreationOrderItemSchema = z.object({
478
+ step: z.number().describe("Step number (1-based)."),
479
+ object: z.string().describe("Object type to create (e.g. 'Permission', 'Service (unpublished)')."),
480
+ reason: z.string().describe("Why this step is here, including dependencies and irreversibility notes."),
481
+ required: z.boolean().describe("Whether this step is mandatory for a working deployment."),
482
+ }).strict();
357
483
  const CreateProjectResultSchema = z
358
- .object({ action: z.literal("create_project"), project: ProjectSchema.describe("The created project.") })
484
+ .object({
485
+ action: z.literal("create_project"),
486
+ project: ProjectSchema.describe("The created project."),
487
+ recommended_creation_order: z.array(RecommendedCreationOrderItemSchema).describe("Canonical deployment sequence satisfying dependency constraints. " +
488
+ "All industries share this base order; see IndustryMode.build_notes for industry-specific deviations."),
489
+ blueprint: z.object({
490
+ objects_count: z.number().describe("Number of draft objects created from the template."),
491
+ edges_count: z.number().describe("Number of graph edges from the template."),
492
+ industry_source: z.string().describe("Industry mode name that sourced the template."),
493
+ applied_template: z.string().describe("Template identifier applied."),
494
+ steps_count: z.number().describe("Number of deployment steps in the template."),
495
+ scenarios_count: z.number().describe("Number of scenarios in the template."),
496
+ key_risk: z.string().nullable().optional().describe("Industry-specific key risk note (or null)."),
497
+ }).strict().optional().describe("Blueprint summary — present when industry template applied successfully. Objects have status='draft' and address='draft:<name>'."),
498
+ blueprint_warning: z.string().optional().describe("Warning message — present when industry template application failed. Project is created without blueprint; use add_object to manually add objects."),
499
+ blueprint_skipped: z.boolean().optional().describe("True when skip_templates=true was passed — no industry blueprint objects were created."),
500
+ hint: z.string().optional().describe("User-facing hint — guides to next action (e.g. add_object, generate_deployment_doc)."),
501
+ })
359
502
  .strict();
360
503
  const CreateProjectFromOnchainResultSchema = z
361
504
  .object({
@@ -395,8 +538,30 @@ const GetProjectDetailResultSchema = z
395
538
  .object({
396
539
  action: z.literal("get_project_detail"),
397
540
  project: ProjectSchema,
398
- objects: z.array(ProjectObjectSchema).describe("Project objects (rigid relationships)."),
541
+ objects: z.array(ProjectObjectSchema).describe("Project objects (rigid relationships). Flat list — use objectGroups for role-based navigation."),
542
+ objectGroups: z.object({
543
+ core: z.array(ProjectObjectSchema).describe("Core objects (the Service) — the primary deliverable of the project."),
544
+ dependency: z.array(ProjectObjectSchema).describe("Dependency objects (Permission, Machine, Guard, Allocation, Treasury, etc.) — required for the Service to function."),
545
+ reference: z.array(ProjectObjectSchema).describe("Reference objects (read-only or external) — tracked but not owned by this project."),
546
+ other: z.array(ProjectObjectSchema).describe("Objects with invalid or missing role (data corruption, legacy data). Grouped here for visibility — should normally be empty. Check server logs for warnings."),
547
+ stats: z.object({
548
+ total: z.number().describe("Total object count."),
549
+ core_count: z.number().describe("Number of core objects."),
550
+ dependency_count: z.number().describe("Number of dependency objects."),
551
+ reference_count: z.number().describe("Number of reference objects."),
552
+ other_count: z.number().describe("Number of objects with invalid/missing role (in 'other' bucket). Normally 0."),
553
+ by_type: z.record(z.string(), z.number()).describe("Object count grouped by objectType prefix (e.g. {'service': 1, 'permission': 1, 'guard': 5})."),
554
+ }).strict().describe("Aggregate counts for quick project sizing."),
555
+ }).strict().describe("Objects grouped by role (core/dependency/reference/other) for easier navigation. The 'other' bucket captures objects with invalid roles (H-05 fix). The flat `objects` array is preserved for backward compatibility."),
399
556
  graphEdgeCount: z.number().describe("Number of persisted graph edges."),
557
+ serviceStatus: z
558
+ .object({
559
+ published: z.boolean().nullable().describe("Whether the on-chain Service is published (live). null = unknown / query failed."),
560
+ paused: z.boolean().nullable().describe("Whether the on-chain Service is paused (not accepting orders). null = unknown."),
561
+ })
562
+ .strict()
563
+ .nullable()
564
+ .describe("On-chain Service status (published / paused). Separate from the project's local lifecycle status. null if the project has no serviceAddress or the on-chain query failed."),
400
565
  evaluations: z
401
566
  .array(z.object({
402
567
  id: z.string(),
@@ -441,11 +606,39 @@ const CreateVersionResultSchema = z
441
606
  const BuildGraphResultSchema = z
442
607
  .object({
443
608
  action: z.literal("build_graph"),
444
- nodeCount: z.number().describe("Total nodes in the constructed graph."),
445
- edgeCount: z.number().describe("Total edges (after conflict resolution + dedup)."),
446
- edgesBySource: z.record(z.string(), z.number()).describe("Edge counts by source: { internal: N, registrar: N, potential: N }."),
447
- reputationCount: z.number().describe("Number of objects with Registrar reputation data."),
448
- builtAt: z.number().describe("Build timestamp (ms)."),
609
+ async_mode: z.boolean().optional().describe("True when graph is building asynchronously (background task). When true, call query_task_status with task_id to retrieve the result."),
610
+ task_id: z.string().optional().describe("Async task id — present only when async_mode=true. Use with query_task_status."),
611
+ nodeCount: z.number().optional().describe("Total nodes in the constructed graph (sync mode only)."),
612
+ edgeCount: z.number().optional().describe("Total edges (after conflict resolution + dedup) (sync mode only)."),
613
+ edgesBySource: z.record(z.string(), z.number()).optional().describe("Edge counts by source: { internal: N, registrar: N, potential: N } (sync mode only)."),
614
+ reputationCount: z.number().optional().describe("Number of objects with Registrar reputation data (sync mode only)."),
615
+ builtAt: z.number().optional().describe("Build timestamp in ms (sync mode only)."),
616
+ binding_verification: z
617
+ .object({
618
+ service: z.string().describe("Service object address that was verified."),
619
+ bindings: z
620
+ .record(z.string(), z.object({
621
+ expected: z.string().describe("Expected target object type."),
622
+ actual: z.string().nullable().describe("Actual on-chain value (address or null)."),
623
+ count: z.number().optional().describe("Item count for array fields (order_allocators, arbitrations)."),
624
+ verified: z.boolean().describe("Whether the binding exists on-chain."),
625
+ }))
626
+ .describe("Per-field binding verification result."),
627
+ all_verified: z.boolean().describe("True when all critical bindings exist on-chain."),
628
+ })
629
+ .nullable()
630
+ .optional()
631
+ .describe("On-chain verification of Service bindings (F-15). Null when no Service address or query failed. Sync mode only."),
632
+ topEdges: z.array(z.object({
633
+ source: z.string().describe("Source object address."),
634
+ target: z.string().describe("Target object address."),
635
+ fieldName: z.string().nullable().describe("Field name on the source object (or null)."),
636
+ relationshipType: z.string().describe("Relationship type (bind, create, trigger, etc.)."),
637
+ weight: z.number().nullable().describe("Edge weight (0-1, higher = more important)."),
638
+ verified: z.boolean().describe("Whether the edge has been verified on-chain."),
639
+ }).strict()).optional().describe("Top 5 critical edges by weight (sync mode only). Preview of the most important relationships — call get_graph for the full list."),
640
+ visualization: z.string().optional().describe("Mermaid-style ASCII visualization of top edges (sync mode only). Compact format: 'source --field--> target'."),
641
+ hint: z.string().optional().describe("User-facing hint — guides to next action (e.g. call get_graph for full list, or query_task_status for async result)."),
449
642
  })
450
643
  .strict();
451
644
  const GetGraphResultSchema = z
@@ -550,10 +743,356 @@ const GenerateDeploymentDocResultSchema = z
550
743
  description: z.string(),
551
744
  status: z.enum(["PASS", "FAIL", "WARN"]),
552
745
  notes: z.string().optional(),
553
- }).strict()).describe("D-01..D-18 check results."),
746
+ }).strict()).describe("D-01..D-20 check results (20 deployment checks including D-19 Machine entry-node forward and D-20 Service compensation_fund)."),
554
747
  errors: z.array(z.string()).describe("List of FAIL error messages."),
555
- }).strict().describe("Deployment doc validation result against D-01..D-18."),
748
+ }).strict().describe("Deployment doc validation result against D-01..D-20."),
556
749
  saved: z.boolean().describe("Whether the markdown was persisted to SQLite project_documents table."),
750
+ detail_level: z.enum(["summary", "detailed", "full"]).describe("Effective detail level used to render the deployment doc. " +
751
+ "'summary' (default) shows only key bindings; 'detailed' adds sale/arbitration lists; 'full' shows complete config."),
752
+ stage_gate: z.object({
753
+ stage: z.number().describe("The stage that was validated (4 = deployment doc generation gate)."),
754
+ passed: z.boolean().describe("True iff no FAIL checks exist — gate allows advancing to Stage 5."),
755
+ can_proceed: z.boolean().describe("Alias for `passed` — whether the stage gate allows advancement."),
756
+ blocking_issues: z.array(z.string()).describe("FAIL status messages — must be resolved before deploying."),
757
+ warnings: z.array(z.string()).describe("WARN status messages — non-blocking, user may proceed at own risk."),
758
+ checks: z.array(z.object({
759
+ dimension: z.enum(["semantic", "tools", "reversibility", "risk", "isolation", "gas_budget"]).describe("The validation dimension."),
760
+ status: z.enum(["PASS", "WARN", "FAIL"]).describe("Check result status."),
761
+ message: z.string().describe("Human-readable check result message."),
762
+ }).strict()).describe("Per-dimension check results."),
763
+ }).strict().describe("Stage gate validation (GLM6 5-stage lifecycle handoff). Validates Stage 3 risk score threshold (>=80 PASS, >=50 WARN, <50 FAIL) and Stage 4 deployment doc generation prerequisite."),
764
+ deployment_scan: z.object({
765
+ overall_readiness: z.enum(["ready", "blocked", "warnings"]).describe("'ready' = all 20 checks pass; 'blocked' = any critical fail; 'warnings' = only warning fails."),
766
+ critical_count: z.number().describe("Number of critical findings (blocks deployment)."),
767
+ warning_count: z.number().describe("Number of warning findings (non-blocking)."),
768
+ findings: z.array(z.object({
769
+ check_id: z.string().describe("D-XX check id (e.g. 'D-19') or sub-id (e.g. 'D-10a')."),
770
+ severity: z.enum(["critical", "warning", "info"]).describe("Finding severity."),
771
+ message: z.string().describe("Human-readable finding message."),
772
+ location: z.string().optional().describe("Document location (section, line, or step id)."),
773
+ suggestion: z.string().optional().describe("Suggested fix."),
774
+ }).strict()).describe("All findings from the 20 D-XX deployment checks."),
775
+ checks: z.object({
776
+ D01_object_defined: z.enum(["pass", "fail"]),
777
+ D02_dependency_complete: z.enum(["pass", "fail"]),
778
+ D03_scenario_covered: z.enum(["pass", "fail"]),
779
+ D04_testnet_topo_order: z.enum(["pass", "fail"]),
780
+ D05_testnet_network: z.enum(["pass", "fail"]),
781
+ D06_testnet_replace: z.enum(["pass", "fail"]),
782
+ D07_permission_index: z.enum(["pass", "fail"]),
783
+ D08_guard_gen_passport: z.enum(["pass", "fail"]),
784
+ D09_machine_node_count: z.enum(["pass", "fail"]),
785
+ D10_substep_coherence: z.enum(["pass", "fail"]),
786
+ D11_mainnet_testnet_match: z.enum(["pass", "fail"]),
787
+ D12_mainnet_network: z.enum(["pass", "fail"]),
788
+ D13_mainnet_replace: z.enum(["pass", "fail"]),
789
+ D14_testnet_verification: z.enum(["pass", "fail"]),
790
+ D15_mainnet_verification: z.enum(["pass", "fail"]),
791
+ D16_no_critical_risk: z.enum(["pass", "fail"]),
792
+ D17_no_high_risk: z.enum(["pass", "fail"]),
793
+ D18_completeness_checklist: z.enum(["pass", "fail"]),
794
+ D19_machine_entry_forward: z.enum(["pass", "fail"]).describe("Machine entry node (prev_node='') forwards non-empty — avoids Progress stuck at current=''."),
795
+ D20_service_compensation_fund: z.enum(["pass", "fail"]).describe("Service compensation_fund (Balance<T>) present or industry-exempt — ensures arbitration refund capability."),
796
+ }).strict().describe("Per-check pass/fail status for all 20 D-XX checks."),
797
+ }).strict().describe("Deployment scanner result — 20 D-XX checks including D-19 (Machine entry forward) and D-20 (Service compensation_fund)."),
798
+ })
799
+ .strict();
800
+ const PreEvaluateCheckResultSchema = z
801
+ .object({
802
+ action: z.literal("pre_evaluate_check"),
803
+ ready: z.boolean().describe("True if evaluate_project will produce meaningful results (no hard blockers). " +
804
+ "If false, address the items in `missing` first."),
805
+ missing: z.array(z.object({
806
+ id: z.string().describe("Check ID (e.g. PE-01, PE-06)."),
807
+ description: z.string().describe("What is missing."),
808
+ impact: z.string().describe("How it affects the evaluation, and how to fix it."),
809
+ }).strict()).describe("Hard blockers — must be resolved before evaluation."),
810
+ warnings: z.array(z.object({
811
+ id: z.string().describe("Check ID (e.g. PE-02, PE-03)."),
812
+ description: z.string().describe("What is suboptimal."),
813
+ impact: z.string().describe("How it affects the evaluation, and how to improve it."),
814
+ }).strict()).describe("Soft issues — evaluation runs but quality may be reduced."),
815
+ summary: z.string().describe("One-line human-readable status."),
816
+ counts: z.object({
817
+ objects: z.number().describe("Total project_objects count."),
818
+ edges: z.number().describe("Total graph_edges count."),
819
+ uncached: z.number().describe("Objects with no cached on-chain data."),
820
+ stale: z.number().describe("Objects with cache older than 24 hours."),
821
+ dangling_edges: z.number().describe("Edges referencing objects not in project_objects."),
822
+ drafts: z.number().describe("Objects still in draft (not yet on-chain)."),
823
+ }).strict().describe("Quick-scan counts for triage."),
824
+ })
825
+ .strict();
826
+ const VerifyDeploymentResultSchema = z
827
+ .object({
828
+ action: z.literal("verify_deployment"),
829
+ verifiedCount: z.number().describe("Number of objects actually verified (excludes drafts and unreachable)."),
830
+ matched: z.number().describe("Objects whose on-chain state matches SQLite."),
831
+ mismatched: z.number().describe("Objects whose on-chain state differs from SQLite (see `results[].differences`)."),
832
+ missing: z.number().describe("Objects that no longer exist on-chain (deleted or never deployed)."),
833
+ unreachable: z.number().describe("Objects that could not be queried (network error)."),
834
+ results: z.array(z.object({
835
+ objectAddress: z.string(),
836
+ objectName: z.string().nullable(),
837
+ objectType: z.string().nullable(),
838
+ status: z.enum(["matched", "mismatched", "missing", "unreachable"]).describe("Verification status: 'matched' = on-chain matches SQLite; " +
839
+ "'mismatched' = on-chain differs (see differences); " +
840
+ "'missing' = object no longer exists on-chain; " +
841
+ "'unreachable' = query failed (network error or rate limit)."),
842
+ differences: z.array(z.object({
843
+ field: z.string().describe("Field path that differs."),
844
+ sqlite: z.unknown().describe("Value recorded in SQLite."),
845
+ onchain: z.unknown().describe("Value observed on-chain."),
846
+ }).strict()).optional().describe("Per-field differences (only for status='mismatched')."),
847
+ bindings: z.object({
848
+ machine: z.boolean(),
849
+ permission: z.boolean(),
850
+ buy_guard: z.boolean(),
851
+ order_allocators: z.boolean(),
852
+ }).strict().optional().describe("Critical binding status (only for Service objects). " +
853
+ "Each boolean indicates whether the binding is set to a non-null value on-chain."),
854
+ error: z.string().optional().describe("Error message (only for status='unreachable')."),
855
+ }).strict()).describe("Per-object verification results."),
856
+ summary: z.string().describe("One-line human-readable summary."),
857
+ })
858
+ .strict();
859
+ const MachineGraphForwardSchema = z.object({
860
+ name: z.string().describe("Forward name."),
861
+ weight: z.number().describe("Forward weight (for weighted threshold)."),
862
+ guard: z.string().nullable().describe("Guard object address if the forward is guard-gated, else null."),
863
+ named_operator: z.string().nullable().describe("Named operator if set, else null."),
864
+ permission_index: z.number().nullable().describe("Permission index if set, else null."),
865
+ }).strict();
866
+ const MachineGraphEdgeSchema = z.object({
867
+ from: z.string().describe("Source node name (prev_node)."),
868
+ to: z.string().describe("Target node name (next_node)."),
869
+ threshold: z.number().describe("Minimum weighted forward count required to advance."),
870
+ forwards: z.array(MachineGraphForwardSchema).describe("Forwards within this pair — each is an advance operation."),
871
+ }).strict();
872
+ const MachineGraphNodeSchema = z.object({
873
+ name: z.string().describe("Node name."),
874
+ description: z.string().nullable().describe("Node description if set, else null."),
875
+ }).strict();
876
+ const GetMachineGraphResultSchema = z
877
+ .object({
878
+ action: z.literal("get_machine_graph"),
879
+ machineAddress: z.string().describe("The Machine object address."),
880
+ machineName: z.string().nullable().describe("The Machine's local name (from LocalMark) if available."),
881
+ nodes: z.array(MachineGraphNodeSchema).describe("Workflow nodes (states)."),
882
+ edges: z.array(MachineGraphEdgeSchema).describe("Directed edges (pairs) connecting nodes. Each edge has a threshold and forwards."),
883
+ published: z.boolean().nullable().describe("Whether the Machine is published (locked for production). null = unknown."),
884
+ paused: z.boolean().nullable().describe("Whether the Machine is paused (not generating new Progress). null = unknown."),
885
+ mermaid: z.string().describe("Mermaid stateDiagram-v2 string visualizing the directed graph. Entry nodes start from [*]. Edge labels include forward name + threshold + guard info. Cycles (revision loops) are rendered as normal edges. Includes a color legend comment block + BehaviorTree.CPP-style color annotations (entry=green, terminal=red, revision=amber, normal=blue). Renderable in markdown viewers."),
886
+ tree_outline: z.string().describe("Indented Markdown outline of the directed graph (human-editable format). Lists edges as outline entries with forwards nested under each edge. Includes a Backrefs section consolidating incoming edges per node (editing aid — answers 'who transitions INTO node X?'). Bidirectional with parseMachineTreeIndented(). Includes JSON code block for round-trip safety. Use this for the download -> edit -> republish workflow."),
887
+ ascii_art: z.string().describe("ASCII art directed graph visualization using arrow notation (A -forward-> B). Cycle (revision loop) and terminal annotations included. Terminal-friendly, avoids JSON escaping issues that affect multi-line Mermaid strings. Use when rendering in plain-text contexts."),
888
+ markmap: z.string().describe("Markmap-compatible Markdown string (heading levels represent hierarchy). Edge-centric layout with forwards nested under edges. Renderable by VS Code Markmap extension or markmap.js. Provides an interactive mind-map view of the workflow."),
889
+ })
890
+ .strict();
891
+ const GuardGraphNodeSchema = z.lazy(() => z.object({
892
+ type: z.string().describe("Guard node type (logic_and, query, identifier, context, calc_*, convert_*, vec_*, etc.)."),
893
+ nodes: z.array(GuardGraphNodeSchema).optional().describe("Child nodes (for logic_and/or, calc_*, vec_contains_*, etc.)."),
894
+ node: GuardGraphNodeSchema.optional().describe("Single child (for logic_not, convert_*, value_type)."),
895
+ nodeLeft: GuardGraphNodeSchema.optional().describe("Left child (for vec_indexof_*)."),
896
+ nodeRight: GuardGraphNodeSchema.optional().describe("Right child (for vec_indexof_*)."),
897
+ query: z.union([z.number(), z.string()]).optional().describe("Query instruction ID or name (for query nodes)."),
898
+ object: z.object({
899
+ identifier: z.number().optional(),
900
+ convert_witness: z.number().optional(),
901
+ }).optional().describe("Query target object reference."),
902
+ parameters: z.array(GuardGraphNodeSchema).optional().describe("Query parameters."),
903
+ identifier: z.number().optional().describe("Table entry index (for identifier nodes)."),
904
+ context: z.string().optional().describe("Context type: Signer, Clock, or Guard."),
905
+ }).strict());
906
+ const GuardTableEntrySchema = z.object({
907
+ identifier: z.number().describe("Table entry index (0-255)."),
908
+ b_submission: z.boolean().describe("Whether this entry is submitted at runtime."),
909
+ value_type: z.union([z.number(), z.string()]).describe("Value type (numeric code or name)."),
910
+ value: z.unknown().optional().describe("Constant value (if b_submission=false)."),
911
+ name: z.string().optional().describe("Human-readable name/description."),
912
+ }).strict();
913
+ const GetGuardGraphResultSchema = z
914
+ .object({
915
+ action: z.literal("get_guard_graph"),
916
+ guardAddress: z.string().describe("The Guard object address."),
917
+ guardName: z.string().nullable().describe("The Guard's local name (from LocalMark) if available."),
918
+ root: GuardGraphNodeSchema.describe("Root computation node (returns Bool). The tree is recursive — each node may have children."),
919
+ table: z.array(GuardTableEntrySchema).describe("Guard data table entries (constants + submission slots)."),
920
+ rely: z.object({
921
+ guards: z.array(z.string()),
922
+ logic_or: z.boolean().optional(),
923
+ }).nullable().describe("Rely dependencies (other Guards this Guard depends on). null = no rely."),
924
+ immutable: z.boolean().nullable().describe("Whether the Guard is immutable (frozen for verification). null = unknown."),
925
+ mermaid: z.string().describe("Mermaid flowchart TD string visualizing the tree. Node shapes: {}=decision (logic_*), []=computation/query, ([])=leaf (identifier), {{}}=context. Includes a color legend comment block + BehaviorTree.CPP-style color annotations (control=blue, decision=amber, computation=purple, query=cyan, leaf=gray, context=green)."),
926
+ tree_outline: z.string().describe("Indented Markdown outline of the tree (human-editable format). Bidirectional with parseGuardTreeIndented(). Includes JSON code block for round-trip safety."),
927
+ ascii_art: z.string().describe("ASCII art tree visualization using box-drawing characters (+-- --, |). Table summary appended. Terminal-friendly, avoids JSON escaping issues that affect multi-line Mermaid strings."),
928
+ markmap: z.string().describe("Markmap-compatible Markdown string (heading levels represent tree depth). Root -> branches -> leaves hierarchy. Renderable by VS Code Markmap extension or markmap.js. Provides an interactive mind-map view of the Guard tree."),
929
+ })
930
+ .strict();
931
+ const PlanObjectEditResultSchema = z
932
+ .object({
933
+ action: z.literal("plan_object_edit"),
934
+ plan_id: z.string().describe("Unique plan ID (UUID). Pass to apply_object_edit within 10 minutes to execute."),
935
+ object_kind: z.enum(["machine", "guard"]).describe("The object kind that was edited."),
936
+ object_address: z.string().describe("The on-chain object address being edited."),
937
+ object_name: z.string().nullable().describe("The object's local name (from LocalMark) if available."),
938
+ expected_hash: z.string().describe("SHA-256 hash of (current_onchain_state + edited_content). Pass to apply_object_edit as expected_hash for stale-edit detection."),
939
+ diff: z.object({
940
+ added: z.array(z.string()).describe("List of added items (node names, edge 'from->to', table identifiers, etc.)."),
941
+ removed: z.array(z.string()).describe("List of removed items."),
942
+ modified: z.array(z.string()).describe("List of modified items with a brief description of the change."),
943
+ summary: z.string().describe("Human-readable one-line diff summary (e.g. '2 nodes added, 1 edge removed, 3 forwards modified')."),
944
+ }).describe("Structured diff between current on-chain state and edited content."),
945
+ warnings: z.array(z.object({
946
+ id: z.string().describe("Warning identifier (e.g. 'W-01')."),
947
+ description: z.string().describe("What the warning is about."),
948
+ impact: z.string().describe("Potential impact if ignored."),
949
+ })).describe("Non-blocking warnings (the edit can still proceed, but review is recommended)."),
950
+ blocking_errors: z.array(z.object({
951
+ id: z.string().describe("Error identifier (e.g. 'E-01')."),
952
+ description: z.string().describe("What the error is."),
953
+ impact: z.string().describe("Why this blocks execution."),
954
+ })).describe("Blocking errors (the edit CANNOT proceed until these are fixed)."),
955
+ can_apply: z.boolean().describe("Whether apply_object_edit can proceed. false if blocking_errors is non-empty."),
956
+ prepared_call: z.unknown().nullable().describe("The prepared onchain_operations call data (operation_type + data). null if can_apply=false. Pass this to onchain_operations to execute the edit."),
957
+ expires_at: z.string().describe("ISO timestamp when the plan expires (10 minutes from creation). After expiry, apply_object_edit will refuse to proceed."),
958
+ summary: z.string().describe("Human-readable one-line plan summary."),
959
+ })
960
+ .strict();
961
+ const ApplyObjectEditResultSchema = z
962
+ .object({
963
+ action: z.literal("apply_object_edit"),
964
+ plan_id: z.string().describe("The plan ID that was applied."),
965
+ applied: z.boolean().describe("Whether the plan was successfully applied (hash matched and plan was fresh)."),
966
+ hash_match: z.boolean().describe("Whether the expected_hash matched the stored plan hash. false = stale edit detected."),
967
+ prepared_call: z.unknown().nullable().describe("The prepared onchain_operations call data. Pass this to onchain_operations to execute the edit on-chain. null if applied=false."),
968
+ error: z.string().nullable().describe("Error message if applied=false (e.g. 'Plan not found', 'Hash mismatch — on-chain state changed', 'Plan expired'). null on success."),
969
+ next_step: z.string().describe("Instructions for the next step (typically 'Pass prepared_call to onchain_operations to execute the edit on-chain')."),
970
+ })
971
+ .strict();
972
+ const PatchMachineNodesResultSchema = z
973
+ .object({
974
+ action: z.literal("patch_machine_nodes"),
975
+ machine_address: z.string().describe("The Machine object address being patched."),
976
+ machine_name: z.string().nullable().describe("The Machine's local name (from LocalMark) if available."),
977
+ operations_applied: z.number().describe("Number of patch operations successfully applied."),
978
+ operations_failed: z.array(z.object({
979
+ operation: z.string().describe("The original operation string."),
980
+ error: z.string().describe("Why the operation failed."),
981
+ })).describe("Operations that failed parse/apply (not applied). Also surfaced as E-OP entries in blocking_errors for schema symmetry with plan_object_edit."),
982
+ patched_nodes: z.array(z.unknown()).describe("The patched Machine nodes (after applying all successful operations)."),
983
+ patched_edges: z.array(z.unknown()).describe("The patched Machine edges (after applying all successful operations)."),
984
+ diff: z.object({
985
+ added: z.array(z.string()).describe("List of added items."),
986
+ removed: z.array(z.string()).describe("List of removed items."),
987
+ modified: z.array(z.string()).describe("List of modified items."),
988
+ summary: z.string().describe("Human-readable one-line diff summary."),
989
+ }).describe("Diff between original and patched Machine."),
990
+ warnings: z.array(z.object({
991
+ id: z.string().describe("Warning identifier (e.g. 'W-01' unreachable node, 'W-02' self-loop)."),
992
+ description: z.string().describe("What the warning is about."),
993
+ impact: z.string().describe("Potential impact if ignored."),
994
+ })).describe("Non-blocking warnings from validateMachine (W-01 unreachable, W-02 self-loop)."),
995
+ blocking_errors: z.array(z.object({
996
+ id: z.string().describe("Error identifier (e.g. 'E-01' no entry forward, 'E-02' orphan endpoint, 'E-03' too many nodes, 'E-OP' operation failed)."),
997
+ description: z.string().describe("What the error is."),
998
+ impact: z.string().describe("Why this blocks execution."),
999
+ })).describe("Blocking errors (operation failures + structural validation). The patch CANNOT proceed until these are fixed. Empty array when can_apply=true."),
1000
+ can_apply: z.boolean().describe("Whether the patch can be applied on-chain. false if any blocking_errors exist (operation failures or validateMachine blocking errors)."),
1001
+ prepared_call: z.unknown().nullable().describe("The prepared onchain_operations call data. null if can_apply=false."),
1002
+ summary: z.string().describe("Human-readable one-line patch summary."),
1003
+ })
1004
+ .strict();
1005
+ const PatchGuardTreeResultSchema = z
1006
+ .object({
1007
+ action: z.literal("patch_guard_tree"),
1008
+ guard_address: z.string().describe("The Guard object address being patched."),
1009
+ guard_name: z.string().nullable().describe("The Guard's local name (from LocalMark) if available."),
1010
+ operations_applied: z.number().describe("Number of Guard patch operations successfully applied."),
1011
+ operations_failed: z.array(z.object({
1012
+ operation: z.string().describe("The original operation string."),
1013
+ error: z.string().describe("Why the operation failed."),
1014
+ })).describe("Operations that failed parse/apply (not applied). Also surfaced as E-OP entries in blocking_errors."),
1015
+ patched_root: z.unknown().describe("The patched Guard root node (after applying all successful operations). For set_root, this is the new root; otherwise the original root unchanged."),
1016
+ patched_table: z.array(z.unknown()).describe("The patched Guard table entries (after applying all successful table operations)."),
1017
+ patched_rely: z.unknown().nullable().describe("The patched rely field (cross-guard composition). null if rely was cleared or never set. Shape: { guards: string[], logic_or?: boolean }."),
1018
+ diff: z.object({
1019
+ added: z.array(z.string()).describe("List of added items (table entries, tree nodes)."),
1020
+ removed: z.array(z.string()).describe("List of removed items."),
1021
+ modified: z.array(z.string()).describe("List of modified items with a brief description of the change."),
1022
+ summary: z.string().describe("Human-readable one-line diff summary."),
1023
+ }).describe("Diff between original and patched Guard (root tree + table)."),
1024
+ warnings: z.array(z.object({
1025
+ id: z.string().describe("Warning identifier (e.g. 'W-01' dead submission slot, 'W-02' orphan table entry, 'W-03' deep nesting)."),
1026
+ description: z.string().describe("What the warning is about."),
1027
+ impact: z.string().describe("Potential impact if ignored."),
1028
+ })).describe("Non-blocking warnings from validateGuard (W-01 dead submission slot, W-02 orphan table entry, W-03 deep nesting > 16)."),
1029
+ blocking_errors: z.array(z.object({
1030
+ id: z.string().describe("Error identifier (e.g. 'E-01' no root, 'E-02' identifier not in table, 'E-03' table too large, 'E-OP' operation failed)."),
1031
+ description: z.string().describe("What the error is."),
1032
+ impact: z.string().describe("Why this blocks execution."),
1033
+ })).describe("Blocking errors (operation failures + structural validation). The patch CANNOT proceed until these are fixed. Empty array when can_apply=true."),
1034
+ can_apply: z.boolean().describe("Whether the patch can be applied on-chain. false if any blocking_errors exist."),
1035
+ prepared_call: z.unknown().nullable().describe("The prepared onchain_operations call data (operation_type='guard'). null if can_apply=false."),
1036
+ summary: z.string().describe("Human-readable one-line patch summary."),
1037
+ })
1038
+ .strict();
1039
+ const CloneProjectToNetworkResultSchema = z
1040
+ .object({
1041
+ action: z.literal("clone_project_to_network"),
1042
+ new_project_id: z.string().describe("The newly created project's UUID."),
1043
+ new_prefix: z.string().describe("New project prefix ('<source_prefix>_<target_network>')."),
1044
+ target_network: z.enum(["testnet", "mainnet"]).describe("The target network the new project is bound to."),
1045
+ cloned_objects_count: z.number().describe("Number of object metadata entries copied (objectAddress is empty — await on-chain deployment)."),
1046
+ message: z.string().describe("Human-readable summary of the clone operation."),
1047
+ next_steps: z.string().describe("Instructions for deploying the cloned objects on the target network."),
1048
+ })
1049
+ .strict();
1050
+ const MigrateNetworkResultSchema = z
1051
+ .object({
1052
+ action: z.literal("migrate_network"),
1053
+ new_project_id: z.string().describe("The newly created project's UUID."),
1054
+ new_prefix: z.string().describe("New project prefix ('<source_prefix>_<target_network>')."),
1055
+ target_network: z.enum(["testnet", "mainnet"]).describe("The target network the new project is bound to."),
1056
+ cloned_objects_count: z.number().describe("Number of object metadata entries copied (objectAddress is empty — await on-chain deployment)."),
1057
+ message: z.string().describe("Human-readable summary of the migration operation."),
1058
+ next_steps: z.string().describe("Instructions for deploying the migrated objects on the target network."),
1059
+ })
1060
+ .strict();
1061
+ const MigrationPlanStepSchema = z.object({
1062
+ step: z.number().describe("Step number (1-5)."),
1063
+ status: z.enum(["completed", "pending_user_action"]).describe("Whether this step is done or awaits user action."),
1064
+ action: z.string().describe("The action to perform (e.g. 'clone_project_to_network', 'onchain_operations', 'local_mark_operation', 'update_project', 'build_graph')."),
1065
+ description: z.string().describe("Human-readable description of what this step does."),
1066
+ result: z.string().optional().describe("Result of this step (only present when status='completed')."),
1067
+ deployment_plan: z.array(z.object({
1068
+ order: z.number(),
1069
+ object_type: z.string(),
1070
+ object_name: z.string(),
1071
+ operation_type: z.string(),
1072
+ localmark_name: z.string(),
1073
+ note: z.string(),
1074
+ })).optional().describe("Deployment plan for step 2 (on-chain deployment). Only present for step 2."),
1075
+ names_to_register: z.array(z.string()).optional().describe("LocalMark names to re-register on mainnet. Only present for step 3."),
1076
+ critical_note: z.string().optional().describe("Critical note for this step."),
1077
+ }).strict();
1078
+ const MigrateToMainnetResultSchema = z
1079
+ .object({
1080
+ action: z.literal("migrate_to_mainnet"),
1081
+ migration_status: z.string().describe("Overall migration status (e.g. 'step_1_complete_steps_2_5_pending_user_action')."),
1082
+ source_project: z.object({
1083
+ prefix: z.string(),
1084
+ network: z.string(),
1085
+ preserved: z.boolean().describe("Whether the source project is preserved unchanged (always true)."),
1086
+ }).strict(),
1087
+ target_project: z.object({
1088
+ prefix: z.string(),
1089
+ project_id: z.string(),
1090
+ network: z.string(),
1091
+ cloned_objects_count: z.number(),
1092
+ }).strict(),
1093
+ key_principle: z.string().describe("Explains that testnet/mainnet are different projects with different addresses for same names."),
1094
+ migration_plan: z.array(MigrationPlanStepSchema).describe("5-step migration plan. Step 1 is completed; steps 2-5 require user action."),
1095
+ summary: z.string().describe("Human-readable summary of the migration."),
557
1096
  })
558
1097
  .strict();
559
1098
  export const ProjectOperationOutputSchema = z
@@ -578,6 +1117,21 @@ export const ProjectOperationOutputSchema = z
578
1117
  DeleteProjectResultSchema,
579
1118
  AssembleContextResultSchema,
580
1119
  GenerateDeploymentDocResultSchema,
1120
+ PreEvaluateCheckResultSchema,
1121
+ VerifyDeploymentResultSchema,
1122
+ GetMachineGraphResultSchema,
1123
+ GetGuardGraphResultSchema,
1124
+ PlanObjectEditResultSchema,
1125
+ ApplyObjectEditResultSchema,
1126
+ PatchMachineNodesResultSchema,
1127
+ PatchGuardTreeResultSchema,
1128
+ CloneProjectToNetworkResultSchema,
1129
+ MigrateNetworkResultSchema,
1130
+ MigrateToMainnetResultSchema,
581
1131
  ]).describe("Query result — shape depends on action"),
1132
+ skills_recommended: z.string().optional().describe("Skills recommendation hint (F-10). Informational only — MCP executes " +
1133
+ "independently of skills. Present when the action benefits from skills' " +
1134
+ "business-semantic guidance (e.g. service/machine/guard/evaluation). " +
1135
+ "Users without skills installed can ignore this field."),
582
1136
  })
583
1137
  .strict();