@desplega.ai/agent-swarm 2.7.5 → 2.7.6
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.
- package/dist/{acp-adapter-g3ads55s.js → acp-adapter-bp91d37f.js} +4 -4
- package/dist/{actions-zwfykqqk.js → actions-yj0eeaqh.js} +18 -17
- package/dist/{amp-adapter-z3s0ssdt.js → amp-adapter-4pg9h34q.js} +1 -1
- package/dist/{app-vmp4fgep.js → app-909e97cr.js} +3 -3
- package/dist/{assistant-vwde653f.js → assistant-qdyb5fyy.js} +24 -22
- package/dist/{boot-reembed-375t7tbk.js → boot-reembed-fk0s9z18.js} +1 -1
- package/dist/{boot-reembed-gq9rcpnj.js → boot-reembed-gs1rzrnh.js} +1 -1
- package/dist/{boot-scrub-sweep-nd938kyf.js → boot-scrub-sweep-4qfd4kfx.js} +2 -2
- package/dist/{boot-seeds-aykx51v3.js → boot-seeds-yr00k13d.js} +4 -4
- package/dist/{boxd-k1j26g3h.js → boxd-vdmfssd9.js} +4 -4
- package/dist/{claude-adapter-8j4hm099.js → claude-adapter-qta1f1xn.js} +3 -3
- package/dist/{claude-managed-setup-0wyynpn1.js → claude-managed-setup-sc6j4dm0.js} +1 -1
- package/dist/{claude-sdk-session-q6wj5hmy.js → claude-sdk-session-zgrz6yvc.js} +9169 -9070
- package/dist/{cli-gjr2y2xk.js → cli-0agcv1v5.js} +4 -1
- package/dist/{cli-vqypxzh4.js → cli-0at8w34w.js} +7 -7
- package/dist/{cli-7a42nfy0.js → cli-0qatpy8q.js} +3 -3
- package/dist/{cli-p599f1qm.js → cli-0yv5z2pg.js} +1 -1
- package/dist/{cli-0gey5fzy.js → cli-386tyxxg.js} +2 -2
- package/dist/{cli-5pag6rmn.js → cli-3ypk9vk1.js} +1 -1
- package/dist/{cli-qxnf8z2z.js → cli-436532ck.js} +2 -2
- package/dist/{cli-z8eh3ex8.js → cli-4necwtsv.js} +4 -4
- package/dist/{cli-zh3fp8v2.js → cli-54t00gt8.js} +1 -1
- package/dist/{cli-hf6zt5m6.js → cli-69szn7w7.js} +17 -1
- package/dist/{cli-nn4d8dne.js → cli-89knwags.js} +2 -2
- package/dist/{cli-spknvxbq.js → cli-8bc1w0tw.js} +10 -10
- package/dist/{cli-rqkxrmgw.js → cli-8snvgs5r.js} +38 -13
- package/dist/{cli-rhw40jgb.js → cli-bjb3z51z.js} +2 -2
- package/dist/{cli-xtjhfmpc.js → cli-c60vetmm.js} +1 -1
- package/dist/{cli-0731hvbw.js → cli-decfb6v8.js} +2 -2
- package/dist/{cli-bhjt02p8.js → cli-drr5v6av.js} +1 -1
- package/dist/{cli-fqzx7gwa.js → cli-dxae2yg7.js} +2 -2
- package/dist/{cli-tqgg40ek.js → cli-e3r2neck.js} +8 -7
- package/dist/{cli-zppwg9p9.js → cli-ekwks2vs.js} +1 -1
- package/dist/{cli-nzxr556s.js → cli-es6va8jk.js} +26 -26
- package/dist/{cli-a47xy8eq.js → cli-faxe6thg.js} +1 -1
- package/dist/cli-gdhpcbhf.js +55 -0
- package/dist/{cli-82jg7fp9.js → cli-he5nxaa8.js} +1 -1
- package/dist/{cli-8veytvbh.js → cli-he9wchme.js} +1 -1
- package/dist/{cli-pywf3eh5.js → cli-hgaazk69.js} +1 -1
- package/dist/{cli-0bxqnvq9.js → cli-hr2e2fft.js} +28 -6
- package/dist/{cli-1ayk1eas.js → cli-k2gzwsj2.js} +135 -26
- package/dist/{cli-xbkdm710.js → cli-kqdg1bsb.js} +3 -3
- package/dist/cli-m2z8jagn.js +12078 -0
- package/dist/{cli-g61qxmge.js → cli-m48g6p95.js} +3 -3
- package/dist/{cli-7wspm5gm.js → cli-nhrvpaj7.js} +20 -4
- package/dist/{cli-afrrppsw.js → cli-nwj0ee2w.js} +2 -2
- package/dist/{cli-3h4nhjn8.js → cli-p5gp8pcx.js} +9 -7
- package/dist/{cli-rm6hqj3z.js → cli-pd7vagab.js} +33 -139
- package/dist/{cli-mjzynrse.js → cli-q0k1w5zd.js} +1 -1
- package/dist/{cli-8hs41zy2.js → cli-rmmmrjkd.js} +1 -1
- package/dist/{cli-kg8hchyg.js → cli-sa02jsqt.js} +1 -1
- package/dist/{cli-1338796d.js → cli-shpbx5ee.js} +142 -98
- package/dist/{cli-82ae98pz.js → cli-svj5090z.js} +2 -2
- package/dist/{cli-bnz7a7qf.js → cli-vvpx3gsx.js} +1 -1
- package/dist/{cli-mmwm7zbf.js → cli-w6dt9ged.js} +1 -1
- package/dist/{cli-wvaawacd.js → cli-waqbxg08.js} +5230 -66
- package/dist/{cli-j3jvnpe8.js → cli-wp9sp1qb.js} +1 -1
- package/dist/{cli-nmbmy64z.js → cli-xbbndvjy.js} +3 -3
- package/dist/{cli-vbyfwh92.js → cli-xds5f77d.js} +2 -2
- package/dist/{cli-7wcyk2s5.js → cli-xnqgpshy.js} +1 -1
- package/dist/{cli-rpm2sgv0.js → cli-xnrwazav.js} +19 -2
- package/dist/{cli-gf5hbmdr.js → cli-yjdgea32.js} +3 -3
- package/dist/{cli-mry0qzym.js → cli-yn4kxs06.js} +123 -10
- package/dist/{cli-hn9hxmz9.js → cli-yx4kfngt.js} +1 -1
- package/dist/{cli-y24sc29k.js → cli-yy3rhsdw.js} +30 -8
- package/dist/{cli-6s7vdcta.js → cli-zbbwez0r.js} +4 -4
- package/dist/{cli-z6jkx23q.js → cli-zm72anhg.js} +9 -9
- package/dist/cli.js +22 -21
- package/dist/{codex-adapter-q6k3gnyg.js → codex-adapter-ayd1fb6h.js} +2 -2
- package/dist/{codex-session-runner-3mwmk3d9.js → codex-session-runner-jesa32xc.js} +2 -2
- package/dist/{commands-evrenjn9.js → commands-hanewgf2.js} +9 -3
- package/dist/{controller-xjp8vswh.js → controller-dt1n3c1q.js} +8 -3
- package/dist/{controllers-connect-pp5jnxvc.js → controllers-connect-xx8x64n5.js} +20 -19
- package/dist/{cursor-adapter-yf47w4t0.js → cursor-adapter-9s4dwwdw.js} +1 -1
- package/dist/{db-zxpw6aht.js → db-3vttcbv4.js} +3 -3
- package/dist/{db-rgfsh91f.js → db-9dv0g1ab.js} +11 -3
- package/dist/{devtools-82fzqra8.js → devtools-qxfgbsqz.js} +1 -1
- package/dist/{dispatcher-smasgws7.js → dispatcher-tx9hd1sv.js} +17 -16
- package/dist/{docker-rrjhaqt9.js → docker-c1a3gqmf.js} +89 -22
- package/dist/{dsh-adapter-ftyy8dnp.js → dsh-adapter-007y4ejs.js} +1 -1
- package/dist/{e2b-qcaj675y.js → e2b-a19d28rz.js} +2 -2
- package/dist/{e2b-w1p0bnpm.js → e2b-we6hs6q5.js} +4 -4
- package/dist/{easter-egg-3d-yyts7p16.js → easter-egg-3d-rgbrqb8s.js} +1 -1
- package/dist/{embedding-space-1z0mbg95.js → embedding-space-ny1e2940.js} +6 -6
- package/dist/{embeddings-ygeg7tm7.js → embeddings-2t386t13.js} +1 -1
- package/dist/{execute-14qhqp4d.js → execute-pksh0ceh.js} +1 -1
- package/dist/{external-channel-ttgrs3sx.js → external-channel-phgmhmd7.js} +2 -2
- package/dist/{fx-adapter-gt6pncj2.js → fx-adapter-fy8rr921.js} +5 -5
- package/dist/{google-generative-ai-yvmdxyxa.js → google-generative-ai-8y3m3k4b.js} +1 -1
- package/dist/{google-vertex-jrtdh9gs.js → google-vertex-w3v98n7b.js} +1 -1
- package/dist/{grok-adapter-sm4m5k4g.js → grok-adapter-q0abvpaj.js} +5 -5
- package/dist/handlers-by3sfxyx.js +32 -0
- package/dist/{heartbeat-qahz4p62.js → heartbeat-kadyek8p.js} +20 -19
- package/dist/{hook-kj3d398m.js → hook-5zs3msf6.js} +2 -2
- package/dist/{hook-4fd5wq5w.js → hook-9k551xnj.js} +2 -2
- package/dist/{http-1ted0j1k.js → http-mhz9vw1f.js} +213 -80
- package/dist/index-4f2pvxae.js +37 -0
- package/dist/index-98gz7tmp.js +30 -0
- package/dist/{index-5rk6rfzr.js → index-fvzke5kx.js} +1 -1
- package/dist/index-k08z2cak.js +33 -0
- package/dist/{index-yqhz88yy.js → index-pxn30mse.js} +8 -8
- package/dist/{index-6rq3r5zb.js → index-q361cg2f.js} +1 -1
- package/dist/{index-7v51awbn.js → index-rvr00sg7.js} +20 -13
- package/dist/{index-q4b917zs.js → index-vdygbq10.js} +1 -1
- package/dist/{keepalive-6cf311t5.js → keepalive-w56f32cg.js} +3 -3
- package/dist/{lead-fjy418cw.js → lead-enq35nqp.js} +31 -30
- package/dist/{maintenance-a4bm1bmt.js → maintenance-7mdgxcea.js} +1 -1
- package/dist/{oauth-refresh-sweep-3h0dfw1k.js → oauth-refresh-sweep-29txy9vk.js} +2 -2
- package/dist/{onboard-myn5hraa.js → onboard-kpsrkarj.js} +4 -4
- package/dist/{opencode-adapter-p2nkb5am.js → opencode-adapter-j25vm3rr.js} +3 -3
- package/dist/{otel-impl-a1a0ef6b.js → otel-impl-6kkct7a8.js} +1 -1
- package/dist/{pi-mono-adapter-rzmpb72a.js → pi-mono-adapter-exhkzhn2.js} +4 -4
- package/dist/{pricing-refresh-83drrnxj.js → pricing-refresh-n2x7jh6k.js} +3 -3
- package/dist/{rbac-roles-s8y6ecb5.js → rbac-roles-81ypx6es.js} +1 -1
- package/dist/{rbac-roles-0fb6e7pj.js → rbac-roles-b5htkjby.js} +2 -2
- package/dist/{render-v2-twmbgrz4.js → render-v2-qn6jmpk4.js} +3 -3
- package/dist/{resume-zfqc36xj.js → resume-wd30wx23.js} +6 -6
- package/dist/{runtime-qwggdpqr.js → runtime-4hsg7h60.js} +1 -1
- package/dist/{session-access-sc9pn9da.js → session-access-5qvfevhk.js} +4 -4
- package/dist/{session-source-backfill-qh07xr8g.js → session-source-backfill-n1czavbr.js} +2 -2
- package/dist/{setup-4fr0m7a1.js → setup-dnb56qy5.js} +3 -3
- package/dist/{virtual-modules-fh4ha15b.js → virtual-modules-76xxv9fs.js} +2 -2
- package/dist/{work-objects-0wr8zxct.js → work-objects-4n21tfkm.js} +20 -19
- package/dist/{worker-follow-up-ktyyazyp.js → worker-follow-up-77hvzxww.js} +17 -16
- package/dist/{worker-0c5tyzqe.js → worker-gg1576j3.js} +31 -30
- package/openapi.json +93 -1
- package/package.json +8 -7
- package/src/be/db/script-runs.ts +23 -0
- package/src/be/db/tasks/read.ts +122 -3
- package/src/be/db-client.ts +8 -5
- package/src/be/db.ts +15 -4
- package/src/be/memory/providers/sqlite-store.ts +49 -12
- package/src/be/migrations/260_runtime_pool_cache.sql +20 -0
- package/src/be/migrations/262_session_visibility_indexes.sql +18 -0
- package/src/be/migrations/263_task_list_filter_index.sql +11 -0
- package/src/be/migrations/264_slack_thread_cover_index.sql +9 -0
- package/src/be/migrations/266_script_runs_source_task.sql +11 -0
- package/src/be/runtime-pools/cache-cleanup.ts +109 -0
- package/src/be/runtime-pools/db.ts +65 -6
- package/src/be/runtime-pools/remote-controller.ts +5 -0
- package/src/be/runtime-pools/supervisor.ts +33 -2
- package/src/be/scripts/typecheck.ts +22 -0
- package/src/be/seed-scripts/catalog/task-failure-audit.ts +5 -1
- package/src/commands/controller.ts +4 -0
- package/src/commands/entrypoint-api-readiness.ts +74 -0
- package/src/http/index.ts +1 -1
- package/src/http/list-total-cache.ts +14 -7
- package/src/http/memory.ts +38 -9
- package/src/http/script-runs.ts +174 -5
- package/src/http/status.ts +10 -2
- package/src/http/tasks.ts +4 -2
- package/src/providers/amp-adapter.ts +1 -1
- package/src/providers/fx-adapter.ts +1 -1
- package/src/runtime-providers/controller-protocol.ts +14 -1
- package/src/runtime-providers/controller.ts +5 -0
- package/src/runtime-providers/docker.ts +108 -23
- package/src/runtime-providers/types.ts +16 -0
- package/src/script-workflows/workflow-ctx.ts +8 -0
- package/src/scripts-runtime/types/stdlib.d.ts +22 -0
- package/src/scripts-runtime/types/swarm-sdk.d.ts +22 -0
- package/src/server-user.ts +1 -0
- package/src/slack/commands.ts +5 -1
- package/src/slack/handlers.ts +37 -2
- package/src/slack/left-threads.ts +27 -4
- package/src/tasks/follow-up-redelegation-guard.ts +155 -0
- package/src/tests/claude-artifacts-read-script.test.ts +209 -0
- package/src/tests/db-client.test.ts +21 -0
- package/src/tests/db-task-read-contract.test.ts +8 -2
- package/src/tests/db-task-write-contract.test.ts +5 -1
- package/src/tests/entrypoint-api-readiness.test.ts +416 -210
- package/src/tests/explicit-model-validation.test.ts +14 -8
- package/src/tests/follow-up-redelivery-guard.test.ts +432 -202
- package/src/tests/list-total-cache.test.ts +27 -2
- package/src/tests/memory-fts-populate.test.ts +11 -9
- package/src/tests/memory-retrieval-purge.test.ts +80 -0
- package/src/tests/migration-260-runtime-pool-cache.test.ts +118 -0
- package/src/tests/query-audit-plans.test.ts +27 -0
- package/src/tests/runtime-cache-cleanup.test.ts +367 -0
- package/src/tests/runtime-e2b-pools.test.ts +41 -0
- package/src/tests/runtime-pools-db.test.ts +98 -0
- package/src/tests/runtime-pools-http.test.ts +29 -0
- package/src/tests/runtime-providers-docker.test.ts +253 -0
- package/src/tests/runtime-remote-controller.test.ts +66 -2
- package/src/tests/runtime-supervisor.test.ts +66 -2
- package/src/tests/script-connections.test.ts +11 -0
- package/src/tests/script-runs-http.test.ts +684 -2
- package/src/tests/seed-scripts.test.ts +26 -0
- package/src/tests/slack-leave-thread.test.ts +145 -5
- package/src/tests/slack-render-v2-query-plans.test.ts +24 -2
- package/src/tests/status.test.ts +11 -0
- package/src/tests/tasks-readable-row.test.ts +155 -0
- package/src/tools/send-task.ts +35 -47
- package/src/tools/slack-leave-thread.ts +1 -1
- package/src/tools/task-dedup.ts +45 -21
- package/src/types.ts +38 -0
- package/templates/skills/composio-google-docs/content.md +10 -0
- package/templates/skills/script-workflows/content.md +19 -1
- package/templates/skills/swarm-docs/content.md +1 -0
- package/templates/skills/swarm-scripts/SKILL.md +2 -0
- package/templates/skills/swarm-scripts/content.md +2 -0
- package/dist/cli-dznrgaep.js +0 -30
- package/dist/cli-w3hcrxht.js +0 -6985
- package/dist/handlers-vwmba1m2.js +0 -31
- package/dist/index-5r71rf98.js +0 -32
- package/dist/index-anmwxs87.js +0 -29
- package/dist/index-spp0ra5c.js +0 -36
|
@@ -6,16 +6,16 @@ import {
|
|
|
6
6
|
use_app_default,
|
|
7
7
|
Spinner,
|
|
8
8
|
TextInput
|
|
9
|
-
} from "./cli-
|
|
9
|
+
} from "./cli-he5nxaa8.js";
|
|
10
10
|
import {
|
|
11
11
|
require_jsx_dev_runtime
|
|
12
|
-
} from "./cli-
|
|
12
|
+
} from "./cli-sa02jsqt.js";
|
|
13
13
|
import {
|
|
14
14
|
SERVER_NAME,
|
|
15
15
|
createDefaultSettingsLocal,
|
|
16
16
|
createDefaultMcpJson,
|
|
17
17
|
createHooksConfig
|
|
18
|
-
} from "./cli-
|
|
18
|
+
} from "./cli-0yv5z2pg.js";
|
|
19
19
|
import {
|
|
20
20
|
getApiKey,
|
|
21
21
|
init_api_key
|
|
@@ -2,7 +2,7 @@ import {
|
|
|
2
2
|
exports_dist,
|
|
3
3
|
exports_dist2,
|
|
4
4
|
exports_dist3
|
|
5
|
-
} from "./cli-
|
|
5
|
+
} from "./cli-0at8w34w.js";
|
|
6
6
|
import {
|
|
7
7
|
exports_build,
|
|
8
8
|
init_build,
|
|
@@ -14,7 +14,7 @@ import {
|
|
|
14
14
|
init_all,
|
|
15
15
|
exports_compat,
|
|
16
16
|
init_compat
|
|
17
|
-
} from "./cli-
|
|
17
|
+
} from "./cli-436532ck.js";
|
|
18
18
|
import {
|
|
19
19
|
exports_models,
|
|
20
20
|
init_models2
|
|
@@ -2,11 +2,11 @@ import {
|
|
|
2
2
|
getAgentById2,
|
|
3
3
|
getTaskById2,
|
|
4
4
|
init_db4
|
|
5
|
-
} from "./cli-
|
|
5
|
+
} from "./cli-k2gzwsj2.js";
|
|
6
6
|
import {
|
|
7
7
|
shouldBlockChannel2,
|
|
8
8
|
init_external_channel
|
|
9
|
-
} from "./cli-
|
|
9
|
+
} from "./cli-w6dt9ged.js";
|
|
10
10
|
import {
|
|
11
11
|
isAdmittedSlackDelivery,
|
|
12
12
|
init_inbound_dispatch,
|
|
@@ -14,31 +14,32 @@ import {
|
|
|
14
14
|
init_task_output,
|
|
15
15
|
getTaskUrl,
|
|
16
16
|
init_blocks
|
|
17
|
-
} from "./cli-
|
|
17
|
+
} from "./cli-waqbxg08.js";
|
|
18
18
|
import"./cli-wx3rhnm0.js";
|
|
19
|
-
import"./cli-
|
|
20
|
-
import"./cli-
|
|
21
|
-
import"./cli-
|
|
22
|
-
import"./cli-
|
|
23
|
-
import"./cli-
|
|
19
|
+
import"./cli-m48g6p95.js";
|
|
20
|
+
import"./cli-shpbx5ee.js";
|
|
21
|
+
import"./cli-rmmmrjkd.js";
|
|
22
|
+
import"./cli-zbbwez0r.js";
|
|
23
|
+
import"./cli-89knwags.js";
|
|
24
24
|
import"./cli-3xj33nrx.js";
|
|
25
|
-
import"./cli-
|
|
26
|
-
import"./cli-
|
|
25
|
+
import"./cli-yn4kxs06.js";
|
|
26
|
+
import"./cli-4necwtsv.js";
|
|
27
27
|
import {
|
|
28
28
|
isUserAllowed2,
|
|
29
29
|
init_handlers
|
|
30
|
-
} from "./cli-
|
|
30
|
+
} from "./cli-yy3rhsdw.js";
|
|
31
31
|
import {
|
|
32
32
|
wasEventSeen,
|
|
33
33
|
init_event_dedup
|
|
34
|
-
} from "./cli-
|
|
35
|
-
import"./cli-
|
|
36
|
-
import"./cli-
|
|
37
|
-
import"./cli-
|
|
38
|
-
import"./cli-
|
|
39
|
-
import"./cli-
|
|
40
|
-
import"./cli-
|
|
41
|
-
import"./cli-
|
|
34
|
+
} from "./cli-p5gp8pcx.js";
|
|
35
|
+
import"./cli-xbbndvjy.js";
|
|
36
|
+
import"./cli-c60vetmm.js";
|
|
37
|
+
import"./cli-hr2e2fft.js";
|
|
38
|
+
import"./cli-xnqgpshy.js";
|
|
39
|
+
import"./cli-8bc1w0tw.js";
|
|
40
|
+
import"./cli-gdhpcbhf.js";
|
|
41
|
+
import"./cli-hgaazk69.js";
|
|
42
|
+
import"./cli-drr5v6av.js";
|
|
42
43
|
import {
|
|
43
44
|
isEnvFlagEnabled,
|
|
44
45
|
init_env_flag
|
|
@@ -10,23 +10,24 @@ import {
|
|
|
10
10
|
createRerouteDecisionTask2,
|
|
11
11
|
createPoolStarvationDecisionTask2,
|
|
12
12
|
init_worker_follow_up
|
|
13
|
-
} from "./cli-
|
|
14
|
-
import"./cli-
|
|
15
|
-
import"./cli-
|
|
16
|
-
import"./cli-
|
|
17
|
-
import"./cli-
|
|
18
|
-
import"./cli-
|
|
13
|
+
} from "./cli-shpbx5ee.js";
|
|
14
|
+
import"./cli-zbbwez0r.js";
|
|
15
|
+
import"./cli-89knwags.js";
|
|
16
|
+
import"./cli-c60vetmm.js";
|
|
17
|
+
import"./cli-hr2e2fft.js";
|
|
18
|
+
import"./cli-xnqgpshy.js";
|
|
19
19
|
import"./cli-3xj33nrx.js";
|
|
20
|
-
import"./cli-
|
|
21
|
-
import"./cli-
|
|
22
|
-
import"./cli-
|
|
23
|
-
import"./cli-
|
|
24
|
-
import"./cli-
|
|
25
|
-
import"./cli-
|
|
26
|
-
import"./cli-
|
|
27
|
-
import"./cli-
|
|
28
|
-
import"./cli-
|
|
29
|
-
import"./cli-
|
|
20
|
+
import"./cli-4necwtsv.js";
|
|
21
|
+
import"./cli-m48g6p95.js";
|
|
22
|
+
import"./cli-8bc1w0tw.js";
|
|
23
|
+
import"./cli-waqbxg08.js";
|
|
24
|
+
import"./cli-gdhpcbhf.js";
|
|
25
|
+
import"./cli-w6dt9ged.js";
|
|
26
|
+
import"./cli-hgaazk69.js";
|
|
27
|
+
import"./cli-yn4kxs06.js";
|
|
28
|
+
import"./cli-drr5v6av.js";
|
|
29
|
+
import"./cli-rmmmrjkd.js";
|
|
30
|
+
import"./cli-k2gzwsj2.js";
|
|
30
31
|
import"./cli-wx3rhnm0.js";
|
|
31
32
|
init_worker_follow_up();
|
|
32
33
|
|
|
@@ -1,57 +1,58 @@
|
|
|
1
|
-
import"./cli-
|
|
2
|
-
import"./cli-
|
|
3
|
-
import"./cli-
|
|
4
|
-
import"./cli-
|
|
1
|
+
import"./cli-k2gzwsj2.js";
|
|
2
|
+
import"./cli-rmmmrjkd.js";
|
|
3
|
+
import"./cli-zbbwez0r.js";
|
|
4
|
+
import"./cli-89knwags.js";
|
|
5
5
|
import"./cli-wx3rhnm0.js";
|
|
6
|
-
import"./cli-
|
|
7
|
-
import"./cli-
|
|
8
|
-
import"./cli-
|
|
6
|
+
import"./cli-w6dt9ged.js";
|
|
7
|
+
import"./cli-waqbxg08.js";
|
|
8
|
+
import"./cli-m48g6p95.js";
|
|
9
9
|
import {
|
|
10
10
|
getEnabledCapabilities,
|
|
11
11
|
init_server
|
|
12
|
-
} from "./cli-
|
|
12
|
+
} from "./cli-shpbx5ee.js";
|
|
13
13
|
import"./cli-3xj33nrx.js";
|
|
14
|
-
import"./cli-
|
|
15
|
-
import"./cli-
|
|
16
|
-
import"./cli-
|
|
14
|
+
import"./cli-yn4kxs06.js";
|
|
15
|
+
import"./cli-4necwtsv.js";
|
|
16
|
+
import"./cli-bjb3z51z.js";
|
|
17
17
|
import"./cli-ftyxyspd.js";
|
|
18
18
|
import {
|
|
19
19
|
runAgent
|
|
20
|
-
} from "./cli-
|
|
20
|
+
} from "./cli-es6va8jk.js";
|
|
21
21
|
import"./cli-98rw5dt5.js";
|
|
22
22
|
import"./cli-77cd6gy8.js";
|
|
23
23
|
import"./cli-mthwvjre.js";
|
|
24
24
|
import"./cli-a22h291q.js";
|
|
25
25
|
import"./cli-dhar9qay.js";
|
|
26
26
|
import"./cli-jc1g9ndz.js";
|
|
27
|
-
import"./cli-
|
|
27
|
+
import"./cli-nwj0ee2w.js";
|
|
28
28
|
import"./cli-jm2vfpfd.js";
|
|
29
|
-
import"./cli-
|
|
29
|
+
import"./cli-faxe6thg.js";
|
|
30
30
|
import"./cli-d82btycs.js";
|
|
31
31
|
import"./cli-0726awxw.js";
|
|
32
|
-
import"./cli-
|
|
33
|
-
import"./cli-
|
|
32
|
+
import"./cli-decfb6v8.js";
|
|
33
|
+
import"./cli-svj5090z.js";
|
|
34
34
|
import"./cli-4bd1rck6.js";
|
|
35
35
|
import"./cli-98rwmcyc.js";
|
|
36
36
|
import"./cli-318r69gq.js";
|
|
37
37
|
import"./cli-vfym7wmz.js";
|
|
38
38
|
import"./cli-kr5tjjtz.js";
|
|
39
|
-
import"./cli-
|
|
40
|
-
import"./cli-
|
|
39
|
+
import"./cli-0qatpy8q.js";
|
|
40
|
+
import"./cli-wp9sp1qb.js";
|
|
41
41
|
import"./cli-srye3vdt.js";
|
|
42
|
-
import"./cli-
|
|
43
|
-
import"./cli-
|
|
44
|
-
import"./cli-
|
|
45
|
-
import"./cli-
|
|
46
|
-
import"./cli-
|
|
47
|
-
import"./cli-
|
|
42
|
+
import"./cli-vvpx3gsx.js";
|
|
43
|
+
import"./cli-pd7vagab.js";
|
|
44
|
+
import"./cli-yx4kfngt.js";
|
|
45
|
+
import"./cli-ekwks2vs.js";
|
|
46
|
+
import"./cli-54t00gt8.js";
|
|
47
|
+
import"./cli-3ypk9vk1.js";
|
|
48
48
|
import"./cli-4zsenjhy.js";
|
|
49
|
-
import"./cli-
|
|
50
|
-
import"./cli-
|
|
51
|
-
import"./cli-
|
|
52
|
-
import"./cli-
|
|
53
|
-
import"./cli-
|
|
54
|
-
import"./cli-
|
|
49
|
+
import"./cli-c60vetmm.js";
|
|
50
|
+
import"./cli-hr2e2fft.js";
|
|
51
|
+
import"./cli-xnqgpshy.js";
|
|
52
|
+
import"./cli-8bc1w0tw.js";
|
|
53
|
+
import"./cli-gdhpcbhf.js";
|
|
54
|
+
import"./cli-hgaazk69.js";
|
|
55
|
+
import"./cli-drr5v6av.js";
|
|
55
56
|
|
|
56
57
|
// src/commands/worker.ts
|
|
57
58
|
init_server();
|
package/openapi.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"openapi": "3.1.0",
|
|
3
3
|
"info": {
|
|
4
4
|
"title": "Agent Swarm API",
|
|
5
|
-
"version": "2.7.
|
|
5
|
+
"version": "2.7.6",
|
|
6
6
|
"description": "Multi-agent orchestration API for Claude Code, Codex, and Gemini CLI. Enables task distribution, agent communication, and service discovery.\n\nMCP tools are documented separately in [MCP.md](./MCP.md)."
|
|
7
7
|
},
|
|
8
8
|
"servers": [
|
|
@@ -3810,6 +3810,9 @@
|
|
|
3810
3810
|
},
|
|
3811
3811
|
"requestedByUserId": {
|
|
3812
3812
|
"type": "string"
|
|
3813
|
+
},
|
|
3814
|
+
"sourceTaskId": {
|
|
3815
|
+
"type": "string"
|
|
3813
3816
|
}
|
|
3814
3817
|
},
|
|
3815
3818
|
"required": [
|
|
@@ -6124,6 +6127,23 @@
|
|
|
6124
6127
|
"default": null,
|
|
6125
6128
|
"additionalProperties": false
|
|
6126
6129
|
},
|
|
6130
|
+
"cache": {
|
|
6131
|
+
"type": [
|
|
6132
|
+
"object",
|
|
6133
|
+
"null"
|
|
6134
|
+
],
|
|
6135
|
+
"properties": {
|
|
6136
|
+
"mountPath": {
|
|
6137
|
+
"type": "string",
|
|
6138
|
+
"minLength": 2
|
|
6139
|
+
}
|
|
6140
|
+
},
|
|
6141
|
+
"default": null,
|
|
6142
|
+
"required": [
|
|
6143
|
+
"mountPath"
|
|
6144
|
+
],
|
|
6145
|
+
"additionalProperties": false
|
|
6146
|
+
},
|
|
6127
6147
|
"ttlSec": {
|
|
6128
6148
|
"type": [
|
|
6129
6149
|
"integer",
|
|
@@ -30804,6 +30824,12 @@
|
|
|
30804
30824
|
"string",
|
|
30805
30825
|
"null"
|
|
30806
30826
|
]
|
|
30827
|
+
},
|
|
30828
|
+
"dashboard_url": {
|
|
30829
|
+
"type": [
|
|
30830
|
+
"string",
|
|
30831
|
+
"null"
|
|
30832
|
+
]
|
|
30807
30833
|
}
|
|
30808
30834
|
},
|
|
30809
30835
|
"required": [
|
|
@@ -49262,6 +49288,9 @@
|
|
|
49262
49288
|
"outputSchema": {
|
|
49263
49289
|
"type": "object",
|
|
49264
49290
|
"additionalProperties": {}
|
|
49291
|
+
},
|
|
49292
|
+
"allowRedelegation": {
|
|
49293
|
+
"type": "boolean"
|
|
49265
49294
|
}
|
|
49266
49295
|
},
|
|
49267
49296
|
"required": [
|
|
@@ -49333,6 +49362,16 @@
|
|
|
49333
49362
|
}
|
|
49334
49363
|
}
|
|
49335
49364
|
},
|
|
49365
|
+
"403": {
|
|
49366
|
+
"description": "Script run belongs to another agent, or the run's agent may not create a child task under parentTaskId",
|
|
49367
|
+
"content": {
|
|
49368
|
+
"application/json": {
|
|
49369
|
+
"schema": {
|
|
49370
|
+
"$ref": "#/components/schemas/ErrorResponse"
|
|
49371
|
+
}
|
|
49372
|
+
}
|
|
49373
|
+
}
|
|
49374
|
+
},
|
|
49336
49375
|
"404": {
|
|
49337
49376
|
"description": "Script run not found",
|
|
49338
49377
|
"content": {
|
|
@@ -49342,6 +49381,26 @@
|
|
|
49342
49381
|
}
|
|
49343
49382
|
}
|
|
49344
49383
|
}
|
|
49384
|
+
},
|
|
49385
|
+
"409": {
|
|
49386
|
+
"description": "Agent task failed, was cancelled, or was superseded",
|
|
49387
|
+
"content": {
|
|
49388
|
+
"application/json": {
|
|
49389
|
+
"schema": {
|
|
49390
|
+
"$ref": "#/components/schemas/ErrorResponse"
|
|
49391
|
+
}
|
|
49392
|
+
}
|
|
49393
|
+
}
|
|
49394
|
+
},
|
|
49395
|
+
"422": {
|
|
49396
|
+
"description": "Blocked by the follow-up re-delegation guard",
|
|
49397
|
+
"content": {
|
|
49398
|
+
"application/json": {
|
|
49399
|
+
"schema": {
|
|
49400
|
+
"$ref": "#/components/schemas/ErrorResponse"
|
|
49401
|
+
}
|
|
49402
|
+
}
|
|
49403
|
+
}
|
|
49345
49404
|
}
|
|
49346
49405
|
}
|
|
49347
49406
|
}
|
|
@@ -66136,6 +66195,23 @@
|
|
|
66136
66195
|
"default": null,
|
|
66137
66196
|
"additionalProperties": false
|
|
66138
66197
|
},
|
|
66198
|
+
"cache": {
|
|
66199
|
+
"type": [
|
|
66200
|
+
"object",
|
|
66201
|
+
"null"
|
|
66202
|
+
],
|
|
66203
|
+
"properties": {
|
|
66204
|
+
"mountPath": {
|
|
66205
|
+
"type": "string",
|
|
66206
|
+
"minLength": 2
|
|
66207
|
+
}
|
|
66208
|
+
},
|
|
66209
|
+
"default": null,
|
|
66210
|
+
"required": [
|
|
66211
|
+
"mountPath"
|
|
66212
|
+
],
|
|
66213
|
+
"additionalProperties": false
|
|
66214
|
+
},
|
|
66139
66215
|
"ttlSec": {
|
|
66140
66216
|
"type": [
|
|
66141
66217
|
"integer",
|
|
@@ -66418,6 +66494,22 @@
|
|
|
66418
66494
|
},
|
|
66419
66495
|
"additionalProperties": false
|
|
66420
66496
|
},
|
|
66497
|
+
"cache": {
|
|
66498
|
+
"type": [
|
|
66499
|
+
"object",
|
|
66500
|
+
"null"
|
|
66501
|
+
],
|
|
66502
|
+
"properties": {
|
|
66503
|
+
"mountPath": {
|
|
66504
|
+
"type": "string",
|
|
66505
|
+
"minLength": 2
|
|
66506
|
+
}
|
|
66507
|
+
},
|
|
66508
|
+
"required": [
|
|
66509
|
+
"mountPath"
|
|
66510
|
+
],
|
|
66511
|
+
"additionalProperties": false
|
|
66512
|
+
},
|
|
66421
66513
|
"ttlSec": {
|
|
66422
66514
|
"type": [
|
|
66423
66515
|
"integer",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@desplega.ai/agent-swarm",
|
|
3
|
-
"version": "2.7.
|
|
3
|
+
"version": "2.7.6",
|
|
4
4
|
"description": "agent-swarm.dev — an open-source operating system for AI work: a lead agent breaks goals into tasks, routes them to specialized workers such as Claude Code or Codex, runs each worker in an isolated container, and preserves shared memory, tools, schedules, and review gates so delegated work compounds across sessions.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"agent-swarm.dev",
|
|
@@ -62,6 +62,7 @@
|
|
|
62
62
|
"packages/*"
|
|
63
63
|
],
|
|
64
64
|
"overrides": {
|
|
65
|
+
"@slack/socket-mode": "^2.0.7",
|
|
65
66
|
"react": "19.2.3",
|
|
66
67
|
"react-dom": "19.2.3"
|
|
67
68
|
},
|
|
@@ -178,12 +179,12 @@
|
|
|
178
179
|
},
|
|
179
180
|
"devDependencies": {
|
|
180
181
|
"@biomejs/biome": "^2.3.10",
|
|
181
|
-
"@desplega.ai/slack-mock": "^0.
|
|
182
|
+
"@desplega.ai/slack-mock": "^0.5.0",
|
|
182
183
|
"@desplega/model-catalog": "workspace:*",
|
|
183
184
|
"@desplega/model-routing": "workspace:*",
|
|
184
185
|
"@faker-js/faker": "^10.4.0",
|
|
185
|
-
"@opencode/plugin": "2.2.
|
|
186
|
-
"@opencode/sdk": "2.2.
|
|
186
|
+
"@opencode/plugin": "2.2.3",
|
|
187
|
+
"@opencode/sdk": "2.2.3",
|
|
187
188
|
"@oxlint/plugins": "1.78.0",
|
|
188
189
|
"@types/bun": "latest",
|
|
189
190
|
"dependency-cruiser": "^18.0.0",
|
|
@@ -201,9 +202,9 @@
|
|
|
201
202
|
"bun": ">=1.3.12"
|
|
202
203
|
},
|
|
203
204
|
"dependencies": {
|
|
204
|
-
"@agentclientprotocol/sdk": "2.
|
|
205
|
+
"@agentclientprotocol/sdk": "2.2.0",
|
|
205
206
|
"@ai-sdk/openai": "^3.0.41",
|
|
206
|
-
"@anthropic-ai/claude-agent-sdk": "0.3.
|
|
207
|
+
"@anthropic-ai/claude-agent-sdk": "0.3.314",
|
|
207
208
|
"@anthropic-ai/sdk": "^1.3.0",
|
|
208
209
|
"@asteasolutions/zod-to-openapi": "^8.0.0",
|
|
209
210
|
"@aws-sdk/client-bedrock": "3.1048.0",
|
|
@@ -222,7 +223,7 @@
|
|
|
222
223
|
"@jitl/quickjs-singlefile-mjs-release-sync": "0.32.0",
|
|
223
224
|
"@linear/sdk": "^77.0.0",
|
|
224
225
|
"@modelcontextprotocol/sdk": "1.32.1",
|
|
225
|
-
"@openai/codex": "0.
|
|
226
|
+
"@openai/codex": "0.166.0",
|
|
226
227
|
"@openfort/openfort-node": "^0.9.1",
|
|
227
228
|
"@opentelemetry/api": "^1.9.1",
|
|
228
229
|
"@opentelemetry/api-logs": "^0.218.0",
|
package/src/be/db/script-runs.ts
CHANGED
|
@@ -13,3 +13,26 @@ export async function getScriptRunExecutionArgs(id: string): Promise<unknown> {
|
|
|
13
13
|
);
|
|
14
14
|
return row ? openSealedJson(row.args) : undefined;
|
|
15
15
|
}
|
|
16
|
+
|
|
17
|
+
/** A durable run's follow-up re-delegation guard decision (see migration 266). */
|
|
18
|
+
export type ScriptRunFollowUpGuard = "passed" | "same-work" | "loop-cap";
|
|
19
|
+
|
|
20
|
+
export async function getScriptRunFollowUpGuard(
|
|
21
|
+
runId: string,
|
|
22
|
+
): Promise<ScriptRunFollowUpGuard | null> {
|
|
23
|
+
const row = await getDbClient().get<{ followUpGuard: ScriptRunFollowUpGuard | null }>(
|
|
24
|
+
"SELECT followUpGuard FROM script_runs WHERE id = ?",
|
|
25
|
+
[runId],
|
|
26
|
+
);
|
|
27
|
+
return row?.followUpGuard ?? null;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export async function setScriptRunFollowUpGuard(
|
|
31
|
+
runId: string,
|
|
32
|
+
decision: ScriptRunFollowUpGuard,
|
|
33
|
+
): Promise<void> {
|
|
34
|
+
await getDbClient().run("UPDATE script_runs SET followUpGuard = ? WHERE id = ?", [
|
|
35
|
+
decision,
|
|
36
|
+
runId,
|
|
37
|
+
]);
|
|
38
|
+
}
|
package/src/be/db/tasks/read.ts
CHANGED
|
@@ -869,6 +869,52 @@ export function readableSessionCondition(
|
|
|
869
869
|
};
|
|
870
870
|
}
|
|
871
871
|
|
|
872
|
+
/** Parent hops the row-at-a-time walk takes before it falls back to the set form. */
|
|
873
|
+
const READABLE_WALK_MAX_DEPTH = 64;
|
|
874
|
+
|
|
875
|
+
/**
|
|
876
|
+
* The row-at-a-time form of {@link readableSessionCondition}, for a query that
|
|
877
|
+
* stops at a LIMIT. It walks up from each row it tests to the root, so a page
|
|
878
|
+
* costs a few key lookups per row instead of the set of every hidden task,
|
|
879
|
+
* which on a large DB took hundreds of milliseconds per request. The rule is
|
|
880
|
+
* the same: the root is the first task whose parent is null or missing. A row
|
|
881
|
+
* whose walk finds no root within {@link READABLE_WALK_MAX_DEPTH} hops (a very
|
|
882
|
+
* deep chain, or a parent cycle written before migration 253) falls back to
|
|
883
|
+
* the set form, which SQLite then builds once for the statement. A count reads
|
|
884
|
+
* every row, so it keeps the set form.
|
|
885
|
+
*/
|
|
886
|
+
function readableSessionRowCondition(
|
|
887
|
+
userId: string | null,
|
|
888
|
+
taskIdColumn = "agent_tasks.id",
|
|
889
|
+
): { sql: string; params: string[] } {
|
|
890
|
+
const otherOwner = userId
|
|
891
|
+
? "up.requestedByUserId IS NOT NULL AND up.requestedByUserId != ?"
|
|
892
|
+
: "up.requestedByUserId IS NOT NULL";
|
|
893
|
+
const shareMatch = userId ? "(s.userId IS NULL OR s.userId = ?)" : "s.userId IS NULL";
|
|
894
|
+
const set = readableSessionCondition(userId, taskIdColumn);
|
|
895
|
+
return {
|
|
896
|
+
sql: `(CASE (
|
|
897
|
+
WITH RECURSIVE up(id, parentTaskId, requestedByUserId, scheduleId, depth) AS (
|
|
898
|
+
SELECT u.id, u.parentTaskId, u.requestedByUserId, u.scheduleId, 0
|
|
899
|
+
FROM agent_tasks u WHERE u.id = ${taskIdColumn}
|
|
900
|
+
UNION ALL
|
|
901
|
+
SELECT p.id, p.parentTaskId, p.requestedByUserId, p.scheduleId, up.depth + 1
|
|
902
|
+
FROM up JOIN agent_tasks p ON p.id = up.parentTaskId
|
|
903
|
+
WHERE up.depth < ${READABLE_WALK_MAX_DEPTH}
|
|
904
|
+
)
|
|
905
|
+
SELECT CASE WHEN ${otherOwner} AND up.scheduleId IS NULL
|
|
906
|
+
AND NOT EXISTS (SELECT 1 FROM session_shares s
|
|
907
|
+
WHERE s.rootTaskId = up.id AND s.revokedAt IS NULL AND ${shareMatch})
|
|
908
|
+
THEN 1 ELSE 0 END
|
|
909
|
+
FROM up
|
|
910
|
+
WHERE up.parentTaskId IS NULL
|
|
911
|
+
OR NOT EXISTS (SELECT 1 FROM agent_tasks p WHERE p.id = up.parentTaskId)
|
|
912
|
+
LIMIT 1
|
|
913
|
+
) WHEN 0 THEN 1 WHEN 1 THEN 0 ELSE ${set.sql} END)`,
|
|
914
|
+
params: [...(userId ? [userId, userId] : []), ...set.params],
|
|
915
|
+
};
|
|
916
|
+
}
|
|
917
|
+
|
|
872
918
|
export function getAllTasks(filters?: TaskFilters): Promise<AgentTask[]>;
|
|
873
919
|
export function getAllTasks(
|
|
874
920
|
filters: TaskFilters | undefined,
|
|
@@ -988,7 +1034,8 @@ export async function getAllTasks(
|
|
|
988
1034
|
}
|
|
989
1035
|
|
|
990
1036
|
if (filters?.readableBy) {
|
|
991
|
-
|
|
1037
|
+
// The page stops at LIMIT, so test only the rows it reads.
|
|
1038
|
+
const readable = readableSessionRowCondition(filters.readableBy.userId);
|
|
992
1039
|
conditions.push(readable.sql);
|
|
993
1040
|
params.push(...readable.params);
|
|
994
1041
|
}
|
|
@@ -1865,7 +1912,44 @@ export async function getMostRecentTaskInThread(
|
|
|
1865
1912
|
return row ? rowToAgentTask(row) : null;
|
|
1866
1913
|
}
|
|
1867
1914
|
|
|
1868
|
-
|
|
1915
|
+
/**
|
|
1916
|
+
* One page of completed tasks in a Slack thread, most recent first. Lead
|
|
1917
|
+
* `follow-up` sessions are excluded: they coordinate the work, they are not the
|
|
1918
|
+
* work, so they never count as "the request was already handled". The caller
|
|
1919
|
+
* matches descriptions in JS, so it pages through the whole window with the
|
|
1920
|
+
* `before` keyset cursor (the last row of the previous page) instead of
|
|
1921
|
+
* loading every row in one query.
|
|
1922
|
+
*/
|
|
1923
|
+
export async function findCompletedTasksInThread(
|
|
1924
|
+
channelId: string,
|
|
1925
|
+
threadTs: string,
|
|
1926
|
+
windowMinutes: number,
|
|
1927
|
+
limit = 200,
|
|
1928
|
+
before?: { lastUpdatedAt: string; id: string },
|
|
1929
|
+
): Promise<AgentTask[]> {
|
|
1930
|
+
const since = new Date(Date.now() - windowMinutes * 60 * 1000).toISOString();
|
|
1931
|
+
const cursorSql = before ? "AND (lastUpdatedAt < ? OR (lastUpdatedAt = ? AND id < ?))" : "";
|
|
1932
|
+
const cursorParams = before ? [before.lastUpdatedAt, before.lastUpdatedAt, before.id] : [];
|
|
1933
|
+
const rows = await getDbClient().query<AgentTaskRow>(
|
|
1934
|
+
`SELECT * FROM agent_tasks
|
|
1935
|
+
WHERE slackChannelId = ?
|
|
1936
|
+
AND slackThreadTs = ?
|
|
1937
|
+
AND status = 'completed'
|
|
1938
|
+
AND COALESCE(taskType, '') != 'follow-up'
|
|
1939
|
+
AND lastUpdatedAt > ?
|
|
1940
|
+
${cursorSql}
|
|
1941
|
+
ORDER BY lastUpdatedAt DESC, id DESC
|
|
1942
|
+
LIMIT ?`,
|
|
1943
|
+
[channelId, threadTs, since, ...cursorParams, limit],
|
|
1944
|
+
);
|
|
1945
|
+
return rows.map(rowToAgentTask);
|
|
1946
|
+
}
|
|
1947
|
+
|
|
1948
|
+
/**
|
|
1949
|
+
* Most recent FAILED task in a Slack thread. A failure more recent than a
|
|
1950
|
+
* completion means the follow-up re-delegation guard must let a retry through.
|
|
1951
|
+
*/
|
|
1952
|
+
export async function findRecentFailedTaskInThread(
|
|
1869
1953
|
channelId: string,
|
|
1870
1954
|
threadTs: string,
|
|
1871
1955
|
windowMinutes: number,
|
|
@@ -1875,7 +1959,7 @@ export async function findCompletedTaskInThread(
|
|
|
1875
1959
|
`SELECT * FROM agent_tasks
|
|
1876
1960
|
WHERE slackChannelId = ?
|
|
1877
1961
|
AND slackThreadTs = ?
|
|
1878
|
-
AND status = '
|
|
1962
|
+
AND status = 'failed'
|
|
1879
1963
|
AND lastUpdatedAt > ?
|
|
1880
1964
|
ORDER BY lastUpdatedAt DESC
|
|
1881
1965
|
LIMIT 1`,
|
|
@@ -1884,6 +1968,41 @@ export async function findCompletedTaskInThread(
|
|
|
1884
1968
|
return row ? rowToAgentTask(row) : null;
|
|
1885
1969
|
}
|
|
1886
1970
|
|
|
1971
|
+
/**
|
|
1972
|
+
* Count the dispatches one agent made into a Slack thread since the window
|
|
1973
|
+
* start: each `send-task` task counts once, and each durable script run counts
|
|
1974
|
+
* once however many `ctx.step.agentTask` steps it created (step tasks share the
|
|
1975
|
+
* `script-run:<runId>:` contextKey prefix). A run is dated by its first step,
|
|
1976
|
+
* the dispatch the guard checked, so a run that started before the window does
|
|
1977
|
+
* not count again for steps it adds later. The follow-up re-delegation loop cap
|
|
1978
|
+
* reads this.
|
|
1979
|
+
*/
|
|
1980
|
+
export async function countAgentDispatchesInThread(
|
|
1981
|
+
channelId: string,
|
|
1982
|
+
threadTs: string,
|
|
1983
|
+
creatorAgentId: string,
|
|
1984
|
+
windowMinutes: number,
|
|
1985
|
+
): Promise<number> {
|
|
1986
|
+
const since = new Date(Date.now() - windowMinutes * 60 * 1000).toISOString();
|
|
1987
|
+
const row = await getDbClient().get<{ c: number }>(
|
|
1988
|
+
`SELECT COUNT(*) AS c FROM (
|
|
1989
|
+
SELECT MIN(createdAt) AS firstAt FROM agent_tasks
|
|
1990
|
+
WHERE slackChannelId = ?
|
|
1991
|
+
AND slackThreadTs = ?
|
|
1992
|
+
AND creatorAgentId = ?
|
|
1993
|
+
AND source = 'mcp'
|
|
1994
|
+
AND (createdAt > ? OR taskType = 'script-run-step')
|
|
1995
|
+
GROUP BY CASE
|
|
1996
|
+
WHEN taskType = 'script-run-step' AND contextKey LIKE 'script-run:%:%'
|
|
1997
|
+
THEN substr(contextKey, 1, instr(substr(contextKey, 12), ':') + 10)
|
|
1998
|
+
ELSE id
|
|
1999
|
+
END
|
|
2000
|
+
) WHERE firstAt > ?`,
|
|
2001
|
+
[channelId, threadTs, creatorAgentId, since, since],
|
|
2002
|
+
);
|
|
2003
|
+
return row?.c ?? 0;
|
|
2004
|
+
}
|
|
2005
|
+
|
|
1887
2006
|
/**
|
|
1888
2007
|
* Find the most recent CANCELLED task in a Slack thread. Used by the
|
|
1889
2008
|
* follow-up re-delegation guard so a cancellation (worker SIGTERM,
|
package/src/be/db-client.ts
CHANGED
|
@@ -468,9 +468,14 @@ class BunSqliteClient implements DbClient {
|
|
|
468
468
|
if (!willRetry) warnIfSlowStatement(sql, ms);
|
|
469
469
|
}
|
|
470
470
|
};
|
|
471
|
+
// The first call opens the database and applies migrations; resolve it
|
|
472
|
+
// before the timer, so boot work is not logged as this statement's cost.
|
|
473
|
+
// Outside a transaction it resolves inside the retry loop, so a boot that
|
|
474
|
+
// hits SQLITE_BUSY boots again.
|
|
471
475
|
const ctx = txContext.getStore();
|
|
472
476
|
if (ctx && !ctx.closed) {
|
|
473
|
-
|
|
477
|
+
const db = this.getDatabase();
|
|
478
|
+
return timed(() => op(db));
|
|
474
479
|
}
|
|
475
480
|
let sleptMs = 0;
|
|
476
481
|
for (let attemptIndex = 0; ; attemptIndex++) {
|
|
@@ -482,10 +487,8 @@ class BunSqliteClient implements DbClient {
|
|
|
482
487
|
// A top-level single statement is atomic, so a repeat on BUSY is
|
|
483
488
|
// exact. The final attempt spins `finalAttemptSpinMs` (see
|
|
484
489
|
// transaction()).
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
canRetryAfter,
|
|
488
|
-
);
|
|
490
|
+
const db = this.getDatabase();
|
|
491
|
+
return timed(() => this.shortSpin(db, () => op(db), !canRetryAfter), canRetryAfter);
|
|
489
492
|
} catch (err) {
|
|
490
493
|
if (!isSqliteBusy(err) || !canRetryAfter || next === undefined) throw err;
|
|
491
494
|
backoff = next;
|