@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
|
@@ -0,0 +1,318 @@
|
|
|
1
|
+
import { createLogEntry, getDbClient } from "../be/db";
|
|
2
|
+
import { getScript } from "../be/scripts/db";
|
|
3
|
+
import { runSavedScriptAsAgent } from "../be/scripts/run-saved";
|
|
4
|
+
import type { AgentTask, ScriptRecord } from "../types";
|
|
5
|
+
import {
|
|
6
|
+
isFollowUpGateScheduleId,
|
|
7
|
+
parseFollowUpGateScheduleIds,
|
|
8
|
+
} from "../utils/follow-up-gate-schedule-ids";
|
|
9
|
+
import { scrubSecrets } from "../utils/secret-scrubber";
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Follow-up gate, shadow mode. When a gated scheduled run's Lead follow-up is
|
|
13
|
+
* created, a configured verifier script checks the run after commit and the
|
|
14
|
+
* server records whether the follow-up could have been skipped. Shadow mode
|
|
15
|
+
* never skips or delays a follow-up.
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
export const FOLLOW_UP_GATE_SHADOW_EVENT = "task_follow_up_gate_shadow" as const;
|
|
19
|
+
|
|
20
|
+
export type FollowUpGateConfig = {
|
|
21
|
+
mode: "off" | "shadow";
|
|
22
|
+
scheduleIds: ReadonlySet<string>;
|
|
23
|
+
verifierScript: string;
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
export type GateIneligibleReason =
|
|
27
|
+
| "mode_off"
|
|
28
|
+
| "not_scheduled"
|
|
29
|
+
| "schedule_not_gated"
|
|
30
|
+
| "status_failed"
|
|
31
|
+
| "follow_up_instructions";
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Read the gate config on every call so a `swarm_config` reload applies. Any
|
|
35
|
+
* mode other than `shadow` reads as `off`, and malformed ids are ignored.
|
|
36
|
+
*/
|
|
37
|
+
export function readFollowUpGateConfig(env: NodeJS.ProcessEnv = process.env): FollowUpGateConfig {
|
|
38
|
+
const mode = env.FOLLOW_UP_GATE_MODE?.trim().toLowerCase() === "shadow" ? "shadow" : "off";
|
|
39
|
+
const scheduleIds = new Set(
|
|
40
|
+
parseFollowUpGateScheduleIds(env.FOLLOW_UP_GATE_SCHEDULE_IDS)
|
|
41
|
+
.filter(isFollowUpGateScheduleId)
|
|
42
|
+
.map((id) => id.toLowerCase()),
|
|
43
|
+
);
|
|
44
|
+
return { mode, scheduleIds, verifierScript: env.FOLLOW_UP_GATE_VERIFIER_SCRIPT?.trim() ?? "" };
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/** Pure decision on whether a follow-up's worker task may be verified. */
|
|
48
|
+
export function classifyFollowUpGate(input: {
|
|
49
|
+
task: Pick<AgentTask, "scheduleId" | "followUpConfig">;
|
|
50
|
+
status: "completed" | "failed";
|
|
51
|
+
config: FollowUpGateConfig;
|
|
52
|
+
}): { eligible: true } | { eligible: false; reason: GateIneligibleReason } {
|
|
53
|
+
const { task, status, config } = input;
|
|
54
|
+
if (config.mode === "off") return { eligible: false, reason: "mode_off" };
|
|
55
|
+
if (!task.scheduleId) return { eligible: false, reason: "not_scheduled" };
|
|
56
|
+
if (!config.scheduleIds.has(task.scheduleId.toLowerCase())) {
|
|
57
|
+
return { eligible: false, reason: "schedule_not_gated" };
|
|
58
|
+
}
|
|
59
|
+
if (status === "failed") return { eligible: false, reason: "status_failed" };
|
|
60
|
+
if (task.followUpConfig?.onCompleted?.trim() || task.followUpConfig?.onFailed?.trim()) {
|
|
61
|
+
return { eligible: false, reason: "follow_up_instructions" };
|
|
62
|
+
}
|
|
63
|
+
return { eligible: true };
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
type VerifierScript = Pick<ScriptRecord, "name" | "version" | "contentHash">;
|
|
67
|
+
|
|
68
|
+
export type FollowUpGateDeps = {
|
|
69
|
+
/** Resolve the global verifier script, or null when it does not exist. */
|
|
70
|
+
getVerifier: (name: string) => Promise<VerifierScript | null>;
|
|
71
|
+
/** Run the verifier as `agentId` and return its result, or throw. */
|
|
72
|
+
runVerifier: (
|
|
73
|
+
script: VerifierScript,
|
|
74
|
+
input: { taskId: string },
|
|
75
|
+
agentId: string,
|
|
76
|
+
signal: AbortSignal,
|
|
77
|
+
) => Promise<unknown>;
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
const FOLLOW_UP_GATE_TIMEOUT_MS = 60_000;
|
|
81
|
+
const FOLLOW_UP_GATE_MAX_IN_FLIGHT = 2;
|
|
82
|
+
const TEXT_LIMIT = 300;
|
|
83
|
+
const MAX_UNVERIFIED = 20;
|
|
84
|
+
|
|
85
|
+
const defaultDeps: FollowUpGateDeps = {
|
|
86
|
+
getVerifier: (name) => getScript({ name, scope: "global" }),
|
|
87
|
+
runVerifier: async (script, input, agentId, signal) => {
|
|
88
|
+
const output = await runSavedScriptAsAgent({
|
|
89
|
+
script: script as ScriptRecord,
|
|
90
|
+
input,
|
|
91
|
+
agentId,
|
|
92
|
+
timeoutMs,
|
|
93
|
+
signal,
|
|
94
|
+
});
|
|
95
|
+
if (output.exitCode !== 0 || output.error || output.runtimeError) {
|
|
96
|
+
throw new Error(
|
|
97
|
+
output.runtimeError?.message ??
|
|
98
|
+
output.error ??
|
|
99
|
+
`script exited with code ${output.exitCode}`,
|
|
100
|
+
);
|
|
101
|
+
}
|
|
102
|
+
return output.result;
|
|
103
|
+
},
|
|
104
|
+
};
|
|
105
|
+
|
|
106
|
+
let timeoutMs = FOLLOW_UP_GATE_TIMEOUT_MS;
|
|
107
|
+
let depsForTests: FollowUpGateDeps | null = null;
|
|
108
|
+
let inFlight = 0;
|
|
109
|
+
const pending = new Set<Promise<void>>();
|
|
110
|
+
|
|
111
|
+
/** Replace the verifier lookup and runner. `null` restores the defaults. */
|
|
112
|
+
export function setFollowUpGateDepsForTests(deps: FollowUpGateDeps | null): void {
|
|
113
|
+
depsForTests = deps;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
/** Override the verifier deadline. `null` restores the 60s default. */
|
|
117
|
+
export function setFollowUpGateTimeoutMsForTests(ms: number | null): void {
|
|
118
|
+
timeoutMs = ms ?? FOLLOW_UP_GATE_TIMEOUT_MS;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
/** Wait until every scheduled shadow hook has written its row. */
|
|
122
|
+
export async function drainFollowUpGateShadowForTest(): Promise<void> {
|
|
123
|
+
// Hooks run in FIFO order behind the client lock, so once this marker runs,
|
|
124
|
+
// every earlier hook has started and registered its promise.
|
|
125
|
+
await new Promise<void>((resolve) => getDbClient().afterCommit(resolve));
|
|
126
|
+
while (pending.size > 0) await Promise.allSettled([...pending]);
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
type ShadowArgs = {
|
|
130
|
+
task: Pick<AgentTask, "id" | "scheduleId" | "followUpConfig">;
|
|
131
|
+
status: "completed" | "failed";
|
|
132
|
+
followUpTaskId: string;
|
|
133
|
+
leadAgentId: string;
|
|
134
|
+
};
|
|
135
|
+
|
|
136
|
+
type ShadowRecord = {
|
|
137
|
+
decision: "would_skip" | "would_keep" | "error" | "ineligible";
|
|
138
|
+
reason: string | null;
|
|
139
|
+
verdict?: { ok: boolean | null; check: string | null; detail: string; controlsOk: boolean };
|
|
140
|
+
unverified?: string[];
|
|
141
|
+
verifier?: VerifierScript | null;
|
|
142
|
+
latencyMs?: number | null;
|
|
143
|
+
error?: string;
|
|
144
|
+
};
|
|
145
|
+
|
|
146
|
+
/**
|
|
147
|
+
* Record a shadow gate decision for a just-created follow-up. Returns
|
|
148
|
+
* synchronously: all work, including the row write, runs after commit. With
|
|
149
|
+
* the gate off or the schedule not gated, nothing is registered.
|
|
150
|
+
*/
|
|
151
|
+
export function scheduleFollowUpGateShadow(args: ShadowArgs): void {
|
|
152
|
+
const config = readFollowUpGateConfig();
|
|
153
|
+
const verdict = classifyFollowUpGate({ task: args.task, status: args.status, config });
|
|
154
|
+
if (
|
|
155
|
+
!verdict.eligible &&
|
|
156
|
+
(verdict.reason === "mode_off" ||
|
|
157
|
+
verdict.reason === "not_scheduled" ||
|
|
158
|
+
verdict.reason === "schedule_not_gated")
|
|
159
|
+
) {
|
|
160
|
+
return;
|
|
161
|
+
}
|
|
162
|
+
const deps = depsForTests ?? defaultDeps;
|
|
163
|
+
getDbClient().afterCommit(() => {
|
|
164
|
+
const run = verdict.eligible
|
|
165
|
+
? runShadow(args, config, deps)
|
|
166
|
+
: writeRecord(args, { decision: "ineligible", reason: verdict.reason });
|
|
167
|
+
pending.add(run);
|
|
168
|
+
const settle = () => {
|
|
169
|
+
pending.delete(run);
|
|
170
|
+
};
|
|
171
|
+
void run.then(settle, settle);
|
|
172
|
+
});
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
async function runShadow(
|
|
176
|
+
args: ShadowArgs,
|
|
177
|
+
config: FollowUpGateConfig,
|
|
178
|
+
deps: FollowUpGateDeps,
|
|
179
|
+
): Promise<void> {
|
|
180
|
+
if (inFlight >= FOLLOW_UP_GATE_MAX_IN_FLIGHT) {
|
|
181
|
+
await writeRecord(args, { decision: "error", reason: "concurrency_cap" });
|
|
182
|
+
return;
|
|
183
|
+
}
|
|
184
|
+
inFlight++;
|
|
185
|
+
try {
|
|
186
|
+
await writeRecord(args, await verify(args, config, deps));
|
|
187
|
+
} finally {
|
|
188
|
+
inFlight--;
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
async function verify(
|
|
193
|
+
args: ShadowArgs,
|
|
194
|
+
config: FollowUpGateConfig,
|
|
195
|
+
deps: FollowUpGateDeps,
|
|
196
|
+
): Promise<ShadowRecord> {
|
|
197
|
+
if (!config.verifierScript) return { decision: "error", reason: "no_verifier" };
|
|
198
|
+
const started = performance.now();
|
|
199
|
+
const latency = () => Math.round(performance.now() - started);
|
|
200
|
+
const controller = new AbortController();
|
|
201
|
+
const deadlineMs = timeoutMs;
|
|
202
|
+
let timer: ReturnType<typeof setTimeout> | undefined;
|
|
203
|
+
let script: VerifierScript | null = null;
|
|
204
|
+
let timedOut = false;
|
|
205
|
+
try {
|
|
206
|
+
const run = (async () => {
|
|
207
|
+
script = await deps.getVerifier(config.verifierScript);
|
|
208
|
+
if (!script) return null;
|
|
209
|
+
return {
|
|
210
|
+
result: await deps.runVerifier(
|
|
211
|
+
script,
|
|
212
|
+
{ taskId: args.task.id },
|
|
213
|
+
args.leadAgentId,
|
|
214
|
+
controller.signal,
|
|
215
|
+
),
|
|
216
|
+
};
|
|
217
|
+
})();
|
|
218
|
+
// A run that settles after the deadline must not surface as an unhandled rejection.
|
|
219
|
+
run.catch(() => {});
|
|
220
|
+
const deadline = new Promise<never>((_, reject) => {
|
|
221
|
+
timer = setTimeout(() => {
|
|
222
|
+
timedOut = true;
|
|
223
|
+
controller.abort();
|
|
224
|
+
reject(new Error(`verifier timed out after ${deadlineMs}ms`));
|
|
225
|
+
}, deadlineMs);
|
|
226
|
+
});
|
|
227
|
+
const outcome = await Promise.race([run, deadline]);
|
|
228
|
+
const verifier = verifierInfo(script);
|
|
229
|
+
if (!outcome) {
|
|
230
|
+
return { decision: "error", reason: "no_verifier", verifier, latencyMs: latency() };
|
|
231
|
+
}
|
|
232
|
+
const result = outcome.result;
|
|
233
|
+
if (!result || typeof result !== "object") {
|
|
234
|
+
return {
|
|
235
|
+
decision: "error",
|
|
236
|
+
reason: "verifier_error",
|
|
237
|
+
verifier,
|
|
238
|
+
latencyMs: latency(),
|
|
239
|
+
error: "verifier result is not an object",
|
|
240
|
+
};
|
|
241
|
+
}
|
|
242
|
+
return { ...mapVerdict(result as Record<string, unknown>), verifier, latencyMs: latency() };
|
|
243
|
+
} catch (err) {
|
|
244
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
245
|
+
return {
|
|
246
|
+
decision: "error",
|
|
247
|
+
reason: timedOut ? "timeout" : "verifier_error",
|
|
248
|
+
verifier: verifierInfo(script),
|
|
249
|
+
latencyMs: latency(),
|
|
250
|
+
error: clip(message),
|
|
251
|
+
};
|
|
252
|
+
} finally {
|
|
253
|
+
clearTimeout(timer);
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
function verifierInfo(script: VerifierScript | null): VerifierScript | null {
|
|
258
|
+
return script
|
|
259
|
+
? { name: script.name, version: script.version, contentHash: script.contentHash }
|
|
260
|
+
: null;
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
/** `ok:true` with passing controls is `would_skip`; anything else keeps the follow-up. */
|
|
264
|
+
function mapVerdict(result: Record<string, unknown>): ShadowRecord {
|
|
265
|
+
const ok = typeof result.ok === "boolean" ? result.ok : null;
|
|
266
|
+
const controls = result.controls as { ok?: unknown } | null | undefined;
|
|
267
|
+
const controlsOk = controls?.ok === true;
|
|
268
|
+
const unverified = Array.isArray(result.unverified)
|
|
269
|
+
? result.unverified
|
|
270
|
+
.filter((name): name is string => typeof name === "string")
|
|
271
|
+
.slice(0, MAX_UNVERIFIED)
|
|
272
|
+
.map((name) => name.slice(0, 100))
|
|
273
|
+
: [];
|
|
274
|
+
return {
|
|
275
|
+
decision: ok === true && controlsOk ? "would_skip" : "would_keep",
|
|
276
|
+
reason: null,
|
|
277
|
+
verdict: {
|
|
278
|
+
ok,
|
|
279
|
+
check: typeof result.check === "string" ? result.check.slice(0, 100) : null,
|
|
280
|
+
detail: typeof result.detail === "string" ? clip(result.detail) : "",
|
|
281
|
+
controlsOk,
|
|
282
|
+
},
|
|
283
|
+
unverified,
|
|
284
|
+
};
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
function clip(text: string): string {
|
|
288
|
+
return scrubSecrets(text).slice(0, TEXT_LIMIT);
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
async function writeRecord(args: ShadowArgs, record: ShadowRecord): Promise<void> {
|
|
292
|
+
try {
|
|
293
|
+
await createLogEntry({
|
|
294
|
+
eventType: FOLLOW_UP_GATE_SHADOW_EVENT,
|
|
295
|
+
taskId: args.task.id,
|
|
296
|
+
agentId: args.leadAgentId,
|
|
297
|
+
metadata: {
|
|
298
|
+
v: 1,
|
|
299
|
+
mode: "shadow",
|
|
300
|
+
followUpTaskId: args.followUpTaskId,
|
|
301
|
+
scheduleId: args.task.scheduleId ?? null,
|
|
302
|
+
status: args.status,
|
|
303
|
+
decision: record.decision,
|
|
304
|
+
reason: record.reason,
|
|
305
|
+
verdict: record.verdict ?? null,
|
|
306
|
+
unverified: record.unverified ?? [],
|
|
307
|
+
verifier: record.verifier ?? null,
|
|
308
|
+
latencyMs: record.latencyMs ?? null,
|
|
309
|
+
...(record.error ? { error: record.error } : {}),
|
|
310
|
+
},
|
|
311
|
+
});
|
|
312
|
+
} catch (err) {
|
|
313
|
+
console.warn(
|
|
314
|
+
`[follow-up-gate] Could not record shadow decision for task ${args.task.id.slice(0, 8)}:`,
|
|
315
|
+
scrubSecrets(err instanceof Error ? err.message : String(err)),
|
|
316
|
+
);
|
|
317
|
+
}
|
|
318
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { finalizeTerminalSlackReactions } from "../slack/ack";
|
|
2
|
+
import type { AgentTask } from "../types";
|
|
3
|
+
import { scrubSecrets } from "../utils/secret-scrubber";
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* The one-line reason a `skipped` finish carries. Accept it from output too,
|
|
7
|
+
* since that is where a finishing call usually puts its text; the caller keeps
|
|
8
|
+
* output empty so nothing that publishes a task result has text to post.
|
|
9
|
+
* Undefined when neither field has text.
|
|
10
|
+
*/
|
|
11
|
+
export function skipReasonFrom(failureReason?: string, output?: string): string | undefined {
|
|
12
|
+
return (failureReason ?? output)?.replace(/\s+/g, " ").trim() || undefined;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* A skip posts nothing to the thread: no outcome card, no relay, no lead
|
|
17
|
+
* follow-up. It only swaps the trigger message's ack reaction for the skip
|
|
18
|
+
* reaction. Call it once, after a fresh skip committed.
|
|
19
|
+
*/
|
|
20
|
+
export function finalizeSkippedTaskReaction(task: AgentTask, caller: string): void {
|
|
21
|
+
if (!task.slackChannelId) return;
|
|
22
|
+
void finalizeTerminalSlackReactions([task]).catch((error) =>
|
|
23
|
+
console.error(
|
|
24
|
+
`[${caller}] skip reaction failed:`,
|
|
25
|
+
scrubSecrets(error instanceof Error ? error.message : String(error)),
|
|
26
|
+
),
|
|
27
|
+
);
|
|
28
|
+
}
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { overwriteTerminalTaskResultText } from "../be/db";
|
|
2
2
|
import type { AgentTask } from "../types";
|
|
3
3
|
import { isTerminalTaskStatus } from "../types";
|
|
4
|
+
import { isEffectiveOutputSchema } from "../utils/output-schema";
|
|
4
5
|
import { scrubSecrets } from "../utils/secret-scrubber";
|
|
5
6
|
import { validateJsonSchema } from "../workflows/json-schema-validator";
|
|
6
7
|
|
|
7
8
|
export type TerminalResultWrite = {
|
|
8
|
-
status?: "completed" | "failed";
|
|
9
|
+
status?: "completed" | "failed" | "skipped";
|
|
9
10
|
output?: string;
|
|
10
11
|
failureReason?: string;
|
|
11
12
|
force?: boolean;
|
|
@@ -23,7 +24,7 @@ export type TerminalResultGuardResult =
|
|
|
23
24
|
};
|
|
24
25
|
|
|
25
26
|
export function getTaskOutputValidationError(outputSchema: unknown, output: string | undefined) {
|
|
26
|
-
if (!outputSchema
|
|
27
|
+
if (!isEffectiveOutputSchema(outputSchema)) return undefined;
|
|
27
28
|
|
|
28
29
|
const schema = outputSchema as Record<string, unknown>;
|
|
29
30
|
if (!output) {
|
|
@@ -34,6 +34,7 @@ import {
|
|
|
34
34
|
import { isEnvFlagEnabled } from "../utils/env-flag";
|
|
35
35
|
import { taskAttachmentDisplayUrl } from "../utils/task-attachment-links";
|
|
36
36
|
import { chatThreadOfContextKey } from "./context-key";
|
|
37
|
+
import { scheduleFollowUpGateShadow } from "./follow-up-gate";
|
|
37
38
|
import { taskModelPin } from "./model-pin";
|
|
38
39
|
import { createTaskWithSiblingAwareness } from "./sibling-awareness";
|
|
39
40
|
// Side-effect import: registers task lifecycle templates in the in-memory registry.
|
|
@@ -261,6 +262,9 @@ async function findDeferredWakeFor(taskId: string, agentId: string): Promise<Def
|
|
|
261
262
|
* `all` wait with siblings still pending wakes nobody, so the follow-up stays.
|
|
262
263
|
* A `followUpConfig.onCompleted` / `onFailed` instruction for this status also
|
|
263
264
|
* keeps the follow-up, because the wake-up task does not carry that text.
|
|
265
|
+
*
|
|
266
|
+
* With `FOLLOW_UP_GATE_MODE=shadow`, a gated scheduled run also records a
|
|
267
|
+
* verifier's would-skip decision after commit; the follow-up is never skipped.
|
|
264
268
|
*/
|
|
265
269
|
export async function createWorkerTaskFollowUp(args: {
|
|
266
270
|
task: AgentTask;
|
|
@@ -392,7 +396,7 @@ export async function createWorkerTaskFollowUp(args: {
|
|
|
392
396
|
);
|
|
393
397
|
return null;
|
|
394
398
|
}
|
|
395
|
-
|
|
399
|
+
const followUp = await createTaskWithSiblingAwareness(
|
|
396
400
|
changes.description ?? followUpDescription,
|
|
397
401
|
{
|
|
398
402
|
agentId: followUpAgentId,
|
|
@@ -413,6 +417,22 @@ export async function createWorkerTaskFollowUp(args: {
|
|
|
413
417
|
},
|
|
414
418
|
{ origin: "followUp" },
|
|
415
419
|
);
|
|
420
|
+
if (followUp) {
|
|
421
|
+
try {
|
|
422
|
+
scheduleFollowUpGateShadow({
|
|
423
|
+
task,
|
|
424
|
+
status,
|
|
425
|
+
followUpTaskId: followUp.id,
|
|
426
|
+
leadAgentId: leadAgent.id,
|
|
427
|
+
});
|
|
428
|
+
} catch (err) {
|
|
429
|
+
console.warn(
|
|
430
|
+
`[worker-follow-up] Follow-up gate shadow failed for task ${task.id.slice(0, 8)}:`,
|
|
431
|
+
err instanceof Error ? err.message : String(err),
|
|
432
|
+
);
|
|
433
|
+
}
|
|
434
|
+
}
|
|
435
|
+
return followUp;
|
|
416
436
|
}
|
|
417
437
|
|
|
418
438
|
/** Hop cap for `deferredWorkChatContextKey`; a defer/resume chain is short. */
|
package/src/telemetry.ts
CHANGED
|
@@ -42,7 +42,34 @@ type FamilyProps<Prefix extends string, S extends string> = PropsFor<
|
|
|
42
42
|
Extract<SwarmEventName, `${Prefix}.${S}`>
|
|
43
43
|
>;
|
|
44
44
|
|
|
45
|
-
const
|
|
45
|
+
const DEFAULT_TELEMETRY_ENDPOINT = "https://proxy.desplega.sh/v1/events";
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* `DESPLEGA_TELEMETRY_ENDPOINT` is a test knob: the black-box suite points it at a
|
|
49
|
+
* loopback mock sink. Telemetry carries install ids and route templates, so the
|
|
50
|
+
* override is accepted only for https origins or plain http on loopback. Anything
|
|
51
|
+
* else is ignored with a warning and the default sink is used.
|
|
52
|
+
*/
|
|
53
|
+
export function resolveTelemetryEndpoint(raw: string | undefined): string {
|
|
54
|
+
const value = raw?.trim();
|
|
55
|
+
if (!value) return DEFAULT_TELEMETRY_ENDPOINT;
|
|
56
|
+
let url: URL;
|
|
57
|
+
try {
|
|
58
|
+
url = new URL(value);
|
|
59
|
+
} catch {
|
|
60
|
+
console.warn("[telemetry] DESPLEGA_TELEMETRY_ENDPOINT is not a URL; using the default sink");
|
|
61
|
+
return DEFAULT_TELEMETRY_ENDPOINT;
|
|
62
|
+
}
|
|
63
|
+
const loopback =
|
|
64
|
+
url.hostname === "127.0.0.1" || url.hostname === "localhost" || url.hostname === "[::1]";
|
|
65
|
+
if (url.protocol === "https:" || (url.protocol === "http:" && loopback)) return url.toString();
|
|
66
|
+
console.warn(
|
|
67
|
+
"[telemetry] DESPLEGA_TELEMETRY_ENDPOINT must be https, or http on loopback; using the default sink",
|
|
68
|
+
);
|
|
69
|
+
return DEFAULT_TELEMETRY_ENDPOINT;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
const TELEMETRY_ENDPOINT = resolveTelemetryEndpoint(process.env.DESPLEGA_TELEMETRY_ENDPOINT);
|
|
46
73
|
const PRODUCT = "agent-swarm";
|
|
47
74
|
const TIMEOUT_MS = 5_000;
|
|
48
75
|
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { afterEach, beforeEach, describe, expect, test } from "bun:test";
|
|
2
|
+
import { unlinkSync } from "node:fs";
|
|
3
|
+
import {
|
|
4
|
+
closeDb,
|
|
5
|
+
createAgent,
|
|
6
|
+
createAgentMailInboxMapping,
|
|
7
|
+
deleteAgentMailInboxMapping,
|
|
8
|
+
getAgentMailInboxMapping,
|
|
9
|
+
initDb,
|
|
10
|
+
} from "../be/db";
|
|
11
|
+
|
|
12
|
+
const TEST_DB_PATH = "./test-agentmail-inbox-mapping.sqlite";
|
|
13
|
+
|
|
14
|
+
function removeDbFiles() {
|
|
15
|
+
for (const suffix of ["", "-wal", "-shm"]) {
|
|
16
|
+
try {
|
|
17
|
+
unlinkSync(`${TEST_DB_PATH}${suffix}`);
|
|
18
|
+
} catch {}
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
let ownerId = "";
|
|
23
|
+
let otherId = "";
|
|
24
|
+
|
|
25
|
+
beforeEach(async () => {
|
|
26
|
+
removeDbFiles();
|
|
27
|
+
initDb(TEST_DB_PATH);
|
|
28
|
+
ownerId = (await createAgent({ name: "Owner", isLead: false, status: "idle" })).id;
|
|
29
|
+
otherId = (await createAgent({ name: "Other", isLead: false, status: "idle" })).id;
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
afterEach(() => {
|
|
33
|
+
closeDb();
|
|
34
|
+
removeDbFiles();
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
describe("createAgentMailInboxMapping", () => {
|
|
38
|
+
test("maps a free inbox to the caller", async () => {
|
|
39
|
+
const mapping = await createAgentMailInboxMapping("inb_free", ownerId, "free@agentmail.to");
|
|
40
|
+
expect(mapping).toMatchObject({
|
|
41
|
+
inboxId: "inb_free",
|
|
42
|
+
agentId: ownerId,
|
|
43
|
+
inboxEmail: "free@agentmail.to",
|
|
44
|
+
});
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
test("the owner registering again keeps the mapping and refreshes the email", async () => {
|
|
48
|
+
const first = await createAgentMailInboxMapping("inb_again", ownerId, "old@agentmail.to");
|
|
49
|
+
const again = await createAgentMailInboxMapping("inb_again", ownerId, "new@agentmail.to");
|
|
50
|
+
expect(again).toMatchObject({
|
|
51
|
+
id: first?.id,
|
|
52
|
+
agentId: ownerId,
|
|
53
|
+
inboxEmail: "new@agentmail.to",
|
|
54
|
+
});
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
test("another agent cannot take over a mapped inbox, and nothing changes", async () => {
|
|
58
|
+
await createAgentMailInboxMapping("inb_owned", ownerId, "owned@agentmail.to");
|
|
59
|
+
const taken = await createAgentMailInboxMapping("inb_owned", otherId, "taken@agentmail.to");
|
|
60
|
+
expect(taken).toBeNull();
|
|
61
|
+
expect(await getAgentMailInboxMapping("inb_owned")).toMatchObject({
|
|
62
|
+
agentId: ownerId,
|
|
63
|
+
inboxEmail: "owned@agentmail.to",
|
|
64
|
+
});
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
test("a freed inbox can be mapped by another agent", async () => {
|
|
68
|
+
await createAgentMailInboxMapping("inb_freed", ownerId);
|
|
69
|
+
expect(await deleteAgentMailInboxMapping("inb_freed")).toBe(true);
|
|
70
|
+
const mapping = await createAgentMailInboxMapping("inb_freed", otherId);
|
|
71
|
+
expect(mapping?.agentId).toBe(otherId);
|
|
72
|
+
});
|
|
73
|
+
});
|
|
@@ -1111,6 +1111,64 @@ describe("Approval Requests", () => {
|
|
|
1111
1111
|
// No approval-type questions means default is "approved"
|
|
1112
1112
|
expect(data.approvalRequest.status).toBe("approved");
|
|
1113
1113
|
});
|
|
1114
|
+
|
|
1115
|
+
test("production route defaults required to true and validates answered optional questions", async () => {
|
|
1116
|
+
const productionServer = createProductionApprovalServer();
|
|
1117
|
+
const port = await listenOnFreePort(productionServer);
|
|
1118
|
+
const origin = `http://127.0.0.1:${port}`;
|
|
1119
|
+
const post = (path: string, body: unknown) =>
|
|
1120
|
+
fetch(`${origin}${path}`, {
|
|
1121
|
+
method: "POST",
|
|
1122
|
+
headers: { "Content-Type": "application/json" },
|
|
1123
|
+
body: JSON.stringify(body),
|
|
1124
|
+
});
|
|
1125
|
+
const create = async (questions: unknown[]) => {
|
|
1126
|
+
const res = await post("/api/approval-requests", {
|
|
1127
|
+
title: "Defaults",
|
|
1128
|
+
questions,
|
|
1129
|
+
approvers: { policy: "any" },
|
|
1130
|
+
});
|
|
1131
|
+
expect(res.status).toBe(201);
|
|
1132
|
+
return ((await res.json()) as { approvalRequest: { id: string; questions: unknown[] } })
|
|
1133
|
+
.approvalRequest;
|
|
1134
|
+
};
|
|
1135
|
+
try {
|
|
1136
|
+
// A question that does not set `required` is stored as required: an empty answer is refused.
|
|
1137
|
+
const lax = await create([{ id: "go", type: "approval", label: "Go?" }]);
|
|
1138
|
+
expect(lax.questions).toEqual([
|
|
1139
|
+
{ id: "go", type: "approval", label: "Go?", required: true },
|
|
1140
|
+
]);
|
|
1141
|
+
const empty = await post(`/api/approval-requests/${lax.id}/respond`, { responses: {} });
|
|
1142
|
+
expect(empty.status).toBe(400);
|
|
1143
|
+
expect((await getApprovalRequestById(lax.id))?.status).toBe("pending");
|
|
1144
|
+
|
|
1145
|
+
// An answered optional question is validated; an unanswered one is allowed.
|
|
1146
|
+
const optional = await create([
|
|
1147
|
+
{ id: "go", type: "approval", label: "Go?" },
|
|
1148
|
+
{
|
|
1149
|
+
id: "color",
|
|
1150
|
+
type: "single-select",
|
|
1151
|
+
label: "Color",
|
|
1152
|
+
required: false,
|
|
1153
|
+
options: [{ value: "red", label: "Red" }],
|
|
1154
|
+
},
|
|
1155
|
+
]);
|
|
1156
|
+
const outOfOptions = await post(`/api/approval-requests/${optional.id}/respond`, {
|
|
1157
|
+
responses: { go: { approved: true }, color: "green" },
|
|
1158
|
+
});
|
|
1159
|
+
expect(outOfOptions.status).toBe(400);
|
|
1160
|
+
expect(((await outOfOptions.json()) as { error: string }).error).toContain("color");
|
|
1161
|
+
expect((await getApprovalRequestById(optional.id))?.status).toBe("pending");
|
|
1162
|
+
const unanswered = await post(`/api/approval-requests/${optional.id}/respond`, {
|
|
1163
|
+
responses: { go: { approved: true }, color: "" },
|
|
1164
|
+
});
|
|
1165
|
+
expect(unanswered.status).toBe(200);
|
|
1166
|
+
} finally {
|
|
1167
|
+
await new Promise<void>((resolve, reject) =>
|
|
1168
|
+
productionServer.close((error) => (error ? reject(error) : resolve())),
|
|
1169
|
+
);
|
|
1170
|
+
}
|
|
1171
|
+
});
|
|
1114
1172
|
});
|
|
1115
1173
|
|
|
1116
1174
|
// ─── HITL Executor ──────────────────────────────────────────
|
|
@@ -397,6 +397,42 @@ describe("runClaudeManagedSetup — entry point", () => {
|
|
|
397
397
|
expect(exit).not.toHaveBeenCalled();
|
|
398
398
|
});
|
|
399
399
|
|
|
400
|
+
test("--help documents AGENT_SWARM_API_KEY before API_KEY for --api-key", async () => {
|
|
401
|
+
const lines: string[] = [];
|
|
402
|
+
const origLog = console.log;
|
|
403
|
+
console.log = (...args: unknown[]) => {
|
|
404
|
+
lines.push(args.map(String).join(" "));
|
|
405
|
+
};
|
|
406
|
+
try {
|
|
407
|
+
await runClaudeManagedSetup(["--help"], {
|
|
408
|
+
log: mock(() => undefined),
|
|
409
|
+
error: mock(() => undefined),
|
|
410
|
+
exit: mock(() => {
|
|
411
|
+
throw new Error("exit was called");
|
|
412
|
+
}),
|
|
413
|
+
flow: mock(async () => {
|
|
414
|
+
throw new Error("flow should not be called");
|
|
415
|
+
}),
|
|
416
|
+
resolveConfig: mock(async () => {
|
|
417
|
+
throw new Error("resolveConfig should not be called");
|
|
418
|
+
}),
|
|
419
|
+
});
|
|
420
|
+
} finally {
|
|
421
|
+
console.log = origLog;
|
|
422
|
+
}
|
|
423
|
+
|
|
424
|
+
const text = lines.join("\n");
|
|
425
|
+
expect(text).toContain("AGENT_SWARM_API_KEY");
|
|
426
|
+
expect(text).toContain("API_KEY");
|
|
427
|
+
expect(text).toContain("123123");
|
|
428
|
+
// Prefer the namespaced key, then legacy API_KEY (same order as getApiKey / COMMAND_HELP).
|
|
429
|
+
const apiKeyLine = text
|
|
430
|
+
.split("\n")
|
|
431
|
+
.find((line) => line.includes("--api-key") && line.includes("default:"));
|
|
432
|
+
expect(apiKeyLine).toBeDefined();
|
|
433
|
+
expect(apiKeyLine!).toMatch(/AGENT_SWARM_API_KEY.*API_KEY/);
|
|
434
|
+
});
|
|
435
|
+
|
|
400
436
|
test("on error, calls error() + exit(1) without throwing", async () => {
|
|
401
437
|
const log = mock((_msg: string) => undefined);
|
|
402
438
|
const errorMessages: string[] = [];
|
|
@@ -579,10 +579,10 @@ describe("Codex app-server session", () => {
|
|
|
579
579
|
expect(snapshots).toHaveLength(2);
|
|
580
580
|
expect(snapshots[0]).toMatchObject({ contextUsedTokens: 51_000, contextTotalTokens: 258_400 });
|
|
581
581
|
expect(snapshots[0]?.contextPercent).toBeCloseTo((51_000 / 258_400) * 100, 6);
|
|
582
|
-
//
|
|
582
|
+
// Missing updates retain the last window the running harness reported.
|
|
583
583
|
expect(snapshots[1]).toMatchObject({
|
|
584
584
|
contextUsedTokens: 61_000,
|
|
585
|
-
contextTotalTokens:
|
|
585
|
+
contextTotalTokens: 258_400,
|
|
586
586
|
});
|
|
587
587
|
});
|
|
588
588
|
|