mirror of
https://github.com/langgenius/dify.git
synced 2026-09-08 02:43:49 +08:00
Co-authored-by: yunlu.wen <yunlu.wen@dify.ai> Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com> Co-authored-by: Yunlu Wen <wylswz@163.com> Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> Co-authored-by: Joel <iamjoel007@gmail.com> Co-authored-by: Yanli 盐粒 <yanli@dify.ai> Co-authored-by: 盐粒 Yanli <beautyyuyanli@gmail.com> Co-authored-by: zyssyz123 <916125788@qq.com> Co-authored-by: 盐粒 Yanli <mail@yanli.one>
49 lines
1.2 KiB
TypeScript
49 lines
1.2 KiB
TypeScript
'use client'
|
|
|
|
import { useAtomValue } from 'jotai'
|
|
import { createContext, use } from 'react'
|
|
import { agentComposerFilesAtom } from '@/features/agent-v2/agent-composer/store-modules/files'
|
|
import { agentComposerSkillsAtom } from '@/features/agent-v2/agent-composer/store-modules/skills'
|
|
|
|
export type AgentConfigApiContext = {
|
|
agentId: string
|
|
draftType?: 'draft' | 'debug_build'
|
|
versionId?: string
|
|
workflow?: {
|
|
appId: string
|
|
nodeId: string
|
|
}
|
|
}
|
|
|
|
const AgentConfigApiContext = createContext<AgentConfigApiContext | null>(null)
|
|
|
|
export const AgentConfigApiContextProvider = AgentConfigApiContext.Provider
|
|
|
|
export const useAgentConfigApiContext = () => {
|
|
const context = use(AgentConfigApiContext)
|
|
if (!context)
|
|
throw new Error('AgentConfigApiContextProvider is required for config-backed UI.')
|
|
|
|
return context
|
|
}
|
|
|
|
export const useAgentConfigSkills = () => {
|
|
const apiContext = useAgentConfigApiContext()
|
|
const skills = useAtomValue(agentComposerSkillsAtom)
|
|
|
|
return {
|
|
apiContext,
|
|
skills,
|
|
}
|
|
}
|
|
|
|
export const useAgentConfigFiles = () => {
|
|
const apiContext = useAgentConfigApiContext()
|
|
const files = useAtomValue(agentComposerFilesAtom)
|
|
|
|
return {
|
|
apiContext,
|
|
files,
|
|
}
|
|
}
|