@desplega.ai/agent-swarm 2.9.1 → 2.11.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/acp-adapter-weaaxey3.js +16 -0
- package/dist/{acp-targets-ny75x1qy.js → acp-targets-5wyy2b9m.js} +9 -9
- package/dist/{actions-b9qgrmeq.js → actions-4nxq386s.js} +54 -32
- package/dist/{agent-fs-provision-b5dhdsbd.js → agent-fs-provision-v6enh76w.js} +4 -4
- package/dist/{amp-adapter-vtax2c9s.js → amp-adapter-ze3x22qn.js} +3 -3
- package/dist/{anthropic-messages-r5xf5hqw.js → anthropic-messages-88b7s3n9.js} +189 -37
- package/dist/{app-g2z15hax.js → app-kyqt8ehw.js} +7 -6
- package/dist/{approval-notifications-yt13wp8r.js → approval-notifications-a0db0esw.js} +7 -6
- package/dist/{assistant-2cgfxsgk.js → assistant-9g5jzq25.js} +26 -25
- package/dist/{azure-openai-responses-590s1eea.js → azure-openai-responses-jeaas6x0.js} +18 -18
- package/dist/{boot-args-schema-3gwy0f60.js → boot-args-schema-d7fme4q1.js} +1 -1
- package/dist/{boot-reembed-92g7s5zp.js → boot-reembed-6wpazmpw.js} +1 -1
- package/dist/{boot-reembed-mywmyp4s.js → boot-reembed-jrwxeye2.js} +1 -1
- package/dist/boot-scrub-sweep-52h7yntp.js +9 -0
- package/dist/{boot-seeds-ce7rvgq1.js → boot-seeds-kb3dxjex.js} +4 -4
- package/dist/{boxd-wn235q80.js → boxd-jrrmkv3w.js} +2 -2
- package/dist/{claude-adapter-3m4q7735.js → claude-adapter-0c0y8fqp.js} +8 -8
- package/dist/{claude-managed-adapter-t8nfgcgz.js → claude-managed-adapter-w2es07qq.js} +4 -4
- package/dist/{claude-managed-setup-c217draw.js → claude-managed-setup-9ssb7ct4.js} +4 -4
- package/dist/{claude-sdk-session-7fbqm51z.js → claude-sdk-session-p6t0gyse.js} +10941 -10412
- package/dist/{cli-2czxfnvj.js → cli-075ccjh6.js} +961 -178
- package/dist/{cli-fkef327x.js → cli-0bgj4rh5.js} +3 -3
- package/dist/{cli-1jykg0py.js → cli-14xdms9a.js} +41 -28
- package/dist/{cli-rqx70rcz.js → cli-17qzb39j.js} +5 -2
- package/dist/{cli-bkjdknnp.js → cli-1h4njv9y.js} +177 -7
- package/dist/{cli-6ym4jhzp.js → cli-27fat7st.js} +7 -7
- package/dist/{cli-kxx4k2jw.js → cli-2aacfdcn.js} +5 -5
- package/dist/{cli-fh97xn30.js → cli-2gvdvsxj.js} +3 -3
- package/dist/{cli-f9gz2vyj.js → cli-2jtfm8kh.js} +10 -10
- package/dist/{cli-6ehs4mta.js → cli-2z2c4k6q.js} +18 -4
- package/dist/{cli-6237rnyr.js → cli-3bpr3wks.js} +1 -1
- package/dist/{cli-bnqncekd.js → cli-453497a0.js} +44 -17
- package/dist/{cli-jm0hvmz2.js → cli-4aswccje.js} +2 -2
- package/dist/{cli-4ymxrwg5.js → cli-4dyzzkfb.js} +2 -2
- package/dist/{cli-vyff45ve.js → cli-4g323fjh.js} +772 -515
- package/dist/{cli-3kd08rej.js → cli-4jjrhy48.js} +1 -1
- package/dist/{cli-gfy38pvt.js → cli-4kzp7r0q.js} +8 -8
- package/dist/{cli-kxn3747f.js → cli-4se3x6qm.js} +1 -26
- package/dist/{cli-mjw0yf82.js → cli-5ptj757f.js} +1 -1
- package/dist/{cli-pyjn0qhk.js → cli-6a3j25xd.js} +348 -196
- package/dist/{cli-hnamkvnc.js → cli-6c9ve77f.js} +2 -2
- package/dist/{cli-mw620q3n.js → cli-6n7y5ypy.js} +1 -1
- package/dist/{cli-g0vv9dg4.js → cli-6p8p2e6r.js} +19 -12
- package/dist/{cli-jwampxxq.js → cli-6tvh1fwq.js} +3 -3
- package/dist/{cli-p74md7t8.js → cli-7b7rxz22.js} +13 -15
- package/dist/{cli-5a6pqy45.js → cli-7e8sxqv5.js} +1 -1
- package/dist/{cli-p4kckx1z.js → cli-892y3vfp.js} +13 -13
- package/dist/cli-8mfdbdhe.js +43 -0
- package/dist/{cli-mkwkwq81.js → cli-8zmpwe79.js} +29 -16
- package/dist/{cli-zcfpsfzf.js → cli-96234j5w.js} +3 -3
- package/dist/{cli-1z4qggfe.js → cli-9fvk9mv8.js} +30 -21
- package/dist/{cli-7mv4h3sn.js → cli-9g12h1aq.js} +2 -2
- package/dist/{cli-f8x9drqr.js → cli-9knhkkgr.js} +19 -5
- package/dist/{cli-5mpy301f.js → cli-9t7syepg.js} +1 -1
- package/dist/{cli-qj39vrc6.js → cli-9yjhshah.js} +1 -1
- package/dist/{cli-zr6qy15y.js → cli-a02habn6.js} +427 -145
- package/dist/{cli-7evph51z.js → cli-a49frv85.js} +2 -2
- package/dist/{cli-h9yqfzx9.js → cli-a6q6x15h.js} +11 -10
- package/dist/{cli-bg63qmsx.js → cli-atm0hkes.js} +11 -11
- package/dist/{cli-m7zvgt57.js → cli-b82a13ga.js} +13 -13
- package/dist/{cli-7zm3b3f5.js → cli-bf0t77nf.js} +1 -1
- package/dist/{cli-2xv18ywz.js → cli-bmqp0ser.js} +2 -2
- package/dist/{cli-xag7btpe.js → cli-bq97k63w.js} +2 -2
- package/dist/{cli-pb2ay3sh.js → cli-cstggwq7.js} +5 -5
- package/dist/{cli-f3jyzq4g.js → cli-czvvnfr9.js} +3 -3
- package/dist/{cli-b6px1k1q.js → cli-dd2k2mcd.js} +1 -1
- package/dist/{cli-nafvvsp8.js → cli-djt6wmrc.js} +9 -9
- package/dist/{cli-tsa40663.js → cli-ebqx630g.js} +3 -3
- package/dist/{cli-8zh9nrew.js → cli-f7dhm7hh.js} +1 -1
- package/dist/cli-f8yhybxr.js +321 -0
- package/dist/{cli-5gpqgs8b.js → cli-fwjwkw66.js} +2 -2
- package/dist/{cli-gabsjg8x.js → cli-g56fxddf.js} +1 -1
- package/dist/{cli-w4n323t3.js → cli-h2qtafm4.js} +19 -19
- package/dist/{cli-psffsanb.js → cli-ha4ek2nb.js} +6 -1
- package/dist/{cli-dgs10ttj.js → cli-hnh8erra.js} +2 -2
- package/dist/{cli-w16kwbzw.js → cli-htymm48w.js} +1 -1
- package/dist/{cli-2xs8tsf7.js → cli-j2r1apqm.js} +152 -67
- package/dist/{cli-43ms35q9.js → cli-k3c13za2.js} +3 -3
- package/dist/{cli-54vrpgm0.js → cli-k3facve0.js} +8 -5
- package/dist/{cli-67mwzr35.js → cli-k4r5sfaj.js} +7 -7
- package/dist/{cli-rq5rpv6k.js → cli-kbm659dk.js} +2 -2
- package/dist/{cli-j7svy295.js → cli-m00c47q6.js} +114 -31
- package/dist/{cli-m7c2380k.js → cli-mhrr4d5b.js} +99 -14
- package/dist/{cli-xqdz5cqm.js → cli-mz7ycqn8.js} +1 -0
- package/dist/{cli-vt89089n.js → cli-n6ygvrrm.js} +4 -4
- package/dist/{cli-jaw5v1sy.js → cli-nbakg5xh.js} +3 -3
- package/dist/{cli-nbt14he0.js → cli-nc39ym5q.js} +8 -8
- package/dist/{cli-tvc4jag9.js → cli-p1a4khta.js} +8 -8
- package/dist/{cli-t9ga4qmb.js → cli-p8zqbbt1.js} +40 -33
- package/dist/{cli-fjggej24.js → cli-ph95yejc.js} +2 -2
- package/dist/{cli-m0cy2vyf.js → cli-q4z9s6zs.js} +5 -5
- package/dist/cli-q71g5q39.js +404 -0
- package/dist/{cli-vs9vdpy0.js → cli-qncx2r0s.js} +1 -1
- package/dist/{cli-hg42n3hx.js → cli-qrzq3hvg.js} +8 -8
- package/dist/{cli-x40a0w9j.js → cli-r813c7rb.js} +1 -1
- package/dist/{cli-kpgcm7xy.js → cli-ramn8jae.js} +1 -1
- package/dist/{cli-jkw6ptfw.js → cli-raqw9fw9.js} +28 -17
- package/dist/cli-rhsc2zyx.js +68 -0
- package/dist/{cli-sn650d7x.js → cli-rpmw4fsv.js} +68 -20
- package/dist/{boot-scrub-sweep-7dkdzqxx.js → cli-rwgwen5v.js} +9 -10
- package/dist/{cli-3j873zxq.js → cli-rytq7dm2.js} +261 -6
- package/dist/{cli-zh0e5x7p.js → cli-s9twe4x0.js} +71 -22
- package/dist/{cli-2dq9yv8p.js → cli-t2s7j5cy.js} +2 -2
- package/dist/{cli-wn13hhdt.js → cli-tb4j757d.js} +7 -7
- package/dist/{cli-q2d3e1k1.js → cli-thd3005a.js} +1 -1
- package/dist/cli-tsfkcd4v.js +30 -0
- package/dist/{cli-br0924pw.js → cli-v3zcnr8g.js} +1 -1
- package/dist/{cli-zfqg6fzn.js → cli-vbppqvte.js} +3 -3
- package/dist/{cli-ysvspf5e.js → cli-vy3fn0mz.js} +4 -4
- package/dist/{cli-7sf9sb0w.js → cli-w5dar1bk.js} +1 -1
- package/dist/{cli-2yjj3e31.js → cli-wz4e5am2.js} +12 -10
- package/dist/{cli-td9tb872.js → cli-xqbqwpxr.js} +14 -14
- package/dist/{cli-32djehja.js → cli-ynph3b70.js} +11137 -8332
- package/dist/{cli-mhapr559.js → cli-yvzxbztc.js} +9 -4
- package/dist/{cli-v57d7fmm.js → cli-yzxqwcvq.js} +25 -27
- package/dist/{cli-y2ewxhth.js → cli-zb1hff00.js} +16 -16
- package/dist/{cli-yab6sh8p.js → cli-zcghfsdg.js} +23 -4
- package/dist/{cli-ctx0b85j.js → cli-zhn4r1rz.js} +757 -157
- package/dist/{cli-6945ywhr.js → cli-zqq57pgx.js} +9 -7
- package/dist/cli.js +30 -29
- package/dist/{cloudflare-workers-ai-system-one-9y1zx3pt.js → cloudflare-workers-ai-system-one-w3m0fbf8.js} +2 -2
- package/dist/{codex-adapter-n656pvb8.js → codex-adapter-ssahg4h4.js} +8 -8
- package/dist/{codex-hook-59atdwd8.js → codex-hook-aqtj17yr.js} +1 -1
- package/dist/{codex-login-a239g1ah.js → codex-login-9c7aggxe.js} +1 -1
- package/dist/{codex-session-runner-p0fbv5y9.js → codex-session-runner-xn63q3h7.js} +9 -9
- package/dist/{commands-gwea8z5p.js → commands-ctey7tr5.js} +3 -3
- package/dist/{controller-t67c3grh.js → controller-rqhbppg9.js} +4 -4
- package/dist/{controllers-connect-ks155r0h.js → controllers-connect-w3qbpbt1.js} +22 -21
- package/dist/core-df1n049h.js +39 -0
- package/dist/{cursor-adapter-ygwrtmkv.js → cursor-adapter-r819hf1a.js} +2 -2
- package/dist/{db-kpmx06s9.js → db-2ah39cyx.js} +2 -2
- package/dist/{db-rb2xqdb1.js → db-p5drc1d1.js} +3 -3
- package/dist/{devin-adapter-zp4tqq53.js → devin-adapter-bc6g0x29.js} +1 -1
- package/dist/{dispatcher-31sm0ej2.js → dispatcher-x6w14pde.js} +19 -18
- package/dist/{docker-09tkkg0n.js → docker-6c4reetq.js} +51 -14
- package/dist/{dsh-adapter-qyxh0w31.js → dsh-adapter-h8qn14n4.js} +2 -2
- package/dist/{e2b-sm28k0k3.js → e2b-jg7kyyef.js} +6 -6
- package/dist/{e2b-3v1e745x.js → e2b-z4ec0qve.js} +3 -3
- package/dist/{easter-egg-3d-00wjscn6.js → easter-egg-3d-1y6r9gxy.js} +1 -1
- package/dist/{embedding-space-qhw4g68n.js → embedding-space-z6ptw3jk.js} +6 -6
- package/dist/{embeddings-zdv9ke6x.js → embeddings-0sxb1d2h.js} +1 -1
- package/dist/{event-bus-xr83x566.js → event-bus-swr88jg5.js} +1 -1
- package/dist/{execute-zna8wwr7.js → execute-6m1ex8ce.js} +8 -4
- package/dist/{external-channel-1ac6t56s.js → external-channel-ezer7pk0.js} +2 -2
- package/dist/fx-adapter-zwmps9re.js +19 -0
- package/dist/{google-generative-ai-maq6c9bf.js → google-generative-ai-sw77egmr.js} +13 -13
- package/dist/{google-vertex-2jgsw2nb.js → google-vertex-rrw93g8h.js} +13 -13
- package/dist/grok-adapter-q0avf919.js +19 -0
- package/dist/handlers-g5jq0e4q.js +36 -0
- package/dist/{heartbeat-2f6z4kdx.js → heartbeat-6c4fr49t.js} +22 -21
- package/dist/{hook-8y0gvtp1.js → hook-02rt5tvq.js} +8 -8
- package/dist/{hook-w1skzaqc.js → hook-t1c5avbv.js} +5 -5
- package/dist/{http-wghxvpef.js → http-qa3h32a1.js} +2659 -355
- package/dist/index-1f6m47mq.js +37 -0
- package/dist/index-1p1mpqda.js +36 -0
- package/dist/{index-rv89fvzf.js → index-akbgsdhh.js} +25 -24
- package/dist/{index-9zkchs9t.js → index-e42j998x.js} +190 -15
- package/dist/{index-b5wgnm78.js → index-kdmkfjt7.js} +4 -4
- package/dist/{index-s71ez27v.js → index-kqv9ebfj.js} +1 -1
- package/dist/{index-9myfj74s.js → index-kzdqn3dd.js} +3 -3
- package/dist/{index-4a0670yh.js → index-p2f5xg64.js} +6 -6
- package/dist/{index-8zn8nxn5.js → index-qpjk2hxk.js} +1 -1
- package/dist/index-tnkd410q.js +41 -0
- package/dist/k8s-7jrh5va2.js +276 -0
- package/dist/{keepalive-sh02349h.js → keepalive-jmf6pn8c.js} +4 -4
- package/dist/lead-m5e7xt93.js +75 -0
- package/dist/{llama-cpp-classify-nfgswa1m.js → llama-cpp-classify-yvb8vh7w.js} +2 -2
- package/dist/{maintenance-yj0dcjja.js → maintenance-g7v15tj1.js} +1 -1
- package/dist/{mistral-conversations-0c30em7t.js → mistral-conversations-w4bncwbt.js} +11 -11
- package/dist/{node-7qsx5kvm.js → node-z67yjre7.js} +19 -13
- package/dist/{oauth-refresh-sweep-d9xedk66.js → oauth-refresh-sweep-ywgf8tbr.js} +3 -3
- package/dist/{onboard-dpgjn03r.js → onboard-m3fedypq.js} +6 -6
- package/dist/{openai-codex-responses-bkcd8pjj.js → openai-codex-responses-70g39cgz.js} +24 -18
- package/dist/{openai-completions-f3n69rep.js → openai-completions-cv3hp4h5.js} +33 -26
- package/dist/{openai-decisions-q3hh60wr.js → openai-decisions-fyq1p9f9.js} +2 -2
- package/dist/{openai-responses-gbh0wfqe.js → openai-responses-trsvnks6.js} +24 -22
- package/dist/{opencode-adapter-2d31cpjc.js → opencode-adapter-19ktcbb9.js} +7 -7
- package/dist/{openrouter-images-xr9gme9x.js → openrouter-images-0jj12a2q.js} +6 -6
- package/dist/{otel-impl-1skarpfq.js → otel-impl-3ehm1hgc.js} +2 -2
- package/dist/{pending-bfmxtx0g.js → pending-fwj2fatd.js} +20 -19
- package/dist/{pi-messages-zebyt7gb.js → pi-messages-zk3g4esn.js} +6 -6
- package/dist/{pi-mono-adapter-gvppnasy.js → pi-mono-adapter-xdeesvc4.js} +18 -17
- package/dist/{pricing-refresh-c6b325mk.js → pricing-refresh-4j8dzvxg.js} +2 -2
- package/dist/{rbac-roles-h80qbdbs.js → rbac-roles-8msjr07m.js} +3 -3
- package/dist/{rbac-roles-zfcx68tx.js → rbac-roles-n7t2acv8.js} +2 -2
- package/dist/{render-v2-nx20t3rb.js → render-v2-j7qggj8h.js} +7 -6
- package/dist/{resume-5ep8agan.js → resume-hj1mn65y.js} +9 -8
- package/dist/{runtime-r3pj4mce.js → runtime-z31mdsgv.js} +2 -2
- package/dist/{session-access-n7p3m15b.js → session-access-w38fh09a.js} +4 -4
- package/dist/{session-source-backfill-v8mt0zwn.js → session-source-backfill-ax6qxv20.js} +3 -3
- package/dist/{setup-z1psaqhe.js → setup-dsqmpfcr.js} +1 -1
- package/dist/thread-buffer-nf55vwx3.js +39 -0
- package/dist/tree-visibility-6vqmnr71.js +24 -0
- package/dist/{typesafe-system-one-f2en2knd.js → typesafe-system-one-qkvkgrcz.js} +2 -2
- package/dist/user-merge-jobs-mvheb3ed.js +22 -0
- package/dist/{virtual-modules-rrbjdpxn.js → virtual-modules-w2qk2wew.js} +32 -10
- package/dist/{work-objects-4aghh73z.js → work-objects-4ahy5es5.js} +22 -21
- package/dist/worker-ews1nyhw.js +75 -0
- package/dist/{worker-follow-up-166zmex1.js → worker-follow-up-1gs4aw7y.js} +19 -18
- package/dist/{x-wg164ss9.js → x-3wr8c5sh.js} +2 -2
- package/openapi.json +2576 -388
- package/package.json +11 -10
- package/src/be/boot-seeds.ts +7 -1
- package/src/be/db/model-groups.ts +238 -0
- package/src/be/db/model-profiles.ts +26 -8
- package/src/be/db/request-composition.ts +190 -0
- package/src/be/db/runtime.ts +15 -0
- package/src/be/db/session-costs.ts +8 -2
- package/src/be/db/slack-trees.ts +220 -10
- package/src/be/db/tasks/human-free.ts +3 -2
- package/src/be/db/tasks/read.ts +3 -2
- package/src/be/db/tasks/write.ts +2 -1
- package/src/be/db/user-references.ts +75 -0
- package/src/be/db/users/references.ts +185 -0
- package/src/be/db/workflow-run-retention.ts +101 -0
- package/src/be/db-client.ts +93 -20
- package/src/be/db-retention-defaults.ts +46 -0
- package/src/be/db-retention.ts +55 -6
- package/src/be/db.ts +32 -57
- package/src/be/key-window-usage.ts +1 -0
- package/src/be/mcp-events/catalog.ts +108 -0
- package/src/be/mcp-events/dispatcher.ts +202 -0
- package/src/be/mcp-events/protocol.ts +296 -0
- package/src/be/mcp-events/store.ts +231 -0
- package/src/be/mcp-events/webhook.ts +226 -0
- package/src/be/memory/demotion-evidence.ts +34 -0
- package/src/be/memory/providers/sqlite-store.ts +110 -24
- package/src/be/memory/reranker.ts +34 -12
- package/src/be/memory/review-recall-filter.ts +105 -0
- package/src/be/memory/search-candidates.ts +16 -5
- package/src/be/memory/types.ts +16 -0
- package/src/be/migrations/312_task_ui_action_runs_repeatable.sql +6 -0
- package/src/be/migrations/314_model_groups.sql +85 -0
- package/src/be/migrations/318_superseded_workflow_cut_backfill.sql +22 -0
- package/src/be/migrations/319_user_fk_indexes.sql +153 -0
- package/src/be/migrations/320_session_costs_kind.sql +4 -0
- package/src/be/migrations/321_user_merge_jobs.sql +52 -0
- package/src/be/migrations/322_runtime_pool_workspace.sql +8 -0
- package/src/be/migrations/323_slack_task_tree_visibility.sql +9 -0
- package/src/be/migrations/326_slack_reconcile_pages.sql +13 -0
- package/src/be/migrations/327_mcp_event_subscriptions.sql +57 -0
- package/src/be/migrations/329_workflow_run_retention.sql +9 -0
- package/src/be/migrations/330_request_composition.sql +22 -0
- package/src/be/model-profile-check.ts +1 -1
- package/src/be/multi-runtime.ts +32 -4
- package/src/be/pricing-normalize.ts +2 -0
- package/src/be/rbac-roles.ts +6 -4
- package/src/be/runtime-pools/controllers.ts +18 -3
- package/src/be/runtime-pools/db.ts +35 -9
- package/src/be/runtime-pools/supervisor.ts +57 -3
- package/src/be/scripts/db.ts +11 -0
- package/src/be/scripts/typecheck.ts +2 -0
- package/src/be/seed-model-groups.ts +86 -0
- package/src/be/seed-model-profiles.ts +20 -13
- package/src/be/seed-scripts/catalog/dreaming-gather.ts +165 -1
- package/src/be/swarm-config-guard.ts +44 -2
- package/src/be/task-ui-spec.ts +102 -1
- package/src/be/user-merge-jobs.ts +564 -0
- package/src/be/users.ts +41 -23
- package/src/commands/context-preamble.ts +11 -4
- package/src/commands/credential-outcome-report.ts +33 -9
- package/src/commands/e2b-stack-wizard.tsx +12 -6
- package/src/commands/onboard/agent-fs-version.ts +1 -1
- package/src/commands/onboard/compose-generator.ts +1 -1
- package/src/commands/onboard/env-generator.ts +1 -1
- package/src/commands/provider-credentials.ts +1 -1
- package/src/commands/runner.ts +116 -12
- package/src/extensions/catalog.generated.json +1 -1
- package/src/extensions/contract-types.generated.ts +1 -1
- package/src/extensions/contract.ts +15 -0
- package/src/extensions/dispatcher.ts +14 -4
- package/src/github/app.ts +59 -14
- package/src/github/handlers.ts +57 -0
- package/src/github/types.ts +4 -0
- package/src/http/all-routes.ts +4 -0
- package/src/http/approval-requests.ts +5 -1
- package/src/http/auth.ts +3 -1
- package/src/http/config.ts +36 -2
- package/src/http/core.ts +2 -0
- package/src/http/github-token.ts +66 -0
- package/src/http/index.ts +34 -0
- package/src/http/mcp-user.ts +11 -8
- package/src/http/mcp.ts +58 -42
- package/src/http/memory.ts +19 -6
- package/src/http/model-groups.ts +277 -0
- package/src/http/model-profiles.ts +30 -13
- package/src/http/prompt-templates.ts +1 -0
- package/src/http/request-composition.ts +310 -0
- package/src/http/tasks.ts +46 -6
- package/src/http/tool-hooks.ts +140 -0
- package/src/http/tool-schema-estimate.ts +95 -0
- package/src/http/users.ts +142 -19
- package/src/http/workflows.ts +37 -1
- package/src/integrations/chat-sdk/inbound.ts +8 -2
- package/src/integrations/chat-sdk/limits.ts +8 -3
- package/src/prompts/base-prompt.ts +133 -7
- package/src/prompts/resolver.ts +41 -2
- package/src/providers/acp-targets.ts +2 -2
- package/src/providers/amp-adapter.ts +1 -1
- package/src/providers/opencode-adapter.ts +72 -1
- package/src/providers/opencode-swarm-plugin.ts +22 -3
- package/src/providers/pi-mono-adapter.ts +1 -0
- package/src/providers/pi-mono-extension.ts +71 -0
- package/src/providers/pricing-sources.md +13 -0
- package/src/providers/request-composition-hook.ts +312 -0
- package/src/providers/types.ts +5 -0
- package/src/rbac/legacy-policy.ts +1 -0
- package/src/rbac/permissions.ts +5 -0
- package/src/runtime-providers/controller-protocol.ts +7 -0
- package/src/runtime-providers/docker.ts +80 -12
- package/src/runtime-providers/index.ts +7 -5
- package/src/runtime-providers/k8s.ts +355 -0
- package/src/runtime-providers/types.ts +17 -0
- package/src/scheduler/scheduler.ts +1 -1
- package/src/scripts-runtime/types/stdlib.d.ts +2 -0
- package/src/scripts-runtime/types/swarm-extension.d.ts +16 -1
- package/src/scripts-runtime/types/swarm-sdk.d.ts +2 -0
- package/src/server-user.ts +16 -1
- package/src/slack/ack.ts +10 -5
- package/src/slack/actions.ts +36 -13
- package/src/slack/app.ts +2 -0
- package/src/slack/assistant.ts +4 -4
- package/src/slack/blocks.ts +26 -5
- package/src/slack/handlers.ts +3 -3
- package/src/slack/reaction-shortcode.ts +23 -2
- package/src/slack/render-v2.ts +344 -200
- package/src/slack/responses.ts +7 -5
- package/src/slack/thread-buffer.ts +3 -3
- package/src/slack/tree-visibility.ts +64 -0
- package/src/tasks/worker-follow-up.ts +127 -17
- package/src/tests/acp-adapter.test.ts +26 -0
- package/src/tests/azure-devops-outbound.test.ts +47 -14
- package/src/tests/base-prompt.test.ts +149 -1
- package/src/tests/chat-sdk-relay.test.ts +21 -1
- package/src/tests/check-playwright-version.test.ts +33 -0
- package/src/tests/check-pr-body.test.ts +43 -0
- package/src/tests/context-preamble-budget.test.ts +65 -0
- package/src/tests/credential-check.test.ts +14 -6
- package/src/tests/credential-outcome-report.test.ts +81 -1
- package/src/tests/db-client.test.ts +168 -0
- package/src/tests/db-retention-defaults.test.ts +244 -0
- package/src/tests/db-retention.test.ts +2 -1
- package/src/tests/db-runtime.test.ts +2 -1
- package/src/tests/deploy-guard.test.ts +7 -7
- package/src/tests/deploy-release-dispatch.test.ts +332 -0
- package/src/tests/deploy-select.test.ts +83 -0
- package/src/tests/dreaming-gather-corrections.test.ts +467 -0
- package/src/tests/e2b-stack-wizard.test.tsx +156 -0
- package/src/tests/entrypoint-chown-no-follow.test.ts +69 -0
- package/src/tests/entrypoint-repo-clone-target.test.ts +112 -0
- package/src/tests/env-flag.test.ts +4 -2
- package/src/tests/event-loop-lag.test.ts +16 -20
- package/src/tests/extensions-example-slack-reply-gate.test.ts +15 -0
- package/src/tests/fixtures/base-prompt-baseline-cases.ts +78 -0
- package/src/tests/fixtures/base-prompt-baseline.json +18 -0
- package/src/tests/fixtures/extensions/native-tool-recorder/hooks.ts +26 -0
- package/src/tests/fixtures/extensions/native-tool-recorder/manifest.json +10 -0
- package/src/tests/fixtures/onboard/content.compose.yml.txt +1 -1
- package/src/tests/fixtures/onboard/content.env.txt +1 -1
- package/src/tests/fixtures/onboard/dev.compose.yml.txt +1 -1
- package/src/tests/fixtures/onboard/dev.env.txt +1 -1
- package/src/tests/fixtures/onboard/full-all.compose.yml.txt +1 -1
- package/src/tests/fixtures/onboard/full-all.env.txt +1 -1
- package/src/tests/fixtures/onboard/full.compose.yml.txt +1 -1
- package/src/tests/fixtures/onboard/full.env.txt +1 -1
- package/src/tests/fixtures/onboard/research.compose.yml.txt +1 -1
- package/src/tests/fixtures/onboard/research.env.txt +1 -1
- package/src/tests/fixtures/onboard/solo.compose.yml.txt +1 -1
- package/src/tests/fixtures/onboard/solo.env.txt +1 -1
- package/src/tests/github-app-worker-auth-helper.test.ts +325 -0
- package/src/tests/github-event-filter.test.ts +8 -0
- package/src/tests/github-handlers-inline-comments.test.ts +2 -0
- package/src/tests/github-handlers-reactions.test.ts +4 -0
- package/src/tests/github-handlers.test.ts +3 -0
- package/src/tests/github-installation-token-route.test.ts +199 -0
- package/src/tests/github-sender-trust.test.ts +223 -0
- package/src/tests/http-users.test.ts +142 -41
- package/src/tests/k8s-pool-smoke.test.ts +190 -0
- package/src/tests/key-window-usage.test.ts +15 -0
- package/src/tests/mcp-user-events.test.ts +708 -0
- package/src/tests/memory-key-paths.test.ts +4 -1
- package/src/tests/memory-rater-store.test.ts +35 -1
- package/src/tests/memory-reranker.test.ts +39 -4
- package/src/tests/memory-review-recall-filter.test.ts +205 -0
- package/src/tests/memory-search-stall.test.ts +421 -0
- package/src/tests/migration-318-superseded-workflow-cut-backfill.test.ts +74 -0
- package/src/tests/migration-322-runtime-pool-workspace.test.ts +116 -0
- package/src/tests/migration-329-workflow-run-retention.test.ts +32 -0
- package/src/tests/model-groups-api.test.ts +415 -0
- package/src/tests/model-profile-fallbacks.test.ts +236 -2
- package/src/tests/model-profiles-api.test.ts +1 -0
- package/src/tests/opencode-adapter.test.ts +86 -0
- package/src/tests/operator-granted-credentials.test.ts +7 -2
- package/src/tests/operator-granted-role-wire.test.ts +2 -1
- package/src/tests/pi-mono-extension.test.ts +168 -0
- package/src/tests/preload-env.test.ts +61 -1
- package/src/tests/preload.ts +22 -0
- package/src/tests/prompt-template-resolver.test.ts +85 -0
- package/src/tests/rbac-engine.test.ts +1 -0
- package/src/tests/reload-config.test.ts +45 -0
- package/src/tests/request-composition.test.ts +447 -0
- package/src/tests/runner-max-concurrent.test.ts +86 -0
- package/src/tests/runtime-k8s-pools.test.ts +142 -0
- package/src/tests/runtime-pools-db.test.ts +122 -2
- package/src/tests/runtime-pools-http.test.ts +47 -2
- package/src/tests/runtime-provider-registration.test.ts +13 -14
- package/src/tests/runtime-providers-docker.test.ts +192 -1
- package/src/tests/runtime-providers-k8s.test.ts +430 -0
- package/src/tests/runtime-remote-controller.test.ts +64 -1
- package/src/tests/runtime-supervisor.test.ts +101 -0
- package/src/tests/script-connections.test.ts +21 -1
- package/src/tests/short-id.test.ts +23 -0
- package/src/tests/slack-blocks.test.ts +87 -0
- package/src/tests/slack-empty-icon-config.test.ts +113 -0
- package/src/tests/slack-reaction-config.test.ts +38 -2
- package/src/tests/slack-render-v2-query-plans.test.ts +100 -1
- package/src/tests/slack-render-v2-reconcile.test.ts +75 -4
- package/src/tests/slack-render-v2.test.ts +737 -11
- package/src/tests/spec-base-url.test.ts +13 -1
- package/src/tests/swarm-config-reserved-keys.test.ts +1 -0
- package/src/tests/system-one-decide-session-cost.test.ts +196 -0
- package/src/tests/task-session-prompts.test.ts +37 -0
- package/src/tests/task-ui-action-route.test.ts +59 -1
- package/src/tests/task-ui-script-actions.test.ts +517 -0
- package/src/tests/tool-hooks-http.test.ts +187 -0
- package/src/tests/ui-spec-script-actions-config.test.ts +196 -0
- package/src/tests/user-delete-perf.test.ts +348 -0
- package/src/tests/user-merge-jobs.test.ts +680 -0
- package/src/tests/vcs-provider.test.ts +25 -5
- package/src/tests/vendored-openapi.test.ts +13 -1
- package/src/tests/webhook-filter.test.ts +327 -0
- package/src/tests/workflow-agent-task-retry.test.ts +62 -0
- package/src/tests/workflow-async-v2.test.ts +19 -16
- package/src/tests/workflow-definition-telemetry.test.ts +15 -5
- package/src/tests/workflow-e2e.test.ts +1 -9
- package/src/tests/workflow-finalization-races.test.ts +553 -0
- package/src/tests/workflow-foreach-supersede-retry.test.ts +10 -0
- package/src/tests/workflow-foreach.test.ts +2 -0
- package/src/tests/workflow-hitl-routing.test.ts +26 -20
- package/src/tests/workflow-http-v2.test.ts +132 -2
- package/src/tests/workflow-idempotency.test.ts +41 -0
- package/src/tests/workflow-mcp-webhook-filter.test.ts +214 -0
- package/src/tests/workflow-parallel-park.test.ts +297 -0
- package/src/tests/workflow-replay.test.ts +10 -1
- package/src/tests/workflow-retry-v2.test.ts +57 -21
- package/src/tests/workflow-retry-validation.test.ts +13 -13
- package/src/tests/workflow-runs-retention.test.ts +533 -0
- package/src/tests/workflow-script-principal.test.ts +7 -2
- package/src/tests/workflow-tla-races.test.ts +7 -2
- package/src/tests/workflow-triggers-v2.test.ts +329 -0
- package/src/tests/workflow-wait-builtin-events.test.ts +3 -1
- package/src/tests/workflow-wait-event.test.ts +137 -3
- package/src/tests/workflow-wait-poller.test.ts +94 -0
- package/src/tests/workflow-wait-time.test.ts +7 -3
- package/src/tests/workflow-wait.test.ts +26 -0
- package/src/tests/workflow-wait.ts +44 -0
- package/src/tools/memory-search.ts +14 -3
- package/src/tools/store-progress.ts +26 -26
- package/src/tools/swarm-config/delete-config.ts +12 -1
- package/src/tools/swarm-config/set-config.ts +8 -0
- package/src/tools/system-one-decide.ts +113 -3
- package/src/tools/utils.ts +4 -1
- package/src/tools/workflows/create-workflow.ts +7 -1
- package/src/tools/workflows/update-workflow.ts +8 -2
- package/src/types.ts +284 -2
- package/src/ui-spec/actions.ts +30 -4
- package/src/ui-spec/schema.ts +38 -0
- package/src/ui-spec/script-actions.ts +340 -0
- package/src/ui-spec/script-allowlist.ts +48 -0
- package/src/utils/credentials.ts +7 -0
- package/src/utils/short-id.ts +20 -14
- package/src/utils/task-ui-spec.ts +16 -4
- package/src/vcs/index.ts +12 -2
- package/src/workflows/checkpoint.ts +18 -0
- package/src/workflows/engine.ts +38 -10
- package/src/workflows/executors/system-one-decision.ts +2 -2
- package/src/workflows/foreach-driver.ts +42 -4
- package/src/workflows/recovery.ts +6 -1
- package/src/workflows/resume.ts +14 -5
- package/src/workflows/retry-poller.ts +17 -4
- package/src/workflows/successor-routing.ts +108 -0
- package/src/workflows/task-step-routing.ts +35 -12
- package/src/workflows/triggers.ts +25 -8
- package/src/workflows/wait-poller.ts +6 -2
- package/src/workflows/webhook-filter.ts +203 -0
- package/templates/extensions/manifest.schema.json +13 -0
- package/templates/extensions/slack-reply-gate/hooks.ts +8 -4
- package/templates/skills/swarm-docs/content.md +4 -0
- package/templates/skills/ui-spec/content.md +7 -1
- package/templates/workflows/dreaming/content.md +1 -1
- package/dist/acp-adapter-g909b5hw.js +0 -16
- package/dist/cli-b91nz213.js +0 -93
- package/dist/fx-adapter-sk7n0fzc.js +0 -19
- package/dist/grok-adapter-sjbcm5ew.js +0 -19
- package/dist/handlers-yzy0c87x.js +0 -35
- package/dist/index-25pvya7q.js +0 -40
- package/dist/index-2t4859r5.js +0 -35
- package/dist/index-cxca2t8y.js +0 -36
- package/dist/lead-gk4h5eg7.js +0 -74
- package/dist/thread-buffer-a1re2r9r.js +0 -38
- package/dist/worker-3dyyb8ev.js +0 -74
- /package/dist/{node-dqm4xgxw.js → node-2wfcey7d.js} +0 -0
|
@@ -24,6 +24,7 @@ import {
|
|
|
24
24
|
ensureSlackDelegationActivation,
|
|
25
25
|
ensureSlackRenderV2Activation,
|
|
26
26
|
failTask,
|
|
27
|
+
getDb,
|
|
27
28
|
getDbClient,
|
|
28
29
|
getInboxMessageById,
|
|
29
30
|
getLogsByEventType,
|
|
@@ -38,12 +39,15 @@ import {
|
|
|
38
39
|
isPendingSlackMessage,
|
|
39
40
|
markTaskSlackReplySent,
|
|
40
41
|
noteSlackOutcomeDeliveryFailure,
|
|
42
|
+
recordSlackMessage,
|
|
43
|
+
reserveSlackMessage,
|
|
41
44
|
skipTask,
|
|
42
45
|
startTask,
|
|
43
46
|
supersedeTask,
|
|
44
47
|
updateAgentProfile,
|
|
45
48
|
upsertSwarmConfig,
|
|
46
49
|
} from "../be/db";
|
|
50
|
+
import { getSlackProcessingThreads } from "../be/db/slack-trees";
|
|
47
51
|
import { upsertTaskCitations } from "../be/task-citations";
|
|
48
52
|
import { upsertTaskUiSpec } from "../be/task-ui-spec";
|
|
49
53
|
import { createStandaloneScheduleTask } from "../scheduler/schedule-task";
|
|
@@ -54,16 +58,20 @@ import {
|
|
|
54
58
|
callSlackWithRetry,
|
|
55
59
|
childOutcomeContent,
|
|
56
60
|
ensureSlackThreadTree,
|
|
61
|
+
flushSlackRenderV2DirtyThreads,
|
|
57
62
|
formatV2Duration,
|
|
58
63
|
isSlackRenderV2Enabled,
|
|
59
64
|
isTerminalSlackError,
|
|
65
|
+
markSlackThreadDirty,
|
|
60
66
|
processSlackRenderV2,
|
|
67
|
+
refreshSlackOutcomeCard,
|
|
61
68
|
renderThreadTree,
|
|
62
69
|
slackErrorSummary,
|
|
63
70
|
streamOutcomeCard,
|
|
64
71
|
withStatusLead,
|
|
65
72
|
} from "../slack/render-v2";
|
|
66
73
|
import { getAgentDisplayName, getAgentEmoji } from "../slack/responses";
|
|
74
|
+
import { syncSlackTreeVisibility } from "../slack/tree-visibility";
|
|
67
75
|
import { slackContextKey } from "../tasks/context-key";
|
|
68
76
|
import { registerSlackReplyTool } from "../tools/slack-reply";
|
|
69
77
|
import type { AgentTask, TaskAttachment } from "../types";
|
|
@@ -622,6 +630,241 @@ describe("Slack renderer v2", () => {
|
|
|
622
630
|
});
|
|
623
631
|
}
|
|
624
632
|
|
|
633
|
+
describe("outcome window", () => {
|
|
634
|
+
async function finishedWakeInThread(label: string) {
|
|
635
|
+
const lead = await createAgent({ name: `${label} Lead`, isLead: true, status: "idle" });
|
|
636
|
+
const { channelId, threadTs } = uniqueSlackAddress(`C_${label}`);
|
|
637
|
+
const ask = await createTaskExtended("answer when ready", {
|
|
638
|
+
agentId: lead.id,
|
|
639
|
+
source: "slack",
|
|
640
|
+
slackChannelId: channelId,
|
|
641
|
+
slackThreadTs: threadTs,
|
|
642
|
+
contextKey: slackContextKey({ channelId, threadTs }),
|
|
643
|
+
});
|
|
644
|
+
await startTask(ask.id);
|
|
645
|
+
await completeTask(ask.id, "Waiting for the result.", { addTags: ["deferred"] });
|
|
646
|
+
await backdateLastUpdated([ask.id], 20);
|
|
647
|
+
await processSlackRenderV2();
|
|
648
|
+
const schedule = await createScheduledTask({
|
|
649
|
+
name: `deferred-${label}`,
|
|
650
|
+
scheduleType: "one_time",
|
|
651
|
+
taskTemplate: "Deliver the result",
|
|
652
|
+
taskType: "deferred",
|
|
653
|
+
tags: ["deferred"],
|
|
654
|
+
parentTaskId: ask.id,
|
|
655
|
+
targetAgentId: lead.id,
|
|
656
|
+
createdByAgentId: lead.id,
|
|
657
|
+
nextRunAt: new Date().toISOString(),
|
|
658
|
+
});
|
|
659
|
+
const wake = await createStandaloneScheduleTask(schedule);
|
|
660
|
+
await startTask(wake.id);
|
|
661
|
+
return { lead, ask, wake, channelId, threadTs };
|
|
662
|
+
}
|
|
663
|
+
|
|
664
|
+
async function backdateFinished(taskIds: string[], daysAgo: number): Promise<void> {
|
|
665
|
+
const ts = new Date(Date.now() - daysAgo * 86_400_000).toISOString();
|
|
666
|
+
for (const id of taskIds) {
|
|
667
|
+
await getDbClient().run(
|
|
668
|
+
"UPDATE agent_tasks SET finishedAt = ?, lastUpdatedAt = ? WHERE id = ?",
|
|
669
|
+
[ts, ts, id],
|
|
670
|
+
);
|
|
671
|
+
}
|
|
672
|
+
}
|
|
673
|
+
|
|
674
|
+
function sweepWindow() {
|
|
675
|
+
const now = Date.now();
|
|
676
|
+
return {
|
|
677
|
+
finishedAfter: new Date(now - 4 * 3_600_000).toISOString(),
|
|
678
|
+
closureActiveAfter: new Date(now - 8 * 3_600_000).toISOString(),
|
|
679
|
+
delegationEnabled: false,
|
|
680
|
+
};
|
|
681
|
+
}
|
|
682
|
+
|
|
683
|
+
test("a Lead wake that finished long ago gets no card from the sweep or a new thread event", async () => {
|
|
684
|
+
const { lead, wake, channelId, threadTs } = await finishedWakeInThread("STALE_WAKE");
|
|
685
|
+
await completeTask(wake.id, "The answer, two months late.");
|
|
686
|
+
await backdateFinished([wake.id], 60);
|
|
687
|
+
const swept = await getSlackProcessingThreads(false, false, sweepWindow());
|
|
688
|
+
expect(swept).not.toContainEqual({ channelId, threadTs });
|
|
689
|
+
calls.length = 0;
|
|
690
|
+
|
|
691
|
+
await processSlackRenderV2();
|
|
692
|
+
await processSlackRenderV2();
|
|
693
|
+
// A new ask in the same old thread renders the thread again.
|
|
694
|
+
const followUp = await createTaskExtended("one more question", {
|
|
695
|
+
agentId: lead.id,
|
|
696
|
+
source: "slack",
|
|
697
|
+
slackChannelId: channelId,
|
|
698
|
+
slackThreadTs: threadTs,
|
|
699
|
+
contextKey: slackContextKey({ channelId, threadTs }),
|
|
700
|
+
});
|
|
701
|
+
await startTask(followUp.id);
|
|
702
|
+
await completeTask(followUp.id, "Fresh answer.");
|
|
703
|
+
await backdateLastUpdated([followUp.id], 20);
|
|
704
|
+
await processSlackRenderV2();
|
|
705
|
+
|
|
706
|
+
expect(await getSlackOutcomeMessage(wake.id)).toBeNull();
|
|
707
|
+
expect((await getSlackOutcomeMessage(followUp.id))?.finalizedAt).toBeTruthy();
|
|
708
|
+
const streams = calls.filter((call) => call.method === "chat.startStream");
|
|
709
|
+
expect(streams.map((call) => call.payload.markdown_text)).toEqual(["✅ Fresh answer."]);
|
|
710
|
+
});
|
|
711
|
+
|
|
712
|
+
test("an ask that finished long ago gets no card when its thread renders again", async () => {
|
|
713
|
+
const lead = await createAgent({ name: "Old Ask Lead", isLead: true, status: "idle" });
|
|
714
|
+
const { channelId, threadTs } = uniqueSlackAddress("C_STALE_ASK");
|
|
715
|
+
const ask = await createTaskExtended("old question", {
|
|
716
|
+
agentId: lead.id,
|
|
717
|
+
source: "slack",
|
|
718
|
+
slackChannelId: channelId,
|
|
719
|
+
slackThreadTs: threadTs,
|
|
720
|
+
contextKey: slackContextKey({ channelId, threadTs }),
|
|
721
|
+
});
|
|
722
|
+
await startTask(ask.id);
|
|
723
|
+
await completeTask(ask.id, "Old answer.");
|
|
724
|
+
await backdateFinished([ask.id], 30);
|
|
725
|
+
calls.length = 0;
|
|
726
|
+
|
|
727
|
+
await processSlackRenderV2();
|
|
728
|
+
|
|
729
|
+
expect(await getSlackOutcomeMessage(ask.id)).toBeNull();
|
|
730
|
+
expect(calls.filter((call) => call.method === "chat.startStream")).toHaveLength(0);
|
|
731
|
+
});
|
|
732
|
+
|
|
733
|
+
for (const delegationEnabled of [false, true]) {
|
|
734
|
+
test(`upgrading an install with uncarded terminal history posts no old cards, delegation=${delegationEnabled}`, async () => {
|
|
735
|
+
process.env.SLACK_RENDER_V2_DELEGATION = String(delegationEnabled);
|
|
736
|
+
const lead = await createAgent({ name: "Upgrade Lead", isLead: true, status: "idle" });
|
|
737
|
+
const worker = await createAgent({ name: "Upgrade Worker", isLead: false, status: "idle" });
|
|
738
|
+
const longAgo = new Date(Date.now() - 30 * 86_400_000).toISOString();
|
|
739
|
+
// Pre-upgrade state: render v2 and delegation active for months, no
|
|
740
|
+
// reconcile cursor, and terminal Slack history with no outcome card,
|
|
741
|
+
// slackReplySent = 0 and no relay obligation.
|
|
742
|
+
await getDbClient().run(
|
|
743
|
+
`UPDATE slack_render_v2_state SET activated_at = ?, delegation_activated_at = ?,
|
|
744
|
+
reconcile_cursors = '{}' WHERE id = 1`,
|
|
745
|
+
["2000-01-01T00:00:00.000Z", "2000-01-01T00:00:00.000Z"],
|
|
746
|
+
);
|
|
747
|
+
const insert = getDb().query(`INSERT INTO agent_tasks
|
|
748
|
+
(id, task, status, source, agentId, taskType, parentTaskId, slackChannelId, slackThreadTs,
|
|
749
|
+
output, createdAt, lastUpdatedAt, finishedAt)
|
|
750
|
+
VALUES (?, 'old work', 'completed', ?, ?, ?, ?, ?, ?, 'old answer', ?, ?, ?)`);
|
|
751
|
+
getDb()
|
|
752
|
+
.transaction(() => {
|
|
753
|
+
for (let i = 0; i < 60; i++) {
|
|
754
|
+
const channelId = `C_UPGRADE_${i}`;
|
|
755
|
+
const ask = crypto.randomUUID();
|
|
756
|
+
insert.run(
|
|
757
|
+
ask,
|
|
758
|
+
"slack",
|
|
759
|
+
lead.id,
|
|
760
|
+
null,
|
|
761
|
+
null,
|
|
762
|
+
channelId,
|
|
763
|
+
"1.0",
|
|
764
|
+
longAgo,
|
|
765
|
+
longAgo,
|
|
766
|
+
longAgo,
|
|
767
|
+
);
|
|
768
|
+
insert.run(
|
|
769
|
+
crypto.randomUUID(),
|
|
770
|
+
"schedule",
|
|
771
|
+
lead.id,
|
|
772
|
+
"deferred",
|
|
773
|
+
ask,
|
|
774
|
+
channelId,
|
|
775
|
+
"1.0",
|
|
776
|
+
longAgo,
|
|
777
|
+
longAgo,
|
|
778
|
+
longAgo,
|
|
779
|
+
);
|
|
780
|
+
insert.run(
|
|
781
|
+
crypto.randomUUID(),
|
|
782
|
+
"mcp",
|
|
783
|
+
worker.id,
|
|
784
|
+
null,
|
|
785
|
+
ask,
|
|
786
|
+
channelId,
|
|
787
|
+
"1.0",
|
|
788
|
+
longAgo,
|
|
789
|
+
longAgo,
|
|
790
|
+
longAgo,
|
|
791
|
+
);
|
|
792
|
+
}
|
|
793
|
+
})
|
|
794
|
+
.immediate();
|
|
795
|
+
calls.length = 0;
|
|
796
|
+
|
|
797
|
+
// 180 terminal rows at 50 per page: four ticks lap the terminal cursor.
|
|
798
|
+
for (let tick = 0; tick < 4; tick++) await processSlackRenderV2();
|
|
799
|
+
|
|
800
|
+
const outcomes = await getDbClient().get<{ n: number }>(
|
|
801
|
+
"SELECT COUNT(*) AS n FROM slack_messages WHERE kind = 'outcome'",
|
|
802
|
+
);
|
|
803
|
+
expect(outcomes?.n).toBe(0);
|
|
804
|
+
expect(calls.filter((call) => call.method === "chat.startStream")).toHaveLength(0);
|
|
805
|
+
|
|
806
|
+
// A task that finishes after the upgrade still gets its card.
|
|
807
|
+
const { channelId, threadTs } = uniqueSlackAddress("C_AFTER_UPGRADE");
|
|
808
|
+
const fresh = await createTaskExtended("new question", {
|
|
809
|
+
agentId: lead.id,
|
|
810
|
+
source: "slack",
|
|
811
|
+
slackChannelId: channelId,
|
|
812
|
+
slackThreadTs: threadTs,
|
|
813
|
+
contextKey: slackContextKey({ channelId, threadTs }),
|
|
814
|
+
});
|
|
815
|
+
await startTask(fresh.id);
|
|
816
|
+
await completeTask(fresh.id, "New answer.");
|
|
817
|
+
await backdateLastUpdated([fresh.id], 20);
|
|
818
|
+
// No event bus here, so the sweep finds it within one lap of the cursor.
|
|
819
|
+
for (let tick = 0; tick < 5; tick++) await processSlackRenderV2();
|
|
820
|
+
|
|
821
|
+
expect((await getSlackOutcomeMessage(fresh.id))?.finalizedAt).toBeTruthy();
|
|
822
|
+
expect(calls.filter((call) => call.method === "chat.startStream")).toHaveLength(1);
|
|
823
|
+
});
|
|
824
|
+
}
|
|
825
|
+
|
|
826
|
+
for (const answeredBy of ["agent reply", "outcome card", "own slack-reply"] as const) {
|
|
827
|
+
test(`a fresh Lead wake already answered by ${answeredBy} gets no card`, async () => {
|
|
828
|
+
const { lead, ask, wake, channelId, threadTs } = await finishedWakeInThread(
|
|
829
|
+
answeredBy.replace(/\W/g, "_").toUpperCase(),
|
|
830
|
+
);
|
|
831
|
+
if (answeredBy === "own slack-reply") {
|
|
832
|
+
await markTaskSlackReplySent(wake.id);
|
|
833
|
+
} else {
|
|
834
|
+
const other =
|
|
835
|
+
answeredBy === "agent reply"
|
|
836
|
+
? ask
|
|
837
|
+
: await createTaskExtended("another lead answer", {
|
|
838
|
+
agentId: lead.id,
|
|
839
|
+
source: "mcp",
|
|
840
|
+
slackChannelId: channelId,
|
|
841
|
+
slackThreadTs: threadTs,
|
|
842
|
+
});
|
|
843
|
+
// A finished task, so the sweep's active page does not flag the thread for it.
|
|
844
|
+
if (other.id !== ask.id) await completeTask(other.id, "Already answered.");
|
|
845
|
+
await recordSlackMessage({
|
|
846
|
+
contextKey: slackContextKey({ channelId, threadTs }),
|
|
847
|
+
channelId,
|
|
848
|
+
threadTs,
|
|
849
|
+
ts: `${slackAddressSequence}.77`,
|
|
850
|
+
kind: answeredBy === "agent reply" ? "agent" : "outcome",
|
|
851
|
+
taskId: other.id,
|
|
852
|
+
finalized: true,
|
|
853
|
+
});
|
|
854
|
+
}
|
|
855
|
+
await completeTask(wake.id, "Same answer again.");
|
|
856
|
+
const swept = await getSlackProcessingThreads(false, false, sweepWindow());
|
|
857
|
+
expect(swept).not.toContainEqual({ channelId, threadTs });
|
|
858
|
+
calls.length = 0;
|
|
859
|
+
|
|
860
|
+
await processSlackRenderV2();
|
|
861
|
+
|
|
862
|
+
expect(await getSlackOutcomeMessage(wake.id)).toBeNull();
|
|
863
|
+
expect(calls.filter((call) => call.method === "chat.startStream")).toHaveLength(0);
|
|
864
|
+
});
|
|
865
|
+
}
|
|
866
|
+
});
|
|
867
|
+
|
|
625
868
|
for (const delegationEnabled of [false, true]) {
|
|
626
869
|
for (const status of ["completed", "failed"] as const) {
|
|
627
870
|
test(`worker deferred ${status} wake posts no outcome with delegation=${delegationEnabled}`, async () => {
|
|
@@ -1258,6 +1501,14 @@ describe("Slack renderer v2", () => {
|
|
|
1258
1501
|
);
|
|
1259
1502
|
expect(await childOutcomeContent(done, true)).toBe("↳ :bee-lgtm: Icon Lead completed");
|
|
1260
1503
|
|
|
1504
|
+
process.env.SLACK_STATUS_ICON_COMPLETED = "";
|
|
1505
|
+
const withoutIcon = await renderThreadTree([done], new Map(), now);
|
|
1506
|
+
expect(withoutIcon.startsWith("🧵 done")).toBe(true);
|
|
1507
|
+
expect(withoutIcon).toContain("↳ ");
|
|
1508
|
+
expect(withoutIcon).not.toContain("↳ ");
|
|
1509
|
+
expect(await childOutcomeContent(done, false)).toBe("↳ Icon Lead — result: Shipped.");
|
|
1510
|
+
expect(await childOutcomeContent(done, true)).toBe("↳ Icon Lead completed");
|
|
1511
|
+
|
|
1261
1512
|
// Only the completed glyph moves; failure keeps its own icon.
|
|
1262
1513
|
expect(
|
|
1263
1514
|
await childOutcomeContent({ ...done, status: "failed", failureReason: "boom" }, false),
|
|
@@ -1548,7 +1799,6 @@ describe("Slack renderer v2", () => {
|
|
|
1548
1799
|
.map((call) => call.method)
|
|
1549
1800
|
.filter((method) => method.startsWith("chat."));
|
|
1550
1801
|
expect(chatSequence).toEqual([
|
|
1551
|
-
"chat.getPermalink",
|
|
1552
1802
|
"chat.startStream",
|
|
1553
1803
|
"chat.stopStream",
|
|
1554
1804
|
"chat.getPermalink",
|
|
@@ -2527,14 +2777,14 @@ describe("Slack renderer v2", () => {
|
|
|
2527
2777
|
contextKey: slackContextKey({ channelId, threadTs }),
|
|
2528
2778
|
});
|
|
2529
2779
|
await startTask(ask.id);
|
|
2530
|
-
|
|
2780
|
+
await ensureSlackThreadTree([ask.id]);
|
|
2531
2781
|
await completeTask(ask.id, "PRIVATE OUTPUT THAT MUST NOT LEAK IF THE REPLY LANDS LATER");
|
|
2532
2782
|
// Simulate a stale snapshot: the caller fetched this task before slack-reply committed.
|
|
2533
2783
|
const staleSnapshot = { ...(await getTaskById(ask.id))!, slackReplySent: false };
|
|
2534
2784
|
await markTaskSlackReplySent(ask.id);
|
|
2535
2785
|
calls.length = 0;
|
|
2536
2786
|
|
|
2537
|
-
const outcome = await streamOutcomeCard(staleSnapshot
|
|
2787
|
+
const outcome = await streamOutcomeCard(staleSnapshot);
|
|
2538
2788
|
|
|
2539
2789
|
const started = calls.find((call) => call.method === "chat.startStream");
|
|
2540
2790
|
expect(started?.payload.markdown_text).toBe(`✅ ${lead.name} completed`);
|
|
@@ -3439,17 +3689,16 @@ describe("Outcome delivery give-up", () => {
|
|
|
3439
3689
|
await completeTask(taskB0.id, "The answer.");
|
|
3440
3690
|
const taskB = (await getTaskById(taskB0.id))!;
|
|
3441
3691
|
|
|
3442
|
-
const tree = (await getSlackTreeMessageByThread(channelId, threadTs))!;
|
|
3443
3692
|
// Simulate a failure before streamOutcomeCard's own reservation (e.g. a
|
|
3444
3693
|
// DB read throwing while building content) — noteOutcomeDeliveryFailure
|
|
3445
3694
|
// eagerly reserves a row with no Slack call ever attempted.
|
|
3446
|
-
await _noteOutcomeDeliveryFailureForTests(taskB,
|
|
3695
|
+
await _noteOutcomeDeliveryFailureForTests(taskB, new Error("content build blew up"));
|
|
3447
3696
|
const reservedB = await getSlackOutcomeMessage(taskB.id);
|
|
3448
3697
|
expect(reservedB?.ts.startsWith("pending:")).toBe(true);
|
|
3449
3698
|
expect(reservedB?.deliveryAttempts).toBe(1);
|
|
3450
3699
|
|
|
3451
3700
|
calls.length = 0;
|
|
3452
|
-
const outcome = await streamOutcomeCard(taskB
|
|
3701
|
+
const outcome = await streamOutcomeCard(taskB);
|
|
3453
3702
|
|
|
3454
3703
|
// Without the fix, this reconciles by presentation text against taskA's
|
|
3455
3704
|
// identical, unrelated message instead of posting a fresh one.
|
|
@@ -3489,8 +3738,7 @@ describe("Outcome delivery give-up", () => {
|
|
|
3489
3738
|
await completeTask(taskB0.id, "The answer.");
|
|
3490
3739
|
const taskB = (await getTaskById(taskB0.id))!;
|
|
3491
3740
|
|
|
3492
|
-
|
|
3493
|
-
await _noteOutcomeDeliveryFailureForTests(taskB, tree, new Error("content build blew up"));
|
|
3741
|
+
await _noteOutcomeDeliveryFailureForTests(taskB, new Error("content build blew up"));
|
|
3494
3742
|
|
|
3495
3743
|
calls.length = 0;
|
|
3496
3744
|
// A process restart clears the in-memory `outcomeReservedWithoutAttempt`
|
|
@@ -3499,7 +3747,7 @@ describe("Outcome delivery give-up", () => {
|
|
|
3499
3747
|
// it — without it, this throws `UNIQUE constraint failed:
|
|
3500
3748
|
// slack_messages.channel_id, slack_messages.ts` at bindSlackMessageTimestamp.
|
|
3501
3749
|
_resetSlackRenderV2ForTests();
|
|
3502
|
-
const outcome = await streamOutcomeCard(taskB
|
|
3750
|
+
const outcome = await streamOutcomeCard(taskB);
|
|
3503
3751
|
|
|
3504
3752
|
expect(calls.some((c) => c.method === "conversations.replies")).toBe(true);
|
|
3505
3753
|
expect(calls.some((c) => c.method === "chat.startStream")).toBe(true);
|
|
@@ -3669,7 +3917,7 @@ describe("Slack renderer v2 delegation (SLACK_RENDER_V2_DELEGATION)", () => {
|
|
|
3669
3917
|
contextKey: slackContextKey({ channelId, threadTs }),
|
|
3670
3918
|
});
|
|
3671
3919
|
await startTask(ask.id);
|
|
3672
|
-
|
|
3920
|
+
await ensureSlackThreadTree([ask.id]);
|
|
3673
3921
|
const child = await createTaskExtended("child whose reply lands before its card", {
|
|
3674
3922
|
agentId: worker.id,
|
|
3675
3923
|
source: "mcp",
|
|
@@ -3684,7 +3932,7 @@ describe("Slack renderer v2 delegation (SLACK_RENDER_V2_DELEGATION)", () => {
|
|
|
3684
3932
|
await markTaskSlackReplySent(child.id);
|
|
3685
3933
|
calls.length = 0;
|
|
3686
3934
|
|
|
3687
|
-
const outcome = await streamOutcomeCard(staleChildSnapshot,
|
|
3935
|
+
const outcome = await streamOutcomeCard(staleChildSnapshot, {
|
|
3688
3936
|
buildContent: childOutcomeContent,
|
|
3689
3937
|
});
|
|
3690
3938
|
|
|
@@ -4770,6 +5018,59 @@ describe("Slack outcome card from a task uiSpec", () => {
|
|
|
4770
5018
|
});
|
|
4771
5019
|
});
|
|
4772
5020
|
|
|
5021
|
+
test("refreshSlackOutcomeCard edits the settled outcome message with the new card", async () => {
|
|
5022
|
+
const { ask } = await slackAskTask("Card refresh");
|
|
5023
|
+
await storeUiSpec(ask.id, await readUiSpecFixture("deploys"));
|
|
5024
|
+
await completeTask(ask.id, "Deploys are up.");
|
|
5025
|
+
await backdateLastUpdated([ask.id], 20);
|
|
5026
|
+
await processSlackRenderV2();
|
|
5027
|
+
const outcome = await getSlackOutcomeMessage(ask.id);
|
|
5028
|
+
expect(outcome?.finalizedAt).toBeTruthy();
|
|
5029
|
+
|
|
5030
|
+
await storeUiSpec(ask.id, await readUiSpecFixture("video"));
|
|
5031
|
+
calls.length = 0;
|
|
5032
|
+
expect(await refreshSlackOutcomeCard(ask.id)).toBe(true);
|
|
5033
|
+
|
|
5034
|
+
const updates = calls.filter((call) => call.method === "chat.update");
|
|
5035
|
+
expect(updates).toHaveLength(1);
|
|
5036
|
+
expect(updates[0]?.payload.ts).toBe(outcome?.ts);
|
|
5037
|
+
const blocks = updates[0]?.payload.blocks as Block[];
|
|
5038
|
+
expect(blocks[0]).toEqual({ type: "markdown", text: "✅ Deploys are up." });
|
|
5039
|
+
expect(blocks.some((block) => block.type === "data_table")).toBe(true);
|
|
5040
|
+
expect(isFooter(blocks.at(-1), ask.id)).toBe(true);
|
|
5041
|
+
});
|
|
5042
|
+
|
|
5043
|
+
test("refreshSlackOutcomeCard falls back to the card text when Slack refuses the blocks", async () => {
|
|
5044
|
+
const { ask } = await slackAskTask("Card refresh refused");
|
|
5045
|
+
await completeTask(ask.id, "Q3 is up.");
|
|
5046
|
+
await backdateLastUpdated([ask.id], 20);
|
|
5047
|
+
await processSlackRenderV2();
|
|
5048
|
+
const fallbackText = await storeUiSpec(ask.id, await readUiSpecFixture("video"));
|
|
5049
|
+
rejectedBlockType = "data_table";
|
|
5050
|
+
calls.length = 0;
|
|
5051
|
+
const warn = spyOn(console, "warn").mockImplementation(() => {});
|
|
5052
|
+
try {
|
|
5053
|
+
expect(await refreshSlackOutcomeCard(ask.id)).toBe(true);
|
|
5054
|
+
} finally {
|
|
5055
|
+
warn.mockRestore();
|
|
5056
|
+
}
|
|
5057
|
+
|
|
5058
|
+
const updates = calls.filter((call) => call.method === "chat.update");
|
|
5059
|
+
expect(updates).toHaveLength(2);
|
|
5060
|
+
const text = `✅ Q3 is up.\n\n${fallbackText}`;
|
|
5061
|
+
expect(updates[1]?.payload.text).toBe(text);
|
|
5062
|
+
const blocks = updates[1]?.payload.blocks as Block[];
|
|
5063
|
+
expect(blocks[0]).toEqual({ type: "markdown", text });
|
|
5064
|
+
expect(blocks.some((block) => block.type === "data_table")).toBe(false);
|
|
5065
|
+
});
|
|
5066
|
+
|
|
5067
|
+
test("refreshSlackOutcomeCard skips a task with no settled outcome message", async () => {
|
|
5068
|
+
const { ask } = await slackAskTask("Card refresh none");
|
|
5069
|
+
calls.length = 0;
|
|
5070
|
+
expect(await refreshSlackOutcomeCard(ask.id)).toBe(false);
|
|
5071
|
+
expect(calls).toHaveLength(0);
|
|
5072
|
+
});
|
|
5073
|
+
|
|
4773
5074
|
test("an ask card never shows a worker child's spec", async () => {
|
|
4774
5075
|
const { ask } = await slackAskTask("Card child");
|
|
4775
5076
|
const worker = await createAgent({ name: "Card Child Worker", isLead: false, status: "idle" });
|
|
@@ -4869,3 +5170,428 @@ describe("Slack outcome card from a task uiSpec", () => {
|
|
|
4869
5170
|
});
|
|
4870
5171
|
});
|
|
4871
5172
|
});
|
|
5173
|
+
|
|
5174
|
+
describe("optional Slack V2 task tree", () => {
|
|
5175
|
+
const original = process.env.SLACK_RENDER_V2_TASK_TREE_ENABLED;
|
|
5176
|
+
afterEach(() => {
|
|
5177
|
+
if (original === undefined) delete process.env.SLACK_RENDER_V2_TASK_TREE_ENABLED;
|
|
5178
|
+
else process.env.SLACK_RENDER_V2_TASK_TREE_ENABLED = original;
|
|
5179
|
+
process.env.SLACK_RENDER_V2 = "true";
|
|
5180
|
+
});
|
|
5181
|
+
|
|
5182
|
+
async function runningAsk(label: string) {
|
|
5183
|
+
const lead = await createAgent({ name: label, isLead: true, status: "idle" });
|
|
5184
|
+
const { channelId, threadTs } = uniqueSlackAddress("C_OPTIONAL_TREE");
|
|
5185
|
+
const task = await createTaskExtended(label, {
|
|
5186
|
+
agentId: lead.id,
|
|
5187
|
+
source: "slack",
|
|
5188
|
+
slackChannelId: channelId,
|
|
5189
|
+
slackThreadTs: threadTs,
|
|
5190
|
+
slackTriggerMessageTs: threadTs,
|
|
5191
|
+
});
|
|
5192
|
+
await startTask(task.id);
|
|
5193
|
+
return { task, channelId, threadTs };
|
|
5194
|
+
}
|
|
5195
|
+
|
|
5196
|
+
test("hidden from acceptance through completion: status, card and reaction survive", async () => {
|
|
5197
|
+
process.env.SLACK_RENDER_V2_TASK_TREE_ENABLED = "false";
|
|
5198
|
+
const { task, channelId, threadTs } = await runningAsk("hidden result");
|
|
5199
|
+
expect(await ensureSlackThreadTree([task.id])).toBeNull();
|
|
5200
|
+
expect(calls.some((call) => call.method === "agents.sessions.setStatus")).toBe(true);
|
|
5201
|
+
await completeTask(task.id, "The tree is optional, the answer is not.");
|
|
5202
|
+
await processSlackRenderV2();
|
|
5203
|
+
expect(await getSlackTreeMessageByThread(channelId, threadTs)).toBeNull();
|
|
5204
|
+
expect((await getSlackOutcomeMessage(task.id))?.finalizedAt).toBeDefined();
|
|
5205
|
+
expect(calls.some((call) => call.method === "reactions.add")).toBe(true);
|
|
5206
|
+
expect(calls.filter((call) => call.method === "chat.postMessage")).toHaveLength(0);
|
|
5207
|
+
expect(calls.filter((call) => call.method === "chat.update")).toHaveLength(0);
|
|
5208
|
+
_resetSlackRenderV2ForTests();
|
|
5209
|
+
await processSlackRenderV2();
|
|
5210
|
+
expect(calls.filter((call) => call.method === "chat.startStream")).toHaveLength(1);
|
|
5211
|
+
});
|
|
5212
|
+
|
|
5213
|
+
for (const enabled of ["false", "true"]) {
|
|
5214
|
+
test(`an old ask cannot suppress a new outcome with tree visibility ${enabled}`, async () => {
|
|
5215
|
+
process.env.SLACK_RENDER_V2_TASK_TREE_ENABLED = enabled;
|
|
5216
|
+
await syncSlackTreeVisibility();
|
|
5217
|
+
const { task, channelId, threadTs } = await runningAsk("new ask in legacy thread");
|
|
5218
|
+
const old = await createTaskExtended("legacy ask", {
|
|
5219
|
+
agentId: task.agentId!,
|
|
5220
|
+
source: "slack",
|
|
5221
|
+
slackChannelId: channelId,
|
|
5222
|
+
slackThreadTs: threadTs,
|
|
5223
|
+
});
|
|
5224
|
+
await startTask(old.id);
|
|
5225
|
+
await completeTask(old.id, "old answer");
|
|
5226
|
+
getDb().run("UPDATE agent_tasks SET createdAt = '2000-01-01T00:00:00.000Z' WHERE id = ?", [
|
|
5227
|
+
old.id,
|
|
5228
|
+
]);
|
|
5229
|
+
await completeTask(task.id, "new answer");
|
|
5230
|
+
calls.length = 0;
|
|
5231
|
+
await processSlackRenderV2();
|
|
5232
|
+
expect((await getSlackOutcomeMessage(task.id))?.finalizedAt).toBeDefined();
|
|
5233
|
+
expect(await getSlackOutcomeMessage(old.id)).toBeNull();
|
|
5234
|
+
expect(calls.some((call) => call.method === "reactions.add")).toBe(true);
|
|
5235
|
+
expect(await getSlackTreeMessageByThread(channelId, threadTs)).toBeNull();
|
|
5236
|
+
});
|
|
5237
|
+
}
|
|
5238
|
+
|
|
5239
|
+
test("unchanged visibility observation makes no writes", async () => {
|
|
5240
|
+
process.env.SLACK_RENDER_V2_TASK_TREE_ENABLED = "true";
|
|
5241
|
+
await syncSlackTreeVisibility();
|
|
5242
|
+
const changes = () =>
|
|
5243
|
+
(getDb().query("SELECT total_changes() AS count").get() as { count: number }).count;
|
|
5244
|
+
const before = changes();
|
|
5245
|
+
for (let i = 0; i < 10; i++) await syncSlackTreeVisibility();
|
|
5246
|
+
expect(changes()).toBe(before);
|
|
5247
|
+
});
|
|
5248
|
+
|
|
5249
|
+
test("off freezes history and on resumes only the active thread across restart", async () => {
|
|
5250
|
+
process.env.SLACK_RENDER_V2_TASK_TREE_ENABLED = "true";
|
|
5251
|
+
const done = await runningAsk("completed while hidden");
|
|
5252
|
+
const active = await runningAsk("still active");
|
|
5253
|
+
const tree = (await ensureSlackThreadTree([done.task.id]))!;
|
|
5254
|
+
await ensureSlackThreadTree([active.task.id]);
|
|
5255
|
+
const historicalText = remoteMessages.get(remoteKey(done.channelId, tree.ts))?.text;
|
|
5256
|
+
process.env.SLACK_RENDER_V2_TASK_TREE_ENABLED = "false";
|
|
5257
|
+
await syncSlackTreeVisibility();
|
|
5258
|
+
await completeTask(done.task.id, "hidden completion");
|
|
5259
|
+
await processSlackRenderV2();
|
|
5260
|
+
await Bun.sleep(2);
|
|
5261
|
+
process.env.SLACK_RENDER_V2_TASK_TREE_ENABLED = "true";
|
|
5262
|
+
const cutoff = await syncSlackTreeVisibility();
|
|
5263
|
+
expect(cutoff).not.toBeNull();
|
|
5264
|
+
_resetSlackRenderV2ForTests();
|
|
5265
|
+
// initDb restores the test template; reopen a snapshot of this database instead.
|
|
5266
|
+
const globals = globalThis as typeof globalThis & { __testMigrationTemplate?: Uint8Array };
|
|
5267
|
+
const originalTemplate = globals.__testMigrationTemplate;
|
|
5268
|
+
globals.__testMigrationTemplate = getDb().serialize();
|
|
5269
|
+
closeDb();
|
|
5270
|
+
try {
|
|
5271
|
+
initDb(TEST_DB_PATH);
|
|
5272
|
+
} finally {
|
|
5273
|
+
globals.__testMigrationTemplate = originalTemplate;
|
|
5274
|
+
}
|
|
5275
|
+
expect(await syncSlackTreeVisibility()).toBe(cutoff);
|
|
5276
|
+
calls.length = 0;
|
|
5277
|
+
await processSlackRenderV2();
|
|
5278
|
+
expect(remoteMessages.get(remoteKey(done.channelId, tree.ts))?.text).toBe(historicalText);
|
|
5279
|
+
expect(
|
|
5280
|
+
calls.filter(
|
|
5281
|
+
(call) => call.payload.channel === done.channelId && call.method.startsWith("chat."),
|
|
5282
|
+
),
|
|
5283
|
+
).toHaveLength(0);
|
|
5284
|
+
expect((await getSlackOutcomeMessage(done.task.id))?.finalizedAt).toBeDefined();
|
|
5285
|
+
expect(await getSlackTreeMessageByThread(active.channelId, active.threadTs)).not.toBeNull();
|
|
5286
|
+
});
|
|
5287
|
+
|
|
5288
|
+
test("no tree is backfilled for a hidden completion even when its outcome still needs recovery", async () => {
|
|
5289
|
+
process.env.SLACK_RENDER_V2_TASK_TREE_ENABLED = "false";
|
|
5290
|
+
const { task, channelId, threadTs } = await runningAsk("recover outcome without backfill");
|
|
5291
|
+
await ensureSlackThreadTree([task.id]);
|
|
5292
|
+
await completeTask(task.id, "delayed answer");
|
|
5293
|
+
await Bun.sleep(2);
|
|
5294
|
+
process.env.SLACK_RENDER_V2_TASK_TREE_ENABLED = "true";
|
|
5295
|
+
await syncSlackTreeVisibility();
|
|
5296
|
+
_resetSlackRenderV2ForTests();
|
|
5297
|
+
await processSlackRenderV2();
|
|
5298
|
+
expect((await getSlackOutcomeMessage(task.id))?.finalizedAt).toBeDefined();
|
|
5299
|
+
expect(await getSlackTreeMessageByThread(channelId, threadTs)).toBeNull();
|
|
5300
|
+
});
|
|
5301
|
+
|
|
5302
|
+
test("a broken tree permalink cannot prevent outcome delivery", async () => {
|
|
5303
|
+
const { task, channelId, threadTs } = await runningAsk("tree lookup fails");
|
|
5304
|
+
permalinkFailuresRemaining = 1;
|
|
5305
|
+
await expect(ensureSlackThreadTree([task.id])).rejects.toThrow();
|
|
5306
|
+
expect((await getSlackTreeMessageByThread(channelId, threadTs))?.permalink).toBeUndefined();
|
|
5307
|
+
await completeTask(task.id, "answer despite tree failure");
|
|
5308
|
+
await processSlackRenderV2();
|
|
5309
|
+
expect((await getSlackOutcomeMessage(task.id))?.finalizedAt).toBeDefined();
|
|
5310
|
+
});
|
|
5311
|
+
|
|
5312
|
+
test("disabling cancels queued debounce updates", async () => {
|
|
5313
|
+
const { task } = await runningAsk("cancel queued update");
|
|
5314
|
+
await ensureSlackThreadTree([task.id]);
|
|
5315
|
+
await ensureSlackThreadTree([task.id]);
|
|
5316
|
+
process.env.SLACK_RENDER_V2_TASK_TREE_ENABLED = "false";
|
|
5317
|
+
await syncSlackTreeVisibility();
|
|
5318
|
+
calls.length = 0;
|
|
5319
|
+
await Bun.sleep(550);
|
|
5320
|
+
expect(calls).toHaveLength(0);
|
|
5321
|
+
});
|
|
5322
|
+
|
|
5323
|
+
test("a dispatched tree post is bound after disabling and reused on re-enable", async () => {
|
|
5324
|
+
const { task, channelId, threadTs } = await runningAsk("in-flight tree");
|
|
5325
|
+
const started = deferred();
|
|
5326
|
+
const release = deferred();
|
|
5327
|
+
apiCallGate = async (method) => {
|
|
5328
|
+
if (method === "chat.postMessage") {
|
|
5329
|
+
started.resolve();
|
|
5330
|
+
await release.promise;
|
|
5331
|
+
}
|
|
5332
|
+
};
|
|
5333
|
+
const posting = ensureSlackThreadTree([task.id]);
|
|
5334
|
+
await started.promise;
|
|
5335
|
+
process.env.SLACK_RENDER_V2_TASK_TREE_ENABLED = "false";
|
|
5336
|
+
await syncSlackTreeVisibility();
|
|
5337
|
+
release.resolve();
|
|
5338
|
+
expect(await posting).toBeNull();
|
|
5339
|
+
const bound = await getSlackTreeMessageByThread(channelId, threadTs);
|
|
5340
|
+
expect(bound).not.toBeNull();
|
|
5341
|
+
expect(isPendingSlackMessage(bound!)).toBe(false);
|
|
5342
|
+
apiCallGate = undefined;
|
|
5343
|
+
process.env.SLACK_RENDER_V2_TASK_TREE_ENABLED = "true";
|
|
5344
|
+
await syncSlackTreeVisibility();
|
|
5345
|
+
await processSlackRenderV2();
|
|
5346
|
+
expect((await getSlackTreeMessageByThread(channelId, threadTs))?.ts).toBe(bound?.ts);
|
|
5347
|
+
expect(calls.filter((call) => call.method === "chat.postMessage")).toHaveLength(1);
|
|
5348
|
+
});
|
|
5349
|
+
|
|
5350
|
+
test("disabling during rate-limit backoff prevents the tree retry", async () => {
|
|
5351
|
+
const { task } = await runningAsk("cancel retry");
|
|
5352
|
+
apiCallGate = async (method) => {
|
|
5353
|
+
if (method !== "chat.postMessage") return;
|
|
5354
|
+
process.env.SLACK_RENDER_V2_TASK_TREE_ENABLED = "false";
|
|
5355
|
+
await syncSlackTreeVisibility();
|
|
5356
|
+
throw { code: "slack_webapi_rate_limited_error", retryAfter: 0.01 };
|
|
5357
|
+
};
|
|
5358
|
+
expect(await ensureSlackThreadTree([task.id])).toBeNull();
|
|
5359
|
+
expect(calls.filter((call) => call.method === "chat.postMessage")).toHaveLength(1);
|
|
5360
|
+
});
|
|
5361
|
+
|
|
5362
|
+
test("hidden delegation delivers child cards before conclusions", async () => {
|
|
5363
|
+
process.env.SLACK_RENDER_V2_TASK_TREE_ENABLED = "false";
|
|
5364
|
+
process.env.SLACK_RENDER_V2_DELEGATION = "true";
|
|
5365
|
+
await ensureSlackDelegationActivation();
|
|
5366
|
+
const { task, channelId, threadTs } = await runningAsk("delegated without tree");
|
|
5367
|
+
const worker = await createAgent({ name: "hidden worker", isLead: false, status: "idle" });
|
|
5368
|
+
const child = await createTaskExtended("hidden child", {
|
|
5369
|
+
agentId: worker.id,
|
|
5370
|
+
parentTaskId: task.id,
|
|
5371
|
+
source: "mcp",
|
|
5372
|
+
slackChannelId: channelId,
|
|
5373
|
+
slackThreadTs: threadTs,
|
|
5374
|
+
});
|
|
5375
|
+
await startTask(child.id);
|
|
5376
|
+
await completeTask(child.id, "child answer");
|
|
5377
|
+
await completeTask(task.id, "parent answer");
|
|
5378
|
+
await getDbClient().run("UPDATE agent_tasks SET lastUpdatedAt = ? WHERE id IN (?, ?)", [
|
|
5379
|
+
new Date(Date.now() - 20_000).toISOString(),
|
|
5380
|
+
task.id,
|
|
5381
|
+
child.id,
|
|
5382
|
+
]);
|
|
5383
|
+
await processSlackRenderV2();
|
|
5384
|
+
expect((await getSlackOutcomeMessage(child.id))?.finalizedAt).toBeDefined();
|
|
5385
|
+
expect((await getSlackOutcomeMessage(task.id))?.finalizedAt).toBeDefined();
|
|
5386
|
+
expect(await getSlackTreeMessageByThread(channelId, threadTs)).toBeNull();
|
|
5387
|
+
const streams = calls.filter((call) => call.method === "chat.startStream");
|
|
5388
|
+
expect(streams).toHaveLength(2);
|
|
5389
|
+
expect(String(streams[0]?.payload.markdown_text)).toContain("child answer");
|
|
5390
|
+
});
|
|
5391
|
+
});
|
|
5392
|
+
|
|
5393
|
+
// With the default 240-minute conclusion timeout the card window is 4 hours,
|
|
5394
|
+
// and a closure stays eligible while it changed in the last 8 hours.
|
|
5395
|
+
describe("Slack outcome window across closures, deliveries and wakes", () => {
|
|
5396
|
+
afterEach(() => {
|
|
5397
|
+
delete process.env.SLACK_RENDER_V2_DELEGATION;
|
|
5398
|
+
});
|
|
5399
|
+
|
|
5400
|
+
function hoursAgo(hours: number): string {
|
|
5401
|
+
return new Date(Date.now() - hours * 3_600_000).toISOString();
|
|
5402
|
+
}
|
|
5403
|
+
|
|
5404
|
+
async function endedAt(taskIds: string[], hours: number): Promise<void> {
|
|
5405
|
+
const ts = hoursAgo(hours);
|
|
5406
|
+
for (const id of taskIds) {
|
|
5407
|
+
await getDbClient().run(
|
|
5408
|
+
"UPDATE agent_tasks SET finishedAt = ?, lastUpdatedAt = ? WHERE id = ?",
|
|
5409
|
+
[ts, ts, id],
|
|
5410
|
+
);
|
|
5411
|
+
}
|
|
5412
|
+
}
|
|
5413
|
+
|
|
5414
|
+
async function slackAsk(label: string, extra: { slackTriggerMessageTs?: string } = {}) {
|
|
5415
|
+
const lead = await createAgent({ name: `${label} Lead`, isLead: true, status: "idle" });
|
|
5416
|
+
const { channelId, threadTs } = uniqueSlackAddress(`C_${label}`);
|
|
5417
|
+
const ask = await createTaskExtended(`${label} ask`, {
|
|
5418
|
+
agentId: lead.id,
|
|
5419
|
+
source: "slack",
|
|
5420
|
+
slackChannelId: channelId,
|
|
5421
|
+
slackThreadTs: threadTs,
|
|
5422
|
+
contextKey: slackContextKey({ channelId, threadTs }),
|
|
5423
|
+
...extra,
|
|
5424
|
+
});
|
|
5425
|
+
await startTask(ask.id);
|
|
5426
|
+
return { lead, ask, channelId, threadTs };
|
|
5427
|
+
}
|
|
5428
|
+
|
|
5429
|
+
async function delegatedAsk(label: string, childCount = 1) {
|
|
5430
|
+
process.env.SLACK_RENDER_V2_DELEGATION = "true";
|
|
5431
|
+
await ensureSlackDelegationActivation();
|
|
5432
|
+
const base = await slackAsk(label);
|
|
5433
|
+
const worker = await createAgent({ name: `${label} Worker`, isLead: false, status: "idle" });
|
|
5434
|
+
const children: AgentTask[] = [];
|
|
5435
|
+
for (let i = 0; i < childCount; i++) {
|
|
5436
|
+
const child = await createTaskExtended(`${label} child ${i}`, {
|
|
5437
|
+
agentId: worker.id,
|
|
5438
|
+
source: "mcp",
|
|
5439
|
+
parentTaskId: base.ask.id,
|
|
5440
|
+
followUpConfig: { disabled: true },
|
|
5441
|
+
});
|
|
5442
|
+
await startTask(child.id);
|
|
5443
|
+
children.push(child);
|
|
5444
|
+
}
|
|
5445
|
+
return { ...base, children };
|
|
5446
|
+
}
|
|
5447
|
+
|
|
5448
|
+
function streamTexts(): string[] {
|
|
5449
|
+
return calls
|
|
5450
|
+
.filter((call) => call.method === "chat.startStream")
|
|
5451
|
+
.map((call) => String(call.payload.markdown_text));
|
|
5452
|
+
}
|
|
5453
|
+
|
|
5454
|
+
test("a child that ended before the window does not hold back a fresh complete conclusion", async () => {
|
|
5455
|
+
const { ask, children } = await delegatedAsk("EXPIRED_CHILD_COMPLETE");
|
|
5456
|
+
const [child] = children;
|
|
5457
|
+
await completeTask(child!.id, "Earlier child result.");
|
|
5458
|
+
await completeTask(ask.id, "Fresh conclusion.");
|
|
5459
|
+
await endedAt([child!.id], 5);
|
|
5460
|
+
await backdateLastUpdated([ask.id], 20);
|
|
5461
|
+
calls.length = 0;
|
|
5462
|
+
|
|
5463
|
+
for (let tick = 0; tick < 3; tick++) await processSlackRenderV2();
|
|
5464
|
+
|
|
5465
|
+
const conclusion = await getSlackOutcomeMessage(ask.id);
|
|
5466
|
+
expect(conclusion?.finalizedAt).toBeTruthy();
|
|
5467
|
+
expect(conclusion?.conclusionKind).toBe("complete");
|
|
5468
|
+
expect(await getSlackOutcomeMessage(child!.id)).toBeNull();
|
|
5469
|
+
expect(streamTexts()).toHaveLength(1);
|
|
5470
|
+
});
|
|
5471
|
+
|
|
5472
|
+
test("a child that ended before the window does not hold back a timeout conclusion", async () => {
|
|
5473
|
+
const { ask, children } = await delegatedAsk("EXPIRED_CHILD_TIMEOUT", 2);
|
|
5474
|
+
const [expired, stuck] = children;
|
|
5475
|
+
await completeTask(expired!.id, "Earlier child result.");
|
|
5476
|
+
await completeTask(ask.id, "Waiting on the children.");
|
|
5477
|
+
// Idle past the 240-minute timeout, still inside the 8-hour closure window.
|
|
5478
|
+
await endedAt([ask.id, expired!.id], 5);
|
|
5479
|
+
await backdateLastUpdated([stuck!.id], 5 * 3600);
|
|
5480
|
+
calls.length = 0;
|
|
5481
|
+
|
|
5482
|
+
await processSlackRenderV2();
|
|
5483
|
+
|
|
5484
|
+
const conclusion = await getSlackOutcomeMessage(ask.id);
|
|
5485
|
+
expect(conclusion?.finalizedAt).toBeTruthy();
|
|
5486
|
+
expect(conclusion?.conclusionKind).toBe("timeout");
|
|
5487
|
+
expect(await getSlackOutcomeMessage(expired!.id)).toBeNull();
|
|
5488
|
+
expect(streamTexts()).toHaveLength(1);
|
|
5489
|
+
});
|
|
5490
|
+
|
|
5491
|
+
test("an old child's in-flight card still holds back the conclusion until it lands", async () => {
|
|
5492
|
+
const { ask, children } = await delegatedAsk("INFLIGHT_CHILD");
|
|
5493
|
+
const [child] = children;
|
|
5494
|
+
await completeTask(child!.id, "Child answer in flight.");
|
|
5495
|
+
await completeTask(ask.id, "Fresh conclusion.");
|
|
5496
|
+
await backdateLastUpdated([ask.id, child!.id], 20);
|
|
5497
|
+
calls.length = 0;
|
|
5498
|
+
// The child's stream starts but never finalizes, then the child ages out.
|
|
5499
|
+
stopCallsUntilFailure = 0;
|
|
5500
|
+
await processSlackRenderV2();
|
|
5501
|
+
expect((await getSlackOutcomeMessage(child!.id))?.finalizedAt).toBeUndefined();
|
|
5502
|
+
await endedAt([child!.id], 5);
|
|
5503
|
+
|
|
5504
|
+
// The child's retry is in backoff, so this tick only sees its open card.
|
|
5505
|
+
await processSlackRenderV2();
|
|
5506
|
+
expect(await getSlackOutcomeMessage(ask.id)).toBeNull();
|
|
5507
|
+
|
|
5508
|
+
_resetSlackRenderV2ForTests();
|
|
5509
|
+
for (let tick = 0; tick < 3; tick++) await processSlackRenderV2();
|
|
5510
|
+
|
|
5511
|
+
expect((await getSlackOutcomeMessage(child!.id))?.finalizedAt).toBeTruthy();
|
|
5512
|
+
expect((await getSlackOutcomeMessage(ask.id))?.conclusionKind).toBe("complete");
|
|
5513
|
+
const texts = streamTexts();
|
|
5514
|
+
expect(texts).toHaveLength(2);
|
|
5515
|
+
expect(texts[0]).toContain("Child answer in flight.");
|
|
5516
|
+
});
|
|
5517
|
+
|
|
5518
|
+
test("a closure timeout stays eligible after the ask leaves the direct card window", async () => {
|
|
5519
|
+
const { ask, children } = await delegatedAsk("CLOSURE_TIMEOUT");
|
|
5520
|
+
await completeTask(ask.id, "Waiting on child.");
|
|
5521
|
+
await getDbClient().run("UPDATE agent_tasks SET finishedAt = ? WHERE id = ?", [
|
|
5522
|
+
hoursAgo(5),
|
|
5523
|
+
ask.id,
|
|
5524
|
+
]);
|
|
5525
|
+
await backdateLastUpdated([ask.id, children[0]!.id], 5 * 3600);
|
|
5526
|
+
|
|
5527
|
+
await processSlackRenderV2();
|
|
5528
|
+
|
|
5529
|
+
expect((await getSlackOutcomeMessage(ask.id))?.conclusionKind).toBe("timeout");
|
|
5530
|
+
});
|
|
5531
|
+
|
|
5532
|
+
test("an old card whose stream never finalized still finishes", async () => {
|
|
5533
|
+
const { ask } = await slackAsk("OLD_STREAM");
|
|
5534
|
+
await completeTask(ask.id, "Retried result.");
|
|
5535
|
+
stopCallsUntilFailure = 0;
|
|
5536
|
+
await processSlackRenderV2();
|
|
5537
|
+
expect((await getSlackOutcomeMessage(ask.id))?.finalizedAt).toBeUndefined();
|
|
5538
|
+
await endedAt([ask.id], 5);
|
|
5539
|
+
stopCallsUntilFailure = undefined;
|
|
5540
|
+
_resetSlackRenderV2ForTests();
|
|
5541
|
+
|
|
5542
|
+
await processSlackRenderV2();
|
|
5543
|
+
|
|
5544
|
+
expect((await getSlackOutcomeMessage(ask.id))?.finalizedAt).toBeTruthy();
|
|
5545
|
+
});
|
|
5546
|
+
|
|
5547
|
+
test("an old card reservation is still delivered", async () => {
|
|
5548
|
+
const { ask, channelId, threadTs } = await slackAsk("OLD_RESERVATION");
|
|
5549
|
+
await completeTask(ask.id, "Reserved result.");
|
|
5550
|
+
await reserveSlackMessage({
|
|
5551
|
+
contextKey: slackContextKey({ channelId, threadTs }),
|
|
5552
|
+
channelId,
|
|
5553
|
+
threadTs,
|
|
5554
|
+
kind: "outcome",
|
|
5555
|
+
taskId: ask.id,
|
|
5556
|
+
});
|
|
5557
|
+
await endedAt([ask.id], 5);
|
|
5558
|
+
|
|
5559
|
+
await processSlackRenderV2();
|
|
5560
|
+
|
|
5561
|
+
expect((await getSlackOutcomeMessage(ask.id))?.finalizedAt).toBeTruthy();
|
|
5562
|
+
});
|
|
5563
|
+
|
|
5564
|
+
test("an answered Lead wake that ended before the window settles its trigger and posts no card", async () => {
|
|
5565
|
+
const trigger = `${slackAddressSequence + 1}.9`;
|
|
5566
|
+
const { lead, ask, channelId, threadTs } = await slackAsk("OLD_ANSWERED_WAKE", {
|
|
5567
|
+
slackTriggerMessageTs: trigger,
|
|
5568
|
+
});
|
|
5569
|
+
await completeTask(ask.id, "Waiting.", { addTags: ["deferred"] });
|
|
5570
|
+
const wake = await createTaskExtended("deferred wake", {
|
|
5571
|
+
agentId: lead.id,
|
|
5572
|
+
source: "schedule",
|
|
5573
|
+
taskType: "deferred",
|
|
5574
|
+
parentTaskId: ask.id,
|
|
5575
|
+
slackChannelId: channelId,
|
|
5576
|
+
slackThreadTs: threadTs,
|
|
5577
|
+
followUpConfig: { disabled: true },
|
|
5578
|
+
});
|
|
5579
|
+
await startTask(wake.id);
|
|
5580
|
+
await markTaskSlackReplySent(wake.id);
|
|
5581
|
+
await completeTask(wake.id, "Already replied.");
|
|
5582
|
+
await endedAt([ask.id, wake.id], 5);
|
|
5583
|
+
calls.length = 0;
|
|
5584
|
+
|
|
5585
|
+
markSlackThreadDirty(channelId, threadTs);
|
|
5586
|
+
await flushSlackRenderV2DirtyThreads();
|
|
5587
|
+
await Bun.sleep(0);
|
|
5588
|
+
|
|
5589
|
+
expect(calls).toContainEqual({
|
|
5590
|
+
method: "reactions.add",
|
|
5591
|
+
payload: { channel: channelId, name: "white_check_mark", timestamp: trigger },
|
|
5592
|
+
});
|
|
5593
|
+
expect(await getSlackOutcomeMessage(wake.id)).toBeNull();
|
|
5594
|
+
expect(await getSlackOutcomeMessage(ask.id)).toBeNull();
|
|
5595
|
+
expect(streamTexts()).toHaveLength(0);
|
|
5596
|
+
});
|
|
5597
|
+
});
|