feat: use original worker types in sdk #296
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
Refactor SDK types to re-export original worker types instead of maintaining duplicate type definitions, improving type consistency between SDK and platform.
Changes
sdk/src/protocol.ts: Added new type re-exports from worker modules:
WebSocketMessage,WebSocketMessageData,CodeFixEdits,ModelConfigsInfoMessage,AgentDisplayConfig,ModelConfigsInfofrom websocket typesAgentStatefrom agent core stateBehaviorType,ProjectTypefrom agent core typesFileOutputTypefrom agent schemasTemplateDetailsfrom sandbox typesAgentConnectionData,PlatformCodeGenArgs,AgentPreviewResponsefrom agent controller typessdk/src/types.ts: Updated to import types from protocol.ts instead of defining them locally
BehaviorTypeandProjectTypenow alias platform typesCodeGenArgsusesPlatformCodeGenArgsfrom protocolsdk/src/index.ts: Added new exports for
AgentState,AgentConnectionData,AgentPreviewResponse,WebSocketMessage,WebSocketMessageDatasdk/package.json: Updated dependencies:
@cloudflare/workers-types,miniflare,puppeteerto devDependencies@types/wsas explicit devDependency (types bundled from ws)Motivation
Eliminates type duplication between SDK and platform code. When platform types change, SDK types automatically stay in sync rather than requiring manual updates. This reduces maintenance burden and prevents type drift.
Testing
bun run typecheckin sdk/bun run bundle-typesin sdk/Generated with Claude Code