@desplega.ai/agent-swarm 1.146.0 → 1.147.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/README.md +1 -1
- package/dist/{acp-adapter-jnq4612m.js → acp-adapter-9n319wqc.js} +42 -4
- package/dist/{actions-s41xcn3f.js → actions-2vxqvpr9.js} +9 -8
- package/dist/{app-j8bfw3f6.js → app-w066xfy0.js} +6 -5
- package/dist/assistant-kt31dj2h.js +236 -0
- package/dist/{boot-reembed-jxdz46jp.js → boot-reembed-az5rassp.js} +7 -6
- package/dist/{boot-reembed-x1476agm.js → boot-reembed-j3mm3rfz.js} +8 -7
- package/dist/{boot-scrub-logs-rab9h5bt.js → boot-scrub-logs-b6h54817.js} +4 -4
- package/dist/{claude-adapter-ep6qekbm.js → claude-adapter-w1z04ann.js} +8 -6
- package/dist/{claude-managed-setup-w619jncn.js → claude-managed-setup-f5pmsyrp.js} +24 -3
- package/dist/{claude-sdk-session-0wp3qrcy.js → claude-sdk-session-f0cc1kec.js} +8 -6
- package/dist/{cli-bafd6xnf.js → cli-0b6y7kxm.js} +1 -1
- package/dist/{cli-jyy3e193.js → cli-12fz972k.js} +4 -4
- package/dist/{cli-pzfc7j7g.js → cli-1th1728g.js} +2 -2
- package/dist/{cli-68h2mfrn.js → cli-3tgwnf43.js} +3 -3
- package/dist/{cli-q3qr220d.js → cli-4nr988h6.js} +1 -1
- package/dist/{cli-m4xsy03s.js → cli-53s590z8.js} +1 -1
- package/dist/{cli-c8q7292f.js → cli-54wwve05.js} +5 -4
- package/dist/{cli-rymrjneb.js → cli-719k9j2c.js} +2 -2
- package/dist/{cli-zn65x0w8.js → cli-89xfd7f9.js} +21 -47
- package/dist/{cli-506z6jqa.js → cli-8v0g1yc8.js} +1 -1
- package/dist/cli-9d8ntetj.js +42 -0
- package/dist/{cli-dhg6j8h3.js → cli-atcve9y8.js} +826 -737
- package/dist/{cli-46yck6nj.js → cli-b5bq9crk.js} +14 -31
- package/dist/cli-d8brzxjb.js +190 -0
- package/dist/{cli-a960nkfb.js → cli-de14znh8.js} +2 -2
- package/dist/{cli-s8sbe32s.js → cli-dttph1bw.js} +2 -2
- package/dist/cli-ep19k3mb.js +19 -0
- package/dist/{cli-d9pnxgth.js → cli-f146mn5s.js} +7 -50
- package/dist/{cli-qar1f940.js → cli-f7dsy61y.js} +5 -3
- package/dist/{cli-d4xqde2b.js → cli-ftht3zzj.js} +2780 -2587
- package/dist/{cli-pmwbdw36.js → cli-hbv0kq6w.js} +2 -2
- package/dist/{cli-fhsz3twr.js → cli-jsp14b6c.js} +171 -1
- package/dist/{cli-2zvtzevh.js → cli-kpv03zhj.js} +13 -11
- package/dist/{cli-a9bn9svs.js → cli-m8yrsg97.js} +2 -2
- package/dist/cli-m9sxbkhm.js +779 -0
- package/dist/cli-mmemxxdc.js +823 -0
- package/dist/{cli-6xwhtc64.js → cli-n8508nre.js} +1 -1
- package/dist/{cli-q0qq1sxw.js → cli-p1d5b073.js} +37 -2
- package/dist/{cli-yqeb27t1.js → cli-rw51bq3j.js} +13 -10
- package/dist/{cli-zww3vcnm.js → cli-smby5m17.js} +7 -6
- package/dist/{cli-ah5hjk49.js → cli-tzvk9haz.js} +94 -372
- package/dist/{cli-yxwe913z.js → cli-w9kb3bk1.js} +1 -1
- package/dist/{cli-skd674mt.js → cli-y6b6fb76.js} +25 -3
- package/dist/{cli-3k2g3kg2.js → cli-yz3djrm0.js} +9 -9
- package/dist/{cli-4secrq32.js → cli-zhjmqxzh.js} +1 -1
- package/dist/cli.js +13 -13
- package/dist/{codex-adapter-d6qajxj3.js → codex-adapter-zw4dwsx7.js} +2 -2
- package/dist/{codex-hook-n7m5k7cr.js → codex-hook-bw8p5nh4.js} +2 -2
- package/dist/{codex-session-runner-v9krqe4x.js → codex-session-runner-k981s65v.js} +2 -2
- package/dist/{commands-923wsas7.js → commands-sykrxx7e.js} +4 -4
- package/dist/{db-m1hy4zh5.js → db-sfbsc8wt.js} +6 -4
- package/dist/handlers-0aspcejm.js +603 -0
- package/dist/{hook-ee4hff56.js → hook-4nvqj2sb.js} +7 -5
- package/dist/{hook-bxe3bkdy.js → hook-hxccs7m5.js} +24 -49
- package/dist/{http-a8rx91me.js → http-y06z517d.js} +223 -92
- package/dist/{index-697zfzv1.js → index-hssww7kj.js} +15 -14
- package/dist/{index-3x9g3nbg.js → index-k8znfx0z.js} +13 -12
- package/dist/{index-1j9va48r.js → index-tce1rss4.js} +371 -110
- package/dist/{index-jj4q3x59.js → index-x5j894zf.js} +14 -13
- package/dist/{keepalive-sds4e4ce.js → keepalive-w733ax66.js} +6 -6
- package/dist/{lead-ggq6szk8.js → lead-75bjqa9d.js} +29 -27
- package/dist/{maintenance-093p41d4.js → maintenance-w4f1zjck.js} +8 -7
- package/dist/{oauth-refresh-sweep-dvzq4ckj.js → oauth-refresh-sweep-wdetky26.js} +5 -5
- package/dist/{onboard-ydr9tzw5.js → onboard-bb5net8s.js} +2 -2
- package/dist/{otel-impl-zx3tdf3j.js → otel-impl-0w7c14ap.js} +1 -1
- package/dist/{pi-mono-adapter-dtkz4e7j.js → pi-mono-adapter-2has4gnp.js} +12 -2
- package/dist/{pricing-refresh-7e6pqnzp.js → pricing-refresh-9nzsrgcq.js} +6 -6
- package/dist/{rbac-roles-p2rh6d0r.js → rbac-roles-r3hqjp09.js} +5 -5
- package/dist/{rbac-roles-0dv1wt0w.js → rbac-roles-z1jrffbt.js} +4 -4
- package/dist/{registry-9kdck5ye.js → registry-v5wytg0s.js} +1 -2
- package/dist/{render-v2-4k3jt4r2.js → render-v2-vbr89fnb.js} +6 -5
- package/dist/{seed-pricing-2cc1qmcd.js → seed-pricing-g62hy1pk.js} +7 -5
- package/dist/{setup-c5yss30k.js → setup-gnfqnptp.js} +2 -2
- package/dist/{worker-7srgeqcr.js → worker-kznxp4qm.js} +29 -27
- package/openapi.json +263 -12
- package/package.json +1 -1
- package/plugin/commands/start-worker.md +4 -9
- package/plugin/pi-skills/start-worker/SKILL.md +4 -9
- package/src/be/db/agents.ts +556 -0
- package/src/be/db/context-versions.ts +117 -0
- package/src/be/db/runtime.ts +406 -0
- package/src/be/db/tasks/read.ts +1167 -0
- package/src/be/db/tasks/write.ts +953 -0
- package/src/be/db.ts +583 -3428
- package/src/be/migrations/147_scheduled_tasks_parent_task.sql +7 -0
- package/src/be/migrations/148_pages_svg.sql +123 -0
- package/src/be/migrations/149_session_tokens.sql +24 -0
- package/src/be/scripts/typecheck.ts +1 -0
- package/src/be/seed-pricing.ts +13 -8
- package/src/be/seed-scripts/catalog/ops-catalog-audit.inline.ts +1 -1
- package/src/be/seed-scripts/catalog/ops-catalog-audit.ts +1 -1
- package/src/be/seed-scripts/catalog/star-history-refresh.ts +101 -0
- package/src/be/seed-scripts/catalog/star-history-renderer.ts +119 -0
- package/src/be/seed-scripts/index.ts +17 -0
- package/src/be/seed-skills/index.ts +14 -0
- package/src/be/swarm-config-guard.ts +1 -1
- package/src/be/task-attachment-store.ts +70 -0
- package/src/be/users.ts +77 -0
- package/src/commands/attachments-section.ts +37 -0
- package/src/commands/claude-managed-setup.ts +45 -3
- package/src/commands/claude-md-session.ts +408 -0
- package/src/commands/context-preamble.ts +15 -3
- package/src/commands/profile-sync.ts +205 -5
- package/src/commands/provider-credentials.ts +60 -27
- package/src/commands/runner.ts +63 -58
- package/src/commands/templates.ts +25 -2
- package/src/hooks/hook.ts +26 -67
- package/src/http/agents.ts +40 -1
- package/src/http/auth.ts +13 -1
- package/src/http/fs.ts +21 -51
- package/src/http/mcp.ts +32 -0
- package/src/http/pages-public.ts +20 -4
- package/src/http/poll.ts +4 -0
- package/src/http/repos.ts +3 -3
- package/src/http/sessions.ts +82 -0
- package/src/http/tasks.ts +10 -2
- package/src/prompts/session-templates.ts +4 -2
- package/src/providers/acp-adapter.ts +42 -6
- package/src/providers/pi-mono-adapter.ts +23 -6
- package/src/scheduler/scheduler.test.ts +49 -2
- package/src/scheduler/scheduler.ts +4 -0
- package/src/scripts-runtime/sdk-allowlist.ts +1 -0
- package/src/scripts-runtime/types/stdlib.d.ts +8 -0
- package/src/scripts-runtime/types/swarm-sdk.d.ts +8 -0
- package/src/server.ts +2 -0
- package/src/slack/assistant.ts +87 -46
- package/src/slack/handlers.test.ts +1 -3
- package/src/slack/handlers.ts +102 -87
- package/src/slack/inbound-files.ts +466 -0
- package/src/slack/templates.ts +14 -0
- package/src/tasks/task-terminal-effects.ts +158 -0
- package/src/tests/acp-adapter.test.ts +327 -192
- package/src/tests/budget-claim-gate.test.ts +1 -0
- package/src/tests/build-pi-skills.test.ts +5 -7
- package/src/tests/claude-managed-setup.test.ts +52 -4
- package/src/tests/claude-md-session.test.ts +603 -0
- package/src/tests/codex-skill-resolver.test.ts +19 -0
- package/src/tests/context-versioning.test.ts +107 -0
- package/src/tests/credential-check.test.ts +157 -14
- package/src/tests/db-agents.test.ts +91 -0
- package/src/tests/db-context-versions.test.ts +37 -0
- package/src/tests/db-extraction-contract.test.ts +45 -0
- package/src/tests/db-runtime.test.ts +70 -0
- package/src/tests/db-task-read-contract.test.ts +624 -0
- package/src/tests/db-task-write-contract.test.ts +653 -0
- package/src/tests/db-tasks-read.test.ts +183 -0
- package/src/tests/db-tasks-write.test.ts +230 -0
- package/src/tests/defer-task.test.ts +389 -0
- package/src/tests/docs-index-footprint.test.js +2 -2
- package/src/tests/e2e-visuals-stage.test.ts +151 -0
- package/src/tests/file-lock.test.ts +144 -0
- package/src/tests/fixtures/file-lock-holder.ts +13 -0
- package/src/tests/fixtures/hold-file-lock.ts +25 -0
- package/src/tests/heartbeat-expiry.test.ts +188 -0
- package/src/tests/http-api-integration.test.ts +78 -1
- package/src/tests/pages-public-html.test.ts +43 -0
- package/src/tests/pages-svg-migration.test.ts +42 -0
- package/src/tests/preload.ts +4 -1
- package/src/tests/profile-sync-warning.test.ts +16 -0
- package/src/tests/profile-sync.test.ts +126 -0
- package/src/tests/prompt-template-session.test.ts +20 -4
- package/src/tests/provider-registration.test.ts +93 -0
- package/src/tests/rbac-e2e-helpers.test.ts +53 -0
- package/src/tests/rbac-e2e-helpers.ts +19 -2
- package/src/tests/routing-affinity-inventory.test.ts +1 -1
- package/src/tests/runner-attachments-section.test.ts +22 -2
- package/src/tests/runner-context-preamble.test.ts +30 -0
- package/src/tests/runner-deployment-resume.test.ts +107 -0
- package/src/tests/runner-repo-autostash.test.ts +12 -0
- package/src/tests/script-connections.test.ts +4 -0
- package/src/tests/seed-scripts.test.ts +2 -2
- package/src/tests/session-tokens.test.ts +279 -0
- package/src/tests/slack-file-tools-attachments.test.ts +408 -0
- package/src/tests/slack-inbound-files.test.ts +847 -0
- package/src/tests/star-history-refresh.test.ts +102 -0
- package/src/tests/swarm-repos.test.ts +20 -0
- package/src/tests/tool-annotations.test.ts +4 -3
- package/src/tests/ui-logs-parser.test.ts +176 -0
- package/src/tools/create-page.ts +4 -2
- package/src/tools/defer-task.ts +239 -0
- package/src/tools/repos/update-repo.ts +2 -2
- package/src/tools/schedules/create-schedule.ts +1 -0
- package/src/tools/schedules/list-schedules.ts +1 -0
- package/src/tools/schedules/patch-schedule.ts +1 -0
- package/src/tools/schedules/update-schedule.ts +1 -0
- package/src/tools/slack-download-file.ts +60 -29
- package/src/tools/slack-read.ts +73 -32
- package/src/tools/store-progress.ts +16 -146
- package/src/tools/tool-config.ts +1 -0
- package/src/tools/utils.ts +21 -0
- package/src/types.ts +37 -4
- package/src/utils/acp-session-token.ts +56 -0
- package/src/utils/file-lock.ts +111 -0
- package/src/utils/heartbeat-expiry.ts +78 -0
- package/src/utils/request-auth-context.ts +2 -0
- package/src/utils/task-attachment-links.ts +22 -0
- package/templates/skills/code-quality/content.md +8 -5
- package/templates/skills/download-task-attachment/content.md +2 -1
- package/{plugin/pi-skills → templates/skills}/review-offered-task/SKILL.md +5 -5
- package/templates/skills/review-offered-task/config.json +14 -0
- package/{plugin/commands/review-offered-task.md → templates/skills/review-offered-task/content.md} +3 -8
- package/templates/skills/scheduling/content.md +4 -0
- package/templates/skills/slack-interaction/content.md +2 -2
- package/templates/skills/work-on-task/SKILL.md +16 -0
- package/templates/skills/work-on-task/config.json +14 -0
- package/templates/skills/work-on-task/content.md +11 -0
- package/dist/assistant-dx3ew4d8.js +0 -212
- package/dist/cli-00kyrp1a.js +0 -317
- package/dist/cli-n1q8q14d.js +0 -177
- package/dist/cli-ss6vybmt.js +0 -269
- package/dist/handlers-e9vp2fr8.js +0 -592
- package/plugin/commands/work-on-task.md +0 -39
- package/plugin/pi-skills/work-on-task/SKILL.md +0 -39
|
@@ -10,6 +10,8 @@ import {
|
|
|
10
10
|
initDb,
|
|
11
11
|
updateAgentProfile,
|
|
12
12
|
} from "../be/db";
|
|
13
|
+
import type { ProfileSyncConflict } from "../types";
|
|
14
|
+
import { IDENTITY_FIELD_BUDGETS } from "../utils/identity-field-budget";
|
|
13
15
|
|
|
14
16
|
const TEST_DB_PATH = "./test-context-versioning.sqlite";
|
|
15
17
|
|
|
@@ -411,6 +413,111 @@ describe("Context Versioning", () => {
|
|
|
411
413
|
});
|
|
412
414
|
});
|
|
413
415
|
|
|
416
|
+
// ============================================================================
|
|
417
|
+
// Compare-and-set (expectedHashes)
|
|
418
|
+
// ============================================================================
|
|
419
|
+
|
|
420
|
+
describe("compare-and-set via expectedHashes", () => {
|
|
421
|
+
const casAgentId = "cccc0000-0000-4000-8000-000000000004";
|
|
422
|
+
const v1 = "# CLAUDE.md\n\nversion one";
|
|
423
|
+
const v2 = "# CLAUDE.md\n\nversion two — the Lead added a rule";
|
|
424
|
+
const v3 = "# CLAUDE.md\n\nversion three — edited in a session";
|
|
425
|
+
|
|
426
|
+
beforeAll(async () => {
|
|
427
|
+
await createAgent({ id: casAgentId, name: "CAS Agent", isLead: false, status: "idle" });
|
|
428
|
+
await updateAgentProfile(casAgentId, { claudeMd: v1 }, { changeSource: "self_edit" });
|
|
429
|
+
await updateAgentProfile(casAgentId, { claudeMd: v2 }, { changeSource: "self_edit" });
|
|
430
|
+
});
|
|
431
|
+
|
|
432
|
+
test("drops a copy based on a superseded version and reports the conflict", async () => {
|
|
433
|
+
// The 2026-09-11 incident: a session materialized v1, the Lead moved the
|
|
434
|
+
// DB to v2 meanwhile, and the session's end-of-run sync carried v1 back.
|
|
435
|
+
const conflicts: ProfileSyncConflict[] = [];
|
|
436
|
+
const agent = await updateAgentProfile(
|
|
437
|
+
casAgentId,
|
|
438
|
+
{ claudeMd: v3 },
|
|
439
|
+
{ changeSource: "session_sync" },
|
|
440
|
+
{ expectedHashes: { claudeMd: sha256(v1) }, onConflict: (c) => conflicts.push(c) },
|
|
441
|
+
);
|
|
442
|
+
|
|
443
|
+
expect(agent!.claudeMd).toBe(v2);
|
|
444
|
+
expect((await getLatestContextVersion(casAgentId, "claudeMd"))!.version).toBe(2);
|
|
445
|
+
expect(conflicts).toEqual([
|
|
446
|
+
{ field: "claudeMd", expectedHash: sha256(v1), currentHash: sha256(v2) },
|
|
447
|
+
]);
|
|
448
|
+
});
|
|
449
|
+
|
|
450
|
+
test("applies a deliberate session_sync revert to an earlier version", async () => {
|
|
451
|
+
// The session was based on the current value (v2) and restored v1 on
|
|
452
|
+
// purpose. Its hash is in the history, and that must not matter.
|
|
453
|
+
const agent = await updateAgentProfile(
|
|
454
|
+
casAgentId,
|
|
455
|
+
{ claudeMd: v1 },
|
|
456
|
+
{ changeSource: "session_sync" },
|
|
457
|
+
{ expectedHashes: { claudeMd: sha256(v2) } },
|
|
458
|
+
);
|
|
459
|
+
|
|
460
|
+
expect(agent!.claudeMd).toBe(v1);
|
|
461
|
+
const latest = await getLatestContextVersion(casAgentId, "claudeMd");
|
|
462
|
+
expect(latest!.version).toBe(3);
|
|
463
|
+
expect(latest!.content).toBe(v1);
|
|
464
|
+
expect(latest!.changeSource).toBe("session_sync");
|
|
465
|
+
});
|
|
466
|
+
|
|
467
|
+
test("the drop is per field: other fields in the same update land", async () => {
|
|
468
|
+
const soul = "s".repeat(600);
|
|
469
|
+
const agent = await updateAgentProfile(
|
|
470
|
+
casAgentId,
|
|
471
|
+
{ claudeMd: v3, soulMd: soul },
|
|
472
|
+
{ changeSource: "session_sync" },
|
|
473
|
+
{ expectedHashes: { claudeMd: sha256(v2) } }, // stale: the DB is at v1 now
|
|
474
|
+
);
|
|
475
|
+
|
|
476
|
+
expect(agent!.claudeMd).toBe(v1);
|
|
477
|
+
expect(agent!.soulMd).toBe(soul);
|
|
478
|
+
expect((await getLatestContextVersion(casAgentId, "claudeMd"))!.version).toBe(3);
|
|
479
|
+
expect((await getLatestContextVersion(casAgentId, "soulMd"))!.version).toBe(1);
|
|
480
|
+
});
|
|
481
|
+
|
|
482
|
+
test("without expectedHashes the write stays unconditional", async () => {
|
|
483
|
+
const agent = await updateAgentProfile(
|
|
484
|
+
casAgentId,
|
|
485
|
+
{ claudeMd: v2 },
|
|
486
|
+
{ changeSource: "session_sync" },
|
|
487
|
+
);
|
|
488
|
+
|
|
489
|
+
expect(agent!.claudeMd).toBe(v2);
|
|
490
|
+
expect((await getLatestContextVersion(casAgentId, "claudeMd"))!.version).toBe(4);
|
|
491
|
+
});
|
|
492
|
+
|
|
493
|
+
test("a stale copy over the budget is dropped, not rejected", async () => {
|
|
494
|
+
// The profile has since been shortened under the budget. A stale copy of
|
|
495
|
+
// the old, oversized value must be dropped by the compare-and-set — not
|
|
496
|
+
// throw IdentityFieldBudgetError and roll back the other fields too.
|
|
497
|
+
const longAgentId = "cccc0000-0000-4000-8000-000000000005";
|
|
498
|
+
const oversized = "x".repeat(IDENTITY_FIELD_BUDGETS.claudeMd + 500);
|
|
499
|
+
const shortened = "# CLAUDE.md\n\nshortened below the budget";
|
|
500
|
+
await createAgent({
|
|
501
|
+
id: longAgentId,
|
|
502
|
+
name: "Long CAS Agent",
|
|
503
|
+
isLead: false,
|
|
504
|
+
status: "idle",
|
|
505
|
+
});
|
|
506
|
+
await updateAgentProfile(longAgentId, { claudeMd: shortened }, { changeSource: "self_edit" });
|
|
507
|
+
|
|
508
|
+
const soul = "t".repeat(600);
|
|
509
|
+
const agent = await updateAgentProfile(
|
|
510
|
+
longAgentId,
|
|
511
|
+
{ claudeMd: oversized, soulMd: soul },
|
|
512
|
+
{ changeSource: "session_sync" },
|
|
513
|
+
{ expectedHashes: { claudeMd: sha256(oversized) } },
|
|
514
|
+
);
|
|
515
|
+
|
|
516
|
+
expect(agent!.claudeMd).toBe(shortened);
|
|
517
|
+
expect(agent!.soulMd).toBe(soul);
|
|
518
|
+
});
|
|
519
|
+
});
|
|
520
|
+
|
|
414
521
|
// ============================================================================
|
|
415
522
|
// Content hash consistency
|
|
416
523
|
// ============================================================================
|
|
@@ -2,8 +2,11 @@ import { describe, expect, mock, test } from "bun:test";
|
|
|
2
2
|
import {
|
|
3
3
|
buildCredStatusReport,
|
|
4
4
|
checkProviderCredentials,
|
|
5
|
+
isBedrockMode,
|
|
5
6
|
isCredCheckDisabled,
|
|
6
7
|
REQUIRED_CRED_VARS_BY_PROVIDER,
|
|
8
|
+
shouldRefreshBedrockStatus,
|
|
9
|
+
validateProviderCredentials,
|
|
7
10
|
} from "../commands/provider-credentials";
|
|
8
11
|
import { checkClaudeCredentials } from "../providers/claude-adapter";
|
|
9
12
|
import { checkClaudeManagedCredentials } from "../providers/claude-managed-adapter";
|
|
@@ -410,21 +413,69 @@ describe("checkPiMonoCredentials", () => {
|
|
|
410
413
|
expect(status.ready).toBe(false);
|
|
411
414
|
});
|
|
412
415
|
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
const status = await checkPiMonoCredentials(env, {
|
|
416
|
+
// ─── BEDROCK_AUTH_MODE=bearer: explicit Bedrock API key ─────────────────────
|
|
417
|
+
|
|
418
|
+
test("BEDROCK_AUTH_MODE=bearer: missing AWS_BEARER_TOKEN_BEDROCK → not ready, no probe, no fall-through", async () => {
|
|
419
|
+
let probed = false;
|
|
420
|
+
// A standard key must not satisfy the bearer mode: it does not apply to Bedrock.
|
|
421
|
+
const env = { BEDROCK_AUTH_MODE: "bearer", AWS_REGION: "us-east-1", ANTHROPIC_API_KEY: "x" };
|
|
422
|
+
const status = await checkPiMonoCredentials(env, {
|
|
423
|
+
homeDir: HOME,
|
|
424
|
+
fs: noFiles,
|
|
425
|
+
bedrockProbe: async () => {
|
|
426
|
+
probed = true;
|
|
427
|
+
},
|
|
428
|
+
});
|
|
420
429
|
expect(status.ready).toBe(false);
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
430
|
+
expect(status.missing).toEqual(["AWS_BEARER_TOKEN_BEDROCK"]);
|
|
431
|
+
expect(status.hint).toContain("AWS_BEARER_TOKEN_BEDROCK");
|
|
432
|
+
expect(probed).toBe(false);
|
|
433
|
+
});
|
|
434
|
+
|
|
435
|
+
test("BEDROCK_AUTH_MODE=bearer: token without AWS_REGION → not ready with the region hint", async () => {
|
|
436
|
+
const env = { BEDROCK_AUTH_MODE: "bearer", AWS_BEARER_TOKEN_BEDROCK: "bedrock-api-key" };
|
|
437
|
+
const status = await checkPiMonoCredentials(env, {
|
|
438
|
+
homeDir: HOME,
|
|
439
|
+
fs: noFiles,
|
|
440
|
+
bedrockProbe: bedrockProbeSuccess,
|
|
441
|
+
});
|
|
442
|
+
expect(status.ready).toBe(false);
|
|
443
|
+
expect(status.hint).toContain("AWS_REGION");
|
|
444
|
+
expect(status.bedrockRegion).toBe("");
|
|
445
|
+
});
|
|
446
|
+
|
|
447
|
+
test("BEDROCK_AUTH_MODE=bearer: token + region → probe runs, ready via env", async () => {
|
|
448
|
+
const env = {
|
|
449
|
+
BEDROCK_AUTH_MODE: "bearer",
|
|
450
|
+
AWS_BEARER_TOKEN_BEDROCK: "bedrock-api-key",
|
|
451
|
+
AWS_REGION: "eu-central-1",
|
|
452
|
+
};
|
|
453
|
+
const status = await checkPiMonoCredentials(env, {
|
|
454
|
+
homeDir: HOME,
|
|
455
|
+
fs: noFiles,
|
|
456
|
+
bedrockProbe: async () => [{ id: "anthropic.claude-sonnet", name: "Claude Sonnet" }],
|
|
457
|
+
});
|
|
458
|
+
expect(status.ready).toBe(true);
|
|
459
|
+
expect(status.satisfiedBy).toBe("env");
|
|
460
|
+
expect(status.bedrockRegion).toBe("eu-central-1");
|
|
461
|
+
expect(status.bedrockModels).toEqual([
|
|
462
|
+
{ id: "anthropic.claude-sonnet", name: "Claude Sonnet" },
|
|
463
|
+
]);
|
|
464
|
+
});
|
|
465
|
+
|
|
466
|
+
test("BEDROCK_AUTH_MODE=bearer: probe failure → ready:false with the classified hint", async () => {
|
|
467
|
+
const env = {
|
|
468
|
+
BEDROCK_AUTH_MODE: "bearer",
|
|
469
|
+
AWS_BEARER_TOKEN_BEDROCK: "bedrock-api-key",
|
|
470
|
+
AWS_REGION: "us-east-1",
|
|
471
|
+
};
|
|
472
|
+
const status = await checkPiMonoCredentials(env, {
|
|
473
|
+
homeDir: HOME,
|
|
474
|
+
fs: noFiles,
|
|
475
|
+
bedrockProbe: bedrockProbeAuthFail,
|
|
476
|
+
});
|
|
477
|
+
expect(status.ready).toBe(false);
|
|
478
|
+
expect(status.bedrockRegion).toBe("us-east-1");
|
|
428
479
|
});
|
|
429
480
|
|
|
430
481
|
test("BEDROCK_AUTH_MODE absent + no MODEL_OVERRIDE=amazon-bedrock: no probe", async () => {
|
|
@@ -689,6 +740,98 @@ describe("snapshot: every provider", () => {
|
|
|
689
740
|
|
|
690
741
|
// ─── REQUIRED_CRED_VARS_BY_PROVIDER documentation map ────────────────────────
|
|
691
742
|
|
|
743
|
+
describe("isBedrockMode (shared gate for the live test and the refresh loop)", () => {
|
|
744
|
+
test("recognizes both explicit modes and the MODEL_OVERRIDE prefix inference", () => {
|
|
745
|
+
expect(isBedrockMode({ BEDROCK_AUTH_MODE: "sdk" })).toBe(true);
|
|
746
|
+
expect(isBedrockMode({ BEDROCK_AUTH_MODE: "bearer" })).toBe(true);
|
|
747
|
+
expect(isBedrockMode({ BEDROCK_AUTH_MODE: "Bearer", MODEL_OVERRIDE: "some-model" })).toBe(true);
|
|
748
|
+
expect(isBedrockMode({ MODEL_OVERRIDE: "amazon-bedrock/anthropic.claude" })).toBe(true);
|
|
749
|
+
expect(isBedrockMode({ MODEL_OVERRIDE: "anthropic/claude" })).toBe(false);
|
|
750
|
+
expect(isBedrockMode({})).toBe(false);
|
|
751
|
+
});
|
|
752
|
+
});
|
|
753
|
+
|
|
754
|
+
describe("shouldRefreshBedrockStatus (runner post-task refresh gate)", () => {
|
|
755
|
+
const INTERVAL = 5 * 60 * 1000;
|
|
756
|
+
const base = { harnessProvider: "pi", lastRefreshAt: 1_000, intervalMs: INTERVAL };
|
|
757
|
+
|
|
758
|
+
test("bearer-only pi configuration is refreshed once the interval has elapsed", () => {
|
|
759
|
+
const env = {
|
|
760
|
+
BEDROCK_AUTH_MODE: "bearer",
|
|
761
|
+
AWS_BEARER_TOKEN_BEDROCK: "tok",
|
|
762
|
+
AWS_REGION: "us-east-1",
|
|
763
|
+
};
|
|
764
|
+
expect(shouldRefreshBedrockStatus({ ...base, env, now: 1_000 + INTERVAL + 1 })).toBe(true);
|
|
765
|
+
});
|
|
766
|
+
|
|
767
|
+
test("bearer mode stays throttled inside the interval", () => {
|
|
768
|
+
const env = {
|
|
769
|
+
BEDROCK_AUTH_MODE: "bearer",
|
|
770
|
+
AWS_BEARER_TOKEN_BEDROCK: "tok",
|
|
771
|
+
AWS_REGION: "us-east-1",
|
|
772
|
+
};
|
|
773
|
+
expect(shouldRefreshBedrockStatus({ ...base, env, now: 1_000 + INTERVAL })).toBe(false);
|
|
774
|
+
expect(shouldRefreshBedrockStatus({ ...base, env, now: 1_000 + 1 })).toBe(false);
|
|
775
|
+
});
|
|
776
|
+
|
|
777
|
+
test("sdk mode and the amazon-bedrock/ prefix inference refresh the same way", () => {
|
|
778
|
+
const now = 1_000 + INTERVAL + 1;
|
|
779
|
+
expect(shouldRefreshBedrockStatus({ ...base, env: { BEDROCK_AUTH_MODE: "sdk" }, now })).toBe(
|
|
780
|
+
true,
|
|
781
|
+
);
|
|
782
|
+
expect(
|
|
783
|
+
shouldRefreshBedrockStatus({
|
|
784
|
+
...base,
|
|
785
|
+
env: { MODEL_OVERRIDE: "amazon-bedrock/anthropic.claude" },
|
|
786
|
+
now,
|
|
787
|
+
}),
|
|
788
|
+
).toBe(true);
|
|
789
|
+
});
|
|
790
|
+
|
|
791
|
+
test("never fires outside Bedrock mode or for a non-pi harness", () => {
|
|
792
|
+
const now = 1_000 + INTERVAL + 1;
|
|
793
|
+
expect(shouldRefreshBedrockStatus({ ...base, env: { ANTHROPIC_API_KEY: "sk" }, now })).toBe(
|
|
794
|
+
false,
|
|
795
|
+
);
|
|
796
|
+
expect(
|
|
797
|
+
shouldRefreshBedrockStatus({ ...base, env: { MODEL_OVERRIDE: "anthropic/claude" }, now }),
|
|
798
|
+
).toBe(false);
|
|
799
|
+
expect(
|
|
800
|
+
shouldRefreshBedrockStatus({
|
|
801
|
+
...base,
|
|
802
|
+
harnessProvider: "claude",
|
|
803
|
+
env: { BEDROCK_AUTH_MODE: "bearer" },
|
|
804
|
+
now,
|
|
805
|
+
}),
|
|
806
|
+
).toBe(false);
|
|
807
|
+
});
|
|
808
|
+
});
|
|
809
|
+
|
|
810
|
+
describe("validateProviderCredentials: pi Bedrock pass-through", () => {
|
|
811
|
+
const saved = { ...process.env };
|
|
812
|
+
const restore = () => {
|
|
813
|
+
for (const key of Object.keys(process.env)) if (!(key in saved)) delete process.env[key];
|
|
814
|
+
Object.assign(process.env, saved);
|
|
815
|
+
};
|
|
816
|
+
|
|
817
|
+
test("bearer mode is a pass-through like sdk mode: no provider-key live test is issued", async () => {
|
|
818
|
+
const realFetch = globalThis.fetch;
|
|
819
|
+
// A stray provider key must not be live-tested: the Bedrock enumeration already ran.
|
|
820
|
+
process.env.BEDROCK_AUTH_MODE = "bearer";
|
|
821
|
+
process.env.AWS_BEARER_TOKEN_BEDROCK = "bedrock-api-key";
|
|
822
|
+
process.env.ANTHROPIC_API_KEY = "x";
|
|
823
|
+
globalThis.fetch = (async () => {
|
|
824
|
+
throw new Error("live test must not reach the network in Bedrock mode");
|
|
825
|
+
}) as typeof fetch;
|
|
826
|
+
try {
|
|
827
|
+
expect(await validateProviderCredentials("pi")).toEqual({ ok: true, latency_ms: 0 });
|
|
828
|
+
} finally {
|
|
829
|
+
globalThis.fetch = realFetch;
|
|
830
|
+
restore();
|
|
831
|
+
}
|
|
832
|
+
});
|
|
833
|
+
});
|
|
834
|
+
|
|
692
835
|
describe("REQUIRED_CRED_VARS_BY_PROVIDER", () => {
|
|
693
836
|
test("covers every supported provider", () => {
|
|
694
837
|
const providers = ["claude", "claude-managed", "codex", "devin", "opencode", "pi"] as const;
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import { afterEach, beforeEach, expect, spyOn, test } from "bun:test";
|
|
2
|
+
import * as db from "../be/db";
|
|
3
|
+
|
|
4
|
+
beforeEach(() => db.initDb(":memory:"));
|
|
5
|
+
afterEach(() => db.closeDb());
|
|
6
|
+
|
|
7
|
+
const worker = { name: "Worker", isLead: false, status: "idle" as const };
|
|
8
|
+
|
|
9
|
+
test("facade registration installs defaults and records lifecycle logs", async () => {
|
|
10
|
+
const skill = await db.createSkill({
|
|
11
|
+
name: "test-default",
|
|
12
|
+
description: "Default",
|
|
13
|
+
content: "Instructions",
|
|
14
|
+
type: "personal",
|
|
15
|
+
scope: "swarm",
|
|
16
|
+
systemDefault: true,
|
|
17
|
+
});
|
|
18
|
+
const agent = await db.createAgent(worker);
|
|
19
|
+
expect(
|
|
20
|
+
await db.getDbClient().get("SELECT skillId FROM agent_skills WHERE agentId = ?", [agent.id]),
|
|
21
|
+
).toEqual({ skillId: skill.id });
|
|
22
|
+
await db.updateAgentStatus(agent.id, "busy");
|
|
23
|
+
expect(
|
|
24
|
+
(await db.getLogsByAgentId(agent.id)).map(({ eventType, oldValue, newValue }) => ({
|
|
25
|
+
eventType,
|
|
26
|
+
oldValue,
|
|
27
|
+
newValue,
|
|
28
|
+
})),
|
|
29
|
+
).toEqual(
|
|
30
|
+
expect.arrayContaining([
|
|
31
|
+
{ eventType: "agent_joined", oldValue: undefined, newValue: "idle" },
|
|
32
|
+
{ eventType: "agent_status_change", oldValue: "idle", newValue: "busy" },
|
|
33
|
+
]),
|
|
34
|
+
);
|
|
35
|
+
// Logging precedes deletion, including when the existing log FK rejects deletion.
|
|
36
|
+
await db.getDbClient().run("CREATE TABLE deletion_probe (eventType TEXT, oldValue TEXT)");
|
|
37
|
+
await db
|
|
38
|
+
.getDbClient()
|
|
39
|
+
.run(
|
|
40
|
+
"CREATE TRIGGER deletion_log AFTER INSERT ON agent_log WHEN NEW.eventType = 'agent_left' BEGIN INSERT INTO deletion_probe VALUES (NEW.eventType, NEW.oldValue); END",
|
|
41
|
+
);
|
|
42
|
+
await expect(db.deleteAgent(agent.id)).rejects.toThrow("FOREIGN KEY constraint failed");
|
|
43
|
+
expect(await db.getDbClient().get("SELECT * FROM deletion_probe")).toEqual({
|
|
44
|
+
eventType: "agent_left",
|
|
45
|
+
oldValue: "busy",
|
|
46
|
+
});
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
test("skill and log failures retain the original catch boundaries", async () => {
|
|
50
|
+
await db.getDbClient().run("DROP TABLE skills");
|
|
51
|
+
await db
|
|
52
|
+
.getDbClient()
|
|
53
|
+
.run(
|
|
54
|
+
"CREATE TRIGGER reject_logs BEFORE INSERT ON agent_log BEGIN SELECT RAISE(FAIL, 'log failure'); END",
|
|
55
|
+
);
|
|
56
|
+
const warning = spyOn(console, "warn").mockImplementation(() => {});
|
|
57
|
+
try {
|
|
58
|
+
const agent = await db.createAgent(worker);
|
|
59
|
+
expect(warning).toHaveBeenCalledWith(
|
|
60
|
+
"[db] Failed to install system-default skills for new agent:",
|
|
61
|
+
expect.any(String),
|
|
62
|
+
);
|
|
63
|
+
expect((await db.updateAgentStatus(agent.id, "busy"))?.status).toBe("busy");
|
|
64
|
+
expect(await db.deleteAgent(agent.id)).toBe(true);
|
|
65
|
+
} finally {
|
|
66
|
+
warning.mockRestore();
|
|
67
|
+
}
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
test("unmoved profile and idle-worker callers share agent mapping defaults", async () => {
|
|
71
|
+
const agent = await db.createAgent(worker);
|
|
72
|
+
expect(agent).toMatchObject({
|
|
73
|
+
maxTasks: 1,
|
|
74
|
+
emptyPollCount: 0,
|
|
75
|
+
capabilities: [],
|
|
76
|
+
credentialMissing: null,
|
|
77
|
+
credStatus: null,
|
|
78
|
+
harnessProvider: null,
|
|
79
|
+
avatar: null,
|
|
80
|
+
});
|
|
81
|
+
const updated = await db.updateAgentProfile(agent.id, {
|
|
82
|
+
role: "coder",
|
|
83
|
+
capabilities: ["typescript"],
|
|
84
|
+
});
|
|
85
|
+
expect(updated).toEqual(await db.getAgentById(agent.id));
|
|
86
|
+
expect(await db.getIdleWorkersWithCapacity()).toEqual([updated!]);
|
|
87
|
+
await db
|
|
88
|
+
.getDbClient()
|
|
89
|
+
.run("UPDATE agents SET avatar = ? WHERE id = ?", ["invalid json", agent.id]);
|
|
90
|
+
expect((await db.getAgentById(agent.id))?.avatar).toBeNull();
|
|
91
|
+
});
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { afterEach, beforeEach, expect, test } from "bun:test";
|
|
2
|
+
import * as db from "../be/db";
|
|
3
|
+
|
|
4
|
+
beforeEach(() => db.initDb(":memory:"));
|
|
5
|
+
afterEach(() => db.closeDb());
|
|
6
|
+
|
|
7
|
+
const worker = { name: "Worker", isLead: false, status: "idle" as const };
|
|
8
|
+
|
|
9
|
+
test("context history keeps version ordering, limits, hashes and null defaults", async () => {
|
|
10
|
+
const agent = await db.createAgent(worker);
|
|
11
|
+
const versions = [];
|
|
12
|
+
for (const version of [2, 1, 3]) {
|
|
13
|
+
versions.push(
|
|
14
|
+
await db.createContextVersion({
|
|
15
|
+
agentId: agent.id,
|
|
16
|
+
field: "soulMd",
|
|
17
|
+
content: `v${version}`,
|
|
18
|
+
version,
|
|
19
|
+
changeSource: "system",
|
|
20
|
+
contentHash: db.computeContentHash(`v${version}`),
|
|
21
|
+
}),
|
|
22
|
+
);
|
|
23
|
+
}
|
|
24
|
+
expect(
|
|
25
|
+
(await db.getContextVersionHistory({ agentId: agent.id, field: "soulMd", limit: 2 })).map(
|
|
26
|
+
(v) => v.version,
|
|
27
|
+
),
|
|
28
|
+
).toEqual([3, 2]);
|
|
29
|
+
expect(await db.getLatestContextVersion(agent.id, "soulMd")).toEqual(versions[2]);
|
|
30
|
+
expect(await db.getContextVersion(versions[0]!.id)).toEqual(versions[0]!);
|
|
31
|
+
expect(versions[0]).toMatchObject({
|
|
32
|
+
changedByAgentId: null,
|
|
33
|
+
changeReason: null,
|
|
34
|
+
previousVersionId: null,
|
|
35
|
+
});
|
|
36
|
+
expect(await db.getLatestContextVersion(agent.id, "toolsMd")).toBeNull();
|
|
37
|
+
});
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { expect, test } from "bun:test";
|
|
2
|
+
import * as db from "../be/db";
|
|
3
|
+
import * as agents from "../be/db/agents";
|
|
4
|
+
import * as context from "../be/db/context-versions";
|
|
5
|
+
import * as taskRead from "../be/db/tasks/read";
|
|
6
|
+
import { CHILD_PROCESS_TEST_BUDGET_MS, expectChildOk, runChild } from "./test-proc";
|
|
7
|
+
|
|
8
|
+
test("facade exposes repository bindings without internal exports", () => {
|
|
9
|
+
for (const [name, value] of Object.entries({ ...agents, ...context, ...taskRead })) {
|
|
10
|
+
if (
|
|
11
|
+
[
|
|
12
|
+
"rowToAgent",
|
|
13
|
+
"configureAgentDependencies",
|
|
14
|
+
"rowToAgentTask",
|
|
15
|
+
"rowToAgentTaskSummary",
|
|
16
|
+
"configureTaskReadDependencies",
|
|
17
|
+
].includes(name)
|
|
18
|
+
) {
|
|
19
|
+
expect(name in db).toBe(false);
|
|
20
|
+
} else {
|
|
21
|
+
expect((db as Record<string, unknown>)[name]).toBe(value);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
test(
|
|
27
|
+
"fresh facade initialization does not access the database",
|
|
28
|
+
async () => {
|
|
29
|
+
const runtimePath = JSON.stringify(new URL("../be/db/runtime.ts", import.meta.url).pathname);
|
|
30
|
+
const facadePath = JSON.stringify(new URL("../be/db.ts", import.meta.url).pathname);
|
|
31
|
+
expectChildOk(
|
|
32
|
+
await runChild([process.execPath, "-"], {
|
|
33
|
+
stdin: `
|
|
34
|
+
import { spyOn } from "bun:test";
|
|
35
|
+
const runtime = await import(${runtimePath});
|
|
36
|
+
const access = spyOn(runtime, "getDbClient");
|
|
37
|
+
await import(${facadePath});
|
|
38
|
+
if (access.mock.calls.length) throw new Error("Facade initialization accessed DB client");
|
|
39
|
+
`,
|
|
40
|
+
}),
|
|
41
|
+
"facade initialization",
|
|
42
|
+
);
|
|
43
|
+
},
|
|
44
|
+
CHILD_PROCESS_TEST_BUDGET_MS,
|
|
45
|
+
);
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { afterEach, describe, expect, test } from "bun:test";
|
|
2
|
+
import * as facade from "../be/db";
|
|
3
|
+
import * as runtime from "../be/db/runtime";
|
|
4
|
+
|
|
5
|
+
const runtimeExports = [
|
|
6
|
+
"__resetSqliteVecExtensionPathCacheForTests",
|
|
7
|
+
"closeDb",
|
|
8
|
+
"getDb",
|
|
9
|
+
"getDbClient",
|
|
10
|
+
"initDb",
|
|
11
|
+
"isSqliteVecAvailable",
|
|
12
|
+
"resolveSqliteVecExtensionPath",
|
|
13
|
+
] as const;
|
|
14
|
+
|
|
15
|
+
afterEach(() => runtime.closeDb());
|
|
16
|
+
|
|
17
|
+
describe("database runtime facade", () => {
|
|
18
|
+
test("re-exports the same seven runtime bindings", () => {
|
|
19
|
+
expect(Object.keys(runtime).sort()).toEqual([...runtimeExports].sort());
|
|
20
|
+
expect(facade.__resetSqliteVecExtensionPathCacheForTests).toBe(
|
|
21
|
+
runtime.__resetSqliteVecExtensionPathCacheForTests,
|
|
22
|
+
);
|
|
23
|
+
expect(facade.closeDb).toBe(runtime.closeDb);
|
|
24
|
+
expect(facade.getDb).toBe(runtime.getDb);
|
|
25
|
+
expect(facade.getDbClient).toBe(runtime.getDbClient);
|
|
26
|
+
expect(facade.initDb).toBe(runtime.initDb);
|
|
27
|
+
expect(facade.isSqliteVecAvailable).toBe(runtime.isSqliteVecAvailable);
|
|
28
|
+
expect(facade.resolveSqliteVecExtensionPath).toBe(runtime.resolveSqliteVecExtensionPath);
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
test("shares one connection and reuses the async client across close/reopen", async () => {
|
|
32
|
+
const first = runtime.initDb(":memory:");
|
|
33
|
+
expect(facade.getDb()).toBe(first);
|
|
34
|
+
expect(facade.initDb(":memory:")).toBe(first);
|
|
35
|
+
const client = facade.getDbClient();
|
|
36
|
+
expect(runtime.getDbClient()).toBe(client);
|
|
37
|
+
await client.run("CREATE TABLE runtime_probe (value TEXT)");
|
|
38
|
+
await client.run("INSERT INTO runtime_probe VALUES (?)", ["first"]);
|
|
39
|
+
expect(await client.get("SELECT value FROM runtime_probe")).toEqual({ value: "first" });
|
|
40
|
+
|
|
41
|
+
facade.closeDb();
|
|
42
|
+
expect(runtime.isSqliteVecAvailable()).toBe(false);
|
|
43
|
+
runtime.closeDb();
|
|
44
|
+
const second = facade.initDb(":memory:");
|
|
45
|
+
expect(second).not.toBe(first);
|
|
46
|
+
expect(runtime.getDb()).toBe(second);
|
|
47
|
+
expect(runtime.getDbClient()).toBe(client);
|
|
48
|
+
expect(
|
|
49
|
+
await client.get("SELECT name FROM sqlite_master WHERE name = 'runtime_probe'"),
|
|
50
|
+
).toBeNull();
|
|
51
|
+
await client.run("CREATE TABLE runtime_probe (value TEXT)");
|
|
52
|
+
await client.run("INSERT INTO runtime_probe VALUES (?)", ["second"]);
|
|
53
|
+
expect(await client.get("SELECT value FROM runtime_probe")).toEqual({ value: "second" });
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
test("cold initialization still seeds templates", () => {
|
|
57
|
+
const globals = globalThis as typeof globalThis & { __testMigrationTemplate?: Uint8Array };
|
|
58
|
+
const template = globals.__testMigrationTemplate;
|
|
59
|
+
runtime.closeDb();
|
|
60
|
+
globals.__testMigrationTemplate = undefined;
|
|
61
|
+
try {
|
|
62
|
+
runtime.initDb(":memory:");
|
|
63
|
+
const templates = facade.getPromptTemplates({ scope: "global" });
|
|
64
|
+
expect(templates.length).toBeGreaterThan(0);
|
|
65
|
+
} finally {
|
|
66
|
+
runtime.closeDb();
|
|
67
|
+
globals.__testMigrationTemplate = template;
|
|
68
|
+
}
|
|
69
|
+
});
|
|
70
|
+
});
|