Просмотр исходного кода

refactor(subagent): normalize optional timing output

_Kerman 2 месяцев назад
Родитель
Сommit
da463ddebc
1 измененных файлов с 5 добавлено и 4 удалено
  1. 5 4
      packages/subagent/subagent/src/projection.ts

+ 5 - 4
packages/subagent/subagent/src/projection.ts

@@ -29,12 +29,13 @@ const activeIntervalSchema = z.object({
   through: z.number().int().nonnegative(),
   through: z.number().int().nonnegative(),
 }).strict()
 }).strict()
 
 
-// Zod's optional output includes explicit `undefined`; with
-// exactOptionalPropertyTypes the public interface permits omission only.
-const projectionSchema = z.object({
+const projectionSchema: z.ZodType<SubagentTimingProjection> = z.object({
   settledMs: z.number().int().nonnegative(),
   settledMs: z.number().int().nonnegative(),
   active: activeIntervalSchema.optional(),
   active: activeIntervalSchema.optional(),
-}).strict() as unknown as z.ZodType<SubagentTimingProjection>
+}).strict().transform(({ settledMs, active }) => ({
+  settledMs,
+  ...active === undefined ? {} : { active },
+}))
 
 
 const timingStateSchema: z.ZodType<TimingState> = z.object({
 const timingStateSchema: z.ZodType<TimingState> = z.object({
   settledMs: z.number().int().nonnegative(),
   settledMs: z.number().int().nonnegative(),