@utcp/sdk
Version:
Universal Tool Calling Protocol (UTCP) client library for TypeScript
45 lines • 1.76 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.UtcpClientConfigSchema = exports.UtcpVariablesConfigSchema = exports.UtcpVariableNotFoundError = void 0;
const zod_1 = require("zod");
/**
* Custom error for when a variable referenced in a provider configuration is not found.
*/
class UtcpVariableNotFoundError extends Error {
constructor(variableName) {
super(`Variable ${variableName} referenced in provider configuration not found. Please add it to the environment variables or to your UTCP configuration.`);
this.variableName = variableName;
this.name = 'UtcpVariableNotFoundError';
}
}
exports.UtcpVariableNotFoundError = UtcpVariableNotFoundError;
// Schema for the dotenv variable source
const UtcpDotEnvSchema = zod_1.z.object({
type: zod_1.z.literal('dotenv'),
env_file_path: zod_1.z.string(),
});
/**
* Represents a source for loading variables, like a .env file.
*/
exports.UtcpVariablesConfigSchema = zod_1.z.discriminatedUnion('type', [
UtcpDotEnvSchema,
// Future variable source types can be added here
]);
/**
* The main configuration schema for the UTCP client.
*/
exports.UtcpClientConfigSchema = zod_1.z.object({
/**
* A dictionary of variables that can be referenced in provider configurations.
*/
variables: zod_1.z.record(zod_1.z.string()).optional().default({}),
/**
* The file path to a JSON or YAML file containing a list of providers.
*/
providers_file_path: zod_1.z.string().optional(),
/**
* A list of sources from which to load additional variables.
*/
load_variables_from: zod_1.z.array(exports.UtcpVariablesConfigSchema).optional(),
});
//# sourceMappingURL=utcp-client-config.js.map