@wowok/agent-mcp 2.7.8 → 3.0.0

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 (393) hide show
  1. package/README.md +2 -2
  2. package/dist/config/runtime.d.ts +1 -1
  3. package/dist/config/runtime.js +1 -1
  4. package/dist/examples/rental-ziroom-machine-create.json +1 -2
  5. package/dist/examples/rental-ziroom-permission-create.json +1 -2
  6. package/dist/examples/rental-ziroom-service-create.json +1 -2
  7. package/dist/experience/experience-reuse.js +1 -1
  8. package/dist/experience/index.d.ts +2 -1
  9. package/dist/experience/index.js +1 -1
  10. package/dist/experience/persistence-config.d.ts +6 -0
  11. package/dist/experience/persistence-config.js +1 -0
  12. package/dist/experience/persistence.d.ts +21 -0
  13. package/dist/experience/persistence.js +1 -0
  14. package/dist/experience/realtime-feedback.js +1 -1
  15. package/dist/experience/user-profile.js +1 -1
  16. package/dist/extensions/business-modules.d.ts +1 -1
  17. package/dist/extensions/capability-manifest.d.ts +2 -83
  18. package/dist/extensions/capability-manifest.js +1 -1
  19. package/dist/extensions/constraint-registry.d.ts +6 -4
  20. package/dist/extensions/constraint-registry.js +1 -1
  21. package/dist/extensions/index.d.ts +4 -5
  22. package/dist/extensions/index.js +1 -1
  23. package/dist/extensions/industry-pack.js +1 -1
  24. package/dist/extensions/metric-registry.d.ts +6 -4
  25. package/dist/extensions/metric-registry.js +1 -1
  26. package/dist/extensions/mode-evaluator.d.ts +2 -3
  27. package/dist/extensions/mode-evaluator.js +1 -1
  28. package/dist/extensions/registry.d.ts +3 -25
  29. package/dist/extensions/registry.js +1 -1
  30. package/dist/extensions/types.d.ts +1 -69
  31. package/dist/goal/GoalClassifier.d.ts +17 -0
  32. package/dist/goal/GoalClassifier.js +1 -0
  33. package/dist/goal/GoalEngine.d.ts +155 -0
  34. package/dist/goal/GoalEngine.js +1 -0
  35. package/dist/goal/GoalStore.d.ts +27 -0
  36. package/dist/goal/GoalStore.js +1 -0
  37. package/dist/goal/plan-approval.d.ts +5 -0
  38. package/dist/goal/plan-approval.js +1 -0
  39. package/dist/goal/types.d.ts +80 -0
  40. package/dist/goal/types.js +1 -0
  41. package/dist/harness/index.d.ts +2 -7
  42. package/dist/harness/index.js +1 -1
  43. package/dist/harness/plan.d.ts +1 -1
  44. package/dist/harness/types.d.ts +0 -35
  45. package/dist/index.js +1 -1
  46. package/dist/knowledge/account-marks.d.ts +36 -0
  47. package/dist/knowledge/account-marks.js +1 -0
  48. package/dist/knowledge/audit-rules.d.ts +3 -1
  49. package/dist/knowledge/audit-rules.js +1 -1
  50. package/dist/knowledge/examples-scanner-cli.js +1 -1
  51. package/dist/knowledge/examples-scanner.js +1 -1
  52. package/dist/knowledge/fund-layer.d.ts +13 -9
  53. package/dist/knowledge/fund-layer.js +1 -1
  54. package/dist/knowledge/goal-completion.d.ts +19 -0
  55. package/dist/knowledge/goal-completion.js +1 -0
  56. package/dist/knowledge/guard-bindings.d.ts +21 -0
  57. package/dist/knowledge/guard-bindings.js +1 -0
  58. package/dist/knowledge/guard-translation.js +1 -1
  59. package/dist/knowledge/index.d.ts +6 -3
  60. package/dist/knowledge/index.js +1 -1
  61. package/dist/knowledge/industry-registry.js +1 -1
  62. package/dist/knowledge/mcp-schema-audit-cli.js +1 -1
  63. package/dist/knowledge/mcp-schema-audit.js +1 -1
  64. package/dist/knowledge/operation-dictionary.js +1 -1
  65. package/dist/knowledge/passport-confirm.js +1 -1
  66. package/dist/knowledge/passport-puzzle.js +1 -1
  67. package/dist/knowledge/passport-translation.js +1 -1
  68. package/dist/knowledge/proof-risk.js +1 -1
  69. package/dist/knowledge/reward-risk.d.ts +1 -1
  70. package/dist/knowledge/reward-risk.js +1 -1
  71. package/dist/knowledge/safety-rules.d.ts +2 -1
  72. package/dist/knowledge/safety-rules.js +1 -1
  73. package/dist/knowledge/scenario-topology.d.ts +43 -0
  74. package/dist/knowledge/scenario-topology.js +1 -0
  75. package/dist/knowledge/service-translation.js +1 -1
  76. package/dist/knowledge/supply-chain.js +1 -1
  77. package/dist/knowledge/template-registry.js +1 -1
  78. package/dist/knowledge/tools-reference.js +1 -1
  79. package/dist/knowledge/workflow-guidance.d.ts +36 -0
  80. package/dist/knowledge/workflow-guidance.js +1 -1
  81. package/dist/knowledge/workspace-lists.d.ts +57 -0
  82. package/dist/knowledge/workspace-lists.js +1 -0
  83. package/dist/loop-engineering/context-collect.d.ts +1 -1
  84. package/dist/monitor/EventRouter.d.ts +10 -0
  85. package/dist/monitor/EventRouter.js +1 -0
  86. package/dist/monitor/EventStore.d.ts +32 -12
  87. package/dist/monitor/EventStore.js +1 -1
  88. package/dist/monitor/MonitorLoop.d.ts +81 -0
  89. package/dist/monitor/MonitorLoop.js +1 -0
  90. package/dist/monitor/ProblemBridge.d.ts +32 -0
  91. package/dist/monitor/ProblemBridge.js +1 -0
  92. package/dist/monitor/ScopeResolver.d.ts +59 -0
  93. package/dist/monitor/ScopeResolver.js +1 -0
  94. package/dist/monitor/SubscriptionStore.d.ts +13 -0
  95. package/dist/monitor/SubscriptionStore.js +1 -0
  96. package/dist/monitor/SuggestionBridge.d.ts +38 -0
  97. package/dist/monitor/SuggestionBridge.js +1 -0
  98. package/dist/monitor/normalize.d.ts +8 -0
  99. package/dist/monitor/normalize.js +1 -0
  100. package/dist/monitor/types.d.ts +89 -0
  101. package/dist/monitor/types.js +1 -0
  102. package/dist/participation/arbitrator-interest.d.ts +20 -0
  103. package/dist/participation/arbitrator-interest.js +1 -0
  104. package/dist/participation/demander-interest.d.ts +23 -0
  105. package/dist/participation/demander-interest.js +1 -0
  106. package/dist/persona/address-format.d.ts +1 -1
  107. package/dist/persona/address-format.js +1 -1
  108. package/dist/persona/distill-goal.d.ts +20 -0
  109. package/dist/persona/distill-goal.js +1 -0
  110. package/dist/persona/index.d.ts +2 -0
  111. package/dist/persona/index.js +1 -1
  112. package/dist/persona/model.js +1 -1
  113. package/dist/playbooks/service-build/business-puzzle.js +1 -0
  114. package/dist/{project → playbooks/service-build}/context-assembly.d.ts +9 -4
  115. package/dist/playbooks/service-build/context-assembly.js +1 -0
  116. package/dist/{project → playbooks/service-build}/game-theory.d.ts +1 -1
  117. package/dist/playbooks/service-build/index.d.ts +14 -0
  118. package/dist/playbooks/service-build/index.js +1 -0
  119. package/dist/{project → playbooks/service-build}/intent-analyzer.d.ts +1 -1
  120. package/dist/playbooks/service-build/intent-analyzer.js +1 -0
  121. package/dist/playbooks/service-build/machine-nodes.js +1 -0
  122. package/dist/{project → playbooks/service-build}/machine-panorama.d.ts +5 -3
  123. package/dist/playbooks/service-build/machine-panorama.js +1 -0
  124. package/dist/{project → playbooks/service-build}/merchant-guide.d.ts +21 -1
  125. package/dist/playbooks/service-build/merchant-guide.js +1 -0
  126. package/dist/{project → playbooks/service-build}/mode-actions.d.ts +32 -8
  127. package/dist/playbooks/service-build/mode-actions.js +1 -0
  128. package/dist/playbooks/service-build/namespace.d.ts +2 -0
  129. package/dist/playbooks/service-build/namespace.js +1 -0
  130. package/dist/{project → playbooks/service-build}/object-panorama.d.ts +2 -3
  131. package/dist/playbooks/service-build/object-panorama.js +1 -0
  132. package/dist/{project → playbooks/service-build}/participation-radar.d.ts +4 -5
  133. package/dist/playbooks/service-build/participation-radar.js +1 -0
  134. package/dist/{project → playbooks/service-build}/pipeline-actions.d.ts +9 -9
  135. package/dist/playbooks/service-build/pipeline-actions.js +1 -0
  136. package/dist/playbooks/service-build/process.d.ts +6 -0
  137. package/dist/playbooks/service-build/process.js +1 -0
  138. package/dist/playbooks/service-build/relationship-profile.d.ts +2 -0
  139. package/dist/playbooks/service-build/relationship-profile.js +1 -0
  140. package/dist/playbooks/service-build/risk-aggregator.js +1 -0
  141. package/dist/{project → playbooks/service-build}/semantic-graph.d.ts +7 -3
  142. package/dist/playbooks/service-build/semantic-graph.js +1 -0
  143. package/dist/{project → playbooks/service-build}/service-panorama.d.ts +3 -19
  144. package/dist/playbooks/service-build/service-panorama.js +1 -0
  145. package/dist/relationship/derivation.d.ts +88 -0
  146. package/dist/relationship/derivation.js +1 -0
  147. package/dist/relationship/incentive.d.ts +38 -0
  148. package/dist/relationship/incentive.js +1 -0
  149. package/dist/relationship/index.d.ts +4 -0
  150. package/dist/relationship/index.js +1 -0
  151. package/dist/relationship/registry.d.ts +13 -0
  152. package/dist/relationship/registry.js +1 -0
  153. package/dist/relationship/types.d.ts +45 -0
  154. package/dist/relationship/types.js +1 -0
  155. package/dist/review/arb.d.ts +6 -0
  156. package/dist/review/arb.js +1 -0
  157. package/dist/review/demand.d.ts +3 -0
  158. package/dist/review/demand.js +1 -0
  159. package/dist/review/index.d.ts +3 -0
  160. package/dist/review/index.js +1 -0
  161. package/dist/review/machine.d.ts +3 -0
  162. package/dist/review/machine.js +1 -0
  163. package/dist/review/order.d.ts +9 -0
  164. package/dist/review/order.js +1 -0
  165. package/dist/review/progress.d.ts +3 -0
  166. package/dist/review/progress.js +1 -0
  167. package/dist/review/repository.d.ts +3 -0
  168. package/dist/review/repository.js +1 -0
  169. package/dist/review/service.d.ts +5 -0
  170. package/dist/review/service.js +1 -0
  171. package/dist/review/types.d.ts +156 -0
  172. package/dist/review/types.js +1 -0
  173. package/dist/rules.d.ts +2 -2
  174. package/dist/rules.js +1 -1
  175. package/dist/safety/confirm-gate.js +1 -1
  176. package/dist/safety/index.d.ts +1 -1
  177. package/dist/safety/index.js +1 -1
  178. package/dist/safety/preview.d.ts +1 -0
  179. package/dist/safety/preview.js +1 -1
  180. package/dist/schema/call/allocation.d.ts +1 -1
  181. package/dist/schema/call/arbitration.d.ts +1 -1
  182. package/dist/schema/call/base.d.ts +1 -1
  183. package/dist/schema/call/base.js +1 -1
  184. package/dist/schema/call/bridge.d.ts +29 -7
  185. package/dist/schema/call/bridge.js +1 -1
  186. package/dist/schema/call/contact.d.ts +1 -1
  187. package/dist/schema/call/contact.js +1 -1
  188. package/dist/schema/call/demand.d.ts +1 -1
  189. package/dist/schema/call/demand.js +1 -1
  190. package/dist/schema/call/guard.d.ts +3 -3
  191. package/dist/schema/call/handler.d.ts +0 -3
  192. package/dist/schema/call/handler.js +1 -1
  193. package/dist/schema/call/machine.d.ts +2 -2
  194. package/dist/schema/call/order.d.ts +1 -1
  195. package/dist/schema/call/payment.d.ts +1 -1
  196. package/dist/schema/call/permission.d.ts +1 -1
  197. package/dist/schema/call/personal.d.ts +1 -1
  198. package/dist/schema/call/progress.d.ts +1 -1
  199. package/dist/schema/call/proof.d.ts +2 -2
  200. package/dist/schema/call/repository.d.ts +1 -1
  201. package/dist/schema/call/repository.js +1 -1
  202. package/dist/schema/call/reward.d.ts +1 -1
  203. package/dist/schema/call/semantic.js +1 -1
  204. package/dist/schema/call/service.d.ts +1 -1
  205. package/dist/schema/call/service.js +1 -1
  206. package/dist/schema/call/treasury.d.ts +1 -1
  207. package/dist/schema/common/index.js +1 -1
  208. package/dist/schema/goal/index.d.ts +343 -0
  209. package/dist/schema/goal/index.js +1 -0
  210. package/dist/schema/goal/planning.d.ts +465 -0
  211. package/dist/schema/goal/planning.js +1 -0
  212. package/dist/schema/index.d.ts +1 -2
  213. package/dist/schema/index.js +1 -1
  214. package/dist/schema/industry-pack/index.d.ts +323 -1
  215. package/dist/schema/industry-pack/index.js +1 -1
  216. package/dist/schema/industry-pack/modes.d.ts +326 -0
  217. package/dist/schema/industry-pack/modes.js +1 -0
  218. package/dist/schema/intent-radar/index.d.ts +19 -19
  219. package/dist/schema/local/index.d.ts +11 -0
  220. package/dist/schema/local/index.js +1 -1
  221. package/dist/schema/operations.d.ts +258 -19
  222. package/dist/schema/operations.js +1 -1
  223. package/dist/schema/permission/index.d.ts +1 -0
  224. package/dist/schema/permission/index.js +1 -1
  225. package/dist/schema/persona/index.d.ts +40 -0
  226. package/dist/schema/persona/index.js +1 -1
  227. package/dist/schema/query/bi.d.ts +912 -0
  228. package/dist/schema/query/bi.js +1 -0
  229. package/dist/schema/query/index.d.ts +663 -2
  230. package/dist/schema/query/index.js +1 -1
  231. package/dist/schema/schema-version.js +1 -1
  232. package/dist/schema/utils/skills-recommendation.d.ts +0 -1
  233. package/dist/schema/utils/skills-recommendation.js +1 -1
  234. package/dist/schema-query-impl/index.js +1 -1
  235. package/dist/schemas/account_operation.output.json +32 -3
  236. package/dist/schemas/account_operation.schema.json +8 -4
  237. package/dist/schemas/bridge_operation.output.json +26 -3
  238. package/dist/schemas/bridge_operation.schema.json +85 -13
  239. package/dist/schemas/config_operation.output.json +1 -1
  240. package/dist/schemas/config_operation.schema.json +1 -1
  241. package/dist/schemas/goal_operation.schema.json +1092 -0
  242. package/dist/schemas/guard2file.schema.json +3 -3
  243. package/dist/schemas/index.json +12 -13
  244. package/dist/schemas/industry_pack_operation.output.json +1073 -0
  245. package/dist/schemas/industry_pack_operation.schema.json +236 -2
  246. package/dist/schemas/local_info_operation.output.json +2 -2
  247. package/dist/schemas/local_mark_operation.output.json +2 -2
  248. package/dist/schemas/machineNode2file.schema.json +3 -3
  249. package/dist/schemas/messenger_operation.output.json +2 -2
  250. package/dist/schemas/monitor_events.output.json +78 -3
  251. package/dist/schemas/monitor_events.schema.json +24 -1
  252. package/dist/schemas/monitor_subscription.output.json +1462 -0
  253. package/dist/schemas/monitor_subscription.schema.json +327 -0
  254. package/dist/schemas/onchain_events.output.json +5 -5
  255. package/dist/schemas/onchain_operations.output.json +2 -2
  256. package/dist/schemas/onchain_operations.schema.json +100 -100
  257. package/dist/schemas/onchain_operations_allocation.schema.json +7 -7
  258. package/dist/schemas/onchain_operations_arbitration.schema.json +6 -6
  259. package/dist/schemas/onchain_operations_contact.schema.json +6 -6
  260. package/dist/schemas/onchain_operations_demand.schema.json +6 -6
  261. package/dist/schemas/onchain_operations_gen_passport.schema.json +3 -3
  262. package/dist/schemas/onchain_operations_gen_proof.schema.json +3 -3
  263. package/dist/schemas/onchain_operations_guard.schema.json +3 -3
  264. package/dist/schemas/onchain_operations_machine.schema.json +5 -5
  265. package/dist/schemas/onchain_operations_order.schema.json +5 -5
  266. package/dist/schemas/onchain_operations_payment.schema.json +4 -4
  267. package/dist/schemas/onchain_operations_permission.schema.json +5 -5
  268. package/dist/schemas/onchain_operations_personal.schema.json +3 -3
  269. package/dist/schemas/onchain_operations_progress.schema.json +5 -5
  270. package/dist/schemas/onchain_operations_proof.schema.json +3 -3
  271. package/dist/schemas/onchain_operations_repository.schema.json +7 -7
  272. package/dist/schemas/onchain_operations_reward.schema.json +9 -9
  273. package/dist/schemas/onchain_operations_service.schema.json +11 -11
  274. package/dist/schemas/onchain_operations_treasury.schema.json +9 -9
  275. package/dist/schemas/onchain_table_data.output.json +399 -2
  276. package/dist/schemas/onchain_table_data.schema.json +22 -22
  277. package/dist/schemas/permission_operation.schema.json +6 -2
  278. package/dist/schemas/persona_operation.output.json +145 -0
  279. package/dist/schemas/persona_operation.schema.json +28 -2
  280. package/dist/schemas/query_toolkit.output.json +1514 -22
  281. package/dist/schemas/query_toolkit.schema.json +465 -11
  282. package/dist/schemas/workflow_operation.schema.json +4 -4
  283. package/dist/task/ProcessStore.d.ts +98 -0
  284. package/dist/task/ProcessStore.js +1 -0
  285. package/dist/task/playbook.d.ts +11 -0
  286. package/dist/task/playbook.js +1 -0
  287. package/dist/task/stage-gate.d.ts +22 -0
  288. package/dist/task/stage-gate.js +1 -0
  289. package/dist/{project → task}/substep-trace.d.ts +6 -45
  290. package/dist/task/types.d.ts +144 -0
  291. package/dist/task/types.js +1 -0
  292. package/dist/tools/handlers/config.js +1 -1
  293. package/dist/tools/handlers/evaluation.js +1 -1
  294. package/dist/tools/handlers/goal.d.ts +4 -0
  295. package/dist/tools/handlers/goal.js +1 -0
  296. package/dist/tools/handlers/industry-pack.js +1 -1
  297. package/dist/tools/handlers/local.d.ts +4 -3
  298. package/dist/tools/handlers/local.js +1 -1
  299. package/dist/tools/handlers/monitor.d.ts +24 -0
  300. package/dist/tools/handlers/monitor.js +1 -1
  301. package/dist/tools/handlers/network.d.ts +1 -0
  302. package/dist/tools/handlers/network.js +1 -0
  303. package/dist/tools/handlers/onchain.js +1 -1
  304. package/dist/tools/handlers/permission.js +1 -1
  305. package/dist/tools/handlers/persona.js +1 -1
  306. package/dist/tools/handlers/query.js +1 -1
  307. package/dist/tools/handlers/watch.js +1 -1
  308. package/dist/tools/handlers/workflow.js +1 -1
  309. package/dist/tools/index.d.ts +2 -0
  310. package/dist/tools/index.js +1 -1
  311. package/dist/tools/rules-hook.d.ts +1 -0
  312. package/dist/tools/rules-hook.js +1 -1
  313. package/dist/tools/shared.js +1 -1
  314. package/dist/tools/wrap.js +1 -1
  315. package/package.json +5 -4
  316. package/dist/harness/checkpoint.d.ts +0 -8
  317. package/dist/harness/checkpoint.js +0 -1
  318. package/dist/knowledge/deployment-scanner.d.ts +0 -66
  319. package/dist/knowledge/deployment-scanner.js +0 -1
  320. package/dist/mode-market/index.d.ts +0 -3
  321. package/dist/mode-market/index.js +0 -1
  322. package/dist/mode-market/registry.d.ts +0 -53
  323. package/dist/mode-market/registry.js +0 -1
  324. package/dist/mode-market/review.d.ts +0 -27
  325. package/dist/mode-market/review.js +0 -1
  326. package/dist/mode-market/submission.d.ts +0 -25
  327. package/dist/mode-market/submission.js +0 -1
  328. package/dist/project/business-puzzle.js +0 -1
  329. package/dist/project/context-assembly.js +0 -1
  330. package/dist/project/deployment-bridge.d.ts +0 -5
  331. package/dist/project/deployment-bridge.js +0 -1
  332. package/dist/project/deployment-doc.d.ts +0 -190
  333. package/dist/project/deployment-doc.js +0 -1
  334. package/dist/project/edit-planner.d.ts +0 -123
  335. package/dist/project/edit-planner.js +0 -1
  336. package/dist/project/evaluation-fix.spec.d.ts +0 -1
  337. package/dist/project/evaluation-fix.spec.js +0 -1
  338. package/dist/project/evaluation.d.ts +0 -127
  339. package/dist/project/evaluation.js +0 -1
  340. package/dist/project/graph-builder.d.ts +0 -51
  341. package/dist/project/graph-builder.js +0 -1
  342. package/dist/project/graph.d.ts +0 -70
  343. package/dist/project/graph.js +0 -1
  344. package/dist/project/handlers.d.ts +0 -524
  345. package/dist/project/handlers.js +0 -1
  346. package/dist/project/index.d.ts +0 -91
  347. package/dist/project/index.js +0 -1
  348. package/dist/project/intent-analyzer.js +0 -1
  349. package/dist/project/machine-nodes.js +0 -1
  350. package/dist/project/machine-panorama.js +0 -1
  351. package/dist/project/merchant-guide.js +0 -1
  352. package/dist/project/mode-actions.js +0 -1
  353. package/dist/project/namespace.d.ts +0 -72
  354. package/dist/project/namespace.js +0 -1
  355. package/dist/project/object-panorama.js +0 -1
  356. package/dist/project/participation-radar.js +0 -1
  357. package/dist/project/pipeline-actions.js +0 -1
  358. package/dist/project/project-store.d.ts +0 -110
  359. package/dist/project/project-store.js +0 -1
  360. package/dist/project/query.d.ts +0 -43
  361. package/dist/project/query.js +0 -1
  362. package/dist/project/risk-aggregator.js +0 -1
  363. package/dist/project/semantic-assembler.d.ts +0 -93
  364. package/dist/project/semantic-assembler.js +0 -1
  365. package/dist/project/semantic-graph.js +0 -1
  366. package/dist/project/service-panorama.js +0 -1
  367. package/dist/project/stage-gate.d.ts +0 -52
  368. package/dist/project/stage-gate.js +0 -1
  369. package/dist/project/task-tracker.d.ts +0 -30
  370. package/dist/project/task-tracker.js +0 -1
  371. package/dist/schema/project/index.d.ts +0 -2021
  372. package/dist/schema/project/index.js +0 -1
  373. package/dist/schema/task-status.d.ts +0 -62
  374. package/dist/schema/task-status.js +0 -1
  375. package/dist/schemas/project_operation.output.json +0 -7877
  376. package/dist/schemas/project_operation.schema.json +0 -1139
  377. package/dist/schemas/query_task_status.output.json +0 -211
  378. package/dist/schemas/query_task_status.schema.json +0 -18
  379. package/dist/tools/handlers/project.d.ts +0 -2
  380. package/dist/tools/handlers/project.js +0 -1
  381. package/dist/tools/handlers/task-status.d.ts +0 -2
  382. package/dist/tools/handlers/task-status.js +0 -1
  383. /package/dist/{project → playbooks/service-build}/business-puzzle.d.ts +0 -0
  384. /package/dist/{project → playbooks/service-build}/game-theory.js +0 -0
  385. /package/dist/{project → playbooks/service-build}/machine-nodes.d.ts +0 -0
  386. /package/dist/{project → playbooks/service-build}/object-type.d.ts +0 -0
  387. /package/dist/{project → playbooks/service-build}/object-type.js +0 -0
  388. /package/dist/{project → playbooks/service-build}/reverse-mapping.d.ts +0 -0
  389. /package/dist/{project → playbooks/service-build}/reverse-mapping.js +0 -0
  390. /package/dist/{project → playbooks/service-build}/risk-aggregator.d.ts +0 -0
  391. /package/dist/{project → playbooks/service-build}/workflow-design-assessment.d.ts +0 -0
  392. /package/dist/{project → playbooks/service-build}/workflow-design-assessment.js +0 -0
  393. /package/dist/{project → task}/substep-trace.js +0 -0
@@ -0,0 +1,98 @@
1
+ import { type DecisionRecord, type FeedbackRecord, type ProblemRecord, type ProcessEvent, type ProcessManifest, type ProcessStageState, type SubstepRecord, type SuggestionRecord, type StageMeta } from "./types.js";
2
+ export declare function processesRootDir(): string;
3
+ export declare function processDir(id: string): string;
4
+ export declare function deleteProcessDir(dir: string): void;
5
+ export declare function initProcess(dir: string, manifest: ProcessManifest, stages: string[]): ProcessManifest;
6
+ export declare function loadManifest(dir: string): ProcessManifest;
7
+ export declare function saveManifest(dir: string, manifest: ProcessManifest): void;
8
+ export declare function loadStageState(dir: string): ProcessStageState | undefined;
9
+ export declare function saveStageState(dir: string, state: ProcessStageState): void;
10
+ export declare function advanceStage(dir: string, toStage: string, opts?: {
11
+ allowSkip?: boolean;
12
+ }): ProcessStageState;
13
+ export declare function updateStageMeta(dir: string, stage: string, patch: Partial<StageMeta>): StageMeta;
14
+ export declare function appendEvent(dir: string, event: ProcessEvent): void;
15
+ export declare function readEvents(dir: string): ProcessEvent[];
16
+ export declare function addProblem(dir: string, input: {
17
+ stage?: string;
18
+ object?: string;
19
+ severity: ProblemRecord["severity"];
20
+ title: string;
21
+ detail?: string;
22
+ note?: {
23
+ by: "user" | "agent" | "system";
24
+ text: string;
25
+ };
26
+ origin?: ProblemRecord["origin"];
27
+ }): ProblemRecord;
28
+ export declare function updateProblem(dir: string, id: string, patch: Partial<Pick<ProblemRecord, "status" | "severity" | "title" | "detail" | "stage" | "object">>, note?: {
29
+ by: "user" | "agent" | "system";
30
+ text: string;
31
+ }): ProblemRecord;
32
+ export declare function listProblems(dir: string, filter?: {
33
+ status?: ProblemRecord["status"];
34
+ }): ProblemRecord[];
35
+ export declare function addSuggestion(dir: string, input: {
36
+ object?: string;
37
+ kind: SuggestionRecord["kind"];
38
+ stage?: string;
39
+ objects?: {
40
+ type: string;
41
+ object: string;
42
+ }[];
43
+ title: string;
44
+ detail?: string;
45
+ origin?: SuggestionRecord["origin"];
46
+ }): SuggestionRecord;
47
+ export declare function updateSuggestion(dir: string, id: string, patch: Partial<Pick<SuggestionRecord, "status" | "resolution_note" | "applied" | "stage" | "object">>): SuggestionRecord;
48
+ export declare function listSuggestions(dir: string, filter?: {
49
+ status?: SuggestionRecord["status"];
50
+ }): SuggestionRecord[];
51
+ export declare function addFeedback(dir: string, input: {
52
+ source: FeedbackRecord["source"];
53
+ sentiment: FeedbackRecord["sentiment"];
54
+ comment: string;
55
+ refs?: FeedbackRecord["refs"];
56
+ }): FeedbackRecord;
57
+ export declare function listFeedback(dir: string): FeedbackRecord[];
58
+ export declare function addDecision(dir: string, input: {
59
+ stage?: string;
60
+ by: DecisionRecord["by"];
61
+ decision: string;
62
+ rationale?: string;
63
+ reversible: boolean;
64
+ }): DecisionRecord;
65
+ export declare function listDecisions(dir: string): DecisionRecord[];
66
+ export declare function appendSubstep(dir: string, network: string, record: SubstepRecord): void;
67
+ export declare function readSubsteps(dir: string, network: string): SubstepRecord[];
68
+ export declare function savePayload(dir: string, relPath: string, data: unknown): string;
69
+ export declare function loadPayload<T = unknown>(dir: string, relPath: string): T | undefined;
70
+ export interface ProcessBundle {
71
+ schema_version: string;
72
+ exported_at: string;
73
+ manifest: ProcessManifest;
74
+ stage?: ProcessStageState;
75
+ events: ProcessEvent[];
76
+ problems: ProblemRecord[];
77
+ suggestions: SuggestionRecord[];
78
+ feedback: FeedbackRecord[];
79
+ decisions: DecisionRecord[];
80
+ substeps: Record<string, SubstepRecord[]>;
81
+ payloads: Record<string, unknown>;
82
+ }
83
+ export declare function exportBundle(dir: string): ProcessBundle;
84
+ export declare function importBundle(destDir: string, bundle: ProcessBundle, opts?: {
85
+ remap?: Record<string, string>;
86
+ }): ProcessManifest;
87
+ export declare function forkProcess(srcDir: string, destDir: string): ProcessManifest;
88
+ export interface ProcessListEntry {
89
+ dir_name: string;
90
+ path: string;
91
+ manifest?: ProcessManifest;
92
+ current_stage?: string;
93
+ stages?: string[];
94
+ committed_stages?: string[];
95
+ archived: boolean;
96
+ mtime: number;
97
+ }
98
+ export declare function listProcesses(root?: string): ProcessListEntry[];
@@ -0,0 +1 @@
1
+ import{appendFileSync,copyFileSync,existsSync,mkdirSync,readFileSync,readdirSync,rmSync,statSync,writeFileSync}from'fs';import{basename,dirname,join,relative,sep}from'path';import{getWowMcpDir}from'@wowok/wowok';import{PROCESS_SCHEMA_VERSION}from'./types.js';export function processesRootDir(){return join(getWowMcpDir(),'processes');}export function processDir(a){return join(processesRootDir(),a);}export function deleteProcessDir(a){rmSync(a,{'recursive':!![],'force':!![]});}function manifestPath(a){return join(a,'manifest.json');}function stageStatePath(a){return join(a,'stage.json');}function eventsPath(a){return join(a,'events.jsonl');}function problemsPath(a){return join(a,'problems.jsonl');}function suggestionsPath(a){return join(a,'suggestions.jsonl');}function feedbackPath(a){return join(a,'feedback.jsonl');}function decisionsPath(a){return join(a,'decisions.jsonl');}function netKey(a){return(a||'default')['replace'](/[^a-zA-Z0-9_-]/g,'_');}function substepsPath(a,b){return join(a,'substeps-'+netKey(b)+'.jsonl');}function relKey(a,b){return relative(a,b)['split'](sep)['join']('/');}function zeroStageMeta(){return{'committed':![],'gate_passed':![],'blocking_issues':[],'completion':0x0};}function newRecordId(a){return a+'_'+Date['now']()['toString'](0x24)+'_'+Math['random']()['toString'](0x24)['slice'](0x2,0x8);}export function initProcess(a,b,c){if(c['length']===0x0)throw new Error('initProcess\x20requires\x20a\x20non-empty\x20stage\x20sequence');mkdirSync(a,{'recursive':!![]}),writeFileSync(manifestPath(a),JSON['stringify'](b,null,0x2),'utf-8');const d={};for(const e of c)d[e]=zeroStageMeta();return saveStageState(a,{'stages':[...c],'current_stage':c[0x0],'stage_meta':d,'updated_at':Date['now']()}),appendEvent(a,{'timestamp':b['created_at'],'event':'process_init','stage':c[0x0],'reason':'process\x20initialized\x20(playbook:\x20'+b['playbook']+')','data':{'playbook':b['playbook'],'stages':[...c]}}),b;}export function loadManifest(a){const b=manifestPath(a);if(!existsSync(b))throw new Error('process\x20not\x20initialized:\x20'+a+'\x20(missing\x20manifest.json)');return JSON['parse'](readFileSync(b,'utf-8'));}export function saveManifest(a,b){b['updated_at']=new Date()['toISOString'](),writeFileSync(manifestPath(a),JSON['stringify'](b,null,0x2),'utf-8');}export function loadStageState(a){const b=stageStatePath(a);if(!existsSync(b))return undefined;return JSON['parse'](readFileSync(b,'utf-8'));}export function saveStageState(a,b){b['updated_at']=Date['now'](),mkdirSync(a,{'recursive':!![]}),writeFileSync(stageStatePath(a),JSON['stringify'](b,null,0x2),'utf-8');}export function advanceStage(a,b,c={}){const d=loadStageState(a);if(!d)throw new Error('process\x20not\x20initialized:\x20'+a+'\x20(missing\x20stage.json)');const e=d['stages']['indexOf'](b);if(e<0x0)throw new Error('unknown\x20stage\x20\x27'+b+'\x27\x20(stages:\x20'+d['stages']['join']('\x20→\x20')+')');const f=d['stages']['indexOf'](d['current_stage']);if(b===d['current_stage'])return d;if(e<f)throw new Error('invalid\x20stage\x20transition:\x20'+d['current_stage']+'\x20→\x20'+b+'\x20(forward-only)');if(e>f+0x1&&!c['allowSkip'])throw new Error('invalid\x20stage\x20transition:\x20'+d['current_stage']+'\x20→\x20'+b+'\x20(skips\x20'+d['stages'][f+0x1]+';\x20pass\x20allowSkip\x20to\x20jump)');const g=d['current_stage'],h=d['stage_meta'][g]??zeroStageMeta();return d['stage_meta'][g]={...h,'committed':!![],'committed_at':h['committed_at']??Date['now'](),'completion':h['committed']?h['completion']:0x64},d['current_stage']=b,saveStageState(a,d),appendEvent(a,{'timestamp':new Date()['toISOString'](),'event':'stage_commit','stage':g,'reason':'stage\x20\x27'+g+'\x27\x20committed;\x20advanced\x20to\x20\x27'+b+'\x27','data':{'from':g,'to':b}}),d;}export function updateStageMeta(a,b,c){const d=loadStageState(a);if(!d)throw new Error('process\x20not\x20initialized:\x20'+a+'\x20(missing\x20stage.json)');if(!d['stages']['includes'](b))throw new Error('unknown\x20stage\x20\x27'+b+'\x27\x20(stages:\x20'+d['stages']['join']('\x20→\x20')+')');const e={...d['stage_meta'][b]??zeroStageMeta(),...c};return d['stage_meta'][b]=e,saveStageState(a,d),e;}export function appendEvent(a,b){mkdirSync(a,{'recursive':!![]}),appendFileSync(eventsPath(a),JSON['stringify'](b)+'\x0a','utf-8');}export function readEvents(a){return readJsonl(eventsPath(a));}function readJsonl(a){if(!existsSync(a))return[];return readFileSync(a,'utf-8')['split']('\x0a')['filter'](b=>b['trim']()['length']>0x0)['map'](b=>JSON['parse'](b));}function appendJsonlRecord(a,b){mkdirSync(dirname(a),{'recursive':!![]}),appendFileSync(a,JSON['stringify'](b)+'\x0a','utf-8');}function foldLatest(a){const b=new Map();for(const c of a)b['set'](c['id'],c);return[...b['values']()];}export function addProblem(a,b){const c={'id':newRecordId('prob'),'created_at':new Date()['toISOString'](),...b['stage']?{'stage':b['stage']}:{},...b['object']?{'object':b['object']}:{},'severity':b['severity'],'status':'open','title':b['title'],...b['detail']?{'detail':b['detail']}:{},'notes':b['note']?[{'at':new Date()['toISOString'](),'by':b['note']['by'],'text':b['note']['text']}]:[],...b['origin']?{'origin':b['origin']}:{}};return appendJsonlRecord(problemsPath(a),c),c;}export function updateProblem(a,b,c,d){const e=foldLatest(readJsonl(problemsPath(a)))['find'](g=>g['id']===b);if(!e)throw new Error('problem\x20not\x20found:\x20'+b);const f={...e,...Object['fromEntries'](Object['entries'](c)['filter'](([,g])=>g!==undefined)),'notes':d?[...e['notes'],{'at':new Date()['toISOString'](),'by':d['by'],'text':d['text']}]:e['notes']};return appendJsonlRecord(problemsPath(a),f),f;}export function listProblems(a,b={}){const c=foldLatest(readJsonl(problemsPath(a)));return b['status']?c['filter'](d=>d['status']===b['status']):c;}export function addSuggestion(a,b){const c={'id':newRecordId('sug'),'created_at':new Date()['toISOString'](),...b['object']?{'object':b['object']}:{},'kind':b['kind'],...b['stage']?{'stage':b['stage']}:{},...b['objects']?{'objects':b['objects']}:{},'title':b['title'],...b['detail']?{'detail':b['detail']}:{},'status':'pending',...b['origin']?{'origin':b['origin']}:{}};return appendJsonlRecord(suggestionsPath(a),c),c;}export function updateSuggestion(a,b,c){const d=foldLatest(readJsonl(suggestionsPath(a)))['find'](f=>f['id']===b);if(!d)throw new Error('suggestion\x20not\x20found:\x20'+b);if(d['status']!=='pending'&&c['status']&&c['status']!==d['status'])throw new Error('suggestion\x20'+b+'\x20already\x20resolved\x20('+d['status']+')');const e={...d,...Object['fromEntries'](Object['entries'](c)['filter'](([,f])=>f!==undefined)),...c['status']&&c['status']!=='pending'?{'resolved_at':new Date()['toISOString']()}:{}};return appendJsonlRecord(suggestionsPath(a),e),e;}export function listSuggestions(a,b={}){const c=foldLatest(readJsonl(suggestionsPath(a)));return b['status']?c['filter'](d=>d['status']===b['status']):c;}export function addFeedback(a,b){const c={'id':newRecordId('fb'),'at':new Date()['toISOString'](),'source':b['source'],'sentiment':b['sentiment'],'comment':b['comment'],...b['refs']?{'refs':b['refs']}:{}};return appendJsonlRecord(feedbackPath(a),c),c;}export function listFeedback(a){return readJsonl(feedbackPath(a));}export function addDecision(a,b){const c={'id':newRecordId('dec'),'at':new Date()['toISOString'](),...b['stage']?{'stage':b['stage']}:{},'by':b['by'],'decision':b['decision'],...b['rationale']?{'rationale':b['rationale']}:{},'reversible':b['reversible']};return appendJsonlRecord(decisionsPath(a),c),c;}export function listDecisions(a){return readJsonl(decisionsPath(a));}export function appendSubstep(a,b,c){appendJsonlRecord(substepsPath(a,b),c);}export function readSubsteps(a,b){return readJsonl(substepsPath(a,b));}export function savePayload(a,b,c){const d=join(a,b);return mkdirSync(dirname(d),{'recursive':!![]}),writeFileSync(d,JSON['stringify'](c,null,0x2),'utf-8'),d;}export function loadPayload(a,b){const c=join(a,b);if(!existsSync(c))return undefined;return JSON['parse'](readFileSync(c,'utf-8'));}export function exportBundle(a){const b=loadManifest(a),c={},d={};function e(f){if(!existsSync(f))return;for(const g of readdirSync(f,{'withFileTypes':!![]})){const h=join(f,g['name']);if(g['isDirectory']())e(h);else{if(g['isFile']()){const i=relKey(a,h);if(i==='manifest.json'||i==='stage.json')continue;if(g['name']['endsWith']('.json'))try{c[i]=JSON['parse'](readFileSync(h,'utf-8'));}catch{}else{const j=g['name']['match'](/^substeps-(.+)\.jsonl$/);if(j)d[j[0x1]]=readJsonl(h);}}}}}return e(a),{'schema_version':PROCESS_SCHEMA_VERSION,'exported_at':new Date()['toISOString'](),'manifest':b,'stage':loadStageState(a),'events':readEvents(a),'problems':listProblems(a),'suggestions':listSuggestions(a),'feedback':listFeedback(a),'decisions':listDecisions(a),'substeps':d,'payloads':c};}function remapDeep(a,b,c){if(typeof a==='string'){const d=b[a];if(d!==undefined)return c['n']+=0x1,d;return a;}if(Array['isArray'](a))return a['map'](e=>remapDeep(e,b,c));if(a!==null&&typeof a==='object'){const e={};for(const [f,g]of Object['entries'](a)){e[f]=remapDeep(g,b,c);}return e;}return a;}export function importBundle(a,b,c={}){const g=c['remap']??{},h={'n':0x0};mkdirSync(a,{'recursive':!![]});const i=remapDeep(b['manifest'],g,h);i['updated_at']=new Date()['toISOString'](),writeFileSync(manifestPath(a),JSON['stringify'](i,null,0x2),'utf-8');b['stage']&&writeFileSync(stageStatePath(a),JSON['stringify'](b['stage'],null,0x2),'utf-8');for(const j of b['events'])appendJsonlRecord(eventsPath(a),j);for(const k of b['problems'])appendJsonlRecord(problemsPath(a),k);for(const l of b['suggestions']??[])appendJsonlRecord(suggestionsPath(a),l);for(const m of b['feedback'])appendJsonlRecord(feedbackPath(a),m);for(const n of b['decisions'])appendJsonlRecord(decisionsPath(a),n);for(const [o,q]of Object['entries'](b['substeps'])){for(const t of q){appendJsonlRecord(substepsPath(a,o),remapDeep(t,g,h));}}for(const [u,v]of Object['entries'](b['payloads'])){savePayload(a,u,remapDeep(v,g,h));}return appendEvent(a,{'timestamp':new Date()['toISOString'](),'event':'process_imported','reason':'process\x20imported\x20from\x20bundle\x20(exported_at\x20'+b['exported_at']+')','data':{'remapped':h['n']}}),i;}export function forkProcess(a,b){const c=loadManifest(a);mkdirSync(b,{'recursive':!![]});function d(f,g){for(const h of readdirSync(f,{'withFileTypes':!![]})){const i=join(f,h['name']),j=join(g,h['name']);if(h['isDirectory']())mkdirSync(j,{'recursive':!![]}),d(i,j);else h['isFile']()&&copyFileSync(i,j);}}d(a,b);const e={...c,'process_id':basename(b),'forked_from':c['process_id'],'archived':![],'updated_at':new Date()['toISOString']()};return writeFileSync(manifestPath(b),JSON['stringify'](e,null,0x2),'utf-8'),appendEvent(b,{'timestamp':new Date()['toISOString'](),'event':'process_forked','reason':'forked\x20from\x20'+c['process_id']+'\x20('+a+')','data':{'source_dir':a,'source_process':c['process_id']}}),e;}export function listProcesses(a=processesRootDir()){if(!existsSync(a))return[];const b=[];for(const c of readdirSync(a,{'withFileTypes':!![]})){if(!c['isDirectory']())continue;const d=join(a,c['name']);if(!existsSync(manifestPath(d)))continue;const f={'dir_name':c['name'],'path':d,'archived':![],'mtime':0x0};try{f['manifest']=loadManifest(d),f['archived']=f['manifest']['archived'];}catch{}try{const g=loadStageState(d);g&&(f['current_stage']=g['current_stage'],f['stages']=g['stages'],f['committed_stages']=g['stages']['filter'](h=>g['stage_meta'][h]?.['committed']));}catch{}try{f['mtime']=statSync(d)['mtimeMs'];}catch{}b['push'](f);}return b['sort']((h,i)=>i['mtime']-h['mtime']);}
@@ -0,0 +1,11 @@
1
+ export interface ProcessPlaybook {
2
+ name: string;
3
+ stages: string[];
4
+ description?: string;
5
+ }
6
+ export declare function registerPlaybook(playbook: ProcessPlaybook): void;
7
+ export declare function getPlaybook(name: string): ProcessPlaybook | undefined;
8
+ export declare function listPlaybooks(): ProcessPlaybook[];
9
+ export declare function hasPlaybook(name: string): boolean;
10
+ export declare const GENERIC_PLAYBOOK = "generic";
11
+ export declare function playbookForGoalType(goalType: string): ProcessPlaybook;
@@ -0,0 +1 @@
1
+ const registry=new Map();export function registerPlaybook(a){if(!a['name'])throw new Error('playbook\x20requires\x20a\x20name');if(a['stages']['length']===0x0)throw new Error('playbook\x20\x27'+a['name']+'\x27\x20requires\x20stages');registry['set'](a['name'],{...a,'stages':[...a['stages']]});}export function getPlaybook(a){return registry['get'](a);}export function listPlaybooks(){return[...registry['values']()];}export function hasPlaybook(a){return registry['has'](a);}export const GENERIC_PLAYBOOK='generic';export function playbookForGoalType(a){switch(a){case'publish_service':return registry['get']('service-build');case'fulfill_order':return registry['get']('order-fulfillment');case'capture_demand':return registry['get']('demand-capture');case'publish_demand':return registry['get']('demand-publish');case'purchase_service':return registry['get']('purchase');default:return registry['get'](GENERIC_PLAYBOOK);}}registerPlaybook({'name':GENERIC_PLAYBOOK,'stages':['prepare','execute','verify','close'],'description':'Fallback\x20stage\x20sequence\x20for\x20goals\x20without\x20a\x20dedicated\x20playbook.'}),registerPlaybook({'name':'service-build','stages':['namespace','puzzle','risk','doc','substeps'],'description':'Design\x20&\x20publish\x20a\x20commercial\x20service\x20(content:\x20src/playbooks/service-build/).'}),registerPlaybook({'name':'order-fulfillment','stages':['confirm','deliver','accept','settle'],'description':'Merchant-side\x20order\x20fulfillment.'}),registerPlaybook({'name':'demand-capture','stages':['discover','evaluate','engage','close'],'description':'Discover\x20and\x20capture\x20demand\x20opportunities.'}),registerPlaybook({'name':'demand-publish','stages':['draft','fund','publish','close'],'description':'Publish\x20a\x20funded\x20demand.'}),registerPlaybook({'name':'purchase','stages':['select','order','monitor','review'],'description':'Purchase\x20a\x20service\x20and\x20see\x20it\x20delivered.'});
@@ -0,0 +1,22 @@
1
+ export type GateDimension = "semantic" | "tools" | "reversibility" | "risk" | "isolation" | "gas_budget";
2
+ export interface GasBudgetCheck {
3
+ network: "testnet" | "mainnet";
4
+ already_spent_gas: number;
5
+ estimated_rerun_gas: number;
6
+ warning?: string;
7
+ }
8
+ export interface StageGateCheck {
9
+ dimension: GateDimension;
10
+ status: "PASS" | "FAIL" | "WARN";
11
+ message: string;
12
+ }
13
+ export interface StageGateResult {
14
+ stage: string;
15
+ passed: boolean;
16
+ checks: StageGateCheck[];
17
+ blocking_issues: string[];
18
+ warnings: string[];
19
+ can_proceed: boolean;
20
+ }
21
+ export declare function buildGasBudgetCheck(gas?: GasBudgetCheck): StageGateCheck;
22
+ export declare function composeStageGateResult(stage: string, checks: StageGateCheck[]): StageGateResult;
@@ -0,0 +1 @@
1
+ export function buildGasBudgetCheck(a){if(!a)return{'dimension':'gas_budget','status':'PASS','message':'Gas\x20budget\x20not\x20provided\x20(N/A\x20for\x20this\x20stage\x20or\x20caller\x20omitted)'};if(a['network']==='testnet')return{'dimension':'gas_budget','status':'PASS','message':'testnet:\x20no\x20gas\x20limit\x20(faucet\x20is\x20free);\x20rollback\x20is\x20costless'};const b=a['already_spent_gas']+a['estimated_rerun_gas'],c=a['warning']??'mainnet:\x20estimated\x20total\x20gas\x20'+b+'\x20MIST\x20(already_spent='+a['already_spent_gas']+'\x20+\x20rerun='+a['estimated_rerun_gas']+').\x20Rollback\x20will\x20incur\x20real\x20cost.';return{'dimension':'gas_budget','status':'WARN','message':c};}export function composeStageGateResult(a,b){const c=b['filter'](e=>e['status']==='FAIL')['map'](e=>'['+e['dimension']+']\x20'+e['message']),d=b['filter'](e=>e['status']==='WARN')['map'](e=>'['+e['dimension']+']\x20'+e['message']);return{'stage':a,'passed':c['length']===0x0,'checks':b,'blocking_issues':c,'warnings':d,'can_proceed':c['length']===0x0};}
@@ -1,50 +1,11 @@
1
- import type { ProjectObjectType } from "./namespace.js";
2
- export type SubstepNetwork = "testnet" | "mainnet";
1
+ import type { SubstepEdge, SubstepRecord } from "./types.js";
3
2
  export type SubstepStatus = "PENDING" | "SUCCESS" | "FAILED" | "SKIPPED";
4
- export interface OutputRef {
5
- substep_id: string;
6
- field_path: string;
7
- }
8
- export interface SubstepRecord {
9
- step_id: string;
10
- parent_step: string;
11
- object_type: ProjectObjectType;
12
- entry_id: string;
13
- operation_type: string;
14
- network: SubstepNetwork;
15
- input: {
16
- data: Record<string, unknown>;
17
- input_refs: string[];
18
- };
19
- output?: {
20
- object_id?: string;
21
- tx_digest?: string;
22
- [key: string]: unknown;
23
- };
24
- timestamp: number;
25
- status: SubstepStatus;
26
- failure_reason?: string;
27
- dependencies: {
28
- input_refs: string[];
29
- output_refs: OutputRef[];
30
- };
31
- retry_info?: {
32
- original_step_id: string;
33
- retry_count: number;
34
- retry_reason: string;
35
- };
36
- }
37
- export interface SubstepEdge {
38
- source: string;
39
- target: string;
40
- field_path: string;
41
- }
42
3
  export interface SubstepDAG {
43
4
  namespace: {
44
5
  prefix: string;
45
6
  version: string;
46
7
  };
47
- network: SubstepNetwork;
8
+ network: string;
48
9
  substeps: SubstepRecord[];
49
10
  edges: SubstepEdge[];
50
11
  topological_order: string[];
@@ -79,7 +40,7 @@ export interface StepTraceDetail {
79
40
  export interface SubstepTraceInput {
80
41
  project_prefix: string;
81
42
  version: string;
82
- network: SubstepNetwork;
43
+ network: string;
83
44
  substeps: SubstepRecord[];
84
45
  edges?: SubstepEdge[];
85
46
  }
@@ -88,7 +49,7 @@ export interface SubstepTraceResult {
88
49
  prefix: string;
89
50
  version: string;
90
51
  };
91
- network: SubstepNetwork;
52
+ network: string;
92
53
  coherent: boolean;
93
54
  dangling_inputs: DanglingInput[];
94
55
  circular_refs: CircularRef[];
@@ -113,7 +74,7 @@ export declare class SubstepTracer {
113
74
  private records;
114
75
  private namespace;
115
76
  private network;
116
- constructor(prefix: string, version: string, network: SubstepNetwork);
77
+ constructor(prefix: string, version: string, network: string);
117
78
  record(rec: SubstepRecord): void;
118
79
  getTrace(): SubstepRecord[];
119
80
  updateStatus(step_id: string, status: SubstepStatus, output?: Record<string, unknown>, failure_reason?: string): void;
@@ -124,7 +85,7 @@ export declare class SubstepTracer {
124
85
  prefix: string;
125
86
  version: string;
126
87
  };
127
- network: SubstepNetwork;
88
+ network: string;
128
89
  substeps: SubstepRecord[];
129
90
  };
130
91
  }
@@ -0,0 +1,144 @@
1
+ export declare const PROCESS_SCHEMA_VERSION = "1.0.0";
2
+ export interface ProcessManifest {
3
+ schema_version: string;
4
+ mcp_version: string;
5
+ process_id: string;
6
+ playbook: string;
7
+ goal_id?: string;
8
+ title: string;
9
+ network?: string;
10
+ objects: {
11
+ type: string;
12
+ object: string;
13
+ }[];
14
+ created_at: string;
15
+ updated_at: string;
16
+ forked_from?: string;
17
+ archived: boolean;
18
+ }
19
+ export interface StageMeta {
20
+ committed: boolean;
21
+ committed_at?: number;
22
+ gate_passed: boolean;
23
+ blocking_issues: string[];
24
+ completion: number;
25
+ }
26
+ export interface ProcessStageState {
27
+ stages: string[];
28
+ current_stage: string;
29
+ stage_meta: Record<string, StageMeta>;
30
+ updated_at: number;
31
+ }
32
+ export interface ProcessEvent {
33
+ timestamp: string;
34
+ event: string;
35
+ stage?: string;
36
+ reason: string;
37
+ data?: Record<string, unknown>;
38
+ user_confirmed?: boolean;
39
+ }
40
+ export interface ProblemRecord {
41
+ id: string;
42
+ created_at: string;
43
+ stage?: string;
44
+ object?: string;
45
+ severity: "low" | "medium" | "high" | "critical";
46
+ status: "open" | "resolved" | "wontfix";
47
+ title: string;
48
+ detail?: string;
49
+ notes: {
50
+ at: string;
51
+ by: "user" | "agent" | "system";
52
+ text: string;
53
+ }[];
54
+ origin?: {
55
+ source: "monitor";
56
+ network: string;
57
+ event_id: string;
58
+ event_type: string;
59
+ };
60
+ }
61
+ export type SuggestionKind = "advance_stage" | "complete_goal" | "register_object" | "note";
62
+ export interface SuggestionRecord {
63
+ id: string;
64
+ created_at: string;
65
+ object?: string;
66
+ kind: SuggestionKind;
67
+ stage?: string;
68
+ objects?: {
69
+ type: string;
70
+ object: string;
71
+ }[];
72
+ title: string;
73
+ detail?: string;
74
+ status: "pending" | "confirmed" | "dismissed";
75
+ resolved_at?: string;
76
+ resolution_note?: string;
77
+ applied?: boolean;
78
+ origin?: {
79
+ source: "monitor";
80
+ network: string;
81
+ event_id: string;
82
+ event_type: string;
83
+ };
84
+ }
85
+ export interface FeedbackRecord {
86
+ id: string;
87
+ at: string;
88
+ source: "user" | "agent" | "system";
89
+ sentiment: "positive" | "negative" | "neutral";
90
+ comment: string;
91
+ refs?: {
92
+ stage?: string;
93
+ object?: string;
94
+ run_id?: string;
95
+ };
96
+ }
97
+ export interface DecisionRecord {
98
+ id: string;
99
+ at: string;
100
+ stage?: string;
101
+ by: "user" | "agent";
102
+ decision: string;
103
+ rationale?: string;
104
+ reversible: boolean;
105
+ }
106
+ export interface OutputRef {
107
+ substep_id: string;
108
+ field_path: string;
109
+ }
110
+ export interface SubstepEdge {
111
+ source: string;
112
+ target: string;
113
+ field_path: string;
114
+ }
115
+ export interface SubstepRecord {
116
+ step_id: string;
117
+ parent_step: string;
118
+ object_type: string;
119
+ entry_id: string;
120
+ operation_type: string;
121
+ network: string;
122
+ input: {
123
+ data: Record<string, unknown>;
124
+ input_refs: string[];
125
+ };
126
+ output?: {
127
+ object_id?: string;
128
+ tx_digest?: string;
129
+ [key: string]: unknown;
130
+ };
131
+ timestamp: number;
132
+ status: "PENDING" | "SUCCESS" | "FAILED" | "SKIPPED";
133
+ failure_reason?: string;
134
+ dependencies: {
135
+ input_refs: string[];
136
+ output_refs: OutputRef[];
137
+ };
138
+ retry_info?: {
139
+ original_step_id: string;
140
+ retry_count: number;
141
+ retry_reason: string;
142
+ };
143
+ }
144
+ export declare function newProcessId(): string;
@@ -0,0 +1 @@
1
+ export const PROCESS_SCHEMA_VERSION='1.0.0';export function newProcessId(){return'proc_'+Date['now']()['toString'](0x24)+'_'+Math['random']()['toString'](0x24)['slice'](0x2,0x8);}
@@ -1 +1 @@
1
- import{listServices,getServiceInfo,toggle as a365a,setEnabled as a365b,reset as a365c}from'../../config/index.js';import{strictParse}from'../../schema/index.js';import{ConfigOperationInputSchema}from'../../schema/config/index.js';export async function handleConfigOperation(a){const b=strictParse(ConfigOperationInputSchema,a,'config_operation\x20input'),{action:c,service:d}=b;let e;switch(c){case'list':e={'action':'list','services':listServices()};break;case'toggle':{if(!d)throw new Error('\x27service\x27\x20param\x20is\x20required\x20for\x20toggle');const f=d,g=getServiceInfo(f);if(!g)throw new Error('Unknown\x20service:\x20'+f+'.\x20Use\x20action=\x27list\x27\x20to\x20see\x20all\x20valid\x20services.');const h=a365a(f);e={'action':'toggle','service':f,'enabled':h,'reminder':g['reminder']};break;}case'enable':{if(!d)throw new Error('\x27service\x27\x20param\x20is\x20required\x20for\x20enable');const i=d,j=getServiceInfo(i);if(!j)throw new Error('Unknown\x20service:\x20'+i+'.\x20Use\x20action=\x27list\x27\x20to\x20see\x20all\x20valid\x20services.');a365b(i,!![]),e={'action':'enable','service':i,'enabled':!![],'reminder':j['reminder']};break;}case'disable':{if(!d)throw new Error('\x27service\x27\x20param\x20is\x20required\x20for\x20disable');const k=d,l=getServiceInfo(k);if(!l)throw new Error('Unknown\x20service:\x20'+k+'.\x20Use\x20action=\x27list\x27\x20to\x20see\x20all\x20valid\x20services.');a365b(k,![]),e={'action':'disable','service':k,'enabled':![],'reminder':l['reminder']};break;}case'reset':{if(!d)throw new Error('\x27service\x27\x20param\x20is\x20required\x20for\x20reset');const m=d,n=getServiceInfo(m);if(!n)throw new Error('Unknown\x20service:\x20'+m+'.\x20Use\x20action=\x27list\x27\x20to\x20see\x20all\x20valid\x20services.');a365c(m),e={'action':'reset','service':m,'enabled':getServiceInfo(m)?.['enabled'],'reminder':n['reminder'],'reset':!![]};break;}case'info':{if(!d)throw new Error('\x27service\x27\x20param\x20is\x20required\x20for\x20info');const o=d,p=getServiceInfo(o);if(!p)throw new Error('Unknown\x20service:\x20'+o+'.\x20Use\x20action=\x27list\x27\x20to\x20see\x20all\x20valid\x20services.');e={'action':'info',...p};break;}default:throw new Error('Unknown\x20config_operation\x20action:\x20'+String(c));}return{'content':[{'type':'text','text':JSON['stringify']({'result':e})}],'structuredContent':{'result':e}};}
1
+ import{listServices,getServiceInfo,toggle as a391a,setEnabled as a391b,reset as a391c}from'../../config/index.js';import{strictParse}from'../../schema/index.js';import{ConfigOperationInputSchema}from'../../schema/config/index.js';export async function handleConfigOperation(a){const b=strictParse(ConfigOperationInputSchema,a,'config_operation\x20input'),{action:c,service:d}=b;let e;switch(c){case'list':e={'action':'list','services':listServices()};break;case'toggle':{if(!d)throw new Error('\x27service\x27\x20param\x20is\x20required\x20for\x20toggle');const f=d,g=getServiceInfo(f);if(!g)throw new Error('Unknown\x20service:\x20'+f+'.\x20Use\x20action=\x27list\x27\x20to\x20see\x20all\x20valid\x20services.');const h=a391a(f);e={'action':'toggle','service':f,'enabled':h,'reminder':g['reminder']};break;}case'enable':{if(!d)throw new Error('\x27service\x27\x20param\x20is\x20required\x20for\x20enable');const i=d,j=getServiceInfo(i);if(!j)throw new Error('Unknown\x20service:\x20'+i+'.\x20Use\x20action=\x27list\x27\x20to\x20see\x20all\x20valid\x20services.');a391b(i,!![]),e={'action':'enable','service':i,'enabled':!![],'reminder':j['reminder']};break;}case'disable':{if(!d)throw new Error('\x27service\x27\x20param\x20is\x20required\x20for\x20disable');const k=d,l=getServiceInfo(k);if(!l)throw new Error('Unknown\x20service:\x20'+k+'.\x20Use\x20action=\x27list\x27\x20to\x20see\x20all\x20valid\x20services.');a391b(k,![]),e={'action':'disable','service':k,'enabled':![],'reminder':l['reminder']};break;}case'reset':{if(!d)throw new Error('\x27service\x27\x20param\x20is\x20required\x20for\x20reset');const m=d,n=getServiceInfo(m);if(!n)throw new Error('Unknown\x20service:\x20'+m+'.\x20Use\x20action=\x27list\x27\x20to\x20see\x20all\x20valid\x20services.');a391c(m),e={'action':'reset','service':m,'enabled':getServiceInfo(m)?.['enabled'],'reminder':n['reminder'],'reset':!![]};break;}case'info':{if(!d)throw new Error('\x27service\x27\x20param\x20is\x20required\x20for\x20info');const o=d,p=getServiceInfo(o);if(!p)throw new Error('Unknown\x20service:\x20'+o+'.\x20Use\x20action=\x27list\x27\x20to\x20see\x20all\x20valid\x20services.');e={'action':'info',...p};break;}default:throw new Error('Unknown\x20config_operation\x20action:\x20'+String(c));}return{'content':[{'type':'text','text':JSON['stringify']({'result':e})}],'structuredContent':{'result':e}};}
@@ -1 +1 @@
1
- import{strictParse}from'../../schema/index.js';import{EvaluationOperationInputSchema}from'../../schema/evaluation/index.js';import{evaluateArbGame}from'../../evaluation/arbitration-game.js';import{evaluateNodeGame}from'../../evaluation/node-game.js';import{evaluatePathReasoning}from'../../evaluation/path-reasoning.js';import{assessEvidenceReview}from'../../knowledge/evidence-review.js';import{expandSearchScope,inferSensitivity,rankByLocation}from'../../evaluation/location-match.js';import{query_objects,ArbStatus}from'@wowok/wowok';import{enumerateServices,enumerateDemands,enumerateArbs}from'../../knowledge/jsonrpc-enum.js';import{fetchObjectLinkerCore}from'../../knowledge/index.js';import{summarizeCapabilityGaps}from'../../evaluation/gap.js';import{composeServicesForDemand}from'../../evaluation/composer.js';import{matchDemandToServices,matchServiceToDemands}from'../../evaluation/builtins/demand-match.js';import{extractDemandCapability}from'../../evaluation/extract.js';import{assessServiceRisk}from'../../evaluation/builtins/service-risk.js';import{assessArbitration}from'../../evaluation/builtins/arbitration-score.js';import{resolveCategoryMatchRules,toSoftWeightInjection,applyHardConstraints}from'../../evaluation/category-match-rules.js';import{computeMarketMetrics,computeOrderFlow}from'../../knowledge/market-metrics.js';import{assessAntiCheat}from'../../knowledge/anti-cheat.js';import{computeJourneyFunnel,attributeReferrals,buildCustomerRelationships}from'../../knowledge/market-operations.js';import{suggestPricing}from'../../knowledge/dynamic-pricing.js';import{runAccountEventWatchers}from'../../customer/account-events.js';import{registerBuiltinEvaluations}from'../../evaluation/builtins/index.js';import{getEffectivePersona,mergeInjections}from'../../persona/index.js';import{buildUserInjection}from'../../evaluation/injection.js';registerBuiltinEvaluations();function arbCaseFromObject(b){const c=typeof b['time']==='number'?b['time']:Number(b['time']??0x0);return{'status':b['status'],'time':Number['isFinite'](c)?c:undefined,'resolved_time':typeof b['indemnity']?.['time']==='number'?b['indemnity']['time']:b['compensation_time']??undefined,'indemnity_amount':b['indemnity']?.['amount'],'objected':b['status']===ArbStatus['Objectionable']||b['objection']!=null&&b['objection']['length']>0x0};}async function arbCasesWithRoles(a,b){const c=a['map'](arbCaseFromObject),d=Array['from'](new Set(a['map'](j=>j['order'])['filter'](Boolean))),e=new Map(),f=[];if(d['length']>0x0){const j=await query_objects({'objects':d,'network':b});for(const k of j['objects']??[]){const l=k;if(!l?.['object'])continue;e['set'](l['object'],l);if(l['service'])f['push'](l['service']);}}const g=new Map(),h=Array['from'](new Set(f));if(h['length']>0x0){const m=await query_objects({'objects':h,'network':b});for(const n of m['objects']??[]){const p=n;if(p?.['object'])g['set'](p['object'],p);}}for(let q=0x0;q<a['length'];q++){const r=e['get'](a[q]['order']);if(!r)continue;c[q]['customer']=r['builder']||undefined;const t=g['get'](r['service']);if(t)c[q]['merchant']=t['permission']||undefined;}return c;}function capabilityFromInput(a){return{'id':a['id'],'kind':a['kind'],'owner':a['owner']??'','industry':a['industry'],'industry_confidence':a['industry_confidence']??0x0,'region':a['region'],'price_min':a['price_min']!==undefined?BigInt(a['price_min']):undefined,'price_max':a['price_max']!==undefined?BigInt(a['price_max']):undefined,'token_type':a['token_type']??'','ticket_size':a['ticket_size']??'medium','trust_score':a['trust_score']??0x32,'reputation_like_ratio':a['reputation_like_ratio']??0x1,'arbitration_independent':a['arbitration_independent']??![],'merchant_history_count':a['merchant_history_count']??0x0,'capabilities':a['capabilities'],'tags':a['tags']??[],'keywords':a['keywords']??[]};}function puzzleRawFromInput(a){return{'service':{...a['service'],'priceRaw':a['service']['priceRaw']!==undefined?BigInt(a['service']['priceRaw']):undefined,'compensation_fund':a['service']['compensation_fund']?{'balance':a['service']['compensation_fund']['balance']!==undefined?BigInt(a['service']['compensation_fund']['balance']):undefined}:undefined},'machine_nodes':a['machine_nodes'],'machine_published':a['machine_published'],'machine_paused':a['machine_paused'],'reviews':a['reviews'],'events':a['events'],'similar_services':a['similar_services']?.['map'](b=>({'price':BigInt(b['price'])})),'order_amount':a['order_amount']!==undefined?BigInt(a['order_amount']):undefined,'trust_score':a['trust_score'],'arbitration_owner':a['arbitration_owner'],'service_owner':a['service_owner'],'wip_verified':a['wip_verified'],'order_history':a['order_history'],'merchant_reputation':a['merchant_reputation']};}async function resolveInjection(a,b){return mergeInjections(await buildUserInjection(a),b);}function serviceSummaryToExtract(a){const b=a['json']??{},c=f=>typeof f==='string'?f:undefined,d=f=>typeof f==='string'?f:null,e=Array['isArray'](b['sales'])?b['sales']['map'](f=>({'name':typeof f?.['name']==='string'?f['name']:undefined,'price':typeof f?.['price']==='string'?f['price']:f?.['price']!=null?String(f['price']):'0','wip_hash':typeof f?.['wip_hash']==='string'?f['wip_hash']:undefined})):[];return{'object':a['object'],'description':c(b['description'])??'','location':a['location']??c(b['location'])??'','sales':e,'arbitrations':Array['isArray'](b['arbitrations'])?b['arbitrations']['map'](String):[],'compensation_fund':c(b['compensation_fund']),'buy_guard':d(b['buy_guard']),'machine':d(b['machine']),'um':d(b['um']),'bPublished':b['bPublished']===!![],'bPaused':b['bPaused']===!![]};}export async function handleEvaluationOperation(a){const b=strictParse(EvaluationOperationInputSchema,a,'evaluation_operation\x20input');let c;switch(b['action']){case'arb_game':{const e=b['account']?await getEffectivePersona(b['account']):null,f=b['appetite']??e?.['layer']['preferences']?.['risk_appetite'],g=b['requirements']??e?.['layer']['requirements'];c={'action':'arb_game',...evaluateArbGame(b['status'],b['perspective'],{'risk_appetite':f,'requirements':g})};break;}case'node_game':{const h=b['account']?await getEffectivePersona(b['account']):null,i=b['appetite']??h?.['layer']['preferences']?.['risk_appetite'],j=b['requirements']??h?.['layer']['requirements'];c={'action':'node_game',...evaluateNodeGame({'current_node':b['current_node'],'perspective':b['perspective'],'appetite':i,'requirements':j,'threshold':b['threshold'],'allocation':b['allocation'],'order_amount':b['order_amount'],'compensation_fund':b['compensation_fund'],'operable':b['operable'],'waiting_on':b['waiting_on']??[]})};break;}case'capability_gap':{c={'action':'capability_gap','report':summarizeCapabilityGaps(capabilityFromInput(b['demand']),capabilityFromInput(b['service']))};break;}case'compose_service':{c={'action':'compose_service','plan':composeServicesForDemand(capabilityFromInput(b['demand']),b['services']['map'](capabilityFromInput))};break;}case'demand_match':{c={'action':'demand_match','matches':await matchDemandToServices(capabilityFromInput(b['demand_cap']),b['services'],await resolveInjection(b['account'],b['injection']))};break;}case'service_match':{c={'action':'service_match','matches':await matchServiceToDemands(capabilityFromInput(b['service_cap']),b['demands'],await resolveInjection(b['account'],b['injection']))};break;}case'service_risk':{c={'action':'service_risk','result':await assessServiceRisk(b['service_id'],puzzleRawFromInput(b['puzzle_raw']),await resolveInjection(b['account'],b['injection']),b['depth']??'preorder')};break;}case'path_reasoning':{const k=b['account']?await getEffectivePersona(b['account']):null,l=b['appetite']??k?.['layer']['preferences']?.['risk_appetite'],m=b['requirements']??k?.['layer']['requirements'];c={'action':'path_reasoning',...evaluatePathReasoning({'current_node':b['current_node'],'perspective':b['perspective'],'machine_nodes':b['machine_nodes'],'node_annotations':b['node_annotations'],'appetite':l,'requirements':m,'order_amount':b['order_amount'],'max_depth':b['max_depth']})};break;}case'evidence_review':{c={'action':'evidence_review','review':assessEvidenceReview({'kind':b['kind'],'hash_committed':b['hash_committed'],'digital_check_passed':b['digital_check_passed'],'contradiction':b['contradiction']})};break;}case'discover_services':{const n=!b['sensitivity']?inferSensitivity(b['description']??''):null,o=b['sensitivity']??n['sensitivity'],p=n?.['signals']??[],q=b['context_network']??'testnet',r={'raw':b['location'],...b['region']??{}},s=expandSearchScope(o,r),t=await enumerateServices(q,{'max_objects':b['max_objects'],'no_cache':b['no_cache'],'location_any':s['search_terms']}),u=rankByLocation(o,r,t['services']['map'](v=>({'id':v['object'],'name':v['name'],'location':v['location']})));c={'action':'discover_services','sensitivity':o,'inference_signals':p,'services':u['map'](v=>{const w=t['services']['find'](x=>x['object']===v['id']);return{'object':v['id'],'name':w?.['name'],'location':w?.['location'],'relation':v['relation'],'satisfied':v['satisfied'],'score':v['score'],'reason':v['reason']};}),'total_enumerated':t['total_enumerated'],'has_more':t['has_more'],'scope_advice':{'search_terms':s['search_terms'],'ai_enrichment_note':s['ai_enrichment_note']}};break;}case'discover_demands':{const v=b['context_network']??'testnet',w=await enumerateDemands(v,{'max_objects':b['max_objects'],'no_cache':b['no_cache']}),x=b['location']?.['toLowerCase'](),y=w['demands']['filter'](z=>!x||(z['location']??'')['toLowerCase']()['includes'](x))['map'](z=>({'object':z['object'],'description':z['description']??'','location':z['location']??'','presenters_count':z['presenters_count']??0x0,'permission':z['permission']??''}));c={'action':'discover_demands','demands':y,'total_enumerated':w['total_enumerated'],'has_more':w['has_more']};break;}case'demand_present':{const z=b['context_network']??'testnet',A=await enumerateDemands(z,{'max_objects':b['max_objects'],'no_cache':b['no_cache']}),B=b['location']?.['toLowerCase'](),C=A['demands']['filter'](G=>!B||(G['location']??'')['toLowerCase']()['includes'](B)),D=new Map(C['map'](G=>[G['object'],(G['guards']?.['length']??0x0)>0x0])),E=C['map'](G=>({'object':G['object'],'description':G['description']??'','location':G['location']??'','rewards':G['rewards']??[],'um':G['um']??null})),F=await matchServiceToDemands(capabilityFromInput(b['service_cap']),E,await resolveInjection(b['account'],b['injection']),b['limit']??0x5);c={'action':'demand_present','matches':F['map'](G=>{const H=D['get'](G['demand']['object'])??![];return{'demand':G['demand'],'result':G['result'],'present':{'operation':H?'demand.present_service_with_passport':'demand.present_service','guard_required':H}};}),'total_enumerated':A['total_enumerated'],'has_more':A['has_more']};break;}case'market_metrics':{const G=b['context_network']??'testnet',H=await computeMarketMetrics(G,b['no_cache']),I=await computeOrderFlow(G,b['limit'],b['no_cache']);c={'action':'market_metrics',...H,'order_flow':I};break;}case'anti_cheat':{const J=assessAntiCheat({'service':{'object':b['service']['object'],'arbitrations':b['service']['arbitrations'],'compensation_fund':b['service']['compensation_fund'],'machine':b['service']['machine'],'bPublished':b['service']['bPublished']},'orders':b['orders'],'reviews':b['reviews']});c={'action':'anti_cheat','signals':J};break;}case'market_operations':{if(b['op']==='journey_funnel')c={'action':'market_operations','result':computeJourneyFunnel({'due_diligence':b['due_diligence']??0x0,'orders':b['orders']??0x0,'completed':b['completed']??0x0,'reviews':b['reviews']??0x0})};else{if(b['op']==='referral_attribution')c={'action':'market_operations','result':attributeReferrals(b['referral_orders']??[])};else{if(b['op']==='dynamic_pricing'){const K=b['market_signals'];if(!K)throw new Error('dynamic_pricing\x20op\x20requires\x20market_signals');c={'action':'market_operations','result':suggestPricing({'supplyCount':K['supplyCount'],'demandCount':K['demandCount'],'avgPrice':K['avgPrice'],'myPrice':K['myPrice'],'competitorPrices':K['competitorPrices'],'recentOrderCount':K['recentOrderCount'],'repeatCustomerRate':K['repeatCustomerRate']})};}else c={'action':'market_operations','result':buildCustomerRelationships(b['customer_orders']??[])};}}break;}case'match_discover':{const L=!b['sensitivity']?inferSensitivity(b['description']??''):null,M=b['sensitivity']??L['sensitivity'],N=L?.['signals']??[],O=b['context_network']??'testnet',P={'raw':b['location'],...b['region']??{}},Q=expandSearchScope(M,P),R=await enumerateServices(O,{'max_objects':b['max_objects'],'no_cache':b['no_cache'],'location_any':Q['search_terms']}),S=new Set(b['required_capabilities']??[]),T=extractDemandCapability({'object':'intent','description':b['description'],'location':b['location'],'owner':b['account']},{'price_max':b['budget']!==undefined?BigInt(b['budget']):undefined,'capabilities':{'has_arbitration':S['has']('has_arbitration'),'has_refund_path':S['has']('has_refund_path'),'has_milestone_nodes':S['has']('has_milestone_nodes'),'has_compensation_fund':S['has']('has_compensation_fund'),'has_wip_verification':S['has']('has_wip_verification'),'has_messenger':S['has']('has_messenger'),'has_buy_guard':S['has']('has_buy_guard'),'has_dynamic_pricing':S['has']('has_dynamic_pricing'),'is_published':!![],'is_paused':![]}}),U=rankByLocation(M,P,R['services']['map'](a5=>({'id':a5['object'],'name':a5['name'],'location':a5['location']}))),V=U['filter'](a5=>a5['satisfied']),W=R['services']['filter'](a5=>V['some'](a6=>a6['id']===a5['object']))['map'](serviceSummaryToExtract),X=resolveCategoryMatchRules(b['category']);let Y=W;const Z=[];if(X){const a5=applyHardConstraints(X,W);Y=a5['passed'];for(const a6 of a5['dropped']){Z['push']({'object':a6['candidate']['object'],'reason':a6['constraint']['description']});}}let a0=await resolveInjection(b['account'],b['injection']);X&&(a0=mergeInjections(a0,toSoftWeightInjection(X)));const a1=await matchDemandToServices(T,Y,a0,Y['length']),a2=new Map(a1['map'](a7=>[a7['service']['object'],a7['result']])),a3=new Set(Y['map'](a7=>a7['object'])),a4=V['filter'](a7=>a3['has'](a7['id']))['map'](a7=>{const a8=R['services']['find'](a9=>a9['object']===a7['id']);return{'service':serviceSummaryToExtract(a8),'location':{'relation':a7['relation'],'satisfied':a7['satisfied'],'score':a7['score'],'reason':a7['reason']},'result':a2['get'](a7['id'])};});c={'action':'match_discover','sensitivity':M,'inference_signals':N,'matches':a4,'total_enumerated':R['total_enumerated'],'has_more':R['has_more'],'scope_advice':{'search_terms':Q['search_terms'],'ai_enrichment_note':Q['ai_enrichment_note']}};break;}case'arbitration_score':{let a7=b['history'];const a8=b['context_network']??'testnet';if((!a7||a7['length']===0x0)&&b['arbitration']['object'])try{const aa=await enumerateArbs(a8,{'arbitration':b['arbitration']['object']});a7=await arbCasesWithRoles(aa['arbs'],a8);}catch{a7=b['history'];}if((!a7||a7['length']===0x0)&&b['arbitration']['object'])try{const ab=await query_objects({'objects':[b['arbitration']['object']],'network':a8}),ac=ab?.['objects']?.[0x0];if(ac?.['permission']){const ad=await fetchObjectLinkerCore(ac['permission'],a8),ae=(ad?.['items']??[])['map'](ag=>ag['who'])['filter'](ag=>ag!==b['arbitration']['object']),af=[];for(const ag of ae['slice'](0x0,0xa)){const ah=await enumerateArbs(a8,{'arbitration':ag})['catch'](()=>undefined);ah?.['arbs']?.['length']&&af['push'](...await arbCasesWithRoles(ah['arbs'],a8));}if(af['length']>0x0)a7=af;}}catch{}const a9=await assessArbitration({'arbitration':{'object':b['arbitration']['object'],'fee':b['arbitration']['fee'],'balance':b['arbitration']['balance'],'voting_guard_count':b['arbitration']['voting_guard_count'],'bPaused':b['arbitration']['bPaused'],'location':b['arbitration']['location'],'has_verified_identity':b['arbitration']['has_verified_identity']},'history':a7,'entity_votes':b['entity_votes'],'fee_median':b['fee_median']},await resolveInjection(b['account'],b['injection']));c={'action':'arbitration_score',...a9};break;}case'account_events':{const ai=await runAccountEventWatchers({'account':b['account'],'network':b['context_network']??'testnet','reviews':b['reviews']?.['map'](aj=>({'reviewer':aj['reviewer'],'rating':aj['rating'],'tags':aj['tags'],'comment':aj['comment'],'orderRef':aj['orderRef'],'timestamp':aj['timestamp'],'verified':aj['verified']??![]})),'order_history':b['order_history']},b['categories']);c={'action':'account_events','events':ai};break;}default:throw new Error('Unknown\x20evaluation_operation\x20action');}return{'content':[{'type':'text','text':JSON['stringify']({'result':c})}],'structuredContent':{'result':c}};}
1
+ import{strictParse}from'../../schema/index.js';import{EvaluationOperationInputSchema}from'../../schema/evaluation/index.js';import{evaluateArbGame}from'../../evaluation/arbitration-game.js';import{evaluateNodeGame}from'../../evaluation/node-game.js';import{evaluatePathReasoning}from'../../evaluation/path-reasoning.js';import{assessEvidenceReview}from'../../knowledge/evidence-review.js';import{expandSearchScope,inferSensitivity,rankByLocation}from'../../evaluation/location-match.js';import{query_objects,ArbStatus}from'@wowok/wowok';import{enumerateServices,enumerateDemands,enumerateArbs}from'../../knowledge/jsonrpc-enum.js';import{fetchObjectLinkerCore,batchQueryObjectsByIds}from'../../knowledge/index.js';import{summarizeCapabilityGaps}from'../../evaluation/gap.js';import{composeServicesForDemand}from'../../evaluation/composer.js';import{matchDemandToServices,matchServiceToDemands}from'../../evaluation/builtins/demand-match.js';import{extractDemandCapability}from'../../evaluation/extract.js';import{assessServiceRisk}from'../../evaluation/builtins/service-risk.js';import{assessArbitration}from'../../evaluation/builtins/arbitration-score.js';import{resolveCategoryMatchRules,toSoftWeightInjection,applyHardConstraints}from'../../evaluation/category-match-rules.js';import{computeMarketMetrics,computeOrderFlow}from'../../knowledge/market-metrics.js';import{assessAntiCheat}from'../../knowledge/anti-cheat.js';import{computeJourneyFunnel,attributeReferrals,buildCustomerRelationships}from'../../knowledge/market-operations.js';import{suggestPricing}from'../../knowledge/dynamic-pricing.js';import{runAccountEventWatchers}from'../../customer/account-events.js';import{registerBuiltinEvaluations}from'../../evaluation/builtins/index.js';import{getEffectivePersona,mergeInjections}from'../../persona/index.js';import{buildUserInjection}from'../../evaluation/injection.js';registerBuiltinEvaluations();function arbCaseFromObject(b){const c=typeof b['time']==='number'?b['time']:Number(b['time']??0x0);return{'status':b['status'],'time':Number['isFinite'](c)?c:undefined,'resolved_time':typeof b['indemnity']?.['time']==='number'?b['indemnity']['time']:b['compensation_time']??undefined,'indemnity_amount':b['indemnity']?.['amount'],'objected':b['status']===ArbStatus['Objectionable']||b['objection']!=null&&b['objection']['length']>0x0};}async function arbCasesWithRoles(a,b){const c=a['map'](arbCaseFromObject),d=Array['from'](new Set(a['map'](j=>j['order'])['filter'](Boolean))),e=new Map(),f=[];if(d['length']>0x0){const j=await batchQueryObjectsByIds(d,b);for(const k of j){const l=k;if(!l?.['object'])continue;e['set'](l['object'],l);if(l['service'])f['push'](l['service']);}}const g=new Map(),h=Array['from'](new Set(f));if(h['length']>0x0){const m=await batchQueryObjectsByIds(h,b);for(const n of m){const p=n;if(p?.['object'])g['set'](p['object'],p);}}for(let q=0x0;q<a['length'];q++){const r=e['get'](a[q]['order']);if(!r)continue;c[q]['customer']=r['builder']||undefined;const t=g['get'](r['service']);if(t)c[q]['merchant']=t['permission']||undefined;}return c;}function capabilityFromInput(a){return{'id':a['id'],'kind':a['kind'],'owner':a['owner']??'','industry':a['industry'],'industry_confidence':a['industry_confidence']??0x0,'region':a['region'],'price_min':a['price_min']!==undefined?BigInt(a['price_min']):undefined,'price_max':a['price_max']!==undefined?BigInt(a['price_max']):undefined,'token_type':a['token_type']??'','ticket_size':a['ticket_size']??'medium','trust_score':a['trust_score']??0x32,'reputation_like_ratio':a['reputation_like_ratio']??0x1,'arbitration_independent':a['arbitration_independent']??![],'merchant_history_count':a['merchant_history_count']??0x0,'capabilities':a['capabilities'],'tags':a['tags']??[],'keywords':a['keywords']??[]};}function puzzleRawFromInput(a){return{'service':{...a['service'],'priceRaw':a['service']['priceRaw']!==undefined?BigInt(a['service']['priceRaw']):undefined,'compensation_fund':a['service']['compensation_fund']?{'balance':a['service']['compensation_fund']['balance']!==undefined?BigInt(a['service']['compensation_fund']['balance']):undefined}:undefined},'machine_nodes':a['machine_nodes'],'machine_published':a['machine_published'],'machine_paused':a['machine_paused'],'reviews':a['reviews'],'events':a['events'],'similar_services':a['similar_services']?.['map'](b=>({'price':BigInt(b['price'])})),'order_amount':a['order_amount']!==undefined?BigInt(a['order_amount']):undefined,'trust_score':a['trust_score'],'arbitration_owner':a['arbitration_owner'],'service_owner':a['service_owner'],'wip_verified':a['wip_verified'],'order_history':a['order_history'],'merchant_reputation':a['merchant_reputation']};}async function resolveInjection(a,b){return mergeInjections(await buildUserInjection(a),b);}function serviceSummaryToExtract(a){const b=a['json']??{},c=f=>typeof f==='string'?f:undefined,d=f=>typeof f==='string'?f:null,e=Array['isArray'](b['sales'])?b['sales']['map'](f=>({'name':typeof f?.['name']==='string'?f['name']:undefined,'price':typeof f?.['price']==='string'?f['price']:f?.['price']!=null?String(f['price']):'0','wip_hash':typeof f?.['wip_hash']==='string'?f['wip_hash']:undefined})):[];return{'object':a['object'],'description':c(b['description'])??'','location':a['location']??c(b['location'])??'','sales':e,'arbitrations':Array['isArray'](b['arbitrations'])?b['arbitrations']['map'](String):[],'compensation_fund':c(b['compensation_fund']),'buy_guard':d(b['buy_guard']),'machine':d(b['machine']),'um':d(b['um']),'bPublished':b['bPublished']===!![],'bPaused':b['bPaused']===!![]};}export async function handleEvaluationOperation(a){const b=strictParse(EvaluationOperationInputSchema,a,'evaluation_operation\x20input');let c;switch(b['action']){case'arb_game':{const e=b['account']?await getEffectivePersona(b['account']):null,f=b['appetite']??e?.['layer']['preferences']?.['risk_appetite'],g=b['requirements']??e?.['layer']['requirements'];c={'action':'arb_game',...evaluateArbGame(b['status'],b['perspective'],{'risk_appetite':f,'requirements':g})};break;}case'node_game':{const h=b['account']?await getEffectivePersona(b['account']):null,i=b['appetite']??h?.['layer']['preferences']?.['risk_appetite'],j=b['requirements']??h?.['layer']['requirements'];c={'action':'node_game',...evaluateNodeGame({'current_node':b['current_node'],'perspective':b['perspective'],'appetite':i,'requirements':j,'threshold':b['threshold'],'allocation':b['allocation'],'order_amount':b['order_amount'],'compensation_fund':b['compensation_fund'],'operable':b['operable'],'waiting_on':b['waiting_on']??[]})};break;}case'capability_gap':{c={'action':'capability_gap','report':summarizeCapabilityGaps(capabilityFromInput(b['demand']),capabilityFromInput(b['service']))};break;}case'compose_service':{c={'action':'compose_service','plan':composeServicesForDemand(capabilityFromInput(b['demand']),b['services']['map'](capabilityFromInput))};break;}case'demand_match':{c={'action':'demand_match','matches':await matchDemandToServices(capabilityFromInput(b['demand_cap']),b['services'],await resolveInjection(b['account'],b['injection']))};break;}case'service_match':{c={'action':'service_match','matches':await matchServiceToDemands(capabilityFromInput(b['service_cap']),b['demands'],await resolveInjection(b['account'],b['injection']))};break;}case'service_risk':{c={'action':'service_risk','result':await assessServiceRisk(b['service_id'],puzzleRawFromInput(b['puzzle_raw']),await resolveInjection(b['account'],b['injection']),b['depth']??'preorder')};break;}case'path_reasoning':{const k=b['account']?await getEffectivePersona(b['account']):null,l=b['appetite']??k?.['layer']['preferences']?.['risk_appetite'],m=b['requirements']??k?.['layer']['requirements'];c={'action':'path_reasoning',...evaluatePathReasoning({'current_node':b['current_node'],'perspective':b['perspective'],'machine_nodes':b['machine_nodes'],'node_annotations':b['node_annotations'],'appetite':l,'requirements':m,'order_amount':b['order_amount'],'max_depth':b['max_depth']})};break;}case'evidence_review':{c={'action':'evidence_review','review':assessEvidenceReview({'kind':b['kind'],'hash_committed':b['hash_committed'],'digital_check_passed':b['digital_check_passed'],'contradiction':b['contradiction']})};break;}case'discover_services':{const n=!b['sensitivity']?inferSensitivity(b['description']??''):null,o=b['sensitivity']??n['sensitivity'],p=n?.['signals']??[],q=b['context_network']??'testnet',r={'raw':b['location'],...b['region']??{}},s=expandSearchScope(o,r),t=await enumerateServices(q,{'max_objects':b['max_objects'],'no_cache':b['no_cache'],'location_any':s['search_terms']}),u=rankByLocation(o,r,t['services']['map'](v=>({'id':v['object'],'name':v['name'],'location':v['location']})));c={'action':'discover_services','sensitivity':o,'inference_signals':p,'services':u['map'](v=>{const w=t['services']['find'](x=>x['object']===v['id']);return{'object':v['id'],'name':w?.['name'],'location':w?.['location'],'relation':v['relation'],'satisfied':v['satisfied'],'score':v['score'],'reason':v['reason']};}),'total_enumerated':t['total_enumerated'],'has_more':t['has_more'],'scope_advice':{'search_terms':s['search_terms'],'ai_enrichment_note':s['ai_enrichment_note']}};break;}case'discover_demands':{const v=b['context_network']??'testnet',w=await enumerateDemands(v,{'max_objects':b['max_objects'],'no_cache':b['no_cache']}),x=b['location']?.['toLowerCase'](),y=w['demands']['filter'](z=>!x||(z['location']??'')['toLowerCase']()['includes'](x))['map'](z=>({'object':z['object'],'description':z['description']??'','location':z['location']??'','presenters_count':z['presenters_count']??0x0,'permission':z['permission']??''}));c={'action':'discover_demands','demands':y,'total_enumerated':w['total_enumerated'],'has_more':w['has_more']};break;}case'demand_present':{const z=b['context_network']??'testnet',A=await enumerateDemands(z,{'max_objects':b['max_objects'],'no_cache':b['no_cache']}),B=b['location']?.['toLowerCase'](),C=A['demands']['filter'](G=>!B||(G['location']??'')['toLowerCase']()['includes'](B)),D=new Map(C['map'](G=>[G['object'],(G['guards']?.['length']??0x0)>0x0])),E=C['map'](G=>({'object':G['object'],'description':G['description']??'','location':G['location']??'','rewards':G['rewards']??[],'um':G['um']??null})),F=await matchServiceToDemands(capabilityFromInput(b['service_cap']),E,await resolveInjection(b['account'],b['injection']),b['limit']??0x5);c={'action':'demand_present','matches':F['map'](G=>{const H=D['get'](G['demand']['object'])??![];return{'demand':G['demand'],'result':G['result'],'present':{'operation':H?'demand.present_service_with_passport':'demand.present_service','guard_required':H}};}),'total_enumerated':A['total_enumerated'],'has_more':A['has_more']};break;}case'market_metrics':{const G=b['context_network']??'testnet',H=await computeMarketMetrics(G,b['no_cache']),I=await computeOrderFlow(G,b['limit'],b['no_cache']);c={'action':'market_metrics',...H,'order_flow':I};break;}case'anti_cheat':{const J=assessAntiCheat({'service':{'object':b['service']['object'],'arbitrations':b['service']['arbitrations'],'compensation_fund':b['service']['compensation_fund'],'machine':b['service']['machine'],'bPublished':b['service']['bPublished']},'orders':b['orders'],'reviews':b['reviews']});c={'action':'anti_cheat','signals':J};break;}case'market_operations':{if(b['op']==='journey_funnel')c={'action':'market_operations','result':computeJourneyFunnel({'due_diligence':b['due_diligence']??0x0,'orders':b['orders']??0x0,'completed':b['completed']??0x0,'reviews':b['reviews']??0x0})};else{if(b['op']==='referral_attribution')c={'action':'market_operations','result':attributeReferrals(b['referral_orders']??[])};else{if(b['op']==='dynamic_pricing'){const K=b['market_signals'];if(!K)throw new Error('dynamic_pricing\x20op\x20requires\x20market_signals');c={'action':'market_operations','result':suggestPricing({'supplyCount':K['supplyCount'],'demandCount':K['demandCount'],'avgPrice':K['avgPrice'],'myPrice':K['myPrice'],'competitorPrices':K['competitorPrices'],'recentOrderCount':K['recentOrderCount'],'repeatCustomerRate':K['repeatCustomerRate']})};}else c={'action':'market_operations','result':buildCustomerRelationships(b['customer_orders']??[])};}}break;}case'match_discover':{const L=!b['sensitivity']?inferSensitivity(b['description']??''):null,M=b['sensitivity']??L['sensitivity'],N=L?.['signals']??[],O=b['context_network']??'testnet',P={'raw':b['location'],...b['region']??{}},Q=expandSearchScope(M,P),R=await enumerateServices(O,{'max_objects':b['max_objects'],'no_cache':b['no_cache'],'location_any':Q['search_terms']}),S=new Set(b['required_capabilities']??[]),T=extractDemandCapability({'object':'intent','description':b['description'],'location':b['location'],'owner':b['account']},{'price_max':b['budget']!==undefined?BigInt(b['budget']):undefined,'capabilities':{'has_arbitration':S['has']('has_arbitration'),'has_refund_path':S['has']('has_refund_path'),'has_milestone_nodes':S['has']('has_milestone_nodes'),'has_compensation_fund':S['has']('has_compensation_fund'),'has_wip_verification':S['has']('has_wip_verification'),'has_messenger':S['has']('has_messenger'),'has_buy_guard':S['has']('has_buy_guard'),'has_dynamic_pricing':S['has']('has_dynamic_pricing'),'is_published':!![],'is_paused':![]}}),U=rankByLocation(M,P,R['services']['map'](a5=>({'id':a5['object'],'name':a5['name'],'location':a5['location']}))),V=U['filter'](a5=>a5['satisfied']),W=R['services']['filter'](a5=>V['some'](a6=>a6['id']===a5['object']))['map'](serviceSummaryToExtract),X=resolveCategoryMatchRules(b['category']);let Y=W;const Z=[];if(X){const a5=applyHardConstraints(X,W);Y=a5['passed'];for(const a6 of a5['dropped']){Z['push']({'object':a6['candidate']['object'],'reason':a6['constraint']['description']});}}let a0=await resolveInjection(b['account'],b['injection']);X&&(a0=mergeInjections(a0,toSoftWeightInjection(X)));const a1=await matchDemandToServices(T,Y,a0,Y['length']),a2=new Map(a1['map'](a7=>[a7['service']['object'],a7['result']])),a3=new Set(Y['map'](a7=>a7['object'])),a4=V['filter'](a7=>a3['has'](a7['id']))['map'](a7=>{const a8=R['services']['find'](a9=>a9['object']===a7['id']);return{'service':serviceSummaryToExtract(a8),'location':{'relation':a7['relation'],'satisfied':a7['satisfied'],'score':a7['score'],'reason':a7['reason']},'result':a2['get'](a7['id'])};});c={'action':'match_discover','sensitivity':M,'inference_signals':N,'matches':a4,'total_enumerated':R['total_enumerated'],'has_more':R['has_more'],'scope_advice':{'search_terms':Q['search_terms'],'ai_enrichment_note':Q['ai_enrichment_note']}};break;}case'arbitration_score':{let a7=b['history'];const a8=b['context_network']??'testnet';if((!a7||a7['length']===0x0)&&b['arbitration']['object'])try{const aa=await enumerateArbs(a8,{'arbitration':b['arbitration']['object']});a7=await arbCasesWithRoles(aa['arbs'],a8);}catch{a7=b['history'];}if((!a7||a7['length']===0x0)&&b['arbitration']['object'])try{const ab=await query_objects({'objects':[b['arbitration']['object']],'network':a8}),ac=ab?.['objects']?.[0x0];if(ac?.['permission']){const ad=await fetchObjectLinkerCore(ac['permission'],a8),ae=(ad?.['items']??[])['map'](ag=>ag['who'])['filter'](ag=>ag!==b['arbitration']['object']),af=[];for(const ag of ae['slice'](0x0,0xa)){const ah=await enumerateArbs(a8,{'arbitration':ag})['catch'](()=>undefined);ah?.['arbs']?.['length']&&af['push'](...await arbCasesWithRoles(ah['arbs'],a8));}if(af['length']>0x0)a7=af;}}catch{}const a9=await assessArbitration({'arbitration':{'object':b['arbitration']['object'],'fee':b['arbitration']['fee'],'balance':b['arbitration']['balance'],'voting_guard_count':b['arbitration']['voting_guard_count'],'bPaused':b['arbitration']['bPaused'],'location':b['arbitration']['location'],'has_verified_identity':b['arbitration']['has_verified_identity']},'history':a7,'entity_votes':b['entity_votes'],'fee_median':b['fee_median']},await resolveInjection(b['account'],b['injection']));c={'action':'arbitration_score',...a9};break;}case'account_events':{const ai=await runAccountEventWatchers({'account':b['account'],'network':b['context_network']??'testnet','reviews':b['reviews']?.['map'](aj=>({'reviewer':aj['reviewer'],'rating':aj['rating'],'tags':aj['tags'],'comment':aj['comment'],'orderRef':aj['orderRef'],'timestamp':aj['timestamp'],'verified':aj['verified']??![]})),'order_history':b['order_history']},b['categories']);c={'action':'account_events','events':ai};break;}default:throw new Error('Unknown\x20evaluation_operation\x20action');}return{'content':[{'type':'text','text':JSON['stringify']({'result':c})}],'structuredContent':{'result':c}};}
@@ -0,0 +1,4 @@
1
+ import { type GoalEngine } from "../../goal/GoalEngine.js";
2
+ import type { ToolDispatchResult } from "../types.js";
3
+ export declare function setGoalEngineDeps(engine?: GoalEngine): void;
4
+ export declare function handleGoalOperation(args: unknown): Promise<ToolDispatchResult>;
@@ -0,0 +1 @@
1
+ import{strictParse}from'../../schema/index.js';import{GoalOperationInputSchema}from'../../schema/goal/index.js';import{goalEngine}from'../../goal/GoalEngine.js';import{isTerminalStage}from'../../goal/types.js';import{resolveNetwork}from'./network.js';import{handleAnalyzeIntent,handleAggregateRisks,handleTraceSubsteps}from'../../playbooks/service-build/pipeline-actions.js';import{handleMerchantGuide}from'../../playbooks/service-build/merchant-guide.js';let engineOverride;export function setGoalEngineDeps(a){engineOverride=a;}function engine(){return engineOverride??goalEngine;}export async function handleGoalOperation(a){const b=strictParse(GoalOperationInputSchema,a,'goal_operation\x20input'),c=await resolveNetwork(b['network']),d=engine();let e;switch(b['action']){case'create':{const f=await d['createOrAdopt']({'intent_text':b['intent_text'],...b['goal_type']?{'goal_type':b['goal_type']}:{},...b['account']?{'account':b['account']}:{},...b['persona']?{'persona':b['persona']}:{},...b['title']?{'title':b['title']}:{},...b['conversation_id']?{'conversation_id':b['conversation_id']}:{},...b['create_process']!==undefined?{'create_process':b['create_process']}:{},'network':c});e={'action':'create',...f};break;}case'list':{const {goals:g,counts:h}=await d['list'](c,{...b['stage']?{'stage':b['stage']}:{},...b['account']?{'account':b['account']}:{},...b['conversation_id']?{'conversation_id':b['conversation_id']}:{}}),i=b['include_finished']?g:g['filter'](j=>!isTerminalStage(j['stage']));e={'action':'list','goals':i,'counts':h};break;}case'get':{e={'action':'get','goal':await d['get'](c,b['id'])};break;}case'approve':{e={'action':'approve','goal':await d['approve'](c,b['id'],b['note'])};break;}case'bind':{e={'action':'bind','goal':await d['bind'](c,b['id'],b['account'],b['persona'])};break;}case'advance':{const j=await d['advance'](c,b['id'],{...b['stage']?{'stage':b['stage']}:{},...b['objects']?{'objects':b['objects']}:{}});e={'action':'advance','goal':j};break;}case'pause':{e={'action':'pause','goal':await d['pause'](c,b['id'])};break;}case'complete':{const k=await d['complete'](c,b['id'],{'force':b['force']===!![],...b['feedback']?{'feedback':b['feedback']}:{}});e={'action':'complete',...k};break;}case'abandon':{const l=await d['abandon'](c,b['id'],b['reason']);e={'action':'abandon',...l};break;}case'delete':{const m=await d['remove'](c,b['id'],{'force':b['force']===!![]});e={'action':'delete',...m};break;}case'suggestions':{const n=await d['listSuggestions'](c,b['id'],{...b['include_resolved']!==undefined?{'include_resolved':b['include_resolved']}:{}});e={'action':'suggestions',...n};break;}case'suggestion_resolve':{const o=await d['resolveSuggestion'](c,b['id'],b['suggestion_id'],{'decision':b['decision'],...b['apply']!==undefined?{'apply':b['apply']}:{},...b['note']?{'note':b['note']}:{}});e={'action':'suggestion_resolve',...o};break;}case'analyze_intent':e=await handleAnalyzeIntent(b);break;case'aggregate_risks':e=await handleAggregateRisks(b);break;case'trace_substeps':e=await handleTraceSubsteps(b);break;case'merchant_guide':e=await handleMerchantGuide(b);break;default:throw new Error('Unknown\x20goal_operation\x20action');}return{'content':[{'type':'text','text':JSON['stringify']({'result':e})}],'structuredContent':{'result':e}};}
@@ -1 +1 @@
1
- import{readdirSync,readFileSync,writeFileSync,existsSync,mkdirSync,statSync,cpSync,renameSync,rmSync}from'node:fs';import{join,relative,resolve,sep,dirname,basename}from'node:path';import{strictParse}from'../../schema/index.js';import{IndustryPackOperationInputSchema}from'../../schema/industry-pack/index.js';import{scaffoldIndustryPack,listRegisteredPacks,scanDefaultIndustryPacks,seedBuiltinIndustryTemplates,ensureIndustryReadme,resolveIndustryPackDir,rescanPack,resolveDisputeRules,resolveComplianceRules,resolveSupplyRules,resolveIndustryRules,resolveIndustryPlaybook,diffIndustryPack,resetIndustryPath}from'../../extensions/index.js';const INDUSTRY_ROOT=resolveIndustryPackDir();function resolveIndustryPath(a){const b=resolve(INDUSTRY_ROOT,a);if(b!==INDUSTRY_ROOT&&!b['startsWith'](INDUSTRY_ROOT+sep))throw new Error('path\x20\x27'+a+'\x27\x20escapes\x20the\x20industry\x20root');return b;}function rescanAffectedPack(a){const b=a['split'](/[\\/]+/)['find'](c=>c['length']>0x0);if(!b)return;rescanPack(b);}function listRecursive(a,b,c,d=0x0){if(d>0x8)return;let f;try{f=readdirSync(a,{'withFileTypes':!![]});}catch{return;}for(const g of f){const h=join(a,g['name']),i=relative(b,h)['split'](sep)['join']('/');let j=0x0,k=0x0;try{const l=statSync(h);k=l['size'],j=l['mtimeMs'];}catch{}g['isDirectory']()?(c['push']({'path':i,'is_dir':!![],'size':0x0,'mtime':j}),listRecursive(h,b,c,d+0x1)):c['push']({'path':i,'is_dir':![],'size':k,'mtime':j});}}export async function handleIndustryPackOperation(a){const b=strictParse(IndustryPackOperationInputSchema,a,'industry_pack_operation\x20input');mkdirSync(INDUSTRY_ROOT,{'recursive':!![]}),seedBuiltinIndustryTemplates(),ensureIndustryReadme();let c;switch(b['action']){case'scaffold':{if(!b['name'])throw new Error('\x27name\x27\x20is\x20required\x20for\x20action=\x27scaffold\x27');const d=scaffoldIndustryPack(b['name']);c={'action':'scaffold','ok':d['ok'],'dir':d['dir'],'files':d['files'],'errors':d['errors']};if(d['ok'])rescanPack(b['name']);break;}case'list':{c={'action':'list','packs':listRegisteredPacks()};break;}case'scan':{c={'action':'scan','results':scanDefaultIndustryPacks()};break;}case'resolve':{c={'action':'resolve','dir':INDUSTRY_ROOT};break;}case'list_files':{const e=[];listRecursive(INDUSTRY_ROOT,INDUSTRY_ROOT,e),c={'action':'list_files','dir':INDUSTRY_ROOT,'files':e};break;}case'read_file':{if(!b['path'])throw new Error('\x27path\x27\x20is\x20required\x20for\x20action=\x27read_file\x27');const f=resolveIndustryPath(b['path']);if(!existsSync(f))throw new Error('file\x20not\x20found:\x20'+b['path']);c={'action':'read_file','path':f,'content':readFileSync(f,'utf-8')};break;}case'write_file':{if(!b['path'])throw new Error('\x27path\x27\x20is\x20required\x20for\x20action=\x27write_file\x27');if(b['content']===undefined)throw new Error('\x27content\x27\x20is\x20required\x20for\x20action=\x27write_file\x27');const g=resolveIndustryPath(b['path']);mkdirSync(dirname(g),{'recursive':!![]}),writeFileSync(g,b['content'],'utf-8'),c={'action':'write_file','path':g,'ok':!![]},rescanAffectedPack(b['path']);break;}case'get':{if(!b['name'])throw new Error('\x27name\x27\x20is\x20required\x20for\x20action=\x27get\x27');const h=b['name'];c={'action':'get','category':h,...resolveDisputeRules(h)?{'dispute':resolveDisputeRules(h)}:{},...resolveComplianceRules(h)?{'compliance':resolveComplianceRules(h)}:{},...resolveSupplyRules(h)?{'supply':resolveSupplyRules(h)}:{},...resolveIndustryRules(h)?{'rules':resolveIndustryRules(h)}:{},...resolveIndustryPlaybook(h)?{'playbook':resolveIndustryPlaybook(h)}:{}};break;}case'diff':{if(!b['name'])throw new Error('\x27name\x27\x20is\x20required\x20for\x20action=\x27diff\x27');c={'action':'diff',...diffIndustryPack(b['name'])};break;}case'reset':{if(!b['path'])throw new Error('\x27path\x27\x20is\x20required\x20for\x20action=\x27reset\x27');const i=resetIndustryPath(b['path']);c={'action':'reset','ok':i['ok'],'layout':i['layout'],'target':i['target'],'restored_files':i['restored_files'],'errors':i['errors']},rescanAffectedPack(b['path']);break;}case'delete_file':{if(!b['path'])throw new Error('\x27path\x27\x20is\x20required\x20for\x20action=\x27delete_file\x27');const j=resolveIndustryPath(b['path']);if(!existsSync(j))throw new Error('file\x20not\x20found:\x20'+b['path']);rmSync(j,{'recursive':!![],'force':!![]}),c={'action':'delete_file','path':j,'ok':!![]},rescanAffectedPack(b['path']);break;}case'create_file':{if(!b['path'])throw new Error('\x27path\x27\x20is\x20required\x20for\x20action=\x27create_file\x27');const k=resolveIndustryPath(b['path']);if(existsSync(k))throw new Error('file\x20already\x20exists:\x20'+b['path']);mkdirSync(dirname(k),{'recursive':!![]}),writeFileSync(k,b['content']??'','utf-8'),c={'action':'create_file','path':k,'ok':!![]},rescanAffectedPack(b['path']);break;}case'create_dir':{if(!b['path'])throw new Error('\x27path\x27\x20is\x20required\x20for\x20action=\x27create_dir\x27');const l=resolveIndustryPath(b['path']);mkdirSync(l,{'recursive':!![]}),c={'action':'create_dir','path':l,'ok':!![]},rescanAffectedPack(b['path']);break;}case'copy':{if(!b['from'])throw new Error('\x27from\x27\x20is\x20required\x20for\x20action=\x27copy\x27');if(!b['to'])throw new Error('\x27to\x27\x20is\x20required\x20for\x20action=\x27copy\x27');const m=resolveIndustryPath(b['from']);let n=resolveIndustryPath(b['to']);if(!existsSync(m))throw new Error('source\x20not\x20found:\x20'+b['from']);try{existsSync(n)&&statSync(n)['isDirectory']()&&(n=join(n,basename(m)));}catch{}if(n===m)throw new Error('\x27copy\x27\x20cannot\x20copy\x20a\x20file\x20onto\x20itself');mkdirSync(dirname(n),{'recursive':!![]}),cpSync(m,n,{'recursive':!![],'force':!![]}),c={'action':'copy','from':m,'to':n,'ok':!![]},rescanAffectedPack(b['to']);break;}case'move':case'rename':{if(!b['from'])throw new Error('\x27from\x27\x20is\x20required\x20for\x20action=\x27'+b['action']+'\x27');if(!b['to'])throw new Error('\x27to\x27\x20is\x20required\x20for\x20action=\x27'+b['action']+'\x27');const o=resolveIndustryPath(b['from']);let p=resolveIndustryPath(b['to']);if(!existsSync(o))throw new Error('source\x20not\x20found:\x20'+b['from']);try{existsSync(p)&&statSync(p)['isDirectory']()&&(p=join(p,basename(o)));}catch{}if(p===o)throw new Error('\x27'+b['action']+'\x27\x20cannot\x20move\x20onto\x20itself');mkdirSync(dirname(p),{'recursive':!![]}),renameSync(o,p),c={'action':b['action'],'from':o,'to':p,'ok':!![]},rescanAffectedPack(b['from']),rescanAffectedPack(b['to']);break;}default:throw new Error('Unknown\x20industry_pack_operation\x20action:\x20'+String(b['action']));}return{'content':[{'type':'text','text':JSON['stringify']({'result':c})}],'structuredContent':{'result':c}};}
1
+ import{readdirSync,readFileSync,writeFileSync,existsSync,mkdirSync,statSync,cpSync,renameSync,rmSync}from'node:fs';import{join,relative,resolve,sep,dirname,basename}from'node:path';import{strictParse}from'../../schema/index.js';import{IndustryPackOperationInputSchema}from'../../schema/industry-pack/index.js';import{scaffoldIndustryPack,listRegisteredPacks,scanDefaultIndustryPacks,seedBuiltinIndustryTemplates,ensureIndustryReadme,resolveIndustryPackDir,rescanPack,resolveDisputeRules,resolveComplianceRules,resolveSupplyRules,resolveIndustryRules,resolveIndustryPlaybook,diffIndustryPack,resetIndustryPath}from'../../extensions/index.js';import{handleRecommendIndustry,handleListModes,handleDeriveUserMode,handleEvolveUserMode,handleRegisterUserMode,handleUnregisterUserMode,handleRegisterCustomMetric,handleUnregisterCustomMetric,handleRegisterCustomConstraint,handleUnregisterCustomConstraint,handleListMetricsConstraints}from'../../playbooks/service-build/mode-actions.js';const INDUSTRY_ROOT=resolveIndustryPackDir();function resolveIndustryPath(a){const b=resolve(INDUSTRY_ROOT,a);if(b!==INDUSTRY_ROOT&&!b['startsWith'](INDUSTRY_ROOT+sep))throw new Error('path\x20\x27'+a+'\x27\x20escapes\x20the\x20industry\x20root');return b;}function rescanAffectedPack(a){const b=a['split'](/[\\/]+/)['find'](c=>c['length']>0x0);if(!b)return;rescanPack(b);}function listRecursive(a,b,c,d=0x0){if(d>0x8)return;let f;try{f=readdirSync(a,{'withFileTypes':!![]});}catch{return;}for(const g of f){const h=join(a,g['name']),i=relative(b,h)['split'](sep)['join']('/');let j=0x0,k=0x0;try{const l=statSync(h);k=l['size'],j=l['mtimeMs'];}catch{}g['isDirectory']()?(c['push']({'path':i,'is_dir':!![],'size':0x0,'mtime':j}),listRecursive(h,b,c,d+0x1)):c['push']({'path':i,'is_dir':![],'size':k,'mtime':j});}}export async function handleIndustryPackOperation(a){const b=strictParse(IndustryPackOperationInputSchema,a,'industry_pack_operation\x20input');mkdirSync(INDUSTRY_ROOT,{'recursive':!![]}),seedBuiltinIndustryTemplates(),ensureIndustryReadme();let c;switch(b['action']){case'scaffold':{if(!b['name'])throw new Error('\x27name\x27\x20is\x20required\x20for\x20action=\x27scaffold\x27');const d=scaffoldIndustryPack(b['name']);c={'action':'scaffold','ok':d['ok'],'dir':d['dir'],'files':d['files'],'errors':d['errors']};if(d['ok'])rescanPack(b['name']);break;}case'list':{c={'action':'list','packs':listRegisteredPacks()};break;}case'scan':{c={'action':'scan','results':scanDefaultIndustryPacks()};break;}case'resolve':{c={'action':'resolve','dir':INDUSTRY_ROOT};break;}case'list_files':{const e=[];listRecursive(INDUSTRY_ROOT,INDUSTRY_ROOT,e),c={'action':'list_files','dir':INDUSTRY_ROOT,'files':e};break;}case'read_file':{if(!b['path'])throw new Error('\x27path\x27\x20is\x20required\x20for\x20action=\x27read_file\x27');const f=resolveIndustryPath(b['path']);if(!existsSync(f))throw new Error('file\x20not\x20found:\x20'+b['path']);c={'action':'read_file','path':f,'content':readFileSync(f,'utf-8')};break;}case'write_file':{if(!b['path'])throw new Error('\x27path\x27\x20is\x20required\x20for\x20action=\x27write_file\x27');if(b['content']===undefined)throw new Error('\x27content\x27\x20is\x20required\x20for\x20action=\x27write_file\x27');const g=resolveIndustryPath(b['path']);mkdirSync(dirname(g),{'recursive':!![]}),writeFileSync(g,b['content'],'utf-8'),c={'action':'write_file','path':g,'ok':!![]},rescanAffectedPack(b['path']);break;}case'get':{if(!b['name'])throw new Error('\x27name\x27\x20is\x20required\x20for\x20action=\x27get\x27');const h=b['name'];c={'action':'get','category':h,...resolveDisputeRules(h)?{'dispute':resolveDisputeRules(h)}:{},...resolveComplianceRules(h)?{'compliance':resolveComplianceRules(h)}:{},...resolveSupplyRules(h)?{'supply':resolveSupplyRules(h)}:{},...resolveIndustryRules(h)?{'rules':resolveIndustryRules(h)}:{},...resolveIndustryPlaybook(h)?{'playbook':resolveIndustryPlaybook(h)}:{}};break;}case'diff':{if(!b['name'])throw new Error('\x27name\x27\x20is\x20required\x20for\x20action=\x27diff\x27');c={'action':'diff',...diffIndustryPack(b['name'])};break;}case'reset':{if(!b['path'])throw new Error('\x27path\x27\x20is\x20required\x20for\x20action=\x27reset\x27');const i=resetIndustryPath(b['path']);c={'action':'reset','ok':i['ok'],'layout':i['layout'],'target':i['target'],'restored_files':i['restored_files'],'errors':i['errors']},rescanAffectedPack(b['path']);break;}case'delete_file':{if(!b['path'])throw new Error('\x27path\x27\x20is\x20required\x20for\x20action=\x27delete_file\x27');const j=resolveIndustryPath(b['path']);if(!existsSync(j))throw new Error('file\x20not\x20found:\x20'+b['path']);rmSync(j,{'recursive':!![],'force':!![]}),c={'action':'delete_file','path':j,'ok':!![]},rescanAffectedPack(b['path']);break;}case'create_file':{if(!b['path'])throw new Error('\x27path\x27\x20is\x20required\x20for\x20action=\x27create_file\x27');const k=resolveIndustryPath(b['path']);if(existsSync(k))throw new Error('file\x20already\x20exists:\x20'+b['path']);mkdirSync(dirname(k),{'recursive':!![]}),writeFileSync(k,b['content']??'','utf-8'),c={'action':'create_file','path':k,'ok':!![]},rescanAffectedPack(b['path']);break;}case'create_dir':{if(!b['path'])throw new Error('\x27path\x27\x20is\x20required\x20for\x20action=\x27create_dir\x27');const l=resolveIndustryPath(b['path']);mkdirSync(l,{'recursive':!![]}),c={'action':'create_dir','path':l,'ok':!![]},rescanAffectedPack(b['path']);break;}case'copy':{if(!b['from'])throw new Error('\x27from\x27\x20is\x20required\x20for\x20action=\x27copy\x27');if(!b['to'])throw new Error('\x27to\x27\x20is\x20required\x20for\x20action=\x27copy\x27');const m=resolveIndustryPath(b['from']);let n=resolveIndustryPath(b['to']);if(!existsSync(m))throw new Error('source\x20not\x20found:\x20'+b['from']);try{existsSync(n)&&statSync(n)['isDirectory']()&&(n=join(n,basename(m)));}catch{}if(n===m)throw new Error('\x27copy\x27\x20cannot\x20copy\x20a\x20file\x20onto\x20itself');mkdirSync(dirname(n),{'recursive':!![]}),cpSync(m,n,{'recursive':!![],'force':!![]}),c={'action':'copy','from':m,'to':n,'ok':!![]},rescanAffectedPack(b['to']);break;}case'move':case'rename':{if(!b['from'])throw new Error('\x27from\x27\x20is\x20required\x20for\x20action=\x27'+b['action']+'\x27');if(!b['to'])throw new Error('\x27to\x27\x20is\x20required\x20for\x20action=\x27'+b['action']+'\x27');const o=resolveIndustryPath(b['from']);let p=resolveIndustryPath(b['to']);if(!existsSync(o))throw new Error('source\x20not\x20found:\x20'+b['from']);try{existsSync(p)&&statSync(p)['isDirectory']()&&(p=join(p,basename(o)));}catch{}if(p===o)throw new Error('\x27'+b['action']+'\x27\x20cannot\x20move\x20onto\x20itself');mkdirSync(dirname(p),{'recursive':!![]}),renameSync(o,p),c={'action':b['action'],'from':o,'to':p,'ok':!![]},rescanAffectedPack(b['from']),rescanAffectedPack(b['to']);break;}case'recommend_industry':c=await handleRecommendIndustry(b);break;case'list_modes':c=await handleListModes();break;case'derive_user_mode':c=await handleDeriveUserMode(b);break;case'evolve_user_mode':c=await handleEvolveUserMode(b);break;case'register_user_mode':c=await handleRegisterUserMode(b);break;case'unregister_user_mode':c=await handleUnregisterUserMode(b);break;case'register_custom_metric':c=await handleRegisterCustomMetric(b);break;case'unregister_custom_metric':c=await handleUnregisterCustomMetric(b);break;case'register_custom_constraint':c=await handleRegisterCustomConstraint(b);break;case'unregister_custom_constraint':c=await handleUnregisterCustomConstraint(b);break;case'list_metrics_constraints':c=await handleListMetricsConstraints(b);break;default:throw new Error('Unknown\x20industry_pack_operation\x20action:\x20'+String(b['action']));}return{'content':[{'type':'text','text':JSON['stringify']({'result':c})}],'structuredContent':{'result':c}};}
@@ -1,3 +1,4 @@
1
- export declare const handleAccountOperation: (args: unknown) => Promise<import("../types.js").ToolDispatchResult>;
2
- export declare const handleMarkOperation: (args: unknown) => Promise<import("../types.js").ToolDispatchResult>;
3
- export declare const handleInfoOperation: (args: unknown) => Promise<import("../types.js").ToolDispatchResult>;
1
+ import type { ToolDispatchResult } from "../types.js";
2
+ export declare const handleAccountOperation: (args: unknown) => Promise<ToolDispatchResult>;
3
+ export declare const handleMarkOperation: (args: unknown) => Promise<ToolDispatchResult>;
4
+ export declare const handleInfoOperation: (args: unknown) => Promise<ToolDispatchResult>;