The Open Standard for Generative UI
@openuidev/lang-core
1.0.2
Patch Changes
- #1499
6fbaf91Thanks @devin-ai-integration! - The CLI and lang-core now read and write the shared~/.config/openui/telemetry.jsonthrough one module. The file is written atomically and only when something in it changed, so the two packages no longer overwrite each other's fields (#1475).
1.0.1
Patch Changes
- #1394
5186585Thanks @Aditya-thesys! - Update the README for OpenUI Lang 1.0: working snippets and links to the new docs pages.
1.0.0
Major Changes
#1348
9e76b1dThanks @Aditya-thesys! - OpenUI Lang 1.0.- Upgrade
@openuidev/lang-coreand@openuidev/react-langtogether, and together with the server that generates the system prompt. A 1.0 prompt teaches bare action steps (@ToAssistant("Hi")withoutAction([...])), which a 0.x client does not run. - react-ui 0.18 requires react-lang 1.0 (peer
>=1.0.0 <2.0.0); upgrade them together. - browser-bundle 0.2 bundles react-lang 1.0 and react-ui 0.18.
- server 0.3 uses lang-core 1.0 for autofix (parser and system prompt); stay on server 0.2 with a 0.x client. Autofix ignores warnings and accepts a ternary entry, so a program that renders does not start a fix round.
- vue-lang, svelte-lang and angular-lang stay on 0.4 (OpenUI Lang 0.x). Keep
@openuidev/lang-core^0.4 for the prompts they render. - A program whose
rootstatement is written last shows nothing while it streams, until therootline arrives. Writerootfirst, as the system prompt asks. - A cut-off output that never reached its
rootstatement, or any statement calling the root component, now renders blank instead of a partial tree.
- Upgrade
#1348
9e76b1dThanks @Aditya-thesys! - Remove exports with no users:isASTNode,isRuntimeExpr,CallNode,RuntimeExprNode,Statement,Token,BUILTINS,isBuiltinandtoNumber.
Minor Changes
#1348
9e76b1dThanks @Aditya-thesys! - Action slots are JSON Schema$refs, like component slots. An action prop is{"$ref": "#/$defs/ActionExpression"}, and the library's$defshasActionExpressionwith the same legacy object union as before. A slot can name specific steps with refs, for exampleshare: z.union([steps.ToAssistant.ref, steps.OpenUrl.ref]).optional()(lang-core, re-exported by react-lang): the JSON getsToAssistantandOpenUrl$defs, and the prompt signature printsshare?: @ToAssistant | @OpenUrl. These refs only shape the prompt and the JSON for now; the runtime accepts any step in them. Action$defsare never components.#1348
9e76b1dThanks @Aditya-thesys! - Action steps are plans. Every step call now evaluates to a one-step plan ({ steps: [step] }), so a single step needs no wrapper:Button("Ask", @ToAssistant("Tell me more")). Several steps still needAction([...]), for exampleButton("Save", Action([@Set($saved, true), @ToAssistant("Saved")])); a plain list of steps stays a plain array. An invalid step evaluates to an empty plan (a no-op) instead of null, andAction([...])flattens nested plans. Legacy{ type, params }action configs are unchanged.New
action()helper (lang-core, re-exported by react-lang), likereactive(): it returns the action prop schema, already taggedActionExpression, so libraries writeaction: action().optional()instead of callingtagSchemaId(..., "ActionExpression")themselves. react-ui's action props use it.Prompt change: for libraries with action props (
ActionExpression), the system prompt teaches one step bare and several steps inAction([...]). The react-ui prompt examples, including the chat library examples, use step calls instead of legacy objects.#1348
9e76b1dThanks @Aditya-thesys! - Add custom actions:defineAction({ name, description, params })pluscreateLibrary({ actions }). Programs use them like the built-in steps, alone or inAction([...]), for exampleButton("Copy", @CopyToClipboard(order.id)), with positional arguments inparamskey order. On click the step reaches the hostonActionas{ type: name, params }(schema defaults applied), in order with the other steps, and the event is typed from the library soparamsnarrows bytype. Args are validated like library function args, and a step with invalid args is a no-op. Only a real call produces a custom step: a plan read from data (an object literal,$state, an@Eachitem) loses its custom steps, and a legacy action object whose type names a custom action is ignored.library.toJSONSchema()lists actions underactions, the prompt lists them with the built-in action steps, andtoSpec()includes them. The ReactRendererand the server autofix parser pick them up automatically, and the react-uiButtonvalidates its form before a custom action.Types: the exported
ActionStepunion adds{ type: "custom_action"; name; params }, so aswitchoverActionSteptypes needs a case for it.In react-ui,
AgentInterfacetakesonAction, which receives the actions the chat does not handle itself, such as custom actions.The built-in steps (
@Run,@ToAssistant,@OpenUrl,@Set,@Reset) are now defined like custom actions and live in the same call registry, so their prompt lines are generated too (for example@OpenUrl(url: string)).ACTION_NAMESis removed.A defined action has a
.reffor slots that take only some actions, for exampleshare: z.union([copy.ref, steps.OpenUrl.ref]).optional(): the prompt signature printsshare?: @CopyToClipboard | @OpenUrl, and the JSON gets aCopyToClipboard$defsentry{ type: "CopyToClipboard", params }.#1348
9e76b1dThanks @Aditya-thesys! - OpenUI Lang 1.0 entry rule: the entry is therootstatement, else the first statement that calls the library root component, wherever it is (no-rootwithseverity: "warning"), else ano-rooterror. With no entry, statements are not also reported as orphaned.root = $t ? A : Bis a valid entry, exposed asParseResult.rootExpressionand evaluated with the newevaluateRoot(). An@Name(...)call that is not a built-in or action step reportsunknown-functionand evaluates to null; its statement is kept. React: renders ternary entries and reportsno-rootinstead ofparse-failedwhen statements parsed but no entry rendered.ValidationErrorCodeaddsno-rootandunknown-function.ValidationErrorandOpenUIErrorgain an optionalseverity: "warning"; react-lang passes it through toonError.Breaking:
- A program without
rootin which no statement calls the library root component no longer renders its first component statement. @Name(...)for a non-built-in, including@Card(...), now evaluates to null withunknown-functioninstead of acting as a component call.
- A program without
#1348
9e76b1dThanks @Aditya-thesys! - AddparseMessageandbuildMessagefor the OpenUI message protocol (]]>openui:content,context,endmarker lines). The react-langRenderernow accepts a stored message asresponseand renders its content.#1348
9e76b1dThanks @Aditya-thesys! - Addlibrary.extend(), which derives a new library from an existing one (the base stays untouched):lib.extend({ components: { add: [ProductCard], remove: ["Image"] }, functions: { add: [percent] }, actions: { add: [copy] } }). Components supportadd(to the library only, or into content slots with{ component, slots: ["Card"] }or"Card.children"),override(every parent points at the replacement) andremove(dropped from every parent union and fromcomponentGroups; removing the root or a slot's only type throws, and a removed name still in prompt notes, examples or rules warns once). Added functions and actions work like those passed tocreateLibrary. The result has no publicid. Adding a name that already exists throws. The typedonActionevent includes added actions and keeps the built-in events. Create derived libraries once at module scope, since parsers memoize by library identity. In development, react-lang registers each derived library with devtools under its own key.#1348
9e76b1dThanks @Aditya-thesys! - Add library functions:defineFunction({ name, description, params, returns, fn })pluscreateLibrary({ functions }), for example@Percent(done, total). Programs call them with positional arguments inparamskey order, andfnreceives one object with schema defaults applied.library.toJSONSchema()lists them underfunctions(params and returns as JSON Schema) andtoSpec()describes them like components, so every parser built from the schema, including the server autofix, accepts them. Args go through the component prop pipeline: the parser maps them by name and validates literals (type-mismatch,missing-required,excess-args; an invalid optional arg is dropped so its default applies), the runtime validates dynamic args and return values. An invalid call or a throwingfnevaluates to null with aruntime-error. Calls run on every streamed chunk like built-ins; the Renderer reports their errors once streaming ends. The prompt lists them with the built-in functions, and the newbuiltinFunctionsprompt option lists the built-ins withouttoolCallsorbindings; prompt options never change what parses or runs.Built-ins are now defined with
defineFunctiontoo, so their prompt lines are generated (for example@Sum(numbers: number[]) → number).BUILTINS,BUILTIN_NAMES,LAZY_BUILTINS,isBuiltinand theBuiltinDeftype are removed.#1348
9e76b1dThanks @Aditya-thesys! -@ToAssistant(message, context)passes its context through unchanged as any value (object, array, number, string, including falsy ones). Thecontinue_conversationstep'scontextis now typedunknown, and react-lang forwards it inparams.contextwhenever it is set. The react-ui chat adds it as the third element of the chat context, and card blocks append their item context to it as text, as before. The system prompt documents the context argument.
Patch Changes
#1348
9e76b1dThanks @Aditya-thesys! -parseMessagereads a content line that starts mid-line as a new content section, so a regenerated response wins over the cut-off one, also while streaming. react-lang and react-ui drop their own copies of this step, and a Cloud response keeps the second attempt's scripts.#1348
9e76b1dThanks @Aditya-thesys! - OpenUI 1.0 review fixes:- lang-core: the built-in functions prompt no longer uses react-ui's
Colin its@Eachexample, and names Query only when tool calls are on. - lang-core:
JSONSchemaDefaddstypeandanyOf, so the CLI's spec for a library that usesaction()passes togenerateSystemPromptwithout a cast. - react-ui: the chat prompt's button rules name
@ToAssistantand@OpenUrl. - react-ui, a2ui, assistant-ui, devtools, react-email: the
@openuidev/react-langpeer window now covers the version this release publishes.
- lang-core: the built-in functions prompt no longer uses react-ui's
#1348
9e76b1dThanks @Aditya-thesys! - A$statevalue that streams in no longer sticks at its half-written value: an untouched default is replaced when the full declaration arrives, a partly typed$nameno longer becomes state, and setting up declared defaults no longer firesonStateUpdate. User edits are kept.StreamParser.push,setandgetResulttake acompleteflag: passtrueonce the stream has ended, or a$namethat is the last token is not declared.
0.4.1
No changes in this release.
0.4.0
No changes in this release.
0.3.2
Patch Changes
- #1287
7c8f5e9Thanks @Aditya-thesys! - Report data (an object, array, string, number or boolean) in a slot that only takes components as atype-mismatchand prune it, instead of passing it through to render as a blank component or stray text. Slots whose schema also allows data are unchanged.
0.3.1
Patch Changes
- #1140
55df79cThanks @AbhinRustagi! - Fix streaming parsing so the latest definition of a repeated statement ID renders progressively as it arrives, matching how new statements stream. Completed programs use the last definition, matching the non-streaming parser.
0.3.0
Minor Changes
- #1069
f8d9b92Thanks @abhithesys! - Adopt automated release management via changesets. The lang-family packages (lang-core,react-lang,svelte-lang,vue-lang) now version together as a fixed group; this release unifies them on a single version line.