@wowok/agent-mcp 2.6.3 → 2.6.4

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 (192) hide show
  1. package/dist/customer/customer-advice.d.ts +31 -0
  2. package/dist/customer/customer-advice.js +129 -0
  3. package/dist/customer/index.d.ts +2 -0
  4. package/dist/customer/index.js +2 -0
  5. package/dist/customer/info-puzzle.d.ts +8 -1
  6. package/dist/customer/info-puzzle.js +30 -5
  7. package/dist/customer/order-monitor.d.ts +2 -0
  8. package/dist/customer/order-monitor.js +3 -2
  9. package/dist/customer/post-purchase.d.ts +2 -0
  10. package/dist/customer/post-purchase.js +6 -5
  11. package/dist/customer/preorder-compare.d.ts +24 -0
  12. package/dist/customer/preorder-compare.js +34 -0
  13. package/dist/customer/reminder-system.d.ts +2 -0
  14. package/dist/customer/reminder-system.js +2 -1
  15. package/dist/customer/risk-assessment.js +4 -3
  16. package/dist/customer/types.d.ts +5 -0
  17. package/dist/examples/arbitration-dispute-create.json +41 -0
  18. package/dist/examples/arbitration-vote-weighted.json +35 -0
  19. package/dist/examples/arbitration-voting-guard-add.json +38 -0
  20. package/dist/examples/demand-present-service.json +33 -0
  21. package/dist/examples/gen-passport-verify-guard.json +48 -0
  22. package/dist/examples/guard-template-balance-check.json +36 -15
  23. package/dist/examples/guard-template-time-lock.json +33 -12
  24. package/dist/examples/insurance-guard-claim-timelock.json +75 -0
  25. package/dist/examples/insurance-guard-withdraw-allocation.json +96 -0
  26. package/dist/examples/insurance-machine-create-publish.json +75 -0
  27. package/dist/examples/insurance-service-allocators-publish.json +56 -0
  28. package/dist/examples/machine-multisig-threshold.json +86 -0
  29. package/dist/examples/machine-template-7node-rental.json +99 -94
  30. package/dist/examples/payment-scenario-bound.json +45 -0
  31. package/dist/examples/rental-ziroom-machine-create.json +126 -114
  32. package/dist/examples/rental-ziroom-permission-create.json +10 -3
  33. package/dist/examples/rental-ziroom-service-create.json +27 -18
  34. package/dist/examples/retail-adv-guard-customer-win-create.json +80 -0
  35. package/dist/examples/retail-adv-guard-messenger-proof-create.json +65 -0
  36. package/dist/examples/retail-adv-guard-reward-timeout-create.json +92 -0
  37. package/dist/examples/retail-adv-reward-guard-add.json +51 -0
  38. package/dist/examples/retail-myshop-allocation-activate.json +55 -0
  39. package/dist/examples/retail-myshop-arbitration-create.json +40 -0
  40. package/dist/examples/retail-myshop-contact-create.json +43 -0
  41. package/dist/examples/retail-myshop-order-create.json +56 -0
  42. package/dist/examples/retail-myshop-progress-operate.json +38 -0
  43. package/dist/examples/retail-myshop-reward-create.json +35 -0
  44. package/dist/examples/service-discount-issue.json +46 -0
  45. package/dist/examples/threebody-guard-create.json +56 -0
  46. package/dist/examples/threebody-machine-create.json +72 -0
  47. package/dist/examples/threebody-permission-create.json +38 -0
  48. package/dist/examples/threebody-service-allocators.json +49 -0
  49. package/dist/examples/travel-guard-time-lock.json +69 -0
  50. package/dist/examples/travel-guard-weather-oracle.json +70 -0
  51. package/dist/examples/travel-machine-create.json +136 -0
  52. package/dist/examples/travel-repository-create.json +47 -0
  53. package/dist/examples/travel-service-create.json +102 -0
  54. package/dist/examples/travel-treasury-create.json +34 -0
  55. package/dist/examples/treasury-deposit.json +37 -0
  56. package/dist/examples/treasury-withdraw.json +38 -0
  57. package/dist/extensions/business-modules.d.ts +49 -0
  58. package/dist/extensions/business-modules.js +287 -0
  59. package/dist/extensions/capability-manifest.js +192 -5
  60. package/dist/extensions/constraint-registry.js +3 -1
  61. package/dist/extensions/modes.js +10 -4
  62. package/dist/extensions/registry.d.ts +14 -9
  63. package/dist/extensions/registry.js +69 -14
  64. package/dist/extensions/types.d.ts +1 -0
  65. package/dist/knowledge/fund-layer.d.ts +67 -1
  66. package/dist/knowledge/fund-layer.js +561 -12
  67. package/dist/knowledge/guard-templates.d.ts +10 -0
  68. package/dist/knowledge/guard-templates.js +50 -0
  69. package/dist/knowledge/index.d.ts +2 -2
  70. package/dist/knowledge/index.js +2 -2
  71. package/dist/knowledge/machine-risk.js +4 -1
  72. package/dist/knowledge/progress-context.js +1 -1
  73. package/dist/knowledge/progress-ledger.js +3 -3
  74. package/dist/knowledge/progress-templates.js +1 -1
  75. package/dist/knowledge/progress-translation.js +1 -1
  76. package/dist/knowledge/safety-rules.d.ts +83 -1
  77. package/dist/knowledge/safety-rules.js +166 -2
  78. package/dist/knowledge/scenario-modes.d.ts +1 -1
  79. package/dist/knowledge/scenario-modes.js +13 -11
  80. package/dist/knowledge/template-registry.d.ts +48 -0
  81. package/dist/knowledge/template-registry.js +341 -0
  82. package/dist/knowledge/tool-constraints.js +6 -6
  83. package/dist/knowledge/tools-reference.js +11 -8
  84. package/dist/participation/merchant-interest.d.ts +32 -0
  85. package/dist/participation/merchant-interest.js +100 -0
  86. package/dist/participation/radar-core.d.ts +104 -0
  87. package/dist/participation/radar-core.js +269 -0
  88. package/dist/project/context-assembly.js +8 -0
  89. package/dist/project/edit-planner.js +27 -56
  90. package/dist/project/evaluation.d.ts +36 -0
  91. package/dist/project/evaluation.js +422 -56
  92. package/dist/project/game-theory.d.ts +43 -0
  93. package/dist/project/game-theory.js +177 -0
  94. package/dist/project/graph-builder.js +1 -0
  95. package/dist/project/handlers.d.ts +38 -0
  96. package/dist/project/handlers.js +65 -35
  97. package/dist/project/intent-analyzer.d.ts +71 -0
  98. package/dist/project/intent-analyzer.js +149 -0
  99. package/dist/project/machine-nodes.d.ts +2 -0
  100. package/dist/project/machine-nodes.js +36 -0
  101. package/dist/project/merchant-guide.d.ts +165 -0
  102. package/dist/project/merchant-guide.js +264 -0
  103. package/dist/project/mode-actions.d.ts +199 -0
  104. package/dist/project/mode-actions.js +309 -0
  105. package/dist/project/participation-radar.d.ts +18 -0
  106. package/dist/project/participation-radar.js +428 -0
  107. package/dist/project/pipeline-actions.d.ts +101 -0
  108. package/dist/project/pipeline-actions.js +109 -0
  109. package/dist/project/semantic-graph.d.ts +95 -0
  110. package/dist/project/semantic-graph.js +245 -0
  111. package/dist/schema/call/allocation.d.ts +11 -11
  112. package/dist/schema/call/allocation.js +11 -1
  113. package/dist/schema/call/arbitration.d.ts +21 -21
  114. package/dist/schema/call/arbitration.js +17 -9
  115. package/dist/schema/call/base.d.ts +2 -2
  116. package/dist/schema/call/base.js +1 -1
  117. package/dist/schema/call/bridge.d.ts +127 -127
  118. package/dist/schema/call/bridge.js +12 -12
  119. package/dist/schema/call/contact.d.ts +3 -3
  120. package/dist/schema/call/demand.d.ts +3 -3
  121. package/dist/schema/call/guard.d.ts +11 -11
  122. package/dist/schema/call/guard.js +1 -1
  123. package/dist/schema/call/machine.d.ts +216 -21
  124. package/dist/schema/call/machine.js +1 -1
  125. package/dist/schema/call/order.d.ts +7 -7
  126. package/dist/schema/call/payment.d.ts +3 -3
  127. package/dist/schema/call/permission.d.ts +3 -3
  128. package/dist/schema/call/personal.d.ts +337 -3
  129. package/dist/schema/call/personal.js +10 -0
  130. package/dist/schema/call/progress.d.ts +177 -9
  131. package/dist/schema/call/progress.js +7 -3
  132. package/dist/schema/call/proof.d.ts +6 -6
  133. package/dist/schema/call/repository.d.ts +3 -3
  134. package/dist/schema/call/reward.d.ts +57 -57
  135. package/dist/schema/call/semantic.js +41 -1
  136. package/dist/schema/call/service.d.ts +114 -114
  137. package/dist/schema/call/service.js +11 -2
  138. package/dist/schema/call/treasury.d.ts +57 -57
  139. package/dist/schema/messenger/index.js +4 -1
  140. package/dist/schema/operations.d.ts +713 -291
  141. package/dist/schema/operations.js +33 -0
  142. package/dist/schema/project/index.d.ts +4635 -100
  143. package/dist/schema/project/index.js +868 -1
  144. package/dist/schema/query/index.d.ts +363 -19
  145. package/dist/schema/query/index.js +25 -3
  146. package/dist/schema/schema-query/index.d.ts +13 -7
  147. package/dist/schema/schema-query/index.js +29 -5
  148. package/dist/schema/trust/index.d.ts +1012 -6
  149. package/dist/schema/trust/index.js +212 -11
  150. package/dist/schema/utils/skills-recommendation.js +1 -0
  151. package/dist/schema-query/index.d.ts +4 -1
  152. package/dist/schema-query/index.js +255 -1
  153. package/dist/schemas/bridge_operation.schema.json +14 -7
  154. package/dist/schemas/guard2file.schema.json +2 -0
  155. package/dist/schemas/index.json +1 -1
  156. package/dist/schemas/machineNode2file.schema.json +2 -0
  157. package/dist/schemas/messenger_operation.schema.json +1 -1
  158. package/dist/schemas/onchain_operations.schema.json +143 -15
  159. package/dist/schemas/onchain_operations_allocation.schema.json +2 -1
  160. package/dist/schemas/onchain_operations_arbitration.schema.json +7 -5
  161. package/dist/schemas/onchain_operations_contact.schema.json +1 -0
  162. package/dist/schemas/onchain_operations_demand.schema.json +1 -0
  163. package/dist/schemas/onchain_operations_gen_passport.schema.json +2 -0
  164. package/dist/schemas/onchain_operations_gen_proof.schema.json +2 -0
  165. package/dist/schemas/onchain_operations_guard.schema.json +578 -0
  166. package/dist/schemas/onchain_operations_machine.schema.json +1 -0
  167. package/dist/schemas/onchain_operations_order.schema.json +4 -3
  168. package/dist/schemas/onchain_operations_payment.schema.json +1 -0
  169. package/dist/schemas/onchain_operations_permission.schema.json +1 -0
  170. package/dist/schemas/onchain_operations_personal.schema.json +37 -0
  171. package/dist/schemas/onchain_operations_progress.schema.json +90 -3
  172. package/dist/schemas/onchain_operations_proof.schema.json +1 -0
  173. package/dist/schemas/onchain_operations_repository.schema.json +1 -0
  174. package/dist/schemas/onchain_operations_reward.schema.json +1 -0
  175. package/dist/schemas/onchain_operations_service.schema.json +4 -3
  176. package/dist/schemas/onchain_operations_treasury.schema.json +1 -0
  177. package/dist/schemas/project_operation.output.json +2243 -1
  178. package/dist/schemas/project_operation.schema.json +683 -1
  179. package/dist/schemas/query_toolkit.output.json +1 -1
  180. package/dist/schemas/query_toolkit.schema.json +37 -0
  181. package/dist/schemas/schema_query.output.json +1 -1
  182. package/dist/schemas/schema_query.schema.json +30 -5
  183. package/dist/schemas/trust_score.output.json +392 -1
  184. package/dist/schemas/trust_score.schema.json +275 -1
  185. package/dist/tools/handlers/onchain.js +73 -8
  186. package/dist/tools/handlers/project.js +46 -0
  187. package/dist/tools/handlers/query.js +117 -2
  188. package/dist/tools/handlers/schema-query.js +41 -0
  189. package/dist/tools/handlers/trust.js +192 -6
  190. package/dist/tools/index.js +52 -9
  191. package/dist/tools/wrap.js +194 -15
  192. package/package.json +2 -2
@@ -0,0 +1,269 @@
1
+ const DEFAULT_ANNOTATIONS = {
2
+ completed: ["complete", "completed", "done", "finish", "finished", "delivered", "accepted"],
3
+ refunded: ["refund", "refunded", "cancelled", "canceled", "lost", "closed"],
4
+ };
5
+ export function analyzeOrderParticipation(input) {
6
+ const annotations = {
7
+ completed: input.node_annotations?.completed ?? DEFAULT_ANNOTATIONS.completed,
8
+ refunded: input.node_annotations?.refunded ?? DEFAULT_ANNOTATIONS.refunded,
9
+ };
10
+ const current = input.current_node ?? "";
11
+ const isOrderHolder = !!input.order_holder && input.order_holder === input.account;
12
+ const heldIndexes = new Set();
13
+ if (input.permission?.entityPermissions) {
14
+ for (const [entity, indexes] of input.permission.entityPermissions) {
15
+ if (entity === input.account) {
16
+ for (const idx of indexes)
17
+ heldIndexes.add(idx);
18
+ }
19
+ }
20
+ }
21
+ const perspective = isOrderHolder
22
+ ? "customer"
23
+ : heldIndexes.size > 0
24
+ ? "operator"
25
+ : "observer";
26
+ const operable = [];
27
+ const waiting = [];
28
+ const workflowUnknown = !input.machine_nodes;
29
+ if (input.machine_nodes) {
30
+ for (const node of input.machine_nodes) {
31
+ for (const pair of node.pairs ?? []) {
32
+ if (pair.prev_node !== current)
33
+ continue;
34
+ for (const fwd of pair.forwards ?? []) {
35
+ const rf = resolveForward(fwd, node.name, input, isOrderHolder, heldIndexes, annotations);
36
+ if (rf.execution_path === "not_available") {
37
+ const role = fwd.permissionIndex != null
38
+ ? `permission index ${fwd.permissionIndex}`
39
+ : fwd.namedOperator === ""
40
+ ? "OrderHolder (customer)"
41
+ : `named operator '${fwd.namedOperator}'`;
42
+ const entry = waiting.find(w => w.role === role);
43
+ if (entry)
44
+ entry.forwards.push(rf.name);
45
+ else
46
+ waiting.push({ role, forwards: [rf.name] });
47
+ }
48
+ else {
49
+ operable.push(rf);
50
+ }
51
+ }
52
+ }
53
+ }
54
+ }
55
+ const roles = [];
56
+ if (isOrderHolder) {
57
+ roles.push({
58
+ label: "OrderHolder (customer)",
59
+ can_act_now: operable.some(f => f.execution_path === "order_holder"),
60
+ });
61
+ }
62
+ for (const idx of [...heldIndexes].sort((a, b) => a - b)) {
63
+ roles.push({
64
+ label: `permission index ${idx}`,
65
+ can_act_now: operable.some(f => f.permission_index === idx),
66
+ });
67
+ }
68
+ if (input.named_accounts) {
69
+ for (const [name, addr] of Object.entries(input.named_accounts)) {
70
+ if (nameResolvesTo(addr, input.account)) {
71
+ roles.push({
72
+ label: `named operator '${name}'`,
73
+ can_act_now: operable.some(f => f.named_operator === name),
74
+ });
75
+ }
76
+ }
77
+ }
78
+ let branchChoice;
79
+ if (operable.length > 1) {
80
+ branchChoice = {
81
+ message: `${operable.length} operations are available to you at node '${current || "(entry)"}'. ` +
82
+ `Each leads to a different outcome — review the consequences and choose; no one else can make this decision for you.`,
83
+ options: operable.map(f => ({
84
+ forward: f.name,
85
+ to_node: f.to_node,
86
+ consequence: f.consequence,
87
+ })),
88
+ };
89
+ }
90
+ const claims = [];
91
+ for (const r of input.claimable_rewards ?? []) {
92
+ if (r.already_claimed)
93
+ continue;
94
+ claims.push({
95
+ kind: "reward",
96
+ label: r.description ?? `Reward ${r.address}`,
97
+ how: `onchain_operations reward op='claim' (object='${r.address}')`,
98
+ });
99
+ }
100
+ if (input.pending_compensation) {
101
+ claims.push({
102
+ kind: "compensation",
103
+ label: input.pending_compensation.note ?? "Arbitration indemnity awarded to you",
104
+ how: `onchain_operations service op='compensation_claim' (arbitration='${input.pending_compensation.arbitration}') — paid directly from the Service compensation_fund`,
105
+ });
106
+ }
107
+ if (input.discount_available) {
108
+ claims.push({
109
+ kind: "discount",
110
+ label: input.discount_available,
111
+ how: "Mention the discount when placing the next order (reward discount config applies at purchase)",
112
+ });
113
+ }
114
+ if (input.rating_pending) {
115
+ claims.push({
116
+ kind: "rating",
117
+ label: "Rate this transaction (like/dislike) — builds on-chain reputation for both sides",
118
+ how: "onchain_operations operation_type='personal', data.mark={op:'like'|'dislike', address:'<merchant address>'} — votes through registrar::like/dislike into the PUBLIC aggregate count",
119
+ });
120
+ }
121
+ const hints = buildInterestHints(input, perspective, operable, waiting, current);
122
+ const summary = buildSummary(input, perspective, roles, operable, waiting, claims, workflowUnknown, current);
123
+ return {
124
+ account: input.account,
125
+ progress: input.progress_address,
126
+ order: input.order_address,
127
+ current_node: current,
128
+ perspective,
129
+ roles,
130
+ operable,
131
+ branch_choice: branchChoice,
132
+ waiting_on: waiting,
133
+ pending_claims: claims,
134
+ interest_hints: hints,
135
+ workflow_unknown: workflowUnknown,
136
+ summary,
137
+ };
138
+ }
139
+ export function aggregateRadar(results, unreadTotal) {
140
+ const actionable = results
141
+ .filter(r => r.operable.length > 0 || r.pending_claims.length > 0)
142
+ .sort((a, b) => (a.perspective === "customer" ? 0 : 1) - (b.perspective === "customer" ? 0 : 1));
143
+ const waiting = results.filter(r => r.operable.length === 0 && r.pending_claims.length === 0);
144
+ const allClaims = results.flatMap(r => r.pending_claims.map(c => ({ ...c, progress: r.progress })));
145
+ const summary = results.length === 0
146
+ ? "No in-flight orders found for this account."
147
+ : `${results.length} in-flight order(s): ${actionable.length} need your action or have claims, ${waiting.length} are waiting on other roles. ` +
148
+ (allClaims.length > 0 ? `${allClaims.length} unclaimed benefit(s) detected. ` : "") +
149
+ (actionable.length > 0 ? `Top priority: ${actionable[0].summary}` : "Nothing requires your action right now.");
150
+ return {
151
+ account: results[0]?.account ?? "",
152
+ orders_analyzed: results.length,
153
+ actionable,
154
+ waiting,
155
+ all_pending_claims: allClaims,
156
+ unread_messages_total: unreadTotal ?? 0,
157
+ summary,
158
+ };
159
+ }
160
+ function nameResolvesTo(value, account) {
161
+ if (!value)
162
+ return false;
163
+ return Array.isArray(value) ? value.includes(account) : value === account;
164
+ }
165
+ export function isConsequenceNode(nodeName, kind, annotations) {
166
+ const list = annotations?.[kind] ?? DEFAULT_ANNOTATIONS[kind];
167
+ const lower = (nodeName ?? "").toLowerCase();
168
+ return list.some(n => lower.includes(n));
169
+ }
170
+ function resolveForward(fwd, nodeName, input, isOrderHolder, heldIndexes, annotations) {
171
+ let path = "not_available";
172
+ if (fwd.permissionIndex != null) {
173
+ if (heldIndexes.has(fwd.permissionIndex))
174
+ path = "permission";
175
+ }
176
+ else if (fwd.namedOperator === "") {
177
+ if (isOrderHolder)
178
+ path = "order_holder";
179
+ }
180
+ else if (fwd.namedOperator != null) {
181
+ const resolved = input.named_accounts?.[fwd.namedOperator];
182
+ if (nameResolvesTo(resolved, input.account))
183
+ path = "named_operator";
184
+ }
185
+ const toNode = nodeName;
186
+ const semantics = describeForward(fwd.name ?? "", toNode, path, fwd.permissionIndex, fwd.namedOperator);
187
+ const consequence = consequenceOf(toNode, annotations);
188
+ return {
189
+ name: fwd.name ?? "(unnamed)",
190
+ to_node: toNode,
191
+ execution_path: path,
192
+ permission_index: fwd.permissionIndex ?? undefined,
193
+ named_operator: fwd.namedOperator ?? undefined,
194
+ guard: fwd.guard ?? undefined,
195
+ semantics,
196
+ consequence,
197
+ };
198
+ }
199
+ function describeForward(name, toNode, path, permissionIndex, namedOperator) {
200
+ const gate = permissionIndex != null
201
+ ? `requires permission index ${permissionIndex}`
202
+ : namedOperator === ""
203
+ ? "executable by the order holder (customer)"
204
+ : `executable by named operator '${namedOperator}'`;
205
+ const access = path === "not_available" ? "You CANNOT execute this" : "You CAN execute this";
206
+ return `'${name}' advances the order to node '${toNode}' (${gate}). ${access}.`;
207
+ }
208
+ function consequenceOf(toNode, annotations) {
209
+ if (isConsequenceNode(toNode, "completed", annotations)) {
210
+ return "Completion path — funds are released to the merchant per the Allocation waterfall; refunds become harder after this point.";
211
+ }
212
+ if (isConsequenceNode(toNode, "refunded", annotations)) {
213
+ return "Refund/cancellation path — escrowed funds return to the buyer per the Allocation configuration.";
214
+ }
215
+ return undefined;
216
+ }
217
+ function buildInterestHints(input, perspective, operable, waiting, current) {
218
+ const hints = [];
219
+ const now = input.now ?? Date.now();
220
+ const stalledHours = input.last_progress_at != null
221
+ ? (now - input.last_progress_at) / 3_600_000
222
+ : undefined;
223
+ if (perspective === "customer") {
224
+ if (operable.length > 0) {
225
+ hints.push("Your confirmation is the fund-release trigger: escrowed money stays locked until YOU act — only confirm when the deliverable matches the agreement.");
226
+ }
227
+ if (waiting.some(w => w.role !== "OrderHolder (customer)")) {
228
+ hints.push("Delivery depends on the merchant-side roles listed in waiting_on; if they stall, Messenger first, then consider dispute via the bound Arbitration.");
229
+ }
230
+ if (stalledHours != null && stalledHours > 24) {
231
+ hints.push(`Order has not advanced for ${Math.round(stalledHours)}h. Your leverage: compensation_fund (if any) + arbitration + on-chain reputation (dislike) — in that order.`);
232
+ }
233
+ }
234
+ else if (perspective === "operator") {
235
+ const myBlocking = waiting.filter(w => w.role.startsWith("permission index"));
236
+ if (operable.length > 0) {
237
+ hints.push("Advancing the workflow NOW improves flow efficiency and shortens your fund-settlement cycle; stalled orders degrade your on-chain reputation metrics (dispute rate, stall statistics).");
238
+ }
239
+ if (myBlocking.length > 0) {
240
+ hints.push("Nodes waiting on YOUR permission indexes are your responsibility surface: prolonged inaction may trigger timeout penalties or disputes recorded permanently on-chain.");
241
+ }
242
+ if (current && operable.length === 0) {
243
+ hints.push("Nothing for you to execute at this node — monitor only; avoid unnecessary interference that creates semantic responsibility.");
244
+ }
245
+ }
246
+ else {
247
+ hints.push("You hold no operative role on this order (observer). On-chain data remains transparent to you for auditing.");
248
+ }
249
+ if ((input.unread_messages ?? 0) > 0) {
250
+ hints.push(`${input.unread_messages} unread Messenger message(s) — negotiation evidence (WTS) forms the arbitration record; timely replies protect your position.`);
251
+ }
252
+ return hints;
253
+ }
254
+ function buildSummary(input, perspective, roles, operable, waiting, claims, workflowUnknown, current) {
255
+ const roleText = roles.length > 0
256
+ ? roles.map(r => r.label).join(", ")
257
+ : "no operative role";
258
+ const nodeText = current === "" ? "(entry, not started)" : `'${current}'`;
259
+ if (workflowUnknown) {
260
+ return `Order ${input.progress_address} is at ${nodeText}; you are ${perspective} (${roleText}). Machine workflow data unavailable — fetch the bound Machine to see executable operations.`;
261
+ }
262
+ const actionText = operable.length > 0
263
+ ? `you can execute: ${operable.map(f => `'${f.name}'→'${f.to_node}'`).join(", ")}`
264
+ : waiting.length > 0
265
+ ? `waiting on ${waiting.map(w => w.role).join(", ")}`
266
+ : "no pending operations at this node";
267
+ const claimText = claims.length > 0 ? ` ${claims.length} unclaimed benefit(s).` : "";
268
+ return `Order at ${nodeText}; you are ${perspective} (${roleText}) — ${actionText}.${claimText}`;
269
+ }
@@ -1,5 +1,6 @@
1
1
  import { createHash } from "crypto";
2
2
  import { query_objects, query_events } from "@wowok/wowok";
3
+ import { annotateEventsMonetaryFields } from "../knowledge/fund-layer.js";
3
4
  import { buildDataSemantic } from "../schema/call/semantic.js";
4
5
  import { collectContextExperience } from "../loop-engineering/context-collect.js";
5
6
  const STATE_TRANSITION_EVENTS = [
@@ -46,6 +47,13 @@ export async function assembleContext(validated) {
46
47
  if (events.length === 0) {
47
48
  events = undefined;
48
49
  }
50
+ else {
51
+ try {
52
+ await annotateEventsMonetaryFields(events, network);
53
+ }
54
+ catch {
55
+ }
56
+ }
49
57
  }
50
58
  const semanticCtx = {
51
59
  operation_type: "assemble_context",
@@ -1,5 +1,6 @@
1
1
  import { randomUUID, createHash } from "node:crypto";
2
- import { LocalProject, LocalMark, query_objects, query_table } from "@wowok/wowok";
2
+ import { LocalProject, LocalMark, query_objects } from "@wowok/wowok";
3
+ import { fetchMachineNodes } from "./machine-nodes.js";
3
4
  import { parseMachineTreeIndented, } from "../knowledge/machine-render.js";
4
5
  import { parseGuardTreeIndented, parseGuardTableJSON, } from "../knowledge/guard-render.js";
5
6
  const PLAN_TTL_MS = 10 * 60 * 1000;
@@ -673,63 +674,33 @@ export async function handleApplyObjectEdit(v) {
673
674
  };
674
675
  }
675
676
  async function fetchCurrentMachine(machineAddress, network) {
676
- const allFieldObjectIds = [];
677
- let cursor = undefined;
678
- for (;;) {
679
- const tableResult = await query_table({
680
- parent: machineAddress,
681
- cursor: cursor ?? undefined,
682
- network,
683
- });
684
- if (!tableResult?.items || tableResult.items.length === 0)
685
- break;
686
- for (const item of tableResult.items) {
687
- if (item.object)
688
- allFieldObjectIds.push(item.object);
689
- }
690
- if (!tableResult.hasNextPage || !tableResult.nextCursor)
691
- break;
692
- cursor = tableResult.nextCursor;
693
- }
677
+ const rawNodes = await fetchMachineNodes(machineAddress, network);
694
678
  const nodeMap = new Map();
695
679
  const edges = [];
696
- if (allFieldObjectIds.length > 0) {
697
- const BATCH = 50;
698
- for (let i = 0; i < allFieldObjectIds.length; i += BATCH) {
699
- const batch = allFieldObjectIds.slice(i, i + BATCH);
700
- const nodeQueryResult = await query_objects({
701
- objects: batch,
702
- network,
703
- });
704
- for (const obj of nodeQueryResult?.objects ?? []) {
705
- if (obj.type === "TableItem_MachineNode") {
706
- const nodeObj = obj;
707
- const nodeName = nodeObj.name;
708
- if (!nodeName)
709
- continue;
710
- if (!nodeMap.has(nodeName)) {
711
- nodeMap.set(nodeName, { name: nodeName, description: null });
712
- }
713
- const pairs = Array.isArray(nodeObj.value) ? nodeObj.value : [];
714
- for (const pair of pairs) {
715
- if (!pair || typeof pair !== "object")
716
- continue;
717
- const from = typeof pair.prev_node === "string" ? pair.prev_node : "";
718
- const to = nodeName;
719
- const threshold = typeof pair.threshold === "number" ? pair.threshold : 1;
720
- const forwardsRaw = Array.isArray(pair.forwards) ? pair.forwards : [];
721
- const forwards = forwardsRaw.map((f) => ({
722
- name: f.name ?? "",
723
- weight: f.weight ?? 1,
724
- named_operator: f.namedOperator ?? null,
725
- permission_index: f.permissionIndex ?? null,
726
- guard: f.guard?.guard ?? f.guard ?? null,
727
- retained_submission: f.retained_submission ?? null,
728
- }));
729
- edges.push({ from, to, threshold, forwards });
730
- }
731
- }
732
- }
680
+ for (const nodeObj of rawNodes) {
681
+ const nodeName = nodeObj.name;
682
+ if (!nodeName)
683
+ continue;
684
+ if (!nodeMap.has(nodeName)) {
685
+ nodeMap.set(nodeName, { name: nodeName, description: null });
686
+ }
687
+ const pairs = Array.isArray(nodeObj.value) ? nodeObj.value : [];
688
+ for (const pair of pairs) {
689
+ if (!pair || typeof pair !== "object")
690
+ continue;
691
+ const from = typeof pair.prev_node === "string" ? pair.prev_node : "";
692
+ const to = nodeName;
693
+ const threshold = typeof pair.threshold === "number" ? pair.threshold : 1;
694
+ const forwardsRaw = Array.isArray(pair.forwards) ? pair.forwards : [];
695
+ const forwards = forwardsRaw.map((f) => ({
696
+ name: f.name ?? "",
697
+ weight: f.weight ?? 1,
698
+ named_operator: f.namedOperator ?? null,
699
+ permission_index: f.permissionIndex ?? null,
700
+ guard: f.guard?.guard ?? f.guard ?? null,
701
+ retained_submission: f.retained_submission ?? null,
702
+ }));
703
+ edges.push({ from, to, threshold, forwards });
733
704
  }
734
705
  }
735
706
  for (const edge of edges) {
@@ -32,6 +32,42 @@ export interface EvaluationInput {
32
32
  }
33
33
  export declare function getNumberField(data: Record<string, unknown> | null, field: string): number;
34
34
  export declare function getMachineNodeCount(data: Record<string, unknown> | null): number;
35
+ export declare const RISK_WEIGHTS: {
36
+ readonly structural_risk: 0.25;
37
+ readonly fund_safety: 0.2;
38
+ readonly operational_risk: 0.15;
39
+ readonly governance_risk: 0.1;
40
+ readonly graph_coherence: 0.2;
41
+ readonly mode_registry: 0.1;
42
+ };
43
+ export declare const TRUST_WEIGHTS: {
44
+ readonly reputation: 0.25;
45
+ readonly arbitration_coverage: 0.2;
46
+ readonly guard_quality: 0.2;
47
+ readonly transparency: 0.15;
48
+ readonly consumer_diligence: 0.2;
49
+ };
50
+ export declare const COMPLETENESS_WEIGHTS: {
51
+ readonly object_coverage: 0.3;
52
+ readonly binding_completeness: 0.25;
53
+ readonly workflow_rationality: 0.2;
54
+ readonly deployment_readiness: 0.25;
55
+ };
56
+ export declare const EXTENDED_DIMENSION_WEIGHTS: {
57
+ readonly escrow_quality: 0.15;
58
+ readonly proof_integrity: 0.1;
59
+ readonly arbitration_fairness: 0.15;
60
+ readonly fee_transparency: 0.1;
61
+ readonly timeout_protection: 0.1;
62
+ readonly supplier_visibility: 0.1;
63
+ readonly content_commitment: 0.1;
64
+ readonly reputation_verifiability: 0.1;
65
+ readonly permission_safety: 0.1;
66
+ };
67
+ export declare function finalizeCriterionScores(baseScores: CriterionScore[], perspective: Project["perspective"]): {
68
+ criterionScores: CriterionScore[];
69
+ overall: number;
70
+ };
35
71
  export declare function runEvaluation(input: EvaluationInput, evaluationType: EvaluationType, llmPrompt?: string): EvaluationResult;
36
72
  export interface ProjectComparisonEntry {
37
73
  projectId: string;