Spaces:
Runtime error
Runtime error
File size: 1,645 Bytes
159e7fa |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 |
import { PrismaClient } from '@prisma/client';
declare global {
var prisma: PrismaClient | undefined;
namespace PrismaJson {
// you can use classes, interfaces, types, etc.
interface StructuredError {
name: string;
value: string;
traceback_raw: string[];
}
type StructuredResult = {
logs: {
stderr: string[];
stdout: string[];
};
results: Array<{
png?: string;
mp4?: string;
text: string;
is_main_result: boolean;
}>;
error?: StructuredError;
};
interface PlanAndToolsBody {
type: 'plans' | 'tools';
status: 'started' | 'completed';
payload?: Array<Record<string, string>>;
}
interface CodeBody {
type: 'code';
status: 'completed' | 'failed' | 'started' | 'running';
payload?: {
code: string;
test: string;
result?: StructuredResult | string;
};
}
interface FinalCodeBody {
type: 'final_code';
status: 'completed' | 'failed';
payload: {
code: string;
test: string;
result: StructuredResult | string;
};
}
interface FinalErrorBody {
type: 'final_error';
status: 'failed';
payload: StructuredError;
}
type MessageBody =
| PlanAndToolsBody
| CodeBody
| FinalErrorBody
| FinalCodeBody;
type AgentResponseBodies = Array<
PlanAndToolsBody | CodeBody | FinalErrorBody
>;
}
}
const db = globalThis.prisma || new PrismaClient();
if (process.env.NODE_ENV != 'production') globalThis.prisma = db;
export default db;
|