Skip to content

Commit 6af6fe9

Browse files
authored
Merge pull request #94 from AgentWorkforce/ricky/sage-214-pr01a-persona-types
feat(persona): add shared persona type package
2 parents 50a004b + d38d98e commit 6af6fe9

7 files changed

Lines changed: 205 additions & 19 deletions

File tree

package-lock.json

Lines changed: 33 additions & 19 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
"packages/vfs",
99
"packages/harness",
1010
"packages/memory",
11+
"packages/persona",
1112
"packages/inbox",
1213
"packages/continuation",
1314
"packages/turn-context",

packages/persona/package.json

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
{
2+
"name": "@agent-assistant/persona",
3+
"version": "0.1.0",
4+
"description": "Shared persona type contracts for agent assistant services",
5+
"type": "module",
6+
"main": "dist/index.js",
7+
"types": "dist/index.d.ts",
8+
"exports": {
9+
".": {
10+
"import": "./dist/index.js",
11+
"types": "./dist/index.d.ts"
12+
}
13+
},
14+
"files": [
15+
"dist"
16+
],
17+
"scripts": {
18+
"prepack": "npm run build",
19+
"build": "tsc -p tsconfig.json",
20+
"test": "vitest run",
21+
"test:watch": "vitest",
22+
"typecheck": "tsc --noEmit -p tsconfig.json"
23+
},
24+
"devDependencies": {
25+
"typescript": "^5.9.3",
26+
"vitest": "^3.2.4"
27+
},
28+
"license": "MIT"
29+
}

packages/persona/src/index.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
export type {
2+
PersonaDefinition,
3+
PersonaDeliveryConfig,
4+
PersonaExecutor,
5+
PersonaMemoryConfig,
6+
PersonaTrigger,
7+
RouterConfig,
8+
SandboxBorrowConfig,
9+
} from "./types.js";

packages/persona/src/types.test.ts

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
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+
});

packages/persona/src/types.ts

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
export interface RouterConfig {
2+
endpoint: string;
3+
method?: "POST";
4+
timeoutMs?: number;
5+
headers?: Record<string, string>;
6+
}
7+
8+
export interface SandboxBorrowConfig {
9+
snapshot: string;
10+
lifecycle?: "ephemeral" | "warm-pool";
11+
ttlSeconds?: number;
12+
maxConcurrentBorrows?: number;
13+
capabilities?: string[];
14+
}
15+
16+
export type PersonaExecutor =
17+
| { kind: "ephemeral-sandbox" }
18+
| { kind: "http-delegate"; router: RouterConfig }
19+
| { kind: "hybrid"; router: RouterConfig; sandbox: SandboxBorrowConfig };
20+
21+
export type PersonaTrigger =
22+
| { kind: "cron"; cron: string; timezone?: string; name?: string }
23+
| { kind: "webhook"; provider: string; event?: string; path?: string }
24+
| { kind: "inbox"; channel?: string; event?: string };
25+
26+
export interface PersonaMemoryConfig {
27+
backend?: "agent-memory" | "supermemory" | "none";
28+
namespace?: string;
29+
}
30+
31+
export interface PersonaDeliveryConfig {
32+
mode?: "inline" | "callback" | "direct";
33+
callbackUrl?: string;
34+
}
35+
36+
export interface PersonaDefinition {
37+
id: string;
38+
displayName: string;
39+
version: string;
40+
description?: string;
41+
ownerService?: "sage" | "nightcto" | "msd-app" | "workforce" | (string & {});
42+
sourceTag?: string;
43+
executor: PersonaExecutor;
44+
triggers?: PersonaTrigger[];
45+
memory?: PersonaMemoryConfig;
46+
delivery?: PersonaDeliveryConfig;
47+
metadata?: Record<string, unknown>;
48+
}

packages/persona/tsconfig.json

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{
2+
"compilerOptions": {
3+
"target": "ES2022",
4+
"module": "NodeNext",
5+
"moduleResolution": "NodeNext",
6+
"declaration": true,
7+
"outDir": "dist",
8+
"rootDir": "src",
9+
"strict": true,
10+
"exactOptionalPropertyTypes": true,
11+
"esModuleInterop": true,
12+
"forceConsistentCasingInFileNames": true,
13+
"skipLibCheck": true,
14+
"noUncheckedIndexedAccess": true
15+
},
16+
"include": [
17+
"src/**/*.ts"
18+
]
19+
}

0 commit comments

Comments
 (0)