mirror of
https://github.com/langgenius/dify.git
synced 2026-07-21 18:58:35 +08:00
Signed-off-by: yyh <yuanyouhuilyz@gmail.com> Co-authored-by: 盐粒 Yanli <mail@yanli.one> 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: 盐粒 Yanli <yanli@dify.ai> Co-authored-by: 林玮 (Jade Lin) <linw1995@icloud.com>
26 lines
1.0 KiB
TypeScript
26 lines
1.0 KiB
TypeScript
import type { DifyWorld } from '../../support/world'
|
|
import { splitToolDisplayName, splitToolResourceId } from './preflight/tools'
|
|
|
|
export const getPreseededToolContract = (world: DifyWorld, resourceName: string) => {
|
|
const resource = world.agentBuilder.preflight.preseededResources[resourceName]
|
|
if (!resource || resource.kind !== 'tool') {
|
|
throw new Error(
|
|
`Preseeded tool "${resourceName}" is not available. Run the matching preflight 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,
|
|
}
|
|
}
|