@wowok/agent-mcp 2.6.1 → 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 (246) 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 +9 -2
  6. package/dist/customer/info-puzzle.js +34 -7
  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 +30 -7
  16. package/dist/customer/types.d.ts +7 -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 +59 -0
  23. package/dist/examples/guard-template-time-lock.json +60 -0
  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 +119 -0
  30. package/dist/examples/payment-scenario-bound.json +45 -0
  31. package/dist/examples/rental-ziroom-machine-create.json +149 -0
  32. package/dist/examples/rental-ziroom-permission-create.json +42 -0
  33. package/dist/examples/rental-ziroom-service-create.json +89 -0
  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/retail-myshop-service-create.json +88 -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 +216 -29
  61. package/dist/extensions/constraint-registry.js +21 -19
  62. package/dist/extensions/metric-registry.js +14 -14
  63. package/dist/extensions/mode-evaluator.js +16 -16
  64. package/dist/extensions/modes.js +141 -49
  65. package/dist/extensions/registry.d.ts +16 -9
  66. package/dist/extensions/registry.js +132 -44
  67. package/dist/extensions/types.d.ts +2 -0
  68. package/dist/index.js +50 -0
  69. package/dist/knowledge/deployment-scanner.js +1 -1
  70. package/dist/knowledge/fund-layer.d.ts +138 -0
  71. package/dist/knowledge/fund-layer.js +969 -0
  72. package/dist/knowledge/guard-render.d.ts +57 -0
  73. package/dist/knowledge/guard-render.js +700 -0
  74. package/dist/knowledge/guard-submission-prompt.d.ts +31 -0
  75. package/dist/knowledge/guard-submission-prompt.js +171 -0
  76. package/dist/knowledge/guard-templates.d.ts +10 -0
  77. package/dist/knowledge/guard-templates.js +50 -0
  78. package/dist/knowledge/index.d.ts +2 -2
  79. package/dist/knowledge/index.js +2 -2
  80. package/dist/knowledge/machine-ledger.js +1 -1
  81. package/dist/knowledge/machine-render.d.ts +41 -0
  82. package/dist/knowledge/machine-render.js +565 -0
  83. package/dist/knowledge/machine-risk.js +4 -1
  84. package/dist/knowledge/machine-templates.js +4 -4
  85. package/dist/knowledge/progress-context.js +1 -1
  86. package/dist/knowledge/progress-ledger.js +3 -3
  87. package/dist/knowledge/progress-templates.js +1 -1
  88. package/dist/knowledge/progress-translation.js +1 -1
  89. package/dist/knowledge/reward-confirm.js +2 -2
  90. package/dist/knowledge/reward-puzzle.js +1 -1
  91. package/dist/knowledge/reward-risk.js +9 -9
  92. package/dist/knowledge/reward-templates.js +2 -2
  93. package/dist/knowledge/safety-rules.d.ts +83 -1
  94. package/dist/knowledge/safety-rules.js +166 -2
  95. package/dist/knowledge/scenario-modes.d.ts +1 -1
  96. package/dist/knowledge/scenario-modes.js +13 -11
  97. package/dist/knowledge/service-confirm.d.ts +1 -1
  98. package/dist/knowledge/service-confirm.js +3 -3
  99. package/dist/knowledge/service-context.js +1 -1
  100. package/dist/knowledge/service-ledger.js +1 -1
  101. package/dist/knowledge/service-risk.d.ts +1 -1
  102. package/dist/knowledge/service-risk.js +3 -3
  103. package/dist/knowledge/service-templates.js +2 -2
  104. package/dist/knowledge/service-translation.d.ts +1 -1
  105. package/dist/knowledge/service-translation.js +7 -7
  106. package/dist/knowledge/template-registry.d.ts +48 -0
  107. package/dist/knowledge/template-registry.js +341 -0
  108. package/dist/knowledge/tool-constraints.js +6 -6
  109. package/dist/knowledge/tools-reference.js +11 -8
  110. package/dist/participation/merchant-interest.d.ts +32 -0
  111. package/dist/participation/merchant-interest.js +100 -0
  112. package/dist/participation/radar-core.d.ts +104 -0
  113. package/dist/participation/radar-core.js +269 -0
  114. package/dist/project/context-assembly.js +8 -0
  115. package/dist/project/deployment-bridge.js +6 -5
  116. package/dist/project/deployment-doc.js +5 -5
  117. package/dist/project/edit-planner.d.ts +123 -0
  118. package/dist/project/edit-planner.js +1342 -0
  119. package/dist/project/evaluation.d.ts +36 -0
  120. package/dist/project/evaluation.js +734 -68
  121. package/dist/project/game-theory.d.ts +43 -0
  122. package/dist/project/game-theory.js +177 -0
  123. package/dist/project/graph-builder.js +7 -1
  124. package/dist/project/handlers.d.ts +137 -2
  125. package/dist/project/handlers.js +423 -51
  126. package/dist/project/intent-analyzer.d.ts +71 -0
  127. package/dist/project/intent-analyzer.js +149 -0
  128. package/dist/project/machine-nodes.d.ts +2 -0
  129. package/dist/project/machine-nodes.js +36 -0
  130. package/dist/project/merchant-guide.d.ts +165 -0
  131. package/dist/project/merchant-guide.js +264 -0
  132. package/dist/project/mode-actions.d.ts +199 -0
  133. package/dist/project/mode-actions.js +309 -0
  134. package/dist/project/participation-radar.d.ts +18 -0
  135. package/dist/project/participation-radar.js +428 -0
  136. package/dist/project/pipeline-actions.d.ts +101 -0
  137. package/dist/project/pipeline-actions.js +109 -0
  138. package/dist/project/semantic-graph.d.ts +95 -0
  139. package/dist/project/semantic-graph.js +245 -0
  140. package/dist/project/stage-gate.js +4 -4
  141. package/dist/schema/call/allocation.d.ts +11 -11
  142. package/dist/schema/call/allocation.js +13 -3
  143. package/dist/schema/call/arbitration.d.ts +21 -21
  144. package/dist/schema/call/arbitration.js +30 -9
  145. package/dist/schema/call/base.d.ts +2 -2
  146. package/dist/schema/call/base.js +1 -1
  147. package/dist/schema/call/bridge.d.ts +127 -127
  148. package/dist/schema/call/bridge.js +12 -12
  149. package/dist/schema/call/contact.d.ts +3 -3
  150. package/dist/schema/call/contact.js +2 -2
  151. package/dist/schema/call/demand.d.ts +3 -3
  152. package/dist/schema/call/demand.js +2 -2
  153. package/dist/schema/call/guard.d.ts +11 -11
  154. package/dist/schema/call/guard.js +2 -2
  155. package/dist/schema/call/machine.d.ts +2072 -679
  156. package/dist/schema/call/machine.js +51 -5
  157. package/dist/schema/call/order.d.ts +7 -7
  158. package/dist/schema/call/order.js +3 -6
  159. package/dist/schema/call/payment.d.ts +3 -3
  160. package/dist/schema/call/permission.d.ts +3 -3
  161. package/dist/schema/call/permission.js +2 -2
  162. package/dist/schema/call/personal.d.ts +337 -3
  163. package/dist/schema/call/personal.js +10 -0
  164. package/dist/schema/call/progress.d.ts +177 -9
  165. package/dist/schema/call/progress.js +7 -3
  166. package/dist/schema/call/proof.d.ts +6 -6
  167. package/dist/schema/call/repository.d.ts +3 -3
  168. package/dist/schema/call/repository.js +2 -2
  169. package/dist/schema/call/reward.d.ts +57 -57
  170. package/dist/schema/call/reward.js +3 -3
  171. package/dist/schema/call/semantic.js +48 -2
  172. package/dist/schema/call/service.d.ts +285 -113
  173. package/dist/schema/call/service.js +92 -28
  174. package/dist/schema/call/treasury.d.ts +57 -57
  175. package/dist/schema/call/treasury.js +3 -3
  176. package/dist/schema/common/index.d.ts +2 -0
  177. package/dist/schema/common/index.js +46 -10
  178. package/dist/schema/local/index.js +5 -1
  179. package/dist/schema/messenger/index.js +4 -1
  180. package/dist/schema/operations.d.ts +1318 -317
  181. package/dist/schema/operations.js +76 -7
  182. package/dist/schema/project/index.d.ts +5662 -164
  183. package/dist/schema/project/index.js +1136 -5
  184. package/dist/schema/query/index.d.ts +580 -19
  185. package/dist/schema/query/index.js +88 -36
  186. package/dist/schema/schema-query/index.d.ts +59 -3
  187. package/dist/schema/schema-query/index.js +45 -6
  188. package/dist/schema/trust/index.d.ts +1012 -6
  189. package/dist/schema/trust/index.js +212 -11
  190. package/dist/schema/utils/node-parser.js +13 -0
  191. package/dist/schema/utils/object-type-utils.d.ts +12 -0
  192. package/dist/schema/utils/object-type-utils.js +35 -0
  193. package/dist/schema/utils/permission-machine-check.d.ts +49 -0
  194. package/dist/schema/utils/permission-machine-check.js +121 -0
  195. package/dist/schema/utils/skills-recommendation.d.ts +2 -0
  196. package/dist/schema/utils/skills-recommendation.js +77 -0
  197. package/dist/schema-query/index.d.ts +17 -1
  198. package/dist/schema-query/index.js +359 -3
  199. package/dist/schemas/account_operation.schema.json +1 -1
  200. package/dist/schemas/bridge_operation.schema.json +14 -7
  201. package/dist/schemas/guard2file.schema.json +2 -0
  202. package/dist/schemas/index.json +1 -1
  203. package/dist/schemas/machineNode2file.schema.json +2 -0
  204. package/dist/schemas/messenger_operation.schema.json +1 -1
  205. package/dist/schemas/onchain_events.output.json +1 -1
  206. package/dist/schemas/onchain_operations.output.json +2820 -0
  207. package/dist/schemas/onchain_operations.schema.json +255 -65
  208. package/dist/schemas/onchain_operations_allocation.schema.json +7 -6
  209. package/dist/schemas/onchain_operations_arbitration.schema.json +14 -10
  210. package/dist/schemas/onchain_operations_contact.schema.json +4 -3
  211. package/dist/schemas/onchain_operations_demand.schema.json +4 -3
  212. package/dist/schemas/onchain_operations_gen_passport.schema.json +4 -2
  213. package/dist/schemas/onchain_operations_gen_proof.schema.json +2 -0
  214. package/dist/schemas/onchain_operations_guard.schema.json +579 -1
  215. package/dist/schemas/onchain_operations_machine.schema.json +5 -4
  216. package/dist/schemas/onchain_operations_order.schema.json +7 -6
  217. package/dist/schemas/onchain_operations_payment.schema.json +2 -1
  218. package/dist/schemas/onchain_operations_permission.schema.json +3 -2
  219. package/dist/schemas/onchain_operations_personal.schema.json +37 -0
  220. package/dist/schemas/onchain_operations_progress.schema.json +91 -4
  221. package/dist/schemas/onchain_operations_proof.schema.json +2 -1
  222. package/dist/schemas/onchain_operations_repository.schema.json +4 -3
  223. package/dist/schemas/onchain_operations_reward.schema.json +7 -6
  224. package/dist/schemas/onchain_operations_service.schema.json +80 -19
  225. package/dist/schemas/onchain_operations_treasury.schema.json +5 -4
  226. package/dist/schemas/onchain_table_data.output.json +1 -1
  227. package/dist/schemas/onchain_table_data.schema.json +10 -9
  228. package/dist/schemas/project_operation.output.json +3318 -57
  229. package/dist/schemas/project_operation.schema.json +728 -4
  230. package/dist/schemas/query_toolkit.output.json +16 -16
  231. package/dist/schemas/query_toolkit.schema.json +40 -3
  232. package/dist/schemas/schema_query.output.json +65 -2
  233. package/dist/schemas/schema_query.schema.json +31 -5
  234. package/dist/schemas/trust_score.output.json +392 -1
  235. package/dist/schemas/trust_score.schema.json +275 -1
  236. package/dist/schemas/wowok_buildin_info.output.json +81 -8
  237. package/dist/schemas/wowok_buildin_info.schema.json +46 -2
  238. package/dist/tools/handlers/onchain.js +636 -6
  239. package/dist/tools/handlers/project.js +71 -2
  240. package/dist/tools/handlers/query.js +117 -2
  241. package/dist/tools/handlers/schema-query.js +65 -1
  242. package/dist/tools/handlers/trust.js +192 -6
  243. package/dist/tools/index.d.ts +8 -0
  244. package/dist/tools/index.js +229 -15
  245. package/dist/tools/wrap.js +194 -15
  246. package/package.json +2 -2
@@ -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;
@@ -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 { LocalProject } from "@wowok/wowok";
2
2
  import { generateDeploymentDoc, validateDeploymentDoc } from "./deployment-doc.js";
3
+ import { isObjectOfType, shortTypeName } from "../schema/utils/object-type-utils.js";
3
4
  export async function generateDeploymentDocFromProject(projectId, network, detailLevel) {
4
5
  const project = await LocalProject.Instance().getProject(projectId);
5
6
  if (!project) {
@@ -26,7 +27,7 @@ export async function generateDeploymentDocFromProject(projectId, network, detai
26
27
  (o.objectAddress.startsWith("draft:") ? "draft" : "deployed");
27
28
  const config = meta.config ?? undefined;
28
29
  const publishRequired = meta.publish_required ??
29
- (objectType === "service" || objectType === "machine");
30
+ (isObjectOfType(objectType, "service") || isObjectOfType(objectType, "machine"));
30
31
  return {
31
32
  entry_id: `${objectType}:${o.objectName || o.objectAddress || o.id}`,
32
33
  object_type: normalizeObjectType(objectType),
@@ -35,7 +36,7 @@ export async function generateDeploymentDocFromProject(projectId, network, detai
35
36
  ? o.objectAddress : undefined,
36
37
  publish_required: publishRequired,
37
38
  description: meta.description ??
38
- (status === "draft" ? "[蓝图] 待上链" : "[已上链]"),
39
+ (status === "draft" ? "[blueprint] pending on-chain" : "[on-chain]"),
39
40
  config,
40
41
  status,
41
42
  };
@@ -85,10 +86,10 @@ export async function generateDeploymentDocFromProject(projectId, network, detai
85
86
  return { markdown, validation };
86
87
  }
87
88
  function normalizeObjectType(raw) {
88
- const lower = raw.toLowerCase();
89
- if (lower === "arbitration")
89
+ const short = shortTypeName(raw).toLowerCase();
90
+ if (short === "arbitration")
90
91
  return "arb";
91
- return lower;
92
+ return short;
92
93
  }
93
94
  function buildTopoSteps(objects, edges, network) {
94
95
  const typeOrder = {
@@ -1,7 +1,7 @@
1
1
  import { join } from "path";
2
2
  const STANDARD_TOPO_ORDER = [
3
- "permission", "treasury", "allocation", "guard", "machine",
4
- "service", "order", "progress", "arb", "reward",
3
+ "permission", "treasury", "allocation", "service", "guard", "machine",
4
+ "order", "progress", "arb", "reward",
5
5
  "proof", "repository", "demand", "contact",
6
6
  "personal", "payment",
7
7
  ];
@@ -230,7 +230,7 @@ function renderNetworkSection(sectionNum, network, input) {
230
230
  data: {
231
231
  object: objectData,
232
232
  description: isDraft
233
- ? `${stepDescription(step)} [蓝图:基于 ${input.industry} 行业模板生成]`
233
+ ? `${stepDescription(step)} [blueprint: generated from ${input.industry} industry template]`
234
234
  : stepDescription(step),
235
235
  status: isDraft ? "draft" : "deployed",
236
236
  },
@@ -1028,8 +1028,8 @@ function renderProjectReadme(input, relations) {
1028
1028
  lines.push("| stage 4 (steps) | stage 5 (substeps) | Steps must be defined before substep tracing |");
1029
1029
  lines.push("");
1030
1030
  lines.push("## §8 Gas / Faucet Rules", "");
1031
- lines.push("- testnet: gas is free (faucet) — encourage experimentation,回退无成本");
1032
- lines.push("- mainnet: gas is real — 回退后重跑有真实成本, WARN before rollback");
1031
+ lines.push("- testnet: gas is free (faucet) — encourage experimentation, rollback is costless");
1032
+ lines.push("- mainnet: gas is real — re-running after rollback incurs real cost, WARN before rollback");
1033
1033
  lines.push("- Reversibility is determined by object lifecycle (§3.2), NOT by network");
1034
1034
  lines.push("");
1035
1035
  lines.push("## §9 Stage Subdirectory Index", "");
@@ -0,0 +1,123 @@
1
+ import type { z } from "zod";
2
+ import { type MachineNodeForRender, type MachineEdgeForRender } from "../knowledge/machine-render.js";
3
+ import { type GuardNodeForRender } from "../knowledge/guard-render.js";
4
+ import type { ProjectOperationInputSchema } from "../schema/project/index.js";
5
+ type ProjectInput = z.infer<typeof ProjectOperationInputSchema>;
6
+ export declare function handlePlanObjectEdit(v: ProjectInput): Promise<{
7
+ action: "plan_object_edit";
8
+ plan_id: string;
9
+ object_kind: "guard" | "machine";
10
+ object_address: string;
11
+ object_name: string | null;
12
+ expected_hash: string;
13
+ diff: {
14
+ added: string[];
15
+ removed: string[];
16
+ modified: string[];
17
+ summary: string;
18
+ };
19
+ warnings: {
20
+ id: string;
21
+ description: string;
22
+ impact: string;
23
+ }[];
24
+ blocking_errors: {
25
+ id: string;
26
+ description: string;
27
+ impact: string;
28
+ }[];
29
+ can_apply: boolean;
30
+ prepared_call: unknown;
31
+ expires_at: string;
32
+ summary: string;
33
+ }>;
34
+ export declare function handleApplyObjectEdit(v: ProjectInput): Promise<{
35
+ action: "apply_object_edit";
36
+ plan_id: string;
37
+ applied: boolean;
38
+ hash_match: boolean;
39
+ prepared_call: null;
40
+ error: string;
41
+ next_step: string;
42
+ } | {
43
+ action: "apply_object_edit";
44
+ plan_id: string;
45
+ applied: boolean;
46
+ hash_match: boolean;
47
+ prepared_call: unknown;
48
+ error: null;
49
+ next_step: string;
50
+ }>;
51
+ export declare function handlePatchMachineNodes(v: ProjectInput): Promise<{
52
+ action: "patch_machine_nodes";
53
+ machine_address: string;
54
+ machine_name: string | null;
55
+ operations_applied: number;
56
+ operations_failed: {
57
+ operation: string;
58
+ error: string;
59
+ }[];
60
+ patched_nodes: MachineNodeForRender[];
61
+ patched_edges: MachineEdgeForRender[];
62
+ diff: {
63
+ added: string[];
64
+ removed: string[];
65
+ modified: string[];
66
+ summary: string;
67
+ };
68
+ warnings: {
69
+ id: string;
70
+ description: string;
71
+ impact: string;
72
+ }[];
73
+ blocking_errors: {
74
+ id: string;
75
+ description: string;
76
+ impact: string;
77
+ }[];
78
+ can_apply: boolean;
79
+ prepared_call: unknown;
80
+ summary: string;
81
+ }>;
82
+ export declare function handlePatchGuardTree(v: ProjectInput): Promise<{
83
+ action: "patch_guard_tree";
84
+ guard_address: string;
85
+ guard_name: string | null;
86
+ operations_applied: number;
87
+ operations_failed: {
88
+ operation: string;
89
+ error: string;
90
+ }[];
91
+ patched_root: GuardNodeForRender;
92
+ patched_table: {
93
+ identifier: number;
94
+ name?: string;
95
+ value_type: string | number;
96
+ b_submission: boolean;
97
+ value?: unknown;
98
+ }[];
99
+ patched_rely: {
100
+ guards: string[];
101
+ logic_or?: boolean;
102
+ } | null;
103
+ diff: {
104
+ added: string[];
105
+ removed: string[];
106
+ modified: string[];
107
+ summary: string;
108
+ };
109
+ warnings: {
110
+ id: string;
111
+ description: string;
112
+ impact: string;
113
+ }[];
114
+ blocking_errors: {
115
+ id: string;
116
+ description: string;
117
+ impact: string;
118
+ }[];
119
+ can_apply: boolean;
120
+ prepared_call: unknown;
121
+ summary: string;
122
+ }>;
123
+ export {};