"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.defineTool = defineTool;
exports.implementServerTool = implementServerTool;
exports.implementClientTool = implementClientTool;
exports.prepareClientTool = prepareClientTool;
exports.createClientTool = createClientTool;
exports.isServerTool = isServerTool;
exports.isPreparedClientTool = isPreparedClientTool;
exports.isPureClientSideTool = isPureClientSideTool;
/**
 * Factory function to create a type-safe ToolDefinition.
 */
function defineTool(definition) {
    return definition;
}
// ============================================================================
// Helper Functions to Create Tools
// ============================================================================
/**
 * Creates a server-side tool from a definition and execute function.
 */
function implementServerTool(definition, execute) {
    return {
        definition: definition,
        executor: 'server',
        execute: execute,
    };
}
/**
 * Creates a client-side tool from a definition and execute function.
 */
function implementClientTool(definition, execute) {
    return {
        definition: definition,
        executor: 'client',
        execute: execute,
    };
}
/**
 * Creates a client-side tool with server preparation from a definition and serverPrepare function.
 */
function prepareClientTool(definition, serverPrepare) {
    if (!definition.serverPrepareResultSchema) {
        throw new Error("Tool ".concat(definition.name, " requires serverPrepareResultSchema to use implementClientToolWithServerPrepare"));
    }
    return {
        definition: definition,
        executor: 'client',
        serverPrepare: serverPrepare,
    };
}
/**
 * Creates a client-side tool from a definition. This has no server-side preparation and no
 * execution logic. It's only used in the tool looping code so that the client tool definitions
 * are available to the models.
 */
function createClientTool(definition) {
    return {
        definition: definition,
        executor: 'client',
    };
}
// ============================================================================
// Type Guards
// ============================================================================
/**
 * Type guard to check if a tool is a server-side tool.
 */
function isServerTool(tool) {
    return tool.executor === 'server';
}
/**
 * Type guard to check if a tool is a client-side tool with server preparation.
 */
function isPreparedClientTool(tool) {
    return tool.executor === 'client' && 'serverPrepare' in tool && typeof tool.serverPrepare === 'function';
}
/**
 * Type guard to check if a tool is a pure client-side tool without server preparation.
 */
function isPureClientSideTool(tool) {
    return tool.executor === 'client' && !('serverPrepare' in tool);
}
//# sourceMappingURL=toolDefinition.js.map