test(connector-id): migrate fixtures and assertions to pi-mono ids
Replaces legacy adapter ids (codex_local / claude_local / gemini_local / claude_compatible) across ~42 test files with pi-mono equivalents: - codex_local → openai-codex - claude_local → claude-pro - gemini_local → gemini-cli - claude_compatible → anthropic Hand-rewrites where fixture semantics changed: - connector-matching: TASK_TYPE_PREFERENCE ordering rebased (claude-pro first for code/content/management; google first for research) - connector-model-policy: getModels(provider) from pi-ai instead of the deleted adapter.module.models array - session-management + edge-case-session: adapter exemption removed; rotation now uniform under pi-mono - ipc-core-admin-handlers: CSV compat model replaced with pi-ai anthropic - connectors.spec: lookup by openai-codex id (catalog now starts with claude-pro) - onboarding-model-pool: listProviderModels(provider) helper; label text changed to "ChatGPT Plus/Pro (Codex)" - database integration: added vault insecure-fallback env + electron mock - command-paths: uses new @main/connector-helpers normalizeCommandValue - pi-mono-migrations: added `as string` casts for 3 negative-existence assertions verifying legacy ids were removed Drops: - pnpm-workspace.yaml packages: [] (was "packages/*"; directory empty) - obsolete CONNECTOR_STRENGTHS import; .module.models probing Verification: - pnpm typecheck → 0 errors - pnpm lint → 0 errors / 0 warnings - pnpm build:verify → 0 errors / 0 warnings - pnpm test:unit → 508/508 pass - pnpm test:integration → 96/96 pass - All 6 adapter hard gates pass (NOT FOUND / 0 matches / empty) - pi-ai / pi-agent-core / pi-coding-agent all resolved @0.67.6
This commit is contained in:
1 parent
4de9cd0339
commit
e94939a562
80 files changed
+2210
-413
No files matched your search
@@ -71,7 +71,7 @@ describe("agent model switching", () => {
|
||||
db.init();
|
||||
|
||||
db.updateConnectorHealth({
|
||||
id: "codex_local",
|
||||
id: "openai-codex",
|
||||
status: "ready",
|
||||
authState: "authenticated",
|
||||
version: "test",
|
||||
@@ -98,7 +98,7 @@ describe("agent model switching", () => {
|
||||
title: "Frontend Engineer",
|
||||
status: "idle",
|
||||
reportsTo: null,
|
||||
connectorId: "codex_local",
|
||||
connectorId: "openai-codex",
|
||||
workspaceId,
|
||||
model: "gpt-5.4",
|
||||
capabilities: "Build frontend features",
|
||||
@@ -147,7 +147,7 @@ describe("agent model switching", () => {
|
||||
title: "Frontend Engineer",
|
||||
status: "idle",
|
||||
reportsTo: null,
|
||||
connectorId: "codex_local",
|
||||
connectorId: "openai-codex",
|
||||
workspaceId,
|
||||
model: "gpt-5.3-codex",
|
||||
capabilities: "Build frontend features",
|
||||
|
||||
@@ -25,7 +25,7 @@ async function createHarness() {
|
||||
db.init();
|
||||
|
||||
db.updateConnectorHealth({
|
||||
id: "codex_local",
|
||||
id: "openai-codex",
|
||||
status: "ready",
|
||||
authState: "authenticated",
|
||||
version: "test",
|
||||
@@ -52,7 +52,7 @@ async function createHarness() {
|
||||
title: "Chief Executive Officer",
|
||||
status: "active",
|
||||
reportsTo: null,
|
||||
connectorId: "codex_local",
|
||||
connectorId: "openai-codex",
|
||||
workspaceId,
|
||||
model: null,
|
||||
capabilities: "Lead the company",
|
||||
@@ -65,7 +65,7 @@ async function createHarness() {
|
||||
title: "Chief Technology Officer",
|
||||
status: "active",
|
||||
reportsTo: ceoId,
|
||||
connectorId: "codex_local",
|
||||
connectorId: "openai-codex",
|
||||
workspaceId,
|
||||
model: null,
|
||||
capabilities: "Lead engineering",
|
||||
@@ -81,7 +81,7 @@ async function createHarness() {
|
||||
priority: "high",
|
||||
status: "in_progress",
|
||||
});
|
||||
const run = db.createRun({ companyId, taskId, agentId: ctoId, workspaceId, connectorId: "codex_local" });
|
||||
const run = db.createRun({ companyId, taskId, agentId: ctoId, workspaceId, connectorId: "openai-codex" });
|
||||
const token = createAgentToken(ctoId, companyId, run.id);
|
||||
const server = createApiServer(db, () => {}, () => null);
|
||||
const port = await server.start();
|
||||
@@ -114,7 +114,7 @@ describe("recursive org execution", () => {
|
||||
role: "Engineer",
|
||||
title: "Frontend Engineer",
|
||||
department: "engineering",
|
||||
connectorId: "codex_local",
|
||||
connectorId: "openai-codex",
|
||||
workspaceId: harness.workspaceId,
|
||||
model: null,
|
||||
capabilities: "React, TypeScript, Tailwind, frontend delivery",
|
||||
@@ -176,7 +176,7 @@ describe("recursive org execution", () => {
|
||||
title: "Director of People",
|
||||
status: "active",
|
||||
reportsTo: harness.ceoId,
|
||||
connectorId: "codex_local",
|
||||
connectorId: "openai-codex",
|
||||
workspaceId: harness.workspaceId,
|
||||
model: null,
|
||||
capabilities: "Coordinate staffing",
|
||||
@@ -197,7 +197,7 @@ describe("recursive org execution", () => {
|
||||
taskId: hrTaskId,
|
||||
agentId: hrId,
|
||||
workspaceId: harness.workspaceId,
|
||||
connectorId: "codex_local",
|
||||
connectorId: "openai-codex",
|
||||
});
|
||||
const hrToken = createAgentToken(hrId, harness.companyId, hrRun.id);
|
||||
|
||||
@@ -213,7 +213,7 @@ describe("recursive org execution", () => {
|
||||
role: "Backend Engineer",
|
||||
title: "Backend Engineer Golang",
|
||||
department: "engineering",
|
||||
connectorId: "codex_local",
|
||||
connectorId: "openai-codex",
|
||||
workspaceId: harness.workspaceId,
|
||||
model: null,
|
||||
capabilities: "Go, PostgreSQL, distributed systems",
|
||||
@@ -243,7 +243,7 @@ describe("recursive org execution", () => {
|
||||
role: "Backend Engineer",
|
||||
title: "Backend Engineer Golang",
|
||||
department: "engineering",
|
||||
connectorId: "codex_local",
|
||||
connectorId: "openai-codex",
|
||||
workspaceId: harness.workspaceId,
|
||||
model: null,
|
||||
capabilities: "Go, APIs",
|
||||
@@ -270,7 +270,7 @@ describe("recursive org execution", () => {
|
||||
title: "Chief Marketing Officer",
|
||||
status: "active",
|
||||
reportsTo: harness.ceoId,
|
||||
connectorId: "codex_local",
|
||||
connectorId: "openai-codex",
|
||||
workspaceId: harness.workspaceId,
|
||||
model: null,
|
||||
capabilities: "Lead marketing",
|
||||
@@ -287,7 +287,7 @@ describe("recursive org execution", () => {
|
||||
title: "Misrouted Engineer",
|
||||
department: "engineering",
|
||||
reportsTo: cmoId,
|
||||
connectorId: "codex_local",
|
||||
connectorId: "openai-codex",
|
||||
workspaceId: harness.workspaceId,
|
||||
model: null,
|
||||
capabilities: "Should not report outside the CTO branch",
|
||||
|
||||
@@ -40,7 +40,7 @@ async function createHarness() {
|
||||
title: "Lead agent",
|
||||
status: "active",
|
||||
reportsTo: null,
|
||||
connectorId: "codex_local",
|
||||
connectorId: "openai-codex",
|
||||
workspaceId,
|
||||
model: null,
|
||||
capabilities: "Operate the company",
|
||||
@@ -55,7 +55,7 @@ async function createHarness() {
|
||||
priority: "high",
|
||||
status: "todo",
|
||||
});
|
||||
const run = db.createRun({ companyId, taskId, agentId, workspaceId, connectorId: "codex_local" });
|
||||
const run = db.createRun({ companyId, taskId, agentId, workspaceId, connectorId: "openai-codex" });
|
||||
const token = createAgentToken(agentId, companyId, run.id);
|
||||
const server = createApiServer(db, () => {}, () => null);
|
||||
const port = await server.start();
|
||||
|
||||
@@ -65,7 +65,7 @@ describe("Step 4: Hire approval + decideApproval", () => {
|
||||
type: "hire_agent",
|
||||
payloadSummary: "Hire CTO",
|
||||
impactSummary: "Test",
|
||||
payloadJson: JSON.stringify({ agentId: hireId, config: { connector: "codex_local" } }),
|
||||
payloadJson: JSON.stringify({ agentId: hireId, config: { connector: "openai-codex" } }),
|
||||
});
|
||||
|
||||
const approval = shared.db.getApprovalRecord(approvalId);
|
||||
|
||||
@@ -91,13 +91,13 @@ describe("Agent Messages", () => {
|
||||
beforeEach(() => {
|
||||
agentAId = shared.db.saveAgent({
|
||||
companyId: shared.companyId, name: "Alice", role: "Engineer", title: "Senior Engineer",
|
||||
department: "engineering", connectorId: "claude_local", status: "active",
|
||||
department: "engineering", connectorId: "claude-pro", status: "active",
|
||||
capabilities: "Backend development, API design, code review",
|
||||
budgetMonthlyUsd: 100,
|
||||
});
|
||||
agentBId = shared.db.saveAgent({
|
||||
companyId: shared.companyId, name: "Bob", role: "Designer", title: "UX Designer",
|
||||
department: "design", connectorId: "claude_local", status: "active",
|
||||
department: "design", connectorId: "claude-pro", status: "active",
|
||||
capabilities: "UI design, wireframing, user research",
|
||||
budgetMonthlyUsd: 100,
|
||||
});
|
||||
@@ -242,13 +242,13 @@ describe("Auto Task Assignment", () => {
|
||||
beforeEach(() => {
|
||||
backendId = shared.db.saveAgent({
|
||||
companyId: shared.companyId, name: "Backend Dev", role: "Backend Engineer", title: "Senior Backend",
|
||||
department: "engineering", connectorId: "codex_local", status: "active",
|
||||
department: "engineering", connectorId: "openai-codex", status: "active",
|
||||
capabilities: "API development, database design, Node.js, PostgreSQL, backend testing",
|
||||
budgetMonthlyUsd: 200,
|
||||
});
|
||||
frontendId = shared.db.saveAgent({
|
||||
companyId: shared.companyId, name: "Frontend Dev", role: "Frontend Engineer", title: "Senior Frontend",
|
||||
department: "engineering", connectorId: "codex_local", status: "active",
|
||||
department: "engineering", connectorId: "openai-codex", status: "active",
|
||||
capabilities: "React, TypeScript, CSS, Tailwind, responsive design, frontend testing, UI components",
|
||||
budgetMonthlyUsd: 200,
|
||||
});
|
||||
@@ -290,8 +290,8 @@ describe("Auto Task Assignment", () => {
|
||||
|
||||
it("returns null if all agents have exhausted their budget", () => {
|
||||
// Set positive budgets that are fully spent
|
||||
shared.db.saveAgent({ id: backendId, companyId: shared.companyId, name: "Backend Dev", role: "Backend", title: "Backend", connectorId: "codex_local", status: "active", capabilities: "backend", budgetMonthlyUsd: 100 });
|
||||
shared.db.saveAgent({ id: frontendId, companyId: shared.companyId, name: "Frontend Dev", role: "Frontend", title: "Frontend", connectorId: "codex_local", status: "active", capabilities: "frontend", budgetMonthlyUsd: 100 });
|
||||
shared.db.saveAgent({ id: backendId, companyId: shared.companyId, name: "Backend Dev", role: "Backend", title: "Backend", connectorId: "openai-codex", status: "active", capabilities: "backend", budgetMonthlyUsd: 100 });
|
||||
shared.db.saveAgent({ id: frontendId, companyId: shared.companyId, name: "Frontend Dev", role: "Frontend", title: "Frontend", connectorId: "openai-codex", status: "active", capabilities: "frontend", budgetMonthlyUsd: 100 });
|
||||
// Exhaust budgets by recording spending via direct SQL (since finishRun would need a real run)
|
||||
(shared.db as unknown as { db: { prepare: (sql: string) => { run: (...args: unknown[]) => void } } }).db.prepare("update agents set spent_monthly_usd = 100 where id = ?").run(backendId);
|
||||
(shared.db as unknown as { db: { prepare: (sql: string) => { run: (...args: unknown[]) => void } } }).db.prepare("update agents set spent_monthly_usd = 100 where id = ?").run(frontendId);
|
||||
|
||||
@@ -28,7 +28,7 @@ describe("Step 7: Worker crash recovery (database layer)", () => {
|
||||
taskId,
|
||||
agentId,
|
||||
workspaceId: shared.workspaceId,
|
||||
connectorId: "codex_local",
|
||||
connectorId: "openai-codex",
|
||||
});
|
||||
|
||||
shared.db.markRunStatus(run.id, "running", "Started");
|
||||
@@ -66,7 +66,7 @@ describe("Step 7: Worker crash recovery (database layer)", () => {
|
||||
taskId,
|
||||
agentId,
|
||||
workspaceId: shared.workspaceId,
|
||||
connectorId: "codex_local",
|
||||
connectorId: "openai-codex",
|
||||
});
|
||||
|
||||
shared.db.markRunStatus(run.id, "running", "Started");
|
||||
|
||||
@@ -27,7 +27,7 @@ describe("Step 6: Run failure escalation (database layer)", () => {
|
||||
taskId,
|
||||
agentId,
|
||||
workspaceId: shared.workspaceId,
|
||||
connectorId: "codex_local",
|
||||
connectorId: "openai-codex",
|
||||
});
|
||||
|
||||
shared.db.markRunStatus(run.id, "running", "Started");
|
||||
|
||||
@@ -88,7 +88,7 @@ export function installSharedSetup(): SharedHandle {
|
||||
title: "Test",
|
||||
status: "idle",
|
||||
reportsTo: null,
|
||||
connectorId: "codex_local",
|
||||
connectorId: "openai-codex",
|
||||
workspaceId: state.workspaceId,
|
||||
model: null,
|
||||
capabilities: "Test capabilities",
|
||||
|
||||
@@ -70,7 +70,7 @@ describe("connector model enforcement", () => {
|
||||
db.init();
|
||||
|
||||
db.updateConnectorHealth({
|
||||
id: "codex_local",
|
||||
id: "openai-codex",
|
||||
status: "ready",
|
||||
authState: "authenticated",
|
||||
version: "test",
|
||||
@@ -97,7 +97,7 @@ describe("connector model enforcement", () => {
|
||||
title: "Chief Executive Officer",
|
||||
status: "idle",
|
||||
reportsTo: null,
|
||||
connectorId: "codex_local",
|
||||
connectorId: "openai-codex",
|
||||
workspaceId,
|
||||
model: "gpt-5.4",
|
||||
capabilities: "Lead the company",
|
||||
@@ -113,7 +113,7 @@ describe("connector model enforcement", () => {
|
||||
status: "todo",
|
||||
});
|
||||
|
||||
db.setDisabledModels("codex_local", [{ id: "gpt-5.4", label: "gpt-5.4" }]);
|
||||
db.setDisabledModels("openai-codex", [{ id: "gpt-5.4", label: "gpt-5.4" }]);
|
||||
|
||||
const { taskRunner } = createOrchestrationHarness(db);
|
||||
const result = taskRunner.queueTaskRun(taskId, "manual", "board");
|
||||
@@ -134,7 +134,7 @@ describe("connector model enforcement", () => {
|
||||
db.init();
|
||||
|
||||
db.updateConnectorHealth({
|
||||
id: "codex_local",
|
||||
id: "openai-codex",
|
||||
status: "ready",
|
||||
authState: "authenticated",
|
||||
version: "test",
|
||||
@@ -161,7 +161,7 @@ describe("connector model enforcement", () => {
|
||||
title: "Chief Executive Officer",
|
||||
status: "idle",
|
||||
reportsTo: null,
|
||||
connectorId: "codex_local",
|
||||
connectorId: "openai-codex",
|
||||
workspaceId,
|
||||
model: "gpt-5.4",
|
||||
capabilities: "Lead the company",
|
||||
@@ -182,12 +182,12 @@ describe("connector model enforcement", () => {
|
||||
taskId,
|
||||
agentId,
|
||||
workspaceId,
|
||||
connectorId: "codex_local",
|
||||
connectorId: "openai-codex",
|
||||
});
|
||||
const checkoutSuccess = db.checkoutTask(taskId, run.id);
|
||||
expect(checkoutSuccess).toBe(true);
|
||||
|
||||
db.setDisabledModels("codex_local", [{ id: "gpt-5.4", label: "gpt-5.4" }]);
|
||||
db.setDisabledModels("openai-codex", [{ id: "gpt-5.4", label: "gpt-5.4" }]);
|
||||
|
||||
const { taskRunner } = createOrchestrationHarness(db);
|
||||
taskRunner.resumeQueuedRuns();
|
||||
|
||||
@@ -52,10 +52,10 @@ const mockLogger = {
|
||||
|
||||
/**
|
||||
* Creates a full entity scaffold with a budget policy:
|
||||
* company, workspace, connector (gemini_local), agent, goal, project, budget policy.
|
||||
* company, workspace, connector (gemini-cli), agent, goal, project, budget policy.
|
||||
*/
|
||||
function scaffold(db: AppDatabase, budgetAmountCents = 500): ScaffoldResult {
|
||||
const connectorId: ConnectorId = "gemini_local";
|
||||
const connectorId: ConnectorId = "gemini-cli";
|
||||
|
||||
db.saveConnector({
|
||||
id: connectorId,
|
||||
@@ -228,7 +228,7 @@ describe("Cross-Subsystem Pipeline (D-04)", () => {
|
||||
taskId,
|
||||
companyId: s.companyId,
|
||||
agentId: s.agentId,
|
||||
adapterType: "gemini_local",
|
||||
adapterType: "gemini-cli",
|
||||
sessionParamsJson: null,
|
||||
sessionDisplayId: null,
|
||||
});
|
||||
@@ -387,7 +387,7 @@ describe("Cross-Subsystem Pipeline (D-04)", () => {
|
||||
taskId,
|
||||
companyId: s.companyId,
|
||||
agentId: s.agentId,
|
||||
adapterType: "gemini_local",
|
||||
adapterType: "gemini-cli",
|
||||
sessionParamsJson: null,
|
||||
sessionDisplayId: null,
|
||||
});
|
||||
|
||||
@@ -1,7 +1,21 @@
|
||||
import { mkdtemp, rm } from "node:fs/promises";
|
||||
import { join } from "node:path";
|
||||
import { tmpdir } from "node:os";
|
||||
import { afterEach, describe, expect, it } from "vitest";
|
||||
import { afterEach, beforeAll, describe, expect, it, vi } from "vitest";
|
||||
|
||||
beforeAll(() => {
|
||||
process.env.AGENTCOMPANY_ALLOW_INSECURE_VAULT = "true";
|
||||
});
|
||||
|
||||
vi.mock("electron", () => ({
|
||||
safeStorage: {
|
||||
isEncryptionAvailable: () => false,
|
||||
getSelectedStorageBackend: () => "basic_text",
|
||||
encryptString: (value: string) => Buffer.from(value, "utf8"),
|
||||
decryptString: (value: Buffer) => value.toString("utf8"),
|
||||
},
|
||||
}));
|
||||
|
||||
import { AppDatabase } from "../../src/main/database";
|
||||
|
||||
const tempDirs: string[] = [];
|
||||
@@ -45,7 +59,7 @@ describe("AppDatabase", () => {
|
||||
title: "Lead agent",
|
||||
status: "active",
|
||||
reportsTo: null,
|
||||
connectorId: "codex_local",
|
||||
connectorId: "openai-codex",
|
||||
workspaceId,
|
||||
model: null,
|
||||
capabilities: "Operate the company",
|
||||
@@ -89,7 +103,7 @@ describe("AppDatabase", () => {
|
||||
});
|
||||
|
||||
db.saveConnector({
|
||||
id: "codex_local",
|
||||
id: "openai-codex",
|
||||
command: "codex",
|
||||
model: null,
|
||||
envBindingText: "OPENAI_API_KEY=vault-openai",
|
||||
@@ -105,7 +119,7 @@ describe("AppDatabase", () => {
|
||||
taskId,
|
||||
agentId,
|
||||
workspaceId,
|
||||
connectorId: "codex_local",
|
||||
connectorId: "openai-codex",
|
||||
});
|
||||
|
||||
await db.appendRunLog(run.id, "stdout", "hello from run\n");
|
||||
@@ -190,7 +204,7 @@ describe("AppDatabase", () => {
|
||||
title: "",
|
||||
status: "active",
|
||||
reportsTo: null,
|
||||
connectorId: "codex_local",
|
||||
connectorId: "openai-codex",
|
||||
workspaceId: alphaWorkspaceId,
|
||||
model: null,
|
||||
capabilities: "Lead alpha",
|
||||
@@ -204,7 +218,7 @@ describe("AppDatabase", () => {
|
||||
title: "",
|
||||
status: "active",
|
||||
reportsTo: null,
|
||||
connectorId: "codex_local",
|
||||
connectorId: "openai-codex",
|
||||
workspaceId: betaWorkspaceId,
|
||||
model: null,
|
||||
capabilities: "Lead beta",
|
||||
|
||||
@@ -26,7 +26,7 @@ async function createHarness() {
|
||||
db.init();
|
||||
|
||||
db.updateConnectorHealth({
|
||||
id: "codex_local",
|
||||
id: "openai-codex",
|
||||
status: "ready",
|
||||
authState: "authenticated",
|
||||
version: "test",
|
||||
@@ -53,7 +53,7 @@ async function createHarness() {
|
||||
title: "Research Lead",
|
||||
status: "active",
|
||||
reportsTo: null,
|
||||
connectorId: "codex_local",
|
||||
connectorId: "openai-codex",
|
||||
workspaceId,
|
||||
model: null,
|
||||
capabilities: "Research and synthesis",
|
||||
@@ -86,7 +86,7 @@ async function createHarness() {
|
||||
taskId,
|
||||
agentId,
|
||||
workspaceId,
|
||||
connectorId: "codex_local",
|
||||
connectorId: "openai-codex",
|
||||
});
|
||||
const token = createAgentToken(agentId, companyId, run.id);
|
||||
const server = createApiServer(db, () => {}, () => null);
|
||||
|
||||
@@ -6,6 +6,16 @@ import { AppDatabase } from "../../src/main/database";
|
||||
import { createOnboardingService } from "../../src/main/onboarding-service";
|
||||
import { buildRunPayload } from "../../src/main/orchestration/turn-context";
|
||||
import { getConnectorDefinition } from "../../src/main/connectors";
|
||||
import { getModels } from "@mariozechner/pi-ai";
|
||||
|
||||
function listProviderModels(provider: string): Array<{ id: string; label: string }> {
|
||||
try {
|
||||
const models = getModels(provider as never);
|
||||
return models.map((model) => ({ id: model.id, label: model.name ?? model.id }));
|
||||
} catch {
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
||||
const tempDirs: string[] = [];
|
||||
|
||||
@@ -80,22 +90,22 @@ describe("onboarding model pool integration", () => {
|
||||
const db = new AppDatabase(profileDir);
|
||||
db.init();
|
||||
|
||||
const codexDefinition = getConnectorDefinition("codex_local");
|
||||
const enabledModel = codexDefinition.module.models?.[0]?.id;
|
||||
const disabledModel = codexDefinition.module.models?.[1]?.id;
|
||||
const codexDefinition = getConnectorDefinition("openai-codex");
|
||||
const enabledModel = listProviderModels(codexDefinition.provider)[0]?.id;
|
||||
const disabledModel = listProviderModels(codexDefinition.provider)[1]?.id;
|
||||
|
||||
if (!enabledModel || !disabledModel) {
|
||||
throw new Error("codex_local requires at least two models for this integration test.");
|
||||
throw new Error("openai-codex requires at least two models for this integration test.");
|
||||
}
|
||||
|
||||
db.updateConnectorHealth({
|
||||
id: "codex_local",
|
||||
id: "openai-codex",
|
||||
status: "ready",
|
||||
authState: "authenticated",
|
||||
version: "test",
|
||||
lastError: null,
|
||||
});
|
||||
db.setDisabledModels("codex_local", [{ id: disabledModel, label: disabledModel }]);
|
||||
db.setDisabledModels("openai-codex", [{ id: disabledModel, label: disabledModel }]);
|
||||
|
||||
const summary = createBootstrapHarness(db).bootstrapOnboarding({
|
||||
companyName: "Model Governance Co",
|
||||
@@ -106,7 +116,7 @@ describe("onboarding model pool integration", () => {
|
||||
executionMode: "ai_ceo",
|
||||
goalTitle: "Launch runtime-safe company",
|
||||
goalDescription: "Ensure onboarding connector models flow into runtime decisions.",
|
||||
connectorId: "codex_local",
|
||||
connectorId: "openai-codex",
|
||||
connectorModel: enabledModel,
|
||||
});
|
||||
|
||||
@@ -115,9 +125,9 @@ describe("onboarding model pool integration", () => {
|
||||
}
|
||||
|
||||
const agent = db.getAgent(summary.leadAgentId);
|
||||
expect(agent.connectorId).toBe("codex_local");
|
||||
expect(agent.connectorId).toBe("openai-codex");
|
||||
expect(agent.model).toBe(enabledModel);
|
||||
expect(db.getDisabledModels("codex_local")).toEqual([{ id: disabledModel, label: disabledModel }]);
|
||||
expect(db.getDisabledModels("openai-codex")).toEqual([{ id: disabledModel, label: disabledModel }]);
|
||||
expect(db.getCurrentCompanyId()).toBe(summary.companyId);
|
||||
|
||||
const payload = buildKickoffPayload(db, summary);
|
||||
@@ -128,7 +138,7 @@ describe("onboarding model pool integration", () => {
|
||||
expect(systemPrompt).toContain(enabledModel);
|
||||
const codexConnectorLine = systemPrompt
|
||||
.split("\n")
|
||||
.find((line) => line.includes("**Codex**"));
|
||||
.find((line) => line.includes("ChatGPT Plus/Pro (Codex)"));
|
||||
expect(codexConnectorLine).toBeDefined();
|
||||
expect(codexConnectorLine).not.toContain(`, ${disabledModel},`);
|
||||
expect(codexConnectorLine).not.toContain(` ${disabledModel}.`);
|
||||
@@ -136,46 +146,53 @@ describe("onboarding model pool integration", () => {
|
||||
db.close();
|
||||
});
|
||||
|
||||
it("uses compat connector csv models minus disabled entries in runtime prompt context", async () => {
|
||||
it("excludes disabled pi-ai models from anthropic connector runtime prompt context", async () => {
|
||||
const profileDir = await createTempDir("agentcompany-onboarding-compat-");
|
||||
const workspaceDir = await createTempDir("agentcompany-onboarding-compat-workspace-");
|
||||
const db = new AppDatabase(profileDir);
|
||||
db.init();
|
||||
|
||||
db.saveConnector({
|
||||
id: "claude_compatible",
|
||||
command: "claude",
|
||||
model: "model-alpha,model-beta,model-gamma",
|
||||
envBindingText: "",
|
||||
notes: "Custom provider",
|
||||
});
|
||||
const anthropicDefinition = getConnectorDefinition("anthropic");
|
||||
const anthropicModels = listProviderModels(anthropicDefinition.provider);
|
||||
const enabledModel = anthropicModels[0]?.id;
|
||||
const disabledModel = anthropicModels[1]?.id;
|
||||
if (!enabledModel || !disabledModel) {
|
||||
throw new Error("anthropic provider must expose at least two models from pi-ai.");
|
||||
}
|
||||
|
||||
db.updateConnectorHealth({
|
||||
id: "claude_compatible",
|
||||
id: "anthropic",
|
||||
status: "ready",
|
||||
authState: "authenticated",
|
||||
version: "test",
|
||||
lastError: null,
|
||||
});
|
||||
db.setDisabledModels("claude_compatible", [{ id: "model-beta", label: "model-beta" }]);
|
||||
db.setDisabledModels("anthropic", [{ id: disabledModel, label: disabledModel }]);
|
||||
|
||||
const summary = createBootstrapHarness(db).bootstrapOnboarding({
|
||||
companyName: "Compat Governance Co",
|
||||
companyDescription: "Tests compat model governance",
|
||||
companyName: "Anthropic Governance Co",
|
||||
companyDescription: "Tests anthropic model governance",
|
||||
workspacePath: workspaceDir,
|
||||
autoApproveHires: true,
|
||||
reviewDeliverables: false,
|
||||
executionMode: "ai_ceo",
|
||||
goalTitle: "Launch compat company",
|
||||
goalDescription: "Ensure compat model pools survive onboarding and runtime prompt assembly.",
|
||||
connectorId: "claude_compatible",
|
||||
connectorModel: "model-alpha",
|
||||
goalTitle: "Launch anthropic company",
|
||||
goalDescription: "Ensure anthropic model pools survive onboarding and runtime prompt assembly.",
|
||||
connectorId: "anthropic",
|
||||
connectorModel: enabledModel,
|
||||
});
|
||||
|
||||
const payload = buildKickoffPayload(db, summary);
|
||||
expect(payload.systemPrompt).not.toBeNull();
|
||||
const systemPrompt = payload.systemPrompt ?? "";
|
||||
expect(systemPrompt).toContain("Enabled models: model-alpha, model-gamma.");
|
||||
expect(systemPrompt).not.toContain("model-beta");
|
||||
expect(systemPrompt).toContain("Enabled models:");
|
||||
expect(systemPrompt).toContain(enabledModel);
|
||||
const anthropicLine = systemPrompt
|
||||
.split("\n")
|
||||
.find((line) => line.includes(anthropicDefinition.label));
|
||||
expect(anthropicLine).toBeDefined();
|
||||
expect(anthropicLine).not.toContain(`, ${disabledModel},`);
|
||||
expect(anthropicLine).not.toContain(` ${disabledModel}.`);
|
||||
|
||||
db.close();
|
||||
});
|
||||
@@ -187,7 +204,7 @@ describe("onboarding model pool integration", () => {
|
||||
db.init();
|
||||
|
||||
db.updateConnectorHealth({
|
||||
id: "codex_local",
|
||||
id: "openai-codex",
|
||||
status: "ready",
|
||||
authState: "authenticated",
|
||||
version: "test",
|
||||
@@ -203,7 +220,7 @@ describe("onboarding model pool integration", () => {
|
||||
executionMode: "ai_ceo",
|
||||
goalTitle: "Launch default-mode company",
|
||||
goalDescription: "Leave the CEO model unset so runtime falls back to connector defaults.",
|
||||
connectorId: "codex_local",
|
||||
connectorId: "openai-codex",
|
||||
connectorModel: "",
|
||||
});
|
||||
|
||||
@@ -215,7 +232,7 @@ describe("onboarding model pool integration", () => {
|
||||
expect(agent.model).toBeNull();
|
||||
|
||||
const payload = buildKickoffPayload(db, summary);
|
||||
const defaultModel = getConnectorDefinition("codex_local").defaultModel;
|
||||
const defaultModel = getConnectorDefinition("openai-codex").defaultModel;
|
||||
expect(payload.model).toBe(defaultModel);
|
||||
|
||||
db.close();
|
||||
@@ -227,22 +244,22 @@ describe("onboarding model pool integration", () => {
|
||||
const db = new AppDatabase(profileDir);
|
||||
db.init();
|
||||
|
||||
const codexDefinition = getConnectorDefinition("codex_local");
|
||||
const codexDefinition = getConnectorDefinition("openai-codex");
|
||||
const defaultModel = codexDefinition.defaultModel;
|
||||
const fallbackModel = codexDefinition.module.models?.find((model) => model.id !== defaultModel)?.id;
|
||||
const fallbackModel = listProviderModels(codexDefinition.provider).find((model) => model.id !== defaultModel)?.id;
|
||||
|
||||
if (!defaultModel || !fallbackModel) {
|
||||
throw new Error("codex_local requires a default and fallback model for reroute testing.");
|
||||
throw new Error("openai-codex requires a default and fallback model for reroute testing.");
|
||||
}
|
||||
|
||||
db.updateConnectorHealth({
|
||||
id: "codex_local",
|
||||
id: "openai-codex",
|
||||
status: "ready",
|
||||
authState: "authenticated",
|
||||
version: "test",
|
||||
lastError: null,
|
||||
});
|
||||
db.setDisabledModels("codex_local", [{ id: defaultModel, label: defaultModel }]);
|
||||
db.setDisabledModels("openai-codex", [{ id: defaultModel, label: defaultModel }]);
|
||||
|
||||
const summary = createBootstrapHarness(db).bootstrapOnboarding({
|
||||
companyName: "Default Reroute Co",
|
||||
@@ -253,7 +270,7 @@ describe("onboarding model pool integration", () => {
|
||||
executionMode: "ai_ceo",
|
||||
goalTitle: "Launch rerouted company",
|
||||
goalDescription: "Ensure runtime picks the first enabled model when connector default is disabled.",
|
||||
connectorId: "codex_local",
|
||||
connectorId: "openai-codex",
|
||||
connectorModel: "",
|
||||
});
|
||||
|
||||
@@ -269,21 +286,21 @@ describe("onboarding model pool integration", () => {
|
||||
const db = new AppDatabase(profileDir);
|
||||
db.init();
|
||||
|
||||
const codexDefinition = getConnectorDefinition("codex_local");
|
||||
const disabledModel = codexDefinition.module.models?.[0]?.id;
|
||||
const codexDefinition = getConnectorDefinition("openai-codex");
|
||||
const disabledModel = listProviderModels(codexDefinition.provider)[0]?.id;
|
||||
|
||||
if (!disabledModel) {
|
||||
throw new Error("codex_local requires a model to validate onboarding rejection.");
|
||||
throw new Error("openai-codex requires a model to validate onboarding rejection.");
|
||||
}
|
||||
|
||||
db.updateConnectorHealth({
|
||||
id: "codex_local",
|
||||
id: "openai-codex",
|
||||
status: "ready",
|
||||
authState: "authenticated",
|
||||
version: "test",
|
||||
lastError: null,
|
||||
});
|
||||
db.setDisabledModels("codex_local", [{ id: disabledModel, label: disabledModel }]);
|
||||
db.setDisabledModels("openai-codex", [{ id: disabledModel, label: disabledModel }]);
|
||||
|
||||
expect(() => createBootstrapHarness(db).bootstrapOnboarding({
|
||||
companyName: "Rejected Model Co",
|
||||
@@ -294,9 +311,9 @@ describe("onboarding model pool integration", () => {
|
||||
executionMode: "ai_ceo",
|
||||
goalTitle: "Reject disabled model bootstrap",
|
||||
goalDescription: "Invalid explicit models should fail before the CEO is created.",
|
||||
connectorId: "codex_local",
|
||||
connectorId: "openai-codex",
|
||||
connectorModel: disabledModel,
|
||||
})).toThrow(`Codex does not allow model "${disabledModel}".`);
|
||||
})).toThrow(`${codexDefinition.label} does not allow model "${disabledModel}".`);
|
||||
|
||||
db.close();
|
||||
});
|
||||
|
||||
@@ -0,0 +1,153 @@
|
||||
import { mkdtemp, rm } from "node:fs/promises";
|
||||
import { tmpdir } from "node:os";
|
||||
import { join } from "node:path";
|
||||
import { afterEach, beforeAll, describe, expect, it } from "vitest";
|
||||
import { AppDatabase } from "../../src/main/database";
|
||||
|
||||
beforeAll(() => {
|
||||
// SecretVault gated for test contexts. Used by the credentials path
|
||||
// touched by migration 28's downstream consumers.
|
||||
process.env.AGENTCOMPANY_ALLOW_INSECURE_VAULT = "true";
|
||||
});
|
||||
|
||||
const tempDirs: string[] = [];
|
||||
|
||||
async function freshProfile(prefix: string) {
|
||||
const dir = await mkdtemp(join(tmpdir(), prefix));
|
||||
tempDirs.push(dir);
|
||||
return dir;
|
||||
}
|
||||
|
||||
afterEach(async () => {
|
||||
await Promise.all(tempDirs.splice(0).map((dir) => rm(dir, { recursive: true, force: true })));
|
||||
});
|
||||
|
||||
/**
|
||||
* Migration 27 (`session_entries`) and 28 (`credentials`) ship in the rebuild.
|
||||
* These tests verify both migrations:
|
||||
* - run cleanly on a fresh SQLite profile;
|
||||
* - are idempotent on subsequent `init()` calls (existing-user upgrade);
|
||||
* - leave their tables queryable.
|
||||
*/
|
||||
describe("pi-mono migrations 27 + 28", () => {
|
||||
it("creates session_entries on first init and accepts inserts", async () => {
|
||||
const dir = await freshProfile("agentcompany-migration-27-fresh-");
|
||||
const db = new AppDatabase(dir);
|
||||
db.init();
|
||||
|
||||
db.sessionEntries.append({
|
||||
taskSessionId: "test-session",
|
||||
kind: "message",
|
||||
role: "user",
|
||||
payloadJson: JSON.stringify({ role: "user", content: "hello" }),
|
||||
});
|
||||
const rows = db.sessionEntries.listActive("test-session");
|
||||
expect(rows).toHaveLength(1);
|
||||
expect(rows[0]?.kind).toBe("message");
|
||||
db.close();
|
||||
});
|
||||
|
||||
it("creates credentials on first init and accepts encrypted inserts", async () => {
|
||||
const dir = await freshProfile("agentcompany-migration-28-fresh-");
|
||||
const db = new AppDatabase(dir);
|
||||
db.init();
|
||||
|
||||
const cipher = db.vault.encrypt(JSON.stringify({ source: "literal", value: "sk-test-1234567890" }));
|
||||
db.credentialsTable.upsert({
|
||||
connectorId: "test-anthropic",
|
||||
kind: "api_key",
|
||||
backend: cipher.backend,
|
||||
ciphertext: cipher.payload,
|
||||
displayHint: "sk-test-...7890",
|
||||
status: "active",
|
||||
expiresAt: null,
|
||||
lastRefreshedAt: null,
|
||||
lastError: null,
|
||||
});
|
||||
|
||||
const rows = db.credentialsTable.list();
|
||||
expect(rows.some((row) => row.connectorId === "test-anthropic")).toBe(true);
|
||||
db.close();
|
||||
});
|
||||
|
||||
it("re-running init() on an existing profile does not re-apply migrations or duplicate rows", async () => {
|
||||
const dir = await freshProfile("agentcompany-migration-idempotent-");
|
||||
const dbA = new AppDatabase(dir);
|
||||
dbA.init();
|
||||
dbA.sessionEntries.append({
|
||||
taskSessionId: "session-x",
|
||||
kind: "message",
|
||||
role: "user",
|
||||
payloadJson: JSON.stringify({ role: "user", content: "first" }),
|
||||
});
|
||||
const cipher = dbA.vault.encrypt(JSON.stringify({ source: "literal", value: "sk-keep-me" }));
|
||||
dbA.credentialsTable.upsert({
|
||||
connectorId: "test-keep",
|
||||
kind: "api_key",
|
||||
backend: cipher.backend,
|
||||
ciphertext: cipher.payload,
|
||||
displayHint: "sk-keep-...e",
|
||||
status: "active",
|
||||
expiresAt: null,
|
||||
lastRefreshedAt: null,
|
||||
lastError: null,
|
||||
});
|
||||
dbA.close();
|
||||
|
||||
const dbB = new AppDatabase(dir);
|
||||
dbB.init();
|
||||
expect(dbB.sessionEntries.listActive("session-x")).toHaveLength(1);
|
||||
expect(dbB.credentialsTable.list().filter((row) => row.connectorId === "test-keep")).toHaveLength(1);
|
||||
dbB.close();
|
||||
});
|
||||
|
||||
it("session_entries respects the unique (task_session_id, sequence) index across replace cycles", async () => {
|
||||
const dir = await freshProfile("agentcompany-migration-replace-");
|
||||
const db = new AppDatabase(dir);
|
||||
db.init();
|
||||
|
||||
for (let i = 0; i < 3; i += 1) {
|
||||
db.sessionEntries.append({
|
||||
taskSessionId: "replace-test",
|
||||
kind: "message",
|
||||
role: "user",
|
||||
payloadJson: JSON.stringify({ role: "user", content: `t${i}` }),
|
||||
});
|
||||
}
|
||||
db.sessionEntries.replace({
|
||||
taskSessionId: "replace-test",
|
||||
entries: [
|
||||
{ kind: "compaction", role: null, payloadJson: JSON.stringify({ summary: "summarised" }) },
|
||||
{ kind: "message", role: "user", payloadJson: JSON.stringify({ role: "user", content: "post" }) },
|
||||
],
|
||||
});
|
||||
|
||||
const active = db.sessionEntries.listActive("replace-test");
|
||||
expect(active).toHaveLength(2);
|
||||
expect(active[0]?.kind).toBe("compaction");
|
||||
expect(active[1]?.kind).toBe("message");
|
||||
|
||||
const all = db.sessionEntries.listAll("replace-test");
|
||||
expect(all.length).toBe(5);
|
||||
expect(all.filter((row) => row.isSuperseded).length).toBe(3);
|
||||
db.close();
|
||||
});
|
||||
|
||||
it("seedConnectors prunes legacy connector rows and inserts the full pi-mono + Fireworks catalog", async () => {
|
||||
const dir = await freshProfile("agentcompany-migration-seed-");
|
||||
const db = new AppDatabase(dir);
|
||||
db.init();
|
||||
|
||||
const rows = db.listSnapshot().connectors.map((entry) => entry.id);
|
||||
expect(rows.length).toBe(26);
|
||||
expect(rows).toContain("claude-pro");
|
||||
expect(rows).toContain("amazon-bedrock");
|
||||
expect(rows).toContain("google-vertex");
|
||||
expect(rows).toContain("fireworks");
|
||||
expect(rows).toContain("fireworks-firepass");
|
||||
expect(rows.find((id) => (id as string) === "claude_local")).toBeUndefined();
|
||||
expect(rows.find((id) => (id as string) === "codex_local")).toBeUndefined();
|
||||
expect(rows.find((id) => (id as string) === "claude_compatible")).toBeUndefined();
|
||||
db.close();
|
||||
});
|
||||
});
|
||||
@@ -51,7 +51,7 @@ interface ScaffoldResult {
|
||||
|
||||
/** Creates a full entity scaffold: company, workspace, connector, agent, goal, project. */
|
||||
function scaffold(db: AppDatabase): ScaffoldResult {
|
||||
const connectorId: ConnectorId = "gemini_local";
|
||||
const connectorId: ConnectorId = "gemini-cli";
|
||||
|
||||
// Connector
|
||||
db.saveConnector({
|
||||
@@ -445,7 +445,7 @@ describe("Process Recovery -- Context Preservation (D-02)", () => {
|
||||
taskId,
|
||||
companyId: s.companyId,
|
||||
agentId: s.agentId,
|
||||
adapterType: "gemini_local",
|
||||
adapterType: "gemini-cli",
|
||||
sessionParamsJson: null,
|
||||
sessionDisplayId: null,
|
||||
});
|
||||
@@ -466,7 +466,7 @@ describe("Process Recovery -- Context Preservation (D-02)", () => {
|
||||
|
||||
const rotationResult = sessionService.evaluateRotation(
|
||||
session!,
|
||||
"gemini_local",
|
||||
"gemini-cli",
|
||||
{ maxRuns: 1 },
|
||||
);
|
||||
expect(rotationResult.shouldRotate).toBe(true);
|
||||
|
||||
@@ -25,7 +25,7 @@ describe("skill-aware capability registry", () => {
|
||||
db.init();
|
||||
|
||||
db.updateConnectorHealth({
|
||||
id: "codex_local",
|
||||
id: "openai-codex",
|
||||
status: "ready",
|
||||
authState: "authenticated",
|
||||
version: "test",
|
||||
@@ -53,7 +53,7 @@ describe("skill-aware capability registry", () => {
|
||||
title: "Engineer",
|
||||
status: "active",
|
||||
reportsTo: null,
|
||||
connectorId: "codex_local",
|
||||
connectorId: "openai-codex",
|
||||
workspaceId,
|
||||
model: null,
|
||||
capabilities: "General software delivery",
|
||||
@@ -66,7 +66,7 @@ describe("skill-aware capability registry", () => {
|
||||
title: "Frontend Specialist",
|
||||
status: "active",
|
||||
reportsTo: null,
|
||||
connectorId: "codex_local",
|
||||
connectorId: "openai-codex",
|
||||
workspaceId,
|
||||
model: null,
|
||||
capabilities: "General software delivery",
|
||||
@@ -116,7 +116,7 @@ describe("skill-aware capability registry", () => {
|
||||
db.init();
|
||||
|
||||
db.updateConnectorHealth({
|
||||
id: "codex_local",
|
||||
id: "openai-codex",
|
||||
status: "ready",
|
||||
authState: "authenticated",
|
||||
version: "test",
|
||||
@@ -143,7 +143,7 @@ describe("skill-aware capability registry", () => {
|
||||
title: "Chief Executive Officer",
|
||||
status: "active",
|
||||
reportsTo: null,
|
||||
connectorId: "codex_local",
|
||||
connectorId: "openai-codex",
|
||||
workspaceId,
|
||||
model: null,
|
||||
capabilities: "Lead the company",
|
||||
@@ -193,7 +193,7 @@ describe("skill-aware capability registry", () => {
|
||||
recentComments: [],
|
||||
socialAccounts: [],
|
||||
allConnectors: snapshot.connectors
|
||||
.filter((connector) => connector.id === "codex_local")
|
||||
.filter((connector) => connector.id === "openai-codex")
|
||||
.map((connector) => ({ id: connector.id, label: connector.label, status: connector.status, enabledModels: ["gpt-5.4"] })),
|
||||
companySkillCatalog: db.listCompanySkills(companyId).map((skill) => ({
|
||||
name: skill.name,
|
||||
|
||||
@@ -29,7 +29,7 @@ function createNoopLogger() {
|
||||
|
||||
function createScaffold(db: AppDatabase) {
|
||||
db.updateConnectorHealth({
|
||||
id: "codex_local",
|
||||
id: "openai-codex",
|
||||
status: "ready",
|
||||
authState: "authenticated",
|
||||
version: "test",
|
||||
@@ -57,7 +57,7 @@ function createScaffold(db: AppDatabase) {
|
||||
title: "Chief Executive Officer",
|
||||
status: "idle",
|
||||
reportsTo: null,
|
||||
connectorId: "codex_local",
|
||||
connectorId: "openai-codex",
|
||||
workspaceId,
|
||||
model: null,
|
||||
capabilities: "Lead the company",
|
||||
@@ -70,7 +70,7 @@ function createScaffold(db: AppDatabase) {
|
||||
title: "Lead Engineer",
|
||||
status: "idle",
|
||||
reportsTo: ceoId,
|
||||
connectorId: "codex_local",
|
||||
connectorId: "openai-codex",
|
||||
workspaceId,
|
||||
model: null,
|
||||
capabilities: "Ship features",
|
||||
@@ -140,7 +140,7 @@ describe("thread wait + heartbeat integration", () => {
|
||||
title: "Chief Marketing Officer",
|
||||
status: "idle",
|
||||
reportsTo: null,
|
||||
connectorId: "codex_local",
|
||||
connectorId: "openai-codex",
|
||||
workspaceId: db.getTask(taskId).workspaceId ?? null,
|
||||
model: null,
|
||||
capabilities: "Drive marketing work",
|
||||
|
||||
Reference in new issue
Block a user