Skip to content

Commit d704110

Browse files
committed
fix: lazy session error schema
1 parent 5cd178b commit d704110

2 files changed

Lines changed: 4 additions & 1 deletion

File tree

packages/opencode/src/session/session.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -284,7 +284,8 @@ export const Event = {
284284
sessionID: Schema.optional(SessionID),
285285
// Reuses MessageV2.Assistant.fields.error (already Schema.optional) so
286286
// the derived zod keeps the same discriminated-union shape on the bus.
287-
error: MessageV2.Assistant.fields.error,
287+
// Schema.suspend defers access to break circular init in compiled binaries.
288+
error: Schema.suspend(() => MessageV2.Assistant.fields.error),
288289
}),
289290
),
290291
}

packages/opencode/src/util/effect-zod.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -256,6 +256,8 @@ function body(ast: SchemaAST.AST): z.ZodTypeAny {
256256
return array(ast)
257257
case "Declaration":
258258
return decl(ast)
259+
case "Suspend":
260+
return z.lazy(() => walk(ast.thunk()))
259261
default:
260262
return fail(ast)
261263
}

0 commit comments

Comments
 (0)