@wowok/agent-mcp 2.7.0 → 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 (427) 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.d.ts +5 -1
  13. package/dist/customer/risk-assessment.js +1 -397
  14. package/dist/customer/types.js +1 -13
  15. package/dist/customer/user-preferences.js +1 -460
  16. package/dist/evaluation/arbitration-game.d.ts +23 -0
  17. package/dist/evaluation/arbitration-game.js +1 -0
  18. package/dist/evaluation/builtins/demand-match.d.ts +15 -0
  19. package/dist/evaluation/builtins/demand-match.js +1 -0
  20. package/dist/evaluation/builtins/index.d.ts +3 -0
  21. package/dist/evaluation/builtins/index.js +1 -0
  22. package/dist/evaluation/builtins/service-risk.d.ts +6 -0
  23. package/dist/evaluation/builtins/service-risk.js +1 -0
  24. package/dist/evaluation/capability.d.ts +50 -0
  25. package/dist/evaluation/capability.js +1 -0
  26. package/dist/evaluation/composer.d.ts +13 -0
  27. package/dist/evaluation/composer.js +1 -0
  28. package/dist/evaluation/engine.d.ts +18 -0
  29. package/dist/evaluation/engine.js +1 -0
  30. package/dist/evaluation/extract.d.ts +30 -0
  31. package/dist/evaluation/extract.js +1 -0
  32. package/dist/evaluation/game-strategy.d.ts +27 -0
  33. package/dist/evaluation/game-strategy.js +1 -0
  34. package/dist/evaluation/gap.d.ts +2 -0
  35. package/dist/evaluation/gap.js +1 -0
  36. package/dist/evaluation/index.d.ts +12 -0
  37. package/dist/evaluation/index.js +1 -0
  38. package/dist/evaluation/node-game.d.ts +62 -0
  39. package/dist/evaluation/node-game.js +1 -0
  40. package/dist/evaluation/region.d.ts +10 -0
  41. package/dist/evaluation/region.js +1 -0
  42. package/dist/evaluation/types.d.ts +77 -0
  43. package/dist/evaluation/types.js +1 -0
  44. package/dist/evaluation/user-injection.d.ts +6 -0
  45. package/dist/evaluation/user-injection.js +1 -0
  46. package/dist/examples/education-contact-create.json +40 -0
  47. package/dist/examples/freelance-contact-create.json +40 -0
  48. package/dist/examples/insurance-machine-create.json +1 -1
  49. package/dist/examples/insurance-service-allocators.json +1 -1
  50. package/dist/examples/machine-publish.json +1 -1
  51. package/dist/examples/rental-ziroom-service-create.json +1 -1
  52. package/dist/examples/retail-adv-guard-messenger-proof-create.json +1 -1
  53. package/dist/examples/retail-myshop-service-create.json +1 -1
  54. package/dist/examples/retail-myshop-service-customer-required.json +1 -1
  55. package/dist/examples/subscription-contact-create.json +40 -0
  56. package/dist/examples/threebody-machine-create.json +1 -1
  57. package/dist/examples/travel-machine-create.json +1 -1
  58. package/dist/examples/travel-service-create.json +1 -1
  59. package/dist/experience/experience-reuse.js +1 -103
  60. package/dist/experience/index.js +1 -5
  61. package/dist/experience/intent-distill.js +1 -83
  62. package/dist/experience/realtime-feedback.js +1 -94
  63. package/dist/experience/types.js +1 -1
  64. package/dist/experience/user-profile.js +1 -171
  65. package/dist/extensions/business-modules.js +1 -287
  66. package/dist/extensions/capability-manifest.js +1 -781
  67. package/dist/extensions/constraint-registry.js +1 -198
  68. package/dist/extensions/index.js +1 -6
  69. package/dist/extensions/metric-registry.js +1 -257
  70. package/dist/extensions/mode-evaluator.js +1 -170
  71. package/dist/extensions/modes.js +1 -499
  72. package/dist/extensions/registry.js +1 -717
  73. package/dist/extensions/types.js +1 -1
  74. package/dist/harness/auto-escalation.js +1 -68
  75. package/dist/harness/checkpoint.js +1 -129
  76. package/dist/harness/index.js +1 -78
  77. package/dist/harness/plan.js +1 -276
  78. package/dist/harness/recover.js +1 -139
  79. package/dist/harness/types.js +1 -1
  80. package/dist/harness/verify.js +1 -237
  81. package/dist/index.js +1 -273
  82. package/dist/intent/enrich.d.ts +1 -0
  83. package/dist/intent/enrich.js +1 -0
  84. package/dist/intent/index.d.ts +23 -0
  85. package/dist/intent/index.js +1 -0
  86. package/dist/intent/matcher.d.ts +2 -0
  87. package/dist/intent/matcher.js +1 -0
  88. package/dist/intent/store.d.ts +19 -0
  89. package/dist/intent/store.js +1 -0
  90. package/dist/intent/types.d.ts +33 -0
  91. package/dist/intent/types.js +1 -0
  92. package/dist/knowledge/acquisition-flywheel.js +1 -192
  93. package/dist/knowledge/allocation-confirm.js +1 -534
  94. package/dist/knowledge/allocation-context.js +1 -249
  95. package/dist/knowledge/allocation-ledger.js +1 -463
  96. package/dist/knowledge/allocation-puzzle.js +1 -298
  97. package/dist/knowledge/allocation-risk.js +1 -568
  98. package/dist/knowledge/allocation-templates.js +1 -970
  99. package/dist/knowledge/allocation-translation.js +1 -585
  100. package/dist/knowledge/arb-risk.js +1 -210
  101. package/dist/knowledge/arbitration-confirm.js +1 -559
  102. package/dist/knowledge/arbitration-context.js +1 -505
  103. package/dist/knowledge/arbitration-ledger.js +1 -521
  104. package/dist/knowledge/arbitration-puzzle.js +1 -304
  105. package/dist/knowledge/arbitration-risk.js +1 -433
  106. package/dist/knowledge/arbitration-templates.js +1 -276
  107. package/dist/knowledge/arbitration-translation.js +1 -487
  108. package/dist/knowledge/arbitration-trust.js +1 -117
  109. package/dist/knowledge/audit-rules.js +1 -141
  110. package/dist/knowledge/bridge-risk.js +1 -263
  111. package/dist/knowledge/contact-risk.js +1 -200
  112. package/dist/knowledge/contact-templates.d.ts +27 -0
  113. package/dist/knowledge/contact-templates.js +1 -0
  114. package/dist/knowledge/demand-confirm.js +1 -206
  115. package/dist/knowledge/demand-matching.js +1 -132
  116. package/dist/knowledge/demand-risk.js +1 -240
  117. package/dist/knowledge/demand-translation.js +1 -354
  118. package/dist/knowledge/deployment-scanner.js +1 -823
  119. package/dist/knowledge/dynamic-pricing.js +1 -87
  120. package/dist/knowledge/examples-scanner-cli.js +1 -26
  121. package/dist/knowledge/examples-scanner.js +1 -825
  122. package/dist/knowledge/flywheel-loop.js +1 -404
  123. package/dist/knowledge/fund-layer.js +1 -973
  124. package/dist/knowledge/glossary.js +1 -211
  125. package/dist/knowledge/guard-confirm.js +1 -406
  126. package/dist/knowledge/guard-context.js +1 -287
  127. package/dist/knowledge/guard-design-patterns.js +1 -360
  128. package/dist/knowledge/guard-ledger.js +1 -260
  129. package/dist/knowledge/guard-lint.js +1 -670
  130. package/dist/knowledge/guard-migration.js +1 -228
  131. package/dist/knowledge/guard-puzzle.js +1 -805
  132. package/dist/knowledge/guard-render.js +1 -700
  133. package/dist/knowledge/guard-risk.js +1 -1879
  134. package/dist/knowledge/guard-submission-prompt.js +1 -171
  135. package/dist/knowledge/guard-templates.js +1 -1105
  136. package/dist/knowledge/guard-translation.js +1 -1119
  137. package/dist/knowledge/index.js +1 -436
  138. package/dist/knowledge/industry-evolution.js +1 -323
  139. package/dist/knowledge/industry-generalizer.js +1 -381
  140. package/dist/knowledge/industry-registry.js +1 -174
  141. package/dist/knowledge/intent-metrics.d.ts +4 -3
  142. package/dist/knowledge/intent-metrics.js +1 -566
  143. package/dist/knowledge/machine-confirm.js +1 -559
  144. package/dist/knowledge/machine-context.js +1 -833
  145. package/dist/knowledge/machine-ledger.js +1 -338
  146. package/dist/knowledge/machine-puzzle.js +1 -494
  147. package/dist/knowledge/machine-render.js +1 -565
  148. package/dist/knowledge/machine-risk.js +1 -670
  149. package/dist/knowledge/machine-templates.js +1 -1597
  150. package/dist/knowledge/machine-topology.js +1 -234
  151. package/dist/knowledge/machine-translation.js +1 -513
  152. package/dist/knowledge/mcp-schema-audit-cli.js +1 -45
  153. package/dist/knowledge/mcp-schema-audit.d.ts +1 -1
  154. package/dist/knowledge/mcp-schema-audit.js +1 -773
  155. package/dist/knowledge/onchain-constants.js +1 -35
  156. package/dist/knowledge/order-confirm.js +1 -573
  157. package/dist/knowledge/order-context.js +1 -390
  158. package/dist/knowledge/order-ledger.js +1 -341
  159. package/dist/knowledge/order-puzzle.js +1 -255
  160. package/dist/knowledge/order-risk.js +1 -653
  161. package/dist/knowledge/order-templates.js +1 -368
  162. package/dist/knowledge/order-translation.js +1 -550
  163. package/dist/knowledge/overrides-loader.js +1 -65
  164. package/dist/knowledge/passport-confirm.js +1 -531
  165. package/dist/knowledge/passport-context.js +1 -306
  166. package/dist/knowledge/passport-ledger.js +1 -282
  167. package/dist/knowledge/passport-puzzle.js +1 -333
  168. package/dist/knowledge/passport-risk.js +1 -450
  169. package/dist/knowledge/passport-templates.js +1 -568
  170. package/dist/knowledge/passport-translation.js +1 -516
  171. package/dist/knowledge/payment-risk.js +1 -249
  172. package/dist/knowledge/permission-confirm.js +1 -426
  173. package/dist/knowledge/permission-context.js +1 -224
  174. package/dist/knowledge/permission-ledger.js +1 -403
  175. package/dist/knowledge/permission-puzzle.js +1 -173
  176. package/dist/knowledge/permission-risk.js +1 -411
  177. package/dist/knowledge/permission-templates.js +1 -234
  178. package/dist/knowledge/permission-translation.js +1 -350
  179. package/dist/knowledge/personal-risk.js +1 -212
  180. package/dist/knowledge/process-model.js +1 -160
  181. package/dist/knowledge/progress-confirm.js +1 -456
  182. package/dist/knowledge/progress-context.js +1 -452
  183. package/dist/knowledge/progress-ledger.js +1 -330
  184. package/dist/knowledge/progress-puzzle.js +1 -219
  185. package/dist/knowledge/progress-risk.js +1 -461
  186. package/dist/knowledge/progress-templates.js +1 -228
  187. package/dist/knowledge/progress-translation.js +1 -405
  188. package/dist/knowledge/proof-confirm.js +1 -187
  189. package/dist/knowledge/proof-risk.js +1 -207
  190. package/dist/knowledge/proof-translation.js +1 -283
  191. package/dist/knowledge/registrar-risk.js +1 -217
  192. package/dist/knowledge/repository-confirm.js +1 -286
  193. package/dist/knowledge/repository-risk.js +1 -373
  194. package/dist/knowledge/repository-translation.js +1 -445
  195. package/dist/knowledge/reputation-rules.js +1 -99
  196. package/dist/knowledge/resource-risk.js +1 -157
  197. package/dist/knowledge/reward-confirm.js +1 -526
  198. package/dist/knowledge/reward-context.js +1 -504
  199. package/dist/knowledge/reward-ledger.js +1 -502
  200. package/dist/knowledge/reward-puzzle.js +1 -300
  201. package/dist/knowledge/reward-risk.js +1 -627
  202. package/dist/knowledge/reward-templates.js +1 -197
  203. package/dist/knowledge/reward-translation.js +1 -501
  204. package/dist/knowledge/safety-rules.js +1 -404
  205. package/dist/knowledge/scenario-modes.js +1 -321
  206. package/dist/knowledge/service-confirm.js +1 -807
  207. package/dist/knowledge/service-context.js +1 -403
  208. package/dist/knowledge/service-ledger.js +1 -609
  209. package/dist/knowledge/service-puzzle.js +1 -236
  210. package/dist/knowledge/service-risk.js +1 -615
  211. package/dist/knowledge/service-templates.js +1 -456
  212. package/dist/knowledge/service-translation.js +1 -622
  213. package/dist/knowledge/template-registry.d.ts +1 -1
  214. package/dist/knowledge/template-registry.js +1 -341
  215. package/dist/knowledge/tool-constraints.js +1 -195
  216. package/dist/knowledge/tools-reference.js +1 -155
  217. package/dist/knowledge/treasury-confirm.js +1 -512
  218. package/dist/knowledge/treasury-context.js +1 -363
  219. package/dist/knowledge/treasury-ledger.js +1 -300
  220. package/dist/knowledge/treasury-puzzle.js +1 -216
  221. package/dist/knowledge/treasury-risk.js +1 -440
  222. package/dist/knowledge/treasury-templates.js +1 -358
  223. package/dist/knowledge/treasury-translation.js +1 -498
  224. package/dist/knowledge/trust-metrics.js +1 -198
  225. package/dist/knowledge/util-risk.js +1 -135
  226. package/dist/loop-engineering/aggregate.js +1 -132
  227. package/dist/loop-engineering/context-collect.js +1 -83
  228. package/dist/loop-engineering/diagnose.js +1 -273
  229. package/dist/loop-engineering/improve.js +1 -405
  230. package/dist/loop-engineering/index.js +1 -4
  231. package/dist/loop-engineering/pipeline.js +1 -56
  232. package/dist/mode-market/index.js +1 -3
  233. package/dist/mode-market/registry.js +1 -124
  234. package/dist/mode-market/review.js +1 -214
  235. package/dist/mode-market/submission.js +1 -85
  236. package/dist/participation/collaborator-interest.d.ts +23 -0
  237. package/dist/participation/collaborator-interest.js +1 -0
  238. package/dist/participation/customer-interest.d.ts +25 -0
  239. package/dist/participation/customer-interest.js +1 -0
  240. package/dist/participation/merchant-interest.js +1 -100
  241. package/dist/participation/radar-core.d.ts +13 -3
  242. package/dist/participation/radar-core.js +1 -269
  243. package/dist/participation/supplier-interest.d.ts +25 -0
  244. package/dist/participation/supplier-interest.js +1 -0
  245. package/dist/persona/analyzer.d.ts +16 -0
  246. package/dist/persona/analyzer.js +1 -0
  247. package/dist/persona/bridge.d.ts +5 -0
  248. package/dist/persona/bridge.js +1 -0
  249. package/dist/persona/defaults.d.ts +4 -0
  250. package/dist/persona/defaults.js +1 -0
  251. package/dist/persona/experience-bridge.d.ts +3 -0
  252. package/dist/persona/experience-bridge.js +1 -0
  253. package/dist/persona/index.d.ts +18 -0
  254. package/dist/persona/index.js +1 -0
  255. package/dist/persona/model.d.ts +7 -0
  256. package/dist/persona/model.js +1 -0
  257. package/dist/persona/store.d.ts +19 -0
  258. package/dist/persona/store.js +1 -0
  259. package/dist/persona/types.d.ts +45 -0
  260. package/dist/persona/types.js +1 -0
  261. package/dist/project/business-puzzle.js +1 -383
  262. package/dist/project/context-assembly.js +1 -254
  263. package/dist/project/deployment-bridge.js +1 -120
  264. package/dist/project/deployment-doc.js +1 -1126
  265. package/dist/project/edit-planner.js +1 -1342
  266. package/dist/project/evaluation.js +1 -2011
  267. package/dist/project/game-theory.js +1 -177
  268. package/dist/project/graph-builder.js +1 -656
  269. package/dist/project/graph.js +1 -340
  270. package/dist/project/handlers.d.ts +5 -0
  271. package/dist/project/handlers.js +1 -1762
  272. package/dist/project/index.d.ts +1 -0
  273. package/dist/project/index.js +1 -301
  274. package/dist/project/intent-analyzer.js +1 -149
  275. package/dist/project/machine-nodes.js +1 -36
  276. package/dist/project/merchant-guide.js +1 -264
  277. package/dist/project/migration.js +1 -125
  278. package/dist/project/mode-actions.js +1 -309
  279. package/dist/project/namespace.js +1 -206
  280. package/dist/project/participation-radar.js +1 -428
  281. package/dist/project/pipeline-actions.js +1 -109
  282. package/dist/project/project-store.js +1 -422
  283. package/dist/project/query.js +1 -153
  284. package/dist/project/reverse-mapping.d.ts +34 -0
  285. package/dist/project/reverse-mapping.js +1 -0
  286. package/dist/project/risk-aggregator.js +1 -295
  287. package/dist/project/rollback-policy.js +1 -290
  288. package/dist/project/semantic-assembler.js +1 -345
  289. package/dist/project/semantic-graph.js +1 -245
  290. package/dist/project/stage-gate.js +1 -369
  291. package/dist/project/substep-trace.js +1 -332
  292. package/dist/project/task-tracker.js +1 -78
  293. package/dist/role/derivation.d.ts +18 -0
  294. package/dist/role/derivation.js +1 -0
  295. package/dist/role/index.d.ts +5 -0
  296. package/dist/role/index.js +1 -0
  297. package/dist/role/model.d.ts +8 -0
  298. package/dist/role/model.js +1 -0
  299. package/dist/role/resolution.d.ts +11 -0
  300. package/dist/role/resolution.js +1 -0
  301. package/dist/role/types.d.ts +11 -0
  302. package/dist/role/types.js +1 -0
  303. package/dist/rules.d.ts +2 -0
  304. package/dist/rules.js +1 -9
  305. package/dist/safety/confirm-gate.js +1 -88
  306. package/dist/safety/index.js +1 -3
  307. package/dist/safety/preview.js +1 -52
  308. package/dist/schema/call/allocation.js +1 -34
  309. package/dist/schema/call/arbitration.js +1 -113
  310. package/dist/schema/call/base.d.ts +15 -15
  311. package/dist/schema/call/base.js +1 -370
  312. package/dist/schema/call/bridge-handler.js +1 -265
  313. package/dist/schema/call/bridge.d.ts +7 -7
  314. package/dist/schema/call/bridge.js +1 -458
  315. package/dist/schema/call/contact.js +1 -37
  316. package/dist/schema/call/demand.js +1 -47
  317. package/dist/schema/call/guard.js +1 -161
  318. package/dist/schema/call/handler.js +1 -322
  319. package/dist/schema/call/index.js +1 -20
  320. package/dist/schema/call/machine.js +1 -193
  321. package/dist/schema/call/order.js +1 -35
  322. package/dist/schema/call/payment.js +1 -37
  323. package/dist/schema/call/permission-handler.js +1 -54
  324. package/dist/schema/call/permission.js +1 -105
  325. package/dist/schema/call/personal.js +1 -78
  326. package/dist/schema/call/progress.js +1 -47
  327. package/dist/schema/call/proof.js +1 -33
  328. package/dist/schema/call/repository.js +1 -77
  329. package/dist/schema/call/reward.js +1 -30
  330. package/dist/schema/call/semantic.js +1 -1657
  331. package/dist/schema/call/service.js +1 -178
  332. package/dist/schema/call/treasury.js +1 -71
  333. package/dist/schema/common/index.js +1 -407
  334. package/dist/schema/config/index.js +1 -68
  335. package/dist/schema/evaluation/index.d.ts +4436 -0
  336. package/dist/schema/evaluation/index.js +1 -0
  337. package/dist/schema/index.d.ts +4 -0
  338. package/dist/schema/index.js +1 -13
  339. package/dist/schema/intent-radar/index.d.ts +284 -0
  340. package/dist/schema/intent-radar/index.js +1 -0
  341. package/dist/schema/local/index.d.ts +21 -21
  342. package/dist/schema/local/index.js +1 -927
  343. package/dist/schema/local/wip.js +1 -187
  344. package/dist/schema/messenger/index.d.ts +7 -7
  345. package/dist/schema/messenger/index.js +1 -475
  346. package/dist/schema/operations.d.ts +7 -7
  347. package/dist/schema/operations.js +1 -520
  348. package/dist/schema/persona/index.d.ts +1985 -0
  349. package/dist/schema/persona/index.js +1 -0
  350. package/dist/schema/project/index.d.ts +96 -50
  351. package/dist/schema/project/index.js +1 -2057
  352. package/dist/schema/query/index.d.ts +423 -7
  353. package/dist/schema/query/index.js +1 -1640
  354. package/dist/schema/schema-query/index.js +1 -104
  355. package/dist/schema/schema-version.js +1 -76
  356. package/dist/schema/sync-layer4.d.ts +1 -1
  357. package/dist/schema/sync-layer4.js +1 -282
  358. package/dist/schema/task-status.d.ts +168 -0
  359. package/dist/schema/task-status.js +1 -0
  360. package/dist/schema/trust/index.js +1 -314
  361. package/dist/schema/utils/guard-parser.js +1 -419
  362. package/dist/schema/utils/guard-query-utils.js +1 -46
  363. package/dist/schema/utils/node-parser.js +1 -369
  364. package/dist/schema/utils/object-type-utils.js +1 -35
  365. package/dist/schema/utils/permission-index-utils.js +1 -7
  366. package/dist/schema/utils/permission-machine-check.js +1 -121
  367. package/dist/schema/utils/skills-recommendation.js +1 -77
  368. package/dist/schema-query/index.js +1 -810
  369. package/dist/schemas/account_operation.output.json +5 -2
  370. package/dist/schemas/bridge_operation.output.json +5 -2
  371. package/dist/schemas/evaluation_operation.output.json +782 -0
  372. package/dist/schemas/evaluation_operation.schema.json +990 -0
  373. package/dist/schemas/index.json +25 -1
  374. package/dist/schemas/intent_radar.output.json +232 -0
  375. package/dist/schemas/intent_radar.schema.json +138 -0
  376. package/dist/schemas/local_info_operation.output.json +5 -2
  377. package/dist/schemas/local_mark_operation.output.json +5 -2
  378. package/dist/schemas/messenger_operation.output.json +5 -2
  379. package/dist/schemas/onchain_events.output.json +5 -2
  380. package/dist/schemas/onchain_operations.output.json +5 -2
  381. package/dist/schemas/onchain_operations.schema.json +6 -6
  382. package/dist/schemas/onchain_operations_allocation.schema.json +1 -1
  383. package/dist/schemas/onchain_operations_machine.schema.json +2 -2
  384. package/dist/schemas/onchain_operations_service.schema.json +3 -3
  385. package/dist/schemas/onchain_table_data.output.json +6 -3
  386. package/dist/schemas/persona_operation.output.json +392 -0
  387. package/dist/schemas/persona_operation.schema.json +250 -0
  388. package/dist/schemas/project_operation.output.json +28 -8
  389. package/dist/schemas/query_task_status.output.json +115 -0
  390. package/dist/schemas/query_task_status.schema.json +24 -0
  391. package/dist/schemas/query_toolkit.output.json +9 -6
  392. package/dist/schemas/trust_score.schema.json +1 -1
  393. package/dist/schemas/wowok_buildin_info.output.json +132 -0
  394. package/dist/schemas/wowok_buildin_info.schema.json +14 -0
  395. package/dist/telemetry/index.js +1 -112
  396. package/dist/telemetry/redact.js +1 -23
  397. package/dist/telemetry/storage.js +1 -80
  398. package/dist/tools/handlers/bridge.js +1 -1
  399. package/dist/tools/handlers/config.js +1 -74
  400. package/dist/tools/handlers/evaluation.d.ts +2 -0
  401. package/dist/tools/handlers/evaluation.js +1 -0
  402. package/dist/tools/handlers/file-export.js +1 -90
  403. package/dist/tools/handlers/intent-radar.d.ts +2 -0
  404. package/dist/tools/handlers/intent-radar.js +1 -0
  405. package/dist/tools/handlers/local.js +1 -53
  406. package/dist/tools/handlers/messenger.js +1 -188
  407. package/dist/tools/handlers/onchain.js +1 -1082
  408. package/dist/tools/handlers/persona.d.ts +4 -0
  409. package/dist/tools/handlers/persona.js +1 -0
  410. package/dist/tools/handlers/project.js +1 -211
  411. package/dist/tools/handlers/query.js +1 -434
  412. package/dist/tools/handlers/schema-query.js +1 -176
  413. package/dist/tools/handlers/task-status.d.ts +0 -168
  414. package/dist/tools/handlers/task-status.js +1 -55
  415. package/dist/tools/handlers/trust.js +1 -380
  416. package/dist/tools/handlers/wip.js +1 -90
  417. package/dist/tools/index.js +1 -1306
  418. package/dist/tools/retry.js +1 -85
  419. package/dist/tools/rules-hook.js +1 -23
  420. package/dist/tools/shared.js +1 -130
  421. package/dist/tools/types.js +1 -1
  422. package/dist/tools/upgrade-check.d.ts +19 -0
  423. package/dist/tools/upgrade-check.js +1 -0
  424. package/dist/tools/wip-deploy-assist.d.ts +1 -1
  425. package/dist/tools/wip-deploy-assist.js +1 -278
  426. package/dist/tools/wrap.js +1 -500
  427. package/package.json +5 -3
@@ -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};}
@@ -0,0 +1,16 @@
1
+ import type { Industry, PersonaRole } from "./types.js";
2
+ export interface PersonaAnalysisSuggestion {
3
+ field: string;
4
+ value: unknown;
5
+ reason: string;
6
+ }
7
+ export interface PersonaAnalysis {
8
+ role?: PersonaRole;
9
+ industries: Industry[];
10
+ preferences: Record<string, unknown>;
11
+ requirements: string[];
12
+ rules: string[];
13
+ suggestions: PersonaAnalysisSuggestion[];
14
+ confidence: number;
15
+ }
16
+ export declare function analyzePersonaContext(context: string): PersonaAnalysis;
@@ -0,0 +1 @@
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;}
@@ -0,0 +1,5 @@
1
+ import type { UserInjection } from "../evaluation/types.js";
2
+ import type { EffectivePersona } from "./types.js";
3
+ export declare function personaToInjection(effective: EffectivePersona): UserInjection;
4
+ export declare function personaToContextText(effective: EffectivePersona): string;
5
+ export declare function mergeInjections(base?: UserInjection | null, override?: UserInjection | null): UserInjection | undefined;
@@ -0,0 +1 @@
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']??{}}}};}
@@ -0,0 +1,4 @@
1
+ import { type Industry, type Persona, type PersonaRole } from "./types.js";
2
+ export declare const GENERIC_PERSONA: Persona;
3
+ export declare function getIndustryDefault(role: PersonaRole, industry: Industry): Persona;
4
+ export declare function listIndustryDefaults(): Persona[];
@@ -0,0 +1 @@
1
+ import{getDefaultPreferences}from'../customer/user-preferences.js';import{PERSONA_VERSION}from'./types.js';function safePrefs(a){const {budget_range:b,...c}=a;return c;}function industryPrefs(a){return safePrefs(getDefaultPreferences(a));}const SPECS=[{'role':'merchant','industry':'freelance','strategy':['Deliver\x20in\x20milestones\x20and\x20release\x20per\x20milestone\x20(avoid\x20all-or-nothing\x20non-acceptance).','Record\x20WIP\x20hash\x20at\x20each\x20key\x20node\x20as\x20evidence.','Use\x20an\x20accept_guard\x20time\x20gate\x20so\x20non-accepting\x20clients\x20auto-release\x20after\x20the\x20deadline.'],'requirements':['must\x20have\x20arbitration','must\x20have\x20a\x20compensation\x20fund','forbid\x20full\x20upfront\x20payment\x20before\x20any\x20delivery']},{'role':'customer','industry':'freelance','strategy':['Pay\x20per\x20milestone,\x20verify\x20each\x20before\x20releasing\x20the\x20next.','Verify\x20WIP\x20hash\x20before\x20accepting\x20a\x20delivery.','Open\x20arbitration\x20if\x20the\x20provider\x20is\x20unresponsive.'],'requirements':['must\x20have\x20arbitration','must\x20have\x20a\x20compensation\x20fund','forbid\x20direct\x20payment\x20without\x20escrow']},{'role':'merchant','industry':'rental','strategy':['Record\x20pre/post\x20rental\x20WIP\x20hashes\x20as\x20the\x20damage-claim\x20baseline.','Hold\x20the\x20deposit\x20in\x20a\x20graded\x20allocator\x20(normal\x20return\x20auto-releases).','Keep\x20an\x20evidence\x20chain\x20for\x20any\x20damage\x20claim.'],'requirements':['must\x20have\x20arbitration','damage\x20claims\x20require\x20pre-rental\x20baseline\x20evidence']},{'role':'customer','industry':'rental','strategy':['Record\x20condition\x20evidence\x20(WIP\x20hash)\x20before\x20renting.','Confirm\x20the\x20return\x20only\x20after\x20verifying\x20no\x20damage.','Open\x20arbitration\x20against\x20unfair\x20damage\x20claims.'],'requirements':['must\x20have\x20arbitration','deposit\x20must\x20be\x20refundable\x20(a\x20return\x20path\x20must\x20exist)']},{'role':'merchant','industry':'education','strategy':['Release\x20tuition\x20per\x20lesson\x20(1/N)\x20to\x20structurally\x20prevent\x20run-away\x20disputes.','Keep\x20attendance/completion\x20evidence.','Declare\x20the\x20refund\x20policy\x20up\x20front.'],'requirements':['must\x20have\x20arbitration','tuition\x20must\x20be\x20escrowed\x20(not\x20directly\x20received)']},{'role':'customer','industry':'education','strategy':['Pay\x20per\x20lesson,\x20never\x20full\x20upfront.','Confirm\x20completed\x20lessons\x20before\x20paying.','Request\x20proportional\x20refund\x20if\x20the\x20course\x20is\x20cancelled.'],'requirements':['must\x20have\x20arbitration','forbid\x20one-time\x20full\x20upfront\x20payment']},{'role':'merchant','industry':'travel','strategy':['Model\x20multi-leg\x20trips\x20as\x20a\x20multi-leg\x20machine\x20with\x20a\x20transparent\x20fund\x20waterfall.','Declare\x20the\x20cancellation\x20policy\x20up\x20front.','Separate\x20refundable\x20vs\x20non-refundable\x20legs.'],'requirements':['must\x20have\x20arbitration','funds\x20must\x20be\x20escrowed\x20(conditionally\x20released)']},{'role':'customer','industry':'travel','strategy':['Confirm\x20the\x20cancellation/refund\x20policy\x20before\x20booking.','Watch\x20cross-leg\x20responsibility\x20in\x20multi-leg\x20trips.','Pursue\x20the\x20non-refundable\x20downstream\x20on\x20flight\x20cancellation.'],'requirements':['must\x20have\x20arbitration','cancellation\x20must\x20be\x20refundable\x20(a\x20refund\x20path\x20must\x20exist)']},{'role':'merchant','industry':'subscription','strategy':['Charge\x20each\x20period\x20via\x20charge_guard_signer\x20(explicit\x20user\x20signature).','Keep\x20100%\x20of\x20revenue\x20(no\x20platform\x20cut).','Declare\x20pauses/cancellation\x20explicitly.'],'requirements':['forbid\x20auto-renewal\x20traps\x20(every\x20period\x20must\x20be\x20explicitly\x20signed)']},{'role':'customer','industry':'subscription','strategy':['Confirm\x20authorization\x20before\x20each\x20charge.','Cancel\x20anytime\x20without\x20friction.','Stop\x20charging\x20when\x20the\x20creator\x20pauses.'],'requirements':['forbid\x20auto-renewal\x20(every\x20period\x20must\x20be\x20explicitly\x20signed)','cancellation\x20must\x20be\x20frictionless']},{'role':'merchant','industry':'retail','strategy':['Release\x20funds\x20on\x20confirmed\x20receipt\x20(escrow).','Keep\x20an\x20evidence\x20chain\x20for\x20authenticity\x20disputes.','Declare\x20the\x20return\x20policy\x20up\x20front.'],'requirements':['must\x20have\x20arbitration','funds\x20must\x20be\x20escrowed\x20(released\x20on\x20confirmed\x20receipt)']},{'role':'customer','industry':'retail','strategy':['Verify\x20authenticity\x20before\x20confirming\x20receipt.','Never\x20confirm\x20receipt\x20before\x20the\x20goods\x20arrive.','Open\x20arbitration\x20for\x20counterfeit\x20/\x20not-received.'],'requirements':['must\x20have\x20arbitration','not-received\x20must\x20be\x20refundable']}];function buildDefault(a){const b=a['industry']?[a['industry']]:[],c={'identity':{'self_description':a['role']+'\x20in\x20'+(a['industry']??'any')+'\x20industry'},'preferences':a['industry']?industryPrefs(a['industry']):{}},d={'strategy':a['strategy'],'requirements':a['requirements']};return{'version':PERSONA_VERSION,'scope':'system','role':a['role'],'industries':b,'long_term':c,'current':d,'updated_at':0x0};}const GENERIC_ROLE_SPECS=[{'role':'arbitrator','strategy':['Confirm\x20cases\x20promptly\x20to\x20keep\x20the\x20dispute\x20pipeline\x20moving\x20(efficiency\x20+\x20fee\x20throughput).','Verify\x20all\x20evidence\x20(WTS)\x20before\x20ruling\x20—\x20unverified\x20evidence\x20is\x20not\x20evidence.','Write\x20reasoned,\x20professional\x20feedback\x20—\x20it\x20is\x20permanently\x20public\x20on-chain\x20(reputation).','Reset\x20unclear\x20cases\x20back\x20with\x20clear\x20feedback\x20rather\x20than\x20guessing.'],'requirements':['must\x20verify\x20evidence\x20(WTS)\x20before\x20ruling','forbid\x20ruling\x20without\x20verified\x20evidence']},{'role':'supplier','strategy':['Deliver\x20the\x20sub-order\x20and\x20retain\x20per-tier\x20sub-delivery\x20proof.','Settle\x20independently\x20per\x20verified\x20tier\x20(not\x20bundled\x20with\x20the\x20main\x20order).','Keep\x20an\x20evidence\x20chain\x20for\x20any\x20sub-delivery\x20dispute.'],'requirements':['sub-delivery\x20must\x20be\x20provable\x20(per-tier\x20release\x20guard)','must\x20have\x20independent\x20allocation\x20for\x20sub-order\x20settlement']},{'role':'collaborator','strategy':['Advance\x20only\x20the\x20forwards\x20within\x20your\x20permission\x20scope.','Advance\x20promptly\x20to\x20keep\x20the\x20workflow\x20moving\x20(avoid\x20stall\x20penalties).','Avoid\x20interfering\x20outside\x20your\x20permission\x20scope\x20(creates\x20responsibility\x20without\x20authority).'],'requirements':['only\x20operate\x20authorized\x20forwards\x20(permission\x20index\x20/\x20named\x20operator)','forbid\x20operating\x20outside\x20your\x20permission\x20scope']},{'role':'prospect','strategy':['Verify\x20fund\x20safety\x20(escrow\x20+\x20refund\x20path)\x20before\x20ordering.','Verify\x20delivery\x20trust\x20(WIP\x20hash,\x20machine\x20workflow)\x20before\x20ordering.','Check\x20arbitration\x20availability\x20for\x20recourse\x20before\x20committing.'],'requirements':['must\x20have\x20arbitration','must\x20have\x20a\x20refund\x20path']}],DEFAULTS=[...SPECS,...GENERIC_ROLE_SPECS]['map'](buildDefault);export const GENERIC_PERSONA={'version':PERSONA_VERSION,'scope':'system','role':'customer','industries':[],'long_term':{'identity':{'self_description':'generic\x20WoWok\x20user'}},'current':{},'updated_at':0x0};export function getIndustryDefault(a,b){const c=DEFAULTS['find'](e=>e['role']===a&&e['industries']['length']===0x0);if(c)return{...c};const d=DEFAULTS['find'](e=>e['role']===a&&e['industries'][0x0]===b);return d?{...d}:{...GENERIC_PERSONA,'role':a};}export function listIndustryDefaults(){return DEFAULTS['map'](a=>({...a}));}
@@ -0,0 +1,3 @@
1
+ import type { UserProfile } from "../experience/types.js";
2
+ import type { PersonaLayer } from "./types.js";
3
+ export declare function profileToCurrentLayer(profile: UserProfile): PersonaLayer;
@@ -0,0 +1 @@
1
+ export function profileToCurrentLayer(a){if(a['total_operations']<=0x0)return{};const b={},c={};if(a['risk_appetite']&&a['risk_appetite']!=='balanced')c['risk_appetite']=a['risk_appetite'];if(a['expertise_tier']&&a['expertise_tier']!=='novice')c['expertise_tier']=a['expertise_tier'];if(a['preferred_confirmation']&&a['preferred_confirmation']!=='standard')c['preferred_confirmation']=a['preferred_confirmation'];if(a['preferred_industries']?.['length'])c['preferred_industries']=a['preferred_industries'];if(typeof a['success_rate']==='number')c['success_rate']=a['success_rate'];if(Object['keys'](c)['length'])b['preferences']=c;return a['frequent_pitfalls']?.['length']&&(b['rules']=a['frequent_pitfalls']['map'](d=>'avoid\x20pitfall:\x20'+d)),b;}
@@ -0,0 +1,18 @@
1
+ import { type PersonaAnalysis } from "./analyzer.js";
2
+ import type { EffectivePersona, Industry, Persona, PersonaLayer, PersonaRole, PersonaScope } from "./types.js";
3
+ import type { UserProfile } from "../experience/types.js";
4
+ export { GENERIC_PERSONA, getIndustryDefault, listIndustryDefaults } from "./defaults.js";
5
+ export { SqlitePersonaStore, getPersonaStore, setPersonaStore } from "./store.js";
6
+ export { countPersonaLines, emptyPersona, mergeLayers, mutateLayer, resolveEffective, validatePersona } from "./model.js";
7
+ export { personaToContextText, personaToInjection, mergeInjections } from "./bridge.js";
8
+ export { analyzePersonaContext } from "./analyzer.js";
9
+ export { profileToCurrentLayer } from "./experience-bridge.js";
10
+ export type { EffectivePersona, Industry, Persona, PersonaIdentity, PersonaLayer, PersonaMutationMode, PersonaRole, PersonaScope, } from "./types.js";
11
+ export declare function getEffectivePersona(account?: string, industry?: Industry, role?: PersonaRole): Promise<EffectivePersona>;
12
+ export declare function analysisToLayerDelta(analysis: PersonaAnalysis): PersonaLayer;
13
+ export declare function applyAnalysisToCurrent(scope: PersonaScope, account: string | undefined, analysis: PersonaAnalysis, mode?: "merge" | "replace", role?: PersonaRole, industries?: Industry[]): Promise<Persona>;
14
+ export declare function syncExperienceToCurrent(account?: string, profile?: UserProfile): Promise<{
15
+ persona: Persona;
16
+ applied: PersonaLayer;
17
+ effective: EffectivePersona;
18
+ }>;
@@ -0,0 +1 @@
1
+ import{GENERIC_PERSONA,getIndustryDefault}from'./defaults.js';import{getPersonaStore}from'./store.js';import{emptyPersona,mutateLayer,resolveEffective,validatePersona}from'./model.js';import{profileToCurrentLayer}from'./experience-bridge.js';import{getProfile}from'../experience/index.js';export{GENERIC_PERSONA,getIndustryDefault,listIndustryDefaults}from'./defaults.js';export{SqlitePersonaStore,getPersonaStore,setPersonaStore}from'./store.js';export{countPersonaLines,emptyPersona,mergeLayers,mutateLayer,resolveEffective,validatePersona}from'./model.js';export{personaToContextText,personaToInjection,mergeInjections}from'./bridge.js';export{analyzePersonaContext}from'./analyzer.js';export{profileToCurrentLayer}from'./experience-bridge.js';export async function getEffectivePersona(a,b,c){const d=getPersonaStore(),e=await d['get']('system'),f=a?await d['get']('account',a):null,g=b?getIndustryDefault(c??'customer',b):{...GENERIC_PERSONA,'role':c??'customer'};return resolveEffective(e,f,g);}export function analysisToLayerDelta(a){const b={};a['preferences']&&Object['keys'](a['preferences'])['length']&&(b['preferences']=a['preferences']);if(a['requirements']['length'])b['requirements']=a['requirements'];if(a['rules']['length'])b['rules']=a['rules'];return b;}export async function applyAnalysisToCurrent(a,b,c,d='merge',e,f){const g=getPersonaStore(),h=a==='account'&&b?await g['get']('account',b):await g['get']('system'),i=e??c['role']??h?.['role']??'customer',j=f??c['industries'],k=h??emptyPersona(a,b,i,j),l=Array['from'](new Set([...k['industries'],...j??[]])),m=analysisToLayerDelta(c),n=mutateLayer(k['current'],m,d),o={...k,'role':i,'industries':l,'current':n,'updated_at':Date['now']()},p=validatePersona(o);if(p['length']>0x0)throw new Error('persona\x20invalid\x20after\x20apply:\x20'+p['join'](';\x20'));return await g['put'](o),o;}export async function syncExperienceToCurrent(a,b){const c=getPersonaStore(),d=a?'account':'system',e=a?await c['get']('account',a):await c['get']('system'),f=e??emptyPersona(d,a,'customer',[]),g=profileToCurrentLayer(b??getProfile()),h=mutateLayer(f['current'],g,'merge'),i={...f,'current':h,'updated_at':Date['now']()},j=validatePersona(i);if(j['length']>0x0)throw new Error('persona\x20invalid\x20after\x20sync:\x20'+j['join'](';\x20'));return await c['put'](i),{'persona':i,'applied':g,'effective':await getEffectivePersona(a)};}
@@ -0,0 +1,7 @@
1
+ import { type EffectivePersona, type Persona, type PersonaLayer, type PersonaMutationMode } from "./types.js";
2
+ export declare function mergeLayers(layers: PersonaLayer[]): PersonaLayer;
3
+ export declare function mutateLayer(layer: PersonaLayer, delta: PersonaLayer, mode: PersonaMutationMode): PersonaLayer;
4
+ export declare function resolveEffective(system?: Persona | null, account?: Persona | null, base?: Persona | null): EffectivePersona;
5
+ export declare function countPersonaLines(persona: Persona): number;
6
+ export declare function validatePersona(persona: Persona): string[];
7
+ export declare function emptyPersona(scope: "system" | "account", account: string | undefined, role: Persona["role"], industries: Persona["industries"]): Persona;
@@ -0,0 +1 @@
1
+ import{PERSONA_MAX_LINES,PERSONA_ROLES,PERSONA_VERSION}from'./types.js';function dedupe(a){return Array['from'](new Set(a['filter'](b=>typeof b==='string'&&b['length']>0x0)));}export function mergeLayers(a){const b={};for(const c of a){if(!c)continue;c['identity']&&(b['identity']={...b['identity'],...c['identity']},c['identity']['languages']&&(b['identity']['languages']=dedupe([...b['identity']['languages']??[],...c['identity']['languages']]))),c['preferences']&&(b['preferences']={...b['preferences'],...c['preferences']}),c['strategy']&&(b['strategy']=dedupe([...b['strategy']??[],...c['strategy']])),c['rules']&&(b['rules']=dedupe([...b['rules']??[],...c['rules']])),c['requirements']&&(b['requirements']=dedupe([...b['requirements']??[],...c['requirements']])),c['spec']&&(b['spec']=[b['spec'],c['spec']]['filter'](Boolean)['join']('\x0a\x0a'));}return b;}export function mutateLayer(a,b,c){if(c==='replace')return{...b};return mergeLayers([a,b]);}export function resolveEffective(a,b,c){const d=[],e=[];c&&(d['push'](c['long_term']),e['push']({'scope':c['scope'],'part':'long_term'}),d['push'](c['current']),e['push']({'scope':c['scope'],'part':'current'}));a&&(d['push'](a['long_term']),e['push']({'scope':'system','part':'long_term'}),d['push'](a['current']),e['push']({'scope':'system','part':'current'}));b&&(d['push'](b['long_term']),e['push']({'scope':'account','account':b['account'],'part':'long_term'}),d['push'](b['current']),e['push']({'scope':'account','account':b['account'],'part':'current'}));const f=b??a??c;return{'scope':b?'account':a?'system':c?'system':'system','account':b?.['account']??a?.['account'],'role':f?.['role']??'customer','industries':f?.['industries']??[],'layer':mergeLayers(d),'sources':e};}export function countPersonaLines(a){return JSON['stringify'](a,null,0x2)['split']('\x0a')['length'];}export function validatePersona(a){const b=[];a['version']!==PERSONA_VERSION&&b['push']('version\x20must\x20be\x20'+PERSONA_VERSION);a['scope']==='account'&&!a['account']&&b['push']('account\x20is\x20required\x20when\x20scope=account');a['scope']!=='account'&&a['account']&&b['push']('account\x20should\x20only\x20be\x20set\x20when\x20scope=account');(!a['role']||!PERSONA_ROLES['includes'](a['role']))&&b['push']('role\x20must\x20be\x20a\x20persona\x20role\x20(merchant|customer|prospect|supplier|collaborator|arbitrator)');!Array['isArray'](a['industries'])&&b['push']('industries\x20must\x20be\x20an\x20array');const c=countPersonaLines(a);return c>PERSONA_MAX_LINES&&b['push']('persona\x20is\x20'+c+'\x20lines\x20(max\x20'+PERSONA_MAX_LINES+')'),b;}export function emptyPersona(a,b,c,d){return{'version':PERSONA_VERSION,'scope':a,'account':b,'role':c,'industries':d,'long_term':{},'current':{},'updated_at':Date['now']()};}
@@ -0,0 +1,19 @@
1
+ import { SQLiteStorage } from "@wowok/wowok";
2
+ import type { Persona, PersonaScope } from "./types.js";
3
+ export interface PersonaStore {
4
+ get(scope: PersonaScope, account?: string): Promise<Persona | null>;
5
+ list(): Promise<Persona[]>;
6
+ put(persona: Persona): Promise<void>;
7
+ delete(scope: PersonaScope, account?: string): Promise<boolean>;
8
+ }
9
+ export declare class SqlitePersonaStore implements PersonaStore {
10
+ private readonly kv;
11
+ constructor(kv?: SQLiteStorage);
12
+ private key;
13
+ get(scope: PersonaScope, account?: string): Promise<Persona | null>;
14
+ list(): Promise<Persona[]>;
15
+ put(persona: Persona): Promise<void>;
16
+ delete(scope: PersonaScope, account?: string): Promise<boolean>;
17
+ }
18
+ export declare function getPersonaStore(): PersonaStore;
19
+ export declare function setPersonaStore(store: PersonaStore): void;
@@ -0,0 +1 @@
1
+ import{SQLiteStorage}from'@wowok/wowok';function safeParse(a){try{return JSON['parse'](a);}catch{return null;}}const SQLITE_KEY_PREFIX='persona:',SQLITE_SYSTEM_KEY='persona:system',SQLITE_ACCOUNT_PREFIX='persona:account:';export class SqlitePersonaStore{['kv'];constructor(a){this['kv']=a??new SQLiteStorage();}['key'](a,b){return a==='account'&&b?''+SQLITE_ACCOUNT_PREFIX+b:SQLITE_SYSTEM_KEY;}async['get'](a,b){const c=await this['kv']['get'](this['key'](a,b));return c?safeParse(c):null;}async['list'](){const a=await this['kv']['list'](SQLITE_KEY_PREFIX),b=[];for(const {value:d}of a){const e=safeParse(d);if(e)b['push'](e);}const c=await this['kv']['get'](SQLITE_SYSTEM_KEY);if(c){const f=safeParse(c);if(f)b['push'](f);}return b;}async['put'](a){await this['kv']['put'](this['key'](a['scope'],a['account']),JSON['stringify'](a));}async['delete'](a,b){const c=this['key'](a,b),d=await this['kv']['get'](c)!==undefined;if(d)await this['kv']['del'](c);return d;}}let _store=null;export function getPersonaStore(){if(!_store)_store=new SqlitePersonaStore();return _store;}export function setPersonaStore(a){_store=a;}
@@ -0,0 +1,45 @@
1
+ import { type CommercialRole } from "../role/types.js";
2
+ export type PersonaScope = "system" | "account";
3
+ export type PersonaRole = Exclude<CommercialRole, "system">;
4
+ export declare const PERSONA_ROLES: readonly PersonaRole[];
5
+ export type Industry = "freelance" | "rental" | "education" | "travel" | "subscription" | "retail";
6
+ export declare const SUPPORTED_INDUSTRIES: Industry[];
7
+ export interface PersonaIdentity {
8
+ region?: string;
9
+ languages?: string[];
10
+ self_description?: string;
11
+ }
12
+ export interface PersonaLayer {
13
+ identity?: PersonaIdentity;
14
+ preferences?: Record<string, unknown>;
15
+ strategy?: string[];
16
+ rules?: string[];
17
+ requirements?: string[];
18
+ spec?: string;
19
+ }
20
+ export type PersonaMutationMode = "merge" | "replace";
21
+ export interface Persona {
22
+ version: number;
23
+ scope: PersonaScope;
24
+ account?: string;
25
+ role: PersonaRole;
26
+ industries: Industry[];
27
+ long_term: PersonaLayer;
28
+ current: PersonaLayer;
29
+ updated_at: number;
30
+ }
31
+ export interface PersonaSource {
32
+ scope: PersonaScope;
33
+ account?: string;
34
+ part: "long_term" | "current";
35
+ }
36
+ export interface EffectivePersona {
37
+ scope: PersonaScope;
38
+ account?: string;
39
+ role: PersonaRole;
40
+ industries: Industry[];
41
+ layer: PersonaLayer;
42
+ sources: PersonaSource[];
43
+ }
44
+ export declare const PERSONA_VERSION = 1;
45
+ export declare const PERSONA_MAX_LINES = 300;
@@ -0,0 +1 @@
1
+ import{COMMERCIAL_ROLES}from'../role/types.js';export const PERSONA_ROLES=COMMERCIAL_ROLES['filter'](a=>a!=='system');export const SUPPORTED_INDUSTRIES=['freelance','rental','education','travel','subscription','retail'];export const PERSONA_VERSION=0x1;export const PERSONA_MAX_LINES=0x12c;