wi-chat 0.6.2 → 0.7.1

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.
Files changed (79) hide show
  1. package/dist/core/index.cjs +1 -1
  2. package/dist/core/index.d.ts +12 -0
  3. package/dist/core/index.js +921 -342
  4. package/dist/core/useAnswerActions.d.ts +61 -0
  5. package/dist/core/useChat.d.ts +29 -3
  6. package/dist/core/useChatAuth.d.ts +175 -0
  7. package/dist/core/useChatRooms.d.ts +66 -0
  8. package/dist/core/useKeepAlive.d.ts +41 -0
  9. package/dist/core/useLlm.d.ts +73 -0
  10. package/dist/core/useRunningGroups.d.ts +58 -0
  11. package/dist/index.cjs +1 -1
  12. package/dist/index.d.ts +3 -1
  13. package/dist/index.js +119 -108
  14. package/dist/mobile-ui/chat/ChatContainer.vue.d.ts +3 -3
  15. package/dist/mobile-ui/inputbox/Inputbox.vue.d.ts +1 -1
  16. package/dist/parser/answerCom/generic/parseGeneric.d.ts +52 -0
  17. package/dist/parser/answerCom/generic/types.d.ts +75 -0
  18. package/dist/parser/answerCom/outputFile/parseOutputFile.d.ts +7 -6
  19. package/dist/parser/answerCom/outputFile/types.d.ts +15 -5
  20. package/dist/parser/answerCom/presentFiles/parsePresentFiles.d.ts +58 -0
  21. package/dist/parser/answerCom/presentFiles/types.d.ts +27 -0
  22. package/dist/parser/answerMeta.d.ts +71 -0
  23. package/dist/parser/deepThinking/parseDeepThinking.d.ts +8 -0
  24. package/dist/parser/history/history.d.ts +9 -0
  25. package/dist/parser/history/index.d.ts +1 -1
  26. package/dist/parser/index.cjs +6 -2
  27. package/dist/parser/index.d.ts +11 -2
  28. package/dist/parser/index.js +591 -366
  29. package/dist/parser/message.d.ts +9 -0
  30. package/dist/parser/runTime.d.ts +29 -0
  31. package/dist/renderers/TextAnswer-BgKGvG_o.cjs +2 -0
  32. package/dist/renderers/TextAnswer-PQwV3K7v.js +5 -0
  33. package/dist/renderers/answerCard/AnswerCard.vue.d.ts +65 -0
  34. package/dist/renderers/answerCard/AnswerToolbar.vue.d.ts +42 -0
  35. package/dist/renderers/answerConfig.d.ts +33 -0
  36. package/dist/renderers/deviceLastValue/DeviceLastValue.vue.d.ts +37 -0
  37. package/dist/renderers/index.cjs +6 -1
  38. package/dist/renderers/index.d.ts +14 -0
  39. package/dist/renderers/index.js +1485 -574
  40. package/dist/renderers/media/MediaAnswer.vue.d.ts +19 -0
  41. package/dist/renderers/outputFile/OutputFileLink.vue.d.ts +19 -0
  42. package/dist/renderers/outputFile/localFile.d.ts +46 -0
  43. package/dist/renderers/outputFile/useOutputFile.d.ts +32 -3
  44. package/dist/renderers/presentFiles/PresentFiles.vue.d.ts +19 -0
  45. package/dist/renderers/recordset/RecordsetView.vue.d.ts +19 -0
  46. package/dist/renderers/sqlQuery/SqlQuery.vue.d.ts +19 -0
  47. package/dist/renderers/style.css +1 -1
  48. package/dist/renderers/text/TextAnswer.vue.d.ts +19 -0
  49. package/dist/request/api.d.ts +121 -1
  50. package/dist/request/client.d.ts +12 -0
  51. package/dist/request/index.cjs +4 -2
  52. package/dist/request/index.d.ts +6 -4
  53. package/dist/request/index.js +780 -179
  54. package/dist/request/login.d.ts +36 -0
  55. package/dist/request/ws.d.ts +11 -86
  56. package/dist/request/wsCore.d.ts +104 -0
  57. package/dist/request/wsSession.d.ts +353 -0
  58. package/dist/right-panel/RightPanelTabs.vue.d.ts +4 -0
  59. package/dist/right-panel/index.cjs +1 -1
  60. package/dist/right-panel/index.d.ts +1 -1
  61. package/dist/right-panel/index.js +598 -499
  62. package/dist/right-panel/style.css +1 -1
  63. package/dist/right-panel/types.d.ts +10 -0
  64. package/dist/tools/index.cjs +5 -5
  65. package/dist/tools/index.d.ts +2 -2
  66. package/dist/tools/index.js +323 -208
  67. package/dist/tools/markdown/index.d.ts +2 -0
  68. package/dist/tools/markdown/interactions.d.ts +39 -0
  69. package/dist/tools/markdown/sanitize.d.ts +6 -0
  70. package/dist/tools/style.css +1 -1
  71. package/dist/web-ui/attach/AttachmentCard.vue.d.ts +1 -1
  72. package/dist/web-ui/attach/AttachmentList.vue.d.ts +1 -1
  73. package/dist/web-ui/chat/ChatContainer.vue.d.ts +5 -5
  74. package/dist/web-ui/envswitch/EnvSwitch.vue.d.ts +1 -1
  75. package/dist/web-ui/index.cjs +1 -1
  76. package/dist/web-ui/index.js +1 -1
  77. package/dist/web-ui/inputbox/Inputbox.vue.d.ts +5 -5
  78. package/dist/web-ui/style.css +1 -1
  79. package/package.json +2 -2
package/dist/index.js CHANGED
@@ -1,114 +1,125 @@
1
1
  import "wi-chat/style.css";
2
- import { AuthExpiredError as a, buildChatWsUrl as o, createChatApi as i, createRequest as n, fileToBase64 as l, formDataToJson as s, isCancelError as p, login as c, openChatWebSocketStream as m, pwdEncrypt as A, resolveMessageData as C, sendPayloadInChunks as u } from "wi-chat/request";
3
- import { CHAT_TITLE_MAX_LENGTH as T, COLLECT_CLARIFICATIONS_ANSWER_TYPE as R, HOST_ACTION_ANSWER_TYPE as g, IFRAME_RESIZER_CHILD_SCRIPT as h, IMAGE_EXTENSIONS as d, OUTPUT_FILE_ANSWER_TYPE as P, RECORDSET_ANSWER_TYPE as S, RoleEnum as _, applyAnswerChunk as y, applyCollectClarificationsChunk as I, applyDeepThinkingChunk as f, applyHostActionChunk as x, applyIframePageChunk as k, applyKnowledgeStreamChunk as w, applyOutputFileChunk as F, applyRecordsetChunk as H, buildChatTitle as O, cancelClarification as z, clearPendingClarifications as L, collectClarificationsParser as N, collectDeepThinkingSteps as G, collectThinkingSteps as M, consumeStream as D, createEmptyAnswerValues as v, createFailureResult as U, createHistoryGroup as W, createLineSplitter as Y, deepThinkingParser as X, deleteHistoryGroup as b, expirePendingClarificationsForReply as B, extractAttachmentsFromHistory as K, extractHistoryAttachments as q, formatFileSize as V, getHistoryGroups as j, hasPendingClarification as J, hostActionParser as Z, iframePageParser as Q, injectIframeResizerScript as $, isImageAttachment as ee, knowledgeStreamParser as te, loadGroupMessages as re, loadGroupMessagesByStep as ae, nextClarificationRequestId as oe, nextLocalMessageId as ie, normalizeActionResult as ne, normalizeAnswer as le, normalizeAnswerReport as se, normalizeAttachment as pe, normalizeCollectClarificationsReport as ce, normalizeHostActionReport as me, normalizeIframePageReport as Ae, normalizeKnowledgeStreamReport as Ce, normalizeOutputFileReport as ue, normalizeRecordsetReport as Ee, outputFileParser as Te, parseActionExecuteCommand as Re, parseClarificationArguments as ge, parseHistoryAttachment as he, parseRealtimeAttachment as de, parseSseLine as Pe, readFrontReplyAction as Se, readOutputFilePayload as _e, readRecordsetPayload as ye, recordsetParser as Ie, registerClarification as fe, resolveAttachDownloadUrl as xe, resolveAttachPreviewUrl as ke, resolveRemoteFileUrl as we, setHistoryGroupTitle as Fe, submitClarification as He, wrapActionFrame as Oe } from "wi-chat/parser";
4
- import { AGENT_TABLE_STATE_ROW_LIMIT as Le, PAGE_CONTEXT_EXT_ARGS_KEY as Ne, PAGE_CONTEXT_SCHEMA_VERSION as Ge, createPageContext as Me, isAgentPageContext as De, normalizeAgentPageState as ve, parsePageContextExtArgs as Ue, toPageContextExtArgs as We } from "wi-chat/page-context";
5
- import { DEFAULT_PRIMARY as Xe, applyTheme as be, createChatTheme as Be } from "wi-chat/theme";
6
- import { useAgent as qe, useChat as Ve, useChatSession as je, useHistory as Je } from "wi-chat/core";
7
- import { closeImagePreview as Qe, createStyleScope as $e, downloadAttachment as et, openImagePreview as tt, renderMarkdown as rt, useAutoScroll as at } from "wi-chat/tools";
2
+ import { AuthExpiredError as a, buildChatWsUrl as o, buildConnectFrame as i, chatWsRegistry as n, createChatApi as s, createChatWsFallback as l, createChatWsRegistry as c, createChunkSender as p, createRequest as C, defaultBuildHistoryAnswerPayload as m, defaultHasHistoryAnswerContent as A, fileToBase64 as u, formDataToJson as h, isCancelError as E, login as d, openChatWebSocketStream as T, openChatWsSessionStream as R, pickChatTaskList as S, pickHistoryId as g, pwdEncrypt as P, resolveMessageData as y, sendPayloadInChunks as _, startChatWsSession as f } from "wi-chat/request";
3
+ import { CHAT_TITLE_MAX_LENGTH as k, COLLECT_CLARIFICATIONS_ANSWER_TYPE as x, HOST_ACTION_ANSWER_TYPE as H, IFRAME_RESIZER_CHILD_SCRIPT as w, IMAGE_EXTENSIONS as F, OUTPUT_FILE_ANSWER_TYPE as L, RECORDSET_ANSWER_TYPE as O, RoleEnum as z, applyAnswerChunk as N, applyCollectClarificationsChunk as G, applyDeepThinkingChunk as W, applyHostActionChunk as M, applyIframePageChunk as D, applyKnowledgeStreamChunk as v, applyOutputFileChunk as U, applyRecordsetChunk as b, buildChatTitle as Y, cancelClarification as X, clearPendingClarifications as B, collectClarificationsParser as K, collectDeepThinkingSteps as q, collectThinkingSteps as V, consumeStream as j, createEmptyAnswerValues as J, createFailureResult as Z, createHistoryGroup as Q, createLineSplitter as $, deepThinkingParser as ee, deleteHistoryGroup as te, expirePendingClarificationsForReply as re, extractAttachmentsFromHistory as ae, extractHistoryAttachments as oe, formatFileSize as ie, getHistoryGroups as ne, hasPendingClarification as se, hostActionParser as le, iframePageParser as ce, injectIframeResizerScript as pe, isImageAttachment as Ce, knowledgeStreamParser as me, loadGroupMessages as Ae, loadGroupMessagesByStep as ue, nextClarificationRequestId as he, nextLocalMessageId as Ee, normalizeActionResult as de, normalizeAnswer as Te, normalizeAnswerReport as Re, normalizeAttachment as Se, normalizeCollectClarificationsReport as ge, normalizeHostActionReport as Pe, normalizeIframePageReport as ye, normalizeKnowledgeStreamReport as _e, normalizeOutputFileReport as fe, normalizeRecordsetReport as Ie, outputFileParser as ke, parseActionExecuteCommand as xe, parseClarificationArguments as He, parseHistoryAttachment as we, parseRealtimeAttachment as Fe, parseSseLine as Le, readFrontReplyAction as Oe, readOutputFilePayload as ze, readRecordsetPayload as Ne, recordsetParser as Ge, registerClarification as We, resolveAttachDownloadUrl as Me, resolveAttachPreviewUrl as De, resolveRemoteFileUrl as ve, setHistoryGroupTitle as Ue, submitClarification as be, wrapActionFrame as Ye } from "wi-chat/parser";
4
+ import { AGENT_TABLE_STATE_ROW_LIMIT as Be, PAGE_CONTEXT_EXT_ARGS_KEY as Ke, PAGE_CONTEXT_SCHEMA_VERSION as qe, createPageContext as Ve, isAgentPageContext as je, normalizeAgentPageState as Je, parsePageContextExtArgs as Ze, toPageContextExtArgs as Qe } from "wi-chat/page-context";
5
+ import { DEFAULT_PRIMARY as et, applyTheme as tt, createChatTheme as rt } from "wi-chat/theme";
6
+ import { useAgent as ot, useChat as it, useChatSession as nt, useHistory as st } from "wi-chat/core";
7
+ import { closeImagePreview as ct, createStyleScope as pt, downloadAttachment as Ct, openImagePreview as mt, renderMarkdown as At, useAutoScroll as ut } from "wi-chat/tools";
8
8
  export {
9
- Le as AGENT_TABLE_STATE_ROW_LIMIT,
9
+ Be as AGENT_TABLE_STATE_ROW_LIMIT,
10
10
  a as AuthExpiredError,
11
- T as CHAT_TITLE_MAX_LENGTH,
12
- R as COLLECT_CLARIFICATIONS_ANSWER_TYPE,
13
- Xe as DEFAULT_PRIMARY,
14
- g as HOST_ACTION_ANSWER_TYPE,
15
- h as IFRAME_RESIZER_CHILD_SCRIPT,
16
- d as IMAGE_EXTENSIONS,
17
- P as OUTPUT_FILE_ANSWER_TYPE,
18
- Ne as PAGE_CONTEXT_EXT_ARGS_KEY,
19
- Ge as PAGE_CONTEXT_SCHEMA_VERSION,
20
- S as RECORDSET_ANSWER_TYPE,
21
- _ as RoleEnum,
22
- y as applyAnswerChunk,
23
- I as applyCollectClarificationsChunk,
24
- f as applyDeepThinkingChunk,
25
- x as applyHostActionChunk,
26
- k as applyIframePageChunk,
27
- w as applyKnowledgeStreamChunk,
28
- F as applyOutputFileChunk,
29
- H as applyRecordsetChunk,
30
- be as applyTheme,
31
- O as buildChatTitle,
11
+ k as CHAT_TITLE_MAX_LENGTH,
12
+ x as COLLECT_CLARIFICATIONS_ANSWER_TYPE,
13
+ et as DEFAULT_PRIMARY,
14
+ H as HOST_ACTION_ANSWER_TYPE,
15
+ w as IFRAME_RESIZER_CHILD_SCRIPT,
16
+ F as IMAGE_EXTENSIONS,
17
+ L as OUTPUT_FILE_ANSWER_TYPE,
18
+ Ke as PAGE_CONTEXT_EXT_ARGS_KEY,
19
+ qe as PAGE_CONTEXT_SCHEMA_VERSION,
20
+ O as RECORDSET_ANSWER_TYPE,
21
+ z as RoleEnum,
22
+ N as applyAnswerChunk,
23
+ G as applyCollectClarificationsChunk,
24
+ W as applyDeepThinkingChunk,
25
+ M as applyHostActionChunk,
26
+ D as applyIframePageChunk,
27
+ v as applyKnowledgeStreamChunk,
28
+ U as applyOutputFileChunk,
29
+ b as applyRecordsetChunk,
30
+ tt as applyTheme,
31
+ Y as buildChatTitle,
32
32
  o as buildChatWsUrl,
33
- z as cancelClarification,
34
- L as clearPendingClarifications,
35
- Qe as closeImagePreview,
36
- N as collectClarificationsParser,
37
- G as collectDeepThinkingSteps,
38
- M as collectThinkingSteps,
39
- D as consumeStream,
40
- i as createChatApi,
41
- Be as createChatTheme,
42
- v as createEmptyAnswerValues,
43
- U as createFailureResult,
44
- W as createHistoryGroup,
45
- Y as createLineSplitter,
46
- Me as createPageContext,
47
- n as createRequest,
48
- $e as createStyleScope,
49
- X as deepThinkingParser,
50
- b as deleteHistoryGroup,
51
- et as downloadAttachment,
52
- B as expirePendingClarificationsForReply,
53
- K as extractAttachmentsFromHistory,
54
- q as extractHistoryAttachments,
55
- l as fileToBase64,
56
- s as formDataToJson,
57
- V as formatFileSize,
58
- j as getHistoryGroups,
59
- J as hasPendingClarification,
60
- Z as hostActionParser,
61
- Q as iframePageParser,
62
- $ as injectIframeResizerScript,
63
- De as isAgentPageContext,
64
- p as isCancelError,
65
- ee as isImageAttachment,
66
- te as knowledgeStreamParser,
67
- re as loadGroupMessages,
68
- ae as loadGroupMessagesByStep,
69
- c as login,
70
- oe as nextClarificationRequestId,
71
- ie as nextLocalMessageId,
72
- ne as normalizeActionResult,
73
- ve as normalizeAgentPageState,
74
- le as normalizeAnswer,
75
- se as normalizeAnswerReport,
76
- pe as normalizeAttachment,
77
- ce as normalizeCollectClarificationsReport,
78
- me as normalizeHostActionReport,
79
- Ae as normalizeIframePageReport,
80
- Ce as normalizeKnowledgeStreamReport,
81
- ue as normalizeOutputFileReport,
82
- Ee as normalizeRecordsetReport,
83
- m as openChatWebSocketStream,
84
- tt as openImagePreview,
85
- Te as outputFileParser,
86
- Re as parseActionExecuteCommand,
87
- ge as parseClarificationArguments,
88
- he as parseHistoryAttachment,
89
- Ue as parsePageContextExtArgs,
90
- de as parseRealtimeAttachment,
91
- Pe as parseSseLine,
92
- A as pwdEncrypt,
93
- Se as readFrontReplyAction,
94
- _e as readOutputFilePayload,
95
- ye as readRecordsetPayload,
96
- Ie as recordsetParser,
97
- fe as registerClarification,
98
- rt as renderMarkdown,
99
- xe as resolveAttachDownloadUrl,
100
- ke as resolveAttachPreviewUrl,
101
- C as resolveMessageData,
102
- we as resolveRemoteFileUrl,
103
- u as sendPayloadInChunks,
104
- Fe as setHistoryGroupTitle,
105
- He as submitClarification,
106
- We as toPageContextExtArgs,
107
- qe as useAgent,
108
- at as useAutoScroll,
109
- Ve as useChat,
110
- je as useChatSession,
111
- Je as useHistory,
112
- Oe as wrapActionFrame
33
+ i as buildConnectFrame,
34
+ X as cancelClarification,
35
+ n as chatWsRegistry,
36
+ B as clearPendingClarifications,
37
+ ct as closeImagePreview,
38
+ K as collectClarificationsParser,
39
+ q as collectDeepThinkingSteps,
40
+ V as collectThinkingSteps,
41
+ j as consumeStream,
42
+ s as createChatApi,
43
+ rt as createChatTheme,
44
+ l as createChatWsFallback,
45
+ c as createChatWsRegistry,
46
+ p as createChunkSender,
47
+ J as createEmptyAnswerValues,
48
+ Z as createFailureResult,
49
+ Q as createHistoryGroup,
50
+ $ as createLineSplitter,
51
+ Ve as createPageContext,
52
+ C as createRequest,
53
+ pt as createStyleScope,
54
+ ee as deepThinkingParser,
55
+ m as defaultBuildHistoryAnswerPayload,
56
+ A as defaultHasHistoryAnswerContent,
57
+ te as deleteHistoryGroup,
58
+ Ct as downloadAttachment,
59
+ re as expirePendingClarificationsForReply,
60
+ ae as extractAttachmentsFromHistory,
61
+ oe as extractHistoryAttachments,
62
+ u as fileToBase64,
63
+ h as formDataToJson,
64
+ ie as formatFileSize,
65
+ ne as getHistoryGroups,
66
+ se as hasPendingClarification,
67
+ le as hostActionParser,
68
+ ce as iframePageParser,
69
+ pe as injectIframeResizerScript,
70
+ je as isAgentPageContext,
71
+ E as isCancelError,
72
+ Ce as isImageAttachment,
73
+ me as knowledgeStreamParser,
74
+ Ae as loadGroupMessages,
75
+ ue as loadGroupMessagesByStep,
76
+ d as login,
77
+ he as nextClarificationRequestId,
78
+ Ee as nextLocalMessageId,
79
+ de as normalizeActionResult,
80
+ Je as normalizeAgentPageState,
81
+ Te as normalizeAnswer,
82
+ Re as normalizeAnswerReport,
83
+ Se as normalizeAttachment,
84
+ ge as normalizeCollectClarificationsReport,
85
+ Pe as normalizeHostActionReport,
86
+ ye as normalizeIframePageReport,
87
+ _e as normalizeKnowledgeStreamReport,
88
+ fe as normalizeOutputFileReport,
89
+ Ie as normalizeRecordsetReport,
90
+ T as openChatWebSocketStream,
91
+ R as openChatWsSessionStream,
92
+ mt as openImagePreview,
93
+ ke as outputFileParser,
94
+ xe as parseActionExecuteCommand,
95
+ He as parseClarificationArguments,
96
+ we as parseHistoryAttachment,
97
+ Ze as parsePageContextExtArgs,
98
+ Fe as parseRealtimeAttachment,
99
+ Le as parseSseLine,
100
+ S as pickChatTaskList,
101
+ g as pickHistoryId,
102
+ P as pwdEncrypt,
103
+ Oe as readFrontReplyAction,
104
+ ze as readOutputFilePayload,
105
+ Ne as readRecordsetPayload,
106
+ Ge as recordsetParser,
107
+ We as registerClarification,
108
+ At as renderMarkdown,
109
+ Me as resolveAttachDownloadUrl,
110
+ De as resolveAttachPreviewUrl,
111
+ y as resolveMessageData,
112
+ ve as resolveRemoteFileUrl,
113
+ _ as sendPayloadInChunks,
114
+ Ue as setHistoryGroupTitle,
115
+ f as startChatWsSession,
116
+ be as submitClarification,
117
+ Qe as toPageContextExtArgs,
118
+ ot as useAgent,
119
+ ut as useAutoScroll,
120
+ it as useChat,
121
+ nt as useChatSession,
122
+ st as useHistory,
123
+ Ye as wrapActionFrame
113
124
  };
114
125
  //# sourceMappingURL=index.js.map
@@ -94,12 +94,12 @@ declare const _default: __VLS_WithTemplateSlots<import('vue').DefineComponent<im
94
94
  parsers: AnswerParser<any>[];
95
95
  loading: boolean;
96
96
  disabled: boolean;
97
+ session: string;
97
98
  messages: Message[];
98
- emptyTitle: string;
99
- emptyDescription: string;
100
99
  talking: boolean;
101
- session: string;
102
100
  hasMore: boolean;
101
+ emptyTitle: string;
102
+ emptyDescription: string;
103
103
  }, {}, {}, {}, string, import('vue').ComponentProvideOptions, true, {}, any>, {
104
104
  messages?(_: {}): any;
105
105
  "above-input"?(_: {}): any;
@@ -67,12 +67,12 @@ declare const _default: import('vue').DefineComponent<import('vue').ExtractPropT
67
67
  }>, {
68
68
  placeholder: string;
69
69
  disabled: boolean;
70
+ talking: boolean;
70
71
  modelValue: string;
71
72
  disabledSend: boolean;
72
73
  enterExact: boolean;
73
74
  submitText: string;
74
75
  stopText: string;
75
- talking: boolean;
76
76
  buttonType: 'primary' | 'danger' | 'success';
77
77
  }, {}, {}, {}, string, import('vue').ComponentProvideOptions, true, {}, any>;
78
78
  export default _default;
@@ -0,0 +1,52 @@
1
+ import { AnswerParser } from '../../registry';
2
+ import { CameraValue, DeviceLastValueValue, ScriptValue, SqlQueryValue, VideoValue, WavValue } from './types';
3
+
4
+ /**
5
+ * 取载荷的有效回答类型(`type` 存在时覆盖 `answer_type`,与后端 result 帧语义一致)
6
+ * @param value result 帧载荷或历史 report
7
+ * @returns 有效类型(取不到为空串)
8
+ */
9
+ export declare const getEffectiveAnswerType: (value: any) => string;
10
+ /**
11
+ * 默认载荷读取:`values` 存在即用;否则把顶层业务字段收拢成对象(空对象视为无载荷)
12
+ * @param value result 帧载荷或历史 report
13
+ * @returns 业务载荷;取不到时 undefined
14
+ */
15
+ export declare const readDefaultPayload: (value: any) => any;
16
+ /** 通用透传 parser 的构造参数 */
17
+ export interface PassThroughParserOptions<T> {
18
+ /** 回答类型(同时作为 parser id 与历史分发键) */
19
+ answerType: string;
20
+ /**
21
+ * 载荷读取(实时与历史共用),缺省 `readDefaultPayload`
22
+ * @param value result 帧载荷或历史 report
23
+ * @returns 归一后的 values;undefined 表示无内容(实时不产出报告、历史不改写)
24
+ */
25
+ readPayload?: (value: any) => T | undefined;
26
+ }
27
+ /**
28
+ * 构造一个「result 整包下发、无流式累积」的回答类型 parser
29
+ * @param options 回答类型与载荷读取方式
30
+ * @returns 可注册进 registry 的 AnswerParser
31
+ */
32
+ export declare const createPassThroughParser: <T = any>(options: PassThroughParserOptions<T>) => AnswerParser<T>;
33
+ /**
34
+ * text:Markdown 纯文本回答(`values` 或 `answer` 字段为字符串)
35
+ */
36
+ export declare const textParser: AnswerParser<string>;
37
+ /**
38
+ * sql_query:可执行 SQL(`values` 或旧字段 `sql_query` 中的 `{ sql, ds_id }`)
39
+ */
40
+ export declare const sqlQueryParser: AnswerParser<SqlQueryValue>;
41
+ /** device_last_value:设备最新值矩阵(rows × values) */
42
+ export declare const deviceLastValueParser: AnswerParser<DeviceLastValueValue>;
43
+ /** camera:监控画面(res_id + cameras[]) */
44
+ export declare const cameraParser: AnswerParser<CameraValue>;
45
+ /** video:录像文件(model_id + file_id) */
46
+ export declare const videoParser: AnswerParser<VideoValue>;
47
+ /** wav:声音(噪声)分析(noise_id,可选 file_id) */
48
+ export declare const wavParser: AnswerParser<WavValue>;
49
+ /** script:脚本模式(values 收拢复用默认规则,幂等:重复 normalize 不会嵌套) */
50
+ export declare const scriptParser: AnswerParser<ScriptValue>;
51
+ /** 本模块提供的全部内置透传 parser(registry 按此顺序注册) */
52
+ export declare const GENERIC_PARSERS: AnswerParser[];
@@ -0,0 +1,75 @@
1
+ /**
2
+ * 通用透传型回答类型的 values 结构定义(text / sql_query / device_last_value / camera / video / wav / script)
3
+ */
4
+ /** sql_query 的 values */
5
+ export interface SqlQueryValue {
6
+ /** 待执行的 SQL 文本 */
7
+ sql: string;
8
+ /** 数据源 id(执行时回传给后端) */
9
+ ds_id?: string;
10
+ }
11
+ /** device_last_value 的行定义(一行 = 一个监测指标) */
12
+ export interface DeviceLastValueRow {
13
+ /** 指标键:在 values 每项中以该键取 `{ OVALUE }` */
14
+ id: string;
15
+ /** 指标标题 */
16
+ title: string;
17
+ /** 单位(可选) */
18
+ unit?: string;
19
+ [key: string]: any;
20
+ }
21
+ /** device_last_value 的单个设备列 */
22
+ export interface DeviceLastValueItem {
23
+ /** 设备类型 */
24
+ OTYPE?: string;
25
+ /** 设备编号 */
26
+ ONAME?: string;
27
+ /** 设备标题(列头) */
28
+ OTITLE?: string;
29
+ /** 数据时间 */
30
+ OTIME?: string;
31
+ /** 其余字段:以 row.id 为键,值形如 `{ OVALUE }` */
32
+ [key: string]: any;
33
+ }
34
+ /** device_last_value 的 values */
35
+ export interface DeviceLastValueValue {
36
+ /** 表格标题 */
37
+ title?: string;
38
+ /** 指标行 */
39
+ rows: DeviceLastValueRow[];
40
+ /** 设备列 */
41
+ values: DeviceLastValueItem[];
42
+ }
43
+ /** camera 的单个摄像头 */
44
+ export interface CameraItem {
45
+ /** 资源 id */
46
+ res_id?: string;
47
+ /** 抓拍 / 截图文件 id */
48
+ file_id?: string;
49
+ /** 摄像头名称 */
50
+ name?: string;
51
+ [key: string]: any;
52
+ }
53
+ /** camera 的 values */
54
+ export interface CameraValue {
55
+ /** 资源 id(多个以逗号分隔) */
56
+ res_id?: string;
57
+ /** 摄像头列表 */
58
+ cameras: CameraItem[];
59
+ }
60
+ /** video 的 values */
61
+ export interface VideoValue {
62
+ /** 视频模型 / 资源 id */
63
+ model_id?: string;
64
+ /** 视频文件 id */
65
+ file_id?: string;
66
+ }
67
+ /** wav 的 values */
68
+ export interface WavValue {
69
+ /** 噪声分析记录 id */
70
+ noise_id?: string;
71
+ /** 音频文件 id */
72
+ file_id?: string;
73
+ }
74
+ /** script 的 values(整份回答对象原样保留) */
75
+ export type ScriptValue = Record<string, any>;
@@ -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 已有 file_id / file_name(实时累积或此前已标准化)时原样跳过;
32
- * 两处都取不到时不改写 values(不造空结构)。
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
- * 后端在本地电脑模式下执行 sys_write_file 等操作后,会下发
5
- * `answer_type = 'output_file'` 的 result 报告:
6
- * `{ values: { file_id, file_name }, answer_type: 'output_file', ... }`。
7
- * 渲染层据此展示文件卡片,点击后按文件类型预览(文本 / 图片 / PDF / HTML / 音视频)。
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 原样保留、无需归一化),