@desplega.ai/agent-swarm 1.112.0 → 1.114.0

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 (276) hide show
  1. package/README.md +2 -2
  2. package/dist/{actions-eckb4g8r.js → actions-bm8vdxys.js} +7 -8
  3. package/dist/{app-b05sgm02.js → app-bhwdxmvp.js} +5 -5
  4. package/dist/{assistant-7255sbyw.js → assistant-15mp2apr.js} +18 -17
  5. package/dist/{boot-reembed-y1bt3ttn.js → boot-reembed-awr2179r.js} +6 -6
  6. package/dist/{boot-reembed-yv7awg4y.js → boot-reembed-b9sbk87z.js} +5 -5
  7. package/dist/{boot-scrub-logs-ddyaeqar.js → boot-scrub-logs-c1zsaw9m.js} +4 -4
  8. package/dist/{claude-adapter-mma9a1yr.js → claude-adapter-2k45y7p7.js} +2 -2
  9. package/dist/{claude-managed-adapter-pv2nbqy4.js → claude-managed-adapter-kysmkz89.js} +2 -2
  10. package/dist/cli-0kgcv878.js +344 -0
  11. package/dist/cli-0pygq9r1.js +429 -0
  12. package/dist/{cli-7xkwgkrs.js → cli-113wmegp.js} +90 -3
  13. package/dist/{cli-7ga43spr.js → cli-1yjrbg1f.js} +1 -1
  14. package/dist/{cli-56s4ehzw.js → cli-2t4e4ayk.js} +1 -1
  15. package/dist/{cli-0c3n0eba.js → cli-312v3c41.js} +1 -1
  16. package/dist/{cli-ceewqajw.js → cli-46b6kc7f.js} +5 -5
  17. package/dist/cli-49j095n9.js +393 -0
  18. package/dist/{cli-h9jx5mag.js → cli-5afkmcfj.js} +10 -7
  19. package/dist/{cli-76d1vtvq.js → cli-5ktc9fd4.js} +1 -1
  20. package/dist/cli-7rgh0w0k.js +262 -0
  21. package/dist/{cli-9cy6nc5m.js → cli-8fjwym53.js} +1 -1
  22. package/dist/{cli-tg0f2wmz.js → cli-a6tzw6vq.js} +175 -28
  23. package/dist/{cli-q21d49ac.js → cli-bw80ck94.js} +1 -1
  24. package/dist/{cli-709t753c.js → cli-byjcad11.js} +2 -2
  25. package/dist/{cli-15598a4k.js → cli-e2xbxmhd.js} +1808 -302
  26. package/dist/{cli-6wscj9z0.js → cli-e7306swv.js} +14 -14
  27. package/dist/{cli-8f0dwca2.js → cli-f5pzfvwb.js} +6 -5
  28. package/dist/{cli-s9pj3c7z.js → cli-f9n2jg31.js} +2 -2
  29. package/dist/{cli-dcfyyh3t.js → cli-ftyf58xj.js} +2 -2
  30. package/dist/{cli-hm27prrc.js → cli-hq39e630.js} +5 -5
  31. package/dist/{cli-a5e8n5hg.js → cli-hvg05qwm.js} +1 -1
  32. package/dist/cli-jkhwmmgg.js +136 -0
  33. package/dist/{cli-951w7c79.js → cli-jzwtn8rm.js} +136 -21
  34. package/dist/{cli-rp8pca98.js → cli-k6h2zkw3.js} +1 -1
  35. package/dist/{cli-3r5y6ayj.js → cli-pnfyyp6h.js} +1240 -335
  36. package/dist/{cli-94vzr3nq.js → cli-q1z5d5ss.js} +13 -7
  37. package/dist/{cli-pt7c7qxz.js → cli-q4e2x252.js} +3 -3
  38. package/dist/{cli-tch0ypp6.js → cli-r3mtrrzp.js} +16 -16
  39. package/dist/{cli-ywez6yps.js → cli-sq7f72d6.js} +1 -1
  40. package/dist/{cli-r1btc895.js → cli-w3nq88yc.js} +2 -2
  41. package/dist/{cli-30d2ct3k.js → cli-w4wk3kx6.js} +12 -7
  42. package/dist/{cli-anrj584m.js → cli-xz9aq0rf.js} +1 -1
  43. package/dist/{cli-tp7e60s3.js → cli-zmmp2r79.js} +22 -9
  44. package/dist/cli.js +35 -17
  45. package/dist/{codex-adapter-5cmy858w.js → codex-adapter-4z8m9mb5.js} +9 -9
  46. package/dist/{codex-session-runner-46q8mrba.js → codex-session-runner-rbct46dg.js} +9 -9
  47. package/dist/{commands-14g7taf4.js → commands-zk4d6esf.js} +4 -4
  48. package/dist/{db-3tge4jrn.js → db-stn16jp2.js} +4 -4
  49. package/dist/{handlers-sy64egg6.js → handlers-gshprvpf.js} +16 -30
  50. package/dist/{hook-rnkzw8vp.js → hook-amzx9tap.js} +7 -7
  51. package/dist/{http-xx9xptcs.js → http-6g0hfzax.js} +1977 -786
  52. package/dist/{index-wz1ea15p.js → index-2dgfj9av.js} +3 -3
  53. package/dist/{index-ha8e9xn2.js → index-df8fmphk.js} +55 -17
  54. package/dist/{index-zfx5p959.js → index-f03rnnrs.js} +13 -10
  55. package/dist/{index-3wr6v2mm.js → index-jbm7qcqk.js} +12 -9
  56. package/dist/{index-ykvs43z4.js → index-t2snazez.js} +4 -4
  57. package/dist/{index-brma88d4.js → index-ty42rxw9.js} +14 -11
  58. package/dist/{keepalive-rbz05zad.js → keepalive-pm6g2wpw.js} +7 -6
  59. package/dist/{lead-s790v7r0.js → lead-h79fzpzw.js} +33 -29
  60. package/dist/{maintenance-420rmadb.js → maintenance-433zndy1.js} +6 -6
  61. package/dist/{mistral-conversations-26yrnbf1.js → mistral-conversations-7gqnz2wt.js} +7 -7
  62. package/dist/oauth-refresh-sweep-mjsbmsk2.js +114 -0
  63. package/dist/{onboard-jgqamqnw.js → onboard-vdr9hc3f.js} +2 -2
  64. package/dist/{otel-zjd9zaxs.js → otel-g299k41b.js} +2 -2
  65. package/dist/{otel-impl-ch3n3783.js → otel-impl-yswd0fty.js} +1 -1
  66. package/dist/{pi-mono-adapter-kxjxpfgy.js → pi-mono-adapter-vbrvg1p8.js} +16 -108
  67. package/dist/{pricing-refresh-rmtrby6h.js → pricing-refresh-2kk2ap9b.js} +6 -6
  68. package/dist/rbac-roles-2wgh9b5t.js +276 -0
  69. package/dist/rbac-roles-xdc5208b.js +28 -0
  70. package/dist/{seed-pricing-1szjzfj1.js → seed-pricing-m9h69d2t.js} +5 -5
  71. package/dist/{setup-8jfzkyzv.js → setup-eynkvafa.js} +2 -2
  72. package/dist/{worker-40vq0pm8.js → worker-136q8dc2.js} +33 -29
  73. package/openapi.json +1634 -20
  74. package/package.json +6 -5
  75. package/src/agentmail/handlers.ts +16 -6
  76. package/src/agentmail/templates.ts +25 -5
  77. package/src/be/audit-user.ts +28 -4
  78. package/src/be/db-queries/oauth.ts +42 -0
  79. package/src/be/db.ts +104 -11
  80. package/src/be/identity.ts +79 -0
  81. package/src/be/mcp-proxy.ts +132 -0
  82. package/src/be/memory/providers/sqlite-store.ts +5 -1
  83. package/src/be/migrations/108_rbac_permission_audit.sql +26 -0
  84. package/src/be/migrations/109_rbac_roles.sql +79 -0
  85. package/src/be/migrations/111_oauth_credential_bindings.sql +6 -0
  86. package/src/be/migrations/112_script_connections_graphql.sql +96 -0
  87. package/src/be/oauth-credential-bindings.ts +35 -0
  88. package/src/be/oauth-refresh-sweep.ts +159 -0
  89. package/src/be/rbac-audit.ts +246 -0
  90. package/src/be/rbac-roles.ts +417 -0
  91. package/src/be/script-connections.ts +456 -37
  92. package/src/be/script-credential-broker.ts +29 -3
  93. package/src/be/scripts/typecheck.ts +40 -7
  94. package/src/be/users.ts +24 -0
  95. package/src/cli.tsx +17 -0
  96. package/src/github/handlers.ts +10 -9
  97. package/src/github/templates.ts +45 -9
  98. package/src/gitlab/handlers.ts +20 -8
  99. package/src/gitlab/templates.ts +18 -6
  100. package/src/http/all-routes.ts +61 -0
  101. package/src/http/approval-requests.ts +12 -0
  102. package/src/http/config.ts +98 -9
  103. package/src/http/core.ts +30 -3
  104. package/src/http/favorites.ts +5 -0
  105. package/src/http/fs.ts +27 -7
  106. package/src/http/index.ts +50 -0
  107. package/src/http/kv.ts +21 -4
  108. package/src/http/mcp-oauth.ts +2 -0
  109. package/src/http/mcp-servers.ts +6 -3
  110. package/src/http/oauth-generic.ts +105 -0
  111. package/src/http/poll.ts +13 -1
  112. package/src/http/route-def.ts +9 -0
  113. package/src/http/schedules.ts +56 -22
  114. package/src/http/script-connection-proxy.ts +116 -0
  115. package/src/http/script-connections.ts +1657 -0
  116. package/src/http/scripts.ts +54 -7
  117. package/src/http/tasks.ts +16 -14
  118. package/src/http/workflows.ts +13 -2
  119. package/src/http/x.ts +6 -2
  120. package/src/integrations/kapso/inbound.ts +23 -6
  121. package/src/jira/sync.ts +111 -17
  122. package/src/jira/templates.ts +10 -2
  123. package/src/mcp-client/http-client.ts +194 -0
  124. package/src/oauth/app-validation.ts +16 -0
  125. package/src/oauth/ensure-token.ts +69 -14
  126. package/src/oauth/mcp-wrapper.ts +15 -0
  127. package/src/oauth/wrapper.ts +48 -20
  128. package/src/prompts/base-prompt.ts +7 -6
  129. package/src/prompts/session-templates.ts +38 -11
  130. package/src/providers/pi-mono-mcp-client.ts +2 -133
  131. package/src/rbac/admission.ts +44 -0
  132. package/src/rbac/can.ts +44 -0
  133. package/src/rbac/index.ts +15 -0
  134. package/src/rbac/legacy-policy.ts +188 -0
  135. package/src/rbac/permissions.ts +194 -0
  136. package/src/rbac/types.ts +45 -0
  137. package/src/scheduler/scheduler.ts +9 -1
  138. package/src/scripts-runtime/api-client.ts +70 -14
  139. package/src/scripts-runtime/api-types.ts +38 -6
  140. package/src/scripts-runtime/credential-broker/default-bindings.ts +1 -0
  141. package/src/scripts-runtime/credential-broker/types.ts +8 -0
  142. package/src/scripts-runtime/ctx.ts +11 -1
  143. package/src/scripts-runtime/eval-harness.ts +5 -1
  144. package/src/scripts-runtime/executors/types.ts +2 -1
  145. package/src/scripts-runtime/loader.ts +3 -1
  146. package/src/scripts-runtime/mcp-client.ts +87 -0
  147. package/src/scripts-runtime/sdk-allowlist.ts +2 -0
  148. package/src/scripts-runtime/swarm-sdk.ts +81 -0
  149. package/src/scripts-runtime/types/stdlib.d.ts +24 -2
  150. package/src/scripts-runtime/types/swarm-sdk.d.ts +26 -2
  151. package/src/server.ts +14 -0
  152. package/src/slack/assistant.ts +14 -6
  153. package/src/slack/enrich.ts +17 -0
  154. package/src/slack/handlers.ts +8 -22
  155. package/src/slack/thread-buffer.ts +6 -3
  156. package/src/stdio.ts +43 -0
  157. package/src/tests/agentmail-handlers.test.ts +32 -3
  158. package/src/tests/approval-requests.test.ts +61 -0
  159. package/src/tests/audit-user.test.ts +47 -1
  160. package/src/tests/base-prompt.test.ts +7 -4
  161. package/src/tests/credential-broker.test.ts +5 -2
  162. package/src/tests/delete-page-tool.test.ts +197 -0
  163. package/src/tests/github-handlers.test.ts +28 -2
  164. package/src/tests/gitlab-handlers.test.ts +125 -0
  165. package/src/tests/harness-provider-resolution.test.ts +5 -0
  166. package/src/tests/http-api-integration.test.ts +8 -1
  167. package/src/tests/identity.test.ts +117 -0
  168. package/src/tests/jira-sync.test.ts +99 -1
  169. package/src/tests/kapso-inbound.test.ts +7 -0
  170. package/src/tests/mcp-tools-user.test.ts +60 -6
  171. package/src/tests/oauth-credential-bindings.test.ts +490 -0
  172. package/src/tests/oauth-refresh-sweep.test.ts +160 -0
  173. package/src/tests/prompt-template-remaining.test.ts +2 -2
  174. package/src/tests/prompt-template-session.test.ts +21 -8
  175. package/src/tests/rbac-admission-e2e.test.ts +241 -0
  176. package/src/tests/rbac-admission.test.ts +433 -0
  177. package/src/tests/rbac-audit.test.ts +345 -0
  178. package/src/tests/rbac-charact-http.test.ts +272 -0
  179. package/src/tests/rbac-charact-misc-tools.test.ts +428 -0
  180. package/src/tests/rbac-charact-skills.test.ts +492 -0
  181. package/src/tests/rbac-charact-slack.test.ts +283 -0
  182. package/src/tests/rbac-e2e-helpers.ts +308 -0
  183. package/src/tests/rbac-engine.test.ts +474 -0
  184. package/src/tests/rbac-lifecycle-e2e.test.ts +262 -0
  185. package/src/tests/rbac-roles.test.ts +326 -0
  186. package/src/tests/rbac-wire-e2e.test.ts +574 -0
  187. package/src/tests/schedule-http-triage-tools.test.ts +121 -0
  188. package/src/tests/schedule-target-type.test.ts +50 -0
  189. package/src/tests/scheduled-tasks.test.ts +74 -0
  190. package/src/tests/script-connections-http.test.ts +1158 -0
  191. package/src/tests/script-connections-mcp.test.ts +894 -0
  192. package/src/tests/script-connections.test.ts +727 -5
  193. package/src/tests/scripts-external-api.test.ts +49 -1
  194. package/src/tests/scripts-http.test.ts +56 -7
  195. package/src/tests/scripts-runtime-secret-egress.test.ts +1 -0
  196. package/src/tests/scripts-runtime.test.ts +104 -0
  197. package/src/tests/slack-identity-resolution.test.ts +37 -3
  198. package/src/tests/slack-thread-buffer.test.ts +28 -0
  199. package/src/tests/swarm-config-reserved-keys.test.ts +17 -0
  200. package/src/tests/tool-annotations.test.ts +2 -0
  201. package/src/tests/update-schedule-mcp-tool.test.ts +57 -0
  202. package/src/tests/user-token-rest-auth.test.ts +30 -1
  203. package/src/tests/workflow-http-v2.test.ts +80 -0
  204. package/src/tests/workflow-swarm-script.test.ts +44 -0
  205. package/src/tests/workflow-triggers-v2.test.ts +300 -1
  206. package/src/tools/cancel-task.ts +13 -3
  207. package/src/tools/context-diff.ts +12 -1
  208. package/src/tools/context-history.ts +12 -1
  209. package/src/tools/credential-bindings/tool.ts +289 -19
  210. package/src/tools/delete-channel.ts +12 -1
  211. package/src/tools/delete-page.ts +145 -0
  212. package/src/tools/get-task-details.ts +1 -1
  213. package/src/tools/inject-learning.ts +12 -1
  214. package/src/tools/kv/kv-delete.ts +3 -18
  215. package/src/tools/kv/kv-incr.ts +3 -18
  216. package/src/tools/kv/kv-set.ts +3 -20
  217. package/src/tools/kv/kv-write-auth.ts +40 -0
  218. package/src/tools/manage-user.ts +12 -1
  219. package/src/tools/mcp-servers/mcp-server-create.ts +12 -1
  220. package/src/tools/mcp-servers/mcp-server-delete.ts +19 -5
  221. package/src/tools/mcp-servers/mcp-server-install.ts +12 -1
  222. package/src/tools/mcp-servers/mcp-server-uninstall.ts +12 -1
  223. package/src/tools/mcp-servers/mcp-server-update.ts +12 -1
  224. package/src/tools/memory-delete.ts +12 -4
  225. package/src/tools/register-kapso-number.ts +23 -2
  226. package/src/tools/request-human-input.ts +2 -0
  227. package/src/tools/resolve-user.ts +77 -27
  228. package/src/tools/schedules/create-schedule.ts +4 -3
  229. package/src/tools/schedules/index.ts +1 -0
  230. package/src/tools/schedules/list-schedules.ts +36 -2
  231. package/src/tools/schedules/patch-schedule.ts +405 -0
  232. package/src/tools/schedules/update-schedule.ts +2 -2
  233. package/src/tools/script-connections/tool.ts +287 -32
  234. package/src/tools/skills/skill-create.ts +12 -1
  235. package/src/tools/skills/skill-delete.ts +12 -1
  236. package/src/tools/skills/skill-install-remote.ts +12 -1
  237. package/src/tools/skills/skill-install.ts +12 -1
  238. package/src/tools/skills/skill-uninstall.ts +12 -1
  239. package/src/tools/skills/skill-update.ts +25 -2
  240. package/src/tools/slack-delete.ts +8 -1
  241. package/src/tools/slack-post.ts +8 -1
  242. package/src/tools/slack-read.ts +8 -1
  243. package/src/tools/slack-start-thread.ts +8 -1
  244. package/src/tools/slack-update.ts +8 -1
  245. package/src/tools/slack-upload-file.ts +8 -1
  246. package/src/tools/swarm-config/delete-config.ts +28 -1
  247. package/src/tools/swarm-config/get-config.ts +32 -5
  248. package/src/tools/swarm-config/list-config.ts +31 -5
  249. package/src/tools/swarm-config/set-config.ts +38 -1
  250. package/src/tools/task-action.ts +1 -1
  251. package/src/tools/task-tool-ctx.ts +19 -3
  252. package/src/tools/templates.ts +5 -1
  253. package/src/tools/tool-config.ts +4 -2
  254. package/src/tools/update-profile.ts +8 -1
  255. package/src/tools/workflows/create-workflow.ts +8 -1
  256. package/src/tools/workflows/list-workflows.ts +14 -2
  257. package/src/tools/workflows/update-workflow.ts +11 -2
  258. package/src/types.ts +63 -6
  259. package/src/utils/scoped-resource.ts +25 -0
  260. package/src/workflows/executors/human-in-the-loop.ts +1 -0
  261. package/src/workflows/executors/swarm-script.ts +7 -1
  262. package/src/workflows/triggers.ts +146 -18
  263. package/templates/skills/swarm-scripts/SKILL.md +4 -9
  264. package/templates/skills/swarm-scripts/content.md +45 -9
  265. package/dist/cli-52tbq17n.js +0 -771
  266. package/dist/cli-9p0qhead.js +0 -43
  267. package/dist/{anthropic-messages-8nc6r2dw.js → anthropic-messages-kq3pjhbp.js} +6 -6
  268. package/dist/{azure-openai-responses-6yfzw3qw.js → azure-openai-responses-gm1ejtmn.js} +7 -7
  269. package/dist/{cli-vbraamxr.js → cli-6b4wwmm8.js} +9 -9
  270. package/dist/{cli-2fc97xm5.js → cli-ggy8c7tk.js} +3 -3
  271. package/dist/{cli-2r7s8jhp.js → cli-sznberje.js} +3 -3
  272. package/dist/{google-generative-ai-vfq6ymz9.js → google-generative-ai-hyrra2jm.js} +3 -3
  273. package/dist/{google-vertex-mj5y5rfj.js → google-vertex-8bs2pzgn.js} +3 -3
  274. package/dist/{openai-codex-responses-8h6kvfv8.js → openai-codex-responses-3nkvje79.js} +4 -4
  275. package/dist/{openai-completions-x6kjnqjd.js → openai-completions-0asftkwg.js} +11 -11
  276. package/dist/{openai-responses-7jwyz3ds.js → openai-responses-pmatek45.js} +10 -10
@@ -4,8 +4,9 @@ import {
4
4
  } from "./cli-z2zcxes1.js";
5
5
  import {
6
6
  init_zod
7
- } from "./cli-q21d49ac.js";
7
+ } from "./cli-bw80ck94.js";
8
8
  import {
9
+ ZodIssueCode,
9
10
  _enum,
10
11
  _null,
11
12
  array,
@@ -21,11 +22,11 @@ import {
21
22
  union,
22
23
  unknown,
23
24
  uuid
24
- } from "./cli-anrj584m.js";
25
+ } from "./cli-xz9aq0rf.js";
25
26
  import {
26
27
  init_package,
27
28
  package_default
28
- } from "./cli-8f0dwca2.js";
29
+ } from "./cli-f5pzfvwb.js";
29
30
  import {
30
31
  init_secret_scrubber,
31
32
  scrubSecrets
@@ -469,7 +470,7 @@ function resolveTaskModelSelection(opts) {
469
470
  function isTerminalTaskStatus(status) {
470
471
  return TERMINAL_TASK_STATUSES.includes(status);
471
472
  }
472
- var ModelTierSchema, MODEL_TIERS, ReasoningEffortSchema, LEGACY_MODEL_TO_TIER, DEFAULT_MODEL_TIER_MAP, AgentTaskStatusSchema, TERMINAL_TASK_STATUSES, InboxMessageStatusSchema, InboxMessageSchema, AgentTaskSourceSchema, ProviderNameSchema, FollowUpConfigSchema, AgentTaskSchema, TaskAttachmentKindSchema, attachmentCommonFields, AttachmentInputSchema, TaskAttachmentSchema, UserSchema, IdentityEventTypeSchema, InboxItemTypeSchema, InboxItemStatusSchema, InboxItemStateSchema, FavoriteItemTypeSchema, UserFavoriteSchema, TaskTemplateKindSchema, TaskTemplateSchema, AgentStatusSchema, AgentSchema, AgentCredStatusLiveTestSchema, AgentLatestModelSchema, AgentBedrockStatusSchema, AgentCredStatusSchema, AgentWithTasksSchema, ChangeSourceSchema, VersionableFieldSchema, ContextVersionSchema, ChannelTypeSchema, ChannelSchema, ChannelMessageSchema, ServiceStatusSchema, ServiceSchema, AgentLogEventTypeSchema, ResumeReasonSchema, AgentLogSchema, SessionLogSchema, SessionCostSourceSchema, SessionCostSchema, EventCategorySchema, EventStatusSchema, EventSourceSchema, EventNameSchema, SwarmEventSchema, ScheduledTaskTargetTypeSchema, ScheduledTaskSchema, SwarmConfigScopeSchema, SwarmConfigSchema, RepoGuidelinesSchema, RepoHooksSchema, SwarmRepoSchema, AgentMemoryScopeSchema, AgentMemorySourceSchema, AgentMemorySchema, ActiveSessionSchema, RetryPolicySchema, ExecutorMetaSchema, ValidationResultSchema, StepValidationConfigSchema, SwarmScriptNodeConfigSchema, WorkflowNodeSchema, WorkflowEdgeSchema, WorkflowDefinitionSchema, WorkflowNodePatchSchema, WorkflowPatchSchema, TriggerConfigSchema, CooldownConfigSchema, InputValueSchema, WorkflowTemplateSchema, WorkflowSnapshotSchema, WorkflowSchema, WorkflowVersionSchema, PageContentTypeSchema, PageAuthModeSchema, PageSnapshotSchema, PageSchema, PageVersionSchema, MetricParamSchema, MetricVariableTypeSchema, MetricFormatSchema, MetricVisualizationSchema, MetricQuerySchema, MetricVariableSchema, MetricVizConfigSchema, MetricWidgetSchema, MetricDefinitionSchema, MetricSnapshotSchema, MetricSchema, MetricVersionSchema, WorkflowRunStatusSchema, WorkflowRunSchema, ScriptRunStatusSchema, TERMINAL_SCRIPT_RUN_STATUSES, ScriptRunKindSchema, ScriptRunSchema, ScriptRunListItemSchema, ScriptRunJournalEntrySchema, WorkflowRunStepStatusSchema, WorkflowRunStepSchema, WaitModeSchema, WaitStateStatusSchema, WaitStateRowSchema, PromptTemplateScopeSchema, PromptTemplateStateSchema, PromptTemplateSchema, PromptTemplateHistorySchema, ScriptScopeSchema, ScriptFsModeSchema, ScriptRecordSchema, ScriptVersionRecordSchema, ScriptApiAuthModeSchema, ScriptApiRecordSchema, SkillTypeSchema, SkillScopeSchema, SkillSchema, AgentSkillSchema, SkillWithInstallInfoSchema, SkillFileSchema, McpServerTransportSchema, McpServerScopeSchema, McpAuthMethodSchema, McpServerSchema, AgentMcpServerSchema, McpServerWithInstallInfoSchema, ContextSnapshotEventTypeSchema, ContextFormulaSchema, ContextSnapshotSchema, BudgetScopeSchema, BudgetSchema, PricingProviderSchema, PricingTokenClassSchema, PricingRowSchema, BudgetRefusalCauseSchema, BudgetRefusalNotificationSchema, BudgetRefusedTriggerSchema, KvValueTypeSchema, KV_NAME_REGEX, KvNamespaceSchema, KvKeySchema, KvEntrySchema;
473
+ var ModelTierSchema, MODEL_TIERS, ReasoningEffortSchema, LEGACY_MODEL_TO_TIER, DEFAULT_MODEL_TIER_MAP, AgentTaskStatusSchema, TERMINAL_TASK_STATUSES, InboxMessageStatusSchema, InboxMessageSchema, AgentTaskSourceSchema, ProviderNameSchema, FollowUpConfigSchema, AgentTaskSchema, TaskAttachmentKindSchema, attachmentCommonFields, AttachmentInputSchema, TaskAttachmentSchema, UserSchema, IdentityEventTypeSchema, InboxItemTypeSchema, InboxItemStatusSchema, InboxItemStateSchema, FavoriteItemTypeSchema, UserFavoriteSchema, TaskTemplateKindSchema, TaskTemplateSchema, AgentStatusSchema, AgentSchema, AgentCredStatusLiveTestSchema, AgentLatestModelSchema, AgentBedrockStatusSchema, AgentCredStatusSchema, AgentWithTasksSchema, ChangeSourceSchema, VersionableFieldSchema, ContextVersionSchema, ChannelTypeSchema, ChannelSchema, ChannelMessageSchema, ServiceStatusSchema, ServiceSchema, AgentLogEventTypeSchema, ResumeReasonSchema, AgentLogSchema, SessionLogSchema, SessionCostSourceSchema, SessionCostSchema, EventCategorySchema, EventStatusSchema, EventSourceSchema, EventNameSchema, SwarmEventSchema, ScheduledTaskTargetTypeSchema, ScheduledTaskSchema, SwarmConfigScopeSchema, SwarmConfigSchema, RepoGuidelinesSchema, RepoHooksSchema, SwarmRepoSchema, AgentMemoryScopeSchema, AgentMemorySourceSchema, AgentMemorySchema, ActiveSessionSchema, RetryPolicySchema, ExecutorMetaSchema, ValidationResultSchema, StepValidationConfigSchema, SwarmScriptNodeConfigSchema, WorkflowNodeSchema, WorkflowEdgeSchema, WorkflowDefinitionSchema, WorkflowNodePatchSchema, WorkflowPatchSchema, WebhookVerificationSchema, TriggerConfigSchema, CooldownConfigSchema, InputValueSchema, WorkflowTemplateSchema, WorkflowSnapshotSchema, WorkflowSchema, WorkflowVersionSchema, PageContentTypeSchema, PageAuthModeSchema, PageSnapshotSchema, PageSchema, PageVersionSchema, MetricParamSchema, MetricVariableTypeSchema, MetricFormatSchema, MetricVisualizationSchema, MetricQuerySchema, MetricVariableSchema, MetricVizConfigSchema, MetricWidgetSchema, MetricDefinitionSchema, MetricSnapshotSchema, MetricSchema, MetricVersionSchema, WorkflowRunStatusSchema, WorkflowRunSchema, ScriptRunStatusSchema, TERMINAL_SCRIPT_RUN_STATUSES, ScriptRunKindSchema, ScriptRunSchema, ScriptRunListItemSchema, ScriptRunJournalEntrySchema, WorkflowRunStepStatusSchema, WorkflowRunStepSchema, WaitModeSchema, WaitStateStatusSchema, WaitStateRowSchema, PromptTemplateScopeSchema, PromptTemplateStateSchema, PromptTemplateSchema, PromptTemplateHistorySchema, ScriptScopeSchema, ScriptFsModeSchema, ScriptRecordSchema, ScriptVersionRecordSchema, ScriptApiAuthModeSchema, ScriptApiRecordSchema, SkillTypeSchema, SkillScopeSchema, SkillSchema, AgentSkillSchema, SkillWithInstallInfoSchema, SkillFileSchema, McpServerTransportSchema, McpServerScopeSchema, McpAuthMethodSchema, McpServerSchema, AgentMcpServerSchema, McpServerWithInstallInfoSchema, ContextSnapshotEventTypeSchema, ContextFormulaSchema, ContextSnapshotSchema, BudgetScopeSchema, BudgetSchema, PricingProviderSchema, PricingTokenClassSchema, PricingRowSchema, BudgetRefusalCauseSchema, BudgetRefusalNotificationSchema, BudgetRefusedTriggerSchema, KvValueTypeSchema, KV_NAME_REGEX, KvNamespaceSchema, KvKeySchema, KvEntrySchema;
473
474
  var init_types = __esm(() => {
474
475
  init_zod();
475
476
  ModelTierSchema = _enum(["smol", "regular", "smart", "ultra"]);
@@ -1224,17 +1225,43 @@ var init_types = __esm(() => {
1224
1225
  onNodeFailure: _enum(["fail", "continue"]).optional().describe("Update the definition-level onNodeFailure behavior"),
1225
1226
  triggerSchema: record(string(), unknown()).optional().nullable().describe("Optional JSON-Schema describing the expected trigger payload shape. " + "Pass an object to set/replace; pass null to clear; omit to leave unchanged. " + "Validator subset: type, required, properties, enum, const, items. " + "Other JSON-Schema keywords are silently ignored.")
1226
1227
  });
1228
+ WebhookVerificationSchema = discriminatedUnion("format", [
1229
+ object({
1230
+ format: literal("hmac-sha256"),
1231
+ header: string().default("X-Hub-Signature-256").describe("Header containing HMAC-SHA256 over the raw request body. Accepts sha256=<hex> or bare hex.")
1232
+ }),
1233
+ object({
1234
+ format: literal("timestamped-hmac-sha256"),
1235
+ header: string().min(1).describe("Header containing comma-separated timestamp/signature pairs such as t=<timestamp>,v1=<hex>."),
1236
+ timestampKey: string().default("t").describe("Timestamp field key in the signature header"),
1237
+ signatureKey: string().default("v1").describe("Signature field key in the signature header; multiple entries are allowed"),
1238
+ toleranceSeconds: number().int().positive().default(300).describe("Maximum allowed clock skew, in seconds, for replay protection")
1239
+ }),
1240
+ object({
1241
+ format: literal("token-equality"),
1242
+ header: string().min(1).describe("Header containing the shared token to compare")
1243
+ })
1244
+ ]);
1227
1245
  TriggerConfigSchema = discriminatedUnion("type", [
1228
1246
  object({
1229
1247
  type: literal("webhook"),
1230
1248
  hmacSecret: string().optional(),
1231
- hmacHeader: string().default("X-Hub-Signature-256")
1249
+ hmacHeader: string().default("X-Hub-Signature-256").describe("Legacy HMAC header for webhook verification. Prefer verification.header for new workflows."),
1250
+ verification: WebhookVerificationSchema.optional().describe("Optional webhook verification format. Omit to keep legacy HMAC-SHA256 behavior with fallback header scanning.")
1232
1251
  }),
1233
1252
  object({
1234
1253
  type: literal("schedule"),
1235
1254
  scheduleId: string().uuid()
1236
1255
  })
1237
- ]);
1256
+ ]).superRefine((trigger, ctx) => {
1257
+ if (trigger.type === "webhook" && trigger.verification && !trigger.hmacSecret) {
1258
+ ctx.addIssue({
1259
+ code: ZodIssueCode.custom,
1260
+ message: "hmacSecret is required when verification is configured",
1261
+ path: ["hmacSecret"]
1262
+ });
1263
+ }
1264
+ });
1238
1265
  CooldownConfigSchema = object({
1239
1266
  hours: number().min(0).optional(),
1240
1267
  minutes: number().min(0).optional(),
@@ -2504,13 +2531,9 @@ Use this to debug issues and propose improvements to your own infrastructure.
2504
2531
  category: "system"
2505
2532
  });
2506
2533
  registerTemplate({
2507
- eventType: "system.agent.context_mode",
2534
+ eventType: "system.agent.script_rubric",
2508
2535
  header: "",
2509
2536
  defaultBody: `
2510
- ### Context Window Management
2511
-
2512
- You have access to the \`context-mode\` MCP tools (\`batch_execute\`, \`execute\`, \`execute_file\`, \`search\`, \`fetch_and_index\`, \`index\`) which compress tool output to save context window space. For data-heavy operations (web fetches, large file reads, CLI output processing), prefer these over raw Bash/WebFetch to avoid flooding your context window with raw output.
2513
-
2514
2537
  ### Agent Scripts — for bulk, repetitive, or data-heavy work
2515
2538
 
2516
2539
  Use **scripts** (\`script-upsert\` + \`script-run\`) when a task involves repetitive SDK calls, large data processing, or deterministic multi-step pipelines. Scripts run out-of-process and return only their final result.
@@ -2519,19 +2542,48 @@ Use **scripts** (\`script-upsert\` + \`script-run\`) when a task involves repeti
2519
2542
 
2520
2543
  | Situation | Preferred approach |
2521
2544
  |---|---|
2522
- | 1–10 SDK calls, result fits in context | Direct tool call |
2545
+ | 1–10 SDK calls, result fits in context | Direct tool call. Do not script below the ~10-call threshold. |
2523
2546
  | 10+ items, bulk/fan-out SDK ops | **Script** (\`script-run\` with inline source or named) |
2524
2547
  | Heavy data (fetch + parse + transform) | **Script** or \`ctx_*\` (context-mode) |
2525
2548
  | Single expensive web fetch | \`ctx_fetch_and_index\` (context-mode) |
2526
2549
  | Multi-agent fan-out, parallel work, deterministic pipeline | **Workflow** |
2527
2550
  | One-off bash/TS with no reuse needed | \`code-mode run\` (Bash) |
2528
2551
 
2552
+ **Script persistence guardrail:** use a named script only when the logic will be invoked ≥2 times by you, another agent, or a workflow. For genuine one-offs, use inline \`script-run\` so the catalog does not accumulate scratch-* auto-saves.
2553
+
2554
+ **Worked example:** workflow triage that previously cost ~26 underlying calls can return one ~4.3k-token result in ~13s, a ~90-95% context reduction.
2555
+
2529
2556
  The 5 script tools (\`script-search\`, \`script-run\`, \`script-upsert\`, \`script-delete\`, \`script-query-types\`) are deferred tools. Call ToolSearch to load \`script-upsert\`, \`script-run\`, and \`script-query-types\` before using them.
2530
2557
 
2531
2558
  **Key gotchas:**
2532
2559
  - \`agentId\` IS propagated to scripts via the \`X-Agent-ID\` header.
2533
2560
  - \`taskId\` is NOT propagated to scripts — there is no ambient task context. Pass \`taskId\` explicitly via \`args\` if the script needs to call \`ctx.swarm.task_storeProgress\`.
2534
2561
  - Use \`script-query-types\` to inspect the live \`swarm-sdk.d.ts\` before authoring a complex script.
2562
+ - Script connections: lead-registered \`script_connections\` entries expose typed clients in scripts — \`ctx.api.<slug>.<operationId>(...)\` (OpenAPI), \`ctx.api.<slug>.graphql(query, vars)\` (GraphQL), and \`ctx.mcp.<slug>.<toolName>(args)\` (MCP, proxied server-side). Introspect with \`Object.keys(ctx.api ?? {})\` / \`Object.keys(ctx.mcp ?? {})\`.
2563
+ - Connection credentials (config secrets or OAuth tokens with auto-refresh) are injected at egress, so scripts calling an external API should prefer a connection over hand-written \`fetch\` + \`[REDACTED:<KEY>]\` headers — and never paste raw secrets.
2564
+ - Registration is lead-only (\`script-connections\` + \`credential-bindings\` tools); workers should hand the lead the spec to register: slug, baseUrl or spec URL, allowedHosts, and auth (config key vs OAuth provider).
2565
+ `,
2566
+ variables: [],
2567
+ category: "system"
2568
+ });
2569
+ registerTemplate({
2570
+ eventType: "system.agent.context_mode",
2571
+ header: "",
2572
+ defaultBody: `
2573
+ ### Context Window Management
2574
+
2575
+ You have access to the \`context-mode\` MCP tools (\`batch_execute\`, \`execute\`, \`execute_file\`, \`search\`, \`fetch_and_index\`, \`index\`) which compress tool output to save context window space. For data-heavy operations (web fetches, large file reads, CLI output processing), prefer these over raw Bash/WebFetch to avoid flooding your context window with raw output.
2576
+
2577
+ {{@template[system.agent.script_rubric]}}
2578
+
2579
+ ### Scheduling — Pick the Right targetType
2580
+
2581
+ When creating a schedule, match \`targetType\` to the work being fired:
2582
+ - Use \`targetType: "workflow"\` with \`workflowId\` when the schedule's only job is to start a workflow.
2583
+ - Use \`targetType: "script"\` with \`scriptName\` and optional \`scriptArgs\` when it only needs to run a catalog script.
2584
+ - Use \`targetType: "agent-task"\` only when a reasoning agent genuinely needs to be in the loop for judgment, open-ended work, or tool orchestration that is not already captured by a workflow or script.
2585
+
2586
+ Do not create an \`agent-task\` schedule whose \`taskTemplate\` just says to trigger a workflow or script. Workflow/script targets dispatch directly; agent-task fields such as \`targetAgentId\`, \`model\`, \`taskTemplate\`, \`priority\`, and \`tags\` do not drive those direct runs, and workflow cooldowns still gate workflow targets.
2535
2587
  `,
2536
2588
  variables: [],
2537
2589
  category: "system"
@@ -2779,6 +2831,8 @@ Honor this requester profile in tone, depth, and format where it doesn't conflic
2779
2831
  {{@template[system.agent.worker]}}
2780
2832
  {{@template[system.agent.filesystem]}}
2781
2833
  {{@template[system.agent.self_awareness]}}
2834
+ {{@template[system.agent.script_rubric]}}
2835
+ {{@template[system.agent.seed_scripts]}}
2782
2836
 
2783
2837
  {{@template[system.agent.system]}}
2784
2838
  {{@template[system.agent.share_urls]}}
@@ -2981,7 +3035,10 @@ A Kapso webhook fired on the swarm's provisioned WhatsApp number. Load the \`kap
2981
3035
  { name: "conversation_id", description: "Kapso conversation id, or 'unknown'" },
2982
3036
  { name: "inbound_wamid", description: "Inbound message WAMID, or 'unknown'" },
2983
3037
  { name: "sender_phone", description: "Sender phone (E.164 no +), or 'unknown'" },
2984
- { name: "contact_name", description: "Contact display name, or 'unknown'" },
3038
+ {
3039
+ name: "contact_name",
3040
+ description: "Sender identity — resolved canonical name (e.g. 'Luis (kapso:15551234567)') or the UNKNOWN sentinel — never the raw WhatsApp profile name"
3041
+ },
2985
3042
  { name: "phone_number_id", description: "Provisioned phone-number id, or 'unknown'" },
2986
3043
  {
2987
3044
  name: "test_note",
@@ -4638,6 +4695,10 @@ function getAllTasks(filters, opts) {
4638
4695
  conditions.push("createdAt >= ?");
4639
4696
  params.push(filters.createdAfter);
4640
4697
  }
4698
+ if (filters?.createdBefore) {
4699
+ conditions.push("createdAt < ?");
4700
+ params.push(filters.createdBefore);
4701
+ }
4641
4702
  if (filters?.requestedByUserId) {
4642
4703
  conditions.push("requestedByUserId = ?");
4643
4704
  params.push(filters.requestedByUserId);
@@ -4648,10 +4709,11 @@ function getAllTasks(filters, opts) {
4648
4709
  const whereClause = conditions.length > 0 ? `WHERE ${conditions.join(" AND ")}` : "";
4649
4710
  const limit = filters?.limit ?? 25;
4650
4711
  const offset = filters?.offset ?? 0;
4712
+ const orderBy = filters?.orderBy === "createdAt" ? "createdAt DESC, rowid DESC" : "lastUpdatedAt DESC, priority DESC";
4651
4713
  const query = `SELECT agent_tasks.*,
4652
4714
  (SELECT SUM(totalCostUsd) FROM session_costs WHERE session_costs.taskId = agent_tasks.id) AS totalCostUsd
4653
4715
  FROM agent_tasks ${whereClause}
4654
- ORDER BY lastUpdatedAt DESC, priority DESC LIMIT ${limit} OFFSET ${offset}`;
4716
+ ORDER BY ${orderBy} LIMIT ${limit} OFFSET ${offset}`;
4655
4717
  const rows = getDb().prepare(query).all(...params);
4656
4718
  const isReady = (task) => {
4657
4719
  if (!task.dependsOn || task.dependsOn.length === 0)
@@ -4728,6 +4790,14 @@ function getTasksCount(filters) {
4728
4790
  conditions.push("createdAt >= ?");
4729
4791
  params.push(filters.createdAfter);
4730
4792
  }
4793
+ if (filters?.createdBefore) {
4794
+ conditions.push("createdAt < ?");
4795
+ params.push(filters.createdBefore);
4796
+ }
4797
+ if (filters?.requestedByUserId) {
4798
+ conditions.push("requestedByUserId = ?");
4799
+ params.push(filters.requestedByUserId);
4800
+ }
4731
4801
  if (!filters?.includeHeartbeat) {
4732
4802
  conditions.push(`(IFNULL(taskType, '') NOT IN ('heartbeat', 'heartbeat-checklist', 'boot-triage') AND tags NOT LIKE '%"heartbeat"%')`);
4733
4803
  }
@@ -6596,6 +6666,15 @@ function getScheduledTasks(filters, opts) {
6596
6666
  query += " AND scriptName = ?";
6597
6667
  params.push(filters.scriptName);
6598
6668
  }
6669
+ if (filters?.consecutiveErrorsMin !== undefined) {
6670
+ query += " AND consecutiveErrors >= ?";
6671
+ params.push(filters.consecutiveErrorsMin);
6672
+ }
6673
+ if (filters?.lastRunStatus === "failed") {
6674
+ query += " AND consecutiveErrors > 0";
6675
+ } else if (filters?.lastRunStatus === "succeeded") {
6676
+ query += " AND lastRunAt IS NOT NULL AND consecutiveErrors = 0";
6677
+ }
6599
6678
  if (filters?.hideCompleted !== false) {
6600
6679
  query += " AND NOT (scheduleType = 'one_time' AND enabled = 0)";
6601
6680
  }
@@ -7257,6 +7336,26 @@ function listWorkflows(filters, opts) {
7257
7336
  query += " AND enabled = ?";
7258
7337
  params.push(filters.enabled ? 1 : 0);
7259
7338
  }
7339
+ if (filters?.lastRunStatus !== undefined) {
7340
+ query += " AND (SELECT status FROM workflow_runs WHERE workflowId = workflows.id ORDER BY startedAt DESC LIMIT 1) = ?";
7341
+ params.push(filters.lastRunStatus);
7342
+ }
7343
+ if (filters?.consecutiveErrorsMin !== undefined) {
7344
+ query += ` AND (
7345
+ SELECT COUNT(*)
7346
+ FROM workflow_runs wr
7347
+ WHERE wr.workflowId = workflows.id
7348
+ AND wr.status = 'failed'
7349
+ AND NOT EXISTS (
7350
+ SELECT 1
7351
+ FROM workflow_runs newer_non_failed
7352
+ WHERE newer_non_failed.workflowId = wr.workflowId
7353
+ AND newer_non_failed.status != 'failed'
7354
+ AND newer_non_failed.startedAt > wr.startedAt
7355
+ )
7356
+ ) >= ?`;
7357
+ params.push(filters.consecutiveErrorsMin);
7358
+ }
7260
7359
  query += " ORDER BY lastUpdatedAt DESC";
7261
7360
  const rows = getDb().prepare(query).all(...params);
7262
7361
  return opts?.slim ? rows.map(rowToWorkflowSummary) : rows.map(rowToWorkflow);
@@ -7682,7 +7781,11 @@ function updatePage(id, data) {
7682
7781
  return row ? rowToPage(row) : null;
7683
7782
  }
7684
7783
  function deletePage(id) {
7685
- const result = getDb().run("DELETE FROM pages WHERE id = ?", [id]);
7784
+ const result = getDb().transaction(() => {
7785
+ getDb().run("DELETE FROM user_favorites WHERE itemType = 'page' AND itemId = ?", [id]);
7786
+ getDb().run("DELETE FROM kv_entries WHERE namespace = ?", [`task:page:${id}`]);
7787
+ return getDb().run("DELETE FROM pages WHERE id = ?", [id]);
7788
+ })();
7686
7789
  return result.changes > 0;
7687
7790
  }
7688
7791
  function incrementPageViewCount(id) {
@@ -8024,6 +8127,7 @@ function rowToApprovalRequest(row) {
8024
8127
  timeoutSeconds: row.timeoutSeconds,
8025
8128
  expiresAt: normalizeDate(row.expiresAt),
8026
8129
  notificationChannels: row.notificationChannels ? JSON.parse(row.notificationChannels) : null,
8130
+ createdBy: row.created_by ?? undefined,
8027
8131
  createdAt: normalizeDateRequired(row.createdAt),
8028
8132
  updatedAt: normalizeDateRequired(row.updatedAt)
8029
8133
  };
@@ -8031,9 +8135,9 @@ function rowToApprovalRequest(row) {
8031
8135
  function createApprovalRequest(data) {
8032
8136
  const now = new Date().toISOString();
8033
8137
  const expiresAt = data.timeoutSeconds ? new Date(Date.now() + data.timeoutSeconds * 1000).toISOString() : null;
8034
- const row = getDb().prepare(`INSERT INTO approval_requests (id, title, questions, workflowRunId, workflowRunStepId, sourceTaskId, approvers, timeoutSeconds, expiresAt, notificationChannels, createdAt, updatedAt)
8035
- VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
8036
- RETURNING *`).get(data.id, data.title, JSON.stringify(data.questions), data.workflowRunId ?? null, data.workflowRunStepId ?? null, data.sourceTaskId ?? null, JSON.stringify(data.approvers), data.timeoutSeconds ?? null, expiresAt, data.notificationChannels ? JSON.stringify(data.notificationChannels) : null, now, now);
8138
+ const row = getDb().prepare(`INSERT INTO approval_requests (id, title, questions, workflowRunId, workflowRunStepId, sourceTaskId, approvers, timeoutSeconds, expiresAt, notificationChannels, created_by, createdAt, updatedAt)
8139
+ VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
8140
+ RETURNING *`).get(data.id, data.title, JSON.stringify(data.questions), data.workflowRunId ?? null, data.workflowRunStepId ?? null, data.sourceTaskId ?? null, JSON.stringify(data.approvers), data.timeoutSeconds ?? null, expiresAt, data.notificationChannels ? JSON.stringify(data.notificationChannels) : null, data.createdBy ?? null, now, now);
8037
8141
  return rowToApprovalRequest(row);
8038
8142
  }
8039
8143
  function getApprovalRequestById(id) {
@@ -8734,8 +8838,19 @@ function updateMcpServer(id, updates) {
8734
8838
  return row ? rowToMcpServer(row) : null;
8735
8839
  }
8736
8840
  function deleteMcpServer(id) {
8737
- const result = getDb().prepare("DELETE FROM mcp_servers WHERE id = ?").run(id);
8738
- return result.changes > 0;
8841
+ const db2 = getDb();
8842
+ const existing = db2.prepare("SELECT id FROM mcp_servers WHERE id = ?").get(id);
8843
+ if (!existing)
8844
+ return { deleted: false, deletedScriptConnectionCount: 0 };
8845
+ const tx = db2.transaction(() => {
8846
+ const deletedConnections = db2.prepare("DELETE FROM script_connections WHERE mcp_server_id = ?").run(id);
8847
+ const deletedServer = db2.prepare("DELETE FROM mcp_servers WHERE id = ?").run(id);
8848
+ return {
8849
+ deleted: deletedServer.changes > 0,
8850
+ deletedScriptConnectionCount: deletedConnections.changes
8851
+ };
8852
+ });
8853
+ return tx();
8739
8854
  }
8740
8855
  function getMcpServerById(id) {
8741
8856
  const row = getDb().prepare("SELECT * FROM mcp_servers WHERE id = ?").get(id);
@@ -10021,4 +10136,4 @@ var init_db = __esm(() => {
10021
10136
  };
10022
10137
  });
10023
10138
 
10024
- export { interpolate, deepInterpolate, init_template, registerTemplate, getTemplateDefinition, getAllTemplateDefinitions, init_registry, configureHttpResolver, resolveTemplate, resolveTemplateAsync, init_resolver, initTelemetry, telemetry, init_telemetry, ModelTierSchema, ReasoningEffortSchema, splitLegacyModelAlias, resolveTaskModelSelection, AgentTaskStatusSchema, isTerminalTaskStatus, AgentTaskSourceSchema, ProviderNameSchema, FollowUpConfigSchema, AgentTaskSchema, AttachmentInputSchema, TaskAttachmentSchema, InboxItemTypeSchema, InboxItemStatusSchema, FavoriteItemTypeSchema, TaskTemplateKindSchema, AgentSchema, AgentLatestModelSchema, AgentCredStatusSchema, ChannelTypeSchema, ChannelSchema, ChannelMessageSchema, ServiceStatusSchema, ServiceSchema, ResumeReasonSchema, AgentLogSchema, EventCategorySchema, EventStatusSchema, EventSourceSchema, EventNameSchema, ScheduledTaskTargetTypeSchema, SwarmConfigScopeSchema, SwarmConfigSchema, RepoGuidelinesSchema, RepoHooksSchema, SwarmRepoSchema, AgentMemoryScopeSchema, AgentMemorySourceSchema, AgentMemorySchema, WorkflowDefinitionSchema, WorkflowNodePatchSchema, WorkflowPatchSchema, TriggerConfigSchema, CooldownConfigSchema, InputValueSchema, PageContentTypeSchema, PageAuthModeSchema, MetricDefinitionSchema, MetricVersionSchema, WorkflowRunStatusSchema, ScriptRunStatusSchema, TERMINAL_SCRIPT_RUN_STATUSES, PromptTemplateScopeSchema, PromptTemplateStateSchema, PromptTemplateSchema, PromptTemplateHistorySchema, ScriptScopeSchema, ScriptFsModeSchema, ScriptApiAuthModeSchema, ContextSnapshotEventTypeSchema, ContextFormulaSchema, BudgetScopeSchema, BudgetSchema, PricingProviderSchema, PricingTokenClassSchema, PricingRowSchema, BudgetRefusalCauseSchema, BudgetRefusalNotificationSchema, KvValueTypeSchema, KvNamespaceSchema, KvKeySchema, KvEntrySchema, init_types, setRequestAuth, getRequestAuth, getCurrentRequestAuth, init_request_auth_context, encryptSecret, decryptSecret, getEncryptionKey, init_crypto, normalizeDateRequired, init_date_utils, init_session_templates, init_templates, init_templates2 as init_templates1, isReservedConfigKey, reservedKeyError, validateConfigValue, init_swarm_config_guard, onTaskStarted, init_task_lifecycle_events, generateDefaultClaudeMd, generateDefaultSoulMd, generateDefaultIdentityMd, generateDefaultToolsMd, init_defaults, isSqliteVecAvailable, initDb, getDb, closeDb, computeContentHash, createContextVersion, getLatestContextVersion, getContextVersion, getContextVersionHistory, agentQueries, updateAgentCredentialState, createAgent, getAgentById, getAllAgents, getLeadAgent, updateAgentStatus, updateAgentMaxTasks, updateAgentProvider, setAgentHarnessProvider, updateAgentCredStatus, listAgentsWithCredStatusByProvider, getAgentHarnessProviders, updateAgentActivity, MAX_EMPTY_POLLS, incrementEmptyPollCount, resetEmptyPollCount, shouldBlockPolling, deleteAgent, getActiveTaskCount, hasCapacity, getRemainingCapacity, updateAgentStatusFromCapacity, taskQueries, createTask, getPendingTaskForAgent, assignUnassignedTaskPending, startTask, getTaskById, markTaskSlackReplySent, setSlackMessageTracking, getChildTasks, hasNonTerminalResumeChild, hasNonTerminalRerouteDecisionChild, updateTaskClaudeSessionId, updateTaskVcs, getTasksByAgentId, getAgentCurrentTask, getTasksByStatus, findTaskByVcs, findTaskByGitHub, getAllTasks, getTasksCount, getTaskStats, getCompletedSlackTasks, getRecentlyFinishedWorkerTasks, markTasksNotified, resetTasksNotified, getInProgressSlackTasks, getInProgressTasksByContextKey, findExistingLinearTrackerContextWork, getLatestTaskByContextKey, getAgentWorkingOnThread, getLatestActiveTaskInThread, getMostRecentTaskInThread, findCompletedTaskInThread, findRecentCancelledTaskInThread, completeTask, failTask, cancelTask, supersedeTask, backfillSupersedeTaskResumeTaskId, pauseTask, resumeTask, getPausedTasksForAgent, getOrphanedInProgressTasksForAgent, resetOrphanedInProgressTasksForAgent, getRecentlyCancelledTasksForAgent, deleteTask, updateTaskProgress, insertTaskAttachment, deleteTaskAttachment, replaceTaskAttachment, getTaskAttachments, getAgentWithTasks, getAllAgentsWithTasks, logQueries, createLogEntry, getLogsByAgentId, getLogsByTaskId, getLogsByTaskIdChronological, getLogsByEventType, getAllLogs, findRecentSimilarTasks, createTaskExtended, claimTask, releaseTask, acceptTask, rejectTask, moveTaskToBacklog, moveTaskFromBacklog, releaseStaleReviewingTasks, getOfferedTasksForAgent, claimOfferedTask, getUnassignedTasksCount, getUnassignedTaskIds, checkDependencies, getDependentTasks, cascadeFailDependents, updateAgentProfile, updateAgentName, createChannel, getMessageById, getChannelById, getChannelByName, getAllChannels, deleteChannel, postMessage, getChannelMessages, updateReadState, getLastReadAt, getUnreadMessages, getMentionsForAgent, getInboxSummary, claimMentions, releaseMentionProcessing, releaseStaleMentionProcessing, createService, getServiceById, getServiceByAgentAndName, getServicesByAgentId, getAllServices, updateServiceStatus, deleteService, upsertService, deleteServicesByAgentId, sessionLogQueries, createSessionLogs, getSessionLogsByTaskId, getSessionLogsBySession, createSessionCost, getSessionCostsByTaskId, getSessionCostsByAgentId, getAllSessionCosts, getSessionCostsFiltered, getSessionCostSummary, getDashboardCostSummary, createInboxMessage, getInboxMessageById, getUnreadInboxMessages, claimInboxMessages, markInboxMessageRead, markInboxMessageResponded, markInboxMessageDelegated, releaseStaleProcessingInbox, getConcurrentContext, getScheduledTasks, getScheduledTaskById, getScheduledTaskByName, createScheduledTask, updateScheduledTask, deleteScheduledTask, getDueScheduledTasks, autoEncryptLegacyPlaintextSecrets, maskSecrets, getSwarmConfigs, getInjectableGlobalConfigs, getSwarmConfigById, getSwarmConfigLookupById, upsertSwarmConfig, deleteSwarmConfig, deleteSwarmConfigByKey, getResolvedConfig, getSwarmRepos, getSwarmRepoById, getSwarmRepoByName, getSwarmRepoByUrl, createSwarmRepo, updateSwarmRepo, deleteSwarmRepo, getAgentMailInboxMapping, getAgentMailInboxMappingsByAgent, getAllAgentMailInboxMappings, createAgentMailInboxMapping, deleteAgentMailInboxMapping, findTaskByAgentMailThread, insertActiveSession, deleteActiveSession, deleteActiveSessionById, getActiveSessions, heartbeatActiveSession, cleanupStaleSessions, cleanupAgentSessions, updateActiveSessionProviderSessionId, getActiveSessionForTask, reassociateSessionLogs, getStalledInProgressTasks, getStalePinnedResumes, failPendingResumeIfUnclaimed, getIdleWorkersWithCapacity, getUnassignedPoolTasks, getRecentFailedTasks, getRecentCompletedCount, getRecentFailedCount, createWorkflow, getWorkflow, listWorkflows, updateWorkflow, deleteWorkflow, getWorkflowsByScheduleId, createWorkflowRun, getWorkflowRun, updateWorkflowRun, listWorkflowRuns, createWorkflowRunStep, getWorkflowRunStep, updateWorkflowRunStep, getWorkflowRunStepsByRunId, getStuckWorkflowRuns, getLastSuccessfulRun, getLastRunStart, getRetryableSteps, getCompletedStepNodeIds, getTaskByWorkflowRunStepId, getStepByIdempotencyKey, getStepCountForNode, getLatestStepForNode, createWorkflowVersion, getWorkflowVersions, getWorkflowVersion, createPage, getPage, getPageBySlug, getLatestPageBySlug, listPagesByAgent, listAllPages, countAllPages, countPagesByAgent, updatePage, deletePage, incrementPageViewCount, createPageVersion, getPageVersions, getPageVersion, createMetric, getMetric, getMetricBySlug, listMetricsByAgent, listAllMetrics, countAllMetrics, countMetricsByAgent, updateMetric, deleteMetric, createMetricVersion, getMetricVersions, getMetricVersion, getPromptTemplates, getPromptTemplateById, upsertPromptTemplate, deletePromptTemplate, resetPromptTemplateToDefault, getPromptTemplateHistory, resolvePromptTemplate, checkoutPromptTemplate, getAllChannelActivityCursors, getChannelActivityCursor, upsertChannelActivityCursor, createApprovalRequest, getApprovalRequestById, resolveApprovalRequest, updateApprovalRequestNotifications, listApprovalRequests, getStuckApprovalRuns, getApprovalRequestByStepId, getExpiredPendingApprovals, createWaitState, getWaitStateById, getWaitStateByStepId, getDueWaitStates, getPendingEventWaitNames, getPendingWaitsByEvent, resolveWaitState, getStuckWaitRuns, SKILL_FILE_LIMITS, normalizeSkillFilePath, createSkill, updateSkill, listSkillFileManifest, getSkillFiles, getSkillFile, upsertSkillFile, upsertSkillFiles, deleteSkillFile, deleteSkill, getSkillById, getSkillByName, listSkills, searchSkills, installSkill, getSystemDefaultSkills, installSystemDefaultSkillsForAgent, uninstallSkill, getAgentSkills, toggleAgentSkill, createMcpServer, updateMcpServer, deleteMcpServer, getMcpServerById, getMcpServerByName, listMcpServers, installMcpServer, uninstallMcpServer, getAgentMcpServers, createContextSnapshot, getContextSnapshotsByTaskId, getContextSnapshotsBySessionId, getContextSummaryByTaskId, getAvailableKeyIndices, recordKeyUsage, markKeyRateLimited, recordKeyRateLimitWindows, setApiKeyName, clearKeyRateLimit, getKeyStatuses, getKeyCostSummary, getUserById, getAllUsers, createUser, updateUser, deleteUser, listInboxState, upsertInboxState, listUserFavorites, getFavoriteItemIdSet, setUserFavorite, withFavoriteFlags, listTaskTemplates, getRootTaskChain, listRecentSessions, countSessions, getBudget, getBudgets, upsertBudget, deleteBudget, getAllPricingRows, getPricingRows, getActivePricingRow, insertPricingRow, deletePricingRow, getDailySpendForAgent, getDailySpendGlobal, getDailySpendForUser, recordBudgetRefusalNotification, getBudgetRefusalNotification, getRecentBudgetRefusalNotifications, hasBudgetRefusalNotificationToday, setBudgetRefusalFollowUpTaskId, getLiveAgentCounts, getInstanceActivity, getSwarmMetrics, hasFirstCompletedTask, getKv, upsertKv, deleteKv, KvTypeCollisionError, incrKv, listKv, countKv, createScriptRun, recordInlineScriptRun, getScriptRun, getScriptRunByIdempotencyKey, listScriptRuns, countScriptRuns, countActiveScriptRuns, updateScriptRun, getRunningScriptRuns, getScriptRunJournalStep, upsertScriptRunJournalStep, listScriptRunJournalSteps, countScriptRunJournalSteps, countScriptRunJournalAgentTaskSteps, exports_db, init_db };
10139
+ export { interpolate, deepInterpolate, init_template, registerTemplate, getTemplateDefinition, getAllTemplateDefinitions, init_registry, configureHttpResolver, resolveTemplate, resolveTemplateAsync, init_resolver, initTelemetry, telemetry, init_telemetry, ModelTierSchema, ReasoningEffortSchema, splitLegacyModelAlias, resolveTaskModelSelection, AgentTaskStatusSchema, isTerminalTaskStatus, AgentTaskSourceSchema, ProviderNameSchema, FollowUpConfigSchema, AgentTaskSchema, AttachmentInputSchema, TaskAttachmentSchema, InboxItemTypeSchema, InboxItemStatusSchema, FavoriteItemTypeSchema, TaskTemplateKindSchema, AgentSchema, AgentLatestModelSchema, AgentCredStatusSchema, ChannelTypeSchema, ChannelSchema, ChannelMessageSchema, ServiceStatusSchema, ServiceSchema, ResumeReasonSchema, AgentLogSchema, EventCategorySchema, EventStatusSchema, EventSourceSchema, EventNameSchema, ScheduledTaskTargetTypeSchema, SwarmConfigScopeSchema, SwarmConfigSchema, RepoGuidelinesSchema, RepoHooksSchema, SwarmRepoSchema, AgentMemoryScopeSchema, AgentMemorySourceSchema, AgentMemorySchema, WorkflowDefinitionSchema, WorkflowNodePatchSchema, WorkflowPatchSchema, TriggerConfigSchema, CooldownConfigSchema, InputValueSchema, PageContentTypeSchema, PageAuthModeSchema, MetricDefinitionSchema, MetricVersionSchema, WorkflowRunStatusSchema, ScriptRunStatusSchema, TERMINAL_SCRIPT_RUN_STATUSES, PromptTemplateScopeSchema, PromptTemplateStateSchema, PromptTemplateSchema, PromptTemplateHistorySchema, ScriptScopeSchema, ScriptFsModeSchema, ScriptApiAuthModeSchema, ContextSnapshotEventTypeSchema, ContextFormulaSchema, BudgetScopeSchema, BudgetSchema, PricingProviderSchema, PricingTokenClassSchema, PricingRowSchema, BudgetRefusalCauseSchema, BudgetRefusalNotificationSchema, KvValueTypeSchema, KvNamespaceSchema, KvKeySchema, KvEntrySchema, init_types, setRequestAuth, getRequestAuth, getCurrentRequestAuth, init_request_auth_context, encryptSecret, decryptSecret, getEncryptionKey, init_crypto, normalizeDate, normalizeDateRequired, init_date_utils, init_session_templates, init_templates, init_templates2 as init_templates1, isReservedConfigKey, reservedKeyError, validateConfigValue, init_swarm_config_guard, onTaskStarted, init_task_lifecycle_events, generateDefaultClaudeMd, generateDefaultSoulMd, generateDefaultIdentityMd, generateDefaultToolsMd, init_defaults, isSqliteVecAvailable, initDb, getDb, closeDb, computeContentHash, createContextVersion, getLatestContextVersion, getContextVersion, getContextVersionHistory, agentQueries, updateAgentCredentialState, createAgent, getAgentById, getAllAgents, getLeadAgent, updateAgentStatus, updateAgentMaxTasks, updateAgentProvider, setAgentHarnessProvider, updateAgentCredStatus, listAgentsWithCredStatusByProvider, getAgentHarnessProviders, updateAgentActivity, MAX_EMPTY_POLLS, incrementEmptyPollCount, resetEmptyPollCount, shouldBlockPolling, deleteAgent, getActiveTaskCount, hasCapacity, getRemainingCapacity, updateAgentStatusFromCapacity, taskQueries, createTask, getPendingTaskForAgent, assignUnassignedTaskPending, startTask, getTaskById, markTaskSlackReplySent, setSlackMessageTracking, getChildTasks, hasNonTerminalResumeChild, hasNonTerminalRerouteDecisionChild, updateTaskClaudeSessionId, updateTaskVcs, getTasksByAgentId, getAgentCurrentTask, getTasksByStatus, findTaskByVcs, findTaskByGitHub, getAllTasks, getTasksCount, getTaskStats, getCompletedSlackTasks, getRecentlyFinishedWorkerTasks, markTasksNotified, resetTasksNotified, getInProgressSlackTasks, getInProgressTasksByContextKey, findExistingLinearTrackerContextWork, getLatestTaskByContextKey, getAgentWorkingOnThread, getLatestActiveTaskInThread, getMostRecentTaskInThread, findCompletedTaskInThread, findRecentCancelledTaskInThread, completeTask, failTask, cancelTask, supersedeTask, backfillSupersedeTaskResumeTaskId, pauseTask, resumeTask, getPausedTasksForAgent, getOrphanedInProgressTasksForAgent, resetOrphanedInProgressTasksForAgent, getRecentlyCancelledTasksForAgent, deleteTask, updateTaskProgress, insertTaskAttachment, deleteTaskAttachment, replaceTaskAttachment, getTaskAttachments, getAgentWithTasks, getAllAgentsWithTasks, logQueries, createLogEntry, getLogsByAgentId, getLogsByTaskId, getLogsByTaskIdChronological, getLogsByEventType, getAllLogs, findRecentSimilarTasks, createTaskExtended, claimTask, releaseTask, acceptTask, rejectTask, moveTaskToBacklog, moveTaskFromBacklog, releaseStaleReviewingTasks, getOfferedTasksForAgent, claimOfferedTask, getUnassignedTasksCount, getUnassignedTaskIds, checkDependencies, getDependentTasks, cascadeFailDependents, updateAgentProfile, updateAgentName, createChannel, getMessageById, getChannelById, getChannelByName, getAllChannels, deleteChannel, postMessage, getChannelMessages, updateReadState, getLastReadAt, getUnreadMessages, getMentionsForAgent, getInboxSummary, claimMentions, releaseMentionProcessing, releaseStaleMentionProcessing, createService, getServiceById, getServiceByAgentAndName, getServicesByAgentId, getAllServices, updateServiceStatus, deleteService, upsertService, deleteServicesByAgentId, sessionLogQueries, createSessionLogs, getSessionLogsByTaskId, getSessionLogsBySession, createSessionCost, getSessionCostsByTaskId, getSessionCostsByAgentId, getAllSessionCosts, getSessionCostsFiltered, getSessionCostSummary, getDashboardCostSummary, createInboxMessage, getInboxMessageById, getUnreadInboxMessages, claimInboxMessages, markInboxMessageRead, markInboxMessageResponded, markInboxMessageDelegated, releaseStaleProcessingInbox, getConcurrentContext, getScheduledTasks, getScheduledTaskById, getScheduledTaskByName, createScheduledTask, updateScheduledTask, deleteScheduledTask, getDueScheduledTasks, autoEncryptLegacyPlaintextSecrets, maskSecrets, getSwarmConfigs, getInjectableGlobalConfigs, getSwarmConfigById, getSwarmConfigLookupById, upsertSwarmConfig, deleteSwarmConfig, deleteSwarmConfigByKey, getResolvedConfig, getSwarmRepos, getSwarmRepoById, getSwarmRepoByName, getSwarmRepoByUrl, createSwarmRepo, updateSwarmRepo, deleteSwarmRepo, getAgentMailInboxMapping, getAgentMailInboxMappingsByAgent, getAllAgentMailInboxMappings, createAgentMailInboxMapping, deleteAgentMailInboxMapping, findTaskByAgentMailThread, insertActiveSession, deleteActiveSession, deleteActiveSessionById, getActiveSessions, heartbeatActiveSession, cleanupStaleSessions, cleanupAgentSessions, updateActiveSessionProviderSessionId, getActiveSessionForTask, reassociateSessionLogs, getStalledInProgressTasks, getStalePinnedResumes, failPendingResumeIfUnclaimed, getIdleWorkersWithCapacity, getUnassignedPoolTasks, getRecentFailedTasks, getRecentCompletedCount, getRecentFailedCount, createWorkflow, getWorkflow, listWorkflows, updateWorkflow, deleteWorkflow, getWorkflowsByScheduleId, createWorkflowRun, getWorkflowRun, updateWorkflowRun, listWorkflowRuns, createWorkflowRunStep, getWorkflowRunStep, updateWorkflowRunStep, getWorkflowRunStepsByRunId, getStuckWorkflowRuns, getLastSuccessfulRun, getLastRunStart, getRetryableSteps, getCompletedStepNodeIds, getTaskByWorkflowRunStepId, getStepByIdempotencyKey, getStepCountForNode, getLatestStepForNode, createWorkflowVersion, getWorkflowVersions, getWorkflowVersion, createPage, getPage, getPageBySlug, getLatestPageBySlug, listPagesByAgent, listAllPages, countAllPages, countPagesByAgent, updatePage, deletePage, incrementPageViewCount, createPageVersion, getPageVersions, getPageVersion, createMetric, getMetric, getMetricBySlug, listMetricsByAgent, listAllMetrics, countAllMetrics, countMetricsByAgent, updateMetric, deleteMetric, createMetricVersion, getMetricVersions, getMetricVersion, getPromptTemplates, getPromptTemplateById, upsertPromptTemplate, deletePromptTemplate, resetPromptTemplateToDefault, getPromptTemplateHistory, resolvePromptTemplate, checkoutPromptTemplate, getAllChannelActivityCursors, getChannelActivityCursor, upsertChannelActivityCursor, createApprovalRequest, getApprovalRequestById, resolveApprovalRequest, updateApprovalRequestNotifications, listApprovalRequests, getStuckApprovalRuns, getApprovalRequestByStepId, getExpiredPendingApprovals, createWaitState, getWaitStateById, getWaitStateByStepId, getDueWaitStates, getPendingEventWaitNames, getPendingWaitsByEvent, resolveWaitState, getStuckWaitRuns, SKILL_FILE_LIMITS, normalizeSkillFilePath, createSkill, updateSkill, listSkillFileManifest, getSkillFiles, getSkillFile, upsertSkillFile, upsertSkillFiles, deleteSkillFile, deleteSkill, getSkillById, getSkillByName, listSkills, searchSkills, installSkill, getSystemDefaultSkills, installSystemDefaultSkillsForAgent, uninstallSkill, getAgentSkills, toggleAgentSkill, createMcpServer, updateMcpServer, deleteMcpServer, getMcpServerById, getMcpServerByName, listMcpServers, installMcpServer, uninstallMcpServer, getAgentMcpServers, createContextSnapshot, getContextSnapshotsByTaskId, getContextSnapshotsBySessionId, getContextSummaryByTaskId, getAvailableKeyIndices, recordKeyUsage, markKeyRateLimited, recordKeyRateLimitWindows, setApiKeyName, clearKeyRateLimit, getKeyStatuses, getKeyCostSummary, getUserById, getAllUsers, createUser, updateUser, deleteUser, listInboxState, upsertInboxState, listUserFavorites, getFavoriteItemIdSet, setUserFavorite, withFavoriteFlags, listTaskTemplates, getRootTaskChain, listRecentSessions, countSessions, getBudget, getBudgets, upsertBudget, deleteBudget, getAllPricingRows, getPricingRows, getActivePricingRow, insertPricingRow, deletePricingRow, getDailySpendForAgent, getDailySpendGlobal, getDailySpendForUser, recordBudgetRefusalNotification, getBudgetRefusalNotification, getRecentBudgetRefusalNotifications, hasBudgetRefusalNotificationToday, setBudgetRefusalFollowUpTaskId, getLiveAgentCounts, getInstanceActivity, getSwarmMetrics, hasFirstCompletedTask, getKv, upsertKv, deleteKv, KvTypeCollisionError, incrKv, listKv, countKv, createScriptRun, recordInlineScriptRun, getScriptRun, getScriptRunByIdempotencyKey, listScriptRuns, countScriptRuns, countActiveScriptRuns, updateScriptRun, getRunningScriptRuns, getScriptRunJournalStep, upsertScriptRunJournalStep, listScriptRunJournalSteps, countScriptRunJournalSteps, countScriptRunJournalAgentTaskSteps, exports_db, init_db };
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  getDb,
3
3
  init_db
4
- } from "./cli-951w7c79.js";
4
+ } from "./cli-jzwtn8rm.js";
5
5
 
6
6
  // src/be/seed-pricing.ts
7
7
  init_db();