@opentiny/tiny-robot 0.4.0-alpha.2 → 0.4.0-alpha.3

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,12 +1,13 @@
1
- import { B as b, a, b as r, c as u, d as B, u as l, e as t, f as n, g as d } from "../index2.js";
1
+ import { B as b, a, b as r, c as u, d as t, u as n, e as B, f as l, g as d, h as o } from "../index2.js";
2
2
  export {
3
3
  b as Bubble,
4
4
  a as BubbleList,
5
5
  r as BubbleProvider,
6
6
  u as BubbleRendererMatchPriority,
7
- B as BubbleRenderers,
8
- l as useBubbleBoxRenderer,
9
- t as useBubbleContentRenderer,
10
- n as useBubbleStateChangeFn,
11
- d as useOmitMessageFields
7
+ t as BubbleRenderers,
8
+ n as useBubbleBoxRenderer,
9
+ B as useBubbleContentRenderer,
10
+ l as useBubbleStateChangeFn,
11
+ d as useMessageContent,
12
+ o as useOmitMessageFields
12
13
  };
package/dist/index.d.ts CHANGED
@@ -52,7 +52,10 @@ contentIndex?: number;
52
52
  placement: "start" | "end";
53
53
  shape: "corner" | "rounded" | "none";
54
54
  contentRenderMode: "single" | "split";
55
- }, {}, {}, {}, string, ComponentProvideOptions, false, {}, HTMLDivElement>;
55
+ contentResolver: (message: BubbleMessage) => ChatMessageContent | undefined;
56
+ }, {}, {}, {}, string, ComponentProvideOptions, false, {
57
+ bubbleRef: HTMLDivElement;
58
+ }, HTMLDivElement>;
56
59
 
57
60
  declare const __VLS_component_10: DefineComponent<__VLS_PublicProps_3, {
58
61
  children: ComputedRef<(HTMLElement | SVGElement)[]>;
@@ -225,6 +228,57 @@ declare const __VLS_component_13: DefineComponent<WelcomeProps, {}, {}, {}, {},
225
228
  align: "left" | "center" | "right" | string;
226
229
  }, {}, {}, {}, string, ComponentProvideOptions, false, {}, HTMLDivElement>;
227
230
 
231
+ declare const __VLS_component_14: DefineComponent<__VLS_PublicProps_6, {}, {}, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, {
232
+ "update:visible": (value: boolean) => any;
233
+ } & {
234
+ refresh: (tab: "installed" | "market") => any;
235
+ "update:visible": (visible: boolean) => any;
236
+ "market-category-change": (category: string) => any;
237
+ "tab-change": (activeTab: "installed" | "market") => any;
238
+ "plugin-toggle": (plugin: PluginInfo, enabled: boolean) => any;
239
+ "plugin-delete": (plugin: PluginInfo) => any;
240
+ "plugin-add": (plugin: PluginInfo) => any;
241
+ "plugin-create": (type: "code" | "form", data: PluginCreationData) => any;
242
+ "tool-toggle": (plugin: PluginInfo, toolId: string, enabled: boolean) => any;
243
+ "update:activeCount": (count: number) => any;
244
+ }, string, PublicProps, Readonly<__VLS_PublicProps_6> & Readonly<{
245
+ onRefresh?: ((tab: "installed" | "market") => any) | undefined;
246
+ "onUpdate:visible"?: ((value: boolean) => any) | undefined;
247
+ "onMarket-category-change"?: ((category: string) => any) | undefined;
248
+ "onTab-change"?: ((activeTab: "installed" | "market") => any) | undefined;
249
+ "onPlugin-toggle"?: ((plugin: PluginInfo, enabled: boolean) => any) | undefined;
250
+ "onPlugin-delete"?: ((plugin: PluginInfo) => any) | undefined;
251
+ "onPlugin-add"?: ((plugin: PluginInfo) => any) | undefined;
252
+ "onPlugin-create"?: ((type: "code" | "form", data: PluginCreationData) => any) | undefined;
253
+ "onTool-toggle"?: ((plugin: PluginInfo, toolId: string, enabled: boolean) => any) | undefined;
254
+ "onUpdate:activeCount"?: ((count: number) => any) | undefined;
255
+ }>, {
256
+ title: string;
257
+ loading: boolean;
258
+ installedPlugins: PluginInfo[];
259
+ marketPlugins: PluginInfo[];
260
+ searchPlaceholder: string;
261
+ enableSearch: boolean;
262
+ installedSearchFn: (query: string, item: PluginInfo) => boolean;
263
+ marketSearchFn: (query: string, item: PluginInfo) => boolean;
264
+ marketCategoryOptions: MarketCategoryOption[];
265
+ marketCategoryPlaceholder: string;
266
+ enableMarketCategoryFilter: boolean;
267
+ defaultActiveTab: "installed" | "market";
268
+ showInstalledTab: boolean;
269
+ showMarketTab: boolean;
270
+ popupConfig: PopupConfig;
271
+ installedTabTitle: string;
272
+ marketTabTitle: string;
273
+ showCustomAddButton: boolean;
274
+ customAddButtonText: string;
275
+ allowPluginToggle: boolean;
276
+ allowToolToggle: boolean;
277
+ allowPluginDelete: boolean;
278
+ allowPluginAdd: boolean;
279
+ marketLoading: boolean;
280
+ }, {}, {}, {}, string, ComponentProvideOptions, false, {}, any>;
281
+
228
282
  declare const __VLS_component_2: DefineComponent<BubbleListProps, {
229
283
  scrollToBottom: (behavior?: ScrollBehavior) => Promise<void>;
230
284
  }, {}, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, {} & {
@@ -242,6 +296,7 @@ messageIndex: number;
242
296
  contentIndex?: number;
243
297
  }) => any) | undefined;
244
298
  }>, {
299
+ contentResolver: (message: BubbleMessage) => ChatMessageContent | undefined;
245
300
  groupStrategy: "consecutive" | "divider" | ((messages: BubbleMessage[], dividerRole?: string) => BubbleMessageGroup[]);
246
301
  dividerRole: string;
247
302
  fallbackRole: string;
@@ -982,7 +1037,9 @@ declare type __VLS_PublicProps_6 = {
982
1037
  declare function __VLS_template(): {
983
1038
  attrs: Partial<{}>;
984
1039
  slots: Readonly<BubbleSlots> & BubbleSlots;
985
- refs: {};
1040
+ refs: {
1041
+ bubbleRef: HTMLDivElement;
1042
+ };
986
1043
  rootEl: HTMLDivElement;
987
1044
  };
988
1045
 
@@ -1134,6 +1191,15 @@ declare function __VLS_template_13(): {
1134
1191
  rootEl: HTMLDivElement;
1135
1192
  };
1136
1193
 
1194
+ declare function __VLS_template_14(): {
1195
+ attrs: Partial<{}>;
1196
+ slots: {
1197
+ 'header-actions'?(_: {}): any;
1198
+ };
1199
+ refs: {};
1200
+ rootEl: any;
1201
+ };
1202
+
1137
1203
  declare function __VLS_template_2(): {
1138
1204
  attrs: Partial<{}>;
1139
1205
  slots: Readonly<BubbleListSlots> & BubbleListSlots;
@@ -1806,6 +1872,8 @@ declare type __VLS_TemplateResult_12 = ReturnType<typeof __VLS_template_12>;
1806
1872
 
1807
1873
  declare type __VLS_TemplateResult_13 = ReturnType<typeof __VLS_template_13>;
1808
1874
 
1875
+ declare type __VLS_TemplateResult_14 = ReturnType<typeof __VLS_template_14>;
1876
+
1809
1877
  declare type __VLS_TemplateResult_2 = ReturnType<typeof __VLS_template_2>;
1810
1878
 
1811
1879
  declare type __VLS_TemplateResult_3 = ReturnType<typeof __VLS_template_3>;
@@ -1852,6 +1920,12 @@ declare type __VLS_WithTemplateSlots_13<T, S> = T & {
1852
1920
  };
1853
1921
  };
1854
1922
 
1923
+ declare type __VLS_WithTemplateSlots_14<T, S> = T & {
1924
+ new (): {
1925
+ $slots: S;
1926
+ };
1927
+ };
1928
+
1855
1929
  declare type __VLS_WithTemplateSlots_2<T, S> = T & {
1856
1930
  new (): {
1857
1931
  $slots: S;
@@ -1980,7 +2054,14 @@ export { Bubble }
1980
2054
  export { Bubble as TrBubble }
1981
2055
 
1982
2056
  export declare type BubbleBoxRendererMatch = {
1983
- find: (messages: BubbleMessage[], contentIndex?: number) => boolean;
2057
+ /**
2058
+ * 匹配函数,用于判断是否应该使用此渲染器
2059
+ * @param messages - 消息数组
2060
+ * @param resolvedContents - 每个消息经过 contentResolver 解析后的内容数组,与 messages 一一对应
2061
+ * @param contentIndex - 内容索引,用于指定要渲染的内容项(当 content 为数组时)
2062
+ * @returns 如果匹配则返回 true,否则返回 false
2063
+ */
2064
+ find: (messages: BubbleMessage[], resolvedContents: BubbleMessage['content'][], contentIndex: number | undefined) => boolean;
1984
2065
  renderer: Component<BubbleBoxRendererProps>;
1985
2066
  priority?: number;
1986
2067
  attributes?: Record<string, string>;
@@ -1989,7 +2070,14 @@ export declare type BubbleBoxRendererMatch = {
1989
2070
  export declare type BubbleBoxRendererProps = Pick<BubbleProps, 'placement' | 'shape'>;
1990
2071
 
1991
2072
  export declare type BubbleContentRendererMatch = {
1992
- find: (message: BubbleMessage, contentIndex?: number) => boolean;
2073
+ /**
2074
+ * 匹配函数,用于判断是否应该使用此渲染器
2075
+ * @param message - 消息对象
2076
+ * @param resolvedContent - 消息经过 contentResolver 解析后的内容
2077
+ * @param contentIndex - 内容索引,用于指定要渲染的内容项(当 content 为数组时)
2078
+ * @returns 如果匹配则返回 true,否则返回 false
2079
+ */
2080
+ find: (message: BubbleMessage, resolvedContent: BubbleMessage['content'], contentIndex: number | undefined) => boolean;
1993
2081
  renderer: Component<BubbleContentRendererProps>;
1994
2082
  priority?: number;
1995
2083
  attributes?: Record<string, string>;
@@ -2044,6 +2132,7 @@ export declare interface BubbleListProps {
2044
2132
  */
2045
2133
  roleConfigs?: Record<string, BubbleRoleConfig>;
2046
2134
  contentRenderMode?: BubbleProps['contentRenderMode'];
2135
+ contentResolver?: BubbleProps['contentResolver'];
2047
2136
  /**
2048
2137
  * 是否自动滚动到底部。需要满足以下条件:
2049
2138
  * - BubbleList 是可滚动容器(需要 scrollHeight > clientHeight)
@@ -2086,6 +2175,7 @@ export declare type BubbleProps = BubbleMessage & {
2086
2175
  placement?: 'start' | 'end';
2087
2176
  shape?: 'corner' | 'rounded' | 'none';
2088
2177
  contentRenderMode?: 'single' | 'split';
2178
+ contentResolver?: (message: BubbleMessage) => ChatMessageContent | undefined;
2089
2179
  fallbackBoxRenderer?: Component<BubbleBoxRendererProps>;
2090
2180
  fallbackContentRenderer?: Component<BubbleContentRendererProps>;
2091
2181
  };
@@ -2103,7 +2193,7 @@ export declare interface BubbleProviderProps {
2103
2193
  contentRendererMatches?: BubbleContentRendererMatch[];
2104
2194
  fallbackBoxRenderer?: Component<BubbleBoxRendererProps>;
2105
2195
  fallbackContentRenderer?: Component<BubbleContentRendererProps>;
2106
- initialStore?: Record<string, unknown>;
2196
+ store?: Record<string, unknown>;
2107
2197
  }
2108
2198
 
2109
2199
  /**
@@ -2142,10 +2232,10 @@ export declare const BubbleRenderers: {
2142
2232
  };
2143
2233
  });
2144
2234
  Image: DefineComponent< {
2145
- message: BubbleMessage<ChatMessageContent, Record<string, unknown>>;
2235
+ message: BubbleMessage<ChatMessageContentItem[], Record<string, unknown>>;
2146
2236
  contentIndex?: number;
2147
2237
  }, {}, {}, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, {}, string, PublicProps, Readonly<{
2148
- message: BubbleMessage<ChatMessageContent, Record<string, unknown>>;
2238
+ message: BubbleMessage<ChatMessageContentItem[], Record<string, unknown>>;
2149
2239
  contentIndex?: number;
2150
2240
  }> & Readonly<{}>, {}, {}, {}, {}, string, ComponentProvideOptions, false, {}, HTMLImageElement>;
2151
2241
  Loading: DefineComponent< {
@@ -2441,56 +2531,7 @@ declare const _default_34: __VLS_WithTemplateSlots_12<typeof __VLS_component_12,
2441
2531
 
2442
2532
  declare const _default_35: __VLS_WithTemplateSlots_13<typeof __VLS_component_13, __VLS_TemplateResult_13["slots"]>;
2443
2533
 
2444
- declare const _default_36: DefineComponent<__VLS_PublicProps_6, {}, {}, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, {
2445
- "update:visible": (value: boolean) => any;
2446
- } & {
2447
- refresh: (tab: "installed" | "market") => any;
2448
- "update:visible": (visible: boolean) => any;
2449
- "market-category-change": (category: string) => any;
2450
- "tab-change": (activeTab: "installed" | "market") => any;
2451
- "plugin-toggle": (plugin: PluginInfo, enabled: boolean) => any;
2452
- "plugin-delete": (plugin: PluginInfo) => any;
2453
- "plugin-add": (plugin: PluginInfo) => any;
2454
- "plugin-create": (type: "code" | "form", data: PluginCreationData) => any;
2455
- "tool-toggle": (plugin: PluginInfo, toolId: string, enabled: boolean) => any;
2456
- "update:activeCount": (count: number) => any;
2457
- }, string, PublicProps, Readonly<__VLS_PublicProps_6> & Readonly<{
2458
- onRefresh?: ((tab: "installed" | "market") => any) | undefined;
2459
- "onUpdate:visible"?: ((value: boolean) => any) | undefined;
2460
- "onMarket-category-change"?: ((category: string) => any) | undefined;
2461
- "onTab-change"?: ((activeTab: "installed" | "market") => any) | undefined;
2462
- "onPlugin-toggle"?: ((plugin: PluginInfo, enabled: boolean) => any) | undefined;
2463
- "onPlugin-delete"?: ((plugin: PluginInfo) => any) | undefined;
2464
- "onPlugin-add"?: ((plugin: PluginInfo) => any) | undefined;
2465
- "onPlugin-create"?: ((type: "code" | "form", data: PluginCreationData) => any) | undefined;
2466
- "onTool-toggle"?: ((plugin: PluginInfo, toolId: string, enabled: boolean) => any) | undefined;
2467
- "onUpdate:activeCount"?: ((count: number) => any) | undefined;
2468
- }>, {
2469
- title: string;
2470
- loading: boolean;
2471
- installedPlugins: PluginInfo[];
2472
- marketPlugins: PluginInfo[];
2473
- searchPlaceholder: string;
2474
- enableSearch: boolean;
2475
- installedSearchFn: (query: string, item: PluginInfo) => boolean;
2476
- marketSearchFn: (query: string, item: PluginInfo) => boolean;
2477
- marketCategoryOptions: MarketCategoryOption[];
2478
- marketCategoryPlaceholder: string;
2479
- enableMarketCategoryFilter: boolean;
2480
- defaultActiveTab: "installed" | "market";
2481
- showInstalledTab: boolean;
2482
- showMarketTab: boolean;
2483
- popupConfig: PopupConfig;
2484
- installedTabTitle: string;
2485
- marketTabTitle: string;
2486
- showCustomAddButton: boolean;
2487
- customAddButtonText: string;
2488
- allowPluginToggle: boolean;
2489
- allowToolToggle: boolean;
2490
- allowPluginDelete: boolean;
2491
- allowPluginAdd: boolean;
2492
- marketLoading: boolean;
2493
- }, {}, {}, {}, string, ComponentProvideOptions, false, {}, any>;
2534
+ declare const _default_36: __VLS_WithTemplateSlots_14<typeof __VLS_component_14, __VLS_TemplateResult_14["slots"]>;
2494
2535
 
2495
2536
  declare const _default_37: DefineComponent<McpAddFormProps, {}, {}, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, {} & {
2496
2537
  cancel: () => any;
@@ -3425,6 +3466,12 @@ export declare function useBubbleContentRenderer(message: MaybeRefOrGetter<Bubbl
3425
3466
 
3426
3467
  export declare function useBubbleStateChangeFn(): (key: string, _value: unknown) => void;
3427
3468
 
3469
+ export declare const useMessageContent: <T extends ChatMessageContent = ChatMessageContent>(props: Readonly<BubbleContentRendererProps<T>>) => {
3470
+ content: ComputedRef<ChatMessageContent | undefined>;
3471
+ contentItem: ComputedRef<ChatMessageContentItem | undefined>;
3472
+ contentText: ComputedRef<string>;
3473
+ };
3474
+
3428
3475
  /**
3429
3476
  * Omit specified fields from message and return computed props
3430
3477
  * @param props - The original props containing the message
package/dist/index.js CHANGED
@@ -1,20 +1,20 @@
1
1
  import z from "./attachments/index.js";
2
2
  import { B as b, a as x, b as S } from "./index2.js";
3
- import { c as ve, d as fe, h as _e, u as ge, e as he, f as De, g as Te } from "./index2.js";
3
+ import { c as ve, d as fe, i as _e, u as ge, e as he, f as De, g as Te, h as Fe } from "./index2.js";
4
4
  import E from "./container/index.js";
5
5
  import P from "./conversations/index.js";
6
6
  import B from "./drag-overlay/index.js";
7
7
  import L from "./dropdown-menu/index.js";
8
- import y from "./feedback/index.js";
9
- import { H as C } from "./index3.js";
10
- import { u as ze } from "./index3.js";
8
+ import C from "./feedback/index.js";
9
+ import { H as y } from "./index3.js";
10
+ import { u as be } from "./index3.js";
11
11
  import O from "./icon-button/index.js";
12
- import { Prompt as A, Prompts as H } from "./prompts/index.js";
13
- import M from "./sender/index.js";
12
+ import { Prompt as M, Prompts as A } from "./prompts/index.js";
13
+ import H from "./sender/index.js";
14
14
  import j, { SuggestionPillButton as R } from "./suggestion-pills/index.js";
15
15
  import w from "./suggestion-popover/index.js";
16
16
  import k from "./theme-provider/index.js";
17
- import { useTheme as xe } from "./theme-provider/index.js";
17
+ import { useTheme as Se } from "./theme-provider/index.js";
18
18
  import W from "./welcome/index.js";
19
19
  import $ from "./mcp-server-picker/index.js";
20
20
  import I from "./mcp-add-form/index.js";
@@ -152,12 +152,12 @@ const ue = {
152
152
  P,
153
153
  B,
154
154
  L,
155
- y,
156
155
  C,
156
+ y,
157
157
  O,
158
+ M,
158
159
  A,
159
160
  H,
160
- M,
161
161
  j,
162
162
  R,
163
163
  w,
@@ -184,14 +184,14 @@ export {
184
184
  P as Conversations,
185
185
  B as DragOverlay,
186
186
  L as DropdownMenu,
187
- y as Feedback,
188
- C as History,
187
+ C as Feedback,
188
+ y as History,
189
189
  O as IconButton,
190
190
  I as McpAddForm,
191
191
  $ as McpServerPicker,
192
- A as Prompt,
193
- H as Prompts,
194
- M as Sender,
192
+ M as Prompt,
193
+ A as Prompts,
194
+ H as Sender,
195
195
  R as SuggestionPillButton,
196
196
  j as SuggestionPills,
197
197
  w as SuggestionPopover,
@@ -204,14 +204,14 @@ export {
204
204
  P as TrConversations,
205
205
  B as TrDragOverlay,
206
206
  L as TrDropdownMenu,
207
- y as TrFeedback,
208
- C as TrHistory,
207
+ C as TrFeedback,
208
+ y as TrHistory,
209
209
  O as TrIconButton,
210
210
  I as TrMcpAddForm,
211
211
  $ as TrMcpServerPicker,
212
- A as TrPrompt,
213
- H as TrPrompts,
214
- M as TrSender,
212
+ M as TrPrompt,
213
+ A as TrPrompts,
214
+ H as TrSender,
215
215
  R as TrSuggestionPillButton,
216
216
  j as TrSuggestionPills,
217
217
  w as TrSuggestionPopover,
@@ -223,8 +223,9 @@ export {
223
223
  ge as useBubbleBoxRenderer,
224
224
  he as useBubbleContentRenderer,
225
225
  De as useBubbleStateChangeFn,
226
- Te as useOmitMessageFields,
227
- xe as useTheme,
228
- ze as useTouchDevice,
226
+ Te as useMessageContent,
227
+ Fe as useOmitMessageFields,
228
+ Se as useTheme,
229
+ be as useTouchDevice,
229
230
  ue as vDropzone
230
231
  };