dify/e2e/features/step-definitions/agent-v2/preflight.steps.ts
yyh d0ea5a5e0d
chore(agent-v2): sync changes (#38442)
Co-authored-by: Joel <iamjoel007@gmail.com>
Co-authored-by: zyssyz123 <916125788@qq.com>
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
Co-authored-by: 林玮 (Jade Lin) <linw1995@icloud.com>
Co-authored-by: 盐粒 Yanli <mail@yanli.one>
2026-07-06 13:51:33 +00:00

216 lines
7.5 KiB
TypeScript

import type { DifyWorld } from '../../support/world'
import { Given } from '@cucumber/cucumber'
import {
skipMissingPreseededAgentBackendApiKey,
skipMissingPreseededAgentPublishedWebApp,
skipMissingPreseededAgentWorkflowReference,
} from '../../agent-v2/support/preflight/access'
import { skipMissingAgentBackendRuntime } from '../../agent-v2/support/preflight/agent-backend'
import {
skipMissingPreseededAgent,
skipMissingPreseededAgentDriveSkill,
skipMissingPreseededDualRetrievalAgentConfiguration,
skipMissingPreseededFullConfigAgentCoreConfiguration,
skipMissingPreseededOAuthToolAgentConfiguration,
skipMissingPreseededToolStatesAgentConfiguration,
skipMissingPreseededWorkflow,
} from '../../agent-v2/support/preflight/agents'
import {
skipMissingIndexingPreseededDataset,
skipMissingPreseededDataset,
skipMissingReadyPreseededDataset,
} from '../../agent-v2/support/preflight/datasets'
import {
skipMissingAgentBuilderAgentDecisionChatModel,
skipMissingAgentBuilderBrokenChatModel,
skipMissingAgentBuilderStableChatModel,
} from '../../agent-v2/support/preflight/models'
import { skipMissingPreseededTool } from '../../agent-v2/support/preflight/tools'
Given('the Agent Builder stable chat model is available', async function (this: DifyWorld) {
const stableModel = await skipMissingAgentBuilderStableChatModel(this)
if (stableModel === 'skipped')
return stableModel
this.agentBuilder.preflight.stableModel = stableModel
})
Given('the Agent Builder agent-decision chat model is available', async function (this: DifyWorld) {
const agentDecisionModel = await skipMissingAgentBuilderAgentDecisionChatModel(this)
if (agentDecisionModel === 'skipped')
return agentDecisionModel
this.agentBuilder.preflight.agentDecisionModel = agentDecisionModel
})
Given('the Agent Builder broken chat model is available', async function (this: DifyWorld) {
const brokenModel = await skipMissingAgentBuilderBrokenChatModel(this)
if (brokenModel === 'skipped')
return brokenModel
this.agentBuilder.preflight.brokenModel = brokenModel
})
Given('the Agent v2 runtime backend is available', async function (this: DifyWorld) {
const runtimeBackend = await skipMissingAgentBackendRuntime(this)
if (runtimeBackend === 'skipped')
return runtimeBackend
})
Given(
'the Agent Builder preseeded Agent {string} is available',
async function (this: DifyWorld, resourceName: string) {
const resource = await skipMissingPreseededAgent(this, resourceName)
if (resource === 'skipped')
return resource
this.agentBuilder.preflight.preseededResources[resourceName] = resource
},
)
Given(
'the Agent Builder preseeded workflow {string} is available',
async function (this: DifyWorld, resourceName: string) {
const resource = await skipMissingPreseededWorkflow(this, resourceName)
if (resource === 'skipped')
return resource
this.agentBuilder.preflight.preseededResources[resourceName] = resource
},
)
Given(
'the Agent Builder preseeded dataset {string} is available',
async function (this: DifyWorld, resourceName: string) {
const resource = await skipMissingPreseededDataset(this, resourceName)
if (resource === 'skipped')
return resource
this.agentBuilder.preflight.preseededResources[resourceName] = resource
},
)
Given(
'the Agent Builder preseeded dataset {string} is indexed and ready',
async function (this: DifyWorld, resourceName: string) {
const resource = await skipMissingReadyPreseededDataset(this, resourceName)
if (resource === 'skipped')
return resource
this.agentBuilder.preflight.preseededResources[resourceName] = resource
},
)
Given(
'the Agent Builder preseeded dataset {string} is indexing',
async function (this: DifyWorld, resourceName: string) {
const resource = await skipMissingIndexingPreseededDataset(this, resourceName)
if (resource === 'skipped')
return resource
this.agentBuilder.preflight.preseededResources[resourceName] = resource
},
)
Given(
'the Agent Builder preseeded tool {string} is available',
async function (this: DifyWorld, resourceName: string) {
const resource = await skipMissingPreseededTool(this, resourceName)
if (resource === 'skipped')
return resource
this.agentBuilder.preflight.preseededResources[resourceName] = resource
},
)
Given(
'the Agent Builder preseeded Agent {string} includes drive skill {string}',
async function (this: DifyWorld, agentName: string, skillName: string) {
const resource = await skipMissingPreseededAgentDriveSkill(this, agentName, skillName)
if (resource === 'skipped')
return resource
this.agentBuilder.preflight.preseededResources[`${agentName} / ${skillName}`] = resource
},
)
Given(
'the Agent Builder preseeded Agent {string} includes the core fixture configuration',
async function (this: DifyWorld, agentName: string) {
const resource = await skipMissingPreseededFullConfigAgentCoreConfiguration(this, agentName)
if (resource === 'skipped')
return resource
this.agentBuilder.preflight.preseededResources[`${agentName} / core fixture configuration`] = resource
},
)
Given(
'the Agent Builder preseeded Agent {string} includes the tool state fixture configuration',
async function (this: DifyWorld, agentName: string) {
const resource = await skipMissingPreseededToolStatesAgentConfiguration(this, agentName)
if (resource === 'skipped')
return resource
this.agentBuilder.preflight.preseededResources[`${agentName} / tool state fixture configuration`]
= resource
},
)
Given(
'the Agent Builder preseeded Agent {string} includes an OAuth2 tool credential',
async function (this: DifyWorld, agentName: string) {
const resource = await skipMissingPreseededOAuthToolAgentConfiguration(this, agentName)
if (resource === 'skipped')
return resource
this.agentBuilder.preflight.preseededResources[`${agentName} / OAuth2 tool credential`]
= resource
},
)
Given(
'the Agent Builder preseeded Agent {string} includes the dual retrieval fixture configuration',
async function (this: DifyWorld, agentName: string) {
const resource = await skipMissingPreseededDualRetrievalAgentConfiguration(this, agentName)
if (resource === 'skipped')
return resource
this.agentBuilder.preflight.preseededResources[`${agentName} / dual retrieval fixture configuration`]
= resource
},
)
Given(
'the Agent Builder preseeded Agent {string} has Backend service API access with an API key',
async function (this: DifyWorld, agentName: string) {
const resource = await skipMissingPreseededAgentBackendApiKey(this, agentName)
if (resource === 'skipped')
return resource
this.agentBuilder.preflight.preseededResources[`${agentName} / Backend service API key`] = resource
},
)
Given(
'the Agent Builder preseeded Agent {string} has published Web app access',
async function (this: DifyWorld, agentName: string) {
const resource = await skipMissingPreseededAgentPublishedWebApp(this, agentName)
if (resource === 'skipped')
return resource
this.agentBuilder.preflight.preseededResources[`${agentName} / Web app`] = resource
},
)
Given(
'the Agent Builder preseeded Agent {string} is referenced by workflow {string}',
async function (this: DifyWorld, agentName: string, workflowName: string) {
const resource = await skipMissingPreseededAgentWorkflowReference(this, agentName, workflowName)
if (resource === 'skipped')
return resource
this.agentBuilder.preflight.preseededResources[`${agentName} / ${workflowName}`] = resource
},
)