From 6b4ecc746579fb0ce83042fc07e44b1bd68ce77c Mon Sep 17 00:00:00 2001 From: Claude Date: Mon, 27 Jul 2026 17:38:20 +0000 Subject: [PATCH] chore(deps): upgrade zod to v4 Bump zod from ^3.23.0 to ^4.4.3 and migrate the breaking/deprecated APIs: - `ZodError.errors` was removed in v4; `createTrajectory`/`completeTrajectory` now read `error.issues[0]` (typecheck failed on the old property). - `z.string().url()` -> `z.url()` and `z.string().datetime()` -> `z.iso.datetime()`, the non-deprecated v4 top-level forms. Custom validation messages, issue paths, and the `describeReadFailure` / `FileStorage.save` error rendering all keep their existing shape. Typecheck, build, lint, and the full 257-test suite pass, and a CLI smoke test (start -> decision -> complete -> list) round-trips through the write-side `validateTrajectory` and read-side schema parse. Co-Authored-By: Claude Opus 5 Claude-Session: https://claude.ai/code/session_01K2zPEUnsjW36Ezbg7gYm9x --- package-lock.json | 38 ++++++++++++++------------------------ package.json | 2 +- src/core/schema.ts | 22 +++++++++++----------- src/core/trajectory.ts | 4 ++-- 4 files changed, 28 insertions(+), 38 deletions(-) diff --git a/package-lock.json b/package-lock.json index 7b0c959..5d8d032 100644 --- a/package-lock.json +++ b/package-lock.json @@ -11,7 +11,7 @@ "dependencies": { "@clack/prompts": "^0.7.0", "commander": "^12.0.0", - "zod": "^3.23.0" + "zod": "^4.4.3" }, "bin": { "trail": "dist/cli/index.js" @@ -41,6 +41,16 @@ "zod-to-json-schema": "^3.23.1" } }, + "node_modules/@agent-relay/config/node_modules/zod": { + "version": "3.25.76", + "resolved": "https://registry.npmjs.org/zod/-/zod-3.25.76.tgz", + "integrity": "sha512-gzUt/qt81nXsFGKIFcC3YnfEAx5NkunCfnDlvuBSSFS02bcXu4Lmea0AFIUwbLWxWPx3d9p8S5QoaujKcNQxcQ==", + "dev": true, + "license": "MIT", + "funding": { + "url": "https://github.com/sponsors/colinhacks" + } + }, "node_modules/@agent-relay/sdk": { "version": "4.0.4", "resolved": "https://registry.npmjs.org/@agent-relay/sdk/-/sdk-4.0.4.tgz", @@ -831,16 +841,6 @@ "zod": "^4.3.6" } }, - "node_modules/@relaycast/sdk/node_modules/zod": { - "version": "4.3.6", - "resolved": "https://registry.npmjs.org/zod/-/zod-4.3.6.tgz", - "integrity": "sha512-rftlrkhHZOcjDwkGlnUtZZkvaPHCsDATp4pGpuOOMDaTdDDXF91wuVDJoWoPsKX/3YPQ5fHuF3STjcYyKr+Qhg==", - "dev": true, - "license": "MIT", - "funding": { - "url": "https://github.com/sponsors/colinhacks" - } - }, "node_modules/@relaycast/types": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/@relaycast/types/-/types-1.1.0.tgz", @@ -850,16 +850,6 @@ "zod": "^4.3.6" } }, - "node_modules/@relaycast/types/node_modules/zod": { - "version": "4.3.6", - "resolved": "https://registry.npmjs.org/zod/-/zod-4.3.6.tgz", - "integrity": "sha512-rftlrkhHZOcjDwkGlnUtZZkvaPHCsDATp4pGpuOOMDaTdDDXF91wuVDJoWoPsKX/3YPQ5fHuF3STjcYyKr+Qhg==", - "dev": true, - "license": "MIT", - "funding": { - "url": "https://github.com/sponsors/colinhacks" - } - }, "node_modules/@relayfile/sdk": { "version": "0.1.6", "resolved": "https://registry.npmjs.org/@relayfile/sdk/-/sdk-0.1.6.tgz", @@ -3520,9 +3510,9 @@ } }, "node_modules/zod": { - "version": "3.25.76", - "resolved": "https://registry.npmjs.org/zod/-/zod-3.25.76.tgz", - "integrity": "sha512-gzUt/qt81nXsFGKIFcC3YnfEAx5NkunCfnDlvuBSSFS02bcXu4Lmea0AFIUwbLWxWPx3d9p8S5QoaujKcNQxcQ==", + "version": "4.4.3", + "resolved": "https://registry.npmjs.org/zod/-/zod-4.4.3.tgz", + "integrity": "sha512-ytENFjIJFl2UwYglde2jchW2Hwm4GJFLDiSXWdTrJQBIN9Fcyp7n4DhxJEiWNAJMV1/BqWfW/kkg71UDcHJyTQ==", "license": "MIT", "funding": { "url": "https://github.com/sponsors/colinhacks" diff --git a/package.json b/package.json index 27f426f..9bb4ab8 100644 --- a/package.json +++ b/package.json @@ -56,7 +56,7 @@ "dependencies": { "@clack/prompts": "^0.7.0", "commander": "^12.0.0", - "zod": "^3.23.0" + "zod": "^4.4.3" }, "devDependencies": { "@agent-relay/sdk": "^4.0.4", diff --git a/src/core/schema.ts b/src/core/schema.ts index bdbc0ae..267bb69 100644 --- a/src/core/schema.ts +++ b/src/core/schema.ts @@ -25,7 +25,7 @@ export const TaskSourceSystemSchema = z.union([ export const TaskSourceSchema = z.object({ system: TaskSourceSystemSchema, id: z.string().min(1, "Task ID is required"), - url: z.string().url().optional(), + url: z.url().optional(), }); /** @@ -124,8 +124,8 @@ export const DecisionSchema = z.object({ export const AgentParticipationSchema = z.object({ name: z.string().min(1, "Agent name is required"), role: z.string().min(1, "Agent role is required"), - joinedAt: z.string().datetime(), - leftAt: z.string().datetime().optional(), + joinedAt: z.iso.datetime(), + leftAt: z.iso.datetime().optional(), }); /** @@ -135,8 +135,8 @@ export const ChapterSchema = z.object({ id: z.string().min(1), title: z.string().min(1, "Chapter title is required"), agentName: z.string().min(1, "Agent name is required"), - startedAt: z.string().datetime(), - endedAt: z.string().datetime().optional(), + startedAt: z.iso.datetime(), + endedAt: z.iso.datetime().optional(), events: z.array(TrajectoryEventSchema), }); @@ -196,7 +196,7 @@ export const TraceContributorSchema = z.object({ */ export const TraceConversationSchema = z.object({ contributor: TraceContributorSchema, - url: z.string().url().optional(), + url: z.url().optional(), ranges: z.array(TraceRangeSchema), }); @@ -215,7 +215,7 @@ export const TraceFileSchema = z.object({ export const TraceRecordSchema = z.object({ version: z.string().min(1, "Version is required"), id: z.string().min(1, "Trace ID is required"), - timestamp: z.string().datetime(), + timestamp: z.iso.datetime(), trajectory: z.string().optional(), files: z.array(TraceFileSchema), }); @@ -237,8 +237,8 @@ export const TrajectorySchema = z.object({ version: z.literal(1), task: TaskReferenceSchema, status: TrajectoryStatusSchema, - startedAt: z.string().datetime(), - completedAt: z.string().datetime().optional(), + startedAt: z.iso.datetime(), + completedAt: z.iso.datetime().optional(), agents: z.array(AgentParticipationSchema), chapters: z.array(ChapterSchema), retrospective: RetrospectiveSchema.optional(), @@ -304,8 +304,8 @@ export const CompleteTrajectoryInputSchema = z.object({ */ export const TrajectoryQuerySchema = z.object({ status: TrajectoryStatusSchema.optional(), - since: z.string().datetime().optional(), - until: z.string().datetime().optional(), + since: z.iso.datetime().optional(), + until: z.iso.datetime().optional(), limit: z.number().int().positive().max(100).optional(), offset: z.number().int().nonnegative().optional(), sortBy: z.enum(["startedAt", "completedAt", "title"]).optional(), diff --git a/src/core/trajectory.ts b/src/core/trajectory.ts index e06cce3..0293dc4 100644 --- a/src/core/trajectory.ts +++ b/src/core/trajectory.ts @@ -45,7 +45,7 @@ export function createTrajectory(input: CreateTrajectoryInput): Trajectory { // Validate input const validation = CreateTrajectoryInputSchema.safeParse(input); if (!validation.success) { - const firstError = validation.error.errors[0]; + const firstError = validation.error.issues[0]; throw new TrajectoryError( firstError.message, "VALIDATION_ERROR", @@ -215,7 +215,7 @@ export function completeTrajectory( // Validate input const validation = CompleteTrajectoryInputSchema.safeParse(input); if (!validation.success) { - const firstError = validation.error.errors[0]; + const firstError = validation.error.issues[0]; throw new TrajectoryError( firstError.message, "VALIDATION_ERROR",