feat: add v0.1 runtime skeleton

This commit is contained in:
Codex
2026-05-29 10:52:41 +08:00
parent 4b33e67484
commit 5deb9fa7fd
20 changed files with 1238 additions and 0 deletions
+28
View File
@@ -0,0 +1,28 @@
import type { FailureKind, JsonRecord } from "./types.js";
export class AgentRunError extends Error {
readonly failureKind: FailureKind;
readonly details: JsonRecord | null;
readonly httpStatus: number;
constructor(failureKind: FailureKind, message: string, options: { httpStatus?: number; details?: JsonRecord } = {}) {
super(message);
this.name = "AgentRunError";
this.failureKind = failureKind;
this.httpStatus = options.httpStatus ?? 400;
this.details = options.details ?? null;
}
}
export function errorToJson(error: unknown): JsonRecord {
if (error instanceof AgentRunError) {
return {
name: error.name,
failureKind: error.failureKind,
message: error.message,
details: error.details,
};
}
if (error instanceof Error) return { name: error.name, message: error.message, stack: error.stack ?? null };
return { name: "UnknownError", message: String(error) };
}