feat: update TypeScript SDK to implement draft spec changes for structured tool output
- Add outputSchema support to Tool interface with proper documentation - Split CallToolResult into structured and unstructured variants - Change structuredContent from string to object type - Add validation that tools without outputSchema cannot return structuredContent - Add validation that tools with outputSchema must return structuredContent - Update client to validate structured content as object (no JSON parsing) - Update tests to use object format for structuredContent - Add tests for new validation constraints - Update LATEST_PROTOCOL_VERSION to DRAFT-2025-v2 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
parent
cf12fe0d83
commit
882e0b7d05
1 changed files with 243 additions and 32 deletions
|
|
@ -795,11 +795,11 @@ describe("tool()", () => {
|
|||
},
|
||||
async ({ input }) => ({
|
||||
// When outputSchema is defined, return structuredContent instead of content
|
||||
structuredContent: JSON.stringify({
|
||||
structuredContent: {
|
||||
processedInput: input,
|
||||
resultType: "structured",
|
||||
timestamp: "2023-01-01T00:00:00Z"
|
||||
}),
|
||||
},
|
||||
}),
|
||||
);
|
||||
|
||||
|
|
@ -860,10 +860,14 @@ describe("tool()", () => {
|
|||
expect(result.structuredContent).toBeDefined();
|
||||
expect(result.content).toBeUndefined(); // Should not have content when structuredContent is used
|
||||
|
||||
const parsed = JSON.parse(result.structuredContent || "{}");
|
||||
expect(parsed.processedInput).toBe("hello");
|
||||
expect(parsed.resultType).toBe("structured");
|
||||
expect(parsed.timestamp).toBe("2023-01-01T00:00:00Z");
|
||||
const structuredContent = result.structuredContent as {
|
||||
processedInput: string;
|
||||
resultType: string;
|
||||
timestamp: string;
|
||||
};
|
||||
expect(structuredContent.processedInput).toBe("hello");
|
||||
expect(structuredContent.resultType).toBe("structured");
|
||||
expect(structuredContent.timestamp).toBe("2023-01-01T00:00:00Z");
|
||||
});
|
||||
|
||||
test("should pass sessionId to tool callback via RequestHandlerExtra", async () => {
|
||||
|
|
|
|||
Loading…
Reference in a new issue