Skip to content

Commit 5b48124

Browse files
ochafikclaude
andcommitted
refactor: re-export tool and elicitation schemas from generated
Add re-exports for: - ToolAnnotationsSchema - ToolExecutionSchema - BooleanSchemaSchema - NumberSchemaSchema Total schemas re-exported: 20 Lines saved: ~171 (2600 → 2429) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent 650038d commit 5b48124

File tree

1 file changed

+14
-79
lines changed

1 file changed

+14
-79
lines changed

src/types.ts

Lines changed: 14 additions & 79 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,12 @@ import {
3131
ModelHintSchema,
3232
ModelPreferencesSchema,
3333
ToolChoiceSchema,
34+
// Tool-related schemas
35+
ToolAnnotationsSchema,
36+
ToolExecutionSchema,
37+
// Elicitation primitive schemas
38+
BooleanSchemaSchema,
39+
NumberSchemaSchema,
3440
} from './generated/sdk.schemas.js';
3541

3642
export {
@@ -50,6 +56,10 @@ export {
5056
ModelHintSchema,
5157
ModelPreferencesSchema,
5258
ToolChoiceSchema,
59+
ToolAnnotationsSchema,
60+
ToolExecutionSchema,
61+
BooleanSchemaSchema,
62+
NumberSchemaSchema,
5363
};
5464

5565
export const LATEST_PROTOCOL_VERSION = '2025-11-25';
@@ -1197,65 +1207,9 @@ export const PromptListChangedNotificationSchema = NotificationSchema.extend({
11971207
*
11981208
* Clients should never make tool use decisions based on ToolAnnotations
11991209
* received from untrusted servers.
1210+
*
1211+
* Note: ToolAnnotationsSchema and ToolExecutionSchema are re-exported from generated schemas.
12001212
*/
1201-
export const ToolAnnotationsSchema = z.object({
1202-
/**
1203-
* A human-readable title for the tool.
1204-
*/
1205-
title: z.string().optional(),
1206-
1207-
/**
1208-
* If true, the tool does not modify its environment.
1209-
*
1210-
* Default: false
1211-
*/
1212-
readOnlyHint: z.boolean().optional(),
1213-
1214-
/**
1215-
* If true, the tool may perform destructive updates to its environment.
1216-
* If false, the tool performs only additive updates.
1217-
*
1218-
* (This property is meaningful only when `readOnlyHint == false`)
1219-
*
1220-
* Default: true
1221-
*/
1222-
destructiveHint: z.boolean().optional(),
1223-
1224-
/**
1225-
* If true, calling the tool repeatedly with the same arguments
1226-
* will have no additional effect on the its environment.
1227-
*
1228-
* (This property is meaningful only when `readOnlyHint == false`)
1229-
*
1230-
* Default: false
1231-
*/
1232-
idempotentHint: z.boolean().optional(),
1233-
1234-
/**
1235-
* If true, this tool may interact with an "open world" of external
1236-
* entities. If false, the tool's domain of interaction is closed.
1237-
* For example, the world of a web search tool is open, whereas that
1238-
* of a memory tool is not.
1239-
*
1240-
* Default: true
1241-
*/
1242-
openWorldHint: z.boolean().optional()
1243-
});
1244-
1245-
/**
1246-
* Execution-related properties for a tool.
1247-
*/
1248-
export const ToolExecutionSchema = z.object({
1249-
/**
1250-
* Indicates the tool's preference for task-augmented execution.
1251-
* - "required": Clients MUST invoke the tool as a task
1252-
* - "optional": Clients MAY invoke the tool as a task or normal request
1253-
* - "forbidden": Clients MUST NOT attempt to invoke the tool as a task
1254-
*
1255-
* If not present, defaults to "forbidden".
1256-
*/
1257-
taskSupport: z.enum(['required', 'optional', 'forbidden']).optional()
1258-
});
12591213

12601214
/**
12611215
* Definition for a tool the client can call.
@@ -1679,15 +1633,8 @@ export const CreateMessageResultWithToolsSchema = ResultSchema.extend({
16791633
});
16801634

16811635
/* Elicitation */
1682-
/**
1683-
* Primitive schema definition for boolean fields.
1684-
*/
1685-
export const BooleanSchemaSchema = z.object({
1686-
type: z.literal('boolean'),
1687-
title: z.string().optional(),
1688-
description: z.string().optional(),
1689-
default: z.boolean().optional()
1690-
});
1636+
// Note: BooleanSchemaSchema and NumberSchemaSchema are re-exported from generated schemas.
1637+
// StringSchemaSchema differs slightly (enum vs union for format) so kept here.
16911638

16921639
/**
16931640
* Primitive schema definition for string fields.
@@ -1702,18 +1649,6 @@ export const StringSchemaSchema = z.object({
17021649
default: z.string().optional()
17031650
});
17041651

1705-
/**
1706-
* Primitive schema definition for number fields.
1707-
*/
1708-
export const NumberSchemaSchema = z.object({
1709-
type: z.enum(['number', 'integer']),
1710-
title: z.string().optional(),
1711-
description: z.string().optional(),
1712-
minimum: z.number().optional(),
1713-
maximum: z.number().optional(),
1714-
default: z.number().optional()
1715-
});
1716-
17171652
/**
17181653
* Schema for single-selection enumeration without display titles for options.
17191654
*/

0 commit comments

Comments
 (0)