@desplega.ai/agent-swarm 2.7.10 → 2.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/acp-adapter-t949vbbp.js +15 -0
- package/dist/{actions-b8aqhrsg.js → actions-7e9czc7s.js} +18 -19
- package/dist/{amp-adapter-4c165vgn.js → amp-adapter-gv6cbb7d.js} +2 -3
- package/dist/{app-m9khefrh.js → app-b9fbkp9v.js} +3 -3
- package/dist/{assistant-rh4v3ntz.js → assistant-wjb7v4c7.js} +20 -21
- package/dist/{boot-args-schema-hwkc8bzv.js → boot-args-schema-2t37e0fe.js} +1 -1
- package/dist/{boot-reembed-5y6yw9sj.js → boot-reembed-a35nkyr1.js} +1 -1
- package/dist/{boot-reembed-fdyk55h4.js → boot-reembed-gka3zas7.js} +1 -1
- package/dist/{boot-scrub-sweep-r5r8kqsn.js → boot-scrub-sweep-65sdnp6c.js} +3 -3
- package/dist/{boot-seeds-8f9zt5cm.js → boot-seeds-x42tzytw.js} +4 -5
- package/dist/{claude-adapter-s5df247c.js → claude-adapter-v221b2fd.js} +7 -8
- package/dist/{claude-managed-adapter-h74d06yz.js → claude-managed-adapter-29eq09wd.js} +2 -2
- package/dist/{claude-managed-setup-9gsmwzyx.js → claude-managed-setup-9m6450zk.js} +2 -2
- package/dist/{claude-sdk-session-dq1j4nz9.js → claude-sdk-session-0q0ptaba.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-eqtfgfr6.js → cli-2gxeg5gr.js} +1 -1
- package/dist/{cli-eqk5p56g.js → cli-2wnq8jkz.js} +9 -9
- package/dist/{cli-hfkwwy1h.js → cli-2zp0et3v.js} +21 -2
- package/dist/{cli-rt0ag4x1.js → cli-334z18y3.js} +4 -4
- package/dist/{cli-6m6b4bep.js → cli-3rkdne1h.js} +2 -2
- package/dist/{cli-3xddv0rk.js → cli-4txa0ter.js} +5 -7
- package/dist/{cli-jc1g9ndz.js → cli-5j88qqa8.js} +10 -5
- package/dist/{cli-xfjrc279.js → cli-5mrq3ake.js} +48 -14
- package/dist/{cli-n07eecjs.js → cli-6t09sdhy.js} +3 -3
- package/dist/{cli-38yww4e9.js → cli-6wxjceza.js} +8 -8
- 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-w3bk0dgv.js → cli-8aes17e4.js} +2 -2
- package/dist/{cli-n9abj89w.js → cli-8fknbnhw.js} +8 -8
- package/dist/{cli-xd5ebp64.js → cli-8kzasymh.js} +3 -3
- package/dist/{cli-2tsfpc70.js → cli-a7wvp2km.js} +1 -1
- package/dist/{cli-kx4c8j05.js → cli-abejgen1.js} +63 -19
- package/dist/{cli-36wdfzgn.js → cli-bsywb58a.js} +8 -8
- package/dist/{cli-yz7v0sh4.js → cli-c55z5chy.js} +4 -6
- package/dist/{cli-18qt3few.js → cli-deefvewm.js} +1 -1
- package/dist/{cli-jg24scat.js → cli-ee0b971j.js} +3 -3
- package/dist/cli-f3vq58d2.js +242 -0
- package/dist/{cli-3xcwp3z8.js → cli-ffhtssbp.js} +2 -2
- package/dist/{cli-rjyghzg4.js → cli-g70vxtjh.js} +2 -2
- package/dist/{cli-g1px1g2e.js → cli-gxkx0zzp.js} +1 -1
- package/dist/{cli-j7d73g1y.js → cli-h38x262p.js} +3035 -354
- package/dist/{cli-zjphdj1a.js → cli-j790gp2w.js} +40 -18
- package/dist/{cli-f2zenhja.js → cli-kc7v1nfv.js} +1 -1
- package/dist/{cli-td33w98c.js → cli-m23zjcy2.js} +10 -10
- package/dist/{cli-8ewkreqd.js → cli-m28atx8q.js} +7 -9
- package/dist/{cli-x9exydey.js → cli-m4dqmnbp.js} +1 -1
- package/dist/{cli-ybjdc978.js → cli-mrt48bx7.js} +7 -4
- package/dist/{cli-mr97t7cc.js → cli-p1bq50aa.js} +263 -14
- package/dist/{cli-ttbqe3q4.js → cli-p1w18yhx.js} +1 -1
- package/dist/{cli-nj3x45rw.js → cli-p2gfst4m.js} +52 -43
- package/dist/{cli-z9cs5m0w.js → cli-pasjcnmj.js} +12 -12
- package/dist/{cli-an1knn2k.js → cli-qa4wdgsy.js} +5 -5
- package/dist/{cli-xncjscpm.js → cli-qfedvmcr.js} +50 -24
- package/dist/{cli-tmft5dz2.js → cli-qmqk2yc2.js} +1 -1
- package/dist/{cli-bxz823sz.js → cli-qsnnd04k.js} +1 -1
- package/dist/{cli-cr14kftt.js → cli-qwca7s44.js} +3 -3
- package/dist/{cli-7wz05bx3.js → cli-rfywm85n.js} +460 -737
- package/dist/{cli-v2fwbnsk.js → cli-rmmpt0wm.js} +6 -6
- package/dist/{cli-xbtq4d6s.js → cli-rzsy6nc6.js} +12 -8
- package/dist/{cli-0m7rtm11.js → cli-s7t6p9my.js} +1 -1
- package/dist/{cli-16phend6.js → cli-sdtt3men.js} +1 -1
- 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-h49ejvmc.js → cli-wcg8x116.js} +1 -1
- package/dist/{cli-q581b386.js → cli-wk18cm92.js} +5 -5
- package/dist/{cli-4vwxp550.js → cli-x1wa213s.js} +1 -1
- package/dist/{cli-jrp1dt73.js → cli-xzm9vcfg.js} +1 -1
- package/dist/{cli-eb2azq8n.js → cli-y97qxcfx.js} +9 -9
- package/dist/{cli-55bkx8hh.js → cli-yq3zak69.js} +1 -1
- package/dist/cli.js +17 -17
- package/dist/{codex-adapter-yr60sme6.js → codex-adapter-30j9bpzd.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-8vp57v8w.js} +5 -6
- package/dist/{commands-phjfbkv0.js → commands-bngnz9g7.js} +3 -3
- package/dist/{controller-jkx994pz.js → controller-hxx8wwy1.js} +2 -2
- package/dist/{controllers-connect-c4448kwa.js → controllers-connect-e2b4gyxc.js} +19 -20
- package/dist/{cursor-adapter-ndebqnm8.js → cursor-adapter-n5nc3mfe.js} +1 -2
- package/dist/{db-ez6egt6v.js → db-bgm7vkc0.js} +3 -3
- package/dist/{db-ef32tbfc.js → db-c6np41ca.js} +10 -2
- package/dist/{devin-adapter-z46ep5ph.js → devin-adapter-xedz98zv.js} +1 -1
- package/dist/{dispatcher-g3tt9hs9.js → dispatcher-jnybck15.js} +17 -18
- 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-crsm2zp0.js} +6 -6
- package/dist/{embeddings-6a8v4a6t.js → embeddings-e7z3f27f.js} +1 -1
- package/dist/{execute-3cbg0twf.js → execute-b3mrb1mv.js} +1 -1
- package/dist/{external-channel-se646snz.js → external-channel-m77wf5z3.js} +2 -2
- package/dist/{fx-adapter-yw795hqq.js → fx-adapter-b6w0kf56.js} +7 -8
- package/dist/{grok-adapter-ttmcss2j.js → grok-adapter-4sqtebdk.js} +7 -8
- package/dist/handlers-kdjcyzdj.js +32 -0
- package/dist/heartbeat-xgb036sx.js +43 -0
- package/dist/{hook-g3nhexsy.js → hook-5h02c9ga.js} +6 -6
- package/dist/{hook-hq93y5ej.js → hook-xsk1jbha.js} +5 -5
- package/dist/{http-5a9p4h6y.js → http-txe7qhvn.js} +282 -140
- package/dist/{index-6haqt3v5.js → index-4a0670yh.js} +8917 -8476
- package/dist/index-835xdgnm.js +33 -0
- package/dist/index-d469300x.js +37 -0
- package/dist/index-rzqwp11g.js +32 -0
- package/dist/{index-s72rqgsx.js → index-tvfafeyy.js} +1 -1
- package/dist/{index-hgn3c961.js → index-vk63emp7.js} +978 -35
- package/dist/{index-3c5pxbge.js → index-ysvbhg5m.js} +1 -1
- package/dist/{keepalive-1j4n4dmk.js → keepalive-4zsrce78.js} +3 -3
- package/dist/lead-yqt47dkr.js +70 -0
- package/dist/{maintenance-dmghacy5.js → maintenance-86jvartk.js} +1 -1
- package/dist/{oauth-refresh-sweep-yy06c03c.js → oauth-refresh-sweep-j52kg9pr.js} +2 -2
- package/dist/{onboard-52f9t5dm.js → onboard-c2aj5p8q.js} +3 -3
- package/dist/{opencode-adapter-krnh9jkn.js → opencode-adapter-dsagkhtw.js} +5 -6
- package/dist/{otel-impl-xjqz6wjj.js → otel-impl-yyy203z8.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-1rgzqyzz.js} +2 -3
- package/dist/{rbac-roles-q0gr8eyj.js → rbac-roles-e70xfeyj.js} +4 -6
- package/dist/{rbac-roles-ehv8s10n.js → rbac-roles-q89qe8er.js} +3 -3
- package/dist/{registry-hpjfmcfz.js → registry-32b1mft6.js} +1 -1
- package/dist/{render-v2-5b6chvcq.js → render-v2-k6tt107q.js} +3 -3
- package/dist/{resume-5a5d2845.js → resume-cnnrjfxa.js} +6 -6
- package/dist/{runtime-khxszyfp.js → runtime-1hv06jsn.js} +1 -1
- package/dist/{session-access-gj0bjhqg.js → session-access-xkxkjw3n.js} +4 -4
- package/dist/{session-source-backfill-2sy0krfk.js → session-source-backfill-1d5pdwww.js} +2 -2
- package/dist/{setup-7ssfakk1.js → setup-se8q7gkc.js} +1 -1
- package/dist/{virtual-modules-pjj0knwf.js → virtual-modules-gazyapte.js} +3 -3
- package/dist/{work-objects-bf3syvhq.js → work-objects-1kxnbzy5.js} +20 -21
- package/dist/{worker-follow-up-38xevga6.js → worker-follow-up-zqm8apt4.js} +17 -18
- package/dist/worker-j6xxtq7p.js +70 -0
- package/openapi.json +334 -7
- package/package.json +4 -4
- 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/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/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-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/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 +1 -1
- package/templates/skills/swarm-scripts/content.md +1 -1
- package/templates/skills/work-on-task/SKILL.md +2 -0
- package/templates/skills/work-on-task/content.md +2 -0
- package/templates/workflows/dreaming/content.md +174 -7
- package/dist/acp-adapter-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/http/schedules.ts
CHANGED
|
@@ -16,6 +16,11 @@ import {
|
|
|
16
16
|
updateScheduledTask,
|
|
17
17
|
withFavoriteFlags,
|
|
18
18
|
} from "../be/db";
|
|
19
|
+
import {
|
|
20
|
+
modelProfileRefError,
|
|
21
|
+
scheduleProfileUpdate,
|
|
22
|
+
taskProfileError,
|
|
23
|
+
} from "../be/db/model-profiles";
|
|
19
24
|
import { explicitModelErrorForAgent } from "../be/model-validation";
|
|
20
25
|
import { mergeScheduleTiming, validateRecurringTiming } from "../be/schedules/validate";
|
|
21
26
|
import { getScript } from "../be/scripts/db";
|
|
@@ -52,6 +57,8 @@ const scheduleUpdateBodySchema = z.object({
|
|
|
52
57
|
timezone: z.string().optional(),
|
|
53
58
|
model: z.string().nullable().optional(),
|
|
54
59
|
modelTier: ModelTierSchema.nullable().optional(),
|
|
60
|
+
/** Model profile for every fired task. Exclusive with model/modelTier; setting one clears the other. */
|
|
61
|
+
profile: z.string().nullable().optional(),
|
|
55
62
|
/** Accept a `model` the catalog does not list (a custom id). Without it an unknown id is a 400. */
|
|
56
63
|
allowCustomModel: z.boolean().optional(),
|
|
57
64
|
nextRunAt: z.string().nullable().optional(),
|
|
@@ -113,6 +120,8 @@ const createSchedule = route({
|
|
|
113
120
|
timezone: z.string().optional(),
|
|
114
121
|
model: z.string().optional(),
|
|
115
122
|
modelTier: ModelTierSchema.optional(),
|
|
123
|
+
/** Model profile for every fired task. Exclusive with model/modelTier. */
|
|
124
|
+
profile: z.string().optional(),
|
|
116
125
|
/** Accept a `model` the catalog does not list (a custom id). Without it an unknown id is a 400. */
|
|
117
126
|
allowCustomModel: z.boolean().optional(),
|
|
118
127
|
scheduleType: z.enum(["recurring", "one_time"]).optional(),
|
|
@@ -411,6 +420,16 @@ export async function handleSchedules(
|
|
|
411
420
|
jsonError(res, modelError, 400);
|
|
412
421
|
return true;
|
|
413
422
|
}
|
|
423
|
+
const profileError = await taskProfileError({
|
|
424
|
+
profile: body.profile,
|
|
425
|
+
model: body.model,
|
|
426
|
+
modelTier: body.modelTier,
|
|
427
|
+
agentId: body.targetAgentId,
|
|
428
|
+
});
|
|
429
|
+
if (profileError) {
|
|
430
|
+
jsonError(res, profileError, 400);
|
|
431
|
+
return true;
|
|
432
|
+
}
|
|
414
433
|
|
|
415
434
|
try {
|
|
416
435
|
const trustedUserId = await resolveHttpAuditUserId(req, myAgentId);
|
|
@@ -456,6 +475,7 @@ export async function handleSchedules(
|
|
|
456
475
|
nextRunAt,
|
|
457
476
|
timezone: body.timezone,
|
|
458
477
|
...splitLegacyModelAlias({ model: body.model, modelTier: body.modelTier }),
|
|
478
|
+
profile: body.profile?.trim() || undefined,
|
|
459
479
|
scheduleType: body.scheduleType,
|
|
460
480
|
targetType: body.targetType,
|
|
461
481
|
workflowId: body.workflowId,
|
|
@@ -468,7 +488,12 @@ export async function handleSchedules(
|
|
|
468
488
|
});
|
|
469
489
|
|
|
470
490
|
createSchedule.respond(res, 201, schedule);
|
|
471
|
-
} catch (
|
|
491
|
+
} catch (error) {
|
|
492
|
+
// The profile was deleted between taskProfileError and the insert.
|
|
493
|
+
if (modelProfileRefError(error) === "missing") {
|
|
494
|
+
jsonError(res, `Unknown model profile "${body.profile}".`, 400);
|
|
495
|
+
return true;
|
|
496
|
+
}
|
|
472
497
|
jsonError(res, "Failed to create schedule", 500);
|
|
473
498
|
}
|
|
474
499
|
return true;
|
|
@@ -593,6 +618,11 @@ export async function handleSchedules(
|
|
|
593
618
|
const agentChanged =
|
|
594
619
|
parsed.body.targetAgentId !== undefined &&
|
|
595
620
|
parsed.body.targetAgentId !== existing.targetAgentId;
|
|
621
|
+
const profileUpdate = await scheduleProfileUpdate(existing, parsed.body);
|
|
622
|
+
if (profileUpdate.error !== undefined) {
|
|
623
|
+
jsonError(res, profileUpdate.error, 400);
|
|
624
|
+
return true;
|
|
625
|
+
}
|
|
596
626
|
if (parsed.body.model !== undefined || parsed.body.modelTier !== undefined) {
|
|
597
627
|
const normalizedModel = splitLegacyModelAlias({
|
|
598
628
|
model: parsed.body.model,
|
|
@@ -614,7 +644,7 @@ export async function handleSchedules(
|
|
|
614
644
|
if (parsed.body.modelTier !== undefined || normalizedModel.modelTier) {
|
|
615
645
|
body.modelTier = normalizedModel.modelTier ?? null;
|
|
616
646
|
}
|
|
617
|
-
} else if (agentChanged && existing.model) {
|
|
647
|
+
} else if (agentChanged && existing.model && !profileUpdate.fields.profile) {
|
|
618
648
|
// Harness only: the stored id already passed the catalog check when it was written.
|
|
619
649
|
const modelError = await explicitModelErrorForAgent({
|
|
620
650
|
model: existing.model,
|
|
@@ -626,6 +656,7 @@ export async function handleSchedules(
|
|
|
626
656
|
return true;
|
|
627
657
|
}
|
|
628
658
|
}
|
|
659
|
+
Object.assign(body, profileUpdate.fields);
|
|
629
660
|
|
|
630
661
|
// Reject updates on completed one-time schedules
|
|
631
662
|
if (existing.scheduleType === "one_time" && !existing.enabled && existing.lastRunAt) {
|
|
@@ -750,7 +781,15 @@ export async function handleSchedules(
|
|
|
750
781
|
|
|
751
782
|
const updatedBy = await resolveHttpAuditUserId(req, myAgentId);
|
|
752
783
|
if (updatedBy !== null) body.updatedBy = updatedBy;
|
|
753
|
-
|
|
784
|
+
let schedule: Awaited<ReturnType<typeof updateScheduledTask>>;
|
|
785
|
+
try {
|
|
786
|
+
schedule = await updateScheduledTask(parsed.params.id, body);
|
|
787
|
+
} catch (error) {
|
|
788
|
+
// The profile was deleted between scheduleProfileUpdate and the write.
|
|
789
|
+
if (modelProfileRefError(error) !== "missing") throw error;
|
|
790
|
+
jsonError(res, `Unknown model profile "${body.profile}".`, 400);
|
|
791
|
+
return true;
|
|
792
|
+
}
|
|
754
793
|
routeHandle.respond(res, 200, schedule);
|
|
755
794
|
return true;
|
|
756
795
|
}
|
package/src/http/tasks.ts
CHANGED
|
@@ -39,7 +39,12 @@ import {
|
|
|
39
39
|
updateTaskTitle,
|
|
40
40
|
updateTaskVcs,
|
|
41
41
|
} from "../be/db";
|
|
42
|
-
import {
|
|
42
|
+
import {
|
|
43
|
+
getModelProfileByName,
|
|
44
|
+
hasUnreadableCredentialAllowlist,
|
|
45
|
+
modelProfileRefError,
|
|
46
|
+
taskProfileError,
|
|
47
|
+
} from "../be/db/model-profiles";
|
|
43
48
|
import { explicitModelErrorForAgent } from "../be/model-validation";
|
|
44
49
|
import { getUserGrant } from "../be/rbac-roles";
|
|
45
50
|
import { hasSessionAccess, type SessionAccess } from "../be/session-shares";
|
|
@@ -69,6 +74,7 @@ import {
|
|
|
69
74
|
AgentTaskStatusSchema,
|
|
70
75
|
AssetKeySchema,
|
|
71
76
|
isTerminalTaskStatus,
|
|
77
|
+
ModelProfileCredentialsSchema,
|
|
72
78
|
ModelTierSchema,
|
|
73
79
|
OnUnsupportedSchema,
|
|
74
80
|
ProviderNameSchema,
|
|
@@ -140,6 +146,8 @@ const AgentTaskSummarySchema = AgentTaskSchema.pick({
|
|
|
140
146
|
modelAlias: true,
|
|
141
147
|
effort: true,
|
|
142
148
|
resolvedEffort: true,
|
|
149
|
+
profile: true,
|
|
150
|
+
resolvedProfile: true,
|
|
143
151
|
provider: true,
|
|
144
152
|
requestedByUserId: true,
|
|
145
153
|
progress: true,
|
|
@@ -706,6 +714,9 @@ const listPausedTasks = route({
|
|
|
706
714
|
// Same requester projection a fresh task_assigned trigger carries,
|
|
707
715
|
// so a resumed session gets the same requester-profile prompt.
|
|
708
716
|
requestedBy: TaskRequestedBySchema.optional(),
|
|
717
|
+
// The claimed profile's pooled-key allowlist, read again from the
|
|
718
|
+
// profile, so the recovery spawn picks keys as the claim did.
|
|
719
|
+
credentialAllowlist: ModelProfileCredentialsSchema.optional(),
|
|
709
720
|
}),
|
|
710
721
|
),
|
|
711
722
|
}),
|
|
@@ -1083,16 +1094,6 @@ export async function handleTasks(
|
|
|
1083
1094
|
jsonError(res, modelError, 400);
|
|
1084
1095
|
return true;
|
|
1085
1096
|
}
|
|
1086
|
-
const profileError = await taskProfileError({
|
|
1087
|
-
profile: parsed.body.profile,
|
|
1088
|
-
...splitLegacyModelAlias({ model: parsed.body.model, modelTier: parsed.body.modelTier }),
|
|
1089
|
-
agentId: defaultAgentId,
|
|
1090
|
-
});
|
|
1091
|
-
if (profileError) {
|
|
1092
|
-
jsonError(res, profileError, 400);
|
|
1093
|
-
return true;
|
|
1094
|
-
}
|
|
1095
|
-
|
|
1096
1097
|
const parentTask = parsed.body.parentTaskId
|
|
1097
1098
|
? await getTaskById(parsed.body.parentTaskId)
|
|
1098
1099
|
: null;
|
|
@@ -1127,6 +1128,18 @@ export async function handleTasks(
|
|
|
1127
1128
|
jsonError(res, "You don't have access to the tasks in this context.", 403);
|
|
1128
1129
|
return true;
|
|
1129
1130
|
}
|
|
1131
|
+
// The child inherits the parent's repo in createTaskExtended, and the worker
|
|
1132
|
+
// loads that repo's config, so the profile check judges the same pool.
|
|
1133
|
+
const profileError = await taskProfileError({
|
|
1134
|
+
profile: parsed.body.profile,
|
|
1135
|
+
...splitLegacyModelAlias({ model: parsed.body.model, modelTier: parsed.body.modelTier }),
|
|
1136
|
+
agentId: defaultAgentId,
|
|
1137
|
+
vcsRepo: parentTask?.vcsRepo,
|
|
1138
|
+
});
|
|
1139
|
+
if (profileError) {
|
|
1140
|
+
jsonError(res, profileError, 400);
|
|
1141
|
+
return true;
|
|
1142
|
+
}
|
|
1130
1143
|
let assetKey: string | undefined;
|
|
1131
1144
|
try {
|
|
1132
1145
|
const inheritedKey = parentTask?.key;
|
|
@@ -1930,14 +1943,26 @@ export async function handleTasks(
|
|
|
1930
1943
|
const tasks = await Promise.all(
|
|
1931
1944
|
pausedTasks.map(async (task) => {
|
|
1932
1945
|
const requestedBy = await buildTaskRequestedBy(task);
|
|
1946
|
+
const profile = task.resolvedProfile
|
|
1947
|
+
? await getModelProfileByName(task.resolvedProfile)
|
|
1948
|
+
: null;
|
|
1949
|
+
// Without an allowlist the recovery spawn picks from the whole pool, so
|
|
1950
|
+
// the task stays paused until the profile's credentials are set again.
|
|
1951
|
+
if (profile && hasUnreadableCredentialAllowlist(profile)) {
|
|
1952
|
+
console.warn(
|
|
1953
|
+
`[paused-tasks] holding task ${task.id}: profile "${profile.name}" has an unreadable credential allowlist`,
|
|
1954
|
+
);
|
|
1955
|
+
return null;
|
|
1956
|
+
}
|
|
1933
1957
|
return {
|
|
1934
1958
|
...task,
|
|
1935
1959
|
attachments: await getTaskAttachments(task.id),
|
|
1936
1960
|
...(requestedBy && { requestedBy }),
|
|
1961
|
+
...(profile?.credentials && { credentialAllowlist: profile.credentials }),
|
|
1937
1962
|
};
|
|
1938
1963
|
}),
|
|
1939
1964
|
);
|
|
1940
|
-
listPausedTasks.respond(res, 200, { tasks });
|
|
1965
|
+
listPausedTasks.respond(res, 200, { tasks: tasks.filter((task) => task !== null) });
|
|
1941
1966
|
return true;
|
|
1942
1967
|
}
|
|
1943
1968
|
|
package/src/http/workflows.ts
CHANGED
|
@@ -425,6 +425,8 @@ const retryWorkflowRunRoute = route({
|
|
|
425
425
|
path: "/api/workflow-runs/{id}/retry",
|
|
426
426
|
pattern: ["api", "workflow-runs", null, "retry"],
|
|
427
427
|
summary: "Retry a failed workflow run",
|
|
428
|
+
description:
|
|
429
|
+
"Retries on the definition the run started with; to use an edited workflow, trigger a new run.",
|
|
428
430
|
tags: ["Workflows"],
|
|
429
431
|
params: z.object({ id: z.string() }),
|
|
430
432
|
responses: {
|
|
@@ -675,7 +677,9 @@ export async function handleWorkflows(
|
|
|
675
677
|
jsonError(res, `Invalid definition: ${validation.errors.join("; ")}`, 400);
|
|
676
678
|
return true;
|
|
677
679
|
}
|
|
678
|
-
const modelErrors = await workflowModelErrors(parsed.body.definition
|
|
680
|
+
const modelErrors = await workflowModelErrors(parsed.body.definition, {
|
|
681
|
+
vcsRepo: parsed.body.vcsRepo,
|
|
682
|
+
});
|
|
679
683
|
if (modelErrors.length > 0) {
|
|
680
684
|
jsonError(res, `Invalid definition: ${modelErrors.join("; ")}`, 400);
|
|
681
685
|
return true;
|
|
@@ -881,7 +885,16 @@ export async function handleWorkflows(
|
|
|
881
885
|
jsonError(res, `Invalid definition: ${validation.errors.join("; ")}`, 400);
|
|
882
886
|
return true;
|
|
883
887
|
}
|
|
884
|
-
|
|
888
|
+
}
|
|
889
|
+
// A stored definition moving to another repo is judged again: its static
|
|
890
|
+
// profiles now check against that repo's credential pool.
|
|
891
|
+
const repoChanged =
|
|
892
|
+
body.vcsRepo !== undefined && (body.vcsRepo ?? null) !== (existing.vcsRepo ?? null);
|
|
893
|
+
const judged = body.definition ?? (repoChanged ? existing.definition : undefined);
|
|
894
|
+
if (judged) {
|
|
895
|
+
const modelErrors = await workflowModelErrors(judged, {
|
|
896
|
+
vcsRepo: body.vcsRepo === undefined ? existing.vcsRepo : body.vcsRepo,
|
|
897
|
+
});
|
|
885
898
|
if (modelErrors.length > 0) {
|
|
886
899
|
jsonError(res, `Invalid definition: ${modelErrors.join("; ")}`, 400);
|
|
887
900
|
return true;
|
|
@@ -182,7 +182,7 @@ registerTemplate({
|
|
|
182
182
|
## Memory
|
|
183
183
|
|
|
184
184
|
Memories from past sessions are in your task message. Read them before you start. For a wider search, run the \`task-context-gathering\` script with the task ID and two to four queries.
|
|
185
|
-
|
|
185
|
+
Pass a fix, pattern or gotcha the next agent needs as \`learning\` on a \`store-progress\` call before the task ends: line 1 a title, line 2 the rule ("When X, do Y"), never a status line. Completed task outputs are stored for you.
|
|
186
186
|
You MUST use the \`memory\` skill before you store, edit, or delete a memory.
|
|
187
187
|
`,
|
|
188
188
|
variables: [],
|
|
@@ -161,14 +161,18 @@ function copyEnvKeys(
|
|
|
161
161
|
|
|
162
162
|
function parseStringArray(value: string | undefined): string[] {
|
|
163
163
|
if (!value?.trim()) return [];
|
|
164
|
+
let parsed: unknown;
|
|
164
165
|
try {
|
|
165
|
-
|
|
166
|
-
if (Array.isArray(parsed) && parsed.every((entry) => typeof entry === "string")) {
|
|
167
|
-
return parsed;
|
|
168
|
-
}
|
|
166
|
+
parsed = JSON.parse(value);
|
|
169
167
|
} catch {
|
|
170
168
|
// Accept comma-separated values for hand-authored environment config.
|
|
171
169
|
}
|
|
170
|
+
if (Array.isArray(parsed)) {
|
|
171
|
+
if (!parsed.every((entry) => typeof entry === "string")) {
|
|
172
|
+
throw new AcpTargetResolutionError("ACP_TARGET_ENV_KEYS must be a JSON array of strings.");
|
|
173
|
+
}
|
|
174
|
+
return parsed;
|
|
175
|
+
}
|
|
172
176
|
return value
|
|
173
177
|
.split(",")
|
|
174
178
|
.map((entry) => entry.trim())
|
|
@@ -423,7 +427,7 @@ const copilotTargetProfile: AcpTargetProfile = {
|
|
|
423
427
|
},
|
|
424
428
|
};
|
|
425
429
|
|
|
426
|
-
/** Qwen Code's `--auth-type` choices (0.26.
|
|
430
|
+
/** Qwen Code's `--auth-type` choices (0.26.7). `qwen-oauth` needs a browser, so it is left out. */
|
|
427
431
|
const QWEN_AUTH_TYPES = ["openai", "openai-responses", "anthropic", "gemini", "vertex-ai"] as const;
|
|
428
432
|
|
|
429
433
|
// Qwen Code is a Gemini CLI fork: QWEN_SYSTEM_MD replaces its built-in prompt
|
|
@@ -475,7 +479,8 @@ const qwenTargetProfile: AcpTargetProfile = {
|
|
|
475
479
|
/**
|
|
476
480
|
* Kiro CLI reads its prompt from a Kiro agent config, not from a flag or an
|
|
477
481
|
* env var, so the swarm system prompt is not injected (as with OpenCode).
|
|
478
|
-
* Kiro
|
|
482
|
+
* Kiro advertises no ACP config options (checked on 2.29.1), so the model
|
|
483
|
+
* rides on argv as `--model`, which `kiro-cli acp` still accepts in 3.0.0.
|
|
479
484
|
*/
|
|
480
485
|
const kiroTargetProfile: AcpTargetProfile = {
|
|
481
486
|
target: "kiro",
|
|
@@ -45,7 +45,7 @@ import type {
|
|
|
45
45
|
* default; the image installs exactly this version and the per-task settings
|
|
46
46
|
* set `amp.updates.mode: "disabled"`. Bump it deliberately, with a live run.
|
|
47
47
|
*/
|
|
48
|
-
export const AMP_PACKAGE = "@ampcode/cli@0.0.
|
|
48
|
+
export const AMP_PACKAGE = "@ampcode/cli@0.0.1793804260-g12625e";
|
|
49
49
|
|
|
50
50
|
/** MCP server name. Amp exposes its tools as `agent_swarm` / `store_progress` (dashes become underscores). */
|
|
51
51
|
const AMP_MCP_SERVER_NAME = "agent-swarm";
|
|
@@ -101,12 +101,13 @@ export class ClaudeInputQueue implements AsyncIterable<SDKUserMessage> {
|
|
|
101
101
|
return this.entries.length + this.inFlight;
|
|
102
102
|
}
|
|
103
103
|
|
|
104
|
-
enqueue(text: string): Promise<void> {
|
|
104
|
+
enqueue(text: string, uuid = crypto.randomUUID()): Promise<void> {
|
|
105
105
|
if (this.closed) return Promise.reject(new Error("Claude SDK input is closed"));
|
|
106
106
|
return new Promise((accepted, rejected) => {
|
|
107
107
|
this.entries.push({
|
|
108
108
|
message: {
|
|
109
109
|
type: "user",
|
|
110
|
+
uuid,
|
|
110
111
|
message: { role: "user", content: text },
|
|
111
112
|
parent_tool_use_id: null,
|
|
112
113
|
},
|
|
@@ -323,6 +324,13 @@ class ClaudeSdkSession implements ProviderSession {
|
|
|
323
324
|
private aborted = false;
|
|
324
325
|
private abortReason = "cancelled";
|
|
325
326
|
private acceptingInput = true;
|
|
327
|
+
private deliveryTail: Promise<unknown> = Promise.resolve();
|
|
328
|
+
private pendingDeliveries = 0;
|
|
329
|
+
private turnActive = true;
|
|
330
|
+
private resultWaiters = new Set<() => void>();
|
|
331
|
+
private completionCandidate = false;
|
|
332
|
+
private unansweredInputs = new Set<string>();
|
|
333
|
+
private inputResultIdsSupported = false;
|
|
326
334
|
private errorTracker = new SessionErrorTracker();
|
|
327
335
|
private shutdownPromise: Promise<void> | undefined;
|
|
328
336
|
/** Keeps the session heartbeat fresh while Claude idles on background tasks. */
|
|
@@ -334,7 +342,7 @@ class ClaudeSdkSession implements ProviderSession {
|
|
|
334
342
|
this.contextWindowSize = getContextWindowSize(options.model);
|
|
335
343
|
this.transcript = [`User: ${scrubSecrets(options.config.prompt)}`];
|
|
336
344
|
if (options.queueSteeringSupported) {
|
|
337
|
-
this.deliverSteering = (delivery) => this.
|
|
345
|
+
this.deliverSteering = (delivery) => this.deliverLiveSteering(delivery);
|
|
338
346
|
}
|
|
339
347
|
this.completionPromise = this.run();
|
|
340
348
|
}
|
|
@@ -360,6 +368,9 @@ class ClaudeSdkSession implements ProviderSession {
|
|
|
360
368
|
this.aborted = true;
|
|
361
369
|
this.acceptingInput = false;
|
|
362
370
|
this.abortReason = scrubSecrets(reason ?? "cancelled");
|
|
371
|
+
this.input.close(this.abortReason);
|
|
372
|
+
for (const resolve of this.resultWaiters) resolve();
|
|
373
|
+
this.resultWaiters.clear();
|
|
363
374
|
const interrupt = this.query?.interrupt();
|
|
364
375
|
if (interrupt) {
|
|
365
376
|
await Promise.race([interrupt.catch(() => undefined), Bun.sleep(SDK_INTERRUPT_TIMEOUT_MS)]);
|
|
@@ -369,22 +380,80 @@ class ClaudeSdkSession implements ProviderSession {
|
|
|
369
380
|
await this.shutdownAfterSdkGrace();
|
|
370
381
|
}
|
|
371
382
|
|
|
372
|
-
private
|
|
383
|
+
private deliverLiveSteering(delivery: SteerDelivery): Promise<SteerDeliveryResult> {
|
|
384
|
+
// Reserve before yielding: a result can arrive while an interrupt or an
|
|
385
|
+
// earlier delivery is awaiting its control response.
|
|
373
386
|
if (!this.acceptingInput || this.aborted) {
|
|
374
|
-
return { delivered: false, reason: "Claude SDK session has completed" };
|
|
387
|
+
return Promise.resolve({ delivered: false, reason: "Claude SDK session has completed" });
|
|
375
388
|
}
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
389
|
+
this.pendingDeliveries++;
|
|
390
|
+
const operation = this.deliveryTail.then(async (): Promise<SteerDeliveryResult> => {
|
|
391
|
+
try {
|
|
392
|
+
if (!this.acceptingInput || this.aborted) {
|
|
393
|
+
throw new Error("Claude SDK session has completed");
|
|
394
|
+
}
|
|
395
|
+
if (delivery.mode === "steer" && this.turnActive && this.query) {
|
|
396
|
+
// The control receipt precedes the interrupted result. Wait for both
|
|
397
|
+
// before writing the redirect, so that result cannot close its input.
|
|
398
|
+
// interrupt() preserves messages already queued inside Claude.
|
|
399
|
+
let release!: () => void;
|
|
400
|
+
const result = new Promise<void>((resolve) => {
|
|
401
|
+
release = resolve;
|
|
402
|
+
this.resultWaiters.add(resolve);
|
|
403
|
+
});
|
|
404
|
+
let timer: ReturnType<typeof setTimeout> | undefined;
|
|
405
|
+
try {
|
|
406
|
+
await Promise.race([
|
|
407
|
+
Promise.all([this.query.interrupt(), result]),
|
|
408
|
+
new Promise<never>((_, reject) => {
|
|
409
|
+
timer = setTimeout(
|
|
410
|
+
() => reject(new Error("Claude SDK redirect timed out")),
|
|
411
|
+
10_000,
|
|
412
|
+
);
|
|
413
|
+
}),
|
|
414
|
+
]);
|
|
415
|
+
} finally {
|
|
416
|
+
clearTimeout(timer);
|
|
417
|
+
this.resultWaiters.delete(release);
|
|
418
|
+
}
|
|
419
|
+
}
|
|
420
|
+
if (!this.acceptingInput || this.aborted) {
|
|
421
|
+
throw new Error("Claude SDK session has completed");
|
|
422
|
+
}
|
|
423
|
+
this.completionCandidate = false;
|
|
424
|
+
this.turnActive = true;
|
|
425
|
+
const uuid = crypto.randomUUID();
|
|
426
|
+
this.unansweredInputs.add(uuid);
|
|
427
|
+
try {
|
|
428
|
+
await this.input.enqueue(delivery.text, uuid);
|
|
429
|
+
} catch (error) {
|
|
430
|
+
this.unansweredInputs.delete(uuid);
|
|
431
|
+
throw error;
|
|
432
|
+
}
|
|
433
|
+
this.transcript.push(`User: ${scrubSecrets(delivery.text)}`);
|
|
434
|
+
return { delivered: true, mode: delivery.mode };
|
|
435
|
+
} catch (error) {
|
|
436
|
+
return { delivered: false, reason: scrubSecrets(String(error)) };
|
|
437
|
+
} finally {
|
|
438
|
+
this.pendingDeliveries--;
|
|
439
|
+
this.maybeCloseInput();
|
|
440
|
+
}
|
|
441
|
+
});
|
|
442
|
+
this.deliveryTail = operation;
|
|
443
|
+
return operation;
|
|
444
|
+
}
|
|
445
|
+
|
|
446
|
+
private maybeCloseInput(): void {
|
|
447
|
+
if (
|
|
448
|
+
!this.completionCandidate ||
|
|
449
|
+
this.pendingDeliveries > 0 ||
|
|
450
|
+
this.input.pendingCount > 0 ||
|
|
451
|
+
this.unansweredInputs.size > 0
|
|
452
|
+
) {
|
|
453
|
+
return;
|
|
381
454
|
}
|
|
382
|
-
|
|
383
|
-
this.
|
|
384
|
-
await this.input.enqueue(text);
|
|
385
|
-
return { delivered: true, mode: "queue" };
|
|
386
|
-
} catch (error) {
|
|
387
|
-
return { delivered: false, reason: scrubSecrets(String(error)) };
|
|
455
|
+
if (!this.backgroundKeepalive.holdInputForBackgroundWork(() => this.closeInput())) {
|
|
456
|
+
this.closeInput();
|
|
388
457
|
}
|
|
389
458
|
}
|
|
390
459
|
|
|
@@ -420,8 +489,49 @@ class ClaudeSdkSession implements ProviderSession {
|
|
|
420
489
|
return this.shutdownPromise;
|
|
421
490
|
}
|
|
422
491
|
|
|
492
|
+
/**
|
|
493
|
+
* A singular `user_message_uuid` names the last message merged into the turn.
|
|
494
|
+
* Every unanswered input enqueued at or before it was coalesced into that
|
|
495
|
+
* turn and is not echoed on its own. Inputs enqueued after it stay open.
|
|
496
|
+
*/
|
|
497
|
+
private answerCoalescedThrough(lastUuid: string): void {
|
|
498
|
+
if (!this.unansweredInputs.has(lastUuid)) return;
|
|
499
|
+
for (const uuid of [...this.unansweredInputs]) {
|
|
500
|
+
this.unansweredInputs.delete(uuid);
|
|
501
|
+
if (uuid === lastUuid) return;
|
|
502
|
+
}
|
|
503
|
+
}
|
|
504
|
+
|
|
505
|
+
private noteAnsweredInputs(result: SDKResultMessage): void {
|
|
506
|
+
const listed = result.user_message_uuids;
|
|
507
|
+
if (listed && listed.length > 0) {
|
|
508
|
+
this.inputResultIdsSupported = true;
|
|
509
|
+
for (const uuid of listed) this.unansweredInputs.delete(uuid);
|
|
510
|
+
return;
|
|
511
|
+
}
|
|
512
|
+
if (result.user_message_uuid) {
|
|
513
|
+
this.inputResultIdsSupported = true;
|
|
514
|
+
this.answerCoalescedThrough(result.user_message_uuid);
|
|
515
|
+
return;
|
|
516
|
+
}
|
|
517
|
+
if (!this.inputResultIdsSupported) {
|
|
518
|
+
// Older executables do not echo input UUIDs. Preserve their existing
|
|
519
|
+
// queued_turn_count completion contract.
|
|
520
|
+
this.unansweredInputs.clear();
|
|
521
|
+
}
|
|
522
|
+
}
|
|
523
|
+
|
|
423
524
|
private handleMessage(message: SDKMessage): boolean {
|
|
424
525
|
const json = message as ClaudeProtocolMessage;
|
|
526
|
+
if (json.type === "result") {
|
|
527
|
+
const result = message as SDKResultMessage;
|
|
528
|
+
this.noteAnsweredInputs(result);
|
|
529
|
+
this.turnActive = (result.queued_turn_count ?? 0) > 0 || this.unansweredInputs.size > 0;
|
|
530
|
+
for (const resolve of this.resultWaiters) resolve();
|
|
531
|
+
this.resultWaiters.clear();
|
|
532
|
+
} else if (json.type === "assistant" && !json.parent_tool_use_id) {
|
|
533
|
+
this.turnActive = true;
|
|
534
|
+
}
|
|
425
535
|
this.backgroundKeepalive.observe(json);
|
|
426
536
|
const normalized = normalizeClaudeMessage(json, {
|
|
427
537
|
taskId: this.options.config.taskId,
|
|
@@ -462,7 +572,9 @@ class ClaudeSdkSession implements ProviderSession {
|
|
|
462
572
|
let terminalError: unknown;
|
|
463
573
|
let stderrOutput = "";
|
|
464
574
|
|
|
465
|
-
|
|
575
|
+
const initialUuid = crypto.randomUUID();
|
|
576
|
+
this.unansweredInputs.add(initialUuid);
|
|
577
|
+
void this.input.enqueue(config.prompt, initialUuid).catch(() => {});
|
|
466
578
|
try {
|
|
467
579
|
const executable = resolveClaudeSdkExecutable(
|
|
468
580
|
this.options.claudeBinaryArgv[0] ?? "claude",
|
|
@@ -529,13 +641,8 @@ class ClaudeSdkSession implements ProviderSession {
|
|
|
529
641
|
const isResult = this.handleMessage(message);
|
|
530
642
|
if (!isResult) continue;
|
|
531
643
|
terminalResult = message as SDKResultMessage;
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
// it settles closes input.
|
|
535
|
-
if (!this.backgroundKeepalive.holdInputForBackgroundWork(() => this.closeInput())) {
|
|
536
|
-
this.closeInput();
|
|
537
|
-
}
|
|
538
|
-
}
|
|
644
|
+
this.completionCandidate = (terminalResult.queued_turn_count ?? 0) === 0;
|
|
645
|
+
this.maybeCloseInput();
|
|
539
646
|
}
|
|
540
647
|
} catch (error) {
|
|
541
648
|
terminalError = error;
|
|
@@ -544,6 +651,8 @@ class ClaudeSdkSession implements ProviderSession {
|
|
|
544
651
|
this.emit({ type: "error", message, category: "sdk_transport" });
|
|
545
652
|
}
|
|
546
653
|
} finally {
|
|
654
|
+
for (const resolve of this.resultWaiters) resolve();
|
|
655
|
+
this.resultWaiters.clear();
|
|
547
656
|
this.backgroundKeepalive.stop();
|
|
548
657
|
this.acceptingInput = false;
|
|
549
658
|
this.input.close();
|
|
@@ -30,7 +30,12 @@ import type { ProviderEvent } from "./types";
|
|
|
30
30
|
*/
|
|
31
31
|
const SLASH_COMMAND_REGEX = /^\/([a-z0-9:_-]+)(?:\s+(.*))?$/;
|
|
32
32
|
|
|
33
|
-
const
|
|
33
|
+
const DEFAULT_MAX_SKILL_CHARS = 100_000;
|
|
34
|
+
|
|
35
|
+
export function getMaxSkillChars(): number {
|
|
36
|
+
const parsed = Number(process.env.MAX_SKILL_CHARS);
|
|
37
|
+
return Number.isInteger(parsed) && parsed > 0 ? parsed : DEFAULT_MAX_SKILL_CHARS;
|
|
38
|
+
}
|
|
34
39
|
|
|
35
40
|
/**
|
|
36
41
|
* Resolve the default skills directory for Codex.
|
|
@@ -128,12 +133,13 @@ export async function resolveSlashSkillPrompt(
|
|
|
128
133
|
return prompt;
|
|
129
134
|
}
|
|
130
135
|
|
|
131
|
-
|
|
136
|
+
const maxSkillChars = getMaxSkillChars();
|
|
137
|
+
if (skillContent.length > maxSkillChars) {
|
|
132
138
|
opts.emit?.({
|
|
133
139
|
type: "raw_stderr",
|
|
134
|
-
content: `[${opts.providerLabel}] skill resolver: SKILL.md for /${commandName} exceeds ${
|
|
140
|
+
content: `[${opts.providerLabel}] skill resolver: SKILL.md for /${commandName} exceeds ${maxSkillChars} chars (${skillContent.length}), truncating\n`,
|
|
135
141
|
});
|
|
136
|
-
skillContent = skillContent.slice(0,
|
|
142
|
+
skillContent = skillContent.slice(0, maxSkillChars);
|
|
137
143
|
}
|
|
138
144
|
|
|
139
145
|
if (opts.stripFrontmatter) {
|
|
@@ -35,7 +35,7 @@ import type {
|
|
|
35
35
|
} from "./types";
|
|
36
36
|
|
|
37
37
|
/** Pinned in package.json and Dockerfile.worker; bump all three together. */
|
|
38
|
-
export const CURSOR_SDK_VERSION = "1.3.
|
|
38
|
+
export const CURSOR_SDK_VERSION = "1.3.1";
|
|
39
39
|
|
|
40
40
|
/** MCP server name; Cursor reports its tools as `mcp` calls with this `providerIdentifier`. */
|
|
41
41
|
const CURSOR_MCP_SERVER_NAME = "agent-swarm";
|
|
@@ -13,6 +13,7 @@
|
|
|
13
13
|
*/
|
|
14
14
|
|
|
15
15
|
import { join } from "node:path";
|
|
16
|
+
import { getMaxSkillChars } from "./codex-skill-resolver";
|
|
16
17
|
import type { ProviderEvent } from "./types";
|
|
17
18
|
|
|
18
19
|
/**
|
|
@@ -24,8 +25,6 @@ import type { ProviderEvent } from "./types";
|
|
|
24
25
|
*/
|
|
25
26
|
const SKILL_COMMAND_REGEX = /^@skills:([a-z0-9:_-]+)(?:\s+(.*))?$/;
|
|
26
27
|
|
|
27
|
-
const MAX_SKILL_CHARS = Number(process.env.MAX_SKILL_CHARS) || 100_000;
|
|
28
|
-
|
|
29
28
|
/**
|
|
30
29
|
* Default skills directory — `plugin/pi-skills/` relative to the project root.
|
|
31
30
|
*
|
|
@@ -97,12 +96,13 @@ export async function resolveDevinPrompt(
|
|
|
97
96
|
return prompt;
|
|
98
97
|
}
|
|
99
98
|
|
|
100
|
-
|
|
99
|
+
const maxSkillChars = getMaxSkillChars();
|
|
100
|
+
if (skillContent.length > maxSkillChars) {
|
|
101
101
|
emit?.({
|
|
102
102
|
type: "raw_stderr",
|
|
103
|
-
content: `[devin] skill resolver: SKILL.md for @skills:${commandName} exceeds ${
|
|
103
|
+
content: `[devin] skill resolver: SKILL.md for @skills:${commandName} exceeds ${maxSkillChars} chars (${skillContent.length}), truncating\n`,
|
|
104
104
|
});
|
|
105
|
-
skillContent = skillContent.slice(0,
|
|
105
|
+
skillContent = skillContent.slice(0, maxSkillChars);
|
|
106
106
|
}
|
|
107
107
|
|
|
108
108
|
// Assemble the user-request body: trailing args from the @skills: line (if any),
|
|
@@ -37,7 +37,7 @@ import type {
|
|
|
37
37
|
} from "./types";
|
|
38
38
|
|
|
39
39
|
// npm's `latest` is older and lacks the JSON/stdin contract used here.
|
|
40
|
-
export const DSH_PACKAGE = "@deepseek-ai/dsh@0.2.2-
|
|
40
|
+
export const DSH_PACKAGE = "@deepseek-ai/dsh@0.2.2-rc.1";
|
|
41
41
|
|
|
42
42
|
export function checkDshCredentials(env: Record<string, string | undefined>): CredStatus {
|
|
43
43
|
return env.DEEPSEEK_API_KEY?.trim() || env.OPENROUTER_API_KEY?.trim()
|
|
@@ -73,6 +73,7 @@ export async function prepareStandaloneScheduleTask(
|
|
|
73
73
|
routingSource: schedule.targetAgentId ? "engine_default" : undefined,
|
|
74
74
|
model: schedule.model,
|
|
75
75
|
modelTier: schedule.modelTier,
|
|
76
|
+
profile: schedule.profile,
|
|
76
77
|
scheduleId: schedule.id,
|
|
77
78
|
source: "schedule",
|
|
78
79
|
requestedByUserId: schedule.createdBy,
|
|
@@ -90,6 +90,7 @@ export const SDK_TOOL_NAME_MAP = {
|
|
|
90
90
|
modelCatalog_refresh: "model-catalog-refresh", // external: fetches models.dev
|
|
91
91
|
modelCatalog_overlayUpsert: "model-catalog-overlay-upsert",
|
|
92
92
|
modelProfile_list: "list-model-profiles",
|
|
93
|
+
modelProfile_check: "check-model-profile",
|
|
93
94
|
|
|
94
95
|
// ── slack ──
|
|
95
96
|
slack_read: "slack-read",
|
|
@@ -493,7 +493,24 @@ async function callBridgeApi(
|
|
|
493
493
|
: `api failed with ${res.status}`;
|
|
494
494
|
throw new Error(`swarm-sdk: ${name} failed with ${res.status}: ${message}`);
|
|
495
495
|
}
|
|
496
|
-
|
|
496
|
+
// The bridge answers 200 with the tool's structuredContent, whose registrar
|
|
497
|
+
// envelope always carries `success: ok` (data cannot override it). A tool
|
|
498
|
+
// refusal (toolErr) is therefore HTTP 200 with `data.success === false`;
|
|
499
|
+
// fold it into the outer flag so scripts gating on `.success` see it, and
|
|
500
|
+
// mirror the refusal text so helpers that read the first failing layer's
|
|
501
|
+
// `message` keep the tool's reason.
|
|
502
|
+
const envelope =
|
|
503
|
+
data !== null && typeof data === "object"
|
|
504
|
+
? (data as { success?: unknown; message?: unknown })
|
|
505
|
+
: undefined;
|
|
506
|
+
const toolRefused = envelope?.success === false;
|
|
507
|
+
const refusalMessage = toolRefused ? envelope?.message : undefined;
|
|
508
|
+
return scrubObject({
|
|
509
|
+
success: res.ok && !toolRefused,
|
|
510
|
+
status: res.status,
|
|
511
|
+
data,
|
|
512
|
+
...(typeof refusalMessage === "string" ? { message: refusalMessage } : {}),
|
|
513
|
+
});
|
|
497
514
|
}
|
|
498
515
|
|
|
499
516
|
const res = await fetch(`${baseUrl}${request.path}`, {
|