MCPcopy Index your code
hub / github.com/CodebuffAI/codebuff / processCustomToolDefinitions

Function processCustomToolDefinitions

sdk/src/run-state.ts:110–133  ·  view source on GitHub ↗

* Processes custom tool definitions into the format expected by SessionState. * Converts Zod schemas to JSON Schema format so they can survive JSON serialization.

(
  customToolDefinitions: CustomToolDefinition[],
)

Source from the content-addressed store, hash-verified

108 * Converts Zod schemas to JSON Schema format so they can survive JSON serialization.
109 */
110function processCustomToolDefinitions(
111 customToolDefinitions: CustomToolDefinition[],
112): CustomToolDefinitions {
113 return Object.fromEntries(
114 customToolDefinitions.map((toolDefinition) => {
115 // Convert Zod schema to JSON Schema format so it survives JSON serialization
116 // The agent-runtime will wrap this with AI SDK's jsonSchema() helper
117 const jsonSchema = z.toJSONSchema(toolDefinition.inputSchema, {
118 io: 'input',
119 }) as Record<string, unknown>
120 delete jsonSchema['$schema']
121
122 return [
123 toolDefinition.toolName,
124 {
125 inputSchema: jsonSchema,
126 description: toolDefinition.description,
127 endsAgentStep: toolDefinition.endsAgentStep,
128 exampleInputs: toolDefinition.exampleInputs,
129 },
130 ]
131 }),
132 )
133}
134
135/**
136 * Computes project file indexes (file tree and token scores)

Callers 2

initialSessionStateFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected