@desplega.ai/agent-swarm 2.7.9 → 2.8.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-t949vbbp.js +15 -0
- package/dist/{actions-g563mbn2.js → actions-7e9czc7s.js} +19 -19
- package/dist/{amp-adapter-q61w05eb.js → amp-adapter-gv6cbb7d.js} +2 -3
- package/dist/app-b9fbkp9v.js +20 -0
- package/dist/{assistant-p477rjwj.js → assistant-wjb7v4c7.js} +22 -22
- package/dist/{boot-args-schema-h4qj462e.js → boot-args-schema-2t37e0fe.js} +1 -1
- package/dist/{boot-reembed-n1ehfbsw.js → boot-reembed-a35nkyr1.js} +1 -1
- package/dist/{boot-reembed-qw4mc0pt.js → boot-reembed-gka3zas7.js} +1 -1
- package/dist/{boot-scrub-sweep-9w9jp4sm.js → boot-scrub-sweep-65sdnp6c.js} +3 -3
- package/dist/{boot-seeds-qdaf3sdy.js → boot-seeds-x42tzytw.js} +4 -5
- package/dist/{claude-adapter-348p5hx9.js → claude-adapter-v221b2fd.js} +7 -8
- package/dist/{claude-managed-adapter-h74d06yz.js → claude-managed-adapter-29eq09wd.js} +2 -2
- package/dist/{claude-managed-setup-7787fxtp.js → claude-managed-setup-9m6450zk.js} +2 -2
- package/dist/{claude-sdk-session-hbszbt8a.js → claude-sdk-session-0q0ptaba.js} +9066 -8818
- package/dist/{cli-n5yexkdg.js → cli-0b4zam62.js} +1 -0
- package/dist/{cli-21159vea.js → cli-0jzra9ad.js} +2 -2
- package/dist/{cli-eqtfgfr6.js → cli-2gxeg5gr.js} +1 -1
- package/dist/{cli-k70e3x9e.js → cli-2wnq8jkz.js} +9 -9
- package/dist/{cli-cvs2r2vq.js → cli-2zp0et3v.js} +59 -6
- package/dist/{cli-650zv9q9.js → cli-334z18y3.js} +4 -4
- package/dist/{cli-12xyjhws.js → cli-3rkdne1h.js} +2 -2
- package/dist/{cli-2a8py3sx.js → cli-4txa0ter.js} +5 -7
- package/dist/{cli-jc1g9ndz.js → cli-5j88qqa8.js} +10 -5
- package/dist/{cli-xfjrc279.js → cli-5mrq3ake.js} +48 -14
- package/dist/{cli-v3cf1ts9.js → cli-6t09sdhy.js} +3 -3
- package/dist/{cli-qzt90yze.js → cli-6wxjceza.js} +8 -8
- package/dist/{cli-9aezs55w.js → cli-7b8sbmag.js} +8 -8
- package/dist/{cli-3xj33nrx.js → cli-7cp6aa1q.js} +10 -3
- package/dist/{cli-jfx48xrj.js → cli-7p1kvkck.js} +6 -6
- package/dist/{cli-b932gexn.js → cli-8aes17e4.js} +2 -2
- package/dist/{cli-3tqcamp6.js → cli-8fknbnhw.js} +14 -13
- package/dist/{cli-587857ys.js → cli-8kzasymh.js} +3 -3
- package/dist/{cli-sgs5k6yd.js → cli-a7wvp2km.js} +1 -1
- package/dist/{cli-varqt4d1.js → cli-abejgen1.js} +69 -22
- package/dist/{cli-rwymrnaz.js → cli-bsywb58a.js} +8 -8
- package/dist/{cli-btc9cb4c.js → cli-c55z5chy.js} +4 -6
- package/dist/{cli-ms5m5r1y.js → cli-deefvewm.js} +1 -1
- package/dist/{cli-p17970qv.js → cli-ee0b971j.js} +3 -3
- package/dist/cli-f3vq58d2.js +242 -0
- package/dist/{cli-3xcwp3z8.js → cli-ffhtssbp.js} +2 -2
- package/dist/{cli-hwprv9e4.js → cli-g70vxtjh.js} +2 -2
- package/dist/{cli-4t0fmf3z.js → cli-gxkx0zzp.js} +1 -1
- package/dist/{cli-neyag5p6.js → cli-h38x262p.js} +3365 -429
- package/dist/{cli-2ccpqyyf.js → cli-j790gp2w.js} +105 -22
- package/dist/{cli-f2zenhja.js → cli-kc7v1nfv.js} +1 -1
- package/dist/{cli-vxh6acp7.js → cli-m23zjcy2.js} +10 -10
- package/dist/{cli-y8nbefpb.js → cli-m28atx8q.js} +12 -10
- package/dist/{cli-serm8zrx.js → cli-m4dqmnbp.js} +1 -1
- package/dist/{cli-ybjdc978.js → cli-mrt48bx7.js} +7 -4
- package/dist/{cli-y5rbvxhc.js → cli-n515ex5z.js} +14 -14
- package/dist/{cli-ypff1qwp.js → cli-n9ftpys4.js} +7 -7
- package/dist/{cli-605nn699.js → cli-p1bq50aa.js} +894 -226
- package/dist/{cli-qkdmz8c8.js → cli-p1w18yhx.js} +1 -1
- package/dist/{cli-xk879m3k.js → cli-p2gfst4m.js} +52 -43
- package/dist/{cli-sya22y84.js → cli-pasjcnmj.js} +12 -12
- package/dist/{cli-0whpms1z.js → cli-qa4wdgsy.js} +5 -5
- package/dist/{cli-ejkvvqbe.js → cli-qfedvmcr.js} +50 -24
- package/dist/{cli-tqq0hspb.js → cli-qmqk2yc2.js} +1 -1
- package/dist/{cli-qmd3mse0.js → cli-qsnnd04k.js} +1 -1
- package/dist/{cli-agyaeef4.js → cli-qwca7s44.js} +3 -3
- package/dist/{cli-fayav105.js → cli-rfywm85n.js} +724 -792
- package/dist/{cli-zgv8gxgs.js → cli-rmmpt0wm.js} +6 -6
- package/dist/{cli-hae9j8sv.js → cli-rzsy6nc6.js} +12 -8
- package/dist/{cli-btf6fw39.js → cli-s7t6p9my.js} +1 -1
- package/dist/{cli-cseh6f8w.js → cli-sdtt3men.js} +1 -1
- package/dist/{cli-9r5gtwjr.js → cli-tk7cjj8h.js} +197 -2
- package/dist/{cli-q26b9wre.js → cli-tph5wt3y.js} +4 -4
- package/dist/{cli-gce09r66.js → cli-tqegb8eq.js} +3 -3
- package/dist/{cli-kf3pxxdg.js → cli-v1dv1r37.js} +1 -1
- package/dist/{cli-09kmfkmq.js → cli-wcg8x116.js} +1 -1
- package/dist/{cli-mnrkgg60.js → cli-wk18cm92.js} +5 -5
- package/dist/{cli-p0m0p34z.js → cli-x1wa213s.js} +3 -3
- package/dist/{cli-jrp1dt73.js → cli-xzm9vcfg.js} +1 -1
- package/dist/{cli-715t1gx6.js → cli-y97qxcfx.js} +9 -9
- package/dist/{cli-bc779n4v.js → cli-yq3zak69.js} +1 -1
- package/dist/cli.js +17 -17
- package/dist/{codex-adapter-ysq6bzha.js → codex-adapter-30j9bpzd.js} +5 -6
- package/dist/{codex-hook-fac6175r.js → codex-hook-h3vk6xzr.js} +1 -1
- package/dist/{codex-session-runner-qakzfx93.js → codex-session-runner-8vp57v8w.js} +5 -6
- package/dist/{commands-rs7hkv9r.js → commands-bngnz9g7.js} +3 -3
- package/dist/{controller-r5x9bg6e.js → controller-hxx8wwy1.js} +2 -2
- package/dist/{controllers-connect-498hrxvk.js → controllers-connect-e2b4gyxc.js} +20 -20
- package/dist/{cursor-adapter-d46qszer.js → cursor-adapter-n5nc3mfe.js} +1 -2
- package/dist/{db-s13dqhr6.js → db-bgm7vkc0.js} +3 -3
- package/dist/{db-pm96nhdb.js → db-c6np41ca.js} +12 -2
- package/dist/{devin-adapter-z46ep5ph.js → devin-adapter-xedz98zv.js} +1 -1
- package/dist/{dispatcher-j3h81t7m.js → dispatcher-jnybck15.js} +18 -18
- package/dist/{dsh-adapter-rw0d5rc4.js → dsh-adapter-nrhbrjz8.js} +1 -2
- package/dist/{easter-egg-3d-qtgfxgze.js → easter-egg-3d-533knw22.js} +1 -1
- package/dist/{embedding-space-xh8p4q4x.js → embedding-space-crsm2zp0.js} +6 -6
- package/dist/{embeddings-wp745m91.js → embeddings-e7z3f27f.js} +1 -1
- package/dist/{execute-2fzb9z74.js → execute-b3mrb1mv.js} +1 -1
- package/dist/{external-channel-ys21h3sy.js → external-channel-m77wf5z3.js} +2 -2
- package/dist/{fx-adapter-vz0b9z3g.js → fx-adapter-b6w0kf56.js} +7 -8
- package/dist/{google-generative-ai-ytpgncx9.js → google-generative-ai-h7s3e9kk.js} +1 -1
- package/dist/{google-vertex-tqhze5j7.js → google-vertex-fhxaafzw.js} +1 -1
- package/dist/{grok-adapter-spea7zkj.js → grok-adapter-4sqtebdk.js} +7 -8
- package/dist/handlers-kdjcyzdj.js +32 -0
- package/dist/heartbeat-xgb036sx.js +43 -0
- package/dist/{hook-amcj4s10.js → hook-5h02c9ga.js} +6 -6
- package/dist/{hook-bc6n49qn.js → hook-xsk1jbha.js} +5 -5
- package/dist/{http-7374brv5.js → http-txe7qhvn.js} +448 -165
- package/dist/{index-pxn30mse.js → index-0eny15vj.js} +8 -8
- package/dist/{index-5a9jtqde.js → index-0rvk3vd4.js} +46 -46
- package/dist/{index-fvzke5kx.js → index-1qw6f2dc.js} +10 -10
- package/dist/{index-q5cmtbz5.js → index-4a0670yh.js} +15939 -14244
- package/dist/index-835xdgnm.js +33 -0
- package/dist/index-d469300x.js +37 -0
- package/dist/{index-h7f61sy9.js → index-e5pfbsys.js} +3 -3
- package/dist/{index-hsad2t3r.js → index-m5gx1xd6.js} +38 -38
- package/dist/{index-5fx3b3kw.js → index-rvccek1w.js} +9 -9
- package/dist/index-rzqwp11g.js +32 -0
- package/dist/{index-w4m9z29z.js → index-tvfafeyy.js} +1 -1
- package/dist/{index-c9y31ytf.js → index-vk63emp7.js} +979 -35
- package/dist/{index-514d9pf6.js → index-w7em4ktq.js} +8 -8
- package/dist/{index-p4hjwbvw.js → index-ysvbhg5m.js} +1 -1
- package/dist/{keepalive-wy29kbrg.js → keepalive-4zsrce78.js} +3 -3
- package/dist/lead-yqt47dkr.js +70 -0
- package/dist/{maintenance-h2ds9w6c.js → maintenance-86jvartk.js} +1 -1
- package/dist/{oauth-refresh-sweep-q7mtbyp3.js → oauth-refresh-sweep-j52kg9pr.js} +2 -2
- package/dist/{onboard-vw8r2fdw.js → onboard-c2aj5p8q.js} +3 -3
- package/dist/{opencode-adapter-mtb0953j.js → opencode-adapter-dsagkhtw.js} +5 -6
- package/dist/{otel-impl-j42czw3r.js → otel-impl-yyy203z8.js} +1 -1
- package/dist/{pi-mono-adapter-zk8pg9jr.js → pi-mono-adapter-546cd1cc.js} +9 -9
- package/dist/{pricing-refresh-x7nhv23d.js → pricing-refresh-1rgzqyzz.js} +2 -3
- package/dist/{rbac-roles-9044425x.js → rbac-roles-e70xfeyj.js} +4 -6
- package/dist/{rbac-roles-bzvee6cf.js → rbac-roles-q89qe8er.js} +3 -3
- package/dist/{registry-hpjfmcfz.js → registry-32b1mft6.js} +1 -1
- package/dist/{render-v2-t7bn4skz.js → render-v2-k6tt107q.js} +9 -4
- package/dist/{resume-x94gemep.js → resume-cnnrjfxa.js} +6 -6
- package/dist/{runtime-breq6fmv.js → runtime-1hv06jsn.js} +1 -1
- package/dist/{session-access-q7dmqjvt.js → session-access-xkxkjw3n.js} +4 -4
- package/dist/{session-source-backfill-440ysamr.js → session-source-backfill-1d5pdwww.js} +2 -2
- package/dist/{setup-07n4727s.js → setup-se8q7gkc.js} +1 -1
- package/dist/{virtual-modules-z5h6mcyf.js → virtual-modules-gazyapte.js} +3 -3
- package/dist/{work-objects-pnq5y534.js → work-objects-1kxnbzy5.js} +22 -22
- package/dist/{worker-follow-up-7z1gfkr8.js → worker-follow-up-zqm8apt4.js} +18 -18
- package/dist/worker-j6xxtq7p.js +70 -0
- package/openapi.json +334 -7
- package/package.json +4 -4
- package/src/apps/catalog.generated.json +55 -0
- package/src/apps/definition.ts +11 -0
- package/src/apps/page-validator.ts +19 -0
- package/src/apps/store.ts +28 -8
- package/src/assets/key.ts +77 -4
- package/src/be/db/model-profiles.ts +147 -38
- package/src/be/db/session-labels.ts +57 -0
- package/src/be/db/session-tree.ts +51 -7
- package/src/be/db/slack-trees.ts +146 -0
- package/src/be/db/tasks/read.ts +107 -8
- package/src/be/db/workflow-run-definitions.ts +117 -0
- package/src/be/db-client.ts +8 -2
- package/src/be/db.ts +119 -87
- package/src/be/event-loop-lag.ts +146 -0
- package/src/be/mcp-overflow-sweep.ts +2 -1
- package/src/be/memory/constants.ts +14 -1
- package/src/be/memory/key-paths.ts +8 -0
- package/src/be/memory/providers/sqlite-store.ts +199 -18
- package/src/be/memory/task-learning.ts +79 -14
- package/src/be/memory/types.ts +24 -1
- package/src/be/migrations/278_slack_render_v2_reconcile.sql +108 -0
- package/src/be/migrations/279_backfill_learning_expiry.sql +15 -0
- package/src/be/migrations/281_model_profiles_pr2.sql +28 -0
- package/src/be/migrations/283_workflow_run_definitions.sql +14 -0
- package/src/be/model-profile-check.ts +284 -0
- package/src/be/model-tier-resolution.ts +112 -12
- package/src/be/multi-runtime.ts +27 -0
- package/src/be/runtime-pools/routing.ts +52 -4
- package/src/be/scripts/typecheck.ts +1 -0
- package/src/be/seed-scripts/catalog/dreaming-learnings.ts +552 -0
- package/src/be/seed-scripts/catalog/dreaming-memtax-create.ts +389 -14
- package/src/be/seed-scripts/catalog/dreaming-memtax.ts +6 -3
- package/src/be/seed-scripts/index.ts +9 -0
- package/src/be/steering.ts +8 -2
- package/src/be/swarm-config-guard.ts +2 -0
- package/src/commands/context-preamble.ts +258 -0
- package/src/commands/onboard/agent-fs-version.ts +1 -1
- package/src/commands/runner.ts +32 -1
- package/src/extensions/catalog.generated.json +3 -3
- package/src/fs/provider.ts +17 -3
- package/src/heartbeat/heartbeat.ts +17 -5
- package/src/heartbeat/index.ts +1 -0
- package/src/http/agents.ts +56 -4
- package/src/http/apps.ts +3 -1
- package/src/http/config.ts +2 -6
- package/src/http/core.ts +9 -3
- package/src/http/index.ts +12 -9
- package/src/http/memory.ts +9 -4
- package/src/http/model-profiles.ts +58 -10
- package/src/http/poll.ts +36 -3
- package/src/http/schedules.ts +42 -3
- package/src/http/sessions.ts +16 -3
- package/src/http/tasks.ts +37 -12
- package/src/http/utils.ts +18 -0
- package/src/http/webhooks.ts +48 -0
- package/src/http/workflows.ts +15 -2
- package/src/integrations/chat-sdk/commands.ts +167 -31
- package/src/integrations/chat-sdk/inbound.ts +10 -8
- package/src/integrations/chat-sdk/message-text.ts +117 -0
- package/src/prompts/session-templates.ts +1 -1
- package/src/providers/acp-targets.ts +11 -6
- package/src/providers/amp-adapter.ts +1 -1
- package/src/providers/claude-sdk-session.ts +132 -23
- package/src/providers/codex-skill-resolver.ts +10 -4
- package/src/providers/cursor-adapter.ts +1 -1
- package/src/providers/devin-skill-resolver.ts +5 -5
- package/src/providers/dsh-adapter.ts +1 -1
- package/src/scheduler/schedule-task.ts +1 -0
- package/src/scheduler/scheduler.ts +4 -1
- package/src/scripts-runtime/executors/quickjs-runner.ts +2 -0
- package/src/scripts-runtime/executors/quickjs-structured-clone.ts +180 -0
- package/src/scripts-runtime/quickjs-compat.ts +0 -1
- package/src/scripts-runtime/sdk-allowlist.ts +1 -0
- package/src/scripts-runtime/swarm-sdk.ts +18 -1
- package/src/scripts-runtime/types/stdlib.d.ts +1 -0
- package/src/scripts-runtime/types/swarm-sdk.d.ts +1 -0
- package/src/server.ts +2 -0
- package/src/slack/app.ts +425 -10
- package/src/slack/handlers.ts +9 -2
- package/src/slack/inbound-dispatch.ts +18 -1
- package/src/slack/index.ts +7 -1
- package/src/slack/lifecycle-lock.ts +29 -0
- package/src/slack/render-v2.ts +424 -212
- package/src/slack/socket-fence.ts +64 -0
- package/src/slack/watcher.ts +42 -8
- package/src/slack/workspace-guard.ts +345 -0
- package/src/tasks/task-terminal-effects.ts +4 -0
- package/src/tasks/worker-follow-up.ts +102 -2
- package/src/tests/acp-adapter.test.ts +82 -0
- package/src/tests/apps-icon.test.ts +120 -0
- package/src/tests/apps-schema-form.test.ts +151 -0
- package/src/tests/chained-task-follow-up.test.ts +248 -0
- package/src/tests/chat-sdk-commands.test.ts +359 -2
- package/src/tests/chat-sdk-inbound.test.ts +20 -0
- package/src/tests/chat-sdk-slack.test.ts +189 -1
- package/src/tests/check-pr-body.test.ts +40 -0
- package/src/tests/claude-sdk-lifecycle.test.ts +216 -1
- package/src/tests/claude-sdk-process.fixture.ts +57 -0
- package/src/tests/codex-skill-resolver.test.ts +31 -0
- package/src/tests/credentials-allowlist.test.ts +470 -0
- package/src/tests/db-client-busy-retry.test.ts +69 -18
- package/src/tests/db-client.test.ts +26 -1
- package/src/tests/db-task-read-contract.test.ts +7 -0
- package/src/tests/db-task-write-contract.test.ts +6 -0
- package/src/tests/deferred-wake-follow-up.test.ts +47 -0
- package/src/tests/docs-index-footprint.test.js +3 -3
- package/src/tests/dreaming-learnings.test.ts +1395 -0
- package/src/tests/dsh-adapter.test.ts +1 -1
- package/src/tests/event-loop-lag.test.ts +184 -0
- package/src/tests/explicit-model-validation.test.ts +2 -0
- package/src/tests/extensions-example-comms-adherence-gate.test.ts +115 -0
- package/src/tests/fs-provider.test.ts +42 -0
- package/src/tests/github-webhook-early-ack.test.ts +144 -0
- package/src/tests/heartbeat.test.ts +28 -1
- package/src/tests/http-api-integration.test.ts +2 -0
- package/src/tests/http-log-scrubbing.test.ts +68 -2
- package/src/tests/human-free-reclassify.test.ts +5 -1
- package/src/tests/kv-storage.test.ts +92 -1
- package/src/tests/list-endpoint-slimming.test.ts +17 -0
- package/src/tests/memory-key-paths.test.ts +57 -0
- package/src/tests/memory-retrieval-purge.test.ts +19 -0
- package/src/tests/migration-283-workflow-run-definitions.test.ts +69 -0
- package/src/tests/model-profile-check.test.ts +387 -0
- package/src/tests/model-profiles-api.test.ts +528 -1
- package/src/tests/profile-claim.test.ts +415 -3
- package/src/tests/profile-tier-alias.test.ts +382 -0
- package/src/tests/quickjs-compat.test.ts +1 -1
- package/src/tests/runner-context-preamble.test.ts +552 -0
- package/src/tests/schedule-profile.test.ts +359 -0
- package/src/tests/script-connections.test.ts +9 -0
- package/src/tests/script-executor-conformance.test.ts +188 -0
- package/src/tests/script-per-script-executor.test.ts +1 -0
- package/src/tests/scripts-sdk-bridge-tool-failure.test.ts +141 -0
- package/src/tests/seed-scripts.test.ts +2 -2
- package/src/tests/sessions-tree.test.ts +133 -2
- package/src/tests/slack-app-icon.test.ts +4 -0
- package/src/tests/slack-dm-implicit-mention.test.ts +236 -0
- package/src/tests/slack-file-tools-attachments.test.ts +1 -0
- package/src/tests/slack-inbound-receipts.test.ts +22 -2
- package/src/tests/slack-read-boundaries.test.ts +4 -3
- package/src/tests/slack-render-v2-query-plans.test.ts +262 -3
- package/src/tests/slack-render-v2-reconcile.test.ts +201 -0
- package/src/tests/slack-socket-ack.test.ts +16 -1
- package/src/tests/slack-socket-watchdog.test.ts +748 -0
- package/src/tests/slack-workspace-guard.test.ts +905 -0
- package/src/tests/steering-core.test.ts +40 -0
- package/src/tests/store-progress-learning.test.ts +605 -20
- package/src/tests/tool-annotations.test.ts +1 -1
- package/src/tests/vcs-identity-inheritance.test.ts +85 -0
- package/src/tests/workflow-convergence.test.ts +46 -40
- package/src/tests/workflow-definition-pinning-recovery.test.ts +552 -0
- package/src/tests/workflow-definition-pinning.test.ts +645 -0
- package/src/tests/workflow-executors.test.ts +16 -7
- package/src/tests/workflow-foreach.test.ts +43 -20
- package/src/tests/workflow-notify-slack-ready.test.ts +161 -0
- package/src/tests/workflow-profile.test.ts +328 -0
- package/src/tools/app-upsert.ts +1 -1
- package/src/tools/memory-edit.ts +2 -1
- package/src/tools/model-profiles/check-model-profile.ts +63 -0
- package/src/tools/schedules/create-schedule.ts +45 -4
- package/src/tools/schedules/patch-schedule.ts +50 -4
- package/src/tools/schedules/update-schedule.ts +50 -4
- package/src/tools/send-task.ts +17 -2
- package/src/tools/store-progress.ts +15 -3
- package/src/tools/task-action.ts +9 -1
- package/src/tools/templates.ts +13 -0
- package/src/tools/tool-config.ts +2 -1
- package/src/tools/utils.ts +77 -11
- package/src/tools/workflows/create-workflow.ts +1 -1
- package/src/tools/workflows/retry-workflow-run.ts +1 -1
- package/src/tools/workflows/update-workflow.ts +10 -1
- package/src/types.ts +56 -1
- package/src/utils/credentials.ts +89 -12
- package/src/workflows/engine.ts +10 -1
- package/src/workflows/executors/agent-task.ts +21 -2
- package/src/workflows/executors/foreach.ts +4 -1
- package/src/workflows/executors/notify.ts +62 -6
- package/src/workflows/executors/sub-workflow.ts +1 -1
- package/src/workflows/executors/swarm-script.ts +4 -1
- package/src/workflows/foreach-driver.ts +8 -5
- package/src/workflows/limits.ts +2 -1
- package/src/workflows/model-validation.ts +27 -2
- package/src/workflows/patch-definition.ts +3 -1
- package/src/workflows/recovery.ts +6 -6
- package/src/workflows/resume.ts +9 -9
- package/src/workflows/retry-poller.ts +2 -2
- package/templates/extensions/comms-adherence-gate/README.md +25 -0
- package/templates/extensions/comms-adherence-gate/hooks.ts +100 -11
- package/templates/extensions/comms-adherence-gate/manifest.json +1 -1
- package/templates/skills/apps/SKILL.md +9 -0
- package/templates/skills/apps/content.md +9 -0
- package/templates/skills/code-quality/content.md +12 -0
- package/templates/skills/memory/content.md +8 -0
- package/templates/skills/scheduling/config.json +1 -1
- package/templates/skills/scheduling/content.md +2 -2
- package/templates/skills/swarm-docs/content.md +4 -0
- package/templates/skills/swarm-extensions/content.md +1 -1
- package/templates/skills/swarm-scripts/SKILL.md +1 -1
- package/templates/skills/swarm-scripts/content.md +1 -1
- package/templates/skills/work-on-task/SKILL.md +2 -0
- package/templates/skills/work-on-task/content.md +2 -0
- package/templates/workflows/dreaming/content.md +174 -7
- package/dist/acp-adapter-dn4gdsgr.js +0 -16
- package/dist/app-a66ssc4k.js +0 -17
- package/dist/cli-530hkwdy.js +0 -779
- package/dist/cli-a0657jmf.js +0 -339
- package/dist/cli-cyn9v8zr.js +0 -748
- package/dist/handlers-crckt5dq.js +0 -32
- package/dist/heartbeat-8phn1kdq.js +0 -41
- package/dist/index-4x08sjtk.js +0 -30
- package/dist/index-8ybffts4.js +0 -37
- package/dist/index-nfy4kkg5.js +0 -33
- package/dist/lead-zdqxsvjn.js +0 -71
- package/dist/worker-y62rvvq3.js +0 -71
- package/dist/{cli-gxy8y1dt.js → cli-8bpgbr8k.js} +3 -3
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Outer `success` on generic MCP bridge calls. The bridge answers HTTP 200 with
|
|
3
|
+
* the tool's structuredContent, so a tool refusal (toolErr) arrives as 200 with
|
|
4
|
+
* `data.success === false`. The SDK must surface that as outer `success: false`
|
|
5
|
+
* while leaving `status` and `data` untouched, mirror the refusal `message`,
|
|
6
|
+
* and must not throw.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
import { afterAll, beforeAll, describe, expect, test } from "bun:test";
|
|
10
|
+
import { unlink } from "node:fs/promises";
|
|
11
|
+
import { createServer as createHttpServer, type Server } from "node:http";
|
|
12
|
+
import { closeDb, createAgent, initDb } from "../be/db";
|
|
13
|
+
import { handleMcpBridge } from "../http/mcp-bridge";
|
|
14
|
+
import { getPathSegments, parseQueryParams } from "../http/utils";
|
|
15
|
+
import { SwarmConfig } from "../scripts-runtime/swarm-config";
|
|
16
|
+
import { createSwarmSdk } from "../scripts-runtime/swarm-sdk";
|
|
17
|
+
import { listenOnFreePort } from "./test-net";
|
|
18
|
+
|
|
19
|
+
const TEST_DB_PATH = "./test-scripts-sdk-bridge-tool-failure.sqlite";
|
|
20
|
+
const API_KEY = "example-scripts-sdk-bridge-tool-failure-key-1234567890";
|
|
21
|
+
let baseUrl = "";
|
|
22
|
+
let server: Server;
|
|
23
|
+
|
|
24
|
+
async function removeDbFiles(path: string): Promise<void> {
|
|
25
|
+
for (const suffix of ["", "-wal", "-shm"]) {
|
|
26
|
+
await unlink(path + suffix).catch(() => {});
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
function sdkFor(agentId: string, mcpBaseUrl: string) {
|
|
31
|
+
return createSwarmSdk(
|
|
32
|
+
new SwarmConfig({
|
|
33
|
+
system: {
|
|
34
|
+
apiKey: { value: API_KEY, isSecret: true },
|
|
35
|
+
agentId: { value: agentId, isSecret: false },
|
|
36
|
+
mcpBaseUrl: { value: mcpBaseUrl, isSecret: false },
|
|
37
|
+
},
|
|
38
|
+
user: {},
|
|
39
|
+
}),
|
|
40
|
+
);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/** Serves one fixed bridge response, to pin the SDK's mapping per body shape. */
|
|
44
|
+
async function withBridgeStub<T>(
|
|
45
|
+
body: unknown,
|
|
46
|
+
status: number,
|
|
47
|
+
fn: (url: string) => Promise<T>,
|
|
48
|
+
): Promise<T> {
|
|
49
|
+
const stub = Bun.serve({
|
|
50
|
+
port: 0,
|
|
51
|
+
fetch: () => Response.json(body, { status }),
|
|
52
|
+
});
|
|
53
|
+
try {
|
|
54
|
+
return await fn(`http://127.0.0.1:${stub.port}`);
|
|
55
|
+
} finally {
|
|
56
|
+
stub.stop(true);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
beforeAll(async () => {
|
|
61
|
+
await removeDbFiles(TEST_DB_PATH);
|
|
62
|
+
initDb(TEST_DB_PATH);
|
|
63
|
+
server = createHttpServer(async (req, res) => {
|
|
64
|
+
const myAgentId = (req.headers["x-agent-id"] as string | undefined) ?? undefined;
|
|
65
|
+
const segments = getPathSegments(req.url ?? "");
|
|
66
|
+
const query = parseQueryParams(req.url ?? "");
|
|
67
|
+
if (await handleMcpBridge(req, res, segments, query, myAgentId)) return;
|
|
68
|
+
res.writeHead(404, { "Content-Type": "application/json" });
|
|
69
|
+
res.end(JSON.stringify({ error: "Not found" }));
|
|
70
|
+
});
|
|
71
|
+
const port = await listenOnFreePort(server);
|
|
72
|
+
baseUrl = `http://localhost:${port}`;
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
afterAll(async () => {
|
|
76
|
+
await new Promise<void>((resolve) => {
|
|
77
|
+
server.close(() => resolve());
|
|
78
|
+
});
|
|
79
|
+
closeDb();
|
|
80
|
+
await removeDbFiles(TEST_DB_PATH);
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
describe("generic MCP bridge: tool refusal sets outer success false", () => {
|
|
84
|
+
test("skill_update with the wrong id field is a refusal, not a success", async () => {
|
|
85
|
+
const agentId = crypto.randomUUID();
|
|
86
|
+
await createAgent({
|
|
87
|
+
id: agentId,
|
|
88
|
+
name: "bridge-failure-agent",
|
|
89
|
+
isLead: false,
|
|
90
|
+
status: "idle",
|
|
91
|
+
capabilities: [],
|
|
92
|
+
});
|
|
93
|
+
|
|
94
|
+
const result = (await sdkFor(agentId, baseUrl).skill_update({
|
|
95
|
+
id: crypto.randomUUID(),
|
|
96
|
+
})) as { success: boolean; status: number; data: Record<string, unknown> };
|
|
97
|
+
|
|
98
|
+
expect(result.status).toBe(200);
|
|
99
|
+
expect(result.data.success).toBe(false);
|
|
100
|
+
expect(result.data.message).toBe("skillId is required.");
|
|
101
|
+
expect(result.success).toBe(false);
|
|
102
|
+
expect((result as { message?: unknown }).message).toBe("skillId is required.");
|
|
103
|
+
});
|
|
104
|
+
|
|
105
|
+
test("an inner success keeps outer success true", async () => {
|
|
106
|
+
const body = { success: true, message: "Posted.", ts: "1" };
|
|
107
|
+
const result = await withBridgeStub(body, 200, (url) =>
|
|
108
|
+
sdkFor("agent-sdk", url).slack_post({ channelId: "C1", message: "hi" }),
|
|
109
|
+
);
|
|
110
|
+
expect(result).toEqual({ success: true, status: 200, data: body });
|
|
111
|
+
});
|
|
112
|
+
|
|
113
|
+
test("an inner failure keeps status and data unchanged and mirrors the message", async () => {
|
|
114
|
+
const body = { success: false, message: "Channel not found." };
|
|
115
|
+
const result = await withBridgeStub(body, 200, (url) =>
|
|
116
|
+
sdkFor("agent-sdk", url).slack_post({ channelId: "C1", message: "hi" }),
|
|
117
|
+
);
|
|
118
|
+
expect(result).toEqual({
|
|
119
|
+
success: false,
|
|
120
|
+
status: 200,
|
|
121
|
+
data: body,
|
|
122
|
+
message: "Channel not found.",
|
|
123
|
+
});
|
|
124
|
+
});
|
|
125
|
+
|
|
126
|
+
test("a body without a success flag follows the HTTP status", async () => {
|
|
127
|
+
const body = { result: "plain text tool output" };
|
|
128
|
+
const result = await withBridgeStub(body, 200, (url) =>
|
|
129
|
+
sdkFor("agent-sdk", url).slack_post({ channelId: "C1", message: "hi" }),
|
|
130
|
+
);
|
|
131
|
+
expect(result).toEqual({ success: true, status: 200, data: body });
|
|
132
|
+
});
|
|
133
|
+
|
|
134
|
+
test("an HTTP error still reports success false without throwing", async () => {
|
|
135
|
+
const body = { error: "Tool 'x' not found in the MCP registry" };
|
|
136
|
+
const result = await withBridgeStub(body, 404, (url) =>
|
|
137
|
+
sdkFor("agent-sdk", url).slack_post({ channelId: "C1", message: "hi" }),
|
|
138
|
+
);
|
|
139
|
+
expect(result).toEqual({ success: false, status: 404, data: body });
|
|
140
|
+
});
|
|
141
|
+
});
|
|
@@ -66,8 +66,8 @@ afterAll(async () => {
|
|
|
66
66
|
});
|
|
67
67
|
|
|
68
68
|
describe("seed-scripts catalog", () => {
|
|
69
|
-
test("manifest holds
|
|
70
|
-
expect(SEED_SCRIPTS.length).toBe(
|
|
69
|
+
test("manifest holds 41 unique, well-described scripts", () => {
|
|
70
|
+
expect(SEED_SCRIPTS.length).toBe(41);
|
|
71
71
|
const names = SEED_SCRIPTS.map((s) => s.name);
|
|
72
72
|
expect(new Set(names).size).toBe(names.length);
|
|
73
73
|
for (const s of SEED_SCRIPTS) {
|
|
@@ -9,7 +9,7 @@ import {
|
|
|
9
9
|
test,
|
|
10
10
|
} from "bun:test";
|
|
11
11
|
import { createServer, type Server } from "node:http";
|
|
12
|
-
import { keyPrefixRange, sessionGroupKey } from "../assets/key";
|
|
12
|
+
import { keyPrefixRange, sessionGroupKey, sessionResourceGroupOf } from "../assets/key";
|
|
13
13
|
import {
|
|
14
14
|
isSourceThreadKey,
|
|
15
15
|
NESTED_THREAD_MIN_ROOTS,
|
|
@@ -19,10 +19,13 @@ import {
|
|
|
19
19
|
closeDb,
|
|
20
20
|
countSessions,
|
|
21
21
|
createAgent,
|
|
22
|
+
createPage,
|
|
23
|
+
createScheduledTask,
|
|
22
24
|
createSessionCost,
|
|
23
25
|
createSteeringMessage,
|
|
24
26
|
createTaskExtended,
|
|
25
27
|
createUser,
|
|
28
|
+
createWorkflow,
|
|
26
29
|
getDbClient,
|
|
27
30
|
initDb,
|
|
28
31
|
listRecentSessions,
|
|
@@ -147,7 +150,7 @@ async function ids(extra: SessionFilters) {
|
|
|
147
150
|
describe("session groups and prefix bounds", () => {
|
|
148
151
|
test("leaf helpers preserve group names and namespace roots", () => {
|
|
149
152
|
expect(keyPrefixRange("shared/a/")).toEqual({ lo: "shared/a/", hi: "shared/a0" });
|
|
150
|
-
for (const kind of ["task", "thread", "schedule", "workflow"]) {
|
|
153
|
+
for (const kind of ["task", "thread", "schedule", "workflow", "page", "app", "script", "fs"]) {
|
|
151
154
|
expect(sessionGroupKey(`shared/a/${kind}:abc/`)).toBe("shared/a/");
|
|
152
155
|
}
|
|
153
156
|
for (const key of [
|
|
@@ -214,6 +217,134 @@ describe("session groups and prefix bounds", () => {
|
|
|
214
217
|
});
|
|
215
218
|
});
|
|
216
219
|
|
|
220
|
+
describe("resource groups", () => {
|
|
221
|
+
test("a resource leaf at a namespace root is its own group; task stays No group", () => {
|
|
222
|
+
const me = `personal/${owner.id}/`;
|
|
223
|
+
const cases: Array<[string, string]> = [
|
|
224
|
+
["shared/task:t1/", "shared/"],
|
|
225
|
+
[`${me}task:t1/`, me],
|
|
226
|
+
["shared/thread:t1/", "shared/"],
|
|
227
|
+
["shared/page:p1/", "shared/page:p1/"],
|
|
228
|
+
["shared/workflow:w1/", "shared/workflow:w1/"],
|
|
229
|
+
[`${me}schedule:s1/`, `${me}schedule:s1/`],
|
|
230
|
+
["shared/script:x1/", "shared/script:x1/"],
|
|
231
|
+
["shared/fs:agent-fs:f1/", "shared/fs:agent-fs:f1/"],
|
|
232
|
+
["shared/app:a1/action:send/", "shared/app:a1/action:send/"],
|
|
233
|
+
["shared/workflow:w1/task:t1/", "shared/workflow:w1/"],
|
|
234
|
+
["shared/northwind/page:p1/", "shared/northwind/"],
|
|
235
|
+
];
|
|
236
|
+
for (const [key, group] of cases) expect([key, sessionGroupKey(key)]).toEqual([key, group]);
|
|
237
|
+
expect(sessionResourceGroupOf("shared/app:a1/action:send/")).toEqual({
|
|
238
|
+
kind: "app",
|
|
239
|
+
id: "a1",
|
|
240
|
+
base: "shared/",
|
|
241
|
+
resourceKey: "shared/app:a1/",
|
|
242
|
+
action: "send",
|
|
243
|
+
});
|
|
244
|
+
expect(sessionResourceGroupOf("shared/page:p1/action:x/")).toBeNull();
|
|
245
|
+
expect(sessionResourceGroupOf("shared/northwind/page:p1/")).toBeNull();
|
|
246
|
+
expect(sessionResourceGroupOf("shared/")).toBeNull();
|
|
247
|
+
});
|
|
248
|
+
|
|
249
|
+
test("tree, lists and the Inbox agree; No group keeps only task leaves", async () => {
|
|
250
|
+
const loose = await task("shared/task:loose/");
|
|
251
|
+
const page = await task("shared/page:p1/");
|
|
252
|
+
const workflow = await task("shared/workflow:w1/");
|
|
253
|
+
const workflowChild = await task("shared/workflow:w1/task:c1/");
|
|
254
|
+
const schedule = await task(`personal/${owner.id}/schedule:s1/`);
|
|
255
|
+
const action = await task("shared/app:a1/action:send/");
|
|
256
|
+
const filed = await task("shared/northwind/workflow:w2/");
|
|
257
|
+
expect(await ids({ noGroup: true })).toEqual([loose.id]);
|
|
258
|
+
expect(await ids({ groupKey: "shared/page:p1/" })).toEqual([page.id]);
|
|
259
|
+
expect(await ids({ groupKey: "shared/workflow:w1/" })).toEqual(
|
|
260
|
+
[workflow.id, workflowChild.id].sort(),
|
|
261
|
+
);
|
|
262
|
+
expect(await ids({ groupKey: `personal/${owner.id}/schedule:s1/` })).toEqual([schedule.id]);
|
|
263
|
+
expect(await ids({ groupKey: "shared/app:a1/" })).toEqual([]);
|
|
264
|
+
expect(await ids({ groupKey: "shared/app:a1/action:send/" })).toEqual([action.id]);
|
|
265
|
+
expect(await ids({ groupKey: "shared/northwind/" })).toEqual([filed.id]);
|
|
266
|
+
// Resource sections file on their own, like sources: their sessions stay in the Inbox.
|
|
267
|
+
const inbox = [loose, page, workflow, workflowChild, schedule, action].map((r) => r.id).sort();
|
|
268
|
+
expect(await ids({ triage: "inbox" })).toEqual(inbox);
|
|
269
|
+
|
|
270
|
+
const tree = await getSessionTree(actor(), NOW);
|
|
271
|
+
expect(tree.noGroup.total).toBe(1);
|
|
272
|
+
expect(tree.inbox.total).toBe(6);
|
|
273
|
+
const totals = Object.fromEntries(tree.groups.map((g) => [g.key, g.total]));
|
|
274
|
+
expect(totals).toEqual({
|
|
275
|
+
"shared/app:a1/action:send/": 1,
|
|
276
|
+
"shared/northwind/": 1,
|
|
277
|
+
"shared/page:p1/": 1,
|
|
278
|
+
"shared/workflow:w1/": 2,
|
|
279
|
+
[`personal/${owner.id}/schedule:s1/`]: 1,
|
|
280
|
+
});
|
|
281
|
+
expect(tree.resourceGroups).toEqual(
|
|
282
|
+
[
|
|
283
|
+
"shared/app:a1/",
|
|
284
|
+
"shared/app:a1/action:send/",
|
|
285
|
+
"shared/page:p1/",
|
|
286
|
+
"shared/workflow:w1/",
|
|
287
|
+
`personal/${owner.id}/schedule:s1/`,
|
|
288
|
+
].sort(),
|
|
289
|
+
);
|
|
290
|
+
});
|
|
291
|
+
|
|
292
|
+
test("the route labels resource groups by name, and a deleted resource gets none", async () => {
|
|
293
|
+
const agent = await createAgent({ name: "page-agent", isLead: false, status: "idle" });
|
|
294
|
+
const page = await createPage({
|
|
295
|
+
agentId: agent.id,
|
|
296
|
+
slug: `pricing-${crypto.randomUUID()}`,
|
|
297
|
+
title: "Pricing review",
|
|
298
|
+
contentType: "text/html",
|
|
299
|
+
body: "<h1>Pricing</h1>",
|
|
300
|
+
});
|
|
301
|
+
const workflow = await createWorkflow({
|
|
302
|
+
name: "Nightly digest",
|
|
303
|
+
definition: { nodes: [] },
|
|
304
|
+
});
|
|
305
|
+
const schedule = await createScheduledTask({
|
|
306
|
+
name: "Morning sweep",
|
|
307
|
+
cronExpression: "0 9 * * *",
|
|
308
|
+
taskTemplate: "Sweep",
|
|
309
|
+
});
|
|
310
|
+
// Each resource's own default key is its session group.
|
|
311
|
+
for (const resource of [page, workflow, schedule]) await task(resource.key);
|
|
312
|
+
await task("shared/workflow:deleted1/");
|
|
313
|
+
await task("shared/app:gone/action:send/");
|
|
314
|
+
const res = await fetch(`${baseUrl}/api/session-tree?show=all`, {
|
|
315
|
+
headers: { "x-swarm-user-id": owner.id },
|
|
316
|
+
});
|
|
317
|
+
expect(res.status).toBe(200);
|
|
318
|
+
const body = (await res.json()) as { labels: Record<string, string>; resourceGroups?: unknown };
|
|
319
|
+
expect(body.resourceGroups).toBeUndefined();
|
|
320
|
+
expect(body.labels).toEqual({
|
|
321
|
+
[`shared/page:${page.id}/`]: "Pricing review",
|
|
322
|
+
[`shared/workflow:${workflow.id}/`]: "Nightly digest",
|
|
323
|
+
[`shared/schedule:${schedule.id}/`]: "Morning sweep",
|
|
324
|
+
"shared/app:gone/action:send/": "send",
|
|
325
|
+
});
|
|
326
|
+
});
|
|
327
|
+
|
|
328
|
+
test("resource groups are read-only: no prefix rename or delete", async () => {
|
|
329
|
+
await task("shared/workflow:w1/");
|
|
330
|
+
const move = (body: { from: string; to: string | null }) =>
|
|
331
|
+
fetch(`${baseUrl}/api/session-moves/prefix`, {
|
|
332
|
+
method: "POST",
|
|
333
|
+
headers: { "content-type": "application/json", "x-swarm-user-id": owner.id },
|
|
334
|
+
body: JSON.stringify(body),
|
|
335
|
+
});
|
|
336
|
+
for (const body of [
|
|
337
|
+
{ from: "shared/workflow:w1/", to: "shared/renamed/" },
|
|
338
|
+
{ from: "shared/workflow:w1/", to: null },
|
|
339
|
+
{ from: "shared/a/", to: "shared/page:p1/" },
|
|
340
|
+
]) {
|
|
341
|
+
const res = await move(body);
|
|
342
|
+
expect(res.status).toBe(400);
|
|
343
|
+
expect(await res.text()).toContain("Resource groups are read-only.");
|
|
344
|
+
}
|
|
345
|
+
});
|
|
346
|
+
});
|
|
347
|
+
|
|
217
348
|
describe("nested source thread groups", () => {
|
|
218
349
|
const channel = "shared/slack/c1/";
|
|
219
350
|
const thread = `${channel}thread:1.2/`;
|
|
@@ -25,7 +25,11 @@ const server = Bun.serve({
|
|
|
25
25
|
});
|
|
26
26
|
const slackApiUrl = `http://localhost:${server.port}/api/`;
|
|
27
27
|
let token: string | null = null;
|
|
28
|
+
// Spread the real module so a later file in the same process still finds
|
|
29
|
+
// every export (bun keeps module mocks for the whole process).
|
|
30
|
+
const realSlackApp = await import("../slack/app");
|
|
28
31
|
mock.module("../slack/app", () => ({
|
|
32
|
+
...realSlackApp,
|
|
29
33
|
getSlackApp: () => (token ? { client: { token, slackApiUrl } } : null),
|
|
30
34
|
}));
|
|
31
35
|
const { getSlackAppIconUrl } = await import("../slack/app-icon");
|
|
@@ -0,0 +1,236 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A top-level message in a 1:1 DM with the bot is addressed to the bot even
|
|
3
|
+
* without an @-mention. Bolt's Assistant middleware claims only DM messages
|
|
4
|
+
* that carry `thread_ts`, so a top-level DM reaches registerMessageHandler,
|
|
5
|
+
* which used to drop it as `not_addressed` unless it tagged the bot.
|
|
6
|
+
*
|
|
7
|
+
* These tests drive the real message handler and read the delivery outcome.
|
|
8
|
+
*/
|
|
9
|
+
import { afterAll, beforeAll, beforeEach, describe, expect, mock, spyOn, test } from "bun:test";
|
|
10
|
+
import * as dbModule from "../be/db";
|
|
11
|
+
import * as slackEnrichModule from "../slack/enrich";
|
|
12
|
+
import * as slackEventDedupModule from "../slack/event-dedup";
|
|
13
|
+
import { runAdmittedSlackDelivery } from "../slack/inbound-dispatch";
|
|
14
|
+
import * as inboundFilesModule from "../slack/inbound-files";
|
|
15
|
+
import * as siblingAwarenessModule from "../tasks/sibling-awareness";
|
|
16
|
+
|
|
17
|
+
const BOT_USER_ID = "U_BOT_DM_IMPLICIT";
|
|
18
|
+
const OTHER_USER_ID = "U0831BS93V1";
|
|
19
|
+
const LEAD = { id: "lead-dm-implicit-1", name: "TestLead", isLead: true, status: "idle" };
|
|
20
|
+
|
|
21
|
+
const originalEnv = {
|
|
22
|
+
ADDITIVE_SLACK: process.env.ADDITIVE_SLACK,
|
|
23
|
+
SLACK_ALLOWED_EMAIL_DOMAINS: process.env.SLACK_ALLOWED_EMAIL_DOMAINS,
|
|
24
|
+
SLACK_ALLOWED_USER_IDS: process.env.SLACK_ALLOWED_USER_IDS,
|
|
25
|
+
SLACK_RENDER_V2: process.env.SLACK_RENDER_V2,
|
|
26
|
+
SLACK_THREAD_WAKE_ON_ANY_MESSAGE: process.env.SLACK_THREAD_WAKE_ON_ANY_MESSAGE,
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
type MessageEventArg = {
|
|
30
|
+
channel: string;
|
|
31
|
+
channel_type?: string;
|
|
32
|
+
ts: string;
|
|
33
|
+
text?: string;
|
|
34
|
+
user?: string;
|
|
35
|
+
subtype?: string;
|
|
36
|
+
thread_ts?: string;
|
|
37
|
+
files?: Array<{ id: string; name: string; mimetype: string; size: number }>;
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
type HandlerArgs = {
|
|
41
|
+
event: MessageEventArg;
|
|
42
|
+
body: Record<string, unknown>;
|
|
43
|
+
client: typeof mockClient;
|
|
44
|
+
say: (args: unknown) => Promise<void>;
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
const mockClient = {
|
|
48
|
+
auth: { test: async () => ({ user_id: BOT_USER_ID, bot_id: "B_BOT_DM_IMPLICIT" }) },
|
|
49
|
+
conversations: { replies: async () => ({ messages: [], ok: true }) },
|
|
50
|
+
reactions: { add: async () => ({ ok: true }), remove: async () => ({ ok: true }) },
|
|
51
|
+
chat: { postMessage: async () => ({ ok: true }) },
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
let createTaskSpy: any;
|
|
55
|
+
let getAllAgentsSpy: any;
|
|
56
|
+
let fetchSlackFilesSpy: any;
|
|
57
|
+
const spies: any[] = [];
|
|
58
|
+
let handler: (args: HandlerArgs) => Promise<void>;
|
|
59
|
+
let resetCaches: () => void;
|
|
60
|
+
let sequence = 0;
|
|
61
|
+
|
|
62
|
+
function emptyInbound(files: inboundFilesModule.InboundSlackFiles["files"] = []) {
|
|
63
|
+
return {
|
|
64
|
+
files,
|
|
65
|
+
fetched: [],
|
|
66
|
+
failed: [],
|
|
67
|
+
async [Symbol.asyncDispose]() {},
|
|
68
|
+
} as inboundFilesModule.InboundSlackFiles;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
function installSpyImplementations(): void {
|
|
72
|
+
createTaskSpy.mockImplementation(async () => ({ id: "mock-task-dm-implicit" }));
|
|
73
|
+
getAllAgentsSpy.mockImplementation(async () => [LEAD]);
|
|
74
|
+
fetchSlackFilesSpy.mockImplementation(async (_client: unknown, files: unknown) =>
|
|
75
|
+
emptyInbound((files as inboundFilesModule.InboundSlackFiles["files"]) ?? []),
|
|
76
|
+
);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
async function deliver(event: Omit<MessageEventArg, "ts" | "user">) {
|
|
80
|
+
sequence += 1;
|
|
81
|
+
const ts = `2000000002.${String(sequence).padStart(6, "0")}`;
|
|
82
|
+
// A distinct sender per message keeps the per-user rate limit out of play.
|
|
83
|
+
const user = `U_HUMAN_DM_${sequence}`;
|
|
84
|
+
const outcome = await runAdmittedSlackDelivery("socket", () =>
|
|
85
|
+
handler({
|
|
86
|
+
event: { ...event, ts, user },
|
|
87
|
+
body: { event_id: `evt_dm_implicit_${sequence}` },
|
|
88
|
+
client: mockClient,
|
|
89
|
+
say: mock(async () => {}),
|
|
90
|
+
}),
|
|
91
|
+
);
|
|
92
|
+
return { outcome, ts };
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
beforeAll(async () => {
|
|
96
|
+
process.env.ADDITIVE_SLACK = "false";
|
|
97
|
+
process.env.SLACK_RENDER_V2 = "false";
|
|
98
|
+
delete process.env.SLACK_ALLOWED_EMAIL_DOMAINS;
|
|
99
|
+
delete process.env.SLACK_ALLOWED_USER_IDS;
|
|
100
|
+
delete process.env.SLACK_THREAD_WAKE_ON_ANY_MESSAGE;
|
|
101
|
+
|
|
102
|
+
createTaskSpy = spyOn(siblingAwarenessModule, "createTaskWithSiblingAwareness");
|
|
103
|
+
getAllAgentsSpy = spyOn(dbModule, "getAllAgents");
|
|
104
|
+
fetchSlackFilesSpy = spyOn(inboundFilesModule, "fetchSlackFiles");
|
|
105
|
+
spies.push(
|
|
106
|
+
createTaskSpy,
|
|
107
|
+
getAllAgentsSpy,
|
|
108
|
+
fetchSlackFilesSpy,
|
|
109
|
+
spyOn(dbModule, "getAgentWorkingOnThread").mockImplementation(async () => null),
|
|
110
|
+
spyOn(dbModule, "getLeadAgent").mockImplementation(async () => LEAD as any),
|
|
111
|
+
spyOn(dbModule, "getAgentById").mockImplementation(async (id: string) =>
|
|
112
|
+
id === LEAD.id ? (LEAD as any) : null,
|
|
113
|
+
),
|
|
114
|
+
spyOn(dbModule, "getMostRecentTaskInThread").mockImplementation(async () => null),
|
|
115
|
+
spyOn(dbModule, "getTasksByAgentId").mockImplementation(async () => []),
|
|
116
|
+
spyOn(slackEnrichModule, "resolveSlackUserId").mockImplementation(async () => undefined),
|
|
117
|
+
spyOn(slackEnrichModule, "enrichSlackUserEmail").mockImplementation(async () => null),
|
|
118
|
+
spyOn(slackEventDedupModule, "wasEventSeen").mockImplementation(() => false),
|
|
119
|
+
);
|
|
120
|
+
installSpyImplementations();
|
|
121
|
+
|
|
122
|
+
const handlers = await import("../slack/handlers");
|
|
123
|
+
resetCaches = handlers.resetSlackHandlerCachesForTesting;
|
|
124
|
+
resetCaches();
|
|
125
|
+
handlers.registerMessageHandler({
|
|
126
|
+
event: (eventType: string, fn: (args: HandlerArgs) => Promise<void>) => {
|
|
127
|
+
if (eventType === "message") handler = fn;
|
|
128
|
+
},
|
|
129
|
+
} as any);
|
|
130
|
+
});
|
|
131
|
+
|
|
132
|
+
beforeEach(() => {
|
|
133
|
+
for (const spy of spies) spy.mockClear();
|
|
134
|
+
installSpyImplementations();
|
|
135
|
+
});
|
|
136
|
+
|
|
137
|
+
afterAll(() => {
|
|
138
|
+
for (const [key, value] of Object.entries(originalEnv)) {
|
|
139
|
+
if (value === undefined) delete process.env[key];
|
|
140
|
+
else process.env[key] = value;
|
|
141
|
+
}
|
|
142
|
+
mock.restore();
|
|
143
|
+
resetCaches();
|
|
144
|
+
});
|
|
145
|
+
|
|
146
|
+
describe("registerMessageHandler — top-level 1:1 DM is addressed to the bot", () => {
|
|
147
|
+
test("untagged top-level DM creates a Lead task", async () => {
|
|
148
|
+
const { outcome, ts } = await deliver({
|
|
149
|
+
channel: "D_DM_IMPLICIT",
|
|
150
|
+
channel_type: "im",
|
|
151
|
+
text: "Can you check why the nightly digest did not post?",
|
|
152
|
+
});
|
|
153
|
+
|
|
154
|
+
expect(outcome.state).toBe("processed");
|
|
155
|
+
expect(createTaskSpy).toHaveBeenCalledTimes(1);
|
|
156
|
+
const [description, options] = createTaskSpy.mock.calls[0];
|
|
157
|
+
expect(description).toContain("Can you check why the nightly digest did not post?");
|
|
158
|
+
expect(options).toMatchObject({ agentId: LEAD.id, slackTriggerMessageTs: ts });
|
|
159
|
+
});
|
|
160
|
+
|
|
161
|
+
test("untagged top-level DM creates a Lead task when no agent is online", async () => {
|
|
162
|
+
getAllAgentsSpy.mockImplementation(async () => []);
|
|
163
|
+
const { outcome } = await deliver({
|
|
164
|
+
channel: "D_DM_IMPLICIT",
|
|
165
|
+
channel_type: "im",
|
|
166
|
+
text: "Queue this for later please",
|
|
167
|
+
});
|
|
168
|
+
|
|
169
|
+
expect(outcome.state).toBe("processed");
|
|
170
|
+
expect(createTaskSpy).toHaveBeenCalledTimes(1);
|
|
171
|
+
expect(createTaskSpy.mock.calls[0][1]).toMatchObject({ agentId: LEAD.id });
|
|
172
|
+
});
|
|
173
|
+
|
|
174
|
+
test("untagged top-level DM with a file upload plus text creates a task", async () => {
|
|
175
|
+
const { outcome } = await deliver({
|
|
176
|
+
channel: "D_DM_IMPLICIT",
|
|
177
|
+
channel_type: "im",
|
|
178
|
+
subtype: "file_share",
|
|
179
|
+
text: "What is wrong in this screenshot?",
|
|
180
|
+
files: [{ id: "F_DM_IMPLICIT", name: "shot.png", mimetype: "image/png", size: 2048 }],
|
|
181
|
+
});
|
|
182
|
+
|
|
183
|
+
expect(outcome.state).toBe("processed");
|
|
184
|
+
expect(fetchSlackFilesSpy).toHaveBeenCalledTimes(1);
|
|
185
|
+
expect(createTaskSpy).toHaveBeenCalledTimes(1);
|
|
186
|
+
const [description, options] = createTaskSpy.mock.calls[0];
|
|
187
|
+
expect(description).toContain("What is wrong in this screenshot?");
|
|
188
|
+
expect(description).toContain("shot.png");
|
|
189
|
+
expect(options).toMatchObject({ agentId: LEAD.id });
|
|
190
|
+
});
|
|
191
|
+
|
|
192
|
+
test("DM that tags only another user creates no task", async () => {
|
|
193
|
+
const { outcome } = await deliver({
|
|
194
|
+
channel: "D_DM_IMPLICIT",
|
|
195
|
+
channel_type: "im",
|
|
196
|
+
text: `<@${OTHER_USER_ID}> can you take a look?`,
|
|
197
|
+
});
|
|
198
|
+
|
|
199
|
+
expect(outcome).toEqual({ state: "ignored", code: "not_addressed" });
|
|
200
|
+
expect(createTaskSpy).not.toHaveBeenCalled();
|
|
201
|
+
});
|
|
202
|
+
|
|
203
|
+
test("untagged top-level channel message stays not_addressed", async () => {
|
|
204
|
+
const { outcome } = await deliver({
|
|
205
|
+
channel: "C_CHANNEL_IMPLICIT",
|
|
206
|
+
channel_type: "channel",
|
|
207
|
+
text: "Can you check why the nightly digest did not post?",
|
|
208
|
+
});
|
|
209
|
+
|
|
210
|
+
expect(outcome).toEqual({ state: "ignored", code: "not_addressed" });
|
|
211
|
+
expect(createTaskSpy).not.toHaveBeenCalled();
|
|
212
|
+
});
|
|
213
|
+
|
|
214
|
+
test("untagged top-level group DM (mpim) message stays not_addressed", async () => {
|
|
215
|
+
const { outcome } = await deliver({
|
|
216
|
+
channel: "G_MPIM_IMPLICIT",
|
|
217
|
+
channel_type: "mpim",
|
|
218
|
+
text: "Can you check why the nightly digest did not post?",
|
|
219
|
+
});
|
|
220
|
+
|
|
221
|
+
expect(outcome).toEqual({ state: "ignored", code: "not_addressed" });
|
|
222
|
+
expect(createTaskSpy).not.toHaveBeenCalled();
|
|
223
|
+
});
|
|
224
|
+
|
|
225
|
+
test("untagged DM thread reply with no swarm activity stays not_addressed", async () => {
|
|
226
|
+
const { outcome } = await deliver({
|
|
227
|
+
channel: "D_DM_IMPLICIT",
|
|
228
|
+
channel_type: "im",
|
|
229
|
+
thread_ts: "2000000001.000001",
|
|
230
|
+
text: "Following up on this",
|
|
231
|
+
});
|
|
232
|
+
|
|
233
|
+
expect(outcome).toEqual({ state: "ignored", code: "not_addressed" });
|
|
234
|
+
expect(createTaskSpy).not.toHaveBeenCalled();
|
|
235
|
+
});
|
|
236
|
+
});
|
|
@@ -66,6 +66,7 @@ mock.module("../slack/app", () => ({
|
|
|
66
66
|
initSlackApp: async () => null,
|
|
67
67
|
startSlackApp: async () => {},
|
|
68
68
|
stopSlackApp: async () => {},
|
|
69
|
+
stopSlackAppUnderLifecycleLock: async () => {},
|
|
69
70
|
}));
|
|
70
71
|
|
|
71
72
|
function addSlackFile(id: string, name: string, bytes: Uint8Array, path = "files-pri"): SlackFile {
|
|
@@ -42,6 +42,11 @@ import {
|
|
|
42
42
|
resetSlackInboundCountersForTests,
|
|
43
43
|
slackInboundOutcomeMiddleware,
|
|
44
44
|
} from "../slack/inbound-dispatch";
|
|
45
|
+
import {
|
|
46
|
+
getSlackWorkspaceIdentity,
|
|
47
|
+
resetSlackWorkspaceGuardForTests,
|
|
48
|
+
setSlackWorkspaceIdentitySource,
|
|
49
|
+
} from "../slack/workspace-guard";
|
|
45
50
|
|
|
46
51
|
const TEST_DB_PATH = "./test-slack-inbound-receipts.sqlite";
|
|
47
52
|
const testGlobals = globalThis as typeof globalThis & {
|
|
@@ -68,7 +73,14 @@ let channelMessage: Handler;
|
|
|
68
73
|
let followUpSubmit: Handler;
|
|
69
74
|
const resolveSlackUserIdSpy = spyOn(slackEnrichModule, "resolveSlackUserId");
|
|
70
75
|
|
|
71
|
-
beforeAll(() => {
|
|
76
|
+
beforeAll(async () => {
|
|
77
|
+
// The workspace guard fails closed without this swarm's identity.
|
|
78
|
+
setSlackWorkspaceIdentitySource(async () => ({
|
|
79
|
+
teamId: "T_TEST",
|
|
80
|
+
enterpriseId: null,
|
|
81
|
+
isEnterpriseInstall: false,
|
|
82
|
+
}));
|
|
83
|
+
await getSlackWorkspaceIdentity();
|
|
72
84
|
closeDb();
|
|
73
85
|
savedMigrationTemplate = testGlobals.__testMigrationTemplate;
|
|
74
86
|
testGlobals.__testMigrationTemplate = undefined;
|
|
@@ -91,6 +103,7 @@ beforeAll(() => {
|
|
|
91
103
|
});
|
|
92
104
|
|
|
93
105
|
afterAll(() => {
|
|
106
|
+
resetSlackWorkspaceGuardForTests();
|
|
94
107
|
resolveSlackUserIdSpy.mockRestore();
|
|
95
108
|
for (const [key, value] of Object.entries(previousEnv)) {
|
|
96
109
|
if (value === undefined) delete process.env[key];
|
|
@@ -135,12 +148,18 @@ function messageEnvelope(eventId: string, ts: string, text = "<@U_SWARM_BOT> ple
|
|
|
135
148
|
};
|
|
136
149
|
}
|
|
137
150
|
|
|
151
|
+
/** A delivery for the swarm's own workspace (see the identity set in beforeAll). */
|
|
152
|
+
const OWN_BODY = {
|
|
153
|
+
type: "event_callback",
|
|
154
|
+
authorizations: [{ team_id: "T_TEST", enterprise_id: null, is_enterprise_install: false }],
|
|
155
|
+
};
|
|
156
|
+
|
|
138
157
|
/** Mirrors Bolt: the global outcome middleware wraps the listener; Bolt's
|
|
139
158
|
* error handler swallows what the middleware rethrows. */
|
|
140
159
|
async function runThroughBolt(listener: () => Promise<void>): Promise<void> {
|
|
141
160
|
const middleware = slackInboundOutcomeMiddleware();
|
|
142
161
|
try {
|
|
143
|
-
await middleware({ next: listener } as unknown as AnyMiddlewareArgs & {
|
|
162
|
+
await middleware({ next: listener, body: OWN_BODY } as unknown as AnyMiddlewareArgs & {
|
|
144
163
|
next: () => Promise<void>;
|
|
145
164
|
});
|
|
146
165
|
} catch {
|
|
@@ -687,6 +706,7 @@ describe("Socket Mode ingress is unchanged", () => {
|
|
|
687
706
|
const boom = new Error("listener exploded");
|
|
688
707
|
await expect(
|
|
689
708
|
middleware({
|
|
709
|
+
body: OWN_BODY,
|
|
690
710
|
next: async () => {
|
|
691
711
|
noteSlackInboundSideEffect("task_created");
|
|
692
712
|
throw boom;
|
|
@@ -22,7 +22,11 @@ const busyMessages = Array.from({ length: FULL_MESSAGE_COUNT }, (_, index) => ({
|
|
|
22
22
|
ts: `1700000000.${String(index).padStart(6, "0")}`,
|
|
23
23
|
}));
|
|
24
24
|
|
|
25
|
+
// Spread the real module so a later file in the same process still finds
|
|
26
|
+
// every export (bun keeps module mocks for the whole process).
|
|
27
|
+
const realSlackApp = await import("../slack/app");
|
|
25
28
|
mock.module("../slack/app", () => ({
|
|
29
|
+
...realSlackApp,
|
|
26
30
|
getSlackApp: () => ({
|
|
27
31
|
client: {
|
|
28
32
|
auth: { test: async () => ({ user_id: "U_BOT" }) },
|
|
@@ -36,9 +40,6 @@ mock.module("../slack/app", () => ({
|
|
|
36
40
|
},
|
|
37
41
|
},
|
|
38
42
|
}),
|
|
39
|
-
initSlackApp: async () => null,
|
|
40
|
-
startSlackApp: async () => {},
|
|
41
|
-
stopSlackApp: async () => {},
|
|
42
43
|
}));
|
|
43
44
|
|
|
44
45
|
type RegisteredTool = {
|