@zhama/a2ui-core 0.4.0 → 0.5.0
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 +60 -141
- package/dist/builders/index.cjs +2 -2
- package/dist/builders/index.d.cts +14 -3
- package/dist/builders/index.d.ts +14 -3
- package/dist/builders/index.js +2 -2
- package/dist/index.cjs +4 -3
- package/dist/index.d.cts +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.js +4 -3
- package/dist/{primitives-nmkVz-tB.d.cts → primitives-DLbBDhLq.d.cts} +1 -35
- package/dist/{primitives-nmkVz-tB.d.ts → primitives-DLbBDhLq.d.ts} +1 -35
- package/dist/surface/index.cjs +2 -2
- package/dist/surface/index.d.cts +1 -1
- package/dist/surface/index.d.ts +1 -1
- package/dist/surface/index.js +2 -2
- package/dist/types/index.cjs +2 -2
- package/dist/types/index.d.cts +62 -34
- package/dist/types/index.d.ts +62 -34
- package/dist/types/index.js +2 -2
- package/dist/utils/index.d.cts +1 -1
- package/dist/utils/index.d.ts +1 -1
- package/dist/validators/index.cjs +2 -1
- package/dist/validators/index.d.cts +78 -11
- package/dist/validators/index.d.ts +78 -11
- package/dist/validators/index.js +2 -1
- package/package.json +5 -1
package/dist/index.d.cts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
export { B as BooleanOrPath,
|
|
2
|
-
export { A2UI_EXTENSION_URI,
|
|
1
|
+
export { B as BooleanOrPath, C as ContextValue, N as NumberOrPath, a as StringArrayOrPath, S as StringOrPath } from './primitives-DLbBDhLq.cjs';
|
|
2
|
+
export { A2UI_EXTENSION_URI, A2UI_MIME_TYPE, Action, AnyComponent, AudioPlayerComponent, ButtonComponent, CardComponent, CheckBoxComponent, ChildrenProperty, ChoicePickerComponent, ClientErrorMessage, ClientToServerMessage, ColumnComponent, ComponentCommon, ComponentInstance, ComponentType, CreateSurfaceMessage, DataArray, DataChangeEvent, DataObject, DataValue, DateTimeInputComponent, DeleteSurfaceMessage, DividerComponent, GenericError, IconComponent, ImageComponent, ListComponent, ModalComponent, RowComponent, STANDARD_CATALOG_ID, ServerToClientMessageV09 as ServerToClientMessage, ServerToClientMessageV09, SliderComponent, StandardIconName, TabsComponent, TextComponent, TextFieldComponent, Theme, UpdateComponentsMessage, UpdateDataModelMessage, UserActionEvent, ValidationFailedError, VideoComponent, isV09Message } from './types/index.cjs';
|
|
3
3
|
export { AudioPlayerOptions, ButtonOptions, CardOptions, CheckBoxOptions, ChoicePickerOptions, ComponentOptions, DEFAULT_PATH_MAPPINGS, DateTimeInputOptions, DividerOptions, IconOptions, ImageOptions, LayoutOptions, ListOptions, ModalOptions, PathMappings, SliderOptions, TabItem, TabsOptions, TextFieldOptions, TextOptions, UpdateDataItem, VideoOptions, audioPlayer, body, button, caption, card, checkbox, choicePicker, column, createSurface, createV09Messages, dateTimeInput, deleteSurface, divider, flattenObjectToValueMap, generateId, getIdCounter, h1, h2, h3, h4, h5, icon, image, jsonlToMessages, list, messagesToJsonl, modal, normalizePath, objectToValueMap, resetIdCounter, row, slider, tabs, text, textButton, textField, updateComponents, updateDataModel, updatesToValueMap, valueMapToObject, valueToValueMap, video } from './builders/index.cjs';
|
|
4
|
-
export { ValidationError, ValidationOptions, ValidationResult, ValidationWarning, validateMessage, validateMessages,
|
|
4
|
+
export { A2UISchemaValidator, SchemaValidationError, SchemaValidationResult, ValidationError, ValidationOptions, ValidationResult, ValidationWarning, getSchemaValidator, validateClientMessage, validateMessage, validateMessages, validateMessagesWithSchema, validateV09Message, validateWithSchema } from './validators/index.cjs';
|
|
5
5
|
export { deepMerge, getLiteralValue, getPathValue, isPathBinding, path, uuid } from './utils/index.cjs';
|
|
6
6
|
export { SURFACE_IDS, SurfaceConfig, SurfaceIdType, SurfaceResult, createA2UISurface, createA2UISurfaceWithData, createChatSurface, createDeleteSurfaceMessage, createInputFormSurface, createOrchestrationSurface, createRecommendationSurface, createStatusSurface, generateSurfaceId, resetSurfaceIdCounter } from './surface/index.cjs';
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
export { B as BooleanOrPath,
|
|
2
|
-
export { A2UI_EXTENSION_URI,
|
|
1
|
+
export { B as BooleanOrPath, C as ContextValue, N as NumberOrPath, a as StringArrayOrPath, S as StringOrPath } from './primitives-DLbBDhLq.js';
|
|
2
|
+
export { A2UI_EXTENSION_URI, A2UI_MIME_TYPE, Action, AnyComponent, AudioPlayerComponent, ButtonComponent, CardComponent, CheckBoxComponent, ChildrenProperty, ChoicePickerComponent, ClientErrorMessage, ClientToServerMessage, ColumnComponent, ComponentCommon, ComponentInstance, ComponentType, CreateSurfaceMessage, DataArray, DataChangeEvent, DataObject, DataValue, DateTimeInputComponent, DeleteSurfaceMessage, DividerComponent, GenericError, IconComponent, ImageComponent, ListComponent, ModalComponent, RowComponent, STANDARD_CATALOG_ID, ServerToClientMessageV09 as ServerToClientMessage, ServerToClientMessageV09, SliderComponent, StandardIconName, TabsComponent, TextComponent, TextFieldComponent, Theme, UpdateComponentsMessage, UpdateDataModelMessage, UserActionEvent, ValidationFailedError, VideoComponent, isV09Message } from './types/index.js';
|
|
3
3
|
export { AudioPlayerOptions, ButtonOptions, CardOptions, CheckBoxOptions, ChoicePickerOptions, ComponentOptions, DEFAULT_PATH_MAPPINGS, DateTimeInputOptions, DividerOptions, IconOptions, ImageOptions, LayoutOptions, ListOptions, ModalOptions, PathMappings, SliderOptions, TabItem, TabsOptions, TextFieldOptions, TextOptions, UpdateDataItem, VideoOptions, audioPlayer, body, button, caption, card, checkbox, choicePicker, column, createSurface, createV09Messages, dateTimeInput, deleteSurface, divider, flattenObjectToValueMap, generateId, getIdCounter, h1, h2, h3, h4, h5, icon, image, jsonlToMessages, list, messagesToJsonl, modal, normalizePath, objectToValueMap, resetIdCounter, row, slider, tabs, text, textButton, textField, updateComponents, updateDataModel, updatesToValueMap, valueMapToObject, valueToValueMap, video } from './builders/index.js';
|
|
4
|
-
export { ValidationError, ValidationOptions, ValidationResult, ValidationWarning, validateMessage, validateMessages,
|
|
4
|
+
export { A2UISchemaValidator, SchemaValidationError, SchemaValidationResult, ValidationError, ValidationOptions, ValidationResult, ValidationWarning, getSchemaValidator, validateClientMessage, validateMessage, validateMessages, validateMessagesWithSchema, validateV09Message, validateWithSchema } from './validators/index.js';
|
|
5
5
|
export { deepMerge, getLiteralValue, getPathValue, isPathBinding, path, uuid } from './utils/index.js';
|
|
6
6
|
export { SURFACE_IDS, SurfaceConfig, SurfaceIdType, SurfaceResult, createA2UISurface, createA2UISurfaceWithData, createChatSurface, createDeleteSurfaceMessage, createInputFormSurface, createOrchestrationSurface, createRecommendationSurface, createStatusSurface, generateSurfaceId, resetSurfaceIdCounter } from './surface/index.js';
|
package/dist/index.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
`)}function
|
|
3
|
-
`).filter(t=>t.trim()).map(t=>JSON.parse(t))}var T={};function de(e,t=""){let n=[];for(let[a,o]of Object.entries(e)){let r=t?`${t}/${a}`:`/${a}`;n.push(l(r,o));}return n}function l(e,t){if(t==null)return {key:e,valueString:""};if(typeof t=="string")return {key:e,valueString:t};if(typeof t=="number")return {key:e,valueNumber:t};if(typeof t=="boolean")return {key:e,valueBoolean:t};if(Array.isArray(t))return {key:e,valueMap:t.map((n,a)=>l(String(a),n))};if(typeof t=="object"){let n=[];for(let[a,o]of Object.entries(t))n.push(l(a,o));return {key:e,valueMap:n}}return {key:e,valueString:String(t)}}function y(e,t={}){let n=e.replace(/\./g,"/");n.startsWith("/")||(n=`/${n}`);for(let[a,o]of Object.entries(t)){let r=new RegExp(`^/${a}(/|$)`);r.test(n)&&(n=n.replace(r,`/${o}$1`));}return n}function le(e,t="",n=T){let a=[];for(let o of e){let r=o.path.startsWith("/")?o.path:`${t}/${o.path}`,i=y(r,n);if(o.value!==null&&typeof o.value=="object"&&!Array.isArray(o.value)){let s=x(o.value,i);a.push(...s);}else a.push(l(i,o.value));}return a}function x(e,t){let n=[];for(let[a,o]of Object.entries(e)){let r=`${t}/${a}`;if(o!==null&&typeof o=="object"&&!Array.isArray(o)){let i=x(o,r);n.push(...i);}else n.push(l(r,o));}return n}function V(e){let t={};for(let n of e){let a=n.key.startsWith("/")?n.key.slice(1):n.key;n.valueString!==void 0?t[a]=n.valueString:n.valueNumber!==void 0?t[a]=n.valueNumber:n.valueBoolean!==void 0?t[a]=n.valueBoolean:n.valueMap!==void 0&&(t[a]=V(n.valueMap));}return t}var Te=["Text","Image","Icon","Video","AudioPlayer","Row","Column","List","Card","Tabs","Divider","Modal","Button","CheckBox","TextField","DateTimeInput","ChoicePicker","Slider"];function D(e,t={}){let n=[],a=[];if("createSurface"in e){let{createSurface:o}=e;o.surfaceId||n.push({code:"MISSING_SURFACE_ID",message:"createSurface.surfaceId is required",path:"createSurface.surfaceId"}),o.catalogId||n.push({code:"MISSING_CATALOG_ID",message:"createSurface.catalogId is required",path:"createSurface.catalogId"});}else if("updateComponents"in e){let{updateComponents:o}=e;o.surfaceId||n.push({code:"MISSING_SURFACE_ID",message:"updateComponents.surfaceId is required",path:"updateComponents.surfaceId"}),!o.components||!Array.isArray(o.components)?n.push({code:"INVALID_COMPONENTS",message:"updateComponents.components must be an array",path:"updateComponents.components"}):ye(o.components,n,a,t);}else if("updateDataModel"in e){let{updateDataModel:o}=e;o.surfaceId||n.push({code:"MISSING_SURFACE_ID",message:"updateDataModel.surfaceId is required",path:"updateDataModel.surfaceId"});}else if("deleteSurface"in e){let{deleteSurface:o}=e;o.surfaceId||n.push({code:"MISSING_SURFACE_ID",message:"deleteSurface.surfaceId is required",path:"deleteSurface.surfaceId"});}else n.push({code:"INVALID_MESSAGE_TYPE",message:"Message must contain one of: createSurface, updateComponents, updateDataModel, deleteSurface"});return {valid:n.length===0,errors:n,warnings:a}}function b(e,t={}){let n=[],a=[];if("beginRendering"in e){let{beginRendering:o}=e;o.surfaceId||n.push({code:"MISSING_SURFACE_ID",message:"beginRendering.surfaceId is required",path:"beginRendering.surfaceId"}),o.root||n.push({code:"MISSING_ROOT",message:"beginRendering.root is required",path:"beginRendering.root"});}else if("surfaceUpdate"in e){let{surfaceUpdate:o}=e;o.surfaceId||n.push({code:"MISSING_SURFACE_ID",message:"surfaceUpdate.surfaceId is required",path:"surfaceUpdate.surfaceId"}),!o.components||!Array.isArray(o.components)?n.push({code:"INVALID_COMPONENTS",message:"surfaceUpdate.components must be an array",path:"surfaceUpdate.components"}):Ve(o.components,n,a,t);}else if("dataModelUpdate"in e){let{dataModelUpdate:o}=e;o.surfaceId||n.push({code:"MISSING_SURFACE_ID",message:"dataModelUpdate.surfaceId is required",path:"dataModelUpdate.surfaceId"}),(!o.contents||!Array.isArray(o.contents))&&n.push({code:"INVALID_CONTENTS",message:"dataModelUpdate.contents must be an array",path:"dataModelUpdate.contents"});}else if("deleteSurface"in e){let{deleteSurface:o}=e;o.surfaceId||n.push({code:"MISSING_SURFACE_ID",message:"deleteSurface.surfaceId is required",path:"deleteSurface.surfaceId"});}else n.push({code:"INVALID_MESSAGE_TYPE",message:"Message must contain one of: beginRendering, surfaceUpdate, dataModelUpdate, deleteSurface"});return {valid:n.length===0,errors:n,warnings:a}}function A(e,t={}){return "createSurface"in e||"updateComponents"in e||"updateDataModel"in e?D(e,t):"beginRendering"in e||"surfaceUpdate"in e||"dataModelUpdate"in e?b(e,t):"deleteSurface"in e?e.deleteSurface.surfaceId?{valid:true,errors:[],warnings:[]}:{valid:false,errors:[{code:"MISSING_SURFACE_ID",message:"deleteSurface.surfaceId is required",path:"deleteSurface.surfaceId"}],warnings:[]}:{valid:false,errors:[{code:"UNKNOWN_MESSAGE_TYPE",message:"Unknown message type"}],warnings:[]}}function fe(e,t={}){let n=[],a=[];for(let o=0;o<e.length;o++){let r=e[o];if(!r)continue;let i=A(r,t);for(let s of i.errors)n.push({...s,path:`messages[${o}].${s.path??""}`});for(let s of i.warnings)a.push({...s,path:`messages[${o}].${s.path??""}`});}return {valid:n.length===0,errors:n,warnings:a}}function ye(e,t,n,a){let o=new Set,r=false;for(let i=0;i<e.length;i++){let s=e[i];if(!s)continue;let u=`updateComponents.components[${i}]`;s.id?(o.has(s.id)&&t.push({code:"DUPLICATE_COMPONENT_ID",message:`Duplicate component id: ${s.id}`,path:`${u}.id`}),o.add(s.id),s.id==="root"&&(r=true)):t.push({code:"MISSING_COMPONENT_ID",message:"Component id is required",path:`${u}.id`}),s.component?a.strict&&a.allowedComponents&&(a.allowedComponents.includes(s.component)||n.push({code:"UNKNOWN_COMPONENT_TYPE",message:`Unknown component type: ${s.component}`,path:`${u}.component`})):t.push({code:"MISSING_COMPONENT_TYPE",message:"Component type is required",path:`${u}.component`});}!r&&a.strict&&n.push({code:"MISSING_ROOT_COMPONENT",message:'No component with id "root" found',path:"updateComponents.components"});}function Ve(e,t,n,a){let o=new Set;for(let r=0;r<e.length;r++){let i=e[r];if(!i)continue;let s=`surfaceUpdate.components[${r}]`;if(i.id?(o.has(i.id)&&t.push({code:"DUPLICATE_COMPONENT_ID",message:`Duplicate component id: ${i.id}`,path:`${s}.id`}),o.add(i.id)):t.push({code:"MISSING_COMPONENT_ID",message:"Component id is required",path:`${s}.id`}),!i.component||typeof i.component!="object")t.push({code:"MISSING_COMPONENT",message:"Component definition is required",path:`${s}.component`});else {let u=Object.keys(i.component)[0];u&&a.strict&&!Te.includes(u)&&n.push({code:"UNKNOWN_COMPONENT_TYPE",message:`Unknown component type: ${u}`,path:`${s}.component`});}}}function P(e){return typeof e=="object"&&e!==null&&"path"in e}function De(e){if(!P(e))return e}function be(e){if(P(e))return e.path}function Ae(e){return {path:e}}function me(e,t){let n={...e};for(let a of Object.keys(t)){let o=t[a],r=n[a];o!==void 0&&typeof o=="object"&&o!==null&&!Array.isArray(o)&&typeof r=="object"&&r!==null&&!Array.isArray(r)?n[a]=me(r,o):o!==void 0&&(n[a]=o);}return n}function Pe(){return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,e=>{let t=Math.random()*16|0;return (e==="x"?t:t&3|8).toString(16)})}var d={CHAT:"@chat",RECOMMENDATION:"@recommendation",INPUT_FORM:"@input-form",ORCHESTRATION:"@orchestration",STATUS:"@status",RESULT:"@result",CONFIRM:"@confirm",NOTIFICATION:"@notification"},v=0;function S(e="surface"){return v++,`${e}-${Date.now()}-${v}`}function ge(){v=0;}function f(e,t,n){let a=n??S();return t.find(i=>i.id===e)||console.warn(`[A2UI] Root component "${e}" not found in components list`),{messages:[m(a),g(a,t)],surfaceId:a}}function Ce(e,t,n,a){let o=a??S();return {messages:[m(o),g(o,t),I(o,n)],surfaceId:o}}function Ie(e){return h(e)}function Se(e,t){return f(e,t,d.CHAT)}function he(e,t){return f(e,t,d.RECOMMENDATION)}function xe(e,t){return f(e,t,d.INPUT_FORM)}function Oe(e,t){return f(e,t,d.ORCHESTRATION)}function Me(e,t){return f(e,t,d.STATUS)}export{E as A2UI_EXTENSION_URI,_ as A2UI_EXTENSION_URI_V08,R as A2UI_MIME_TYPE,T as DEFAULT_PATH_MAPPINGS,C as STANDARD_CATALOG_ID,d as SURFACE_IDS,$ as audioPlayer,se as body,M as button,ie as caption,W as card,z as checkbox,Q as choicePicker,H as column,f as createA2UISurface,Ce as createA2UISurfaceWithData,Se as createChatSurface,Ie as createDeleteSurfaceMessage,xe as createInputFormSurface,Oe as createOrchestrationSurface,he as createRecommendationSurface,Me as createStatusSurface,m as createSurface,pe as createV09Messages,K as dateTimeInput,me as deepMerge,h as deleteSurface,Y as divider,x as flattenObjectToValueMap,p as generateId,S as generateSurfaceId,k as getIdCounter,De as getLiteralValue,be as getPathValue,te as h1,ne as h2,oe as h3,ae as h4,re as h5,F as icon,j as image,P as isPathBinding,U as isV08Message,N as isV09Message,ue as jsonlToMessages,G as list,ce as messagesToJsonl,X as modal,y as normalizePath,de as objectToValueMap,Ae as path,w as resetIdCounter,ge as resetSurfaceIdCounter,L as row,Z as slider,q as tabs,c as text,ee as textButton,J as textField,g as updateComponents,I as updateDataModel,le as updatesToValueMap,Pe as uuid,A as validateMessage,fe as validateMessages,b as validateV08Message,D as validateV09Message,V as valueMapToObject,l as valueToValueMap,B as video};
|
|
1
|
+
import ke from'ajv/dist/2020';import qe from'ajv-formats';var Ve=Object.defineProperty;var Ae=(e,t,n)=>t in e?Ve(e,t,{enumerable:true,configurable:true,writable:true,value:n}):e[t]=n;var S=(e,t,n)=>Ae(e,typeof t!="symbol"?t+"":t,n);function _(e){return "createSurface"in e||"updateComponents"in e||"updateDataModel"in e}var h="https://a2ui.dev/specification/0.9/standard_catalog_definition.json";var U="https://a2ui.dev/specification/0.9",E="application/json+a2ui";var b=0;function s(e="comp"){return `${e}_${Date.now()}_${b++}`}function R(){b=0;}function N(){return b}function c(e,t={}){let{id:n=s("text"),weight:r,usageHint:o}=t;return {id:n,component:"Text",text:e,...r!==void 0&&{weight:r},...o&&{usageHint:o}}}function k(e,t={}){let{id:n=s("image"),weight:r,fit:o,usageHint:a}=t;return {id:n,component:"Image",url:e,...r!==void 0&&{weight:r},...o&&{fit:o},...a&&{usageHint:a}}}function q(e,t={}){let{id:n=s("icon"),weight:r}=t;return {id:n,component:"Icon",name:e,...r!==void 0&&{weight:r}}}function F(e,t={}){let{id:n=s("video"),weight:r}=t;return {id:n,component:"Video",url:e,...r!==void 0&&{weight:r}}}function B(e,t={}){let{id:n=s("audio"),weight:r,description:o}=t;return {id:n,component:"AudioPlayer",url:e,...r!==void 0&&{weight:r},...o&&{description:o}}}function L(e,t={}){let{id:n=s("row"),weight:r,alignment:o,distribution:a}=t;return {id:n,component:"Row",children:e,...r!==void 0&&{weight:r},...o&&{alignment:o},...a&&{distribution:a}}}function H(e,t={}){let{id:n=s("column"),weight:r,alignment:o,distribution:a}=t;return {id:n,component:"Column",children:e,...r!==void 0&&{weight:r},...o&&{alignment:o},...a&&{distribution:a}}}function G(e,t={}){let{id:n=s("list"),weight:r,direction:o,alignment:a}=t;return {id:n,component:"List",children:e,...r!==void 0&&{weight:r},...o&&{direction:o},...a&&{alignment:a}}}function W(e,t={}){let{id:n=s("card"),weight:r}=t;return {id:n,component:"Card",child:e,...r!==void 0&&{weight:r}}}function z(e,t={}){let{id:n=s("tabs"),weight:r}=t;return {id:n,component:"Tabs",tabItems:e.map(o=>({title:o.title,child:o.childId})),...r!==void 0&&{weight:r}}}function J(e={}){let{id:t=s("divider"),weight:n,axis:r}=e;return {id:t,component:"Divider",...n!==void 0&&{weight:n},...r&&{axis:r}}}function Y(e,t,n={}){let{id:r=s("modal"),weight:o}=n;return {id:r,component:"Modal",entryPointChild:e,contentChild:t,...o!==void 0&&{weight:o}}}function v(e,t,n={}){let{id:r=s("button"),weight:o,primary:a}=n;return {id:r,component:"Button",child:e,action:t,...o!==void 0&&{weight:o},...a!==void 0&&{primary:a}}}function X(e,t,n={}){let{id:r=s("checkbox"),weight:o}=n;return {id:r,component:"CheckBox",label:e,value:t,...o!==void 0&&{weight:o}}}function K(e,t,n={}){let{id:r=s("textfield"),weight:o,usageHint:a,validationRegexp:i}=n;return {id:r,component:"TextField",label:e,...t!==void 0&&{text:t},...o!==void 0&&{weight:o},...a&&{usageHint:a},...i&&{validationRegexp:i}}}function Q(e,t={}){let{id:n=s("datetime"),weight:r,enableDate:o,enableTime:a,outputFormat:i,label:p}=t;return {id:n,component:"DateTimeInput",value:e,...r!==void 0&&{weight:r},...o!==void 0&&{enableDate:o},...a!==void 0&&{enableTime:a},...i&&{outputFormat:i},...p&&{label:p}}}function Z(e,t,n,r={}){let{id:o=s("choice"),weight:a,label:i}=r;return {id:o,component:"ChoicePicker",options:e,value:t,usageHint:n,...a!==void 0&&{weight:a},...i&&{label:i}}}function ee(e,t={}){let{id:n=s("slider"),weight:r,label:o,min:a,max:i}=t;return {id:n,component:"Slider",value:e,...r!==void 0&&{weight:r},...o&&{label:o},...a!==void 0&&{min:a},...i!==void 0&&{max:i}}}function te(e,t,n={}){let r=n.textId??s("btn_text"),o=c(e,{id:r}),a=v(r,t,n);return [o,a]}function ne(e,t={}){return c(e,{...t,usageHint:"h1"})}function oe(e,t={}){return c(e,{...t,usageHint:"h2"})}function re(e,t={}){return c(e,{...t,usageHint:"h3"})}function ae(e,t={}){return c(e,{...t,usageHint:"h4"})}function ie(e,t={}){return c(e,{...t,usageHint:"h5"})}function se(e,t={}){return c(e,{...t,usageHint:"caption"})}function pe(e,t={}){return c(e,{...t,usageHint:"body"})}function m(e,t=h){return {createSurface:{surfaceId:e,catalogId:t}}}function f(e,t){return {updateComponents:{surfaceId:e,components:t}}}function g(e,t,n,r="replace"){return {updateDataModel:{surfaceId:e,...n&&{path:n},op:r,...r!=="remove"&&{value:t}}}}function O(e){return {deleteSurface:{surfaceId:e}}}function ce(e){let{surfaceId:t,catalogId:n=h,components:r,dataModel:o}=e,a=[m(t,n),f(t,r)];return o&&a.push(g(t,o)),a}function de(e){return e.map(t=>JSON.stringify(t)).join(`
|
|
2
|
+
`)}function le(e){return e.split(`
|
|
3
|
+
`).filter(t=>t.trim()).map(t=>JSON.parse(t))}var M={};function ue(e,t=""){let n=[];for(let[r,o]of Object.entries(e)){let a=t?`${t}/${r}`:`/${r}`;n.push(l(a,o));}return n}function l(e,t){if(t==null)return {key:e,valueString:""};if(typeof t=="string")return {key:e,valueString:t};if(typeof t=="number")return {key:e,valueNumber:t};if(typeof t=="boolean")return {key:e,valueBoolean:t};if(Array.isArray(t))return {key:e,valueMap:t.map((n,r)=>l(String(r),n))};if(typeof t=="object"){let n=[];for(let[r,o]of Object.entries(t))n.push(l(r,o));return {key:e,valueMap:n}}return {key:e,valueString:String(t)}}function P(e,t={}){let n=e.replace(/\./g,"/");n.startsWith("/")||(n=`/${n}`);for(let[r,o]of Object.entries(t)){let a=new RegExp(`^/${r}(/|$)`);a.test(n)&&(n=n.replace(a,`/${o}$1`));}return n}function me(e,t="",n=M){let r=[];for(let o of e){let a=o.path.startsWith("/")?o.path:`${t}/${o.path}`,i=P(a,n);if(o.value!==null&&typeof o.value=="object"&&!Array.isArray(o.value)){let p=T(o.value,i);r.push(...p);}else r.push(l(i,o.value));}return r}function T(e,t){let n=[];for(let[r,o]of Object.entries(e)){let a=`${t}/${r}`;if(o!==null&&typeof o=="object"&&!Array.isArray(o)){let i=T(o,a);n.push(...i);}else n.push(l(a,o));}return n}function D(e){let t={};for(let n of e){let r=n.key.startsWith("/")?n.key.slice(1):n.key;n.valueString!==void 0?t[r]=n.valueString:n.valueNumber!==void 0?t[r]=n.valueNumber:n.valueBoolean!==void 0?t[r]=n.valueBoolean:n.valueMap!==void 0&&(t[r]=D(n.valueMap));}return t}var we=["Text","Image","Icon","Video","AudioPlayer","Row","Column","List","Card","Tabs","Divider","Modal","Button","CheckBox","TextField","DateTimeInput","ChoicePicker","Slider"];function j(e,t={}){let n=[],r=[];if("createSurface"in e){let{createSurface:o}=e;o.surfaceId||n.push({code:"MISSING_SURFACE_ID",message:"createSurface.surfaceId is required",path:"createSurface.surfaceId"}),o.catalogId||n.push({code:"MISSING_CATALOG_ID",message:"createSurface.catalogId is required",path:"createSurface.catalogId"});}else if("updateComponents"in e){let{updateComponents:o}=e;o.surfaceId||n.push({code:"MISSING_SURFACE_ID",message:"updateComponents.surfaceId is required",path:"updateComponents.surfaceId"}),!o.components||!Array.isArray(o.components)?n.push({code:"INVALID_COMPONENTS",message:"updateComponents.components must be an array",path:"updateComponents.components"}):_e(o.components,n,r,t);}else if("updateDataModel"in e){let{updateDataModel:o}=e;o.surfaceId||n.push({code:"MISSING_SURFACE_ID",message:"updateDataModel.surfaceId is required",path:"updateDataModel.surfaceId"}),o.op&&!["add","replace","remove"].includes(o.op)&&n.push({code:"INVALID_OP",message:"updateDataModel.op must be one of: add, replace, remove",path:"updateDataModel.op"}),o.op==="remove"&&o.value!==void 0&&r.push({code:"UNNECESSARY_VALUE",message:"updateDataModel.value should not be provided for remove operation",path:"updateDataModel.value"}),o.op!=="remove"&&o.value===void 0&&o.op==="add"&&n.push({code:"MISSING_VALUE",message:"updateDataModel.value is required for add operation",path:"updateDataModel.value"});}else if("deleteSurface"in e){let{deleteSurface:o}=e;o.surfaceId||n.push({code:"MISSING_SURFACE_ID",message:"deleteSurface.surfaceId is required",path:"deleteSurface.surfaceId"});}else n.push({code:"INVALID_MESSAGE_TYPE",message:"Message must contain one of: createSurface, updateComponents, updateDataModel, deleteSurface"});return {valid:n.length===0,errors:n,warnings:r}}function $(e,t={}){return j(e,t)}function fe(e,t={}){let n=[],r=[];for(let o=0;o<e.length;o++){let a=e[o];if(!a)continue;let i=$(a,t);for(let p of i.errors)n.push({...p,path:`messages[${o}].${p.path??""}`});for(let p of i.warnings)r.push({...p,path:`messages[${o}].${p.path??""}`});}return {valid:n.length===0,errors:n,warnings:r}}function _e(e,t,n,r){let o=new Set,a=false;for(let i=0;i<e.length;i++){let p=e[i];if(!p)continue;let x=`updateComponents.components[${i}]`;p.id?(o.has(p.id)&&t.push({code:"DUPLICATE_COMPONENT_ID",message:`Duplicate component id: ${p.id}`,path:`${x}.id`}),o.add(p.id),p.id==="root"&&(a=true)):t.push({code:"MISSING_COMPONENT_ID",message:"Component id is required",path:`${x}.id`}),p.component?r.strict&&!we.includes(p.component)&&r.allowedComponents&&!r.allowedComponents.includes(p.component)&&n.push({code:"UNKNOWN_COMPONENT_TYPE",message:`Unknown component type: ${p.component}`,path:`${x}.component`}):t.push({code:"MISSING_COMPONENT_TYPE",message:"Component type is required",path:`${x}.component`});}!a&&r.strict&&n.push({code:"MISSING_ROOT_COMPONENT",message:'No component with id "root" found',path:"updateComponents.components"});}var he={title:"A2UI (Agent to UI) Client-to-Server Event Schema",description:"Describes a JSON payload for a client-to-server event message.",type:"object",minProperties:1,maxProperties:1,properties:{userAction:{type:"object",description:"Reports a user-initiated action from a component.",properties:{name:{type:"string",description:"The name of the action, taken from the component's action.name property."},surfaceId:{type:"string",description:"The id of the surface where the event originated."},sourceComponentId:{type:"string",description:"The id of the component that triggered the event."},timestamp:{type:"string",format:"date-time",description:"An ISO 8601 timestamp of when the event occurred."},context:{type:"object",description:"A JSON object containing the key-value pairs from the component's action.context, after resolving all data bindings.",additionalProperties:true}},required:["name","surfaceId","sourceComponentId","timestamp","context"]},error:{description:"Reports a client-side error.",oneOf:[{type:"object",title:"Validation Failed Error",properties:{code:{const:"VALIDATION_FAILED"},surfaceId:{type:"string",description:"The id of the surface where the error occurred."},path:{type:"string",description:"The JSON pointer to the field that failed validation (e.g. '/components/0/text')."},message:{type:"string",description:"A short one-sentence description of why validation failed."}},required:["code","path","message","surfaceId"]},{type:"object",title:"Generic Error",properties:{code:{not:{const:"VALIDATION_FAILED"}},message:{type:"string",description:"A short one-sentence description of why the error occurred."},surfaceId:{type:"string",description:"The id of the surface where the error occurred."}},required:["code","surfaceId","message"],additionalProperties:true}]}},oneOf:[{required:["userAction"]},{required:["clientUiCapabilities"]},{required:["error"]}]};var ge={$schema:"https://json-schema.org/draft/2020-12/schema",$id:"https://a2ui.dev/specification/0.9/common_types.json",title:"A2UI Common Types",description:"Common type definitions used across A2UI schemas.",$defs:{stringOrPath:{description:"Represents a value that can be either a literal string or a path to a value in the data model.",oneOf:[{type:"string"},{type:"object",properties:{path:{type:"string"}},required:["path"],additionalProperties:false}]},numberOrPath:{description:"Represents a value that can be either a literal number or a path to a value in the data model.",oneOf:[{type:"number"},{type:"object",properties:{path:{type:"string"}},required:["path"],additionalProperties:false}]},booleanOrPath:{description:"Represents a value that can be either a literal boolean or a path to a value in the data model.",oneOf:[{type:"boolean"},{type:"object",properties:{path:{type:"string"}},required:["path"],additionalProperties:false}]},stringArrayOrPath:{description:"Represents a value that can be either a literal array of strings or a path to a value in the data model.",oneOf:[{type:"array",items:{type:"string"}},{type:"object",properties:{path:{type:"string"}},required:["path"],additionalProperties:false}]},id:{type:"string",description:"The unique identifier for this component."},ComponentCommon:{type:"object",properties:{id:{$ref:"#/$defs/id"},weight:{type:"number",description:"The relative weight of this component within a Row or Column. This is similar to the CSS 'flex-grow' property."}},required:["id"]},contextValue:{description:"A value that can be a string, number, boolean, or a path to a value.",oneOf:[{type:"string"},{type:"number"},{type:"boolean"},{type:"object",properties:{path:{type:"string"}},required:["path"],additionalProperties:false}]},childrenProperty:{oneOf:[{type:"array",items:{type:"string"},description:"A static list of child component IDs."},{type:"object",description:"A template for generating a dynamic list of children from a data model list. The `componentId` is the component to use as a template.",properties:{componentId:{$ref:"#/$defs/id"},path:{type:"string",description:"The path to the list of component property objects in the data model."}},required:["componentId","path"],additionalProperties:false}]}}};var ye={$schema:"https://json-schema.org/draft/2020-12/schema",$id:"https://a2ui.dev/specification/0.9/server_to_client.json",title:"A2UI Message Schema",description:"Describes a JSON payload for an A2UI (Agent to UI) message, which is used to dynamically construct and update user interfaces.",type:"object",oneOf:[{$ref:"#/$defs/CreateSurfaceMessage"},{$ref:"#/$defs/UpdateComponentsMessage"},{$ref:"#/$defs/UpdateDataModelMessage"},{$ref:"#/$defs/DeleteSurfaceMessage"}],$defs:{CreateSurfaceMessage:{properties:{createSurface:{type:"object",description:"Signals the client to create a new surface and begin rendering it. When this message is sent, the client will expect 'updateComponents' and/or 'updateDataModel' messages for the same surfaceId that define the component tree.",properties:{surfaceId:{type:"string",description:"The unique identifier for the UI surface to be rendered."},catalogId:{title:"Catalog ID",description:"A string that uniquely identifies this catalog. It is recommended to prefix this with an internet domain that you own, to avoid conflicts e.g. mycompany.com:somecatalog'.",type:"string"}},required:["surfaceId","catalogId"],additionalProperties:false}},required:["createSurface"],additionalProperties:false},UpdateComponentsMessage:{properties:{updateComponents:{type:"object",description:"Updates a surface with a new set of components. This message can be sent multiple times to update the component tree of an existing surface. One of the components in one of the components lists MUST have an 'id' of 'root' to serve as the root of the component tree. The createSurface message MUST have been previously sent with the 'catalogId' that is in this message.",properties:{surfaceId:{type:"string",description:"The unique identifier for the UI surface to be updated."},components:{type:"array",description:"A list containing all UI components for the surface.",minItems:1,items:{$ref:"standard_catalog_definition.json#/$defs/anyComponent"}}},required:["surfaceId","components"],additionalProperties:false}},required:["updateComponents"],additionalProperties:false},UpdateDataModelMessage:{properties:{updateDataModel:{type:"object",description:"Updates the data model for an existing surface. This message can be sent multiple times to update the data model. The createSurface message MUST have been previously sent with the 'catalogId' that is in this message.",properties:{surfaceId:{type:"string",description:"The unique identifier for the UI surface this data model update applies to."},path:{type:"string",description:"An optional path to a location within the data model (e.g., '/user/name'). If omitted, or set to '/', refers to the entire data model."},op:{type:"string",description:"The operation to perform on the data model. Defaults to 'replace' if omitted.",enum:["add","replace","remove"]},value:{description:"The data to be updated in the data model. Required for 'add' and 'replace' operations. Not allowed for 'remove' operation.",additionalProperties:true}},required:["surfaceId"],additionalProperties:false}},required:["updateDataModel"],additionalProperties:false},DeleteSurfaceMessage:{properties:{deleteSurface:{type:"object",description:"Signals the client to delete the surface identified by 'surfaceId'. The createSurface message MUST have been previously sent with the 'catalogId' that is in this message.",properties:{surfaceId:{type:"string",description:"The unique identifier for the UI surface to be deleted."}},required:["surfaceId"],additionalProperties:false}},required:["deleteSurface"],additionalProperties:false}}};var Ce={$schema:"https://json-schema.org/draft/2020-12/schema",$id:"https://a2ui.dev/specification/0.9/standard_catalog_definition.json",title:"A2UI Component Catalog",description:"Definitions for the standard catalog of A2UI components.",$defs:{Theme:{type:"object",description:"Theming information for the UI.",properties:{font:{type:"string",description:"The primary font for the UI."},primaryColor:{type:"string",description:"The primary UI color as a hexadecimal code (e.g., '#00BFFF').",pattern:"^#[0-9a-fA-F]{6}$"}},additionalProperties:false},anyComponent:{oneOf:[{$ref:"#/$defs/Text"},{$ref:"#/$defs/Image"},{$ref:"#/$defs/Icon"},{$ref:"#/$defs/Video"},{$ref:"#/$defs/AudioPlayer"},{$ref:"#/$defs/Row"},{$ref:"#/$defs/Column"},{$ref:"#/$defs/List"},{$ref:"#/$defs/Card"},{$ref:"#/$defs/Tabs"},{$ref:"#/$defs/Divider"},{$ref:"#/$defs/Modal"},{$ref:"#/$defs/Button"},{$ref:"#/$defs/CheckBox"},{$ref:"#/$defs/TextField"},{$ref:"#/$defs/DateTimeInput"},{$ref:"#/$defs/ChoicePicker"},{$ref:"#/$defs/Slider"}],discriminator:{propertyName:"component"}},Text:{type:"object",allOf:[{$ref:"common_types.json#/$defs/ComponentCommon"},{type:"object",properties:{component:{const:"Text"},text:{$ref:"common_types.json#/$defs/stringOrPath",description:"The text content to display. While simple Markdown formatting is supported (i.e. without HTML, images, or links), utilizing dedicated UI components is generally preferred for a richer and more structured presentation."},usageHint:{type:"string",description:"A hint for the base text style.",enum:["h1","h2","h3","h4","h5","caption","body"]}},required:["component","text"]}],unevaluatedProperties:false},Image:{type:"object",allOf:[{$ref:"common_types.json#/$defs/ComponentCommon"},{type:"object",properties:{component:{const:"Image"},url:{$ref:"common_types.json#/$defs/stringOrPath",description:"The URL of the image to display."},fit:{type:"string",description:"Specifies how the image should be resized to fit its container. This corresponds to the CSS 'object-fit' property.",enum:["contain","cover","fill","none","scale-down"]},usageHint:{type:"string",description:"A hint for the image size and style.",enum:["icon","avatar","smallFeature","mediumFeature","largeFeature","header"]}},required:["component","url"]}],unevaluatedProperties:false},Icon:{type:"object",allOf:[{$ref:"common_types.json#/$defs/ComponentCommon"},{type:"object",properties:{component:{const:"Icon"},name:{description:"The name of the icon to display.",oneOf:[{type:"string",enum:["accountCircle","add","arrowBack","arrowForward","attachFile","calendarToday","call","camera","check","close","delete","download","edit","event","error","fastForward","favorite","favoriteOff","folder","help","home","info","locationOn","lock","lockOpen","mail","menu","moreVert","moreHoriz","notificationsOff","notifications","pause","payment","person","phone","photo","play","print","refresh","rewind","search","send","settings","share","shoppingCart","skipNext","skipPrevious","star","starHalf","starOff","stop","upload","visibility","visibilityOff","volumeDown","volumeMute","volumeOff","volumeUp","warning"]},{type:"object",properties:{path:{type:"string"}},required:["path"],additionalProperties:false}]}},required:["component","name"]}],unevaluatedProperties:false},Video:{type:"object",allOf:[{$ref:"common_types.json#/$defs/ComponentCommon"},{type:"object",properties:{component:{const:"Video"},url:{$ref:"common_types.json#/$defs/stringOrPath",description:"The URL of the video to display."}},required:["component","url"]}],unevaluatedProperties:false},AudioPlayer:{type:"object",allOf:[{$ref:"common_types.json#/$defs/ComponentCommon"},{type:"object",properties:{component:{const:"AudioPlayer"},url:{$ref:"common_types.json#/$defs/stringOrPath",description:"The URL of the audio to be played."},description:{description:"A description of the audio, such as a title or summary.",$ref:"common_types.json#/$defs/stringOrPath"}},required:["component","url"]}],unevaluatedProperties:false},Row:{type:"object",allOf:[{$ref:"common_types.json#/$defs/ComponentCommon"},{type:"object",description:"A layout component that arranges its children horizontally. To create a grid layout, nest Columns within this Row.",properties:{component:{const:"Row"},children:{description:"Defines the children. Use an array of strings for a fixed set of children, or a template object to generate children from a data list. Children cannot be defined inline, they must be referred to by ID.",$ref:"common_types.json#/$defs/childrenProperty"},distribution:{type:"string",description:"Defines the arrangement of children along the main axis (horizontally). Use 'spaceBetween' to push items to the edges, or 'start'/'end'/'center' to pack them together.",enum:["center","end","spaceAround","spaceBetween","spaceEvenly","start","stretch"]},alignment:{type:"string",description:"Defines the alignment of children along the cross axis (vertically). This is similar to the CSS 'align-items' property, but uses camelCase values (e.g., 'start').",enum:["start","center","end","stretch"]}},required:["component","children"]}],unevaluatedProperties:false},Column:{type:"object",allOf:[{$ref:"common_types.json#/$defs/ComponentCommon"},{type:"object",description:"A layout component that arranges its children vertically. To create a grid layout, nest Rows within this Column.",properties:{component:{const:"Column"},children:{description:"Defines the children. Use an array of strings for a fixed set of children, or a template object to generate children from a data list. Children cannot be defined inline, they must be referred to by ID.",$ref:"common_types.json#/$defs/childrenProperty"},distribution:{type:"string",description:"Defines the arrangement of children along the main axis (vertically). Use 'spaceBetween' to push items to the edges (e.g. header at top, footer at bottom), or 'start'/'end'/'center' to pack them together.",enum:["start","center","end","spaceBetween","spaceAround","spaceEvenly","stretch"]},alignment:{type:"string",description:"Defines the alignment of children along the cross axis (horizontally). This is similar to the CSS 'align-items' property.",enum:["center","end","start","stretch"]}},required:["component","children"]}],unevaluatedProperties:false},List:{type:"object",allOf:[{$ref:"common_types.json#/$defs/ComponentCommon"},{type:"object",properties:{component:{const:"List"},children:{description:"Defines the children. Use an array of strings for a fixed set of children, or a template object to generate children from a data list.",$ref:"common_types.json#/$defs/childrenProperty"},direction:{type:"string",description:"The direction in which the list items are laid out.",enum:["vertical","horizontal"]},alignment:{type:"string",description:"Defines the alignment of children along the cross axis.",enum:["start","center","end","stretch"]}},required:["component","children"]}],unevaluatedProperties:false},Card:{type:"object",allOf:[{$ref:"common_types.json#/$defs/ComponentCommon"},{type:"object",properties:{component:{const:"Card"},child:{type:"string",description:"The ID of the single child component to be rendered inside the card. To display multiple elements, you MUST wrap them in a layout component (like Column or Row) and pass that container's ID here. Do NOT pass multiple IDs or a non-existent ID. Do NOT define the child component inline."}},required:["component","child"]}],unevaluatedProperties:false},Tabs:{type:"object",allOf:[{$ref:"common_types.json#/$defs/ComponentCommon"},{type:"object",properties:{component:{const:"Tabs"},tabItems:{type:"array",description:"An array of objects, where each object defines a tab with a title and a child component.",items:{type:"object",properties:{title:{description:"The tab title.",$ref:"common_types.json#/$defs/stringOrPath"},child:{type:"string",description:"The ID of the child component. Do NOT define the component inline."}},required:["title","child"],additionalProperties:false}}},required:["component","tabItems"]}],unevaluatedProperties:false},Divider:{type:"object",allOf:[{$ref:"common_types.json#/$defs/ComponentCommon"},{type:"object",properties:{component:{const:"Divider"},axis:{type:"string",description:"The orientation of the divider.",enum:["horizontal","vertical"]}},required:["component"]}],unevaluatedProperties:false},Modal:{type:"object",allOf:[{$ref:"common_types.json#/$defs/ComponentCommon"},{type:"object",properties:{component:{const:"Modal"},entryPointChild:{type:"string",description:"The ID of the component that opens the modal when interacted with (e.g., a button). Do NOT define the component inline."},contentChild:{type:"string",description:"The ID of the component to be displayed inside the modal. Do NOT define the component inline."}},required:["component","entryPointChild","contentChild"]}],unevaluatedProperties:false},Button:{type:"object",allOf:[{$ref:"common_types.json#/$defs/ComponentCommon"},{type:"object",properties:{component:{const:"Button"},child:{type:"string",description:"The ID of the child component. Use a 'Text' component for a labeled button. Only use an 'Icon' if the requirements explicitly ask for an icon-only button. Do NOT define the child component inline."},primary:{type:"boolean",description:"Indicates if this button should be styled as the primary action."},action:{type:"object",description:"The client-side action to be dispatched when the button is clicked. It includes the action's name and an optional context payload.",properties:{name:{type:"string"},context:{type:"object",description:"A JSON object containing the key-value pairs for the action context. Values can be literals or paths. Use literal values unless the value must be dynamically bound to the data model. Do NOT use paths for static IDs.",additionalProperties:{$ref:"common_types.json#/$defs/contextValue"}}},required:["name"],additionalProperties:false}},required:["component","child","action"]}],unevaluatedProperties:false},CheckBox:{type:"object",allOf:[{$ref:"common_types.json#/$defs/ComponentCommon"},{type:"object",properties:{component:{const:"CheckBox"},label:{$ref:"common_types.json#/$defs/stringOrPath",description:"The text to display next to the checkbox."},value:{$ref:"common_types.json#/$defs/booleanOrPath",description:"The current state of the checkbox (true for checked, false for unchecked)."}},required:["component","label","value"]}],unevaluatedProperties:false},TextField:{type:"object",allOf:[{$ref:"common_types.json#/$defs/ComponentCommon"},{type:"object",properties:{component:{const:"TextField"},label:{$ref:"common_types.json#/$defs/stringOrPath",description:"The text label for the input field."},text:{$ref:"common_types.json#/$defs/stringOrPath",description:"The value of the text field."},usageHint:{type:"string",description:"The type of input field to display.",enum:["longText","number","shortText","obscured"]},validationRegexp:{type:"string",description:"A regular expression used for client-side validation of the input."}},required:["component","label"]}],unevaluatedProperties:false},DateTimeInput:{type:"object",allOf:[{$ref:"common_types.json#/$defs/ComponentCommon"},{type:"object",properties:{component:{const:"DateTimeInput"},value:{$ref:"common_types.json#/$defs/stringOrPath",description:"The selected date and/or time value in ISO 8601 format. If not yet set, initialize with an empty string."},enableDate:{type:"boolean",description:"If true, allows the user to select a date."},enableTime:{type:"boolean",description:"If true, allows the user to select a time."},outputFormat:{type:"string",description:"The desired format for the output string after a date or time is selected."},label:{$ref:"common_types.json#/$defs/stringOrPath",description:"The text label for the input field."}},required:["component","value"]}],unevaluatedProperties:false},ChoicePicker:{type:"object",allOf:[{$ref:"common_types.json#/$defs/ComponentCommon"},{type:"object",description:"A component that allows selecting one or more options from a list.",properties:{component:{const:"ChoicePicker"},label:{$ref:"common_types.json#/$defs/stringOrPath",description:"The label for the group of options."},usageHint:{type:"string",description:"A hint for how the choice picker should be displayed and behave.",enum:["multipleSelection","mutuallyExclusive"]},options:{type:"array",description:"The list of available options to choose from.",items:{type:"object",properties:{label:{description:"The text to display for this option.",$ref:"common_types.json#/$defs/stringOrPath"},value:{type:"string",description:"The stable value associated with this option."}},required:["label","value"],additionalProperties:false}},value:{$ref:"common_types.json#/$defs/stringArrayOrPath",description:"The list of currently selected values. This should be bound to a string array in the data model."}},required:["component","options","value","usageHint"]}],unevaluatedProperties:false},Slider:{type:"object",allOf:[{$ref:"common_types.json#/$defs/ComponentCommon"},{type:"object",properties:{component:{const:"Slider"},label:{$ref:"common_types.json#/$defs/stringOrPath",description:"The label for the slider."},min:{type:"number",description:"The minimum value of the slider."},max:{type:"number",description:"The maximum value of the slider."},value:{$ref:"common_types.json#/$defs/numberOrPath",description:"The current value of the slider."}},required:["component","value"]}],unevaluatedProperties:false}}};var y=class{constructor(){S(this,"ajv");S(this,"serverToClientValidator");S(this,"clientToServerValidator");this.ajv=new ke({allErrors:true,strict:false}),qe(this.ajv),this.ajv.addSchema(ge,"common_types.json"),this.ajv.addSchema(Ce,"standard_catalog_definition.json"),this.serverToClientValidator=this.ajv.compile(ye),this.clientToServerValidator=this.ajv.compile(he);}validateServerToClientMessage(t){return this.serverToClientValidator(t)?{valid:true,errors:[]}:{valid:false,errors:this.formatErrors(this.serverToClientValidator.errors||[])}}validateClientToServerMessage(t){return this.clientToServerValidator(t)?{valid:true,errors:[]}:{valid:false,errors:this.formatErrors(this.clientToServerValidator.errors||[])}}validateMessages(t){let n=[];for(let r=0;r<t.length;r++){let o=this.validateServerToClientMessage(t[r]);o.valid||n.push(...o.errors.map(a=>({...a,path:`/messages/${r}${a.path}`})));}return {valid:n.length===0,errors:n}}formatErrors(t){return t.map(n=>({path:n.instancePath||"/",message:n.message||"Validation failed",keyword:n.keyword,expected:n.params,actual:void 0}))}},V=null;function C(){return V||(V=new y),V}function Ie(e){return C().validateServerToClientMessage(e)}function xe(e){return C().validateClientToServerMessage(e)}function Se(e){return C().validateMessages(e)}function A(e){return typeof e=="object"&&e!==null&&"path"in e}function Fe(e){if(!A(e))return e}function Be(e){if(A(e))return e.path}function Le(e){return {path:e}}function Oe(e,t){let n={...e};for(let r of Object.keys(t)){let o=t[r],a=n[r];o!==void 0&&typeof o=="object"&&o!==null&&!Array.isArray(o)&&typeof a=="object"&&a!==null&&!Array.isArray(a)?n[r]=Oe(a,o):o!==void 0&&(n[r]=o);}return n}function He(){return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,e=>{let t=Math.random()*16|0;return (e==="x"?t:t&3|8).toString(16)})}var d={CHAT:"@chat",RECOMMENDATION:"@recommendation",INPUT_FORM:"@input-form",ORCHESTRATION:"@orchestration",STATUS:"@status",RESULT:"@result",CONFIRM:"@confirm",NOTIFICATION:"@notification"},w=0;function I(e="surface"){return w++,`${e}-${Date.now()}-${w}`}function Te(){w=0;}function u(e,t,n){let r=n??I();return t.find(i=>i.id===e)||console.warn(`[A2UI] Root component "${e}" not found in components list`),{messages:[m(r),f(r,t)],surfaceId:r}}function be(e,t,n,r){let o=r??I();return {messages:[m(o),f(o,t),g(o,n)],surfaceId:o}}function ve(e){return O(e)}function Me(e,t){return u(e,t,d.CHAT)}function Pe(e,t){return u(e,t,d.RECOMMENDATION)}function De(e,t){return u(e,t,d.INPUT_FORM)}function je(e,t){return u(e,t,d.ORCHESTRATION)}function $e(e,t){return u(e,t,d.STATUS)}
|
|
4
|
+
export{y as A2UISchemaValidator,U as A2UI_EXTENSION_URI,E as A2UI_MIME_TYPE,M as DEFAULT_PATH_MAPPINGS,h as STANDARD_CATALOG_ID,d as SURFACE_IDS,B as audioPlayer,pe as body,v as button,se as caption,W as card,X as checkbox,Z as choicePicker,H as column,u as createA2UISurface,be as createA2UISurfaceWithData,Me as createChatSurface,ve as createDeleteSurfaceMessage,De as createInputFormSurface,je as createOrchestrationSurface,Pe as createRecommendationSurface,$e as createStatusSurface,m as createSurface,ce as createV09Messages,Q as dateTimeInput,Oe as deepMerge,O as deleteSurface,J as divider,T as flattenObjectToValueMap,s as generateId,I as generateSurfaceId,N as getIdCounter,Fe as getLiteralValue,Be as getPathValue,C as getSchemaValidator,ne as h1,oe as h2,re as h3,ae as h4,ie as h5,q as icon,k as image,A as isPathBinding,_ as isV09Message,le as jsonlToMessages,G as list,de as messagesToJsonl,Y as modal,P as normalizePath,ue as objectToValueMap,Le as path,R as resetIdCounter,Te as resetSurfaceIdCounter,L as row,ee as slider,z as tabs,c as text,te as textButton,K as textField,f as updateComponents,g as updateDataModel,me as updatesToValueMap,He as uuid,xe as validateClientMessage,$ as validateMessage,fe as validateMessages,Se as validateMessagesWithSchema,j as validateV09Message,Ie as validateWithSchema,D as valueMapToObject,l as valueToValueMap,F as video};
|
|
@@ -36,40 +36,6 @@ type BooleanOrPath = boolean | {
|
|
|
36
36
|
type StringArrayOrPath = string[] | {
|
|
37
37
|
path: string;
|
|
38
38
|
};
|
|
39
|
-
/**
|
|
40
|
-
* v0.8 格式的字符串值(带有 literalString/path 区分)
|
|
41
|
-
*/
|
|
42
|
-
interface StringValue {
|
|
43
|
-
path?: string;
|
|
44
|
-
literalString?: string;
|
|
45
|
-
/** @deprecated 使用 literalString */
|
|
46
|
-
literal?: string;
|
|
47
|
-
}
|
|
48
|
-
/**
|
|
49
|
-
* v0.8 格式的数值(带有 literalNumber/path 区分)
|
|
50
|
-
*/
|
|
51
|
-
interface NumberValue {
|
|
52
|
-
path?: string;
|
|
53
|
-
literalNumber?: number;
|
|
54
|
-
/** @deprecated 使用 literalNumber */
|
|
55
|
-
literal?: number;
|
|
56
|
-
}
|
|
57
|
-
/**
|
|
58
|
-
* v0.8 格式的布尔值(带有 literalBoolean/path 区分)
|
|
59
|
-
*/
|
|
60
|
-
interface BooleanValue {
|
|
61
|
-
path?: string;
|
|
62
|
-
literalBoolean?: boolean;
|
|
63
|
-
/** @deprecated 使用 literalBoolean */
|
|
64
|
-
literal?: boolean;
|
|
65
|
-
}
|
|
66
|
-
/**
|
|
67
|
-
* v0.8 格式的字符串数组值
|
|
68
|
-
*/
|
|
69
|
-
interface StringArrayValue {
|
|
70
|
-
path?: string;
|
|
71
|
-
literalArray?: string[];
|
|
72
|
-
}
|
|
73
39
|
/**
|
|
74
40
|
* Context value - 用于 Action context 中的值
|
|
75
41
|
*/
|
|
@@ -77,4 +43,4 @@ type ContextValue = string | number | boolean | {
|
|
|
77
43
|
path: string;
|
|
78
44
|
};
|
|
79
45
|
|
|
80
|
-
export type { BooleanOrPath as B, ContextValue as C, NumberOrPath as N, StringOrPath as S, StringArrayOrPath as a
|
|
46
|
+
export type { BooleanOrPath as B, ContextValue as C, NumberOrPath as N, StringOrPath as S, StringArrayOrPath as a };
|
|
@@ -36,40 +36,6 @@ type BooleanOrPath = boolean | {
|
|
|
36
36
|
type StringArrayOrPath = string[] | {
|
|
37
37
|
path: string;
|
|
38
38
|
};
|
|
39
|
-
/**
|
|
40
|
-
* v0.8 格式的字符串值(带有 literalString/path 区分)
|
|
41
|
-
*/
|
|
42
|
-
interface StringValue {
|
|
43
|
-
path?: string;
|
|
44
|
-
literalString?: string;
|
|
45
|
-
/** @deprecated 使用 literalString */
|
|
46
|
-
literal?: string;
|
|
47
|
-
}
|
|
48
|
-
/**
|
|
49
|
-
* v0.8 格式的数值(带有 literalNumber/path 区分)
|
|
50
|
-
*/
|
|
51
|
-
interface NumberValue {
|
|
52
|
-
path?: string;
|
|
53
|
-
literalNumber?: number;
|
|
54
|
-
/** @deprecated 使用 literalNumber */
|
|
55
|
-
literal?: number;
|
|
56
|
-
}
|
|
57
|
-
/**
|
|
58
|
-
* v0.8 格式的布尔值(带有 literalBoolean/path 区分)
|
|
59
|
-
*/
|
|
60
|
-
interface BooleanValue {
|
|
61
|
-
path?: string;
|
|
62
|
-
literalBoolean?: boolean;
|
|
63
|
-
/** @deprecated 使用 literalBoolean */
|
|
64
|
-
literal?: boolean;
|
|
65
|
-
}
|
|
66
|
-
/**
|
|
67
|
-
* v0.8 格式的字符串数组值
|
|
68
|
-
*/
|
|
69
|
-
interface StringArrayValue {
|
|
70
|
-
path?: string;
|
|
71
|
-
literalArray?: string[];
|
|
72
|
-
}
|
|
73
39
|
/**
|
|
74
40
|
* Context value - 用于 Action context 中的值
|
|
75
41
|
*/
|
|
@@ -77,4 +43,4 @@ type ContextValue = string | number | boolean | {
|
|
|
77
43
|
path: string;
|
|
78
44
|
};
|
|
79
45
|
|
|
80
|
-
export type { BooleanOrPath as B, ContextValue as C, NumberOrPath as N, StringOrPath as S, StringArrayOrPath as a
|
|
46
|
+
export type { BooleanOrPath as B, ContextValue as C, NumberOrPath as N, StringOrPath as S, StringArrayOrPath as a };
|
package/dist/surface/index.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
'use strict';var
|
|
2
|
-
exports.SURFACE_IDS=
|
|
1
|
+
'use strict';var n={CHAT:"@chat",RECOMMENDATION:"@recommendation",INPUT_FORM:"@input-form",ORCHESTRATION:"@orchestration",STATUS:"@status",RESULT:"@result",CONFIRM:"@confirm",NOTIFICATION:"@notification"},c=0;function i(e="surface"){return c++,`${e}-${Date.now()}-${c}`}function C(){c=0;}var p="https://a2ui.dev/specification/0.9/standard_catalog_definition.json";function u(e,t=p){return {createSurface:{surfaceId:e,catalogId:t}}}function g(e,t){return {updateComponents:{surfaceId:e,components:t}}}function f(e,t,a,r="replace"){return {updateDataModel:{surfaceId:e,...a,op:r,...r!=="remove"&&{value:t}}}}function d(e){return {deleteSurface:{surfaceId:e}}}function o(e,t,a){let r=a??i();return t.find(l=>l.id===e)||console.warn(`[A2UI] Root component "${e}" not found in components list`),{messages:[u(r),g(r,t)],surfaceId:r}}function S(e,t,a,r){let s=r??i();return {messages:[u(s),g(s,t),f(s,a)],surfaceId:s}}function M(e){return d(e)}function I(e,t){return o(e,t,n.CHAT)}function T(e,t){return o(e,t,n.RECOMMENDATION)}function x(e,t){return o(e,t,n.INPUT_FORM)}function D(e,t){return o(e,t,n.ORCHESTRATION)}function A(e,t){return o(e,t,n.STATUS)}
|
|
2
|
+
exports.SURFACE_IDS=n;exports.createA2UISurface=o;exports.createA2UISurfaceWithData=S;exports.createChatSurface=I;exports.createDeleteSurfaceMessage=M;exports.createInputFormSurface=x;exports.createOrchestrationSurface=D;exports.createRecommendationSurface=T;exports.createStatusSurface=A;exports.generateSurfaceId=i;exports.resetSurfaceIdCounter=C;
|
package/dist/surface/index.d.cts
CHANGED
package/dist/surface/index.d.ts
CHANGED
package/dist/surface/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var
|
|
2
|
-
export{
|
|
1
|
+
var n={CHAT:"@chat",RECOMMENDATION:"@recommendation",INPUT_FORM:"@input-form",ORCHESTRATION:"@orchestration",STATUS:"@status",RESULT:"@result",CONFIRM:"@confirm",NOTIFICATION:"@notification"},c=0;function i(e="surface"){return c++,`${e}-${Date.now()}-${c}`}function C(){c=0;}var p="https://a2ui.dev/specification/0.9/standard_catalog_definition.json";function u(e,t=p){return {createSurface:{surfaceId:e,catalogId:t}}}function g(e,t){return {updateComponents:{surfaceId:e,components:t}}}function f(e,t,a,r="replace"){return {updateDataModel:{surfaceId:e,...a,op:r,...r!=="remove"&&{value:t}}}}function d(e){return {deleteSurface:{surfaceId:e}}}function o(e,t,a){let r=a??i();return t.find(l=>l.id===e)||console.warn(`[A2UI] Root component "${e}" not found in components list`),{messages:[u(r),g(r,t)],surfaceId:r}}function S(e,t,a,r){let s=r??i();return {messages:[u(s),g(s,t),f(s,a)],surfaceId:s}}function M(e){return d(e)}function I(e,t){return o(e,t,n.CHAT)}function T(e,t){return o(e,t,n.RECOMMENDATION)}function x(e,t){return o(e,t,n.INPUT_FORM)}function D(e,t){return o(e,t,n.ORCHESTRATION)}function A(e,t){return o(e,t,n.STATUS)}
|
|
2
|
+
export{n as SURFACE_IDS,o as createA2UISurface,S as createA2UISurfaceWithData,I as createChatSurface,M as createDeleteSurfaceMessage,x as createInputFormSurface,D as createOrchestrationSurface,T as createRecommendationSurface,A as createStatusSurface,i as generateSurfaceId,C as resetSurfaceIdCounter};
|
package/dist/types/index.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
'use strict';function t(e){return "createSurface"in e||"updateComponents"in e||"updateDataModel"in e}
|
|
2
|
-
exports.A2UI_EXTENSION_URI=r;exports.
|
|
1
|
+
'use strict';function t(e){return "createSurface"in e||"updateComponents"in e||"updateDataModel"in e}var n="https://a2ui.dev/specification/0.9/standard_catalog_definition.json";var r="https://a2ui.dev/specification/0.9",a="application/json+a2ui";
|
|
2
|
+
exports.A2UI_EXTENSION_URI=r;exports.A2UI_MIME_TYPE=a;exports.STANDARD_CATALOG_ID=n;exports.isV09Message=t;
|
package/dist/types/index.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { S as StringOrPath, N as NumberOrPath, B as BooleanOrPath, a as StringArrayOrPath } from '../primitives-
|
|
2
|
-
export {
|
|
1
|
+
import { S as StringOrPath, N as NumberOrPath, B as BooleanOrPath, a as StringArrayOrPath } from '../primitives-DLbBDhLq.cjs';
|
|
2
|
+
export { C as ContextValue } from '../primitives-DLbBDhLq.cjs';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* A2UI Component Types
|
|
@@ -24,25 +24,6 @@ interface Action {
|
|
|
24
24
|
*/
|
|
25
25
|
context?: Record<string, StringOrPath | NumberOrPath | BooleanOrPath>;
|
|
26
26
|
}
|
|
27
|
-
/**
|
|
28
|
-
* v0.8 格式的 Action 上下文项
|
|
29
|
-
*/
|
|
30
|
-
interface ActionContextItem {
|
|
31
|
-
key: string;
|
|
32
|
-
value: {
|
|
33
|
-
path?: string;
|
|
34
|
-
literalString?: string;
|
|
35
|
-
literalNumber?: number;
|
|
36
|
-
literalBoolean?: boolean;
|
|
37
|
-
};
|
|
38
|
-
}
|
|
39
|
-
/**
|
|
40
|
-
* v0.8 格式的 Action
|
|
41
|
-
*/
|
|
42
|
-
interface ActionV08 {
|
|
43
|
-
name: string;
|
|
44
|
-
context?: ActionContextItem[];
|
|
45
|
-
}
|
|
46
27
|
/**
|
|
47
28
|
* 组件公共属性
|
|
48
29
|
*/
|
|
@@ -547,18 +528,19 @@ type ServerToClientMessage = ServerToClientMessageV08 | ServerToClientMessageV09
|
|
|
547
528
|
* 判断是否为 v0.9 消息
|
|
548
529
|
*/
|
|
549
530
|
declare function isV09Message(message: ServerToClientMessage): message is ServerToClientMessageV09;
|
|
550
|
-
/**
|
|
551
|
-
* 判断是否为 v0.8 消息
|
|
552
|
-
*/
|
|
553
|
-
declare function isV08Message(message: ServerToClientMessage): message is ServerToClientMessageV08;
|
|
554
531
|
/**
|
|
555
532
|
* 用户操作事件
|
|
533
|
+
* @see https://a2ui.dev/specification/0.9/client_to_server.json
|
|
556
534
|
*/
|
|
557
535
|
interface UserActionEvent {
|
|
558
536
|
/**
|
|
559
|
-
*
|
|
537
|
+
* 操作名称(来自组件的 action.name)
|
|
560
538
|
*/
|
|
561
|
-
|
|
539
|
+
name: string;
|
|
540
|
+
/**
|
|
541
|
+
* 触发操作的 Surface ID
|
|
542
|
+
*/
|
|
543
|
+
surfaceId: string;
|
|
562
544
|
/**
|
|
563
545
|
* 触发组件的 ID
|
|
564
546
|
*/
|
|
@@ -568,9 +550,9 @@ interface UserActionEvent {
|
|
|
568
550
|
*/
|
|
569
551
|
timestamp: string;
|
|
570
552
|
/**
|
|
571
|
-
*
|
|
553
|
+
* 操作上下文(解析数据绑定后的键值对)
|
|
572
554
|
*/
|
|
573
|
-
context
|
|
555
|
+
context: Record<string, unknown>;
|
|
574
556
|
}
|
|
575
557
|
/**
|
|
576
558
|
* 数据变更事件
|
|
@@ -593,6 +575,54 @@ interface DataChangeEvent {
|
|
|
593
575
|
*/
|
|
594
576
|
sourceComponentId: string;
|
|
595
577
|
}
|
|
578
|
+
/**
|
|
579
|
+
* 验证失败错误
|
|
580
|
+
* @see https://a2ui.dev/specification/0.9/client_to_server.json
|
|
581
|
+
*/
|
|
582
|
+
interface ValidationFailedError {
|
|
583
|
+
/**
|
|
584
|
+
* 错误代码
|
|
585
|
+
*/
|
|
586
|
+
code: 'VALIDATION_FAILED';
|
|
587
|
+
/**
|
|
588
|
+
* 发生错误的 Surface ID
|
|
589
|
+
*/
|
|
590
|
+
surfaceId: string;
|
|
591
|
+
/**
|
|
592
|
+
* 验证失败的字段路径(JSON Pointer 格式)
|
|
593
|
+
* @example "/components/0/text"
|
|
594
|
+
*/
|
|
595
|
+
path: string;
|
|
596
|
+
/**
|
|
597
|
+
* 错误描述
|
|
598
|
+
*/
|
|
599
|
+
message: string;
|
|
600
|
+
}
|
|
601
|
+
/**
|
|
602
|
+
* 通用错误
|
|
603
|
+
*/
|
|
604
|
+
interface GenericError {
|
|
605
|
+
/**
|
|
606
|
+
* 错误代码(非 VALIDATION_FAILED)
|
|
607
|
+
*/
|
|
608
|
+
code: string;
|
|
609
|
+
/**
|
|
610
|
+
* 发生错误的 Surface ID
|
|
611
|
+
*/
|
|
612
|
+
surfaceId: string;
|
|
613
|
+
/**
|
|
614
|
+
* 错误描述
|
|
615
|
+
*/
|
|
616
|
+
message: string;
|
|
617
|
+
/**
|
|
618
|
+
* 其他附加信息
|
|
619
|
+
*/
|
|
620
|
+
[key: string]: unknown;
|
|
621
|
+
}
|
|
622
|
+
/**
|
|
623
|
+
* 客户端错误消息
|
|
624
|
+
*/
|
|
625
|
+
type ClientErrorMessage = ValidationFailedError | GenericError;
|
|
596
626
|
/**
|
|
597
627
|
* 客户端到服务器消息
|
|
598
628
|
*/
|
|
@@ -600,6 +630,8 @@ type ClientToServerMessage = {
|
|
|
600
630
|
userAction: UserActionEvent;
|
|
601
631
|
} | {
|
|
602
632
|
dataChange: DataChangeEvent;
|
|
633
|
+
} | {
|
|
634
|
+
error: ClientErrorMessage;
|
|
603
635
|
};
|
|
604
636
|
/**
|
|
605
637
|
* 数据模型值类型
|
|
@@ -619,10 +651,6 @@ type DataArray = DataValue[];
|
|
|
619
651
|
* A2UI 标准 Catalog ID
|
|
620
652
|
*/
|
|
621
653
|
declare const STANDARD_CATALOG_ID = "https://a2ui.dev/specification/0.9/standard_catalog_definition.json";
|
|
622
|
-
/**
|
|
623
|
-
* A2UI 扩展 URI (v0.8)
|
|
624
|
-
*/
|
|
625
|
-
declare const A2UI_EXTENSION_URI_V08 = "https://a2ui.org/a2a-extension/a2ui/v0.8";
|
|
626
654
|
/**
|
|
627
655
|
* A2UI 扩展 URI (v0.9)
|
|
628
656
|
*/
|
|
@@ -632,4 +660,4 @@ declare const A2UI_EXTENSION_URI = "https://a2ui.dev/specification/0.9";
|
|
|
632
660
|
*/
|
|
633
661
|
declare const A2UI_MIME_TYPE = "application/json+a2ui";
|
|
634
662
|
|
|
635
|
-
export { A2UI_EXTENSION_URI,
|
|
663
|
+
export { A2UI_EXTENSION_URI, A2UI_MIME_TYPE, type Action, type AnyComponent, type AudioPlayerComponent, BooleanOrPath, type ButtonComponent, type CardComponent, type CheckBoxComponent, type ChildrenProperty, type ChoicePickerComponent, type ClientErrorMessage, type ClientToServerMessage, type ColumnComponent, type ComponentCommon, type ComponentInstance, type ComponentType, type CreateSurfaceMessage, type DataArray, type DataChangeEvent, type DataObject, type DataValue, type DateTimeInputComponent, type DeleteSurfaceMessage, type DividerComponent, type GenericError, type IconComponent, type ImageComponent, type ListComponent, type ModalComponent, NumberOrPath, type RowComponent, STANDARD_CATALOG_ID, type ServerToClientMessageV09, type SliderComponent, type StandardIconName, StringArrayOrPath, StringOrPath, type TabsComponent, type TextComponent, type TextFieldComponent, type Theme, type UpdateComponentsMessage, type UpdateDataModelMessage, type UserActionEvent, type ValidationFailedError, type VideoComponent, isV09Message };
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { S as StringOrPath, N as NumberOrPath, B as BooleanOrPath, a as StringArrayOrPath } from '../primitives-
|
|
2
|
-
export {
|
|
1
|
+
import { S as StringOrPath, N as NumberOrPath, B as BooleanOrPath, a as StringArrayOrPath } from '../primitives-DLbBDhLq.js';
|
|
2
|
+
export { C as ContextValue } from '../primitives-DLbBDhLq.js';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* A2UI Component Types
|
|
@@ -24,25 +24,6 @@ interface Action {
|
|
|
24
24
|
*/
|
|
25
25
|
context?: Record<string, StringOrPath | NumberOrPath | BooleanOrPath>;
|
|
26
26
|
}
|
|
27
|
-
/**
|
|
28
|
-
* v0.8 格式的 Action 上下文项
|
|
29
|
-
*/
|
|
30
|
-
interface ActionContextItem {
|
|
31
|
-
key: string;
|
|
32
|
-
value: {
|
|
33
|
-
path?: string;
|
|
34
|
-
literalString?: string;
|
|
35
|
-
literalNumber?: number;
|
|
36
|
-
literalBoolean?: boolean;
|
|
37
|
-
};
|
|
38
|
-
}
|
|
39
|
-
/**
|
|
40
|
-
* v0.8 格式的 Action
|
|
41
|
-
*/
|
|
42
|
-
interface ActionV08 {
|
|
43
|
-
name: string;
|
|
44
|
-
context?: ActionContextItem[];
|
|
45
|
-
}
|
|
46
27
|
/**
|
|
47
28
|
* 组件公共属性
|
|
48
29
|
*/
|
|
@@ -547,18 +528,19 @@ type ServerToClientMessage = ServerToClientMessageV08 | ServerToClientMessageV09
|
|
|
547
528
|
* 判断是否为 v0.9 消息
|
|
548
529
|
*/
|
|
549
530
|
declare function isV09Message(message: ServerToClientMessage): message is ServerToClientMessageV09;
|
|
550
|
-
/**
|
|
551
|
-
* 判断是否为 v0.8 消息
|
|
552
|
-
*/
|
|
553
|
-
declare function isV08Message(message: ServerToClientMessage): message is ServerToClientMessageV08;
|
|
554
531
|
/**
|
|
555
532
|
* 用户操作事件
|
|
533
|
+
* @see https://a2ui.dev/specification/0.9/client_to_server.json
|
|
556
534
|
*/
|
|
557
535
|
interface UserActionEvent {
|
|
558
536
|
/**
|
|
559
|
-
*
|
|
537
|
+
* 操作名称(来自组件的 action.name)
|
|
560
538
|
*/
|
|
561
|
-
|
|
539
|
+
name: string;
|
|
540
|
+
/**
|
|
541
|
+
* 触发操作的 Surface ID
|
|
542
|
+
*/
|
|
543
|
+
surfaceId: string;
|
|
562
544
|
/**
|
|
563
545
|
* 触发组件的 ID
|
|
564
546
|
*/
|
|
@@ -568,9 +550,9 @@ interface UserActionEvent {
|
|
|
568
550
|
*/
|
|
569
551
|
timestamp: string;
|
|
570
552
|
/**
|
|
571
|
-
*
|
|
553
|
+
* 操作上下文(解析数据绑定后的键值对)
|
|
572
554
|
*/
|
|
573
|
-
context
|
|
555
|
+
context: Record<string, unknown>;
|
|
574
556
|
}
|
|
575
557
|
/**
|
|
576
558
|
* 数据变更事件
|
|
@@ -593,6 +575,54 @@ interface DataChangeEvent {
|
|
|
593
575
|
*/
|
|
594
576
|
sourceComponentId: string;
|
|
595
577
|
}
|
|
578
|
+
/**
|
|
579
|
+
* 验证失败错误
|
|
580
|
+
* @see https://a2ui.dev/specification/0.9/client_to_server.json
|
|
581
|
+
*/
|
|
582
|
+
interface ValidationFailedError {
|
|
583
|
+
/**
|
|
584
|
+
* 错误代码
|
|
585
|
+
*/
|
|
586
|
+
code: 'VALIDATION_FAILED';
|
|
587
|
+
/**
|
|
588
|
+
* 发生错误的 Surface ID
|
|
589
|
+
*/
|
|
590
|
+
surfaceId: string;
|
|
591
|
+
/**
|
|
592
|
+
* 验证失败的字段路径(JSON Pointer 格式)
|
|
593
|
+
* @example "/components/0/text"
|
|
594
|
+
*/
|
|
595
|
+
path: string;
|
|
596
|
+
/**
|
|
597
|
+
* 错误描述
|
|
598
|
+
*/
|
|
599
|
+
message: string;
|
|
600
|
+
}
|
|
601
|
+
/**
|
|
602
|
+
* 通用错误
|
|
603
|
+
*/
|
|
604
|
+
interface GenericError {
|
|
605
|
+
/**
|
|
606
|
+
* 错误代码(非 VALIDATION_FAILED)
|
|
607
|
+
*/
|
|
608
|
+
code: string;
|
|
609
|
+
/**
|
|
610
|
+
* 发生错误的 Surface ID
|
|
611
|
+
*/
|
|
612
|
+
surfaceId: string;
|
|
613
|
+
/**
|
|
614
|
+
* 错误描述
|
|
615
|
+
*/
|
|
616
|
+
message: string;
|
|
617
|
+
/**
|
|
618
|
+
* 其他附加信息
|
|
619
|
+
*/
|
|
620
|
+
[key: string]: unknown;
|
|
621
|
+
}
|
|
622
|
+
/**
|
|
623
|
+
* 客户端错误消息
|
|
624
|
+
*/
|
|
625
|
+
type ClientErrorMessage = ValidationFailedError | GenericError;
|
|
596
626
|
/**
|
|
597
627
|
* 客户端到服务器消息
|
|
598
628
|
*/
|
|
@@ -600,6 +630,8 @@ type ClientToServerMessage = {
|
|
|
600
630
|
userAction: UserActionEvent;
|
|
601
631
|
} | {
|
|
602
632
|
dataChange: DataChangeEvent;
|
|
633
|
+
} | {
|
|
634
|
+
error: ClientErrorMessage;
|
|
603
635
|
};
|
|
604
636
|
/**
|
|
605
637
|
* 数据模型值类型
|
|
@@ -619,10 +651,6 @@ type DataArray = DataValue[];
|
|
|
619
651
|
* A2UI 标准 Catalog ID
|
|
620
652
|
*/
|
|
621
653
|
declare const STANDARD_CATALOG_ID = "https://a2ui.dev/specification/0.9/standard_catalog_definition.json";
|
|
622
|
-
/**
|
|
623
|
-
* A2UI 扩展 URI (v0.8)
|
|
624
|
-
*/
|
|
625
|
-
declare const A2UI_EXTENSION_URI_V08 = "https://a2ui.org/a2a-extension/a2ui/v0.8";
|
|
626
654
|
/**
|
|
627
655
|
* A2UI 扩展 URI (v0.9)
|
|
628
656
|
*/
|
|
@@ -632,4 +660,4 @@ declare const A2UI_EXTENSION_URI = "https://a2ui.dev/specification/0.9";
|
|
|
632
660
|
*/
|
|
633
661
|
declare const A2UI_MIME_TYPE = "application/json+a2ui";
|
|
634
662
|
|
|
635
|
-
export { A2UI_EXTENSION_URI,
|
|
663
|
+
export { A2UI_EXTENSION_URI, A2UI_MIME_TYPE, type Action, type AnyComponent, type AudioPlayerComponent, BooleanOrPath, type ButtonComponent, type CardComponent, type CheckBoxComponent, type ChildrenProperty, type ChoicePickerComponent, type ClientErrorMessage, type ClientToServerMessage, type ColumnComponent, type ComponentCommon, type ComponentInstance, type ComponentType, type CreateSurfaceMessage, type DataArray, type DataChangeEvent, type DataObject, type DataValue, type DateTimeInputComponent, type DeleteSurfaceMessage, type DividerComponent, type GenericError, type IconComponent, type ImageComponent, type ListComponent, type ModalComponent, NumberOrPath, type RowComponent, STANDARD_CATALOG_ID, type ServerToClientMessageV09, type SliderComponent, type StandardIconName, StringArrayOrPath, StringOrPath, type TabsComponent, type TextComponent, type TextFieldComponent, type Theme, type UpdateComponentsMessage, type UpdateDataModelMessage, type UserActionEvent, type ValidationFailedError, type VideoComponent, isV09Message };
|
package/dist/types/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
function t(e){return "createSurface"in e||"updateComponents"in e||"updateDataModel"in e}
|
|
2
|
-
export{r as A2UI_EXTENSION_URI,
|
|
1
|
+
function t(e){return "createSurface"in e||"updateComponents"in e||"updateDataModel"in e}var n="https://a2ui.dev/specification/0.9/standard_catalog_definition.json";var r="https://a2ui.dev/specification/0.9",a="application/json+a2ui";
|
|
2
|
+
export{r as A2UI_EXTENSION_URI,a as A2UI_MIME_TYPE,n as STANDARD_CATALOG_ID,t as isV09Message};
|