Skip to content

refactor(core): migrate MessageV2 tool state schemas to Effect Schema#23752

Merged
kitlangton merged 1 commit intodevfrom
kit/session-schema-tool-state
Apr 21, 2026
Merged

refactor(core): migrate MessageV2 tool state schemas to Effect Schema#23752
kitlangton merged 1 commit intodevfrom
kit/session-schema-tool-state

Conversation

@kitlangton
Copy link
Copy Markdown
Contributor

Summary

Second piecemeal slice of the session-domain Effect Schema migration (see `packages/opencode/specs/effect/schema.md`, added in #23744).

  • Converts `MessageV2.ToolStatePending`, `ToolStateRunning`, `ToolStateCompleted`, `ToolStateError`, and the `ToolState` union to Effect Schema via `Schema.Struct` + derived `.zod`.
  • `ToolPart` stays Zod in this slice; its `state` field now references `ToolState.zod`.
  • `ToolStateCompleted.attachments` bridges to the still-Zod `FilePart` through `ZodOverride`, so array items keep emitting `$ref: #/components/schemas/FilePart`.
  • Exported TS types are cast through `Types.DeepMutable` to preserve the pre-migration mutable shape used by consumer code like `compaction.ts` and `prompt.ts`.

Acceptance check

  • `bun typecheck` (package + repo root) clean.
  • `bun run test` → 2010 pass / 0 fail.
  • `bun dev generate` output 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

Listed in `specs/effect/schema.md`:

  1. Part leaf schemas (`FilePart`, `TextPart`, ...) — next slice
  2. `Part` discriminated union
  3. `Base` / `User` / `Assistant` / `Info` / `WithParts`
  4. Event payloads
  5. Cursor + cleanup
  6. Errors via `NamedError`-shaped bridge on `Schema.TaggedErrorClass`

Converts MessageV2.ToolStatePending/Running/Completed/Error and the ToolState union to Effect Schema, exposing .zod compatibility for the still-Zod ToolPart consumer. Uses ZodOverride for ToolStateCompleted.attachments so FilePart stays Zod-first until the next slice.
@kitlangton kitlangton merged commit df0c1f6 into dev Apr 21, 2026
11 checks passed
@kitlangton kitlangton deleted the kit/session-schema-tool-state branch April 21, 2026 21:47
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