@desplega.ai/agent-swarm 2.7.6 → 2.7.8
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-bp91d37f.js → acp-adapter-vg5hqkvj.js} +6 -5
- package/dist/{actions-yj0eeaqh.js → actions-4m1ct4nh.js} +18 -18
- package/dist/{amp-adapter-4pg9h34q.js → amp-adapter-txqh7eqj.js} +2 -2
- package/dist/{anthropic-messages-x4q6rfq5.js → anthropic-messages-xey2skwx.js} +7 -7
- package/dist/{app-909e97cr.js → app-e00m45gn.js} +3 -3
- package/dist/{assistant-qdyb5fyy.js → assistant-gd08kr9e.js} +20 -20
- package/dist/{azure-openai-responses-s1w5n70z.js → azure-openai-responses-26t7j9ra.js} +5 -5
- package/dist/boot-args-schema-tjrkpbvm.js +89 -0
- package/dist/{boot-reembed-fk0s9z18.js → boot-reembed-21hbck22.js} +1 -1
- package/dist/{boot-reembed-gs1rzrnh.js → boot-reembed-mdxd3wgp.js} +1 -1
- package/dist/{boot-scrub-sweep-4qfd4kfx.js → boot-scrub-sweep-qy0zr9t2.js} +3 -3
- package/dist/{boot-seeds-yr00k13d.js → boot-seeds-n46eaxdv.js} +4 -4
- package/dist/{boxd-vdmfssd9.js → boxd-nv507va8.js} +1 -1
- package/dist/{claude-adapter-qta1f1xn.js → claude-adapter-j37w2eds.js} +6 -5
- package/dist/{claude-managed-adapter-dvs2xw5n.js → claude-managed-adapter-8jvcma9a.js} +3 -3
- package/dist/{claude-managed-setup-sc6j4dm0.js → claude-managed-setup-rzkjmgc1.js} +3 -3
- package/dist/{claude-sdk-session-zgrz6yvc.js → claude-sdk-session-4k7w73t0.js} +8290 -8226
- package/dist/{cli-w6dt9ged.js → cli-0ykgn1h5.js} +1 -1
- package/dist/{cli-89knwags.js → cli-1cxrbkk6.js} +2 -2
- package/dist/{cli-drr5v6av.js → cli-269q28a1.js} +4 -2
- package/dist/{cli-es6va8jk.js → cli-32m9eda8.js} +60 -53
- package/dist/{cli-q0k1w5zd.js → cli-3e4snnzf.js} +1 -1
- package/dist/{cli-dxae2yg7.js → cli-4t50yq3j.js} +2 -2
- package/dist/{cli-nhrvpaj7.js → cli-5j0m12ns.js} +520 -7
- package/dist/{cli-dhar9qay.js → cli-5ja3b75e.js} +2 -2
- package/dist/{cli-gdhpcbhf.js → cli-66ww7fer.js} +1 -1
- package/dist/{cli-bsn8nhrq.js → cli-6vcp76qk.js} +3 -3
- package/dist/{cli-8bc1w0tw.js → cli-7axf41jq.js} +29 -16
- package/dist/cli-82j36f2m.js +45 -0
- package/dist/{cli-svj5090z.js → cli-84rj785g.js} +5 -5
- package/dist/{cli-pd7vagab.js → cli-85gzce7b.js} +5 -5
- package/dist/{cli-xnrwazav.js → cli-8h0ayw8c.js} +1 -1
- package/dist/cli-8rpcng8j.js +67 -0
- package/dist/{cli-shpbx5ee.js → cli-8sdejs1f.js} +1728 -72
- package/dist/{cli-yx4kfngt.js → cli-9m8hdawy.js} +30 -17
- package/dist/{cli-436532ck.js → cli-ae0dnfee.js} +166 -154
- package/dist/{cli-bqt1mptt.js → cli-az48n0nr.js} +4 -4
- package/dist/{cli-386tyxxg.js → cli-bb0mmdk8.js} +2 -2
- package/dist/{cli-yy3rhsdw.js → cli-bbw9wj9m.js} +8 -8
- package/dist/{cli-xds5f77d.js → cli-bshb7jas.js} +2 -2
- package/dist/{cli-wp9sp1qb.js → cli-btfsp3mv.js} +3 -3
- package/dist/{cli-4zsenjhy.js → cli-c0kqky8y.js} +16 -3
- package/dist/{cli-a7v854rf.js → cli-dq8x79v8.js} +264 -13
- package/dist/{cli-ftyxyspd.js → cli-eqtfgfr6.js} +1 -1
- package/dist/{cli-yn4kxs06.js → cli-eyg1pa00.js} +4 -4
- package/dist/{cli-71ptav7x.js → cli-ferkkrg9.js} +1 -1
- package/dist/{cli-vpf89f34.js → cli-fmjd0t1y.js} +3 -3
- package/dist/{cli-4necwtsv.js → cli-fyhr5h4s.js} +38 -16
- package/dist/{cli-xnqgpshy.js → cli-fzachfnf.js} +1 -1
- package/dist/{cli-ehq736cn.js → cli-g7s47cc5.js} +4 -4
- package/dist/{cli-0qatpy8q.js → cli-ga786dzg.js} +34 -11
- package/dist/{cli-bjb3z51z.js → cli-gazw7kpa.js} +2 -2
- package/dist/{cli-54t00gt8.js → cli-gvx71kqv.js} +2 -2
- package/dist/{cli-c60vetmm.js → cli-jdv6ypxs.js} +1 -1
- package/dist/{cli-611a1294.js → cli-k0wwfqbg.js} +18 -1
- package/dist/{cli-cm5yqn35.js → cli-kf3pxxdg.js} +1 -0
- package/dist/{cli-0at8w34w.js → cli-kyr67fgx.js} +8 -8
- package/dist/{cli-vvpx3gsx.js → cli-m0hmeqma.js} +2 -2
- package/dist/{cli-he9wchme.js → cli-mkk9rnzz.js} +4 -4
- package/dist/{cli-e3r2neck.js → cli-msg9m2ny.js} +7 -5
- package/dist/{cli-m48g6p95.js → cli-nbsf8yvn.js} +15 -3
- package/dist/{cli-tfyyvzx6.js → cli-njwac61j.js} +5 -0
- package/dist/{cli-faxe6thg.js → cli-nn3ysbqk.js} +186 -54
- package/dist/{cli-decfb6v8.js → cli-p3vsj0d3.js} +24 -10
- package/dist/{cli-ekwks2vs.js → cli-ppjxh6ah.js} +3 -3
- package/dist/{cli-aa6yxc7m.js → cli-pz4rk021.js} +1 -1
- package/dist/{cli-nwj0ee2w.js → cli-q4ebh7h7.js} +4 -4
- package/dist/{cli-75gkpjvw.js → cli-qd57hhhh.js} +2 -2
- package/dist/{cli-zbbwez0r.js → cli-rjknb2ae.js} +4 -4
- package/dist/{cli-hgaazk69.js → cli-s4ss5g59.js} +5 -5
- package/dist/{cli-1h3wcpbw.js → cli-snpj5zbj.js} +2 -2
- package/dist/{cli-3ypk9vk1.js → cli-sq4n7af4.js} +1 -1
- package/dist/{cli-vfym7wmz.js → cli-ssnjfg5p.js} +5 -5
- package/dist/{cli-8snvgs5r.js → cli-t60ajbbp.js} +10 -10
- package/dist/{cli-hr2e2fft.js → cli-tpksw2nr.js} +22 -18
- package/dist/{cli-k2gzwsj2.js → cli-w4xnbm46.js} +300 -74
- package/dist/{cli-p5gp8pcx.js → cli-wemma3jd.js} +8 -7
- package/dist/{cli-70r77n04.js → cli-xae4g51r.js} +1 -1
- package/dist/{cli-waqbxg08.js → cli-xq9r2wtt.js} +50 -26
- package/dist/{cli-zm72anhg.js → cli-xr8908my.js} +11 -11
- package/dist/{cli-73jzwksr.js → cli-ycscb2ar.js} +4 -1
- package/dist/{cli-kqdg1bsb.js → cli-yndmfxb3.js} +2 -2
- package/dist/{cli-0yv5z2pg.js → cli-yqefz277.js} +1 -1
- package/dist/{cli-rmmmrjkd.js → cli-z1srzaf6.js} +11 -3
- package/dist/{cli-xbbndvjy.js → cli-z75yxkjh.js} +3 -3
- package/dist/{cli-jm2vfpfd.js → cli-zkky4t5g.js} +1 -1
- package/dist/cli.js +24 -22
- package/dist/{cloudflare-workers-ai-system-one-bm60fjm0.js → cloudflare-workers-ai-system-one-ef2a980q.js} +2 -2
- package/dist/{codex-adapter-ayd1fb6h.js → codex-adapter-88z6psm4.js} +5 -4
- package/dist/{codex-hook-9efm2x1m.js → codex-hook-fac6175r.js} +2 -2
- package/dist/{codex-login-y0pmff1c.js → codex-login-74wa4hmq.js} +1 -1
- package/dist/{codex-session-runner-jesa32xc.js → codex-session-runner-zwbcwzvx.js} +5 -4
- package/dist/{commands-hanewgf2.js → commands-7amxs716.js} +3 -3
- package/dist/{controller-dt1n3c1q.js → controller-5rkkc37m.js} +3 -3
- package/dist/{controllers-connect-xx8x64n5.js → controllers-connect-m7d4vxxb.js} +19 -19
- package/dist/{cursor-adapter-9s4dwwdw.js → cursor-adapter-x1q18693.js} +1 -1
- package/dist/{db-9dv0g1ab.js → db-athc68zt.js} +6 -2
- package/dist/{db-3vttcbv4.js → db-h2fsfve3.js} +3 -3
- package/dist/{dispatcher-tx9hd1sv.js → dispatcher-b1yz2bnn.js} +17 -17
- package/dist/{dsh-adapter-007y4ejs.js → dsh-adapter-e33bkxq9.js} +1 -1
- package/dist/{e2b-we6hs6q5.js → e2b-fr12yccx.js} +1 -1
- package/dist/{e2b-a19d28rz.js → e2b-x6ywzak3.js} +1 -1
- package/dist/{easter-egg-3d-rgbrqb8s.js → easter-egg-3d-pv5qnzc8.js} +1 -1
- package/dist/{embedding-space-ny1e2940.js → embedding-space-b4txbwrk.js} +6 -6
- package/dist/{embeddings-2t386t13.js → embeddings-m6zn6tad.js} +1 -1
- package/dist/{execute-pksh0ceh.js → execute-68nwny8m.js} +1 -1
- package/dist/{external-channel-phgmhmd7.js → external-channel-gkckmhzh.js} +2 -2
- package/dist/{fx-adapter-fy8rr921.js → fx-adapter-m5jbgd5q.js} +7 -6
- package/dist/{google-generative-ai-8y3m3k4b.js → google-generative-ai-v94hr7h0.js} +5 -5
- package/dist/{google-vertex-w3v98n7b.js → google-vertex-g7vr6cf8.js} +5 -5
- package/dist/{grok-adapter-q0abvpaj.js → grok-adapter-csvv7sac.js} +7 -6
- package/dist/handlers-8x5gfbzx.js +32 -0
- package/dist/{heartbeat-kadyek8p.js → heartbeat-6c2y3267.js} +20 -20
- package/dist/{hook-5zs3msf6.js → hook-q5fv0jy2.js} +25 -10
- package/dist/{hook-9k551xnj.js → hook-w0q2wcrv.js} +5 -4
- package/dist/{http-mhz9vw1f.js → http-bxat8dg3.js} +1242 -250
- package/dist/{index-rvr00sg7.js → index-bxrexmfy.js} +1020 -577
- package/dist/{index-vdygbq10.js → index-cqhqpgrv.js} +1 -1
- package/dist/{index-q361cg2f.js → index-fm0czesf.js} +1 -1
- package/dist/index-hpfte8jd.js +33 -0
- package/dist/index-ncf7yb5s.js +30 -0
- package/dist/index-vte6dyeh.js +37 -0
- package/dist/{keepalive-w56f32cg.js → keepalive-qnt21cv0.js} +3 -3
- package/dist/lead-4bvftzm6.js +71 -0
- package/dist/{maintenance-7mdgxcea.js → maintenance-btdr68y4.js} +1 -1
- package/dist/{mistral-conversations-4pmwj1c0.js → mistral-conversations-3gjpdb4b.js} +4 -4
- package/dist/{oauth-refresh-sweep-29txy9vk.js → oauth-refresh-sweep-vczabeh4.js} +2 -2
- package/dist/{onboard-kpsrkarj.js → onboard-k33ezyq8.js} +3 -3
- package/dist/{openai-codex-responses-44j573nm.js → openai-codex-responses-8pbxq9h5.js} +5 -5
- package/dist/{openai-completions-a4gee2a8.js → openai-completions-rm00s912.js} +4 -4
- package/dist/{openai-decisions-w4qkrcar.js → openai-decisions-8v957r2r.js} +1 -1
- package/dist/{openai-responses-rbp6h5kr.js → openai-responses-agxpf96k.js} +5 -5
- package/dist/{opencode-adapter-j25vm3rr.js → opencode-adapter-3dst2ka7.js} +5 -4
- package/dist/{otel-impl-6kkct7a8.js → otel-impl-13am7a65.js} +4 -4
- package/dist/{pi-mono-adapter-exhkzhn2.js → pi-mono-adapter-c53de1gd.js} +16 -9
- package/dist/{pricing-refresh-n2x7jh6k.js → pricing-refresh-9fcbnq3f.js} +3 -3
- package/dist/{rbac-roles-b5htkjby.js → rbac-roles-66j5h4y5.js} +5 -3
- package/dist/{rbac-roles-81ypx6es.js → rbac-roles-gw0p9h3j.js} +2 -2
- package/dist/{render-v2-qn6jmpk4.js → render-v2-fg8bmdn4.js} +3 -3
- package/dist/{resume-wd30wx23.js → resume-1c8kr3nh.js} +6 -6
- package/dist/{runtime-4hsg7h60.js → runtime-tzf9j7tc.js} +1 -1
- package/dist/{session-access-5qvfevhk.js → session-access-d0atq10j.js} +7 -5
- package/dist/{session-source-backfill-n1czavbr.js → session-source-backfill-0vscqmsa.js} +2 -2
- package/dist/{setup-dnb56qy5.js → setup-tvfa7rwe.js} +1 -1
- package/dist/{typesafe-system-one-5mavm259.js → typesafe-system-one-0bmqcxfg.js} +2 -2
- package/dist/{virtual-modules-76xxv9fs.js → virtual-modules-efxcp740.js} +5 -5
- package/dist/{work-objects-4n21tfkm.js → work-objects-ks71xqeb.js} +20 -20
- package/dist/worker-e7v2bvm9.js +71 -0
- package/dist/{worker-follow-up-77hvzxww.js → worker-follow-up-bfx0h9hg.js} +17 -17
- package/openapi.json +300 -27
- package/package.json +7 -5
- package/src/apps/definition.ts +6 -5
- package/src/be/db/model-profiles.ts +1 -1
- package/src/be/db/page-theme-tokens.ts +12 -0
- package/src/be/db/session-tree.ts +9 -5
- package/src/be/db/session-visibility.ts +25 -9
- package/src/be/db/tasks/read.ts +20 -7
- package/src/be/db/tasks/write.ts +96 -7
- package/src/be/db-client.ts +107 -7
- package/src/be/db-queries/tracker.ts +4 -2
- package/src/be/db.ts +83 -19
- package/src/be/migrations/269_pages_design_system.sql +23 -0
- package/src/be/migrations/271_subscription_usage_model.sql +30 -0
- package/src/be/model-validation.ts +19 -1
- package/src/be/rbac-roles.ts +21 -0
- package/src/be/runtime-pools/routing.ts +1 -1
- package/src/be/scripts/boot-args-schema.ts +95 -0
- package/src/be/scripts/extract-schema.ts +15 -10
- package/src/be/seed/schedules-seeder.ts +0 -10
- package/src/be/seed-scripts/catalog/boot-triage.inline.ts +1 -1
- package/src/be/seed-scripts/catalog/boot-triage.ts +1 -1
- package/src/be/seed-scripts/catalog/catalog-report.inline.ts +2 -0
- package/src/be/seed-scripts/catalog/catalog-report.ts +2 -0
- package/src/be/seed-scripts/catalog/get-child-outputs.ts +1 -1
- package/src/be/seed-scripts/catalog/memory-eval.ts +2 -0
- package/src/be/seed-scripts/catalog/swarm-update-check.ts +150 -0
- package/src/be/seed-scripts/catalog/wait-for-task.ts +1 -1
- package/src/be/seed-scripts/index.ts +9 -0
- package/src/be/seed-skills/bundled-files.generated.json +3 -3
- package/src/be/swarm-config-guard.ts +39 -0
- package/src/be/task-auto-title-listener.ts +127 -0
- package/src/be/users.ts +6 -4
- package/src/commands/claude-managed-setup.ts +1 -1
- package/src/commands/onboard/agent-fs-version.ts +1 -1
- package/src/commands/profile-sync.ts +151 -16
- package/src/commands/runner.ts +41 -16
- package/src/extensions/contract-types.generated.ts +1 -1
- package/src/hooks/hook.ts +20 -9
- package/src/http/agents.ts +7 -1
- package/src/http/approval-requests.ts +30 -6
- package/src/http/codex-oauth-device.ts +2 -2
- package/src/http/index.ts +11 -0
- package/src/http/mcp-oauth.ts +6 -0
- package/src/http/mcp-servers.ts +8 -0
- package/src/http/models-catalog.ts +1 -1
- package/src/http/pages-public.ts +131 -130
- package/src/http/pages.ts +94 -21
- package/src/http/poll.ts +3 -4
- package/src/http/prompt-templates.ts +1 -1
- package/src/http/schedules.ts +4 -0
- package/src/http/script-runs.ts +6 -1
- package/src/http/session-access.ts +61 -6
- package/src/http/sessions.ts +23 -7
- package/src/http/tasks.ts +53 -9
- package/src/http/users.ts +30 -1
- package/src/http/utils.ts +2 -1
- package/src/http/workflows.ts +11 -7
- package/src/pages/browser-sdk.ts +48 -21
- package/src/pages/color-literals.ts +115 -0
- package/src/pages/page-head.ts +766 -0
- package/src/pages/version.ts +3 -0
- package/src/prompts/session-templates.ts +1 -0
- package/src/providers/acp-targets.ts +1 -1
- package/src/providers/amp-adapter.ts +1 -1
- package/src/providers/codex-adapter.ts +10 -2
- package/src/providers/codex-app-server.ts +27 -1
- package/src/providers/codex-oauth/device.ts +49 -15
- package/src/providers/codex-oauth/flow.ts +2 -1
- package/src/providers/pi-mono-adapter.ts +8 -0
- package/src/providers/pi-mono-extension.ts +30 -15
- package/src/providers/pricing-sources.md +16 -1
- package/src/providers/swarm-events-shared.ts +15 -2
- package/src/rbac/legacy-policy.ts +1 -0
- package/src/rbac/permissions.ts +5 -0
- package/src/scheduler/deferred-task-waits.ts +9 -4
- package/src/scripts-runtime/extract-args-schema.ts +3 -1
- package/src/scripts-runtime/swarm-sdk.ts +1 -1
- package/src/scripts-runtime/types/swarm-extension.d.ts +29 -28
- package/src/server-user.ts +1 -1
- package/src/slack/ack.ts +48 -12
- package/src/slack/blocks.ts +1 -0
- package/src/slack/reaction-shortcode.ts +8 -2
- package/src/slack/render-v2.ts +30 -3
- package/src/slack/task-output.ts +4 -1
- package/src/slack/thread-buffer.ts +2 -2
- package/src/tasks/follow-up-gate.ts +318 -0
- package/src/tasks/task-skip.ts +28 -0
- package/src/tasks/terminal-result-guard.ts +3 -2
- package/src/tasks/worker-follow-up.ts +21 -1
- package/src/telemetry.ts +28 -1
- package/src/tests/agentmail-inbox-mapping.test.ts +73 -0
- package/src/tests/approval-requests.test.ts +58 -0
- package/src/tests/claude-managed-setup.test.ts +36 -0
- package/src/tests/codex-adapter.test.ts +2 -2
- package/src/tests/codex-app-server.test.ts +59 -0
- package/src/tests/codex-gateway-route.test.ts +50 -1
- package/src/tests/codex-oauth-device.test.ts +60 -0
- package/src/tests/codex-swarm-events.test.ts +43 -1
- package/src/tests/context-window.test.ts +14 -0
- package/src/tests/create-page-tool.test.ts +501 -0
- package/src/tests/db-client-busy-retry.test.ts +81 -0
- package/src/tests/db-queries-tracker.test.ts +2 -1
- package/src/tests/db-task-read-contract.test.ts +2 -0
- package/src/tests/db-task-write-contract.test.ts +4 -0
- package/src/tests/db-tasks-read.test.ts +21 -0
- package/src/tests/deferred-task-wake.test.ts +7 -2
- package/src/tests/e2e-coverage-contract.test.ts +235 -0
- package/src/tests/empty-output-schema.test.ts +160 -0
- package/src/tests/env-flag.test.ts +1 -0
- package/src/tests/explicit-model-validation.test.ts +14 -0
- package/src/tests/fixtures/pages/head-v1.html +56 -0
- package/src/tests/follow-up-gate-shadow.test.ts +513 -0
- package/src/tests/http-api-integration.test.ts +2 -2
- package/src/tests/http-users.test.ts +63 -0
- package/src/tests/identity-field-budget.test.ts +1 -1
- package/src/tests/internal-ai/credentials.test.ts +62 -0
- package/src/tests/internal-ai/task-title.test.ts +283 -0
- package/src/tests/mcp-input-caps.test.ts +4 -3
- package/src/tests/merge-gate-detect-changes.test.ts +167 -0
- package/src/tests/page-proxy.test.ts +1 -1
- package/src/tests/page-session-dev-cookie.test.ts +188 -0
- package/src/tests/pages-authed-mode.test.ts +13 -2
- package/src/tests/pages-frame-ancestors.test.ts +28 -1
- package/src/tests/pages-head-v2.test.ts +534 -0
- package/src/tests/pages-http.test.ts +330 -0
- package/src/tests/pages-public-html.test.ts +43 -0
- package/src/tests/pages-storage.test.ts +182 -0
- package/src/tests/pages-versioning.test.ts +72 -0
- package/src/tests/pi-mono-adapter.test.ts +39 -4
- package/src/tests/profile-sync-stale-writeback.test.ts +334 -0
- package/src/tests/profile-sync.test.ts +11 -15
- package/src/tests/rbac-engine.test.ts +1 -0
- package/src/tests/runner-context-usage.test.ts +119 -0
- package/src/tests/scheduled-task-required-params-migration.test.ts +3 -1
- package/src/tests/script-connections.test.ts +4 -0
- package/src/tests/script-executor-quickjs.test.ts +2 -0
- package/src/tests/script-runs-http.test.ts +57 -0
- package/src/tests/scripts-boot-args-schema.test.ts +181 -0
- package/src/tests/scripts-runtime.test.ts +24 -0
- package/src/tests/sdk-store-progress-skipped.test.ts +155 -0
- package/src/tests/seed-registry.test.ts +28 -6
- package/src/tests/seed-schedules.test.ts +61 -8
- package/src/tests/seed-scripts.test.ts +142 -2
- package/src/tests/session-costs-model-key-normalize.test.ts +59 -0
- package/src/tests/session-sharing.test.ts +212 -2
- package/src/tests/slack-reaction-config.test.ts +1 -0
- package/src/tests/slack-render-v2.test.ts +73 -0
- package/src/tests/slack-skip-reaction.test.ts +203 -0
- package/src/tests/store-progress-skipped.test.ts +159 -0
- package/src/tests/subscription-usage-migration.test.ts +57 -0
- package/src/tests/swarm-config-reserved-keys.test.ts +3 -0
- package/src/tests/swarm-diff.test.ts +121 -2
- package/src/tests/task-auto-title-config-guard.test.ts +37 -0
- package/src/tests/task-auto-title-listener.test.ts +165 -0
- package/src/tests/telemetry-endpoint-override.test.ts +27 -0
- package/src/tests/theme-import.test.ts +758 -0
- package/src/tests/themes-page-theme.test.ts +155 -0
- package/src/tests/themes-presets.test.ts +172 -0
- package/src/tests/trigger-claiming.test.ts +2 -0
- package/src/tests/workflow-script-principal.test.ts +2 -1
- package/src/tests/workflow-system-one-extraction.test.ts +29 -0
- package/src/themes/classics.ts +949 -0
- package/src/themes/import.ts +420 -0
- package/src/themes/page-fields.ts +40 -0
- package/src/themes/page-theme.ts +102 -0
- package/src/themes/presets.ts +561 -0
- package/src/themes/tokens.ts +218 -0
- package/src/tools/app-upsert.ts +1 -1
- package/src/tools/create-channel.ts +1 -1
- package/src/tools/create-page.ts +118 -12
- package/src/tools/defer-task.ts +1 -1
- package/src/tools/register-agentmail-inbox.ts +5 -0
- package/src/tools/repos/update-repo.ts +1 -1
- package/src/tools/request-human-input.ts +1 -1
- package/src/tools/send-task.ts +1 -1
- package/src/tools/store-progress.ts +39 -8
- package/src/tools/tracker/tracker-unlink.ts +2 -1
- package/src/tools/utils.ts +33 -0
- package/src/tools/workflows/retry-workflow-run.ts +3 -0
- package/src/types.ts +56 -5
- package/src/utils/constants.ts +19 -0
- package/src/utils/context-window.ts +6 -1
- package/src/utils/follow-up-gate-schedule-ids.ts +13 -0
- package/src/utils/internal-ai/credentials.ts +146 -93
- package/src/utils/internal-ai/index.ts +10 -0
- package/src/utils/internal-ai/models.ts +18 -0
- package/src/utils/internal-ai/task-title.ts +282 -0
- package/src/utils/output-schema.ts +23 -0
- package/src/utils/page-session.ts +37 -0
- package/src/workflows/executors/system-one-providers.ts +25 -6
- package/src/workflows/recovery.ts +8 -4
- package/src/workflows/resume.ts +19 -0
- package/templates/schedules/daily-status-report/content.md +88 -2
- package/templates/schedules/daily-swarm-update-check/content.md +16 -40
- package/templates/skills/apps/SKILL.md +1 -1
- package/templates/skills/apps/content.md +1 -1
- package/templates/skills/heartbeat-runbook/content.md +1 -1
- package/templates/skills/pages/config.json +1 -1
- package/templates/skills/pages/content.md +539 -86
- package/templates/skills/pages/files/examples/annotated-pr.html +21 -12
- package/templates/skills/pages/files/examples/multiplayer-board.html +41 -41
- package/templates/skills/pages/files/examples/report-page.html +125 -124
- package/dist/cli-2pnswgh8.js +0 -189
- package/dist/handlers-by3sfxyx.js +0 -32
- package/dist/index-4f2pvxae.js +0 -37
- package/dist/index-98gz7tmp.js +0 -30
- package/dist/index-k08z2cak.js +0 -33
- package/dist/lead-enq35nqp.js +0 -70
- package/dist/worker-gg1576j3.js +0 -70
- package/templates/schedules/daily-workflow-health-audit/config.json +0 -19
- package/templates/schedules/daily-workflow-health-audit/content.md +0 -191
package/src/http/pages.ts
CHANGED
|
@@ -25,6 +25,8 @@ import { resolveTemplate } from "../prompts/resolver";
|
|
|
25
25
|
// Side-effect import: registers `task.page.feedback`.
|
|
26
26
|
import "../prompts/session-templates";
|
|
27
27
|
import { createTaskWithSiblingAwareness } from "../tasks/sibling-awareness";
|
|
28
|
+
import { readThemeFields } from "../themes/page-fields";
|
|
29
|
+
import { THEME_PRESET_IDS } from "../themes/presets";
|
|
28
30
|
import {
|
|
29
31
|
AssetKeySchema,
|
|
30
32
|
type Page,
|
|
@@ -32,11 +34,11 @@ import {
|
|
|
32
34
|
PageContentTypeSchema,
|
|
33
35
|
PageSchema,
|
|
34
36
|
type PageSummary,
|
|
37
|
+
PageThemeTokensInputSchema,
|
|
35
38
|
PageVersionSchema,
|
|
36
39
|
} from "../types";
|
|
37
40
|
import { getAppUrl, getPublicMcpBaseUrl } from "../utils/constants";
|
|
38
|
-
import {
|
|
39
|
-
import { pageSessionSetCookies } from "../utils/page-session";
|
|
41
|
+
import { isLocalDevPageRequest, pageSessionSetCookies } from "../utils/page-session";
|
|
40
42
|
import { authUser, getRequestAuth, isOperatorAuth } from "../utils/request-auth-context";
|
|
41
43
|
import { resolveHttpFavoriteOwner } from "./favorite-owner";
|
|
42
44
|
import { route } from "./route-def";
|
|
@@ -94,12 +96,43 @@ const PageWithShareUrlsSchema = PageSchema.extend({
|
|
|
94
96
|
* used, which omits them entirely) — modeled as optional rather than a union
|
|
95
97
|
* since both shapes share every other field verbatim.
|
|
96
98
|
*/
|
|
97
|
-
const PageListItemSchema = PageSchema.partial({
|
|
99
|
+
const PageListItemSchema = PageSchema.partial({
|
|
100
|
+
body: true,
|
|
101
|
+
passwordHash: true,
|
|
102
|
+
theme: true,
|
|
103
|
+
themeTokens: true,
|
|
104
|
+
designVersion: true,
|
|
105
|
+
}).extend({
|
|
98
106
|
favorite: z.boolean(),
|
|
99
107
|
api_url: z.string(),
|
|
100
108
|
app_url: z.string(),
|
|
101
109
|
});
|
|
102
110
|
|
|
111
|
+
/** Design fields shared by the create and update bodies. */
|
|
112
|
+
const pageDesignBodyFields = {
|
|
113
|
+
theme: z
|
|
114
|
+
.string()
|
|
115
|
+
.nullable()
|
|
116
|
+
.optional()
|
|
117
|
+
.describe(
|
|
118
|
+
`Theme preset id that restyles the whole page. One of: ${THEME_PRESET_IDS.join(", ")}. Omit to follow the viewer's theme. Pass null on update to clear it.`,
|
|
119
|
+
),
|
|
120
|
+
themeTokens: PageThemeTokensInputSchema.nullable()
|
|
121
|
+
.optional()
|
|
122
|
+
.describe(
|
|
123
|
+
'Per-page token overrides, applied on top of the preset. Send { light, dark } maps of token name to CSS value, or { format: "css", css } with a CSS variable block (:root, .dark, @theme). Stored normalized. Names outside the token contract, and values that reference a variable outside it, are ignored and listed in ignoredTokens. Replaces the stored overrides. Pass null on update to clear them.',
|
|
124
|
+
),
|
|
125
|
+
designVersion: z
|
|
126
|
+
.number()
|
|
127
|
+
.int()
|
|
128
|
+
.min(1)
|
|
129
|
+
.max(2)
|
|
130
|
+
.optional()
|
|
131
|
+
.describe(
|
|
132
|
+
"Design system version. 2 is the swarm design system and the default for new pages. 1 is the original look that older pages keep. Omit on update to keep the stored value.",
|
|
133
|
+
),
|
|
134
|
+
};
|
|
135
|
+
|
|
103
136
|
// ─── Route Definitions ──────────────────────────────────────────────────────
|
|
104
137
|
|
|
105
138
|
const createPageRoute = route({
|
|
@@ -118,6 +151,7 @@ const createPageRoute = route({
|
|
|
118
151
|
password: z.string().min(1).optional(),
|
|
119
152
|
body: z.string(),
|
|
120
153
|
needsCredentials: z.array(z.string()).optional(),
|
|
154
|
+
...pageDesignBodyFields,
|
|
121
155
|
}),
|
|
122
156
|
responses: {
|
|
123
157
|
201: {
|
|
@@ -128,9 +162,20 @@ const createPageRoute = route({
|
|
|
128
162
|
version: z.literal(1),
|
|
129
163
|
api_url: z.string(),
|
|
130
164
|
app_url: z.string(),
|
|
165
|
+
ignoredTokens: z
|
|
166
|
+
.array(z.string())
|
|
167
|
+
.optional()
|
|
168
|
+
.describe(
|
|
169
|
+
"Theme tokens the importer ignored. A bare name is outside the token contract. Other entries give the reason, for example --font-sans (references --font-geist-sans) or --ring (in .card). Absent when none were ignored.",
|
|
170
|
+
),
|
|
171
|
+
designVersion: z
|
|
172
|
+
.number()
|
|
173
|
+
.int()
|
|
174
|
+
.min(1)
|
|
175
|
+
.describe("The design version of the new page: 2 unless the body set designVersion: 1."),
|
|
131
176
|
}),
|
|
132
177
|
},
|
|
133
|
-
400: { description: "Invalid body" },
|
|
178
|
+
400: { description: "Invalid body, unknown theme, or invalid themeTokens" },
|
|
134
179
|
409: { description: "Slug already exists for this agent" },
|
|
135
180
|
},
|
|
136
181
|
});
|
|
@@ -214,12 +259,31 @@ const updatePageRoute = route({
|
|
|
214
259
|
password: z.string().min(1).nullable().optional(),
|
|
215
260
|
body: z.string().optional(),
|
|
216
261
|
needsCredentials: z.array(z.string()).nullable().optional(),
|
|
262
|
+
...pageDesignBodyFields,
|
|
217
263
|
}),
|
|
218
264
|
responses: {
|
|
219
265
|
200: {
|
|
220
266
|
description: "Page updated",
|
|
221
|
-
schema: z.object({
|
|
267
|
+
schema: z.object({
|
|
268
|
+
id: z.string(),
|
|
269
|
+
key: AssetKeySchema,
|
|
270
|
+
version: z.number().int().min(1),
|
|
271
|
+
ignoredTokens: z
|
|
272
|
+
.array(z.string())
|
|
273
|
+
.optional()
|
|
274
|
+
.describe(
|
|
275
|
+
"Theme tokens the importer ignored. A bare name is outside the token contract. Other entries give the reason, for example --font-sans (references --font-geist-sans) or --ring (in .card). Absent when none were ignored.",
|
|
276
|
+
),
|
|
277
|
+
designVersion: z
|
|
278
|
+
.number()
|
|
279
|
+
.int()
|
|
280
|
+
.min(1)
|
|
281
|
+
.describe(
|
|
282
|
+
"The design version the page has after the update. An omitted designVersion keeps the stored one, so an older page stays on 1.",
|
|
283
|
+
),
|
|
284
|
+
}),
|
|
222
285
|
},
|
|
286
|
+
400: { description: "Unknown theme or invalid themeTokens" },
|
|
223
287
|
404: { description: "Page not found" },
|
|
224
288
|
413: { description: "Payload too large" },
|
|
225
289
|
},
|
|
@@ -429,7 +493,7 @@ const getPageVersionRoute = route({
|
|
|
429
493
|
* Cookie issuance moved to `src/utils/page-session.ts::issuePageSessionCookie`
|
|
430
494
|
* so the password-flow on `/p/:id` (step-5) can mint cookies via the same
|
|
431
495
|
* helper. `dev=true` softens the cookie for `http://localhost` (no Secure
|
|
432
|
-
* required; SameSite=Lax). Detected by `
|
|
496
|
+
* required; SameSite=Lax). Detected by `isLocalDevPageRequest()` in `src/utils/page-session.ts`.
|
|
433
497
|
*/
|
|
434
498
|
|
|
435
499
|
/**
|
|
@@ -528,20 +592,6 @@ function formatFeedbackComments(comments: z.infer<typeof PageFeedbackCommentSche
|
|
|
528
592
|
.join("\n\n");
|
|
529
593
|
}
|
|
530
594
|
|
|
531
|
-
function isDevRequest(req: IncomingMessage): boolean {
|
|
532
|
-
if (getNodeEnv() === "production") return false;
|
|
533
|
-
// We want `SameSite=Lax` only when the request itself comes from the same
|
|
534
|
-
// local-`http://localhost` origin as the API — same-site loads tolerate
|
|
535
|
-
// Lax without Secure. Anything else (including portless `*.localhost`
|
|
536
|
-
// setups talking from HTTPS to the HTTP API) must use `SameSite=None;
|
|
537
|
-
// Secure` so the cookie travels on cross-site fetches; Chrome treats
|
|
538
|
-
// localhost as a secure origin so the Secure flag is fine on HTTP.
|
|
539
|
-
const origin = (req.headers.origin as string | undefined) ?? "";
|
|
540
|
-
return (
|
|
541
|
-
origin === "" || origin.startsWith("http://localhost") || origin.startsWith("http://127.0.0.1")
|
|
542
|
-
);
|
|
543
|
-
}
|
|
544
|
-
|
|
545
595
|
// ─── Handler ────────────────────────────────────────────────────────────────
|
|
546
596
|
|
|
547
597
|
export async function handlePages(
|
|
@@ -562,6 +612,12 @@ export async function handlePages(
|
|
|
562
612
|
return true;
|
|
563
613
|
}
|
|
564
614
|
|
|
615
|
+
const themeFields = readThemeFields(parsed.body);
|
|
616
|
+
if ("error" in themeFields) {
|
|
617
|
+
jsonError(res, themeFields.error, 400);
|
|
618
|
+
return true;
|
|
619
|
+
}
|
|
620
|
+
|
|
565
621
|
const slug = parsed.body.slug ?? slugify(parsed.body.title);
|
|
566
622
|
|
|
567
623
|
// Hash password if provided. Bun.password.hash is async (Argon2 by default;
|
|
@@ -589,6 +645,9 @@ export async function handlePages(
|
|
|
589
645
|
passwordHash,
|
|
590
646
|
body: parsed.body.body,
|
|
591
647
|
needsCredentials: parsed.body.needsCredentials,
|
|
648
|
+
theme: themeFields.theme,
|
|
649
|
+
themeTokens: themeFields.themeTokens,
|
|
650
|
+
designVersion: parsed.body.designVersion,
|
|
592
651
|
});
|
|
593
652
|
// First write has no prior snapshot — version 1 is implicit (the parent
|
|
594
653
|
// IS v1). Subsequent edits land via PUT and bump the counter.
|
|
@@ -598,6 +657,8 @@ export async function handlePages(
|
|
|
598
657
|
version: 1,
|
|
599
658
|
api_url: `${getApiBaseUrl()}/p/${page.id}`,
|
|
600
659
|
app_url: `${getAppBaseUrl()}/pages/${page.slug}`,
|
|
660
|
+
...(themeFields.ignored.length > 0 ? { ignoredTokens: themeFields.ignored } : {}),
|
|
661
|
+
designVersion: page.designVersion,
|
|
601
662
|
});
|
|
602
663
|
} catch (err) {
|
|
603
664
|
if (err instanceof AssetKeyAuthorizationError) {
|
|
@@ -790,6 +851,13 @@ export async function handlePages(
|
|
|
790
851
|
return true;
|
|
791
852
|
}
|
|
792
853
|
|
|
854
|
+
// Before the snapshot: a rejected theme must not leave a version row behind.
|
|
855
|
+
const themeFields = readThemeFields(parsed.body);
|
|
856
|
+
if ("error" in themeFields) {
|
|
857
|
+
jsonError(res, themeFields.error, 400);
|
|
858
|
+
return true;
|
|
859
|
+
}
|
|
860
|
+
|
|
793
861
|
// Hash password if a new one was provided. `null` → clear the hash.
|
|
794
862
|
let passwordHashUpdate: string | null | undefined;
|
|
795
863
|
if (parsed.body.password === null) {
|
|
@@ -830,6 +898,9 @@ export async function handlePages(
|
|
|
830
898
|
passwordHash: passwordHashUpdate,
|
|
831
899
|
body: parsed.body.body,
|
|
832
900
|
needsCredentials: parsed.body.needsCredentials ?? undefined,
|
|
901
|
+
theme: themeFields.theme,
|
|
902
|
+
themeTokens: themeFields.themeTokens,
|
|
903
|
+
designVersion: parsed.body.designVersion,
|
|
833
904
|
});
|
|
834
905
|
if (!updated) {
|
|
835
906
|
res.writeHead(404);
|
|
@@ -840,6 +911,8 @@ export async function handlePages(
|
|
|
840
911
|
id: updated.id,
|
|
841
912
|
key: updated.key,
|
|
842
913
|
version: await getPageEditCounter(updated.id),
|
|
914
|
+
...(themeFields.ignored.length > 0 ? { ignoredTokens: themeFields.ignored } : {}),
|
|
915
|
+
designVersion: updated.designVersion,
|
|
843
916
|
});
|
|
844
917
|
return true;
|
|
845
918
|
}
|
|
@@ -988,7 +1061,7 @@ export async function handlePages(
|
|
|
988
1061
|
? { name: `guest-${randomUUID().slice(0, 8)}`, op: true as const }
|
|
989
1062
|
: undefined;
|
|
990
1063
|
const cookies = await pageSessionSetCookies(req, page.id, {
|
|
991
|
-
dev:
|
|
1064
|
+
dev: isLocalDevPageRequest(req),
|
|
992
1065
|
...identity,
|
|
993
1066
|
});
|
|
994
1067
|
|
package/src/http/poll.ts
CHANGED
|
@@ -13,7 +13,6 @@ import {
|
|
|
13
13
|
getAgentById,
|
|
14
14
|
getAllChannelActivityCursors,
|
|
15
15
|
getDbClient,
|
|
16
|
-
getInboxSummary,
|
|
17
16
|
getOfferedTasksForAgent,
|
|
18
17
|
getPendingTaskForAgent,
|
|
19
18
|
getTaskAttachments,
|
|
@@ -524,12 +523,12 @@ export async function handlePoll(
|
|
|
524
523
|
// would instruct a missing tool and strand the claimed mentions.
|
|
525
524
|
const claimedChannels = hasCapability("messaging") ? await claimMentions(myAgentId) : [];
|
|
526
525
|
if (claimedChannels.length > 0) {
|
|
527
|
-
//
|
|
528
|
-
|
|
526
|
+
// Count what this claim took: the inbox summary no longer sees mentions already
|
|
527
|
+
// moved to "processing".
|
|
529
528
|
return {
|
|
530
529
|
trigger: {
|
|
531
530
|
type: "unread_mentions",
|
|
532
|
-
mentionsCount:
|
|
531
|
+
mentionsCount: claimedChannels.reduce((sum, c) => sum + c.mentionsCount, 0),
|
|
533
532
|
claimedChannels: claimedChannels.map((c) => c.channelId), // Include for tracking
|
|
534
533
|
},
|
|
535
534
|
};
|
|
@@ -366,7 +366,7 @@ export async function handlePromptTemplates(
|
|
|
366
366
|
checkoutRoute.respond(res, 200, { template: toPromptTemplateResponse(template) });
|
|
367
367
|
} catch (error) {
|
|
368
368
|
const message = error instanceof Error ? error.message : "Unknown error";
|
|
369
|
-
if (message.includes("not found")) {
|
|
369
|
+
if (message.includes("not found") || message.startsWith("No history entry")) {
|
|
370
370
|
jsonError(res, message, 404);
|
|
371
371
|
} else {
|
|
372
372
|
jsonError(res, message, 400);
|
package/src/http/schedules.ts
CHANGED
|
@@ -343,6 +343,10 @@ export async function handleSchedules(
|
|
|
343
343
|
);
|
|
344
344
|
return true;
|
|
345
345
|
}
|
|
346
|
+
if (!body.cronExpression && !body.intervalMs) {
|
|
347
|
+
jsonError(res, "Either cronExpression or intervalMs must be provided.", 400);
|
|
348
|
+
return true;
|
|
349
|
+
}
|
|
346
350
|
}
|
|
347
351
|
|
|
348
352
|
if (body.cronExpression) {
|
package/src/http/script-runs.ts
CHANGED
|
@@ -238,6 +238,8 @@ const postInternalStepRoute = route({
|
|
|
238
238
|
pattern: ["api", "internal", "script-runs", null, "steps"],
|
|
239
239
|
operationId: "script_runs_internal_step_create",
|
|
240
240
|
summary: "Write a script run journal step",
|
|
241
|
+
description:
|
|
242
|
+
"Write-once per stepKey; a replay keeps the first journal entry and still answers 201.",
|
|
241
243
|
tags: ["Script Runs"],
|
|
242
244
|
params: runIdParamsSchema,
|
|
243
245
|
body: journalStepBodySchema,
|
|
@@ -856,10 +858,13 @@ export async function handleScriptRuns(
|
|
|
856
858
|
agentTaskRoute.respond(res, 200, { taskId: latest.id, taskOutput: latest.output ?? null });
|
|
857
859
|
return true;
|
|
858
860
|
}
|
|
861
|
+
// A skipped step did not do its work, so it settles as a failure, the
|
|
862
|
+
// same way the workflow engine routes it.
|
|
859
863
|
if (
|
|
860
864
|
latest.status === "failed" ||
|
|
861
865
|
latest.status === "cancelled" ||
|
|
862
|
-
latest.status === "superseded"
|
|
866
|
+
latest.status === "superseded" ||
|
|
867
|
+
latest.status === "skipped"
|
|
863
868
|
) {
|
|
864
869
|
json(res, { error: `Agent task ${latest.status}`, taskId: latest.id }, 409);
|
|
865
870
|
return true;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { IncomingMessage, ServerResponse } from "node:http";
|
|
2
2
|
import { getSteeringMessageById } from "../be/db";
|
|
3
3
|
import { getActiveSessionById } from "../be/db/active-sessions";
|
|
4
|
-
import { getUserGrant } from "../be/rbac-roles";
|
|
4
|
+
import { getUserGrant, userHoldsExplicitVerb } from "../be/rbac-roles";
|
|
5
5
|
import {
|
|
6
6
|
getSessionRoot,
|
|
7
7
|
hasSessionAccess,
|
|
@@ -28,14 +28,59 @@ import { jsonError } from "./utils";
|
|
|
28
28
|
* active user in `X-Swarm-User-Id`. On the shared key that identity is
|
|
29
29
|
* honor-system, the same trust the dashboard already gives favorites.
|
|
30
30
|
* `userId: null` is a guest page session, which has no user at all.
|
|
31
|
+
* `readAll` is the all-users read scope: the request opted in and the user
|
|
32
|
+
* may read every session (see `canReadAllSessions`). It lifts reads only;
|
|
33
|
+
* write and steer checks still need the user's own access.
|
|
31
34
|
*/
|
|
32
|
-
export type SessionActor =
|
|
35
|
+
export type SessionActor =
|
|
36
|
+
| { kind: "bypass" }
|
|
37
|
+
| { kind: "user"; userId: string | null; readAll?: boolean };
|
|
33
38
|
|
|
34
39
|
const BYPASS: SessionActor = { kind: "bypass" };
|
|
35
40
|
|
|
41
|
+
/**
|
|
42
|
+
* Request header that opts a dashboard tab into the all-users read scope, so
|
|
43
|
+
* every list and detail read of that tab carries it. `GET /api/tasks` and
|
|
44
|
+
* `GET /api/sessions` also take it as `scope=all`.
|
|
45
|
+
*/
|
|
46
|
+
export const SESSION_SCOPE_HEADER = "x-swarm-session-scope";
|
|
47
|
+
|
|
48
|
+
function requestsAllUsersScope(req: IncomingMessage): boolean {
|
|
49
|
+
const raw = req.headers[SESSION_SCOPE_HEADER];
|
|
50
|
+
return (Array.isArray(raw) ? raw[0] : raw)?.trim().toLowerCase() === "all";
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* Whether `userId` may opt in to read every user's sessions: one of its roles
|
|
55
|
+
* lists `session.read.all` explicitly. The grant-all `admin` role is not
|
|
56
|
+
* enough, because every new user gets it (`trg_users_default_role`). The
|
|
57
|
+
* stored grant decides with RBAC on or off: RBAC off opens the admission
|
|
58
|
+
* gate, not other users' private sessions.
|
|
59
|
+
*/
|
|
60
|
+
export async function canReadAllSessions(userId: string): Promise<boolean> {
|
|
61
|
+
return userHoldsExplicitVerb(userId, "session.read.all");
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* The session actor of a request. The all-users scope (`allUsers`, or the
|
|
66
|
+
* `X-Swarm-Session-Scope: all` header) sets `readAll` only for a user who may
|
|
67
|
+
* read every session; for anyone else it is ignored and the usual filter
|
|
68
|
+
* applies. A bypass actor already reads everything.
|
|
69
|
+
*/
|
|
36
70
|
export async function resolveSessionActor(
|
|
37
71
|
req: IncomingMessage,
|
|
38
72
|
myAgentId: string | undefined,
|
|
73
|
+
opts: { allUsers?: boolean } = {},
|
|
74
|
+
): Promise<SessionActor> {
|
|
75
|
+
const actor = await resolveBaseSessionActor(req, myAgentId);
|
|
76
|
+
if (actor.kind !== "user" || !actor.userId) return actor;
|
|
77
|
+
if (!opts.allUsers && !requestsAllUsersScope(req)) return actor;
|
|
78
|
+
return (await canReadAllSessions(actor.userId)) ? { ...actor, readAll: true } : actor;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
async function resolveBaseSessionActor(
|
|
82
|
+
req: IncomingMessage,
|
|
83
|
+
myAgentId: string | undefined,
|
|
39
84
|
): Promise<SessionActor> {
|
|
40
85
|
const auth = getRequestAuth(req);
|
|
41
86
|
const userId = authUserId(auth);
|
|
@@ -50,12 +95,18 @@ export async function resolveSessionActor(
|
|
|
50
95
|
return BYPASS;
|
|
51
96
|
}
|
|
52
97
|
|
|
98
|
+
/** `access`, raised to at least `read` for an actor with the all-users read scope. */
|
|
99
|
+
export function withReadAll(actor: SessionActor, access: SessionAccess): SessionAccess {
|
|
100
|
+
return actor.kind === "user" && actor.readAll && access === "none" ? "read" : access;
|
|
101
|
+
}
|
|
102
|
+
|
|
53
103
|
/** The actor's access to the session holding `taskId`; `owner` for a bypass actor. */
|
|
54
104
|
export async function sessionAccessFor(
|
|
55
105
|
actor: SessionActor,
|
|
56
106
|
taskId: string,
|
|
57
107
|
): Promise<SessionAccess> {
|
|
58
|
-
|
|
108
|
+
if (actor.kind === "bypass") return "owner";
|
|
109
|
+
return withReadAll(actor, await sessionAccess(actor.userId, taskId));
|
|
59
110
|
}
|
|
60
111
|
|
|
61
112
|
export const SESSION_READ_DENIED =
|
|
@@ -71,9 +122,12 @@ export async function canReadSession(
|
|
|
71
122
|
return hasSessionAccess(access, "read");
|
|
72
123
|
}
|
|
73
124
|
|
|
74
|
-
/**
|
|
125
|
+
/**
|
|
126
|
+
* The SQL list filter (`readableSessionCondition`) for an actor; none for a
|
|
127
|
+
* bypass actor or the all-users read scope.
|
|
128
|
+
*/
|
|
75
129
|
export function readableByFor(actor: SessionActor): { userId: string | null } | undefined {
|
|
76
|
-
return actor.kind === "user" ? { userId: actor.userId } : undefined;
|
|
130
|
+
return actor.kind === "user" && !actor.readAll ? { userId: actor.userId } : undefined;
|
|
77
131
|
}
|
|
78
132
|
|
|
79
133
|
export const SESSION_WRITE_DENIED =
|
|
@@ -162,7 +216,8 @@ async function denialFor(
|
|
|
162
216
|
if (actor.kind === "bypass") return null;
|
|
163
217
|
const root = await getSessionRoot(taskId);
|
|
164
218
|
if (!root) return null;
|
|
165
|
-
|
|
219
|
+
const access = withReadAll(actor, await sessionAccessForRoot(actor.userId, root));
|
|
220
|
+
if (hasSessionAccess(access, needed)) return null;
|
|
166
221
|
return needed === "read" ? SESSION_READ_DENIED : SESSION_WRITE_DENIED;
|
|
167
222
|
}
|
|
168
223
|
|
package/src/http/sessions.ts
CHANGED
|
@@ -84,6 +84,7 @@ import {
|
|
|
84
84
|
resolveSessionActor,
|
|
85
85
|
type SessionActor,
|
|
86
86
|
sessionAccessFor,
|
|
87
|
+
withReadAll,
|
|
87
88
|
} from "./session-access";
|
|
88
89
|
import { jsonError } from "./utils";
|
|
89
90
|
|
|
@@ -593,12 +594,16 @@ const listSessions = route({
|
|
|
593
594
|
* an empty list for mine or shared.
|
|
594
595
|
* tree: Sessions that GET /api/session-tree counts: mine plus shared with me,
|
|
595
596
|
* no ownerless roots. A bypass actor sees every root.
|
|
597
|
+
* all: every user's sessions, read-only. Honored for a user who may read
|
|
598
|
+
* every session (admin, or `session.read.all`); anyone else gets the
|
|
599
|
+
* default list. The `X-Swarm-Session-Scope: all` header opts in the same
|
|
600
|
+
* way and also lifts the tree scope.
|
|
596
601
|
*/
|
|
597
602
|
scope: z
|
|
598
|
-
.enum(["mine", "shared", "tree"])
|
|
603
|
+
.enum(["mine", "shared", "tree", "all"])
|
|
599
604
|
.optional()
|
|
600
605
|
.describe(
|
|
601
|
-
"mine: owned sessions. shared: sessions shared with me. tree: Sessions that GET /api/session-tree counts: mine plus shared with me, no ownerless roots. A bypass actor sees every root with tree scope.",
|
|
606
|
+
"mine: owned sessions. shared: sessions shared with me. tree: Sessions that GET /api/session-tree counts: mine plus shared with me, no ownerless roots. A bypass actor sees every root with tree scope. all: every user's sessions, read-only, for a user with an admin role or session.read.all; ignored for anyone else. The X-Swarm-Session-Scope: all header opts in the same way, also for tree.",
|
|
602
607
|
),
|
|
603
608
|
/** With `scope=tree`: `mine` (default) or `all`. Must match the tree's `show`. */
|
|
604
609
|
show: SessionShowSchema,
|
|
@@ -862,7 +867,9 @@ async function accessForRoot(
|
|
|
862
867
|
actor: SessionActor,
|
|
863
868
|
root: { id: string; requestedByUserId: string | null },
|
|
864
869
|
): Promise<SessionAccess> {
|
|
865
|
-
return actor.kind === "bypass"
|
|
870
|
+
return actor.kind === "bypass"
|
|
871
|
+
? "owner"
|
|
872
|
+
: withReadAll(actor, await sessionAccessForRoot(actor.userId, root));
|
|
866
873
|
}
|
|
867
874
|
|
|
868
875
|
// ─── Handler ─────────────────────────────────────────────────────────────────
|
|
@@ -972,9 +979,13 @@ export async function handleSessions(
|
|
|
972
979
|
.map((s) => s.trim())
|
|
973
980
|
.filter(Boolean)
|
|
974
981
|
: undefined;
|
|
975
|
-
const
|
|
982
|
+
const allUsers = parsed.query.scope === "all";
|
|
983
|
+
const actor = await resolveSessionActor(req, myAgentId, { allUsers });
|
|
976
984
|
const limit = Math.min(200, Math.max(0, parsed.query.limit ?? 25));
|
|
977
|
-
if (
|
|
985
|
+
if (
|
|
986
|
+
actor.kind === "bypass" &&
|
|
987
|
+
(parsed.query.scope === "mine" || parsed.query.scope === "shared")
|
|
988
|
+
) {
|
|
978
989
|
// No user to own or receive a share.
|
|
979
990
|
listSessions.respond(res, 200, {
|
|
980
991
|
sessions: [],
|
|
@@ -1004,7 +1015,11 @@ export async function handleSessions(
|
|
|
1004
1015
|
? {
|
|
1005
1016
|
viewer: {
|
|
1006
1017
|
userId: actor.userId,
|
|
1007
|
-
scope:
|
|
1018
|
+
scope:
|
|
1019
|
+
parsed.query.scope === "mine" || parsed.query.scope === "shared"
|
|
1020
|
+
? parsed.query.scope
|
|
1021
|
+
: "all",
|
|
1022
|
+
readAll: actor.readAll,
|
|
1008
1023
|
} as const,
|
|
1009
1024
|
}
|
|
1010
1025
|
: {}),
|
|
@@ -1067,6 +1082,7 @@ export async function handleSessions(
|
|
|
1067
1082
|
actor.userId,
|
|
1068
1083
|
{ ...list, mine: show !== "all" },
|
|
1069
1084
|
action,
|
|
1085
|
+
actor.readAll,
|
|
1070
1086
|
);
|
|
1071
1087
|
triageSessionListRoute.respond(res, 200, { updated });
|
|
1072
1088
|
return true;
|
|
@@ -1219,7 +1235,7 @@ export async function handleSessions(
|
|
|
1219
1235
|
// The viewer's read state, so a client marks a session read on open
|
|
1220
1236
|
// without the list row (the same rule as `GET /api/sessions`).
|
|
1221
1237
|
actor.kind === "user" && actor.userId
|
|
1222
|
-
? getSessionReadState(sessionRoot.id, actor.userId)
|
|
1238
|
+
? getSessionReadState(sessionRoot.id, actor.userId, undefined, actor.readAll)
|
|
1223
1239
|
: Promise.resolve(null),
|
|
1224
1240
|
getSessionGroupKey(root),
|
|
1225
1241
|
]);
|
package/src/http/tasks.ts
CHANGED
|
@@ -30,6 +30,7 @@ import {
|
|
|
30
30
|
recordTaskProviderIfUnset,
|
|
31
31
|
resumeTask,
|
|
32
32
|
settleSupersededTaskDependents,
|
|
33
|
+
skipTask,
|
|
33
34
|
supersedeTask,
|
|
34
35
|
TASK_LINEAGE_LIMITS,
|
|
35
36
|
updateAgentStatusFromCapacity,
|
|
@@ -55,6 +56,7 @@ import { can, isRbacEnabled, type RbacPrincipal, type RbacResource } from "../rb
|
|
|
55
56
|
import { chatThreadOfContextKey } from "../tasks/context-key";
|
|
56
57
|
import { TaskCreationBlockedError } from "../tasks/errors";
|
|
57
58
|
import { createTaskWithSiblingAwareness } from "../tasks/sibling-awareness";
|
|
59
|
+
import { finalizeSkippedTaskReaction, skipReasonFrom } from "../tasks/task-skip";
|
|
58
60
|
import { guardTerminalTaskResultWrite } from "../tasks/terminal-result-guard";
|
|
59
61
|
import { createResumeFollowUp, createWorkerTaskFollowUp } from "../tasks/worker-follow-up";
|
|
60
62
|
import {
|
|
@@ -234,7 +236,7 @@ const listTasks = route({
|
|
|
234
236
|
pattern: ["api", "tasks"],
|
|
235
237
|
summary: "List tasks with filters",
|
|
236
238
|
description:
|
|
237
|
-
"Returns tasks with the full `task` text replaced by a bounded `taskPreview` and completion/integration blobs dropped by default — list views only need the preview. Pass `fields=full` to restore the full `AgentTask`, or `fields=timeline` for the narrow shape the dashboard timeline draws. Every shape gives a user caller only tasks of sessions they can read. Fetch a single task in full via `GET /api/tasks/{id}`. `total` (the filtered row count, ignoring limit/offset) is computed only with `includeTotal=true`.",
|
|
239
|
+
"Returns tasks with the full `task` text replaced by a bounded `taskPreview` and completion/integration blobs dropped by default — list views only need the preview. Pass `fields=full` to restore the full `AgentTask`, or `fields=timeline` for the narrow shape the dashboard timeline draws. Every shape gives a user caller only tasks of sessions they can read, unless `scope=all` applies. Fetch a single task in full via `GET /api/tasks/{id}`. `total` (the filtered row count, ignoring limit/offset) is computed only with `includeTotal=true`.",
|
|
238
240
|
tags: ["Tasks"],
|
|
239
241
|
query: z.object({
|
|
240
242
|
/** Single status, or comma-separated list (e.g. "failed,cancelled"). */
|
|
@@ -275,6 +277,12 @@ const listTasks = route({
|
|
|
275
277
|
fields: z.enum(["full", "slim", "timeline"]).optional(),
|
|
276
278
|
/** `true` adds `total`, a filtered COUNT(*) that pagers need. Omitted by default. */
|
|
277
279
|
includeTotal: z.enum(["true", "false"]).optional(),
|
|
280
|
+
scope: z
|
|
281
|
+
.enum(["all"])
|
|
282
|
+
.optional()
|
|
283
|
+
.describe(
|
|
284
|
+
"all: every user's tasks, read-only, for a user with an admin role or session.read.all; ignored for anyone else. The X-Swarm-Session-Scope: all header opts in the same way.",
|
|
285
|
+
),
|
|
278
286
|
}),
|
|
279
287
|
responses: {
|
|
280
288
|
200: {
|
|
@@ -655,11 +663,13 @@ const finishTask = route({
|
|
|
655
663
|
path: "/api/tasks/{id}/finish",
|
|
656
664
|
pattern: ["api", "tasks", null, "finish"],
|
|
657
665
|
session: { taskParam: "id" },
|
|
658
|
-
summary: "Mark task as completed or
|
|
666
|
+
summary: "Mark task as completed, failed, or skipped (runner endpoint)",
|
|
667
|
+
description:
|
|
668
|
+
"`skipped` ends a task that is not the caller's to handle. It needs a one-line reason in `failureReason` (or `output`), keeps `output` empty, posts nothing, and creates no follow-up.",
|
|
659
669
|
tags: ["Tasks"],
|
|
660
670
|
params: z.object({ id: z.string() }),
|
|
661
671
|
body: z.object({
|
|
662
|
-
status: z.enum(["completed", "failed"]),
|
|
672
|
+
status: z.enum(["completed", "failed", "skipped"]),
|
|
663
673
|
output: z.string().optional(),
|
|
664
674
|
failureReason: z.string().optional(),
|
|
665
675
|
force: z.boolean().optional(),
|
|
@@ -669,7 +679,7 @@ const finishTask = route({
|
|
|
669
679
|
auth: { apiKey: true, agentId: true },
|
|
670
680
|
responses: {
|
|
671
681
|
200: { description: "Task finished", schema: FinishTaskSuccessSchema },
|
|
672
|
-
400: { description: "Invalid status" },
|
|
682
|
+
400: { description: "Invalid status, or a skip without a reason" },
|
|
673
683
|
403: { description: "Not assigned to this agent" },
|
|
674
684
|
404: { description: "Task not found" },
|
|
675
685
|
409: {
|
|
@@ -993,7 +1003,9 @@ export async function handleTasks(
|
|
|
993
1003
|
|
|
994
1004
|
// Every shape carries task text, so a user sees only sessions they can
|
|
995
1005
|
// read, and `total` counts the same rows.
|
|
996
|
-
const actor = await resolveSessionActor(req, myAgentId
|
|
1006
|
+
const actor = await resolveSessionActor(req, myAgentId, {
|
|
1007
|
+
allUsers: parsed.query.scope === "all",
|
|
1008
|
+
});
|
|
997
1009
|
const filters = {
|
|
998
1010
|
status,
|
|
999
1011
|
agentId: parsed.query.agentId || undefined,
|
|
@@ -1014,7 +1026,7 @@ export async function handleTasks(
|
|
|
1014
1026
|
orderBy: parsed.query.orderBy,
|
|
1015
1027
|
limit: parsed.query.limit,
|
|
1016
1028
|
offset: parsed.query.offset,
|
|
1017
|
-
readableBy: actor
|
|
1029
|
+
readableBy: readableByFor(actor),
|
|
1018
1030
|
};
|
|
1019
1031
|
// List responses default to slim (full `task` text → bounded `taskPreview`,
|
|
1020
1032
|
// heavy blobs dropped); `?fields=full` restores the full `AgentTask`.
|
|
@@ -1771,7 +1783,23 @@ export async function handleTasks(
|
|
|
1771
1783
|
return { error: "Task is assigned to another agent", status: 403 };
|
|
1772
1784
|
}
|
|
1773
1785
|
|
|
1774
|
-
const
|
|
1786
|
+
const skipReason =
|
|
1787
|
+
parsed.body.status === "skipped"
|
|
1788
|
+
? skipReasonFrom(parsed.body.failureReason, parsed.body.output)
|
|
1789
|
+
: undefined;
|
|
1790
|
+
if (parsed.body.status === "skipped" && !skipReason) {
|
|
1791
|
+
return {
|
|
1792
|
+
error: 'Status "skipped" needs a one-line reason in failureReason',
|
|
1793
|
+
status: 400,
|
|
1794
|
+
};
|
|
1795
|
+
}
|
|
1796
|
+
|
|
1797
|
+
const terminalResultGuard = await guardTerminalTaskResultWrite(
|
|
1798
|
+
task,
|
|
1799
|
+
parsed.body.status === "skipped"
|
|
1800
|
+
? { status: "skipped", failureReason: skipReason, force: parsed.body.force }
|
|
1801
|
+
: parsed.body,
|
|
1802
|
+
);
|
|
1775
1803
|
if (terminalResultGuard.handled) {
|
|
1776
1804
|
const { handled: _handled, ...guardResult } = terminalResultGuard;
|
|
1777
1805
|
return { ...guardResult, alreadyFinished: true };
|
|
@@ -1797,6 +1825,12 @@ export async function handleTasks(
|
|
|
1797
1825
|
return { error: "Failed to complete task", status: 500 };
|
|
1798
1826
|
}
|
|
1799
1827
|
updatedTask = result;
|
|
1828
|
+
} else if (parsed.body.status === "skipped") {
|
|
1829
|
+
const result = await skipTask(parsed.params.id, skipReason!);
|
|
1830
|
+
if (!result) {
|
|
1831
|
+
return { error: "Failed to mark task as skipped", status: 500 };
|
|
1832
|
+
}
|
|
1833
|
+
updatedTask = result;
|
|
1800
1834
|
} else {
|
|
1801
1835
|
const result = await failTask(
|
|
1802
1836
|
parsed.params.id,
|
|
@@ -1829,7 +1863,9 @@ export async function handleTasks(
|
|
|
1829
1863
|
return true;
|
|
1830
1864
|
}
|
|
1831
1865
|
|
|
1832
|
-
if (result.task && isFreshFinishResult(result)) {
|
|
1866
|
+
if (result.task && isFreshFinishResult(result) && parsed.body.status === "skipped") {
|
|
1867
|
+
finalizeSkippedTaskReaction(result.task, "tasks.finish");
|
|
1868
|
+
} else if (result.task && isFreshFinishResult(result)) {
|
|
1833
1869
|
const finishEventId = parsed.body.status === "completed" ? "completed" : "failed";
|
|
1834
1870
|
|
|
1835
1871
|
ensure({
|
|
@@ -1854,7 +1890,7 @@ export async function handleTasks(
|
|
|
1854
1890
|
try {
|
|
1855
1891
|
const followUp = await createWorkerTaskFollowUp({
|
|
1856
1892
|
task: result.task,
|
|
1857
|
-
status:
|
|
1893
|
+
status: finishEventId,
|
|
1858
1894
|
output: parsed.body.output,
|
|
1859
1895
|
failureReason: parsed.body.failureReason,
|
|
1860
1896
|
});
|
|
@@ -2090,6 +2126,9 @@ export async function handleTasks(
|
|
|
2090
2126
|
// step in `superseded` if the engine expects `failed`.
|
|
2091
2127
|
if (task.workflowRunStepId != null) {
|
|
2092
2128
|
const failed = await failTask(parsed.params.id, SUPERSEDED_WORKFLOW_TASK_REASON);
|
|
2129
|
+
if (task.agentId) {
|
|
2130
|
+
await updateAgentStatusFromCapacity(task.agentId);
|
|
2131
|
+
}
|
|
2093
2132
|
ensure({
|
|
2094
2133
|
id: "task.workflow_step_failed_on_supersede",
|
|
2095
2134
|
flow: "task",
|
|
@@ -2132,6 +2171,11 @@ export async function handleTasks(
|
|
|
2132
2171
|
return true;
|
|
2133
2172
|
}
|
|
2134
2173
|
|
|
2174
|
+
// Cancel and finish recompute the agent status; a superseded task frees its slot too.
|
|
2175
|
+
if (task.agentId) {
|
|
2176
|
+
await updateAgentStatusFromCapacity(task.agentId);
|
|
2177
|
+
}
|
|
2178
|
+
|
|
2135
2179
|
// Parent is now superseded. Create the resume child.
|
|
2136
2180
|
const followUp = await createResumeFollowUp({
|
|
2137
2181
|
parentId: parsed.params.id,
|