Skip to content

refactor(core): migrate MessageV2 part leaves + ToolPart to Effect Schema#23756

Merged
kitlangton merged 1 commit intodevfrom
kit/session-schema-parts
Apr 22, 2026
Merged

refactor(core): migrate MessageV2 part leaves + ToolPart to Effect Schema#23756
kitlangton merged 1 commit intodevfrom
kit/session-schema-parts

Conversation

@kitlangton
Copy link
Copy Markdown
Contributor

Summary

Third piecemeal slice of the session-domain Effect Schema migration.

  • Migrates all 13 part leaf schemas to Effect Schema with derived .zod compatibility:
    SnapshotPart, PatchPart, TextPart, ReasoningPart, FileSource, SymbolSource, ResourceSource, FilePartSource, FilePart, AgentPart, CompactionPart, SubtaskPart, RetryPart, StepStartPart, StepFinishPart, ToolPart.
  • ToolPart now references ToolState directly via Schema.Struct.
  • ToolStateCompleted.attachments drops the ZodOverride bridge and uses Schema.Array(FilePart) directly.
  • RetryPart.error bridges to APIError.Schema via ZodOverride since the error classes are still NamedError-based Zod.
  • Inlines the four *PartInput schemas in prompt.ts so z.discriminatedUnion keeps its precise shape inference (the original .omit/.partial helpers only existed on the raw Zod types).

Acceptance check

  • bun typecheck (package + repo root) clean.
  • bun run test → 2010 pass / 0 fail.
  • bun dev generate byte-identical to committed packages/sdk/openapi.json.
  • packages/sdk/js/src/v2/gen/types.gen.ts unchanged after bun script/build.ts.

Follow-up

Part of the stacked session-schema migration series. The next slice (stacked PR) migrates the message aggregate DTOs (User, Assistant, Part union, Info, WithParts).

…hema

Migrates all 13 part leaf schemas and the FilePartSource union to Effect Schema with derived .zod compatibility. ToolPart also moves, now referencing ToolState directly via Schema.Struct. The Part discriminated union stays Zod in this slice (migrates next). Also exports Schema-backed {Text,File,Agent,Subtask}PartInput with matching identifiers so prompt.ts PromptInput can reference them via .zod without re-inlining the part shapes. CommandInput keeps its (smaller) FilePart shape inlined since the SDK does not name that one with a $ref.
@kitlangton kitlangton force-pushed the kit/session-schema-parts branch from ec4f641 to f93bc46 Compare April 22, 2026 03:12
@kitlangton kitlangton merged commit fa62396 into dev Apr 22, 2026
9 checks passed
@kitlangton kitlangton deleted the kit/session-schema-parts branch April 22, 2026 03:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant