@lynx-js/genui 0.0.2 → 0.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5 -9
- package/a2ui/AGENTS.md +167 -0
- package/a2ui/README.md +76 -780
- package/a2ui/README_zh.md +103 -0
- package/a2ui/dist/catalog/Button/catalog.json +2 -1
- package/a2ui/dist/catalog/Button/index.d.ts +5 -0
- package/a2ui/dist/catalog/Button/index.jsx +3 -0
- package/a2ui/dist/catalog/Button/index.jsx.map +1 -1
- package/a2ui/dist/catalog/Card/catalog.json +2 -1
- package/a2ui/dist/catalog/Card/index.d.ts +5 -0
- package/a2ui/dist/catalog/Card/index.jsx +3 -0
- package/a2ui/dist/catalog/Card/index.jsx.map +1 -1
- package/a2ui/dist/catalog/CheckBox/catalog.json +2 -1
- package/a2ui/dist/catalog/CheckBox/index.d.ts +5 -0
- package/a2ui/dist/catalog/CheckBox/index.jsx +3 -0
- package/a2ui/dist/catalog/CheckBox/index.jsx.map +1 -1
- package/a2ui/dist/catalog/ChoicePicker/catalog.json +2 -1
- package/a2ui/dist/catalog/ChoicePicker/index.d.ts +5 -0
- package/a2ui/dist/catalog/ChoicePicker/index.jsx +3 -0
- package/a2ui/dist/catalog/ChoicePicker/index.jsx.map +1 -1
- package/a2ui/dist/catalog/Column/catalog.json +2 -1
- package/a2ui/dist/catalog/Column/index.d.ts +5 -0
- package/a2ui/dist/catalog/Column/index.jsx +3 -0
- package/a2ui/dist/catalog/Column/index.jsx.map +1 -1
- package/a2ui/dist/catalog/DateTimeInput/catalog.json +2 -1
- package/a2ui/dist/catalog/DateTimeInput/index.d.ts +5 -0
- package/a2ui/dist/catalog/DateTimeInput/index.jsx +4 -10
- package/a2ui/dist/catalog/DateTimeInput/index.jsx.map +1 -1
- package/a2ui/dist/catalog/DateTimeInput/utils.d.ts +0 -1
- package/a2ui/dist/catalog/DateTimeInput/utils.js +0 -3
- package/a2ui/dist/catalog/DateTimeInput/utils.js.map +1 -1
- package/a2ui/dist/catalog/Divider/catalog.json +2 -1
- package/a2ui/dist/catalog/Divider/index.d.ts +5 -0
- package/a2ui/dist/catalog/Divider/index.jsx +3 -0
- package/a2ui/dist/catalog/Divider/index.jsx.map +1 -1
- package/a2ui/dist/catalog/Icon/catalog.json +2 -1
- package/a2ui/dist/catalog/Icon/index.d.ts +5 -0
- package/a2ui/dist/catalog/Icon/index.jsx +3 -0
- package/a2ui/dist/catalog/Icon/index.jsx.map +1 -1
- package/a2ui/dist/catalog/Image/catalog.json +2 -1
- package/a2ui/dist/catalog/Image/index.d.ts +5 -0
- package/a2ui/dist/catalog/Image/index.jsx +3 -0
- package/a2ui/dist/catalog/Image/index.jsx.map +1 -1
- package/a2ui/dist/catalog/LazyComponent/catalog.json +37 -0
- package/a2ui/dist/catalog/LazyComponent/index.d.ts +27 -0
- package/a2ui/dist/catalog/LazyComponent/index.jsx +39 -0
- package/a2ui/dist/catalog/LazyComponent/index.jsx.map +1 -0
- package/a2ui/dist/catalog/LineChart/catalog.json +2 -1
- package/a2ui/dist/catalog/LineChart/index.d.ts +8 -0
- package/a2ui/dist/catalog/LineChart/index.jsx +3 -0
- package/a2ui/dist/catalog/LineChart/index.jsx.map +1 -1
- package/a2ui/dist/catalog/List/catalog.json +2 -1
- package/a2ui/dist/catalog/List/index.d.ts +5 -0
- package/a2ui/dist/catalog/List/index.jsx +3 -0
- package/a2ui/dist/catalog/List/index.jsx.map +1 -1
- package/a2ui/dist/catalog/Loading/catalog.json +16 -0
- package/a2ui/dist/catalog/Loading/index.d.ts +15 -0
- package/a2ui/dist/catalog/Loading/index.jsx +14 -0
- package/a2ui/dist/catalog/Loading/index.jsx.map +1 -0
- package/a2ui/dist/catalog/Modal/catalog.json +2 -1
- package/a2ui/dist/catalog/Modal/index.d.ts +5 -0
- package/a2ui/dist/catalog/Modal/index.jsx +3 -0
- package/a2ui/dist/catalog/Modal/index.jsx.map +1 -1
- package/a2ui/dist/catalog/PieChart/catalog.json +2 -1
- package/a2ui/dist/catalog/PieChart/index.d.ts +8 -0
- package/a2ui/dist/catalog/PieChart/index.jsx +3 -0
- package/a2ui/dist/catalog/PieChart/index.jsx.map +1 -1
- package/a2ui/dist/catalog/RadioGroup/catalog.json +2 -1
- package/a2ui/dist/catalog/RadioGroup/index.d.ts +5 -0
- package/a2ui/dist/catalog/RadioGroup/index.jsx +3 -0
- package/a2ui/dist/catalog/RadioGroup/index.jsx.map +1 -1
- package/a2ui/dist/catalog/Row/catalog.json +2 -1
- package/a2ui/dist/catalog/Row/index.d.ts +5 -0
- package/a2ui/dist/catalog/Row/index.jsx +3 -0
- package/a2ui/dist/catalog/Row/index.jsx.map +1 -1
- package/a2ui/dist/catalog/Slider/catalog.json +2 -1
- package/a2ui/dist/catalog/Slider/index.d.ts +5 -0
- package/a2ui/dist/catalog/Slider/index.jsx +3 -0
- package/a2ui/dist/catalog/Slider/index.jsx.map +1 -1
- package/a2ui/dist/catalog/Tabs/catalog.json +2 -1
- package/a2ui/dist/catalog/Tabs/index.d.ts +5 -0
- package/a2ui/dist/catalog/Tabs/index.jsx +3 -0
- package/a2ui/dist/catalog/Tabs/index.jsx.map +1 -1
- package/a2ui/dist/catalog/Text/catalog.json +2 -1
- package/a2ui/dist/catalog/Text/index.d.ts +5 -0
- package/a2ui/dist/catalog/Text/index.jsx +3 -0
- package/a2ui/dist/catalog/Text/index.jsx.map +1 -1
- package/a2ui/dist/catalog/TextField/catalog.json +2 -1
- package/a2ui/dist/catalog/TextField/index.d.ts +5 -0
- package/a2ui/dist/catalog/TextField/index.jsx +3 -0
- package/a2ui/dist/catalog/TextField/index.jsx.map +1 -1
- package/a2ui/dist/catalog/defineCatalog.d.ts +4 -4
- package/a2ui/dist/catalog/defineCatalog.js.map +1 -1
- package/a2ui/dist/catalog/index.d.ts +2 -0
- package/a2ui/dist/catalog/index.js +92 -18
- package/a2ui/dist/catalog/index.js.map +1 -1
- package/a2ui/dist/catalog.json +2603 -0
- package/a2ui/dist/index.d.ts +1 -1
- package/a2ui/dist/index.js +2 -2
- package/a2ui/dist/index.js.map +1 -1
- package/a2ui/dist/react/A2UI.d.ts +3 -0
- package/a2ui/dist/react/A2UI.jsx.map +1 -1
- package/a2ui/dist/react/A2UIRenderer.d.ts +5 -18
- package/a2ui/dist/react/A2UIRenderer.jsx +3 -13
- package/a2ui/dist/react/A2UIRenderer.jsx.map +1 -1
- package/a2ui/dist/react/useAction.d.ts +7 -0
- package/a2ui/dist/react/useAction.js +4 -0
- package/a2ui/dist/react/useAction.js.map +1 -1
- package/a2ui/dist/react/useDataBinding.d.ts +7 -5
- package/a2ui/dist/react/useDataBinding.js +18 -0
- package/a2ui/dist/react/useDataBinding.js.map +1 -1
- package/a2ui/dist/store/FunctionRegistry.d.ts +7 -0
- package/a2ui/dist/store/FunctionRegistry.js +4 -0
- package/a2ui/dist/store/FunctionRegistry.js.map +1 -1
- package/a2ui/dist/store/MessageProcessor.d.ts +7 -0
- package/a2ui/dist/store/MessageProcessor.js +4 -0
- package/a2ui/dist/store/MessageProcessor.js.map +1 -1
- package/a2ui/dist/store/MessageStore.d.ts +6 -0
- package/a2ui/dist/store/MessageStore.js +3 -0
- package/a2ui/dist/store/MessageStore.js.map +1 -1
- package/a2ui/dist/store/Resource.d.ts +8 -0
- package/a2ui/dist/store/Resource.js +4 -0
- package/a2ui/dist/store/Resource.js.map +1 -1
- package/a2ui/dist/store/SignalStore.d.ts +3 -2
- package/a2ui/dist/store/SignalStore.js +9 -0
- package/a2ui/dist/store/SignalStore.js.map +1 -1
- package/a2ui/dist/store/resolveDynamic.d.ts +4 -3
- package/a2ui/dist/store/resolveDynamic.js +19 -0
- package/a2ui/dist/store/resolveDynamic.js.map +1 -1
- package/a2ui/dist/store/resolveFunctionCall.d.ts +7 -0
- package/a2ui/dist/store/resolveFunctionCall.js +4 -0
- package/a2ui/dist/store/resolveFunctionCall.js.map +1 -1
- package/a2ui/dist/store/types.d.ts +13 -0
- package/a2ui/dist/store/utils.d.ts +6 -4
- package/a2ui/dist/store/utils.js +26 -0
- package/a2ui/dist/store/utils.js.map +1 -1
- package/a2ui/dist/tsconfig.build.tsbuildinfo +1 -1
- package/a2ui/docs/catalog-guide.md +407 -0
- package/a2ui/docs/catalog-guide_zh.md +379 -0
- package/a2ui/docs/overview.md +312 -0
- package/a2ui/docs/overview_zh.md +289 -0
- package/a2ui/docs/system-prompts.md +187 -0
- package/a2ui/docs/system-prompts_zh.md +187 -0
- package/a2ui/src/catalog/README.md +12 -0
- package/a2ui/src/catalog/index.ts +52 -0
- package/a2ui/src/catalog/readme_zh.md +11 -0
- package/a2ui/src/index.ts +116 -0
- package/a2ui/styles/catalog/Button.css +5 -5
- package/a2ui/styles/catalog/DateTimeInput.css +22 -30
- package/a2ui/styles/catalog/Loading.css +61 -0
- package/a2ui-catalog-extractor/README.md +14 -7
- package/a2ui-catalog-extractor/dist/cli.d.ts +1 -0
- package/a2ui-catalog-extractor/dist/cli.js +15 -6
- package/a2ui-catalog-extractor/dist/cli.js.map +1 -1
- package/a2ui-catalog-extractor/dist/index.d.ts +97 -2
- package/a2ui-catalog-extractor/dist/index.js +91 -6
- package/a2ui-catalog-extractor/dist/index.js.map +1 -1
- package/a2ui-catalog-extractor/dist/tsconfig.build.tsbuildinfo +1 -1
- package/a2ui-catalog-extractor/skills/a2ui-catalog-extractor/SKILL.md +1 -1
- package/a2ui-prompt/README.md +3 -2
- package/a2ui-prompt/dist/index.d.ts +41 -0
- package/a2ui-prompt/dist/index.js +159 -84
- package/cli/README.md +26 -0
- package/cli/bin/cli.js +7 -265
- package/cli/dist/a2ui/create.d.ts +5 -0
- package/cli/dist/a2ui/create.js +178 -0
- package/cli/dist/a2ui/create.js.map +1 -0
- package/cli/dist/a2ui/index.d.ts +5 -0
- package/cli/dist/a2ui/index.js +170 -0
- package/cli/dist/a2ui/index.js.map +1 -0
- package/cli/dist/cli.d.ts +4 -0
- package/cli/dist/cli.js +40 -0
- package/cli/dist/cli.js.map +1 -0
- package/cli/dist/openui.d.ts +1 -0
- package/cli/dist/openui.js +21 -0
- package/cli/dist/openui.js.map +1 -0
- package/cli/dist/tsconfig.build.tsbuildinfo +1 -0
- package/cli/dist/utils.d.ts +2 -0
- package/cli/dist/utils.js +17 -0
- package/cli/dist/utils.js.map +1 -0
- package/cli/templates/default/lynx.config.ts +13 -0
- package/cli/templates/default/package.json +27 -0
- package/cli/templates/default/src/App.css +88 -0
- package/cli/templates/default/src/App.tsx +100 -0
- package/cli/templates/default/src/index.tsx +10 -0
- package/cli/templates/default/src/messages.ts +158 -0
- package/cli/templates/default/src/rspeedy-env.d.ts +14 -0
- package/cli/templates/default/src/tsconfig.json +17 -0
- package/cli/templates/default/tsconfig.json +15 -0
- package/cli/templates/default/tsconfig.node.json +16 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/index.ts +12 -0
- package/openui/README.md +50 -46
- package/openui/dist/catalog/Action/{index.js → index.jsx} +1 -1
- package/openui/dist/catalog/Action/index.jsx.map +1 -0
- package/openui/dist/catalog/Button/index.d.ts +8 -8
- package/openui/dist/catalog/Button/{index.js → index.jsx} +28 -14
- package/openui/dist/catalog/Button/index.jsx.map +1 -0
- package/openui/dist/catalog/Card/index.d.ts +1 -1
- package/openui/dist/catalog/Card/{index.js → index.jsx} +5 -4
- package/openui/dist/catalog/Card/{index.js.map → index.jsx.map} +1 -1
- package/openui/dist/catalog/CardHeader/index.d.ts +1 -1
- package/openui/dist/catalog/CardHeader/index.jsx +20 -0
- package/openui/dist/catalog/CardHeader/index.jsx.map +1 -0
- package/openui/dist/catalog/CheckBox/index.d.ts +16 -0
- package/openui/dist/catalog/CheckBox/index.jsx +82 -0
- package/openui/dist/catalog/CheckBox/index.jsx.map +1 -0
- package/openui/dist/catalog/Icon/index.d.ts +44 -0
- package/openui/dist/catalog/Icon/index.jsx +66 -0
- package/openui/dist/catalog/Icon/index.jsx.map +1 -0
- package/openui/dist/catalog/Image/index.d.ts +19 -0
- package/openui/dist/catalog/Image/index.jsx +40 -0
- package/openui/dist/catalog/Image/index.jsx.map +1 -0
- package/openui/dist/catalog/Loading/index.d.ts +7 -0
- package/openui/dist/catalog/Loading/index.jsx +25 -0
- package/openui/dist/catalog/Loading/index.jsx.map +1 -0
- package/openui/dist/catalog/RadioGroup/index.d.ts +21 -0
- package/openui/dist/catalog/RadioGroup/index.jsx +99 -0
- package/openui/dist/catalog/RadioGroup/index.jsx.map +1 -0
- package/openui/dist/catalog/Separator/index.d.ts +1 -1
- package/openui/dist/catalog/Separator/{index.js → index.jsx} +3 -4
- package/openui/dist/catalog/Separator/index.jsx.map +1 -0
- package/openui/dist/catalog/Slider/index.d.ts +19 -0
- package/openui/dist/catalog/Slider/index.jsx +139 -0
- package/openui/dist/catalog/Slider/index.jsx.map +1 -0
- package/openui/dist/catalog/Stack/index.d.ts +1 -1
- package/openui/dist/catalog/Stack/{index.js → index.jsx} +3 -4
- package/openui/dist/catalog/Stack/{index.js.map → index.jsx.map} +1 -1
- package/openui/dist/catalog/Tag/index.d.ts +1 -1
- package/openui/dist/catalog/Tag/{index.js → index.jsx} +5 -4
- package/openui/dist/catalog/Tag/index.jsx.map +1 -0
- package/openui/dist/catalog/TextContent/index.d.ts +1 -1
- package/openui/dist/catalog/TextContent/{index.js → index.jsx} +5 -4
- package/openui/dist/catalog/TextContent/{index.js.map → index.jsx.map} +1 -1
- package/openui/dist/catalog/TextField/index.d.ts +23 -0
- package/openui/dist/catalog/TextField/index.jsx +132 -0
- package/openui/dist/catalog/TextField/index.jsx.map +1 -0
- package/openui/dist/catalog/index.d.ts +14 -7
- package/openui/dist/catalog/index.js +14 -7
- package/openui/dist/catalog/index.js.map +1 -1
- package/openui/dist/core/context.d.ts +22 -8
- package/openui/dist/core/{context.js → context.jsx} +10 -3
- package/openui/dist/core/context.jsx.map +1 -0
- package/openui/dist/core/createLibrary.d.ts +8 -1
- package/openui/dist/core/{createLibrary.js → createLibrary.jsx} +18 -3
- package/openui/dist/core/createLibrary.jsx.map +1 -0
- package/openui/dist/core/hooks/index.d.ts +1 -0
- package/openui/dist/core/hooks/index.js +1 -0
- package/openui/dist/core/hooks/index.js.map +1 -1
- package/openui/dist/core/hooks/useFormValidation.d.ts +9 -0
- package/openui/dist/core/hooks/useFormValidation.js +6 -0
- package/openui/dist/core/hooks/useFormValidation.js.map +1 -1
- package/openui/dist/core/hooks/useOpenUIState.d.ts +8 -2
- package/openui/dist/core/hooks/useOpenUIState.js +3 -1
- package/openui/dist/core/hooks/useOpenUIState.js.map +1 -1
- package/openui/dist/core/hooks/useStateField.d.ts +3 -0
- package/openui/dist/core/hooks/useStateField.js +4 -1
- package/openui/dist/core/hooks/useStateField.js.map +1 -1
- package/openui/dist/core/index.d.ts +13 -7
- package/openui/dist/core/index.js +7 -4
- package/openui/dist/core/index.js.map +1 -1
- package/openui/dist/core/library.d.ts +6 -1
- package/openui/dist/core/{library.js → library.jsx} +9 -1
- package/openui/dist/core/library.jsx.map +1 -0
- package/openui/dist/core/renderer.css +527 -0
- package/openui/dist/core/renderer.d.ts +41 -4
- package/openui/dist/core/renderer.jsx +284 -0
- package/openui/dist/core/renderer.jsx.map +1 -0
- package/openui/dist/core/runtime/index.d.ts +1 -0
- package/openui/dist/core/runtime/index.js +5 -0
- package/openui/dist/core/runtime/index.js.map +1 -0
- package/openui/dist/core/runtime/reactive.d.ts +7 -0
- package/openui/dist/core/runtime/reactive.js +10 -0
- package/openui/dist/core/runtime/reactive.js.map +1 -0
- package/openui/dist/openui-prompt/index.d.ts +47 -0
- package/openui/dist/openui-prompt/index.js +321 -0
- package/openui/dist/openui-prompt/index.js.map +1 -0
- package/package.json +20 -8
- package/openui/dist/catalog/Action/index.js.map +0 -1
- package/openui/dist/catalog/Button/index.js.map +0 -1
- package/openui/dist/catalog/CardHeader/index.js +0 -18
- package/openui/dist/catalog/CardHeader/index.js.map +0 -1
- package/openui/dist/catalog/Separator/index.js.map +0 -1
- package/openui/dist/catalog/Tag/index.js.map +0 -1
- package/openui/dist/core/context.js.map +0 -1
- package/openui/dist/core/createLibrary.js.map +0 -1
- package/openui/dist/core/library.js.map +0 -1
- package/openui/dist/core/renderer.js +0 -139
- package/openui/dist/core/renderer.js.map +0 -1
|
@@ -1,9 +1,46 @@
|
|
|
1
|
-
import type { ActionEvent, ParseResult } from '@openuidev/lang-core';
|
|
2
|
-
import type {
|
|
1
|
+
import type { ActionEvent, McpClientLike, OpenUIError, ParseResult } from '@openuidev/lang-core';
|
|
2
|
+
import type { ReactNode } from '@lynx-js/react';
|
|
3
|
+
import type { Library, RenderOutput } from './library.jsx';
|
|
3
4
|
export type { Library, RenderOutput };
|
|
4
|
-
export
|
|
5
|
+
export type ToolProviderInput = Record<string, (args: Record<string, unknown>) => unknown> | McpClientLike | null;
|
|
6
|
+
/**
|
|
7
|
+
* Props for rendering raw OpenUI response text with parsing, runtime state,
|
|
8
|
+
* actions, and query execution.
|
|
9
|
+
*/
|
|
10
|
+
export interface OpenUiRendererRuntimeProps {
|
|
11
|
+
/** Raw openui-lang response text. This enables v0.5 runtime features. */
|
|
12
|
+
response: string | null;
|
|
13
|
+
/** Component library from createOpenUiLibrary(). */
|
|
14
|
+
library: Library;
|
|
15
|
+
/** Whether the LLM is still streaming; disables interactions while true. */
|
|
16
|
+
isStreaming?: boolean;
|
|
17
|
+
/** Callback when a component triggers a host action. */
|
|
18
|
+
onAction?: (event: ActionEvent) => void;
|
|
19
|
+
/** Called whenever $variables or form state changes. */
|
|
20
|
+
onStateUpdate?: (state: Record<string, unknown>) => void;
|
|
21
|
+
/** Initial persisted state. $-prefixed keys hydrate reactive bindings. */
|
|
22
|
+
initialState?: Record<string, unknown>;
|
|
23
|
+
/** Called whenever the raw parse result changes. */
|
|
24
|
+
onParseResult?: (result: ParseResult | null) => void;
|
|
25
|
+
/** Tool provider for Query()/Mutation(): function map or MCP client. */
|
|
26
|
+
toolProvider?: ToolProviderInput;
|
|
27
|
+
/** Custom loading node shown while Query() calls are in flight. */
|
|
28
|
+
queryLoader?: ReactNode;
|
|
29
|
+
/** Structured parser/runtime/query errors for correction loops. */
|
|
30
|
+
onError?: (errors: OpenUIError[]) => void;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Props for rendering an already parsed OpenUI result.
|
|
34
|
+
*/
|
|
35
|
+
export interface OpenUiRendererParsedProps {
|
|
36
|
+
/** Pre-parsed result. Kept for v0.1/static-render compatibility. */
|
|
5
37
|
result: ParseResult | null;
|
|
6
38
|
library: Library;
|
|
7
39
|
onAction?: (event: ActionEvent) => void;
|
|
8
40
|
isStreaming?: boolean;
|
|
9
|
-
}
|
|
41
|
+
}
|
|
42
|
+
export type OpenUiRendererProps = OpenUiRendererRuntimeProps | OpenUiRendererParsedProps;
|
|
43
|
+
/**
|
|
44
|
+
* Render OpenUI language output using a ReactLynx component library.
|
|
45
|
+
*/
|
|
46
|
+
export declare function OpenUiRenderer(props: OpenUiRendererProps): import("@lynx-js/react").JSX.Element;
|
|
@@ -0,0 +1,284 @@
|
|
|
1
|
+
import { ACTION_STEPS, BuiltinActionType, ToolNotFoundError, createStore, extractToolResult, } from '@openuidev/lang-core';
|
|
2
|
+
import { Fragment, useCallback, useEffect, useMemo, useRef, useState, } from '@lynx-js/react';
|
|
3
|
+
import { OpenUIContext, useOpenUI, useRenderNode } from './context.jsx';
|
|
4
|
+
import { useOpenUIState } from './hooks/useOpenUIState.js';
|
|
5
|
+
import { keyFrom } from './utils.js';
|
|
6
|
+
function isElementNode(value) {
|
|
7
|
+
return (typeof value === 'object'
|
|
8
|
+
&& value !== null
|
|
9
|
+
&& 'type' in value
|
|
10
|
+
&& 'typeName' in value
|
|
11
|
+
&& value['type'] === 'element');
|
|
12
|
+
}
|
|
13
|
+
function createFieldEntry(value, componentType) {
|
|
14
|
+
return componentType === undefined ? { value } : { value, componentType };
|
|
15
|
+
}
|
|
16
|
+
function isFieldEntry(value) {
|
|
17
|
+
return (typeof value === 'object'
|
|
18
|
+
&& value !== null
|
|
19
|
+
&& !Array.isArray(value)
|
|
20
|
+
&& 'value' in value);
|
|
21
|
+
}
|
|
22
|
+
function isFieldMap(value) {
|
|
23
|
+
return (typeof value === 'object'
|
|
24
|
+
&& value !== null
|
|
25
|
+
&& !Array.isArray(value)
|
|
26
|
+
&& Object.values(value).every((entry) => isFieldEntry(entry)));
|
|
27
|
+
}
|
|
28
|
+
function getFieldEntry(state, formName, name) {
|
|
29
|
+
if (!formName) {
|
|
30
|
+
const value = state[name];
|
|
31
|
+
return isFieldEntry(value) ? value : undefined;
|
|
32
|
+
}
|
|
33
|
+
const formValue = state[formName];
|
|
34
|
+
if (!isFieldMap(formValue))
|
|
35
|
+
return undefined;
|
|
36
|
+
return formValue[name];
|
|
37
|
+
}
|
|
38
|
+
function renderDeep(value) {
|
|
39
|
+
if (value === null || value === undefined)
|
|
40
|
+
return null;
|
|
41
|
+
if (typeof value === 'string' || typeof value === 'number'
|
|
42
|
+
|| typeof value === 'boolean') {
|
|
43
|
+
return <text>{String(value)}</text>;
|
|
44
|
+
}
|
|
45
|
+
if (Array.isArray(value)) {
|
|
46
|
+
return value.map((v, i) => (<Fragment key={keyFrom(v, i)}>
|
|
47
|
+
{renderDeep(v)}
|
|
48
|
+
</Fragment>));
|
|
49
|
+
}
|
|
50
|
+
if (isElementNode(value)) {
|
|
51
|
+
const stableKey = value.statementId ?? keyFrom(value);
|
|
52
|
+
return <RenderNode key={stableKey} node={value}/>;
|
|
53
|
+
}
|
|
54
|
+
return null;
|
|
55
|
+
}
|
|
56
|
+
function RenderNode({ node }) {
|
|
57
|
+
const { library, reportError } = useOpenUI();
|
|
58
|
+
const Comp = library.components[node.typeName]?.component;
|
|
59
|
+
if (!Comp)
|
|
60
|
+
return null;
|
|
61
|
+
try {
|
|
62
|
+
return <RenderNodeInner el={node} Comp={Comp}/>;
|
|
63
|
+
}
|
|
64
|
+
catch (error) {
|
|
65
|
+
reportError?.({
|
|
66
|
+
source: 'runtime',
|
|
67
|
+
code: 'render-error',
|
|
68
|
+
component: node.typeName,
|
|
69
|
+
message: `Component ${node.typeName} render failed: ${error instanceof Error ? error.message : String(error)}`,
|
|
70
|
+
});
|
|
71
|
+
return null;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
function RenderNodeInner({ el, Comp }) {
|
|
75
|
+
const renderNode = useRenderNode();
|
|
76
|
+
return (<Comp props={el.props} renderNode={renderNode} {...(el.statementId ? { statementId: el.statementId } : {})}/>);
|
|
77
|
+
}
|
|
78
|
+
function DefaultQueryLoader() {
|
|
79
|
+
return (<view className='OpenUIQueryLoader'>
|
|
80
|
+
<view className='OpenUIQueryLoaderDot'/>
|
|
81
|
+
</view>);
|
|
82
|
+
}
|
|
83
|
+
function RuntimeOpenUiRenderer({ response, library, isStreaming = false, onAction, onStateUpdate, initialState, onParseResult, toolProvider, queryLoader, onError, }) {
|
|
84
|
+
const onParseResultRef = useRef(onParseResult);
|
|
85
|
+
onParseResultRef.current = onParseResult;
|
|
86
|
+
const toolProviderInputRef = useRef(toolProvider);
|
|
87
|
+
toolProviderInputRef.current = toolProvider;
|
|
88
|
+
const stableToolProvider = useRef({
|
|
89
|
+
async callTool(toolName, args) {
|
|
90
|
+
const current = toolProviderInputRef.current ?? null;
|
|
91
|
+
if (current === null) {
|
|
92
|
+
throw new Error('[openui] toolProvider is null');
|
|
93
|
+
}
|
|
94
|
+
if (typeof current.callTool === 'function') {
|
|
95
|
+
const result = await current.callTool({
|
|
96
|
+
name: toolName,
|
|
97
|
+
arguments: args,
|
|
98
|
+
});
|
|
99
|
+
return extractToolResult(result);
|
|
100
|
+
}
|
|
101
|
+
const map = current;
|
|
102
|
+
const fn = map[toolName];
|
|
103
|
+
if (!fn)
|
|
104
|
+
throw new ToolNotFoundError(toolName, Object.keys(map));
|
|
105
|
+
return await fn(args);
|
|
106
|
+
},
|
|
107
|
+
});
|
|
108
|
+
const resolvedToolProvider = toolProvider !== null && toolProvider !== undefined
|
|
109
|
+
? stableToolProvider.current
|
|
110
|
+
: null;
|
|
111
|
+
const stateOptions = {
|
|
112
|
+
response,
|
|
113
|
+
library,
|
|
114
|
+
isStreaming,
|
|
115
|
+
toolProvider: resolvedToolProvider,
|
|
116
|
+
...(onAction ? { onAction } : {}),
|
|
117
|
+
...(onStateUpdate ? { onStateUpdate } : {}),
|
|
118
|
+
...(initialState ? { initialState } : {}),
|
|
119
|
+
...(onError ? { onError } : {}),
|
|
120
|
+
};
|
|
121
|
+
const { result, parseResult, contextValue, isQueryLoading } = useOpenUIState(stateOptions, renderDeep);
|
|
122
|
+
useEffect(() => {
|
|
123
|
+
onParseResultRef.current?.(parseResult);
|
|
124
|
+
}, [parseResult]);
|
|
125
|
+
if (!result?.root)
|
|
126
|
+
return null;
|
|
127
|
+
return (<OpenUIContext.Provider value={contextValue}>
|
|
128
|
+
<view className='OpenUIRenderer'>
|
|
129
|
+
{isQueryLoading ? (queryLoader ?? <DefaultQueryLoader />) : null}
|
|
130
|
+
<view className={isQueryLoading
|
|
131
|
+
? 'OpenUIRendererContent OpenUIRendererContentLoading'
|
|
132
|
+
: 'OpenUIRendererContent'}>
|
|
133
|
+
<RenderNode node={result.root}/>
|
|
134
|
+
</view>
|
|
135
|
+
</view>
|
|
136
|
+
</OpenUIContext.Provider>);
|
|
137
|
+
}
|
|
138
|
+
function ParsedOpenUiRenderer({ result, library, onAction, isStreaming = false, }) {
|
|
139
|
+
const [formState, setFormState] = useState({});
|
|
140
|
+
const formStateRef = useRef(formState);
|
|
141
|
+
const onActionRef = useRef(onAction);
|
|
142
|
+
const store = useMemo(() => createStore(), []);
|
|
143
|
+
useEffect(() => {
|
|
144
|
+
formStateRef.current = formState;
|
|
145
|
+
}, [formState]);
|
|
146
|
+
useEffect(() => {
|
|
147
|
+
onActionRef.current = onAction;
|
|
148
|
+
}, [onAction]);
|
|
149
|
+
useEffect(() => {
|
|
150
|
+
return () => store.dispose();
|
|
151
|
+
}, [store]);
|
|
152
|
+
const getFieldValue = useCallback((formName, name) => {
|
|
153
|
+
return getFieldEntry(formStateRef.current, formName, name)?.value;
|
|
154
|
+
}, [formStateRef]);
|
|
155
|
+
const setFieldValue = useCallback((formName, componentType, name, value, _shouldTriggerSaveCallback = true) => {
|
|
156
|
+
const currentState = formStateRef.current;
|
|
157
|
+
const newState = { ...currentState };
|
|
158
|
+
if (formName) {
|
|
159
|
+
const currentFormValue = currentState[formName];
|
|
160
|
+
newState[formName] = {
|
|
161
|
+
...(isFieldMap(currentFormValue) ? currentFormValue : {}),
|
|
162
|
+
[name]: createFieldEntry(value, componentType),
|
|
163
|
+
};
|
|
164
|
+
}
|
|
165
|
+
else {
|
|
166
|
+
newState[name] = createFieldEntry(value, componentType);
|
|
167
|
+
store.set(name, value);
|
|
168
|
+
}
|
|
169
|
+
setFormState(newState);
|
|
170
|
+
formStateRef.current = newState;
|
|
171
|
+
}, [formStateRef, setFormState, store]);
|
|
172
|
+
const triggerAction = useCallback((userMessage, formName, action) => {
|
|
173
|
+
const currentState = formStateRef.current;
|
|
174
|
+
const handler = onActionRef.current;
|
|
175
|
+
// ActionPlan path (v0.5) — sequential steps
|
|
176
|
+
if (action && 'steps' in action) {
|
|
177
|
+
let relevantState;
|
|
178
|
+
const formValue = formName ? currentState[formName] : undefined;
|
|
179
|
+
if (formName && formValue !== undefined) {
|
|
180
|
+
relevantState = { [formName]: formValue };
|
|
181
|
+
}
|
|
182
|
+
else if (Object.keys(currentState).length > 0) {
|
|
183
|
+
relevantState = currentState;
|
|
184
|
+
}
|
|
185
|
+
for (const step of action.steps) {
|
|
186
|
+
switch (step.type) {
|
|
187
|
+
case ACTION_STEPS.ToAssistant:
|
|
188
|
+
handler?.({
|
|
189
|
+
type: BuiltinActionType.ContinueConversation,
|
|
190
|
+
params: step.context ? { context: step.context } : {},
|
|
191
|
+
humanFriendlyMessage: step.message,
|
|
192
|
+
...(relevantState ? { formState: relevantState } : {}),
|
|
193
|
+
...(formName ? { formName } : {}),
|
|
194
|
+
});
|
|
195
|
+
break;
|
|
196
|
+
case ACTION_STEPS.OpenUrl:
|
|
197
|
+
handler?.({
|
|
198
|
+
type: BuiltinActionType.OpenUrl,
|
|
199
|
+
params: { url: step.url },
|
|
200
|
+
humanFriendlyMessage: '',
|
|
201
|
+
...(relevantState ? { formState: relevantState } : {}),
|
|
202
|
+
...(formName ? { formName } : {}),
|
|
203
|
+
});
|
|
204
|
+
break;
|
|
205
|
+
case ACTION_STEPS.Run:
|
|
206
|
+
case ACTION_STEPS.Set:
|
|
207
|
+
case ACTION_STEPS.Reset:
|
|
208
|
+
// OpenUiRenderer does not own the query manager, store, or
|
|
209
|
+
// evaluation context needed to execute these steps. Report them
|
|
210
|
+
// explicitly so generated plans do not fail silently here.
|
|
211
|
+
console.warn(`[OpenUiRenderer] Unsupported ActionPlan step: ${step.type}`, step);
|
|
212
|
+
break;
|
|
213
|
+
default:
|
|
214
|
+
console.warn('[OpenUiRenderer] Unknown ActionPlan step:', step);
|
|
215
|
+
break;
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
return;
|
|
219
|
+
}
|
|
220
|
+
const legacyAction = action && !('steps' in action)
|
|
221
|
+
? action
|
|
222
|
+
: undefined;
|
|
223
|
+
const actionType = legacyAction?.type
|
|
224
|
+
?? BuiltinActionType.ContinueConversation;
|
|
225
|
+
const actionParams = { ...(legacyAction?.params ?? {}) };
|
|
226
|
+
if (legacyAction?.url)
|
|
227
|
+
actionParams['url'] = legacyAction.url;
|
|
228
|
+
if (legacyAction?.context)
|
|
229
|
+
actionParams['context'] = legacyAction.context;
|
|
230
|
+
let relevantState;
|
|
231
|
+
const formValue = formName ? currentState[formName] : undefined;
|
|
232
|
+
if (formName && formValue !== undefined) {
|
|
233
|
+
relevantState = { [formName]: formValue };
|
|
234
|
+
}
|
|
235
|
+
else if (Object.keys(currentState).length > 0) {
|
|
236
|
+
relevantState = currentState;
|
|
237
|
+
}
|
|
238
|
+
handler?.({
|
|
239
|
+
type: actionType,
|
|
240
|
+
params: actionParams,
|
|
241
|
+
humanFriendlyMessage: userMessage,
|
|
242
|
+
...(relevantState ? { formState: relevantState } : {}),
|
|
243
|
+
...(formName ? { formName } : {}),
|
|
244
|
+
});
|
|
245
|
+
}, [formStateRef, onActionRef]);
|
|
246
|
+
const evaluationContext = useMemo(() => ({
|
|
247
|
+
getState: (name) => getFieldValue(undefined, name),
|
|
248
|
+
resolveRef: () => undefined,
|
|
249
|
+
}), [getFieldValue]);
|
|
250
|
+
const contextValue = useMemo(() => ({
|
|
251
|
+
library,
|
|
252
|
+
renderNode: renderDeep,
|
|
253
|
+
triggerAction,
|
|
254
|
+
isStreaming,
|
|
255
|
+
isQueryLoading: false,
|
|
256
|
+
getFieldValue,
|
|
257
|
+
setFieldValue,
|
|
258
|
+
store,
|
|
259
|
+
evaluationContext,
|
|
260
|
+
}), [
|
|
261
|
+
library,
|
|
262
|
+
triggerAction,
|
|
263
|
+
isStreaming,
|
|
264
|
+
getFieldValue,
|
|
265
|
+
setFieldValue,
|
|
266
|
+
store,
|
|
267
|
+
evaluationContext,
|
|
268
|
+
]);
|
|
269
|
+
if (!result?.root)
|
|
270
|
+
return null;
|
|
271
|
+
return (<OpenUIContext.Provider value={contextValue}>
|
|
272
|
+
<RenderNode node={result.root}/>
|
|
273
|
+
</OpenUIContext.Provider>);
|
|
274
|
+
}
|
|
275
|
+
/**
|
|
276
|
+
* Render OpenUI language output using a ReactLynx component library.
|
|
277
|
+
*/
|
|
278
|
+
export function OpenUiRenderer(props) {
|
|
279
|
+
if ('response' in props) {
|
|
280
|
+
return <RuntimeOpenUiRenderer {...props}/>;
|
|
281
|
+
}
|
|
282
|
+
return <ParsedOpenUiRenderer {...props}/>;
|
|
283
|
+
}
|
|
284
|
+
//# sourceMappingURL=renderer.jsx.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"renderer.jsx","sourceRoot":"","sources":["../../src/core/renderer.tsx"],"names":[],"mappings":"AAcA,OAAO,EACL,YAAY,EACZ,iBAAiB,EACjB,iBAAi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C;IAAA,EAAE,aAAa,CAAC,QAAQ,CAAC,CAC1B,CAAC;AACJ,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,cAAc,CAAC,KAA0B;IACvD,IAAI,UAAU,IAAI,KAAK,EAAE,CAAC;QACxB,OAAO,CAAC,qBAAqB,CAAC,IAAI,KAAK,CAAC,EAAG,CAAC;IAC9C,CAAC;IACD,OAAO,CAAC,oBAAoB,CAAC,IAAI,KAAK,CAAC,EAAG,CAAC;AAC7C,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { isReactiveSchema, reactive } from './reactive.js';
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
// Copyright 2026 The Lynx Authors. All rights reserved.
|
|
2
|
+
// Licensed under the Apache License Version 2.0 that can be found in the
|
|
3
|
+
// LICENSE file in the root directory of this source tree.
|
|
4
|
+
export { isReactiveSchema, reactive } from './reactive.js';
|
|
5
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/core/runtime/index.ts"],"names":[],"mappings":"AAAA,wDAAwD;AACxD,yEAAyE;AACzE,0DAA0D;AAC1D,OAAO,EAAE,gBAAgB,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { StateField } from '@openuidev/lang-core';
|
|
2
|
+
import type { z } from 'zod/v4';
|
|
3
|
+
export { isReactiveSchema } from '@openuidev/lang-core';
|
|
4
|
+
/**
|
|
5
|
+
* Mark a schema prop as reactive so runtime evaluation can preserve $bindings.
|
|
6
|
+
*/
|
|
7
|
+
export declare function reactive<T extends z.ZodType>(schema: T): z.ZodType<StateField<z.infer<T>>>;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { markReactive } from '@openuidev/lang-core';
|
|
2
|
+
export { isReactiveSchema } from '@openuidev/lang-core';
|
|
3
|
+
/**
|
|
4
|
+
* Mark a schema prop as reactive so runtime evaluation can preserve $bindings.
|
|
5
|
+
*/
|
|
6
|
+
export function reactive(schema) {
|
|
7
|
+
markReactive(schema);
|
|
8
|
+
return schema;
|
|
9
|
+
}
|
|
10
|
+
//# sourceMappingURL=reactive.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"reactive.js","sourceRoot":"","sources":["../../../src/core/runtime/reactive.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAGpD,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAExD;;GAEG;AACH,MAAM,UAAU,QAAQ,CACtB,MAAS;IAET,YAAY,CAAC,MAAM,CAAC,CAAC;IACrB,OAAO,MAAsD,CAAC;AAChE,CAAC"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import type { ComponentGroup, DefinedComponent, Library, PromptOptions } from '@openuidev/lang-core';
|
|
2
|
+
import { z } from 'zod/v4';
|
|
3
|
+
type HeadlessRenderer = () => null;
|
|
4
|
+
export type OpenUiPromptComponent = DefinedComponent<any, HeadlessRenderer>;
|
|
5
|
+
export type OpenUiPromptLibrary = Library<HeadlessRenderer>;
|
|
6
|
+
/**
|
|
7
|
+
* Options for creating the headless OpenUI prompt library.
|
|
8
|
+
*/
|
|
9
|
+
export interface CreateOpenUiPromptLibraryOptions {
|
|
10
|
+
/** Override the root component name. Defaults to `'Stack'`. */
|
|
11
|
+
root?: string;
|
|
12
|
+
/** Replace or extend the built-in component set. */
|
|
13
|
+
components?: OpenUiPromptComponent[];
|
|
14
|
+
/** Replace or extend the built-in component groups. */
|
|
15
|
+
componentGroups?: ComponentGroup[];
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Options used to customize the generated OpenUI system prompt.
|
|
19
|
+
*/
|
|
20
|
+
export interface BuildOpenUiSystemPromptOptions extends CreateOpenUiPromptLibraryOptions {
|
|
21
|
+
promptOptions?: PromptOptions;
|
|
22
|
+
appendix?: string;
|
|
23
|
+
}
|
|
24
|
+
/** Shared action prop schema exposed to prompt signatures as `ActionExpression`. */
|
|
25
|
+
export declare const openUiPromptActionPropSchema: z.ZodUnion<readonly [z.ZodObject<{
|
|
26
|
+
steps: z.ZodArray<z.ZodObject<{
|
|
27
|
+
type: z.ZodString;
|
|
28
|
+
}, z.core.$loose>>;
|
|
29
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
30
|
+
type: z.ZodOptional<z.ZodString>;
|
|
31
|
+
params: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
|
|
32
|
+
url: z.ZodOptional<z.ZodString>;
|
|
33
|
+
context: z.ZodOptional<z.ZodString>;
|
|
34
|
+
}, z.core.$strip>]>;
|
|
35
|
+
/**
|
|
36
|
+
* Create a headless OpenUI library with the built-in component schemas.
|
|
37
|
+
*
|
|
38
|
+
* This mirrors the ReactLynx library for prompt generation while avoiding any
|
|
39
|
+
* runtime dependency on ReactLynx or Lynx UI components.
|
|
40
|
+
*/
|
|
41
|
+
export declare function createOpenUiPromptLibrary(options?: CreateOpenUiPromptLibraryOptions): OpenUiPromptLibrary;
|
|
42
|
+
/**
|
|
43
|
+
* Build the full OpenUI system prompt for the supplied library and options.
|
|
44
|
+
*/
|
|
45
|
+
export declare function buildOpenUiSystemPrompt(options?: BuildOpenUiSystemPromptOptions): string;
|
|
46
|
+
export declare const OPENUI_SYSTEM_PROMPT: string;
|
|
47
|
+
export {};
|