Improve imported agent adapter selection

This commit is contained in:
Dotta
2026-03-16 12:17:28 -05:00
parent 0763e2eb20
commit fed94d18f3
7 changed files with 95 additions and 20 deletions

View File

@@ -471,4 +471,71 @@ describe("company portability", () => {
},
]);
});
it("applies adapter overrides while keeping imported AGENTS content implicit", async () => {
const portability = companyPortabilityService({} as any);
companySvc.create.mockResolvedValue({
id: "company-imported",
name: "Imported Paperclip",
});
accessSvc.ensureMembership.mockResolvedValue(undefined);
agentSvc.create.mockResolvedValue({
id: "agent-created",
name: "ClaudeCoder",
});
const exported = await portability.exportBundle("company-1", {
include: {
company: true,
agents: true,
projects: false,
issues: false,
},
});
agentSvc.list.mockResolvedValue([]);
await portability.importBundle({
source: {
type: "inline",
rootPath: exported.rootPath,
files: exported.files,
},
include: {
company: true,
agents: true,
projects: false,
issues: false,
},
target: {
mode: "new_company",
newCompanyName: "Imported Paperclip",
},
agents: "all",
collisionStrategy: "rename",
adapterOverrides: {
claudecoder: {
adapterType: "codex_local",
adapterConfig: {
dangerouslyBypassApprovalsAndSandbox: true,
instructionsFilePath: "/tmp/should-not-survive.md",
},
},
},
}, "user-1");
expect(agentSvc.create).toHaveBeenCalledWith("company-imported", expect.objectContaining({
adapterType: "codex_local",
adapterConfig: expect.objectContaining({
promptTemplate: "You are ClaudeCoder.",
dangerouslyBypassApprovalsAndSandbox: true,
}),
}));
expect(agentSvc.create).toHaveBeenCalledWith("company-imported", expect.objectContaining({
adapterConfig: expect.not.objectContaining({
instructionsFilePath: expect.anything(),
}),
}));
});
});

View File

@@ -2274,7 +2274,7 @@ export function companyPortabilityService(db: Db) {
baseAdapterConfig,
desiredSkills,
);
delete baseAdapterConfig.instructionsFilePath;
delete adapterConfigWithSkills.instructionsFilePath;
const patch = {
name: planAgent.plannedName,
role: manifestAgent.role,