mirror of
https://github.com/paperclipai/paperclip.git
synced 2026-11-11 05:11:49 +01:00
Materialize built-in bundles after approval
Co-Authored-By: Paperclip <noreply@paperclip.ing>
This commit is contained in:
1 parent
b63e5a624d
commit
4f2419f7b2
2 files changed
+15
-1
No files matched your search
@@ -591,13 +591,19 @@ describeEmbeddedPostgres("built-in agents", () => {
|
||||
});
|
||||
|
||||
await approvalService(db).approve(approval.id, "board-user", "Approved Reflection Coach");
|
||||
await expect(builtInAgentService(db).get(companyId, "reflection-coach")).resolves.toMatchObject({
|
||||
const approvedState = await builtInAgentService(db).get(companyId, "reflection-coach");
|
||||
expect(approvedState).toMatchObject({
|
||||
agent: {
|
||||
permissions: {
|
||||
builtInMutationPolicy: mutationPolicy,
|
||||
},
|
||||
},
|
||||
});
|
||||
expect(approvedState.resources.map((resource) => resource.stockStatus)).toEqual([
|
||||
"stock_current",
|
||||
"stock_current",
|
||||
"stock_current",
|
||||
]);
|
||||
|
||||
await reconcileBuiltInAgentsOnStartup(db);
|
||||
const agentRows = await db.select().from(agents).where(eq(agents.companyId, companyId));
|
||||
|
||||
@@ -24,6 +24,13 @@ export function approvalService(db: Db) {
|
||||
};
|
||||
}
|
||||
|
||||
async function reconcileApprovedBuiltInAgent(companyId: string, payload: Record<string, unknown>) {
|
||||
const sourceBuiltInAgentKey = typeof payload.sourceBuiltInAgentKey === "string" ? payload.sourceBuiltInAgentKey : null;
|
||||
if (!sourceBuiltInAgentKey) return;
|
||||
const { builtInAgentService } = await import("./built-in-agents.js");
|
||||
await builtInAgentService(db).ensure(companyId, sourceBuiltInAgentKey);
|
||||
}
|
||||
|
||||
async function getExistingApproval(id: string) {
|
||||
const existing = await db
|
||||
.select()
|
||||
@@ -129,6 +136,7 @@ export function approvalService(db: Db) {
|
||||
const payloadAgentId = typeof payload.agentId === "string" ? payload.agentId : null;
|
||||
if (payloadAgentId) {
|
||||
await agentsSvc.activatePendingApproval(payloadAgentId, payload);
|
||||
await reconcileApprovedBuiltInAgent(updated.companyId, payload);
|
||||
hireApprovedAgentId = payloadAgentId;
|
||||
} else {
|
||||
const created = await agentsSvc.create(updated.companyId, {
|
||||
|
||||
Reference in new issue
Block a user