Skip to content

Commit 85d79bc

Browse files
docs: add FixSpec wrapper for CreateMessageResult schema divergence
Document the intentional divergence between SDK's CreateMessageResult (single content for v1.x backwards compat) and the spec's version (array content per SEP-1577). The full array-capable type is available as CreateMessageResultWithTools. This will be aligned with schema in v2.0.
1 parent 5eb6d54 commit 85d79bc

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

src/spec.types.test.ts

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,16 @@ type FixSpecInitializeRequest<T> = T extends { params: infer P } ? Omit<T, 'para
8080

8181
type FixSpecClientRequest<T> = T extends { params: infer P } ? Omit<T, 'params'> & { params: FixSpecInitializeRequestParams<P> } : T;
8282

83+
// Targeted fix: CreateMessageResult in SDK uses single content for v1.x backwards compat.
84+
// The full array-capable type is CreateMessageResultWithTools.
85+
// This will be aligned with schema in v2.0.
86+
type FixSpecCreateMessageResult<T> = T extends { content: infer C; stopReason?: infer S }
87+
? Omit<T, 'content' | 'stopReason'> & {
88+
content: C extends (infer U)[] ? U : C;
89+
stopReason?: Exclude<S, 'toolUse'>;
90+
}
91+
: T;
92+
8393
const sdkTypeChecks = {
8494
RequestParams: (sdk: RemovePassthrough<SDKTypes.RequestParams>, spec: SpecTypes.RequestParams) => {
8595
sdk = spec;
@@ -369,7 +379,10 @@ const sdkTypeChecks = {
369379
sdk = spec;
370380
spec = sdk;
371381
},
372-
CreateMessageResult: (sdk: RemovePassthrough<SDKTypes.CreateMessageResult>, spec: SpecTypes.CreateMessageResult) => {
382+
CreateMessageResult: (
383+
sdk: RemovePassthrough<SDKTypes.CreateMessageResult>,
384+
spec: FixSpecCreateMessageResult<SpecTypes.CreateMessageResult>
385+
) => {
373386
sdk = spec;
374387
spec = sdk;
375388
},

0 commit comments

Comments
 (0)