@desplega.ai/agent-swarm 2.13.4 → 2.14.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-99n6z9ky.js +17 -0
- package/dist/{acp-targets-zrk9k0n7.js → acp-targets-23exz4z4.js} +10 -10
- package/dist/{actions-acqqj9jn.js → actions-zcr25x27.js} +61 -40
- package/dist/{agent-fs-provision-zmaykqnd.js → agent-fs-provision-7fa9e12e.js} +4 -4
- package/dist/{amp-adapter-a7ts8tmw.js → amp-adapter-s7ytmv6b.js} +3 -3
- package/dist/{anthropic-messages-88b7s3n9.js → anthropic-messages-vdd1zmha.js} +10 -10
- package/dist/{app-tmwa442h.js → app-5d3sz1hy.js} +7 -7
- package/dist/{approval-notifications-6psaaaye.js → approval-notifications-7qgkzkzx.js} +8 -8
- package/dist/{assistant-564v6emv.js → assistant-p2yvhc3j.js} +37 -32
- package/dist/{boot-args-schema-n099e0f2.js → boot-args-schema-ry6cb0p7.js} +1 -1
- package/dist/{boot-reembed-epvg4fp9.js → boot-reembed-2hkm3vz2.js} +1 -1
- package/dist/{boot-reembed-chx66qfk.js → boot-reembed-c9643ms3.js} +1 -1
- package/dist/{boot-scrub-sweep-dhkfp0a7.js → boot-scrub-sweep-3ycxr51t.js} +2 -2
- package/dist/{boot-seeds-m74fc07r.js → boot-seeds-2hzvvzg0.js} +4 -4
- package/dist/{boxd-451q55ys.js → boxd-9py3x0jb.js} +2 -2
- package/dist/{claude-adapter-hw63yj3j.js → claude-adapter-dnkww93e.js} +9 -9
- package/dist/{claude-managed-adapter-z5s7fx6p.js → claude-managed-adapter-yk0cr5x6.js} +4 -4
- package/dist/{claude-managed-setup-wee1762m.js → claude-managed-setup-4byxpp47.js} +5 -5
- package/dist/{claude-sdk-session-cktyqkpk.js → claude-sdk-session-4wf3dbvs.js} +13163 -12195
- package/dist/{cli-5rxsb3wq.js → cli-096aftq6.js} +12 -7
- package/dist/{cli-5rgm8p39.js → cli-0e914dp9.js} +3 -3
- package/dist/{cli-bzcwwebm.js → cli-0h6m6z5g.js} +1 -1
- package/dist/{cli-cah298e5.js → cli-0k7ppk9k.js} +231 -124
- package/dist/{cli-ja450998.js → cli-1nfabrt4.js} +8 -8
- package/dist/{cli-jzerrzgc.js → cli-2414h5r9.js} +8 -8
- package/dist/{cli-b768ek79.js → cli-24wervhz.js} +38 -0
- package/dist/{cli-93n305hm.js → cli-2ayk9gn8.js} +2 -2
- package/dist/{cli-kr0jpw9c.js → cli-2ckwgs7q.js} +1 -1
- package/dist/{cli-d5pc8ep0.js → cli-2savn6mm.js} +11 -100
- package/dist/{cli-jbrc98qb.js → cli-2zjxake1.js} +4 -4
- package/dist/{cli-4q2c8rxw.js → cli-37p61fcg.js} +15 -9
- package/dist/{cli-2vp0z049.js → cli-39t9d248.js} +1 -1
- package/dist/{cli-sa02jsqt.js → cli-3mhdmcd4.js} +1 -1
- package/dist/{cli-x2cem5vy.js → cli-3wsabyt0.js} +2 -2
- package/dist/{cli-dqgnbnxs.js → cli-466jjrwe.js} +16 -2
- package/dist/{cli-zhwjdhjr.js → cli-6ajyhxh7.js} +2 -2
- package/dist/{cli-3bxrrh53.js → cli-6yy4fepf.js} +4 -4
- package/dist/{cli-hhtbandk.js → cli-73rmgm45.js} +2 -2
- package/dist/{cli-8b4rpnwj.js → cli-7ca8hczj.js} +1 -1
- package/dist/{cli-0h8skzss.js → cli-7g5qj2ca.js} +4 -3
- package/dist/{cli-m1sns1da.js → cli-7w1fs01q.js} +2 -2
- package/dist/{cli-xwsm6xkr.js → cli-84wxwt3z.js} +1 -1
- package/dist/{cli-qzz6tz8s.js → cli-84xn7bgz.js} +1 -1
- package/dist/{cli-49aq3cyn.js → cli-879txsac.js} +5 -5
- package/dist/{cli-bv4vvnmg.js → cli-8vbxjzk0.js} +3 -3
- package/dist/{cli-7by7vp6m.js → cli-91amj3md.js} +3 -3
- package/dist/{cli-60dwk8tx.js → cli-930zbczq.js} +3 -3
- package/dist/{cli-7g3fg4gf.js → cli-9fwznq4p.js} +10 -10
- package/dist/{cli-4pbwg7sn.js → cli-9j1t3kf6.js} +2 -2
- package/dist/{cli-tzw1jr2t.js → cli-9j47sgzy.js} +2 -2
- package/dist/{cli-0fgvnb0x.js → cli-ad00h1st.js} +7 -7
- package/dist/{cli-kj84fqxz.js → cli-adzmmcvf.js} +19 -7
- package/dist/{cli-3tzmh38q.js → cli-ayxxkk3p.js} +68 -25
- package/dist/{cli-4vynxtrb.js → cli-bqfx72e6.js} +10 -3
- package/dist/{cli-8cas2xvp.js → cli-cbg0j1yt.js} +2716 -2643
- package/dist/{cli-fw67mnyc.js → cli-cg1q8ymp.js} +1 -1
- package/dist/{cli-he5nxaa8.js → cli-dw9rtjm3.js} +1 -1
- package/dist/{cli-jg5txpm6.js → cli-dy754erz.js} +83 -1
- package/dist/{cli-tsc3pdfd.js → cli-edxfzgah.js} +4 -4
- package/dist/{cli-hyqksecw.js → cli-ejnhs815.js} +15 -15
- package/dist/{cli-k0nebh10.js → cli-enavhq6r.js} +1 -1
- package/dist/{cli-ea7nz50q.js → cli-f2rwt43y.js} +14 -14
- package/dist/{cli-zjdhrzm0.js → cli-f9g96z28.js} +8 -8
- package/dist/{cli-rmgvwcmy.js → cli-fww016hh.js} +534 -70
- package/dist/{cli-rv3y60bt.js → cli-g6a696c0.js} +4 -4
- package/dist/{cli-z1vam71h.js → cli-gc6b94tj.js} +2 -2
- package/dist/{cli-p436yrzp.js → cli-gcyws2bp.js} +2 -2
- package/dist/{cli-srktrbby.js → cli-hzhv7yac.js} +1 -1
- package/dist/{cli-0p76my9q.js → cli-jcnc5ret.js} +44 -32
- package/dist/{cli-tr19nyn9.js → cli-jgq9xptq.js} +7 -7
- package/dist/{cli-pz1dp12c.js → cli-jwnac23b.js} +1 -1
- package/dist/{cli-904wk98s.js → cli-kc7vd07m.js} +917 -350
- package/dist/{cli-t0jmkcah.js → cli-kg63yp1r.js} +14 -14
- package/dist/{cli-ts5yv7dn.js → cli-krk8y8c7.js} +835 -157
- package/dist/{cli-jyhbvdga.js → cli-m0ea8ggd.js} +8 -10
- package/dist/{cli-944w9wb4.js → cli-md4tn21h.js} +20 -15
- package/dist/{cli-zexwhj3f.js → cli-mv8ft7b0.js} +10 -9
- package/dist/{cli-phdzn699.js → cli-mw1tmn3x.js} +217 -27
- package/dist/{cli-5ashycw3.js → cli-njvpngc6.js} +3 -3
- package/dist/{cli-9ah37a8a.js → cli-phe2vcw5.js} +10 -7
- package/dist/{cli-eds5xnsz.js → cli-phmy14hb.js} +2 -2
- package/dist/{cli-n1kjs58m.js → cli-pq0kv31y.js} +5 -5
- package/dist/{cli-pz1nq5xm.js → cli-q457ga28.js} +6 -6
- package/dist/{cli-s33bzmk0.js → cli-q5n3deaf.js} +1 -1
- package/dist/{cli-4fpa0zns.js → cli-qkbevqer.js} +3 -3
- package/dist/{cli-29h5239w.js → cli-qrwjk4xy.js} +5 -5
- package/dist/{cli-kezzteka.js → cli-r04ve9xw.js} +1 -1
- package/dist/{cli-3xqad83h.js → cli-r495stwd.js} +2 -2
- package/dist/{cli-1kvcsd2f.js → cli-r9d2tya0.js} +71 -3
- package/dist/{cli-ybte1fqc.js → cli-rp1n2xpd.js} +1 -1
- package/dist/{cli-fkpnx3vf.js → cli-rs1rzwp4.js} +3 -2
- package/dist/{cli-h9d3sdnc.js → cli-rzbsh6bw.js} +1 -1
- package/dist/{cli-94gx6ze9.js → cli-s4pccby1.js} +1 -1
- package/dist/{cli-cq4am6vg.js → cli-shyhb4t5.js} +10 -10
- package/dist/{cli-gtj12v95.js → cli-srq69pn1.js} +1 -1
- package/dist/{cli-azj9t1f9.js → cli-tc165vrb.js} +48 -5
- package/dist/{cli-gse7bp3z.js → cli-v4z5v3jd.js} +300 -81
- package/dist/{cli-p3knvk62.js → cli-vxmmttmt.js} +132 -53
- package/dist/{cli-404am6f3.js → cli-w4bvtxet.js} +7 -7
- package/dist/{cli-gkv0r2hq.js → cli-wd7b5hgc.js} +71 -9
- package/dist/{cli-akm6y2a8.js → cli-wvbaq052.js} +1 -1
- package/dist/{cli-ywy8yz6t.js → cli-wvgg7r4j.js} +2 -2
- package/dist/{cli-ka48vpev.js → cli-wym6rxgt.js} +165 -6
- package/dist/{cli-nc4pbwmp.js → cli-yd7e590v.js} +12 -12
- package/dist/{cli-3zrwrnz7.js → cli-yjb3cddd.js} +1 -1
- package/dist/{cli-7gbff32z.js → cli-z8t4485r.js} +2 -2
- package/dist/{cli-hdhpdrka.js → cli-ze1ndjs4.js} +4 -6
- package/dist/{cli-50wa8k4h.js → cli-zy9bb22b.js} +1 -2
- package/dist/cli.js +28 -28
- package/dist/{codex-adapter-2fs2c0n6.js → codex-adapter-eq61radw.js} +8 -8
- package/dist/{codex-hook-jxjv6dy5.js → codex-hook-8nmepvz6.js} +3 -3
- package/dist/{codex-login-ktfg1cxk.js → codex-login-vbd9707w.js} +1 -1
- package/dist/{codex-session-runner-r55tmx4c.js → codex-session-runner-rfx355h4.js} +9 -9
- package/dist/{commands-0mxdy9x8.js → commands-d1z0sx62.js} +3 -3
- package/dist/{controller-g3vkfhr4.js → controller-9hz6d8x3.js} +4 -4
- package/dist/{controllers-connect-4wdmncqt.js → controllers-connect-tz07d2xr.js} +24 -25
- package/dist/core-dynsv289.js +41 -0
- package/dist/{cursor-adapter-t9qb96q2.js → cursor-adapter-ef22ze3j.js} +2 -2
- package/dist/{db-487vvyv9.js → db-gd81d68c.js} +3 -3
- package/dist/{db-76p7w3gr.js → db-vrckks6q.js} +4 -2
- package/dist/{devin-adapter-3bp6rape.js → devin-adapter-kdt6a2bh.js} +1 -1
- package/dist/{dispatcher-64rp6w67.js → dispatcher-76as8w2t.js} +21 -22
- package/dist/{docker-a59g3ebm.js → docker-51ta7jsh.js} +2 -2
- package/dist/dsh-adapter-ypfvcdyz.js +11 -0
- package/dist/{e2b-dc8f6ctq.js → e2b-05kn3kpq.js} +16 -5
- package/dist/{e2b-3ykbe805.js → e2b-dm9r8hpy.js} +3 -3
- package/dist/{easter-egg-3d-jrrwyf55.js → easter-egg-3d-sg21j15g.js} +1 -1
- package/dist/{embedding-space-001hhhpk.js → embedding-space-zsdw37bb.js} +13 -23
- package/dist/{embeddings-esj19cnw.js → embeddings-p4e3e1m6.js} +1 -1
- package/dist/{event-bus-7gbsr0g4.js → event-bus-tvf2grf4.js} +1 -1
- package/dist/{execute-301hkxqg.js → execute-nztd0af0.js} +1 -1
- package/dist/{external-channel-w10e2j05.js → external-channel-717yzn4d.js} +2 -2
- package/dist/fx-adapter-9k0hptnz.js +20 -0
- package/dist/grok-adapter-skdj2pce.js +20 -0
- package/dist/handlers-5btjqkz6.js +39 -0
- package/dist/{heartbeat-tbrj7vhq.js → heartbeat-vfb1gy84.js} +24 -25
- package/dist/{hook-tx917rqw.js → hook-ctz0xmp3.js} +11 -11
- package/dist/{hook-3am1sq68.js → hook-eh52p7yd.js} +6 -6
- package/dist/{http-3rmemtqy.js → http-zregegrx.js} +902 -198
- package/dist/{index-s7xtvc0f.js → index-5kx15d19.js} +1 -1
- package/dist/index-7w8p6em0.js +41 -0
- package/dist/index-evay0xyk.js +17 -0
- package/dist/{index-2jw11t8s.js → index-fdym6ryb.js} +25 -26
- package/dist/{index-3j803vnb.js → index-mtnbhe12.js} +20533 -19786
- package/dist/index-vz4semsx.js +38 -0
- package/dist/{index-gfnq66t1.js → index-x9qf8dg7.js} +294 -29
- package/dist/index-y3s0xp2v.js +43 -0
- package/dist/{k8s-36gfn847.js → k8s-ejkk0aw7.js} +2 -2
- package/dist/{keepalive-9px3t7qj.js → keepalive-zdqay870.js} +4 -5
- package/dist/lead-6cscw8a5.js +82 -0
- package/dist/{maintenance-vwqjwst6.js → maintenance-t5ndg11m.js} +1 -1
- package/dist/{node-2wfcey7d.js → node-0as4n1ef.js} +3 -3
- package/dist/{node-zd6shky9.js → node-dhxbt01p.js} +3 -3
- package/dist/{node-z67yjre7.js → node-jkdd5w7m.js} +290 -70
- package/dist/{node-hjn5n1yp.js → node-t0ct2zpw.js} +3 -5
- package/dist/{oauth-refresh-sweep-yqry3wn4.js → oauth-refresh-sweep-y9zyd7t6.js} +3 -4
- package/dist/{object-webhooks-8s1wtths.js → object-webhooks-mkca91s0.js} +7 -7
- package/dist/{onboard-hb8czx0p.js → onboard-ss995244.js} +11 -9
- package/dist/{opencode-adapter-djd6m6dk.js → opencode-adapter-mwpz0278.js} +8 -8
- package/dist/{otel-impl-2ymwyczz.js → otel-impl-6n6vva3x.js} +2 -2
- package/dist/{pending-nxavtvx7.js → pending-2sxh1t6j.js} +22 -23
- package/dist/{pi-mono-adapter-d2cpmcy4.js → pi-mono-adapter-sfb7zy43.js} +13 -13
- package/dist/{pricing-refresh-1yz8jkqv.js → pricing-refresh-h79bg4cf.js} +2 -2
- package/dist/{rbac-roles-7s6m31xw.js → rbac-roles-ckq0czp4.js} +2 -2
- package/dist/{rbac-roles-dbpx0x9v.js → rbac-roles-jg2e260w.js} +3 -3
- package/dist/{render-v2-7y20rjrn.js → render-v2-ymbshmn0.js} +7 -7
- package/dist/{resume-wz546x47.js → resume-jdhnt4jk.js} +10 -10
- package/dist/{runtime-cb5bd9tz.js → runtime-y28jhhnf.js} +1 -1
- package/dist/{session-access-4vcft8kq.js → session-access-k4ta5hvp.js} +5 -5
- package/dist/{session-source-backfill-57b50tpw.js → session-source-backfill-528j4s8j.js} +3 -3
- package/dist/{setup-e1tevjyj.js → setup-d6pj82fr.js} +15 -6
- package/dist/thread-buffer-9w6x5zec.js +40 -0
- package/dist/{tree-visibility-07wf1nct.js → tree-visibility-kjxv3nxk.js} +2 -2
- package/dist/{user-merge-jobs-n20qpv6s.js → user-merge-jobs-rabbncf6.js} +3 -3
- package/dist/{virtual-modules-6fxmn1yv.js → virtual-modules-22k51txd.js} +3 -3
- package/dist/{work-objects-eg7y48pe.js → work-objects-xtjbar3r.js} +26 -30
- package/dist/{worker-follow-up-jnvnnf2b.js → worker-follow-up-fg48vk6d.js} +21 -22
- package/dist/worker-g4aj93dt.js +82 -0
- package/dist/{x-d27jj7z7.js → x-vfsqypht.js} +2 -2
- package/openapi.json +633 -25
- package/package.json +10 -10
- package/src/apps/definition.ts +76 -24
- package/src/apps/row-store.ts +67 -0
- package/src/apps/script-types.ts +131 -21
- package/src/apps/store.ts +4 -1
- package/src/apps/sync.ts +20 -5
- package/src/azure-devops/boards-sync.ts +1 -1
- package/src/be/db/script-runs.ts +33 -0
- package/src/be/db/slack-card-groups.ts +147 -0
- package/src/be/db/slack-trees.ts +38 -1
- package/src/be/db/task-idempotency.ts +63 -0
- package/src/be/db/tasks/read.ts +27 -1
- package/src/be/db/tasks/write.ts +51 -14
- package/src/be/db/users/avatar.ts +12 -0
- package/src/be/db/workflow-idempotency.ts +6 -1
- package/src/be/db/workflows/read.ts +79 -0
- package/src/be/db.ts +129 -152
- package/src/be/improvements.ts +24 -2
- package/src/be/mcp-proxy.ts +45 -11
- package/src/be/memory/embedding-space.ts +10 -20
- package/src/be/memory/index.ts +35 -0
- package/src/be/memory/providers/openai-embedding.ts +10 -0
- package/src/be/migrations/344_user_avatar.sql +4 -0
- package/src/be/migrations/345_task_status_kind.sql +6 -0
- package/src/be/migrations/348_task_deferred_until.sql +4 -0
- package/src/be/migrations/354_durable_objects.sql +9 -0
- package/src/be/migrations/356_slack_outcome_card_groups.sql +14 -0
- package/src/be/migrations/357_task_idempotency_keys.sql +27 -0
- package/src/be/migrations/362_favorites_app.sql +36 -0
- package/src/be/primitives/object-embed.ts +2 -2
- package/src/be/primitives/objects.ts +2 -2
- package/src/be/repo-checked-update.ts +58 -5
- package/src/be/requester-timezone.ts +10 -0
- package/src/be/runtime-pools/supervisor.ts +1 -0
- package/src/be/script-connections.ts +5 -1
- package/src/be/script-credential-broker.ts +29 -2
- package/src/be/scripts/durable.ts +204 -0
- package/src/be/scripts/extract-schema.ts +29 -4
- package/src/be/scripts/run-credential.ts +1 -8
- package/src/be/scripts/typecheck.ts +33 -8
- package/src/be/seed-scripts/catalog/memory-eval.ts +11 -2
- package/src/be/seed-scripts/catalog/tool-usage.ts +27 -8
- package/src/be/swarm-config-guard.ts +91 -7
- package/src/be/users.ts +33 -12
- package/src/bitbucket/handlers.ts +1 -1
- package/src/comb/review-batch.ts +16 -5
- package/src/commands/context-preamble.ts +237 -0
- package/src/commands/credential-outcome-report.ts +96 -0
- package/src/commands/e2b.ts +14 -0
- package/src/commands/entrypoint-mcp-config.ts +231 -0
- package/src/commands/onboard/agent-fs-version.ts +1 -1
- package/src/commands/onboard/compose-generator.ts +2 -1
- package/src/commands/onboard/env-generator.ts +16 -7
- package/src/commands/runner.ts +72 -10
- package/src/commands/setup.tsx +17 -3
- package/src/event-waits/github.ts +39 -6
- package/src/event-waits/index.ts +4 -2
- package/src/event-waits/types.ts +10 -3
- package/src/extensions/contract-types.generated.ts +1 -1
- package/src/github/app.ts +177 -13
- package/src/github/handlers.ts +7 -2
- package/src/github/pull-request-state.ts +100 -11
- package/src/gitlab/handlers.ts +2 -2
- package/src/heartbeat/heartbeat.ts +6 -1
- package/src/hooks/hook.ts +8 -2
- package/src/hooks/native-tool-hooks.ts +4 -2
- package/src/http/api-keys.ts +26 -0
- package/src/http/apps.ts +82 -42
- package/src/http/asset-key-write.ts +45 -0
- package/src/http/assets.ts +4 -3
- package/src/http/comb.ts +21 -5
- package/src/http/config.ts +8 -4
- package/src/http/github-token.ts +27 -6
- package/src/http/heartbeat.ts +5 -0
- package/src/http/index.ts +12 -6
- package/src/http/kv.ts +7 -5
- package/src/http/mcp-oauth.ts +16 -0
- package/src/http/mcp-servers.ts +43 -3
- package/src/http/memory.ts +28 -1
- package/src/http/metrics.ts +11 -4
- package/src/http/onboarding.ts +12 -1
- package/src/http/pages.ts +4 -10
- package/src/http/repos.ts +27 -11
- package/src/http/request-principal.ts +27 -1
- package/src/http/schedules.ts +42 -14
- package/src/http/script-connection-proxy.ts +3 -1
- package/src/http/script-runs.ts +21 -10
- package/src/http/scripts.ts +177 -26
- package/src/http/session-cost-recompute.ts +9 -4
- package/src/http/sessions.ts +7 -2
- package/src/http/skills.ts +70 -0
- package/src/http/status.ts +2 -0
- package/src/http/tasks.ts +115 -19
- package/src/http/trackers/jira.ts +18 -3
- package/src/http/trackers/linear.ts +3 -0
- package/src/http/users.ts +5 -0
- package/src/http/webhooks.ts +19 -1
- package/src/http/workflows.ts +5 -10
- package/src/integrations/chat-sdk/commands.ts +3 -1
- package/src/jira/sync.ts +1 -1
- package/src/kv-limits.ts +2 -0
- package/src/kv-reserved-namespaces.ts +25 -2
- package/src/linear/sync.ts +5 -3
- package/src/prompts/session-templates.ts +50 -0
- package/src/prompts/session-turns.ts +30 -0
- package/src/providers/acp-targets.ts +2 -2
- package/src/providers/amp-adapter.ts +1 -1
- package/src/providers/claude-adapter.ts +5 -0
- package/src/providers/claude-managed-adapter.ts +14 -0
- package/src/providers/claude-sdk-session.ts +19 -1
- package/src/providers/cursor-adapter.ts +1 -1
- package/src/providers/dsh-adapter.ts +1 -1
- package/src/providers/opencode-adapter.ts +3 -5
- package/src/providers/runtime-dependencies.ts +11 -8
- package/src/rbac/legacy-policy.ts +7 -0
- package/src/rbac/permissions.ts +27 -0
- package/src/scheduler/deferred-task-waits.ts +74 -13
- package/src/scheduler/scheduler.ts +36 -18
- package/src/script-workflows/executor.ts +37 -8
- package/src/script-workflows/supervisor.ts +14 -0
- package/src/scripts-runtime/ctx.ts +5 -1
- package/src/scripts-runtime/durable-object-base.ts +19 -0
- package/src/scripts-runtime/eval-harness.ts +46 -1
- package/src/scripts-runtime/executors/native.ts +13 -1
- package/src/scripts-runtime/executors/quickjs-bundle.ts +20 -1
- package/src/scripts-runtime/executors/quickjs-prelude.ts +40 -1
- package/src/scripts-runtime/executors/quickjs-runner.ts +26 -3
- package/src/scripts-runtime/executors/quickjs-worker.ts +2 -1
- package/src/scripts-runtime/executors/types.ts +26 -0
- package/src/scripts-runtime/extract-signature.ts +96 -1
- package/src/scripts-runtime/loader.ts +11 -5
- package/src/scripts-runtime/mcp-client.ts +1 -1
- package/src/scripts-runtime/sdk-allowlist.ts +1 -0
- package/src/scripts-runtime/swarm-config.ts +7 -0
- package/src/scripts-runtime/swarm-sdk.ts +12 -2
- package/src/scripts-runtime/types/stdlib.d.ts +27 -1
- package/src/scripts-runtime/types/swarm-extension.d.ts +20 -2
- package/src/scripts-runtime/types/swarm-sdk.d.ts +27 -1
- package/src/slack/actions.ts +25 -1
- package/src/slack/assistant.ts +8 -0
- package/src/slack/blocks.ts +35 -0
- package/src/slack/channel-activity.ts +7 -0
- package/src/slack/enrich.ts +46 -54
- package/src/slack/files.ts +173 -23
- package/src/slack/handlers.test.ts +17 -19
- package/src/slack/handlers.ts +15 -14
- package/src/slack/render-v2.ts +403 -17
- package/src/slack/responses.ts +61 -5
- package/src/slack/session-mirror.ts +10 -5
- package/src/slack/task-output.ts +25 -14
- package/src/slack/templates.ts +9 -0
- package/src/slack/thread-participants.ts +64 -24
- package/src/slack/watcher.ts +4 -4
- package/src/slack/work-objects.ts +1 -1
- package/src/stdio.ts +5 -0
- package/src/tests/agents-list-model-display.test.ts +4 -0
- package/src/tests/api-drain-worker-e2e.test.ts +0 -2
- package/src/tests/approval-auto-cancellation-migration.test.ts +8 -19
- package/src/tests/approval-card-resolution.test.ts +2 -17
- package/src/tests/approval-requests-notifications.test.ts +41 -27
- package/src/tests/approval-requests.test.ts +137 -369
- package/src/tests/apps-script-types.test.ts +63 -16
- package/src/tests/apps-sort-order.test.ts +87 -0
- package/src/tests/apps-sync-engine.test.ts +5 -3
- package/src/tests/apps-table-filters-migration.test.ts +44 -25
- package/src/tests/bedrock-model-groups.test.ts +4 -0
- package/src/tests/bitbucket-handlers.test.ts +2 -0
- package/src/tests/channel-activity.test.ts +9 -0
- package/src/tests/chat-sdk-commands.test.ts +1 -0
- package/src/tests/chatgpt-subscription-model-groups.test.ts +4 -0
- package/src/tests/claude-adapter.test.ts +35 -0
- package/src/tests/claude-hook-output.test.ts +2 -0
- package/src/tests/claude-managed-adapter.test.ts +15 -3
- package/src/tests/claude-sdk-stderr.test.ts +28 -0
- package/src/tests/codex-adapter.test.ts +3 -92
- package/src/tests/codex-gpt6-release.test.ts +4 -9
- package/src/tests/codex-oauth-credential-info.test.ts +35 -18
- package/src/tests/codex-oauth.test.ts +0 -6
- package/src/tests/codex-pool.test.ts +5 -214
- package/src/tests/codex-rate-limit-parse.test.ts +0 -7
- package/src/tests/codex-swarm-events.test.ts +11 -54
- package/src/tests/comb-review-batch.test.ts +17 -4
- package/src/tests/comb-status.test.ts +1 -0
- package/src/tests/db-client-busy-retry.test.ts +49 -16
- package/src/tests/db-client.test.ts +11 -5
- package/src/tests/db-task-read-contract.test.ts +1 -0
- package/src/tests/db-task-write-contract.test.ts +2 -2
- package/src/tests/defer-task.test.ts +24 -1
- package/src/tests/dsh-adapter.test.ts +1 -1
- package/src/tests/e2b-dispatch.test.ts +13 -1
- package/src/tests/e2e-shards.test.ts +9 -9
- package/src/tests/enabled-tools.test.ts +0 -2
- package/src/tests/entrypoint-mcp-config.test.ts +642 -0
- package/src/tests/fixtures/base-prompt-baseline.json +6 -6
- package/src/tests/fixtures/onboard/content.env.txt +2 -2
- package/src/tests/fixtures/onboard/dev.env.txt +2 -2
- package/src/tests/fixtures/onboard/full-all.env.txt +2 -2
- package/src/tests/fixtures/onboard/full.env.txt +2 -2
- package/src/tests/fixtures/onboard/research.env.txt +2 -2
- package/src/tests/fixtures/onboard/solo.env.txt +2 -2
- package/src/tests/fixtures/runner-missing-dependency.ts +2 -1
- package/src/tests/fx-adapter.test.ts +4 -5
- package/src/tests/github-app-worker-auth-helper.test.ts +147 -1
- package/src/tests/gitlab-handlers.test.ts +2 -0
- package/src/tests/heartbeat-jev-gate.test.ts +9 -241
- package/src/tests/heartbeat-reroute-decision.test.ts +2 -0
- package/src/tests/heartbeat-supersede-resume.test.ts +2 -0
- package/src/tests/heartbeat.test.ts +1 -0
- package/src/tests/hook-mcp-config-precedence.test.ts +59 -0
- package/src/tests/hook-ping-me-order.test.ts +1 -0
- package/src/tests/hook-runtime-close.test.ts +1 -0
- package/src/tests/improvements-payload.test.ts +2 -2
- package/src/tests/key-usage-selection.test.ts +302 -0
- package/src/tests/memory-e2e.test.ts +34 -103
- package/src/tests/memory-key-paths.test.ts +5 -0
- package/src/tests/memory-rater-llm.test.ts +33 -149
- package/src/tests/memory-store.test.ts +24 -125
- package/src/tests/memory.test.ts +31 -100
- package/src/tests/merge-gate-detect-changes.test.ts +108 -2
- package/src/tests/model-groups-live-catalog.test.ts +4 -0
- package/src/tests/oauth-credential-bindings.test.ts +8 -3
- package/src/tests/oauth-refresh-failure.test.ts +15 -3
- package/src/tests/onboard-env.test.ts +1 -1
- package/src/tests/openai-compatible-providers.test.ts +5 -0
- package/src/tests/openapi-route-headers.test.ts +2 -1
- package/src/tests/opus-5-5-registry.test.ts +4 -0
- package/src/tests/otel-service-name.test.ts +0 -9
- package/src/tests/otel-session-cost-metrics.test.ts +1 -38
- package/src/tests/pool-session-logs.test.ts +8 -42
- package/src/tests/pre-push-affected-tests.test.ts +106 -0
- package/src/tests/prompt-template-session.test.ts +3 -0
- package/src/tests/provider-runtime-dependencies.test.ts +26 -15
- package/src/tests/routing-affinity-inventory.test.ts +11 -0
- package/src/tests/runner-api-drain.test.ts +2 -17
- package/src/tests/runner-context-preamble.test.ts +202 -0
- package/src/tests/runner-repo-clone-args.test.ts +116 -0
- package/src/tests/runner-terminal-window-report.test.ts +132 -0
- package/src/tests/runtime-supervisor-failures.test.ts +1 -0
- package/src/tests/sandboxed-process.test.ts +26 -21
- package/src/tests/schedule-http-triage-tools.test.ts +12 -9
- package/src/tests/scheduled-tasks.test.ts +14 -51
- package/src/tests/scheduler-occurrence.test.ts +60 -9
- package/src/tests/script-connections-mcp.test.ts +6 -3
- package/src/tests/script-connections.test.ts +4 -0
- package/src/tests/script-executor-conformance.test.ts +4 -48
- package/src/tests/script-executor-quickjs-pool.test.ts +9 -7
- package/src/tests/script-native-startup.test.ts +21 -25
- package/src/tests/scripts-namespaces.test.ts +3 -1
- package/src/tests/secret-rules.test.ts +4 -2
- package/src/tests/secret-scrubber.test.ts +8 -2
- package/src/tests/session-cost-recompute-unit.test.ts +39 -0
- package/src/tests/session-costs-recompute-all-providers.test.ts +6 -3
- package/src/tests/session-logs.test.ts +1 -260
- package/src/tests/session-route-posture.test.ts +7 -1
- package/src/tests/slack-file-tools-attachments.test.ts +14 -9
- package/src/tests/slack-identity-resolution.test.ts +10 -3
- package/src/tests/slack-inline-output.test.ts +10 -8
- package/src/tests/slack-render-v2.test.ts +14 -152
- package/src/tests/slack-steering.test.ts +8 -2
- package/src/tests/slack-thread-participants.test.ts +11 -1
- package/src/tests/sonnet-5-5-registry.test.ts +4 -0
- package/src/tests/swarm-config-encryption.test.ts +5 -8
- package/src/tests/task-cascade-fail.test.ts +1 -0
- package/src/tests/task-supersede-resume.test.ts +1 -0
- package/src/tests/test-proc.ts +5 -2
- package/src/tests/ui-spec-script-actions-config.test.ts +7 -3
- package/src/tests/window-stream-reporter.test.ts +122 -0
- package/src/tests/workflow-agent-task-retry.test.ts +1 -3
- package/src/tests/workflow-cascade-cancel.test.ts +1 -0
- package/src/tests/workflow-retry-v2.test.ts +34 -43
- package/src/tests/workflow-retry-validation.test.ts +8 -48
- package/src/tests/workflow-triggers-v2.test.ts +35 -11
- package/src/tests/worktree-reaper.test.ts +2 -2
- package/src/tools/app-patch.ts +6 -2
- package/src/tools/app-upsert.ts +8 -4
- package/src/tools/cancel-task.ts +2 -2
- package/src/tools/defer-task.ts +24 -79
- package/src/tools/get-task-details.ts +8 -4
- package/src/tools/get-tasks.ts +13 -2
- package/src/tools/kv/kv-get.ts +2 -0
- package/src/tools/kv/kv-list.ts +11 -5
- package/src/tools/kv/kv-set.ts +1 -3
- package/src/tools/manage-user.ts +9 -0
- package/src/tools/repos/update-repo.ts +37 -19
- package/src/tools/schedules/run-schedule-now.ts +21 -1
- package/src/tools/script-apis.ts +9 -4
- package/src/tools/script-common.ts +2 -2
- package/src/tools/script-run.ts +8 -0
- package/src/tools/script-upsert.ts +1 -1
- package/src/tools/slack-download-file.ts +15 -12
- package/src/tools/slack-post.ts +7 -1
- package/src/tools/slack-read.ts +3 -1
- package/src/tools/slack-reply.ts +16 -0
- package/src/tools/slack-start-thread.ts +8 -1
- package/src/tools/slack-upload-file.ts +99 -96
- package/src/tools/store-progress.ts +5 -3
- package/src/tools/swarm-config/set-config.ts +3 -1
- package/src/tools/swarm-x.ts +0 -2
- package/src/tools/utils.ts +3 -0
- package/src/types.ts +101 -2
- package/src/utils/constants.ts +32 -0
- package/src/utils/credentials.ts +42 -5
- package/src/utils/deferral-time.ts +61 -0
- package/src/utils/error-tracker.ts +6 -0
- package/src/utils/key-usage.ts +114 -0
- package/src/utils/request-auth-context.ts +15 -16
- package/src/utils/sandboxed-process.ts +1 -0
- package/src/utils/secret-scrubber.ts +1 -1
- package/src/workflows/engine.ts +6 -11
- package/src/workflows/executors/swarm-script.ts +0 -2
- package/src/workflows/foreach-driver.ts +6 -12
- package/src/workflows/input.ts +24 -1
- package/src/workflows/node-timeout.ts +18 -0
- package/src/workflows/resume.ts +5 -2
- package/src/workflows/retry-poller.ts +2 -1
- package/src/workflows/triggers.ts +21 -11
- package/src/x/composio.ts +10 -1
- package/templates/skills/apps/SKILL.md +6 -2
- package/templates/skills/apps/content.md +6 -2
- package/templates/skills/boards-and-sheets/content.md +4 -2
- package/templates/skills/code-quality/content.md +4 -4
- package/templates/skills/pages/content.md +7 -0
- package/templates/skills/scheduled-task-resilience/SKILL.md +2 -0
- package/templates/skills/scheduled-task-resilience/content.md +2 -0
- package/templates/skills/swarm-docs/content.md +8 -0
- package/templates/skills/swarm-scripts/SKILL.md +45 -0
- package/templates/skills/swarm-scripts/content.md +45 -0
- package/dist/acp-adapter-mr4temec.js +0 -17
- package/dist/cli-1vmhnncj.js +0 -173
- package/dist/cli-kj0hyr43.js +0 -51
- package/dist/cli-ysv0k1we.js +0 -459
- package/dist/core-gsvj5f3z.js +0 -42
- package/dist/dsh-adapter-8abzqk5c.js +0 -9
- package/dist/fx-adapter-4sjrbdne.js +0 -20
- package/dist/grok-adapter-3a0ezfee.js +0 -20
- package/dist/handlers-ef3k11hb.js +0 -41
- package/dist/index-aetfyx6p.js +0 -13
- package/dist/index-e6bq0exk.js +0 -42
- package/dist/index-hf2k1vge.js +0 -39
- package/dist/index-taxmejj3.js +0 -44
- package/dist/lead-5vt6f174.js +0 -83
- package/dist/thread-buffer-686pa1p1.js +0 -42
- package/dist/worker-4vp616ms.js +0 -83
- package/src/tests/apps-table-selection-migration.test.ts +0 -95
- package/src/tests/extensions-example-heartbeat-remediate.test.ts +0 -69
- package/src/tests/extensions-example-rewrite-and-suppress.test.ts +0 -70
|
@@ -17,10 +17,14 @@ import {
|
|
|
17
17
|
iconPrefix,
|
|
18
18
|
completedStatusIcon,
|
|
19
19
|
init_reaction_shortcode,
|
|
20
|
+
isValidTimezone,
|
|
21
|
+
formatDeferralDateTime,
|
|
22
|
+
init_deferral_time,
|
|
20
23
|
getAgentById2,
|
|
21
24
|
closeSlackTreeIfSettled,
|
|
22
25
|
getSlackThreadsOfTasks,
|
|
23
26
|
slackThreadHasBotReplySince,
|
|
27
|
+
slackThreadHasAgentReplyOnTasksSince,
|
|
24
28
|
slackThreadHasOutcomeWork,
|
|
25
29
|
getSlackProcessingThreads,
|
|
26
30
|
init_slack_trees,
|
|
@@ -61,15 +65,16 @@ import {
|
|
|
61
65
|
getLogsByTaskIdChronological2,
|
|
62
66
|
checkDependencies2,
|
|
63
67
|
emitBuiltInIntegrationConnectedOnce2,
|
|
68
|
+
getUserById2,
|
|
64
69
|
claimKv2,
|
|
65
70
|
deleteKv2,
|
|
66
71
|
init_db4
|
|
67
|
-
} from "./cli-
|
|
72
|
+
} from "./cli-krk8y8c7.js";
|
|
68
73
|
import {
|
|
69
74
|
getChannelExternality2,
|
|
70
75
|
getChannelBlockReason2,
|
|
71
76
|
init_external_channel
|
|
72
|
-
} from "./cli-
|
|
77
|
+
} from "./cli-z8t4485r.js";
|
|
73
78
|
import {
|
|
74
79
|
isSlackTaskTreeEnabled2,
|
|
75
80
|
invalidateSlackTreeOperations2,
|
|
@@ -80,7 +85,7 @@ import {
|
|
|
80
85
|
assertSlackTreeCurrent2,
|
|
81
86
|
canPresentSlackTree2,
|
|
82
87
|
init_tree_visibility
|
|
83
|
-
} from "./cli-
|
|
88
|
+
} from "./cli-84xn7bgz.js";
|
|
84
89
|
import {
|
|
85
90
|
require_dist6,
|
|
86
91
|
require_is_electron,
|
|
@@ -96,7 +101,7 @@ import {
|
|
|
96
101
|
import {
|
|
97
102
|
workflowEventBus2,
|
|
98
103
|
init_event_bus
|
|
99
|
-
} from "./cli-
|
|
104
|
+
} from "./cli-rp1n2xpd.js";
|
|
100
105
|
import {
|
|
101
106
|
require_jsonwebtoken,
|
|
102
107
|
require_dist9,
|
|
@@ -110,7 +115,7 @@ import {
|
|
|
110
115
|
import {
|
|
111
116
|
getSessionRoot,
|
|
112
117
|
init_session_shares
|
|
113
|
-
} from "./cli-
|
|
118
|
+
} from "./cli-jwnac23b.js";
|
|
114
119
|
import {
|
|
115
120
|
require_p_retry
|
|
116
121
|
} from "./cli-952zgdwp.js";
|
|
@@ -118,7 +123,7 @@ import {
|
|
|
118
123
|
findUserById,
|
|
119
124
|
getUserIdentities,
|
|
120
125
|
init_users
|
|
121
|
-
} from "./cli-
|
|
126
|
+
} from "./cli-adzmmcvf.js";
|
|
122
127
|
import {
|
|
123
128
|
getGitHubLinkConfig,
|
|
124
129
|
init_github_host
|
|
@@ -126,7 +131,7 @@ import {
|
|
|
126
131
|
import {
|
|
127
132
|
taskAttachmentDisplayUrl,
|
|
128
133
|
init_task_attachment_links
|
|
129
|
-
} from "./cli-
|
|
134
|
+
} from "./cli-wym6rxgt.js";
|
|
130
135
|
import {
|
|
131
136
|
getSlackConfiguration,
|
|
132
137
|
init_config5
|
|
@@ -134,7 +139,7 @@ import {
|
|
|
134
139
|
import {
|
|
135
140
|
isTerminalTaskStatus,
|
|
136
141
|
init_types5
|
|
137
|
-
} from "./cli-
|
|
142
|
+
} from "./cli-tc165vrb.js";
|
|
138
143
|
import {
|
|
139
144
|
init_zod
|
|
140
145
|
} from "./cli-96234j5w.js";
|
|
@@ -158,7 +163,7 @@ import {
|
|
|
158
163
|
import {
|
|
159
164
|
getAppUrl,
|
|
160
165
|
init_constants3
|
|
161
|
-
} from "./cli-
|
|
166
|
+
} from "./cli-466jjrwe.js";
|
|
162
167
|
import {
|
|
163
168
|
isEnvFlagEnabled,
|
|
164
169
|
init_env_flag
|
|
@@ -171,7 +176,7 @@ import {
|
|
|
171
176
|
scrubSecrets,
|
|
172
177
|
scrubObject,
|
|
173
178
|
init_secret_scrubber
|
|
174
|
-
} from "./cli-
|
|
179
|
+
} from "./cli-r9d2tya0.js";
|
|
175
180
|
import {
|
|
176
181
|
__toESM,
|
|
177
182
|
__commonJS,
|
|
@@ -12411,7 +12416,7 @@ async function initOtel(serviceRole = process.env.AGENT_ROLE || "api") {
|
|
|
12411
12416
|
return;
|
|
12412
12417
|
initialized = true;
|
|
12413
12418
|
try {
|
|
12414
|
-
const impl = await import("./otel-impl-
|
|
12419
|
+
const impl = await import("./otel-impl-6n6vva3x.js");
|
|
12415
12420
|
await impl.boot(serviceRole, {
|
|
12416
12421
|
exportConsoleLogs: serviceRole === "api" && isApiLogExportEnabled()
|
|
12417
12422
|
});
|
|
@@ -12492,17 +12497,35 @@ var init_otel = __esm(() => {
|
|
|
12492
12497
|
};
|
|
12493
12498
|
});
|
|
12494
12499
|
|
|
12500
|
+
// src/be/requester-timezone.ts
|
|
12501
|
+
async function resolveRequesterTimezone(requestedByUserId, fallback) {
|
|
12502
|
+
const user = requestedByUserId ? await getUserById2(requestedByUserId) : null;
|
|
12503
|
+
const timezone = user?.timezone;
|
|
12504
|
+
if (isValidTimezone(timezone))
|
|
12505
|
+
return { tz: timezone, isFallback: false };
|
|
12506
|
+
return { tz: isValidTimezone(fallback) ? fallback : "UTC", isFallback: true };
|
|
12507
|
+
}
|
|
12508
|
+
var init_requester_timezone = __esm(() => {
|
|
12509
|
+
init_deferral_time();
|
|
12510
|
+
init_db4();
|
|
12511
|
+
});
|
|
12512
|
+
|
|
12495
12513
|
// src/slack/task-output.ts
|
|
12496
|
-
function slackTaskOutput(task) {
|
|
12514
|
+
async function slackTaskOutput(task, now = new Date) {
|
|
12497
12515
|
const output = task.output ?? undefined;
|
|
12498
12516
|
if (!output || task.status !== "completed" || task.outputSchema || !task.tags?.includes("deferred")) {
|
|
12499
12517
|
return output;
|
|
12500
12518
|
}
|
|
12501
|
-
if (LEGACY_DEFERRAL_NOTICE.test(output) || TIME_DEFERRAL_CARD.test(output)) {
|
|
12502
|
-
return "Checking back later";
|
|
12503
|
-
}
|
|
12504
12519
|
const waitingOn = output.match(EVENT_DEFERRAL_CARD)?.[1];
|
|
12505
|
-
|
|
12520
|
+
if (!waitingOn && !LEGACY_DEFERRAL_NOTICE.test(output) && !TIME_DEFERRAL_CARD.test(output)) {
|
|
12521
|
+
return output;
|
|
12522
|
+
}
|
|
12523
|
+
if (!task.deferredUntil)
|
|
12524
|
+
return waitingOn ? `Waiting on ${waitingOn}` : "Checking back later";
|
|
12525
|
+
const { tz, isFallback } = await resolveRequesterTimezone(task.requestedByUserId, process.env.SLACK_DEFAULT_TIMEZONE);
|
|
12526
|
+
const { date, time } = formatDeferralDateTime(new Date(task.deferredUntil), now, tz, isFallback);
|
|
12527
|
+
const resumes = date === "today" ? time : `${date} ${time}`;
|
|
12528
|
+
return waitingOn ? `Waiting on ${waitingOn} · resumes by ${resumes}` : `Checking back ${date === "today" ? "at " : ""}${resumes}`;
|
|
12506
12529
|
}
|
|
12507
12530
|
function isDeferredTask(task) {
|
|
12508
12531
|
if (task.status !== "completed")
|
|
@@ -12521,6 +12544,8 @@ function isAwaitingWake(task, threadTasks) {
|
|
|
12521
12544
|
}
|
|
12522
12545
|
var LEGACY_DEFERRAL_NOTICE, WHEN, TIME_DEFERRAL_CARD, EVENT_DEFERRAL_CARD;
|
|
12523
12546
|
var init_task_output = __esm(() => {
|
|
12547
|
+
init_requester_timezone();
|
|
12548
|
+
init_deferral_time();
|
|
12524
12549
|
LEGACY_DEFERRAL_NOTICE = /^Deferred until [^\n(]+? \([^\n]*?\) -> .*$/;
|
|
12525
12550
|
WHEN = String.raw`(?:today|tomorrow|on \S+) at [^\n]+?`;
|
|
12526
12551
|
TIME_DEFERRAL_CARD = new RegExp(`^Checking back ${WHEN}$`);
|
|
@@ -12668,6 +12693,111 @@ var init_ack = __esm(() => {
|
|
|
12668
12693
|
ACCEPTANCE_EVENTS = ["accepted", "buffered", "now", "steered"];
|
|
12669
12694
|
});
|
|
12670
12695
|
|
|
12696
|
+
// src/utils/task-ui-spec.ts
|
|
12697
|
+
var UI_SPEC_MAX_BYTES = 32768, UI_SPEC_MAX_BLOCKS = 45, UI_SPEC_MAX_ACTIONS_ROW_ELEMENTS = 25, UI_SPEC_MAX_ACTIONS = 25, UI_SPEC_ACTION_PREFIX = "swarm_ui:", TASK_UI_SPEC_UPDATED_EVENT = "task.ui_spec_updated", UI_SPEC_ACTION_ID, UI_SPEC_CARD_LIMITS, UI_SPEC_SCRIPT_ARGS_MAX_BYTES = 4096;
|
|
12698
|
+
var init_task_ui_spec = __esm(() => {
|
|
12699
|
+
UI_SPEC_ACTION_ID = /^[a-z][a-z0-9_]{0,39}$/;
|
|
12700
|
+
UI_SPEC_CARD_LIMITS = {
|
|
12701
|
+
tables: 1,
|
|
12702
|
+
charts: 2,
|
|
12703
|
+
chartLabel: 20,
|
|
12704
|
+
chartTitle: 50,
|
|
12705
|
+
tableRows: 100,
|
|
12706
|
+
tableColumns: 20
|
|
12707
|
+
};
|
|
12708
|
+
});
|
|
12709
|
+
|
|
12710
|
+
// src/workflows/approval-inline.ts
|
|
12711
|
+
function inlineApprovalQuestion(questions) {
|
|
12712
|
+
if (!questions || questions.length !== 1)
|
|
12713
|
+
return null;
|
|
12714
|
+
const [q] = questions;
|
|
12715
|
+
if (!q?.id)
|
|
12716
|
+
return null;
|
|
12717
|
+
const base = { id: q.id, label: q.label ?? "", options: q.options ?? [] };
|
|
12718
|
+
switch (q.type) {
|
|
12719
|
+
case "approval":
|
|
12720
|
+
case "boolean":
|
|
12721
|
+
return { ...base, type: q.type };
|
|
12722
|
+
case "single-select":
|
|
12723
|
+
return base.options.length > 0 && base.options.length <= INLINE_MAX_OPTIONS ? { ...base, type: q.type } : null;
|
|
12724
|
+
case "text":
|
|
12725
|
+
return q.multiline ? null : { ...base, type: q.type };
|
|
12726
|
+
default:
|
|
12727
|
+
return null;
|
|
12728
|
+
}
|
|
12729
|
+
}
|
|
12730
|
+
function inlineApprovalChoices(question) {
|
|
12731
|
+
switch (question.type) {
|
|
12732
|
+
case "approval":
|
|
12733
|
+
return [
|
|
12734
|
+
{ label: "Approve", choice: "y", style: "primary" },
|
|
12735
|
+
{ label: "Deny", choice: "n", style: "danger", needsText: "optional" }
|
|
12736
|
+
];
|
|
12737
|
+
case "boolean":
|
|
12738
|
+
return [
|
|
12739
|
+
{ label: "Yes", choice: "y" },
|
|
12740
|
+
{ label: "No", choice: "n" }
|
|
12741
|
+
];
|
|
12742
|
+
case "single-select":
|
|
12743
|
+
return question.options.map((option, index) => ({
|
|
12744
|
+
label: option.label || option.value,
|
|
12745
|
+
choice: String(index)
|
|
12746
|
+
}));
|
|
12747
|
+
case "text":
|
|
12748
|
+
return [{ label: "Answer", choice: "t", needsText: "required" }];
|
|
12749
|
+
}
|
|
12750
|
+
}
|
|
12751
|
+
function inlineApprovalResponses(question, choice, text) {
|
|
12752
|
+
const trimmed = (text ?? "").trim().slice(0, INLINE_TEXT_MAX_LENGTH);
|
|
12753
|
+
let answer;
|
|
12754
|
+
switch (question.type) {
|
|
12755
|
+
case "approval":
|
|
12756
|
+
if (choice === "y")
|
|
12757
|
+
answer = { approved: true };
|
|
12758
|
+
else if (choice === "n")
|
|
12759
|
+
answer = trimmed ? { approved: false, comment: trimmed } : { approved: false };
|
|
12760
|
+
break;
|
|
12761
|
+
case "boolean":
|
|
12762
|
+
if (choice === "y" || choice === "n")
|
|
12763
|
+
answer = choice === "y";
|
|
12764
|
+
break;
|
|
12765
|
+
case "single-select": {
|
|
12766
|
+
const option = /^\d+$/.test(choice) ? question.options[Number(choice)] : undefined;
|
|
12767
|
+
answer = option?.value;
|
|
12768
|
+
break;
|
|
12769
|
+
}
|
|
12770
|
+
case "text":
|
|
12771
|
+
if (choice === "t" && trimmed)
|
|
12772
|
+
answer = trimmed;
|
|
12773
|
+
break;
|
|
12774
|
+
}
|
|
12775
|
+
return answer === undefined ? null : { [question.id]: answer };
|
|
12776
|
+
}
|
|
12777
|
+
var INLINE_MAX_OPTIONS = 5, INLINE_TEXT_MAX_LENGTH = 500;
|
|
12778
|
+
var init_approval_inline = () => {};
|
|
12779
|
+
|
|
12780
|
+
// src/slack/approval-buttons.ts
|
|
12781
|
+
function buttonText(label) {
|
|
12782
|
+
return label.length > 75 ? `${label.slice(0, 74)}…` : label;
|
|
12783
|
+
}
|
|
12784
|
+
function buildApprovalAnswerButtons(requestId, questions) {
|
|
12785
|
+
const question = inlineApprovalQuestion(questions);
|
|
12786
|
+
if (!question)
|
|
12787
|
+
return [];
|
|
12788
|
+
return inlineApprovalChoices(question).map((choice) => ({
|
|
12789
|
+
type: "button",
|
|
12790
|
+
action_id: `${APPROVAL_ACTION_PREFIX}${choice.choice}`,
|
|
12791
|
+
text: { type: "plain_text", text: buttonText(choice.label) },
|
|
12792
|
+
value: requestId,
|
|
12793
|
+
...choice.style ? { style: choice.style } : {}
|
|
12794
|
+
}));
|
|
12795
|
+
}
|
|
12796
|
+
var APPROVAL_ACTION_PREFIX = "hitl_answer:";
|
|
12797
|
+
var init_approval_buttons = __esm(() => {
|
|
12798
|
+
init_approval_inline();
|
|
12799
|
+
});
|
|
12800
|
+
|
|
12671
12801
|
// src/slack/blocks.ts
|
|
12672
12802
|
function getTaskLink(taskId) {
|
|
12673
12803
|
const shortId = taskId.slice(0, 8);
|
|
@@ -12719,6 +12849,27 @@ function splitSlackSectionText(text) {
|
|
|
12719
12849
|
}
|
|
12720
12850
|
return chunks;
|
|
12721
12851
|
}
|
|
12852
|
+
function findReservedActionId(value) {
|
|
12853
|
+
if (Array.isArray(value)) {
|
|
12854
|
+
for (const item of value) {
|
|
12855
|
+
const found = findReservedActionId(item);
|
|
12856
|
+
if (found)
|
|
12857
|
+
return found;
|
|
12858
|
+
}
|
|
12859
|
+
return;
|
|
12860
|
+
}
|
|
12861
|
+
if (!value || typeof value !== "object")
|
|
12862
|
+
return;
|
|
12863
|
+
for (const [key, child] of Object.entries(value)) {
|
|
12864
|
+
if (key === "action_id" && typeof child === "string" && (RESERVED_ACTION_IDS.has(child) || RESERVED_ACTION_PREFIXES.some((prefix) => child.startsWith(prefix)))) {
|
|
12865
|
+
return child;
|
|
12866
|
+
}
|
|
12867
|
+
const found = findReservedActionId(child);
|
|
12868
|
+
if (found)
|
|
12869
|
+
return found;
|
|
12870
|
+
}
|
|
12871
|
+
return;
|
|
12872
|
+
}
|
|
12722
12873
|
function buildMrkdwnSectionBlocks(text) {
|
|
12723
12874
|
if (text.length <= SLACK_SECTION_TEXT_LIMIT)
|
|
12724
12875
|
return [sectionBlock(text)];
|
|
@@ -13002,11 +13153,15 @@ function buildTreeBlocks(roots) {
|
|
|
13002
13153
|
}
|
|
13003
13154
|
return blocks;
|
|
13004
13155
|
}
|
|
13005
|
-
var MAX_SECTION_LENGTH = 2900, MAX_BLOCKS_PER_COMPLETION_MESSAGE = 45, SLACK_SECTION_TEXT_LIMIT = 3000, MAX_CONTEXT_ELEMENTS = 10, MAX_CONTEXT_TEXT_LENGTH = 3000, SLACK_ATTACHMENTS_MAX = 20, STATUS_ICON, MAX_VISIBLE_CHILDREN = 8, MAX_OUTPUT_LENGTH = 120, SLACK_TREE_ATTACHMENT_BLOCKS_MAX = 10;
|
|
13156
|
+
var MAX_SECTION_LENGTH = 2900, MAX_BLOCKS_PER_COMPLETION_MESSAGE = 45, RESERVED_ACTION_IDS, RESERVED_ACTION_PREFIXES, SLACK_SECTION_TEXT_LIMIT = 3000, MAX_CONTEXT_ELEMENTS = 10, MAX_CONTEXT_TEXT_LENGTH = 3000, SLACK_ATTACHMENTS_MAX = 20, STATUS_ICON, MAX_VISIBLE_CHILDREN = 8, MAX_OUTPUT_LENGTH = 120, SLACK_TREE_ATTACHMENT_BLOCKS_MAX = 10;
|
|
13006
13157
|
var init_blocks = __esm(() => {
|
|
13007
13158
|
init_constants3();
|
|
13008
13159
|
init_task_attachment_links();
|
|
13160
|
+
init_task_ui_spec();
|
|
13161
|
+
init_approval_buttons();
|
|
13009
13162
|
init_reaction_shortcode();
|
|
13163
|
+
RESERVED_ACTION_IDS = new Set(["cancel_task", "follow_up_task", "view_task_logs"]);
|
|
13164
|
+
RESERVED_ACTION_PREFIXES = [APPROVAL_ACTION_PREFIX, UI_SPEC_ACTION_PREFIX];
|
|
13010
13165
|
STATUS_ICON = {
|
|
13011
13166
|
draft: "\uD83D\uDCCE",
|
|
13012
13167
|
backlog: "\uD83D\uDDC2️",
|
|
@@ -13024,6 +13179,81 @@ var init_blocks = __esm(() => {
|
|
|
13024
13179
|
};
|
|
13025
13180
|
});
|
|
13026
13181
|
|
|
13182
|
+
// src/be/db/slack-card-groups.ts
|
|
13183
|
+
function isMergedSlackMessageTs(ts) {
|
|
13184
|
+
return ts.startsWith(MERGED_SLACK_MESSAGE_TS_PREFIX);
|
|
13185
|
+
}
|
|
13186
|
+
async function mergedTaskIds(hostId) {
|
|
13187
|
+
const rows = await getDbClient2().query(`SELECT task_id, created_at FROM slack_messages
|
|
13188
|
+
WHERE merged_into_id = ? AND kind = 'outcome' AND task_id IS NOT NULL
|
|
13189
|
+
ORDER BY created_at ASC, id ASC`, [hostId]);
|
|
13190
|
+
return rows.map((row) => ({ taskId: row.task_id, createdAt: row.created_at }));
|
|
13191
|
+
}
|
|
13192
|
+
async function toHost(row) {
|
|
13193
|
+
const merged = await mergedTaskIds(row.id);
|
|
13194
|
+
const newestMerge = merged.at(-1)?.createdAt;
|
|
13195
|
+
return {
|
|
13196
|
+
id: row.id,
|
|
13197
|
+
ts: row.ts,
|
|
13198
|
+
taskId: row.task_id,
|
|
13199
|
+
contextKey: row.context_key,
|
|
13200
|
+
permalink: row.permalink,
|
|
13201
|
+
conclusionKind: row.conclusion_kind,
|
|
13202
|
+
lastSectionAt: newestMerge && newestMerge > row.finalized_at ? newestMerge : row.finalized_at,
|
|
13203
|
+
mergedTaskIds: merged.map((entry) => entry.taskId)
|
|
13204
|
+
};
|
|
13205
|
+
}
|
|
13206
|
+
async function getLatestSlackOutcomeGroupHost(channelId, threadTs) {
|
|
13207
|
+
const row = await getDbClient2().get(`SELECT ${HOST_COLUMNS} FROM slack_messages
|
|
13208
|
+
WHERE channel_id = ? AND thread_ts = ? AND ${DELIVERED_HOST_SQL}
|
|
13209
|
+
ORDER BY finalized_at DESC, created_at DESC
|
|
13210
|
+
LIMIT 1`, [channelId, threadTs]);
|
|
13211
|
+
return row ? await toHost(row) : null;
|
|
13212
|
+
}
|
|
13213
|
+
async function getSlackOutcomeGroupOf(messageId) {
|
|
13214
|
+
const own = await getDbClient2().get(`SELECT merged_into_id FROM slack_messages WHERE id = ?`, [messageId]);
|
|
13215
|
+
if (!own)
|
|
13216
|
+
return null;
|
|
13217
|
+
const hostId = own.merged_into_id ?? messageId;
|
|
13218
|
+
const row = await getDbClient2().get(`SELECT ${HOST_COLUMNS} FROM slack_messages WHERE id = ? AND ${DELIVERED_HOST_SQL}`, [hostId]);
|
|
13219
|
+
if (!row)
|
|
13220
|
+
return null;
|
|
13221
|
+
const host = await toHost(row);
|
|
13222
|
+
return host.mergedTaskIds.length > 0 ? host : null;
|
|
13223
|
+
}
|
|
13224
|
+
async function recordMergedSlackOutcome(input) {
|
|
13225
|
+
const id = crypto.randomUUID();
|
|
13226
|
+
const now = new Date().toISOString();
|
|
13227
|
+
const row = await getDbClient2().get(`INSERT INTO slack_messages (
|
|
13228
|
+
id, context_key, channel_id, thread_ts, ts, kind, task_id, permalink,
|
|
13229
|
+
finalized_at, merged_into_id, created_at, updated_at, created_by, updated_by
|
|
13230
|
+
) VALUES (?, ?, ?, ?, ?, 'outcome', ?, ?, ?, ?, ?, ?, ?, ?)
|
|
13231
|
+
ON CONFLICT DO NOTHING
|
|
13232
|
+
RETURNING id`, [
|
|
13233
|
+
id,
|
|
13234
|
+
input.host.contextKey,
|
|
13235
|
+
input.channelId,
|
|
13236
|
+
input.threadTs,
|
|
13237
|
+
`${MERGED_SLACK_MESSAGE_TS_PREFIX}${id}`,
|
|
13238
|
+
input.taskId,
|
|
13239
|
+
input.host.permalink,
|
|
13240
|
+
now,
|
|
13241
|
+
input.host.id,
|
|
13242
|
+
now,
|
|
13243
|
+
now,
|
|
13244
|
+
input.actorId ?? null,
|
|
13245
|
+
input.actorId ?? null
|
|
13246
|
+
]);
|
|
13247
|
+
return !!row;
|
|
13248
|
+
}
|
|
13249
|
+
var MERGED_SLACK_MESSAGE_TS_PREFIX = "merged:", HOST_COLUMNS = `id, ts, task_id, context_key, permalink, conclusion_kind, finalized_at`, DELIVERED_HOST_SQL;
|
|
13250
|
+
var init_slack_card_groups = __esm(() => {
|
|
13251
|
+
init_db4();
|
|
13252
|
+
DELIVERED_HOST_SQL = `kind = 'outcome' AND task_id IS NOT NULL AND merged_into_id IS NULL
|
|
13253
|
+
AND finalized_at IS NOT NULL AND delivery_abandoned_at IS NULL
|
|
13254
|
+
AND ts NOT LIKE 'pending:%' AND ts NOT LIKE '${MERGED_SLACK_MESSAGE_TS_PREFIX}%'`;
|
|
13255
|
+
});
|
|
13256
|
+
|
|
13027
13257
|
// src/utils/task-citations.ts
|
|
13028
13258
|
function citedIndices(text) {
|
|
13029
13259
|
return new Set([...text.matchAll(CITATION_MARKER)].map((match) => Number(match[1])));
|
|
@@ -13387,7 +13617,7 @@ async function hasTaskUiSpecCheckRefusal(taskId) {
|
|
|
13387
13617
|
return Boolean(await getDbClient2().get("SELECT id FROM agent_log WHERE taskId = ? AND eventType = 'task_ui_spec_check_refused' LIMIT 1", [taskId]));
|
|
13388
13618
|
}
|
|
13389
13619
|
var TaskUiSpecSchema, TASK_ID_CHUNK2 = 500;
|
|
13390
|
-
var
|
|
13620
|
+
var init_task_ui_spec2 = __esm(() => {
|
|
13391
13621
|
init_zod();
|
|
13392
13622
|
init_secret_scrubber();
|
|
13393
13623
|
init_db4();
|
|
@@ -15307,20 +15537,6 @@ var init_dist5 = __esm(() => {
|
|
|
15307
15537
|
GROUPS = /* @__PURE__ */ new Set(["Fields", "Actions", "Section"]);
|
|
15308
15538
|
});
|
|
15309
15539
|
|
|
15310
|
-
// src/utils/task-ui-spec.ts
|
|
15311
|
-
var UI_SPEC_MAX_BYTES = 32768, UI_SPEC_MAX_BLOCKS = 45, UI_SPEC_MAX_ACTIONS_ROW_ELEMENTS = 25, UI_SPEC_MAX_ACTIONS = 25, UI_SPEC_ACTION_PREFIX = "swarm_ui:", TASK_UI_SPEC_UPDATED_EVENT = "task.ui_spec_updated", UI_SPEC_ACTION_ID, UI_SPEC_CARD_LIMITS, UI_SPEC_SCRIPT_ARGS_MAX_BYTES = 4096;
|
|
15312
|
-
var init_task_ui_spec2 = __esm(() => {
|
|
15313
|
-
UI_SPEC_ACTION_ID = /^[a-z][a-z0-9_]{0,39}$/;
|
|
15314
|
-
UI_SPEC_CARD_LIMITS = {
|
|
15315
|
-
tables: 1,
|
|
15316
|
-
charts: 2,
|
|
15317
|
-
chartLabel: 20,
|
|
15318
|
-
chartTitle: 50,
|
|
15319
|
-
tableRows: 100,
|
|
15320
|
-
tableColumns: 20
|
|
15321
|
-
};
|
|
15322
|
-
});
|
|
15323
|
-
|
|
15324
15540
|
// src/ui-spec/validate.ts
|
|
15325
15541
|
function asElement(value) {
|
|
15326
15542
|
return value !== null && typeof value === "object" ? value : null;
|
|
@@ -15418,7 +15634,7 @@ var URL_PROPS;
|
|
|
15418
15634
|
var init_validate2 = __esm(() => {
|
|
15419
15635
|
init_dist6();
|
|
15420
15636
|
init_dist5();
|
|
15421
|
-
|
|
15637
|
+
init_task_ui_spec();
|
|
15422
15638
|
URL_PROPS = {
|
|
15423
15639
|
LinkButton: "url",
|
|
15424
15640
|
Image: "url",
|
|
@@ -15942,7 +16158,7 @@ async function withUiSpecFallback(taskId, body) {
|
|
|
15942
16158
|
${fallbackText}` : fallbackText;
|
|
15943
16159
|
}
|
|
15944
16160
|
var init_fallback = __esm(() => {
|
|
15945
|
-
|
|
16161
|
+
init_task_ui_spec2();
|
|
15946
16162
|
init_env_flag();
|
|
15947
16163
|
init_secret_scrubber();
|
|
15948
16164
|
});
|
|
@@ -15966,14 +16182,14 @@ function classifySlackUpdateError(error) {
|
|
|
15966
16182
|
function getAgentDisplayName(agent) {
|
|
15967
16183
|
return isDev ? `(dev) ${agent.name}` : agent.name;
|
|
15968
16184
|
}
|
|
15969
|
-
function shouldPostInlineCompletionOutput(task) {
|
|
16185
|
+
async function shouldPostInlineCompletionOutput(task) {
|
|
15970
16186
|
if (task.status !== "completed")
|
|
15971
16187
|
return false;
|
|
15972
16188
|
if (!task.slackChannelId || !task.slackThreadTs)
|
|
15973
16189
|
return false;
|
|
15974
16190
|
if (task.slackReplySent)
|
|
15975
16191
|
return false;
|
|
15976
|
-
const output = slackTaskOutput(task)?.trim();
|
|
16192
|
+
const output = (await slackTaskOutput(task))?.trim();
|
|
15977
16193
|
return !!output && isTreeOutputTruncated(markdownToSlack(output));
|
|
15978
16194
|
}
|
|
15979
16195
|
function formatInlineCompletionOutputChunks(opts) {
|
|
@@ -15996,7 +16212,7 @@ async function sendInlineTaskOutput(task) {
|
|
|
15996
16212
|
const chunks = formatInlineCompletionOutputChunks({
|
|
15997
16213
|
agentName: agent.name,
|
|
15998
16214
|
taskId: task.id,
|
|
15999
|
-
output: await withUiSpecFallback(task.id, slackTaskOutput(task) ?? "")
|
|
16215
|
+
output: await withUiSpecFallback(task.id, await slackTaskOutput(task) ?? "")
|
|
16000
16216
|
});
|
|
16001
16217
|
try {
|
|
16002
16218
|
for (let i = 0;i < chunks.length; i += MAX_INLINE_OUTPUT_BLOCKS_PER_MESSAGE) {
|
|
@@ -16022,6 +16238,47 @@ async function sendInlineTaskOutput(task) {
|
|
|
16022
16238
|
return false;
|
|
16023
16239
|
}
|
|
16024
16240
|
}
|
|
16241
|
+
async function sendTaskOutputAsReply(task) {
|
|
16242
|
+
const app = getSlackApp2();
|
|
16243
|
+
if (!app || !task.slackChannelId || !task.slackThreadTs || !task.agentId)
|
|
16244
|
+
return false;
|
|
16245
|
+
const agent = await getAgentById2(task.agentId);
|
|
16246
|
+
if (!agent) {
|
|
16247
|
+
console.error(`[Slack] Agent not found for task ${task.id}`);
|
|
16248
|
+
return false;
|
|
16249
|
+
}
|
|
16250
|
+
const output = await withUiSpecFallback(task.id, await slackTaskOutput(task) || "Task completed.");
|
|
16251
|
+
const body = markdownToSlack(output) + formatAttachmentsBlockForSlack(await getSlackOutputAttachments(task.id));
|
|
16252
|
+
const sections = splitSlackSectionText(body);
|
|
16253
|
+
const footer = {
|
|
16254
|
+
type: "context",
|
|
16255
|
+
elements: [{ type: "mrkdwn", text: `${agent.name} · ${getTaskLink(task.id)}` }]
|
|
16256
|
+
};
|
|
16257
|
+
try {
|
|
16258
|
+
for (let i = 0;i < sections.length; i += MAX_INLINE_OUTPUT_BLOCKS_PER_MESSAGE) {
|
|
16259
|
+
const batch = sections.slice(i, i + MAX_INLINE_OUTPUT_BLOCKS_PER_MESSAGE);
|
|
16260
|
+
const isLast = i + MAX_INLINE_OUTPUT_BLOCKS_PER_MESSAGE >= sections.length;
|
|
16261
|
+
await sendWithPersona(app.client, {
|
|
16262
|
+
channel: task.slackChannelId,
|
|
16263
|
+
thread_ts: task.slackThreadTs,
|
|
16264
|
+
text: batch.join(`
|
|
16265
|
+
|
|
16266
|
+
`),
|
|
16267
|
+
username: getAgentDisplayName(agent),
|
|
16268
|
+
icon: getAgentSlackIcon(agent),
|
|
16269
|
+
blocks: [
|
|
16270
|
+
...batch.map((chunk) => ({ type: "section", text: { type: "mrkdwn", text: chunk } })),
|
|
16271
|
+
...isLast ? [footer] : []
|
|
16272
|
+
]
|
|
16273
|
+
});
|
|
16274
|
+
}
|
|
16275
|
+
await markTaskSlackReplySent2(task.id);
|
|
16276
|
+
return true;
|
|
16277
|
+
} catch (error) {
|
|
16278
|
+
console.error(`[Slack] Failed to send reply for task ${task.id}:`, error);
|
|
16279
|
+
return false;
|
|
16280
|
+
}
|
|
16281
|
+
}
|
|
16025
16282
|
async function sendTaskResponse(task) {
|
|
16026
16283
|
const app = getSlackApp2();
|
|
16027
16284
|
if (!app || !task.slackChannelId || !task.slackThreadTs) {
|
|
@@ -16040,7 +16297,7 @@ async function sendTaskResponse(task) {
|
|
|
16040
16297
|
const agentName = agent.name;
|
|
16041
16298
|
try {
|
|
16042
16299
|
if (task.status === "completed") {
|
|
16043
|
-
const output = await withUiSpecFallback(task.id, slackTaskOutput(task) || "Task completed.");
|
|
16300
|
+
const output = await withUiSpecFallback(task.id, await slackTaskOutput(task) || "Task completed.");
|
|
16044
16301
|
const slackOutput = markdownToSlack(output);
|
|
16045
16302
|
const attachmentsBlock = formatAttachmentsBlockForSlack(await getSlackOutputAttachments(task.id));
|
|
16046
16303
|
const body = slackOutput + attachmentsBlock;
|
|
@@ -16159,7 +16416,7 @@ async function updateToFinal(task, messageTs) {
|
|
|
16159
16416
|
let text;
|
|
16160
16417
|
let completionBlockBatches;
|
|
16161
16418
|
if (task.status === "completed") {
|
|
16162
|
-
const output = slackTaskOutput(task) || "Task completed.";
|
|
16419
|
+
const output = await slackTaskOutput(task) || "Task completed.";
|
|
16163
16420
|
const slackOutput = markdownToSlack(output);
|
|
16164
16421
|
const attachmentsBlock = formatAttachmentsBlockForSlack(await getSlackOutputAttachments(task.id));
|
|
16165
16422
|
const body = slackOutput + attachmentsBlock;
|
|
@@ -17266,9 +17523,9 @@ async function outcomeContent(task, slackReplySent) {
|
|
|
17266
17523
|
return `${iconPrefix(completedStatusIcon())}${agentName} completed`;
|
|
17267
17524
|
}
|
|
17268
17525
|
if (isDeferred) {
|
|
17269
|
-
return withStatusLead("⏳", outcomeText(slackTaskOutput(task), "Deferred."));
|
|
17526
|
+
return withStatusLead("⏳", outcomeText(await slackTaskOutput(task), "Deferred."));
|
|
17270
17527
|
}
|
|
17271
|
-
return withStatusLead(completedStatusIcon(), outcomeText(slackTaskOutput(task), "Task completed."));
|
|
17528
|
+
return withStatusLead(completedStatusIcon(), outcomeText(await slackTaskOutput(task), "Task completed."));
|
|
17272
17529
|
}
|
|
17273
17530
|
async function agentDisplayNameFor(task) {
|
|
17274
17531
|
return task.agentId ? (await getAgentById2(task.agentId))?.name ?? "Agent" : "Agent";
|
|
@@ -17282,13 +17539,78 @@ async function childOutcomeContent(task, slackReplySent) {
|
|
|
17282
17539
|
return `↳ ${iconPrefix(completedStatusIcon())}${agentName} completed`;
|
|
17283
17540
|
}
|
|
17284
17541
|
if (isDeferredTask(task)) {
|
|
17285
|
-
return withStatusLead(`↳ ⏳ ${agentName} — deferred:`, outcomeText(slackTaskOutput(task), "Deferred."));
|
|
17542
|
+
return withStatusLead(`↳ ⏳ ${agentName} — deferred:`, outcomeText(await slackTaskOutput(task), "Deferred."));
|
|
17286
17543
|
}
|
|
17287
|
-
return withStatusLead(`↳ ${iconPrefix(completedStatusIcon())}${agentName} — result:`, outcomeText(slackTaskOutput(task), "Task completed."));
|
|
17544
|
+
return withStatusLead(`↳ ${iconPrefix(completedStatusIcon())}${agentName} — result:`, outcomeText(await slackTaskOutput(task), "Task completed."));
|
|
17288
17545
|
}
|
|
17289
17546
|
async function isSlackContinuation(task) {
|
|
17290
17547
|
return task.source === "schedule" && task.taskType === "deferred" && !!task.slackChannelId && !!task.slackThreadTs && !!task.agentId && !!(await getAgentById2(task.agentId))?.isLead;
|
|
17291
17548
|
}
|
|
17549
|
+
async function hasSlackAskAncestor(task, threadTasks) {
|
|
17550
|
+
const byId = new Map(threadTasks.map((candidate) => [candidate.id, candidate]));
|
|
17551
|
+
const seen = new Set([task.id]);
|
|
17552
|
+
let parentId = task.parentTaskId;
|
|
17553
|
+
while (parentId && !seen.has(parentId) && seen.size <= SLACK_ANCESTOR_WALK_LIMIT) {
|
|
17554
|
+
seen.add(parentId);
|
|
17555
|
+
const parent = byId.get(parentId) ?? await getTaskById2(parentId);
|
|
17556
|
+
if (!parent)
|
|
17557
|
+
return false;
|
|
17558
|
+
if (parent.source === "slack")
|
|
17559
|
+
return true;
|
|
17560
|
+
parentId = parent.parentTaskId;
|
|
17561
|
+
}
|
|
17562
|
+
return false;
|
|
17563
|
+
}
|
|
17564
|
+
async function classifyLeadFollowUp(task, threadTasks) {
|
|
17565
|
+
if (task.source !== "system" || !SLACK_LEAD_FOLLOW_UP_TYPES.has(task.taskType ?? "") || !task.slackChannelId || !task.slackThreadTs || !task.agentId || !(await getAgentById2(task.agentId))?.isLead) {
|
|
17566
|
+
return "none";
|
|
17567
|
+
}
|
|
17568
|
+
return await hasSlackAskAncestor(task, threadTasks) ? "eligible" : "orphan";
|
|
17569
|
+
}
|
|
17570
|
+
async function settleLeadFollowUpWithoutCard(task, reason) {
|
|
17571
|
+
if (!task.slackChannelId || !task.slackThreadTs)
|
|
17572
|
+
return;
|
|
17573
|
+
const card = await getSlackOutcomeMessage2(task.id);
|
|
17574
|
+
if (card && !isPendingSlackMessage2(card))
|
|
17575
|
+
return;
|
|
17576
|
+
await reserveSlackMessage2({
|
|
17577
|
+
contextKey: task.contextKey ?? slackContextKey({ channelId: task.slackChannelId, threadTs: task.slackThreadTs }),
|
|
17578
|
+
channelId: task.slackChannelId,
|
|
17579
|
+
threadTs: task.slackThreadTs,
|
|
17580
|
+
kind: "outcome",
|
|
17581
|
+
taskId: task.id
|
|
17582
|
+
});
|
|
17583
|
+
await abandonSlackOutcomeDelivery2(task.id, reason);
|
|
17584
|
+
}
|
|
17585
|
+
async function mayPostLeadFollowUpCard(task, threadTasks, ownerAskId, delegationActivatedAt) {
|
|
17586
|
+
if (task.source !== "system" || !SLACK_LEAD_FOLLOW_UP_TYPES.has(task.taskType ?? "")) {
|
|
17587
|
+
return true;
|
|
17588
|
+
}
|
|
17589
|
+
if ((await getTaskById2(task.id))?.slackReplySent ?? task.slackReplySent) {
|
|
17590
|
+
if (await getSlackOutcomeMessage2(task.id)) {
|
|
17591
|
+
await settleLeadFollowUpWithoutCard(task, "slack_reply_sent: Lead follow-up not posted");
|
|
17592
|
+
}
|
|
17593
|
+
return false;
|
|
17594
|
+
}
|
|
17595
|
+
if (task.agentId && task.parentTaskId && task.slackChannelId && task.slackThreadTs && await slackThreadHasAgentReplyOnTasksSince(task.slackChannelId, task.slackThreadTs, task.createdAt, task.agentId, [task.parentTaskId])) {
|
|
17596
|
+
await settleLeadFollowUpWithoutCard(task, "agent_reply_in_thread: Lead follow-up not posted");
|
|
17597
|
+
return false;
|
|
17598
|
+
}
|
|
17599
|
+
const askId = ownerAskId.get(task.id);
|
|
17600
|
+
const ownerAsk = askId ? threadTasks.find((candidate) => candidate.id === askId) : undefined;
|
|
17601
|
+
if (delegationActivatedAt !== null && ownerAsk && ownerAsk.createdAt >= delegationActivatedAt && isChildCardCandidate(task, delegationActivatedAt)) {
|
|
17602
|
+
return false;
|
|
17603
|
+
}
|
|
17604
|
+
const app = getSlackApp2();
|
|
17605
|
+
if (!app || !task.slackChannelId || !task.slackThreadTs)
|
|
17606
|
+
return false;
|
|
17607
|
+
const blockReason = await getChannelBlockReason2(app.client, task.slackChannelId);
|
|
17608
|
+
if (blockReason === "external") {
|
|
17609
|
+
await settleLeadFollowUpWithoutCard(task, "external_channel: Lead follow-up not posted");
|
|
17610
|
+
return false;
|
|
17611
|
+
}
|
|
17612
|
+
return blockReason === null;
|
|
17613
|
+
}
|
|
17292
17614
|
function isChildCardCandidate(task, delegationActivatedAt) {
|
|
17293
17615
|
return task.source !== "slack" && !(task.source === "schedule" && task.taskType === "deferred") && !!task.slackChannelId && !!task.slackThreadTs && (task.status === "completed" || task.status === "failed") && task.taskType !== "follow-up" && task.taskType !== "reroute-decision" && task.createdAt >= delegationActivatedAt;
|
|
17294
17616
|
}
|
|
@@ -17304,8 +17626,14 @@ async function slackDelegationOwnsChildCard2(task) {
|
|
|
17304
17626
|
const ownerAsk = tasks.find((ask) => ask.source === "slack" && buildAskClosure(ask, tasks).some((member) => member.id === task.id));
|
|
17305
17627
|
return !!ownerAsk && ownerAsk.createdAt >= delegationActivatedAt;
|
|
17306
17628
|
}
|
|
17307
|
-
async function taskNeedsDirectOutcome(task, activatedAt) {
|
|
17308
|
-
|
|
17629
|
+
async function taskNeedsDirectOutcome(task, activatedAt, leadFollowUp) {
|
|
17630
|
+
if (task.createdAt < activatedAt)
|
|
17631
|
+
return false;
|
|
17632
|
+
if (task.source === "slack")
|
|
17633
|
+
return isAskOutcomeStatus(task.status);
|
|
17634
|
+
if (!isOutcomeStatus(task.status))
|
|
17635
|
+
return false;
|
|
17636
|
+
return leadFollowUp === "eligible" || await isSlackContinuation(task);
|
|
17309
17637
|
}
|
|
17310
17638
|
async function conclusionResultsLines(closure) {
|
|
17311
17639
|
const lines = [];
|
|
@@ -17321,7 +17649,7 @@ async function conclusionResultsLines(closure) {
|
|
|
17321
17649
|
lines.push(`↳ ${iconPrefix(glyph)}${agentName} — [result](${card.permalink})`);
|
|
17322
17650
|
continue;
|
|
17323
17651
|
}
|
|
17324
|
-
const raw = outcomeText(member.status === "failed" ? member.failureReason : slackTaskOutput(member), "");
|
|
17652
|
+
const raw = outcomeText(member.status === "failed" ? member.failureReason : await slackTaskOutput(member), "");
|
|
17325
17653
|
const digest = raw.length > CONCLUSION_DIGEST_LENGTH ? `${raw.slice(0, CONCLUSION_DIGEST_LENGTH).trimEnd()}…` : raw;
|
|
17326
17654
|
const citedDigest = renderTaskCitations(digest, await getTaskCitations(member.id), "slack", false);
|
|
17327
17655
|
const label = digest ? `${agentName} — ${citedDigest}` : agentName;
|
|
@@ -17500,8 +17828,14 @@ async function slackTeamId(client) {
|
|
|
17500
17828
|
cachedTeamId = teamId;
|
|
17501
17829
|
return cachedTeamId;
|
|
17502
17830
|
}
|
|
17503
|
-
async function outcomeFooter(
|
|
17504
|
-
const
|
|
17831
|
+
async function outcomeFooter(members, tasks, duration) {
|
|
17832
|
+
const task = members[0];
|
|
17833
|
+
if (!task)
|
|
17834
|
+
return [];
|
|
17835
|
+
const memberIds = new Set(members.map((member) => member.id));
|
|
17836
|
+
const descendants = [
|
|
17837
|
+
...new Map(members.flatMap((member) => buildAskClosure(member, tasks)).filter((candidate) => !memberIds.has(candidate.id)).map((candidate) => [candidate.id, candidate])).values()
|
|
17838
|
+
];
|
|
17505
17839
|
const candidateAgentIds = [
|
|
17506
17840
|
...new Set(descendants.map((candidate) => candidate.agentId).filter((id) => !!id))
|
|
17507
17841
|
];
|
|
@@ -17509,7 +17843,8 @@ async function outcomeFooter(task, tasks, duration) {
|
|
|
17509
17843
|
const nonLeadAgentIds = new Set(candidateAgentIds.filter((_, index) => !candidateAgents[index]?.isLead));
|
|
17510
17844
|
const workerIds = new Set(descendants.map((candidate) => candidate.agentId).filter((agentId) => !!agentId && nonLeadAgentIds.has(agentId)));
|
|
17511
17845
|
const who = workerIds.size > 0 ? `${workerIds.size} worker${workerIds.size === 1 ? "" : "s"}` : task.agentId ? (await getAgentById2(task.agentId))?.name : undefined;
|
|
17512
|
-
const
|
|
17846
|
+
const links = members.map((member) => getTaskLink(member.id)).join(", ");
|
|
17847
|
+
const parts = [duration, who, links].filter(Boolean);
|
|
17513
17848
|
if (parts.length === 0)
|
|
17514
17849
|
return [];
|
|
17515
17850
|
return [{ type: "context", elements: [{ type: "mrkdwn", text: parts.join(" · ") }] }];
|
|
@@ -17531,7 +17866,7 @@ async function streamOutcomeCard(task, options) {
|
|
|
17531
17866
|
throw new Error(`Outcome presentation is empty for task ${task.id}`);
|
|
17532
17867
|
const captions = [
|
|
17533
17868
|
...await outcomeCaptionBlocks(task, content),
|
|
17534
|
-
...await outcomeFooter(task, tasks, duration)
|
|
17869
|
+
...await outcomeFooter([task], tasks, duration)
|
|
17535
17870
|
];
|
|
17536
17871
|
const uiSpec = await outcomeUiSpec(task);
|
|
17537
17872
|
const blocksFor = (withCard) => withCard && uiSpec ? [...uiSpec.blocks, ...captions] : captions;
|
|
@@ -17653,6 +17988,12 @@ async function refreshSlackOutcomeCard(taskId) {
|
|
|
17653
17988
|
if (!card?.ts || !card.finalizedAt || !isSettledSlackMessage2(card))
|
|
17654
17989
|
return false;
|
|
17655
17990
|
const tasks = await getSlackTasksInThread2(task.slackChannelId, task.slackThreadTs);
|
|
17991
|
+
const group = await getSlackOutcomeGroupOf(card.id);
|
|
17992
|
+
if (group) {
|
|
17993
|
+
return await updateOutcomeGroupCard(app.client, task.slackChannelId, group, await outcomeGroupMembers(group, tasks), tasks);
|
|
17994
|
+
}
|
|
17995
|
+
if (isMergedSlackMessageTs(card.ts))
|
|
17996
|
+
return false;
|
|
17656
17997
|
const duration = formatV2Duration(new Date(task.createdAt), terminalEnd(task, new Date));
|
|
17657
17998
|
const content = await outcomeContent(task, task.slackReplySent);
|
|
17658
17999
|
const presentation = await outcomePresentation(task, content);
|
|
@@ -17660,7 +18001,7 @@ async function refreshSlackOutcomeCard(taskId) {
|
|
|
17660
18001
|
return false;
|
|
17661
18002
|
const captions = [
|
|
17662
18003
|
...await outcomeCaptionBlocks(task, content),
|
|
17663
|
-
...await outcomeFooter(task, tasks, duration)
|
|
18004
|
+
...await outcomeFooter([task], tasks, duration)
|
|
17664
18005
|
];
|
|
17665
18006
|
const uiSpec = await outcomeUiSpec(task);
|
|
17666
18007
|
await withUiSpecBlockFallback(uiSpec, task.id, (withCard) => {
|
|
@@ -17675,6 +18016,110 @@ async function refreshSlackOutcomeCard(taskId) {
|
|
|
17675
18016
|
});
|
|
17676
18017
|
return true;
|
|
17677
18018
|
}
|
|
18019
|
+
function isSlackTsAfter(a, b) {
|
|
18020
|
+
const key = (ts) => {
|
|
18021
|
+
const [seconds = "", micros = ""] = ts.split(".");
|
|
18022
|
+
return `${seconds.padStart(12, "0")}.${micros.padEnd(6, "0")}`;
|
|
18023
|
+
};
|
|
18024
|
+
return key(a) > key(b);
|
|
18025
|
+
}
|
|
18026
|
+
async function slackThreadHasMessageAfter(client, channelId, threadTs, ts) {
|
|
18027
|
+
const response = await callSlackWithRetry2(client, "conversations.replies", {
|
|
18028
|
+
channel: channelId,
|
|
18029
|
+
ts: threadTs,
|
|
18030
|
+
oldest: ts,
|
|
18031
|
+
inclusive: false,
|
|
18032
|
+
limit: 20
|
|
18033
|
+
});
|
|
18034
|
+
const messages = Array.isArray(response.messages) ? response.messages : [];
|
|
18035
|
+
return messages.some((message) => !!message.ts && isSlackTsAfter(message.ts, ts));
|
|
18036
|
+
}
|
|
18037
|
+
async function outcomeGroupMembers(group, tasks) {
|
|
18038
|
+
const ids = [group.taskId, ...group.mergedTaskIds];
|
|
18039
|
+
const members = await Promise.all(ids.map(async (id) => tasks.find((task) => task.id === id) ?? await getTaskById2(id)));
|
|
18040
|
+
return members.filter((member) => !!member);
|
|
18041
|
+
}
|
|
18042
|
+
async function renderOutcomeGroup(members, tasks) {
|
|
18043
|
+
const sections = [];
|
|
18044
|
+
const captions = [];
|
|
18045
|
+
for (const member of members) {
|
|
18046
|
+
const slackReplySent = (await getTaskById2(member.id))?.slackReplySent ?? member.slackReplySent;
|
|
18047
|
+
const content = await outcomeContent(member, slackReplySent);
|
|
18048
|
+
const presentation = await outcomePresentation(member, content);
|
|
18049
|
+
if (!presentation)
|
|
18050
|
+
continue;
|
|
18051
|
+
sections.push(withUiSpecFallbackText(presentation, await outcomeUiSpec(member), false));
|
|
18052
|
+
captions.push(...await outcomeCaptionBlocks(member, content));
|
|
18053
|
+
}
|
|
18054
|
+
const text = sections.join(`
|
|
18055
|
+
|
|
18056
|
+
`);
|
|
18057
|
+
if (!text || text.length > MAX_OUTCOME_MARKDOWN_LENGTH)
|
|
18058
|
+
return null;
|
|
18059
|
+
const now = new Date;
|
|
18060
|
+
const start = Math.min(...members.map((member) => Date.parse(member.createdAt)));
|
|
18061
|
+
const end = Math.max(...members.map((member) => terminalEnd(member, now).getTime()));
|
|
18062
|
+
const footer = await outcomeFooter(members, tasks, formatV2Duration(new Date(start), new Date(end)));
|
|
18063
|
+
return { text, blocks: [{ type: "markdown", text }, ...captions, ...footer] };
|
|
18064
|
+
}
|
|
18065
|
+
async function updateOutcomeGroupCard(client, channelId, group, members, tasks) {
|
|
18066
|
+
const rendered = await renderOutcomeGroup(members, tasks);
|
|
18067
|
+
if (!rendered)
|
|
18068
|
+
return false;
|
|
18069
|
+
await callSlackWithRetry2(client, "chat.update", {
|
|
18070
|
+
channel: channelId,
|
|
18071
|
+
ts: group.ts,
|
|
18072
|
+
text: rendered.text,
|
|
18073
|
+
blocks: rendered.blocks
|
|
18074
|
+
});
|
|
18075
|
+
return true;
|
|
18076
|
+
}
|
|
18077
|
+
async function mergeLeadFollowUpCard(task, tasks, statusBudget) {
|
|
18078
|
+
if (task.source !== "system" || !SLACK_LEAD_FOLLOW_UP_TYPES.has(task.taskType ?? "")) {
|
|
18079
|
+
return false;
|
|
18080
|
+
}
|
|
18081
|
+
if (task.status !== "completed" || isDeferredTask(task))
|
|
18082
|
+
return false;
|
|
18083
|
+
const app = getSlackApp2();
|
|
18084
|
+
const { agentId, slackChannelId: channelId, slackThreadTs: threadTs } = task;
|
|
18085
|
+
if (!app || !agentId || !channelId || !threadTs)
|
|
18086
|
+
return false;
|
|
18087
|
+
let group;
|
|
18088
|
+
let members;
|
|
18089
|
+
try {
|
|
18090
|
+
const host = await getLatestSlackOutcomeGroupHost(channelId, threadTs);
|
|
18091
|
+
if (!host || host.conclusionKind)
|
|
18092
|
+
return false;
|
|
18093
|
+
if (host.mergedTaskIds.length + 2 > SLACK_CARD_GROUP_MAX_SECTIONS)
|
|
18094
|
+
return false;
|
|
18095
|
+
if (Date.now() - Date.parse(host.lastSectionAt) > SLACK_CARD_MERGE_WINDOW_MS)
|
|
18096
|
+
return false;
|
|
18097
|
+
const existing = await outcomeGroupMembers(host, tasks);
|
|
18098
|
+
const hostTask = existing[0];
|
|
18099
|
+
if (!hostTask || hostTask.id !== host.taskId || existing.length !== host.mergedTaskIds.length + 1 || hostTask.agentId !== agentId || hostTask.status !== "completed" || isDeferredTask(hostTask) || await slackDelegationOwnsChildCard2(hostTask) || await outcomeUiSpec(hostTask) || await outcomeUiSpec(task)) {
|
|
18100
|
+
return false;
|
|
18101
|
+
}
|
|
18102
|
+
if (await slackThreadHasMessageAfter(app.client, channelId, threadTs, host.ts))
|
|
18103
|
+
return false;
|
|
18104
|
+
group = host;
|
|
18105
|
+
members = [...existing, task];
|
|
18106
|
+
} catch (error) {
|
|
18107
|
+
console.error(`[Slack] Could not check a card merge for task ${task.id}; posting a new card:`, scrubSecrets(String(error)));
|
|
18108
|
+
return false;
|
|
18109
|
+
}
|
|
18110
|
+
try {
|
|
18111
|
+
if (!await updateOutcomeGroupCard(app.client, channelId, group, members, tasks)) {
|
|
18112
|
+
return false;
|
|
18113
|
+
}
|
|
18114
|
+
} catch (error) {
|
|
18115
|
+
console.error(`[Slack] Could not merge the card of task ${task.id}; posting a new card:`, scrubSecrets(String(error)));
|
|
18116
|
+
return false;
|
|
18117
|
+
}
|
|
18118
|
+
await recordMergedSlackOutcome({ host: group, channelId, threadTs, taskId: task.id });
|
|
18119
|
+
await clearAssistantStatus(app.client, channelId, threadTs, statusBudget);
|
|
18120
|
+
console.log(`[Slack] Merged the card of task ${task.id.slice(0, 8)} into the card of task ${group.taskId.slice(0, 8)}`);
|
|
18121
|
+
return true;
|
|
18122
|
+
}
|
|
17678
18123
|
function onTaskUiSpecUpdated(data) {
|
|
17679
18124
|
const taskId = data?.taskId;
|
|
17680
18125
|
if (typeof taskId !== "string")
|
|
@@ -17879,13 +18324,21 @@ async function processSlackThread(thread, {
|
|
|
17879
18324
|
for (const task of tasks) {
|
|
17880
18325
|
if (!isSlackRenderV2Enabled2())
|
|
17881
18326
|
return "stop";
|
|
17882
|
-
|
|
18327
|
+
const leadFollowUp = isOutcomeStatus(task.status) ? await classifyLeadFollowUp(task, tasks) : "none";
|
|
18328
|
+
if (leadFollowUp === "orphan" && isOutcomeStatus(task.status) && !task.slackReplySent && task.createdAt >= activatedAt && !endedBefore(task, outcomeWindow.finishedAfter)) {
|
|
18329
|
+
await settleLeadFollowUpWithoutCard(task, "no_slack_ask: Lead follow-up not posted");
|
|
18330
|
+
continue;
|
|
18331
|
+
}
|
|
18332
|
+
if (!await taskNeedsDirectOutcome(task, activatedAt, leadFollowUp))
|
|
17883
18333
|
continue;
|
|
17884
18334
|
const card = await getSlackOutcomeMessage2(task.id);
|
|
17885
18335
|
if (card && isSettledSlackMessage2(card))
|
|
17886
18336
|
continue;
|
|
17887
18337
|
if (await isAnsweredByDeferralCard(task, tasks))
|
|
17888
18338
|
continue;
|
|
18339
|
+
if ((!card || isPendingSlackMessage2(card)) && !await mayPostLeadFollowUpCard(task, tasks, ownerAskId, delegationActivatedAt)) {
|
|
18340
|
+
continue;
|
|
18341
|
+
}
|
|
17889
18342
|
const deferByClosure = task.source === "slack" && delegationEnabled && delegationActivatedAt !== null && task.createdAt >= delegationActivatedAt;
|
|
17890
18343
|
if (!deferByClosure) {
|
|
17891
18344
|
if (!card && await isSlackContinuation(task) && await isWakeAnsweredByReply(task)) {
|
|
@@ -17897,6 +18350,12 @@ async function processSlackThread(thread, {
|
|
|
17897
18350
|
if (!await checkOutcomeDeliveryGate(task, card, statusTick.budget))
|
|
17898
18351
|
continue;
|
|
17899
18352
|
try {
|
|
18353
|
+
if (!card && await mergeLeadFollowUpCard(task, tasks, statusTick.budget)) {
|
|
18354
|
+
noteOutcomeDeliverySuccess(task.id);
|
|
18355
|
+
await finalizeTerminalSlackReactions([task]);
|
|
18356
|
+
outcomeCreated = true;
|
|
18357
|
+
continue;
|
|
18358
|
+
}
|
|
17900
18359
|
const outcome = await streamOutcomeCard(task, { statusBudget: statusTick.budget });
|
|
17901
18360
|
if (outcome) {
|
|
17902
18361
|
noteOutcomeDeliverySuccess(task.id);
|
|
@@ -18098,12 +18557,13 @@ async function renderDirtyThreads() {
|
|
|
18098
18557
|
if (touched.wakeTouched)
|
|
18099
18558
|
await refreshResolvedDeferralCards();
|
|
18100
18559
|
}
|
|
18101
|
-
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, ensureSlackThreadTree, LINE_START_BLOCK, UI_SPEC_BLOCK_REJECTION_CODES, 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;
|
|
18560
|
+
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, ensureSlackThreadTree, LINE_START_BLOCK, SLACK_LEAD_FOLLOW_UP_TYPES, SLACK_ANCESTOR_WALK_LIMIT = 50, UI_SPEC_BLOCK_REJECTION_CODES, SLACK_CARD_MERGE_WINDOW_MS, SLACK_CARD_GROUP_MAX_SECTIONS = 5, 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;
|
|
18102
18561
|
var init_render_v2 = __esm(() => {
|
|
18103
18562
|
init_db4();
|
|
18563
|
+
init_slack_card_groups();
|
|
18104
18564
|
init_slack_trees();
|
|
18105
18565
|
init_task_citations2();
|
|
18106
|
-
|
|
18566
|
+
init_task_ui_spec2();
|
|
18107
18567
|
init_context_key();
|
|
18108
18568
|
init_slack();
|
|
18109
18569
|
init_business_use();
|
|
@@ -18111,12 +18571,13 @@ var init_render_v2 = __esm(() => {
|
|
|
18111
18571
|
init_secret_scrubber();
|
|
18112
18572
|
init_task_attachment_links();
|
|
18113
18573
|
init_task_citations();
|
|
18114
|
-
|
|
18574
|
+
init_task_ui_spec();
|
|
18115
18575
|
init_event_bus();
|
|
18116
18576
|
init_ack();
|
|
18117
18577
|
init_app4();
|
|
18118
18578
|
init_blocks();
|
|
18119
18579
|
init_closure();
|
|
18580
|
+
init_external_channel();
|
|
18120
18581
|
init_reaction_shortcode();
|
|
18121
18582
|
init_responses();
|
|
18122
18583
|
init_session_status();
|
|
@@ -18139,11 +18600,13 @@ var init_render_v2 = __esm(() => {
|
|
|
18139
18600
|
outcomeReservedWithoutAttempt = new Set;
|
|
18140
18601
|
ensureSlackThreadTree = ensureSlackThreadPresentation2;
|
|
18141
18602
|
LINE_START_BLOCK = /^(?:`{3}|~{3}|[-*+]\s|\d+[.)]\s|>|#{1,6}\s|\||(?:-{3,}|\*{3,}|_{3,})[ \t]*(?:\r?\n|$)|(?: {4}|\t))/;
|
|
18603
|
+
SLACK_LEAD_FOLLOW_UP_TYPES = new Set(["follow-up", "resume"]);
|
|
18142
18604
|
UI_SPEC_BLOCK_REJECTION_CODES = new Set([
|
|
18143
18605
|
"invalid_blocks",
|
|
18144
18606
|
"invalid_blocks_format",
|
|
18145
18607
|
"msg_blocks_too_long"
|
|
18146
18608
|
]);
|
|
18609
|
+
SLACK_CARD_MERGE_WINDOW_MS = 2 * 60000;
|
|
18147
18610
|
TRANSIENT_SLACK_ERROR_CODES = new Set([
|
|
18148
18611
|
"ratelimited",
|
|
18149
18612
|
"rate_limited",
|
|
@@ -18274,9 +18737,10 @@ async function mirrorSessionReply(taskId) {
|
|
|
18274
18737
|
return;
|
|
18275
18738
|
if (!await claimOnce(`reply:${task.id}`))
|
|
18276
18739
|
return;
|
|
18277
|
-
|
|
18740
|
+
const sent = task.status === "completed" ? await sendTaskOutputAsReply(task) : await sendTaskResponse(task);
|
|
18741
|
+
if (!sent) {
|
|
18278
18742
|
await deleteKv2(MIRROR_KV_NAMESPACE, `reply:${task.id}`);
|
|
18279
|
-
logFailure("reply", task.id, "Slack did not accept the outcome
|
|
18743
|
+
logFailure("reply", task.id, "Slack did not accept the outcome message");
|
|
18280
18744
|
}
|
|
18281
18745
|
} catch (error) {
|
|
18282
18746
|
logFailure("reply", taskId, error);
|
|
@@ -18382,7 +18846,7 @@ async function buildTreeNodes(tree) {
|
|
|
18382
18846
|
progress: child.progress ?? undefined,
|
|
18383
18847
|
duration: childDuration,
|
|
18384
18848
|
slackReplySent: child.slackReplySent,
|
|
18385
|
-
output: slackTaskOutput(child),
|
|
18849
|
+
output: await slackTaskOutput(child),
|
|
18386
18850
|
failureReason: child.failureReason ?? undefined,
|
|
18387
18851
|
attachments: childAttachments,
|
|
18388
18852
|
steered: childSteered,
|
|
@@ -18400,7 +18864,7 @@ async function buildTreeNodes(tree) {
|
|
|
18400
18864
|
progress: task.progress ?? undefined,
|
|
18401
18865
|
duration,
|
|
18402
18866
|
slackReplySent: task.slackReplySent,
|
|
18403
|
-
output: slackTaskOutput(task),
|
|
18867
|
+
output: await slackTaskOutput(task),
|
|
18404
18868
|
failureReason: task.failureReason ?? undefined,
|
|
18405
18869
|
attachments: rootAttachments,
|
|
18406
18870
|
steered: rootSteered,
|
|
@@ -18463,7 +18927,7 @@ async function processTreeMessages() {
|
|
|
18463
18927
|
let outputDeliverySucceeded = true;
|
|
18464
18928
|
for (const node of nodes.flatMap((root) => [root, ...root.children])) {
|
|
18465
18929
|
const task = await getTaskById2(node.taskId);
|
|
18466
|
-
if (!task || !shouldPostInlineCompletionOutput(task))
|
|
18930
|
+
if (!task || !await shouldPostInlineCompletionOutput(task))
|
|
18467
18931
|
continue;
|
|
18468
18932
|
const sent = await sendInlineTaskOutput(task);
|
|
18469
18933
|
if (sent) {
|
|
@@ -18609,7 +19073,7 @@ async function processPendingSlackRelays(now = Date.now()) {
|
|
|
18609
19073
|
await registerTreeMessage(task.id, task.slackChannelId, task.slackThreadTs, task.slackTreeRootMessageTs);
|
|
18610
19074
|
}
|
|
18611
19075
|
if (taskToTree.has(task.id)) {
|
|
18612
|
-
if (!shouldPostInlineCompletionOutput(task)) {
|
|
19076
|
+
if (!await shouldPostInlineCompletionOutput(task)) {
|
|
18613
19077
|
notifiedCompletions.set(task.id, now);
|
|
18614
19078
|
continue;
|
|
18615
19079
|
}
|
|
@@ -19111,17 +19575,17 @@ async function initSlackApp2() {
|
|
|
19111
19575
|
created.use(slackInboundOutcomeMiddleware(config.mode === "http" ? "http" : "socket"));
|
|
19112
19576
|
if (config.mode === "http")
|
|
19113
19577
|
created.use(ignoreSelfAsIgnored);
|
|
19114
|
-
const { registerMessageHandler } = await import("./handlers-
|
|
19115
|
-
const { registerCommandHandler } = await import("./commands-
|
|
19116
|
-
const { registerActionHandlers } = await import("./actions-
|
|
19117
|
-
const { registerWorkObjectHandlers } = await import("./work-objects-
|
|
19578
|
+
const { registerMessageHandler } = await import("./handlers-5btjqkz6.js");
|
|
19579
|
+
const { registerCommandHandler } = await import("./commands-d1z0sx62.js");
|
|
19580
|
+
const { registerActionHandlers } = await import("./actions-zcr25x27.js");
|
|
19581
|
+
const { registerWorkObjectHandlers } = await import("./work-objects-xtjbar3r.js");
|
|
19118
19582
|
registerMessageHandler(created);
|
|
19119
19583
|
registerCommandHandler(created);
|
|
19120
19584
|
registerActionHandlers(created);
|
|
19121
19585
|
registerWorkObjectHandlers(created);
|
|
19122
|
-
const { createAssistant } = await import("./assistant-
|
|
19586
|
+
const { createAssistant } = await import("./assistant-p2yvhc3j.js");
|
|
19123
19587
|
created.assistant(createAssistant());
|
|
19124
|
-
const { isBlockExternalEnabled, scanExternalChannelsOnBoot } = await import("./external-channel-
|
|
19588
|
+
const { isBlockExternalEnabled, scanExternalChannelsOnBoot } = await import("./external-channel-717yzn4d.js");
|
|
19125
19589
|
if (isBlockExternalEnabled()) {
|
|
19126
19590
|
scanExternalChannelsOnBoot(created.client).catch((error) => {
|
|
19127
19591
|
console.error("[Slack] External channel boot scan failed:", error);
|
|
@@ -19149,7 +19613,7 @@ async function startSlackApp2() {
|
|
|
19149
19613
|
startRetryAttempt = 0;
|
|
19150
19614
|
if (!httpReceiver)
|
|
19151
19615
|
startSocketWatchdog();
|
|
19152
|
-
const { isSlackRenderV2Enabled } = await import("./render-v2-
|
|
19616
|
+
const { isSlackRenderV2Enabled } = await import("./render-v2-ymbshmn0.js");
|
|
19153
19617
|
if (isSlackRenderV2Enabled())
|
|
19154
19618
|
await ensureSlackRenderV2Activation2();
|
|
19155
19619
|
await recoverSlackInboundAfterRestart();
|
|
@@ -19165,7 +19629,7 @@ async function startSlackApp2() {
|
|
|
19165
19629
|
} else {
|
|
19166
19630
|
console.log("[Slack] Bot connected via Socket Mode");
|
|
19167
19631
|
}
|
|
19168
|
-
const { restoreBufferedSlackMessages } = await import("./thread-buffer-
|
|
19632
|
+
const { restoreBufferedSlackMessages } = await import("./thread-buffer-9w6x5zec.js");
|
|
19169
19633
|
await restoreBufferedSlackMessages().catch((error) => {
|
|
19170
19634
|
console.error("[Slack] Failed to restore buffered thread messages:", error);
|
|
19171
19635
|
});
|
|
@@ -19314,4 +19778,4 @@ var init_app4 = __esm(() => {
|
|
|
19314
19778
|
watchdogOptions = SLACK_SOCKET_WATCHDOG_DEFAULTS;
|
|
19315
19779
|
});
|
|
19316
19780
|
|
|
19317
|
-
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, TaskUiSpecSchema, getTaskUiSpec, getTaskUiSpecsForTasks, upsertTaskUiSpec, reserveTaskUiActionRun, releaseTaskUiActionRun, setTaskUiActionResult, acquireTaskUiScriptActionRun, finishTaskUiScriptActionRun, hasTaskUiSpecCheckRefusal,
|
|
19781
|
+
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, resolveRequesterTimezone, init_requester_timezone, slackTaskOutput, init_task_output, ackSlackMessage, skipSlackMessageReaction, finalizeTerminalSlackReactions, init_ack, UI_SPEC_MAX_ACTIONS, UI_SPEC_ACTION_PREFIX, TASK_UI_SPEC_UPDATED_EVENT, UI_SPEC_ACTION_ID, UI_SPEC_CARD_LIMITS, UI_SPEC_SCRIPT_ARGS_MAX_BYTES, init_task_ui_spec, INLINE_TEXT_MAX_LENGTH, inlineApprovalQuestion, inlineApprovalChoices, inlineApprovalResponses, init_approval_inline, APPROVAL_ACTION_PREFIX, buildApprovalAnswerButtons, init_approval_buttons, getTaskLink, getTaskUrl, markdownToSlack, findReservedActionId, 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, TaskUiSpecSchema, getTaskUiSpec, getTaskUiSpecsForTasks, upsertTaskUiSpec, reserveTaskUiActionRun, releaseTaskUiActionRun, setTaskUiActionResult, acquireTaskUiScriptActionRun, finishTaskUiScriptActionRun, hasTaskUiSpecCheckRefusal, init_task_ui_spec2, standardComponentDefinitions, CardSpecError, toCard, init_dist5, validateTaskUiSpec, init_validate2, initialize, ensure, init_business_use, withUiSpecFallback, init_fallback, getAgentDisplayName, getAgentSlackIcon, init_responses, markSlackSessionProcessing, init_session_status, isSlackRenderV2Enabled2, callSlackWithRetry2, ensureSlackThreadPresentation2, slackDelegationOwnsChildCard2, slackErrorCode2, startSlackRenderV2Events2, stopSlackRenderV2Events2, processSlackRenderV22, init_render_v2, mirrorSessionPrompt, init_session_mirror, registerTreeMessage, init_watcher, getSlackApp2, getSlackHttpReceiver2, initSlackApp2, startSlackApp2, stopSlackApp2, stopSlackAppUnderLifecycleLock2, init_app4 };
|