mirror of
https://github.com/harivansh-afk/sandbox-agent.git
synced 2026-04-15 06:04:43 +00:00
Revert actor communication from direct action calls to queue/workflow-based patterns for better observability (workflow history in RivetKit inspector), replay/recovery semantics, and idiomatic RivetKit usage. - Add queue/workflow infrastructure to all actors: organization, task, user, github-data, sandbox, and audit-log - Mutations route through named queues processed by workflow command loops with ctx.step() wrapping for c.state/c.db access and observability - Remove command action wrappers (~460 lines) — callers use .send() directly to queue names with expectQueueResponse() for wait:true results - Keep sendPrompt and runProcess as direct sandbox actions (long-running / large responses that would block the workflow loop or exceed 128KB limit) - Fix workspace fire-and-forget calls (enqueueWorkspaceEnsureSession, enqueueWorkspaceRefresh) to self-send to task queue instead of calling directly outside workflow step context Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
85 lines
2.6 KiB
TypeScript
85 lines
2.6 KiB
TypeScript
import { auditLogKey, githubDataKey, organizationKey, taskKey, taskSandboxKey, userKey } from "./keys.js";
|
|
|
|
export function actorClient(c: any) {
|
|
return c.client();
|
|
}
|
|
|
|
export async function getOrCreateOrganization(c: any, organizationId: string) {
|
|
return await actorClient(c).organization.getOrCreate(organizationKey(organizationId), {
|
|
createWithInput: organizationId,
|
|
});
|
|
}
|
|
|
|
export async function getOrCreateUser(c: any, userId: string) {
|
|
return await actorClient(c).user.getOrCreate(userKey(userId), {
|
|
createWithInput: { userId },
|
|
});
|
|
}
|
|
|
|
export function getUser(c: any, userId: string) {
|
|
return actorClient(c).user.get(userKey(userId));
|
|
}
|
|
|
|
export function getTask(c: any, organizationId: string, repoId: string, taskId: string) {
|
|
return actorClient(c).task.get(taskKey(organizationId, repoId, taskId));
|
|
}
|
|
|
|
export async function getOrCreateTask(c: any, organizationId: string, repoId: string, taskId: string, createWithInput: Record<string, unknown>) {
|
|
return await actorClient(c).task.getOrCreate(taskKey(organizationId, repoId, taskId), {
|
|
createWithInput,
|
|
});
|
|
}
|
|
|
|
export async function getOrCreateAuditLog(c: any, organizationId: string) {
|
|
return await actorClient(c).auditLog.getOrCreate(auditLogKey(organizationId), {
|
|
createWithInput: {
|
|
organizationId,
|
|
},
|
|
});
|
|
}
|
|
|
|
export async function getOrCreateGithubData(c: any, organizationId: string) {
|
|
return await actorClient(c).githubData.getOrCreate(githubDataKey(organizationId), {
|
|
createWithInput: {
|
|
organizationId,
|
|
},
|
|
});
|
|
}
|
|
|
|
export function getGithubData(c: any, organizationId: string) {
|
|
return actorClient(c).githubData.get(githubDataKey(organizationId));
|
|
}
|
|
|
|
export function getTaskSandbox(c: any, organizationId: string, sandboxId: string) {
|
|
return actorClient(c).taskSandbox.get(taskSandboxKey(organizationId, sandboxId));
|
|
}
|
|
|
|
export async function getOrCreateTaskSandbox(c: any, organizationId: string, sandboxId: string, createWithInput?: Record<string, unknown>) {
|
|
return await actorClient(c).taskSandbox.getOrCreate(taskSandboxKey(organizationId, sandboxId), {
|
|
createWithInput,
|
|
});
|
|
}
|
|
|
|
export function selfAuditLog(c: any) {
|
|
return actorClient(c).auditLog.getForId(c.actorId);
|
|
}
|
|
|
|
export function selfTask(c: any) {
|
|
return actorClient(c).task.getForId(c.actorId);
|
|
}
|
|
|
|
export function selfOrganization(c: any) {
|
|
return actorClient(c).organization.getForId(c.actorId);
|
|
}
|
|
|
|
export function selfUser(c: any) {
|
|
return actorClient(c).user.getForId(c.actorId);
|
|
}
|
|
|
|
export function selfGithubData(c: any) {
|
|
return actorClient(c).githubData.getForId(c.actorId);
|
|
}
|
|
|
|
export function selfTaskSandbox(c: any) {
|
|
return actorClient(c).taskSandbox.getForId(c.actorId);
|
|
}
|