@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
|
@@ -27,6 +27,7 @@
|
|
|
27
27
|
* but it must be VISIBLE.
|
|
28
28
|
*/
|
|
29
29
|
|
|
30
|
+
import { rename } from "node:fs/promises";
|
|
30
31
|
import { resolveTemplateAsync } from "../prompts/resolver.ts";
|
|
31
32
|
import type { Agent, ProfileExpectedHashes, SwarmEvent } from "../types.ts";
|
|
32
33
|
import { MAX_PROFILE_FILE_LENGTH } from "../utils/constants.ts";
|
|
@@ -52,10 +53,13 @@ export const SETUP_SCRIPT_PATH = "/workspace/start-up.sh";
|
|
|
52
53
|
// Flow:
|
|
53
54
|
// 1. Runner writes DB content → /workspace/*.md at session start.
|
|
54
55
|
// 2. Runner records SHA-256 hashes of the written content (the "baselines").
|
|
55
|
-
// 3.
|
|
56
|
+
// 3. Every sync (session end AND on-edit) compares each file's hash against
|
|
57
|
+
// its baseline.
|
|
56
58
|
// - Hash matches → file untouched by the agent → skip sync (preserves
|
|
57
59
|
// any DB-side edits Lead made during the session).
|
|
58
60
|
// - Hash differs → agent modified the file → sync it back to DB.
|
|
61
|
+
// 4. After the API accepts a file, its baseline advances to the synced hash,
|
|
62
|
+
// so a file edited once is not re-sent over a later DB-side edit.
|
|
59
63
|
// ──────────────────────────────────────────────────────────────────────────
|
|
60
64
|
export const IDENTITY_BASELINES_PATH = "/tmp/identity-baselines.json";
|
|
61
65
|
|
|
@@ -337,8 +341,71 @@ export async function prependProfileSyncRejectionBanner(
|
|
|
337
341
|
: { prompt, injected: false };
|
|
338
342
|
}
|
|
339
343
|
|
|
344
|
+
/**
|
|
345
|
+
* Serializes every read-modify-write of IDENTITY_BASELINES_PATH across
|
|
346
|
+
* processes: the runner, the Claude hook and the pi extension each advance it,
|
|
347
|
+
* and two unserialized advances drop one another's hashes.
|
|
348
|
+
*/
|
|
349
|
+
export const IDENTITY_BASELINES_LOCK_PATH = `${IDENTITY_BASELINES_PATH}.lock`;
|
|
350
|
+
/** The baselines critical section is one small read and write; wait this long for it. */
|
|
351
|
+
const BASELINES_LOCK_WAIT_MS = 5_000;
|
|
352
|
+
|
|
353
|
+
/** Profile-file IO, injectable so tests never touch the real workspace. */
|
|
354
|
+
export interface ProfileFileIO {
|
|
355
|
+
readFile: FileReader;
|
|
356
|
+
writeFile: FileWriter;
|
|
357
|
+
/** Lock for baseline updates; defaults to IDENTITY_BASELINES_LOCK_PATH. */
|
|
358
|
+
baselinesLockPath?: string;
|
|
359
|
+
}
|
|
360
|
+
|
|
361
|
+
export const PROFILE_FILE_IO: ProfileFileIO = {
|
|
362
|
+
readFile: readFileIfExists,
|
|
363
|
+
writeFile: writeFileAtomic,
|
|
364
|
+
};
|
|
365
|
+
|
|
366
|
+
/**
|
|
367
|
+
* Replace the baselines at boot. Taken under the baselines lock so an advance
|
|
368
|
+
* still in flight from an earlier session cannot reapply its pre-boot read; if
|
|
369
|
+
* the lock is unavailable the boot baselines are written anyway.
|
|
370
|
+
*/
|
|
340
371
|
export async function writeIdentityBaselines(baselines: IdentityBaselines): Promise<void> {
|
|
341
|
-
|
|
372
|
+
const write = () => writeFileAtomic(IDENTITY_BASELINES_PATH, JSON.stringify(baselines));
|
|
373
|
+
const locked = await withFileLock(IDENTITY_BASELINES_LOCK_PATH, write, {
|
|
374
|
+
waitMs: BASELINES_LOCK_WAIT_MS,
|
|
375
|
+
});
|
|
376
|
+
if (!locked.acquired) await write();
|
|
377
|
+
}
|
|
378
|
+
|
|
379
|
+
/**
|
|
380
|
+
* The baselines the runner records at boot: the hash of each DB value the
|
|
381
|
+
* workspace file now derives from. An empty HEARTBEAT.md is a valid DB value
|
|
382
|
+
* and is never rewritten at boot, so it is baselined too; otherwise the empty
|
|
383
|
+
* file that survives a restart would count as an edit and be sent over a later
|
|
384
|
+
* DB edit. The setup script is baselined from the entrypoint-composed file.
|
|
385
|
+
*/
|
|
386
|
+
export function bootIdentityBaselines(
|
|
387
|
+
profile: {
|
|
388
|
+
soulMd?: string;
|
|
389
|
+
identityMd?: string;
|
|
390
|
+
toolsMd?: string;
|
|
391
|
+
heartbeatMd?: string | null;
|
|
392
|
+
claudeMd?: string;
|
|
393
|
+
},
|
|
394
|
+
setupScriptFile: string | undefined,
|
|
395
|
+
agentId = "unknown",
|
|
396
|
+
): IdentityBaselines {
|
|
397
|
+
const baselines: IdentityBaselines = {};
|
|
398
|
+
if (profile.soulMd) baselines.soulMd = contentSha256(profile.soulMd);
|
|
399
|
+
if (profile.identityMd) baselines.identityMd = contentSha256(profile.identityMd);
|
|
400
|
+
if (profile.toolsMd) baselines.toolsMd = contentSha256(profile.toolsMd);
|
|
401
|
+
if (typeof profile.heartbeatMd === "string") {
|
|
402
|
+
baselines.heartbeatMd = contentSha256(profile.heartbeatMd);
|
|
403
|
+
}
|
|
404
|
+
if (profile.claudeMd) baselines.claudeMd = contentSha256(profile.claudeMd);
|
|
405
|
+
const setupContent =
|
|
406
|
+
setupScriptFile === undefined ? null : extractSetupScriptContent(setupScriptFile, agentId);
|
|
407
|
+
if (setupContent) baselines.setupScript = contentSha256(setupContent);
|
|
408
|
+
return baselines;
|
|
342
409
|
}
|
|
343
410
|
|
|
344
411
|
export async function readIdentityBaselines(
|
|
@@ -353,6 +420,42 @@ export async function readIdentityBaselines(
|
|
|
353
420
|
}
|
|
354
421
|
}
|
|
355
422
|
|
|
423
|
+
/**
|
|
424
|
+
* Record the hashes of profile files the API just accepted: the DB now holds
|
|
425
|
+
* that content, so the same bytes on disk are no longer an edit. The update
|
|
426
|
+
* runs under IDENTITY_BASELINES_LOCK_PATH so concurrent syncs never drop each
|
|
427
|
+
* other's hashes. Best effort: on failure the older baselines stay (logged).
|
|
428
|
+
*/
|
|
429
|
+
export async function advanceIdentityBaselines(
|
|
430
|
+
synced: Record<string, string>,
|
|
431
|
+
io: ProfileFileIO = PROFILE_FILE_IO,
|
|
432
|
+
): Promise<void> {
|
|
433
|
+
if (Object.keys(synced).length === 0) return;
|
|
434
|
+
const update = async () => {
|
|
435
|
+
const baselines = (await readIdentityBaselines(io.readFile)) ?? {};
|
|
436
|
+
for (const [field, content] of Object.entries(synced)) {
|
|
437
|
+
baselines[field] = contentSha256(content);
|
|
438
|
+
}
|
|
439
|
+
await io.writeFile(IDENTITY_BASELINES_PATH, JSON.stringify(baselines));
|
|
440
|
+
};
|
|
441
|
+
try {
|
|
442
|
+
const locked = await withFileLock(
|
|
443
|
+
io.baselinesLockPath ?? IDENTITY_BASELINES_LOCK_PATH,
|
|
444
|
+
update,
|
|
445
|
+
{
|
|
446
|
+
waitMs: BASELINES_LOCK_WAIT_MS,
|
|
447
|
+
},
|
|
448
|
+
);
|
|
449
|
+
if (locked.acquired) return;
|
|
450
|
+
// No flock on this platform: nothing else can serialize it, so update anyway.
|
|
451
|
+
if (locked.reason === "unsupported") return await update();
|
|
452
|
+
console.warn(`[profile-sync] identity baselines not advanced: lock ${locked.reason}`);
|
|
453
|
+
} catch (err) {
|
|
454
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
455
|
+
console.warn(scrubSecrets(`[profile-sync] identity baselines not advanced: ${msg}`));
|
|
456
|
+
}
|
|
457
|
+
}
|
|
458
|
+
|
|
356
459
|
/**
|
|
357
460
|
* Claude Code's personal-file CLAUDE.md path. This is what the Claude plugin
|
|
358
461
|
* Stop hook reads and owns — the runner only uses it as a backstop for an
|
|
@@ -581,6 +684,8 @@ export interface ProfileSyncOptions {
|
|
|
581
684
|
claudeMdLock?: { path?: string; waitMs?: number };
|
|
582
685
|
/** Injectable fetch for tests. Defaults to the global `fetch`. */
|
|
583
686
|
fetchImpl?: typeof fetch;
|
|
687
|
+
/** Injectable profile-file IO for tests. Defaults to the worker's FS. */
|
|
688
|
+
io?: ProfileFileIO;
|
|
584
689
|
}
|
|
585
690
|
|
|
586
691
|
/**
|
|
@@ -658,7 +763,7 @@ export function extractSetupScriptContent(raw: string, agentId = "unknown"): str
|
|
|
658
763
|
*
|
|
659
764
|
* When `baselines` is provided, skips any field whose content hash matches the
|
|
660
765
|
* baseline (i.e. the file was not modified during the session). This prevents
|
|
661
|
-
*
|
|
766
|
+
* a sync from clobbering DB-side edits made by Lead.
|
|
662
767
|
*/
|
|
663
768
|
export function buildIdentityPayload(
|
|
664
769
|
files: {
|
|
@@ -729,7 +834,7 @@ export function buildIdentityPayload(
|
|
|
729
834
|
export type FileReader = (path: string) => Promise<string | undefined>;
|
|
730
835
|
|
|
731
836
|
/** Default file reader — reads from the worker's local FS via Bun. */
|
|
732
|
-
async function readFileIfExists(path: string): Promise<string | undefined> {
|
|
837
|
+
export async function readFileIfExists(path: string): Promise<string | undefined> {
|
|
733
838
|
try {
|
|
734
839
|
const file = Bun.file(path);
|
|
735
840
|
if (!(await file.exists())) return undefined;
|
|
@@ -739,6 +844,16 @@ async function readFileIfExists(path: string): Promise<string | undefined> {
|
|
|
739
844
|
}
|
|
740
845
|
}
|
|
741
846
|
|
|
847
|
+
/** Writes a file's text. */
|
|
848
|
+
export type FileWriter = (path: string, content: string) => Promise<void>;
|
|
849
|
+
|
|
850
|
+
/** Write via a temp file and rename, so a concurrent reader never sees a partial file. */
|
|
851
|
+
async function writeFileAtomic(path: string, content: string): Promise<void> {
|
|
852
|
+
const tmp = `${path}.${process.pid}.${crypto.randomUUID()}.tmp`;
|
|
853
|
+
await Bun.write(tmp, content);
|
|
854
|
+
await rename(tmp, path);
|
|
855
|
+
}
|
|
856
|
+
|
|
742
857
|
/**
|
|
743
858
|
* Compare the five local profile markdown files with the authenticated agent's
|
|
744
859
|
* stored DB values. This must run inside the agent's local environment; a
|
|
@@ -788,11 +903,11 @@ export async function auditProfileDivergences(
|
|
|
788
903
|
* `fields` selects which groups to include. The file reader is injectable so
|
|
789
904
|
* the field-selection / guard logic can be unit-tested without touching the FS.
|
|
790
905
|
*
|
|
791
|
-
*
|
|
792
|
-
*
|
|
793
|
-
*
|
|
794
|
-
*
|
|
795
|
-
*
|
|
906
|
+
* Loads the baseline hashes and skips identity fields and the setup script
|
|
907
|
+
* whose content hasn't changed — this prevents blind-overwriting DB-side edits
|
|
908
|
+
* made by Lead during the session. That holds for on-edit syncs
|
|
909
|
+
* (`"self_edit"`) too: an edit to one file triggers a sync of every identity
|
|
910
|
+
* file, and the untouched ones still hold the boot-time copy.
|
|
796
911
|
*/
|
|
797
912
|
export async function collectProfilePayloads(
|
|
798
913
|
fields: ProfileSyncField[],
|
|
@@ -803,7 +918,7 @@ export async function collectProfilePayloads(
|
|
|
803
918
|
): Promise<ProfilePayload[]> {
|
|
804
919
|
const payloads: ProfilePayload[] = [];
|
|
805
920
|
|
|
806
|
-
const baselines =
|
|
921
|
+
const baselines = await readIdentityBaselines(readFile);
|
|
807
922
|
|
|
808
923
|
if (fields.includes("identity")) {
|
|
809
924
|
const updates = buildIdentityPayload(
|
|
@@ -843,7 +958,7 @@ export async function collectProfilePayloads(
|
|
|
843
958
|
const raw = await readFile(SETUP_SCRIPT_PATH);
|
|
844
959
|
if (raw !== undefined) {
|
|
845
960
|
const content = extractSetupScriptContent(raw, agentId);
|
|
846
|
-
if (content !== null) {
|
|
961
|
+
if (content !== null && baselines?.setupScript !== contentSha256(content)) {
|
|
847
962
|
payloads.push({ label: "setup", body: { setupScript: content, changeSource } });
|
|
848
963
|
}
|
|
849
964
|
}
|
|
@@ -855,12 +970,13 @@ export async function collectProfilePayloads(
|
|
|
855
970
|
/**
|
|
856
971
|
* POST a single profile update. NON-FATAL but VISIBLE: a non-2xx response or a
|
|
857
972
|
* thrown error is logged (scrubbed) and swallowed so it never fails the task,
|
|
858
|
-
* but — unlike the original copies — it is never silently ignored.
|
|
973
|
+
* but — unlike the original copies — it is never silently ignored. Resolves to
|
|
974
|
+
* whether the API accepted it.
|
|
859
975
|
*/
|
|
860
976
|
export async function postProfileUpdate(
|
|
861
977
|
opts: Pick<ProfileSyncOptions, "agentId" | "apiUrl" | "apiKey" | "fetchImpl">,
|
|
862
978
|
payload: ProfilePayload,
|
|
863
|
-
): Promise<
|
|
979
|
+
): Promise<boolean> {
|
|
864
980
|
const doFetch = opts.fetchImpl ?? fetch;
|
|
865
981
|
try {
|
|
866
982
|
const resp = await doFetch(`${opts.apiUrl}/api/agents/${opts.agentId}/profile`, {
|
|
@@ -885,10 +1001,26 @@ export async function postProfileUpdate(
|
|
|
885
1001
|
),
|
|
886
1002
|
);
|
|
887
1003
|
}
|
|
1004
|
+
return resp.ok;
|
|
888
1005
|
} catch (err) {
|
|
889
1006
|
const msg = err instanceof Error ? err.message : String(err);
|
|
890
1007
|
console.warn(scrubSecrets(`[profile-sync] ${payload.label} sync errored: ${msg}`));
|
|
1008
|
+
return false;
|
|
1009
|
+
}
|
|
1010
|
+
}
|
|
1011
|
+
|
|
1012
|
+
/**
|
|
1013
|
+
* The baseline-tracked profile fields a payload carried. Only for payloads sent
|
|
1014
|
+
* outside the CLAUDE.md lock: the hook-owned personal CLAUDE.md keeps its own
|
|
1015
|
+
* lineage record, but an unconditional CLAUDE.md sync (the workspace copy, or a
|
|
1016
|
+
* self_edit) is tracked by its baseline like every other file.
|
|
1017
|
+
*/
|
|
1018
|
+
function baselineFieldsOf(payload: ProfilePayload): Record<string, string> {
|
|
1019
|
+
const fields: Record<string, string> = {};
|
|
1020
|
+
for (const [field, value] of Object.entries(payload.body)) {
|
|
1021
|
+
if (field !== "changeSource" && typeof value === "string") fields[field] = value;
|
|
891
1022
|
}
|
|
1023
|
+
return fields;
|
|
892
1024
|
}
|
|
893
1025
|
|
|
894
1026
|
/**
|
|
@@ -912,16 +1044,19 @@ export async function syncProfileFilesToServer(opts: ProfileSyncOptions): Promis
|
|
|
912
1044
|
fields.includes("claude") && syncsHookOwnedClaudeMd(claudeMdPath, changeSource);
|
|
913
1045
|
const unlockedFields = claudeUnderLock ? fields.filter((f) => f !== "claude") : fields;
|
|
914
1046
|
|
|
1047
|
+
const io = opts.io ?? PROFILE_FILE_IO;
|
|
915
1048
|
const payloads = await collectProfilePayloads(
|
|
916
1049
|
unlockedFields,
|
|
917
1050
|
changeSource,
|
|
918
|
-
|
|
1051
|
+
io.readFile,
|
|
919
1052
|
claudeMdPath,
|
|
920
1053
|
opts.agentId,
|
|
921
1054
|
);
|
|
1055
|
+
const synced: Record<string, string> = {};
|
|
922
1056
|
for (const payload of payloads) {
|
|
923
|
-
await postProfileUpdate(opts, payload);
|
|
1057
|
+
if (await postProfileUpdate(opts, payload)) Object.assign(synced, baselineFieldsOf(payload));
|
|
924
1058
|
}
|
|
1059
|
+
await advanceIdentityBaselines(synced, io);
|
|
925
1060
|
|
|
926
1061
|
if (claudeUnderLock) {
|
|
927
1062
|
const { path: lockPath = CLAUDE_MD_LOCK_PATH, waitMs = RUNNER_LOCK_WAIT_MS } =
|
|
@@ -933,7 +1068,7 @@ export async function syncProfileFilesToServer(opts: ProfileSyncOptions): Promis
|
|
|
933
1068
|
const claude = await collectProfilePayloads(
|
|
934
1069
|
["claude"],
|
|
935
1070
|
changeSource,
|
|
936
|
-
|
|
1071
|
+
io.readFile,
|
|
937
1072
|
claudeMdPath,
|
|
938
1073
|
opts.agentId,
|
|
939
1074
|
);
|
package/src/commands/runner.ts
CHANGED
|
@@ -91,6 +91,7 @@ import {
|
|
|
91
91
|
import { resolveCodexCreditsExhaustedCooldownMs } from "../utils/error-tracker.ts";
|
|
92
92
|
import { probeHarnessCliVersion, reportHarnessModelOutcome } from "../utils/harness-cli-version.ts";
|
|
93
93
|
import { resolveHarnessProvider } from "../utils/harness-provider.ts";
|
|
94
|
+
import { isEffectiveOutputSchema } from "../utils/output-schema.ts";
|
|
94
95
|
import { prettyPrintLine, prettyPrintStderr } from "../utils/pretty-print.ts";
|
|
95
96
|
import { terminateRegisteredProcessGroups } from "../utils/process-group.ts";
|
|
96
97
|
import { refreshRuntimeModelCatalog } from "../utils/runtime-model-catalog.ts";
|
|
@@ -135,7 +136,7 @@ import {
|
|
|
135
136
|
} from "./credential-wait.ts";
|
|
136
137
|
import { refreshIdentityIfChanged } from "./identity-refresh.ts";
|
|
137
138
|
import {
|
|
138
|
-
|
|
139
|
+
bootIdentityBaselines,
|
|
139
140
|
prependProfileSyncRejectionBanner,
|
|
140
141
|
resolveClaudeMdPath,
|
|
141
142
|
syncProfileFilesToServer,
|
|
@@ -1659,7 +1660,7 @@ export async function handleStructuredOutputFallback(
|
|
|
1659
1660
|
logs?: Array<{ eventType: string; newValue?: string; createdAt?: string }>;
|
|
1660
1661
|
};
|
|
1661
1662
|
|
|
1662
|
-
if (!taskData.outputSchema) {
|
|
1663
|
+
if (!isEffectiveOutputSchema(taskData.outputSchema)) {
|
|
1663
1664
|
// No structured output required — extract last progress as context
|
|
1664
1665
|
const lastProgressLog = (taskData.logs ?? [])
|
|
1665
1666
|
.filter((l) => l.eventType === "task_progress")
|
|
@@ -1748,7 +1749,7 @@ async function validateProviderOutputIfNeeded(
|
|
|
1748
1749
|
const taskData = (await taskRes.json()) as {
|
|
1749
1750
|
outputSchema?: Record<string, unknown>;
|
|
1750
1751
|
};
|
|
1751
|
-
if (!taskData.outputSchema
|
|
1752
|
+
if (!isEffectiveOutputSchema(taskData.outputSchema)) {
|
|
1752
1753
|
return { ok: true };
|
|
1753
1754
|
}
|
|
1754
1755
|
|
|
@@ -3776,12 +3777,13 @@ async function buildTaskOutputInstructions(
|
|
|
3776
3777
|
hasMcp: boolean,
|
|
3777
3778
|
): Promise<string> {
|
|
3778
3779
|
if (!hasMcp) return "";
|
|
3779
|
-
|
|
3780
|
-
|
|
3781
|
-
|
|
3782
|
-
|
|
3783
|
-
|
|
3784
|
-
|
|
3780
|
+
// An empty `{}` schema means no schema; rendering it as a contract makes the
|
|
3781
|
+
// worker complete with the literal output "{}".
|
|
3782
|
+
const result = isEffectiveOutputSchema(outputSchema)
|
|
3783
|
+
? await resolveTemplateAsync("task.output.schema", {
|
|
3784
|
+
schema: JSON.stringify(outputSchema, null, 2),
|
|
3785
|
+
})
|
|
3786
|
+
: await resolveTemplateAsync("task.output.generic", {});
|
|
3785
3787
|
return result.text;
|
|
3786
3788
|
}
|
|
3787
3789
|
|
|
@@ -4643,6 +4645,7 @@ export async function spawnProviderProcess(
|
|
|
4643
4645
|
// Context usage throttle: max 1 snapshot per 30 seconds
|
|
4644
4646
|
let lastContextPostTime = 0;
|
|
4645
4647
|
const CONTEXT_THROTTLE_MS = 30_000;
|
|
4648
|
+
let latestContextWindow: number | undefined;
|
|
4646
4649
|
|
|
4647
4650
|
// Phase 10: accumulate per-turn output tokens across the session so progress
|
|
4648
4651
|
// snapshots carry a real `cumulativeOutputTokens` (was 0 until completion).
|
|
@@ -4901,6 +4904,14 @@ export async function spawnProviderProcess(
|
|
|
4901
4904
|
});
|
|
4902
4905
|
break;
|
|
4903
4906
|
case "context_usage": {
|
|
4907
|
+
// Observe every live window, including events whose HTTP post is throttled.
|
|
4908
|
+
if (
|
|
4909
|
+
event.contextTotalTokens != null &&
|
|
4910
|
+
Number.isFinite(event.contextTotalTokens) &&
|
|
4911
|
+
event.contextTotalTokens > 0
|
|
4912
|
+
) {
|
|
4913
|
+
latestContextWindow = event.contextTotalTokens;
|
|
4914
|
+
}
|
|
4904
4915
|
const now2 = Date.now();
|
|
4905
4916
|
if (now2 - lastContextPostTime >= CONTEXT_THROTTLE_MS) {
|
|
4906
4917
|
lastContextPostTime = now2;
|
|
@@ -4937,6 +4948,9 @@ export async function spawnProviderProcess(
|
|
|
4937
4948
|
break;
|
|
4938
4949
|
}
|
|
4939
4950
|
case "compaction": {
|
|
4951
|
+
if (Number.isFinite(event.contextTotalTokens) && event.contextTotalTokens > 0) {
|
|
4952
|
+
latestContextWindow = event.contextTotalTokens;
|
|
4953
|
+
}
|
|
4940
4954
|
// Always record compaction events (no throttle)
|
|
4941
4955
|
telemetry.compaction("triggered", {
|
|
4942
4956
|
compactTrigger: event.compactTrigger,
|
|
@@ -5112,7 +5126,10 @@ export async function spawnProviderProcess(
|
|
|
5112
5126
|
sessionId: opts.runnerSessionId,
|
|
5113
5127
|
cumulativeInputTokens: result.cost.inputTokens ?? 0,
|
|
5114
5128
|
cumulativeOutputTokens: result.cost.outputTokens ?? 0,
|
|
5115
|
-
contextTotalTokens: getContextWindowSize(
|
|
5129
|
+
contextTotalTokens: getContextWindowSize(
|
|
5130
|
+
result.cost.model || "default",
|
|
5131
|
+
latestContextWindow,
|
|
5132
|
+
),
|
|
5116
5133
|
}),
|
|
5117
5134
|
}).catch(() => {});
|
|
5118
5135
|
}
|
|
@@ -6779,12 +6796,20 @@ export async function runAgent(config: RunnerConfig, opts: RunnerOptions) {
|
|
|
6779
6796
|
// are skipped, which prevents clobbering DB-side edits made by Lead via
|
|
6780
6797
|
// update-profile during the running session.
|
|
6781
6798
|
try {
|
|
6782
|
-
|
|
6783
|
-
|
|
6784
|
-
|
|
6785
|
-
|
|
6786
|
-
|
|
6787
|
-
|
|
6799
|
+
// start-up.sh is not rewritten here when it exists: the entrypoint composed
|
|
6800
|
+
// it from the DB at container start, so its agent-managed section is the base.
|
|
6801
|
+
const setupFile = Bun.file("/workspace/start-up.sh");
|
|
6802
|
+
const baselines = bootIdentityBaselines(
|
|
6803
|
+
{
|
|
6804
|
+
soulMd: agentSoulMd,
|
|
6805
|
+
identityMd: agentIdentityMd,
|
|
6806
|
+
toolsMd: agentToolsMd,
|
|
6807
|
+
heartbeatMd: agentHeartbeatMd,
|
|
6808
|
+
claudeMd: agentClaudeMd,
|
|
6809
|
+
},
|
|
6810
|
+
(await setupFile.exists()) ? await setupFile.text() : undefined,
|
|
6811
|
+
agentId,
|
|
6812
|
+
);
|
|
6788
6813
|
await writeIdentityBaselines(baselines);
|
|
6789
6814
|
console.log(`[${role}] Recorded identity file baselines for session-end sync`);
|
|
6790
6815
|
} catch {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
// Generated by scripts/bundle-extension-types.ts. Do not edit.
|
|
2
2
|
// biome-ignore-all lint/suspicious/noTemplateCurlyInString: Type declarations contain literal template placeholders.
|
|
3
3
|
export const EXTENSION_TYPE_DEFINITIONS =
|
|
4
|
-
'// biome-ignore-all lint/suspicious/noConfusingVoidType: Extension handlers may explicitly return no result.\ndeclare module "swarm-extension" {\n export type CreateTaskOptions = {\n key?: string | undefined;\n agentId?: string | null | undefined;\n creatorAgentId?: string | undefined;\n source?:\n | "workflow"\n | "schedule"\n | "slack"\n | "agentmail"\n | "github"\n | "gitlab"\n | "azure-devops"\n | "bitbucket"\n | "linear"\n | "jira"\n | "mcp"\n | "api"\n | "ui"\n | "system"\n | "comb"\n | "chat"\n | undefined;\n routingReason?:\n | "skill"\n | "continuity"\n | "overflow"\n | "human_pinned"\n | "reroute_fault"\n | undefined;\n routingSource?: "declared" | "engine_default" | undefined;\n routingNote?: string | undefined;\n taskType?: string | undefined;\n tags?: string[] | undefined;\n priority?: number | undefined;\n dependsOn?: string[] | undefined;\n offeredTo?: string | undefined;\n status?: "draft" | "backlog" | "unassigned" | undefined;\n slackChannelId?: string | undefined;\n slackThreadTs?: string | undefined;\n slackTriggerMessageTs?: string | undefined;\n slackUserId?: string | undefined;\n overrideSlackContext?: boolean | undefined;\n vcsProvider?: "github" | "gitlab" | "azure-devops" | "bitbucket" | undefined;\n vcsRepo?: string | undefined;\n vcsEventType?: string | undefined;\n vcsNumber?: number | undefined;\n vcsCommentId?: number | undefined;\n vcsAuthor?: string | undefined;\n vcsUrl?: string | undefined;\n vcsInstallationId?: number | undefined;\n vcsNodeId?: string | undefined;\n agentmailInboxId?: string | undefined;\n agentmailMessageId?: string | undefined;\n agentmailThreadId?: string | undefined;\n mentionMessageId?: string | undefined;\n mentionChannelId?: string | undefined;\n dir?: string | undefined;\n parentTaskId?: string | undefined;\n model?: string | undefined;\n modelTier?: "smol" | "regular" | "smart" | "ultra" | undefined;\n effort?: "off" | "low" | "medium" | "high" | "xhigh" | "max" | undefined;\n profile?: string | undefined;\n scheduleId?: string | undefined;\n workflowRunId?: string | undefined;\n workflowRunStepId?: string | undefined;\n sourceTaskId?: string | undefined;\n outputSchema?: Record<string, unknown> | undefined;\n inheritParentOutputSchema?: boolean | undefined;\n inheritParentRequester?: boolean | undefined;\n inheritParentRoutingAffinity?: boolean | undefined;\n inheritParentFollowUpConfig?: boolean | undefined;\n followUpConfig?:\n | {\n disabled?: boolean | undefined;\n onCompleted?: string | undefined;\n onFailed?: string | undefined;\n }\n | undefined;\n requestedByUserId?: string | undefined;\n contextKey?: string | undefined;\n bypassTrackerContextDedup?: boolean | undefined;\n routingAffinity?:\n | {\n capabilities: string[];\n sourceAgentId?: string | undefined;\n role?: string | undefined;\n harnessProvider?:\n | "claude"\n | "codex"\n | "pi"\n | "devin"\n | "claude-managed"\n | "opencode"\n | "acp"\n | "dsh"\n | "amp"\n | "cursor"\n | "grok"\n | "fx"\n | undefined;\n leadOnly?: boolean | undefined;\n }\n | undefined;\n };\n\n export type AgentTask = {\n id: string;\n key: string;\n agentId: string | null;\n task: string;\n status:\n | "draft"\n | "backlog"\n | "unassigned"\n | "offered"\n | "reviewing"\n | "pending"\n | "in_progress"\n | "paused"\n | "completed"\n | "failed"\n | "cancelled"\n | "superseded";\n source:\n | "workflow"\n | "schedule"\n | "slack"\n | "agentmail"\n | "github"\n | "gitlab"\n | "azure-devops"\n | "bitbucket"\n | "linear"\n | "jira"\n | "mcp"\n | "api"\n | "ui"\n | "system"\n | "comb"\n | "chat";\n tags: string[];\n priority: number;\n dependsOn: string[];\n createdAt: string;\n lastUpdatedAt: string;\n slackReplySent: boolean;\n wasPaused: boolean;\n creatorAgentId?: string | undefined;\n title?: string | undefined;\n routingReason?:\n | "skill"\n | "continuity"\n | "overflow"\n | "human_pinned"\n | "reroute_fault"\n | undefined;\n routingSource?: "declared" | "engine_default" | undefined;\n routingNote?: string | undefined;\n poolWakeAt?: string | undefined;\n taskType?: string | undefined;\n offeredTo?: string | undefined;\n offeredAt?: string | undefined;\n acceptedAt?: string | undefined;\n rejectionReason?: string | undefined;\n finishedAt?: string | undefined;\n notifiedAt?: string | undefined;\n failureReason?: string | undefined;\n output?: string | undefined;\n progress?: string | undefined;\n slackChannelId?: string | undefined;\n slackThreadTs?: string | undefined;\n slackTriggerMessageTs?: string | undefined;\n slackUserId?: string | undefined;\n slackProgressMessageTs?: string | undefined;\n slackTreeRootMessageTs?: string | undefined;\n vcsProvider?: "github" | "gitlab" | "azure-devops" | "bitbucket" | undefined;\n vcsRepo?: string | undefined;\n vcsEventType?: string | undefined;\n vcsNumber?: number | undefined;\n vcsCommentId?: number | undefined;\n vcsAuthor?: string | undefined;\n vcsUrl?: string | undefined;\n vcsInstallationId?: number | undefined;\n vcsNodeId?: string | undefined;\n agentmailInboxId?: string | undefined;\n agentmailMessageId?: string | undefined;\n agentmailThreadId?: string | undefined;\n mentionMessageId?: string | undefined;\n mentionChannelId?: string | undefined;\n dir?: string | undefined;\n parentTaskId?: string | undefined;\n claudeSessionId?: string | undefined;\n model?: string | undefined;\n modelTier?: "smol" | "regular" | "smart" | "ultra" | undefined;\n effort?: "off" | "low" | "medium" | "high" | "xhigh" | "max" | undefined;\n resolvedModel?: string | undefined;\n modelSource?: string | undefined;\n modelAlias?: string | undefined;\n resolvedEffort?: "off" | "low" | "medium" | "high" | "xhigh" | "max" | undefined;\n profile?: string | undefined;\n resolvedProfile?: string | undefined;\n scheduleId?: string | undefined;\n workflowRunId?: string | null | undefined;\n workflowRunStepId?: string | null | undefined;\n contextKey?: string | undefined;\n outputSchema?: Record<string, unknown> | undefined;\n followUpConfig?:\n | {\n disabled?: boolean | undefined;\n onCompleted?: string | undefined;\n onFailed?: string | undefined;\n }\n | undefined;\n deferredAt?: string | undefined;\n compactionCount?: number | undefined;\n peakContextPercent?: number | undefined;\n peakContextTokens?: number | undefined;\n contextWindowSize?: number | undefined;\n credentialKeySuffix?: string | undefined;\n credentialKeyType?: string | undefined;\n requestedByUserId?: string | undefined;\n swarmVersion?: string | undefined;\n provider?:\n | "claude"\n | "codex"\n | "pi"\n | "devin"\n | "claude-managed"\n | "opencode"\n | "acp"\n | "dsh"\n | "amp"\n | "cursor"\n | "grok"\n | "fx"\n | undefined;\n providerMeta?: Record<string, unknown> | undefined;\n harnessVariant?: string | undefined;\n harnessVariantMeta?: Record<string, unknown> | undefined;\n totalCostUsd?: number | undefined;\n routingAffinity?:\n | {\n capabilities: string[];\n sourceAgentId?: string | undefined;\n role?: string | undefined;\n harnessProvider?:\n | "claude"\n | "codex"\n | "pi"\n | "devin"\n | "claude-managed"\n | "opencode"\n | "acp"\n | "dsh"\n | "amp"\n | "cursor"\n | "grok"\n | "fx"\n | undefined;\n leadOnly?: boolean | undefined;\n }\n | undefined;\n routingAffinityInvalid?: boolean | undefined;\n };\n\n export type ActiveSession = {\n id: string;\n agentId: string;\n taskId: string | null;\n triggerType: string;\n inboxMessageId: string | null;\n taskDescription: string | null;\n runnerSessionId: string | null;\n providerSessionId: string | null;\n startedAt: string;\n lastHeartbeatAt: string;\n runtimeInstanceId?: string | null | undefined;\n };\n\n export type SteerMode = "steer" | "queue";\n\n export type SteeringSource = "script" | "slack" | "mcp" | "api" | "ui" | "chat";\n\n export type RequestInfo = {\n sessionId: string | undefined;\n agentId: string | undefined;\n runtimeInstanceId: string | undefined;\n sourceTaskId: string | undefined;\n contextKey: string | undefined;\n callOrigin: "mcp" | "extension" | "script-sdk";\n };\n\n import type { SwarmSdk } from "swarm-sdk";\n import type { z } from "zod";\n export type Runtime = "api" | "worker";\n export interface ExtensionScriptAsset {\n name: string;\n file: string;\n description: string;\n intent?: string;\n }\n export interface ExtensionScheduleAsset {\n name: string;\n description?: string;\n script: string;\n cronExpression?: string;\n intervalMs?: number;\n timezone?: string;\n args?: Record<string, unknown>;\n }\n export interface ExtensionWorkflowAsset {\n file: string;\n }\n export interface ExtensionSkillAsset {\n dir: string;\n }\n export interface ExtensionManifest {\n $schema?: string;\n name: string;\n description: string;\n version: string;\n runtime: Runtime;\n assets: {\n hooks: string;\n scripts?: readonly ExtensionScriptAsset[];\n schedules?: readonly ExtensionScheduleAsset[];\n workflows?: readonly ExtensionWorkflowAsset[];\n skills?: readonly ExtensionSkillAsset[];\n };\n homepage?: string;\n author?: string;\n }\n export interface HooksModule {\n default: SwarmExtension;\n config?: z.ZodTypeAny;\n }\n export interface ExtensionState {\n get<T = unknown>(key: string): Promise<T | null>;\n set<T>(key: string, value: T): Promise<void>;\n incr(key: string, by?: number): Promise<number>;\n del(key: string): Promise<void>;\n }\n export interface ExtensionLogger {\n debug(message: string, data?: unknown): void;\n info(message: string, data?: unknown): void;\n warn(message: string, data?: unknown): void;\n error(message: string, data?: unknown): void;\n }\n type ConfigFor<M extends ExtensionManifest> = M extends {\n config: infer C extends z.ZodTypeAny;\n }\n ? z.infer<C>\n : Record<string, unknown>;\n export interface ApiCtx<Config = Record<string, unknown>> {\n swarm: SwarmSdk;\n state: ExtensionState;\n config: Config;\n log: ExtensionLogger;\n signal: AbortSignal;\n event: {\n name: keyof SwarmEventMap;\n at: string;\n extension: {\n id: string;\n version: number;\n };\n };\n }\n export interface WorkerCtx<Config = Record<string, unknown>>\n extends Omit<ApiCtx<Config>, "swarm"> {\n swarm: SwarmSdk;\n worker: {\n agentId: string;\n taskId: string;\n harness: string;\n };\n }\n export type CtxFor<M extends ExtensionManifest> = M["runtime"] extends "api"\n ? ApiCtx<ConfigFor<M>>\n : WorkerCtx<ConfigFor<M>>;\n export type PreResult<Modify> =\n | void\n | {\n action: "continue";\n }\n | {\n action: "modify";\n data: Modify;\n }\n | {\n action: "block";\n reason: string;\n };\n export type TaskCreateOrigin =\n | "rest"\n | "app"\n | "mcp"\n | "slack"\n | "schedule"\n | "workflow"\n | "webhook"\n | "followUp"\n | `extension:${string}`;\n export interface TaskCreateEvent {\n options: CreateTaskOptions;\n description: string;\n origin: TaskCreateOrigin;\n requestInfo?: RequestInfo;\n /** Slack ingress metadata; not persisted or writable through modify. */\n slack?: {\n trigger: "mention" | "thread-buffer";\n messages: {\n ts: string;\n userId: string;\n text: string;\n }[];\n };\n }\n /** A pre.task.create hook blocked a task before it was created. */\n export interface TaskBlockedEvent {\n /** The extension that blocked, or whose model/agent rewrite was rejected. */\n extension: {\n id: string;\n name: string;\n };\n /** The scrubbed block reason. */\n reason: string;\n origin: TaskCreateOrigin;\n source?: AgentTask["source"];\n requester: {\n userId?: string;\n agentId?: string;\n slackUserId?: string;\n };\n context?: {\n contextKey?: string;\n scheduleId?: string;\n workflowRunId?: string;\n workflowRunStepId?: string;\n parentTaskId?: string;\n vcsRepo?: string;\n vcsNumber?: number;\n slackChannelId?: string;\n slackThreadTs?: string;\n };\n /** The original task description, scrubbed and cut to 500 characters. */\n description: string;\n }\n export type TaskCreateModify = Partial<\n Pick<\n CreateTaskOptions,\n | "agentId"\n | "creatorAgentId"\n | "source"\n | "taskType"\n | "tags"\n | "priority"\n | "dependsOn"\n | "offeredTo"\n | "vcsProvider"\n | "vcsRepo"\n | "vcsEventType"\n | "vcsNumber"\n | "vcsCommentId"\n | "vcsAuthor"\n | "vcsUrl"\n | "vcsInstallationId"\n | "vcsNodeId"\n | "agentmailInboxId"\n | "agentmailMessageId"\n | "agentmailThreadId"\n | "mentionMessageId"\n | "mentionChannelId"\n | "dir"\n | "model"\n | "modelTier"\n | "effort"\n | "outputSchema"\n | "followUpConfig"\n | "bypassTrackerContextDedup"\n >\n > & {\n description?: string;\n };\n export interface TaskFollowUpEvent {\n completedTask: AgentTask;\n status: "completed" | "failed";\n output?: string;\n failureReason?: string;\n workerAgentId: string;\n leadAgentId: string;\n summary: string;\n }\n export interface TaskSteerEvent {\n task: AgentTask;\n message: string;\n mode: SteerMode;\n source: SteeringSource;\n sender: {\n kind: "user" | "agent" | "system";\n userId?: string;\n agentId?: string;\n };\n messageTimestamps?: string[];\n /** Slack ingress metadata; not persisted or writable through modify. */\n slack?: {\n channelId: string;\n threadTs: string;\n userId?: string;\n };\n }\n export interface TaskSteerModify {\n message: string;\n }\n export type TaskFollowUpModify = Partial<\n Pick<CreateTaskOptions, "agentId" | "priority" | "followUpConfig">\n > & {\n description?: string;\n };\n export interface SlackRouteEvent {\n channelId: string;\n userId: string;\n text: string;\n threadTs?: string;\n botMentioned: boolean;\n threadContext?: {\n channelId: string;\n threadTs: string;\n };\n }\n export interface SlackRouteModify {\n target:\n | {\n kind: "agent";\n agentId: string;\n }\n | {\n kind: "lead";\n }\n | {\n kind: "broadcast";\n };\n }\n /** A Chat SDK message after its thread buffer flushed, before routing. */\n export interface ChatRouteEvent {\n /** Adapter name, such as `telegram` or `slack`. */\n adapter: string;\n channelId: string;\n /** The Chat SDK thread id, prefixed with the adapter name. */\n threadId: string;\n /** The first buffered sender. */\n userId: string;\n userName?: string;\n /** The buffered messages, joined. */\n text: string;\n /** True for an @mention and for a reply to one of the bot\'s messages. */\n botMentioned: boolean;\n isDirectMessage: boolean;\n /** Platform chat type, such as Telegram `private`, `group`, `supergroup` or `channel`. */\n chatType?: string;\n /** Set for a Telegram supergroup with topics. */\n isForum?: boolean;\n /** A buffered message replies to one of the bot\'s own messages. */\n replyToBot: boolean;\n /** Set when earlier swarm tasks exist in this thread. */\n threadContext?: {\n adapter: string;\n threadId: string;\n };\n }\n export interface ChatRouteModify {\n target:\n | {\n kind: "agent";\n agentId: string;\n }\n | {\n kind: "lead";\n }\n | {\n kind: "broadcast";\n }\n | {\n kind: "workflow";\n workflowId: string;\n };\n }\n export type HeartbeatClassification = "no-session" | "stale-session" | "fresh-stalled";\n export type HeartbeatAction = "supersede-resume" | "fail" | "record";\n export interface HeartbeatRemediateEvent {\n task: AgentTask;\n session?: ActiveSession;\n classification: HeartbeatClassification;\n proposedAction: HeartbeatAction;\n reason: string;\n taskAgeMs: number;\n sessionHeartbeatAgeMs?: number;\n }\n export interface HeartbeatRemediateModify {\n proposedAction: HeartbeatAction;\n }\n export interface ToolCallEvent {\n tool: string;\n args: unknown;\n requestInfo: RequestInfo;\n }\n export interface ToolCallModify {\n args: unknown;\n }\n export interface TaskEvent {\n task: AgentTask;\n }\n export interface TaskCompletedEvent extends TaskEvent {\n output: string;\n }\n export interface TaskFailedEvent extends TaskEvent {\n failureReason: string;\n }\n export interface TaskSupersededEvent extends TaskEvent {\n supersededBy: string;\n }\n export interface TaskProgressEvent extends TaskEvent {\n progress: string;\n }\n export interface SlackMessageEvent {\n channelId: string;\n userId: string;\n text: string;\n threadTs?: string;\n taskId?: string;\n }\n /** A Chat SDK message the swarm received or sent. */\n export interface ChatMessageEvent {\n adapter: string;\n channelId: string;\n threadId: string;\n /** The sender, for an inbound message. */\n userId?: string;\n text: string;\n direction: "inbound" | "outbound";\n taskId?: string;\n messageId?: string;\n }\n /**\n * A person answered an approval request. Fires for workflow and standalone\n * requests. Timeouts and cancellations do not emit it today.\n */\n export interface ApprovalResolvedEvent {\n requestId: string;\n status: "approved" | "rejected" | "timeout" | "cancelled";\n responses: Record<string, unknown> | null;\n /** Set when a workflow human-in-the-loop step asked. Absent for a standalone request. */\n workflowRunId?: string;\n workflowRunStepId?: string;\n /** The task whose agent asked, for a standalone request. */\n sourceTaskId?: string;\n }\n /** A task was refused because a daily spend budget is used up. */\n export interface TaskBudgetRefusedEvent extends TaskEvent {\n /** The agent the task was refused for. */\n agentId: string;\n /** Which budget refused it. The matching spend and budget fields are set. */\n cause: "agent" | "global" | "user";\n agentSpendUsd?: number;\n agentBudgetUsd?: number;\n globalSpendUsd?: number;\n globalBudgetUsd?: number;\n userSpendUsd?: number;\n userBudgetUsd?: number;\n /** ISO 8601 time the daily budget resets. */\n resetAt: string;\n }\n /** An inbound AgentMail message. */\n export interface EmailReceivedEvent {\n inboxId: string;\n /** The From header as sent. */\n from: string;\n subject: string;\n /** The text body, or the HTML when there is no text, cut to 500 characters with `...` appended. */\n body: string;\n threadId: string;\n messageId: string;\n }\n /** An inbound Kapso (WhatsApp) message. */\n export interface KapsoMessageEvent {\n phoneNumberId: string;\n conversationId?: string;\n messageId: string;\n from?: string;\n /** Kapso message type, such as `text` or `image`. */\n type?: string;\n /** The text, or a placeholder naming the type for a non-text message. */\n text: string;\n }\n export type VcsProvider = "github" | "gitlab" | "azure-devops" | "bitbucket";\n /**\n * The provider object the event is about, as the provider names it. GitLab\n * calls a pull request a merge request, and a comment a `note`.\n */\n export type VcsEventKind =\n | "pull_request"\n | "merge_request"\n | "issue"\n | "issue_comment"\n | "note"\n | "pull_request_review"\n | "pipeline";\n /**\n * A webhook event from a connected code host. `action` is the provider\'s own\n * value: `opened`, `closed`, `synchronize`, `merge`, `created`, `commented`, or,\n * for a pipeline, its status such as `success` or `failed`. Fields a kind does\n * not carry are absent.\n */\n export interface VcsEvent {\n provider: VcsProvider;\n kind: VcsEventKind;\n action: string;\n /** `owner/name` on GitHub and GitLab, `workspace/repo_slug` on Bitbucket, the repository URL on Azure DevOps. */\n repo: string;\n /** The PR, merge request, or issue number. Absent for a pipeline outside a merge request. */\n number?: number;\n title?: string;\n body?: string | null;\n /** Login of the user behind the event. Set for pull requests, merge requests, and Azure DevOps comments. */\n author?: string;\n url?: string;\n merged?: boolean;\n changedFiles?: number;\n /** The review verdict, on a pull request review. */\n reviewState?: string;\n }\n export interface ToolCallCompletedEvent extends ToolCallEvent {\n result: unknown;\n durationMs: number;\n }\n export interface SwarmEventMap {\n "pre.task.create": {\n event: TaskCreateEvent;\n modify: TaskCreateModify;\n result: PreResult<TaskCreateModify>;\n };\n "pre.task.followUp": {\n event: TaskFollowUpEvent;\n modify: TaskFollowUpModify;\n result: PreResult<TaskFollowUpModify>;\n };\n "pre.task.steer": {\n event: TaskSteerEvent;\n modify: TaskSteerModify;\n result: PreResult<TaskSteerModify>;\n };\n "pre.slack.route": {\n event: SlackRouteEvent;\n modify: SlackRouteModify;\n result: PreResult<SlackRouteModify>;\n };\n "pre.chat.route": {\n event: ChatRouteEvent;\n modify: ChatRouteModify;\n result: PreResult<ChatRouteModify>;\n };\n "pre.heartbeat.remediate": {\n event: HeartbeatRemediateEvent;\n modify: HeartbeatRemediateModify;\n result: PreResult<HeartbeatRemediateModify>;\n };\n "pre.tool.call": {\n event: ToolCallEvent;\n modify: ToolCallModify;\n result: PreResult<ToolCallModify>;\n };\n "post.task.created": {\n event: TaskEvent;\n modify: never;\n result: void;\n };\n "post.task.blocked": {\n event: TaskBlockedEvent;\n modify: never;\n result: void;\n };\n "post.task.completed": {\n event: TaskCompletedEvent;\n modify: never;\n result: void;\n };\n "post.task.failed": {\n event: TaskFailedEvent;\n modify: never;\n result: void;\n };\n "post.task.cancelled": {\n event: TaskEvent;\n modify: never;\n result: void;\n };\n "post.task.superseded": {\n event: TaskSupersededEvent;\n modify: never;\n result: void;\n };\n "post.task.progress": {\n event: TaskProgressEvent;\n modify: never;\n result: void;\n };\n "post.slack.message": {\n event: SlackMessageEvent;\n modify: never;\n result: void;\n };\n "post.chat.message": {\n event: ChatMessageEvent;\n modify: never;\n result: void;\n };\n "post.approval.resolved": {\n event: ApprovalResolvedEvent;\n modify: never;\n result: void;\n };\n "post.task.budgetRefused": {\n event: TaskBudgetRefusedEvent;\n modify: never;\n result: void;\n };\n "post.email.received": {\n event: EmailReceivedEvent;\n modify: never;\n result: void;\n };\n "post.kapso.message": {\n event: KapsoMessageEvent;\n modify: never;\n result: void;\n };\n "post.vcs.event": {\n event: VcsEvent;\n modify: never;\n result: void;\n };\n "post.tool.call": {\n event: ToolCallCompletedEvent;\n modify: never;\n result: void;\n };\n }\n export interface ExtensionApi<\n M extends ExtensionManifest = ExtensionManifest & {\n runtime: "api";\n },\n > {\n on<E extends keyof SwarmEventMap>(\n event: E,\n handler: (\n event: SwarmEventMap[E]["event"],\n ctx: CtxFor<M>,\n ) => Promise<SwarmEventMap[E]["result"]> | SwarmEventMap[E]["result"],\n opts?: {\n priority?: number;\n },\n ): void;\n }\n export type SwarmExtension<\n M extends ExtensionManifest = ExtensionManifest & {\n runtime: "api";\n },\n > = (api: ExtensionApi<M>) => void;\n export { block, modify } from "./contract-runtime";\n}\n';
|
|
4
|
+
'// biome-ignore-all lint/suspicious/noConfusingVoidType: Extension handlers may explicitly return no result.\ndeclare module "swarm-extension" {\n export type CreateTaskOptions = {\n key?: string | undefined;\n agentId?: string | null | undefined;\n creatorAgentId?: string | undefined;\n source?:\n | "chat"\n | "workflow"\n | "schedule"\n | "slack"\n | "agentmail"\n | "github"\n | "gitlab"\n | "azure-devops"\n | "bitbucket"\n | "linear"\n | "jira"\n | "mcp"\n | "api"\n | "ui"\n | "system"\n | "comb"\n | undefined;\n routingReason?:\n | "skill"\n | "continuity"\n | "overflow"\n | "human_pinned"\n | "reroute_fault"\n | undefined;\n routingSource?: "declared" | "engine_default" | undefined;\n routingNote?: string | undefined;\n taskType?: string | undefined;\n tags?: string[] | undefined;\n priority?: number | undefined;\n dependsOn?: string[] | undefined;\n offeredTo?: string | undefined;\n status?: "draft" | "backlog" | "unassigned" | undefined;\n slackChannelId?: string | undefined;\n slackThreadTs?: string | undefined;\n slackTriggerMessageTs?: string | undefined;\n slackUserId?: string | undefined;\n overrideSlackContext?: boolean | undefined;\n vcsProvider?: "github" | "gitlab" | "azure-devops" | "bitbucket" | undefined;\n vcsRepo?: string | undefined;\n vcsEventType?: string | undefined;\n vcsNumber?: number | undefined;\n vcsCommentId?: number | undefined;\n vcsAuthor?: string | undefined;\n vcsUrl?: string | undefined;\n vcsInstallationId?: number | undefined;\n vcsNodeId?: string | undefined;\n agentmailInboxId?: string | undefined;\n agentmailMessageId?: string | undefined;\n agentmailThreadId?: string | undefined;\n mentionMessageId?: string | undefined;\n mentionChannelId?: string | undefined;\n dir?: string | undefined;\n parentTaskId?: string | undefined;\n model?: string | undefined;\n modelTier?: "smol" | "regular" | "smart" | "ultra" | undefined;\n effort?: "low" | "medium" | "high" | "max" | "off" | "xhigh" | undefined;\n profile?: string | undefined;\n scheduleId?: string | undefined;\n workflowRunId?: string | undefined;\n workflowRunStepId?: string | undefined;\n sourceTaskId?: string | undefined;\n outputSchema?: Record<string, unknown> | undefined;\n inheritParentOutputSchema?: boolean | undefined;\n inheritParentRequester?: boolean | undefined;\n inheritParentRoutingAffinity?: boolean | undefined;\n inheritParentFollowUpConfig?: boolean | undefined;\n followUpConfig?:\n | {\n disabled?: boolean | undefined;\n onCompleted?: string | undefined;\n onFailed?: string | undefined;\n }\n | undefined;\n requestedByUserId?: string | undefined;\n contextKey?: string | undefined;\n bypassTrackerContextDedup?: boolean | undefined;\n routingAffinity?:\n | {\n capabilities: string[];\n sourceAgentId?: string | undefined;\n role?: string | undefined;\n harnessProvider?:\n | "pi"\n | "claude"\n | "claude-managed"\n | "codex"\n | "grok"\n | "fx"\n | "opencode"\n | "dsh"\n | "cursor"\n | "amp"\n | "devin"\n | "acp"\n | undefined;\n leadOnly?: boolean | undefined;\n }\n | undefined;\n };\n\n export type AgentTask = {\n id: string;\n key: string;\n agentId: string | null;\n task: string;\n status:\n | "skipped"\n | "draft"\n | "backlog"\n | "unassigned"\n | "offered"\n | "reviewing"\n | "pending"\n | "in_progress"\n | "paused"\n | "completed"\n | "failed"\n | "cancelled"\n | "superseded";\n source:\n | "chat"\n | "workflow"\n | "schedule"\n | "slack"\n | "agentmail"\n | "github"\n | "gitlab"\n | "azure-devops"\n | "bitbucket"\n | "linear"\n | "jira"\n | "mcp"\n | "api"\n | "ui"\n | "system"\n | "comb";\n tags: string[];\n priority: number;\n dependsOn: string[];\n createdAt: string;\n lastUpdatedAt: string;\n slackReplySent: boolean;\n wasPaused: boolean;\n creatorAgentId?: string | undefined;\n title?: string | undefined;\n routingReason?:\n | "skill"\n | "continuity"\n | "overflow"\n | "human_pinned"\n | "reroute_fault"\n | undefined;\n routingSource?: "declared" | "engine_default" | undefined;\n routingNote?: string | undefined;\n poolWakeAt?: string | undefined;\n taskType?: string | undefined;\n offeredTo?: string | undefined;\n offeredAt?: string | undefined;\n acceptedAt?: string | undefined;\n rejectionReason?: string | undefined;\n finishedAt?: string | undefined;\n notifiedAt?: string | undefined;\n failureReason?: string | undefined;\n output?: string | undefined;\n progress?: string | undefined;\n slackChannelId?: string | undefined;\n slackThreadTs?: string | undefined;\n slackTriggerMessageTs?: string | undefined;\n slackUserId?: string | undefined;\n slackProgressMessageTs?: string | undefined;\n slackTreeRootMessageTs?: string | undefined;\n vcsProvider?: "github" | "gitlab" | "azure-devops" | "bitbucket" | undefined;\n vcsRepo?: string | undefined;\n vcsEventType?: string | undefined;\n vcsNumber?: number | undefined;\n vcsCommentId?: number | undefined;\n vcsAuthor?: string | undefined;\n vcsUrl?: string | undefined;\n vcsInstallationId?: number | undefined;\n vcsNodeId?: string | undefined;\n agentmailInboxId?: string | undefined;\n agentmailMessageId?: string | undefined;\n agentmailThreadId?: string | undefined;\n mentionMessageId?: string | undefined;\n mentionChannelId?: string | undefined;\n dir?: string | undefined;\n parentTaskId?: string | undefined;\n claudeSessionId?: string | undefined;\n model?: string | undefined;\n modelTier?: "smol" | "regular" | "smart" | "ultra" | undefined;\n effort?: "low" | "medium" | "high" | "max" | "off" | "xhigh" | undefined;\n resolvedModel?: string | undefined;\n modelSource?: string | undefined;\n modelAlias?: string | undefined;\n resolvedEffort?: "low" | "medium" | "high" | "max" | "off" | "xhigh" | undefined;\n profile?: string | undefined;\n resolvedProfile?: string | undefined;\n scheduleId?: string | undefined;\n workflowRunId?: string | null | undefined;\n workflowRunStepId?: string | null | undefined;\n contextKey?: string | undefined;\n outputSchema?: Record<string, unknown> | undefined;\n followUpConfig?:\n | {\n disabled?: boolean | undefined;\n onCompleted?: string | undefined;\n onFailed?: string | undefined;\n }\n | undefined;\n deferredAt?: string | undefined;\n compactionCount?: number | undefined;\n peakContextPercent?: number | undefined;\n peakContextTokens?: number | undefined;\n contextWindowSize?: number | undefined;\n credentialKeySuffix?: string | undefined;\n credentialKeyType?: string | undefined;\n requestedByUserId?: string | undefined;\n swarmVersion?: string | undefined;\n provider?:\n | "pi"\n | "claude"\n | "claude-managed"\n | "codex"\n | "grok"\n | "fx"\n | "opencode"\n | "dsh"\n | "cursor"\n | "amp"\n | "devin"\n | "acp"\n | undefined;\n providerMeta?: Record<string, unknown> | undefined;\n harnessVariant?: string | undefined;\n harnessVariantMeta?: Record<string, unknown> | undefined;\n totalCostUsd?: number | undefined;\n routingAffinity?:\n | {\n capabilities: string[];\n sourceAgentId?: string | undefined;\n role?: string | undefined;\n harnessProvider?:\n | "pi"\n | "claude"\n | "claude-managed"\n | "codex"\n | "grok"\n | "fx"\n | "opencode"\n | "dsh"\n | "cursor"\n | "amp"\n | "devin"\n | "acp"\n | undefined;\n leadOnly?: boolean | undefined;\n }\n | undefined;\n routingAffinityInvalid?: boolean | undefined;\n };\n\n export type ActiveSession = {\n id: string;\n agentId: string;\n taskId: string | null;\n triggerType: string;\n inboxMessageId: string | null;\n taskDescription: string | null;\n runnerSessionId: string | null;\n providerSessionId: string | null;\n startedAt: string;\n lastHeartbeatAt: string;\n runtimeInstanceId?: string | null | undefined;\n };\n\n export type SteerMode = "steer" | "queue";\n\n export type SteeringSource = "chat" | "script" | "slack" | "mcp" | "api" | "ui";\n\n export type RequestInfo = {\n sessionId: string | undefined;\n agentId: string | undefined;\n runtimeInstanceId: string | undefined;\n sourceTaskId: string | undefined;\n contextKey: string | undefined;\n callOrigin: "mcp" | "extension" | "script-sdk";\n };\n\n import type { SwarmSdk } from "swarm-sdk";\n import type { z } from "zod";\n export type Runtime = "api" | "worker";\n export interface ExtensionScriptAsset {\n name: string;\n file: string;\n description: string;\n intent?: string;\n }\n export interface ExtensionScheduleAsset {\n name: string;\n description?: string;\n script: string;\n cronExpression?: string;\n intervalMs?: number;\n timezone?: string;\n args?: Record<string, unknown>;\n }\n export interface ExtensionWorkflowAsset {\n file: string;\n }\n export interface ExtensionSkillAsset {\n dir: string;\n }\n export interface ExtensionManifest {\n $schema?: string;\n name: string;\n description: string;\n version: string;\n runtime: Runtime;\n assets: {\n hooks: string;\n scripts?: readonly ExtensionScriptAsset[];\n schedules?: readonly ExtensionScheduleAsset[];\n workflows?: readonly ExtensionWorkflowAsset[];\n skills?: readonly ExtensionSkillAsset[];\n };\n homepage?: string;\n author?: string;\n }\n export interface HooksModule {\n default: SwarmExtension;\n config?: z.ZodTypeAny;\n }\n export interface ExtensionState {\n get<T = unknown>(key: string): Promise<T | null>;\n set<T>(key: string, value: T): Promise<void>;\n incr(key: string, by?: number): Promise<number>;\n del(key: string): Promise<void>;\n }\n export interface ExtensionLogger {\n debug(message: string, data?: unknown): void;\n info(message: string, data?: unknown): void;\n warn(message: string, data?: unknown): void;\n error(message: string, data?: unknown): void;\n }\n type ConfigFor<M extends ExtensionManifest> = M extends {\n config: infer C extends z.ZodTypeAny;\n }\n ? z.infer<C>\n : Record<string, unknown>;\n export interface ApiCtx<Config = Record<string, unknown>> {\n swarm: SwarmSdk;\n state: ExtensionState;\n config: Config;\n log: ExtensionLogger;\n signal: AbortSignal;\n event: {\n name: keyof SwarmEventMap;\n at: string;\n extension: {\n id: string;\n version: number;\n };\n };\n }\n export interface WorkerCtx<Config = Record<string, unknown>>\n extends Omit<ApiCtx<Config>, "swarm"> {\n swarm: SwarmSdk;\n worker: {\n agentId: string;\n taskId: string;\n harness: string;\n };\n }\n export type CtxFor<M extends ExtensionManifest> = M["runtime"] extends "api"\n ? ApiCtx<ConfigFor<M>>\n : WorkerCtx<ConfigFor<M>>;\n export type PreResult<Modify> =\n | void\n | {\n action: "continue";\n }\n | {\n action: "modify";\n data: Modify;\n }\n | {\n action: "block";\n reason: string;\n };\n export type TaskCreateOrigin =\n | "rest"\n | "app"\n | "mcp"\n | "slack"\n | "schedule"\n | "workflow"\n | "webhook"\n | "followUp"\n | `extension:${string}`;\n export interface TaskCreateEvent {\n options: CreateTaskOptions;\n description: string;\n origin: TaskCreateOrigin;\n requestInfo?: RequestInfo;\n /** Slack ingress metadata; not persisted or writable through modify. */\n slack?: {\n trigger: "mention" | "thread-buffer";\n messages: {\n ts: string;\n userId: string;\n text: string;\n }[];\n };\n }\n /** A pre.task.create hook blocked a task before it was created. */\n export interface TaskBlockedEvent {\n /** The extension that blocked, or whose model/agent rewrite was rejected. */\n extension: {\n id: string;\n name: string;\n };\n /** The scrubbed block reason. */\n reason: string;\n origin: TaskCreateOrigin;\n source?: AgentTask["source"];\n requester: {\n userId?: string;\n agentId?: string;\n slackUserId?: string;\n };\n context?: {\n contextKey?: string;\n scheduleId?: string;\n workflowRunId?: string;\n workflowRunStepId?: string;\n parentTaskId?: string;\n vcsRepo?: string;\n vcsNumber?: number;\n slackChannelId?: string;\n slackThreadTs?: string;\n };\n /** The original task description, scrubbed and cut to 500 characters. */\n description: string;\n }\n export type TaskCreateModify = Partial<\n Pick<\n CreateTaskOptions,\n | "agentId"\n | "creatorAgentId"\n | "source"\n | "taskType"\n | "tags"\n | "priority"\n | "dependsOn"\n | "offeredTo"\n | "vcsProvider"\n | "vcsRepo"\n | "vcsEventType"\n | "vcsNumber"\n | "vcsCommentId"\n | "vcsAuthor"\n | "vcsUrl"\n | "vcsInstallationId"\n | "vcsNodeId"\n | "agentmailInboxId"\n | "agentmailMessageId"\n | "agentmailThreadId"\n | "mentionMessageId"\n | "mentionChannelId"\n | "dir"\n | "model"\n | "modelTier"\n | "effort"\n | "outputSchema"\n | "followUpConfig"\n | "bypassTrackerContextDedup"\n >\n > & {\n description?: string;\n };\n export interface TaskFollowUpEvent {\n completedTask: AgentTask;\n status: "completed" | "failed";\n output?: string;\n failureReason?: string;\n workerAgentId: string;\n leadAgentId: string;\n summary: string;\n }\n export interface TaskSteerEvent {\n task: AgentTask;\n message: string;\n mode: SteerMode;\n source: SteeringSource;\n sender: {\n kind: "user" | "agent" | "system";\n userId?: string;\n agentId?: string;\n };\n messageTimestamps?: string[];\n /** Slack ingress metadata; not persisted or writable through modify. */\n slack?: {\n channelId: string;\n threadTs: string;\n userId?: string;\n };\n }\n export interface TaskSteerModify {\n message: string;\n }\n export type TaskFollowUpModify = Partial<\n Pick<CreateTaskOptions, "agentId" | "priority" | "followUpConfig">\n > & {\n description?: string;\n };\n export interface SlackRouteEvent {\n channelId: string;\n userId: string;\n text: string;\n threadTs?: string;\n botMentioned: boolean;\n threadContext?: {\n channelId: string;\n threadTs: string;\n };\n }\n export interface SlackRouteModify {\n target:\n | {\n kind: "agent";\n agentId: string;\n }\n | {\n kind: "lead";\n }\n | {\n kind: "broadcast";\n };\n }\n /** A Chat SDK message after its thread buffer flushed, before routing. */\n export interface ChatRouteEvent {\n /** Adapter name, such as `telegram` or `slack`. */\n adapter: string;\n channelId: string;\n /** The Chat SDK thread id, prefixed with the adapter name. */\n threadId: string;\n /** The first buffered sender. */\n userId: string;\n userName?: string;\n /** The buffered messages, joined. */\n text: string;\n /** True for an @mention and for a reply to one of the bot\'s messages. */\n botMentioned: boolean;\n isDirectMessage: boolean;\n /** Platform chat type, such as Telegram `private`, `group`, `supergroup` or `channel`. */\n chatType?: string;\n /** Set for a Telegram supergroup with topics. */\n isForum?: boolean;\n /** A buffered message replies to one of the bot\'s own messages. */\n replyToBot: boolean;\n /** Set when earlier swarm tasks exist in this thread. */\n threadContext?: {\n adapter: string;\n threadId: string;\n };\n }\n export interface ChatRouteModify {\n target:\n | {\n kind: "agent";\n agentId: string;\n }\n | {\n kind: "lead";\n }\n | {\n kind: "broadcast";\n }\n | {\n kind: "workflow";\n workflowId: string;\n };\n }\n export type HeartbeatClassification = "no-session" | "stale-session" | "fresh-stalled";\n export type HeartbeatAction = "supersede-resume" | "fail" | "record";\n export interface HeartbeatRemediateEvent {\n task: AgentTask;\n session?: ActiveSession;\n classification: HeartbeatClassification;\n proposedAction: HeartbeatAction;\n reason: string;\n taskAgeMs: number;\n sessionHeartbeatAgeMs?: number;\n }\n export interface HeartbeatRemediateModify {\n proposedAction: HeartbeatAction;\n }\n export interface ToolCallEvent {\n tool: string;\n args: unknown;\n requestInfo: RequestInfo;\n }\n export interface ToolCallModify {\n args: unknown;\n }\n export interface TaskEvent {\n task: AgentTask;\n }\n export interface TaskCompletedEvent extends TaskEvent {\n output: string;\n }\n export interface TaskFailedEvent extends TaskEvent {\n failureReason: string;\n }\n export interface TaskSupersededEvent extends TaskEvent {\n supersededBy: string;\n }\n export interface TaskProgressEvent extends TaskEvent {\n progress: string;\n }\n export interface SlackMessageEvent {\n channelId: string;\n userId: string;\n text: string;\n threadTs?: string;\n taskId?: string;\n }\n /** A Chat SDK message the swarm received or sent. */\n export interface ChatMessageEvent {\n adapter: string;\n channelId: string;\n threadId: string;\n /** The sender, for an inbound message. */\n userId?: string;\n text: string;\n direction: "inbound" | "outbound";\n taskId?: string;\n messageId?: string;\n }\n /**\n * A person answered an approval request. Fires for workflow and standalone\n * requests. Timeouts and cancellations do not emit it today.\n */\n export interface ApprovalResolvedEvent {\n requestId: string;\n status: "approved" | "rejected" | "timeout" | "cancelled";\n responses: Record<string, unknown> | null;\n /** Set when a workflow human-in-the-loop step asked. Absent for a standalone request. */\n workflowRunId?: string;\n workflowRunStepId?: string;\n /** The task whose agent asked, for a standalone request. */\n sourceTaskId?: string;\n }\n /** A task was refused because a daily spend budget is used up. */\n export interface TaskBudgetRefusedEvent extends TaskEvent {\n /** The agent the task was refused for. */\n agentId: string;\n /** Which budget refused it. The matching spend and budget fields are set. */\n cause: "agent" | "global" | "user";\n agentSpendUsd?: number;\n agentBudgetUsd?: number;\n globalSpendUsd?: number;\n globalBudgetUsd?: number;\n userSpendUsd?: number;\n userBudgetUsd?: number;\n /** ISO 8601 time the daily budget resets. */\n resetAt: string;\n }\n /** An inbound AgentMail message. */\n export interface EmailReceivedEvent {\n inboxId: string;\n /** The From header as sent. */\n from: string;\n subject: string;\n /** The text body, or the HTML when there is no text, cut to 500 characters with `...` appended. */\n body: string;\n threadId: string;\n messageId: string;\n }\n /** An inbound Kapso (WhatsApp) message. */\n export interface KapsoMessageEvent {\n phoneNumberId: string;\n conversationId?: string;\n messageId: string;\n from?: string;\n /** Kapso message type, such as `text` or `image`. */\n type?: string;\n /** The text, or a placeholder naming the type for a non-text message. */\n text: string;\n }\n export type VcsProvider = "github" | "gitlab" | "azure-devops" | "bitbucket";\n /**\n * The provider object the event is about, as the provider names it. GitLab\n * calls a pull request a merge request, and a comment a `note`.\n */\n export type VcsEventKind =\n | "pull_request"\n | "merge_request"\n | "issue"\n | "issue_comment"\n | "note"\n | "pull_request_review"\n | "pipeline";\n /**\n * A webhook event from a connected code host. `action` is the provider\'s own\n * value: `opened`, `closed`, `synchronize`, `merge`, `created`, `commented`, or,\n * for a pipeline, its status such as `success` or `failed`. Fields a kind does\n * not carry are absent.\n */\n export interface VcsEvent {\n provider: VcsProvider;\n kind: VcsEventKind;\n action: string;\n /** `owner/name` on GitHub and GitLab, `workspace/repo_slug` on Bitbucket, the repository URL on Azure DevOps. */\n repo: string;\n /** The PR, merge request, or issue number. Absent for a pipeline outside a merge request. */\n number?: number;\n title?: string;\n body?: string | null;\n /** Login of the user behind the event. Set for pull requests, merge requests, and Azure DevOps comments. */\n author?: string;\n url?: string;\n merged?: boolean;\n changedFiles?: number;\n /** The review verdict, on a pull request review. */\n reviewState?: string;\n }\n export interface ToolCallCompletedEvent extends ToolCallEvent {\n result: unknown;\n durationMs: number;\n }\n export interface SwarmEventMap {\n "pre.task.create": {\n event: TaskCreateEvent;\n modify: TaskCreateModify;\n result: PreResult<TaskCreateModify>;\n };\n "pre.task.followUp": {\n event: TaskFollowUpEvent;\n modify: TaskFollowUpModify;\n result: PreResult<TaskFollowUpModify>;\n };\n "pre.task.steer": {\n event: TaskSteerEvent;\n modify: TaskSteerModify;\n result: PreResult<TaskSteerModify>;\n };\n "pre.slack.route": {\n event: SlackRouteEvent;\n modify: SlackRouteModify;\n result: PreResult<SlackRouteModify>;\n };\n "pre.chat.route": {\n event: ChatRouteEvent;\n modify: ChatRouteModify;\n result: PreResult<ChatRouteModify>;\n };\n "pre.heartbeat.remediate": {\n event: HeartbeatRemediateEvent;\n modify: HeartbeatRemediateModify;\n result: PreResult<HeartbeatRemediateModify>;\n };\n "pre.tool.call": {\n event: ToolCallEvent;\n modify: ToolCallModify;\n result: PreResult<ToolCallModify>;\n };\n "post.task.created": {\n event: TaskEvent;\n modify: never;\n result: void;\n };\n "post.task.blocked": {\n event: TaskBlockedEvent;\n modify: never;\n result: void;\n };\n "post.task.completed": {\n event: TaskCompletedEvent;\n modify: never;\n result: void;\n };\n "post.task.failed": {\n event: TaskFailedEvent;\n modify: never;\n result: void;\n };\n "post.task.cancelled": {\n event: TaskEvent;\n modify: never;\n result: void;\n };\n "post.task.superseded": {\n event: TaskSupersededEvent;\n modify: never;\n result: void;\n };\n "post.task.progress": {\n event: TaskProgressEvent;\n modify: never;\n result: void;\n };\n "post.slack.message": {\n event: SlackMessageEvent;\n modify: never;\n result: void;\n };\n "post.chat.message": {\n event: ChatMessageEvent;\n modify: never;\n result: void;\n };\n "post.approval.resolved": {\n event: ApprovalResolvedEvent;\n modify: never;\n result: void;\n };\n "post.task.budgetRefused": {\n event: TaskBudgetRefusedEvent;\n modify: never;\n result: void;\n };\n "post.email.received": {\n event: EmailReceivedEvent;\n modify: never;\n result: void;\n };\n "post.kapso.message": {\n event: KapsoMessageEvent;\n modify: never;\n result: void;\n };\n "post.vcs.event": {\n event: VcsEvent;\n modify: never;\n result: void;\n };\n "post.tool.call": {\n event: ToolCallCompletedEvent;\n modify: never;\n result: void;\n };\n }\n export interface ExtensionApi<\n M extends ExtensionManifest = ExtensionManifest & {\n runtime: "api";\n },\n > {\n on<E extends keyof SwarmEventMap>(\n event: E,\n handler: (\n event: SwarmEventMap[E]["event"],\n ctx: CtxFor<M>,\n ) => Promise<SwarmEventMap[E]["result"]> | SwarmEventMap[E]["result"],\n opts?: {\n priority?: number;\n },\n ): void;\n }\n export type SwarmExtension<\n M extends ExtensionManifest = ExtensionManifest & {\n runtime: "api";\n },\n > = (api: ExtensionApi<M>) => void;\n export { block, modify } from "./contract-runtime";\n}\n';
|
package/src/hooks/hook.ts
CHANGED
|
@@ -11,6 +11,7 @@ import {
|
|
|
11
11
|
} from "../be/memory/raters/llm";
|
|
12
12
|
import { materializeClaudeMd, stopClaudeMd } from "../commands/claude-md-session";
|
|
13
13
|
import {
|
|
14
|
+
advanceIdentityBaselines,
|
|
14
15
|
buildIndependentIdentityPayloads,
|
|
15
16
|
contentSha256,
|
|
16
17
|
fetchWithSyncTimeout,
|
|
@@ -148,7 +149,7 @@ export async function postHookProfileUpdate({
|
|
|
148
149
|
body: ProfilePayload["body"];
|
|
149
150
|
label: string;
|
|
150
151
|
fetchImpl?: typeof fetch;
|
|
151
|
-
}): Promise<
|
|
152
|
+
}): Promise<boolean> {
|
|
152
153
|
try {
|
|
153
154
|
const response = await fetchImpl(url, {
|
|
154
155
|
method: "PUT",
|
|
@@ -166,9 +167,11 @@ export async function postHookProfileUpdate({
|
|
|
166
167
|
),
|
|
167
168
|
);
|
|
168
169
|
}
|
|
170
|
+
return response.ok;
|
|
169
171
|
} catch (error) {
|
|
170
172
|
const message = error instanceof Error ? error.message : String(error);
|
|
171
173
|
console.error(scrubSecrets(`[hook] ${label} profile sync errored: ${message}`));
|
|
174
|
+
return false;
|
|
172
175
|
}
|
|
173
176
|
}
|
|
174
177
|
|
|
@@ -676,10 +679,10 @@ export async function handleHook(): Promise<void> {
|
|
|
676
679
|
/**
|
|
677
680
|
* Sync SOUL.md and IDENTITY.md content back to the server.
|
|
678
681
|
*
|
|
679
|
-
*
|
|
680
|
-
*
|
|
681
|
-
*
|
|
682
|
-
*
|
|
682
|
+
* Loads the baseline hashes and skips any file whose content hasn't changed.
|
|
683
|
+
* This prevents clobbering DB-side edits that Lead made via `update-profile`
|
|
684
|
+
* during the running session: at Stop, and on a `"self_edit"` too, where an
|
|
685
|
+
* edit to one file re-reads all four.
|
|
683
686
|
*/
|
|
684
687
|
const syncIdentityFilesToServer = async (
|
|
685
688
|
agentId: string,
|
|
@@ -687,7 +690,7 @@ export async function handleHook(): Promise<void> {
|
|
|
687
690
|
): Promise<void> => {
|
|
688
691
|
if (!mcpConfig) return;
|
|
689
692
|
|
|
690
|
-
const baselines =
|
|
693
|
+
const baselines = await readIdentityBaselines();
|
|
691
694
|
|
|
692
695
|
const updates: Record<string, string> = {};
|
|
693
696
|
|
|
@@ -747,14 +750,19 @@ export async function handleHook(): Promise<void> {
|
|
|
747
750
|
|
|
748
751
|
if (Object.keys(updates).length === 0) return;
|
|
749
752
|
|
|
750
|
-
|
|
751
|
-
|
|
753
|
+
const synced: Record<string, string> = {};
|
|
754
|
+
for (const [field, value] of Object.entries(updates)) {
|
|
755
|
+
const [payload] = buildIndependentIdentityPayloads({ [field]: value }, changeSource);
|
|
756
|
+
if (!payload) continue;
|
|
757
|
+
const ok = await postHookProfileUpdate({
|
|
752
758
|
url: `${getBaseUrl()}/api/agents/${agentId}/profile`,
|
|
753
759
|
headers: mcpConfig.headers,
|
|
754
760
|
body: payload.body,
|
|
755
761
|
label: payload.label,
|
|
756
762
|
});
|
|
763
|
+
if (ok) synced[field] = value;
|
|
757
764
|
}
|
|
765
|
+
await advanceIdentityBaselines(synced);
|
|
758
766
|
};
|
|
759
767
|
|
|
760
768
|
/**
|
|
@@ -792,9 +800,11 @@ export async function handleHook(): Promise<void> {
|
|
|
792
800
|
warnProfileFileTooLarge(agentId, "setupScript", content.length, "hook");
|
|
793
801
|
return;
|
|
794
802
|
}
|
|
803
|
+
// Unchanged since it last matched the DB: not an edit, so don't send it.
|
|
804
|
+
if ((await readIdentityBaselines())?.setupScript === contentSha256(content)) return;
|
|
795
805
|
|
|
796
806
|
try {
|
|
797
|
-
await fetch(`${getBaseUrl()}/api/agents/${agentId}/profile`, {
|
|
807
|
+
const resp = await fetch(`${getBaseUrl()}/api/agents/${agentId}/profile`, {
|
|
798
808
|
method: "PUT",
|
|
799
809
|
headers: {
|
|
800
810
|
...mcpConfig.headers,
|
|
@@ -802,6 +812,7 @@ export async function handleHook(): Promise<void> {
|
|
|
802
812
|
},
|
|
803
813
|
body: JSON.stringify({ setupScript: content, changeSource }),
|
|
804
814
|
});
|
|
815
|
+
if (resp.ok) await advanceIdentityBaselines({ setupScript: content });
|
|
805
816
|
} catch {
|
|
806
817
|
/* silently fail */
|
|
807
818
|
}
|