Skip to content

Commit c0976cf

Browse files
ochafikclaude
andcommitted
Fix TypeScript build errors
- Remove duplicate 'sampling' property in ClientCapabilitiesSchema (types.ts:299) - Add type guards for union types in backfillSampling.ts: - Check 'text' in c.resource before accessing text property - Check 'blob' in c.resource before accessing blob property - Fix c.resource.data to c.resource.blob for PDF (blob is the correct property) - Fix c.url to c.uri for resource_link (uri is the correct property) - Fix toolLoop.ts: - Change tool_choice to toolChoice (camelCase convention) - Add type guard for text blocks when joining content - Fix toolRegistry.ts: - Remove .shape access on Zod schemas (not available on ZodType) - Add type assertion for callback to handle optional inputSchema 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
1 parent 337ad89 commit c0976cf

File tree

4 files changed

+11
-12
lines changed

4 files changed

+11
-12
lines changed

src/examples/backfill/backfillSampling.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -256,16 +256,16 @@ function contentBlockFromMcp(content: AssistantMessageContent | UserMessageConte
256256
} else if (c.type === 'image') {
257257
return makeImageBlock(c.data, c.mimeType);
258258
} else if (c.type === 'resource') {
259-
if (c.resource.mimeType === 'text/plain') {
259+
if (c.resource.mimeType === 'text/plain' && 'text' in c.resource) {
260260
return <TextBlockParam>{type: 'text', text: c.resource.text};
261-
} else if (c.resource.mimeType?.startsWith('image/') && typeof c.resource.blob === 'string') {
261+
} else if (c.resource.mimeType?.startsWith('image/') && 'blob' in c.resource && typeof c.resource.blob === 'string') {
262262
return makeImageBlock(c.resource.blob, c.resource.mimeType);
263-
} else if (c.resource.mimeType === 'application/pdf') {
263+
} else if (c.resource.mimeType === 'application/pdf' && 'blob' in c.resource) {
264264
return <DocumentBlockParam>{
265265
type: 'document',
266266
source: {
267267
type: 'base64',
268-
data: c.resource.data,
268+
data: c.resource.blob,
269269
media_type: 'application/pdf',
270270
},
271271
};
@@ -281,7 +281,7 @@ function contentBlockFromMcp(content: AssistantMessageContent | UserMessageConte
281281
type: 'document',
282282
source: {
283283
type: 'url',
284-
url: c.url,
284+
url: c.uri,
285285
},
286286
}
287287
} else {

src/examples/server/toolLoop.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ export async function runToolLoop(
8080
maxTokens: 4000,
8181
tools: iteration < maxIterations ? options.registry.tools : undefined,
8282
// Don't allow tool calls at the last iteration: finish with an answer no matter what!
83-
tool_choice: iteration < maxIterations ? defaultToolChoice : { mode: "none" },
83+
toolChoice: iteration < maxIterations ? defaultToolChoice : { mode: "none" },
8484
});
8585

8686
// Aggregate usage statistics from the response
@@ -138,14 +138,14 @@ export async function runToolLoop(
138138
if (unexpectedBlocks.length > 0) {
139139
throw new Error(`Expected text content in final answer, but got: ${unexpectedBlocks.map(b => b.type).join(", ")}`);
140140
}
141-
141+
142142
await options.server.sendLoggingMessage({
143143
level: "info",
144144
data: `Tool loop completed after ${iteration} iteration(s)`,
145145
});
146146

147147
return {
148-
answer: contentArray.map(block => block.text).join("\n\n"),
148+
answer: contentArray.map(block => block.type === 'text' ? block.text : '').join("\n\n"),
149149
transcript: messages,
150150
usage
151151
};

src/examples/server/toolRegistry.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,11 @@ export class ToolRegistry {
3232
server.registerTool(name, {
3333
title: tool.title,
3434
description: tool.description,
35-
inputSchema: tool.inputSchema?.shape,
36-
outputSchema: tool.outputSchema?.shape,
35+
inputSchema: tool.inputSchema,
36+
outputSchema: tool.outputSchema,
3737
annotations: tool.annotations,
3838
_meta: tool._meta,
39-
}, tool.callback);
39+
}, tool.callback as any);
4040
}
4141
}
4242

src/types.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -296,7 +296,6 @@ export const ClientCapabilitiesSchema = z.object({
296296
tools: AssertObjectSchema.optional(),
297297
})
298298
.optional(),
299-
sampling: AssertObjectSchema.optional(),
300299
/**
301300
* Present if the client supports eliciting user input.
302301
*/

0 commit comments

Comments
 (0)