@wowok/agent-mcp 2.7.1 → 2.7.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (597) hide show
  1. package/dist/config/index.js +1 -1
  2. package/dist/config/runtime.js +1 -238
  3. package/dist/customer/account-events.d.ts +32 -0
  4. package/dist/customer/account-events.js +1 -0
  5. package/dist/customer/customer-advice.d.ts +1 -0
  6. package/dist/customer/customer-advice.js +1 -130
  7. package/dist/customer/index.js +1 -11
  8. package/dist/customer/industry-risks.js +1 -438
  9. package/dist/customer/info-puzzle.js +1 -681
  10. package/dist/customer/order-monitor.js +1 -328
  11. package/dist/customer/order-strategy.d.ts +1 -1
  12. package/dist/customer/order-strategy.js +1 -373
  13. package/dist/customer/post-purchase.js +1 -351
  14. package/dist/customer/preorder-compare.js +1 -34
  15. package/dist/customer/reminder-system.d.ts +2 -0
  16. package/dist/customer/reminder-system.js +1 -316
  17. package/dist/customer/risk-assessment.d.ts +1 -0
  18. package/dist/customer/risk-assessment.js +1 -397
  19. package/dist/customer/types.d.ts +2 -0
  20. package/dist/customer/types.js +1 -13
  21. package/dist/customer/user-preferences.js +1 -460
  22. package/dist/evaluation/arbitration-game.d.ts +9 -2
  23. package/dist/evaluation/arbitration-game.js +1 -48
  24. package/dist/evaluation/builtins/arbitration-score.d.ts +41 -0
  25. package/dist/evaluation/builtins/arbitration-score.js +1 -0
  26. package/dist/evaluation/builtins/demand-match.js +1 -153
  27. package/dist/evaluation/builtins/index.d.ts +1 -0
  28. package/dist/evaluation/builtins/index.js +1 -10
  29. package/dist/evaluation/builtins/service-risk.js +1 -55
  30. package/dist/evaluation/capability.js +1 -13
  31. package/dist/evaluation/category-match-rules.d.ts +30 -0
  32. package/dist/evaluation/category-match-rules.js +1 -0
  33. package/dist/evaluation/composer.js +1 -40
  34. package/dist/evaluation/engine.js +1 -175
  35. package/dist/evaluation/extract.js +1 -115
  36. package/dist/evaluation/game-strategy.d.ts +27 -0
  37. package/dist/evaluation/game-strategy.js +1 -0
  38. package/dist/evaluation/gap.js +1 -100
  39. package/dist/evaluation/index.d.ts +2 -0
  40. package/dist/evaluation/index.js +1 -11
  41. package/dist/evaluation/location-match.d.ts +42 -0
  42. package/dist/evaluation/location-match.js +1 -0
  43. package/dist/evaluation/node-game.d.ts +31 -3
  44. package/dist/evaluation/node-game.js +1 -57
  45. package/dist/evaluation/path-reasoning.d.ts +35 -0
  46. package/dist/evaluation/path-reasoning.js +1 -0
  47. package/dist/evaluation/region.d.ts +6 -0
  48. package/dist/evaluation/region.js +1 -36
  49. package/dist/evaluation/types.d.ts +18 -0
  50. package/dist/evaluation/types.js +1 -1
  51. package/dist/evaluation/user-injection.js +1 -27
  52. package/dist/experience/experience-reuse.js +1 -103
  53. package/dist/experience/index.js +1 -5
  54. package/dist/experience/intent-distill.js +1 -83
  55. package/dist/experience/realtime-feedback.js +1 -94
  56. package/dist/experience/types.js +1 -1
  57. package/dist/experience/user-profile.d.ts +1 -1
  58. package/dist/experience/user-profile.js +1 -171
  59. package/dist/extensions/business-modules.js +1 -287
  60. package/dist/extensions/capability-manifest.js +1 -781
  61. package/dist/extensions/constraint-registry.js +1 -198
  62. package/dist/extensions/index.d.ts +6 -0
  63. package/dist/extensions/index.js +1 -6
  64. package/dist/extensions/industry-layers.d.ts +75 -0
  65. package/dist/extensions/industry-layers.js +1 -0
  66. package/dist/extensions/industry-pack.d.ts +105 -0
  67. package/dist/extensions/industry-pack.js +1 -0
  68. package/dist/extensions/metric-registry.js +1 -257
  69. package/dist/extensions/mode-evaluator.d.ts +1 -1
  70. package/dist/extensions/mode-evaluator.js +1 -170
  71. package/dist/extensions/modes.js +1 -499
  72. package/dist/extensions/registry.d.ts +1 -0
  73. package/dist/extensions/registry.js +1 -717
  74. package/dist/extensions/types.js +1 -1
  75. package/dist/graph/base.d.ts +8 -0
  76. package/dist/graph/base.js +1 -0
  77. package/dist/harness/auto-escalation.js +1 -68
  78. package/dist/harness/checkpoint.js +1 -129
  79. package/dist/harness/index.d.ts +1 -0
  80. package/dist/harness/index.js +1 -78
  81. package/dist/harness/plan.d.ts +2 -0
  82. package/dist/harness/plan.js +1 -315
  83. package/dist/harness/recover.d.ts +1 -1
  84. package/dist/harness/recover.js +1 -139
  85. package/dist/harness/types.d.ts +2 -3
  86. package/dist/harness/types.js +1 -1
  87. package/dist/harness/verify.js +1 -237
  88. package/dist/index.js +1 -273
  89. package/dist/intent/enrich.js +1 -67
  90. package/dist/intent/index.js +1 -60
  91. package/dist/intent/matcher.js +1 -81
  92. package/dist/intent/store.js +1 -55
  93. package/dist/intent/types.js +1 -10
  94. package/dist/knowledge/acquisition-flywheel.js +1 -192
  95. package/dist/knowledge/allocation-confirm.js +1 -534
  96. package/dist/knowledge/allocation-context.js +1 -249
  97. package/dist/knowledge/allocation-ledger.js +1 -463
  98. package/dist/knowledge/allocation-puzzle.js +1 -298
  99. package/dist/knowledge/allocation-risk.js +1 -568
  100. package/dist/knowledge/allocation-templates.js +1 -970
  101. package/dist/knowledge/allocation-translation.js +1 -585
  102. package/dist/knowledge/anti-cheat.d.ts +37 -0
  103. package/dist/knowledge/anti-cheat.js +1 -0
  104. package/dist/knowledge/arb-confirm.d.ts +28 -0
  105. package/dist/knowledge/arb-confirm.js +1 -0
  106. package/dist/knowledge/arb-risk.js +1 -210
  107. package/dist/knowledge/arb-translation.d.ts +48 -0
  108. package/dist/knowledge/arb-translation.js +1 -0
  109. package/dist/knowledge/arbitration-confirm.js +1 -559
  110. package/dist/knowledge/arbitration-context.js +1 -505
  111. package/dist/knowledge/arbitration-ledger.js +1 -521
  112. package/dist/knowledge/arbitration-puzzle.js +1 -304
  113. package/dist/knowledge/arbitration-risk.js +1 -423
  114. package/dist/knowledge/arbitration-templates.js +1 -276
  115. package/dist/knowledge/arbitration-translation.js +1 -487
  116. package/dist/knowledge/audit-rules.js +1 -141
  117. package/dist/knowledge/bridge-confirm.d.ts +26 -0
  118. package/dist/knowledge/bridge-confirm.js +1 -0
  119. package/dist/knowledge/bridge-risk.js +1 -263
  120. package/dist/knowledge/bridge-translation.d.ts +37 -0
  121. package/dist/knowledge/bridge-translation.js +1 -0
  122. package/dist/knowledge/contact-confirm.d.ts +27 -0
  123. package/dist/knowledge/contact-confirm.js +1 -0
  124. package/dist/knowledge/contact-risk.js +1 -200
  125. package/dist/knowledge/contact-templates.js +1 -60
  126. package/dist/knowledge/contact-translation.d.ts +39 -0
  127. package/dist/knowledge/contact-translation.js +1 -0
  128. package/dist/knowledge/demand-confirm.js +1 -206
  129. package/dist/knowledge/demand-context.d.ts +17 -0
  130. package/dist/knowledge/demand-context.js +1 -0
  131. package/dist/knowledge/demand-ledger.d.ts +26 -0
  132. package/dist/knowledge/demand-ledger.js +1 -0
  133. package/dist/knowledge/demand-matching.js +1 -132
  134. package/dist/knowledge/demand-puzzle.d.ts +29 -0
  135. package/dist/knowledge/demand-puzzle.js +1 -0
  136. package/dist/knowledge/demand-risk.js +1 -240
  137. package/dist/knowledge/demand-templates.d.ts +12 -0
  138. package/dist/knowledge/demand-templates.js +1 -0
  139. package/dist/knowledge/demand-translation.js +1 -354
  140. package/dist/knowledge/deployment-scanner.js +1 -823
  141. package/dist/knowledge/dynamic-pricing.js +1 -87
  142. package/dist/knowledge/evidence-review.d.ts +12 -0
  143. package/dist/knowledge/evidence-review.js +1 -0
  144. package/dist/knowledge/examples-scanner-cli.js +1 -26
  145. package/dist/knowledge/examples-scanner.js +1 -843
  146. package/dist/knowledge/flywheel-loop.d.ts +0 -1
  147. package/dist/knowledge/flywheel-loop.js +1 -404
  148. package/dist/knowledge/fund-layer.js +1 -973
  149. package/dist/knowledge/glossary.js +1 -211
  150. package/dist/knowledge/guard-confirm.js +1 -406
  151. package/dist/knowledge/guard-context.js +1 -287
  152. package/dist/knowledge/guard-design-patterns.js +1 -360
  153. package/dist/knowledge/guard-ledger.js +1 -260
  154. package/dist/knowledge/guard-lint.js +1 -670
  155. package/dist/knowledge/guard-migration.d.ts +1 -1
  156. package/dist/knowledge/guard-migration.js +1 -228
  157. package/dist/knowledge/guard-puzzle.js +1 -805
  158. package/dist/knowledge/guard-render.js +1 -700
  159. package/dist/knowledge/guard-risk.js +1 -1879
  160. package/dist/knowledge/guard-submission-prompt.js +1 -171
  161. package/dist/knowledge/guard-templates.js +1 -1105
  162. package/dist/knowledge/guard-translation.js +1 -1119
  163. package/dist/knowledge/index.d.ts +71 -3
  164. package/dist/knowledge/index.js +1 -436
  165. package/dist/knowledge/industry-evolution.js +1 -323
  166. package/dist/knowledge/industry-generalizer.js +1 -381
  167. package/dist/knowledge/industry-registry.js +1 -174
  168. package/dist/knowledge/intent-metrics.d.ts +4 -3
  169. package/dist/knowledge/intent-metrics.js +1 -566
  170. package/dist/knowledge/machine-confirm.js +1 -559
  171. package/dist/knowledge/machine-context.js +1 -833
  172. package/dist/knowledge/machine-ledger.js +1 -338
  173. package/dist/knowledge/machine-puzzle.js +1 -494
  174. package/dist/knowledge/machine-render.js +1 -565
  175. package/dist/knowledge/machine-risk.js +1 -669
  176. package/dist/knowledge/machine-templates.js +1 -1597
  177. package/dist/knowledge/machine-topology.js +1 -234
  178. package/dist/knowledge/machine-translation.js +1 -513
  179. package/dist/knowledge/market-metrics.d.ts +12 -0
  180. package/dist/knowledge/market-metrics.js +1 -0
  181. package/dist/knowledge/market-operations.d.ts +46 -0
  182. package/dist/knowledge/market-operations.js +1 -0
  183. package/dist/knowledge/mcp-schema-audit-cli.js +1 -45
  184. package/dist/knowledge/mcp-schema-audit.d.ts +22 -22
  185. package/dist/knowledge/mcp-schema-audit.js +1 -777
  186. package/dist/knowledge/onchain-constants.js +1 -35
  187. package/dist/knowledge/order-confirm.js +1 -573
  188. package/dist/knowledge/order-context.js +1 -390
  189. package/dist/knowledge/order-ledger.js +1 -341
  190. package/dist/knowledge/order-puzzle.js +1 -255
  191. package/dist/knowledge/order-risk.js +1 -653
  192. package/dist/knowledge/order-templates.js +1 -368
  193. package/dist/knowledge/order-translation.js +1 -550
  194. package/dist/knowledge/overrides-loader.js +1 -65
  195. package/dist/knowledge/passport-confirm.js +1 -531
  196. package/dist/knowledge/passport-context.js +1 -306
  197. package/dist/knowledge/passport-ledger.js +1 -282
  198. package/dist/knowledge/passport-puzzle.js +1 -333
  199. package/dist/knowledge/passport-risk.js +1 -450
  200. package/dist/knowledge/passport-templates.js +1 -568
  201. package/dist/knowledge/passport-translation.js +1 -516
  202. package/dist/knowledge/payment-confirm.d.ts +26 -0
  203. package/dist/knowledge/payment-confirm.js +1 -0
  204. package/dist/knowledge/payment-risk.js +1 -249
  205. package/dist/knowledge/payment-translation.d.ts +37 -0
  206. package/dist/knowledge/payment-translation.js +1 -0
  207. package/dist/knowledge/permission-confirm.js +1 -426
  208. package/dist/knowledge/permission-context.js +1 -224
  209. package/dist/knowledge/permission-ledger.d.ts +11 -0
  210. package/dist/knowledge/permission-ledger.js +1 -403
  211. package/dist/knowledge/permission-puzzle.js +1 -173
  212. package/dist/knowledge/permission-risk.js +1 -411
  213. package/dist/knowledge/permission-templates.js +1 -234
  214. package/dist/knowledge/permission-translation.js +1 -350
  215. package/dist/knowledge/personal-confirm.d.ts +29 -0
  216. package/dist/knowledge/personal-confirm.js +1 -0
  217. package/dist/knowledge/personal-risk.js +1 -212
  218. package/dist/knowledge/personal-translation.d.ts +37 -0
  219. package/dist/knowledge/personal-translation.js +1 -0
  220. package/dist/knowledge/process-model.d.ts +1 -11
  221. package/dist/knowledge/process-model.js +1 -160
  222. package/dist/knowledge/progress-confirm.js +1 -456
  223. package/dist/knowledge/progress-context.js +1 -452
  224. package/dist/knowledge/progress-ledger.js +1 -330
  225. package/dist/knowledge/progress-puzzle.js +1 -219
  226. package/dist/knowledge/progress-risk.js +1 -461
  227. package/dist/knowledge/progress-templates.js +1 -228
  228. package/dist/knowledge/progress-translation.js +1 -405
  229. package/dist/knowledge/proof-confirm.js +1 -187
  230. package/dist/knowledge/proof-context.d.ts +17 -0
  231. package/dist/knowledge/proof-context.js +1 -0
  232. package/dist/knowledge/proof-ledger.d.ts +34 -0
  233. package/dist/knowledge/proof-ledger.js +1 -0
  234. package/dist/knowledge/proof-puzzle.d.ts +35 -0
  235. package/dist/knowledge/proof-puzzle.js +1 -0
  236. package/dist/knowledge/proof-risk.js +1 -207
  237. package/dist/knowledge/proof-templates.d.ts +22 -0
  238. package/dist/knowledge/proof-templates.js +1 -0
  239. package/dist/knowledge/proof-translation.js +1 -283
  240. package/dist/knowledge/registrar-confirm.d.ts +26 -0
  241. package/dist/knowledge/registrar-confirm.js +1 -0
  242. package/dist/knowledge/registrar-risk.js +1 -217
  243. package/dist/knowledge/registrar-translation.d.ts +37 -0
  244. package/dist/knowledge/registrar-translation.js +1 -0
  245. package/dist/knowledge/repository-confirm.js +1 -286
  246. package/dist/knowledge/repository-context.d.ts +12 -0
  247. package/dist/knowledge/repository-context.js +1 -0
  248. package/dist/knowledge/repository-ledger.d.ts +25 -0
  249. package/dist/knowledge/repository-ledger.js +1 -0
  250. package/dist/knowledge/repository-puzzle.d.ts +30 -0
  251. package/dist/knowledge/repository-puzzle.js +1 -0
  252. package/dist/knowledge/repository-risk.js +1 -373
  253. package/dist/knowledge/repository-templates.d.ts +14 -0
  254. package/dist/knowledge/repository-templates.js +1 -0
  255. package/dist/knowledge/repository-translation.js +1 -445
  256. package/dist/knowledge/reputation-rules.js +1 -99
  257. package/dist/knowledge/resource-confirm.d.ts +25 -0
  258. package/dist/knowledge/resource-confirm.js +1 -0
  259. package/dist/knowledge/resource-risk.js +1 -157
  260. package/dist/knowledge/resource-translation.d.ts +37 -0
  261. package/dist/knowledge/resource-translation.js +1 -0
  262. package/dist/knowledge/reward-confirm.js +1 -526
  263. package/dist/knowledge/reward-context.d.ts +2 -2
  264. package/dist/knowledge/reward-context.js +1 -504
  265. package/dist/knowledge/reward-ledger.js +1 -502
  266. package/dist/knowledge/reward-puzzle.js +1 -300
  267. package/dist/knowledge/reward-risk.js +1 -627
  268. package/dist/knowledge/reward-templates.js +1 -197
  269. package/dist/knowledge/reward-translation.js +1 -501
  270. package/dist/knowledge/safety-rules.d.ts +1 -0
  271. package/dist/knowledge/safety-rules.js +1 -404
  272. package/dist/knowledge/scenario-modes.js +1 -321
  273. package/dist/knowledge/service-confirm.js +1 -807
  274. package/dist/knowledge/service-context.js +1 -403
  275. package/dist/knowledge/service-ledger.js +1 -609
  276. package/dist/knowledge/service-puzzle.js +1 -236
  277. package/dist/knowledge/service-risk.d.ts +1 -1
  278. package/dist/knowledge/service-risk.js +1 -651
  279. package/dist/knowledge/service-templates.js +1 -456
  280. package/dist/knowledge/service-translation.js +1 -622
  281. package/dist/knowledge/template-registry.js +1 -353
  282. package/dist/knowledge/tool-constraints.js +1 -195
  283. package/dist/knowledge/tools-reference.js +1 -178
  284. package/dist/knowledge/treasury-confirm.js +1 -512
  285. package/dist/knowledge/treasury-context.js +1 -363
  286. package/dist/knowledge/treasury-ledger.js +1 -300
  287. package/dist/knowledge/treasury-puzzle.js +1 -216
  288. package/dist/knowledge/treasury-risk.js +1 -440
  289. package/dist/knowledge/treasury-templates.js +1 -358
  290. package/dist/knowledge/treasury-translation.js +1 -498
  291. package/dist/knowledge/trust-metrics.js +1 -198
  292. package/dist/knowledge/universal-template.d.ts +22 -0
  293. package/dist/knowledge/universal-template.js +1 -0
  294. package/dist/knowledge/util-confirm.d.ts +24 -0
  295. package/dist/knowledge/util-confirm.js +1 -0
  296. package/dist/knowledge/util-risk.js +1 -135
  297. package/dist/knowledge/util-translation.d.ts +38 -0
  298. package/dist/knowledge/util-translation.js +1 -0
  299. package/dist/knowledge/workflow-guidance.d.ts +116 -0
  300. package/dist/knowledge/workflow-guidance.js +1 -0
  301. package/dist/loop-engineering/aggregate.js +1 -132
  302. package/dist/loop-engineering/context-collect.js +1 -83
  303. package/dist/loop-engineering/diagnose.js +1 -273
  304. package/dist/loop-engineering/improve.js +1 -405
  305. package/dist/loop-engineering/index.js +1 -4
  306. package/dist/loop-engineering/pipeline.js +1 -56
  307. package/dist/mode-market/index.js +1 -3
  308. package/dist/mode-market/registry.js +1 -124
  309. package/dist/mode-market/review.js +1 -214
  310. package/dist/mode-market/submission.js +1 -85
  311. package/dist/participation/collaborator-interest.d.ts +23 -0
  312. package/dist/participation/collaborator-interest.js +1 -0
  313. package/dist/participation/customer-interest.d.ts +25 -0
  314. package/dist/participation/customer-interest.js +1 -0
  315. package/dist/participation/employee-kpi.d.ts +25 -0
  316. package/dist/participation/employee-kpi.js +1 -0
  317. package/dist/participation/employee-store.d.ts +16 -0
  318. package/dist/participation/employee-store.js +1 -0
  319. package/dist/participation/index.d.ts +2 -0
  320. package/dist/participation/index.js +1 -0
  321. package/dist/participation/merchant-interest.js +1 -100
  322. package/dist/participation/radar-core.d.ts +13 -3
  323. package/dist/participation/radar-core.js +1 -269
  324. package/dist/participation/supplier-interest.d.ts +25 -0
  325. package/dist/participation/supplier-interest.js +1 -0
  326. package/dist/persona/analyzer.js +1 -66
  327. package/dist/persona/bridge.js +1 -86
  328. package/dist/persona/defaults.js +1 -195
  329. package/dist/persona/experience-bridge.js +1 -23
  330. package/dist/persona/index.d.ts +9 -2
  331. package/dist/persona/index.js +1 -71
  332. package/dist/persona/local-region.d.ts +20 -0
  333. package/dist/persona/local-region.js +1 -0
  334. package/dist/persona/model.js +1 -111
  335. package/dist/persona/overrides.d.ts +10 -0
  336. package/dist/persona/overrides.js +1 -0
  337. package/dist/persona/pack-personae.d.ts +11 -0
  338. package/dist/persona/pack-personae.js +1 -0
  339. package/dist/persona/store.js +1 -62
  340. package/dist/persona/strategy-intent.d.ts +20 -0
  341. package/dist/persona/strategy-intent.js +1 -0
  342. package/dist/persona/types.d.ts +6 -2
  343. package/dist/persona/types.js +1 -5
  344. package/dist/project/business-puzzle.d.ts +1 -1
  345. package/dist/project/business-puzzle.js +1 -383
  346. package/dist/project/context-assembly.js +1 -254
  347. package/dist/project/deployment-bridge.js +1 -120
  348. package/dist/project/deployment-doc.js +1 -1126
  349. package/dist/project/edit-planner.js +1 -1342
  350. package/dist/project/evaluation.d.ts +37 -1
  351. package/dist/project/evaluation.js +1 -2011
  352. package/dist/project/game-theory.js +1 -177
  353. package/dist/project/graph-builder.js +1 -656
  354. package/dist/project/graph.d.ts +3 -6
  355. package/dist/project/graph.js +1 -340
  356. package/dist/project/handlers.d.ts +33 -2
  357. package/dist/project/handlers.js +1 -1784
  358. package/dist/project/index.d.ts +2 -0
  359. package/dist/project/index.js +1 -301
  360. package/dist/project/intent-analyzer.js +1 -149
  361. package/dist/project/machine-nodes.js +1 -36
  362. package/dist/project/merchant-guide.d.ts +19 -0
  363. package/dist/project/merchant-guide.js +1 -264
  364. package/dist/project/migration.js +1 -125
  365. package/dist/project/mode-actions.js +1 -309
  366. package/dist/project/namespace.js +1 -206
  367. package/dist/project/participation-radar.js +1 -428
  368. package/dist/project/pipeline-actions.js +1 -109
  369. package/dist/project/project-store.js +1 -422
  370. package/dist/project/query.js +1 -153
  371. package/dist/project/reverse-mapping.d.ts +34 -0
  372. package/dist/project/reverse-mapping.js +1 -0
  373. package/dist/project/risk-aggregator.js +1 -295
  374. package/dist/project/rollback-policy.js +1 -290
  375. package/dist/project/semantic-assembler.js +1 -345
  376. package/dist/project/semantic-graph.d.ts +3 -5
  377. package/dist/project/semantic-graph.js +1 -292
  378. package/dist/project/stage-gate.js +1 -369
  379. package/dist/project/substep-trace.js +1 -332
  380. package/dist/project/task-tracker.js +1 -78
  381. package/dist/project/workflow-design-assessment.d.ts +24 -0
  382. package/dist/project/workflow-design-assessment.js +1 -0
  383. package/dist/role/derivation.d.ts +18 -0
  384. package/dist/role/derivation.js +1 -0
  385. package/dist/role/index.d.ts +5 -0
  386. package/dist/role/index.js +1 -0
  387. package/dist/role/model.d.ts +8 -0
  388. package/dist/role/model.js +1 -0
  389. package/dist/role/resolution.d.ts +11 -0
  390. package/dist/role/resolution.js +1 -0
  391. package/dist/role/types.d.ts +11 -0
  392. package/dist/role/types.js +1 -0
  393. package/dist/rules.js +1 -52
  394. package/dist/safety/confirm-gate.d.ts +1 -1
  395. package/dist/safety/confirm-gate.js +1 -88
  396. package/dist/safety/index.js +1 -3
  397. package/dist/safety/preview.js +1 -52
  398. package/dist/schema/call/allocation.d.ts +186 -1385
  399. package/dist/schema/call/allocation.js +1 -34
  400. package/dist/schema/call/arbitration.d.ts +272 -1871
  401. package/dist/schema/call/arbitration.js +1 -113
  402. package/dist/schema/call/base.d.ts +1831 -9076
  403. package/dist/schema/call/base.js +1 -370
  404. package/dist/schema/call/bridge.d.ts +911 -3171
  405. package/dist/schema/call/bridge.js +1 -458
  406. package/dist/schema/call/contact.d.ts +135 -931
  407. package/dist/schema/call/contact.js +1 -37
  408. package/dist/schema/call/demand.d.ts +164 -1194
  409. package/dist/schema/call/demand.js +1 -47
  410. package/dist/schema/call/guard.d.ts +298 -1140
  411. package/dist/schema/call/guard.js +1 -161
  412. package/dist/schema/call/handler.js +1 -322
  413. package/dist/schema/call/index.js +1 -20
  414. package/dist/schema/call/machine.d.ts +459 -5403
  415. package/dist/schema/call/machine.js +1 -193
  416. package/dist/schema/call/order.d.ts +137 -844
  417. package/dist/schema/call/order.js +1 -35
  418. package/dist/schema/call/payment.d.ts +74 -561
  419. package/dist/schema/call/payment.js +1 -37
  420. package/dist/schema/call/permission-handler.js +1 -54
  421. package/dist/schema/call/permission.d.ts +335 -2791
  422. package/dist/schema/call/permission.js +1 -105
  423. package/dist/schema/call/personal.d.ts +227 -1814
  424. package/dist/schema/call/personal.js +1 -78
  425. package/dist/schema/call/progress.d.ts +140 -843
  426. package/dist/schema/call/progress.js +1 -47
  427. package/dist/schema/call/proof.d.ts +42 -258
  428. package/dist/schema/call/proof.js +1 -33
  429. package/dist/schema/call/repository.d.ts +324 -2222
  430. package/dist/schema/call/repository.js +1 -77
  431. package/dist/schema/call/reward.d.ts +153 -1183
  432. package/dist/schema/call/reward.js +1 -30
  433. package/dist/schema/call/semantic.js +1 -1679
  434. package/dist/schema/call/service.d.ts +376 -3431
  435. package/dist/schema/call/service.js +1 -184
  436. package/dist/schema/call/treasury.d.ts +252 -2158
  437. package/dist/schema/call/treasury.js +1 -71
  438. package/dist/schema/common/index.d.ts +222 -697
  439. package/dist/schema/common/index.js +1 -407
  440. package/dist/schema/config/index.d.ts +18 -161
  441. package/dist/schema/config/index.js +1 -68
  442. package/dist/schema/employee/index.d.ts +99 -0
  443. package/dist/schema/employee/index.js +1 -0
  444. package/dist/schema/evaluation/index.d.ts +1062 -3748
  445. package/dist/schema/evaluation/index.js +1 -356
  446. package/dist/schema/index.d.ts +3 -0
  447. package/dist/schema/index.js +1 -17
  448. package/dist/schema/industry-pack/index.d.ts +132 -0
  449. package/dist/schema/industry-pack/index.js +1 -0
  450. package/dist/schema/intent-radar/index.d.ts +92 -245
  451. package/dist/schema/intent-radar/index.js +1 -89
  452. package/dist/schema/local/index.d.ts +2045 -18080
  453. package/dist/schema/local/index.js +1 -927
  454. package/dist/schema/local/wip.d.ts +61 -651
  455. package/dist/schema/local/wip.js +1 -187
  456. package/dist/schema/messenger/index.d.ts +949 -5557
  457. package/dist/schema/messenger/index.js +1 -475
  458. package/dist/schema/operations.d.ts +2969 -26518
  459. package/dist/schema/operations.js +1 -520
  460. package/dist/schema/persona/index.d.ts +469 -1820
  461. package/dist/schema/persona/index.js +1 -148
  462. package/dist/schema/project/index.d.ts +1027 -8408
  463. package/dist/schema/project/index.js +1 -2057
  464. package/dist/schema/query/index.d.ts +12041 -75261
  465. package/dist/schema/query/index.js +1 -1646
  466. package/dist/schema/schema-query/index.d.ts +35 -98
  467. package/dist/schema/schema-query/index.js +1 -104
  468. package/dist/schema/schema-version.js +1 -76
  469. package/dist/schema/task-status.d.ts +26 -132
  470. package/dist/schema/task-status.js +1 -36
  471. package/dist/schema/trust/index.d.ts +194 -1290
  472. package/dist/schema/trust/index.js +1 -314
  473. package/dist/schema/utils/guard-parser.js +1 -419
  474. package/dist/schema/utils/guard-query-utils.js +1 -46
  475. package/dist/schema/utils/node-parser.js +1 -369
  476. package/dist/schema/utils/object-type-utils.js +1 -35
  477. package/dist/schema/utils/permission-index-utils.js +1 -7
  478. package/dist/schema/utils/permission-machine-check.js +1 -121
  479. package/dist/schema/utils/skills-recommendation.d.ts +1 -0
  480. package/dist/schema/utils/skills-recommendation.js +1 -77
  481. package/dist/schema/workspace/index.d.ts +69 -0
  482. package/dist/schema/workspace/index.js +1 -0
  483. package/dist/schema-query-impl/index.js +1 -0
  484. package/dist/schemas/account_operation.output.json +3147 -1652
  485. package/dist/schemas/account_operation.schema.json +225 -218
  486. package/dist/schemas/bridge_operation.output.json +1168 -650
  487. package/dist/schemas/bridge_operation.schema.json +736 -504
  488. package/dist/schemas/config_operation.output.json +185 -179
  489. package/dist/schemas/config_operation.schema.json +21 -26
  490. package/dist/schemas/employee_operation.output.json +207 -0
  491. package/dist/schemas/employee_operation.schema.json +176 -0
  492. package/dist/schemas/evaluation_operation.output.json +2329 -557
  493. package/dist/schemas/evaluation_operation.schema.json +2939 -720
  494. package/dist/schemas/guard2file.output.json +58 -64
  495. package/dist/schemas/guard2file.schema.json +79 -81
  496. package/dist/schemas/index.json +29 -11
  497. package/dist/schemas/industry_pack_operation.output.json +594 -0
  498. package/dist/schemas/industry_pack_operation.schema.json +55 -0
  499. package/dist/schemas/intent_radar.output.json +275 -200
  500. package/dist/schemas/intent_radar.schema.json +124 -123
  501. package/dist/schemas/local_info_operation.output.json +1174 -657
  502. package/dist/schemas/local_info_operation.schema.json +119 -125
  503. package/dist/schemas/local_mark_operation.output.json +1239 -689
  504. package/dist/schemas/local_mark_operation.schema.json +91 -96
  505. package/dist/schemas/machineNode2file.output.json +63 -69
  506. package/dist/schemas/machineNode2file.schema.json +79 -81
  507. package/dist/schemas/messenger_operation.output.json +2722 -1528
  508. package/dist/schemas/messenger_operation.schema.json +1482 -1264
  509. package/dist/schemas/onchain_events.output.json +2590 -975
  510. package/dist/schemas/onchain_events.schema.json +117 -99
  511. package/dist/schemas/onchain_operations.output.json +3957 -2309
  512. package/dist/schemas/onchain_operations.schema.json +20799 -9285
  513. package/dist/schemas/onchain_operations_allocation.schema.json +172 -108
  514. package/dist/schemas/onchain_operations_arbitration.schema.json +233 -146
  515. package/dist/schemas/onchain_operations_contact.schema.json +129 -90
  516. package/dist/schemas/onchain_operations_demand.schema.json +170 -112
  517. package/dist/schemas/onchain_operations_gen_passport.schema.json +61 -646
  518. package/dist/schemas/onchain_operations_gen_proof.schema.json +40 -172
  519. package/dist/schemas/onchain_operations_guard.schema.json +3765 -294
  520. package/dist/schemas/onchain_operations_machine.schema.json +537 -164
  521. package/dist/schemas/onchain_operations_order.schema.json +126 -96
  522. package/dist/schemas/onchain_operations_payment.schema.json +82 -67
  523. package/dist/schemas/onchain_operations_permission.schema.json +331 -93
  524. package/dist/schemas/onchain_operations_personal.schema.json +636 -96
  525. package/dist/schemas/onchain_operations_progress.schema.json +125 -92
  526. package/dist/schemas/onchain_operations_proof.schema.json +76 -69
  527. package/dist/schemas/onchain_operations_repository.schema.json +636 -249
  528. package/dist/schemas/onchain_operations_reward.schema.json +218 -108
  529. package/dist/schemas/onchain_operations_service.schema.json +679 -221
  530. package/dist/schemas/onchain_operations_treasury.schema.json +401 -135
  531. package/dist/schemas/onchain_table_data.output.json +6018 -2430
  532. package/dist/schemas/onchain_table_data.schema.json +544 -430
  533. package/dist/schemas/persona_operation.output.json +1568 -265
  534. package/dist/schemas/persona_operation.schema.json +346 -202
  535. package/dist/schemas/project_operation.output.json +6957 -5147
  536. package/dist/schemas/project_operation.schema.json +1050 -1020
  537. package/dist/schemas/query_task_status.output.json +195 -99
  538. package/dist/schemas/query_task_status.schema.json +12 -18
  539. package/dist/schemas/query_toolkit.output.json +18870 -14566
  540. package/dist/schemas/query_toolkit.schema.json +614 -522
  541. package/dist/schemas/schema_query.output.json +127 -129
  542. package/dist/schemas/schema_query.schema.json +64 -69
  543. package/dist/schemas/trust_score.output.json +678 -587
  544. package/dist/schemas/trust_score.schema.json +289 -277
  545. package/dist/schemas/wip_file.output.json +116 -124
  546. package/dist/schemas/wip_file.schema.json +142 -143
  547. package/dist/schemas/workspace_operation.output.json +277 -0
  548. package/dist/schemas/workspace_operation.schema.json +45 -0
  549. package/dist/schemas/wowok_buildin_info.output.json +1693 -723
  550. package/dist/schemas/wowok_buildin_info.schema.json +576 -512
  551. package/dist/telemetry/index.js +1 -112
  552. package/dist/telemetry/redact.js +1 -23
  553. package/dist/telemetry/storage.js +1 -80
  554. package/dist/tools/handlers/bridge.d.ts +8 -1
  555. package/dist/tools/handlers/bridge.js +1 -1
  556. package/dist/tools/handlers/config.js +1 -74
  557. package/dist/tools/handlers/employee.d.ts +2 -0
  558. package/dist/tools/handlers/employee.js +1 -0
  559. package/dist/tools/handlers/evaluation.js +1 -123
  560. package/dist/tools/handlers/file-export.js +1 -90
  561. package/dist/tools/handlers/industry-pack.d.ts +2 -0
  562. package/dist/tools/handlers/industry-pack.js +1 -0
  563. package/dist/tools/handlers/intent-radar.js +1 -76
  564. package/dist/tools/handlers/local.js +1 -53
  565. package/dist/tools/handlers/messenger.js +1 -188
  566. package/dist/tools/handlers/onchain.js +1 -1180
  567. package/dist/tools/handlers/persona.js +1 -89
  568. package/dist/tools/handlers/project.js +1 -211
  569. package/dist/tools/handlers/query.js +1 -434
  570. package/dist/tools/handlers/schema-query.js +1 -176
  571. package/dist/tools/handlers/task-status.js +1 -26
  572. package/dist/tools/handlers/trust.js +1 -380
  573. package/dist/tools/handlers/wip.js +1 -90
  574. package/dist/tools/handlers/workspace.d.ts +2 -0
  575. package/dist/tools/handlers/workspace.js +1 -0
  576. package/dist/tools/index.d.ts +2 -1
  577. package/dist/tools/index.js +1 -1382
  578. package/dist/tools/retry.js +1 -85
  579. package/dist/tools/rules-hook.d.ts +1 -1
  580. package/dist/tools/rules-hook.js +1 -23
  581. package/dist/tools/shared.d.ts +1 -1
  582. package/dist/tools/shared.js +1 -130
  583. package/dist/tools/types.d.ts +2 -1
  584. package/dist/tools/types.js +1 -1
  585. package/dist/tools/upgrade-check.d.ts +19 -0
  586. package/dist/tools/upgrade-check.js +1 -0
  587. package/dist/tools/wip-deploy-assist.js +1 -306
  588. package/dist/tools/wrap.js +1 -500
  589. package/package.json +7 -6
  590. package/dist/knowledge/arbitration-trust.d.ts +0 -24
  591. package/dist/knowledge/arbitration-trust.js +0 -117
  592. package/dist/schema/call/bridge-handler.d.ts +0 -8
  593. package/dist/schema/call/bridge-handler.js +0 -265
  594. package/dist/schema/sync-layer4.d.ts +0 -21
  595. package/dist/schema/sync-layer4.js +0 -286
  596. package/dist/schema-query/index.js +0 -810
  597. /package/dist/{schema-query → schema-query-impl}/index.d.ts +0 -0
@@ -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']??{}}}};}