fix: restore zod typing and import ClaudeJsonParseResult
parent
4704099d2b
commit
4fa414919b
|
|
@ -88,6 +88,8 @@ const ClaudeJsonSchema = z
|
||||||
{ message: "Not a Claude JSON payload" },
|
{ message: "Not a Claude JSON payload" },
|
||||||
);
|
);
|
||||||
|
|
||||||
|
type ClaudeSafeParse = ReturnType<typeof ClaudeJsonSchema.safeParse>;
|
||||||
|
|
||||||
export function parseClaudeJson(
|
export function parseClaudeJson(
|
||||||
raw: string,
|
raw: string,
|
||||||
): ClaudeJsonParseResult | undefined {
|
): ClaudeJsonParseResult | undefined {
|
||||||
|
|
@ -104,9 +106,7 @@ export function parseClaudeJson(
|
||||||
try {
|
try {
|
||||||
const parsed = JSON.parse(candidate);
|
const parsed = JSON.parse(candidate);
|
||||||
if (firstParsed === undefined) firstParsed = parsed;
|
if (firstParsed === undefined) firstParsed = parsed;
|
||||||
let validation:
|
let validation: ClaudeSafeParse | { success: false };
|
||||||
| z.SafeParseReturnType<unknown, z.infer<typeof ClaudeJsonSchema>>
|
|
||||||
| { success: false };
|
|
||||||
try {
|
try {
|
||||||
validation = ClaudeJsonSchema.safeParse(parsed);
|
validation = ClaudeJsonSchema.safeParse(parsed);
|
||||||
} catch {
|
} catch {
|
||||||
|
|
@ -133,9 +133,7 @@ export function parseClaudeJson(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (firstParsed !== undefined) {
|
if (firstParsed !== undefined) {
|
||||||
let validation:
|
let validation: ClaudeSafeParse | { success: false };
|
||||||
| z.SafeParseReturnType<unknown, z.infer<typeof ClaudeJsonSchema>>
|
|
||||||
| { success: false };
|
|
||||||
try {
|
try {
|
||||||
validation = ClaudeJsonSchema.safeParse(firstParsed);
|
validation = ClaudeJsonSchema.safeParse(firstParsed);
|
||||||
} catch {
|
} catch {
|
||||||
|
|
|
||||||
|
|
@ -23,6 +23,7 @@ import { sendTypingIndicator } from "../twilio/typing.js";
|
||||||
import {
|
import {
|
||||||
CLAUDE_BIN,
|
CLAUDE_BIN,
|
||||||
CLAUDE_IDENTITY_PREFIX,
|
CLAUDE_IDENTITY_PREFIX,
|
||||||
|
type ClaudeJsonParseResult,
|
||||||
parseClaudeJson,
|
parseClaudeJson,
|
||||||
} from "./claude.js";
|
} from "./claude.js";
|
||||||
import {
|
import {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue