chatlab-cli 0.35.0 → 0.36.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/{chat-command-24RYGJAS.mjs → chat-command-SXW67RF7.mjs} +9 -9
- package/dist/{chunk-4GWWKHWA.mjs → chunk-4YPNYQSP.mjs} +672 -7064
- package/dist/chunk-4YPNYQSP.mjs.map +1 -0
- package/dist/{chunk-KXDJ7N6N.mjs → chunk-AAGDVTP2.mjs} +2 -2
- package/dist/{chunk-7IGBPZMI.mjs → chunk-BSGLH6G3.mjs} +163 -36
- package/dist/chunk-BSGLH6G3.mjs.map +1 -0
- package/dist/{chunk-ZBPPLXM4.mjs → chunk-CNEWMCGX.mjs} +18 -18
- package/dist/{chunk-QKEARRFH.mjs → chunk-GVW3BDGZ.mjs} +3 -3
- package/dist/{chunk-BRZ6YIBR.mjs → chunk-JHON5FN7.mjs} +2 -2
- package/dist/{chunk-DEFEU567.mjs → chunk-LZGOIRLV.mjs} +8 -10
- package/dist/{chunk-DEFEU567.mjs.map → chunk-LZGOIRLV.mjs.map} +1 -1
- package/dist/chunk-OWOEWZIC.mjs +19072 -0
- package/dist/chunk-OWOEWZIC.mjs.map +1 -0
- package/dist/{chunk-DC7IUDNV.mjs → chunk-U2NXHIJK.mjs} +27 -9
- package/dist/chunk-U2NXHIJK.mjs.map +1 -0
- package/dist/{chunk-U36TQMAF.mjs → chunk-UNIKQFI5.mjs} +2 -2
- package/dist/{chunk-GQMCDWZQ.mjs → chunk-VDWI4A4U.mjs} +2 -2
- package/dist/{chunk-KIMJXKZO.mjs → chunk-XDF6PMVZ.mjs} +2 -2
- package/dist/chunk-YKMQLAVP.mjs +25 -0
- package/dist/chunk-YKMQLAVP.mjs.map +1 -0
- package/dist/cli.mjs +10 -10
- package/dist/contacts-worker.mjs +2 -2
- package/dist/global-insight-worker.mjs +136 -4
- package/dist/global-insight-worker.mjs.map +1 -1
- package/dist/{http-3K4YMWDE.mjs → http-LVOGJFDL.mjs} +13 -13
- package/dist/{import-D4LV565A.mjs → import-7OU57ZHM.mjs} +8 -8
- package/dist/index.mjs +13 -13
- package/dist/{mcp-KL22FKQ2.mjs → mcp-CUKHTTII.mjs} +9 -9
- package/dist/people-relationships-worker.mjs +2 -2
- package/dist/semantic-index-worker.mjs +1 -1
- package/dist/{src-COIB6Z4P.mjs → src-LORFXAUE.mjs} +120 -98
- package/dist/{stream-import-FSXCFG4M.mjs → stream-import-7YUWIAD6.mjs} +8 -8
- package/dist/{worker-runtime-DPS2LURI.mjs → worker-runtime-GQ5SY7E3.mjs} +6 -6
- package/dist-cli-web/assets/AISettingsTab-BmhNcUEh.js +1 -0
- package/dist-cli-web/assets/AboutTab-CFklrZt8.js +1 -0
- package/dist-cli-web/assets/ActionToolsPanel.vue_vue_type_script_setup_true_lang-B-dIPvcs.js +110 -0
- package/dist-cli-web/assets/Alert-DJzXKcec.js +1 -0
- package/dist-cli-web/assets/{ApiSettingsTab-CtXl4I28.js → ApiSettingsTab-DvDm421U.js} +1 -1
- package/dist-cli-web/assets/BatchManageTab-DhIDH3Q1.js +1 -0
- package/dist-cli-web/assets/{BufferResource-BXSJADxx.js → BufferResource-DY3P-dGs.js} +1 -1
- package/dist-cli-web/assets/{CanvasRenderer-Cq--8UQ_.js → CanvasRenderer-As2MJTWZ.js} +1 -1
- package/dist-cli-web/assets/ChatRecordDrawer-DHdas7Jp.js +1 -0
- package/dist-cli-web/assets/ChatRecordWorkspace-CVDPBmcl.js +11 -0
- package/dist-cli-web/assets/ChatRecordWorkspace-D_oJMtqh.css +1 -0
- package/dist-cli-web/assets/Checkbox-4F1WAuVF.js +1 -0
- package/dist-cli-web/assets/DataDirCleanupNotice-jebQ9il3.js +1 -0
- package/dist-cli-web/assets/{DatePicker.vue_vue_type_script_setup_true_lang-C4CsoIlq.js → DatePicker.vue_vue_type_script_setup_true_lang-Cal624eP.js} +1 -1
- package/dist-cli-web/assets/DebugToolsPanel-BLU6SY8a.js +1 -0
- package/dist-cli-web/assets/EChart.vue_vue_type_script_setup_true_lang-CsgJ-Xn3.js +1 -0
- package/dist-cli-web/assets/EChartLine.vue_vue_type_script_setup_true_lang-BYhukELX.js +1 -0
- package/dist-cli-web/assets/{EChartWordcloud-KV0MdsDE.js → EChartWordcloud-C16xh7Tx.js} +1 -1
- package/dist-cli-web/assets/{Filter-DVaqcFmI.js → Filter-BEtPORqF.js} +1 -1
- package/dist-cli-web/assets/GlobalTaskBar-BvNmFO7q.js +1 -0
- package/dist-cli-web/assets/GroupRelationshipGalaxyView-DEUIrvgz.js +1 -0
- package/dist-cli-web/assets/Label-Dgl3ghzT.js +1 -0
- package/dist-cli-web/assets/LoadingState.vue_vue_type_script_setup_true_lang-CwDIA0UP.js +1 -0
- package/dist-cli-web/assets/{MessageExportModal-BozaR9UZ.js → MessageExportModal-DYjhBuzO.js} +1 -1
- package/dist-cli-web/assets/PageHeader-CL9AFfvl.js +1 -0
- package/dist-cli-web/assets/PageTabs.vue_vue_type_script_setup_true_lang-C22kOxIK.js +1 -0
- package/dist-cli-web/assets/{RelationshipGalaxyCanvas-6EamagxG.js → RelationshipGalaxyCanvas-BnkcrIpk.js} +3 -3
- package/dist-cli-web/assets/{RelationshipGalaxyThreeCanvas-B6GB4PWS.js → RelationshipGalaxyThreeCanvas-CqdqveEJ.js} +1 -1
- package/dist-cli-web/assets/{RenderTargetSystem-mYuj4uBS.js → RenderTargetSystem-CPwnC2X3.js} +1 -1
- package/dist-cli-web/assets/{RovingFocusItem-B2y6BG1a.js → RovingFocusItem-j33Nsbbn.js} +1 -1
- package/dist-cli-web/assets/ScreenCaptureModal-ByKxzNQe.js +1 -0
- package/dist-cli-web/assets/{SectionTabs.vue_vue_type_script_setup_true_lang-ueEF4zHE.js → SectionTabs.vue_vue_type_script_setup_true_lang-C6EHKB_i.js} +1 -1
- package/dist-cli-web/assets/Select-jVtfc_xc.js +1 -0
- package/dist-cli-web/assets/SettingsModal-Dg27piEO.js +2 -0
- package/dist-cli-web/assets/StorageTab-QdcDqA6Q.js +1 -0
- package/dist-cli-web/assets/Switch-DYHM64k9.js +1 -0
- package/dist-cli-web/assets/Tabs-B6Nzq2NQ.js +1 -0
- package/dist-cli-web/assets/{Tabs-Dqwkh3Ea.js → Tabs-CRZdCcU4.js} +1 -1
- package/dist-cli-web/assets/{ThemeCard.vue_vue_type_script_setup_true_lang-DPIvbq75.js → ThemeCard.vue_vue_type_script_setup_true_lang-Bsq7gpC0.js} +1 -1
- package/dist-cli-web/assets/{TimeSelect.vue_vue_type_script_setup_true_lang-dEdo6CqM.js → TimeSelect.vue_vue_type_script_setup_true_lang-BLpQds4F.js} +1 -1
- package/dist-cli-web/assets/{VisuallyHiddenInput-BOdkR_GC.js → VisuallyHiddenInput-IQpmK9yR.js} +1 -1
- package/dist-cli-web/assets/{WebGLRenderer-BB8ukBI_.js → WebGLRenderer-8JHbnkTc.js} +1 -1
- package/dist-cli-web/assets/{WebGPURenderer-DDOzF1Kc.js → WebGPURenderer-CLWfB4CC.js} +1 -1
- package/dist-cli-web/assets/{aiChat-CzFSFuOJ.js → aiChat-4JvxWGXZ.js} +6 -6
- package/dist-cli-web/assets/base-D6fxqD_X.js +1 -0
- package/dist-cli-web/assets/{browserAll-BRqlnNxq.js → browserAll-Cin6ghNg.js} +1 -1
- package/dist-cli-web/assets/{cli-web-ClAJ6Tao.js → cli-web-D7IBc3AX.js} +1 -1
- package/dist-cli-web/assets/{dateFormat-DXuDxIye.js → dateFormat-Bu4-Ux3L.js} +1 -1
- package/dist-cli-web/assets/{fetch-CGu53cxT.js → fetch-1NiXh-_B.js} +1 -1
- package/dist-cli-web/assets/{fetch-q480XYZQ.js → fetch-2QEQPA9q.js} +8 -5
- package/dist-cli-web/assets/fetch-B2agy1hy.js +1 -0
- package/dist-cli-web/assets/{fetch-LY-yerw1.js → fetch-B7kuohCt.js} +1 -1
- package/dist-cli-web/assets/{fetch-Dy38lkAa.js → fetch-BR71C0K9.js} +1 -1
- package/dist-cli-web/assets/{fetch-CP1afnT0.js → fetch-Bk-7vxHV.js} +1 -1
- package/dist-cli-web/assets/fetch-C8tTTsCm.js +1 -0
- package/dist-cli-web/assets/{fetch-DijSOvop.js → fetch-CuUeyk0N.js} +1 -1
- package/dist-cli-web/assets/{fetch-DzKlTaLz.js → fetch-DPRDSI39.js} +1 -1
- package/dist-cli-web/assets/{fetch-Bcy2T8Fe.js → fetch-OnnCjzee.js} +1 -1
- package/dist-cli-web/assets/{fetch-DWAIk_6_.js → fetch-_CN1EVMt.js} +1 -1
- package/dist-cli-web/assets/index-B4J99zv3.css +1 -0
- package/dist-cli-web/assets/index-BBeqtL8d.css +1 -0
- package/dist-cli-web/assets/{index-Di6FmCdk.js → index-BCEk6ZpL.js} +9 -9
- package/dist-cli-web/assets/{index-CNzv7aBW.js → index-BIHFuCJK.js} +1 -1
- package/dist-cli-web/assets/index-BUz_Vl9U.js +2 -0
- package/dist-cli-web/assets/index-BWZIoPV3.css +1 -0
- package/dist-cli-web/assets/index-BYQV3OA5.js +1 -0
- package/dist-cli-web/assets/index-CVVv_6qu.js +2 -0
- package/dist-cli-web/assets/index-CacwXQL4.js +1 -0
- package/dist-cli-web/assets/{index-BRV_D8dv.js → index-Colc58j-.js} +1 -1
- package/dist-cli-web/assets/index-DImo7TQN.js +1 -0
- package/dist-cli-web/assets/index-DV9zQVPV.js +137 -0
- package/dist-cli-web/assets/index-DXKS-q-w.css +1 -0
- package/dist-cli-web/assets/index-DZc5A4_J.js +1 -0
- package/dist-cli-web/assets/index-DkWTvE7d.js +36 -0
- package/dist-cli-web/assets/index-DmEn0PAI.js +1 -0
- package/dist-cli-web/assets/index-b9eEQeVt.js +1 -0
- package/dist-cli-web/assets/index-waDxab2e.css +1 -0
- package/dist-cli-web/assets/insight-time-range-MJxLEu6o.js +1 -0
- package/dist-cli-web/assets/{people-page-header-Bh3KXD4g.js → people-page-header-DNPjaSt4.js} +1 -1
- package/dist-cli-web/assets/{prompt-DcAcgQiB.js → prompt-BgywZQ_g.js} +1 -1
- package/dist-cli-web/assets/{semantic-index-config-builder-CK6v64Y1.js → semantic-index-config-builder-bji_UxYE.js} +1 -1
- package/dist-cli-web/assets/{service-YZnJyEMq.js → service-DpU9fa-l.js} +1 -1
- package/dist-cli-web/assets/{useFormControl-B-aXrJZN.js → useFormControl-De24E2zT.js} +1 -1
- package/dist-cli-web/assets/useTable-C7BH94MF.js +1 -0
- package/dist-cli-web/assets/{useToast-B36MzFFy.js → useToast-CxhJkhXK.js} +1 -1
- package/dist-cli-web/assets/{webworkerAll-Dwqmy_YO.js → webworkerAll-BRnv6GvJ.js} +1 -1
- package/dist-cli-web/index.html +2 -2
- package/package.json +1 -1
- package/dist/chunk-22YJOBA3.mjs +0 -9826
- package/dist/chunk-22YJOBA3.mjs.map +0 -1
- package/dist/chunk-4GWWKHWA.mjs.map +0 -1
- package/dist/chunk-7IGBPZMI.mjs.map +0 -1
- package/dist/chunk-DC7IUDNV.mjs.map +0 -1
- package/dist/chunk-QZCNVAH6.mjs +0 -14
- package/dist/chunk-QZCNVAH6.mjs.map +0 -1
- package/dist-cli-web/assets/AISettingsTab-rQC2ocFH.js +0 -1
- package/dist-cli-web/assets/AboutTab-DMPziKjj.js +0 -1
- package/dist-cli-web/assets/ActionToolsPanel.vue_vue_type_script_setup_true_lang-CnRLt_1j.js +0 -110
- package/dist-cli-web/assets/Alert--bTQXRcZ.js +0 -1
- package/dist-cli-web/assets/BatchManageTab-1KaCPweN.js +0 -1
- package/dist-cli-web/assets/ChatRecordDrawer-BC0F7ok1.js +0 -11
- package/dist-cli-web/assets/ChatRecordDrawer-Tt6UduRC.css +0 -1
- package/dist-cli-web/assets/Checkbox-CwajNPGF.js +0 -1
- package/dist-cli-web/assets/DataDirCleanupNotice-D0Oruka2.js +0 -1
- package/dist-cli-web/assets/DebugToolsPanel-DVDwS-wz.js +0 -1
- package/dist-cli-web/assets/GlobalTaskBar-DpPMX0jx.js +0 -1
- package/dist-cli-web/assets/GroupRelationshipGalaxyView-CLnO3phW.js +0 -1
- package/dist-cli-web/assets/Label-Bt2U4lGy.js +0 -1
- package/dist-cli-web/assets/LoadingState.vue_vue_type_script_setup_true_lang-Cnshyn0f.js +0 -1
- package/dist-cli-web/assets/PageHeader-CEe0xTl3.js +0 -1
- package/dist-cli-web/assets/PageTabs.vue_vue_type_script_setup_true_lang-D2DZrrnv.js +0 -1
- package/dist-cli-web/assets/ScreenCaptureModal-BvAtSNNR.js +0 -1
- package/dist-cli-web/assets/Select-Cm4I8u9n.js +0 -1
- package/dist-cli-web/assets/SettingsModal-Cwshzj7i.js +0 -2
- package/dist-cli-web/assets/StorageTab-D7HzH16Y.js +0 -1
- package/dist-cli-web/assets/Switch-BVw4e_19.js +0 -1
- package/dist-cli-web/assets/Tabs-OrJkANIA.js +0 -1
- package/dist-cli-web/assets/annual-summary-time-range-CmrAqcuj.js +0 -1
- package/dist-cli-web/assets/base-CawUl6ET.js +0 -1
- package/dist-cli-web/assets/fetch-3_xX8Yi8.js +0 -1
- package/dist-cli-web/assets/index-0dp58uL4.css +0 -1
- package/dist-cli-web/assets/index-1X7zdLgJ.css +0 -1
- package/dist-cli-web/assets/index-4enwdBcq.css +0 -1
- package/dist-cli-web/assets/index-AudHHbMs.js +0 -1
- package/dist-cli-web/assets/index-CF4DTbvD.js +0 -1
- package/dist-cli-web/assets/index-CMLoht5R.js +0 -1
- package/dist-cli-web/assets/index-CMPHZH6B.css +0 -1
- package/dist-cli-web/assets/index-CXUTiy-V.js +0 -1
- package/dist-cli-web/assets/index-D5m0P4ss.js +0 -36
- package/dist-cli-web/assets/index-DkOrt7_X.js +0 -2
- package/dist-cli-web/assets/index-Dlb6fC68.js +0 -1
- package/dist-cli-web/assets/index-IA7YUjQX.js +0 -2
- package/dist-cli-web/assets/index-ZsZwPLWy.css +0 -1
- package/dist-cli-web/assets/index-kzU381y1.js +0 -1
- package/dist-cli-web/assets/index-z8Vogc-b.js +0 -137
- package/dist-cli-web/assets/lazy-overlay-visibility-Bd9ZFOgR.js +0 -1
- package/dist-cli-web/assets/member-select-utils-BXZ3oHct.js +0 -1
- package/dist-cli-web/assets/useTable-DPEMaGby.js +0 -1
- /package/dist/{chat-command-24RYGJAS.mjs.map → chat-command-SXW67RF7.mjs.map} +0 -0
- /package/dist/{chunk-KXDJ7N6N.mjs.map → chunk-AAGDVTP2.mjs.map} +0 -0
- /package/dist/{chunk-ZBPPLXM4.mjs.map → chunk-CNEWMCGX.mjs.map} +0 -0
- /package/dist/{chunk-QKEARRFH.mjs.map → chunk-GVW3BDGZ.mjs.map} +0 -0
- /package/dist/{chunk-BRZ6YIBR.mjs.map → chunk-JHON5FN7.mjs.map} +0 -0
- /package/dist/{chunk-U36TQMAF.mjs.map → chunk-UNIKQFI5.mjs.map} +0 -0
- /package/dist/{chunk-GQMCDWZQ.mjs.map → chunk-VDWI4A4U.mjs.map} +0 -0
- /package/dist/{chunk-KIMJXKZO.mjs.map → chunk-XDF6PMVZ.mjs.map} +0 -0
- /package/dist/{http-3K4YMWDE.mjs.map → http-LVOGJFDL.mjs.map} +0 -0
- /package/dist/{import-D4LV565A.mjs.map → import-7OU57ZHM.mjs.map} +0 -0
- /package/dist/{mcp-KL22FKQ2.mjs.map → mcp-CUKHTTII.mjs.map} +0 -0
- /package/dist/{src-COIB6Z4P.mjs.map → src-LORFXAUE.mjs.map} +0 -0
- /package/dist/{stream-import-FSXCFG4M.mjs.map → stream-import-7YUWIAD6.mjs.map} +0 -0
- /package/dist/{worker-runtime-DPS2LURI.mjs.map → worker-runtime-GQ5SY7E3.mjs.map} +0 -0
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/index-
|
|
2
|
-
import{U as bs,d as is,r as
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/index-DkWTvE7d.js","assets/vendor-snapdom--nZvo8Sg.js","assets/index-BWZIoPV3.css"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{U as bs,d as is,r as q,f as te,aw as He,bE as We,bF as Qe,bG as _s,T as xs,bu as Us,bH as ds,am as Ls,a6 as qs,bI as Ds,ah as Fs,ad as fs,aT as re,bJ as Ke}from"./index-DkWTvE7d.js";import{u as Os}from"./prompt-BgywZQ_g.js";import{C as ws}from"./chatlabSiteLocale-CrCNb8QP.js";const xe="chart_runtime",$s=4e3,zs=`
|
|
3
3
|
…[truncated]`;function ps(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function gs(e){return!ps(e)||!Array.isArray(e.content)?"":e.content.map(t=>ps(t)&&t.type==="text"&&typeof t.text=="string"?t.text:"").filter(t=>t.length>0).join(`
|
|
4
|
-
`)}function ms(e,t=$s){return e.length<=t?e:e.slice(0,t)+zs}function X(){return bs("assistant-crud")}function le(){return bs("skill-crud")}const ks=ws,Ws={"zh-CN":"cn","zh-TW":"cn","en-US":"en","ja-JP":"ja"},Bs=is("assistant",()=>{const e=
|
|
5
|
-
`);x=F.pop()||"";for(const Y of F)Y.startsWith("event: ")?
|
|
6
|
-
`).trim():null:null}function hs(e,t){if(!ae(e)||ns(t).length>0)return null;const u=Ks(t);if(!u)return null;const c=/^Error:\s*(.+)$/is.exec(u)?.[1]?.trim();return!c||/^Call get_schema before render_chart\b/i.test(c)?null:{type:"error",error:{name:"ChartRenderError",message:c,stack:null}}}function je(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function ss(e){return je(e)&&e.version===1&&typeof e.query=="string"&&Array.isArray(e.groups)}function Ts(e){if(!je(e))return null;const t=je(e.details)?e.details:null;if(t&&ss(t.evidence))return t.evidence;const u=je(e.data)?e.data:null;return u&&ss(u.evidence)?u.evidence:ss(e.evidence)?e.evidence:null}function et(e){return{type:"evidence",evidence:e}}function vs(e){return JSON.parse(JSON.stringify(e))}function ls(e){return JSON.parse(JSON.stringify(e))}function Es(e){return e?.type==="plan_draft"&&typeof e.text=="string"}function st(e,t){const u=e.map(ls),f=u[u.length-1];return Es(f)?f.text+=t:u.push({type:"plan_draft",version:1,status:"streaming",text:t}),u}function tt(e,t){const u=e.map(ls);for(let f=u.length-1;f>=0;f--){const c=u[f];if(Es(c)){const h=c.text.trim();return u[f]={...vs(t),...h?{displayText:h}:{}},u}}return u.push(vs(t)),u}function nt(e){return e.filter(t=>t.type!=="plan_draft").map(ls)}function As(e){if(!e)return;const t=JSON.parse(JSON.stringify(e));for(const u of t)u.type==="tool"&&delete u.tool.displayResult;return t}const oe="__draft__";function rt(e){return e?`${e.startTs}_${e.endTs}`:"all"}function ot(e){return`${e.sessionId}:${e.chatType}:${rt(e.timeFilter)}`}function os(){return{promptTokens:0,completionTokens:0,totalTokens:0,cacheReadTokens:0,cacheWriteTokens:0}}function Cs(e){return{promptTokens:e.promptTokens??0,completionTokens:e.completionTokens??0,totalTokens:e.totalTokens??0,cacheReadTokens:e.cacheReadTokens??0,cacheWriteTokens:e.cacheWriteTokens??0}}function $e(e){if(e&&typeof e=="object"){const t=e;return{name:typeof t.name=="string"?t.name:null,message:typeof t.message=="string"?t.message:"未知错误",stack:typeof t.stack=="string"?t.stack:null,statusCode:typeof t.statusCode=="number"?t.statusCode:null,url:typeof t.url=="string"?t.url:null,responseBody:typeof t.responseBody=="string"?t.responseBody:null,responseHeaders:t.responseHeaders&&typeof t.responseHeaders=="object"?t.responseHeaders:null,requestBody:typeof t.requestBody=="string"?t.requestBody:null,cause:typeof t.cause=="string"?t.cause:null,provider:typeof t.provider=="string"?t.provider:null,friendlyMessage:typeof t.friendlyMessage=="string"?t.friendlyMessage:null}}return{name:null,message:e?String(e):"未知错误",stack:null}}function ze(e){return{id:e.id,role:e.role,content:e.content,timestamp:e.timestamp*1e3,parentId:e.parentId,contentBlocks:e.contentBlocks}}function as(e=null){return{messages:[],sourceMessages:[],currentKeywords:[],assistantId:e,loaded:!1}}function at(e){const t=as(null);return{sessionId:e.sessionId,sessionName:e.sessionName,chatType:e.chatType,locale:e.locale,timeFilter:e.timeFilter,selectedAssistantId:null,messages:t.messages,sourceMessages:t.sourceMessages,currentKeywords:t.currentKeywords,isLoadingSource:!1,isAIThinking:!1,currentAIChatId:null,currentToolStatus:null,toolsUsedInCurrentRound:[],sessionTokenUsage:os(),agentStatus:null,ownerInfo:void 0,ownerInfoInitialized:!1,isAborted:!1,currentRequestId:"",currentAgentRequestId:"",aiChatBuffers:{[oe]:t}}}function ts(e){return e.currentAIChatId??oe}const ft=is("aiChatRuntime",()=>{const e=L({}),t=L(null),u=Os(),f=qs(),c=Ls(),h=Bs(),D=Js(),b=Ds(),{aiGlobalSettings:M}=Fs(u);let E=!1;function x(n){return`${n}_${Date.now()}_${Math.random().toString(36).slice(2,8)}`}function J(n){const s=ot(n),o=e.value[s];if(o)return o.sessionName=n.sessionName,o.chatType=n.chatType,o.locale=n.locale,o.timeFilter=n.timeFilter,{chatKey:s,state:o};const r=at(n);e.value[s]=r;const a=e.value[s];return K(s),{chatKey:s,state:a}}function U(n){return e.value[n]??null}function V(){return t.value?U(t.value.chatKey):null}function F(n,s,o=null){return n.aiChatBuffers[s]||(n.aiChatBuffers[s]=as(o)),n.aiChatBuffers[s]}function Y(n,s){const o=n.currentAIChatId??oe,r=n.aiChatBuffers[o];r&&(r.sessionTokenUsage={...n.sessionTokenUsage});const a=F(n,s);n.currentAIChatId=s===oe?null:s,n.messages=a.messages,n.sourceMessages=a.sourceMessages,n.currentKeywords=a.currentKeywords,n.selectedAssistantId=a.assistantId,n.sessionTokenUsage=a.sessionTokenUsage?{...a.sessionTokenUsage}:os(),n.agentStatus=null}function ce(n,s,o){const r=F(n,s);return n.aiChatBuffers[o]=r,s!==o&&delete n.aiChatBuffers[s],n.currentAIChatId===null&&s===oe&&(n.currentAIChatId=o),r}function _(n){const s=U(n);s&&(s.selectedAssistantId?h.selectAssistant(s.selectedAssistantId):h.clearSelection())}async function K(n){const s=U(n);if(!s)return;const r=f.sessions.find(a=>a.id===s.sessionId)?.ownerId;if(!r){s.ownerInfo=void 0,s.ownerInfoInitialized=!0;return}if(!(s.ownerInfoInitialized&&s.ownerInfo?.platformId===r))try{const w=(await fs().getMembers(s.sessionId)).find(v=>v.platformId===r);s.ownerInfo=w?{platformId:r,displayName:w.groupNickname||w.accountName||r}:{platformId:r,displayName:r},s.ownerInfoInitialized=!0}catch(a){console.error("[AI] 获取 Owner 信息失败:",a),s.ownerInfo=void 0,s.ownerInfoInitialized=!0}}function ue(n,s,o,r=null){const a=U(n);a&&(t.value={requestId:o,chatKey:n,sessionId:a.sessionId,sessionName:a.sessionName,chatType:a.chatType,aiChatId:r,questionPreview:s.trim().slice(0,80),startedAt:Date.now()})}function N(n,s){t.value&&t.value.chatKey===n&&(s&&t.value.requestId!==s||(t.value=null))}function Ie(n,s){t.value&&t.value.chatKey===n&&(t.value.aiChatId=s)}function Re(n){return{phase:"preparing",round:0,toolsUsed:n.toolsUsedInCurrentRound.length,contextTokens:0,totalUsage:{...n.sessionTokenUsage},updatedAt:Date.now()}}function ie(n,s,o){const r=n.agentStatus?{...n.agentStatus}:Re(n);n.agentStatus={...r,...o,phase:s,updatedAt:Date.now()}}function Te(n,s){const o=U(n);if(!o||o.isAIThinking)return!1;const r=F(o,ts(o),s);return r.assistantId=s,o.selectedAssistantId=s,h.selectAssistant(s),!0}async function Me(n,s){const o=U(n);if(!o)return!1;try{const r=await re().getAIChat(s),a=F(o,s,r?.assistantId??null);if(!a.loaded){const[w,v]=await Promise.all([re().getMessages(s),re().getAIChatTokenUsage(s)]);a.messages.splice(0,a.messages.length,...w.map(S=>ze(S))),a.sourceMessages.splice(0,a.sourceMessages.length),a.currentKeywords.splice(0,a.currentKeywords.length),a.sessionTokenUsage=Cs(v),a.loaded=!0}return a.assistantId=r?.assistantId??a.assistantId??null,Y(o,s),_(n),!0}catch(r){return console.error("[AI] 加载对话历史失败:",r),!1}}function ve(n,s){const o=U(n);if(!o)return!1;const r=s??oe;return o.aiChatBuffers[r]?(Y(o,r),_(n),!0):!1}function Ne(){return t.value?(E=!0,ve(t.value.chatKey,t.value.aiChatId)):!1}async function Pe(n){if(E){E=!1;return}const s=U(n);if(!(!s||s.isAIThinking)){if(h.isLoaded||await h.loadAssistants(),!s.selectedAssistantId){const o=We(s.locale);Te(n,o)}k(n)}}function k(n,s){const o=U(n);if(!o||o.isAIThinking)return!1;const r=as(o.selectedAssistantId);return o.aiChatBuffers[oe]=r,Y(o,oe),o.currentToolStatus=null,o.toolsUsedInCurrentRound=[],o.isLoadingSource=!1,o.sessionTokenUsage=os(),o.agentStatus=null,o.isAborted=!1,o.currentRequestId="",o.currentAgentRequestId="",s&&r.messages.push({id:x("welcome"),role:"assistant",content:s,timestamp:Date.now()}),!0}async function y(){}async function R(){}function ee(n,s){const o=p=>{const I=s();n.messages[I]={...n.messages[I],...p}};return{updateAIMessage:o,appendTextToBlocks:p=>{if(!p)return;const I=s(),l=n.messages[I].contentBlocks||[],C=l[l.length-1];p.trim().length===0&&(!C||C.type!=="text")||(C&&C.type==="text"?C.text+=p:l.push({type:"text",text:p}),o({contentBlocks:[...l],content:n.messages[I].content+p}))},appendThinkToBlocks:(p,I,l)=>{if(!p&&l===void 0)return;const C=s(),B=n.messages[C].contentBlocks||[],H=I||"think",W=B[B.length-1];let q=W;if(W&&W.type==="think"&&W.tag===H)W.text+=p;else if(p.trim().length>0)q={type:"think",tag:H,text:p},B.push(q);else if(l!==void 0)for(let G=B.length-1;G>=0;G--){const Se=B[G];if(Se.type==="think"&&Se.tag===H){q=Se;break}}l!==void 0&&q&&q.type==="think"&&(q.durationMs=l),o({contentBlocks:[...B]})},appendChartsToBlocks:p=>{if(p.length===0)return;const I=s(),l=n.messages[I].contentBlocks||[];l.push(...Ps(p)),o({contentBlocks:[...l]})},appendEvidenceToBlocks:p=>{const I=s(),l=n.messages[I].contentBlocks||[];l.push(et(p)),o({contentBlocks:[...l]})},appendPlanDraftToBlocks:p=>{if(!p)return;const I=s(),l=n.messages[I].contentBlocks||[];o({contentBlocks:[...st(l,p)]})},appendPlanToBlocks:p=>{const I=s(),l=n.messages[I].contentBlocks||[];o({contentBlocks:[...tt(l,p)]})},removePlanDraftsFromBlocks:()=>{const p=s(),I=n.messages[p].contentBlocks||[];o({contentBlocks:[...nt(I)]})},updatePlanBlockStatus:p=>{const I=s(),l=n.messages[I].contentBlocks||[];for(let C=l.length-1;C>=0;C--){const B=l[C];if(B.type==="plan"){B.status=p;break}}o({contentBlocks:[...l]})},appendErrorToBlocks:p=>{const I=s(),l=n.messages[I].contentBlocks||[];l.push({type:"error",error:p}),o({contentBlocks:[...l]})},addToolBlock:(p,I,l)=>{const C=s(),B=n.messages[C].contentBlocks||[];B.push({type:"tool",tool:{name:p,displayName:p,status:"running",params:I,toolCallId:l}}),o({contentBlocks:[...B]})},addRenderOnlyToolPendingBlock:(p,I,l)=>{const C=Gs(p,I,l);if(!C)return;const B=s(),H=n.messages[B].contentBlocks||[];H.push(C),o({contentBlocks:[...H]})},updateRenderOnlyToolResult:(p,I,l,C)=>{const B=s(),H=n.messages[B].contentBlocks||[];o({contentBlocks:Qs(H,p,I,l,C)})},updateToolBlockStatus:(p,I,l)=>{const C=s(),B=n.messages[C].contentBlocks||[],H=q=>q.type==="tool"&&q.tool.status==="running";let W;if(l?.toolCallId)for(let q=B.length-1;q>=0;q--){const G=B[q];if(H(G)&&G.tool.toolCallId===l.toolCallId){W=G;break}}if(!W)for(let q=B.length-1;q>=0;q--){const G=B[q];if(H(G)&&G.tool.name===p){W=G;break}}W&&(W.tool.status=I,l?.result!==void 0&&(W.tool.result=l.result),l?.displayResult!==void 0&&(W.tool.displayResult=l.displayResult),l?.isError!==void 0&&(W.tool.isError=l.isError)),o({contentBlocks:[...B]})}}}async function de(n,s,o){const r=U(n);if(!r)return{success:!1,reason:"error"};if(!s.trim())return{success:!1,reason:"empty"};if(r.isAIThinking||t.value)return{success:!1,reason:"busy",activeTask:t.value};const a=x("req"),w=ts(r);let v=w===oe?null:w;const S=F(r,w,r.selectedAssistantId);let P,A;S.assistantId=r.selectedAssistantId,S.loaded=!0,ue(n,s,a,v),_(n),K(n);const $=D.activeSkillId,fe=D.activeSkill?.name,pe=M.value.enableAutoSkill??!0,ge=pe?M.value.chartAutoMode??"suggest":"explicit",Ce=(o?.mentionedMembers??[]).map(z=>({memberId:z.memberId,platformId:z.platformId,displayName:z.displayName,aliases:[...z.aliases],mentionText:z.mentionText}));r.isAIThinking=!0,r.isLoadingSource=!0,r.currentToolStatus=null,r.toolsUsedInCurrentRound=[],r.agentStatus=null,r.isAborted=!1,r.currentRequestId=a,r.currentAgentRequestId="";try{const z=await Ke().hasConfig();if(r.isAborted)return N(n,a),{success:!1,reason:"aborted"};if(r.currentRequestId!==a)return N(n,a),{success:!1,reason:"busy",activeTask:t.value};if(!z)return S.messages.push({id:x("error"),role:"assistant",content:"⚠️ 请先配置 AI 服务。点击左下角「设置」按钮前往「模型配置Tab」进行配置。",timestamp:Date.now()}),N(n,a),{success:!1,reason:"no_config"};const p={id:x("user"),role:"user",content:s,timestamp:Date.now(),toolCalls:[]};P=p,S.messages.push(p);const I={id:x("ai"),role:"assistant",content:"",timestamp:Date.now(),isStreaming:!0,contentBlocks:[]};$&&fe&&I.contentBlocks.push({type:"skill",skillId:$,skillName:fe}),S.messages.push(I);let l=S.messages.length-1,C=!1;const{updateAIMessage:B,appendTextToBlocks:H,appendThinkToBlocks:W,appendChartsToBlocks:q,appendEvidenceToBlocks:G,appendPlanDraftToBlocks:Se,appendPlanToBlocks:Le,removePlanDraftsFromBlocks:be,updatePlanBlockStatus:Ee,appendErrorToBlocks:Ge,addToolBlock:Ye,addRenderOnlyToolPendingBlock:Xe,updateRenderOnlyToolResult:De,updateToolBlockStatus:se}=ee(S,()=>l),me=S.assistantId??We(r.locale);if(!v){const i=s.slice(0,50)+(s.length>50?"...":""),O=await re().createAIChat(r.sessionId,i,me);if(r.isAborted)return B({isStreaming:!1}),N(n,a),{success:!1,reason:"aborted"};if(r.currentRequestId!==a)return B({isStreaming:!1}),N(n,a),{success:!1,reason:"busy",activeTask:t.value};v=O.id,ce(r,oe,O.id),S.assistantId=me,Ie(n,O.id)}const ke={sessionId:r.sessionId,aiChatId:v,timeFilter:r.timeFilter?{startTs:r.timeFilter.startTs,endTs:r.timeFilter.endTs}:void 0,maxMessagesLimit:M.value.maxMessagesPerRequest,ownerInfo:r.ownerInfo?{platformId:r.ownerInfo.platformId,displayName:r.ownerInfo.displayName}:void 0,mentionedMembers:Ce.length>0?Ce:void 0,preprocessConfig:await Ue(),searchContextBefore:M.value.searchContextBefore,searchContextAfter:M.value.searchContextAfter},{requestId:he,promise:Ze}=es().runStream({userMessage:s,sessionId:r.sessionId,aiChatId:v,timeFilter:ke.timeFilter,maxMessagesLimit:ke.maxMessagesLimit,ownerInfo:ke.ownerInfo,mentionedMembers:ke.mentionedMembers,preprocessConfig:ke.preprocessConfig,chatType:r.chatType,locale:r.locale,assistantId:me,skillId:$,enableAutoSkill:$?void 0:pe,chartAutoMode:$?void 0:ge,thinkingLevel:(()=>{const i=b.defaultAssistant;if(!(!i?.configId||!i?.modelId))return u.getThinkingLevel(i.configId,i.modelId)})()},i=>{if(!(r.isAborted||a!==r.currentRequestId))switch(i.type){case"content":i.content&&(r.currentToolStatus=null,H(i.content));break;case"think":i.content?W(i.content,i.thinkTag):i.thinkDurationMs!==void 0&&W("",i.thinkTag,i.thinkDurationMs);break;case"tool_start":if(i.toolName){const O=i.toolParams;r.currentToolStatus={name:i.toolName,displayName:i.toolName,status:"running"},r.toolsUsedInCurrentRound.push(i.toolName),ae(i.toolName)?Xe(i.toolName,O,i.toolCallId):Ye(i.toolName,O,i.toolCallId)}break;case"tool_result":if(i.toolName){const O=ns(i.toolResult),Q=hs(i.toolName,i.toolResult);ae(i.toolName)?De(i.toolName,i.toolCallId,O,Q):q(O);const Fe=Ts(i.toolResult);Fe&&G(Fe),Q&&(ae(i.toolName)||Ge(Q.error));const _e=Q!==null||i.toolIsError===!0;if(r.currentToolStatus?.name===i.toolName&&(r.currentToolStatus={...r.currentToolStatus,status:_e?"error":"done"}),!ae(i.toolName)){const we=gs(i.toolResult);se(i.toolName,_e?"error":"done",{toolCallId:i.toolCallId,result:ms(we),displayResult:we,isError:i.toolIsError})}}r.isLoadingSource=!1;break;case"plan_delta":i.planDelta&&Se(i.planDelta);break;case"plan":i.plan&&(Le(i.plan),Ee("executing"));break;case"plan_skipped":be();break;case"status":i.status&&(!r.agentStatus||i.status.updatedAt>=r.agentStatus.updatedAt)&&(r.agentStatus=i.status);break;case"compression_done":if(i.compressionResult){const O={id:`summary-${Date.now()}`,role:"summary",content:i.compressionResult.summaryContent,timestamp:i.compressionResult.timestamp},Q=Math.max(0,S.messages.length-1);S.messages.splice(Q,0,O),l++}break;case"done":r.currentToolStatus=null,C||Ee("done"),i.usage&&(A={...i.usage},r.sessionTokenUsage={promptTokens:r.sessionTokenUsage.promptTokens+i.usage.promptTokens,completionTokens:r.sessionTokenUsage.completionTokens+i.usage.completionTokens,totalTokens:r.sessionTokenUsage.totalTokens+i.usage.totalTokens,cacheReadTokens:r.sessionTokenUsage.cacheReadTokens+i.usage.cacheReadTokens,cacheWriteTokens:r.sessionTokenUsage.cacheWriteTokens+i.usage.cacheWriteTokens}),ie(r,"completed",i.usage?{totalUsage:i.usage}:void 0);break;case"error":if(be(),Ee("skipped"),r.currentToolStatus&&(r.currentToolStatus={...r.currentToolStatus,status:"error"},se(r.currentToolStatus.name,"error")),!C){C=!0;const O=S.messages[l].contentBlocks||[];O.push({type:"error",error:$e(i.error)}),B({contentBlocks:[...O],isStreaming:!1})}ie(r,"error");break}});r.currentAgentRequestId=he,ue(n,s,he,v);const ne=await Ze;if(r.isAborted)return N(n,he),{success:!1,reason:"aborted"};if(a!==r.currentRequestId)return N(n,he),{success:!1,reason:"busy",activeTask:t.value};if(ne.success&&ne.result){S.messages[l]={...S.messages[l],dataSource:{toolsUsed:ne.result.toolsUsed,toolRounds:ne.result.toolRounds},isStreaming:!1};const i=await Ae(v,p,S.messages[l],A);i&&(Object.assign(p,i.userMessage),S.messages[l]={...S.messages[l],...i.assistantMessage,isStreaming:!1})}else if(C){const i=await Ae(v,p,S.messages[l],A);i&&(Object.assign(p,i.userMessage),S.messages[l]={...S.messages[l],...i.assistantMessage,isStreaming:!1})}else{const i=S.messages[l].contentBlocks||[];i.push({type:"error",error:$e(ne.error)}),S.messages[l]={...S.messages[l],contentBlocks:[...i],isStreaming:!1};const O=await Ae(v,p,S.messages[l],A);O&&(Object.assign(p,O.userMessage),S.messages[l]={...S.messages[l],...O.assistantMessage,isStreaming:!1})}return{success:!0}}catch(z){console.error("[AI] 处理失败:",z),r.agentStatus=null;const p=S.messages[S.messages.length-1];if(p&&p.role==="assistant"){const I={name:z instanceof Error?z.name:null,message:z instanceof Error?z.message:String(z),stack:z instanceof Error?z.stack??null:null},l=p.contentBlocks||[];l.push({type:"error",error:I}),p.contentBlocks=[...l],p.isStreaming=!1;const C=P||S.messages.findLast(B=>B.role==="user");C&&await Ae(v,C,p,A)}return{success:!1,reason:"error"}}finally{r.isAIThinking=!1,r.isLoadingSource=!1,r.currentToolStatus=null,r.isAborted=!1,r.currentRequestId="",r.currentAgentRequestId="",N(n)}}async function Ae(n,s,o,r){try{if(!n)return null;const a=await re().addMessage(n,"user",s.content),w=As(o.contentBlocks),v=await re().addMessage(n,"assistant",o.content,void 0,void 0,w,r);return{userMessage:ze(a),assistantMessage:ze(v)}}catch(a){return console.error("[AI] 保存对话失败:",a),null}}async function Ue(){const n=c.aiPreprocessConfig;return Hs(n)&&await c.ensureDesensitizeRules(),Vs(c.aiPreprocessConfig)}function qe(n){return n.trim().replace(/^[\s"'“”‘’([{<]+|[\s"'“”‘’)\]}>.,!?;:,。!?;:、]+$/g,"").toLocaleLowerCase()}async function He(n,s){const o=new Set;for(const r of s.matchAll(/@([^\s@]+)/g)){const a=qe(r[1]??"");a&&o.add(a)}if(o.size===0)return[];try{const r=await fs().getMembers(n.sessionId),a=new Map;r.forEach(P=>{const A=P.groupNickname||P.accountName||P.platformId;a.set(A,(a.get(A)??0)+1)});const w=r.map(P=>{const A=P.groupNickname||P.accountName||P.platformId,$=(a.get(A)??0)>1?`${A}·${P.platformId}`:A,fe=[...P.aliases],pe=[A,P.groupNickname||"",P.accountName||"",P.platformId,$,...fe].map(qe).filter(Boolean);return{memberId:P.id,platformId:P.platformId,displayName:A,aliases:fe,mentionText:`@${$}`,lookupValues:pe}}),v=[],S=new Set;for(const P of o){const A=w.find($=>!S.has($.memberId)&&$.lookupValues.includes(P));A&&(S.add(A.memberId),v.push({memberId:A.memberId,platformId:A.platformId,displayName:A.displayName,aliases:A.aliases,mentionText:A.mentionText}))}return v}catch(r){return console.error("[AI] Failed to resolve mentioned members for edited message:",r),[]}}async function Ve(n,s,o,r){const a=U(n),w=o.trim();if(!a||!a.currentAIChatId)return{success:!1,reason:"error"};if(!w)return{success:!1,reason:"empty"};if(a.isAIThinking||t.value)return{success:!1,reason:"busy",activeTask:t.value};const v=r?.overwriteSubsequent??!1,S=F(a,a.currentAIChatId,a.selectedAssistantId),P=S.messages.findIndex($=>$.id===s),A=S.messages[P];return!A||A.role!=="user"||A.isStreaming?{success:!1,reason:"error"}:A.content.trim()===w?{success:!1,reason:"empty"}:v?m(n,a,S,P,A,w):d(n,a,S,P,A,w)}async function m(n,s,o,r,a,w){try{return await Ke().hasConfig()?s.isAborted?{success:!1,reason:"aborted"}:s.isAIThinking||t.value?{success:!1,reason:"busy",activeTask:t.value}:(await re().deleteMessagesFrom(s.currentAIChatId,a.id),o.messages.splice(r,o.messages.length-r),de(n,w)):{success:!1,reason:"no_config"}}catch(v){return console.error("[AI] edit and overwrite failed:",v),{success:!1,reason:"error"}}}async function d(n,s,o,r,a,w){const v=x("req");let S,P=!1;ue(n,w,v,s.currentAIChatId),_(n),K(n),s.isAIThinking=!0,s.isLoadingSource=!0,s.currentToolStatus=null,s.toolsUsedInCurrentRound=[],s.agentStatus=null,s.isAborted=!1,s.currentRequestId=v,s.currentAgentRequestId="";const A=o.messages[r+1],$=A?.role==="assistant",fe=$?o.messages.slice(r+2):o.messages.slice(r+1),pe={id:x("ai"),role:"assistant",content:"",timestamp:Date.now(),isStreaming:!0,contentBlocks:[]},ge=D.activeSkillId,Ce=D.activeSkill?.name;ge&&Ce&&pe.contentBlocks.push({type:"skill",skillId:ge,skillName:Ce});const z={...a,content:w},p=$?2:1;o.messages.splice(r,p,z,pe);const I=r+1,l=()=>{o.messages.splice(r,o.messages.length-r,a),$&&o.messages.splice(r+1,0,A),o.messages.push(...fe)},{updateAIMessage:C,appendTextToBlocks:B,appendThinkToBlocks:H,appendChartsToBlocks:W,appendEvidenceToBlocks:q,appendPlanDraftToBlocks:G,appendPlanToBlocks:Se,removePlanDraftsFromBlocks:Le,updatePlanBlockStatus:be,appendErrorToBlocks:Ee,addToolBlock:Ge,addRenderOnlyToolPendingBlock:Ye,updateRenderOnlyToolResult:Xe,updateToolBlockStatus:De}=ee(o,()=>I);try{if(!await Ke().hasConfig())return l(),N(n,v),{success:!1,reason:"no_config"};const me=o.assistantId??We(s.locale),ke=await He(s,w);if(s.isAborted)return l(),N(n,v),{success:!1,reason:"aborted"};if(v!==s.currentRequestId)return l(),N(n,v),{success:!1,reason:"busy",activeTask:t.value};const he=M.value.enableAutoSkill??!0,Ze=he?M.value.chartAutoMode??"suggest":"explicit",ne={sessionId:s.sessionId,aiChatId:s.currentAIChatId,historyLeafMessageId:a.parentId??null,timeFilter:s.timeFilter?{startTs:s.timeFilter.startTs,endTs:s.timeFilter.endTs}:void 0,maxMessagesLimit:M.value.maxMessagesPerRequest,ownerInfo:s.ownerInfo?{platformId:s.ownerInfo.platformId,displayName:s.ownerInfo.displayName}:void 0,mentionedMembers:ke.length>0?ke:void 0,preprocessConfig:await Ue(),searchContextBefore:M.value.searchContextBefore,searchContextAfter:M.value.searchContextAfter},{requestId:i,promise:O}=es().runStream({userMessage:w,sessionId:s.sessionId,aiChatId:s.currentAIChatId,historyLeafMessageId:a.parentId??null,timeFilter:ne.timeFilter,maxMessagesLimit:ne.maxMessagesLimit,ownerInfo:ne.ownerInfo,mentionedMembers:ne.mentionedMembers,preprocessConfig:ne.preprocessConfig,chatType:s.chatType,locale:s.locale,assistantId:me,skillId:ge,enableAutoSkill:ge?void 0:he,chartAutoMode:ge?void 0:Ze,thinkingLevel:(()=>{const g=b.defaultAssistant;if(!(!g?.configId||!g?.modelId))return u.getThinkingLevel(g.configId,g.modelId)})()},g=>{if(!(s.isAborted||v!==s.currentRequestId))switch(g.type){case"content":s.currentToolStatus=null,B(g.content||"");break;case"think":g.content?H(g.content,g.thinkTag):g.thinkDurationMs!==void 0&&H("",g.thinkTag,g.thinkDurationMs);break;case"tool_start":if(g.toolName){const ye=g.toolParams;s.currentToolStatus={name:g.toolName,displayName:g.toolName,status:"running"},s.toolsUsedInCurrentRound.push(g.toolName),ae(g.toolName)?Ye(g.toolName,ye,g.toolCallId):Ge(g.toolName,ye,g.toolCallId)}break;case"tool_result":if(g.toolName){const ye=ns(g.toolResult),Oe=hs(g.toolName,g.toolResult);ae(g.toolName)?Xe(g.toolName,g.toolCallId,ye,Oe):W(ye);const cs=Ts(g.toolResult);if(cs&&q(cs),Oe&&(ae(g.toolName)||Ee(Oe.error)),!ae(g.toolName)){const us=gs(g.toolResult);De(g.toolName,Oe!==null||g.toolIsError===!0?"error":"done",{toolCallId:g.toolCallId,result:ms(us),displayResult:us,isError:g.toolIsError})}}s.currentToolStatus=null,s.isLoadingSource=!1;break;case"plan_delta":g.planDelta&&G(g.planDelta);break;case"plan":g.plan&&(Se(g.plan),be("executing"));break;case"plan_skipped":Le();break;case"status":g.status&&(!s.agentStatus||g.status.updatedAt>=s.agentStatus.updatedAt)&&(s.agentStatus=g.status);break;case"done":s.currentToolStatus=null,P||be("done"),g.usage&&(S={...g.usage}),ie(s,"completed",g.usage?{totalUsage:g.usage}:void 0);break;case"error":{Le(),be("skipped"),P=!0,s.currentToolStatus&&De(s.currentToolStatus.name,"error");const ye=o.messages[I].contentBlocks||[];ye.push({type:"error",error:$e(g.error)}),C({contentBlocks:[...ye],isStreaming:!1}),ie(s,"error");break}}});s.currentAgentRequestId=i,ue(n,w,i,s.currentAIChatId);const Q=await O;if(s.isAborted)return l(),N(n,i),{success:!1,reason:"aborted"};if(v!==s.currentRequestId)return l(),N(n,i),{success:!1,reason:"busy",activeTask:t.value};if(Q.success&&Q.result)C({dataSource:{toolsUsed:Q.result.toolsUsed,toolRounds:Q.result.toolRounds},isStreaming:!1});else if(!P){const g=o.messages[I].contentBlocks||[];g.push({type:"error",error:$e(Q.error)}),C({contentBlocks:[...g],isStreaming:!1})}if(!Q.success)return l(),{success:!1,reason:"error"};await re().updateMessageContent(a.id,w),$&&await re().deleteAndRelinkMessage(s.currentAIChatId,A.id);const Fe=As(o.messages[I].contentBlocks),_e=await re().insertMessageAfter(s.currentAIChatId,a.id,"assistant",o.messages[I].content,Fe,S);o.messages[I]={...ze(_e),dataSource:o.messages[I].dataSource,isStreaming:!1},o.messages[r]={...o.messages[r],content:w};const we=I+1;return we<o.messages.length&&(o.messages[we]={...o.messages[we],parentId:_e.id}),o.sessionTokenUsage=Cs(await re().getAIChatTokenUsage(s.currentAIChatId)),s.sessionTokenUsage={...o.sessionTokenUsage},{success:!0}}catch(se){if(s.isAborted)return l(),{success:!1,reason:"aborted"};console.error("[AI] edit and regenerate failed:",se);const me=o.messages[I]?.contentBlocks||[];return me.push({type:"error",error:{name:se instanceof Error?se.name:null,message:se instanceof Error?se.message:String(se),stack:se instanceof Error?se.stack??null:null}}),o.messages[I]&&C({contentBlocks:[...me],isStreaming:!1}),{success:!1,reason:"error"}}finally{s.isAIThinking=!1,s.isLoadingSource=!1,s.currentToolStatus=null,s.isAborted=!1,s.currentRequestId="",s.currentAgentRequestId="",N(n)}}async function T(n){const s=U(n);if(!s||!s.isAIThinking)return!1;s.isAborted=!0,s.isAIThinking=!1,s.isLoadingSource=!1,s.currentToolStatus=null,ie(s,"aborted");const o=t.value?.chatKey===n?t.value.aiChatId??oe:ts(s),r=s.aiChatBuffers[o],a=r?r.messages[r.messages.length-1]:void 0;if(a&&a.role==="assistant"&&a.isStreaming&&(a.isStreaming=!1,a.content+=`
|
|
4
|
+
`)}function ms(e,t=$s){return e.length<=t?e:e.slice(0,t)+zs}function X(){return bs("assistant-crud")}function le(){return bs("skill-crud")}const ks=ws,Ws={"zh-CN":"cn","zh-TW":"cn","en-US":"en","ja-JP":"ja"},Bs=is("assistant",()=>{const e=q([]),t=q(null),u=q(!1),f=new Set;let c=null;const h=q([]),D=q([]),b=q([]),M=q(!1),E=q(null),x=q("group"),H=q("zh-CN"),U=te(()=>t.value?e.value.find(m=>m.id===t.value)??null:null),V=te(()=>e.value.filter(m=>{const d=!m.applicableChatTypes?.length||m.applicableChatTypes.includes(x.value),T=!m.supportedLocales?.length||m.supportedLocales.some(j=>H.value.startsWith(j));return d&&T})),F=4,Y=te(()=>V.value.slice(0,F)),ce=te(()=>V.value.slice(F)),_=te(()=>V.value.length>F),K=te(()=>{const m=new Set(e.value.map(d=>d.id));return b.value.map(d=>({...d,imported:m.has(d.id)}))});function ue(m,d){x.value=m,H.value=d}async function N(){try{const m=X();e.value=await m.getAll(),u.value=!0}catch(m){console.error("[AssistantStore] Failed to load assistants:",m)}}async function ye(){try{h.value=await X().getBuiltinCatalog()}catch(m){console.error("[AssistantStore] Failed to load builtin catalog:",m)}}async function Re(){try{D.value=await X().getBuiltinToolCatalog()}catch(m){console.error("[AssistantStore] Failed to load builtin tool catalog:",m)}}async function ie(m){const d=Ws[m||H.value]??"en",T=`${ks}/${d}/assistant.json`;M.value=!0,E.value=null;try{const j=await He().fetchRemoteConfig(T);if(!j.success||!j.data){E.value=j.error||"Failed to fetch cloud catalog",b.value=[];return}const n=j.data;if(!Array.isArray(n)){E.value="Invalid catalog format",b.value=[];return}b.value=n.filter(s=>s.id&&s.name&&s.path)}catch(j){E.value=String(j),b.value=[]}finally{M.value=!1}}async function Te(m){const d=`${ks}${m.path}`;try{const T=await He().fetchRemoteConfig(d);if(!T.success||typeof T.data!="string")return{success:!1,error:T.error||"Failed to fetch assistant content"};const j=await X().importFromMd(T.data);return j.success&&await N(),j}catch(T){return{success:!1,error:String(T)}}}function Me(m){return e.value.some(d=>d.id===m)}function ve(m){t.value=m}function Ne(){t.value=null}async function Pe(m){try{return await X().getConfig(m)}catch(d){return console.error("[AssistantStore] Failed to get config:",d),null}}async function k(m,d){try{const T=await X().update(m,d);return T.success&&await N(),T}catch(T){return{success:!1,error:String(T)}}}async function I(m){try{const d=await X().reset(m);return d.success&&await N(),d}catch(d){return{success:!1,error:String(d)}}}async function R(m){const d=We(m);if(f.has(d))return null;f.add(d);try{const T=await X().getUpgradeInfo(d);if(!T)return null;try{if(c||(c={...(await Qe().getPreferences()).assistantUpgradeSkippedVersions}),T.latestVersion!==null&&c[T.builtinId]===T.latestVersion)return null}catch(j){console.error("[AssistantStore] Failed to load skipped assistant upgrades:",j)}return T}catch(T){return f.delete(d),console.error("[AssistantStore] Failed to check assistant upgrade:",T),null}}async function ee(m){if(m.latestVersion===null)return{success:!1,error:"Assistant template version is unavailable"};try{c||(c={...(await Qe().getPreferences()).assistantUpgradeSkippedVersions});const d={...c,[m.builtinId]:m.latestVersion},T=await Qe().savePreferences({assistantUpgradeSkippedVersions:d});return T.success&&(c=d),T}catch(d){return{success:!1,error:String(d)}}}async function de(m,d){try{const T=await X().upgradeWithBackup(m.assistantId,d);return T.success&&await N(),T}catch(T){return{success:!1,error:String(T)}}}async function Ae(m){try{const d=await X().importBuiltin(m);return d.success&&(await N(),await ye()),d}catch(d){return{success:!1,error:String(d)}}}async function Ue(m){try{const d=await X().reimport(m);return d.success&&(await N(),await ye()),d}catch(d){return{success:!1,error:String(d)}}}async function Le(m){try{const d=await X().create(m);return d.success&&await N(),d}catch(d){return{success:!1,error:String(d)}}}async function Je(m){try{const d=X(),T=await d.getConfig(m);if(!T)return{success:!1,error:"Assistant not found"};const{id:j,builtinId:n,...s}=T,o=await d.create({...s,name:`${T.name}${_s.global.t("ai.assistant.duplicateSuffix")}`});return o.success&&await N(),o}catch(d){return{success:!1,error:String(d)}}}async function Ve(m){try{const d=await X().delete(m);return d.success&&await N(),d}catch(d){return{success:!1,error:String(d)}}}return{assistants:e,selectedAssistantId:t,selectedAssistant:U,isLoaded:u,builtinCatalog:h,builtinToolCatalog:D,cloudCatalog:b,cloudLoading:M,cloudError:E,cloudCatalogWithStatus:K,currentChatType:x,currentLocale:H,filteredAssistants:V,defaultAssistants:Y,moreAssistants:ce,hasMoreAssistants:_,loadAssistants:N,loadBuiltinCatalog:ye,loadBuiltinToolCatalog:Re,fetchCloudCatalog:ie,importFromCloud:Te,isCloudItemImported:Me,selectAssistant:ve,clearSelection:Ne,setFilterContext:ue,getAssistantConfig:Pe,updateAssistant:k,createAssistant:Le,duplicateAssistant:Je,resetAssistant:I,checkDefaultAssistantUpgrade:R,skipAssistantUpgrade:ee,upgradeAssistantWithBackup:de,importAssistant:Ae,reimportAssistant:Ue,deleteAssistant:Ve}}),Is=ws,js={"zh-CN":"cn","zh-TW":"cn","en-US":"en","ja-JP":"ja"},Hs=is("skill",()=>{const e=q([]),t=q(null),u=q(!1),f=q([]),c=q([]),h=q(!1),D=q(null),b=q("group"),M=q("zh-CN");function E(){const k=M.value.startsWith("zh");return{id:xe,name:k?"绘图助手":"Chart Assistant",description:k?"按本轮问题生成灵活的聊天数据图表":"Generate flexible charts for this chat question",tags:[k?"图表":"chart"],chatScope:"all",tools:["render_chart","get_schema"],builtinId:xe}}const x=te(()=>t.value?t.value===xe?E():e.value.find(k=>k.id===t.value)??null:null),H=te(()=>E()),U=te(()=>e.value.filter(k=>k.chatScope==="all"||k.chatScope===b.value)),V=te(()=>{const I=Bs().selectedAssistant,R=[H.value,...U.value];return I?R.filter(ee=>(ee.tools.length,!0)):R}),F=te(()=>{const k={};for(const I of V.value){const R=I.tags[0]||"other";k[R]||(k[R]=[]),k[R].push(I)}return k}),Y=te(()=>{const k=new Set(e.value.map(I=>I.id));return c.value.map(I=>({...I,imported:k.has(I.id)}))});function ce(k,I){b.value=k,I&&(M.value=I)}async function _(){try{e.value=await le().getAll(),u.value=!0}catch(k){console.error("[SkillStore] Failed to load skills:",k)}}async function K(){try{f.value=await le().getBuiltinCatalog()}catch(k){console.error("[SkillStore] Failed to load builtin catalog:",k)}}async function ue(){const k=js[M.value]??"en",I=`${Is}/${k}/skill.json`;h.value=!0,D.value=null;try{const R=await He().fetchRemoteConfig(I);if(!R.success||!R.data){D.value=R.error||"Failed to fetch cloud catalog",c.value=[];return}const ee=R.data;if(!Array.isArray(ee)){D.value="Invalid catalog format",c.value=[];return}c.value=ee.filter(de=>de.id&&de.name&&de.path)}catch(R){D.value=String(R),c.value=[]}finally{h.value=!1}}async function N(k){const I=`${Is}${k.path}`;try{const R=await He().fetchRemoteConfig(I);if(!R.success||typeof R.data!="string")return{success:!1,error:R.error||"Failed to fetch skill content"};const ee=await le().importFromMd(R.data);return ee.success&&await _(),ee}catch(R){return{success:!1,error:String(R)}}}function ye(k){return e.value.some(I=>I.id===k)}function Re(k){t.value=k}async function ie(k){if(k===xe)return{...E(),prompt:"",builtinId:xe};try{return await le().getConfig(k)}catch(I){return console.error("[SkillStore] Failed to get skill config:",I),null}}async function Te(k,I){try{const R=await le().update(k,I);return R.success&&await _(),R}catch(R){return{success:!1,error:String(R)}}}async function Me(k){try{const I=await le().create(k);return I.success&&await _(),I}catch(I){return{success:!1,error:String(I)}}}async function ve(k){try{const I=await le().delete(k);return I.success&&(t.value===k&&(t.value=null),await _()),I}catch(I){return{success:!1,error:String(I)}}}async function Ne(k){try{const I=await le().importBuiltin(k);return I.success&&(await _(),await K()),I}catch(I){return{success:!1,error:String(I)}}}async function Pe(k){try{const I=await le().reimport(k);return I.success&&(await _(),await K()),I}catch(I){return{success:!1,error:String(I)}}}return{skills:e,activeSkillId:t,builtinCatalog:f,isLoaded:u,currentChatType:b,currentLocale:M,activeSkill:x,scopedSkills:U,compatibleSkills:V,groupedSkills:F,cloudCatalog:c,cloudLoading:h,cloudError:D,cloudCatalogWithStatus:Y,setFilterContext:ce,loadSkills:_,loadBuiltinCatalog:K,fetchCloudCatalog:ue,importFromCloud:N,isCloudItemImported:ye,activateSkill:Re,getSkillConfig:ie,updateSkill:Te,createSkill:Me,deleteSkill:ve,importSkill:Ne,reimportSkill:Pe}});async function Rs(e){const{url:t,method:u="POST",headers:f={},body:c,signal:h,onEvent:D}=e,b=await xs(t,{method:u,headers:{"Content-Type":"application/json",...f},body:c!=null?JSON.stringify(c):void 0,signal:h});if(!b.ok){const U=await b.text().catch(()=>"");throw new Error(`SSE request failed: HTTP ${b.status} ${U}`)}if(!b.body)throw new Error("SSE response has no body");const M=b.body.getReader(),E=new TextDecoder;let x="",H="";for(;;){const{done:U,value:V}=await M.read();if(U)break;x+=E.decode(V,{stream:!0});const F=x.split(`
|
|
5
|
+
`);x=F.pop()||"";for(const Y of F)Y.startsWith("event: ")?H=Y.slice(7).trim():Y.startsWith("data: ")&&(D({event:H,data:Y.slice(6)}),H="")}x.trim()&&x.startsWith("data: ")&&D({event:H,data:x.slice(6)})}function ut(){return{async chatStream(e,t,u){let f;try{return await Rs({url:"/_web/ai/llm/chat-stream",body:{messages:e,options:t},onEvent:({data:c})=>{try{const h=JSON.parse(c);h.finishReason==="error"&&h.error&&(f=h.error),u?.(h)}catch{}}}),f?{success:!1,error:f}:{success:!0}}catch(c){const h=c instanceof Error?c.message:String(c);return{success:!1,error:f??h}}}}}const Be=new Map;function es(){return{runStream(e,t){const u=Date.now();ds("ai_request_started");const f=new AbortController,c=`local_${Date.now()}_${Math.random().toString(36).slice(2,8)}`;Be.set(c,{serverId:"",abortController:f});const D=new Promise(b=>{let M="";const E=[];let x=0,H,U=!1,V;Rs({url:"/_web/ai/agent/stream",body:e,signal:f.signal,onEvent:({event:F,data:Y})=>{try{const ce=JSON.parse(Y);if(F==="meta"){const K=Be.get(c);K&&(K.serverId=ce.requestId??"");return}const _=ce;switch(t?.(_),_.type){case"content":_.content&&(M+=_.content);break;case"tool_start":_.toolName&&E.push(_.toolName);break;case"status":_.status&&(x=_.status.round);break;case"done":_.usage&&(H=_.usage);break;case"error":U=!0,V=_.error;break}}catch{}}}).then(()=>{Be.delete(c),b({success:!U,result:{content:M,toolsUsed:E,toolRounds:x,totalUsage:H},...U&&V?{error:V}:{}})}).catch(F=>{Be.delete(c),f.signal.aborted?b({success:!1,result:{content:M,toolsUsed:E,toolRounds:x,aborted:!0}}):b({success:!1,error:{name:"FetchError",message:F.message??String(F),stack:null}})})}).then(b=>(ds("ai_request_completed",{success:b.success,duration_ms:Date.now()-u,...b.success?{}:{failure_reason:b.result?.aborted?"aborted":b.error?.name==="FetchError"?"network":"unknown"}}),b));return{requestId:c,promise:D}},async abort(e){const t=Be.get(e);if(!t)return{success:!1,error:"Request not found"};if(t.abortController.abort(),t.serverId)try{const{post:u}=await Us(async()=>{const{post:f}=await import("./index-DkWTvE7d.js").then(c=>c.cP);return{post:f}},__vite__mapDeps([0,1,2]));await u("/ai/agent/abort",{requestId:t.serverId})}catch{}return Be.delete(e),{success:!0}}}}function Js(e){return e.desensitize&&!e.desensitizeRules.some(t=>t.builtin)}function Vs(e){if(e.dataCleaning||e.mergeConsecutive||e.blacklistKeywords.length>0||e.denoise||e.desensitize||e.anonymizeNames)return{dataCleaning:e.dataCleaning,mergeConsecutive:e.mergeConsecutive,mergeWindowSeconds:e.mergeWindowSeconds,blacklistKeywords:[...e.blacklistKeywords],denoise:e.denoise,desensitize:e.desensitize,desensitizeRules:e.desensitizeRules.map(u=>({...u,locales:[...u.locales]})),anonymizeNames:e.anonymizeNames}}function ae(e){return e==="render_chart"}function Gs(e,t,u){if(!e||!ae(e))return null;const f=e;return{type:"tool",tool:{name:f,displayName:f,status:"running",params:t,toolCallId:u,transient:!0}}}function Ms(e,t,u){if(!Z(e))return!1;const f=e;return f.type!=="tool"||!f.tool||f.tool.transient!==!0||f.tool.name!==t||u&&f.tool.toolCallId!==u?!1:ae(String(f.tool.name))}function Ys(e,t,u){let f=!1;const c=[...e];for(let h=c.length-1;h>=0;h--)if(Ms(c[h],t,u)){c.splice(h,1),f=!0;break}return f?c:[...e]}function Z(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function ys(e){return Z(e)&&e.version===1&&Z(e.spec)&&Z(e.dataset)}function ns(e){if(!Z(e))return[];const t=Z(e.details)?e.details:e,u=[];if(ys(t.chart)&&u.push(t.chart),Array.isArray(t.charts))for(const f of t.charts)ys(f)&&u.push(f);return u}function Ns(e){return{...e,dataset:{...e.dataset,rows:[]}}}function Ps(e){return e.map(t=>({type:"chart",chart:Ns(t)}))}function rs(e){return Array.isArray(e)?`[${e.map(rs).join(",")}]`:Z(e)?`{${Object.keys(e).sort().map(t=>`${JSON.stringify(t)}:${rs(e[t])}`).join(",")}}`:JSON.stringify(e)}function Ss(e){const t=Ns(e);return rs({spec:t.spec,columns:t.dataset.columns,data:t.data,rowCount:t.rowCount,truncated:t.truncated})}function Xs(e,t){const u=Ss(t);return e.some(f=>{if(!Z(f))return!1;const c=f;return c.type==="chart"&&c.chart?Ss(c.chart)===u:!1})}function Zs(e,t,u,f){const c=[...e];let h=-1;for(let E=c.length-1;E>=0;E--)if(Ms(c[E],t,u)){h=E;break}const D=h>=0?c.filter((E,x)=>x!==h):c,b=f.filter(E=>!Xs(D,E)),M=Ps(b);return h>=0?(c.splice(h,1,...M),c):[...c,...M]}function Qs(e,t,u,f,c){if(f.length>0)return Zs(e,t,u,f);const h=Ys(e,t,u);return c?[...h,c]:h}function dt(e,t,u){const f=e[t];return!Z(f)||f.type!=="error"||!Z(f.error)||f.error.name!=="ChartRenderError"?!1:u?.isStreaming?!0:e.slice(t+1).some(c=>Z(c)&&c.type==="chart")}function Ks(e){return Z(e)?typeof e.error=="string"?e.error:Z(e.error)&&typeof e.error.message=="string"?e.error.message:Array.isArray(e.content)?e.content.map(t=>Z(t)&&t.type==="text"&&typeof t.text=="string"?t.text:"").join(`
|
|
6
|
+
`).trim():null:null}function hs(e,t){if(!ae(e)||ns(t).length>0)return null;const u=Ks(t);if(!u)return null;const c=/^Error:\s*(.+)$/is.exec(u)?.[1]?.trim();return!c||/^Call get_schema before render_chart\b/i.test(c)?null:{type:"error",error:{name:"ChartRenderError",message:c,stack:null}}}function je(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function ss(e){return je(e)&&e.version===1&&typeof e.query=="string"&&Array.isArray(e.groups)}function Ts(e){if(!je(e))return null;const t=je(e.details)?e.details:null;if(t&&ss(t.evidence))return t.evidence;const u=je(e.data)?e.data:null;return u&&ss(u.evidence)?u.evidence:ss(e.evidence)?e.evidence:null}function et(e){return{type:"evidence",evidence:e}}function vs(e){return JSON.parse(JSON.stringify(e))}function ls(e){return JSON.parse(JSON.stringify(e))}function Es(e){return e?.type==="plan_draft"&&typeof e.text=="string"}function st(e,t){const u=e.map(ls),f=u[u.length-1];return Es(f)?f.text+=t:u.push({type:"plan_draft",version:1,status:"streaming",text:t}),u}function tt(e,t){const u=e.map(ls);for(let f=u.length-1;f>=0;f--){const c=u[f];if(Es(c)){const h=c.text.trim();return u[f]={...vs(t),...h?{displayText:h}:{}},u}}return u.push(vs(t)),u}function nt(e){return e.filter(t=>t.type!=="plan_draft").map(ls)}function As(e){if(!e)return;const t=JSON.parse(JSON.stringify(e));for(const u of t)u.type==="tool"&&delete u.tool.displayResult;return t}const oe="__draft__";function rt(e){return e?`${e.startTs}_${e.endTs}`:"all"}function ot(e){return`${e.sessionId}:${e.chatType}:${rt(e.timeFilter)}`}function os(){return{promptTokens:0,completionTokens:0,totalTokens:0,cacheReadTokens:0,cacheWriteTokens:0}}function Cs(e){return{promptTokens:e.promptTokens??0,completionTokens:e.completionTokens??0,totalTokens:e.totalTokens??0,cacheReadTokens:e.cacheReadTokens??0,cacheWriteTokens:e.cacheWriteTokens??0}}function $e(e){if(e&&typeof e=="object"){const t=e;return{name:typeof t.name=="string"?t.name:null,message:typeof t.message=="string"?t.message:"未知错误",stack:typeof t.stack=="string"?t.stack:null,statusCode:typeof t.statusCode=="number"?t.statusCode:null,url:typeof t.url=="string"?t.url:null,responseBody:typeof t.responseBody=="string"?t.responseBody:null,responseHeaders:t.responseHeaders&&typeof t.responseHeaders=="object"?t.responseHeaders:null,requestBody:typeof t.requestBody=="string"?t.requestBody:null,cause:typeof t.cause=="string"?t.cause:null,provider:typeof t.provider=="string"?t.provider:null,friendlyMessage:typeof t.friendlyMessage=="string"?t.friendlyMessage:null}}return{name:null,message:e?String(e):"未知错误",stack:null}}function ze(e){return{id:e.id,role:e.role,content:e.content,timestamp:e.timestamp*1e3,parentId:e.parentId,contentBlocks:e.contentBlocks}}function as(e=null){return{messages:[],sourceMessages:[],currentKeywords:[],assistantId:e,loaded:!1}}function at(e){const t=as(null);return{sessionId:e.sessionId,sessionName:e.sessionName,chatType:e.chatType,locale:e.locale,timeFilter:e.timeFilter,selectedAssistantId:null,messages:t.messages,sourceMessages:t.sourceMessages,currentKeywords:t.currentKeywords,isLoadingSource:!1,isAIThinking:!1,currentAIChatId:null,currentToolStatus:null,toolsUsedInCurrentRound:[],sessionTokenUsage:os(),agentStatus:null,ownerInfo:void 0,ownerInfoInitialized:!1,isAborted:!1,currentRequestId:"",currentAgentRequestId:"",aiChatBuffers:{[oe]:t}}}function ts(e){return e.currentAIChatId??oe}const ft=is("aiChatRuntime",()=>{const e=q({}),t=q(null),u=Os(),f=Ls(),c=qs(),h=Bs(),D=Hs(),b=Ds(),{aiGlobalSettings:M}=Fs(u);let E=!1;function x(n){return`${n}_${Date.now()}_${Math.random().toString(36).slice(2,8)}`}function H(n){const s=ot(n),o=e.value[s];if(o)return o.sessionName=n.sessionName,o.chatType=n.chatType,o.locale=n.locale,o.timeFilter=n.timeFilter,{chatKey:s,state:o};const r=at(n);e.value[s]=r;const a=e.value[s];return K(s),{chatKey:s,state:a}}function U(n){return e.value[n]??null}function V(){return t.value?U(t.value.chatKey):null}function F(n,s,o=null){return n.aiChatBuffers[s]||(n.aiChatBuffers[s]=as(o)),n.aiChatBuffers[s]}function Y(n,s){const o=n.currentAIChatId??oe,r=n.aiChatBuffers[o];r&&(r.sessionTokenUsage={...n.sessionTokenUsage});const a=F(n,s);n.currentAIChatId=s===oe?null:s,n.messages=a.messages,n.sourceMessages=a.sourceMessages,n.currentKeywords=a.currentKeywords,n.selectedAssistantId=a.assistantId,n.sessionTokenUsage=a.sessionTokenUsage?{...a.sessionTokenUsage}:os(),n.agentStatus=null}function ce(n,s,o){const r=F(n,s);return n.aiChatBuffers[o]=r,s!==o&&delete n.aiChatBuffers[s],n.currentAIChatId===null&&s===oe&&(n.currentAIChatId=o),r}function _(n){const s=U(n);s&&(s.selectedAssistantId?h.selectAssistant(s.selectedAssistantId):h.clearSelection())}async function K(n){const s=U(n);if(!s)return;const r=f.sessions.find(a=>a.id===s.sessionId)?.ownerId;if(!r){s.ownerInfo=void 0,s.ownerInfoInitialized=!0;return}if(!(s.ownerInfoInitialized&&s.ownerInfo?.platformId===r))try{const w=(await fs().getMembers(s.sessionId)).find(v=>v.platformId===r);s.ownerInfo=w?{platformId:r,displayName:w.groupNickname||w.accountName||r}:{platformId:r,displayName:r},s.ownerInfoInitialized=!0}catch(a){console.error("[AI] 获取 Owner 信息失败:",a),s.ownerInfo=void 0,s.ownerInfoInitialized=!0}}function ue(n,s,o,r=null){const a=U(n);a&&(t.value={requestId:o,chatKey:n,sessionId:a.sessionId,sessionName:a.sessionName,chatType:a.chatType,aiChatId:r,questionPreview:s.trim().slice(0,80),startedAt:Date.now()})}function N(n,s){t.value&&t.value.chatKey===n&&(s&&t.value.requestId!==s||(t.value=null))}function ye(n,s){t.value&&t.value.chatKey===n&&(t.value.aiChatId=s)}function Re(n){return{phase:"preparing",round:0,toolsUsed:n.toolsUsedInCurrentRound.length,contextTokens:0,totalUsage:{...n.sessionTokenUsage},updatedAt:Date.now()}}function ie(n,s,o){const r=n.agentStatus?{...n.agentStatus}:Re(n);n.agentStatus={...r,...o,phase:s,updatedAt:Date.now()}}function Te(n,s){const o=U(n);if(!o||o.isAIThinking)return!1;const r=F(o,ts(o),s);return r.assistantId=s,o.selectedAssistantId=s,h.selectAssistant(s),!0}async function Me(n,s){const o=U(n);if(!o)return!1;try{const r=await re().getAIChat(s),a=F(o,s,r?.assistantId??null);if(!a.loaded){const[w,v]=await Promise.all([re().getMessages(s),re().getAIChatTokenUsage(s)]);a.messages.splice(0,a.messages.length,...w.map(S=>ze(S))),a.sourceMessages.splice(0,a.sourceMessages.length),a.currentKeywords.splice(0,a.currentKeywords.length),a.sessionTokenUsage=Cs(v),a.loaded=!0}return a.assistantId=r?.assistantId??a.assistantId??null,Y(o,s),_(n),!0}catch(r){return console.error("[AI] 加载对话历史失败:",r),!1}}function ve(n,s){const o=U(n);if(!o)return!1;const r=s??oe;return o.aiChatBuffers[r]?(Y(o,r),_(n),!0):!1}function Ne(){return t.value?(E=!0,ve(t.value.chatKey,t.value.aiChatId)):!1}async function Pe(n){if(E){E=!1;return}const s=U(n);if(!(!s||s.isAIThinking)){if(h.isLoaded||await h.loadAssistants(),!s.selectedAssistantId){const o=We(s.locale);Te(n,o)}k(n)}}function k(n,s){const o=U(n);if(!o||o.isAIThinking)return!1;const r=as(o.selectedAssistantId);return o.aiChatBuffers[oe]=r,Y(o,oe),o.currentToolStatus=null,o.toolsUsedInCurrentRound=[],o.isLoadingSource=!1,o.sessionTokenUsage=os(),o.agentStatus=null,o.isAborted=!1,o.currentRequestId="",o.currentAgentRequestId="",s&&r.messages.push({id:x("welcome"),role:"assistant",content:s,timestamp:Date.now()}),!0}async function I(){}async function R(){}function ee(n,s){const o=p=>{const y=s();n.messages[y]={...n.messages[y],...p}};return{updateAIMessage:o,appendTextToBlocks:p=>{if(!p)return;const y=s(),l=n.messages[y].contentBlocks||[],C=l[l.length-1];p.trim().length===0&&(!C||C.type!=="text")||(C&&C.type==="text"?C.text+=p:l.push({type:"text",text:p}),o({contentBlocks:[...l],content:n.messages[y].content+p}))},appendThinkToBlocks:(p,y,l)=>{if(!p&&l===void 0)return;const C=s(),B=n.messages[C].contentBlocks||[],J=y||"think",W=B[B.length-1];let L=W;if(W&&W.type==="think"&&W.tag===J)W.text+=p;else if(p.trim().length>0)L={type:"think",tag:J,text:p},B.push(L);else if(l!==void 0)for(let G=B.length-1;G>=0;G--){const Se=B[G];if(Se.type==="think"&&Se.tag===J){L=Se;break}}l!==void 0&&L&&L.type==="think"&&(L.durationMs=l),o({contentBlocks:[...B]})},appendChartsToBlocks:p=>{if(p.length===0)return;const y=s(),l=n.messages[y].contentBlocks||[];l.push(...Ps(p)),o({contentBlocks:[...l]})},appendEvidenceToBlocks:p=>{const y=s(),l=n.messages[y].contentBlocks||[];l.push(et(p)),o({contentBlocks:[...l]})},appendPlanDraftToBlocks:p=>{if(!p)return;const y=s(),l=n.messages[y].contentBlocks||[];o({contentBlocks:[...st(l,p)]})},appendPlanToBlocks:p=>{const y=s(),l=n.messages[y].contentBlocks||[];o({contentBlocks:[...tt(l,p)]})},removePlanDraftsFromBlocks:()=>{const p=s(),y=n.messages[p].contentBlocks||[];o({contentBlocks:[...nt(y)]})},updatePlanBlockStatus:p=>{const y=s(),l=n.messages[y].contentBlocks||[];for(let C=l.length-1;C>=0;C--){const B=l[C];if(B.type==="plan"){B.status=p;break}}o({contentBlocks:[...l]})},appendErrorToBlocks:p=>{const y=s(),l=n.messages[y].contentBlocks||[];l.push({type:"error",error:p}),o({contentBlocks:[...l]})},addToolBlock:(p,y,l)=>{const C=s(),B=n.messages[C].contentBlocks||[];B.push({type:"tool",tool:{name:p,displayName:p,status:"running",params:y,toolCallId:l}}),o({contentBlocks:[...B]})},addRenderOnlyToolPendingBlock:(p,y,l)=>{const C=Gs(p,y,l);if(!C)return;const B=s(),J=n.messages[B].contentBlocks||[];J.push(C),o({contentBlocks:[...J]})},updateRenderOnlyToolResult:(p,y,l,C)=>{const B=s(),J=n.messages[B].contentBlocks||[];o({contentBlocks:Qs(J,p,y,l,C)})},updateToolBlockStatus:(p,y,l)=>{const C=s(),B=n.messages[C].contentBlocks||[],J=L=>L.type==="tool"&&L.tool.status==="running";let W;if(l?.toolCallId)for(let L=B.length-1;L>=0;L--){const G=B[L];if(J(G)&&G.tool.toolCallId===l.toolCallId){W=G;break}}if(!W)for(let L=B.length-1;L>=0;L--){const G=B[L];if(J(G)&&G.tool.name===p){W=G;break}}W&&(W.tool.status=y,l?.result!==void 0&&(W.tool.result=l.result),l?.displayResult!==void 0&&(W.tool.displayResult=l.displayResult),l?.isError!==void 0&&(W.tool.isError=l.isError)),o({contentBlocks:[...B]})}}}async function de(n,s,o){const r=U(n);if(!r)return{success:!1,reason:"error"};if(!s.trim())return{success:!1,reason:"empty"};if(r.isAIThinking||t.value)return{success:!1,reason:"busy",activeTask:t.value};const a=x("req"),w=ts(r);let v=w===oe?null:w;const S=F(r,w,r.selectedAssistantId);let P,A;S.assistantId=r.selectedAssistantId,S.loaded=!0,ue(n,s,a,v),_(n),K(n);const $=D.activeSkillId,fe=D.activeSkill?.name,pe=M.value.enableAutoSkill??!0,ge=pe?M.value.chartAutoMode??"suggest":"explicit",Ce=(o?.mentionedMembers??[]).map(z=>({memberId:z.memberId,platformId:z.platformId,displayName:z.displayName,aliases:[...z.aliases],mentionText:z.mentionText}));r.isAIThinking=!0,r.isLoadingSource=!0,r.currentToolStatus=null,r.toolsUsedInCurrentRound=[],r.agentStatus=null,r.isAborted=!1,r.currentRequestId=a,r.currentAgentRequestId="";try{const z=await Ke().hasConfig();if(r.isAborted)return N(n,a),{success:!1,reason:"aborted"};if(r.currentRequestId!==a)return N(n,a),{success:!1,reason:"busy",activeTask:t.value};if(!z)return S.messages.push({id:x("error"),role:"assistant",content:"⚠️ 请先配置 AI 服务。点击左下角「设置」按钮前往「模型配置Tab」进行配置。",timestamp:Date.now()}),N(n,a),{success:!1,reason:"no_config"};const p={id:x("user"),role:"user",content:s,timestamp:Date.now(),toolCalls:[]};P=p,S.messages.push(p);const y={id:x("ai"),role:"assistant",content:"",timestamp:Date.now(),isStreaming:!0,contentBlocks:[]};$&&fe&&y.contentBlocks.push({type:"skill",skillId:$,skillName:fe}),S.messages.push(y);let l=S.messages.length-1,C=!1;const{updateAIMessage:B,appendTextToBlocks:J,appendThinkToBlocks:W,appendChartsToBlocks:L,appendEvidenceToBlocks:G,appendPlanDraftToBlocks:Se,appendPlanToBlocks:qe,removePlanDraftsFromBlocks:be,updatePlanBlockStatus:Ee,appendErrorToBlocks:Ge,addToolBlock:Ye,addRenderOnlyToolPendingBlock:Xe,updateRenderOnlyToolResult:De,updateToolBlockStatus:se}=ee(S,()=>l),me=S.assistantId??We(r.locale);if(!v){const i=s.slice(0,50)+(s.length>50?"...":""),O=await re().createAIChat(r.sessionId,i,me);if(r.isAborted)return B({isStreaming:!1}),N(n,a),{success:!1,reason:"aborted"};if(r.currentRequestId!==a)return B({isStreaming:!1}),N(n,a),{success:!1,reason:"busy",activeTask:t.value};v=O.id,ce(r,oe,O.id),S.assistantId=me,ye(n,O.id)}const ke={sessionId:r.sessionId,aiChatId:v,timeFilter:r.timeFilter?{startTs:r.timeFilter.startTs,endTs:r.timeFilter.endTs}:void 0,maxMessagesLimit:M.value.maxMessagesPerRequest,ownerInfo:r.ownerInfo?{platformId:r.ownerInfo.platformId,displayName:r.ownerInfo.displayName}:void 0,mentionedMembers:Ce.length>0?Ce:void 0,preprocessConfig:await Ue(),searchContextBefore:M.value.searchContextBefore,searchContextAfter:M.value.searchContextAfter},{requestId:he,promise:Ze}=es().runStream({userMessage:s,sessionId:r.sessionId,aiChatId:v,timeFilter:ke.timeFilter,maxMessagesLimit:ke.maxMessagesLimit,ownerInfo:ke.ownerInfo,mentionedMembers:ke.mentionedMembers,preprocessConfig:ke.preprocessConfig,chatType:r.chatType,locale:r.locale,assistantId:me,skillId:$,enableAutoSkill:$?void 0:pe,chartAutoMode:$?void 0:ge,thinkingLevel:(()=>{const i=b.defaultAssistant;if(!(!i?.configId||!i?.modelId))return u.getThinkingLevel(i.configId,i.modelId)})()},i=>{if(!(r.isAborted||a!==r.currentRequestId))switch(i.type){case"content":i.content&&(r.currentToolStatus=null,J(i.content));break;case"think":i.content?W(i.content,i.thinkTag):i.thinkDurationMs!==void 0&&W("",i.thinkTag,i.thinkDurationMs);break;case"tool_start":if(i.toolName){const O=i.toolParams;r.currentToolStatus={name:i.toolName,displayName:i.toolName,status:"running"},r.toolsUsedInCurrentRound.push(i.toolName),ae(i.toolName)?Xe(i.toolName,O,i.toolCallId):Ye(i.toolName,O,i.toolCallId)}break;case"tool_result":if(i.toolName){const O=ns(i.toolResult),Q=hs(i.toolName,i.toolResult);ae(i.toolName)?De(i.toolName,i.toolCallId,O,Q):L(O);const Fe=Ts(i.toolResult);Fe&&G(Fe),Q&&(ae(i.toolName)||Ge(Q.error));const _e=Q!==null||i.toolIsError===!0;if(r.currentToolStatus?.name===i.toolName&&(r.currentToolStatus={...r.currentToolStatus,status:_e?"error":"done"}),!ae(i.toolName)){const we=gs(i.toolResult);se(i.toolName,_e?"error":"done",{toolCallId:i.toolCallId,result:ms(we),displayResult:we,isError:i.toolIsError})}}r.isLoadingSource=!1;break;case"plan_delta":i.planDelta&&Se(i.planDelta);break;case"plan":i.plan&&(qe(i.plan),Ee("executing"));break;case"plan_skipped":be();break;case"status":i.status&&(!r.agentStatus||i.status.updatedAt>=r.agentStatus.updatedAt)&&(r.agentStatus=i.status);break;case"compression_done":if(i.compressionResult){const O={id:`summary-${Date.now()}`,role:"summary",content:i.compressionResult.summaryContent,timestamp:i.compressionResult.timestamp},Q=Math.max(0,S.messages.length-1);S.messages.splice(Q,0,O),l++}break;case"done":r.currentToolStatus=null,C||Ee("done"),i.usage&&(A={...i.usage},r.sessionTokenUsage={promptTokens:r.sessionTokenUsage.promptTokens+i.usage.promptTokens,completionTokens:r.sessionTokenUsage.completionTokens+i.usage.completionTokens,totalTokens:r.sessionTokenUsage.totalTokens+i.usage.totalTokens,cacheReadTokens:r.sessionTokenUsage.cacheReadTokens+i.usage.cacheReadTokens,cacheWriteTokens:r.sessionTokenUsage.cacheWriteTokens+i.usage.cacheWriteTokens}),ie(r,"completed",i.usage?{totalUsage:i.usage}:void 0);break;case"error":if(be(),Ee("skipped"),r.currentToolStatus&&(r.currentToolStatus={...r.currentToolStatus,status:"error"},se(r.currentToolStatus.name,"error")),!C){C=!0;const O=S.messages[l].contentBlocks||[];O.push({type:"error",error:$e(i.error)}),B({contentBlocks:[...O],isStreaming:!1})}ie(r,"error");break}});r.currentAgentRequestId=he,ue(n,s,he,v);const ne=await Ze;if(r.isAborted)return N(n,he),{success:!1,reason:"aborted"};if(a!==r.currentRequestId)return N(n,he),{success:!1,reason:"busy",activeTask:t.value};if(ne.success&&ne.result){S.messages[l]={...S.messages[l],dataSource:{toolsUsed:ne.result.toolsUsed,toolRounds:ne.result.toolRounds},isStreaming:!1};const i=await Ae(v,p,S.messages[l],A);i&&(Object.assign(p,i.userMessage),S.messages[l]={...S.messages[l],...i.assistantMessage,isStreaming:!1})}else if(C){const i=await Ae(v,p,S.messages[l],A);i&&(Object.assign(p,i.userMessage),S.messages[l]={...S.messages[l],...i.assistantMessage,isStreaming:!1})}else{const i=S.messages[l].contentBlocks||[];i.push({type:"error",error:$e(ne.error)}),S.messages[l]={...S.messages[l],contentBlocks:[...i],isStreaming:!1};const O=await Ae(v,p,S.messages[l],A);O&&(Object.assign(p,O.userMessage),S.messages[l]={...S.messages[l],...O.assistantMessage,isStreaming:!1})}return{success:!0}}catch(z){console.error("[AI] 处理失败:",z),r.agentStatus=null;const p=S.messages[S.messages.length-1];if(p&&p.role==="assistant"){const y={name:z instanceof Error?z.name:null,message:z instanceof Error?z.message:String(z),stack:z instanceof Error?z.stack??null:null},l=p.contentBlocks||[];l.push({type:"error",error:y}),p.contentBlocks=[...l],p.isStreaming=!1;const C=P||S.messages.findLast(B=>B.role==="user");C&&await Ae(v,C,p,A)}return{success:!1,reason:"error"}}finally{r.isAIThinking=!1,r.isLoadingSource=!1,r.currentToolStatus=null,r.isAborted=!1,r.currentRequestId="",r.currentAgentRequestId="",N(n)}}async function Ae(n,s,o,r){try{if(!n)return null;const a=await re().addMessage(n,"user",s.content),w=As(o.contentBlocks),v=await re().addMessage(n,"assistant",o.content,void 0,void 0,w,r);return{userMessage:ze(a),assistantMessage:ze(v)}}catch(a){return console.error("[AI] 保存对话失败:",a),null}}async function Ue(){const n=c.aiPreprocessConfig;return Js(n)&&await c.ensureDesensitizeRules(),Vs(c.aiPreprocessConfig)}function Le(n){return n.trim().replace(/^[\s"'“”‘’([{<]+|[\s"'“”‘’)\]}>.,!?;:,。!?;:、]+$/g,"").toLocaleLowerCase()}async function Je(n,s){const o=new Set;for(const r of s.matchAll(/@([^\s@]+)/g)){const a=Le(r[1]??"");a&&o.add(a)}if(o.size===0)return[];try{const r=await fs().getMembers(n.sessionId),a=new Map;r.forEach(P=>{const A=P.groupNickname||P.accountName||P.platformId;a.set(A,(a.get(A)??0)+1)});const w=r.map(P=>{const A=P.groupNickname||P.accountName||P.platformId,$=(a.get(A)??0)>1?`${A}·${P.platformId}`:A,fe=[...P.aliases],pe=[A,P.groupNickname||"",P.accountName||"",P.platformId,$,...fe].map(Le).filter(Boolean);return{memberId:P.id,platformId:P.platformId,displayName:A,aliases:fe,mentionText:`@${$}`,lookupValues:pe}}),v=[],S=new Set;for(const P of o){const A=w.find($=>!S.has($.memberId)&&$.lookupValues.includes(P));A&&(S.add(A.memberId),v.push({memberId:A.memberId,platformId:A.platformId,displayName:A.displayName,aliases:A.aliases,mentionText:A.mentionText}))}return v}catch(r){return console.error("[AI] Failed to resolve mentioned members for edited message:",r),[]}}async function Ve(n,s,o,r){const a=U(n),w=o.trim();if(!a||!a.currentAIChatId)return{success:!1,reason:"error"};if(!w)return{success:!1,reason:"empty"};if(a.isAIThinking||t.value)return{success:!1,reason:"busy",activeTask:t.value};const v=r?.overwriteSubsequent??!1,S=F(a,a.currentAIChatId,a.selectedAssistantId),P=S.messages.findIndex($=>$.id===s),A=S.messages[P];return!A||A.role!=="user"||A.isStreaming?{success:!1,reason:"error"}:A.content.trim()===w?{success:!1,reason:"empty"}:v?m(n,a,S,P,A,w):d(n,a,S,P,A,w)}async function m(n,s,o,r,a,w){try{return await Ke().hasConfig()?s.isAborted?{success:!1,reason:"aborted"}:s.isAIThinking||t.value?{success:!1,reason:"busy",activeTask:t.value}:(await re().deleteMessagesFrom(s.currentAIChatId,a.id),o.messages.splice(r,o.messages.length-r),de(n,w)):{success:!1,reason:"no_config"}}catch(v){return console.error("[AI] edit and overwrite failed:",v),{success:!1,reason:"error"}}}async function d(n,s,o,r,a,w){const v=x("req");let S,P=!1;ue(n,w,v,s.currentAIChatId),_(n),K(n),s.isAIThinking=!0,s.isLoadingSource=!0,s.currentToolStatus=null,s.toolsUsedInCurrentRound=[],s.agentStatus=null,s.isAborted=!1,s.currentRequestId=v,s.currentAgentRequestId="";const A=o.messages[r+1],$=A?.role==="assistant",fe=$?o.messages.slice(r+2):o.messages.slice(r+1),pe={id:x("ai"),role:"assistant",content:"",timestamp:Date.now(),isStreaming:!0,contentBlocks:[]},ge=D.activeSkillId,Ce=D.activeSkill?.name;ge&&Ce&&pe.contentBlocks.push({type:"skill",skillId:ge,skillName:Ce});const z={...a,content:w},p=$?2:1;o.messages.splice(r,p,z,pe);const y=r+1,l=()=>{o.messages.splice(r,o.messages.length-r,a),$&&o.messages.splice(r+1,0,A),o.messages.push(...fe)},{updateAIMessage:C,appendTextToBlocks:B,appendThinkToBlocks:J,appendChartsToBlocks:W,appendEvidenceToBlocks:L,appendPlanDraftToBlocks:G,appendPlanToBlocks:Se,removePlanDraftsFromBlocks:qe,updatePlanBlockStatus:be,appendErrorToBlocks:Ee,addToolBlock:Ge,addRenderOnlyToolPendingBlock:Ye,updateRenderOnlyToolResult:Xe,updateToolBlockStatus:De}=ee(o,()=>y);try{if(!await Ke().hasConfig())return l(),N(n,v),{success:!1,reason:"no_config"};const me=o.assistantId??We(s.locale),ke=await Je(s,w);if(s.isAborted)return l(),N(n,v),{success:!1,reason:"aborted"};if(v!==s.currentRequestId)return l(),N(n,v),{success:!1,reason:"busy",activeTask:t.value};const he=M.value.enableAutoSkill??!0,Ze=he?M.value.chartAutoMode??"suggest":"explicit",ne={sessionId:s.sessionId,aiChatId:s.currentAIChatId,historyLeafMessageId:a.parentId??null,timeFilter:s.timeFilter?{startTs:s.timeFilter.startTs,endTs:s.timeFilter.endTs}:void 0,maxMessagesLimit:M.value.maxMessagesPerRequest,ownerInfo:s.ownerInfo?{platformId:s.ownerInfo.platformId,displayName:s.ownerInfo.displayName}:void 0,mentionedMembers:ke.length>0?ke:void 0,preprocessConfig:await Ue(),searchContextBefore:M.value.searchContextBefore,searchContextAfter:M.value.searchContextAfter},{requestId:i,promise:O}=es().runStream({userMessage:w,sessionId:s.sessionId,aiChatId:s.currentAIChatId,historyLeafMessageId:a.parentId??null,timeFilter:ne.timeFilter,maxMessagesLimit:ne.maxMessagesLimit,ownerInfo:ne.ownerInfo,mentionedMembers:ne.mentionedMembers,preprocessConfig:ne.preprocessConfig,chatType:s.chatType,locale:s.locale,assistantId:me,skillId:ge,enableAutoSkill:ge?void 0:he,chartAutoMode:ge?void 0:Ze,thinkingLevel:(()=>{const g=b.defaultAssistant;if(!(!g?.configId||!g?.modelId))return u.getThinkingLevel(g.configId,g.modelId)})()},g=>{if(!(s.isAborted||v!==s.currentRequestId))switch(g.type){case"content":s.currentToolStatus=null,B(g.content||"");break;case"think":g.content?J(g.content,g.thinkTag):g.thinkDurationMs!==void 0&&J("",g.thinkTag,g.thinkDurationMs);break;case"tool_start":if(g.toolName){const Ie=g.toolParams;s.currentToolStatus={name:g.toolName,displayName:g.toolName,status:"running"},s.toolsUsedInCurrentRound.push(g.toolName),ae(g.toolName)?Ye(g.toolName,Ie,g.toolCallId):Ge(g.toolName,Ie,g.toolCallId)}break;case"tool_result":if(g.toolName){const Ie=ns(g.toolResult),Oe=hs(g.toolName,g.toolResult);ae(g.toolName)?Xe(g.toolName,g.toolCallId,Ie,Oe):W(Ie);const cs=Ts(g.toolResult);if(cs&&L(cs),Oe&&(ae(g.toolName)||Ee(Oe.error)),!ae(g.toolName)){const us=gs(g.toolResult);De(g.toolName,Oe!==null||g.toolIsError===!0?"error":"done",{toolCallId:g.toolCallId,result:ms(us),displayResult:us,isError:g.toolIsError})}}s.currentToolStatus=null,s.isLoadingSource=!1;break;case"plan_delta":g.planDelta&&G(g.planDelta);break;case"plan":g.plan&&(Se(g.plan),be("executing"));break;case"plan_skipped":qe();break;case"status":g.status&&(!s.agentStatus||g.status.updatedAt>=s.agentStatus.updatedAt)&&(s.agentStatus=g.status);break;case"done":s.currentToolStatus=null,P||be("done"),g.usage&&(S={...g.usage}),ie(s,"completed",g.usage?{totalUsage:g.usage}:void 0);break;case"error":{qe(),be("skipped"),P=!0,s.currentToolStatus&&De(s.currentToolStatus.name,"error");const Ie=o.messages[y].contentBlocks||[];Ie.push({type:"error",error:$e(g.error)}),C({contentBlocks:[...Ie],isStreaming:!1}),ie(s,"error");break}}});s.currentAgentRequestId=i,ue(n,w,i,s.currentAIChatId);const Q=await O;if(s.isAborted)return l(),N(n,i),{success:!1,reason:"aborted"};if(v!==s.currentRequestId)return l(),N(n,i),{success:!1,reason:"busy",activeTask:t.value};if(Q.success&&Q.result)C({dataSource:{toolsUsed:Q.result.toolsUsed,toolRounds:Q.result.toolRounds},isStreaming:!1});else if(!P){const g=o.messages[y].contentBlocks||[];g.push({type:"error",error:$e(Q.error)}),C({contentBlocks:[...g],isStreaming:!1})}if(!Q.success)return l(),{success:!1,reason:"error"};await re().updateMessageContent(a.id,w),$&&await re().deleteAndRelinkMessage(s.currentAIChatId,A.id);const Fe=As(o.messages[y].contentBlocks),_e=await re().insertMessageAfter(s.currentAIChatId,a.id,"assistant",o.messages[y].content,Fe,S);o.messages[y]={...ze(_e),dataSource:o.messages[y].dataSource,isStreaming:!1},o.messages[r]={...o.messages[r],content:w};const we=y+1;return we<o.messages.length&&(o.messages[we]={...o.messages[we],parentId:_e.id}),o.sessionTokenUsage=Cs(await re().getAIChatTokenUsage(s.currentAIChatId)),s.sessionTokenUsage={...o.sessionTokenUsage},{success:!0}}catch(se){if(s.isAborted)return l(),{success:!1,reason:"aborted"};console.error("[AI] edit and regenerate failed:",se);const me=o.messages[y]?.contentBlocks||[];return me.push({type:"error",error:{name:se instanceof Error?se.name:null,message:se instanceof Error?se.message:String(se),stack:se instanceof Error?se.stack??null:null}}),o.messages[y]&&C({contentBlocks:[...me],isStreaming:!1}),{success:!1,reason:"error"}}finally{s.isAIThinking=!1,s.isLoadingSource=!1,s.currentToolStatus=null,s.isAborted=!1,s.currentRequestId="",s.currentAgentRequestId="",N(n)}}async function T(n){const s=U(n);if(!s||!s.isAIThinking)return!1;s.isAborted=!0,s.isAIThinking=!1,s.isLoadingSource=!1,s.currentToolStatus=null,ie(s,"aborted");const o=t.value?.chatKey===n?t.value.aiChatId??oe:ts(s),r=s.aiChatBuffers[o],a=r?r.messages[r.messages.length-1]:void 0;if(a&&a.role==="assistant"&&a.isStreaming&&(a.isStreaming=!1,a.content+=`
|
|
7
7
|
|
|
8
|
-
_(已停止生成)_`),s.currentAgentRequestId)try{await es().abort(s.currentAgentRequestId)}catch(w){console.error("[AI] 中止 Agent 请求失败:",w)}return s.currentRequestId="",s.currentAgentRequestId="",N(n),!0}async function j(){return t.value?T(t.value.chatKey):!1}return{sessionStates:e,activeTask:t,ensureSessionState:
|
|
8
|
+
_(已停止生成)_`),s.currentAgentRequestId)try{await es().abort(s.currentAgentRequestId)}catch(w){console.error("[AI] 中止 Agent 请求失败:",w)}return s.currentRequestId="",s.currentAgentRequestId="",N(n),!0}async function j(){return t.value?T(t.value.chatKey):!1}return{sessionStates:e,activeTask:t,ensureSessionState:H,getSessionState:U,getActiveTaskState:V,applySessionAssistantSelection:_,selectAssistantForSession:Te,loadAIChat:Me,focusAIChat:ve,focusActiveTaskAIChat:Ne,resetToSelectorOnEnter:Pe,startNewAIChat:k,loadMoreSourceMessages:I,updateMaxMessages:R,sendMessage:de,editMessageAndRegenerate:Ve,stopGeneration:T,stopActiveTask:j}});export{ut as a,Hs as b,Bs as c,dt as s,ft as u};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as u,af as h,o as m,c as x,f,ag as e}from"./index-DkWTvE7d.js";import{_ as y}from"./EChart.vue_vue_type_script_setup_true_lang-CsgJ-Xn3.js";const L=u({__name:"EChartBar",props:{data:{},height:{default:200},mode:{default:"expanded"},horizontal:{type:Boolean,default:!1},gradient:{type:Boolean,default:!0},borderRadius:{default:4}},setup(t){const o=t,s=h(),i=f(()=>s.value==="dark"),n={type:"linear",x:0,y:0,x2:0,y2:1,colorStops:[{offset:0,color:"#ee4567"},{offset:1,color:"#f7758c"}]},p=f(()=>{const a=o.horizontal,l=o.mode==="compact",c=o.data.labels.length,r=i.value?"#a1a1aa":"#6b7280",d=i.value?"rgba(255, 255, 255, 0.08)":"#e5e7eb";return{tooltip:{trigger:"axis",confine:!0,extraCssText:"max-width: min(360px, 70vw); white-space: normal; word-break: break-word;",axisPointer:{type:"shadow"},backgroundColor:"rgba(0, 0, 0, 0.8)",borderColor:"transparent",textStyle:{color:"#fff"}},grid:{left:a?l?72:96:36,right:16,top:20,bottom:a?20:c>8?48:30,outerBoundsMode:"same"},xAxis:a?{type:"value",axisLine:{show:!1},axisTick:{show:!1},splitLine:{lineStyle:{type:"dashed",color:d}},axisLabel:{fontSize:11,color:r}}:{type:"category",data:o.data.labels,axisLine:{show:!1},axisTick:{show:!1},axisLabel:{fontSize:11,color:r,interval:"auto",rotate:!a&&c>8?28:0,hideOverlap:!0}},yAxis:a?{type:"category",data:o.data.labels,axisLine:{show:!1},axisTick:{show:!1},axisLabel:{fontSize:11,color:r,overflow:"truncate",width:l?70:110}}:{type:"value",axisLine:{show:!1},axisTick:{show:!1},splitLine:{lineStyle:{type:"dashed",color:d}},axisLabel:{fontSize:11,color:r}},series:[{type:"bar",data:o.data.values,itemStyle:{color:o.gradient?n:"#ee4567",borderRadius:o.borderRadius},barMaxWidth:40,emphasis:{itemStyle:{color:o.gradient?{...n,colorStops:[{offset:0,color:"#de335e"},{offset:1,color:"#ee4567"}]}:"#de335e"}}}]}});return(a,l)=>(m(),x(y,{option:p.value,height:t.height},null,8,["option","height"]))}}),g={[e.TEXT]:"text",[e.IMAGE]:"image",[e.VOICE]:"voice",[e.VIDEO]:"video",[e.FILE]:"file",[e.EMOJI]:"emoji",[e.LINK]:"link",[e.LOCATION]:"location",[e.RED_PACKET]:"redPacket",[e.TRANSFER]:"transfer",[e.POKE]:"poke",[e.CALL]:"call",[e.SHARE]:"share",[e.REPLY]:"reply",[e.FORWARD]:"forward",[e.CONTACT]:"contact",[e.SYSTEM]:"system",[e.RECALL]:"recall",[e.OTHER]:"other"};function T(t,o){const s=g[t];return o&&s?o(`common.messageType.${s}`):o?o("common.messageType.unknown"):"未知"}export{L as _,T as g};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{t as M,U as Z,P as f,v as te,j as y,E as ie,w as g,r as P,x as V}from"./RelationshipGalaxyCanvas-6EamagxG.js";import"./webworkerAll-Dwqmy_YO.js";import"./index-D5m0P4ss.js";import"./vendor-snapdom--nZvo8Sg.js";import"./index-IA7YUjQX.js";import"./Tabs-OrJkANIA.js";import"./RovingFocusItem-B2y6BG1a.js";import"./useToast-B36MzFFy.js";import"./LoadingState.vue_vue_type_script_setup_true_lang-Cnshyn0f.js";import"./people-page-header-Bh3KXD4g.js";import"./relationship-galaxy-connections-Cg4G5yYE.js";import"./relationship-galaxy-viewport-Cwfa51ER.js";import"./Filter-DVaqcFmI.js";class q{constructor(e){this._lastTransform="",this._observer=null,this._tickerAttached=!1,this.updateTranslation=()=>{if(!this._canvas)return;const t=this._canvas.getBoundingClientRect(),i=this._canvas.width,n=this._canvas.height,s=t.width/i*this._renderer.resolution,o=t.height/n*this._renderer.resolution,r=t.left,l=t.top,d=`translate(${r}px, ${l}px) scale(${s}, ${o})`;d!==this._lastTransform&&(this._domElement.style.transform=d,this._lastTransform=d)},this._domElement=e.domElement,this._renderer=e.renderer,!(globalThis.OffscreenCanvas&&this._renderer.canvas instanceof OffscreenCanvas)&&(this._canvas=this._renderer.canvas,this._attachObserver())}get canvas(){return this._canvas}ensureAttached(){!this._domElement.parentNode&&this._canvas.parentNode&&(this._canvas.parentNode.appendChild(this._domElement),this.updateTranslation())}_attachObserver(){"ResizeObserver"in globalThis?(this._observer&&(this._observer.disconnect(),this._observer=null),this._observer=new ResizeObserver(e=>{for(const t of e){if(t.target!==this._canvas)continue;const i=this.canvas.width,n=this.canvas.height,s=t.contentRect.width/i*this._renderer.resolution,o=t.contentRect.height/n*this._renderer.resolution;(this._lastScaleX!==s||this._lastScaleY!==o)&&(this.updateTranslation(),this._lastScaleX=s,this._lastScaleY=o)}}),this._observer.observe(this._canvas)):this._tickerAttached||M.shared.add(this.updateTranslation,this,Z.HIGH)}destroy(){this._observer?(this._observer.disconnect(),this._observer=null):this._tickerAttached&&M.shared.remove(this.updateTranslation),this._domElement=null,this._renderer=null,this._canvas=null,this._tickerAttached=!1,this._lastTransform="",this._lastScaleX=null,this._lastScaleY=null}}class w{constructor(e){this.bubbles=!0,this.cancelBubble=!0,this.cancelable=!1,this.composed=!1,this.defaultPrevented=!1,this.eventPhase=w.prototype.NONE,this.propagationStopped=!1,this.propagationImmediatelyStopped=!1,this.layer=new f,this.page=new f,this.NONE=0,this.CAPTURING_PHASE=1,this.AT_TARGET=2,this.BUBBLING_PHASE=3,this.manager=e}get layerX(){return this.layer.x}get layerY(){return this.layer.y}get pageX(){return this.page.x}get pageY(){return this.page.y}get data(){return this}composedPath(){return this.manager&&(!this.path||this.path[this.path.length-1]!==this.target)&&(this.path=this.target?this.manager.propagationPath(this.target):[]),this.path}initEvent(e,t,i){throw new Error("initEvent() is a legacy DOM API. It is not implemented in the Federated Events API.")}initUIEvent(e,t,i,n,s){throw new Error("initUIEvent() is a legacy DOM API. It is not implemented in the Federated Events API.")}preventDefault(){this.nativeEvent instanceof Event&&this.nativeEvent.cancelable&&this.nativeEvent.preventDefault(),this.defaultPrevented=!0}stopImmediatePropagation(){this.propagationImmediatelyStopped=!0}stopPropagation(){this.propagationStopped=!0}}var I=/iPhone/i,B=/iPod/i,C=/iPad/i,U=/\biOS-universal(?:.+)Mac\b/i,k=/\bAndroid(?:.+)Mobile\b/i,R=/Android/i,b=/(?:SD4930UR|\bSilk(?:.+)Mobile\b)/i,O=/Silk/i,v=/Windows Phone/i,X=/\bWindows(?:.+)ARM\b/i,K=/BlackBerry/i,Y=/BB10/i,H=/Opera Mini/i,F=/\b(CriOS|Chrome)(?:.+)Mobile/i,N=/Mobile(?:.+)Firefox\b/i,$=function(a){return typeof a<"u"&&a.platform==="MacIntel"&&typeof a.maxTouchPoints=="number"&&a.maxTouchPoints>1&&typeof MSStream>"u"};function ne(a){return function(e){return e.test(a)}}function j(a){var e={userAgent:"",platform:"",maxTouchPoints:0};!a&&typeof navigator<"u"?e={userAgent:navigator.userAgent,platform:navigator.platform,maxTouchPoints:navigator.maxTouchPoints||0}:typeof a=="string"?e.userAgent=a:a&&a.userAgent&&(e={userAgent:a.userAgent,platform:a.platform,maxTouchPoints:a.maxTouchPoints||0});var t=e.userAgent,i=t.split("[FBAN");typeof i[1]<"u"&&(t=i[0]),i=t.split("Twitter"),typeof i[1]<"u"&&(t=i[0]);var n=ne(t),s={apple:{phone:n(I)&&!n(v),ipod:n(B),tablet:!n(I)&&(n(C)||$(e))&&!n(v),universal:n(U),device:(n(I)||n(B)||n(C)||n(U)||$(e))&&!n(v)},amazon:{phone:n(b),tablet:!n(b)&&n(O),device:n(b)||n(O)},android:{phone:!n(v)&&n(b)||!n(v)&&n(k),tablet:!n(v)&&!n(b)&&!n(k)&&(n(O)||n(R)),device:!n(v)&&(n(b)||n(O)||n(k)||n(R))||n(/\bokhttp\b/i)},windows:{phone:n(v),tablet:n(X),device:n(v)||n(X)},other:{blackberry:n(K),blackberry10:n(Y),opera:n(H),firefox:n(N),chrome:n(F),device:n(K)||n(Y)||n(H)||n(N)||n(F)},any:!1,phone:!1,tablet:!1};return s.any=s.apple.device||s.android.device||s.windows.device||s.other.device,s.phone=s.apple.phone||s.android.phone||s.windows.phone,s.tablet=s.apple.tablet||s.android.tablet||s.windows.tablet,s}const se=j.default??j,oe=se(globalThis.navigator),re=9,G=100,ae=0,le=0,W=2,z=1,he=-1e3,ce=-1e3,de=2,L=class J{constructor(e,t=oe){this._mobileInfo=t,this.debug=!1,this._activateOnTab=!0,this._deactivateOnMouseMove=!0,this._isActive=!1,this._isMobileAccessibility=!1,this._div=null,this._pools={},this._renderId=0,this._children=[],this._androidUpdateCount=0,this._androidUpdateFrequency=500,this._isRunningTests=!1,this._boundOnKeyDown=this._onKeyDown.bind(this),this._boundOnMouseMove=this._onMouseMove.bind(this),this._hookDiv=null,(t.tablet||t.phone)&&this._createTouchHook(),this._renderer=e}get isActive(){return this._isActive}get isMobileAccessibility(){return this._isMobileAccessibility}get hookDiv(){return this._hookDiv}get div(){return this._div}_createTouchHook(){const e=document.createElement("button");e.style.width=`${z}px`,e.style.height=`${z}px`,e.style.position="absolute",e.style.top=`${he}px`,e.style.left=`${ce}px`,e.style.zIndex=de.toString(),e.style.backgroundColor="#FF0000",e.title="select to enable accessibility for this content",e.addEventListener("focus",()=>{this._isMobileAccessibility=!0,this._activate(),this._destroyTouchHook()}),document.body.appendChild(e),this._hookDiv=e}_destroyTouchHook(){this._hookDiv&&(document.body.removeChild(this._hookDiv),this._hookDiv=null)}_activate(){if(this._isActive)return;this._isActive=!0,this._div||(this._div=document.createElement("div"),this._div.style.position="absolute",this._div.style.top=`${ae}px`,this._div.style.left=`${le}px`,this._div.style.pointerEvents="none",this._div.style.zIndex=W.toString(),this._canvasObserver=new q({domElement:this._div,renderer:this._renderer})),this._activateOnTab&&globalThis.addEventListener("keydown",this._boundOnKeyDown,!1),this._deactivateOnMouseMove&&globalThis.document.addEventListener("mousemove",this._boundOnMouseMove,!0);const e=this._renderer.view.canvas;if(e.parentNode)this._canvasObserver.ensureAttached(),this._initAccessibilitySetup();else{const t=new MutationObserver(()=>{e.parentNode&&(t.disconnect(),this._canvasObserver.ensureAttached(),this._initAccessibilitySetup())});t.observe(document.body,{childList:!0,subtree:!0})}}_initAccessibilitySetup(){this._renderer.runners.postrender.add(this),this._renderer.lastObjectRendered&&this._updateAccessibleObjects(this._renderer.lastObjectRendered)}_deactivate(){if(!(!this._isActive||this._isMobileAccessibility)){this._isActive=!1,globalThis.document.removeEventListener("mousemove",this._boundOnMouseMove,!0),this._activateOnTab&&globalThis.addEventListener("keydown",this._boundOnKeyDown,!1),this._renderer.runners.postrender.remove(this);for(const e of this._children)e._accessibleDiv?.parentNode&&(e._accessibleDiv.parentNode.removeChild(e._accessibleDiv),e._accessibleDiv=null),e._accessibleActive=!1;for(const e in this._pools)this._pools[e].forEach(i=>{i.parentNode&&i.parentNode.removeChild(i)}),delete this._pools[e];this._div?.parentNode&&this._div.parentNode.removeChild(this._div),this._pools={},this._children=[]}}_updateAccessibleObjects(e){if(!e.visible||!e.accessibleChildren)return;e.accessible&&(e._accessibleActive||this._addChild(e),e._renderId=this._renderId);const t=e.children;if(t)for(let i=0;i<t.length;i++)this._updateAccessibleObjects(t[i])}init(e){const i={accessibilityOptions:{...J.defaultOptions,...e?.accessibilityOptions||{}}};this.debug=i.accessibilityOptions.debug,this._activateOnTab=i.accessibilityOptions.activateOnTab,this._deactivateOnMouseMove=i.accessibilityOptions.deactivateOnMouseMove,i.accessibilityOptions.enabledByDefault&&this._activate(),this._renderer.runners.postrender.remove(this)}postrender(){const e=performance.now();if(this._mobileInfo.android.device&&e<this._androidUpdateCount||(this._androidUpdateCount=e+this._androidUpdateFrequency,(!this._renderer.renderingToScreen||!this._renderer.view.canvas)&&!this._isRunningTests))return;const t=new Set;if(this._renderer.lastObjectRendered){this._updateAccessibleObjects(this._renderer.lastObjectRendered);for(const i of this._children)i._renderId===this._renderId&&t.add(this._children.indexOf(i))}for(let i=this._children.length-1;i>=0;i--){const n=this._children[i];t.has(i)||(n._accessibleDiv&&n._accessibleDiv.parentNode&&(n._accessibleDiv.parentNode.removeChild(n._accessibleDiv),this._getPool(n.accessibleType).push(n._accessibleDiv),n._accessibleDiv=null),n._accessibleActive=!1,te(this._children,i,1))}this._renderer.renderingToScreen&&this._canvasObserver.ensureAttached();for(let i=0;i<this._children.length;i++){const n=this._children[i];if(!n._accessibleActive||!n._accessibleDiv)continue;const s=n._accessibleDiv,o=n.hitArea||n.getBounds().rectangle;if(n.hitArea){const r=n.worldTransform;s.style.left=`${r.tx+o.x*r.a}px`,s.style.top=`${r.ty+o.y*r.d}px`,s.style.width=`${o.width*r.a}px`,s.style.height=`${o.height*r.d}px`}else this._capHitArea(o),s.style.left=`${o.x}px`,s.style.top=`${o.y}px`,s.style.width=`${o.width}px`,s.style.height=`${o.height}px`}this._renderId++}_updateDebugHTML(e){e.innerHTML=`type: ${e.type}</br> title : ${e.title}</br> tabIndex: ${e.tabIndex}`}_capHitArea(e){e.x<0&&(e.width+=e.x,e.x=0),e.y<0&&(e.height+=e.y,e.y=0);const{width:t,height:i}=this._renderer;e.x+e.width>t&&(e.width=t-e.x),e.y+e.height>i&&(e.height=i-e.y)}_addChild(e){let i=this._getPool(e.accessibleType).pop();i?(i.innerHTML="",i.removeAttribute("title"),i.removeAttribute("aria-label"),i.tabIndex=0):(e.accessibleType==="button"?i=document.createElement("button"):(i=document.createElement(e.accessibleType),i.style.cssText=`
|
|
1
|
+
import{t as M,U as Z,P as f,v as te,j as y,E as ie,w as g,r as P,x as V}from"./RelationshipGalaxyCanvas-BnkcrIpk.js";import"./webworkerAll-BRnv6GvJ.js";import"./index-DkWTvE7d.js";import"./vendor-snapdom--nZvo8Sg.js";import"./index-BUz_Vl9U.js";import"./Tabs-B6Nzq2NQ.js";import"./RovingFocusItem-j33Nsbbn.js";import"./useToast-CxhJkhXK.js";import"./LoadingState.vue_vue_type_script_setup_true_lang-CwDIA0UP.js";import"./people-page-header-DNPjaSt4.js";import"./relationship-galaxy-connections-Cg4G5yYE.js";import"./relationship-galaxy-viewport-Cwfa51ER.js";import"./Filter-BEtPORqF.js";class q{constructor(e){this._lastTransform="",this._observer=null,this._tickerAttached=!1,this.updateTranslation=()=>{if(!this._canvas)return;const t=this._canvas.getBoundingClientRect(),i=this._canvas.width,n=this._canvas.height,s=t.width/i*this._renderer.resolution,o=t.height/n*this._renderer.resolution,r=t.left,l=t.top,d=`translate(${r}px, ${l}px) scale(${s}, ${o})`;d!==this._lastTransform&&(this._domElement.style.transform=d,this._lastTransform=d)},this._domElement=e.domElement,this._renderer=e.renderer,!(globalThis.OffscreenCanvas&&this._renderer.canvas instanceof OffscreenCanvas)&&(this._canvas=this._renderer.canvas,this._attachObserver())}get canvas(){return this._canvas}ensureAttached(){!this._domElement.parentNode&&this._canvas.parentNode&&(this._canvas.parentNode.appendChild(this._domElement),this.updateTranslation())}_attachObserver(){"ResizeObserver"in globalThis?(this._observer&&(this._observer.disconnect(),this._observer=null),this._observer=new ResizeObserver(e=>{for(const t of e){if(t.target!==this._canvas)continue;const i=this.canvas.width,n=this.canvas.height,s=t.contentRect.width/i*this._renderer.resolution,o=t.contentRect.height/n*this._renderer.resolution;(this._lastScaleX!==s||this._lastScaleY!==o)&&(this.updateTranslation(),this._lastScaleX=s,this._lastScaleY=o)}}),this._observer.observe(this._canvas)):this._tickerAttached||M.shared.add(this.updateTranslation,this,Z.HIGH)}destroy(){this._observer?(this._observer.disconnect(),this._observer=null):this._tickerAttached&&M.shared.remove(this.updateTranslation),this._domElement=null,this._renderer=null,this._canvas=null,this._tickerAttached=!1,this._lastTransform="",this._lastScaleX=null,this._lastScaleY=null}}class w{constructor(e){this.bubbles=!0,this.cancelBubble=!0,this.cancelable=!1,this.composed=!1,this.defaultPrevented=!1,this.eventPhase=w.prototype.NONE,this.propagationStopped=!1,this.propagationImmediatelyStopped=!1,this.layer=new f,this.page=new f,this.NONE=0,this.CAPTURING_PHASE=1,this.AT_TARGET=2,this.BUBBLING_PHASE=3,this.manager=e}get layerX(){return this.layer.x}get layerY(){return this.layer.y}get pageX(){return this.page.x}get pageY(){return this.page.y}get data(){return this}composedPath(){return this.manager&&(!this.path||this.path[this.path.length-1]!==this.target)&&(this.path=this.target?this.manager.propagationPath(this.target):[]),this.path}initEvent(e,t,i){throw new Error("initEvent() is a legacy DOM API. It is not implemented in the Federated Events API.")}initUIEvent(e,t,i,n,s){throw new Error("initUIEvent() is a legacy DOM API. It is not implemented in the Federated Events API.")}preventDefault(){this.nativeEvent instanceof Event&&this.nativeEvent.cancelable&&this.nativeEvent.preventDefault(),this.defaultPrevented=!0}stopImmediatePropagation(){this.propagationImmediatelyStopped=!0}stopPropagation(){this.propagationStopped=!0}}var I=/iPhone/i,B=/iPod/i,C=/iPad/i,U=/\biOS-universal(?:.+)Mac\b/i,k=/\bAndroid(?:.+)Mobile\b/i,R=/Android/i,b=/(?:SD4930UR|\bSilk(?:.+)Mobile\b)/i,O=/Silk/i,v=/Windows Phone/i,X=/\bWindows(?:.+)ARM\b/i,K=/BlackBerry/i,Y=/BB10/i,H=/Opera Mini/i,F=/\b(CriOS|Chrome)(?:.+)Mobile/i,N=/Mobile(?:.+)Firefox\b/i,$=function(a){return typeof a<"u"&&a.platform==="MacIntel"&&typeof a.maxTouchPoints=="number"&&a.maxTouchPoints>1&&typeof MSStream>"u"};function ne(a){return function(e){return e.test(a)}}function j(a){var e={userAgent:"",platform:"",maxTouchPoints:0};!a&&typeof navigator<"u"?e={userAgent:navigator.userAgent,platform:navigator.platform,maxTouchPoints:navigator.maxTouchPoints||0}:typeof a=="string"?e.userAgent=a:a&&a.userAgent&&(e={userAgent:a.userAgent,platform:a.platform,maxTouchPoints:a.maxTouchPoints||0});var t=e.userAgent,i=t.split("[FBAN");typeof i[1]<"u"&&(t=i[0]),i=t.split("Twitter"),typeof i[1]<"u"&&(t=i[0]);var n=ne(t),s={apple:{phone:n(I)&&!n(v),ipod:n(B),tablet:!n(I)&&(n(C)||$(e))&&!n(v),universal:n(U),device:(n(I)||n(B)||n(C)||n(U)||$(e))&&!n(v)},amazon:{phone:n(b),tablet:!n(b)&&n(O),device:n(b)||n(O)},android:{phone:!n(v)&&n(b)||!n(v)&&n(k),tablet:!n(v)&&!n(b)&&!n(k)&&(n(O)||n(R)),device:!n(v)&&(n(b)||n(O)||n(k)||n(R))||n(/\bokhttp\b/i)},windows:{phone:n(v),tablet:n(X),device:n(v)||n(X)},other:{blackberry:n(K),blackberry10:n(Y),opera:n(H),firefox:n(N),chrome:n(F),device:n(K)||n(Y)||n(H)||n(N)||n(F)},any:!1,phone:!1,tablet:!1};return s.any=s.apple.device||s.android.device||s.windows.device||s.other.device,s.phone=s.apple.phone||s.android.phone||s.windows.phone,s.tablet=s.apple.tablet||s.android.tablet||s.windows.tablet,s}const se=j.default??j,oe=se(globalThis.navigator),re=9,G=100,ae=0,le=0,W=2,z=1,he=-1e3,ce=-1e3,de=2,L=class J{constructor(e,t=oe){this._mobileInfo=t,this.debug=!1,this._activateOnTab=!0,this._deactivateOnMouseMove=!0,this._isActive=!1,this._isMobileAccessibility=!1,this._div=null,this._pools={},this._renderId=0,this._children=[],this._androidUpdateCount=0,this._androidUpdateFrequency=500,this._isRunningTests=!1,this._boundOnKeyDown=this._onKeyDown.bind(this),this._boundOnMouseMove=this._onMouseMove.bind(this),this._hookDiv=null,(t.tablet||t.phone)&&this._createTouchHook(),this._renderer=e}get isActive(){return this._isActive}get isMobileAccessibility(){return this._isMobileAccessibility}get hookDiv(){return this._hookDiv}get div(){return this._div}_createTouchHook(){const e=document.createElement("button");e.style.width=`${z}px`,e.style.height=`${z}px`,e.style.position="absolute",e.style.top=`${he}px`,e.style.left=`${ce}px`,e.style.zIndex=de.toString(),e.style.backgroundColor="#FF0000",e.title="select to enable accessibility for this content",e.addEventListener("focus",()=>{this._isMobileAccessibility=!0,this._activate(),this._destroyTouchHook()}),document.body.appendChild(e),this._hookDiv=e}_destroyTouchHook(){this._hookDiv&&(document.body.removeChild(this._hookDiv),this._hookDiv=null)}_activate(){if(this._isActive)return;this._isActive=!0,this._div||(this._div=document.createElement("div"),this._div.style.position="absolute",this._div.style.top=`${ae}px`,this._div.style.left=`${le}px`,this._div.style.pointerEvents="none",this._div.style.zIndex=W.toString(),this._canvasObserver=new q({domElement:this._div,renderer:this._renderer})),this._activateOnTab&&globalThis.addEventListener("keydown",this._boundOnKeyDown,!1),this._deactivateOnMouseMove&&globalThis.document.addEventListener("mousemove",this._boundOnMouseMove,!0);const e=this._renderer.view.canvas;if(e.parentNode)this._canvasObserver.ensureAttached(),this._initAccessibilitySetup();else{const t=new MutationObserver(()=>{e.parentNode&&(t.disconnect(),this._canvasObserver.ensureAttached(),this._initAccessibilitySetup())});t.observe(document.body,{childList:!0,subtree:!0})}}_initAccessibilitySetup(){this._renderer.runners.postrender.add(this),this._renderer.lastObjectRendered&&this._updateAccessibleObjects(this._renderer.lastObjectRendered)}_deactivate(){if(!(!this._isActive||this._isMobileAccessibility)){this._isActive=!1,globalThis.document.removeEventListener("mousemove",this._boundOnMouseMove,!0),this._activateOnTab&&globalThis.addEventListener("keydown",this._boundOnKeyDown,!1),this._renderer.runners.postrender.remove(this);for(const e of this._children)e._accessibleDiv?.parentNode&&(e._accessibleDiv.parentNode.removeChild(e._accessibleDiv),e._accessibleDiv=null),e._accessibleActive=!1;for(const e in this._pools)this._pools[e].forEach(i=>{i.parentNode&&i.parentNode.removeChild(i)}),delete this._pools[e];this._div?.parentNode&&this._div.parentNode.removeChild(this._div),this._pools={},this._children=[]}}_updateAccessibleObjects(e){if(!e.visible||!e.accessibleChildren)return;e.accessible&&(e._accessibleActive||this._addChild(e),e._renderId=this._renderId);const t=e.children;if(t)for(let i=0;i<t.length;i++)this._updateAccessibleObjects(t[i])}init(e){const i={accessibilityOptions:{...J.defaultOptions,...e?.accessibilityOptions||{}}};this.debug=i.accessibilityOptions.debug,this._activateOnTab=i.accessibilityOptions.activateOnTab,this._deactivateOnMouseMove=i.accessibilityOptions.deactivateOnMouseMove,i.accessibilityOptions.enabledByDefault&&this._activate(),this._renderer.runners.postrender.remove(this)}postrender(){const e=performance.now();if(this._mobileInfo.android.device&&e<this._androidUpdateCount||(this._androidUpdateCount=e+this._androidUpdateFrequency,(!this._renderer.renderingToScreen||!this._renderer.view.canvas)&&!this._isRunningTests))return;const t=new Set;if(this._renderer.lastObjectRendered){this._updateAccessibleObjects(this._renderer.lastObjectRendered);for(const i of this._children)i._renderId===this._renderId&&t.add(this._children.indexOf(i))}for(let i=this._children.length-1;i>=0;i--){const n=this._children[i];t.has(i)||(n._accessibleDiv&&n._accessibleDiv.parentNode&&(n._accessibleDiv.parentNode.removeChild(n._accessibleDiv),this._getPool(n.accessibleType).push(n._accessibleDiv),n._accessibleDiv=null),n._accessibleActive=!1,te(this._children,i,1))}this._renderer.renderingToScreen&&this._canvasObserver.ensureAttached();for(let i=0;i<this._children.length;i++){const n=this._children[i];if(!n._accessibleActive||!n._accessibleDiv)continue;const s=n._accessibleDiv,o=n.hitArea||n.getBounds().rectangle;if(n.hitArea){const r=n.worldTransform;s.style.left=`${r.tx+o.x*r.a}px`,s.style.top=`${r.ty+o.y*r.d}px`,s.style.width=`${o.width*r.a}px`,s.style.height=`${o.height*r.d}px`}else this._capHitArea(o),s.style.left=`${o.x}px`,s.style.top=`${o.y}px`,s.style.width=`${o.width}px`,s.style.height=`${o.height}px`}this._renderId++}_updateDebugHTML(e){e.innerHTML=`type: ${e.type}</br> title : ${e.title}</br> tabIndex: ${e.tabIndex}`}_capHitArea(e){e.x<0&&(e.width+=e.x,e.x=0),e.y<0&&(e.height+=e.y,e.y=0);const{width:t,height:i}=this._renderer;e.x+e.width>t&&(e.width=t-e.x),e.y+e.height>i&&(e.height=i-e.y)}_addChild(e){let i=this._getPool(e.accessibleType).pop();i?(i.innerHTML="",i.removeAttribute("title"),i.removeAttribute("aria-label"),i.tabIndex=0):(e.accessibleType==="button"?i=document.createElement("button"):(i=document.createElement(e.accessibleType),i.style.cssText=`
|
|
2
2
|
color: transparent;
|
|
3
3
|
pointer-events: none;
|
|
4
4
|
padding: 0;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{T as a,V as n}from"./index-
|
|
1
|
+
import{T as a,V as n}from"./index-DkWTvE7d.js";import"./vendor-snapdom--nZvo8Sg.js";class p{async getVersion(){return"0.36.0"}async fetchRemoteConfig(e){try{const t=await fetch(e);return t.ok?{success:!0,data:(t.headers.get("content-type")||"").includes("application/json")||e.split("?")[0].endsWith(".json")?await t.json():await t.text()}:{success:!1,error:`HTTP ${t.status}`}}catch(t){return{success:!1,error:String(t)}}}setThemeSource(e){}async getOpenAtLogin(){return!1}async setOpenAtLogin(e){return{success:!1,error:"Not available in CLI Web"}}async getDesktopCloseBehavior(){return"background"}async setDesktopCloseBehavior(e){return{success:!1,error:"Not available in CLI Web"}}async getAnalyticsEnabled(){try{return(await(await a("/_web/telemetry/enabled")).json()).enabled===!0}catch{return!1}}async setAnalyticsEnabled(e){try{return await(await a("/_web/telemetry/enabled",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({enabled:e})})).json()}catch{return{success:!1}}}async trackDailyActive(e){await a("/_web/telemetry/track",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({eventName:"app_active",properties:{app_locale:e}})}).catch(()=>{})}async trackAnalyticsEvent(e,t){await a("/_web/telemetry/track",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({eventName:e,properties:t})}).catch(()=>{})}async showOpenDialog(e){return{canceled:!0,filePaths:[]}}async copyImageToClipboard(e){if(globalThis.isSecureContext===!1)return{success:!1,error:"Image clipboard requires HTTPS or localhost"};if(typeof navigator>"u"||typeof navigator.clipboard?.write!="function"||typeof ClipboardItem>"u")return{success:!1,error:"Image clipboard is not supported by this browser"};try{const t=fetch(e).then(async r=>{if(!r.ok)throw new Error(`Failed to read screenshot data: HTTP ${r.status}`);const s=await r.blob();if(s.type!=="image/png")throw new Error(`Unsupported screenshot MIME type: ${s.type||"unknown"}`);return s});return await navigator.clipboard.write([new ClipboardItem({"image/png":t})]),{success:!0}}catch(t){const r=t instanceof Error?`${t.name}: ${t.message}`:String(t);return n(`Image clipboard write failed: ${r}`,t instanceof Error?t.stack:void 0),{success:!1,error:r}}}async checkUpdate(){try{return await(await a("/_web/system/check-update")).json()}catch(e){return{hasUpdate:!1,currentVersion:"unknown",error:e instanceof Error?e.message:String(e)}}}async performUpdate(){return{success:!1,error:"Web update is unavailable. Run clb update in your terminal."}}async relaunch(){window.location.reload()}}export{p as CliWebPlatformAdapter};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{k as s}from"./index-
|
|
1
|
+
import{k as s}from"./index-DkWTvE7d.js";function u(r){const t=new Date(r*1e3),n=t.getFullYear(),a=String(t.getMonth()+1).padStart(2,"0"),e=String(t.getDate()).padStart(2,"0");return`${n}-${a}-${e}`}function f(r){const t=new Date(r*1e3),n=t.getFullYear(),a=String(t.getMonth()+1).padStart(2,"0"),e=String(t.getDate()).padStart(2,"0"),o=String(t.getHours()).padStart(2,"0"),i=String(t.getMinutes()).padStart(2,"0");return`${n}-${a}-${e} ${o}:${i}`}function m(r){return s.unix(r).format("YYYY-MM-DD HH:mm:ss")}function g(r,t){const n=u(r);if(t===null)return`${n} ~ 至今`;const a=u(t);return n===a?n:`${n} ~ ${a}`}function d(r,t,n="YYYY/MM/DD",a=" - "){const e=s.unix(r).format(n),o=s.unix(t).format(n);return e===o?e:`${e}${a}${o}`}export{u as a,m as b,g as c,f as d,d as f};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{K as t,N as e}from"./index-
|
|
1
|
+
import{K as t,N as e}from"./index-DkWTvE7d.js";import"./vendor-snapdom--nZvo8Sg.js";class o{async getInfo(){return t("/cache/info")}async clear(a){return e("/cache/clear",{cacheId:a})}async getDataDir(){return t("/cache/data-dir")}async setDataDir(a,r=!0){return e("/cache/data-dir",{path:a,migrate:r})}async openDataDirCleanup(a){return e("/cache/data-dir/cleanup/open",{cleanupId:a})}async dismissDataDirCleanupNotice(a){return e("/cache/data-dir/cleanup/dismiss",{cleanupId:a})}async deleteDataDirCleanup(a){return e("/cache/data-dir/cleanup/delete",{cleanupId:a})}async getLatestImportLog(){return t("/cache/latest-import-log")}async saveToDownloads(a,r){return e("/cache/save-to-downloads",{filename:a,dataUrl:r})}async openDir(a){return e("/cache/open-dir",{cacheId:a})}async showInFolder(a){return e("/cache/show-in-folder",{filePath:a})}}export{o as FetchCacheAdapter};
|
|
@@ -1,6 +1,9 @@
|
|
|
1
|
-
import{T as r,U as
|
|
1
|
+
import{T as r,U as m}from"./index-DkWTvE7d.js";import"./vendor-snapdom--nZvo8Sg.js";function u(){return m("data")}const c=`(SELECT mc.message_id FROM message_context mc
|
|
2
2
|
JOIN message first_msg ON first_msg.id = mc.message_id
|
|
3
|
-
WHERE mc.segment_id = segment.id ORDER BY first_msg.ts ASC, first_msg.id ASC LIMIT 1) as firstMessageId`;class
|
|
4
|
-
|
|
5
|
-
FROM segment
|
|
6
|
-
|
|
3
|
+
WHERE mc.segment_id = segment.id ORDER BY first_msg.ts ASC, first_msg.id ASC LIMIT 1) as firstMessageId`;class l{async generate(s,t=1800){const e=await r(`/_web/sessions/${s}/generate-index`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({gapThreshold:t})});if(!e.ok)throw new Error(`Failed to generate session index: ${e.status}`);return(await e.json()).sessionCount}async generateIncremental(s,t=1800){const e=await r(`/_web/sessions/${s}/generate-incremental-index`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({gapThreshold:t})});if(!e.ok)throw new Error(`Failed to generate incremental session index: ${e.status}`);return(await e.json()).sessionCount}async hasIndex(s){return(await this.getStats(s)).hasIndex}async getStats(s){try{const e=(await u().pluginQuery(s,"SELECT COUNT(*) as cnt FROM segment",[]))[0]?.cnt??0;return{hasIndex:e>0,sessionCount:e,gapThreshold:1800}}catch{return{hasIndex:!1,sessionCount:0,gapThreshold:1800}}}async getAllIndexStats(){const s=await r("/_web/sessions/index-stats");return s.ok?await s.json():[]}async clear(s){return await r(`/_web/sessions/${s}/clear-index`,{method:"POST"}),!0}async updateGapThreshold(s,t){return!0}async getSessions(s){return u().pluginQuery(s,`SELECT id, start_ts as startTs, end_ts as endTs, message_count as messageCount, summary,
|
|
4
|
+
summary_message_count as summaryMessageCount, ${c}
|
|
5
|
+
FROM segment ORDER BY start_ts ASC`,[])}async getByTimeRange(s,t,e){return u().pluginQuery(s,`SELECT id, start_ts as startTs, end_ts as endTs, message_count as messageCount, summary,
|
|
6
|
+
summary_message_count as summaryMessageCount, ${c}
|
|
7
|
+
FROM segment WHERE start_ts >= ? AND end_ts <= ? ORDER BY start_ts ASC`,[t,e])}async getRecent(s,t){return u().pluginQuery(s,`SELECT id, start_ts as startTs, end_ts as endTs, message_count as messageCount, summary,
|
|
8
|
+
summary_message_count as summaryMessageCount, ${c}
|
|
9
|
+
FROM segment ORDER BY start_ts DESC LIMIT ?`,[t])}async generateSummary(s,t,e,n,o){try{const a=await r(`/_web/sessions/${s}/summaries/generate`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({segmentId:t,locale:e,forceRegenerate:n,strategy:o})}),i=await a.json();return a.ok?i:{success:!1,error:i.error||`HTTP ${a.status}`}}catch(a){return{success:!1,error:a instanceof Error?a.message:String(a)}}}async generateSummaries(s,t,e){let n=0,o=0;const a=0;for(const i of t)try{(await this.generateSummary(s,i,e)).success?n++:o++}catch{o++}return{success:n,failed:o,skipped:a}}async checkCanGenerateSummary(s,t){try{const e=await r(`/_web/sessions/${s}/summaries/check-can-generate`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({segmentIds:t})});return e.ok?await e.json():{}}catch{return{}}}}export{l as FetchSessionIndexAdapter};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{T as c}from"./index-DkWTvE7d.js";import"./vendor-snapdom--nZvo8Sg.js";class p{preflight(e,n){return s(`/_web/sessions/${encodeURIComponent(e)}/topics/preflight`,{method:"POST",body:JSON.stringify(n)})}start(e,n){return s(`/_web/sessions/${encodeURIComponent(e)}/topics/runs`,{method:"POST",body:JSON.stringify(n)})}generateDay(e,n,o,t){return s(`/_web/sessions/${encodeURIComponent(e)}/topics/days/${encodeURIComponent(n)}/generate`,{method:"POST",body:JSON.stringify({timezone:o,locale:t})})}getLatestRun(e){return s(`/_web/sessions/${encodeURIComponent(e)}/topics/runs/latest`)}getRun(e,n){return s(`/_web/sessions/${encodeURIComponent(e)}/topics/runs/${encodeURIComponent(n)}`)}pause(e,n){return this.runAction(e,n,"pause")}resume(e,n){return this.runAction(e,n,"resume")}cancel(e,n){return this.runAction(e,n,"cancel")}getDay(e,n,o){return s(`/_web/sessions/${encodeURIComponent(e)}/topics/days/${encodeURIComponent(n)}?timezone=${encodeURIComponent(o)}`)}async deleteDay(e,n){return(await s(`/_web/sessions/${encodeURIComponent(e)}/topics/days/${encodeURIComponent(n)}`,{method:"DELETE"})).success}runAction(e,n,o){return s(`/_web/sessions/${encodeURIComponent(e)}/topics/runs/${encodeURIComponent(n)}/${o}`,{method:"POST"})}}async function s(r,e={}){const n=new Headers(e.headers);e.body!==void 0&&n.set("Content-Type","application/json");const o=await c(r,{...e,headers:n});if(!o.ok){const t=await o.json().catch(()=>null);throw new Error(t?.error||t?.message||`HTTP ${o.status}`)}return o.json()}export{p as FetchChatTopicsAdapter};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{K as s,O as l,N as o,L as i}from"./index-
|
|
1
|
+
import{K as s,O as l,N as o,L as i}from"./index-DkWTvE7d.js";import"./vendor-snapdom--nZvo8Sg.js";class g{async hasConfig(){return s("/ai/llm/has-config")}async getConfigStore(){return s("/ai/llm/configs")}async getAllConfigs(){return(await this.getConfigStore()).configs}async getDefaultAssistantSlot(){return s("/ai/llm/default-assistant-slot")}async getFastModelSlot(){return s("/ai/llm/fast-model-slot")}async setDefaultAssistantModel(e,t){return l("/ai/llm/default-assistant-slot",{configId:e,modelId:t})}async setFastModel(e){return l("/ai/llm/fast-model-slot",e)}async getProviders(){return s("/ai/llm/providers")}async getProviderRegistry(){return s("/ai/llm/provider-registry")}async getModelCatalog(){return s("/ai/llm/model-catalog")}async addConfig(e){return o("/ai/llm/configs",e)}async updateConfig(e,t){return l(`/ai/llm/configs/${e}`,t)}async deleteConfig(e){return i(`/ai/llm/configs/${e}`)}async validateApiKey(e,t,a,r,n,m){return o("/ai/llm/validate-key",{provider:e,apiKey:t,baseUrl:a,model:r,apiFormat:n,configId:m})}async fetchRemoteModels(e,t,a,r,n){return o("/ai/llm/remote-models",{provider:e,apiKey:t,baseUrl:a,apiFormat:r,configId:n})}async addCustomProvider(e){return o("/ai/llm/custom-providers",e)}async updateCustomProvider(e,t){return l(`/ai/llm/custom-providers/${e}`,t)}async deleteCustomProvider(e){return i(`/ai/llm/custom-providers/${e}`)}async addCustomModel(e){return o("/ai/llm/custom-models",e)}async updateCustomModel(e,t,a){return l(`/ai/llm/custom-models/${e}/${encodeURIComponent(t)}`,a)}async deleteCustomModel(e,t){return i(`/ai/llm/custom-models/${e}/${encodeURIComponent(t)}`)}}export{g as FetchLLMAdapter};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{K as i,N as r,O as s,L as l}from"./index-
|
|
1
|
+
import{K as i,N as r,O as s,L as l}from"./index-DkWTvE7d.js";import"./vendor-snapdom--nZvo8Sg.js";class c{async getAll(){return i("/ai/skills")}async getConfig(t){try{return await i(`/ai/skills/${t}`)}catch{return null}}async create(t){return r("/ai/skills",{rawMd:t})}async update(t,a){return s(`/ai/skills/${t}`,{rawMd:a})}async delete(t){return l(`/ai/skills/${t}`)}async importFromMd(t){return r("/ai/skills/import",{rawMd:t})}async importBuiltin(t){return r("/ai/skills/import-builtin",{builtinId:t})}async reimport(t){return r(`/ai/skills/${t}/reimport`,{})}async getBuiltinCatalog(){try{return await i("/ai/skills/builtin-catalog")}catch{return[]}}}export{c as FetchSkillAdapter};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{K as r,M as n}from"./index-
|
|
1
|
+
import{K as r,M as n}from"./index-DkWTvE7d.js";import"./vendor-snapdom--nZvo8Sg.js";class a{getPresentationPreferences(){return r("/preferences/bootstrap")}getPreferences(){return r("/preferences")}savePreferences(e){return n("/preferences",e)}getUiConfig(){return r("/preferences/ui-config")}saveUiConfig(e){return n("/preferences/ui-config",e)}async getLocale(){return(await r("/preferences/locale")).lang}saveLocale(e){return n("/preferences/locale",{lang:e})}}export{a as FetchPreferencesAdapter};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{K as c,L as o,M as l,N as m,O as $,Q as a,S as y}from"./index-DkWTvE7d.js";import"./vendor-snapdom--nZvo8Sg.js";function S(i,e){e&&(e.startTs&&i.set("startTs",String(e.startTs)),e.endTs&&i.set("endTs",String(e.endTs)),e.memberId&&i.set("memberId",String(e.memberId)))}function n(i){const e=new URLSearchParams;S(e,i);const s=e.toString();return s?`?${s}`:""}function u(i){const e=new URLSearchParams;i?.mode&&e.set("mode",i.mode),i?.year&&e.set("year",String(i.year)),i?.days&&e.set("days",String(i.days)),i?.acceptStale&&e.set("acceptStale","1");const s=e.toString();return s?`?${s}`:""}class h{getSessions(){return c("/sessions")}getSession(e){return c(`/sessions/${e}`)}async deleteSession(e){return(await o(`/sessions/${e}`)).success}async renameSession(e,s){return(await l(`/sessions/${e}/name`,{name:s})).success}async updateSessionOwnerId(e,s){return(await l(`/sessions/${e}/owner`,{ownerId:s})).success}tryApplyOwnerProfile(e){return m(`/sessions/${e}/owner/apply-profile`,{})}setOwnerAndApplyProfile(e,s){return m(`/sessions/${e}/owner/select`,{ownerPlatformId:s})}async excludeOwnerSession(e){return(await m(`/sessions/${e}/owner/exclude`,{})).success}getContacts(e){const s=new URLSearchParams;e?.acceptStale&&s.set("acceptStale","1"),e?.timeRangePreset&&s.set("timeRange",e.timeRangePreset),e?.pool&&s.set("pool",e.pool),e?.page&&s.set("page",String(e.page)),e?.pageSize&&s.set("pageSize",String(e.pageSize)),e?.query&&s.set("q",e.query);const t=s.toString();return c(`/contacts${t?`?${t}`:""}`)}getContactDetail(e,s){const t=new URLSearchParams;s?.acceptStale&&t.set("acceptStale","1"),s?.timeRangePreset&&t.set("timeRange",s.timeRangePreset);const r=t.toString();return c(`/contacts/${encodeURIComponent(e)}/detail${r?`?${r}`:""}`)}recomputeContacts(e){const s=new URLSearchParams;e?.timeRangePreset&&s.set("timeRange",e.timeRangePreset),e?.pool&&s.set("pool",e.pool),e?.page&&s.set("page",String(e.page)),e?.pageSize&&s.set("pageSize",String(e.pageSize)),e?.query&&s.set("q",e.query);const t=s.toString();return m(`/contacts/recompute${t?`?${t}`:""}`,{})}async markContactAsFriend(e,s){const t=new URLSearchParams;s?.timeRangePreset&&t.set("timeRange",s.timeRangePreset);const r=t.toString();return(await $(`/contacts/${encodeURIComponent(e)}/mark-friend${r?`?${r}`:""}`)).success}async unmarkContactAsFriend(e,s){const t=new URLSearchParams;s?.timeRangePreset&&t.set("timeRange",s.timeRangePreset);const r=t.toString();return(await o(`/contacts/${encodeURIComponent(e)}/mark-friend${r?`?${r}`:""}`)).success}getPeopleRelationships(e){const s=new URLSearchParams;e?.acceptStale&&s.set("acceptStale","1"),e?.timeRangePreset&&s.set("timeRange",e.timeRangePreset),e?.graphScope&&s.set("scope",e.graphScope),e?.query&&s.set("q",e.query);const t=s.toString();return c(`/people/relationships${t?`?${t}`:""}`)}recomputePeopleRelationships(e){const s=new URLSearchParams;e?.timeRangePreset&&s.set("timeRange",e.timeRangePreset),e?.graphScope&&s.set("scope",e.graphScope),e?.query&&s.set("q",e.query);const t=s.toString();return m(`/people/relationships/recompute${t?`?${t}`:""}`,{})}getPeopleRelationshipNeighborhood(e,s){const t=new URLSearchParams;s?.acceptStale&&t.set("acceptStale","1"),s?.timeRangePreset&&t.set("timeRange",s.timeRangePreset),s?.graphScope&&t.set("scope",s.graphScope);const r=t.toString();return c(`/people/relationships/${encodeURIComponent(e)}/neighborhood${r?`?${r}`:""}`)}getAnnualSummary(e){return c(`/global-insight/annual-summary${u(e)}`)}recomputeAnnualSummary(e){return m(`/global-insight/annual-summary/recompute${u(e)}`,{})}getTimeInvestment(e){return c(`/global-insight/time-investment${u(e)}`)}recomputeTimeInvestment(e){return m(`/global-insight/time-investment/recompute${u(e)}`,{})}getAvailableYears(e){return c(`/sessions/${e}/years`)}getTimeRange(e){return c(`/sessions/${e}/time-range`)}getMemberActivity(e,s){return a(`/sessions/${e}/stats/member-activity${n(s)}`)}getHourlyActivity(e,s){return a(`/sessions/${e}/stats/hourly${n(s)}`)}getDailyActivity(e,s){return a(`/sessions/${e}/stats/daily${n(s)}`)}getWeekdayActivity(e,s){return a(`/sessions/${e}/stats/weekday${n(s)}`)}getMonthlyActivity(e,s){return a(`/sessions/${e}/analytics/monthly-activity${n(s)}`)}getYearlyActivity(e,s){return a(`/sessions/${e}/analytics/yearly-activity${n(s)}`)}getMessageLengthDistribution(e,s){return a(`/sessions/${e}/analytics/message-length-distribution${n(s)}`)}getMessageTypeDistribution(e,s){return a(`/sessions/${e}/stats/message-types${n(s)}`)}getTextStats(e,s){return a(`/sessions/${e}/analytics/text-stats${n(s)}`)}getLongMessageCount(e,s,t){const r=new URLSearchParams;s?.startTs&&r.set("startTs",String(s.startTs)),s?.endTs&&r.set("endTs",String(s.endTs)),s?.memberId&&r.set("memberId",String(s.memberId)),t!=null&&r.set("minLength",String(t));const g=r.toString();return a(`/sessions/${e}/analytics/long-message-count${g?`?${g}`:""}`)}getMemberMonthlyTrend(e,s){return a(`/sessions/${e}/analytics/member-monthly-trend${n(s)}`)}getTextLengthPercentiles(e,s){return a(`/sessions/${e}/analytics/text-length-percentiles${n(s)}`)}getWordFrequency(e,s){return y("/nlp/word-frequency",{sessionId:e,...s})}getDragonKingAnalysis(e,s){return a(`/sessions/${e}/analytics/dragon-king${n(s)}`)}getDivingAnalysis(e,s){return a(`/sessions/${e}/analytics/diving${n(s)}`)}getCheckInAnalysis(e,s){return a(`/sessions/${e}/analytics/check-in${n(s)}`)}getMemeBattleAnalysis(e,s){return a(`/sessions/${e}/analytics/meme-battle${n(s)}`)}getNightOwlAnalysis(e,s){return a(`/sessions/${e}/analytics/night-owl${n(s)}`)}getRepeatAnalysis(e,s){return a(`/sessions/${e}/analytics/repeat${n(s)}`)}getMembers(e){return c(`/sessions/${e}/members`)}getMembersPaginated(e,s){const t=new URLSearchParams({page:String(s.page),pageSize:String(s.pageSize)});return s.search&&t.set("search",s.search),s.sortOrder&&t.set("sortOrder",s.sortOrder),c(`/sessions/${e}/members/paginated?${t}`)}getMemberNameHistory(e,s){return c(`/sessions/${e}/members/${s}/history`)}async updateMemberAliases(e,s,t){return(await l(`/sessions/${e}/members/${s}/aliases`,{aliases:t})).success}async mergeMembers(e,s,t){return(await m(`/sessions/${e}/members/merge`,{memberId1:s,memberId2:t})).success}async deleteMember(e,s){return(await o(`/sessions/${e}/members/${s}`)).success}async deleteMembers(e,s){return(await m(`/sessions/${e}/members/batch-delete`,{memberIds:s})).success}getCatchphraseAnalysis(e,s){return a(`/sessions/${e}/analytics/catchphrase${n(s)}`)}getLanguagePreferenceAnalysis(e,s,t,r){const g=new URLSearchParams;return g.set("locale",s),t?.startTs&&g.set("startTs",String(t.startTs)),t?.endTs&&g.set("endTs",String(t.endTs)),t?.memberId&&g.set("memberId",String(t.memberId)),a(`/sessions/${e}/analytics/language-preference?${g}`)}getMentionAnalysis(e,s){return a(`/sessions/${e}/analytics/mention${n(s)}`)}getGroupRelationshipGalaxy(e,s){return a(`/sessions/${e}/analytics/relationship-galaxy${n(s)}`)}getClusterGraph(e,s,t){const r=new URLSearchParams;s?.startTs&&r.set("startTs",String(s.startTs)),s?.endTs&&r.set("endTs",String(s.endTs)),s?.memberId&&r.set("memberId",String(s.memberId)),t?.topEdges&&r.set("topEdges",String(t.topEdges)),t?.lookAhead&&r.set("lookAhead",String(t.lookAhead)),t?.decaySeconds&&r.set("decaySeconds",String(t.decaySeconds));const g=r.toString();return a(`/sessions/${e}/analytics/cluster${g?`?${g}`:""}`)}getLaughAnalysis(e,s,t){return y(`/sessions/${e}/analytics/laugh${n(s)}`,{keywords:t??[]})}getRelationshipStats(e,s,t){return a(`/sessions/${e}/analytics/relationship${n(s)}`)}getJourneyStats(e,s){return a(`/sessions/${e}/analytics/journey${n(s)}`)}executeSQL(e,s){return m(`/sessions/${e}/sql`,{sql:s})}getSchema(e){return c(`/sessions/${e}/schema`)}pluginQuery(e,s,t){return m(`/sessions/${e}/query`,{sql:s,params:t??[]})}}export{h as FetchDataAdapter};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{K as a,N as s,O as n,L as i}from"./index-
|
|
1
|
+
import{K as a,N as s,O as n,L as i}from"./index-DkWTvE7d.js";import"./vendor-snapdom--nZvo8Sg.js";class c{async getAll(){return a("/ai/assistants")}async getConfig(t){try{return await a(`/ai/assistants/${t}`)}catch{return null}}async create(t){return s("/ai/assistants",t)}async update(t,r){return n(`/ai/assistants/${t}`,r)}async delete(t){return i(`/ai/assistants/${t}`)}async reset(t){return s(`/ai/assistants/${t}/reset`,{})}async getUpgradeInfo(t){return a(`/ai/assistants/${t}/upgrade-status`)}async upgradeWithBackup(t,r){return s(`/ai/assistants/${t}/upgrade`,{backupName:r})}async importFromMd(t){return s("/ai/assistants/import",{rawMd:t})}async getBuiltinCatalog(){return[]}async importBuiltin(t){return s("/ai/assistants/import-builtin",{builtinId:t})}async reimport(t){return s(`/ai/assistants/${t}/reimport`,{})}async getBuiltinToolCatalog(){return a("/ai/tools/catalog")}}export{c as FetchAssistantAdapter};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{K as r,N as a,O as u,L as l,T as h}from"./index-
|
|
1
|
+
import{K as r,N as a,O as u,L as l,T as h}from"./index-DkWTvE7d.js";import"./vendor-snapdom--nZvo8Sg.js";const g="This feature is not available in web mode";class ${async getAIChat(e){try{return await r(`/ai/chats/${e}`)}catch{return null}}async getAIChats(e){return r(`/ai/chats?sessionId=${encodeURIComponent(e)}`)}async createAIChat(e,t,s){return a("/ai/chats",{sessionId:e,title:t,assistantId:s})}async updateAIChatTitle(e,t){return u(`/ai/chats/${e}/title`,{title:t})}async deleteAIChat(e){return l(`/ai/chats/${e}`)}async getMessages(e){return r(`/ai/chats/${e}/messages`)}async addMessage(e,t,s,c,n,o,i){return a(`/ai/chats/${e}/messages`,{role:t,content:s,dataKeywords:c,dataMessageCount:n,contentBlocks:o,tokenUsage:i})}async deleteMessagesFrom(e,t){return a(`/ai/chats/${e}/messages/${t}/delete-from`,{})}async forkAIChat(e,t,s){return a(`/ai/chats/${e}/fork`,{upToMessageId:t,title:s})}async updateMessageContent(e,t){await u(`/ai/messages/${e}/content`,{content:t})}async deleteAndRelinkMessage(e,t){await a(`/ai/chats/${e}/messages/${t}/delete-relink`,{})}async insertMessageAfter(e,t,s,c,n,o){return a(`/ai/chats/${e}/messages/insert-after`,{afterMessageId:t,role:s,content:c,contentBlocks:n,tokenUsage:o})}async getAIChatTokenUsage(e){return r(`/ai/chats/${e}/token-usage`)}async estimateContextTokens(e){try{return await r(`/ai/chats/${e}/estimate-tokens`)}catch(t){return{success:!1,tokens:0,error:t instanceof Error?t.message:String(t)}}}async exportFilterResultToFile(e){try{const t=await h(`/_web/sessions/${e.sessionId}/export`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({sessionName:e.sessionName,format:e.format||"txt",timeFilter:e.timeFilter})});if(!t.ok)return{success:!1,error:(await t.json().catch(()=>null))?.error||`HTTP ${t.status}`};const s=await t.blob(),c=t.headers.get("Content-Disposition")?.match(/filename="?(.+?)"?$/)?.[1]||`${e.sessionName}_export.txt`,n=URL.createObjectURL(s),o=document.createElement("a");return o.href=n,o.download=decodeURIComponent(c),o.click(),URL.revokeObjectURL(n),{success:!0}}catch(t){return{success:!1,error:t instanceof Error?t.message:String(t)}}}onExportProgress(e){return()=>{}}async executeAiSQL(e){return a("/ai/debug/execute-sql",{sql:e})}async getAiSchema(){return r("/ai/debug/schema")}async clearDebugContext(){return a("/ai/debug/clear-debug-context",{})}async getToolCatalog(){try{return await r("/ai/tools/full-catalog")}catch{return r("/ai/tools/catalog")}}async executeTool(e,t,s,c){try{return await a("/ai/tools/execute",{testId:e,toolName:t,params:s,sessionId:c})}catch(n){return{success:!1,error:String(n)}}}async cancelToolTest(e){try{return await a("/ai/tools/cancel",{testId:e})}catch{return{success:!1}}}async getDefaultDesensitizeRules(e){try{return await r(`/ai/desensitize-rules/defaults?locale=${encodeURIComponent(e)}`)}catch{return[]}}async mergeDesensitizeRules(e,t,s={}){try{return await a("/ai/desensitize-rules/merge",{existingRules:e,locale:t,overrides:s})}catch{return e}}async showAiLogFile(){try{return await a("/ai/logs/show")}catch(e){return{success:!1,error:e instanceof Error?e.message:g}}}}export{$ as FetchAIAdapter};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{U as O}from"./index-
|
|
1
|
+
import{U as O}from"./index-DkWTvE7d.js";import"./vendor-snapdom--nZvo8Sg.js";const N=`
|
|
2
2
|
msg.id,
|
|
3
3
|
m.id as senderId,
|
|
4
4
|
COALESCE(m.group_nickname, m.account_name, m.platform_id) as senderName,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{T as d,
|
|
1
|
+
import{T as d,al as l,K as I}from"./index-DkWTvE7d.js";import"./vendor-snapdom--nZvo8Sg.js";function g(i){return{success:i.success,sessionId:i.sessionId,platform:i.platform,error:i.error,importMode:i.importMode,matchedBy:i.matchedBy,createReason:i.createReason,newMessageCount:i.newMessageCount,duplicateCount:i.duplicateCount,messageCount:i.messageCount,memberCount:i.memberCount,diagnostics:i.diagnostics}}async function S(i,e,t){const o=i.body?.getReader();if(!o)return e;const s=new TextDecoder;let r="",a=e;for(;;){const{done:n,value:y}=await o.read();if(n)break;r+=s.decode(y,{stream:!0});const w=r.split(`
|
|
2
2
|
`);r=w.pop()||"";let p="";for(const u of w)if(u.startsWith("event: "))p=u.slice(7).trim();else if(u.startsWith("data: ")){const f=JSON.parse(u.slice(6));p==="progress"?t?.(f):(p==="done"||p==="error")&&(a=f),p=""}}return a}class B{constructor(){this.activeBatch=null}async requestBatchCancellation(e){try{await d(`${l()}/import/batch/${encodeURIComponent(e)}/cancel`,{method:"POST"})}catch{}}async importFile(e,t,o){if(typeof e=="string")return{success:!1,error:"File path import is not supported in Web mode"};const s=new FormData;s.append("file",e),t?.formatId&&s.append("formatId",t.formatId),t?.chatIndex!==void 0&&s.append("chatIndex",String(t.chatIndex)),t?.sessionGapThreshold!==void 0&&s.append("sessionGapThreshold",String(t.sessionGapThreshold));const r=await d(`${l()}/import`,{method:"POST",body:s});if(!r.ok){const a=await r.text();return{success:!1,error:`HTTP ${r.status}: ${a}`}}return g(await S(r,{success:!1,error:"Unknown error"},o))}async importBatch(e,t,o){if(e.some(n=>typeof n.file=="string"))return e.map(n=>({id:n.id,status:"failed",error:"File path import is not supported in Web mode"}));const s=new FormData;for(const n of e)s.append("files",n.file);t?.sessionGapThreshold!==void 0&&s.append("sessionGapThreshold",String(t.sessionGapThreshold));const r={id:crypto.randomUUID(),cancelRequested:!1};this.activeBatch=r;const a=Array(e.length);try{const n=await d(`${l()}/import/batch`,{method:"POST",body:s,headers:{"X-ChatLab-Import-Batch-Id":r.id}});if(r.cancelRequested&&await this.requestBatchCancellation(r.id),!n.ok||!n.body){const m=await n.text();return e.map(T=>({id:T.id,status:"failed",error:`HTTP ${n.status}: ${m}`}))}const y=n.body.getReader(),w=new TextDecoder;let p="",u=null,f=null,c="";for(;;){const{done:m,value:T}=await y.read();if(m)break;p+=w.decode(T,{stream:!0});const v=p.split(`
|
|
3
3
|
`);p=v.pop()||"";for(const b of v){if(b.startsWith("event: ")){c=b.slice(7).trim();continue}if(!b.startsWith("data: "))continue;const h=JSON.parse(b.slice(6));if(c==="batch-start")o?.({index:h.index,event:"start"});else if(c==="batch-progress")o?.({index:h.index,event:"progress",progress:h.progress});else if(c==="batch-complete"){const $=x(e,h.index,h.result);a[h.index]=$,o?.({index:h.index,event:"complete",result:$})}else c==="done"?u=h.map(($,C)=>x(e,C,$)):c==="error"&&(f=typeof h?.error=="string"?h.error:"Batch import failed");c=""}}return u??e.map((m,T)=>a[T]??{id:m.id,status:"failed",error:f??"Batch response ended without results"})}catch(n){return e.map((y,w)=>a[w]??{id:y.id,status:"failed",error:n instanceof Error?n.message:String(n)})}finally{this.activeBatch===r&&(this.activeBatch=null)}}cancelActiveImport(){this.activeBatch&&(this.activeBatch.cancelRequested=!0,this.requestBatchCancellation(this.activeBatch.id))}async detectFormat(e){if(typeof e=="string")return null;const t=new FormData;t.append("file",e);const o=await d(`${l()}/detect-format`,{method:"POST",body:t});return o.ok?(await o.json()).format:null}async scanMultiChatFile(e){if(typeof e=="string")return[];const t=new FormData;t.append("file",e);const o=await d(`${l()}/scan-multi-chat`,{method:"POST",body:t});return o.ok?(await o.json()).chats:[]}async prepareImportSource(e){if(typeof e=="string")return{success:!1,error:"File path import is not supported in Web mode"};const t=new FormData;t.append("file",e);const o=await d(`${l()}/import-sources`,{method:"POST",body:t}),s=await o.json().catch(()=>null);return o.ok?s??{success:!1,error:"Invalid import source response"}:{success:!1,error:s?.error||`HTTP ${o.status}`}}async importPreparedChat(e,t,o,s){const r=await d(`${l()}/import-sources/${encodeURIComponent(e)}/import`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({chatId:t,sessionGapThreshold:s?.sessionGapThreshold})});if(!r.ok){const a=await r.text();return{success:!1,error:`HTTP ${r.status}: ${a}`}}return g(await S(r,{success:!1,error:"Unknown error"},o))}async releaseImportSource(e){await d(`${l()}/import-sources/${encodeURIComponent(e)}`,{method:"DELETE"})}getSupportedFormats(){return I("/supported-formats")}async importDemo(e,t,o){return new Promise(s=>{d(`${l()}/demo/import`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({locale:e,timeZone:Intl.DateTimeFormat().resolvedOptions().timeZone,sessionGapThreshold:o?.sessionGapThreshold})}).then(async r=>{if(!r.ok||!r.body){s({success:!1,error:`HTTP ${r.status}`});return}const a=r.body.getReader(),n=new TextDecoder;let y="";for(;;){const{done:w,value:p}=await a.read();if(w)break;y+=n.decode(p,{stream:!0});const u=y.split(`
|
|
4
4
|
`);y=u.pop()||"";let f="";for(const c of u)if(c.startsWith("event: "))f=c.slice(7).trim();else if(c.startsWith("data: ")){const m=JSON.parse(c.slice(6));if(f==="progress")(m.stage==="downloading"||m.stage==="importing")&&t?.({stage:m.stage});else if(f==="result"){s(m);return}f=""}}s({success:!1,error:"Stream ended without result"})}).catch(r=>s({success:!1,error:String(r)}))})}async analyzeIncrementalImport(e,t){if(typeof t=="string")return{newMessageCount:0,duplicateCount:0,totalInFile:0,error:"File path not supported in Web mode"};const o=new FormData;o.append("file",t);const s=await d(`${l()}/sessions/${e}/import/incremental/analyze`,{method:"POST",body:o});if(!s.ok){const r=await s.text();return{newMessageCount:0,duplicateCount:0,totalInFile:0,error:`HTTP ${s.status}: ${r}`}}return await s.json()}async incrementalImport(e,t,o){if(typeof t=="string")return{success:!1,newMessageCount:0,error:"File path not supported in Web mode"};const s=new FormData;s.append("file",t);const r=await d(`${l()}/sessions/${e}/import/incremental`,{method:"POST",body:s});if(!r.ok){const a=await r.text();return{success:!1,newMessageCount:0,error:`HTTP ${r.status}: ${a}`}}return S(r,{success:!1,newMessageCount:0,error:"Unknown error"},o)}async importDirectory(e,t,o){if(typeof e=="string")return{success:!1,error:"Directory path import is not supported in Web mode"};if(e.length===0)return{success:!1,error:"No files in directory"};const s=new FormData;for(const a of e)s.append("files",a),s.append("relativePaths",a.webkitRelativePath||a.name);t?.sessionGapThreshold!==void 0&&s.append("sessionGapThreshold",String(t.sessionGapThreshold));const r=await d(`${l()}/import-directory`,{method:"POST",body:s});if(!r.ok){const a=await r.text();return{success:!1,error:`HTTP ${r.status}: ${a}`}}return g(await S(r,{success:!1,error:"Unknown error"},o))}}function x(i,e,t){const o=i[e]?.id??String(e);return t?.status==="cancelled"?{id:o,status:"cancelled"}:t?.status==="success"?{id:o,status:"success",result:g(t.result)}:{id:o,status:"failed",error:t?.error??t?.result?.error??"error.import_failed",result:t?.result?g(t.result):void 0}}export{B as FetchImportAdapter};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
.tab-slide-enter-active[data-v-d1e67205],.tab-slide-leave-active[data-v-d1e67205]{transition:opacity .2s ease,transform .2s ease}.tab-slide-enter-from[data-v-d1e67205]{opacity:0;transform:translateY(10px)}.tab-slide-leave-to[data-v-d1e67205]{opacity:0;transform:translateY(-10px)}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
.fade-enter-active[data-v-616e92db],.fade-leave-active[data-v-616e92db]{transition:opacity .15s ease}.fade-enter-from[data-v-616e92db],.fade-leave-to[data-v-616e92db]{opacity:0}.tab-slide-enter-active[data-v-1e621d59],.tab-slide-leave-active[data-v-1e621d59]{transition:opacity .2s ease,transform .2s ease}.tab-slide-enter-from[data-v-1e621d59]{opacity:0;transform:translateY(10px)}.tab-slide-leave-to[data-v-1e621d59]{opacity:0;transform:translateY(-10px)}
|