MCPcopy
hub / github.com/thesysdev/openui / OpenUIContextValue

Interface OpenUIContextValue

packages/svelte-lang/src/lib/context.svelte.ts:19–56  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

17 * This avoids the stale-closure problem and matches Svelte's snippet model.
18 */
19export interface OpenUIContextValue {
20 /** The active component library (schema + renderers). */
21 library: Library;
22
23 /**
24 * Trigger an action. Components call this to fire structured ActionEvents.
25 *
26 * @param userMessage Human-readable label ("Submit Application")
27 * @param formName Optional form name — if provided, form state for this form is included
28 * @param action Optional custom action config { type, params }
29 */
30 triggerAction: (userMessage: string, formName?: string, action?: ActionConfig) => void;
31
32 /** Whether the LLM is currently streaming content. */
33 isStreaming: boolean;
34
35 /** Get a form field value. Returns undefined if not set. */
36 getFieldValue: (formName: string | undefined, name: string) => any;
37
38 /**
39 * Set a form field value.
40 *
41 * @param formName The form's name prop
42 * @param componentType The component type (e.g. "Input", "Select", "RadioGroup")
43 * @param name The field's name prop
44 * @param value The new value
45 * @param shouldTriggerSaveCallback When true, persists the updated state via updateMessage.
46 * Text inputs should pass `false` on change and `true` on blur.
47 * Discrete inputs (Select, RadioGroup, etc.) should always pass `true`.
48 */
49 setFieldValue: (
50 formName: string | undefined,
51 componentType: string | undefined,
52 name: string,
53 value: any,
54 shouldTriggerSaveCallback?: boolean,
55 ) => void;
56}
57
58const OPENUI_CONTEXT_KEY = Symbol("openui-context");
59const FORM_NAME_CONTEXT_KEY = Symbol("openui-form-name");

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected