@wowok/agent-mcp 2.7.8 → 2.7.10

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 (334) 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 +1 -1
  18. package/dist/extensions/types.d.ts +1 -1
  19. package/dist/goal/GoalClassifier.d.ts +17 -0
  20. package/dist/goal/GoalClassifier.js +1 -0
  21. package/dist/goal/GoalEngine.d.ts +120 -0
  22. package/dist/goal/GoalEngine.js +1 -0
  23. package/dist/goal/GoalStore.d.ts +27 -0
  24. package/dist/goal/GoalStore.js +1 -0
  25. package/dist/goal/plan-approval.d.ts +5 -0
  26. package/dist/goal/plan-approval.js +1 -0
  27. package/dist/goal/types.d.ts +76 -0
  28. package/dist/goal/types.js +1 -0
  29. package/dist/harness/index.d.ts +2 -7
  30. package/dist/harness/index.js +1 -1
  31. package/dist/harness/plan.d.ts +1 -1
  32. package/dist/harness/types.d.ts +0 -35
  33. package/dist/index.js +1 -1
  34. package/dist/knowledge/account-marks.d.ts +35 -0
  35. package/dist/knowledge/account-marks.js +1 -0
  36. package/dist/knowledge/audit-rules.d.ts +3 -1
  37. package/dist/knowledge/audit-rules.js +1 -1
  38. package/dist/knowledge/examples-scanner-cli.js +1 -1
  39. package/dist/knowledge/examples-scanner.js +1 -1
  40. package/dist/knowledge/goal-completion.d.ts +19 -0
  41. package/dist/knowledge/goal-completion.js +1 -0
  42. package/dist/knowledge/guard-translation.js +1 -1
  43. package/dist/knowledge/index.d.ts +3 -2
  44. package/dist/knowledge/index.js +1 -1
  45. package/dist/knowledge/industry-registry.js +1 -1
  46. package/dist/knowledge/mcp-schema-audit-cli.js +1 -1
  47. package/dist/knowledge/mcp-schema-audit.js +1 -1
  48. package/dist/knowledge/operation-dictionary.js +1 -1
  49. package/dist/knowledge/passport-confirm.js +1 -1
  50. package/dist/knowledge/passport-puzzle.js +1 -1
  51. package/dist/knowledge/passport-translation.js +1 -1
  52. package/dist/knowledge/proof-risk.js +1 -1
  53. package/dist/knowledge/safety-rules.js +1 -1
  54. package/dist/knowledge/service-translation.js +1 -1
  55. package/dist/knowledge/template-registry.js +1 -1
  56. package/dist/knowledge/tools-reference.js +1 -1
  57. package/dist/knowledge/workflow-guidance.d.ts +1 -0
  58. package/dist/knowledge/workflow-guidance.js +1 -1
  59. package/dist/knowledge/workspace-lists.d.ts +56 -0
  60. package/dist/knowledge/workspace-lists.js +1 -0
  61. package/dist/loop-engineering/context-collect.d.ts +1 -1
  62. package/dist/monitor/EventRouter.d.ts +10 -0
  63. package/dist/monitor/EventRouter.js +1 -0
  64. package/dist/monitor/EventStore.d.ts +32 -12
  65. package/dist/monitor/EventStore.js +1 -1
  66. package/dist/monitor/MonitorLoop.d.ts +79 -0
  67. package/dist/monitor/MonitorLoop.js +1 -0
  68. package/dist/monitor/ProblemBridge.d.ts +32 -0
  69. package/dist/monitor/ProblemBridge.js +1 -0
  70. package/dist/monitor/ScopeResolver.d.ts +59 -0
  71. package/dist/monitor/ScopeResolver.js +1 -0
  72. package/dist/monitor/SubscriptionStore.d.ts +13 -0
  73. package/dist/monitor/SubscriptionStore.js +1 -0
  74. package/dist/monitor/normalize.d.ts +8 -0
  75. package/dist/monitor/normalize.js +1 -0
  76. package/dist/monitor/types.d.ts +89 -0
  77. package/dist/monitor/types.js +1 -0
  78. package/dist/persona/address-format.d.ts +1 -1
  79. package/dist/persona/address-format.js +1 -1
  80. package/dist/persona/distill-goal.d.ts +20 -0
  81. package/dist/persona/distill-goal.js +1 -0
  82. package/dist/persona/index.d.ts +2 -0
  83. package/dist/persona/index.js +1 -1
  84. package/dist/persona/model.js +1 -1
  85. package/dist/playbooks/service-build/business-puzzle.js +1 -0
  86. package/dist/{project → playbooks/service-build}/context-assembly.d.ts +9 -4
  87. package/dist/playbooks/service-build/context-assembly.js +1 -0
  88. package/dist/{project → playbooks/service-build}/game-theory.d.ts +1 -1
  89. package/dist/playbooks/service-build/index.d.ts +14 -0
  90. package/dist/playbooks/service-build/index.js +1 -0
  91. package/dist/{project → playbooks/service-build}/intent-analyzer.d.ts +1 -1
  92. package/dist/playbooks/service-build/intent-analyzer.js +1 -0
  93. package/dist/{project → playbooks/service-build}/machine-panorama.d.ts +5 -3
  94. package/dist/playbooks/service-build/machine-panorama.js +1 -0
  95. package/dist/{project → playbooks/service-build}/merchant-guide.d.ts +1 -1
  96. package/dist/playbooks/service-build/merchant-guide.js +1 -0
  97. package/dist/{project → playbooks/service-build}/mode-actions.d.ts +2 -2
  98. package/dist/playbooks/service-build/mode-actions.js +1 -0
  99. package/dist/playbooks/service-build/namespace.d.ts +2 -0
  100. package/dist/playbooks/service-build/namespace.js +1 -0
  101. package/dist/{project → playbooks/service-build}/object-panorama.d.ts +2 -3
  102. package/dist/playbooks/service-build/object-panorama.js +1 -0
  103. package/dist/{project → playbooks/service-build}/participation-radar.d.ts +4 -5
  104. package/dist/playbooks/service-build/participation-radar.js +1 -0
  105. package/dist/{project → playbooks/service-build}/pipeline-actions.d.ts +9 -9
  106. package/dist/playbooks/service-build/pipeline-actions.js +1 -0
  107. package/dist/playbooks/service-build/process.d.ts +6 -0
  108. package/dist/playbooks/service-build/process.js +1 -0
  109. package/dist/playbooks/service-build/risk-aggregator.js +1 -0
  110. package/dist/{project → playbooks/service-build}/semantic-graph.d.ts +2 -2
  111. package/dist/{project → playbooks/service-build}/service-panorama.d.ts +3 -19
  112. package/dist/playbooks/service-build/service-panorama.js +1 -0
  113. package/dist/review/arb.d.ts +6 -0
  114. package/dist/review/arb.js +1 -0
  115. package/dist/review/demand.d.ts +3 -0
  116. package/dist/review/demand.js +1 -0
  117. package/dist/review/index.d.ts +3 -0
  118. package/dist/review/index.js +1 -0
  119. package/dist/review/machine.d.ts +3 -0
  120. package/dist/review/machine.js +1 -0
  121. package/dist/review/order.d.ts +9 -0
  122. package/dist/review/order.js +1 -0
  123. package/dist/review/progress.d.ts +3 -0
  124. package/dist/review/progress.js +1 -0
  125. package/dist/review/repository.d.ts +3 -0
  126. package/dist/review/repository.js +1 -0
  127. package/dist/review/service.d.ts +5 -0
  128. package/dist/review/service.js +1 -0
  129. package/dist/review/types.d.ts +156 -0
  130. package/dist/review/types.js +1 -0
  131. package/dist/rules.d.ts +2 -2
  132. package/dist/rules.js +1 -1
  133. package/dist/safety/confirm-gate.js +1 -1
  134. package/dist/safety/index.d.ts +1 -1
  135. package/dist/safety/index.js +1 -1
  136. package/dist/safety/preview.d.ts +1 -0
  137. package/dist/safety/preview.js +1 -1
  138. package/dist/schema/call/allocation.d.ts +1 -1
  139. package/dist/schema/call/arbitration.d.ts +1 -1
  140. package/dist/schema/call/base.d.ts +1 -1
  141. package/dist/schema/call/base.js +1 -1
  142. package/dist/schema/call/bridge.d.ts +4 -4
  143. package/dist/schema/call/contact.d.ts +1 -1
  144. package/dist/schema/call/contact.js +1 -1
  145. package/dist/schema/call/demand.d.ts +1 -1
  146. package/dist/schema/call/demand.js +1 -1
  147. package/dist/schema/call/guard.d.ts +3 -3
  148. package/dist/schema/call/handler.d.ts +0 -3
  149. package/dist/schema/call/handler.js +1 -1
  150. package/dist/schema/call/machine.d.ts +2 -2
  151. package/dist/schema/call/order.d.ts +1 -1
  152. package/dist/schema/call/payment.d.ts +1 -1
  153. package/dist/schema/call/permission.d.ts +1 -1
  154. package/dist/schema/call/personal.d.ts +1 -1
  155. package/dist/schema/call/progress.d.ts +1 -1
  156. package/dist/schema/call/proof.d.ts +2 -2
  157. package/dist/schema/call/repository.d.ts +1 -1
  158. package/dist/schema/call/repository.js +1 -1
  159. package/dist/schema/call/reward.d.ts +1 -1
  160. package/dist/schema/call/semantic.js +1 -1
  161. package/dist/schema/call/service.d.ts +1 -1
  162. package/dist/schema/call/service.js +1 -1
  163. package/dist/schema/call/treasury.d.ts +1 -1
  164. package/dist/schema/common/index.js +1 -1
  165. package/dist/schema/goal/index.d.ts +317 -0
  166. package/dist/schema/goal/index.js +1 -0
  167. package/dist/schema/goal/planning.d.ts +465 -0
  168. package/dist/schema/goal/planning.js +1 -0
  169. package/dist/schema/index.d.ts +1 -2
  170. package/dist/schema/index.js +1 -1
  171. package/dist/schema/industry-pack/index.d.ts +265 -1
  172. package/dist/schema/industry-pack/index.js +1 -1
  173. package/dist/schema/industry-pack/modes.d.ts +268 -0
  174. package/dist/schema/industry-pack/modes.js +1 -0
  175. package/dist/schema/local/index.js +1 -1
  176. package/dist/schema/operations.d.ts +216 -19
  177. package/dist/schema/operations.js +1 -1
  178. package/dist/schema/permission/index.d.ts +1 -0
  179. package/dist/schema/permission/index.js +1 -1
  180. package/dist/schema/persona/index.d.ts +40 -0
  181. package/dist/schema/persona/index.js +1 -1
  182. package/dist/schema/query/bi.d.ts +783 -0
  183. package/dist/schema/query/bi.js +1 -0
  184. package/dist/schema/query/index.d.ts +661 -0
  185. package/dist/schema/query/index.js +1 -1
  186. package/dist/schema/schema-version.js +1 -1
  187. package/dist/schema/utils/skills-recommendation.d.ts +0 -1
  188. package/dist/schema/utils/skills-recommendation.js +1 -1
  189. package/dist/schema-query-impl/index.js +1 -1
  190. package/dist/schemas/account_operation.output.json +3 -3
  191. package/dist/schemas/account_operation.schema.json +2 -2
  192. package/dist/schemas/bridge_operation.output.json +2 -2
  193. package/dist/schemas/bridge_operation.schema.json +12 -12
  194. package/dist/schemas/config_operation.output.json +1 -1
  195. package/dist/schemas/config_operation.schema.json +1 -1
  196. package/dist/schemas/goal_operation.schema.json +1016 -0
  197. package/dist/schemas/guard2file.schema.json +3 -3
  198. package/dist/schemas/index.json +12 -13
  199. package/dist/schemas/industry_pack_operation.output.json +898 -0
  200. package/dist/schemas/industry_pack_operation.schema.json +217 -2
  201. package/dist/schemas/local_info_operation.output.json +2 -2
  202. package/dist/schemas/local_mark_operation.output.json +2 -2
  203. package/dist/schemas/machineNode2file.schema.json +3 -3
  204. package/dist/schemas/messenger_operation.output.json +2 -2
  205. package/dist/schemas/monitor_events.output.json +78 -3
  206. package/dist/schemas/monitor_events.schema.json +24 -1
  207. package/dist/schemas/monitor_subscription.output.json +1462 -0
  208. package/dist/schemas/monitor_subscription.schema.json +327 -0
  209. package/dist/schemas/onchain_events.output.json +4 -4
  210. package/dist/schemas/onchain_operations.output.json +2 -2
  211. package/dist/schemas/onchain_operations.schema.json +59 -59
  212. package/dist/schemas/onchain_operations_allocation.schema.json +3 -3
  213. package/dist/schemas/onchain_operations_arbitration.schema.json +3 -3
  214. package/dist/schemas/onchain_operations_contact.schema.json +4 -4
  215. package/dist/schemas/onchain_operations_demand.schema.json +4 -4
  216. package/dist/schemas/onchain_operations_gen_passport.schema.json +3 -3
  217. package/dist/schemas/onchain_operations_gen_proof.schema.json +3 -3
  218. package/dist/schemas/onchain_operations_guard.schema.json +3 -3
  219. package/dist/schemas/onchain_operations_machine.schema.json +3 -3
  220. package/dist/schemas/onchain_operations_order.schema.json +3 -3
  221. package/dist/schemas/onchain_operations_payment.schema.json +3 -3
  222. package/dist/schemas/onchain_operations_permission.schema.json +3 -3
  223. package/dist/schemas/onchain_operations_personal.schema.json +3 -3
  224. package/dist/schemas/onchain_operations_progress.schema.json +3 -3
  225. package/dist/schemas/onchain_operations_proof.schema.json +3 -3
  226. package/dist/schemas/onchain_operations_repository.schema.json +5 -5
  227. package/dist/schemas/onchain_operations_reward.schema.json +3 -3
  228. package/dist/schemas/onchain_operations_service.schema.json +4 -4
  229. package/dist/schemas/onchain_operations_treasury.schema.json +3 -3
  230. package/dist/schemas/onchain_table_data.output.json +346 -2
  231. package/dist/schemas/onchain_table_data.schema.json +22 -22
  232. package/dist/schemas/permission_operation.schema.json +6 -2
  233. package/dist/schemas/persona_operation.output.json +145 -0
  234. package/dist/schemas/persona_operation.schema.json +28 -2
  235. package/dist/schemas/query_toolkit.output.json +1274 -15
  236. package/dist/schemas/query_toolkit.schema.json +412 -11
  237. package/dist/schemas/workflow_operation.schema.json +4 -4
  238. package/dist/task/ProcessStore.d.ts +81 -0
  239. package/dist/task/ProcessStore.js +1 -0
  240. package/dist/task/playbook.d.ts +11 -0
  241. package/dist/task/playbook.js +1 -0
  242. package/dist/task/stage-gate.d.ts +22 -0
  243. package/dist/task/stage-gate.js +1 -0
  244. package/dist/{project → task}/substep-trace.d.ts +6 -45
  245. package/dist/task/types.d.ts +120 -0
  246. package/dist/task/types.js +1 -0
  247. package/dist/tools/handlers/config.js +1 -1
  248. package/dist/tools/handlers/goal.d.ts +4 -0
  249. package/dist/tools/handlers/goal.js +1 -0
  250. package/dist/tools/handlers/industry-pack.js +1 -1
  251. package/dist/tools/handlers/monitor.d.ts +24 -0
  252. package/dist/tools/handlers/monitor.js +1 -1
  253. package/dist/tools/handlers/network.d.ts +1 -0
  254. package/dist/tools/handlers/network.js +1 -0
  255. package/dist/tools/handlers/onchain.js +1 -1
  256. package/dist/tools/handlers/permission.js +1 -1
  257. package/dist/tools/handlers/persona.js +1 -1
  258. package/dist/tools/handlers/query.js +1 -1
  259. package/dist/tools/handlers/watch.js +1 -1
  260. package/dist/tools/index.d.ts +2 -0
  261. package/dist/tools/index.js +1 -1
  262. package/dist/tools/shared.js +1 -1
  263. package/dist/tools/wrap.js +1 -1
  264. package/package.json +5 -4
  265. package/dist/harness/checkpoint.d.ts +0 -8
  266. package/dist/harness/checkpoint.js +0 -1
  267. package/dist/knowledge/deployment-scanner.d.ts +0 -66
  268. package/dist/knowledge/deployment-scanner.js +0 -1
  269. package/dist/project/business-puzzle.js +0 -1
  270. package/dist/project/context-assembly.js +0 -1
  271. package/dist/project/deployment-bridge.d.ts +0 -5
  272. package/dist/project/deployment-bridge.js +0 -1
  273. package/dist/project/deployment-doc.d.ts +0 -190
  274. package/dist/project/deployment-doc.js +0 -1
  275. package/dist/project/edit-planner.d.ts +0 -123
  276. package/dist/project/edit-planner.js +0 -1
  277. package/dist/project/evaluation-fix.spec.d.ts +0 -1
  278. package/dist/project/evaluation-fix.spec.js +0 -1
  279. package/dist/project/evaluation.d.ts +0 -127
  280. package/dist/project/evaluation.js +0 -1
  281. package/dist/project/graph-builder.d.ts +0 -51
  282. package/dist/project/graph-builder.js +0 -1
  283. package/dist/project/graph.d.ts +0 -70
  284. package/dist/project/graph.js +0 -1
  285. package/dist/project/handlers.d.ts +0 -524
  286. package/dist/project/handlers.js +0 -1
  287. package/dist/project/index.d.ts +0 -91
  288. package/dist/project/index.js +0 -1
  289. package/dist/project/intent-analyzer.js +0 -1
  290. package/dist/project/machine-panorama.js +0 -1
  291. package/dist/project/merchant-guide.js +0 -1
  292. package/dist/project/mode-actions.js +0 -1
  293. package/dist/project/namespace.d.ts +0 -72
  294. package/dist/project/namespace.js +0 -1
  295. package/dist/project/object-panorama.js +0 -1
  296. package/dist/project/participation-radar.js +0 -1
  297. package/dist/project/pipeline-actions.js +0 -1
  298. package/dist/project/project-store.d.ts +0 -110
  299. package/dist/project/project-store.js +0 -1
  300. package/dist/project/query.d.ts +0 -43
  301. package/dist/project/query.js +0 -1
  302. package/dist/project/risk-aggregator.js +0 -1
  303. package/dist/project/semantic-assembler.d.ts +0 -93
  304. package/dist/project/semantic-assembler.js +0 -1
  305. package/dist/project/service-panorama.js +0 -1
  306. package/dist/project/stage-gate.d.ts +0 -52
  307. package/dist/project/stage-gate.js +0 -1
  308. package/dist/project/task-tracker.d.ts +0 -30
  309. package/dist/project/task-tracker.js +0 -1
  310. package/dist/schema/project/index.d.ts +0 -2021
  311. package/dist/schema/project/index.js +0 -1
  312. package/dist/schema/task-status.d.ts +0 -62
  313. package/dist/schema/task-status.js +0 -1
  314. package/dist/schemas/project_operation.output.json +0 -7877
  315. package/dist/schemas/project_operation.schema.json +0 -1139
  316. package/dist/schemas/query_task_status.output.json +0 -211
  317. package/dist/schemas/query_task_status.schema.json +0 -18
  318. package/dist/tools/handlers/project.d.ts +0 -2
  319. package/dist/tools/handlers/project.js +0 -1
  320. package/dist/tools/handlers/task-status.d.ts +0 -2
  321. package/dist/tools/handlers/task-status.js +0 -1
  322. /package/dist/{project → playbooks/service-build}/business-puzzle.d.ts +0 -0
  323. /package/dist/{project → playbooks/service-build}/game-theory.js +0 -0
  324. /package/dist/{project → playbooks/service-build}/machine-nodes.d.ts +0 -0
  325. /package/dist/{project → playbooks/service-build}/machine-nodes.js +0 -0
  326. /package/dist/{project → playbooks/service-build}/object-type.d.ts +0 -0
  327. /package/dist/{project → playbooks/service-build}/object-type.js +0 -0
  328. /package/dist/{project → playbooks/service-build}/reverse-mapping.d.ts +0 -0
  329. /package/dist/{project → playbooks/service-build}/reverse-mapping.js +0 -0
  330. /package/dist/{project → playbooks/service-build}/risk-aggregator.d.ts +0 -0
  331. /package/dist/{project → playbooks/service-build}/semantic-graph.js +0 -0
  332. /package/dist/{project → playbooks/service-build}/workflow-design-assessment.d.ts +0 -0
  333. /package/dist/{project → playbooks/service-build}/workflow-design-assessment.js +0 -0
  334. /package/dist/{project → task}/substep-trace.js +0 -0
package/README.md CHANGED
@@ -63,13 +63,13 @@ wowok-skills init --target all # All 10 supported clients
63
63
  | `wowok-planner` | 🛠️ Shared | Planning — converts natural language intent into Object Dependency Graph (ODG) |
64
64
  | `wowok-auditor` | 🛠️ Shared | Pre-publish audit — Guard completeness, Machine soundness, 32 audit checks |
65
65
 
66
- **Deprecated** (sunk to MCP knowledge layer — no longer installed as skills; their content is served by `schema_query` / `project_operation`):
66
+ **Deprecated** (sunk to MCP knowledge layer — no longer installed as skills; their content is served by `schema_query` / `industry_pack_operation`):
67
67
 
68
68
  | Skill | Replaced By |
69
69
  |-------|-------------|
70
70
  | `wowok-tools` | `schema_query action='get_tool_reference'` |
71
71
  | `wowok-safety` | `schema_query action='get_safety_rules'` + runtime confirm-gate |
72
72
  | `wowok-guard` | `schema_query action='get_guard_design_patterns'` |
73
- | `wowok-scenario` | `project_operation` (recommend_industry / create_project) |
73
+ | `wowok-scenario` | `industry_pack_operation` (recommend_industry / list_modes) |
74
74
 
75
75
  > **Tip:** `wowok-output` is always loaded. Add role-specific skills (`wowok-order`, `wowok-provider`, `wowok-arbitrator`) as needed. Guard design, safety rules, tool reference, and industry mode content are now served directly by the MCP server — no skill installation required.
@@ -1,4 +1,4 @@
1
- export type ServiceName = "confirm_gate" | "project_service" | "harness" | "graph_persist" | "semantic_rich" | "experience_layer" | "customer_intelligence" | "order_monitor" | "industry_evolution";
1
+ export type ServiceName = "confirm_gate" | "harness" | "semantic_rich" | "experience_layer" | "customer_intelligence" | "order_monitor" | "industry_evolution";
2
2
  export type HarnessTier = "off" | "lightweight" | "full";
3
3
  interface ServiceMeta {
4
4
  name: ServiceName;
@@ -1 +1 @@
1
- import{readFileSync,writeFileSync,existsSync,mkdirSync}from'fs';import{dirname,join}from'path';import{getWowMcpDir}from'@wowok/wowok';export const SERVICE_REGISTRY=[{'name':'confirm_gate','description':'Security\x20confirmation\x20gate\x20—\x20prompts\x20user\x20confirmation\x20before\x20amount,\x20default\x20account,\x20publish,\x20or\x20irreversible\x20operations','defaultEnabled':!![],'envVar':'WOWOK_CONFIRM_GATE','remindOnToggle':!![]},{'name':'project_service','description':'Project\x20namespace\x20+\x20object\x20dependency\x20graph\x20—\x20auto-injects\x20project:/type:\x20tags,\x20maintains\x20DAG','defaultEnabled':!![],'envVar':'WOWOK_PROJECT_SERVICE','remindOnToggle':!![]},{'name':'harness','description':'L4\x20Harness\x20verify/recover\x20loop\x20—\x20automatically\x20validates\x20expected\x20results\x20before\x20and\x20after\x20operations.\x20GLM5:\x20default\x20ON\x20with\x20tiered\x20enforcement\x20(off/lightweight/full).','defaultEnabled':!![],'envVar':'WOWOK_HARNESS_ENABLED','remindOnToggle':!![]},{'name':'graph_persist','description':'Object\x20graph\x20persistence\x20—\x20saves\x20in-memory\x20DAG\x20to\x20local\x20file,\x20retained\x20across\x20sessions','defaultEnabled':![],'envVar':'WOWOK_GRAPH_PERSIST','remindOnToggle':!![]},{'name':'semantic_rich','description':'Semantic\x20layer\x20enrichment\x20—\x20attaches\x20extra\x20reminder\x20info\x20such\x20as\x20service_status\x20in\x20responses','defaultEnabled':!![],'envVar':'WOWOK_SEMANTIC_RICH','remindOnToggle':![]},{'name':'experience_layer','description':'Real-time\x20experience\x20layer\x20—\x20intent\x20distillation\x20+\x20user\x20profiling\x20+\x20experience\x20reuse,\x20gets\x20smarter\x20with\x20usage','defaultEnabled':!![],'envVar':'WOWOK_EXPERIENCE_LAYER','remindOnToggle':!![]},{'name':'customer_intelligence','description':'Buyer\x20intelligence\x20(Phase\x203\x20C-3)\x20—\x20attaches\x20risk\x20reminders,\x20preference\x20matching,\x20and\x20blocking\x20alerts\x20in\x20semantic.customer_advice\x20for\x20order/query\x20operations','defaultEnabled':!![],'envVar':'WOWOK_CUSTOMER_INTELLIGENCE','remindOnToggle':!![]},{'name':'order_monitor','description':'In-progress\x20order\x20monitoring\x20(Phase\x203\x20C-3.2)\x20—\x20detects\x20Progress\x20stalls\x20/\x20compensation\x20balance\x20changes\x20/\x20Messenger\x20timeouts;\x20disabled\x20by\x20default,\x20must\x20be\x20actively\x20enabled','defaultEnabled':![],'envVar':'WOWOK_ORDER_MONITOR','remindOnToggle':!![]},{'name':'industry_evolution','description':'Industry\x20specialization\x20evolution\x20(Phase\x204)\x20—\x20AI-Human-WOW\x20flywheel\x20loop:\x20captures\x20industry\x20signals\x20+\x20updates\x20knowledge\x20+\x20injects\x20evolution\x20context','defaultEnabled':!![],'envVar':'WOWOK_INDUSTRY_EVOLUTION','remindOnToggle':!![]}];const SERVICE_MAP=new Map(SERVICE_REGISTRY['map'](a=>[a['name'],a])),runtimeOverrides=new Map();let harnessTierOverride;function configFilePath(){if(process['env']['WOWOK_CONFIG_DIR'])return join(process['env']['WOWOK_CONFIG_DIR'],'runtime-config.json');return join(getWowMcpDir(),'runtime-config.json');}function isPersistEnabled(){const a=process['env']['WOWOK_RUNTIME_CONFIG_PERSIST'];return a==='1'||a==='true';}function loadPersisted(){if(!isPersistEnabled())return null;try{const a=configFilePath();if(!existsSync(a))return null;const b=readFileSync(a,'utf-8'),c=JSON['parse'](b);if(c&&typeof c==='object'&&c['services'])return c;}catch{}return null;}function savePersisted(){if(!isPersistEnabled())return;try{const a=configFilePath(),b=dirname(a);if(!existsSync(b))mkdirSync(b,{'recursive':!![]});const c={'version':0x2,'services':Object['fromEntries'](runtimeOverrides),'harness_tier':harnessTierOverride,'updatedAt':Date['now']()};writeFileSync(a,JSON['stringify'](c,null,0x2),'utf-8');}catch{}}{const persisted=loadPersisted();if(persisted){for(const [name,enabled]of Object['entries'](persisted['services'])){SERVICE_MAP['has'](name)&&runtimeOverrides['set'](name,enabled);}persisted['harness_tier']&&(harnessTierOverride=persisted['harness_tier']);}}export function getHarnessTier(){if(!isEnabled('harness'))return'off';if(harnessTierOverride)return harnessTierOverride;const a=process['env']['WOWOK_HARNESS_TIER'];if(a==='off'||a==='lightweight'||a==='full')return a;return'lightweight';}export function setHarnessTier(a){harnessTierOverride=a,savePersisted();}export function resetHarnessTier(){harnessTierOverride=undefined,savePersisted();}export function isEnabled(a){if(runtimeOverrides['has'](a))return runtimeOverrides['get'](a);const b=SERVICE_MAP['get'](a);if(b){const c=process['env'][b['envVar']];if(c!==undefined){if(c==='0'||c==='false')return![];if(c==='1'||c==='true')return!![];}return b['defaultEnabled'];}return![];}export function setEnabled(a,b){runtimeOverrides['set'](a,b),savePersisted();}export function toggle(a){const b=!isEnabled(a);return setEnabled(a,b),b;}export function reset(a){runtimeOverrides['delete'](a),savePersisted();}export function listServices(){return SERVICE_REGISTRY['map'](a=>{const b=runtimeOverrides['has'](a['name']),c=isEnabled(a['name']);return{'name':a['name'],'enabled':c,'defaultEnabled':a['defaultEnabled'],'description':a['description'],'overridden':b,'envVar':a['envVar'],'reminder':a['remindOnToggle']?buildReminder(a['name'],c):undefined};});}export function getServiceInfo(a){const b=SERVICE_MAP['get'](a);if(!b)return undefined;return{'name':b['name'],'enabled':isEnabled(b['name']),'defaultEnabled':b['defaultEnabled'],'description':b['description'],'overridden':runtimeOverrides['has'](b['name']),'envVar':b['envVar'],'reminder':b['remindOnToggle']?buildReminder(b['name'],isEnabled(b['name'])):undefined};}function buildReminder(a,b){switch(a){case'confirm_gate':return b?'ConfirmGate\x20is\x20ON:\x20prompts\x20confirmation\x20before\x20amount,\x20default\x20account,\x20publish,\x20or\x20irreversible\x20operations.\x20To\x20disable,\x20call\x20config_operation\x20toggle\x20confirm_gate.':'ConfirmGate\x20is\x20OFF:\x20operations\x20will\x20execute\x20directly\x20without\x20confirmation.\x20Note\x20the\x20risk\x20of\x20irreversible\x20operations.\x20To\x20re-enable,\x20call\x20config_operation\x20toggle\x20confirm_gate.';case'project_service':return b?'ProjectService\x20is\x20ON:\x20auto-injects\x20project:/type:\x20tags\x20on\x20object\x20creation\x20and\x20maintains\x20the\x20dependency\x20graph.\x20To\x20disable,\x20call\x20config_operation\x20toggle\x20project_service.':'ProjectService\x20is\x20OFF:\x20objects\x20will\x20not\x20be\x20automatically\x20tagged\x20with\x20project\x20membership.\x20To\x20enable,\x20call\x20config_operation\x20toggle\x20project_service.';case'harness':return b?'Harness\x20is\x20ON\x20(tier:\x20'+getHarnessTier()+'):\x20automatically\x20validates\x20expected\x20results\x20around\x20operations.\x20lightweight=Plan+Verify;\x20full=Plan+Expect+Verify+Recover+Checkpoint.\x20To\x20change\x20tier,\x20set\x20WOWOK_HARNESS_TIER\x20or\x20call\x20harness\x20API.\x20To\x20disable,\x20call\x20config_operation\x20toggle\x20harness.':'Harness\x20is\x20OFF.\x20GLM5\x20recommends\x20keeping\x20it\x20ON\x20(lightweight\x20tier)\x20for\x20safety.\x20To\x20enable,\x20call\x20config_operation\x20toggle\x20harness.';case'graph_persist':return b?'Graph\x20persistence\x20is\x20ON:\x20the\x20object\x20dependency\x20graph\x20will\x20be\x20saved\x20to\x20~/.wow/mcp/project-graph.json.':'Graph\x20persistence\x20is\x20OFF:\x20the\x20dependency\x20graph\x20exists\x20only\x20in\x20memory\x20and\x20will\x20be\x20lost\x20on\x20process\x20restart.\x20To\x20persist,\x20call\x20config_operation\x20toggle\x20graph_persist.';case'semantic_rich':return undefined;case'experience_layer':return b?'Experience\x20layer\x20is\x20ON:\x20provides\x20suggestions\x20in\x20semantic.experience\x20based\x20on\x20historical\x20operation\x20experience.\x20To\x20disable,\x20call\x20config_operation\x20toggle\x20experience_layer.':'Experience\x20layer\x20is\x20OFF:\x20no\x20experience\x20suggestions\x20will\x20be\x20attached.\x20To\x20enable,\x20call\x20config_operation\x20toggle\x20experience_layer.';case'customer_intelligence':return b?'Customer\x20intelligence\x20is\x20ON:\x20order/query\x20operations\x20will\x20attach\x20risk/preference/blocking\x20alerts\x20in\x20semantic.customer_advice.\x20To\x20disable,\x20call\x20config_operation\x20toggle\x20customer_intelligence.':'Customer\x20intelligence\x20is\x20OFF:\x20semantic.customer_advice\x20will\x20not\x20be\x20populated.\x20To\x20enable,\x20call\x20config_operation\x20toggle\x20customer_intelligence.';case'order_monitor':return b?'Order\x20monitor\x20is\x20ON:\x20detects\x20Progress\x20stalls,\x20compensation\x20balance\x20changes,\x20and\x20Messenger\x20timeouts.\x20To\x20disable,\x20call\x20config_operation\x20toggle\x20order_monitor.':'Order\x20monitor\x20is\x20OFF:\x20will\x20not\x20actively\x20detect\x20order\x20anomalies.\x20To\x20enable\x20(recommended\x20when\x20there\x20are\x20active\x20orders),\x20call\x20config_operation\x20toggle\x20order_monitor.';}}export const RUNTIME_CONFIG_VERSION=0x1;
1
+ import{readFileSync,writeFileSync,existsSync,mkdirSync}from'fs';import{dirname,join}from'path';import{getWowMcpDir}from'@wowok/wowok';export const SERVICE_REGISTRY=[{'name':'confirm_gate','description':'Security\x20confirmation\x20gate\x20—\x20prompts\x20user\x20confirmation\x20before\x20amount,\x20default\x20account,\x20publish,\x20or\x20irreversible\x20operations','defaultEnabled':!![],'envVar':'WOWOK_CONFIRM_GATE','remindOnToggle':!![]},{'name':'harness','description':'L4\x20Harness\x20verify/recover\x20loop\x20—\x20automatically\x20validates\x20expected\x20results\x20before\x20and\x20after\x20operations.\x20GLM5:\x20default\x20ON\x20with\x20tiered\x20enforcement\x20(off/lightweight/full).','defaultEnabled':!![],'envVar':'WOWOK_HARNESS_ENABLED','remindOnToggle':!![]},{'name':'semantic_rich','description':'Semantic\x20layer\x20enrichment\x20—\x20attaches\x20extra\x20reminder\x20info\x20such\x20as\x20service_status\x20in\x20responses','defaultEnabled':!![],'envVar':'WOWOK_SEMANTIC_RICH','remindOnToggle':![]},{'name':'experience_layer','description':'Real-time\x20experience\x20layer\x20—\x20intent\x20distillation\x20+\x20user\x20profiling\x20+\x20experience\x20reuse,\x20gets\x20smarter\x20with\x20usage','defaultEnabled':!![],'envVar':'WOWOK_EXPERIENCE_LAYER','remindOnToggle':!![]},{'name':'customer_intelligence','description':'Buyer\x20intelligence\x20(Phase\x203\x20C-3)\x20—\x20attaches\x20risk\x20reminders,\x20preference\x20matching,\x20and\x20blocking\x20alerts\x20in\x20semantic.customer_advice\x20for\x20order/query\x20operations','defaultEnabled':!![],'envVar':'WOWOK_CUSTOMER_INTELLIGENCE','remindOnToggle':!![]},{'name':'order_monitor','description':'In-progress\x20order\x20monitoring\x20(Phase\x203\x20C-3.2)\x20—\x20detects\x20Progress\x20stalls\x20/\x20compensation\x20balance\x20changes\x20/\x20Messenger\x20timeouts;\x20disabled\x20by\x20default,\x20must\x20be\x20actively\x20enabled','defaultEnabled':![],'envVar':'WOWOK_ORDER_MONITOR','remindOnToggle':!![]},{'name':'industry_evolution','description':'Industry\x20specialization\x20evolution\x20(Phase\x204)\x20—\x20AI-Human-WOW\x20flywheel\x20loop:\x20captures\x20industry\x20signals\x20+\x20updates\x20knowledge\x20+\x20injects\x20evolution\x20context','defaultEnabled':!![],'envVar':'WOWOK_INDUSTRY_EVOLUTION','remindOnToggle':!![]}];const SERVICE_MAP=new Map(SERVICE_REGISTRY['map'](a=>[a['name'],a])),runtimeOverrides=new Map();let harnessTierOverride;function configFilePath(){if(process['env']['WOWOK_CONFIG_DIR'])return join(process['env']['WOWOK_CONFIG_DIR'],'runtime-config.json');return join(getWowMcpDir(),'runtime-config.json');}function isPersistEnabled(){const a=process['env']['WOWOK_RUNTIME_CONFIG_PERSIST'];return a==='1'||a==='true';}function loadPersisted(){if(!isPersistEnabled())return null;try{const a=configFilePath();if(!existsSync(a))return null;const b=readFileSync(a,'utf-8'),c=JSON['parse'](b);if(c&&typeof c==='object'&&c['services'])return c;}catch{}return null;}function savePersisted(){if(!isPersistEnabled())return;try{const a=configFilePath(),b=dirname(a);if(!existsSync(b))mkdirSync(b,{'recursive':!![]});const c={'version':0x2,'services':Object['fromEntries'](runtimeOverrides),'harness_tier':harnessTierOverride,'updatedAt':Date['now']()};writeFileSync(a,JSON['stringify'](c,null,0x2),'utf-8');}catch{}}{const persisted=loadPersisted();if(persisted){for(const [name,enabled]of Object['entries'](persisted['services'])){SERVICE_MAP['has'](name)&&runtimeOverrides['set'](name,enabled);}persisted['harness_tier']&&(harnessTierOverride=persisted['harness_tier']);}}export function getHarnessTier(){if(!isEnabled('harness'))return'off';if(harnessTierOverride)return harnessTierOverride;const a=process['env']['WOWOK_HARNESS_TIER'];if(a==='off'||a==='lightweight'||a==='full')return a;return'lightweight';}export function setHarnessTier(a){harnessTierOverride=a,savePersisted();}export function resetHarnessTier(){harnessTierOverride=undefined,savePersisted();}export function isEnabled(a){if(runtimeOverrides['has'](a))return runtimeOverrides['get'](a);const b=SERVICE_MAP['get'](a);if(b){const c=process['env'][b['envVar']];if(c!==undefined){if(c==='0'||c==='false')return![];if(c==='1'||c==='true')return!![];}return b['defaultEnabled'];}return![];}export function setEnabled(a,b){runtimeOverrides['set'](a,b),savePersisted();}export function toggle(a){const b=!isEnabled(a);return setEnabled(a,b),b;}export function reset(a){runtimeOverrides['delete'](a),savePersisted();}export function listServices(){return SERVICE_REGISTRY['map'](a=>{const b=runtimeOverrides['has'](a['name']),c=isEnabled(a['name']);return{'name':a['name'],'enabled':c,'defaultEnabled':a['defaultEnabled'],'description':a['description'],'overridden':b,'envVar':a['envVar'],'reminder':a['remindOnToggle']?buildReminder(a['name'],c):undefined};});}export function getServiceInfo(a){const b=SERVICE_MAP['get'](a);if(!b)return undefined;return{'name':b['name'],'enabled':isEnabled(b['name']),'defaultEnabled':b['defaultEnabled'],'description':b['description'],'overridden':runtimeOverrides['has'](b['name']),'envVar':b['envVar'],'reminder':b['remindOnToggle']?buildReminder(b['name'],isEnabled(b['name'])):undefined};}function buildReminder(a,b){switch(a){case'confirm_gate':return b?'ConfirmGate\x20is\x20ON:\x20prompts\x20confirmation\x20before\x20amount,\x20default\x20account,\x20publish,\x20or\x20irreversible\x20operations.\x20To\x20disable,\x20call\x20config_operation\x20toggle\x20confirm_gate.':'ConfirmGate\x20is\x20OFF:\x20operations\x20will\x20execute\x20directly\x20without\x20confirmation.\x20Note\x20the\x20risk\x20of\x20irreversible\x20operations.\x20To\x20re-enable,\x20call\x20config_operation\x20toggle\x20confirm_gate.';case'harness':return b?'Harness\x20is\x20ON\x20(tier:\x20'+getHarnessTier()+'):\x20automatically\x20validates\x20expected\x20results\x20around\x20operations.\x20lightweight=Plan+Verify;\x20full=Plan+Expect+Verify+Recover.\x20To\x20change\x20tier,\x20set\x20WOWOK_HARNESS_TIER\x20or\x20call\x20harness\x20API.\x20To\x20disable,\x20call\x20config_operation\x20toggle\x20harness.':'Harness\x20is\x20OFF.\x20GLM5\x20recommends\x20keeping\x20it\x20ON\x20(lightweight\x20tier)\x20for\x20safety.\x20To\x20enable,\x20call\x20config_operation\x20toggle\x20harness.';case'semantic_rich':return undefined;case'experience_layer':return b?'Experience\x20layer\x20is\x20ON:\x20provides\x20suggestions\x20in\x20semantic.experience\x20based\x20on\x20historical\x20operation\x20experience.\x20To\x20disable,\x20call\x20config_operation\x20toggle\x20experience_layer.':'Experience\x20layer\x20is\x20OFF:\x20no\x20experience\x20suggestions\x20will\x20be\x20attached.\x20To\x20enable,\x20call\x20config_operation\x20toggle\x20experience_layer.';case'customer_intelligence':return b?'Customer\x20intelligence\x20is\x20ON:\x20order/query\x20operations\x20will\x20attach\x20risk/preference/blocking\x20alerts\x20in\x20semantic.customer_advice.\x20To\x20disable,\x20call\x20config_operation\x20toggle\x20customer_intelligence.':'Customer\x20intelligence\x20is\x20OFF:\x20semantic.customer_advice\x20will\x20not\x20be\x20populated.\x20To\x20enable,\x20call\x20config_operation\x20toggle\x20customer_intelligence.';case'order_monitor':return b?'Order\x20monitor\x20is\x20ON:\x20detects\x20Progress\x20stalls,\x20compensation\x20balance\x20changes,\x20and\x20Messenger\x20timeouts.\x20To\x20disable,\x20call\x20config_operation\x20toggle\x20order_monitor.':'Order\x20monitor\x20is\x20OFF:\x20will\x20not\x20actively\x20detect\x20order\x20anomalies.\x20To\x20enable\x20(recommended\x20when\x20there\x20are\x20active\x20orders),\x20call\x20config_operation\x20toggle\x20order_monitor.';}}export const RUNTIME_CONFIG_VERSION=0x1;
@@ -134,8 +134,7 @@
134
134
  },
135
135
  "env": {
136
136
  "network": "testnet",
137
- "no_cache": true,
138
- "project": "ziroom"
137
+ "no_cache": true
139
138
  }
140
139
  },
141
140
  "notes": [
@@ -29,8 +29,7 @@
29
29
  },
30
30
  "env": {
31
31
  "network": "testnet",
32
- "no_cache": true,
33
- "project": "ziroom"
32
+ "no_cache": true
34
33
  }
35
34
  },
36
35
  "notes": [
@@ -23,8 +23,7 @@
23
23
  },
24
24
  "env": {
25
25
  "network": "testnet",
26
- "no_cache": true,
27
- "project": "ziroom"
26
+ "no_cache": true
28
27
  }
29
28
  },
30
29
  "notes": [
@@ -1 +1 @@
1
- import{extractSignals}from'./intent-distill.js';const MAX_HISTORY=0xc8,history=[];export function recordSignature(a){try{history['push'](a),history['length']>MAX_HISTORY&&history['shift']();}catch{}}export function findMatches(a,b,c,d=0x3){try{const e=extractSignals(b,c),f=Date['now'](),g=history['map'](h=>{const i=computeRelevance(h,a,e,f);return{'signature':h,'relevance':i};})['filter'](h=>h['relevance']>0.3)['sort']((h,i)=>i['relevance']-h['relevance'])['slice'](0x0,d);return g['map'](h=>formatMatch(h['signature'],h['relevance']));}catch{return[];}}function computeRelevance(a,b,c,d){let e=0x0;if(a['intent']===b)e+=0.5;else a['intent']['startsWith'](b['split']('_')[0x0])&&(e+=0.2);const f=Object['keys'](a['signals']);if(f['length']>0x0){const i=f['filter'](j=>{const l=JSON['stringify'](a['signals'][j]),m=JSON['stringify'](c[j]);return l===m;})['length'];e+=i/f['length']*0.3;}const g=(d-a['timestamp'])/(0x3e8*0x3c*0x3c*0x18),h=Math['exp'](-g/0x1e);return e*=h,Math['min'](0x1,e);}function formatMatch(a,b){const c=buildAdvice(a),d=buildAvoid(a);return{'signature':a,'relevance':b,'advice':c,'avoid':d};}function buildAdvice(a){if(a['outcome']==='success'){if(a['recovery_path']&&a['recovery_path']['length']>0x0)return'Last\x20'+a['intent']+'\x20succeeded\x20(after\x20'+a['recovery_path']['length']+'\x20recovery\x20steps),\x20you\x20can\x20follow\x20the\x20same\x20path.';return'Last\x20'+a['intent']+'\x20succeeded,\x20parameter\x20configuration\x20is\x20valid.';}if(a['outcome']==='failed'&&a['error_code'])return'Last\x20'+a['intent']+'\x20failed\x20('+a['error_code']+'),\x20please\x20check\x20the\x20relevant\x20parameters.';return'Last\x20'+a['intent']+'\x20partially\x20succeeded,\x20check\x20result\x20completeness.';}function buildAvoid(a){const b=[];return a['outcome']!=='success'&&a['error_code']&&b['push']('Avoid\x20triggering\x20'+a['error_code']+'\x20error'),a['recovery_path']&&a['recovery_path']['length']>0x0&&b['push']('Note:\x20last\x20time\x20required\x20'+a['recovery_path']['length']+'\x20recovery\x20steps\x20to\x20succeed'),b;}export function getHistory(a){if(a)return history['filter'](b=>b['intent']===a);return[...history];}export function clearHistory(){history['length']=0x0;}export function getHistoryStats(){const a={},b={};for(const c of history){a[c['outcome']]=(a[c['outcome']]??0x0)+0x1,b[c['intent']]=(b[c['intent']]??0x0)+0x1;}return{'total':history['length'],'by_outcome':a,'by_intent':b};}
1
+ import{extractSignals}from'./intent-distill.js';import{appendSignature,clearSignatures,loadSignatures,rewriteSignatures}from'./persistence.js';const MAX_HISTORY=0xc8,history=[];let hydrated=![];function ensureHydrated(){if(hydrated)return;hydrated=!![];try{for(const a of loadSignatures(MAX_HISTORY)){if(a&&typeof a['intent']==='string')history['push'](a);}}catch{}}export function recordSignature(a){try{ensureHydrated(),history['push'](a),history['length']>MAX_HISTORY?(history['shift'](),rewriteSignatures(history)):appendSignature(a);}catch{}}export function findMatches(a,b,c,d=0x3){try{ensureHydrated();const e=extractSignals(b,c),f=Date['now'](),g=history['map'](h=>{const i=computeRelevance(h,a,e,f);return{'signature':h,'relevance':i};})['filter'](h=>h['relevance']>0.3)['sort']((h,i)=>i['relevance']-h['relevance'])['slice'](0x0,d);return g['map'](h=>formatMatch(h['signature'],h['relevance']));}catch{return[];}}function computeRelevance(a,b,c,d){let e=0x0;if(a['intent']===b)e+=0.5;else a['intent']['startsWith'](b['split']('_')[0x0])&&(e+=0.2);const f=Object['keys'](a['signals']);if(f['length']>0x0){const i=f['filter'](j=>{const l=JSON['stringify'](a['signals'][j]),m=JSON['stringify'](c[j]);return l===m;})['length'];e+=i/f['length']*0.3;}const g=(d-a['timestamp'])/(0x3e8*0x3c*0x3c*0x18),h=Math['exp'](-g/0x1e);return e*=h,Math['min'](0x1,e);}function formatMatch(a,b){const c=buildAdvice(a),d=buildAvoid(a);return{'signature':a,'relevance':b,'advice':c,'avoid':d};}function buildAdvice(a){if(a['outcome']==='success'){if(a['recovery_path']&&a['recovery_path']['length']>0x0)return'Last\x20'+a['intent']+'\x20succeeded\x20(after\x20'+a['recovery_path']['length']+'\x20recovery\x20steps),\x20you\x20can\x20follow\x20the\x20same\x20path.';return'Last\x20'+a['intent']+'\x20succeeded,\x20parameter\x20configuration\x20is\x20valid.';}if(a['outcome']==='failed'&&a['error_code'])return'Last\x20'+a['intent']+'\x20failed\x20('+a['error_code']+'),\x20please\x20check\x20the\x20relevant\x20parameters.';return'Last\x20'+a['intent']+'\x20partially\x20succeeded,\x20check\x20result\x20completeness.';}function buildAvoid(a){const b=[];return a['outcome']!=='success'&&a['error_code']&&b['push']('Avoid\x20triggering\x20'+a['error_code']+'\x20error'),a['recovery_path']&&a['recovery_path']['length']>0x0&&b['push']('Note:\x20last\x20time\x20required\x20'+a['recovery_path']['length']+'\x20recovery\x20steps\x20to\x20succeed'),b;}export function getHistory(a){ensureHydrated();if(a)return history['filter'](b=>b['intent']===a);return[...history];}export function clearHistory(){ensureHydrated(),history['length']=0x0,clearSignatures();}export function getHistoryStats(){ensureHydrated();const a={},b={};for(const c of history){a[c['outcome']]=(a[c['outcome']]??0x0)+0x1,b[c['intent']]=(b[c['intent']]??0x0)+0x1;}return{'total':history['length'],'by_outcome':a,'by_intent':b};}
@@ -2,5 +2,6 @@ import { distillIntent, extractSignals } from "./intent-distill.js";
2
2
  import { getProfile, updateFromOperation, resetProfile, getProfileStats } from "./user-profile.js";
3
3
  import { findMatches, recordSignature, getHistory, clearHistory, getHistoryStats } from "./experience-reuse.js";
4
4
  import { getExperienceFeedback, recordOperationOutcome, EXPERIENCE_LAYER_VERSION } from "./realtime-feedback.js";
5
+ import { configureExperiencePersistence } from "./persistence.js";
5
6
  import type { DistilledIntent, ExperienceMatch, ExperienceFeedback, UserProfile, UserIntentSignature } from "./types.js";
6
- export { distillIntent, extractSignals, getProfile, updateFromOperation, resetProfile, getProfileStats, findMatches, recordSignature, getHistory, clearHistory, getHistoryStats, getExperienceFeedback, recordOperationOutcome, EXPERIENCE_LAYER_VERSION, type DistilledIntent, type ExperienceMatch, type ExperienceFeedback, type UserProfile, type UserIntentSignature, };
7
+ export { distillIntent, extractSignals, getProfile, updateFromOperation, resetProfile, getProfileStats, findMatches, recordSignature, getHistory, clearHistory, getHistoryStats, getExperienceFeedback, recordOperationOutcome, configureExperiencePersistence, EXPERIENCE_LAYER_VERSION, type DistilledIntent, type ExperienceMatch, type ExperienceFeedback, type UserProfile, type UserIntentSignature, };
@@ -1 +1 @@
1
- import{distillIntent,extractSignals}from'./intent-distill.js';import{getProfile,updateFromOperation,resetProfile,getProfileStats}from'./user-profile.js';import{findMatches,recordSignature,getHistory,clearHistory,getHistoryStats}from'./experience-reuse.js';import{getExperienceFeedback,recordOperationOutcome,EXPERIENCE_LAYER_VERSION}from'./realtime-feedback.js';export{distillIntent,extractSignals,getProfile,updateFromOperation,resetProfile,getProfileStats,findMatches,recordSignature,getHistory,clearHistory,getHistoryStats,getExperienceFeedback,recordOperationOutcome,EXPERIENCE_LAYER_VERSION};
1
+ import{distillIntent,extractSignals}from'./intent-distill.js';import{getProfile,updateFromOperation,resetProfile,getProfileStats}from'./user-profile.js';import{findMatches,recordSignature,getHistory,clearHistory,getHistoryStats}from'./experience-reuse.js';import{getExperienceFeedback,recordOperationOutcome,EXPERIENCE_LAYER_VERSION}from'./realtime-feedback.js';import{configureExperiencePersistence}from'./persistence.js';export{distillIntent,extractSignals,getProfile,updateFromOperation,resetProfile,getProfileStats,findMatches,recordSignature,getHistory,clearHistory,getHistoryStats,getExperienceFeedback,recordOperationOutcome,configureExperiencePersistence,EXPERIENCE_LAYER_VERSION};
@@ -0,0 +1,6 @@
1
+ export declare function configureExperiencePersistence(opts?: {
2
+ dir?: string;
3
+ enabled?: boolean;
4
+ }): void;
5
+ export declare function persistenceOverrideDir(): string | undefined;
6
+ export declare function persistenceEnabled(): boolean;
@@ -0,0 +1 @@
1
+ let overrideDir,enabled=!![];export function configureExperiencePersistence(a={}){if(a['dir']!==undefined)overrideDir=a['dir'];if(a['enabled']!==undefined)enabled=a['enabled'];}export function persistenceOverrideDir(){return overrideDir;}export function persistenceEnabled(){return enabled;}
@@ -0,0 +1,21 @@
1
+ import type { BuyerSignals, UserIntentSignature, UserProfile } from "./types.js";
2
+ import { configureExperiencePersistence } from "./persistence-config.js";
3
+ export { configureExperiencePersistence };
4
+ export interface ProfileSnapshot {
5
+ profile: UserProfile;
6
+ buyer_signals: BuyerSignals;
7
+ counters: {
8
+ scenario_counts: [string, number][];
9
+ pitfall_counts: [string, number][];
10
+ object_refs: [string, number][];
11
+ success_count: number;
12
+ total_count: number;
13
+ };
14
+ }
15
+ export declare function experienceDir(): string;
16
+ export declare function loadSignatures(limit: number): UserIntentSignature[];
17
+ export declare function appendSignature(sig: UserIntentSignature): void;
18
+ export declare function clearSignatures(): void;
19
+ export declare function rewriteSignatures(sigs: UserIntentSignature[]): void;
20
+ export declare function loadProfileSnapshot(): ProfileSnapshot | undefined;
21
+ export declare function saveProfileSnapshot(snapshot: ProfileSnapshot): void;
@@ -0,0 +1 @@
1
+ import{appendFileSync,existsSync,mkdirSync,readFileSync,renameSync,unlinkSync,writeFileSync}from'fs';import{join}from'path';import{getWowMcpDir}from'@wowok/wowok';import{configureExperiencePersistence,persistenceEnabled,persistenceOverrideDir}from'./persistence-config.js';export{configureExperiencePersistence};export function experienceDir(){return persistenceOverrideDir()??join(getWowMcpDir(),'experience');}function signaturesFile(){return join(experienceDir(),'signatures.jsonl');}function profileFile(){return join(experienceDir(),'profile.json');}function ensureDir(){mkdirSync(experienceDir(),{'recursive':!![]});}export function loadSignatures(a){if(!persistenceEnabled())return[];try{const b=signaturesFile();if(!existsSync(b))return[];const c=[];for(const d of readFileSync(b,'utf8')['split']('\x0a')){const e=d['trim']();if(!e)continue;try{c['push'](JSON['parse'](e));}catch{}}return c['slice'](-a);}catch{return[];}}export function appendSignature(a){if(!persistenceEnabled())return;try{ensureDir(),appendFileSync(signaturesFile(),JSON['stringify'](a)+'\x0a','utf8');}catch{}}export function clearSignatures(){if(!persistenceEnabled())return;try{const a=signaturesFile();if(existsSync(a))unlinkSync(a);}catch{}}export function rewriteSignatures(a){if(!persistenceEnabled())return;try{ensureDir();const b=signaturesFile(),c=b+'.tmp';writeFileSync(c,a['map'](d=>JSON['stringify'](d))['join']('\x0a')+(a['length']?'\x0a':''),'utf8'),renameSync(c,b);}catch{}}export function loadProfileSnapshot(){if(!persistenceEnabled())return undefined;try{const a=profileFile();if(!existsSync(a))return undefined;const b=JSON['parse'](readFileSync(a,'utf8'));if(!b||typeof b!=='object'||!b['profile']||!b['counters'])return undefined;return b;}catch{return undefined;}}export function saveProfileSnapshot(a){if(!persistenceEnabled())return;try{ensureDir();const b=profileFile(),c=b+'.tmp';writeFileSync(c,JSON['stringify'](a),'utf8'),renameSync(c,b);}catch{}}
@@ -1 +1 @@
1
- import{distillIntent,extractSignals}from'./intent-distill.js';import{getProfile,updateFromOperation}from'./user-profile.js';import{findMatches,recordSignature}from'./experience-reuse.js';import{EXPERIENCE_LAYER_VERSION}from'./types.js';import{isEnabled as a37a}from'../config/index.js';import{recordIndustrySignal}from'../knowledge/flywheel-loop.js';export{EXPERIENCE_LAYER_VERSION};export function getExperienceFeedback(a,b,c){try{const d=distillIntent(a,b,c),e=findMatches(d['primary_intent'],a,b,0x3);if(e['length']===0x0)return undefined;const f=e[0x0],g=getProfile();return formatFeedback(f,e,d['scenario'],g);}catch{return undefined;}}export function recordOperationOutcome(a,b,c,d,e,f=[]){try{const g=distillIntent(a,b,c),h=extractSignals(a,b);recordSignature({'intent':g['primary_intent'],'scenario':g['scenario'],'signals':h,'timestamp':Date['now'](),'outcome':d,'error_code':e}),updateFromOperation(g['primary_intent'],g['scenario'],d,e,f);try{if(a37a('industry_evolution')){const i=typeof b?.['industry']==='string'&&b['industry']['trim']()?b['industry']['trim']():undefined;if(i){const j=d==='success'?{'success':!![]}:{'success':![],'error_code':e};recordIndustrySignal(i,{'type':a,'data':b},j);}}}catch{}}catch{}}function formatFeedback(a,b,c,d){const e=buildAdviceText(a,b,d),f=collectAvoidList(b,d),g=a['relevance'],h=c??a['signature']['scenario'],i={};if(e)i['advice']=e;if(f['length']>0x0)i['avoid']=f;if(g>0x0)i['relevance']=Math['round'](g*0x64)/0x64;if(h)i['matched_scenario']=h;return i;}function buildAdviceText(a,b,c){const d=[];if(a['signature']['outcome']==='success')d['push']('Historically,\x20'+a['signature']['intent']+'\x20operation\x20succeeded');else a['signature']['outcome']==='failed'&&d['push']('Historically,\x20'+a['signature']['intent']+'\x20operation\x20failed\x20('+(a['signature']['error_code']??'unknown\x20error')+'),\x20pay\x20special\x20attention\x20to\x20parameters');return c['expertise_tier']==='novice'&&b['length']>0x0&&d['push']('It\x20is\x20recommended\x20to\x20carefully\x20check\x20parameters\x20before\x20executing'),d['join'](';\x20')||a['advice'];}function collectAvoidList(b,c){const d=new Set();for(const e of b){for(const f of e['avoid']){d['add'](f);}}for(const g of c['frequent_pitfalls']){d['add']('You\x20often\x20make\x20mistakes\x20at\x20the\x20'+g+'\x20step,\x20please\x20be\x20especially\x20careful');}return Array['from'](d)['slice'](0x0,0x5);}
1
+ import{distillIntent,extractSignals}from'./intent-distill.js';import{getProfile,updateFromOperation}from'./user-profile.js';import{findMatches,recordSignature}from'./experience-reuse.js';import{EXPERIENCE_LAYER_VERSION}from'./types.js';import{isEnabled as a39a}from'../config/index.js';import{recordIndustrySignal}from'../knowledge/flywheel-loop.js';export{EXPERIENCE_LAYER_VERSION};export function getExperienceFeedback(a,b,c){try{const d=distillIntent(a,b,c),e=findMatches(d['primary_intent'],a,b,0x3);if(e['length']===0x0)return undefined;const f=e[0x0],g=getProfile();return formatFeedback(f,e,d['scenario'],g);}catch{return undefined;}}export function recordOperationOutcome(a,b,c,d,e,f=[]){try{const g=distillIntent(a,b,c),h=extractSignals(a,b);recordSignature({'intent':g['primary_intent'],'scenario':g['scenario'],'signals':h,'timestamp':Date['now'](),'outcome':d,'error_code':e}),updateFromOperation(g['primary_intent'],g['scenario'],d,e,f);try{if(a39a('industry_evolution')){const i=typeof b?.['industry']==='string'&&b['industry']['trim']()?b['industry']['trim']():undefined;if(i){const j=d==='success'?{'success':!![]}:{'success':![],'error_code':e};recordIndustrySignal(i,{'type':a,'data':b},j);}}}catch{}}catch{}}function formatFeedback(a,b,c,d){const e=buildAdviceText(a,b,d),f=collectAvoidList(b,d),g=a['relevance'],h=c??a['signature']['scenario'],i={};if(e)i['advice']=e;if(f['length']>0x0)i['avoid']=f;if(g>0x0)i['relevance']=Math['round'](g*0x64)/0x64;if(h)i['matched_scenario']=h;return i;}function buildAdviceText(a,b,c){const d=[];if(a['signature']['outcome']==='success')d['push']('Historically,\x20'+a['signature']['intent']+'\x20operation\x20succeeded');else a['signature']['outcome']==='failed'&&d['push']('Historically,\x20'+a['signature']['intent']+'\x20operation\x20failed\x20('+(a['signature']['error_code']??'unknown\x20error')+'),\x20pay\x20special\x20attention\x20to\x20parameters');return c['expertise_tier']==='novice'&&b['length']>0x0&&d['push']('It\x20is\x20recommended\x20to\x20carefully\x20check\x20parameters\x20before\x20executing'),d['join'](';\x20')||a['advice'];}function collectAvoidList(b,c){const d=new Set();for(const e of b){for(const f of e['avoid']){d['add'](f);}}for(const g of c['frequent_pitfalls']){d['add']('You\x20often\x20make\x20mistakes\x20at\x20the\x20'+g+'\x20step,\x20please\x20be\x20especially\x20careful');}return Array['from'](d)['slice'](0x0,0x5);}
@@ -1 +1 @@
1
- let currentProfile={'expertise_tier':'novice','preferred_industries':[],'risk_appetite':'balanced','frequent_pitfalls':[],'reused_objects':[],'preferred_confirmation':'standard','total_operations':0x0,'success_rate':0x1,'last_updated':0x0},buyerSignals={'purchase_count':0x0,'avg_purchase_price_ratio':0x1,'discount_usage_count':0x0,'referral_usage_count':0x0,'dispute_count':0x0},scenarioCounts=new Map(),pitfallCounts=new Map(),objectRefs=new Map(),successCount=0x0,totalCount=0x0;export function getProfile(){return{...currentProfile,'buyer_signals':{...buyerSignals}};}export function recordPurchaseOutcome(a){try{buyerSignals['purchase_count']++;if(a['used_discount'])buyerSignals['discount_usage_count']++;if(a['used_referral'])buyerSignals['referral_usage_count']++;if(a['has_dispute'])buyerSignals['dispute_count']++;if(a['avg_market_price']&&a['avg_market_price']>0x0n){const b=Number(a['price']*0x64n/a['avg_market_price'])/0x64,c=buyerSignals['avg_purchase_price_ratio'],d=buyerSignals['purchase_count'];buyerSignals['avg_purchase_price_ratio']=(c*(d-0x1)+b)/d;}recomputeBuyerInferences();}catch{}}function recomputeBuyerInferences(){const a=buyerSignals['purchase_count'];if(a>=0x3){const b=buyerSignals['avg_purchase_price_ratio'];if(b<0.9)buyerSignals['inferred_price_sensitivity']='high';else b>1.1?buyerSignals['inferred_price_sensitivity']='low':buyerSignals['inferred_price_sensitivity']='medium';}if(a>=0x2){const c=buyerSignals['discount_usage_count']+buyerSignals['referral_usage_count'],d=c/a;buyerSignals['inferred_bargain_hunting']=Math['min'](0x1,d);}}export function getBuyerSignals(){return{...buyerSignals};}export function updateFromOperation(a,b,c,d,e){try{totalCount++;if(c==='success')successCount++;b&&scenarioCounts['set'](b,(scenarioCounts['get'](b)??0x0)+0x1);c!=='success'&&d&&pitfallCounts['set'](d,(pitfallCounts['get'](d)??0x0)+0x1);for(const f of e){objectRefs['set'](f,(objectRefs['get'](f)??0x0)+0x1);}currentProfile=recomputeProfile();}catch{}}function recomputeProfile(){const a=totalCount,b=a>0x0?successCount/a:0x1;let c='novice';if(a>=0x32&&b>=0.9)c='expert';else{if(a>=0xa&&b>=0.7)c='advanced';}const d=Array['from'](scenarioCounts['entries']())['sort']((i,j)=>j[0x1]-i[0x1])['slice'](0x0,0x3)['map'](([i])=>i);let e='balanced';if(a>0x14&&b<0.6)e='aggressive';else{if(a>0x14&&b>0.95)e='conservative';}const f=Array['from'](pitfallCounts['entries']())['filter'](([,i])=>i>=0x2)['sort']((i,j)=>j[0x1]-i[0x1])['slice'](0x0,0x3)['map'](([i])=>i),g=Array['from'](objectRefs['entries']())['filter'](([,i])=>i>=0x2)['sort']((i,j)=>j[0x1]-i[0x1])['slice'](0x0,0x5)['map'](([i])=>i);let h='standard';if(c==='expert')h='minimal';else{if(c==='novice')h='verbose';}return{'expertise_tier':c,'preferred_industries':d,'risk_appetite':e,'frequent_pitfalls':f,'reused_objects':g,'preferred_confirmation':h,'total_operations':a,'success_rate':b,'last_updated':Date['now']()};}export function resetProfile(){currentProfile={'expertise_tier':'novice','preferred_industries':[],'risk_appetite':'balanced','frequent_pitfalls':[],'reused_objects':[],'preferred_confirmation':'verbose','total_operations':0x0,'success_rate':0x1,'last_updated':0x0},scenarioCounts=new Map(),pitfallCounts=new Map(),objectRefs=new Map(),successCount=0x0,totalCount=0x0,buyerSignals={'purchase_count':0x0,'avg_purchase_price_ratio':0x1,'discount_usage_count':0x0,'referral_usage_count':0x0,'dispute_count':0x0};}export function getProfileStats(){return{'total_operations':totalCount,'success_rate':totalCount>0x0?successCount/totalCount:0x1,'top_scenarios':Array['from'](scenarioCounts['entries']())['sort']((c,d)=>d[0x1]-c[0x1])['slice'](0x0,0x5)['map'](([a,b])=>({'scenario':a,'count':b})),'top_pitfalls':Array['from'](pitfallCounts['entries']())['sort']((c,d)=>d[0x1]-c[0x1])['slice'](0x0,0x5)['map'](([a,b])=>({'error_code':a,'count':b}))};}
1
+ import{loadProfileSnapshot,saveProfileSnapshot}from'./persistence.js';let currentProfile={'expertise_tier':'novice','preferred_industries':[],'risk_appetite':'balanced','frequent_pitfalls':[],'reused_objects':[],'preferred_confirmation':'standard','total_operations':0x0,'success_rate':0x1,'last_updated':0x0},buyerSignals={'purchase_count':0x0,'avg_purchase_price_ratio':0x1,'discount_usage_count':0x0,'referral_usage_count':0x0,'dispute_count':0x0},scenarioCounts=new Map(),pitfallCounts=new Map(),objectRefs=new Map(),successCount=0x0,totalCount=0x0,hydrated=![];function ensureHydrated(){if(hydrated)return;hydrated=!![];try{const a=loadProfileSnapshot();if(!a)return;currentProfile=a['profile'],buyerSignals=a['buyer_signals'],scenarioCounts=new Map(a['counters']['scenario_counts']),pitfallCounts=new Map(a['counters']['pitfall_counts']),objectRefs=new Map(a['counters']['object_refs']),successCount=a['counters']['success_count'],totalCount=a['counters']['total_count'];}catch{}}function persist(){try{const a={'profile':currentProfile,'buyer_signals':buyerSignals,'counters':{'scenario_counts':[...scenarioCounts['entries']()],'pitfall_counts':[...pitfallCounts['entries']()],'object_refs':[...objectRefs['entries']()],'success_count':successCount,'total_count':totalCount}};saveProfileSnapshot(a);}catch{}}export function getProfile(){return ensureHydrated(),{...currentProfile,'buyer_signals':{...buyerSignals}};}export function recordPurchaseOutcome(a){try{ensureHydrated(),buyerSignals['purchase_count']++;if(a['used_discount'])buyerSignals['discount_usage_count']++;if(a['used_referral'])buyerSignals['referral_usage_count']++;if(a['has_dispute'])buyerSignals['dispute_count']++;if(a['avg_market_price']&&a['avg_market_price']>0x0n){const b=Number(a['price']*0x64n/a['avg_market_price'])/0x64,c=buyerSignals['avg_purchase_price_ratio'],d=buyerSignals['purchase_count'];buyerSignals['avg_purchase_price_ratio']=(c*(d-0x1)+b)/d;}recomputeBuyerInferences(),persist();}catch{}}function recomputeBuyerInferences(){const a=buyerSignals['purchase_count'];if(a>=0x3){const b=buyerSignals['avg_purchase_price_ratio'];if(b<0.9)buyerSignals['inferred_price_sensitivity']='high';else b>1.1?buyerSignals['inferred_price_sensitivity']='low':buyerSignals['inferred_price_sensitivity']='medium';}if(a>=0x2){const c=buyerSignals['discount_usage_count']+buyerSignals['referral_usage_count'],d=c/a;buyerSignals['inferred_bargain_hunting']=Math['min'](0x1,d);}}export function getBuyerSignals(){return ensureHydrated(),{...buyerSignals};}export function updateFromOperation(a,b,c,d,e){try{ensureHydrated(),totalCount++;if(c==='success')successCount++;b&&scenarioCounts['set'](b,(scenarioCounts['get'](b)??0x0)+0x1);c!=='success'&&d&&pitfallCounts['set'](d,(pitfallCounts['get'](d)??0x0)+0x1);for(const f of e){objectRefs['set'](f,(objectRefs['get'](f)??0x0)+0x1);}currentProfile=recomputeProfile(),persist();}catch{}}function recomputeProfile(){const a=totalCount,b=a>0x0?successCount/a:0x1;let c='novice';if(a>=0x32&&b>=0.9)c='expert';else{if(a>=0xa&&b>=0.7)c='advanced';}const d=Array['from'](scenarioCounts['entries']())['sort']((i,j)=>j[0x1]-i[0x1])['slice'](0x0,0x3)['map'](([i])=>i);let e='balanced';if(a>0x14&&b<0.6)e='aggressive';else{if(a>0x14&&b>0.95)e='conservative';}const f=Array['from'](pitfallCounts['entries']())['filter'](([,i])=>i>=0x2)['sort']((i,j)=>j[0x1]-i[0x1])['slice'](0x0,0x3)['map'](([i])=>i),g=Array['from'](objectRefs['entries']())['filter'](([,i])=>i>=0x2)['sort']((i,j)=>j[0x1]-i[0x1])['slice'](0x0,0x5)['map'](([i])=>i);let h='standard';if(c==='expert')h='minimal';else{if(c==='novice')h='verbose';}return{'expertise_tier':c,'preferred_industries':d,'risk_appetite':e,'frequent_pitfalls':f,'reused_objects':g,'preferred_confirmation':h,'total_operations':a,'success_rate':b,'last_updated':Date['now']()};}export function resetProfile(){ensureHydrated(),currentProfile={'expertise_tier':'novice','preferred_industries':[],'risk_appetite':'balanced','frequent_pitfalls':[],'reused_objects':[],'preferred_confirmation':'verbose','total_operations':0x0,'success_rate':0x1,'last_updated':0x0},scenarioCounts=new Map(),pitfallCounts=new Map(),objectRefs=new Map(),successCount=0x0,totalCount=0x0,buyerSignals={'purchase_count':0x0,'avg_purchase_price_ratio':0x1,'discount_usage_count':0x0,'referral_usage_count':0x0,'dispute_count':0x0},persist();}export function getProfileStats(){return ensureHydrated(),{'total_operations':totalCount,'success_rate':totalCount>0x0?successCount/totalCount:0x1,'top_scenarios':Array['from'](scenarioCounts['entries']())['sort']((c,d)=>d[0x1]-c[0x1])['slice'](0x0,0x5)['map'](([a,b])=>({'scenario':a,'count':b})),'top_pitfalls':Array['from'](pitfallCounts['entries']())['sort']((c,d)=>d[0x1]-c[0x1])['slice'](0x0,0x5)['map'](([a,b])=>({'error_code':a,'count':b}))};}
@@ -1,4 +1,4 @@
1
- import type { ProjectObjectType } from "../project/namespace.js";
1
+ import type { ProjectObjectType } from "../playbooks/service-build/namespace.js";
2
2
  export type BusinessModuleId = "milestone_escrow" | "independent_arbitration" | "wip_provenance" | "multi_tier_allocation" | "subscription_with_proof" | "accept_timeout_protection" | "refund_guarantee" | "reputation_on_chain" | "supplier_collaboration" | "damage_attestation";
3
3
  export interface ModuleEvaluationImpact {
4
4
  dimension: string;
@@ -1,4 +1,4 @@
1
- import type { ProjectObjectType } from "../project/namespace.js";
1
+ import type { ProjectObjectType } from "../playbooks/service-build/namespace.js";
2
2
  export type CapabilityModule = "puzzle" | "risk" | "translation" | "templates" | "confirm" | "context" | "ledger" | "schema" | "handler";
3
3
  export type CapabilityCategory = "data_model" | "validation" | "lifecycle" | "fund_flow" | "trust" | "workflow" | "communication" | "evidence" | "query";
4
4
  export type IndustryAgnostic = "high" | "medium" | "low";
@@ -1,4 +1,4 @@
1
- import type { ProjectObjectType } from "../project/namespace.js";
1
+ import type { ProjectObjectType } from "../playbooks/service-build/namespace.js";
2
2
  import type { IndustryTraits, IndustrySource } from "../knowledge/industry-registry.js";
3
3
  import type { AcquisitionFlywheel } from "../knowledge/acquisition-flywheel.js";
4
4
  import type { IndustryRiskCheck, IndustryNeed } from "../customer/industry-risks.js";
@@ -0,0 +1,17 @@
1
+ import { GOAL_TYPES, type GoalType } from "./types.js";
2
+ export interface GoalClassification {
3
+ goal_type: GoalType | null;
4
+ confidence: number;
5
+ matched: string[];
6
+ alternatives: {
7
+ goal_type: GoalType;
8
+ score: number;
9
+ }[];
10
+ }
11
+ interface GoalKeywordRule {
12
+ goal_type: GoalType;
13
+ keywords: string[];
14
+ }
15
+ export declare const GOAL_KEYWORD_RULES: readonly GoalKeywordRule[];
16
+ export declare function classifyGoal(intentText: string): GoalClassification;
17
+ export { GOAL_TYPES };
@@ -0,0 +1 @@
1
+ import{GOAL_TYPES}from'./types.js';export const GOAL_KEYWORD_RULES=[{'goal_type':'publish_service','keywords':['发布服务','开店','上线服务','开个店','开个点','出售服务','上架','publish\x20service','launch\x20service','open\x20store','open\x20a\x20store','open\x20shop','sell\x20service']},{'goal_type':'fulfill_order','keywords':['履约','交付订单','新订单','推进订单','处理订单','订单交付','fulfill','fulfil','deliver\x20order','new\x20order','process\x20order']},{'goal_type':'capture_demand','keywords':['需求机会','接单','有什么需求','找需求','需求匹配','capture\x20demand','opportunities','opportunity','demands\x20available','what\x20demands']},{'goal_type':'purchase_service','keywords':['购买服务','帮我买','帮我找','定制','下单','买个','buy','purchase','order\x20a\x20service','customize','custom-made']},{'goal_type':'collaborate_flow','keywords':['待办','我的节点','协作','员工','工作任务','my\x20tasks','pending\x20nodes','collaborate','my\x20node','todo']},{'goal_type':'supply_suborder','keywords':['子订单','应征','供应商','供货','sub-order','suborder','supplier','present']},{'goal_type':'publish_demand','keywords':['发布需求','找人做','悬赏','求人','publish\x20demand','post\x20demand','bounty','looking\x20for\x20someone']},{'goal_type':'run_arbitration','keywords':['仲裁业务','仲裁服务','经营仲裁','仲裁经营','arbitration\x20business','arbitrator','arbitration\x20service']},{'goal_type':'dispute_resolution','keywords':['争议','纠纷','投诉','申诉','维权','dispute','complaint','appeal']},{'goal_type':'manage_assets','keywords':['资产','资金','数据管理','盘点','权限盘点','treasury','assets','manage\x20funds','asset','inventory']}];const ASCII_RE=/^[\x20-\x7e]+$/;function keywordWeight(a){return a['length']>=0x4?0x2:0x1;}function escapeRe(a){return a['replace'](/[.*+?^${}()|[\]\\]/g,'\x5c$&');}const boundaryCache=new Map();function keywordMatches(a,b){if(ASCII_RE['test'](a)){let c=boundaryCache['get'](a);return!c&&(c=new RegExp('\x5cb'+escapeRe(a)+'\x5cb','i'),boundaryCache['set'](a,c)),c['test'](b);}return b['includes'](a);}export function classifyGoal(a){const b=(a??'')['trim']()['toLowerCase'](),c={'goal_type':null,'confidence':0x0,'matched':[],'alternatives':[]};if(!b)return c;const d=[];for(const k of GOAL_KEYWORD_RULES){const l=[];let m=0x0;for(const n of k['keywords']){keywordMatches(n,b)&&(l['push'](n),m+=keywordWeight(n));}if(m>0x0)d['push']({'goal_type':k['goal_type'],'score':m,'matched':l});}if(d['length']===0x0)return c;let e=d[0x0];for(const o of d){if(o['score']>e['score'])e=o;}const f=d['reduce']((p,q)=>p+q['score'],0x0),g=e['score']/f,h=Math['min'](0x1,e['score']/0x3),i=Math['round'](g*h*0x3e8)/0x3e8,j=d['filter'](p=>p['goal_type']!==e['goal_type'])['sort']((p,q)=>q['score']-p['score'])['map'](({goal_type:p,score:q})=>({'goal_type':p,'score':q}));return{'goal_type':e['goal_type'],'confidence':i,'matched':e['matched'],'alternatives':j};}export{GOAL_TYPES};
@@ -0,0 +1,120 @@
1
+ import { type GoalClassification } from "./GoalClassifier.js";
2
+ import { GoalStore } from "./GoalStore.js";
3
+ import { type GoalProcessSummary, type GoalRecord, type GoalStage, type GoalType, type ObjectRef } from "./types.js";
4
+ import { type FeedbackRecord, type ProblemRecord, type ProcessEvent, type ProcessManifest, type ProcessStageState } from "../task/types.js";
5
+ import type { UserIntentSignature } from "../experience/types.js";
6
+ import { type SubscriptionStore } from "../monitor/SubscriptionStore.js";
7
+ import type { CreateIntentInput } from "../intent/index.js";
8
+ import type { IntentRecord } from "../intent/types.js";
9
+ import { type LocalAccountInfo } from "../knowledge/workflow-guidance.js";
10
+ import { type GoalCompletionVerdict } from "../knowledge/goal-completion.js";
11
+ export declare const GOAL_PLAYBOOKS: Record<GoalType, string | undefined>;
12
+ export declare const PLAN_APPROVAL_COVERS_LEVELS: readonly ["standard", "none"];
13
+ export interface GoalProcessDeps {
14
+ rootDir(): string;
15
+ initProcess(dir: string, manifest: ProcessManifest, stages: string[]): ProcessManifest;
16
+ loadManifest(dir: string): ProcessManifest;
17
+ saveManifest(dir: string, manifest: ProcessManifest): void;
18
+ loadStageState(dir: string): ProcessStageState | undefined;
19
+ appendEvent(dir: string, event: ProcessEvent): void;
20
+ addFeedback(dir: string, input: {
21
+ source: FeedbackRecord["source"];
22
+ sentiment: FeedbackRecord["sentiment"];
23
+ comment: string;
24
+ refs?: FeedbackRecord["refs"];
25
+ }): FeedbackRecord;
26
+ listProblems(dir: string, filter?: {
27
+ status?: ProblemRecord["status"];
28
+ }): ProblemRecord[];
29
+ listFeedback(dir: string): FeedbackRecord[];
30
+ readEvents(dir: string): ProcessEvent[];
31
+ removeDir(dir: string): void;
32
+ }
33
+ export interface GoalEngineDeps {
34
+ store: Pick<GoalStore, "create" | "get" | "save" | "list" | "counts" | "remove">;
35
+ subscriptionStore: Pick<SubscriptionStore, "getConfig" | "saveConfig">;
36
+ createIntent(input: CreateIntentInput): Promise<IntentRecord>;
37
+ removeIntent(id: string): Promise<boolean>;
38
+ listLocalAccounts(): Promise<LocalAccountInfo[]>;
39
+ evaluateCompletion(goal: GoalRecord, network?: string): Promise<GoalCompletionVerdict>;
40
+ processes: GoalProcessDeps;
41
+ recordSignature(sig: UserIntentSignature): void;
42
+ }
43
+ export interface CreateOrAdoptInput {
44
+ intent_text: string;
45
+ goal_type?: GoalType;
46
+ account?: string;
47
+ persona?: string;
48
+ title?: string;
49
+ network?: string;
50
+ conversation_id?: string;
51
+ create_process?: boolean;
52
+ }
53
+ export interface CreateOrAdoptResult {
54
+ goal?: GoalRecord;
55
+ adopted: boolean;
56
+ classification?: GoalClassification;
57
+ needs_type?: boolean;
58
+ warnings?: string[];
59
+ }
60
+ export interface AdvanceInput {
61
+ stage?: GoalStage;
62
+ objects?: ObjectRef[];
63
+ }
64
+ export interface CompleteResult {
65
+ goal: GoalRecord;
66
+ completed: boolean;
67
+ verify_report: GoalCompletionVerdict;
68
+ teardown_notes?: string[];
69
+ }
70
+ export declare const ADOPT_JACCARD_THRESHOLD = 0.6;
71
+ export declare function tokenizeIntent(text: string): Set<string>;
72
+ export declare function jaccard(a: Set<string>, b: Set<string>): number;
73
+ export declare class GoalEngine {
74
+ private readonly deps;
75
+ constructor(deps: GoalEngineDeps);
76
+ createOrAdopt(input: CreateOrAdoptInput): Promise<CreateOrAdoptResult>;
77
+ private preflightAccount;
78
+ approve(network: string, id: string, note?: string): Promise<GoalRecord>;
79
+ bind(network: string, id: string, account: string, persona?: string): Promise<GoalRecord>;
80
+ advance(network: string, id: string, input?: AdvanceInput): Promise<GoalRecord>;
81
+ registerActObjects(goalId: string, objects: ObjectRef[], network?: string): Promise<number>;
82
+ private registerProcessObjects;
83
+ private emitProcessEvent;
84
+ private distillOutcome;
85
+ private assertTransition;
86
+ pause(network: string, id: string): Promise<GoalRecord>;
87
+ private autoBindMonitor;
88
+ complete(network: string, id: string, opts?: {
89
+ force?: boolean;
90
+ feedback?: {
91
+ sentiment: "positive" | "negative" | "neutral";
92
+ comment: string;
93
+ };
94
+ }): Promise<CompleteResult>;
95
+ abandon(network: string, id: string, reason?: string): Promise<{
96
+ goal: GoalRecord;
97
+ teardown_notes?: string[];
98
+ }>;
99
+ remove(network: string, id: string, opts?: {
100
+ force?: boolean;
101
+ }): Promise<{
102
+ deleted: boolean;
103
+ tore_down_active?: boolean;
104
+ process_removed?: boolean;
105
+ }>;
106
+ private teardown;
107
+ get(network: string, id: string): Promise<GoalRecord & {
108
+ process_summary?: GoalProcessSummary;
109
+ }>;
110
+ private summarizeProcess;
111
+ list(network: string, filter?: {
112
+ stage?: GoalStage;
113
+ account?: string;
114
+ }): Promise<{
115
+ goals: GoalRecord[];
116
+ counts: Record<string, number>;
117
+ }>;
118
+ private mustGet;
119
+ }
120
+ export declare const goalEngine: GoalEngine;
@@ -0,0 +1 @@
1
+ import{classifyGoal}from'./GoalClassifier.js';import{goalStore}from'./GoalStore.js';import{isTerminalStage,newGoalId,stageIndex}from'./types.js';import{GENERIC_PLAYBOOK,playbookForGoalType}from'../task/playbook.js';import{PROCESS_SCHEMA_VERSION,newProcessId}from'../task/types.js';import{addFeedback,appendEvent,deleteProcessDir,initProcess,listFeedback,listProblems,loadManifest,loadStageState,processesRootDir,readEvents,saveManifest}from'../task/ProcessStore.js';import{recordSignature}from'../experience/index.js';import{join}from'path';import{registerPlanApproval,revokePlanApproval}from'./plan-approval.js';import{subscriptionStore}from'../monitor/SubscriptionStore.js';import{createIntent,removeIntent}from'../intent/index.js';import{listLocalAccounts}from'../knowledge/workflow-guidance.js';import{evaluateGoalCompletion}from'../knowledge/goal-completion.js';export const GOAL_PLAYBOOKS={'publish_service':'wowok-provider','fulfill_order':'wowok-provider','capture_demand':'wowok-market','purchase_service':'wowok-order','collaborate_flow':'wowok-collaborator','supply_suborder':'wowok-supplier','publish_demand':'wowok-order','run_arbitration':'wowok-arbitrator','dispute_resolution':'wowok-order','manage_assets':undefined};export const PLAN_APPROVAL_COVERS_LEVELS=['standard','none'];export const ADOPT_JACCARD_THRESHOLD=0.6;export function tokenizeIntent(a){const b=new Set(),c=(a??'')['toLowerCase']();for(const d of c['matchAll'](/[a-z0-9]+/g))b['add'](d[0x0]);for(const e of c['matchAll'](/[\u3400-\u9fff\uf900-\ufaff]/g))b['add'](e[0x0]);return b;}export function jaccard(c,d){if(c['size']===0x0||d['size']===0x0)return 0x0;let e=0x0;for(const f of c)if(d['has'](f))e++;return e/(c['size']+d['size']-e);}function deriveTitle(a){const b=(intent_text_first_line(a)||'Untitled\x20goal')['trim']();return b['length']>0x3c?b['slice'](0x0,0x39)+'…':b;}function intent_text_first_line(a){return(a??'')['split'](/\r?\n/,0x1)[0x0]??'';}function newApprovalId(){return'appr_'+Date['now']()['toString'](0x24)+Math['random']()['toString'](0x24)['slice'](0x2,0x8);}export class GoalEngine{['deps'];constructor(a){this['deps']=a;}async['createOrAdopt'](a){const b=a['network']??'default',c=(a['intent_text']??'')['trim']();if(!c)throw new Error('create_or_adopt\x20requires\x20non-empty\x20intent_text');let d=a['goal_type'],f;if(!d){f=classifyGoal(c),d=f['goal_type']??undefined;if(!d)return{'adopted':![],'classification':f,'needs_type':!![]};}const h=await this['deps']['store']['list'](b),i=a['account']??'',j=tokenizeIntent(c);let k;for(const r of h){if(isTerminalStage(r['stage']))continue;if(r['goal_type']!==d)continue;if((r['binding']?.['account']??'')!==i)continue;const s=jaccard(j,tokenizeIntent(r['intent_text']));s>=ADOPT_JACCARD_THRESHOLD&&(!k||s>k['sim'])&&(k={'goal':r,'sim':s});}if(k)return{'goal':k['goal'],'adopted':!![],'classification':f};const l=Date['now']();let m,n='recognized';if(a['account']){const t=await this['preflightAccount'](a['account']);m={'account':a['account'],'persona':a['persona'],'preflight':t},n='bound';}const o={'id':newGoalId(),'goal_type':d,'title':a['title']?.['trim']()||deriveTitle(c),'intent_text':c,...a['conversation_id']?{'conversation_id':a['conversation_id']}:{},'binding':m,'objects':[],'monitor':{'focus_ids':[],'intent_ids':[]},'stage':n,'playbook':GOAL_PLAYBOOKS[d],'approvals':[],'created_at':l,'updated_at':l};await this['deps']['store']['create'](b,o);const p=[],q=playbookForGoalType(d);if(q['name']!==GENERIC_PLAYBOOK||a['create_process']===!![])try{const u=newProcessId(),v=join(this['deps']['processes']['rootDir'](),u),w=new Date(l)['toISOString']();this['deps']['processes']['initProcess'](v,{'schema_version':PROCESS_SCHEMA_VERSION,'mcp_version':'unknown','process_id':u,'playbook':q['name'],'goal_id':o['id'],'title':o['title'],'network':b,'objects':[],'created_at':w,'updated_at':w,'archived':![]},q['stages']),o['process']={'id':u,'playbook':q['name'],'dir':v},o['plan_ref']=u,await this['deps']['store']['save'](b,o);}catch(x){p['push']('process\x20creation\x20failed\x20(goal\x20kept\x20without\x20process):\x20'+(x instanceof Error?x['message']:String(x)));}return{'goal':o,'adopted':![],'classification':f,...p['length']?{'warnings':p}:{}};}async['preflightAccount'](a){const b=[];let c;try{const d=await this['deps']['listLocalAccounts']();c=d['find'](f=>f['address']===a||f['name']===a);}catch(f){b['push']('local\x20account\x20lookup\x20failed:\x20'+(f instanceof Error?f['message']:String(f)));}if(c){if(c['address']!==a)b['push']('resolved\x20\x27'+a+'\x27\x20to\x20'+c['address']);}else b['push']('account\x20\x27'+a+'\x27\x20not\x20found\x20among\x20local\x20accounts');return{'account_found':Boolean(c),'notes':b};}async['approve'](a,b,c){const d=await this['mustGet'](a,b);if(isTerminalStage(d['stage']))throw new Error('goal\x20'+b+'\x20is\x20terminal\x20('+d['stage']+')');const e={'id':newApprovalId(),'approved_at':Date['now'](),'scope':'plan','covers_levels':[...PLAN_APPROVAL_COVERS_LEVELS],...c?{'note':c}:{}};d['approvals']['push'](e),registerPlanApproval(d['id']);const f=stageIndex(d['stage']);if(f>=0x0&&f<stageIndex('approved'))d['stage']='approved';return d['updated_at']=Date['now'](),this['deps']['store']['save'](a,d);}async['bind'](a,b,c,d){const e=await this['mustGet'](a,b);if(isTerminalStage(e['stage']))throw new Error('goal\x20'+b+'\x20is\x20terminal\x20('+e['stage']+')');if(!c?.['trim']())throw new Error('bind\x20requires\x20a\x20non-empty\x20account');const f=await this['preflightAccount'](c['trim']());e['binding']={'account':c['trim'](),...d?.['trim']()?{'persona':d['trim']()}:{},'preflight':f};const g=stageIndex(e['stage']);if(g>=0x0&&g<stageIndex('bound'))e['stage']='bound';return e['updated_at']=Date['now'](),this['deps']['store']['save'](a,e);}async['advance'](a,b,c={}){const d=await this['mustGet'](a,b);if(isTerminalStage(d['stage']))throw new Error('goal\x20'+b+'\x20is\x20terminal\x20('+d['stage']+')');const e=[];for(const g of c['objects']??[]){const h=d['objects']['some'](i=>i['type']===g['type']&&i['object']['toLowerCase']()===g['object']['toLowerCase']());!h&&(d['objects']['push']({'type':g['type'],'object':g['object']}),e['push']({'type':g['type'],'object':g['object']}));}const f=c['stage'];if(f){this['assertTransition'](d['stage'],f);const i=f==='monitoring'&&d['stage']!=='monitoring';d['stage']=f,d['updated_at']=Date['now']();if(i)await this['autoBindMonitor'](a,d);if(i)this['emitProcessEvent'](d,'goal_monitoring','goal\x20entered\x20monitoring');}else{if((c['objects']??[])['length']===0x0)throw new Error('advance\x20requires\x20a\x20target\x20stage\x20and/or\x20objects');}return e['length']>0x0&&d['process']&&this['registerProcessObjects'](d,e),d['updated_at']=Date['now'](),this['deps']['store']['save'](a,d);}async['registerActObjects'](a,b,c='default'){if(b['length']===0x0)return 0x0;try{let d=c,e=await this['deps']['store']['get'](d,a);if(!e&&d!=='default'){e=await this['deps']['store']['get']('default',a);if(e)d='default';}if(!e||isTerminalStage(e['stage']))return 0x0;const f=e['objects']['length'],g=await this['advance'](d,a,{'objects':b});return g['objects']['length']-f;}catch{return 0x0;}}['registerProcessObjects'](a,b){try{const c=a['process']['dir'],d=this['deps']['processes']['loadManifest'](c);for(const e of b){const f=d['objects']['some'](g=>g['type']===e['type']&&g['object']['toLowerCase']()===e['object']['toLowerCase']());if(!f)d['objects']['push']({'type':e['type'],'object':e['object']});}this['deps']['processes']['saveManifest'](c,d),this['deps']['processes']['appendEvent'](c,{'timestamp':new Date()['toISOString'](),'event':'objects_registered','reason':b['length']+'\x20object(s)\x20registered\x20by\x20goal\x20'+a['id'],'data':{'added':b['map'](g=>g['type']+':'+g['object'])}});}catch{}}['emitProcessEvent'](a,b,c){if(!a['process'])return;try{this['deps']['processes']['appendEvent'](a['process']['dir'],{'timestamp':new Date()['toISOString'](),'event':b,'reason':c});}catch{}}['distillOutcome'](a,b){try{const c={'playbook':a['process']?.['playbook'],'objects_count':a['objects']['length']};if(a['process']){const d=this['deps']['processes']['loadStageState'](a['process']['dir']),e=d?.['stages']['filter'](h=>d['stage_meta'][h]?.['committed'])['length'];if(e!==undefined)c['stages_completed']=e;const f=this['deps']['processes']['listProblems'](a['process']['dir']),g=this['deps']['processes']['listFeedback'](a['process']['dir']);c['problems_open']=f['filter'](h=>h['status']==='open')['length'],c['problems_resolved']=f['filter'](h=>h['status']==='resolved')['length'],c['feedback_positive']=g['filter'](h=>h['sentiment']==='positive')['length'],c['feedback_negative']=g['filter'](h=>h['sentiment']==='negative')['length'];}this['deps']['recordSignature']({'intent':a['goal_type'],'signals':c,'timestamp':Date['now'](),'outcome':b});}catch{}}['assertTransition'](a,b){if(isTerminalStage(a))throw new Error('goal\x20is\x20terminal\x20('+a+')');if(b==='abandoned')throw new Error('use\x20the\x20abandon\x20action\x20to\x20abandon\x20a\x20goal');if(b==='paused')return;if(a==='paused')return;if(b===a)return;const c=stageIndex(a),d=stageIndex(b);if(d<0x0||c<0x0||d<c)throw new Error('invalid\x20stage\x20transition:\x20'+a+'\x20→\x20'+b+'\x20(forward-only\x20along\x20'+'recognized→confirmed→bound→planned→approved→acting→monitoring→completed'+')');}async['pause'](a,b){return this['advance'](a,b,{'stage':'paused'});}async['autoBindMonitor'](a,b){const c=await this['deps']['subscriptionStore']['getConfig'](a),d=c['scope']['focus_objects']['map'](g=>({...g})),e=Date['now']();for(const f of b['objects']){const g=d['some'](h=>h['object']===f['object']&&h['goal_id']===b['id']);if(g)continue;d['push']({'object':f['object'],'added_at':e,'reason':'goal','closure':!![],'goal_id':b['id'],'note':b['title']});if(!b['monitor']['focus_ids']['includes'](f['object']))b['monitor']['focus_ids']['push'](f['object']);}await this['deps']['subscriptionStore']['saveConfig'](a,{'scope':{...c['scope'],'focus_objects':d}});if((b['goal_type']==='capture_demand'||b['goal_type']==='publish_demand')&&b['monitor']['intent_ids']['length']===0x0){const h=await this['deps']['createIntent']({'intent':b['intent_text'],'account':b['binding']?.['account']});b['monitor']['intent_ids']['push'](h['id']);}}async['complete'](a,b,c={}){const d=await this['mustGet'](a,b);if(isTerminalStage(d['stage']))throw new Error('goal\x20'+b+'\x20is\x20terminal\x20('+d['stage']+')');const e=await this['deps']['evaluateCompletion'](d,a),f=c['force']===!![];if(!e['complete']&&!f)return{'goal':d,'completed':![],'verify_report':e};const g=await this['teardown'](a,d);d['stage']='completed',d['outcome']={'success':e['complete']||f,'completed_at':Date['now'](),'verify_report':e,...!e['complete']&&f?{'forced':!![]}:{}},d['updated_at']=Date['now']();if(d['process']){if(c['feedback'])try{this['deps']['processes']['addFeedback'](d['process']['dir'],{'source':'user','sentiment':c['feedback']['sentiment'],'comment':c['feedback']['comment']});}catch{g['push']('feedback\x20recording\x20failed');}this['emitProcessEvent'](d,'goal_completed','goal\x20completed\x20('+d['title']+')');}this['distillOutcome'](d,'success');const h=await this['deps']['store']['save'](a,d);return{'goal':h,'completed':!![],'verify_report':e,'teardown_notes':g['length']?g:undefined};}async['abandon'](a,b,c){const d=await this['mustGet'](a,b);if(isTerminalStage(d['stage']))throw new Error('goal\x20'+b+'\x20is\x20already\x20terminal\x20('+d['stage']+')');const e=await this['teardown'](a,d);d['stage']='abandoned',d['outcome']={'success':![],'completed_at':Date['now'](),...c?{'verify_report':{'reason':c}}:{}},d['updated_at']=Date['now'](),this['emitProcessEvent'](d,'goal_abandoned',c??'goal\x20abandoned'),this['distillOutcome'](d,'failed');const f=await this['deps']['store']['save'](a,d);return{'goal':f,'teardown_notes':e['length']?e:undefined};}async['remove'](a,b,c={}){const d=await this['mustGet'](a,b);let e;if(!isTerminalStage(d['stage'])){if(c['force']!==!![])throw new Error('goal\x20'+b+'\x20is\x20not\x20terminal\x20('+d['stage']+')\x20—\x20complete/abandon\x20it\x20first,\x20or\x20pass\x20force=true');await this['teardown'](a,d),e=!![];}let f;if(d['process'])try{this['deps']['processes']['removeDir'](d['process']['dir']),f=!![];}catch{f=![];}const g=await this['deps']['store']['remove'](a,b);return{'deleted':g,...e!==undefined?{'tore_down_active':e}:{},...f!==undefined?{'process_removed':f}:{}};}async['teardown'](a,b){const c=[];try{const d=await this['deps']['subscriptionStore']['getConfig'](a),f=d['scope']['focus_objects']['filter'](g=>g['goal_id']!==b['id']);f['length']!==d['scope']['focus_objects']['length']&&await this['deps']['subscriptionStore']['saveConfig'](a,{'scope':{...d['scope'],'focus_objects':f}});}catch(g){c['push']('focus\x20teardown\x20failed:\x20'+(g instanceof Error?g['message']:String(g)));}revokePlanApproval(b['id']);for(const h of b['monitor']['intent_ids']){try{await this['deps']['removeIntent'](h);}catch(i){c['push']('intent\x20teardown\x20failed\x20('+h+'):\x20'+(i instanceof Error?i['message']:String(i)));}}return c;}async['get'](a,b){const c=await this['mustGet'](a,b);if(!c['process'])return c;try{return{...c,'process_summary':this['summarizeProcess'](c['process']['dir'],c['process']['id'],c['process']['playbook'])};}catch{return c;}}['summarizeProcess'](a,b,c){const d=this['deps']['processes']['loadStageState'](a),e=this['deps']['processes']['listProblems'](a,{'status':'open'}),f={'critical':0x0,'high':0x1,'medium':0x2,'low':0x3},g=[...e]['sort']((h,i)=>f[h['severity']]-f[i['severity']])['slice'](0x0,0x3)['map'](h=>h['title']);return{'id':b,'playbook':c,'current_stage':d?.['current_stage']??'unknown','stages':(d?.['stages']??[])['map'](h=>({'name':h,'committed':d?.['stage_meta'][h]?.['committed']??![],'completion':d?.['stage_meta'][h]?.['completion']??0x0})),'open_problems':{'count':e['length'],'top':g},'last_events':this['deps']['processes']['readEvents'](a)['slice'](-0x5),'feedback_count':this['deps']['processes']['listFeedback'](a)['length']};}async['list'](a,b={}){const [c,d]=await Promise['all']([this['deps']['store']['list'](a,b),this['deps']['store']['counts'](a)]);return{'goals':c,'counts':d};}async['mustGet'](a,b){const c=await this['deps']['store']['get'](a,b);if(!c)throw new Error('goal\x20not\x20found:\x20'+b);return c;}}export const goalEngine=new GoalEngine({'store':goalStore,'subscriptionStore':subscriptionStore,'createIntent':createIntent,'removeIntent':removeIntent,'listLocalAccounts':listLocalAccounts,'evaluateCompletion':(a,b)=>evaluateGoalCompletion(a,b),'processes':{'rootDir':processesRootDir,'initProcess':initProcess,'loadManifest':loadManifest,'saveManifest':saveManifest,'loadStageState':loadStageState,'appendEvent':appendEvent,'addFeedback':addFeedback,'listProblems':listProblems,'listFeedback':listFeedback,'readEvents':readEvents,'removeDir':deleteProcessDir},'recordSignature':recordSignature});
@@ -0,0 +1,27 @@
1
+ import { SQLiteStorage } from "@wowok/wowok/w/local";
2
+ import { TERMINAL_STAGES, type GoalRecord, type GoalStage } from "./types.js";
3
+ export interface GoalListFilter {
4
+ stage?: GoalStage;
5
+ account?: string;
6
+ conversation_id?: string;
7
+ }
8
+ export declare class GoalStore {
9
+ private storage;
10
+ private locks;
11
+ constructor(storage?: SQLiteStorage);
12
+ private withLock;
13
+ private goalKey;
14
+ private idxKey;
15
+ private getJson;
16
+ private putJson;
17
+ create(network: string, goal: GoalRecord): Promise<GoalRecord>;
18
+ get(network: string, id: string): Promise<GoalRecord | undefined>;
19
+ save(network: string, goal: GoalRecord): Promise<GoalRecord>;
20
+ list(network: string, filter?: GoalListFilter): Promise<GoalRecord[]>;
21
+ remove(network: string, id: string): Promise<boolean>;
22
+ counts(network: string): Promise<Record<string, number>>;
23
+ private indexAdd;
24
+ }
25
+ export declare const GOAL_INDEX_STAGES: readonly GoalStage[];
26
+ export { TERMINAL_STAGES };
27
+ export declare const goalStore: GoalStore;
@@ -0,0 +1 @@
1
+ import{SQLiteStorage}from'@wowok/wowok/w/local';import{TERMINAL_STAGES}from'./types.js';const KEY_PREFIX='goal:v1:',IDX_PREFIX='goal_idx:v1:',INDEX_STAGES=['recognized','confirmed','bound','planned','approved','acting','monitoring','paused','completed','abandoned'];function netKey(a){return(a||'default')['replace'](/[^a-zA-Z0-9_-]/g,'_');}function parseRecord(a){try{const b=JSON['parse'](a);return b&&typeof b['id']==='string'?b:undefined;}catch{return undefined;}}export class GoalStore{['storage'];['locks']=new Map();constructor(a){this['storage']=a??new SQLiteStorage();}['withLock'](a,b){const c=netKey(a),d=this['locks']['get'](c)??Promise['resolve'](),e=d['then'](b,b);return this['locks']['set'](c,e['catch'](()=>undefined)),e;}['goalKey'](a,b){return''+KEY_PREFIX+netKey(a)+':'+b;}['idxKey'](a){return''+IDX_PREFIX+netKey(a);}async['getJson'](a){const b=await this['storage']['get'](a);if(!b)return undefined;try{return JSON['parse'](b);}catch{return undefined;}}async['putJson'](a,b){await this['storage']['put'](a,JSON['stringify'](b));}async['create'](a,b){return this['withLock'](a,async()=>{const c=await this['storage']['get'](this['goalKey'](a,b['id']));if(c)throw new Error('goal\x20already\x20exists:\x20'+b['id']);return await this['putJson'](this['goalKey'](a,b['id']),b),await this['indexAdd'](a,b['id'],b['stage']),b;});}async['get'](a,b){const c=await this['storage']['get'](this['goalKey'](a,b));return c?parseRecord(c):undefined;}async['save'](a,b){return this['withLock'](a,async()=>{const c=await this['storage']['get'](this['goalKey'](a,b['id']));if(!c)throw new Error('goal\x20not\x20found:\x20'+b['id']);return await this['putJson'](this['goalKey'](a,b['id']),b),await this['indexAdd'](a,b['id'],b['stage']),b;});}async['list'](a,b={}){let c;if(b['stage']){const f=await this['getJson'](this['idxKey'](a))??{'by_stage':{}};c=[...f['by_stage'][b['stage']]??[]];}else{const g=await this['storage']['list'](''+KEY_PREFIX+netKey(a)+':');c=g['map'](({value:h})=>parseRecord(h)?.['id'])['filter'](h=>typeof h==='string');}if(c['length']===0x0)return[];const d=await this['storage']['getMany'](c['map'](h=>this['goalKey'](a,h))),e=[];for(const h of d){const i=h?parseRecord(h):undefined;if(!i)continue;if(b['stage']&&i['stage']!==b['stage'])continue;if(b['account']!==undefined&&i['binding']?.['account']!==b['account'])continue;if(b['conversation_id']!==undefined&&i['conversation_id']!==b['conversation_id'])continue;e['push'](i);}return e['sort']((j,k)=>k['updated_at']-j['updated_at']);}async['remove'](a,b){return this['withLock'](a,async()=>{const c=this['goalKey'](a,b),d=await this['storage']['get'](c);if(!d)return![];await this['storage']['del'](c);const e=await this['getJson'](this['idxKey'](a))??{'by_stage':{}},f={...e['by_stage']};let g=![];for(const h of INDEX_STAGES){const i=f[h]??[];i['includes'](b)&&(f[h]=i['filter'](j=>j!==b),g=!![]);}if(g)await this['putJson'](this['idxKey'](a),{'by_stage':f});return!![];});}async['counts'](a){const b=await this['getJson'](this['idxKey'](a))??{'by_stage':{}},c={};for(const d of INDEX_STAGES)c[d]=b['by_stage'][d]?.['length']??0x0;return c;}async['indexAdd'](a,b,c){const d=await this['getJson'](this['idxKey'](a))??{'by_stage':{}},e={...d['by_stage']};for(const f of INDEX_STAGES){const g=(e[f]??[])['filter'](h=>h!==b);if(f===c)g['push'](b);e[f]=g;}await this['putJson'](this['idxKey'](a),{'by_stage':e});}}export const GOAL_INDEX_STAGES=INDEX_STAGES;export{TERMINAL_STAGES};export const goalStore=new GoalStore();
@@ -0,0 +1,5 @@
1
+ export declare function registerPlanApproval(goalId: string): void;
2
+ export declare function revokePlanApproval(goalId: string): void;
3
+ export declare function isPlanPreapproved(env: unknown): boolean;
4
+ export declare function clearPlanApprovals(): void;
5
+ export declare function listPlanApprovals(): string[];
@@ -0,0 +1 @@
1
+ const preapprovedGoals=new Map();export function registerPlanApproval(a){if(!a)return;preapprovedGoals['set'](a,Date['now']());}export function revokePlanApproval(a){preapprovedGoals['delete'](a);}export function isPlanPreapproved(a){const b=a?.['plan_approval'];return typeof b==='string'&&b['length']>0x0&&preapprovedGoals['has'](b);}export function clearPlanApprovals(){preapprovedGoals['clear']();}export function listPlanApprovals(){return[...preapprovedGoals['keys']()];}
@@ -0,0 +1,76 @@
1
+ import type { ProcessEvent } from "../task/types.js";
2
+ export type GoalType = "publish_service" | "fulfill_order" | "capture_demand" | "purchase_service" | "collaborate_flow" | "supply_suborder" | "publish_demand" | "run_arbitration" | "dispute_resolution" | "manage_assets";
3
+ export declare const GOAL_TYPES: readonly GoalType[];
4
+ export declare const GOAL_TYPE_LABELS: Record<GoalType, string>;
5
+ export type GoalStage = "recognized" | "confirmed" | "bound" | "planned" | "approved" | "acting" | "monitoring" | "paused" | "completed" | "abandoned";
6
+ export declare const STAGE_ORDER: readonly GoalStage[];
7
+ export declare const TERMINAL_STAGES: readonly GoalStage[];
8
+ export interface ObjectRef {
9
+ type: string;
10
+ object: string;
11
+ }
12
+ export interface PreflightResult {
13
+ account_found: boolean;
14
+ notes: string[];
15
+ }
16
+ export interface BindingRecord {
17
+ account: string;
18
+ persona?: string;
19
+ preflight: PreflightResult;
20
+ }
21
+ export interface ApprovalRecord {
22
+ id: string;
23
+ approved_at: number;
24
+ scope: "plan";
25
+ covers_levels: string[];
26
+ note?: string;
27
+ }
28
+ export interface GoalRecord {
29
+ id: string;
30
+ goal_type: GoalType;
31
+ title: string;
32
+ intent_text: string;
33
+ conversation_id?: string;
34
+ binding?: BindingRecord;
35
+ plan_ref?: string;
36
+ process?: {
37
+ id: string;
38
+ playbook: string;
39
+ dir: string;
40
+ };
41
+ objects: ObjectRef[];
42
+ monitor: {
43
+ focus_ids: string[];
44
+ intent_ids: string[];
45
+ };
46
+ stage: GoalStage;
47
+ playbook?: string;
48
+ approvals: ApprovalRecord[];
49
+ outcome?: {
50
+ success: boolean;
51
+ completed_at: number;
52
+ verify_report?: unknown;
53
+ forced?: boolean;
54
+ };
55
+ created_at: number;
56
+ updated_at: number;
57
+ }
58
+ export declare function isTerminalStage(stage: GoalStage): boolean;
59
+ export declare function stageIndex(stage: GoalStage): number;
60
+ export interface GoalProcessSummary {
61
+ id: string;
62
+ playbook: string;
63
+ current_stage: string;
64
+ stages: {
65
+ name: string;
66
+ committed: boolean;
67
+ completion: number;
68
+ }[];
69
+ open_problems: {
70
+ count: number;
71
+ top: string[];
72
+ };
73
+ last_events: ProcessEvent[];
74
+ feedback_count: number;
75
+ }
76
+ export declare function newGoalId(): string;
@@ -0,0 +1 @@
1
+ export const GOAL_TYPES=['publish_service','fulfill_order','capture_demand','purchase_service','collaborate_flow','supply_suborder','publish_demand','run_arbitration','dispute_resolution','manage_assets'];export const GOAL_TYPE_LABELS={'publish_service':'Publish\x20&\x20operate\x20a\x20service','fulfill_order':'Fulfill\x20an\x20order\x20(merchant\x20side)','capture_demand':'Capture\x20demand\x20opportunities','purchase_service':'Purchase\x20a\x20service\x20&\x20see\x20it\x20delivered','collaborate_flow':'Collaborate\x20in\x20a\x20workflow\x20(my\x20pending\x20nodes)','supply_suborder':'Supply\x20a\x20sub-order\x20to\x20a\x20demand','publish_demand':'Publish\x20a\x20demand','run_arbitration':'Run\x20an\x20arbitration\x20business','dispute_resolution':'Resolve\x20a\x20dispute\x20(as\x20a\x20party)','manage_assets':'Manage\x20assets\x20&\x20data'};export const STAGE_ORDER=['recognized','confirmed','bound','planned','approved','acting','monitoring','completed'];export const TERMINAL_STAGES=['completed','abandoned'];export function isTerminalStage(a){return TERMINAL_STAGES['includes'](a);}export function stageIndex(a){return STAGE_ORDER['indexOf'](a);}export function newGoalId(){return'goal_'+Date['now']()['toString'](0x24)+Math['random']()['toString'](0x24)['slice'](0x2,0x8);}