@wowok/agent-mcp 2.6.3 → 2.6.6

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 (193) hide show
  1. package/README.md +13 -9
  2. package/dist/customer/customer-advice.d.ts +31 -0
  3. package/dist/customer/customer-advice.js +129 -0
  4. package/dist/customer/index.d.ts +2 -0
  5. package/dist/customer/index.js +2 -0
  6. package/dist/customer/info-puzzle.d.ts +8 -1
  7. package/dist/customer/info-puzzle.js +30 -5
  8. package/dist/customer/order-monitor.d.ts +2 -0
  9. package/dist/customer/order-monitor.js +3 -2
  10. package/dist/customer/post-purchase.d.ts +2 -0
  11. package/dist/customer/post-purchase.js +6 -5
  12. package/dist/customer/preorder-compare.d.ts +24 -0
  13. package/dist/customer/preorder-compare.js +34 -0
  14. package/dist/customer/reminder-system.d.ts +2 -0
  15. package/dist/customer/reminder-system.js +2 -1
  16. package/dist/customer/risk-assessment.js +4 -3
  17. package/dist/customer/types.d.ts +5 -0
  18. package/dist/examples/arbitration-dispute-create.json +41 -0
  19. package/dist/examples/arbitration-vote-weighted.json +35 -0
  20. package/dist/examples/arbitration-voting-guard-add.json +38 -0
  21. package/dist/examples/demand-present-service.json +33 -0
  22. package/dist/examples/gen-passport-verify-guard.json +48 -0
  23. package/dist/examples/guard-template-balance-check.json +36 -15
  24. package/dist/examples/guard-template-time-lock.json +33 -12
  25. package/dist/examples/insurance-guard-claim-timelock.json +75 -0
  26. package/dist/examples/insurance-guard-withdraw-allocation.json +96 -0
  27. package/dist/examples/insurance-machine-create-publish.json +75 -0
  28. package/dist/examples/insurance-service-allocators-publish.json +56 -0
  29. package/dist/examples/machine-multisig-threshold.json +86 -0
  30. package/dist/examples/machine-template-7node-rental.json +99 -94
  31. package/dist/examples/payment-scenario-bound.json +45 -0
  32. package/dist/examples/rental-ziroom-machine-create.json +126 -114
  33. package/dist/examples/rental-ziroom-permission-create.json +10 -3
  34. package/dist/examples/rental-ziroom-service-create.json +27 -18
  35. package/dist/examples/retail-adv-guard-customer-win-create.json +80 -0
  36. package/dist/examples/retail-adv-guard-messenger-proof-create.json +65 -0
  37. package/dist/examples/retail-adv-guard-reward-timeout-create.json +92 -0
  38. package/dist/examples/retail-adv-reward-guard-add.json +51 -0
  39. package/dist/examples/retail-myshop-allocation-activate.json +55 -0
  40. package/dist/examples/retail-myshop-arbitration-create.json +40 -0
  41. package/dist/examples/retail-myshop-contact-create.json +43 -0
  42. package/dist/examples/retail-myshop-order-create.json +56 -0
  43. package/dist/examples/retail-myshop-progress-operate.json +38 -0
  44. package/dist/examples/retail-myshop-reward-create.json +35 -0
  45. package/dist/examples/service-discount-issue.json +46 -0
  46. package/dist/examples/threebody-guard-create.json +56 -0
  47. package/dist/examples/threebody-machine-create.json +72 -0
  48. package/dist/examples/threebody-permission-create.json +38 -0
  49. package/dist/examples/threebody-service-allocators.json +49 -0
  50. package/dist/examples/travel-guard-time-lock.json +69 -0
  51. package/dist/examples/travel-guard-weather-oracle.json +70 -0
  52. package/dist/examples/travel-machine-create.json +136 -0
  53. package/dist/examples/travel-repository-create.json +47 -0
  54. package/dist/examples/travel-service-create.json +102 -0
  55. package/dist/examples/travel-treasury-create.json +34 -0
  56. package/dist/examples/treasury-deposit.json +37 -0
  57. package/dist/examples/treasury-withdraw.json +38 -0
  58. package/dist/extensions/business-modules.d.ts +49 -0
  59. package/dist/extensions/business-modules.js +287 -0
  60. package/dist/extensions/capability-manifest.js +192 -5
  61. package/dist/extensions/constraint-registry.js +3 -1
  62. package/dist/extensions/modes.js +10 -4
  63. package/dist/extensions/registry.d.ts +14 -9
  64. package/dist/extensions/registry.js +69 -14
  65. package/dist/extensions/types.d.ts +1 -0
  66. package/dist/knowledge/fund-layer.d.ts +67 -1
  67. package/dist/knowledge/fund-layer.js +561 -12
  68. package/dist/knowledge/guard-templates.d.ts +10 -0
  69. package/dist/knowledge/guard-templates.js +50 -0
  70. package/dist/knowledge/index.d.ts +2 -2
  71. package/dist/knowledge/index.js +2 -2
  72. package/dist/knowledge/machine-risk.js +4 -1
  73. package/dist/knowledge/progress-context.js +1 -1
  74. package/dist/knowledge/progress-ledger.js +3 -3
  75. package/dist/knowledge/progress-templates.js +1 -1
  76. package/dist/knowledge/progress-translation.js +1 -1
  77. package/dist/knowledge/safety-rules.d.ts +83 -1
  78. package/dist/knowledge/safety-rules.js +166 -2
  79. package/dist/knowledge/scenario-modes.d.ts +1 -1
  80. package/dist/knowledge/scenario-modes.js +13 -11
  81. package/dist/knowledge/template-registry.d.ts +48 -0
  82. package/dist/knowledge/template-registry.js +341 -0
  83. package/dist/knowledge/tool-constraints.js +6 -6
  84. package/dist/knowledge/tools-reference.js +11 -8
  85. package/dist/participation/merchant-interest.d.ts +32 -0
  86. package/dist/participation/merchant-interest.js +100 -0
  87. package/dist/participation/radar-core.d.ts +104 -0
  88. package/dist/participation/radar-core.js +269 -0
  89. package/dist/project/context-assembly.js +8 -0
  90. package/dist/project/edit-planner.js +27 -56
  91. package/dist/project/evaluation.d.ts +36 -0
  92. package/dist/project/evaluation.js +422 -56
  93. package/dist/project/game-theory.d.ts +43 -0
  94. package/dist/project/game-theory.js +177 -0
  95. package/dist/project/graph-builder.js +1 -0
  96. package/dist/project/handlers.d.ts +38 -0
  97. package/dist/project/handlers.js +65 -35
  98. package/dist/project/intent-analyzer.d.ts +71 -0
  99. package/dist/project/intent-analyzer.js +149 -0
  100. package/dist/project/machine-nodes.d.ts +2 -0
  101. package/dist/project/machine-nodes.js +36 -0
  102. package/dist/project/merchant-guide.d.ts +165 -0
  103. package/dist/project/merchant-guide.js +264 -0
  104. package/dist/project/mode-actions.d.ts +199 -0
  105. package/dist/project/mode-actions.js +309 -0
  106. package/dist/project/participation-radar.d.ts +18 -0
  107. package/dist/project/participation-radar.js +428 -0
  108. package/dist/project/pipeline-actions.d.ts +101 -0
  109. package/dist/project/pipeline-actions.js +109 -0
  110. package/dist/project/semantic-graph.d.ts +95 -0
  111. package/dist/project/semantic-graph.js +245 -0
  112. package/dist/schema/call/allocation.d.ts +11 -11
  113. package/dist/schema/call/allocation.js +11 -1
  114. package/dist/schema/call/arbitration.d.ts +21 -21
  115. package/dist/schema/call/arbitration.js +17 -9
  116. package/dist/schema/call/base.d.ts +2 -2
  117. package/dist/schema/call/base.js +1 -1
  118. package/dist/schema/call/bridge.d.ts +127 -127
  119. package/dist/schema/call/bridge.js +12 -12
  120. package/dist/schema/call/contact.d.ts +3 -3
  121. package/dist/schema/call/demand.d.ts +3 -3
  122. package/dist/schema/call/guard.d.ts +11 -11
  123. package/dist/schema/call/guard.js +1 -1
  124. package/dist/schema/call/machine.d.ts +216 -21
  125. package/dist/schema/call/machine.js +1 -1
  126. package/dist/schema/call/order.d.ts +7 -7
  127. package/dist/schema/call/payment.d.ts +3 -3
  128. package/dist/schema/call/permission.d.ts +3 -3
  129. package/dist/schema/call/personal.d.ts +337 -3
  130. package/dist/schema/call/personal.js +10 -0
  131. package/dist/schema/call/progress.d.ts +177 -9
  132. package/dist/schema/call/progress.js +7 -3
  133. package/dist/schema/call/proof.d.ts +6 -6
  134. package/dist/schema/call/repository.d.ts +3 -3
  135. package/dist/schema/call/reward.d.ts +57 -57
  136. package/dist/schema/call/semantic.js +41 -1
  137. package/dist/schema/call/service.d.ts +114 -114
  138. package/dist/schema/call/service.js +11 -2
  139. package/dist/schema/call/treasury.d.ts +57 -57
  140. package/dist/schema/messenger/index.js +4 -1
  141. package/dist/schema/operations.d.ts +713 -291
  142. package/dist/schema/operations.js +33 -0
  143. package/dist/schema/project/index.d.ts +4635 -100
  144. package/dist/schema/project/index.js +868 -1
  145. package/dist/schema/query/index.d.ts +363 -19
  146. package/dist/schema/query/index.js +25 -3
  147. package/dist/schema/schema-query/index.d.ts +13 -7
  148. package/dist/schema/schema-query/index.js +29 -5
  149. package/dist/schema/trust/index.d.ts +1012 -6
  150. package/dist/schema/trust/index.js +212 -11
  151. package/dist/schema/utils/skills-recommendation.js +1 -0
  152. package/dist/schema-query/index.d.ts +4 -1
  153. package/dist/schema-query/index.js +255 -1
  154. package/dist/schemas/bridge_operation.schema.json +14 -7
  155. package/dist/schemas/guard2file.schema.json +2 -0
  156. package/dist/schemas/index.json +1 -1
  157. package/dist/schemas/machineNode2file.schema.json +2 -0
  158. package/dist/schemas/messenger_operation.schema.json +1 -1
  159. package/dist/schemas/onchain_operations.schema.json +143 -15
  160. package/dist/schemas/onchain_operations_allocation.schema.json +2 -1
  161. package/dist/schemas/onchain_operations_arbitration.schema.json +7 -5
  162. package/dist/schemas/onchain_operations_contact.schema.json +1 -0
  163. package/dist/schemas/onchain_operations_demand.schema.json +1 -0
  164. package/dist/schemas/onchain_operations_gen_passport.schema.json +2 -0
  165. package/dist/schemas/onchain_operations_gen_proof.schema.json +2 -0
  166. package/dist/schemas/onchain_operations_guard.schema.json +578 -0
  167. package/dist/schemas/onchain_operations_machine.schema.json +1 -0
  168. package/dist/schemas/onchain_operations_order.schema.json +4 -3
  169. package/dist/schemas/onchain_operations_payment.schema.json +1 -0
  170. package/dist/schemas/onchain_operations_permission.schema.json +1 -0
  171. package/dist/schemas/onchain_operations_personal.schema.json +37 -0
  172. package/dist/schemas/onchain_operations_progress.schema.json +90 -3
  173. package/dist/schemas/onchain_operations_proof.schema.json +1 -0
  174. package/dist/schemas/onchain_operations_repository.schema.json +1 -0
  175. package/dist/schemas/onchain_operations_reward.schema.json +1 -0
  176. package/dist/schemas/onchain_operations_service.schema.json +4 -3
  177. package/dist/schemas/onchain_operations_treasury.schema.json +1 -0
  178. package/dist/schemas/project_operation.output.json +2243 -1
  179. package/dist/schemas/project_operation.schema.json +683 -1
  180. package/dist/schemas/query_toolkit.output.json +1 -1
  181. package/dist/schemas/query_toolkit.schema.json +37 -0
  182. package/dist/schemas/schema_query.output.json +1 -1
  183. package/dist/schemas/schema_query.schema.json +30 -5
  184. package/dist/schemas/trust_score.output.json +392 -1
  185. package/dist/schemas/trust_score.schema.json +275 -1
  186. package/dist/tools/handlers/onchain.js +73 -8
  187. package/dist/tools/handlers/project.js +46 -0
  188. package/dist/tools/handlers/query.js +117 -2
  189. package/dist/tools/handlers/schema-query.js +41 -0
  190. package/dist/tools/handlers/trust.js +192 -6
  191. package/dist/tools/index.js +52 -9
  192. package/dist/tools/wrap.js +194 -15
  193. package/package.json +2 -2
@@ -0,0 +1,341 @@
1
+ import { GUARD_TEMPLATES, fillGuardTemplate, } from "./guard-templates.js";
2
+ import { MACHINE_TEMPLATES, fillTemplate as fillMachineTemplate, } from "./machine-templates.js";
3
+ import { SERVICE_TEMPLATES, fillServiceTemplate, } from "./service-templates.js";
4
+ import { ORDER_TEMPLATES, fillTemplate as fillOrderTemplate, } from "./order-templates.js";
5
+ import { PROGRESS_TEMPLATES, fillProgressTemplate, } from "./progress-templates.js";
6
+ import { ARBITRATION_TEMPLATES, fillTemplate as fillArbitrationTemplate, } from "./arbitration-templates.js";
7
+ import { TREASURY_TEMPLATES, fillTemplate as fillTreasuryTemplate, } from "./treasury-templates.js";
8
+ import { PERMISSION_TEMPLATES, fillTemplate as fillPermissionTemplate, } from "./permission-templates.js";
9
+ import { PASSPORT_TEMPLATES, fillTemplate as fillPassportTemplate, } from "./passport-templates.js";
10
+ import { ALLOCATION_TEMPLATES, fillTemplate as fillAllocationTemplate, } from "./allocation-templates.js";
11
+ import { REWARD_TEMPLATES, } from "./reward-templates.js";
12
+ export const TEMPLATE_REGISTRY_VERSION = 1;
13
+ export const TEMPLATE_OBJECT_TYPES = [
14
+ "guard",
15
+ "machine",
16
+ "service",
17
+ "order",
18
+ "progress",
19
+ "arbitration",
20
+ "treasury",
21
+ "permission",
22
+ "passport",
23
+ "allocation",
24
+ "reward",
25
+ ];
26
+ function normalizeParam(p) {
27
+ return {
28
+ name: p.name,
29
+ type: p.type,
30
+ description: p.description ?? "",
31
+ required: p.required,
32
+ ...(p.default !== undefined ? { default: p.default } : {}),
33
+ ...(p.constraint !== undefined ? { constraint: p.constraint } : {}),
34
+ };
35
+ }
36
+ function guardMeta(t) {
37
+ return {
38
+ id: t.id,
39
+ object_type: "guard",
40
+ name: t.name,
41
+ description: t.description,
42
+ scenes: [t.scene_id],
43
+ industries: t.applicable_industries,
44
+ instantiable: true,
45
+ parameters: t.parameters.map((p) => normalizeParam(p)),
46
+ };
47
+ }
48
+ function machineMeta(t) {
49
+ return {
50
+ id: t.id,
51
+ object_type: "machine",
52
+ name: t.name,
53
+ description: t.description,
54
+ scenes: [t.scene_id],
55
+ industries: t.applicable_industries,
56
+ instantiable: true,
57
+ parameters: t.parameters.map((p) => normalizeParam(p)),
58
+ };
59
+ }
60
+ function bodyMeta(t, objectType, scenes, industries) {
61
+ return {
62
+ id: t.id,
63
+ object_type: objectType,
64
+ name: t.name,
65
+ description: t.description,
66
+ scenes,
67
+ industries,
68
+ instantiable: true,
69
+ parameters: t.params.map((p) => normalizeParam(p)),
70
+ };
71
+ }
72
+ function rewardMeta(t) {
73
+ return {
74
+ id: t.type,
75
+ object_type: "reward",
76
+ name: t.name,
77
+ description: t.description,
78
+ scenes: [],
79
+ industries: [],
80
+ instantiable: false,
81
+ parameters: t.parameters.map((p) => normalizeParam(p)),
82
+ };
83
+ }
84
+ let REGISTRY = null;
85
+ let ID_COLLISIONS = [];
86
+ function buildRegistry() {
87
+ const map = new Map();
88
+ const collisions = [];
89
+ const add = (entry) => {
90
+ if (map.has(entry.meta.id)) {
91
+ collisions.push(entry.meta.id);
92
+ return;
93
+ }
94
+ map.set(entry.meta.id, entry);
95
+ };
96
+ for (const t of GUARD_TEMPLATES) {
97
+ add({ meta: guardMeta(t), raw: t, notes: t.creation_notes });
98
+ }
99
+ for (const t of MACHINE_TEMPLATES) {
100
+ add({ meta: machineMeta(t), raw: t, notes: t.creation_notes });
101
+ }
102
+ for (const t of SERVICE_TEMPLATES) {
103
+ add({
104
+ meta: bodyMeta(t, "service", t.applicable_scenes, t.industry_tags),
105
+ raw: t,
106
+ notes: t.notes,
107
+ });
108
+ }
109
+ for (const t of ORDER_TEMPLATES) {
110
+ add({
111
+ meta: bodyMeta(t, "order", t.applicable_scenes, t.industry_tags),
112
+ raw: t,
113
+ notes: t.notes,
114
+ });
115
+ }
116
+ for (const t of PROGRESS_TEMPLATES) {
117
+ add({
118
+ meta: bodyMeta(t, "progress", t.applicable_scenes, t.industry_tags),
119
+ raw: t,
120
+ notes: t.notes,
121
+ });
122
+ }
123
+ for (const t of ARBITRATION_TEMPLATES) {
124
+ add({
125
+ meta: bodyMeta(t, "arbitration", t.applicable_scenes, t.industry_tags),
126
+ raw: t,
127
+ notes: t.notes,
128
+ });
129
+ }
130
+ for (const t of TREASURY_TEMPLATES) {
131
+ add({
132
+ meta: bodyMeta(t, "treasury", t.applicable_scenes, t.industry_tags),
133
+ raw: t,
134
+ notes: t.notes,
135
+ });
136
+ }
137
+ for (const t of PERMISSION_TEMPLATES) {
138
+ add({
139
+ meta: bodyMeta(t, "permission", t.applicable_scenes, t.industry_tags),
140
+ raw: t,
141
+ notes: t.notes,
142
+ });
143
+ }
144
+ for (const t of PASSPORT_TEMPLATES) {
145
+ add({
146
+ meta: bodyMeta(t, "passport", t.applicable_scenarios, t.industry_tags),
147
+ raw: t,
148
+ notes: t.notes,
149
+ });
150
+ }
151
+ for (const t of ALLOCATION_TEMPLATES) {
152
+ add({
153
+ meta: bodyMeta(t, "allocation", t.applicable_scenes, t.industry_tags),
154
+ raw: t,
155
+ notes: t.notes,
156
+ });
157
+ }
158
+ for (const t of REWARD_TEMPLATES) {
159
+ add({
160
+ meta: rewardMeta(t),
161
+ raw: t,
162
+ guidance: {
163
+ guardCondition: t.guardCondition,
164
+ amountRange: t.amountRange,
165
+ allocationStrategy: t.allocationStrategy,
166
+ example: t.example,
167
+ relevantGuardOps: t.relevantGuardOps,
168
+ },
169
+ });
170
+ }
171
+ ID_COLLISIONS = collisions;
172
+ return map;
173
+ }
174
+ function registry() {
175
+ if (!REGISTRY) {
176
+ REGISTRY = buildRegistry();
177
+ }
178
+ return REGISTRY;
179
+ }
180
+ export function getTemplateIdCollisions() {
181
+ registry();
182
+ return ID_COLLISIONS;
183
+ }
184
+ export function getTemplateCounts() {
185
+ const counts = Object.fromEntries(TEMPLATE_OBJECT_TYPES.map((t) => [t, 0]));
186
+ for (const entry of registry().values()) {
187
+ counts[entry.meta.object_type] += 1;
188
+ }
189
+ return counts;
190
+ }
191
+ export function listTemplates(objectType) {
192
+ const all = [...registry().values()].map((e) => e.meta);
193
+ return objectType ? all.filter((m) => m.object_type === objectType) : all;
194
+ }
195
+ export function getTemplateDetail(templateId) {
196
+ const entry = registry().get(templateId);
197
+ if (!entry)
198
+ return null;
199
+ return {
200
+ ...entry.meta,
201
+ raw: entry.raw,
202
+ ...(entry.notes ? { notes: entry.notes } : {}),
203
+ ...(entry.guidance ? { guidance: entry.guidance } : {}),
204
+ };
205
+ }
206
+ export function findTemplateObjectType(templateId) {
207
+ return registry().get(templateId)?.meta.object_type ?? null;
208
+ }
209
+ export function instantiateTemplate(templateId, params) {
210
+ const entry = registry().get(templateId);
211
+ if (!entry) {
212
+ return {
213
+ ok: false,
214
+ object_type: null,
215
+ template_id: templateId,
216
+ error: `Template not found: ${templateId}. Use get_templates without 'template' to list all template ids.`,
217
+ };
218
+ }
219
+ const objectType = entry.meta.object_type;
220
+ if (!entry.meta.instantiable) {
221
+ return {
222
+ ok: false,
223
+ object_type: objectType,
224
+ template_id: templateId,
225
+ error: "Reward templates are guidance-only (prose guard conditions) and cannot be " +
226
+ "instantiated into executable JSON. Use the guidance payload to design the " +
227
+ "Reward + Guard manually.",
228
+ guidance: entry.guidance,
229
+ };
230
+ }
231
+ switch (objectType) {
232
+ case "guard": {
233
+ const r = fillGuardTemplate(templateId, params);
234
+ if (!r.ok) {
235
+ return {
236
+ ok: false,
237
+ object_type: objectType,
238
+ template_id: templateId,
239
+ error: r.error,
240
+ ...(r.missing ? { missing_params: r.missing } : {}),
241
+ };
242
+ }
243
+ return {
244
+ ok: true,
245
+ object_type: objectType,
246
+ template_id: templateId,
247
+ body: { table: r.table, root: r.root },
248
+ ...(entry.notes ? { notes: entry.notes } : {}),
249
+ };
250
+ }
251
+ case "machine": {
252
+ const r = fillMachineTemplate(templateId, params);
253
+ if (!r.success) {
254
+ return {
255
+ ok: false,
256
+ object_type: objectType,
257
+ template_id: templateId,
258
+ error: r.validation_errors?.join("; ") ?? "Machine template fill failed",
259
+ ...(r.missing_params ? { missing_params: r.missing_params } : {}),
260
+ };
261
+ }
262
+ return {
263
+ ok: true,
264
+ object_type: objectType,
265
+ template_id: templateId,
266
+ body: { nodes: r.filled_nodes, pairs: r.filled_pairs },
267
+ ...(entry.notes ? { notes: entry.notes } : {}),
268
+ };
269
+ }
270
+ case "service": {
271
+ const r = fillServiceTemplate(templateId, params);
272
+ if (!r.ok) {
273
+ return {
274
+ ok: false,
275
+ object_type: objectType,
276
+ template_id: templateId,
277
+ error: r.error ?? "Service template fill failed",
278
+ ...(r.missing_required ? { missing_params: r.missing_required } : {}),
279
+ };
280
+ }
281
+ return {
282
+ ok: true,
283
+ object_type: objectType,
284
+ template_id: templateId,
285
+ body: r.body,
286
+ ...(entry.notes ? { notes: entry.notes } : {}),
287
+ };
288
+ }
289
+ case "order":
290
+ case "arbitration":
291
+ case "treasury":
292
+ case "permission":
293
+ case "passport":
294
+ case "allocation":
295
+ case "progress": {
296
+ const r = fillBodyTemplate(objectType, templateId, params);
297
+ if (!r.ok) {
298
+ return {
299
+ ok: false,
300
+ object_type: objectType,
301
+ template_id: templateId,
302
+ error: r.error,
303
+ };
304
+ }
305
+ return {
306
+ ok: true,
307
+ object_type: objectType,
308
+ template_id: templateId,
309
+ body: r.body,
310
+ ...(entry.notes ? { notes: entry.notes } : {}),
311
+ };
312
+ }
313
+ default:
314
+ return {
315
+ ok: false,
316
+ object_type: objectType,
317
+ template_id: templateId,
318
+ error: `Instantiation not supported for object_type '${objectType}'`,
319
+ };
320
+ }
321
+ }
322
+ function fillBodyTemplate(objectType, templateId, params) {
323
+ switch (objectType) {
324
+ case "order":
325
+ return fillOrderTemplate(templateId, params);
326
+ case "arbitration":
327
+ return fillArbitrationTemplate(templateId, params);
328
+ case "treasury":
329
+ return fillTreasuryTemplate(templateId, params);
330
+ case "permission":
331
+ return fillPermissionTemplate(templateId, params);
332
+ case "passport":
333
+ return fillPassportTemplate(templateId, params);
334
+ case "allocation":
335
+ return fillAllocationTemplate(templateId, params);
336
+ case "progress":
337
+ return fillProgressTemplate(templateId, params);
338
+ default:
339
+ return { ok: false, error: `No body-template fill for '${objectType}'` };
340
+ }
341
+ }
@@ -48,17 +48,17 @@ export const TOOL_CONSTRAINTS = [
48
48
  constraints: [
49
49
  {
50
50
  field: "revenue",
51
- description: "Payment requires at least one revenue entry",
51
+ description: "Payment requires at least one revenue entry (CREATE mode only)",
52
52
  severity: "error",
53
- check: (d) => Array.isArray(d?.revenue) && d.revenue.length > 0,
54
- message: () => "Payment requires a non-empty 'revenue' array (payment recipients and amounts).",
53
+ check: (d) => d?.receive === true || (Array.isArray(d?.revenue) && d.revenue.length > 0),
54
+ message: () => "Payment requires a non-empty 'revenue' array (payment recipients and amounts). For RECEIVE mode (unwrap CoinWrapper), use {object: '<coinwrapper_id>', receive: true, type_parameter: '0x2::wow::WOW'}.",
55
55
  },
56
56
  {
57
57
  field: "revenue[0].amount",
58
- description: "Payment revenue amount must be specified",
58
+ description: "Payment revenue amount must be specified (CREATE mode only)",
59
59
  severity: "error",
60
- check: (d) => Array.isArray(d?.revenue) && d.revenue.length > 0 &&
61
- (!!d.revenue[0]?.amount?.balance || !!d.revenue[0]?.amount?.coin),
60
+ check: (d) => d?.receive === true || (Array.isArray(d?.revenue) && d.revenue.length > 0 &&
61
+ (!!d.revenue[0]?.amount?.balance || !!d.revenue[0]?.amount?.coin)),
62
62
  message: () => "Payment revenue[0].amount must specify either 'balance' value or 'coin' object (see CoinParamSchema).",
63
63
  },
64
64
  ],
@@ -87,15 +87,15 @@ export const TOOLS_REFERENCE = [
87
87
  },
88
88
  {
89
89
  name: "wowok_buildin_info",
90
- summary: "Protocol info — constants, built-in permissions, guard instructions, network, value types, bridge tokens.",
91
- actions: ["constants", "permissions", "guard", "network", "value_types", "bridge_tokens"],
92
- notes: ["Read-only — authoritative protocol reference."],
90
+ summary: "Protocol info — constants, built-in permissions, common mistakes, guard instructions, network, value types, bridge tokens.",
91
+ actions: ["constants", "built-in permissions", "common mistakes", "guard instructions", "current network", "value types", "mainnet bridge tokens"],
92
+ notes: ["Read-only — authoritative protocol reference.", "Use 'common mistakes' before submitting an operation to learn known field-name/unit/workflow pitfalls."],
93
93
  },
94
94
  {
95
95
  name: "schema_query",
96
- summary: "Look up JSON Schemas for MCP tools and on-chain operations — the authoritative reference.",
97
- actions: ["list", "get", "get_output", "search", "list_operations"],
98
- notes: ["Always check schema before calling an unfamiliar tool."],
96
+ summary: "Look up JSON Schemas for MCP tools and on-chain operations — the authoritative reference. Also serves sunk knowledge: tool reference, Guard design patterns, safety rules.",
97
+ actions: ["list", "get", "get_output", "get_field", "search", "list_operations", "get_guard_templates", "search_examples", "get_tool_reference", "get_guard_design_patterns", "get_safety_rules"],
98
+ notes: ["Always check schema before calling an unfamiliar tool.", "get_field takes a dot-path (field_path) for single-field lookup; search_examples finds verified example files by keyword.", "get_tool_reference/get_guard_design_patterns/get_safety_rules expose the knowledge sunk from the wowok-tools/guard/safety skills — no skills installation required."],
99
99
  },
100
100
  {
101
101
  name: "bridge_operation",
@@ -105,12 +105,15 @@ export const TOOLS_REFERENCE = [
105
105
  },
106
106
  {
107
107
  name: "project_operation",
108
- summary: "Project entity management (SQLite) + 3-pathway graph construction + dual rule-based/LLM-assisted evaluation engine.",
109
- actions: ["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", "assemble_context"],
108
+ summary: "Project entity management (SQLite) + 3-pathway graph construction + dual rule-based/LLM-assisted evaluation engine + industry mode recommendation/registry + C1-C4 intent/risk/substep pipeline.",
109
+ actions: ["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", "assemble_context", "recommend_industry", "list_modes", "derive_user_mode", "evolve_user_mode", "register_user_mode", "unregister_user_mode", "register_custom_metric", "register_custom_constraint", "list_metrics_constraints", "analyze_intent", "aggregate_risks", "trace_substeps"],
110
110
  notes: [
111
111
  "GLM6: Projects are first-class entities with SQLite persistence, rigid project-object relationships.",
112
112
  "Evaluation: risk/trust/completeness are rule-based (computed locally). value/worth_buying require LLM assistance (returns a prompt).",
113
113
  "Graph: 3 pathways — internal references (configurable depth), Registrar inbound (O(1)), potential relationships.",
114
+ "E.7: call recommend_industry BEFORE create_project when the user describes a business without naming an industry — returns top-3 industries + reference examples.",
115
+ "E.2: user modes — derive_user_mode customizes a builtin mode; register_user_mode registers fully custom; R-M1-11 enforced on machine_shape.",
116
+ "C1-C4 pipeline (GLM5-31 §V3/V4): analyze_intent (intent → objects + puzzle snapshots) → aggregate_risks (puzzles OR intent → calibrated risks + RISK_BLOCKED status; optional planned_objects/planned_operations safety checks) → trace_substeps (substep records → DAG coherence + D-10 verdict). All three are pure transformations — no I/O, no confirmation needed.",
114
117
  ],
115
118
  },
116
119
  {
@@ -0,0 +1,32 @@
1
+ import type { RadarForward } from "./radar-core.js";
2
+ export interface MerchantInterestInput {
3
+ account: string;
4
+ current_node: string;
5
+ operable: RadarForward[];
6
+ waiting_on: Array<{
7
+ role: string;
8
+ forwards: string[];
9
+ }>;
10
+ order_amount?: string;
11
+ token_type?: string;
12
+ allocation?: {
13
+ recipient_slots: number;
14
+ guard_gated_slots: number;
15
+ direct_to_me_slots: number;
16
+ to_payer_slots: number;
17
+ };
18
+ compensation_fund?: string;
19
+ arbitration_bound: boolean;
20
+ rewards_count: number;
21
+ stalled_hours?: number;
22
+ terminal?: "completed" | "refunded" | null;
23
+ unread_messages?: number;
24
+ }
25
+ export interface MerchantInterestAnalysis {
26
+ fund_flow: string[];
27
+ responsibility: string[];
28
+ leverage: string[];
29
+ stakes: string[];
30
+ summary: string;
31
+ }
32
+ export declare function analyzeMerchantInterest(input: MerchantInterestInput): MerchantInterestAnalysis;
@@ -0,0 +1,100 @@
1
+ export function analyzeMerchantInterest(input) {
2
+ const fund_flow = [];
3
+ const responsibility = [];
4
+ const leverage = [];
5
+ const stakes = [];
6
+ const token = input.token_type ? ` (${input.token_type})` : "";
7
+ if (input.terminal === "completed") {
8
+ fund_flow.push("Order reached a completion terminal: escrowed funds are released through the Allocation waterfall. " +
9
+ "Verify your expected share arrived (query the Allocation/Treasury objects).");
10
+ }
11
+ else if (input.terminal === "refunded") {
12
+ fund_flow.push("Order reached a refund terminal: escrowed funds returned to the buyer per the Allocation configuration. " +
13
+ "No settlement remains for this order.");
14
+ }
15
+ else {
16
+ if (input.order_amount != null) {
17
+ fund_flow.push(`${input.order_amount} raw units${token} sit escrowed in the Order object — ` +
18
+ "released ONLY by workflow advancement to a completion path (not by time, not by platform decision).");
19
+ }
20
+ if (input.allocation) {
21
+ const a = input.allocation;
22
+ const parts = [`settlement splits across ${a.recipient_slots} recipient slot(s)`];
23
+ if (a.direct_to_me_slots > 0)
24
+ parts.push(`${a.direct_to_me_slots} pay directly to you`);
25
+ if (a.guard_gated_slots > 0)
26
+ parts.push(`${a.guard_gated_slots} are guard-resolved at settlement time (recipient not statically known)`);
27
+ if (a.to_payer_slots > 0)
28
+ parts.push(`${a.to_payer_slots} route back to the payer (refund-oriented)`);
29
+ fund_flow.push(`Allocation waterfall: ${parts.join("; ")}.`);
30
+ }
31
+ else {
32
+ fund_flow.push("Allocation waterfall not configured or unresolved — settlement recipients unknown; " +
33
+ "funds may sit in the Order until an allocation is set or refund path triggers.");
34
+ }
35
+ }
36
+ if (input.compensation_fund != null && input.compensation_fund !== "0") {
37
+ fund_flow.push(`Service compensation_fund holds ${input.compensation_fund} raw units${token} — merchant-funded skin-in-the-game: ` +
38
+ "arbitration indemnity is paid FROM it, but it also converts directly into buyer trust (higher preorder confidence).");
39
+ }
40
+ const myGated = input.operable.filter(f => f.guard);
41
+ if (input.operable.length > 0) {
42
+ responsibility.push(`${input.operable.length} forward(s) are executable by YOUR role right now ` +
43
+ `(${input.operable.map(f => `'${f.name}'`).join(", ")}): inaction keeps settlement locked and the stall is publicly visible on-chain.`);
44
+ }
45
+ if (myGated.length > 0) {
46
+ responsibility.push(`Forward(s) ${myGated.map(f => `'${f.name}'`).join(", ")} are guard-gated: YOU must satisfy the guard conditions ` +
47
+ "(evidence, verification, timing) before execution — prepare submissions (proof/repository data) in advance.");
48
+ }
49
+ if (input.terminal == null && input.operable.length === 0 && input.waiting_on.length > 0) {
50
+ responsibility.push("No forward is yours at this node — you carry no execution responsibility here; " +
51
+ "avoid interfering outside your permission scope (creates semantic responsibility without authority).");
52
+ }
53
+ if (input.operable.length > 0 && input.terminal == null) {
54
+ leverage.push("Advancing NOW shortens your fund-settlement cycle and improves your publicly-visible flow statistics " +
55
+ "(future buyers' trust evaluation reads stall/dispute metrics).");
56
+ }
57
+ const waitingOnCustomer = input.waiting_on.some(w => w.role.includes("OrderHolder"));
58
+ if (waitingOnCustomer && input.terminal == null) {
59
+ leverage.push("The workflow waits on the customer (OrderHolder): a Messenger nudge accelerates fund release " +
60
+ "without creating semantic responsibility — and the conversation is recorded as WTS evidence protecting YOU in a dispute.");
61
+ }
62
+ if (myGated.length > 0) {
63
+ leverage.push("Uploading delivery evidence (Repository/proof) BEFORE executing guard-gated forwards reduces dispute probability " +
64
+ "and pre-builds your arbitration defense.");
65
+ }
66
+ if ((input.unread_messages ?? 0) > 0) {
67
+ leverage.push(`${input.unread_messages} unread message(s) from this order's counterparties — timely replies protect your position (WTS record).`);
68
+ }
69
+ if (input.rewards_count > 0) {
70
+ leverage.push(`${input.rewards_count} reward(s) configured on the Service — honoring them (discounts/bonuses) builds repeat-buyer rate and like/dislike reputation.`);
71
+ }
72
+ if (input.arbitration_bound && input.terminal == null) {
73
+ const fundNote = input.compensation_fund != null && input.compensation_fund !== "0"
74
+ ? `indemnity would be paid from the compensation_fund (${input.compensation_fund} raw units)`
75
+ : "the compensation_fund is empty (indemnity unenforceable — but the arb-loss record still lands)";
76
+ stakes.push(`A dispute path exists: if the customer opens arbitration and you lose, ${fundNote}, ` +
77
+ "and the loss is permanently recorded (arb-loss rate is a public metric in future buyers' trust evaluation).");
78
+ }
79
+ if (input.stalled_hours != null && input.stalled_hours > 72 && input.terminal == null) {
80
+ stakes.push(`Order stalled ${Math.round(input.stalled_hours)}h: prolonged stalls degrade merchant flow statistics ` +
81
+ "and invite dispute/dislike — the two cheapest reputation losses to avoid.");
82
+ }
83
+ if (input.terminal === "refunded") {
84
+ stakes.push("Refund executed: settlement lost. Remaining stakes are reputational — a dislike vote is the customer's residual leverage; " +
85
+ "a professional post-refund Messenger close-out is your residual protection.");
86
+ }
87
+ const pos = input.terminal === "completed"
88
+ ? "order completed — settlement released"
89
+ : input.terminal === "refunded"
90
+ ? "order refunded — settlement lost"
91
+ : input.operable.length > 0
92
+ ? `YOU can advance ${input.operable.length} forward(s) — settlement speed is in your hands`
93
+ : `waiting on ${input.waiting_on.map(w => w.role).join(", ") || "others"} — monitor and nudge`;
94
+ const exposure = input.compensation_fund != null && input.compensation_fund !== "0"
95
+ ? ` Compensation fund at risk: ${input.compensation_fund} raw units.`
96
+ : "";
97
+ const summary = `Merchant interest at node '${input.current_node || "(entry)"}': ${pos}.${exposure} ` +
98
+ "All options above are informational — the decision is yours.";
99
+ return { fund_flow, responsibility, leverage, stakes, summary };
100
+ }
@@ -0,0 +1,104 @@
1
+ import type { PermissionObjectData } from "../schema/utils/permission-machine-check.js";
2
+ export interface RadarMachineNode {
3
+ name: string;
4
+ pairs?: Array<{
5
+ prev_node: string;
6
+ forwards?: Array<{
7
+ name: string;
8
+ permissionIndex?: number | null;
9
+ namedOperator?: string | null;
10
+ guard?: string | null;
11
+ weight?: number | null;
12
+ }>;
13
+ }>;
14
+ }
15
+ export interface NodeAnnotations {
16
+ completed?: string[];
17
+ refunded?: string[];
18
+ }
19
+ export interface OrderRadarInput {
20
+ account: string;
21
+ progress_address: string;
22
+ order_address?: string;
23
+ current_node: string;
24
+ order_holder?: string;
25
+ machine_nodes?: RadarMachineNode[];
26
+ permission?: PermissionObjectData | null;
27
+ named_accounts?: Record<string, string | string[]>;
28
+ node_annotations?: NodeAnnotations;
29
+ claimable_rewards?: Array<{
30
+ address: string;
31
+ description?: string;
32
+ already_claimed?: boolean;
33
+ }>;
34
+ pending_compensation?: {
35
+ arbitration: string;
36
+ note?: string;
37
+ };
38
+ rating_pending?: boolean;
39
+ discount_available?: string;
40
+ last_progress_at?: number;
41
+ now?: number;
42
+ unread_messages?: number;
43
+ }
44
+ export type ParticipationPerspective = "customer" | "operator" | "observer";
45
+ export type ExecutionPath = "order_holder" | "permission" | "named_operator" | "not_available";
46
+ export interface RadarForward {
47
+ name: string;
48
+ to_node: string;
49
+ execution_path: ExecutionPath;
50
+ permission_index?: number;
51
+ named_operator?: string;
52
+ guard?: string;
53
+ semantics: string;
54
+ consequence?: string;
55
+ }
56
+ export interface PendingClaim {
57
+ kind: "reward" | "discount" | "compensation" | "rating";
58
+ label: string;
59
+ how: string;
60
+ }
61
+ export interface RoleSummary {
62
+ label: string;
63
+ can_act_now: boolean;
64
+ }
65
+ export interface OrderRadarResult {
66
+ account: string;
67
+ progress: string;
68
+ order?: string;
69
+ current_node: string;
70
+ perspective: ParticipationPerspective;
71
+ roles: RoleSummary[];
72
+ operable: RadarForward[];
73
+ branch_choice?: {
74
+ message: string;
75
+ options: Array<{
76
+ forward: string;
77
+ to_node: string;
78
+ consequence?: string;
79
+ }>;
80
+ };
81
+ waiting_on: Array<{
82
+ role: string;
83
+ forwards: string[];
84
+ }>;
85
+ pending_claims: PendingClaim[];
86
+ interest_hints: string[];
87
+ workflow_unknown: boolean;
88
+ interest_analysis?: import("./merchant-interest.js").MerchantInterestAnalysis;
89
+ summary: string;
90
+ }
91
+ export declare function analyzeOrderParticipation(input: OrderRadarInput): OrderRadarResult;
92
+ export interface AccountRadarDashboard {
93
+ account: string;
94
+ orders_analyzed: number;
95
+ actionable: OrderRadarResult[];
96
+ waiting: OrderRadarResult[];
97
+ all_pending_claims: Array<PendingClaim & {
98
+ progress: string;
99
+ }>;
100
+ unread_messages_total: number;
101
+ summary: string;
102
+ }
103
+ export declare function aggregateRadar(results: OrderRadarResult[], unreadTotal?: number): AccountRadarDashboard;
104
+ export declare function isConsequenceNode(nodeName: string, kind: keyof Required<NodeAnnotations>, annotations?: NodeAnnotations): boolean;