@desplega.ai/agent-swarm 2.13.1 → 2.13.3
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/README.md +1 -1
- package/dist/acp-adapter-t2q6nsqv.js +17 -0
- package/dist/{acp-targets-n7vm5atw.js → acp-targets-k8xs4tj8.js} +7 -7
- package/dist/{actions-hq6wp9xv.js → actions-pg5fxjer.js} +25 -25
- package/dist/{agent-fs-provision-y0qc1rdd.js → agent-fs-provision-vbk3fppw.js} +4 -4
- package/dist/{amp-adapter-1qqs6h91.js → amp-adapter-adbhxsz9.js} +2 -2
- package/dist/{app-7m4z44rv.js → app-b267ggx1.js} +8 -8
- package/dist/{approval-notifications-8sr41gjx.js → approval-notifications-evc1a9z5.js} +9 -9
- package/dist/{assistant-hkczwfv6.js → assistant-wgz2ab84.js} +26 -26
- package/dist/{boot-args-schema-8025snev.js → boot-args-schema-6tpk28j4.js} +1 -1
- package/dist/{boot-reembed-15m87nr1.js → boot-reembed-ankp369c.js} +1 -1
- package/dist/{boot-reembed-4bbpxjh1.js → boot-reembed-r1zyvefv.js} +1 -1
- package/dist/{boot-scrub-sweep-eajr97e9.js → boot-scrub-sweep-cgb6r5bd.js} +2 -2
- package/dist/{boot-seeds-9cwy39jx.js → boot-seeds-bjceqg7b.js} +4 -4
- package/dist/{claude-adapter-g61wa4rt.js → claude-adapter-knztdnff.js} +9 -6
- package/dist/{claude-managed-adapter-znkk0prm.js → claude-managed-adapter-qwejzqkk.js} +3 -3
- package/dist/{claude-managed-setup-f1wndkr2.js → claude-managed-setup-0vgz4d1j.js} +4 -4
- package/dist/{claude-sdk-session-687xzf21.js → claude-sdk-session-c3g6dv0g.js} +11984 -11775
- package/dist/{cli-4mj5g29m.js → cli-0j4qmc80.js} +7 -7
- package/dist/{cli-fn8aj7gb.js → cli-1606qw3n.js} +98 -71
- package/dist/{cli-w41bvvms.js → cli-1gnf5c7x.js} +1 -1
- package/dist/{cli-aebswqmz.js → cli-1wew39p0.js} +15 -15
- package/dist/{cli-0fx95c06.js → cli-268b3dgn.js} +2 -2
- package/dist/cli-2ap1the6.js +11 -0
- package/dist/{cli-w6c6dj91.js → cli-4dyhzhpx.js} +1 -1
- package/dist/{cli-grcc2h2g.js → cli-55fqpd9q.js} +8 -8
- package/dist/{cli-p7g7wd9n.js → cli-61fzwtjk.js} +7 -7
- package/dist/{cli-zaate0rd.js → cli-61p7ty8d.js} +2 -2
- package/dist/{cli-cp0m07wb.js → cli-7fa6yv98.js} +2 -2
- package/dist/{cli-5v6b2am8.js → cli-7kv5d674.js} +7 -7
- package/dist/{cli-6r1dwegd.js → cli-80d5g0fa.js} +2 -2
- package/dist/{cli-0xwb7zpt.js → cli-88np9va3.js} +1 -1
- package/dist/{cli-1b5axkt1.js → cli-8m6gqnf1.js} +2 -2
- package/dist/{cli-0a336ze7.js → cli-8pnawt98.js} +3 -3
- package/dist/{cli-7ewre3dm.js → cli-8sayvj48.js} +2 -2
- package/dist/{cli-yeh3g1q6.js → cli-9gmkw6xn.js} +53 -32
- package/dist/{cli-h03j6je3.js → cli-a21cwm89.js} +2 -2
- package/dist/{cli-s6fhqbz1.js → cli-aytna2fm.js} +1 -1
- package/dist/{cli-84xtgbn6.js → cli-b0m3bg0f.js} +100 -2
- package/dist/{cli-mwxez0pz.js → cli-b768ek79.js} +1 -1
- package/dist/{cli-9xx36trj.js → cli-bh53ppqm.js} +2 -2
- package/dist/{cli-1carhg8g.js → cli-czeh7x13.js} +3 -3
- package/dist/{cli-cd9acnvd.js → cli-djwt4mtn.js} +71 -5
- package/dist/{cli-sfajkbd7.js → cli-dq30fq3q.js} +2 -2
- package/dist/{cli-a8ts6x1n.js → cli-dw43pnzp.js} +5 -5
- package/dist/{cli-h9bejmkf.js → cli-e4gx499y.js} +52 -29
- package/dist/{cli-t90k0phh.js → cli-ea367bdn.js} +32 -23
- package/dist/{cli-cmgdptmx.js → cli-ef590376.js} +29 -5
- package/dist/{cli-8rbkw18r.js → cli-fbmgpt72.js} +2 -2
- package/dist/{cli-tzzas8rb.js → cli-g4dhd3pr.js} +2 -2
- package/dist/{cli-snypfjgj.js → cli-gc715jrc.js} +1 -1
- package/dist/{cli-c0tyzt73.js → cli-gkjw33x5.js} +1 -1
- package/dist/{cli-z6m6xzxt.js → cli-grk77aen.js} +26 -5
- package/dist/{cli-hs3mqswp.js → cli-gxqwm3k3.js} +5 -5
- package/dist/{cli-4h90xaet.js → cli-h3drhntp.js} +1 -1
- package/dist/{cli-qn79645p.js → cli-h9d3sdnc.js} +1 -1
- package/dist/{cli-byxsctca.js → cli-hd2a204w.js} +6 -6
- package/dist/{cli-1dr5at77.js → cli-hhb8kbwd.js} +12 -12
- package/dist/{cli-zvpkrgsc.js → cli-hpxcfvdm.js} +3 -3
- package/dist/{cli-cqxwjb93.js → cli-hxj888w3.js} +1 -1
- package/dist/{cli-82j36f2m.js → cli-jjzxsk47.js} +9 -3
- package/dist/{cli-13t0smbk.js → cli-ka4tqjzd.js} +185 -58
- package/dist/{cli-jhtvt7gn.js → cli-kh973792.js} +3 -3
- package/dist/{cli-x5yb8zc8.js → cli-kwm1bek7.js} +1 -1
- package/dist/{cli-bjmq14k9.js → cli-mgr3gatr.js} +4 -4
- package/dist/{cli-c8kqmzzf.js → cli-nbawx3s0.js} +2 -2
- package/dist/{cli-04103ryh.js → cli-ppf9ap9n.js} +1 -1
- package/dist/{cli-dd57p1gd.js → cli-pzsedyb0.js} +4 -4
- package/dist/{cli-32xndx6b.js → cli-r6xnchva.js} +2 -2
- package/dist/{cli-4tbvndmm.js → cli-r8ddn0hf.js} +1 -1
- package/dist/{cli-y6qqbpwc.js → cli-snwz16eg.js} +1 -1
- package/dist/{cli-w24f3j49.js → cli-sy2ge2ye.js} +7 -6
- package/dist/{cli-3m8vqehw.js → cli-syqcny89.js} +3 -3
- package/dist/{cli-qx1dwrr5.js → cli-tjf1bh1v.js} +2 -2
- package/dist/{cli-xhkek467.js → cli-v1v49t36.js} +28 -2
- package/dist/{cli-cn6fpa1p.js → cli-v8rpjrnx.js} +1 -1
- package/dist/{cli-mmw2sjaf.js → cli-vgh5adn9.js} +5 -5
- package/dist/{cli-3zyme1wt.js → cli-w24741sm.js} +3 -3
- package/dist/{cli-gq6qhmrr.js → cli-wsnradtk.js} +3 -3
- package/dist/{cli-nk8swfpx.js → cli-wtffytm8.js} +3 -3
- package/dist/{cli-0m77n7ej.js → cli-xc8m5cjn.js} +54 -12
- package/dist/{cli-8cmjkbvj.js → cli-y0q92v4r.js} +2 -2
- package/dist/{cli-gedf48yw.js → cli-y754psdt.js} +4 -4
- package/dist/cli.js +19 -18
- package/dist/{codex-adapter-ysfg6ty3.js → codex-adapter-493vb8cv.js} +5 -5
- package/dist/{codex-hook-c0nvm30r.js → codex-hook-ej8hn6z5.js} +9 -2
- package/dist/{codex-session-runner-823scr6g.js → codex-session-runner-ps5m4z1g.js} +5 -5
- package/dist/{commands-5rbm07fz.js → commands-shktk0b8.js} +3 -3
- package/dist/{controllers-connect-34jzhfft.js → controllers-connect-yft057ws.js} +24 -24
- package/dist/core-nheayfgm.js +42 -0
- package/dist/{cursor-adapter-w1681kp1.js → cursor-adapter-8fpm4dng.js} +1 -1
- package/dist/{db-6bkgbfwk.js → db-0ezhdhz5.js} +3 -3
- package/dist/{db-hcj16x7z.js → db-84pz2w5c.js} +2 -2
- package/dist/{dispatcher-jgjqrfzv.js → dispatcher-h2rz69f6.js} +23 -23
- package/dist/{easter-egg-3d-w17nsny6.js → easter-egg-3d-m41ad78v.js} +1 -1
- package/dist/{embedding-space-v06fwy7b.js → embedding-space-yam9zwzj.js} +6 -6
- package/dist/{embeddings-g50dxea4.js → embeddings-g2be0y8q.js} +1 -1
- package/dist/{execute-1n36haw1.js → execute-hhdejgzf.js} +1 -1
- package/dist/{external-channel-43tv8pg6.js → external-channel-kjt2yzfj.js} +2 -2
- package/dist/fx-adapter-8g7xsp8q.js +20 -0
- package/dist/{grok-adapter-my5j8mdf.js → grok-adapter-ztk2zkz1.js} +9 -9
- package/dist/handlers-9ywssz71.js +41 -0
- package/dist/{heartbeat-sf3nk937.js → heartbeat-2e5jdexj.js} +25 -25
- package/dist/{hook-dqph1e05.js → hook-34s8cmgn.js} +9 -6
- package/dist/{hook-m1m9dm6w.js → hook-acg9saz7.js} +8 -5
- package/dist/{http-w0th1cz9.js → http-ra2zr2f8.js} +304 -111
- package/dist/{index-pb03vans.js → index-2z1z7qx6.js} +26 -26
- package/dist/{index-p2f5xg64.js → index-3j803vnb.js} +36259 -34299
- package/dist/index-6mgbdtv1.js +44 -0
- package/dist/{index-e8pz8qdg.js → index-7dgxveck.js} +2 -2
- package/dist/{index-gkpfgpg7.js → index-93bw5wds.js} +1 -1
- package/dist/{index-c0e8en64.js → index-9q42cr54.js} +1 -1
- package/dist/{index-ffba0z8q.js → index-9r4j0a60.js} +28 -18
- package/dist/index-hqdsn2t2.js +39 -0
- package/dist/{index-k8ajc0g0.js → index-maddg9ys.js} +1 -1
- package/dist/{index-y4vd4mhn.js → index-mbpxhc4w.js} +1 -1
- package/dist/index-rz8ve510.js +569 -0
- package/dist/index-st231bqv.js +40 -0
- package/dist/{index-ez823q84.js → index-ym9fgxad.js} +1 -1
- package/dist/{keepalive-2v06q2e8.js → keepalive-vjnnqbkm.js} +4 -4
- package/dist/lead-mk0xkth2.js +82 -0
- package/dist/{maintenance-vx7vjhhy.js → maintenance-px2g599e.js} +1 -1
- package/dist/{oauth-refresh-sweep-g06k4bza.js → oauth-refresh-sweep-nkykf09m.js} +3 -3
- package/dist/{object-webhooks-3dzdq4fm.js → object-webhooks-gt9xnq21.js} +7 -7
- package/dist/{onboard-232pazny.js → onboard-1f134p65.js} +3 -3
- package/dist/{opencode-adapter-t0paqbh8.js → opencode-adapter-94976yab.js} +6 -6
- package/dist/{otel-impl-kmpkyp4y.js → otel-impl-5d4p2fqs.js} +1 -1
- package/dist/{pending-x0z3vx1x.js → pending-vkk0vx6n.js} +24 -24
- package/dist/{pi-mono-adapter-7pmypn6d.js → pi-mono-adapter-cyzdv5er.js} +11 -11
- package/dist/{pricing-refresh-ytjmtyd7.js → pricing-refresh-jtmjwss9.js} +2 -2
- package/dist/{rbac-roles-xyaxekh3.js → rbac-roles-1fvmdyeb.js} +2 -2
- package/dist/{rbac-roles-fgm5mxr2.js → rbac-roles-yd1fgpsn.js} +3 -3
- package/dist/{render-v2-ws972g4r.js → render-v2-kb5s3vx4.js} +8 -8
- package/dist/{resume-m6mjzhkp.js → resume-z1vs44n5.js} +11 -11
- package/dist/{runtime-zzpc0c8a.js → runtime-gk6ct7r7.js} +1 -1
- package/dist/{session-access-vp35xs91.js → session-access-nz6nre4d.js} +5 -5
- package/dist/{session-source-backfill-p73e8zbe.js → session-source-backfill-wb60zjkd.js} +1 -1
- package/dist/{setup-r4kd7rxg.js → setup-2x8g8j4s.js} +1 -1
- package/dist/thread-buffer-d50rqpev.js +42 -0
- package/dist/{tree-visibility-07h2tbs2.js → tree-visibility-ts3z30kw.js} +2 -2
- package/dist/{user-merge-jobs-96vg9rpe.js → user-merge-jobs-zetg26e0.js} +3 -3
- package/dist/{virtual-modules-vgn3f2x4.js → virtual-modules-674fka8x.js} +3 -3
- package/dist/{work-objects-74hbcx3e.js → work-objects-w52yyjxm.js} +26 -26
- package/dist/worker-662x1vse.js +82 -0
- package/dist/{worker-follow-up-ezavwn5d.js → worker-follow-up-dyfxyjbj.js} +23 -23
- package/openapi.json +6 -2
- package/package.json +7 -6
- package/src/be/migrations/341_user_token_expiry.sql +4 -0
- package/src/be/scripts/run-credential.ts +55 -1
- package/src/be/scripts/typecheck.ts +4 -4
- package/src/be/scripts/user-code-mode.ts +160 -0
- package/src/be/users.ts +48 -7
- package/src/commands/onboard/agent-fs-version.ts +1 -1
- package/src/commands/runner.ts +62 -6
- package/src/hooks/codex-hook.ts +15 -4
- package/src/hooks/hook.ts +7 -0
- package/src/http/script-connection-proxy.ts +18 -6
- package/src/http/scripts.ts +2 -11
- package/src/http/session-cost-recompute.ts +3 -1
- package/src/http/session-data.ts +3 -0
- package/src/http/users.ts +1 -0
- package/src/integrations/chat-sdk/adapters.ts +29 -0
- package/src/integrations/chat-sdk/limits.ts +3 -0
- package/src/integrations/chat-sdk/rocketchat/README.md +8 -0
- package/src/integrations/chat-sdk/rocketchat/index.ts +790 -0
- package/src/integrations/chat-sdk/rocketchat/markdown.ts +210 -0
- package/src/integrations/chat-sdk/rocketchat/types.ts +249 -0
- package/src/integrations/chat-sdk/runtime.ts +11 -5
- package/src/integrations/chat-sdk/schema.ts +37 -3
- package/src/integrations/chat-sdk/status.ts +9 -0
- package/src/prompts/base-prompt.ts +1 -1
- package/src/prompts/session-templates.ts +1 -1
- package/src/providers/acp-targets.ts +2 -2
- package/src/providers/amp-adapter.ts +1 -1
- package/src/providers/claude-adapter.ts +21 -1
- package/src/providers/claude-sdk-session.ts +22 -3
- package/src/providers/claude-session-events.ts +76 -1
- package/src/providers/cursor-adapter.ts +1 -1
- package/src/providers/fx-adapter.ts +2 -2
- package/src/providers/pricing-sources.md +3 -0
- package/src/providers/types.ts +13 -0
- package/src/rbac/legacy-policy.ts +1 -0
- package/src/rbac/permissions.ts +4 -0
- package/src/scripts-runtime/executors/native.ts +225 -67
- package/src/scripts-runtime/mcp-client.ts +2 -1
- package/src/scripts-runtime/swarm-sdk.ts +2 -1
- package/src/scripts-runtime/types/stdlib.d.ts +4 -4
- package/src/scripts-runtime/types/swarm-sdk.d.ts +4 -4
- package/src/server-user.ts +98 -0
- package/src/slack/render-v2.ts +27 -7
- package/src/tests/base-prompt.test.ts +6 -2
- package/src/tests/chat-sdk-rocketchat-vendored.test.ts +67 -0
- package/src/tests/chat-sdk-status-route.test.ts +13 -1
- package/src/tests/claude-adapter.test.ts +115 -0
- package/src/tests/codex-app-server.test.ts +4 -6
- package/src/tests/fixtures/fx/acp-updates-recorded.jsonl +1 -1
- package/src/tests/internal-ai/complete-structured.test.ts +105 -0
- package/src/tests/internal-ai/credentials.test.ts +149 -0
- package/src/tests/internal-ai/task-title.test.ts +78 -0
- package/src/tests/mcp-input-caps.test.ts +16 -11
- package/src/tests/mcp-user-route.test.ts +10 -1
- package/src/tests/runner-slot-reconcile.test.ts +102 -0
- package/src/tests/script-connections-mcp.test.ts +14 -10
- package/src/tests/script-connections-sql.test.ts +6 -2
- package/src/tests/script-connections.test.ts +2 -0
- package/src/tests/slack-render-v2.test.ts +85 -0
- package/src/tools/script-common.ts +37 -22
- package/src/tools/script-query-types.ts +1 -1
- package/src/tools/script-run.ts +1 -1
- package/src/tools/script-search.ts +12 -10
- package/src/tools/utils.ts +7 -1
- package/src/types.ts +2 -1
- package/src/utils/internal-ai/complete-structured.ts +36 -5
- package/src/utils/internal-ai/credentials.ts +78 -2
- package/src/utils/internal-ai/models.ts +37 -1
- package/src/utils/internal-ai/task-title.ts +31 -1
- package/templates/skills/chat-sdk/content.md +2 -2
- package/templates/skills/swarm-docs/content.md +10 -0
- package/dist/acp-adapter-xtj40wd8.js +0 -17
- package/dist/core-kdehq26g.js +0 -42
- package/dist/fx-adapter-bvh05t4a.js +0 -20
- package/dist/handlers-wyymeeqh.js +0 -41
- package/dist/index-22khdtby.js +0 -44
- package/dist/index-np0582ac.js +0 -40
- package/dist/index-vgkrj1jt.js +0 -39
- package/dist/lead-55z813ng.js +0 -79
- package/dist/thread-buffer-cm2nzq6t.js +0 -42
- package/dist/worker-5pn2vzx6.js +0 -79
- /package/dist/{cli-m4ejz4nj.js → cli-cah298e5.js} +0 -0
|
@@ -393,3 +393,152 @@ describe("resolveCredentials", () => {
|
|
|
393
393
|
expect(probed).toBe(2);
|
|
394
394
|
});
|
|
395
395
|
});
|
|
396
|
+
|
|
397
|
+
describe("fireworks", () => {
|
|
398
|
+
test("FIREWORKS_API_KEY resolves through env and through pi-ai's key lookup", async () => {
|
|
399
|
+
for (const source of ["env", "fallback"] as const) {
|
|
400
|
+
const cred = await resolveCredential(
|
|
401
|
+
makeOpts({
|
|
402
|
+
env: source === "env" ? { FIREWORKS_API_KEY: "fw-key" } : {},
|
|
403
|
+
_getEnvApiKey: (provider) =>
|
|
404
|
+
source === "fallback" && provider === "fireworks" ? "fw-key" : undefined,
|
|
405
|
+
}),
|
|
406
|
+
);
|
|
407
|
+
expect(cred?.kind).toBe("fireworks");
|
|
408
|
+
if (cred?.kind === "fireworks") {
|
|
409
|
+
expect(cred.apiKey).toBe("fw-key");
|
|
410
|
+
expect(cred.modelDefault).toBe("fireworks/accounts/fireworks/models/deepseek-v4p1-flash");
|
|
411
|
+
}
|
|
412
|
+
}
|
|
413
|
+
});
|
|
414
|
+
|
|
415
|
+
test("a comma-separated pool picks one member, never the joined string", async () => {
|
|
416
|
+
const cred = await resolveCredential(
|
|
417
|
+
makeOpts({ env: { FIREWORKS_API_KEY: "fw-first, fw-second" } }),
|
|
418
|
+
);
|
|
419
|
+
expect(cred?.kind).toBe("fireworks");
|
|
420
|
+
if (cred?.kind === "fireworks") {
|
|
421
|
+
expect(["fw-first", "fw-second"]).toContain(cred.apiKey);
|
|
422
|
+
}
|
|
423
|
+
});
|
|
424
|
+
|
|
425
|
+
test("FIREWORKS_API_KEY does not outrank a key an operator set for this layer", async () => {
|
|
426
|
+
// Precedence decision: existing callers keep their provider.
|
|
427
|
+
for (const earlier of ["OPENROUTER_API_KEY", "ANTHROPIC_API_KEY", "OPENAI_API_KEY"]) {
|
|
428
|
+
const cred = await resolveCredential(
|
|
429
|
+
makeOpts({ env: { FIREWORKS_API_KEY: "fw", [earlier]: "earlier-key" } }),
|
|
430
|
+
);
|
|
431
|
+
expect(cred?.kind).not.toBe("fireworks");
|
|
432
|
+
}
|
|
433
|
+
const only = await resolveCredential(makeOpts({ env: { FIREWORKS_API_KEY: "fw" } }));
|
|
434
|
+
expect(only?.kind).toBe("fireworks");
|
|
435
|
+
});
|
|
436
|
+
});
|
|
437
|
+
|
|
438
|
+
describe("amazon-bedrock", () => {
|
|
439
|
+
/** pi-ai's `getEnvApiKey` answers the sentinel when the AWS chain is configured. */
|
|
440
|
+
const awsChain = (provider: string) =>
|
|
441
|
+
provider === "amazon-bedrock" ? "<authenticated>" : undefined;
|
|
442
|
+
|
|
443
|
+
test("resolves from the credential chain plus a region, with no apiKey field", async () => {
|
|
444
|
+
const cred = await resolveCredential(
|
|
445
|
+
makeOpts({
|
|
446
|
+
env: { AWS_PROFILE: "example-profile", AWS_REGION: "eu-west-1" },
|
|
447
|
+
_getEnvApiKey: awsChain,
|
|
448
|
+
}),
|
|
449
|
+
);
|
|
450
|
+
expect(cred).toEqual({
|
|
451
|
+
kind: "amazon-bedrock",
|
|
452
|
+
modelDefault: "amazon-bedrock/global.anthropic.claude-haiku-5-5",
|
|
453
|
+
region: "eu-west-1",
|
|
454
|
+
});
|
|
455
|
+
// The shape is the design decision: there is no apiKey to fabricate.
|
|
456
|
+
expect(cred && "apiKey" in cred).toBe(false);
|
|
457
|
+
});
|
|
458
|
+
|
|
459
|
+
test("AWS_DEFAULT_REGION is accepted when AWS_REGION is unset", async () => {
|
|
460
|
+
const cred = await resolveCredential(
|
|
461
|
+
makeOpts({
|
|
462
|
+
env: { AWS_PROFILE: "p", AWS_DEFAULT_REGION: "us-west-2" },
|
|
463
|
+
_getEnvApiKey: awsChain,
|
|
464
|
+
}),
|
|
465
|
+
);
|
|
466
|
+
expect(cred?.kind).toBe("amazon-bedrock");
|
|
467
|
+
if (cred?.kind === "amazon-bedrock") expect(cred.region).toBe("us-west-2");
|
|
468
|
+
});
|
|
469
|
+
|
|
470
|
+
test("an empty or blank AWS_REGION falls back to AWS_DEFAULT_REGION", async () => {
|
|
471
|
+
// A compose file writes `AWS_REGION=${AWS_REGION:-}`, which sets the var to
|
|
472
|
+
// an empty string. `??` would keep that and discard the real region, and
|
|
473
|
+
// Bedrock would be skipped despite a valid AWS_DEFAULT_REGION.
|
|
474
|
+
for (const blank of ["", " "]) {
|
|
475
|
+
const cred = await resolveCredential(
|
|
476
|
+
makeOpts({
|
|
477
|
+
env: { AWS_PROFILE: "p", AWS_REGION: blank, AWS_DEFAULT_REGION: "eu-west-1" },
|
|
478
|
+
_getEnvApiKey: awsChain,
|
|
479
|
+
}),
|
|
480
|
+
);
|
|
481
|
+
expect(cred?.kind).toBe("amazon-bedrock");
|
|
482
|
+
if (cred?.kind === "amazon-bedrock") expect(cred.region).toBe("eu-west-1");
|
|
483
|
+
}
|
|
484
|
+
});
|
|
485
|
+
|
|
486
|
+
test("no region → clean no-op rather than a guessed us-east-1", async () => {
|
|
487
|
+
const cred = await resolveCredential(
|
|
488
|
+
makeOpts({ env: { AWS_PROFILE: "p" }, _getEnvApiKey: awsChain }),
|
|
489
|
+
);
|
|
490
|
+
expect(cred).toBeNull();
|
|
491
|
+
});
|
|
492
|
+
|
|
493
|
+
test("no credential chain → clean no-op even with a region", async () => {
|
|
494
|
+
expect(await resolveCredential(makeOpts({ env: { AWS_REGION: "us-east-1" } }))).toBeNull();
|
|
495
|
+
});
|
|
496
|
+
|
|
497
|
+
test("region whitespace alone is not a region", async () => {
|
|
498
|
+
const cred = await resolveCredential(
|
|
499
|
+
makeOpts({ env: { AWS_PROFILE: "p", AWS_REGION: " " }, _getEnvApiKey: awsChain }),
|
|
500
|
+
);
|
|
501
|
+
expect(cred).toBeNull();
|
|
502
|
+
});
|
|
503
|
+
|
|
504
|
+
test("sits after fireworks and after every key-based kind", async () => {
|
|
505
|
+
const withKeys = await resolveCredentials(
|
|
506
|
+
makeOpts({
|
|
507
|
+
env: {
|
|
508
|
+
OPENROUTER_API_KEY: "or",
|
|
509
|
+
FIREWORKS_API_KEY: "fw",
|
|
510
|
+
AWS_PROFILE: "p",
|
|
511
|
+
AWS_REGION: "us-east-1",
|
|
512
|
+
},
|
|
513
|
+
_getEnvApiKey: awsChain,
|
|
514
|
+
}),
|
|
515
|
+
);
|
|
516
|
+
expect(withKeys.map((cred) => cred.kind)).toEqual([
|
|
517
|
+
"openrouter",
|
|
518
|
+
"fireworks",
|
|
519
|
+
"amazon-bedrock",
|
|
520
|
+
]);
|
|
521
|
+
|
|
522
|
+
const ambientOnly = await resolveCredentials(
|
|
523
|
+
makeOpts({
|
|
524
|
+
env: { AWS_PROFILE: "p", AWS_REGION: "us-east-1" },
|
|
525
|
+
_getEnvApiKey: awsChain,
|
|
526
|
+
}),
|
|
527
|
+
);
|
|
528
|
+
expect(ambientOnly.map((cred) => cred.kind)).toEqual(["amazon-bedrock"]);
|
|
529
|
+
});
|
|
530
|
+
|
|
531
|
+
test("a pinned rater model applies to the bedrock credential too", async () => {
|
|
532
|
+
const saved = process.env.MEMORY_RATER_MODEL;
|
|
533
|
+
process.env.MEMORY_RATER_MODEL = "amazon-bedrock/us.anthropic.claude-haiku-5-5";
|
|
534
|
+
try {
|
|
535
|
+
const cred = await resolveCredential(
|
|
536
|
+
makeOpts({ env: { AWS_PROFILE: "p", AWS_REGION: "us-east-1" }, _getEnvApiKey: awsChain }),
|
|
537
|
+
);
|
|
538
|
+
expect(cred?.modelDefault).toBe("amazon-bedrock/us.anthropic.claude-haiku-5-5");
|
|
539
|
+
} finally {
|
|
540
|
+
if (saved === undefined) delete process.env.MEMORY_RATER_MODEL;
|
|
541
|
+
else process.env.MEMORY_RATER_MODEL = saved;
|
|
542
|
+
}
|
|
543
|
+
});
|
|
544
|
+
});
|
|
@@ -1,10 +1,16 @@
|
|
|
1
1
|
import { describe, expect, test } from "bun:test";
|
|
2
|
+
import { getBuiltinModel } from "@earendil-works/pi-ai/providers/all";
|
|
2
3
|
import type { completeStructuredWithModel } from "../../utils/internal-ai/complete-structured.js";
|
|
3
4
|
import type {
|
|
4
5
|
CredentialKind,
|
|
5
6
|
ResolvedCredential,
|
|
6
7
|
resolveCredentials,
|
|
7
8
|
} from "../../utils/internal-ai/credentials.js";
|
|
9
|
+
import {
|
|
10
|
+
DEFAULT_MODEL,
|
|
11
|
+
MEMORY_RATER_DEFAULT_MODEL,
|
|
12
|
+
parseModelStr,
|
|
13
|
+
} from "../../utils/internal-ai/models.js";
|
|
8
14
|
import {
|
|
9
15
|
buildTaskTitlePlan,
|
|
10
16
|
generateTaskTitle,
|
|
@@ -108,6 +114,8 @@ describe("buildTaskTitlePlan", () => {
|
|
|
108
114
|
"anthropic",
|
|
109
115
|
"openai-codex",
|
|
110
116
|
"claude-cli",
|
|
117
|
+
"fireworks",
|
|
118
|
+
"amazon-bedrock",
|
|
111
119
|
]);
|
|
112
120
|
});
|
|
113
121
|
|
|
@@ -132,6 +140,49 @@ describe("buildTaskTitlePlan", () => {
|
|
|
132
140
|
expect(kindForModelString("haiku")).toBe("claude-cli");
|
|
133
141
|
expect(kindForModelString("mistral/ministral-3b")).toBeNull();
|
|
134
142
|
});
|
|
143
|
+
|
|
144
|
+
test("kindForModelString recognises the two new providers", () => {
|
|
145
|
+
expect(kindForModelString("fireworks/accounts/fireworks/models/deepseek-v4p1-flash")).toBe(
|
|
146
|
+
"fireworks",
|
|
147
|
+
);
|
|
148
|
+
expect(kindForModelString("amazon-bedrock/global.anthropic.claude-haiku-5-5")).toBe(
|
|
149
|
+
"amazon-bedrock",
|
|
150
|
+
);
|
|
151
|
+
// No regression on the compound-id and bare-alias shapes.
|
|
152
|
+
expect(kindForModelString("openrouter/anthropic/claude-haiku-5.5")).toBe("openrouter");
|
|
153
|
+
expect(kindForModelString("sonnet")).toBe("claude-cli");
|
|
154
|
+
});
|
|
155
|
+
|
|
156
|
+
test("pinning either new provider moves it first with its own fallbacks", () => {
|
|
157
|
+
const fireworks = buildTaskTitlePlan({
|
|
158
|
+
[TASK_TITLE_MODEL_ENV]: "fireworks/accounts/fireworks/routers/kimi-k3-fast",
|
|
159
|
+
});
|
|
160
|
+
expect(fireworks[0]).toEqual({
|
|
161
|
+
kind: "fireworks",
|
|
162
|
+
models: [
|
|
163
|
+
"fireworks/accounts/fireworks/routers/kimi-k3-fast",
|
|
164
|
+
"fireworks/accounts/fireworks/models/deepseek-v4p1-flash",
|
|
165
|
+
"fireworks/accounts/fireworks/models/glm-5p3-flash",
|
|
166
|
+
],
|
|
167
|
+
});
|
|
168
|
+
|
|
169
|
+
const bedrock = buildTaskTitlePlan({
|
|
170
|
+
[TASK_TITLE_MODEL_ENV]: "amazon-bedrock/eu.anthropic.claude-haiku-5-5",
|
|
171
|
+
});
|
|
172
|
+
expect(bedrock[0].kind).toBe("amazon-bedrock");
|
|
173
|
+
expect(bedrock[0].models[0]).toBe("amazon-bedrock/eu.anthropic.claude-haiku-5-5");
|
|
174
|
+
// A region-scoped pin does not displace the shipped defaults behind it.
|
|
175
|
+
expect(bedrock[0].models).toContain("amazon-bedrock/global.anthropic.claude-haiku-5-5");
|
|
176
|
+
expect(bedrock.map((group) => group.kind)).toEqual([
|
|
177
|
+
"amazon-bedrock",
|
|
178
|
+
"openrouter",
|
|
179
|
+
"anthropic",
|
|
180
|
+
"openai",
|
|
181
|
+
"openai-codex",
|
|
182
|
+
"claude-cli",
|
|
183
|
+
"fireworks",
|
|
184
|
+
]);
|
|
185
|
+
});
|
|
135
186
|
});
|
|
136
187
|
|
|
137
188
|
describe("generateTaskTitle", () => {
|
|
@@ -281,3 +332,30 @@ describe("generateTaskTitle", () => {
|
|
|
281
332
|
expect(models).toEqual([]);
|
|
282
333
|
});
|
|
283
334
|
});
|
|
335
|
+
|
|
336
|
+
describe("catalog verification for the new kinds", () => {
|
|
337
|
+
// Every default the registries name must resolve in pi-ai's own catalog: a
|
|
338
|
+
// miss is a silent null from `completeStructured`, which would leave titling
|
|
339
|
+
// and summarization dead in exactly the deployments this change is for.
|
|
340
|
+
test("DEFAULT_MODEL and MEMORY_RATER_DEFAULT_MODEL all exist in pi-ai's catalog", () => {
|
|
341
|
+
for (const registry of [DEFAULT_MODEL, MEMORY_RATER_DEFAULT_MODEL]) {
|
|
342
|
+
for (const [kind, modelStr] of Object.entries(registry)) {
|
|
343
|
+
if (kind === "claude-cli") continue; // a `claude -p` alias, not a pi-ai model
|
|
344
|
+
const [provider, modelId] = parseModelStr(modelStr);
|
|
345
|
+
expect(provider).toBe(kind);
|
|
346
|
+
expect(getBuiltinModel(provider as never, modelId as never)).toBeTruthy();
|
|
347
|
+
}
|
|
348
|
+
}
|
|
349
|
+
});
|
|
350
|
+
|
|
351
|
+
test("every titling candidate resolves in pi-ai's catalog", () => {
|
|
352
|
+
for (const group of TASK_TITLE_MODEL_CANDIDATES) {
|
|
353
|
+
if (group.kind === "claude-cli") continue;
|
|
354
|
+
for (const modelStr of group.models) {
|
|
355
|
+
const [provider, modelId] = parseModelStr(modelStr);
|
|
356
|
+
expect(provider).toBe(group.kind);
|
|
357
|
+
expect(getBuiltinModel(provider as never, modelId as never)).toBeTruthy();
|
|
358
|
+
}
|
|
359
|
+
}
|
|
360
|
+
});
|
|
361
|
+
});
|
|
@@ -166,7 +166,12 @@ async function openSession(path: string, headers: Record<string, string>): Promi
|
|
|
166
166
|
return init.sessionId;
|
|
167
167
|
}
|
|
168
168
|
|
|
169
|
-
/**
|
|
169
|
+
/**
|
|
170
|
+
* POST `totalBytes` with no Content-Length (chunked), so only the streaming cap can stop it.
|
|
171
|
+
* The body is never ended: the server answers 413 and closes the socket as soon as the cap is
|
|
172
|
+
* crossed. Bytes still in flight at that point make the close a TCP reset that can drop the
|
|
173
|
+
* response, so callers send exactly one byte over the cap.
|
|
174
|
+
*/
|
|
170
175
|
function postChunked(
|
|
171
176
|
path: string,
|
|
172
177
|
headers: Record<string, string>,
|
|
@@ -188,25 +193,25 @@ function postChunked(
|
|
|
188
193
|
body += chunk;
|
|
189
194
|
});
|
|
190
195
|
res.on("error", reject);
|
|
191
|
-
res.on("end", () =>
|
|
196
|
+
res.on("end", () => {
|
|
197
|
+
resolve({ status: res.statusCode ?? 0, body });
|
|
198
|
+
req.destroy();
|
|
199
|
+
});
|
|
192
200
|
},
|
|
193
201
|
);
|
|
194
|
-
//
|
|
195
|
-
req.on("error",
|
|
196
|
-
if (error.code === "EPIPE") return;
|
|
197
|
-
reject(error);
|
|
198
|
-
});
|
|
202
|
+
// An error after the response is complete is just our own teardown.
|
|
203
|
+
req.on("error", reject);
|
|
199
204
|
const chunk = Buffer.alloc(64 * 1024, 0x20);
|
|
200
205
|
let sent = 0;
|
|
201
206
|
const pump = () => {
|
|
202
207
|
while (sent < totalBytes) {
|
|
203
|
-
|
|
204
|
-
|
|
208
|
+
const part = chunk.subarray(0, Math.min(chunk.byteLength, totalBytes - sent));
|
|
209
|
+
sent += part.byteLength;
|
|
210
|
+
if (!req.write(part)) {
|
|
205
211
|
req.once("drain", pump);
|
|
206
212
|
return;
|
|
207
213
|
}
|
|
208
214
|
}
|
|
209
|
-
req.end();
|
|
210
215
|
};
|
|
211
216
|
pump();
|
|
212
217
|
});
|
|
@@ -282,7 +287,7 @@ for (const surface of surfaces) {
|
|
|
282
287
|
const { status, body } = await postChunked(
|
|
283
288
|
surface.path,
|
|
284
289
|
headers,
|
|
285
|
-
MCP_MAX_REQUEST_BODY_BYTES +
|
|
290
|
+
MCP_MAX_REQUEST_BODY_BYTES + 1,
|
|
286
291
|
);
|
|
287
292
|
expect(status).toBe(413);
|
|
288
293
|
expect(JSON.parse(body)).toEqual({
|
|
@@ -287,7 +287,16 @@ describe("/mcp-user auth and tool surface", () => {
|
|
|
287
287
|
};
|
|
288
288
|
const names = result.result.tools.map((tool) => tool.name).sort();
|
|
289
289
|
expect(names).toEqual(
|
|
290
|
-
[
|
|
290
|
+
[
|
|
291
|
+
"cancel-task",
|
|
292
|
+
"get-task-details",
|
|
293
|
+
"get-tasks",
|
|
294
|
+
"script-get-types",
|
|
295
|
+
"script-run",
|
|
296
|
+
"script-search",
|
|
297
|
+
"send-task",
|
|
298
|
+
"steer-task",
|
|
299
|
+
].sort(),
|
|
291
300
|
);
|
|
292
301
|
const sendTask = result.result.tools.find((tool) => tool.name === "send-task");
|
|
293
302
|
expect(Object.keys(sendTask?.inputSchema.properties ?? {}).sort()).toEqual(
|
|
@@ -12,10 +12,12 @@ import {
|
|
|
12
12
|
type ApiConfig,
|
|
13
13
|
checkCompletedProcesses,
|
|
14
14
|
DEFAULT_TASK_RECONCILE_INTERVAL_MS,
|
|
15
|
+
DEFAULT_TERMINAL_TASK_GRACE_MS,
|
|
15
16
|
type RunnerState,
|
|
16
17
|
type RunningTask,
|
|
17
18
|
reconcileActiveTasks,
|
|
18
19
|
resolveTaskReconcileIntervalMs,
|
|
20
|
+
resolveTerminalTaskGraceMs,
|
|
19
21
|
} from "../commands/runner";
|
|
20
22
|
import type { ProviderResult, ProviderSession } from "../providers/types";
|
|
21
23
|
import { registerVolatileSecret } from "../utils/secret-scrubber";
|
|
@@ -197,6 +199,106 @@ describe("reconcileActiveTasks: a session that never settles", () => {
|
|
|
197
199
|
});
|
|
198
200
|
});
|
|
199
201
|
|
|
202
|
+
describe("reconcileActiveTasks: a server-terminal task whose session can finish its input", () => {
|
|
203
|
+
/** Like Claude: `finishInput` closes stdin; `endsTurn` says whether the turn then ends. */
|
|
204
|
+
function finishableSetup(startedAt: number, endsTurn: boolean) {
|
|
205
|
+
const ctx = setup(startedAt);
|
|
206
|
+
const finishCalls: number[] = [];
|
|
207
|
+
ctx.session.finishInput = () => {
|
|
208
|
+
finishCalls.push(finishCalls.length);
|
|
209
|
+
if (!endsTurn) return;
|
|
210
|
+
ctx.task.result = {
|
|
211
|
+
exitCode: 0,
|
|
212
|
+
isError: false,
|
|
213
|
+
sessionId: "sess-hung",
|
|
214
|
+
cost: {
|
|
215
|
+
sessionId: "runner-session",
|
|
216
|
+
taskId: ctx.taskId,
|
|
217
|
+
agentId: crypto.randomUUID(),
|
|
218
|
+
totalCostUsd: 0.42,
|
|
219
|
+
durationMs: 1_000,
|
|
220
|
+
numTurns: 3,
|
|
221
|
+
model: "claude-sonnet-5-5",
|
|
222
|
+
isError: false,
|
|
223
|
+
provider: "claude",
|
|
224
|
+
},
|
|
225
|
+
};
|
|
226
|
+
};
|
|
227
|
+
return { ...ctx, finishCalls };
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
test("closes input instead of aborting, so the session's result and cost still land", async () => {
|
|
231
|
+
const startedAt = 6_000_000;
|
|
232
|
+
const { session, task, state, finishCalls } = finishableSetup(startedAt, true);
|
|
233
|
+
const apiConfig: ApiConfig = { apiUrl, apiKey: "test-key", agentId: crypto.randomUUID() };
|
|
234
|
+
|
|
235
|
+
await runUntilFree(state, startedAt, {
|
|
236
|
+
serverStatus: () => "completed",
|
|
237
|
+
apiConfig,
|
|
238
|
+
maxMs: 5 * 60_000,
|
|
239
|
+
});
|
|
240
|
+
|
|
241
|
+
expect(state.activeTasks.size).toBe(0);
|
|
242
|
+
expect(finishCalls).toHaveLength(1);
|
|
243
|
+
expect(session.abortReasons).toEqual([]);
|
|
244
|
+
expect(task.serverTerminalStatus).toBe("completed");
|
|
245
|
+
expect(requests).toContain("POST /api/session-costs");
|
|
246
|
+
expect(requests.some((r) => r.endsWith("/finish"))).toBe(false);
|
|
247
|
+
});
|
|
248
|
+
|
|
249
|
+
test("a session still running when the grace ends is aborted, then force-settled", async () => {
|
|
250
|
+
const startedAt = 7_000_000;
|
|
251
|
+
const { session, task, state, finishCalls } = finishableSetup(startedAt, false);
|
|
252
|
+
|
|
253
|
+
const { elapsedMs, statusReads } = await runUntilFree(state, startedAt, {
|
|
254
|
+
serverStatus: () => "completed",
|
|
255
|
+
maxMs: 5 * 60_000,
|
|
256
|
+
});
|
|
257
|
+
|
|
258
|
+
expect(state.activeTasks.size).toBe(0);
|
|
259
|
+
expect(finishCalls).toHaveLength(1);
|
|
260
|
+
expect(statusReads).toBe(1);
|
|
261
|
+
expect(session.abortReasons).toEqual(["server task completed"]);
|
|
262
|
+
expect(elapsedMs).toBeGreaterThanOrEqual(INTERVAL_MS + DEFAULT_TERMINAL_TASK_GRACE_MS);
|
|
263
|
+
expect(elapsedMs).toBeLessThanOrEqual(
|
|
264
|
+
INTERVAL_MS + DEFAULT_TERMINAL_TASK_GRACE_MS + ABORT_SETTLE_GRACE_MS + 2 * TICK_MS,
|
|
265
|
+
);
|
|
266
|
+
expect(task.result?.failureReason).toContain("runner exited without result");
|
|
267
|
+
});
|
|
268
|
+
|
|
269
|
+
test("a cancelled task is aborted at once, without the grace", async () => {
|
|
270
|
+
const startedAt = 8_000_000;
|
|
271
|
+
const { session, state, finishCalls } = finishableSetup(startedAt, true);
|
|
272
|
+
|
|
273
|
+
const { elapsedMs } = await runUntilFree(state, startedAt, {
|
|
274
|
+
serverStatus: () => "cancelled",
|
|
275
|
+
maxMs: 5 * 60_000,
|
|
276
|
+
});
|
|
277
|
+
|
|
278
|
+
expect(state.activeTasks.size).toBe(0);
|
|
279
|
+
expect(finishCalls).toHaveLength(0);
|
|
280
|
+
expect(session.abortReasons).toEqual(["server task cancelled"]);
|
|
281
|
+
expect(elapsedMs).toBeLessThanOrEqual(INTERVAL_MS + ABORT_SETTLE_GRACE_MS + 2 * TICK_MS);
|
|
282
|
+
});
|
|
283
|
+
});
|
|
284
|
+
|
|
285
|
+
describe("resolveTerminalTaskGraceMs", () => {
|
|
286
|
+
test("reads RUNNER_TERMINAL_TASK_GRACE_MS, accepts 0, and falls back on unset or invalid values", () => {
|
|
287
|
+
expect(resolveTerminalTaskGraceMs({ RUNNER_TERMINAL_TASK_GRACE_MS: "60000" })).toBe(60_000);
|
|
288
|
+
expect(resolveTerminalTaskGraceMs({ RUNNER_TERMINAL_TASK_GRACE_MS: "0" })).toBe(0);
|
|
289
|
+
expect(resolveTerminalTaskGraceMs({})).toBe(DEFAULT_TERMINAL_TASK_GRACE_MS);
|
|
290
|
+
expect(resolveTerminalTaskGraceMs({ RUNNER_TERMINAL_TASK_GRACE_MS: "" })).toBe(
|
|
291
|
+
DEFAULT_TERMINAL_TASK_GRACE_MS,
|
|
292
|
+
);
|
|
293
|
+
expect(resolveTerminalTaskGraceMs({ RUNNER_TERMINAL_TASK_GRACE_MS: "-1" })).toBe(
|
|
294
|
+
DEFAULT_TERMINAL_TASK_GRACE_MS,
|
|
295
|
+
);
|
|
296
|
+
expect(resolveTerminalTaskGraceMs({ RUNNER_TERMINAL_TASK_GRACE_MS: "soon" })).toBe(
|
|
297
|
+
DEFAULT_TERMINAL_TASK_GRACE_MS,
|
|
298
|
+
);
|
|
299
|
+
});
|
|
300
|
+
});
|
|
301
|
+
|
|
200
302
|
describe("resolveTaskReconcileIntervalMs", () => {
|
|
201
303
|
test("reads RUNNER_TASK_RECONCILE_INTERVAL_MS and falls back on unset or invalid values", () => {
|
|
202
304
|
expect(resolveTaskReconcileIntervalMs({ RUNNER_TASK_RECONCILE_INTERVAL_MS: "5000" })).toBe(
|
|
@@ -565,7 +565,7 @@ describe("script MCP connections", () => {
|
|
|
565
565
|
}
|
|
566
566
|
});
|
|
567
567
|
|
|
568
|
-
test("proxy route allows repo-scoped MCP connections
|
|
568
|
+
test("proxy route allows repo-scoped MCP connections for a lead only", async () => {
|
|
569
569
|
const fake = startFakeMcpServer();
|
|
570
570
|
try {
|
|
571
571
|
const lead = await createAgent({ name: "mcp-repo-lead", isLead: true, status: "idle" });
|
|
@@ -579,17 +579,21 @@ describe("script MCP connections", () => {
|
|
|
579
579
|
mcpServerId: mcpServer.id,
|
|
580
580
|
agentId: lead.id,
|
|
581
581
|
});
|
|
582
|
+
const call = (agentId: string) =>
|
|
583
|
+
dispatchProxyApi(`/api/script-connections/${connection.id}/mcp-call`, {
|
|
584
|
+
method: "POST",
|
|
585
|
+
headers: {
|
|
586
|
+
Authorization: `Bearer ${API_KEY}`,
|
|
587
|
+
"X-Agent-ID": agentId,
|
|
588
|
+
"Content-Type": "application/json",
|
|
589
|
+
},
|
|
590
|
+
body: JSON.stringify({ tool: "echo-tool", arguments: { message: "repo" } }),
|
|
591
|
+
});
|
|
582
592
|
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
headers: {
|
|
586
|
-
Authorization: `Bearer ${API_KEY}`,
|
|
587
|
-
"X-Agent-ID": worker.id,
|
|
588
|
-
"Content-Type": "application/json",
|
|
589
|
-
},
|
|
590
|
-
body: JSON.stringify({ tool: "echo-tool", arguments: { message: "repo" } }),
|
|
591
|
-
});
|
|
593
|
+
expect((await call(worker.id)).status).toBe(403);
|
|
594
|
+
expect(fake.requests.filter((request) => request.method === "tools/call")).toHaveLength(0);
|
|
592
595
|
|
|
596
|
+
const response = await call(lead.id);
|
|
593
597
|
expect(response.status).toBe(200);
|
|
594
598
|
expect(((await response.json()) as { ok: boolean }).ok).toBe(true);
|
|
595
599
|
} finally {
|
|
@@ -373,13 +373,17 @@ describe("sql-query route", () => {
|
|
|
373
373
|
expect(executorCalls).toHaveLength(0);
|
|
374
374
|
});
|
|
375
375
|
|
|
376
|
-
test("repo-scoped connections resolve the repo-scope secret", async () => {
|
|
376
|
+
test("repo-scoped connections resolve the repo-scope secret for a lead only", async () => {
|
|
377
377
|
const repoId = crypto.randomUUID();
|
|
378
378
|
const connection = await createSql({ scope: "repo", scopeId: repoId });
|
|
379
379
|
expect(await configRows("connection.analytics.secret")).toEqual([
|
|
380
380
|
expect.objectContaining({ scope: "repo", scopeId: repoId }),
|
|
381
381
|
]);
|
|
382
|
-
|
|
382
|
+
expect((await sqlQuery(connection.id, workerId, { sql: "select 1" })).status).toBe(403);
|
|
383
|
+
expect((await sqlQuery(connection.id, "workflow", { sql: "select 1" })).status).toBe(403);
|
|
384
|
+
expect(executorCalls).toHaveLength(0);
|
|
385
|
+
|
|
386
|
+
const response = await sqlQuery(connection.id, leadId, { sql: "select 1" });
|
|
383
387
|
expect(response.json()).toMatchObject({ ok: true });
|
|
384
388
|
expect(executorCalls[0]?.dsn).toBe(DSN);
|
|
385
389
|
});
|
|
@@ -726,6 +726,8 @@ describe("script connections", () => {
|
|
|
726
726
|
markMigrationApplied(database, "338_audit_agent_columns.sql");
|
|
727
727
|
// 340 alters api_key_status, which this migration-112-only fixture does not create.
|
|
728
728
|
markMigrationApplied(database, "340_api_key_spend_cap.sql");
|
|
729
|
+
// 341 alters user_tokens, which this fixture does not create.
|
|
730
|
+
markMigrationApplied(database, "341_user_token_expiry.sql");
|
|
729
731
|
|
|
730
732
|
const id = crypto.randomUUID();
|
|
731
733
|
const now = new Date().toISOString();
|
|
@@ -4416,6 +4416,91 @@ describe("Slack renderer v2 delegation (SLACK_RENDER_V2_DELEGATION)", () => {
|
|
|
4416
4416
|
expect(String(conclusionStream?.payload.markdown_text)).toContain(getTaskLink(child.id));
|
|
4417
4417
|
});
|
|
4418
4418
|
|
|
4419
|
+
test("a negative settle window falls back to the default, so a just-terminal closure still waits it out", async () => {
|
|
4420
|
+
process.env.SLACK_CONCLUSION_SETTLE_SEC = "-1";
|
|
4421
|
+
const lead = await createAgent({ name: "Negative Settle Lead", isLead: true, status: "idle" });
|
|
4422
|
+
const worker = await createAgent({
|
|
4423
|
+
name: "Negative Settle Worker",
|
|
4424
|
+
isLead: false,
|
|
4425
|
+
status: "idle",
|
|
4426
|
+
});
|
|
4427
|
+
const { channelId, threadTs } = uniqueSlackAddress("C_NEGATIVE_SETTLE");
|
|
4428
|
+
const ask = await createTaskExtended("negative settle ask", {
|
|
4429
|
+
agentId: lead.id,
|
|
4430
|
+
source: "slack",
|
|
4431
|
+
slackChannelId: channelId,
|
|
4432
|
+
slackThreadTs: threadTs,
|
|
4433
|
+
contextKey: slackContextKey({ channelId, threadTs }),
|
|
4434
|
+
});
|
|
4435
|
+
await startTask(ask.id);
|
|
4436
|
+
const child = await createTaskExtended("settle child work", {
|
|
4437
|
+
agentId: worker.id,
|
|
4438
|
+
source: "mcp",
|
|
4439
|
+
parentTaskId: ask.id,
|
|
4440
|
+
followUpConfig: { disabled: true },
|
|
4441
|
+
});
|
|
4442
|
+
await startTask(child.id);
|
|
4443
|
+
await completeTask(child.id, "Child result body.");
|
|
4444
|
+
calls.length = 0;
|
|
4445
|
+
|
|
4446
|
+
// Tick 1: the child gets its own card; the ask is still open, so no conclusion.
|
|
4447
|
+
await processSlackRenderV2();
|
|
4448
|
+
expect((await getSlackOutcomeMessage(child.id))?.finalizedAt).toBeDefined();
|
|
4449
|
+
expect(await getSlackOutcomeMessage(ask.id)).toBeNull();
|
|
4450
|
+
|
|
4451
|
+
// Every member is terminal but the closure has been quiet for 2s only. A
|
|
4452
|
+
// negative settle window must not read as "already quiet long enough".
|
|
4453
|
+
await completeTask(ask.id, "Ask completed.");
|
|
4454
|
+
await backdateLastUpdated([ask.id, child.id], 2);
|
|
4455
|
+
calls.length = 0;
|
|
4456
|
+
|
|
4457
|
+
await processSlackRenderV2();
|
|
4458
|
+
expect(await getSlackOutcomeMessage(ask.id)).toBeNull();
|
|
4459
|
+
|
|
4460
|
+
// The fallback is the documented 10s, so 30s of quiet does conclude.
|
|
4461
|
+
await backdateLastUpdated([ask.id, child.id], 30);
|
|
4462
|
+
await processSlackRenderV2();
|
|
4463
|
+
expect((await getSlackOutcomeMessage(ask.id))?.conclusionKind).toBe("complete");
|
|
4464
|
+
});
|
|
4465
|
+
|
|
4466
|
+
test("a negative timeout falls back to the default, so a fresh unfinished closure is not timed out at once", async () => {
|
|
4467
|
+
process.env.SLACK_CONCLUSION_TIMEOUT_MIN = "-1";
|
|
4468
|
+
const lead = await createAgent({ name: "Negative Timeout Lead", isLead: true, status: "idle" });
|
|
4469
|
+
const worker = await createAgent({
|
|
4470
|
+
name: "Negative Timeout Worker",
|
|
4471
|
+
isLead: false,
|
|
4472
|
+
status: "idle",
|
|
4473
|
+
});
|
|
4474
|
+
const { channelId, threadTs } = uniqueSlackAddress("C_NEGATIVE_TIMEOUT");
|
|
4475
|
+
const ask = await createTaskExtended("negative timeout ask", {
|
|
4476
|
+
agentId: lead.id,
|
|
4477
|
+
source: "slack",
|
|
4478
|
+
slackChannelId: channelId,
|
|
4479
|
+
slackThreadTs: threadTs,
|
|
4480
|
+
contextKey: slackContextKey({ channelId, threadTs }),
|
|
4481
|
+
});
|
|
4482
|
+
await startTask(ask.id);
|
|
4483
|
+
const child = await createTaskExtended("still running work", {
|
|
4484
|
+
agentId: worker.id,
|
|
4485
|
+
source: "mcp",
|
|
4486
|
+
parentTaskId: ask.id,
|
|
4487
|
+
followUpConfig: { disabled: true },
|
|
4488
|
+
});
|
|
4489
|
+
await startTask(child.id);
|
|
4490
|
+
await completeTask(ask.id, "Ask done; the child never finished.");
|
|
4491
|
+
await backdateLastUpdated([ask.id, child.id], 2);
|
|
4492
|
+
calls.length = 0;
|
|
4493
|
+
|
|
4494
|
+
// 2s of idle is nowhere near the 240min fallback, so no timeout card.
|
|
4495
|
+
await processSlackRenderV2();
|
|
4496
|
+
expect(await getSlackOutcomeMessage(ask.id)).toBeNull();
|
|
4497
|
+
|
|
4498
|
+
// Past the documented 240min default the closure does conclude as timed out.
|
|
4499
|
+
await backdateLastUpdated([ask.id, child.id], 260 * 60);
|
|
4500
|
+
await processSlackRenderV2();
|
|
4501
|
+
expect((await getSlackOutcomeMessage(ask.id))?.conclusionKind).toBe("timeout");
|
|
4502
|
+
});
|
|
4503
|
+
|
|
4419
4504
|
test("a stale in-progress ask times out without a completed outcome", async () => {
|
|
4420
4505
|
process.env.SLACK_CONCLUSION_TIMEOUT_MIN = "1";
|
|
4421
4506
|
const lead = await createAgent({ name: "Stale Ask Lead", isLead: true, status: "idle" });
|