@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
|
@@ -37,6 +37,7 @@
|
|
|
37
37
|
"Calendar",
|
|
38
38
|
"ContributionGraph",
|
|
39
39
|
"Tree",
|
|
40
|
+
"SchemaForm",
|
|
40
41
|
"ElementRef",
|
|
41
42
|
"ElementSlot"
|
|
42
43
|
],
|
|
@@ -2706,6 +2707,60 @@
|
|
|
2706
2707
|
"additionalProperties": false
|
|
2707
2708
|
}
|
|
2708
2709
|
},
|
|
2710
|
+
"SchemaForm": {
|
|
2711
|
+
"description": "Schema-driven props panel. Walks `schema.properties` and renders one control per property — text input (or a select when `enum` is present), number input, or switch — labelled by key with the property `description` as tooltip. Each field seeds from `value?.[key] ?? property.default`. On every field commit the draft object is written to `/ui/<id>/value` and the `onChange` chain is dispatched with `$form` = the current values and `{ \"$value\": true }` = the value just written (the whole merged doc when `baseDoc` is set; never read `/ui/<id>/value` with `$state` in `onChange`, the renderer resolves it before the commit and it is one edit stale). The draft rebuilds whenever the bound `schema` identity changes. With `baseDoc` (a `{ root, elements }` doc) and `nodeKey`, it edits `baseDoc.elements[nodeKey].props` and `/ui/<id>/value` holds the whole doc with the edit merged in, ready for one `app.mutate` (pass it as `{ \"$value\": true }`). At most 100 fields and 200 enum options render, and a `baseDoc` over 5,000 elements is refused. `fill: true` grows the field list to fill a `fill`-aware parent and scrolls internally instead of sizing to content — pair it with a `fill` sibling (e.g. Tree) in the same column Stack to split the available height evenly between them.",
|
|
2712
|
+
"props": {
|
|
2713
|
+
"$schema": "http://json-schema.org/draft-07/schema#",
|
|
2714
|
+
"type": "object",
|
|
2715
|
+
"properties": {
|
|
2716
|
+
"id": {
|
|
2717
|
+
"type": "string"
|
|
2718
|
+
},
|
|
2719
|
+
"schema": {
|
|
2720
|
+
"description": "JSON Schema (object with `properties`) held in state — usually a {$state} binding to a prop schema held in state"
|
|
2721
|
+
},
|
|
2722
|
+
"value": {
|
|
2723
|
+
"description": "Current values object (bound) — seeds the draft; each key falls back to its default. Ignored in nested document editing (baseDoc + nodeKey), where the draft seeds from baseDoc.elements[nodeKey].props"
|
|
2724
|
+
},
|
|
2725
|
+
"baseDoc": {
|
|
2726
|
+
"description": "Nested document editing: the full json-render doc ({ root, elements }) the edited props belong to — usually a {$state} binding to a query row's json column. When present with nodeKey, `/ui/<id>/value` receives the FULL doc with the draft merged into elements[nodeKey].props (a synchronous, parent-side merge), instead of the bare draft."
|
|
2727
|
+
},
|
|
2728
|
+
"nodeKey": {
|
|
2729
|
+
"description": "Nested document editing: the element key inside baseDoc whose props this form edits — usually a {$state} binding to the selected node (e.g. a Tree's /ui/<id>/value).",
|
|
2730
|
+
"type": "string"
|
|
2731
|
+
},
|
|
2732
|
+
"submitLabel": {
|
|
2733
|
+
"type": "string"
|
|
2734
|
+
},
|
|
2735
|
+
"onChange": {
|
|
2736
|
+
"description": "Action chain dispatched on every field commit. $form = the current draft values; with `baseDoc` + `nodeKey` read the merged doc from /ui/<id>/value.",
|
|
2737
|
+
"type": "array",
|
|
2738
|
+
"items": {
|
|
2739
|
+
"type": "object",
|
|
2740
|
+
"properties": {
|
|
2741
|
+
"action": {
|
|
2742
|
+
"type": "string"
|
|
2743
|
+
},
|
|
2744
|
+
"params": {
|
|
2745
|
+
"type": "object",
|
|
2746
|
+
"propertyNames": {
|
|
2747
|
+
"type": "string"
|
|
2748
|
+
},
|
|
2749
|
+
"additionalProperties": {}
|
|
2750
|
+
}
|
|
2751
|
+
},
|
|
2752
|
+
"required": ["action"],
|
|
2753
|
+
"additionalProperties": false
|
|
2754
|
+
}
|
|
2755
|
+
},
|
|
2756
|
+
"fill": {
|
|
2757
|
+
"type": "boolean"
|
|
2758
|
+
}
|
|
2759
|
+
},
|
|
2760
|
+
"required": ["id", "schema"],
|
|
2761
|
+
"additionalProperties": false
|
|
2762
|
+
}
|
|
2763
|
+
},
|
|
2709
2764
|
"ElementRef": {
|
|
2710
2765
|
"description": "Reference a reusable element from this app or an exported element from another app. Consumer children are inserted at the target's ElementSlot.",
|
|
2711
2766
|
"slots": ["default"],
|
package/src/apps/definition.ts
CHANGED
|
@@ -4,6 +4,7 @@ import { getScriptById } from "../be/scripts/db";
|
|
|
4
4
|
import { getSavedScriptOwnerAgentId } from "../be/scripts/run-saved";
|
|
5
5
|
import { APPS_JSON_COLUMN_MAX_BYTES_BOUNDS } from "../be/swarm-config-guard";
|
|
6
6
|
import { checkQuickJSCompat, quickJSCompatWarnings } from "../scripts-runtime/quickjs-compat";
|
|
7
|
+
import { AppIconSchema } from "../types";
|
|
7
8
|
import catalog from "./catalog.generated.json";
|
|
8
9
|
import {
|
|
9
10
|
crossPageDefinitionIssues,
|
|
@@ -467,6 +468,13 @@ export const AppDefinitionSchema = z
|
|
|
467
468
|
pages: z.record(AppNameSchema, AppPageSchema),
|
|
468
469
|
defaultPage: AppNameSchema,
|
|
469
470
|
theme: AppThemeIdSchema.optional(),
|
|
471
|
+
/**
|
|
472
|
+
* Icon shown for the app on the dashboard Apps page (lucide icon name +
|
|
473
|
+
* optional hex color). The server validates shape only; the dashboard owns
|
|
474
|
+
* the curated icon catalog and falls back to a generic icon when the name
|
|
475
|
+
* is unknown (`AVATAR_ICON_CATALOG` in `apps/ui/src/lib/agent-icon.ts`).
|
|
476
|
+
*/
|
|
477
|
+
icon: AppIconSchema.optional(),
|
|
470
478
|
})
|
|
471
479
|
.superRefine((definition, ctx) => {
|
|
472
480
|
if (!Object.hasOwn(definition.pages, definition.defaultPage)) {
|
|
@@ -626,6 +634,7 @@ const APP_DEFINITION_TOP_LEVEL_KEYS = new Set([
|
|
|
626
634
|
"defaultPage",
|
|
627
635
|
"schemaVersion",
|
|
628
636
|
"theme",
|
|
637
|
+
"icon",
|
|
629
638
|
]);
|
|
630
639
|
|
|
631
640
|
const TOP_LEVEL_KEY_SUGGESTIONS: Record<string, string> = {
|
|
@@ -634,6 +643,8 @@ const TOP_LEVEL_KEY_SUGGESTIONS: Record<string, string> = {
|
|
|
634
643
|
themes: "theme",
|
|
635
644
|
appearance: "theme",
|
|
636
645
|
styling: "theme",
|
|
646
|
+
avatar: "icon",
|
|
647
|
+
emoji: "icon",
|
|
637
648
|
};
|
|
638
649
|
|
|
639
650
|
export type AppDefinitionPatchResult =
|
|
@@ -53,9 +53,14 @@ const UI_STATE_COMPONENTS = new Set([
|
|
|
53
53
|
"Tabs",
|
|
54
54
|
"Chips",
|
|
55
55
|
"Tree",
|
|
56
|
+
"SchemaForm",
|
|
56
57
|
"Table",
|
|
57
58
|
]);
|
|
58
59
|
|
|
60
|
+
// A SchemaForm id is spliced into `/ui/<id>/value`, so it must be a plain token.
|
|
61
|
+
const SCHEMA_FORM_ID = /^[A-Za-z0-9_-]+$/;
|
|
62
|
+
const RESERVED_UI_IDS = new Set(["__proto__", "constructor", "prototype"]);
|
|
63
|
+
|
|
59
64
|
/**
|
|
60
65
|
* Props that hold a plain action chain (an array of `{ action, params }`),
|
|
61
66
|
* keyed by component type. Chains nested one level deeper (an array prop
|
|
@@ -67,6 +72,7 @@ const PROP_ACTION_CHAINS: Record<string, readonly string[]> = {
|
|
|
67
72
|
Kanban: ["onMove", "onCardClick"],
|
|
68
73
|
Calendar: ["onSelect"],
|
|
69
74
|
CardGrid: ["onClick"],
|
|
75
|
+
SchemaForm: ["onChange"],
|
|
70
76
|
};
|
|
71
77
|
|
|
72
78
|
/**
|
|
@@ -1411,6 +1417,19 @@ export function validatePage(
|
|
|
1411
1417
|
) {
|
|
1412
1418
|
formIds.add(rawElement.props.id);
|
|
1413
1419
|
}
|
|
1420
|
+
if (
|
|
1421
|
+
type === "SchemaForm" &&
|
|
1422
|
+
isPlainObject(rawElement.props) &&
|
|
1423
|
+
typeof rawElement.props.id === "string" &&
|
|
1424
|
+
(!SCHEMA_FORM_ID.test(rawElement.props.id) || RESERVED_UI_IDS.has(rawElement.props.id))
|
|
1425
|
+
) {
|
|
1426
|
+
issues.push(
|
|
1427
|
+
issue(
|
|
1428
|
+
`${propsPath}.id`,
|
|
1429
|
+
"SchemaForm id must match ^[A-Za-z0-9_-]+$ and not be __proto__, constructor, or prototype",
|
|
1430
|
+
),
|
|
1431
|
+
);
|
|
1432
|
+
}
|
|
1414
1433
|
if (
|
|
1415
1434
|
typeof type === "string" &&
|
|
1416
1435
|
UI_STATE_COMPONENTS.has(type) &&
|
package/src/apps/store.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { defaultAssetKey } from "../assets/key";
|
|
2
2
|
import { getDbClient, literalPrefixPattern } from "../be/db";
|
|
3
|
+
import type { AppIcon } from "../types";
|
|
4
|
+
import { AppIconSchema } from "../types";
|
|
3
5
|
import type { AppDefinition, AppValidationIssue } from "./definition";
|
|
4
6
|
import { AppDefinitionSchema, appDefinitionIssues } from "./definition";
|
|
5
7
|
import {
|
|
@@ -132,11 +134,25 @@ export async function getApp(id: string): Promise<AppRecord | null> {
|
|
|
132
134
|
return row ? decodeApp(row) : null;
|
|
133
135
|
}
|
|
134
136
|
|
|
137
|
+
/** Best-effort `definition.icon` extraction: a malformed or absent value just means no custom icon. */
|
|
138
|
+
function extractIcon(rawDefinitionJson: string): AppIcon | undefined {
|
|
139
|
+
try {
|
|
140
|
+
const parsed: unknown = JSON.parse(rawDefinitionJson);
|
|
141
|
+
const candidate =
|
|
142
|
+
typeof parsed === "object" && parsed !== null
|
|
143
|
+
? (parsed as Record<string, unknown>).icon
|
|
144
|
+
: undefined;
|
|
145
|
+
return AppIconSchema.safeParse(candidate).data;
|
|
146
|
+
} catch {
|
|
147
|
+
return undefined;
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
|
|
135
151
|
export async function listApps(filters?: {
|
|
136
152
|
/** Matches the name or description anywhere, case-insensitive. */
|
|
137
153
|
q?: string;
|
|
138
154
|
limit?: number;
|
|
139
|
-
}): Promise<Array<Omit<AppRecord, "definition"
|
|
155
|
+
}): Promise<Array<Omit<AppRecord, "definition"> & { icon?: AppIcon }>> {
|
|
140
156
|
const params: (string | number)[] = [];
|
|
141
157
|
let where = "";
|
|
142
158
|
if (filters?.q) {
|
|
@@ -154,13 +170,17 @@ export async function listApps(filters?: {
|
|
|
154
170
|
FROM apps${where} ORDER BY created_at DESC, id${limit}`,
|
|
155
171
|
params,
|
|
156
172
|
);
|
|
157
|
-
return rows.map((row) =>
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
173
|
+
return rows.map((row) => {
|
|
174
|
+
const icon = extractIcon(row.definition);
|
|
175
|
+
return {
|
|
176
|
+
id: row.id,
|
|
177
|
+
name: row.name,
|
|
178
|
+
...(row.description === null ? {} : { description: row.description }),
|
|
179
|
+
...(icon ? { icon } : {}),
|
|
180
|
+
createdAt: row.created_at,
|
|
181
|
+
updatedAt: row.updated_at,
|
|
182
|
+
};
|
|
183
|
+
});
|
|
164
184
|
}
|
|
165
185
|
|
|
166
186
|
export async function listAppRecords(): Promise<AppRecord[]> {
|
package/src/assets/key.ts
CHANGED
|
@@ -89,15 +89,88 @@ export function keyPrefixRange(prefix: string): { lo: string; hi: string } {
|
|
|
89
89
|
return { lo, hi: `${lo.slice(0, -1)}${String.fromCharCode(lo.charCodeAt(lo.length - 1) + 1)}` };
|
|
90
90
|
}
|
|
91
91
|
|
|
92
|
-
|
|
93
|
-
|
|
92
|
+
/**
|
|
93
|
+
* Resource kinds whose default key (`defaultAssetKey`) names a session group
|
|
94
|
+
* of its own. At a namespace root (`shared/<kind>:<id>/`,
|
|
95
|
+
* `personal/<me>/<kind>:<id>/`) the leaf is the group, shown under a section
|
|
96
|
+
* per kind (Pages, Workflows, ...). Below a user group it is a plain leaf.
|
|
97
|
+
*/
|
|
98
|
+
export const SESSION_RESOURCE_KINDS = [
|
|
99
|
+
"page",
|
|
100
|
+
"workflow",
|
|
101
|
+
"schedule",
|
|
102
|
+
"app",
|
|
103
|
+
"script",
|
|
104
|
+
"fs",
|
|
105
|
+
] as const;
|
|
106
|
+
export type SessionResourceKind = (typeof SESSION_RESOURCE_KINDS)[number];
|
|
107
|
+
|
|
108
|
+
/** Leaves that file a session into the group above them. */
|
|
109
|
+
export const SESSION_LEAF_KINDS = ["task", "thread", ...SESSION_RESOURCE_KINDS] as const;
|
|
110
|
+
/** The leaves a namespace root (`shared/`, `personal/<me>/`) holds as No group. */
|
|
111
|
+
export const NO_GROUP_LEAF_KINDS = ["task", "thread"] as const;
|
|
112
|
+
const sessionLeafPattern = new RegExp(`/(${SESSION_LEAF_KINDS.join("|")}):[^/]+/$`);
|
|
113
|
+
const resourceGroupPattern = new RegExp(
|
|
114
|
+
`^(shared/|personal/[^/]+/)((${SESSION_RESOURCE_KINDS.join("|")}):([^/]+))/(?:(action:[^/]+)/)?`,
|
|
115
|
+
);
|
|
116
|
+
|
|
117
|
+
const resourcePrefixPattern = new RegExp(
|
|
118
|
+
`^(?:shared/|personal/[^/]+/)(?:${SESSION_RESOURCE_KINDS.join("|")}):`,
|
|
119
|
+
);
|
|
120
|
+
|
|
121
|
+
/** Whether a key sits under a resource group (`shared/<kind>:...`), which is read-only. */
|
|
122
|
+
export function isResourceGroupPrefix(key: string): boolean {
|
|
123
|
+
return resourcePrefixPattern.test(key);
|
|
124
|
+
}
|
|
94
125
|
|
|
95
|
-
|
|
126
|
+
export const RESOURCE_GROUPS_READ_ONLY = "Resource groups are read-only.";
|
|
127
|
+
|
|
128
|
+
/** The resource a session group belongs to, from `sessionGroupKey`. */
|
|
129
|
+
export interface SessionResourceGroup {
|
|
130
|
+
kind: SessionResourceKind;
|
|
131
|
+
/** The resource id (`fs` ids keep their provider: `agent-fs:<id>`). */
|
|
132
|
+
id: string;
|
|
133
|
+
/** The namespace root: `shared/` or `personal/<user>/`. */
|
|
134
|
+
base: string;
|
|
135
|
+
/** The group of the resource itself: `<base><kind>:<id>/`. */
|
|
136
|
+
resourceKey: string;
|
|
137
|
+
/** An app action below the app (`shared/app:<id>/action:<name>/`). */
|
|
138
|
+
action?: string;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
/**
|
|
142
|
+
* The resource of a session group key, or null. Only exact resource groups
|
|
143
|
+
* match: `<base><kind>:<id>/`, or `<base>app:<id>/action:<name>/`. The UI
|
|
144
|
+
* mirrors this in `apps/ui/src/lib/session-groups.ts` (pinned by a test).
|
|
145
|
+
*/
|
|
146
|
+
export function sessionResourceGroupOf(groupKey: string): SessionResourceGroup | null {
|
|
147
|
+
const match = resourceGroupPattern.exec(groupKey);
|
|
148
|
+
if (!match || match[0] !== groupKey) return null;
|
|
149
|
+
const kind = match[3] as SessionResourceKind;
|
|
150
|
+
if (match[5] && kind !== "app") return null;
|
|
151
|
+
return {
|
|
152
|
+
kind,
|
|
153
|
+
id: match[4]!,
|
|
154
|
+
base: match[1]!,
|
|
155
|
+
resourceKey: `${match[1]}${match[2]}/`,
|
|
156
|
+
...(match[5] ? { action: match[5].slice("action:".length) } : {}),
|
|
157
|
+
};
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
/**
|
|
161
|
+
* A root key's session group: the key without its trailing `<kind>:<id>/`
|
|
162
|
+
* leaf, preserving user groups that contain a colon. A resource leaf right at
|
|
163
|
+
* a namespace root stays: it is the resource's group (`shared/page:<id>/`).
|
|
164
|
+
*/
|
|
96
165
|
export function sessionGroupKey(key: string): string {
|
|
97
166
|
const normalized = normalizeAssetKey(key);
|
|
98
167
|
const namespace = parseAssetKey(normalized);
|
|
99
168
|
if (namespace.relativeSegments.length === 0) return normalized;
|
|
100
|
-
|
|
169
|
+
const leaf = sessionLeafPattern.exec(normalized);
|
|
170
|
+
if (!leaf) return normalized;
|
|
171
|
+
const group = normalized.slice(0, leaf.index + 1);
|
|
172
|
+
const resource = (SESSION_RESOURCE_KINDS as readonly string[]).includes(leaf[1]!);
|
|
173
|
+
return resource && parseAssetKey(group).relativeSegments.length === 0 ? normalized : group;
|
|
101
174
|
}
|
|
102
175
|
|
|
103
176
|
export function parseAssetKey(input: string): AssetNamespace {
|
|
@@ -6,12 +6,18 @@
|
|
|
6
6
|
*/
|
|
7
7
|
import {
|
|
8
8
|
type ModelProfile,
|
|
9
|
+
type ModelProfileCredentials,
|
|
10
|
+
ModelProfileCredentialsSchema,
|
|
9
11
|
type ProviderName,
|
|
10
12
|
ProviderNameSchema,
|
|
11
13
|
type ReasoningEffort,
|
|
12
14
|
ReasoningEffortSchema,
|
|
13
15
|
} from "../../types";
|
|
14
|
-
import {
|
|
16
|
+
import {
|
|
17
|
+
checkProfileForAgent,
|
|
18
|
+
formatProfileCheckFailures,
|
|
19
|
+
vcsRepoId,
|
|
20
|
+
} from "../model-profile-check";
|
|
15
21
|
import { getDbClient } from "./runtime";
|
|
16
22
|
import { SUPERSEDED_RESUME_REPAIR_WINDOW_MS } from "./tasks/read";
|
|
17
23
|
|
|
@@ -27,12 +33,50 @@ type ModelProfileRow = {
|
|
|
27
33
|
allowCustomModel: number;
|
|
28
34
|
description: string | null;
|
|
29
35
|
seededFrom: string | null;
|
|
36
|
+
credentialAllowlist: string | null;
|
|
30
37
|
createdAt: string;
|
|
31
38
|
lastUpdatedAt: string;
|
|
32
39
|
};
|
|
33
40
|
|
|
41
|
+
/**
|
|
42
|
+
* Profiles whose stored allowlist is set but unreadable (bad JSON or schema).
|
|
43
|
+
* They read back with `credentials: null`, so list and get endpoints still
|
|
44
|
+
* render them, but null means the whole pool: every dispatch path must check
|
|
45
|
+
* `hasUnreadableCredentialAllowlist` and refuse the profile instead.
|
|
46
|
+
*/
|
|
47
|
+
const unreadableAllowlists = new WeakSet<ModelProfile>();
|
|
48
|
+
|
|
49
|
+
/** Whether `profile`'s stored credential allowlist is set but unreadable. */
|
|
50
|
+
export function hasUnreadableCredentialAllowlist(profile: ModelProfile): boolean {
|
|
51
|
+
return unreadableAllowlists.has(profile);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/** The stored allowlist JSON as a map; `unreadable` when set but not a valid allowlist. */
|
|
55
|
+
function parseCredentialAllowlist(value: string | null): {
|
|
56
|
+
credentials: ModelProfileCredentials | null;
|
|
57
|
+
unreadable: boolean;
|
|
58
|
+
} {
|
|
59
|
+
// Only NULL means "no allowlist". An empty string is malformed: the writer
|
|
60
|
+
// never stores one, so it fails closed like any other unreadable value.
|
|
61
|
+
if (value === null) return { credentials: null, unreadable: false };
|
|
62
|
+
try {
|
|
63
|
+
const parsed = ModelProfileCredentialsSchema.safeParse(JSON.parse(value));
|
|
64
|
+
if (parsed.success) return { credentials: parsed.data, unreadable: false };
|
|
65
|
+
} catch {
|
|
66
|
+
// Falls through to unreadable.
|
|
67
|
+
}
|
|
68
|
+
return { credentials: null, unreadable: true };
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
function serializeCredentialAllowlist(
|
|
72
|
+
value: ModelProfileCredentials | null | undefined,
|
|
73
|
+
): string | null {
|
|
74
|
+
return value && Object.keys(value).length > 0 ? JSON.stringify(value) : null;
|
|
75
|
+
}
|
|
76
|
+
|
|
34
77
|
function rowToModelProfile(row: ModelProfileRow): ModelProfile {
|
|
35
|
-
|
|
78
|
+
const allowlist = parseCredentialAllowlist(row.credentialAllowlist);
|
|
79
|
+
const profile: ModelProfile = {
|
|
36
80
|
id: row.id,
|
|
37
81
|
name: row.name,
|
|
38
82
|
harness: ProviderNameSchema.parse(row.harness),
|
|
@@ -43,9 +87,12 @@ function rowToModelProfile(row: ModelProfileRow): ModelProfile {
|
|
|
43
87
|
allowCustomModel: row.allowCustomModel === 1,
|
|
44
88
|
description: row.description,
|
|
45
89
|
seededFrom: row.seededFrom,
|
|
90
|
+
credentials: allowlist.credentials,
|
|
46
91
|
createdAt: row.createdAt,
|
|
47
92
|
lastUpdatedAt: row.lastUpdatedAt,
|
|
48
93
|
};
|
|
94
|
+
if (allowlist.unreadable) unreadableAllowlists.add(profile);
|
|
95
|
+
return profile;
|
|
49
96
|
}
|
|
50
97
|
|
|
51
98
|
export async function listModelProfiles(
|
|
@@ -78,6 +125,8 @@ export interface ModelProfileInput {
|
|
|
78
125
|
allowCustomModel?: boolean;
|
|
79
126
|
description?: string | null;
|
|
80
127
|
seededFrom?: string | null;
|
|
128
|
+
/** Pooled-key allowlist, stored as `credentialAllowlist`; null uses the whole pool. */
|
|
129
|
+
credentials?: ModelProfileCredentials | null;
|
|
81
130
|
}
|
|
82
131
|
|
|
83
132
|
/** Insert a profile. Returns null when the name is taken. */
|
|
@@ -88,8 +137,8 @@ export async function createModelProfile(
|
|
|
88
137
|
const now = new Date().toISOString();
|
|
89
138
|
const row = await getDbClient().get<ModelProfileRow>(
|
|
90
139
|
`INSERT INTO model_profiles
|
|
91
|
-
(id, name, harness, model, effort, allowCustomModel, description, seededFrom, createdAt, lastUpdatedAt, created_by, updated_by)
|
|
92
|
-
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
|
|
140
|
+
(id, name, harness, model, effort, allowCustomModel, description, seededFrom, credentialAllowlist, createdAt, lastUpdatedAt, created_by, updated_by)
|
|
141
|
+
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
|
|
93
142
|
ON CONFLICT(name) DO NOTHING
|
|
94
143
|
RETURNING *`,
|
|
95
144
|
[
|
|
@@ -101,6 +150,7 @@ export async function createModelProfile(
|
|
|
101
150
|
input.allowCustomModel ? 1 : 0,
|
|
102
151
|
input.description ?? null,
|
|
103
152
|
input.seededFrom ?? null,
|
|
153
|
+
serializeCredentialAllowlist(input.credentials),
|
|
104
154
|
now,
|
|
105
155
|
now,
|
|
106
156
|
audit.userId ?? null,
|
|
@@ -111,10 +161,13 @@ export async function createModelProfile(
|
|
|
111
161
|
}
|
|
112
162
|
|
|
113
163
|
export type ModelProfilePatch = Partial<
|
|
114
|
-
Pick<ModelProfileInput, "model" | "effort" | "allowCustomModel" | "description">
|
|
164
|
+
Pick<ModelProfileInput, "model" | "effort" | "allowCustomModel" | "description" | "credentials">
|
|
115
165
|
>;
|
|
116
166
|
|
|
117
|
-
/**
|
|
167
|
+
/**
|
|
168
|
+
* Update a profile's model, effort, description or credential allowlist
|
|
169
|
+
* (`credentials: null` clears it). The name and harness are fixed.
|
|
170
|
+
*/
|
|
118
171
|
export async function updateModelProfile(
|
|
119
172
|
name: string,
|
|
120
173
|
patch: ModelProfilePatch,
|
|
@@ -138,6 +191,10 @@ export async function updateModelProfile(
|
|
|
138
191
|
sets.push("description = ?");
|
|
139
192
|
params.push(patch.description);
|
|
140
193
|
}
|
|
194
|
+
if (patch.credentials !== undefined) {
|
|
195
|
+
sets.push("credentialAllowlist = ?");
|
|
196
|
+
params.push(serializeCredentialAllowlist(patch.credentials));
|
|
197
|
+
}
|
|
141
198
|
sets.push("lastUpdatedAt = ?", "updated_by = ?");
|
|
142
199
|
params.push(new Date().toISOString(), audit.userId ?? null);
|
|
143
200
|
const row = await getDbClient().get<ModelProfileRow>(
|
|
@@ -167,24 +224,36 @@ function repairWindowStart(): string {
|
|
|
167
224
|
return new Date(Date.now() - SUPERSEDED_RESUME_REPAIR_WINDOW_MS).toISOString();
|
|
168
225
|
}
|
|
169
226
|
|
|
170
|
-
/**
|
|
227
|
+
/**
|
|
228
|
+
* Who still points at a profile: agents with it as default, tasks that still
|
|
229
|
+
* hold it, and schedules that fire tasks with it.
|
|
230
|
+
*/
|
|
171
231
|
export async function modelProfileReferences(
|
|
172
232
|
name: string,
|
|
173
|
-
): Promise<{ agentIds: string[]; openTaskCount: number }> {
|
|
233
|
+
): Promise<{ agentIds: string[]; openTaskCount: number; scheduleIds: string[] }> {
|
|
174
234
|
const agents = await getDbClient().query<{ scopeId: string }>(
|
|
175
235
|
"SELECT scopeId FROM swarm_config WHERE scope = 'agent' AND key = ? AND value = ?",
|
|
176
236
|
[MODEL_PROFILE_CONFIG_KEY, name],
|
|
177
237
|
);
|
|
178
238
|
const tasks = await getDbClient().get<{ n: number }>(
|
|
179
|
-
`SELECT COUNT(*) AS n FROM agent_tasks t
|
|
180
|
-
|
|
239
|
+
`SELECT COUNT(*) AS n FROM agent_tasks t
|
|
240
|
+
WHERE (t.profile = ? OR t.resolvedProfile = ?) AND ${TASK_HOLDS_PROFILE_SQL}`,
|
|
241
|
+
[name, name, repairWindowStart()],
|
|
181
242
|
);
|
|
182
|
-
|
|
243
|
+
const schedules = await getDbClient().query<{ id: string }>(
|
|
244
|
+
"SELECT id FROM scheduled_tasks WHERE profile = ? ORDER BY id",
|
|
245
|
+
[name],
|
|
246
|
+
);
|
|
247
|
+
return {
|
|
248
|
+
agentIds: agents.map((a) => a.scopeId),
|
|
249
|
+
openTaskCount: tasks?.n ?? 0,
|
|
250
|
+
scheduleIds: schedules.map((s) => s.id),
|
|
251
|
+
};
|
|
183
252
|
}
|
|
184
253
|
|
|
185
254
|
/**
|
|
186
|
-
* Which
|
|
187
|
-
* or an agent default names a profile that does not exist.
|
|
255
|
+
* Which reference trigger (migrations 220, 240) refused a write: `missing` when
|
|
256
|
+
* a task, a schedule or an agent default names a profile that does not exist.
|
|
188
257
|
*/
|
|
189
258
|
export function modelProfileRefError(error: unknown): "missing" | null {
|
|
190
259
|
const message = error instanceof Error ? error.message : "";
|
|
@@ -192,11 +261,13 @@ export function modelProfileRefError(error: unknown): "missing" | null {
|
|
|
192
261
|
}
|
|
193
262
|
|
|
194
263
|
/**
|
|
195
|
-
* Delete a profile unless a task still holds it (`TASK_HOLDS_PROFILE_SQL`)
|
|
196
|
-
*
|
|
197
|
-
*
|
|
198
|
-
*
|
|
199
|
-
* after
|
|
264
|
+
* Delete a profile unless a task still holds it (`TASK_HOLDS_PROFILE_SQL`) as
|
|
265
|
+
* its ask or as the profile claim applied (`resolvedProfile`, which a paused
|
|
266
|
+
* task's resume re-reads for its credential allowlist), an
|
|
267
|
+
* agent default names it, or a schedule names it. The check is part of the
|
|
268
|
+
* DELETE statement, so a reference written after the caller's own count still
|
|
269
|
+
* makes it `in-use`; the triggers in migrations 220 and 240 refuse the
|
|
270
|
+
* opposite order (a reference written after this delete).
|
|
200
271
|
*/
|
|
201
272
|
export async function deleteModelProfile(name: string): Promise<"deleted" | "missing" | "in-use"> {
|
|
202
273
|
const row = await getDbClient().get<{ id: string }>(
|
|
@@ -204,10 +275,13 @@ export async function deleteModelProfile(name: string): Promise<"deleted" | "mis
|
|
|
204
275
|
WHERE name = ?
|
|
205
276
|
AND NOT EXISTS (
|
|
206
277
|
SELECT 1 FROM agent_tasks t
|
|
207
|
-
WHERE t.profile = model_profiles.name
|
|
278
|
+
WHERE (t.profile = model_profiles.name OR t.resolvedProfile = model_profiles.name)
|
|
279
|
+
AND ${TASK_HOLDS_PROFILE_SQL})
|
|
208
280
|
AND NOT EXISTS (
|
|
209
281
|
SELECT 1 FROM swarm_config
|
|
210
282
|
WHERE scope = 'agent' AND key = ? AND trim(value) = model_profiles.name)
|
|
283
|
+
AND NOT EXISTS (
|
|
284
|
+
SELECT 1 FROM scheduled_tasks s WHERE s.profile = model_profiles.name)
|
|
211
285
|
RETURNING id`,
|
|
212
286
|
[name, repairWindowStart(), MODEL_PROFILE_CONFIG_KEY],
|
|
213
287
|
);
|
|
@@ -237,33 +311,31 @@ export async function repoModelOverrideKeys(
|
|
|
237
311
|
vcsRepo: string | null | undefined,
|
|
238
312
|
{ includeSecrets = true }: { includeSecrets?: boolean } = {},
|
|
239
313
|
): Promise<Set<string>> {
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
"SELECT id, url FROM swarm_repos WHERE name = ? ORDER BY name ASC",
|
|
243
|
-
[vcsRepoName(vcsRepo)],
|
|
244
|
-
);
|
|
245
|
-
const repo = repos.find((r) => vcsRepoUrlMatches(r.url, vcsRepo));
|
|
246
|
-
if (!repo) return new Set();
|
|
314
|
+
const repoId = await vcsRepoId(vcsRepo);
|
|
315
|
+
if (!repoId) return new Set();
|
|
247
316
|
const rows = await getDbClient().query<{ key: string }>(
|
|
248
317
|
`SELECT key FROM swarm_config
|
|
249
318
|
WHERE scope = 'repo' AND scopeId = ? AND key IN ('MODEL_OVERRIDE', 'REASONING_EFFORT_OVERRIDE')
|
|
250
319
|
${includeSecrets ? "" : "AND isSecret = 0"}`,
|
|
251
|
-
[
|
|
320
|
+
[repoId],
|
|
252
321
|
);
|
|
253
322
|
return new Set(rows.map((row) => row.key));
|
|
254
323
|
}
|
|
255
324
|
|
|
256
325
|
/**
|
|
257
|
-
* Why a task cannot ask for `profile`, or null when it can.
|
|
258
|
-
*
|
|
259
|
-
*
|
|
260
|
-
*
|
|
326
|
+
* Why a task cannot ask for `profile`, or null when it can. The profile must
|
|
327
|
+
* exist and, when the target agent is known, pass `checkProfileForAgent`
|
|
328
|
+
* (harness, model, credentials, allowlist). A pooled task (no agent) is judged
|
|
329
|
+
* per agent at claim instead. `profile` is exclusive with `model` and
|
|
330
|
+
* `modelTier`, which pick the model another way.
|
|
261
331
|
*/
|
|
262
332
|
export async function taskProfileError(check: {
|
|
263
333
|
profile?: string | null;
|
|
264
334
|
model?: string | null;
|
|
265
335
|
modelTier?: string | null;
|
|
266
336
|
agentId?: string | null;
|
|
337
|
+
/** The task's repo; its scoped credentials count, as on the worker. */
|
|
338
|
+
vcsRepo?: string | null;
|
|
267
339
|
}): Promise<string | null> {
|
|
268
340
|
const name = check.profile?.trim();
|
|
269
341
|
if (!name) return null;
|
|
@@ -275,14 +347,51 @@ export async function taskProfileError(check: {
|
|
|
275
347
|
return `Unknown model profile "${name}". List profiles with list-model-profiles.`;
|
|
276
348
|
}
|
|
277
349
|
if (!check.agentId) return null;
|
|
278
|
-
const
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
350
|
+
const result = await checkProfileForAgent(check.agentId, name, { vcsRepo: check.vcsRepo });
|
|
351
|
+
if (!result || result.ok) return null;
|
|
352
|
+
return formatProfileCheckFailures(result);
|
|
353
|
+
}
|
|
354
|
+
|
|
355
|
+
/**
|
|
356
|
+
* The profile half of a schedule update. `profile` and `model`/`modelTier`
|
|
357
|
+
* pick the model two ways, so setting one clears the other, and sending both
|
|
358
|
+
* is an error. A new profile, or a move of a profiled schedule to another
|
|
359
|
+
* agent, is judged by `taskProfileError`. Returns the columns to write.
|
|
360
|
+
*/
|
|
361
|
+
export async function scheduleProfileUpdate(
|
|
362
|
+
existing: { profile?: string | null; targetAgentId?: string | null },
|
|
363
|
+
patch: {
|
|
364
|
+
profile?: string | null;
|
|
365
|
+
model?: string | null;
|
|
366
|
+
modelTier?: string | null;
|
|
367
|
+
targetAgentId?: string | null;
|
|
368
|
+
},
|
|
369
|
+
): Promise<
|
|
370
|
+
| { error: string }
|
|
371
|
+
| { error?: undefined; fields: { profile?: string | null; model?: null; modelTier?: null } }
|
|
372
|
+
> {
|
|
373
|
+
const profile = patch.profile === undefined ? undefined : patch.profile?.trim() || null;
|
|
374
|
+
const agentId = patch.targetAgentId !== undefined ? patch.targetAgentId : existing.targetAgentId;
|
|
375
|
+
if (profile) {
|
|
376
|
+
const error = await taskProfileError({
|
|
377
|
+
profile,
|
|
378
|
+
model: patch.model,
|
|
379
|
+
modelTier: patch.modelTier,
|
|
380
|
+
agentId,
|
|
381
|
+
});
|
|
382
|
+
if (error) return { error };
|
|
383
|
+
return { fields: { profile, model: null, modelTier: null } };
|
|
384
|
+
}
|
|
385
|
+
if (patch.model?.trim() || patch.modelTier?.trim() || profile === null) {
|
|
386
|
+
return { fields: { profile: null } };
|
|
387
|
+
}
|
|
388
|
+
const agentChanged =
|
|
389
|
+
patch.targetAgentId !== undefined && patch.targetAgentId !== existing.targetAgentId;
|
|
390
|
+
if (agentChanged && existing.profile) {
|
|
391
|
+
const error = await taskProfileError({ profile: existing.profile, agentId });
|
|
392
|
+
if (error) return { error };
|
|
284
393
|
}
|
|
285
|
-
return
|
|
394
|
+
return { fields: {} };
|
|
286
395
|
}
|
|
287
396
|
|
|
288
397
|
type OverrideRowState = { value: string; exportToEnv?: number } | null;
|