qlogicagent 2.10.22 → 2.10.24

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 (263) hide show
  1. package/README.md +29 -4
  2. package/dist/agent.js +11 -11
  3. package/dist/cli.js +701 -604
  4. package/dist/index.js +700 -603
  5. package/dist/permissions.js +1 -0
  6. package/dist/protocol.js +1 -1
  7. package/dist/types/agent/tool-access.d.ts +1 -30
  8. package/dist/types/agent/tunable-defaults.d.ts +1 -249
  9. package/dist/types/agent/types.d.ts +7 -0
  10. package/dist/types/cli/acp-extended-handlers.d.ts +41 -0
  11. package/dist/types/cli/acp-extended-host-adapter.d.ts +28 -0
  12. package/dist/types/cli/acp-extended-host-adapter.test.d.ts +1 -0
  13. package/dist/types/cli/acp-session-handlers.d.ts +39 -0
  14. package/dist/types/cli/acp-session-handlers.test.d.ts +1 -0
  15. package/dist/types/cli/agent-config-coordinator.d.ts +13 -0
  16. package/dist/types/cli/agent-config-runtime.d.ts +11 -0
  17. package/dist/types/cli/agent-runner-factory.d.ts +2 -0
  18. package/dist/types/cli/agent-runtime-bootstrap.d.ts +64 -0
  19. package/dist/types/cli/agent-status-notifier.d.ts +11 -0
  20. package/dist/types/cli/agent-status-notifier.test.d.ts +1 -0
  21. package/dist/types/cli/base-tool-bootstrap.d.ts +7 -0
  22. package/dist/types/cli/cli-acp-request-handler.d.ts +9 -0
  23. package/dist/types/cli/cli-acp-request-handler.test.d.ts +1 -0
  24. package/dist/types/cli/cli-agent-builder.d.ts +35 -0
  25. package/dist/types/cli/community-skill-installer.d.ts +12 -0
  26. package/dist/types/cli/community-skill-installer.test.d.ts +1 -0
  27. package/dist/types/cli/core-tool-coordinator.d.ts +30 -0
  28. package/dist/types/cli/core-tools/agent-tool-bootstrap.d.ts +10 -0
  29. package/dist/types/cli/core-tools/agent-tool-service.d.ts +18 -0
  30. package/dist/types/cli/core-tools/checkpoint-tool-bootstrap.d.ts +7 -0
  31. package/dist/types/cli/core-tools/checkpoint-tool-service.d.ts +7 -0
  32. package/dist/types/cli/core-tools/config-tool-bootstrap.d.ts +7 -0
  33. package/dist/types/cli/core-tools/config-tool-service.d.ts +7 -0
  34. package/dist/types/cli/core-tools/cron-tool-bootstrap.d.ts +7 -0
  35. package/dist/types/cli/core-tools/cron-tool-service.d.ts +22 -0
  36. package/dist/types/cli/core-tools/cron-tool-service.test.d.ts +1 -0
  37. package/dist/types/cli/core-tools/monitor-tool-bootstrap.d.ts +5 -0
  38. package/dist/types/cli/core-tools/monitor-tool-service.d.ts +6 -0
  39. package/dist/types/cli/core-tools/registry.d.ts +9 -0
  40. package/dist/types/cli/core-tools/team-tool-bootstrap.d.ts +7 -0
  41. package/dist/types/cli/core-tools/team-tool-service.d.ts +21 -0
  42. package/dist/types/cli/core-tools/utility-tool-bootstrap.d.ts +8 -0
  43. package/dist/types/cli/default-project-bootstrap.d.ts +8 -0
  44. package/dist/types/cli/dev-tool-bootstrap.d.ts +4 -0
  45. package/dist/types/cli/dev-tools/lsp-tool-service.d.ts +5 -0
  46. package/dist/types/cli/dev-tools/repl-lsp-tool-services.test.d.ts +1 -0
  47. package/dist/types/cli/dev-tools/repl-tool-service.d.ts +5 -0
  48. package/dist/types/cli/dream-host-adapter.d.ts +19 -0
  49. package/dist/types/cli/handlers/agents-handler.d.ts +28 -14
  50. package/dist/types/cli/handlers/community-handler.d.ts +25 -0
  51. package/dist/types/cli/handlers/community-handler.test.d.ts +1 -0
  52. package/dist/types/cli/handlers/config-handler.d.ts +15 -9
  53. package/dist/types/cli/handlers/config-handler.test.d.ts +1 -0
  54. package/dist/types/cli/handlers/control-handler.d.ts +23 -0
  55. package/dist/types/cli/handlers/dream-handler.d.ts +21 -1
  56. package/dist/types/cli/handlers/files-handler.d.ts +15 -9
  57. package/dist/types/cli/handlers/files-handler.instructions.test.d.ts +1 -0
  58. package/dist/types/cli/handlers/media-handler.d.ts +10 -4
  59. package/dist/types/cli/handlers/media-handler.test.d.ts +1 -0
  60. package/dist/types/cli/handlers/memory-handler.d.ts +39 -12
  61. package/dist/types/cli/handlers/pet-confirm-handler.d.ts +7 -0
  62. package/dist/types/cli/handlers/pet-handler.d.ts +29 -4
  63. package/dist/types/cli/handlers/pet-handler.test.d.ts +1 -0
  64. package/dist/types/cli/handlers/product-handler.d.ts +40 -14
  65. package/dist/types/cli/handlers/project-handler.d.ts +23 -14
  66. package/dist/types/cli/handlers/session-handler.d.ts +36 -17
  67. package/dist/types/cli/handlers/session-handler.resume.test.d.ts +1 -0
  68. package/dist/types/cli/handlers/settings-handler.d.ts +16 -12
  69. package/dist/types/cli/handlers/skills-handler.d.ts +19 -10
  70. package/dist/types/cli/handlers/skills-handler.profile.test.d.ts +1 -0
  71. package/dist/types/cli/handlers/solo-handler.d.ts +31 -9
  72. package/dist/types/cli/handlers/turn-handler.approval.test.d.ts +1 -0
  73. package/dist/types/cli/handlers/turn-handler.d.ts +17 -11
  74. package/dist/types/cli/idle-dream-coordinator.d.ts +46 -0
  75. package/dist/types/cli/idle-dream-coordinator.test.d.ts +1 -0
  76. package/dist/types/cli/mcp-plugin-bootstrap.d.ts +27 -0
  77. package/dist/types/cli/mcp-plugin-bootstrap.test.d.ts +1 -0
  78. package/dist/types/cli/mcp-tool-proxy.d.ts +7 -0
  79. package/dist/types/cli/media-file-api-service.d.ts +73 -0
  80. package/dist/types/cli/media-file-api-service.test.d.ts +1 -0
  81. package/dist/types/cli/media-file-tool-service.d.ts +13 -0
  82. package/dist/types/cli/memory-coordinator.d.ts +36 -0
  83. package/dist/types/cli/model-client-resolver.d.ts +22 -0
  84. package/dist/types/cli/multi-agent-handler-host.d.ts +27 -0
  85. package/dist/types/cli/multi-agent-handler-host.test.d.ts +1 -0
  86. package/dist/types/cli/multi-agent-state-coordinator.d.ts +11 -0
  87. package/dist/types/cli/permission-bootstrap.d.ts +33 -0
  88. package/dist/types/cli/permission-bootstrap.test.d.ts +1 -0
  89. package/dist/types/cli/permission-settings-store.d.ts +2 -0
  90. package/dist/types/cli/permission-settings-store.test.d.ts +1 -0
  91. package/dist/types/cli/pet-confirm-coordinator.d.ts +20 -0
  92. package/dist/types/cli/pet-confirm-coordinator.test.d.ts +1 -0
  93. package/dist/types/cli/pet-runtime.d.ts +34 -0
  94. package/dist/types/cli/pet-runtime.test.d.ts +1 -0
  95. package/dist/types/cli/project-context.d.ts +1 -0
  96. package/dist/types/cli/project-memory-store-factory.d.ts +2 -0
  97. package/dist/types/cli/project-template-seeder.d.ts +5 -0
  98. package/dist/types/cli/provider-core-facade.d.ts +27 -0
  99. package/dist/types/cli/rpc-registry.community.test.d.ts +1 -0
  100. package/dist/types/cli/rpc-registry.d.ts +8 -0
  101. package/dist/types/cli/runtime-hook-bootstrap.d.ts +34 -0
  102. package/dist/types/cli/runtime-watcher-bootstrap.d.ts +15 -0
  103. package/dist/types/cli/session-coordinator.d.ts +10 -0
  104. package/dist/types/cli/session-coordinator.test.d.ts +1 -0
  105. package/dist/types/cli/session-history-coordinator.d.ts +11 -0
  106. package/dist/types/cli/session-history-coordinator.test.d.ts +1 -0
  107. package/dist/types/cli/skill-meta-tool-bootstrap.d.ts +25 -0
  108. package/dist/types/cli/skill-meta-tool-bootstrap.test.d.ts +1 -0
  109. package/dist/types/cli/stdio-server.d.ts +17 -134
  110. package/dist/types/cli/tool-bootstrap.d.ts +1 -4
  111. package/dist/types/cli/tool-bootstrap.instructions.test.d.ts +1 -0
  112. package/dist/types/cli/tool-bootstrap.media-provider-alias.test.d.ts +1 -0
  113. package/dist/types/cli/tool-catalog.d.ts +2 -0
  114. package/dist/types/cli/tool-invoker-factory.d.ts +10 -0
  115. package/dist/types/cli/tool-result-processor.d.ts +14 -0
  116. package/dist/types/cli/transport.d.ts +2 -12
  117. package/dist/types/cli/turn-ask-user-setup.d.ts +9 -0
  118. package/dist/types/cli/turn-event-forwarder.d.ts +10 -0
  119. package/dist/types/cli/turn-lifecycle.d.ts +19 -0
  120. package/dist/types/cli/turn-lifecycle.test.d.ts +1 -0
  121. package/dist/types/cli/turn-media-setup.d.ts +16 -0
  122. package/dist/types/cli/turn-permission-sync.d.ts +7 -0
  123. package/dist/types/cli/turn-permission-sync.test.d.ts +1 -0
  124. package/dist/types/cli/turn-project-router.d.ts +22 -0
  125. package/dist/types/cli/turn-project-router.test.d.ts +1 -0
  126. package/dist/types/cli/turn-skill-autopersist.d.ts +47 -0
  127. package/dist/types/cli/turn-skill-autopersist.test.d.ts +1 -0
  128. package/dist/types/cli/turn-suggestion-generator.d.ts +15 -0
  129. package/dist/types/orchestration/agent-instance.d.ts +1 -1
  130. package/dist/types/orchestration/dag-scheduler.d.ts +135 -86
  131. package/dist/types/orchestration/index.d.ts +2 -2
  132. package/dist/types/orchestration/product-budget.d.ts +1 -1
  133. package/dist/types/orchestration/product-persistence.d.ts +3 -12
  134. package/dist/types/orchestration/product-planner.d.ts +1 -1
  135. package/dist/types/orchestration/skill-improvement.d.ts +1 -1
  136. package/dist/types/orchestration/solo-evaluator.d.ts +1 -1
  137. package/dist/types/orchestration/solo-persistence.d.ts +1 -1
  138. package/dist/types/orchestration/subagent/fork-subagent.d.ts +1 -1
  139. package/dist/types/orchestration/subagent/task-types.d.ts +1 -146
  140. package/dist/types/orchestration/tool-cascade.d.ts +2 -2
  141. package/dist/types/orchestration/workflow/budget-permission-gate.d.ts +85 -0
  142. package/dist/types/orchestration/workflow/builtin-executors.d.ts +12 -0
  143. package/dist/types/orchestration/workflow/cron-schedule.d.ts +37 -0
  144. package/dist/types/orchestration/workflow/data-item.d.ts +39 -0
  145. package/dist/types/orchestration/workflow/expression.d.ts +52 -0
  146. package/dist/types/orchestration/workflow/host-executors.d.ts +15 -0
  147. package/dist/types/orchestration/workflow/n8n-import.d.ts +35 -0
  148. package/dist/types/orchestration/workflow/node-registry.d.ts +19 -0
  149. package/dist/types/orchestration/workflow/node-schema.d.ts +119 -0
  150. package/dist/types/orchestration/workflow/qla-executor-host.d.ts +42 -0
  151. package/dist/types/orchestration/workflow/run-checkpoint-store.d.ts +53 -0
  152. package/dist/types/orchestration/workflow/trigger-validation.d.ts +22 -0
  153. package/dist/types/orchestration/workflow/workflow-controller.d.ts +143 -0
  154. package/dist/types/orchestration/workflow/workflow-patch.d.ts +101 -0
  155. package/dist/types/orchestration/workflow/workflow-render.d.ts +41 -0
  156. package/dist/types/orchestration/workflow/workflow-runtime.d.ts +127 -0
  157. package/dist/types/orchestration/workflow/workflow-scheduler.d.ts +83 -0
  158. package/dist/types/orchestration/workflow/workflow-store.d.ts +40 -0
  159. package/dist/types/orchestration/workflow/workflow-trigger.d.ts +14 -0
  160. package/dist/types/permissions.d.ts +2 -0
  161. package/dist/types/permissions.public-api.test.d.ts +1 -0
  162. package/dist/types/protocol/methods.d.ts +262 -11
  163. package/dist/types/{runtime/infra/acp-types.d.ts → protocol/wire/acp-agent-management.d.ts} +3 -3
  164. package/dist/types/protocol/wire/agent-methods.d.ts +15 -11
  165. package/dist/types/protocol/wire/agent-rpc.d.ts +11 -0
  166. package/dist/types/protocol/wire/chat-types.d.ts +9 -0
  167. package/dist/types/protocol/wire/gateway-rpc.d.ts +13 -0
  168. package/dist/types/protocol/wire/index.d.ts +2 -1
  169. package/dist/types/protocol/wire/notification-payloads.d.ts +18 -3
  170. package/dist/types/runtime/community/community-consent-client.d.ts +117 -0
  171. package/dist/types/runtime/community/community-consent-client.test.d.ts +1 -0
  172. package/dist/types/runtime/community/community-desensitization-red-team-cli.d.ts +7 -0
  173. package/dist/types/runtime/community/community-desensitization-red-team-cli.test.d.ts +1 -0
  174. package/dist/types/runtime/community/community-desensitization.d.ts +29 -0
  175. package/dist/types/runtime/community/community-desensitization.test.d.ts +1 -0
  176. package/dist/types/runtime/community/community-telemetry-recorder.d.ts +6 -0
  177. package/dist/types/runtime/config/tunable-defaults.d.ts +249 -0
  178. package/dist/types/runtime/execution/dream-agent.d.ts +4 -2
  179. package/dist/types/runtime/execution/dream-category-context.d.ts +1 -1
  180. package/dist/types/runtime/execution/forked-agent.d.ts +3 -1
  181. package/dist/types/runtime/execution/streaming-tool-executor.d.ts +4 -2
  182. package/dist/types/runtime/execution/tool-eligibility.d.ts +1 -1
  183. package/dist/types/runtime/hooks/context-compression.d.ts +2 -2
  184. package/dist/types/runtime/hooks/memory-hooks.d.ts +6 -6
  185. package/dist/types/runtime/infra/acp-detector.d.ts +2 -2
  186. package/dist/types/runtime/infra/acp-protocol-adapter.d.ts +1 -1
  187. package/dist/types/runtime/infra/acp-usage-tracker.d.ts +1 -1
  188. package/dist/types/runtime/infra/agent-config-store.d.ts +2 -2
  189. package/dist/types/runtime/infra/agent-paths.d.ts +18 -10
  190. package/dist/types/runtime/infra/agent-paths.test.d.ts +1 -0
  191. package/dist/types/runtime/infra/agent-process.d.ts +2 -2
  192. package/dist/types/runtime/infra/checkpoint-backend.d.ts +2 -2
  193. package/dist/types/runtime/infra/index.d.ts +1 -1
  194. package/dist/types/runtime/infra/llmrouter-catalog.d.ts +10 -0
  195. package/dist/types/runtime/infra/mcp-bridge.d.ts +1 -1
  196. package/dist/types/runtime/infra/model-registry.d.ts +2 -1
  197. package/dist/types/runtime/infra/profile-storage.test.d.ts +1 -0
  198. package/dist/types/runtime/infra/skill-injector.d.ts +3 -2
  199. package/dist/types/runtime/infra/skill-injector.test.d.ts +1 -0
  200. package/dist/types/runtime/infra/task-runtime.d.ts +1 -1
  201. package/dist/types/runtime/infra/worktree-backend.d.ts +2 -2
  202. package/dist/types/runtime/memory/categories.d.ts +5 -0
  203. package/dist/types/runtime/memory/find-relevant-memories.d.ts +70 -0
  204. package/dist/types/runtime/memory/implicit-extraction.d.ts +58 -0
  205. package/dist/types/runtime/memory/recall-category-filter.d.ts +54 -0
  206. package/dist/types/runtime/pet/index.d.ts +1 -1
  207. package/dist/types/runtime/pet/pet-growth-engine.d.ts +10 -9
  208. package/dist/types/runtime/pet/pet-growth-engine.test.d.ts +1 -0
  209. package/dist/types/runtime/pet/pet-soul-service.d.ts +1 -2
  210. package/dist/types/runtime/pet/pet-soul-service.test.d.ts +1 -0
  211. package/dist/types/runtime/ports/agent-execution-contracts.d.ts +182 -0
  212. package/dist/types/runtime/ports/checkpoint-contracts.d.ts +19 -0
  213. package/dist/types/runtime/ports/index.d.ts +13 -0
  214. package/dist/types/runtime/ports/memory-provider.d.ts +146 -0
  215. package/dist/types/runtime/ports/memory-recall-source.d.ts +3 -0
  216. package/dist/types/runtime/ports/memory-writer.d.ts +21 -0
  217. package/dist/types/runtime/ports/path-service.d.ts +5 -0
  218. package/dist/types/runtime/ports/permission-contracts.d.ts +107 -0
  219. package/dist/types/runtime/ports/project-memory-store.d.ts +44 -0
  220. package/dist/types/runtime/ports/tool-call-contracts.d.ts +16 -0
  221. package/dist/types/runtime/ports/tool-contracts.d.ts +23 -0
  222. package/dist/types/runtime/ports/web-search-contracts.d.ts +17 -0
  223. package/dist/types/runtime/ports/worktree-contracts.d.ts +22 -0
  224. package/dist/types/runtime/prompt/environment-context.test.d.ts +1 -0
  225. package/dist/types/runtime/prompt/fresh-workspace-evidence.d.ts +19 -0
  226. package/dist/types/runtime/prompt/fresh-workspace-evidence.test.d.ts +1 -0
  227. package/dist/types/runtime/prompt/instruction-loader.d.ts +9 -3
  228. package/dist/types/runtime/prompt/instruction-loader.test.d.ts +1 -0
  229. package/dist/types/runtime/session/session-persistence.test.d.ts +1 -0
  230. package/dist/types/runtime/tasks/task-types.d.ts +146 -0
  231. package/dist/types/skills/index.d.ts +2 -2
  232. package/dist/types/skills/mcp/mcp-http-client.d.ts +2 -0
  233. package/dist/types/skills/mcp/mcp-manager.d.ts +7 -4
  234. package/dist/types/skills/mcp/mcp-stdio-client.d.ts +2 -0
  235. package/dist/types/skills/mcp/mcp-tool-metadata.d.ts +18 -0
  236. package/dist/types/skills/memory/categories.d.ts +1 -5
  237. package/dist/types/skills/memory/find-relevant-memories.d.ts +1 -70
  238. package/dist/types/skills/memory/implicit-extraction.d.ts +1 -58
  239. package/dist/types/skills/memory/local-memory-provider.d.ts +6 -10
  240. package/dist/types/skills/memory/local-store.d.ts +4 -4
  241. package/dist/types/skills/memory/memory-consolidation.d.ts +9 -1
  242. package/dist/types/skills/memory/memory-provider-factory.d.ts +2 -0
  243. package/dist/types/skills/memory/memory-tool.d.ts +4 -6
  244. package/dist/types/skills/memory/recall-category-filter.d.ts +1 -54
  245. package/dist/types/skills/permissions/community-sandbox-policy.d.ts +3 -0
  246. package/dist/types/skills/permissions/community-sandbox-red-team-cli.d.ts +7 -0
  247. package/dist/types/skills/permissions/community-sandbox-red-team.d.ts +30 -0
  248. package/dist/types/skills/permissions/hook-runner.d.ts +15 -2
  249. package/dist/types/skills/permissions/settings-watcher.d.ts +2 -0
  250. package/dist/types/skills/permissions/types.d.ts +2 -113
  251. package/dist/types/skills/portable-tool.d.ts +22 -0
  252. package/dist/types/skills/skill-system/skill-lifecycle.d.ts +5 -0
  253. package/dist/types/skills/skill-system/skill-source.d.ts +2 -148
  254. package/dist/types/skills/tool-access.d.ts +30 -0
  255. package/dist/types/skills/tools/skill-tool.d.ts +2 -10
  256. package/dist/types/skills/tools/web-search-tool.d.ts +3 -20
  257. package/dist/types/skills/tools.d.ts +1 -1
  258. package/dist/types/transport/acp-server.d.ts +1 -1
  259. package/dist/types/transport/index.d.ts +1 -0
  260. package/dist/types/transport/io-transport.d.ts +19 -0
  261. package/package.json +93 -80
  262. package/dist/types/llm/index.d.ts +0 -1
  263. /package/dist/types/{orchestration/context/context-compression.d.ts → runtime/context/context-compression-strategies.d.ts} +0 -0
@@ -0,0 +1,101 @@
1
+ /**
2
+ * WorkflowPatch — the single mutation channel for workflow editing (plan D17/D19,
3
+ * spec workflow-conversational-editing-spec.md §C).
4
+ *
5
+ * One change protocol for BOTH agent edits and canvas hand-edits: every edit is a list of
6
+ * `WorkflowPatch` ops applied transactionally to a workflow's graph. This module is the
7
+ * deterministic ENGINE half (no gateway, no UI, no LLM):
8
+ * - applies the 8 ops to a WorkflowDef (+ workflow meta/trigger),
9
+ * - enforces scoped-edit boundaries (框选批注: ops may only touch the selection subgraph,
10
+ * D19) at the PROTOCOL level — not a prompt soft-constraint,
11
+ * - validates the resulting graph through DagScheduler v2's invariants (acyclic minus
12
+ * loopBack, edge integrity, loop maxIterations) — the spec's "patch 落库前过 validateDag".
13
+ *
14
+ * Transactional + fail-loud (§1.5): a patch is all-or-nothing. The candidate is built on a deep
15
+ * clone; if any op is illegal, references a missing node/edge, breaks scope, or yields an invalid
16
+ * graph, the WHOLE patch is rejected via `PatchError` (carrying `errors` for agent self-correction)
17
+ * and the input is never mutated. No partial application, no silent drop.
18
+ */
19
+ import type { WorkflowDef, WorkflowNodeDef, DataEdge } from "./node-schema.js";
20
+ import type { TriggerDef } from "./workflow-trigger.js";
21
+ export type { TriggerDef } from "./workflow-trigger.js";
22
+ /** A workflow trigger (spec §B / plan D7). Registered by the gateway trigger layer. */
23
+ /** Workflow-global fields a patch can set (kept separate from the node graph). */
24
+ export interface WorkflowMeta {
25
+ name?: string;
26
+ active?: boolean;
27
+ trigger?: TriggerDef | null;
28
+ }
29
+ /** The full mutable target of a patch: the node graph plus workflow-global meta. */
30
+ export interface PatchTarget {
31
+ def: WorkflowDef;
32
+ meta: WorkflowMeta;
33
+ }
34
+ export type WorkflowPatch = {
35
+ op: "add_node";
36
+ node: WorkflowNodeDef;
37
+ } | {
38
+ op: "remove_node";
39
+ nodeId: string;
40
+ } | {
41
+ op: "update_params";
42
+ nodeId: string;
43
+ params: Record<string, unknown>;
44
+ } | {
45
+ op: "rename_node";
46
+ nodeId: string;
47
+ name: string;
48
+ } | {
49
+ op: "add_edge";
50
+ edge: DataEdge;
51
+ } | {
52
+ op: "remove_edge";
53
+ edge: {
54
+ from: string;
55
+ to: string;
56
+ fromPort?: string;
57
+ };
58
+ } | {
59
+ op: "set_trigger";
60
+ trigger: TriggerDef | null;
61
+ } | {
62
+ op: "set_meta";
63
+ meta: {
64
+ name?: string;
65
+ active?: boolean;
66
+ };
67
+ };
68
+ /** A patch + concurrency/scope envelope (spec §C). `scope` present ⇒ scoped (框选) edit. */
69
+ export interface PatchEnvelope {
70
+ patch: WorkflowPatch[];
71
+ /** Optimistic-concurrency base revision (LWW handled by the store layer). */
72
+ baseRev?: number;
73
+ /** Selected node ids for a scoped edit; given ⇒ ops may only touch the selection subgraph. */
74
+ scope?: string[];
75
+ }
76
+ export interface ApplyResult {
77
+ target: PatchTarget;
78
+ applied: WorkflowPatch[];
79
+ }
80
+ /** Thrown when a patch is rejected. `errors` is the ordered list of reasons (for self-correction). */
81
+ export declare class PatchError extends Error {
82
+ readonly errors: string[];
83
+ constructor(errors: string[]);
84
+ }
85
+ /**
86
+ * Apply a patch transactionally. Returns a NEW PatchTarget (input untouched) or throws PatchError.
87
+ * Scope enforcement (when `scope` is set, spec §C):
88
+ * - update_params / rename_node / remove_node: the node MUST be in scope.
89
+ * - add_node: allowed; the new node joins the in-scope set for subsequent ops in this patch.
90
+ * - add_edge / remove_edge: at least ONE endpoint must be in scope (selection-boundary edges).
91
+ * - set_trigger / set_meta: workflow-global ⇒ rejected under a scoped edit.
92
+ */
93
+ export declare function applyPatch(target: PatchTarget, env: PatchEnvelope): ApplyResult;
94
+ /**
95
+ * Validate a standalone WorkflowDef against DagScheduler v2's invariants (acyclic minus loopBack,
96
+ * edge integrity, duplicate ids, loop maxIterations + hard cap). Returns a list of human-readable
97
+ * errors; empty ⇒ valid. This is the SAME graph gate `applyPatch` runs, exported so every
98
+ * persistence path (controller create/update) enforces identical invariants — single-track, no
99
+ * write path may bypass validation (D17 "一个 store").
100
+ */
101
+ export declare function validateWorkflowDef(def: WorkflowDef): string[];
@@ -0,0 +1,41 @@
1
+ /**
2
+ * Compact workflow renderer — the "workflow-as-context" feeder (plan D17,
3
+ * spec workflow-conversational-editing-spec.md §B).
4
+ *
5
+ * Every page-chat user turn injects the LATEST workflow as compact, deterministic text (NOT raw
6
+ * JSON: cheaper tokens, never stale, stable node ids the agent references back in a WorkflowPatch).
7
+ * This module is the deterministic ENGINE half of that loop — the agent reads this rendering and
8
+ * emits a `WorkflowPatch` (workflow-patch.ts) against the shown `rev`. Pure function: no gateway,
9
+ * no LLM, no I/O.
10
+ *
11
+ * Determinism (§1.5): node order follows the def's node array (stable, persisted order); param
12
+ * keys are sorted; expressions (`{{ }}`) render verbatim so the agent can copy them into bindings.
13
+ * Large graphs truncate with an explicit hint to call `workflow.get` for the full definition.
14
+ */
15
+ import type { WorkflowDef } from "./node-schema.js";
16
+ import type { TriggerDef } from "./workflow-patch.js";
17
+ /** The minimal shape needed to render (WorkflowRecord satisfies it). */
18
+ export interface RenderableWorkflow {
19
+ name: string;
20
+ rev: number;
21
+ active: boolean;
22
+ trigger?: TriggerDef | null;
23
+ def: WorkflowDef;
24
+ }
25
+ export interface RenderOptions {
26
+ /** Max nodes to list before truncating (default 50). */
27
+ maxNodes?: number;
28
+ /** Max rendered length of a single param value before eliding (default 60). */
29
+ maxValueLen?: number;
30
+ }
31
+ /**
32
+ * Render a workflow as compact agent-context text. Shape (spec §B):
33
+ *
34
+ * Workflow "晨报" (rev 7, trigger: schedule "0 9 * * *", active)
35
+ * nodes:
36
+ * n1 [agent] prompt="抓取今日新闻要点" out: default
37
+ * n3 [if] cond={{ $json.count > 0 }} out: true,false
38
+ * edges:
39
+ * n1.default→n2.default ; n3.true→n4.default
40
+ */
41
+ export declare function renderWorkflow(wf: RenderableWorkflow, opts?: RenderOptions): string;
@@ -0,0 +1,127 @@
1
+ /**
2
+ * WorkflowRuntime — the automation data-routing driver (M2; plan §M2, spec §A1/§A5).
3
+ *
4
+ * Responsibilities (control/data separation, spec §A1):
5
+ * - DagScheduler v2 owns CONTROL (ready/skip/loop/ports). The runtime owns DATA:
6
+ * for each ready node it collects upstream outputs along data edges (fromPort→toPort),
7
+ * resolves param expressions, invokes the registered NodeExecutor, stores outputs, and
8
+ * reports completion + firedPorts back to the scheduler.
9
+ * - run-from-node + output cache (spec §A5): cache key = hash(kind + resolved params +
10
+ * input signature + runIndex). A clean node hits cache (executor skipped); a changed node
11
+ * and its dirty downstream recompute. This is content-addressed, so successive run() calls
12
+ * after a param change recompute only the dirty subgraph.
13
+ * - loop control is runtime-owned (DagScheduler.decideLoop), not a user executor.
14
+ * - every node passes an injectable budget/permission gate before executing (plan D15).
15
+ *
16
+ * fail-loud: unknown kinds, gate rejections, and executor errors all throw and halt the run.
17
+ */
18
+ import { DagScheduler } from "../dag-scheduler.js";
19
+ import { type PortMap } from "./data-item.js";
20
+ import { NodeRegistry } from "./node-registry.js";
21
+ import type { RunCheckpoint } from "./run-checkpoint-store.js";
22
+ import type { WorkflowDef, ExecutorHost } from "./node-schema.js";
23
+ /** Gate invoked before each node executes (budget / permission). Throw to halt the run. */
24
+ export interface ExecutionGate {
25
+ check(nodeId: string, kind: string): void;
26
+ /**
27
+ * Optionally raise the gate's remaining allowance so a budget-paused run can resume (D15
28
+ * "抬预算后 resume"). Gates without a budget may omit this. Implementations are fail-loud on
29
+ * non-positive deltas.
30
+ */
31
+ extend?(delta: {
32
+ executions?: number;
33
+ durationMs?: number;
34
+ }): void;
35
+ }
36
+ /**
37
+ * Thrown by a gate (or `pause()`) to suspend the run gracefully. Unlike a plain error this is
38
+ * not a failure: completed work stays cached, and a later `run()` on the same instance resumes
39
+ * (cached nodes hit, only the not-yet-run remainder executes).
40
+ */
41
+ export declare class WorkflowPauseSignal extends Error {
42
+ readonly atNodeId?: string | undefined;
43
+ constructor(atNodeId?: string | undefined);
44
+ }
45
+ export interface RunResult {
46
+ status: "completed" | "failed" | "paused";
47
+ /** nodeId → its output PortMap. */
48
+ outputs: Record<string, PortMap>;
49
+ /** nodeIds whose executor actually ran in this run (cache misses). */
50
+ executed: Set<string>;
51
+ progress: ReturnType<DagScheduler["getProgress"]>;
52
+ /** Set when status === "paused": the node the run suspended at. */
53
+ pausedAt?: string;
54
+ }
55
+ export interface WorkflowRuntimeOptions {
56
+ registry?: NodeRegistry;
57
+ gate?: ExecutionGate;
58
+ now?: () => Date;
59
+ trigger?: Record<string, unknown>;
60
+ log?: {
61
+ info(m: string): void;
62
+ warn(m: string): void;
63
+ };
64
+ /** Host capabilities for host-backed kinds (agent/tool/http/mcp/channel), D13. */
65
+ host?: ExecutorHost;
66
+ /** Cancellation propagated to host calls. */
67
+ signal?: AbortSignal;
68
+ /** Durable run checkpoint for crash-restart recovery (plan §M3). */
69
+ checkpoint?: RunCheckpoint;
70
+ }
71
+ export declare class WorkflowRuntime {
72
+ private def;
73
+ private readonly registry;
74
+ private readonly gate?;
75
+ private readonly now;
76
+ private readonly trigger?;
77
+ private readonly log?;
78
+ private readonly host?;
79
+ private readonly signal?;
80
+ private readonly checkpoint?;
81
+ private dag;
82
+ private readonly nodeDefs;
83
+ private readonly nodeOutputs;
84
+ /** Content-addressed output cache; persists across run() calls for run-from-node. */
85
+ private readonly cache;
86
+ /** loopBack source nodeId → loop controller nodeId. */
87
+ private readonly loopBackOf;
88
+ /** Cooperative pause request; honored before the next node executes. */
89
+ private pauseRequested;
90
+ /** True once the durable checkpoint has been loaded into `cache` (load once per instance). */
91
+ private checkpointLoaded;
92
+ constructor(def: WorkflowDef, opts?: WorkflowRuntimeOptions);
93
+ /** Patch a node's params (for run-from-node param changes). Invalidates nothing directly —
94
+ * the content-addressed cache recomputes only what changed. */
95
+ setNodeParams(nodeId: string, params: Record<string, unknown>): void;
96
+ /** Request a cooperative pause: the in-flight run suspends before the next node executes. */
97
+ pause(): void;
98
+ /**
99
+ * Raise the budget gate's remaining allowance so a budget-paused run can resume (D15
100
+ * "抬预算后 resume"). fail-loud if this runtime was built without an extensible budget gate.
101
+ */
102
+ extendBudget(delta: {
103
+ executions?: number;
104
+ durationMs?: number;
105
+ }): void;
106
+ /** Execute the workflow to completion (or until the gate halts / a branch fails / a pause). */
107
+ run(): Promise<RunResult>;
108
+ /**
109
+ * Seed the content-addressed cache from a durable checkpoint (once per instance). After a
110
+ * crash-restart a fresh runtime replays the DAG; nodes that completed before the crash hit
111
+ * these entries and their executors are not re-invoked (no duplicate side effects).
112
+ */
113
+ private loadCheckpoint;
114
+ /** Persist the full content-addressed cache so a crash mid-run can resume from here. */
115
+ private persistCheckpoint;
116
+ private executeNode;
117
+ /** Loop entry: fire the "loop" port once to kick the first iteration. */
118
+ private enterLoop;
119
+ private decideLoopBack;
120
+ /** Loop again? No condition → loop until the scheduler's maxIterations cap. */
121
+ private evalLoopCondition;
122
+ /** Collect inputs for a node from completed upstream outputs along forward data edges. */
123
+ private collectInputs;
124
+ private buildExprContext;
125
+ private cacheKey;
126
+ private buildDag;
127
+ }
@@ -0,0 +1,83 @@
1
+ /**
2
+ * In-process workflow trigger scheduler (plan M3 trigger layer).
3
+ *
4
+ * Architecture note: scheduling lives INSIDE qlogicagent, not the gateway. This mirrors the
5
+ * established precedent — the idle "dream" timer was deliberately moved out of the openclaw gateway
6
+ * into qlogicagent so the Agent owns its own timed lifecycle ("Agent 是唯一状态拥有者"). The gateway
7
+ * remains a pure relay: it terminates external ingress (webhook HTTP, inbound IM) and forwards those
8
+ * events here via `onWebhook` / `onImMessage`; the cron clock and the run decision are the Agent's.
9
+ *
10
+ * The scheduler is the consumer of WorkflowController: on `start()` it loads every active workflow
11
+ * (`listActive`, spec §B4 restart re-registration) and arms a timer per `schedule` trigger; on fire
12
+ * it calls `controller.run(id, { type: "schedule" })`. Webhook / IM / manual triggers are
13
+ * caller-driven (the gateway relay or the agent invokes the matching method). Concurrency,
14
+ * budgeting, and permission gating all live in `controller.run` — the scheduler only decides WHEN.
15
+ *
16
+ * Determinism: the clock (now + timers) is injected, so tests pin time exactly and far-future cron
17
+ * delays are handled by chunked re-arming (Node's setTimeout caps at ~24.8 days).
18
+ */
19
+ import type { WorkflowController, RunOutcome } from "./workflow-controller.js";
20
+ export type TimerHandle = unknown;
21
+ /** Injectable clock + timer surface so the scheduler is fully deterministic under test. */
22
+ export interface SchedulerClock {
23
+ now(): number;
24
+ setTimer(fn: () => void, delayMs: number): TimerHandle;
25
+ clearTimer(handle: TimerHandle): void;
26
+ }
27
+ /** Default clock backed by the real system time and Node timers. */
28
+ export declare const systemClock: SchedulerClock;
29
+ export interface SchedulerDeps {
30
+ controller: WorkflowController;
31
+ clock?: SchedulerClock;
32
+ /**
33
+ * Surfaces an error from a timer-driven (cron) run, which has no caller to throw back to.
34
+ * Required so a failed unattended run is never silently swallowed (§1.5 fail-loud). Caller-driven
35
+ * triggers (webhook/IM/manual) propagate their errors to the caller instead.
36
+ */
37
+ onError: (err: unknown, workflowId: string) => void;
38
+ }
39
+ export declare class WorkflowScheduler {
40
+ private readonly controller;
41
+ private readonly clock;
42
+ private readonly onError;
43
+ /** Every registered workflow's trigger, keyed by id (the single source for lookups). */
44
+ private readonly triggers;
45
+ /** Active cron arms keyed by workflow id. */
46
+ private readonly cronArms;
47
+ private started;
48
+ constructor(deps: SchedulerDeps);
49
+ /** Load every active workflow and arm its trigger (spec §B4 restart re-registration). */
50
+ start(): Promise<void>;
51
+ /** Stop all timers and forget every registration. Idempotent. */
52
+ stop(): void;
53
+ /**
54
+ * Re-read a workflow and (re-)arm its trigger after a create/patch/setActive change. If the
55
+ * workflow no longer exists or is inactive it is unregistered. Active workflows are armed by
56
+ * their current trigger (manual ⇒ lookup-only, no timer).
57
+ */
58
+ refresh(id: string): Promise<void>;
59
+ /** Drop a workflow's registration and cancel any pending cron timer. */
60
+ unregister(id: string): void;
61
+ /** Workflow ids currently registered (for inspection/tests). */
62
+ registeredIds(): string[];
63
+ /** The epoch ms a scheduled workflow will next fire, or undefined if it has no cron arm. */
64
+ nextFireAt(id: string): number | undefined;
65
+ /**
66
+ * Deliver an external webhook hit. Runs every active workflow whose webhook trigger path equals
67
+ * `path`. Returns the outcomes (empty ⇒ no workflow matched, which the gateway maps to 404).
68
+ * Errors propagate to the caller (the HTTP handler), which is the fail-loud surface here.
69
+ */
70
+ onWebhook(path: string, payload?: Record<string, unknown>): Promise<RunOutcome[]>;
71
+ /**
72
+ * Deliver an inbound IM message. Runs every active workflow whose im-message trigger is on
73
+ * `channel` and whose optional `match` regex tests `text`. The message text + channel are merged
74
+ * into the run payload so downstream nodes can reference `$trigger`.
75
+ */
76
+ onImMessage(channel: string, text: string, payload?: Record<string, unknown>): Promise<RunOutcome[]>;
77
+ /** Manually trigger a single workflow (the agent's `workflow.run`). Errors propagate to caller. */
78
+ triggerManual(id: string, payload?: Record<string, unknown>): Promise<RunOutcome>;
79
+ private matchingIds;
80
+ private registerTrigger;
81
+ private armCron;
82
+ private fireCron;
83
+ }
@@ -0,0 +1,40 @@
1
+ /**
2
+ * Workflow Store — persist workflow definitions + lifecycle state to disk (spec §B4).
3
+ *
4
+ * Stored at `<project>/.qlogicagent/workflows/<workflowId>/workflow.json`. Listing enumerates
5
+ * subdirectories (mirrors product-persistence.ts). The store is the single source of truth for a
6
+ * workflow's definition, its active flag, and its concurrency policy; the gateway re-registers
7
+ * triggers for every active workflow on restart (spec §B4).
8
+ *
9
+ * fail-loud: missing id on save throws; load returns undefined only for a genuinely absent record.
10
+ */
11
+ import type { WorkflowDef } from "./node-schema.js";
12
+ import type { TriggerDef } from "./workflow-patch.js";
13
+ /** What to do when a workflow is triggered while a previous run is still in-flight (spec §B5). */
14
+ export type ConcurrencyPolicy = "queue" | "skip" | "parallel";
15
+ export interface WorkflowRecord {
16
+ id: string;
17
+ name: string;
18
+ def: WorkflowDef;
19
+ /** Active workflows have their triggers registered by the gateway (spec §B4). */
20
+ active: boolean;
21
+ concurrency: ConcurrencyPolicy;
22
+ /** The workflow's trigger (set via a WorkflowPatch set_trigger op; spec §C/D7). */
23
+ trigger?: TriggerDef | null;
24
+ /** Monotonic revision for optimistic concurrency (LWW); bumped on every patch (spec §C). */
25
+ rev: number;
26
+ createdAt: string;
27
+ updatedAt: string;
28
+ }
29
+ export declare class WorkflowStore {
30
+ private readonly cwd;
31
+ constructor(cwd: string);
32
+ save(record: WorkflowRecord): Promise<void>;
33
+ load(id: string): Promise<WorkflowRecord | undefined>;
34
+ /** Load a record or throw (fail-loud lookup for callers that require existence). */
35
+ require(id: string): Promise<WorkflowRecord>;
36
+ list(): Promise<WorkflowRecord[]>;
37
+ /** Active workflows the gateway must re-register triggers for after a restart (spec §B4). */
38
+ listActive(): Promise<WorkflowRecord[]>;
39
+ delete(id: string): Promise<void>;
40
+ }
@@ -0,0 +1,14 @@
1
+ /** Workflow trigger definitions shared by patching, validation, storage, and render helpers. */
2
+ export type TriggerDef = {
3
+ type: "manual";
4
+ } | {
5
+ type: "schedule";
6
+ cron: string;
7
+ } | {
8
+ type: "im-message";
9
+ channel: string;
10
+ match?: string;
11
+ } | {
12
+ type: "webhook";
13
+ path: string;
14
+ };
@@ -0,0 +1,2 @@
1
+ export { PERMISSION_MODES, } from "./runtime/ports/permission-contracts.js";
2
+ export type { ApprovalRequest, ApprovalResponse, PermissionAllowResult, PermissionApprovalResolver, PermissionAskResult, PermissionBehavior, PermissionConfig, PermissionDecisionReason, PermissionDenyResult, PermissionMetadataResolver, PermissionMode, PermissionResult, PermissionRuleEnginePort, PermissionRuleEntry, PermissionUpdate, ToolPermissionCheckInput, } from "./runtime/ports/permission-contracts.js";
@@ -0,0 +1 @@
1
+ export {};