From 2d55cc446afd5e41714107a42be769a870aa9a2c Mon Sep 17 00:00:00 2001 From: Peter Steinberger Date: Wed, 18 Feb 2026 17:58:05 +0000 Subject: [PATCH] refactor(config): share install record schema shape --- src/config/zod-schema.hooks.ts | 8 ++------ src/config/zod-schema.installs.ts | 16 ++++++++++++++++ src/config/zod-schema.ts | 8 ++------ 3 files changed, 20 insertions(+), 12 deletions(-) create mode 100644 src/config/zod-schema.installs.ts diff --git a/src/config/zod-schema.hooks.ts b/src/config/zod-schema.hooks.ts index f7583e334be..57d617bbd6b 100644 --- a/src/config/zod-schema.hooks.ts +++ b/src/config/zod-schema.hooks.ts @@ -1,5 +1,6 @@ import path from "node:path"; import { z } from "zod"; +import { InstallRecordShape } from "./zod-schema.installs.js"; import { sensitive } from "./zod-schema.sensitive.js"; function isSafeRelativeModulePath(raw: string): boolean { @@ -96,12 +97,7 @@ const HookConfigSchema = z const HookInstallRecordSchema = z .object({ - source: z.union([z.literal("npm"), z.literal("archive"), z.literal("path")]), - spec: z.string().optional(), - sourcePath: z.string().optional(), - installPath: z.string().optional(), - version: z.string().optional(), - installedAt: z.string().optional(), + ...InstallRecordShape, hooks: z.array(z.string()).optional(), }) .strict(); diff --git a/src/config/zod-schema.installs.ts b/src/config/zod-schema.installs.ts new file mode 100644 index 00000000000..3c2710096f2 --- /dev/null +++ b/src/config/zod-schema.installs.ts @@ -0,0 +1,16 @@ +import { z } from "zod"; + +export const InstallSourceSchema = z.union([ + z.literal("npm"), + z.literal("archive"), + z.literal("path"), +]); + +export const InstallRecordShape = { + source: InstallSourceSchema, + spec: z.string().optional(), + sourcePath: z.string().optional(), + installPath: z.string().optional(), + version: z.string().optional(), + installedAt: z.string().optional(), +} as const; diff --git a/src/config/zod-schema.ts b/src/config/zod-schema.ts index 9ca6f14b718..ca1a781fa36 100644 --- a/src/config/zod-schema.ts +++ b/src/config/zod-schema.ts @@ -4,6 +4,7 @@ import { AgentsSchema, AudioSchema, BindingsSchema, BroadcastSchema } from "./zo import { ApprovalsSchema } from "./zod-schema.approvals.js"; import { HexColorSchema, ModelsConfigSchema } from "./zod-schema.core.js"; import { HookMappingSchema, HooksGmailSchema, InternalHooksSchema } from "./zod-schema.hooks.js"; +import { InstallRecordShape } from "./zod-schema.installs.js"; import { ChannelsSchema } from "./zod-schema.providers.js"; import { sensitive } from "./zod-schema.sensitive.js"; import { @@ -639,12 +640,7 @@ export const OpenClawSchema = z z.string(), z .object({ - source: z.union([z.literal("npm"), z.literal("archive"), z.literal("path")]), - spec: z.string().optional(), - sourcePath: z.string().optional(), - installPath: z.string().optional(), - version: z.string().optional(), - installedAt: z.string().optional(), + ...InstallRecordShape, }) .strict(), )