@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
@@ -0,0 +1,81 @@
1
+ import { type DecisionRecord, type FeedbackRecord, type ProblemRecord, type ProcessEvent, type ProcessManifest, type ProcessStageState, type SubstepRecord, type StageMeta } from "./types.js";
2
+ export declare function processesRootDir(): string;
3
+ export declare function processDir(id: string): string;
4
+ export declare function deleteProcessDir(dir: string): void;
5
+ export declare function initProcess(dir: string, manifest: ProcessManifest, stages: string[]): ProcessManifest;
6
+ export declare function loadManifest(dir: string): ProcessManifest;
7
+ export declare function saveManifest(dir: string, manifest: ProcessManifest): void;
8
+ export declare function loadStageState(dir: string): ProcessStageState | undefined;
9
+ export declare function saveStageState(dir: string, state: ProcessStageState): void;
10
+ export declare function advanceStage(dir: string, toStage: string, opts?: {
11
+ allowSkip?: boolean;
12
+ }): ProcessStageState;
13
+ export declare function updateStageMeta(dir: string, stage: string, patch: Partial<StageMeta>): StageMeta;
14
+ export declare function appendEvent(dir: string, event: ProcessEvent): void;
15
+ export declare function readEvents(dir: string): ProcessEvent[];
16
+ export declare function addProblem(dir: string, input: {
17
+ stage?: string;
18
+ object?: string;
19
+ severity: ProblemRecord["severity"];
20
+ title: string;
21
+ detail?: string;
22
+ note?: {
23
+ by: "user" | "agent" | "system";
24
+ text: string;
25
+ };
26
+ origin?: ProblemRecord["origin"];
27
+ }): ProblemRecord;
28
+ export declare function updateProblem(dir: string, id: string, patch: Partial<Pick<ProblemRecord, "status" | "severity" | "title" | "detail" | "stage" | "object">>, note?: {
29
+ by: "user" | "agent" | "system";
30
+ text: string;
31
+ }): ProblemRecord;
32
+ export declare function listProblems(dir: string, filter?: {
33
+ status?: ProblemRecord["status"];
34
+ }): ProblemRecord[];
35
+ export declare function addFeedback(dir: string, input: {
36
+ source: FeedbackRecord["source"];
37
+ sentiment: FeedbackRecord["sentiment"];
38
+ comment: string;
39
+ refs?: FeedbackRecord["refs"];
40
+ }): FeedbackRecord;
41
+ export declare function listFeedback(dir: string): FeedbackRecord[];
42
+ export declare function addDecision(dir: string, input: {
43
+ stage?: string;
44
+ by: DecisionRecord["by"];
45
+ decision: string;
46
+ rationale?: string;
47
+ reversible: boolean;
48
+ }): DecisionRecord;
49
+ export declare function listDecisions(dir: string): DecisionRecord[];
50
+ export declare function appendSubstep(dir: string, network: string, record: SubstepRecord): void;
51
+ export declare function readSubsteps(dir: string, network: string): SubstepRecord[];
52
+ export declare function savePayload(dir: string, relPath: string, data: unknown): string;
53
+ export declare function loadPayload<T = unknown>(dir: string, relPath: string): T | undefined;
54
+ export interface ProcessBundle {
55
+ schema_version: string;
56
+ exported_at: string;
57
+ manifest: ProcessManifest;
58
+ stage?: ProcessStageState;
59
+ events: ProcessEvent[];
60
+ problems: ProblemRecord[];
61
+ feedback: FeedbackRecord[];
62
+ decisions: DecisionRecord[];
63
+ substeps: Record<string, SubstepRecord[]>;
64
+ payloads: Record<string, unknown>;
65
+ }
66
+ export declare function exportBundle(dir: string): ProcessBundle;
67
+ export declare function importBundle(destDir: string, bundle: ProcessBundle, opts?: {
68
+ remap?: Record<string, string>;
69
+ }): ProcessManifest;
70
+ export declare function forkProcess(srcDir: string, destDir: string): ProcessManifest;
71
+ export interface ProcessListEntry {
72
+ dir_name: string;
73
+ path: string;
74
+ manifest?: ProcessManifest;
75
+ current_stage?: string;
76
+ stages?: string[];
77
+ committed_stages?: string[];
78
+ archived: boolean;
79
+ mtime: number;
80
+ }
81
+ export declare function listProcesses(root?: string): ProcessListEntry[];
@@ -0,0 +1 @@
1
+ import{appendFileSync,copyFileSync,existsSync,mkdirSync,readFileSync,readdirSync,rmSync,statSync,writeFileSync}from'fs';import{basename,dirname,join,relative,sep}from'path';import{getWowMcpDir}from'@wowok/wowok';import{PROCESS_SCHEMA_VERSION}from'./types.js';export function processesRootDir(){return join(getWowMcpDir(),'processes');}export function processDir(a){return join(processesRootDir(),a);}export function deleteProcessDir(a){rmSync(a,{'recursive':!![],'force':!![]});}function manifestPath(a){return join(a,'manifest.json');}function stageStatePath(a){return join(a,'stage.json');}function eventsPath(a){return join(a,'events.jsonl');}function problemsPath(a){return join(a,'problems.jsonl');}function feedbackPath(a){return join(a,'feedback.jsonl');}function decisionsPath(a){return join(a,'decisions.jsonl');}function netKey(a){return(a||'default')['replace'](/[^a-zA-Z0-9_-]/g,'_');}function substepsPath(a,b){return join(a,'substeps-'+netKey(b)+'.jsonl');}function relKey(a,b){return relative(a,b)['split'](sep)['join']('/');}function zeroStageMeta(){return{'committed':![],'gate_passed':![],'blocking_issues':[],'completion':0x0};}function newRecordId(a){return a+'_'+Date['now']()['toString'](0x24)+'_'+Math['random']()['toString'](0x24)['slice'](0x2,0x8);}export function initProcess(a,b,c){if(c['length']===0x0)throw new Error('initProcess\x20requires\x20a\x20non-empty\x20stage\x20sequence');mkdirSync(a,{'recursive':!![]}),writeFileSync(manifestPath(a),JSON['stringify'](b,null,0x2),'utf-8');const d={};for(const e of c)d[e]=zeroStageMeta();return saveStageState(a,{'stages':[...c],'current_stage':c[0x0],'stage_meta':d,'updated_at':Date['now']()}),appendEvent(a,{'timestamp':b['created_at'],'event':'process_init','stage':c[0x0],'reason':'process\x20initialized\x20(playbook:\x20'+b['playbook']+')','data':{'playbook':b['playbook'],'stages':[...c]}}),b;}export function loadManifest(a){const b=manifestPath(a);if(!existsSync(b))throw new Error('process\x20not\x20initialized:\x20'+a+'\x20(missing\x20manifest.json)');return JSON['parse'](readFileSync(b,'utf-8'));}export function saveManifest(a,b){b['updated_at']=new Date()['toISOString'](),writeFileSync(manifestPath(a),JSON['stringify'](b,null,0x2),'utf-8');}export function loadStageState(a){const b=stageStatePath(a);if(!existsSync(b))return undefined;return JSON['parse'](readFileSync(b,'utf-8'));}export function saveStageState(a,b){b['updated_at']=Date['now'](),mkdirSync(a,{'recursive':!![]}),writeFileSync(stageStatePath(a),JSON['stringify'](b,null,0x2),'utf-8');}export function advanceStage(a,b,c={}){const d=loadStageState(a);if(!d)throw new Error('process\x20not\x20initialized:\x20'+a+'\x20(missing\x20stage.json)');const e=d['stages']['indexOf'](b);if(e<0x0)throw new Error('unknown\x20stage\x20\x27'+b+'\x27\x20(stages:\x20'+d['stages']['join']('\x20→\x20')+')');const f=d['stages']['indexOf'](d['current_stage']);if(b===d['current_stage'])return d;if(e<f)throw new Error('invalid\x20stage\x20transition:\x20'+d['current_stage']+'\x20→\x20'+b+'\x20(forward-only)');if(e>f+0x1&&!c['allowSkip'])throw new Error('invalid\x20stage\x20transition:\x20'+d['current_stage']+'\x20→\x20'+b+'\x20(skips\x20'+d['stages'][f+0x1]+';\x20pass\x20allowSkip\x20to\x20jump)');const g=d['current_stage'],h=d['stage_meta'][g]??zeroStageMeta();return d['stage_meta'][g]={...h,'committed':!![],'committed_at':h['committed_at']??Date['now'](),'completion':h['committed']?h['completion']:0x64},d['current_stage']=b,saveStageState(a,d),appendEvent(a,{'timestamp':new Date()['toISOString'](),'event':'stage_commit','stage':g,'reason':'stage\x20\x27'+g+'\x27\x20committed;\x20advanced\x20to\x20\x27'+b+'\x27','data':{'from':g,'to':b}}),d;}export function updateStageMeta(a,b,c){const d=loadStageState(a);if(!d)throw new Error('process\x20not\x20initialized:\x20'+a+'\x20(missing\x20stage.json)');if(!d['stages']['includes'](b))throw new Error('unknown\x20stage\x20\x27'+b+'\x27\x20(stages:\x20'+d['stages']['join']('\x20→\x20')+')');const e={...d['stage_meta'][b]??zeroStageMeta(),...c};return d['stage_meta'][b]=e,saveStageState(a,d),e;}export function appendEvent(a,b){mkdirSync(a,{'recursive':!![]}),appendFileSync(eventsPath(a),JSON['stringify'](b)+'\x0a','utf-8');}export function readEvents(a){return readJsonl(eventsPath(a));}function readJsonl(a){if(!existsSync(a))return[];return readFileSync(a,'utf-8')['split']('\x0a')['filter'](b=>b['trim']()['length']>0x0)['map'](b=>JSON['parse'](b));}function appendJsonlRecord(a,b){mkdirSync(dirname(a),{'recursive':!![]}),appendFileSync(a,JSON['stringify'](b)+'\x0a','utf-8');}function foldLatest(a){const b=new Map();for(const c of a)b['set'](c['id'],c);return[...b['values']()];}export function addProblem(a,b){const c={'id':newRecordId('prob'),'created_at':new Date()['toISOString'](),...b['stage']?{'stage':b['stage']}:{},...b['object']?{'object':b['object']}:{},'severity':b['severity'],'status':'open','title':b['title'],...b['detail']?{'detail':b['detail']}:{},'notes':b['note']?[{'at':new Date()['toISOString'](),'by':b['note']['by'],'text':b['note']['text']}]:[],...b['origin']?{'origin':b['origin']}:{}};return appendJsonlRecord(problemsPath(a),c),c;}export function updateProblem(a,b,c,d){const e=foldLatest(readJsonl(problemsPath(a)))['find'](g=>g['id']===b);if(!e)throw new Error('problem\x20not\x20found:\x20'+b);const f={...e,...Object['fromEntries'](Object['entries'](c)['filter'](([,g])=>g!==undefined)),'notes':d?[...e['notes'],{'at':new Date()['toISOString'](),'by':d['by'],'text':d['text']}]:e['notes']};return appendJsonlRecord(problemsPath(a),f),f;}export function listProblems(a,b={}){const c=foldLatest(readJsonl(problemsPath(a)));return b['status']?c['filter'](d=>d['status']===b['status']):c;}export function addFeedback(a,b){const c={'id':newRecordId('fb'),'at':new Date()['toISOString'](),'source':b['source'],'sentiment':b['sentiment'],'comment':b['comment'],...b['refs']?{'refs':b['refs']}:{}};return appendJsonlRecord(feedbackPath(a),c),c;}export function listFeedback(a){return readJsonl(feedbackPath(a));}export function addDecision(a,b){const c={'id':newRecordId('dec'),'at':new Date()['toISOString'](),...b['stage']?{'stage':b['stage']}:{},'by':b['by'],'decision':b['decision'],...b['rationale']?{'rationale':b['rationale']}:{},'reversible':b['reversible']};return appendJsonlRecord(decisionsPath(a),c),c;}export function listDecisions(a){return readJsonl(decisionsPath(a));}export function appendSubstep(a,b,c){appendJsonlRecord(substepsPath(a,b),c);}export function readSubsteps(a,b){return readJsonl(substepsPath(a,b));}export function savePayload(a,b,c){const d=join(a,b);return mkdirSync(dirname(d),{'recursive':!![]}),writeFileSync(d,JSON['stringify'](c,null,0x2),'utf-8'),d;}export function loadPayload(a,b){const c=join(a,b);if(!existsSync(c))return undefined;return JSON['parse'](readFileSync(c,'utf-8'));}export function exportBundle(a){const b=loadManifest(a),c={},d={};function e(f){if(!existsSync(f))return;for(const g of readdirSync(f,{'withFileTypes':!![]})){const h=join(f,g['name']);if(g['isDirectory']())e(h);else{if(g['isFile']()){const i=relKey(a,h);if(i==='manifest.json'||i==='stage.json')continue;if(g['name']['endsWith']('.json'))try{c[i]=JSON['parse'](readFileSync(h,'utf-8'));}catch{}else{const j=g['name']['match'](/^substeps-(.+)\.jsonl$/);if(j)d[j[0x1]]=readJsonl(h);}}}}}return e(a),{'schema_version':PROCESS_SCHEMA_VERSION,'exported_at':new Date()['toISOString'](),'manifest':b,'stage':loadStageState(a),'events':readEvents(a),'problems':listProblems(a),'feedback':listFeedback(a),'decisions':listDecisions(a),'substeps':d,'payloads':c};}function remapDeep(a,b,c){if(typeof a==='string'){const d=b[a];if(d!==undefined)return c['n']+=0x1,d;return a;}if(Array['isArray'](a))return a['map'](e=>remapDeep(e,b,c));if(a!==null&&typeof a==='object'){const e={};for(const [f,g]of Object['entries'](a)){e[f]=remapDeep(g,b,c);}return e;}return a;}export function importBundle(a,b,c={}){const g=c['remap']??{},h={'n':0x0};mkdirSync(a,{'recursive':!![]});const i=remapDeep(b['manifest'],g,h);i['updated_at']=new Date()['toISOString'](),writeFileSync(manifestPath(a),JSON['stringify'](i,null,0x2),'utf-8');b['stage']&&writeFileSync(stageStatePath(a),JSON['stringify'](b['stage'],null,0x2),'utf-8');for(const j of b['events'])appendJsonlRecord(eventsPath(a),j);for(const k of b['problems'])appendJsonlRecord(problemsPath(a),k);for(const l of b['feedback'])appendJsonlRecord(feedbackPath(a),l);for(const m of b['decisions'])appendJsonlRecord(decisionsPath(a),m);for(const [n,o]of Object['entries'](b['substeps'])){for(const q of o){appendJsonlRecord(substepsPath(a,n),remapDeep(q,g,h));}}for(const [s,t]of Object['entries'](b['payloads'])){savePayload(a,s,remapDeep(t,g,h));}return appendEvent(a,{'timestamp':new Date()['toISOString'](),'event':'process_imported','reason':'process\x20imported\x20from\x20bundle\x20(exported_at\x20'+b['exported_at']+')','data':{'remapped':h['n']}}),i;}export function forkProcess(a,b){const c=loadManifest(a);mkdirSync(b,{'recursive':!![]});function d(f,g){for(const h of readdirSync(f,{'withFileTypes':!![]})){const i=join(f,h['name']),j=join(g,h['name']);if(h['isDirectory']())mkdirSync(j,{'recursive':!![]}),d(i,j);else h['isFile']()&&copyFileSync(i,j);}}d(a,b);const e={...c,'process_id':basename(b),'forked_from':c['process_id'],'archived':![],'updated_at':new Date()['toISOString']()};return writeFileSync(manifestPath(b),JSON['stringify'](e,null,0x2),'utf-8'),appendEvent(b,{'timestamp':new Date()['toISOString'](),'event':'process_forked','reason':'forked\x20from\x20'+c['process_id']+'\x20('+a+')','data':{'source_dir':a,'source_process':c['process_id']}}),e;}export function listProcesses(a=processesRootDir()){if(!existsSync(a))return[];const b=[];for(const c of readdirSync(a,{'withFileTypes':!![]})){if(!c['isDirectory']())continue;const d=join(a,c['name']);if(!existsSync(manifestPath(d)))continue;const f={'dir_name':c['name'],'path':d,'archived':![],'mtime':0x0};try{f['manifest']=loadManifest(d),f['archived']=f['manifest']['archived'];}catch{}try{const g=loadStageState(d);g&&(f['current_stage']=g['current_stage'],f['stages']=g['stages'],f['committed_stages']=g['stages']['filter'](h=>g['stage_meta'][h]?.['committed']));}catch{}try{f['mtime']=statSync(d)['mtimeMs'];}catch{}b['push'](f);}return b['sort']((h,i)=>i['mtime']-h['mtime']);}
@@ -0,0 +1,11 @@
1
+ export interface ProcessPlaybook {
2
+ name: string;
3
+ stages: string[];
4
+ description?: string;
5
+ }
6
+ export declare function registerPlaybook(playbook: ProcessPlaybook): void;
7
+ export declare function getPlaybook(name: string): ProcessPlaybook | undefined;
8
+ export declare function listPlaybooks(): ProcessPlaybook[];
9
+ export declare function hasPlaybook(name: string): boolean;
10
+ export declare const GENERIC_PLAYBOOK = "generic";
11
+ export declare function playbookForGoalType(goalType: string): ProcessPlaybook;
@@ -0,0 +1 @@
1
+ const registry=new Map();export function registerPlaybook(a){if(!a['name'])throw new Error('playbook\x20requires\x20a\x20name');if(a['stages']['length']===0x0)throw new Error('playbook\x20\x27'+a['name']+'\x27\x20requires\x20stages');registry['set'](a['name'],{...a,'stages':[...a['stages']]});}export function getPlaybook(a){return registry['get'](a);}export function listPlaybooks(){return[...registry['values']()];}export function hasPlaybook(a){return registry['has'](a);}export const GENERIC_PLAYBOOK='generic';export function playbookForGoalType(a){switch(a){case'publish_service':return registry['get']('service-build');case'fulfill_order':return registry['get']('order-fulfillment');case'capture_demand':return registry['get']('demand-capture');case'publish_demand':return registry['get']('demand-publish');case'purchase_service':return registry['get']('purchase');default:return registry['get'](GENERIC_PLAYBOOK);}}registerPlaybook({'name':GENERIC_PLAYBOOK,'stages':['prepare','execute','verify','close'],'description':'Fallback\x20stage\x20sequence\x20for\x20goals\x20without\x20a\x20dedicated\x20playbook.'}),registerPlaybook({'name':'service-build','stages':['namespace','puzzle','risk','doc','substeps'],'description':'Design\x20&\x20publish\x20a\x20commercial\x20service\x20(content:\x20src/playbooks/service-build/).'}),registerPlaybook({'name':'order-fulfillment','stages':['confirm','deliver','accept','settle'],'description':'Merchant-side\x20order\x20fulfillment.'}),registerPlaybook({'name':'demand-capture','stages':['discover','evaluate','engage','close'],'description':'Discover\x20and\x20capture\x20demand\x20opportunities.'}),registerPlaybook({'name':'demand-publish','stages':['draft','fund','publish','close'],'description':'Publish\x20a\x20funded\x20demand.'}),registerPlaybook({'name':'purchase','stages':['select','order','monitor','review'],'description':'Purchase\x20a\x20service\x20and\x20see\x20it\x20delivered.'});
@@ -0,0 +1,22 @@
1
+ export type GateDimension = "semantic" | "tools" | "reversibility" | "risk" | "isolation" | "gas_budget";
2
+ export interface GasBudgetCheck {
3
+ network: "testnet" | "mainnet";
4
+ already_spent_gas: number;
5
+ estimated_rerun_gas: number;
6
+ warning?: string;
7
+ }
8
+ export interface StageGateCheck {
9
+ dimension: GateDimension;
10
+ status: "PASS" | "FAIL" | "WARN";
11
+ message: string;
12
+ }
13
+ export interface StageGateResult {
14
+ stage: string;
15
+ passed: boolean;
16
+ checks: StageGateCheck[];
17
+ blocking_issues: string[];
18
+ warnings: string[];
19
+ can_proceed: boolean;
20
+ }
21
+ export declare function buildGasBudgetCheck(gas?: GasBudgetCheck): StageGateCheck;
22
+ export declare function composeStageGateResult(stage: string, checks: StageGateCheck[]): StageGateResult;
@@ -0,0 +1 @@
1
+ export function buildGasBudgetCheck(a){if(!a)return{'dimension':'gas_budget','status':'PASS','message':'Gas\x20budget\x20not\x20provided\x20(N/A\x20for\x20this\x20stage\x20or\x20caller\x20omitted)'};if(a['network']==='testnet')return{'dimension':'gas_budget','status':'PASS','message':'testnet:\x20no\x20gas\x20limit\x20(faucet\x20is\x20free);\x20rollback\x20is\x20costless'};const b=a['already_spent_gas']+a['estimated_rerun_gas'],c=a['warning']??'mainnet:\x20estimated\x20total\x20gas\x20'+b+'\x20MIST\x20(already_spent='+a['already_spent_gas']+'\x20+\x20rerun='+a['estimated_rerun_gas']+').\x20Rollback\x20will\x20incur\x20real\x20cost.';return{'dimension':'gas_budget','status':'WARN','message':c};}export function composeStageGateResult(a,b){const c=b['filter'](e=>e['status']==='FAIL')['map'](e=>'['+e['dimension']+']\x20'+e['message']),d=b['filter'](e=>e['status']==='WARN')['map'](e=>'['+e['dimension']+']\x20'+e['message']);return{'stage':a,'passed':c['length']===0x0,'checks':b,'blocking_issues':c,'warnings':d,'can_proceed':c['length']===0x0};}
@@ -1,50 +1,11 @@
1
- import type { ProjectObjectType } from "./namespace.js";
2
- export type SubstepNetwork = "testnet" | "mainnet";
1
+ import type { SubstepEdge, SubstepRecord } from "./types.js";
3
2
  export type SubstepStatus = "PENDING" | "SUCCESS" | "FAILED" | "SKIPPED";
4
- export interface OutputRef {
5
- substep_id: string;
6
- field_path: string;
7
- }
8
- export interface SubstepRecord {
9
- step_id: string;
10
- parent_step: string;
11
- object_type: ProjectObjectType;
12
- entry_id: string;
13
- operation_type: string;
14
- network: SubstepNetwork;
15
- input: {
16
- data: Record<string, unknown>;
17
- input_refs: string[];
18
- };
19
- output?: {
20
- object_id?: string;
21
- tx_digest?: string;
22
- [key: string]: unknown;
23
- };
24
- timestamp: number;
25
- status: SubstepStatus;
26
- failure_reason?: string;
27
- dependencies: {
28
- input_refs: string[];
29
- output_refs: OutputRef[];
30
- };
31
- retry_info?: {
32
- original_step_id: string;
33
- retry_count: number;
34
- retry_reason: string;
35
- };
36
- }
37
- export interface SubstepEdge {
38
- source: string;
39
- target: string;
40
- field_path: string;
41
- }
42
3
  export interface SubstepDAG {
43
4
  namespace: {
44
5
  prefix: string;
45
6
  version: string;
46
7
  };
47
- network: SubstepNetwork;
8
+ network: string;
48
9
  substeps: SubstepRecord[];
49
10
  edges: SubstepEdge[];
50
11
  topological_order: string[];
@@ -79,7 +40,7 @@ export interface StepTraceDetail {
79
40
  export interface SubstepTraceInput {
80
41
  project_prefix: string;
81
42
  version: string;
82
- network: SubstepNetwork;
43
+ network: string;
83
44
  substeps: SubstepRecord[];
84
45
  edges?: SubstepEdge[];
85
46
  }
@@ -88,7 +49,7 @@ export interface SubstepTraceResult {
88
49
  prefix: string;
89
50
  version: string;
90
51
  };
91
- network: SubstepNetwork;
52
+ network: string;
92
53
  coherent: boolean;
93
54
  dangling_inputs: DanglingInput[];
94
55
  circular_refs: CircularRef[];
@@ -113,7 +74,7 @@ export declare class SubstepTracer {
113
74
  private records;
114
75
  private namespace;
115
76
  private network;
116
- constructor(prefix: string, version: string, network: SubstepNetwork);
77
+ constructor(prefix: string, version: string, network: string);
117
78
  record(rec: SubstepRecord): void;
118
79
  getTrace(): SubstepRecord[];
119
80
  updateStatus(step_id: string, status: SubstepStatus, output?: Record<string, unknown>, failure_reason?: string): void;
@@ -124,7 +85,7 @@ export declare class SubstepTracer {
124
85
  prefix: string;
125
86
  version: string;
126
87
  };
127
- network: SubstepNetwork;
88
+ network: string;
128
89
  substeps: SubstepRecord[];
129
90
  };
130
91
  }
@@ -0,0 +1,120 @@
1
+ export declare const PROCESS_SCHEMA_VERSION = "1.0.0";
2
+ export interface ProcessManifest {
3
+ schema_version: string;
4
+ mcp_version: string;
5
+ process_id: string;
6
+ playbook: string;
7
+ goal_id?: string;
8
+ title: string;
9
+ network?: string;
10
+ objects: {
11
+ type: string;
12
+ object: string;
13
+ }[];
14
+ created_at: string;
15
+ updated_at: string;
16
+ forked_from?: string;
17
+ archived: boolean;
18
+ }
19
+ export interface StageMeta {
20
+ committed: boolean;
21
+ committed_at?: number;
22
+ gate_passed: boolean;
23
+ blocking_issues: string[];
24
+ completion: number;
25
+ }
26
+ export interface ProcessStageState {
27
+ stages: string[];
28
+ current_stage: string;
29
+ stage_meta: Record<string, StageMeta>;
30
+ updated_at: number;
31
+ }
32
+ export interface ProcessEvent {
33
+ timestamp: string;
34
+ event: string;
35
+ stage?: string;
36
+ reason: string;
37
+ data?: Record<string, unknown>;
38
+ user_confirmed?: boolean;
39
+ }
40
+ export interface ProblemRecord {
41
+ id: string;
42
+ created_at: string;
43
+ stage?: string;
44
+ object?: string;
45
+ severity: "low" | "medium" | "high" | "critical";
46
+ status: "open" | "resolved" | "wontfix";
47
+ title: string;
48
+ detail?: string;
49
+ notes: {
50
+ at: string;
51
+ by: "user" | "agent" | "system";
52
+ text: string;
53
+ }[];
54
+ origin?: {
55
+ source: "monitor";
56
+ network: string;
57
+ event_id: string;
58
+ event_type: string;
59
+ };
60
+ }
61
+ export interface FeedbackRecord {
62
+ id: string;
63
+ at: string;
64
+ source: "user" | "agent" | "system";
65
+ sentiment: "positive" | "negative" | "neutral";
66
+ comment: string;
67
+ refs?: {
68
+ stage?: string;
69
+ object?: string;
70
+ run_id?: string;
71
+ };
72
+ }
73
+ export interface DecisionRecord {
74
+ id: string;
75
+ at: string;
76
+ stage?: string;
77
+ by: "user" | "agent";
78
+ decision: string;
79
+ rationale?: string;
80
+ reversible: boolean;
81
+ }
82
+ export interface OutputRef {
83
+ substep_id: string;
84
+ field_path: string;
85
+ }
86
+ export interface SubstepEdge {
87
+ source: string;
88
+ target: string;
89
+ field_path: string;
90
+ }
91
+ export interface SubstepRecord {
92
+ step_id: string;
93
+ parent_step: string;
94
+ object_type: string;
95
+ entry_id: string;
96
+ operation_type: string;
97
+ network: string;
98
+ input: {
99
+ data: Record<string, unknown>;
100
+ input_refs: string[];
101
+ };
102
+ output?: {
103
+ object_id?: string;
104
+ tx_digest?: string;
105
+ [key: string]: unknown;
106
+ };
107
+ timestamp: number;
108
+ status: "PENDING" | "SUCCESS" | "FAILED" | "SKIPPED";
109
+ failure_reason?: string;
110
+ dependencies: {
111
+ input_refs: string[];
112
+ output_refs: OutputRef[];
113
+ };
114
+ retry_info?: {
115
+ original_step_id: string;
116
+ retry_count: number;
117
+ retry_reason: string;
118
+ };
119
+ }
120
+ export declare function newProcessId(): string;
@@ -0,0 +1 @@
1
+ export const PROCESS_SCHEMA_VERSION='1.0.0';export function newProcessId(){return'proc_'+Date['now']()['toString'](0x24)+'_'+Math['random']()['toString'](0x24)['slice'](0x2,0x8);}
@@ -1 +1 @@
1
- import{listServices,getServiceInfo,toggle as a365a,setEnabled as a365b,reset as a365c}from'../../config/index.js';import{strictParse}from'../../schema/index.js';import{ConfigOperationInputSchema}from'../../schema/config/index.js';export async function handleConfigOperation(a){const b=strictParse(ConfigOperationInputSchema,a,'config_operation\x20input'),{action:c,service:d}=b;let e;switch(c){case'list':e={'action':'list','services':listServices()};break;case'toggle':{if(!d)throw new Error('\x27service\x27\x20param\x20is\x20required\x20for\x20toggle');const f=d,g=getServiceInfo(f);if(!g)throw new Error('Unknown\x20service:\x20'+f+'.\x20Use\x20action=\x27list\x27\x20to\x20see\x20all\x20valid\x20services.');const h=a365a(f);e={'action':'toggle','service':f,'enabled':h,'reminder':g['reminder']};break;}case'enable':{if(!d)throw new Error('\x27service\x27\x20param\x20is\x20required\x20for\x20enable');const i=d,j=getServiceInfo(i);if(!j)throw new Error('Unknown\x20service:\x20'+i+'.\x20Use\x20action=\x27list\x27\x20to\x20see\x20all\x20valid\x20services.');a365b(i,!![]),e={'action':'enable','service':i,'enabled':!![],'reminder':j['reminder']};break;}case'disable':{if(!d)throw new Error('\x27service\x27\x20param\x20is\x20required\x20for\x20disable');const k=d,l=getServiceInfo(k);if(!l)throw new Error('Unknown\x20service:\x20'+k+'.\x20Use\x20action=\x27list\x27\x20to\x20see\x20all\x20valid\x20services.');a365b(k,![]),e={'action':'disable','service':k,'enabled':![],'reminder':l['reminder']};break;}case'reset':{if(!d)throw new Error('\x27service\x27\x20param\x20is\x20required\x20for\x20reset');const m=d,n=getServiceInfo(m);if(!n)throw new Error('Unknown\x20service:\x20'+m+'.\x20Use\x20action=\x27list\x27\x20to\x20see\x20all\x20valid\x20services.');a365c(m),e={'action':'reset','service':m,'enabled':getServiceInfo(m)?.['enabled'],'reminder':n['reminder'],'reset':!![]};break;}case'info':{if(!d)throw new Error('\x27service\x27\x20param\x20is\x20required\x20for\x20info');const o=d,p=getServiceInfo(o);if(!p)throw new Error('Unknown\x20service:\x20'+o+'.\x20Use\x20action=\x27list\x27\x20to\x20see\x20all\x20valid\x20services.');e={'action':'info',...p};break;}default:throw new Error('Unknown\x20config_operation\x20action:\x20'+String(c));}return{'content':[{'type':'text','text':JSON['stringify']({'result':e})}],'structuredContent':{'result':e}};}
1
+ import{listServices,getServiceInfo,toggle as a384a,setEnabled as a384b,reset as a384c}from'../../config/index.js';import{strictParse}from'../../schema/index.js';import{ConfigOperationInputSchema}from'../../schema/config/index.js';export async function handleConfigOperation(a){const b=strictParse(ConfigOperationInputSchema,a,'config_operation\x20input'),{action:c,service:d}=b;let e;switch(c){case'list':e={'action':'list','services':listServices()};break;case'toggle':{if(!d)throw new Error('\x27service\x27\x20param\x20is\x20required\x20for\x20toggle');const f=d,g=getServiceInfo(f);if(!g)throw new Error('Unknown\x20service:\x20'+f+'.\x20Use\x20action=\x27list\x27\x20to\x20see\x20all\x20valid\x20services.');const h=a384a(f);e={'action':'toggle','service':f,'enabled':h,'reminder':g['reminder']};break;}case'enable':{if(!d)throw new Error('\x27service\x27\x20param\x20is\x20required\x20for\x20enable');const i=d,j=getServiceInfo(i);if(!j)throw new Error('Unknown\x20service:\x20'+i+'.\x20Use\x20action=\x27list\x27\x20to\x20see\x20all\x20valid\x20services.');a384b(i,!![]),e={'action':'enable','service':i,'enabled':!![],'reminder':j['reminder']};break;}case'disable':{if(!d)throw new Error('\x27service\x27\x20param\x20is\x20required\x20for\x20disable');const k=d,l=getServiceInfo(k);if(!l)throw new Error('Unknown\x20service:\x20'+k+'.\x20Use\x20action=\x27list\x27\x20to\x20see\x20all\x20valid\x20services.');a384b(k,![]),e={'action':'disable','service':k,'enabled':![],'reminder':l['reminder']};break;}case'reset':{if(!d)throw new Error('\x27service\x27\x20param\x20is\x20required\x20for\x20reset');const m=d,n=getServiceInfo(m);if(!n)throw new Error('Unknown\x20service:\x20'+m+'.\x20Use\x20action=\x27list\x27\x20to\x20see\x20all\x20valid\x20services.');a384c(m),e={'action':'reset','service':m,'enabled':getServiceInfo(m)?.['enabled'],'reminder':n['reminder'],'reset':!![]};break;}case'info':{if(!d)throw new Error('\x27service\x27\x20param\x20is\x20required\x20for\x20info');const o=d,p=getServiceInfo(o);if(!p)throw new Error('Unknown\x20service:\x20'+o+'.\x20Use\x20action=\x27list\x27\x20to\x20see\x20all\x20valid\x20services.');e={'action':'info',...p};break;}default:throw new Error('Unknown\x20config_operation\x20action:\x20'+String(c));}return{'content':[{'type':'text','text':JSON['stringify']({'result':e})}],'structuredContent':{'result':e}};}
@@ -0,0 +1,4 @@
1
+ import { type GoalEngine } from "../../goal/GoalEngine.js";
2
+ import type { ToolDispatchResult } from "../types.js";
3
+ export declare function setGoalEngineDeps(engine?: GoalEngine): void;
4
+ export declare function handleGoalOperation(args: unknown): Promise<ToolDispatchResult>;
@@ -0,0 +1 @@
1
+ import{strictParse}from'../../schema/index.js';import{GoalOperationInputSchema}from'../../schema/goal/index.js';import{goalEngine}from'../../goal/GoalEngine.js';import{isTerminalStage}from'../../goal/types.js';import{resolveNetwork}from'./network.js';import{handleAnalyzeIntent,handleAggregateRisks,handleTraceSubsteps}from'../../playbooks/service-build/pipeline-actions.js';import{handleMerchantGuide}from'../../playbooks/service-build/merchant-guide.js';let engineOverride;export function setGoalEngineDeps(a){engineOverride=a;}function engine(){return engineOverride??goalEngine;}export async function handleGoalOperation(a){const b=strictParse(GoalOperationInputSchema,a,'goal_operation\x20input'),c=await resolveNetwork(b['network']),d=engine();let e;switch(b['action']){case'create':{const f=await d['createOrAdopt']({'intent_text':b['intent_text'],...b['goal_type']?{'goal_type':b['goal_type']}:{},...b['account']?{'account':b['account']}:{},...b['persona']?{'persona':b['persona']}:{},...b['title']?{'title':b['title']}:{},...b['conversation_id']?{'conversation_id':b['conversation_id']}:{},...b['create_process']!==undefined?{'create_process':b['create_process']}:{},'network':c});e={'action':'create',...f};break;}case'list':{const {goals:g,counts:h}=await d['list'](c,{...b['stage']?{'stage':b['stage']}:{},...b['account']?{'account':b['account']}:{},...b['conversation_id']?{'conversation_id':b['conversation_id']}:{}}),i=b['include_finished']?g:g['filter'](j=>!isTerminalStage(j['stage']));e={'action':'list','goals':i,'counts':h};break;}case'get':{e={'action':'get','goal':await d['get'](c,b['id'])};break;}case'approve':{e={'action':'approve','goal':await d['approve'](c,b['id'],b['note'])};break;}case'bind':{e={'action':'bind','goal':await d['bind'](c,b['id'],b['account'],b['persona'])};break;}case'advance':{const j=await d['advance'](c,b['id'],{...b['stage']?{'stage':b['stage']}:{},...b['objects']?{'objects':b['objects']}:{}});e={'action':'advance','goal':j};break;}case'pause':{e={'action':'pause','goal':await d['pause'](c,b['id'])};break;}case'complete':{const k=await d['complete'](c,b['id'],{'force':b['force']===!![],...b['feedback']?{'feedback':b['feedback']}:{}});e={'action':'complete',...k};break;}case'abandon':{const l=await d['abandon'](c,b['id'],b['reason']);e={'action':'abandon',...l};break;}case'delete':{const m=await d['remove'](c,b['id'],{'force':b['force']===!![]});e={'action':'delete',...m};break;}case'analyze_intent':e=await handleAnalyzeIntent(b);break;case'aggregate_risks':e=await handleAggregateRisks(b);break;case'trace_substeps':e=await handleTraceSubsteps(b);break;case'merchant_guide':e=await handleMerchantGuide(b);break;default:throw new Error('Unknown\x20goal_operation\x20action');}return{'content':[{'type':'text','text':JSON['stringify']({'result':e})}],'structuredContent':{'result':e}};}
@@ -1 +1 @@
1
- import{readdirSync,readFileSync,writeFileSync,existsSync,mkdirSync,statSync,cpSync,renameSync,rmSync}from'node:fs';import{join,relative,resolve,sep,dirname,basename}from'node:path';import{strictParse}from'../../schema/index.js';import{IndustryPackOperationInputSchema}from'../../schema/industry-pack/index.js';import{scaffoldIndustryPack,listRegisteredPacks,scanDefaultIndustryPacks,seedBuiltinIndustryTemplates,ensureIndustryReadme,resolveIndustryPackDir,rescanPack,resolveDisputeRules,resolveComplianceRules,resolveSupplyRules,resolveIndustryRules,resolveIndustryPlaybook,diffIndustryPack,resetIndustryPath}from'../../extensions/index.js';const INDUSTRY_ROOT=resolveIndustryPackDir();function resolveIndustryPath(a){const b=resolve(INDUSTRY_ROOT,a);if(b!==INDUSTRY_ROOT&&!b['startsWith'](INDUSTRY_ROOT+sep))throw new Error('path\x20\x27'+a+'\x27\x20escapes\x20the\x20industry\x20root');return b;}function rescanAffectedPack(a){const b=a['split'](/[\\/]+/)['find'](c=>c['length']>0x0);if(!b)return;rescanPack(b);}function listRecursive(a,b,c,d=0x0){if(d>0x8)return;let f;try{f=readdirSync(a,{'withFileTypes':!![]});}catch{return;}for(const g of f){const h=join(a,g['name']),i=relative(b,h)['split'](sep)['join']('/');let j=0x0,k=0x0;try{const l=statSync(h);k=l['size'],j=l['mtimeMs'];}catch{}g['isDirectory']()?(c['push']({'path':i,'is_dir':!![],'size':0x0,'mtime':j}),listRecursive(h,b,c,d+0x1)):c['push']({'path':i,'is_dir':![],'size':k,'mtime':j});}}export async function handleIndustryPackOperation(a){const b=strictParse(IndustryPackOperationInputSchema,a,'industry_pack_operation\x20input');mkdirSync(INDUSTRY_ROOT,{'recursive':!![]}),seedBuiltinIndustryTemplates(),ensureIndustryReadme();let c;switch(b['action']){case'scaffold':{if(!b['name'])throw new Error('\x27name\x27\x20is\x20required\x20for\x20action=\x27scaffold\x27');const d=scaffoldIndustryPack(b['name']);c={'action':'scaffold','ok':d['ok'],'dir':d['dir'],'files':d['files'],'errors':d['errors']};if(d['ok'])rescanPack(b['name']);break;}case'list':{c={'action':'list','packs':listRegisteredPacks()};break;}case'scan':{c={'action':'scan','results':scanDefaultIndustryPacks()};break;}case'resolve':{c={'action':'resolve','dir':INDUSTRY_ROOT};break;}case'list_files':{const e=[];listRecursive(INDUSTRY_ROOT,INDUSTRY_ROOT,e),c={'action':'list_files','dir':INDUSTRY_ROOT,'files':e};break;}case'read_file':{if(!b['path'])throw new Error('\x27path\x27\x20is\x20required\x20for\x20action=\x27read_file\x27');const f=resolveIndustryPath(b['path']);if(!existsSync(f))throw new Error('file\x20not\x20found:\x20'+b['path']);c={'action':'read_file','path':f,'content':readFileSync(f,'utf-8')};break;}case'write_file':{if(!b['path'])throw new Error('\x27path\x27\x20is\x20required\x20for\x20action=\x27write_file\x27');if(b['content']===undefined)throw new Error('\x27content\x27\x20is\x20required\x20for\x20action=\x27write_file\x27');const g=resolveIndustryPath(b['path']);mkdirSync(dirname(g),{'recursive':!![]}),writeFileSync(g,b['content'],'utf-8'),c={'action':'write_file','path':g,'ok':!![]},rescanAffectedPack(b['path']);break;}case'get':{if(!b['name'])throw new Error('\x27name\x27\x20is\x20required\x20for\x20action=\x27get\x27');const h=b['name'];c={'action':'get','category':h,...resolveDisputeRules(h)?{'dispute':resolveDisputeRules(h)}:{},...resolveComplianceRules(h)?{'compliance':resolveComplianceRules(h)}:{},...resolveSupplyRules(h)?{'supply':resolveSupplyRules(h)}:{},...resolveIndustryRules(h)?{'rules':resolveIndustryRules(h)}:{},...resolveIndustryPlaybook(h)?{'playbook':resolveIndustryPlaybook(h)}:{}};break;}case'diff':{if(!b['name'])throw new Error('\x27name\x27\x20is\x20required\x20for\x20action=\x27diff\x27');c={'action':'diff',...diffIndustryPack(b['name'])};break;}case'reset':{if(!b['path'])throw new Error('\x27path\x27\x20is\x20required\x20for\x20action=\x27reset\x27');const i=resetIndustryPath(b['path']);c={'action':'reset','ok':i['ok'],'layout':i['layout'],'target':i['target'],'restored_files':i['restored_files'],'errors':i['errors']},rescanAffectedPack(b['path']);break;}case'delete_file':{if(!b['path'])throw new Error('\x27path\x27\x20is\x20required\x20for\x20action=\x27delete_file\x27');const j=resolveIndustryPath(b['path']);if(!existsSync(j))throw new Error('file\x20not\x20found:\x20'+b['path']);rmSync(j,{'recursive':!![],'force':!![]}),c={'action':'delete_file','path':j,'ok':!![]},rescanAffectedPack(b['path']);break;}case'create_file':{if(!b['path'])throw new Error('\x27path\x27\x20is\x20required\x20for\x20action=\x27create_file\x27');const k=resolveIndustryPath(b['path']);if(existsSync(k))throw new Error('file\x20already\x20exists:\x20'+b['path']);mkdirSync(dirname(k),{'recursive':!![]}),writeFileSync(k,b['content']??'','utf-8'),c={'action':'create_file','path':k,'ok':!![]},rescanAffectedPack(b['path']);break;}case'create_dir':{if(!b['path'])throw new Error('\x27path\x27\x20is\x20required\x20for\x20action=\x27create_dir\x27');const l=resolveIndustryPath(b['path']);mkdirSync(l,{'recursive':!![]}),c={'action':'create_dir','path':l,'ok':!![]},rescanAffectedPack(b['path']);break;}case'copy':{if(!b['from'])throw new Error('\x27from\x27\x20is\x20required\x20for\x20action=\x27copy\x27');if(!b['to'])throw new Error('\x27to\x27\x20is\x20required\x20for\x20action=\x27copy\x27');const m=resolveIndustryPath(b['from']);let n=resolveIndustryPath(b['to']);if(!existsSync(m))throw new Error('source\x20not\x20found:\x20'+b['from']);try{existsSync(n)&&statSync(n)['isDirectory']()&&(n=join(n,basename(m)));}catch{}if(n===m)throw new Error('\x27copy\x27\x20cannot\x20copy\x20a\x20file\x20onto\x20itself');mkdirSync(dirname(n),{'recursive':!![]}),cpSync(m,n,{'recursive':!![],'force':!![]}),c={'action':'copy','from':m,'to':n,'ok':!![]},rescanAffectedPack(b['to']);break;}case'move':case'rename':{if(!b['from'])throw new Error('\x27from\x27\x20is\x20required\x20for\x20action=\x27'+b['action']+'\x27');if(!b['to'])throw new Error('\x27to\x27\x20is\x20required\x20for\x20action=\x27'+b['action']+'\x27');const o=resolveIndustryPath(b['from']);let p=resolveIndustryPath(b['to']);if(!existsSync(o))throw new Error('source\x20not\x20found:\x20'+b['from']);try{existsSync(p)&&statSync(p)['isDirectory']()&&(p=join(p,basename(o)));}catch{}if(p===o)throw new Error('\x27'+b['action']+'\x27\x20cannot\x20move\x20onto\x20itself');mkdirSync(dirname(p),{'recursive':!![]}),renameSync(o,p),c={'action':b['action'],'from':o,'to':p,'ok':!![]},rescanAffectedPack(b['from']),rescanAffectedPack(b['to']);break;}default:throw new Error('Unknown\x20industry_pack_operation\x20action:\x20'+String(b['action']));}return{'content':[{'type':'text','text':JSON['stringify']({'result':c})}],'structuredContent':{'result':c}};}
1
+ import{readdirSync,readFileSync,writeFileSync,existsSync,mkdirSync,statSync,cpSync,renameSync,rmSync}from'node:fs';import{join,relative,resolve,sep,dirname,basename}from'node:path';import{strictParse}from'../../schema/index.js';import{IndustryPackOperationInputSchema}from'../../schema/industry-pack/index.js';import{scaffoldIndustryPack,listRegisteredPacks,scanDefaultIndustryPacks,seedBuiltinIndustryTemplates,ensureIndustryReadme,resolveIndustryPackDir,rescanPack,resolveDisputeRules,resolveComplianceRules,resolveSupplyRules,resolveIndustryRules,resolveIndustryPlaybook,diffIndustryPack,resetIndustryPath}from'../../extensions/index.js';import{handleRecommendIndustry,handleListModes,handleDeriveUserMode,handleEvolveUserMode,handleRegisterUserMode,handleUnregisterUserMode,handleRegisterCustomMetric,handleRegisterCustomConstraint,handleListMetricsConstraints}from'../../playbooks/service-build/mode-actions.js';const INDUSTRY_ROOT=resolveIndustryPackDir();function resolveIndustryPath(a){const b=resolve(INDUSTRY_ROOT,a);if(b!==INDUSTRY_ROOT&&!b['startsWith'](INDUSTRY_ROOT+sep))throw new Error('path\x20\x27'+a+'\x27\x20escapes\x20the\x20industry\x20root');return b;}function rescanAffectedPack(a){const b=a['split'](/[\\/]+/)['find'](c=>c['length']>0x0);if(!b)return;rescanPack(b);}function listRecursive(a,b,c,d=0x0){if(d>0x8)return;let f;try{f=readdirSync(a,{'withFileTypes':!![]});}catch{return;}for(const g of f){const h=join(a,g['name']),i=relative(b,h)['split'](sep)['join']('/');let j=0x0,k=0x0;try{const l=statSync(h);k=l['size'],j=l['mtimeMs'];}catch{}g['isDirectory']()?(c['push']({'path':i,'is_dir':!![],'size':0x0,'mtime':j}),listRecursive(h,b,c,d+0x1)):c['push']({'path':i,'is_dir':![],'size':k,'mtime':j});}}export async function handleIndustryPackOperation(a){const b=strictParse(IndustryPackOperationInputSchema,a,'industry_pack_operation\x20input');mkdirSync(INDUSTRY_ROOT,{'recursive':!![]}),seedBuiltinIndustryTemplates(),ensureIndustryReadme();let c;switch(b['action']){case'scaffold':{if(!b['name'])throw new Error('\x27name\x27\x20is\x20required\x20for\x20action=\x27scaffold\x27');const d=scaffoldIndustryPack(b['name']);c={'action':'scaffold','ok':d['ok'],'dir':d['dir'],'files':d['files'],'errors':d['errors']};if(d['ok'])rescanPack(b['name']);break;}case'list':{c={'action':'list','packs':listRegisteredPacks()};break;}case'scan':{c={'action':'scan','results':scanDefaultIndustryPacks()};break;}case'resolve':{c={'action':'resolve','dir':INDUSTRY_ROOT};break;}case'list_files':{const e=[];listRecursive(INDUSTRY_ROOT,INDUSTRY_ROOT,e),c={'action':'list_files','dir':INDUSTRY_ROOT,'files':e};break;}case'read_file':{if(!b['path'])throw new Error('\x27path\x27\x20is\x20required\x20for\x20action=\x27read_file\x27');const f=resolveIndustryPath(b['path']);if(!existsSync(f))throw new Error('file\x20not\x20found:\x20'+b['path']);c={'action':'read_file','path':f,'content':readFileSync(f,'utf-8')};break;}case'write_file':{if(!b['path'])throw new Error('\x27path\x27\x20is\x20required\x20for\x20action=\x27write_file\x27');if(b['content']===undefined)throw new Error('\x27content\x27\x20is\x20required\x20for\x20action=\x27write_file\x27');const g=resolveIndustryPath(b['path']);mkdirSync(dirname(g),{'recursive':!![]}),writeFileSync(g,b['content'],'utf-8'),c={'action':'write_file','path':g,'ok':!![]},rescanAffectedPack(b['path']);break;}case'get':{if(!b['name'])throw new Error('\x27name\x27\x20is\x20required\x20for\x20action=\x27get\x27');const h=b['name'];c={'action':'get','category':h,...resolveDisputeRules(h)?{'dispute':resolveDisputeRules(h)}:{},...resolveComplianceRules(h)?{'compliance':resolveComplianceRules(h)}:{},...resolveSupplyRules(h)?{'supply':resolveSupplyRules(h)}:{},...resolveIndustryRules(h)?{'rules':resolveIndustryRules(h)}:{},...resolveIndustryPlaybook(h)?{'playbook':resolveIndustryPlaybook(h)}:{}};break;}case'diff':{if(!b['name'])throw new Error('\x27name\x27\x20is\x20required\x20for\x20action=\x27diff\x27');c={'action':'diff',...diffIndustryPack(b['name'])};break;}case'reset':{if(!b['path'])throw new Error('\x27path\x27\x20is\x20required\x20for\x20action=\x27reset\x27');const i=resetIndustryPath(b['path']);c={'action':'reset','ok':i['ok'],'layout':i['layout'],'target':i['target'],'restored_files':i['restored_files'],'errors':i['errors']},rescanAffectedPack(b['path']);break;}case'delete_file':{if(!b['path'])throw new Error('\x27path\x27\x20is\x20required\x20for\x20action=\x27delete_file\x27');const j=resolveIndustryPath(b['path']);if(!existsSync(j))throw new Error('file\x20not\x20found:\x20'+b['path']);rmSync(j,{'recursive':!![],'force':!![]}),c={'action':'delete_file','path':j,'ok':!![]},rescanAffectedPack(b['path']);break;}case'create_file':{if(!b['path'])throw new Error('\x27path\x27\x20is\x20required\x20for\x20action=\x27create_file\x27');const k=resolveIndustryPath(b['path']);if(existsSync(k))throw new Error('file\x20already\x20exists:\x20'+b['path']);mkdirSync(dirname(k),{'recursive':!![]}),writeFileSync(k,b['content']??'','utf-8'),c={'action':'create_file','path':k,'ok':!![]},rescanAffectedPack(b['path']);break;}case'create_dir':{if(!b['path'])throw new Error('\x27path\x27\x20is\x20required\x20for\x20action=\x27create_dir\x27');const l=resolveIndustryPath(b['path']);mkdirSync(l,{'recursive':!![]}),c={'action':'create_dir','path':l,'ok':!![]},rescanAffectedPack(b['path']);break;}case'copy':{if(!b['from'])throw new Error('\x27from\x27\x20is\x20required\x20for\x20action=\x27copy\x27');if(!b['to'])throw new Error('\x27to\x27\x20is\x20required\x20for\x20action=\x27copy\x27');const m=resolveIndustryPath(b['from']);let n=resolveIndustryPath(b['to']);if(!existsSync(m))throw new Error('source\x20not\x20found:\x20'+b['from']);try{existsSync(n)&&statSync(n)['isDirectory']()&&(n=join(n,basename(m)));}catch{}if(n===m)throw new Error('\x27copy\x27\x20cannot\x20copy\x20a\x20file\x20onto\x20itself');mkdirSync(dirname(n),{'recursive':!![]}),cpSync(m,n,{'recursive':!![],'force':!![]}),c={'action':'copy','from':m,'to':n,'ok':!![]},rescanAffectedPack(b['to']);break;}case'move':case'rename':{if(!b['from'])throw new Error('\x27from\x27\x20is\x20required\x20for\x20action=\x27'+b['action']+'\x27');if(!b['to'])throw new Error('\x27to\x27\x20is\x20required\x20for\x20action=\x27'+b['action']+'\x27');const o=resolveIndustryPath(b['from']);let p=resolveIndustryPath(b['to']);if(!existsSync(o))throw new Error('source\x20not\x20found:\x20'+b['from']);try{existsSync(p)&&statSync(p)['isDirectory']()&&(p=join(p,basename(o)));}catch{}if(p===o)throw new Error('\x27'+b['action']+'\x27\x20cannot\x20move\x20onto\x20itself');mkdirSync(dirname(p),{'recursive':!![]}),renameSync(o,p),c={'action':b['action'],'from':o,'to':p,'ok':!![]},rescanAffectedPack(b['from']),rescanAffectedPack(b['to']);break;}case'recommend_industry':c=await handleRecommendIndustry(b);break;case'list_modes':c=await handleListModes();break;case'derive_user_mode':c=await handleDeriveUserMode(b);break;case'evolve_user_mode':c=await handleEvolveUserMode(b);break;case'register_user_mode':c=await handleRegisterUserMode(b);break;case'unregister_user_mode':c=await handleUnregisterUserMode(b);break;case'register_custom_metric':c=await handleRegisterCustomMetric(b);break;case'register_custom_constraint':c=await handleRegisterCustomConstraint(b);break;case'list_metrics_constraints':c=await handleListMetricsConstraints(b);break;default:throw new Error('Unknown\x20industry_pack_operation\x20action:\x20'+String(b['action']));}return{'content':[{'type':'text','text':JSON['stringify']({'result':c})}],'structuredContent':{'result':c}};}
@@ -1,2 +1,26 @@
1
1
  import type { ToolDispatchResult } from "../types.js";
2
+ import { type MonitorEventStore } from "../../monitor/EventStore.js";
3
+ import { type SubscriptionStore } from "../../monitor/SubscriptionStore.js";
4
+ import { type ResolveScopeResult } from "../../monitor/ScopeResolver.js";
5
+ import { type MonitorLoop } from "../../monitor/MonitorLoop.js";
6
+ import { type ScopeSnapshot, type SubscriptionConfig } from "../../monitor/types.js";
7
+ export interface MonitorEventsDeps {
8
+ store: MonitorEventStore;
9
+ configStore: Pick<SubscriptionStore, "getConfig">;
10
+ }
11
+ export declare function setMonitorEventsDeps(deps?: MonitorEventsDeps): void;
2
12
  export declare function handleMonitorEvents(args: unknown): Promise<ToolDispatchResult>;
13
+ export interface MonitorSubscriptionDeps {
14
+ store: Pick<MonitorEventStore, "list" | "getCursors">;
15
+ configStore: Pick<SubscriptionStore, "getConfig" | "saveConfig" | "resetConfig">;
16
+ resolveScope(network: string, config: SubscriptionConfig): Promise<ResolveScopeResult>;
17
+ loadScope(network: string): Promise<ScopeSnapshot | undefined>;
18
+ backfill(network: string, snapshot: ScopeSnapshot, windowDays: number, config: SubscriptionConfig): Promise<{
19
+ rescanned: number;
20
+ updated: number;
21
+ }>;
22
+ loop: Pick<MonitorLoop, "status" | "invalidateScope">;
23
+ logger(message: string): void;
24
+ }
25
+ export declare function setMonitorSubscriptionDeps(deps?: MonitorSubscriptionDeps): void;
26
+ export declare function handleMonitorSubscription(args: unknown): Promise<ToolDispatchResult>;
@@ -1 +1 @@
1
- import{MonitorEventsInputSchema,strictParse}from'../../schema/index.js';import{buildDataSemantic}from'../../schema/call/semantic.js';import{monitorEventStore}from'../../monitor/EventStore.js';import{Config}from'@wowok/wowok/w/local';async function resolveNetwork(a){if(a){const b=await Config['Instance']()['network_get'](a);if(b)return b;}return await Config['Instance']()['network_get']();}export async function handleMonitorEvents(a){const b=strictParse(MonitorEventsInputSchema,a,'monitor_events\x20input'),c=await resolveNetwork(b['network']),d=b['module'];let e;if(b['action']==='query'){const f=await monitorEventStore['list'](c,{'module':d,'limit':b['limit'],'offset':b['offset']});e={'action':'query','events':f['events'],'total':f['total'],'module_counts':f['moduleCounts'],'unread_by_module':f['unreadByModule'],'total_unread':f['totalUnread']};}else{if(b['action']==='mark_read'){const {marked:g}=await monitorEventStore['markRead'](c,b['event_ids']??[]);e={'action':'mark_read','marked':g,'total_unread':await monitorEventStore['unreadCount'](c)};}else{const {marked:h}=await monitorEventStore['markAllRead'](c,d);e={'action':'mark_all_read','marked':h,'total_unread':await monitorEventStore['unreadCount'](c)};}}return{'content':[{'type':'text','text':JSON['stringify']({'result':e})}],'structuredContent':{'result':e,'semantic':buildDataSemantic(e,{'operation_type':'monitor_events','data':b})}};}
1
+ import{MonitorEventsInputSchema,MonitorSubscriptionInputSchema,strictParse}from'../../schema/index.js';import{buildDataSemantic}from'../../schema/call/semantic.js';import{monitorEventStore}from'../../monitor/EventStore.js';import{subscriptionStore}from'../../monitor/SubscriptionStore.js';import{backfillAnnotations,evaluateFilter,shouldDeliver}from'../../monitor/EventRouter.js';import{loadScopeSnapshot,resolveScope}from'../../monitor/ScopeResolver.js';import{monitorLoop}from'../../monitor/MonitorLoop.js';import{MONITOR_CAPTURE_TYPES,PAYMENT_EVENT_TYPE}from'../../monitor/normalize.js';import{LOOP_DEFAULTS}from'../../monitor/types.js';import{resolveNetwork}from'./network.js';let depsOverride;export function setMonitorEventsDeps(a){depsOverride=a;}export async function handleMonitorEvents(a){const b=strictParse(MonitorEventsInputSchema,a,'monitor_events\x20input'),c=await resolveNetwork(b['network']),d=b['module'],e=depsOverride?.['store']??monitorEventStore,f=depsOverride?.['configStore']??subscriptionStore;let g;if(b['action']==='query'){const h=b['with_reason']??![],i=await e['list'](c,{'module':d,'limit':b['limit'],'offset':b['offset'],'eventType':b['event_type'],'since':b['since'],'until':b['until'],'relevantOnly':b['relevant_only']??!![],'withReason':h});if(h){const j=await f['getConfig'](c);for(const k of i['events']){k['relevance']&&(k['delivered']=shouldDeliver(k['relevance'],j));}}g={'action':'query','events':i['events'],'total':i['total'],'module_counts':i['moduleCounts'],'unread_by_module':i['unreadByModule'],'total_unread':i['totalUnread']};}else{if(b['action']==='mark_read'){const {marked:l}=await e['markRead'](c,b['event_ids']??[]);g={'action':'mark_read','marked':l,'total_unread':await e['unreadCount'](c)};}else{const {marked:m}=await e['markAllRead'](c,d);g={'action':'mark_all_read','marked':m,'total_unread':await e['unreadCount'](c)};}}return{'content':[{'type':'text','text':JSON['stringify']({'result':g})}],'structuredContent':{'result':g,'semantic':buildDataSemantic(g,{'operation_type':'monitor_events','data':b})}};}let subscriptionDepsOverride;export function setMonitorSubscriptionDeps(a){subscriptionDepsOverride=a;}function subscriptionDeps(){return subscriptionDepsOverride??{'store':monitorEventStore,'configStore':subscriptionStore,'resolveScope':(a,b)=>resolveScope(a,b),'loadScope':a=>loadScopeSnapshot(a),'backfill':(a,b,c,d)=>backfillAnnotations(a,monitorEventStore,b,c,d),'loop':monitorLoop,'logger':a=>console['error']('[monitor]\x20'+a)};}function captureTypesOf(a){const b=[...MONITOR_CAPTURE_TYPES];if(a['events']?.[PAYMENT_EVENT_TYPE]===!![])b['push'](PAYMENT_EVENT_TYPE);return b;}async function buildResolved(a,b,c,e){const f=e??await c['loadScope'](a),g=await c['store']['getCursors'](a);return{'scope_version':f?.['version']??0x0,'counts':{'accounts':f?.['accounts']['length']??0x0,'permissions':f?.['permissions']['length']??0x0,'managed':f?.['managed_objects']['length']??0x0,'services':f?.['services']['length']??0x0,'orders':f?.['orders']['length']??0x0,'order_children':f?.['order_children']['length']??0x0,'focus':f?.['focus']['length']??0x0},'capture_types':captureTypesOf(b),'last_poll_at':g['lastPollAt']??0x0,'loop':c['loop']['status'](a)};}async function resolveAfterConfigChange(a,b,c){let f,g='not_needed';try{const i=await c['resolveScope'](a,b);f=i['snapshot'];if(i['changed']){g='scheduled';const j=Number(b['loop']?.['backfill_days']??LOOP_DEFAULTS['backfill_days']);void c['backfill'](a,i['snapshot'],j,b)['catch'](k=>c['logger']('monitor_subscription:\x20backfill\x20failed:\x20'+String(k?.['message']??k)));}}catch(k){c['logger']('monitor_subscription:\x20immediate\x20scope\x20resolve\x20failed:\x20'+String(k?.['message']??k));}c['loop']['invalidateScope'](a);const h={...await buildResolved(a,b,c,f),'backfill':g};return{'resolved':h};}export async function handleMonitorSubscription(a){const b=strictParse(MonitorSubscriptionInputSchema,a,'monitor_subscription\x20input'),c=await resolveNetwork(b['network']),f=subscriptionDeps();let g;if(b['action']==='get'){const h=await f['configStore']['getConfig'](c);g={'action':'get','config':h,'resolved':await buildResolved(c,h,f)};}else{if(b['action']==='save'){const i=await f['configStore']['saveConfig'](c,b['config']??{}),{resolved:j}=await resolveAfterConfigChange(c,i,f);g={'action':'save','config':i,'resolved':j};}else{if(b['action']==='reset'){const k=await f['configStore']['resetConfig'](c),{resolved:l}=await resolveAfterConfigChange(c,k,f);g={'action':'reset','config':k,'resolved':l};}else{if(b['action']==='scope_preview'){let m=await f['loadScope'](c);if(!m)try{m=(await f['resolveScope'](c,await f['configStore']['getConfig'](c)))['snapshot'];}catch(s){f['logger']('monitor_subscription:\x20scope_preview\x20resolve\x20failed:\x20'+String(s?.['message']??s));}const n=b['limit']??0x32,o=b['offset']??0x0,p=t=>({'total':t['length'],'items':t['slice'](o,o+n)}),q={'accounts':p((m?.['accounts']??[])['map'](t=>({'address':t}))),'permissions':p((m?.['permissions']??[])['map'](t=>({'object':t}))),'managed_objects':p((m?.['managed_objects']??[])['map'](t=>({'object':t['object'],'type':t['type']}))),'services':p((m?.['services']??[])['map'](t=>({'object':t}))),'orders':p((m?.['orders']??[])['map'](t=>({'object':t['order'],'role':t['role']}))),'order_children':p((m?.['order_children']??[])['map'](t=>({'object':t['object'],'type':t['type']}))),'focus':p((m?.['focus']??[])['map'](t=>({'object':t['object'],'reason':t['reason'],'added_at':t['added_at'],'closure':t['closure'],...t['note']?{'note':t['note']}:{}})))},r=b['rule'];g={'action':'scope_preview','groups':r?{[r]:q[r]}:q};}else{const t=b['filter'];if(!t)throw new Error('monitor_subscription\x20action=\x27test_filter\x27\x20requires\x20`filter`');const u=b['sample']??0xc8;let v=0x0,w=0x0;const x=[];let y=0x0;const z=0xc8;while(v<u){const A=await f['store']['list'](c,{'offset':y,'limit':Math['min'](z,u-v)});if(A['events']['length']===0x0)break;for(const B of A['events']){v++;if(t['event']&&t['event']!==B['type'])continue;let C=![];try{C=evaluateFilter(t,B['event']);}catch{C=![];}C&&(w++,x['length']<0x5&&x['push']({'event_id':B['id'],'type':B['type'],'time':B['time']}));}y+=A['events']['length'];if(y>=A['total'])break;}g={'action':'test_filter','matched':w,'scanned':v,'samples':x};}}}}return{'content':[{'type':'text','text':JSON['stringify']({'result':g})}],'structuredContent':{'result':g,'semantic':buildDataSemantic(g,{'operation_type':'monitor_subscription','data':b})}};}
@@ -0,0 +1 @@
1
+ export declare function resolveNetwork(network?: string): Promise<string>;
@@ -0,0 +1 @@
1
+ import{Config}from'@wowok/wowok/w/local';export async function resolveNetwork(a){if(a){const b=await Config['Instance']()['network_get'](a);if(b)return b;}return await Config['Instance']()['network_get']();}