// This file is auto-generated by @hey-api/openapi-ts

import * as z from 'zod';

export const zPostAuthWebsocketTicketBody = z.object({
    audience: z.string().min(1).max(256)
});

export const zPutPreferencesAppBody = z.object({
    featureFlags: z.object({
        multiWorkspacePoc: z.boolean().default(false),
        localAuthForDangerousActions: z.boolean().optional().default(false),
        continueBlockedCodexGoals: z.boolean().optional().default(false),
        blockCodexAppServerLogInserts: z.boolean().optional().default(false),
        codexCliCompatibleIdentity: z.boolean().optional().default(false),
        nativeProviderSkillProjection: z.boolean().optional().default(false),
        turnCheckpoints: z.boolean().optional().default(false),
        threadHandoffs: z.boolean().optional().default(false)
    }),
    worktreeCleanup: z.object({
        maxWorktrees: z.number().gte(0).default(25),
        maxTotalSizeGb: z.number().gte(0).default(50)
    }).optional()
});

export const zPutPreferencesChatBody = z.object({
    modelId: z.string().nullable(),
    configSelections: z.record(z.string(), z.unknown()),
    continuationBehavior: z.enum(['queue', 'steer']).optional(),
    titleGeneration: z.object({
        providerTargetId: z.string().nullable(),
        modelId: z.string().nullable(),
        thinkingEffort: z.enum([
            'minimal',
            'low',
            'medium',
            'high',
            'xhigh'
        ])
    }).optional()
});

export const zPutPreferencesCodexBody = z.object({
    useCradleUserAgent: z.boolean().default(true)
});

export const zPutPreferencesDesktopBody = z.object({
    requireDoubleCommandQToQuit: z.boolean().default(true),
    appshotHotkeyEnabled: z.boolean().default(true),
    appshotHotkeyTrigger: z.enum([
        'DoubleCommand',
        'DoubleOption',
        'DoubleShift'
    ]),
    autoCheckForUpdates: z.boolean().default(true),
    autoDownloadUpdates: z.boolean().default(false),
    lastSeenChangelogVersion: z.string().nullable().default(null),
    externalTerminalApp: z.string().nullable().default(null)
});

export const zPutPreferencesNetworkBody = z.object({
    proxyEnabled: z.boolean().default(true),
    proxyMode: z.enum([
        'system',
        'custom',
        'environment'
    ]),
    customProxyUrl: z.string().nullable(),
    inbound: z.object({
        serverAccessMode: z.enum(['local', 'network']),
        managedRelayAccessMode: z.enum(['local', 'network']),
        managedRelayPublicUrl: z.string().nullable()
    }).optional()
});

export const zPutPreferencesJarvisBody = z.object({
    runtimeKind: z.string().min(1).optional(),
    profileId: z.string().nullable(),
    model: z.string().optional(),
    thinkingLevel: z.enum([
        'minimal',
        'low',
        'medium',
        'high',
        'xhigh'
    ])
});

export const zPostWorkspacesBody = z.object({
    name: z.string().min(1).regex(/.*\S.*/),
    locator: z.object({
        hostId: z.string().min(1).regex(/.*\S.*/),
        path: z.string().min(1).regex(/.*\S.*/),
        kind: z.enum(['project', 'managed-worktree']).optional(),
        sourceWorkspaceId: z.string().nullish()
    }),
    gitIdentity: z.object({
        originUrl: z.string().nullish(),
        repoRoot: z.string().nullish(),
        headSha: z.string().nullish(),
        branch: z.string().nullish()
    }).optional()
});

export const zPostWorkspacesFromDirectoryBody = z.object({
    path: z.string().min(1).regex(/.*\S.*/)
});

export const zPostWorkspacesInspectDirectoryBody = z.object({
    path: z.string().min(1).regex(/.*\S.*/)
});

export const zPostWorkspacesMultiFolderBody = z.object({
    name: z.string().min(1).regex(/.*\S.*/),
    folders: z.array(z.object({
        name: z.string().min(1).regex(/.*\S.*/),
        path: z.string().min(1).regex(/.*\S.*/)
    })).min(2)
});

export const zPostWorkspacesMultiFolderFromConfigBody = z.object({
    path: z.string().min(1).regex(/.*\S.*/)
});

export const zGetWorkspacesResolveQuery = z.object({
    hostId: z.string().min(1).regex(/.*\S.*/),
    path: z.string().min(1).regex(/.*\S.*/)
});

export const zGetWorkspacesByWorkspaceIdFilesPath = z.object({
    workspaceId: z.string().min(1)
});

export const zGetWorkspacesByWorkspaceIdFilesChildrenPath = z.object({
    workspaceId: z.string().min(1)
});

export const zGetWorkspacesByWorkspaceIdFilesChildrenQuery = z.object({
    path: z.string().optional()
});

export const zGetWorkspacesByWorkspaceIdFilesSearchPath = z.object({
    workspaceId: z.string().min(1)
});

export const zGetWorkspacesByWorkspaceIdFilesSearchQuery = z.object({
    q: z.string().optional(),
    limit: z.number().gte(1).lte(100).optional()
});

export const zGetWorkspacesByWorkspaceIdFilesEventsPath = z.object({
    workspaceId: z.string().min(1)
});

export const zGetWorkspacesByWorkspaceIdFilesContentPath = z.object({
    workspaceId: z.string().min(1)
});

export const zGetWorkspacesByWorkspaceIdFilesContentQuery = z.object({
    path: z.string().min(1).regex(/.*\S.*/)
});

export const zPutWorkspacesByWorkspaceIdFilesContentBody = z.object({
    path: z.string().min(1).regex(/.*\S.*/),
    content: z.string(),
    confirmedNonCradleOwnedWrite: z.boolean()
});

export const zPutWorkspacesByWorkspaceIdFilesContentPath = z.object({
    workspaceId: z.string().min(1)
});

export const zGetWorkspacesByWorkspaceIdFilesInfoPath = z.object({
    workspaceId: z.string().min(1)
});

export const zGetWorkspacesByWorkspaceIdFilesInfoQuery = z.object({
    path: z.string().min(1).regex(/.*\S.*/)
});

export const zGetWorkspacesByWorkspaceIdFilesRawPath = z.object({
    workspaceId: z.string().min(1)
});

export const zGetWorkspacesByWorkspaceIdFilesRawQuery = z.object({
    path: z.string().min(1).regex(/.*\S.*/)
});

export const zGetWorkspacesByWorkspaceIdFilesRenditionPdfPath = z.object({
    workspaceId: z.string().min(1)
});

export const zGetWorkspacesByWorkspaceIdFilesRenditionPdfQuery = z.object({
    path: z.string().min(1).regex(/.*\S.*/)
});

export const zPostWorkspacesByWorkspaceIdFilesFileBody = z.object({
    path: z.string().min(1).regex(/.*\S.*/),
    confirmedNonCradleOwnedWrite: z.boolean()
});

export const zPostWorkspacesByWorkspaceIdFilesFilePath = z.object({
    workspaceId: z.string().min(1)
});

export const zPostWorkspacesByWorkspaceIdFilesFolderBody = z.object({
    path: z.string().min(1).regex(/.*\S.*/),
    confirmedNonCradleOwnedWrite: z.boolean()
});

export const zPostWorkspacesByWorkspaceIdFilesFolderPath = z.object({
    workspaceId: z.string().min(1)
});

export const zPatchWorkspacesByWorkspaceIdFilesPathBody = z.object({
    sourcePath: z.string().min(1).regex(/.*\S.*/),
    destinationPath: z.string().min(1).regex(/.*\S.*/),
    confirmedNonCradleOwnedWrite: z.boolean()
});

export const zPatchWorkspacesByWorkspaceIdFilesPathPath = z.object({
    workspaceId: z.string().min(1)
});

export const zDeleteWorkspacesByWorkspaceIdPath = z.object({
    workspaceId: z.string().min(1)
});

export const zGetWorkspacesByWorkspaceIdPath = z.object({
    workspaceId: z.string().min(1)
});

export const zPatchWorkspacesByWorkspaceIdBody = z.object({
    name: z.string().min(1).regex(/.*\S.*/).optional(),
    pinned: z.boolean().optional()
});

export const zPatchWorkspacesByWorkspaceIdPath = z.object({
    workspaceId: z.string().min(1)
});

export const zPatchWorkspacesByWorkspaceIdLocationBody = z.object({
    path: z.string().min(1).regex(/.*\S.*/)
});

export const zPatchWorkspacesByWorkspaceIdLocationPath = z.object({
    workspaceId: z.string().min(1)
});

export const zPostWorkspacesByWorkspaceIdMigrateBody = z.object({
    targetWorkspaceId: z.string().min(1),
    entities: z.array(z.enum([
        'issues',
        'kanban',
        'automation'
    ])).optional(),
    statusMappings: z.record(z.string(), z.unknown()).optional(),
    milestoneMappings: z.record(z.string(), z.unknown()).optional(),
    dryRun: z.boolean().optional()
});

export const zPostWorkspacesByWorkspaceIdMigratePath = z.object({
    workspaceId: z.string().min(1)
});

export const zGetFilesystemBrowseQuery = z.object({
    path: z.string().optional()
});

export const zPostUsageReconcileClaudeQuery = z.object({
    maxBindings: z.union([
        z.string(),
        z.number().gte(1).lte(1000)
    ]).optional()
});

export const zGetUsageDailyQuery = z.object({
    days: z.union([
        z.string(),
        z.number().gte(1)
    ]).optional()
});

export const zGetUsageDailyByModelQuery = z.object({
    days: z.union([
        z.string(),
        z.number().gte(1)
    ]).optional()
});

export const zGetUsageSummaryQuery = z.object({
    from: z.iso.date().optional(),
    to: z.iso.date().optional()
});

export const zGetUsageSessionsRecentQuery = z.object({
    limit: z.union([
        z.string(),
        z.number().gte(1).lte(20)
    ]).optional()
});

export const zGetUsageSessionsBySessionIdPath = z.object({
    sessionId: z.string().min(1)
});

export const zGetUsageCostSummaryQuery = z.object({
    from: z.iso.date().optional(),
    to: z.iso.date().optional()
});

export const zGetUsageCostSessionsQuery = z.object({
    from: z.iso.date().optional(),
    to: z.iso.date().optional()
});

export const zGetUsageCostDailyQuery = z.object({
    from: z.iso.date().optional(),
    to: z.iso.date().optional()
});

export const zGetUsagePerformanceQuery = z.object({
    from: z.iso.date().optional(),
    to: z.iso.date().optional()
});

export const zGetUsageToolsQuery = z.object({
    from: z.iso.date().optional(),
    to: z.iso.date().optional()
});

export const zGetUsageCostEfficiencyQuery = z.object({
    days: z.union([
        z.string(),
        z.number().gte(1)
    ]).optional()
});

export const zDeleteProfilesByIdPath = z.object({
    id: z.string().min(1)
});

export const zGetProfilesByIdPath = z.object({
    id: z.string().min(1)
});

export const zPutProfilesByIdBody = z.object({
    name: z.string().min(1),
    providerKind: z.enum([
        'openai-compatible',
        'anthropic',
        'universal'
    ]),
    enabled: z.boolean(),
    config: z.record(z.string(), z.unknown()),
    credentialRef: z.string().min(1).nullish(),
    iconSlug: z.string().nullish(),
    providerId: z.string().min(1).nullish()
});

export const zPutProfilesByIdPath = z.object({
    id: z.string().min(1)
});

export const zPostProfilesByIdBindProviderBody = z.object({
    providerId: z.string().min(1),
    applyEndpointDefaults: z.boolean().optional()
});

export const zPostProfilesByIdBindProviderPath = z.object({
    id: z.string().min(1)
});

export const zPatchProfilesByIdIconBody = z.object({
    iconSlug: z.string().nullable()
});

export const zPatchProfilesByIdIconPath = z.object({
    id: z.string().min(1)
});

export const zPatchProfilesByIdCustomModelsBody = z.object({
    models: z.array(z.object({
        id: z.string().min(1),
        label: z.string().optional(),
        capabilities: z.object({
            contextWindow: z.number().optional(),
            maxOutput: z.number().optional(),
            inputModalities: z.array(z.string()).optional(),
            outputModalities: z.array(z.string()).optional(),
            reasoning: z.boolean().optional(),
            reasoningEfforts: z.array(z.enum([
                'none',
                'minimal',
                'low',
                'medium',
                'high',
                'xhigh',
                'max',
                'ultra'
            ])).optional(),
            toolCall: z.boolean().optional(),
            temperature: z.boolean().optional(),
            structuredOutput: z.boolean().optional(),
            cost: z.object({
                input: z.number().optional(),
                output: z.number().optional(),
                cacheRead: z.number().optional(),
                cacheWrite: z.number().optional()
            }).optional(),
            family: z.string().optional(),
            knowledgeCutoff: z.string().optional(),
            releaseDate: z.string().optional(),
            registryMatch: z.enum([
                'exact',
                'fuzzy',
                'manual',
                'alias',
                'unmatched'
            ]).optional(),
            registryModelId: z.string().optional(),
            registryModelLabel: z.string().optional()
        }).optional()
    }))
});

export const zPatchProfilesByIdCustomModelsPath = z.object({
    id: z.string().min(1)
});

export const zGetProviderTargetsQuery = z.object({
    runtimeKind: z.string().min(1).optional(),
    workspaceId: z.string().min(1).optional()
});

export const zDeleteProviderTargetsByProviderTargetIdPath = z.object({
    providerTargetId: z.string().min(1)
});

export const zPutProviderTargetsByProviderTargetIdBody = z.object({
    displayName: z.string().min(1),
    providerKind: z.enum([
        'openai-compatible',
        'anthropic',
        'universal'
    ]),
    enabled: z.boolean().optional(),
    connectionConfig: z.record(z.string(), z.unknown()),
    credentialRef: z.string().nullish(),
    iconSlug: z.string().nullish()
});

export const zPutProviderTargetsByProviderTargetIdPath = z.object({
    providerTargetId: z.string().min(1)
});

export const zPostProviderTargetsCredentialsChatgptLoginBody = z.object({
    label: z.string().nullish()
});

export const zGetProviderTargetsCredentialsChatgptLoginByLoginIdPath = z.object({
    loginId: z.string().min(1)
});

export const zPostProviderTargetsCredentialsChatgptLoginByLoginIdCancelPath = z.object({
    loginId: z.string().min(1)
});

export const zGetProviderTargetsByProviderTargetIdModelSettingsPath = z.object({
    providerTargetId: z.string().min(1)
});

export const zPatchProviderTargetsByProviderTargetIdModelSettingsBody = z.object({
    claudeAgent: z.object({
        modelAliases: z.object({
            haiku: z.string().optional(),
            sonnet: z.string().optional(),
            opus: z.string().optional()
        }).optional()
    }).nullable()
});

export const zPatchProviderTargetsByProviderTargetIdModelSettingsPath = z.object({
    providerTargetId: z.string().min(1)
});

export const zGetProviderTargetsByProviderTargetIdAuthDiagnosticsPath = z.object({
    providerTargetId: z.string().min(1)
});

export const zGetProviderTargetsByProviderTargetIdCodexAccountDiagnosticsPath = z.object({
    providerTargetId: z.string().min(1)
});

export const zGetProviderTargetsByProviderTargetIdCodexWhamDiagnosticsPath = z.object({
    providerTargetId: z.string().min(1)
});

export const zPostProviderTargetsByProviderTargetIdCodexRateLimitResetCreditConsumeBody = z.object({
    idempotencyKey: z.string().min(1)
});

export const zPostProviderTargetsByProviderTargetIdCodexRateLimitResetCreditConsumePath = z.object({
    providerTargetId: z.string().min(1)
});

export const zPatchProviderTargetsByProviderTargetIdModelVisibilityBody = z.object({
    enabledModels: z.array(z.string().min(1))
});

export const zPatchProviderTargetsByProviderTargetIdModelVisibilityPath = z.object({
    providerTargetId: z.string().min(1)
});

export const zPatchProviderTargetsByProviderTargetIdCustomModelsBody = z.object({
    models: z.array(z.object({
        id: z.string().min(1),
        label: z.string().optional()
    }))
});

export const zPatchProviderTargetsByProviderTargetIdCustomModelsPath = z.object({
    providerTargetId: z.string().min(1)
});

export const zGetProviderTargetsByProviderTargetIdTestPath = z.object({
    providerTargetId: z.string().min(1)
});

export const zPostProviderTargetsByProviderTargetIdTestBody = z.object({
    deep: z.boolean().optional(),
    model: z.string().min(1).optional()
});

export const zPostProviderTargetsByProviderTargetIdTestPath = z.object({
    providerTargetId: z.string().min(1)
});

export const zPostRelayServersBody = z.object({
    id: z.string().min(1).regex(/.*\S.*/).optional(),
    displayName: z.string().min(1).regex(/.*\S.*/),
    relayUrl: z.string().min(1).regex(/.*\S.*/),
    enabled: z.boolean().optional(),
    isDefault: z.boolean().optional()
});

export const zDeleteRelayServersByRelayServerIdPath = z.object({
    relayServerId: z.string().min(1)
});

export const zPatchRelayServersByRelayServerIdBody = z.object({
    displayName: z.string().min(1).regex(/.*\S.*/).optional(),
    relayUrl: z.string().min(1).regex(/.*\S.*/).optional(),
    enabled: z.boolean().optional(),
    isDefault: z.boolean().optional()
});

export const zPatchRelayServersByRelayServerIdPath = z.object({
    relayServerId: z.string().min(1)
});

export const zPostRelayTransportHostEnrollmentsBody = z.object({
    id: z.string().min(1).optional(),
    displayName: z.string().min(1),
    relayUrl: z.string().min(1)
});

export const zDeleteRelayTransportHostEnrollmentsByEnrollmentIdPath = z.object({
    enrollmentId: z.string().min(1)
});

export const zGetRelayTransportHostEnrollmentsByEnrollmentIdPath = z.object({
    enrollmentId: z.string().min(1)
});

export const zGetRelayTransportHostEnrollmentsByEnrollmentIdPairingStringPath = z.object({
    enrollmentId: z.string().min(1)
});

export const zPostRemoteHostsBody = z.object({
    id: z.string().min(1).regex(/.*\S.*/).optional(),
    displayName: z.string().min(1).regex(/.*\S.*/),
    enabled: z.boolean().optional(),
    connectionConfig: z.object({
        transport: z.enum([
            'ssh',
            'direct-url',
            'relay'
        ]).optional(),
        baseUrl: z.string().min(1).regex(/.*\S.*/).optional(),
        ssh: z.object({
            hostName: z.string().min(1).regex(/.*\S.*/),
            user: z.string().nullish(),
            port: z.union([
                z.string(),
                z.int().gte(1).lte(65535)
            ]).nullish(),
            auth: z.enum(['default', 'identityFile']).optional(),
            identityFilePath: z.string().nullish()
        }).optional(),
        sshExecutable: z.string().min(1).regex(/.*\S.*/).optional(),
        sshArgs: z.array(z.string()).optional(),
        connectTimeoutMs: z.union([
            z.string(),
            z.int().gte(1).lte(120000)
        ]).optional(),
        relay: z.object({
            relayServerId: z.string().nullish(),
            relayUrl: z.string().nullish(),
            roomId: z.string().nullish(),
            pinnedHostPubkey: z.string().nullish(),
            controllerKeyRef: z.string().nullish()
        }).optional()
    }).optional(),
    capabilities: z.object({
        cradleServer: z.object({
            enabled: z.boolean().optional(),
            remoteHost: z.string().min(1).regex(/.*\S.*/).optional(),
            remotePort: z.union([
                z.string(),
                z.int().gte(1).lte(65535)
            ]).optional()
        }).optional()
    }).optional()
});

export const zDeleteRemoteHostsByHostIdPath = z.object({
    hostId: z.string().min(1)
});

export const zPatchRemoteHostsByHostIdBody = z.object({
    displayName: z.string().min(1).regex(/.*\S.*/).optional(),
    enabled: z.boolean().optional(),
    connectionConfig: z.object({
        transport: z.enum([
            'ssh',
            'direct-url',
            'relay'
        ]).optional(),
        baseUrl: z.string().min(1).regex(/.*\S.*/).optional(),
        ssh: z.object({
            hostName: z.string().min(1).regex(/.*\S.*/),
            user: z.string().nullish(),
            port: z.union([
                z.string(),
                z.int().gte(1).lte(65535)
            ]).nullish(),
            auth: z.enum(['default', 'identityFile']).optional(),
            identityFilePath: z.string().nullish()
        }).optional(),
        sshExecutable: z.string().min(1).regex(/.*\S.*/).optional(),
        sshArgs: z.array(z.string()).optional(),
        connectTimeoutMs: z.union([
            z.string(),
            z.int().gte(1).lte(120000)
        ]).optional(),
        relay: z.object({
            relayServerId: z.string().nullish(),
            relayUrl: z.string().nullish(),
            roomId: z.string().nullish(),
            pinnedHostPubkey: z.string().nullish(),
            controllerKeyRef: z.string().nullish()
        }).optional()
    }).optional(),
    capabilities: z.object({
        cradleServer: z.object({
            enabled: z.boolean().optional(),
            remoteHost: z.string().min(1).regex(/.*\S.*/).optional(),
            remotePort: z.union([
                z.string(),
                z.int().gte(1).lte(65535)
            ]).optional()
        }).optional()
    }).optional()
});

export const zPatchRemoteHostsByHostIdPath = z.object({
    hostId: z.string().min(1)
});

export const zPostRemoteHostsByHostIdCradleServerConnectPath = z.object({
    hostId: z.string().min(1)
});

export const zPostRemoteHostsByHostIdCradleServerDisconnectPath = z.object({
    hostId: z.string().min(1)
});

export const zGetRemoteHostsByHostIdCradleServerHealthPath = z.object({
    hostId: z.string().min(1)
});

export const zPostRemoteHostsByHostIdCradleServerTestPath = z.object({
    hostId: z.string().min(1)
});

export const zPostRemoteHostsByHostIdRelayClaimBody = z.object({
    pairingString: z.string().min(1).regex(/.*\S.*/)
});

export const zPostRemoteHostsByHostIdRelayClaimPath = z.object({
    hostId: z.string().min(1)
});

export const zAllRemoteHostsByHostIdUpstreamPath = z.object({
    hostId: z.string().min(1),
    '*': z.string()
});

export const zAllRemoteHostsByHostIdUpstream2Path = z.object({
    hostId: z.string().min(1),
    '*': z.string()
});

export const zAllRemoteHostsByHostIdUpstream3Path = z.object({
    hostId: z.string().min(1),
    '*': z.string()
});

export const zAllRemoteHostsByHostIdUpstream4Path = z.object({
    hostId: z.string().min(1),
    '*': z.string()
});

export const zAllRemoteHostsByHostIdUpstream5Path = z.object({
    hostId: z.string().min(1),
    '*': z.string()
});

export const zAllRemoteHostsByHostIdUpstream6Path = z.object({
    hostId: z.string().min(1),
    '*': z.string()
});

export const zAllRemoteHostsByHostIdUpstream7Path = z.object({
    hostId: z.string().min(1),
    '*': z.string()
});

export const zAllRemoteHostsByHostIdUpstream8Path = z.object({
    hostId: z.string().min(1),
    '*': z.string()
});

export const zGetExternalIssueSourcesBindingsQuery = z.object({
    workspaceId: z.string().optional(),
    sourceKey: z.string().optional()
});

export const zPostExternalIssueSourcesBySourceKeyBindingsBody = z.object({
    workspaceId: z.string().min(1),
    repositoryOwner: z.string().min(1),
    repositoryName: z.string().min(1),
    scheduleEnabled: z.boolean().optional(),
    refreshIntervalSeconds: z.number().optional(),
    refreshNow: z.boolean().optional()
});

export const zPostExternalIssueSourcesBySourceKeyBindingsPath = z.object({
    sourceKey: z.string().min(1)
});

export const zDeleteExternalIssueSourcesBindingsByBindingIdPath = z.object({
    bindingId: z.string().min(1)
});

export const zPatchExternalIssueSourcesBindingsByBindingIdBody = z.object({
    enabled: z.boolean().optional(),
    scheduleEnabled: z.boolean().optional(),
    refreshIntervalSeconds: z.number().optional()
});

export const zPatchExternalIssueSourcesBindingsByBindingIdPath = z.object({
    bindingId: z.string().min(1)
});

export const zPostExternalIssueSourcesBindingsByBindingIdRefreshBody = z.object({
    force: z.boolean().optional()
});

export const zPostExternalIssueSourcesBindingsByBindingIdRefreshPath = z.object({
    bindingId: z.string().min(1)
});

export const zPostExternalIssueSourcesBySourceKeyRefreshBody = z.object({
    workspaceId: z.string().min(1),
    force: z.boolean().optional()
});

export const zPostExternalIssueSourcesBySourceKeyRefreshPath = z.object({
    sourceKey: z.string().min(1)
});

export const zGetExternalIssueSourcesItemsQuery = z.object({
    workspaceId: z.string().optional(),
    sourceKey: z.string().optional(),
    syncStatus: z.enum([
        'active',
        'missing',
        'error'
    ]).optional()
});

export const zPatchExternalIssueSourcesItemsByIdBody = z.record(z.string(), z.unknown());

export const zPatchExternalIssueSourcesItemsByIdPath = z.object({
    id: z.string().min(1)
});

export const zPatchExternalIssueSourcesItemsByIdStatusBody = z.object({
    statusId: z.string().min(1)
});

export const zPatchExternalIssueSourcesItemsByIdStatusPath = z.object({
    id: z.string().min(1)
});

export const zGetGithubAuthDeviceLoginByLoginIdPath = z.object({
    loginId: z.string().min(1)
});

export const zPostGithubAuthDeviceLoginByLoginIdCancelPath = z.object({
    loginId: z.string().min(1)
});

export const zPostExternalProviderSourcesBySourceKeyRefreshPath = z.object({
    sourceKey: z.string().min(1)
});

export const zGetExternalProviderSourcesBySourceKeyRecordsByExternalRecordIdRuntimeTargetPath = z.object({
    sourceKey: z.string().min(1),
    externalRecordId: z.string().min(1)
});

export const zPatchExternalProviderSourcesBySourceKeyRecordsByExternalRecordIdRuntimeTargetBody = z.object({
    enabled: z.boolean()
});

export const zPatchExternalProviderSourcesBySourceKeyRecordsByExternalRecordIdRuntimeTargetPath = z.object({
    sourceKey: z.string().min(1),
    externalRecordId: z.string().min(1)
});

export const zPostExternalSessionImportScansBody = z.object({
    sourceHostId: z.string().min(1).optional(),
    sourceApps: z.array(z.enum(['claude', 'codex'])).optional(),
    limitPerSource: z.number().gte(1).lte(2000).optional()
});

export const zGetExternalSessionImportScansByScanIdPath = z.object({
    scanId: z.string().min(1)
});

export const zPostExternalSessionImportImportsBody = z.object({
    scanId: z.string().min(1),
    candidateIds: z.array(z.string().min(1)).min(1)
});

export const zPostExternalSessionImportImportsByImportIdSyncBody = z.object({
    scanId: z.string().min(1),
    candidateId: z.string().min(1)
});

export const zPostExternalSessionImportImportsByImportIdSyncPath = z.object({
    importId: z.string().min(1)
});

export const zPostSecretsBody = z.object({
    kind: z.string().min(1),
    label: z.string().min(1),
    secret: z.string().min(1)
});

export const zPostSecretsByIdRevealPath = z.object({
    id: z.string().min(1)
});

export const zDeleteSecretsByIdPath = z.object({
    id: z.string().min(1)
});

export const zDeleteModelRegistryMappingsByModelIdPath = z.object({
    modelId: z.string().min(1)
});

export const zPutModelRegistryMappingsByModelIdBody = z.object({
    registryModelId: z.string().min(1).optional(),
    matchType: z.enum(['manual', 'alias']).optional(),
    model: z.object({
        id: z.string().min(1),
        name: z.string().optional(),
        limit: z.object({
            context: z.number().optional(),
            output: z.number().optional()
        }).optional(),
        modalities: z.object({
            input: z.array(z.string()).optional(),
            output: z.array(z.string()).optional()
        }).optional(),
        reasoning: z.boolean().optional(),
        tool_call: z.boolean().optional(),
        temperature: z.boolean().optional(),
        structured_output: z.boolean().optional(),
        cost: z.object({
            input: z.number().optional(),
            output: z.number().optional(),
            cache_read: z.number().optional(),
            cache_write: z.number().optional()
        }).optional(),
        family: z.string().optional(),
        knowledge: z.string().optional(),
        release_date: z.string().optional()
    }).optional()
});

export const zPutModelRegistryMappingsByModelIdPath = z.object({
    modelId: z.string().min(1)
});

export const zGetMcpServersRegistryServersQuery = z.object({
    search: z.string().optional(),
    cursor: z.string().optional()
});

export const zPostMcpServersBody = z.union([
    z.object({
        transport: z.enum(['stdio']),
        name: z.string().min(1).max(64).regex(/^[A-Za-z0-9][A-Za-z0-9._-]*$/),
        enabled: z.boolean().default(true),
        command: z.string().min(1),
        args: z.array(z.string()),
        secretValues: z.record(z.string(), z.unknown()).optional()
    }),
    z.object({
        transport: z.enum(['streamable-http']),
        name: z.string().min(1).max(64).regex(/^[A-Za-z0-9][A-Za-z0-9._-]*$/),
        enabled: z.boolean().default(true),
        url: z.url().min(1),
        secretValues: z.record(z.string(), z.unknown()).optional()
    })
]);

export const zDeleteMcpServersByIdPath = z.object({
    id: z.string().min(1)
});

export const zPutMcpServersByIdBody = z.union([
    z.object({
        transport: z.enum(['stdio']),
        name: z.string().min(1).max(64).regex(/^[A-Za-z0-9][A-Za-z0-9._-]*$/),
        enabled: z.boolean().default(true),
        command: z.string().min(1),
        args: z.array(z.string()),
        secretValues: z.record(z.string(), z.unknown()).optional()
    }),
    z.object({
        transport: z.enum(['streamable-http']),
        name: z.string().min(1).max(64).regex(/^[A-Za-z0-9][A-Za-z0-9._-]*$/),
        enabled: z.boolean().default(true),
        url: z.url().min(1),
        secretValues: z.record(z.string(), z.unknown()).optional()
    })
]);

export const zPutMcpServersByIdPath = z.object({
    id: z.string().min(1)
});

export const zPatchMcpServersByIdEnabledBody = z.object({
    enabled: z.boolean()
});

export const zPatchMcpServersByIdEnabledPath = z.object({
    id: z.string().min(1)
});

export const zPostProvidersModelsBody = z.object({
    providerKind: z.enum([
        'openai-compatible',
        'anthropic',
        'universal'
    ]),
    label: z.string().min(1),
    config: z.record(z.string(), z.unknown()),
    secretRef: z.string().min(1).nullish(),
    profileId: z.string().min(1).nullish(),
    providerTargetKind: z.enum(['manual', 'external']).nullish(),
    providerTargetId: z.string().min(1).nullish(),
    workspaceId: z.string().min(1).nullish()
});

export const zGetProvidersTargetsByProviderTargetIdModelsCachePath = z.object({
    providerTargetId: z.string().min(1)
});

export const zGetProvidersByProfileIdModelsCachePath = z.object({
    profileId: z.string().min(1)
});

export const zPostProvidersModelLookupBody = z.object({
    modelId: z.string().min(1)
});

export const zPostProvidersModelSearchBody = z.object({
    query: z.string().min(1)
});

export const zGetAgentsQuery = z.object({
    enabled: z.string().optional(),
    providerTargetId: z.string().optional()
});

export const zPostAgentsBody = z.object({
    name: z.string().min(1),
    description: z.string().nullish(),
    avatarStyle: z.string().min(1),
    avatarSeed: z.string().min(1),
    providerTargetId: z.string().nullish(),
    modelId: z.string().nullish(),
    thinkingEffort: z.enum([
        'none',
        'minimal',
        'low',
        'medium',
        'high',
        'xhigh',
        'max',
        'ultra'
    ]).optional(),
    runtimeKind: z.string().min(1).optional(),
    configJson: z.string().optional()
});

export const zDeleteAgentsByIdPath = z.object({
    id: z.string().min(1)
});

export const zGetAgentsByIdPath = z.object({
    id: z.string().min(1)
});

export const zPatchAgentsByIdBody = z.object({
    name: z.string().min(1).optional(),
    description: z.string().nullish(),
    avatarStyle: z.string().min(1).optional(),
    avatarSeed: z.string().min(1).optional(),
    providerTargetId: z.string().nullish(),
    modelId: z.string().nullish(),
    thinkingEffort: z.enum([
        'none',
        'minimal',
        'low',
        'medium',
        'high',
        'xhigh',
        'max',
        'ultra'
    ]).optional(),
    runtimeKind: z.string().min(1).optional(),
    configJson: z.string().optional(),
    enabled: z.boolean().optional()
});

export const zPatchAgentsByIdPath = z.object({
    id: z.string().min(1)
});

export const zPostAgentsImportLocalConfigBody = z.object({
    includeProcessEnv: z.boolean().optional(),
    candidateIds: z.array(z.string().min(1)).optional()
});

export const zPostAgentsImportLocalConfigPreviewBody = z.object({
    includeProcessEnv: z.boolean().optional(),
    candidateIds: z.array(z.string().min(1)).optional()
});

export const zGetAutomationsQuery = z.object({
    workspaceId: z.string().min(1).optional(),
    enabled: z.boolean().optional()
});

export const zPostAutomationsBody = z.object({
    id: z.string().min(1).optional(),
    workspaceId: z.string().min(1).nullish(),
    title: z.string().min(1),
    description: z.string().optional(),
    enabled: z.boolean().optional(),
    trigger: z.object({
        type: z.enum(['rrule']),
        rrule: z.string().min(1),
        timezone: z.string().min(1),
        misfirePolicy: z.enum(['skip', 'run_latest']).optional()
    }),
    recipe: z.object({
        kind: z.enum(['agent_task']),
        prompt: z.string().min(1),
        inputs: z.array(z.union([
            z.object({
                type: z.enum(['file_ref']),
                path: z.string().min(1)
            }),
            z.object({
                type: z.enum(['inline_file']),
                name: z.string().min(1),
                content: z.string()
            }),
            z.object({
                type: z.enum(['text']),
                name: z.string().min(1),
                content: z.string()
            }),
            z.object({
                type: z.enum(['url']),
                url: z.string().min(1)
            })
        ])),
        artifactRequests: z.array(z.object({
            kind: z.enum([
                'markdown',
                'text',
                'json',
                'file_ref'
            ]),
            name: z.string().min(1),
            description: z.string().optional()
        })),
        agentId: z.string().min(1).optional(),
        providerTargetId: z.string().min(1).optional(),
        runtimeKind: z.string().min(1).optional(),
        modelId: z.string().min(1).optional(),
        thinkingEffort: z.enum([
            'none',
            'minimal',
            'low',
            'medium',
            'high',
            'xhigh',
            'max',
            'ultra'
        ]).optional(),
        sessionPolicy: z.enum(['new', 'heartbeat']).optional(),
        isolationPolicy: z.enum(['workspace', 'worktree_per_run']).optional(),
        completionPolicy: z.object({
            stopWhen: z.enum(['agent_complete']).optional(),
            noFindingsBehavior: z.enum(['archive', 'triage']).optional()
        }).optional()
    }),
    createdByKind: z.enum([
        'agent',
        'user',
        'system'
    ]).optional(),
    createdById: z.string().min(1).nullish()
});

export const zDeleteAutomationsByIdPath = z.object({
    id: z.string().min(1)
});

export const zGetAutomationsByIdPath = z.object({
    id: z.string().min(1)
});

export const zPatchAutomationsByIdBody = z.object({
    title: z.string().min(1).optional(),
    description: z.string().optional(),
    trigger: z.object({
        type: z.enum(['rrule']),
        rrule: z.string().min(1),
        timezone: z.string().min(1),
        misfirePolicy: z.enum(['skip', 'run_latest']).optional()
    }).optional(),
    recipe: z.object({
        kind: z.enum(['agent_task']),
        prompt: z.string().min(1),
        inputs: z.array(z.union([
            z.object({
                type: z.enum(['file_ref']),
                path: z.string().min(1)
            }),
            z.object({
                type: z.enum(['inline_file']),
                name: z.string().min(1),
                content: z.string()
            }),
            z.object({
                type: z.enum(['text']),
                name: z.string().min(1),
                content: z.string()
            }),
            z.object({
                type: z.enum(['url']),
                url: z.string().min(1)
            })
        ])),
        artifactRequests: z.array(z.object({
            kind: z.enum([
                'markdown',
                'text',
                'json',
                'file_ref'
            ]),
            name: z.string().min(1),
            description: z.string().optional()
        })),
        agentId: z.string().min(1).optional(),
        providerTargetId: z.string().min(1).optional(),
        runtimeKind: z.string().min(1).optional(),
        modelId: z.string().min(1).optional(),
        thinkingEffort: z.enum([
            'none',
            'minimal',
            'low',
            'medium',
            'high',
            'xhigh',
            'max',
            'ultra'
        ]).optional(),
        sessionPolicy: z.enum(['new', 'heartbeat']).optional(),
        isolationPolicy: z.enum(['workspace', 'worktree_per_run']).optional(),
        completionPolicy: z.object({
            stopWhen: z.enum(['agent_complete']).optional(),
            noFindingsBehavior: z.enum(['archive', 'triage']).optional()
        }).optional()
    }).optional(),
    createdByKind: z.enum([
        'agent',
        'user',
        'system'
    ]).optional(),
    createdById: z.string().min(1).nullish()
});

export const zPatchAutomationsByIdPath = z.object({
    id: z.string().min(1)
});

export const zPostAutomationsByIdEnablePath = z.object({
    id: z.string().min(1)
});

export const zPostAutomationsByIdDisablePath = z.object({
    id: z.string().min(1)
});

export const zPostAutomationsByIdRunBody = z.object({
    occurrenceKey: z.string().min(1).optional(),
    scheduledFor: z.number().optional()
});

export const zPostAutomationsByIdRunPath = z.object({
    id: z.string().min(1)
});

export const zGetAutomationsByIdRunsPath = z.object({
    id: z.string().min(1)
});

export const zGetAutomationsByIdRunsByRunIdPath = z.object({
    id: z.string().min(1),
    runId: z.string().min(1)
});

export const zPostAutomationsByIdRunsByRunIdStopPath = z.object({
    id: z.string().min(1),
    runId: z.string().min(1)
});

export const zPatchAutomationsByIdRunsByRunIdTriageBody = z.object({
    status: z.enum([
        'unread',
        'read',
        'resolved',
        'archived'
    ])
});

export const zPatchAutomationsByIdRunsByRunIdTriagePath = z.object({
    id: z.string().min(1),
    runId: z.string().min(1)
});

export const zGetAutomationsByIdRunsByRunIdArtifactsPath = z.object({
    id: z.string().min(1),
    runId: z.string().min(1)
});

export const zGetAutomationsByIdArtifactsPath = z.object({
    id: z.string().min(1)
});

export const zGetAutomationsByIdArtifactsByArtifactIdPath = z.object({
    id: z.string().min(1),
    artifactId: z.string().min(1)
});

export const zGetAutomationTriageQuery = z.object({
    workspaceId: z.string().min(1).optional(),
    status: z.enum([
        'unread',
        'read',
        'resolved',
        'archived',
        'all'
    ]).optional()
});

export const zGetCronJobsQuery = z.object({
    workspaceId: z.string().min(1).optional(),
    enabled: z.boolean().optional()
});

export const zPostCronJobsBody = z.object({
    id: z.string().min(1),
    workspaceId: z.string().min(1).nullish(),
    title: z.string().min(1),
    description: z.string().optional(),
    enabled: z.boolean().optional(),
    scheduleKind: z.enum(['rrule']),
    scheduleConfig: z.string().min(1),
    timezone: z.string().min(1),
    prompt: z.string().min(1),
    providerTargetId: z.string().min(1).optional(),
    modelId: z.string().min(1).optional()
});

export const zDeleteCronJobsByIdPath = z.object({
    id: z.string().min(1)
});

export const zGetCronJobsByIdPath = z.object({
    id: z.string().min(1)
});

export const zPutCronJobsByIdBody = z.object({
    title: z.string().min(1).optional(),
    description: z.string().optional(),
    enabled: z.boolean().optional(),
    scheduleKind: z.enum(['rrule']).optional(),
    scheduleConfig: z.string().min(1).optional(),
    timezone: z.string().min(1).optional(),
    prompt: z.string().min(1).optional(),
    providerTargetId: z.string().min(1).optional(),
    modelId: z.string().min(1).optional()
});

export const zPutCronJobsByIdPath = z.object({
    id: z.string().min(1)
});

export const zGetCronRunsQuery = z.object({
    jobId: z.string().min(1)
});

export const zDeleteAssetsByIdPath = z.object({
    id: z.string().min(1)
});

export const zGetAssetsByIdPath = z.object({
    id: z.string().min(1)
});

export const zGetAssetsByIdContentPath = z.object({
    id: z.string().min(1)
});

export const zGetBlobsByIdPath = z.object({
    id: z.string().min(1)
});

export const zPostBackgroundActivitiesByOwnerNamespaceByKeyRunPath = z.object({
    ownerNamespace: z.string().min(1),
    key: z.string().min(1)
});

export const zGetBackgroundJobsQuery = z.object({
    workspaceId: z.string().min(1).optional(),
    ownerNamespace: z.string().min(1).optional(),
    ownerResourceType: z.string().min(1).optional(),
    ownerResourceId: z.string().min(1).optional(),
    ownerResourceKey: z.string().min(1).optional(),
    kind: z.string().min(1).optional(),
    status: z.enum([
        'pending',
        'running',
        'succeeded',
        'failed',
        'cancelled'
    ]).optional(),
    limit: z.number().gte(1).lte(200).optional()
});

export const zGetBackgroundJobsByIdPath = z.object({
    id: z.string().min(1)
});

export const zPostBackgroundJobsByIdCancelPath = z.object({
    id: z.string().min(1)
});

export const zGetSessionsQuery = z.object({
    workspaceId: z.string().min(1).optional(),
    origin: z.string().min(1).optional(),
    sessionGroupId: z.string().min(1).optional(),
    archived: z.boolean().optional()
});

export const zPostSessionsBody = z.object({
    workspaceId: z.string().min(1).nullish(),
    title: z.string().min(1),
    origin: z.string().min(1).optional(),
    providerTargetId: z.string().min(1).optional(),
    modelId: z.string().min(1).nullish(),
    agentId: z.string().min(1).optional(),
    acpAgentId: z.string().min(1).optional(),
    acpDraftSessionId: z.string().min(1).optional(),
    runtimeKind: z.string().min(1).optional(),
    runtimeSettings: z.object({
        permissionMode: z.enum([
            'default',
            'acceptEdits',
            'bypassPermissions',
            'plan'
        ]).nullish(),
        accessMode: z.enum(['approval-required', 'full-access']).nullish(),
        interactionMode: z.enum(['default', 'plan']).nullish(),
        claudeAgent: z.object({
            modelAliases: z.object({
                haiku: z.string().optional(),
                sonnet: z.string().optional(),
                opus: z.string().optional()
            }).optional()
        }).nullish()
    }).optional(),
    thinkingEffort: z.enum([
        'none',
        'minimal',
        'low',
        'medium',
        'high',
        'xhigh',
        'max',
        'ultra'
    ]).optional(),
    linkedIssueId: z.string().min(1).nullish(),
    sessionGroupId: z.string().min(1).nullish(),
    worktreeId: z.string().min(1).optional(),
    id: z.string().optional()
});

export const zDeleteSessionsByIdPath = z.object({
    id: z.string().min(1)
});

export const zGetSessionsByIdPath = z.object({
    id: z.string().min(1)
});

export const zPatchSessionsByIdBody = z.object({
    title: z.string().min(1).optional(),
    pinned: z.boolean().optional(),
    providerTargetId: z.string().min(1).optional(),
    modelId: z.string().min(1).nullish(),
    thinkingEffort: z.enum([
        'none',
        'minimal',
        'low',
        'medium',
        'high',
        'xhigh',
        'max',
        'ultra'
    ]).nullish(),
    sessionGroupId: z.string().min(1).nullish()
});

export const zPatchSessionsByIdPath = z.object({
    id: z.string().min(1)
});

export const zPostSessionsByIdArchiveBody = z.object({
    archived: z.boolean()
});

export const zPostSessionsByIdArchivePath = z.object({
    id: z.string().min(1)
});

export const zPostSessionsByIdReadPath = z.object({
    id: z.string().min(1)
});

export const zPostSessionsByIdUnreadPath = z.object({
    id: z.string().min(1)
});

export const zGetSessionsByIdExportMarkdownPath = z.object({
    id: z.string().min(1)
});

export const zGetSessionsByIdExportZipPath = z.object({
    id: z.string().min(1)
});

export const zDeleteSessionsByIdLinkedIssuePath = z.object({
    id: z.string().min(1)
});

export const zGetSessionsByIdLinkedIssuePath = z.object({
    id: z.string().min(1)
});

export const zPostSessionsByIdLinkedIssueBody = z.object({
    issueId: z.string().min(1)
});

export const zPostSessionsByIdLinkedIssuePath = z.object({
    id: z.string().min(1)
});

export const zPostSessionsByIdIsolationStartBody = z.object({
    slug: z.string().min(1).optional()
});

export const zPostSessionsByIdIsolationStartPath = z.object({
    id: z.string().min(1)
});

export const zPostSessionsByIdIsolationActivateBody = z.object({
    mode: z.enum([
        'migrate',
        'leave-main',
        'cancel'
    ])
});

export const zPostSessionsByIdIsolationActivatePath = z.object({
    id: z.string().min(1)
});

export const zPostSessionsByIdIsolationCancelPath = z.object({
    id: z.string().min(1)
});

export const zPostSessionsByIdIsolationLeavePath = z.object({
    id: z.string().min(1)
});

export const zPostSessionsByIdIsolationRepairPath = z.object({
    id: z.string().min(1)
});

export const zPostSessionsByIdIsolationAttachBody = z.object({
    worktreeId: z.string().min(1)
});

export const zPostSessionsByIdIsolationAttachPath = z.object({
    id: z.string().min(1)
});

export const zGetSessionsByIdIsolationPath = z.object({
    id: z.string().min(1)
});

export const zGetSessionsByIdEnvironmentPath = z.object({
    id: z.string().min(1)
});

export const zPutSessionsByIdEnvironmentNotesBody = z.object({
    notes: z.string().max(16000)
});

export const zPutSessionsByIdEnvironmentNotesPath = z.object({
    id: z.string().min(1)
});

export const zDeleteSessionsByIdEnvironmentPinsByMessageIdPath = z.object({
    id: z.string().min(1),
    messageId: z.string().min(1)
});

export const zPatchSessionsByIdEnvironmentPinsByMessageIdBody = z.object({
    label: z.string().max(120).nullish(),
    done: z.boolean().optional()
});

export const zPatchSessionsByIdEnvironmentPinsByMessageIdPath = z.object({
    id: z.string().min(1),
    messageId: z.string().min(1)
});

export const zPostSessionsByIdEnvironmentPinsByMessageIdPath = z.object({
    id: z.string().min(1),
    messageId: z.string().min(1)
});

export const zPostSessionsByIdEnvironmentMarkersBody = z.object({
    messageId: z.string().min(1),
    startOffset: z.number().gte(0),
    endOffset: z.number().gte(1),
    selectedText: z.string().min(1).max(2000),
    style: z.enum(['highlight', 'underline']),
    color: z.enum([
        'yellow',
        'blue',
        'green',
        'pink'
    ])
});

export const zPostSessionsByIdEnvironmentMarkersPath = z.object({
    id: z.string().min(1)
});

export const zDeleteSessionsByIdEnvironmentMarkersByMarkerIdPath = z.object({
    id: z.string().min(1),
    markerId: z.string().min(1)
});

export const zPatchSessionsByIdEnvironmentMarkersByMarkerIdBody = z.object({
    label: z.string().max(120).nullish(),
    done: z.boolean().optional()
});

export const zPatchSessionsByIdEnvironmentMarkersByMarkerIdPath = z.object({
    id: z.string().min(1),
    markerId: z.string().min(1)
});

export const zPostThreadHandoffsBody = z.object({
    requestId: z.string().min(1),
    sourceSessionId: z.string().min(1),
    destinationRuntimeKind: z.string().min(1),
    destinationProviderTargetId: z.string().min(1).nullish(),
    modelId: z.string().min(1).nullish(),
    thinkingEffort: z.enum([
        'none',
        'minimal',
        'low',
        'medium',
        'high',
        'xhigh',
        'max',
        'ultra'
    ]).nullish()
});

export const zGetThreadHandoffsDestinationBySessionIdPath = z.object({
    sessionId: z.string().min(1)
});

export const zGetSessionsByIdTurnCheckpointsPath = z.object({
    id: z.string().min(1)
});

export const zPostSessionsByIdTurnCheckpointsByCheckpointIdRestorePath = z.object({
    id: z.string().min(1),
    checkpointId: z.string().min(1)
});

export const zPostSessionsByIdTurnCheckpointsByCheckpointIdRewindPath = z.object({
    id: z.string().min(1),
    checkpointId: z.string().min(1)
});

export const zGetWorksQuery = z.object({
    workspaceId: z.string().min(1).optional(),
    linkedIssueId: z.string().min(1).optional(),
    archived: z.boolean().optional()
});

export const zPostWorksBody = z.object({
    workspaceId: z.string().min(1),
    title: z.string().min(1),
    goal: z.string().min(1).optional(),
    objective: z.string().min(1).optional(),
    linkedIssueId: z.string().min(1).optional(),
    baseBranch: z.string().min(1).optional(),
    providerTargetId: z.string().min(1).optional(),
    modelId: z.string().min(1).nullish(),
    thinkingEffort: z.enum([
        'none',
        'minimal',
        'low',
        'medium',
        'high',
        'xhigh',
        'max',
        'ultra'
    ]).optional(),
    runtimeKind: z.string().min(1).optional(),
    runtimeSettings: z.object({
        permissionMode: z.enum([
            'default',
            'acceptEdits',
            'bypassPermissions',
            'plan'
        ]).nullish(),
        accessMode: z.enum(['approval-required', 'full-access']).nullish(),
        interactionMode: z.enum(['default', 'plan']).nullish(),
        claudeAgent: z.object({
            modelAliases: z.object({
                haiku: z.string().optional(),
                sonnet: z.string().optional(),
                opus: z.string().optional()
            }).optional()
        }).nullish()
    }).optional(),
    agentId: z.string().min(1).optional()
});

export const zGetWorksByIdPath = z.object({
    id: z.string().min(1)
});

export const zPostWorksByIdArchiveBody = z.object({
    archived: z.boolean()
});

export const zPostWorksByIdArchivePath = z.object({
    id: z.string().min(1)
});

export const zPostWorksByIdPrepareBody = z.object({
    title: z.string().min(1),
    summary: z.string().min(1),
    testPlan: z.string().min(1)
});

export const zPostWorksByIdPreparePath = z.object({
    id: z.string().min(1)
});

export const zPostWorksByIdSubmitBody = z.object({
    title: z.string().min(1).optional(),
    summary: z.string().min(1).optional(),
    testPlan: z.string().min(1).optional(),
    base: z.string().min(1).optional()
});

export const zPostWorksByIdSubmitPath = z.object({
    id: z.string().min(1)
});

export const zPostWorksByIdBranchBody = z.object({
    branch: z.string().min(1)
});

export const zPostWorksByIdBranchPath = z.object({
    id: z.string().min(1)
});

export const zGetSessionsByIdWorkPath = z.object({
    id: z.string().min(1)
});

export const zGetSessionsByIdPullRequestPath = z.object({
    id: z.string().min(1)
});

export const zPostSessionsByIdPullRequestBody = z.object({
    title: z.string().min(1),
    body: z.string().optional(),
    base: z.string().min(1).optional()
});

export const zPostSessionsByIdPullRequestPath = z.object({
    id: z.string().min(1)
});

export const zGetSessionsByIdPullRequestDetailPath = z.object({
    id: z.string().min(1)
});

export const zPostSessionsByIdPullRequestReadyPath = z.object({
    id: z.string().min(1)
});

export const zGetPullRequestsAuthoredQuery = z.object({
    login: z.string().min(1),
    after: z.string().optional()
});

export const zGetPullRequestsReviewingQuery = z.object({
    login: z.string().min(1),
    after: z.string().optional()
});

export const zGetPullRequestsByOwnerByRepoAssignableUsersPath = z.object({
    owner: z.string().min(1),
    repo: z.string().min(1)
});

export const zGetPullRequestsByOwnerByRepoByNumberDetailPath = z.object({
    owner: z.string().min(1),
    repo: z.string().min(1),
    number: z.string().min(1)
});

export const zGetPullRequestsByOwnerByRepoByNumberFingerprintPath = z.object({
    owner: z.string().min(1),
    repo: z.string().min(1),
    number: z.string().min(1)
});

export const zPostPullRequestsByOwnerByRepoByNumberFingerprintProbeBody = z.object({
    previous: z.object({
        updatedAt: z.string(),
        headSha: z.string(),
        state: z.enum(['open', 'closed']),
        merged: z.boolean(),
        isDraft: z.boolean(),
        mergeableState: z.string(),
        comments: z.number(),
        reviewComments: z.number(),
        commits: z.number(),
        checksState: z.enum([
            'success',
            'failure',
            'pending',
            'neutral'
        ])
    }).nullish()
});

export const zPostPullRequestsByOwnerByRepoByNumberFingerprintProbePath = z.object({
    owner: z.string().min(1),
    repo: z.string().min(1),
    number: z.string().min(1)
});

export const zPostPullRequestsByOwnerByRepoByNumberCommentBody = z.object({
    body: z.string().min(1)
});

export const zPostPullRequestsByOwnerByRepoByNumberCommentPath = z.object({
    owner: z.string().min(1),
    repo: z.string().min(1),
    number: z.string().min(1)
});

export const zPostPullRequestsByOwnerByRepoByNumberReviewBody = z.object({
    event: z.enum([
        'APPROVE',
        'REQUEST_CHANGES',
        'COMMENT'
    ]),
    body: z.string().optional()
});

export const zPostPullRequestsByOwnerByRepoByNumberReviewPath = z.object({
    owner: z.string().min(1),
    repo: z.string().min(1),
    number: z.string().min(1)
});

export const zPostPullRequestsByOwnerByRepoByNumberMergeBody = z.object({
    mergeMethod: z.enum([
        'merge',
        'squash',
        'rebase'
    ]),
    commitTitle: z.string().min(1).optional(),
    commitMessage: z.string().optional()
});

export const zPostPullRequestsByOwnerByRepoByNumberMergePath = z.object({
    owner: z.string().min(1),
    repo: z.string().min(1),
    number: z.string().min(1)
});

export const zPostPullRequestsByOwnerByRepoByNumberAssigneesBody = z.object({
    add: z.array(z.string().min(1)).optional(),
    remove: z.array(z.string().min(1)).optional()
});

export const zPostPullRequestsByOwnerByRepoByNumberAssigneesPath = z.object({
    owner: z.string().min(1),
    repo: z.string().min(1),
    number: z.string().min(1)
});

export const zPostPullRequestsByOwnerByRepoByNumberReviewersBody = z.object({
    add: z.array(z.string().min(1)).optional(),
    remove: z.array(z.string().min(1)).optional()
});

export const zPostPullRequestsByOwnerByRepoByNumberReviewersPath = z.object({
    owner: z.string().min(1),
    repo: z.string().min(1),
    number: z.string().min(1)
});

export const zPostPullRequestsByOwnerByRepoByNumberReadyPath = z.object({
    owner: z.string().min(1),
    repo: z.string().min(1),
    number: z.string().min(1)
});

export const zPostPullRequestsByOwnerByRepoByNumberDraftPath = z.object({
    owner: z.string().min(1),
    repo: z.string().min(1),
    number: z.string().min(1)
});

export const zGetSessionGroupsQuery = z.object({
    workspaceId: z.string().min(1).optional(),
    linkedIssueId: z.string().min(1).optional(),
    archived: z.boolean().optional()
});

export const zPostSessionGroupsBody = z.object({
    workspaceId: z.string().min(1),
    title: z.string().min(1),
    description: z.string().min(1).nullish(),
    linkedIssueId: z.string().min(1).nullish(),
    sessionIds: z.array(z.string().min(1)).optional()
});

export const zDeleteSessionGroupsByIdPath = z.object({
    id: z.string().min(1)
});

export const zGetSessionGroupsByIdPath = z.object({
    id: z.string().min(1)
});

export const zPatchSessionGroupsByIdBody = z.object({
    title: z.string().min(1).optional(),
    description: z.string().min(1).nullish(),
    linkedIssueId: z.string().min(1).nullish(),
    archived: z.boolean().optional()
});

export const zPatchSessionGroupsByIdPath = z.object({
    id: z.string().min(1)
});

export const zPostSessionGroupsByIdMembersBody = z.object({
    sessionIds: z.array(z.string().min(1)).min(1)
});

export const zPostSessionGroupsByIdMembersPath = z.object({
    id: z.string().min(1)
});

export const zDeleteSessionGroupsByIdMembersBySessionIdPath = z.object({
    id: z.string().min(1),
    sessionId: z.string().min(1)
});

export const zGetSessionAwaitsQuery = z.object({
    sessionId: z.string().min(1)
});

export const zPostSessionAwaitsBody = z.object({
    chatSessionId: z.string().min(1),
    workspaceId: z.string().min(1),
    source: z.string().min(1),
    filterJson: z.string().min(1),
    reason: z.string().nullish(),
    expiresAt: z.number().nullish(),
    fireAt: z.number().nullish()
});

export const zGetSessionAwaitsByIdPath = z.object({
    id: z.string().min(1)
});

export const zPostSessionAwaitsByIdCancelPath = z.object({
    id: z.string().min(1)
});

export const zPostSessionAwaitsByIdTriggerBody = z.object({
    resumeText: z.string().min(1).regex(/.*\S.*/),
    resumePayloadJson: z.string().nullish()
});

export const zPostSessionAwaitsByIdTriggerPath = z.object({
    id: z.string().min(1)
});

export const zPostSessionAwaitsByIdRetryDeliveryBody = z.object({
    resumeText: z.string().min(1).regex(/.*\S.*/).optional(),
    resumePayloadJson: z.string().nullish()
});

export const zPostSessionAwaitsByIdRetryDeliveryPath = z.object({
    id: z.string().min(1)
});

export const zGetSessionAwaitsSummaryQuery = z.object({
    sessionId: z.string().min(1)
});

export const zGetSessionAwaitsDiscoveredReposQuery = z.object({
    workspaceId: z.string().min(1)
});

export const zGetSessionAwaitsAvailableChecksQuery = z.object({
    owner: z.string().min(1),
    repo: z.string().min(1)
});

export const zPostSessionAwaitsByIdBypassCheckBody = z.object({
    checkName: z.string().min(1)
});

export const zPostSessionAwaitsByIdBypassCheckPath = z.object({
    id: z.string().min(1)
});

export const zPostSessionAwaitsByIdEvaluateNowPath = z.object({
    id: z.string().min(1)
});

export const zGetSessionAwaitsByIdLiveStatusPath = z.object({
    id: z.string().min(1)
});

export const zGetSessionAwaitsBypassRulesQuery = z.object({
    workspaceId: z.string().min(1)
});

export const zPostSessionAwaitsBypassRulesBody = z.object({
    workspaceId: z.string().min(1),
    repo: z.string().min(1),
    checkPattern: z.string().min(1)
});

export const zDeleteSessionAwaitsBypassRulesByIdPath = z.object({
    id: z.string().min(1)
});

export const zPatchSessionAwaitsBypassRulesByIdBody = z.object({
    enabled: z.boolean()
});

export const zPatchSessionAwaitsBypassRulesByIdPath = z.object({
    id: z.string().min(1)
});

export const zPostJavascriptEvaluateBody = z.object({
    program: z.string().min(1),
    timeoutMs: z.number().optional(),
    cwd: z.string().optional()
});

export const zGetIssuesStatusesQuery = z.object({
    workspaceId: z.string().min(1).optional()
});

export const zPostIssuesStatusesBody = z.object({
    workspaceId: z.string().min(1),
    name: z.string().min(1),
    color: z.string().nullish(),
    category: z.enum([
        'triage',
        'backlog',
        'unstarted',
        'started',
        'completed',
        'canceled'
    ]).optional()
});

export const zPostIssuesStatusesReorderBody = z.object({
    workspaceId: z.string().min(1),
    orderedIds: z.array(z.string())
});

export const zDeleteIssuesStatusesByIdPath = z.object({
    id: z.string().min(1)
});

export const zPatchIssuesStatusesByIdBody = z.object({
    name: z.string().min(1).optional(),
    color: z.string().nullish()
});

export const zPatchIssuesStatusesByIdPath = z.object({
    id: z.string().min(1)
});

export const zGetIssuesMilestonesQuery = z.object({
    workspaceId: z.string().min(1).optional()
});

export const zPostIssuesMilestonesBody = z.object({
    workspaceId: z.string().min(1),
    title: z.string().min(1),
    description: z.string().nullish(),
    dueDate: z.number().nullish(),
    status: z.enum(['open', 'closed']).optional()
});

export const zDeleteIssuesMilestonesByIdPath = z.object({
    id: z.string().min(1)
});

export const zPatchIssuesMilestonesByIdBody = z.object({
    title: z.string().min(1).optional(),
    description: z.string().nullish(),
    dueDate: z.number().nullish(),
    status: z.enum(['open', 'closed']).optional()
});

export const zPatchIssuesMilestonesByIdPath = z.object({
    id: z.string().min(1)
});

export const zGetIssuesSearchQuery = z.object({
    q: z.string(),
    limit: z.string().optional()
});

export const zGetIssuesQuery = z.object({
    workspaceId: z.string().min(1).optional(),
    milestoneId: z.string().optional(),
    parentIssueId: z.string().optional(),
    priority: z.string().optional(),
    labels: z.union([
        z.array(z.string()),
        z.string()
    ]).optional(),
    statusId: z.string().optional()
});

export const zPostIssuesBody = z.object({
    workspaceId: z.string().min(1),
    title: z.string().min(1),
    description: z.string().nullish(),
    priority: z.enum([
        'none',
        'low',
        'medium',
        'high',
        'urgent'
    ]).optional(),
    labels: z.array(z.string()).optional(),
    milestoneId: z.string().nullish(),
    parentIssueId: z.string().nullish(),
    statusId: z.string().nullish(),
    statusName: z.string().min(1).nullish(),
    dueDate: z.number().nullish(),
    assigneeKind: z.string().nullish(),
    assigneeId: z.string().nullish()
});

export const zPostIssuesReorderBody = z.object({
    workspaceId: z.string().min(1),
    orderedIds: z.array(z.string()),
    patch: z.object({
        issueIds: z.array(z.string()),
        fields: z.object({
            priority: z.enum([
                'none',
                'low',
                'medium',
                'high',
                'urgent'
            ]).optional(),
            milestoneId: z.string().nullish(),
            statusId: z.string().nullish(),
            assigneeKind: z.string().nullish(),
            assigneeId: z.string().nullish()
        })
    }).optional()
});

export const zDeleteIssuesByIdPath = z.object({
    id: z.string().min(1)
});

export const zGetIssuesByIdPath = z.object({
    id: z.string().min(1)
});

export const zPatchIssuesByIdBody = z.object({
    workspaceId: z.string().min(1).optional(),
    title: z.string().min(1).optional(),
    description: z.string().nullish(),
    priority: z.enum([
        'none',
        'low',
        'medium',
        'high',
        'urgent'
    ]).optional(),
    labels: z.array(z.string()).optional(),
    milestoneId: z.string().nullish(),
    parentIssueId: z.string().nullish(),
    statusId: z.string().nullish(),
    statusName: z.string().min(1).nullish(),
    assigneeKind: z.string().nullish(),
    assigneeId: z.string().nullish(),
    dueDate: z.number().nullish(),
    order: z.number().optional()
});

export const zPatchIssuesByIdPath = z.object({
    id: z.string().min(1)
});

export const zGetIssuesByIdSessionsPath = z.object({
    id: z.string().min(1)
});

export const zGetIssuesByIdSessionGroupsPath = z.object({
    id: z.string().min(1)
});

export const zGetIssuesByIdIsolationContextPath = z.object({
    id: z.string().min(1)
});

export const zPatchIssuesBulkBody = z.object({
    issueIds: z.array(z.string()),
    update: z.object({
        statusId: z.string().nullish(),
        priority: z.enum([
            'none',
            'low',
            'medium',
            'high',
            'urgent'
        ]).optional(),
        labels: z.array(z.string()).optional(),
        milestoneId: z.string().nullish(),
        assigneeKind: z.string().nullish(),
        assigneeId: z.string().nullish(),
        dueDate: z.number().nullish()
    })
});

export const zPatchIssuesByIdStatusByStatusNamePath = z.object({
    id: z.string().min(1),
    statusName: z.string().min(1)
});

export const zGetIssuesByIdActivityPath = z.object({
    id: z.string().min(1)
});

export const zGetIssuesByIdFieldChangesPath = z.object({
    id: z.string().min(1)
});

export const zGetIssuesByIdCommentsPath = z.object({
    id: z.string().min(1)
});

export const zPostIssuesByIdCommentsBody = z.object({
    content: z.string().min(1)
});

export const zPostIssuesByIdCommentsPath = z.object({
    id: z.string().min(1)
});

export const zDeleteIssuesCommentsByIdPath = z.object({
    id: z.string().min(1)
});

export const zGetIssuesByIdRelationsPath = z.object({
    id: z.string().min(1)
});

export const zPostIssuesRelationsBody = z.object({
    sourceIssueId: z.string().min(1),
    targetIssueId: z.string().min(1),
    type: z.enum([
        'blocks',
        'duplicates',
        'relates_to'
    ])
});

export const zDeleteIssuesRelationsByIdPath = z.object({
    id: z.string().min(1)
});

export const zPostIssuesByIdContextRefsBody = z.object({
    ref: z.string().min(1)
});

export const zPostIssuesByIdContextRefsPath = z.object({
    id: z.string().min(1)
});

export const zDeleteIssuesByIdContextRefsByIndexPath = z.object({
    id: z.string().min(1),
    index: z.string()
});

export const zPostImageOcrRecognizeBody = z.object({
    files: z.array(z.object({
        type: z.enum(['file']),
        mediaType: z.string().min(1),
        filename: z.string().optional(),
        url: z.string().min(1),
        providerMetadata: z.unknown().optional()
    })).min(1).max(8)
});

export const zGetKanbanBoardsQuery = z.object({
    workspaceId: z.string().optional()
});

export const zPostKanbanBoardsBody = z.object({
    workspaceId: z.string().min(1),
    name: z.string().min(1),
    filterConfig: z.string().nullish()
});

export const zDeleteKanbanBoardsByIdPath = z.object({
    id: z.string().min(1)
});

export const zPatchKanbanBoardsByIdBody = z.object({
    name: z.string().min(1).optional(),
    filterConfig: z.string().nullish()
});

export const zPatchKanbanBoardsByIdPath = z.object({
    id: z.string().min(1)
});

export const zGetLinkPreviewQuery = z.object({
    url: z.url()
});

export const zGetSearchThreadsQuery = z.object({
    query: z.string().min(1),
    workspaceId: z.string().optional(),
    origin: z.string().min(1).optional(),
    limit: z.union([
        z.string(),
        z.number().gte(1)
    ]).optional(),
    snippetsPerHit: z.union([
        z.string(),
        z.number().gte(1)
    ]).optional()
});

export const zGetSearchChronicleQuery = z.object({
    query: z.string().min(1),
    workspaceId: z.string().optional(),
    limit: z.union([
        z.string(),
        z.number().gte(1)
    ]).optional()
});

export const zPostRecallQueryBody = z.object({
    chatSessionId: z.string().min(1),
    code: z.string().min(1)
});

export const zPostRecallAttuneBody = z.object({
    chatSessionId: z.string().min(1),
    code: z.string().min(1)
});

export const zPostRecallAttuneByIdResolveBody = z.object({
    chatSessionId: z.string().min(1),
    approved: z.boolean()
});

export const zPostRecallAttuneByIdResolvePath = z.object({
    id: z.string().min(1)
});

export const zPostPluginsSourcesBody = z.object({
    kind: z.enum([
        'localPath',
        'git',
        'npm'
    ]),
    location: z.string().min(1),
    ref: z.string().nullish(),
    subPath: z.string().nullish(),
    label: z.string().nullish(),
    addedReason: z.string().nullish()
});

export const zPostPluginsDevSessionsBody = z.object({
    packageDir: z.string().min(1),
    entries: z.object({
        server: z.string().min(1).optional(),
        web: z.string().min(1).optional(),
        desktop: z.string().min(1).optional()
    })
});

export const zPostPluginsDevSessionsByIdReloadBody = z.object({
    layer: z.enum([
        'server',
        'web',
        'desktop'
    ])
});

export const zPostPluginsDevSessionsByIdReloadPath = z.object({
    id: z.string().min(1)
});

export const zPostPluginsDevSessionsByIdHeartbeatPath = z.object({
    id: z.string().min(1)
});

export const zDeletePluginsDevSessionsByIdPath = z.object({
    id: z.string().min(1)
});

export const zPostPluginsSourcesPreviewBody = z.object({
    kind: z.enum(['git', 'npm']),
    location: z.string().min(1),
    ref: z.string().nullish(),
    subPath: z.string().nullish()
});

export const zDeletePluginsSourcesByIdBody = z.object({
    confirmationToken: z.string().min(1)
});

export const zDeletePluginsSourcesByIdPath = z.object({
    id: z.string().min(1)
});

export const zGetPluginsSourcesByIdPath = z.object({
    id: z.string().min(1)
});

export const zPostPluginsSourcesByIdRefreshPath = z.object({
    id: z.string().min(1)
});

export const zGetPluginsSourcesByIdUninstallPlanPath = z.object({
    id: z.string().min(1)
});

export const zGetPluginsByRouteSegmentIconPath = z.object({
    routeSegment: z.string().min(1)
});

export const zGetPluginsByRouteSegmentPath = z.object({
    routeSegment: z.string().min(1)
});

export const zPatchPluginsByRouteSegmentEnabledBody = z.object({
    enabled: z.boolean(),
    reason: z.string().nullish()
});

export const zPatchPluginsByRouteSegmentEnabledPath = z.object({
    routeSegment: z.string().min(1)
});

export const zGetSkillsQuery = z.object({
    workspaceId: z.string().min(1).regex(/.*\S.*/).optional(),
    agentId: z.string().min(1).regex(/.*\S.*/).optional()
});

export const zPostSkillsBody = z.object({
    scope: z.enum([
        'builtin',
        'legacy',
        'global',
        'repository',
        'workspace',
        'agent'
    ]),
    name: z.string().min(1).regex(/.*\S.*/),
    description: z.string().min(1).regex(/.*\S.*/),
    body: z.string(),
    workspaceId: z.string().min(1).regex(/.*\S.*/).nullish(),
    agentId: z.string().min(1).regex(/.*\S.*/).nullish(),
    frontmatter: z.record(z.string(), z.unknown()).optional()
});

export const zDeleteSkillsDocumentQuery = z.object({
    scope: z.enum([
        'builtin',
        'legacy',
        'global',
        'repository',
        'workspace',
        'agent'
    ]),
    name: z.string().min(1).regex(/.*\S.*/),
    workspaceId: z.string().min(1).regex(/.*\S.*/).optional(),
    agentId: z.string().min(1).regex(/.*\S.*/).optional()
});

export const zGetSkillsDocumentQuery = z.object({
    scope: z.enum([
        'builtin',
        'legacy',
        'global',
        'repository',
        'workspace',
        'agent'
    ]),
    name: z.string().min(1).regex(/.*\S.*/),
    workspaceId: z.string().min(1).regex(/.*\S.*/).optional(),
    agentId: z.string().min(1).regex(/.*\S.*/).optional()
});

export const zPutSkillsDocumentBody = z.object({
    scope: z.enum([
        'builtin',
        'legacy',
        'global',
        'repository',
        'workspace',
        'agent'
    ]),
    name: z.string().min(1).regex(/.*\S.*/),
    workspaceId: z.string().min(1).regex(/.*\S.*/).nullish(),
    agentId: z.string().min(1).regex(/.*\S.*/).nullish(),
    document: z.object({
        name: z.string().min(1).regex(/.*\S.*/),
        description: z.string().min(1).regex(/.*\S.*/),
        body: z.string(),
        frontmatter: z.record(z.string(), z.unknown()).optional()
    })
});

export const zPostSkillsImportBody = z.object({
    scope: z.enum([
        'builtin',
        'legacy',
        'global',
        'repository',
        'workspace',
        'agent'
    ]),
    sourceDir: z.string().min(1).regex(/.*\S.*/),
    overwrite: z.boolean().optional(),
    workspaceId: z.string().min(1).regex(/.*\S.*/).nullish(),
    agentId: z.string().min(1).regex(/.*\S.*/).nullish()
});

export const zPostSkillsExportBody = z.object({
    scope: z.enum([
        'builtin',
        'legacy',
        'global',
        'repository',
        'workspace',
        'agent'
    ]),
    name: z.string().min(1).regex(/.*\S.*/),
    destinationDir: z.string().min(1).regex(/.*\S.*/),
    confirmedNonCradleOwnedWrite: z.boolean(),
    overwrite: z.boolean().optional(),
    workspaceId: z.string().min(1).regex(/.*\S.*/).nullish(),
    agentId: z.string().min(1).regex(/.*\S.*/).nullish()
});

export const zPostSkillsFetchSourceBody = z.object({
    source: z.string().min(1).regex(/.*\S.*/)
});

export const zPostSkillsImportFromFetchBody = z.object({
    sessionId: z.string().min(1).regex(/.*\S.*/),
    selectedDirs: z.array(z.string().min(1).regex(/.*\S.*/)).min(1),
    scope: z.enum([
        'builtin',
        'legacy',
        'global',
        'repository',
        'workspace',
        'agent'
    ]),
    overwrite: z.boolean().optional(),
    workspaceId: z.string().min(1).regex(/.*\S.*/).nullish(),
    agentId: z.string().min(1).regex(/.*\S.*/).nullish()
});

export const zPostSkillsCancelFetchBody = z.object({
    sessionId: z.string().min(1).regex(/.*\S.*/)
});

export const zGetWorkflowRulesByWorkspaceIdListPath = z.object({
    workspaceId: z.string().min(1)
});

export const zDeleteWorkflowRulesByWorkspaceIdPath = z.object({
    workspaceId: z.string().min(1)
});

export const zDeleteWorkflowRulesByWorkspaceIdQuery = z.object({
    agentId: z.string().optional()
});

export const zGetWorkflowRulesByWorkspaceIdPath = z.object({
    workspaceId: z.string().min(1)
});

export const zGetWorkflowRulesByWorkspaceIdQuery = z.object({
    agentId: z.string().optional()
});

export const zPutWorkflowRulesByWorkspaceIdBody = z.object({
    agentId: z.string().nullish(),
    content: z.string()
});

export const zPutWorkflowRulesByWorkspaceIdPath = z.object({
    workspaceId: z.string().min(1)
});

export const zGetWorkspacesByWorkspaceIdGitRepositoriesPath = z.object({
    workspaceId: z.string().min(1)
});

export const zGetWorkspacesByWorkspaceIdGitRepositoriesQuery = z.object({
    repo: z.string().min(1).optional(),
    sessionId: z.string().min(1).optional()
});

export const zGetWorkspacesByWorkspaceIdGitStatusPath = z.object({
    workspaceId: z.string().min(1)
});

export const zGetWorkspacesByWorkspaceIdGitStatusQuery = z.object({
    repo: z.string().min(1).optional(),
    sessionId: z.string().min(1).optional()
});

export const zGetWorkspacesByWorkspaceIdGitBranchesPath = z.object({
    workspaceId: z.string().min(1)
});

export const zGetWorkspacesByWorkspaceIdGitBranchesQuery = z.object({
    repo: z.string().min(1).optional(),
    sessionId: z.string().min(1).optional()
});

export const zPostWorkspacesByWorkspaceIdGitBranchesBody = z.object({
    repo: z.string().min(1).optional(),
    name: z.string().min(1),
    from: z.string().min(1).optional()
});

export const zPostWorkspacesByWorkspaceIdGitBranchesPath = z.object({
    workspaceId: z.string().min(1)
});

export const zGetWorkspacesByWorkspaceIdGitRemotesPath = z.object({
    workspaceId: z.string().min(1)
});

export const zGetWorkspacesByWorkspaceIdGitRemotesQuery = z.object({
    repo: z.string().min(1).optional(),
    sessionId: z.string().min(1).optional()
});

export const zGetWorkspacesByWorkspaceIdGitGraphPath = z.object({
    workspaceId: z.string().min(1)
});

export const zGetWorkspacesByWorkspaceIdGitGraphQuery = z.object({
    repo: z.string().min(1).optional(),
    limit: z.union([
        z.string(),
        z.number().gte(1)
    ]).optional()
});

export const zPostWorkspacesByWorkspaceIdGitCheckoutBody = z.object({
    repo: z.string().min(1).optional(),
    branch: z.string().min(1)
});

export const zPostWorkspacesByWorkspaceIdGitCheckoutPath = z.object({
    workspaceId: z.string().min(1)
});

export const zPostWorkspacesByWorkspaceIdGitFetchBody = z.object({
    repo: z.string().min(1).optional()
});

export const zPostWorkspacesByWorkspaceIdGitFetchPath = z.object({
    workspaceId: z.string().min(1)
});

export const zGetWorkspacesByWorkspaceIdGitDiffPath = z.object({
    workspaceId: z.string().min(1)
});

export const zGetWorkspacesByWorkspaceIdGitDiffQuery = z.object({
    repo: z.string().min(1).optional(),
    paths: z.string().optional(),
    sessionId: z.string().min(1).optional()
});

export const zGetWorkspacesByWorkspaceIdGitMergeBasePath = z.object({
    workspaceId: z.string().min(1)
});

export const zGetWorkspacesByWorkspaceIdGitMergeBaseQuery = z.object({
    repo: z.string().min(1).optional(),
    baseBranch: z.string().min(1)
});

export const zGetWorkspacesByWorkspaceIdGitBranchComparePath = z.object({
    workspaceId: z.string().min(1)
});

export const zGetWorkspacesByWorkspaceIdGitBranchCompareQuery = z.object({
    repo: z.string().min(1).optional(),
    baseRef: z.string().min(1),
    headRef: z.string().min(1)
});

export const zPostWorktreesCleanupBody = z.object({
    maxWorktrees: z.number().gte(0),
    maxTotalSizeGb: z.number().gte(0)
});

export const zGetWorkspacesByWorkspaceIdWorktreesPath = z.object({
    workspaceId: z.string().min(1)
});

export const zPostWorkspacesByWorkspaceIdWorktreesBody = z.object({
    sessionId: z.string().min(1),
    slug: z.string().min(1).optional(),
    bindSession: z.boolean().optional(),
    confirmedSetupHooks: z.boolean().optional()
});

export const zPostWorkspacesByWorkspaceIdWorktreesPath = z.object({
    workspaceId: z.string().min(1)
});

export const zPostWorkspacesByWorkspaceIdWorktreesByWorktreeIdCleanupBody = z.object({
    mode: z.enum(['merge-and-close', 'abandon']),
    targetBranch: z.string().min(1).optional()
});

export const zPostWorkspacesByWorkspaceIdWorktreesByWorktreeIdCleanupPath = z.object({
    workspaceId: z.string().min(1),
    worktreeId: z.string().min(1)
});

export const zGetWorkspacesByWorkspaceIdDiffReviewsPath = z.object({
    workspaceId: z.string().min(1)
});

export const zGetWorkspacesByWorkspaceIdDiffReviewsSourceReadinessPath = z.object({
    workspaceId: z.string().min(1)
});

export const zPostWorkspacesByWorkspaceIdDiffReviewsLocalWorkingTreeBody = z.object({
    repo: z.string().min(1).optional()
});

export const zPostWorkspacesByWorkspaceIdDiffReviewsLocalWorkingTreePath = z.object({
    workspaceId: z.string().min(1)
});

export const zPostWorkspacesByWorkspaceIdDiffReviewsLocalBranchCompareBody = z.object({
    repo: z.string().min(1).optional(),
    baseRef: z.string().min(1),
    headRef: z.string().min(1)
});

export const zPostWorkspacesByWorkspaceIdDiffReviewsLocalBranchComparePath = z.object({
    workspaceId: z.string().min(1)
});

export const zPostWorkspacesByWorkspaceIdDiffReviewsLocalCommitBody = z.object({
    repo: z.string().min(1).optional(),
    commitRef: z.string().min(1)
});

export const zPostWorkspacesByWorkspaceIdDiffReviewsLocalCommitPath = z.object({
    workspaceId: z.string().min(1)
});

export const zPostWorkspacesByWorkspaceIdDiffReviewsGithubPullRequestBody = z.object({
    owner: z.string().min(1).max(39).regex(/^[A-Za-z0-9](?:[A-Za-z0-9-]{0,37}[A-Za-z0-9])?$/),
    repo: z.string().min(1).max(100).regex(/^[A-Za-z0-9_.-]+$/),
    number: z.union([
        z.string(),
        z.int().gte(1)
    ])
});

export const zPostWorkspacesByWorkspaceIdDiffReviewsGithubPullRequestPath = z.object({
    workspaceId: z.string().min(1)
});

export const zGetWorkspacesByWorkspaceIdDiffReviewsByReviewIdPath = z.object({
    workspaceId: z.string().min(1),
    reviewId: z.string().min(1)
});

export const zPostWorkspacesByWorkspaceIdDiffReviewsByReviewIdRefreshPath = z.object({
    workspaceId: z.string().min(1),
    reviewId: z.string().min(1)
});

export const zPostWorkspacesByWorkspaceIdDiffReviewsByReviewIdClosePath = z.object({
    workspaceId: z.string().min(1),
    reviewId: z.string().min(1)
});

export const zPostWorkspacesByWorkspaceIdDiffReviewsByReviewIdFilesByFileIdViewedBody = z.object({
    viewed: z.boolean()
});

export const zPostWorkspacesByWorkspaceIdDiffReviewsByReviewIdFilesByFileIdViewedPath = z.object({
    workspaceId: z.string().min(1),
    reviewId: z.string().min(1),
    fileId: z.string().min(1)
});

export const zPostWorkspacesByWorkspaceIdDiffReviewsByReviewIdThreadsBody = z.object({
    fileId: z.string().min(1).nullish(),
    anchor: z.object({
        fileId: z.string().min(1),
        side: z.enum(['base', 'head']).optional(),
        startLine: z.number().gte(1),
        endLine: z.number().gte(1).optional(),
        startColumn: z.number().gte(1).optional(),
        endColumn: z.number().gte(1).optional()
    }).nullish(),
    bodyMarkdown: z.string().min(1)
});

export const zPostWorkspacesByWorkspaceIdDiffReviewsByReviewIdThreadsPath = z.object({
    workspaceId: z.string().min(1),
    reviewId: z.string().min(1)
});

export const zPostWorkspacesByWorkspaceIdDiffReviewsByReviewIdThreadsByThreadIdCommentsBody = z.object({
    bodyMarkdown: z.string().min(1)
});

export const zPostWorkspacesByWorkspaceIdDiffReviewsByReviewIdThreadsByThreadIdCommentsPath = z.object({
    workspaceId: z.string().min(1),
    reviewId: z.string().min(1),
    threadId: z.string().min(1)
});

export const zPostWorkspacesByWorkspaceIdDiffReviewsByReviewIdThreadsByThreadIdResolvePath = z.object({
    workspaceId: z.string().min(1),
    reviewId: z.string().min(1),
    threadId: z.string().min(1)
});

export const zPostWorkspacesByWorkspaceIdDiffReviewsByReviewIdSubmitBody = z.object({
    decision: z.enum([
        'approve',
        'request-changes',
        'comment'
    ]),
    bodyMarkdown: z.string().nullish()
});

export const zPostWorkspacesByWorkspaceIdDiffReviewsByReviewIdSubmitPath = z.object({
    workspaceId: z.string().min(1),
    reviewId: z.string().min(1)
});

export const zPostWorkspacesByWorkspaceIdDiffReviewsByReviewIdMergeBody = z.object({
    mergeMethod: z.enum([
        'merge',
        'squash',
        'rebase'
    ])
});

export const zPostWorkspacesByWorkspaceIdDiffReviewsByReviewIdMergePath = z.object({
    workspaceId: z.string().min(1),
    reviewId: z.string().min(1)
});

export const zPutWorkspacesByWorkspaceIdDiffReviewsPreferencesBody = z.object({
    diffStyle: z.enum(['split', 'unified']).optional(),
    codeTheme: z.string().min(1).optional(),
    fontSize: z.number().gte(9).lte(24).optional(),
    lineHeight: z.number().gte(12).lte(36).optional(),
    hideWhitespaceOnly: z.boolean().optional(),
    structuralHighlighting: z.boolean().optional(),
    collapseGeneratedFiles: z.boolean().optional(),
    notificationMode: z.enum([
        'all-activity',
        'all-activity-by-people',
        'reviews-and-comments',
        'reviews-and-comments-by-people',
        'none'
    ]).optional()
});

export const zPutWorkspacesByWorkspaceIdDiffReviewsPreferencesPath = z.object({
    workspaceId: z.string().min(1)
});

export const zPostWorkspacesByWorkspaceIdDiffReviewsByReviewIdAgentFixesBody = z.object({
    threadId: z.string().min(1).nullish(),
    anchor: z.object({
        fileId: z.string().min(1),
        side: z.enum(['base', 'head']).optional(),
        startLine: z.number().gte(1),
        endLine: z.number().gte(1).optional(),
        startColumn: z.number().gte(1).optional(),
        endColumn: z.number().gte(1).optional()
    }).nullish(),
    instruction: z.string().min(1),
    agentId: z.string().min(1).nullish(),
    expectedOutput: z.enum(['working-tree-change', 'patch-artifact'])
});

export const zPostWorkspacesByWorkspaceIdDiffReviewsByReviewIdAgentFixesPath = z.object({
    workspaceId: z.string().min(1),
    reviewId: z.string().min(1)
});

export const zPostWorkspacesByWorkspaceIdDiffReviewsByReviewIdAgentFixesByAgentFixIdStartBody = z.object({
    agentId: z.string().min(1).nullish(),
    providerTargetId: z.string().min(1).nullish(),
    runtimeKind: z.string().min(1).nullish(),
    modelId: z.string().min(1).nullish(),
    outputLocale: z.enum([
        'en-US',
        'zh-CN',
        'ja-JP',
        'es-ES'
    ]).nullish()
});

export const zPostWorkspacesByWorkspaceIdDiffReviewsByReviewIdAgentFixesByAgentFixIdStartPath = z.object({
    workspaceId: z.string().min(1),
    reviewId: z.string().min(1),
    agentFixId: z.string().min(1)
});

export const zGetWorkspacesByWorkspaceIdDiffReviewsByReviewIdAgentFixesByAgentFixIdArtifactPath = z.object({
    workspaceId: z.string().min(1),
    reviewId: z.string().min(1),
    agentFixId: z.string().min(1)
});

export const zPostWorkspacesByWorkspaceIdDiffReviewsByReviewIdAgentFixesByAgentFixIdCancelBody = z.record(z.string(), z.never());

export const zPostWorkspacesByWorkspaceIdDiffReviewsByReviewIdAgentFixesByAgentFixIdCancelPath = z.object({
    workspaceId: z.string().min(1),
    reviewId: z.string().min(1),
    agentFixId: z.string().min(1)
});

export const zPostWorkspacesByWorkspaceIdDiffReviewsByReviewIdAgentFixesByAgentFixIdRerunBody = z.object({
    agentId: z.string().min(1).nullish(),
    providerTargetId: z.string().min(1).nullish(),
    runtimeKind: z.string().min(1).nullish(),
    modelId: z.string().min(1).nullish(),
    outputLocale: z.enum([
        'en-US',
        'zh-CN',
        'ja-JP',
        'es-ES'
    ]).nullish()
});

export const zPostWorkspacesByWorkspaceIdDiffReviewsByReviewIdAgentFixesByAgentFixIdRerunPath = z.object({
    workspaceId: z.string().min(1),
    reviewId: z.string().min(1),
    agentFixId: z.string().min(1)
});

export const zDeleteWorkspacesByWorkspaceIdDiffReviewsByReviewIdAgentFixesByAgentFixIdPath = z.object({
    workspaceId: z.string().min(1),
    reviewId: z.string().min(1),
    agentFixId: z.string().min(1)
});

export const zGetAcpRegistryByAgentIdDistributionTypesPath = z.object({
    agentId: z.string().min(1)
});

export const zPostAcpAgentsBody = z.object({
    id: z.string().min(1).optional(),
    name: z.string().min(1),
    cmd: z.string().min(1),
    args: z.array(z.string()).optional(),
    env: z.record(z.string(), z.unknown()).optional(),
    distributionType: z.enum([
        'command',
        'npx',
        'uvx'
    ]).optional(),
    version: z.string().min(1).optional()
});

export const zDeleteAcpAgentsByAgentIdPath = z.object({
    agentId: z.string().min(1)
});

export const zGetAcpAgentsByAgentIdPath = z.object({
    agentId: z.string().min(1)
});

export const zPatchAcpAgentsByAgentIdLaunchConfigBody = z.object({
    name: z.string().min(1).optional(),
    overrideCmd: z.string().nullish(),
    overrideArgs: z.array(z.string()).nullish(),
    overrideEnv: z.record(z.string(), z.unknown()).nullish(),
    cmd: z.string().min(1).optional(),
    args: z.array(z.string()).optional(),
    env: z.record(z.string(), z.unknown()).optional(),
    distributionType: z.enum([
        'command',
        'npx',
        'uvx'
    ]).optional(),
    version: z.string().min(1).optional()
});

export const zPatchAcpAgentsByAgentIdLaunchConfigPath = z.object({
    agentId: z.string().min(1)
});

export const zPostAcpAgentsByAgentIdDraftSessionBody = z.object({
    workspaceId: z.string().min(1).optional()
});

export const zPostAcpAgentsByAgentIdDraftSessionPath = z.object({
    agentId: z.string().min(1)
});

export const zDeleteAcpAgentsByAgentIdInstallationPath = z.object({
    agentId: z.string().min(1)
});

export const zPutAcpAgentsByAgentIdInstallationBody = z.object({
    distributionType: z.enum([
        'binary',
        'npx',
        'uvx'
    ])
});

export const zPutAcpAgentsByAgentIdInstallationPath = z.object({
    agentId: z.string().min(1)
});

export const zGetAcpAuditQuery = z.object({
    agentId: z.string().optional()
});

export const zGetAcpAgentsByAgentIdInstallPathPath = z.object({
    agentId: z.string().min(1)
});

export const zGetEventsQuery = z.object({
    scope: z.enum(['sessions']),
    afterSequenceId: z.number().gte(0).optional(),
    workspaceId: z.string().optional(),
    limit: z.number().gte(1).lte(500).optional()
});

export const zGetChatSessionsBySessionIdEventsPath = z.object({
    sessionId: z.string().min(1)
});

export const zGetChatSessionsBySessionIdEventsQuery = z.object({
    afterVersion: z.number().gte(0).optional(),
    limit: z.number().gte(1).lte(500).optional()
});

export const zGetChatSessionsBySessionIdBlobsByBlobIdContentPath = z.object({
    sessionId: z.string().min(1),
    blobId: z.string().min(1)
});

export const zDeleteChatComposerDraftsBySurfaceIdPath = z.object({
    surfaceId: z.string().min(1)
});

export const zGetChatComposerDraftsBySurfaceIdPath = z.object({
    surfaceId: z.string().min(1)
});

export const zPutChatComposerDraftsBySurfaceIdBody = z.object({
    draft: z.object({
        text: z.string(),
        contextParts: z.array(z.union([
            z.object({
                type: z.enum(['data-cradle-skill']),
                name: z.string().min(1),
                path: z.string().min(1),
                scope: z.enum([
                    'builtin',
                    'legacy',
                    'global',
                    'repository',
                    'workspace',
                    'agent'
                ]),
                description: z.string().nullable(),
                position: z.number().gte(0).optional()
            }),
            z.object({
                type: z.enum(['data-cradle-plugin']),
                provider: z.enum(['cradle', 'codex']).optional(),
                pluginName: z.string().min(1),
                displayName: z.string().min(1),
                description: z.string().nullable(),
                iconUrl: z.string().min(1).nullish(),
                routeSegment: z.string().min(1),
                capabilities: z.array(z.object({
                    id: z.string().min(1),
                    type: z.string().min(1),
                    layer: z.enum([
                        'server',
                        'web',
                        'desktop'
                    ]),
                    label: z.string().nullable()
                })),
                mcpServers: z.array(z.string().min(1)),
                nativeMention: z.object({
                    name: z.string().min(1),
                    path: z.string().min(1)
                }).nullish(),
                position: z.number().gte(0).optional()
            }),
            z.object({
                type: z.enum(['data-cradle-file-line-comment']),
                workspaceId: z.string().min(1),
                path: z.string().min(1),
                lineStart: z.number().gte(1),
                lineEnd: z.number().gte(1),
                comment: z.string().min(1),
                position: z.number().gte(0).optional()
            }),
            z.object({
                type: z.enum(['data-cradle-intent']),
                intentId: z.enum([
                    'review',
                    'commit',
                    'push'
                ]),
                name: z.string().min(1),
                label: z.string().min(1),
                prompt: z.string().min(1),
                position: z.number().gte(0).optional()
            })
        ])),
        files: z.array(z.object({
            type: z.enum(['file']),
            mediaType: z.string().min(1),
            filename: z.string().optional(),
            url: z.string().min(1),
            providerMetadata: z.unknown().optional()
        })),
        pastedTexts: z.array(z.object({
            id: z.string().min(1),
            text: z.string(),
            lineCount: z.number().gte(0),
            charCount: z.number().gte(0)
        }))
    })
});

export const zPutChatComposerDraftsBySurfaceIdPath = z.object({
    surfaceId: z.string().min(1)
});

export const zGetChatRuntimesByRuntimeKindModelsPath = z.object({
    runtimeKind: z.string().min(1)
});

export const zGetChatRuntimesByRuntimeKindModelsQuery = z.object({
    workspaceId: z.string().optional()
});

export const zGetChatDraftRuntimeCapabilitiesQuery = z.object({
    runtimeKind: z.string().min(1)
});

export const zGetChatSessionsBySessionIdCapabilitiesPath = z.object({
    sessionId: z.string().min(1)
});

export const zGetChatSessionsBySessionIdUiSlotStatesPath = z.object({
    sessionId: z.string().min(1)
});

export const zGetChatSessionsBySessionIdContextUsagePath = z.object({
    sessionId: z.string().min(1)
});

export const zGetChatSessionsBySessionIdBackgroundTerminalsPath = z.object({
    sessionId: z.string().min(1)
});

export const zGetChatSessionsBySessionIdBackgroundTerminalsQuery = z.object({
    cursor: z.string().optional(),
    limit: z.number().optional()
});

export const zPostChatSessionsBySessionIdBackgroundTerminalsByProcessIdTerminatePath = z.object({
    sessionId: z.string().min(1),
    processId: z.string().min(1)
});

export const zGetChatSessionsBySessionIdProviderThreadsPath = z.object({
    sessionId: z.string().min(1)
});

export const zGetChatSessionsBySessionIdProviderThreadsQuery = z.object({
    cursor: z.string().optional(),
    limit: z.number().optional(),
    sortKey: z.enum(['created_at', 'updated_at']).optional(),
    sortDirection: z.enum(['asc', 'desc']).optional(),
    sourceKinds: z.string().optional(),
    archived: z.boolean().optional(),
    searchTerm: z.string().optional()
});

export const zDeleteChatSessionsBySessionIdProviderThreadsByThreadIdPath = z.object({
    sessionId: z.string().min(1),
    threadId: z.string().min(1)
});

export const zGetChatSessionsBySessionIdProviderThreadsByThreadIdPath = z.object({
    sessionId: z.string().min(1),
    threadId: z.string().min(1)
});

export const zGetChatSessionsBySessionIdProviderThreadsByThreadIdTurnsPath = z.object({
    sessionId: z.string().min(1),
    threadId: z.string().min(1)
});

export const zGetChatSessionsBySessionIdProviderThreadsByThreadIdTurnsQuery = z.object({
    cursor: z.string().optional(),
    limit: z.number().optional(),
    sortDirection: z.enum(['asc', 'desc']).optional()
});

export const zGetChatSessionsBySessionIdProviderThreadsByThreadIdStreamPath = z.object({
    sessionId: z.string().min(1),
    threadId: z.string().min(1)
});

export const zGetChatSessionsBySessionIdWorkflowsByToolCallIdStreamPath = z.object({
    sessionId: z.string().min(1),
    toolCallId: z.string().min(1)
});

export const zGetChatSessionsBySessionIdRuntimeStatusPath = z.object({
    sessionId: z.string().min(1)
});

export const zGetChatSessionsBySessionIdCodexAppServerCapabilitiesPath = z.object({
    sessionId: z.string().min(1)
});

export const zPostChatSessionsBySessionIdCodexAppServerInvokeBody = z.object({
    method: z.string().min(1),
    params: z.unknown().optional(),
    providerTargetId: z.string().optional(),
    modelId: z.string().optional()
});

export const zPostChatSessionsBySessionIdCodexAppServerInvokePath = z.object({
    sessionId: z.string().min(1)
});

export const zPostChatSessionsBySessionIdCodexAppServerStreamBody = z.object({
    method: z.string().min(1),
    params: z.unknown().optional(),
    providerTargetId: z.string().optional(),
    modelId: z.string().optional(),
    closeOnMethods: z.array(z.string().min(1)).optional()
});

export const zPostChatSessionsBySessionIdCodexAppServerStreamPath = z.object({
    sessionId: z.string().min(1)
});

export const zPostChatSessionsBySessionIdRollbackLastTurnPath = z.object({
    sessionId: z.string().min(1)
});

export const zGetChatSessionsBySessionIdQueuePath = z.object({
    sessionId: z.string().min(1)
});

export const zPostChatSessionsBySessionIdQueueBody = z.object({
    text: z.string().min(1).optional(),
    files: z.array(z.object({
        type: z.enum(['file']),
        mediaType: z.string().min(1),
        filename: z.string().optional(),
        url: z.string().min(1),
        providerMetadata: z.unknown().optional()
    })).optional(),
    contextParts: z.array(z.union([
        z.object({
            type: z.enum(['data-cradle-skill']),
            name: z.string().min(1),
            path: z.string().min(1),
            scope: z.enum([
                'builtin',
                'legacy',
                'global',
                'repository',
                'workspace',
                'agent'
            ]),
            description: z.string().nullable(),
            position: z.number().gte(0).optional()
        }),
        z.object({
            type: z.enum(['data-cradle-plugin']),
            provider: z.enum(['cradle', 'codex']).optional(),
            pluginName: z.string().min(1),
            displayName: z.string().min(1),
            description: z.string().nullable(),
            iconUrl: z.string().min(1).nullish(),
            routeSegment: z.string().min(1),
            capabilities: z.array(z.object({
                id: z.string().min(1),
                type: z.string().min(1),
                layer: z.enum([
                    'server',
                    'web',
                    'desktop'
                ]),
                label: z.string().nullable()
            })),
            mcpServers: z.array(z.string().min(1)),
            nativeMention: z.object({
                name: z.string().min(1),
                path: z.string().min(1)
            }).nullish(),
            position: z.number().gte(0).optional()
        }),
        z.object({
            type: z.enum(['data-cradle-file-line-comment']),
            workspaceId: z.string().min(1),
            path: z.string().min(1),
            lineStart: z.number().gte(1),
            lineEnd: z.number().gte(1),
            comment: z.string().min(1),
            position: z.number().gte(0).optional()
        }),
        z.object({
            type: z.enum(['data-cradle-intent']),
            intentId: z.enum([
                'review',
                'commit',
                'push'
            ]),
            name: z.string().min(1),
            label: z.string().min(1),
            prompt: z.string().min(1),
            position: z.number().gte(0).optional()
        })
    ])).optional(),
    providerTargetId: z.string().optional(),
    modelId: z.string().nullish(),
    thinkingEffort: z.enum([
        'none',
        'minimal',
        'low',
        'medium',
        'high',
        'xhigh',
        'max',
        'ultra'
    ]).optional(),
    runtimeSettings: z.record(z.string(), z.union([
        z.string(),
        z.number(),
        z.boolean()
    ]).nullable()).optional()
});

export const zPostChatSessionsBySessionIdQueuePath = z.object({
    sessionId: z.string().min(1)
});

export const zPostChatSessionsBySessionIdSteerBody = z.object({
    text: z.string().min(1).optional(),
    files: z.array(z.object({
        type: z.enum(['file']),
        mediaType: z.string().min(1),
        filename: z.string().optional(),
        url: z.string().min(1),
        providerMetadata: z.unknown().optional()
    })).optional(),
    contextParts: z.array(z.union([
        z.object({
            type: z.enum(['data-cradle-skill']),
            name: z.string().min(1),
            path: z.string().min(1),
            scope: z.enum([
                'builtin',
                'legacy',
                'global',
                'repository',
                'workspace',
                'agent'
            ]),
            description: z.string().nullable(),
            position: z.number().gte(0).optional()
        }),
        z.object({
            type: z.enum(['data-cradle-plugin']),
            provider: z.enum(['cradle', 'codex']).optional(),
            pluginName: z.string().min(1),
            displayName: z.string().min(1),
            description: z.string().nullable(),
            iconUrl: z.string().min(1).nullish(),
            routeSegment: z.string().min(1),
            capabilities: z.array(z.object({
                id: z.string().min(1),
                type: z.string().min(1),
                layer: z.enum([
                    'server',
                    'web',
                    'desktop'
                ]),
                label: z.string().nullable()
            })),
            mcpServers: z.array(z.string().min(1)),
            nativeMention: z.object({
                name: z.string().min(1),
                path: z.string().min(1)
            }).nullish(),
            position: z.number().gte(0).optional()
        }),
        z.object({
            type: z.enum(['data-cradle-file-line-comment']),
            workspaceId: z.string().min(1),
            path: z.string().min(1),
            lineStart: z.number().gte(1),
            lineEnd: z.number().gte(1),
            comment: z.string().min(1),
            position: z.number().gte(0).optional()
        }),
        z.object({
            type: z.enum(['data-cradle-intent']),
            intentId: z.enum([
                'review',
                'commit',
                'push'
            ]),
            name: z.string().min(1),
            label: z.string().min(1),
            prompt: z.string().min(1),
            position: z.number().gte(0).optional()
        })
    ])).optional(),
    providerTargetId: z.string().optional()
});

export const zPostChatSessionsBySessionIdSteerPath = z.object({
    sessionId: z.string().min(1)
});

export const zPostChatSessionsBySessionIdQueueReorderBody = z.object({
    queueItemIds: z.array(z.string().min(1))
});

export const zPostChatSessionsBySessionIdQueueReorderPath = z.object({
    sessionId: z.string().min(1)
});

export const zDeleteChatSessionsBySessionIdQueueByQueueItemIdPath = z.object({
    sessionId: z.string().min(1),
    queueItemId: z.string().min(1)
});

export const zPatchChatSessionsBySessionIdQueueByQueueItemIdBody = z.object({
    text: z.string().min(1).optional(),
    files: z.array(z.object({
        type: z.enum(['file']),
        mediaType: z.string().min(1),
        filename: z.string().optional(),
        url: z.string().min(1),
        providerMetadata: z.unknown().optional()
    })).optional(),
    contextParts: z.array(z.union([
        z.object({
            type: z.enum(['data-cradle-skill']),
            name: z.string().min(1),
            path: z.string().min(1),
            scope: z.enum([
                'builtin',
                'legacy',
                'global',
                'repository',
                'workspace',
                'agent'
            ]),
            description: z.string().nullable(),
            position: z.number().gte(0).optional()
        }),
        z.object({
            type: z.enum(['data-cradle-plugin']),
            provider: z.enum(['cradle', 'codex']).optional(),
            pluginName: z.string().min(1),
            displayName: z.string().min(1),
            description: z.string().nullable(),
            iconUrl: z.string().min(1).nullish(),
            routeSegment: z.string().min(1),
            capabilities: z.array(z.object({
                id: z.string().min(1),
                type: z.string().min(1),
                layer: z.enum([
                    'server',
                    'web',
                    'desktop'
                ]),
                label: z.string().nullable()
            })),
            mcpServers: z.array(z.string().min(1)),
            nativeMention: z.object({
                name: z.string().min(1),
                path: z.string().min(1)
            }).nullish(),
            position: z.number().gte(0).optional()
        }),
        z.object({
            type: z.enum(['data-cradle-file-line-comment']),
            workspaceId: z.string().min(1),
            path: z.string().min(1),
            lineStart: z.number().gte(1),
            lineEnd: z.number().gte(1),
            comment: z.string().min(1),
            position: z.number().gte(0).optional()
        }),
        z.object({
            type: z.enum(['data-cradle-intent']),
            intentId: z.enum([
                'review',
                'commit',
                'push'
            ]),
            name: z.string().min(1),
            label: z.string().min(1),
            prompt: z.string().min(1),
            position: z.number().gte(0).optional()
        })
    ])).optional(),
    providerTargetId: z.string().optional(),
    modelId: z.string().nullish(),
    thinkingEffort: z.enum([
        'none',
        'minimal',
        'low',
        'medium',
        'high',
        'xhigh',
        'max',
        'ultra'
    ]).optional(),
    runtimeSettings: z.record(z.string(), z.union([
        z.string(),
        z.number(),
        z.boolean()
    ]).nullable()).optional()
});

export const zPatchChatSessionsBySessionIdQueueByQueueItemIdPath = z.object({
    sessionId: z.string().min(1),
    queueItemId: z.string().min(1)
});

export const zPostChatSessionsBySessionIdCancelPath = z.object({
    sessionId: z.string().min(1)
});

export const zPostChatSessionsBySessionIdTitleRegeneratePath = z.object({
    sessionId: z.string().min(1)
});

export const zGetChatSessionsBySessionIdRuntimeSettingsPath = z.object({
    sessionId: z.string().min(1)
});

export const zPatchChatSessionsBySessionIdRuntimeSettingsBody = z.object({
    permissionMode: z.enum([
        'default',
        'acceptEdits',
        'bypassPermissions',
        'plan'
    ]).nullish(),
    accessMode: z.enum(['approval-required', 'full-access']).nullish(),
    interactionMode: z.enum(['default', 'plan']).nullish(),
    claudeAgent: z.object({
        modelAliases: z.object({
            haiku: z.string().optional(),
            sonnet: z.string().optional(),
            opus: z.string().optional()
        }).optional()
    }).nullish()
});

export const zPatchChatSessionsBySessionIdRuntimeSettingsPath = z.object({
    sessionId: z.string().min(1)
});

export const zPostChatSessionsBySessionIdResponseBody = z.object({
    text: z.string().optional(),
    files: z.array(z.object({
        type: z.enum(['file']),
        mediaType: z.string().min(1),
        filename: z.string().optional(),
        url: z.string().min(1),
        providerMetadata: z.unknown().optional()
    })).optional(),
    contextParts: z.array(z.union([
        z.object({
            type: z.enum(['data-cradle-skill']),
            name: z.string().min(1),
            path: z.string().min(1),
            scope: z.enum([
                'builtin',
                'legacy',
                'global',
                'repository',
                'workspace',
                'agent'
            ]),
            description: z.string().nullable(),
            position: z.number().gte(0).optional()
        }),
        z.object({
            type: z.enum(['data-cradle-plugin']),
            provider: z.enum(['cradle', 'codex']).optional(),
            pluginName: z.string().min(1),
            displayName: z.string().min(1),
            description: z.string().nullable(),
            iconUrl: z.string().min(1).nullish(),
            routeSegment: z.string().min(1),
            capabilities: z.array(z.object({
                id: z.string().min(1),
                type: z.string().min(1),
                layer: z.enum([
                    'server',
                    'web',
                    'desktop'
                ]),
                label: z.string().nullable()
            })),
            mcpServers: z.array(z.string().min(1)),
            nativeMention: z.object({
                name: z.string().min(1),
                path: z.string().min(1)
            }).nullish(),
            position: z.number().gte(0).optional()
        }),
        z.object({
            type: z.enum(['data-cradle-file-line-comment']),
            workspaceId: z.string().min(1),
            path: z.string().min(1),
            lineStart: z.number().gte(1),
            lineEnd: z.number().gte(1),
            comment: z.string().min(1),
            position: z.number().gte(0).optional()
        }),
        z.object({
            type: z.enum(['data-cradle-intent']),
            intentId: z.enum([
                'review',
                'commit',
                'push'
            ]),
            name: z.string().min(1),
            label: z.string().min(1),
            prompt: z.string().min(1),
            position: z.number().gte(0).optional()
        })
    ])).optional(),
    messages: z.array(z.object({
        id: z.string(),
        role: z.enum([
            'system',
            'user',
            'assistant'
        ]),
        parts: z.array(z.object({
            type: z.string()
        })),
        metadata: z.unknown().optional()
    })).optional(),
    providerTargetId: z.string().optional(),
    modelId: z.string().nullish(),
    thinkingEffort: z.enum([
        'none',
        'minimal',
        'low',
        'medium',
        'high',
        'xhigh',
        'max',
        'ultra'
    ]).optional(),
    runtimeSettings: z.record(z.string(), z.union([
        z.string(),
        z.number(),
        z.boolean()
    ]).nullable()).optional(),
    reviewTarget: z.union([
        z.object({
            type: z.enum(['uncommittedChanges'])
        }),
        z.object({
            type: z.enum(['baseBranch']),
            branch: z.string().min(1)
        })
    ]).optional()
});

export const zPostChatSessionsBySessionIdResponsePath = z.object({
    sessionId: z.string().min(1)
});

export const zPostChatSideConversationsBySideConversationIdResponseBody = z.object({
    text: z.string().optional(),
    files: z.array(z.object({
        type: z.enum(['file']),
        mediaType: z.string().min(1),
        filename: z.string().optional(),
        url: z.string().min(1),
        providerMetadata: z.unknown().optional()
    })).optional(),
    contextParts: z.array(z.union([
        z.object({
            type: z.enum(['data-cradle-skill']),
            name: z.string().min(1),
            path: z.string().min(1),
            scope: z.enum([
                'builtin',
                'legacy',
                'global',
                'repository',
                'workspace',
                'agent'
            ]),
            description: z.string().nullable(),
            position: z.number().gte(0).optional()
        }),
        z.object({
            type: z.enum(['data-cradle-plugin']),
            provider: z.enum(['cradle', 'codex']).optional(),
            pluginName: z.string().min(1),
            displayName: z.string().min(1),
            description: z.string().nullable(),
            iconUrl: z.string().min(1).nullish(),
            routeSegment: z.string().min(1),
            capabilities: z.array(z.object({
                id: z.string().min(1),
                type: z.string().min(1),
                layer: z.enum([
                    'server',
                    'web',
                    'desktop'
                ]),
                label: z.string().nullable()
            })),
            mcpServers: z.array(z.string().min(1)),
            nativeMention: z.object({
                name: z.string().min(1),
                path: z.string().min(1)
            }).nullish(),
            position: z.number().gte(0).optional()
        }),
        z.object({
            type: z.enum(['data-cradle-file-line-comment']),
            workspaceId: z.string().min(1),
            path: z.string().min(1),
            lineStart: z.number().gte(1),
            lineEnd: z.number().gte(1),
            comment: z.string().min(1),
            position: z.number().gte(0).optional()
        }),
        z.object({
            type: z.enum(['data-cradle-intent']),
            intentId: z.enum([
                'review',
                'commit',
                'push'
            ]),
            name: z.string().min(1),
            label: z.string().min(1),
            prompt: z.string().min(1),
            position: z.number().gte(0).optional()
        })
    ])).optional(),
    messages: z.array(z.object({
        id: z.string(),
        role: z.enum([
            'system',
            'user',
            'assistant'
        ]),
        parts: z.array(z.object({
            type: z.string()
        })),
        metadata: z.unknown().optional()
    })).optional(),
    providerTargetId: z.string().optional(),
    modelId: z.string().nullish(),
    thinkingEffort: z.enum([
        'none',
        'minimal',
        'low',
        'medium',
        'high',
        'xhigh',
        'max',
        'ultra'
    ]).optional(),
    runtimeSettings: z.record(z.string(), z.union([
        z.string(),
        z.number(),
        z.boolean()
    ]).nullable()).optional(),
    reviewTarget: z.union([
        z.object({
            type: z.enum(['uncommittedChanges'])
        }),
        z.object({
            type: z.enum(['baseBranch']),
            branch: z.string().min(1)
        })
    ]).optional()
});

export const zPostChatSideConversationsBySideConversationIdResponsePath = z.object({
    sideConversationId: z.string().min(1)
});

export const zPostChatSessionsBySessionIdBangCommandBody = z.object({
    command: z.string().min(1)
});

export const zPostChatSessionsBySessionIdBangCommandPath = z.object({
    sessionId: z.string().min(1)
});

export const zPostChatSessionsBySessionIdBangTranscriptBody = z.object({
    transcript: z.string(),
    command: z.string().min(1).optional(),
    durationMs: z.number().gte(0).optional(),
    exitCode: z.number().nullish()
});

export const zPostChatSessionsBySessionIdBangTranscriptPath = z.object({
    sessionId: z.string().min(1)
});

export const zPostChatSessionsBySessionIdObservationsBody = z.object({
    text: z.string().min(1),
    entity: z.string().optional(),
    entityType: z.string().optional(),
    durationMs: z.number().optional(),
    endReason: z.string().optional()
});

export const zPostChatSessionsBySessionIdObservationsPath = z.object({
    sessionId: z.string().min(1)
});

export const zPostChatSessionsBySessionIdSideChatBody = z.object({
    providerTargetId: z.string().optional(),
    modelId: z.string().nullish()
});

export const zPostChatSessionsBySessionIdSideChatPath = z.object({
    sessionId: z.string().min(1)
});

export const zPostChatSessionsBySessionIdQuickQuestionBody = z.object({
    question: z.string().min(1)
});

export const zPostChatSessionsBySessionIdQuickQuestionPath = z.object({
    sessionId: z.string().min(1)
});

export const zPostChatSessionsBySessionIdUserInputByRequestIdBody = z.object({
    answers: z.record(z.string(), z.unknown())
});

export const zPostChatSessionsBySessionIdUserInputByRequestIdPath = z.object({
    sessionId: z.string().min(1),
    requestId: z.string().min(1)
});

export const zPostChatSessionsBySessionIdToolApprovalByRequestIdBody = z.object({
    approved: z.boolean(),
    reason: z.string().optional()
});

export const zPostChatSessionsBySessionIdToolApprovalByRequestIdPath = z.object({
    sessionId: z.string().min(1),
    requestId: z.string().min(1)
});

export const zDeleteChatSideConversationsBySideConversationIdPath = z.object({
    sideConversationId: z.string().min(1)
});

export const zPostChatSessionsBySessionIdMessagesByMessageIdPlanImplementationApprovalBody = z.object({
    approvalId: z.string().min(1),
    approved: z.boolean()
});

export const zPostChatSessionsBySessionIdMessagesByMessageIdPlanImplementationApprovalPath = z.object({
    sessionId: z.string().min(1),
    messageId: z.string().min(1)
});

export const zGetChatSessionsBySessionIdStreamPath = z.object({
    sessionId: z.string().min(1)
});

export const zGetChatSessionsBySessionIdMessagesPath = z.object({
    sessionId: z.string().min(1)
});

export const zGetChatSessionsBySessionIdMessagesQuery = z.object({
    cursor: z.string().min(1).optional(),
    limit: z.number().gte(1).lte(200).optional()
});

export const zGetChatSessionsBySessionIdMessagePreviewsPath = z.object({
    sessionId: z.string().min(1)
});

export const zGetChatSessionsBySessionIdMessagePreviewsQuery = z.object({
    cursor: z.string().min(1).optional(),
    limit: z.number().gte(1).lte(200).optional()
});

export const zGetChatSessionsBySessionIdMessagesByMessageIdPath = z.object({
    sessionId: z.string().min(1),
    messageId: z.string().min(1)
});

export const zGetChatRunsCompletedQuery = z.object({
    since: z.number().gte(0).optional(),
    limit: z.number().gte(1).lte(200).optional()
});

export const zGetChatRunsByRunIdTracePath = z.object({
    runId: z.string().min(1)
});

export const zGetChatRunsByRunIdSnapshotPath = z.object({
    runId: z.string().min(1)
});

export const zGetChatSessionsBySessionIdTracesPath = z.object({
    sessionId: z.string().min(1)
});

export const zGetChatSessionsBySessionIdRunSnapshotsPath = z.object({
    sessionId: z.string().min(1)
});

export const zPostConversationBridgeConnectionsBody = z.object({
    platform: z.string().min(1),
    adapterOwner: z.string().min(1),
    adapterId: z.string().min(1),
    displayName: z.string().min(1),
    enabled: z.boolean().optional(),
    secretRefs: z.record(z.string(), z.unknown()).optional(),
    config: z.record(z.string(), z.unknown()).optional()
});

export const zDeleteConversationBridgeConnectionsByIdPath = z.object({
    id: z.string().min(1)
});

export const zGetConversationBridgeConnectionsByIdPath = z.object({
    id: z.string().min(1)
});

export const zPatchConversationBridgeConnectionsByIdBody = z.object({
    displayName: z.string().min(1).optional(),
    enabled: z.boolean().optional(),
    secretRefs: z.record(z.string(), z.unknown()).optional(),
    config: z.record(z.string(), z.unknown()).optional()
});

export const zPatchConversationBridgeConnectionsByIdPath = z.object({
    id: z.string().min(1)
});

export const zPostConversationBridgeConnectionsByIdStartPath = z.object({
    id: z.string().min(1)
});

export const zPostConversationBridgeConnectionsByIdStopPath = z.object({
    id: z.string().min(1)
});

export const zGetConversationBridgeConnectionsByIdChannelBindingsPath = z.object({
    id: z.string().min(1)
});

export const zDeleteConversationBridgeConnectionsByIdWorkspacesByExternalWorkspaceIdChannelsByExternalChannelIdBindingPath = z.object({
    id: z.string().min(1),
    externalWorkspaceId: z.string().min(1),
    externalChannelId: z.string().min(1)
});

export const zPutConversationBridgeConnectionsByIdWorkspacesByExternalWorkspaceIdChannelsByExternalChannelIdBindingBody = z.object({
    cradleWorkspaceId: z.string().min(1),
    sessionAgentId: z.string().nullish(),
    sessionProviderTargetId: z.string().nullish(),
    sessionRuntimeKind: z.string().nullish(),
    sessionModelId: z.string().nullish(),
    boundByExternalActorId: z.string().nullish(),
    metadata: z.record(z.string(), z.unknown()).optional()
});

export const zPutConversationBridgeConnectionsByIdWorkspacesByExternalWorkspaceIdChannelsByExternalChannelIdBindingPath = z.object({
    id: z.string().min(1),
    externalWorkspaceId: z.string().min(1),
    externalChannelId: z.string().min(1)
});

export const zGetConversationBridgeConnectionsByIdThreadsPath = z.object({
    id: z.string().min(1)
});

export const zGetConversationBridgeConnectionsByIdThreadsQuery = z.object({
    limit: z.number().gte(1).lte(100).optional()
});

export const zGetConversationBridgeDeliveryAttemptsRetryableQuery = z.object({
    limit: z.number().gte(1).lte(100).optional()
});

export const zPostConversationBridgeDeliveryAttemptsRetryQuery = z.object({
    limit: z.number().gte(1).lte(100).optional()
});

export const zPutChronicleConfigBody = z.object({
    profileId: z.string(),
    modelId: z.string(),
    workspaceId: z.string(),
    enabled: z.boolean(),
    activityPipelineEnabled: z.boolean(),
    activityPipelineIntervalMs: z.number(),
    activityPipelineBatchSize: z.number(),
    dreamSchedulerEnabled: z.boolean().optional().default(false),
    dreamSchedulerIntervalMs: z.number().optional().default(86400000),
    dreamSchedulerApplyMerge: z.boolean().optional().default(false),
    audioCaptureEnabled: z.boolean(),
    audioSource: z.enum([
        'microphone',
        'system',
        'mixed'
    ]).optional(),
    audioSegmentMs: z.number(),
    audioSegmentIntervalMs: z.number(),
    audioRmsThreshold: z.number(),
    storageRoot: z.string(),
    privacySensitiveAppBundleIds: z.array(z.string()).optional().default([]),
    privacySensitiveTitlePatterns: z.array(z.string()).optional().default([]),
    privacySensitiveUrlPatterns: z.array(z.string()).optional().default([]),
    closedEyesDiscardEnabled: z.boolean().optional().default(false),
    closedEyesMode: z.enum([
        'auto',
        'always-record',
        'always-pause'
    ]).optional()
});

export const zPostChronicleSummarizeBody = z.object({
    prompt: z.string().min(1),
    windowType: z.enum(['10min', '6h']),
    sourceSnapshotIds: z.array(z.string()).optional(),
    sourceArtifactPaths: z.array(z.string()).optional()
});

export const zPostChronicleSnapshotsBody = z.object({
    sourceId: z.string().min(1),
    displayId: z.number(),
    frameIndex: z.number().optional(),
    capturedAt: z.string().min(1),
    segmentDir: z.string(),
    framePath: z.string(),
    capturePath: z.string().optional(),
    ocrPath: z.string().optional(),
    snapshotPath: z.string().optional(),
    ocrText: z.string().optional(),
    appBundleId: z.string().optional(),
    windowTitle: z.string().optional(),
    closedEyes: z.object({
        status: z.enum([
            'open',
            'closed',
            'absent',
            'unknown'
        ]).optional(),
        confidence: z.number().gte(0).lte(1).nullish(),
        detector: z.string().nullish(),
        discard: z.boolean().optional(),
        reason: z.string().nullish(),
        metadata: z.record(z.string(), z.unknown()).optional()
    }).optional(),
    accessibility: z.object({
        sourceId: z.string().min(1),
        status: z.enum([
            'ready',
            'permission-denied',
            'unavailable',
            'error'
        ]).optional(),
        provider: z.string().optional(),
        accessibilityPath: z.string().nullish(),
        text: z.string().nullish(),
        elementCount: z.number().gte(0).optional(),
        appBundleId: z.string().nullish(),
        windowTitle: z.string().nullish(),
        tree: z.array(z.unknown()).optional(),
        metadata: z.record(z.string(), z.unknown()).optional()
    }).optional(),
    metadata: z.record(z.string(), z.unknown()).optional()
});

export const zGetChronicleMemoriesQuery = z.object({
    limit: z.number().optional().default(20)
});

export const zPostChronicleMemoriesBody = z.object({
    sourceId: z.string().min(1),
    windowType: z.enum(['10min', '6h']),
    createdAt: z.string().min(1),
    memoryPath: z.string().optional(),
    content: z.string(),
    summaryKind: z.enum([
        'llm',
        'local',
        'imported'
    ]),
    sourceSnapshotPaths: z.array(z.string()).optional(),
    sourceFramePaths: z.array(z.string()).optional(),
    metadata: z.record(z.string(), z.unknown()).optional()
});

export const zPostChronicleModelResourcesByCategoryVerifyPath = z.object({
    category: z.enum([
        'ocr',
        'audio-vad',
        'audio-asr',
        'speaker',
        'embedding',
        'pii'
    ])
});

export const zPostChronicleModelResourcesByCategoryInstallBody = z.object({
    source: z.enum(['manifest', 'local-files']).optional(),
    sourceRoot: z.string().nullish(),
    files: z.array(z.object({
        relativePath: z.string().min(1),
        sourcePath: z.string().min(1)
    })).optional()
});

export const zPostChronicleModelResourcesByCategoryInstallPath = z.object({
    category: z.enum([
        'ocr',
        'audio-vad',
        'audio-asr',
        'speaker',
        'embedding',
        'pii'
    ])
});

export const zDeleteChronicleModelResourcesByCategoryPath = z.object({
    category: z.enum([
        'ocr',
        'audio-vad',
        'audio-asr',
        'speaker',
        'embedding',
        'pii'
    ])
});

export const zPostChronicleMessageSourcesBody = z.object({
    platform: z.enum(['slack']),
    label: z.string().min(1),
    enabled: z.boolean(),
    workspaceId: z.string().nullish(),
    teamId: z.string().nullish(),
    botTokenRef: z.string().nullish(),
    channelIds: z.array(z.string()),
    realtimeMode: z.enum(['polling', 'events-api']).optional(),
    signingSecretRef: z.string().nullish()
});

export const zDeleteChronicleMessageSourcesBySourceIdPath = z.object({
    sourceId: z.string().min(1)
});

export const zPatchChronicleMessageSourcesBySourceIdBody = z.object({
    label: z.string().min(1).optional(),
    enabled: z.boolean().optional(),
    workspaceId: z.string().nullish(),
    teamId: z.string().nullish(),
    botTokenRef: z.string().nullish(),
    channelIds: z.array(z.string()).optional(),
    realtimeMode: z.enum(['polling', 'events-api']).optional(),
    signingSecretRef: z.string().nullish()
});

export const zPatchChronicleMessageSourcesBySourceIdPath = z.object({
    sourceId: z.string().min(1)
});

export const zPostChronicleMessageSourcesBySourceIdSyncPath = z.object({
    sourceId: z.string().min(1)
});

export const zPostChronicleMessageSourcesBySourceIdSlackEventsPath = z.object({
    sourceId: z.string().min(1)
});

export const zGetChronicleMessagesQuery = z.object({
    limit: z.number().optional().default(50)
});

export const zGetChronicleAudioTranscriptsQuery = z.object({
    limit: z.number().optional().default(20)
});

export const zPostChronicleAudioTranscriptsBody = z.object({
    sourceId: z.string().min(1),
    title: z.string().nullish(),
    source: z.enum([
        'asr',
        'manual',
        'imported'
    ]).optional(),
    status: z.enum([
        'recording',
        'completed',
        'imported',
        'error'
    ]).optional(),
    startedAt: z.string().min(1),
    endedAt: z.string().nullish(),
    language: z.string().nullish(),
    appBundleId: z.string().nullish(),
    windowTitle: z.string().nullish(),
    audioPath: z.string().nullish(),
    transcriptPath: z.string().nullish(),
    segments: z.array(z.object({
        startMs: z.number().gte(0),
        endMs: z.number().gte(0).nullish(),
        speakerLabel: z.string().nullish(),
        text: z.string().min(1),
        confidence: z.number().gte(0).lte(1).nullish(),
        language: z.string().nullish(),
        metadata: z.record(z.string(), z.unknown()).optional()
    })),
    metadata: z.record(z.string(), z.unknown()).optional()
});

export const zPostChronicleSpeakerProfilesBody = z.object({
    displayName: z.string().min(1),
    aliases: z.array(z.string()).optional(),
    embedding: z.array(z.number()).nullish(),
    embeddingModelId: z.string().nullish(),
    sampleCount: z.number().gte(0).optional(),
    lastSeenAt: z.string().nullish(),
    metadata: z.record(z.string(), z.unknown()).optional()
});

export const zGetChronicleAudioRawSegmentsQuery = z.object({
    limit: z.number().optional().default(20)
});

export const zPostChronicleAudioRawSegmentsBody = z.object({
    sourceId: z.string().min(1),
    recordedAt: z.string().min(1),
    source: z.enum([
        'microphone',
        'system',
        'mixed'
    ]).optional(),
    status: z.enum([
        'captured',
        'queued',
        'processed',
        'ignored',
        'error'
    ]).optional(),
    audioPath: z.string().min(1),
    metadataPath: z.string().min(1),
    sampleRate: z.number().gte(1),
    channels: z.number().gte(1),
    sampleCount: z.number().gte(0),
    droppedSamples: z.number().gte(0).optional(),
    durationMs: z.number().gte(0).optional(),
    rms: z.number().gte(0).lte(1),
    peak: z.number().gte(0).lte(1),
    active: z.boolean(),
    vadImplemented: z.boolean().optional(),
    asrImplemented: z.boolean().optional(),
    speakerLabelingImplemented: z.boolean().optional(),
    metadata: z.record(z.string(), z.unknown()).optional()
});

export const zPostChronicleAudioRawSegmentsBySourceIdProcessingResultBody = z.object({
    status: z.enum([
        'captured',
        'queued',
        'processed',
        'ignored',
        'error'
    ]).optional(),
    vadStatus: z.enum([
        'not-implemented',
        'pending',
        'ready',
        'error'
    ]).optional(),
    asrStatus: z.enum([
        'not-implemented',
        'pending',
        'ready',
        'error'
    ]).optional(),
    speakerStatus: z.enum([
        'not-implemented',
        'pending',
        'ready',
        'error'
    ]).optional(),
    transcriptSourceId: z.string().nullish(),
    speakerProfileIds: z.array(z.string()).optional(),
    errorMessage: z.string().nullish(),
    metadata: z.record(z.string(), z.unknown()).optional()
});

export const zPostChronicleAudioRawSegmentsBySourceIdProcessingResultPath = z.object({
    sourceId: z.string().min(1)
});

export const zGetChronicleAccessibilitySnapshotsQuery = z.object({
    limit: z.number().optional().default(20)
});

export const zGetChronicleAccessibilityEventsQuery = z.object({
    limit: z.number().optional().default(50)
});

export const zPostChronicleAccessibilityEventsBody = z.object({
    sourceId: z.string().min(1),
    capturedAt: z.string().min(1),
    provider: z.string().optional(),
    appBundleId: z.string().nullish(),
    pid: z.number().nullish(),
    notification: z.string().min(1),
    droppedBefore: z.number().gte(0).optional(),
    snapshotId: z.string().nullish(),
    accessibilitySnapshotId: z.string().nullish(),
    metadata: z.record(z.string(), z.unknown()).optional()
});

export const zGetChronicleActivitySegmentsQuery = z.object({
    limit: z.number().optional().default(20)
});

export const zGetChronicleActivitySessionsQuery = z.object({
    limit: z.number().optional().default(20)
});

export const zGetChronicleActivitySessionsBySessionIdPath = z.object({
    sessionId: z.string().min(1)
});

export const zGetChronicleActivitySessionsBySessionIdSnapshotsPath = z.object({
    sessionId: z.string().min(1)
});

export const zGetChronicleActivitySnapshotsBySnapshotIdPath = z.object({
    snapshotId: z.string().min(1)
});

export const zGetChronicleActivitySnapshotsBySnapshotIdOcrPath = z.object({
    snapshotId: z.string().min(1)
});

export const zGetChronicleActivitySegmentsBySegmentIdPath = z.object({
    segmentId: z.string().min(1)
});

export const zPostChronicleActivitySegmentsBySegmentIdTriagePath = z.object({
    segmentId: z.string().min(1)
});

export const zPostChronicleActivitySegmentsBySegmentIdSummarizePath = z.object({
    segmentId: z.string().min(1)
});

export const zPostChronicleActivitySegmentsBySegmentIdCrystallizePath = z.object({
    segmentId: z.string().min(1)
});

export const zGetChroniclePipelineRunsQuery = z.object({
    limit: z.number().optional().default(20)
});

export const zGetChronicleKnowledgeCardsQuery = z.object({
    limit: z.number().optional().default(50),
    dimension: z.enum([
        'technical',
        'business',
        'personal',
        'project',
        'general'
    ]).optional(),
    type: z.enum([
        'fact',
        'insight',
        'decision',
        'task',
        'pattern'
    ]).optional(),
    includeDeleted: z.boolean().optional().default(false)
});

export const zPostChronicleKnowledgeCardsBody = z.object({
    title: z.string().min(1),
    content: z.string().min(1),
    cardType: z.enum([
        'fact',
        'insight',
        'decision',
        'task',
        'pattern'
    ]).optional(),
    dimension: z.enum([
        'technical',
        'business',
        'personal',
        'project',
        'general'
    ]).optional(),
    confidence: z.number().gte(0).lte(1).optional(),
    sourceMemoryIds: z.array(z.string()).optional(),
    sourceSegmentIds: z.array(z.string()).optional(),
    sourceChunkIds: z.array(z.string()).optional(),
    tags: z.array(z.string()).optional(),
    stableKey: z.string().optional(),
    pinned: z.boolean().optional(),
    metadata: z.record(z.string(), z.unknown()).optional()
});

export const zGetChronicleKnowledgeCardsByKnowledgeIdVersionsPath = z.object({
    knowledgeId: z.string().min(1)
});

export const zGetChronicleKnowledgeCardsByKnowledgeIdFilesPath = z.object({
    knowledgeId: z.string().min(1)
});

export const zPostChronicleKnowledgeCardsByKnowledgeIdVersionsRestoreBody = z.object({
    version: z.number().gte(1)
});

export const zPostChronicleKnowledgeCardsByKnowledgeIdVersionsRestorePath = z.object({
    knowledgeId: z.string().min(1)
});

export const zDeleteChronicleKnowledgeCardsByKnowledgeIdPath = z.object({
    knowledgeId: z.string().min(1)
});

export const zGetChronicleKnowledgeCardsByKnowledgeIdPath = z.object({
    knowledgeId: z.string().min(1)
});

export const zPatchChronicleKnowledgeCardsByKnowledgeIdBody = z.object({
    title: z.string().min(1).optional(),
    content: z.string().min(1).optional(),
    cardType: z.enum([
        'fact',
        'insight',
        'decision',
        'task',
        'pattern'
    ]).optional(),
    dimension: z.enum([
        'technical',
        'business',
        'personal',
        'project',
        'general'
    ]).optional(),
    confidence: z.number().gte(0).lte(1).optional(),
    sourceMemoryIds: z.array(z.string()).optional(),
    sourceSegmentIds: z.array(z.string()).optional(),
    sourceChunkIds: z.array(z.string()).optional(),
    tags: z.array(z.string()).optional(),
    pinned: z.boolean().optional(),
    status: z.enum([
        'active',
        'merged',
        'archived',
        'deleted'
    ]).optional(),
    mergedIntoId: z.string().nullish(),
    metadata: z.record(z.string(), z.unknown()).optional()
});

export const zPatchChronicleKnowledgeCardsByKnowledgeIdPath = z.object({
    knowledgeId: z.string().min(1)
});

export const zGetChronicleDreamRunsQuery = z.object({
    limit: z.number().optional().default(20)
});

export const zPostChronicleDreamRunsBody = z.object({
    runType: z.enum([
        'archive',
        'merge',
        'prune',
        'restore',
        'dry-run'
    ]).optional(),
    dryRun: z.boolean().optional(),
    limit: z.number().gte(2).optional(),
    similarityThreshold: z.number().gte(0.1).lte(1).optional(),
    applyMerge: z.boolean().optional(),
    olderThanDays: z.number().gte(0).optional(),
    knowledgeIds: z.array(z.string()).optional()
});

export const zGetChronicleTimelineQuery = z.object({
    limit: z.number().optional().default(50)
});

export const zGetChronicleEventsQuery = z.object({
    limit: z.number().gte(1).lte(500).optional().default(50),
    after: z.number().gte(0).optional()
});

export const zGetChronicleEventsStreamQuery = z.object({
    limit: z.number().gte(1).lte(500).optional().default(50),
    after: z.number().gte(0).optional(),
    intervalMs: z.number().gte(250).lte(30000).optional().default(1000),
    once: z.boolean().optional().default(false)
});

export const zGetChronicleSnapshotsBySnapshotIdFramePath = z.object({
    snapshotId: z.string()
});

export const zGetChronicleFrameByDisplayIdBySegmentByFramePath = z.object({
    displayId: z.string(),
    segment: z.string(),
    frame: z.string()
});

export const zGetChronicleMemoriesSearchQuery = z.object({
    q: z.string().min(1),
    limit: z.number().optional().default(20)
});

export const zDeleteChronicleMemoriesByMemoryIdPath = z.object({
    memoryId: z.string().min(1)
});

export const zGetChronicleMemoriesByMemoryIdPath = z.object({
    memoryId: z.string().min(1)
});

export const zPatchChronicleMemoriesByMemoryIdBody = z.object({
    content: z.string().min(1).optional(),
    metadata: z.record(z.string(), z.unknown()).optional(),
    sourceSnapshotPaths: z.array(z.string()).optional(),
    sourceFramePaths: z.array(z.string()).optional()
});

export const zPatchChronicleMemoriesByMemoryIdPath = z.object({
    memoryId: z.string().min(1)
});

export const zPostChroniclePrivacyRedactBody = z.object({
    text: z.string()
});

export const zPostChroniclePrivacyExportBody = z.object({
    workspaceId: z.string().nullish(),
    limit: z.number().gte(1).optional(),
    includeMemories: z.boolean().optional(),
    includeMessages: z.boolean().optional(),
    includeAudioTranscripts: z.boolean().optional(),
    includeSnapshots: z.boolean().optional(),
    outputFormat: z.enum(['markdown', 'json']).optional()
});

export const zPostChroniclePrivacySnapshotsBySnapshotIdFrameMaskBody = z.object({
    mode: z.enum(['blur']).optional(),
    fullFrame: z.boolean().optional(),
    blurSigma: z.number().gte(1).lte(100).optional(),
    regions: z.array(z.object({
        x: z.number().gte(0),
        y: z.number().gte(0),
        width: z.number().gte(1),
        height: z.number().gte(1)
    })).optional()
});

export const zPostChroniclePrivacySnapshotsBySnapshotIdFrameMaskPath = z.object({
    snapshotId: z.string().min(1)
});

export const zGetChroniclePrivacyBreadcrumbsQuery = z.object({
    limit: z.number().optional().default(50)
});

export const zPostChronicleEmbeddingsBody = z.object({
    texts: z.array(z.string().min(1)).min(1).max(64)
});

export const zDeleteManagedResourcesByNamespaceByResourceTypeByResourceIdPath = z.object({
    namespace: z.string().min(1),
    resourceType: z.string().min(1),
    resourceId: z.string().min(1)
});

export const zGetManagedResourcesByNamespaceByResourceTypeByResourceIdPath = z.object({
    namespace: z.string().min(1),
    resourceType: z.string().min(1),
    resourceId: z.string().min(1)
});

export const zPostManagedResourcesByNamespaceByResourceTypeByResourceIdInstallPath = z.object({
    namespace: z.string().min(1),
    resourceType: z.string().min(1),
    resourceId: z.string().min(1)
});

export const zPostManagedResourcesByNamespaceByResourceTypeByResourceIdUpdatePath = z.object({
    namespace: z.string().min(1),
    resourceType: z.string().min(1),
    resourceId: z.string().min(1)
});

export const zGetAgentSessionsByAgentSessionIdPath = z.object({
    agentSessionId: z.string()
});

export const zGetAgentSessionsByAgentSessionIdActivitiesPath = z.object({
    agentSessionId: z.string()
});

export const zGetDownloadCenterTasksQuery = z.object({
    status: z.enum([
        'queued',
        'downloading',
        'verifying',
        'completed',
        'failed',
        'cancelled'
    ]).optional(),
    ownerNamespace: z.string().min(1).optional(),
    ownerResourceType: z.string().min(1).optional(),
    ownerResourceId: z.string().min(1).optional(),
    limit: z.union([
        z.string(),
        z.number().gte(1).lte(100)
    ]).optional()
});

export const zGetDownloadCenterTasksByIdPath = z.object({
    id: z.string().min(1)
});

export const zPostDownloadCenterTasksByIdCancelPath = z.object({
    id: z.string().min(1)
});

export const zPostTerminalSessionsBySessionIdStartOrAttachBody = z.object({
    cols: z.union([
        z.string(),
        z.int().gte(1)
    ]),
    rows: z.union([
        z.string(),
        z.int().gte(1)
    ])
});

export const zPostTerminalSessionsBySessionIdStartOrAttachPath = z.object({
    sessionId: z.string().min(1)
});

export const zDeleteTerminalSessionsBySessionIdPath = z.object({
    sessionId: z.string().min(1)
});

export const zGetTerminalSessionsBySessionIdHostPath = z.object({
    sessionId: z.string().min(1)
});

export const zDeleteTerminalSessionsBySessionIdProviderSessionPath = z.object({
    sessionId: z.string().min(1)
});

export const zGetTerminalSessionsBySessionIdProviderSessionPath = z.object({
    sessionId: z.string().min(1)
});

export const zPostTerminalSessionsBySessionIdProviderSessionBody = z.object({
    source: z.string().min(1),
    agent: z.string().min(1),
    kind: z.enum(['id', 'path']).optional(),
    value: z.string().min(1).max(512),
    sourcePath: z.string().min(1).optional(),
    confidence: z.enum(['exact', 'heuristic']).optional()
});

export const zPostTerminalSessionsBySessionIdProviderSessionPath = z.object({
    sessionId: z.string().min(1)
});

export const zPostTerminalSessionsShellStartBody = z.object({
    ptyId: z.string().min(1),
    cwd: z.string().min(1),
    cols: z.union([
        z.string(),
        z.int().gte(1)
    ]),
    rows: z.union([
        z.string(),
        z.int().gte(1)
    ])
});

export const zDeleteTerminalSessionsShellByPtyIdPath = z.object({
    ptyId: z.string().min(1)
});

export const zGetObservabilityEventsQuery = z.object({
    chatSessionId: z.string().optional(),
    runId: z.string().optional(),
    code: z.string().optional(),
    severity: z.string().optional(),
    since: z.string().optional(),
    until: z.string().optional(),
    limit: z.string().optional()
});

export const zPostObservabilityEventsBody = z.object({
    source: z.string(),
    code: z.string(),
    severity: z.string(),
    category: z.string(),
    message: z.string(),
    attrs: z.record(z.string(), z.unknown()).optional(),
    chatSessionId: z.string().optional(),
    runId: z.string().optional(),
    messageId: z.string().optional(),
    traceId: z.string().optional(),
    dedupeKey: z.string().optional(),
    parentEventId: z.string().optional(),
    occurredAt: z.number().optional(),
    recordedAt: z.number().optional()
});

export const zPostObservabilityRuntimeSamplesBody = z.object({
    source: z.enum(['desktop-main']),
    sampledAt: z.number(),
    main: z.record(z.string(), z.unknown()),
    appMetrics: z.array(z.record(z.string(), z.unknown())),
    windows: z.array(z.record(z.string(), z.unknown())),
    diagnostics: z.record(z.string(), z.unknown()).optional()
});

export const zGetObservabilityIncidentsQuery = z.object({
    dedupeKey: z.string().optional(),
    chatSessionId: z.string().optional(),
    runId: z.string().optional(),
    code: z.string().optional(),
    status: z.enum(['open', 'resolved']).optional(),
    limit: z.string().optional()
});

export const zGetObservabilityErrorPatternsQuery = z.object({
    chatSessionId: z.string().optional(),
    runId: z.string().optional(),
    code: z.string().optional(),
    runtimeKind: z.string().optional(),
    providerTargetId: z.string().optional(),
    sinceUnix: z.string().optional(),
    limit: z.string().optional()
});

export const zPostObservabilityDiagnosticsHeapSnapshotBody = z.object({
    token: z.string().optional()
});

export const zGetObservabilityExportQuery = z.object({
    chatSessionId: z.string().optional(),
    runId: z.string().optional(),
    sinceUnix: z.string().optional()
});

export const zDeleteIssuesByIdDelegationPath = z.object({
    id: z.string()
});

export const zGetIssuesByIdDelegationPath = z.object({
    id: z.string()
});

export const zPostIssuesByIdDelegationBody = z.object({
    agentId: z.string().min(1),
    providerTargetId: z.string().nullish(),
    runInIsolation: z.boolean().optional()
});

export const zPostIssuesByIdDelegationPath = z.object({
    id: z.string()
});

export const zGetIssuesByIdAgentSessionsPath = z.object({
    id: z.string()
});

export const zGetIssueAgentSessionsByAgentSessionIdActivitiesPath = z.object({
    agentSessionId: z.string()
});

export const zPostIssueAgentSessionsByAgentSessionIdContinuationBody = z.object({
    mode: z.enum(['queue', 'steer']),
    text: z.string().min(1)
});

export const zPostIssueAgentSessionsByAgentSessionIdContinuationPath = z.object({
    agentSessionId: z.string()
});

export const zPostIssueAgentSessionsByAgentSessionIdRerunBody = z.record(z.string(), z.unknown());

export const zPostIssueAgentSessionsByAgentSessionIdRerunPath = z.object({
    agentSessionId: z.string()
});

export const zDeleteIssueAgentSessionsByAgentSessionIdPath = z.object({
    agentSessionId: z.string()
});
