refactor: dedupe reader helpers

This commit is contained in:
Peter Steinberger
2026-04-07 04:31:30 +01:00
parent d9fbfa268f
commit 2f115bc645
10 changed files with 63 additions and 60 deletions

View File

@@ -8,6 +8,7 @@ import { z } from "zod";
import { PROTOCOL_VERSION } from "../../src/gateway/protocol/index.ts";
import { formatErrorMessage } from "../../src/infra/errors.ts";
import { rawDataToString } from "../../src/infra/ws.ts";
import { readStringValue } from "../../src/shared/string-coerce.ts";
export const ClaudeChannelNotificationSchema = z.object({
method: z.literal("notifications/claude/channel"),
@@ -66,8 +67,7 @@ export function extractTextFromGatewayPayload(
if (!first || typeof first !== "object") {
return undefined;
}
const text = (first as { text?: unknown }).text;
return typeof text === "string" ? text : undefined;
return readStringValue((first as { text?: unknown }).text);
}
export async function waitFor<T>(