@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
package/src/http/tasks.ts
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import type { IncomingMessage, ServerResponse } from "node:http";
|
|
2
2
|
import { z } from "zod";
|
|
3
|
-
import { AssetKeyAuthorizationError
|
|
3
|
+
import { AssetKeyAuthorizationError } from "../be/asset-key-auth";
|
|
4
4
|
import { resolveHttpRequesterUserId } from "../be/audit-user";
|
|
5
5
|
import {
|
|
6
6
|
backfillSupersedeTaskResumeTaskId,
|
|
7
7
|
cancelTask,
|
|
8
8
|
completeTask,
|
|
9
|
+
createTaskExtended,
|
|
9
10
|
ExtensionAgentAssignmentError,
|
|
10
11
|
failTask,
|
|
11
12
|
getAgentById,
|
|
@@ -47,6 +48,12 @@ import {
|
|
|
47
48
|
modelProfileRefError,
|
|
48
49
|
taskProfileError,
|
|
49
50
|
} from "../be/db/model-profiles";
|
|
51
|
+
import {
|
|
52
|
+
findAcceptedTaskCreate,
|
|
53
|
+
recordAcceptedTaskCreate,
|
|
54
|
+
type TaskIdempotencyClaim,
|
|
55
|
+
} from "../be/db/task-idempotency";
|
|
56
|
+
import { IdempotencyKeyTakenError, requestFingerprint } from "../be/db/workflow-idempotency";
|
|
50
57
|
import { explicitModelErrorForAgent } from "../be/model-validation";
|
|
51
58
|
import { getUserGrant } from "../be/rbac-roles";
|
|
52
59
|
import { hasSessionAccess, type SessionAccess } from "../be/session-shares";
|
|
@@ -63,7 +70,7 @@ import { can, isRbacEnabled, type RbacPrincipal, type RbacResource } from "../rb
|
|
|
63
70
|
import { mirrorSessionPrompt } from "../slack/session-mirror";
|
|
64
71
|
import { chatThreadOfContextKey } from "../tasks/context-key";
|
|
65
72
|
import { TaskCreationBlockedError, TaskRoutingAuthorizationError } from "../tasks/errors";
|
|
66
|
-
import {
|
|
73
|
+
import { prepareTaskWithSiblingAwareness } from "../tasks/sibling-awareness";
|
|
67
74
|
import { finalizeSkippedTaskReaction, skipReasonFrom } from "../tasks/task-skip";
|
|
68
75
|
import { guardTerminalTaskResultWrite } from "../tasks/terminal-result-guard";
|
|
69
76
|
import {
|
|
@@ -97,13 +104,20 @@ import {
|
|
|
97
104
|
SUPERSEDED_WORKFLOW_TASK_REASON,
|
|
98
105
|
splitLegacyModelAlias,
|
|
99
106
|
TaskAttachmentSchema,
|
|
107
|
+
TaskStatusKindSchema,
|
|
100
108
|
} from "../types";
|
|
101
109
|
import { runTaskUiAction } from "../ui-spec/actions";
|
|
102
110
|
import { ensure } from "../utils/business-use";
|
|
103
111
|
import { getRequestAuth } from "../utils/request-auth-context";
|
|
104
112
|
import { scrubSecrets } from "../utils/secret-scrubber";
|
|
105
113
|
import { normalizeVcsRepo, vcsRepoUrlMatches } from "../utils/vcs-repo-match";
|
|
114
|
+
import { authorizeHttpAssetKeyWrite } from "./asset-key-write";
|
|
106
115
|
import { readsRepoSecrets } from "./config";
|
|
116
|
+
import {
|
|
117
|
+
IDEMPOTENT_REPLAYED_HEADER,
|
|
118
|
+
idempotencyKeyHeader,
|
|
119
|
+
readIdempotencyKey,
|
|
120
|
+
} from "./idempotency-key";
|
|
107
121
|
import { createListTotalCache, LIST_TOTAL_TTL_MS } from "./list-total-cache";
|
|
108
122
|
import {
|
|
109
123
|
agentFirstPrincipal,
|
|
@@ -172,6 +186,7 @@ const AgentTaskSummarySchema = AgentTaskSchema.pick({
|
|
|
172
186
|
createdAt: true,
|
|
173
187
|
lastUpdatedAt: true,
|
|
174
188
|
finishedAt: true,
|
|
189
|
+
statusKind: true,
|
|
175
190
|
peakContextPercent: true,
|
|
176
191
|
totalCostUsd: true,
|
|
177
192
|
});
|
|
@@ -270,6 +285,9 @@ const listTasks = route({
|
|
|
270
285
|
query: z.object({
|
|
271
286
|
/** Single status, or comma-separated list (e.g. "failed,cancelled"). */
|
|
272
287
|
status: z.string().optional(),
|
|
288
|
+
statusKind: TaskStatusKindSchema.optional().describe(
|
|
289
|
+
"Why the task ended, e.g. `status=failed&statusKind=error` (crash, rate limit, exit code) vs `statusKind=agent` (the agent chose to fail). Valid kinds per status: TASK_STATUS_KINDS in src/types.ts.",
|
|
290
|
+
),
|
|
273
291
|
agentId: z.string().optional(),
|
|
274
292
|
scheduleId: z.string().optional(),
|
|
275
293
|
/** Only tasks of this workflow run (indexed; independent of fleet size). */
|
|
@@ -338,6 +356,7 @@ const createTask = route({
|
|
|
338
356
|
rbac: { permission: "task.create.own" },
|
|
339
357
|
summary: "Create a new task",
|
|
340
358
|
tags: ["Tasks"],
|
|
359
|
+
headers: idempotencyKeyHeader("creates one task (a replay returns that task as it is now)"),
|
|
341
360
|
body: z
|
|
342
361
|
.object({
|
|
343
362
|
task: z.string().min(1),
|
|
@@ -401,11 +420,13 @@ const createTask = route({
|
|
|
401
420
|
201: { description: "Task created", schema: AgentTaskSchema },
|
|
402
421
|
400: {
|
|
403
422
|
description:
|
|
404
|
-
"Validation error, an unknown `model` (set `allowCustomModel` to store a custom id), a `vcsRepo` that is not exactly one registered repo,
|
|
423
|
+
"Validation error, an unknown `model` (set `allowCustomModel` to store a custom id), a `vcsRepo` that is not exactly one registered repo, agentId/offeredTo targets an extension identity, or a malformed Idempotency-Key",
|
|
405
424
|
},
|
|
425
|
+
409: { description: "Idempotency-Key was already used for a different request" },
|
|
426
|
+
410: { description: "The task created under this Idempotency-Key was deleted" },
|
|
406
427
|
403: {
|
|
407
428
|
description:
|
|
408
|
-
"Parent/session access denied, unauthorized chat-thread binding,
|
|
429
|
+
"Parent/session access denied, unauthorized chat-thread binding, routing requirements reject the assignment, or an Idempotency-Key replay of a task whose session the caller can no longer read",
|
|
409
430
|
},
|
|
410
431
|
422: {
|
|
411
432
|
description: "Task creation blocked by an extension",
|
|
@@ -1095,6 +1116,7 @@ export async function handleTasks(
|
|
|
1095
1116
|
});
|
|
1096
1117
|
const filters = {
|
|
1097
1118
|
status,
|
|
1119
|
+
statusKind: parsed.query.statusKind,
|
|
1098
1120
|
agentId: parsed.query.agentId || undefined,
|
|
1099
1121
|
scheduleId: parsed.query.scheduleId || undefined,
|
|
1100
1122
|
workflowRunId: parsed.query.workflowRunId,
|
|
@@ -1136,8 +1158,38 @@ export async function handleTasks(
|
|
|
1136
1158
|
}
|
|
1137
1159
|
|
|
1138
1160
|
if (createTask.match(req.method, pathSegments)) {
|
|
1161
|
+
const idempotency = readIdempotencyKey(req, res, myAgentId);
|
|
1162
|
+
if (idempotency === null) return true;
|
|
1139
1163
|
const parsed = await createTask.parse(req, res, pathSegments, queryParams);
|
|
1140
1164
|
if (!parsed) return true;
|
|
1165
|
+
const claim: TaskIdempotencyClaim | undefined = idempotency && {
|
|
1166
|
+
...idempotency,
|
|
1167
|
+
fingerprint: requestFingerprint("task.create", parsed.body),
|
|
1168
|
+
};
|
|
1169
|
+
// Answer from the task this key already created, if any. Before the
|
|
1170
|
+
// routing and create checks: the key is scoped to this caller, and a retry
|
|
1171
|
+
// gets the original task even if the same request would no longer pass.
|
|
1172
|
+
// The replay returns the task as it is now (output included), so it needs
|
|
1173
|
+
// the same session read access as GET /api/tasks/{id}: a revoked share
|
|
1174
|
+
// must not keep reading the task through its old key.
|
|
1175
|
+
const replayCreate = async (): Promise<boolean> => {
|
|
1176
|
+
const accepted = claim && (await findAcceptedTaskCreate(claim));
|
|
1177
|
+
if (!accepted) return false;
|
|
1178
|
+
const task =
|
|
1179
|
+
accepted.fingerprint === claim.fingerprint ? await getTaskById(accepted.taskId) : null;
|
|
1180
|
+
if (accepted.fingerprint !== claim.fingerprint) {
|
|
1181
|
+
jsonError(res, "Idempotency-Key was already used for a different request", 409);
|
|
1182
|
+
} else if (!task) {
|
|
1183
|
+
jsonError(res, "The task this Idempotency-Key created was deleted", 410);
|
|
1184
|
+
} else if (!(await canReadSession(req, myAgentId, task.id))) {
|
|
1185
|
+
jsonError(res, SESSION_READ_DENIED, 403);
|
|
1186
|
+
} else {
|
|
1187
|
+
res.setHeader(IDEMPOTENT_REPLAYED_HEADER, "true");
|
|
1188
|
+
createTask.respond(res, 201, task);
|
|
1189
|
+
}
|
|
1190
|
+
return true;
|
|
1191
|
+
};
|
|
1192
|
+
if (await replayCreate()) return true;
|
|
1141
1193
|
|
|
1142
1194
|
// Trusted identity first, then the body hint; see resolveTaskRequester.
|
|
1143
1195
|
const trustedUserId = await resolveHttpRequesterUserId(req, myAgentId);
|
|
@@ -1240,7 +1292,7 @@ export async function handleTasks(
|
|
|
1240
1292
|
const inheritedKey = parentTask?.key;
|
|
1241
1293
|
const requestedKey = parsed.body.key ?? inheritedKey;
|
|
1242
1294
|
assetKey = requestedKey
|
|
1243
|
-
? await
|
|
1295
|
+
? await authorizeHttpAssetKeyWrite(req, myAgentId, requestedKey, trustedUserId)
|
|
1244
1296
|
: undefined;
|
|
1245
1297
|
} catch (error) {
|
|
1246
1298
|
if (error instanceof AssetKeyAuthorizationError) {
|
|
@@ -1251,7 +1303,7 @@ export async function handleTasks(
|
|
|
1251
1303
|
}
|
|
1252
1304
|
|
|
1253
1305
|
try {
|
|
1254
|
-
const
|
|
1306
|
+
const prepared = await prepareTaskWithSiblingAwareness(
|
|
1255
1307
|
parsed.body.task,
|
|
1256
1308
|
{
|
|
1257
1309
|
key: assetKey,
|
|
@@ -1300,6 +1352,17 @@ export async function handleTasks(
|
|
|
1300
1352
|
},
|
|
1301
1353
|
{ origin: "rest", allowCustomModel: parsed.body.allowCustomModel },
|
|
1302
1354
|
);
|
|
1355
|
+
// Extension pre-hooks ran above, outside the transaction; the key record
|
|
1356
|
+
// commits with the task, so a rollback drops both.
|
|
1357
|
+
const task = claim
|
|
1358
|
+
? await getDbClient().transaction(async () => {
|
|
1359
|
+
// A concurrent request with this key committed while this one got ready.
|
|
1360
|
+
if (await findAcceptedTaskCreate(claim)) throw new IdempotencyKeyTakenError();
|
|
1361
|
+
const created = await createTaskExtended(prepared.description, prepared.options);
|
|
1362
|
+
await recordAcceptedTaskCreate(claim, created.id);
|
|
1363
|
+
return created;
|
|
1364
|
+
})
|
|
1365
|
+
: await createTaskExtended(prepared.description, prepared.options);
|
|
1303
1366
|
|
|
1304
1367
|
ensure({
|
|
1305
1368
|
id: "created",
|
|
@@ -1324,6 +1387,8 @@ export async function handleTasks(
|
|
|
1324
1387
|
|
|
1325
1388
|
createTask.respond(res, 201, task);
|
|
1326
1389
|
} catch (error) {
|
|
1390
|
+
// A concurrent request with this key committed first; nothing of this one did.
|
|
1391
|
+
if (error instanceof IdempotencyKeyTakenError && (await replayCreate())) return true;
|
|
1327
1392
|
if (error instanceof TaskRoutingAuthorizationError) {
|
|
1328
1393
|
console.warn(
|
|
1329
1394
|
"[HTTP] Task assignment rejected:",
|
|
@@ -1395,16 +1460,36 @@ export async function handleTasks(
|
|
|
1395
1460
|
if (updateSession.match(req.method, pathSegments)) {
|
|
1396
1461
|
const parsed = await updateSession.parse(req, res, pathSegments, queryParams);
|
|
1397
1462
|
if (!parsed) return true;
|
|
1398
|
-
const
|
|
1399
|
-
|
|
1400
|
-
|
|
1401
|
-
|
|
1402
|
-
|
|
1403
|
-
|
|
1404
|
-
|
|
1405
|
-
|
|
1406
|
-
|
|
1407
|
-
|
|
1463
|
+
const auth = getRequestAuth(req);
|
|
1464
|
+
// An agent session token writes only its own task's session: a task token
|
|
1465
|
+
// its bound task, any other agent token a task its agent holds. The holder is
|
|
1466
|
+
// the offeree while a task is offered or in review (its review session), else
|
|
1467
|
+
// strictly the assignee, so a stale offer never grants a write.
|
|
1468
|
+
// Check and write in one transaction so a reassignment cannot slip between.
|
|
1469
|
+
const task = await getDbClient().transaction(async () => {
|
|
1470
|
+
if (auth?.kind === "agent") {
|
|
1471
|
+
if (auth.taskId !== null && auth.taskId !== parsed.params.id) return "forbidden";
|
|
1472
|
+
const existing = await getTaskById(parsed.params.id);
|
|
1473
|
+
if (!existing) return null;
|
|
1474
|
+
const offerOpen = existing.status === "offered" || existing.status === "reviewing";
|
|
1475
|
+
const holder = offerOpen ? existing.offeredTo : existing.agentId;
|
|
1476
|
+
if (holder !== auth.agentId) return "forbidden";
|
|
1477
|
+
}
|
|
1478
|
+
return await updateTaskClaudeSessionId(
|
|
1479
|
+
parsed.params.id,
|
|
1480
|
+
parsed.body.claudeSessionId,
|
|
1481
|
+
parsed.body.provider,
|
|
1482
|
+
parsed.body.providerMeta,
|
|
1483
|
+
parsed.body.model,
|
|
1484
|
+
"harnessVariant" in parsed.body ? parsed.body.harnessVariant : undefined,
|
|
1485
|
+
"harnessVariantMeta" in parsed.body ? parsed.body.harnessVariantMeta : undefined,
|
|
1486
|
+
"effort" in parsed.body ? parsed.body.effort : undefined,
|
|
1487
|
+
);
|
|
1488
|
+
});
|
|
1489
|
+
if (task === "forbidden") {
|
|
1490
|
+
jsonError(res, "Task belongs to another token agent", 403);
|
|
1491
|
+
return true;
|
|
1492
|
+
}
|
|
1408
1493
|
if (!task) {
|
|
1409
1494
|
jsonError(res, "Task not found", 404);
|
|
1410
1495
|
return true;
|
|
@@ -1466,7 +1551,12 @@ export async function handleTasks(
|
|
|
1466
1551
|
}
|
|
1467
1552
|
}
|
|
1468
1553
|
|
|
1469
|
-
|
|
1554
|
+
// Who cancelled comes from the resolved principal, never the body: an agent
|
|
1555
|
+
// (X-Agent-ID, including ctx.swarm.task_cancel) records `agent`, as MCP
|
|
1556
|
+
// cancel-task does; the dashboard and operator record `user`.
|
|
1557
|
+
const cancelledTask = await cancelTask(parsed.params.id, reason, {
|
|
1558
|
+
statusKind: principal.kind === "agent" ? "agent" : "user",
|
|
1559
|
+
});
|
|
1470
1560
|
if (!cancelledTask) {
|
|
1471
1561
|
jsonError(res, "Failed to cancel task", 500);
|
|
1472
1562
|
return true;
|
|
@@ -1957,21 +2047,25 @@ export async function handleTasks(
|
|
|
1957
2047
|
const result = await completeTask(
|
|
1958
2048
|
parsed.params.id,
|
|
1959
2049
|
parsed.body.output || "Completed by runner wrapper (no explicit output)",
|
|
2050
|
+
{ statusKind: "runner" },
|
|
1960
2051
|
);
|
|
1961
2052
|
if (!result) {
|
|
1962
2053
|
return { error: "Failed to complete task", status: 500 };
|
|
1963
2054
|
}
|
|
1964
2055
|
updatedTask = result;
|
|
1965
2056
|
} else if (parsed.body.status === "skipped") {
|
|
1966
|
-
const result = await skipTask(parsed.params.id, skipReason
|
|
2057
|
+
const result = await skipTask(parsed.params.id, skipReason!, { statusKind: "runner" });
|
|
1967
2058
|
if (!result) {
|
|
1968
2059
|
return { error: "Failed to mark task as skipped", status: 500 };
|
|
1969
2060
|
}
|
|
1970
2061
|
updatedTask = result;
|
|
1971
2062
|
} else {
|
|
2063
|
+
// The runner posts `failed` for a crash, a non-zero exit, a provider
|
|
2064
|
+
// error or an output-schema parse failure: none is the agent's call.
|
|
1972
2065
|
const result = await failTask(
|
|
1973
2066
|
parsed.params.id,
|
|
1974
2067
|
parsed.body.failureReason || "Process exited without explicit completion",
|
|
2068
|
+
{ statusKind: "error" },
|
|
1975
2069
|
);
|
|
1976
2070
|
if (!result) {
|
|
1977
2071
|
return { error: "Failed to mark task as failed", status: 500 };
|
|
@@ -2402,7 +2496,9 @@ export async function handleTasks(
|
|
|
2402
2496
|
// `task.failed`. Once it queues the step's retry it moves the task to
|
|
2403
2497
|
// `superseded` itself (`scheduleTaskStepRetry`).
|
|
2404
2498
|
if (task.workflowRunStepId != null) {
|
|
2405
|
-
const failed = await failTask(parsed.params.id, SUPERSEDED_WORKFLOW_TASK_REASON
|
|
2499
|
+
const failed = await failTask(parsed.params.id, SUPERSEDED_WORKFLOW_TASK_REASON, {
|
|
2500
|
+
statusKind: "error",
|
|
2501
|
+
});
|
|
2406
2502
|
if (task.agentId) {
|
|
2407
2503
|
await updateAgentStatusFromCapacity(task.agentId);
|
|
2408
2504
|
}
|
|
@@ -12,7 +12,9 @@ import { getJiraAuthorizationUrl } from "../../jira/oauth";
|
|
|
12
12
|
import { handleJiraWebhook } from "../../jira/webhook";
|
|
13
13
|
import { deleteJiraWebhook, registerJiraWebhook } from "../../jira/webhook-lifecycle";
|
|
14
14
|
import { forceRefreshAuthorizationOrThrow } from "../../oauth/ensure-token";
|
|
15
|
+
import { requestSecretReadScope } from "../config";
|
|
15
16
|
import { completeGenericOAuthCallback } from "../oauth-callback";
|
|
17
|
+
import { refuseAgentTokenWithout } from "../request-principal";
|
|
16
18
|
import { route } from "../route-def";
|
|
17
19
|
import { allowedCredentialRedirect, deriveApiBaseUrl, parseQueryParams } from "../utils";
|
|
18
20
|
import {
|
|
@@ -185,6 +187,7 @@ const jiraWebhookRegister = route({
|
|
|
185
187
|
body: z.object({
|
|
186
188
|
jqlFilter: z.string().min(1),
|
|
187
189
|
}),
|
|
190
|
+
rbac: { permission: "oauth-authorization.manage" },
|
|
188
191
|
responses: {
|
|
189
192
|
200: { description: "Webhook registered", schema: JiraWebhookRegisteredSchema },
|
|
190
193
|
400: { description: "Invalid jqlFilter" },
|
|
@@ -203,6 +206,7 @@ const jiraWebhookDelete = route({
|
|
|
203
206
|
params: z.object({
|
|
204
207
|
id: z.coerce.number().int().positive(),
|
|
205
208
|
}),
|
|
209
|
+
rbac: { permission: "oauth-authorization.manage" },
|
|
206
210
|
responses: {
|
|
207
211
|
200: { description: "Webhook deleted", schema: JiraWebhookDeletedSchema },
|
|
208
212
|
400: { description: "Invalid webhook id" },
|
|
@@ -220,6 +224,7 @@ const jiraDisconnect = route({
|
|
|
220
224
|
pattern: ["api", "trackers", "jira", "disconnect"],
|
|
221
225
|
summary: "Fully disconnect Jira: delete all webhooks, drop tokens, clear metadata",
|
|
222
226
|
tags: ["Trackers"],
|
|
227
|
+
rbac: { permission: "oauth-authorization.manage" },
|
|
223
228
|
responses: {
|
|
224
229
|
200: { description: "Disconnected", schema: JiraDisconnectResultSchema },
|
|
225
230
|
503: { description: "Jira not configured" },
|
|
@@ -228,8 +233,15 @@ const jiraDisconnect = route({
|
|
|
228
233
|
|
|
229
234
|
// ─── Helpers ─────────────────────────────────────────────────────────────────
|
|
230
235
|
|
|
231
|
-
|
|
232
|
-
|
|
236
|
+
// The path token is the only credential of the inbound Jira webhook. Only a
|
|
237
|
+
// caller that may read every config secret gets it; everyone else sees a mask.
|
|
238
|
+
async function getWebhookUrl(req: IncomingMessage): Promise<string> {
|
|
239
|
+
const configured = process.env.JIRA_WEBHOOK_TOKEN;
|
|
240
|
+
const token = !configured
|
|
241
|
+
? "<unset>"
|
|
242
|
+
: (await requestSecretReadScope(req)) === "all"
|
|
243
|
+
? configured
|
|
244
|
+
: "<redacted>";
|
|
233
245
|
return `${deriveApiBaseUrl(req)}/api/trackers/jira/webhook/${token}`;
|
|
234
246
|
}
|
|
235
247
|
|
|
@@ -259,7 +271,7 @@ async function buildJiraStatusPayload(req: IncomingMessage): Promise<JiraStatusP
|
|
|
259
271
|
scope,
|
|
260
272
|
hasManageWebhookScope,
|
|
261
273
|
webhookTokenConfigured: Boolean(process.env.JIRA_WEBHOOK_TOKEN),
|
|
262
|
-
webhookUrl: getWebhookUrl(req),
|
|
274
|
+
webhookUrl: await getWebhookUrl(req),
|
|
263
275
|
redirectUri: getRedirectUri(req),
|
|
264
276
|
webhookIds: meta.webhookIds ?? [],
|
|
265
277
|
};
|
|
@@ -430,6 +442,7 @@ export async function handleJiraTracker(
|
|
|
430
442
|
|
|
431
443
|
// POST /api/trackers/jira/webhook-register — admin: register a dynamic webhook.
|
|
432
444
|
if (jiraWebhookRegister.match(req.method, pathSegments)) {
|
|
445
|
+
if (await refuseAgentTokenWithout(req, res, "oauth-authorization.manage")) return true;
|
|
433
446
|
if (!isJiraEnabled()) {
|
|
434
447
|
res.writeHead(503, { "Content-Type": "application/json" });
|
|
435
448
|
res.end(JSON.stringify({ error: "Jira integration not configured" }));
|
|
@@ -461,6 +474,7 @@ export async function handleJiraTracker(
|
|
|
461
474
|
// Note: this pattern overlaps the POST /webhook/:token path; the matcher
|
|
462
475
|
// disambiguates by HTTP method.
|
|
463
476
|
if (jiraWebhookDelete.match(req.method, pathSegments)) {
|
|
477
|
+
if (await refuseAgentTokenWithout(req, res, "oauth-authorization.manage")) return true;
|
|
464
478
|
if (!isJiraEnabled()) {
|
|
465
479
|
res.writeHead(503, { "Content-Type": "application/json" });
|
|
466
480
|
res.end(JSON.stringify({ error: "Jira integration not configured" }));
|
|
@@ -485,6 +499,7 @@ export async function handleJiraTracker(
|
|
|
485
499
|
|
|
486
500
|
// DELETE /api/trackers/jira/disconnect — full cleanup.
|
|
487
501
|
if (jiraDisconnect.match(req.method, pathSegments)) {
|
|
502
|
+
if (await refuseAgentTokenWithout(req, res, "oauth-authorization.manage")) return true;
|
|
488
503
|
if (!isJiraEnabled()) {
|
|
489
504
|
res.writeHead(503, { "Content-Type": "application/json" });
|
|
490
505
|
res.end(JSON.stringify({ error: "Jira integration not configured" }));
|
|
@@ -11,6 +11,7 @@ import { getLinearAuthorizationUrl, revokeLinearToken } from "../../linear/oauth
|
|
|
11
11
|
import { handleLinearWebhook } from "../../linear/webhook";
|
|
12
12
|
import { forceRefreshAuthorizationOrThrow } from "../../oauth/ensure-token";
|
|
13
13
|
import { completeGenericOAuthCallback } from "../oauth-callback";
|
|
14
|
+
import { refuseAgentTokenWithout } from "../request-principal";
|
|
14
15
|
import { route } from "../route-def";
|
|
15
16
|
import { allowedCredentialRedirect, deriveApiBaseUrl, parseQueryParams } from "../utils";
|
|
16
17
|
import {
|
|
@@ -141,6 +142,7 @@ const linearDisconnect = route({
|
|
|
141
142
|
pattern: ["api", "trackers", "linear", "disconnect"],
|
|
142
143
|
summary: "Fully disconnect Linear: revoke OAuth grant + drop tokens",
|
|
143
144
|
tags: ["Trackers"],
|
|
145
|
+
rbac: { permission: "oauth-authorization.manage" },
|
|
144
146
|
responses: {
|
|
145
147
|
200: { description: "Disconnected", schema: LinearDisconnectSchema },
|
|
146
148
|
503: { description: "Linear not configured" },
|
|
@@ -309,6 +311,7 @@ export async function handleLinearTracker(
|
|
|
309
311
|
|
|
310
312
|
// DELETE /api/trackers/linear/disconnect — full cleanup.
|
|
311
313
|
if (linearDisconnect.match(req.method, pathSegments)) {
|
|
314
|
+
if (await refuseAgentTokenWithout(req, res, "oauth-authorization.manage")) return true;
|
|
312
315
|
if (!isLinearEnabled()) {
|
|
313
316
|
res.writeHead(503, { "Content-Type": "application/json" });
|
|
314
317
|
res.end(JSON.stringify({ error: "Linear integration not configured" }));
|
package/src/http/users.ts
CHANGED
|
@@ -94,6 +94,7 @@ import {
|
|
|
94
94
|
} from "../be/users";
|
|
95
95
|
import { isRbacEnabled } from "../rbac";
|
|
96
96
|
import {
|
|
97
|
+
UserAvatarSchema,
|
|
97
98
|
UserCommsPrefsSchema,
|
|
98
99
|
UserMergeJobSchema,
|
|
99
100
|
UserMergeJobStatusSchema,
|
|
@@ -285,6 +286,7 @@ const createUserRoute = route({
|
|
|
285
286
|
metadata: z.record(z.string(), z.unknown()).optional(),
|
|
286
287
|
dailyBudgetUsd: z.number().nullable().optional(),
|
|
287
288
|
status: z.enum(["invited", "active", "suspended"]).optional(),
|
|
289
|
+
avatar: UserAvatarSchema.nullable().optional(),
|
|
288
290
|
identities: z
|
|
289
291
|
.array(z.object({ kind: z.string().min(1), externalId: z.string().min(1) }))
|
|
290
292
|
.optional(),
|
|
@@ -445,6 +447,8 @@ const updateUserRoute = route({
|
|
|
445
447
|
),
|
|
446
448
|
dailyBudgetUsd: z.number().nullable().optional(),
|
|
447
449
|
status: z.enum(["invited", "active", "suspended"]).optional(),
|
|
450
|
+
// null resets to the initials avatar.
|
|
451
|
+
avatar: UserAvatarSchema.nullable().optional(),
|
|
448
452
|
// Complete-list diff: passing this replaces the user's identity set,
|
|
449
453
|
// emitting `identity_added` / `identity_removed` for each delta.
|
|
450
454
|
identities: z
|
|
@@ -1865,6 +1869,7 @@ export async function handleUsers(
|
|
|
1865
1869
|
"preferredChannel",
|
|
1866
1870
|
"notes",
|
|
1867
1871
|
"metadata",
|
|
1872
|
+
"avatar",
|
|
1868
1873
|
] as const;
|
|
1869
1874
|
for (const field of PROFILE_FIELDS) {
|
|
1870
1875
|
if (parsed.body[field] === undefined) continue;
|
package/src/http/webhooks.ts
CHANGED
|
@@ -94,6 +94,7 @@ import type { KapsoConfig } from "../integrations/kapso/config";
|
|
|
94
94
|
import { getKapsoConfig } from "../integrations/kapso/config";
|
|
95
95
|
import type { KapsoWebhookPayload } from "../integrations/kapso/inbound";
|
|
96
96
|
import { resolveKapsoRequestedByUserId, routeKapsoInbound } from "../integrations/kapso/inbound";
|
|
97
|
+
import { hasPendingEventWait } from "../scheduler/deferred-task-waits";
|
|
97
98
|
import { TaskCreationBlockedError } from "../tasks/errors";
|
|
98
99
|
import { getPublicMcpBaseUrl } from "../utils/constants";
|
|
99
100
|
import { resolveGitHubHost } from "../utils/github-host";
|
|
@@ -440,7 +441,13 @@ export async function handleWebhooks(
|
|
|
440
441
|
|
|
441
442
|
// Early ack: events nothing handles (check_run, workflow_run, push, ...) change
|
|
442
443
|
// no state, so skip the body read, HMAC and parse, and drain the body in the background.
|
|
443
|
-
|
|
444
|
+
// check_run is read only while some agent waits on vcs.pr.checks_done.
|
|
445
|
+
if (
|
|
446
|
+
typeof eventType === "string" &&
|
|
447
|
+
eventType &&
|
|
448
|
+
!GITHUB_VERIFIED_EVENTS.has(eventType) &&
|
|
449
|
+
!(eventType === "check_run" && (await hasPendingEventWait("github", "vcs.pr.checks_done")))
|
|
450
|
+
) {
|
|
444
451
|
countGithubIgnoredEvent(eventType);
|
|
445
452
|
githubWebhook.respond(res, 200, { created: false });
|
|
446
453
|
req.resume();
|
|
@@ -556,6 +563,17 @@ export async function handleWebhooks(
|
|
|
556
563
|
});
|
|
557
564
|
break;
|
|
558
565
|
}
|
|
566
|
+
case "check_run": {
|
|
567
|
+
const cr = body as CheckRunEvent;
|
|
568
|
+
workflowEventBus.emit(`github.check_run.${cr.action}`, {
|
|
569
|
+
repo: cr.repository.full_name,
|
|
570
|
+
name: cr.check_run.name,
|
|
571
|
+
headSha: cr.check_run.check_suite?.head_sha,
|
|
572
|
+
conclusion: cr.check_run.conclusion,
|
|
573
|
+
pullRequests: (cr.check_run.pull_requests ?? []).map((pr) => pr.number),
|
|
574
|
+
});
|
|
575
|
+
break;
|
|
576
|
+
}
|
|
559
577
|
case "pull_request_review": {
|
|
560
578
|
const prr = body as PullRequestReviewEvent;
|
|
561
579
|
workflowEventBus.emit("github.pull_request_review.submitted", {
|
package/src/http/workflows.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { IncomingMessage, ServerResponse } from "node:http";
|
|
2
2
|
import { z } from "zod";
|
|
3
|
-
import { AssetKeyAuthorizationError
|
|
3
|
+
import { AssetKeyAuthorizationError } from "../be/asset-key-auth";
|
|
4
4
|
import { resolveHttpAuditUserId, resolveHttpRequesterUserId } from "../be/audit-user";
|
|
5
5
|
import {
|
|
6
6
|
createWorkflow,
|
|
@@ -62,6 +62,7 @@ import { workflowSaveWarnings } from "../workflows/readiness";
|
|
|
62
62
|
import { cancelWorkflowRun, retryFailedRun } from "../workflows/resume";
|
|
63
63
|
import { handleWebhookTrigger, WebhookError } from "../workflows/triggers";
|
|
64
64
|
import { snapshotAndUpdateWorkflow } from "../workflows/version";
|
|
65
|
+
import { authorizeHttpAssetKeyWrite } from "./asset-key-write";
|
|
65
66
|
import { requestSecretReadScope } from "./config";
|
|
66
67
|
import { resolveHttpFavoriteOwner } from "./favorite-owner";
|
|
67
68
|
import {
|
|
@@ -737,7 +738,7 @@ export async function handleWorkflows(
|
|
|
737
738
|
let key: string | undefined;
|
|
738
739
|
try {
|
|
739
740
|
key = parsed.body.key
|
|
740
|
-
? await
|
|
741
|
+
? await authorizeHttpAssetKeyWrite(req, myAgentId, parsed.body.key, trustedUserId)
|
|
741
742
|
: undefined;
|
|
742
743
|
} catch (error) {
|
|
743
744
|
if (error instanceof AssetKeyAuthorizationError) {
|
|
@@ -867,10 +868,7 @@ export async function handleWorkflows(
|
|
|
867
868
|
const updateArgs: Omit<Parameters<typeof updateWorkflow>[1], "definition"> = {};
|
|
868
869
|
if (parsed.body.key !== undefined) {
|
|
869
870
|
try {
|
|
870
|
-
updateArgs.key = await
|
|
871
|
-
parsed.body.key,
|
|
872
|
-
await resolveHttpRequesterUserId(req, myAgentId),
|
|
873
|
-
);
|
|
871
|
+
updateArgs.key = await authorizeHttpAssetKeyWrite(req, myAgentId, parsed.body.key);
|
|
874
872
|
} catch (error) {
|
|
875
873
|
if (error instanceof AssetKeyAuthorizationError) {
|
|
876
874
|
jsonError(res, error.message, error.statusCode);
|
|
@@ -980,10 +978,7 @@ export async function handleWorkflows(
|
|
|
980
978
|
let key: string | undefined;
|
|
981
979
|
if (body.key !== undefined) {
|
|
982
980
|
try {
|
|
983
|
-
key = await
|
|
984
|
-
body.key,
|
|
985
|
-
await resolveHttpRequesterUserId(req, myAgentId),
|
|
986
|
-
);
|
|
981
|
+
key = await authorizeHttpAssetKeyWrite(req, myAgentId, body.key);
|
|
987
982
|
} catch (error) {
|
|
988
983
|
if (error instanceof AssetKeyAuthorizationError) {
|
|
989
984
|
jsonError(res, error.message, error.statusCode);
|
|
@@ -163,7 +163,9 @@ async function cancelActiveTasks(
|
|
|
163
163
|
for (let i = 0; i < CANCEL_LIMIT; i++) {
|
|
164
164
|
const active = await getLatestActiveTaskByContextKey(contextKey, "chat", target.owner);
|
|
165
165
|
if (!active) break;
|
|
166
|
-
const task = await cancelTask(active.id, `Cancelled from chat by ${requestedBy}
|
|
166
|
+
const task = await cancelTask(active.id, `Cancelled from chat by ${requestedBy}`, {
|
|
167
|
+
statusKind: "user",
|
|
168
|
+
});
|
|
167
169
|
if (!task) break;
|
|
168
170
|
if (task.agentId) await updateAgentStatusFromCapacity(task.agentId);
|
|
169
171
|
cancelled.push(task);
|
package/src/jira/sync.ts
CHANGED
|
@@ -531,7 +531,7 @@ export async function handleIssueDeleteEvent(event: Record<string, unknown>): Pr
|
|
|
531
531
|
|
|
532
532
|
const task = sync.swarmId ? await getTaskById(sync.swarmId) : null;
|
|
533
533
|
if (task && !isTerminalTaskStatus(task.status)) {
|
|
534
|
-
await cancelTask(sync.swarmId, "Jira issue deleted");
|
|
534
|
+
await cancelTask(sync.swarmId, "Jira issue deleted", { statusKind: "external" });
|
|
535
535
|
console.log(
|
|
536
536
|
`[Jira Sync] Cancelled task ${sync.swarmId} (Jira issue ${issue.key ?? issue.id} deleted)`,
|
|
537
537
|
);
|
package/src/kv-limits.ts
ADDED
|
@@ -1,10 +1,14 @@
|
|
|
1
|
+
import { scrubObject } from "./utils/secret-scrubber";
|
|
2
|
+
|
|
1
3
|
/**
|
|
2
4
|
* Namespace families owned by internal subsystems which write through the raw
|
|
3
5
|
* DB helpers. Generic HTTP/MCP KV callers may read these namespaces for
|
|
4
6
|
* inspection, but must not mutate them. A family is `<name>` and `<name>:*`,
|
|
5
|
-
* mapped here to the error a generic write gets.
|
|
7
|
+
* mapped here to the error a generic write gets. A name may span segments
|
|
8
|
+
* (`integrations:kapso`), so its siblings under `integrations:` stay writable.
|
|
6
9
|
*/
|
|
7
10
|
const RESERVED_FAMILIES = new Map([
|
|
11
|
+
["durable", "namespace holds durable object state; it is written only by object calls"],
|
|
8
12
|
["apps", "namespace is reserved for swarm apps; use the app row endpoints"],
|
|
9
13
|
// step-9: Comb's "Send to swarm" claims (`comb:sent`).
|
|
10
14
|
["comb", "namespace is reserved for Comb; use POST /api/comb/review-batches"],
|
|
@@ -26,6 +30,17 @@ const RESERVED_FAMILIES = new Map([
|
|
|
26
30
|
"session-labels",
|
|
27
31
|
"namespace is reserved for session source labels; GET /api/session-tree returns them",
|
|
28
32
|
],
|
|
33
|
+
// Slack profile emails read from users.info (src/slack/enrich.ts). They decide the
|
|
34
|
+
// email-domain allowlist and the Slack-to-user auto-link, so only the API writes them.
|
|
35
|
+
[
|
|
36
|
+
"integration:user-enrichment",
|
|
37
|
+
"namespace is reserved for integration profile enrichment; the API writes it from the provider",
|
|
38
|
+
],
|
|
39
|
+
// Kapso number routing and inbound dedupe (src/integrations/kapso/config.ts).
|
|
40
|
+
[
|
|
41
|
+
"integrations:kapso",
|
|
42
|
+
"namespace is reserved for Kapso routing; use register-kapso-number or unregister-kapso-number",
|
|
43
|
+
],
|
|
29
44
|
]);
|
|
30
45
|
|
|
31
46
|
/**
|
|
@@ -53,7 +68,10 @@ export function isReservedNamespace(namespace: string): boolean {
|
|
|
53
68
|
}
|
|
54
69
|
|
|
55
70
|
export function reservedNamespaceError(namespace: string): string | null {
|
|
56
|
-
|
|
71
|
+
for (const [family, error] of RESERVED_FAMILIES) {
|
|
72
|
+
if (namespace === family || namespace.startsWith(`${family}:`)) return error;
|
|
73
|
+
}
|
|
74
|
+
return null;
|
|
57
75
|
}
|
|
58
76
|
|
|
59
77
|
/** The error a generic KV read of a private family gets, or null. */
|
|
@@ -68,3 +86,8 @@ export function reservedRoomKeyError(key: string): string | null {
|
|
|
68
86
|
? "room snapshot keys are reserved; use the room endpoints"
|
|
69
87
|
: null;
|
|
70
88
|
}
|
|
89
|
+
|
|
90
|
+
/** Scrub durable state before generic KV reads return it. */
|
|
91
|
+
export function scrubReservedRead(namespace: string, value: unknown): unknown {
|
|
92
|
+
return namespace.split(":", 1)[0] === "durable" ? scrubObject(value) : value;
|
|
93
|
+
}
|
package/src/linear/sync.ts
CHANGED
|
@@ -774,7 +774,7 @@ export async function handleIssueUpdate(
|
|
|
774
774
|
if (swarmStatus === "cancelled") {
|
|
775
775
|
const task = await getTaskById(sync.swarmId);
|
|
776
776
|
if (task && !isTerminalTaskStatus(task.status)) {
|
|
777
|
-
await cancelTask(sync.swarmId, `Linear issue cancelled
|
|
777
|
+
await cancelTask(sync.swarmId, `Linear issue cancelled`, { statusKind: "external" });
|
|
778
778
|
console.log(
|
|
779
779
|
`[Linear Sync] Cancelled task ${sync.swarmId} (Linear issue ${data.identifier ?? issueId} cancelled)`,
|
|
780
780
|
);
|
|
@@ -812,7 +812,7 @@ export async function handleIssueDelete(event: Record<string, unknown>): Promise
|
|
|
812
812
|
|
|
813
813
|
const task = await getTaskById(sync.swarmId);
|
|
814
814
|
if (task && !isTerminalTaskStatus(task.status)) {
|
|
815
|
-
await cancelTask(sync.swarmId, "Linear issue deleted");
|
|
815
|
+
await cancelTask(sync.swarmId, "Linear issue deleted", { statusKind: "external" });
|
|
816
816
|
console.log(`[Linear Sync] Cancelled task ${sync.swarmId} (Linear issue ${issueId} deleted)`);
|
|
817
817
|
}
|
|
818
818
|
}
|
|
@@ -853,7 +853,9 @@ export async function handleAgentSessionPrompted(event: Record<string, unknown>)
|
|
|
853
853
|
if (existing) {
|
|
854
854
|
const existingTask = await getTaskById(existing.swarmId);
|
|
855
855
|
if (existingTask && !isTerminalTaskStatus(existingTask.status)) {
|
|
856
|
-
await cancelTask(existing.swarmId, "Stopped by user from Linear"
|
|
856
|
+
await cancelTask(existing.swarmId, "Stopped by user from Linear", {
|
|
857
|
+
statusKind: "user",
|
|
858
|
+
});
|
|
857
859
|
console.log(`[Linear Sync] Cancelled task ${existing.swarmId} (stop signal from Linear)`);
|
|
858
860
|
}
|
|
859
861
|
}
|