@desplega.ai/agent-swarm 2.7.8 → 2.7.10
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-srfhs1s9.js +16 -0
- package/dist/{actions-4m1ct4nh.js → actions-b8aqhrsg.js} +20 -19
- package/dist/{amp-adapter-txqh7eqj.js → amp-adapter-4c165vgn.js} +3 -3
- package/dist/{anthropic-messages-xey2skwx.js → anthropic-messages-jkva0zps.js} +68 -78
- package/dist/app-m9khefrh.js +20 -0
- package/dist/{assistant-gd08kr9e.js → assistant-rh4v3ntz.js} +22 -21
- package/dist/{azure-openai-responses-26t7j9ra.js → azure-openai-responses-wgtqkbr3.js} +5 -10
- package/dist/{boot-args-schema-tjrkpbvm.js → boot-args-schema-hwkc8bzv.js} +1 -1
- package/dist/{boot-reembed-21hbck22.js → boot-reembed-5y6yw9sj.js} +1 -1
- package/dist/{boot-reembed-mdxd3wgp.js → boot-reembed-fdyk55h4.js} +1 -1
- package/dist/{boot-scrub-sweep-qy0zr9t2.js → boot-scrub-sweep-r5r8kqsn.js} +4 -4
- package/dist/{boot-seeds-n46eaxdv.js → boot-seeds-8f9zt5cm.js} +5 -4
- package/dist/{boxd-nv507va8.js → boxd-qbkxy6ap.js} +1 -1
- package/dist/{claude-adapter-j37w2eds.js → claude-adapter-s5df247c.js} +8 -8
- package/dist/{claude-managed-adapter-8jvcma9a.js → claude-managed-adapter-h74d06yz.js} +4 -4
- package/dist/{claude-managed-setup-rzkjmgc1.js → claude-managed-setup-9gsmwzyx.js} +4 -4
- package/dist/{claude-sdk-session-4k7w73t0.js → claude-sdk-session-dq1j4nz9.js} +7901 -7718
- package/dist/{cli-s4ss5g59.js → cli-0m7rtm11.js} +5 -5
- package/dist/{cli-fzachfnf.js → cli-16phend6.js} +5 -5
- package/dist/{cli-yqefz277.js → cli-18qt3few.js} +1 -1
- package/dist/{cli-snpj5zbj.js → cli-1z4qggfe.js} +9 -36
- package/dist/{cli-s0qnd4wv.js → cli-28fq781p.js} +1 -1
- package/dist/{cli-1p89xny0.js → cli-2r0jcc3k.js} +1 -1
- package/dist/{cli-66ww7fer.js → cli-2tsfpc70.js} +1 -1
- package/dist/{cli-rvtm68yy.js → cli-2xv18ywz.js} +2 -2
- package/dist/{cli-kyr67fgx.js → cli-36wdfzgn.js} +18608 -9089
- package/dist/{cli-t60ajbbp.js → cli-38yww4e9.js} +20 -20
- package/dist/{cli-5xaqj21p.js → cli-3kd08rej.js} +1 -1
- package/dist/{cli-ae7mrdf9.js → cli-3vjhs18n.js} +4 -6
- package/dist/{cli-ssnjfg5p.js → cli-3xcwp3z8.js} +8 -10
- package/dist/{cli-rjknb2ae.js → cli-3xddv0rk.js} +6 -6
- package/dist/{cli-az48n0nr.js → cli-4caa1x7d.js} +67 -64
- package/dist/cli-4vwxp550.js +9321 -0
- package/dist/{cli-pz4rk021.js → cli-54vrpgm0.js} +1 -1
- package/dist/{cli-gvx71kqv.js → cli-55bkx8hh.js} +3 -3
- package/dist/{cli-r9jqcehk.js → cli-5mpy301f.js} +38 -2
- package/dist/{cli-bb0mmdk8.js → cli-5wfz00be.js} +35 -12
- package/dist/{cli-btfsp3mv.js → cli-5xcb8gxq.js} +9 -11
- package/dist/{cli-4t50yq3j.js → cli-6m6b4bep.js} +29 -12
- package/dist/cli-6pzk82fd.js +778 -0
- package/dist/{cli-8sdejs1f.js → cli-7wz05bx3.js} +797 -255
- package/dist/{cli-mkk9rnzz.js → cli-8bpgbr8k.js} +54 -7
- package/dist/{cli-fyhr5h4s.js → cli-8ewkreqd.js} +17 -13
- package/dist/{cli-p3vsj0d3.js → cli-an1knn2k.js} +15 -10
- package/dist/{cli-0ykgn1h5.js → cli-bxz823sz.js} +2 -2
- package/dist/{cli-jdv6ypxs.js → cli-bzvs88tv.js} +2 -2
- package/dist/{cli-bshb7jas.js → cli-cr14kftt.js} +3 -3
- package/dist/{cli-njwac61j.js → cli-cyn9v8zr.js} +12 -2
- package/dist/{cli-a22h291q.js → cli-d6521kb5.js} +1 -1
- package/dist/{cli-1b7btd38.js → cli-d84byzn8.js} +869 -5
- package/dist/{cli-84rj785g.js → cli-eb2azq8n.js} +9 -9
- package/dist/{cli-1cxrbkk6.js → cli-ed6yqpf1.js} +7 -9
- package/dist/{cli-wx3rhnm0.js → cli-eddnyg3t.js} +1 -1
- package/dist/{cli-ga786dzg.js → cli-eqk5p56g.js} +18 -17
- package/dist/{cli-mthwvjre.js → cli-f2zenhja.js} +1 -1
- package/dist/{cli-ferkkrg9.js → cli-fjggej24.js} +2 -2
- package/dist/{cli-g7s47cc5.js → cli-fsgttth8.js} +123 -102
- package/dist/{cli-269q28a1.js → cli-g1px1g2e.js} +27 -6
- package/dist/{cli-sq4n7af4.js → cli-h49ejvmc.js} +4 -6
- package/dist/{cli-5j0m12ns.js → cli-hfkwwy1h.js} +51 -15
- package/dist/{cli-agfm16v9.js → cli-hg42n3hx.js} +12 -12
- package/dist/{cli-yndmfxb3.js → cli-hxpyc9sn.js} +3 -3
- package/dist/{cli-w4xnbm46.js → cli-j7d73g1y.js} +414 -145
- package/dist/{cli-gazw7kpa.js → cli-jg24scat.js} +8 -10
- package/dist/{cli-5ja3b75e.js → cli-jrp1dt73.js} +1 -1
- package/dist/{cli-98rw5dt5.js → cli-jrzkw01m.js} +2 -2
- package/dist/{cli-583frbyr.js → cli-kchjb7qy.js} +1 -1
- package/dist/{cli-xr8908my.js → cli-kx4c8j05.js} +32 -17
- package/dist/{cli-fmjd0t1y.js → cli-m0cy2vyf.js} +2 -2
- package/dist/{cli-c0kqky8y.js → cli-m5akxq8q.js} +1 -1
- package/dist/{cli-ycscb2ar.js → cli-m88rpzkh.js} +2 -2
- package/dist/{cli-ppjxh6ah.js → cli-mp9aa8g5.js} +10 -12
- package/dist/{cli-xq9r2wtt.js → cli-mr97t7cc.js} +679 -247
- package/dist/{cli-z75yxkjh.js → cli-n07eecjs.js} +3 -3
- package/dist/{cli-7cx2m6t2.js → cli-n515ex5z.js} +16 -16
- package/dist/{cli-fy6x31ps.js → cli-n5yexkdg.js} +1 -0
- package/dist/{cli-bbw9wj9m.js → cli-n9abj89w.js} +17 -16
- package/dist/{cli-ypff1qwp.js → cli-n9ftpys4.js} +7 -7
- package/dist/{cli-32m9eda8.js → cli-nj3x45rw.js} +111 -109
- package/dist/{cli-6vcp76qk.js → cli-p74md7t8.js} +42 -23
- package/dist/{cli-rjcbm574.js → cli-pr0eze3x.js} +2 -2
- package/dist/{cli-dq8x79v8.js → cli-pyrxt9gw.js} +198 -3
- package/dist/{cli-m0hmeqma.js → cli-q581b386.js} +5 -5
- package/dist/{cli-8rpcng8j.js → cli-rjyghzg4.js} +8 -10
- package/dist/cli-rkc97c6a.js +39 -0
- package/dist/{cli-msg9m2ny.js → cli-rt0ag4x1.js} +9 -11
- package/dist/{cli-qd57hhhh.js → cli-rvhdmjvt.js} +6 -10
- package/dist/{cli-318r69gq.js → cli-t73cas91.js} +440 -9
- package/dist/{cli-q4ebh7h7.js → cli-td33w98c.js} +6 -6
- package/dist/{cli-zkky4t5g.js → cli-tmft5dz2.js} +2 -2
- package/dist/{cli-q26b9wre.js → cli-tph5wt3y.js} +4 -4
- package/dist/{cli-3e4snnzf.js → cli-ttbqe3q4.js} +1 -1
- package/dist/{cli-wemma3jd.js → cli-v2fwbnsk.js} +7 -7
- package/dist/cli-w3bk0dgv.js +5266 -0
- package/dist/{cli-8h0ayw8c.js → cli-x9exydey.js} +6 -6
- package/dist/{cli-85gzce7b.js → cli-xbtq4d6s.js} +287 -75
- package/dist/{cli-eyg1pa00.js → cli-xd5ebp64.js} +7 -7
- package/dist/{cli-g83s9ewh.js → cli-xfjrc279.js} +1 -1
- package/dist/{cli-7axf41jq.js → cli-xncjscpm.js} +40 -42
- package/dist/{cli-9m8hdawy.js → cli-xvymtmv4.js} +4 -4
- package/dist/{cli-81p9jd57.js → cli-yab6sh8p.js} +9 -3
- package/dist/{cli-srye3vdt.js → cli-ybjdc978.js} +1 -1
- package/dist/{cli-z1srzaf6.js → cli-yz7v0sh4.js} +70 -5
- package/dist/{cli-nbsf8yvn.js → cli-z9cs5m0w.js} +9 -9
- package/dist/{cli-k5671be5.js → cli-zcfpsfzf.js} +5 -5
- package/dist/{cli-vf078p3e.js → cli-zfqg6fzn.js} +1 -1
- package/dist/{cli-tpksw2nr.js → cli-zjphdj1a.js} +461 -108
- package/dist/cli.js +32 -52
- package/dist/{cloudflare-workers-ai-system-one-ef2a980q.js → cloudflare-workers-ai-system-one-9y1zx3pt.js} +2 -2
- package/dist/{codex-adapter-88z6psm4.js → codex-adapter-yr60sme6.js} +7 -7
- package/dist/{codex-login-74wa4hmq.js → codex-login-bcda78ge.js} +2 -2
- package/dist/{codex-session-runner-zwbcwzvx.js → codex-session-runner-pch8x584.js} +8 -8
- package/dist/{commands-7amxs716.js → commands-phjfbkv0.js} +3 -3
- package/dist/{controller-5rkkc37m.js → controller-jkx994pz.js} +4 -4
- package/dist/{controllers-connect-m7d4vxxb.js → controllers-connect-c4448kwa.js} +25 -24
- package/dist/{cursor-adapter-x1q18693.js → cursor-adapter-ndebqnm8.js} +2 -2
- package/dist/{db-athc68zt.js → db-ef32tbfc.js} +6 -2
- package/dist/{db-h2fsfve3.js → db-ez6egt6v.js} +3 -3
- package/dist/{devin-adapter-r9phbnc9.js → devin-adapter-z46ep5ph.js} +1 -1
- package/dist/{dispatcher-b1yz2bnn.js → dispatcher-g3tt9hs9.js} +19 -18
- package/dist/{docker-c1a3gqmf.js → docker-866qpzt9.js} +2 -2
- package/dist/{dsh-adapter-e33bkxq9.js → dsh-adapter-tcyn3099.js} +2 -2
- package/dist/{e2b-fr12yccx.js → e2b-jkwfhbcv.js} +2 -2
- package/dist/{e2b-x6ywzak3.js → e2b-s16txnpx.js} +2 -3
- package/dist/{easter-egg-3d-pv5qnzc8.js → easter-egg-3d-e36hk5td.js} +1 -1
- package/dist/{embedding-space-b4txbwrk.js → embedding-space-4kyh5qqj.js} +6 -6
- package/dist/{embeddings-m6zn6tad.js → embeddings-6a8v4a6t.js} +1 -1
- package/dist/{event-bus-g0ka3pbw.js → event-bus-e66gh7cc.js} +1 -1
- package/dist/{execute-68nwny8m.js → execute-3cbg0twf.js} +1 -1
- package/dist/{external-channel-gkckmhzh.js → external-channel-se646snz.js} +2 -2
- package/dist/fx-adapter-yw795hqq.js +19 -0
- package/dist/{google-generative-ai-v94hr7h0.js → google-generative-ai-h7s3e9kk.js} +7 -12
- package/dist/{google-vertex-g7vr6cf8.js → google-vertex-fhxaafzw.js} +7 -12
- package/dist/grok-adapter-ttmcss2j.js +19 -0
- package/dist/handlers-17wha3ze.js +33 -0
- package/dist/heartbeat-gwewgdms.js +42 -0
- package/dist/{hook-q5fv0jy2.js → hook-g3nhexsy.js} +16 -11
- package/dist/{hook-w0q2wcrv.js → hook-hq93y5ej.js} +5 -5
- package/dist/{http-bxat8dg3.js → http-5a9p4h6y.js} +808 -285
- package/dist/{index-pxn30mse.js → index-0eny15vj.js} +8 -8
- package/dist/{index-6cxzwfen.js → index-0rvk3vd4.js} +71 -71
- package/dist/{index-fvzke5kx.js → index-1qw6f2dc.js} +10 -10
- package/dist/{index-cqhqpgrv.js → index-3c5pxbge.js} +1 -1
- package/dist/{index-k7fj52d3.js → index-6haqt3v5.js} +12302 -11048
- package/dist/index-8arwq8mw.js +34 -0
- package/dist/{index-h7f61sy9.js → index-e5pfbsys.js} +3 -3
- package/dist/{index-bxrexmfy.js → index-hgn3c961.js} +14 -13
- package/dist/{index-h39zbx67.js → index-m5gx1xd6.js} +68 -68
- package/dist/{index-5fx3b3kw.js → index-rvccek1w.js} +9 -9
- package/dist/{index-fm0czesf.js → index-s72rqgsx.js} +1 -1
- package/dist/index-tpw054az.js +38 -0
- package/dist/{index-514d9pf6.js → index-w7em4ktq.js} +8 -8
- package/dist/index-waq75j2j.js +31 -0
- package/dist/{keepalive-qnt21cv0.js → keepalive-1j4n4dmk.js} +4 -4
- package/dist/lead-re73kdgc.js +72 -0
- package/dist/{llama-cpp-classify-s5c47rwh.js → llama-cpp-classify-nfgswa1m.js} +2 -2
- package/dist/{maintenance-btdr68y4.js → maintenance-dmghacy5.js} +1 -1
- package/dist/{mistral-conversations-3gjpdb4b.js → mistral-conversations-a45tx39a.js} +29 -51
- package/dist/{oauth-refresh-sweep-vczabeh4.js → oauth-refresh-sweep-yy06c03c.js} +3 -3
- package/dist/{onboard-k33ezyq8.js → onboard-52f9t5dm.js} +68 -16
- package/dist/{openai-codex-responses-8pbxq9h5.js → openai-codex-responses-k9gapdze.js} +7 -11
- package/dist/{openai-completions-rm00s912.js → openai-completions-xd579js7.js} +50 -58
- package/dist/{openai-decisions-8v957r2r.js → openai-decisions-q3hh60wr.js} +2 -2
- package/dist/{openai-responses-agxpf96k.js → openai-responses-4d5dx3c7.js} +5 -10
- package/dist/{opencode-adapter-3dst2ka7.js → opencode-adapter-krnh9jkn.js} +6 -6
- package/dist/{openrouter-images-3ecegv0d.js → openrouter-images-xr9gme9x.js} +4 -3
- package/dist/{otel-impl-13am7a65.js → otel-impl-xjqz6wjj.js} +2 -2
- package/dist/{pi-messages-pchtw4he.js → pi-messages-hjbv8v10.js} +28 -12
- package/dist/{pi-mono-adapter-c53de1gd.js → pi-mono-adapter-dbxyp0qv.js} +23 -26
- package/dist/{pricing-refresh-9fcbnq3f.js → pricing-refresh-ctdr74pd.js} +3 -3
- package/dist/{rbac-roles-66j5h4y5.js → rbac-roles-ehv8s10n.js} +12 -3
- package/dist/{rbac-roles-gw0p9h3j.js → rbac-roles-q0gr8eyj.js} +16 -2
- package/dist/{render-v2-fg8bmdn4.js → render-v2-5b6chvcq.js} +9 -4
- package/dist/{resume-1c8kr3nh.js → resume-5a5d2845.js} +7 -7
- package/dist/{runtime-tzf9j7tc.js → runtime-khxszyfp.js} +1 -1
- package/dist/{session-access-d0atq10j.js → session-access-gj0bjhqg.js} +4 -4
- package/dist/{session-source-backfill-0vscqmsa.js → session-source-backfill-2sy0krfk.js} +3 -3
- package/dist/{setup-tvfa7rwe.js → setup-7ssfakk1.js} +1 -1
- package/dist/{typesafe-system-one-0bmqcxfg.js → typesafe-system-one-f2en2knd.js} +2 -2
- package/dist/virtual-modules-pjj0knwf.js +362 -0
- package/dist/{work-objects-ks71xqeb.js → work-objects-bf3syvhq.js} +22 -21
- package/dist/{worker-follow-up-bfx0h9hg.js → worker-follow-up-38xevga6.js} +19 -18
- package/dist/worker-r8mz7a65.js +72 -0
- package/dist/{x-vmmye1kb.js → x-2fyrt5pp.js} +2 -2
- package/openapi.json +1169 -257
- package/package.json +9 -11
- package/src/apps/catalog.generated.json +354 -82
- package/src/apps/page-validator.ts +134 -2
- package/src/assets/key.ts +77 -4
- package/src/be/connector-codes.ts +21 -6
- package/src/be/db/session-labels.ts +57 -0
- package/src/be/db/session-tree.ts +51 -7
- package/src/be/db/slack-trees.ts +146 -0
- package/src/be/db/tasks/read.ts +124 -7
- package/src/be/db-client.ts +8 -2
- package/src/be/db.ts +99 -86
- package/src/be/event-loop-lag.ts +146 -0
- package/src/be/improvements.ts +416 -0
- package/src/be/mcp-overflow-sweep.ts +2 -1
- package/src/be/memory/providers/sqlite-store.ts +39 -8
- package/src/be/migrations/274_improvements.sql +27 -0
- package/src/be/migrations/275_task_dispatched_by.sql +8 -0
- package/src/be/migrations/278_slack_render_v2_reconcile.sql +108 -0
- package/src/be/rbac-roles.ts +123 -1
- package/src/be/swarm-config-guard.ts +3 -0
- package/src/be/users.ts +58 -1
- package/src/cli.tsx +5 -25
- package/src/commands/codex-login.ts +1 -1
- package/src/commands/context-preamble.ts +258 -0
- package/src/commands/e2b.ts +0 -1
- package/src/commands/onboard/agent-fs-version.ts +1 -1
- package/src/commands/onboard/compose-generator.ts +0 -1
- package/src/commands/onboard/dashboard-url.ts +31 -0
- package/src/commands/onboard/steps/generate.tsx +17 -1
- package/src/commands/onboard/steps/post-dashboard.tsx +9 -3
- package/src/commands/onboard.tsx +19 -6
- package/src/commands/runner.ts +117 -96
- package/src/extensions/catalog.generated.json +3 -3
- package/src/extensions/contract-types.generated.ts +1 -1
- package/src/heartbeat/heartbeat.ts +5 -4
- package/src/hooks/hook.ts +13 -5
- package/src/http/all-routes.ts +1 -0
- package/src/http/approval-requests.ts +2 -44
- package/src/http/auth.ts +5 -4
- package/src/http/codex-oauth-accounts.ts +31 -23
- package/src/http/codex-oauth-device.ts +1 -1
- package/src/http/codex-oauth-keep-warm.ts +1 -1
- package/src/http/core.ts +9 -3
- package/src/http/improvements.ts +317 -0
- package/src/http/index.ts +12 -6
- package/src/http/memory.ts +9 -4
- package/src/http/operator-actor.ts +2 -1
- package/src/http/person-responder.ts +66 -0
- package/src/http/sessions.ts +65 -10
- package/src/http/tasks.ts +1 -1
- package/src/http/user-roles.ts +11 -2
- package/src/http/users.ts +194 -104
- package/src/http/utils.ts +18 -0
- package/src/http/webhooks.ts +48 -0
- package/src/integrations/chat-sdk/commands.ts +167 -31
- package/src/integrations/chat-sdk/inbound.ts +10 -8
- package/src/integrations/chat-sdk/message-text.ts +117 -0
- package/src/providers/acp-targets.ts +1 -1
- package/src/providers/amp-adapter.ts +1 -1
- package/src/providers/codex-adapter.ts +8 -1
- package/src/providers/codex-models.ts +4 -3
- package/src/providers/codex-oauth/auth-json.ts +14 -18
- package/src/providers/codex-oauth/storage.ts +2 -2
- package/src/providers/cursor-adapter.ts +1 -1
- package/src/providers/dsh-adapter.ts +1 -1
- package/src/rbac/legacy-policy.ts +2 -0
- package/src/rbac/permissions.ts +10 -0
- package/src/scheduler/scheduler.ts +4 -1
- package/src/scripts-runtime/executors/quickjs-runner.ts +2 -0
- package/src/scripts-runtime/executors/quickjs-structured-clone.ts +180 -0
- package/src/scripts-runtime/quickjs-compat.ts +0 -1
- package/src/scripts-runtime/types/swarm-extension.d.ts +2 -0
- package/src/server.ts +2 -0
- package/src/slack/ack.ts +20 -14
- package/src/slack/app.ts +332 -10
- package/src/slack/handlers.ts +9 -2
- package/src/slack/index.ts +7 -1
- package/src/slack/lifecycle-lock.ts +29 -0
- package/src/slack/render-v2.ts +466 -229
- package/src/slack/socket-fence.ts +64 -0
- package/src/slack/watcher.ts +42 -8
- package/src/tests/api-drain-worker-e2e.test.ts +69 -2
- package/src/tests/apps-catalog-drift.test.ts +35 -0
- package/src/tests/apps-catalog-table.test.ts +203 -0
- package/src/tests/apps-element-assembly.test.ts +28 -0
- package/src/tests/apps-schema-form.test.ts +151 -0
- package/src/tests/apps-smart-links.test.ts +151 -0
- package/src/tests/apps-table-filters-migration.test.ts +96 -0
- package/src/tests/apps-table-selection-migration.test.ts +95 -0
- package/src/tests/chat-sdk-commands.test.ts +359 -2
- package/src/tests/chat-sdk-inbound.test.ts +20 -0
- package/src/tests/chat-sdk-slack.test.ts +189 -1
- package/src/tests/chatgpt-subscription-session-bench.test.ts +2 -2
- package/src/tests/claude-worker-parity.test.ts +2 -2
- package/src/tests/codex-adapter.test.ts +30 -0
- package/src/tests/codex-login.test.ts +2 -2
- package/src/tests/codex-oauth-accounts.test.ts +48 -12
- package/src/tests/codex-oauth-credential-info.test.ts +77 -1
- package/src/tests/codex-oauth-device.test.ts +1 -1
- package/src/tests/codex-oauth-keep-warm.test.ts +2 -2
- package/src/tests/codex-oauth.test.ts +25 -4
- package/src/tests/codex-pool.test.ts +2 -2
- package/src/tests/db-client-busy-retry.test.ts +69 -18
- package/src/tests/db-client.test.ts +26 -1
- package/src/tests/db-task-read-contract.test.ts +4 -0
- package/src/tests/db-task-write-contract.test.ts +2 -0
- package/src/tests/deploy-one-box.test.ts +39 -1
- package/src/tests/docs-index-footprint.test.js +3 -3
- package/src/tests/dsh-adapter.test.ts +1 -1
- package/src/tests/event-loop-lag.test.ts +184 -0
- package/src/tests/extensions-example-comms-adherence-gate.test.ts +115 -0
- package/src/tests/fixtures/onboard/content.compose.yml.txt +0 -4
- package/src/tests/fixtures/onboard/dev.compose.yml.txt +0 -3
- package/src/tests/fixtures/onboard/full-all.compose.yml.txt +0 -11
- package/src/tests/fixtures/onboard/full.compose.yml.txt +0 -11
- package/src/tests/fixtures/onboard/research.compose.yml.txt +0 -3
- package/src/tests/fixtures/onboard/solo.compose.yml.txt +0 -1
- package/src/tests/fixtures/prs-app-definition.json.txt +784 -0
- package/src/tests/fixtures/prs-filters-migration.patch.json.txt +318 -0
- package/src/tests/fixtures/prs-selection-migration.patch.json.txt +373 -0
- package/src/tests/fixtures/runner-identity-refresh.ts +3 -0
- package/src/tests/fixtures/runner-legacy-resume-prompt.ts +3 -0
- package/src/tests/fixtures/runner-task-start-reads.ts +140 -0
- package/src/tests/github-webhook-early-ack.test.ts +144 -0
- package/src/tests/hook-ping-me-order.test.ts +85 -0
- package/src/tests/http-api-integration.test.ts +2 -0
- package/src/tests/http-log-scrubbing.test.ts +68 -2
- package/src/tests/improvements-payload.test.ts +200 -0
- package/src/tests/improvements-route.test.ts +419 -0
- package/src/tests/install-sh-setup-url.test.ts +190 -0
- package/src/tests/kv-storage.test.ts +92 -1
- package/src/tests/memory-key-paths.test.ts +57 -0
- package/src/tests/memory-retrieval-purge.test.ts +19 -0
- package/src/tests/onboard-dashboard-output.test.ts +109 -0
- package/src/tests/onboard-dashboard-url.test.ts +83 -0
- package/src/tests/operator-granted-credentials.test.ts +561 -0
- package/src/tests/operator-granted-role-wire.test.ts +222 -0
- package/src/tests/quickjs-compat.test.ts +1 -1
- package/src/tests/rbac-engine.test.ts +2 -0
- package/src/tests/runner-context-preamble.test.ts +552 -0
- package/src/tests/runner-context-usage.test.ts +0 -1
- package/src/tests/runner-legacy-options.test.ts +55 -0
- package/src/tests/runner-slot-reconcile.test.ts +38 -0
- package/src/tests/runner-task-start-reads.test.ts +58 -0
- package/src/tests/script-connections.test.ts +3 -0
- package/src/tests/script-executor-conformance.test.ts +188 -0
- package/src/tests/send-task-dispatched-by.test.ts +129 -0
- package/src/tests/session-dispatched-tasks.test.ts +115 -0
- package/src/tests/session-sharing.test.ts +198 -9
- package/src/tests/sessions-tree.test.ts +133 -2
- package/src/tests/slack-app-icon.test.ts +4 -0
- package/src/tests/slack-dm-implicit-mention.test.ts +236 -0
- package/src/tests/slack-file-tools-attachments.test.ts +96 -3
- package/src/tests/slack-reaction-config.test.ts +39 -0
- package/src/tests/slack-read-boundaries.test.ts +4 -3
- package/src/tests/slack-render-v2-query-plans.test.ts +262 -3
- package/src/tests/slack-render-v2-reconcile.test.ts +201 -0
- package/src/tests/slack-render-v2.test.ts +47 -0
- package/src/tests/slack-socket-watchdog.test.ts +748 -0
- package/src/tests/submit-improvement-tool.test.ts +82 -0
- package/src/tests/tool-annotations.test.ts +1 -1
- package/src/tests/vcs-identity-inheritance.test.ts +85 -0
- package/src/tools/manage-user.ts +88 -58
- package/src/tools/send-task.ts +3 -0
- package/src/tools/slack-read.ts +61 -33
- package/src/tools/submit-improvement.ts +68 -0
- package/src/tools/tool-config.ts +3 -0
- package/src/tools/utils.ts +16 -7
- package/src/types.ts +5 -0
- package/src/utils/request-auth-context.ts +6 -1
- package/templates/extensions/comms-adherence-gate/README.md +25 -0
- package/templates/extensions/comms-adherence-gate/hooks.ts +100 -11
- package/templates/extensions/comms-adherence-gate/manifest.json +1 -1
- package/templates/skills/apps/SKILL.md +29 -11
- package/templates/skills/apps/content.md +29 -11
- package/templates/skills/swarm-scripts/SKILL.md +1 -1
- package/templates/skills/swarm-scripts/content.md +1 -1
- package/templates/skills/work-on-task/SKILL.md +1 -1
- package/templates/skills/work-on-task/content.md +1 -1
- package/dist/acp-adapter-vg5hqkvj.js +0 -16
- package/dist/app-e00m45gn.js +0 -17
- package/dist/cli-5c4hjzne.js +0 -873
- package/dist/cli-ae0dnfee.js +0 -20222
- package/dist/cli-nn3ysbqk.js +0 -428
- package/dist/cli-pc5znp64.js +0 -364
- package/dist/fx-adapter-m5jbgd5q.js +0 -19
- package/dist/grok-adapter-csvv7sac.js +0 -19
- package/dist/handlers-8x5gfbzx.js +0 -32
- package/dist/heartbeat-6c2y3267.js +0 -41
- package/dist/index-hpfte8jd.js +0 -33
- package/dist/index-ncf7yb5s.js +0 -30
- package/dist/index-vte6dyeh.js +0 -37
- package/dist/lead-4bvftzm6.js +0 -71
- package/dist/virtual-modules-efxcp740.js +0 -59
- package/dist/worker-e7v2bvm9.js +0 -71
|
@@ -5,7 +5,14 @@ import {
|
|
|
5
5
|
decryptSecret,
|
|
6
6
|
getEncryptionKey,
|
|
7
7
|
init_crypto,
|
|
8
|
+
bindLoopPath,
|
|
9
|
+
init_event_loop_lag,
|
|
8
10
|
getDbClient2,
|
|
11
|
+
SLACK_REACTION_DEFAULTS,
|
|
12
|
+
SLACK_REACTION_CONFIG_KEYS,
|
|
13
|
+
reactionName,
|
|
14
|
+
completedStatusIcon,
|
|
15
|
+
init_reaction_shortcode,
|
|
9
16
|
getAgentById2,
|
|
10
17
|
getTaskById2,
|
|
11
18
|
getChildTasks2,
|
|
@@ -15,11 +22,10 @@ import {
|
|
|
15
22
|
markFinalizedSlackRelaysDelivered2,
|
|
16
23
|
getInProgressSlackTasks2,
|
|
17
24
|
getSlackTasksMissingTree2,
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
init_reaction_shortcode,
|
|
25
|
+
closeSlackTreeIfSettled,
|
|
26
|
+
getSlackThreadsOfTasks,
|
|
27
|
+
slackThreadHasOutcomeWork,
|
|
28
|
+
init_slack_trees,
|
|
23
29
|
ensureSlackRenderV2Activation2,
|
|
24
30
|
ensureSlackDelegationActivation2,
|
|
25
31
|
isPendingSlackMessage2,
|
|
@@ -50,11 +56,15 @@ import {
|
|
|
50
56
|
checkDependencies2,
|
|
51
57
|
emitBuiltInIntegrationConnectedOnce2,
|
|
52
58
|
init_db4
|
|
53
|
-
} from "./cli-
|
|
59
|
+
} from "./cli-j7d73g1y.js";
|
|
54
60
|
import {
|
|
55
61
|
getChannelBlockReason2,
|
|
56
62
|
init_external_channel
|
|
57
|
-
} from "./cli-
|
|
63
|
+
} from "./cli-bxz823sz.js";
|
|
64
|
+
import {
|
|
65
|
+
workflowEventBus2,
|
|
66
|
+
init_event_bus
|
|
67
|
+
} from "./cli-eddnyg3t.js";
|
|
58
68
|
import {
|
|
59
69
|
require_jsonwebtoken,
|
|
60
70
|
require_dist6,
|
|
@@ -80,25 +90,25 @@ import {
|
|
|
80
90
|
import {
|
|
81
91
|
isTerminalTaskStatus,
|
|
82
92
|
init_types4
|
|
83
|
-
} from "./cli-
|
|
93
|
+
} from "./cli-hfkwwy1h.js";
|
|
84
94
|
import {
|
|
85
95
|
taskAttachmentDisplayUrl,
|
|
86
96
|
init_task_attachment_links
|
|
87
|
-
} from "./cli-
|
|
97
|
+
} from "./cli-pyrxt9gw.js";
|
|
88
98
|
import {
|
|
89
99
|
getSlackConfiguration,
|
|
90
100
|
init_config4
|
|
91
101
|
} from "./cli-eetzmsy5.js";
|
|
92
102
|
import {
|
|
93
103
|
init_zod
|
|
94
|
-
} from "./cli-
|
|
104
|
+
} from "./cli-zcfpsfzf.js";
|
|
95
105
|
import {
|
|
96
106
|
string2,
|
|
97
107
|
number2,
|
|
98
108
|
boolean,
|
|
99
109
|
object2,
|
|
100
110
|
_enum2
|
|
101
|
-
} from "./cli-
|
|
111
|
+
} from "./cli-hg42n3hx.js";
|
|
102
112
|
import {
|
|
103
113
|
getAppUrl,
|
|
104
114
|
init_constants3
|
|
@@ -115,7 +125,7 @@ import {
|
|
|
115
125
|
scrubSecrets,
|
|
116
126
|
scrubObject,
|
|
117
127
|
init_secret_scrubber
|
|
118
|
-
} from "./cli-
|
|
128
|
+
} from "./cli-d84byzn8.js";
|
|
119
129
|
import {
|
|
120
130
|
__toESM,
|
|
121
131
|
__commonJS,
|
|
@@ -11734,6 +11744,30 @@ var init_inbound_dispatch = __esm(() => {
|
|
|
11734
11744
|
};
|
|
11735
11745
|
});
|
|
11736
11746
|
|
|
11747
|
+
// src/slack/lifecycle-lock.ts
|
|
11748
|
+
async function runSlackLifecycleExclusive(fn) {
|
|
11749
|
+
holders += 1;
|
|
11750
|
+
const previous = tail;
|
|
11751
|
+
let release;
|
|
11752
|
+
tail = new Promise((resolve) => {
|
|
11753
|
+
release = resolve;
|
|
11754
|
+
});
|
|
11755
|
+
try {
|
|
11756
|
+
await previous;
|
|
11757
|
+
return await fn();
|
|
11758
|
+
} finally {
|
|
11759
|
+
holders -= 1;
|
|
11760
|
+
release();
|
|
11761
|
+
}
|
|
11762
|
+
}
|
|
11763
|
+
function isSlackLifecycleBusy() {
|
|
11764
|
+
return holders > 0;
|
|
11765
|
+
}
|
|
11766
|
+
var tail, holders = 0;
|
|
11767
|
+
var init_lifecycle_lock = __esm(() => {
|
|
11768
|
+
tail = Promise.resolve();
|
|
11769
|
+
});
|
|
11770
|
+
|
|
11737
11771
|
// src/slack/socket-ack.ts
|
|
11738
11772
|
function isSocketNotReadyError(error) {
|
|
11739
11773
|
return error instanceof Error && error.message === NOT_READY_MESSAGE;
|
|
@@ -11848,6 +11882,53 @@ var init_socket_ack = __esm(() => {
|
|
|
11848
11882
|
ORDER_DEPENDENT_EVENTS = new Set(["assistant_thread_context_changed"]);
|
|
11849
11883
|
});
|
|
11850
11884
|
|
|
11885
|
+
// src/slack/socket-fence.ts
|
|
11886
|
+
function fenceSocketModeClient(client) {
|
|
11887
|
+
let retired = false;
|
|
11888
|
+
const retrieveWSSURL = Reflect.get(client, "retrieveWSSURL");
|
|
11889
|
+
if (typeof retrieveWSSURL !== "function") {
|
|
11890
|
+
throw new Error("@slack/socket-mode changed: SocketModeClient.retrieveWSSURL is missing");
|
|
11891
|
+
}
|
|
11892
|
+
const start = client.start;
|
|
11893
|
+
Reflect.set(client, "retrieveWSSURL", async function() {
|
|
11894
|
+
if (retired)
|
|
11895
|
+
throw new SlackSocketClientRetiredError;
|
|
11896
|
+
let url;
|
|
11897
|
+
try {
|
|
11898
|
+
url = await retrieveWSSURL.call(this);
|
|
11899
|
+
} catch (error) {
|
|
11900
|
+
if (retired)
|
|
11901
|
+
throw new SlackSocketClientRetiredError;
|
|
11902
|
+
throw error;
|
|
11903
|
+
}
|
|
11904
|
+
if (retired)
|
|
11905
|
+
throw new SlackSocketClientRetiredError;
|
|
11906
|
+
return url;
|
|
11907
|
+
});
|
|
11908
|
+
Reflect.set(client, "start", function() {
|
|
11909
|
+
return start.call(this).catch((error) => {
|
|
11910
|
+
if (error instanceof SlackSocketClientRetiredError)
|
|
11911
|
+
return;
|
|
11912
|
+
throw error;
|
|
11913
|
+
});
|
|
11914
|
+
});
|
|
11915
|
+
return {
|
|
11916
|
+
retire: () => {
|
|
11917
|
+
retired = true;
|
|
11918
|
+
},
|
|
11919
|
+
isRetired: () => retired
|
|
11920
|
+
};
|
|
11921
|
+
}
|
|
11922
|
+
var SlackSocketClientRetiredError;
|
|
11923
|
+
var init_socket_fence = __esm(() => {
|
|
11924
|
+
SlackSocketClientRetiredError = class SlackSocketClientRetiredError extends Error {
|
|
11925
|
+
constructor() {
|
|
11926
|
+
super("Slack socket-mode client was retired; it opens no new socket");
|
|
11927
|
+
this.name = "SlackSocketClientRetiredError";
|
|
11928
|
+
}
|
|
11929
|
+
};
|
|
11930
|
+
});
|
|
11931
|
+
|
|
11851
11932
|
// src/slack/socket-mode-guard.ts
|
|
11852
11933
|
function getSlackSocketModeBlockReason(env) {
|
|
11853
11934
|
if (env.NODE_ENV !== "development")
|
|
@@ -11886,7 +11967,7 @@ async function initOtel(serviceRole = process.env.AGENT_ROLE || "api") {
|
|
|
11886
11967
|
return;
|
|
11887
11968
|
initialized = true;
|
|
11888
11969
|
try {
|
|
11889
|
-
const impl = await import("./otel-impl-
|
|
11970
|
+
const impl = await import("./otel-impl-xjqz6wjj.js");
|
|
11890
11971
|
await impl.boot(serviceRole, {
|
|
11891
11972
|
exportConsoleLogs: serviceRole === "api" && isApiLogExportEnabled()
|
|
11892
11973
|
});
|
|
@@ -12037,16 +12118,16 @@ async function ackSlackMessage(client, channel, timestamp, name, event) {
|
|
|
12037
12118
|
}
|
|
12038
12119
|
async function finalizeSlackMessageReaction(client, channel, timestamp, outcome, event) {
|
|
12039
12120
|
const names = new Set(ACCEPTANCE_EVENTS.map((acceptanceEvent) => reactionName(acceptanceEvent)));
|
|
12040
|
-
|
|
12121
|
+
await Promise.all(Array.from(names, async (name) => {
|
|
12041
12122
|
try {
|
|
12042
12123
|
await client.reactions.remove({ channel, name, timestamp });
|
|
12043
12124
|
} catch (error) {
|
|
12044
12125
|
const code = slackErrorCode(error);
|
|
12045
12126
|
if (code === "no_reaction" || code === "message_not_found" || code === "invalid_name")
|
|
12046
|
-
|
|
12127
|
+
return;
|
|
12047
12128
|
console.log(scrubSecrets(`[Slack] ${name} acknowledgement reaction removal failed: ${error instanceof Error ? error.message : error}`));
|
|
12048
12129
|
}
|
|
12049
|
-
}
|
|
12130
|
+
}));
|
|
12050
12131
|
await addReaction(client, channel, timestamp, outcome, event);
|
|
12051
12132
|
}
|
|
12052
12133
|
async function skipSlackMessageReaction(client, channel, timestamp) {
|
|
@@ -14322,16 +14403,24 @@ async function ensureSlackThreadTree2(taskIds, statusBudget) {
|
|
|
14322
14403
|
const task = (await Promise.all(taskIds.map(getTaskById2))).find((candidate) => !!candidate);
|
|
14323
14404
|
if (!task?.slackChannelId || !task.slackThreadTs)
|
|
14324
14405
|
return null;
|
|
14325
|
-
await
|
|
14326
|
-
|
|
14327
|
-
|
|
14328
|
-
|
|
14329
|
-
|
|
14406
|
+
const [tree] = await Promise.allSettled([
|
|
14407
|
+
findOrCreateThreadTree(task, task.slackChannelId, task.slackThreadTs, taskIds, statusBudget),
|
|
14408
|
+
reconcileSlackSessionStatus({
|
|
14409
|
+
channelId: task.slackChannelId,
|
|
14410
|
+
threadTs: task.slackThreadTs,
|
|
14411
|
+
budget: statusBudget
|
|
14412
|
+
})
|
|
14413
|
+
]);
|
|
14414
|
+
if (tree.status === "rejected")
|
|
14415
|
+
throw tree.reason;
|
|
14416
|
+
return tree.value;
|
|
14417
|
+
}
|
|
14418
|
+
async function findOrCreateThreadTree(task, channelId, threadTs, taskIds, statusBudget) {
|
|
14330
14419
|
const contextKey = task.contextKey ?? slackContextKey({
|
|
14331
|
-
channelId
|
|
14332
|
-
threadTs
|
|
14420
|
+
channelId,
|
|
14421
|
+
threadTs
|
|
14333
14422
|
});
|
|
14334
|
-
const existing = await findThreadTree(contextKey,
|
|
14423
|
+
const existing = await findThreadTree(contextKey, channelId, threadTs);
|
|
14335
14424
|
if (existing && !isPendingSlackMessage2(existing)) {
|
|
14336
14425
|
const app = getSlackApp2();
|
|
14337
14426
|
try {
|
|
@@ -14345,7 +14434,7 @@ async function ensureSlackThreadTree2(taskIds, statusBudget) {
|
|
|
14345
14434
|
return ensureSlackThreadTree2(taskIds, statusBudget);
|
|
14346
14435
|
}
|
|
14347
14436
|
}
|
|
14348
|
-
const creationKey = physicalThreadKey(
|
|
14437
|
+
const creationKey = physicalThreadKey(channelId, threadTs);
|
|
14349
14438
|
const inFlight = treeCreationPromises.get(creationKey);
|
|
14350
14439
|
if (inFlight)
|
|
14351
14440
|
return inFlight;
|
|
@@ -14780,8 +14869,13 @@ async function streamOutcomeCard(task, tree, options) {
|
|
|
14780
14869
|
});
|
|
14781
14870
|
}
|
|
14782
14871
|
}
|
|
14783
|
-
|
|
14784
|
-
|
|
14872
|
+
const [, permalinkResult] = await Promise.allSettled([
|
|
14873
|
+
clearAssistantStatus(app.client, task.slackChannelId, task.slackThreadTs, options?.statusBudget),
|
|
14874
|
+
resolvePermalink(app.client, task.slackChannelId, outcome.ts)
|
|
14875
|
+
]);
|
|
14876
|
+
if (permalinkResult.status === "rejected")
|
|
14877
|
+
throw permalinkResult.reason;
|
|
14878
|
+
const permalink = permalinkResult.value;
|
|
14785
14879
|
return await updateSlackMessageRecord2(outcome.id, {
|
|
14786
14880
|
permalink,
|
|
14787
14881
|
finalized: true,
|
|
@@ -14853,6 +14947,7 @@ async function refreshResolvedDeferralCards() {
|
|
|
14853
14947
|
} else {
|
|
14854
14948
|
await markSlackDeferralResolved2(card.id);
|
|
14855
14949
|
}
|
|
14950
|
+
markSlackThreadDirty(card.channelId, card.threadTs);
|
|
14856
14951
|
deferralRefreshAttempts.delete(card.id);
|
|
14857
14952
|
if (!isDeferredTask(wake))
|
|
14858
14953
|
await finalizeTerminalSlackReactions([wake]);
|
|
@@ -14870,240 +14965,373 @@ async function refreshResolvedDeferralCards() {
|
|
|
14870
14965
|
}
|
|
14871
14966
|
}
|
|
14872
14967
|
}
|
|
14873
|
-
async function
|
|
14968
|
+
async function renderStoredTree(storedTree, { activatedAt, delegationEnabled, delegationActivatedAt, statusTick }) {
|
|
14874
14969
|
if (!isSlackRenderV2Enabled2())
|
|
14875
|
-
return;
|
|
14876
|
-
|
|
14877
|
-
const
|
|
14878
|
-
|
|
14879
|
-
const statusTick = beginSlackStatusTick();
|
|
14880
|
-
for (const task of await getSlackTasksMissingTree2()) {
|
|
14881
|
-
if (!isSlackRenderV2Enabled2())
|
|
14882
|
-
return;
|
|
14883
|
-
if (!task.slackChannelId || !task.slackThreadTs)
|
|
14884
|
-
continue;
|
|
14970
|
+
return "stop";
|
|
14971
|
+
let tree = storedTree;
|
|
14972
|
+
const initialTasks = await getSlackTasksInThread2(tree.channelId, tree.threadTs);
|
|
14973
|
+
if (isPendingSlackMessage2(tree)) {
|
|
14885
14974
|
try {
|
|
14886
|
-
await ensureSlackThreadTree2(
|
|
14975
|
+
const recovered = await ensureSlackThreadTree2(initialTasks.map((task) => task.id), statusTick.budget);
|
|
14976
|
+
if (!recovered)
|
|
14977
|
+
return "skipped";
|
|
14978
|
+
tree = recovered;
|
|
14887
14979
|
} catch (error) {
|
|
14888
|
-
console.error(`[Slack] Failed to
|
|
14980
|
+
console.error(`[Slack] Failed to recover pending v2 tree ${tree.id}:`, error);
|
|
14981
|
+
return "skipped";
|
|
14889
14982
|
}
|
|
14890
14983
|
}
|
|
14891
|
-
|
|
14892
|
-
|
|
14893
|
-
|
|
14894
|
-
|
|
14895
|
-
|
|
14896
|
-
|
|
14897
|
-
try {
|
|
14898
|
-
const recovered = await ensureSlackThreadTree2(initialTasks.map((task) => task.id), statusTick.budget);
|
|
14899
|
-
if (!recovered)
|
|
14900
|
-
continue;
|
|
14901
|
-
tree = recovered;
|
|
14902
|
-
} catch (error) {
|
|
14903
|
-
console.error(`[Slack] Failed to recover pending v2 tree ${tree.id}:`, error);
|
|
14904
|
-
continue;
|
|
14905
|
-
}
|
|
14906
|
-
}
|
|
14907
|
-
const app = getSlackApp2();
|
|
14908
|
-
if (app && !tree.permalink) {
|
|
14909
|
-
try {
|
|
14910
|
-
tree = await ensureTreePermalink(app.client, tree);
|
|
14911
|
-
} catch (error) {
|
|
14912
|
-
if (isSlackMessageNotFound(error)) {
|
|
14913
|
-
try {
|
|
14914
|
-
await replaceMissingTree(tree, statusTick.budget);
|
|
14915
|
-
} catch (replacementError) {
|
|
14916
|
-
console.error(`[Slack] Failed to replace missing v2 tree ${tree.id}:`, replacementError);
|
|
14917
|
-
}
|
|
14918
|
-
continue;
|
|
14919
|
-
}
|
|
14920
|
-
console.error(`[Slack] Failed to resolve v2 tree permalink ${tree.id}:`, error);
|
|
14921
|
-
continue;
|
|
14922
|
-
}
|
|
14923
|
-
}
|
|
14924
|
-
let tasks = await getSlackTasksInThread2(tree.channelId, tree.threadTs);
|
|
14925
|
-
let needsOutcome = false;
|
|
14926
|
-
for (const task of tasks) {
|
|
14927
|
-
const card = await getSlackOutcomeMessage2(task.id);
|
|
14928
|
-
if (card && isSettledSlackMessage2(card))
|
|
14929
|
-
continue;
|
|
14930
|
-
const isDirectCandidate = await taskNeedsDirectOutcome(task, activatedAt) && isOutcomeStatus(task.status) && !await isAnsweredByDeferralCard(task, tasks);
|
|
14931
|
-
const isChildCandidate = delegationEnabled && delegationActivatedAt !== null && isChildCardCandidate(task, delegationActivatedAt) && !task.slackReplySent;
|
|
14932
|
-
if (isDirectCandidate || isChildCandidate) {
|
|
14933
|
-
needsOutcome = true;
|
|
14934
|
-
break;
|
|
14935
|
-
}
|
|
14936
|
-
}
|
|
14937
|
-
if (needsOutcome && app) {
|
|
14938
|
-
try {
|
|
14939
|
-
await resolvePermalink(app.client, tree.channelId, tree.ts);
|
|
14940
|
-
} catch (error) {
|
|
14941
|
-
if (!isSlackMessageNotFound(error)) {
|
|
14942
|
-
console.error(`[Slack] Failed to verify v2 tree ${tree.id}:`, error);
|
|
14943
|
-
continue;
|
|
14944
|
-
}
|
|
14984
|
+
const app = getSlackApp2();
|
|
14985
|
+
if (app && !tree.permalink) {
|
|
14986
|
+
try {
|
|
14987
|
+
tree = await ensureTreePermalink(app.client, tree);
|
|
14988
|
+
} catch (error) {
|
|
14989
|
+
if (isSlackMessageNotFound(error)) {
|
|
14945
14990
|
try {
|
|
14946
|
-
|
|
14947
|
-
if (!replacement)
|
|
14948
|
-
continue;
|
|
14949
|
-
tree = replacement;
|
|
14950
|
-
tasks = await getSlackTasksInThread2(tree.channelId, tree.threadTs);
|
|
14991
|
+
await replaceMissingTree(tree, statusTick.budget);
|
|
14951
14992
|
} catch (replacementError) {
|
|
14952
14993
|
console.error(`[Slack] Failed to replace missing v2 tree ${tree.id}:`, replacementError);
|
|
14953
|
-
continue;
|
|
14954
14994
|
}
|
|
14995
|
+
return "skipped";
|
|
14955
14996
|
}
|
|
14997
|
+
console.error(`[Slack] Failed to resolve v2 tree permalink ${tree.id}:`, error);
|
|
14998
|
+
return "skipped";
|
|
14956
14999
|
}
|
|
14957
|
-
|
|
14958
|
-
|
|
14959
|
-
|
|
14960
|
-
|
|
14961
|
-
|
|
14962
|
-
|
|
14963
|
-
|
|
14964
|
-
|
|
14965
|
-
|
|
14966
|
-
|
|
14967
|
-
|
|
14968
|
-
|
|
15000
|
+
}
|
|
15001
|
+
let tasks = await getSlackTasksInThread2(tree.channelId, tree.threadTs);
|
|
15002
|
+
let needsOutcome = false;
|
|
15003
|
+
for (const task of tasks) {
|
|
15004
|
+
const card = await getSlackOutcomeMessage2(task.id);
|
|
15005
|
+
if (card && isSettledSlackMessage2(card))
|
|
15006
|
+
continue;
|
|
15007
|
+
const isDirectCandidate = await taskNeedsDirectOutcome(task, activatedAt) && isOutcomeStatus(task.status) && !await isAnsweredByDeferralCard(task, tasks);
|
|
15008
|
+
const isChildCandidate = delegationEnabled && delegationActivatedAt !== null && isChildCardCandidate(task, delegationActivatedAt) && !task.slackReplySent;
|
|
15009
|
+
if (isDirectCandidate || isChildCandidate) {
|
|
15010
|
+
needsOutcome = true;
|
|
15011
|
+
break;
|
|
15012
|
+
}
|
|
15013
|
+
}
|
|
15014
|
+
if (needsOutcome && app) {
|
|
15015
|
+
try {
|
|
15016
|
+
await resolvePermalink(app.client, tree.channelId, tree.ts);
|
|
15017
|
+
} catch (error) {
|
|
15018
|
+
if (!isSlackMessageNotFound(error)) {
|
|
15019
|
+
console.error(`[Slack] Failed to verify v2 tree ${tree.id}:`, error);
|
|
15020
|
+
return "skipped";
|
|
15021
|
+
}
|
|
15022
|
+
try {
|
|
15023
|
+
const replacement = await replaceMissingTree(tree, statusTick.budget);
|
|
15024
|
+
if (!replacement)
|
|
15025
|
+
return "skipped";
|
|
15026
|
+
tree = replacement;
|
|
15027
|
+
tasks = await getSlackTasksInThread2(tree.channelId, tree.threadTs);
|
|
15028
|
+
} catch (replacementError) {
|
|
15029
|
+
console.error(`[Slack] Failed to replace missing v2 tree ${tree.id}:`, replacementError);
|
|
15030
|
+
return "skipped";
|
|
14969
15031
|
}
|
|
14970
15032
|
}
|
|
14971
|
-
|
|
14972
|
-
|
|
14973
|
-
|
|
14974
|
-
|
|
14975
|
-
|
|
14976
|
-
|
|
14977
|
-
|
|
15033
|
+
}
|
|
15034
|
+
const settleSec = Number(process.env.SLACK_CONCLUSION_SETTLE_SEC) || 10;
|
|
15035
|
+
const timeoutMin = Number(process.env.SLACK_CONCLUSION_TIMEOUT_MIN) || 240;
|
|
15036
|
+
const closuresByAskId = new Map;
|
|
15037
|
+
const ownerAskId = new Map;
|
|
15038
|
+
if (delegationEnabled) {
|
|
15039
|
+
for (const ask of tasks.filter((candidate) => candidate.source === "slack")) {
|
|
15040
|
+
const closure = buildAskClosure(ask, tasks);
|
|
15041
|
+
closuresByAskId.set(ask.id, closure);
|
|
14978
15042
|
for (const member of closure) {
|
|
14979
|
-
if (
|
|
14980
|
-
|
|
15043
|
+
if (!ownerAskId.has(member.id))
|
|
15044
|
+
ownerAskId.set(member.id, ask.id);
|
|
14981
15045
|
}
|
|
14982
|
-
childCardCounts.set(askId, count);
|
|
14983
|
-
return count;
|
|
14984
15046
|
}
|
|
14985
|
-
|
|
14986
|
-
|
|
14987
|
-
|
|
14988
|
-
|
|
14989
|
-
|
|
14990
|
-
|
|
14991
|
-
|
|
14992
|
-
|
|
14993
|
-
|
|
14994
|
-
|
|
14995
|
-
|
|
14996
|
-
|
|
14997
|
-
|
|
14998
|
-
|
|
14999
|
-
|
|
15000
|
-
|
|
15001
|
-
|
|
15002
|
-
|
|
15003
|
-
|
|
15004
|
-
|
|
15005
|
-
|
|
15006
|
-
|
|
15047
|
+
}
|
|
15048
|
+
const childCardCounts = new Map;
|
|
15049
|
+
async function childCardCountFor(askId) {
|
|
15050
|
+
const cached = childCardCounts.get(askId);
|
|
15051
|
+
if (cached !== undefined)
|
|
15052
|
+
return cached;
|
|
15053
|
+
const closure = closuresByAskId.get(askId) ?? [];
|
|
15054
|
+
let count = 0;
|
|
15055
|
+
for (const member of closure) {
|
|
15056
|
+
if (await getSlackOutcomeMessage2(member.id))
|
|
15057
|
+
count++;
|
|
15058
|
+
}
|
|
15059
|
+
childCardCounts.set(askId, count);
|
|
15060
|
+
return count;
|
|
15061
|
+
}
|
|
15062
|
+
let outcomeCreated = false;
|
|
15063
|
+
let childCardsThisTick = 0;
|
|
15064
|
+
for (const task of tasks) {
|
|
15065
|
+
if (!isSlackRenderV2Enabled2())
|
|
15066
|
+
return "stop";
|
|
15067
|
+
if (task.source === "slack")
|
|
15068
|
+
continue;
|
|
15069
|
+
const card = await getSlackOutcomeMessage2(task.id);
|
|
15070
|
+
if (card && isSettledSlackMessage2(card))
|
|
15071
|
+
continue;
|
|
15072
|
+
if (!delegationEnabled || delegationActivatedAt === null)
|
|
15073
|
+
continue;
|
|
15074
|
+
if (!isChildCardCandidate(task, delegationActivatedAt) || task.slackReplySent)
|
|
15075
|
+
continue;
|
|
15076
|
+
const askId = ownerAskId.get(task.id);
|
|
15077
|
+
const ownerAsk = askId ? tasks.find((candidate) => candidate.id === askId) : undefined;
|
|
15078
|
+
if (!ownerAsk || ownerAsk.createdAt < delegationActivatedAt)
|
|
15079
|
+
continue;
|
|
15080
|
+
if (childCardsThisTick >= CHILD_CARDS_PER_TICK)
|
|
15081
|
+
continue;
|
|
15082
|
+
if (askId && await childCardCountFor(askId) >= CHILD_CARDS_PER_ASK)
|
|
15083
|
+
continue;
|
|
15084
|
+
if (!await checkOutcomeDeliveryGate(task, card, statusTick.budget))
|
|
15085
|
+
continue;
|
|
15086
|
+
try {
|
|
15087
|
+
const outcome = await streamOutcomeCard(task, tree, {
|
|
15088
|
+
buildContent: childOutcomeContent,
|
|
15089
|
+
statusBudget: statusTick.budget
|
|
15090
|
+
});
|
|
15091
|
+
if (outcome) {
|
|
15092
|
+
noteOutcomeDeliverySuccess(task.id);
|
|
15093
|
+
childCardsThisTick++;
|
|
15094
|
+
if (askId)
|
|
15095
|
+
childCardCounts.set(askId, (childCardCounts.get(askId) ?? 0) + 1);
|
|
15096
|
+
await recordSlackDelivery(task, outcome, "child_outcome");
|
|
15097
|
+
}
|
|
15098
|
+
outcomeCreated ||= !!outcome;
|
|
15099
|
+
} catch (error) {
|
|
15100
|
+
await noteOutcomeDeliveryFailure(task, tree, error, statusTick.budget);
|
|
15101
|
+
}
|
|
15102
|
+
}
|
|
15103
|
+
for (const task of tasks) {
|
|
15104
|
+
if (!isSlackRenderV2Enabled2())
|
|
15105
|
+
return "stop";
|
|
15106
|
+
if (!await taskNeedsDirectOutcome(task, activatedAt))
|
|
15107
|
+
continue;
|
|
15108
|
+
const card = await getSlackOutcomeMessage2(task.id);
|
|
15109
|
+
if (card && isSettledSlackMessage2(card))
|
|
15110
|
+
continue;
|
|
15111
|
+
if (await isAnsweredByDeferralCard(task, tasks))
|
|
15112
|
+
continue;
|
|
15113
|
+
const deferByClosure = task.source === "slack" && delegationEnabled && delegationActivatedAt !== null && task.createdAt >= delegationActivatedAt;
|
|
15114
|
+
if (!deferByClosure) {
|
|
15007
15115
|
if (!await checkOutcomeDeliveryGate(task, card, statusTick.budget))
|
|
15008
15116
|
continue;
|
|
15009
15117
|
try {
|
|
15010
|
-
const outcome = await streamOutcomeCard(task, tree, {
|
|
15011
|
-
buildContent: childOutcomeContent,
|
|
15012
|
-
statusBudget: statusTick.budget
|
|
15013
|
-
});
|
|
15118
|
+
const outcome = await streamOutcomeCard(task, tree, { statusBudget: statusTick.budget });
|
|
15014
15119
|
if (outcome) {
|
|
15015
15120
|
noteOutcomeDeliverySuccess(task.id);
|
|
15016
|
-
|
|
15017
|
-
if (askId)
|
|
15018
|
-
childCardCounts.set(askId, (childCardCounts.get(askId) ?? 0) + 1);
|
|
15019
|
-
await recordSlackDelivery(task, outcome, "child_outcome");
|
|
15121
|
+
await finalizeTerminalSlackReactions([task]);
|
|
15020
15122
|
}
|
|
15021
15123
|
outcomeCreated ||= !!outcome;
|
|
15022
15124
|
} catch (error) {
|
|
15023
15125
|
await noteOutcomeDeliveryFailure(task, tree, error, statusTick.budget);
|
|
15024
15126
|
}
|
|
15127
|
+
continue;
|
|
15025
15128
|
}
|
|
15026
|
-
|
|
15027
|
-
|
|
15028
|
-
|
|
15029
|
-
|
|
15030
|
-
|
|
15031
|
-
const card = await getSlackOutcomeMessage2(task.id);
|
|
15032
|
-
if (card && isSettledSlackMessage2(card))
|
|
15033
|
-
continue;
|
|
15034
|
-
if (await isAnsweredByDeferralCard(task, tasks))
|
|
15035
|
-
continue;
|
|
15036
|
-
const deferByClosure = task.source === "slack" && delegationEnabled && delegationActivatedAt !== null && task.createdAt >= delegationActivatedAt;
|
|
15037
|
-
if (!deferByClosure) {
|
|
15038
|
-
if (!await checkOutcomeDeliveryGate(task, card, statusTick.budget))
|
|
15039
|
-
continue;
|
|
15040
|
-
try {
|
|
15041
|
-
const outcome = await streamOutcomeCard(task, tree, { statusBudget: statusTick.budget });
|
|
15042
|
-
if (outcome) {
|
|
15043
|
-
noteOutcomeDeliverySuccess(task.id);
|
|
15044
|
-
await finalizeTerminalSlackReactions([task]);
|
|
15045
|
-
}
|
|
15046
|
-
outcomeCreated ||= !!outcome;
|
|
15047
|
-
} catch (error) {
|
|
15048
|
-
await noteOutcomeDeliveryFailure(task, tree, error, statusTick.budget);
|
|
15049
|
-
}
|
|
15129
|
+
const closure = closuresByAskId.get(task.id) ?? buildAskClosure(task, tasks);
|
|
15130
|
+
let childCardPending = false;
|
|
15131
|
+
const existingChildCards = await childCardCountFor(task.id);
|
|
15132
|
+
for (const member of closure) {
|
|
15133
|
+
if (!isChildCardCandidate(member, delegationActivatedAt) || member.slackReplySent)
|
|
15050
15134
|
continue;
|
|
15135
|
+
if (existingChildCards >= CHILD_CARDS_PER_ASK)
|
|
15136
|
+
break;
|
|
15137
|
+
const memberCard = await getSlackOutcomeMessage2(member.id);
|
|
15138
|
+
if (!memberCard || !isSettledSlackMessage2(memberCard)) {
|
|
15139
|
+
childCardPending = true;
|
|
15140
|
+
break;
|
|
15051
15141
|
}
|
|
15052
|
-
|
|
15053
|
-
|
|
15054
|
-
|
|
15055
|
-
|
|
15056
|
-
|
|
15057
|
-
|
|
15058
|
-
|
|
15059
|
-
|
|
15060
|
-
|
|
15061
|
-
|
|
15062
|
-
|
|
15063
|
-
|
|
15064
|
-
|
|
15065
|
-
}
|
|
15066
|
-
if (
|
|
15067
|
-
|
|
15068
|
-
|
|
15069
|
-
|
|
15070
|
-
|
|
15071
|
-
|
|
15072
|
-
|
|
15073
|
-
try {
|
|
15074
|
-
const outcome = await streamOutcomeCard(task, tree, {
|
|
15075
|
-
buildContent: (_t, slackReplySent) => askConclusionContent(task, closure, state, slackReplySent),
|
|
15076
|
-
conclusionKind: state === "timedOut" ? "timeout" : "complete",
|
|
15077
|
-
statusBudget: statusTick.budget
|
|
15078
|
-
});
|
|
15079
|
-
if (outcome) {
|
|
15080
|
-
noteOutcomeDeliverySuccess(task.id);
|
|
15081
|
-
const app = getSlackApp2();
|
|
15082
|
-
if (app && task.slackChannelId && task.slackTriggerMessageTs) {
|
|
15083
|
-
const reaction = conclusionReactionChoice(state, task, closure);
|
|
15084
|
-
await finalizeSlackMessageReaction(app.client, task.slackChannelId, task.slackTriggerMessageTs, reaction.name, reaction.event);
|
|
15085
|
-
await finalizeSlackSteerReactions([task], () => reaction);
|
|
15086
|
-
}
|
|
15087
|
-
await recordSlackDelivery(task, outcome, state === "timedOut" ? "conclusion_timeout" : "conclusion");
|
|
15142
|
+
}
|
|
15143
|
+
if (childCardPending)
|
|
15144
|
+
continue;
|
|
15145
|
+
const state = closureState(task, closure, new Date, settleSec, timeoutMin);
|
|
15146
|
+
if (state === "open")
|
|
15147
|
+
continue;
|
|
15148
|
+
if (!await checkOutcomeDeliveryGate(task, card, statusTick.budget))
|
|
15149
|
+
continue;
|
|
15150
|
+
try {
|
|
15151
|
+
const outcome = await streamOutcomeCard(task, tree, {
|
|
15152
|
+
buildContent: (_t, slackReplySent) => askConclusionContent(task, closure, state, slackReplySent),
|
|
15153
|
+
conclusionKind: state === "timedOut" ? "timeout" : "complete",
|
|
15154
|
+
statusBudget: statusTick.budget
|
|
15155
|
+
});
|
|
15156
|
+
if (outcome) {
|
|
15157
|
+
noteOutcomeDeliverySuccess(task.id);
|
|
15158
|
+
const app = getSlackApp2();
|
|
15159
|
+
if (app && task.slackChannelId && task.slackTriggerMessageTs) {
|
|
15160
|
+
const reaction = conclusionReactionChoice(state, task, closure);
|
|
15161
|
+
await finalizeSlackMessageReaction(app.client, task.slackChannelId, task.slackTriggerMessageTs, reaction.name, reaction.event);
|
|
15162
|
+
await finalizeSlackSteerReactions([task], () => reaction);
|
|
15088
15163
|
}
|
|
15089
|
-
|
|
15090
|
-
} catch (error) {
|
|
15091
|
-
await noteOutcomeDeliveryFailure(task, tree, error, statusTick.budget);
|
|
15164
|
+
await recordSlackDelivery(task, outcome, state === "timedOut" ? "conclusion_timeout" : "conclusion");
|
|
15092
15165
|
}
|
|
15166
|
+
outcomeCreated ||= !!outcome;
|
|
15167
|
+
} catch (error) {
|
|
15168
|
+
await noteOutcomeDeliveryFailure(task, tree, error, statusTick.budget);
|
|
15169
|
+
}
|
|
15170
|
+
}
|
|
15171
|
+
try {
|
|
15172
|
+
await updateThreadTree(tree, outcomeCreated, statusTick.budget);
|
|
15173
|
+
} catch (error) {
|
|
15174
|
+
console.error(`[Slack] Failed to update v2 tree ${tree.id}:`, error);
|
|
15175
|
+
}
|
|
15176
|
+
await statusTick.reconcile(tree.channelId, tree.threadTs);
|
|
15177
|
+
try {
|
|
15178
|
+
if (await closeSlackTreeIfSettled(tree.id))
|
|
15179
|
+
return "closed";
|
|
15180
|
+
} catch (error) {
|
|
15181
|
+
console.error(`[Slack] Failed to close settled v2 tree ${tree.id}:`, error);
|
|
15182
|
+
}
|
|
15183
|
+
return "open";
|
|
15184
|
+
}
|
|
15185
|
+
function yieldToEventLoop() {
|
|
15186
|
+
return new Promise((resolve) => setImmediate(resolve));
|
|
15187
|
+
}
|
|
15188
|
+
function scheduleDirtyFlush(delayMs) {
|
|
15189
|
+
if (!renderEventsSubscribed)
|
|
15190
|
+
return;
|
|
15191
|
+
const at = Date.now() + delayMs;
|
|
15192
|
+
if (dirtyFlushTimer && dirtyFlushAt <= at)
|
|
15193
|
+
return;
|
|
15194
|
+
if (dirtyFlushTimer)
|
|
15195
|
+
clearTimeout(dirtyFlushTimer);
|
|
15196
|
+
dirtyFlushAt = at;
|
|
15197
|
+
dirtyFlushTimer = setTimeout(() => {
|
|
15198
|
+
dirtyFlushTimer = null;
|
|
15199
|
+
flushSlackRenderV2DirtyThreads().catch((error) => {
|
|
15200
|
+
console.error("[Slack] Event-driven v2 render failed:", error);
|
|
15201
|
+
});
|
|
15202
|
+
}, delayMs);
|
|
15203
|
+
}
|
|
15204
|
+
function markSlackThreadDirty(channelId, threadTs, delayMs = DIRTY_FLUSH_DEBOUNCE_MS) {
|
|
15205
|
+
dirtyThreads.set(`${channelId}\x00${threadTs}`, { channelId, threadTs });
|
|
15206
|
+
scheduleDirtyFlush(delayMs);
|
|
15207
|
+
}
|
|
15208
|
+
function onSlackRenderTaskEvent(data) {
|
|
15209
|
+
const taskId = data?.taskId;
|
|
15210
|
+
if (typeof taskId !== "string")
|
|
15211
|
+
return;
|
|
15212
|
+
dirtyTaskIds.add(taskId);
|
|
15213
|
+
scheduleDirtyFlush(DIRTY_FLUSH_DEBOUNCE_MS);
|
|
15214
|
+
}
|
|
15215
|
+
function startSlackRenderV2Events2() {
|
|
15216
|
+
if (renderEventsSubscribed)
|
|
15217
|
+
return;
|
|
15218
|
+
for (const event of SLACK_RENDER_TASK_EVENTS)
|
|
15219
|
+
workflowEventBus2.on(event, onSlackRenderTaskEvent);
|
|
15220
|
+
renderEventsSubscribed = true;
|
|
15221
|
+
}
|
|
15222
|
+
function stopSlackRenderV2Events2() {
|
|
15223
|
+
if (!renderEventsSubscribed)
|
|
15224
|
+
return;
|
|
15225
|
+
for (const event of SLACK_RENDER_TASK_EVENTS)
|
|
15226
|
+
workflowEventBus2.off(event, onSlackRenderTaskEvent);
|
|
15227
|
+
renderEventsSubscribed = false;
|
|
15228
|
+
if (dirtyFlushTimer)
|
|
15229
|
+
clearTimeout(dirtyFlushTimer);
|
|
15230
|
+
dirtyFlushTimer = null;
|
|
15231
|
+
}
|
|
15232
|
+
function runExclusive(work) {
|
|
15233
|
+
if (renderInFlight)
|
|
15234
|
+
return renderInFlight;
|
|
15235
|
+
const run = (async () => {
|
|
15236
|
+
try {
|
|
15237
|
+
await work();
|
|
15238
|
+
} finally {
|
|
15239
|
+
renderInFlight = null;
|
|
15093
15240
|
}
|
|
15241
|
+
})();
|
|
15242
|
+
renderInFlight = run;
|
|
15243
|
+
return run;
|
|
15244
|
+
}
|
|
15245
|
+
async function beginRenderPass() {
|
|
15246
|
+
const activatedAt = await ensureSlackRenderV2Activation2();
|
|
15247
|
+
const delegationEnabled = isSlackDelegationEnabled();
|
|
15248
|
+
const delegationActivatedAt = delegationEnabled ? await ensureSlackDelegationActivation2() : null;
|
|
15249
|
+
return {
|
|
15250
|
+
activatedAt,
|
|
15251
|
+
delegationEnabled,
|
|
15252
|
+
delegationActivatedAt,
|
|
15253
|
+
statusTick: beginSlackStatusTick()
|
|
15254
|
+
};
|
|
15255
|
+
}
|
|
15256
|
+
async function flushSlackRenderV2DirtyThreads() {
|
|
15257
|
+
if (!isSlackRenderV2Enabled2() || !getSlackApp2())
|
|
15258
|
+
return;
|
|
15259
|
+
if (renderInFlight) {
|
|
15260
|
+
await renderInFlight;
|
|
15261
|
+
if (dirtyTaskIds.size === 0 && dirtyThreads.size === 0)
|
|
15262
|
+
return;
|
|
15263
|
+
}
|
|
15264
|
+
await runExclusive(renderDirtyThreads);
|
|
15265
|
+
}
|
|
15266
|
+
function processSlackRenderV22() {
|
|
15267
|
+
if (!isSlackRenderV2Enabled2())
|
|
15268
|
+
return Promise.resolve();
|
|
15269
|
+
return runExclusive(reconcileAllThreads);
|
|
15270
|
+
}
|
|
15271
|
+
async function reconcileAllThreads() {
|
|
15272
|
+
dirtyTaskIds.clear();
|
|
15273
|
+
dirtyThreads.clear();
|
|
15274
|
+
const context = await beginRenderPass();
|
|
15275
|
+
for (const task of await getSlackTasksMissingTree2()) {
|
|
15276
|
+
if (!isSlackRenderV2Enabled2())
|
|
15277
|
+
return;
|
|
15278
|
+
if (!task.slackChannelId || !task.slackThreadTs)
|
|
15279
|
+
continue;
|
|
15094
15280
|
try {
|
|
15095
|
-
await
|
|
15281
|
+
await ensureSlackThreadTree2([task.id], context.statusTick.budget);
|
|
15096
15282
|
} catch (error) {
|
|
15097
|
-
console.error(`[Slack] Failed to
|
|
15283
|
+
console.error(`[Slack] Failed to create v2 tree for task ${task.id}:`, error);
|
|
15098
15284
|
}
|
|
15099
|
-
|
|
15285
|
+
}
|
|
15286
|
+
await yieldToEventLoop();
|
|
15287
|
+
for (const storedTree of await getSlackTreeMessages2()) {
|
|
15288
|
+
if (await renderStoredTree(storedTree, context) === "stop")
|
|
15289
|
+
return;
|
|
15290
|
+
await yieldToEventLoop();
|
|
15100
15291
|
}
|
|
15101
15292
|
await refreshResolvedDeferralCards();
|
|
15102
|
-
await
|
|
15293
|
+
await yieldToEventLoop();
|
|
15294
|
+
await context.statusTick.finish();
|
|
15295
|
+
}
|
|
15296
|
+
async function renderDirtyThreads() {
|
|
15297
|
+
const taskIds = [...dirtyTaskIds];
|
|
15298
|
+
dirtyTaskIds.clear();
|
|
15299
|
+
const threads = new Map(dirtyThreads);
|
|
15300
|
+
dirtyThreads.clear();
|
|
15301
|
+
const touched = await getSlackThreadsOfTasks(taskIds);
|
|
15302
|
+
for (const thread of touched.threads) {
|
|
15303
|
+
threads.set(`${thread.channelId}\x00${thread.threadTs}`, thread);
|
|
15304
|
+
}
|
|
15305
|
+
if (threads.size === 0 && !touched.wakeTouched)
|
|
15306
|
+
return;
|
|
15307
|
+
const context = await beginRenderPass();
|
|
15308
|
+
for (const thread of threads.values()) {
|
|
15309
|
+
if (!isSlackRenderV2Enabled2())
|
|
15310
|
+
return;
|
|
15311
|
+
for (const task of await getSlackTasksMissingTree2({ thread })) {
|
|
15312
|
+
try {
|
|
15313
|
+
await ensureSlackThreadTree2([task.id], context.statusTick.budget);
|
|
15314
|
+
} catch (error) {
|
|
15315
|
+
console.error(`[Slack] Failed to create v2 tree for task ${task.id}:`, error);
|
|
15316
|
+
}
|
|
15317
|
+
}
|
|
15318
|
+
for (const storedTree of await getSlackTreeMessages2({ thread })) {
|
|
15319
|
+
const result = await renderStoredTree(storedTree, context);
|
|
15320
|
+
if (result === "stop")
|
|
15321
|
+
return;
|
|
15322
|
+
if (result !== "closed" && await slackThreadHasOutcomeWork(thread)) {
|
|
15323
|
+
markSlackThreadDirty(thread.channelId, thread.threadTs, DIRTY_REVISIT_MS);
|
|
15324
|
+
}
|
|
15325
|
+
}
|
|
15326
|
+
await yieldToEventLoop();
|
|
15327
|
+
}
|
|
15328
|
+
if (touched.wakeTouched)
|
|
15329
|
+
await refreshResolvedDeferralCards();
|
|
15103
15330
|
}
|
|
15104
|
-
var TREE_UPDATE_DEBOUNCE_MS = 500, TREE_UPDATE_MIN_INTERVAL_MS = 3000, MAX_SLACK_RETRIES = 3, MAX_RETRY_DELAY_MS = 30000, MAX_TITLE_LENGTH = 72, MAX_OUTCOME_MARKDOWN_LENGTH = 12000, MAX_TREE_NODE_LINE_LENGTH = 1000, MAX_TREE_PREFIX_LENGTH = 120, MAX_TREE_PROGRESS_LENGTH = 60, CHILD_CARDS_PER_TICK = 3, CHILD_CARDS_PER_ASK = 10, CONCLUSION_DIGEST_LENGTH = 300, TREE_INDENT, FIGURE_SPACE = " ", SLACK_RENDER_METADATA_EVENT = "agent_swarm_render_v2", treeCreationPromises, pendingTreeUpdates, treeUpdateTails, lastTreeText, lastTreeUpdateAt, cachedTeamId, OUTCOME_DELIVERY_MAX_ATTEMPTS = 5, OUTCOME_DELIVERY_BASE_DELAY_MS = 30000, OUTCOME_DELIVERY_MAX_DELAY_MS, outcomeDeliveryNextAttemptAt, outcomeReservedWithoutAttempt, LINE_START_BLOCK, TRANSIENT_SLACK_ERROR_CODES, DEFERRAL_REFRESH_MAX_ATTEMPTS = 5, deferralRefreshAttempts;
|
|
15331
|
+
var TREE_UPDATE_DEBOUNCE_MS = 500, TREE_UPDATE_MIN_INTERVAL_MS = 3000, MAX_SLACK_RETRIES = 3, MAX_RETRY_DELAY_MS = 30000, MAX_TITLE_LENGTH = 72, MAX_OUTCOME_MARKDOWN_LENGTH = 12000, MAX_TREE_NODE_LINE_LENGTH = 1000, MAX_TREE_PREFIX_LENGTH = 120, MAX_TREE_PROGRESS_LENGTH = 60, CHILD_CARDS_PER_TICK = 3, CHILD_CARDS_PER_ASK = 10, CONCLUSION_DIGEST_LENGTH = 300, TREE_INDENT, FIGURE_SPACE = " ", SLACK_RENDER_METADATA_EVENT = "agent_swarm_render_v2", treeCreationPromises, pendingTreeUpdates, treeUpdateTails, lastTreeText, lastTreeUpdateAt, cachedTeamId, OUTCOME_DELIVERY_MAX_ATTEMPTS = 5, OUTCOME_DELIVERY_BASE_DELAY_MS = 30000, OUTCOME_DELIVERY_MAX_DELAY_MS, outcomeDeliveryNextAttemptAt, outcomeReservedWithoutAttempt, LINE_START_BLOCK, TRANSIENT_SLACK_ERROR_CODES, DEFERRAL_REFRESH_MAX_ATTEMPTS = 5, deferralRefreshAttempts, SLACK_RENDER_TASK_EVENTS, DIRTY_FLUSH_DEBOUNCE_MS = 500, DIRTY_REVISIT_MS = 3000, dirtyTaskIds, dirtyThreads, renderInFlight = null, renderEventsSubscribed = false, dirtyFlushTimer = null, dirtyFlushAt = 0;
|
|
15105
15332
|
var init_render_v2 = __esm(() => {
|
|
15106
15333
|
init_db4();
|
|
15334
|
+
init_slack_trees();
|
|
15107
15335
|
init_task_citations2();
|
|
15108
15336
|
init_context_key();
|
|
15109
15337
|
init_business_use();
|
|
@@ -15111,6 +15339,7 @@ var init_render_v2 = __esm(() => {
|
|
|
15111
15339
|
init_secret_scrubber();
|
|
15112
15340
|
init_task_attachment_links();
|
|
15113
15341
|
init_task_citations();
|
|
15342
|
+
init_event_bus();
|
|
15114
15343
|
init_ack();
|
|
15115
15344
|
init_app3();
|
|
15116
15345
|
init_blocks();
|
|
@@ -15140,6 +15369,17 @@ var init_render_v2 = __esm(() => {
|
|
|
15140
15369
|
"external_channel_unverified"
|
|
15141
15370
|
]);
|
|
15142
15371
|
deferralRefreshAttempts = new Map;
|
|
15372
|
+
SLACK_RENDER_TASK_EVENTS = [
|
|
15373
|
+
"task.created",
|
|
15374
|
+
"task.completed",
|
|
15375
|
+
"task.failed",
|
|
15376
|
+
"task.cancelled",
|
|
15377
|
+
"task.skipped",
|
|
15378
|
+
"task.superseded",
|
|
15379
|
+
"task.progress"
|
|
15380
|
+
];
|
|
15381
|
+
dirtyTaskIds = new Set;
|
|
15382
|
+
dirtyThreads = new Map;
|
|
15143
15383
|
});
|
|
15144
15384
|
|
|
15145
15385
|
// src/slack/watcher.ts
|
|
@@ -15491,18 +15731,25 @@ async function processPendingSlackRelays(now = Date.now()) {
|
|
|
15491
15731
|
}
|
|
15492
15732
|
}
|
|
15493
15733
|
}
|
|
15494
|
-
|
|
15734
|
+
function slackTaskWatcherIntervalMs() {
|
|
15735
|
+
const raw = process.env.SLACK_TASK_WATCHER_INTERVAL_MS?.trim();
|
|
15736
|
+
const parsed = raw ? Number(raw) : Number.NaN;
|
|
15737
|
+
return Number.isInteger(parsed) && parsed > 0 ? parsed : DEFAULT_SLACK_TASK_WATCHER_INTERVAL_MS;
|
|
15738
|
+
}
|
|
15739
|
+
async function startTaskWatcher(intervalMs = slackTaskWatcherIntervalMs()) {
|
|
15495
15740
|
if (watcherInterval) {
|
|
15496
15741
|
console.log("[Slack] Task watcher already running");
|
|
15497
15742
|
return;
|
|
15498
15743
|
}
|
|
15744
|
+
const epoch = watcherEpoch;
|
|
15499
15745
|
let hydratedTrees = 0;
|
|
15500
15746
|
let hydratedFlat = 0;
|
|
15501
15747
|
const hydrationTasks = new Map;
|
|
15502
|
-
|
|
15503
|
-
|
|
15504
|
-
|
|
15505
|
-
|
|
15748
|
+
const inProgress = await getInProgressSlackTasks2();
|
|
15749
|
+
const pendingRelays = await getPendingSlackRelayTasks2();
|
|
15750
|
+
if (epoch !== watcherEpoch || watcherInterval)
|
|
15751
|
+
return;
|
|
15752
|
+
for (const task of [...inProgress, ...pendingRelays]) {
|
|
15506
15753
|
hydrationTasks.set(task.id, task);
|
|
15507
15754
|
}
|
|
15508
15755
|
for (const task of hydrationTasks.values()) {
|
|
@@ -15545,7 +15792,8 @@ async function startTaskWatcher(intervalMs = 3000) {
|
|
|
15545
15792
|
if (hydratedTrees > 0 || hydratedFlat > 0) {
|
|
15546
15793
|
console.log(`[Slack] Hydrated ${hydratedTrees} tree task(s) and ${hydratedFlat} flat task(s) from DB`);
|
|
15547
15794
|
}
|
|
15548
|
-
|
|
15795
|
+
startSlackRenderV2Events2();
|
|
15796
|
+
const watcherTick = async () => {
|
|
15549
15797
|
if (isProcessing || !getSlackApp2())
|
|
15550
15798
|
return;
|
|
15551
15799
|
isProcessing = true;
|
|
@@ -15683,20 +15931,24 @@ async function startTaskWatcher(intervalMs = 3000) {
|
|
|
15683
15931
|
} finally {
|
|
15684
15932
|
isProcessing = false;
|
|
15685
15933
|
}
|
|
15686
|
-
}
|
|
15934
|
+
};
|
|
15935
|
+
watcherInterval = setInterval(bindLoopPath("slack.watcher.tick", watcherTick), intervalMs);
|
|
15687
15936
|
console.log(`[Slack] Task watcher started (interval: ${intervalMs}ms)`);
|
|
15688
15937
|
}
|
|
15689
15938
|
function stopTaskWatcher() {
|
|
15939
|
+
watcherEpoch += 1;
|
|
15690
15940
|
if (watcherInterval) {
|
|
15691
15941
|
clearInterval(watcherInterval);
|
|
15692
15942
|
watcherInterval = null;
|
|
15693
15943
|
isProcessing = false;
|
|
15944
|
+
stopSlackRenderV2Events2();
|
|
15694
15945
|
console.log("[Slack] Task watcher stopped");
|
|
15695
15946
|
}
|
|
15696
15947
|
}
|
|
15697
|
-
var watcherInterval = null, isProcessing = false, notifiedCompletions, sentProgress, pendingSends, lastSendTime, MIN_SEND_INTERVAL = 1000, treeMessages, taskToTree, taskMessages, lastRenderedTree, treeLastUpdateTime;
|
|
15948
|
+
var watcherInterval = null, isProcessing = false, watcherEpoch = 0, notifiedCompletions, sentProgress, pendingSends, lastSendTime, MIN_SEND_INTERVAL = 1000, treeMessages, taskToTree, taskMessages, lastRenderedTree, treeLastUpdateTime, DEFAULT_SLACK_TASK_WATCHER_INTERVAL_MS = 1e4;
|
|
15698
15949
|
var init_watcher = __esm(() => {
|
|
15699
15950
|
init_db4();
|
|
15951
|
+
init_event_loop_lag();
|
|
15700
15952
|
init_ack();
|
|
15701
15953
|
init_app3();
|
|
15702
15954
|
init_blocks();
|
|
@@ -15719,10 +15971,128 @@ var init_watcher = __esm(() => {
|
|
|
15719
15971
|
function trackConnectionState(owner) {
|
|
15720
15972
|
for (const [event, state] of Object.entries(SOCKET_EVENT_STATES)) {
|
|
15721
15973
|
owner.client.on(event, () => {
|
|
15722
|
-
if (receiver
|
|
15723
|
-
|
|
15974
|
+
if (receiver !== owner)
|
|
15975
|
+
return;
|
|
15976
|
+
setSlackConnectionState(state);
|
|
15977
|
+
if (state === "connected")
|
|
15978
|
+
lastSocketActivityAt = Date.now();
|
|
15724
15979
|
});
|
|
15725
15980
|
}
|
|
15981
|
+
owner.client.on("slack_event", () => {
|
|
15982
|
+
if (receiver === owner)
|
|
15983
|
+
lastSocketActivityAt = Date.now();
|
|
15984
|
+
});
|
|
15985
|
+
}
|
|
15986
|
+
function slackWatchdogBackoffMs(attempt, options) {
|
|
15987
|
+
return Math.min(options.backoffBaseMs * 2 ** Math.max(0, attempt - 1), options.backoffMaxMs);
|
|
15988
|
+
}
|
|
15989
|
+
function createSlackSocketWatchdog(deps, options = SLACK_SOCKET_WATCHDOG_DEFAULTS) {
|
|
15990
|
+
let downSince = null;
|
|
15991
|
+
let attempts = 0;
|
|
15992
|
+
let nextAttemptAt = 0;
|
|
15993
|
+
let restarting = false;
|
|
15994
|
+
function isHealthy(now) {
|
|
15995
|
+
if (deps.getState() !== "connected")
|
|
15996
|
+
return false;
|
|
15997
|
+
const lastActivityAt = deps.getLastActivityAt();
|
|
15998
|
+
if (lastActivityAt === null || now - lastActivityAt < options.staleActivityMs)
|
|
15999
|
+
return true;
|
|
16000
|
+
return deps.isSocketActive();
|
|
16001
|
+
}
|
|
16002
|
+
async function tick() {
|
|
16003
|
+
if (restarting || deps.isLifecycleBusy())
|
|
16004
|
+
return;
|
|
16005
|
+
const now = deps.now();
|
|
16006
|
+
if (isHealthy(now)) {
|
|
16007
|
+
if (attempts > 0 && downSince !== null) {
|
|
16008
|
+
deps.log(`[Slack] watchdog: recovered after ${seconds(now - downSince)}s`);
|
|
16009
|
+
}
|
|
16010
|
+
downSince = null;
|
|
16011
|
+
attempts = 0;
|
|
16012
|
+
nextAttemptAt = 0;
|
|
16013
|
+
return;
|
|
16014
|
+
}
|
|
16015
|
+
downSince ??= now;
|
|
16016
|
+
if (now - downSince < options.downAfterMs || now < nextAttemptAt)
|
|
16017
|
+
return;
|
|
16018
|
+
attempts += 1;
|
|
16019
|
+
nextAttemptAt = now + slackWatchdogBackoffMs(attempts, options);
|
|
16020
|
+
deps.log(`[Slack] watchdog: socket down for ${seconds(now - downSince)}s, restarting (attempt ${attempts})`);
|
|
16021
|
+
restarting = true;
|
|
16022
|
+
try {
|
|
16023
|
+
await deps.restart();
|
|
16024
|
+
} catch (error) {
|
|
16025
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
16026
|
+
console.error(`[Slack] watchdog: restart failed: ${scrubSecrets(message)}`);
|
|
16027
|
+
} finally {
|
|
16028
|
+
restarting = false;
|
|
16029
|
+
}
|
|
16030
|
+
}
|
|
16031
|
+
return { tick, attempts: () => attempts };
|
|
16032
|
+
}
|
|
16033
|
+
function seconds(ms) {
|
|
16034
|
+
return Math.round(ms / 1000);
|
|
16035
|
+
}
|
|
16036
|
+
function isLiveSocketActive() {
|
|
16037
|
+
return receiver?.client.websocket?.isActive() ?? false;
|
|
16038
|
+
}
|
|
16039
|
+
async function restartSlackAppForWatchdog(owner) {
|
|
16040
|
+
await runSlackLifecycleExclusive(async () => {
|
|
16041
|
+
if (watchdogTimer !== owner)
|
|
16042
|
+
return;
|
|
16043
|
+
if (getSlackConnectionState() === "connected" && isLiveSocketActive())
|
|
16044
|
+
return;
|
|
16045
|
+
let abandoned = false;
|
|
16046
|
+
const restart = (async () => {
|
|
16047
|
+
await teardownSlackApp();
|
|
16048
|
+
if (!abandoned && watchdogTimer === owner)
|
|
16049
|
+
await startSlackApp2();
|
|
16050
|
+
})();
|
|
16051
|
+
const timeoutMs = watchdogOptions.restartTimeoutMs;
|
|
16052
|
+
let timer;
|
|
16053
|
+
const timedOut = new Promise((resolve) => {
|
|
16054
|
+
timer = setTimeout(() => resolve(true), timeoutMs);
|
|
16055
|
+
});
|
|
16056
|
+
try {
|
|
16057
|
+
const outcome = await Promise.race([restart.then(() => false), timedOut]);
|
|
16058
|
+
if (!outcome)
|
|
16059
|
+
return;
|
|
16060
|
+
} finally {
|
|
16061
|
+
clearTimeout(timer);
|
|
16062
|
+
}
|
|
16063
|
+
abandoned = true;
|
|
16064
|
+
restart.catch(() => {});
|
|
16065
|
+
abandonSlackApp();
|
|
16066
|
+
throw new Error(`restart did not finish within ${seconds(timeoutMs)}s; abandoned it`);
|
|
16067
|
+
});
|
|
16068
|
+
}
|
|
16069
|
+
function startSocketWatchdog() {
|
|
16070
|
+
if (watchdogTimer)
|
|
16071
|
+
return;
|
|
16072
|
+
let timer = null;
|
|
16073
|
+
const watchdog = createSlackSocketWatchdog({
|
|
16074
|
+
now: Date.now,
|
|
16075
|
+
getState: getSlackConnectionState,
|
|
16076
|
+
getLastActivityAt: () => lastSocketActivityAt,
|
|
16077
|
+
isSocketActive: isLiveSocketActive,
|
|
16078
|
+
isLifecycleBusy: isSlackLifecycleBusy,
|
|
16079
|
+
restart: () => timer ? restartSlackAppForWatchdog(timer) : Promise.resolve(),
|
|
16080
|
+
log: (line) => console.log(line)
|
|
16081
|
+
}, watchdogOptions);
|
|
16082
|
+
timer = setInterval(() => {
|
|
16083
|
+
if (getSlackConfiguration().mode !== "socket") {
|
|
16084
|
+
stopSocketWatchdog();
|
|
16085
|
+
return;
|
|
16086
|
+
}
|
|
16087
|
+
watchdog.tick();
|
|
16088
|
+
}, watchdogOptions.tickMs);
|
|
16089
|
+
timer.unref?.();
|
|
16090
|
+
watchdogTimer = timer;
|
|
16091
|
+
}
|
|
16092
|
+
function stopSocketWatchdog() {
|
|
16093
|
+
if (watchdogTimer)
|
|
16094
|
+
clearInterval(watchdogTimer);
|
|
16095
|
+
watchdogTimer = null;
|
|
15726
16096
|
}
|
|
15727
16097
|
function getSlackApp2() {
|
|
15728
16098
|
return app;
|
|
@@ -15767,6 +16137,7 @@ async function initSlackApp2() {
|
|
|
15767
16137
|
installerOptions: clientOptions ? { clientOptions } : {}
|
|
15768
16138
|
});
|
|
15769
16139
|
trackConnectionState(receiver);
|
|
16140
|
+
socketFence = fenceSocketModeClient(receiver.client);
|
|
15770
16141
|
app = new import_bolt4.App({
|
|
15771
16142
|
token: botToken,
|
|
15772
16143
|
receiver,
|
|
@@ -15777,17 +16148,17 @@ async function initSlackApp2() {
|
|
|
15777
16148
|
inboundDrain = installSocketAckRecovery(receiver.client, app);
|
|
15778
16149
|
initialized2 = true;
|
|
15779
16150
|
app.use(slackInboundOutcomeMiddleware());
|
|
15780
|
-
const { registerMessageHandler } = await import("./handlers-
|
|
15781
|
-
const { registerCommandHandler } = await import("./commands-
|
|
15782
|
-
const { registerActionHandlers } = await import("./actions-
|
|
15783
|
-
const { registerWorkObjectHandlers } = await import("./work-objects-
|
|
16151
|
+
const { registerMessageHandler } = await import("./handlers-17wha3ze.js");
|
|
16152
|
+
const { registerCommandHandler } = await import("./commands-phjfbkv0.js");
|
|
16153
|
+
const { registerActionHandlers } = await import("./actions-b8aqhrsg.js");
|
|
16154
|
+
const { registerWorkObjectHandlers } = await import("./work-objects-bf3syvhq.js");
|
|
15784
16155
|
registerMessageHandler(app);
|
|
15785
16156
|
registerCommandHandler(app);
|
|
15786
16157
|
registerActionHandlers(app);
|
|
15787
16158
|
registerWorkObjectHandlers(app);
|
|
15788
|
-
const { createAssistant } = await import("./assistant-
|
|
16159
|
+
const { createAssistant } = await import("./assistant-rh4v3ntz.js");
|
|
15789
16160
|
app.assistant(createAssistant());
|
|
15790
|
-
const { isBlockExternalEnabled, scanExternalChannelsOnBoot } = await import("./external-channel-
|
|
16161
|
+
const { isBlockExternalEnabled, scanExternalChannelsOnBoot } = await import("./external-channel-se646snz.js");
|
|
15791
16162
|
if (isBlockExternalEnabled()) {
|
|
15792
16163
|
scanExternalChannelsOnBoot(app.client).catch((error) => {
|
|
15793
16164
|
console.error("[Slack] External channel boot scan failed:", error);
|
|
@@ -15796,46 +16167,97 @@ async function initSlackApp2() {
|
|
|
15796
16167
|
return app;
|
|
15797
16168
|
}
|
|
15798
16169
|
async function startSlackApp2() {
|
|
16170
|
+
const generation = lifecycleGeneration;
|
|
15799
16171
|
if (!app) {
|
|
15800
16172
|
await initSlackApp2();
|
|
15801
16173
|
}
|
|
15802
|
-
|
|
15803
|
-
|
|
16174
|
+
const current = app;
|
|
16175
|
+
if (current && generation === lifecycleGeneration) {
|
|
16176
|
+
startSocketWatchdog();
|
|
16177
|
+
const { isSlackRenderV2Enabled } = await import("./render-v2-5b6chvcq.js");
|
|
15804
16178
|
if (isSlackRenderV2Enabled())
|
|
15805
16179
|
await ensureSlackRenderV2Activation2();
|
|
15806
16180
|
await recoverSlackInboundAfterRestart();
|
|
15807
|
-
|
|
16181
|
+
if (generation !== lifecycleGeneration)
|
|
16182
|
+
return false;
|
|
16183
|
+
await current.start();
|
|
16184
|
+
if (generation !== lifecycleGeneration)
|
|
16185
|
+
return false;
|
|
15808
16186
|
console.log("[Slack] Bot connected via Socket Mode");
|
|
15809
16187
|
inboundDrain?.wake();
|
|
15810
16188
|
await emitBuiltInIntegrationConnectedOnce2("slack");
|
|
16189
|
+
if (generation !== lifecycleGeneration)
|
|
16190
|
+
return false;
|
|
15811
16191
|
await startTaskWatcher();
|
|
15812
16192
|
return true;
|
|
15813
16193
|
}
|
|
15814
16194
|
return false;
|
|
15815
16195
|
}
|
|
15816
16196
|
async function stopSlackApp2() {
|
|
16197
|
+
const locked = runSlackLifecycleExclusive(stopSlackAppUnderLifecycleLock2);
|
|
16198
|
+
const waitMs = watchdogOptions.stopLockWaitMs;
|
|
16199
|
+
let timer;
|
|
16200
|
+
const timedOut = new Promise((resolve) => {
|
|
16201
|
+
timer = setTimeout(() => resolve(true), waitMs);
|
|
16202
|
+
});
|
|
16203
|
+
try {
|
|
16204
|
+
const outcome = await Promise.race([locked.then(() => false), timedOut]);
|
|
16205
|
+
if (!outcome)
|
|
16206
|
+
return;
|
|
16207
|
+
} finally {
|
|
16208
|
+
clearTimeout(timer);
|
|
16209
|
+
}
|
|
16210
|
+
locked.catch(() => {});
|
|
16211
|
+
console.error(`[Slack] stop: lifecycle lock still held after ${seconds(waitMs)}s; stopping without it`);
|
|
16212
|
+
stopSocketWatchdog();
|
|
16213
|
+
abandonSlackApp();
|
|
16214
|
+
}
|
|
16215
|
+
async function stopSlackAppUnderLifecycleLock2() {
|
|
16216
|
+
stopSocketWatchdog();
|
|
16217
|
+
await teardownSlackApp();
|
|
16218
|
+
}
|
|
16219
|
+
async function teardownSlackApp() {
|
|
16220
|
+
const stopping = detachSlackApp();
|
|
16221
|
+
if (stopping) {
|
|
16222
|
+
await stopping.stop();
|
|
16223
|
+
console.log("[Slack] Bot disconnected");
|
|
16224
|
+
}
|
|
16225
|
+
}
|
|
16226
|
+
function abandonSlackApp() {
|
|
16227
|
+
const stalled = detachSlackApp();
|
|
16228
|
+
stalled?.stop().catch((error) => {
|
|
16229
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
16230
|
+
console.error(`[Slack] watchdog: stopping the abandoned app failed: ${scrubSecrets(message)}`);
|
|
16231
|
+
});
|
|
16232
|
+
}
|
|
16233
|
+
function detachSlackApp() {
|
|
16234
|
+
socketFence?.retire();
|
|
16235
|
+
socketFence = null;
|
|
16236
|
+
lifecycleGeneration += 1;
|
|
15817
16237
|
stopTaskWatcher();
|
|
15818
16238
|
inboundDrain?.stop();
|
|
15819
16239
|
inboundDrain = null;
|
|
15820
|
-
|
|
15821
|
-
|
|
15822
|
-
app = null;
|
|
15823
|
-
console.log("[Slack] Bot disconnected");
|
|
15824
|
-
}
|
|
16240
|
+
const detached = app;
|
|
16241
|
+
app = null;
|
|
15825
16242
|
receiver = null;
|
|
16243
|
+
lastSocketActivityAt = null;
|
|
15826
16244
|
setSlackConnectionState("disconnected");
|
|
15827
16245
|
initialized2 = false;
|
|
16246
|
+
return detached;
|
|
15828
16247
|
}
|
|
15829
|
-
var import_bolt4, app = null, receiver = null, initialized2 = false, inboundDrain = null, SOCKET_EVENT_STATES;
|
|
16248
|
+
var import_bolt4, app = null, receiver = null, initialized2 = false, inboundDrain = null, socketFence = null, lifecycleGeneration = 0, lastSocketActivityAt = null, SOCKET_EVENT_STATES, SLACK_SOCKET_WATCHDOG_DEFAULTS, watchdogTimer = null, watchdogOptions;
|
|
15830
16249
|
var init_app3 = __esm(() => {
|
|
15831
16250
|
init_db4();
|
|
15832
16251
|
init_node_env();
|
|
16252
|
+
init_secret_scrubber();
|
|
15833
16253
|
init_config4();
|
|
15834
16254
|
init_connection_state();
|
|
15835
16255
|
init_egress_scrub();
|
|
15836
16256
|
init_external_channel_egress();
|
|
15837
16257
|
init_inbound_dispatch();
|
|
16258
|
+
init_lifecycle_lock();
|
|
15838
16259
|
init_socket_ack();
|
|
16260
|
+
init_socket_fence();
|
|
15839
16261
|
init_socket_mode_guard();
|
|
15840
16262
|
init_watcher();
|
|
15841
16263
|
import_bolt4 = __toESM(require_dist5(), 1);
|
|
@@ -15846,6 +16268,16 @@ var init_app3 = __esm(() => {
|
|
|
15846
16268
|
disconnecting: "disconnected",
|
|
15847
16269
|
disconnected: "disconnected"
|
|
15848
16270
|
};
|
|
16271
|
+
SLACK_SOCKET_WATCHDOG_DEFAULTS = {
|
|
16272
|
+
tickMs: 5000,
|
|
16273
|
+
downAfterMs: 60000,
|
|
16274
|
+
staleActivityMs: 10 * 60000,
|
|
16275
|
+
backoffBaseMs: 30000,
|
|
16276
|
+
backoffMaxMs: 5 * 60000,
|
|
16277
|
+
restartTimeoutMs: 2 * 60000,
|
|
16278
|
+
stopLockWaitMs: 1e4
|
|
16279
|
+
};
|
|
16280
|
+
watchdogOptions = SLACK_SOCKET_WATCHDOG_DEFAULTS;
|
|
15849
16281
|
});
|
|
15850
16282
|
|
|
15851
|
-
export { require_dist4, require_dist5, getSlackConnectionState, init_connection_state, noteSlackInboundSideEffect, ignoreSlackInbound, reportSlackInboundFailure, isAdmittedSlackDelivery, getSlackInboundDiagnostics, init_inbound_dispatch, terminalReactionEvent, init_reaction_events, isPollTracingEnabled, initOtel, withSpan2, startSpan2, withSpanContext2, withRemoteContext2, injectTraceContext2, recordSessionCost2, recordDbRetentionSweep2, recordDbRetentionStatement2, init_otel, slackTaskOutput, init_task_output, ackSlackMessage, skipSlackMessageReaction, finalizeTerminalSlackReactions, init_ack, getTaskLink, getTaskUrl, markdownToSlack, buildMrkdwnSectionBlocks, buildCaptionBlock, buildCancelledBlocks, buildBufferFlushBlocks, buildTreeBlocks, init_blocks, taskCitationIssues, stripInvalidTaskCitations, taskCitationSourceGroups, renderTaskCitations, taskCitationWarnings, init_task_citations, MAX_TASK_CITATIONS, CitationInputSchema, TaskCitationSchema, upsertTaskCitations, getTaskCitations, getTaskCitationsForTasks, hasTaskCitationCheckRefusal, init_task_citations2, initialize, ensure, init_business_use, getAgentDisplayName, getAgentSlackIcon, init_responses, markSlackSessionProcessing, init_session_status, isSlackRenderV2Enabled2, callSlackWithRetry2, ensureSlackThreadTree2, slackErrorCode2, processSlackRenderV22, init_render_v2, registerTreeMessage, init_watcher, getSlackApp2, initSlackApp2, startSlackApp2, stopSlackApp2, init_app3 };
|
|
16283
|
+
export { require_dist4, require_dist5, getSlackConnectionState, init_connection_state, noteSlackInboundSideEffect, ignoreSlackInbound, reportSlackInboundFailure, isAdmittedSlackDelivery, getSlackInboundDiagnostics, init_inbound_dispatch, runSlackLifecycleExclusive, init_lifecycle_lock, terminalReactionEvent, init_reaction_events, isPollTracingEnabled, initOtel, withSpan2, startSpan2, withSpanContext2, withRemoteContext2, injectTraceContext2, recordSessionCost2, recordDbRetentionSweep2, recordDbRetentionStatement2, init_otel, slackTaskOutput, init_task_output, ackSlackMessage, skipSlackMessageReaction, finalizeTerminalSlackReactions, init_ack, getTaskLink, getTaskUrl, markdownToSlack, buildMrkdwnSectionBlocks, buildCaptionBlock, buildCancelledBlocks, buildBufferFlushBlocks, buildTreeBlocks, init_blocks, taskCitationIssues, stripInvalidTaskCitations, taskCitationSourceGroups, renderTaskCitations, taskCitationWarnings, init_task_citations, MAX_TASK_CITATIONS, CitationInputSchema, TaskCitationSchema, upsertTaskCitations, getTaskCitations, getTaskCitationsForTasks, hasTaskCitationCheckRefusal, init_task_citations2, initialize, ensure, init_business_use, getAgentDisplayName, getAgentSlackIcon, init_responses, markSlackSessionProcessing, init_session_status, isSlackRenderV2Enabled2, callSlackWithRetry2, ensureSlackThreadTree2, slackErrorCode2, startSlackRenderV2Events2, stopSlackRenderV2Events2, processSlackRenderV22, init_render_v2, registerTreeMessage, init_watcher, getSlackApp2, initSlackApp2, startSlackApp2, stopSlackApp2, stopSlackAppUnderLifecycleLock2, init_app3 };
|