import {z} from 'zod' export type AgentStatus = 'draft' | 'creating' | 'active' | 'under_review' | 'deprecated' | 'archived' | 'pending' | 'rejected'; export type AccessLevel = 'black_box' | 'grey_box' | 'white_box'; export type AgentParams = {temperature?: (number | null) | undefined, top_p?: (number | null) | undefined, max_tokens?: (number | null) | undefined, timeout?: (number | null) | undefined, rag_params?: ({[key: string]: unknown} | null) | undefined, function_route_params?: ({[key: string]: unknown} | null) | undefined}; export type MCPAccessLevel = 'read' | 'write' | 'admin'; export type MCPConfig = {proxy_url?: (string | null) | undefined, access_level?: (MCPAccessLevel | null) | undefined, server_urls?: (Array | null) | undefined}; export type DelegatedAgent = {url: string, agent_card_url?: (string | null) | undefined, name?: (string | null) | undefined, capabilities?: (Array | null) | undefined}; export type WhiteBoxConfigInput = {source_code?: (string | null) | undefined, repo_url?: (string | null) | undefined, github_username?: (string | null) | undefined, github_token?: (string | null) | undefined, repo_branch?: (string | null) | undefined, entry_point?: (string | null) | undefined}; export type AgentMetadata = {role?: (string | null) | undefined, job_description?: (string | null) | undefined, version?: (string | null) | undefined, author?: (string | null) | undefined, tags?: (Array | null) | undefined}; export type ProtocolType = 'chat_completions' | 'a2a'; export type ProtectionStatus = 'unprotected' | 'configured' | 'domed'; export type AgentUpdate = {status?: (AgentStatus | null) | undefined, agent_name?: (string | null) | undefined, agent_url?: (string | null) | undefined, model_name?: (string | null) | undefined, api_key?: (string | null) | undefined, agent_system_prompt?: (string | null) | undefined, hub?: (string | null) | undefined, rate_limit_requests_per_minute?: (number | null) | undefined, access_level?: (AccessLevel | null) | undefined, agent_params?: (AgentParams | null) | undefined, mcp_config?: (MCPConfig | null) | undefined, delegated_agents?: (Array | null) | undefined, white_box_config?: (WhiteBoxConfigInput | null) | undefined, agent_metadata?: (AgentMetadata | null) | undefined, purpose?: (string | null) | undefined, protocol?: (ProtocolType | null) | undefined, test_score?: (number | string | null) | undefined, last_tested_by?: (string | null) | undefined, evaluated_harnesses?: (Array | null) | undefined, last_evaluated_at?: (number | null) | undefined, protection_status?: (ProtectionStatus | null) | undefined, dome_config_id?: (string | null) | undefined, dome_manually_configured?: (boolean | null) | undefined}; export type UpdateApiV1AgentConfigurationsIdArgs = {id: string, body: AgentUpdate}; export type UpdateApiV1AgentConfigurationsIdOptions = {baseUrl: string, fetch?: typeof fetch | undefined}; export const agentStatus = z.enum(["draft", "creating", "active", "under_review", "deprecated", "archived", "pending", "rejected"]); export const accessLevel = z.enum(["black_box", "grey_box", "white_box"]); export const agentParams = z.object({temperature: z.number().nullable().optional(), top_p: z.number().nullable().optional(), max_tokens: z.number().int().nullable().optional(), timeout: z.number().int().nullable().optional(), rag_params: z.record(z.string(), z.unknown()).nullable().optional(), function_route_params: z.record(z.string(), z.unknown()).nullable().optional()}); export const mCPAccessLevel = z.enum(["read", "write", "admin"]); export const mCPConfig = z.object({proxy_url: z.string().min(1).max(2083).nullable().optional(), access_level: mCPAccessLevel.nullable().optional(), server_urls: z.array(z.string().min(1).max(2083)).nullable().optional()}); export const delegatedAgent = z.object({url: z.string(), agent_card_url: z.string().nullable().optional(), name: z.string().nullable().optional(), capabilities: z.array(z.string()).nullable().optional()}); export const whiteBoxConfigOutput = z.object({source_code: z.string().nullable().optional(), repo_url: z.string().nullable().optional(), github_username: z.string().nullable().optional(), repo_branch: z.string().nullable().optional(), entry_point: z.string().nullable().optional()}); export const agentMetadata = z.object({role: z.string().nullable().optional(), job_description: z.string().nullable().optional(), version: z.string().nullable().optional(), author: z.string().nullable().optional(), tags: z.array(z.string()).nullable().optional()}); export const protocolType = z.enum(["chat_completions", "a2a"]); export const protectionStatus = z.enum(["unprotected", "configured", "domed"]); export const trustLifecycleStage = z.enum(["registered", "tested", "hardened", "trusted", "optimized", "adapted"]); export const importSource = z.literal("manual"); export const importMetadata = z.object({source: importSource.nullable().optional(), source_url: z.string().nullable().optional(), imported_at: z.number().int().nullable().optional(), original_format: z.string().nullable().optional()}); export const agentCapabilities = z.object({streaming: z.boolean().optional(), push_notifications: z.boolean().optional(), code_execution: z.boolean().optional(), memory: z.boolean().optional(), delegation: z.boolean().optional(), tools: z.array(z.string()).optional()}); export const agentSkill = z.object({id: z.string(), name: z.string(), description: z.string().nullable().optional(), input_modes: z.array(z.string()).optional(), output_modes: z.array(z.string()).optional()}); export const agentLatestEvaluation = z.object({evaluation_id: z.string(), overall_score: z.number().nullable().optional(), reliability_score: z.number().nullable().optional(), security_score: z.number().nullable().optional(), safety_score: z.number().nullable().optional(), completed_at: z.number().int().nullable().optional()}); export const agent = z.object({id: z.string(), agent_name: z.string(), model_name: z.string(), agent_url: z.string().nullable().optional(), hub: z.string().optional(), api_key: z.string().nullable().optional(), agent_system_prompt: z.string().nullable().optional(), rate_limit_requests_per_minute: z.number().int().gte(1).optional(), team_id: z.string(), created_by: z.string(), status: agentStatus.optional(), created_at: z.number().int(), updated_at: z.number().int(), access_level: accessLevel.optional(), agent_params: agentParams.nullable().optional(), mcp_config: mCPConfig.nullable().optional(), delegated_agents: z.array(delegatedAgent).optional(), white_box_config: whiteBoxConfigOutput.nullable().optional(), agent_metadata: agentMetadata.nullable().optional(), purpose: z.string().nullable().optional(), protocol: protocolType.optional(), test_score: z.string().nullable().optional(), last_tested_by: z.string().nullable().optional(), evaluated_harnesses: z.array(z.string()).nullable().optional(), last_evaluated_at: z.number().int().nullable().optional(), protection_status: protectionStatus.optional(), trust_stage: trustLifecycleStage.optional(), trusted_at: z.number().int().nullable().optional(), ttt_days: z.number().nullable().optional(), dome_config_id: z.string().nullable().optional(), dome_manually_configured: z.boolean().optional(), import_metadata: z.union([importMetadata, z.record(z.string(), z.unknown())]).nullable().optional(), capabilities: z.union([agentCapabilities, z.record(z.string(), z.unknown())]).nullable().optional(), skills: z.array(z.union([agentSkill, z.record(z.string(), z.unknown())])).optional(), latest_evaluation: agentLatestEvaluation.nullable().optional()}); export const validateResponse = async ( schema: { readonly '~standard': { readonly validate: (value: unknown) => ({ readonly value: Output; readonly issues?: undefined } | { readonly issues: ReadonlyArray<{ readonly message: string; readonly path?: ReadonlyArray | undefined }> }) | Promise<{ readonly value: Output; readonly issues?: undefined } | { readonly issues: ReadonlyArray<{ readonly message: string; readonly path?: ReadonlyArray | undefined }> }> } }, value: unknown ): Promise => { const result = await schema['~standard'].validate(value) if (result.issues !== undefined) { const detail = result.issues .map(({ message, path }) => path?.length ? `${path.map((segment) => String(typeof segment === 'object' ? segment.key : segment)).join('.')}: ${message}` : message ) .join('; ') throw new Error(`Response does not match the schema: ${detail}`, { cause: { issues: result.issues } }) } return result.value }; /** * Update Agent Configuration * * PUT /v1/agent-configurations/{id} */ export const updateApiV1AgentConfigurationsId = async (args: UpdateApiV1AgentConfigurationsIdArgs, options: UpdateApiV1AgentConfigurationsIdOptions) => { const {baseUrl, fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") headers.set('accept', "application/json") const url = `${baseUrl.replace(/\/+$/, '')}/v1/agent-configurations/${encodeURIComponent(String(args.id))}${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "PUT", headers, body: JSON.stringify(args.body)}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return validateResponse(agent, await res.json()) };