import {z} from 'zod' export type GoogleCloudAiplatformV1Tenant = {id?: string | undefined, type?: ('TYPE_UNSPECIFIED' | 'WORKSPACE_CUSTOMER') | undefined}; export type GoogleCloudAiplatformV1AgentIdentity = {email?: string | undefined, gaiaId?: string | undefined, tenant?: GoogleCloudAiplatformV1Tenant | undefined}; export type GoogleCloudAiplatformV1Teammate = {email?: string | undefined, expansionMode?: ('EXPANSION_MODE_UNSPECIFIED' | 'INFER' | 'EXPANDED' | 'NON_EXPANDED') | undefined, gaiaId?: string | undefined}; export type GoogleCloudAiplatformV1AllowedTeammates = {teammates?: Array | undefined}; export type GoogleCloudAiplatformV1EncryptionSpec = {kmsKeyName?: string | undefined}; export type GoogleCloudAiplatformV1AgentMemoryConfig = {disableMemory?: boolean | undefined}; export type GoogleCloudAiplatformV1AgentModelConfig = {model?: string | undefined, temperature?: number | undefined}; export type GoogleCloudAiplatformV1ObservabilityConfig = {observabilityEnabled?: boolean | undefined, sensitiveLoggingEnabled?: boolean | undefined}; export type GoogleCloudAiplatformV1Principal = {id?: string | undefined, type?: ('TYPE_UNSPECIFIED' | 'USER') | undefined}; export type GoogleCloudAiplatformV1Persona = {avatarUrl?: string | undefined, displayName?: string | undefined, personality?: string | undefined, role?: string | undefined}; export type GoogleCloudAiplatformV1AgentStatusSuspensionReason = {reason?: ('REASON_UNSPECIFIED' | 'ABUSE' | 'ADMIN' | 'USER_INITIATED') | undefined, suspensionTime?: unknown | undefined}; export type GoogleCloudAiplatformV1AgentStatus = {deleteTime?: unknown | undefined, state?: ('STATE_UNSPECIFIED' | 'ACTIVE' | 'SUSPENDED' | 'ARCHIVED' | 'DELETED') | undefined, suspensionReason?: GoogleCloudAiplatformV1AgentStatusSuspensionReason | undefined}; export type GoogleCloudAiplatformV1AgentTool = {headers?: {[key: string]: string} | undefined, name?: string | undefined, type?: string | undefined, url?: string | undefined}; export type GoogleCloudAiplatformV1Agent = {agentIdentity?: GoogleCloudAiplatformV1AgentIdentity | undefined, aiApplication?: string | undefined, allowedTeammates?: GoogleCloudAiplatformV1AllowedTeammates | undefined, base_agent?: string | undefined, base_environment: unknown, created?: unknown | undefined, description?: string | undefined, effectiveIdentity?: string | undefined, encryptionSpec?: GoogleCloudAiplatformV1EncryptionSpec | undefined, id?: string | undefined, memoryConfig?: GoogleCloudAiplatformV1AgentMemoryConfig | undefined, metadata?: {[key: string]: string} | undefined, modelConfig?: GoogleCloudAiplatformV1AgentModelConfig | undefined, name?: string | undefined, object?: string | undefined, observabilityConfig?: GoogleCloudAiplatformV1ObservabilityConfig | undefined, owner?: GoogleCloudAiplatformV1Principal | undefined, persona?: GoogleCloudAiplatformV1Persona | undefined, status?: GoogleCloudAiplatformV1AgentStatus | undefined, system_instruction?: string | undefined, tools?: Array | undefined, updated?: unknown | undefined}; export type PatchApiV1ProjectsProjectsIdLocationsLocationsIdAgentsAgentsIdArgs = {projectsId: string, locationsId: string, agentsId: string, updateMask?: unknown | undefined, body: GoogleCloudAiplatformV1Agent}; export type PatchApiV1ProjectsProjectsIdLocationsLocationsIdAgentsAgentsIdOptions = {baseUrl?: string | undefined, Oauth2?: string | undefined, Oauth2c?: string | undefined, fetch?: typeof fetch | undefined}; export const googleRpcStatus = z.object({code: z.number().int().optional(), details: z.array(z.record(z.string(), z.unknown())).optional(), message: z.string().optional()}); export const googleLongrunningOperation = z.object({done: z.boolean().optional(), error: googleRpcStatus.optional(), metadata: z.record(z.string(), z.unknown()).optional(), name: z.string().optional(), response: z.record(z.string(), z.unknown()).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 }; /** * Updates an agent. * * PATCH /v1/projects/{projectsId}/locations/{locationsId}/agents/{agentsId} * * Also accepts auth: Oauth2 + Oauth2c */ export const patchApiV1ProjectsProjectsIdLocationsLocationsIdAgentsAgentsId = async (args: PatchApiV1ProjectsProjectsIdLocationsLocationsIdAgentsAgentsIdArgs, options?: PatchApiV1ProjectsProjectsIdLocationsLocationsIdAgentsAgentsIdOptions) => { const {baseUrl = "https://aiplatform.googleapis.com", fetch: fetchFn = fetch, Oauth2, Oauth2c} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") headers.set('accept', "application/json") if (args.updateMask != null) query.append("updateMask", String(args.updateMask)) if (Oauth2 !== undefined) headers.set('authorization', `Bearer ${Oauth2}`) if (Oauth2c !== undefined) headers.set('authorization', `Bearer ${Oauth2c}`) const url = `${baseUrl.replace(/\/+$/, '')}/v1/projects/${encodeURIComponent(String(args.projectsId))}/locations/${encodeURIComponent(String(args.locationsId))}/agents/${encodeURIComponent(String(args.agentsId))}${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "PATCH", 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(googleLongrunningOperation, await res.json()) };