mirror of
https://github.com/langgenius/dify.git
synced 2026-07-30 08:49:31 +08:00
30 lines
725 B
TypeScript
30 lines
725 B
TypeScript
'use client'
|
|
|
|
import type { ReactNode } from 'react'
|
|
import type { AgentSoulConfigFormState } from './form-state'
|
|
import { ScopeProvider } from 'jotai-scope'
|
|
import { defaultAgentSoulConfigFormState } from './form-state'
|
|
import { agentComposerDraftAtom, agentComposerSavedDraftAtom } from './store'
|
|
|
|
export function AgentComposerProvider({
|
|
children,
|
|
initialDraft,
|
|
}: {
|
|
children: ReactNode
|
|
initialDraft?: AgentSoulConfigFormState
|
|
}) {
|
|
const draft = initialDraft ?? defaultAgentSoulConfigFormState
|
|
|
|
return (
|
|
<ScopeProvider
|
|
atoms={[
|
|
[agentComposerDraftAtom, draft],
|
|
[agentComposerSavedDraftAtom, draft],
|
|
]}
|
|
name="AgentComposer"
|
|
>
|
|
{children}
|
|
</ScopeProvider>
|
|
)
|
|
}
|