@desplega.ai/agent-swarm 2.5.3 → 2.5.4
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-gr2fcyyj.js → acp-adapter-ek38cwsv.js} +4 -4
- package/dist/{actions-wv766ghf.js → actions-92mepq03.js} +17 -17
- package/dist/{amp-adapter-speb906t.js → amp-adapter-9gaxg015.js} +2 -2
- package/dist/{app-ag29n14f.js → app-ctn8gsgx.js} +3 -3
- package/dist/{assistant-3x8bz3eg.js → assistant-zyr5kz47.js} +19 -19
- package/dist/{boot-reembed-jsmfrpzf.js → boot-reembed-dwzfttdr.js} +1 -1
- package/dist/{boot-reembed-5b3d2eea.js → boot-reembed-w75maga2.js} +1 -1
- package/dist/{boot-scrub-sweep-s73gerxy.js → boot-scrub-sweep-e9kq43kf.js} +3 -3
- package/dist/{boot-seeds-5zmax2wr.js → boot-seeds-x28v3fhb.js} +4 -4
- package/dist/{claude-adapter-hswdnm3t.js → claude-adapter-f0afqnne.js} +4 -4
- package/dist/{claude-managed-adapter-cvbzj1h6.js → claude-managed-adapter-x81a7r65.js} +3 -3
- package/dist/{claude-managed-setup-3k8m3hhc.js → claude-managed-setup-bqzwjd9x.js} +1 -1
- package/dist/{claude-sdk-session-fkbyk66x.js → claude-sdk-session-7b7whkaq.js} +9307 -9254
- package/dist/{cli-a5ebc95n.js → cli-0shx9j93.js} +16 -13
- package/dist/{cli-vwn81jbs.js → cli-19202kew.js} +3 -3
- package/dist/{cli-svrj71pg.js → cli-1r5ad7j5.js} +7 -7
- package/dist/{cli-hhxjnjzs.js → cli-25n3mv5d.js} +8 -6
- package/dist/cli-2655k16q.js +140 -0
- package/dist/{cli-hcpj2xqz.js → cli-277c31dw.js} +1 -1
- package/dist/{cli-35gtk1p6.js → cli-4b2z6n0m.js} +29 -7
- package/dist/{cli-40jsnrjm.js → cli-5bnsc0e1.js} +7 -5
- package/dist/{cli-fzcn3d87.js → cli-621ce7kw.js} +1 -1
- package/dist/{cli-s49hpn37.js → cli-64mh9mf3.js} +19 -5
- package/dist/{cli-e8jyq7d8.js → cli-6a1xg1p7.js} +6 -2
- package/dist/{cli-p9rafdrb.js → cli-7p4jxgtt.js} +4 -4
- package/dist/{cli-w1zwctj2.js → cli-9j129brq.js} +9 -3
- package/dist/{cli-ce0ak9ms.js → cli-abs8ndtr.js} +11 -11
- package/dist/{cli-aecdcr77.js → cli-asq5ydm4.js} +123 -50
- package/dist/{cli-n45mr7zh.js → cli-bvpgr9ny.js} +2 -2
- package/dist/{cli-210xd1f4.js → cli-c61mbdds.js} +3 -3
- package/dist/{cli-e5bxnjps.js → cli-c952c7ac.js} +5 -5
- package/dist/{cli-p859hcc8.js → cli-dew6x255.js} +1 -1
- package/dist/{cli-tx00c0h6.js → cli-dqygeeh5.js} +17 -1
- package/dist/{cli-gpv60278.js → cli-e42vss7b.js} +2 -2
- package/dist/{cli-s53vp709.js → cli-eftzyh9y.js} +1 -1
- package/dist/{cli-3ngdk5te.js → cli-ethgy7ha.js} +1 -1
- package/dist/{cli-99xgw26r.js → cli-ff1tm9n9.js} +1 -1
- package/dist/{cli-ewm3pwbq.js → cli-g9vd9ece.js} +37 -12
- package/dist/{cli-jjznk3f7.js → cli-gbfxp48k.js} +62 -28
- package/dist/{cli-z21whrrg.js → cli-gn5af0x5.js} +14 -14
- package/dist/{cli-1fc85mvt.js → cli-gwhjmh8g.js} +4 -4
- package/dist/{cli-avdvgcay.js → cli-hh5we352.js} +24 -5
- package/dist/{cli-0ebey9hg.js → cli-j6rktc91.js} +1 -1
- package/dist/{cli-kxawjrxg.js → cli-jb30dzvk.js} +332 -36
- package/dist/{cli-25j01dpj.js → cli-jbnn4vxb.js} +3 -3
- package/dist/{cli-qzme5949.js → cli-k4tjsdx9.js} +44 -39
- package/dist/{cli-8s5wx3nz.js → cli-m4ecdxvz.js} +40 -13
- package/dist/{cli-ta8bd7th.js → cli-pzatvw94.js} +1 -1
- package/dist/{cli-p6zs9h4y.js → cli-rr7zx19j.js} +767 -249
- package/dist/{cli-502eqv93.js → cli-s682zgqz.js} +1 -1
- package/dist/{cli-fsdprwrg.js → cli-sbwsxvtd.js} +1 -1
- package/dist/{cli-0xk505e8.js → cli-sxgtf5fw.js} +1 -1
- package/dist/{cli-egjggehm.js → cli-tsma7p8v.js} +1 -1
- package/dist/{cli-qgf8emrn.js → cli-wghjkr0e.js} +5 -5
- package/dist/{cli-p0rzjkya.js → cli-wx2nj19m.js} +29 -10
- package/dist/{cli-e2ar4bp1.js → cli-x0f2v69c.js} +111 -42
- package/dist/{cli-y561h5a9.js → cli-xtrz6bzs.js} +5 -5
- package/dist/{cli-gpsz7g88.js → cli-xzfq4at3.js} +7 -7
- package/dist/cli.js +18 -18
- package/dist/{codex-adapter-n8ka66vf.js → codex-adapter-wch12q99.js} +2 -2
- package/dist/{codex-hook-e2he7aca.js → codex-hook-brpnycn5.js} +1 -1
- package/dist/{codex-session-runner-fsebts37.js → codex-session-runner-41pfcr95.js} +2 -2
- package/dist/{commands-t04rt2pc.js → commands-9849dkj6.js} +2 -2
- package/dist/{controller-rgna04r2.js → controller-ja0sd95p.js} +27 -1
- package/dist/{controllers-connect-bqm1rtft.js → controllers-connect-xp05dj6x.js} +16 -16
- package/dist/{cursor-adapter-swr2k95y.js → cursor-adapter-623qxqew.js} +1 -2
- package/dist/{db-a4m7haw0.js → db-47vj40dy.js} +3 -3
- package/dist/{db-24ck09xy.js → db-w759qmx0.js} +2 -2
- package/dist/{dispatcher-nwf9ss0q.js → dispatcher-7b8e4z2j.js} +15 -15
- package/dist/{docker-nfy2gc8t.js → docker-s84hjs91.js} +2 -2
- package/dist/{dsh-adapter-kpdnhjst.js → dsh-adapter-2ezw3xea.js} +1 -2
- package/dist/{external-channel-j1e2p34p.js → external-channel-e2s028da.js} +2 -2
- package/dist/{grok-adapter-qtjz0whk.js → grok-adapter-ys7gaqee.js} +5 -5
- package/dist/{handlers-19xr6dnz.js → handlers-wy1dr6ja.js} +18 -18
- package/dist/{heartbeat-vtesda5d.js → heartbeat-w3mntghj.js} +17 -17
- package/dist/{hook-8wqaszda.js → hook-3jjywnpb.js} +9 -3
- package/dist/{hook-b2hhj6rd.js → hook-g7kvv6x9.js} +3 -2
- package/dist/{http-mxcqhhcs.js → http-tkp7d4kb.js} +267 -75
- package/dist/{index-srg522m6.js → index-1ef1myq2.js} +15 -15
- package/dist/{index-1r8wfpzs.js → index-3n8m9ea2.js} +1 -1
- package/dist/{index-kw2mmat7.js → index-nmm79qgr.js} +17 -17
- package/dist/{index-n1vbvta9.js → index-q7m26kvs.js} +24 -22
- package/dist/{index-spwxjgay.js → index-xdaahthb.js} +15 -15
- package/dist/{keepalive-dsd8rtgx.js → keepalive-v4ta8wgg.js} +3 -3
- package/dist/{lead-zyerk1x2.js → lead-sawnyqxk.js} +33 -33
- package/dist/{maintenance-jqmqwnet.js → maintenance-84n1ex21.js} +1 -1
- package/dist/{oauth-refresh-sweep-q2c3bnvm.js → oauth-refresh-sweep-vjnnandw.js} +2 -2
- package/dist/{onboard-w4yd7s8t.js → onboard-sfmpe4np.js} +2 -2
- package/dist/{opencode-adapter-9tppvxar.js → opencode-adapter-jmpst4q4.js} +3 -3
- package/dist/{otel-impl-f36byzbd.js → otel-impl-v6cc0zve.js} +1 -1
- package/dist/{pi-mono-adapter-tqsge1ay.js → pi-mono-adapter-fk8fkcf6.js} +33 -6
- package/dist/{pricing-refresh-xvak5p4v.js → pricing-refresh-fsk1e1zc.js} +3 -3
- package/dist/{rbac-roles-gfn30fb8.js → rbac-roles-prmkdnkw.js} +2 -2
- package/dist/{rbac-roles-682k2mt5.js → rbac-roles-zxmxqa39.js} +1 -1
- package/dist/{render-v2-hgytz8nn.js → render-v2-pjwxvnkw.js} +3 -3
- package/dist/{resume-2dvq348g.js → resume-frdtgfa0.js} +8 -6
- package/dist/{session-access-7f21ekq9.js → session-access-fpez4y5q.js} +4 -4
- package/dist/{setup-epffxtbk.js → setup-mq6m3m8q.js} +1 -1
- package/dist/{work-objects-xz1a5rqk.js → work-objects-kfahhjsq.js} +18 -18
- package/dist/{worker-42t8emjt.js → worker-v5e5rxj3.js} +33 -33
- package/openapi.json +68 -3
- package/package.json +5 -5
- package/plugin/commands/create-pr.md +2 -2
- package/plugin/pi-skills/create-pr/SKILL.md +2 -2
- package/src/be/db/approvals.ts +48 -0
- package/src/be/db/tasks/write.ts +15 -5
- package/src/be/db/workflow-idempotency.ts +183 -0
- package/src/be/db/workflow-runs.ts +318 -7
- package/src/be/db.ts +67 -17
- package/src/be/migrations/242_workflow_idempotency_keys.sql +40 -0
- package/src/be/sealed-json.ts +1 -0
- package/src/be/seed-scripts/catalog/compound-insights.inline.ts +2 -2
- package/src/be/seed-scripts/catalog/compound-insights.ts +2 -2
- package/src/be/seed-skills/bundled-files.generated.json +1 -1
- package/src/be/sql-connections.ts +7 -1
- package/src/be/swarm-config-guard.ts +2 -0
- package/src/be/users.ts +9 -0
- package/src/commands/controller.ts +33 -0
- package/src/commands/runner.ts +6 -2
- package/src/extensions/apply-task-create.ts +57 -11
- package/src/extensions/contract-types.generated.ts +1 -1
- package/src/extensions/contract.ts +25 -0
- package/src/extensions/dispatcher.ts +4 -0
- package/src/extensions/post-bridge.ts +8 -0
- package/src/hooks/context-bound-note.ts +196 -0
- package/src/hooks/hook.ts +12 -0
- package/src/http/config.ts +48 -16
- package/src/http/idempotency-key.ts +117 -0
- package/src/http/workflows.ts +129 -24
- package/src/prompts/context-bound-note.ts +48 -0
- package/src/prompts/session-templates.ts +25 -1
- package/src/providers/amp-adapter.ts +30 -8
- package/src/providers/claude-adapter.ts +29 -4
- package/src/providers/claude-managed-adapter.ts +26 -0
- package/src/providers/claude-sdk-session.ts +10 -0
- package/src/providers/claude-session-events.ts +13 -0
- package/src/providers/codex-adapter.ts +12 -0
- package/src/providers/opencode-adapter.ts +18 -0
- package/src/providers/pi-mono-adapter.ts +35 -0
- package/src/runtime-providers/docker.ts +6 -2
- package/src/scripts-runtime/types/swarm-extension.d.ts +35 -0
- package/src/tests/amp-adapter.test.ts +97 -0
- package/src/tests/approval-requests.test.ts +10 -7
- package/src/tests/approval-sweeps.test.ts +12 -6
- package/src/tests/base-prompt.test.ts +1 -1
- package/src/tests/claude-hook-output.test.ts +79 -1
- package/src/tests/claude-managed-adapter.test.ts +275 -0
- package/src/tests/codex-adapter.test.ts +163 -0
- package/src/tests/context-bound-note.test.ts +269 -0
- package/src/tests/extensions-pre-task.test.ts +273 -0
- package/src/tests/fetch-resolved-env.test.ts +17 -0
- package/src/tests/fixtures/extensions/record-blocks/hooks.ts +10 -0
- package/src/tests/fixtures/extensions/record-blocks/manifest.json +7 -0
- package/src/tests/fixtures/fake-amp.ts +22 -8
- package/src/tests/fixtures/held-template-render.ts +42 -0
- package/src/tests/fixtures/workflow-idempotency-trigger.child.ts +73 -0
- package/src/tests/openapi-route-headers.test.ts +2 -0
- package/src/tests/opencode-adapter.test.ts +134 -0
- package/src/tests/pi-mono-adapter.test.ts +105 -0
- package/src/tests/prompt-template-session.test.ts +4 -3
- package/src/tests/runner-push-delivery.test.ts +25 -0
- package/src/tests/runtime-controller-liveness.test.ts +133 -0
- package/src/tests/runtime-providers-docker.test.ts +2 -0
- package/src/tests/script-connections.test.ts +3 -0
- package/src/tests/script-run-config-scope.test.ts +91 -3
- package/src/tests/session-logs.test.ts +70 -0
- package/src/tests/sessions-tree.test.ts +37 -0
- package/src/tests/workflow-cascade-cancel.test.ts +1169 -0
- package/src/tests/workflow-foreach-supersede-retry.test.ts +488 -0
- package/src/tests/workflow-idempotency.test.ts +915 -0
- package/src/tools/workflows/cancel-workflow-run.ts +1 -1
- package/src/utils/context-window.ts +8 -6
- package/src/workflows/approval-cancel.ts +15 -13
- package/src/workflows/approval-notifications.ts +5 -1
- package/src/workflows/checkpoint.ts +6 -3
- package/src/workflows/engine.ts +30 -8
- package/src/workflows/executors/foreach.ts +2 -2
- package/src/workflows/foreach-driver.ts +10 -3
- package/src/workflows/foreach-join.ts +29 -6
- package/src/workflows/recovery.ts +6 -1
- package/src/workflows/resume.ts +168 -56
- package/src/workflows/retry-poller.ts +49 -3
- package/src/workflows/task-step-routing.ts +29 -7
- package/templates/ai-toolbox.manifest.json +8 -8
- package/templates/community/open-prompt-showreel/PLAYBOOK.md +5 -6
- package/templates/community/open-prompt-showreel/lead-prompt.md +1 -1
- package/templates/community/open-prompt-showreel/skills/open-prompt-showreel/SKILL.md +4 -4
- package/templates/skills/agent-browser/SKILL.md +4 -4
- package/templates/skills/agent-browser/content.md +4 -4
- package/templates/skills/code-quality/config.json +1 -1
- package/templates/skills/code-quality/content.md +2 -2
- package/templates/skills/delegate-work/content.md +29 -25
- package/templates/skills/delegate-work/files/scripts/codex-exec.sh +5 -5
- package/templates/skills/qa/content.md +2 -2
- package/templates/skills/researching/content.md +2 -0
- package/templates/skills/work-on-task/SKILL.md +1 -1
- package/templates/skills/work-on-task/content.md +1 -1
|
@@ -10,7 +10,7 @@ import {
|
|
|
10
10
|
init_steering,
|
|
11
11
|
createLogEntry2,
|
|
12
12
|
init_db3
|
|
13
|
-
} from "./cli-
|
|
13
|
+
} from "./cli-jb30dzvk.js";
|
|
14
14
|
import {
|
|
15
15
|
ackSlackMessage,
|
|
16
16
|
buildBufferFlushBlocks,
|
|
@@ -20,7 +20,7 @@ import {
|
|
|
20
20
|
ensureSlackThreadTree2,
|
|
21
21
|
registerTreeMessage,
|
|
22
22
|
getSlackApp2
|
|
23
|
-
} from "./cli-
|
|
23
|
+
} from "./cli-abs8ndtr.js";
|
|
24
24
|
import {
|
|
25
25
|
createAdditiveBuffer,
|
|
26
26
|
TaskCreationBlockedError,
|
|
@@ -30,15 +30,15 @@ import {
|
|
|
30
30
|
createSlackTaskWithFiles,
|
|
31
31
|
notifySlackFileFailures,
|
|
32
32
|
extractSlackMessageText
|
|
33
|
-
} from "./cli-
|
|
33
|
+
} from "./cli-asq5ydm4.js";
|
|
34
34
|
import {
|
|
35
35
|
resolveSlackUserId,
|
|
36
36
|
rewriteSlackMentions
|
|
37
|
-
} from "./cli-
|
|
37
|
+
} from "./cli-jbnn4vxb.js";
|
|
38
38
|
import {
|
|
39
39
|
findUserByExternalId,
|
|
40
40
|
init_users
|
|
41
|
-
} from "./cli-
|
|
41
|
+
} from "./cli-6a1xg1p7.js";
|
|
42
42
|
import {
|
|
43
43
|
isSteeringEnabled2,
|
|
44
44
|
init_steering_enabled
|
|
@@ -1,12 +1,11 @@
|
|
|
1
|
+
import {
|
|
2
|
+
contextBoundNoteThreshold,
|
|
3
|
+
createContextBoundNote
|
|
4
|
+
} from "./cli-2655k16q.js";
|
|
1
5
|
import {
|
|
2
6
|
ampBillsCacheWrites,
|
|
3
7
|
resolveAmpModel
|
|
4
8
|
} from "./cli-9s05422w.js";
|
|
5
|
-
import {
|
|
6
|
-
CONTEXT_FORMULA,
|
|
7
|
-
computeContextUsedUnified,
|
|
8
|
-
clampContextPercent
|
|
9
|
-
} from "./cli-a5ebc95n.js";
|
|
10
9
|
import {
|
|
11
10
|
swarmRuntimeInstanceId
|
|
12
11
|
} from "./cli-e8xyjvfc.js";
|
|
@@ -24,6 +23,12 @@ import {
|
|
|
24
23
|
import {
|
|
25
24
|
applyReasoningEffort
|
|
26
25
|
} from "./cli-bn0rewsy.js";
|
|
26
|
+
import {
|
|
27
|
+
CONTEXT_FORMULA,
|
|
28
|
+
computeContextUsedUnified,
|
|
29
|
+
clampContextPercent,
|
|
30
|
+
init_context_window
|
|
31
|
+
} from "./cli-0shx9j93.js";
|
|
27
32
|
import {
|
|
28
33
|
scrubSecrets,
|
|
29
34
|
registerVolatileSecret,
|
|
@@ -35,8 +40,9 @@ import { existsSync, readFileSync, renameSync, rmSync, writeFileSync } from "nod
|
|
|
35
40
|
import { mkdir, mkdtemp, rm, writeFile } from "node:fs/promises";
|
|
36
41
|
import { tmpdir } from "node:os";
|
|
37
42
|
import { join } from "node:path";
|
|
43
|
+
init_context_window();
|
|
38
44
|
init_secret_scrubber();
|
|
39
|
-
var AMP_PACKAGE = "@ampcode/cli@0.0.
|
|
45
|
+
var AMP_PACKAGE = "@ampcode/cli@0.0.1792844927-g360c96";
|
|
40
46
|
var AMP_MCP_SERVER_NAME = "agent-swarm";
|
|
41
47
|
var AMP_PLUGIN_MODE_KEY = "agent-swarm";
|
|
42
48
|
var AMP_LIVE_TEST_TIMEOUT_MS = 5000;
|
|
@@ -322,6 +328,7 @@ class AmpSession {
|
|
|
322
328
|
captures = [];
|
|
323
329
|
steeringSeq = 0;
|
|
324
330
|
steers = new Map;
|
|
331
|
+
observeContextBound;
|
|
325
332
|
constructor(proc, directory, prompt, run) {
|
|
326
333
|
this.proc = proc;
|
|
327
334
|
this.directory = directory;
|
|
@@ -353,6 +360,12 @@ class AmpSession {
|
|
|
353
360
|
});
|
|
354
361
|
}
|
|
355
362
|
};
|
|
363
|
+
this.observeContextBound = createContextBoundNote({
|
|
364
|
+
threshold: contextBoundNoteThreshold(run.env),
|
|
365
|
+
model: () => run.selection.pin,
|
|
366
|
+
canDeliver: () => !this.inputClosed && !this.aborted,
|
|
367
|
+
inject: (note) => this.queueSteering(note, true)
|
|
368
|
+
});
|
|
356
369
|
this.completion = this.runSession(prompt);
|
|
357
370
|
}
|
|
358
371
|
onEvent(listener) {
|
|
@@ -375,13 +388,13 @@ class AmpSession {
|
|
|
375
388
|
await this.stdin.write(userMessage(text));
|
|
376
389
|
await this.stdin.flush?.();
|
|
377
390
|
}
|
|
378
|
-
queueSteering(text) {
|
|
391
|
+
queueSteering(text, internal = false) {
|
|
379
392
|
const name = `${String(++this.steeringSeq).padStart(6, "0")}.json`;
|
|
380
393
|
const temp = join(this.run.steeringInbox, `.${name}.tmp`);
|
|
381
394
|
writeFileSync(temp, JSON.stringify(text), { mode: 384 });
|
|
382
395
|
renameSync(temp, join(this.run.steeringInbox, name));
|
|
383
396
|
return new Promise((resolve) => {
|
|
384
|
-
this.steers.set(name, { text, via: "inbox", resolve });
|
|
397
|
+
this.steers.set(name, { text, via: "inbox", internal, resolve });
|
|
385
398
|
});
|
|
386
399
|
}
|
|
387
400
|
inboxPath(name, suffix = "") {
|
|
@@ -446,7 +459,7 @@ class AmpSession {
|
|
|
446
459
|
continue;
|
|
447
460
|
}
|
|
448
461
|
steer.via = "stdin";
|
|
449
|
-
taken.push({ name, text: steer.text });
|
|
462
|
+
taken.push({ name, text: steer.text, internal: steer.internal });
|
|
450
463
|
}
|
|
451
464
|
return taken;
|
|
452
465
|
}
|
|
@@ -482,7 +495,11 @@ class AmpSession {
|
|
|
482
495
|
onTurnEnd() {
|
|
483
496
|
if (this.inputClosed)
|
|
484
497
|
return;
|
|
485
|
-
for (const { name, text } of this.takeSteering()) {
|
|
498
|
+
for (const { name, text, internal } of this.takeSteering()) {
|
|
499
|
+
if (internal) {
|
|
500
|
+
this.settleSteer(name, { delivered: false, reason: "no tool result carried the note" });
|
|
501
|
+
continue;
|
|
502
|
+
}
|
|
486
503
|
this.writeInput(text).catch((error) => {
|
|
487
504
|
this.settleSteer(name, {
|
|
488
505
|
delivered: false,
|
|
@@ -581,6 +598,8 @@ class AmpSession {
|
|
|
581
598
|
});
|
|
582
599
|
if (used > 0)
|
|
583
600
|
this.emitContext(used, output, null);
|
|
601
|
+
if (topLevel && calledTool)
|
|
602
|
+
this.observeContextBound(input + cacheRead + cacheCreation);
|
|
584
603
|
}
|
|
585
604
|
if (topLevel && !calledTool && message.stop_reason !== "tool_use")
|
|
586
605
|
this.onTurnEnd();
|
|
@@ -1,7 +1,18 @@
|
|
|
1
1
|
import {
|
|
2
2
|
getDbClient2,
|
|
3
|
+
listUndeliveredCancelledApprovalRequestIds,
|
|
4
|
+
init_approvals,
|
|
3
5
|
getTaskById2,
|
|
4
6
|
cancelTask2,
|
|
7
|
+
getRunLineageBlock,
|
|
8
|
+
getWorkflowRunTreeIds,
|
|
9
|
+
getWorkflowRunStatus,
|
|
10
|
+
getOpenWorkflowTreeTaskIds,
|
|
11
|
+
getTaskIdsWithDependents,
|
|
12
|
+
workflowRunTreeHasOpenWork,
|
|
13
|
+
cancelOpenWorkflowTreeSteps,
|
|
14
|
+
disarmWorkflowTreeRetries,
|
|
15
|
+
cancelLiveWorkflowTreeRuns,
|
|
5
16
|
getChildWorkflowRunId,
|
|
6
17
|
getWorkflowRunLineage,
|
|
7
18
|
createForeachAttemptSteps,
|
|
@@ -15,14 +26,14 @@ import {
|
|
|
15
26
|
getCompletedStepNodeIds2,
|
|
16
27
|
getTaskByWorkflowRunStepId2,
|
|
17
28
|
detachTaskFromWorkflowRunStep2,
|
|
29
|
+
getApprovalRequestById2,
|
|
18
30
|
cancelPendingApprovalRequestsForRun2,
|
|
19
|
-
listCancelledApprovalRequestsForRun2,
|
|
20
31
|
getWaitStateById2,
|
|
21
32
|
getPendingEventWaitNames2,
|
|
22
33
|
getPendingWaitsByEvent2,
|
|
23
34
|
resolveWaitState2,
|
|
24
35
|
init_db3
|
|
25
|
-
} from "./cli-
|
|
36
|
+
} from "./cli-jb30dzvk.js";
|
|
26
37
|
import {
|
|
27
38
|
BaseExecutor,
|
|
28
39
|
postApprovalCancellationUpdates,
|
|
@@ -42,6 +53,7 @@ import {
|
|
|
42
53
|
findReadyNodes,
|
|
43
54
|
startForeachDrive,
|
|
44
55
|
FOREACH_TERMINAL_STEP_STATUSES,
|
|
56
|
+
isRetryPending,
|
|
45
57
|
parseSyntheticNodeId,
|
|
46
58
|
resolveForeachParent,
|
|
47
59
|
settleForeachChild,
|
|
@@ -49,7 +61,7 @@ import {
|
|
|
49
61
|
stepFailureMode,
|
|
50
62
|
getNextTargets,
|
|
51
63
|
getSuccessors
|
|
52
|
-
} from "./cli-
|
|
64
|
+
} from "./cli-gbfxp48k.js";
|
|
53
65
|
import {
|
|
54
66
|
workflowEventBus2,
|
|
55
67
|
init_event_bus
|
|
@@ -98,6 +110,7 @@ function shapeApprovalResolution(registry, definition, nodeId, parkedOutput, app
|
|
|
98
110
|
|
|
99
111
|
// src/workflows/resume.ts
|
|
100
112
|
init_db3();
|
|
113
|
+
init_approvals();
|
|
101
114
|
init_workflow_runs();
|
|
102
115
|
init_types();
|
|
103
116
|
init_secret_scrubber();
|
|
@@ -490,6 +503,7 @@ function computeNextPort(mode, status) {
|
|
|
490
503
|
|
|
491
504
|
// src/workflows/task-step-routing.ts
|
|
492
505
|
init_db3();
|
|
506
|
+
init_workflow_runs();
|
|
493
507
|
init_types();
|
|
494
508
|
var UNCLAIMED = {
|
|
495
509
|
claimed: false,
|
|
@@ -547,6 +561,8 @@ async function checkpointPortStepAndResolveSuccessors(def, runId, stepId, nodeId
|
|
|
547
561
|
if (!run || run.status !== "waiting" && run.status !== "running") {
|
|
548
562
|
return UNCLAIMED;
|
|
549
563
|
}
|
|
564
|
+
if (await getRunLineageBlock(runId))
|
|
565
|
+
return UNCLAIMED;
|
|
550
566
|
if (resolveForeachParent(def, nodeId)) {
|
|
551
567
|
return toRoutingResult(await settleForeachChild(def, runId, stepId, { status: "completed", output, nextPort }, ctx, {
|
|
552
568
|
registry
|
|
@@ -570,12 +586,14 @@ var SUPERSEDE_RETRY_POLICY = {
|
|
|
570
586
|
maxDelayMs: 30000
|
|
571
587
|
};
|
|
572
588
|
async function scheduleTaskStepRetry(def, runId, step, taskId, reason) {
|
|
573
|
-
const
|
|
589
|
+
const foreachParent = resolveForeachParent(def, step.nodeId);
|
|
590
|
+
const node = resolveStepNode(def, step.nodeId);
|
|
574
591
|
if (!node || node.type !== "agent-task")
|
|
575
592
|
return "not-eligible";
|
|
593
|
+
const declaredRetry = foreachParent ? foreachParent.retry : node.retry;
|
|
576
594
|
let policy;
|
|
577
|
-
if (
|
|
578
|
-
const parsed = RetryPolicySchema.safeParse(
|
|
595
|
+
if (declaredRetry) {
|
|
596
|
+
const parsed = RetryPolicySchema.safeParse(declaredRetry);
|
|
579
597
|
if (!parsed.success)
|
|
580
598
|
return "not-eligible";
|
|
581
599
|
policy = parsed.data;
|
|
@@ -590,6 +608,13 @@ async function scheduleTaskStepRetry(def, runId, step, taskId, reason) {
|
|
|
590
608
|
return "not-claimed";
|
|
591
609
|
if (!await isTaskBoundToStep(taskId, step.id))
|
|
592
610
|
return "not-claimed";
|
|
611
|
+
if (foreachParent) {
|
|
612
|
+
const run = await getWorkflowRun2(runId);
|
|
613
|
+
if (run?.status !== "running" && run?.status !== "waiting")
|
|
614
|
+
return "not-eligible";
|
|
615
|
+
}
|
|
616
|
+
if (await getRunLineageBlock(runId))
|
|
617
|
+
return "not-claimed";
|
|
593
618
|
if (current.retryCount >= policy.maxRetries)
|
|
594
619
|
return "not-eligible";
|
|
595
620
|
await detachTaskFromWorkflowRunStep2(taskId);
|
|
@@ -610,6 +635,8 @@ async function completeTaskStepAndResolveSuccessors(def, runId, step, output, ct
|
|
|
610
635
|
return UNCLAIMED;
|
|
611
636
|
if (ownerTaskId && !await isTaskBoundToStep(ownerTaskId, step.id))
|
|
612
637
|
return UNCLAIMED;
|
|
638
|
+
if (await getRunLineageBlock(runId))
|
|
639
|
+
return UNCLAIMED;
|
|
613
640
|
if (resolveForeachParent(def, step.nodeId)) {
|
|
614
641
|
return toRoutingResult(await settleForeachChild(def, runId, step.id, {
|
|
615
642
|
status: "completed",
|
|
@@ -750,10 +777,14 @@ async function resumeFromTaskCompletionUnguarded(event, registry) {
|
|
|
750
777
|
}
|
|
751
778
|
async function finalizeOrWait2(runId) {
|
|
752
779
|
await getDbClient2().transaction(async () => {
|
|
780
|
+
const status = await getWorkflowRunStatus(runId);
|
|
781
|
+
if (status !== "running" && status !== "waiting")
|
|
782
|
+
return;
|
|
783
|
+
if (await getRunLineageBlock(runId))
|
|
784
|
+
return;
|
|
753
785
|
const steps = await getWorkflowRunStepsByRunId2(runId);
|
|
754
786
|
if (hasRunningStep(steps)) {
|
|
755
|
-
|
|
756
|
-
if (run?.status === "waiting")
|
|
787
|
+
if (status === "waiting")
|
|
757
788
|
await updateWorkflowRun2(runId, { status: "running" });
|
|
758
789
|
return;
|
|
759
790
|
}
|
|
@@ -872,6 +903,9 @@ async function retryFailedRun2(runId, registry) {
|
|
|
872
903
|
const current = await getWorkflowRun2(runId);
|
|
873
904
|
if (!current || current.status !== "failed")
|
|
874
905
|
return null;
|
|
906
|
+
const blocked = await getRunLineageBlock(runId);
|
|
907
|
+
if (blocked)
|
|
908
|
+
throw new Error(`Retry not started, run left failed: ${blocked}`);
|
|
875
909
|
const currentSteps = await getWorkflowRunStepsByRunId2(runId);
|
|
876
910
|
const attempts = foreachRetryAttempts(workflow.definition, [
|
|
877
911
|
...latestStepPerNode(currentSteps).values()
|
|
@@ -879,6 +913,11 @@ async function retryFailedRun2(runId, registry) {
|
|
|
879
913
|
const capError = foreachRetryCapError(currentSteps.length, attempts);
|
|
880
914
|
if (capError)
|
|
881
915
|
throw new Error(`Retry not started, run left failed: ${capError}`);
|
|
916
|
+
for (const step of currentSteps) {
|
|
917
|
+
if (isRetryPending(step) && resolveForeachParent(workflow.definition, step.nodeId)) {
|
|
918
|
+
await updateWorkflowRunStep2(step.id, { nextRetryAt: null });
|
|
919
|
+
}
|
|
920
|
+
}
|
|
882
921
|
if (!foreachParent) {
|
|
883
922
|
await updateWorkflowRunStep2(failedStep.id, {
|
|
884
923
|
status: shouldRetryFailedNode ? "pending" : "cancelled",
|
|
@@ -941,52 +980,80 @@ function foreachRetryCapError(existingSteps, attempts) {
|
|
|
941
980
|
return null;
|
|
942
981
|
return `foreach retry would reach ${maxSteps} total steps (WORKFLOW_MAX_STEPS_PER_RUN): ${existingSteps} existing + ${added} new attempts leaves no room for the retry walk`;
|
|
943
982
|
}
|
|
983
|
+
var TERMINAL_RUN_STATUSES = new Set(["completed", "failed", "cancelled", "skipped"]);
|
|
944
984
|
async function cancelWorkflowRunRows2(runId, cancelReason) {
|
|
945
|
-
const terminalStatuses = ["completed", "failed", "cancelled", "skipped"];
|
|
946
985
|
const now = new Date().toISOString();
|
|
986
|
+
const settledTree = await getDbClient2().transaction(async () => {
|
|
987
|
+
if (await getWorkflowRunStatus(runId) !== "cancelled")
|
|
988
|
+
return null;
|
|
989
|
+
const ids = await getWorkflowRunTreeIds(runId);
|
|
990
|
+
return await workflowRunTreeHasOpenWork(ids) ? null : ids;
|
|
991
|
+
}, { readOnly: true });
|
|
992
|
+
if (settledTree)
|
|
993
|
+
return { cancelled: false, runIds: settledTree };
|
|
947
994
|
return await getDbClient2().transaction(async () => {
|
|
948
|
-
const
|
|
949
|
-
if (!
|
|
950
|
-
return false;
|
|
951
|
-
const steps = await getWorkflowRunStepsByRunId2(runId);
|
|
952
|
-
for (const step of steps) {
|
|
953
|
-
if (terminalStatuses.includes(step.status))
|
|
954
|
-
continue;
|
|
955
|
-
const task = await getTaskByWorkflowRunStepId2(step.id);
|
|
956
|
-
if (task) {
|
|
957
|
-
await cancelTask2(task.id, cancelReason);
|
|
958
|
-
}
|
|
959
|
-
await updateWorkflowRunStep2(step.id, {
|
|
960
|
-
status: "cancelled",
|
|
961
|
-
error: cancelReason,
|
|
962
|
-
finishedAt: now
|
|
963
|
-
});
|
|
995
|
+
const rootStatus = await getWorkflowRunStatus(runId);
|
|
996
|
+
if (!rootStatus || TERMINAL_RUN_STATUSES.has(rootStatus) && rootStatus !== "cancelled") {
|
|
997
|
+
return { cancelled: false, runIds: [] };
|
|
964
998
|
}
|
|
965
|
-
await
|
|
966
|
-
await
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
}
|
|
971
|
-
|
|
999
|
+
const runIds = await getWorkflowRunTreeIds(runId);
|
|
1000
|
+
const openTaskIds = await getOpenWorkflowTreeTaskIds(runIds);
|
|
1001
|
+
const withDependents = openTaskIds.length > 0 ? await getTaskIdsWithDependents() : new Set;
|
|
1002
|
+
for (const taskId of openTaskIds) {
|
|
1003
|
+
await cancelTask2(taskId, cancelReason, { cascadeDependents: withDependents.has(taskId) });
|
|
1004
|
+
}
|
|
1005
|
+
await cancelOpenWorkflowTreeSteps(runIds, cancelReason, now);
|
|
1006
|
+
await disarmWorkflowTreeRetries(runIds, now);
|
|
1007
|
+
for (const id of runIds)
|
|
1008
|
+
await cancelPendingApprovalRequestsForRun2(id, cancelReason);
|
|
1009
|
+
await cancelLiveWorkflowTreeRuns(runIds.slice(1), cancelReason, now);
|
|
1010
|
+
if (rootStatus !== "cancelled") {
|
|
1011
|
+
await updateWorkflowRun2(runId, { status: "cancelled", error: cancelReason, finishedAt: now });
|
|
1012
|
+
}
|
|
1013
|
+
return { cancelled: rootStatus !== "cancelled", runIds };
|
|
972
1014
|
});
|
|
973
1015
|
}
|
|
974
|
-
|
|
975
|
-
|
|
1016
|
+
var inFlightCancels = new Map;
|
|
1017
|
+
function cancelWorkflowRun2(runId, reason) {
|
|
1018
|
+
const inFlight = inFlightCancels.get(runId);
|
|
1019
|
+
if (inFlight)
|
|
1020
|
+
return inFlight;
|
|
1021
|
+
const cancel = cancelWorkflowRunOnce(runId, reason).finally(() => {
|
|
1022
|
+
inFlightCancels.delete(runId);
|
|
1023
|
+
});
|
|
1024
|
+
inFlightCancels.set(runId, cancel);
|
|
1025
|
+
return cancel;
|
|
1026
|
+
}
|
|
1027
|
+
async function cancelWorkflowRunOnce(runId, reason) {
|
|
1028
|
+
const run = await getWorkflowRun2(runId, "display");
|
|
976
1029
|
if (!run)
|
|
977
1030
|
throw new Error("Workflow run not found");
|
|
978
|
-
|
|
979
|
-
if (terminalStatuses.includes(run.status) && run.status !== "cancelled") {
|
|
1031
|
+
if (TERMINAL_RUN_STATUSES.has(run.status) && run.status !== "cancelled") {
|
|
980
1032
|
throw new Error(`Cannot cancel run in '${run.status}' state`);
|
|
981
1033
|
}
|
|
982
1034
|
const cancelReason = reason ?? "Cancelled by user";
|
|
983
|
-
const
|
|
984
|
-
const
|
|
985
|
-
|
|
986
|
-
if (!applied && latestRun?.status !== "cancelled") {
|
|
1035
|
+
const { cancelled, runIds } = await cancelWorkflowRunRows2(runId, cancelReason);
|
|
1036
|
+
const latestRun = await getWorkflowRun2(runId, "display");
|
|
1037
|
+
if (!cancelled && latestRun?.status !== "cancelled") {
|
|
987
1038
|
throw new Error(`Cannot cancel run in '${latestRun?.status ?? "missing"}' state`);
|
|
988
1039
|
}
|
|
989
|
-
await
|
|
1040
|
+
await postTreeApprovalCancellations2(runIds, cancelled ? cancelReason : latestRun?.error ?? cancelReason);
|
|
1041
|
+
}
|
|
1042
|
+
async function postTreeApprovalCancellations2(runIds, reason, options = {}) {
|
|
1043
|
+
try {
|
|
1044
|
+
const approvals = [];
|
|
1045
|
+
for (const id of await listUndeliveredCancelledApprovalRequestIds(runIds)) {
|
|
1046
|
+
if (id === options.exceptRequestId)
|
|
1047
|
+
continue;
|
|
1048
|
+
const approval = await getApprovalRequestById2(id);
|
|
1049
|
+
if (approval)
|
|
1050
|
+
approvals.push(approval);
|
|
1051
|
+
}
|
|
1052
|
+
if (approvals.length > 0)
|
|
1053
|
+
await postApprovalCancellationUpdates(approvals, reason);
|
|
1054
|
+
} catch (err) {
|
|
1055
|
+
console.error("[workflows] approval cancellation updates not posted:", scrubSecrets(err instanceof Error ? err.message : String(err)));
|
|
1056
|
+
}
|
|
990
1057
|
}
|
|
991
1058
|
async function resumeFromApprovalResolution(event, registry) {
|
|
992
1059
|
await failClosedOnUnreadableReplay(event.workflowRunId, event.workflowRunStepId, () => resumeFromApprovalResolutionUnguarded(event, registry));
|
|
@@ -1084,6 +1151,8 @@ async function resumeFromChildRun2(parentStepId, registry) {
|
|
|
1084
1151
|
const current = await getWorkflowRunStep2(step.id);
|
|
1085
1152
|
if (!current || current.status !== "waiting")
|
|
1086
1153
|
return null;
|
|
1154
|
+
if (await getRunLineageBlock(run.id))
|
|
1155
|
+
return null;
|
|
1087
1156
|
const childId = await getChildWorkflowRunId(step.id, current.retryCount);
|
|
1088
1157
|
const child = childId ? await getWorkflowRun2(childId) : null;
|
|
1089
1158
|
const outcome = child ? childRunOutcome(child) : { error: `Child workflow run of step ${parentStepId} was deleted`, retryable: false };
|
|
@@ -1241,4 +1310,4 @@ function isPayloadInRun(payload, runId) {
|
|
|
1241
1310
|
const rec = payload;
|
|
1242
1311
|
return rec._runId === runId || rec.workflowRunId === runId;
|
|
1243
1312
|
}
|
|
1244
|
-
export { shapeApprovalResolution, SubWorkflowExecutor, WaitExecutor, failStepAndRunIfWaiting, checkpointPortStepAndResolveSuccessors, scheduleTaskStepRetry, completeTaskStepAndResolveSuccessors, setupWorkflowResumeListener2, finalizeOrWait2, retryFailedRun2, cancelWorkflowRunRows2, cancelWorkflowRun2, resumeWaitState2, recoverResolvedWaitState2, resumeFromChildRun2, initWaitBusSubscriptions2, subscribeWaitToBus2 };
|
|
1313
|
+
export { shapeApprovalResolution, SubWorkflowExecutor, WaitExecutor, failStepAndRunIfWaiting, checkpointPortStepAndResolveSuccessors, scheduleTaskStepRetry, completeTaskStepAndResolveSuccessors, setupWorkflowResumeListener2, finalizeOrWait2, retryFailedRun2, cancelWorkflowRunRows2, cancelWorkflowRun2, postTreeApprovalCancellations2, resumeWaitState2, recoverResolvedWaitState2, resumeFromChildRun2, initWaitBusSubscriptions2, subscribeWaitToBus2 };
|
|
@@ -7,7 +7,7 @@ var package_default;
|
|
|
7
7
|
var init_package = __esm(() => {
|
|
8
8
|
package_default = {
|
|
9
9
|
name: "@desplega.ai/agent-swarm",
|
|
10
|
-
version: "2.5.
|
|
10
|
+
version: "2.5.4",
|
|
11
11
|
description: "agent-swarm.dev — an open-source operating system for AI work: a lead agent breaks goals into tasks, routes them to specialized workers such as Claude Code or Codex, runs each worker in an isolated container, and preserves shared memory, tools, schedules, and review gates so delegated work compounds across sessions.",
|
|
12
12
|
keywords: [
|
|
13
13
|
"agent-swarm.dev",
|
|
@@ -61,7 +61,7 @@ var init_package = __esm(() => {
|
|
|
61
61
|
config: {
|
|
62
62
|
name: "agent-swarm"
|
|
63
63
|
},
|
|
64
|
-
packageManager: "bun@1.4.
|
|
64
|
+
packageManager: "bun@1.4.4",
|
|
65
65
|
workspaces: [
|
|
66
66
|
"apps/ui",
|
|
67
67
|
"apps/templates-ui",
|
|
@@ -206,10 +206,10 @@ var init_package = __esm(() => {
|
|
|
206
206
|
bun: ">=1.3.12"
|
|
207
207
|
},
|
|
208
208
|
dependencies: {
|
|
209
|
-
"@agentclientprotocol/sdk": "2.0.
|
|
209
|
+
"@agentclientprotocol/sdk": "2.0.2",
|
|
210
210
|
"@ai-sdk/openai": "^3.0.41",
|
|
211
|
-
"@anthropic-ai/claude-agent-sdk": "0.3.
|
|
212
|
-
"@anthropic-ai/sdk": "^1.
|
|
211
|
+
"@anthropic-ai/claude-agent-sdk": "0.3.310",
|
|
212
|
+
"@anthropic-ai/sdk": "^1.3.0",
|
|
213
213
|
"@asteasolutions/zod-to-openapi": "^8.0.0",
|
|
214
214
|
"@aws-sdk/client-bedrock": "3.1048.0",
|
|
215
215
|
"@chat-adapter/discord": "4.41.1",
|
|
@@ -10,7 +10,7 @@ import {
|
|
|
10
10
|
getMostRecentTaskInThread2,
|
|
11
11
|
reactionName,
|
|
12
12
|
init_db3
|
|
13
|
-
} from "./cli-
|
|
13
|
+
} from "./cli-jb30dzvk.js";
|
|
14
14
|
import {
|
|
15
15
|
TaskCreationBlockedError,
|
|
16
16
|
buildEffectiveText,
|
|
@@ -23,7 +23,7 @@ import {
|
|
|
23
23
|
extractTaskFromMessage,
|
|
24
24
|
extractSlackMessageText,
|
|
25
25
|
dispatchPre2
|
|
26
|
-
} from "./cli-
|
|
26
|
+
} from "./cli-asq5ydm4.js";
|
|
27
27
|
import {
|
|
28
28
|
noteSlackInboundSideEffect,
|
|
29
29
|
ignoreSlackInbound,
|
|
@@ -34,14 +34,14 @@ import {
|
|
|
34
34
|
isSlackRenderV2Enabled2,
|
|
35
35
|
ensureSlackThreadTree2,
|
|
36
36
|
registerTreeMessage
|
|
37
|
-
} from "./cli-
|
|
37
|
+
} from "./cli-abs8ndtr.js";
|
|
38
38
|
import {
|
|
39
39
|
isBlockExternalEnabled2,
|
|
40
40
|
invalidateChannelExternality2,
|
|
41
41
|
getChannelBlockReason2,
|
|
42
42
|
shouldBlockChannel2,
|
|
43
43
|
leaveExternalChannel2
|
|
44
|
-
} from "./cli-
|
|
44
|
+
} from "./cli-eftzyh9y.js";
|
|
45
45
|
import {
|
|
46
46
|
workflowEventBus2,
|
|
47
47
|
init_event_bus
|
|
@@ -50,7 +50,7 @@ import {
|
|
|
50
50
|
enrichSlackUserEmail,
|
|
51
51
|
resolveSlackUserId,
|
|
52
52
|
rewriteSlackMentions
|
|
53
|
-
} from "./cli-
|
|
53
|
+
} from "./cli-jbnn4vxb.js";
|
|
54
54
|
import {
|
|
55
55
|
wasEventSeen,
|
|
56
56
|
requestSlackThreadSteering,
|
|
@@ -58,11 +58,11 @@ import {
|
|
|
58
58
|
bufferThreadMessage,
|
|
59
59
|
getBufferMessageCount,
|
|
60
60
|
instantFlush
|
|
61
|
-
} from "./cli-
|
|
61
|
+
} from "./cli-wghjkr0e.js";
|
|
62
62
|
import {
|
|
63
63
|
resolveTemplate,
|
|
64
64
|
init_resolver
|
|
65
|
-
} from "./cli-
|
|
65
|
+
} from "./cli-dqygeeh5.js";
|
|
66
66
|
import {
|
|
67
67
|
init_zod
|
|
68
68
|
} from "./cli-4chz1hye.js";
|