Add runtime issue clear action

This commit is contained in:
Nathan Flurry 2026-03-12 11:03:32 -07:00
parent ec8e816d0d
commit b224294b0e
11 changed files with 82 additions and 2 deletions

View file

@ -1,6 +1,6 @@
import type { WorkflowErrorEvent } from "rivetkit/workflow";
import type { FoundryActorRuntimeIssue, FoundryActorRuntimeType } from "@sandbox-agent/foundry-shared";
import { sql } from "drizzle-orm";
import { eq, sql } from "drizzle-orm";
import { organizationActorIssues } from "./organization/db/schema.js";
import { getOrCreateOrganization } from "./handles.js";
@ -98,6 +98,17 @@ export async function listActorRuntimeIssues(c: any): Promise<ActorRuntimeIssueR
.sort((left, right) => right.occurredAt - left.occurredAt);
}
export async function clearActorRuntimeIssues(c: any, input?: { actorId?: string | null }): Promise<void> {
await ensureOrganizationActorIssuesTable(c);
const actorId = input?.actorId?.trim();
if (actorId) {
await c.db.delete(organizationActorIssues).where(eq(organizationActorIssues.actorId, actorId)).run();
return;
}
await c.db.delete(organizationActorIssues).run();
}
function normalizeWorkflowIssue(event: WorkflowErrorEvent): NormalizedWorkflowIssue {
if ("step" in event) {
const error = event.step.error;