@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
@@ -1,9 +1,14 @@
1
1
  import { assembleContext } from "../../project/context-assembly.js";
2
2
  import { generateDeploymentDocFromProject } from "../../project/deployment-bridge.js";
3
3
  import { LocalProject } from "@wowok/wowok";
4
- import { handleListProjects, handleCreateProject, handleCreateProjectFromOnchain, handleUpdateProject, handleGetProjectDetail, handleAddObject, handleRemoveObject, handleUpdateObject, handleCreateVersion, handleBuildGraph, handleGetGraph, handleEvaluateProject, handleSaveEvaluation, handleCompareProjects, handleRefreshObjects, handleGetObjectDiff, handleDeleteProject, } from "../../project/handlers.js";
4
+ import { validateStageGate } from "../../project/stage-gate.js";
5
+ import { scanDeployment } from "../../knowledge/deployment-scanner.js";
6
+ import { handleListProjects, handleCreateProject, handleCreateProjectFromOnchain, handleUpdateProject, handleGetProjectDetail, handleAddObject, handleRemoveObject, handleUpdateObject, handleCreateVersion, handleBuildGraph, handleGetGraph, handleEvaluateProject, handleSaveEvaluation, handleCompareProjects, handleRefreshObjects, handleGetObjectDiff, handleDeleteProject, handleGetMachineGraph, handleGetGuardGraph, handlePreEvaluateCheck, handleVerifyDeployment, handleCloneProjectToNetwork, handleMigrateToMainnet, } from "../../project/handlers.js";
7
+ import { handlePlanObjectEdit, handleApplyObjectEdit, handlePatchMachineNodes, handlePatchGuardTree, } from "../../project/edit-planner.js";
5
8
  import { strictParse } from "../../schema/index.js";
6
9
  import { ProjectOperationInputSchema } from "../../schema/project/index.js";
10
+ import { getStageCache } from "../../project/index.js";
11
+ import { getSkillsHintForProject } from "../../schema/utils/skills-recommendation.js";
7
12
  export async function handleProjectOperation(args) {
8
13
  const validated = strictParse(ProjectOperationInputSchema, args, "project_operation input");
9
14
  const { action } = validated;
@@ -60,34 +65,101 @@ export async function handleProjectOperation(args) {
60
65
  case "delete_project":
61
66
  result = await handleDeleteProject(validated);
62
67
  break;
68
+ case "get_machine_graph":
69
+ result = await handleGetMachineGraph(validated);
70
+ break;
71
+ case "get_guard_graph":
72
+ result = await handleGetGuardGraph(validated);
73
+ break;
63
74
  case "assemble_context":
64
75
  result = await assembleContext(validated);
65
76
  break;
66
77
  case "generate_deployment_doc": {
67
- const { project_id, network, save = true } = validated;
78
+ const { project_id, network, save = true, detail_level } = validated;
68
79
  if (!project_id) {
69
80
  throw new Error("'project_id' is required for generate_deployment_doc");
70
81
  }
71
82
  if (!network) {
72
83
  throw new Error("'network' is required for generate_deployment_doc");
73
84
  }
74
- const genResult = await generateDeploymentDocFromProject(project_id, network);
85
+ const genResult = await generateDeploymentDocFromProject(project_id, network, detail_level);
75
86
  if (save) {
76
87
  await LocalProject.Instance().saveDocument(project_id, network, genResult.markdown);
77
88
  }
89
+ const project = await LocalProject.Instance().getProject(project_id);
90
+ const stageEntry = getStageCache(project?.prefix ?? project_id, project?.currentVersion ?? "v1");
91
+ const stageGateResult = validateStageGate({
92
+ stage: 4,
93
+ prefix: project?.prefix ?? project_id,
94
+ version: project?.currentVersion ?? "v1",
95
+ objects: [],
96
+ risk_status: stageEntry?.risk_status,
97
+ risk_can_proceed: stageEntry?.risk_can_proceed,
98
+ has_published_object: false,
99
+ deployment_doc_generated: true,
100
+ });
101
+ const scanResult = scanDeployment({
102
+ project_name: project?.prefix ?? project_id,
103
+ });
78
104
  result = {
79
105
  action: "generate_deployment_doc",
80
106
  markdown: genResult.markdown,
81
107
  validation: genResult.validation,
82
108
  saved: save,
109
+ detail_level: detail_level ?? "summary",
110
+ stage_gate: {
111
+ stage: stageGateResult.stage,
112
+ passed: stageGateResult.passed,
113
+ can_proceed: stageGateResult.can_proceed,
114
+ blocking_issues: stageGateResult.blocking_issues,
115
+ warnings: stageGateResult.warnings,
116
+ checks: stageGateResult.checks,
117
+ },
118
+ deployment_scan: {
119
+ overall_readiness: scanResult.overall_readiness,
120
+ critical_count: scanResult.findings.filter(f => f.severity === "critical").length,
121
+ warning_count: scanResult.findings.filter(f => f.severity === "warning").length,
122
+ findings: scanResult.findings,
123
+ checks: scanResult.checks,
124
+ },
83
125
  };
84
126
  break;
85
127
  }
128
+ case "pre_evaluate_check":
129
+ result = await handlePreEvaluateCheck(validated);
130
+ break;
131
+ case "verify_deployment":
132
+ result = await handleVerifyDeployment(validated);
133
+ break;
134
+ case "clone_project_to_network":
135
+ result = await handleCloneProjectToNetwork(validated);
136
+ break;
137
+ case "migrate_network":
138
+ result = await handleCloneProjectToNetwork(validated);
139
+ break;
140
+ case "migrate_to_mainnet":
141
+ result = await handleMigrateToMainnet(validated);
142
+ break;
143
+ case "plan_object_edit":
144
+ result = await handlePlanObjectEdit(validated);
145
+ break;
146
+ case "apply_object_edit":
147
+ result = await handleApplyObjectEdit(validated);
148
+ break;
149
+ case "patch_machine_nodes":
150
+ result = await handlePatchMachineNodes(validated);
151
+ break;
152
+ case "patch_guard_tree":
153
+ result = await handlePatchGuardTree(validated);
154
+ break;
86
155
  default:
87
156
  throw new Error(`Unknown project_operation action: ${String(action)}`);
88
157
  }
158
+ const skillsHint = getSkillsHintForProject(action);
89
159
  return {
90
160
  content: [{ type: "text", text: JSON.stringify({ result }) }],
91
- structuredContent: { result },
161
+ structuredContent: skillsHint
162
+ ? { result, skills_recommended: skillsHint }
163
+ : { result },
92
164
  };
93
165
  }
@@ -73,6 +73,33 @@ export async function handleWatchQueryOperations(args) {
73
73
  }
74
74
  return obj;
75
75
  });
76
+ queryResult.objects = queryResult.objects.map((obj) => {
77
+ if (obj && obj.data && obj.data.type === "Progress" && obj.data.current === "") {
78
+ const machineId = obj.data.machine;
79
+ const taskId = obj.data.task;
80
+ return {
81
+ ...obj,
82
+ _diagnostic: {
83
+ issue: "Progress.current is empty — order workflow is stuck at the initial state",
84
+ cause: "The Machine's entry node (prev_node='') likely has no forwards defined. " +
85
+ "When Progress starts, it looks up the entry node's forwards to determine " +
86
+ "the next node. Without forwards, Progress cannot advance and the order " +
87
+ "is permanently stuck.",
88
+ machine_object_id: machineId ?? null,
89
+ bound_order_id: taskId ?? null,
90
+ fix: [
91
+ "1. Query the Machine object (use query_toolkit with query_type='onchain_objects' and objects=[" + JSON.stringify(machineId) + "]).",
92
+ "2. Inspect node.pairs for the entry node (prev_node='').",
93
+ "3. If forwards is empty: this is the root cause. The Machine must be republished with at least one forward on the entry node.",
94
+ "4. To republish: clone the Machine nodes, add a forward to the entry node's pairs, then create a new Machine (Machine nodes are immutable after publish — see P0-2 schema validation that now blocks this).",
95
+ "5. Rebind the new Machine to the Service (service.machine field) and create a new Order to test.",
96
+ ],
97
+ reference: "P0-2 schema refinement in MachineNodePairSchema ensures new Machines cannot be published with empty entry-node forwards. This diagnostic catches legacy Machines that predate the fix.",
98
+ },
99
+ };
100
+ }
101
+ return obj;
102
+ });
76
103
  }
77
104
  result = { query_type: "onchain_objects", result: queryResult };
78
105
  break;
@@ -1,4 +1,4 @@
1
- import { processSchemaQuery, } from "../../schema-query/index.js";
1
+ import { processSchemaQuery, EXAMPLES_DIR, } from "../../schema-query/index.js";
2
2
  import { strictParse } from "../../schema/index.js";
3
3
  import { SchemaQueryInputSchema } from "../../schema/schema-query/index.js";
4
4
  export async function handleSchemaQuery(args) {
@@ -7,9 +7,16 @@ export async function handleSchemaQuery(args) {
7
7
  action: validated.action,
8
8
  name: validated.name,
9
9
  query: validated.query,
10
+ field_path: validated.field_path,
11
+ template: validated.template,
12
+ output_file: validated.output_file,
10
13
  };
11
14
  const response = processSchemaQuery(request);
12
15
  let textContent = response.message;
16
+ if (response.output_file_path) {
17
+ textContent += `\n\n📄 Full data written to: ${response.output_file_path}`;
18
+ textContent += `\n Use the Read tool to access the file content.`;
19
+ }
13
20
  const data = response.data;
14
21
  if (response.success && data) {
15
22
  switch (request.action) {
@@ -55,6 +62,18 @@ export async function handleSchemaQuery(args) {
55
62
  textContent += JSON.stringify(data, null, 2);
56
63
  textContent += "\n```\n";
57
64
  break;
65
+ case "get_guard_templates":
66
+ textContent += "\n\n## Guard Templates\n\n";
67
+ textContent += "```json\n";
68
+ textContent += JSON.stringify(data, null, 2);
69
+ textContent += "\n```\n";
70
+ break;
71
+ case "get_field":
72
+ textContent += "\n\n## Field Schema\n\n";
73
+ textContent += "```json\n";
74
+ textContent += JSON.stringify(data, null, 2);
75
+ textContent += "\n```\n";
76
+ break;
58
77
  case "search":
59
78
  if (Array.isArray(data) && data.length > 0) {
60
79
  textContent += `\n\nFound ${data.length} schemas matching '${request.query ?? ""}':\n`;
@@ -73,6 +92,29 @@ export async function handleSchemaQuery(args) {
73
92
  textContent += "\n\nNo schemas found. Try 'list' to browse all available schemas, or use a broader search term.";
74
93
  }
75
94
  break;
95
+ case "search_examples": {
96
+ const items = (Array.isArray(data) ? data : []);
97
+ if (items.length > 0) {
98
+ textContent += `\n\nFound ${items.length} example(s) matching '${request.query ?? ""}':\n`;
99
+ for (const item of items) {
100
+ textContent += `\n • [score: ${item.score}] ${item.file}`;
101
+ textContent += `\n Title: ${item.title}`;
102
+ textContent += `\n Industry: ${item.industry} | Operation: ${item.operation_type} | Verified: ${item.verified ? "yes" : "no"}`;
103
+ textContent += `\n Tags: ${item.tags.join(", ")}`;
104
+ textContent += `\n Matched fields: ${item.matched_fields.join(", ")}`;
105
+ const descPreview = item.description.length > 120
106
+ ? `${item.description.slice(0, 120)}...`
107
+ : item.description;
108
+ textContent += `\n Description: ${descPreview}`;
109
+ textContent += "\n";
110
+ }
111
+ textContent += `\n To view the full example JSON, read files from: ${EXAMPLES_DIR}`;
112
+ }
113
+ else {
114
+ textContent += "\n\nNo examples found. Try broader terms like 'service', 'machine', 'guard', 'permission', or an industry name like 'rental' or 'retail'.";
115
+ }
116
+ break;
117
+ }
76
118
  default:
77
119
  throw new Error(`Unknown schema_query action: ${String(request.action)}`);
78
120
  }
@@ -0,0 +1,170 @@
1
+ import { z } from "zod";
2
+ import type { ToolDispatchResult } from "../types.js";
3
+ export declare const QueryTaskStatusInputSchema: z.ZodObject<{
4
+ task_id: z.ZodOptional<z.ZodString>;
5
+ project_id: z.ZodOptional<z.ZodString>;
6
+ }, "strict", z.ZodTypeAny, {
7
+ project_id?: string | undefined;
8
+ task_id?: string | undefined;
9
+ }, {
10
+ project_id?: string | undefined;
11
+ task_id?: string | undefined;
12
+ }>;
13
+ export declare const TaskStateSchema: z.ZodObject<{
14
+ task_id: z.ZodString;
15
+ operation: z.ZodString;
16
+ status: z.ZodEnum<["pending", "running", "completed", "failed", "cancelled"]>;
17
+ progress: z.ZodNumber;
18
+ message: z.ZodString;
19
+ result: z.ZodNullable<z.ZodUnknown>;
20
+ error: z.ZodNullable<z.ZodString>;
21
+ started_at: z.ZodNumber;
22
+ completed_at: z.ZodNullable<z.ZodNumber>;
23
+ project_id: z.ZodNullable<z.ZodString>;
24
+ }, "strict", z.ZodTypeAny, {
25
+ message: string;
26
+ status: "failed" | "completed" | "pending" | "cancelled" | "running";
27
+ error: string | null;
28
+ operation: string;
29
+ progress: number;
30
+ completed_at: number | null;
31
+ project_id: string | null;
32
+ task_id: string;
33
+ started_at: number;
34
+ result?: unknown;
35
+ }, {
36
+ message: string;
37
+ status: "failed" | "completed" | "pending" | "cancelled" | "running";
38
+ error: string | null;
39
+ operation: string;
40
+ progress: number;
41
+ completed_at: number | null;
42
+ project_id: string | null;
43
+ task_id: string;
44
+ started_at: number;
45
+ result?: unknown;
46
+ }>;
47
+ export declare const QueryTaskStatusOutputSchema: z.ZodObject<{
48
+ task_id: z.ZodOptional<z.ZodString>;
49
+ task: z.ZodNullable<z.ZodObject<{
50
+ task_id: z.ZodString;
51
+ operation: z.ZodString;
52
+ status: z.ZodEnum<["pending", "running", "completed", "failed", "cancelled"]>;
53
+ progress: z.ZodNumber;
54
+ message: z.ZodString;
55
+ result: z.ZodNullable<z.ZodUnknown>;
56
+ error: z.ZodNullable<z.ZodString>;
57
+ started_at: z.ZodNumber;
58
+ completed_at: z.ZodNullable<z.ZodNumber>;
59
+ project_id: z.ZodNullable<z.ZodString>;
60
+ }, "strict", z.ZodTypeAny, {
61
+ message: string;
62
+ status: "failed" | "completed" | "pending" | "cancelled" | "running";
63
+ error: string | null;
64
+ operation: string;
65
+ progress: number;
66
+ completed_at: number | null;
67
+ project_id: string | null;
68
+ task_id: string;
69
+ started_at: number;
70
+ result?: unknown;
71
+ }, {
72
+ message: string;
73
+ status: "failed" | "completed" | "pending" | "cancelled" | "running";
74
+ error: string | null;
75
+ operation: string;
76
+ progress: number;
77
+ completed_at: number | null;
78
+ project_id: string | null;
79
+ task_id: string;
80
+ started_at: number;
81
+ result?: unknown;
82
+ }>>;
83
+ tasks: z.ZodOptional<z.ZodArray<z.ZodObject<{
84
+ task_id: z.ZodString;
85
+ operation: z.ZodString;
86
+ status: z.ZodEnum<["pending", "running", "completed", "failed", "cancelled"]>;
87
+ progress: z.ZodNumber;
88
+ message: z.ZodString;
89
+ result: z.ZodNullable<z.ZodUnknown>;
90
+ error: z.ZodNullable<z.ZodString>;
91
+ started_at: z.ZodNumber;
92
+ completed_at: z.ZodNullable<z.ZodNumber>;
93
+ project_id: z.ZodNullable<z.ZodString>;
94
+ }, "strict", z.ZodTypeAny, {
95
+ message: string;
96
+ status: "failed" | "completed" | "pending" | "cancelled" | "running";
97
+ error: string | null;
98
+ operation: string;
99
+ progress: number;
100
+ completed_at: number | null;
101
+ project_id: string | null;
102
+ task_id: string;
103
+ started_at: number;
104
+ result?: unknown;
105
+ }, {
106
+ message: string;
107
+ status: "failed" | "completed" | "pending" | "cancelled" | "running";
108
+ error: string | null;
109
+ operation: string;
110
+ progress: number;
111
+ completed_at: number | null;
112
+ project_id: string | null;
113
+ task_id: string;
114
+ started_at: number;
115
+ result?: unknown;
116
+ }>, "many">>;
117
+ }, "strict", z.ZodTypeAny, {
118
+ task: {
119
+ message: string;
120
+ status: "failed" | "completed" | "pending" | "cancelled" | "running";
121
+ error: string | null;
122
+ operation: string;
123
+ progress: number;
124
+ completed_at: number | null;
125
+ project_id: string | null;
126
+ task_id: string;
127
+ started_at: number;
128
+ result?: unknown;
129
+ } | null;
130
+ task_id?: string | undefined;
131
+ tasks?: {
132
+ message: string;
133
+ status: "failed" | "completed" | "pending" | "cancelled" | "running";
134
+ error: string | null;
135
+ operation: string;
136
+ progress: number;
137
+ completed_at: number | null;
138
+ project_id: string | null;
139
+ task_id: string;
140
+ started_at: number;
141
+ result?: unknown;
142
+ }[] | undefined;
143
+ }, {
144
+ task: {
145
+ message: string;
146
+ status: "failed" | "completed" | "pending" | "cancelled" | "running";
147
+ error: string | null;
148
+ operation: string;
149
+ progress: number;
150
+ completed_at: number | null;
151
+ project_id: string | null;
152
+ task_id: string;
153
+ started_at: number;
154
+ result?: unknown;
155
+ } | null;
156
+ task_id?: string | undefined;
157
+ tasks?: {
158
+ message: string;
159
+ status: "failed" | "completed" | "pending" | "cancelled" | "running";
160
+ error: string | null;
161
+ operation: string;
162
+ progress: number;
163
+ completed_at: number | null;
164
+ project_id: string | null;
165
+ task_id: string;
166
+ started_at: number;
167
+ result?: unknown;
168
+ }[] | undefined;
169
+ }>;
170
+ export declare function handleQueryTaskStatus(args: unknown): Promise<ToolDispatchResult>;
@@ -0,0 +1,55 @@
1
+ import { z } from "zod";
2
+ import { TaskTracker } from "../../project/task-tracker.js";
3
+ export const QueryTaskStatusInputSchema = z.object({
4
+ task_id: z
5
+ .string()
6
+ .optional()
7
+ .describe("The task ID to query (returned by a prior async operation). " +
8
+ "If omitted, lists all recent tasks (most recent first, max 50)."),
9
+ project_id: z
10
+ .string()
11
+ .optional()
12
+ .describe("Optional filter — when listing tasks (task_id omitted), only return tasks for this project."),
13
+ }).strict().describe("Query the status of an async task, or list all recent tasks when task_id is omitted.");
14
+ export const TaskStateSchema = z.object({
15
+ task_id: z.string().describe("Unique task identifier."),
16
+ operation: z.string().describe("Operation type that created this task (e.g. 'build_graph')."),
17
+ status: z.enum(["pending", "running", "completed", "failed", "cancelled"]).describe("Current task status."),
18
+ progress: z.number().describe("Progress percentage 0-100."),
19
+ message: z.string().describe("Human-readable progress message."),
20
+ result: z.unknown().nullable().describe("Result payload (set when status='completed'). null otherwise."),
21
+ error: z.string().nullable().describe("Error message (set when status='failed'). null otherwise."),
22
+ started_at: z.number().describe("Timestamp (ms) when the task was created."),
23
+ completed_at: z.number().nullable().describe("Timestamp (ms) when the task reached a terminal state. null if still running."),
24
+ project_id: z.string().nullable().describe("Project ID associated with this task, if any."),
25
+ }).strict();
26
+ export const QueryTaskStatusOutputSchema = z.object({
27
+ task_id: z.string().optional().describe("The queried task ID (present when a single task was queried)."),
28
+ task: TaskStateSchema.nullable().describe("The task state. null if task_id not found or when listing."),
29
+ tasks: z.array(TaskStateSchema).optional().describe("List of tasks (present when task_id was omitted)."),
30
+ }).strict();
31
+ export async function handleQueryTaskStatus(args) {
32
+ const validated = (args && typeof args === "object" ? args : {});
33
+ if (validated.task_id) {
34
+ const task = TaskTracker.get(validated.task_id);
35
+ const result = {
36
+ task_id: validated.task_id,
37
+ task: task ?? null,
38
+ tasks: undefined,
39
+ };
40
+ return {
41
+ content: [{ type: "text", text: JSON.stringify(result) }],
42
+ structuredContent: result,
43
+ };
44
+ }
45
+ const tasks = TaskTracker.list(validated.project_id).slice(0, 50);
46
+ const result = {
47
+ task_id: undefined,
48
+ task: null,
49
+ tasks,
50
+ };
51
+ return {
52
+ content: [{ type: "text", text: JSON.stringify(result) }],
53
+ structuredContent: result,
54
+ };
55
+ }
@@ -1,6 +1,36 @@
1
1
  import { strictParse, WipOperationsSchema, } from "../../schema/index.js";
2
2
  import { generate_wip, verify_wip, sign_wip, wip2html, } from "@wowok/wowok";
3
+ import { analyzeWipDeployment, formatDeployHints, } from "../wip-deploy-assist.js";
3
4
  export async function handleWipOperations(args) {
5
+ if (typeof args === "object" && args !== null
6
+ && args.type === "deploy_assist") {
7
+ const wipPath = args.wipFilePath;
8
+ if (typeof wipPath !== "string") {
9
+ return {
10
+ content: [{
11
+ type: "text",
12
+ text: "Error: 'wipFilePath' is required for deploy_assist action",
13
+ }],
14
+ structuredContent: {
15
+ result: {
16
+ type: "error",
17
+ error: "'wipFilePath' is required for deploy_assist action",
18
+ },
19
+ },
20
+ };
21
+ }
22
+ const suggestion = analyzeWipDeployment(wipPath);
23
+ const hints = formatDeployHints(suggestion);
24
+ return {
25
+ content: [{ type: "text", text: hints || "No deployment needed." }],
26
+ structuredContent: {
27
+ result: {
28
+ type: "deploy_assist",
29
+ ...suggestion,
30
+ },
31
+ },
32
+ };
33
+ }
4
34
  const validated = strictParse(WipOperationsSchema, args, "wip_file input");
5
35
  let structuredContent;
6
36
  switch (validated.type) {
@@ -10,8 +40,24 @@ export async function handleWipOperations(args) {
10
40
  break;
11
41
  }
12
42
  case "verify": {
43
+ const deploySuggestion = analyzeWipDeployment(validated.wipFilePath);
13
44
  const result = await verify_wip(validated.wipFilePath, validated.hash_equal, validated.requireSignature);
14
- structuredContent = { result: { type: "verify", ...result } };
45
+ const attachHints = deploySuggestion.needs_deployment
46
+ || (!result.valid && deploySuggestion.classification.type !== "data_url");
47
+ if (attachHints) {
48
+ const hints = formatDeployHints(deploySuggestion);
49
+ structuredContent = {
50
+ result: {
51
+ type: "verify",
52
+ ...result,
53
+ deployment_assistance: deploySuggestion,
54
+ },
55
+ deployment_hints: hints,
56
+ };
57
+ }
58
+ else {
59
+ structuredContent = { result: { type: "verify", ...result } };
60
+ }
15
61
  break;
16
62
  }
17
63
  case "sign": {
@@ -2,6 +2,14 @@ import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
2
2
  import type { ToolEntry, ToolDispatchResult, DispatchOptions } from "./types.js";
3
3
  export declare const TOOL_REGISTRY: ToolEntry[];
4
4
  export declare const TOOL_REGISTRY_MAP: Map<string, ToolEntry>;
5
+ export interface StructuredSchemaError {
6
+ path: string;
7
+ code: string;
8
+ message: string;
9
+ expected?: string;
10
+ received_value?: unknown;
11
+ suggestion: string;
12
+ }
5
13
  export declare function dispatchToolCall(name: string, args: unknown, options?: DispatchOptions): Promise<ToolDispatchResult>;
6
14
  export interface ToolListEntry {
7
15
  name: string;