managarten/packages/shared-ai/src/tools/index.ts
Till JS 4523ab24e3 feat(shared-ai): toolToFunctionSchema — catalog → OpenAI function-spec
Single bridge between the AI_TOOL_CATALOG shape and the wire format every
provider (Gemini, OpenAI-compat, Ollama ≥ 0.3) speaks for native tool
calling. Keeps the catalog as the source of truth — the runner never
reads catalog entries directly; it asks this converter for function-spec
shapes to hand the LLM.

- No _rationale or wrapper-tool injection: the runner doesn't need it
  and the added schema noise would hurt planner quality.
- Throws on unknown parameter types so catalog typos (e.g. "array"
  instead of "string") fail loudly instead of coercing silently.
- Preserves enum constraints; drops the enum key entirely when absent
  so Gemini doesn't reject empty-enum function-declarations.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-20 15:24:36 +02:00

9 lines
305 B
TypeScript

export type { ToolSchema } from './schemas';
export { AI_TOOL_CATALOG, AI_TOOL_CATALOG_BY_NAME } from './schemas';
export type {
FunctionSpec,
JsonSchemaObject,
JsonSchemaProperty,
ToolSpec,
} from './function-schema';
export { toolToFunctionSchema, toolsToFunctionSchemas } from './function-schema';