@zhama/a2ui-core 0.6.0 → 0.9.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.
@@ -1,5 +1,5 @@
1
- import { ServerToClientMessageV09, ComponentInstance, DataObject } from '../types/index.cjs';
2
- import '../primitives-DLbBDhLq.cjs';
1
+ import { ServerToClientMessage, Theme, ComponentInstance, DataObject } from '../types/index.cjs';
2
+ import '../primitives-DRaAeo-1.cjs';
3
3
 
4
4
  /**
5
5
  * Surface IDs and Configuration
@@ -91,16 +91,27 @@ declare function resetSurfaceIdCounter(): void;
91
91
  */
92
92
  interface SurfaceResult {
93
93
  /** 构建的消息数组 */
94
- messages: ServerToClientMessageV09[];
94
+ messages: ServerToClientMessage[];
95
95
  /** Surface ID */
96
96
  surfaceId: string;
97
97
  }
98
+ /**
99
+ * Surface 选项
100
+ */
101
+ interface SurfaceOptions {
102
+ /** Surface ID(可选,自动生成) */
103
+ surfaceId?: string;
104
+ /** 主题配置 */
105
+ theme?: Theme;
106
+ /** 是否发送数据模型 */
107
+ sendDataModel?: boolean;
108
+ }
98
109
  /**
99
110
  * 创建 A2UI Surface 消息
100
111
  *
101
112
  * @param rootId - 根组件 ID
102
113
  * @param components - 组件列表(v0.9 格式)
103
- * @param surfaceId - Surface ID(可选,自动生成)
114
+ * @param options - 可选配置
104
115
  * @returns Surface 构建结果
105
116
  *
106
117
  * @example
@@ -110,17 +121,19 @@ interface SurfaceResult {
110
121
  * const title = h1('Hello', { id: 'title' });
111
122
  * const root = column(['title'], { id: 'root' });
112
123
  *
113
- * const { messages, surfaceId } = createA2UISurface('root', [title, root], SURFACE_IDS.CHAT);
124
+ * const { messages, surfaceId } = createA2UISurface('root', [title, root], {
125
+ * surfaceId: SURFACE_IDS.CHAT
126
+ * });
114
127
  * ```
115
128
  */
116
- declare function createA2UISurface(rootId: string, components: ComponentInstance[], surfaceId?: string): SurfaceResult;
129
+ declare function createA2UISurface(rootId: string, components: ComponentInstance[], options?: SurfaceOptions): SurfaceResult;
117
130
  /**
118
131
  * 创建带数据模型的 A2UI Surface
119
132
  *
120
133
  * @param rootId - 根组件 ID
121
134
  * @param components - 组件列表(v0.9 格式)
122
135
  * @param dataModel - 数据模型对象
123
- * @param surfaceId - Surface ID(可选)
136
+ * @param options - 可选配置
124
137
  * @returns Surface 构建结果
125
138
  *
126
139
  * @example
@@ -129,37 +142,37 @@ declare function createA2UISurface(rootId: string, components: ComponentInstance
129
142
  * 'root',
130
143
  * [title, greeting, root],
131
144
  * { user: { name: 'John' } },
132
- * SURFACE_IDS.CHAT
145
+ * { surfaceId: SURFACE_IDS.CHAT }
133
146
  * );
134
147
  * ```
135
148
  */
136
- declare function createA2UISurfaceWithData(rootId: string, components: ComponentInstance[], dataModel: DataObject, surfaceId?: string): SurfaceResult;
149
+ declare function createA2UISurfaceWithData(rootId: string, components: ComponentInstance[], dataModel: DataObject, options?: SurfaceOptions): SurfaceResult;
137
150
  /**
138
151
  * 创建删除 Surface 的消息
139
152
  *
140
153
  * @param surfaceId - 要删除的 Surface ID
141
154
  * @returns 删除消息
142
155
  */
143
- declare function createDeleteSurfaceMessage(surfaceId: string): ServerToClientMessageV09;
156
+ declare function createDeleteSurfaceMessage(surfaceId: string): ServerToClientMessage;
144
157
  /**
145
158
  * 创建聊天区 Surface
146
159
  */
147
- declare function createChatSurface(rootId: string, components: ComponentInstance[]): SurfaceResult;
160
+ declare function createChatSurface(rootId: string, components: ComponentInstance[], options?: Omit<SurfaceOptions, 'surfaceId'>): SurfaceResult;
148
161
  /**
149
162
  * 创建智能体推荐区 Surface
150
163
  */
151
- declare function createRecommendationSurface(rootId: string, components: ComponentInstance[]): SurfaceResult;
164
+ declare function createRecommendationSurface(rootId: string, components: ComponentInstance[], options?: Omit<SurfaceOptions, 'surfaceId'>): SurfaceResult;
152
165
  /**
153
166
  * 创建输入表单区 Surface
154
167
  */
155
- declare function createInputFormSurface(rootId: string, components: ComponentInstance[]): SurfaceResult;
168
+ declare function createInputFormSurface(rootId: string, components: ComponentInstance[], options?: Omit<SurfaceOptions, 'surfaceId'>): SurfaceResult;
156
169
  /**
157
170
  * 创建编排面板 Surface
158
171
  */
159
- declare function createOrchestrationSurface(rootId: string, components: ComponentInstance[]): SurfaceResult;
172
+ declare function createOrchestrationSurface(rootId: string, components: ComponentInstance[], options?: Omit<SurfaceOptions, 'surfaceId'>): SurfaceResult;
160
173
  /**
161
174
  * 创建状态提示 Surface
162
175
  */
163
- declare function createStatusSurface(rootId: string, components: ComponentInstance[]): SurfaceResult;
176
+ declare function createStatusSurface(rootId: string, components: ComponentInstance[], options?: Omit<SurfaceOptions, 'surfaceId'>): SurfaceResult;
164
177
 
165
- export { SURFACE_IDS, type SurfaceConfig, type SurfaceIdType, type SurfaceResult, createA2UISurface, createA2UISurfaceWithData, createChatSurface, createDeleteSurfaceMessage, createInputFormSurface, createOrchestrationSurface, createRecommendationSurface, createStatusSurface, generateSurfaceId, resetSurfaceIdCounter };
178
+ export { SURFACE_IDS, type SurfaceConfig, type SurfaceIdType, type SurfaceOptions, type SurfaceResult, createA2UISurface, createA2UISurfaceWithData, createChatSurface, createDeleteSurfaceMessage, createInputFormSurface, createOrchestrationSurface, createRecommendationSurface, createStatusSurface, generateSurfaceId, resetSurfaceIdCounter };
@@ -1,5 +1,5 @@
1
- import { ServerToClientMessageV09, ComponentInstance, DataObject } from '../types/index.js';
2
- import '../primitives-DLbBDhLq.js';
1
+ import { ServerToClientMessage, Theme, ComponentInstance, DataObject } from '../types/index.js';
2
+ import '../primitives-DRaAeo-1.js';
3
3
 
4
4
  /**
5
5
  * Surface IDs and Configuration
@@ -91,16 +91,27 @@ declare function resetSurfaceIdCounter(): void;
91
91
  */
92
92
  interface SurfaceResult {
93
93
  /** 构建的消息数组 */
94
- messages: ServerToClientMessageV09[];
94
+ messages: ServerToClientMessage[];
95
95
  /** Surface ID */
96
96
  surfaceId: string;
97
97
  }
98
+ /**
99
+ * Surface 选项
100
+ */
101
+ interface SurfaceOptions {
102
+ /** Surface ID(可选,自动生成) */
103
+ surfaceId?: string;
104
+ /** 主题配置 */
105
+ theme?: Theme;
106
+ /** 是否发送数据模型 */
107
+ sendDataModel?: boolean;
108
+ }
98
109
  /**
99
110
  * 创建 A2UI Surface 消息
100
111
  *
101
112
  * @param rootId - 根组件 ID
102
113
  * @param components - 组件列表(v0.9 格式)
103
- * @param surfaceId - Surface ID(可选,自动生成)
114
+ * @param options - 可选配置
104
115
  * @returns Surface 构建结果
105
116
  *
106
117
  * @example
@@ -110,17 +121,19 @@ interface SurfaceResult {
110
121
  * const title = h1('Hello', { id: 'title' });
111
122
  * const root = column(['title'], { id: 'root' });
112
123
  *
113
- * const { messages, surfaceId } = createA2UISurface('root', [title, root], SURFACE_IDS.CHAT);
124
+ * const { messages, surfaceId } = createA2UISurface('root', [title, root], {
125
+ * surfaceId: SURFACE_IDS.CHAT
126
+ * });
114
127
  * ```
115
128
  */
116
- declare function createA2UISurface(rootId: string, components: ComponentInstance[], surfaceId?: string): SurfaceResult;
129
+ declare function createA2UISurface(rootId: string, components: ComponentInstance[], options?: SurfaceOptions): SurfaceResult;
117
130
  /**
118
131
  * 创建带数据模型的 A2UI Surface
119
132
  *
120
133
  * @param rootId - 根组件 ID
121
134
  * @param components - 组件列表(v0.9 格式)
122
135
  * @param dataModel - 数据模型对象
123
- * @param surfaceId - Surface ID(可选)
136
+ * @param options - 可选配置
124
137
  * @returns Surface 构建结果
125
138
  *
126
139
  * @example
@@ -129,37 +142,37 @@ declare function createA2UISurface(rootId: string, components: ComponentInstance
129
142
  * 'root',
130
143
  * [title, greeting, root],
131
144
  * { user: { name: 'John' } },
132
- * SURFACE_IDS.CHAT
145
+ * { surfaceId: SURFACE_IDS.CHAT }
133
146
  * );
134
147
  * ```
135
148
  */
136
- declare function createA2UISurfaceWithData(rootId: string, components: ComponentInstance[], dataModel: DataObject, surfaceId?: string): SurfaceResult;
149
+ declare function createA2UISurfaceWithData(rootId: string, components: ComponentInstance[], dataModel: DataObject, options?: SurfaceOptions): SurfaceResult;
137
150
  /**
138
151
  * 创建删除 Surface 的消息
139
152
  *
140
153
  * @param surfaceId - 要删除的 Surface ID
141
154
  * @returns 删除消息
142
155
  */
143
- declare function createDeleteSurfaceMessage(surfaceId: string): ServerToClientMessageV09;
156
+ declare function createDeleteSurfaceMessage(surfaceId: string): ServerToClientMessage;
144
157
  /**
145
158
  * 创建聊天区 Surface
146
159
  */
147
- declare function createChatSurface(rootId: string, components: ComponentInstance[]): SurfaceResult;
160
+ declare function createChatSurface(rootId: string, components: ComponentInstance[], options?: Omit<SurfaceOptions, 'surfaceId'>): SurfaceResult;
148
161
  /**
149
162
  * 创建智能体推荐区 Surface
150
163
  */
151
- declare function createRecommendationSurface(rootId: string, components: ComponentInstance[]): SurfaceResult;
164
+ declare function createRecommendationSurface(rootId: string, components: ComponentInstance[], options?: Omit<SurfaceOptions, 'surfaceId'>): SurfaceResult;
152
165
  /**
153
166
  * 创建输入表单区 Surface
154
167
  */
155
- declare function createInputFormSurface(rootId: string, components: ComponentInstance[]): SurfaceResult;
168
+ declare function createInputFormSurface(rootId: string, components: ComponentInstance[], options?: Omit<SurfaceOptions, 'surfaceId'>): SurfaceResult;
156
169
  /**
157
170
  * 创建编排面板 Surface
158
171
  */
159
- declare function createOrchestrationSurface(rootId: string, components: ComponentInstance[]): SurfaceResult;
172
+ declare function createOrchestrationSurface(rootId: string, components: ComponentInstance[], options?: Omit<SurfaceOptions, 'surfaceId'>): SurfaceResult;
160
173
  /**
161
174
  * 创建状态提示 Surface
162
175
  */
163
- declare function createStatusSurface(rootId: string, components: ComponentInstance[]): SurfaceResult;
176
+ declare function createStatusSurface(rootId: string, components: ComponentInstance[], options?: Omit<SurfaceOptions, 'surfaceId'>): SurfaceResult;
164
177
 
165
- export { SURFACE_IDS, type SurfaceConfig, type SurfaceIdType, type SurfaceResult, createA2UISurface, createA2UISurfaceWithData, createChatSurface, createDeleteSurfaceMessage, createInputFormSurface, createOrchestrationSurface, createRecommendationSurface, createStatusSurface, generateSurfaceId, resetSurfaceIdCounter };
178
+ export { SURFACE_IDS, type SurfaceConfig, type SurfaceIdType, type SurfaceOptions, type SurfaceResult, createA2UISurface, createA2UISurfaceWithData, createChatSurface, createDeleteSurfaceMessage, createInputFormSurface, createOrchestrationSurface, createRecommendationSurface, createStatusSurface, generateSurfaceId, resetSurfaceIdCounter };
@@ -1,2 +1,2 @@
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};
1
+ var r={CHAT:"@chat",RECOMMENDATION:"@recommendation",INPUT_FORM:"@input-form",ORCHESTRATION:"@orchestration",STATUS:"@status",RESULT:"@result",CONFIRM:"@confirm",NOTIFICATION:"@notification"},f=0;function u(e="surface"){return f++,`${e}-${Date.now()}-${f}`}function I(){f=0;}var g="https://a2ui.dev/specification/v0_9/standard_catalog.json";function m(e,t={}){let{catalogId:n=g,theme:a,sendDataModel:o}=t;return {createSurface:{surfaceId:e,catalogId:n,...a&&{theme:a},...o!==void 0&&{sendDataModel:o}}}}function d(e,t){return {updateComponents:{surfaceId:e,components:t}}}function l(e,t,n){return {updateDataModel:{surfaceId:e,...n,...t!==void 0&&{value:t}}}}function C(e){return {deleteSurface:{surfaceId:e}}}function s(e,t,n={}){let{surfaceId:a,theme:o,sendDataModel:p}=n,i=a??u();return t.find(M=>M.id===e)||console.warn(`[A2UI] Root component "${e}" not found in components list`),{messages:[m(i,{theme:o,sendDataModel:p}),d(i,t)],surfaceId:i}}function D(e,t,n,a={}){let{surfaceId:o,theme:p,sendDataModel:i}=a,c=o??u();return {messages:[m(c,{theme:p,sendDataModel:i}),d(c,t),l(c,n)],surfaceId:c}}function T(e){return C(e)}function x(e,t,n={}){return s(e,t,{...n,surfaceId:r.CHAT})}function A(e,t,n={}){return s(e,t,{...n,surfaceId:r.RECOMMENDATION})}function y(e,t,n={}){return s(e,t,{...n,surfaceId:r.INPUT_FORM})}function O(e,t,n={}){return s(e,t,{...n,surfaceId:r.ORCHESTRATION})}function R(e,t,n={}){return s(e,t,{...n,surfaceId:r.STATUS})}
2
+ export{r as SURFACE_IDS,s as createA2UISurface,D as createA2UISurfaceWithData,x as createChatSurface,T as createDeleteSurfaceMessage,y as createInputFormSurface,O as createOrchestrationSurface,A as createRecommendationSurface,R as createStatusSurface,u as generateSurfaceId,I as resetSurfaceIdCounter};
@@ -1,2 +1,2 @@
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;
1
+ 'use strict';var t="https://a2ui.dev/specification/v0_9/standard_catalog.json";function n(e){return "createSurface"in e}function a(e){return "updateComponents"in e}function o(e){return "updateDataModel"in e}function r(e){return "deleteSurface"in e}function s(e){return "action"in e}function i(e){return "error"in e}
2
+ exports.STANDARD_CATALOG_ID=t;exports.isActionMessage=s;exports.isCreateSurfaceMessage=n;exports.isDeleteSurfaceMessage=r;exports.isErrorMessage=i;exports.isUpdateComponentsMessage=a;exports.isUpdateDataModelMessage=o;