@assemblyline-agents/runtime 5.0.10 → 6.0.1

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 (451) hide show
  1. package/README.md +20 -5
  2. package/dist/a2a-client.d.ts +1 -3
  3. package/dist/a2a-client.d.ts.map +1 -1
  4. package/dist/a2a-client.js +1 -4
  5. package/dist/a2a-client.js.map +1 -1
  6. package/dist/agent-event-handlers.d.ts +2 -0
  7. package/dist/agent-event-handlers.d.ts.map +1 -1
  8. package/dist/agent-event-handlers.js +1 -1
  9. package/dist/agent-event-handlers.js.map +1 -1
  10. package/dist/agent-hook-context.d.ts.map +1 -1
  11. package/dist/agent-hook-context.js +3 -1
  12. package/dist/agent-hook-context.js.map +1 -1
  13. package/dist/agent-hook-controller-factory.d.ts +5 -1
  14. package/dist/agent-hook-controller-factory.d.ts.map +1 -1
  15. package/dist/agent-hook-controller-factory.js +11 -9
  16. package/dist/agent-hook-controller-factory.js.map +1 -1
  17. package/dist/agent-hook-evaluation.d.ts +0 -2
  18. package/dist/agent-hook-evaluation.d.ts.map +1 -1
  19. package/dist/agent-hook-evaluation.js +10 -10
  20. package/dist/agent-hook-evaluation.js.map +1 -1
  21. package/dist/agent-hook-run-lifecycle.d.ts +1 -2
  22. package/dist/agent-hook-run-lifecycle.d.ts.map +1 -1
  23. package/dist/agent-hook-run-lifecycle.js +1 -2
  24. package/dist/agent-hook-run-lifecycle.js.map +1 -1
  25. package/dist/agent-surface.d.ts +5 -2
  26. package/dist/agent-surface.d.ts.map +1 -1
  27. package/dist/agent-surface.js +11 -3
  28. package/dist/agent-surface.js.map +1 -1
  29. package/dist/artifact-selection.js +1 -1
  30. package/dist/artifact-selection.js.map +1 -1
  31. package/dist/assembly-line-runtime.d.ts +9 -0
  32. package/dist/assembly-line-runtime.d.ts.map +1 -0
  33. package/dist/assembly-line-runtime.js +9 -0
  34. package/dist/assembly-line-runtime.js.map +1 -0
  35. package/dist/attachment-download.d.ts +17 -0
  36. package/dist/attachment-download.d.ts.map +1 -0
  37. package/dist/attachment-download.js +51 -0
  38. package/dist/attachment-download.js.map +1 -0
  39. package/dist/attachments.d.ts +2 -14
  40. package/dist/attachments.d.ts.map +1 -1
  41. package/dist/attachments.js +8 -80
  42. package/dist/attachments.js.map +1 -1
  43. package/dist/background-review-types.d.ts +2 -0
  44. package/dist/background-review-types.d.ts.map +1 -1
  45. package/dist/background-review.d.ts.map +1 -1
  46. package/dist/background-review.js +13 -0
  47. package/dist/background-review.js.map +1 -1
  48. package/dist/background-subagents.d.ts +1 -1
  49. package/dist/background-subagents.d.ts.map +1 -1
  50. package/dist/blob-storage.d.ts +12 -0
  51. package/dist/blob-storage.d.ts.map +1 -0
  52. package/dist/blob-storage.js +86 -0
  53. package/dist/blob-storage.js.map +1 -0
  54. package/dist/builtin-tool-executors.d.ts.map +1 -1
  55. package/dist/builtin-tool-executors.js +12 -11
  56. package/dist/builtin-tool-executors.js.map +1 -1
  57. package/dist/builtin-tools.d.ts +1 -2
  58. package/dist/builtin-tools.d.ts.map +1 -1
  59. package/dist/builtin-tools.js +0 -8
  60. package/dist/builtin-tools.js.map +1 -1
  61. package/dist/capability-inspection.d.ts +4 -0
  62. package/dist/capability-inspection.d.ts.map +1 -1
  63. package/dist/capability-inspection.js +10 -11
  64. package/dist/capability-inspection.js.map +1 -1
  65. package/dist/channel-credential-environment.d.ts +1 -1
  66. package/dist/channel-credential-environment.d.ts.map +1 -1
  67. package/dist/channel-credential-environment.js +1 -6
  68. package/dist/channel-credential-environment.js.map +1 -1
  69. package/dist/channel-ingress.d.ts +1 -2
  70. package/dist/channel-ingress.d.ts.map +1 -1
  71. package/dist/channel-ingress.js +2 -2
  72. package/dist/channel-ingress.js.map +1 -1
  73. package/dist/channel-operation.d.ts +0 -1
  74. package/dist/channel-operation.d.ts.map +1 -1
  75. package/dist/channel-operation.js +1 -2
  76. package/dist/channel-operation.js.map +1 -1
  77. package/dist/channel.d.ts +32 -3
  78. package/dist/channel.d.ts.map +1 -1
  79. package/dist/connection-assets.d.ts.map +1 -1
  80. package/dist/connection-assets.js.map +1 -1
  81. package/dist/connection-authorization-service.d.ts +52 -0
  82. package/dist/connection-authorization-service.d.ts.map +1 -0
  83. package/dist/connection-authorization-service.js +417 -0
  84. package/dist/connection-authorization-service.js.map +1 -0
  85. package/dist/connection-credential-materialization.d.ts +23 -0
  86. package/dist/connection-credential-materialization.d.ts.map +1 -0
  87. package/dist/connection-credential-materialization.js +223 -0
  88. package/dist/connection-credential-materialization.js.map +1 -0
  89. package/dist/connection-definition-loader.d.ts +6 -0
  90. package/dist/connection-definition-loader.d.ts.map +1 -0
  91. package/dist/connection-definition-loader.js +102 -0
  92. package/dist/connection-definition-loader.js.map +1 -0
  93. package/dist/connection-discovery.d.ts +11 -0
  94. package/dist/connection-discovery.d.ts.map +1 -0
  95. package/dist/connection-discovery.js +105 -0
  96. package/dist/connection-discovery.js.map +1 -0
  97. package/dist/connection-events.d.ts.map +1 -1
  98. package/dist/connection-events.js.map +1 -1
  99. package/dist/connection-oauth-client.d.ts +3 -0
  100. package/dist/connection-oauth-client.d.ts.map +1 -0
  101. package/dist/connection-oauth-client.js +64 -0
  102. package/dist/connection-oauth-client.js.map +1 -0
  103. package/dist/connection-runtime-types.d.ts +78 -0
  104. package/dist/connection-runtime-types.d.ts.map +1 -0
  105. package/dist/connection-runtime-types.js +31 -0
  106. package/dist/connection-runtime-types.js.map +1 -0
  107. package/dist/connections.d.ts +18 -167
  108. package/dist/connections.d.ts.map +1 -1
  109. package/dist/connections.js +71 -1017
  110. package/dist/connections.js.map +1 -1
  111. package/dist/context-policy-util.d.ts +0 -4
  112. package/dist/context-policy-util.d.ts.map +1 -1
  113. package/dist/context-policy-util.js +0 -10
  114. package/dist/context-policy-util.js.map +1 -1
  115. package/dist/conversation-context.d.ts +1 -1
  116. package/dist/conversation-context.d.ts.map +1 -1
  117. package/dist/conversation-context.js +12 -9
  118. package/dist/conversation-context.js.map +1 -1
  119. package/dist/default-outbound-route.d.ts +1 -0
  120. package/dist/default-outbound-route.d.ts.map +1 -1
  121. package/dist/default-outbound-route.js +1 -1
  122. package/dist/default-outbound-route.js.map +1 -1
  123. package/dist/delivery-queue.d.ts +1 -1
  124. package/dist/delivery-send.d.ts.map +1 -1
  125. package/dist/delivery-send.js +3 -2
  126. package/dist/delivery-send.js.map +1 -1
  127. package/dist/dynamic-schedule-execution.d.ts +4 -0
  128. package/dist/dynamic-schedule-execution.d.ts.map +1 -0
  129. package/dist/dynamic-schedule-execution.js +136 -0
  130. package/dist/dynamic-schedule-execution.js.map +1 -0
  131. package/dist/dynamic-schedule-runtime.d.ts +11 -20
  132. package/dist/dynamic-schedule-runtime.d.ts.map +1 -1
  133. package/dist/dynamic-schedule-runtime.js +27 -39
  134. package/dist/dynamic-schedule-runtime.js.map +1 -1
  135. package/dist/evolution-tracker.d.ts +52 -0
  136. package/dist/evolution-tracker.d.ts.map +1 -0
  137. package/dist/evolution-tracker.js +179 -0
  138. package/dist/evolution-tracker.js.map +1 -0
  139. package/dist/harness-capabilities.d.ts +7 -0
  140. package/dist/harness-capabilities.d.ts.map +1 -0
  141. package/dist/harness-capabilities.js +56 -0
  142. package/dist/harness-capabilities.js.map +1 -0
  143. package/dist/harness-continuation-persistence.d.ts +6 -0
  144. package/dist/harness-continuation-persistence.d.ts.map +1 -0
  145. package/dist/harness-continuation-persistence.js +11 -0
  146. package/dist/harness-continuation-persistence.js.map +1 -0
  147. package/dist/harness-execution-context.d.ts +10 -0
  148. package/dist/harness-execution-context.d.ts.map +1 -0
  149. package/dist/harness-execution-context.js +193 -0
  150. package/dist/harness-execution-context.js.map +1 -0
  151. package/dist/harness-loop-types.d.ts +67 -0
  152. package/dist/harness-loop-types.d.ts.map +1 -0
  153. package/dist/harness-loop-types.js +2 -0
  154. package/dist/harness-loop-types.js.map +1 -0
  155. package/dist/harness-loop.d.ts +13 -94
  156. package/dist/harness-loop.d.ts.map +1 -1
  157. package/dist/harness-loop.js +19 -551
  158. package/dist/harness-loop.js.map +1 -1
  159. package/dist/harness-tool-execution.d.ts +30 -0
  160. package/dist/harness-tool-execution.d.ts.map +1 -0
  161. package/dist/harness-tool-execution.js +397 -0
  162. package/dist/harness-tool-execution.js.map +1 -0
  163. package/dist/harness-transcript-resume.d.ts +18 -0
  164. package/dist/harness-transcript-resume.d.ts.map +1 -0
  165. package/dist/harness-transcript-resume.js +102 -0
  166. package/dist/harness-transcript-resume.js.map +1 -0
  167. package/dist/harness-turn-execution.d.ts +11 -0
  168. package/dist/harness-turn-execution.d.ts.map +1 -0
  169. package/dist/harness-turn-execution.js +157 -0
  170. package/dist/harness-turn-execution.js.map +1 -0
  171. package/dist/index.d.ts +10 -499
  172. package/dist/index.d.ts.map +1 -1
  173. package/dist/index.js +9 -2139
  174. package/dist/index.js.map +1 -1
  175. package/dist/local-sandbox.d.ts +2 -1
  176. package/dist/local-sandbox.d.ts.map +1 -1
  177. package/dist/mcp-client.d.ts +11 -1
  178. package/dist/mcp-client.d.ts.map +1 -1
  179. package/dist/mcp-client.js +39 -7
  180. package/dist/mcp-client.js.map +1 -1
  181. package/dist/media-processor.d.ts +3 -1
  182. package/dist/media-processor.d.ts.map +1 -1
  183. package/dist/media-processor.js +15 -1
  184. package/dist/media-processor.js.map +1 -1
  185. package/dist/memory-storage.d.ts +51 -0
  186. package/dist/memory-storage.d.ts.map +1 -0
  187. package/dist/memory-storage.js +324 -0
  188. package/dist/memory-storage.js.map +1 -0
  189. package/dist/model-credential-stores.d.ts.map +1 -1
  190. package/dist/model-credential-stores.js +6 -12
  191. package/dist/model-credential-stores.js.map +1 -1
  192. package/dist/model-provider-environment.d.ts +4 -0
  193. package/dist/model-provider-environment.d.ts.map +1 -0
  194. package/dist/model-provider-environment.js +36 -0
  195. package/dist/model-provider-environment.js.map +1 -0
  196. package/dist/plugin-embeddings.d.ts +4 -0
  197. package/dist/plugin-embeddings.d.ts.map +1 -0
  198. package/dist/plugin-embeddings.js +75 -0
  199. package/dist/plugin-embeddings.js.map +1 -0
  200. package/dist/public-api.d.ts +8 -5
  201. package/dist/public-api.d.ts.map +1 -1
  202. package/dist/public-api.js +6 -4
  203. package/dist/public-api.js.map +1 -1
  204. package/dist/relay-mcp-client.js +1 -1
  205. package/dist/relay-mcp-client.js.map +1 -1
  206. package/dist/replay-resume-authorization.d.ts +8 -0
  207. package/dist/replay-resume-authorization.d.ts.map +1 -0
  208. package/dist/replay-resume-authorization.js +181 -0
  209. package/dist/replay-resume-authorization.js.map +1 -0
  210. package/dist/replay-resume-connection.d.ts +6 -0
  211. package/dist/replay-resume-connection.d.ts.map +1 -0
  212. package/dist/replay-resume-connection.js +75 -0
  213. package/dist/replay-resume-connection.js.map +1 -0
  214. package/dist/replay-resume-controls.d.ts +6 -0
  215. package/dist/replay-resume-controls.d.ts.map +1 -0
  216. package/dist/replay-resume-controls.js +157 -0
  217. package/dist/replay-resume-controls.js.map +1 -0
  218. package/dist/replay-resume-harness.d.ts +14 -0
  219. package/dist/replay-resume-harness.d.ts.map +1 -0
  220. package/dist/replay-resume-harness.js +158 -0
  221. package/dist/replay-resume-harness.js.map +1 -0
  222. package/dist/replay-resume-recovery.d.ts +10 -0
  223. package/dist/replay-resume-recovery.d.ts.map +1 -0
  224. package/dist/replay-resume-recovery.js +62 -0
  225. package/dist/replay-resume-recovery.js.map +1 -0
  226. package/dist/replay-resume-shared.d.ts +16 -0
  227. package/dist/replay-resume-shared.d.ts.map +1 -0
  228. package/dist/replay-resume-shared.js +55 -0
  229. package/dist/replay-resume-shared.js.map +1 -0
  230. package/dist/replay-resume-types.d.ts +85 -0
  231. package/dist/replay-resume-types.d.ts.map +1 -0
  232. package/dist/replay-resume-types.js +2 -0
  233. package/dist/replay-resume-types.js.map +1 -0
  234. package/dist/replay-resume.d.ts +7 -119
  235. package/dist/replay-resume.d.ts.map +1 -1
  236. package/dist/replay-resume.js +5 -715
  237. package/dist/replay-resume.js.map +1 -1
  238. package/dist/resource-projection-util.d.ts +1 -2
  239. package/dist/resource-projection-util.d.ts.map +1 -1
  240. package/dist/resource-projection-util.js +2 -11
  241. package/dist/resource-projection-util.js.map +1 -1
  242. package/dist/resource-projection.d.ts.map +1 -1
  243. package/dist/resource-projection.js +67 -22
  244. package/dist/resource-projection.js.map +1 -1
  245. package/dist/run-execution-host.d.ts +98 -0
  246. package/dist/run-execution-host.d.ts.map +1 -0
  247. package/dist/run-execution-host.js +2 -0
  248. package/dist/run-execution-host.js.map +1 -0
  249. package/dist/run-execution.d.ts +6 -0
  250. package/dist/run-execution.d.ts.map +1 -0
  251. package/dist/run-execution.js +313 -0
  252. package/dist/run-execution.js.map +1 -0
  253. package/dist/run-initialization.d.ts +19 -0
  254. package/dist/run-initialization.d.ts.map +1 -0
  255. package/dist/run-initialization.js +171 -0
  256. package/dist/run-initialization.js.map +1 -0
  257. package/dist/run-recovery.d.ts +1 -1
  258. package/dist/run-recovery.js.map +1 -1
  259. package/dist/runtime-connection-definitions.d.ts +35 -0
  260. package/dist/runtime-connection-definitions.d.ts.map +1 -0
  261. package/dist/runtime-connection-definitions.js +97 -0
  262. package/dist/runtime-connection-definitions.js.map +1 -0
  263. package/dist/runtime-engine-background.d.ts +64 -0
  264. package/dist/runtime-engine-background.d.ts.map +1 -0
  265. package/dist/runtime-engine-background.js +136 -0
  266. package/dist/runtime-engine-background.js.map +1 -0
  267. package/dist/runtime-engine-base.d.ts +60 -0
  268. package/dist/runtime-engine-base.d.ts.map +1 -0
  269. package/dist/runtime-engine-base.js +192 -0
  270. package/dist/runtime-engine-base.js.map +1 -0
  271. package/dist/runtime-engine-capabilities.d.ts +81 -0
  272. package/dist/runtime-engine-capabilities.d.ts.map +1 -0
  273. package/dist/runtime-engine-capabilities.js +198 -0
  274. package/dist/runtime-engine-capabilities.js.map +1 -0
  275. package/dist/runtime-engine-config.d.ts +77 -0
  276. package/dist/runtime-engine-config.d.ts.map +1 -0
  277. package/dist/runtime-engine-config.js +187 -0
  278. package/dist/runtime-engine-config.js.map +1 -0
  279. package/dist/runtime-engine-foundation.d.ts +11 -0
  280. package/dist/runtime-engine-foundation.d.ts.map +1 -0
  281. package/dist/runtime-engine-foundation.js +121 -0
  282. package/dist/runtime-engine-foundation.js.map +1 -0
  283. package/dist/runtime-engine-hooks.d.ts +33 -0
  284. package/dist/runtime-engine-hooks.d.ts.map +1 -0
  285. package/dist/runtime-engine-hooks.js +153 -0
  286. package/dist/runtime-engine-hooks.js.map +1 -0
  287. package/dist/runtime-engine-integrations.d.ts +16 -0
  288. package/dist/runtime-engine-integrations.d.ts.map +1 -0
  289. package/dist/runtime-engine-integrations.js +177 -0
  290. package/dist/runtime-engine-integrations.js.map +1 -0
  291. package/dist/runtime-engine-operations.d.ts +87 -0
  292. package/dist/runtime-engine-operations.d.ts.map +1 -0
  293. package/dist/runtime-engine-operations.js +204 -0
  294. package/dist/runtime-engine-operations.js.map +1 -0
  295. package/dist/runtime-engine-resources.d.ts +18 -0
  296. package/dist/runtime-engine-resources.d.ts.map +1 -0
  297. package/dist/runtime-engine-resources.js +49 -0
  298. package/dist/runtime-engine-resources.js.map +1 -0
  299. package/dist/runtime-engine-run.d.ts +70 -0
  300. package/dist/runtime-engine-run.d.ts.map +1 -0
  301. package/dist/runtime-engine-run.js +202 -0
  302. package/dist/runtime-engine-run.js.map +1 -0
  303. package/dist/runtime-engine-scheduling.d.ts +22 -0
  304. package/dist/runtime-engine-scheduling.d.ts.map +1 -0
  305. package/dist/runtime-engine-scheduling.js +45 -0
  306. package/dist/runtime-engine-scheduling.js.map +1 -0
  307. package/dist/runtime-engine-tools.d.ts +8 -0
  308. package/dist/runtime-engine-tools.d.ts.map +1 -0
  309. package/dist/runtime-engine-tools.js +80 -0
  310. package/dist/runtime-engine-tools.js.map +1 -0
  311. package/dist/runtime-evolution.d.ts +17 -0
  312. package/dist/runtime-evolution.d.ts.map +1 -0
  313. package/dist/runtime-evolution.js +51 -0
  314. package/dist/runtime-evolution.js.map +1 -0
  315. package/dist/runtime-learning.d.ts +4 -6
  316. package/dist/runtime-learning.d.ts.map +1 -1
  317. package/dist/runtime-learning.js +109 -99
  318. package/dist/runtime-learning.js.map +1 -1
  319. package/dist/runtime-types.d.ts +21 -7
  320. package/dist/runtime-types.d.ts.map +1 -1
  321. package/dist/runtime-util.d.ts +4 -3
  322. package/dist/runtime-util.d.ts.map +1 -1
  323. package/dist/runtime-util.js +0 -7
  324. package/dist/runtime-util.js.map +1 -1
  325. package/dist/sandbox-atomic-json.d.ts +4 -0
  326. package/dist/sandbox-atomic-json.d.ts.map +1 -0
  327. package/dist/sandbox-atomic-json.js +23 -0
  328. package/dist/sandbox-atomic-json.js.map +1 -0
  329. package/dist/sandbox-authored-tool-executor.d.ts.map +1 -1
  330. package/dist/sandbox-authored-tool-executor.js +13 -3
  331. package/dist/sandbox-authored-tool-executor.js.map +1 -1
  332. package/dist/sandbox-fs.d.ts +2 -7
  333. package/dist/sandbox-fs.d.ts.map +1 -1
  334. package/dist/sandbox-fs.js +6 -37
  335. package/dist/sandbox-fs.js.map +1 -1
  336. package/dist/sandbox-handle.d.ts +1 -3
  337. package/dist/sandbox-handle.d.ts.map +1 -1
  338. package/dist/sandbox-handle.js +2 -5
  339. package/dist/sandbox-handle.js.map +1 -1
  340. package/dist/sandbox-state-sync.d.ts +2 -0
  341. package/dist/sandbox-state-sync.d.ts.map +1 -1
  342. package/dist/sandbox-state-sync.js +26 -2
  343. package/dist/sandbox-state-sync.js.map +1 -1
  344. package/dist/sandbox-tool-bridge.d.ts.map +1 -1
  345. package/dist/sandbox-tool-bridge.js +23 -3
  346. package/dist/sandbox-tool-bridge.js.map +1 -1
  347. package/dist/schedule-execution.d.ts +4 -4
  348. package/dist/schedule-execution.d.ts.map +1 -1
  349. package/dist/schedule-execution.js +45 -440
  350. package/dist/schedule-execution.js.map +1 -1
  351. package/dist/schedule-trigger-context.d.ts +18 -0
  352. package/dist/schedule-trigger-context.d.ts.map +1 -0
  353. package/dist/schedule-trigger-context.js +276 -0
  354. package/dist/schedule-trigger-context.js.map +1 -0
  355. package/dist/scheduler.d.ts +1 -14
  356. package/dist/scheduler.d.ts.map +1 -1
  357. package/dist/scheduler.js +1 -37
  358. package/dist/scheduler.js.map +1 -1
  359. package/dist/security.d.ts +0 -4
  360. package/dist/security.d.ts.map +1 -1
  361. package/dist/security.js +0 -22
  362. package/dist/security.js.map +1 -1
  363. package/dist/self-improvement.d.ts +5 -21
  364. package/dist/self-improvement.d.ts.map +1 -1
  365. package/dist/self-improvement.js +10 -40
  366. package/dist/self-improvement.js.map +1 -1
  367. package/dist/source-loader.d.ts +0 -3
  368. package/dist/source-loader.d.ts.map +1 -1
  369. package/dist/source-loader.js +1 -10
  370. package/dist/source-loader.js.map +1 -1
  371. package/dist/state/conversation-state.d.ts +117 -0
  372. package/dist/state/conversation-state.d.ts.map +1 -0
  373. package/dist/state/conversation-state.js +2 -0
  374. package/dist/state/conversation-state.js.map +1 -0
  375. package/dist/state/run-state.d.ts +129 -0
  376. package/dist/state/run-state.d.ts.map +1 -0
  377. package/dist/state/run-state.js +3 -0
  378. package/dist/state/run-state.js.map +1 -0
  379. package/dist/state/sandbox-memory-state.d.ts +159 -0
  380. package/dist/state/sandbox-memory-state.d.ts.map +1 -0
  381. package/dist/state/sandbox-memory-state.js +2 -0
  382. package/dist/state/sandbox-memory-state.js.map +1 -0
  383. package/dist/state/store-contracts.d.ts +329 -0
  384. package/dist/state/store-contracts.d.ts.map +1 -0
  385. package/dist/state/store-contracts.js +26 -0
  386. package/dist/state/store-contracts.js.map +1 -0
  387. package/dist/state/usage-state.d.ts +111 -0
  388. package/dist/state/usage-state.d.ts.map +1 -0
  389. package/dist/state/usage-state.js +2 -0
  390. package/dist/state/usage-state.js.map +1 -0
  391. package/dist/state/workspace-state.d.ts +126 -0
  392. package/dist/state/workspace-state.d.ts.map +1 -0
  393. package/dist/state/workspace-state.js +16 -0
  394. package/dist/state/workspace-state.js.map +1 -0
  395. package/dist/state-stores.d.ts +3 -15
  396. package/dist/state-stores.d.ts.map +1 -1
  397. package/dist/state-stores.js +36 -82
  398. package/dist/state-stores.js.map +1 -1
  399. package/dist/state.d.ts +7 -1075
  400. package/dist/state.d.ts.map +1 -1
  401. package/dist/state.js +7 -88
  402. package/dist/state.js.map +1 -1
  403. package/dist/storage.d.ts +4 -64
  404. package/dist/storage.d.ts.map +1 -1
  405. package/dist/storage.js +5 -408
  406. package/dist/storage.js.map +1 -1
  407. package/dist/subagent-execution.d.ts +1 -2
  408. package/dist/subagent-execution.d.ts.map +1 -1
  409. package/dist/subagent-execution.js +2 -26
  410. package/dist/subagent-execution.js.map +1 -1
  411. package/dist/subagent-handoff.d.ts +13 -0
  412. package/dist/subagent-handoff.d.ts.map +1 -1
  413. package/dist/subagent-handoff.js +74 -9
  414. package/dist/subagent-handoff.js.map +1 -1
  415. package/dist/tool-apis.d.ts +2 -2
  416. package/dist/tool-apis.d.ts.map +1 -1
  417. package/dist/tool-apis.js +26 -14
  418. package/dist/tool-apis.js.map +1 -1
  419. package/dist/tool-execution-host.d.ts +122 -0
  420. package/dist/tool-execution-host.d.ts.map +1 -0
  421. package/dist/tool-execution-host.js +2 -0
  422. package/dist/tool-execution-host.js.map +1 -0
  423. package/dist/tool-execution.d.ts +5 -141
  424. package/dist/tool-execution.d.ts.map +1 -1
  425. package/dist/tool-execution.js +6 -395
  426. package/dist/tool-execution.js.map +1 -1
  427. package/dist/usage-reconciliation-support.d.ts +20 -0
  428. package/dist/usage-reconciliation-support.d.ts.map +1 -0
  429. package/dist/usage-reconciliation-support.js +95 -0
  430. package/dist/usage-reconciliation-support.js.map +1 -0
  431. package/dist/usage-reconciliation.d.ts +14 -35
  432. package/dist/usage-reconciliation.d.ts.map +1 -1
  433. package/dist/usage-reconciliation.js +17 -394
  434. package/dist/usage-reconciliation.js.map +1 -1
  435. package/dist/workspace-paths.d.ts +3 -0
  436. package/dist/workspace-paths.d.ts.map +1 -0
  437. package/dist/workspace-paths.js +13 -0
  438. package/dist/workspace-paths.js.map +1 -0
  439. package/dist/workspace-service.d.ts +0 -1
  440. package/dist/workspace-service.d.ts.map +1 -1
  441. package/dist/workspace-service.js +1 -4
  442. package/dist/workspace-service.js.map +1 -1
  443. package/package.json +3 -3
  444. package/dist/run-timeline.d.ts +0 -11
  445. package/dist/run-timeline.d.ts.map +0 -1
  446. package/dist/run-timeline.js +0 -2
  447. package/dist/run-timeline.js.map +0 -1
  448. package/dist/trusted-attachments.d.ts +0 -20
  449. package/dist/trusted-attachments.d.ts.map +0 -1
  450. package/dist/trusted-attachments.js +0 -276
  451. package/dist/trusted-attachments.js.map +0 -1
@@ -1,15 +1,17 @@
1
- import { isTriggerHandlerDefinition, normalizeRoutineRunRecord, normalizeTriggerPrepareResult, triggerPrepareContext } from "./channel-http-util.js";
1
+ import { normalizeTriggerPrepareResult, triggerPrepareContext } from "./channel-http-util.js";
2
2
  import { RunCapacityError } from "./concurrency.js";
3
- import { dueTimeForSchedule, dynamicScheduleMessage, stringValue, timestamp } from "./runtime-util.js";
4
- import { buildDefaultContextBundle } from "./sandbox-fs.js";
3
+ import { dueTimeForSchedule, timestamp } from "./runtime-util.js";
5
4
  import { isJsonObject, safeJson } from "./json-util.js";
6
5
  import { failRun } from "./run-outcome.js";
7
6
  import { loadDefaultOutboundRoute } from "./default-outbound-route.js";
8
7
  import { isRuntimeSettingsStore } from "./state.js";
9
- import { memoryBodyText, memoryDocumentSummary, positiveLimit } from "./storage.js";
10
- import { defaultUserPrincipal, initiatorFromRun, principalFromRun } from "./principals.js";
11
- import { audienceFromMetadata, audienceFromRun, normalizeAgentAudience } from "./audience.js";
8
+ import { defaultUserPrincipal } from "./principals.js";
9
+ import { normalizeAgentAudience } from "./audience.js";
12
10
  import { matchingEventAutomations } from "./automation-event-match.js";
11
+ import { surfaceForPath } from "./agent-surface.js";
12
+ import { createTriggerHandlerContext, loadTriggerHandler, resolvedScheduleAudience, trustedScheduleAudience } from "./schedule-trigger-context.js";
13
+ import { runDueDynamicSchedules } from "./dynamic-schedule-execution.js";
14
+ export { normalizeScheduleTriggerDefinitionImpl } from "./schedule-trigger-context.js";
13
15
  export async function registerManifestSchedulesImpl(host) {
14
16
  const records = [];
15
17
  for (const schedule of manifestScheduleRegistrations(host)) {
@@ -20,14 +22,13 @@ export async function registerManifestSchedulesImpl(host) {
20
22
  ...(schedule.timezone ? { timezone: schedule.timezone } : {}),
21
23
  metadata: {
22
24
  agentRevision: host.manifest.agentRevision,
23
- message: schedule.message ?? compiledSchedule(host, schedule.schedule)?.message ?? null,
24
- trigger: schedule.trigger ? safeJson(schedule.trigger) : null
25
+ message: schedule.message ?? compiledSchedule(host, schedule.schedule)?.message ?? null
25
26
  }
26
27
  }));
27
28
  }
28
29
  return records;
29
30
  }
30
- export async function runDueSchedulesImpl(host, options = {}) {
31
+ export async function runDueAutomationsImpl(host, options = {}) {
31
32
  host.boot();
32
33
  if (!(await host.agentEnabled()))
33
34
  return [];
@@ -61,7 +62,7 @@ export async function runDueSchedulesImpl(host, options = {}) {
61
62
  // tick without burning the key (the next sweep retries). Triggered
62
63
  // schedules use an existingRun and bypass admission (enter()).
63
64
  let admission;
64
- if (!schedule.trigger && !schedule.lifecycle) {
65
+ if (!schedule.lifecycle) {
65
66
  const admitted = host.admitRunOrReject();
66
67
  if (admitted instanceof RunCapacityError) {
67
68
  results.push({ schedule: schedule.schedule, dueAt: dueAtIso, idempotencyKey, status: "skipped", error: "run capacity saturated" });
@@ -104,7 +105,7 @@ export async function runDueSchedulesImpl(host, options = {}) {
104
105
  results.push({ schedule: schedule.schedule, dueAt: dueAtIso, idempotencyKey, status: "failed", error: message });
105
106
  }
106
107
  }
107
- results.push(...(await runDueDynamicSchedules(host, now)));
108
+ results.push(...(await runDueDynamicSchedules(host, now, (schedule) => runScheduleExecution(host, schedule))));
108
109
  return results;
109
110
  }
110
111
  export async function dispatchAutomationEventImpl(host, event) {
@@ -213,6 +214,7 @@ function eventAutomationExecution(host, automation, event, idempotencyKey) {
213
214
  channel: "automation",
214
215
  ...(automation.lifecycle ? { lifecycle: automation.lifecycle } : {}),
215
216
  ...(automation.target ? { target: automation.target } : {}),
217
+ ...(automation.surface ? { surface: automation.surface } : {}),
216
218
  automationEvent: event,
217
219
  metadata: {
218
220
  automation: automation.automation,
@@ -249,9 +251,9 @@ async function manifestScheduleExecution(host, schedule, dueAtIso, idempotencyKe
249
251
  idempotencyKey,
250
252
  message: scheduleMessage(host, schedule.schedule),
251
253
  channel: "schedule",
252
- ...(schedule.trigger ? { trigger: schedule.trigger } : {}),
253
254
  ...(schedule.lifecycle ? { lifecycle: schedule.lifecycle } : {}),
254
255
  ...(schedule.target ? { target: schedule.target } : {}),
256
+ ...(schedule.surface ? { surface: schedule.surface } : {}),
255
257
  metadata: {
256
258
  ...compiledMetadata,
257
259
  schedule: schedule.schedule,
@@ -260,13 +262,16 @@ async function manifestScheduleExecution(host, schedule, dueAtIso, idempotencyKe
260
262
  },
261
263
  definition: safeJson(compiled ?? schedule)
262
264
  };
263
- const channel = host.manifest.agent.defaultOutboundChannel?.trim();
265
+ if (compiledMetadata.delivery === "silent")
266
+ return execution;
267
+ const surface = surfaceForPath(host.manifest, schedule.surface);
268
+ const channel = surface.defaultOutboundChannel?.trim();
264
269
  if (!channel)
265
270
  return execution;
266
271
  if (!isRuntimeSettingsStore(host.state)) {
267
272
  throw new Error(`Default outbound channel "${channel}" requires durable runtime settings.`);
268
273
  }
269
- const saved = await loadDefaultOutboundRoute(host.state, host.skillScope(), channel);
274
+ const saved = await loadDefaultOutboundRoute(host.state, host.skillScope(surface.path), channel);
270
275
  if (!saved) {
271
276
  throw new Error(`Default outbound channel "${channel}" has no saved route. Send the agent a message on that channel first.`);
272
277
  }
@@ -341,6 +346,8 @@ function scheduleRunOptions(host, schedule, message, metadata, overrides = {}) {
341
346
  options.tenantId = schedule.tenantId;
342
347
  if (schedule.delivery)
343
348
  options.delivery = schedule.delivery;
349
+ if (schedule.surface)
350
+ options.agentSurface = schedule.surface;
344
351
  if (schedule.conversationId) {
345
352
  options.turn = {
346
353
  eventId: schedule.idempotencyKey,
@@ -379,6 +386,7 @@ async function runTriggeredSchedule(host, schedule) {
379
386
  status: "created",
380
387
  input: {
381
388
  message: schedule.message,
389
+ agentSurface: schedule.surface ?? "root",
382
390
  channel: schedule.channel,
383
391
  eventId: schedule.idempotencyKey,
384
392
  conversationId: schedule.conversationId ?? null,
@@ -589,395 +597,6 @@ async function runTriggeredSchedule(host, schedule) {
589
597
  ...(finalizeResult.error ? { error: finalizeResult.error } : {})
590
598
  };
591
599
  }
592
- function resolvedScheduleAudience(host, schedule) {
593
- if (schedule.audience)
594
- return schedule.audience;
595
- if (host.manifest.agent.audienceIsolation !== true)
596
- return trustedScheduleAudience(schedule);
597
- if (schedule.conversationId)
598
- return { private: false, conversationId: schedule.conversationId };
599
- if (schedule.principal)
600
- return { private: true, principal: schedule.principal };
601
- return { private: true };
602
- }
603
- /** Without audienceIsolation, schedule fallbacks are trusted like every other run. */
604
- function trustedScheduleAudience(schedule) {
605
- return {
606
- private: true,
607
- ...(schedule.principal ? { principal: schedule.principal } : {}),
608
- ...(schedule.conversationId ? { conversationId: schedule.conversationId } : {})
609
- };
610
- }
611
- async function loadTriggerHandler(host, handler) {
612
- const module = await host.sourceLoader.load(handler.source);
613
- const candidates = [module.default, module[handler.name], ...Object.values(module)];
614
- const definition = candidates.find(isTriggerHandlerDefinition);
615
- if (!definition)
616
- throw new Error(`Trigger handler ${handler.name} did not export a trigger handler definition.`);
617
- return definition;
618
- }
619
- export function normalizeScheduleTriggerDefinitionImpl(host, value) {
620
- if (!isJsonObject(value))
621
- throw new Error("Schedule trigger must be an object.");
622
- const handler = stringValue(value.handler);
623
- if (!handler)
624
- throw new Error("Schedule trigger requires handler.");
625
- if (!automationLifecycleSources(host).some((candidate) => candidate.name === handler)) {
626
- throw new Error(`Unknown trigger handler: ${handler}`);
627
- }
628
- const trigger = { handler };
629
- if (value.target !== undefined && value.target !== null) {
630
- trigger.target = normalizeTriggerTarget(value.target);
631
- }
632
- if (value.metadata !== undefined) {
633
- if (!isJsonObject(value.metadata))
634
- throw new Error("Schedule trigger metadata must be an object.");
635
- trigger.metadata = value.metadata;
636
- }
637
- return trigger;
638
- }
639
- function normalizeTriggerTarget(value) {
640
- if (!isJsonObject(value))
641
- throw new Error("Schedule trigger target must be an object.");
642
- const type = stringValue(value.type);
643
- if (type === "skill") {
644
- const name = stringValue(value.name);
645
- if (!name)
646
- throw new Error("Skill trigger targets require name.");
647
- return { type, name, ...(isJsonObject(value.metadata) ? { metadata: value.metadata } : {}) };
648
- }
649
- if (type === "agent") {
650
- if (value.model !== undefined) {
651
- throw new Error("Automation targets cannot select a model; use useModel() in agent.ts setup().");
652
- }
653
- const name = stringValue(value.name);
654
- const target = { type };
655
- if (name)
656
- target.name = name;
657
- if (isJsonObject(value.metadata))
658
- target.metadata = value.metadata;
659
- return target;
660
- }
661
- if (type === "playbook") {
662
- const name = stringValue(value.name);
663
- if (!name)
664
- throw new Error("Playbook trigger targets require name.");
665
- return { type, name, ...(isJsonObject(value.metadata) ? { metadata: value.metadata } : {}) };
666
- }
667
- throw new Error(`Unsupported schedule trigger target type: ${type || "missing"}`);
668
- }
669
- function createTriggerHandlerContext(host, run, schedule, trigger, prepare) {
670
- const sandboxHandle = host.createSandboxHandle(() => run, () => undefined, () => buildDefaultContextBundle(host.manifest, {
671
- message: typeof run.input.message === "string" ? run.input.message : schedule.message,
672
- channel: schedule.channel
673
- }));
674
- return {
675
- runId: run.id,
676
- agentRevision: host.manifest.agentRevision,
677
- ...(principalFromRun(run) ? { principal: principalFromRun(run) } : {}),
678
- ...(initiatorFromRun(run) ? { initiator: initiatorFromRun(run) } : {}),
679
- audience: audienceFromRun(run),
680
- trigger,
681
- state: createTriggerStateApi(host, run),
682
- memory: host.createMemoryToolApi(run),
683
- resources: createTriggerResourceApi(host, run, sandboxHandle),
684
- blob: {
685
- put: async (key, value, contentTypeOrOptions) => host.blob.put(key, value, contentTypeOrOptions),
686
- get: async (key) => host.blob.get(key)
687
- },
688
- schedule: {
689
- definition: schedule.definition,
690
- run: {
691
- scheduleId: schedule.resultSchedule,
692
- runId: run.id,
693
- runAt: trigger.dueAt ?? trigger.event?.occurredAt ?? schedule.dueAtIso,
694
- idempotencyKey: trigger.idempotencyKey
695
- }
696
- },
697
- env: host.env,
698
- fetch: host.fetch,
699
- prepare,
700
- emit: async (eventType, data = {}) => {
701
- await host.state.appendEvent(run.id, eventType, data);
702
- },
703
- idempotencyKey: (scope) => `${trigger.idempotencyKey}:${scope}`,
704
- step: (key, fn, options) => host.durableStep(run.id, key, fn, options)
705
- };
706
- }
707
- function createTriggerStateApi(host, run) {
708
- const runtime = host;
709
- return {
710
- async upsertRoutineRun(input) {
711
- const current = await runtime.state.getRun(run.id) ?? run;
712
- const metadata = isJsonObject(current.input.metadata) ? current.input.metadata : {};
713
- const existing = isJsonObject(metadata.routineRun) ? metadata.routineRun : {};
714
- const record = normalizeRoutineRunRecord({
715
- existing,
716
- runId: run.id,
717
- kind: input.kind,
718
- triggerKey: input.triggerKey,
719
- status: input.status ?? (stringValue(existing.status) || current.status),
720
- metadata: input.metadata ?? (isJsonObject(existing.metadata) ? existing.metadata : {})
721
- });
722
- await runtime.state.updateRun(run.id, {
723
- input: {
724
- ...current.input,
725
- metadata: {
726
- ...metadata,
727
- routineRun: safeJson(record)
728
- }
729
- }
730
- });
731
- await runtime.state.appendEvent(run.id, "routine.run_upserted", safeJson(record));
732
- return record;
733
- },
734
- async completeRoutineRun(input) {
735
- const current = await runtime.state.getRun(run.id) ?? run;
736
- const metadata = isJsonObject(current.input.metadata) ? current.input.metadata : {};
737
- const existing = isJsonObject(metadata.routineRun) ? metadata.routineRun : {};
738
- const completeInput = {
739
- existing,
740
- runId: input.runId || run.id,
741
- kind: stringValue(existing.kind) || "routine",
742
- triggerKey: stringValue(existing.triggerKey) || "",
743
- status: input.status,
744
- metadata: input.metadata ?? (isJsonObject(existing.metadata) ? existing.metadata : {})
745
- };
746
- if (input.summary)
747
- completeInput.summary = input.summary;
748
- const record = normalizeRoutineRunRecord(completeInput);
749
- await runtime.state.updateRun(run.id, {
750
- input: {
751
- ...current.input,
752
- metadata: {
753
- ...metadata,
754
- routineRun: safeJson(record)
755
- }
756
- }
757
- });
758
- await runtime.state.appendEvent(run.id, "routine.run_completed", safeJson(record));
759
- return record;
760
- }
761
- };
762
- }
763
- function createTriggerResourceApi(host, run, sandboxHandle) {
764
- const base = host.createResourceToolApi(run, sandboxHandle);
765
- return {
766
- ...base,
767
- collect: async (input = {}) => collectTriggerResources(host, run, input)
768
- };
769
- }
770
- async function collectTriggerResources(host, run, input = {}) {
771
- const requested = new Set(input.sources ?? ["memory", "history", "connections"]);
772
- const limit = positiveLimit(input.limit, 50);
773
- const resources = [];
774
- const sections = [];
775
- if (requested.has("memory")) {
776
- const documents = await host.memoryStore.list(host.memoryScopeForRun(run), { limit });
777
- resources.push(...documents.map((document) => memoryDocumentSummary(document)));
778
- if (documents.length > 0) {
779
- sections.push([
780
- "# Memory",
781
- ...documents.map((document) => [
782
- `## ${document.path}`,
783
- memoryBodyText(document)
784
- ].join("\n"))
785
- ].join("\n\n"));
786
- }
787
- }
788
- if (requested.has("history")) {
789
- const conversationId = typeof run.input.conversationId === "string" ? run.input.conversationId : undefined;
790
- const messages = conversationId ? await host.state.listRecentMessages(conversationId, limit) : [];
791
- resources.push(...messages.map((message) => ({
792
- kind: "history",
793
- role: message.role,
794
- createdAt: message.createdAt,
795
- runId: message.runId ?? null
796
- })));
797
- if (messages.length > 0) {
798
- sections.push([
799
- "# History",
800
- ...messages.map((message) => {
801
- const text = typeof message.content.text === "string" ? message.content.text : JSON.stringify(message.content);
802
- return `- ${message.role}: ${text}`;
803
- })
804
- ].join("\n"));
805
- }
806
- }
807
- if (requested.has("connections")) {
808
- const connections = host.mergedConnections().slice(0, limit);
809
- resources.push(...connections.map((connection) => ({
810
- kind: "connection",
811
- name: connection.name,
812
- protocol: connection.protocol,
813
- provider: connection.provider,
814
- required: connection.required
815
- })));
816
- if (connections.length > 0) {
817
- sections.push([
818
- "# Connections",
819
- ...connections.map((connection) => `- ${connection.name} (${connection.protocol}, ${connection.provider})`)
820
- ].join("\n"));
821
- }
822
- }
823
- if (requested.has("skills")) {
824
- const skills = (await host.skillStore.list(host.skillScope())).filter((skill) => !skill.pending && !skill.archived).slice(0, limit);
825
- resources.push(...skills.map((skill) => ({
826
- kind: "skill",
827
- name: skill.name,
828
- origin: skill.origin,
829
- updatedAt: skill.updatedAt
830
- })));
831
- if (skills.length > 0) {
832
- sections.push([
833
- "# Skills",
834
- ...skills.map((skill) => `- ${skill.name} (${skill.origin})`)
835
- ].join("\n"));
836
- }
837
- }
838
- await host.state.appendEvent(run.id, "trigger.resources_collected", {
839
- sources: [...requested],
840
- count: resources.length,
841
- since: input.since ?? null
842
- });
843
- return {
844
- markdown: sections.join("\n\n").trim(),
845
- resources
846
- };
847
- }
848
- /**
849
- * Dispatch application-managed dynamic schedules: atomically lease due rows
850
- * and start one durable run per row. At-least-once; tasks should be idempotent.
851
- */
852
- async function runDueDynamicSchedules(host, now) {
853
- if (!host.schedulesConfig.dynamic)
854
- return [];
855
- const results = [];
856
- const due = await host.scheduleStore.claimDue({ now, limit: 25, leaseForMs: 5 * 60_000 });
857
- for (const job of due) {
858
- const dueAtIso = job.nextRunAt;
859
- const idempotencyKey = `dynamic:${job.id}:${dueAtIso}`;
860
- const leaseToken = job.leaseToken ?? "";
861
- try {
862
- // assembly_line_schedule_runs rows reference assembly_line_schedules; dynamic jobs
863
- // live in the schedule store, so upsert a parent row before recording runs.
864
- await host.state.registerSchedule({
865
- id: `dynamic:${job.id}`,
866
- name: `dynamic:${job.id}`,
867
- cron: job.cron ?? (job.everyMinutes ? `@every ${job.everyMinutes}m` : `@at ${dueAtIso}`),
868
- ...(job.timezone ? { timezone: job.timezone } : {}),
869
- metadata: { source: "dynamic", scope: job.scope }
870
- });
871
- const schedule = dynamicScheduleExecution(host, job, dueAtIso, idempotencyKey);
872
- const result = await runScheduleExecution(host, schedule);
873
- await host.scheduleStore.complete(job.id, leaseToken, { ranAt: dueAtIso });
874
- if (result.runId) {
875
- await host.state.appendEvent(result.runId, "schedule.dynamic_dispatched", {
876
- dynamicScheduleId: job.id,
877
- dueAt: dueAtIso,
878
- trigger: job.trigger ? safeJson(job.trigger) : null
879
- });
880
- }
881
- results.push(result);
882
- }
883
- catch (error) {
884
- const message = error instanceof Error ? error.message : String(error);
885
- try {
886
- await host.state.recordScheduleRun({
887
- scheduleId: `dynamic:${job.id}`,
888
- runAt: dueAtIso,
889
- idempotencyKey,
890
- status: "failed"
891
- });
892
- }
893
- catch (recordError) {
894
- host.logger.warn("dynamic schedule failure bookkeeping failed", {
895
- dynamicScheduleId: job.id,
896
- error: recordError instanceof Error ? recordError.message : String(recordError)
897
- });
898
- }
899
- // Escalating backoff on the failure streak (5min base, 2x, capped 6h);
900
- // the store disables the schedule atomically once the streak hits the
901
- // cap so a poison schedule cannot burn a model run every cycle forever.
902
- const failureStreak = (job.consecutiveFailures ?? 0) + 1;
903
- const retryDelayMs = Math.min(300_000 * 2 ** (failureStreak - 1), 6 * 3_600_000);
904
- const disabled = failureStreak >= host.scheduleMaxConsecutiveFailures;
905
- await host.scheduleStore.release(job.id, leaseToken, new Date(now.getTime() + retryDelayMs), {
906
- maxConsecutiveFailures: host.scheduleMaxConsecutiveFailures
907
- });
908
- if (disabled) {
909
- host.logger.warn("dynamic schedule disabled after consecutive failures", {
910
- dynamicScheduleId: job.id,
911
- scope: job.scope,
912
- consecutiveFailures: failureStreak,
913
- error: message
914
- });
915
- if (isRuntimeSettingsStore(host.state)) {
916
- await host.state.appendRuntimeControlEvent(job.scope, "schedule.disabled_after_failures", {
917
- dynamicScheduleId: job.id,
918
- consecutiveFailures: failureStreak,
919
- error: message
920
- }).catch(() => undefined);
921
- }
922
- }
923
- results.push({ schedule: `dynamic:${job.id}`, dueAt: dueAtIso, idempotencyKey, status: "failed", error: message });
924
- }
925
- }
926
- return results;
927
- }
928
- function dynamicScheduleExecution(host, job, dueAtIso, idempotencyKey) {
929
- const target = isJsonObject(job.target) ? job.target : {};
930
- const targetConversation = typeof target.conversationId === "string" ? target.conversationId : undefined;
931
- const targetProject = typeof target.projectId === "string" ? target.projectId : undefined;
932
- const conversationId = job.conversationId ?? targetConversation;
933
- const projectId = job.projectId ?? targetProject;
934
- const delivery = isJsonObject(job.target) ? job.target : undefined;
935
- const principal = job.principal ?? defaultUserPrincipal(job.userId, job.channel);
936
- const initiator = job.initiator ?? principal;
937
- const audience = audienceFromMetadata(job.metadata)
938
- ?? (host.manifest.agent.audienceIsolation !== true
939
- ? trustedScheduleAudience({ ...(principal ? { principal } : {}), ...(conversationId ? { conversationId } : {}) })
940
- : principal
941
- ? { private: true, principal }
942
- : conversationId
943
- ? { private: false, conversationId }
944
- : { private: true });
945
- const message = dynamicScheduleMessage(job);
946
- const trigger = job.trigger ? normalizeScheduleTriggerDefinitionImpl(host, job.trigger) : undefined;
947
- const metadata = {
948
- ...(job.metadata ?? {}),
949
- dynamicScheduleId: job.id,
950
- scope: job.scope,
951
- source: "dynamic",
952
- schedule: `dynamic:${job.id}`,
953
- dueAt: dueAtIso,
954
- idempotencyKey
955
- };
956
- if (job.target)
957
- metadata.target = safeJson(job.target);
958
- const definition = { ...job };
959
- if (trigger)
960
- definition.trigger = trigger;
961
- return {
962
- source: "dynamic",
963
- scheduleId: job.id,
964
- resultSchedule: `dynamic:${job.id}`,
965
- dueAtIso,
966
- idempotencyKey,
967
- message,
968
- channel: job.channel,
969
- ...(trigger ? { trigger } : {}),
970
- metadata,
971
- definition: safeJson(definition),
972
- ...(job.userId ? { userId: job.userId } : {}),
973
- ...(principal ? { principal } : {}),
974
- ...(initiator ? { initiator } : {}),
975
- audience,
976
- ...(conversationId ? { conversationId } : {}),
977
- ...(projectId ? { projectId } : {}),
978
- ...(delivery ? { delivery } : {})
979
- };
980
- }
981
600
  export async function startSchedulerPollingLoopImpl(host) {
982
601
  if (!hasScheduledWork(host))
983
602
  return undefined;
@@ -988,7 +607,7 @@ export async function startSchedulerPollingLoopImpl(host) {
988
607
  return [];
989
608
  inFlight = true;
990
609
  try {
991
- return await runDueSchedulesImpl(host, { now: host.now(), lookbackMs: host.schedulerTickMs });
610
+ return await runDueAutomationsImpl(host, { now: host.now(), lookbackMs: host.schedulerTickMs });
992
611
  }
993
612
  catch (error) {
994
613
  // The interval invokes tick as a floating promise; a throw here would
@@ -1020,8 +639,7 @@ function hasScheduledWork(host) {
1020
639
  return manifestScheduleRegistrations(host).length > 0;
1021
640
  }
1022
641
  function compiledSchedule(host, name) {
1023
- return host.manifest.automations?.find((automation) => automation.name === name)
1024
- ?? host.manifest.schedules.find((schedule) => schedule.name === name);
642
+ return host.manifest.automations.find((automation) => automation.name === name);
1025
643
  }
1026
644
  function scheduleMessage(host, name) {
1027
645
  const registration = manifestScheduleRegistrations(host).find((schedule) => schedule.schedule === name);
@@ -1030,52 +648,39 @@ function scheduleMessage(host, name) {
1030
648
  }
1031
649
  function resolveAutomationLifecycle(host, schedule) {
1032
650
  const lifecycle = schedule.lifecycle;
1033
- if (lifecycle?.kind === "inline") {
1034
- const compiled = host.manifest.automationLifecycles?.find((candidate) => candidate.automation === schedule.resultSchedule) ?? host.manifest.automations?.find((candidate) => candidate.name === schedule.resultSchedule);
1035
- return compiled ? { name: schedule.resultSchedule, source: compiled.source } : undefined;
1036
- }
1037
651
  const handlerName = lifecycle?.handler ?? schedule.trigger?.handler;
1038
652
  return handlerName
1039
653
  ? automationLifecycleSources(host).find((candidate) => candidate.name === handlerName)
1040
654
  : undefined;
1041
655
  }
1042
656
  function automationLifecycleSources(host) {
1043
- const inline = (host.manifest.automationLifecycles ?? []).map((lifecycle) => ({
1044
- name: lifecycle.automation,
1045
- source: lifecycle.source
1046
- }));
1047
- const legacy = [
1048
- ...(host.manifest.automationHandlers ?? []),
1049
- ...(host.manifest.triggerHandlers ?? [])
1050
- ];
1051
657
  const sources = new Map();
1052
- for (const candidate of [...inline, ...legacy]) {
658
+ for (const candidate of host.manifest.automationHandlers) {
1053
659
  if (!sources.has(candidate.name))
1054
660
  sources.set(candidate.name, candidate);
1055
661
  }
1056
662
  return [...sources.values()];
1057
663
  }
1058
664
  function manifestScheduleRegistrations(host) {
1059
- if (Array.isArray(host.manifest.automationRegistrations)) {
1060
- return host.manifest.automationRegistrations.flatMap((automation) => {
1061
- if (automation.trigger.type !== "schedule")
1062
- return [];
1063
- const registration = {
1064
- schedule: automation.automation,
1065
- cron: automation.trigger.cron,
1066
- idempotencyKey: automation.idempotencyKey
1067
- };
1068
- if (automation.trigger.timezone)
1069
- registration.timezone = automation.trigger.timezone;
1070
- if (automation.message)
1071
- registration.message = automation.message;
1072
- if (automation.target)
1073
- registration.target = automation.target;
1074
- if (automation.lifecycle)
1075
- registration.lifecycle = automation.lifecycle;
1076
- return [registration];
1077
- });
1078
- }
1079
- return host.manifest.scheduleRegistrations ?? [];
665
+ return host.manifest.automationRegistrations.flatMap((automation) => {
666
+ if (automation.trigger.type !== "schedule")
667
+ return [];
668
+ const registration = {
669
+ schedule: automation.automation,
670
+ cron: automation.trigger.cron,
671
+ idempotencyKey: automation.idempotencyKey
672
+ };
673
+ if (automation.trigger.timezone)
674
+ registration.timezone = automation.trigger.timezone;
675
+ if (automation.message)
676
+ registration.message = automation.message;
677
+ if (automation.target)
678
+ registration.target = automation.target;
679
+ if (automation.lifecycle)
680
+ registration.lifecycle = automation.lifecycle;
681
+ if (automation.surface)
682
+ registration.surface = automation.surface;
683
+ return [registration];
684
+ });
1080
685
  }
1081
686
  //# sourceMappingURL=schedule-execution.js.map