Skip to content

Commit 89f14e5

Browse files
committed
ToolCallContent -> ToolUseContent
1 parent c0976cf commit 89f14e5

File tree

7 files changed

+18
-18
lines changed

7 files changed

+18
-18
lines changed

src/examples/backfill/backfillSampling.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ import {
4444
CallToolRequestSchema,
4545
isJSONRPCNotification,
4646
Tool,
47-
ToolCallContent,
47+
ToolUseContent,
4848
LoggingMessageNotification,
4949
JSONRPCNotification,
5050
AssistantMessageContent,
@@ -193,7 +193,7 @@ function contentToMcp(content: ContentBlock): CreateMessageResult['content'] {
193193
id: content.id,
194194
name: content.name,
195195
input: content.input,
196-
} as ToolCallContent;
196+
} as ToolUseContent;
197197
default:
198198
throw new Error(`[contentToMcp] Unsupported content type: ${(content as any).type}`);
199199
}

src/examples/server/adventureGame.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ import { resolve, relative } from "node:path";
3434
import type {
3535
SamplingMessage,
3636
Tool,
37-
ToolCallContent,
37+
ToolUseContent,
3838
CreateMessageResult,
3939
CreateMessageRequest,
4040
ToolResultContent,

src/examples/server/simpleLocalResearcher.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ import { resolve, relative } from "node:path";
3939
import type {
4040
SamplingMessage,
4141
Tool,
42-
ToolCallContent,
42+
ToolUseContent,
4343
CreateMessageResult,
4444
CreateMessageRequest,
4545
ToolResultContent,

src/examples/server/toolLoop.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import { RequestHandlerExtra } from "../../shared/protocol.js";
99
import type {
1010
SamplingMessage,
1111
Tool,
12-
ToolCallContent,
12+
ToolUseContent,
1313
CreateMessageResult,
1414
CreateMessageRequest,
1515
RequestId,
@@ -103,7 +103,7 @@ export async function runToolLoop(
103103
if (response.stopReason === "toolUse") {
104104
const contentArray = Array.isArray(response.content) ? response.content : [response.content];
105105
const toolCalls = contentArray.filter(
106-
(content): content is ToolCallContent => content.type === "tool_use"
106+
(content): content is ToolUseContent => content.type === "tool_use"
107107
);
108108

109109
await options.server.sendLoggingMessage({

src/examples/server/toolRegistry.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { RequestHandlerExtra } from "../../shared/protocol.js";
33
import { z } from "zod";
44
import type {
55
Tool,
6-
ToolCallContent,
6+
ToolUseContent,
77
ToolResultContent,
88
ServerRequest,
99
ServerNotification,
@@ -40,7 +40,7 @@ export class ToolRegistry {
4040
}
4141
}
4242

43-
async callTools(toolCalls: ToolCallContent[], extra: RequestHandlerExtra<ServerRequest, ServerNotification>): Promise<ToolResultContent[]> {
43+
async callTools(toolCalls: ToolUseContent[], extra: RequestHandlerExtra<ServerRequest, ServerNotification>): Promise<ToolResultContent[]> {
4444
return Promise.all(toolCalls.map(async ({ name, id, input }) => {
4545
const tool = this.toolDefinitions[name];
4646
if (!tool) {

src/types.test.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import {
66
PromptMessageSchema,
77
CallToolResultSchema,
88
CompleteRequestSchema,
9-
ToolCallContentSchema,
9+
ToolUseContentSchema,
1010
ToolResultContentSchema,
1111
ToolChoiceSchema,
1212
UserMessageSchema,
@@ -322,7 +322,7 @@ describe('Types', () => {
322322
});
323323

324324
describe("SEP-1577: Sampling with Tools", () => {
325-
describe("ToolCallContent", () => {
325+
describe("ToolUseContent", () => {
326326
test("should validate a tool call content", () => {
327327
const toolCall = {
328328
type: "tool_use",
@@ -331,7 +331,7 @@ describe('Types', () => {
331331
input: { city: "San Francisco", units: "celsius" }
332332
};
333333

334-
const result = ToolCallContentSchema.safeParse(toolCall);
334+
const result = ToolUseContentSchema.safeParse(toolCall);
335335
expect(result.success).toBe(true);
336336
if (result.success) {
337337
expect(result.data.type).toBe("tool_use");
@@ -350,7 +350,7 @@ describe('Types', () => {
350350
_meta: { custom: "data" }
351351
};
352352

353-
const result = ToolCallContentSchema.safeParse(toolCall);
353+
const result = ToolUseContentSchema.safeParse(toolCall);
354354
expect(result.success).toBe(true);
355355
if (result.success) {
356356
expect(result.data._meta).toEqual({ custom: "data" });
@@ -364,7 +364,7 @@ describe('Types', () => {
364364
// missing id and input
365365
};
366366

367-
const result = ToolCallContentSchema.safeParse(invalidToolCall);
367+
const result = ToolUseContentSchema.safeParse(invalidToolCall);
368368
expect(result.success).toBe(false);
369369
});
370370
});

src/types.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -821,7 +821,7 @@ export const AudioContentSchema = z.object({
821821
* A tool call request from an assistant (LLM).
822822
* Represents the assistant's request to use a tool.
823823
*/
824-
export const ToolCallContentSchema = z
824+
export const ToolUseContentSchema = z
825825
.object({
826826
type: z.literal("tool_use"),
827827
/**
@@ -1195,7 +1195,7 @@ export const ToolChoiceSchema = z
11951195

11961196
/**
11971197
* The result of a tool execution, provided by the user (server).
1198-
* Represents the outcome of invoking a tool requested via ToolCallContent.
1198+
* Represents the outcome of invoking a tool requested via ToolUseContent.
11991199
*/
12001200
export const ToolResultContentSchema = z
12011201
.object({
@@ -1239,7 +1239,7 @@ export const AssistantMessageContentSchema = z.discriminatedUnion("type", [
12391239
TextContentSchema,
12401240
ImageContentSchema,
12411241
AudioContentSchema,
1242-
ToolCallContentSchema,
1242+
ToolUseContentSchema,
12431243
]);
12441244

12451245
/**
@@ -1340,7 +1340,7 @@ export const CreateMessageResultSchema = ResultSchema.extend({
13401340
*/
13411341
role: z.literal("assistant"),
13421342
/**
1343-
* Response content. May be ToolCallContent if stopReason is "toolUse".
1343+
* Response content. May be ToolUseContent if stopReason is "toolUse".
13441344
*/
13451345
content: z.union([AssistantMessageContentSchema, z.array(AssistantMessageContentSchema)]),
13461346
});
@@ -1770,7 +1770,7 @@ export type GetPromptRequest = Infer<typeof GetPromptRequestSchema>;
17701770
export type TextContent = Infer<typeof TextContentSchema>;
17711771
export type ImageContent = Infer<typeof ImageContentSchema>;
17721772
export type AudioContent = Infer<typeof AudioContentSchema>;
1773-
export type ToolCallContent = Infer<typeof ToolCallContentSchema>;
1773+
export type ToolUseContent = Infer<typeof ToolUseContentSchema>;
17741774
export type ToolResultContent = Infer<typeof ToolResultContentSchema>;
17751775
export type EmbeddedResource = Infer<typeof EmbeddedResourceSchema>;
17761776
export type ResourceLink = Infer<typeof ResourceLinkSchema>;

0 commit comments

Comments
 (0)