@desplega.ai/agent-swarm 2.7.10 → 2.8.1
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-pdy3qsvg.js +15 -0
- package/dist/{actions-b8aqhrsg.js → actions-pwjpn0j6.js} +19 -20
- package/dist/{amp-adapter-4c165vgn.js → amp-adapter-cq9jgj6x.js} +2 -3
- package/dist/{app-m9khefrh.js → app-cnfffgwg.js} +3 -3
- package/dist/{assistant-rh4v3ntz.js → assistant-kpn317y1.js} +21 -22
- package/dist/{boot-args-schema-hwkc8bzv.js → boot-args-schema-pbbnhmc3.js} +1 -1
- package/dist/{boot-reembed-fdyk55h4.js → boot-reembed-9m0ysxma.js} +1 -1
- package/dist/{boot-reembed-5y6yw9sj.js → boot-reembed-majbn53m.js} +1 -1
- package/dist/{boot-scrub-sweep-r5r8kqsn.js → boot-scrub-sweep-app8g8ym.js} +3 -3
- package/dist/{boot-seeds-8f9zt5cm.js → boot-seeds-pbtmvcjm.js} +4 -5
- package/dist/{claude-adapter-s5df247c.js → claude-adapter-wn1g3qp5.js} +7 -8
- package/dist/{claude-managed-adapter-h74d06yz.js → claude-managed-adapter-jh6c523j.js} +3 -3
- package/dist/{claude-managed-setup-9gsmwzyx.js → claude-managed-setup-pd47nzch.js} +6 -6
- package/dist/{claude-sdk-session-dq1j4nz9.js → claude-sdk-session-3a2a6589.js} +9066 -8818
- package/dist/{cli-n5yexkdg.js → cli-0b4zam62.js} +1 -0
- package/dist/{cli-5wfz00be.js → cli-0jzra9ad.js} +2 -2
- package/dist/{cli-zjphdj1a.js → cli-0ntbxyaa.js} +40 -18
- package/dist/{cli-yz7v0sh4.js → cli-1xh9a7hn.js} +4 -6
- package/dist/{cli-eqtfgfr6.js → cli-2gxeg5gr.js} +1 -1
- package/dist/{cli-hfkwwy1h.js → cli-2zp0et3v.js} +21 -2
- package/dist/{cli-6m6b4bep.js → cli-3rkdne1h.js} +2 -2
- package/dist/{cli-mr97t7cc.js → cli-4r05hnqa.js} +263 -14
- package/dist/{cli-jc1g9ndz.js → cli-5j88qqa8.js} +10 -5
- package/dist/{cli-xfjrc279.js → cli-5mrq3ake.js} +48 -14
- package/dist/{cli-an1knn2k.js → cli-6mma83xa.js} +5 -5
- package/dist/{cli-tph5wt3y.js → cli-6wj7p986.js} +1 -1
- package/dist/{cli-t73cas91.js → cli-7349va39.js} +8100 -7620
- package/dist/{cli-5xcb8gxq.js → cli-7b8sbmag.js} +8 -8
- package/dist/{cli-3xj33nrx.js → cli-7cp6aa1q.js} +10 -3
- package/dist/{cli-mp9aa8g5.js → cli-7p1kvkck.js} +6 -6
- package/dist/{cli-j7d73g1y.js → cli-7w69ne2f.js} +3035 -354
- package/dist/{cli-cr14kftt.js → cli-89cqnasv.js} +3 -3
- package/dist/{cli-w3bk0dgv.js → cli-8aes17e4.js} +2 -2
- package/dist/{cli-7wz05bx3.js → cli-93k32c37.js} +468 -745
- package/dist/{cli-eqk5p56g.js → cli-9vhebtjz.js} +9 -9
- package/dist/{cli-td33w98c.js → cli-9wngrawf.js} +10 -10
- package/dist/cli-a3b239vq.js +242 -0
- package/dist/{cli-kx4c8j05.js → cli-b085njxz.js} +63 -19
- package/dist/{cli-8ewkreqd.js → cli-b5rs97a6.js} +7 -9
- package/dist/{cli-bxz823sz.js → cli-b8e9nb04.js} +1 -1
- package/dist/{cli-nj3x45rw.js → cli-bb431xey.js} +52 -43
- package/dist/{cli-36wdfzgn.js → cli-bsywb58a.js} +8 -8
- package/dist/{cli-18qt3few.js → cli-cyhbbd1z.js} +1 -1
- package/dist/{cli-eb2azq8n.js → cli-d3p5vwbk.js} +9 -9
- package/dist/{cli-2tsfpc70.js → cli-dy32zecz.js} +1 -1
- package/dist/{cli-rjyghzg4.js → cli-g70vxtjh.js} +2 -2
- package/dist/{cli-55bkx8hh.js → cli-gax7fk3t.js} +1 -1
- package/dist/{cli-jg24scat.js → cli-jcpr5smb.js} +3 -3
- package/dist/{cli-n07eecjs.js → cli-jywyhqws.js} +3 -3
- package/dist/{cli-38yww4e9.js → cli-k0615eh8.js} +8 -8
- package/dist/{cli-3xddv0rk.js → cli-k26bkr9t.js} +5 -7
- package/dist/{cli-xd5ebp64.js → cli-k93bq1wq.js} +3 -3
- package/dist/{cli-f2zenhja.js → cli-kc7v1nfv.js} +1 -1
- package/dist/{cli-x9exydey.js → cli-m4dqmnbp.js} +1 -1
- package/dist/{cli-gpwhbgx0.js → cli-m9s2qff2.js} +57 -25
- package/dist/{cli-ybjdc978.js → cli-mrt48bx7.js} +7 -4
- package/dist/{cli-ttbqe3q4.js → cli-p1w18yhx.js} +1 -1
- package/dist/{cli-h49ejvmc.js → cli-pcad4cb1.js} +1 -1
- package/dist/{cli-tmft5dz2.js → cli-qmqk2yc2.js} +1 -1
- package/dist/{cli-g1px1g2e.js → cli-re4raaj0.js} +1 -1
- package/dist/{cli-xbtq4d6s.js → cli-sn7rtnj4.js} +12 -8
- package/dist/{cli-n9abj89w.js → cli-syybb0p1.js} +8 -8
- package/dist/{cli-v2fwbnsk.js → cli-tacge1w0.js} +6 -6
- package/dist/{cli-pyrxt9gw.js → cli-tk7cjj8h.js} +1 -1
- package/dist/{cli-xvymtmv4.js → cli-tqegb8eq.js} +3 -3
- package/dist/{cli-kf3pxxdg.js → cli-v1dv1r37.js} +1 -1
- package/dist/{cli-z9cs5m0w.js → cli-vbh10fqa.js} +12 -12
- package/dist/{cli-3xcwp3z8.js → cli-vj75tyaw.js} +3 -3
- package/dist/{cli-xncjscpm.js → cli-vqptjbr7.js} +50 -24
- package/dist/{cli-q581b386.js → cli-wk18cm92.js} +5 -5
- package/dist/{cli-4vwxp550.js → cli-x1wa213s.js} +1 -1
- package/dist/{cli-n9ftpys4.js → cli-x6t50dmw.js} +7 -7
- package/dist/{cli-jrp1dt73.js → cli-xzm9vcfg.js} +1 -1
- package/dist/{cli-16phend6.js → cli-yn2bbre9.js} +1 -1
- package/dist/{cli-rt0ag4x1.js → cli-yncmerje.js} +5 -5
- package/dist/{cli-0m7rtm11.js → cli-zcsw143p.js} +1 -1
- package/dist/cli.js +18 -18
- package/dist/{codex-adapter-yr60sme6.js → codex-adapter-nha71q3n.js} +5 -6
- package/dist/{codex-hook-fac6175r.js → codex-hook-h3vk6xzr.js} +1 -1
- package/dist/{codex-session-runner-pch8x584.js → codex-session-runner-ak9x1k1h.js} +5 -6
- package/dist/{commands-phjfbkv0.js → commands-f587qpq8.js} +3 -3
- package/dist/{controller-jkx994pz.js → controller-hxx8wwy1.js} +2 -2
- package/dist/{controllers-connect-c4448kwa.js → controllers-connect-k5sg9m9h.js} +20 -21
- package/dist/{cursor-adapter-ndebqnm8.js → cursor-adapter-n5nc3mfe.js} +1 -2
- package/dist/{db-ef32tbfc.js → db-amm8w15a.js} +10 -2
- package/dist/{db-ez6egt6v.js → db-nzf8zb5z.js} +3 -3
- package/dist/{devin-adapter-z46ep5ph.js → devin-adapter-xedz98zv.js} +1 -1
- package/dist/{dispatcher-g3tt9hs9.js → dispatcher-89zrts8f.js} +18 -19
- package/dist/{dsh-adapter-tcyn3099.js → dsh-adapter-nrhbrjz8.js} +1 -2
- package/dist/{easter-egg-3d-e36hk5td.js → easter-egg-3d-533knw22.js} +1 -1
- package/dist/{embedding-space-4kyh5qqj.js → embedding-space-ezwenjmj.js} +6 -6
- package/dist/{embeddings-6a8v4a6t.js → embeddings-np74ht6g.js} +1 -1
- package/dist/{execute-3cbg0twf.js → execute-b3mrb1mv.js} +1 -1
- package/dist/{external-channel-se646snz.js → external-channel-z46yx9d7.js} +2 -2
- package/dist/{fx-adapter-yw795hqq.js → fx-adapter-3q12snn6.js} +7 -8
- package/dist/{grok-adapter-ttmcss2j.js → grok-adapter-ahb1w033.js} +7 -8
- package/dist/handlers-vbww69re.js +32 -0
- package/dist/heartbeat-dt9qw9c8.js +43 -0
- package/dist/{hook-hq93y5ej.js → hook-8k6fbz9b.js} +5 -5
- package/dist/{hook-g3nhexsy.js → hook-jgcgygex.js} +6 -6
- package/dist/{http-5a9p4h6y.js → http-haw4r8ne.js} +284 -142
- package/dist/{index-0eny15vj.js → index-2skqtd76.js} +2 -2
- package/dist/{index-6haqt3v5.js → index-4a0670yh.js} +8917 -8476
- package/dist/index-4xwaf5th.js +32 -0
- package/dist/{index-3c5pxbge.js → index-5gk12my8.js} +1 -1
- package/dist/{index-w7em4ktq.js → index-d6wkh8ar.js} +2 -2
- package/dist/index-f0hcrs8e.js +33 -0
- package/dist/{index-rvccek1w.js → index-gjwaqaq8.js} +5 -5
- package/dist/{index-e5pfbsys.js → index-hjhfk3ra.js} +3 -3
- package/dist/{index-1qw6f2dc.js → index-khe3gp0k.js} +4 -4
- package/dist/index-s4ewdma4.js +37 -0
- package/dist/{index-hgn3c961.js → index-tez78qj3.js} +979 -36
- package/dist/{index-s72rqgsx.js → index-tvfafeyy.js} +1 -1
- package/dist/{keepalive-1j4n4dmk.js → keepalive-xn6s7rmg.js} +3 -3
- package/dist/lead-6ygbfhbh.js +70 -0
- package/dist/{maintenance-dmghacy5.js → maintenance-vdts800b.js} +1 -1
- package/dist/{node-je82wjet.js → node-4c5jqxr3.js} +1 -1
- package/dist/{oauth-refresh-sweep-yy06c03c.js → oauth-refresh-sweep-094c8wfk.js} +2 -2
- package/dist/{onboard-52f9t5dm.js → onboard-v99eh56m.js} +3 -3
- package/dist/{opencode-adapter-krnh9jkn.js → opencode-adapter-dsagkhtw.js} +5 -6
- package/dist/{otel-impl-xjqz6wjj.js → otel-impl-q7yr9yp0.js} +1 -1
- package/dist/{pi-mono-adapter-dbxyp0qv.js → pi-mono-adapter-546cd1cc.js} +9 -9
- package/dist/{pricing-refresh-ctdr74pd.js → pricing-refresh-7dh2yase.js} +2 -3
- package/dist/{rbac-roles-ehv8s10n.js → rbac-roles-mdmc96p4.js} +3 -3
- package/dist/{rbac-roles-q0gr8eyj.js → rbac-roles-npbmdh77.js} +4 -6
- package/dist/{registry-hpjfmcfz.js → registry-32b1mft6.js} +1 -1
- package/dist/{render-v2-5b6chvcq.js → render-v2-twhhwmms.js} +3 -3
- package/dist/{resume-5a5d2845.js → resume-5gsrjd5e.js} +6 -6
- package/dist/{runtime-khxszyfp.js → runtime-1hv06jsn.js} +1 -1
- package/dist/{session-access-gj0bjhqg.js → session-access-m191x30x.js} +4 -4
- package/dist/{session-source-backfill-2sy0krfk.js → session-source-backfill-nt923ask.js} +2 -2
- package/dist/{setup-7ssfakk1.js → setup-wv467afy.js} +1 -1
- package/dist/{virtual-modules-pjj0knwf.js → virtual-modules-gazyapte.js} +3 -3
- package/dist/{work-objects-bf3syvhq.js → work-objects-8zkrpy13.js} +21 -22
- package/dist/{worker-follow-up-38xevga6.js → worker-follow-up-cecqszem.js} +18 -19
- package/dist/worker-mz5z7kj0.js +70 -0
- package/openapi.json +334 -7
- package/package.json +5 -5
- package/src/apps/definition.ts +11 -0
- package/src/apps/store.ts +28 -8
- package/src/be/db/model-profiles.ts +147 -38
- package/src/be/db/tasks/read.ts +5 -1
- package/src/be/db/workflow-run-definitions.ts +117 -0
- package/src/be/db.ts +24 -3
- 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 +160 -10
- package/src/be/memory/task-learning.ts +79 -14
- package/src/be/memory/types.ts +24 -1
- 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/commands/onboard/agent-fs-version.ts +1 -1
- package/src/commands/runner.ts +32 -1
- package/src/fs/provider.ts +17 -3
- package/src/heartbeat/heartbeat.ts +12 -1
- 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/index.ts +2 -3
- 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/tasks.ts +37 -12
- package/src/http/workflows.ts +15 -2
- 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/scripts-runtime/eval-harness.ts +14 -1
- package/src/scripts-runtime/executors/types.ts +3 -0
- 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 +93 -0
- package/src/slack/inbound-dispatch.ts +18 -1
- 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/chained-task-follow-up.test.ts +248 -0
- 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-task-read-contract.test.ts +5 -0
- package/src/tests/db-task-write-contract.test.ts +5 -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/explicit-model-validation.test.ts +2 -0
- package/src/tests/fs-provider.test.ts +42 -0
- package/src/tests/heartbeat.test.ts +28 -1
- package/src/tests/human-free-reclassify.test.ts +5 -1
- package/src/tests/list-endpoint-slimming.test.ts +17 -0
- package/src/tests/mcp-tools.test.ts +1 -1
- 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/schedule-profile.test.ts +359 -0
- package/src/tests/script-connections.test.ts +6 -0
- package/src/tests/script-native-unawaited-drain.test.ts +167 -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/slack-inbound-receipts.test.ts +22 -2
- package/src/tests/slack-socket-ack.test.ts +16 -1
- 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/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/script-run.ts +1 -1
- 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 +61 -4
- 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/skills/apps/SKILL.md +2 -0
- package/templates/skills/apps/content.md +2 -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 +2 -2
- package/templates/skills/swarm-scripts/content.md +2 -2
- 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-srfhs1s9.js +0 -16
- package/dist/cli-bzvs88tv.js +0 -339
- package/dist/cli-cyn9v8zr.js +0 -748
- package/dist/cli-ed6yqpf1.js +0 -779
- package/dist/handlers-17wha3ze.js +0 -33
- package/dist/heartbeat-gwewgdms.js +0 -42
- package/dist/index-8arwq8mw.js +0 -34
- package/dist/index-tpw054az.js +0 -38
- package/dist/index-waq75j2j.js +0 -31
- package/dist/lead-re73kdgc.js +0 -72
- package/dist/worker-r8mz7a65.js +0 -72
|
@@ -543,27 +543,50 @@ describe("workflow foreach", () => {
|
|
|
543
543
|
expect(await stepByNodeId(runId, "after")).toBeUndefined();
|
|
544
544
|
});
|
|
545
545
|
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
546
|
+
for (const [value, limit] of [
|
|
547
|
+
[undefined, 500],
|
|
548
|
+
["", 500],
|
|
549
|
+
[" ", 500],
|
|
550
|
+
["Infinity", 500],
|
|
551
|
+
["-Infinity", 500],
|
|
552
|
+
["NaN", 500],
|
|
553
|
+
["invalid", 500],
|
|
554
|
+
["0", 500],
|
|
555
|
+
["-1", 500],
|
|
556
|
+
["1.5", 500],
|
|
557
|
+
["1", 1],
|
|
558
|
+
["3", 3],
|
|
559
|
+
["501", 501],
|
|
560
|
+
] as const) {
|
|
561
|
+
test(`WORKFLOW_MAX_STEPS_PER_RUN=${value} refuses dispatch beyond ${limit} steps`, async () => {
|
|
562
|
+
const originalLimit = process.env.WORKFLOW_MAX_STEPS_PER_RUN;
|
|
563
|
+
if (value === undefined) delete process.env.WORKFLOW_MAX_STEPS_PER_RUN;
|
|
564
|
+
else process.env.WORKFLOW_MAX_STEPS_PER_RUN = value;
|
|
565
|
+
|
|
566
|
+
try {
|
|
567
|
+
const { registry } = createRegistry(false);
|
|
568
|
+
const definition = foreachDefinition();
|
|
569
|
+
definition.nodes[0]!.config.itemKey = "name";
|
|
570
|
+
const workflow = await makeWorkflow(definition);
|
|
571
|
+
const items = Array.from({ length: limit }, (_, i) => ({
|
|
572
|
+
id: agentItems[0]!.id,
|
|
573
|
+
name: `item-${i}`,
|
|
574
|
+
}));
|
|
575
|
+
const runId = await startWorkflowExecution(workflow, { items }, registry);
|
|
576
|
+
|
|
577
|
+
expect((await getWorkflowRun(runId))?.status).toBe("failed");
|
|
578
|
+
expect((await stepByNodeId(runId, "reflect"))?.status).toBe("failed");
|
|
579
|
+
expect((await stepByNodeId(runId, "reflect"))?.error).toContain(
|
|
580
|
+
`foreach would reach ${limit} total steps (WORKFLOW_MAX_STEPS_PER_RUN)`,
|
|
581
|
+
);
|
|
582
|
+
expect(await foreachChildren(runId)).toHaveLength(0);
|
|
583
|
+
expect(await taskCountForForeachChildren(runId)).toBe(0);
|
|
584
|
+
} finally {
|
|
585
|
+
if (originalLimit === undefined) delete process.env.WORKFLOW_MAX_STEPS_PER_RUN;
|
|
586
|
+
else process.env.WORKFLOW_MAX_STEPS_PER_RUN = originalLimit;
|
|
564
587
|
}
|
|
565
|
-
}
|
|
566
|
-
}
|
|
588
|
+
});
|
|
589
|
+
}
|
|
567
590
|
|
|
568
591
|
test("foreach rejects a fan-out that lands exactly on the step cap when reaching it", async () => {
|
|
569
592
|
// 1 existing (parent) + 3 children == cap of 4. Admitting this would spend all
|
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
import { afterAll, afterEach, beforeAll, describe, expect, mock, test } from "bun:test";
|
|
2
|
+
|
|
3
|
+
// The Slack client the executor sees. Tests set it, or set it after a delay to
|
|
4
|
+
// model a server whose Slack client is not up yet.
|
|
5
|
+
type FakeApp = { client: { chat: { postMessage: (args: unknown) => Promise<{ ts: string }> } } };
|
|
6
|
+
let currentApp: FakeApp | null = null;
|
|
7
|
+
const posted: unknown[] = [];
|
|
8
|
+
|
|
9
|
+
mock.module("../slack/app", () => ({
|
|
10
|
+
getSlackApp: () => currentApp,
|
|
11
|
+
}));
|
|
12
|
+
|
|
13
|
+
import type { ExecutorMeta } from "../types";
|
|
14
|
+
import type { ExecutorDependencies } from "../workflows/executors/base";
|
|
15
|
+
import { _setNotifySlackReadyWaitForTests, NotifyExecutor } from "../workflows/executors/notify";
|
|
16
|
+
|
|
17
|
+
const SLACK_ENV_KEYS = ["SLACK_DISABLE", "SLACK_MODE", "SLACK_BOT_TOKEN", "SLACK_APP_TOKEN"];
|
|
18
|
+
const savedEnv: Record<string, string | undefined> = {};
|
|
19
|
+
|
|
20
|
+
function fakeApp(): FakeApp {
|
|
21
|
+
return {
|
|
22
|
+
client: {
|
|
23
|
+
chat: {
|
|
24
|
+
postMessage: async (args: unknown) => {
|
|
25
|
+
posted.push(args);
|
|
26
|
+
return { ts: "1700000000.000100" };
|
|
27
|
+
},
|
|
28
|
+
},
|
|
29
|
+
},
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
function configureSlack(configured: boolean): void {
|
|
34
|
+
for (const key of SLACK_ENV_KEYS) delete process.env[key];
|
|
35
|
+
if (configured) {
|
|
36
|
+
process.env.SLACK_BOT_TOKEN = "xoxb-test";
|
|
37
|
+
process.env.SLACK_APP_TOKEN = "xapp-test";
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
const deps = {
|
|
42
|
+
db: {},
|
|
43
|
+
eventBus: { emit: () => {}, on: () => {}, off: () => {} },
|
|
44
|
+
interpolate: (template: string) => template,
|
|
45
|
+
} as unknown as ExecutorDependencies;
|
|
46
|
+
|
|
47
|
+
const executor = new NotifyExecutor(deps);
|
|
48
|
+
|
|
49
|
+
function run(signal?: AbortSignal) {
|
|
50
|
+
const meta: ExecutorMeta = {
|
|
51
|
+
runId: "00000000-0000-0000-0000-000000000001",
|
|
52
|
+
stepId: "00000000-0000-0000-0000-000000000002",
|
|
53
|
+
nodeId: "notify",
|
|
54
|
+
workflowId: "00000000-0000-0000-0000-000000000003",
|
|
55
|
+
dryRun: false,
|
|
56
|
+
...(signal ? { signal } : {}),
|
|
57
|
+
};
|
|
58
|
+
return executor.run({
|
|
59
|
+
config: { channel: "slack", target: "C123", template: "drift alert" },
|
|
60
|
+
context: {},
|
|
61
|
+
meta,
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
beforeAll(() => {
|
|
66
|
+
for (const key of SLACK_ENV_KEYS) savedEnv[key] = process.env[key];
|
|
67
|
+
_setNotifySlackReadyWaitForTests({ timeoutMs: 400, pollMs: 10 });
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
afterEach(() => {
|
|
71
|
+
currentApp = null;
|
|
72
|
+
posted.length = 0;
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
afterAll(() => {
|
|
76
|
+
for (const key of SLACK_ENV_KEYS) {
|
|
77
|
+
if (savedEnv[key] === undefined) delete process.env[key];
|
|
78
|
+
else process.env[key] = savedEnv[key];
|
|
79
|
+
}
|
|
80
|
+
_setNotifySlackReadyWaitForTests({ timeoutMs: 25_000, pollMs: 250 });
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
describe("NotifyExecutor slack readiness", () => {
|
|
84
|
+
test("Slack not configured: success with sent=false, no wait", async () => {
|
|
85
|
+
configureSlack(false);
|
|
86
|
+
const started = Date.now();
|
|
87
|
+
const result = await run();
|
|
88
|
+
expect(result.status).toBe("success");
|
|
89
|
+
expect(result.output).toMatchObject({ sent: false, message: "drift alert" });
|
|
90
|
+
expect(Date.now() - started).toBeLessThan(200);
|
|
91
|
+
expect(posted).toHaveLength(0);
|
|
92
|
+
});
|
|
93
|
+
|
|
94
|
+
test("Slack configured and ready: posts", async () => {
|
|
95
|
+
configureSlack(true);
|
|
96
|
+
currentApp = fakeApp();
|
|
97
|
+
const result = await run();
|
|
98
|
+
expect(result.status).toBe("success");
|
|
99
|
+
expect(result.output).toMatchObject({ sent: true, messageId: "1700000000.000100" });
|
|
100
|
+
expect(posted).toHaveLength(1);
|
|
101
|
+
});
|
|
102
|
+
|
|
103
|
+
test("Slack configured but not ready yet: waits for the client, then posts", async () => {
|
|
104
|
+
configureSlack(true);
|
|
105
|
+
const timer = setTimeout(() => {
|
|
106
|
+
currentApp = fakeApp();
|
|
107
|
+
}, 50);
|
|
108
|
+
try {
|
|
109
|
+
const result = await run();
|
|
110
|
+
expect(result.status).toBe("success");
|
|
111
|
+
expect(result.output).toMatchObject({ sent: true, message: "drift alert" });
|
|
112
|
+
expect(posted).toEqual([
|
|
113
|
+
{ channel: "C123", text: "drift alert", unfurl_links: false, unfurl_media: false },
|
|
114
|
+
]);
|
|
115
|
+
} finally {
|
|
116
|
+
clearTimeout(timer);
|
|
117
|
+
}
|
|
118
|
+
});
|
|
119
|
+
|
|
120
|
+
test("Slack configured but never ready: fails instead of reporting success", async () => {
|
|
121
|
+
configureSlack(true);
|
|
122
|
+
const result = await run();
|
|
123
|
+
expect(result.status).toBe("failed");
|
|
124
|
+
expect(result.error).toContain("Slack is configured but its client was not ready");
|
|
125
|
+
expect(result.output).toBeUndefined();
|
|
126
|
+
expect(posted).toHaveLength(0);
|
|
127
|
+
});
|
|
128
|
+
|
|
129
|
+
test("Slack configured, step deadline aborts the wait: fails early", async () => {
|
|
130
|
+
configureSlack(true);
|
|
131
|
+
const controller = new AbortController();
|
|
132
|
+
setTimeout(() => controller.abort(), 20);
|
|
133
|
+
const started = Date.now();
|
|
134
|
+
const result = await run(controller.signal);
|
|
135
|
+
expect(result.status).toBe("failed");
|
|
136
|
+
expect(Date.now() - started).toBeLessThan(300);
|
|
137
|
+
expect(posted).toHaveLength(0);
|
|
138
|
+
});
|
|
139
|
+
|
|
140
|
+
test("Slack becomes ready after the deadline aborts but before the next poll: does not post", async () => {
|
|
141
|
+
configureSlack(true);
|
|
142
|
+
// One long poll interval, so the abort and the readiness both land inside
|
|
143
|
+
// the same sleep.
|
|
144
|
+
_setNotifySlackReadyWaitForTests({ pollMs: 150 });
|
|
145
|
+
const controller = new AbortController();
|
|
146
|
+
const abortTimer = setTimeout(() => controller.abort(), 20);
|
|
147
|
+
const readyTimer = setTimeout(() => {
|
|
148
|
+
currentApp = fakeApp();
|
|
149
|
+
}, 60);
|
|
150
|
+
try {
|
|
151
|
+
const result = await run(controller.signal);
|
|
152
|
+
expect(result.status).toBe("failed");
|
|
153
|
+
expect(result.error).toContain("Step deadline reached");
|
|
154
|
+
expect(posted).toHaveLength(0);
|
|
155
|
+
} finally {
|
|
156
|
+
clearTimeout(abortTimer);
|
|
157
|
+
clearTimeout(readyTimer);
|
|
158
|
+
_setNotifySlackReadyWaitForTests({ pollMs: 10 });
|
|
159
|
+
}
|
|
160
|
+
});
|
|
161
|
+
});
|
|
@@ -0,0 +1,328 @@
|
|
|
1
|
+
// `profile` on workflow agent-task nodes (plan phase 6): save rejects a static
|
|
2
|
+
// profile that is unknown, sits beside model/modelTier, or fails the check for
|
|
3
|
+
// a static agentId (foreach bodies too); a node run creates its task with the
|
|
4
|
+
// profile; an interpolated profile that fails the check fails the node.
|
|
5
|
+
|
|
6
|
+
import { afterAll, beforeAll, describe, expect, test } from "bun:test";
|
|
7
|
+
import { unlink } from "node:fs/promises";
|
|
8
|
+
import { createServer, type Server } from "node:http";
|
|
9
|
+
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
10
|
+
import * as db from "../be/db";
|
|
11
|
+
import {
|
|
12
|
+
closeDb,
|
|
13
|
+
createAgent,
|
|
14
|
+
createSwarmRepo,
|
|
15
|
+
createWorkflow,
|
|
16
|
+
getTaskByWorkflowRunStepId,
|
|
17
|
+
getWorkflow,
|
|
18
|
+
getWorkflowRun,
|
|
19
|
+
getWorkflowRunStepsByRunId,
|
|
20
|
+
initDb,
|
|
21
|
+
upsertSwarmConfig,
|
|
22
|
+
} from "../be/db";
|
|
23
|
+
import { updateAgentCredStatus } from "../be/db/agents";
|
|
24
|
+
import { createModelProfile } from "../be/db/model-profiles";
|
|
25
|
+
import { reloadModelsCatalog } from "../be/model-catalog-store";
|
|
26
|
+
import { getPathSegments, parseQueryParams } from "../http/utils";
|
|
27
|
+
import { handleWorkflows } from "../http/workflows";
|
|
28
|
+
import { registerUpdateWorkflowTool } from "../tools/workflows/update-workflow";
|
|
29
|
+
import type { AgentCredStatus, WorkflowDefinition } from "../types";
|
|
30
|
+
import { startWorkflowExecution } from "../workflows/engine";
|
|
31
|
+
import { workflowEventBus } from "../workflows/event-bus";
|
|
32
|
+
import { AgentTaskExecutor } from "../workflows/executors/agent-task";
|
|
33
|
+
import type { ExecutorDependencies } from "../workflows/executors/base";
|
|
34
|
+
import { ExecutorRegistry } from "../workflows/executors/registry";
|
|
35
|
+
import { workflowModelErrors } from "../workflows/model-validation";
|
|
36
|
+
import { interpolate } from "../workflows/template";
|
|
37
|
+
import { listenOnFreePort } from "./test-net";
|
|
38
|
+
|
|
39
|
+
const TEST_DB_PATH = "./test-workflow-profile.sqlite";
|
|
40
|
+
const oldEncryptionKey = process.env.SECRETS_ENCRYPTION_KEY;
|
|
41
|
+
|
|
42
|
+
async function removeDbFiles(path: string): Promise<void> {
|
|
43
|
+
for (const suffix of ["", "-wal", "-shm"]) {
|
|
44
|
+
await unlink(path + suffix).catch(() => undefined);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
const READY: AgentCredStatus = {
|
|
49
|
+
ready: true,
|
|
50
|
+
missing: [],
|
|
51
|
+
satisfiedBy: "env",
|
|
52
|
+
hint: null,
|
|
53
|
+
liveTest: null,
|
|
54
|
+
latestModel: null,
|
|
55
|
+
reportedAt: Date.now(),
|
|
56
|
+
reportKind: "boot",
|
|
57
|
+
bedrock: null,
|
|
58
|
+
acp: null,
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
const deps: ExecutorDependencies = {
|
|
62
|
+
db: db as typeof import("../be/db"),
|
|
63
|
+
eventBus: workflowEventBus,
|
|
64
|
+
interpolate: (template, ctx) => interpolate(template, ctx).result,
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
let registry: ExecutorRegistry;
|
|
68
|
+
let claudeId = "";
|
|
69
|
+
let codexId = "";
|
|
70
|
+
|
|
71
|
+
beforeAll(async () => {
|
|
72
|
+
process.env.SECRETS_ENCRYPTION_KEY ??= Buffer.alloc(32, 7).toString("base64");
|
|
73
|
+
await removeDbFiles(TEST_DB_PATH);
|
|
74
|
+
initDb(TEST_DB_PATH);
|
|
75
|
+
await reloadModelsCatalog();
|
|
76
|
+
registry = new ExecutorRegistry();
|
|
77
|
+
registry.register(new AgentTaskExecutor(deps));
|
|
78
|
+
claudeId = (
|
|
79
|
+
await createAgent({
|
|
80
|
+
name: "wp-claude",
|
|
81
|
+
isLead: false,
|
|
82
|
+
status: "idle",
|
|
83
|
+
harnessProvider: "claude",
|
|
84
|
+
})
|
|
85
|
+
).id;
|
|
86
|
+
await updateAgentCredStatus(claudeId, READY);
|
|
87
|
+
codexId = (
|
|
88
|
+
await createAgent({ name: "wp-codex", isLead: false, status: "idle", harnessProvider: "codex" })
|
|
89
|
+
).id;
|
|
90
|
+
await updateAgentCredStatus(codexId, READY);
|
|
91
|
+
await createModelProfile({ name: "wp-claude-opus", harness: "claude", model: "opus" });
|
|
92
|
+
});
|
|
93
|
+
|
|
94
|
+
afterAll(async () => {
|
|
95
|
+
closeDb();
|
|
96
|
+
await removeDbFiles(TEST_DB_PATH);
|
|
97
|
+
if (oldEncryptionKey === undefined) delete process.env.SECRETS_ENCRYPTION_KEY;
|
|
98
|
+
else process.env.SECRETS_ENCRYPTION_KEY = oldEncryptionKey;
|
|
99
|
+
});
|
|
100
|
+
|
|
101
|
+
function agentTaskDef(config: Record<string, unknown>): WorkflowDefinition {
|
|
102
|
+
return {
|
|
103
|
+
nodes: [{ id: "work", type: "agent-task", config: { template: "do it", ...config } }],
|
|
104
|
+
} as unknown as WorkflowDefinition;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
describe("workflow save (workflowModelErrors)", () => {
|
|
108
|
+
test("rejects a static unknown profile", async () => {
|
|
109
|
+
const errors = await workflowModelErrors(agentTaskDef({ profile: "wp-no-such-profile" }));
|
|
110
|
+
expect(errors).toHaveLength(1);
|
|
111
|
+
expect(errors[0]).toContain('Node "work" config.profile');
|
|
112
|
+
expect(errors[0]).toContain('Unknown model profile "wp-no-such-profile"');
|
|
113
|
+
});
|
|
114
|
+
|
|
115
|
+
test("rejects a harness mismatch with a static agentId", async () => {
|
|
116
|
+
const errors = await workflowModelErrors(
|
|
117
|
+
agentTaskDef({ agentId: codexId, profile: "wp-claude-opus" }),
|
|
118
|
+
);
|
|
119
|
+
expect(errors).toHaveLength(1);
|
|
120
|
+
expect(errors[0]).toContain('Node "work" config.profile');
|
|
121
|
+
expect(errors[0]).toContain('Model profile "wp-claude-opus" fails harness');
|
|
122
|
+
});
|
|
123
|
+
|
|
124
|
+
test("rejects profile beside model or modelTier", async () => {
|
|
125
|
+
for (const extra of [{ model: "opus" }, { modelTier: "smart" }]) {
|
|
126
|
+
const errors = await workflowModelErrors(
|
|
127
|
+
agentTaskDef({ agentId: claudeId, profile: "wp-claude-opus", ...extra }),
|
|
128
|
+
);
|
|
129
|
+
expect(errors.some((e) => e.includes("config.profile") && e.includes("not both"))).toBe(true);
|
|
130
|
+
}
|
|
131
|
+
});
|
|
132
|
+
|
|
133
|
+
test("judges a foreach body", async () => {
|
|
134
|
+
const definition = {
|
|
135
|
+
nodes: [
|
|
136
|
+
{
|
|
137
|
+
id: "each",
|
|
138
|
+
type: "foreach",
|
|
139
|
+
config: {
|
|
140
|
+
items: "{{trigger.items}}",
|
|
141
|
+
body: {
|
|
142
|
+
type: "agent-task",
|
|
143
|
+
config: { template: "x", agentId: codexId, profile: "wp-claude-opus" },
|
|
144
|
+
},
|
|
145
|
+
},
|
|
146
|
+
},
|
|
147
|
+
],
|
|
148
|
+
} as unknown as WorkflowDefinition;
|
|
149
|
+
const errors = await workflowModelErrors(definition);
|
|
150
|
+
expect(errors).toHaveLength(1);
|
|
151
|
+
expect(errors[0]).toContain('Node "each" config.body.config.profile');
|
|
152
|
+
});
|
|
153
|
+
|
|
154
|
+
test("accepts a passing profile, a pool node, and an interpolated profile", async () => {
|
|
155
|
+
expect(
|
|
156
|
+
await workflowModelErrors(agentTaskDef({ agentId: claudeId, profile: "wp-claude-opus" })),
|
|
157
|
+
).toEqual([]);
|
|
158
|
+
expect(await workflowModelErrors(agentTaskDef({ profile: "wp-claude-opus" }))).toEqual([]);
|
|
159
|
+
expect(
|
|
160
|
+
await workflowModelErrors(agentTaskDef({ agentId: codexId, profile: "{{trigger.p}}" })),
|
|
161
|
+
).toEqual([]);
|
|
162
|
+
});
|
|
163
|
+
});
|
|
164
|
+
|
|
165
|
+
async function waitFor<T>(
|
|
166
|
+
probe: () => Promise<T | null | undefined | false>,
|
|
167
|
+
label: string,
|
|
168
|
+
timeoutMs = 3000,
|
|
169
|
+
): Promise<T> {
|
|
170
|
+
const deadline = Date.now() + timeoutMs;
|
|
171
|
+
while (Date.now() < deadline) {
|
|
172
|
+
const value = await probe();
|
|
173
|
+
if (value) return value;
|
|
174
|
+
await new Promise((r) => setTimeout(r, 10));
|
|
175
|
+
}
|
|
176
|
+
throw new Error(`Timed out waiting for ${label}`);
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
let counter = 0;
|
|
180
|
+
async function run(config: Record<string, unknown>, trigger: Record<string, unknown> = {}) {
|
|
181
|
+
counter++;
|
|
182
|
+
const workflow = await createWorkflow({
|
|
183
|
+
name: `workflow-profile-${counter}-${Date.now()}`,
|
|
184
|
+
definition: agentTaskDef(config),
|
|
185
|
+
});
|
|
186
|
+
return await startWorkflowExecution(workflow, trigger, registry);
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
describe("node run", () => {
|
|
190
|
+
test("creates the task with the node's profile", async () => {
|
|
191
|
+
const runId = await run({ agentId: claudeId, profile: "wp-claude-opus" });
|
|
192
|
+
const step = await waitFor(async () => {
|
|
193
|
+
const steps = await getWorkflowRunStepsByRunId(runId);
|
|
194
|
+
return steps.find((s) => s.nodeId === "work");
|
|
195
|
+
}, "work step");
|
|
196
|
+
const task = await waitFor(() => getTaskByWorkflowRunStepId(step.id), "node task");
|
|
197
|
+
expect(task.profile).toBe("wp-claude-opus");
|
|
198
|
+
expect(task.agentId).toBe(claudeId);
|
|
199
|
+
});
|
|
200
|
+
|
|
201
|
+
test("an interpolated profile that fails the check fails the node", async () => {
|
|
202
|
+
const runId = await run(
|
|
203
|
+
{ agentId: codexId, profile: "{{trigger.profile}}" },
|
|
204
|
+
{ profile: "wp-claude-opus" },
|
|
205
|
+
);
|
|
206
|
+
const failed = await waitFor(async () => {
|
|
207
|
+
const steps = await getWorkflowRunStepsByRunId(runId);
|
|
208
|
+
const step = steps.find((s) => s.nodeId === "work");
|
|
209
|
+
return step?.status === "failed" ? step : null;
|
|
210
|
+
}, "failed step");
|
|
211
|
+
expect(failed.error).toContain('Model profile "wp-claude-opus" fails harness');
|
|
212
|
+
expect(await getTaskByWorkflowRunStepId(failed.id)).toBeFalsy();
|
|
213
|
+
expect((await getWorkflowRun(runId))?.status).toBe("failed");
|
|
214
|
+
});
|
|
215
|
+
});
|
|
216
|
+
|
|
217
|
+
// A workflow update that only moves the workflow to another repo still judges
|
|
218
|
+
// its stored definition: a static profile's credential allowlist now checks
|
|
219
|
+
// against that repo's pool (repo > agent), on both the HTTP and MCP paths.
|
|
220
|
+
describe("workflow repo change", () => {
|
|
221
|
+
let server: Server;
|
|
222
|
+
let baseUrl = "";
|
|
223
|
+
let updateTool: (args: Record<string, unknown>) => Promise<unknown>;
|
|
224
|
+
let repoAgentId = "";
|
|
225
|
+
|
|
226
|
+
beforeAll(async () => {
|
|
227
|
+
server = createServer(async (req, res) => {
|
|
228
|
+
res.setHeader("Content-Type", "application/json");
|
|
229
|
+
const handled = await handleWorkflows(
|
|
230
|
+
req,
|
|
231
|
+
res,
|
|
232
|
+
getPathSegments(req.url || ""),
|
|
233
|
+
parseQueryParams(req.url || ""),
|
|
234
|
+
req.headers["x-agent-id"] as string | undefined,
|
|
235
|
+
);
|
|
236
|
+
if (!handled) {
|
|
237
|
+
res.writeHead(404);
|
|
238
|
+
res.end("{}");
|
|
239
|
+
}
|
|
240
|
+
});
|
|
241
|
+
baseUrl = `http://localhost:${await listenOnFreePort(server)}`;
|
|
242
|
+
|
|
243
|
+
const mcp = new McpServer({ name: "test-workflow-profile", version: "1.0.0" });
|
|
244
|
+
registerUpdateWorkflowTool(mcp);
|
|
245
|
+
const tools = (mcp as unknown as Record<string, unknown>)._registeredTools as Record<
|
|
246
|
+
string,
|
|
247
|
+
{ handler: (args: unknown, extra: unknown) => Promise<unknown> }
|
|
248
|
+
>;
|
|
249
|
+
updateTool = (args) =>
|
|
250
|
+
tools["update-workflow"]!.handler(args, {
|
|
251
|
+
sessionId: "session-test",
|
|
252
|
+
requestInfo: { headers: { "x-agent-id": "agent-test" } },
|
|
253
|
+
});
|
|
254
|
+
|
|
255
|
+
await createModelProfile({
|
|
256
|
+
name: "wp-claude-repo-key",
|
|
257
|
+
harness: "claude",
|
|
258
|
+
model: "opus",
|
|
259
|
+
credentials: { CLAUDE_CODE_OAUTH_TOKEN: ["22222"] },
|
|
260
|
+
});
|
|
261
|
+
repoAgentId = (
|
|
262
|
+
await createAgent({
|
|
263
|
+
name: "wp-claude-repo",
|
|
264
|
+
isLead: false,
|
|
265
|
+
status: "idle",
|
|
266
|
+
harnessProvider: "claude",
|
|
267
|
+
})
|
|
268
|
+
).id;
|
|
269
|
+
await updateAgentCredStatus(repoAgentId, READY);
|
|
270
|
+
const secret = { isSecret: true, exportToEnv: true, key: "CLAUDE_CODE_OAUTH_TOKEN" };
|
|
271
|
+
await upsertSwarmConfig({
|
|
272
|
+
...secret,
|
|
273
|
+
scope: "agent",
|
|
274
|
+
scopeId: repoAgentId,
|
|
275
|
+
value: "sk-ant-oat01-secret-material-bbbbbbbb-22222",
|
|
276
|
+
});
|
|
277
|
+
const repo = await createSwarmRepo({
|
|
278
|
+
url: "https://github.com/acme/wp-widgets",
|
|
279
|
+
name: "wp-widgets",
|
|
280
|
+
});
|
|
281
|
+
await upsertSwarmConfig({
|
|
282
|
+
...secret,
|
|
283
|
+
scope: "repo",
|
|
284
|
+
scopeId: repo.id,
|
|
285
|
+
value: "sk-ant-oat01-secret-material-aaaaaaaa-11111",
|
|
286
|
+
});
|
|
287
|
+
});
|
|
288
|
+
|
|
289
|
+
afterAll(async () => {
|
|
290
|
+
await new Promise<void>((resolve) => server.close(() => resolve()));
|
|
291
|
+
});
|
|
292
|
+
|
|
293
|
+
async function profiledWorkflow() {
|
|
294
|
+
counter++;
|
|
295
|
+
const definition = agentTaskDef({ agentId: repoAgentId, profile: "wp-claude-repo-key" });
|
|
296
|
+
expect(await workflowModelErrors(definition)).toEqual([]);
|
|
297
|
+
return await createWorkflow({ name: `workflow-profile-repo-${counter}`, definition });
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
test("PUT /api/workflows/{id} with only vcsRepo re-judges the stored definition", async () => {
|
|
301
|
+
const workflow = await profiledWorkflow();
|
|
302
|
+
const put = (body: unknown) =>
|
|
303
|
+
fetch(`${baseUrl}/api/workflows/${workflow.id}`, {
|
|
304
|
+
method: "PUT",
|
|
305
|
+
headers: { "Content-Type": "application/json", "X-Agent-ID": crypto.randomUUID() },
|
|
306
|
+
body: JSON.stringify(body),
|
|
307
|
+
});
|
|
308
|
+
|
|
309
|
+
const moved = await put({ vcsRepo: "acme/wp-widgets" });
|
|
310
|
+
expect(moved.status).toBe(400);
|
|
311
|
+
expect(JSON.stringify(await moved.json())).toContain("credential-allowlist");
|
|
312
|
+
expect((await getWorkflow(workflow.id))?.vcsRepo ?? null).toBeNull();
|
|
313
|
+
|
|
314
|
+
// Control: an update that leaves the repo alone does not re-judge.
|
|
315
|
+
const renamed = await put({ description: "still in no repo" });
|
|
316
|
+
expect(renamed.status).toBe(200);
|
|
317
|
+
});
|
|
318
|
+
|
|
319
|
+
test("update-workflow with only vcsRepo re-judges the stored definition", async () => {
|
|
320
|
+
const workflow = await profiledWorkflow();
|
|
321
|
+
const result = (await updateTool({ id: workflow.id, vcsRepo: "acme/wp-widgets" })) as {
|
|
322
|
+
structuredContent?: { success: boolean; message: string };
|
|
323
|
+
};
|
|
324
|
+
expect(result.structuredContent?.success).toBe(false);
|
|
325
|
+
expect(result.structuredContent?.message).toContain("credential-allowlist");
|
|
326
|
+
expect((await getWorkflow(workflow.id))?.vcsRepo ?? null).toBeNull();
|
|
327
|
+
});
|
|
328
|
+
});
|
package/src/tools/app-upsert.ts
CHANGED
|
@@ -24,7 +24,7 @@ export const registerAppUpsertTool = (server: McpServer) => {
|
|
|
24
24
|
{
|
|
25
25
|
title: "Create or update an app",
|
|
26
26
|
description:
|
|
27
|
-
"Stores a schema-backed app definition with models, queries/actions, pages, reusable elements, optional userConfig fields,
|
|
27
|
+
"Stores a schema-backed app definition with models, queries/actions, pages, reusable elements, optional userConfig fields, an optional top-level theme (a dashboard preset slug for the app's canvas: hive (stock; omit to inherit the viewer's theme), meadow, iris, rose, cobalt, ember, carbon, paper (the warm editorial paper look), plus the classic presets github, vscode, material, solarized, tokyo, monokai, gruvbox, catppuccin; viewers can override it per-user; unknown slugs degrade to the viewer's dashboard theme), and an optional top-level icon ({ type: \"lucide\", icon: \"<kebab-case lucide icon name>\", color?: \"#RRGGBB\" }) shown as the app's icon on the dashboard Apps page (omit it, or use an unrecognized name, for a generic default), then returns its dashboard URL. userConfig is versioned schema only; each user's values are stored separately, survive rollback, and schema changes are always compatible. Pages may bind a declared field read-only at exactly /user/<field>; pure and bound reusable elements must receive that value through a prop. Elements are private by default: pure elements read declared props, allow $item/$index inside repeats, may expose one leaf ElementSlot, and cannot invoke actions; bound elements may use the defining app's queries/actions, while exported bound elements cannot navigate. Prop kinds include enum with a required non-empty enum values array. Pages or elements reuse them with literal ElementRef targets, and cross-app refs require export: true. Zero-model pure-UI apps are valid. Pass appId to update; breaking a referenced export is blocked by the compatibility gate unless forceElementBreak explicitly names it.",
|
|
28
28
|
annotations: { destructiveHint: false },
|
|
29
29
|
inputSchema: z.object({
|
|
30
30
|
name: z.string().min(1).describe("Human-readable app name."),
|
package/src/tools/memory-edit.ts
CHANGED
|
@@ -2,6 +2,7 @@ import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
|
2
2
|
import * as z from "zod";
|
|
3
3
|
import { getAgentById } from "@/be/db";
|
|
4
4
|
import { getEmbeddingProvider, getMemoryStore } from "@/be/memory";
|
|
5
|
+
import { LEARNING_TTL_DAYS } from "@/be/memory/constants";
|
|
5
6
|
import { assertKeyWritable, MemoryKeyError } from "@/be/memory/key-guard";
|
|
6
7
|
import {
|
|
7
8
|
MEMORY_KEY_MAX_LENGTH,
|
|
@@ -83,7 +84,7 @@ export const registerMemoryEditTool = (server: McpServer) => {
|
|
|
83
84
|
.regex(MEMORY_KEY_PATTERN, MEMORY_KEY_PATTERN_MESSAGE)
|
|
84
85
|
.optional()
|
|
85
86
|
.describe(
|
|
86
|
-
|
|
87
|
+
`Move the memory to this logical path, for example '/longterm/facts/swarm-runtime/slug'. Alone it is a pure move: omit content/oldString/newString. Fails when the key is already used in this scope by the same owner. Moving into /longterm marks the memory as curated on every chunk: it stops expiring and is protected from cleanup, and moving it out later does not bring the expiry back. A move into /learnings starts a ${LEARNING_TTL_DAYS}-day expiry; a move out of /learnings takes the source's own expiry (none for manual). A key under /longterm must start with /longterm/company-story, /longterm/entities/people, /longterm/entities/customers, /longterm/facts, /longterm/decisions, /longterm/workstreams or /longterm/timeline. Paths under /longterm/company-story, /longterm/entities and /longterm/timeline are lead-only.`,
|
|
87
88
|
),
|
|
88
89
|
}),
|
|
89
90
|
outputSchema: swarmToolOutputSchema({
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
2
|
+
import * as z from "zod";
|
|
3
|
+
import { getAgentById } from "@/be/db";
|
|
4
|
+
import { checkProfileForAgent } from "@/be/model-profile-check";
|
|
5
|
+
import { createToolRegistrar, swarmToolOutputSchema, toolErr, toolOk } from "@/tools/utils";
|
|
6
|
+
|
|
7
|
+
export const registerCheckModelProfileTool = (server: McpServer) => {
|
|
8
|
+
createToolRegistrar(server)(
|
|
9
|
+
"check-model-profile",
|
|
10
|
+
{
|
|
11
|
+
title: "Check Model Profile",
|
|
12
|
+
description:
|
|
13
|
+
"Check whether an agent can run a model profile before you pass it as `profile` or set it as the agent's default. Judges the harness, the model, the agent's credential report and the profile's credential allowlist. Each row is pass, warn, fail or unverified; only a fail blocks.",
|
|
14
|
+
annotations: { readOnlyHint: true },
|
|
15
|
+
inputSchema: z.object({
|
|
16
|
+
agentId: z.string().min(1).describe("The agent that would run the profile."),
|
|
17
|
+
profile: z.string().min(1).describe("Model profile name (see list-model-profiles)."),
|
|
18
|
+
}),
|
|
19
|
+
outputSchema: swarmToolOutputSchema({
|
|
20
|
+
result: z
|
|
21
|
+
.looseObject({
|
|
22
|
+
agentId: z.string().optional(),
|
|
23
|
+
ok: z.boolean().optional(),
|
|
24
|
+
profiles: z
|
|
25
|
+
.array(
|
|
26
|
+
z.looseObject({
|
|
27
|
+
name: z.string().optional(),
|
|
28
|
+
ok: z.boolean().optional(),
|
|
29
|
+
checks: z
|
|
30
|
+
.array(
|
|
31
|
+
z.looseObject({
|
|
32
|
+
check: z.string().optional(),
|
|
33
|
+
state: z.string().optional(),
|
|
34
|
+
detail: z.string().optional(),
|
|
35
|
+
}),
|
|
36
|
+
)
|
|
37
|
+
.optional(),
|
|
38
|
+
}),
|
|
39
|
+
)
|
|
40
|
+
.optional(),
|
|
41
|
+
})
|
|
42
|
+
.optional(),
|
|
43
|
+
}),
|
|
44
|
+
},
|
|
45
|
+
async ({ agentId, profile }) => {
|
|
46
|
+
if (!(await getAgentById(agentId))) return toolErr(`Agent ${agentId} not found.`);
|
|
47
|
+
const result = await checkProfileForAgent(agentId, profile);
|
|
48
|
+
if (!result) {
|
|
49
|
+
return toolErr(
|
|
50
|
+
`Unknown model profile "${profile}". List profiles with list-model-profiles.`,
|
|
51
|
+
);
|
|
52
|
+
}
|
|
53
|
+
const primary = result.profiles[0];
|
|
54
|
+
const lines = (primary?.checks ?? []).map(
|
|
55
|
+
(row) => `${row.check}: ${row.state}${row.detail ? ` (${row.detail})` : ""}`,
|
|
56
|
+
);
|
|
57
|
+
return toolOk(
|
|
58
|
+
`Agent ${agentId} ${result.ok ? "can" : "cannot"} run model profile "${profile}".`,
|
|
59
|
+
{ details: lines.join("\n"), data: { result } },
|
|
60
|
+
);
|
|
61
|
+
},
|
|
62
|
+
);
|
|
63
|
+
};
|