@desplega.ai/agent-swarm 2.7.9 → 2.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/acp-adapter-t949vbbp.js +15 -0
- package/dist/{actions-g563mbn2.js → actions-7e9czc7s.js} +19 -19
- package/dist/{amp-adapter-q61w05eb.js → amp-adapter-gv6cbb7d.js} +2 -3
- package/dist/app-b9fbkp9v.js +20 -0
- package/dist/{assistant-p477rjwj.js → assistant-wjb7v4c7.js} +22 -22
- package/dist/{boot-args-schema-h4qj462e.js → boot-args-schema-2t37e0fe.js} +1 -1
- package/dist/{boot-reembed-n1ehfbsw.js → boot-reembed-a35nkyr1.js} +1 -1
- package/dist/{boot-reembed-qw4mc0pt.js → boot-reembed-gka3zas7.js} +1 -1
- package/dist/{boot-scrub-sweep-9w9jp4sm.js → boot-scrub-sweep-65sdnp6c.js} +3 -3
- package/dist/{boot-seeds-qdaf3sdy.js → boot-seeds-x42tzytw.js} +4 -5
- package/dist/{claude-adapter-348p5hx9.js → claude-adapter-v221b2fd.js} +7 -8
- package/dist/{claude-managed-adapter-h74d06yz.js → claude-managed-adapter-29eq09wd.js} +2 -2
- package/dist/{claude-managed-setup-7787fxtp.js → claude-managed-setup-9m6450zk.js} +2 -2
- package/dist/{claude-sdk-session-hbszbt8a.js → claude-sdk-session-0q0ptaba.js} +9066 -8818
- package/dist/{cli-n5yexkdg.js → cli-0b4zam62.js} +1 -0
- package/dist/{cli-21159vea.js → cli-0jzra9ad.js} +2 -2
- package/dist/{cli-eqtfgfr6.js → cli-2gxeg5gr.js} +1 -1
- package/dist/{cli-k70e3x9e.js → cli-2wnq8jkz.js} +9 -9
- package/dist/{cli-cvs2r2vq.js → cli-2zp0et3v.js} +59 -6
- package/dist/{cli-650zv9q9.js → cli-334z18y3.js} +4 -4
- package/dist/{cli-12xyjhws.js → cli-3rkdne1h.js} +2 -2
- package/dist/{cli-2a8py3sx.js → cli-4txa0ter.js} +5 -7
- package/dist/{cli-jc1g9ndz.js → cli-5j88qqa8.js} +10 -5
- package/dist/{cli-xfjrc279.js → cli-5mrq3ake.js} +48 -14
- package/dist/{cli-v3cf1ts9.js → cli-6t09sdhy.js} +3 -3
- package/dist/{cli-qzt90yze.js → cli-6wxjceza.js} +8 -8
- package/dist/{cli-9aezs55w.js → cli-7b8sbmag.js} +8 -8
- package/dist/{cli-3xj33nrx.js → cli-7cp6aa1q.js} +10 -3
- package/dist/{cli-jfx48xrj.js → cli-7p1kvkck.js} +6 -6
- package/dist/{cli-b932gexn.js → cli-8aes17e4.js} +2 -2
- package/dist/{cli-3tqcamp6.js → cli-8fknbnhw.js} +14 -13
- package/dist/{cli-587857ys.js → cli-8kzasymh.js} +3 -3
- package/dist/{cli-sgs5k6yd.js → cli-a7wvp2km.js} +1 -1
- package/dist/{cli-varqt4d1.js → cli-abejgen1.js} +69 -22
- package/dist/{cli-rwymrnaz.js → cli-bsywb58a.js} +8 -8
- package/dist/{cli-btc9cb4c.js → cli-c55z5chy.js} +4 -6
- package/dist/{cli-ms5m5r1y.js → cli-deefvewm.js} +1 -1
- package/dist/{cli-p17970qv.js → cli-ee0b971j.js} +3 -3
- package/dist/cli-f3vq58d2.js +242 -0
- package/dist/{cli-3xcwp3z8.js → cli-ffhtssbp.js} +2 -2
- package/dist/{cli-hwprv9e4.js → cli-g70vxtjh.js} +2 -2
- package/dist/{cli-4t0fmf3z.js → cli-gxkx0zzp.js} +1 -1
- package/dist/{cli-neyag5p6.js → cli-h38x262p.js} +3365 -429
- package/dist/{cli-2ccpqyyf.js → cli-j790gp2w.js} +105 -22
- package/dist/{cli-f2zenhja.js → cli-kc7v1nfv.js} +1 -1
- package/dist/{cli-vxh6acp7.js → cli-m23zjcy2.js} +10 -10
- package/dist/{cli-y8nbefpb.js → cli-m28atx8q.js} +12 -10
- package/dist/{cli-serm8zrx.js → cli-m4dqmnbp.js} +1 -1
- package/dist/{cli-ybjdc978.js → cli-mrt48bx7.js} +7 -4
- package/dist/{cli-y5rbvxhc.js → cli-n515ex5z.js} +14 -14
- package/dist/{cli-ypff1qwp.js → cli-n9ftpys4.js} +7 -7
- package/dist/{cli-605nn699.js → cli-p1bq50aa.js} +894 -226
- package/dist/{cli-qkdmz8c8.js → cli-p1w18yhx.js} +1 -1
- package/dist/{cli-xk879m3k.js → cli-p2gfst4m.js} +52 -43
- package/dist/{cli-sya22y84.js → cli-pasjcnmj.js} +12 -12
- package/dist/{cli-0whpms1z.js → cli-qa4wdgsy.js} +5 -5
- package/dist/{cli-ejkvvqbe.js → cli-qfedvmcr.js} +50 -24
- package/dist/{cli-tqq0hspb.js → cli-qmqk2yc2.js} +1 -1
- package/dist/{cli-qmd3mse0.js → cli-qsnnd04k.js} +1 -1
- package/dist/{cli-agyaeef4.js → cli-qwca7s44.js} +3 -3
- package/dist/{cli-fayav105.js → cli-rfywm85n.js} +724 -792
- package/dist/{cli-zgv8gxgs.js → cli-rmmpt0wm.js} +6 -6
- package/dist/{cli-hae9j8sv.js → cli-rzsy6nc6.js} +12 -8
- package/dist/{cli-btf6fw39.js → cli-s7t6p9my.js} +1 -1
- package/dist/{cli-cseh6f8w.js → cli-sdtt3men.js} +1 -1
- package/dist/{cli-9r5gtwjr.js → cli-tk7cjj8h.js} +197 -2
- package/dist/{cli-q26b9wre.js → cli-tph5wt3y.js} +4 -4
- package/dist/{cli-gce09r66.js → cli-tqegb8eq.js} +3 -3
- package/dist/{cli-kf3pxxdg.js → cli-v1dv1r37.js} +1 -1
- package/dist/{cli-09kmfkmq.js → cli-wcg8x116.js} +1 -1
- package/dist/{cli-mnrkgg60.js → cli-wk18cm92.js} +5 -5
- package/dist/{cli-p0m0p34z.js → cli-x1wa213s.js} +3 -3
- package/dist/{cli-jrp1dt73.js → cli-xzm9vcfg.js} +1 -1
- package/dist/{cli-715t1gx6.js → cli-y97qxcfx.js} +9 -9
- package/dist/{cli-bc779n4v.js → cli-yq3zak69.js} +1 -1
- package/dist/cli.js +17 -17
- package/dist/{codex-adapter-ysq6bzha.js → codex-adapter-30j9bpzd.js} +5 -6
- package/dist/{codex-hook-fac6175r.js → codex-hook-h3vk6xzr.js} +1 -1
- package/dist/{codex-session-runner-qakzfx93.js → codex-session-runner-8vp57v8w.js} +5 -6
- package/dist/{commands-rs7hkv9r.js → commands-bngnz9g7.js} +3 -3
- package/dist/{controller-r5x9bg6e.js → controller-hxx8wwy1.js} +2 -2
- package/dist/{controllers-connect-498hrxvk.js → controllers-connect-e2b4gyxc.js} +20 -20
- package/dist/{cursor-adapter-d46qszer.js → cursor-adapter-n5nc3mfe.js} +1 -2
- package/dist/{db-s13dqhr6.js → db-bgm7vkc0.js} +3 -3
- package/dist/{db-pm96nhdb.js → db-c6np41ca.js} +12 -2
- package/dist/{devin-adapter-z46ep5ph.js → devin-adapter-xedz98zv.js} +1 -1
- package/dist/{dispatcher-j3h81t7m.js → dispatcher-jnybck15.js} +18 -18
- package/dist/{dsh-adapter-rw0d5rc4.js → dsh-adapter-nrhbrjz8.js} +1 -2
- package/dist/{easter-egg-3d-qtgfxgze.js → easter-egg-3d-533knw22.js} +1 -1
- package/dist/{embedding-space-xh8p4q4x.js → embedding-space-crsm2zp0.js} +6 -6
- package/dist/{embeddings-wp745m91.js → embeddings-e7z3f27f.js} +1 -1
- package/dist/{execute-2fzb9z74.js → execute-b3mrb1mv.js} +1 -1
- package/dist/{external-channel-ys21h3sy.js → external-channel-m77wf5z3.js} +2 -2
- package/dist/{fx-adapter-vz0b9z3g.js → fx-adapter-b6w0kf56.js} +7 -8
- package/dist/{google-generative-ai-ytpgncx9.js → google-generative-ai-h7s3e9kk.js} +1 -1
- package/dist/{google-vertex-tqhze5j7.js → google-vertex-fhxaafzw.js} +1 -1
- package/dist/{grok-adapter-spea7zkj.js → grok-adapter-4sqtebdk.js} +7 -8
- package/dist/handlers-kdjcyzdj.js +32 -0
- package/dist/heartbeat-xgb036sx.js +43 -0
- package/dist/{hook-amcj4s10.js → hook-5h02c9ga.js} +6 -6
- package/dist/{hook-bc6n49qn.js → hook-xsk1jbha.js} +5 -5
- package/dist/{http-7374brv5.js → http-txe7qhvn.js} +448 -165
- package/dist/{index-pxn30mse.js → index-0eny15vj.js} +8 -8
- package/dist/{index-5a9jtqde.js → index-0rvk3vd4.js} +46 -46
- package/dist/{index-fvzke5kx.js → index-1qw6f2dc.js} +10 -10
- package/dist/{index-q5cmtbz5.js → index-4a0670yh.js} +15939 -14244
- package/dist/index-835xdgnm.js +33 -0
- package/dist/index-d469300x.js +37 -0
- package/dist/{index-h7f61sy9.js → index-e5pfbsys.js} +3 -3
- package/dist/{index-hsad2t3r.js → index-m5gx1xd6.js} +38 -38
- package/dist/{index-5fx3b3kw.js → index-rvccek1w.js} +9 -9
- package/dist/index-rzqwp11g.js +32 -0
- package/dist/{index-w4m9z29z.js → index-tvfafeyy.js} +1 -1
- package/dist/{index-c9y31ytf.js → index-vk63emp7.js} +979 -35
- package/dist/{index-514d9pf6.js → index-w7em4ktq.js} +8 -8
- package/dist/{index-p4hjwbvw.js → index-ysvbhg5m.js} +1 -1
- package/dist/{keepalive-wy29kbrg.js → keepalive-4zsrce78.js} +3 -3
- package/dist/lead-yqt47dkr.js +70 -0
- package/dist/{maintenance-h2ds9w6c.js → maintenance-86jvartk.js} +1 -1
- package/dist/{oauth-refresh-sweep-q7mtbyp3.js → oauth-refresh-sweep-j52kg9pr.js} +2 -2
- package/dist/{onboard-vw8r2fdw.js → onboard-c2aj5p8q.js} +3 -3
- package/dist/{opencode-adapter-mtb0953j.js → opencode-adapter-dsagkhtw.js} +5 -6
- package/dist/{otel-impl-j42czw3r.js → otel-impl-yyy203z8.js} +1 -1
- package/dist/{pi-mono-adapter-zk8pg9jr.js → pi-mono-adapter-546cd1cc.js} +9 -9
- package/dist/{pricing-refresh-x7nhv23d.js → pricing-refresh-1rgzqyzz.js} +2 -3
- package/dist/{rbac-roles-9044425x.js → rbac-roles-e70xfeyj.js} +4 -6
- package/dist/{rbac-roles-bzvee6cf.js → rbac-roles-q89qe8er.js} +3 -3
- package/dist/{registry-hpjfmcfz.js → registry-32b1mft6.js} +1 -1
- package/dist/{render-v2-t7bn4skz.js → render-v2-k6tt107q.js} +9 -4
- package/dist/{resume-x94gemep.js → resume-cnnrjfxa.js} +6 -6
- package/dist/{runtime-breq6fmv.js → runtime-1hv06jsn.js} +1 -1
- package/dist/{session-access-q7dmqjvt.js → session-access-xkxkjw3n.js} +4 -4
- package/dist/{session-source-backfill-440ysamr.js → session-source-backfill-1d5pdwww.js} +2 -2
- package/dist/{setup-07n4727s.js → setup-se8q7gkc.js} +1 -1
- package/dist/{virtual-modules-z5h6mcyf.js → virtual-modules-gazyapte.js} +3 -3
- package/dist/{work-objects-pnq5y534.js → work-objects-1kxnbzy5.js} +22 -22
- package/dist/{worker-follow-up-7z1gfkr8.js → worker-follow-up-zqm8apt4.js} +18 -18
- package/dist/worker-j6xxtq7p.js +70 -0
- package/openapi.json +334 -7
- package/package.json +4 -4
- package/src/apps/catalog.generated.json +55 -0
- package/src/apps/definition.ts +11 -0
- package/src/apps/page-validator.ts +19 -0
- package/src/apps/store.ts +28 -8
- package/src/assets/key.ts +77 -4
- package/src/be/db/model-profiles.ts +147 -38
- package/src/be/db/session-labels.ts +57 -0
- package/src/be/db/session-tree.ts +51 -7
- package/src/be/db/slack-trees.ts +146 -0
- package/src/be/db/tasks/read.ts +107 -8
- package/src/be/db/workflow-run-definitions.ts +117 -0
- package/src/be/db-client.ts +8 -2
- package/src/be/db.ts +119 -87
- package/src/be/event-loop-lag.ts +146 -0
- package/src/be/mcp-overflow-sweep.ts +2 -1
- package/src/be/memory/constants.ts +14 -1
- package/src/be/memory/key-paths.ts +8 -0
- package/src/be/memory/providers/sqlite-store.ts +199 -18
- package/src/be/memory/task-learning.ts +79 -14
- package/src/be/memory/types.ts +24 -1
- package/src/be/migrations/278_slack_render_v2_reconcile.sql +108 -0
- package/src/be/migrations/279_backfill_learning_expiry.sql +15 -0
- package/src/be/migrations/281_model_profiles_pr2.sql +28 -0
- package/src/be/migrations/283_workflow_run_definitions.sql +14 -0
- package/src/be/model-profile-check.ts +284 -0
- package/src/be/model-tier-resolution.ts +112 -12
- package/src/be/multi-runtime.ts +27 -0
- package/src/be/runtime-pools/routing.ts +52 -4
- package/src/be/scripts/typecheck.ts +1 -0
- package/src/be/seed-scripts/catalog/dreaming-learnings.ts +552 -0
- package/src/be/seed-scripts/catalog/dreaming-memtax-create.ts +389 -14
- package/src/be/seed-scripts/catalog/dreaming-memtax.ts +6 -3
- package/src/be/seed-scripts/index.ts +9 -0
- package/src/be/steering.ts +8 -2
- package/src/be/swarm-config-guard.ts +2 -0
- package/src/commands/context-preamble.ts +258 -0
- package/src/commands/onboard/agent-fs-version.ts +1 -1
- package/src/commands/runner.ts +32 -1
- package/src/extensions/catalog.generated.json +3 -3
- package/src/fs/provider.ts +17 -3
- package/src/heartbeat/heartbeat.ts +17 -5
- package/src/heartbeat/index.ts +1 -0
- package/src/http/agents.ts +56 -4
- package/src/http/apps.ts +3 -1
- package/src/http/config.ts +2 -6
- package/src/http/core.ts +9 -3
- package/src/http/index.ts +12 -9
- package/src/http/memory.ts +9 -4
- package/src/http/model-profiles.ts +58 -10
- package/src/http/poll.ts +36 -3
- package/src/http/schedules.ts +42 -3
- package/src/http/sessions.ts +16 -3
- package/src/http/tasks.ts +37 -12
- package/src/http/utils.ts +18 -0
- package/src/http/webhooks.ts +48 -0
- package/src/http/workflows.ts +15 -2
- package/src/integrations/chat-sdk/commands.ts +167 -31
- package/src/integrations/chat-sdk/inbound.ts +10 -8
- package/src/integrations/chat-sdk/message-text.ts +117 -0
- package/src/prompts/session-templates.ts +1 -1
- package/src/providers/acp-targets.ts +11 -6
- package/src/providers/amp-adapter.ts +1 -1
- package/src/providers/claude-sdk-session.ts +132 -23
- package/src/providers/codex-skill-resolver.ts +10 -4
- package/src/providers/cursor-adapter.ts +1 -1
- package/src/providers/devin-skill-resolver.ts +5 -5
- package/src/providers/dsh-adapter.ts +1 -1
- package/src/scheduler/schedule-task.ts +1 -0
- package/src/scheduler/scheduler.ts +4 -1
- package/src/scripts-runtime/executors/quickjs-runner.ts +2 -0
- package/src/scripts-runtime/executors/quickjs-structured-clone.ts +180 -0
- package/src/scripts-runtime/quickjs-compat.ts +0 -1
- package/src/scripts-runtime/sdk-allowlist.ts +1 -0
- package/src/scripts-runtime/swarm-sdk.ts +18 -1
- package/src/scripts-runtime/types/stdlib.d.ts +1 -0
- package/src/scripts-runtime/types/swarm-sdk.d.ts +1 -0
- package/src/server.ts +2 -0
- package/src/slack/app.ts +425 -10
- package/src/slack/handlers.ts +9 -2
- package/src/slack/inbound-dispatch.ts +18 -1
- package/src/slack/index.ts +7 -1
- package/src/slack/lifecycle-lock.ts +29 -0
- package/src/slack/render-v2.ts +424 -212
- package/src/slack/socket-fence.ts +64 -0
- package/src/slack/watcher.ts +42 -8
- package/src/slack/workspace-guard.ts +345 -0
- package/src/tasks/task-terminal-effects.ts +4 -0
- package/src/tasks/worker-follow-up.ts +102 -2
- package/src/tests/acp-adapter.test.ts +82 -0
- package/src/tests/apps-icon.test.ts +120 -0
- package/src/tests/apps-schema-form.test.ts +151 -0
- package/src/tests/chained-task-follow-up.test.ts +248 -0
- package/src/tests/chat-sdk-commands.test.ts +359 -2
- package/src/tests/chat-sdk-inbound.test.ts +20 -0
- package/src/tests/chat-sdk-slack.test.ts +189 -1
- package/src/tests/check-pr-body.test.ts +40 -0
- package/src/tests/claude-sdk-lifecycle.test.ts +216 -1
- package/src/tests/claude-sdk-process.fixture.ts +57 -0
- package/src/tests/codex-skill-resolver.test.ts +31 -0
- package/src/tests/credentials-allowlist.test.ts +470 -0
- package/src/tests/db-client-busy-retry.test.ts +69 -18
- package/src/tests/db-client.test.ts +26 -1
- package/src/tests/db-task-read-contract.test.ts +7 -0
- package/src/tests/db-task-write-contract.test.ts +6 -0
- package/src/tests/deferred-wake-follow-up.test.ts +47 -0
- package/src/tests/docs-index-footprint.test.js +3 -3
- package/src/tests/dreaming-learnings.test.ts +1395 -0
- package/src/tests/dsh-adapter.test.ts +1 -1
- package/src/tests/event-loop-lag.test.ts +184 -0
- package/src/tests/explicit-model-validation.test.ts +2 -0
- package/src/tests/extensions-example-comms-adherence-gate.test.ts +115 -0
- package/src/tests/fs-provider.test.ts +42 -0
- package/src/tests/github-webhook-early-ack.test.ts +144 -0
- package/src/tests/heartbeat.test.ts +28 -1
- package/src/tests/http-api-integration.test.ts +2 -0
- package/src/tests/http-log-scrubbing.test.ts +68 -2
- package/src/tests/human-free-reclassify.test.ts +5 -1
- package/src/tests/kv-storage.test.ts +92 -1
- package/src/tests/list-endpoint-slimming.test.ts +17 -0
- package/src/tests/memory-key-paths.test.ts +57 -0
- package/src/tests/memory-retrieval-purge.test.ts +19 -0
- package/src/tests/migration-283-workflow-run-definitions.test.ts +69 -0
- package/src/tests/model-profile-check.test.ts +387 -0
- package/src/tests/model-profiles-api.test.ts +528 -1
- package/src/tests/profile-claim.test.ts +415 -3
- package/src/tests/profile-tier-alias.test.ts +382 -0
- package/src/tests/quickjs-compat.test.ts +1 -1
- package/src/tests/runner-context-preamble.test.ts +552 -0
- package/src/tests/schedule-profile.test.ts +359 -0
- package/src/tests/script-connections.test.ts +9 -0
- package/src/tests/script-executor-conformance.test.ts +188 -0
- package/src/tests/script-per-script-executor.test.ts +1 -0
- package/src/tests/scripts-sdk-bridge-tool-failure.test.ts +141 -0
- package/src/tests/seed-scripts.test.ts +2 -2
- package/src/tests/sessions-tree.test.ts +133 -2
- package/src/tests/slack-app-icon.test.ts +4 -0
- package/src/tests/slack-dm-implicit-mention.test.ts +236 -0
- package/src/tests/slack-file-tools-attachments.test.ts +1 -0
- package/src/tests/slack-inbound-receipts.test.ts +22 -2
- package/src/tests/slack-read-boundaries.test.ts +4 -3
- package/src/tests/slack-render-v2-query-plans.test.ts +262 -3
- package/src/tests/slack-render-v2-reconcile.test.ts +201 -0
- package/src/tests/slack-socket-ack.test.ts +16 -1
- package/src/tests/slack-socket-watchdog.test.ts +748 -0
- package/src/tests/slack-workspace-guard.test.ts +905 -0
- package/src/tests/steering-core.test.ts +40 -0
- package/src/tests/store-progress-learning.test.ts +605 -20
- package/src/tests/tool-annotations.test.ts +1 -1
- package/src/tests/vcs-identity-inheritance.test.ts +85 -0
- package/src/tests/workflow-convergence.test.ts +46 -40
- package/src/tests/workflow-definition-pinning-recovery.test.ts +552 -0
- package/src/tests/workflow-definition-pinning.test.ts +645 -0
- package/src/tests/workflow-executors.test.ts +16 -7
- package/src/tests/workflow-foreach.test.ts +43 -20
- package/src/tests/workflow-notify-slack-ready.test.ts +161 -0
- package/src/tests/workflow-profile.test.ts +328 -0
- package/src/tools/app-upsert.ts +1 -1
- package/src/tools/memory-edit.ts +2 -1
- package/src/tools/model-profiles/check-model-profile.ts +63 -0
- package/src/tools/schedules/create-schedule.ts +45 -4
- package/src/tools/schedules/patch-schedule.ts +50 -4
- package/src/tools/schedules/update-schedule.ts +50 -4
- package/src/tools/send-task.ts +17 -2
- package/src/tools/store-progress.ts +15 -3
- package/src/tools/task-action.ts +9 -1
- package/src/tools/templates.ts +13 -0
- package/src/tools/tool-config.ts +2 -1
- package/src/tools/utils.ts +77 -11
- package/src/tools/workflows/create-workflow.ts +1 -1
- package/src/tools/workflows/retry-workflow-run.ts +1 -1
- package/src/tools/workflows/update-workflow.ts +10 -1
- package/src/types.ts +56 -1
- package/src/utils/credentials.ts +89 -12
- package/src/workflows/engine.ts +10 -1
- package/src/workflows/executors/agent-task.ts +21 -2
- package/src/workflows/executors/foreach.ts +4 -1
- package/src/workflows/executors/notify.ts +62 -6
- package/src/workflows/executors/sub-workflow.ts +1 -1
- package/src/workflows/executors/swarm-script.ts +4 -1
- package/src/workflows/foreach-driver.ts +8 -5
- package/src/workflows/limits.ts +2 -1
- package/src/workflows/model-validation.ts +27 -2
- package/src/workflows/patch-definition.ts +3 -1
- package/src/workflows/recovery.ts +6 -6
- package/src/workflows/resume.ts +9 -9
- package/src/workflows/retry-poller.ts +2 -2
- package/templates/extensions/comms-adherence-gate/README.md +25 -0
- package/templates/extensions/comms-adherence-gate/hooks.ts +100 -11
- package/templates/extensions/comms-adherence-gate/manifest.json +1 -1
- package/templates/skills/apps/SKILL.md +9 -0
- package/templates/skills/apps/content.md +9 -0
- package/templates/skills/code-quality/content.md +12 -0
- package/templates/skills/memory/content.md +8 -0
- package/templates/skills/scheduling/config.json +1 -1
- package/templates/skills/scheduling/content.md +2 -2
- package/templates/skills/swarm-docs/content.md +4 -0
- package/templates/skills/swarm-extensions/content.md +1 -1
- package/templates/skills/swarm-scripts/SKILL.md +1 -1
- package/templates/skills/swarm-scripts/content.md +1 -1
- package/templates/skills/work-on-task/SKILL.md +2 -0
- package/templates/skills/work-on-task/content.md +2 -0
- package/templates/workflows/dreaming/content.md +174 -7
- package/dist/acp-adapter-dn4gdsgr.js +0 -16
- package/dist/app-a66ssc4k.js +0 -17
- package/dist/cli-530hkwdy.js +0 -779
- package/dist/cli-a0657jmf.js +0 -339
- package/dist/cli-cyn9v8zr.js +0 -748
- package/dist/handlers-crckt5dq.js +0 -32
- package/dist/heartbeat-8phn1kdq.js +0 -41
- package/dist/index-4x08sjtk.js +0 -30
- package/dist/index-8ybffts4.js +0 -37
- package/dist/index-nfy4kkg5.js +0 -33
- package/dist/lead-zdqxsvjn.js +0 -71
- package/dist/worker-y62rvvq3.js +0 -71
- package/dist/{cli-gxy8y1dt.js → cli-8bpgbr8k.js} +3 -3
package/src/fs/provider.ts
CHANGED
|
@@ -117,8 +117,13 @@ export function normalizeStoredKey(key: string): string {
|
|
|
117
117
|
if (!trimmed || trimmed.includes("\0")) {
|
|
118
118
|
throw new FilesError("Provider", "Stored file key must be a non-empty path");
|
|
119
119
|
}
|
|
120
|
-
|
|
121
|
-
|
|
120
|
+
// Match normalizeName: reject empty and "." segments so a stored key stays a
|
|
121
|
+
// concrete relative file path (not a directory-like or ambiguous path).
|
|
122
|
+
if (trimmed.split("/").some((part) => !part || part === "." || isParentSegment(part))) {
|
|
123
|
+
throw new FilesError(
|
|
124
|
+
"Provider",
|
|
125
|
+
"Stored file key must not contain empty or parent path segments",
|
|
126
|
+
);
|
|
122
127
|
}
|
|
123
128
|
return trimmed;
|
|
124
129
|
}
|
|
@@ -156,13 +161,22 @@ export function fileObjectFromHeaders(
|
|
|
156
161
|
overrides: Partial<FileObject> = {},
|
|
157
162
|
): FileObject {
|
|
158
163
|
const sizeHeader = headers.get("content-length");
|
|
164
|
+
let sizeBytes: number | undefined;
|
|
165
|
+
if (sizeHeader) {
|
|
166
|
+
const parsed = Number(sizeHeader);
|
|
167
|
+
// Malformed / negative / non-finite Content-Length must not leak NaN into
|
|
168
|
+
// metadata consumers — omit the field instead (#2671).
|
|
169
|
+
if (Number.isFinite(parsed) && parsed >= 0) {
|
|
170
|
+
sizeBytes = parsed;
|
|
171
|
+
}
|
|
172
|
+
}
|
|
159
173
|
return {
|
|
160
174
|
providerId,
|
|
161
175
|
key: providerPath(scope),
|
|
162
176
|
taskId: scope.taskId,
|
|
163
177
|
name: scope.name,
|
|
164
178
|
contentType: headers.get("content-type") ?? undefined,
|
|
165
|
-
sizeBytes
|
|
179
|
+
sizeBytes,
|
|
166
180
|
etag: headers.get("etag") ?? undefined,
|
|
167
181
|
sha256: headers.get("x-agent-fs-content-hash") ?? undefined,
|
|
168
182
|
version: headers.get("x-agent-fs-version") ?? undefined,
|
|
@@ -51,6 +51,7 @@ import {
|
|
|
51
51
|
upsertKv,
|
|
52
52
|
} from "../be/db";
|
|
53
53
|
import { repointTrackerSyncBySwarmId } from "../be/db-queries/tracker";
|
|
54
|
+
import { withLoopPath } from "../be/event-loop-lag";
|
|
54
55
|
import { poolTaskRunsOnHarness } from "../be/model-validation";
|
|
55
56
|
import {
|
|
56
57
|
countActiveRuntimeInstancesForAgent,
|
|
@@ -114,6 +115,17 @@ const SKIP_AUTO_RESUME_TYPES = new Set([
|
|
|
114
115
|
// Configuration (env var overrides)
|
|
115
116
|
// ============================================================================
|
|
116
117
|
|
|
118
|
+
/**
|
|
119
|
+
* Parse HEARTBEAT_INTERVAL_MS: a positive integer, or the 90-second default.
|
|
120
|
+
*
|
|
121
|
+
* `Number("Infinity")` is truthy, so `Number(value) || 90_000` let a non-finite
|
|
122
|
+
* interval through to `setInterval` (#2714).
|
|
123
|
+
*/
|
|
124
|
+
export function parseHeartbeatIntervalMs(raw: string | undefined): number {
|
|
125
|
+
const value = Number(raw);
|
|
126
|
+
return Number.isInteger(value) && value > 0 ? value : 90_000;
|
|
127
|
+
}
|
|
128
|
+
|
|
117
129
|
/**
|
|
118
130
|
* Default heartbeat interval: 90 seconds.
|
|
119
131
|
*
|
|
@@ -123,7 +135,7 @@ const SKIP_AUTO_RESUME_TYPES = new Set([
|
|
|
123
135
|
* silently ignored — even across a restart. Keep these as functions.
|
|
124
136
|
*/
|
|
125
137
|
function defaultIntervalMs(): number {
|
|
126
|
-
return
|
|
138
|
+
return parseHeartbeatIntervalMs(process.env.HEARTBEAT_INTERVAL_MS);
|
|
127
139
|
}
|
|
128
140
|
|
|
129
141
|
/** Stall threshold: tasks with fresh worker heartbeat but no task update for this many minutes */
|
|
@@ -2031,8 +2043,8 @@ export function startHeartbeat(intervalMs = defaultIntervalMs()): void {
|
|
|
2031
2043
|
// `finally` but has no `catch`, so a throw anywhere inside it escapes as an
|
|
2032
2044
|
// unhandled rejection unless it is caught here.
|
|
2033
2045
|
setTimeout(() => {
|
|
2034
|
-
runRebootSweep()
|
|
2035
|
-
.then(() => runHeartbeatSweep())
|
|
2046
|
+
withLoopPath("heartbeat.boot-sweep", () => runRebootSweep())
|
|
2047
|
+
.then(() => withLoopPath("heartbeat.sweep", () => runHeartbeatSweep()))
|
|
2036
2048
|
.catch((err) =>
|
|
2037
2049
|
console.error(
|
|
2038
2050
|
"[Heartbeat] boot sweep failed:",
|
|
@@ -2042,7 +2054,7 @@ export function startHeartbeat(intervalMs = defaultIntervalMs()): void {
|
|
|
2042
2054
|
}, 5000);
|
|
2043
2055
|
|
|
2044
2056
|
heartbeatInterval = setInterval(() => {
|
|
2045
|
-
runHeartbeatSweep().catch((err) =>
|
|
2057
|
+
withLoopPath("heartbeat.sweep", () => runHeartbeatSweep()).catch((err) =>
|
|
2046
2058
|
console.error(
|
|
2047
2059
|
"[Heartbeat] sweep failed:",
|
|
2048
2060
|
scrubSecrets(err instanceof Error ? err.message : String(err)),
|
|
@@ -2163,7 +2175,7 @@ export function startHeartbeatChecklist(intervalMs = heartbeatChecklistIntervalM
|
|
|
2163
2175
|
|
|
2164
2176
|
// Recurring checklist starts from the second interval onward
|
|
2165
2177
|
checklistInterval = setInterval(() => {
|
|
2166
|
-
checkHeartbeatChecklist().catch((err) =>
|
|
2178
|
+
withLoopPath("heartbeat.checklist", () => checkHeartbeatChecklist()).catch((err) =>
|
|
2167
2179
|
console.error(
|
|
2168
2180
|
"[Heartbeat] checklist check failed:",
|
|
2169
2181
|
scrubSecrets(err instanceof Error ? err.message : String(err)),
|
package/src/heartbeat/index.ts
CHANGED
package/src/http/agents.ts
CHANGED
|
@@ -35,6 +35,7 @@ import {
|
|
|
35
35
|
} from "../be/db/model-profiles";
|
|
36
36
|
import { createEvent } from "../be/events";
|
|
37
37
|
import { setAgentHarnessCliVersion } from "../be/harness-model-support";
|
|
38
|
+
import { checkProfileForAgent, formatProfileCheckFailures } from "../be/model-profile-check";
|
|
38
39
|
import {
|
|
39
40
|
sanitizeModelTierOverrides,
|
|
40
41
|
setAgentModelTierOverrides,
|
|
@@ -65,6 +66,8 @@ import {
|
|
|
65
66
|
AgentStatusSchema,
|
|
66
67
|
AgentWithTasksSchema,
|
|
67
68
|
DeliveryModeSchema,
|
|
69
|
+
type ProfileCheckResult,
|
|
70
|
+
ProfileCheckResultSchema,
|
|
68
71
|
type ProfileSyncConflict,
|
|
69
72
|
type ProviderName,
|
|
70
73
|
ProviderNameSchema,
|
|
@@ -286,7 +289,7 @@ const updateAgentRuntimeRoute = route({
|
|
|
286
289
|
pattern: ["api", "agents", null, "runtime"],
|
|
287
290
|
summary: "Update an agent's runtime harness and default model",
|
|
288
291
|
description:
|
|
289
|
-
"Updates `agents.harness_provider` and agent-scoped runtime config. The settings apply to future provider sessions. For `model`, `reasoning_effort`, and `claude.transport`: omit the field to leave it unchanged, send `null` to clear the corresponding override, or send a value to set it. A `model` the model catalog does not list is a 400 unless `allow_custom_model` is true. A `latest:` alias is not accepted here (aliases resolve for a task's model and for `MODEL_TIER_*` values); `reasoning_effort` must be one the harness and model support. `profile` sets the agent's default model profile (same tri-state): it must exist
|
|
292
|
+
"Updates `agents.harness_provider` and agent-scoped runtime config. The settings apply to future provider sessions. For `model`, `reasoning_effort`, and `claude.transport`: omit the field to leave it unchanged, send `null` to clear the corresponding override, or send a value to set it. A `model` the model catalog does not list is a 400 unless `allow_custom_model` is true. A `latest:` alias is not accepted here (aliases resolve for a task's model and for `MODEL_TIER_*` values); `reasoning_effort` must be one the harness and model support. `profile` sets the agent's default model profile (same tri-state): it must exist, run on `harness_provider` and pass the profile check (`GET /api/agents/{id}/profile-check`) against it, and it cannot be sent with `model`. A failing check is a 400 `{ error, check }`; a passing one returns the result as `profileCheck`. Sending `model`, or changing the model or effort override by any path, clears the default profile.",
|
|
290
293
|
tags: ["Agents"],
|
|
291
294
|
params: z.object({ id: z.string() }),
|
|
292
295
|
query: z.object({ repoId: z.string().optional() }),
|
|
@@ -300,8 +303,12 @@ const updateAgentRuntimeRoute = route({
|
|
|
300
303
|
claude: ClaudeRuntimeConfigSchema.optional(),
|
|
301
304
|
}),
|
|
302
305
|
responses: {
|
|
303
|
-
200: {
|
|
304
|
-
|
|
306
|
+
200: {
|
|
307
|
+
description:
|
|
308
|
+
"Updated agent row. `profileCheck` is set when the body set `profile`, so warnings show.",
|
|
309
|
+
schema: AgentWithCapacitySchema.extend({ profileCheck: ProfileCheckResultSchema.optional() }),
|
|
310
|
+
},
|
|
311
|
+
400: { description: "Validation error, or `{ error, check }` when the profile check fails" },
|
|
305
312
|
404: { description: "Agent not found" },
|
|
306
313
|
},
|
|
307
314
|
});
|
|
@@ -642,6 +649,22 @@ const getAgentCredentialStatusRoute = route({
|
|
|
642
649
|
},
|
|
643
650
|
});
|
|
644
651
|
|
|
652
|
+
const getAgentProfileCheckRoute = route({
|
|
653
|
+
method: "get",
|
|
654
|
+
path: "/api/agents/{id}/profile-check",
|
|
655
|
+
pattern: ["api", "agents", null, "profile-check"],
|
|
656
|
+
summary: "Check whether an agent can run a model profile",
|
|
657
|
+
description:
|
|
658
|
+
"Read-only. Judges the profile's harness, model, the agent's credential report and the profile's credential allowlist. Each row is pass, warn, fail or unverified; `ok` is false only when a row fails. Never returns a secret value.",
|
|
659
|
+
tags: ["Agents"],
|
|
660
|
+
params: z.object({ id: z.string() }),
|
|
661
|
+
query: z.object({ profile: z.string().trim().min(1) }),
|
|
662
|
+
responses: {
|
|
663
|
+
200: { description: "The check result", schema: ProfileCheckResultSchema },
|
|
664
|
+
404: { description: "Agent or profile not found" },
|
|
665
|
+
},
|
|
666
|
+
});
|
|
667
|
+
|
|
645
668
|
const listCredentialStatusRoute = route({
|
|
646
669
|
method: "get",
|
|
647
670
|
path: "/api/agents/credential-status",
|
|
@@ -1182,6 +1205,7 @@ export async function handleAgentsRest(
|
|
|
1182
1205
|
const { harness_provider, model, allow_custom_model, reasoning_effort, profile, acp, claude } =
|
|
1183
1206
|
parsed.body;
|
|
1184
1207
|
|
|
1208
|
+
let profileCheck: ProfileCheckResult | null = null;
|
|
1185
1209
|
if (typeof profile === "string") {
|
|
1186
1210
|
if (model !== undefined) {
|
|
1187
1211
|
jsonError(res, "Send `profile` or `model`, not both", 400);
|
|
@@ -1200,6 +1224,15 @@ export async function handleAgentsRest(
|
|
|
1200
1224
|
);
|
|
1201
1225
|
return true;
|
|
1202
1226
|
}
|
|
1227
|
+
// Judged against the body's harness: a PATCH that also switches it is
|
|
1228
|
+
// checked against the new one.
|
|
1229
|
+
profileCheck = await checkProfileForAgent(parsed.params.id, profile, {
|
|
1230
|
+
harness: harness_provider,
|
|
1231
|
+
});
|
|
1232
|
+
if (profileCheck && !profileCheck.ok) {
|
|
1233
|
+
json(res, { error: formatProfileCheckFailures(profileCheck), check: profileCheck }, 400);
|
|
1234
|
+
return true;
|
|
1235
|
+
}
|
|
1203
1236
|
}
|
|
1204
1237
|
|
|
1205
1238
|
if (acp && harness_provider !== "acp") {
|
|
@@ -1439,7 +1472,10 @@ export async function handleAgentsRest(
|
|
|
1439
1472
|
jsonError(res, "Agent not found", 404);
|
|
1440
1473
|
return true;
|
|
1441
1474
|
}
|
|
1442
|
-
updateAgentRuntimeRoute.respond(res, 200,
|
|
1475
|
+
updateAgentRuntimeRoute.respond(res, 200, {
|
|
1476
|
+
...(await agentWithCapacity(agent)),
|
|
1477
|
+
...(profileCheck ? { profileCheck } : {}),
|
|
1478
|
+
});
|
|
1443
1479
|
return true;
|
|
1444
1480
|
}
|
|
1445
1481
|
|
|
@@ -1577,6 +1613,22 @@ export async function handleAgentsRest(
|
|
|
1577
1613
|
return true;
|
|
1578
1614
|
}
|
|
1579
1615
|
|
|
1616
|
+
if (getAgentProfileCheckRoute.match(req.method, pathSegments)) {
|
|
1617
|
+
const parsed = await getAgentProfileCheckRoute.parse(req, res, pathSegments, queryParams);
|
|
1618
|
+
if (!parsed) return true;
|
|
1619
|
+
if (!(await getAgentById(parsed.params.id))) {
|
|
1620
|
+
jsonError(res, "Agent not found", 404);
|
|
1621
|
+
return true;
|
|
1622
|
+
}
|
|
1623
|
+
const result = await checkProfileForAgent(parsed.params.id, parsed.query.profile);
|
|
1624
|
+
if (!result) {
|
|
1625
|
+
jsonError(res, `Model profile "${parsed.query.profile}" not found`, 404);
|
|
1626
|
+
return true;
|
|
1627
|
+
}
|
|
1628
|
+
getAgentProfileCheckRoute.respond(res, 200, result);
|
|
1629
|
+
return true;
|
|
1630
|
+
}
|
|
1631
|
+
|
|
1580
1632
|
if (getAgent.match(req.method, pathSegments)) {
|
|
1581
1633
|
const parsed = await getAgent.parse(req, res, pathSegments, queryParams);
|
|
1582
1634
|
if (!parsed) return true;
|
package/src/http/apps.ts
CHANGED
|
@@ -65,7 +65,7 @@ import {
|
|
|
65
65
|
import { getAgentById, getAppVersion, getAppVersions, getTaskById } from "../be/db";
|
|
66
66
|
import type { RbacResource } from "../rbac";
|
|
67
67
|
import { can } from "../rbac";
|
|
68
|
-
import { AgentTaskStatusSchema } from "../types";
|
|
68
|
+
import { AgentTaskStatusSchema, AppIconSchema } from "../types";
|
|
69
69
|
import { getRequestAuth } from "../utils/request-auth-context";
|
|
70
70
|
import { scrubObject } from "../utils/secret-scrubber";
|
|
71
71
|
import { resolveHttpFavoriteOwner } from "./favorite-owner";
|
|
@@ -139,6 +139,8 @@ const AppSummarySchema = z.object({
|
|
|
139
139
|
id: z.string(),
|
|
140
140
|
name: z.string(),
|
|
141
141
|
description: z.string().optional(),
|
|
142
|
+
/** Projected from `definition.icon` (see `extractIcon` in `src/apps/store.ts`). */
|
|
143
|
+
icon: AppIconSchema.optional(),
|
|
142
144
|
createdAt: z.string(),
|
|
143
145
|
updatedAt: z.string(),
|
|
144
146
|
});
|
package/src/http/config.ts
CHANGED
|
@@ -9,6 +9,7 @@ import {
|
|
|
9
9
|
maskSecrets,
|
|
10
10
|
} from "../be/db";
|
|
11
11
|
import { modelProfileRefError } from "../be/db/model-profiles";
|
|
12
|
+
import { runtimeReadsRepoSecrets } from "../be/model-profile-check";
|
|
12
13
|
import {
|
|
13
14
|
AGENT_MAX_TASKS_CONFIG_KEY,
|
|
14
15
|
resetAgentMaxTasksMirror,
|
|
@@ -59,12 +60,7 @@ export function readsRepoSecrets(
|
|
|
59
60
|
agent: { isLead?: boolean } | null | undefined,
|
|
60
61
|
): boolean {
|
|
61
62
|
if (auth?.kind !== "agent" || !auth.runtimeId) return true;
|
|
62
|
-
return
|
|
63
|
-
principal: { kind: "agent", agentId: auth.agentId, isLead: agent?.isLead ?? false },
|
|
64
|
-
verb: "config.read.secrets",
|
|
65
|
-
resource: { kind: "none" },
|
|
66
|
-
source: "http",
|
|
67
|
-
}).allow;
|
|
63
|
+
return runtimeReadsRepoSecrets({ id: auth.agentId, isLead: agent?.isLead });
|
|
68
64
|
}
|
|
69
65
|
|
|
70
66
|
export async function requestSecretReadScope(
|
package/src/http/core.ts
CHANGED
|
@@ -41,7 +41,8 @@ import { restartChatSdkIfConfigChanged } from "../integrations/chat-sdk/runtime"
|
|
|
41
41
|
import { initJira, resetJira } from "../jira";
|
|
42
42
|
import { initLinear, resetLinear } from "../linear";
|
|
43
43
|
import { can, decideAdmission, isRbacEnabled } from "../rbac";
|
|
44
|
-
import { startSlackApp,
|
|
44
|
+
import { startSlackApp, stopSlackAppUnderLifecycleLock } from "../slack";
|
|
45
|
+
import { runSlackLifecycleExclusive } from "../slack/lifecycle-lock";
|
|
45
46
|
import type { AgentStatus } from "../types";
|
|
46
47
|
import { isMultiRuntimeEnabled } from "../utils/multi-runtime";
|
|
47
48
|
import {
|
|
@@ -180,7 +181,11 @@ export async function reloadGlobalConfigsAndIntegrations(): Promise<ReloadConfig
|
|
|
180
181
|
// request's frame they capture that request's auth slot for their whole
|
|
181
182
|
// lifetime, and their later DB writes get attributed to whichever user
|
|
182
183
|
// happened to save config.
|
|
183
|
-
|
|
184
|
+
// The shared Slack lifecycle lock keeps the socket watchdog from restarting
|
|
185
|
+
// the Slack app while a reload tears it down and rebuilds it.
|
|
186
|
+
return runWithoutRequestAuth(() =>
|
|
187
|
+
runSlackLifecycleExclusive(() => reloadGlobalConfigsAndIntegrationsInner()),
|
|
188
|
+
);
|
|
184
189
|
}
|
|
185
190
|
|
|
186
191
|
async function reloadGlobalConfigsAndIntegrationsInner(): Promise<ReloadConfigResult> {
|
|
@@ -201,7 +206,8 @@ async function reloadGlobalConfigsAndIntegrationsInner(): Promise<ReloadConfigRe
|
|
|
201
206
|
|
|
202
207
|
// Retire the old transport before any other integration can fail during
|
|
203
208
|
// reload. HTTP/invalid selection must never leave the previous socket live.
|
|
204
|
-
|
|
209
|
+
// The reload already holds the Slack lifecycle lock (see the caller).
|
|
210
|
+
await stopSlackAppUnderLifecycleLock();
|
|
205
211
|
|
|
206
212
|
// File-storage provider selection reads process.env once and memoizes; the
|
|
207
213
|
// env we just (re)hydrated may flip it (local-fs → agent-fs after late
|
package/src/http/index.ts
CHANGED
|
@@ -17,6 +17,7 @@ import {
|
|
|
17
17
|
} from "../be/db";
|
|
18
18
|
import { startTaskSearchBackfill, stopTaskSearchBackfill } from "../be/db/tasks/search-index";
|
|
19
19
|
import { startDbRetention, stopDbRetention } from "../be/db-retention";
|
|
20
|
+
import { startEventLoopLagProbe, stopEventLoopLagProbe, withLoopPath } from "../be/event-loop-lag";
|
|
20
21
|
import { startHumanFreeDrain, stopHumanFreeDrain } from "../be/human-free-drain";
|
|
21
22
|
import { startMcpOverflowSweep, stopMcpOverflowSweep } from "../be/mcp-overflow-sweep";
|
|
22
23
|
import {
|
|
@@ -151,6 +152,7 @@ import { handleUsers } from "./users";
|
|
|
151
152
|
import {
|
|
152
153
|
getPathSegments,
|
|
153
154
|
httpServerSemconvAttributes,
|
|
155
|
+
loopPathForRequest,
|
|
154
156
|
parseQueryParams,
|
|
155
157
|
redactShareTokenInPath,
|
|
156
158
|
safeRequestUrlForLog,
|
|
@@ -225,7 +227,8 @@ function startApiGcInterval() {
|
|
|
225
227
|
}
|
|
226
228
|
|
|
227
229
|
const interval = setInterval(() => {
|
|
228
|
-
|
|
230
|
+
// The rooms sweep is the DB work of this tick; name it for the stall line.
|
|
231
|
+
void withLoopPath("http.gc-interval", () => sweepRooms()).catch((error) =>
|
|
229
232
|
console.error("[rooms] Sweep failed:", scrubSecrets(String(error))),
|
|
230
233
|
);
|
|
231
234
|
const closedOwnerTransports = closeIdleMcpTransports(transports, transportActivity, {
|
|
@@ -455,11 +458,10 @@ const httpServer = createHttpServer(async (req, res) => {
|
|
|
455
458
|
}
|
|
456
459
|
};
|
|
457
460
|
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
}
|
|
461
|
+
// Name the entry point for the event-loop stall line.
|
|
462
|
+
await withLoopPath(loopPathForRequest(req.method, pathSegments), () =>
|
|
463
|
+
span ? withSpanContext(span, handleRequest) : handleRequest(),
|
|
464
|
+
);
|
|
463
465
|
});
|
|
464
466
|
});
|
|
465
467
|
|
|
@@ -565,6 +567,7 @@ async function shutdown() {
|
|
|
565
567
|
clearInterval(globalState.__apiGcInterval);
|
|
566
568
|
delete globalState.__apiGcInterval;
|
|
567
569
|
}
|
|
570
|
+
stopEventLoopLagProbe();
|
|
568
571
|
|
|
569
572
|
// Close all active transports (SSE connections, etc.)
|
|
570
573
|
for (const [id, transport] of Object.entries(transports)) {
|
|
@@ -624,6 +627,7 @@ if (!globalState.__runId) {
|
|
|
624
627
|
}
|
|
625
628
|
|
|
626
629
|
startApiGcInterval();
|
|
630
|
+
startEventLoopLagProbe();
|
|
627
631
|
|
|
628
632
|
// Load global swarm configs before the server starts listening so decrypt/key
|
|
629
633
|
// failures fail closed instead of leaving the runtime half-initialized.
|
|
@@ -854,9 +858,8 @@ httpServer
|
|
|
854
858
|
// restart — which is what the Configuration page's "Restart required"
|
|
855
859
|
// badge promises for HEARTBEAT_DISABLE / HEARTBEAT_INTERVAL_MS.
|
|
856
860
|
if (!isEnvFlagEnabled("HEARTBEAT_DISABLE", false)) {
|
|
857
|
-
const { startHeartbeat } = await import("../heartbeat");
|
|
858
|
-
|
|
859
|
-
startHeartbeat(heartbeatMs);
|
|
861
|
+
const { parseHeartbeatIntervalMs, startHeartbeat } = await import("../heartbeat");
|
|
862
|
+
startHeartbeat(parseHeartbeatIntervalMs(process.env.HEARTBEAT_INTERVAL_MS));
|
|
860
863
|
}
|
|
861
864
|
|
|
862
865
|
startPoolRouting();
|
package/src/http/memory.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { IncomingMessage, ServerResponse } from "node:http";
|
|
2
2
|
import { z } from "zod";
|
|
3
3
|
import { getAgentById, getDbClient, getTaskById } from "../be/db";
|
|
4
|
+
import { withLoopPath } from "../be/event-loop-lag";
|
|
4
5
|
import { getEmbeddingProvider, getMemoryStore } from "../be/memory";
|
|
5
6
|
import { canReadMemory } from "../be/memory/access";
|
|
6
7
|
import { CANDIDATE_SET_MULTIPLIER } from "../be/memory/constants";
|
|
@@ -1568,8 +1569,12 @@ const MEMORY_GC_INTERVAL_MS = 60 * 60 * 1000; // 1 hour
|
|
|
1568
1569
|
let memoryGcTimer: ReturnType<typeof setInterval> | null = null;
|
|
1569
1570
|
|
|
1570
1571
|
const SEARCH_RETRIEVAL_TTL_DAYS = 90;
|
|
1571
|
-
/**
|
|
1572
|
-
|
|
1572
|
+
/**
|
|
1573
|
+
* Rows per purge statement. The purge yields the event loop between batches.
|
|
1574
|
+
* A 2,000-row batch blocked the loop for 1.1 s in production; 500 keeps one
|
|
1575
|
+
* batch near the 250 ms target.
|
|
1576
|
+
*/
|
|
1577
|
+
const SEARCH_RETRIEVAL_PURGE_BATCH = 500;
|
|
1573
1578
|
|
|
1574
1579
|
export async function purgeStaleSearchRetrievals(
|
|
1575
1580
|
batchSize = SEARCH_RETRIEVAL_PURGE_BATCH,
|
|
@@ -1629,12 +1634,12 @@ export async function startMemoryGc(
|
|
|
1629
1634
|
// Clear any backlog soon after startup, but off the boot path.
|
|
1630
1635
|
memoryGcInitialTimer = setTimeout(() => {
|
|
1631
1636
|
memoryGcInitialTimer = null;
|
|
1632
|
-
void runMemoryGcTick("Initial");
|
|
1637
|
+
void withLoopPath("memory-gc.tick", () => runMemoryGcTick("Initial"));
|
|
1633
1638
|
}, initialDelayMs);
|
|
1634
1639
|
if (typeof memoryGcInitialTimer?.unref === "function") memoryGcInitialTimer.unref();
|
|
1635
1640
|
|
|
1636
1641
|
memoryGcTimer = setInterval(() => {
|
|
1637
|
-
void runMemoryGcTick("Periodic");
|
|
1642
|
+
void withLoopPath("memory-gc.tick", () => runMemoryGcTick("Periodic"));
|
|
1638
1643
|
}, intervalMs);
|
|
1639
1644
|
if (typeof memoryGcTimer?.unref === "function") memoryGcTimer.unref();
|
|
1640
1645
|
}
|
|
@@ -21,6 +21,8 @@ import { explicitModelError } from "../be/model-validation";
|
|
|
21
21
|
import { supportedReasoningLevels } from "../providers/reasoning-effort";
|
|
22
22
|
import { can } from "../rbac";
|
|
23
23
|
import {
|
|
24
|
+
type ModelProfileCredentials,
|
|
25
|
+
ModelProfileCredentialsSchema,
|
|
24
26
|
ModelProfileNameSchema,
|
|
25
27
|
ModelProfileSchema,
|
|
26
28
|
type ProviderName,
|
|
@@ -28,6 +30,7 @@ import {
|
|
|
28
30
|
type ReasoningEffort,
|
|
29
31
|
ReasoningEffortSchema,
|
|
30
32
|
} from "../types";
|
|
33
|
+
import { getModelAwareCredentialVars, PROVIDER_CREDENTIAL_VARS } from "../utils/credentials";
|
|
31
34
|
import { agentFirstPrincipal } from "./request-principal";
|
|
32
35
|
import { route } from "./route-def";
|
|
33
36
|
import { jsonError } from "./utils";
|
|
@@ -68,7 +71,7 @@ const createProfile = route({
|
|
|
68
71
|
pattern: ["api", "model-profiles"],
|
|
69
72
|
summary: "Create a model profile",
|
|
70
73
|
description:
|
|
71
|
-
"A profile runs on one harness. `model` must run on that harness and be in the model catalog unless `allowCustomModel` is true (a gateway id, a fresh launch); a `latest:` alias is accepted and resolves at claim. `effort` must be a level the harness and model support. Operator only (the shared API key).",
|
|
74
|
+
"A profile runs on one harness. `model` must run on that harness and be in the model catalog unless `allowCustomModel` is true (a gateway id, a fresh launch); a `latest:` alias is accepted and resolves at claim. `effort` must be a level the harness and model support. `credentials` pins which pooled keys the profile uses: per credential var of the harness, the last 5 characters of each allowed key (`CODEX_OAUTH` is not supported). Operator only (the shared API key).",
|
|
72
75
|
tags: ["Models"],
|
|
73
76
|
rbac: { permission: "models.profiles.write" },
|
|
74
77
|
body: z.object({
|
|
@@ -78,6 +81,7 @@ const createProfile = route({
|
|
|
78
81
|
effort: ReasoningEffortSchema.nullable().optional(),
|
|
79
82
|
allowCustomModel: z.boolean().optional().default(false),
|
|
80
83
|
description: z.string().trim().max(500).nullable().optional(),
|
|
84
|
+
credentials: ModelProfileCredentialsSchema.nullable().optional(),
|
|
81
85
|
}),
|
|
82
86
|
responses: {
|
|
83
87
|
201: { description: "Profile created", schema: ModelProfileSchema },
|
|
@@ -93,7 +97,7 @@ const updateProfile = route({
|
|
|
93
97
|
pattern: ["api", "model-profiles", null],
|
|
94
98
|
summary: "Update a model profile",
|
|
95
99
|
description:
|
|
96
|
-
"Changes the model, effort, custom-model flag or
|
|
100
|
+
"Changes the model, effort, custom-model flag, description or credential allowlist; the name and harness are fixed. Omit a field to keep it; `effort: null` and `credentials: null` clear it. Applies to tasks claimed after the change. Operator only (the shared API key).",
|
|
97
101
|
tags: ["Models"],
|
|
98
102
|
rbac: { permission: "models.profiles.write" },
|
|
99
103
|
params: z.object({ name: z.string() }),
|
|
@@ -102,6 +106,7 @@ const updateProfile = route({
|
|
|
102
106
|
effort: ReasoningEffortSchema.nullable().optional(),
|
|
103
107
|
allowCustomModel: z.boolean().optional(),
|
|
104
108
|
description: z.string().trim().max(500).nullable().optional(),
|
|
109
|
+
credentials: ModelProfileCredentialsSchema.nullable().optional(),
|
|
105
110
|
}),
|
|
106
111
|
responses: {
|
|
107
112
|
200: { description: "Profile updated", schema: ModelProfileSchema },
|
|
@@ -117,7 +122,7 @@ const deleteProfile = route({
|
|
|
117
122
|
pattern: ["api", "model-profiles", null],
|
|
118
123
|
summary: "Delete a model profile",
|
|
119
124
|
description:
|
|
120
|
-
"Refused (409) for a shipped `<harness>-<tier>` seed (edit it instead; it would come back at the next boot), and while an agent has the profile as its default or a task holds it (unfinished, or superseded and still owed its resume). Operator only (the shared API key).",
|
|
125
|
+
"Refused (409) for a shipped `<harness>-<tier>` seed (edit it instead; it would come back at the next boot), and while an agent has the profile as its default, a schedule names it, or a task holds it (unfinished, or superseded and still owed its resume). Operator only (the shared API key).",
|
|
121
126
|
tags: ["Models"],
|
|
122
127
|
rbac: { permission: "models.profiles.write" },
|
|
123
128
|
params: z.object({ name: z.string() }),
|
|
@@ -129,12 +134,53 @@ const deleteProfile = route({
|
|
|
129
134
|
},
|
|
130
135
|
});
|
|
131
136
|
|
|
132
|
-
/**
|
|
137
|
+
/**
|
|
138
|
+
* Why a credential allowlist does not fit the profile, or null. Each var must
|
|
139
|
+
* be a credential var the harness loads for this model (harnesses that pick
|
|
140
|
+
* the key by model prefix load a subset).
|
|
141
|
+
*/
|
|
142
|
+
function credentialsError(
|
|
143
|
+
harness: ProviderName,
|
|
144
|
+
model: string,
|
|
145
|
+
credentials: ModelProfileCredentials | null | undefined,
|
|
146
|
+
): string | null {
|
|
147
|
+
if (!credentials) return null;
|
|
148
|
+
// Only the vars the worker loads for this model (`selectCredentials`): an
|
|
149
|
+
// entry for any other var picks nothing, yet the profile check would still
|
|
150
|
+
// judge the agent's pool on it.
|
|
151
|
+
const base = PROVIDER_CREDENTIAL_VARS[harness] ?? [];
|
|
152
|
+
const allowed = new Set(base.length > 0 ? getModelAwareCredentialVars(harness, model) : []);
|
|
153
|
+
for (const [envVar, suffixes] of Object.entries(credentials)) {
|
|
154
|
+
if (envVar === "CODEX_OAUTH") {
|
|
155
|
+
return "A credential allowlist for CODEX_OAUTH is not supported in v1.";
|
|
156
|
+
}
|
|
157
|
+
if (!allowed.has(envVar)) {
|
|
158
|
+
return `"${envVar}" is not a credential var of the ${harness} harness${
|
|
159
|
+
allowed.size > 0 ? ` (expected one of ${[...allowed].join(", ")})` : ""
|
|
160
|
+
}.`;
|
|
161
|
+
}
|
|
162
|
+
if (suffixes.length === 0) return `The allowlist for ${envVar} is empty.`;
|
|
163
|
+
}
|
|
164
|
+
return null;
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
/** Each var's suffixes once, in first-seen order. */
|
|
168
|
+
function dedupeCredentials(
|
|
169
|
+
credentials: ModelProfileCredentials | null | undefined,
|
|
170
|
+
): ModelProfileCredentials | null | undefined {
|
|
171
|
+
if (!credentials) return credentials;
|
|
172
|
+
return Object.fromEntries(
|
|
173
|
+
Object.entries(credentials).map(([envVar, suffixes]) => [envVar, [...new Set(suffixes)]]),
|
|
174
|
+
);
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
/** Why `harness` + `model` + `effort` + `credentials` is not a valid profile, or null. */
|
|
133
178
|
async function profileValueError(input: {
|
|
134
179
|
harness: ProviderName;
|
|
135
180
|
model: string;
|
|
136
181
|
effort: ReasoningEffort | null | undefined;
|
|
137
182
|
allowCustomModel: boolean;
|
|
183
|
+
credentials?: ModelProfileCredentials | null;
|
|
138
184
|
}): Promise<string | null> {
|
|
139
185
|
const modelError = await explicitModelError({
|
|
140
186
|
model: input.model,
|
|
@@ -152,7 +198,7 @@ async function profileValueError(input: {
|
|
|
152
198
|
) {
|
|
153
199
|
return `Effort "${input.effort}" is not supported by ${input.model} on ${input.harness}.`;
|
|
154
200
|
}
|
|
155
|
-
return
|
|
201
|
+
return credentialsError(input.harness, input.model, input.credentials);
|
|
156
202
|
}
|
|
157
203
|
|
|
158
204
|
/** Gate a write on `models.profiles.write`; writes a 403 and returns false on denial. */
|
|
@@ -206,7 +252,7 @@ export async function handleModelProfiles(
|
|
|
206
252
|
const parsed = await createProfile.parse(req, res, pathSegments, queryParams);
|
|
207
253
|
if (!parsed) return true;
|
|
208
254
|
if (!(await canWriteProfiles(req, res, myAgentId))) return true;
|
|
209
|
-
const body = parsed.body;
|
|
255
|
+
const body = { ...parsed.body, credentials: dedupeCredentials(parsed.body.credentials) };
|
|
210
256
|
const error = await profileValueError({ ...body, effort: body.effort ?? null });
|
|
211
257
|
if (error) {
|
|
212
258
|
jsonError(res, error, 400);
|
|
@@ -232,12 +278,13 @@ export async function handleModelProfiles(
|
|
|
232
278
|
jsonError(res, "Model profile not found", 404);
|
|
233
279
|
return true;
|
|
234
280
|
}
|
|
235
|
-
const body = parsed.body;
|
|
281
|
+
const body = { ...parsed.body, credentials: dedupeCredentials(parsed.body.credentials) };
|
|
236
282
|
const error = await profileValueError({
|
|
237
283
|
harness: current.harness,
|
|
238
284
|
model: body.model ?? current.model,
|
|
239
285
|
effort: body.effort === undefined ? current.effort : body.effort,
|
|
240
286
|
allowCustomModel: body.allowCustomModel ?? current.allowCustomModel,
|
|
287
|
+
credentials: body.credentials === undefined ? current.credentials : body.credentials,
|
|
241
288
|
});
|
|
242
289
|
if (error) {
|
|
243
290
|
jsonError(res, error, 400);
|
|
@@ -272,10 +319,11 @@ export async function handleModelProfiles(
|
|
|
272
319
|
return true;
|
|
273
320
|
}
|
|
274
321
|
const refs = await modelProfileReferences(current.name);
|
|
275
|
-
if (refs.agentIds.length > 0 || refs.openTaskCount > 0) {
|
|
322
|
+
if (refs.agentIds.length > 0 || refs.openTaskCount > 0 || refs.scheduleIds.length > 0) {
|
|
323
|
+
const schedules = refs.scheduleIds.length > 0 ? ` (${refs.scheduleIds.join(", ")})` : "";
|
|
276
324
|
jsonError(
|
|
277
325
|
res,
|
|
278
|
-
`"${current.name}" is in use: default of ${refs.agentIds.length} agent(s), held by ${refs.openTaskCount} unfinished or awaiting-resume task(s).`,
|
|
326
|
+
`"${current.name}" is in use: default of ${refs.agentIds.length} agent(s), held by ${refs.openTaskCount} unfinished or awaiting-resume task(s), named by ${refs.scheduleIds.length} schedule(s)${schedules}.`,
|
|
279
327
|
409,
|
|
280
328
|
);
|
|
281
329
|
return true;
|
|
@@ -286,7 +334,7 @@ export async function handleModelProfiles(
|
|
|
286
334
|
if (outcome === "in-use") {
|
|
287
335
|
jsonError(
|
|
288
336
|
res,
|
|
289
|
-
`"${current.name}" is in use by a task or an agent default created just now.`,
|
|
337
|
+
`"${current.name}" is in use by a task, a schedule or an agent default created just now.`,
|
|
290
338
|
409,
|
|
291
339
|
);
|
|
292
340
|
return true;
|
package/src/http/poll.ts
CHANGED
|
@@ -25,6 +25,7 @@ import {
|
|
|
25
25
|
updateAgentStatusFromCapacity,
|
|
26
26
|
upsertChannelActivityCursor,
|
|
27
27
|
} from "../be/db";
|
|
28
|
+
import { checkProfileForAgent } from "../be/model-profile-check";
|
|
28
29
|
import {
|
|
29
30
|
parseModelTierOverridesHeader,
|
|
30
31
|
recordClaimModelResolution,
|
|
@@ -36,7 +37,12 @@ import { hasCapability } from "../server";
|
|
|
36
37
|
import { fetchChannelActivity } from "../slack/channel-activity";
|
|
37
38
|
import { type TaskModelPinFields, taskModelPin } from "../tasks/model-pin";
|
|
38
39
|
import { emitTaskTelemetry, resolveTriggerSurface } from "../telemetry-trigger";
|
|
39
|
-
import {
|
|
40
|
+
import {
|
|
41
|
+
AgentTaskSchema,
|
|
42
|
+
BudgetRefusedTriggerSchema,
|
|
43
|
+
ModelProfileCredentialsSchema,
|
|
44
|
+
TaskAttachmentSchema,
|
|
45
|
+
} from "../types";
|
|
40
46
|
import { ensure } from "../utils/business-use";
|
|
41
47
|
import { isLeadChannelMonitoringEnabled } from "../utils/lead-monitor-channels";
|
|
42
48
|
import { isMultiRuntimeEnabled } from "../utils/multi-runtime";
|
|
@@ -109,6 +115,8 @@ const PollTaskAssignedTriggerSchema = z.object({
|
|
|
109
115
|
triggerSurface: z.string().optional(),
|
|
110
116
|
task: AgentTaskSchema.extend({
|
|
111
117
|
attachments: z.array(PollTriggerAttachmentSchema),
|
|
118
|
+
// The claimed profile's pooled-key allowlist. Trigger only, not stored on the task.
|
|
119
|
+
credentialAllowlist: ModelProfileCredentialsSchema.optional(),
|
|
112
120
|
}),
|
|
113
121
|
requestedBy: TaskRequestedBySchema.optional(),
|
|
114
122
|
});
|
|
@@ -225,6 +233,7 @@ async function claimModelFields(
|
|
|
225
233
|
modelSource: undefined,
|
|
226
234
|
modelAlias: undefined,
|
|
227
235
|
resolvedProfile: undefined,
|
|
236
|
+
credentialAllowlist: undefined,
|
|
228
237
|
};
|
|
229
238
|
try {
|
|
230
239
|
return {
|
|
@@ -559,9 +568,33 @@ export async function handlePoll(
|
|
|
559
568
|
// worker (runbooks/model-tiers.md § Harness compatibility). Filter before the
|
|
560
569
|
// budget gate so an incompatible first candidate never drives a refusal.
|
|
561
570
|
const harness = agent.harnessProvider ?? agent.provider ?? null;
|
|
571
|
+
// A pool task with an explicit `profile` also waits for an agent that passes
|
|
572
|
+
// the profile check, judged on the task repo's config as the worker loads it.
|
|
573
|
+
// Memoized per poll: one check per profile name and repo.
|
|
574
|
+
const profileOk = new Map<string, boolean>();
|
|
575
|
+
const includeRepoSecrets = readsRepoSecrets(getRequestAuth(req), agent);
|
|
576
|
+
const passesProfileCheck = async (
|
|
577
|
+
profile: string,
|
|
578
|
+
vcsRepo: string | null | undefined,
|
|
579
|
+
): Promise<boolean> => {
|
|
580
|
+
const memoKey = JSON.stringify([profile, vcsRepo ?? null]);
|
|
581
|
+
const cached = profileOk.get(memoKey);
|
|
582
|
+
if (cached !== undefined) return cached;
|
|
583
|
+
const result = await checkProfileForAgent(myAgentId, profile, {
|
|
584
|
+
vcsRepo,
|
|
585
|
+
includeRepoSecrets,
|
|
586
|
+
});
|
|
587
|
+
const ok = result?.ok !== false;
|
|
588
|
+
profileOk.set(memoKey, ok);
|
|
589
|
+
return ok;
|
|
590
|
+
};
|
|
562
591
|
// The filter runs inside the paginated scan, so incompatible rows never use up the limit.
|
|
563
|
-
const unassignedIds = await getUnassignedTaskIdsForAgent(
|
|
564
|
-
|
|
592
|
+
const unassignedIds = await getUnassignedTaskIdsForAgent(
|
|
593
|
+
myAgentId,
|
|
594
|
+
5,
|
|
595
|
+
async (task) =>
|
|
596
|
+
(await poolTaskRunsOnHarness(task, harness)) &&
|
|
597
|
+
(!task.profile || (await passesProfileCheck(task.profile, task.vcsRepo))),
|
|
565
598
|
);
|
|
566
599
|
// Budget admission gate (Phase 3). Pool path is workers-only —
|
|
567
600
|
// per-agent budgets matter most here, but we still check global.
|