mirror of
https://github.com/langgenius/dify.git
synced 2026-07-24 04:58:32 +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>
40 lines
1.0 KiB
TypeScript
40 lines
1.0 KiB
TypeScript
'use client'
|
|
|
|
import type { AgentSoulConfig } from '@dify/contracts/api/console/agent/types.gen'
|
|
import type { ReactNode } from 'react'
|
|
import type { AgentSoulConfigFormState } from './form-state'
|
|
import { ScopeProvider } from 'jotai-scope'
|
|
import { defaultAgentSoulConfigFormState } from './form-state'
|
|
import {
|
|
agentComposerDraftAtom,
|
|
agentComposerOriginalConfigAtom,
|
|
agentComposerOriginalDraftAtom,
|
|
agentComposerPublishedDraftAtom,
|
|
} from './store'
|
|
|
|
export function AgentComposerProvider({
|
|
children,
|
|
initialDraft,
|
|
initialOriginalConfig,
|
|
}: {
|
|
children: ReactNode
|
|
initialDraft?: AgentSoulConfigFormState
|
|
initialOriginalConfig?: AgentSoulConfig
|
|
}) {
|
|
const draft = initialDraft ?? defaultAgentSoulConfigFormState
|
|
|
|
return (
|
|
<ScopeProvider
|
|
atoms={[
|
|
[agentComposerOriginalConfigAtom, initialOriginalConfig],
|
|
[agentComposerDraftAtom, draft],
|
|
[agentComposerOriginalDraftAtom, draft],
|
|
[agentComposerPublishedDraftAtom, draft],
|
|
]}
|
|
name="AgentComposer"
|
|
>
|
|
{children}
|
|
</ScopeProvider>
|
|
)
|
|
}
|