@farris/x-ui 0.0.2 → 0.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@farris/x-ui",
3
- "version": "0.0.2",
3
+ "version": "0.0.4",
4
4
  "description": "可复用的 AI 对话组件",
5
5
  "type": "module",
6
6
  "main": "./farris.x-ui.umd.cjs",
@@ -1,61 +0,0 @@
1
- import { PreviewBridgeAssistantPayload } from '../../../preview-bridge-protocol';
2
-
3
- export type { PreviewChromeSdkHandlers } from '../../../preview-chrome-sdk';
4
- export { registerPreviewChromeSdk } from '../../../preview-chrome-sdk';
5
- export interface SendWorkbenchChatMessageOptions {
6
- /**
7
- * 接收 `message` 事件的窗口,默认 `window.top ?? window`(与 Workbench 挂载 `window.sendMessage` 时一致)。
8
- */
9
- target?: Window;
10
- /** `postMessage` 第二参数,默认 `'*'` */
11
- targetOrigin?: string;
12
- }
13
- /**
14
- * 通过 Workbench 约定的 `postMessage` 向宿主注入一条「用户发送」文案(等价于控制台 `window.top.sendMessage(content)`)。
15
- * 由 Workbench 内 `WorkbenchContent` 监听并转交 `handleSendMessage`;空串等行为与宿主实现一致。
16
- */
17
- export declare function sendChatMessageViaAgentWorkbenchSDK(content: string, options?: SendWorkbenchChatMessageOptions): boolean;
18
- export interface AgentWorkbenchSDKSubscribeOptions {
19
- /** 允许的父页面 origin;不传则只做结构校验,不校验 origin */
20
- allowedParentOrigins?: string[];
21
- /**
22
- * 为 true(默认)时接受 `window.parent` 或 `window.top` 作为发送方。
23
- * 嵌套 iframe 时顶层脚本常通过 top 持有子 iframe 引用并 postMessage,子页 `ev.source` 可能是 top。
24
- */
25
- allowTopAsSource?: boolean;
26
- onAssistantMessage?: (payload: PreviewBridgeAssistantPayload) => void;
27
- }
28
- /**
29
- * 父页 / 顶层壳:向预览 iframe 的 `contentWindow` 推送助手消息(与 {@link AgentWorkbenchSDK.subscribe} 协议一致)。
30
- * @param targetWindow 一般为 `iframe.contentWindow`
31
- * @param targetOrigin 须与 `postMessage` 规范一致,同源可传 `iframe.contentWindow.location.origin` 或从预览 URL 推导
32
- * @returns 是否已成功调用 postMessage(不代表子页一定已监听)
33
- */
34
- export declare function postAssistantViaAgentWorkbenchSDK(targetWindow: Window, targetOrigin: string, payload: PreviewBridgeAssistantPayload): boolean;
35
- /**
36
- * 预览 iframe 内:订阅父页 / top 推送的助手消息。
37
- * @returns 取消订阅函数
38
- */
39
- export declare function subscribeAssistantViaAgentWorkbenchSDK(options: AgentWorkbenchSDKSubscribeOptions): () => void;
40
- /**
41
- * Workbench 会话预览集成 SDK:postMessage 预览桥 + 分屏/双栏预览 imperative API(由 FXConversation `registerPreviewChromeSdk` 注入后 `showPreview` 等生效)。
42
- */
43
- export declare const AgentWorkbenchSDK: {
44
- readonly subscribe: typeof subscribeAssistantViaAgentWorkbenchSDK;
45
- readonly postAssistantMessage: typeof postAssistantViaAgentWorkbenchSDK;
46
- /** 向 Workbench 宿主投递会话发送(postMessage invoke / sendMessage) */
47
- readonly sendChatMessage: typeof sendChatMessageViaAgentWorkbenchSDK;
48
- readonly showPreview: (config: import('../../../../..').PreviewConfig) => void;
49
- /** 双栏(左、右均为预览 iframe)时,将右侧换成新的 `previewConfig`;其它情况与 `showPreview` 一致。 */
50
- readonly replaceRightPreview: (config: import('../../../../..').PreviewConfig) => void;
51
- readonly closePreviewPane: () => void;
52
- readonly closeRightPreview: () => void;
53
- readonly showFullScreenPreview: (config: import('../../../../..').PreviewConfig) => void;
54
- readonly closeFullScreenPreview: () => void;
55
- readonly isPreviewLayoutActive: () => boolean;
56
- };
57
- /**
58
- * 按方法名调用 {@link AgentWorkbenchSDK}(供网关 `InputRecommend` 等配置 `api` + `params`)。
59
- * 未知方法或非函数成员会告警并返回 `undefined`。
60
- */
61
- export declare function invokeAgentWorkbenchSdkApi(api: string, params?: unknown[]): unknown;