Skip to content

armgit / dify

Public Imported from GitHub
0

Build Agentic workflows, RAG pipelines, with rich AI model and tool support on one collaborative workspace. Deploy on cloud, VPC, or self-hosted, so teams move from prototype to production without rebuilding the stack.

1.0 KB
Raw Blame
import type { DifyWorld } from '../../support/world.ts'
import { splitToolDisplayName, splitToolResourceId } from './fixtures/tools.ts'

export const getPreseededToolContract = (world: DifyWorld, resourceName: string) => {
  const resource = world.agentBuilder.fixtures.preseededResources[resourceName]
  if (!resource || resource.kind !== 'tool') {
    throw new Error(
      `Preseeded tool "${resourceName}" is not available. Run the matching fixture setup step first.`,
    )
  }

  const parsedDisplayName = splitToolDisplayName(resource.name)
  const parsedToolId = splitToolResourceId(resource.id)
  if (!parsedDisplayName.ok) throw new Error(parsedDisplayName.reason)
  if (!parsedToolId.providerName || !parsedToolId.toolName)
    throw new Error(`Preseeded tool "${resource.id}" must include provider and tool id segments.`)

  return {
    providerDisplayName: parsedDisplayName.providerName,
    providerName: parsedToolId.providerName,
    toolDisplayName: parsedDisplayName.toolName,
    toolName: parsedToolId.toolName,
  }
}