@desplega.ai/agent-swarm 1.167.0 → 1.169.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 (184) hide show
  1. package/dist/{acp-adapter-zpvy6321.js → acp-adapter-m47zfx4a.js} +2 -2
  2. package/dist/{actions-fq2zrwtf.js → actions-ws7k3tvq.js} +25 -19
  3. package/dist/{amp-adapter-5gbk7501.js → amp-adapter-nvv8k8j5.js} +1 -1
  4. package/dist/{app-nctetn1e.js → app-80w6qspx.js} +5 -5
  5. package/dist/{assistant-0aq8gjvj.js → assistant-jtq439kw.js} +29 -20
  6. package/dist/{boot-reembed-1ze5853n.js → boot-reembed-3nc0aaed.js} +4 -4
  7. package/dist/{boot-reembed-fmp5ww69.js → boot-reembed-feda8wn8.js} +4 -4
  8. package/dist/{boot-scrub-sweep-cbp8xd4e.js → boot-scrub-sweep-grsa2er0.js} +5 -5
  9. package/dist/{boot-seeds-22tx8a53.js → boot-seeds-gcfgq44f.js} +7 -7
  10. package/dist/{claude-adapter-0jhgeh1d.js → claude-adapter-pjv2q7t8.js} +7 -7
  11. package/dist/{claude-managed-adapter-tzwxy803.js → claude-managed-adapter-0wa8se82.js} +2 -2
  12. package/dist/{claude-managed-setup-nrhfx5b0.js → claude-managed-setup-zxa9p9tx.js} +1 -1
  13. package/dist/{claude-sdk-session-wh77rh83.js → claude-sdk-session-c9j6k9kx.js} +8772 -8663
  14. package/dist/{cli-c2tpw9ck.js → cli-3ry5gx4f.js} +1 -1
  15. package/dist/{cli-wydz3feg.js → cli-61tbnjpf.js} +214 -2472
  16. package/dist/{cli-cexctgn5.js → cli-7vz49g7h.js} +101 -34
  17. package/dist/{cli-6qxmjpem.js → cli-8xjst8q2.js} +34 -22
  18. package/dist/{cli-tx2zvn23.js → cli-91r17hb1.js} +3 -3
  19. package/dist/{cli-577bxkf6.js → cli-a8vps458.js} +182 -2208
  20. package/dist/{cli-tc5zec7v.js → cli-b7y8113e.js} +1 -1
  21. package/dist/{cli-69egj654.js → cli-bqrs5ycj.js} +1 -1
  22. package/dist/{cli-cf2vgn9d.js → cli-dv76vq5d.js} +30 -28
  23. package/dist/{cli-g5erf0zt.js → cli-e2prcx5m.js} +31 -0
  24. package/dist/{cli-c8r99akr.js → cli-e5qk3m2a.js} +209 -31
  25. package/dist/{cli-z1dqhc9y.js → cli-eqfbsxsn.js} +3 -3
  26. package/dist/{cli-kw0jcfje.js → cli-fyeft04q.js} +1 -1
  27. package/dist/{cli-5qkcdv8c.js → cli-gmdajfw5.js} +3 -3
  28. package/dist/{cli-ypgba1a8.js → cli-jkfxpg1b.js} +1 -1
  29. package/dist/{cli-mxvnnv5q.js → cli-jv36y8wz.js} +1 -1
  30. package/dist/{cli-m7vmeepg.js → cli-km8559dm.js} +6 -6
  31. package/dist/{cli-ykt8f7va.js → cli-kp3vfknv.js} +1 -1
  32. package/dist/{cli-ymmc1zxg.js → cli-m23r88re.js} +8 -5
  33. package/dist/{cli-v1pwxreq.js → cli-n4z21pt8.js} +1 -1
  34. package/dist/{cli-mxry91sa.js → cli-qg2zhjfc.js} +73 -4
  35. package/dist/{cli-1yrcfa5s.js → cli-rbr91whd.js} +4 -4
  36. package/dist/{cli-mkdsy1nq.js → cli-rg1c8ccw.js} +93 -7
  37. package/dist/cli-rh44xx46.js +2659 -0
  38. package/dist/cli-s0k2j7q9.js +2084 -0
  39. package/dist/{cli-ty4bzkqr.js → cli-sajr098b.js} +1 -1
  40. package/dist/{cli-6vfz44sr.js → cli-swrz3mj8.js} +1 -1
  41. package/dist/{cli-p8rt8spp.js → cli-vejds37t.js} +2 -2
  42. package/dist/{cli-jbzbr36n.js → cli-w6xa5nf5.js} +1 -1
  43. package/dist/{cli-9q3wt23f.js → cli-x6z90nq9.js} +1 -1
  44. package/dist/{cli-qzmzwegq.js → cli-ysnkvdx6.js} +102 -9
  45. package/dist/{cli-y0kjpfm9.js → cli-yvxfaem2.js} +2 -2
  46. package/dist/{cli-pkj1w46r.js → cli-z48ggfyq.js} +1 -1
  47. package/dist/{cli-6bpvv8h4.js → cli-zzev32jw.js} +1 -1
  48. package/dist/cli.js +20 -17
  49. package/dist/{codex-adapter-cgesnjkr.js → codex-adapter-0kpg09ca.js} +3 -3
  50. package/dist/{codex-hook-15dgc4cb.js → codex-hook-295jpbfa.js} +2 -2
  51. package/dist/{codex-session-runner-8kd7ddhr.js → codex-session-runner-8n672hxh.js} +3 -3
  52. package/dist/{commands-h6zaaxym.js → commands-mhmg5n0x.js} +4 -4
  53. package/dist/{cursor-adapter-v8mm6bp5.js → cursor-adapter-wn8n5zzk.js} +2 -2
  54. package/dist/{db-qg3myn53.js → db-wa6s1mwv.js} +4 -4
  55. package/dist/{dispatcher-7vnwj9qw.js → dispatcher-nhs2pkr8.js} +16 -14
  56. package/dist/{dsh-adapter-tz6hfp5r.js → dsh-adapter-5423p70m.js} +1 -1
  57. package/dist/{grok-adapter-jdt2dz2s.js → grok-adapter-28pkdt80.js} +3 -3
  58. package/dist/{handlers-2qtkpncr.js → handlers-5rtf9nng.js} +19 -17
  59. package/dist/{hook-51yfcgsv.js → hook-krjfkpzy.js} +4 -4
  60. package/dist/{hook-qnbdgwvd.js → hook-qkm73zk6.js} +5 -5
  61. package/dist/{http-jsmtag08.js → http-a397xcn4.js} +4845 -3484
  62. package/dist/{index-2t9kesn1.js → index-ac0v8v9d.js} +4 -4
  63. package/dist/{index-ekywyv2v.js → index-kqre45fr.js} +16 -14
  64. package/dist/{index-bt8wkv1w.js → index-rtxg15ah.js} +17 -15
  65. package/dist/{index-t4g06w93.js → index-vvsq7v45.js} +26 -23
  66. package/dist/{index-cx1sb9bq.js → index-ytdhtdry.js} +50 -11
  67. package/dist/{keepalive-4aezx4bj.js → keepalive-psfh8ysx.js} +6 -6
  68. package/dist/{lead-r44bkpm5.js → lead-m6rppjn7.js} +29 -27
  69. package/dist/{maintenance-grz5jrzh.js → maintenance-41f837ke.js} +4 -4
  70. package/dist/{node-qm9eb6z0.js → node-fkajaq96.js} +1 -1
  71. package/dist/{oauth-refresh-sweep-wm4ctjfj.js → oauth-refresh-sweep-6hr55hm8.js} +5 -5
  72. package/dist/{onboard-v60zgqf0.js → onboard-ktrtd7cz.js} +2 -2
  73. package/dist/{otel-impl-ghh4dyf8.js → otel-impl-dq4f2k3m.js} +1 -1
  74. package/dist/{pi-mono-adapter-0eg8kw2c.js → pi-mono-adapter-e5v9w0hv.js} +3 -2
  75. package/dist/{pricing-refresh-mjrqvnvw.js → pricing-refresh-kmk7j1ra.js} +6 -6
  76. package/dist/{rbac-roles-fd5tskj9.js → rbac-roles-9w1dkkxd.js} +4 -4
  77. package/dist/{rbac-roles-axv4d74x.js → rbac-roles-9ykx9tc5.js} +5 -5
  78. package/dist/{render-v2-k50j33qd.js → render-v2-ycqm53np.js} +5 -5
  79. package/dist/resume-cq2pkp8q.js +70 -0
  80. package/dist/{setup-4syh0pd2.js → setup-0dcmdvbn.js} +2 -2
  81. package/dist/{virtual-modules-ftr9kwe8.js → virtual-modules-1x9k4jcs.js} +1 -1
  82. package/dist/{work-objects-jcdbg8rr.js → work-objects-x01x2fh8.js} +19 -17
  83. package/dist/{worker-x8j8c9sx.js → worker-py1ssb1h.js} +29 -27
  84. package/openapi.json +15622 -15042
  85. package/package.json +8 -5
  86. package/src/apps/store.ts +1 -0
  87. package/src/artifact-sdk/feedback-overlay.ts +528 -0
  88. package/src/be/db/workflow-runs.ts +95 -0
  89. package/src/be/db-queries/slack-inbound.ts +489 -0
  90. package/src/be/db.ts +9 -2
  91. package/src/be/extensions/assets.ts +1 -1
  92. package/src/be/migrations/203_workflow_run_parent_step.sql +10 -0
  93. package/src/be/migrations/204_slack_inbound_receipts.sql +51 -0
  94. package/src/be/script-connections.ts +41 -7
  95. package/src/be/scripts/run-saved.ts +40 -20
  96. package/src/be/swarm-config-guard.ts +4 -0
  97. package/src/extensions/catalog.generated.json +17 -0
  98. package/src/extensions/catalog.ts +1 -1
  99. package/src/extensions/dispatcher.ts +3 -3
  100. package/src/heartbeat/heartbeat.ts +152 -2
  101. package/src/heartbeat/templates.ts +16 -0
  102. package/src/http/all-routes.ts +1 -0
  103. package/src/http/index.ts +2 -0
  104. package/src/http/integrations.ts +3 -1
  105. package/src/http/mcp-bridge.ts +1 -0
  106. package/src/http/pages-public.ts +7 -2
  107. package/src/http/pages.ts +178 -0
  108. package/src/http/script-connections.ts +35 -0
  109. package/src/http/slack-inbound.ts +107 -0
  110. package/src/http/tasks.ts +45 -27
  111. package/src/http/users.ts +1 -1
  112. package/src/http/webhooks.ts +20 -20
  113. package/src/prompts/session-templates.ts +32 -0
  114. package/src/providers/acp-targets.ts +1 -1
  115. package/src/providers/amp-adapter.ts +2 -2
  116. package/src/providers/claude-adapter.ts +6 -0
  117. package/src/providers/claude-background-keepalive.ts +100 -0
  118. package/src/providers/claude-managed-adapter.ts +2 -11
  119. package/src/providers/claude-sdk-session.ts +7 -1
  120. package/src/providers/dsh-adapter.ts +1 -1
  121. package/src/providers/opencode-adapter.ts +1 -2
  122. package/src/providers/pi-mono-adapter.ts +3 -3
  123. package/src/realtime/browser.generated.txt +8 -8
  124. package/src/realtime/browser.ts +3 -3
  125. package/src/scheduler/scheduler.ts +82 -13
  126. package/src/scripts-runtime/executors/quickjs-pool-config.ts +26 -0
  127. package/src/scripts-runtime/executors/quickjs.ts +9 -2
  128. package/src/scripts-runtime/executors/registry.ts +1 -1
  129. package/src/server.ts +1 -0
  130. package/src/slack/actions.ts +6 -2
  131. package/src/slack/app.ts +5 -0
  132. package/src/slack/assistant.ts +15 -5
  133. package/src/slack/egress-scrub.ts +3 -2
  134. package/src/slack/handlers.ts +36 -18
  135. package/src/slack/inbound-dispatch.ts +549 -0
  136. package/src/slack/inbound-files.ts +2 -0
  137. package/src/telemetry-context.ts +1 -0
  138. package/src/tests/claude-background-keepalive-wiring.test.ts +220 -0
  139. package/src/tests/claude-background-keepalive.fixture.ts +162 -0
  140. package/src/tests/claude-background-keepalive.test.ts +139 -0
  141. package/src/tests/codex-oauth-device.test.ts +1 -1
  142. package/src/tests/connection-embedded-auth.test.ts +51 -0
  143. package/src/tests/docs-index-footprint.test.js +3 -3
  144. package/src/tests/dsh-adapter.test.ts +1 -1
  145. package/src/tests/extensions-catalog.test.ts +1 -0
  146. package/src/tests/extensions-example-slack-reply-gate.test.ts +756 -0
  147. package/src/tests/heartbeat-checklist.test.ts +243 -0
  148. package/src/tests/pages-feedback.test.ts +218 -0
  149. package/src/tests/schedule-target-type.test.ts +136 -0
  150. package/src/tests/script-connections-http.test.ts +45 -0
  151. package/src/tests/script-connections-mcp.test.ts +41 -0
  152. package/src/tests/script-connections.test.ts +2 -0
  153. package/src/tests/script-executor-quickjs-pool.test.ts +106 -0
  154. package/src/tests/script-executor-registry.test.ts +56 -0
  155. package/src/tests/send-task-self-send.test.ts +107 -0
  156. package/src/tests/slack-inbound-diagnostics-auth.test.ts +93 -0
  157. package/src/tests/slack-inbound-receipts.test.ts +684 -0
  158. package/src/tests/slack-session-status.test.ts +4 -2
  159. package/src/tests/ui-e2e-ingest-payload.test.ts +5 -1
  160. package/src/tests/user-token-routes.test.ts +1 -1
  161. package/src/tests/workflow-executors.test.ts +3 -2
  162. package/src/tests/workflow-sub-workflow.test.ts +363 -0
  163. package/src/tools/script-connections/tool.ts +35 -3
  164. package/src/tools/send-task.ts +9 -1
  165. package/src/utils/internal-ai/complete-structured.ts +6 -3
  166. package/src/utils/runtime-model-catalog.ts +1 -1
  167. package/src/workflows/engine.ts +17 -1
  168. package/src/workflows/executors/agent-task.ts +2 -2
  169. package/src/workflows/executors/human-in-the-loop.ts +3 -3
  170. package/src/workflows/executors/registry.ts +2 -0
  171. package/src/workflows/executors/script.ts +1 -1
  172. package/src/workflows/executors/sub-workflow.ts +135 -0
  173. package/src/workflows/executors/wait.ts +3 -3
  174. package/src/workflows/recovery.ts +11 -1
  175. package/src/workflows/resume.ts +77 -0
  176. package/src/workflows/wait-filter.ts +5 -7
  177. package/templates/extensions/README.md +1 -0
  178. package/templates/extensions/slack-reply-gate/README.md +98 -0
  179. package/templates/extensions/slack-reply-gate/hooks.ts +582 -0
  180. package/templates/extensions/slack-reply-gate/manifest.json +8 -0
  181. package/templates/skills/heartbeat-runbook/content.md +3 -1
  182. package/templates/skills/pages/content.md +25 -0
  183. package/templates/skills/swarm-scripts/SKILL.md +10 -0
  184. package/templates/skills/swarm-scripts/content.md +10 -0
@@ -26,6 +26,7 @@ import {
26
26
  normalizeGrokModel
27
27
  } from "./cli-014vns2y.js";
28
28
  import {
29
+ _null,
29
30
  array,
30
31
  boolean,
31
32
  exports_external,
@@ -44,7 +45,7 @@ import {
44
45
  import {
45
46
  init_package,
46
47
  package_default
47
- } from "./cli-ymmc1zxg.js";
48
+ } from "./cli-m23r88re.js";
48
49
  import {
49
50
  init_secret_scrubber,
50
51
  scrubSecrets
@@ -159,6 +160,21 @@ function preserveCustomPayload(schema, key, knownTags) {
159
160
  return output;
160
161
  });
161
162
  }
163
+ function defaultOnErrorOptionalStringTag(schema, key) {
164
+ return exports_external.preprocess((value) => {
165
+ if (value === null || typeof value !== "object" || Array.isArray(value)) {
166
+ return value;
167
+ }
168
+ const record2 = value;
169
+ const tag = record2[key];
170
+ if (tag === undefined || tag === null || typeof tag === "string") {
171
+ return value;
172
+ }
173
+ const normalized = { ...record2 };
174
+ delete normalized[key];
175
+ return normalized;
176
+ }, schema);
177
+ }
162
178
  function vecSkipError(itemSchema) {
163
179
  return exports_external.array(itemSchema.catch(skippedItem)).transform((items) => items.filter((item) => item !== skippedItem));
164
180
  }
@@ -177,16 +193,12 @@ var zWriteTextFileRequest = object({
177
193
  var zReadTextFileRequest = object({
178
194
  sessionId: zSessionId,
179
195
  path: string(),
180
- line: defaultOnError(int().gte(0).max(4294967295, {
196
+ line: int().gte(0).max(4294967295, {
181
197
  error: "Invalid value: Expected uint32 to be <= 4294967295"
182
- }).nullish(), () => {
183
- return;
184
- }),
185
- limit: defaultOnError(int().gte(0).max(4294967295, {
198
+ }).nullish(),
199
+ limit: int().gte(0).max(4294967295, {
186
200
  error: "Invalid value: Expected uint32 to be <= 4294967295"
187
- }).nullish(), () => {
188
- return;
189
- }),
201
+ }).nullish(),
190
202
  _meta: defaultOnError(record(string(), unknown()).nullish(), () => {
191
203
  return;
192
204
  })
@@ -437,14 +449,10 @@ var zEnvVariable = object({
437
449
  var zCreateTerminalRequest = object({
438
450
  sessionId: zSessionId,
439
451
  command: string(),
440
- args: defaultOnError(vecSkipError(string()).optional(), () => []),
441
- env: defaultOnError(vecSkipError(zEnvVariable).optional(), () => []),
442
- cwd: defaultOnError(string().nullish(), () => {
443
- return;
444
- }),
445
- outputByteLimit: defaultOnError(number().nullish(), () => {
446
- return;
447
- }),
452
+ args: array(string()).optional(),
453
+ env: array(zEnvVariable).optional(),
454
+ cwd: string().nullish(),
455
+ outputByteLimit: number().nullish(),
448
456
  _meta: defaultOnError(record(string(), unknown()).nullish(), () => {
449
457
  return;
450
458
  })
@@ -970,10 +978,8 @@ var zAuthMethodTerminal = object({
970
978
  description: defaultOnError(string().nullish(), () => {
971
979
  return;
972
980
  }),
973
- args: defaultOnError(vecSkipError(string()).optional(), () => []),
974
- env: defaultOnError(record(string(), string()).optional(), () => {
975
- return;
976
- }),
981
+ args: array(string()).optional(),
982
+ env: record(string(), string()).optional(),
977
983
  _meta: defaultOnError(record(string(), unknown()).nullish(), () => {
978
984
  return;
979
985
  })
@@ -1671,17 +1677,61 @@ var zRunningStateUpdate = object({
1671
1677
  return;
1672
1678
  })
1673
1679
  });
1674
- var zIdleStateUpdate = object({
1675
- stopReason: defaultOnError(zStopReason.nullish(), () => {
1680
+ var zErrorStopReason = object({
1681
+ error: defaultOnError(zError.nullish(), () => {
1676
1682
  return;
1683
+ })
1684
+ });
1685
+ var zIdleStateUpdate = defaultOnErrorOptionalStringTag(preserveCustomPayload(intersection(union([
1686
+ object({
1687
+ stopReason: literal("end_turn")
1688
+ }),
1689
+ object({
1690
+ stopReason: literal("max_tokens")
1691
+ }),
1692
+ object({
1693
+ stopReason: literal("max_turn_requests")
1694
+ }),
1695
+ object({
1696
+ stopReason: literal("refusal")
1697
+ }),
1698
+ object({
1699
+ stopReason: literal("cancelled")
1677
1700
  }),
1701
+ zErrorStopReason.and(object({
1702
+ stopReason: literal("error")
1703
+ })),
1704
+ excludeKnownTags(object({
1705
+ stopReason: string()
1706
+ }), "stopReason", [
1707
+ "cancelled",
1708
+ "end_turn",
1709
+ "error",
1710
+ "max_tokens",
1711
+ "max_turn_requests",
1712
+ "refusal"
1713
+ ]),
1714
+ object({
1715
+ stopReason: _null().optional()
1716
+ })
1717
+ ]), object({
1678
1718
  usage: defaultOnError(zUsage.nullish(), () => {
1679
1719
  return;
1680
1720
  }),
1681
1721
  _meta: defaultOnError(record(string(), unknown()).nullish(), () => {
1682
1722
  return;
1723
+ }),
1724
+ stopReason: defaultOnError(string().nullish(), () => {
1725
+ return;
1683
1726
  })
1684
- });
1727
+ })), "stopReason", [
1728
+ "cancelled",
1729
+ "end_turn",
1730
+ "error",
1731
+ "max_tokens",
1732
+ "max_turn_requests",
1733
+ "refusal"
1734
+ ]), "stopReason");
1685
1735
  var zRequiresActionStateUpdate = object({
1686
1736
  _meta: defaultOnError(record(string(), unknown()).nullish(), () => {
1687
1737
  return;
@@ -2064,16 +2114,16 @@ var zMcpServer = union([
2064
2114
  ]);
2065
2115
  var zNewSessionRequest = object({
2066
2116
  cwd: string(),
2067
- additionalDirectories: defaultOnError(vecSkipError(string()).optional(), () => []),
2068
- mcpServers: requiredDefaultOnError(vecSkipError(zMcpServer), () => []),
2117
+ additionalDirectories: array(string()).optional(),
2118
+ mcpServers: array(zMcpServer),
2069
2119
  _meta: defaultOnError(record(string(), unknown()).nullish(), () => {
2070
2120
  return;
2071
2121
  })
2072
2122
  });
2073
2123
  var zLoadSessionRequest = object({
2074
- mcpServers: requiredDefaultOnError(vecSkipError(zMcpServer), () => []),
2124
+ mcpServers: array(zMcpServer),
2075
2125
  cwd: string(),
2076
- additionalDirectories: defaultOnError(vecSkipError(string()).optional(), () => []),
2126
+ additionalDirectories: array(string()).optional(),
2077
2127
  sessionId: zSessionId,
2078
2128
  _meta: defaultOnError(record(string(), unknown()).nullish(), () => {
2079
2129
  return;
@@ -2095,8 +2145,8 @@ var zDeleteSessionRequest = object({
2095
2145
  var zForkSessionRequest = object({
2096
2146
  sessionId: zSessionId,
2097
2147
  cwd: string(),
2098
- additionalDirectories: defaultOnError(vecSkipError(string()).optional(), () => []),
2099
- mcpServers: defaultOnError(vecSkipError(zMcpServer).optional(), () => []),
2148
+ additionalDirectories: array(string()).optional(),
2149
+ mcpServers: array(zMcpServer).optional(),
2100
2150
  _meta: defaultOnError(record(string(), unknown()).nullish(), () => {
2101
2151
  return;
2102
2152
  })
@@ -2104,8 +2154,8 @@ var zForkSessionRequest = object({
2104
2154
  var zResumeSessionRequest = object({
2105
2155
  sessionId: zSessionId,
2106
2156
  cwd: string(),
2107
- additionalDirectories: defaultOnError(vecSkipError(string()).optional(), () => []),
2108
- mcpServers: defaultOnError(vecSkipError(zMcpServer).optional(), () => []),
2157
+ additionalDirectories: array(string()).optional(),
2158
+ mcpServers: array(zMcpServer).optional(),
2109
2159
  _meta: defaultOnError(record(string(), unknown()).nullish(), () => {
2110
2160
  return;
2111
2161
  })
@@ -2486,7 +2536,7 @@ var zDidChangeDocumentNotification = object({
2486
2536
  sessionId: zSessionId,
2487
2537
  uri: string(),
2488
2538
  version: number(),
2489
- contentChanges: requiredDefaultOnError(vecSkipError(zTextDocumentContentChangeEvent), () => []),
2539
+ contentChanges: array(zTextDocumentContentChangeEvent),
2490
2540
  _meta: defaultOnError(record(string(), unknown()).nullish(), () => {
2491
2541
  return;
2492
2542
  })
@@ -3565,9 +3615,26 @@ var zGuardElicitationPropertySchemaBoolean = zBooleanPropertySchema.and(object({
3565
3615
  var zGuardElicitationPropertySchemaArray = zMultiSelectPropertySchema.and(object({ type: literal("array") }));
3566
3616
  var zGuardMultiSelectItemsString = zStringMultiSelectItems.and(object({ type: literal("string") }));
3567
3617
  var zGuardStateUpdateRunning = zRunningStateUpdate.and(object({ state: literal("running") }));
3568
- var zGuardStateUpdateIdle = zIdleStateUpdate.and(object({ state: literal("idle") }));
3618
+ var zGuardStateUpdateIdle = zIdleStateUpdate.and(object({ usage: zUsage.nullish() })).and(object({ state: literal("idle") }));
3569
3619
  var zGuardStateUpdateRequiresAction = zRequiresActionStateUpdate.and(object({ state: literal("requires_action") }));
3570
3620
  var zGuardStateUpdateUnknown = zUnknownStateUpdate.and(object({ state: literal("unknown") }));
3621
+ var zGuardIdleStateUpdateEndTurn = object({
3622
+ stopReason: literal("end_turn")
3623
+ });
3624
+ var zGuardIdleStateUpdateMaxTokens = object({
3625
+ stopReason: literal("max_tokens")
3626
+ });
3627
+ var zGuardIdleStateUpdateMaxTurnRequests = object({
3628
+ stopReason: literal("max_turn_requests")
3629
+ });
3630
+ var zGuardIdleStateUpdateRefusal = object({
3631
+ stopReason: literal("refusal")
3632
+ });
3633
+ var zGuardIdleStateUpdateCancelled = object({
3634
+ stopReason: literal("cancelled")
3635
+ });
3636
+ var zGuardIdleStateUpdateError = zErrorStopReason.and(object({ error: zError.nullish() })).and(object({ stopReason: literal("error") }));
3637
+ var zGuardIdleStateUpdateNone = object({ stopReason: _null().optional() });
3571
3638
  var zGuardCreateElicitationResponseAccept = zElicitationAcceptAction.and(object({ action: literal("accept") }));
3572
3639
  var zGuardCreateElicitationResponseDecline = object({
3573
3640
  action: literal("decline")
@@ -5,12 +5,12 @@ import {
5
5
  instantFlush,
6
6
  requestSlackThreadSteering,
7
7
  wasEventSeen
8
- } from "./cli-1yrcfa5s.js";
8
+ } from "./cli-rbr91whd.js";
9
9
  import {
10
10
  enrichSlackUserEmail,
11
11
  resolveSlackUserId,
12
12
  rewriteSlackMentions
13
- } from "./cli-y0kjpfm9.js";
13
+ } from "./cli-yvxfaem2.js";
14
14
  import {
15
15
  TaskCreationBlockedError,
16
16
  broadcastMatches,
@@ -23,14 +23,18 @@ import {
23
23
  hasOtherUserMention,
24
24
  notifySlackFileFailures,
25
25
  routeMessage
26
- } from "./cli-wydz3feg.js";
26
+ } from "./cli-61tbnjpf.js";
27
27
  import {
28
28
  ackSlackMessage,
29
29
  buildTreeBlocks,
30
30
  ensureSlackThreadTree,
31
+ ignoreSlackInbound,
32
+ isAdmittedSlackDelivery,
31
33
  isSlackRenderV2Enabled,
32
- registerTreeMessage
33
- } from "./cli-c8r99akr.js";
34
+ noteSlackInboundSideEffect,
35
+ registerTreeMessage,
36
+ reportSlackInboundFailure
37
+ } from "./cli-e5qk3m2a.js";
34
38
  import {
35
39
  getAgentById,
36
40
  getAgentWorkingOnThread,
@@ -43,7 +47,7 @@ import {
43
47
  isExtensionAgent,
44
48
  reactionName,
45
49
  slackContextKey
46
- } from "./cli-mkdsy1nq.js";
50
+ } from "./cli-rg1c8ccw.js";
47
51
  import {
48
52
  init_resolver,
49
53
  resolveTemplate
@@ -261,13 +265,13 @@ function registerMessageHandler(app) {
261
265
  let __stack2 = [];
262
266
  try {
263
267
  const eventId = body?.event_id;
264
- if (wasEventSeen(eventId)) {
268
+ if (!isAdmittedSlackDelivery() && wasEventSeen(eventId)) {
265
269
  console.log(`[Slack] dropping Slack retry: event_id=${eventId}`);
266
- return;
270
+ return ignoreSlackInbound("duplicate_event");
267
271
  }
268
272
  const msg = event;
269
273
  if (msg.subtype === "message_changed")
270
- return;
274
+ return ignoreSlackInbound("message_changed");
271
275
  if (!cachedBotUserId) {
272
276
  try {
273
277
  const authResult = await client.auth.test();
@@ -278,24 +282,25 @@ function registerMessageHandler(app) {
278
282
  }
279
283
  }
280
284
  if (isBotMessage(msg, cachedBotUserId)) {
281
- return;
285
+ return ignoreSlackInbound("bot_message");
282
286
  }
283
287
  const hasText = !!msg.text?.trim();
284
288
  const hasFiles = !!(msg.files && msg.files.length > 0);
285
289
  if (!hasText && !hasFiles || !msg.user)
286
- return;
290
+ return ignoreSlackInbound("empty_message");
287
291
  const messageKey = `${msg.channel}:${msg.ts}`;
288
- if (isMessageProcessed(messageKey)) {
289
- return;
292
+ if (!isAdmittedSlackDelivery() && isMessageProcessed(messageKey)) {
293
+ return ignoreSlackInbound("duplicate_message");
290
294
  }
291
295
  if (!await isUserAllowed(client, msg.user)) {
292
296
  console.log(`[Slack] Ignoring message from unauthorized user ${msg.user}`);
293
- return;
297
+ return ignoreSlackInbound("unauthorized_user");
294
298
  }
295
299
  const requestedByUserId = await resolveSlackUserId(client, msg.user, {
296
300
  sampleEventType: "message",
297
301
  sampleContext: msg.text ?? ""
298
302
  });
303
+ noteSlackInboundSideEffect("workflow_event");
299
304
  workflowEventBus.emit("slack.message", {
300
305
  channel: msg.channel,
301
306
  channelId: msg.channel,
@@ -308,7 +313,7 @@ function registerMessageHandler(app) {
308
313
  const effectiveText = buildEffectiveText(msg.text, msg.files);
309
314
  if (!cachedBotUserId) {
310
315
  console.error("[Slack] Bot user ID unavailable — skipping message to avoid silent misbehavior");
311
- return;
316
+ return reportSlackInboundFailure("bot_user_unavailable");
312
317
  }
313
318
  const botUserId = cachedBotUserId;
314
319
  const botMentioned = !!msg.text?.includes(`<@${botUserId}>`);
@@ -322,6 +327,7 @@ function registerMessageHandler(app) {
322
327
  const nowMessage = stripped.replace(/^!now\s*/, "").trim();
323
328
  const threadKey = `${msg.channel}:${msg.thread_ts}`;
324
329
  console.log(`[Slack] !now command detected in thread ${threadKey}${nowMessage ? ` with message: "${nowMessage}"` : ""}`);
330
+ noteSlackInboundSideEffect("thread_flush");
325
331
  if (nowMessage || msg.files?.length) {
326
332
  bufferThreadMessage(msg.channel, msg.thread_ts, nowMessage, msg.user, msg.ts, msg.files, botUserId);
327
333
  }
@@ -333,11 +339,12 @@ function registerMessageHandler(app) {
333
339
  if (additiveSlack && !botMentioned && msg.thread_ts && !requireMentionForThreadFollowup) {
334
340
  if (hasOtherUserMention(effectiveText, botUserId)) {
335
341
  console.log(`[Slack] Skipping ADDITIVE buffer in ${msg.channel}/${msg.thread_ts}: message mentions another user`);
336
- return;
342
+ return ignoreSlackInbound("other_user_mention");
337
343
  }
338
344
  const hasSwarmActivity = await hasSwarmThreadActivity(client, msg.channel, msg.thread_ts);
339
345
  if (hasSwarmActivity) {
340
346
  const threadKey = `${msg.channel}:${msg.thread_ts}`;
347
+ noteSlackInboundSideEffect("thread_buffer");
341
348
  bufferThreadMessage(msg.channel, msg.thread_ts, msg.text ?? "", msg.user, msg.ts, msg.files, botUserId);
342
349
  const count = getBufferMessageCount(threadKey);
343
350
  const event2 = count === 1 ? "accepted" : "buffered";
@@ -364,7 +371,7 @@ function registerMessageHandler(app) {
364
371
  });
365
372
  if (routeResult.action === "block") {
366
373
  console.info("[Slack] Extension blocked message routing:", scrubSecrets(routeResult.reason));
367
- return;
374
+ return ignoreSlackInbound("extension_blocked");
368
375
  }
369
376
  let matches;
370
377
  if (routeResult.action === "modify") {
@@ -394,7 +401,7 @@ function registerMessageHandler(app) {
394
401
  let __stack = [];
395
402
  try {
396
403
  if (!botMentioned && !isImplicitMention)
397
- return;
404
+ return ignoreSlackInbound("not_addressed");
398
405
  if (!checkRateLimit(msg.user)) {
399
406
  if (!isSlackRenderV2Enabled()) {
400
407
  await say({
@@ -402,7 +409,7 @@ function registerMessageHandler(app) {
402
409
  thread_ts: msg.thread_ts || msg.ts
403
410
  });
404
411
  }
405
- return;
412
+ return ignoreSlackInbound("rate_limited");
406
413
  }
407
414
  const inbound2 = __using(__stack, await fetchSlackFiles(client, msg.files), 1);
408
415
  const taskText = buildEffectiveText(msg.text, inbound2.files, inbound2.failed);
@@ -414,7 +421,7 @@ function registerMessageHandler(app) {
414
421
  thread_ts: msg.thread_ts || msg.ts
415
422
  });
416
423
  }
417
- return;
424
+ return ignoreSlackInbound("empty_task");
418
425
  }
419
426
  const threadTs2 = msg.thread_ts || msg.ts;
420
427
  const threadContext2 = await getThreadContext(client, msg.channel, msg.thread_ts, msg.ts, botUserId);
@@ -467,7 +474,7 @@ ${taskDescription2}`;
467
474
  thread_ts: msg.thread_ts || msg.ts
468
475
  });
469
476
  }
470
- return;
477
+ return ignoreSlackInbound("rate_limited");
471
478
  }
472
479
  const inbound = __using(__stack2, await fetchSlackFiles(client, msg.files), 1);
473
480
  const taskDescription = extractTaskFromMessage(buildEffectiveText(msg.text, inbound.files, inbound.failed), botUserId);
@@ -478,7 +485,7 @@ ${taskDescription2}`;
478
485
  thread_ts: msg.thread_ts || msg.ts
479
486
  });
480
487
  }
481
- return;
488
+ return ignoreSlackInbound("empty_task");
482
489
  }
483
490
  const threadTs = msg.thread_ts || msg.ts;
484
491
  const threadContext = await getThreadContext(client, msg.channel, msg.thread_ts, msg.ts, botUserId);
@@ -504,6 +511,8 @@ ${taskDescription}`;
504
511
  try {
505
512
  const latestTask = await getMostRecentTaskInThread(msg.channel, threadTs);
506
513
  if (agent.isLead) {
514
+ if (msg.thread_ts && inbound.files.length === 0)
515
+ noteSlackInboundSideEffect("steering");
507
516
  const steering = msg.thread_ts && inbound.files.length === 0 ? await requestSlackThreadSteering({
508
517
  channelId: msg.channel,
509
518
  threadTs,
@@ -562,6 +571,9 @@ ${taskDescription}`;
562
571
  results.assigned.push({ agentName: agent.name, taskId: task.id });
563
572
  }
564
573
  } catch (error) {
574
+ if (!(error instanceof TaskCreationBlockedError)) {
575
+ reportSlackInboundFailure("task_creation_error");
576
+ }
565
577
  results.failed.push({
566
578
  agentName: agent.name,
567
579
  reason: error instanceof TaskCreationBlockedError ? error.reason : "error"
@@ -1,14 +1,14 @@
1
1
  import {
2
2
  seedPricingFromModelsDev
3
- } from "./cli-v1pwxreq.js";
3
+ } from "./cli-n4z21pt8.js";
4
4
  import {
5
5
  ensureRbacSeedsSynced,
6
6
  init_rbac_roles
7
- } from "./cli-ypgba1a8.js";
7
+ } from "./cli-jkfxpg1b.js";
8
8
  import {
9
9
  getDb,
10
10
  init_db1 as init_db
11
- } from "./cli-mkdsy1nq.js";
11
+ } from "./cli-rg1c8ccw.js";
12
12
 
13
13
  // src/be/boot-seeds.ts
14
14
  init_db();