fix: restore zod typing and import ClaudeJsonParseResult

This commit is contained in:
Peter Steinberger
2025-11-25 12:25:05 +01:00
parent 4704099d2b
commit 4fa414919b
2 changed files with 5 additions and 6 deletions

View File

@@ -88,6 +88,8 @@ const ClaudeJsonSchema = z
{ message: "Not a Claude JSON payload" },
);
type ClaudeSafeParse = ReturnType<typeof ClaudeJsonSchema.safeParse>;
export function parseClaudeJson(
raw: string,
): ClaudeJsonParseResult | undefined {
@@ -104,9 +106,7 @@ export function parseClaudeJson(
try {
const parsed = JSON.parse(candidate);
if (firstParsed === undefined) firstParsed = parsed;
let validation:
| z.SafeParseReturnType<unknown, z.infer<typeof ClaudeJsonSchema>>
| { success: false };
let validation: ClaudeSafeParse | { success: false };
try {
validation = ClaudeJsonSchema.safeParse(parsed);
} catch {
@@ -133,9 +133,7 @@ export function parseClaudeJson(
}
}
if (firstParsed !== undefined) {
let validation:
| z.SafeParseReturnType<unknown, z.infer<typeof ClaudeJsonSchema>>
| { success: false };
let validation: ClaudeSafeParse | { success: false };
try {
validation = ClaudeJsonSchema.safeParse(firstParsed);
} catch {

View File

@@ -23,6 +23,7 @@ import { sendTypingIndicator } from "../twilio/typing.js";
import {
CLAUDE_BIN,
CLAUDE_IDENTITY_PREFIX,
type ClaudeJsonParseResult,
parseClaudeJson,
} from "./claude.js";
import {