@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
@@ -472,7 +472,7 @@ const R_R_5_03 = {
472
472
  const R_R_6_01 = {
473
473
  id: "R-R-6-01",
474
474
  category: "business_semantic",
475
- trigger: "intent mentions praise/好评 but Guard checks non-wonder progress node",
475
+ trigger: "intent mentions praise/positive-review but Guard checks non-wonder progress node",
476
476
  check: (ctx) => {
477
477
  if (!ctx.user_intent_phrases || ctx.user_intent_phrases.length === 0)
478
478
  return null;
@@ -480,8 +480,8 @@ const R_R_6_01 = {
480
480
  return null;
481
481
  const intentLower = ctx.user_intent_phrases.join(" ").toLowerCase();
482
482
  const praiseKeywords = [
483
- "好评", "praise", "wonder", "thumbs_up",
484
- "positive review", "satisfaction reward", "好评奖励",
483
+ "praise", "wonder", "thumbs_up",
484
+ "positive review", "satisfaction reward", "praise reward",
485
485
  ];
486
486
  const isPraiseIntent = praiseKeywords.some(kw => intentLower.includes(kw.toLowerCase()));
487
487
  if (!isPraiseIntent)
@@ -495,10 +495,10 @@ const R_R_6_01 = {
495
495
  level: "HIGH",
496
496
  category: "business_semantic",
497
497
  title: `Guard checks progress=="${expected}" but intent indicates praise reward (wonder node)`,
498
- description: `User intent mentions praise/好评/wonder, which maps to the 'wonder' progress node ` +
498
+ description: `User intent mentions praise/positive-review/wonder, which maps to the 'wonder' progress node ` +
499
499
  `(customer gives positive review AFTER service completion). But the Guard's table bakes ` +
500
500
  `expected state="${expected}", allowing reward claim at the wrong lifecycle stage. ` +
501
- `This violates the business semantics: "好评奖励" should only be claimable AFTER the ` +
501
+ `This violates the business semantics: "praise reward" should only be claimable AFTER the ` +
502
502
  `customer advances to the 'wonder' node, not before. ` +
503
503
  `Guard is immutable — fixing this requires creating a new Guard + Reward pair.`,
504
504
  affected_stakeholders: ["owner", "service_provider", "claimer"],
@@ -526,8 +526,8 @@ const R_R_6_02 = {
526
526
  return null;
527
527
  const intentLower = ctx.user_intent_phrases.join(" ").toLowerCase();
528
528
  const praiseKeywords = [
529
- "好评", "praise", "wonder", "thumbs_up",
530
- "positive review", "satisfaction reward", "好评奖励",
529
+ "praise", "wonder", "thumbs_up",
530
+ "positive review", "satisfaction reward", "praise reward",
531
531
  ];
532
532
  const isPraiseIntent = praiseKeywords.some(kw => intentLower.includes(kw.toLowerCase()));
533
533
  if (isPraiseIntent)
@@ -538,12 +538,12 @@ const R_R_6_02 = {
538
538
  category: "business_semantic",
539
539
  title: "Guard checks wonder node but intent does not mention praise",
540
540
  description: `Guard's expected progress state is "wonder" (positive-review node), but the user intent ` +
541
- `does not mention any praise/好评 keyword. This may be a copy-paste from a wonder_praise ` +
541
+ `does not mention any praise/positive-review keyword. This may be a copy-paste from a wonder_praise ` +
542
542
  `template without adjusting the Guard for the actual business semantics. If this is a ` +
543
543
  `general feedback reward (wonder_feedback), this is fine. Otherwise, verify the node choice.`,
544
544
  affected_stakeholders: ["owner"],
545
545
  scenario: "Designer copies wonder_praise template but actually wants a completion-based reward",
546
- mitigation: "Verify: if intent is praise reward, add '好评/praise' to description. " +
546
+ mitigation: "Verify: if intent is praise reward, add 'praise/positive review' to description. " +
547
547
  "If intent is completion-based reward, change Guard to check 'completed' node.",
548
548
  evidence: `expected_state="wonder", intent="${intentLower}" (no praise keyword)`,
549
549
  auto_fixable: false,
@@ -165,13 +165,13 @@ export function listRewardTemplates() {
165
165
  export function suggestRewardTemplate(intent) {
166
166
  const lower = intent.toLowerCase();
167
167
  if (lower.includes("wonder") || lower.includes("praise") || lower.includes("thumbs_up")
168
- || lower.includes("好评") || lower.includes("positive review")
168
+ || lower.includes("praise") || lower.includes("positive review")
169
169
  || lower.includes("satisfaction reward")) {
170
170
  return getRewardTemplate("wonder_praise");
171
171
  }
172
172
  if (lower.includes("feedback") || lower.includes("review collection")
173
173
  || lower.includes("no_wonder") || lower.includes("thumbs_down")
174
- || lower.includes("差评") || lower.includes("both sentiment")) {
174
+ || lower.includes("complaint") || lower.includes("both sentiment")) {
175
175
  return getRewardTemplate("wonder_feedback");
176
176
  }
177
177
  if (lower.includes("first order") || lower.includes("new") || lower.includes("first")) {
@@ -35,13 +35,18 @@ export interface ServiceConfirmationResponse {
35
35
  question_id: string;
36
36
  response: "yes" | "no" | "skip";
37
37
  }
38
+ export type ServiceEnvironmentCheckLevel = "block" | "warning" | "info";
39
+ export interface ServiceEnvironmentCheck {
40
+ name: string;
41
+ passed: boolean;
42
+ message: string;
43
+ level?: ServiceEnvironmentCheckLevel;
44
+ }
38
45
  export interface ServiceEnvironmentResult {
39
46
  passed: boolean;
40
- checks: {
41
- name: string;
42
- passed: boolean;
43
- message: string;
44
- }[];
47
+ checks: ServiceEnvironmentCheck[];
48
+ warnings_count: number;
49
+ infos_count: number;
45
50
  }
46
51
  export interface ServiceDecisionRecord {
47
52
  timestamp: string;
@@ -106,7 +111,7 @@ export interface ServiceJsonForConfirm {
106
111
  };
107
112
  compensation_fund_withdraw?: unknown;
108
113
  compensation_fund_receive?: unknown;
109
- setting_locked_time_add?: number;
114
+ setting_lock_duration_add?: number;
110
115
  order_new?: {
111
116
  buy: {
112
117
  items: Array<{
@@ -138,6 +143,10 @@ export interface ServiceConfirmGateInput {
138
143
  current_order_allocators_set?: boolean;
139
144
  skip_user_confirmation?: boolean;
140
145
  skip_environment_check?: boolean;
146
+ current_machine_node_count?: number;
147
+ current_machine_initial_forward_ok?: boolean;
148
+ current_machine_bPublished?: boolean;
149
+ current_arbitrators_authorized?: boolean;
141
150
  }
142
151
  export declare const SERVICE_PUBLISH_CHECKLIST: ServiceChecklistItem[];
143
152
  export declare const SERVICE_CONFIRMATION_QUESTIONS: ServiceConfirmationQuestion[];
@@ -19,6 +19,7 @@ export const SERVICE_PUBLISH_CHECKLIST = [
19
19
  { id: "C-S-16", description: "Address fields valid (0x prefix, length >= 40)", passed: false, message: "" },
20
20
  { id: "C-S-17", description: "Publish operation double-confirmed (bPublished irreversible)", passed: false, message: "" },
21
21
  { id: "C-S-18", description: "Ownership transfer double-confirmed (IRREVERSIBLE)", passed: false, message: "" },
22
+ { id: "C-S-19", description: "Publish: arbitrations strongly recommended (cannot add post-publish, F-S-21)", passed: false, message: "" },
22
23
  ];
23
24
  function runStaticChecklist(input) {
24
25
  const items = SERVICE_PUBLISH_CHECKLIST.map(c => ({ ...c }));
@@ -227,7 +228,24 @@ function runStaticChecklist(input) {
227
228
  else {
228
229
  items.find(i => i.id === "C-S-18").passed = true;
229
230
  }
230
- const allPassed = items.filter(i => i.id !== "C-S-17" && i.id !== "C-S-18").every(i => i.passed);
231
+ if (data.publish) {
232
+ const currentArbCount = input.current_arbitrations_count ?? 0;
233
+ const arbFromInput = data.arbitrations && "objects" in data.arbitrations ? data.arbitrations.objects.length : 0;
234
+ const arbCleared = data.arbitrations && data.arbitrations.op === "clear";
235
+ const totalArb = arbCleared ? 0 : currentArbCount + arbFromInput;
236
+ const cs19 = items.find(i => i.id === "C-S-19");
237
+ if (totalArb === 0) {
238
+ cs19.passed = false;
239
+ cs19.message = "Pending user confirmation in Layer 3 (QS11) — arbitrations cannot be added post-publish";
240
+ }
241
+ else {
242
+ cs19.passed = true;
243
+ }
244
+ }
245
+ else {
246
+ items.find(i => i.id === "C-S-19").passed = true;
247
+ }
248
+ const allPassed = items.filter(i => i.id !== "C-S-17" && i.id !== "C-S-18" && i.id !== "C-S-19").every(i => i.passed);
231
249
  return { all_passed: allPassed, items };
232
250
  }
233
251
  function adaptRiskAssessment(input) {
@@ -245,7 +263,7 @@ function adaptRiskAssessment(input) {
245
263
  order_allocators: input.service_json.order_allocators,
246
264
  buy_guard: input.service_json.buy_guard,
247
265
  compensation_fund_add: input.service_json.compensation_fund_add,
248
- setting_locked_time_add: input.service_json.setting_locked_time_add,
266
+ setting_lock_duration_add: input.service_json.setting_lock_duration_add,
249
267
  compensation_fund_receive: input.service_json.compensation_fund_receive,
250
268
  owner_receive: input.service_json.owner_receive,
251
269
  pause: input.service_json.pause,
@@ -327,6 +345,16 @@ export const SERVICE_CONFIRMATION_QUESTIONS = [
327
345
  question: "Have you exported the current Service JSON as a backup before this operation?",
328
346
  requires_explicit_yes: false,
329
347
  },
348
+ {
349
+ id: "QS11",
350
+ question: "⚠️ Service is about to be published WITHOUT arbitrations.\n\n" +
351
+ "After publishing, arbitrations CANNOT be added (contract restriction, F-S-21).\n" +
352
+ "Dispute resolution will NOT be available for this service.\n\n" +
353
+ "Recommended: Set arbitrations BEFORE publishing:\n" +
354
+ ' "arbitrations": {"op": "add", "objects": ["your_arbitration_object"]}\n\n' +
355
+ "Continue with publish anyway?",
356
+ requires_explicit_yes: true,
357
+ },
330
358
  ];
331
359
  function processUserConfirmation(input, assessment) {
332
360
  const questions = [...SERVICE_CONFIRMATION_QUESTIONS];
@@ -350,6 +378,18 @@ function processUserConfirmation(input, assessment) {
350
378
  irrelevant.push("QS8");
351
379
  if (!data.order_new)
352
380
  irrelevant.push("QS9");
381
+ if (!data.publish) {
382
+ irrelevant.push("QS11");
383
+ }
384
+ else {
385
+ const currentArbCount = input.current_arbitrations_count ?? 0;
386
+ const arbFromInput = data.arbitrations && "objects" in data.arbitrations ? data.arbitrations.objects.length : 0;
387
+ const arbCleared = data.arbitrations && data.arbitrations.op === "clear";
388
+ const totalArb = arbCleared ? 0 : currentArbCount + arbFromInput;
389
+ if (totalArb > 0) {
390
+ irrelevant.push("QS11");
391
+ }
392
+ }
353
393
  const filtered = questions.filter(q => !irrelevant.includes(q.id));
354
394
  if (input.skip_user_confirmation) {
355
395
  return {
@@ -413,6 +453,40 @@ function verifyEnvironment(input) {
413
453
  message: "Publish blocked: compensation_fund > 0 but no arbitrations (E_ARBITRATION_NOT_SET_WITH_COMPENSATION_FUND)",
414
454
  });
415
455
  }
456
+ if (data.machine) {
457
+ if (input.current_machine_node_count !== undefined && input.current_machine_node_count === 0) {
458
+ checks.push({
459
+ name: "machine_has_nodes",
460
+ passed: false,
461
+ message: "Publish blocked: bound Machine has 0 nodes — Progress will be permanently stuck",
462
+ });
463
+ }
464
+ if (input.current_machine_initial_forward_ok === false) {
465
+ checks.push({
466
+ name: "machine_initial_forward",
467
+ passed: false,
468
+ message: "Publish blocked: bound Machine's initial node (prev_node='') has no forward — Progress cannot advance from '' (FIX-002 violated)",
469
+ });
470
+ }
471
+ if (input.current_machine_bPublished === false) {
472
+ checks.push({
473
+ name: "machine_not_published",
474
+ passed: true,
475
+ level: "warning",
476
+ message: "Warning: bound Machine is not yet published. Orders cannot advance until the Machine is published. Publish the Machine after this Service to enable order workflow.",
477
+ });
478
+ }
479
+ }
480
+ const arbCountForPerm = input.current_arbitrations_count ?? 0;
481
+ const arbFromInputForPerm = data.arbitrations && "objects" in data.arbitrations ? data.arbitrations.objects.length : 0;
482
+ if ((arbCountForPerm + arbFromInputForPerm) > 0 && input.current_arbitrators_authorized === false) {
483
+ checks.push({
484
+ name: "arbitrators_permission_authorized",
485
+ passed: true,
486
+ level: "info",
487
+ message: "Info: ensure arbitrators have been granted the required permission index in the Permission object. Without authorization, dispute resolution Guards will reject arbitrator signatures (Permission denied).",
488
+ });
489
+ }
416
490
  }
417
491
  if (input.current_bPublished) {
418
492
  if (data.machine !== undefined) {
@@ -445,7 +519,9 @@ function verifyEnvironment(input) {
445
519
  });
446
520
  }
447
521
  const allPassed = checks.every(c => c.passed);
448
- return { passed: allPassed, checks };
522
+ const warnings_count = checks.filter(c => c.level === "warning").length;
523
+ const infos_count = checks.filter(c => c.level === "info").length;
524
+ return { passed: allPassed, checks, warnings_count, infos_count };
449
525
  }
450
526
  export const SERVICE_CONFIRM_VERSION = "1.0.0";
451
527
  export function runServiceConfirmGate(input) {
@@ -458,7 +534,7 @@ export function runServiceConfirmGate(input) {
458
534
  status: "blocked_checklist",
459
535
  checklist_result: checklist,
460
536
  confirmation_text: generateConfirmationText(input, checklist),
461
- block_reason: `Checklist failed: ${checklist.items.filter(i => !i.passed && i.id !== "C-S-17" && i.id !== "C-S-18").map(i => i.id).join(", ")}`,
537
+ block_reason: `Checklist failed: ${checklist.items.filter(i => !i.passed && i.id !== "C-S-17" && i.id !== "C-S-18" && i.id !== "C-S-19").map(i => i.id).join(", ")}`,
462
538
  decision_record: {
463
539
  timestamp: new Date().toISOString(),
464
540
  gate_version: SERVICE_CONFIRM_VERSION,
@@ -507,6 +583,15 @@ export function runServiceConfirmGate(input) {
507
583
  cs18.message = cs18.passed ? "" : "Transfer not confirmed by user (QS2)";
508
584
  }
509
585
  }
586
+ const cs19 = checklist.items.find(i => i.id === "C-S-19");
587
+ if (cs19 && !cs19.passed) {
588
+ const qs11Asked = userConf.questions_asked.some(q => q.id === "QS11");
589
+ if (qs11Asked) {
590
+ const qs11 = userConf.responses.find(r => r.question_id === "QS11");
591
+ cs19.passed = qs11?.response === "yes";
592
+ cs19.message = cs19.passed ? "" : "User declined publish without arbitrations (QS11)";
593
+ }
594
+ }
510
595
  if (input.service_json.publish) {
511
596
  const cs17 = checklist.items.find(i => i.id === "C-S-17");
512
597
  if (cs17 && !cs17.passed) {
@@ -549,23 +634,45 @@ export function runServiceConfirmGate(input) {
549
634
  };
550
635
  }
551
636
  }
637
+ if (cs19 && !cs19.passed) {
638
+ const qs11Asked = userConf.questions_asked.some(q => q.id === "QS11");
639
+ if (qs11Asked) {
640
+ layersFailed.push("L3_user");
641
+ return {
642
+ status: "blocked_user",
643
+ checklist_result: checklist,
644
+ risk_result: assessment,
645
+ user_confirmation: userConf,
646
+ confirmation_text: generateConfirmationText(input, checklist, assessment),
647
+ block_reason: "User did not confirm publish without arbitrations (QS11) — set arbitrations or explicitly confirm",
648
+ decision_record: {
649
+ timestamp: new Date().toISOString(),
650
+ gate_version: SERVICE_CONFIRM_VERSION,
651
+ final_status: "blocked_user",
652
+ layers_passed: layersPassed,
653
+ layers_failed: layersFailed,
654
+ },
655
+ };
656
+ }
657
+ }
552
658
  }
553
659
  layersPassed.push("L3_user");
660
+ let envResult;
554
661
  if (input.skip_environment_check) {
555
662
  layersPassed.push("L4_environment");
556
663
  }
557
664
  else {
558
- const env = verifyEnvironment(input);
559
- if (!env.passed) {
665
+ envResult = verifyEnvironment(input);
666
+ if (!envResult.passed) {
560
667
  layersFailed.push("L4_environment");
561
668
  return {
562
669
  status: "blocked_environment",
563
670
  checklist_result: checklist,
564
671
  risk_result: assessment,
565
672
  user_confirmation: userConf,
566
- environment_result: env,
673
+ environment_result: envResult,
567
674
  confirmation_text: generateConfirmationText(input, checklist, assessment),
568
- block_reason: `Environment check failed: ${env.checks.filter(c => !c.passed).map(c => c.name).join(", ")}`,
675
+ block_reason: `Environment check failed: ${envResult.checks.filter(c => !c.passed).map(c => c.name).join(", ")}`,
569
676
  decision_record: {
570
677
  timestamp: new Date().toISOString(),
571
678
  gate_version: SERVICE_CONFIRM_VERSION,
@@ -582,6 +689,7 @@ export function runServiceConfirmGate(input) {
582
689
  checklist_result: checklist,
583
690
  risk_result: assessment,
584
691
  user_confirmation: userConf,
692
+ environment_result: envResult,
585
693
  confirmation_text: generateConfirmationText(input, checklist, assessment),
586
694
  decision_record: {
587
695
  timestamp: new Date().toISOString(),
@@ -653,8 +761,8 @@ function generateConfirmationText(input, checklist, assessment) {
653
761
  lines.push(`- Compensation fund deposit: ${data.compensation_fund_add.balance}`);
654
762
  if (data.compensation_fund_withdraw)
655
763
  lines.push(`- ⚠️ Compensation fund withdraw (requires paused + lock expired)`);
656
- if (data.setting_locked_time_add !== undefined)
657
- lines.push(`- Setting lock +${data.setting_locked_time_add}ms`);
764
+ if (data.setting_lock_duration_add !== undefined)
765
+ lines.push(`- Setting lock +${data.setting_lock_duration_add}ms`);
658
766
  if (data.order_new)
659
767
  lines.push(`- ⚠️ ORDER NEW (8-stage flow, stock deducted at quote)`);
660
768
  if (data.builder)
@@ -670,7 +778,7 @@ export function progressiveServiceCheck(input) {
670
778
  return {
671
779
  stage: "checklist",
672
780
  status: "fail",
673
- message: `Checklist failed: ${checklist.items.filter(i => !i.passed && i.id !== "C-S-17" && i.id !== "C-S-18").map(i => i.id).join(", ")}`,
781
+ message: `Checklist failed: ${checklist.items.filter(i => !i.passed && i.id !== "C-S-17" && i.id !== "C-S-18" && i.id !== "C-S-19").map(i => i.id).join(", ")}`,
674
782
  next_action: "Fix failing checklist items",
675
783
  };
676
784
  }
@@ -58,7 +58,7 @@ export function buildServiceContext(input) {
58
58
  order_allocators: input.service_json.order_allocators,
59
59
  buy_guard: input.service_json.buy_guard,
60
60
  compensation_fund_add: input.service_json.compensation_fund_add,
61
- setting_locked_time_add: input.service_json.setting_locked_time_add,
61
+ setting_lock_duration_add: input.service_json.setting_lock_duration_add,
62
62
  compensation_fund_receive: input.service_json.compensation_fund_receive,
63
63
  owner_receive: input.service_json.owner_receive,
64
64
  pause: input.service_json.pause,
@@ -15,7 +15,7 @@ export const SERVICE_PERMISSIONS = [
15
15
  { index: 314, name: "SERVICE_COMPENSATION_FUND_WITHDRAW", description: "Withdraw compensation fund (lock_duration)", governed_operation: "service::compensation_fund_withdraw", post_publish_mutability: "locked_by_duration" },
16
16
  { index: 315, name: "SERVICE_COMPENSATION_FUND_DEPOSIT", description: "Deposit to compensation fund", governed_operation: "service::compensation_fund_add", post_publish_mutability: "mutable" },
17
17
  { index: 316, name: "SERVICE_COMPENSATION_FUND_RECEIVE", description: "Receive compensation fund (lock_duration)", governed_operation: "service::compensation_fund_receive", post_publish_mutability: "locked_by_duration" },
18
- { index: 317, name: "SERVICE_COMPENSATION_LOCKED_TIME_ADD", description: "Extend setting_lock_duration (only-increase)", governed_operation: "service::setting_lock_duration_add", post_publish_mutability: "mutable" },
18
+ { index: 317, name: "SERVICE_COMPENSATION_LOCK_DURATION_ADD", description: "Extend setting_lock_duration (only-increase)", governed_operation: "service::setting_lock_duration_add", post_publish_mutability: "mutable" },
19
19
  { index: 318, name: "SERVICE_REWARD", description: "Add/remove Reward references (locked)", governed_operation: "service::reward_add/remove/clear", post_publish_mutability: "locked_by_duration" },
20
20
  { index: 319, name: "SERVICE_OWNER_RECEIVE", description: "Receive Payment/objects to owner", governed_operation: "service::owner_receive", post_publish_mutability: "mutable" },
21
21
  { index: 320, name: "SERVICE_UM", description: "Bind/unbind Contact as UM", governed_operation: "service::um_set/um_none", post_publish_mutability: "mutable" },
@@ -65,7 +65,7 @@ export interface ServiceRiskCheckContext {
65
65
  compensation_fund_add?: {
66
66
  balance: string | number;
67
67
  };
68
- setting_locked_time_add?: number;
68
+ setting_lock_duration_add?: number;
69
69
  compensation_fund_receive?: unknown;
70
70
  owner_receive?: unknown;
71
71
  pause?: boolean;
@@ -370,18 +370,18 @@ const R_S_4_02 = {
370
370
  category: "lifecycle",
371
371
  trigger: "setting_lock_duration add — only-increase mechanism",
372
372
  check: (ctx) => {
373
- if (ctx.setting_locked_time_add === undefined)
373
+ if (ctx.setting_lock_duration_add === undefined)
374
374
  return null;
375
375
  return {
376
376
  id: "R-S-4-02",
377
377
  level: "MEDIUM",
378
378
  category: "lifecycle",
379
379
  title: "setting_lock_duration can only INCREASE",
380
- description: `Adding ${ctx.setting_locked_time_add} ms to setting_lock_duration. New value = old + input (safe_add). Cannot be decreased — protects customers from owner reducing lock to withdraw compensation_fund faster.`,
380
+ description: `Adding ${ctx.setting_lock_duration_add} ms to setting_lock_duration. New value = old + input (safe_add). Cannot be decreased — protects customers from owner reducing lock to withdraw compensation_fund faster.`,
381
381
  affected_stakeholders: ["owner", "customer"],
382
382
  scenario: "Owner extends lock period to build trust",
383
383
  mitigation: "Ensure extension is intentional. Lock affects rewards/compensation_fund_withdraw/compensation_fund_receive.",
384
- evidence: `add_ms=${ctx.setting_locked_time_add}`,
384
+ evidence: `add_ms=${ctx.setting_lock_duration_add}`,
385
385
  };
386
386
  },
387
387
  };
@@ -191,7 +191,7 @@ export const SERVICE_TEMPLATES = [
191
191
  permission: p.permission_address,
192
192
  arbitrations: { op: "add", objects: p.arbitration_addresses },
193
193
  compensation_fund_add: { balance: p.compensation_fund_balance },
194
- setting_locked_time_add: p.setting_lock_duration_ms,
194
+ setting_lock_duration_add: p.setting_lock_duration_ms,
195
195
  sales: { op: "add", sales: p.service_items },
196
196
  order_allocators: [
197
197
  {
@@ -234,7 +234,7 @@ export const SERVICE_TEMPLATES = [
234
234
  permission: p.permission_address,
235
235
  arbitrations: { op: "add", objects: p.arbitration_addresses },
236
236
  compensation_fund_add: { balance: p.initial_deposit },
237
- setting_locked_time_add: p.lock_duration_ms,
237
+ setting_lock_duration_add: p.lock_duration_ms,
238
238
  sales: { op: "add", sales: p.service_items },
239
239
  order_allocators: [
240
240
  {
@@ -80,7 +80,7 @@ export interface ServiceCallDataForExplain {
80
80
  };
81
81
  compensation_fund_withdraw?: unknown;
82
82
  compensation_fund_receive?: unknown;
83
- setting_locked_time_add?: number;
83
+ setting_lock_duration_add?: number;
84
84
  order_new?: {
85
85
  buy: {
86
86
  items: Array<{
@@ -185,10 +185,10 @@ export const SEMANTIC_TO_SCHEMA_RULES = [
185
185
  pattern_name: "Extend setting_lock_duration",
186
186
  semantic_intent: "Add milliseconds to setting_lock_duration (only-increase mechanism)",
187
187
  match_keywords: ["setting_lock_duration", "lock_duration", "lock period", "extend lock"],
188
- schema_fields: ["object", "setting_locked_time_add"],
188
+ schema_fields: ["object", "setting_lock_duration_add"],
189
189
  example_json: {
190
190
  object: "0xSERVICE_ADDRESS",
191
- setting_locked_time_add: 2592000000,
191
+ setting_lock_duration_add: 2592000000,
192
192
  },
193
193
  reverse_explanation: "Only-increase (safe_add). Default 2592000000ms (30 days). Affects rewards/compensation_fund_withdraw/compensation_fund_receive mutability windows.",
194
194
  },
@@ -315,8 +315,8 @@ export const SCHEMA_TO_SEMANTIC_RULES = [
315
315
  },
316
316
  {
317
317
  element_type: "field",
318
- type_name: "setting_locked_time_add",
319
- semantic_explanation: "Extend setting_lock_duration (only-increase, safe_add). Index 317 (SERVICE_COMPENSATION_LOCKED_TIME_ADD).",
318
+ type_name: "setting_lock_duration_add",
319
+ semantic_explanation: "Extend setting_lock_duration (only-increase, safe_add). Index 317 (SERVICE_COMPENSATION_LOCK_DURATION_ADD).",
320
320
  },
321
321
  {
322
322
  element_type: "field",
@@ -454,7 +454,7 @@ export const SERVICE_CONSTRAINT_RULES = [
454
454
  id: "MC-S-16",
455
455
  category: "lifecycle",
456
456
  rule: `setting_lock_duration only-increase (safe_add) — cannot be decreased; protects customers`,
457
- applies_to: ["setting_locked_time_add"],
457
+ applies_to: ["setting_lock_duration_add"],
458
458
  },
459
459
  {
460
460
  id: "MC-S-17",
@@ -572,8 +572,8 @@ export function explainServiceCallData(data) {
572
572
  if (data.compensation_fund_receive) {
573
573
  lines.push(`- Compensation fund receive (locked by duration)`);
574
574
  }
575
- if (data.setting_locked_time_add !== undefined) {
576
- lines.push(`- Setting lock duration +${data.setting_locked_time_add}ms (only-increase)`);
575
+ if (data.setting_lock_duration_add !== undefined) {
576
+ lines.push(`- Setting lock duration +${data.setting_lock_duration_add}ms (only-increase)`);
577
577
  }
578
578
  if (data.order_new) {
579
579
  const o = data.order_new;
@@ -33,9 +33,13 @@ export const TOOL_CONSTRAINTS = [
33
33
  return true;
34
34
  if (!d?.publish)
35
35
  return true;
36
- return Array.isArray(d?.node?.nodes) && d.node.nodes.length > 0;
36
+ if (Array.isArray(d?.node?.nodes) && d.node.nodes.length > 0)
37
+ return true;
38
+ if (typeof d?.node?.json_or_markdown_file === "string" && d.node.json_or_markdown_file.length > 0)
39
+ return true;
40
+ return false;
37
41
  },
38
- message: () => "Publishing a Machine without nodes — a workflow template requires at least one node. Consider adding nodes before publish, or publish later after adding nodes.",
42
+ message: () => "Publishing a Machine without nodes — a workflow template requires at least one node. Provide nodes via inline `node.nodes` array OR `node.json_or_markdown_file` path (file contains JSON or Markdown node definitions). Consider adding nodes before publish, or publish later after adding nodes.",
39
43
  },
40
44
  ],
41
45
  },
@@ -1,5 +1,5 @@
1
1
  import type { DeploymentDocValidationResult } from "./deployment-doc.js";
2
- export declare function generateDeploymentDocFromProject(projectId: string, network: "testnet" | "mainnet"): Promise<{
2
+ export declare function generateDeploymentDocFromProject(projectId: string, network: "testnet" | "mainnet", detailLevel?: "summary" | "detailed" | "full"): Promise<{
3
3
  markdown: string;
4
4
  validation: DeploymentDocValidationResult;
5
5
  }>;
@@ -1,6 +1,7 @@
1
1
  import { LocalProject } from "@wowok/wowok";
2
2
  import { generateDeploymentDoc, validateDeploymentDoc } from "./deployment-doc.js";
3
- export async function generateDeploymentDocFromProject(projectId, network) {
3
+ import { isObjectOfType, shortTypeName } from "../schema/utils/object-type-utils.js";
4
+ export async function generateDeploymentDocFromProject(projectId, network, detailLevel) {
4
5
  const project = await LocalProject.Instance().getProject(projectId);
5
6
  if (!project) {
6
7
  throw new Error(`Project not found: ${projectId}`);
@@ -8,15 +9,36 @@ export async function generateDeploymentDocFromProject(projectId, network) {
8
9
  const objects = await LocalProject.Instance().listObjects(projectId);
9
10
  const graphEdges = await LocalProject.Instance().getGraph(projectId);
10
11
  const evaluations = await LocalProject.Instance().listEvaluations(projectId, { evalType: "risk" });
11
- const validObjects = objects.filter((o) => o.objectType !== null && o.objectType !== undefined);
12
+ const validObjects = objects.filter((o) => {
13
+ if (o.objectType === null || o.objectType === undefined)
14
+ return false;
15
+ if (o.objectName && /^0x[0-9a-fA-F]{40,}$/.test(o.objectName))
16
+ return false;
17
+ const meta = (o.metadata ?? {});
18
+ const typeRaw = meta.type_raw;
19
+ if (typeRaw && typeRaw.includes("dynamic_field::Field<"))
20
+ return false;
21
+ return true;
22
+ });
12
23
  const deployObjects = validObjects.map((o) => {
13
24
  const objectType = o.objectType;
25
+ const meta = (o.metadata ?? {});
26
+ const status = meta.status ??
27
+ (o.objectAddress.startsWith("draft:") ? "draft" : "deployed");
28
+ const config = meta.config ?? undefined;
29
+ const publishRequired = meta.publish_required ??
30
+ (isObjectOfType(objectType, "service") || isObjectOfType(objectType, "machine"));
14
31
  return {
15
32
  entry_id: `${objectType}:${o.objectName || o.objectAddress || o.id}`,
16
33
  object_type: normalizeObjectType(objectType),
17
34
  name: o.objectName || o.objectAddress || o.id,
18
- reused_from: o.objectAddress.startsWith("0x") ? o.objectAddress : undefined,
19
- publish_required: objectType === "service" || objectType === "machine",
35
+ reused_from: status === "deployed" && o.objectAddress.startsWith("0x")
36
+ ? o.objectAddress : undefined,
37
+ publish_required: publishRequired,
38
+ description: meta.description ??
39
+ (status === "draft" ? "[blueprint] pending on-chain" : "[on-chain]"),
40
+ config,
41
+ status,
20
42
  };
21
43
  });
22
44
  const addrToEntryId = new Map();
@@ -29,6 +51,7 @@ export async function generateDeploymentDocFromProject(projectId, network) {
29
51
  if (o.objectName) {
30
52
  addrToEntryId.set(o.objectName, entryId);
31
53
  }
54
+ addrToEntryId.set(entryId, entryId);
32
55
  }
33
56
  const deployEdges = graphEdges.map((e) => ({
34
57
  from: addrToEntryId.get(e.sourceObject) ?? e.sourceObject,
@@ -56,16 +79,17 @@ export async function generateDeploymentDocFromProject(projectId, network) {
56
79
  risk_status,
57
80
  risk_critical_count,
58
81
  risk_high_count,
82
+ detail_level: detailLevel,
59
83
  };
60
84
  const markdown = generateDeploymentDoc(input);
61
85
  const validation = validateDeploymentDoc(input);
62
86
  return { markdown, validation };
63
87
  }
64
88
  function normalizeObjectType(raw) {
65
- const lower = raw.toLowerCase();
66
- if (lower === "arbitration")
89
+ const short = shortTypeName(raw).toLowerCase();
90
+ if (short === "arbitration")
67
91
  return "arb";
68
- return lower;
92
+ return short;
69
93
  }
70
94
  function buildTopoSteps(objects, edges, network) {
71
95
  const typeOrder = {
@@ -7,6 +7,8 @@ export interface DeploymentObject {
7
7
  reused_from?: string;
8
8
  publish_required: boolean;
9
9
  description?: string;
10
+ config?: Record<string, unknown>;
11
+ status?: "draft" | "deployed";
10
12
  }
11
13
  export interface DeploymentDagEdge {
12
14
  from: string;
@@ -45,6 +47,7 @@ export interface DeploymentDocInput {
45
47
  risk_status?: "RISK_PASSED" | "RISK_BLOCKED" | "RISK_PENDING_CONFIRM" | "RISK_CANCELLED";
46
48
  risk_critical_count?: number;
47
49
  risk_high_count?: number;
50
+ detail_level?: "summary" | "detailed" | "full";
48
51
  }
49
52
  export interface DeploymentDocValidationResult {
50
53
  valid: boolean;