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,37 @@
1
+ /**
2
+ * Deterministic cron schedule computation (plan M3 trigger layer).
3
+ *
4
+ * `validateCron` (trigger-validation.ts) guarantees a stored schedule is structurally valid; this
5
+ * module turns a validated cron string into a concrete "next fire time" so the in-process
6
+ * WorkflowScheduler can arm a timer. Pure, side-effect-free, and UTC-based for determinism — the
7
+ * scheduler injects its own clock, and tests pin time exactly. (A future local-timezone offset is a
8
+ * caller concern; the engine itself is UTC so the same input always yields the same output.)
9
+ *
10
+ * Grammar matches validateCron exactly: 5-field (min hour dom month dow) or 6-field (+ leading
11
+ * seconds); each field is a comma-list of star / star-step / value / range / stepped-range, with
12
+ * 3-letter month and day-of-week names, and dow accepting both 0 and 7 for Sunday.
13
+ */
14
+ export interface ParsedCron {
15
+ hasSeconds: boolean;
16
+ seconds: Set<number>;
17
+ minutes: Set<number>;
18
+ hours: Set<number>;
19
+ /** days-of-month, 1-31 */
20
+ doms: Set<number>;
21
+ /** months, 1-12 */
22
+ months: Set<number>;
23
+ /** days-of-week, 0-6 (Sunday=0; 7 is normalized to 0) */
24
+ dows: Set<number>;
25
+ /** true ⇔ the day-of-month field is restricted (not "*") */
26
+ domRestricted: boolean;
27
+ /** true ⇔ the day-of-week field is restricted (not "*") */
28
+ dowRestricted: boolean;
29
+ }
30
+ /** Parse a validated cron string into expanded numeric sets. Throws on malformed input (fail-loud). */
31
+ export declare function parseCron(cron: string): ParsedCron;
32
+ /**
33
+ * The next instant strictly after `afterMs` (UTC epoch ms) that matches `cron`. Throws if no match
34
+ * exists within a ~5-year horizon (e.g. an impossible date like "0 0 30 2 *"). Deterministic: the
35
+ * same (cron, afterMs) always returns the same value.
36
+ */
37
+ export declare function nextCronTime(cron: string, afterMs: number): number;
@@ -0,0 +1,39 @@
1
+ /**
2
+ * Workflow data envelope (spec: workflow-dataflow-and-triggers-spec.md §A2).
3
+ *
4
+ * Control/data separation: DagScheduler manages control (ready/skip/loop/ports) and
5
+ * never touches these values. The runtime data-routing layer carries DataItem[] along
6
+ * data edges; NodeExecutors consume/produce them.
7
+ *
8
+ * Media travels by-ref (BinaryRef → content-addressed blob store), keeping the envelope
9
+ * small and hash-cacheable.
10
+ */
11
+ /** A content-addressed reference to a large binary (image/video/audio), never inlined into json. */
12
+ export interface BinaryRef {
13
+ /** Pointer into the engine-managed blob store; content-addressed hash. */
14
+ ref: string;
15
+ mimeType: string;
16
+ size: number;
17
+ fileName?: string;
18
+ meta?: Record<string, unknown>;
19
+ }
20
+ /** A single unit of data flowing through a port. Most nodes emit one item per port. */
21
+ export interface DataItem {
22
+ /** Structured data — what expressions reference. */
23
+ json: Record<string, unknown>;
24
+ /** Large binaries by reference; kept out of json. */
25
+ binary?: Record<string, BinaryRef>;
26
+ }
27
+ /** Per-port payload: every port carries an array of items (supports fan-out / batching). */
28
+ export type PortMap = Record<string, DataItem[]>;
29
+ /** Convenience: wrap a plain object into a single-item DataItem. */
30
+ export declare function item(json: Record<string, unknown>, binary?: Record<string, BinaryRef>): DataItem;
31
+ /** Convenience: a single-item port map on the given port (default "default"). */
32
+ export declare function singlePort(json: Record<string, unknown>, port?: string): PortMap;
33
+ /**
34
+ * Stable content signature of a port map, for the run-from-node cache key (§A5).
35
+ * Binary participates via its content-addressed ref (not its bytes).
36
+ */
37
+ export declare function signaturePortMap(ports: PortMap): string;
38
+ /** Deterministic JSON stringify with sorted object keys (arrays keep order). */
39
+ export declare function stableStringify(value: unknown): string;
@@ -0,0 +1,52 @@
1
+ /**
2
+ * Restricted workflow expression evaluator (spec: workflow-dataflow-and-triggers-spec.md §A3–A4,
3
+ * plan D6). Used to bind node params to upstream data.
4
+ *
5
+ * HARD SECURITY LINE: NO arbitrary JS eval. This is a tiny recursive-descent interpreter over a
6
+ * fixed grammar — property/index path access + a whitelist of pure functions only. Unattended
7
+ * triggers make eval an injection surface, so arbitrary script is explicitly out of v1.
8
+ *
9
+ * Supported:
10
+ * - context roots: $input · $json · $node("name") · $now · $vars · $trigger
11
+ * - accessors: `.prop` and `[index]` / `["key"]`
12
+ * - literals: string ('..' / ".."), number, true/false/null
13
+ * - whitelist functions: len, upper, lower, default, jsonpath, date
14
+ *
15
+ * fail-loud: unknown roots/functions, reads through null/undefined, and prototype-escape keys
16
+ * all throw. Absent *leaf* keys evaluate to undefined (so `default(x, fb)` works).
17
+ */
18
+ import type { PortMap } from "./data-item.js";
19
+ export interface ExpressionContext {
20
+ /** $input — this node's input ports. */
21
+ input?: PortMap;
22
+ /** $json — shorthand for the current item's json (typically input.default[0].json). */
23
+ json?: Record<string, unknown>;
24
+ /** $node("X") — completed upstream node outputs, keyed by node id/name. */
25
+ nodes?: Record<string, {
26
+ output: PortMap;
27
+ }>;
28
+ /** $now — injectable clock for determinism; defaults to real time. */
29
+ now?: () => Date;
30
+ /** $vars — workflow-level variables. */
31
+ vars?: Record<string, unknown>;
32
+ /** $trigger — trigger payload. */
33
+ trigger?: Record<string, unknown>;
34
+ }
35
+ /**
36
+ * Evaluate a single expression body (the text inside `{{ }}`, braces stripped).
37
+ * Returns the raw value (object/array/number/string/boolean/null/undefined).
38
+ */
39
+ export declare function evaluateExpression(body: string, ctx: ExpressionContext): unknown;
40
+ /**
41
+ * Resolve a binding template:
42
+ * - exactly `{{ expr }}` (whole string) → returns the raw evaluated value (keeps type)
43
+ * - text with embedded `{{ }}` → string interpolation (each sub-expression stringified;
44
+ * a sub-expression resolving to null/undefined throws — fail-loud)
45
+ * - no `{{ }}` → returned unchanged
46
+ */
47
+ export declare function resolveBinding(template: string, ctx: ExpressionContext): unknown;
48
+ /**
49
+ * Recursively resolve every string value in a params object against the context.
50
+ * Non-string leaves are returned untouched. Arrays and nested objects are walked.
51
+ */
52
+ export declare function resolveParams(params: Record<string, unknown>, ctx: ExpressionContext): Record<string, unknown>;
@@ -0,0 +1,15 @@
1
+ /**
2
+ * Host-backed NodeExecutors (M3 bridge contract; plan D12/D13, spec §B).
3
+ *
4
+ * The engine is a pure executor: kinds that need real-world capabilities (agent / tool / http /
5
+ * mcp / channel) are fulfilled by an injected `ExecutorHost`. In production the openclaw gateway
6
+ * (or the qlogicagent CLI host) provides a real host; the engine never imports those subsystems.
7
+ *
8
+ * These executors are REAL (not mocks): they read the node's resolved params + inputs and delegate
9
+ * to the host. fail-loud — invoking a host-backed kind with no host throws (no silent fallback).
10
+ */
11
+ import type { NodeExecutor } from "./node-schema.js";
12
+ /** The host-backed kinds. Register these into a NodeRegistry to enable agent/tool/http/mcp/channel. */
13
+ export declare const hostExecutors: Record<string, NodeExecutor>;
14
+ /** Host-backed kind names (used by callers to know which kinds need a host). */
15
+ export declare const HOST_BACKED_KINDS: string[];
@@ -0,0 +1,35 @@
1
+ /**
2
+ * n8n workflow JSON import — read-format-only translator (plan M5 §2.1: "导入 n8n workflow JSON
3
+ * (读格式,不打包其代码)").
4
+ *
5
+ * Converts an n8n workflow export (its public JSON shape: `nodes` + `connections`) into our own
6
+ * WorkflowDef. This reads n8n's data FORMAT only — it links/embeds NONE of n8n's runtime code, so
7
+ * the SUL licensing concern (plan §2.1 / risk register) does not apply.
8
+ *
9
+ * Fail-loud, single-track (§1.5): the type map is CURATED. An unknown node type, an unmodeled
10
+ * multi-output port, a connection referencing a missing node, or a malformed top-level shape is
11
+ * REJECTED with a clear error — never silently coerced to a generic/passthrough fallback. The
12
+ * converted def is returned raw; the caller runs it through `validateWorkflowDef` (every write path
13
+ * does) so graph invariants are enforced by the single existing gate, not duplicated here.
14
+ *
15
+ * Out of scope (intentionally, to avoid fabricating config): deriving a workflow-level TriggerDef
16
+ * from n8n's structured trigger params. Recognized trigger nodes map to our `trigger` entry kind
17
+ * (preserving their original type + params for visibility); the real schedule/webhook TriggerDef is
18
+ * set afterward through the validated set_trigger channel.
19
+ */
20
+ import type { WorkflowDef } from "./node-schema.js";
21
+ export interface N8nImportResult {
22
+ name: string;
23
+ def: WorkflowDef;
24
+ }
25
+ /** Thrown when an n8n workflow cannot be faithfully translated. Carries every problem found. */
26
+ export declare class N8nImportError extends Error {
27
+ readonly errors: string[];
28
+ constructor(errors: string[]);
29
+ }
30
+ /**
31
+ * Convert an n8n workflow (a JSON string or already-parsed object) into a WorkflowDef.
32
+ * The returned def is NOT yet graph-validated — pass it to `validateWorkflowDef` / a controller
33
+ * write path, which is the single existing invariant gate.
34
+ */
35
+ export declare function convertN8nWorkflow(input: string | unknown, workflowId: string): N8nImportResult;
@@ -0,0 +1,19 @@
1
+ /**
2
+ * NodeExecutor registry (M2; plan §M2 "NodeExecutor 注册表").
3
+ *
4
+ * Single source of truth mapping node `kind` → executor. fail-loud on unknown kinds and
5
+ * duplicate registration. Built-in deterministic executors (set / if / merge) register here;
6
+ * host-backed executors (agent / tool / http / mcp / channel) are injected by the host so the
7
+ * engine stays a pure executor (plan D12/D13).
8
+ */
9
+ import type { NodeExecutor } from "./node-schema.js";
10
+ export declare class NodeRegistry {
11
+ private executors;
12
+ constructor(includeBuiltins?: boolean);
13
+ register(kind: string, executor: NodeExecutor): void;
14
+ /** Replace an existing executor (e.g. host overrides a built-in). Must already exist. */
15
+ override(kind: string, executor: NodeExecutor): void;
16
+ has(kind: string): boolean;
17
+ get(kind: string): NodeExecutor;
18
+ kinds(): string[];
19
+ }
@@ -0,0 +1,119 @@
1
+ /**
2
+ * Workflow node schema + NodeExecutor contract (M2; plan D10, spec §A1/§A6).
3
+ *
4
+ * One declarative schema, three consumers: inline UI (M4) / execution (here) / NL generation (M5).
5
+ * Control/data separation (spec §A1): the DagScheduler owns control; executors are pure data
6
+ * transforms `(inputs, params, ctx) → { outputs, firedPorts }`.
7
+ */
8
+ import type { DataItem, PortMap } from "./data-item.js";
9
+ /** Port type for connection validation (spec §A6). "any" connects to anything. */
10
+ export type PortType = "any" | "string" | "number" | "boolean" | "json" | "image" | "video" | "audio" | "binary";
11
+ export interface PortDef {
12
+ name: string;
13
+ type?: PortType;
14
+ }
15
+ /** Declarative workflow node (persisted; may carry `{{ }}` expressions in params). */
16
+ export interface WorkflowNodeDef {
17
+ id: string;
18
+ kind: string;
19
+ /** Optional human-friendly display name (rename_node patch op; spec D17 §C). */
20
+ name?: string;
21
+ params?: Record<string, unknown>;
22
+ /** Output ports; default ["default"]. if→["true","false"], loop→["loop","done"]. */
23
+ outPorts?: string[];
24
+ /** Input ports (for type-checked routing); default ["default"]. */
25
+ inPorts?: PortDef[];
26
+ joinPolicy?: "all" | "any";
27
+ maxIterations?: number;
28
+ }
29
+ /** A data edge (carries DataItem[]). fromPort/toPort default "default". */
30
+ export interface DataEdge {
31
+ from: string;
32
+ to: string;
33
+ fromPort?: string;
34
+ toPort?: string;
35
+ loopBack?: boolean;
36
+ }
37
+ export interface WorkflowDef {
38
+ id: string;
39
+ nodes: WorkflowNodeDef[];
40
+ edges: DataEdge[];
41
+ /** Workflow-level variables exposed to expressions as $vars. */
42
+ vars?: Record<string, unknown>;
43
+ }
44
+ export interface ExecutorContext {
45
+ nodeId: string;
46
+ kind: string;
47
+ /** 0-based; increments per loop iteration (drives the cache key, spec §A5). */
48
+ runIndex: number;
49
+ vars: Record<string, unknown>;
50
+ trigger?: Record<string, unknown>;
51
+ /** Injected clock for determinism. */
52
+ now: () => Date;
53
+ log?: {
54
+ info(m: string): void;
55
+ warn(m: string): void;
56
+ };
57
+ /** Host capabilities for host-backed node kinds (agent/tool/http/mcp/channel), D13. */
58
+ host?: ExecutorHost;
59
+ /** Cooperative cancellation for long-running host calls. */
60
+ signal?: AbortSignal;
61
+ }
62
+ /**
63
+ * Capabilities the HOST (openclaw gateway, or the qlogicagent CLI host) provides to back node
64
+ * kinds the engine cannot fulfil on its own. The engine stays a pure executor (plan D12/D13):
65
+ * agent/tool/mcp/http are qlogicagent-owned host capabilities; channel/IM call back into the
66
+ * openclaw channel layer. fail-loud: a host-backed kind with no host throws.
67
+ */
68
+ export interface ExecutorHost {
69
+ /** Run an agent turn. Returns the agent's structured output as DataItem(s). */
70
+ runAgent(req: AgentHostRequest): Promise<DataItem[]>;
71
+ /** Invoke a qlogicagent tool by name. */
72
+ invokeTool(req: ToolHostRequest): Promise<DataItem[]>;
73
+ /** Perform an HTTP request (credentials resolved host-side). */
74
+ httpRequest(req: HttpHostRequest): Promise<DataItem[]>;
75
+ /** Invoke an MCP server tool. */
76
+ invokeMcp(req: McpHostRequest): Promise<DataItem[]>;
77
+ /** Send a message out through a channel (飞书/微信/…) via the openclaw channel layer. */
78
+ sendChannel(req: ChannelHostRequest): Promise<DataItem[]>;
79
+ }
80
+ export interface AgentHostRequest {
81
+ agentId?: string;
82
+ prompt: string;
83
+ input: DataItem[];
84
+ signal?: AbortSignal;
85
+ }
86
+ export interface ToolHostRequest {
87
+ tool: string;
88
+ args: Record<string, unknown>;
89
+ input: DataItem[];
90
+ signal?: AbortSignal;
91
+ }
92
+ export interface HttpHostRequest {
93
+ method: string;
94
+ url: string;
95
+ headers?: Record<string, string>;
96
+ body?: unknown;
97
+ signal?: AbortSignal;
98
+ }
99
+ export interface McpHostRequest {
100
+ server: string;
101
+ tool: string;
102
+ args: Record<string, unknown>;
103
+ signal?: AbortSignal;
104
+ }
105
+ export interface ChannelHostRequest {
106
+ channel: string;
107
+ target?: string;
108
+ payload: unknown;
109
+ input: DataItem[];
110
+ signal?: AbortSignal;
111
+ }
112
+ export interface NodeExecResult {
113
+ /** outPort → DataItem[]. */
114
+ outputs: PortMap;
115
+ /** Control nodes (if/loop) set this; data nodes omit → all outPorts fire. */
116
+ firedPorts?: string[];
117
+ }
118
+ /** A node executor: pure with respect to (inputs, params, ctx). NO hidden global state. */
119
+ export type NodeExecutor = (inputs: PortMap, params: Record<string, unknown>, ctx: ExecutorContext) => Promise<NodeExecResult> | NodeExecResult;
@@ -0,0 +1,42 @@
1
+ /**
2
+ * QlogicagentExecutorHost — the REAL host backing host-executors (agent/tool/http/mcp/channel)
3
+ * with qlogicagent's actual capabilities. No mocks, no stubs (plan §1.5).
4
+ *
5
+ * Boundary capabilities (runAgent / invokeMcp / sendChannel) are injected so this file stays
6
+ * decoupled from the handler host that owns processManager/acpDetector and the openclaw channel
7
+ * callback. Tool invocation goes straight through the single-source-of-truth tool registry
8
+ * (`findTool`). fail-loud everywhere: unknown tool, missing channel host, or any rejection throws.
9
+ */
10
+ import type { PortableTool } from "../../skills/portable-tool.js";
11
+ import type { ExecutorHost } from "./node-schema.js";
12
+ /** Injected boundary capabilities — supplied by the handler host that owns the real runners. */
13
+ export interface QlaExecutorHostDeps {
14
+ /** Run one agent turn (spawn external ACP agent + sendTask). Returns the agent's text output. */
15
+ runAgent: (req: {
16
+ agentId?: string;
17
+ prompt: string;
18
+ signal?: AbortSignal;
19
+ }) => Promise<string>;
20
+ /** Invoke an MCP server tool through the real MCP bridge. */
21
+ invokeMcp: (req: {
22
+ server: string;
23
+ tool: string;
24
+ args: Record<string, unknown>;
25
+ signal?: AbortSignal;
26
+ }) => Promise<unknown>;
27
+ /**
28
+ * Send a message out through a channel via the openclaw channel layer.
29
+ * Undefined in standalone qlogicagent (no gateway) → channel nodes fail-loud (D12/D13).
30
+ */
31
+ sendChannel?: (req: {
32
+ channel: string;
33
+ target?: string;
34
+ payload: unknown;
35
+ signal?: AbortSignal;
36
+ }) => Promise<unknown>;
37
+ /** Tool lookup; defaults to the real registry. Injectable for tests. */
38
+ findTool?: (name: string) => PortableTool | undefined;
39
+ /** fetch impl; defaults to global fetch. Injectable for tests. */
40
+ fetchImpl?: typeof fetch;
41
+ }
42
+ export declare function createQlaExecutorHost(deps: QlaExecutorHostDeps): ExecutorHost;
@@ -0,0 +1,53 @@
1
+ /**
2
+ * Run Checkpoint Store — durable crash-restart recovery for in-flight workflow runs (plan §M3).
3
+ *
4
+ * The runtime's output cache is content-addressed (key = hash(kind + params + input signature +
5
+ * runIndex), spec §A5). Persisting that cache to disk turns run-from-node into crash recovery:
6
+ * after a qlogicagent restart, a FRESH WorkflowRuntime replays the same DAG, recomputes the same
7
+ * cache keys, and hits the persisted entries for every node that already completed — so those
8
+ * executors are NOT re-invoked (no duplicate agent turns / channel sends), and only the
9
+ * not-yet-run remainder executes. This is exactly the M3 acceptance:
10
+ * "qlogicagent 崩溃重启从 checkpoint 恢复在跑工作流".
11
+ *
12
+ * Stored at `<project>/.qlogicagent/workflows/<workflowId>/runs/<runId>/cache.json`.
13
+ * NodeExecResult is JSON (PortMap of DataItems + firedPorts), so the snapshot round-trips losslessly.
14
+ *
15
+ * fail-loud: a corrupt/unreadable snapshot is treated as absent (a fresh run), never silently
16
+ * partially applied.
17
+ */
18
+ import type { NodeExecResult } from "./node-schema.js";
19
+ /** One persisted cache entry: a content key and the executor result it produced. */
20
+ export interface CheckpointEntry {
21
+ key: string;
22
+ result: NodeExecResult;
23
+ }
24
+ /** A point-in-time snapshot of a run's content-addressed output cache. */
25
+ export interface CheckpointSnapshot {
26
+ workflowId: string;
27
+ runId: string;
28
+ entries: CheckpointEntry[];
29
+ updatedAt: string;
30
+ }
31
+ /**
32
+ * Durable run state the runtime loads on (re)start and persists after each computed node.
33
+ * Implementations may be file-backed (production) or in-memory (tests).
34
+ */
35
+ export interface RunCheckpoint {
36
+ /** Load the prior snapshot, or undefined for a never-started / absent run. */
37
+ load(): Promise<CheckpointSnapshot | undefined>;
38
+ /** Persist the full set of computed cache entries (idempotent overwrite). */
39
+ persist(entries: CheckpointEntry[]): Promise<void>;
40
+ /** Remove the snapshot once the run has completed successfully. */
41
+ clear(): Promise<void>;
42
+ }
43
+ /** File-backed checkpoint under `.qlogicagent/workflows/<id>/runs/<runId>/cache.json`. */
44
+ export declare class FileRunCheckpoint implements RunCheckpoint {
45
+ private readonly workflowId;
46
+ private readonly runId;
47
+ private readonly dir;
48
+ private readonly file;
49
+ constructor(cwd: string, workflowId: string, runId: string);
50
+ load(): Promise<CheckpointSnapshot | undefined>;
51
+ persist(entries: CheckpointEntry[]): Promise<void>;
52
+ clear(): Promise<void>;
53
+ }
@@ -0,0 +1,22 @@
1
+ /**
2
+ * Trigger validation — deterministic, fail-loud gate for workflow trigger configs (plan D7/D15).
3
+ *
4
+ * Triggers are the unattended entry points to a workflow (schedule/im-message/webhook/manual). A
5
+ * malformed trigger (an unparseable cron, a non-path webhook, an uncompilable IM match regex) must
6
+ * be rejected at the SINGLE mutation channel (`applyPatch` set_trigger), not silently persisted to
7
+ * fail later inside the gateway trigger layer where it is unreachable to fix. This keeps §1.5
8
+ * fail-loud and satisfies D15 ("schedule 须有效 cron / webhook 鉴权+限流" preconditions).
9
+ *
10
+ * Pure functions, no I/O, no side effects — the gateway still owns actual registration/auth/rate
11
+ * limiting; this only guarantees the stored config is structurally valid and runnable.
12
+ */
13
+ import type { TriggerDef } from "./workflow-trigger.js";
14
+ /** Returns a list of human-readable errors; empty ⇒ the trigger is valid. */
15
+ export declare function validateTrigger(trigger: TriggerDef): string[];
16
+ /**
17
+ * Validate a 5-field (min hour dom month dow) or 6-field (sec + the same) cron expression.
18
+ * Each field accepts a star, a star-step (every-N), a single value, a range, a stepped range, and
19
+ * comma-lists of those. Month and day-of-week additionally accept their 3-letter names.
20
+ * Day-of-week allows 0 and 7 for Sunday.
21
+ */
22
+ export declare function validateCron(cron: string): string[];
@@ -0,0 +1,143 @@
1
+ /**
2
+ * Workflow Controller — automation driver: create / run / pause / resume + concurrency (spec §B4/B5).
3
+ *
4
+ * Owns workflow lifecycle on top of the WorkflowStore (persistence) and WorkflowRuntime (execution).
5
+ * Concurrency (spec §B5): when a workflow is triggered while a previous run is still in-flight, the
6
+ * record's `concurrency` policy decides:
7
+ * - "skip" → drop the new trigger (returns status "skipped")
8
+ * - "queue" → run after the current one finishes, reusing the runtime so its output cache
9
+ * survives → resume / run-from-node semantics hold
10
+ * - "parallel" → start a fresh independent runtime concurrently (own cache)
11
+ *
12
+ * The caller supplies a `runtimeFactory` so host capabilities (D13), the node registry, the
13
+ * budget/permission gate (D15), and the clock are injected per workflow — the controller never
14
+ * imports those subsystems (engine stays a pure executor; plan D12).
15
+ *
16
+ * fail-loud: unknown workflow ids throw; executor/gate errors propagate out of run().
17
+ */
18
+ import type { RunResult, WorkflowRuntime } from "./workflow-runtime.js";
19
+ import type { NodeRegistry } from "./node-registry.js";
20
+ import type { ExecutorHost } from "./node-schema.js";
21
+ import { type WorkflowTriggerKind } from "./budget-permission-gate.js";
22
+ import type { WorkflowDef } from "./node-schema.js";
23
+ import { type PatchEnvelope, type WorkflowPatch } from "./workflow-patch.js";
24
+ import { type RenderOptions } from "./workflow-render.js";
25
+ import { WorkflowStore, type ConcurrencyPolicy, type WorkflowRecord } from "./workflow-store.js";
26
+ export interface TriggerEvent {
27
+ type: WorkflowTriggerKind;
28
+ payload?: Record<string, unknown>;
29
+ }
30
+ /**
31
+ * Per-run context handed to the RuntimeFactory: the trigger KIND (so the factory can wire the D15
32
+ * permission gate — unattended kinds are restricted) plus its payload (exposed to expressions).
33
+ */
34
+ export interface RunContext {
35
+ type: WorkflowTriggerKind;
36
+ payload?: Record<string, unknown>;
37
+ }
38
+ /** Builds a runtime for a workflow run. `ctx` carries the run's trigger kind + payload (spec §B3). */
39
+ export type RuntimeFactory = (def: WorkflowDef, ctx: RunContext) => WorkflowRuntime;
40
+ export interface RunOutcome {
41
+ workflowId: string;
42
+ status: "completed" | "failed" | "paused" | "skipped";
43
+ /** Absent when status === "skipped" (a busy run under the "skip" policy). */
44
+ result?: RunResult;
45
+ }
46
+ export interface CreateInput {
47
+ id: string;
48
+ name: string;
49
+ def: WorkflowDef;
50
+ concurrency?: ConcurrencyPolicy;
51
+ active?: boolean;
52
+ }
53
+ /** Result of a `patch()` call (spec §C `WorkflowToolResult`). */
54
+ export type PatchOutcome = {
55
+ ok: true;
56
+ rev: number;
57
+ applied: WorkflowPatch[];
58
+ } | {
59
+ ok: false;
60
+ conflict: {
61
+ latestRev: number;
62
+ };
63
+ };
64
+ export declare class WorkflowController {
65
+ private readonly store;
66
+ private readonly runtimeFactory;
67
+ private readonly slots;
68
+ constructor(store: WorkflowStore, runtimeFactory: RuntimeFactory);
69
+ create(input: CreateInput): Promise<WorkflowRecord>;
70
+ update(id: string, patch: Partial<Pick<WorkflowRecord, "name" | "def" | "concurrency" | "active">>): Promise<WorkflowRecord>;
71
+ setActive(id: string, active: boolean): Promise<WorkflowRecord>;
72
+ /**
73
+ * Import an n8n workflow JSON (read-format only, plan M5 §2.1) into the single store. Converts
74
+ * via the deterministic translator then routes through `create`, so the graph passes the same
75
+ * `validateWorkflowDef` gate every write path uses — fail-loud on unsupported nodes or bad graph.
76
+ */
77
+ importN8n(id: string, json: string | unknown, opts?: {
78
+ concurrency?: ConcurrencyPolicy;
79
+ }): Promise<WorkflowRecord>;
80
+ /** Load a single record or throw (fail-loud lookup; used by the scheduler to re-read triggers). */
81
+ get(id: string): Promise<WorkflowRecord>;
82
+ /**
83
+ * Render a workflow as compact agent-context text (spec §B / §A `get`). Fail-loud on unknown id.
84
+ * This is the engine half of the agent `workflow.get`/describe action: the agent reads this and
85
+ * emits a WorkflowPatch against the shown `rev`.
86
+ */
87
+ describe(id: string, opts?: RenderOptions): Promise<string>;
88
+ /**
89
+ * Apply a WorkflowPatch — the single mutation channel for agent edits and canvas hand-edits
90
+ * (spec §C). Loads the latest record, applies the patch transactionally through the engine
91
+ * (scope enforcement + validateDag), bumps `rev`, and persists. Optimistic concurrency (LWW):
92
+ * - baseRev omitted or == current rev → apply against the latest.
93
+ * - baseRev < current rev (someone edited in between) → replay onto the latest; if every op
94
+ * still references valid nodes/edges it applies (last-write-wins), otherwise a conflict is
95
+ * returned so the caller can redo against the latest rendering.
96
+ * A rejected patch (illegal op / scope violation / invalid graph) throws PatchError unchanged.
97
+ */
98
+ patch(id: string, env: PatchEnvelope): Promise<PatchOutcome>;
99
+ /** Trigger a run, honoring the workflow's concurrency policy (spec §B5). */
100
+ run(id: string, trigger?: TriggerEvent): Promise<RunOutcome>;
101
+ /** Cooperatively pause the in-flight run; it suspends before the next node (cache retained). */
102
+ pause(id: string): void;
103
+ /** Resume a paused workflow: re-run the same runtime so cached nodes hit and only the
104
+ * unfinished remainder executes. When the run paused on an exhausted budget, pass `extraBudget`
105
+ * to raise the gate's ceiling first (D15 "抬预算后 resume"); otherwise the first not-yet-run
106
+ * node would immediately re-trip the same budget and pause again. */
107
+ resume(id: string, opts?: {
108
+ extraBudget?: {
109
+ executions?: number;
110
+ durationMs?: number;
111
+ };
112
+ }): Promise<RunOutcome>;
113
+ /** Active workflows whose triggers the gateway should re-register after restart (spec §B4). */
114
+ listActive(): Promise<WorkflowRecord[]>;
115
+ private slotFor;
116
+ /**
117
+ * Track a fresh or queued run on the slot. `chained` runs wait for the slot's tail (the prior
118
+ * run) before starting → strict serialization for the "queue" policy. `pending` is incremented
119
+ * synchronously so concurrent triggers observe the slot as busy across the run→queue handoff.
120
+ */
121
+ private track;
122
+ private startParallel;
123
+ }
124
+ /**
125
+ * The production RuntimeFactory: builds a WorkflowRuntime wired with the D15 BudgetPermissionGate
126
+ * derived from the run's trigger kind. This is the consumer that turns the gate from a bare
127
+ * interface into an enforced guarantee — every run the controller starts through this factory has
128
+ * its per-run budget and (for unattended triggers) its permission allowlist checked before each
129
+ * node. Hosts supply the registry/host capabilities and the budget ceilings; the gate wiring is
130
+ * fixed so no run can accidentally execute ungated.
131
+ */
132
+ export declare function defaultRuntimeFactory(opts: {
133
+ registry?: NodeRegistry;
134
+ host?: ExecutorHost;
135
+ /** Per-run budget ceilings (D15 "每轮过 budget"). maxNodeExecutions is required and must be > 0. */
136
+ budget: {
137
+ maxNodeExecutions: number;
138
+ maxDurationMs?: number;
139
+ };
140
+ /** Sensitive kinds an unattended run may execute (D15 permission gate). */
141
+ allowUnattendedKinds?: readonly string[];
142
+ now?: () => Date;
143
+ }): RuntimeFactory;