mirror of
https://github.com/paperclipai/paperclip.git
synced 2026-10-26 18:31:34 +01:00
Reject stale built-in approval setup retries
This commit is contained in:
1 parent
bce8dacb21
commit
0aee005b1f
2 files changed
+22
No files matched your search
@@ -197,6 +197,17 @@ describeEmbeddedPostgres("built-in agents", () => {
|
||||
},
|
||||
});
|
||||
|
||||
await expect(builtIns.provision(companyId, "briefs", {
|
||||
budgetMonthlyCents: 7500,
|
||||
})).rejects.toMatchObject({
|
||||
status: 409,
|
||||
details: {
|
||||
code: "built_in_agent_pending_approval",
|
||||
key: "briefs",
|
||||
agentId: result.state.agentId,
|
||||
},
|
||||
});
|
||||
|
||||
await db
|
||||
.update(agents)
|
||||
.set({
|
||||
|
||||
@@ -239,6 +239,10 @@ function builtInAgentNotConfiguredError(state: BuiltInAgentState) {
|
||||
});
|
||||
}
|
||||
|
||||
function hasProvisionSetupInput(input: BuiltInAgentProvisionInput) {
|
||||
return input.adapterType !== undefined || input.adapterConfig !== undefined || input.budgetMonthlyCents !== undefined;
|
||||
}
|
||||
|
||||
function rowIsBuiltInAgent(row: typeof agents.$inferSelect, key: string) {
|
||||
const marker = readBuiltInAgentMarker(row.metadata);
|
||||
return marker?.key === key;
|
||||
@@ -368,6 +372,13 @@ export function builtInAgentService(db: Db) {
|
||||
const existing = await findSingleAgent(companyId, definition);
|
||||
if (existing) {
|
||||
if (existing.status === "pending_approval") {
|
||||
if (hasProvisionSetupInput(input)) {
|
||||
throw conflict("Built-in agent setup is already pending board approval.", {
|
||||
code: "built_in_agent_pending_approval",
|
||||
key: definition.key,
|
||||
agentId: existing.id,
|
||||
});
|
||||
}
|
||||
const approval = await approvalSvc.findOpenHireApprovalForAgent(companyId, existing.id);
|
||||
return {
|
||||
state: state(definition, existing),
|
||||
|
||||
Reference in new issue
Block a user