@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
package/src/tools/utils.ts
CHANGED
|
@@ -26,6 +26,7 @@ import { withSpan } from "../otel";
|
|
|
26
26
|
import { COLOR_LITERAL_THRESHOLD } from "../pages/color-literals";
|
|
27
27
|
import type { PermissionVerb } from "../rbac/permissions";
|
|
28
28
|
import { SCRIPT_LONG_TIMEOUT_HINT_MS } from "../scripts-runtime/executors/types";
|
|
29
|
+
import { DEFAULT_MODEL_TIER_MAP, type ModelTier, type ProviderName } from "../types";
|
|
29
30
|
import { scrubObject, scrubSecrets } from "../utils/secret-scrubber";
|
|
30
31
|
|
|
31
32
|
type Meta = RequestHandlerExtra<ServerRequest, ServerNotification>;
|
|
@@ -299,14 +300,30 @@ const storeProgressBlockedWaitingNudge = (r: SwarmToolResult): string | undefine
|
|
|
299
300
|
return `That reads as blocked-waiting, ${formatIdleDuration(ms)} since your last update — keep working if you can, and if the wait is genuinely long, defer-task is one way to resume later instead of polling.`;
|
|
300
301
|
};
|
|
301
302
|
|
|
303
|
+
/** One steer per noise-floor rule (src/be/memory/task-learning.ts), each naming the fix. */
|
|
304
|
+
const LEARNING_NOISE_FLOOR_NUDGES: Record<string, string> = {
|
|
305
|
+
"too-short":
|
|
306
|
+
'That learning was too short to hold a lesson; resend it as a title line, then the rule as "When X, do Y", or drop it if it is only status.',
|
|
307
|
+
"repeats-progress":
|
|
308
|
+
'That learning restates this call\'s progress or output; resend only the rule the next agent should follow ("When X, do Y"), or drop it.',
|
|
309
|
+
};
|
|
310
|
+
|
|
302
311
|
const storeProgressNudge = (r: SwarmToolResult): string | undefined => {
|
|
303
|
-
const learning = (
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
312
|
+
const learning = (
|
|
313
|
+
r.data as
|
|
314
|
+
| { learning?: { status?: unknown; memoryId?: unknown; noiseFloor?: unknown } }
|
|
315
|
+
| undefined
|
|
316
|
+
)?.learning;
|
|
317
|
+
// nudgeMiddleware permits exactly one steer: the learning steers name a
|
|
318
|
+
// concrete fix, so they win over the blocked-waiting reminder, duplicate first.
|
|
307
319
|
if (r.ok && learning?.status === "duplicate" && typeof learning.memoryId === "string") {
|
|
308
320
|
return `That learning repeats memory ${learning.memoryId}; if your text adds something, memory-edit that memory instead of storing a new one.`;
|
|
309
321
|
}
|
|
322
|
+
const noiseSteer =
|
|
323
|
+
r.ok && learning?.status === "failed" && typeof learning.noiseFloor === "string"
|
|
324
|
+
? LEARNING_NOISE_FLOOR_NUDGES[learning.noiseFloor]
|
|
325
|
+
: undefined;
|
|
326
|
+
if (noiseSteer) return noiseSteer;
|
|
310
327
|
return storeProgressBlockedWaitingNudge(r);
|
|
311
328
|
};
|
|
312
329
|
|
|
@@ -316,6 +333,41 @@ const workflowLongScriptTimeoutNudge = (r: SwarmToolResult): string | undefined
|
|
|
316
333
|
return hint ? WORKFLOW_LONG_SCRIPT_TIMEOUT_NUDGE : undefined;
|
|
317
334
|
};
|
|
318
335
|
|
|
336
|
+
/** Result extra for a tool that received `modelTier` (runbooks/model-tiers.md § Model profiles). */
|
|
337
|
+
export type ModelTierDeprecated = { tier: ModelTier; suggestedProfile: string | null };
|
|
338
|
+
|
|
339
|
+
export const modelTierDeprecatedOutputSchema = z.looseObject({
|
|
340
|
+
tier: z.string().optional(),
|
|
341
|
+
suggestedProfile: z.string().nullable().optional(),
|
|
342
|
+
});
|
|
343
|
+
|
|
344
|
+
/**
|
|
345
|
+
* `modelTier` is an alias for the seeded `<harness>-<tier>` profile. The
|
|
346
|
+
* suggestion is null when the harness is unknown (a pool task) or has no seed
|
|
347
|
+
* for the tier (acp).
|
|
348
|
+
*/
|
|
349
|
+
export function modelTierDeprecation(
|
|
350
|
+
tier: ModelTier | null | undefined,
|
|
351
|
+
harness: ProviderName | null | undefined,
|
|
352
|
+
): ModelTierDeprecated | undefined {
|
|
353
|
+
if (!tier) return undefined;
|
|
354
|
+
const seeded = harness ? Boolean(DEFAULT_MODEL_TIER_MAP[harness]?.[tier]) : false;
|
|
355
|
+
return { tier, suggestedProfile: seeded ? `${harness}-${tier}` : null };
|
|
356
|
+
}
|
|
357
|
+
|
|
358
|
+
const modelTierDeprecatedNudge = (r: SwarmToolResult): string | undefined => {
|
|
359
|
+
if (!r.ok) return undefined;
|
|
360
|
+
const note = (
|
|
361
|
+
r.data as { modelTierDeprecated?: { tier?: unknown; suggestedProfile?: unknown } } | undefined
|
|
362
|
+
)?.modelTierDeprecated;
|
|
363
|
+
if (!note) return undefined;
|
|
364
|
+
const profile =
|
|
365
|
+
typeof note.suggestedProfile === "string"
|
|
366
|
+
? note.suggestedProfile
|
|
367
|
+
: `<harness>-${String(note.tier)}`;
|
|
368
|
+
return `modelTier is deprecated: pass profile "${profile}" (same model).`;
|
|
369
|
+
};
|
|
370
|
+
|
|
319
371
|
/**
|
|
320
372
|
* One call can fall into more than one create_page trap, and a result carries
|
|
321
373
|
* one nudge, so this entry joins one sentence per trap that applies: a
|
|
@@ -365,6 +417,11 @@ export const NUDGES: Record<string, (result: SwarmToolResult) => string | undefi
|
|
|
365
417
|
"patch-workflow": workflowLongScriptTimeoutNudge,
|
|
366
418
|
"patch-workflow-node": workflowLongScriptTimeoutNudge,
|
|
367
419
|
"slack-download-file": slackDownloadFileNudge,
|
|
420
|
+
"send-task": modelTierDeprecatedNudge,
|
|
421
|
+
"task-action": modelTierDeprecatedNudge,
|
|
422
|
+
"create-schedule": modelTierDeprecatedNudge,
|
|
423
|
+
"update-schedule": modelTierDeprecatedNudge,
|
|
424
|
+
"patch-schedule": modelTierDeprecatedNudge,
|
|
368
425
|
"slack-read": slackReadNudge,
|
|
369
426
|
create_page: createPageNudge,
|
|
370
427
|
"script-search": (r) => {
|
|
@@ -135,7 +135,7 @@ export const registerCreateWorkflowTool = (server: McpServer) => {
|
|
|
135
135
|
if (!validation.valid) {
|
|
136
136
|
return toolErr(`Invalid definition: ${validation.errors.join("; ")}`);
|
|
137
137
|
}
|
|
138
|
-
const modelErrors = await workflowModelErrors(definition);
|
|
138
|
+
const modelErrors = await workflowModelErrors(definition, { vcsRepo });
|
|
139
139
|
if (modelErrors.length > 0) {
|
|
140
140
|
return toolErr(`Invalid definition: ${modelErrors.join("; ")}`);
|
|
141
141
|
}
|
|
@@ -11,7 +11,7 @@ export const registerRetryWorkflowRunTool = (server: McpServer) => {
|
|
|
11
11
|
title: "Retry Workflow Run",
|
|
12
12
|
annotations: { destructiveHint: false },
|
|
13
13
|
description:
|
|
14
|
-
"Resume the same failed workflow run from its failed step(s); completed steps are not re-run. Retrying re-creates the failed node's side effects (e.g. an agent task), so check the target state first if that work was already done manually.",
|
|
14
|
+
"Resume the same failed workflow run from its failed step(s); completed steps are not re-run. Retrying re-creates the failed node's side effects (e.g. an agent task), so check the target state first if that work was already done manually. Retries on the definition the run started with; to use an edited workflow, trigger a new run.",
|
|
15
15
|
inputSchema: z.object({
|
|
16
16
|
runId: z.string().uuid().describe("Workflow run ID to retry"),
|
|
17
17
|
}),
|
|
@@ -122,7 +122,16 @@ export const registerUpdateWorkflowTool = (server: McpServer) => {
|
|
|
122
122
|
if (!validation.valid) {
|
|
123
123
|
return toolErr(`Invalid definition: ${validation.errors.join("; ")}`);
|
|
124
124
|
}
|
|
125
|
-
|
|
125
|
+
}
|
|
126
|
+
// A stored definition moving to another repo is judged again: its
|
|
127
|
+
// static profiles now check against that repo's credential pool.
|
|
128
|
+
const repoChanged =
|
|
129
|
+
vcsRepo !== undefined && (vcsRepo ?? null) !== (existing.vcsRepo ?? null);
|
|
130
|
+
const judged = definition ?? (repoChanged ? existing.definition : undefined);
|
|
131
|
+
if (judged) {
|
|
132
|
+
const modelErrors = await workflowModelErrors(judged, {
|
|
133
|
+
vcsRepo: vcsRepo === undefined ? existing.vcsRepo : vcsRepo,
|
|
134
|
+
});
|
|
126
135
|
if (modelErrors.length > 0) {
|
|
127
136
|
return toolErr(`Invalid definition: ${modelErrors.join("; ")}`);
|
|
128
137
|
}
|
package/src/types.ts
CHANGED
|
@@ -466,6 +466,16 @@ export const ModelProfileNameSchema = z
|
|
|
466
466
|
.trim()
|
|
467
467
|
.regex(/^[a-z0-9][a-z0-9._-]{0,99}$/, "lowercase letters, digits, '.', '_' or '-', max 100");
|
|
468
468
|
|
|
469
|
+
/**
|
|
470
|
+
* The pooled keys a profile may use, per credential var: the last 5
|
|
471
|
+
* characters of each allowed key. A var with no entry keeps its whole pool.
|
|
472
|
+
*/
|
|
473
|
+
export const ModelProfileCredentialsSchema = z.record(
|
|
474
|
+
z.string(),
|
|
475
|
+
z.array(z.string().length(5)).min(1),
|
|
476
|
+
);
|
|
477
|
+
export type ModelProfileCredentials = z.infer<typeof ModelProfileCredentialsSchema>;
|
|
478
|
+
|
|
469
479
|
export const ModelProfileSchema = z.object({
|
|
470
480
|
id: z.string(),
|
|
471
481
|
name: z.string(),
|
|
@@ -476,11 +486,44 @@ export const ModelProfileSchema = z.object({
|
|
|
476
486
|
description: z.string().nullable(),
|
|
477
487
|
/** `tier:<tier>` (boot seed), `agent-config` (made from an agent's MODEL_OVERRIDE), or null. */
|
|
478
488
|
seededFrom: z.string().nullable(),
|
|
489
|
+
/** Pooled-key allowlist (column `credentialAllowlist`); null uses the whole pool. */
|
|
490
|
+
credentials: ModelProfileCredentialsSchema.nullable(),
|
|
479
491
|
createdAt: z.string(),
|
|
480
492
|
lastUpdatedAt: z.string(),
|
|
481
493
|
});
|
|
482
494
|
export type ModelProfile = z.infer<typeof ModelProfileSchema>;
|
|
483
495
|
|
|
496
|
+
/** One check's verdict: only `fail` blocks; `unverified` means nothing to judge yet. */
|
|
497
|
+
export const ProfileCheckStateSchema = z.enum(["pass", "warn", "fail", "unverified"]);
|
|
498
|
+
export type ProfileCheckState = z.infer<typeof ProfileCheckStateSchema>;
|
|
499
|
+
|
|
500
|
+
export const ProfileCheckRowSchema = z.object({
|
|
501
|
+
check: z.enum(["harness", "model", "harness-credentials", "credential-allowlist"]),
|
|
502
|
+
state: ProfileCheckStateSchema,
|
|
503
|
+
/** Why, in words. Names vars and key suffixes, never a secret value. */
|
|
504
|
+
detail: z.string().optional(),
|
|
505
|
+
});
|
|
506
|
+
export type ProfileCheckRow = z.infer<typeof ProfileCheckRowSchema>;
|
|
507
|
+
|
|
508
|
+
/**
|
|
509
|
+
* Whether an agent can run a profile. `profiles[0]` is the primary; `ok` is
|
|
510
|
+
* true when it has no `fail` row.
|
|
511
|
+
*/
|
|
512
|
+
export const ProfileCheckResultSchema = z
|
|
513
|
+
.object({
|
|
514
|
+
agentId: z.string(),
|
|
515
|
+
ok: z.boolean(),
|
|
516
|
+
profiles: z.array(
|
|
517
|
+
z.object({
|
|
518
|
+
name: z.string(),
|
|
519
|
+
ok: z.boolean(),
|
|
520
|
+
checks: z.array(ProfileCheckRowSchema),
|
|
521
|
+
}),
|
|
522
|
+
),
|
|
523
|
+
})
|
|
524
|
+
.openapi("ProfileCheckResult");
|
|
525
|
+
export type ProfileCheckResult = z.infer<typeof ProfileCheckResultSchema>;
|
|
526
|
+
|
|
484
527
|
// ============================================================================
|
|
485
528
|
// Session sharing
|
|
486
529
|
// ============================================================================
|
|
@@ -767,7 +810,7 @@ export const AgentTaskSchema = z
|
|
|
767
810
|
|
|
768
811
|
// Model selection (optional — provider-specific; can be "opus", "gpt-4o",
|
|
769
812
|
// "openrouter/openai/gpt-5-nano", etc. depending on HARNESS_PROVIDER).
|
|
770
|
-
// Prefer
|
|
813
|
+
// Prefer `profile` (below) for named intent; model is a concrete override
|
|
771
814
|
// interpreted by the claiming worker's harness and never switches provider.
|
|
772
815
|
model: z.string().optional(),
|
|
773
816
|
modelTier: ModelTierSchema.optional(),
|
|
@@ -1285,6 +1328,14 @@ export const AgentAvatarSchema = z.discriminatedUnion("type", [
|
|
|
1285
1328
|
]);
|
|
1286
1329
|
export type AgentAvatar = z.infer<typeof AgentAvatarSchema>;
|
|
1287
1330
|
|
|
1331
|
+
/**
|
|
1332
|
+
* Apps reuse the same avatar shape as agents (lucide icon + optional hex
|
|
1333
|
+
* color) for their dashboard tile icon. A distinct export name keeps app call
|
|
1334
|
+
* sites self-documenting.
|
|
1335
|
+
*/
|
|
1336
|
+
export const AppIconSchema = AgentAvatarSchema;
|
|
1337
|
+
export type AppIcon = AgentAvatar;
|
|
1338
|
+
|
|
1288
1339
|
// Separate from `avatar` so an agent can keep its lucide disc and still post
|
|
1289
1340
|
// to Slack with its own emoji or image.
|
|
1290
1341
|
export const AgentSlackIconSchema = z
|
|
@@ -1965,6 +2016,8 @@ export const ScheduledTaskSchema = z
|
|
|
1965
2016
|
lastErrorMessage: z.string().optional(),
|
|
1966
2017
|
model: z.string().optional(),
|
|
1967
2018
|
modelTier: ModelTierSchema.optional(),
|
|
2019
|
+
/** Model profile copied onto every fired task; exclusive with model/modelTier. */
|
|
2020
|
+
profile: z.string().optional(),
|
|
1968
2021
|
scheduleType: z.enum(["recurring", "one_time"]).default("recurring"),
|
|
1969
2022
|
targetType: ScheduledTaskTargetTypeSchema.default("agent-task"),
|
|
1970
2023
|
workflowId: z.uuid().optional(),
|
|
@@ -2926,6 +2979,8 @@ export type AgentTaskSummary = Pick<
|
|
|
2926
2979
|
| "modelAlias"
|
|
2927
2980
|
| "effort"
|
|
2928
2981
|
| "resolvedEffort"
|
|
2982
|
+
| "profile"
|
|
2983
|
+
| "resolvedProfile"
|
|
2929
2984
|
| "provider"
|
|
2930
2985
|
| "requestedByUserId"
|
|
2931
2986
|
| "progress"
|
package/src/utils/credentials.ts
CHANGED
|
@@ -231,6 +231,32 @@ export class ModelWindowExhaustedError extends Error {
|
|
|
231
231
|
}
|
|
232
232
|
}
|
|
233
233
|
|
|
234
|
+
/**
|
|
235
|
+
* Thrown by `resolveCredentialPools` when a model profile's credential
|
|
236
|
+
* allowlist names no key of a pool the worker holds. The caller must not
|
|
237
|
+
* spawn the CLI on this error, the same as `ModelWindowExhaustedError`.
|
|
238
|
+
*/
|
|
239
|
+
export class CredentialAllowlistError extends Error {
|
|
240
|
+
readonly profile: string | null;
|
|
241
|
+
readonly keyType: string;
|
|
242
|
+
readonly wanted: string[];
|
|
243
|
+
|
|
244
|
+
constructor(opts: { profile?: string | null; keyType: string; wanted: string[] }) {
|
|
245
|
+
super(
|
|
246
|
+
`credential allowlist for ${opts.profile ?? "this task"} matches no ${opts.keyType} key (wanted ${opts.wanted.join(", ")})`,
|
|
247
|
+
);
|
|
248
|
+
this.name = "CredentialAllowlistError";
|
|
249
|
+
this.profile = opts.profile ?? null;
|
|
250
|
+
this.keyType = opts.keyType;
|
|
251
|
+
this.wanted = opts.wanted;
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
/** The last 5 characters of a credential: the suffix stamped on task records and named by allowlists. */
|
|
256
|
+
export function keySuffix(value: string): string {
|
|
257
|
+
return value.slice(-5);
|
|
258
|
+
}
|
|
259
|
+
|
|
234
260
|
function isJsonObject(value: string): boolean {
|
|
235
261
|
const trimmed = value.trim();
|
|
236
262
|
if (!trimmed.startsWith("{") || !trimmed.endsWith("}")) return false;
|
|
@@ -257,10 +283,16 @@ export function splitCredentialPool(value: string): string[] {
|
|
|
257
283
|
.filter(Boolean);
|
|
258
284
|
}
|
|
259
285
|
|
|
286
|
+
/**
|
|
287
|
+
* `allowedIndices` (a profile's credential allowlist, as pool positions)
|
|
288
|
+
* bounds every pick, including the "all rate-limited, pick anyway" fallbacks.
|
|
289
|
+
* Indices stay positions in the full pool.
|
|
290
|
+
*/
|
|
260
291
|
export function selectCredential(
|
|
261
292
|
value: string,
|
|
262
293
|
availableIndices?: number[],
|
|
263
294
|
keyType = "ANTHROPIC_API_KEY",
|
|
295
|
+
allowedIndices?: number[],
|
|
264
296
|
): CredentialSelection {
|
|
265
297
|
// A CODEX_OAUTH value is one JSON blob ({access, refresh, expires, accountId}),
|
|
266
298
|
// never a comma-separated pool: its commas are field separators. Splitting it
|
|
@@ -275,31 +307,43 @@ export function selectCredential(
|
|
|
275
307
|
selected,
|
|
276
308
|
index: 0,
|
|
277
309
|
total: 1,
|
|
278
|
-
keySuffix: selected
|
|
310
|
+
keySuffix: keySuffix(selected),
|
|
279
311
|
keyType,
|
|
280
312
|
isRateLimitFallback,
|
|
281
313
|
};
|
|
282
314
|
}
|
|
283
315
|
|
|
316
|
+
// Every random draw comes from the allowlist when one is given, never the
|
|
317
|
+
// full pool. An empty list is ignored here: `resolveCredentialPools` throws
|
|
318
|
+
// `CredentialAllowlistError` before it gets this far.
|
|
319
|
+
const allowed = allowedIndices?.filter((i) => i >= 0 && i < credentials.length);
|
|
320
|
+
const drawFrom = allowed && allowed.length > 0 ? allowed : undefined;
|
|
321
|
+
const pickAny = () =>
|
|
322
|
+
drawFrom
|
|
323
|
+
? drawFrom[Math.floor(Math.random() * drawFrom.length)]!
|
|
324
|
+
: Math.floor(Math.random() * credentials.length);
|
|
325
|
+
|
|
284
326
|
let index: number;
|
|
285
327
|
let isRateLimitFallback = false;
|
|
286
328
|
if (availableIndices && availableIndices.length > 0) {
|
|
287
329
|
// Pick randomly from available (non-rate-limited) indices
|
|
288
|
-
const validIndices = availableIndices.filter(
|
|
330
|
+
const validIndices = availableIndices.filter(
|
|
331
|
+
(i) => i >= 0 && i < credentials.length && (!drawFrom || drawFrom.includes(i)),
|
|
332
|
+
);
|
|
289
333
|
if (validIndices.length > 0) {
|
|
290
334
|
index = validIndices[Math.floor(Math.random() * validIndices.length)]!;
|
|
291
335
|
} else {
|
|
292
336
|
// All available indices out of range — fall back to random from all
|
|
293
|
-
index =
|
|
337
|
+
index = pickAny();
|
|
294
338
|
isRateLimitFallback = true;
|
|
295
339
|
}
|
|
296
340
|
} else if (availableIndices && availableIndices.length === 0) {
|
|
297
341
|
// All keys are rate-limited — pick randomly anyway (best effort)
|
|
298
|
-
index =
|
|
342
|
+
index = pickAny();
|
|
299
343
|
isRateLimitFallback = true;
|
|
300
344
|
} else {
|
|
301
345
|
// No availability info — pure random (backward compatible)
|
|
302
|
-
index =
|
|
346
|
+
index = pickAny();
|
|
303
347
|
}
|
|
304
348
|
|
|
305
349
|
const selected = credentials[index]!;
|
|
@@ -307,7 +351,7 @@ export function selectCredential(
|
|
|
307
351
|
selected,
|
|
308
352
|
index,
|
|
309
353
|
total: credentials.length,
|
|
310
|
-
keySuffix: selected
|
|
354
|
+
keySuffix: keySuffix(selected),
|
|
311
355
|
keyType,
|
|
312
356
|
isRateLimitFallback,
|
|
313
357
|
};
|
|
@@ -499,6 +543,15 @@ export async function resolveCredentialPools(
|
|
|
499
543
|
* worker can still accept tasks for another model.
|
|
500
544
|
*/
|
|
501
545
|
enforceModelCapacity?: boolean;
|
|
546
|
+
/**
|
|
547
|
+
* The claimed model profile's credential allowlist (`{ VAR: [suffix] }`).
|
|
548
|
+
* A pool var with an entry picks only keys whose last 5 characters are
|
|
549
|
+
* listed, and throws `CredentialAllowlistError` when none match. A var
|
|
550
|
+
* with no entry, or no allowlist at all, keeps the whole pool.
|
|
551
|
+
*/
|
|
552
|
+
allowedKeySuffixes?: Record<string, string[]>;
|
|
553
|
+
/** Profile name for the `CredentialAllowlistError` message. */
|
|
554
|
+
allowlistProfile?: string;
|
|
502
555
|
},
|
|
503
556
|
): Promise<CredentialSelection[]> {
|
|
504
557
|
const providerVars = opts?.provider
|
|
@@ -519,9 +572,30 @@ export async function resolveCredentialPools(
|
|
|
519
572
|
for (const envVar of providerVars) {
|
|
520
573
|
const val = env[envVar];
|
|
521
574
|
if (val) {
|
|
575
|
+
// Allowlist positions in the full pool, so reported key indices are unchanged.
|
|
576
|
+
const wanted = opts?.allowedKeySuffixes?.[envVar];
|
|
577
|
+
let allowedIdx: number[] | undefined;
|
|
578
|
+
if (wanted) {
|
|
579
|
+
allowedIdx = splitCredentialPool(val).flatMap((key, i) =>
|
|
580
|
+
wanted.includes(keySuffix(key)) ? [i] : [],
|
|
581
|
+
);
|
|
582
|
+
if (allowedIdx.length === 0) {
|
|
583
|
+
throw new CredentialAllowlistError({
|
|
584
|
+
profile: opts?.allowlistProfile,
|
|
585
|
+
keyType: envVar,
|
|
586
|
+
wanted,
|
|
587
|
+
});
|
|
588
|
+
}
|
|
589
|
+
}
|
|
590
|
+
const inAllowlist = (i: number) => !allowedIdx || allowedIdx.includes(i);
|
|
591
|
+
|
|
522
592
|
const info = availableIndicesMap?.[envVar];
|
|
523
|
-
let available =
|
|
524
|
-
|
|
593
|
+
let available = allowedIdx
|
|
594
|
+
? info?.availableIndices?.filter(inAllowlist)
|
|
595
|
+
: info?.availableIndices;
|
|
596
|
+
let modelBlockedCount = allowedIdx
|
|
597
|
+
? (info?.modelBlockedIndices?.filter(inAllowlist).length ?? 0)
|
|
598
|
+
: (info?.modelBlockedIndices?.length ?? 0);
|
|
525
599
|
if (available && window && opts?.localBlocks) {
|
|
526
600
|
const beforeCount = available.length;
|
|
527
601
|
available = available.filter((i) => {
|
|
@@ -532,7 +606,7 @@ export async function resolveCredentialPools(
|
|
|
532
606
|
}
|
|
533
607
|
|
|
534
608
|
const seatBlockedIndices = info?.seatBlockedIndices ?? [];
|
|
535
|
-
const seatBlockedCount = seatBlockedIndices.length;
|
|
609
|
+
const seatBlockedCount = seatBlockedIndices.filter(inAllowlist).length;
|
|
536
610
|
let seatFallbackIndices: number[] | undefined;
|
|
537
611
|
|
|
538
612
|
// Every key is key-wide rate-limited, blocked by this model's weekly
|
|
@@ -551,7 +625,7 @@ export async function resolveCredentialPools(
|
|
|
551
625
|
if (seatBlockedCount > 0) {
|
|
552
626
|
seatFallbackIndices = splitCredentialPool(val)
|
|
553
627
|
.map((_, i) => i)
|
|
554
|
-
.filter((i) => !seatBlockedIndices.includes(i));
|
|
628
|
+
.filter((i) => !seatBlockedIndices.includes(i) && inAllowlist(i));
|
|
555
629
|
}
|
|
556
630
|
if (windowExhausted || seatFallbackIndices?.length === 0) {
|
|
557
631
|
throw new ModelWindowExhaustedError({
|
|
@@ -566,8 +640,11 @@ export async function resolveCredentialPools(
|
|
|
566
640
|
}
|
|
567
641
|
|
|
568
642
|
const result = seatFallbackIndices
|
|
569
|
-
? {
|
|
570
|
-
|
|
643
|
+
? {
|
|
644
|
+
...selectCredential(val, seatFallbackIndices, envVar, allowedIdx),
|
|
645
|
+
isRateLimitFallback: true,
|
|
646
|
+
}
|
|
647
|
+
: selectCredential(val, available, envVar, allowedIdx);
|
|
571
648
|
env[envVar] = result.selected;
|
|
572
649
|
const availInfo = available ? ` (${available.length} available of ${result.total})` : "";
|
|
573
650
|
console.log(
|
package/src/workflows/engine.ts
CHANGED
|
@@ -18,6 +18,7 @@ import {
|
|
|
18
18
|
getStepCountForNode,
|
|
19
19
|
getWorkflowRun,
|
|
20
20
|
getWorkflowRunStepsByRunId,
|
|
21
|
+
pinWorkflowDefinition,
|
|
21
22
|
updateWorkflowRun,
|
|
22
23
|
updateWorkflowRunStep,
|
|
23
24
|
} from "../be/db";
|
|
@@ -61,7 +62,8 @@ import { runStepValidation, type ValidationRunResult } from "./validation";
|
|
|
61
62
|
// `process.env`, so a module-level const would permanently ignore DB-saved
|
|
62
63
|
// limits. Functions let a config reload take effect without a restart.
|
|
63
64
|
function maxIterations(): number {
|
|
64
|
-
|
|
65
|
+
const value = Number(process.env.WORKFLOW_MAX_ITERATIONS);
|
|
66
|
+
return Number.isInteger(value) && value > 0 ? value : 100;
|
|
65
67
|
}
|
|
66
68
|
|
|
67
69
|
export interface WorkflowExecutionOptions {
|
|
@@ -131,6 +133,9 @@ export async function startWorkflowExecution(
|
|
|
131
133
|
registry: ExecutorRegistry,
|
|
132
134
|
options: WorkflowExecutionOptions = {},
|
|
133
135
|
): Promise<string> {
|
|
136
|
+
// The run pins the definition exactly as the caller read it, before token
|
|
137
|
+
// rendering: resume paths read the pin back raw, as they read the live row.
|
|
138
|
+
const pinSource = workflow;
|
|
134
139
|
const preflight = preflightAutomation(
|
|
135
140
|
workflowPreflightInput(workflow),
|
|
136
141
|
await getAutomationSetupStates(),
|
|
@@ -198,6 +203,7 @@ export async function startWorkflowExecution(
|
|
|
198
203
|
options,
|
|
199
204
|
initial,
|
|
200
205
|
newRunId,
|
|
206
|
+
pinSource,
|
|
201
207
|
);
|
|
202
208
|
if (!created) return runId;
|
|
203
209
|
if (initial.status === "failed" && initial.preflight) {
|
|
@@ -317,6 +323,7 @@ async function createRunWithInitialState(
|
|
|
317
323
|
options: WorkflowExecutionOptions,
|
|
318
324
|
initial: InitialRunState,
|
|
319
325
|
runId: string,
|
|
326
|
+
pinSource: Workflow,
|
|
320
327
|
): Promise<{
|
|
321
328
|
runId: string;
|
|
322
329
|
created: boolean;
|
|
@@ -343,6 +350,7 @@ async function createRunWithInitialState(
|
|
|
343
350
|
(await shouldSkipCooldown(workflow.id, workflow.cooldown))
|
|
344
351
|
? { status: "skipped", error: "cooldown", finishedAt: new Date().toISOString() }
|
|
345
352
|
: initial;
|
|
353
|
+
const definitionHash = await pinWorkflowDefinition(pinSource);
|
|
346
354
|
await createWorkflowRun({
|
|
347
355
|
id: runId,
|
|
348
356
|
workflowId: workflow.id,
|
|
@@ -352,6 +360,7 @@ async function createRunWithInitialState(
|
|
|
352
360
|
parentStepId,
|
|
353
361
|
parentStepAttempt: parentStepId ? attempt : undefined,
|
|
354
362
|
triggeredByAgentId: options.triggeredByAgentId,
|
|
363
|
+
definitionHash,
|
|
355
364
|
});
|
|
356
365
|
await updateWorkflowRun(
|
|
357
366
|
runId,
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
|
+
import { modelProfileRefError, taskProfileError } from "../../be/db/model-profiles";
|
|
2
3
|
import { explicitModelErrorForAgent } from "../../be/model-validation";
|
|
3
4
|
import { applyPreTaskCreate } from "../../extensions/apply-task-create";
|
|
4
5
|
import { workflowContextKey } from "../../tasks/context-key";
|
|
@@ -33,6 +34,8 @@ export const AgentTaskConfigSchema = z.object({
|
|
|
33
34
|
/** Accept a `model` the catalog does not list (a custom id). Without it an unknown id fails the node. */
|
|
34
35
|
allowCustomModel: z.boolean().optional(),
|
|
35
36
|
effort: ReasoningEffortSchema.optional(),
|
|
37
|
+
/** Model profile name (see list-model-profiles). Exclusive with model/modelTier; checked against `agentId` at run. */
|
|
38
|
+
profile: z.string().min(1).optional(),
|
|
36
39
|
parentTaskId: z.string().uuid().optional(),
|
|
37
40
|
requestedByUserId: z.string().optional(),
|
|
38
41
|
outputSchema: z.record(z.string(), z.unknown()).optional(),
|
|
@@ -91,7 +94,7 @@ export class AgentTaskExecutor extends BaseExecutor<
|
|
|
91
94
|
let effectiveVcsRepo = config.vcsRepo;
|
|
92
95
|
let effectiveKey: string | undefined;
|
|
93
96
|
if (meta.workflowId) {
|
|
94
|
-
const workflow = await db.
|
|
97
|
+
const workflow = await db.getRunWorkflow({ id: meta.runId, workflowId: meta.workflowId });
|
|
95
98
|
if (workflow) {
|
|
96
99
|
if (!effectiveDir && workflow.dir) effectiveDir = workflow.dir;
|
|
97
100
|
if (!effectiveVcsRepo && workflow.vcsRepo) effectiveVcsRepo = workflow.vcsRepo;
|
|
@@ -106,6 +109,14 @@ export class AgentTaskExecutor extends BaseExecutor<
|
|
|
106
109
|
agentId: config.agentId,
|
|
107
110
|
});
|
|
108
111
|
if (modelError) return { status: "failed", error: modelError };
|
|
112
|
+
const profileError = await taskProfileError({
|
|
113
|
+
profile: config.profile,
|
|
114
|
+
model: config.model,
|
|
115
|
+
modelTier: config.modelTier,
|
|
116
|
+
agentId: config.agentId,
|
|
117
|
+
vcsRepo: effectiveVcsRepo,
|
|
118
|
+
});
|
|
119
|
+
if (profileError) return { status: "failed", error: profileError };
|
|
109
120
|
const preCreate = await applyPreTaskCreate({
|
|
110
121
|
description: config.template,
|
|
111
122
|
options: {
|
|
@@ -129,6 +140,7 @@ export class AgentTaskExecutor extends BaseExecutor<
|
|
|
129
140
|
vcsRepo: effectiveVcsRepo,
|
|
130
141
|
...splitLegacyModelAlias({ model: config.model, modelTier: config.modelTier }),
|
|
131
142
|
effort: config.effort,
|
|
143
|
+
profile: config.profile?.trim() || undefined,
|
|
132
144
|
parentTaskId: config.parentTaskId,
|
|
133
145
|
requestedByUserId: config.requestedByUserId ?? meta.requestedByUserId,
|
|
134
146
|
outputSchema: config.outputSchema,
|
|
@@ -146,7 +158,14 @@ export class AgentTaskExecutor extends BaseExecutor<
|
|
|
146
158
|
// block handed each child its siblings' task ids, and one child completed
|
|
147
159
|
// a sibling's task with its own report. It would also wire parentTaskId to
|
|
148
160
|
// a concurrent same-agent sibling's session.
|
|
149
|
-
|
|
161
|
+
let task: Awaited<ReturnType<typeof db.createTaskExtended>>;
|
|
162
|
+
try {
|
|
163
|
+
task = await db.createTaskExtended(preCreate.description, preCreate.options);
|
|
164
|
+
} catch (error) {
|
|
165
|
+
// The profile was deleted between taskProfileError and the insert.
|
|
166
|
+
if (modelProfileRefError(error) !== "missing") throw error;
|
|
167
|
+
return { status: "failed", error: `Unknown model profile "${config.profile}".` };
|
|
168
|
+
}
|
|
150
169
|
|
|
151
170
|
// 4. Return async result — engine will pause the workflow
|
|
152
171
|
return {
|
|
@@ -107,7 +107,10 @@ export class ForeachExecutor extends BaseExecutor<
|
|
|
107
107
|
// before any child is dispatched — but only when there IS a post-join walk: a
|
|
108
108
|
// terminal foreach (no successors) just closes the join and finalizes, so an
|
|
109
109
|
// exact-cap fan-out is allowed there.
|
|
110
|
-
const workflow = await this.deps.db.
|
|
110
|
+
const workflow = await this.deps.db.getRunWorkflow({
|
|
111
|
+
id: meta.runId,
|
|
112
|
+
workflowId: meta.workflowId,
|
|
113
|
+
});
|
|
111
114
|
const hasSuccessors = workflow
|
|
112
115
|
? getSuccessors(workflow.definition, meta.nodeId).length > 0
|
|
113
116
|
: true;
|
|
@@ -1,8 +1,45 @@
|
|
|
1
|
+
import type { App } from "@slack/bolt";
|
|
1
2
|
import { z } from "zod";
|
|
3
|
+
import { isSlackConfigured } from "../../slack/config";
|
|
2
4
|
import type { ExecutorMeta } from "../../types";
|
|
3
5
|
import { scrubSecrets } from "../../utils/secret-scrubber";
|
|
4
6
|
import { BaseExecutor, type ExecutorResult } from "./base";
|
|
5
7
|
|
|
8
|
+
// ─── Slack readiness wait ───────────────────────────────────
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* How long a Slack notify waits for a configured but not yet initialized
|
|
12
|
+
* client. Kept under the default 30s node watchdog (`DEFAULT_NODE_TIMEOUT_MS`)
|
|
13
|
+
* so the step fails with this executor's error rather than a bare timeout.
|
|
14
|
+
*/
|
|
15
|
+
const slackReadyWait = { timeoutMs: 25_000, pollMs: 250 };
|
|
16
|
+
|
|
17
|
+
/** Test seam: shrink the readiness wait. */
|
|
18
|
+
export function _setNotifySlackReadyWaitForTests(opts: {
|
|
19
|
+
timeoutMs?: number;
|
|
20
|
+
pollMs?: number;
|
|
21
|
+
}): void {
|
|
22
|
+
if (opts.timeoutMs !== undefined) slackReadyWait.timeoutMs = opts.timeoutMs;
|
|
23
|
+
if (opts.pollMs !== undefined) slackReadyWait.pollMs = opts.pollMs;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/** Poll for the Slack client until it exists, the wait runs out, or `signal` aborts. */
|
|
27
|
+
async function waitForSlackApp(
|
|
28
|
+
getApp: () => App | null,
|
|
29
|
+
signal: AbortSignal | undefined,
|
|
30
|
+
): Promise<App | null> {
|
|
31
|
+
const deadline = Date.now() + slackReadyWait.timeoutMs;
|
|
32
|
+
while (Date.now() < deadline && !signal?.aborted) {
|
|
33
|
+
await Bun.sleep(Math.min(slackReadyWait.pollMs, Math.max(0, deadline - Date.now())));
|
|
34
|
+
// The deadline may have fired during the sleep. Posting now would land
|
|
35
|
+
// after the engine marked the step failed, and a retry would post again.
|
|
36
|
+
if (signal?.aborted) return null;
|
|
37
|
+
const app = getApp();
|
|
38
|
+
if (app) return app;
|
|
39
|
+
}
|
|
40
|
+
return null;
|
|
41
|
+
}
|
|
42
|
+
|
|
6
43
|
// ─── Schemas ────────────────────────────────────────────────
|
|
7
44
|
|
|
8
45
|
export const NotifyConfigSchema = z.object({
|
|
@@ -31,7 +68,7 @@ export class NotifyExecutor extends BaseExecutor<
|
|
|
31
68
|
protected async execute(
|
|
32
69
|
config: z.infer<typeof NotifyConfigSchema>,
|
|
33
70
|
context: Readonly<Record<string, unknown>>,
|
|
34
|
-
|
|
71
|
+
meta: ExecutorMeta,
|
|
35
72
|
): Promise<ExecutorResult<z.infer<typeof NotifyOutputSchema>>> {
|
|
36
73
|
// Scrub once: the message reaches Slack, the swarm channel, a log line and
|
|
37
74
|
// the step output.
|
|
@@ -62,12 +99,31 @@ export class NotifyExecutor extends BaseExecutor<
|
|
|
62
99
|
}
|
|
63
100
|
case "slack": {
|
|
64
101
|
const { getSlackApp } = await import("../../slack/app");
|
|
65
|
-
|
|
102
|
+
let app = getSlackApp();
|
|
66
103
|
if (!app) {
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
104
|
+
// No Slack on this install: nothing to post to, so not a failure.
|
|
105
|
+
if (!isSlackConfigured()) {
|
|
106
|
+
return {
|
|
107
|
+
status: "success",
|
|
108
|
+
output: { sent: false, message },
|
|
109
|
+
};
|
|
110
|
+
}
|
|
111
|
+
// Slack is configured but its client is not up: the server is still
|
|
112
|
+
// booting, shutting down, or reloading integrations. Reporting
|
|
113
|
+
// success here would drop the message and hide it.
|
|
114
|
+
app = await waitForSlackApp(getSlackApp, meta.signal);
|
|
115
|
+
if (meta.signal?.aborted) {
|
|
116
|
+
return {
|
|
117
|
+
status: "failed",
|
|
118
|
+
error: "Step deadline reached while waiting for the Slack client; message not sent",
|
|
119
|
+
};
|
|
120
|
+
}
|
|
121
|
+
if (!app) {
|
|
122
|
+
return {
|
|
123
|
+
status: "failed",
|
|
124
|
+
error: `Slack is configured but its client was not ready within ${slackReadyWait.timeoutMs}ms; message not sent`,
|
|
125
|
+
};
|
|
126
|
+
}
|
|
71
127
|
}
|
|
72
128
|
try {
|
|
73
129
|
const result = await app.client.chat.postMessage({
|
|
@@ -125,7 +125,7 @@ export class SubWorkflowExecutor extends BaseExecutor<
|
|
|
125
125
|
// The child acts as the parent's principal, never as an `agentId` in
|
|
126
126
|
// `config.inputs`: the parent's author writes those, so a creator-less
|
|
127
127
|
// child would otherwise run as any agent the author names.
|
|
128
|
-
const parent = await db.
|
|
128
|
+
const parent = await db.getRunWorkflow({ id: meta.runId, workflowId: meta.workflowId });
|
|
129
129
|
const triggeredByAgentId =
|
|
130
130
|
parent?.createdByAgentId ?? (await getWorkflowRunTriggeredByAgentId(meta.runId)) ?? undefined;
|
|
131
131
|
|