@wowok/agent-mcp 2.7.1 → 2.7.2

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 (375) hide show
  1. package/dist/config/index.js +1 -1
  2. package/dist/config/runtime.js +1 -238
  3. package/dist/customer/customer-advice.js +1 -130
  4. package/dist/customer/index.js +1 -11
  5. package/dist/customer/industry-risks.js +1 -438
  6. package/dist/customer/info-puzzle.js +1 -681
  7. package/dist/customer/order-monitor.js +1 -328
  8. package/dist/customer/order-strategy.js +1 -373
  9. package/dist/customer/post-purchase.js +1 -351
  10. package/dist/customer/preorder-compare.js +1 -34
  11. package/dist/customer/reminder-system.js +1 -316
  12. package/dist/customer/risk-assessment.js +1 -397
  13. package/dist/customer/types.js +1 -13
  14. package/dist/customer/user-preferences.js +1 -460
  15. package/dist/evaluation/arbitration-game.d.ts +9 -2
  16. package/dist/evaluation/arbitration-game.js +1 -48
  17. package/dist/evaluation/builtins/demand-match.js +1 -153
  18. package/dist/evaluation/builtins/index.js +1 -10
  19. package/dist/evaluation/builtins/service-risk.js +1 -55
  20. package/dist/evaluation/capability.js +1 -13
  21. package/dist/evaluation/composer.js +1 -40
  22. package/dist/evaluation/engine.js +1 -175
  23. package/dist/evaluation/extract.js +1 -115
  24. package/dist/evaluation/game-strategy.d.ts +27 -0
  25. package/dist/evaluation/game-strategy.js +1 -0
  26. package/dist/evaluation/gap.js +1 -100
  27. package/dist/evaluation/index.d.ts +1 -0
  28. package/dist/evaluation/index.js +1 -11
  29. package/dist/evaluation/node-game.d.ts +31 -3
  30. package/dist/evaluation/node-game.js +1 -57
  31. package/dist/evaluation/region.js +1 -36
  32. package/dist/evaluation/types.d.ts +1 -0
  33. package/dist/evaluation/types.js +1 -1
  34. package/dist/evaluation/user-injection.js +1 -27
  35. package/dist/experience/experience-reuse.js +1 -103
  36. package/dist/experience/index.js +1 -5
  37. package/dist/experience/intent-distill.js +1 -83
  38. package/dist/experience/realtime-feedback.js +1 -94
  39. package/dist/experience/types.js +1 -1
  40. package/dist/experience/user-profile.js +1 -171
  41. package/dist/extensions/business-modules.js +1 -287
  42. package/dist/extensions/capability-manifest.js +1 -781
  43. package/dist/extensions/constraint-registry.js +1 -198
  44. package/dist/extensions/index.js +1 -6
  45. package/dist/extensions/metric-registry.js +1 -257
  46. package/dist/extensions/mode-evaluator.js +1 -170
  47. package/dist/extensions/modes.js +1 -499
  48. package/dist/extensions/registry.js +1 -717
  49. package/dist/extensions/types.js +1 -1
  50. package/dist/harness/auto-escalation.js +1 -68
  51. package/dist/harness/checkpoint.js +1 -129
  52. package/dist/harness/index.js +1 -78
  53. package/dist/harness/plan.js +1 -315
  54. package/dist/harness/recover.js +1 -139
  55. package/dist/harness/types.js +1 -1
  56. package/dist/harness/verify.js +1 -237
  57. package/dist/index.js +1 -273
  58. package/dist/intent/enrich.js +1 -67
  59. package/dist/intent/index.js +1 -60
  60. package/dist/intent/matcher.js +1 -81
  61. package/dist/intent/store.js +1 -55
  62. package/dist/intent/types.js +1 -10
  63. package/dist/knowledge/acquisition-flywheel.js +1 -192
  64. package/dist/knowledge/allocation-confirm.js +1 -534
  65. package/dist/knowledge/allocation-context.js +1 -249
  66. package/dist/knowledge/allocation-ledger.js +1 -463
  67. package/dist/knowledge/allocation-puzzle.js +1 -298
  68. package/dist/knowledge/allocation-risk.js +1 -568
  69. package/dist/knowledge/allocation-templates.js +1 -970
  70. package/dist/knowledge/allocation-translation.js +1 -585
  71. package/dist/knowledge/arb-risk.js +1 -210
  72. package/dist/knowledge/arbitration-confirm.js +1 -559
  73. package/dist/knowledge/arbitration-context.js +1 -505
  74. package/dist/knowledge/arbitration-ledger.js +1 -521
  75. package/dist/knowledge/arbitration-puzzle.js +1 -304
  76. package/dist/knowledge/arbitration-risk.js +1 -423
  77. package/dist/knowledge/arbitration-templates.js +1 -276
  78. package/dist/knowledge/arbitration-translation.js +1 -487
  79. package/dist/knowledge/arbitration-trust.js +1 -117
  80. package/dist/knowledge/audit-rules.js +1 -141
  81. package/dist/knowledge/bridge-risk.js +1 -263
  82. package/dist/knowledge/contact-risk.js +1 -200
  83. package/dist/knowledge/contact-templates.js +1 -60
  84. package/dist/knowledge/demand-confirm.js +1 -206
  85. package/dist/knowledge/demand-matching.js +1 -132
  86. package/dist/knowledge/demand-risk.js +1 -240
  87. package/dist/knowledge/demand-translation.js +1 -354
  88. package/dist/knowledge/deployment-scanner.js +1 -823
  89. package/dist/knowledge/dynamic-pricing.js +1 -87
  90. package/dist/knowledge/examples-scanner-cli.js +1 -26
  91. package/dist/knowledge/examples-scanner.js +1 -843
  92. package/dist/knowledge/flywheel-loop.js +1 -404
  93. package/dist/knowledge/fund-layer.js +1 -973
  94. package/dist/knowledge/glossary.js +1 -211
  95. package/dist/knowledge/guard-confirm.js +1 -406
  96. package/dist/knowledge/guard-context.js +1 -287
  97. package/dist/knowledge/guard-design-patterns.js +1 -360
  98. package/dist/knowledge/guard-ledger.js +1 -260
  99. package/dist/knowledge/guard-lint.js +1 -670
  100. package/dist/knowledge/guard-migration.js +1 -228
  101. package/dist/knowledge/guard-puzzle.js +1 -805
  102. package/dist/knowledge/guard-render.js +1 -700
  103. package/dist/knowledge/guard-risk.js +1 -1879
  104. package/dist/knowledge/guard-submission-prompt.js +1 -171
  105. package/dist/knowledge/guard-templates.js +1 -1105
  106. package/dist/knowledge/guard-translation.js +1 -1119
  107. package/dist/knowledge/index.js +1 -436
  108. package/dist/knowledge/industry-evolution.js +1 -323
  109. package/dist/knowledge/industry-generalizer.js +1 -381
  110. package/dist/knowledge/industry-registry.js +1 -174
  111. package/dist/knowledge/intent-metrics.d.ts +4 -3
  112. package/dist/knowledge/intent-metrics.js +1 -566
  113. package/dist/knowledge/machine-confirm.js +1 -559
  114. package/dist/knowledge/machine-context.js +1 -833
  115. package/dist/knowledge/machine-ledger.js +1 -338
  116. package/dist/knowledge/machine-puzzle.js +1 -494
  117. package/dist/knowledge/machine-render.js +1 -565
  118. package/dist/knowledge/machine-risk.js +1 -669
  119. package/dist/knowledge/machine-templates.js +1 -1597
  120. package/dist/knowledge/machine-topology.js +1 -234
  121. package/dist/knowledge/machine-translation.js +1 -513
  122. package/dist/knowledge/mcp-schema-audit-cli.js +1 -45
  123. package/dist/knowledge/mcp-schema-audit.js +1 -777
  124. package/dist/knowledge/onchain-constants.js +1 -35
  125. package/dist/knowledge/order-confirm.js +1 -573
  126. package/dist/knowledge/order-context.js +1 -390
  127. package/dist/knowledge/order-ledger.js +1 -341
  128. package/dist/knowledge/order-puzzle.js +1 -255
  129. package/dist/knowledge/order-risk.js +1 -653
  130. package/dist/knowledge/order-templates.js +1 -368
  131. package/dist/knowledge/order-translation.js +1 -550
  132. package/dist/knowledge/overrides-loader.js +1 -65
  133. package/dist/knowledge/passport-confirm.js +1 -531
  134. package/dist/knowledge/passport-context.js +1 -306
  135. package/dist/knowledge/passport-ledger.js +1 -282
  136. package/dist/knowledge/passport-puzzle.js +1 -333
  137. package/dist/knowledge/passport-risk.js +1 -450
  138. package/dist/knowledge/passport-templates.js +1 -568
  139. package/dist/knowledge/passport-translation.js +1 -516
  140. package/dist/knowledge/payment-risk.js +1 -249
  141. package/dist/knowledge/permission-confirm.js +1 -426
  142. package/dist/knowledge/permission-context.js +1 -224
  143. package/dist/knowledge/permission-ledger.js +1 -403
  144. package/dist/knowledge/permission-puzzle.js +1 -173
  145. package/dist/knowledge/permission-risk.js +1 -411
  146. package/dist/knowledge/permission-templates.js +1 -234
  147. package/dist/knowledge/permission-translation.js +1 -350
  148. package/dist/knowledge/personal-risk.js +1 -212
  149. package/dist/knowledge/process-model.js +1 -160
  150. package/dist/knowledge/progress-confirm.js +1 -456
  151. package/dist/knowledge/progress-context.js +1 -452
  152. package/dist/knowledge/progress-ledger.js +1 -330
  153. package/dist/knowledge/progress-puzzle.js +1 -219
  154. package/dist/knowledge/progress-risk.js +1 -461
  155. package/dist/knowledge/progress-templates.js +1 -228
  156. package/dist/knowledge/progress-translation.js +1 -405
  157. package/dist/knowledge/proof-confirm.js +1 -187
  158. package/dist/knowledge/proof-risk.js +1 -207
  159. package/dist/knowledge/proof-translation.js +1 -283
  160. package/dist/knowledge/registrar-risk.js +1 -217
  161. package/dist/knowledge/repository-confirm.js +1 -286
  162. package/dist/knowledge/repository-risk.js +1 -373
  163. package/dist/knowledge/repository-translation.js +1 -445
  164. package/dist/knowledge/reputation-rules.js +1 -99
  165. package/dist/knowledge/resource-risk.js +1 -157
  166. package/dist/knowledge/reward-confirm.js +1 -526
  167. package/dist/knowledge/reward-context.js +1 -504
  168. package/dist/knowledge/reward-ledger.js +1 -502
  169. package/dist/knowledge/reward-puzzle.js +1 -300
  170. package/dist/knowledge/reward-risk.js +1 -627
  171. package/dist/knowledge/reward-templates.js +1 -197
  172. package/dist/knowledge/reward-translation.js +1 -501
  173. package/dist/knowledge/safety-rules.js +1 -404
  174. package/dist/knowledge/scenario-modes.js +1 -321
  175. package/dist/knowledge/service-confirm.js +1 -807
  176. package/dist/knowledge/service-context.js +1 -403
  177. package/dist/knowledge/service-ledger.js +1 -609
  178. package/dist/knowledge/service-puzzle.js +1 -236
  179. package/dist/knowledge/service-risk.js +1 -651
  180. package/dist/knowledge/service-templates.js +1 -456
  181. package/dist/knowledge/service-translation.js +1 -622
  182. package/dist/knowledge/template-registry.js +1 -353
  183. package/dist/knowledge/tool-constraints.js +1 -195
  184. package/dist/knowledge/tools-reference.js +1 -178
  185. package/dist/knowledge/treasury-confirm.js +1 -512
  186. package/dist/knowledge/treasury-context.js +1 -363
  187. package/dist/knowledge/treasury-ledger.js +1 -300
  188. package/dist/knowledge/treasury-puzzle.js +1 -216
  189. package/dist/knowledge/treasury-risk.js +1 -440
  190. package/dist/knowledge/treasury-templates.js +1 -358
  191. package/dist/knowledge/treasury-translation.js +1 -498
  192. package/dist/knowledge/trust-metrics.js +1 -198
  193. package/dist/knowledge/util-risk.js +1 -135
  194. package/dist/loop-engineering/aggregate.js +1 -132
  195. package/dist/loop-engineering/context-collect.js +1 -83
  196. package/dist/loop-engineering/diagnose.js +1 -273
  197. package/dist/loop-engineering/improve.js +1 -405
  198. package/dist/loop-engineering/index.js +1 -4
  199. package/dist/loop-engineering/pipeline.js +1 -56
  200. package/dist/mode-market/index.js +1 -3
  201. package/dist/mode-market/registry.js +1 -124
  202. package/dist/mode-market/review.js +1 -214
  203. package/dist/mode-market/submission.js +1 -85
  204. package/dist/participation/collaborator-interest.d.ts +23 -0
  205. package/dist/participation/collaborator-interest.js +1 -0
  206. package/dist/participation/customer-interest.d.ts +25 -0
  207. package/dist/participation/customer-interest.js +1 -0
  208. package/dist/participation/merchant-interest.js +1 -100
  209. package/dist/participation/radar-core.d.ts +13 -3
  210. package/dist/participation/radar-core.js +1 -269
  211. package/dist/participation/supplier-interest.d.ts +25 -0
  212. package/dist/participation/supplier-interest.js +1 -0
  213. package/dist/persona/analyzer.js +1 -66
  214. package/dist/persona/bridge.js +1 -86
  215. package/dist/persona/defaults.js +1 -195
  216. package/dist/persona/experience-bridge.js +1 -23
  217. package/dist/persona/index.js +1 -71
  218. package/dist/persona/model.js +1 -111
  219. package/dist/persona/store.js +1 -62
  220. package/dist/persona/types.d.ts +3 -1
  221. package/dist/persona/types.js +1 -5
  222. package/dist/project/business-puzzle.js +1 -383
  223. package/dist/project/context-assembly.js +1 -254
  224. package/dist/project/deployment-bridge.js +1 -120
  225. package/dist/project/deployment-doc.js +1 -1126
  226. package/dist/project/edit-planner.js +1 -1342
  227. package/dist/project/evaluation.js +1 -2011
  228. package/dist/project/game-theory.js +1 -177
  229. package/dist/project/graph-builder.js +1 -656
  230. package/dist/project/graph.js +1 -340
  231. package/dist/project/handlers.js +1 -1784
  232. package/dist/project/index.d.ts +1 -0
  233. package/dist/project/index.js +1 -301
  234. package/dist/project/intent-analyzer.js +1 -149
  235. package/dist/project/machine-nodes.js +1 -36
  236. package/dist/project/merchant-guide.js +1 -264
  237. package/dist/project/migration.js +1 -125
  238. package/dist/project/mode-actions.js +1 -309
  239. package/dist/project/namespace.js +1 -206
  240. package/dist/project/participation-radar.js +1 -428
  241. package/dist/project/pipeline-actions.js +1 -109
  242. package/dist/project/project-store.js +1 -422
  243. package/dist/project/query.js +1 -153
  244. package/dist/project/reverse-mapping.d.ts +34 -0
  245. package/dist/project/reverse-mapping.js +1 -0
  246. package/dist/project/risk-aggregator.js +1 -295
  247. package/dist/project/rollback-policy.js +1 -290
  248. package/dist/project/semantic-assembler.js +1 -345
  249. package/dist/project/semantic-graph.js +1 -292
  250. package/dist/project/stage-gate.js +1 -369
  251. package/dist/project/substep-trace.js +1 -332
  252. package/dist/project/task-tracker.js +1 -78
  253. package/dist/role/derivation.d.ts +18 -0
  254. package/dist/role/derivation.js +1 -0
  255. package/dist/role/index.d.ts +5 -0
  256. package/dist/role/index.js +1 -0
  257. package/dist/role/model.d.ts +8 -0
  258. package/dist/role/model.js +1 -0
  259. package/dist/role/resolution.d.ts +11 -0
  260. package/dist/role/resolution.js +1 -0
  261. package/dist/role/types.d.ts +11 -0
  262. package/dist/role/types.js +1 -0
  263. package/dist/rules.js +1 -52
  264. package/dist/safety/confirm-gate.js +1 -88
  265. package/dist/safety/index.js +1 -3
  266. package/dist/safety/preview.js +1 -52
  267. package/dist/schema/call/allocation.js +1 -34
  268. package/dist/schema/call/arbitration.js +1 -113
  269. package/dist/schema/call/base.d.ts +15 -15
  270. package/dist/schema/call/base.js +1 -370
  271. package/dist/schema/call/bridge-handler.js +1 -265
  272. package/dist/schema/call/bridge.d.ts +7 -7
  273. package/dist/schema/call/bridge.js +1 -458
  274. package/dist/schema/call/contact.js +1 -37
  275. package/dist/schema/call/demand.js +1 -47
  276. package/dist/schema/call/guard.js +1 -161
  277. package/dist/schema/call/handler.js +1 -322
  278. package/dist/schema/call/index.js +1 -20
  279. package/dist/schema/call/machine.js +1 -193
  280. package/dist/schema/call/order.js +1 -35
  281. package/dist/schema/call/payment.js +1 -37
  282. package/dist/schema/call/permission-handler.js +1 -54
  283. package/dist/schema/call/permission.js +1 -105
  284. package/dist/schema/call/personal.js +1 -78
  285. package/dist/schema/call/progress.js +1 -47
  286. package/dist/schema/call/proof.js +1 -33
  287. package/dist/schema/call/repository.js +1 -77
  288. package/dist/schema/call/reward.js +1 -30
  289. package/dist/schema/call/semantic.js +1 -1679
  290. package/dist/schema/call/service.js +1 -184
  291. package/dist/schema/call/treasury.js +1 -71
  292. package/dist/schema/common/index.js +1 -407
  293. package/dist/schema/config/index.js +1 -68
  294. package/dist/schema/evaluation/index.d.ts +213 -16
  295. package/dist/schema/evaluation/index.js +1 -356
  296. package/dist/schema/index.js +1 -17
  297. package/dist/schema/intent-radar/index.d.ts +13 -13
  298. package/dist/schema/intent-radar/index.js +1 -89
  299. package/dist/schema/local/index.d.ts +21 -21
  300. package/dist/schema/local/index.js +1 -927
  301. package/dist/schema/local/wip.js +1 -187
  302. package/dist/schema/messenger/index.d.ts +7 -7
  303. package/dist/schema/messenger/index.js +1 -475
  304. package/dist/schema/operations.d.ts +7 -7
  305. package/dist/schema/operations.js +1 -520
  306. package/dist/schema/persona/index.d.ts +54 -54
  307. package/dist/schema/persona/index.js +1 -148
  308. package/dist/schema/project/index.d.ts +94 -48
  309. package/dist/schema/project/index.js +1 -2057
  310. package/dist/schema/query/index.d.ts +423 -7
  311. package/dist/schema/query/index.js +1 -1646
  312. package/dist/schema/schema-query/index.js +1 -104
  313. package/dist/schema/schema-version.js +1 -76
  314. package/dist/schema/sync-layer4.js +1 -286
  315. package/dist/schema/task-status.js +1 -36
  316. package/dist/schema/trust/index.js +1 -314
  317. package/dist/schema/utils/guard-parser.js +1 -419
  318. package/dist/schema/utils/guard-query-utils.js +1 -46
  319. package/dist/schema/utils/node-parser.js +1 -369
  320. package/dist/schema/utils/object-type-utils.js +1 -35
  321. package/dist/schema/utils/permission-index-utils.js +1 -7
  322. package/dist/schema/utils/permission-machine-check.js +1 -121
  323. package/dist/schema/utils/skills-recommendation.js +1 -77
  324. package/dist/schema-query/index.js +1 -810
  325. package/dist/schemas/account_operation.output.json +5 -2
  326. package/dist/schemas/bridge_operation.output.json +5 -2
  327. package/dist/schemas/evaluation_operation.output.json +112 -7
  328. package/dist/schemas/evaluation_operation.schema.json +93 -6
  329. package/dist/schemas/index.json +1 -1
  330. package/dist/schemas/intent_radar.output.json +4 -1
  331. package/dist/schemas/intent_radar.schema.json +4 -1
  332. package/dist/schemas/local_info_operation.output.json +5 -2
  333. package/dist/schemas/local_mark_operation.output.json +5 -2
  334. package/dist/schemas/messenger_operation.output.json +5 -2
  335. package/dist/schemas/onchain_events.output.json +5 -2
  336. package/dist/schemas/onchain_operations.output.json +5 -2
  337. package/dist/schemas/onchain_operations.schema.json +4 -4
  338. package/dist/schemas/onchain_operations_allocation.schema.json +1 -1
  339. package/dist/schemas/onchain_operations_machine.schema.json +2 -2
  340. package/dist/schemas/onchain_operations_service.schema.json +1 -1
  341. package/dist/schemas/onchain_table_data.output.json +6 -3
  342. package/dist/schemas/persona_operation.output.json +4 -1
  343. package/dist/schemas/persona_operation.schema.json +4 -1
  344. package/dist/schemas/project_operation.output.json +28 -8
  345. package/dist/schemas/query_toolkit.output.json +8 -5
  346. package/dist/schemas/wowok_buildin_info.output.json +132 -0
  347. package/dist/schemas/wowok_buildin_info.schema.json +14 -0
  348. package/dist/telemetry/index.js +1 -112
  349. package/dist/telemetry/redact.js +1 -23
  350. package/dist/telemetry/storage.js +1 -80
  351. package/dist/tools/handlers/bridge.js +1 -1
  352. package/dist/tools/handlers/config.js +1 -74
  353. package/dist/tools/handlers/evaluation.js +1 -123
  354. package/dist/tools/handlers/file-export.js +1 -90
  355. package/dist/tools/handlers/intent-radar.js +1 -76
  356. package/dist/tools/handlers/local.js +1 -53
  357. package/dist/tools/handlers/messenger.js +1 -188
  358. package/dist/tools/handlers/onchain.js +1 -1180
  359. package/dist/tools/handlers/persona.js +1 -89
  360. package/dist/tools/handlers/project.js +1 -211
  361. package/dist/tools/handlers/query.js +1 -434
  362. package/dist/tools/handlers/schema-query.js +1 -176
  363. package/dist/tools/handlers/task-status.js +1 -26
  364. package/dist/tools/handlers/trust.js +1 -380
  365. package/dist/tools/handlers/wip.js +1 -90
  366. package/dist/tools/index.js +1 -1382
  367. package/dist/tools/retry.js +1 -85
  368. package/dist/tools/rules-hook.js +1 -23
  369. package/dist/tools/shared.js +1 -130
  370. package/dist/tools/types.js +1 -1
  371. package/dist/tools/upgrade-check.d.ts +19 -0
  372. package/dist/tools/upgrade-check.js +1 -0
  373. package/dist/tools/wip-deploy-assist.js +1 -306
  374. package/dist/tools/wrap.js +1 -500
  375. package/package.json +4 -2
@@ -1,269 +1 @@
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
+ import{deriveCommercialRole}from'../role/derivation.js';const DEFAULT_ANNOTATIONS={'completed':['complete','completed','done','finish','finished','delivered','accepted'],'refunded':['refund','refunded','cancelled','canceled','lost','closed']};export function analyzeOrderParticipation(a){const b={'completed':a['node_annotations']?.['completed']??DEFAULT_ANNOTATIONS['completed'],'refunded':a['node_annotations']?.['refunded']??DEFAULT_ANNOTATIONS['refunded']},c=a['current_node']??'',d=!!a['order_holder']&&a['order_holder']===a['account'],e=new Set();if(a['permission']?.['entityPermissions'])for(const [t,u]of a['permission']['entityPermissions']){if(t===a['account']){for(const v of u)e['add'](v);}}const f=[];if(a['named_accounts'])for(const [w,x]of Object['entries'](a['named_accounts'])){if(nameResolvesTo(x,a['account']))f['push'](w);}const g=deriveCommercialRole({'account':a['account'],'order_holder':a['order_holder'],'held_permission_indexes':Array['from'](e),'named_operator_names':f,'service_builder':a['service_builder'],'demand_presenters':a['demand_presenters'],'has_active_order':!![]}),h=g['role'],i=g['collaborator_kind'],j=[],k=[],l=!a['machine_nodes'];let m;if(a['machine_nodes'])for(const y of a['machine_nodes']){for(const z of y['pairs']??[]){if(z['prev_node']!==c)continue;m=z['threshold'];for(const A of z['forwards']??[]){const B=resolveForward(A,y['name'],a,d,e,b);if(B['execution_path']==='not_available'){const C=A['permissionIndex']!=null?'permission\x20index\x20'+A['permissionIndex']:A['namedOperator']===''?'OrderHolder\x20(customer)':'named\x20operator\x20\x27'+A['namedOperator']+'\x27',D=k['find'](E=>E['role']===C);if(D)D['forwards']['push'](B['name']);else k['push']({'role':C,'forwards':[B['name']]});}else j['push'](B);}}}const n=[];d&&n['push']({'label':'OrderHolder\x20(customer)','can_act_now':j['some'](E=>E['execution_path']==='order_holder')});for(const E of[...e]['sort']((F,G)=>F-G)){n['push']({'label':'permission\x20index\x20'+E,'can_act_now':j['some'](F=>F['permission_index']===E)});}if(a['named_accounts'])for(const [F,G]of Object['entries'](a['named_accounts'])){nameResolvesTo(G,a['account'])&&n['push']({'label':'named\x20operator\x20\x27'+F+'\x27','can_act_now':j['some'](H=>H['named_operator']===F)});}let o;j['length']>0x1&&(o={'message':j['length']+'\x20operations\x20are\x20available\x20to\x20you\x20at\x20node\x20\x27'+(c||'(entry)')+'\x27.\x20'+'Each\x20leads\x20to\x20a\x20different\x20outcome\x20—\x20review\x20the\x20consequences\x20and\x20choose;\x20no\x20one\x20else\x20can\x20make\x20this\x20decision\x20for\x20you.','options':j['map'](H=>({'forward':H['name'],'to_node':H['to_node'],'consequence':H['consequence']}))});const p=[];for(const H of a['claimable_rewards']??[]){if(H['already_claimed'])continue;p['push']({'kind':'reward','label':H['description']??'Reward\x20'+H['address'],'how':'onchain_operations\x20reward\x20op=\x27claim\x27\x20(object=\x27'+H['address']+'\x27)'});}a['pending_compensation']&&p['push']({'kind':'compensation','label':a['pending_compensation']['note']??'Arbitration\x20indemnity\x20awarded\x20to\x20you','how':'onchain_operations\x20service\x20op=\x27compensation_claim\x27\x20(arbitration=\x27'+a['pending_compensation']['arbitration']+'\x27)\x20—\x20paid\x20directly\x20from\x20the\x20Service\x20compensation_fund'});a['discount_available']&&p['push']({'kind':'discount','label':a['discount_available'],'how':'Mention\x20the\x20discount\x20when\x20placing\x20the\x20next\x20order\x20(reward\x20discount\x20config\x20applies\x20at\x20purchase)'});a['rating_pending']&&p['push']({'kind':'rating','label':'Rate\x20this\x20transaction\x20(like/dislike)\x20—\x20builds\x20on-chain\x20reputation\x20for\x20both\x20sides','how':'onchain_operations\x20operation_type=\x27personal\x27,\x20data.mark={op:\x27like\x27|\x27dislike\x27,\x20address:\x27<merchant\x20address>\x27}\x20—\x20votes\x20through\x20registrar::like/dislike\x20into\x20the\x20PUBLIC\x20aggregate\x20count'});const q=buildInterestHints(a,h,j,k,c),s=buildSummary(a,h,n,j,k,p,l,c);return{'account':a['account'],'progress':a['progress_address'],'order':a['order_address'],'current_node':c,'perspective':h,'collaborator_kind':i,'roles':n,'operable':j,'branch_choice':o,'waiting_on':k,'pending_claims':p,'interest_hints':q,'workflow_unknown':l,'threshold':m,'summary':s};}export function aggregateRadar(a,b){const c=a['filter'](g=>g['operable']['length']>0x0||g['pending_claims']['length']>0x0)['sort']((g,h)=>(g['perspective']==='customer'?0x0:0x1)-(h['perspective']==='customer'?0x0:0x1)),d=a['filter'](g=>g['operable']['length']===0x0&&g['pending_claims']['length']===0x0),e=a['flatMap'](g=>g['pending_claims']['map'](h=>({...h,'progress':g['progress']}))),f=a['length']===0x0?'No\x20in-flight\x20orders\x20found\x20for\x20this\x20account.':a['length']+'\x20in-flight\x20order(s):\x20'+c['length']+'\x20need\x20your\x20action\x20or\x20have\x20claims,\x20'+d['length']+'\x20are\x20waiting\x20on\x20other\x20roles.\x20'+(e['length']>0x0?e['length']+'\x20unclaimed\x20benefit(s)\x20detected.\x20':'')+(c['length']>0x0?'Top\x20priority:\x20'+c[0x0]['summary']:'Nothing\x20requires\x20your\x20action\x20right\x20now.');return{'account':a[0x0]?.['account']??'','orders_analyzed':a['length'],'actionable':c,'waiting':d,'all_pending_claims':e,'unread_messages_total':b??0x0,'summary':f};}function nameResolvesTo(a,b){if(!a)return![];return Array['isArray'](a)?a['includes'](b):a===b;}export function isConsequenceNode(a,b,c){const d=c?.[b]??DEFAULT_ANNOTATIONS[b],e=(a??'')['toLowerCase']();return d['some'](f=>e['includes'](f));}function resolveForward(a,b,c,d,e,f){let g='not_available';if(a['permissionIndex']!=null){if(e['has'](a['permissionIndex']))g='permission';}else{if(a['namedOperator']===''){if(d)g='order_holder';}else{if(a['namedOperator']!=null){const k=c['named_accounts']?.[a['namedOperator']];if(nameResolvesTo(k,c['account']))g='named_operator';}}}const h=b,i=describeForward(a['name']??'',h,g,a['permissionIndex'],a['namedOperator']),j=consequenceOf(h,f);return{'name':a['name']??'(unnamed)','to_node':h,'execution_path':g,'permission_index':a['permissionIndex']??undefined,'named_operator':a['namedOperator']??undefined,'guard':a['guard']??undefined,'semantics':i,'consequence':j,'weight':a['weight']??undefined};}function describeForward(a,b,c,d,e){const f=d!=null?'requires\x20permission\x20index\x20'+d:e===''?'executable\x20by\x20the\x20order\x20holder\x20(customer)':'executable\x20by\x20named\x20operator\x20\x27'+e+'\x27',g=c==='not_available'?'You\x20CANNOT\x20execute\x20this':'You\x20CAN\x20execute\x20this';return'\x27'+a+'\x27\x20advances\x20the\x20order\x20to\x20node\x20\x27'+b+'\x27\x20('+f+').\x20'+g+'.';}function consequenceOf(a,b){if(isConsequenceNode(a,'completed',b))return'Completion\x20path\x20—\x20funds\x20are\x20released\x20to\x20the\x20merchant\x20per\x20the\x20Allocation\x20waterfall;\x20refunds\x20become\x20harder\x20after\x20this\x20point.';if(isConsequenceNode(a,'refunded',b))return'Refund/cancellation\x20path\x20—\x20escrowed\x20funds\x20return\x20to\x20the\x20buyer\x20per\x20the\x20Allocation\x20configuration.';return undefined;}function buildInterestHints(a,b,c,d,e){const f=[],g=a['now']??Date['now'](),h=a['last_progress_at']!=null?(g-a['last_progress_at'])/0x36ee80:undefined;if(b==='customer')c['length']>0x0&&f['push']('Your\x20confirmation\x20is\x20the\x20fund-release\x20trigger:\x20escrowed\x20money\x20stays\x20locked\x20until\x20YOU\x20act\x20—\x20only\x20confirm\x20when\x20the\x20deliverable\x20matches\x20the\x20agreement.'),d['some'](i=>i['role']!=='OrderHolder\x20(customer)')&&f['push']('Delivery\x20depends\x20on\x20the\x20merchant-side\x20roles\x20listed\x20in\x20waiting_on;\x20if\x20they\x20stall,\x20Messenger\x20first,\x20then\x20consider\x20dispute\x20via\x20the\x20bound\x20Arbitration.'),h!=null&&h>0x18&&f['push']('Order\x20has\x20not\x20advanced\x20for\x20'+Math['round'](h)+'h.\x20Your\x20leverage:\x20compensation_fund\x20(if\x20any)\x20+\x20arbitration\x20+\x20on-chain\x20reputation\x20(dislike)\x20—\x20in\x20that\x20order.');else{if(b==='supplier')c['length']>0x0&&f['push']('Advancing\x20your\x20sub-order\x20NOW\x20unlocks\x20YOUR\x20settlement\x20—\x20upload\x20delivery\x20evidence\x20first\x20to\x20protect\x20your\x20payment\x20claim\x20against\x20the\x20upstream\x20merchant.'),d['some'](i=>i['role']!=='OrderHolder\x20(customer)')&&f['push']('Your\x20settlement\x20depends\x20on\x20upstream\x20roles\x20in\x20waiting_on;\x20if\x20they\x20stall,\x20a\x20Messenger\x20nudge\x20first,\x20then\x20arbitration\x20via\x20the\x20bound\x20Arbitration.'),h!=null&&h>0x30&&f['push']('Sub-order\x20stalled\x20'+Math['round'](h)+'h:\x20your\x20claim\x20erodes\x20with\x20time\x20—\x20evidence\x20+\x20a\x20Messenger\x20nudge\x20are\x20your\x20cheapest\x20protections.');else{if(b==='collaborator'||b==='merchant'){const i=d['filter'](j=>j['role']['startsWith']('permission\x20index'));c['length']>0x0&&f['push']('Advancing\x20the\x20workflow\x20NOW\x20improves\x20flow\x20efficiency\x20and\x20shortens\x20your\x20fund-settlement\x20cycle;\x20stalled\x20orders\x20degrade\x20your\x20on-chain\x20reputation\x20metrics\x20(dispute\x20rate,\x20stall\x20statistics).'),i['length']>0x0&&f['push']('Nodes\x20waiting\x20on\x20YOUR\x20permission\x20indexes\x20are\x20your\x20responsibility\x20surface:\x20prolonged\x20inaction\x20may\x20trigger\x20timeout\x20penalties\x20or\x20disputes\x20recorded\x20permanently\x20on-chain.'),e&&c['length']===0x0&&f['push']('Nothing\x20for\x20you\x20to\x20execute\x20at\x20this\x20node\x20—\x20monitor\x20only;\x20avoid\x20unnecessary\x20interference\x20that\x20creates\x20semantic\x20responsibility.');}else f['push']('You\x20hold\x20no\x20operative\x20role\x20on\x20this\x20order\x20(prospect).\x20On-chain\x20data\x20remains\x20transparent\x20to\x20you\x20for\x20auditing.');}}return(a['unread_messages']??0x0)>0x0&&f['push'](a['unread_messages']+'\x20unread\x20Messenger\x20message(s)\x20—\x20negotiation\x20evidence\x20(WTS)\x20forms\x20the\x20arbitration\x20record;\x20timely\x20replies\x20protect\x20your\x20position.'),f;}function buildSummary(a,b,c,d,e,f,g,h){const i=c['length']>0x0?c['map'](m=>m['label'])['join'](',\x20'):'no\x20operative\x20role',j=h===''?'(entry,\x20not\x20started)':'\x27'+h+'\x27';if(g)return'Order\x20'+a['progress_address']+'\x20is\x20at\x20'+j+';\x20you\x20are\x20'+b+'\x20('+i+').\x20Machine\x20workflow\x20data\x20unavailable\x20—\x20fetch\x20the\x20bound\x20Machine\x20to\x20see\x20executable\x20operations.';const k=d['length']>0x0?'you\x20can\x20execute:\x20'+d['map'](m=>'\x27'+m['name']+'\x27→\x27'+m['to_node']+'\x27')['join'](',\x20'):e['length']>0x0?'waiting\x20on\x20'+e['map'](m=>m['role'])['join'](',\x20'):'no\x20pending\x20operations\x20at\x20this\x20node',l=f['length']>0x0?'\x20'+f['length']+'\x20unclaimed\x20benefit(s).':'';return'Order\x20at\x20'+j+';\x20you\x20are\x20'+b+'\x20('+i+')\x20—\x20'+k+'.'+l;}
@@ -0,0 +1,25 @@
1
+ import type { RadarForward } from "./radar-core.js";
2
+ export interface SupplierInterestInput {
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
+ arbitration_bound: boolean;
13
+ compensation_fund?: string;
14
+ terminal?: "completed" | "refunded" | null;
15
+ stalled_hours?: number;
16
+ unread_messages?: number;
17
+ }
18
+ export interface SupplierInterestAnalysis {
19
+ fund_flow: string[];
20
+ responsibility: string[];
21
+ leverage: string[];
22
+ stakes: string[];
23
+ summary: string;
24
+ }
25
+ export declare function analyzeSupplierInterest(input: SupplierInterestInput): SupplierInterestAnalysis;
@@ -0,0 +1 @@
1
+ export function analyzeSupplierInterest(a){const b=[],c=[],d=[],e=[],f=a['token_type']?'\x20('+a['token_type']+')':'';if(a['terminal']==='completed')b['push']('Sub-order\x20reached\x20a\x20completion\x20terminal:\x20your\x20settlement\x20is\x20released\x20through\x20the\x20allocation\x20waterfall.\x20'+'Verify\x20your\x20share\x20arrived\x20(query\x20your\x20sub-order\x27s\x20Allocation/Treasury\x20objects)\x20—\x20the\x20upstream\x20hop\x20must\x20pay\x20out\x20too.');else{if(a['terminal']==='refunded')b['push']('Sub-order\x20reached\x20a\x20refund\x20terminal:\x20the\x20sub-order\x27s\x20escrow\x20is\x20returned,\x20not\x20settled.\x20'+'No\x20settlement\x20remains\x20for\x20this\x20sub-order;\x20any\x20completed\x20work\x20may\x20be\x20unrecoverable\x20absent\x20a\x20dispute.');else a['order_amount']!=null&&b['push'](a['order_amount']+'\x20raw\x20units'+f+'\x20are\x20owed\x20to\x20YOU\x20for\x20this\x20sub-order\x20—\x20'+'released\x20ONLY\x20when\x20the\x20sub-order\x20advances\x20to\x20completion;\x20your\x20claim\x20is\x20against\x20the\x20upstream\x20merchant\x27s\x20settlement,\x20not\x20a\x20platform.');}a['compensation_fund']!=null&&a['compensation_fund']!=='0'?b['push']('The\x20upstream\x20merchant\x27s\x20compensation_fund\x20holds\x20'+a['compensation_fund']+'\x20raw\x20units'+f+'\x20—\x20'+'your\x20recourse\x20if\x20the\x20merchant\x20withholds\x20your\x20share\x20and\x20arbitration\x20awards\x20indemnity\x20(paid\x20FROM\x20it).'):b['push']('The\x20upstream\x20merchant\x27s\x20compensation_fund\x20is\x20EMPTY\x20—\x20your\x20only\x20recourse\x20for\x20unpaid\x20work\x20is\x20the\x20refund\x20path\x20+\x20on-chain\x20reputation.');a['operable']['length']>0x0&&c['push']('YOU\x20can\x20execute\x20'+a['operable']['map'](j=>'\x27'+j['name']+'\x27')['join'](',\x20')+'\x20on\x20your\x20sub-order\x20right\x20now\x20—\x20'+'your\x20delivery\x20is\x20what\x20unlocks\x20your\x20settlement;\x20only\x20advance\x20when\x20the\x20deliverable\x20is\x20actually\x20ready.');a['terminal']==null&&a['operable']['length']===0x0&&a['waiting_on']['length']>0x0&&c['push']('No\x20forward\x20is\x20yours\x20on\x20this\x20sub-order\x20at\x20this\x20node\x20—\x20you\x20carry\x20no\x20execution\x20responsibility\x20here;\x20'+'your\x20settlement\x20depends\x20on\x20the\x20roles\x20in\x20waiting_on.');a['operable']['length']>0x0&&a['terminal']==null&&d['push']('Uploading\x20delivery\x20evidence\x20(Repository/proof)\x20BEFORE\x20advancing\x20your\x20sub-order\x20protects\x20your\x20payment\x20claim\x20'+'and\x20pre-builds\x20your\x20arbitration\x20defense\x20if\x20the\x20upstream\x20merchant\x20disputes.');const g=a['waiting_on']['some'](j=>j['role']!=='OrderHolder\x20(customer)');g&&a['terminal']==null&&d['push']('Your\x20settlement\x20waits\x20on\x20upstream\x20roles:\x20a\x20Messenger\x20nudge\x20accelerates\x20collection,\x20'+'and\x20the\x20conversation\x20is\x20recorded\x20as\x20WTS\x20evidence\x20protecting\x20your\x20claim.');a['arbitration_bound']&&a['terminal']==null&&d['push']('A\x20dispute\x20path\x20exists:\x20if\x20the\x20upstream\x20merchant\x20withholds\x20your\x20share,\x20open\x20arbitration\x20—\x20'+'your\x20evidence\x20(WTS\x20+\x20WIP\x20hash)\x20decides\x20the\x20outcome.');(a['unread_messages']??0x0)>0x0&&d['push'](a['unread_messages']+'\x20unread\x20Messenger\x20message(s)\x20—\x20timely\x20replies\x20protect\x20your\x20position\x20(WTS\x20record).');a['order_amount']!=null&&a['terminal']==null&&e['push'](a['order_amount']+'\x20raw\x20units'+f+'\x20of\x20your\x20settlement\x20are\x20at\x20risk:\x20'+'if\x20you\x20under-deliver\x20you\x20lose\x20the\x20claim;\x20if\x20the\x20upstream\x20merchant\x20stalls\x20you\x20are\x20left\x20waiting\x20—\x20'+'pursue\x20evidence\x20+\x20Messenger\x20+\x20arbitration\x20rather\x20than\x20letting\x20the\x20sub-order\x20stall\x20indefinitely.');a['stalled_hours']!=null&&a['stalled_hours']>0x30&&a['terminal']==null&&e['push']('Sub-order\x20stalled\x20'+Math['round'](a['stalled_hours'])+'h:\x20prolonged\x20stall\x20erodes\x20your\x20claim\x20and\x20'+'invites\x20dispute\x20—\x20evidence\x20+\x20a\x20Messenger\x20nudge\x20are\x20your\x20two\x20cheapest\x20protections.');a['terminal']==='refunded'&&e['push']('Refund\x20executed:\x20settlement\x20lost\x20for\x20this\x20sub-order.\x20Completed\x20work\x20may\x20be\x20unrecoverable\x20—\x20'+'a\x20professional\x20Messenger\x20close-out\x20+\x20evidence\x20archive\x20is\x20your\x20residual\x20protection\x20for\x20any\x20dispute.');const h=a['terminal']==='completed'?'sub-order\x20completed\x20—\x20settlement\x20released\x20(verify\x20your\x20share\x20arrived)':a['terminal']==='refunded'?'sub-order\x20refunded\x20—\x20settlement\x20lost':a['operable']['length']>0x0?'YOU\x20can\x20advance\x20'+a['operable']['length']+'\x20forward(s)\x20—\x20delivery\x20unlocks\x20your\x20settlement':'waiting\x20on\x20'+(a['waiting_on']['map'](j=>j['role'])['join'](',\x20')||'others')+'\x20—\x20monitor\x20and\x20nudge',i='Supplier\x20interest\x20at\x20node\x20\x27'+(a['current_node']||'(entry)')+'\x27:\x20'+h+'.\x20'+'All\x20options\x20above\x20are\x20informational\x20—\x20the\x20decision\x20is\x20yours.';return{'fund_flow':b,'responsibility':c,'leverage':d,'stakes':e,'summary':i};}
@@ -1,66 +1 @@
1
- const INDUSTRY_KEYWORDS = {
2
- freelance: ["freelance", "upwork"],
3
- rental: ["rental", "airbnb"],
4
- education: ["education", "coursera"],
5
- travel: ["travel", "booking"],
6
- subscription: ["subscription", "patreon"],
7
- retail: ["retail", "amazon"],
8
- };
9
- const ROLE_KEYWORDS = {
10
- merchant: ["merchant", "seller", "provider"],
11
- user: ["user", "buyer", "customer"],
12
- arbitrator: ["arbitrator"],
13
- };
14
- const RISK_KEYWORDS = {
15
- conservative: ["conservative"],
16
- aggressive: ["aggressive"],
17
- };
18
- export function analyzePersonaContext(context) {
19
- const lower = context.toLowerCase();
20
- const analysis = {
21
- industries: [],
22
- preferences: {},
23
- requirements: [],
24
- rules: [],
25
- suggestions: [],
26
- confidence: 0,
27
- };
28
- for (const [role, kws] of Object.entries(ROLE_KEYWORDS)) {
29
- if (kws.some((k) => lower.includes(k))) {
30
- analysis.role = role;
31
- analysis.suggestions.push({ field: "role", value: role, reason: "role keyword matched" });
32
- break;
33
- }
34
- }
35
- for (const [ind, kws] of Object.entries(INDUSTRY_KEYWORDS)) {
36
- if (kws.some((k) => lower.includes(k))) {
37
- analysis.industries.push(ind);
38
- analysis.suggestions.push({ field: "industries", value: ind, reason: "industry keyword matched" });
39
- }
40
- }
41
- if (RISK_KEYWORDS.conservative.some((k) => lower.includes(k))) {
42
- analysis.preferences.risk_appetite = "conservative";
43
- analysis.suggestions.push({ field: "preferences.risk_appetite", value: "conservative", reason: "conservative keyword" });
44
- }
45
- else if (RISK_KEYWORDS.aggressive.some((k) => lower.includes(k))) {
46
- analysis.preferences.risk_appetite = "aggressive";
47
- analysis.suggestions.push({ field: "preferences.risk_appetite", value: "aggressive", reason: "aggressive keyword" });
48
- }
49
- const reqKeywords = ["must", "forbid", "never", "require"];
50
- const ruleKeywords = ["learned", "avoid"];
51
- for (const raw of context.split(/[;.\n]/)) {
52
- const s = raw.trim();
53
- if (!s)
54
- continue;
55
- if (reqKeywords.some((k) => s.toLowerCase().includes(k.toLowerCase()))) {
56
- analysis.requirements.push(s);
57
- analysis.suggestions.push({ field: "requirements", value: s, reason: "red-line keyword" });
58
- }
59
- else if (ruleKeywords.some((k) => s.toLowerCase().includes(k.toLowerCase()))) {
60
- analysis.rules.push(s);
61
- analysis.suggestions.push({ field: "rules", value: s, reason: "experience keyword" });
62
- }
63
- }
64
- analysis.confidence = Math.min(1, analysis.suggestions.length * 0.2);
65
- return analysis;
66
- }
1
+ const INDUSTRY_KEYWORDS={'freelance':['freelance','upwork'],'rental':['rental','airbnb'],'education':['education','coursera'],'travel':['travel','booking'],'subscription':['subscription','patreon'],'retail':['retail','amazon']},ROLE_KEYWORDS={'merchant':['merchant','seller','provider'],'customer':['customer','buyer'],'prospect':['prospect','considering\x20a\x20purchase','shopping\x20for'],'supplier':['supplier','subcontractor','sub-order'],'collaborator':['collaborator','operator','staff','named\x20operator'],'arbitrator':['arbitrator','arbiter','judge']},RISK_KEYWORDS={'conservative':['conservative'],'aggressive':['aggressive']};export function analyzePersonaContext(a){const b=a['toLowerCase'](),c={'industries':[],'preferences':{},'requirements':[],'rules':[],'suggestions':[],'confidence':0x0};for(const [f,g]of Object['entries'](ROLE_KEYWORDS)){if(g['some'](h=>b['includes'](h))){c['role']=f,c['suggestions']['push']({'field':'role','value':f,'reason':'role\x20keyword\x20matched'});break;}}for(const [h,i]of Object['entries'](INDUSTRY_KEYWORDS)){i['some'](j=>b['includes'](j))&&(c['industries']['push'](h),c['suggestions']['push']({'field':'industries','value':h,'reason':'industry\x20keyword\x20matched'}));}if(RISK_KEYWORDS['conservative']['some'](j=>b['includes'](j)))c['preferences']['risk_appetite']='conservative',c['suggestions']['push']({'field':'preferences.risk_appetite','value':'conservative','reason':'conservative\x20keyword'});else RISK_KEYWORDS['aggressive']['some'](j=>b['includes'](j))&&(c['preferences']['risk_appetite']='aggressive',c['suggestions']['push']({'field':'preferences.risk_appetite','value':'aggressive','reason':'aggressive\x20keyword'}));const d=['must','forbid','never','require'],e=['learned','avoid'];for(const j of a['split'](/[;.\n]/)){const k=j['trim']();if(!k)continue;if(d['some'](l=>k['toLowerCase']()['includes'](l['toLowerCase']())))c['requirements']['push'](k),c['suggestions']['push']({'field':'requirements','value':k,'reason':'red-line\x20keyword'});else e['some'](l=>k['toLowerCase']()['includes'](l['toLowerCase']()))&&(c['rules']['push'](k),c['suggestions']['push']({'field':'rules','value':k,'reason':'experience\x20keyword'}));}return c['confidence']=Math['min'](0x1,c['suggestions']['length']*0.2),c;}
@@ -1,86 +1 @@
1
- const REQUIREMENT_RULE_MAP = [
2
- { keywords: ["arbitration", "arb"], rule_id: "r_trust" },
3
- { keywords: ["compensation", "fund"], rule_id: "r_fund" },
4
- { keywords: ["region", "location"], rule_id: "r_region" },
5
- { keywords: ["price", "budget"], rule_id: "r_price" },
6
- { keywords: ["industry"], rule_id: "r_industry" },
7
- { keywords: ["capability"], rule_id: "r_capabilities" },
8
- { keywords: ["trust", "score"], rule_id: "r_trust" },
9
- ];
10
- const FORBID_KEYWORDS = ["forbid", "never", "no "];
11
- function mapRequirement(req) {
12
- const lower = req.toLowerCase();
13
- const forbid = FORBID_KEYWORDS.some((k) => lower.includes(k));
14
- for (const m of REQUIREMENT_RULE_MAP) {
15
- if (m.keywords.some((k) => lower.includes(k))) {
16
- return { rule_id: m.rule_id, condition: forbid ? "forbid" : "require", note: req };
17
- }
18
- }
19
- return { rule_id: "r_trust", condition: forbid ? "forbid" : "require", note: req };
20
- }
21
- export function personaToInjection(effective) {
22
- const requirements = (effective.layer.requirements ?? []).map(mapRequirement);
23
- const intent = [
24
- `role=${effective.role}`,
25
- effective.industries.length ? `industries=${effective.industries.join(",")}` : "",
26
- effective.layer.identity?.self_description ?? "",
27
- ].filter(Boolean).join("; ");
28
- return {
29
- intent,
30
- preferences: effective.layer.preferences ?? {},
31
- requirements: requirements.length ? requirements : undefined,
32
- };
33
- }
34
- export function personaToContextText(effective) {
35
- const lines = [];
36
- lines.push(`# Effective Persona (role=${effective.role}, industries=${effective.industries.join(",") || "any"})`);
37
- const id = effective.layer.identity;
38
- if (id) {
39
- if (id.self_description)
40
- lines.push(`- self: ${id.self_description}`);
41
- if (id.region)
42
- lines.push(`- region: ${id.region}`);
43
- if (id.languages?.length)
44
- lines.push(`- languages: ${id.languages.join(", ")}`);
45
- }
46
- if (effective.layer.strategy?.length) {
47
- lines.push("- strategy:");
48
- for (const s of effective.layer.strategy)
49
- lines.push(` - ${s}`);
50
- }
51
- if (effective.layer.rules?.length) {
52
- lines.push("- rules:");
53
- for (const r of effective.layer.rules)
54
- lines.push(` - ${r}`);
55
- }
56
- if (effective.layer.requirements?.length) {
57
- lines.push("- requirements:");
58
- for (const r of effective.layer.requirements)
59
- lines.push(` - ${r}`);
60
- }
61
- if (effective.layer.spec) {
62
- lines.push("- spec:");
63
- lines.push(effective.layer.spec);
64
- }
65
- return lines.join("\n");
66
- }
67
- export function mergeInjections(base, override) {
68
- if (!base && !override)
69
- return undefined;
70
- if (!base)
71
- return override ?? undefined;
72
- if (!override)
73
- return base;
74
- return {
75
- intent: override.intent ?? base.intent,
76
- preferences: { ...(base.preferences ?? {}), ...(override.preferences ?? {}) },
77
- requirements: [...(base.requirements ?? []), ...(override.requirements ?? [])],
78
- overrides: {
79
- rules: { ...(base.overrides?.rules ?? {}), ...(override.overrides?.rules ?? {}) },
80
- data_sources: {
81
- ...(base.overrides?.data_sources ?? {}),
82
- ...(override.overrides?.data_sources ?? {}),
83
- },
84
- },
85
- };
86
- }
1
+ const REQUIREMENT_RULE_MAP=[{'keywords':['arbitration','arb'],'rule_id':'r_trust'},{'keywords':['compensation','fund'],'rule_id':'r_fund'},{'keywords':['region','location'],'rule_id':'r_region'},{'keywords':['price','budget'],'rule_id':'r_price'},{'keywords':['industry'],'rule_id':'r_industry'},{'keywords':['capability'],'rule_id':'r_capabilities'},{'keywords':['trust','score'],'rule_id':'r_trust'}],FORBID_KEYWORDS=['forbid','never','no\x20'];function mapRequirement(a){const b=a['toLowerCase'](),c=FORBID_KEYWORDS['some'](d=>b['includes'](d));for(const d of REQUIREMENT_RULE_MAP){if(d['keywords']['some'](e=>b['includes'](e)))return{'rule_id':d['rule_id'],'condition':c?'forbid':'require','note':a};}return{'rule_id':'r_trust','condition':c?'forbid':'require','note':a};}export function personaToInjection(a){const b=(a['layer']['requirements']??[])['map'](mapRequirement),c=['role='+a['role'],a['industries']['length']?'industries='+a['industries']['join'](','):'',a['layer']['identity']?.['self_description']??'']['filter'](Boolean)['join'](';\x20');return{'intent':c,'preferences':a['layer']['preferences']??{},'requirements':b['length']?b:undefined};}export function personaToContextText(a){const b=[];b['push']('#\x20Effective\x20Persona\x20(role='+a['role']+',\x20industries='+(a['industries']['join'](',')||'any')+')');const c=a['layer']['identity'];if(c){if(c['self_description'])b['push']('-\x20self:\x20'+c['self_description']);if(c['region'])b['push']('-\x20region:\x20'+c['region']);if(c['languages']?.['length'])b['push']('-\x20languages:\x20'+c['languages']['join'](',\x20'));}if(a['layer']['strategy']?.['length']){b['push']('-\x20strategy:');for(const d of a['layer']['strategy'])b['push']('\x20\x20-\x20'+d);}if(a['layer']['rules']?.['length']){b['push']('-\x20rules:');for(const e of a['layer']['rules'])b['push']('\x20\x20-\x20'+e);}if(a['layer']['requirements']?.['length']){b['push']('-\x20requirements:');for(const f of a['layer']['requirements'])b['push']('\x20\x20-\x20'+f);}return a['layer']['spec']&&(b['push']('-\x20spec:'),b['push'](a['layer']['spec'])),b['join']('\x0a');}export function mergeInjections(a,b){if(!a&&!b)return undefined;if(!a)return b??undefined;if(!b)return a;return{'intent':b['intent']??a['intent'],'preferences':{...a['preferences']??{},...b['preferences']??{}},'requirements':[...a['requirements']??[],...b['requirements']??[]],'overrides':{'rules':{...a['overrides']?.['rules']??{},...b['overrides']?.['rules']??{}},'data_sources':{...a['overrides']?.['data_sources']??{},...b['overrides']?.['data_sources']??{}}}};}