Skip to content

fix(sdk): narrow prompt part input id type#21312

Open
StatPan wants to merge 2 commits intoanomalyco:devfrom
StatPan:fix/sdk-part-input-id-type
Open

fix(sdk): narrow prompt part input id type#21312
StatPan wants to merge 2 commits intoanomalyco:devfrom
StatPan:fix/sdk-part-input-id-type

Conversation

@StatPan
Copy link
Copy Markdown

@StatPan StatPan commented Apr 7, 2026

Issue for this PR

Closes #21311

Type of change

  • Bug fix

What does this PR do?

The server rejects part IDs that don't start with prt, but the generated SDK types had id?: string. This adds a PartIDInput = \prt${string}`type and uses it forTextPartInput, FilePartInput, AgentPartInput, and SubtaskPartInput. A post-processing step in the build script keeps this correct when types are regenerated. Downstream call sites in packages/appandpackages/opencode` were updated to match.

How did you verify your code works?

Full turbo typecheck passes across all 13 packages. The id field type now matches the OpenAPI schema pattern ^prt.*.

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

The server rejects part IDs not starting with "prt" but the generated
SDK types had id as plain string. Added PartIDInput template literal
type and updated downstream call sites to match.
@StatPan StatPan requested a review from adamdotdevin as a code owner April 7, 2026 10:36
@StatPan
Copy link
Copy Markdown
Author

StatPan commented Apr 7, 2026

A few things I considered:

The generator (@hey-api/openapi-ts) doesn't translate OpenAPI pattern into template literal types — no clean generator-level fix without a custom plugin. Went with build-script post-processing as the pragmatic option.

The downstream changes in packages/app and packages/opencode were needed to keep typecheck passing. Happy to split if preferred.

Open to feedback on the direction.

@StatPan
Copy link
Copy Markdown
Author

StatPan commented Apr 7, 2026

Related: #18205 — a plugin generating part IDs without the prt prefix causes runtime ZodErrors. Narrowing the SDK type would catch this at compile time for TypeScript consumers.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

SDK part input id type does not enforce prt prefix

1 participant