@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
|
@@ -261,7 +261,8 @@ async function findDeferredWakeFor(taskId: string, agentId: string): Promise<Def
|
|
|
261
261
|
* task already reviews the result, so a follow-up would duplicate it. An
|
|
262
262
|
* `all` wait with siblings still pending wakes nobody, so the follow-up stays.
|
|
263
263
|
* A `followUpConfig.onCompleted` / `onFailed` instruction for this status also
|
|
264
|
-
* keeps the follow-up, because the wake-up task does not carry that text.
|
|
264
|
+
* keeps the follow-up, because the wake-up task does not carry that text. A
|
|
265
|
+
* rejected `chainedTaskId` keeps it for the same reason.
|
|
265
266
|
*
|
|
266
267
|
* With `FOLLOW_UP_GATE_MODE=shadow`, a gated scheduled run also records a
|
|
267
268
|
* verifier's would-skip decision after commit; the follow-up is never skipped.
|
|
@@ -271,6 +272,13 @@ export async function createWorkerTaskFollowUp(args: {
|
|
|
271
272
|
status: "completed" | "failed";
|
|
272
273
|
output?: string;
|
|
273
274
|
failureReason?: string;
|
|
275
|
+
/**
|
|
276
|
+
* `store-progress` `chainedTaskId`: a live child task the completing agent
|
|
277
|
+
* created to carry this result forward. Honoured only on `completed`.
|
|
278
|
+
*/
|
|
279
|
+
chainedTaskId?: string;
|
|
280
|
+
/** Agent that made the completing call; defaults to the task's assignee. */
|
|
281
|
+
completingAgentId?: string;
|
|
274
282
|
}): Promise<AgentTask | null> {
|
|
275
283
|
const { task, status, output, failureReason } = args;
|
|
276
284
|
|
|
@@ -295,6 +303,37 @@ export async function createWorkerTaskFollowUp(args: {
|
|
|
295
303
|
return null;
|
|
296
304
|
}
|
|
297
305
|
|
|
306
|
+
// Failures always wake the Lead, so only a completion can hand off to a child.
|
|
307
|
+
let chainRejection: (ChainedTaskCheck & { ok: false }) | null = null;
|
|
308
|
+
if (status === "completed" && args.chainedTaskId) {
|
|
309
|
+
const chain = await checkChainedTask(
|
|
310
|
+
task,
|
|
311
|
+
args.chainedTaskId,
|
|
312
|
+
args.completingAgentId ?? task.agentId ?? "",
|
|
313
|
+
);
|
|
314
|
+
if (chain.ok) {
|
|
315
|
+
try {
|
|
316
|
+
await createLogEntry({
|
|
317
|
+
eventType: "task_follow_up_suppressed",
|
|
318
|
+
taskId: task.id,
|
|
319
|
+
agentId: leadAgent.id,
|
|
320
|
+
metadata: {
|
|
321
|
+
reason: "chained_task_live",
|
|
322
|
+
status,
|
|
323
|
+
chainedTaskId: chain.child.id,
|
|
324
|
+
chainedTaskStatus: chain.child.status,
|
|
325
|
+
...(task.followUpConfig?.onCompleted ? { droppedOnCompleted: true } : {}),
|
|
326
|
+
},
|
|
327
|
+
});
|
|
328
|
+
} catch {}
|
|
329
|
+
console.log(
|
|
330
|
+
`[worker-follow-up] Skipped follow-up for completed task ${task.id.slice(0, 8)}: work continues in chained task ${chain.child.id.slice(0, 8)} (${chain.child.status})`,
|
|
331
|
+
);
|
|
332
|
+
return null;
|
|
333
|
+
}
|
|
334
|
+
chainRejection = chain;
|
|
335
|
+
}
|
|
336
|
+
|
|
298
337
|
const agentName = taskAgent.name || task.agentId?.slice(0, 8) || "Unknown";
|
|
299
338
|
const taskDesc = task.task.slice(0, 200);
|
|
300
339
|
const creatorAgent = task.creatorAgentId
|
|
@@ -323,6 +362,12 @@ export async function createWorkerTaskFollowUp(args: {
|
|
|
323
362
|
task_id: task.id,
|
|
324
363
|
});
|
|
325
364
|
followUpDescription = completedResult.text;
|
|
365
|
+
if (chainRejection) {
|
|
366
|
+
followUpDescription += resolveTemplate("task.worker.chain_rejected", {
|
|
367
|
+
chained_task_id: chainRejection.chainedTaskId,
|
|
368
|
+
reason: chainRejection.reason,
|
|
369
|
+
}).text;
|
|
370
|
+
}
|
|
326
371
|
} else {
|
|
327
372
|
const reason = failureReason || "(no reason given)";
|
|
328
373
|
const failedResult = resolveTemplate("task.worker.failed", {
|
|
@@ -374,8 +419,12 @@ export async function createWorkerTaskFollowUp(args: {
|
|
|
374
419
|
const changes = preFollowUp.action === "modify" ? preFollowUp.data : {};
|
|
375
420
|
const followUpAgentId = changes.agentId === undefined ? leadAgent.id : changes.agentId;
|
|
376
421
|
|
|
422
|
+
// Like `instructions`, a rejected chainedTaskId keeps the follow-up: the
|
|
423
|
+
// wake-up task does not carry the rejected id or the reason.
|
|
377
424
|
const wake =
|
|
378
|
-
followUpAgentId && !instructions
|
|
425
|
+
followUpAgentId && !instructions && !chainRejection
|
|
426
|
+
? await findDeferredWakeFor(task.id, followUpAgentId)
|
|
427
|
+
: null;
|
|
379
428
|
if (wake) {
|
|
380
429
|
try {
|
|
381
430
|
await createLogEntry({
|
|
@@ -435,6 +484,57 @@ export async function createWorkerTaskFollowUp(args: {
|
|
|
435
484
|
return followUp;
|
|
436
485
|
}
|
|
437
486
|
|
|
487
|
+
/**
|
|
488
|
+
* Child statuses that mean the chained work is still going to run. `reviewing`
|
|
489
|
+
* is the accept/reject step of an offer, and a `paused` task keeps its agent
|
|
490
|
+
* and resumes when that worker restarts.
|
|
491
|
+
*/
|
|
492
|
+
const LIVE_CHAINED_TASK_STATUSES: ReadonlySet<AgentTask["status"]> = new Set([
|
|
493
|
+
"offered",
|
|
494
|
+
"reviewing",
|
|
495
|
+
"pending",
|
|
496
|
+
"in_progress",
|
|
497
|
+
"paused",
|
|
498
|
+
]);
|
|
499
|
+
|
|
500
|
+
type ChainedTaskCheck =
|
|
501
|
+
| { ok: true; child: AgentTask }
|
|
502
|
+
| { ok: false; chainedTaskId: string; reason: string };
|
|
503
|
+
|
|
504
|
+
/**
|
|
505
|
+
* Whether `chainedTaskId` may stand in for the Lead follow-up of `task`: it
|
|
506
|
+
* must be a live direct child of `task`, created by the completing agent.
|
|
507
|
+
*/
|
|
508
|
+
async function checkChainedTask(
|
|
509
|
+
task: AgentTask,
|
|
510
|
+
chainedTaskId: string,
|
|
511
|
+
completingAgentId: string,
|
|
512
|
+
): Promise<ChainedTaskCheck> {
|
|
513
|
+
const reject = (reason: string): ChainedTaskCheck => ({ ok: false, chainedTaskId, reason });
|
|
514
|
+
let child: AgentTask | null;
|
|
515
|
+
try {
|
|
516
|
+
child = await getTaskById(chainedTaskId);
|
|
517
|
+
} catch (err) {
|
|
518
|
+
// Fail open: a broken lookup must never drop the follow-up.
|
|
519
|
+
return reject(`lookup failed (${err instanceof Error ? err.message : String(err)})`);
|
|
520
|
+
}
|
|
521
|
+
if (!child) return reject("no task has this id");
|
|
522
|
+
if (child.parentTaskId !== task.id) {
|
|
523
|
+
return reject(
|
|
524
|
+
child.parentTaskId
|
|
525
|
+
? `its parentTaskId is ${child.parentTaskId}, not this task`
|
|
526
|
+
: "it has no parentTaskId",
|
|
527
|
+
);
|
|
528
|
+
}
|
|
529
|
+
if (!completingAgentId || child.creatorAgentId !== completingAgentId) {
|
|
530
|
+
return reject("it was not created by the agent that completed this task");
|
|
531
|
+
}
|
|
532
|
+
if (!LIVE_CHAINED_TASK_STATUSES.has(child.status)) {
|
|
533
|
+
return reject(`it is ${child.status}, not live`);
|
|
534
|
+
}
|
|
535
|
+
return { ok: true, child };
|
|
536
|
+
}
|
|
537
|
+
|
|
438
538
|
/** Hop cap for `deferredWorkChatContextKey`; a defer/resume chain is short. */
|
|
439
539
|
const MAX_CONTINUATION_HOPS = 32;
|
|
440
540
|
|
|
@@ -1047,6 +1047,88 @@ ${serveFakeAcpAgent("FakeCopilot")}
|
|
|
1047
1047
|
expect(env.AGENT_MODEL).toBe("custom-model");
|
|
1048
1048
|
});
|
|
1049
1049
|
|
|
1050
|
+
test.each([
|
|
1051
|
+
["number", 1],
|
|
1052
|
+
["boolean", false],
|
|
1053
|
+
["null", null],
|
|
1054
|
+
["object", { key: "ALLOWED_TOKEN" }],
|
|
1055
|
+
["nested array", ["ALLOWED_TOKEN"]],
|
|
1056
|
+
])("custom target rejects a JSON env-key array containing a %s", (_name, entry) => {
|
|
1057
|
+
const config = baseConfig({
|
|
1058
|
+
env: {
|
|
1059
|
+
ACP_TARGET_ENV_KEYS: JSON.stringify(["ALLOWED_TOKEN", entry]),
|
|
1060
|
+
ALLOWED_TOKEN: "allowed",
|
|
1061
|
+
},
|
|
1062
|
+
});
|
|
1063
|
+
const resolveEnv = () => resolveAcpTarget(config).env(config);
|
|
1064
|
+
|
|
1065
|
+
expect(resolveEnv).toThrow(AcpTargetResolutionError);
|
|
1066
|
+
expect(resolveEnv).toThrow("ACP_TARGET_ENV_KEYS");
|
|
1067
|
+
});
|
|
1068
|
+
|
|
1069
|
+
test("custom target preserves literal keys in an all-string JSON env-key array", () => {
|
|
1070
|
+
const config = baseConfig({
|
|
1071
|
+
env: {
|
|
1072
|
+
ACP_TARGET_ENV_KEYS: JSON.stringify(["ALLOWED_TOKEN", " SPACED_KEY ", "", "ALLOWED_TOKEN"]),
|
|
1073
|
+
ALLOWED_TOKEN: "allowed",
|
|
1074
|
+
" SPACED_KEY ": "literal",
|
|
1075
|
+
"": "empty-key",
|
|
1076
|
+
BLOCKED_TOKEN: "blocked",
|
|
1077
|
+
},
|
|
1078
|
+
});
|
|
1079
|
+
const env = resolveAcpTarget(config).env(config);
|
|
1080
|
+
|
|
1081
|
+
expect(env.ALLOWED_TOKEN).toBe("allowed");
|
|
1082
|
+
expect(env[" SPACED_KEY "]).toBe("literal");
|
|
1083
|
+
expect(env[""]).toBe("empty-key");
|
|
1084
|
+
expect(env.SPACED_KEY).toBeUndefined();
|
|
1085
|
+
expect(env.BLOCKED_TOKEN).toBeUndefined();
|
|
1086
|
+
});
|
|
1087
|
+
|
|
1088
|
+
test("custom target trims comma-separated env keys and ignores empty segments", () => {
|
|
1089
|
+
const config = baseConfig({
|
|
1090
|
+
env: {
|
|
1091
|
+
ACP_TARGET_ENV_KEYS: " ALLOWED_TOKEN , , SECOND_TOKEN, ALLOWED_TOKEN , ",
|
|
1092
|
+
ALLOWED_TOKEN: "allowed",
|
|
1093
|
+
SECOND_TOKEN: "second",
|
|
1094
|
+
BLOCKED_TOKEN: "blocked",
|
|
1095
|
+
},
|
|
1096
|
+
});
|
|
1097
|
+
const env = resolveAcpTarget(config).env(config);
|
|
1098
|
+
|
|
1099
|
+
expect(env.ALLOWED_TOKEN).toBe("allowed");
|
|
1100
|
+
expect(env.SECOND_TOKEN).toBe("second");
|
|
1101
|
+
expect(env.BLOCKED_TOKEN).toBeUndefined();
|
|
1102
|
+
});
|
|
1103
|
+
|
|
1104
|
+
test.each([
|
|
1105
|
+
undefined,
|
|
1106
|
+
"",
|
|
1107
|
+
" ",
|
|
1108
|
+
"[]",
|
|
1109
|
+
])("custom target forwards no extra env keys for an empty list (%j)", (value) => {
|
|
1110
|
+
const config = baseConfig({
|
|
1111
|
+
env: { ACP_TARGET_ENV_KEYS: value, ALLOWED_TOKEN: "allowed" },
|
|
1112
|
+
});
|
|
1113
|
+
|
|
1114
|
+
expect(resolveAcpTarget(config).env(config).ALLOWED_TOKEN).toBeUndefined();
|
|
1115
|
+
});
|
|
1116
|
+
|
|
1117
|
+
test.each([
|
|
1118
|
+
'["ALLOWED_TOKEN"',
|
|
1119
|
+
'"ALLOWED_TOKEN"',
|
|
1120
|
+
"123",
|
|
1121
|
+
"true",
|
|
1122
|
+
"null",
|
|
1123
|
+
'{"key":"value"}',
|
|
1124
|
+
])("custom target keeps the text fallback for non-array or invalid JSON (%s)", (value) => {
|
|
1125
|
+
const config = baseConfig({
|
|
1126
|
+
env: { ACP_TARGET_ENV_KEYS: value, [value]: "allowed" },
|
|
1127
|
+
});
|
|
1128
|
+
|
|
1129
|
+
expect(resolveAcpTarget(config).env(config)[value]).toBe("allowed");
|
|
1130
|
+
});
|
|
1131
|
+
|
|
1050
1132
|
test("configured options are nonfatal when absent or rejected", async () => {
|
|
1051
1133
|
const advertised = [
|
|
1052
1134
|
{
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
import { afterAll, beforeAll, describe, expect, test } from "bun:test";
|
|
2
|
+
import { unlink } from "node:fs/promises";
|
|
3
|
+
import { parseAppDefinition } from "../apps/definition";
|
|
4
|
+
import { createApp, getApp, listApps, updateApp } from "../apps/store";
|
|
5
|
+
import { closeDb, getDbClient, initDb } from "../be/db";
|
|
6
|
+
|
|
7
|
+
const TEST_DB_PATH = `/private/tmp/test-apps-icon-${process.pid}.sqlite`;
|
|
8
|
+
|
|
9
|
+
const baseDefinition = {
|
|
10
|
+
models: {},
|
|
11
|
+
queries: {},
|
|
12
|
+
actions: {},
|
|
13
|
+
pages: {
|
|
14
|
+
main: {
|
|
15
|
+
title: "Main",
|
|
16
|
+
root: "root",
|
|
17
|
+
elements: { root: { type: "Stack", props: {}, children: [] } },
|
|
18
|
+
},
|
|
19
|
+
},
|
|
20
|
+
defaultPage: "main",
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
async function createWithIcon(name: string, icon: unknown) {
|
|
24
|
+
const parsed = await parseAppDefinition(baseDefinition, { writerIsUser: true });
|
|
25
|
+
if (!parsed.success) throw new Error(JSON.stringify(parsed.issues));
|
|
26
|
+
const app = await createApp({ name, definition: parsed.definition });
|
|
27
|
+
if (icon !== undefined) {
|
|
28
|
+
// Write the raw column so malformed stored icons (hand edits, old data) can be exercised.
|
|
29
|
+
const stored = { ...parsed.definition, icon };
|
|
30
|
+
await getDbClient().run("UPDATE apps SET definition = ? WHERE id = ?", [
|
|
31
|
+
JSON.stringify(stored),
|
|
32
|
+
app.id,
|
|
33
|
+
]);
|
|
34
|
+
}
|
|
35
|
+
return app.id;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
beforeAll(() => {
|
|
39
|
+
initDb(TEST_DB_PATH);
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
afterAll(async () => {
|
|
43
|
+
closeDb();
|
|
44
|
+
for (const suffix of ["", "-wal", "-shm"])
|
|
45
|
+
await unlink(`${TEST_DB_PATH}${suffix}`).catch(() => {});
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
describe("app icon", () => {
|
|
49
|
+
test("definition accepts a lucide icon and rejects a malformed one", async () => {
|
|
50
|
+
const icon = { type: "lucide", icon: "layout-grid", color: "#f59e0b" };
|
|
51
|
+
expect((await parseAppDefinition({ ...baseDefinition, icon })).success).toBe(true);
|
|
52
|
+
expect(
|
|
53
|
+
(await parseAppDefinition({ ...baseDefinition, icon: { type: "lucide", icon: "Not Valid" } }))
|
|
54
|
+
.success,
|
|
55
|
+
).toBe(false);
|
|
56
|
+
expect(
|
|
57
|
+
(
|
|
58
|
+
await parseAppDefinition({
|
|
59
|
+
...baseDefinition,
|
|
60
|
+
icon: { type: "lucide", icon: "star", color: "red" },
|
|
61
|
+
})
|
|
62
|
+
).success,
|
|
63
|
+
).toBe(false);
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
test('suggests "icon" for avatar and emoji top-level keys', async () => {
|
|
67
|
+
for (const key of ["avatar", "emoji"]) {
|
|
68
|
+
const parsed = await parseAppDefinition({ ...baseDefinition, [key]: "x" });
|
|
69
|
+
expect(parsed.success).toBe(false);
|
|
70
|
+
if (!parsed.success) {
|
|
71
|
+
expect(parsed.issues.some((issue) => issue.message.includes('did you mean "icon"'))).toBe(
|
|
72
|
+
true,
|
|
73
|
+
);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
test("an icon written through the normal create and update path survives to listApps", async () => {
|
|
79
|
+
const icon = { type: "lucide", icon: "layout-grid", color: "#f59e0b" };
|
|
80
|
+
const parsed = await parseAppDefinition({ ...baseDefinition, icon }, { writerIsUser: true });
|
|
81
|
+
if (!parsed.success) throw new Error(JSON.stringify(parsed.issues));
|
|
82
|
+
const app = await createApp({ name: "Round trip", definition: parsed.definition });
|
|
83
|
+
|
|
84
|
+
expect((await listApps()).find((summary) => summary.id === app.id)?.icon).toEqual(icon);
|
|
85
|
+
expect((await getApp(app.id))?.definition.icon).toEqual(icon);
|
|
86
|
+
|
|
87
|
+
const nextIcon = { type: "lucide", icon: "star" };
|
|
88
|
+
const reparsed = await parseAppDefinition(
|
|
89
|
+
{ ...baseDefinition, icon: nextIcon },
|
|
90
|
+
{ writerIsUser: true },
|
|
91
|
+
);
|
|
92
|
+
if (!reparsed.success) throw new Error(JSON.stringify(reparsed.issues));
|
|
93
|
+
await updateApp(app.id, { definition: reparsed.definition });
|
|
94
|
+
|
|
95
|
+
expect((await listApps()).find((summary) => summary.id === app.id)?.icon).toEqual(nextIcon);
|
|
96
|
+
});
|
|
97
|
+
|
|
98
|
+
test("listApps projects a valid icon and omits it when absent or invalid", async () => {
|
|
99
|
+
const icon = { type: "lucide", icon: "layout-grid", color: "#f59e0b" };
|
|
100
|
+
const withIcon = await createWithIcon("With icon", icon);
|
|
101
|
+
const withoutIcon = await createWithIcon("Without icon", undefined);
|
|
102
|
+
const badShape = await createWithIcon("Bad shape", { type: "lucide", icon: "Not Valid" });
|
|
103
|
+
const wrongType = await createWithIcon("Wrong type", "star");
|
|
104
|
+
|
|
105
|
+
const byId = new Map((await listApps()).map((app) => [app.id, app]));
|
|
106
|
+
expect(byId.get(withIcon)?.icon).toEqual(icon);
|
|
107
|
+
for (const id of [withoutIcon, badShape, wrongType]) {
|
|
108
|
+
const summary = byId.get(id);
|
|
109
|
+
expect(summary).toBeDefined();
|
|
110
|
+
expect(summary && "icon" in summary).toBe(false);
|
|
111
|
+
}
|
|
112
|
+
});
|
|
113
|
+
|
|
114
|
+
test("an unknown but well-formed icon name is passed through for the dashboard to fall back on", async () => {
|
|
115
|
+
const icon = { type: "lucide", icon: "no-such-icon" };
|
|
116
|
+
const id = await createWithIcon("Unknown icon", icon);
|
|
117
|
+
const summary = (await listApps()).find((app) => app.id === id);
|
|
118
|
+
expect(summary?.icon).toEqual(icon);
|
|
119
|
+
});
|
|
120
|
+
});
|
|
@@ -0,0 +1,248 @@
|
|
|
1
|
+
import { afterAll, beforeAll, describe, expect, test } from "bun:test";
|
|
2
|
+
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
3
|
+
import {
|
|
4
|
+
cancelTask,
|
|
5
|
+
closeDb,
|
|
6
|
+
completeTask,
|
|
7
|
+
createAgent,
|
|
8
|
+
createTaskExtended,
|
|
9
|
+
getDbClient,
|
|
10
|
+
getLogsByTaskIdAndEventType,
|
|
11
|
+
initDb,
|
|
12
|
+
pauseTask,
|
|
13
|
+
startTask,
|
|
14
|
+
} from "../be/db";
|
|
15
|
+
import { registerStoreProgressTool } from "../tools/store-progress";
|
|
16
|
+
import type { CreateTaskOptions } from "../types";
|
|
17
|
+
|
|
18
|
+
type StoreProgressResult = { structuredContent: { success: boolean; message: string } };
|
|
19
|
+
type RegisteredTool = { handler: (args: unknown, extra: unknown) => Promise<unknown> };
|
|
20
|
+
|
|
21
|
+
let leadId: string;
|
|
22
|
+
let workerId: string;
|
|
23
|
+
let otherWorkerId: string;
|
|
24
|
+
let storeProgress: RegisteredTool;
|
|
25
|
+
|
|
26
|
+
beforeAll(async () => {
|
|
27
|
+
initDb(":memory:");
|
|
28
|
+
leadId = (
|
|
29
|
+
await createAgent({
|
|
30
|
+
name: "Lead",
|
|
31
|
+
isLead: true,
|
|
32
|
+
status: "busy",
|
|
33
|
+
capabilities: [],
|
|
34
|
+
maxTasks: 50,
|
|
35
|
+
})
|
|
36
|
+
).id;
|
|
37
|
+
workerId = (
|
|
38
|
+
await createAgent({ name: "Reviewer", status: "busy", capabilities: [], maxTasks: 50 })
|
|
39
|
+
).id;
|
|
40
|
+
otherWorkerId = (
|
|
41
|
+
await createAgent({ name: "Coder", status: "busy", capabilities: [], maxTasks: 50 })
|
|
42
|
+
).id;
|
|
43
|
+
const server = new McpServer({ name: "chained-follow-up-test", version: "1.0.0" });
|
|
44
|
+
registerStoreProgressTool(server);
|
|
45
|
+
storeProgress = (server as unknown as { _registeredTools: Record<string, RegisteredTool> })
|
|
46
|
+
._registeredTools["store-progress"]!;
|
|
47
|
+
});
|
|
48
|
+
afterAll(() => closeDb());
|
|
49
|
+
|
|
50
|
+
type FollowUpRow = { id: string; task: string; slackChannelId: string | null };
|
|
51
|
+
|
|
52
|
+
function followUps(parentTaskId: string): Promise<FollowUpRow[]> {
|
|
53
|
+
return getDbClient().query<FollowUpRow>(
|
|
54
|
+
"SELECT id, task, slackChannelId FROM agent_tasks WHERE parentTaskId = ? AND taskType = 'follow-up'",
|
|
55
|
+
[parentTaskId],
|
|
56
|
+
);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/** A started worker task, as the Reviewer holds it mid-review. */
|
|
60
|
+
async function reviewTask(options: CreateTaskOptions = {}) {
|
|
61
|
+
const task = await createTaskExtended("Review PR #1", {
|
|
62
|
+
agentId: workerId,
|
|
63
|
+
creatorAgentId: leadId,
|
|
64
|
+
...options,
|
|
65
|
+
});
|
|
66
|
+
await startTask(task.id);
|
|
67
|
+
return task;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/** The fix task the Reviewer chains from its review. */
|
|
71
|
+
function chainChild(parentTaskId: string, options: CreateTaskOptions = {}) {
|
|
72
|
+
return createTaskExtended("Fix the review blockers", {
|
|
73
|
+
agentId: otherWorkerId,
|
|
74
|
+
creatorAgentId: workerId,
|
|
75
|
+
parentTaskId,
|
|
76
|
+
followUpConfig: { disabled: true },
|
|
77
|
+
...options,
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
async function finish(
|
|
82
|
+
taskId: string,
|
|
83
|
+
args: { status?: "completed" | "failed" | "skipped"; chainedTaskId?: string },
|
|
84
|
+
) {
|
|
85
|
+
const status = args.status ?? "completed";
|
|
86
|
+
const result = (await storeProgress.handler(
|
|
87
|
+
{
|
|
88
|
+
taskId,
|
|
89
|
+
status,
|
|
90
|
+
...(status === "completed" ? { output: "CHAINED: fix task" } : { failureReason: "boom" }),
|
|
91
|
+
...(args.chainedTaskId ? { chainedTaskId: args.chainedTaskId } : {}),
|
|
92
|
+
},
|
|
93
|
+
{
|
|
94
|
+
sessionId: `session-${crypto.randomUUID()}`,
|
|
95
|
+
requestInfo: { headers: { "x-agent-id": workerId } },
|
|
96
|
+
},
|
|
97
|
+
)) as StoreProgressResult;
|
|
98
|
+
// The completion itself never fails because of chainedTaskId.
|
|
99
|
+
expect(result.structuredContent.success).toBe(true);
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
async function suppressions(taskId: string) {
|
|
103
|
+
return (await getLogsByTaskIdAndEventType(taskId, "task_follow_up_suppressed")).map(
|
|
104
|
+
(log) => JSON.parse(log.metadata ?? "{}") as Record<string, unknown>,
|
|
105
|
+
);
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
describe("store-progress chainedTaskId", () => {
|
|
109
|
+
test("a live chained child suppresses the follow-up and logs the handoff", async () => {
|
|
110
|
+
const task = await reviewTask({ followUpConfig: { onCompleted: "CHAINED => no action" } });
|
|
111
|
+
const child = await chainChild(task.id);
|
|
112
|
+
|
|
113
|
+
await finish(task.id, { chainedTaskId: child.id });
|
|
114
|
+
|
|
115
|
+
expect(await followUps(task.id)).toHaveLength(0);
|
|
116
|
+
expect(await suppressions(task.id)).toEqual([
|
|
117
|
+
{
|
|
118
|
+
reason: "chained_task_live",
|
|
119
|
+
status: "completed",
|
|
120
|
+
chainedTaskId: child.id,
|
|
121
|
+
chainedTaskStatus: "pending",
|
|
122
|
+
droppedOnCompleted: true,
|
|
123
|
+
},
|
|
124
|
+
]);
|
|
125
|
+
});
|
|
126
|
+
|
|
127
|
+
test("in_progress and paused children count as live", async () => {
|
|
128
|
+
for (const settle of [startTask, async (id: string) => pauseTask((await startTask(id))!.id)]) {
|
|
129
|
+
const task = await reviewTask();
|
|
130
|
+
const child = await chainChild(task.id);
|
|
131
|
+
await settle(child.id);
|
|
132
|
+
|
|
133
|
+
await finish(task.id, { chainedTaskId: child.id });
|
|
134
|
+
|
|
135
|
+
expect(await followUps(task.id)).toHaveLength(0);
|
|
136
|
+
}
|
|
137
|
+
});
|
|
138
|
+
|
|
139
|
+
test.each([
|
|
140
|
+
["completed", (id: string) => completeTask(id, "done"), "it is completed, not live"],
|
|
141
|
+
["cancelled", (id: string) => cancelTask(id, "stop"), "it is cancelled, not live"],
|
|
142
|
+
] as const)("a %s child creates the follow-up naming the reason", async (_, settle, reason) => {
|
|
143
|
+
const task = await reviewTask();
|
|
144
|
+
const child = await chainChild(task.id);
|
|
145
|
+
await settle(child.id);
|
|
146
|
+
|
|
147
|
+
await finish(task.id, { chainedTaskId: child.id });
|
|
148
|
+
|
|
149
|
+
const [followUp, ...rest] = await followUps(task.id);
|
|
150
|
+
expect(rest).toHaveLength(0);
|
|
151
|
+
expect(followUp!.task).toContain(`chainedTaskId ${child.id}`);
|
|
152
|
+
expect(followUp!.task).toContain(reason);
|
|
153
|
+
expect(await suppressions(task.id)).toHaveLength(0);
|
|
154
|
+
});
|
|
155
|
+
|
|
156
|
+
test("a child with another parent creates the follow-up", async () => {
|
|
157
|
+
const task = await reviewTask();
|
|
158
|
+
const otherParent = await reviewTask();
|
|
159
|
+
const child = await chainChild(otherParent.id);
|
|
160
|
+
|
|
161
|
+
await finish(task.id, { chainedTaskId: child.id });
|
|
162
|
+
|
|
163
|
+
const [followUp] = await followUps(task.id);
|
|
164
|
+
expect(followUp!.task).toContain(`its parentTaskId is ${otherParent.id}, not this task`);
|
|
165
|
+
});
|
|
166
|
+
|
|
167
|
+
test("a child created by another agent creates the follow-up", async () => {
|
|
168
|
+
const task = await reviewTask();
|
|
169
|
+
const child = await chainChild(task.id, { creatorAgentId: leadId });
|
|
170
|
+
|
|
171
|
+
await finish(task.id, { chainedTaskId: child.id });
|
|
172
|
+
|
|
173
|
+
const [followUp] = await followUps(task.id);
|
|
174
|
+
expect(followUp!.task).toContain("not created by the agent that completed this task");
|
|
175
|
+
});
|
|
176
|
+
|
|
177
|
+
test("an unknown id creates the follow-up", async () => {
|
|
178
|
+
const task = await reviewTask();
|
|
179
|
+
const missing = crypto.randomUUID();
|
|
180
|
+
|
|
181
|
+
await finish(task.id, { chainedTaskId: missing });
|
|
182
|
+
|
|
183
|
+
const [followUp] = await followUps(task.id);
|
|
184
|
+
expect(followUp!.task).toContain(`chainedTaskId ${missing}`);
|
|
185
|
+
expect(followUp!.task).toContain("no task has this id");
|
|
186
|
+
});
|
|
187
|
+
|
|
188
|
+
test("a failed completion ignores chainedTaskId and wakes the lead", async () => {
|
|
189
|
+
const task = await reviewTask();
|
|
190
|
+
const child = await chainChild(task.id);
|
|
191
|
+
|
|
192
|
+
await finish(task.id, { status: "failed", chainedTaskId: child.id });
|
|
193
|
+
|
|
194
|
+
const [followUp, ...rest] = await followUps(task.id);
|
|
195
|
+
expect(rest).toHaveLength(0);
|
|
196
|
+
expect(followUp!.task).not.toContain("chainedTaskId");
|
|
197
|
+
expect(await suppressions(task.id)).toHaveLength(0);
|
|
198
|
+
});
|
|
199
|
+
|
|
200
|
+
test("a skipped completion ignores chainedTaskId", async () => {
|
|
201
|
+
const task = await reviewTask();
|
|
202
|
+
const child = await chainChild(task.id);
|
|
203
|
+
|
|
204
|
+
await finish(task.id, { status: "skipped", chainedTaskId: child.id });
|
|
205
|
+
|
|
206
|
+
expect(await followUps(task.id)).toHaveLength(0);
|
|
207
|
+
expect(await suppressions(task.id)).toHaveLength(0);
|
|
208
|
+
});
|
|
209
|
+
|
|
210
|
+
test("followUpConfig.disabled still disables, with or without a valid chain", async () => {
|
|
211
|
+
for (const chained of [false, true]) {
|
|
212
|
+
const task = await reviewTask({ followUpConfig: { disabled: true } });
|
|
213
|
+
const child = await chainChild(task.id);
|
|
214
|
+
|
|
215
|
+
await finish(task.id, chained ? { chainedTaskId: child.id } : {});
|
|
216
|
+
|
|
217
|
+
expect(await followUps(task.id)).toHaveLength(0);
|
|
218
|
+
expect(await suppressions(task.id)).toHaveLength(0);
|
|
219
|
+
}
|
|
220
|
+
});
|
|
221
|
+
|
|
222
|
+
test("without chainedTaskId the follow-up is unchanged", async () => {
|
|
223
|
+
const task = await reviewTask();
|
|
224
|
+
await chainChild(task.id);
|
|
225
|
+
|
|
226
|
+
await finish(task.id, {});
|
|
227
|
+
|
|
228
|
+
const [followUp] = await followUps(task.id);
|
|
229
|
+
expect(followUp!.task).not.toContain("chainedTaskId");
|
|
230
|
+
});
|
|
231
|
+
|
|
232
|
+
test("a Slack-sourced task with a suppressed follow-up creates nothing in the thread", async () => {
|
|
233
|
+
const slack = { slackChannelId: "C_TEST", slackThreadTs: "1700000000.000100" };
|
|
234
|
+
const task = await reviewTask({ source: "slack", ...slack });
|
|
235
|
+
const child = await chainChild(task.id);
|
|
236
|
+
|
|
237
|
+
await finish(task.id, { chainedTaskId: child.id });
|
|
238
|
+
|
|
239
|
+
expect(await followUps(task.id)).toHaveLength(0);
|
|
240
|
+
// Only the review and its chained child live in the thread: no Lead
|
|
241
|
+
// follow-up exists to reply there or post an outcome card.
|
|
242
|
+
const inThread = await getDbClient().query<{ id: string }>(
|
|
243
|
+
"SELECT id FROM agent_tasks WHERE slackChannelId = ? AND slackThreadTs = ?",
|
|
244
|
+
[slack.slackChannelId, slack.slackThreadTs],
|
|
245
|
+
);
|
|
246
|
+
expect(inThread.map((row) => row.id).sort()).toEqual([task.id, child.id].sort());
|
|
247
|
+
});
|
|
248
|
+
});
|
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
import { describe, expect, test } from "bun:test";
|
|
2
|
+
import { mkdtemp, rm } from "node:fs/promises";
|
|
3
|
+
import { tmpdir } from "node:os";
|
|
4
|
+
import { join } from "node:path";
|
|
2
5
|
import {
|
|
3
6
|
checkPrBody,
|
|
4
7
|
isFixTitle,
|
|
@@ -9,6 +12,7 @@ import {
|
|
|
9
12
|
templateLeadLines,
|
|
10
13
|
templateSections,
|
|
11
14
|
} from "../../scripts/check-pr-body";
|
|
15
|
+
import { runChild } from "./test-proc";
|
|
12
16
|
|
|
13
17
|
const TEMPLATE = `<!-- top comment -->
|
|
14
18
|
|
|
@@ -246,3 +250,39 @@ describe("check-pr-body: prose budget", () => {
|
|
|
246
250
|
expect(prBodyWarnings("word ".repeat(301))).toHaveLength(1);
|
|
247
251
|
});
|
|
248
252
|
});
|
|
253
|
+
|
|
254
|
+
describe("check-pr-body: PR_TEMPLATE_PATH", () => {
|
|
255
|
+
// The org-wide check (desplega-ai/.github) runs this script against another
|
|
256
|
+
// repo's template or the org default, so the CLI must honor the override.
|
|
257
|
+
test("the CLI checks the body against the template the env names", async () => {
|
|
258
|
+
const dir = await mkdtemp(join(tmpdir(), "pr-body-template-"));
|
|
259
|
+
try {
|
|
260
|
+
const templatePath = join(dir, "template.md");
|
|
261
|
+
const bodyPath = join(dir, "body.md");
|
|
262
|
+
await Bun.write(templatePath, "## Only section\n\n<!-- guidance -->\n");
|
|
263
|
+
await Bun.write(bodyPath, "## Only section\n\nFilled.\n");
|
|
264
|
+
const run = (env: Record<string, string>) =>
|
|
265
|
+
runChild(["bun", "scripts/check-pr-body.ts", "--body-file", bodyPath], {
|
|
266
|
+
env: {
|
|
267
|
+
PATH: process.env.PATH,
|
|
268
|
+
HOME: process.env.HOME,
|
|
269
|
+
PR_TITLE: "chore: x",
|
|
270
|
+
PR_AUTHOR: "someone",
|
|
271
|
+
PR_CHANGED_FILES_FILE: bodyPath,
|
|
272
|
+
...env,
|
|
273
|
+
},
|
|
274
|
+
});
|
|
275
|
+
|
|
276
|
+
const custom = await run({ PR_TEMPLATE_PATH: templatePath });
|
|
277
|
+
expect(custom.stderr).not.toContain("does not match");
|
|
278
|
+
expect(custom.exitCode).toBe(0);
|
|
279
|
+
|
|
280
|
+
// Control: without the override, the repo template applies and this body fails it.
|
|
281
|
+
const repoDefault = await run({});
|
|
282
|
+
expect(repoDefault.exitCode).toBe(1);
|
|
283
|
+
expect(repoDefault.stderr).toContain("does not match .github/pull_request_template.md");
|
|
284
|
+
} finally {
|
|
285
|
+
await rm(dir, { recursive: true, force: true });
|
|
286
|
+
}
|
|
287
|
+
});
|
|
288
|
+
});
|