|
| 1 | +import { describe, expect, it } from "vitest"; |
| 2 | +import type { PersonaDefinition } from "./types.js"; |
| 3 | + |
| 4 | +describe("persona type contracts", () => { |
| 5 | + it("supports ephemeral sandbox executors", () => { |
| 6 | + const persona = { |
| 7 | + id: "daily-research", |
| 8 | + displayName: "Daily Research", |
| 9 | + version: "0.1.0", |
| 10 | + ownerService: "sage", |
| 11 | + executor: { kind: "ephemeral-sandbox" }, |
| 12 | + triggers: [{ kind: "cron", cron: "0 9 * * *", timezone: "UTC" }], |
| 13 | + } satisfies PersonaDefinition; |
| 14 | + |
| 15 | + expect(persona.executor.kind).toBe("ephemeral-sandbox"); |
| 16 | + }); |
| 17 | + |
| 18 | + it("supports HTTP delegate executors", () => { |
| 19 | + const persona = { |
| 20 | + id: "nightcto-triage", |
| 21 | + displayName: "NightCTO Triage", |
| 22 | + version: "0.1.0", |
| 23 | + ownerService: "nightcto", |
| 24 | + executor: { |
| 25 | + kind: "http-delegate", |
| 26 | + router: { |
| 27 | + endpoint: "https://example.com/personas/nightcto", |
| 28 | + method: "POST", |
| 29 | + timeoutMs: 30_000, |
| 30 | + headers: { "x-persona": "nightcto" }, |
| 31 | + }, |
| 32 | + }, |
| 33 | + triggers: [{ kind: "webhook", provider: "github", event: "issue.opened" }], |
| 34 | + delivery: { mode: "callback", callbackUrl: "https://example.com/callback" }, |
| 35 | + } satisfies PersonaDefinition; |
| 36 | + |
| 37 | + expect(persona.executor.kind).toBe("http-delegate"); |
| 38 | + }); |
| 39 | + |
| 40 | + it("supports hybrid executors", () => { |
| 41 | + const persona = { |
| 42 | + id: "msd-app-helper", |
| 43 | + displayName: "MSD App Helper", |
| 44 | + version: "0.1.0", |
| 45 | + ownerService: "msd-app", |
| 46 | + executor: { |
| 47 | + kind: "hybrid", |
| 48 | + router: { |
| 49 | + endpoint: "https://example.com/personas/msd", |
| 50 | + }, |
| 51 | + sandbox: { |
| 52 | + snapshot: "persona-msd-base", |
| 53 | + lifecycle: "warm-pool", |
| 54 | + ttlSeconds: 600, |
| 55 | + maxConcurrentBorrows: 3, |
| 56 | + capabilities: ["repo-read", "browser"], |
| 57 | + }, |
| 58 | + }, |
| 59 | + triggers: [{ kind: "inbox", channel: "support", event: "message.created" }], |
| 60 | + memory: { backend: "agent-memory", namespace: "msd-app" }, |
| 61 | + metadata: { tier: "support" }, |
| 62 | + } satisfies PersonaDefinition; |
| 63 | + |
| 64 | + expect(persona.executor.kind).toBe("hybrid"); |
| 65 | + }); |
| 66 | +}); |
0 commit comments