mirror of
https://github.com/paperclipai/paperclip.git
synced 2026-11-10 12:37:55 +01:00
fix: keep provisioning run attribution in supported activity audit
Co-Authored-By: Paperclip <noreply@paperclip.ing>
This commit is contained in:
1 parent
e5682d22fa
commit
b6cd49d4b6
3 files changed
+7
-7
No files matched your search
@@ -380,6 +380,7 @@ describe("built-in agent routes", () => {
|
|||||||
const app = await createApp({
|
const app = await createApp({
|
||||||
type: "agent",
|
type: "agent",
|
||||||
agentId: "manager-agent",
|
agentId: "manager-agent",
|
||||||
|
runId: "native-request-run",
|
||||||
companyId,
|
companyId,
|
||||||
source: "agent_key",
|
source: "agent_key",
|
||||||
});
|
});
|
||||||
@@ -403,6 +404,7 @@ describe("built-in agent routes", () => {
|
|||||||
actorType: "agent",
|
actorType: "agent",
|
||||||
actorId: "manager-agent",
|
actorId: "manager-agent",
|
||||||
action: "approval.created",
|
action: "approval.created",
|
||||||
|
runId: "native-request-run",
|
||||||
entityId: "approval-1",
|
entityId: "approval-1",
|
||||||
}));
|
}));
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -189,7 +189,6 @@ export function builtInAgentRoutes(db: Db) {
|
|||||||
if (req.body.budgetMonthlyCents !== undefined) assertBoard(req);
|
if (req.body.budgetMonthlyCents !== undefined) assertBoard(req);
|
||||||
const result = await svc.provision(companyId, key, req.body, {
|
const result = await svc.provision(companyId, key, req.body, {
|
||||||
requestedByAgentId: actor.actorType === "agent" ? actor.actorId : null,
|
requestedByAgentId: actor.actorType === "agent" ? actor.actorId : null,
|
||||||
...(actor.runId ? { sourceRunId: actor.runId } : {}),
|
|
||||||
requestedByUserId: actor.actorType === "user" ? actor.actorId : null,
|
requestedByUserId: actor.actorType === "user" ? actor.actorId : null,
|
||||||
});
|
});
|
||||||
const { state, approval } = result;
|
const { state, approval } = result;
|
||||||
|
|||||||
@@ -75,7 +75,6 @@ export interface BuiltInAgentProvisionInput {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export interface BuiltInAgentProvisionActor {
|
export interface BuiltInAgentProvisionActor {
|
||||||
sourceRunId?: string | null;
|
|
||||||
requestedByAgentId?: string | null;
|
requestedByAgentId?: string | null;
|
||||||
requestedByUserId?: string | null;
|
requestedByUserId?: string | null;
|
||||||
}
|
}
|
||||||
@@ -1730,7 +1729,7 @@ export function builtInAgentService(db: Db) {
|
|||||||
companyId: string,
|
companyId: string,
|
||||||
key: string,
|
key: string,
|
||||||
input: BuiltInAgentProvisionInput = {},
|
input: BuiltInAgentProvisionInput = {},
|
||||||
options: { isRaceRetry?: boolean; createdByUserId?: string | null; createdByAgentId?: string | null; sourceRunId?: string | null } = {},
|
options: { isRaceRetry?: boolean; createdByUserId?: string | null; createdByAgentId?: string | null } = {},
|
||||||
) {
|
) {
|
||||||
const definition = requireBuiltInAgentDefinition(key);
|
const definition = requireBuiltInAgentDefinition(key);
|
||||||
await ensureCompany(companyId);
|
await ensureCompany(companyId);
|
||||||
@@ -1798,7 +1797,7 @@ export function builtInAgentService(db: Db) {
|
|||||||
}
|
}
|
||||||
const updated = await agentSvc.update(existing.id, patch, {
|
const updated = await agentSvc.update(existing.id, patch, {
|
||||||
allowBuiltInAgentMetadata: true,
|
allowBuiltInAgentMetadata: true,
|
||||||
recordRevision: { source: "built-in-agent:ensure", createdByUserId: options.createdByUserId, createdByAgentId: options.createdByAgentId, sourceRunId: options.sourceRunId },
|
recordRevision: { source: "built-in-agent:ensure", createdByUserId: options.createdByUserId, createdByAgentId: options.createdByAgentId },
|
||||||
});
|
});
|
||||||
if (!updated) throw notFound("Built-in agent not found");
|
if (!updated) throw notFound("Built-in agent not found");
|
||||||
if (existingPendingApproval) {
|
if (existingPendingApproval) {
|
||||||
@@ -1840,7 +1839,7 @@ export function builtInAgentService(db: Db) {
|
|||||||
// and the partial unique index rejected ours. Re-run once; the winning
|
// and the partial unique index rejected ours. Re-run once; the winning
|
||||||
// row now exists, so we take the update path instead of inserting again.
|
// row now exists, so we take the update path instead of inserting again.
|
||||||
if (!options.isRaceRetry && isBuiltInAgentMarkerConflict(error)) {
|
if (!options.isRaceRetry && isBuiltInAgentMarkerConflict(error)) {
|
||||||
return ensure(companyId, key, input, { isRaceRetry: true, createdByUserId: options.createdByUserId, createdByAgentId: options.createdByAgentId, sourceRunId: options.sourceRunId });
|
return ensure(companyId, key, input, { isRaceRetry: true, createdByUserId: options.createdByUserId, createdByAgentId: options.createdByAgentId });
|
||||||
}
|
}
|
||||||
throw error;
|
throw error;
|
||||||
}
|
}
|
||||||
@@ -1873,7 +1872,7 @@ export function builtInAgentService(db: Db) {
|
|||||||
const definition = requireBuiltInAgentDefinition(key);
|
const definition = requireBuiltInAgentDefinition(key);
|
||||||
const company = await ensureCompany(companyId);
|
const company = await ensureCompany(companyId);
|
||||||
if (!company.requireBoardApprovalForNewAgents) {
|
if (!company.requireBoardApprovalForNewAgents) {
|
||||||
return { state: await ensure(companyId, key, input, { createdByUserId: actor.requestedByUserId ?? null, createdByAgentId: actor.requestedByAgentId ?? null, sourceRunId: actor.sourceRunId }), approval: null };
|
return { state: await ensure(companyId, key, input, { createdByUserId: actor.requestedByUserId ?? null, createdByAgentId: actor.requestedByAgentId ?? null }), approval: null };
|
||||||
}
|
}
|
||||||
await assertKnownBuiltInAgentModel(definition, input);
|
await assertKnownBuiltInAgentModel(definition, input);
|
||||||
|
|
||||||
@@ -1905,7 +1904,7 @@ export function builtInAgentService(db: Db) {
|
|||||||
// it does when board approval is not required, instead of dead-ending on a
|
// it does when board approval is not required, instead of dead-ending on a
|
||||||
// fresh board-approval requirement the operator can never satisfy.
|
// fresh board-approval requirement the operator can never satisfy.
|
||||||
if (providesAdapterSetup && (existing.metadata?.paperclipBuiltInSetupRequired === true || !hasCompleteAdapterConfig(existing.adapterType, existing.adapterConfig))) {
|
if (providesAdapterSetup && (existing.metadata?.paperclipBuiltInSetupRequired === true || !hasCompleteAdapterConfig(existing.adapterType, existing.adapterConfig))) {
|
||||||
return { state: await ensure(companyId, key, input, { createdByUserId: actor.requestedByUserId ?? null, createdByAgentId: actor.requestedByAgentId ?? null, sourceRunId: actor.sourceRunId }), approval: null };
|
return { state: await ensure(companyId, key, input, { createdByUserId: actor.requestedByUserId ?? null, createdByAgentId: actor.requestedByAgentId ?? null }), approval: null };
|
||||||
}
|
}
|
||||||
|
|
||||||
// Changing the adapter of an already-configured (`ready`/`paused`)
|
// Changing the adapter of an already-configured (`ready`/`paused`)
|
||||||
|
|||||||
Reference in new issue
Block a user