dify/packages/contracts/generated/api/console/agents/zod.gen.ts
yyh 2d6c9300e3
fix(api): tighten agent v2 generated contracts (#36989)
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2026-06-03 06:52:40 +00:00

644 lines
17 KiB
TypeScript

// This file is auto-generated by @hey-api/openapi-ts
import * as z from 'zod'
/**
* AgentIconType
*
* Supported icon storage formats for Agent roster entries.
*/
export const zAgentIconType = z.enum(['emoji', 'image', 'link'])
/**
* RosterAgentUpdatePayload
*/
export const zRosterAgentUpdatePayload = z.object({
description: z.string().nullish(),
icon: z.string().max(255).nullish(),
icon_background: z.string().max(255).nullish(),
icon_type: zAgentIconType.optional(),
name: z.string().min(1).max(255).nullish(),
})
/**
* AgentConfigSnapshotSummaryResponse
*/
export const zAgentConfigSnapshotSummaryResponse = z.object({
agent_id: z.string().nullish(),
created_at: z.string().nullish(),
created_by: z.string().nullish(),
id: z.string(),
summary: z.string().nullish(),
version: z.int(),
version_note: z.string().nullish(),
})
/**
* AgentConfigSnapshotListResponse
*/
export const zAgentConfigSnapshotListResponse = z.object({
data: z.array(zAgentConfigSnapshotSummaryResponse),
})
/**
* AgentKind
*
* Agent implementation family.
*
* This leaves room for future non-Dify agent implementations while keeping
* the current roster/workflow APIs scoped to Dify Agent.
*/
export const zAgentKind = z.enum(['dify_agent'])
/**
* AgentScope
*
* Visibility and lifecycle scope of an Agent record.
*/
export const zAgentScope = z.enum(['roster', 'workflow_only'])
/**
* AgentSource
*
* Origin that created or imported the Agent.
*/
export const zAgentSource = z.enum(['agent_app', 'imported', 'system', 'workflow'])
/**
* AgentStatus
*
* Soft lifecycle state for Agent records.
*/
export const zAgentStatus = z.enum(['active', 'archived'])
/**
* AgentRosterResponse
*/
export const zAgentRosterResponse = z.object({
active_config_snapshot: zAgentConfigSnapshotSummaryResponse.optional(),
active_config_snapshot_id: z.string().nullish(),
agent_kind: zAgentKind,
app_id: z.string().nullish(),
archived_at: z.string().nullish(),
archived_by: z.string().nullish(),
created_at: z.string().nullish(),
created_by: z.string().nullish(),
description: z.string(),
icon: z.string().nullish(),
icon_background: z.string().nullish(),
icon_type: zAgentIconType.optional(),
id: z.string(),
name: z.string(),
scope: zAgentScope,
source: zAgentSource,
status: zAgentStatus,
updated_at: z.string().nullish(),
updated_by: z.string().nullish(),
workflow_id: z.string().nullish(),
workflow_node_id: z.string().nullish(),
})
/**
* AgentRosterListResponse
*/
export const zAgentRosterListResponse = z.object({
data: z.array(zAgentRosterResponse),
has_more: z.boolean(),
limit: z.int(),
page: z.int(),
total: z.int(),
})
/**
* AgentInviteOptionResponse
*/
export const zAgentInviteOptionResponse = z.object({
active_config_snapshot: zAgentConfigSnapshotSummaryResponse.optional(),
active_config_snapshot_id: z.string().nullish(),
agent_kind: zAgentKind,
app_id: z.string().nullish(),
archived_at: z.string().nullish(),
archived_by: z.string().nullish(),
created_at: z.string().nullish(),
created_by: z.string().nullish(),
description: z.string(),
existing_node_ids: z.array(z.string()).optional(),
icon: z.string().nullish(),
icon_background: z.string().nullish(),
icon_type: zAgentIconType.optional(),
id: z.string(),
in_current_workflow_count: z.int().optional().default(0),
is_in_current_workflow: z.boolean().optional().default(false),
name: z.string(),
scope: zAgentScope,
source: zAgentSource,
status: zAgentStatus,
updated_at: z.string().nullish(),
updated_by: z.string().nullish(),
workflow_id: z.string().nullish(),
workflow_node_id: z.string().nullish(),
})
/**
* AgentInviteOptionsResponse
*/
export const zAgentInviteOptionsResponse = z.object({
data: z.array(zAgentInviteOptionResponse),
has_more: z.boolean(),
limit: z.int(),
page: z.int(),
total: z.int(),
})
/**
* AppVariableConfig
*/
export const zAppVariableConfig = z.object({
default: z.unknown().optional(),
name: z.string().min(1).max(255),
required: z.boolean().optional().default(false),
type: z.string().min(1).max(64),
})
/**
* AgentSoulPromptConfig
*/
export const zAgentSoulPromptConfig = z.object({
system_prompt: z.string().optional().default(''),
})
/**
* AgentConfigRevisionOperation
*
* Audit operation recorded for Agent Soul version/revision changes.
*/
export const zAgentConfigRevisionOperation = z.enum([
'create_version',
'save_current_version',
'save_new_agent',
'save_new_version',
'save_to_roster',
])
/**
* AgentConfigRevisionResponse
*/
export const zAgentConfigRevisionResponse = z.object({
created_at: z.string().nullish(),
created_by: z.string().nullish(),
current_snapshot_id: z.string(),
id: z.string(),
operation: zAgentConfigRevisionOperation,
previous_snapshot_id: z.string().nullish(),
revision: z.int(),
summary: z.string().nullish(),
version_note: z.string().nullish(),
})
/**
* AgentFeatureToggleConfig
*/
export const zAgentFeatureToggleConfig = z.object({
enabled: z.boolean().optional().default(false),
})
/**
* AgentTextToSpeechFeatureConfig
*/
export const zAgentTextToSpeechFeatureConfig = z.object({
autoPlay: z.string().nullish(),
enabled: z.boolean().optional().default(false),
language: z.string().nullish(),
voice: z.string().nullish(),
})
/**
* AgentSecretRefConfig
*/
export const zAgentSecretRefConfig = z.object({
id: z.string().max(255).nullish(),
name: z.string().max(255).nullish(),
provider: z.string().max(255).nullish(),
type: z.string().max(64).nullish(),
})
/**
* AgentEnvVariableConfig
*/
export const zAgentEnvVariableConfig = z.object({
name: z.string().max(255).nullish(),
required: z.boolean().optional().default(false),
type: z.string().max(64).nullish(),
value: z.unknown().optional(),
})
/**
* AgentSoulEnvConfig
*/
export const zAgentSoulEnvConfig = z.object({
secret_refs: z.array(zAgentSecretRefConfig).optional(),
variables: z.array(zAgentEnvVariableConfig).optional(),
})
/**
* AgentHumanContactConfig
*/
export const zAgentHumanContactConfig = z.object({
contact_id: z.string().max(255).nullish(),
email: z.string().max(255).nullish(),
human_id: z.string().max(255).nullish(),
id: z.string().max(255).nullish(),
name: z.string().max(255).nullish(),
})
/**
* AgentHumanToolConfig
*/
export const zAgentHumanToolConfig = z.object({
description: z.string().nullish(),
enabled: z.boolean().optional().default(true),
name: z.string().max(255).nullish(),
})
/**
* AgentSoulHumanConfig
*/
export const zAgentSoulHumanConfig = z.object({
contacts: z.array(zAgentHumanContactConfig).optional(),
tools: z.array(zAgentHumanToolConfig).optional(),
})
/**
* AgentKnowledgeDatasetConfig
*/
export const zAgentKnowledgeDatasetConfig = z.object({
description: z.string().nullish(),
id: z.string().max(255).nullish(),
name: z.string().max(255).nullish(),
})
/**
* AgentKnowledgeQueryConfig
*/
export const zAgentKnowledgeQueryConfig = z.object({
query: z.string().nullish(),
score_threshold: z.number().gte(0).lte(1).nullish(),
score_threshold_enabled: z.boolean().nullish(),
top_k: z.int().gte(1).nullish(),
})
/**
* AgentKnowledgeQueryMode
*/
export const zAgentKnowledgeQueryMode = z.enum(['generated_query', 'user_query'])
/**
* AgentSoulKnowledgeConfig
*/
export const zAgentSoulKnowledgeConfig = z.object({
datasets: z.array(zAgentKnowledgeDatasetConfig).optional(),
query_config: zAgentKnowledgeQueryConfig.optional(),
query_mode: zAgentKnowledgeQueryMode.optional(),
})
/**
* AgentMemoryArtifactConfig
*/
export const zAgentMemoryArtifactConfig = z.object({
id: z.string().max(255).nullish(),
name: z.string().max(255).nullish(),
type: z.string().max(64).nullish(),
url: z.string().nullish(),
})
/**
* AgentSoulMemoryConfig
*/
export const zAgentSoulMemoryConfig = z.object({
artifacts: z.array(zAgentMemoryArtifactConfig).optional(),
budget: z.string().nullish(),
scope: z.string().nullish(),
})
/**
* AgentSoulModelCredentialRef
*
* Reference to model credentials resolved only at runtime.
*/
export const zAgentSoulModelCredentialRef = z.object({
id: z.string().max(255).nullish(),
provider: z.string().max(255).nullish(),
type: z.string().min(1).max(64),
})
/**
* AgentSandboxProviderConfig
*/
export const zAgentSandboxProviderConfig = z.object({
env: z.array(zAgentEnvVariableConfig).optional(),
image: z.string().nullish(),
working_dir: z.string().nullish(),
})
/**
* AgentSoulSandboxConfig
*/
export const zAgentSoulSandboxConfig = z.object({
config: zAgentSandboxProviderConfig.optional(),
provider: z.string().nullish(),
})
/**
* AgentFileRefConfig
*/
export const zAgentFileRefConfig = z.object({
id: z.string().max(255).nullish(),
name: z.string().max(255).nullish(),
transfer_method: z.string().max(64).nullish(),
type: z.string().max(64).nullish(),
url: z.string().nullish(),
})
/**
* AgentSkillRefConfig
*/
export const zAgentSkillRefConfig = z.object({
description: z.string().nullish(),
file_id: z.string().max(255).nullish(),
id: z.string().max(255).nullish(),
name: z.string().max(255).nullish(),
path: z.string().nullish(),
})
/**
* AgentSoulSkillsFilesConfig
*/
export const zAgentSoulSkillsFilesConfig = z.object({
files: z.array(zAgentFileRefConfig).optional(),
skills: z.array(zAgentSkillRefConfig).optional(),
})
/**
* AgentCliToolConfig
*/
export const zAgentCliToolConfig = z.object({
command: z.string().nullish(),
description: z.string().nullish(),
enabled: z.boolean().optional().default(true),
name: z.string().max(255).nullish(),
})
/**
* AgentModelResponseFormatConfig
*/
export const zAgentModelResponseFormatConfig = z.object({
type: z.string().max(64).nullish(),
})
/**
* AgentSoulModelSettings
*/
export const zAgentSoulModelSettings = z.object({
frequency_penalty: z.number().nullish(),
max_tokens: z.int().nullish(),
presence_penalty: z.number().nullish(),
response_format: zAgentModelResponseFormatConfig.optional(),
stop: z.array(z.string()).nullish(),
temperature: z.number().nullish(),
top_p: z.number().nullish(),
})
/**
* AgentSoulModelConfig
*
* Stable model selection for Agent runtime without storing secret values.
*/
export const zAgentSoulModelConfig = z.object({
credential_ref: zAgentSoulModelCredentialRef.optional(),
model: z.string().min(1).max(255),
model_provider: z.string().min(1).max(255),
model_settings: zAgentSoulModelSettings.optional(),
plugin_id: z.string().min(1).max(255),
})
/**
* AgentSuggestedQuestionsAfterAnswerFeatureConfig
*/
export const zAgentSuggestedQuestionsAfterAnswerFeatureConfig = z.object({
enabled: z.boolean().optional().default(false),
model: zAgentSoulModelConfig.optional(),
prompt: z.string().nullish(),
})
/**
* AgentSoulDifyToolCredentialRef
*
* Reference to a stored Dify Plugin Tool credential.
*
* Secret values are resolved only at runtime. The legacy ``credential_id``
* field is accepted by :class:`AgentSoulDifyToolConfig` and normalized here so
* old Agent tool payloads can be read while new payloads stay explicit.
*/
export const zAgentSoulDifyToolCredentialRef = z.object({
id: z.string().max(255).nullish(),
provider: z.string().max(255).nullish(),
type: z.enum(['provider', 'tool']).optional().default('tool'),
})
/**
* AgentSoulDifyToolConfig
*
* One Dify Plugin Tool configured on Agent Soul.
*
* The API backend prepares this persisted product shape into
* ``DifyPluginToolConfig`` before sending a run request to Agent backend.
* ``provider_id`` keeps compatibility with existing Agent tool config payloads;
* new callers should send ``plugin_id`` + ``provider`` when available.
*/
export const zAgentSoulDifyToolConfig = z.object({
credential_ref: zAgentSoulDifyToolCredentialRef.optional(),
credential_type: z.enum(['api-key', 'oauth2', 'unauthorized']).optional().default('api-key'),
description: z.string().nullish(),
enabled: z.boolean().optional().default(true),
name: z.string().max(255).nullish(),
plugin_id: z.string().max(255).nullish(),
provider: z.string().max(255).nullish(),
provider_id: z.string().max(255).nullish(),
provider_type: z.string().optional().default('plugin'),
runtime_parameters: z.record(z.string(), z.unknown()).optional(),
tool_name: z.string().min(1).max(255),
})
/**
* AgentSoulToolsConfig
*/
export const zAgentSoulToolsConfig = z.object({
cli_tools: z.array(zAgentCliToolConfig).optional(),
dify_tools: z.array(zAgentSoulDifyToolConfig).optional(),
})
/**
* AgentModerationIOConfig
*/
export const zAgentModerationIoConfig = z.object({
enabled: z.boolean().optional().default(false),
preset_response: z.string().nullish(),
})
/**
* AgentModerationProviderConfig
*/
export const zAgentModerationProviderConfig = z.object({
api_based_extension_id: z.string().nullish(),
inputs_config: zAgentModerationIoConfig.optional(),
keywords: z.string().nullish(),
outputs_config: zAgentModerationIoConfig.optional(),
})
/**
* AgentSensitiveWordAvoidanceFeatureConfig
*/
export const zAgentSensitiveWordAvoidanceFeatureConfig = z.object({
config: zAgentModerationProviderConfig.optional(),
enabled: z.boolean().optional().default(false),
type: z.string().nullish(),
})
/**
* AgentSoulAppFeaturesConfig
*/
export const zAgentSoulAppFeaturesConfig = z.object({
opening_statement: z.string().nullish(),
retriever_resource: zAgentFeatureToggleConfig.optional(),
sensitive_word_avoidance: zAgentSensitiveWordAvoidanceFeatureConfig.optional(),
speech_to_text: zAgentFeatureToggleConfig.optional(),
suggested_questions: z.array(z.string()).nullish(),
suggested_questions_after_answer: zAgentSuggestedQuestionsAfterAnswerFeatureConfig.optional(),
text_to_speech: zAgentTextToSpeechFeatureConfig.optional(),
})
/**
* AgentSoulConfig
*/
export const zAgentSoulConfig = z.object({
app_features: zAgentSoulAppFeaturesConfig.optional(),
app_variables: z.array(zAppVariableConfig).optional(),
env: zAgentSoulEnvConfig.optional(),
human: zAgentSoulHumanConfig.optional(),
knowledge: zAgentSoulKnowledgeConfig.optional(),
memory: zAgentSoulMemoryConfig.optional(),
misc_legacy: zAgentSoulAppFeaturesConfig.optional(),
model: zAgentSoulModelConfig.optional(),
prompt: zAgentSoulPromptConfig.optional(),
sandbox: zAgentSoulSandboxConfig.optional(),
schema_version: z.int().optional().default(1),
skills_files: zAgentSoulSkillsFilesConfig.optional(),
tools: zAgentSoulToolsConfig.optional(),
})
/**
* RosterAgentCreatePayload
*/
export const zRosterAgentCreatePayload = z.object({
agent_soul: zAgentSoulConfig.optional(),
description: z.string().optional().default(''),
icon: z.string().max(255).nullish(),
icon_background: z.string().max(255).nullish(),
icon_type: zAgentIconType.optional(),
name: z.string().min(1).max(255),
version_note: z.string().nullish(),
})
/**
* AgentConfigSnapshotDetailResponse
*/
export const zAgentConfigSnapshotDetailResponse = z.object({
agent_id: z.string().nullish(),
config_snapshot: zAgentSoulConfig,
created_at: z.string().nullish(),
created_by: z.string().nullish(),
id: z.string(),
revisions: z.array(zAgentConfigRevisionResponse).optional(),
summary: z.string().nullish(),
version: z.int(),
version_note: z.string().nullish(),
})
export const zGetAgentsQuery = z.object({
keyword: z.string().optional(),
limit: z.int().gte(1).lte(100).optional().default(20),
page: z.int().gte(1).optional().default(1),
})
/**
* Agent roster list
*/
export const zGetAgentsResponse = zAgentRosterListResponse
export const zPostAgentsBody = zRosterAgentCreatePayload
/**
* Agent created
*/
export const zPostAgentsResponse = zAgentRosterResponse
export const zGetAgentsInviteOptionsQuery = z.object({
app_id: z.string().optional(),
keyword: z.string().optional(),
limit: z.int().gte(1).lte(100).optional().default(20),
page: z.int().gte(1).optional().default(1),
})
/**
* Agent invite options
*/
export const zGetAgentsInviteOptionsResponse = zAgentInviteOptionsResponse
export const zDeleteAgentsByAgentIdPath = z.object({
agent_id: z.string(),
})
/**
* Agent archived
*/
export const zDeleteAgentsByAgentIdResponse = z.record(z.string(), z.never())
export const zGetAgentsByAgentIdPath = z.object({
agent_id: z.string(),
})
/**
* Agent detail
*/
export const zGetAgentsByAgentIdResponse = zAgentRosterResponse
export const zPatchAgentsByAgentIdBody = zRosterAgentUpdatePayload
export const zPatchAgentsByAgentIdPath = z.object({
agent_id: z.string(),
})
/**
* Agent updated
*/
export const zPatchAgentsByAgentIdResponse = zAgentRosterResponse
export const zGetAgentsByAgentIdVersionsPath = z.object({
agent_id: z.string(),
})
/**
* Agent versions
*/
export const zGetAgentsByAgentIdVersionsResponse = zAgentConfigSnapshotListResponse
export const zGetAgentsByAgentIdVersionsByVersionIdPath = z.object({
agent_id: z.string(),
version_id: z.string(),
})
/**
* Agent version detail
*/
export const zGetAgentsByAgentIdVersionsByVersionIdResponse = zAgentConfigSnapshotDetailResponse