wi-chat 0.6.1 → 0.7.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/dist/core/index.cjs +1 -1
- package/dist/core/index.d.ts +12 -0
- package/dist/core/index.js +737 -322
- package/dist/core/useAnswerActions.d.ts +61 -0
- package/dist/core/useChat.d.ts +90 -15
- package/dist/core/useChatAuth.d.ts +96 -0
- package/dist/core/useChatRooms.d.ts +66 -0
- package/dist/core/useKeepAlive.d.ts +41 -0
- package/dist/core/useLlm.d.ts +73 -0
- package/dist/core/useRunningGroups.d.ts +58 -0
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +4 -2
- package/dist/index.js +119 -108
- package/dist/mobile-ui/chat/ChatContainer.vue.d.ts +8 -8
- package/dist/mobile-ui/chat/ChatMessagesView.vue.d.ts +6 -6
- package/dist/mobile-ui/index.cjs +1 -1
- package/dist/mobile-ui/index.js +104 -104
- package/dist/mobile-ui/inputbox/Inputbox.vue.d.ts +6 -6
- package/dist/page-context/index.js +2 -4
- package/dist/parser/answerCom/actionExecute/actionProtocol.d.ts +1 -7
- package/dist/parser/answerCom/actionExecute/clarification.d.ts +15 -3
- package/dist/parser/answerCom/actionExecute/constants.d.ts +10 -0
- package/dist/parser/answerCom/actionExecute/parseCollectClarifications.d.ts +3 -2
- package/dist/parser/answerCom/actionExecute/parseHostAction.d.ts +3 -2
- package/dist/parser/answerCom/actionExecute/types.d.ts +3 -3
- package/dist/parser/answerCom/generic/parseGeneric.d.ts +52 -0
- package/dist/parser/answerCom/generic/types.d.ts +75 -0
- package/dist/parser/answerCom/outputFile/parseOutputFile.d.ts +7 -6
- package/dist/parser/answerCom/outputFile/types.d.ts +15 -5
- package/dist/parser/answerCom/presentFiles/parsePresentFiles.d.ts +58 -0
- package/dist/parser/answerCom/presentFiles/types.d.ts +27 -0
- package/dist/parser/answerMeta.d.ts +71 -0
- package/dist/parser/deepThinking/parseDeepThinking.d.ts +8 -0
- package/dist/parser/history/history.d.ts +9 -0
- package/dist/parser/history/index.d.ts +1 -1
- package/dist/parser/index.cjs +6 -2
- package/dist/parser/index.d.ts +13 -4
- package/dist/parser/index.js +640 -457
- package/dist/parser/message.d.ts +9 -0
- package/dist/parser/registry.d.ts +1 -1
- package/dist/parser/runTime.d.ts +29 -0
- package/dist/renderers/TextAnswer-BgKGvG_o.cjs +2 -0
- package/dist/renderers/TextAnswer-PQwV3K7v.js +5 -0
- package/dist/renderers/aiAnswer/AiAnswerBubble.vue.d.ts +4 -4
- package/dist/renderers/answerCard/AnswerCard.vue.d.ts +65 -0
- package/dist/renderers/answerCard/AnswerToolbar.vue.d.ts +42 -0
- package/dist/renderers/answerConfig.d.ts +33 -0
- package/dist/renderers/clarification/ClarificationCard.vue.d.ts +3 -3
- package/dist/renderers/deepThinking/DeepThinkingSteps.vue.d.ts +4 -4
- package/dist/renderers/deviceLastValue/DeviceLastValue.vue.d.ts +37 -0
- package/dist/renderers/hostAction/HostActionStatus.vue.d.ts +3 -3
- package/dist/renderers/iframePage/IframePage.vue.d.ts +3 -3
- package/dist/renderers/index.cjs +6 -1
- package/dist/renderers/index.d.ts +14 -0
- package/dist/renderers/index.js +1504 -607
- package/dist/renderers/knowledgeStream/KnowledgeStreamResult.vue.d.ts +3 -3
- package/dist/renderers/media/MediaAnswer.vue.d.ts +19 -0
- package/dist/renderers/outputFile/OutputFile.vue.d.ts +3 -3
- package/dist/renderers/outputFile/OutputFileLink.vue.d.ts +19 -0
- package/dist/renderers/outputFile/localFile.d.ts +46 -0
- package/dist/renderers/outputFile/useOutputFile.d.ts +32 -3
- package/dist/renderers/presentFiles/PresentFiles.vue.d.ts +19 -0
- package/dist/renderers/recordset/RecordsetView.vue.d.ts +19 -0
- package/dist/renderers/sqlQuery/SqlQuery.vue.d.ts +19 -0
- package/dist/renderers/style.css +1 -1
- package/dist/renderers/text/TextAnswer.vue.d.ts +19 -0
- package/dist/request/api.d.ts +121 -1
- package/dist/request/client.d.ts +6 -0
- package/dist/request/index.cjs +4 -2
- package/dist/request/index.d.ts +4 -2
- package/dist/request/index.js +754 -181
- package/dist/request/ws.d.ts +11 -86
- package/dist/request/wsCore.d.ts +104 -0
- package/dist/request/wsSession.d.ts +353 -0
- package/dist/right-panel/RightPanel.vue.d.ts +6 -6
- package/dist/right-panel/RightPanelIcon.vue.d.ts +4 -4
- package/dist/right-panel/RightPanelTabs.vue.d.ts +9 -5
- package/dist/right-panel/index.cjs +1 -1
- package/dist/right-panel/index.d.ts +1 -1
- package/dist/right-panel/index.js +617 -537
- package/dist/right-panel/panels/newtab/NewTabPanel.vue.d.ts +4 -4
- package/dist/right-panel/panels/web/WebPanel.vue.d.ts +3 -3
- package/dist/right-panel/shared/BrowserToolbar.vue.d.ts +3 -3
- package/dist/right-panel/shared/RightPanelToolList.vue.d.ts +5 -5
- package/dist/right-panel/style.css +1 -1
- package/dist/right-panel/types.d.ts +10 -0
- package/dist/theme/index.js +2 -4
- package/dist/tools/index.cjs +5 -5
- package/dist/tools/index.d.ts +2 -2
- package/dist/tools/index.js +323 -217
- package/dist/tools/markdown/MarkdownContent.vue.d.ts +5 -5
- package/dist/tools/markdown/index.d.ts +2 -0
- package/dist/tools/markdown/interactions.d.ts +39 -0
- package/dist/tools/markdown/sanitize.d.ts +6 -0
- package/dist/tools/style.css +1 -1
- package/dist/tools/useAutoScroll.d.ts +3 -3
- package/dist/web-ui/attach/AttachmentCard.vue.d.ts +6 -6
- package/dist/web-ui/attach/AttachmentList.vue.d.ts +6 -6
- package/dist/web-ui/chat/ChatContainer.vue.d.ts +10 -10
- package/dist/web-ui/chat/ChatMessagesView.vue.d.ts +6 -6
- package/dist/web-ui/envswitch/EnvSwitch.vue.d.ts +6 -6
- package/dist/web-ui/index.cjs +1 -1
- package/dist/web-ui/index.js +630 -635
- package/dist/web-ui/inputbox/Inputbox.vue.d.ts +11 -11
- package/dist/web-ui/recordset/RecordsetTable.vue.d.ts +4 -4
- package/dist/web-ui/style.css +1 -1
- package/package.json +2 -1
|
@@ -7,11 +7,11 @@ import { OutputFileValue } from './types';
|
|
|
7
7
|
export declare const OUTPUT_FILE_ANSWER_TYPE = "output_file";
|
|
8
8
|
/**
|
|
9
9
|
* 防御性读取 output_file 载荷,兼容两种服务端形态:
|
|
10
|
-
* - 实时链路:`{ values: { file_id, file_name }, answer_type: 'output_file' }`;
|
|
11
|
-
* - 历史接口:`{ file_id, file_name, answer_type: 'output_file' }`(顶层字段)。
|
|
10
|
+
* - 实时链路:`{ values: { file_id, file_name, file_path? }, answer_type: 'output_file' }`;
|
|
11
|
+
* - 历史接口:`{ file_id, file_name, file_path?, answer_type: 'output_file' }`(顶层字段)。
|
|
12
12
|
* 嵌套优先、顶层兜底;两者都取不到时返回空对象。
|
|
13
13
|
* @param value result chunk 载荷(或历史 report 元素)
|
|
14
|
-
* @returns 只含非空 file_id / file_name 的取值结构
|
|
14
|
+
* @returns 只含非空 file_id / file_name / file_path 的取值结构
|
|
15
15
|
*/
|
|
16
16
|
export declare const readOutputFilePayload: (value: any) => OutputFileValue;
|
|
17
17
|
/**
|
|
@@ -26,10 +26,11 @@ export declare const readOutputFilePayload: (value: any) => OutputFileValue;
|
|
|
26
26
|
export declare const applyOutputFileChunk: (chunk: StreamChunk, reports: AiAnswerReport<any>[]) => boolean;
|
|
27
27
|
/**
|
|
28
28
|
* 把历史接口返回的单个 `output_file` report 元素标准化成渲染层结构:
|
|
29
|
-
* 渲染层只读 `values`,故把顶层 file_id / file_name 收拢进 values。
|
|
29
|
+
* 渲染层只读 `values`,故把顶层 file_id / file_name / file_path 收拢进 values。
|
|
30
30
|
*
|
|
31
|
-
* 幂等:values
|
|
32
|
-
*
|
|
31
|
+
* 幂等:values 已有全部可用字段(实时累积或此前已标准化)时原样跳过;
|
|
32
|
+
* 三处都取不到时不改写 values(不造空结构)。已有字段不覆盖,只补齐缺失字段
|
|
33
|
+
* (如 values 只有 file_name、顶层才有 file_id / file_path)。
|
|
33
34
|
* @param report 历史 reports 中的一个 `output_file` 元素(就地修改并返回)
|
|
34
35
|
* @returns 标准化后的同一 report 引用
|
|
35
36
|
*/
|
|
@@ -1,17 +1,27 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* output_file 答案类型的类型定义
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
* `answer_type
|
|
6
|
-
*
|
|
7
|
-
*
|
|
4
|
+
* 后端生成文件后下发 `answer_type = 'output_file'` 的 result 报告:
|
|
5
|
+
* `{ values: { file_id, file_name, file_path? }, answer_type: 'output_file', ... }`。
|
|
6
|
+
* 渲染层据此展示文件卡片,点击后按文件类型预览(文本 / 图片 / PDF / HTML / 音视频),
|
|
7
|
+
* 文件来源由宿主裁决(`OutputFileConfig.isLocalSupported`):
|
|
8
|
+
* - 「当前对话为本地电脑」且「当前是桌面端」:按 file_path 读本地文件
|
|
9
|
+
* (相对路径由桌面主进程解析挂载),本地 HTML 的相对 js/css 资源一并内联;
|
|
10
|
+
* - 其余一律(云电脑对话 / 网页端 / 未带 file_path / 无本地桥):按 file_id 走后端接口下载。
|
|
8
11
|
*/
|
|
9
12
|
/** output_file 回答的渲染层取值结构 */
|
|
10
13
|
export interface OutputFileValue {
|
|
11
|
-
/** 后端文件 id,用于按 id
|
|
14
|
+
/** 后端文件 id,用于按 id 下载文件二进制(网页端链路) */
|
|
12
15
|
file_id?: string;
|
|
13
16
|
/** 文件名(含扩展名),用于展示与判断预览类型 */
|
|
14
17
|
file_name?: string;
|
|
18
|
+
/**
|
|
19
|
+
* 桌面端本地文件路径(相对或绝对,由后端下发)。
|
|
20
|
+
* 仅当「当前对话为本地电脑」且「运行在桌面端」时消费:相对路径由主进程
|
|
21
|
+
* resolveFilePath 挂到个人目录,盘符 / UNC / ~ 视为绝对。
|
|
22
|
+
* 其余场景忽略该字段,仍按 file_id 走后端接口。
|
|
23
|
+
*/
|
|
24
|
+
file_path?: string;
|
|
15
25
|
/** 其余字段原样保留 */
|
|
16
26
|
[key: string]: any;
|
|
17
27
|
}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { AiAnswerReport } from '../../answer';
|
|
2
|
+
import { StreamChunk } from '../../sse';
|
|
3
|
+
import { AnswerParser } from '../../registry';
|
|
4
|
+
import { OutputFileValue } from '../outputFile/types';
|
|
5
|
+
import { PresentFilesValue, PresentFileItem } from './types';
|
|
6
|
+
|
|
7
|
+
/** present_files 类型的历史分发键 / 实时载荷有效类型 */
|
|
8
|
+
export declare const PRESENT_FILES_ANSWER_TYPE = "present_files";
|
|
9
|
+
/**
|
|
10
|
+
* 从路径中取文件名(同时兼容 Windows 反斜杠与 posix 正斜杠)。
|
|
11
|
+
* 拿不到时退回整串,保证卡片至少有显示名。
|
|
12
|
+
* @param path 完整路径或文件名
|
|
13
|
+
* @returns 最后一段文件名
|
|
14
|
+
*/
|
|
15
|
+
export declare const basenameOf: (path: string) => string;
|
|
16
|
+
/**
|
|
17
|
+
* 把单个服务端文件条目映射成 OutputFileValue(供 output_file 渲染器复用)。
|
|
18
|
+
* - `id` → `file_id`(云端下载);
|
|
19
|
+
* - 完整路径 → `file_path`(仅「本地电脑对话 + 桌面端」消费,读本地文件 / URL 直连),
|
|
20
|
+
* 按 `file_path` → `path` → `name` 的顺序取:新版后端把文件名放 `name`、完整路径单独放 `path`,
|
|
21
|
+
* 老版后端则把完整路径直接塞进 `name`,两种形态都要能取到;
|
|
22
|
+
* - `basename(完整路径)` → `file_name`(卡片显示),显式 `file_name` 优先。
|
|
23
|
+
* @param item 服务端文件条目
|
|
24
|
+
* @returns 归一化后的文件卡片值;id / 路径 / 文件名都缺失时返回 null(过滤空条目)
|
|
25
|
+
*/
|
|
26
|
+
export declare const toOutputFileValue: (item: PresentFileItem | null | undefined) => OutputFileValue | null;
|
|
27
|
+
/**
|
|
28
|
+
* 防御性读取 present_files 载荷,兼容两种服务端形态:
|
|
29
|
+
* - 实时链路:`{ values: { files: [...], explanation? }, answer_type: 'present_files' }`;
|
|
30
|
+
* - 历史接口:`{ files: [...], explanation?, answer_type: 'present_files' }`(顶层字段)。
|
|
31
|
+
* 嵌套优先、顶层兜底;`files` 必须是数组,逐项过滤空条目后映射。
|
|
32
|
+
* @param value result chunk 载荷(或历史 report 元素)
|
|
33
|
+
* @returns 归一化后的取值结构(files 可能为空数组)
|
|
34
|
+
*/
|
|
35
|
+
export declare const readPresentFilesPayload: (value: any) => PresentFilesValue;
|
|
36
|
+
/**
|
|
37
|
+
* 处理实时流的 `result` chunk:有效类型为 `present_files` 时把载荷归一成 values
|
|
38
|
+
* 并追加为新报告。严格按有效类型门控,`files` 为空时消费但不产生空报告。
|
|
39
|
+
* @param chunk 流式数据块
|
|
40
|
+
* @param reports 回答 reports 数组(registry 预取的同一引用,push 即累积)
|
|
41
|
+
* @returns 是否消费了该 chunk:`result` 且有效类型为 `present_files` 时 true,其余 false
|
|
42
|
+
*/
|
|
43
|
+
export declare const applyPresentFilesChunk: (chunk: StreamChunk, reports: AiAnswerReport<any>[]) => boolean;
|
|
44
|
+
/**
|
|
45
|
+
* 把历史接口返回的单个 `present_files` report 元素标准化成渲染层结构。
|
|
46
|
+
* 幂等:values.files 已是归一化数组(含 file_id / file_name / file_path 语义)时跳过,
|
|
47
|
+
* 否则从顶层 / 原始 files 重新映射。缺字段不改写,不造空结构。
|
|
48
|
+
* @param report 历史 reports 中的一个 `present_files` 元素(就地修改并返回)
|
|
49
|
+
* @returns 标准化后的同一 report 引用
|
|
50
|
+
*/
|
|
51
|
+
export declare const normalizePresentFilesReport: (report: AiAnswerReport<PresentFilesValue>) => AiAnswerReport<PresentFilesValue>;
|
|
52
|
+
/**
|
|
53
|
+
* present_files 答案类型的注册表条目(registry 内置):
|
|
54
|
+
* - 实时链路:`applyChunk` 复用 `applyPresentFilesChunk`(只消费 `result`/`present_files` 载荷);
|
|
55
|
+
* - 历史链路:`answerType` 命中 `present_files` 时由 `normalizeReport` 复用
|
|
56
|
+
* `normalizePresentFilesReport` 把服务端原始形态映射成 values.files。
|
|
57
|
+
*/
|
|
58
|
+
export declare const presentFilesParser: AnswerParser<PresentFilesValue>;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { OutputFileValue } from '../outputFile/types';
|
|
2
|
+
|
|
3
|
+
/** 单个文件条目(服务端原始形态) */
|
|
4
|
+
export interface PresentFileItem {
|
|
5
|
+
/** 文件 ID:云端按此下载 */
|
|
6
|
+
id?: string;
|
|
7
|
+
/**
|
|
8
|
+
* 完整本地路径(新版后端契约):如 `C:\沙箱\user_storage\index.html`。
|
|
9
|
+
* 桌面端按此读本地文件 / 直连预览;缺省时回退读 `name`(老版把完整路径放在 name)。
|
|
10
|
+
*/
|
|
11
|
+
path?: string;
|
|
12
|
+
/** 文件名;老版后端这里放的是完整路径(两种形态都兼容,basename 用于卡片显示) */
|
|
13
|
+
name?: string;
|
|
14
|
+
/** 显式文件名(可选,优先于从路径提取的 basename) */
|
|
15
|
+
file_name?: string;
|
|
16
|
+
/** 显式本地路径别名(与 path / name 等价) */
|
|
17
|
+
file_path?: string;
|
|
18
|
+
/** 显式文件 id 别名(与 id 等价) */
|
|
19
|
+
file_id?: string;
|
|
20
|
+
}
|
|
21
|
+
/** present_files 回答归一化后的取值结构(供渲染层消费) */
|
|
22
|
+
export interface PresentFilesValue {
|
|
23
|
+
/** 归一化后的文件卡片列表(每项已是 OutputFileValue 结构) */
|
|
24
|
+
files: OutputFileValue[];
|
|
25
|
+
/** 服务端说明文案(不展示,仅保留) */
|
|
26
|
+
explanation?: string;
|
|
27
|
+
}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { AiAnswerValues } from './answer';
|
|
2
|
+
import { AnswerParser } from './registry';
|
|
3
|
+
|
|
4
|
+
/** 分析结论项 */
|
|
5
|
+
export interface AnswerConclusion {
|
|
6
|
+
/** 产出该结论的智能体标识 */
|
|
7
|
+
agent_key?: string;
|
|
8
|
+
/** 结论正文(Markdown) */
|
|
9
|
+
report?: string;
|
|
10
|
+
[key: string]: any;
|
|
11
|
+
}
|
|
12
|
+
/** 相关追问项(context_history) */
|
|
13
|
+
export interface AnswerContextHistory {
|
|
14
|
+
/** 相似度(数字字符串) */
|
|
15
|
+
ratio?: string;
|
|
16
|
+
/** 关联的历史明细 id */
|
|
17
|
+
history_id?: string;
|
|
18
|
+
/** 追问文本 */
|
|
19
|
+
question?: string;
|
|
20
|
+
[key: string]: any;
|
|
21
|
+
}
|
|
22
|
+
/** 回答级元信息视图 */
|
|
23
|
+
export interface AnswerMeta {
|
|
24
|
+
/** 评价:'1' 点赞 / '0' 点踩 / null 未评价 */
|
|
25
|
+
state: '1' | '0' | null;
|
|
26
|
+
/** 分析结论 */
|
|
27
|
+
conclusion: AnswerConclusion[];
|
|
28
|
+
/** 相关追问(已按 ratio 降序) */
|
|
29
|
+
contextHistory: AnswerContextHistory[];
|
|
30
|
+
/** 回答所属智能体 */
|
|
31
|
+
entry: {
|
|
32
|
+
id?: string;
|
|
33
|
+
title?: string;
|
|
34
|
+
} | null;
|
|
35
|
+
/** 业务错误(如 err.code === 'MESSAGE' 时 msg 直接展示给用户) */
|
|
36
|
+
err: {
|
|
37
|
+
code?: string;
|
|
38
|
+
msg?: string;
|
|
39
|
+
} | null;
|
|
40
|
+
/** 后端记录的运行耗时(毫秒) */
|
|
41
|
+
runMs: number | null;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* 读取回答级元信息(缺省字段给安全默认值)
|
|
45
|
+
* @param answerValues 回答结构
|
|
46
|
+
* @returns 元信息视图
|
|
47
|
+
*/
|
|
48
|
+
export declare const readAnswerMeta: (answerValues: AiAnswerValues | null | undefined) => AnswerMeta;
|
|
49
|
+
/**
|
|
50
|
+
* 把历史接口返回的元信息合入实时回答(reports 不动,避免覆盖实时已渲染的内容)
|
|
51
|
+
* @param target 实时累积的回答结构(就地修改)
|
|
52
|
+
* @param source get_history_answer 的 values(或含 values 的完整响应)
|
|
53
|
+
*/
|
|
54
|
+
export declare const mergeAnswerMeta: (target: AiAnswerValues, source: any) => void;
|
|
55
|
+
/**
|
|
56
|
+
* 实时 `conclusion` 帧:value 为结论数组(或单个结论对象),写入 answerValues.conclusion
|
|
57
|
+
*/
|
|
58
|
+
export declare const conclusionParser: AnswerParser;
|
|
59
|
+
/**
|
|
60
|
+
* 抽取回答中可复制的 Markdown 原文(知识流 / text / 分析结论),按出现顺序以空行拼接
|
|
61
|
+
* @param answerValues 回答结构
|
|
62
|
+
* @returns Markdown 文本(无可复制内容时为空串)
|
|
63
|
+
*/
|
|
64
|
+
export declare const collectAnswerMarkdown: (answerValues: AiAnswerValues | null | undefined) => string;
|
|
65
|
+
/**
|
|
66
|
+
* Markdown 转纯文本(复制 / 朗读用的轻量实现:去掉代码围栏、标记符号与链接语法)。
|
|
67
|
+
* 标记符号按「成对包裹」匹配(如 __加粗__、_斜体_),不会动 history_id、snake_case 里的下划线。
|
|
68
|
+
* @param markdown Markdown 原文
|
|
69
|
+
* @returns 纯文本
|
|
70
|
+
*/
|
|
71
|
+
export declare const markdownToPlainText: (markdown: string) => string;
|
|
@@ -22,6 +22,14 @@ export declare const collectDeepThinkingSteps: (report: AiAnswerReport<any>) =>
|
|
|
22
22
|
* 渲染组件只消费已算好的文本数组,不再内部拼接。
|
|
23
23
|
*/
|
|
24
24
|
export declare const collectThinkingSteps: (answerValues: AiAnswerValues) => string[];
|
|
25
|
+
/**
|
|
26
|
+
* 去掉独占一行的 `===` / `---` 分隔线。
|
|
27
|
+
* 模型在思考过程中常用这种分隔线,markdown-it 的 setext 语法会把紧邻的上一段文字整段解析成
|
|
28
|
+
* `<h1>` / `<h2>`,导致步骤里一大片文字被放大加粗。(代码块内的同形行极少见,按行清理可接受)
|
|
29
|
+
* @param text 思考步骤 markdown
|
|
30
|
+
* @returns 清理后的文本
|
|
31
|
+
*/
|
|
32
|
+
export declare const stripSetextUnderline: (text: string) => string;
|
|
25
33
|
/**
|
|
26
34
|
* 深度思考答案类型的注册表条目(registry 内置,实时链路):
|
|
27
35
|
* 历史形态与实时累积一致(exec_process 原样保留、无需归一化),
|
|
@@ -52,3 +52,12 @@ export type GroupMessagesProgress = {
|
|
|
52
52
|
* @returns 交错完整的消息列表
|
|
53
53
|
*/
|
|
54
54
|
export declare const loadGroupMessagesByStep: (api: ChatApi, historyGroupId: string, lastCount?: number, onProgress?: (progress: GroupMessagesProgress) => void, lastEnd?: number, options?: AnswerParseOptions) => Promise<Message[]>;
|
|
55
|
+
/**
|
|
56
|
+
* 加载分享页内容(/chat/get_share_chat_json):返回「提问 + 回答」两条消息(无提问时只有回答)。
|
|
57
|
+
* 分享页免登录,回答结构与 get_history_answer 的 values 同构,同样走 normalizeAnswer 归一化。
|
|
58
|
+
* @param api 业务 API(需实现 getShareChatJson)
|
|
59
|
+
* @param shareId 分享 id(分享链接 ?id= 参数)
|
|
60
|
+
* @param options 答案解析配置(自定义 parsers / beforeKnowledgeRender)
|
|
61
|
+
* @returns 消息列表;分享不存在或已过期时为空数组
|
|
62
|
+
*/
|
|
63
|
+
export declare const loadSharedMessages: (api: ChatApi, shareId: string, options?: AnswerParseOptions) => Promise<Message[]>;
|
|
@@ -3,5 +3,5 @@
|
|
|
3
3
|
*
|
|
4
4
|
* 注意:用具名 re-export 而非 export *,原因同 parser/index.ts 头注释。
|
|
5
5
|
*/
|
|
6
|
-
export { extractAttachmentsFromHistory, getHistoryGroups, createHistoryGroup, deleteHistoryGroup, setHistoryGroupTitle, loadGroupMessages, loadGroupMessagesByStep } from './history';
|
|
6
|
+
export { extractAttachmentsFromHistory, getHistoryGroups, createHistoryGroup, deleteHistoryGroup, setHistoryGroupTitle, loadGroupMessages, loadGroupMessagesByStep, loadSharedMessages } from './history';
|
|
7
7
|
export type { GroupMessagesProgress, HistoryGroup } from './history';
|
package/dist/parser/index.cjs
CHANGED
|
@@ -1,3 +1,7 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const q=()=>({answer_type:"knowledge_stream_result",values:[{answer:""}]}),G=e=>(e.answer_type="knowledge_stream_result",(!Array.isArray(e.values)||!e.values.length)&&(e.values=[{answer:""}]),e),K=(e="",t="")=>({id:e,question:t,answer:{reports:[]}}),Me=["knowledge_stream_begin","knowledge_stream","knowledge_stream_result","knowledge_stream_end"],I=(e,t,n,r)=>{var u;if(!e.mode||!Me.includes(e.mode))return!1;if(e.mode==="knowledge_stream_result"||e.mode==="knowledge_stream_end")return!0;const o=r==null?void 0:r.beforeKnowledgeRender,s=l=>o?o(l):l;if(e.mode==="knowledge_stream_begin"){const l=t.at(-1);return(l==null?void 0:l.answer_type)==="knowledge_stream_result"?(l.values=l.values??[],l.values.push({answer:""}),!0):l&&!l.answer_type?(G(l),!0):(t.push(q()),!0)}if(e.mode!=="knowledge_stream")return!1;let i=t.at(-1);i&&!i.answer_type?i=G(i):(!i||i.answer_type!=="knowledge_stream_result")&&(i=q(),t.push(i)),i.values=(u=i.values)!=null&&u.length?i.values:[{answer:""}];const a=i.values[i.values.length-1],c=`${a.raw??""}${e.value||""}`;return a.raw=c,a.answer=s(c),!0},V=(e,t)=>{if(Array.isArray(e.values)&&e.values.length)return e;const n=t==null?void 0:t.beforeKnowledgeRender,r=s=>n?n(s):s;let o=[];return Array.isArray(e.knowledge)&&(o=e.knowledge.map(s=>typeof s=="string"?s:s==null?void 0:s.answer).filter(s=>typeof s=="string"&&s!=="")),o.length===0&&typeof e.answer=="string"&&e.answer!==""&&(o=[e.answer]),o.length&&(e.values=o.map(s=>({answer:r(s),raw:s}))),e},J={id:"knowledge_stream",answerType:"knowledge_stream_result",applyChunk:I,normalizeReport:V},Z=["begin","begin_stream","send_stream","end_stream"],F=(e,t)=>{if(!Z.includes(e.mode||""))return!1;let n=t.at(-1);return(!n||n.answer_type)&&(n={exec_process:[]},t.push(n)),n.exec_process=n.exec_process??[],n.exec_process.push({mode:e.mode,type:e.type,value:e.value}),!0},Q=e=>{const t=[];let n="",r=!1;for(const o of(e.exec_process??[]).filter(s=>Z.includes(s.mode||""))){const s=typeof o.value=="string"?o.value:"";o.mode==="begin"?(r&&n.trim()&&t.push(n.trim()),r=!1,n="",s.trim()&&t.push(s.trim())):o.mode==="begin_stream"?(r&&n.trim()&&t.push(n.trim()),r=!0,n=s):o.mode==="send_stream"&&r?n+=s:o.mode==="end_stream"&&r&&(n+=s,n.trim()&&t.push(n.trim()),r=!1,n="")}return r&&n.trim()&&t.push(n.trim()),t},$=e=>{var t;return(((t=e.answer)==null?void 0:t.reports)??[]).flatMap(Q)},ee={id:"deep_thinking",applyChunk:F},te='/**\n * Skipped minification because the original files appears to be already minified.\n * Original file: /npm/@iframe-resizer/child@5.1.5/index.umd.js\n *\n * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files\n */\n/*!\n * @preserve\n * \n * @module iframe-resizer/child 5.1.5 (umd) - 2024-07-09\n *\n * @license GPL-3.0 for non-commercial use only.\n * For commercial use, you must purchase a license from\n * https://iframe-resizer.com/pricing\n * \n * @desciption Keep same and cross domain iFrames sized to their content \n *\n * @author David J. Bradshaw <info@iframe-resizer.com>\n * \n * @see {@link https://iframe-resizer.com}\n * \n * @copyright (c) 2013 - 2024, David J. Bradshaw. All rights reserved.\n */\n\n\n!function(e){"function"==typeof define&&define.amd?define(e):e()}((function(){"use strict";const e="5.1.5",t=10,n="data-iframe-size",o=(e,t,n,o)=>e.addEventListener(t,n,o||!1),i=(e,t,n)=>e.removeEventListener(t,n,!1),r=["<iy><yi>Puchspk Spjluzl Rlf</><iy><iy>","<iy><yi>Tpzzpun Spjluzl Rlf</><iy><iy>","Aopz spiyhyf pz hchpshisl dpao ivao Jvttlyjphs huk Vwlu-Zvbyjl spjluzlz.<iy><iy><i>Jvttlyjphs Spjluzl</><iy>Mvy jvttlyjphs bzl, <p>pmyhtl-ylzpgly</> ylxbpylz h svd jvza vul aptl spjluzl mll. Mvy tvyl pumvythapvu cpzpa <b>oaawz://pmyhtl-ylzpgly.jvt/wypjpun</>.<iy><iy><i>Vwlu Zvbyjl Spjluzl</><iy>Pm fvb hyl bzpun aopz spiyhyf pu h uvu-jvttlyjphs vwlu zvbyjl wyvqlja aolu fvb jhu bzl pa mvy myll bukly aol alytz vm aol NWS C3 Spjluzl. Av jvumpyt fvb hjjlwa aolzl alytz, wslhzl zla aol <i>spjluzl</> rlf pu <p>pmyhtl-ylzpgly</> vwapvuz av <i>NWSc3</>.<iy><iy>Mvy tvyl pumvythapvu wslhzl zll: <b>oaawz://pmyhtl-ylzpgly.jvt/nws</>","<i>NWSc3 Spjluzl Clyzpvu</><iy><iy>Aopz clyzpvu vm <p>pmyhtl-ylzpgly</> pz ilpun bzlk bukly aol alytz vm aol <i>NWS C3</> spjluzl. Aopz spjluzl hssvdz fvb av bzl <p>pmyhtl-ylzpgly</> pu Vwlu Zvbyjl wyvqljaz, iba pa ylxbpylz fvby wyvqlja av il wbispj, wyvcpkl haaypibapvu huk il spjluzlk bukly clyzpvu 3 vy shaly vm aol NUB Nlulyhs Wbispj Spjluzl.<iy><iy>Pm fvb hyl bzpun aopz spiyhyf pu h uvu-vwlu zvbyjl wyvqlja vy dlizpal, fvb dpss ullk av wbyjohzl h svd jvza vul aptl jvttlyjphs spjluzl.<iy><iy>Mvy tvyl pumvythapvu cpzpa <b>oaawz://pmyhtl-ylzpgly.jvt/wypjpun</>."];Object.fromEntries(["2cgs7fdf4xb","1c9ctcccr4z","1q2pc4eebgb","ueokt0969w","w2zxchhgqz","1umuxblj2e5"].map(((e,t)=>[e,Math.max(0,t-1)])));const a=e=>(e=>e.replaceAll(/[A-Za-z]/g,(e=>String.fromCodePoint((e<="Z"?90:122)>=(e=e.codePointAt(0)+19)?e:e-26))))(r[e]),l={contentVisibilityAuto:!0,opacityProperty:!0,visibilityProperty:!0},c={height:()=>(de("Custom height calculation function not defined"),He.auto()),width:()=>(de("Custom width calculation function not defined"),Ue.auto())},s={bodyOffset:1,bodyScroll:1,offset:1,documentElementOffset:1,documentElementScroll:1,documentElementBoundingClientRect:1,max:1,min:1,grow:1,lowestElement:1},u=128,d={},m="checkVisibility"in window,f="auto",p="[iFrameSizer]",h=p.length,y={max:1,min:1,bodyScroll:1,documentElementScroll:1},g=["body"],v="scroll";let b,w,z=!0,S="",$=0,j="",E=null,P="",O=!0,M=!1,A=null,C=!0,T=!1,k=1,I=f,x=!0,N="",R={},B=!0,q=!1,L=0,W=!1,D="",H="child",U=null,F=!1,V="",J=window.parent,Z="*",Q=0,X=!1,Y="",G=1,K=v,_=window,ee=()=>{de("onMessage function not defined")},te=()=>{},ne=null,oe=null;const ie=e=>""!=`${e}`&&void 0!==e,re=new WeakSet,ae=e=>"object"==typeof e&&re.add(e);function le(e){switch(!0){case!ie(e):return"";case ie(e.id):return`${e.nodeName.toUpperCase()}#${e.id}`;case ie(e.name):return`${e.nodeName.toUpperCase()} (${e.name})`;default:return e.nodeName.toUpperCase()+(ie(e.className)?`.${e.className}`:"")}}function ce(e,t=30){const n=e?.outerHTML?.toString();return n?n.length<t?n:`${n.slice(0,t).replaceAll("\\n"," ")}...`:e}const se=(...e)=>[`[iframe-resizer][${D}]`,...e].join(" "),ue=(...e)=>console?.info(se(...e)),de=(...e)=>console?.warn(se(...e)),me=(...e)=>console?.warn((e=>t=>window.chrome?e(t.replaceAll("<br>","\\n").replaceAll("<rb>","\x1B[31;1m").replaceAll("</>","\x1B[m").replaceAll("<b>","\x1B[1m").replaceAll("<i>","\x1B[3m").replaceAll("<u>","\x1B[4m")):e(t.replaceAll("<br>","\\n").replaceAll(/<[/a-z]+>/gi,"")))(se)(...e)),fe=e=>me(e);function pe(){!function(){try{F="iframeParentListener"in window.parent}catch(e){}}(),function(){const e=e=>"true"===e,t=N.slice(h).split(":");D=t[0],$=void 0===t[1]?$:Number(t[1]),M=void 0===t[2]?M:e(t[2]),q=void 0===t[3]?q:e(t[3]),z=void 0===t[6]?z:e(t[6]),j=t[7],I=void 0===t[8]?I:t[8],S=t[9],P=t[10],Q=void 0===t[11]?Q:Number(t[11]),R.enable=void 0!==t[12]&&e(t[12]),H=void 0===t[13]?H:t[13],K=void 0===t[14]?K:t[14],W=void 0===t[15]?W:e(t[15]),b=void 0===t[16]?b:Number(t[16]),w=void 0===t[17]?w:Number(t[17]),O=void 0===t[18]?O:e(t[18]),t[19],Y=t[20]||Y,L=void 0===t[21]?L:Number(t[21])}(),function(){function e(){const e=window.iframeResizer||window.iFrameResizer;ee=e?.onMessage||ee,te=e?.onReady||te,"number"==typeof e?.offset&&(O&&(b=e?.offset),M&&(w=e?.offset)),Object.prototype.hasOwnProperty.call(e,"sizeSelector")&&(V=e.sizeSelector),Z=e?.targetOrigin||Z,I=e?.heightCalculationMethod||I,K=e?.widthCalculationMethod||K}function t(e,t){return"function"==typeof e&&(c[t]=e,e="custom"),e}if(1===L)return;"iFrameResizer"in window&&Object===window.iFrameResizer.constructor&&(e(),I=t(I,"height"),K=t(K,"width"))}(),function(){void 0===j&&(j=`${$}px`);he("margin",function(e,t){t.includes("-")&&(de(`Negative CSS value ignored for ${e}`),t="");return t}("margin",j))}(),he("background",S),he("padding",P),function(){const e=document.createElement("div");e.style.clear="both",e.style.display="block",e.style.height="0",document.body.append(e)}(),function(){const e=e=>e.style.setProperty("height","auto","important");e(document.documentElement),e(document.body)}(),ye(),L<0?fe(`${a(L+2)}${a(2)}`):Y.codePointAt(0)>4||L<2&&fe(a(3)),function(){if(!Y||""===Y||"false"===Y)return void me("<rb>Legacy version detected on parent page</>\\n\\nDetected legacy version of parent page script. It is recommended to update the parent page to use <b>@iframe-resizer/parent</>.\\n\\nSee <u>https://iframe-resizer.com/setup/</> for more details.\\n");Y!==e&&me(`<rb>Version mismatch</>\\n\\nThe parent and child pages are running different versions of <i>iframe resizer</>.\\n\\nParent page: ${Y} - Child page: ${e}.\\n`)}(),ze(),Se(),function(){let e=!1;const t=t=>document.querySelectorAll(`[${t}]`).forEach((o=>{e=!0,o.removeAttribute(t),o.setAttribute(n,null)}));t("data-iframe-height"),t("data-iframe-width"),e&&me("<rb>Deprecated Attributes</>\\n \\nThe <b>data-iframe-height</> and <b>data-iframe-width</> attributes have been deprecated and replaced with the single <b>data-iframe-size</> attribute. Use of the old attributes will be removed in a future version of <i>iframe-resizer</>.")}(),document.querySelectorAll(`[${n}]`).length>0&&("auto"===I&&(I="autoOverflow"),"auto"===K&&(K="autoOverflow")),be(),function(){if(1===L)return;_.parentIframe=Object.freeze({autoResize:e=>(!0===e&&!1===z?(z=!0,$e()):!1===e&&!0===z&&(z=!1,ve("remove"),U?.disconnect(),E?.disconnect()),Xe(0,0,"autoResize",JSON.stringify(z)),z),close(){Xe(0,0,"close")},getId:()=>D,getPageInfo(e){if("function"==typeof e)return ne=e,Xe(0,0,"pageInfo"),void me("<rb>Deprecated Method</>\\n \\nThe <b>getPageInfo()</> method has been deprecated and replaced with <b>getParentProps()</>. Use of this method will be removed in a future version of <i>iframe-resizer</>.\\n");ne=null,Xe(0,0,"pageInfoStop")},getParentProps(e){if("function"!=typeof e)throw new TypeError("parentIFrame.getParentProps(callback) callback not a function");return oe=e,Xe(0,0,"parentInfo"),()=>{oe=null,Xe(0,0,"parentInfoStop")}},getParentProperties(e){me("<rb>Renamed Method</>\\n \\nThe <b>getParentProperties()</> method has been renamed <b>getParentProps()</>. Use of the old name will be removed in a future version of <i>iframe-resizer</>.\\n"),this.getParentProps(e)},moveToAnchor(e){R.findTarget(e)},reset(){Qe()},scrollBy(e,t){Xe(t,e,"scrollBy")},scrollTo(e,t){Xe(t,e,"scrollTo")},scrollToOffset(e,t){Xe(t,e,"scrollToOffset")},sendMessage(e,t){Xe(0,0,"message",JSON.stringify(e),t)},setHeightCalculationMethod(e){I=e,ze()},setWidthCalculationMethod(e){K=e,Se()},setTargetOrigin(e){Z=e},resize(e,t){Ve("size",`parentIFrame.size(${`${e||""}${t?`,${t}`:""}`})`,e,t)},size(e,t){me("<rb>Deprecated Method</>\\n \\nThe <b>size()</> method has been deprecated and replaced with <b>resize()</>. Use of this method will be removed in a future version of <i>iframe-resizer</>.\\n"),this.resize(e,t)}}),_.parentIFrame=_.parentIframe}(),function(){if(!0!==W)return;function e(e){Xe(0,0,e.type,`${e.screenY}:${e.screenX}`)}function t(t,n){o(window.document,t,e)}t("mouseenter"),t("mouseleave")}(),$e(),R=function(){const e=()=>({x:document.documentElement.scrollLeft,y:document.documentElement.scrollTop});function n(n){const o=n.getBoundingClientRect(),i=e();return{x:parseInt(o.left,t)+parseInt(i.x,t),y:parseInt(o.top,t)+parseInt(i.y,t)}}function i(e){function t(e){const t=n(e);Xe(t.y,t.x,"scrollToOffset")}const o=e.split("#")[1]||e,i=decodeURIComponent(o),r=document.getElementById(i)||document.getElementsByName(i)[0];void 0===r?Xe(0,0,"inPageLink",`#${o}`):t(r)}function r(){const{hash:e,href:t}=window.location;""!==e&&"#"!==e&&i(t)}function a(){function e(e){function t(e){e.preventDefault(),i(this.getAttribute("href"))}"#"!==e.getAttribute("href")&&o(e,"click",t)}document.querySelectorAll(\'a[href^="#"]\').forEach(e)}function l(){o(window,"hashchange",r)}function c(){setTimeout(r,u)}function s(){a(),l(),c()}R.enable&&(1===L?me("In page linking requires a Professional or Business license. Please see https://iframe-resizer.com/pricing for more details."):s());return{findTarget:i}}(),ae(document.documentElement),ae(document.body),Ve("init","Init message from host page",void 0,void 0,e),document.title&&""!==document.title&&Xe(0,0,"title",document.title),te(),B=!1}function he(e,t){void 0!==t&&""!==t&&"null"!==t&&document.body.style.setProperty(e,t)}function ye(){""!==V&&document.querySelectorAll(V).forEach((e=>{e.dataset.iframeSize=!0}))}function ge(e){({add(t){function n(){Ve(e.eventName,e.eventType)}d[t]=n,o(window,t,n,{passive:!0})},remove(e){const t=d[e];delete d[e],i(window,e,t)}})[e.method](e.eventName)}function ve(e){ge({method:e,eventType:"After Print",eventName:"afterprint"}),ge({method:e,eventType:"Before Print",eventName:"beforeprint"}),ge({method:e,eventType:"Ready State Change",eventName:"readystatechange"})}function be(){const e=document.querySelectorAll(`[${n}]`);T=e.length>0,A=T?e:Re(document)()}function we(e,t,n,o){return t!==e&&(e in n||(de(`${e} is not a valid option for ${o}CalculationMethod.`),e=t),e in s&&me(`<rb>Deprecated ${o}CalculationMethod (${e})</>\\n\\nThis version of <i>iframe-resizer</> can auto detect the most suitable ${o} calculation method. It is recommended that you remove this option.`)),e}function ze(){I=we(I,f,He,"height")}function Se(){K=we(K,v,Ue,"width")}function $e(){!0===z&&(ve("add"),E=function(){function e(e){e.forEach(Te),ye(),be()}function t(){const t=new window.MutationObserver(e),n=document.querySelector("body"),o={attributes:!1,attributeOldValue:!1,characterData:!1,characterDataOldValue:!1,childList:!0,subtree:!0};return t.observe(n,o),t}const n=t();return{disconnect(){n.disconnect()}}}(),U=new ResizeObserver(Ee),Ce(window.document))}let je;function Ee(e){if(!Array.isArray(e)||0===e.length)return;const t=e[0].target;je=()=>Ve("resizeObserver",`Resize Observed: ${le(t)}`),setTimeout((()=>{je&&je(),je=void 0}),0)}const Pe=e=>{const t=getComputedStyle(e);return""!==t?.position&&"static"!==t?.position},Oe=()=>[...Re(document)()].filter(Pe),Me=new WeakSet;function Ae(e){e&&(Me.has(e)||(U.observe(e),Me.add(e)))}function Ce(e){[...Oe(),...g.flatMap((t=>e.querySelector(t)))].forEach(Ae)}function Te(e){"childList"===e.type&&Ce(e.target)}let ke=4,Ie=4;function xe(e){const t=(n=e).charAt(0).toUpperCase()+n.slice(1);var n;let o=0,i=A.length,r=document.documentElement,a=T?0:document.documentElement.getBoundingClientRect().bottom,c=performance.now();var s;A.forEach((t=>{T||!m||t.checkVisibility(l)?(o=t.getBoundingClientRect()[e]+parseFloat(getComputedStyle(t).getPropertyValue(`margin-${e}`)),o>a&&(a=o,r=t)):i-=1})),c=performance.now()-c,i>1&&(s=r,re.has(s)||(ae(s),ue(`\\nHeight calculated from: ${le(s)} (${ce(s)})`)));const u=`\\nParsed ${i} element${1===i?"":"s"} in ${c.toPrecision(3)}ms\\n${t} ${T?"tagged ":""}element found at: ${a}px\\nPosition calculated from HTML element: ${le(r)} (${ce(r,100)})`;return c<4||i<99||T||B||ke<c&&ke<Ie&&(ke=1.2*c,me(`<rb>Performance Warning</>\\n\\nCalculating the page size took an excessive amount of time. To improve performance add the <b>data-iframe-size</> attribute to the ${e} most element on the page.\\n${u}`)),Ie=c,a}const Ne=e=>[e.bodyOffset(),e.bodyScroll(),e.documentElementOffset(),e.documentElementScroll(),e.documentElementBoundingClientRect()],Re=e=>()=>e.querySelectorAll("* :not(head):not(meta):not(base):not(title):not(script):not(link):not(style):not(map):not(area):not(option):not(optgroup):not(template):not(track):not(wbr):not(nobr)");let Be=!1;function qe({ceilBoundingSize:e,dimension:t,getDimension:n,isHeight:o,scrollSize:i}){if(!Be)return Be=!0,n.taggedElement();const r=o?"bottom":"right";return me(`<rb>Detected content overflowing html element</>\\n \\nThis causes <i>iframe-resizer</> to fall back to checking the position of every element on the page in order to calculate the correct dimensions of the iframe. Inspecting the size, ${r} margin, and position of every visible HTML element will have a performance impact on more complex pages. \\n\\nTo fix this issue, and remove this warning, you can either ensure the content of the page does not overflow the <b><HTML></> element or alternatively you can add the attribute <b>data-iframe-size</> to the elements on the page that you want <i>iframe-resizer</> to use when calculating the dimensions of the iframe. \\n \\nWhen present the ${r} margin of the ${o?"lowest":"right most"} element with a <b>data-iframe-size</> attribute will be used to set the ${t} of the iframe.\\n\\nMore info: https://iframe-resizer.com/performance.\\n\\n(Page size: ${i} > document size: ${e})`),o?I="autoOverflow":K="autoOverflow",n.taggedElement()}const Le={height:0,width:0},We={height:0,width:0};function De(e,t){function n(){return We[i]=r,Le[i]=c,r}const o=e===He,i=o?"height":"width",r=e.documentElementBoundingClientRect(),a=Math.ceil(r),l=Math.floor(r),c=(e=>e.documentElementScroll()+Math.max(0,e.getOffset()))(e);switch(!0){case!e.enabled():return c;case!t&&0===We[i]&&0===Le[i]:if(e.taggedElement(!0)<=a)return n();break;case X&&r===We[i]&&c===Le[i]:return Math.max(r,c);case 0===r:return c;case!t&&r!==We[i]&&c<=Le[i]:return n();case!o:return t?e.taggedElement():qe({ceilBoundingSize:a,dimension:i,getDimension:e,isHeight:o,scrollSize:c});case!t&&r<We[i]:case c===l||c===a:case r>c:return n();case!t:return qe({ceilBoundingSize:a,dimension:i,getDimension:e,isHeight:o,scrollSize:c})}return Math.max(e.taggedElement(),n())}const He={enabled:()=>O,getOffset:()=>b,type:"height",auto:()=>De(He,!1),autoOverflow:()=>De(He,!0),bodyOffset:()=>{const{body:e}=document,n=getComputedStyle(e);return e.offsetHeight+parseInt(n.marginTop,t)+parseInt(n.marginBottom,t)},bodyScroll:()=>document.body.scrollHeight,offset:()=>He.bodyOffset(),custom:()=>c.height(),documentElementOffset:()=>document.documentElement.offsetHeight,documentElementScroll:()=>document.documentElement.scrollHeight,documentElementBoundingClientRect:()=>document.documentElement.getBoundingClientRect().bottom,max:()=>Math.max(...Ne(He)),min:()=>Math.min(...Ne(He)),grow:()=>He.max(),lowestElement:()=>xe("bottom"),taggedElement:()=>xe("bottom")},Ue={enabled:()=>M,getOffset:()=>w,type:"width",auto:()=>De(Ue,!1),autoOverflow:()=>De(Ue,!0),bodyScroll:()=>document.body.scrollWidth,bodyOffset:()=>document.body.offsetWidth,custom:()=>c.width(),documentElementScroll:()=>document.documentElement.scrollWidth,documentElementOffset:()=>document.documentElement.offsetWidth,documentElementBoundingClientRect:()=>document.documentElement.getBoundingClientRect().right,max:()=>Math.max(...Ne(Ue)),min:()=>Math.min(...Ne(Ue)),rightMostElement:()=>xe("right"),scroll:()=>Math.max(Ue.bodyScroll(),Ue.documentElementScroll()),taggedElement:()=>xe("right")};function Fe(e,t,n,o,i){let r,a;!function(){const e=(e,t)=>!(Math.abs(e-t)<=Q);return r=void 0===n?He[I]():n,a=void 0===o?Ue[K]():o,O&&e(k,r)||M&&e(G,a)}()&&"init"!==e?!(e in{init:1,size:1})&&(O&&I in y||M&&K in y)&&Qe():(Je(),k=r,G=a,Xe(k,G,e,i))}function Ve(e,t,n,o,i){document.hidden||Fe(e,0,n,o,i)}function Je(){X||(X=!0,requestAnimationFrame((()=>{X=!1})))}function Ze(e){k=He[I](),G=Ue[K](),Xe(k,G,e)}function Qe(e){const t=I;I=f,Je(),Ze("reset"),I=t}function Xe(e,t,n,o,i){L<-1||(void 0!==i||(i=Z),function(){const r=`${D}:${`${e+(b||0)}:${t+(w||0)}`}:${n}${void 0===o?"":`:${o}`}`;F?window.parent.iframeParentListener(p+r):J.postMessage(p+r,i)}())}function Ye(e){const t={init:function(){N=e.data,J=e.source,pe(),C=!1,setTimeout((()=>{x=!1}),u)},reset(){x||Ze("resetPage")},resize(){Ve("resizeParent")},moveToAnchor(){R.findTarget(o())},inPageLink(){this.moveToAnchor()},pageInfo(){const e=o();ne?ne(JSON.parse(e)):Xe(0,0,"pageInfoStop")},parentInfo(){const e=o();oe?oe(Object.freeze(JSON.parse(e))):Xe(0,0,"parentInfoStop")},message(){const e=o();ee(JSON.parse(e))}},n=()=>e.data.split("]")[1].split(":")[0],o=()=>e.data.slice(e.data.indexOf(":")+1),i=()=>"iframeResize"in window||void 0!==window.jQuery&&""in window.jQuery.prototype,r=()=>e.data.split(":")[2]in{true:1,false:1};p===`${e.data}`.slice(0,h)&&(!1!==C?r()&&t.init():function(){const o=n();o in t?t[o]():i()||r()||de(`Unexpected message (${e.data})`)}())}function Ge(){"loading"!==document.readyState&&window.parent.postMessage("[iFrameResizerChild]Ready","*")}"undefined"!=typeof window&&(window.iframeChildListener=e=>Ye({data:e,sameDomain:!0}),o(window,"message",Ye),o(window,"readystatechange",Ge),Ge())}));\n',Ne="iframe-resizer/child 5.1.5",He=te,C=`<script>${te}<\/script>`,Le=e=>!e||typeof e!="object"?"":String(e.type||e.answer_type||""),ne=e=>{if(!e||typeof e!="object")return{};const t=e.values,n=s=>{const i=t&&typeof t=="object"?t[s]:void 0;if(typeof i=="string"&&i)return i;const a=e[s];return typeof a=="string"&&a?a:void 0},r=n("url"),o=n("srcdoc");return{...r?{url:r}:{},...o?{srcdoc:o}:{}}},j=e=>e&&(e.includes("</head>")?e.replace("</head>",`${C}</head>`):e.includes("<body")?e.replace("<body",`${C}<body`):C+e),De=e=>!e||typeof e!="object"||Array.isArray(e)||!e.url&&!e.srcdoc?!1:!e.srcdoc||e.srcdoc.includes(Ne),re=(e,t)=>{if(e.mode!=="result"||Le(e.value)!=="url")return!1;const n=ne(e.value);return!n.url&&!n.srcdoc||(n.srcdoc&&(n.srcdoc=j(n.srcdoc)),t.push({answer_type:"url",values:n})),!0},oe=e=>{if(De(e.values))return e;const t=ne(e);return!t.url&&!t.srcdoc||(t.srcdoc&&(t.srcdoc=j(t.srcdoc)),e.values=t),e},se={id:"iframe_page",answerType:"url",applyChunk:re,normalizeReport:oe},z="recordset",Be=["cols","values","chart","title","max_cols","parent_link_col","agent_key"],Ue=e=>!e||typeof e!="object"?"":String(e.type||e.answer_type||""),E=e=>!!e&&typeof e=="object"&&!Array.isArray(e)&&(Array.isArray(e.cols)||Array.isArray(e.values)),ie=e=>{if(!e||typeof e!="object"||Array.isArray(e))return;const t=e.values;if(E(t))return t;if(E(e))return e},ae=(e,t)=>{if(e.mode!=="result"||Ue(e.value)!==z)return!1;const n=ie(e.value);return n&&t.push({answer_type:z,values:n}),!0},ce=e=>{if(E(e.values))return e;const t=e;if(!E(t))return e;const n={};for(const r of Be)n[r]=t[r];return e.values=n,e},le={id:"recordset",answerType:z,applyChunk:ae,normalizeReport:ce},w="output_file",We=e=>!e||typeof e!="object"?"":String(e.type||e.answer_type||""),_=(e,t)=>{if(!e||typeof e!="object")return;const n=e[t];return typeof n=="string"&&n?n:void 0},P=e=>{if(!e||typeof e!="object")return{};const t=e.values&&typeof e.values=="object"?e.values:void 0,n=_(t,"file_id")??_(e,"file_id"),r=_(t,"file_name")??_(e,"file_name");return{...n?{file_id:n}:{},...r?{file_name:r}:{}}},ue=(e,t)=>{if(e.mode!=="result"||We(e.value)!==w)return!1;const n=P(e.value);return!n.file_id&&!n.file_name||t.push({answer_type:w,values:n}),!0},de=e=>{const t=P(e);if(!t.file_id&&!t.file_name)return e;const n=e.values&&typeof e.values=="object"&&!Array.isArray(e.values)?e.values:{};return(!t.file_id||n.file_id)&&(!t.file_name||n.file_name)||(e.values={...n,...t}),e},fe={id:w,answerType:w,applyChunk:ue,normalizeReport:de},h=e=>({success:!1,message:e,data:null}),qe=e=>{if(typeof e!="string")return e;try{return JSON.parse(e)}catch{throw new Error("执行指令不是合法的 JSON")}},me=e=>{const t=qe(e);if(!t||typeof t!="object")throw new Error("执行指令格式无效");const{type:n,executor:r,action:o}=t;if(n!=="action_execute")throw new Error(`不支持的指令类型:${String(n??"")}`);if(r!=="host"&&r!=="agent")throw new Error(`不支持的执行端:${String(r??"")}`);if(!o||typeof o!="object"||typeof o.name!="string"||!o.name.trim())throw new Error("执行指令缺少合法的 action.name");if(!o.arguments||typeof o.arguments!="object"||Array.isArray(o.arguments))throw new Error("执行指令的 action.arguments 必须是对象");return{type:n,executor:r,action:{name:o.name,arguments:o.arguments}}},pe=(e,t="执行端未返回有效的执行结果")=>{if(!e||typeof e!="object")return h(t);const n=e;return typeof n.success!="boolean"?h("执行端返回的 success 必须是布尔值"):{success:n.success,message:typeof n.message=="string"?n.message:n.success?"操作成功":"操作失败",data:Object.prototype.hasOwnProperty.call(n,"data")?n.data??null:null}},Ge=e=>{if(e&&typeof e=="object"){const t=e;if(typeof t.success=="boolean")return e;if(t.json_ok===!0)return{success:!0,message:"操作成功",data:e};if(t.json_ok===!1)return{success:!1,message:typeof t.error=="string"?t.error:"操作失败",data:e}}return h("系统操作返回了无法识别的报文帧")},Xe=e=>({name:e.name,arguments:e.arguments}),Ye=e=>typeof e.reply_id=="string"||typeof e.reply_id=="number"?e.reply_id:void 0,k=e=>{if((e==null?void 0:e.mode)!=="front_reply")return{kind:"ignored"};const t=Ye(e),n=e.values??e.value;let r=n;if(typeof n=="string")try{r=JSON.parse(n)}catch{return{kind:"ignored"}}if(!r||typeof r!="object"||Array.isArray(r)||r.type!=="action_execute")return{kind:"ignored"};try{return{kind:"ok",replyId:t,command:me(r)}}catch(o){return{kind:"invalid",replyId:t,error:o instanceof Error?o:new Error("执行指令解析失败")}}},Ke=["single_select","multi_select","date","text"],y=new Map;let X=0;const b=e=>!!e&&typeof e=="object"&&!Array.isArray(e),g=e=>typeof e=="string"&&e.trim()?e:void 0,Ve=(e,t)=>{if(!Array.isArray(e)||e.length===0)throw new Error(`确认项 ${t} 缺少可选项`);return e.map((n,r)=>{if(!b(n)||typeof n.label!="string"||!n.label.trim())throw new Error(`确认项 ${t} 的第 ${r+1} 个选项格式无效`);if(!Object.prototype.hasOwnProperty.call(n,"value"))throw new Error(`确认项 ${t} 的第 ${r+1} 个选项缺少 value`);return{label:n.label,value:n.value}})},Je=e=>{if(e===void 0)return;if(!b(e))throw new Error("确认项的 binding 必须是对象");const t={};return typeof e.actionIndex=="number"&&(t.actionIndex=e.actionIndex),typeof e.actionName=="string"&&(t.actionName=e.actionName),typeof e.parameterPath=="string"&&(t.parameterPath=e.parameterPath),t},Ze=(e,t)=>{if(!b(e)||!Ke.includes(e.type))throw new Error(`确认项 ${t} 的 input.type 无效`);const n=e.type,r={type:n,placeholder:g(e.placeholder)};if((n==="single_select"||n==="multi_select")&&(r.options=Ve(e.options,t)),n==="date"){if(e.format!==void 0&&e.format!=="YYYY-MM-DD")throw new Error(`确认项 ${t} 暂不支持日期格式 ${String(e.format)}`);r.format="YYYY-MM-DD"}if(e.textInput!==void 0){if(!b(e.textInput))throw new Error(`确认项 ${t} 的 textInput 必须是对象`);r.textInput={placeholder:g(e.textInput.placeholder)}}return r},ye=e=>{if(!Array.isArray(e.items)||e.items.length===0)throw new Error("collect_clarifications 至少需要一个确认项");const t=new Set,n=e.items.map((r,o)=>{if(!b(r))throw new Error(`第 ${o+1} 个确认项格式无效`);const s=typeof r.id=="string"?r.id.trim():"",i=typeof r.question=="string"?r.question.trim():"";if(!s)throw new Error(`第 ${o+1} 个确认项缺少 id`);if(t.has(s))throw new Error(`确认项 id 重复:${s}`);if(!i)throw new Error(`确认项 ${s} 缺少 question`);return t.add(s),{id:s,question:i,description:g(r.description),required:r.required!==!1,default:r.default,binding:Je(r.binding),input:Ze(r.input,s)}});return{title:g(e.title)??"需要你确认几项信息",description:g(e.description)??"请补充以下信息,我会据此继续完成操作。",items:n}},he=e=>e!==void 0?String(e):(X+=1,`clarification-${Date.now()}-${X}`),ge=e=>{y.set(e.reportId,e)},Fe=e=>y.has(e),O=(e,t)=>{const n=e.reports.findIndex(r=>{var o;return((o=r.values)==null?void 0:o.requestId)===e.reportId});n<0||e.reports.splice(n,1,{...e.reports[n],values:{...e.reports[n].values,...t}})},we=(e,t)=>{var n;if(!e.reply)return!1;try{return e.reply({type:"wait_reply",reply_id:e.replyId,values:t})!==!1}catch(r){return(n=e.onError)==null||n.call(e,r),!1}},Qe=(e,t)=>{const n=y.get(e);if(!n)return!1;y.delete(e);const r=we(n,{success:!0,message:"用户已提交补充信息",data:{answers:t}});return O(n,{status:"submitted",resultMessage:r?"补充信息已提交":"补充信息已提交,但结果回传失败(连接已关闭)",answers:t}),!0},et=e=>{const t=y.get(e);if(!t)return!1;y.delete(e);const n=we(t,{success:!1,message:"用户取消了补充信息",data:null});return O(t,{status:"cancelled",resultMessage:n?"已取消补充信息":"已取消补充信息,但结果回传失败(连接已关闭)"}),!0},tt=()=>{y.forEach(e=>{O(e,{status:"expired",resultMessage:"本次补充信息已失效(回答已结束)"})}),y.clear()},be=(e,t,n)=>{var r;if(!(e!=null&&e.reply))return!1;try{const o={type:"wait_reply",reply_id:t,values:n};return e.reply(o)!==!1}catch(o){return(r=e.onError)==null||r.call(e,o),!1}},ve=(e,t,n)=>{be(e,t,h(n))},x="collect_clarifications",_e=(e,t,n,r)=>{var m;const o=k(e);if(o.kind!=="ok")return!1;const{command:s,replyId:i}=o;if(s.executor!=="agent"||s.action.name!=="collect_clarifications")return!1;const a=r==null?void 0:r.actionExecute;let c;try{c=ye(s.action.arguments)}catch(d){return(m=a==null?void 0:a.onError)==null||m.call(a,d),ve(a,i,d instanceof Error?d.message:"确认项参数无效"),!0}const u=he(i),l={requestId:u,...c,status:"pending",resultMessage:""};return ge({reportId:u,replyId:i,reports:t,reply:a==null?void 0:a.reply,onError:a==null?void 0:a.onError}),t.push({answer_type:x,values:l}),!0},ze=e=>{const t=e.values;!t||typeof t!="object"||t.status==="pending"&&(t.status="expired",t.resultMessage="本次补充信息已失效(回答已结束)")},Ee={id:"collect_clarifications",answerType:x,applyChunk:_e,normalizeReport:ze},S="host_action";let Y=0;const nt=e=>e!==void 0?String(e):(Y+=1,`host-action-${Date.now()}-${Y}`),rt=(e,t,n)=>{const r=e.findIndex(o=>{var s;return o.answer_type===S&&((s=o.values)==null?void 0:s.id)===t});r<0||e.splice(r,1,{...e[r],values:{...e[r].values,...n}})},ot=async(e,t,n,r,o)=>{var i,a;let s;if(!(o!=null&&o.execute))s=h(`宿主未注入执行器,无法执行:${e.name}`);else try{s=pe(await o.execute(e),`宿主未返回 ${e.name} 的执行结果`)}catch(c){(i=o.onError)==null||i.call(o,c),s=h(c instanceof Error?c.message:`${e.name} 执行失败`)}rt(r,t,{status:s.success?"success":"error",message:s.message,data:s.data??void 0}),be(o,n,s)||(a=o==null?void 0:o.onError)==null||a.call(o,new Error(`${e.name} 已执行,但 wait_reply 回传失败(连接已关闭)`))},Ae=(e,t,n,r)=>{var l;const o=k(e);if(o.kind==="ignored")return!1;const s=r==null?void 0:r.actionExecute;if(o.kind==="invalid")return(l=s==null?void 0:s.onError)==null||l.call(s,o.error),ve(s,o.replyId,o.error.message),!0;const{command:i,replyId:a}=o;if(i.executor!=="host")return!1;const c=nt(a),u={id:c,name:i.action.name,arguments:i.action.arguments,status:"running",message:"执行中…"};return t.push({answer_type:S,values:u}),ot(i.action,c,a,t,s),!0},Se=e=>{const t=e.values;!t||typeof t!="object"||t.status==="running"&&(t.status="unknown",t.message="执行状态未知(回答已结束)")},Ce={id:"host_action",answerType:S,applyChunk:Ae,normalizeReport:Se},A=[ee,J,se,le,fe,Ee,Ce],st=e=>{const t=(e==null?void 0:e.parsers)??[];return t.length?[...A,...t]:A},it=(e,t,n)=>{var i;const r=(i=e.answer)==null?void 0:i.reports;if(!r)return[];const o=new Set(((n==null?void 0:n.parsers)??[]).filter(a=>a.applyChunk&&a.answerType).map(a=>a.answerType)),s=[];for(const a of st(n))a.applyChunk&&(A.includes(a)&&a.answerType&&o.has(a.answerType)||a.applyChunk(t,r,e,n)&&s.push(a.id));return s},Re=(e,t)=>{var s;const n=e.answer_type;if(!n)return;const o=((t==null?void 0:t.parsers)??[]).find(i=>i.answerType===n&&!!i.normalizeReport)??A.find(i=>i.answerType===n&&!!i.normalizeReport);(s=o==null?void 0:o.normalizeReport)==null||s.call(o,e,t)},M=(e,t="",n="",r)=>{var i;const o=(e==null?void 0:e.values)??e;if((i=o==null?void 0:o.answer)!=null&&i.reports){const a=o;for(const c of a.answer.reports)Re(c,r);return a}const s=K(t,n);return typeof o=="string"&&I({mode:"knowledge_stream",value:o},s.answer.reports,s,r),s},at={User:"user",Assistant:"assistant"};let ct=0;const N=(e="msg")=>`${e}-${++ct}`,Te=e=>{const t=e.trim();if(!t||t==="[DONE]")return null;const n=t.replace(/^data:\s*/,"");try{return JSON.parse(n)}catch{try{return JSON.parse(decodeURIComponent(n))}catch{return null}}},Ie=()=>{let e="";return{push(t){const n=(e+t).split(`
|
|
2
|
-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const J=()=>({answer_type:"knowledge_stream_result",values:[{answer:""}]}),Z=e=>(e.answer_type="knowledge_stream_result",(!Array.isArray(e.values)||!e.values.length)&&(e.values=[{answer:""}]),e),re=(e="",t="")=>({id:e,question:t,answer:{reports:[]}}),ot=["knowledge_stream_begin","knowledge_stream","knowledge_stream_result","knowledge_stream_end"],D=(e,t,r,n)=>{var l;if(!e.mode||!ot.includes(e.mode))return!1;if(e.mode==="knowledge_stream_result"||e.mode==="knowledge_stream_end")return!0;const s=n==null?void 0:n.beforeKnowledgeRender,o=u=>s?s(u):u;if(e.mode==="knowledge_stream_begin"){const u=t.at(-1);return(u==null?void 0:u.answer_type)==="knowledge_stream_result"?(u.values=u.values??[],u.values.push({answer:""}),!0):u&&!u.answer_type?(Z(u),!0):(t.push(J()),!0)}if(e.mode!=="knowledge_stream")return!1;let a=t.at(-1);a&&!a.answer_type?a=Z(a):(!a||a.answer_type!=="knowledge_stream_result")&&(a=J(),t.push(a)),a.values=(l=a.values)!=null&&l.length?a.values:[{answer:""}];const i=a.values[a.values.length-1],c=`${i.raw??""}${e.value||""}`;return i.raw=c,i.answer=o(c),!0},ne=(e,t)=>{if(Array.isArray(e.values)&&e.values.length)return e;const r=t==null?void 0:t.beforeKnowledgeRender,n=o=>r?r(o):o;let s=[];return Array.isArray(e.knowledge)&&(s=e.knowledge.map(o=>typeof o=="string"?o:o==null?void 0:o.answer).filter(o=>typeof o=="string"&&o!=="")),s.length===0&&typeof e.answer=="string"&&e.answer!==""&&(s=[e.answer]),s.length&&(e.values=s.map(o=>({answer:n(o),raw:o}))),e},se={id:"knowledge_stream",answerType:"knowledge_stream_result",applyChunk:D,normalizeReport:ne},oe=["begin","begin_stream","send_stream","end_stream"],ae=(e,t)=>{if(!oe.includes(e.mode||""))return!1;let r=t.at(-1);return(!r||r.answer_type)&&(r={exec_process:[]},t.push(r)),r.exec_process=r.exec_process??[],r.exec_process.push({mode:e.mode,type:e.type,value:e.value}),!0},ie=e=>{const t=[];let r="",n=!1;for(const s of(e.exec_process??[]).filter(o=>oe.includes(o.mode||""))){const o=typeof s.value=="string"?s.value:"";s.mode==="begin"?(n&&r.trim()&&t.push(r.trim()),n=!1,r="",o.trim()&&t.push(o.trim())):s.mode==="begin_stream"?(n&&r.trim()&&t.push(r.trim()),n=!0,r=o):s.mode==="send_stream"&&n?r+=o:s.mode==="end_stream"&&n&&(r+=o,r.trim()&&t.push(r.trim()),n=!1,r="")}return n&&r.trim()&&t.push(r.trim()),t},P=e=>{var t;return(((t=e.answer)==null?void 0:t.reports)??[]).flatMap(ie).map(ce).filter(r=>r.trim()&&!at.test(r.trim()))},at=/^(分析结束|已完成|思考结束|开始|结束|分析完成|任务结束)$/,ce=e=>e.replace(/^ {0,3}(?:={2,}|-{2,})[ \t]*\r?$/gm,"").trim(),le={id:"deep_thinking",applyChunk:ae},it=new Set(["answer_type","type","exec_process","json_ok","json_msg","values"]),_=e=>!e||typeof e!="object"?"":String(e.type||e.answer_type||""),U=e=>{if(!e||typeof e!="object")return;if(e.values!==void 0&&e.values!==null)return e.values;const t={};return Object.keys(e).forEach(r=>{it.has(r)||(t[r]=e[r])}),Object.keys(t).length?t:void 0},g=e=>{const{answerType:t}=e,r=e.readPayload??U;return{id:t,answerType:t,applyChunk:(n,s)=>{if(n.mode!=="result"||_(n.value)!==t)return!1;const o=r(n.value);return o!==void 0&&s.push({answer_type:t,values:o}),!0},normalizeReport:n=>{n.answer_type=t;const s=r(n);s!==void 0&&(n.values=s)}}},ue=g({answerType:"text",readPayload:e=>{if(typeof(e==null?void 0:e.values)=="string")return e.values;if(typeof(e==null?void 0:e.answer)=="string")return e.answer}}),de=g({answerType:"sql_query",readPayload:e=>{var r;const t=((r=e==null?void 0:e.values)==null?void 0:r.sql)!==void 0?e.values:(e==null?void 0:e.sql_query)??e;if(!(!t||typeof t.sql!="string"))return{sql:t.sql,ds_id:t.ds_id}}}),fe=g({answerType:"device_last_value",readPayload:e=>{const t=Array.isArray(e==null?void 0:e.rows)?e:e==null?void 0:e.values;if(!(!t||!Array.isArray(t.rows)))return{title:t.title,rows:t.rows,values:Array.isArray(t.values)?t.values:[]}}}),pe=g({answerType:"camera",readPayload:e=>{const t=e!=null&&e.values&&typeof e.values=="object"&&!Array.isArray(e.values)?e.values:e;if(!t||!t.res_id&&!Array.isArray(t.cameras))return;const r=Array.isArray(t.cameras)?t.cameras:[];return{res_id:t.res_id,cameras:r}}}),me=g({answerType:"video",readPayload:e=>{var r,n;const t=(r=e==null?void 0:e.values)!=null&&r.file_id||(n=e==null?void 0:e.values)!=null&&n.model_id?e.values:e;if(!(!t||!t.file_id&&!t.model_id))return{model_id:t.model_id,file_id:t.file_id}}}),ye=g({answerType:"wav",readPayload:e=>{var r,n;const t=(r=e==null?void 0:e.values)!=null&&r.noise_id||(n=e==null?void 0:e.values)!=null&&n.file_id?e.values:e;if(!(!t||!t.noise_id&&!t.file_id))return{noise_id:t.noise_id,file_id:t.file_id}}}),he=g({answerType:"script",readPayload:U}),ge=[ue,de,fe,pe,me,ye,he],we='/**\n * Skipped minification because the original files appears to be already minified.\n * Original file: /npm/@iframe-resizer/child@5.1.5/index.umd.js\n *\n * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files\n */\n/*!\n * @preserve\n * \n * @module iframe-resizer/child 5.1.5 (umd) - 2024-07-09\n *\n * @license GPL-3.0 for non-commercial use only.\n * For commercial use, you must purchase a license from\n * https://iframe-resizer.com/pricing\n * \n * @desciption Keep same and cross domain iFrames sized to their content \n *\n * @author David J. Bradshaw <info@iframe-resizer.com>\n * \n * @see {@link https://iframe-resizer.com}\n * \n * @copyright (c) 2013 - 2024, David J. Bradshaw. All rights reserved.\n */\n\n\n!function(e){"function"==typeof define&&define.amd?define(e):e()}((function(){"use strict";const e="5.1.5",t=10,n="data-iframe-size",o=(e,t,n,o)=>e.addEventListener(t,n,o||!1),i=(e,t,n)=>e.removeEventListener(t,n,!1),r=["<iy><yi>Puchspk Spjluzl Rlf</><iy><iy>","<iy><yi>Tpzzpun Spjluzl Rlf</><iy><iy>","Aopz spiyhyf pz hchpshisl dpao ivao Jvttlyjphs huk Vwlu-Zvbyjl spjluzlz.<iy><iy><i>Jvttlyjphs Spjluzl</><iy>Mvy jvttlyjphs bzl, <p>pmyhtl-ylzpgly</> ylxbpylz h svd jvza vul aptl spjluzl mll. Mvy tvyl pumvythapvu cpzpa <b>oaawz://pmyhtl-ylzpgly.jvt/wypjpun</>.<iy><iy><i>Vwlu Zvbyjl Spjluzl</><iy>Pm fvb hyl bzpun aopz spiyhyf pu h uvu-jvttlyjphs vwlu zvbyjl wyvqlja aolu fvb jhu bzl pa mvy myll bukly aol alytz vm aol NWS C3 Spjluzl. Av jvumpyt fvb hjjlwa aolzl alytz, wslhzl zla aol <i>spjluzl</> rlf pu <p>pmyhtl-ylzpgly</> vwapvuz av <i>NWSc3</>.<iy><iy>Mvy tvyl pumvythapvu wslhzl zll: <b>oaawz://pmyhtl-ylzpgly.jvt/nws</>","<i>NWSc3 Spjluzl Clyzpvu</><iy><iy>Aopz clyzpvu vm <p>pmyhtl-ylzpgly</> pz ilpun bzlk bukly aol alytz vm aol <i>NWS C3</> spjluzl. Aopz spjluzl hssvdz fvb av bzl <p>pmyhtl-ylzpgly</> pu Vwlu Zvbyjl wyvqljaz, iba pa ylxbpylz fvby wyvqlja av il wbispj, wyvcpkl haaypibapvu huk il spjluzlk bukly clyzpvu 3 vy shaly vm aol NUB Nlulyhs Wbispj Spjluzl.<iy><iy>Pm fvb hyl bzpun aopz spiyhyf pu h uvu-vwlu zvbyjl wyvqlja vy dlizpal, fvb dpss ullk av wbyjohzl h svd jvza vul aptl jvttlyjphs spjluzl.<iy><iy>Mvy tvyl pumvythapvu cpzpa <b>oaawz://pmyhtl-ylzpgly.jvt/wypjpun</>."];Object.fromEntries(["2cgs7fdf4xb","1c9ctcccr4z","1q2pc4eebgb","ueokt0969w","w2zxchhgqz","1umuxblj2e5"].map(((e,t)=>[e,Math.max(0,t-1)])));const a=e=>(e=>e.replaceAll(/[A-Za-z]/g,(e=>String.fromCodePoint((e<="Z"?90:122)>=(e=e.codePointAt(0)+19)?e:e-26))))(r[e]),l={contentVisibilityAuto:!0,opacityProperty:!0,visibilityProperty:!0},c={height:()=>(de("Custom height calculation function not defined"),He.auto()),width:()=>(de("Custom width calculation function not defined"),Ue.auto())},s={bodyOffset:1,bodyScroll:1,offset:1,documentElementOffset:1,documentElementScroll:1,documentElementBoundingClientRect:1,max:1,min:1,grow:1,lowestElement:1},u=128,d={},m="checkVisibility"in window,f="auto",p="[iFrameSizer]",h=p.length,y={max:1,min:1,bodyScroll:1,documentElementScroll:1},g=["body"],v="scroll";let b,w,z=!0,S="",$=0,j="",E=null,P="",O=!0,M=!1,A=null,C=!0,T=!1,k=1,I=f,x=!0,N="",R={},B=!0,q=!1,L=0,W=!1,D="",H="child",U=null,F=!1,V="",J=window.parent,Z="*",Q=0,X=!1,Y="",G=1,K=v,_=window,ee=()=>{de("onMessage function not defined")},te=()=>{},ne=null,oe=null;const ie=e=>""!=`${e}`&&void 0!==e,re=new WeakSet,ae=e=>"object"==typeof e&&re.add(e);function le(e){switch(!0){case!ie(e):return"";case ie(e.id):return`${e.nodeName.toUpperCase()}#${e.id}`;case ie(e.name):return`${e.nodeName.toUpperCase()} (${e.name})`;default:return e.nodeName.toUpperCase()+(ie(e.className)?`.${e.className}`:"")}}function ce(e,t=30){const n=e?.outerHTML?.toString();return n?n.length<t?n:`${n.slice(0,t).replaceAll("\\n"," ")}...`:e}const se=(...e)=>[`[iframe-resizer][${D}]`,...e].join(" "),ue=(...e)=>console?.info(se(...e)),de=(...e)=>console?.warn(se(...e)),me=(...e)=>console?.warn((e=>t=>window.chrome?e(t.replaceAll("<br>","\\n").replaceAll("<rb>","\x1B[31;1m").replaceAll("</>","\x1B[m").replaceAll("<b>","\x1B[1m").replaceAll("<i>","\x1B[3m").replaceAll("<u>","\x1B[4m")):e(t.replaceAll("<br>","\\n").replaceAll(/<[/a-z]+>/gi,"")))(se)(...e)),fe=e=>me(e);function pe(){!function(){try{F="iframeParentListener"in window.parent}catch(e){}}(),function(){const e=e=>"true"===e,t=N.slice(h).split(":");D=t[0],$=void 0===t[1]?$:Number(t[1]),M=void 0===t[2]?M:e(t[2]),q=void 0===t[3]?q:e(t[3]),z=void 0===t[6]?z:e(t[6]),j=t[7],I=void 0===t[8]?I:t[8],S=t[9],P=t[10],Q=void 0===t[11]?Q:Number(t[11]),R.enable=void 0!==t[12]&&e(t[12]),H=void 0===t[13]?H:t[13],K=void 0===t[14]?K:t[14],W=void 0===t[15]?W:e(t[15]),b=void 0===t[16]?b:Number(t[16]),w=void 0===t[17]?w:Number(t[17]),O=void 0===t[18]?O:e(t[18]),t[19],Y=t[20]||Y,L=void 0===t[21]?L:Number(t[21])}(),function(){function e(){const e=window.iframeResizer||window.iFrameResizer;ee=e?.onMessage||ee,te=e?.onReady||te,"number"==typeof e?.offset&&(O&&(b=e?.offset),M&&(w=e?.offset)),Object.prototype.hasOwnProperty.call(e,"sizeSelector")&&(V=e.sizeSelector),Z=e?.targetOrigin||Z,I=e?.heightCalculationMethod||I,K=e?.widthCalculationMethod||K}function t(e,t){return"function"==typeof e&&(c[t]=e,e="custom"),e}if(1===L)return;"iFrameResizer"in window&&Object===window.iFrameResizer.constructor&&(e(),I=t(I,"height"),K=t(K,"width"))}(),function(){void 0===j&&(j=`${$}px`);he("margin",function(e,t){t.includes("-")&&(de(`Negative CSS value ignored for ${e}`),t="");return t}("margin",j))}(),he("background",S),he("padding",P),function(){const e=document.createElement("div");e.style.clear="both",e.style.display="block",e.style.height="0",document.body.append(e)}(),function(){const e=e=>e.style.setProperty("height","auto","important");e(document.documentElement),e(document.body)}(),ye(),L<0?fe(`${a(L+2)}${a(2)}`):Y.codePointAt(0)>4||L<2&&fe(a(3)),function(){if(!Y||""===Y||"false"===Y)return void me("<rb>Legacy version detected on parent page</>\\n\\nDetected legacy version of parent page script. It is recommended to update the parent page to use <b>@iframe-resizer/parent</>.\\n\\nSee <u>https://iframe-resizer.com/setup/</> for more details.\\n");Y!==e&&me(`<rb>Version mismatch</>\\n\\nThe parent and child pages are running different versions of <i>iframe resizer</>.\\n\\nParent page: ${Y} - Child page: ${e}.\\n`)}(),ze(),Se(),function(){let e=!1;const t=t=>document.querySelectorAll(`[${t}]`).forEach((o=>{e=!0,o.removeAttribute(t),o.setAttribute(n,null)}));t("data-iframe-height"),t("data-iframe-width"),e&&me("<rb>Deprecated Attributes</>\\n \\nThe <b>data-iframe-height</> and <b>data-iframe-width</> attributes have been deprecated and replaced with the single <b>data-iframe-size</> attribute. Use of the old attributes will be removed in a future version of <i>iframe-resizer</>.")}(),document.querySelectorAll(`[${n}]`).length>0&&("auto"===I&&(I="autoOverflow"),"auto"===K&&(K="autoOverflow")),be(),function(){if(1===L)return;_.parentIframe=Object.freeze({autoResize:e=>(!0===e&&!1===z?(z=!0,$e()):!1===e&&!0===z&&(z=!1,ve("remove"),U?.disconnect(),E?.disconnect()),Xe(0,0,"autoResize",JSON.stringify(z)),z),close(){Xe(0,0,"close")},getId:()=>D,getPageInfo(e){if("function"==typeof e)return ne=e,Xe(0,0,"pageInfo"),void me("<rb>Deprecated Method</>\\n \\nThe <b>getPageInfo()</> method has been deprecated and replaced with <b>getParentProps()</>. Use of this method will be removed in a future version of <i>iframe-resizer</>.\\n");ne=null,Xe(0,0,"pageInfoStop")},getParentProps(e){if("function"!=typeof e)throw new TypeError("parentIFrame.getParentProps(callback) callback not a function");return oe=e,Xe(0,0,"parentInfo"),()=>{oe=null,Xe(0,0,"parentInfoStop")}},getParentProperties(e){me("<rb>Renamed Method</>\\n \\nThe <b>getParentProperties()</> method has been renamed <b>getParentProps()</>. Use of the old name will be removed in a future version of <i>iframe-resizer</>.\\n"),this.getParentProps(e)},moveToAnchor(e){R.findTarget(e)},reset(){Qe()},scrollBy(e,t){Xe(t,e,"scrollBy")},scrollTo(e,t){Xe(t,e,"scrollTo")},scrollToOffset(e,t){Xe(t,e,"scrollToOffset")},sendMessage(e,t){Xe(0,0,"message",JSON.stringify(e),t)},setHeightCalculationMethod(e){I=e,ze()},setWidthCalculationMethod(e){K=e,Se()},setTargetOrigin(e){Z=e},resize(e,t){Ve("size",`parentIFrame.size(${`${e||""}${t?`,${t}`:""}`})`,e,t)},size(e,t){me("<rb>Deprecated Method</>\\n \\nThe <b>size()</> method has been deprecated and replaced with <b>resize()</>. Use of this method will be removed in a future version of <i>iframe-resizer</>.\\n"),this.resize(e,t)}}),_.parentIFrame=_.parentIframe}(),function(){if(!0!==W)return;function e(e){Xe(0,0,e.type,`${e.screenY}:${e.screenX}`)}function t(t,n){o(window.document,t,e)}t("mouseenter"),t("mouseleave")}(),$e(),R=function(){const e=()=>({x:document.documentElement.scrollLeft,y:document.documentElement.scrollTop});function n(n){const o=n.getBoundingClientRect(),i=e();return{x:parseInt(o.left,t)+parseInt(i.x,t),y:parseInt(o.top,t)+parseInt(i.y,t)}}function i(e){function t(e){const t=n(e);Xe(t.y,t.x,"scrollToOffset")}const o=e.split("#")[1]||e,i=decodeURIComponent(o),r=document.getElementById(i)||document.getElementsByName(i)[0];void 0===r?Xe(0,0,"inPageLink",`#${o}`):t(r)}function r(){const{hash:e,href:t}=window.location;""!==e&&"#"!==e&&i(t)}function a(){function e(e){function t(e){e.preventDefault(),i(this.getAttribute("href"))}"#"!==e.getAttribute("href")&&o(e,"click",t)}document.querySelectorAll(\'a[href^="#"]\').forEach(e)}function l(){o(window,"hashchange",r)}function c(){setTimeout(r,u)}function s(){a(),l(),c()}R.enable&&(1===L?me("In page linking requires a Professional or Business license. Please see https://iframe-resizer.com/pricing for more details."):s());return{findTarget:i}}(),ae(document.documentElement),ae(document.body),Ve("init","Init message from host page",void 0,void 0,e),document.title&&""!==document.title&&Xe(0,0,"title",document.title),te(),B=!1}function he(e,t){void 0!==t&&""!==t&&"null"!==t&&document.body.style.setProperty(e,t)}function ye(){""!==V&&document.querySelectorAll(V).forEach((e=>{e.dataset.iframeSize=!0}))}function ge(e){({add(t){function n(){Ve(e.eventName,e.eventType)}d[t]=n,o(window,t,n,{passive:!0})},remove(e){const t=d[e];delete d[e],i(window,e,t)}})[e.method](e.eventName)}function ve(e){ge({method:e,eventType:"After Print",eventName:"afterprint"}),ge({method:e,eventType:"Before Print",eventName:"beforeprint"}),ge({method:e,eventType:"Ready State Change",eventName:"readystatechange"})}function be(){const e=document.querySelectorAll(`[${n}]`);T=e.length>0,A=T?e:Re(document)()}function we(e,t,n,o){return t!==e&&(e in n||(de(`${e} is not a valid option for ${o}CalculationMethod.`),e=t),e in s&&me(`<rb>Deprecated ${o}CalculationMethod (${e})</>\\n\\nThis version of <i>iframe-resizer</> can auto detect the most suitable ${o} calculation method. It is recommended that you remove this option.`)),e}function ze(){I=we(I,f,He,"height")}function Se(){K=we(K,v,Ue,"width")}function $e(){!0===z&&(ve("add"),E=function(){function e(e){e.forEach(Te),ye(),be()}function t(){const t=new window.MutationObserver(e),n=document.querySelector("body"),o={attributes:!1,attributeOldValue:!1,characterData:!1,characterDataOldValue:!1,childList:!0,subtree:!0};return t.observe(n,o),t}const n=t();return{disconnect(){n.disconnect()}}}(),U=new ResizeObserver(Ee),Ce(window.document))}let je;function Ee(e){if(!Array.isArray(e)||0===e.length)return;const t=e[0].target;je=()=>Ve("resizeObserver",`Resize Observed: ${le(t)}`),setTimeout((()=>{je&&je(),je=void 0}),0)}const Pe=e=>{const t=getComputedStyle(e);return""!==t?.position&&"static"!==t?.position},Oe=()=>[...Re(document)()].filter(Pe),Me=new WeakSet;function Ae(e){e&&(Me.has(e)||(U.observe(e),Me.add(e)))}function Ce(e){[...Oe(),...g.flatMap((t=>e.querySelector(t)))].forEach(Ae)}function Te(e){"childList"===e.type&&Ce(e.target)}let ke=4,Ie=4;function xe(e){const t=(n=e).charAt(0).toUpperCase()+n.slice(1);var n;let o=0,i=A.length,r=document.documentElement,a=T?0:document.documentElement.getBoundingClientRect().bottom,c=performance.now();var s;A.forEach((t=>{T||!m||t.checkVisibility(l)?(o=t.getBoundingClientRect()[e]+parseFloat(getComputedStyle(t).getPropertyValue(`margin-${e}`)),o>a&&(a=o,r=t)):i-=1})),c=performance.now()-c,i>1&&(s=r,re.has(s)||(ae(s),ue(`\\nHeight calculated from: ${le(s)} (${ce(s)})`)));const u=`\\nParsed ${i} element${1===i?"":"s"} in ${c.toPrecision(3)}ms\\n${t} ${T?"tagged ":""}element found at: ${a}px\\nPosition calculated from HTML element: ${le(r)} (${ce(r,100)})`;return c<4||i<99||T||B||ke<c&&ke<Ie&&(ke=1.2*c,me(`<rb>Performance Warning</>\\n\\nCalculating the page size took an excessive amount of time. To improve performance add the <b>data-iframe-size</> attribute to the ${e} most element on the page.\\n${u}`)),Ie=c,a}const Ne=e=>[e.bodyOffset(),e.bodyScroll(),e.documentElementOffset(),e.documentElementScroll(),e.documentElementBoundingClientRect()],Re=e=>()=>e.querySelectorAll("* :not(head):not(meta):not(base):not(title):not(script):not(link):not(style):not(map):not(area):not(option):not(optgroup):not(template):not(track):not(wbr):not(nobr)");let Be=!1;function qe({ceilBoundingSize:e,dimension:t,getDimension:n,isHeight:o,scrollSize:i}){if(!Be)return Be=!0,n.taggedElement();const r=o?"bottom":"right";return me(`<rb>Detected content overflowing html element</>\\n \\nThis causes <i>iframe-resizer</> to fall back to checking the position of every element on the page in order to calculate the correct dimensions of the iframe. Inspecting the size, ${r} margin, and position of every visible HTML element will have a performance impact on more complex pages. \\n\\nTo fix this issue, and remove this warning, you can either ensure the content of the page does not overflow the <b><HTML></> element or alternatively you can add the attribute <b>data-iframe-size</> to the elements on the page that you want <i>iframe-resizer</> to use when calculating the dimensions of the iframe. \\n \\nWhen present the ${r} margin of the ${o?"lowest":"right most"} element with a <b>data-iframe-size</> attribute will be used to set the ${t} of the iframe.\\n\\nMore info: https://iframe-resizer.com/performance.\\n\\n(Page size: ${i} > document size: ${e})`),o?I="autoOverflow":K="autoOverflow",n.taggedElement()}const Le={height:0,width:0},We={height:0,width:0};function De(e,t){function n(){return We[i]=r,Le[i]=c,r}const o=e===He,i=o?"height":"width",r=e.documentElementBoundingClientRect(),a=Math.ceil(r),l=Math.floor(r),c=(e=>e.documentElementScroll()+Math.max(0,e.getOffset()))(e);switch(!0){case!e.enabled():return c;case!t&&0===We[i]&&0===Le[i]:if(e.taggedElement(!0)<=a)return n();break;case X&&r===We[i]&&c===Le[i]:return Math.max(r,c);case 0===r:return c;case!t&&r!==We[i]&&c<=Le[i]:return n();case!o:return t?e.taggedElement():qe({ceilBoundingSize:a,dimension:i,getDimension:e,isHeight:o,scrollSize:c});case!t&&r<We[i]:case c===l||c===a:case r>c:return n();case!t:return qe({ceilBoundingSize:a,dimension:i,getDimension:e,isHeight:o,scrollSize:c})}return Math.max(e.taggedElement(),n())}const He={enabled:()=>O,getOffset:()=>b,type:"height",auto:()=>De(He,!1),autoOverflow:()=>De(He,!0),bodyOffset:()=>{const{body:e}=document,n=getComputedStyle(e);return e.offsetHeight+parseInt(n.marginTop,t)+parseInt(n.marginBottom,t)},bodyScroll:()=>document.body.scrollHeight,offset:()=>He.bodyOffset(),custom:()=>c.height(),documentElementOffset:()=>document.documentElement.offsetHeight,documentElementScroll:()=>document.documentElement.scrollHeight,documentElementBoundingClientRect:()=>document.documentElement.getBoundingClientRect().bottom,max:()=>Math.max(...Ne(He)),min:()=>Math.min(...Ne(He)),grow:()=>He.max(),lowestElement:()=>xe("bottom"),taggedElement:()=>xe("bottom")},Ue={enabled:()=>M,getOffset:()=>w,type:"width",auto:()=>De(Ue,!1),autoOverflow:()=>De(Ue,!0),bodyScroll:()=>document.body.scrollWidth,bodyOffset:()=>document.body.offsetWidth,custom:()=>c.width(),documentElementScroll:()=>document.documentElement.scrollWidth,documentElementOffset:()=>document.documentElement.offsetWidth,documentElementBoundingClientRect:()=>document.documentElement.getBoundingClientRect().right,max:()=>Math.max(...Ne(Ue)),min:()=>Math.min(...Ne(Ue)),rightMostElement:()=>xe("right"),scroll:()=>Math.max(Ue.bodyScroll(),Ue.documentElementScroll()),taggedElement:()=>xe("right")};function Fe(e,t,n,o,i){let r,a;!function(){const e=(e,t)=>!(Math.abs(e-t)<=Q);return r=void 0===n?He[I]():n,a=void 0===o?Ue[K]():o,O&&e(k,r)||M&&e(G,a)}()&&"init"!==e?!(e in{init:1,size:1})&&(O&&I in y||M&&K in y)&&Qe():(Je(),k=r,G=a,Xe(k,G,e,i))}function Ve(e,t,n,o,i){document.hidden||Fe(e,0,n,o,i)}function Je(){X||(X=!0,requestAnimationFrame((()=>{X=!1})))}function Ze(e){k=He[I](),G=Ue[K](),Xe(k,G,e)}function Qe(e){const t=I;I=f,Je(),Ze("reset"),I=t}function Xe(e,t,n,o,i){L<-1||(void 0!==i||(i=Z),function(){const r=`${D}:${`${e+(b||0)}:${t+(w||0)}`}:${n}${void 0===o?"":`:${o}`}`;F?window.parent.iframeParentListener(p+r):J.postMessage(p+r,i)}())}function Ye(e){const t={init:function(){N=e.data,J=e.source,pe(),C=!1,setTimeout((()=>{x=!1}),u)},reset(){x||Ze("resetPage")},resize(){Ve("resizeParent")},moveToAnchor(){R.findTarget(o())},inPageLink(){this.moveToAnchor()},pageInfo(){const e=o();ne?ne(JSON.parse(e)):Xe(0,0,"pageInfoStop")},parentInfo(){const e=o();oe?oe(Object.freeze(JSON.parse(e))):Xe(0,0,"parentInfoStop")},message(){const e=o();ee(JSON.parse(e))}},n=()=>e.data.split("]")[1].split(":")[0],o=()=>e.data.slice(e.data.indexOf(":")+1),i=()=>"iframeResize"in window||void 0!==window.jQuery&&""in window.jQuery.prototype,r=()=>e.data.split(":")[2]in{true:1,false:1};p===`${e.data}`.slice(0,h)&&(!1!==C?r()&&t.init():function(){const o=n();o in t?t[o]():i()||r()||de(`Unexpected message (${e.data})`)}())}function Ge(){"loading"!==document.readyState&&window.parent.postMessage("[iFrameResizerChild]Ready","*")}"undefined"!=typeof window&&(window.iframeChildListener=e=>Ye({data:e,sameDomain:!0}),o(window,"message",Ye),o(window,"readystatechange",Ge),Ge())}));\n',ct="iframe-resizer/child 5.1.5",lt=we,k=`<script>${we}<\/script>`,_e=e=>{if(!e||typeof e!="object")return{};const t=e.values,r=o=>{const a=t&&typeof t=="object"?t[o]:void 0;if(typeof a=="string"&&a)return a;const i=e[o];return typeof i=="string"&&i?i:void 0},n=r("url"),s=r("srcdoc");return{...n?{url:n}:{},...s?{srcdoc:s}:{}}},q=e=>e&&(e.includes("</head>")?e.replace("</head>",`${k}</head>`):e.includes("<body")?e.replace("<body",`${k}<body`):k+e),ut=e=>!e||typeof e!="object"||Array.isArray(e)||!e.url&&!e.srcdoc?!1:!e.srcdoc||e.srcdoc.includes(ct),be=(e,t)=>{if(e.mode!=="result"||_(e.value)!=="url")return!1;const r=_e(e.value);return!r.url&&!r.srcdoc||(r.srcdoc&&(r.srcdoc=q(r.srcdoc)),t.push({answer_type:"url",values:r})),!0},Ee=e=>{if(ut(e.values))return e;const t=_e(e);return!t.url&&!t.srcdoc||(t.srcdoc&&(t.srcdoc=q(t.srcdoc)),e.values=t),e},ve={id:"iframe_page",answerType:"url",applyChunk:be,normalizeReport:Ee},C="recordset",dt=["cols","values","chart","title","max_cols","parent_link_col","agent_key"],T=e=>!!e&&typeof e=="object"&&!Array.isArray(e)&&(Array.isArray(e.cols)||Array.isArray(e.values)),Ae=e=>{if(!e||typeof e!="object"||Array.isArray(e))return;const t=e.values;if(T(t))return t;if(T(e))return e},Se=(e,t)=>{if(e.mode!=="result"||_(e.value)!==C)return!1;const r=Ae(e.value);return r&&t.push({answer_type:C,values:r}),!0},ze=e=>{if(T(e.values))return e;const t=e;if(!T(t))return e;const r={};for(const n of dt)r[n]=t[n];return e.values=r,e},Ce={id:"recordset",answerType:C,applyChunk:Se,normalizeReport:ze},E="output_file",Q=(e,t)=>{if(!e||typeof e!="object")return;const r=e[t];return typeof r=="string"&&r?r:void 0},Te=["file_id","file_name","file_path"],B=e=>{if(!e||typeof e!="object")return{};const t=e.values&&typeof e.values=="object"?e.values:void 0,r={};for(const n of Te){const s=Q(t,n)??Q(e,n);s&&(r[n]=s)}return r},Re=(e,t)=>{if(e.mode!=="result"||_(e.value)!==E)return!1;const r=B(e.value);return!r.file_id&&!r.file_name&&!r.file_path||t.push({answer_type:E,values:r}),!0},Pe=e=>{const t=B(e);if(!t.file_id&&!t.file_name&&!t.file_path)return e;const r=e.values&&typeof e.values=="object"&&!Array.isArray(e.values)?e.values:{},n=Te.filter(s=>t[s]&&!r[s]);return n.length===0||(e.values={...r,...Object.fromEntries(n.map(s=>[s,t[s]]))}),e},Ie={id:E,answerType:E,applyChunk:Re,normalizeReport:Pe},v="present_files",h=(e,t)=>{if(!e||typeof e!="object")return;const r=e[t];return typeof r=="string"&&r.trim()?r.trim():void 0},je=e=>{const t=String(e||"").replace(/\\/g,"/"),r=t.split("/").filter(Boolean);return r[r.length-1]||t},$e=e=>{if(!e||typeof e!="object")return null;const t=h(e,"id")??h(e,"file_id"),r=h(e,"file_path")??h(e,"path")??h(e,"name"),n=h(e,"file_name");if(!t&&!r&&!n)return null;const s={};return t&&(s.file_id=t),r&&(s.file_path=r),n?s.file_name=n:r&&(s.file_name=je(r)),s},W=e=>{if(!e||typeof e!="object")return{files:[]};const t=e.values&&typeof e.values=="object"&&!Array.isArray(e.values)?e.values:void 0,s={files:(Array.isArray(t==null?void 0:t.files)?t.files:Array.isArray(e.files)?e.files:[]).map(a=>$e(a)).filter(a=>!!a)},o=h(t,"explanation")??h(e,"explanation");return o&&(s.explanation=o),s},xe=(e,t)=>{if(e.mode!=="result"||_(e.value)!==v)return!1;const r=W(e.value);return r.files.length&&t.push({answer_type:v,values:r}),!0},Me=e=>{const t=e.values&&typeof e.values=="object"&&!Array.isArray(e.values)?e.values:void 0;if(Array.isArray(t==null?void 0:t.files)&&t.files.every(s=>s&&typeof s=="object"&&(s.file_id||s.file_name||s.file_path)))return e;const n=W(e);return n.files.length&&(e.values={...t??{},files:n.files,...n.explanation?{explanation:n.explanation}:{}}),e},Oe={id:v,answerType:v,applyChunk:xe,normalizeReport:Me},w=e=>({success:!1,message:e,data:null}),ft=e=>{if(typeof e!="string")return e;try{return JSON.parse(e)}catch{throw new Error("执行指令不是合法的 JSON")}},ke=e=>{const t=ft(e);if(!t||typeof t!="object")throw new Error("执行指令格式无效");const{type:r,executor:n,action:s}=t;if(r!=="action_execute")throw new Error(`不支持的指令类型:${String(r??"")}`);if(n!=="host"&&n!=="agent")throw new Error(`不支持的执行端:${String(n??"")}`);if(!s||typeof s!="object"||typeof s.name!="string"||!s.name.trim())throw new Error("执行指令缺少合法的 action.name");if(!s.arguments||typeof s.arguments!="object"||Array.isArray(s.arguments))throw new Error("执行指令的 action.arguments 必须是对象");return{type:r,executor:n,action:{name:s.name,arguments:s.arguments}}},Ne=(e,t="执行端未返回有效的执行结果")=>{if(!e||typeof e!="object")return w(t);const r=e;return typeof r.success!="boolean"?w("执行端返回的 success 必须是布尔值"):{success:r.success,message:typeof r.message=="string"?r.message:r.success?"操作成功":"操作失败",data:Object.prototype.hasOwnProperty.call(r,"data")?r.data??null:null}},pt=e=>{if(e&&typeof e=="object"){const t=e;if(typeof t.success=="boolean")return e;if(t.json_ok===!0)return{success:!0,message:"操作成功",data:e};if(t.json_ok===!1)return{success:!1,message:typeof t.error=="string"?t.error:"操作失败",data:e}}return w("系统操作返回了无法识别的报文帧")},mt=e=>typeof e.reply_id=="string"||typeof e.reply_id=="number"?e.reply_id:void 0,G=e=>{if((e==null?void 0:e.mode)!=="front_reply")return{kind:"ignored"};const t=mt(e),r=e.values??e.value;let n=r;if(typeof r=="string")try{n=JSON.parse(r)}catch{return{kind:"ignored"}}if(!n||typeof n!="object"||Array.isArray(n)||n.type!=="action_execute")return{kind:"ignored"};try{return{kind:"ok",replyId:t,command:ke(n)}}catch(s){return{kind:"invalid",replyId:t,error:s instanceof Error?s:new Error("执行指令解析失败")}}},I="collect_clarifications",j="host_action",yt=["single_select","multi_select","date","text"],y=new Map;let ee=0;const A=e=>!!e&&typeof e=="object"&&!Array.isArray(e),b=e=>typeof e=="string"&&e.trim()?e:void 0,ht=(e,t)=>{if(!Array.isArray(e)||e.length===0)throw new Error(`确认项 ${t} 缺少可选项`);return e.map((r,n)=>{if(!A(r)||typeof r.label!="string"||!r.label.trim())throw new Error(`确认项 ${t} 的第 ${n+1} 个选项格式无效`);if(!Object.prototype.hasOwnProperty.call(r,"value"))throw new Error(`确认项 ${t} 的第 ${n+1} 个选项缺少 value`);return{label:r.label,value:r.value}})},gt=e=>{if(e===void 0)return;if(!A(e))throw new Error("确认项的 binding 必须是对象");const t={};return typeof e.actionIndex=="number"&&(t.actionIndex=e.actionIndex),typeof e.actionName=="string"&&(t.actionName=e.actionName),typeof e.parameterPath=="string"&&(t.parameterPath=e.parameterPath),t},wt=(e,t)=>{if(!A(e)||!yt.includes(e.type))throw new Error(`确认项 ${t} 的 input.type 无效`);const r=e.type,n={type:r,placeholder:b(e.placeholder)};if((r==="single_select"||r==="multi_select")&&(n.options=ht(e.options,t)),r==="date"){if(e.format!==void 0&&e.format!=="YYYY-MM-DD")throw new Error(`确认项 ${t} 暂不支持日期格式 ${String(e.format)}`);n.format="YYYY-MM-DD"}if(e.textInput!==void 0){if(!A(e.textInput))throw new Error(`确认项 ${t} 的 textInput 必须是对象`);n.textInput={placeholder:b(e.textInput.placeholder)}}return n},Le=e=>{if(!Array.isArray(e.items)||e.items.length===0)throw new Error("collect_clarifications 至少需要一个确认项");const t=new Set,r=e.items.map((n,s)=>{if(!A(n))throw new Error(`第 ${s+1} 个确认项格式无效`);const o=typeof n.id=="string"?n.id.trim():"",a=typeof n.question=="string"?n.question.trim():"";if(!o)throw new Error(`第 ${s+1} 个确认项缺少 id`);if(t.has(o))throw new Error(`确认项 id 重复:${o}`);if(!a)throw new Error(`确认项 ${o} 缺少 question`);return t.add(o),{id:o,question:a,description:b(n.description),required:n.required!==!1,default:n.default,binding:gt(n.binding),input:wt(n.input,o)}});return{title:b(e.title)??"需要你确认几项信息",description:b(e.description)??"请补充以下信息,我会据此继续完成操作。",items:r}},He=e=>e!==void 0?String(e):(ee+=1,`clarification-${Date.now()}-${ee}`),De=e=>{y.set(e.reportId,e)},_t=e=>y.has(e),$=(e,t)=>{const r=e.reports.findIndex(n=>{var s;return n.answer_type===I&&((s=n.values)==null?void 0:s.requestId)===e.reportId});r<0||e.reports.splice(r,1,{...e.reports[r],values:{...e.reports[r].values,...t}})},Ue=(e,t)=>{var r;if(!e.reply)return!1;try{return e.reply({type:"wait_reply",reply_id:e.replyId,values:t})!==!1}catch(n){return(r=e.onError)==null||r.call(e,n),!1}},bt=(e,t)=>{const r=y.get(e);if(!r)return!1;y.delete(e);const n=Ue(r,{success:!0,message:"用户已提交补充信息",data:{answers:t}});return $(r,{status:"submitted",resultMessage:n?"补充信息已提交":"补充信息已提交,但结果回传失败(连接已关闭)",answers:t}),!0},Et=e=>{const t=y.get(e);if(!t)return!1;y.delete(e);const r=Ue(t,{success:!1,message:"用户取消了补充信息",data:null});return $(t,{status:"cancelled",resultMessage:r?"已取消补充信息":"已取消补充信息,但结果回传失败(连接已关闭)"}),!0},vt=e=>{y.forEach((t,r)=>{e&&t.reply!==e||($(t,{status:"expired",resultMessage:"本次补充信息已失效(回答已结束)"}),y.delete(r))})},At=e=>{y.forEach((t,r)=>{t.reply===e&&($(t,{status:"expired",resultMessage:"本次补充信息已失效(连接已关闭)"}),y.delete(r))})},qe=(e,t,r)=>{var n;if(!(e!=null&&e.reply))return!1;try{const s={type:"wait_reply",reply_id:t,values:r};return e.reply(s)!==!1}catch(s){return(n=e.onError)==null||n.call(e,s),!1}},L=(e,t,r)=>{qe(e,t,w(r))},Be=(e,t,r,n)=>{var m;const s=G(e);if(s.kind!=="ok")return!1;const{command:o,replyId:a}=s;if(o.executor!=="agent"||o.action.name!=="collect_clarifications")return!1;const i=n==null?void 0:n.actionExecute;let c;try{c=Le(o.action.arguments)}catch(d){return(m=i==null?void 0:i.onError)==null||m.call(i,d),L(i,a,d instanceof Error?d.message:"确认项参数无效"),!0}const l=He(a),u={requestId:l,...c,status:"pending",resultMessage:""};return De({reportId:l,replyId:a,reports:t,reply:i==null?void 0:i.reply,onError:i==null?void 0:i.onError}),t.push({answer_type:I,values:u}),!0},We=e=>{const t=e.values;!t||typeof t!="object"||t.status==="pending"&&(t.status="expired",t.resultMessage="本次补充信息已失效(回答已结束)")},Ge={id:"collect_clarifications",answerType:I,applyChunk:Be,normalizeReport:We};let te=0;const St=e=>e!==void 0?String(e):(te+=1,`host-action-${Date.now()}-${te}`),zt=(e,t,r)=>{const n=e.findIndex(s=>{var o;return s.answer_type===j&&((o=s.values)==null?void 0:o.id)===t});n<0||e.splice(n,1,{...e[n],values:{...e[n].values,...r}})},Ct=async(e,t,r,n,s,o)=>{var i,c;let a;try{a=Ne(await o(e),`宿主未返回 ${e.name} 的执行结果`)}catch(l){(i=s.onError)==null||i.call(s,l),a=w(l instanceof Error?l.message:`${e.name} 执行失败`)}zt(n,t,{status:a.success?"success":"error",message:a.message,data:a.data??void 0}),qe(s,r,a)||(c=s.onError)==null||c.call(s,new Error(`${e.name} 已执行,但 wait_reply 回传失败(连接已关闭)`))},Fe=(e,t,r,n)=>{var u;const s=G(e);if(s.kind==="ignored")return!1;const o=n==null?void 0:n.actionExecute;if(s.kind==="invalid")return o!=null&&o.reply?((u=o.onError)==null||u.call(o,s.error),L(o,s.replyId,s.error.message),!0):!1;const{command:a,replyId:i}=s;if(a.executor!=="host")return!1;if(!(o!=null&&o.execute))return o!=null&&o.reply?(L(o,i,"当前页面不支持该操作"),!0):!1;const c=St(i),l={id:c,name:a.action.name,arguments:a.action.arguments,status:"running",message:"执行中…"};return t.push({answer_type:j,values:l}),Ct(a.action,c,i,t,o,o.execute),!0},Xe=e=>{const t=e.values;!t||typeof t!="object"||t.status==="running"&&(t.status="unknown",t.message="执行状态未知(回答已结束)")},Ye={id:"host_action",answerType:j,applyChunk:Fe,normalizeReport:Xe},S=e=>{var a;const t=e??{},r=((a=t.answer)==null?void 0:a.state)??t.state??null,n=r==="1"||r===1?"1":r==="0"||r===0?"0":null,s=Array.isArray(t.context_history)?[...t.context_history].sort((i,c)=>Number((c==null?void 0:c.ratio)??0)-Number((i==null?void 0:i.ratio)??0)):[],o=t.run_ms!=null&&t.run_ms!==""&&Number.isFinite(Number(t.run_ms))?Number(t.run_ms):null;return{state:n,conclusion:Array.isArray(t.conclusion)?t.conclusion.filter(i=>i&&i.report):[],contextHistory:s,entry:t.entry&&typeof t.entry=="object"?t.entry:null,err:t.err&&typeof t.err=="object"&&(t.err.code||t.err.msg)?t.err:null,runMs:o}},Tt=["conclusion","context_history","entry","err","run_ms","attach"],Rt=(e,t)=>{const r=(t==null?void 0:t.values)??t;!r||typeof r!="object"||(Tt.forEach(n=>{const s=r[n],o=e[n],a=o==null||Array.isArray(o)&&o.length===0;s!=null&&a&&(e[n]=s)}),r.answer&&"state"in r.answer&&e.answer&&(e.answer.state=r.answer.state))},Ke={id:"conclusion",applyChunk:(e,t,r)=>{if(e.mode!=="conclusion")return!1;const n=e.value,s=Array.isArray(n)?n:n&&typeof n=="object"?[n]:[];return s.length&&(r.conclusion=s),!0}},Pt=e=>{var r;const t=[];return(((r=e==null?void 0:e.answer)==null?void 0:r.reports)??[]).forEach(n=>{n.answer_type==="knowledge_stream_result"&&Array.isArray(n.values)?n.values.forEach(s=>(s==null?void 0:s.answer)&&t.push(s.answer)):n.answer_type==="text"&&typeof n.values=="string"&&t.push(n.values)}),S(e).conclusion.forEach(n=>n.report&&t.push(n.report)),t.join(`
|
|
2
|
+
|
|
3
|
+
`).trim()},It=e=>e.replace(/```[\s\S]*?\n([\s\S]*?)```/g,"$1").replace(/!\[([^\]]*)\]\([^)]*\)/g,"$1").replace(/\[([^\]]+)\]\([^)]*\)/g,"$1").replace(/^\s{0,3}#{1,6}\s+/gm,"").replace(/^\s{0,3}>\s?/gm,"").replace(/(\*\*|__)(?=\S)[\s\S]*?\1/g,(t,r)=>t.split(r).join("")).replace(new RegExp("(?<![*_\\w])\\*([^*\\n]+?)\\*(?!\\*)","g"),"$1").replace(new RegExp("(?<![_\\w])_([^_\\n]+?)_(?![_\\w])","g"),"$1").replace(/~~(?=\S)[\s\S]*?~~/g,t=>t.split("~~").join("")).replace(/`([^`]*)`/g,"$1").replace(/^\s*[-*+]\s+/gm,"").replace(/\n{3,}/g,`
|
|
4
|
+
|
|
5
|
+
`).trim(),R=[le,se,ve,Ce,Ie,Oe,Ge,Ye,...ge,Ke],jt=e=>{const t=(e==null?void 0:e.parsers)??[];return t.length?[...R,...t]:R},$t=(e,t,r)=>{var a;const n=(a=e.answer)==null?void 0:a.reports;if(!n)return[];const s=new Set(((r==null?void 0:r.parsers)??[]).filter(i=>i.applyChunk&&i.answerType).map(i=>i.answerType)),o=[];for(const i of jt(r))i.applyChunk&&(R.includes(i)&&i.answerType&&s.has(i.answerType)||i.applyChunk(t,n,e,r)&&o.push(i.id));return o},Ve=(e,t)=>{var o;const r=e.answer_type;if(!r)return;const s=((t==null?void 0:t.parsers)??[]).find(a=>a.answerType===r&&!!a.normalizeReport)??R.find(a=>a.answerType===r&&!!a.normalizeReport);(o=s==null?void 0:s.normalizeReport)==null||o.call(s,e,t)},x=(e,t="",r="",n)=>{var a;const s=(e==null?void 0:e.values)??e;if((a=s==null?void 0:s.answer)!=null&&a.reports){const i=s;for(const c of i.answer.reports)Ve(c,n);return i}const o=re(t,r);return typeof s=="string"&&D({mode:"knowledge_stream",value:s},o.answer.reports,o,n),o},xt={User:"user",Assistant:"assistant"};let Mt=0;const F=(e="msg")=>`${e}-${++Mt}`,Je=e=>{const t=e.trim();if(!t||t==="[DONE]")return null;const r=t.replace(/^data:\s*/,"");try{return JSON.parse(r)}catch{try{return JSON.parse(decodeURIComponent(r))}catch{return null}}},Ze=()=>{let e="";return{push(t){const r=(e+t).split(`
|
|
6
|
+
`);return e=r.pop()||"",r},flush(){const t=e;return e="",t?[t]:[]}}},Qe=30,Ot=/[A-Za-z]:[\\/][^\s"'`,。;;、,()()【】\[\]<>|?*]*/g,kt=/\\\\[^\s"'`,。;;、,()()【】\[\]<>|?*]+/g,Nt=/(^|[\s"'`((【\[::,,、])((?:\/[^\s"'`,。;;、,()()【】\[\]<>|?*\/]+){2,})/g,Lt=/^(?:请帮忙|请帮我|帮我看看|帮我把|帮我|帮忙|请把|麻烦你|麻烦|劳驾|请你|请问|帮(?!助))\s*[::,,、\-—]?\s*/,N=e=>{const t=e.split(/[\\/]+/).filter(Boolean);return t.length?t[t.length-1]:""},Ht=e=>e.replace(kt,t=>N(t)).replace(Ot,t=>N(t)).replace(Nt,(t,r,n)=>r+N(n)),Dt=e=>{let t=String(e??"").replace(/\r\n|\r|\n/g," ").replace(/\s+/g," ").trim();if(!t)return"";t=Ht(t).replace(/\s+/g," ").trim();let r="";for(;r!==t;)r=t,t=t.replace(Lt,"").trim(),t=t.replace(/^[::,,、\-—\s]+/,"").trim();return t.slice(0,Qe)},Ut=async(e,t)=>{const r=e.getReader(),n=new TextDecoder,s=Ze(),o=a=>{const i=Je(a);i&&t(i)};try{for(;;){const{done:a,value:i}=await r.read();if(a)break;s.push(n.decode(i,{stream:!0})).forEach(o)}s.flush().forEach(o)}catch(a){throw await r.cancel().catch(()=>{}),a}finally{r.releaseLock()}},z=new Set(["png","jpg","jpeg","gif","webp","svg","bmp"]),X=e=>!e||isNaN(e)?"":e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/(1024*1024)).toFixed(1)} MB`,qt=e=>{var n;if(e.type&&e.type!=="file")return!1;const t=e.attachContent||{};if(t.groupType==="image")return!0;const r=(t.suffix||((n=e.name)!=null&&n.includes(".")?e.name.split(".").pop():"")||"").toLowerCase();return!!(z.has(r)||t.raw&&typeof t.raw.type=="string"&&t.raw.type.startsWith("image/"))},et=(e,t,r)=>e.startsWith("http://")||e.startsWith("https://")||e.startsWith("/")?e:`${(t||"").replace(/\/$/,"")}${r}?file_id=${e}`,tt=(e,t="",r)=>e?r?r(e):et(e,t,"/file/download_file"):"",Bt=(e,t="",r)=>{const n=e.attachContent||{};return n.url?n.url:typeof n.fileContent=="string"&&n.fileContent.startsWith("data:image/")?n.fileContent:n.fileId?tt(n.fileId,t,r):""},H=e=>{var i;const t=(e==null?void 0:e.name)||"",r=t.includes(".")&&((i=t.split(".").pop())==null?void 0:i.toLowerCase())||"",n=z.has(r)||(e==null?void 0:e.type)&&typeof e.type=="string"&&e.type.startsWith("image/");let s;if(n&&typeof window<"u"&&typeof URL<"u"&&e instanceof Blob)try{s=URL.createObjectURL(e)}catch{s=void 0}const o=X(e==null?void 0:e.size),a=[r.toUpperCase(),o].filter(Boolean).join(" · ");return{type:"file",name:t,description:a,attachContent:{file_name:t,size:e==null?void 0:e.size,suffix:r,raw:e,url:s,groupType:n?"image":"file"}}},Y=e=>{var o;const t=(e==null?void 0:e.file_name)??(e==null?void 0:e.name)??(e==null?void 0:e.title)??"",r=t.includes(".")&&((o=t.split(".").pop())==null?void 0:o.toLowerCase())||"",n=z.has(r)||(e==null?void 0:e.groupType)==="image",s=r?r.toUpperCase():"";return{type:"file",name:t,description:s,attachContent:{file_name:(e==null?void 0:e.file_name)??t,fileId:(e==null?void 0:e.file_id)??(e==null?void 0:e.id),fileContent:e==null?void 0:e.file_content,suffix:r,groupType:n?"image":"file"}}},rt=e=>{var n,s,o,a;const t=(e==null?void 0:e.values)??e,r=((n=t==null?void 0:t.attach)==null?void 0:n.files)??((o=(s=t==null?void 0:t.answer)==null?void 0:s.attach)==null?void 0:o.files)??(t==null?void 0:t.attach_files)??((a=t==null?void 0:t.answer)==null?void 0:a.attach_files)??[];return!Array.isArray(r)||r.length===0?[]:r.map(i=>Y(i))},Wt=e=>{var n,s;if(!e)return{type:"file",name:"",description:"",attachContent:{}};if(typeof Blob<"u"&&e instanceof Blob)return H(e);if(typeof e=="object"&&e.attachContent){const o=e.type||"file",a=e.name||e.attachContent.file_name||e.attachContent.name||"";let i=e.description||"";const c={...e.attachContent};if(o==="file"&&(!c.suffix&&a.includes(".")&&(c.suffix=((n=a.split(".").pop())==null?void 0:n.toLowerCase())||""),(c.groupType==="image"||c.suffix&&z.has(c.suffix.toLowerCase())||c.raw&&typeof c.raw.type=="string"&&c.raw.type.startsWith("image/"))&&(c.groupType="image"),!i)){const u=typeof c.size=="number"?X(c.size):c.size||"";i=[c.suffix?c.suffix.toUpperCase():"",u].filter(Boolean).join(" · ")}return{...e,type:o,name:a,description:i,attachContent:c}}if(e.file_id||e.fileId)return Y(e);if(e.raw&&typeof Blob<"u"&&e.raw instanceof Blob){const o=H(e.raw);return{...o,...e,attachContent:{...o.attachContent,...e.attachContent}}}const t=e.name||e.title||"",r=t.includes(".")&&((s=t.split(".").pop())==null?void 0:s.toLowerCase())||"";return{type:e.type||"file",name:t,description:e.description||(r?r.toUpperCase():""),attachContent:{file_name:t,suffix:r,...e}}},Gt=24*60*60*1e3,Ft=(e,t,r=Date.now())=>{let n;if(typeof e=="number")n=e;else if(typeof e=="string"){const s=e.trim();if(!s)return null;n=/^\d+$/.test(s)?Number(s):Date.parse(s.replace(" ","T"))}else return null;return!Number.isFinite(n)||n<1e12||n>r+60*1e3||typeof t=="number"&&(n>t||t-n>Gt)?null:n},Xt=e=>typeof e=="number"&&Number.isFinite(e)&&e>=0,Yt=e=>{const t=typeof e=="number"&&Number.isFinite(e)&&e>0?e:0;if(t<1e3)return`${Math.round(t)}毫秒`;const r=Math.round(t/1e3);if(r<60)return`${r}秒`;const n=Math.floor(r%60),s=Math.floor(r/60);return s<60?`${s}分${String(n).padStart(2,"0")}秒`:`${Math.floor(s/60)}时${String(s%60).padStart(2,"0")}分`},M=e=>rt(e),Kt=async e=>[...(await e.getHistoryGroups()).groups??[]].sort((n,s)=>String(s.create_time??"").localeCompare(String(n.create_time??""))),Vt=async(e,t)=>{const r=await e.createHistoryGroup(t),n=(r==null?void 0:r.group_id)??(r==null?void 0:r.history_group_id)??"";if(!n)throw new Error("创建对话分组失败");return n},Jt=(e,t)=>e.deleteHistoryGroup(t),Zt=(e,t,r)=>e.setHistoryGroupTitle(t,r),nt=5,st=async(e,t,r)=>{const n=new Array(e.length);let s=0;const o=Array.from({length:Math.min(t,e.length)},async()=>{for(;s<e.length;){const a=s++;n[a]=await r(e[a],a)}});return await Promise.all(o),n},Qt=async(e,t,r=10,n=0,s)=>{if(!t)return[];const a=[...await e.getHistoryDetail(t,n,r)].sort((l,u)=>String(l.create_time||"").localeCompare(String(u.create_time||""))),i=await st(a,nt,async l=>{try{return await e.getHistoryAnswer(l.history_id||"")}catch{return null}}),c=[];return a.forEach((l,u)=>{const m=l.history_id||F("h"),d=i[u],f=d!=null?M(d):[];if(c.push({id:m,historyId:l.history_id,role:"user",content:l.question??"",attachments:f.length>0?f:void 0}),d!=null){const p=x(d,m,l.question??"",s);c.push({id:`${m}-answer`,historyId:l.history_id,role:"assistant",answer:p,error:!1,stopped:!1,runMs:S(p).runMs,thinking:{steps:P(p),expanded:!1}})}}),c},er=async(e,t,r=10,n,s=0,o)=>{if(!t)return n==null||n({type:"users",users:[]}),[];const i=[...await e.getHistoryDetail(t,s,r)].sort((d,f)=>String(d.create_time||"").localeCompare(String(f.create_time||""))),c=i.map(d=>d.history_id||F("h")),l=i.map((d,f)=>({id:c[f],historyId:d.history_id,role:"user",content:d.question??""}));n==null||n({type:"users",users:l});const u=new Array(i.length).fill(null);await st(i,nt,async(d,f)=>{let p=null;try{p=await e.getHistoryAnswer(d.history_id||"")}catch{p=null}if(p==null)return;const K=M(p);K.length>0&&(l[f].attachments=K);const O=x(p,c[f],d.question??"",o),V={id:`${c[f]}-answer`,historyId:d.history_id,role:"assistant",answer:O,error:!1,stopped:!1,runMs:S(O).runMs,thinking:{steps:P(O),expanded:!1}};u[f]=V,n==null||n({type:"assistant",index:f,user:l[f],assistant:V})});const m=[];return i.forEach((d,f)=>{m.push(l[f]);const p=u[f];p&&m.push(p)}),m},tr=async(e,t,r)=>{if(!t||!e.getShareChatJson)return[];const n=await e.getShareChatJson(t);if(!n)return[];const s=String(n.id??n.history_id??t),o=typeof n.question=="string"?n.question:"",a=x(n,s,o,r),i=[];if(o){const c=M({values:n});i.push({id:s,historyId:s,role:"user",content:o,attachments:c.length?c:void 0})}return i.push({id:`${s}-answer`,historyId:s,role:"assistant",answer:a,error:!1,stopped:!1,runMs:S(a).runMs,thinking:{steps:P(a),expanded:!1}}),i};exports.CHAT_TITLE_MAX_LENGTH=Qe;exports.COLLECT_CLARIFICATIONS_ANSWER_TYPE=I;exports.GENERIC_PARSERS=ge;exports.HOST_ACTION_ANSWER_TYPE=j;exports.IFRAME_RESIZER_CHILD_SCRIPT=lt;exports.IMAGE_EXTENSIONS=z;exports.OUTPUT_FILE_ANSWER_TYPE=E;exports.PRESENT_FILES_ANSWER_TYPE=v;exports.RECORDSET_ANSWER_TYPE=C;exports.RoleEnum=xt;exports.applyAnswerChunk=$t;exports.applyCollectClarificationsChunk=Be;exports.applyDeepThinkingChunk=ae;exports.applyHostActionChunk=Fe;exports.applyIframePageChunk=be;exports.applyKnowledgeStreamChunk=D;exports.applyOutputFileChunk=Re;exports.applyPresentFilesChunk=xe;exports.applyRecordsetChunk=Se;exports.basenameOf=je;exports.buildChatTitle=Dt;exports.cameraParser=pe;exports.cancelClarification=Et;exports.clearPendingClarifications=vt;exports.collectAnswerMarkdown=Pt;exports.collectClarificationsParser=Ge;exports.collectDeepThinkingSteps=ie;exports.collectThinkingSteps=P;exports.conclusionParser=Ke;exports.consumeStream=Ut;exports.createEmptyAnswerValues=re;exports.createFailureResult=w;exports.createHistoryGroup=Vt;exports.createLineSplitter=Ze;exports.createPassThroughParser=g;exports.deepThinkingParser=le;exports.deleteHistoryGroup=Jt;exports.deviceLastValueParser=fe;exports.expirePendingClarificationsForReply=At;exports.extractAttachmentsFromHistory=M;exports.extractHistoryAttachments=rt;exports.formatDuration=Yt;exports.formatFileSize=X;exports.getEffectiveAnswerType=_;exports.getHistoryGroups=Kt;exports.hasPendingClarification=_t;exports.hostActionParser=Ye;exports.iframePageParser=ve;exports.injectIframeResizerScript=q;exports.isImageAttachment=qt;exports.isValidDuration=Xt;exports.knowledgeStreamParser=se;exports.loadGroupMessages=Qt;exports.loadGroupMessagesByStep=er;exports.loadSharedMessages=tr;exports.markdownToPlainText=It;exports.mergeAnswerMeta=Rt;exports.nextClarificationRequestId=He;exports.nextLocalMessageId=F;exports.normalizeActionResult=Ne;exports.normalizeAnswer=x;exports.normalizeAnswerReport=Ve;exports.normalizeAttachment=Wt;exports.normalizeCollectClarificationsReport=We;exports.normalizeHostActionReport=Xe;exports.normalizeIframePageReport=Ee;exports.normalizeKnowledgeStreamReport=ne;exports.normalizeOutputFileReport=Pe;exports.normalizePresentFilesReport=Me;exports.normalizeRecordsetReport=ze;exports.outputFileParser=Ie;exports.parseActionExecuteCommand=ke;exports.parseClarificationArguments=Le;exports.parseHistoryAttachment=Y;exports.parseRealtimeAttachment=H;exports.parseServerStartTime=Ft;exports.parseSseLine=Je;exports.presentFilesParser=Oe;exports.readAnswerMeta=S;exports.readDefaultPayload=U;exports.readFrontReplyAction=G;exports.readOutputFilePayload=B;exports.readPresentFilesPayload=W;exports.readRecordsetPayload=Ae;exports.recordsetParser=Ce;exports.registerClarification=De;exports.resolveAttachDownloadUrl=tt;exports.resolveAttachPreviewUrl=Bt;exports.resolveRemoteFileUrl=et;exports.scriptParser=he;exports.setHistoryGroupTitle=Zt;exports.sqlQueryParser=de;exports.stripSetextUnderline=ce;exports.submitClarification=bt;exports.textParser=ue;exports.toOutputFileValue=$e;exports.videoParser=me;exports.wavParser=ye;exports.wrapActionFrame=pt;
|
|
3
7
|
//# sourceMappingURL=index.cjs.map
|
package/dist/parser/index.d.ts
CHANGED
|
@@ -15,6 +15,7 @@
|
|
|
15
15
|
* - `./answerCom/iframePage`:iframe 页面(applyIframePageChunk / 注入 child 脚本 / types)
|
|
16
16
|
* - `./answerCom/recordset`:记录集表格(applyRecordsetChunk / normalizeRecordsetReport / types)
|
|
17
17
|
* - `./answerCom/outputFile`:输出文件(applyOutputFileChunk / normalizeOutputFileReport / types)
|
|
18
|
+
* - `./answerCom/presentFiles`:多文件展示(present_files,values.files[] 归一成 OutputFileValue[])
|
|
18
19
|
* - `./answerCom/actionExecute`:front_reply 内的 action_execute 指令——
|
|
19
20
|
* agent 端 collect_clarifications(确认卡片)/ host 端命令执行过程(进度卡片)
|
|
20
21
|
* - `./deepThinking`:思考(applyDeepThinkingChunk / collectDeepThinkingSteps / types)
|
|
@@ -43,14 +44,22 @@ export { RECORDSET_ANSWER_TYPE, readRecordsetPayload, applyRecordsetChunk, norma
|
|
|
43
44
|
export type { RecordsetColumn, RecordsetValue } from './answerCom/recordset/types';
|
|
44
45
|
export { OUTPUT_FILE_ANSWER_TYPE, readOutputFilePayload, applyOutputFileChunk, normalizeOutputFileReport, outputFileParser } from './answerCom/outputFile/parseOutputFile';
|
|
45
46
|
export type { OutputFileValue } from './answerCom/outputFile/types';
|
|
47
|
+
export { PRESENT_FILES_ANSWER_TYPE, basenameOf, toOutputFileValue, readPresentFilesPayload, applyPresentFilesChunk, normalizePresentFilesReport, presentFilesParser } from './answerCom/presentFiles/parsePresentFiles';
|
|
48
|
+
export type { PresentFileItem, PresentFilesValue } from './answerCom/presentFiles/types';
|
|
46
49
|
export { COLLECT_CLARIFICATIONS_ANSWER_TYPE, applyCollectClarificationsChunk, normalizeCollectClarificationsReport, collectClarificationsParser } from './answerCom/actionExecute/parseCollectClarifications';
|
|
47
50
|
export { HOST_ACTION_ANSWER_TYPE, applyHostActionChunk, normalizeHostActionReport, hostActionParser } from './answerCom/actionExecute/parseHostAction';
|
|
48
|
-
export { createFailureResult, normalizeActionResult, parseActionExecuteCommand, wrapActionFrame,
|
|
51
|
+
export { createFailureResult, normalizeActionResult, parseActionExecuteCommand, wrapActionFrame, readFrontReplyAction } from './answerCom/actionExecute/actionProtocol';
|
|
49
52
|
export type { FrontReplyActionResult } from './answerCom/actionExecute/actionProtocol';
|
|
50
|
-
export { parseClarificationArguments, nextClarificationRequestId, registerClarification, hasPendingClarification, submitClarification, cancelClarification, clearPendingClarifications } from './answerCom/actionExecute/clarification';
|
|
53
|
+
export { parseClarificationArguments, nextClarificationRequestId, registerClarification, hasPendingClarification, submitClarification, cancelClarification, clearPendingClarifications, expirePendingClarificationsForReply } from './answerCom/actionExecute/clarification';
|
|
51
54
|
export type { ParsedClarificationArguments } from './answerCom/actionExecute/clarification';
|
|
52
55
|
export type { ActionExecutor, ActionDefinition, ActionExecuteCommand, ActionResult, WaitReplyPayload, ActionExecuteOptions, HostActionState, HostActionValue, ClarificationInputType, ClarificationAnswerMode, ClarificationOption, ClarificationBinding, ClarificationInput, ClarificationItem, ClarificationAnswer, ClarificationStatus, ClarificationViewModel, } from './answerCom/actionExecute/types';
|
|
53
|
-
export {
|
|
56
|
+
export { getEffectiveAnswerType, readDefaultPayload, createPassThroughParser, textParser, sqlQueryParser, deviceLastValueParser, cameraParser, videoParser, wavParser, scriptParser, GENERIC_PARSERS, } from './answerCom/generic/parseGeneric';
|
|
57
|
+
export type { PassThroughParserOptions } from './answerCom/generic/parseGeneric';
|
|
58
|
+
export type { SqlQueryValue, DeviceLastValueRow, DeviceLastValueItem, DeviceLastValueValue, CameraItem, CameraValue, VideoValue, WavValue, ScriptValue, } from './answerCom/generic/types';
|
|
59
|
+
export { parseServerStartTime, formatDuration, isValidDuration } from './runTime';
|
|
60
|
+
export { readAnswerMeta, mergeAnswerMeta, conclusionParser, collectAnswerMarkdown, markdownToPlainText } from './answerMeta';
|
|
61
|
+
export type { AnswerMeta, AnswerConclusion, AnswerContextHistory } from './answerMeta';
|
|
62
|
+
export { applyDeepThinkingChunk, collectDeepThinkingSteps, collectThinkingSteps, deepThinkingParser, stripSetextUnderline } from './deepThinking/parseDeepThinking';
|
|
54
63
|
export type { ExecProcessItem } from './deepThinking/types';
|
|
55
|
-
export { extractAttachmentsFromHistory, getHistoryGroups, createHistoryGroup, deleteHistoryGroup, setHistoryGroupTitle, loadGroupMessages, loadGroupMessagesByStep } from './history';
|
|
64
|
+
export { extractAttachmentsFromHistory, getHistoryGroups, createHistoryGroup, deleteHistoryGroup, setHistoryGroupTitle, loadGroupMessages, loadGroupMessagesByStep, loadSharedMessages } from './history';
|
|
56
65
|
export type { GroupMessagesProgress, HistoryGroup } from './history';
|