sliccy 6.141.4 → 6.141.6
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/ui/.vite/manifest.json +155 -155
- package/dist/ui/assets/SKILL-fr8gk3vb.js +1 -0
- package/dist/ui/assets/SKILL-zHRhO4F3.js +1 -0
- package/dist/ui/assets/{account-store-CfKG-Ig3.js → account-store-Bf3BFMdU.js} +1 -1
- package/dist/ui/assets/{account-store-BSIs8eWH.js → account-store-DjTVFONV.js} +1 -1
- package/dist/ui/assets/{adobe-BrcV3j-w.js → adobe-DIWyL4A7.js} +1 -1
- package/dist/ui/assets/{adobe--jIvF0ng.js → adobe-DLA59eNB.js} +1 -1
- package/dist/ui/assets/{agent-bridge-DEABZego.js → agent-bridge-CssfMh4B.js} +1 -1
- package/dist/ui/assets/{agent-panels-_ItKLnAu.js → agent-panels-kstIzyXc.js} +1 -1
- package/dist/ui/assets/{apply-layout-B0AnPvJo.js → apply-layout-GFoXN3lO.js} +1 -1
- package/dist/ui/assets/{apps-3LBDpLXu.js → apps-CUkrobW4.js} +1 -1
- package/dist/ui/assets/{azure-openai-HqCDLaNq.js → azure-openai-BRlfoxEh.js} +1 -1
- package/dist/ui/assets/{azure-openai-Cye1lDSV.js → azure-openai-BoB2mssJ.js} +1 -1
- package/dist/ui/assets/{budget-usage-source--h4cY6Ul.js → budget-usage-source-BLGJMn9C.js} +1 -1
- package/dist/ui/assets/{cdp-BX0PiRAg.js → cdp-CY75LqPS.js} +1 -1
- package/dist/ui/assets/{cerebras-BzO5UDZf.js → cerebras-DEqMsx1F.js} +1 -1
- package/dist/ui/assets/{cerebras-BL4Mp561.js → cerebras-DIfBoyb8.js} +1 -1
- package/dist/ui/assets/{composer-speech-4JiTrymN.js → composer-speech-75eV9W5M.js} +1 -1
- package/dist/ui/assets/{connect-surface-COdJoI-e.js → connect-surface-p4YzBtc5.js} +1 -1
- package/dist/ui/assets/derive-CfRcH7sr.js +1 -0
- package/dist/ui/assets/{directed-approval-Blbo1tMy.js → directed-approval-CLTJGxjb.js} +1 -1
- package/dist/ui/assets/{fs-CxM_n_WI.js → fs-C_OwVw4w.js} +2 -2
- package/dist/ui/assets/{fs-luCL6DCO.js → fs-Dg-ls--O.js} +1 -1
- package/dist/ui/assets/{github-DYjXr1_m.js → github-BscVb1-A.js} +2 -2
- package/dist/ui/assets/{github-CkKjkah0.js → github-C1CG_JVQ.js} +1 -1
- package/dist/ui/assets/{github-copilot-BH7WyhE6.js → github-copilot-B_i0YdRi.js} +1 -1
- package/dist/ui/assets/{github-copilot-BgdxHbZb.js → github-copilot-o3pbr7ZS.js} +1 -1
- package/dist/ui/assets/{github-install-DCTLf8fO.js → github-install-CkEeDJy3.js} +1 -1
- package/dist/ui/assets/{github-zip-B98l3J_a.js → github-zip-lYd4OfXC.js} +1 -1
- package/dist/ui/assets/{hear-BjVVAhs0.js → hear-CDwOQX0U.js} +1 -1
- package/dist/ui/assets/{help-S6yh95LF.js → help-B2j3l3bf.js} +1 -1
- package/dist/ui/assets/{js-realm-worker-DPLcRbzk.js → js-realm-worker-CB7HojJ5.js} +1 -1
- package/dist/ui/assets/{kernel-worker-CFvPuOAi.js → kernel-worker-DwW3gDk8.js} +599 -599
- package/dist/ui/assets/{local-llm-DRegic15.js → local-llm-BI0SFe2W.js} +1 -1
- package/dist/ui/assets/{local-llm-BDyp_VE9.js → local-llm-DEZAmHSj.js} +1 -1
- package/dist/ui/assets/{main-DRyLg5pd.js → main-By36LP6F.js} +3 -3
- package/dist/ui/assets/{main-cherry-D1YCAckw.js → main-cherry-DZqLhJde.js} +1 -1
- package/dist/ui/assets/{mount-BehlIVTc.js → mount-CedgW8GD.js} +1 -1
- package/dist/ui/assets/{mount-hVHVLao0.js → mount-ItL2LLFI.js} +3 -3
- package/dist/ui/assets/{mount-recovery-Ds6xJnFc.js → mount-recovery-B6RW0S7-.js} +1 -1
- package/dist/ui/assets/{new-session-Cvy359ZG.js → new-session-BE9qA8YK.js} +2 -2
- package/dist/ui/assets/{oauth-bootstrap-0NJ1uts7.js → oauth-bootstrap-Ovk_e-xK.js} +2 -2
- package/dist/ui/assets/{onboarding-orchestrator-Q2fKoNJZ.js → onboarding-orchestrator-CjjW1nUs.js} +1 -1
- package/dist/ui/assets/{openai-codex-DqGAC_RJ.js → openai-codex-Co0nmG38.js} +1 -1
- package/dist/ui/assets/{openai-codex-K0Kx4ldr.js → openai-codex-Ctz1T4F0.js} +1 -1
- package/dist/ui/assets/{openrouter-BL1BgW8W.js → openrouter-DGA24YiM.js} +1 -1
- package/dist/ui/assets/{openrouter-free-CY-4NfFi.js → openrouter-free-DLGIIDJU.js} +1 -1
- package/dist/ui/assets/{openrouter-free-OvrtzVRw.js → openrouter-free-DYk22dlQ.js} +1 -1
- package/dist/ui/assets/{openrouter-x2bz26jc.js → openrouter-mazv6ply.js} +1 -1
- package/dist/ui/assets/{openrouter-oauth-CUoyHM94.js → openrouter-oauth-CQcHXBaZ.js} +1 -1
- package/dist/ui/assets/{openrouter-oauth-B7IMQSSe.js → openrouter-oauth-OiWTr12W.js} +1 -1
- package/dist/ui/assets/{panel-rpc-handlers-Bcgk807g.js → panel-rpc-handlers-pWopYFWu.js} +2 -2
- package/dist/ui/assets/{panelize-shell-BgTzzpy_.js → panelize-shell-BP7AProZ.js} +1 -1
- package/dist/ui/assets/{provider-DesDs-vM.js → provider-CDr-JHcv.js} +1 -1
- package/dist/ui/assets/{provider-665TUltd.js → provider-DrvyW7Yy.js} +2 -2
- package/dist/ui/assets/provider-settings-fvhg3uYm.js +1 -0
- package/dist/ui/assets/provider-store-access-Di19tbK5.js +1 -0
- package/dist/ui/assets/provider-store-access-oK6WcDx9.js +1 -0
- package/dist/ui/assets/{providers-DdkKCDPr.js → providers-CNGfzUux.js} +1 -1
- package/dist/ui/assets/{providers-CFCRFvFH.js → providers-D6gPpxXb.js} +2 -2
- package/dist/ui/assets/{quick-llm-DDPHThwA.js → quick-llm-Bv2hzD4O.js} +1 -1
- package/dist/ui/assets/{recovery-screen-BxSagH2C.js → recovery-screen-Dtganhe_.js} +1 -1
- package/dist/ui/assets/{run-DVF88haQ.js → run-BdWZ42FI.js} +1 -1
- package/dist/ui/assets/{run-DP2klSX1.js → run-C1vJEz5Y.js} +1 -1
- package/dist/ui/assets/{run-mty6BV1K.js → run-Cy4KoI0m.js} +2 -2
- package/dist/ui/assets/{setup-feature-flags-remote-BHnboyDd.js → setup-feature-flags-remote-Dlr6U1L5.js} +1 -1
- package/dist/ui/assets/sidecar-repair-BbLQg5__.js +1 -0
- package/dist/ui/assets/{silent-renew-backoff-CefoN4SB.js → silent-renew-backoff-BFhKZLg8.js} +1 -1
- package/dist/ui/assets/{skills-DQ9l8ZBo.js → skills-ZZBKZdQu.js} +1 -1
- package/dist/ui/assets/slicc-version-B--jU_SR.js +1 -0
- package/dist/ui/assets/{snapshot-x1OXJvjv.js → snapshot-DQqVYpRq.js} +1 -1
- package/dist/ui/assets/{snapshot-features-CsC80g1q.js → snapshot-features-DGdncE7d.js} +1 -1
- package/dist/ui/assets/{soundscape-lMcnjSro.js → soundscape-BUY8wROt.js} +1 -1
- package/dist/ui/assets/{speak-DAMy1Kok.js → speak-DBrRdt29.js} +1 -1
- package/dist/ui/assets/{sprinkle-manager-jUfWlPSr.js → sprinkle-manager-BI99gg-O.js} +1 -1
- package/dist/ui/assets/{sprinkle-renderer-DRjk0Axq.js → sprinkle-renderer-DCom0PPi.js} +6 -6
- package/dist/ui/assets/{state-DnkBl3YO.js → state-Dbl-8JsM.js} +1 -1
- package/dist/ui/assets/{store-CyOgmeoj.js → store-7xGSTCIh.js} +1 -1
- package/dist/ui/assets/{store-CvgWI8Er.js → store-CVYJPCZM.js} +1 -1
- package/dist/ui/assets/{sudo-BUdJPcIH.js → sudo-CQrKF9OU.js} +1 -1
- package/dist/ui/assets/{sync-dialog-D1W1SkvI.js → sync-dialog-CqyL53ig.js} +1 -1
- package/dist/ui/assets/{transformers-env-DnyPjSfP.js → transformers-env-DFwC6UcV.js} +1 -1
- package/dist/ui/assets/{tray-sidecar-Cq4YlygL.js → tray-sidecar-4Td9gord.js} +1 -1
- package/dist/ui/assets/{upgrade-detection-DgoklRjO.js → upgrade-detection-Bac7J4qZ.js} +1 -1
- package/dist/ui/assets/{voice-reply-oNIB61T4.js → voice-reply-C2DNaJoU.js} +1 -1
- package/dist/ui/assets/{wc-attach-Dm3guiHt.js → wc-attach-3JGxMRCh.js} +2 -2
- package/dist/ui/assets/{wc-extension-B-HQw_fj.js → wc-extension-DlICtefI.js} +2 -2
- package/dist/ui/assets/{wc-follower-UnBMtKdu.js → wc-follower-BIL8SS-F.js} +3 -3
- package/dist/ui/assets/{wc-follower-oauth-CUFehOmO.js → wc-follower-oauth-Dwu3a6LW.js} +1 -1
- package/dist/ui/assets/wc-live-ut8r0JYb.js +400 -0
- package/dist/ui/assets/{wc-nav-BCixgrNu.js → wc-nav-B0NvVKcE.js} +2 -2
- package/dist/ui/assets/{wc-onboarding-hbn2eX0f.js → wc-onboarding-C4CUWGHN.js} +2 -2
- package/dist/ui/assets/{wc-placeholder-VxPXRa-X.js → wc-placeholder-BINV9Wvi.js} +3 -3
- package/dist/ui/assets/{wc-settings-DjO1GovJ.js → wc-settings-5cWnsC1W.js} +3 -3
- package/dist/ui/assets/{wc-shell-CdkXzmml.js → wc-shell-CPMJP7Nw.js} +3 -3
- package/dist/ui/assets/{wc-shortcut-config-DRFDW5Tg.js → wc-shortcut-config-Vl2ofFcr.js} +1 -1
- package/dist/ui/assets/{wc-shortcuts-udkJj992.js → wc-shortcuts-Ctl8LyEF.js} +1 -1
- package/dist/ui/assets/{wc-sprinkles-CiVxUeGF.js → wc-sprinkles-BUncqtmN.js} +2 -2
- package/dist/ui/assets/{wc-transcript-export-BCh_MVB_.js → wc-transcript-export-DipIeSmz.js} +2 -2
- package/dist/ui/assets/{wc-tray-B33mq_SX.js → wc-tray-ByWeeHn8.js} +4 -4
- package/dist/ui/assets/welcome-detection-BvaqvIBk.js +1 -0
- package/dist/ui/assets/{whisper-session-BsYu0J3h.js → whisper-session-DbSwtMkL.js} +2 -2
- package/dist/ui/assets/{xai-grok-BULrVqKw.js → xai-grok-DdKzgHn7.js} +1 -1
- package/dist/ui/assets/{xai-grok-Cud8PiSx.js → xai-grok-geoFEOCs.js} +1 -1
- package/dist/ui/index.html +3 -3
- package/dist/ui/packages/webapp/index.html +3 -3
- package/package.json +1 -1
- package/dist/ui/assets/SKILL-DGS-d3qt.js +0 -1
- package/dist/ui/assets/SKILL-Dkk5iZlJ.js +0 -1
- package/dist/ui/assets/derive-TWFNEJkb.js +0 -1
- package/dist/ui/assets/provider-settings-D4bmGLB0.js +0 -1
- package/dist/ui/assets/provider-store-access-BYNLuUjQ.js +0 -1
- package/dist/ui/assets/provider-store-access-DTu0j6hV.js +0 -1
- package/dist/ui/assets/sidecar-repair-BTfXbONN.js +0 -1
- package/dist/ui/assets/slicc-version-Dao6QpwG.js +0 -1
- package/dist/ui/assets/wc-live-B6vu9NGR.js +0 -400
- package/dist/ui/assets/welcome-detection-DtOhe2WK.js +0 -1
|
@@ -1,400 +0,0 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/mount-picker-popup--ijSfN8u.js","assets/logger-DDBAeTLF.js","assets/picker-popup-sQtXmfAo.js","assets/runtime-env-Dlaokqg1.js","assets/usb-picker-Cbm0jfjl.js","assets/serial-picker-BQF_Eitc.js","assets/hid-picker-sFJ8vzUj.js","assets/usb-device-registry-DmUBqrA-.js","assets/rolldown-runtime-Dd_uD5pT.js","assets/serial-port-registry-CCqklAEr.js","assets/hid-device-registry-B2R-0rNt.js","assets/quick-llm-DDPHThwA.js","assets/account-store-CfKG-Ig3.js","assets/preload-helper-Czpn1I53.js","assets/claude-model-version-CSATLzrT.js","assets/models-BSkXF4T6.js","assets/diagnostics-DN_idNHx.js","assets/provider-env-CTOcDKrQ.js","assets/__vite-browser-external-5eBdwsFd.js","assets/openrouter.models-B-zmcypy.js","assets/libesm-BypnjKEL.js","assets/base64-DJRlyqZu.js","assets/proxied-fetch-CiijUcSt.js","assets/fetch-body-D2PwksUW.js","assets/api-endpoint-DGxXvrur.js","assets/float-topology-hfgMx1Yq.js","assets/secret-topology-Yt0aO4Gz.js","assets/secrets-bridge-client-BVl0YuB2.js","assets/port-bridge-client-C1tBBqwu.js","assets/tool-ui-eSQ1g2I1.js","assets/providers-CFCRFvFH.js","assets/panel-rpc-B3MSVImO.js","assets/bedrock-camp-compat-BeCSBUrZ.js","assets/llm-session-id-bZQs6gBN.js","assets/icons-BXcp4CBT.js","assets/main-DRyLg5pd.js","assets/modulepreload-polyfill-P2Xu9kJm.js","assets/bridge-protocol-06nbmp2X.js","assets/tray-runtime-config-BQL-GPqt.js","assets/messages-BD4p8GuF.js","assets/telemetry-BWAgv6Hm.js","assets/feature-flags-DaSRRz0w.js","assets/tray-follower-status-BAjnN7Ar.js","assets/clipboard-eqmn97SP.js","assets/tray-join-url-BIvzbiFR.js","assets/wc-placeholder-VxPXRa-X.js","assets/wc-shortcuts-udkJj992.js","assets/wc-attach-Dm3guiHt.js","assets/permissions-surface-registry-CilCRwhh.js","assets/new-session-Cvy359ZG.js","assets/tray-leader-DaLUK8LB.js","assets/mount-table-store-dY2IfQ5S.js","assets/legacy-styles-B3nS5QUo.js","assets/soundscape-lMcnjSro.js","assets/voice-reply-oNIB61T4.js","assets/speak-DAMy1Kok.js","assets/speech-assets-bridge-CFYafE89.js","assets/transformers-env-DnyPjSfP.js","assets/shared-f0tP2HLX.js","assets/mime-types-D0xZwlMO.js","assets/remote-vfs-client-DdFPlnwq.js","assets/types-Dgm4REV3.js","assets/writable-vfs-client-Czpbtd8Y.js","assets/wc-onboarding-hbn2eX0f.js","assets/record-DOq72weu.js","assets/wc-browser-DO1Pnegi.js","assets/slicc-app-url-B9OxaBDe.js","assets/tab-teleport-BimzPYfT.js","assets/teleport-storage-CyYkSZfJ.js","assets/remote-terminal-view-D0AXaUk6.js","assets/browser-DGwroBSO.js","assets/terminal-session-client-ADzaWGFd.js","assets/secret-env-CtpVPUh5.js","assets/wc-permissions-Ch85s0Vv.js","assets/wc-permissions-providers-CVe-8jSH.js","assets/theme-CXRqxpw6.js","assets/theme-engine-By4GU_Wc.js","assets/panelize-shell-BgTzzpy_.js","assets/virtual-device-paths-D45tpPP6.js","assets/layout-apply-registry-Cw730jao.js","assets/wc-shortcut-config-DRFDW5Tg.js","assets/remote-sprinkle-vfs-BY9A-xsx.js","assets/bounded-walk-BjxKWNqp.js","assets/path-utils-DNJG-zQf.js","assets/wc-sprinkles-CiVxUeGF.js","assets/wc-unit-context-Cl6J7YTp.js","assets/agent-panels-_ItKLnAu.js","assets/apply-layout-B0AnPvJo.js","assets/wc-tray-B33mq_SX.js","assets/transcript-export-DP-r8eDz.js","assets/wc-follower-oauth-CUFehOmO.js","assets/sprinkle-renderer-DRjk0Axq.js","assets/usb-operations-BsAiCAWF.js","assets/pending-request-table-k-D7ZZsL.js","assets/export-spool-CuNzzI8a.js","assets/src-BWaKqLvQ.js","assets/synthetic-cdp-transport-OUVdC4zy.js","assets/wc-shell-CdkXzmml.js","assets/wc-shell-WkeczD9x.css","assets/sprinkle-instances-B8n7h-oP.js","assets/wc-transcript-export-BCh_MVB_.js","assets/wc-nav-BCixgrNu.js","assets/composer-speech-4JiTrymN.js","assets/whisper-session-BsYu0J3h.js"])))=>i.map(i=>d[i]);
|
|
2
|
-
import{n as e}from"./rolldown-runtime-Dd_uD5pT.js";import{B as t,T as n,V as r,et as i,f as a,nt as o,tt as s,w as c}from"./account-store-CfKG-Ig3.js";import{t as l}from"./preload-helper-Czpn1I53.js";import{s as u}from"./claude-model-version-CSATLzrT.js";import{t as d}from"./logger-DDBAeTLF.js";import{B as f,V as p,W as m,Y as h,q as g,y as _}from"./wc-shortcuts-udkJj992.js";import{r as v,t as y}from"./base64-DJRlyqZu.js";import"./proxied-fetch-CiijUcSt.js";import{a as b,i as x,n as ee,o as S}from"./sprinkle-renderer-DRjk0Axq.js";import{n as te}from"./runtime-env-Dlaokqg1.js";import{t as C}from"./slugify-BYJ6QVAt.js";import{a as ne,i as re,n as w,t as ie}from"./transcript-export-DP-r8eDz.js";import{f as ae,h as oe,m as se,o as ce}from"./tray-runtime-config-BQL-GPqt.js";import{a as le,t as ue}from"./api-endpoint-DGxXvrur.js";import{n as de}from"./float-topology-hfgMx1Yq.js";import"./secret-topology-Yt0aO4Gz.js";import{n as fe}from"./secrets-bridge-client-BVl0YuB2.js";import{t as pe}from"./tool-ui-eSQ1g2I1.js";import{a as me,d as he,n as ge,r as _e}from"./telemetry-BWAgv6Hm.js";import{r as ve}from"./feature-flags-DaSRRz0w.js";import{a as ye,i as be,t as xe}from"./tray-follower-status-BAjnN7Ar.js";import{a as Se,o as Ce,r as we,s as Te}from"./main-DRyLg5pd.js";import{n as Ee}from"./src-BWaKqLvQ.js";import{n as De,r as Oe,t as ke}from"./provider-budget-LCzMPlKv.js";import{t as Ae}from"./permissions-surface-registry-CilCRwhh.js";import{t as T}from"./types-Dgm4REV3.js";import{n as je,r as Me}from"./hid-device-registry-B2R-0rNt.js";import"./browser-DGwroBSO.js";import{a as Ne,i as Pe}from"./serial-port-registry-CCqklAEr.js";import{A as Fe,C as Ie,D as Le,O as Re,S as ze,T as Be,_ as Ve,b as He,c as Ue,g as We,h as Ge,o as Ke,r as qe,s as Je,u as Ye,v as Xe,w as Ze}from"./usb-operations-BsAiCAWF.js";import{a as Qe,t as $e}from"./icons-BXcp4CBT.js";import{i as et,r as tt}from"./usb-device-registry-DmUBqrA-.js";import{a as nt,i as rt,r as it}from"./tray-leader-DaLUK8LB.js";import{a as at,c as ot,d as st,f as E,i as ct,l as lt,m as ut,n as dt,o as ft,p as pt,r as mt,s as ht,t as gt,u as D}from"./record-DOq72weu.js";import"./shared-f0tP2HLX.js";import{a as _t,n as vt,r as yt}from"./theme-CXRqxpw6.js";import{C as bt,S as xt,_ as St,a as Ct,b as wt,c as Tt,d as Et,f as Dt,g as Ot,h as kt,i as At,l as jt,m as Mt,n as Nt,o as Pt,p as Ft,r as It,t as Lt,u as Rt,v as zt,x as Bt,y as Vt}from"./wc-shell-CdkXzmml.js";import{a as Ht,c as Ut,f as Wt,i as Gt,l as Kt,m as qt,n as Jt,o as Yt,p as Xt,r as Zt,s as Qt,t as $t,u as en}from"./wc-unit-context-Cl6J7YTp.js";var tn=[{category:`jwt`,source:String.raw`ey[A-Za-z0-9_-]{4,}\.[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+`,flags:`g`},{category:`private-key`,source:`-----BEGIN [A-Z ]* PRIVATE KEY-----`+String.raw`[\s\S]*?`+`-----END [A-Z ]* PRIVATE KEY-----`,flags:`g`},{category:`bearer-token`,source:`Bearer [A-Za-z0-9._~+/=!-]+`,flags:`gi`},{category:`api-key`,source:`(?:sk-(?:live|test|prod|proj)-[A-Za-z0-9]{8,}|sk-ant-[A-Za-z0-9-]{8,}|xoxb-[A-Za-z0-9-]{10,}|xoxp-[A-Za-z0-9-]{10,}|AKIA[A-Z0-9]{16}|ghp_[A-Za-z0-9]{36}|hf_[A-Za-z0-9]{34})`,flags:`g`},{category:`password`,source:String.raw`\b(?:password|passwd|token|secret|api_key)\s*[=:]\s*\S+`,flags:`gi`}],nn=`⟦REDACTED:[^⟧]*⟧`;function rn(e,t){return e.start<t.end&&t.start<e.end}function an(e){let t=[];for(let n of e.matchAll(new RegExp(nn,`g`))){let e=n.index;e!==void 0&&t.push({start:e,end:e+n[0].length})}return t}function on(e,t,n=1){let r=an(e),i=[],a=n;for(let{category:n,source:o,flags:s}of tn)for(let c of e.matchAll(new RegExp(o,s))){let e=c.index;if(e===void 0)continue;let o={start:e,end:e+c[0].length};r.some(e=>rn(e,o))||i.some(e=>rn(e,o))||i.push({...o,id:`${t}${a++}`,category:n})}i.sort((e,t)=>e.start-t.start);let o=``,s=0;for(let{start:t,end:n,id:r,category:a}of i)o+=e.slice(s,t),o+=`⟦REDACTED:${a}:${r}⟧`,s=n;return o+=e.slice(s),{text:o,matches:i.map(({id:e,category:t})=>({id:e,category:t})),nextId:a}}var sn=`agent-sessions`,cn=1,O=`sessions`;function ln(){return new Promise((e,t)=>{let n=indexedDB.open(sn,cn);n.onupgradeneeded=()=>{let e=n.result;e.objectStoreNames.contains(O)||e.createObjectStore(O,{keyPath:`id`})},n.onsuccess=()=>e(n.result),n.onerror=()=>t(n.error)})}var un=class{dbPromise=null;getDB(){return this.dbPromise||=ln().then(e=>(e.onversionchange=()=>{e.close(),this.dbPromise=null},e.onclose=()=>{this.dbPromise=null},e)),this.dbPromise}async save(e){let t=await this.getDB();return new Promise((n,r)=>{let i=t.transaction(O,`readwrite`).objectStore(O).put(e);i.onsuccess=()=>n(),i.onerror=()=>r(i.error)})}async load(e){let t=await this.getDB();return new Promise((n,r)=>{let i=t.transaction(O,`readonly`).objectStore(O).get(e);i.onsuccess=()=>n(i.result??null),i.onerror=()=>r(i.error)})}async delete(e){let t=await this.getDB();return new Promise((n,r)=>{let i=t.transaction(O,`readwrite`).objectStore(O).delete(e);i.onsuccess=()=>n(),i.onerror=()=>r(i.error)})}async loadAll(){let e=await this.getDB();return new Promise((t,n)=>{let r=e.transaction(O,`readonly`).objectStore(O).getAll();r.onsuccess=()=>t(r.result??[]),r.onerror=()=>n(r.error)})}async list(){let e=await this.getDB();return new Promise((t,n)=>{let r=e.transaction(O,`readonly`).objectStore(O).getAll();r.onsuccess=()=>{t((r.result??[]).map(e=>({id:e.id,updatedAt:e.updatedAt})))},r.onerror=()=>n(r.error)})}async clearAll(){let e=await this.getDB();return new Promise((t,n)=>{let r=e.transaction(O,`readwrite`).objectStore(O).clear();r.onsuccess=()=>t(),r.onerror=()=>n(r.error)})}static newId(){return`session-${Date.now()}-${Math.random().toString(36).slice(2,8)}`}static createSession(e,t){let n=Date.now();return{id:e,messages:[],config:t,createdAt:n,updatedAt:n}}static updateMessages(e,t){return{...e,messages:t,updatedAt:Date.now()}}},dn=e({SessionStore:()=>hn}),fn=`browser-coding-agent`,pn=1,k=`sessions`;function mn(){return new Promise((e,t)=>{let n=indexedDB.open(fn,pn);n.onupgradeneeded=()=>{let e=n.result;e.objectStoreNames.contains(k)||e.createObjectStore(k,{keyPath:`id`})},n.onsuccess=()=>e(n.result),n.onerror=()=>t(n.error)})}var hn=class{db=null;async init(){await this.getDb()}async getDb(){if(!this.db){let e=await mn();e.onversionchange=()=>{e.close(),this.db=null},e.onclose=()=>{this.db=null},this.db=e}return this.db}async save(e){let t=await this.getDb();return new Promise((n,r)=>{let i=t.transaction(k,`readwrite`);i.objectStore(k).put(e),i.oncomplete=()=>n(),i.onerror=()=>r(i.error)})}async load(e){let t=await this.getDb();return new Promise((n,r)=>{let i=t.transaction(k,`readonly`).objectStore(k).get(e);i.onsuccess=()=>n(i.result??null),i.onerror=()=>r(i.error)})}async list(){let e=await this.getDb();return new Promise((t,n)=>{let r=e.transaction(k,`readonly`).objectStore(k).getAll();r.onsuccess=()=>{t(r.result.sort((e,t)=>t.updatedAt-e.updatedAt).map(e=>e.id))},r.onerror=()=>n(r.error)})}async delete(e){let t=await this.getDb();return new Promise((n,r)=>{let i=t.transaction(k,`readwrite`);i.objectStore(k).delete(e),i.oncomplete=()=>n(),i.onerror=()=>r(i.error)})}async saveMessages(e,t){let n=await this.load(e),r=n?{...n,messages:t,updatedAt:Date.now()}:{id:e,messages:t,createdAt:Date.now(),updatedAt:Date.now()};await this.save(r)}},gn=e({getTranscriptExportService:()=>vn,registerTranscriptExportService:()=>_n}),A=null;function _n(e){return A=e,()=>{A===e&&(A=null)}}function vn(){if(!A)throw new w(`session-not-found`);return A}var yn=e({broadcastToDips:()=>Ln,disposeDips:()=>ir,handleDipPickerAction:()=>ar,hydrateDips:()=>rr,mountDip:()=>F,setDipExecHandler:()=>zn}),bn=te();function xn(e){if(typeof e!=`object`||!e||Array.isArray(e))return[];let t=e.filters;return Array.isArray(t)?t:[]}async function Sn(e,t){if(t?.aborted)throw new DOMException(`aborted`,`AbortError`);let n=await Tn(e,!0,t);if(t?.aborted)throw new DOMException(`aborted`,`AbortError`);if(n===null)throw Error(`VFS read failed: ${e}`);return typeof n==`string`?n:new TextDecoder().decode(n)}var Cn=null;function wn(){if(Cn)return Cn;if(typeof BroadcastChannel>`u`)return null;try{Cn=new BroadcastChannel(`preview-vfs`)}catch{return null}return Cn}async function Tn(e,t,n){let r=wn();if(!r)return null;let i=`dip-${Date.now()}-${Math.random().toString(36).slice(2)}`;return new Promise(a=>{let o=!1,s=()=>{r.removeEventListener(`message`,c),n?.removeEventListener(`abort`,l)},c=e=>{if(!o&&e.data?.type===`preview-vfs-response`&&e.data.id===i){if(o=!0,s(),e.data.error){a(null);return}a(e.data.content??null)}},l=()=>{o||(o=!0,s(),a(null))};r.addEventListener(`message`,c),n?.addEventListener(`abort`,l),setTimeout(()=>{o||(o=!0,s(),a(null))},5e3),r.postMessage({type:`preview-vfs-read`,id:i,path:e,asText:t})})}var En=[`/shared/sprinkles/`,`/workspace/skills/sprinkles/`,`/workspace/sprinkles/`],Dn=[`/shared/`,`/workspace/skills/sprinkles/`,`/workspace/sprinkles/`];function On(e){return En.some(t=>e.startsWith(t))}function kn(e){return typeof e!=`string`||!e.startsWith(`/`)||e.includes(`..`)?!1:Dn.some(t=>e.startsWith(t))}var j=new WeakSet,An=`,
|
|
3
|
-
exec: Object.assign(function(cmd) {
|
|
4
|
-
return _vfsCall('dip-exec', { cmd: cmd }, function(m) { return m.result; });
|
|
5
|
-
}, { spawn: function(argv) {
|
|
6
|
-
return _vfsCall('dip-jsh', { op: 'spawn', args: [argv] }, function(m) { return m.result; });
|
|
7
|
-
} }),
|
|
8
|
-
agent: function(prompt, opts) {
|
|
9
|
-
return _vfsCall('dip-agent', { prompt: prompt, opts: opts || null },
|
|
10
|
-
function(m) { return m.result; });
|
|
11
|
-
}`,jn=`,
|
|
12
|
-
fetch: function(url, init) {
|
|
13
|
-
return _vfsCall('dip-jsh', { op: 'fetch', args: [url, init || null] }, function(m) { return m.result; });
|
|
14
|
-
},
|
|
15
|
-
http: { client: function(cfg) {
|
|
16
|
-
function mk(method) { return function(path, opts) { return _vfsCall('dip-jsh', { op: 'http', args: [cfg, method, path, opts || null] }, function(m) { return m.result; }); }; }
|
|
17
|
-
return { get: mk('get'), post: mk('post'), put: mk('put'), patch: mk('patch'), 'delete': mk('delete') };
|
|
18
|
-
} },
|
|
19
|
-
browser: {
|
|
20
|
-
findTab: function(q) { return _vfsCall('dip-jsh', { op: 'browser', args: ['findTab', q] }, function(m) { return m.result; }); },
|
|
21
|
-
ensureTab: function(url, options) { return _vfsCall('dip-jsh', { op: 'browser', args: ['ensureTab', url, options || {}] }, function(m) { return m.result; }); },
|
|
22
|
-
eval: function(tab, code) { return _vfsCall('dip-jsh', { op: 'browser', args: ['eval', tab, code] }, function(m) { return m.result; }); },
|
|
23
|
-
evalAsync: function(tab, code) { return _vfsCall('dip-jsh', { op: 'browser', args: ['evalAsync', tab, code] }, function(m) { return m.result; }); },
|
|
24
|
-
cookie: function(tab, name) { return _vfsCall('dip-jsh', { op: 'browser', args: ['cookie', tab, name] }, function(m) { return m.result; }); },
|
|
25
|
-
localStorage: function(tab, key) { return _vfsCall('dip-jsh', { op: 'browser', args: ['localStorage', tab, key] }, function(m) { return m.result; }); },
|
|
26
|
-
fetch: function(tab, url, opts) { return _vfsCall('dip-jsh', { op: 'browser', args: ['fetch', tab, url, opts || {}] }, function(m) { return m.result; }); }
|
|
27
|
-
},
|
|
28
|
-
fetchToFile: function(url, path) {
|
|
29
|
-
return _vfsCall('dip-jsh', { op: 'fetchToFile', args: [url, path] }, function(m) { return m.result; });
|
|
30
|
-
}`,Mn=`,
|
|
31
|
-
_device: function(channel, op, args) {
|
|
32
|
-
return _vfsCall('dip-device-op',
|
|
33
|
-
{ channel: channel, op: op, args: args || [] },
|
|
34
|
-
function(m) { return m.result; });
|
|
35
|
-
},
|
|
36
|
-
hid: {
|
|
37
|
-
list: function() { return _vfsCall('dip-device-op', { channel: 'hid', op: 'list', args: [] }, function(m) { return m.result; }); },
|
|
38
|
-
request: function(filters) { return _vfsCall('dip-device-op', { channel: 'hid', op: 'request', args: [filters || []] }, function(m) { return m.result; }); },
|
|
39
|
-
open: function(handle) { return _vfsCall('dip-device-op', { channel: 'hid', op: 'open', args: [handle] }, function(m) { return m.result; }).then(function() {}); },
|
|
40
|
-
close: function(handle) { return _vfsCall('dip-device-op', { channel: 'hid', op: 'close', args: [handle] }, function(m) { return m.result; }).then(function() {}); },
|
|
41
|
-
sendReport: function(handle, reportId, data) { return _vfsCall('dip-device-op', { channel: 'hid', op: 'sendReport', args: [handle, reportId, data] }, function(m) { return m.result; }).then(function() {}); },
|
|
42
|
-
on: function(event, cb) { if (event === 'inputreport') _hidInputReportListeners.add(cb); },
|
|
43
|
-
off: function(event, cb) { if (event === 'inputreport') _hidInputReportListeners.delete(cb); }
|
|
44
|
-
},
|
|
45
|
-
serial: {
|
|
46
|
-
list: function() { return _vfsCall('dip-device-op', { channel: 'serial', op: 'list', args: [] }, function(m) { return m.result; }); },
|
|
47
|
-
request: function(filters) { return _vfsCall('dip-device-op', { channel: 'serial', op: 'request', args: [filters || []] }, function(m) { return m.result; }); },
|
|
48
|
-
open: function(handle, options) { return _vfsCall('dip-device-op', { channel: 'serial', op: 'open', args: [handle, options] }, function(m) { return m.result; }).then(function() {}); },
|
|
49
|
-
close: function(handle) { return _vfsCall('dip-device-op', { channel: 'serial', op: 'close', args: [handle] }, function(m) { return m.result; }).then(function() {}); }
|
|
50
|
-
},
|
|
51
|
-
usb: {
|
|
52
|
-
list: function() { return _vfsCall('dip-device-op', { channel: 'usb', op: 'list', args: [] }, function(m) { return m.result; }); },
|
|
53
|
-
request: function(filters) { return _vfsCall('dip-device-op', { channel: 'usb', op: 'request', args: [filters || []] }, function(m) { return m.result; }); },
|
|
54
|
-
open: function(handle) { return _vfsCall('dip-device-op', { channel: 'usb', op: 'open', args: [handle] }, function(m) { return m.result; }).then(function() {}); },
|
|
55
|
-
close: function(handle) { return _vfsCall('dip-device-op', { channel: 'usb', op: 'close', args: [handle] }, function(m) { return m.result; }).then(function() {}); }
|
|
56
|
-
}`;function Nn(e){return`(function() {
|
|
57
|
-
var _cbId = 0;
|
|
58
|
-
var _callbacks = {};
|
|
59
|
-
var _hidInputReportListeners = new Set();
|
|
60
|
-
|
|
61
|
-
function _vfsCall(type, params, extractResult) {
|
|
62
|
-
return new Promise(function(resolve, reject) {
|
|
63
|
-
var id = ++_cbId;
|
|
64
|
-
_callbacks[id] = function(msg) {
|
|
65
|
-
if (msg.error) reject(new Error(msg.error));
|
|
66
|
-
else resolve(extractResult ? extractResult(msg) : undefined);
|
|
67
|
-
};
|
|
68
|
-
var m = { type: type, id: id };
|
|
69
|
-
if (params) { for (var k in params) m[k] = params[k]; }
|
|
70
|
-
parent.postMessage(m, '*');
|
|
71
|
-
});
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
window.slicc = window.bridge = {
|
|
75
|
-
lick: function(event) {
|
|
76
|
-
var action = typeof event === 'string' ? event : event.action;
|
|
77
|
-
var data = typeof event === 'string' ? undefined : ('data' in event ? event.data : event);
|
|
78
|
-
parent.postMessage({ type: 'dip-lick', action: action, data: data }, '*');
|
|
79
|
-
},
|
|
80
|
-
/* Read-only VFS access. Mirrors the sprinkle bridge so dips can
|
|
81
|
-
check onboarding markers, profiles, etc. without a parent-side
|
|
82
|
-
handshake. */
|
|
83
|
-
readFile: function(path) {
|
|
84
|
-
return _vfsCall('dip-readfile', { path: path }, function(m) { return m.content; });
|
|
85
|
-
},
|
|
86
|
-
exists: function(path) {
|
|
87
|
-
return _vfsCall('dip-exists', { path: path }, function(m) { return m.exists; });
|
|
88
|
-
},
|
|
89
|
-
stat: function(path) {
|
|
90
|
-
return _vfsCall('dip-stat', { path: path }, function(m) { return m.stat; });
|
|
91
|
-
}${e?An:``}${e?jn:``}${e?Mn:``}
|
|
92
|
-
};
|
|
93
|
-
function reportHeight() {
|
|
94
|
-
parent.postMessage({ type: 'dip-height',
|
|
95
|
-
height: document.documentElement.scrollHeight }, '*');
|
|
96
|
-
}
|
|
97
|
-
window.addEventListener('message', function(e) {
|
|
98
|
-
if (!e.data || typeof e.data.type !== 'string') return;
|
|
99
|
-
if (e.data.type === 'slicc-theme') {
|
|
100
|
-
document.documentElement.classList.toggle('theme-light', !!e.data.isLight);
|
|
101
|
-
return;
|
|
102
|
-
}
|
|
103
|
-
/* Pushed device events (currently 'hid:inputreport'). The host
|
|
104
|
-
attaches the underlying listener on slicc.hid.open(handle) for
|
|
105
|
-
this dip; teardown happens automatically on dispose. */
|
|
106
|
-
if (e.data.type === 'dip-device-event' && e.data.channel === 'hid:inputreport') {
|
|
107
|
-
_hidInputReportListeners.forEach(function(cb) {
|
|
108
|
-
try { cb(e.data.payload); } catch(ex) {}
|
|
109
|
-
});
|
|
110
|
-
return;
|
|
111
|
-
}
|
|
112
|
-
/* VFS callback responses target the originating call by id. */
|
|
113
|
-
if (e.data.id && _callbacks[e.data.id]) {
|
|
114
|
-
var cb = _callbacks[e.data.id];
|
|
115
|
-
delete _callbacks[e.data.id];
|
|
116
|
-
cb(e.data);
|
|
117
|
-
return;
|
|
118
|
-
}
|
|
119
|
-
/* Forward any other slicc-* message to in-page listeners via a
|
|
120
|
-
CustomEvent. Dips can opt in with
|
|
121
|
-
window.addEventListener('slicc-message', (ev) => ev.detail). */
|
|
122
|
-
if (e.data.type.indexOf('slicc-') === 0) {
|
|
123
|
-
try {
|
|
124
|
-
document.dispatchEvent(new CustomEvent('slicc-message', { detail: e.data }));
|
|
125
|
-
} catch (ex) {}
|
|
126
|
-
}
|
|
127
|
-
});
|
|
128
|
-
window.addEventListener('load', function() {
|
|
129
|
-
reportHeight();
|
|
130
|
-
new ResizeObserver(reportHeight).observe(document.body);
|
|
131
|
-
});
|
|
132
|
-
/* Support data-action attributes (Tool UI compat) — auto-lick on click.
|
|
133
|
-
Also intercept <a href> clicks and relay to the parent so links open
|
|
134
|
-
despite the iframe sandbox blocking top-level navigation. */
|
|
135
|
-
document.addEventListener('click', function(e) {
|
|
136
|
-
var el = e.target;
|
|
137
|
-
while (el && el !== document.body) {
|
|
138
|
-
if (el.dataset && el.dataset.action) {
|
|
139
|
-
var actionData = el.dataset.actionData;
|
|
140
|
-
if (actionData) { try { actionData = JSON.parse(actionData); } catch(ex) {} }
|
|
141
|
-
/* Picker hint (e.g. data-picker="directory") needs the parent to
|
|
142
|
-
run File System Access API on the click activation chain.
|
|
143
|
-
Forward as a separate message so the parent can run
|
|
144
|
-
showDirectoryPicker, stash the handle in IDB, then dispatch
|
|
145
|
-
the lick with the IDB key. */
|
|
146
|
-
var picker = el.dataset.picker;
|
|
147
|
-
if (picker) {
|
|
148
|
-
parent.postMessage({
|
|
149
|
-
type: 'dip-picker-action',
|
|
150
|
-
action: el.dataset.action,
|
|
151
|
-
data: actionData || null,
|
|
152
|
-
picker: picker,
|
|
153
|
-
}, '*');
|
|
154
|
-
} else {
|
|
155
|
-
window.slicc.lick({ action: el.dataset.action, data: actionData || null });
|
|
156
|
-
}
|
|
157
|
-
e.preventDefault();
|
|
158
|
-
e.stopPropagation();
|
|
159
|
-
return;
|
|
160
|
-
}
|
|
161
|
-
if (el.tagName === 'A' && el.getAttribute('href')) {
|
|
162
|
-
var href = el.getAttribute('href');
|
|
163
|
-
/* Allow in-iframe anchor navigation (#foo). Skip javascript: for safety. */
|
|
164
|
-
if (href.charAt(0) === '#') return;
|
|
165
|
-
if (/^javascript:/i.test(href)) { e.preventDefault(); return; }
|
|
166
|
-
/* Resolve relative URLs against the iframe's base. */
|
|
167
|
-
var resolved;
|
|
168
|
-
try { resolved = new URL(href, document.baseURI).href; } catch(ex) { resolved = href; }
|
|
169
|
-
parent.postMessage({ type: 'dip-open-link', url: resolved }, '*');
|
|
170
|
-
e.preventDefault();
|
|
171
|
-
e.stopPropagation();
|
|
172
|
-
return;
|
|
173
|
-
}
|
|
174
|
-
el = el.parentElement;
|
|
175
|
-
}
|
|
176
|
-
});
|
|
177
|
-
})();`}var Pn=`html,body{margin:0;padding:0;overflow:hidden;background:transparent;box-sizing:border-box}
|
|
178
|
-
*,*::before,*::after{box-sizing:inherit}
|
|
179
|
-
/* Vertical breathing room around dip content. Horizontal padding is owned
|
|
180
|
-
by the dip's own content (e.g. .sprinkle-action-card__body) so shtml
|
|
181
|
-
widgets that already pad themselves don't end up double-indented. The
|
|
182
|
-
ResizeObserver on document.body reports the post-padding scrollHeight
|
|
183
|
-
correctly, so auto-height continues to work. The .sprinkle-inline rule
|
|
184
|
-
(set on the iframe body) carries 2px of horizontal padding so the 1px
|
|
185
|
-
focus ring (box-shadow:0 0 0 1px on inputs/select below) doesn't get
|
|
186
|
-
clipped at the iframe paint boundary. */
|
|
187
|
-
body{padding:12px 0;font-family:var(--s2-font-family, sans-serif);font-size:13px;color:var(--s2-content-default)}
|
|
188
|
-
.sprinkle-inline{padding:var(--s2-spacing-100) 2px}
|
|
189
|
-
.sprinkle-inline .sprinkle-btn{padding:4px 12px;font-size:12px;height:28px;box-shadow:none}
|
|
190
|
-
.sprinkle-inline .sprinkle-btn:not([class*="sprinkle-btn--"]){background:var(--s2-bg-elevated)}
|
|
191
|
-
.sprinkle-inline .sprinkle-card{box-shadow:none;margin:0}
|
|
192
|
-
.sprinkle-inline .sprinkle-action-card{margin:0;width:100%}
|
|
193
|
-
.sprinkle-inline .sprinkle-action-card .sprinkle-table{width:100%}
|
|
194
|
-
.sprinkle-inline .sprinkle-grid{width:100%}
|
|
195
|
-
input[type="range"]{width:100%;height:4px;-webkit-appearance:none;appearance:none;background:var(--s2-gray-300);border-radius:2px;outline:none;cursor:default}
|
|
196
|
-
input[type="range"]::-webkit-slider-thumb{-webkit-appearance:none;width:18px;height:18px;border-radius:50%;background:var(--s2-accent);cursor:default;border:2px solid var(--s2-bg-base)}
|
|
197
|
-
input[type="range"]::-moz-range-thumb{width:14px;height:14px;border-radius:50%;background:var(--s2-accent);cursor:default;border:2px solid var(--s2-bg-base)}
|
|
198
|
-
input[type="text"],input[type="number"],textarea{width:100%;padding:7px 12px;font-size:13px;font-family:var(--s2-font-family,sans-serif);color:var(--s2-content-default);background:var(--s2-bg-layer-2);border:1px solid var(--s2-border-subtle,var(--s2-gray-300));border-radius:8px;outline:none;box-sizing:border-box}
|
|
199
|
-
input[type="text"]:focus,input[type="number"]:focus,textarea:focus{border-color:var(--s2-accent);box-shadow:0 0 0 1px var(--s2-accent)}
|
|
200
|
-
input[type="text"]::placeholder,textarea::placeholder{color:var(--s2-content-disabled,var(--s2-gray-400))}
|
|
201
|
-
select{padding:6px 12px;font-size:13px;font-family:var(--s2-font-family,sans-serif);color:var(--s2-content-default);background:var(--s2-bg-layer-2);border:1px solid var(--s2-border-subtle,var(--s2-gray-300));border-radius:8px;outline:none;cursor:default}
|
|
202
|
-
select:focus{border-color:var(--s2-accent);box-shadow:0 0 0 1px var(--s2-accent)}
|
|
203
|
-
button{display:inline-flex;align-items:center;justify-content:center;gap:6px;height:28px;padding:4px 12px;border:1px solid var(--s2-border-default,var(--s2-gray-300));border-radius:9999px;background:transparent;color:var(--s2-content-default);font-size:12px;font-weight:700;font-family:var(--s2-font-family,sans-serif);cursor:default;transition:background 130ms ease}
|
|
204
|
-
button:hover{background:color-mix(in srgb,var(--s2-content-default) 6%,transparent)}
|
|
205
|
-
button:disabled{opacity:0.4;pointer-events:none}
|
|
206
|
-
canvas{display:block;width:100%;border-radius:8px}
|
|
207
|
-
mark{background:color-mix(in srgb,var(--s2-accent) 25%,transparent);color:inherit;border-radius:2px;padding:0 2px}
|
|
208
|
-
.c-purple{background:#3C3489;color:#EEEDFE}.c-teal{background:#085041;color:#E1F5EE}
|
|
209
|
-
.c-coral{background:#712B13;color:#FAECE7}.c-pink{background:#72243E;color:#FBEAF0}
|
|
210
|
-
.c-gray{background:#444441;color:#F1EFE8}.c-blue{background:#0C447C;color:#E6F1FB}
|
|
211
|
-
.c-amber{background:#633806;color:#FAEEDA}.c-red{background:#791F1F;color:#FCEBEB}
|
|
212
|
-
.c-green{background:#27500A;color:#EAF3DE}`,Fn=`(function(){
|
|
213
|
-
window.addEventListener('message', function(e){
|
|
214
|
-
if (!e.data || e.data.type !== 'dip-draft-update') return;
|
|
215
|
-
var content = typeof e.data.content === 'string' ? e.data.content : '';
|
|
216
|
-
document.body.innerHTML = content;
|
|
217
|
-
if (window.lucide && typeof window.lucide.createIcons === 'function') {
|
|
218
|
-
try { window.lucide.createIcons(); } catch(ex){}
|
|
219
|
-
}
|
|
220
|
-
});
|
|
221
|
-
})();`;function In(e,t,n=!1){let r=ee(),i=vt()?` class="theme-light"`:``,a=t||e.includes(`<slicc-editor`),o=t||e.includes(`<slicc-diff`),s=t?`<script>${Fn}<\/script>`:``;return`<!DOCTYPE html>
|
|
222
|
-
<html${i}><head>
|
|
223
|
-
<meta charset="utf-8">
|
|
224
|
-
<style>${r}</style>
|
|
225
|
-
<style>${Pn}</style>
|
|
226
|
-
<script>${Nn(n&&!t)}<\/script>
|
|
227
|
-
${s}
|
|
228
|
-
${a?`<script src="/slicc-editor.js"><\/script>`:``}
|
|
229
|
-
${o?`<script src="/slicc-diff.js"><\/script>`:``}
|
|
230
|
-
<script src="/lucide-icons.js"><\/script>
|
|
231
|
-
</head>
|
|
232
|
-
<body class="sprinkle-inline">${e}</body></html>`}var M=new Set;function Ln(e){if(typeof e?.type!=`string`||e.type.indexOf(`slicc-`)!==0)throw Error(`broadcastToDips: payload.type must start with 'slicc-'`);for(let t of M)try{t.postMessage(e,`*`)}catch{}}var Rn;function zn(e){Rn=e}function N(e){return e.length===0?`''`:`'${e.replace(/'/g,`'\\''`)}'`}function Bn(e,t){let n=t?.cwd??`.`,r=t?.allowedCommands??`*`,i=[`agent`];return t?.model&&i.push(`--model`,N(t.model)),t?.thinking&&i.push(`--thinking`,N(t.thinking)),t?.readOnly&&i.push(`--read-only`,N(t.readOnly)),i.push(N(n),N(r),N(e)),i.join(` `)}async function Vn(e){if(!Rn)return{stdout:``,stderr:`exec: shell bridge not available
|
|
233
|
-
`,exitCode:127};try{return await Rn(e)}catch(e){return{stdout:``,stderr:`exec: ${e instanceof Error?e.message:String(e)}\n`,exitCode:1}}}async function Hn(e,t){let n=await Vn(Bn(e,t));return{stdout:n.stdout||n.stderr,exitCode:n.exitCode}}async function Un(e,t){let n=await x(Vn,e,t);if(e===`fetch`){let e=n,t=atob(e.bodyBase64),r=new Uint8Array(t.length);for(let e=0;e<t.length;e++)r[e]=t.charCodeAt(e);return{...e,body:new TextDecoder(`utf-8`).decode(r)}}return n}var P=new WeakMap;function Wn(e,t){try{e.postMessage({type:`dip-device-event`,channel:`hid:inputreport`,payload:t},`*`)}catch{}}async function Gn(e,t){let n=P.get(e);if(n||(n=new Map,P.set(e,n)),n.has(t))return;let r=await Ie(Me(),t,n=>{let r=n.bytes instanceof Uint8Array?n.bytes:new Uint8Array(n.bytes);Wn(e,{handle:t,reportId:n.reportId,data:r})});n.set(t,r)}async function Kn(e,t){let n=P.get(e);if(!n)return;let r=n.get(t);if(r){n.delete(t);try{await Promise.resolve(r())}catch{}}n.size===0&&P.delete(e)}function qn(e){let t=P.get(e);if(t){for(let e of t.values())try{Promise.resolve(e()).catch(()=>{})}catch{}P.delete(e)}}function Jn(e){if(e instanceof Uint8Array)return e;if(e instanceof ArrayBuffer)return new Uint8Array(e);if(ArrayBuffer.isView(e)){let t=e;return new Uint8Array(t.buffer,t.byteOffset,t.byteLength)}if(Array.isArray(e))return new Uint8Array(e);throw Error(`expected Uint8Array, ArrayBuffer, or number[]`)}async function Yn(e,t,n){let r=Me();switch(t){case`list`:{let e=je();if(!e)throw Error(`WebHID is unavailable in this browser`);return Ve(r,e)}case`request`:{let e=je();if(!e)throw Error(`WebHID is unavailable in this browser`);return He(r,e,n[0]??[])}case`info`:return We(r,n[0]);case`open`:{let t=n[0];return await Xe(r,t),await Gn(e,t),{ok:!0}}case`close`:{let t=n[0];return await Kn(e,t),await Ge(r,t),{ok:!0}}case`sendReport`:{let e=n[0],t=n[1],i=Jn(n[2]),a=i.buffer.slice(i.byteOffset,i.byteOffset+i.byteLength);return await ze(r,e,t,a),{ok:!0}}default:throw Error(`hid: unknown op '${t}'`)}}async function Xn(e,t){let n=Ne();switch(e){case`list`:{let e=Pe();if(!e)throw Error(`Web Serial is unavailable in this browser`);return Le(n,e)}case`request`:{let e=Pe();if(!e)throw Error(`Web Serial is unavailable in this browser`);return Fe(n,e,t[0]??[])}case`info`:return Be(n,t[0]);case`open`:{let e=t[0],r=t[1]??{baudRate:9600};return await Re(n,e,r),{ok:!0}}case`close`:return await Ze(n,t[0]),{ok:!0};default:throw Error(`serial: unknown op '${e}'`)}}async function Zn(e,t){let n=et();switch(e){case`list`:{let e=tt();if(!e)throw Error(`WebUSB is unavailable in this browser`);return Je(n,e)}case`request`:{let e=tt();if(!e)throw Error(`WebUSB is unavailable in this browser`);return Ye(n,e,t[0]??[])}case`info`:return Ke(n,t[0]);case`open`:return await Ue(n,t[0]),{ok:!0};case`close`:return await qe(n,t[0]),{ok:!0};default:throw Error(`usb: unknown op '${e}'`)}}async function Qn(e,t,n,r){switch(t){case`hid`:return Yn(e,n,r);case`serial`:return Xn(n,r);case`usb`:return Zn(n,r);default:throw Error(`unknown device channel '${t}'`)}}async function $n(e,t){if(!e||typeof t.id!=`number`)return!1;let n=n=>{try{e.postMessage({...n,id:t.id},`*`)}catch{}};if(!j.has(e))return n({type:`dip-device-op-response`,error:`device access not allowed for this dip`}),!0;let r=t.channel;if(r!==`hid`&&r!==`serial`&&r!==`usb`)return n({type:`dip-device-op-response`,error:`unknown device channel '${r}'`}),!0;try{n({type:`dip-device-op-response`,result:await Qn(e,r,typeof t.op==`string`?t.op:``,Array.isArray(t.args)?t.args:[])})}catch(e){n({type:`dip-device-op-response`,error:e instanceof Error?e.message:String(e)})}return!0}async function er(e,t){if(!e||typeof t.id!=`number`)return!1;let n=n=>{try{e.postMessage({...n,id:t.id},`*`)}catch{}};if(!j.has(e))return n({type:`${t.type}-response`,error:`exec not allowed for this dip`}),!0;if(t.type===`dip-exec`)return n({type:`dip-exec-response`,result:await Vn(typeof t.cmd==`string`?t.cmd:``)}),!0;if(t.type===`dip-agent`)return n({type:`dip-agent-response`,result:await Hn(typeof t.prompt==`string`?t.prompt:``,t.opts)}),!0;if(t.type===`dip-jsh`){try{n({type:`dip-jsh-response`,result:await Un(typeof t.op==`string`?t.op:``,Array.isArray(t.args)?t.args:[])})}catch(e){n({type:`dip-jsh-response`,error:e instanceof Error?e.message:String(e)})}return!0}return!1}function F(e,t,n,r=!1){let i=In(t,!1,r);if(bn)return pr(e,i,n,r);let a=document.createElement(`iframe`);a.setAttribute(`sandbox`,`allow-scripts allow-same-origin`),a.style.cssText=`width:100%;border:none;overflow:hidden;display:block;`,a.srcdoc=i,e.appendChild(a),a.contentWindow&&(yt(a.contentWindow),M.add(a.contentWindow),r&&j.add(a.contentWindow)),a.addEventListener(`load`,()=>{yt(a.contentWindow),a.contentWindow&&(M.add(a.contentWindow),r&&j.add(a.contentWindow)),b()&&S(a)},{once:!0});let o=e=>{if(e.source!==a.contentWindow)return;let t=e.data;t?.type&&(t.type===`dip-lick`?n(t.action,t.data):t.type===`dip-height`?a.style.height=t.height+`px`:t.type===`dip-open-link`?nr(t.url):t.type===`dip-picker-action`?ar(t,n):t.type===`dip-readfile`||t.type===`dip-exists`||t.type===`dip-stat`?tr(a.contentWindow,t):t.type===`dip-exec`||t.type===`dip-agent`||t.type===`dip-jsh`?er(a.contentWindow,t):t.type===`dip-device-op`&&$n(a.contentWindow,t))};window.addEventListener(`message`,o);let s=null;if(b()&&typeof IntersectionObserver<`u`){let e=!1,t=new IntersectionObserver(n=>{if(n[n.length-1].isIntersecting){if(e){e=!1;return}t.unobserve(a),S(a,()=>{e=!0,t.observe(a)})}});s=t,t.observe(a)}return{dispose(){s?.disconnect(),window.removeEventListener(`message`,o),_t(a.contentWindow),a.contentWindow&&(M.delete(a.contentWindow),j.delete(a.contentWindow),qn(a.contentWindow)),a.remove()}}}async function tr(e,t){if(!e||typeof t.id!=`number`)return!1;let n=typeof t.path==`string`?t.path:``,r=n=>{try{e.postMessage({...n,id:t.id},`*`)}catch{}};if(!j.has(e))return r({type:`${t.type}-response`,error:`VFS access not allowed for this dip`}),!0;if(!kn(n))return r({type:`${t.type}-response`,error:`VFS path not allowed: ${n}`}),!0;if(t.type===`dip-readfile`){let e=await Tn(n,!0);return e===null?(r({type:`dip-readfile-response`,error:`Read failed`}),!0):(r({type:`dip-readfile-response`,content:typeof e==`string`?e:new TextDecoder().decode(e)}),!0)}if(t.type===`dip-exists`)return r({type:`dip-exists-response`,exists:await Tn(n,!0)!==null}),!0;if(t.type===`dip-stat`){let e=await Tn(n,!1);return e===null?(r({type:`dip-stat-response`,error:`Stat failed`}),!0):(r({type:`dip-stat-response`,stat:{isFile:!0,isDirectory:!1,size:typeof e==`string`?e.length:e.byteLength,mtimeMs:0}}),!0)}return!1}function nr(e){if(!(typeof e!=`string`||!e)&&/^(https?:|mailto:)/i.test(e))try{window.open(e,`_blank`,`noopener,noreferrer`)}catch{}}function rr(e,t){let n=[],r=e.querySelectorAll(`pre > code.language-shtml`);for(let e of r){let r=e.parentElement,i=e.textContent??``,a=document.createElement(`div`);a.className=`msg__dip`,r.replaceWith(a),n.push(F(a,i,t,!1))}let i=e.querySelectorAll(`img[src$=".shtml"]`);for(let e of i){let r=e.getAttribute(`src`);if(!r)continue;let i=document.createElement(`div`);i.className=`msg__dip`,e.alt&&i.setAttribute(`title`,e.alt),e.replaceWith(i);let a=new AbortController,o=null,s=!1;n.push({dispose(){s=!0,a.abort(),o&&=(o.dispose(),null)}});let c=r.startsWith(`/`),l=typeof navigator<`u`&&!!navigator.serviceWorker?.controller,u=c?`/preview${r}`:r,d=async()=>{if(c&&!l)return Sn(r,a.signal);let e;try{e=await fetch(u,{signal:a.signal})}catch(e){if(e?.name===`AbortError`)throw e;if(c)return Sn(r,a.signal);throw e}if(e.ok)return e.text();if(c)return Sn(r,a.signal);throw Error(`HTTP ${e.status}`)},f=c&&On(r);d().then(e=>{s||!i.isConnected||(o=F(i,e,t,f))}).catch(e=>{s||e?.name===`AbortError`||(i.textContent=`Failed to load dip: ${r}`,i.style.cssText=`padding:8px;font-size:12px;color:var(--s2-negative);font-family:var(--s2-font-mono)`)})}return n}function ir(e){for(let t of e)try{t.dispose()}catch{}e.length=0}async function ar(e,t){let n=xn(e.data);if(bn){await or(e.picker,e.action,n,t);return}switch(e.picker){case`directory`:await lr(e.action,t);return;case`usb-device`:await ur(e.action,n,t);return;case`serial-port`:await dr(e.action,n,t);return;case`hid-device`:await fr(e.action,n,t);return;default:t(e.action,e.data);return}}async function or(e,t,n,r){try{switch(e){case`directory`:{let{openMountPickerPopup:e}=await l(async()=>{let{openMountPickerPopup:e}=await import(`./mount-picker-popup--ijSfN8u.js`);return{openMountPickerPopup:e}},__vite__mapDeps([0,1,2,3])),n=await e();n.cancelled?r(t,{cancelled:!0}):n.error?r(t,{error:n.error}):n.idbKey?r(t,{handleInIdb:!0,idbKey:n.idbKey,dirName:n.dirName??``}):r(t,{error:`mount picker returned no handle key`});return}case`usb-device`:{let{openUsbPickerPopup:e}=await l(async()=>{let{openUsbPickerPopup:e}=await import(`./usb-picker-Cbm0jfjl.js`);return{openUsbPickerPopup:e}},__vite__mapDeps([4,2,3])),i=await e(n);`cancelled`in i?r(t,{cancelled:!0}):`error`in i?r(t,{error:i.error}):r(t,{granted:!0,info:i.info});return}case`serial-port`:{let{openSerialPickerPopup:e}=await l(async()=>{let{openSerialPickerPopup:e}=await import(`./serial-picker-BQF_Eitc.js`);return{openSerialPickerPopup:e}},__vite__mapDeps([5,2,3])),i=await e(n);`cancelled`in i?r(t,{cancelled:!0}):`error`in i?r(t,{error:i.error}):r(t,{granted:!0,info:i.info});return}case`hid-device`:{let{openHidPickerPopup:e}=await l(async()=>{let{openHidPickerPopup:e}=await import(`./hid-picker-sFJ8vzUj.js`);return{openHidPickerPopup:e}},__vite__mapDeps([6,2,3])),i=await e(n);`cancelled`in i?r(t,{cancelled:!0}):`error`in i?r(t,{error:i.error}):r(t,{granted:!0,info:i.info});return}default:r(t,{error:`unknown picker kind: ${e??`(none)`}`});return}}catch(e){r(t,{error:e instanceof Error?e.message:String(e)})}}async function sr(e,t){let n=Ae();if(!n)return null;let r={current:null},i=t=>{let n=t.detail;n.kind===e&&(r.current=n)};n.addEventListener(`slicc-permission-deny`,i);try{let i=await n.request(e,t);if(i)return{ok:!0,grant:i};let a=r.current;return{ok:!1,reason:a?.reason??`error`,...a?.message?{message:a.message}:{}}}finally{n.removeEventListener(`slicc-permission-deny`,i)}}function cr(e,t,n,r){if(t.reason===`cancelled`){r(e,{cancelled:!0});return}if(t.reason===`unavailable`){r(e,{error:n});return}r(e,{error:t.message??`unknown error`})}async function lr(e,t){let n=await sr(`filesystem`);if(!n){t(e,{error:`File System Access API not available`});return}if(!n.ok){cr(e,n,`File System Access API not available`,t);return}let r=n.grant.handle,i=`pendingMount:dip-${Date.now().toString(36)}-${Math.random().toString(36).slice(2,10)}`;try{let{storePendingHandle:e}=await l(async()=>{let{storePendingHandle:e}=await import(`./mount-picker-popup--ijSfN8u.js`);return{storePendingHandle:e}},__vite__mapDeps([0,1,2,3]));await e(i,r)}catch(n){t(e,{error:`failed to store directory handle: ${n instanceof Error?n.message:String(n)}`});return}t(e,{handleInIdb:!0,idbKey:i,dirName:r.name})}async function ur(e,t,n){let r=await sr(`usb`,{filters:t});if(!r){n(e,{error:`WebUSB is not available`});return}if(!r.ok){cr(e,r,`WebUSB is not available`,n);return}let i=r.grant,{getSharedUsbRegistry:a,deviceToInfo:o}=await l(async()=>{let{getSharedUsbRegistry:e,deviceToInfo:t}=await import(`./usb-device-registry-DmUBqrA-.js`).then(e=>e.a);return{getSharedUsbRegistry:e,deviceToInfo:t}},__vite__mapDeps([7,8])),s=a().register(i.device);n(e,{granted:!0,handle:s,info:o(s,i.device)})}async function dr(e,t,n){let r=await sr(`serial`,t.length?{filters:t}:void 0);if(!r){n(e,{error:`Web Serial is not available`});return}if(!r.ok){cr(e,r,`Web Serial is not available`,n);return}let i=r.grant,a=await l(()=>import(`./serial-port-registry-CCqklAEr.js`).then(e=>e.o),__vite__mapDeps([9,8])),o=a.getSharedSerialRegistry(),s=o.register(i.port),c=o.get(s);n(e,{granted:!0,handle:s,info:c?a.deviceToInfo(s,c):{handle:s}})}async function fr(e,t,n){let r=await sr(`hid`,{filters:t});if(!r){n(e,{error:`WebHID is not available`});return}if(!r.ok){cr(e,r,`WebHID is not available`,n);return}let i=r.grant,{getSharedHidRegistry:a,hidDeviceToInfo:o}=await l(async()=>{let{getSharedHidRegistry:e,hidDeviceToInfo:t}=await import(`./hid-device-registry-B2R-0rNt.js`).then(e=>e.a);return{getSharedHidRegistry:e,hidDeviceToInfo:t}},__vite__mapDeps([10,8])),s=a(),c=i.devices.map(e=>{let t=s.register(e);return o(t,e)}),u=c[0];n(e,{granted:!0,handle:u.handle,info:u,devices:c})}function pr(e,t,n,r=!1){let i=document.createElement(`iframe`);i.src=chrome.runtime.getURL(`sprinkle-sandbox.html`),i.style.cssText=`width:100%;border:none;overflow:hidden;display:block;`,e.appendChild(i);let a=e=>{if(e.source!==i.contentWindow)return;let t=e.data;t?.type&&(t.type===`dip-lick`?n(t.action,t.data):t.type===`dip-height`?i.style.height=t.height+`px`:t.type===`dip-open-link`?nr(t.url):t.type===`dip-readfile`||t.type===`dip-exists`||t.type===`dip-stat`?tr(i.contentWindow,t):t.type===`dip-exec`||t.type===`dip-agent`||t.type===`dip-jsh`?er(i.contentWindow,t):t.type===`dip-device-op`?$n(i.contentWindow,t):t.type===`dip-picker-action`&&ar(t,n))};return window.addEventListener(`message`,a),i.addEventListener(`load`,()=>{yt(i.contentWindow),i.contentWindow&&(M.add(i.contentWindow),r&&j.add(i.contentWindow)),i.contentWindow?.postMessage({type:`dip-render`,srcdoc:t,isLight:vt()},`*`)},{once:!0}),{dispose(){window.removeEventListener(`message`,a),_t(i.contentWindow),i.contentWindow&&(M.delete(i.contentWindow),j.delete(i.contentWindow),qn(i.contentWindow)),i.remove()}}}var mr=`---
|
|
234
|
-
writablePaths:
|
|
235
|
-
- /workspace/CLAUDE.md
|
|
236
|
-
visiblePaths:
|
|
237
|
-
- /sessions/
|
|
238
|
-
- /shared/
|
|
239
|
-
- /workspace/
|
|
240
|
-
allowedCommands:
|
|
241
|
-
- awk
|
|
242
|
-
- cat
|
|
243
|
-
- cp
|
|
244
|
-
- cut
|
|
245
|
-
- echo
|
|
246
|
-
- file
|
|
247
|
-
- find
|
|
248
|
-
- grep
|
|
249
|
-
- head
|
|
250
|
-
- jq # structured reads of JSON stores such as /shared/loose-ends.json
|
|
251
|
-
- ls
|
|
252
|
-
- mkdir
|
|
253
|
-
- mv
|
|
254
|
-
- od # read-only byte inspection of corrupted stores
|
|
255
|
-
- printf
|
|
256
|
-
- rg # recursive, .gitignore-aware search; what the curator actually uses over find|xargs grep
|
|
257
|
-
- sed
|
|
258
|
-
- sort
|
|
259
|
-
- tail
|
|
260
|
-
- tr
|
|
261
|
-
- uniq
|
|
262
|
-
- upskill
|
|
263
|
-
- wc
|
|
264
|
-
timeoutSeconds: 1200
|
|
265
|
-
thinkingLevel: medium
|
|
266
|
-
---
|
|
267
|
-
|
|
268
|
-
# Memory curator
|
|
269
|
-
|
|
270
|
-
Curate the durable memory for session {{SESSION_COUNT}}. Today's date is {{TODAY}}.
|
|
271
|
-
|
|
272
|
-
**Work fast: a full pass should finish in well under 10 minutes.** The run is hard-stopped at 20 minutes, and your rewrite only lands if the pass completes — a killed run is discarded wholesale. So mine the three signals, rewrite the file, compact it in the same pass, and stop, rather than exploring the archive exhaustively.
|
|
273
|
-
|
|
274
|
-
Read the entire current memory at {{MEMORY_PATH}} if it exists. Then mine the archived session at {{SESSION_ARCHIVE_PATH}} using the reading recipes below. Rewrite the entire {{MEMORY_PATH}} file with the durable information worth carrying into future sessions. Every part of the file is editable and counts toward the budget.
|
|
275
|
-
|
|
276
|
-
## What to look for
|
|
277
|
-
|
|
278
|
-
Three things carry across sessions, and each has its own place in the archive:
|
|
279
|
-
|
|
280
|
-
| Look for | Where it lives |
|
|
281
|
-
| --------------- | ---------------------------------------------------------------------- |
|
|
282
|
-
| **Preferences** | the user's own messages — how they want things done, and what to avoid |
|
|
283
|
-
| **Projects** | tool-call arguments — the paths, repos and files actually worked on |
|
|
284
|
-
| **Pitfalls** | failed tool calls — what broke, and the error that proves it |
|
|
285
|
-
|
|
286
|
-
Pitfalls are the highest-value and most-often-lost category: a failure that cost half an hour is worth one line next time. Keep the error text that identifies it, not the stack trace.
|
|
287
|
-
|
|
288
|
-
## Reading the session archive
|
|
289
|
-
|
|
290
|
-
**Never \`cat\` the archive and never \`head\` it.** Archives reach several megabytes, and the machine-readable \`<!-- slicc:session-data ... -->\` block is a _single line_ holding the whole session as JSON — roughly half the file. Reading it costs a fortune and tells you nothing the prose below it does not. Whole \`### Tool\` result bodies are the other half and are equally not worth reading.
|
|
291
|
-
|
|
292
|
-
Check the size first, then pull the three signals separately. Together they run about 1% of the archive, so these work on a 2.5 MB file as happily as on a small one.
|
|
293
|
-
|
|
294
|
-
\`\`\`bash
|
|
295
|
-
wc -c {{SESSION_ARCHIVE_PATH}}
|
|
296
|
-
|
|
297
|
-
# Preferences — what the user asked for, in their words.
|
|
298
|
-
sed '/^<!-- slicc:session-data$/,/^-->$/d' {{SESSION_ARCHIVE_PATH}} \\
|
|
299
|
-
| awk '/^## User/{p=1;next} /^## (Assistant|Summary)/{p=0} /^### Tool/{p=0} p'
|
|
300
|
-
|
|
301
|
-
# Projects — the paths touched most, which name the work.
|
|
302
|
-
sed '/^<!-- slicc:session-data$/,/^-->$/d' {{SESSION_ARCHIVE_PATH}} \\
|
|
303
|
-
| grep -o '/[A-Za-z0-9_][A-Za-z0-9_./-]\\{3,\\}' \\
|
|
304
|
-
| sort | uniq -c | sort -rn | head -40
|
|
305
|
-
|
|
306
|
-
# Pitfalls — failed calls with the input that caused them.
|
|
307
|
-
sed '/^<!-- slicc:session-data$/,/^-->$/d' {{SESSION_ARCHIVE_PATH}} \\
|
|
308
|
-
| grep -B6 '^Result:.*\\(rror\\|not found\\|failed\\|denied\\|ENOENT\\|fatal\\)' \\
|
|
309
|
-
| cut -c1-200
|
|
310
|
-
\`\`\`
|
|
311
|
-
|
|
312
|
-
Only if something is still missing, reach into one specific block with \`grep -n\` plus a bounded \`sed -n 'START,ENDp'\`. Never widen these to the whole file.
|
|
313
|
-
|
|
314
|
-
## Suggesting a skill
|
|
315
|
-
|
|
316
|
-
A recurring pitfall is often a missing skill. Once you know what broke and what the work was, spend **one** lookup on it — no more, and skip it entirely when the session had no failures:
|
|
317
|
-
|
|
318
|
-
\`\`\`bash
|
|
319
|
-
upskill search <a few words from the pitfall>
|
|
320
|
-
upskill list # what is already installed — never suggest a duplicate
|
|
321
|
-
\`\`\`
|
|
322
|
-
|
|
323
|
-
\`upskill ai-ecoverse/skills\` and \`upskill adobe/skills\` list a repo's skills without installing anything. **Never install.** You have no write access to the skills tree, so an install attempt will fail or interrupt the user for approval; recommending is your job, deciding is theirs. Put any suggestion in your closing message, with the pitfall it addresses — that message is delivered to the main agent.
|
|
324
|
-
|
|
325
|
-
## Working within the budget
|
|
326
|
-
|
|
327
|
-
Measure, decide, then write once. Do not converge on the budget by trial and error — each attempt re-reads your whole context and is billed accordingly.
|
|
328
|
-
|
|
329
|
-
1. \`wc -c {{MEMORY_PATH}}\` to get the current size, and subtract {{BUDGET_CHARS}} to get the exact surplus.
|
|
330
|
-
2. Decide up front which sections absorb that surplus, oldest-dated first, and roughly what each one costs. Budget the whole cut before editing anything.
|
|
331
|
-
3. Write the complete file once, already inside the budget. Never write a version you know to be over budget «to fix in the next step»: the pass can be killed at any moment, and the file you leave behind is the one the next session inherits.
|
|
332
|
-
4. \`wc -c {{MEMORY_PATH}}\` to confirm. If you are still over, cut a whole section rather than shaving a few characters at a time.
|
|
333
|
-
|
|
334
|
-
Per-section costs come out of \`awk\`, not an interpreter: \`awk '/^## /{h=$0} {c[h]+=length($0)+1} END{for(k in c) printf "%7d %s\\n", c[k], k}' {{MEMORY_PATH}} | sort -rn\` tells you which sections pay for the surplus.
|
|
335
|
-
|
|
336
|
-
To draft before committing, draft in \`{{SCRATCH_DIR}}\`. That is your own scratch folder: writable without a grant and without an approval prompt, private to this pass, and deleted when the pass ends. Reuse one filename such as \`{{SCRATCH_DIR}}/draft.md\` rather than numbering drafts — you have no \`rm\`, so every extra draft survives until the folder goes.
|
|
337
|
-
|
|
338
|
-
If the pass is running long, drop the oldest-dated section wholesale and write. An under-budget file missing one stale section is a good outcome; an over-budget file is a broken one.
|
|
339
|
-
|
|
340
|
-
Rules:
|
|
341
|
-
|
|
342
|
-
- Keep durable preferences, stable project facts, validated approaches, named resources, and the pitfalls worth not repeating.
|
|
343
|
-
- Organize retained information into concise per-topic sections rather than one flat list. Let the topic lead the heading; preferences, projects and pitfalls are what to look for, not a required table of contents.
|
|
344
|
-
- Never write next to the memory file. It is versioned, so backups and scratch copies beside it are noise; drafts belong in \`{{SCRATCH_DIR}}\`. Do not draft in the shared \`/tmp/\` root either — every other unit can read and overwrite what you leave there. \`$TMPDIR\` is your own directory under it and is the right home for ordinary scratch, but a full rewrite of durable memory still belongs in \`{{SCRATCH_DIR}}\`, which is private to the run and removed when the pass ends.
|
|
345
|
-
- Shell tools only. Interpreters such as \`python3\` and \`node -e\` are not on your allow-list, so reaching for one costs an approval round-trip and may fail even when approved — \`awk\`, \`sed\`, \`wc\` and \`sort\` cover every measurement this pass needs.
|
|
346
|
-
- End every \`##\` and \`###\` section heading with its last-verified date in \`YYYY-MM-DD\` form, for example \`## Deployment pipeline (2026-08-06)\`. Dates are UTC, matching the session archive timestamps, so a late-evening freeze west of UTC stamps the next day.
|
|
347
|
-
- Stamp sections you write or confirm with today's date, {{TODAY}}.
|
|
348
|
-
- Prioritize re-verifying the oldest-dated sections. Treat undated headings as maximally stale and date them on this pass.
|
|
349
|
-
- Drop ephemera and duplicates. Delete or merge sections that are stale, superseded, or unverifiable.
|
|
350
|
-
- Preserve concrete identifiers such as file paths, URLs, IDs, and names verbatim.
|
|
351
|
-
- Keep the entire file at or below the hard budget of {{BUDGET_CHARS}} characters, with no exempt region. When over budget, compact or remove the oldest-dated sections first.
|
|
352
|
-
- Write the result to {{MEMORY_PATH}}; do not merely return it in your response.
|
|
353
|
-
|
|
354
|
-
<!-- How to customize
|
|
355
|
-
Add curator instructions here, for example: also update the knowledge base at /path following its WIKI.md. Extend visiblePaths or writablePaths above to grant access to extra stores, and adjust timeoutSeconds when needed.
|
|
356
|
-
|
|
357
|
-
{{MEMORY_PATH}} resolves to a staged per-archive draft under /sessions/.curation/, not the live memory file: the pass snapshots the live file when it spawns, the curator rewrites the draft, and on a successful exit the runtime three-way-merges the rewrite back onto the live file. Edits the cone or the user makes to the live memory while the curator runs survive; where both sides changed the same lines the curator's version wins. An entry in writablePaths naming the memory file is substituted with the draft automatically, so this file keeps working unchanged. A failed or killed run leaves the live memory untouched and its outcome recorded at /sessions/.curation/<archive>/status.json.
|
|
358
|
-
|
|
359
|
-
writablePaths defaults to the memory file alone rather than /workspace/, because the curator can run upskill and a directory-wide grant would also let it install skills into /workspace/skills. Widen it only as far as a task genuinely needs; a single file is a valid entry, not just a directory.
|
|
360
|
-
|
|
361
|
-
Scratch space needs no entry here. The curator spawns under a fixed per-cone name (memory-curator for the primary cone), so the bridge grants it {{SCRATCH_DIR}} — private to the run, writable without a prompt, and removed when the pass ends — and that is where the prompt sends drafts. $TMPDIR is writable too and is this unit's own directory, but it outlives the run and stays readable by the cone, so a full rewrite of durable memory does not belong there.
|
|
362
|
-
|
|
363
|
-
thinkingLevel accepts off, minimal, low, medium, high, or xhigh. Curation is cheaper with reasoning than without: an unreasoned pass converges on the budget by trial and error, and because every turn re-reads the whole context, turn count is what the pass costs. Lower it to off only if you also shrink the prompt to a single mechanical instruction.
|
|
364
|
-
|
|
365
|
-
MEMORY.md is user-edited only: the curator intentionally has read-only access to /shared/ and cannot rewrite its own instructions. A bare / is rejected in writablePaths.
|
|
366
|
-
|
|
367
|
-
Frontmatter supports a strict YAML subset. Arrays may use the block form above (with optional # comment tails) or inline form such as [cat, grep]. \`allowedCommands\` is additive: listed commands extend the built-in base set without replacing it. Inline entries containing commas must be quoted, for example ["/knowledge/lars,rebecca/"].
|
|
368
|
-
-->
|
|
369
|
-
`,hr=`/cones`,gr=`/workspace/skills`;function _r(e){if(D(e)){if(mt(e))return{root:`/workspace`,memoryPath:`/workspace/CLAUDE.md`,scratch:`/tmp`};let t=`${hr}/${e.folder}`;return{root:`${t}/workspace`,memoryPath:`${t}/CLAUDE.md`,scratch:`/tmp`}}let t=`/scoops/${e.folder}`;return{root:`${t}/workspace`,memoryPath:`${t}/CLAUDE.md`,scratch:t}}var vr=`/tmp`;function yr(e,t){if(!t)return`${vr}/${gt}`;if(D(t))return`${vr}/${t.folder}`;let n=[...e];return`${vr}/${(st(n,t)??E(n)[0])?.folder??`cone`}/${t.folder}`}var I=Object.freeze(_r({parentJid:null,folder:gt}));function br(e,t){let n=[...e],r=st(n,t)??E(n)[0];return r?_r(r):I}function xr(e){let t=`${e.root}/`,n=`${gr}/`;return n.startsWith(t)?[t]:[t,n]}function Sr(e,t,n,r){let i=`/scoops/${t}/`;return e===`private`?{visiblePaths:[],writablePaths:[i]}:{visiblePaths:xr({root:r??n.root}),writablePaths:[i,`/shared/`]}}var Cr=`abject.abortive.abrasive.absolute.abstruse.abundant.abyssal.accessible.acerbic.acrid.adamant.adept.adlerian.adornian.adroit.adventurous.aeolian.aerated.aesthetic.affable.aged.ageless.agile.airborne.airlocked.airy.akkadian.alabaster.alacritous.alert.alien.alloyed.allusive.aloof.alpha.alpine.alternate.altruistic.amaranthine.amber.ambidextrous.ambivalent.ambrosial.amiable.amorphous.ample.analog.analytical.ancestral.ancient.angelic.animated.animist.anomalous.antediluvian.antic.antlered.apollinairian.apollonian.apt.aquatic.arbitrary.arcadian.arcane.archaic.archimedean.ardent.arduous.arendtian.argent.argentine.argive.aristotelian.armstrongian.aromatic.arresting.artful.arthurian.articulate.artificial.artisanal.artless.ascetic.ashen.ashy.asimovian.aspiring.assiduous.assyrian.asteroidal.astral.astute.asynchronous.athenian.atlantean.atomic.attentive.attic.audacious.audenesque.augmented.august.augustan.aureate.auric.auroral.austenian.austere.austral.authentic.autonomous.autumnal.avalonian.avid.avuncular.aztec.azure.babbagean.babylonian.bacchic.bachian.bactrian.ballardian.ballistic.balmy.banksian.barefoot.barreled.barthesian.bartokian.bashy.baudelairean.bayesian.beatific.beckettesque.beckettian.beethovenian.beguiling.bellicose.bemused.benevolent.benign.benjaminian.bergmanesque.beta.bewitched.binary.bionic.bismarckian.bitter.bitwise.blackened.blakean.blameless.bland.blazar.blazing.blended.blessed.blissful.blistered.blithe.blooming.blunt.blustery.boeotian.boggy.bohrian.boingy.boisterous.bold.bolted.bombastic.bonny.boolean.boreal.borgesian.borgian.bosky.botticellian.bottled.bouncy.boundless.bountiful.bourbon.bradburyan.brahmsian.braised.brambly.brash.brave.brazen.bready.breathless.brechtian.breezy.briared.briery.bright.brilliant.brined.briny.brisk.bristling.briton.brittenesque.broadband.brontean.bronzed.brooding.browned.browningesque.brucknerian.brumal.brusque.bubbling.bubbly.bucolic.budding.bunuelian.buoyant.burnished.burnt.buttered.buttery.bygone.byronic.bytewise.byzantine.cacophonous.caesarean.callow.calm.candescent.candid.candied.canny.cantorian.capable.capricious.caramelized.caravaggesque.carbon.carefree.carolingian.cartesian.carved.casked.cast.cavafian.cavalier.celebrated.celestial.celtic.ceramic.cerebral.ceremonious.cerulean.cervantine.cezannesque.chagallian.chalky.chaplinesque.charcoal.charismatic.charmed.charming.charred.chaucerian.cheeky.cheerful.chekhovian.cherished.cherubic.chewy.chilled.chilly.chimerical.chipper.chirpy.chivalrous.chopinesque.chromospheric.chronal.chthonic.chubby.chunky.churchillian.cimmerian.cindered.circumspect.circumstellar.citrusy.civil.clandestine.clangy.clarified.clarkean.classic.clement.clever.cloaked.clockwork.clompy.cloned.cloudlike.cloudy.clunky.clustered.coastal.cobalt.cognitive.coherent.coleridgean.colossal.coltranesque.comely.cometary.compiled.complacent.composite.concurrent.conradian.constablean.convivial.copernican.copious.coplandesque.cordial.corinthian.corked.cornelian.coronal.cortical.cosmic.coy.cozy.cracked.crackling.crafty.cranky.crashy.creamy.credible.crepuscular.cretan.crimson.crisp.crispy.crowned.crumbly.crunchy.crushed.cryo.cryofrozen.cryogenic.cryonic.cryptic.crystalline.cuddly.cumulative.cunning.cupric.cured.curious.cursed.cursory.cushy.cybernetic.cyberpunk.cynical.cyprian.daliesque.dancy.dandy.dantean.dantesque.dapper.dappled.daring.dark.darwinian.dashing.dashy.dauntless.davisian.dawning.dazzling.deathless.debonair.deboned.debussyan.decanted.decompiled.decorous.decrypted.deep.deferential.deft.degasian.delectable.deleuzian.delian.deliberate.delicate.delirious.delphic.delta.demure.depressurized.derridean.destined.devout.dewy.dexterous.diaphanous.diced.dickensian.dickian.dickinsonian.didactic.dieselpunk.diffident.digital.dignified.diligent.dimensional.dinky.dionysian.discerning.discreet.disheveled.disparate.distant.distinct.distributed.diurnal.divine.dizzy.docile.docked.dogged.doomed.dorian.dormant.dostoevskian.dotty.doughty.doughy.downy.dozy.draconic.dreamful.dreamy.drifting.dripping.drizzly.droll.drowsy.druidic.dulcet.dun.dunky.durkheimian.dusky.dwarven.dynamic.dystopian.eager.earnest.earthy.eastward.easygoing.ebony.ebullient.eclectic.eclipsed.ecstatic.edenic.edwardian.effervescent.effulgent.effusive.einsteinian.elamite.elastic.elated.eldritch.electric.electronic.elegant.elegiac.elgarian.eliotian.eliotic.elizabethan.ellingtonian.eloquent.elusive.elven.elvish.elysian.embered.emergent.eminent.emphatic.emulsified.enchanted.encoded.encrypted.endearing.endless.endogenous.energetic.enhanced.enigmatic.enthralling.ephemeral.epic.epicurean.equanimous.errant.erudite.escherian.esoteric.esteemed.eternal.ethereal.ethiopian.etruscan.euclidean.eulerian.euphonious.euphoric.evanescent.evening.eventide.everlasting.evocative.exacting.exalted.exemplary.exo.exogenous.expansive.expressive.exquisite.extraterrestrial.extruded.exuberant.fabled.fabulous.facetious.faithful.fallow.fanciful.fantastic.faradayic.faraway.farmhouse.fastidious.fated.fateful.fathomless.faulknerian.faunal.fearless.feathered.feathery.fecund.federated.feisty.felicitous.felliniesque.fenny.fermented.ferny.ferrous.fervent.fervid.festive.fetching.fey.fickle.fierce.fiery.filleted.filtered.fitzgeraldian.fizzy.flaky.flamboyant.flamed.flashy.flawless.fleecy.fleet.fleeting.flexible.flickering.flinty.floral.florid.flouncy.flourishing.flowering.fluent.fluffy.fluid.fluvial.foamy.folded.fond.foraged.forged.formidable.forthright.fortuitous.forward.foucauldian.fourier.fractal.fragrant.frank.frankish.freckled.free.fresh.freudian.friedmanite.frisky.frizzy.frolicsome.frosted.frosty.frothy.frozen.frugal.fruiting.fruity.funky.furred.furtive.futuristic.fuzzy.gaelic.galactic.galbraithian.galilean.gallant.gallic.galvanic.gamesome.gamma.gandhian.garlanded.garrulous.gauguinesque.gaussian.gauzy.generous.genetic.genial.genomic.genteel.gentle.geomagnetic.georgian.gershwinesque.ghostly.giant.gibsonian.giddy.gifted.giga.giggly.gilded.giottesque.glacial.glad.glazed.gleaming.gleeful.glimmering.glistening.glorious.glossy.glowing.gnomish.godardian.godelian.goethean.goethesque.gogolian.golden.gooey.goofy.gorgeous.gorsy.gossamer.gothic.gowned.goyaesque.graceful.gracious.grainy.grand.grassy.grated.gravitic.gregarious.grilled.groovy.ground.grounded.guileless.gushy.gusty.habermasian.habsburg.hadrianic.halcyon.hale.hallowed.haloed.halved.hamiltonian.han.handelian.handmade.handsome.hanoverian.hapless.happy.hardy.hardyesque.harmonious.hashed.haunted.haydnesque.hayekian.hazy.heady.heaneyesque.hearthside.hearty.heathen.heathered.heavenly.hegelian.heideggerian.heinesque.heinleinian.heirloom.heisenbergian.heliacal.hellenic.hellish.hemingwayesque.herbal.herbertian.herculean.hermetic.heroic.hexed.hibernal.hilbertian.histrionic.hitchcockian.hittite.hoar.hoary.hobbesian.hobbitish.hogarthian.holderlinian.holo.holographic.holy.homerian.homeric.homeward.honest.honeyed.honky.hooded.hooved.hopeful.hopkinsian.hopperesque.hoppy.horatian.horned.hospitable.hot.housemade.huggy.humble.humean.humming.humorous.hunky.hunnish.hurrian.hushed.hydraulic.hyper.hyperborean.hypersonic.hyperspatial.hypnotic.iberian.ibsenite.iced.icy.ideal.idyllic.igneous.illustrious.imaginative.immaculate.immense.immortal.impassioned.impeccable.impetuous.impish.impressive.incan.incandescent.incisive.incorrigible.indefatigable.indelible.indigo.indolent.indomitable.industrious.ineffable.inexorable.infernal.infinite.infra.infrared.infused.ingenious.ingenuous.inimitable.innocuous.inquisitive.insatiable.inspired.intense.intergalactic.interstellar.intragalactic.intrepid.intricate.intrinsic.intuitive.inventive.inveterate.invincible.inward.ionian.ionic.ionospheric.irenic.iridescent.irrepressible.ithacan.itinerant.ivory.jacobean.jammy.jangly.jaunty.jazzy.jeffersonian.jiggly.jingly.jocular.jocund.johnsonian.jolly.jouncy.jovial.jovian.joycean.joyful.joyous.jubilant.judicious.juiced.juicy.jumped.jumpy.jungian.junky.justinianic.jute.kafkaesque.kandinskian.kantian.keatonesque.keatsian.keen.keplerian.keynesian.kierkegaardian.kindly.kindred.kinetic.kiplingesque.klimtian.knowing.kooky.kubrickian.kurosawan.lacanian.laconic.lacquered.lacustrine.lacy.lamarckian.lambda.lambent.laminated.landed.languid.lanky.laplacian.larkinesque.laser.latent.lathed.latin.lattice.laudable.launched.laureled.lavish.layered.leaden.leafy.lean.learned.legendary.leguinian.leibnizian.lemian.lemurian.lenient.leonardesque.liberal.libyan.lidar.light.lighthearted.likable.lilac.lilting.liminal.limpid.lincolnesque.lingering.linnaean.lissome.lisztian.literate.lithe.littoral.lively.loamy.local.lockean.lofty.logical.loopy.loose.loquacious.lorcaesque.lorcan.lossless.lossy.lovecraftian.lovelacean.loyal.lucent.lucid.lucky.ludic.lukewarm.luminal.luminous.lunar.luscious.lush.lushy.lusitanian.lustrous.lydian.lynchian.lyotardian.lyric.lyrical.macerated.machiavellian.macro.magical.magnanimous.magnetar.magnetic.magnetospheric.magnificent.magrittean.mahlerian.majestic.mallarmean.malleable.malthusian.malty.mandelan.manetesque.manifold.marbled.marshy.martial.martian.marvelous.marxian.maser.masked.masterful.matchless.matin.matissean.mature.matutinal.mauve.maverick.mawkish.maxwellian.mayan.meandering.mechanical.median.medicean.mega.mellifluous.mellow.melodic.mendelian.merciful.mercurial.merovingian.merry.meshed.meta.metamorphic.meteoric.meticulous.metternichian.mettlesome.michelangelesque.micro.microwave.midnight.mighty.mild.milled.miltonian.miltonic.minced.mindful.mineral.ming.mingusian.minoan.minty.miraculous.mired.miroesque.mirthful.mischievous.misty.mobile.modest.modular.molecular.molieresque.momentous.mondrianesque.monetian.monkish.mono.montane.moonless.moonlit.mordant.morning.mossy.motley.mottled.mouthwatering.mozartian.mughal.multiversal.munificent.murmuring.mushy.musical.mutable.mutant.mycenaean.mysterious.mystical.mythic.nabokovian.nameless.nano.nanoscale.napoleonic.narrowband.nascent.natty.neat.nebular.nebulous.nefarious.neptunian.nerudian.networked.neural.neutron.neutronic.newtonian.nietzschean.nifty.nimble.noble.nocturnal.nonchalant.nonpareil.noontide.norse.northward.nostalgic.notable.novel.nozickian.nuanced.nubian.nuclear.numinous.nutty.oaky.obdurate.oblique.observant.obstinate.obtuse.oceanic.ochre.odyssean.olden.olympian.omega.omni.onward.opaline.opportune.optical.optimistic.opulent.oracular.orbital.orbiting.orderly.original.ornate.orphic.orwellian.osirian.ostentatious.otherworldly.otiose.ottoman.outgoing.outspoken.outward.overcast.overclocked.ovidian.pacific.pagan.painstaking.palatial.pale.pallid.palpable.paradisal.paradoxical.parallel.paramount.parkerish.parsonian.parthian.passionate.pastoral.patched.pathless.patient.pavlovian.peaceable.peaceful.peachy.pearly.peaty.pebbly.peeled.peered.peerless.pelagic.pellucid.penetrating.pensive.peppered.peppery.peppy.perceptive.perennial.perfect.perfumed.perky.persian.persistent.perspicacious.persuasive.pert.pervasive.pessoan.petaled.petrarchan.phantom.pharaonic.phased.philosophical.phlegmatic.phoenician.photonic.photospheric.phrygian.picassoesque.pickled.pictish.picturesque.pillowy.pindaric.pinteresque.piping.piquant.pirandellian.pithy.pivotal.pixelated.placid.planckian.planetary.planetoid.plangent.plasmic.plathian.platinum.platonic.playful.pleasant.plentiful.pliant.plinky.plonky.plucky.plumed.plummy.plush.plushy.plutonian.plutonic.pneumatic.poached.poesque.poetic.poignant.poised.polished.polite.pollockian.poly.polygonal.polymer.polynesian.popean.popped.popular.portly.posh.positronic.posthuman.potent.pouncy.powdery.powerful.pragmatic.prancy.precise.precocious.precognitive.preeminent.premier.prescient.pressed.pressurized.prestigious.pretty.primeval.primordial.princely.printed.pristine.private.prized.prodigious.profane.proficient.profound.profuse.prokofievian.prolific.promethean.prompt.proper.prophetic.prosaic.prosperous.protean.proto.protostellar.proud.proustian.providential.prudent.psionic.puccinian.puckish.pudgy.puffed.pulled.pulsar.punctilious.punctual.pungent.punic.pure.purposeful.pushkinian.pynchonesque.pythagorean.quaint.quantum.quartered.quasar.questing.quick.quiescent.quiet.quintessential.quirky.quixotic.rabelaisian.racinian.radar.radiant.radio.rainwashed.rainy.rakish.rambunctious.raphaelesque.rapid.rapturous.rare.rational.ravelian.rawlsian.raytraced.ready.reasonable.rebooted.receptive.recondite.recursive.redolent.reduced.reedy.refined.reflective.refulgent.regal.relativistic.relaxed.reliable.remarkable.rembrandtesque.remote.rendered.renoiresque.renowned.replete.replicated.resilient.resinous.resolute.resourceful.respectful.resplendent.responsive.restful.restive.restless.reticent.retro.reverent.rhapsodic.rhodian.rhythmic.ricardian.rich.richelieuvian.riemannian.rigorous.rilkean.rimbaudian.rimed.ringed.ripe.ripening.rippling.risible.riverine.riveted.roaming.roaring.roasted.robed.robotic.robust.rolled.roly.roman.romanov.romantic.rompy.rooseveltian.roseate.rosy.rothkoesque.rousing.rousseauian.rowdy.royal.rubenesque.ruddy.runic.rushy.russet.rustic.sabine.sable.sacred.sagacious.sage.saintly.salient.saline.salingeresque.salted.salty.salubrious.samian.sandaled.sandy.sanguine.sapid.sapient.sapphic.sardonic.sarmatian.sartrean.sassy.satiny.saturnian.saturnine.saucy.savory.savvy.saxon.scalding.scarlet.schielesque.schillerian.schoenbergian.scholarly.schubertian.schumannesque.schumpeterian.scintillating.scorched.scorsesean.scrappy.scruffy.scrupulous.scythian.seaborne.seamless.seared.seasonal.seaward.secure.sedate.sedgy.sedimentary.sedulous.seemly.seismic.selenic.selfless.sensible.sensitive.sentient.sentimental.seraphic.sere.serene.seuratian.shaded.shadowed.shadowy.shaggy.shaken.shakespearean.shamanic.shannonian.sharded.sharp.shaved.shavian.shelleyan.shielded.shimmering.shiny.shoreless.shostakovian.shrewd.shucked.sibelian.sibilant.sibylline.sicilian.sidereal.sienna.sifted.sigma.silicon.silken.silky.silly.silty.silver.silvered.simmering.simulated.sincere.singed.singing.singular.sinuous.sisyphean.sizzling.skeptical.skillful.skinnerian.skittish.skyward.sleek.sleepless.sleepy.slender.sliced.slick.slipstreamed.slow.sly.smart.smashy.smithian.smoked.smoky.smoldering.smooth.snappy.snazzy.snoozy.snowy.snug.snuggly.soaring.sociable.socratic.sodden.soft.sogdian.solar.solarpunk.solemn.solid.somnolent.sonar.song.sonic.sonorous.sooty.soporific.soulful.sound.soundless.sour.southward.sovereign.spaceborne.spacefaring.spacious.sparkling.sparkly.spartan.special.speckled.spectacular.spectral.speedy.spellbound.spiced.spicy.spielbergian.spiffy.spinozan.spirited.splashy.splendid.split.sploshy.spontaneous.spooky.sporty.spotless.spotted.sprightly.sproingy.spry.spun.spunky.squally.squashy.squelchy.squiggly.squishy.staid.stainless.stalwart.starborn.starfaring.starless.starlit.stasisbound.stately.steadfast.steady.steaming.steampunk.steely.steeped.steinbeckian.stellar.stellarborn.sticky.stirred.stirring.stoic.stoical.stolid.stompy.stoppardian.storied.stormy.stout.strained.stratospheric.straussian.stravinskian.streaky.stretched.striking.strindbergian.striped.strong.stuart.stubby.studious.stunning.sturdy.stygian.suave.subatomic.sublime.suborbital.subsonic.substantial.subtle.succinct.succulent.sudsy.sugared.sugary.sumerian.summery.sunless.sunlit.sunny.sunward.superb.supergalactic.superlative.superluminal.supersonic.supple.supreme.sure.surreptitious.svelte.swanky.sweeping.sweet.swift.swiftian.swirled.swooshy.sylvan.sympathetic.synaptic.synchronous.synthetic.syrupy.tableside.tachyonic.taciturn.talented.talleyrandian.tame.tang.tangy.tarantinoesque.tarkovskian.tart.tasteful.tattered.taut.tawny.tectonic.telekinetic.telepathic.temperate.tempered.temporal.tenacious.tender.tennysonian.tenuous.tepid.tera.terran.terrific.terse.textured.thackerayan.thankful.thawed.theban.thessalian.theta.thorny.thorough.thoughtful.thracian.threadbare.thriving.thundery.tidal.tidy.timeless.timely.timeworn.tinkly.tiny.tipsy.tireless.titanesque.titanian.titanic.titanium.titianesque.toasted.toasty.tocharian.tokenized.tolerant.tolkienesque.tolstoyan.tonic.tonky.toothsome.torched.totemic.tough.towering.trackless.tranquil.transcendent.transhuman.treacly.treasured.tremendous.tremulous.trenchant.tricky.trim.triumphant.trojan.trollopian.truculent.true.truffautian.truffled.trusty.truthful.tudor.turbo.turingian.turneresque.twangy.twilight.twilit.twinkling.twinkly.ubiquitous.ultra.ultrasonic.ultraviolet.umami.umber.unassuming.unbounded.uncanny.uncorked.unctuous.undaunted.underworldly.undocked.undying.unearthly.unerring.unflappable.unique.unknown.unruffled.upbeat.upgraded.upright.upstanding.upward.uranian.urbane.utopian.vacuous.valeryan.valiant.valorous.vandal.vangoghian.vast.veblenian.vectorized.vedic.vehement.veiled.velazquezian.velvet.velvety.venerable.venturous.venusian.veracious.verbose.verdant.verdian.verdurous.verlainian.vermeerian.vermilion.vernal.verneian.versatile.vesper.vespertine.vibrant.victorian.vigilant.vigorous.vintage.violet.virgilian.virtual.virtuous.visceral.vital.vivacious.vivid.vocal.voidborn.voidward.volcanic.voltairean.voluble.vonnegutian.voracious.voxel.vroomy.wacky.wagnerian.wakeful.waking.wan.wandering.warholian.warm.warped.wary.washingtonian.wayward.wealthy.weathered.weberian.welcome.welded.wellesian.wellsian.westward.whacky.whimsical.whimsy.whipped.whisked.whispering.whistlerian.whitmanesque.whole.wholesome.whooshy.wide.wiggly.wild.wildean.willowy.wilsonian.wily.windswept.windy.winged.winning.winsome.wintry.wired.wireframe.wireless.wise.wishful.wispy.wistful.wittgensteinian.witty.wobbly.wodehousian.wondrous.wonky.wooded.woody.woolly.woozy.wordless.wordsworthian.wormholed.worthy.wraithlike.wreathed.wriggly.wry.xenial.xeno.yanky.yearning.yeasty.yeatsian.young.youthful.yuletide.yummy.zany.zappy.zealous.zested.zestful.zesty.zeta.zingy.zippy.zodiacal.zonked.zonky.zoomy.zoroastrian`.split(`.`),wr=`abalone.absinthe.absyrtus.accelerator.achilles.acorn.acquerello.actuator.adobo.adonis.aeetes.aegis.aello.aeneas.aengus.aether.affogato.afterburner.agartha.agate.agni.agnolotti.aioli.airlock.ajax.aji.albatross.alder.ale.alecto.aleppo.alfheim.allegory.alliteration.almond.amaranth.amaretto.amaterasu.ambrosia.americano.amphiaraus.anago.anapest.ancho.anchovy.android.andromeda.anise.annal.annwn.ansible.antaeus.antenna.anthem.antigone.antimony.antistrophe.anubis.aoidos.aperol.aphelion.aphrodite.apogee.apollo.apple.apricot.aquamarine.aquavit.aqueduct.arabica.arachne.arawn.arbor.arborio.arc.arcadia.arch.archipelago.ares.argo.argon.argonaut.aria.ariadne.ark.arke.armagnac.array.arrow.artemis.arthur.artichoke.artifact.arugula.asgard.asgardia.ash.asparagus.aspen.assam.assonance.asteroid.astronaut.atalanta.athena.atlantis.atlas.atoll.atom.atropos.aubergine.augean.aura.aurora.avalon.avalonia.avocado.awning.axion.axle.azurite.bacchus.bagna.baharat.balder.ballad.balladeer.banana.banshee.baozi.bard.barge.barium.barley.barn.basalt.basil.basilisk.basmati.bastet.bastion.bay.bayleaf.beacon.beam.bean.bearing.beech.beetroot.behemoth.bellini.beowulf.bergamot.berth.beryl.beryllium.bifrost.biodome.birch.biscotti.bismuth.bisque.bit.bittern.blackberry.blast.blaster.blini.block.blodeuwedd.bloodstone.blossom.bluebell.blueberry.bolt.bomba.bonito.boom.borage.boson.botargo.bottarga.bouillon.boundary.bow.bower.bragi.bramble.bran.branch.brandy.branwen.breeze.brew.bridge.brigid.brioche.broccoli.brook.brulee.brunhild.brush.bucatini.buckler.buckwheat.buffer.bulkhead.bunting.burrata.burst.bus.busiris.butte.butter.buttercup.butterscotch.byte.cabbage.cabin.cacao.cachaca.cache.cacus.cadence.caesura.calamarata.calamari.calcite.caldera.calliope.calvados.calypso.cam.camellia.camelot.camembert.campari.canal.cannelloni.cannoli.canopy.cantaloupe.cantata.canticle.canvas.canyon.canzone.capacitor.capellini.caper.capon.cappelletti.cappuccino.capsule.caramel.cardamom.cardoon.carillon.carnaroli.carnation.carol.carrier.carrot.cascade.cashew.cassandra.cassis.castle.castor.cavatelli.caviar.cayenne.cedar.celaeno.celeriac.cell.centaur.cerberi.cerberus.cernunnos.ceryneian.cesium.ceto.ceylon.chaff.chaffinch.chai.chain.chalk.chamomile.champagne.chandra.channel.chanson.chanterelle.chard.charon.chartreuse.cheddar.cherry.chert.chervil.chestnut.chickweed.chicory.chili.chime.chimera.chimichurri.chimney.chip.chipotle.chirashi.chiron.chive.chocolate.chorale.chorizo.chorus.chronicle.chrysanthemum.chrysaor.chrysomallus.chutney.ciabatta.cibola.cider.cilantro.cinder.cinnamon.cipher.circe.circlet.circuit.cirque.cistern.citadel.citrine.citron.clementine.cliff.clio.clipper.cloak.clotho.cloud.clove.clover.cluster.coal.cobbler.cockaigne.cockpit.cocoa.coconut.codex.coffee.cog.cognac.coif.coil.col.colchis.collider.colony.combe.comet.compote.concerto.conchiglie.conduit.confit.console.consomme.consonance.continuum.contour.cookies.coordinate.core.coriander.cormorant.corona.coronet.cortado.corvette.cosmos.cottage.couplet.course.couscous.cove.cowl.cowslip.crab.craft.crag.cranberry.crane.crayon.cream.creme.crepe.cress.crocus.croissant.crosne.crown.cruiser.crumble.cryopod.cryosleep.crystal.cuchulainn.cuckoo.cucumber.cuirass.cumin.cupid.curlew.currant.current.curry.custard.cyborg.cycle.cyclops.cyclotron.cylinder.dactyl.daedalus.daemon.daffodil.dagda.dahlia.daiquiri.dais.daisy.dale.dam.dandelion.danu.daphne.darjeeling.dart.dashi.date.dawn.daydream.deck.deirdre.demeter.destroyer.dew.diadem.diary.dill.dimension.diode.diomedean.dionysus.ditalini.ditch.djinn.dock.doenjang.domain.donburi.donjon.door.doppio.dove.downlink.dreadnought.dream.drift.droid.dryad.dukkah.dulce.dumpling.dune.durga.dusk.dust.dyke.eagle.earlgrey.easel.echidna.echo.eclair.eclipse.ecliptic.edamame.eddy.edelweiss.edge.egret.einsteinium.elderflower.eldorado.electra.elegy.elm.elysium.ember.endive.enigma.enjambment.enkidu.envoi.eos.epigram.epistle.epode.erato.erinyes.eros.erymanthian.escargot.espresso.estuary.eumenides.euryale.eurybia.eurydice.eurytion.excalibur.exoplanet.fable.fafnir.falcon.fancy.farfalle.fate.feather.feldspar.fell.fence.fennel.fenrir.fenugreek.fermion.fern.fettuccine.fiddlehead.field.fig.finch.finn.fionn.firebird.firefly.fission.fizz.fjord.flake.flame.flare.flash.flicker.flint.flue.fluorite.flux.flywheel.focaccia.fog.folio.fondant.forge.fortress.foxglove.fragment.fraise.frame.frangipane.frappe.freesia.fregola.freighter.freya.frigate.frigg.frost.fudge.fugue.fumarole.furies.fusilli.fusion.gaia.galahad.galangal.galatea.galaxy.galette.galleon.gallium.ganache.ganesh.gannet.gantry.ganymede.garam.gardenia.garlic.garuda.gateway.gauntlet.gawain.gazebo.gear.gelato.gemelli.genmaicha.genoise.geranium.germ.germanium.geryon.geyser.ghazal.ghee.ghost.gilgamesh.ginger.gingko.ginnungagap.girder.glacier.glade.glaze.gleam.gleeman.glen.glimmer.glint.glitter.gloss.glow.gluon.gnocchi.gochujang.goldfinch.golem.goose.gooseberry.gorgon.gouda.governor.gradient.graeae.granary.granite.grapefruit.grappa.gratin.graviton.greave.grebe.gremolata.grenadine.grendel.grid.griffin.gruyere.guajillo.guava.gudrun.guinevere.gunkan.gwydion.gyoza.gyroscope.habanero.habitat.hades.hadron.haiku.hall.halloumi.halo.halva.hamachi.hangar.hanuman.harissa.harpies.harpy.harvest.hatch.hauberk.hawthorn.haze.hazel.hazelnut.heading.headland.heap.heart.hearth.heather.hecate.hedge.heimdall.hel.helheim.helios.helium.helix.helle.hellebore.helm.hemistich.hephaestus.hera.hermes.heron.hesperides.hestia.hibiscus.hippogriff.hirame.hive.hoisin.hojicha.hollandaise.hollow.holly.hologram.honey.honeycomb.honeysuckle.hood.hoopoe.horizon.horseradish.horus.hrothgar.hub.huckleberry.hue.huginn.hull.husk.hut.hyacinth.hydra.hydras.hylas.hymn.hyperborea.hypercube.hyperdrive.hyperion.hyperspace.hyssop.iamb.ibis.icarus.idas.idunn.idyll.igniter.igraine.ikura.indium.indra.inductor.infusion.injector.ink.inlet.inspiration.ion.iridium.iris.ishtar.isis.isolde.isotope.ivy.iwashi.izanagi.jackdaw.jackfruit.jalapeno.janus.jasmine.jason.jasper.javelin.jay.jet.jiaozi.jongleur.jonquil.jormungandr.jotunheim.journal.julep.jumpgate.juniper.juno.jupiter.kaffir.kale.kali.kampachi.karaage.karasumi.katsu.keel.keep.kefir.kelpie.kenning.kernel.kestrel.khinkali.kiln.kimchi.kingfisher.kinmedai.kirsch.kite.kitsune.kiwi.koan.kohlrabi.kombucha.koshihikari.kraken.krypton.kumquat.kvass.lachesis.lacquer.ladon.ladons.laertes.lager.lagoon.lake.lakshmi.lambic.lament.lance.lancelot.lander.lane.langoustine.lantern.lapis.lark.larkspur.lasagna.latte.laureate.laurel.lava.lavender.leaf.leda.leek.legend.lemon.lemonbalm.lemongrass.lemuria.lens.lentil.lepton.lernaean.lethe.letter.levee.lever.leviathan.lightyear.lily.lime.limerick.limoncello.linden.linguine.link.linnet.lir.lithium.lityerses.lobster.loch.lock.lodge.loki.loop.loquat.lotus.lovage.lugh.lullaby.lungo.luster.lychee.lynceus.lyonesse.lyricist.macadamia.macaron.macchiato.madai.madeleine.madrigal.magma.magnolia.magpie.mail.mainframe.maki.makrut.malachite.manannan.mango.manicotti.manor.manti.manticore.mantle.mantou.manuscript.maple.marble.marduk.margarita.marigold.marjoram.marquee.marrow.martini.marvel.marzipan.masago.masala.mascarpone.mast.matcha.matrix.mead.meadow.mech.medea.medusa.megaera.meleager.memoir.mentaiko.mercury.meringue.merlin.merlot.mesa.mesh.metaphor.meteor.meter.mezcal.mezzaluna.mica.midas.midgard.mill.mimir.mimosa.minerva.minotaur.minstrel.mint.minuet.miracle.mirin.mirror.miso.missive.mist.mjolnir.mocha.module.moira.mojito.molasses.mole.momo.monolith.moonbase.moonbeam.moonstone.moor.mopsus.mordred.morel.morgana.morpheus.morrigan.moss.mote.motet.mousse.mu.mulberry.muninn.muon.muse.muspelheim.mustard.myrtle.mystery.myth.nadir.naga.naiad.nanite.nanobot.narcissus.neapolitan.nebula.nectarine.needle.negroni.nemean.nemesis.neon.neptune.neptunium.nereid.nereus.nessus.nest.nestor.net.nettle.neutrino.nexus.niamh.nib.nibble.nibiru.niflheim.nightingale.nigiri.nike.niobe.njord.nocturne.node.nog.nori.norn.note.nougat.nova.nozzle.nuada.nutmeg.nyx.oak.oasis.oat.obelisk.oberon.obsidian.oceanid.oceanus.octave.octavo.ocypete.ode.odin.odysseus.oisin.okonomiyaki.olive.olympus.oni.onigiri.oolong.oracle.orange.orb.orbit.orbiter.orchard.orchid.oreads.orecchiette.oregano.orion.orpheus.orthros.orthrus.orzo.oscillator.osiris.osmium.osprey.ouroboros.outline.outpost.ouzo.oven.overture.owl.oyster.paccheri.packet.padron.page.palace.palette.palladium.palm.pan.pandan.pandora.panettone.pansotti.pansy.pantoum.papaya.pappardelle.paprika.papyrus.parable.paradox.parcae.parchment.parfait.parmesan.parsec.parsley.parsnip.particle.partridge.parvati.pasilla.passionfruit.pastel.pastis.patina.pavilion.pavlova.peach.peak.pear.pebble.pecan.pegasi.pegasus.pekoe.peleus.pelican.pelmeni.pen.pencil.penelope.penne.peony.pepper.peppermint.percival.peregrine.pergola.peridot.perigee.perihelion.perry.persephone.perseus.persillade.persimmon.pesto.petal.petrel.phase.pheasant.phoenix.pholus.phorcys.photon.phrixus.pickle.pierogi.pigment.pimento.pine.pineapple.ping.pinot.pipe.pipit.piquillo.pisco.pistachio.piston.pith.plane.plasma.plate.plover.plum.plume.pluto.plutonium.poblano.pod.podarge.poet.polenta.pollux.polyphemus.pomegranate.pomelo.pond.pontus.ponzu.pooka.pool.poplar.poppy.porcini.port.portal.porter.porthole.poseidon.positron.prairie.praline.prelude.primrose.prism.probe.profile.prometheus.prosciutto.prosecco.proteus.protocol.psalm.psyche.pudding.puffin.pulse.pumice.pumpkin.purslane.pwyll.pylon.pyrrhic.quadrant.quail.quark.quarto.quartz.quatrain.qubit.quetzalcoatl.queue.quill.quince.quinoa.quiver.radish.radium.radon.ragnarok.rain.rama.ramen.ramp.rampart.ramson.raspberry.ratatoskr.raven.ravioli.ray.reactor.realm.reaper.reed.reef.refrain.region.register.relay.relic.remnant.requiem.reservoir.residue.resistor.resonator.reverie.rhapsode.rhapsody.rhea.rhiannon.rhodium.rhododendron.rhubarb.rhyme.ricotta.riddle.ridge.riesling.rigatoni.rim.ring.risotto.ristretto.river.roast.robin.robusta.roc.rocket.rod.romesco.rondeau.rooibos.rook.root.rose.rosemary.rosewater.roundel.rover.rowan.rubidium.rum.rune.saba.saffron.saga.saison.sake.salmoriglio.salsa.salsify.sambal.sambuca.samphire.sancerre.sandpiper.sangria.sanma.sansho.saraswati.sashimi.sasquatch.satellite.satyr.sauternes.savanna.sawara.sazerac.scaffold.scalar.scallop.scansion.scepter.schnapps.schooner.scop.scorzonera.scotchbonnet.scroll.sector.seed.sekhmet.selene.selenite.selenium.selkie.sencha.sensor.sequoia.serenade.serrano.servo.sesame.sestina.sextet.shack.shade.shadow.shaft.shale.shallot.shambhala.shard.shed.sheen.sherbet.sherry.shield.shimmer.ship.shishito.shiso.shiva.shoyu.shrub.shumai.shuttle.sibyl.sif.signal.sigurd.silhouette.silo.simile.simurgh.singularity.siren.sita.skadi.skald.skiff.skuld.skylark.slant.slate.sleipnir.sling.slipstream.sliver.sloop.sluice.smithy.smoke.snowdrop.socket.sofrito.sonata.sonnet.soot.sorbet.sorrel.souffle.soul.soy.spaceport.spaghetti.spark.sparkle.sparrow.spear.speck.specter.speculoos.spelt.sphere.sphinx.sphinxes.spindle.spinel.spiral.spire.spirit.splinter.spoke.spondee.spore.spring.spritz.spruce.sriracha.ssamjang.stack.stanza.starbase.starlight.starling.starport.starship.stasis.station.steam.stellarator.steppe.stheno.stork.stracciatella.strawberry.stream.strontium.strophe.strozzapreti.strut.stylus.stymphalian.styx.subspace.sumac.summit.sunbeam.sunstone.supernova.surge.surya.susanoo.sushi.svartalfheim.swallow.swan.swarm.sycamore.syleus.synchrotron.tabard.tachyon.tagliatelle.tahini.takoyaki.taliesin.tamari.tamarind.tangerine.tanka.tanker.tapenade.tapioca.tarako.taranis.tare.tarn.tarragon.tartarus.telamon.telemetry.teleporter.tellurium.temaki.tempura.tengu.tensor.tent.tequila.tercet.teriyaki.terminal.tern.terraform.tesseract.tethys.thalassa.thalia.thallium.thaumas.themis.theseus.thistle.thor.thorium.thoth.threshold.throne.throttle.thrush.thruster.thule.thunderbird.thyme.tiamat.tiara.tide.tint.tintagel.tiphys.tiramisu.tirnanog.tisane.tisiphone.titan.tobiko.toccata.toddy.toffee.tofu.tokamak.tomatillo.tomato.tome.tone.tonka.tonkatsu.tor.tortellini.torus.tourmaline.tower.trace.track.transducer.transistor.treacle.trellis.triolet.tristan.triton.trochee.trofie.trope.troubadour.trouvere.truffle.trunk.truss.tug.tulip.tundra.tungsten.turbine.turmeric.turquoise.turret.twinkle.typhon.tyr.udon.ulysses.unagi.uni.unicorn.uplink.uramaki.urania.uranium.urd.urfa.uther.vale.valhalla.valkyrie.valve.vanadium.vanaheim.vanilla.vapor.vareniki.varnish.varuna.vector.veil.vellum.vent.venus.verbena.verdandi.verge.verjus.vermouth.verse.vessel.vesta.vestige.vialone.viewport.villanelle.vishnu.vodka.volcano.volta.volume.vortex.vulcan.wall.walnut.waltz.warbler.warpgate.wasabi.wash.watercress.watermelon.wave.waypoint.web.weir.well.wendigo.wheat.whisky.whisper.wiglaf.willow.wimple.window.wisteria.wonder.wonton.woodcock.woodpecker.word.wormhole.wraith.wren.wyrm.wyvern.xenon.yacht.yakitori.yama.yarrow.yeti.yew.yggdrasil.yokai.yuzu.zaatar.zabaglione.zenith.zephyr.zeus.zinnia.zircon.zirconium.ziti.zone.zucchini`.split(`.`);Cr.length*wr.length;var Tr=[`off`,`minimal`,`low`,`medium`,`high`,`xhigh`];function Er(e){return typeof e==`string`&&Tr.includes(e)}d(`agent-bridge`);var Dr=`agent: name already in use`,Or=d(`cone-memory-budget`),kr=4e3,Ar=2e3,jr=1.25,Mr=I.memoryPath,Nr=`/sessions/index.json`,Pr=4096,Fr=/^## Auto-extracted/m,Ir=`Consolidate the auto-extracted memory bullets below into a single tighter set of durable memories.
|
|
370
|
-
|
|
371
|
-
Rules:
|
|
372
|
-
- Output ONLY a single \`## Auto-extracted (consolidated)\` heading followed by markdown bullets.
|
|
373
|
-
- One fact per bullet. Drop duplicates and superseded facts. Keep the most recent / specific phrasing.
|
|
374
|
-
- Preserve concrete identifiers (file paths, URLs, IDs, names) verbatim.
|
|
375
|
-
- Be terse. Aim well under the original size.
|
|
376
|
-
- Do NOT add preamble, commentary, or any heading other than the single consolidated one.`;function Lr(e){return Math.round(kr+Ar*Math.log2((Number.isFinite(e)&&e>=0?e:0)+2))}function Rr(e){let t=Fr.exec(e);if(!t)return{header:e,autoExtracted:``};let n=t.index;return{header:e.slice(0,n),autoExtracted:e.slice(n)}}async function zr(e){try{let t=await e.readFile(Nr,{encoding:`utf-8`}),n=typeof t==`string`?t:new TextDecoder().decode(t),r=JSON.parse(n);return Array.isArray(r)?r.length:0}catch{return 0}}async function Br(e){let{header:t,autoExtracted:n}=Rr(e.currentContent);if(!n.trim())return e.currentContent;let r=`You are a memory consolidation assistant. You are given a markdown file's "auto-extracted" section — a list of memory bullets accumulated across sessions of an AI coding assistant. Your job is to rewrite that section as a tighter, deduplicated set of durable memories that fits well within ${e.budget} characters.
|
|
377
|
-
|
|
378
|
-
<auto-extracted>
|
|
379
|
-
${n}
|
|
380
|
-
</auto-extracted>`,i={role:`user`,content:[{type:`text`,text:Ir}],timestamp:Date.now()},a=await u(e.model,{systemPrompt:r,messages:[i]},{apiKey:e.apiKey,maxTokens:Pr,headers:e.headers,signal:e.signal});if(a.stopReason===`error`)throw Error(`Restructure call failed: ${a.errorMessage||`Unknown error`}`);let o=a.content.filter(e=>e.type===`text`).map(e=>e.text).join(`
|
|
381
|
-
`).trim();if(!o)throw Error(`Restructure call returned empty content`);return`${t}${t.length===0||t.endsWith(`
|
|
382
|
-
`)?``:`
|
|
383
|
-
`}${o}\n`}async function Vr(e){if(!e.model||!e.apiKey)return{restructured:!1,reason:`no-llm`};let t=e.memoryPath??Mr,n=``;try{let r=await e.vfs.readFile(t,{encoding:`utf-8`});n=typeof r==`string`?r:new TextDecoder().decode(r)}catch{return{restructured:!1,reason:`missing-file`}}let r=await zr(e.vfs),i=Lr(r),a=i*jr;if(n.length<=a)return{restructured:!1,reason:`under-threshold`};Or.info(`Cone memory over threshold — restructuring`,{size:n.length,budget:i,threshold:a,sessionCount:r});try{let r=await Br({currentContent:n,budget:i,model:e.model,apiKey:e.apiKey,headers:e.headers,signal:e.signal});return await e.vfs.writeFile(t,r),Or.info(`Cone memory restructured`,{before:n.length,after:r.length}),{restructured:!0}}catch(e){return Or.warn(`Cone memory restructure failed — leaving appended content in place`,{error:e instanceof Error?e.message:String(e)}),{restructured:!1,reason:`error`}}}var Hr=d(`agentic-memory`),Ur=`/shared/MEMORY.md`,Wr=1200,Gr=e=>[e.memoryPath],Kr=e=>[`/sessions/`,`/shared/`,...xr(e)],qr=`awk.cat.cp.cut.date.diff.du.echo.file.find.grep.head.jq.ls.mkdir.mount.mv.nl.od.printf.readlink.sed.sort.stat.tail.touch.tr.uniq.upskill.wc.xxd`.split(`.`),Jr=new Set([`writablePaths`,`visiblePaths`,`allowedCommands`]),Yr=new Set([`model`,`timeoutSeconds`,`thinkingLevel`]),Xr=`medium`,Zr=3e4;function Qr(e){return e===`cone`?`memory-curator`:`memory-curator-${e}`}function $r(e){let t=Qr(e);return ei.test(t)?t:Qr(gt)}var ei=/^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/;function ti(e){return`/scoops/agent-${$r(e)}`}var ni=ti(gt);function ri(e){return _r({parentJid:null,folder:e?.folder??`cone`})}function ii(e,t){if(t.root===I.root)return e;if(e===I.memoryPath)return t.memoryPath;if(e===`/workspace/skills`||e.startsWith(`/workspace/skills/`))return e;let n=`${I.root}/`;return e===I.root?t.root:e.startsWith(n)?`${t.root}/${e.slice(n.length)}`:e}function ai(e,t){let n=`${gr}/`,r=e=>e.some(e=>n.startsWith(e.endsWith(`/`)?e:`${e}/`)),i=e.map(e=>ii(e,t));return r(e)&&!r(i)&&i.push(n),i}async function oi(e){try{if(e.signal?.aborted)return{ok:!1,reason:`aborted`,legacyFallbackSafe:!1};let t=ri(e.cone),n=ti(e.cone?.folder??`cone`),r=await si(e.vfs,t),i=xi(e.sessionArchivePath);try{await Ci(e.vfs,t.memoryPath,e.sessionArchivePath)}catch(e){return{ok:!1,reason:`snapshot: ${R(e)}`,legacyFallbackSafe:!0}}let a=Ti(r,Ei(Di(r.promptTemplate,{MEMORY_PATH:i,SESSION_ARCHIVE_PATH:e.sessionArchivePath,SESSION_COUNT:String(e.sessionCount),BUDGET_CHARS:String(Lr(e.sessionCount)),SCRATCH_DIR:n,TODAY:e.today??new Date().toISOString().slice(0,10)}),n),e.sessionArchivePath,t,e.cone);e.signal&&(a.signal=e.signal);let o=await Oi(Promise.resolve().then(()=>e.spawn(a)),r.timeoutSeconds*1e3+Zr,e.signal);if(o.type===`timeout`)return Hr.warn(`Agentic memory wait timed out past the in-run bound + grace`,{timeoutSeconds:r.timeoutSeconds,graceMs:Zr}),{ok:!1,reason:`timeout`,legacyFallbackSafe:!1};if(o.type===`aborted`)return{ok:!1,reason:`aborted`,legacyFallbackSafe:!1};if(o.type===`error`)return{ok:!1,reason:R(o.error),legacyFallbackSafe:!0};if(o.result.exitCode!==0){let e=(o.result.finalText??``).startsWith(Dr);return{ok:!1,reason:o.result.finalText||`exit-${o.result.exitCode}`,legacyFallbackSafe:!e}}return{ok:!0,report:o.result.finalText}}catch(e){return Hr.warn(`Agentic memory pass failed`,{error:R(e)}),{ok:!1,reason:R(e),legacyFallbackSafe:!1}}}async function si(e,t=I){try{let n=await e.readFile(Ur,{encoding:`utf-8`});return ci(typeof n==`string`?n:new TextDecoder().decode(n),t)}catch(e){return Hr.warn(`Could not load valid MEMORY.md; using built-in default`,{error:R(e)}),ci(mr,t)}}function ci(e,t=I){let n=e.replace(/^\uFEFF/,``).replace(/\r\n?/g,`
|
|
384
|
-
`).match(/^---\s*\n([\s\S]*?)\n---\s*\n([\s\S]*)$/);if(!n?.[2].trim())throw Error(`MEMORY.md requires frontmatter and a prompt`);let r=ui(n[1]),i=hi(r,`writablePaths`,Gr(t));if(i.length===0)throw Error(`writablePaths must not be empty`);vi(i,`writablePaths`);let a=hi(r,`visiblePaths`,Kr(t));vi(a,`visiblePaths`);let o=_i(r.timeoutSeconds),s=gi(r.model,`model`);return{writablePaths:i.map(e=>ii(e,t)),visiblePaths:ai(a,t),allowedCommands:[...new Set([...qr,...hi(r,`allowedCommands`,[])])],...s?{model:s}:{},thinkingLevel:li(r.thinkingLevel),timeoutSeconds:o,promptTemplate:n[2].trim()}}function li(e){if(e===void 0)return Xr;if(typeof e!=`string`||!Er(e))throw Error(`thinkingLevel must be one of ${Tr.join(`, `)}`);return e}function ui(e){let t={},n=e.split(`
|
|
385
|
-
`);for(let e=0;e<n.length;e+=1){let r=n[e];if(!r.trim()||r.trimStart().startsWith(`#`))continue;let i=r.match(/^([A-Za-z][A-Za-z0-9]*):\s*(.*)$/);if(!i)throw Error(`Invalid frontmatter line: ${r}`);let[,a,o]=i;if(Jr.has(a)){let r=di(n,e,o);t[a]=r.value,e=r.lastIndex}else if(Yr.has(a)&&o.trim())t[a]=mi(o);else throw Error(`Unsupported or empty frontmatter field: ${a}`)}return t}function di(e,t,n){if(n.trim()){let e=n.trim();if(!e.startsWith(`[`)||!e.endsWith(`]`))throw Error(`Expected an array`);let r=e.slice(1,-1).trim();return{value:r?fi(r):[],lastIndex:t}}let r=[],i=t;for(let n=t+1;n<e.length;n+=1){let t=e[n].match(/^\s+-\s+(.+)$/);if(!t)break;r.push(mi(pi(t[1]))),i=n}return{value:r,lastIndex:i}}function fi(e){let t=[],n=0,r;for(let i=0;i<e.length;i+=1){let a=e[i];a===`"`||a===`'`?r=r===a?void 0:r??a:a===`,`&&!r&&(t.push(mi(e.slice(n,i))),n=i+1)}if(r)throw Error(`Unclosed quoted value`);return t.push(mi(e.slice(n))),t}function pi(e){let t;for(let n=0;n<e.length;n+=1){let r=e[n];if(r===`"`||r===`'`)t=t===r?void 0:t??r;else if(r===`#`&&!t&&(n===0||/\s/.test(e[n-1])))return e.slice(0,n).trimEnd()}return e}function mi(e){let t=e.trim();if(!t)throw Error(`Empty frontmatter value`);let n=t[0];if((n===`"`||n===`'`)&&t.at(-1)===n)return t.slice(1,-1);if(n===`"`||n===`'`)throw Error(`Unclosed quoted value`);return t}function hi(e,t,n){let r=e[t];if(r===void 0)return[...n];if(!Array.isArray(r)||r.some(e=>!e))throw Error(`${t} is invalid`);return[...r]}function gi(e,t){if(e!==void 0){if(typeof e!=`string`||!e)throw Error(`${t} is invalid`);return e}}function _i(e){if(e===void 0)return 600;if(typeof e!=`string`)throw Error(`timeoutSeconds is invalid`);let t=Number(e);if(!Number.isFinite(t)||t<=0)throw Error(`timeoutSeconds must be positive`);return Math.min(t,Wr)}function vi(e,t){if(e.some(e=>!e.startsWith(`/`)||e.includes(`\0`)||t===`writablePaths`&&e===`/`))throw Error(`${t} must contain absolute VFS paths`)}function yi(e){return`/sessions/.curated/${e.slice(e.lastIndexOf(`/`)+1)}`}function L(e){return`/sessions/.curation/${e.slice(e.lastIndexOf(`/`)+1)}`}function bi(e){return`${L(e)}/base.md`}function xi(e){return`${L(e)}/draft.md`}function Si(e){return`${L(e)}/status.json`}async function Ci(e,t,n){let r=``;try{let n=await e.readFile(t,{encoding:`utf-8`});r=typeof n==`string`?n:new TextDecoder().decode(n)}catch{}await e.mkdir(L(n),{recursive:!0}),await e.writeFile(bi(n),r),await e.writeFile(xi(n),r)}function wi(e,t,n){let r=e.map(e=>e===t?n:e);return r.includes(n)?r:[...r,n]}function Ti(e,t,n,r,i){let a=e.model===`parent`||e.model===`cone`,o=bi(n),s=xi(n);return{cwd:r.root,writablePaths:wi(e.writablePaths,r.memoryPath,s),visiblePaths:[...e.visiblePaths,`${L(n)}/`],allowedCommands:e.allowedCommands,prompt:t,thinkingLevel:e.thinkingLevel,persistSession:!0,name:$r(i?.folder??`cone`),...i?.jid?{parentJid:i.jid}:{},notifyOnComplete:!0,successReceiptPath:yi(n),mergeOnSuccess:{targetPath:r.memoryPath,basePath:o,draftPath:s},outcomeReceiptPath:Si(n),maxWallClockMs:e.timeoutSeconds*1e3,...!a&&e.model?{modelId:e.model}:{}}}function Ei(e,t){return t===ni?e:e.replaceAll(ni,t)}function Di(e,t){let n=e;for(let[e,r]of Object.entries(t))n=n.replaceAll(`{{${e}}}`,r);return n}function Oi(e,t,n){return new Promise(r=>{let i=!1,a=e=>{i||(i=!0,clearTimeout(s),n?.removeEventListener(`abort`,o),r(e))},o=()=>a({type:`aborted`}),s=setTimeout(()=>a({type:`timeout`}),t);n?.addEventListener(`abort`,o,{once:!0}),e.then(e=>a({type:`result`,result:e}),e=>a({type:`error`,error:e}))})}function R(e){return e instanceof Error?e.message:String(e)}var z=`/sessions`,B=`/sessions/index.json`;async function V(e){try{let t=await e.readFile(B,{encoding:`utf-8`}),n=typeof t==`string`?t:new TextDecoder().decode(t),r=JSON.parse(n);return Array.isArray(r)?r:[]}catch{return[]}}function H(e){return`${z}/${e.filename}`}function ki(e){let t=e,n=`Untitled`,r={},i=t.match(/^---\n([\s\S]*?)\n---\n+/);if(i){t=t.slice(i[0].length),Object.assign(r,Ai(i[1]));let e=i[1].match(/^title:\s*(.+?)\s*$/m);e&&(n=ji(e[1]))}let a=t.match(/<!-- slicc:session-data\n([\s\S]*?)\n-->\n*/);if(a){try{let e=a[1].replace(/-- >/g,`-->`),t=JSON.parse(e);if(Array.isArray(t))return{title:n,messages:t,...r}}catch{}t=t.replace(/<!-- slicc:session-data\n[\s\S]*?\n-->\n*/,``)}return t=t.replace(/^#\s+[^\n]*\n+/,``),{title:n,messages:Ni(t),...r}}function Ai(e){let t={},n=Mi(e,`cost`),r=Mi(e,`models`);n&&(t.cost=n),r&&(t.models=r);let i=e.match(/^cone:\s*(.+?)\s*$/m)?.[1];i&&(t.cone=i);let a=e.match(/^coneLabel:\s*(.+?)\s*$/m)?.[1];a&&(t.coneLabel=ji(a)),/^memorySkipped:\s*true\s*$/m.test(e)&&(t.memorySkipped=!0),/^live:\s*true\s*$/m.test(e)&&(t.live=!0);let o=Number(e.match(/^liveThrough:\s*(\d+)\s*$/m)?.[1]);Number.isFinite(o)&&o>0&&(t.liveThrough=o);let s=Number(e.match(/^compactions:\s*(\d+)\s*$/m)?.[1]);Number.isFinite(s)&&s>0&&(t.compactions=s);let c=e.match(/^id:\s*(\S+)\s*$/m)?.[1];return c&&(t.id=c),t}function ji(e){let t=e.trim();if(!t.startsWith(`"`))return t;try{let e=JSON.parse(t);if(typeof e==`string`)return e}catch{}return t.replace(/^"|"$/g,``)}function Mi(e,t){let n=RegExp(`^${t}:\\s*(.+?)\\s*$`,`m`).exec(e)?.[1];if(n)try{return JSON.parse(n)}catch{return}}function Ni(e){let t=[],n=/^## (User|Assistant)\s*\n/gm,r=[],i;for(;(i=n.exec(e))!==null;)r.push({role:i[1]===`User`?`user`:`assistant`,start:i.index,bodyStart:i.index+i[0].length});for(let n=0;n<r.length;n++){let i=n+1<r.length?r[n+1].start:e.length,a=e.slice(r[n].bodyStart,i).trim();t.push({id:`frozen-${n}`,role:r[n].role,content:a,timestamp:0})}return t}function Pi(e){let t=``;for(let n of e){let e=n.role===`user`?`User`:`Assistant`,r=n.role===`user`?m(n.content):n.content;if(t+=`## ${e}\n${r}\n\n`,n.attachments?.length&&(t+=`Attachments:\n${n.attachments.map(e=>`- ${h(e)}`).join(`
|
|
386
|
-
`)}\n\n`),n.toolCalls)for(let e of n.toolCalls)t+=`### Tool: ${e.name}\nInput: ${JSON.stringify(e.input,null,2)}\nResult: ${e.result??``}\n\n`}return t}var Fi=`<!-- slicc:session-data
|
|
387
|
-
`,Ii=`
|
|
388
|
-
-->`;function Li(e){return e.startsWith(`pending-`)||e.startsWith(`live-`)}function Ri(e,t){return e.find(e=>e.live===!0&&(e.cone??`cone`)===t)}function zi(){return`${Date.now().toString(36)}-${Math.random().toString(36).slice(2,6)}`}function Bi(e){return C(e,{maxLen:48,fallback:`session`})}function Vi(e){let t=e.find(e=>e.role===`user`);if(!t?.content)return`untitled-session`;let n=t.content.trim().replace(/\s+/g,` `);return n.length>60?`${n.slice(0,60)}…`:n||`untitled-session`}function Hi(e){return e.map(e=>{let t={id:e.id,role:e.role,content:e.content,timestamp:e.timestamp};return e.attachments?.length&&(t.attachments=e.attachments),e.toolCalls?.length&&(t.toolCalls=e.toolCalls.map(e=>({id:e.id,name:e.name,input:e.input,...e.result===void 0?{}:{result:e.result},...e.isError?{isError:e.isError}:{}}))),e.source&&(t.source=e.source),e.channel&&(t.channel=e.channel),t})}function Ui(e){let t=(e.cost?`cost: ${JSON.stringify(e.cost)}\n`:``)+(e.models?`models: ${JSON.stringify(e.models)}\n`:``),n=(e.cone?`cone: ${e.cone}\n`:``)+(e.coneLabel?`coneLabel: ${JSON.stringify(e.coneLabel)}\n`:``)+(e.memorySkipped?`memorySkipped: true
|
|
389
|
-
`:``)+(e.live?`live: true
|
|
390
|
-
`:``)+(e.live&&e.liveThrough?`liveThrough: ${e.liveThrough}\n`:``)+(e.live&&e.compactions?`compactions: ${e.compactions}\n`:``),r=`---\nid: ${e.id}\ntitle: ${JSON.stringify(e.title)}\nfrozenAt: ${e.frozenAt}\ncreatedAt: ${e.createdAt}\nupdatedAt: ${e.updatedAt}\nmessageCount: ${e.messageCount}\n`+t+n+`---
|
|
391
|
-
|
|
392
|
-
`,i=`${Fi}${JSON.stringify(Hi(e.messages)).replace(/-->/g,`-- >`)}${Ii}\n\n`,a=`# ${e.title}\n\n`;return r+i+a+Pi(e.messages)}async function Wi(e){try{let t=await e.readFile(B,{encoding:`utf-8`}),n=typeof t==`string`?t:new TextDecoder().decode(t),r=JSON.parse(n);return Array.isArray(r)?r:[]}catch(e){if(e instanceof T&&e.code!==`ENOENT`)throw e;return[]}}var Gi=`slicc:sessions-index`,Ki=Promise.resolve();function U(e){let t=()=>{let t=globalThis.navigator?.locks;return typeof t?.request==`function`?t.request(Gi,()=>e()):e()},n=Ki.then(t,t);return Ki=n.then(()=>void 0,()=>void 0),n}function qi(e,t){return e.writeFile(B,JSON.stringify(t,null,2))}async function Ji(e,t){await qi(e,[t,...(await Wi(e)).filter(e=>e.filename!==t.filename)])}function Yi(e,t){return U(()=>Ji(e,t))}var Xi=e({PENDING_SESSION_ATTEMPT_LIMIT:()=>3,SESSIONS_INDEX_PATH:()=>B,curateFrozenSessionMemories:()=>na,enrichPendingSession:()=>Oa,freezeConeSession:()=>ta,listPendingEnrichments:()=>Ta,markSnapshotUnavailable:()=>Ga,processPendingSessions:()=>Ea,readSessionsIndex:()=>V}),W=d(`session-freezer`),Zi=4,Qi=2048,$i=40,ea=`${z}/attachments`;async function ta(e){let t=await ya(e.sessionStore,_a(e));if(!t||t.messages.length<Zi)return W.info(`Skipping freeze: session below threshold or missing`,{messageCount:t?.messages.length??0}),null;let n=xa(t.messages),r=e.mode??`full`,i=r===`full`&&!!(e.apiKey&&e.model);!e.agenticMemorySpawn&&e.memory!==`skip`&&await aa(e,n,i);let a=await oa(e,n,i)||Vi(t.messages);return await sa(e,t,a,r,i?await ra(e,a):void 0,!!e.agenticMemorySpawn&&e.memory!==`skip`)}async function na(e,t){let n=xa(t.archive.messages),r;try{r=await oi({spawn:e.agenticMemorySpawn,vfs:e.vfs,sessionArchivePath:H(t),sessionCount:await zr(e.vfs),...e.cone?{cone:e.cone}:{}})}catch(e){r={ok:!1,reason:e instanceof Error?e.message:String(e),legacyFallbackSafe:!1}}if(r.ok){let n=await Ba(e.vfs,t.filename);return await ja(e.vfs,t.filename),n?(delete t.memoryPending,W.info(`Agentic memory pass completed`,{filename:t.filename}),n):(W.info(`Agentic memory pass completed; index entry already gone`,{filename:t.filename}),null)}return await Ha(e.vfs,t.filename,r.reason),r.legacyFallbackSafe?(W.warn(`Agentic memory pass failed after finishing — falling back to legacy extraction`,{filename:t.filename,reason:r.reason}),await aa(e,n,!0),null):(W.warn(`Agentic memory pass unfinished — entry stays pending for boot catch-up`,{filename:t.filename,reason:r.reason,attemptLimit:3}),null)}async function ra(e,t){try{return ia(await(e.pickIcon??(await l(async()=>{let{pickLucideIcon:e}=await import(`./quick-llm-DDPHThwA.js`).then(e=>e.n);return{pickLucideIcon:e}},__vite__mapDeps([11,8,12,13,14,15,16,17,18,19,20,1,21,22,23,24,3,25,26,27,28,29,30,31,32,33,34]))).pickLucideIcon)({subject:`"${t}" — an archived chat session`})??void 0)}catch(e){W.warn(`Icon pick failed (freeze still proceeds)`,{error:e instanceof Error?e.message:String(e)});return}}function ia(e){if(e)return $e(e)?e:void 0}async function aa(e,t,n){if(!n){W.info(`LLM unavailable — skipping memory extraction; freezing anyway`);return}let r=``;try{r=await o({messages:t,instruction:i,model:e.model,apiKey:e.apiKey,maxTokens:Qi,headers:e.headers})}catch(e){W.warn(`Memory extraction call failed (freeze still proceeds)`,{error:e instanceof Error?e.message:String(e)});return}if(!r.trim()||r.trim()===`NONE`){W.info(`Memory extraction returned no durable memories`);return}try{await wa(e.vfs,va(_a(e)),r.trim(),`new-session`,{model:e.model,apiKey:e.apiKey,headers:e.headers}),W.info(`Memory extracted and appended on new-session`)}catch(e){W.warn(`Memory append failed`,{error:e instanceof Error?e.message:String(e)})}}async function oa(e,t,n){if(!n)return``;try{return Sa(await o({messages:t,instruction:s,model:e.model,apiKey:e.apiKey,maxTokens:$i,headers:e.headers}))}catch(e){return W.warn(`Title generation call failed (using heuristic)`,{error:e instanceof Error?e.message:String(e)}),``}}async function sa(e,t,n,r,i,a=!1){let o=new Date().toISOString(),s=_a(e),c=await ba(e.vfs,s),l=c?.sessionId??crypto.randomUUID(),u=c?.filename??(r===`quick`?`pending-${zi()}.md`:`${o.replace(/[:.]/g,`-`)}-${Bi(n)}.md`),d=ca(t.messages),f={cone:s,...s!==`cone`&&e.cone?.label?{coneLabel:e.cone.label}:{}},p={filename:u,sessionId:l,title:n,frozenAt:o,messageCount:t.messages.length,...d??{},...f,...i?{icon:i}:{},...r===`quick`||c?{pendingEnrichment:!0}:{},...a?{memoryPending:!0}:{},...e.memory===`skip`?{memorySkipped:!0}:{}};try{await Ca(e.vfs,z);let r=await da(e.vfs,t.messages,u.replace(/\.md$/,``)),i={id:t.id,title:n,frozenAt:o,createdAt:t.createdAt,updatedAt:t.updatedAt,messageCount:t.messages.length,messages:r,...d??{},...f,...e.memory===`skip`?{memorySkipped:!0}:{}},a=Ui(i);return await e.vfs.writeFile(`${z}/${u}`,a),await Yi(e.vfs,p),await e.vfs.flush(),W.info(`Cone session frozen`,{filename:u,title:n,cone:s,messageCount:t.messages.length,completedLiveSnapshot:!!c}),{...p,archive:i}}catch(e){return W.warn(`Failed to write frozen session to VFS`,{error:e instanceof Error?e.message:String(e)}),null}}function ca(e){let t={total:0,input:0,output:0,cacheRead:0,cacheWrite:0},n=new Map,r=!1;for(let i of e){if(i.role!==`assistant`)continue;let{model:e,usage:a}=i;if(!e||!a||!ua(a))return null;let o=a.cost;r=!0,t.total+=o.total,t.input+=o.input,t.output+=o.output,t.cacheRead+=o.cacheRead,t.cacheWrite+=o.cacheWrite;let s=n.get(e)??{model:e,cost:0,turns:0,tokens:0};s.cost+=o.total,s.turns+=1,s.tokens+=a.input+a.output+a.cacheRead+a.cacheWrite,n.set(e,s)}return r?{cost:t,models:[...n.values()].sort((e,t)=>t.cost-e.cost)}:null}function la(e){return typeof e==`number`&&Number.isFinite(e)}function ua(e){let{cost:t}=e;return[e.input,e.output,e.cacheRead,e.cacheWrite].every(la)&&[t.input,t.output,t.cacheRead,t.cacheWrite,t.total].every(la)}async function da(e,t,n){let r={vfs:e,archiveDir:`${ea}/${n}`,copiedPaths:new Map,fileIndex:0},i=[];for(let e of t){if(!e.attachments?.some(ma)){i.push(e);continue}let t=[];for(let n of e.attachments)t.push(await fa(r,n));i.push({...e,attachments:t})}return i}async function fa(e,t){if(!ma(t))return t;let n=e.copiedPaths.get(t.path);if(n)return{...t,path:n};let r=await pa(e.vfs,t.path);if(!r)return ga(t);let i=t.name.replace(/[^A-Za-z0-9._-]+/g,`_`)||`attachment`,a=`${e.archiveDir}/${e.fileIndex++}-${i}`;return await Ca(e.vfs,e.archiveDir),await e.vfs.writeFile(a,r),e.copiedPaths.set(t.path,a),{...t,path:a}}async function pa(e,t){try{if(!await ha(e,t))return null;let n=await e.readFile(t,{encoding:`binary`});if(!(n instanceof Uint8Array))throw Error(`Expected binary attachment content at ${t}`);return n}catch{return null}}function ma(e){return typeof e.path==`string`&&e.path.startsWith(`/tmp/`)&&e.data===void 0&&e.text===void 0}async function ha(e,t){let n=t.split(`/`).slice(1);if(n.length<2||n[0]!==`tmp`||n.some(e=>!e||e===`.`||e===`..`))return!1;let r=`/`;for(let t=0;t<n.length;t+=1){let i=(await e.readDir(r)).find(e=>e.name===n[t]);if(!i)return!1;if(t===n.length-1)return i.type===`file`;if(i.type!==`directory`)return!1;r=r===`/`?`/${n[t]}`:`${r}/${n[t]}`}return!1}function ga(e){let{path:t,...n}=e;return{...n,error:e.error??`Archived attachment file is missing or unsafe to preserve.`}}function _a(e){return e.cone?.folder||`cone`}function va(e){return _r({parentJid:null,folder:e}).memoryPath}async function ya(e,t){let n=dt({folder:t});try{return await e.load(n)}catch(e){return W.warn(`Failed to load cone chat session`,{sessionId:n,error:e instanceof Error?e.message:String(e)}),null}}async function ba(e,t){try{return Ri(await Wi(e),t)}catch(e){W.warn(`Sessions index unreadable while looking for a live snapshot`,{error:e instanceof Error?e.message:String(e)});return}}function xa(e){return e.map(e=>({role:e.role,content:[{type:`text`,text:e.content}],timestamp:e.timestamp}))}function Sa(e){let t=e.trim();return t=t.replace(/^["'`]+|["'`]+$/g,``).trim(),t=t.replace(/\s+/g,` `),t.length>80&&(t=t.slice(0,80).trimEnd()),t}async function Ca(e,t){try{await e.mkdir(t,{recursive:!0})}catch{}}async function wa(e,t,n,r,i){let a=t,o=``;try{let t=await e.readFile(a,{encoding:`utf-8`});o=typeof t==`string`?t:new TextDecoder().decode(t)}catch(t){if(!(t instanceof T)||t.code!==`ENOENT`)throw t;await Ca(e,a.slice(0,a.lastIndexOf(`/`)))}let s=`## Auto-extracted (${new Date().toISOString().slice(0,10)}, ${r})`,c=`${o.length===0||o.endsWith(`
|
|
393
|
-
`)?``:`
|
|
394
|
-
`}\n${s}\n\n${n}\n`;await e.writeFile(a,o+c);try{await Vr({vfs:e,memoryPath:a,model:i?.model,apiKey:i?.apiKey,headers:i?.headers,signal:i?.signal})}catch(e){W.warn(`Cone memory budget step threw (append already committed)`,{error:e instanceof Error?e.message:String(e)})}}async function Ta(e){return(await V(e)).filter(e=>(e.pendingEnrichment===!0||e.memoryPending===!0)&&Da(e)<3)}async function Ea(e){let t={attempted:0,completed:0};if(!e.model||!e.apiKey)return t;try{for(let t of await V(e.vfs))t.memoryPending===!0&&t.memoryFailed===void 0&&Da(t)>=3&&await Ha(e.vfs,t.filename,`catch-up retries exhausted (3)`);let n=await Ta(e.vfs);for(let r of n)try{let n=await Va(e.vfs,r.filename);if(!n)continue;t.attempted+=1,await Oa(e.vfs,n,{model:e.model,apiKey:e.apiKey,headers:e.headers})&&(t.completed+=1)}catch(e){W.warn(`Pending session catch-up attempt failed`,{filename:r.filename,error:e instanceof Error?e.message:String(e)})}}catch(e){W.warn(`Pending session catch-up failed`,{error:e instanceof Error?e.message:String(e)})}return t}function Da(e){let t=e.pendingAttemptCount;return typeof t==`number`&&Number.isInteger(t)&&t>0?t:0}async function Oa(e,t,n){if(!t.pendingEnrichment&&!t.memoryPending)return null;let r=await Na(e,t);if(r===null)return null;let i=Pa(t,r);if(i===null)return null;let a=t.memoryPending===!0&&n.skipMemory!==!0&&await Aa(e,t),o=a||t.memorySkipped===!0?{...n,skipMemory:!0}:n,s=await Fa(t,i,o);if(s===null)return null;let c=await Ma(o,s.newTitle);await Ia(e,t,s.bullets,o);let l=await Ra(e,t,r,s.newTitle,c,n.skipMemory===!0);return l&&a&&(await ja(e,t.filename),await Ua(e,l.filename),await ka(e,t.filename)),l}async function ka(e,t){for(let n of[bi(`/sessions/${t}`),xi(`/sessions/${t}`)])try{await e.rm(n)}catch{}}async function Aa(e,t){try{return await e.stat(yi(`/sessions/${t.filename}`)),!0}catch{return!1}}async function ja(e,t){try{await e.rm(yi(`/sessions/${t}`))}catch{}}async function Ma(e,t){if(e.pickIcon)try{return await ia(await e.pickIcon({subject:`"${t}" — an archived chat session`})??void 0)}catch(e){W.warn(`Enrichment icon pick failed (continuing without icon)`,{error:e instanceof Error?e.message:String(e)});return}}async function Na(e,t){try{let n=await e.readFile(H(t),{encoding:`utf-8`});return typeof n==`string`?n:new TextDecoder().decode(n)}catch(e){return e?.code===`ENOENT`?W.info(`Pending archive missing — treating as already enriched`,{filename:t.filename}):W.warn(`Failed to read pending archive (entry stays pending)`,{filename:t.filename,error:e instanceof Error?e.message:String(e)}),null}}function Pa(e,t){let n;try{n=ki(t).messages}catch(t){return W.warn(`Failed to parse pending archive — leaving entry intact`,{filename:e.filename,error:t instanceof Error?t.message:String(t)}),null}return n.length===0?(W.info(`Pending archive has no messages — skipping enrichment`,{filename:e.filename}),null):xa(n)}async function Fa(e,t,n){let r=``;if(!n.skipMemory)try{r=await o({messages:t,instruction:i,model:n.model,apiKey:n.apiKey,maxTokens:Qi,headers:n.headers})}catch(t){return W.warn(`Enrichment memory call failed (entry stays pending)`,{filename:e.filename,error:t instanceof Error?t.message:String(t)}),null}let a=``;try{a=Sa(await o({messages:t,instruction:s,model:n.model,apiKey:n.apiKey,maxTokens:$i,headers:n.headers}))}catch(t){return W.warn(`Enrichment title call failed (entry stays pending)`,{filename:e.filename,error:t instanceof Error?t.message:String(t)}),null}return a?{bullets:r,newTitle:a}:(W.info(`Enrichment title call returned empty — entry stays pending`,{filename:e.filename}),null)}async function Ia(e,t,n,r){let i=n.trim();if(!(!i||i===`NONE`))try{await wa(e,va(t.cone||`cone`),i,`pending-enrichment`,{model:r.model,apiKey:r.apiKey,headers:r.headers})}catch(e){W.warn(`Enrichment memory append failed (continuing with title rewrite)`,{filename:t.filename,error:e instanceof Error?e.message:String(e)})}}function La(e,t,n,r,i){let a=r??e.icon;return{filename:t,title:n,frozenAt:e.frozenAt,messageCount:e.messageCount,...e.cost?{cost:e.cost}:{},...e.models?{models:e.models}:{},...e.cone?{cone:e.cone}:{},...e.coneLabel?{coneLabel:e.coneLabel}:{},...e.sessionId?{sessionId:e.sessionId}:{},...a?{icon:a}:{},...e.completeSnapshotUnavailable?{completeSnapshotUnavailable:!0}:{},...i&&e.memoryPending?{memoryPending:!0}:{},...e.memorySkipped?{memorySkipped:!0}:{}}}async function Ra(e,t,n,r,i,a=!1){let o=H(t),s=Li(t.filename),c=s?r:t.title,l=s?`${t.frozenAt.replace(/[:.]/g,`-`)}-${Bi(r)}.md`:t.filename,u=`${z}/${l}`;if(s)try{await Ca(e,z),await e.writeFile(u,za(n,c))}catch(e){return W.warn(`Enrichment write failed (entry stays pending)`,{filename:t.filename,error:e instanceof Error?e.message:String(e)}),null}let d=La(t,l,c,i,a);try{await Wa(e,t.filename,d)}catch(e){return W.warn(`Enrichment index update failed (entry may stay pending)`,{filename:t.filename,error:e instanceof Error?e.message:String(e)}),null}if(u!==o)try{await e.rm(o)}catch(e){W.info(`Stale pending archive cleanup failed (harmless)`,{oldPath:o,error:e instanceof Error?e.message:String(e)})}try{await e.flush()}catch{}return W.info(`Pending session enriched`,{oldFilename:t.filename,newFilename:l,title:c}),d}function za(e,t){let n=e.match(/^---\n([\s\S]*?)\n---\n([\s\S]*)$/);if(!n)return e;let r=n[1].replace(/^title:\s*.+$/m,`title: ${JSON.stringify(t)}`),i=n[2];return i=i.replace(/^#\s+[^\n]*$/m,`# ${t}`),`---\n${r}\n---\n${i}`}async function Ba(e,t){let n=null,r=U(async()=>{let r=await V(e),i=r.findIndex(e=>e.filename===t);if(i===-1)return;let{memoryPending:a,pendingEnrichment:o,pendingAttemptCount:s,memoryFailed:c,...l}=r[i],u={...l,memoryCuratedAt:new Date().toISOString()},d=r.slice();d[i]=u,await e.writeFile(B,JSON.stringify(d,null,2)),await e.flush(),n=u});try{await r}catch(e){W.warn(`Failed to clear agentic memory pending marker`,{filename:t,error:e instanceof Error?e.message:String(e)})}return n}async function Va(e,t){let n=null;return await U(async()=>{let r=await V(e),i=r.findIndex(e=>e.filename===t);if(i===-1)return;let a=r[i];if(!a.pendingEnrichment&&!a.memoryPending)return;let o=Da(a);if(o>=3)return;n={...a,pendingAttemptCount:o+1};let s=r.slice();s[i]=n,await e.writeFile(B,JSON.stringify(s,null,2)),await e.flush()}),n}async function Ha(e,t,n){let r=U(async()=>{let r=await V(e),i=r.findIndex(e=>e.filename===t);if(i===-1)return;let a=r.slice();a[i]={...r[i],memoryFailed:n.slice(0,300)},await e.writeFile(B,JSON.stringify(a,null,2)),await e.flush()});try{await r}catch(e){W.warn(`Failed to record curator failure in sessions index`,{filename:t,error:e instanceof Error?e.message:String(e)})}}async function Ua(e,t){let n=U(async()=>{let n=await V(e),r=n.findIndex(e=>e.filename===t);if(r===-1)return;let{memoryFailed:i,...a}=n[r],o=n.slice();o[r]={...a,memoryCuratedAt:new Date().toISOString()},await e.writeFile(B,JSON.stringify(o,null,2)),await e.flush()});try{await n}catch(e){W.warn(`Failed to record curator completion in sessions index`,{filename:t,error:e instanceof Error?e.message:String(e)})}}async function Wa(e,t,n){return U(async()=>{let r=[];try{let t=await e.readFile(B,{encoding:`utf-8`}),n=typeof t==`string`?t:new TextDecoder().decode(t),i=JSON.parse(n);Array.isArray(i)&&(r=i)}catch(e){if(!(e instanceof T)||e.code!==`ENOENT`)throw e}let i=r.findIndex(e=>e.filename===t),a;i===-1?a=[n,...r.filter(e=>e.filename!==n.filename)]:(a=r.slice(),a[i]=n,a=a.filter((e,t)=>t===i||e.filename!==n.filename)),await e.writeFile(B,JSON.stringify(a,null,2))})}async function Ga(e,t){return U(async()=>{let n=[];try{let t=await e.readFile(B,{encoding:`utf-8`}),r=typeof t==`string`?t:new TextDecoder().decode(t),i=JSON.parse(r);Array.isArray(i)&&(n=i)}catch(e){if(!(e instanceof T)||e.code!==`ENOENT`)throw e;return}if(!n.find(e=>e.filename===t))return;let r=n.map(e=>e.filename===t?{...e,completeSnapshotUnavailable:!0}:e);await e.writeFile(B,JSON.stringify(r,null,2))})}var Ka=`slicc:followers-changed`;function qa(e){let t=e.replace(/^follower-/,``);return t.length>12?`${t.slice(0,8)}…`:t}function Ja(e){return e.floatType===`ios`?`iOS`:e.floatType===`electron`?`Electron`:e.floatType===`extension`?`Extension`:e.floatType===`standalone`?`Standalone`:e.runtime?.includes(`cli`)?`CLI`:`Follower`}function Ya(e){return e.floatType===`ios`?`smartphone`:e.floatType===`electron`||e.floatType===`standalone`?`monitor`:e.floatType===`extension`?`blocks`:e.runtime?.includes(`cli`)?`terminal`:`radio`}function Xa(e,t=Date.now()){if(!e)return null;let n=new Date(e).getTime();if(!Number.isFinite(n))return null;let r=Math.max(0,Math.floor((t-n)/1e3));return r<60?`${r}s`:r<3600?`${Math.floor(r/60)}m`:r<86400?`${Math.floor(r/3600)}h`:`${Math.floor(r/86400)}d`}function Za(e){return e.health===`stalled`?`warn`:e.peerState===`connecting`?`idle`:e.peerState===`connected`&&e.health===`live`?`active`:`idle`}function Qa(e,t=Date.now()){let n=e.health===`stalled`?`stalled`:e.peerState===`connecting`?`connecting`:`connected`,r=Xa(e.connectedAt,t);return r?`${n} ${r}`:n}function $a(e){let t=[];return e.exec&&t.push(`can run commands`),e.cdp&&t.push(`hosts tabs`),t}function eo(e){return`${Ja(e)} · ${qa(e.runtimeId)}`}function to(e){return e.motd??e.runtime??void 0}function no(e,t=Date.now()){return e.map(e=>({id:e.runtimeId,icon:Ya(e),title:eo(e),detail:to(e),state:Za(e),stateText:Qa(e,t),chips:$a(e)}))}var ro=`__slicc_binary__`,io=`b64`;function ao(e){if(!e||typeof e!=`object`)return!1;let t=e;return t[ro]===io&&typeof t.data==`string`}function oo(e){return typeof e==`object`&&!!e&&!Array.isArray(e)&&!(e instanceof Uint8Array)}function so(e){return typeof e==`object`&&!!e&&!Array.isArray(e)&&!(e instanceof Uint8Array)&&!ao(e)}function co(e){if(e instanceof Uint8Array)return{[ro]:io,data:v(e)};if(Array.isArray(e))return e.map(co);if(oo(e)){let t={};for(let[n,r]of Object.entries(e))t[n]=co(r);return t}return e}function lo(e){if(ao(e))return y(e.data);if(Array.isArray(e))return e.map(lo);if(so(e)){let t={};for(let[n,r]of Object.entries(e))t[n]=lo(r);return t}return e}var uo=d(`panel-transport`);function fo(e){return typeof e==`object`&&!!e&&`source`in e&&`payload`in e}function po(){return{onMessage:e=>{let t=(t,n,r)=>(fo(t)&&e(lo(t)),!1);return chrome.runtime.onMessage.addListener(t),()=>chrome.runtime.onMessage.removeListener(t)},send:(e,t)=>{let n=co(e);chrome.runtime.sendMessage({source:`panel`,payload:n}).catch(e=>{uo.error(`failed to send to offscreen`,{error:e instanceof Error?e.message:String(e)})})}}}var mo=2e3,G=d(`offscreen-client`),ho={summarizing:`summarizing`,fallback:`fallback`,cancelled:`discarded`,idle:`summarized`},go=class{eventListeners=new Set;callbacks;scoops=[];scoopStatuses=new Map;currentMessageId=new Map;compactionNoticeIds=new Map;compactionSettledRows=new Map;toolDepth=new Map;ready=!1;stateRetryTimer=null;localFs=null;pendingClearAcks=new Map;pendingWebhookDeliveries=new Map;pendingAgentSpawnRequests=new Map;pendingThinkingAcks=new Map;pendingModelAcks=new Map;pendingTranscriptRequests=new Map;pendingChatMessagesRequests=new Map;pendingStatsRequests=new Map;pendingSudoRequests=new Map;transport;_selectedScoopJid=null;get selectedScoopJid(){return this._selectedScoopJid}scoopSelectedListeners=new Set;onScoopSelected(e){return this.scoopSelectedListeners.add(e),()=>{this.scoopSelectedListeners.delete(e)}}setSelectedScoopJid(e){if(this._selectedScoopJid!==e&&(this._selectedScoopJid=e,e!==null))for(let t of this.scoopSelectedListeners)try{t(e)}catch(e){G.error(`onScoopSelected handler threw`,{error:e instanceof Error?e.message:String(e)})}}locked=!1;constructor(e,t){this.callbacks=e,this.transport=t??po(),this.setupMessageListener()}setLocalFS(e){this.localFs=e}getTransport(){return this.transport}emitAgentError(e){this.emitToUI({type:`error`,error:e})}createAgentHandle(){return{sendMessage:(e,t,n,r)=>{if(!this.selectedScoopJid){this.emitToUI({type:`error`,error:`No scoop selected`});return}this.send({type:`user-message`,scoopJid:this.selectedScoopJid,text:e,attachments:n,messageId:t??`msg-${Date.now()}-${Math.random().toString(36).slice(2,8)}`,...r?.steer?{steer:!0}:{},...r?.guestGate?{guestGate:r.guestGate}:{}})},onEvent:e=>(this.eventListeners.add(e),()=>this.eventListeners.delete(e)),stop:()=>{this.selectedScoopJid&&this.send({type:`abort`,scoopJid:this.selectedScoopJid})}}}getScoops(){return this.scoops}getScoop(e){return this.scoops.find(t=>t.jid===e)}isProcessing(e){return this.scoopStatuses.get(e)===`processing`}async registerScoop(e,t={}){if(!D(e))throw Error(`OffscreenClient.registerScoop is cone-only; use scoop_scoop for non-cone scoops`);this.scoops.find(t=>t.name===e.name)||(this.scoops.push(e),this.scoopStatuses.set(e.jid,`initializing`)),this.send({type:`cone-create`,name:e.name,...t.description?{description:t.description}:{},...t.prompt?{prompt:t.prompt}:{},...e.model?{model:e.model}:{}})}async unregisterScoop(e){let t=this.scoops.find(t=>t.jid===e);if(t&&D(t)&&E(this.scoops).length<=1)throw Error(`Cannot remove the last cone`);this.send({type:`scoop-drop`,scoopJid:e}),this.scoops=this.scoops.filter(t=>t.jid!==e),this.scoopStatuses.delete(e)}createScoopTab(e){}async getGlobalMemory(){if(!this.localFs)return``;try{let e=await this.localFs.readFile(`/shared/CLAUDE.md`,{encoding:`utf-8`});return typeof e==`string`?e:new TextDecoder().decode(e)}catch{return``}}getScoopContext(e){if(this.localFs)return{getFS:()=>this.localFs}}getSharedFS(){return this.localFs}stopScoop(e){this.send({type:`abort`,scoopJid:e})}async clearQueuedMessages(e){}async deleteQueuedMessage(e,t){this.send({type:`delete-queued-message`,scoopJid:e,messageId:t})}updateModel(){this.send({type:`refresh-model`})}setScoopModel(e,t){let n=`model-${K()}`,r=new Promise(e=>{this.pendingModelAcks.set(n,e)});return this.send({type:`set-scoop-model`,requestId:n,scoopJid:e,model:t}),Promise.race([r,new Promise(e=>setTimeout(()=>e(!1),5e3))]).finally(()=>this.pendingModelAcks.delete(n))}setLocked(e){this.locked=e}setScoopThinkingLevel(e,t,n){let r=`thinking-${K()}`,i=new Promise(e=>{this.pendingThinkingAcks.set(r,e)});return this.send({type:`set-thinking-level`,requestId:r,scoopJid:e,level:t,effortOverride:n}),Promise.race([i,new Promise(e=>setTimeout(()=>e(!1),5e3))]).finally(()=>this.pendingThinkingAcks.delete(r))}async clearAllMessages(e,t={}){let n=`clear-${Date.now()}-${Math.random().toString(36).slice(2,8)}`,r=new Promise(e=>{this.pendingClearAcks.set(n,e)});this.send({type:`clear-chat`,requestId:n,...e?{scoopJid:e}:{},...t.discardLiveSnapshot?{discardLiveSnapshot:!0}:{}}),await Promise.race([r,new Promise(e=>setTimeout(e,5e3))]),this.pendingClearAcks.delete(n)}spawnAgent(e){let t=`agent-${K()}`,n=new Promise((e,n)=>{this.pendingAgentSpawnRequests.set(t,{resolve:e,reject:n})}),{signal:r,...i}=e;return this.send({type:`agent-spawn-request`,requestId:t,options:i}),r&&(r.aborted?this.send({type:`agent-spawn-abort`,requestId:t}):r.addEventListener(`abort`,()=>this.send({type:`agent-spawn-abort`,requestId:t}),{once:!0})),n}clearFilesystem(){this.send({type:`clear-filesystem`})}requestScoopMessages(e){this.send({type:`request-scoop-messages`,scoopJid:e})}async getScoopTranscript(e){let t=`tr-${Date.now()}-${Math.random().toString(36).slice(2,8)}`,n=new Promise(e=>{this.pendingTranscriptRequests.set(t,e)});this.send({type:`request-scoop-transcript`,requestId:t,scoopJid:e});let r=await Promise.race([n,new Promise(e=>setTimeout(()=>e(``),5e3))]);return this.pendingTranscriptRequests.delete(t),r}async getMessagesForScoop(e){let t=`cm-${Date.now()}-${Math.random().toString(36).slice(2,8)}`,n=new Promise(e=>{this.pendingChatMessagesRequests.set(t,e)});this.send({type:`request-scoop-chat-messages`,requestId:t,scoopJid:e});let r=!1,i=await Promise.race([n,new Promise(e=>setTimeout(()=>{r=!0,e([])},5e3))]);return this.pendingChatMessagesRequests.delete(t),r&&G.warn(`getMessagesForScoop timed out`,{scoopJid:e}),i}async requestSudoApproval(e,t=6e5){let n=`sudo-${Date.now()}-${Math.random().toString(36).slice(2,8)}`,r=new Promise(e=>{this.pendingSudoRequests.set(n,e)});this.send({type:`request-sudo-approval`,requestId:n,request:e});let i=await Promise.race([r,new Promise(e=>setTimeout(()=>e({decision:`deny`}),t))]);return this.pendingSudoRequests.delete(n),i}async getSessionStats(){let e=`st-${Date.now()}-${Math.random().toString(36).slice(2,8)}`,t=new Promise(t=>{this.pendingStatsRequests.set(e,t)});this.send({type:`request-session-stats`,requestId:e});let n=await Promise.race([t,new Promise(e=>setTimeout(()=>e(null),5e3))]);return this.pendingStatsRequests.delete(e),n}requestState(){this.send({type:`request-state`});let e=0;this.stateRetryTimer=setInterval(()=>{if(e++,this.ready||e>20){this.stateRetryTimer&&=(clearInterval(this.stateRetryTimer),null);return}G.debug(`Retrying request-state`,{attempt:e}),this.send({type:`request-state`})},500)}isReady(){return this.ready}sprinkleOpHandler=null;forwardLickHandler=null;sendSprinkleLick(e,t,n,r){this.send({type:`sprinkle-lick`,sprinkleName:e,body:t,targetScoop:n,origin:r})}sendToolUiAction(e,t,n){this.send({type:`tool-ui-action`,requestId:e,action:t,data:n})}async sendWebhookEvent(e,t,n){let r=`wh-${K()}`,i=new Promise(e=>{this.pendingWebhookDeliveries.set(r,e)});this.send({type:`lick-webhook-event`,webhookId:e,headers:t,body:n,requestId:r});try{return await Promise.race([i,new Promise(e=>setTimeout(()=>e(null),mo))])}finally{this.pendingWebhookDeliveries.delete(r)}}sendSetFollowerForwarding(e){this.send({type:`set-follower-forwarding`,enabled:e})}sendForwardedLick(e){this.send({type:`inject-forwarded-lick`,event:e})}setForwardLickHandler(e){this.forwardLickHandler=e}sendCherryHostEvent(e,t,n){this.send({type:`lick-cherry-host-event`,cherryRuntimeId:e,name:t,detail:n})}sendPreviewLick(e){this.send({type:`lick-preview`,event:e})}setSprinkleOpHandler(e){this.sprinkleOpHandler=e}sendRaw(e){this.send(e)}setupMessageListener(){this.transport.onMessage(e=>{if(e.source!==`offscreen`)return;let t=e.payload;t?.type===`sprinkle-op`&&this.sprinkleOpHandler?this.sprinkleOpHandler(t):this.handleOffscreenMessage(e.payload)})}handleOffscreenMessage(e){switch(e.type){case`offscreen-ready`:this.ready?(G.warn(`Offscreen restarted — re-requesting state`),this.ready=!1):G.info(`Offscreen engine ready`),this.send({type:`request-state`});break;case`agent-event`:this.handleAgentEvent(e);break;case`scoop-status`:this.handleScoopStatus(e);break;case`compaction-state`:this.handleCompactionState(e);break;case`clear-chat-ack`:{let t=this.pendingClearAcks.get(e.requestId);t&&(this.pendingClearAcks.delete(e.requestId),t());break}case`lick-webhook-delivery`:{let t=this.pendingWebhookDeliveries.get(e.requestId);t&&(this.pendingWebhookDeliveries.delete(e.requestId),t(e.disposition));break}case`agent-spawn-result`:this.handleAgentSpawnResult(e);break;case`set-scoop-model-ack`:this.handleScoopModelAck(e);break;case`set-thinking-level-ack`:this.handleThinkingLevelAck(e);break;case`scoop-created`:this.handleScoopCreated(e);break;case`scoop-list`:this.handleScoopList(e);break;case`state-snapshot`:this.handleStateSnapshot(e);break;case`error`:this.handleError(e);break;case`lick-backpressure`:this.callbacks.onLickBackpressure?.(e.scoopJid,{count:e.count,waitingMs:e.waitingMs});break;case`incoming-message`:this.handleIncomingMessage(e);break;case`message-updated`:this.handleMessageUpdated(e);break;case`scoop-messages-replaced`:{let t=e;this.resyncStreamPointer(t.scoopJid,t.messages),this.callbacks.onScoopMessagesReplaced?.(t.scoopJid,t.messages,t.queuedIds);break}case`scoop-transcript`:{let t=e,n=this.pendingTranscriptRequests.get(t.requestId);n&&(this.pendingTranscriptRequests.delete(t.requestId),n(t.transcript));break}case`scoop-chat-messages`:{let t=e,n=this.pendingChatMessagesRequests.get(t.requestId);n&&(this.pendingChatMessagesRequests.delete(t.requestId),n(t.messages));break}case`sudo-approval`:{let t=e,n=this.pendingSudoRequests.get(t.requestId);n&&(this.pendingSudoRequests.delete(t.requestId),n(t.decision));break}case`session-stats`:{let t=e,n=this.pendingStatsRequests.get(t.requestId);n&&(this.pendingStatsRequests.delete(t.requestId),n({totalCost:t.totalCost,burnRate:t.burnRate,fills:t.fills,models:t.models??[],scoops:t.scoops??[],...t.budget?{budget:t.budget}:{}}));break}case`tray-runtime-status`:{let t=e;_o(t.leader,t.follower);break}case`forward-lick`:this.forwardLickHandler?.(e.event);break;case`terminal-status`:case`terminal-output`:case`terminal-media-preview`:case`terminal-exit`:case`terminal-cleared`:for(let t of this.terminalEventListeners)try{t(e)}catch(e){G.error(`terminal event listener error`,{error:e instanceof Error?e.message:String(e)})}}}handleAgentSpawnResult(e){let t=this.pendingAgentSpawnRequests.get(e.requestId);t&&(this.pendingAgentSpawnRequests.delete(e.requestId),e.ok?t.resolve(e.result):t.reject(Error(e.error)))}terminalEventListeners=new Set;onTerminalEvent(e){return this.terminalEventListeners.add(e),()=>this.terminalEventListeners.delete(e)}resyncStreamPointer(e,t){let n;for(let e=t.length-1;e>=0;e--){let r=t[e];if(r.role===`assistant`&&r.isStreaming){n=r.id;break}}n===void 0?this.currentMessageId.delete(e):this.currentMessageId.set(e,n)}trackToolPhase(e,t){let n=this.toolDepth.get(e)??0,r=t===null?0:Math.max(0,n+t);r===0?this.toolDepth.delete(e):this.toolDepth.set(e,r),n>0!=r>0&&this.callbacks.onScoopPhaseChange?.(e,r>0?`tool`:`thinking`)}handleToolUiAgentEvent(e){if(e.displayScoopJid){let t=`tool-ui-${e.requestId??``}`;e.eventType===`tool_ui`?this.emitToUI({type:`tool_ui`,messageId:t,toolName:e.toolName??``,requestId:e.requestId??``,html:e.html??``}):e.eventType===`tool_ui_done`&&this.emitToUI({type:`tool_ui_done`,messageId:t,requestId:e.requestId??``});return}if(e.eventType===`tool_ui`){let t=this.currentMessageId.get(e.scoopJid);t||(t=`scoop-${e.scoopJid}-${K()}`,this.currentMessageId.set(e.scoopJid,t),this.emitToUI({type:`message_start`,messageId:t})),this.emitToUI({type:`tool_ui`,messageId:t,toolName:e.toolName??``,requestId:e.requestId??``,html:e.html??``});return}let t=this.currentMessageId.get(e.scoopJid);t&&(e.eventType===`tool_ui_done`?this.emitToUI({type:`tool_ui_done`,messageId:t,requestId:e.requestId??``}):e.progress&&this.emitToUI({type:`tool_progress`,messageId:t,toolName:e.toolName??``,progress:e.progress,toolCallId:e.toolCallId}))}handleAgentEvent(e){switch(e.eventType){case`text_delta`:case`tool_start`:case`tool_ui`:case`turn_end`:this.callbacks.onScoopActivity?.(e.scoopJid)}switch(e.eventType){case`tool_start`:this.trackToolPhase(e.scoopJid,1);break;case`tool_end`:this.trackToolPhase(e.scoopJid,-1);break;case`turn_end`:this.trackToolPhase(e.scoopJid,null)}if((e.displayScoopJid??e.scoopJid)===this.selectedScoopJid)switch(e.eventType){case`text_delta`:{let t=this.currentMessageId.get(e.scoopJid);t||(t=`scoop-${e.scoopJid}-${K()}`,this.currentMessageId.set(e.scoopJid,t),this.emitToUI({type:`message_start`,messageId:t})),this.emitToUI({type:`content_delta`,messageId:t,text:e.text??``});break}case`tool_start`:{let t=this.currentMessageId.get(e.scoopJid);t||(t=`scoop-${e.scoopJid}-${K()}`,this.currentMessageId.set(e.scoopJid,t),this.emitToUI({type:`message_start`,messageId:t})),this.emitToUI({type:`tool_use_start`,messageId:t,toolName:e.toolName??``,toolInput:e.toolInput,toolCallId:e.toolCallId});break}case`tool_end`:{let t=this.currentMessageId.get(e.scoopJid);t&&this.emitToUI({type:`tool_result`,messageId:t,toolName:e.toolName??``,result:e.toolResult??``,isError:e.isError,toolCallId:e.toolCallId});break}case`tool_ui`:case`tool_ui_done`:case`tool_progress`:this.handleToolUiAgentEvent(e);break;case`response_done`:{let t=this.currentMessageId.get(e.scoopJid);t&&(this.emitToUI({type:`content_done`,messageId:t,model:e.model,usage:e.usage}),this.currentMessageId.delete(e.scoopJid));break}case`turn_end`:{let t=this.currentMessageId.get(e.scoopJid)??`done-${e.scoopJid}-${K()}`;this.currentMessageId.delete(e.scoopJid),this.emitToUI({type:`turn_end`,messageId:t});break}}}renderCompactionNotice(e,t,n){if(t===`extracting-memory`)return;let r=this.compactionNoticeIds.get(e)??this.lateRetraction(e,t,n);if(t!==`summarizing`&&!r)return;(t===`idle`||t===`cancelled`||t===`fallback`)&&(this.compactionNoticeIds.delete(e),this.compactionSettledRows.delete(e));let i=r??`compaction-${e}-${K()}`;t===`summarizing`&&this.compactionNoticeIds.set(e,i),(t===`idle`||t===`fallback`)&&n.roundId&&this.compactionSettledRows.set(e,{messageId:i,roundId:n.roundId}),e===this.selectedScoopJid&&this.emitToUI({type:`compaction_notice`,messageId:i,marker:{trigger:n.trigger,state:ho[t],...n.transcriptPath?{transcriptPath:n.transcriptPath}:{}}})}lateRetraction(e,t,n){if(t!==`cancelled`||!n.roundId)return;let r=this.compactionSettledRows.get(e);return r?.roundId===n.roundId?r.messageId:void 0}handleCompactionState(e){let t={trigger:e.trigger??`threshold`,...e.transcriptPath?{transcriptPath:e.transcriptPath}:{},...e.roundId?{roundId:e.roundId}:{}};this.callbacks.onCompactionStateChange?.(e.scoopJid,e.state,t),this.renderCompactionNotice(e.scoopJid,e.state,t)}handleScoopStatus(e){let t=this.scoopStatuses.get(e.scoopJid);this.scoopStatuses.set(e.scoopJid,e.status),t!==e.status&&this.trackToolPhase(e.scoopJid,null),this.callbacks.onStatusChange(e.scoopJid,e.status)}handleScoopCreated(e){let t=this.msgScoopToRegistered(e.scoop);this.scoops=this.scoops.filter(e=>e.name!==t.name||e.jid===t.jid),this.scoops.find(e=>e.jid===t.jid)||this.scoops.push(t),this.scoopStatuses.set(t.jid,e.scoop.status),this.callbacks.onScoopCreated(t)}wireScoops(){return this.scoops.map(e=>{let t=ct(e),n=lt(e),r={...e.config,...t?{modelId:t.id,modelProviderId:t.provider}:{},...n.level?{thinkingLevel:n.level}:{},...n.effortOverride?{effortOverride:n.effortOverride}:{}};return{jid:e.jid,name:e.name,folder:e.folder,parentId:e.parentJid,assistantLabel:e.assistantLabel,status:this.scoopStatuses.get(e.jid)??`ready`,...Object.keys(r).length>0?{config:r}:{}}})}handleScoopModelAck(e){if(e.applied){let t=this.getScoop(e.scoopJid);t&&(t.model=e.model?{...e.model}:void 0,this.callbacks.onScoopListUpdate(this.wireScoops()))}this.pendingModelAcks.get(e.requestId)?.(e.applied)}handleThinkingLevelAck(e){if(e.applied){let t=this.getScoop(e.scoopJid);t&&ot(t,e.level===void 0?void 0:{level:e.level,effortOverride:e.effortOverride})}this.pendingThinkingAcks.get(e.requestId)?.(e.applied)}handleScoopList(e){this.scoops=e.scoops.map(e=>this.msgScoopToRegistered(e));for(let t of e.scoops)this.scoopStatuses.set(t.jid,t.status);this.callbacks.onScoopListUpdate(e.scoops)}handleStateSnapshot(e){G.info(`Received state snapshot`,{scoopCount:e.scoops.length}),this.scoops=e.scoops.map(e=>this.msgScoopToRegistered(e));for(let t of e.scoops)this.scoopStatuses.set(t.jid,t.status);e.trayRuntimeStatus&&_o(e.trayRuntimeStatus.leader,e.trayRuntimeStatus.follower);let t=!this.ready;t&&(this.ready=!0,this.stateRetryTimer&&=(clearInterval(this.stateRetryTimer),null)),this.callbacks.onScoopListUpdate(e.scoops),t&&this.callbacks.onReady?.()}handleError(e){e.scoopJid===this.selectedScoopJid&&this.emitToUI({type:`error`,error:e.error})}handleIncomingMessage(e){this.callbacks.onIncomingMessage(e.scoopJid,e.message)}handleMessageUpdated(e){this.callbacks.onMessageUpdate?.(e.scoopJid,{messageId:e.messageId,lickId:e.lickId,lickState:e.lickState})}msgScoopToRegistered(e){return at({jid:e.jid,name:e.name,folder:e.folder,parentJid:e.parentId,requiresTrigger:e.parentId!==null,assistantLabel:e.assistantLabel,addedAt:new Date().toISOString(),...e.config?{config:{...e.config}}:{}})}emitToUI(e){for(let t of this.eventListeners)try{t(e)}catch(e){G.error(`Listener error`,{error:e instanceof Error?e.message:String(e)})}}send(e){if(this.locked){this.emitToUI({type:`error`,error:`This window is detached. Close it and use the detached tab.`});return}this.transport.send(e)}};function K(){return Date.now().toString(36)+Math.random().toString(36).slice(2,8)}function _o(e,t){rt({state:e.state,error:e.error,reconnectAttempts:e.reconnectAttempts,session:e.session?{...e.session}:null}),be({state:t.state,joinUrl:t.joinUrl,trayId:t.trayId,error:t.error,lastError:t.lastError,reconnectAttempts:t.reconnectAttempts,attachAttempts:t.attachAttempts,lastAttachCode:t.lastAttachCode,connectingSince:t.connectingSince,lastPingTime:t.lastPingTime})}function vo(e){let t=e.createAgentHandle(),n=null,r=null;return{onAgentEvent:e=>t.onEvent(e),sendSprinkleLick:(t,n,r,i)=>e.sendSprinkleLick(t,n,r,i?{unitJid:i}:void 0),sendToolUiAction:(t,n,r)=>e.sendToolUiAction(t,n,r),deleteQueuedMessage:(t,n)=>e.deleteQueuedMessage(t,n),emitAgentError:t=>e.emitAgentError(t),getRecord:t=>e.getScoops().find(e=>e.jid===t),speaksReplies:!0,takeAttachments:()=>n?.(),onTurnIdle:()=>r?.(),welcome:{intercept:null},setAttachmentSource:e=>{n=e},setTurnIdleHook:e=>{r=e}}}var yo={onAgentEvent:()=>()=>void 0,sendSprinkleLick:()=>void 0,sendToolUiAction:()=>void 0,deleteQueuedMessage:()=>Promise.resolve(),emitAgentError:()=>void 0},bo=`A follower cannot cancel the leader’s queued message`;function xo(e){return{onAgentEvent:e.onAgentEvent,sendSprinkleLick:(t,n,r)=>e.getSync()?.sendSprinkleLick(t,n,r),sendToolUiAction:()=>void 0,deleteQueuedMessage:()=>Promise.reject(Error(bo)),emitAgentError:e.onAgentError,readOnlyToolUi:!0}}function q(e){return!e.includes(`\0`)}function So(e){if(typeof window>`u`||window.localStorage===void 0)return()=>void 0;let t=window.localStorage,n=typeof Storage<`u`&&t instanceof Storage,r=n?Storage.prototype.setItem:t.setItem.bind(t),i=n?Storage.prototype.removeItem:t.removeItem.bind(t),a=n?Storage.prototype.clear:t.clear.bind(t);if(n){let n=Storage.prototype;n.setItem=function(n,i){if(r.call(this,n,i),this===t){if(!q(n)){console.warn(`[page-storage-sync] dropping localStorage write with NUL in key`,n);return}e.send({type:`local-storage-set`,key:n,value:i})}},n.removeItem=function(n){if(i.call(this,n),this===t){if(!q(n)){console.warn(`[page-storage-sync] dropping localStorage remove with NUL in key`,n);return}e.send({type:`local-storage-remove`,key:n})}},n.clear=function(){a.call(this),this===t&&e.send({type:`local-storage-clear`})}}else{let n=(e,n)=>{Object.defineProperty(t,e,{value:n,writable:!0,configurable:!0,enumerable:!1})};n(`setItem`,(t,n)=>{if(r(t,n),!q(t)){console.warn(`[page-storage-sync] dropping localStorage write with NUL in key`,t);return}e.send({type:`local-storage-set`,key:t,value:n})}),n(`removeItem`,t=>{if(i(t),!q(t)){console.warn(`[page-storage-sync] dropping localStorage remove with NUL in key`,t);return}e.send({type:`local-storage-remove`,key:t})}),n(`clear`,()=>{a(),e.send({type:`local-storage-clear`})})}let o=n=>{if(n.storageArea===t){if(n.key===null){e.send({type:`local-storage-clear`});return}if(q(n.key)){if(n.newValue===null){e.send({type:`local-storage-remove`,key:n.key});return}e.send({type:`local-storage-set`,key:n.key,value:n.newValue})}}};return window.addEventListener(`storage`,o),()=>{if(n)Storage.prototype.setItem=r,Storage.prototype.removeItem=i,Storage.prototype.clear=a;else{let e=(e,n)=>{Object.defineProperty(t,e,{value:n,writable:!0,configurable:!0,enumerable:!1})};e(`setItem`,r),e(`removeItem`,i),e(`clear`,a)}window.removeEventListener(`storage`,o)}}function Co(e){let t=!1,n=()=>{t||(t=!0,typeof e.start==`function`&&e.start())};return{onMessage:t=>{let r=e=>{t(e.data)};return e.addEventListener(`message`,r),n(),()=>{e.removeEventListener(`message`,r)}},send:(t,n)=>{n&&n.length>0?e.postMessage(t,n):e.postMessage(t)}}}function wo(e){let t=Co(e);return{onMessage:e=>t.onMessage(e),send:(e,n)=>{t.send({source:`panel`,payload:e},n)}}}async function To(e,t,n,r,i,a){let o=e;if(o?.type){if(o.type===`cdp-cmd`){let r=e;if((r.gen??a())<a()){n.send({type:`cdp-response`,id:r.id,error:`dropped: command crossed a CDP connection reset in flight`});return}try{i&&t.state!==`connected`&&t.superseded!==!0&&await i();let e=await t.send(r.method,r.params,r.sessionId);n.send({type:`cdp-response`,id:r.id,result:e})}catch(e){n.send({type:`cdp-response`,id:r.id,error:e instanceof Error?e.message:String(e)})}return}if(o.type===`cdp-subscribe`){let i=e;if(r.has(i.event))return;let a=e=>{n.send({type:`cdp-event`,method:i.event,params:e})};r.set(i.event,a),t.on(i.event,a);return}if(o.type===`cdp-unsubscribe`){let n=e,i=r.get(n.event);if(!i)return;r.delete(n.event),t.off(n.event,i)}}}function Eo(e,t){for(let[n,r]of t)e.off(n,r),e.on(n,r)}var Do=1e4;function Oo(e){return new Promise((t,n)=>{let r=!1,i=null,a=null,o=e=>{r||(r=!0,clearTimeout(s),a&&clearInterval(a),i?.(),e?n(e):t())},s=setTimeout(()=>o(Error(`page CDP client is still connecting`)),Do),c=e=>{e===`connected`?o():e===`disconnected`&&o(Error(`page CDP client failed to reconnect`))};e.onStateChange?i=e.onStateChange(e=>c(e)):a=setInterval(()=>c(e.state),50),c(e.state)})}function ko(e,t,n={}){let r=Co(e),i=null,a=n.reconnect?()=>(i||=(t.state===`connecting`?Oo(t):n.reconnect()).finally(()=>{i=null}),i):null,o=new Map,s=r.onMessage(e=>{To(e,t,r,o,a,()=>l)}),c=t.state,l=0,u=t.onStateChange?.((e,n)=>{if(e!==c){if(c=e,e===`disconnected`){l+=1,r.send({type:`cdp-reset`,reason:n??`page CDP client disconnected`});return}e===`connected`&&(Eo(t,o),r.send({type:`cdp-ready`}))}});return()=>{s(),u?.();for(let[e,n]of o)t.off(e,n);o.clear()}}function Ao(){let e={};if(typeof localStorage>`u`)return e;for(let t=0;t<localStorage.length;t++){let n=localStorage.key(t);if(n===null)continue;let r=localStorage.getItem(n);r!==null&&(e[n]=r)}return e}function jo(e,t,n){let r=()=>{};return{ready:new Promise((i,a)=>{let o=null,s=null,c=()=>{o!==null&&(clearTimeout(o),o=null)},l=Math.max(1,t.readyStallLimit??(t.onReadyStall?3:1)),u=Date.now(),d=0,f=!1,p=()=>{c(),o=setTimeout(()=>{if(d+=1,d<l){t.onReadyStall?.({elapsedMs:Date.now()-u,stalls:d}),p();return}t.onLateReady?c():r(),f=!0,a(Error(`Kernel worker did not signal ready within ${n*l}ms`))},n)};r=()=>{s!==null&&(e.removeEventListener(`message`,s),s=null),c()},s=e=>{let n=e.data;if(n?.type===`kernel-worker-boot-progress`){d=0,p();return}if(n?.type===`kernel-worker-ready`){if(r(),f){t.onLateReady?.();return}i();return}if(n?.type===`kernel-worker-boot-error`){r();let e=n.message??`unknown error`,t=n.code,i=Error(`Kernel worker boot failed: ${e}`);t&&(i.code=t),a(i)}},e.addEventListener(`message`,s),p()}),cleanup:()=>r()}}function Mo(e){let{worker:t,realCdpTransport:n}=e,r=e.readyTimeoutMs??3e4,i=e.localStorageSeed??{},a=new MessageChannel,o=new MessageChannel,s=wo(a.port1),c=e.makeClient(s);e.onWorkerScriptError&&e.worker.addEventListener?.(`error`,()=>e.onWorkerScriptError());let l=ko(o.port1,n,{...e.reconnectCdp?{reconnect:e.reconnectCdp}:{}}),{ready:u,cleanup:d}=jo(a.port1,e,r),f={type:`kernel-worker-init`,kernelPort:a.port2,cdpPort:o.port2,localStorageSeed:i,instanceId:e.instanceId,localApiBaseUrl:e.localApiBaseUrl??null,bridgeToken:e.bridgeToken??null,syncFsBridgeEnabled:e.syncFsBridgeEnabled??!1,syncFsChannelNonce:e.syncFsChannelNonce??null,localLickWsUrl:e.localLickWsUrl??null,extensionDelegateId:e.extensionDelegateId??null,pageBuildId:`6.141.4-mtt9nzun`,pageLoadedAt:globalThis.performance?.timeOrigin??Date.now(),flagFloat:e.flagFloat??null,appPageUrl:globalThis.location?.href??null};t.postMessage(f,[a.port2,o.port2]);let p=!1;return{client:c,ready:u,dispose(){if(!p){p=!0,d(),l();try{t.postMessage({type:`kernel-worker-shutdown`})}catch{}t.terminate(),a.port1.close(),o.port1.close()}}}}function No(e){return Mo({worker:e.workerUrl?new Worker(e.workerUrl,{type:`module`}):new Worker(new URL(`/assets/kernel-worker-CFvPuOAi.js`,``+import.meta.url),{type:`module`}),realCdpTransport:e.realCdpTransport,reconnectCdp:e.reconnectCdp,makeClient:e.makeClient,readyTimeoutMs:e.readyTimeoutMs,localStorageSeed:e.localStorageSeed??Ao(),instanceId:e.instanceId,localApiBaseUrl:e.localApiBaseUrl,bridgeToken:e.bridgeToken,syncFsBridgeEnabled:e.syncFsBridgeEnabled,syncFsChannelNonce:e.syncFsChannelNonce,localLickWsUrl:e.localLickWsUrl,extensionDelegateId:e.extensionDelegateId,flagFloat:e.flagFloat,onWorkerScriptError:e.onWorkerScriptError,onReadyStall:e.onReadyStall,readyStallLimit:e.readyStallLimit,onLateReady:e.onLateReady})}var Po=1048576,Fo=`r`;function Io(e){return e.replace(/~/g,`~0`).replace(/\//g,`~1`)}function Lo(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function Ro(e,t,n){if(typeof e==`string`){n.push({pointer:t,value:e});return}if(Array.isArray(e)){for(let r=0;r<e.length;r++)Ro(e[r],`${t}/${r}`,n);return}if(Lo(e))for(let[r,i]of Object.entries(e))Ro(i,`${t}/${Io(r)}`,n)}function zo(e,t,n){if(typeof e==`string`)return n.get(t)??e;if(Array.isArray(e)){let r=!1,i=[];for(let a=0;a<e.length;a++){let o=zo(e[a],`${t}/${a}`,n);o!==e[a]&&(r=!0),i.push(o)}return r?i:e}if(Lo(e)){let r=!1,i={};for(let[a,o]of Object.entries(e)){let e=zo(o,`${t}/${Io(a)}`,n);e!==o&&(r=!0),i[a]=e}return r?i:e}return e}function Bo(e,t,n){if(Lo(e))return zo(e,t,n);if(typeof e==`string`)return n.get(t)??e;if(Array.isArray(e)){let r=!1,i=[];for(let a=0;a<e.length;a++){let o=Bo(e[a],`${t}/${a}`,n);o!==e[a]&&(r=!0),i.push(o)}return r?i:e}return e}function Vo(e){let t=new Map;for(let n of e.matchAll(/⟦REDACTED:([^:⟧]+):([^⟧]+)⟧/g)){let e=n[0],r=t.get(e);r?r.count++:t.set(e,{category:n[1],id:n[2],count:1})}return t}async function Ho(e,t,n){let r=[],i=0;for(;i<e.length;){if(n?.aborted)throw new w(`redaction-unavailable`);let a=0,o=i;for(;o<e.length;){let t=e[o].length;if(o>i&&a+t>Po)break;a+=t,o++}let s=e.slice(i,o),c;try{c=await t.redact(s,n)}catch{throw new w(`redaction-unavailable`)}if(c.length!==s.length)throw new w(`redaction-unavailable`);r.push(...c),i=o}return r}function Uo(e,t,n,r){let i=[],a=Vo(e);for(let{category:e,id:t}of a.values())i.push({id:t,category:e,detector:`pre-obfuscated`,target:n});let o=Vo(t);for(let[e,{category:t,id:r,count:s}]of o)s>(a.get(e)?.count??0)&&i.push({id:r,category:t,detector:`known-secret`,target:n});let{text:s,matches:c,nextId:l}=on(t,Fo,r);for(let{id:e,category:t}of c)i.push({id:e,category:t,detector:`credential-pattern`,target:n});return{finalText:s,redactions:i,nextId:l}}function Wo(e,t,n){for(let{redactions:r}of e)for(let e of r)t.push(e),n[e.category]=(n[e.category]??0)+1}async function Go(e,t,n,r){if(r?.aborted)throw new w(`redaction-unavailable`);let{privacy:i,...a}=e,o=[];Ro(a,``,o);let s=o.filter(e=>!re(e.pointer)),c=[...t.entries()],l=await Ho([...s.map(e=>e.value),...c.map(([,e])=>e)],n,r),u=[],d={},f=1,p=new Map,m=[];for(let e=0;e<s.length;e++){let t=s[e],n=Uo(t.value,l[e],{kind:`json`,pointer:t.pointer},f);f=n.nextId,n.finalText!==t.value&&p.set(t.pointer,n.finalText),m.push(n)}Wo(m,u,d);let h=new Map,g=s.length,_=[];for(let e=0;e<c.length;e++){let[t,n]=c[e],r=Uo(n,l[g+e],{kind:`attachment`,attachmentId:t},f);f=r.nextId,h.set(t,r.finalText),_.push(r)}Wo(_,u,d);let v=Bo(e,``,p);return{document:{...v,privacy:{...v.privacy,redactionCounts:d,redactions:u}},textAttachments:h}}function Ko(e,t){let n=e.startsWith(`text/`)||e===`application/json`,r=/\.(?:txt|md|json|csv|xml|ya?ml|js|mjs|cjs|ts|tsx|css|html)$/i.test(t);return n||r?`text-redacted`:`binary-unchanged`}async function qo(e){let t=e.buffer.slice(e.byteOffset,e.byteOffset+e.byteLength),n=await crypto.subtle.digest(`SHA-256`,t);return Array.from(new Uint8Array(n)).map(e=>e.toString(16).padStart(2,`0`)).join(``)}var Jo={"image/png":`.png`,"image/jpeg":`.jpg`,"image/gif":`.gif`,"image/webp":`.webp`,"image/svg+xml":`.svg`,"image/bmp":`.bmp`,"application/pdf":`.pdf`,"application/zip":`.zip`,"application/gzip":`.gz`,"application/json":`.json`,"text/plain":`.txt`,"text/markdown":`.md`,"text/csv":`.csv`,"text/html":`.html`,"text/xml":`.xml`,"application/xml":`.xml`};function Yo(e,t){return Jo[e]??(t===`text-redacted`?`.txt`:`.bin`)}function Xo(e,t,n){return`attachments/att-${String(e+1).padStart(4,`0`)}${Yo(t,n)}`}function Zo(e){let t=atob(e),n=new Uint8Array(t.length);for(let e=0;e<t.length;e++)n[e]=t.charCodeAt(e);return n}function Qo(e){let t=[];for(let n of e.conversations){let e=0;for(let r of n.messages){let i=r.role;if(i!==`user`&&i!==`assistant`&&i!==`tool-result`)continue;let a=0;for(let o of r.content)o.type===`attachment-ref`&&(t.push({attachmentId:o.attachmentId,conversationId:n.id,messageId:r.id,role:i,userOrdinal:e,imgIndex:a}),a++);i===`user`&&e++}}return t}async function $o(e,t,n,r,i){let a=Ko(e.mimeType,e.name),o={attachmentId:t,originalName:e.name,mimeType:e.mimeType,handling:a,present:!0,sourceConversationId:n,sourceMessageId:r};if(a===`text-redacted`){let t;if(e.text!==void 0)t=e.text;else if(e.data!==void 0)t=new TextDecoder().decode(Zo(e.data));else if(e.path!==void 0&&i!==void 0)try{t=new TextDecoder().decode(await i(e.path))}catch{return{...o,present:!1,missingReason:`attachment-file-missing`}}return t===void 0?{...o,present:!1,missingReason:`attachment-file-missing`}:{...o,rawText:t}}let s;if(e.data!==void 0)s=Zo(e.data);else if(e.path!==void 0&&i!==void 0)try{s=await i(e.path)}catch{return{...o,present:!1,missingReason:`attachment-file-missing`}}return s===void 0?{...o,present:!1,missingReason:`attachment-file-missing`}:{...o,rawBytes:s}}function es(e,t,n,r){let i=[],a=new Set,o=new Set;for(let s of e){if(s.role!==`user`){let e=n.get(s.attachmentId);e===void 0?i.push(Promise.resolve({attachmentId:s.attachmentId,originalName:`unknown`,mimeType:`application/octet-stream`,handling:`binary-unchanged`,present:!1,missingReason:`attachment-file-missing`,sourceConversationId:s.conversationId,sourceMessageId:s.messageId})):i.push(Promise.resolve({attachmentId:s.attachmentId,originalName:`image-${s.imgIndex}`,mimeType:e.mimeType,handling:`binary-unchanged`,rawBytes:Zo(e.data),present:!0,sourceConversationId:s.conversationId,sourceMessageId:s.messageId}));continue}let e=(t.get(s.conversationId)??[]).filter(e=>e.role===`user`)[s.userOrdinal];if(e===void 0){a.add(s.conversationId),i.push(Promise.resolve({attachmentId:s.attachmentId,originalName:`unknown`,mimeType:`application/octet-stream`,handling:`binary-unchanged`,present:!1,missingReason:`attachment-association-unavailable`,sourceConversationId:s.conversationId,sourceMessageId:s.messageId}));continue}let c=(e.attachments??[]).map((e,t)=>({a:e,i:t})).filter(({a:e})=>e.kind===`image`||e.kind===`file`&&e.data!==void 0)[s.imgIndex];if(c===void 0){i.push(Promise.resolve({attachmentId:s.attachmentId,originalName:`unknown`,mimeType:`application/octet-stream`,handling:`binary-unchanged`,present:!1,missingReason:`attachment-file-missing`,sourceConversationId:s.conversationId,sourceMessageId:s.messageId}));continue}o.add(`${s.conversationId}:${e.id}:${c.i}`),i.push($o(c.a,s.attachmentId,s.conversationId,s.messageId,r))}return{pendingPromises:i,mismatchedConvIds:a,processedUiPositions:o}}function ts(e,t,n){return(e.attachments??[]).map((e,t)=>({a:e,i:t})).filter(({a:r,i})=>(r.kind===`text`||r.kind===`file`&&(r.data!==void 0||r.path!==void 0))&&!n.has(`${t}:${e.id}:${i}`))}function ns(e,t,n,r,i,a,o){let s=ts(t,n,i),c=[];for(let t=0;t<s.length;t++){let{a:i}=s[t],l=`${e.id}-file-${t}`;r.has(l)||(a.push($o(i,l,n,e.id,o)),c.push({type:`attachment-ref`,attachmentId:l}))}return c}function rs(e,t,n,r,i){let a=new Map,o=[];for(let s of e.conversations){let e=(t.get(s.id)??[]).filter(e=>e.role===`user`),c=0;for(let t of s.messages){if(t.role!==`user`)continue;let l=e[c];if(c++,l===void 0)continue;let u=ns(t,l,s.id,n,r,o,i);u.length>0&&(a.has(s.id)||a.set(s.id,new Map),a.get(s.id).set(t.id,[...t.content,...u]))}}return{updates:a,additionalPendingPromises:o}}function is(e,t){let n=new Map,r=0,i=new Map;for(let t of e)t.handling===`text-redacted`&&t.rawText!==void 0&&n.set(t.attachmentId,t.rawText),t.present&&i.set(t.attachmentId,Xo(r++,t.mimeType,t.handling));for(let n of e)!n.present&&n.missingReason!==void 0&&t.add(n.missingReason);return{rawAttachments:e.map(e=>e.present?{id:e.attachmentId,path:i.get(e.attachmentId),originalName:e.originalName,mimeType:e.mimeType,byteLength:0,sha256:``,sourceConversationId:e.sourceConversationId,sourceMessageId:e.sourceMessageId,handling:e.handling,present:!0}:{id:e.attachmentId,path:``,originalName:e.originalName,mimeType:e.mimeType,byteLength:0,sha256:``,sourceConversationId:e.sourceConversationId,sourceMessageId:e.sourceMessageId,handling:e.handling,present:!1,missingReason:e.missingReason??`attachment-file-missing`}),textMap:n}}async function as(e,t,n,r,i){let{rawAttachments:a,textMap:o}=is(e,n),s,c;try{let e=await Go({...t,attachments:a},o,r,i);s=e.document,c=e.textAttachments}catch(e){throw e instanceof w?e:new w(`attachment-unreadable`)}let l=new Map;for(let t of e){if(l.has(t.attachmentId))throw new w(`schema-invalid`);l.set(t.attachmentId,t)}let u=new Map,d=await Promise.all(s.attachments.map(async e=>{if(!e.present||!e.path)return e;let t=l.get(e.id);if(t===void 0)throw new w(`schema-invalid`);let n=t.handling===`text-redacted`?new TextEncoder().encode(c.get(t.attachmentId)??t.rawText??``):t.rawBytes,r=await qo(n);return u.set(e.path,n),{...e,byteLength:n.length,sha256:r}}));return{redactedDocument:{...s,attachments:d},bundleFiles:u}}async function os(e){let{document:t,chatMessagesByConversation:n,knownSecrets:r,signal:i}=e,a=e.canonicalImages??new Map,o=e.vfsReader,s=new Set,{pendingPromises:c,mismatchedConvIds:l,processedUiPositions:u}=es(Qo(t),n,a,o);l.size>0&&s.add(`attachment-association-unavailable`);for(let e of t.conversations)e.messages.filter(e=>e.role===`user`).length>(n.get(e.id)??[]).filter(e=>e.role===`user`).length&&s.add(`attachment-association-unavailable`);let d=await Promise.all(c),{updates:f,additionalPendingPromises:p}=rs(t,n,new Set(d.map(e=>e.attachmentId)),u,o),m=await Promise.all(p),h=[...d,...m],g=t;f.size>0&&(g={...t,conversations:t.conversations.map(e=>{let t=f.get(e.id);return t?{...e,messages:e.messages.map(e=>{let n=t.get(e.id);return n?{...e,content:n}:e})}:e})});let{redactedDocument:_,bundleFiles:v}=await as(h,g,s,r,i),y=[..._.session.completeness.missing.filter(e=>!s.has(e)),...s];return{document:{..._,session:{..._.session,completeness:{status:y.length>0?`partial`:_.session.completeness.status,missing:y}}},bundleFiles:v}}var ss=50;function cs(e){return dt(e)}function ls(e,t){return e.map(e=>{let n=t.isProcessing(e.jid)?`1`:`0`,r=t.getAgentMessages(e.jid);if(r===null)return`${e.jid}:${n}:null`;let i=r.length,a=r[i-1],o=a?.role??``,s=a&&`timestamp`in a?a.timestamp:-1,c=a&&`toolCallId`in a?a.toolCallId:``;return`${e.jid}:${n}:${i}:${o}:${s}:${c}`}).join(`,`)}function us(e,t,n,r){let i=new Map;for(let e of t)i.set(e.id,e);let a=new Map;for(let e of n)a.set(e.id,e);let o=[],s=new Map;for(let t of e){let e=r.getAgentMessages(t.jid)??i.get(t.jid)?.messages??[],n={id:t.jid,kind:D(t)?`cone`:`scoop`,name:t.name,...t.folder&&!D(t)?{folder:t.folder}:{},...t.parentJid?{parentConversationId:t.parentJid}:{},...t.originToolCallId?{originToolCallId:t.originToolCallId}:{},messages:e};o.push(n);let c=cs(t),l=a.get(c);l&&s.set(t.jid,l.messages)}return{sources:o,chatMessagesByConversation:s}}async function ds(e,t,n={}){let r=e=>n.rootJid===void 0?e:pt(e,n.rootJid);for(;;){let n=r(e.listScoops());for(;n.some(t=>e.isProcessing(t.jid));)if(t?.aborted||(await e.wait(ss,t),t?.aborted))throw new w(`transfer-aborted`);let i=ls(n,e),[a,o]=await Promise.all([e.loadPersistedSessions(),e.loadUiChatSessions()]);if(t?.aborted)throw new w(`transfer-aborted`);let s=r(e.listScoops());if(i===ls(s,e))return us(s,a,o,e)}}function fs(e,t){return`${e}-msg-${t.toString().padStart(6,`0`)}`}function ps(e,t){return{type:`attachment-ref`,attachmentId:`${e}-img-${t}`}}function ms(e,t){if(typeof e==`string`)return e?[{type:`text`,text:e}]:[];let n=[],r=0;for(let i of e)i.type===`text`?i.text&&n.push({type:`text`,text:i.text}):i.type===`image`&&n.push(ps(t,r++));return n}function hs(e,t){let n=[],r=new Map,i=0,a=0;for(let o of e)if(o.type===`thinking`)i+=1;else if(o.type===`text`)o.text&&n.push({type:`text`,text:o.text});else if(o.type===`toolCall`)n.push({type:`tool-call`,id:o.id??``,name:o.name??``,input:o.arguments??{}});else if(o.type===`image`){let e=ps(t,a++);n.push(e),o.data&&o.mimeType&&r.set(e.attachmentId,{data:o.data,mimeType:o.mimeType})}return{blocks:n,excluded:i,images:r}}function gs(e,t){let n=[],r=new Map,i=0;for(let a of e)if(a.type===`text`)a.text&&n.push({type:`text`,text:a.text});else if(a.type===`image`){let e=ps(t,i++);n.push(e),a.data&&a.mimeType&&r.set(e.attachmentId,{data:a.data,mimeType:a.mimeType})}return{blocks:n,images:r}}function _s(e,t,n){let r=fs(t,n),i=ms(e.content,r);return{message:{id:r,sequence:n,role:`user`,timestamp:new Date(e.timestamp).toISOString(),content:i},excludedReasoningBlocks:0,images:new Map}}function vs(e,t,n){let r=fs(t,n),{blocks:i,excluded:a,images:o}=hs(e.content,r);return{message:{id:r,sequence:n,role:`assistant`,timestamp:new Date(e.timestamp).toISOString(),content:i,model:{provider:e.provider,id:e.model,api:e.api},usage:e.usage,stopReason:e.stopReason,...e.errorMessage?{error:e.errorMessage}:{}},excludedReasoningBlocks:a,images:o}}function ys(e,t,n){let r=fs(t,n),{blocks:i,images:a}=gs(e.content,r);return{message:{id:r,sequence:n,role:`tool-result`,timestamp:new Date(e.timestamp).toISOString(),content:i,toolCallId:e.toolCallId,isError:e.isError},excludedReasoningBlocks:0,images:a}}function bs(e,t,n){return e.role===`user`?_s(e,t,n):e.role===`assistant`?vs(e,t,n):e.role===`toolResult`?ys(e,t,n):{message:null,excludedReasoningBlocks:0,images:new Map}}function xs(e){let t=[];for(let n of e){if(!n.parentConversationId)continue;let e={sourceConversationId:n.parentConversationId,targetConversationId:n.id};n.originToolCallId&&(e.toolCallId=n.originToolCallId),t.push(e)}return t}function Ss(e){let t=0,n=new Map;return{conversations:e.map(e=>{let r=e.messages.flatMap((r,i)=>{let a=bs(r,e.id,i+1);t+=a.excludedReasoningBlocks;for(let[e,t]of a.images)n.set(e,t);return a.message?[a.message]:[]});return{id:e.id,kind:e.kind,name:e.name,...e.folder?{folder:e.folder}:{},...e.parentConversationId?{parentConversationId:e.parentConversationId}:{},...e.createdAt?{createdAt:e.createdAt}:{},...e.updatedAt?{updatedAt:e.updatedAt}:{},messages:r}}),delegations:xs(e),excludedReasoningBlocks:t,canonicalImages:n}}var Cs=(()=>{let e=new Uint32Array(256);for(let t=0;t<256;t++){let n=t;for(let e=0;e<8;e++)n=n&1?3988292384^n>>>1:n>>>1;e[t]=n}return e})();function ws(e){let t=-1>>>0;for(let n=0;n<e.length;n++)t=t>>>8^Cs[(t^e[n])&255];return~t>>>0}var Ts=new TextEncoder;function J(e,t,n){e[t]=n&255,e[t+1]=n>>>8&255}function Y(e,t,n){e[t]=n&255,e[t+1]=n>>>8&255,e[t+2]=n>>>16&255,e[t+3]=n>>>24&255}function Es(e,t,n){let r=new Uint8Array(30+e.length);return r[0]=80,r[1]=75,r[2]=3,r[3]=4,J(r,4,20),J(r,6,2048),J(r,8,0),J(r,10,0),J(r,12,0),Y(r,14,n),Y(r,18,t),Y(r,22,t),J(r,26,e.length),J(r,28,0),r.set(e,30),r}function Ds(e,t,n,r){let i=new Uint8Array(46+e.length);return i[0]=80,i[1]=75,i[2]=1,i[3]=2,J(i,4,20),J(i,6,20),J(i,8,2048),J(i,10,0),J(i,12,0),J(i,14,0),Y(i,16,n),Y(i,20,t),Y(i,24,t),J(i,28,e.length),J(i,30,0),J(i,32,0),J(i,34,0),J(i,36,0),Y(i,38,0),Y(i,42,r),i.set(e,46),i}function Os(e,t,n){let r=new Uint8Array(22);return r[0]=80,r[1]=75,r[2]=5,r[3]=6,J(r,4,0),J(r,6,0),J(r,8,e),J(r,10,e),Y(r,12,t),Y(r,16,n),J(r,20,0),r}function ks(e){if(!e||e.startsWith(`/`)||e.includes(`\0`)||e.includes(`\\`))return!1;for(let t of e.split(`/`))if(t===``||t===`.`||t===`..`)return!1;return!0}function As(e){let t=e.export.generatedAt.slice(0,10),n=e.export.id.slice(0,8);return`slicc-${t}-${C(e.session.title,{maxLen:40,fallback:`transcript`})}-${n}.zip`}async function*js(e,t,n,r,i){if(n?.aborted)throw i(new w(`transfer-aborted`)),new w(`transfer-aborted`);let a=()=>i(new w(`transfer-aborted`));n?.addEventListener(`abort`,a,{once:!0});let o=Ee.create(),s=0,c=0,l=[],u=!1;function*d(e){o.update(e),s+=e.byteLength,c+=e.byteLength,yield e}try{let i=new TextEncoder().encode(JSON.stringify(e,null,2)),a=Ts.encode(`transcript.json`),f=ws(i),p=Es(a,i.length,f);if(l.push({nameBytes:a,size:i.length,crc:f,localOffset:c}),n?.aborted||(yield*d(p),n?.aborted))throw new w(`transfer-aborted`);yield*d(i);for(let[e,r]of t){if(n?.aborted)throw new w(`transfer-aborted`);let t=Ts.encode(e),i=ws(r),a=Es(t,r.length,i);if(l.push({nameBytes:t,size:r.length,crc:i,localOffset:c}),yield*d(a),n?.aborted)throw new w(`transfer-aborted`);yield*d(r)}let m=c;for(let e of l){if(n?.aborted)throw new w(`transfer-aborted`);yield*d(Ds(e.nameBytes,e.size,e.crc,e.localOffset))}if(n?.aborted)throw new w(`transfer-aborted`);yield*d(Os(l.length,c-m,m)),u=!0,r({byteLength:s,sha256:o.hex()})}catch(e){throw u=!0,i(e),e}finally{n?.removeEventListener(`abort`,a),u||(u=!0,i(new w(`transfer-aborted`)))}}var Ms=4294967295,Ns=65535;function Ps(e,t,n){for(let e of t.keys())if(!ks(e))throw new w(`schema-invalid`);if(t.size+1>Ns)throw new w(`schema-invalid`);for(let e of t.values())if(e.byteLength>Ms)throw new w(`schema-invalid`);let r,i,a=new Promise((e,t)=>{r=e,i=t});return{filename:As(e),chunks:js(e,t,n,r,i),completion:a}}function Fs(e,t,n,r,i,a={}){return{schemaVersion:1,export:{id:crypto.randomUUID(),generatedAt:new Date().toISOString(),producer:{application:`slicc`,version:i},format:ie},session:{id:e,title:t,state:n,completeness:{status:`complete`,missing:[]},...a},privacy:{reasoningExcluded:!0,excludedReasoningBlocks:r.excludedReasoningBlocks,binaryAttachments:`included-unchanged`,redactionCounts:{},redactions:[]},conversations:r.conversations,delegations:r.delegations,attachments:[]}}function Is(e,t){let n=[],r=1;for(let i of e){if(i.role!==`user`&&i.role!==`assistant`)continue;let e=`${t}-msg-${String(r).padStart(6,`0`)}`;n.push({id:e,sequence:r++,role:i.role,timestamp:new Date(i.timestamp||0).toISOString(),content:i.content?[{type:`text`,text:i.content}]:[]})}return n}function Ls(e){let t=ne(e);if(!t.ok)throw new w(`schema-invalid`,t.error)}function Rs(e,t,n){let r=new Map;for(let i of e)if(!(!i.present||!i.path)){if(i.handling===`text-redacted`){let e=t.get(i.id);e!==void 0&&r.set(i.path,new TextEncoder().encode(e))}else{let e=n.get(i.path);e&&r.set(i.path,e)}}return r}async function zs(e,t){return Promise.all(e.map(async e=>{if(!e.present||!e.path||e.handling!==`text-redacted`)return e;let n=t.get(e.path);if(!n)return e;let r=n.buffer.slice(n.byteOffset,n.byteOffset+n.byteLength),i=await crypto.subtle.digest(`SHA-256`,r),a=Array.from(new Uint8Array(i)).map(e=>e.toString(16).padStart(2,`0`)).join(``);return{...e,byteLength:n.length,sha256:a}}))}function Bs(e){let t=e.match(/^---\n([\s\S]*?)\n---\n/);if(!t)return{};let n=t[1],r={},i=n.match(/^createdAt:\s*(\d+)\s*$/m),a=n.match(/^updatedAt:\s*(\d+)\s*$/m);return i&&(r.createdAt=new Date(Number(i[1])).toISOString()),a&&(r.updatedAt=new Date(Number(a[1])).toISOString()),r}var Vs=class{deps;constructor(e){this.deps=e}async export(e,t={}){let{signal:n,onProgress:r}=t,i;return i=e.kind===`active`?await this.buildActiveSnapshot(n,r):await this.buildFrozenSnapshot(e.sessionId,n,r),Ls(i.document),r?.({phase:`packaging`}),Ps(i.document,i.bundleFiles,n)}async captureFrozen(e,t){let n=await ds(this.deps.collection,t,{...e.rootJid?{rootJid:e.rootJid}:{}});if(e.rootJid&&n.sources.length===0)return;let r=Ss(n.sources),{document:i,bundleFiles:a}=await os({document:Fs(e.sessionId,e.title,`frozen`,r,this.deps.version,{frozenAt:e.frozenAt,createdAt:new Date(e.createdAt).toISOString(),updatedAt:new Date(e.updatedAt).toISOString()}),chatMessagesByConversation:n.chatMessagesByConversation,knownSecrets:this.deps.knownSecrets,canonicalImages:r.canonicalImages,vfsReader:e=>this.readBinaryFromVfs(e),signal:t});Ls(i),await this.deps.snapshotStore.write(e.sessionId,{document:i,attachments:a})}async buildActiveSnapshot(e,t){t?.({phase:`waiting-for-conversations`}),t?.({phase:`collecting`});let n=await ds(this.deps.collection,e),r=Ss(n.sources),{id:i,title:a}=this.deps.getActiveSessionInfo(),o=Fs(i,a,`active`,r,this.deps.version);return t?.({phase:`redacting`}),os({document:o,chatMessagesByConversation:n.chatMessagesByConversation,knownSecrets:this.deps.knownSecrets,canonicalImages:r.canonicalImages,vfsReader:e=>this.readBinaryFromVfs(e),signal:e})}async buildFrozenSnapshot(e,t,n){let r=await this.deps.snapshotStore.read(e);return r?(n?.({phase:`redacting`}),this.reredactStoredSnapshot(r,t)):this.buildLegacyPartial(e,t,n)}async reredactStoredSnapshot(e,t){let n=new Map;for(let t of e.document.attachments){if(t.handling!==`text-redacted`||!t.present||!t.path)continue;let r=e.attachments.get(t.path);r&&n.set(t.id,new TextDecoder().decode(r))}let r,i;try{let a=await Go(e.document,n,this.deps.knownSecrets,t);r=a.document,i=a.textAttachments}catch{throw new w(`redaction-unavailable`)}let a=Rs(r.attachments,i,e.attachments),o=await zs(r.attachments,a);return{document:{...r,attachments:o},bundleFiles:a}}async buildLegacyPartial(e,t,n){let r=(await V(this.deps.vfs)).find(t=>t.sessionId===e||!t.sessionId&&t.filename===e);if(!r)throw new w(`session-not-found`);let i;try{let e=await this.deps.vfs.readFile(`/sessions/${r.filename}`,{encoding:`utf-8`});i=typeof e==`string`?e:new TextDecoder().decode(e)}catch{throw new w(`session-not-found`)}let{title:a,messages:o}=ki(i),s=`legacy-cone`,c=Is(o,s),l=Bs(i),u={schemaVersion:1,export:{id:crypto.randomUUID(),generatedAt:new Date().toISOString(),producer:{application:`slicc`,version:this.deps.version},format:ie},session:{id:e,title:a,state:`frozen`,...r.frozenAt?{frozenAt:r.frozenAt}:{},...l,completeness:{status:`partial`,missing:[`complete-snapshot-unavailable`,`canonical-agent-history-unavailable`]}},privacy:{reasoningExcluded:!0,excludedReasoningBlocks:0,binaryAttachments:`included-unchanged`,redactionCounts:{},redactions:[]},conversations:[{id:s,kind:`cone`,name:a,messages:c}],delegations:[],attachments:[]},d=new Map([[s,o]]);return n?.({phase:`redacting`}),os({document:u,chatMessagesByConversation:d,knownSecrets:this.deps.knownSecrets,vfsReader:e=>this.readBinaryFromVfs(e),signal:t})}async readBinaryFromVfs(e){let t=await this.deps.vfs.readFile(e,{encoding:`binary`});if(!(t instanceof Uint8Array))throw new w(`attachment-unreadable`);return t}},Hs=`/sessions/data`,Us=`document.json`;async function Ws(e){let t=e.buffer.slice(e.byteOffset,e.byteOffset+e.byteLength),n=await crypto.subtle.digest(`SHA-256`,t);return Array.from(new Uint8Array(n)).map(e=>e.toString(16).padStart(2,`0`)).join(``)}function Gs(e){if(e.length===0||/[/\\\x00]/.test(e)||e===`..`||e===`.`||e.includes(`..`)||!/^[a-zA-Z0-9._-]+$/.test(e))throw new w(`session-not-found`)}function Ks(e){return`${Hs}/${e}`}function qs(e){return`${Hs}/.tmp-${e}`}async function Js(e,t){try{await e.mkdir(t,{recursive:!0})}catch{}}async function Ys(e,t){let n;try{n=await e.readDir(t)}catch{return}for(let r of n){let n=`${t}/${r.name}`;r.type===`directory`&&await Ys(e,n);try{await e.rm(n)}catch{}}try{await e.rm(t)}catch{}}async function Xs(e,t,n){await Js(e,n);let r=await e.readDir(t);for(let i of r){let r=`${t}/${i.name}`,a=`${n}/${i.name}`;if(i.type===`directory`)await Xs(e,r,a);else{let t=await e.readFile(r,{encoding:`binary`});await e.writeFile(a,t)}}}async function Zs(e,t,n){Gs(t);let r=qs(t),i=Ks(t),a=new Map(n.document.attachments.filter(e=>e.present&&e.path).map(e=>[e.path,e]));for(let[e]of n.attachments)if(!a.has(e))throw new w(`schema-invalid`);await Ys(e,i),await Js(e,r);try{let t=[...n.document.attachments];for(let[e,r]of n.attachments){let n=await Ws(r),i=a.get(e);if(i!==void 0){let e=t.indexOf(i);e!==-1&&(t[e]={...i,sha256:n,byteLength:r.length})}}let o={...n.document,attachments:t},s=JSON.stringify(o,null,2);if(await e.writeFile(`${r}/${Us}`,s),n.attachments.size>0)for(let[t,i]of n.attachments){let n=`${r}/${t}`,a=t.lastIndexOf(`/`);a!==-1&&await Js(e,`${r}/${t.slice(0,a)}`),await e.writeFile(n,i)}await e.flush(),await Xs(e,r,i),await e.flush()}catch(t){throw await Ys(e,r),t}await Ys(e,r)}async function Qs(e,t){Gs(t);let n=Ks(t),r=`${n}/${Us}`,i;try{let t=await e.readFile(r,{encoding:`utf-8`});i=typeof t==`string`?t:new TextDecoder().decode(t)}catch{throw new w(`session-not-found`)}let a;try{a=JSON.parse(i)}catch{throw new w(`schema-invalid`)}if(!ne(a).ok)throw new w(`schema-invalid`);let o=new Map;for(let t of a.attachments){if(!t.present||!t.path)continue;let r=`${n}/${t.path}`,i;try{let t=await e.readFile(r,{encoding:`binary`});i=t instanceof Uint8Array?t:new TextEncoder().encode(t)}catch{throw new w(`transfer-corrupt`)}if(await Ws(i)!==t.sha256)throw new w(`transfer-corrupt`);o.set(t.path,i)}return{document:a,attachments:o}}function $s(e){return`error`in e}function X(){throw new w(`redaction-unavailable`)}function ec(e,t){return(typeof e!=`object`||!e||!Array.isArray(e.texts)||e.texts.length!==t)&&X(),e.texts}function tc(){return{async redact(e){let t;try{t=await fetch(le(`/api/secrets/redact-export`),{method:`POST`,headers:ue({"content-type":`application/json`}),body:JSON.stringify({texts:e})})}catch{X()}t.ok||X();let n;try{n=await t.json()}catch{X()}return ec(n,e.length)}}}function nc(){return{async redact(e){let t;try{t=await new Promise(t=>{chrome.runtime.sendMessage({type:`secrets.redact-export`,texts:e},e=>{chrome.runtime.lastError,t(e??null)})})}catch{X()}return typeof t==`object`&&t&&$s(t)&&X(),ec(t,e.length)}}}function rc(){return{async redact(e){let t;try{t=await fe(`secrets.redact-export`,{texts:e})}catch{X()}return t??X(),typeof t==`object`&&t&&$s(t)&&X(),ec(t,e.length)}}}function ic(){return{async redact(e){X()}}}function ac(){let e=de();return e===`connect`?ic():e===`extension-direct`?nc():e===`extension-delegate`?rc():tc()}function Z(e){switch(e){case`processing`:return`working`;case`error`:return`broken`;case`initializing`:return`initializing`;default:return`idle`}}function oc(e,t={}){let n=Z(t.status),r=ct(e);return{id:e.jid,parentId:e.parentJid,role:D(e)?`primary`:`child`,name:e.name,folder:e.folder,assistantLabel:e.assistantLabel,state:n,...n===`working`&&t.phase?{phase:t.phase}:{},...n===`idle`&&t.awaiting?{awaiting:!0}:{},fill:typeof t.fill==`number`?Math.round(t.fill*100):0,...typeof t.turns==`number`?{turns:t.turns}:{},...r?{model:r}:{},...e.trigger?{trigger:e.trigger}:{},...e.addedAt?{addedAt:e.addedAt}:{}}}function sc(e,t=Date.now){let n=e.parentId===null,r=e.folder??e.name,i=n?e.config:cc(e,r),a={jid:e.id??(n?`cone_${t()}`:`scoop_${r}_${t()}`),name:e.name,folder:r,requiresTrigger:!n,assistantLabel:n?`sliccy`:r,addedAt:new Date(t()).toISOString(),parentJid:e.parentId,...i?{config:i,configSchemaVersion:3}:{},...e.notifyOnComplete===!1?{notifyOnComplete:!1}:{},...!n&&e.onParentClose===`detach`?{onParentClose:`detach`}:{}};return n||(a.trigger=`@${r}`),a}function cc(e,t){let n=ut(e.workspace?.mode??e.config?.workspaceMode),r=Sr(n,t,{root:e.workspace?.from??`/workspace`},e.workspace?.from),i=e.config;return{...i,workspaceMode:n,visiblePaths:i?.visiblePaths===void 0?r.visiblePaths:i.visiblePaths,writablePaths:i?.writablePaths===void 0?r.writablePaths:i.writablePaths}}var lc=`padding:0.5rem 1.25rem;border-radius:0.375rem;cursor:pointer;font:inherit;font-size:0.875rem;`,uc=`${lc}border:none;background:var(--s2-accent-color,#0265dc);color:#fff;`,dc=`${lc}border:none;background:#d23;color:#fff;`,fc=`${lc}background:transparent;border:1px solid var(--s2-border-color,#e0e0e0);color:inherit;`;function pc(e,t,n){return{...sc({parentId:null,name:e,folder:`cone-pending-${t.length+1}`}),assistantLabel:e,...n?{model:n}:{}}}function mc(e,t){let n=e.createElement(`slicc-dialog`);n.setAttribute(`heading`,t.heading),n.append(t.body);for(let r of t.actions){let t=e.createElement(`button`);t.setAttribute(`slot`,`footer`),t.type=`button`,t.dataset.coneAction=r.data,t.textContent=r.text,t.style.cssText=r.style,t.addEventListener(`click`,r.onClick),n.append(t)}return n.addEventListener(`slicc-dialog-close`,()=>t.onDismiss(n)),n}function hc(e,t){let n=e.createElement(`form`);n.style.cssText=`display:flex;flex-direction:column;gap:0.5rem;padding:0.25rem 0;`;let r=`font-size:0.9375rem;padding:0.5rem 0.625rem;border:1px solid var(--s2-border-color,#e0e0e0);border-radius:0.375rem;background:transparent;color:inherit;font-family:inherit;`,i=e.createElement(`input`);i.type=`text`,i.name=`name`,i.placeholder=`Name`,i.setAttribute(`aria-label`,`Cone name`),i.maxLength=40,i.autocomplete=`off`,i.required=!0,i.style.cssText=r;let a=e.createElement(`textarea`);a.name=`brief`,a.placeholder=`What should it work on? (optional)`,a.setAttribute(`aria-label`,`What the cone should work on`),a.rows=3,a.style.cssText=`${r}resize:vertical;`,n.append(i,a);let o=()=>({name:i.value.trim(),brief:a.value.trim()});return n.addEventListener(`submit`,e=>{e.preventDefault(),t(o())}),a.addEventListener(`keydown`,e=>{e.key===`Enter`&&(e.metaKey||e.ctrlKey)&&(e.preventDefault(),t(o()))}),n.readDraft=o,n}function gc(e){let{freezer:t,client:n,log:r}=e,i=t.ownerDocument,a=null,o=!1,s=null,c=()=>t.querySelector(`slicc-freezer-new`),l=()=>Ht(e.getUnits(),e.getSelected()),u=t=>e.getUnits().find(e=>e.id===t.jid)??oc(t),d=()=>{if(!s)return;let e=s;s=null,e.hide?.(),e.remove()},f=e=>{d();let t=mc(i,{...e,onDismiss:e=>{s===e&&(s=null),e.remove()}});s=t,i.body.append(t),t.show?.()},p=t=>{if(!t.name)return;d();let i=l(),o=pc(t.name,n.getScoops(),Xt(e.getUnits(),i?.id));a=t.name,n.registerScoop(o,t.brief?{description:t.brief,prompt:t.brief}:{}).catch(e=>r.warn(`WC cone create failed`,e)),_()},m=()=>{let e=hc(i,p);f({heading:`New cone`,body:e,actions:[{text:`Create`,style:uc,data:`create`,onClick:()=>p(e.readDraft())},{text:`Cancel`,style:fc,data:`cancel`,onClick:d}]}),queueMicrotask(()=>e.querySelector(`input`)?.focus())},h=t=>{d();let i=E(n.getScoops()),a=i.find(e=>e.jid===t);if(!a||i.length<=1||o){_();return}o=!0,_(),(async()=>{try{await e.freezeCone(a)}catch(e){r.warn(`WC cone freeze before drop failed`,e)}let t=l()?.id===a.jid;try{await n.unregisterScoop(a.jid)}catch(e){r.warn(`WC cone drop failed`,e)}if(t){let t=E(n.getScoops()).find(e=>e.jid!==a.jid);t&&e.selectScoop(u(t))}o=!1,_()})()},g=e=>{let t=Yt(e),n=i.createElement(`p`);n.textContent=`Its chat goes to the Freezer.`,n.style.cssText=`font-size:0.875rem;margin:0;`,f({heading:`Drop ${t}?`,body:n,actions:[{text:`Drop`,style:dc,data:`drop`,onClick:()=>h(e.id)},{text:`Cancel`,style:fc,data:`cancel`,onClick:d}]})},_=()=>{let t=E(n.getScoops());if(a!==null){let n=t.find(e=>e.name===a&&!e.folder.startsWith(`cone-pending-`));n&&(a=null,e.getSelected()?.id!==n.jid&&e.selectScoop(u(n)))}let r=c();r?.setAttribute(`cones`,String(t.length)),r?.toggleAttribute(`busy`,o)};return t.addEventListener(`new-cone`,m),t.addEventListener(`drop-cone`,()=>{let e=l();!e||E(n.getScoops()).length<=1||o||g(e)}),_(),{refresh:_,dialog:()=>s}}var _c=5e3,vc=class{deps;listListeners=new Set;unitListeners=new Map;lastSnapshots=new Map;orphanedReplays=new Map;retriedSnapshots=new Set;pendingSnapshots=new Map;constructor(e){this.deps=e}toSummary(e){return oc(e,{awaiting:this.deps.getAwaiting?.()===e.jid,fill:this.deps.fills.get(e.jid),phase:this.deps.phases.get(e.jid),status:this.deps.statuses.get(e.jid),turns:this.deps.turns?.get(e.jid)})}snapshotFor(e,t,n){let r=this.deps.getClient()?.getScoops().find(t=>t.jid===e);return r?{summary:this.toSummary(r),messages:t,...n?{queuedIds:n}:{}}:null}currentUnits(){return(this.deps.getClient()?.getScoops()??[]).map(e=>this.toSummary(e))}publishSnapshot(e,t){this.retriedSnapshots.delete(e),this.lastSnapshots.set(e,t),this.emit(e,{snapshot:t,type:`snapshot`});let n=this.pendingSnapshots.get(e);if(n){this.pendingSnapshots.delete(e);for(let e of n)e(t)}}drainOrphanedReplays(){for(let[e,t]of this.orphanedReplays){let n=this.snapshotFor(e,t.messages,t.queuedIds);n&&(this.orphanedReplays.delete(e),this.publishSnapshot(e,n))}}recoverUnanswered(e){if(this.unitListeners.has(e)){if(this.retriedSnapshots.has(e)){this.publishRecovery(e);return}this.retriedSnapshots.add(e),this.deps.getClient()?.requestScoopMessages(e),setTimeout(()=>{this.retriedSnapshots.has(e)&&this.publishRecovery(e)},_c)}}publishRecovery(e){if(!this.unitListeners.has(e))return;let t=this.lastSnapshots.get(e),n=this.deps.getClient()?.getScoops().find(t=>t.jid===e);this.emit(e,{snapshot:{messages:t?.messages??[],...n?{summary:this.toSummary(n)}:{}},type:`snapshot`})}forgetWaiter(e,t){let n=this.pendingSnapshots.get(e);n&&(n.delete(t),n.size===0&&this.pendingSnapshots.delete(e))}emitList(){if(this.drainOrphanedReplays(),this.listListeners.size===0)return;let e=this.currentUnits();for(let t of this.listListeners)t(e)}emit(e,t){let n=this.unitListeners.get(e);if(n)for(let e of n)e(t)}wrapCallbacks(e){return{...e,onStatusChange:(t,n)=>{e.onStatusChange(t,n),this.emit(t,{state:Z(n),type:`status`}),this.emitList()},onScoopCreated:t=>{e.onScoopCreated(t),this.emitList()},onScoopListUpdate:t=>{e.onScoopListUpdate(t),this.emitList()},onScoopPhaseChange:(t,n)=>{e.onScoopPhaseChange?.(t,n),this.emitList()},onIncomingMessage:(t,n)=>{e.onIncomingMessage(t,n),this.emit(t,{message:n,type:`message`})},onScoopMessagesReplaced:(t,n,r)=>{e.onScoopMessagesReplaced?.(t,n,r);let i=n,a=this.snapshotFor(t,i,r);a?this.publishSnapshot(t,a):this.orphanedReplays.set(t,{messages:i,queuedIds:r})}}}list(){return Promise.resolve(this.currentUnits())}subscribeList(e){return this.listListeners.add(e),e(this.currentUnits()),()=>{this.listListeners.delete(e)}}subscribe(e,t){let n=this.unitListeners.get(e)??new Set;n.add(t),this.unitListeners.set(e,n);let r=this.lastSnapshots.get(e);return this.pendingSnapshots.has(e)||(r?t({snapshot:r,type:`snapshot`}):this.deps.getClient()?.requestScoopMessages(e)),()=>{n.delete(t),n.size===0&&this.unitListeners.delete(e)}}snapshot(e){let t=this.deps.getClient();if(!t)return Promise.reject(Error(`kernel client not attached`));let n=this.pendingSnapshots.get(e)??new Set;this.pendingSnapshots.set(e,n);let r=()=>{},i=new Promise(e=>{r=e,n.add(e)});t.setSelectedScoopJid(e),t.requestScoopMessages(e);let a,o=new Promise(t=>{a=setTimeout(()=>{a=void 0;let n=this.pendingSnapshots.get(e)?.has(r)===!0;this.forgetWaiter(e,r),n&&this.recoverUnanswered(e),t(this.snapshotFor(e,[],void 0))},_c)});return Promise.race([i.then(e=>(a!==void 0&&(clearTimeout(a),a=void 0),e)),o]).then(t=>{if(!t)throw Error(`unknown work unit: ${e}`);return t})}send(e,t){let n=this.deps.getClient();return n?(n.sendRaw({attachments:t.attachments,messageId:t.messageId??`msg-${Date.now()}-${Math.random().toString(36).slice(2,8)}`,scoopJid:e,text:t.text,type:`user-message`,...t.steer?{steer:!0}:{},...t.guestGate?{guestGate:t.guestGate}:{}}),Promise.resolve()):Promise.reject(Error(`kernel client not attached`))}setModel(e,t){let n=this.deps.getClient();return n?n.setScoopModel(e,t):Promise.reject(Error(`kernel client not attached`))}signal(e,t){if(t!==`stop`)return Promise.resolve();let n=this.deps.getClient();return n?(n.stopScoop(e),Promise.resolve()):Promise.reject(Error(`kernel client not attached`))}};function Q(e){return e.workUnits??=new vc({fills:e.fills,getAwaiting:()=>e.awaitingInput,getClient:()=>e.getClient(),phases:e.phases,statuses:e.statuses,turns:e.turns}),e.workUnits}function yc(e){let t=Q(e),n=()=>e.refreshScoops?.(),r=()=>(e.refs.thread.getAttribute(`context`)??``).startsWith(`freezer:`),i=()=>{if(e.getSelected()||r())return;let n=t.currentUnits(),i=e.pendingUrlContext;if(i?.startsWith(`freezer:`))return;if(i?.startsWith(`scoop:`)||i?.startsWith(`cone:`)){let t=Ut(n,i);if(t){e.pendingUrlContext=null,e.selectScoop(t);return}}let a=$t(n);a&&(e.pendingUrlContext=null,e.selectScoop(a))};return t.wrapCallbacks({onStatusChange:(t,r)=>{let i=e.statuses.get(t),a=r;e.statuses.set(t,a),a!==`ready`&&e.awaitingInput===t&&(e.awaitingInput=null),Z(i)===`working`&&Z(a)!==`working`&&e.turns.set(t,(e.turns.get(t)??0)+1),Z(i)!==Z(a)&&(n(),e.notifyScoopStateChanged?.()),e.getSelected()?.id===t&&e.getController()?.setProcessing(r===`processing`)},onScoopCreated:t=>{n(),!e.getSelected()&&!r()&&!e.pendingUrlContext&&e.selectScoop(oc(t,{fill:e.fills.get(t.jid),phase:e.phases.get(t.jid),status:e.statuses.get(t.jid)}))},onScoopListUpdate:t=>{let r=new Set(t.map(e=>e.jid));for(let t of e.lickBackpressure.keys())r.has(t)||e.lickBackpressure.delete(t);for(let t of e.turns.keys())r.has(t)||e.turns.delete(t);n(),i()},onScoopActivity:t=>{e.refs.switcher.setAttribute(`attention`,t)},onScoopPhaseChange:(t,r)=>{e.phases.set(t,r),n(),e.notifyScoopStateChanged?.()},onIncomingMessage:(t,n)=>{e.refs.switcher.setAttribute(`attention`,t),e.lastActivity.set(t,String(n.content??``).slice(0,600)),e.getSelected()?.id===t&&n.channel!==`web`&&bt(n.channel)&&e.getController()?.addLickMessage(n.id,n.content,n.channel,new Date(n.timestamp).getTime(),n.lickId)},onLickBackpressure:(t,n)=>{n.count<=0?e.lickBackpressure.delete(t):e.lickBackpressure.set(t,n);let r=e.getSelected();if(r?.id!==t)return;let i=en(r);e.getController()?.setLickBackpressure(n.count,n.waitingMs,i)},onMessageUpdate:(t,n)=>{e.getSelected()?.id===t&&n.lickId&&n.lickState&&e.getController()?.updateLickState(n.lickId,n.lickState)},onReady:()=>{n(),i(),e.notifyReady?.()}})}var bc=`slicc:leader-local-model-state-changed`;function xc(e=window){e.dispatchEvent(new Event(bc))}var Sc=`slicc:leader-model-catalog-changed`;function Cc(e=window){e.dispatchEvent(new Event(Sc))}var wc={off:`off`,low:`low`,medium:`medium`,high:`high`,xhigh:`xhigh`,max:`xhigh`},Tc={off:`off`,minimal:`low`,low:`low`,medium:`medium`,high:`high`,xhigh:`xhigh`};function Ec(e){return e?wc[e]:void 0}function Dc(e){return e===`max`?`max`:void 0}function Oc(e,t){return t===`max`?`max`:(e&&Tc[e])??`off`}var kc=2e3,Ac=1e4,jc=12e4;function Mc(e){let t=[],n=null,r=new Map,i=e.modelPickerEnabled!==!1,a=e.catalogRetryDelayMs??kc,o=e.catalogRetryMaxDelayMs??Ac,s=e.catalogRetryWindowMs??jc,c=0,l=null,u=null,d=()=>{if(!i||u!==null)return;let t=Date.now();if(l===null&&(l=t+s),t>=l)return;let n=Math.min(a*2**c,o);u=setTimeout(()=>{u=null;let t=e.getSync();t?.requestModels&&(c+=1,t.requestModels())},n)},f=()=>{u!==null&&clearTimeout(u),u=null,c=0,l=null},p=e=>{if(e.length===0)return;let t=new Set(e.map(e=>e.id));for(let e of r.keys())t.has(e)||r.delete(e)},m=()=>{let t=e.getSelectedScoopJid(),i=e.getUnits();if(p(i),n&&(i.length===0||!t))return n.activeModelId;if(n&&t&&n.scoopJid===t){let e=ft(n.activeModelId);return e&&r.set(t,e),n.activeModelId}let a=Xt(i,t,t?r.get(t):void 0);return t&&a&&r.set(t,a),a?ht(a):void 0},h=()=>{let r=m(),a=r?t.find(e=>e.modelId===r):void 0;if(!i||!n||!a){e.composerMeta.style.display=`none`,d();return}e.composerMeta.model=a.modelName,e.composerMeta.setAttribute(`thinking`,Oc(n.thinkingLevel,n.effortOverride)),e.composerMeta.toggleAttribute(`no-thinking`,!a.reasoning),e.composerMeta.style.removeProperty(`display`),f()},g=t=>{e.interceptLocalHandlers&&t.stopImmediatePropagation()},_=t=>{let i=e.getSync();if(!i)return;g(t);let a=t.detail?.id,o=e.getSelectedScoopJid()??n?.scoopJid,s=a?ft(a):null;s&&o?(r.set(o,s),e.setModel(o,s)):a&&i.selectModel(a,o??void 0),h()};e.composerMeta.addEventListener(`model-change`,_,{capture:e.interceptLocalHandlers});let v=t=>{let r=e.getSync();if(!r)return;if(g(t),e.getLockedEffortLevel?.()){h();return}let i=t.detail?.thinking,a=Ec(i),o=e.getSelectedScoopJid()??n?.scoopJid;o&&a&&a!==`max`&&r.setThinkingLevel(o,a,Dc(i)),h()};e.composerMeta.addEventListener(`thinking-change`,v,{capture:e.interceptLocalHandlers});let y=()=>{t=[],n=null,r.clear(),f(),e.composerMeta.models=[],e.composerMeta.style.display=`none`};return y(),{onModelsList(n){t=n,e.composerMeta.models=n.map(e=>({id:e.modelId,name:e.modelName,provider:e.providerName})),h()},onModelState(e){n=e,h()},onShownUnitChanged(){h()},reset:y,dispose(){e.composerMeta.removeEventListener(`model-change`,_,{capture:e.interceptLocalHandlers}),e.composerMeta.removeEventListener(`thinking-change`,v,{capture:e.interceptLocalHandlers}),y(),e.composerMeta.style.removeProperty(`display`)}}}async function Nc(e,t,n,r,i=xc){let a=await e.setScoopThinkingLevel(t,n,r);return a&&i(),a}function Pc(e,t){return Zt(e)===null||new URL(t.location.href).searchParams.get(`cherry`)===`1`||ce(t.localStorage)}async function Fc(e,t,n,r,i){let a=Kt(t),o=Jt(a);e.thread.setAttribute(`context`,Qt(t));let s=Wt(t),c=xt({isRoot:s,name:t.name});e.thread.setAttribute(`accent`,c),e.switcher.setAttribute(`active`,t.id),It(e,s?{kind:`cone`}:{kind:`scoop`,accent:c}),Nt(e,o);let u=localStorage.getItem(`slicc_locked_effort_level`),d=r?.(t.id);if(d||u){let t=d?lt(d):{};e.composerMeta.setAttribute(`thinking`,Oc(u??t.level,t.effortOverride))}if(!i?.skipModelPill)try{let{resolveCurrentModel:r,resolveModelById:i}=await l(async()=>{let{resolveCurrentModel:e,resolveModelById:t}=await import(`./main-DRyLg5pd.js`).then(e=>e.t);return{resolveCurrentModel:e,resolveModelById:t}},__vite__mapDeps([35,8,36,12,13,14,15,16,17,18,19,20,1,21,22,23,24,3,25,26,27,28,29,30,31,32,37,38,39,40,41,42,43,44])),a=Xt(n,t.id),o=a?i(a.id,a.provider):r();e.composerMeta.setAttribute(`model`,o.name??o.id),e.composerMeta.toggleAttribute(`no-thinking`,o.reasoning!==!0||!!u)}catch{}}async function Ic(e){if(Pc(e.pendingUrlContext,e.win))return;let t=Zt(e.pendingUrlContext);if(t===null)return;let{SessionStore:n}=await l(async()=>{let{SessionStore:e}=await Promise.resolve().then(()=>dn);return{SessionStore:e}},void 0),r=new n;await r.init();let i=await r.load(dt({folder:t}));i&&i.messages.length>0&&!e.hasSelection()&&(e.loadMessages(i.messages),e.onHydrated())}function Lc(e){let{boot:t,client:n,openReader:r,log:i}=e,{refs:a}=t;l(async()=>{let{createPlaceholderRefresher:e}=await import(`./wc-placeholder-VxPXRa-X.js`);return{createPlaceholderRefresher:e}},__vite__mapDeps([45,13,46,8,12,14,15,16,17,18,19,20,1,21,22,23,24,3,25,26,27,28,29,30,31,32,34])).then(({createPlaceholderRefresher:n})=>{e.setRefreshPlaceholder(n({inputCard:a.inputCard,getMessages:()=>t.getController()?.getMessages()??[],defaultPlaceholder:a.inputCard.getAttribute(`placeholder`)??`Ask sliccy, or describe a change…`}))}),Ic({pendingUrlContext:t.wiring.pendingUrlContext,win:window,hasSelection:()=>!!t.getSelected(),loadMessages:e=>t.getController()?.loadMessages(e),onHydrated:e.triggerPlaceholder}).catch(e=>i.warn(`WC session hydration failed`,e));let o=null;return l(async()=>{let{wireWcAttach:e}=await import(`./wc-attach-Dm3guiHt.js`);return{wireWcAttach:e}},__vite__mapDeps([47,13,21,48])).then(({wireWcAttach:t})=>{o=t({inputCard:a.inputCard,freezer:a.freezer,composer:a.composer,openReader:r,openWriter:e.openWriter,listConversations:async()=>{let{readSessionsIndex:e}=await l(async()=>{let{readSessionsIndex:e}=await Promise.resolve().then(()=>Xi);return{readSessionsIndex:e}},void 0);return(await e(await r())).map(e=>({id:e.filename,label:e.title,sub:`${e.messageCount} turns`}))},log:i})}).catch(e=>i.error(`WC add-menu wiring failed`,e)),l(async()=>{let{wireWcHistoryNav:e}=await import(`./wc-history-nav-C5w8ianG.js`);return{wireWcHistoryNav:e}},[]).then(({wireWcHistoryNav:e})=>e({thread:a.thread,inputCard:a.inputCard})).catch(e=>i.error(`WC history nav wiring failed`,e)),a.composerMeta.addEventListener(`thinking-change`,e=>{if(localStorage.getItem(`slicc_locked_effort_level`))return;let r=e.detail?.thinking,a=Ec(r),o=Dc(r),s=t.getSelected();s&&a&&Nc(n,s.id,a,o).catch(e=>i.warn(`local thinking update failed`,e))}),{getAttachStage:()=>o}}var Rc=`slicc:leader-run-new-session`,zc=`slicc:leader-broadcast-snapshot`;function Bc(e){if(!(!e.cone||e.cone===`cone`))return e.coneLabel||e.cone.replace(/^cone-/,``)}function Vc(e){let t=`${new Date(e.frozenAt).toLocaleDateString(void 0,{month:`short`,day:`numeric`})} · ${e.messageCount} turns`;return e.live?`${t} · in progress`:t}function Hc(e){let t=document.createElement(`slicc-freezer-card`);return t.setAttribute(`title`,e.title),t.setAttribute(`meta`,Vc(e)),t.setAttribute(`slug`,e.filename),e.icon&&t.setAttribute(`icon`,e.icon),t}async function Uc(e){let t=new Map;for(let n of e.entries){if(n.icon||n.pendingEnrichment)continue;let r=await e.pickIcon(`"${n.title}" — an archived chat session`);r&&t.set(n.filename,r)}if(t.size===0)return;let n=await Wc(e.reader);if(n===null||n.length===0)return;let r=n.map(e=>{let n=!e.icon&&t.has(e.filename)?t.get(e.filename):void 0;return n?{...e,icon:n}:e});await e.writer.writeFile(B,JSON.stringify(r,null,2));for(let n of e.freezer.querySelectorAll(`slicc-freezer-card`)){let e=t.get(n.getAttribute(`slug`)??``);e&&!n.hasAttribute(`icon`)&&n.setAttribute(`icon`,e)}}async function Wc(e){let t=await Gc(e);return t.kind===`ok`?t.entries:t.kind===`missing`?[]:null}async function Gc(e){let t;try{let n=await e.readFile(B,{encoding:`utf-8`});t=typeof n==`string`?n:new TextDecoder().decode(n)}catch(e){return e?.code===`ENOENT`?{kind:`missing`}:{kind:`fault`}}try{let e=JSON.parse(t);return Array.isArray(e)?{kind:`ok`,entries:e}:{kind:`corrupt`}}catch{return{kind:`corrupt`}}}async function Kc(e){let t;try{t=(await e.readDir(`/sessions`)).filter(e=>e.type===`file`&&e.name.endsWith(`.md`)).map(e=>e.name)}catch{return[]}let n=[];for(let r of t)try{let t=await e.readFile(`/sessions/${r}`,{encoding:`utf-8`}),i=typeof t==`string`?t:new TextDecoder().decode(t);n.push(qc(r,i))}catch{}return n.sort((e,t)=>t.frozenAt.localeCompare(e.frozenAt)),n}function qc(e,t){let n=t.slice(0,2e3),r=/^title:\s*"?(.*?)"?\s*$/m.exec(n)?.[1]??e,i=/^frozenAt:\s*"?(.*?)"?\s*$/m.exec(n)?.[1]??new Date(0).toISOString(),a=Number(/^messageCount:\s*(\d+)\s*$/m.exec(n)?.[1]??0),o=ki(t),s=e.startsWith(`pending-`)||e.startsWith(`live-`)&&!o.live;return{filename:e,title:r,frozenAt:i,messageCount:a,...o.cost?{cost:o.cost}:{},...o.models?{models:o.models}:{},...o.cone?{cone:o.cone}:{},...o.coneLabel?{coneLabel:o.coneLabel}:{},...o.memorySkipped?{memorySkipped:!0}:{},...o.live?{live:!0}:{},...o.live&&o.liveThrough?{liveThrough:o.liveThrough}:{},...o.live&&o.compactions?{compactions:o.compactions}:{},...o.id?{sessionId:o.id}:{},...s?{pendingEnrichment:!0}:{}}}function Jc(e,t){for(let t of Array.from(e.querySelectorAll(`slicc-freezer-card`)))t.remove();e.append(...t.map(Hc))}async function Yc(e,t){let n=await e.readFile(H(t),{encoding:`utf-8`}),r=ki(typeof n==`string`?n:new TextDecoder().decode(n));return{title:r.title||t.title,messages:r.messages}}async function Xc(e,t){let{getTranscriptExportService:n}=await l(async()=>{let{getTranscriptExportService:e}=await Promise.resolve().then(()=>gn);return{getTranscriptExportService:e}},void 0);await n().captureFrozen({sessionId:t.sessionId??t.archive.id,title:t.archive.title,frozenAt:t.archive.frozenAt,createdAt:t.archive.createdAt,updatedAt:t.archive.updatedAt,...e?{rootJid:e.jid}:{}})}function Zc(e,t){if(t)return e.getScoops().find(e=>e.jid===t.id)}function Qc(e){return{folder:e.folder,label:Yt({assistantLabel:e.assistantLabel,name:e.name,role:D(e)?`primary`:`child`}),jid:e.jid}}async function $c(e){let{root:t}=e,n=t?Qc(t):void 0,r=e=>Xc(t,e);if(e.action!==`save`){await e.runNewSessionFreezeQuick({vfs:e.writer,cone:n,captureCompleteSnapshot:r});return}await e.runNewSessionFreeze({vfs:e.writer,cone:n,agenticMemorySpawn:t=>e.client.spawnAgent(t),captureCompleteSnapshot:r,onProgress:t=>{let n=e.freezerNew();n&&(t===null?n.removeAttribute(`progress`):n.setAttribute(`progress`,String(t)))},onBackgroundEnriched:e.refreshFreezer})}async function el(e,t){e!==`erase`&&await $c({...t,action:e})}async function tl(e){try{await e.resetNewSessionTmp(e.writer,e.tmpDir)}catch(t){e.log.warn(`WC new session /tmp reset failed — clearing anyway`,t)}await e.client.clearAllMessages(e.root?.jid,e.discardLiveSnapshot?{discardLiveSnapshot:!0}:{}),e.getController()?.loadMessages([]),window.dispatchEvent(new CustomEvent(zc)),l(async()=>{let{resetDictationPriming:e}=await import(`./wc-shortcuts-udkJj992.js`).then(e=>e.H);return{resetDictationPriming:e}},__vite__mapDeps([46,8,12,13,14,15,16,17,18,19,20,1,21,22,23,24,3,25,26,27,28,29,30,31,32,34])).then(({resetDictationPriming:e})=>e()).catch(()=>void 0)}function nl(e,t){(e.thread.inner??e.thread).prepend(rl(e.thread.ownerDocument,t)),e.thread.setAttribute(`accent`,Lt),It(e,{kind:`freezer`}),e.inputCard.setAttribute(`disabled`,``),e.switcher.removeAttribute(`active`)}function rl(e,t){let n=t?Bc(t):void 0,r=e.createElement(`slicc-day-separator`);return r.setAttribute(`label`,n?`Frozen chat · from cone ${n}`:`Frozen chat`),r.setAttribute(`data-frozen-provenance`,n??``),r}function il(e){let{refs:t,openVfs:n,client:r,getController:i,getSelected:a,clearSelection:o,log:s}=e,c=[],u=null,d=t=>{u=null,e.selectScoop(t)},f=0,p=!1,m=()=>{let e=++f;n().then(async({reader:n,writer:r})=>{let i=await Wc(n);if(i===null){if((await Gc(n)).kind!==`corrupt`||(s.warn(`WC freezer index corrupt — rebuilding from archives`),i=await Kc(n),i.length===0))return;await r.writeFile(B,JSON.stringify(i,null,2))}e===f&&(c=i,Jc(t.freezer,i),!p&&i.some(e=>!e.icon&&!e.pendingEnrichment)&&(p=!0,l(async()=>{let{pickLucideIcon:e}=await import(`./quick-llm-DDPHThwA.js`).then(e=>e.n);return{pickLucideIcon:e}},__vite__mapDeps([11,8,12,13,14,15,16,17,18,19,20,1,21,22,23,24,3,25,26,27,28,29,30,31,32,33,34])).then(({pickLucideIcon:e})=>Uc({reader:n,writer:r,freezer:t.freezer,entries:i,pickIcon:t=>e({subject:t})})).catch(e=>s.warn(`WC freezer icon enrichment failed`,e)).finally(()=>{p=!1})))}).catch(e=>s.error(`WC freezer refresh failed`,e))},h=!1,g=()=>t.freezer.querySelector(`slicc-freezer-new`),_=t=>{h||(h=!0,g()?.setAttribute(`busy`,``),(async()=>{let o=Zc(r,Ht(e.getUnits(),a()));try{let{writer:a}=await n(),{resetNewSessionTmp:c,runNewSessionFreeze:u,runNewSessionFreezeQuick:f}=await l(async()=>{let{resetNewSessionTmp:e,runNewSessionFreeze:t,runNewSessionFreezeQuick:n}=await import(`./new-session-Cvy359ZG.js`);return{resetNewSessionTmp:e,runNewSessionFreeze:t,runNewSessionFreezeQuick:n}},__vite__mapDeps([49,12,8,13,14,15,16,17,18,19,20,1,21,22,23,24,3,25,26,27,28,29,30,31,32,41,35,36,37,38,39,40,42,43,44,33]));await el(t,{writer:a,root:o,client:r,freezerNew:g,refreshFreezer:m,runNewSessionFreeze:u,runNewSessionFreezeQuick:f}),await tl({writer:a,root:o,client:r,getController:i,log:s,resetNewSessionTmp:c,tmpDir:yr(r.getScoops(),o),discardLiveSnapshot:t===`erase`}),m();let p=e.getUnits().find(e=>e.id===o?.jid)??$t(e.getUnits());p&&d(p)}catch(e){s.error(`WC new session failed`,e)}finally{h=!1;let e=g();e?.removeAttribute(`busy`),e?.removeAttribute(`progress`)}})())};for(let e of[`save`,`skip`,`erase`])t.freezer.addEventListener(`new-chat-${e}`,()=>_(e));let v=async e=>{let{writer:t}=await n(),{runNewSessionArchiveOnly:r}=await l(async()=>{let{runNewSessionArchiveOnly:e}=await import(`./new-session-Cvy359ZG.js`);return{runNewSessionArchiveOnly:e}},__vite__mapDeps([49,12,8,13,14,15,16,17,18,19,20,1,21,22,23,24,3,25,26,27,28,29,30,31,32,41,35,36,37,38,39,40,42,43,44,33]));await r({vfs:t,cone:Qc(e),captureCompleteSnapshot:t=>Xc(e,t)}),m()};ve(`agentic-memory`)&&g()?.setAttribute(`no-skip`,``),window.addEventListener(Rc,e=>{let t=e.detail?.action;(t===`save`||t===`skip`||t===`erase`)&&_(t)});let y=async r=>{let l=c.find(e=>e.filename===r);try{let{reader:a}=await n();l||=(await Wc(a)??[]).find(e=>e.filename===r);let{messages:s}=await Yc(a,l??{filename:r,title:r,frozenAt:``,messageCount:0});t.thread.setAttribute(`context`,`freezer:${l?.filename??r}`),u=l?.sessionId??l?.filename??null,e.holdQueuedPile(),i()?.loadMessages(s),nl(t,l),o()}catch(t){if(s.error(`WC thaw failed`,t),!a()){let t=Gt(e.getUnits(),l?.cone);t&&d(t)}}};return t.freezer.addEventListener(`freezer-card-select`,e=>{let t=e.detail?.slug;t&&y(t)}),{refreshFreezer:m,openFrozen:y,getViewedFrozenSessionId:()=>u,freezeCone:v}}d(`scoops.tray-leave`),d(`scoops.tray-join`);var al=null;function ol(e){al=e}function sl(){return al?.()??[]}var cl=null;function ll(e){cl=e}function ul(){return cl??void 0}var dl=`slicc.leaderTrayFollowers`;function fl(){return pl()}function pl(){if(al)return al();try{let e=globalThis.localStorage?.getItem(dl);if(e)return JSON.parse(e)}catch{}return[]}function ml(e,t=globalThis.localStorage){try{t?.setItem(dl,JSON.stringify(e))}catch{}}function hl(e){try{let t=JSON.parse(e);return{processes:(t.processes??[]).filter(e=>e.status===`running`||e.status===`pending`).map(e=>({pid:Number(e.pid??0),argv:String(e.argv??``),status:String(e.status??`unknown`)})),terminated:Number(t.stats?.terminated??0)}}catch{return{processes:[],terminated:0}}}function gl(e){let t=xe();if(t.state!==`inactive`)return{role:`follower`,state:t.state,joinUrl:t.joinUrl,sessionId:t.trayId,workerBaseUrl:ae(t.joinUrl)?.workerBaseUrl??null,stalled:t.stalled};let n=it();if(n.state!==`inactive`)return{role:`leader`,state:n.state,joinUrl:n.session?.joinUrl,sessionId:n.session?.trayId,workerBaseUrl:n.session?.workerBaseUrl};let r=null;try{r=oe(e.getItem(se))}catch{}return{role:`standalone`,state:`inactive`,workerBaseUrl:r}}function _l(e){let{client:t,openReader:r,storage:i}=e;return{getScoops:()=>t.getScoops(),isProcessing:e=>t.isProcessing(e),getCronTasks:async()=>{let{getAllCronTasks:e}=await l(async()=>{let{getAllCronTasks:e}=await import(`./tray-leader-DaLUK8LB.js`).then(e=>e.o);return{getAllCronTasks:e}},__vite__mapDeps([50,8,1,22,13,21,23,24,3,38,37,39]));return e()},getWebhooks:async()=>{let{getAllWebhooks:e}=await l(async()=>{let{getAllWebhooks:e}=await import(`./tray-leader-DaLUK8LB.js`).then(e=>e.o);return{getAllWebhooks:e}},__vite__mapDeps([50,8,1,22,13,21,23,24,3,38,37,39]));return e()},getMounts:async()=>{let{getAllMountEntries:e,loadMountHandle:t}=await l(async()=>{let{getAllMountEntries:e,loadMountHandle:t}=await import(`./mount-table-store-dY2IfQ5S.js`).then(e=>e.r);return{getAllMountEntries:e,loadMountHandle:t}},__vite__mapDeps([51,8])),n=await e();return Promise.all(n.map(async e=>{if(e.descriptor.kind!==`local`)return e;try{let n=await(await t(e.descriptor.idbHandleKey))?.queryPermission?.({mode:`readwrite`});return{...e,valid:n===`granted`}}catch{return{...e,valid:!1}}}))},getMcpServers:async()=>{try{let e=await(await r()).readFile(`/workspace/.mcp/servers.json`,{encoding:`utf-8`});return JSON.parse(typeof e==`string`?e:new TextDecoder().decode(e)).servers??{}}catch{return{}}},getOAuthProviders:()=>{try{let e=new Set,t=[];for(let r of a()){if(e.has(r.providerId))continue;if(e.add(r.providerId),!n(r.providerId)?.isOAuth){t.push({providerId:r.providerId});continue}let i=c(r.providerId),a=r.loggedOut?!1:i?!i.expired:!1;t.push({providerId:r.providerId,valid:a})}return t}catch{return[]}},getSessionStats:async()=>t.getSessionStats?.()??null,getProcesses:async()=>{try{let e=await(await r()).readFile(`/proc/table`,{encoding:`utf-8`});return hl(typeof e==`string`?e:new TextDecoder().decode(e))}catch{return{processes:[],terminated:0}}},getTrayInfo:()=>gl(i),getConnectedFollowers:sl}}var vl=`sync-fs-nonce`;function yl(e={}){let t=e.navigator??(typeof navigator<`u`?navigator:void 0),n=e.document??(typeof document<`u`?document:void 0),r=e.window??(typeof window<`u`?window:void 0),i=e.randomUUID??(()=>crypto.randomUUID()),a=!!t?.serviceWorker?.controller,o=a?i():void 0;if(!o||!t?.serviceWorker)return{syncFsBridgeEnabled:a,syncFsChannelNonce:o};let s=t.serviceWorker,c={type:vl,nonce:o},l=()=>s.controller?.postMessage(c);return l(),s.addEventListener(`controllerchange`,l),s.addEventListener(`message`,e=>{e.data?.type===`sync-fs-need-nonce`&&l()}),n?.addEventListener(`visibilitychange`,()=>{n.visibilityState===`visible`&&l()}),r?.addEventListener(`focus`,l),{syncFsBridgeEnabled:a,syncFsChannelNonce:o}}var bl=class{#e=new Map;#t=new Map;#n=new Map;sync(e,t){let n=new Set;for(let r of e){n.add(r.id);let e=this.#r(r);e>0&&r.id!==t&&this.#e.set(r.id,(this.#e.get(r.id)??0)+e)}t&&this.#e.delete(t);for(let e of[...this.#e.keys()])n.has(e)||this.#e.delete(e);for(let e of[...this.#t.keys()])n.has(e)||this.#t.delete(e);for(let e of[...this.#n.keys()])n.has(e)||this.#n.delete(e);return this.counts()}#r(e){let t=this.#t.get(e.id),n=this.#t.has(e.id);if(this.#t.set(e.id,e.state),typeof e.turns==`number`&&Number.isFinite(e.turns)){let t=this.#n.get(e.id)??(n?0:void 0);return this.#n.set(e.id,e.turns),t===void 0?0:e.turns>t?Math.floor(e.turns-t):0}return this.#n.delete(e.id),n&&t===`working`&&e.state!==`working`?1:0}counts(){return new Map(this.#e)}};function xl(e,t){let n=e=>{t.onError?.(e instanceof Error?e.message:String(e))};return{sendMessage:(r,i,a,o)=>{let s=t.getSelectedId();if(!s){t.onError?.(`No scoop selected`);return}e.send(s,{text:r,...i?{messageId:i}:{},...a?{attachments:a}:{},...o?.steer?{steer:!0}:{},...o?.guestGate?{guestGate:o.guestGate}:{}}).catch(n)},onEvent:e=>t.onEvent(e),stop:()=>{let r=t.getSelectedId();r&&e.signal(r,`stop`).catch(n)}}}var Sl=`<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><rect width="14" height="14" x="8" y="8" rx="2" ry="2"/><path d="M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2"/></svg>`;function Cl(e){for(let t=e.length-1;t>=0;t--){let n=e[t];if(n.role===`assistant`&&!n.isStreaming&&!n.queued)return n.content}for(let t=e.length-1;t>=0;t--)if(e[t].role===`assistant`)return e[t].content;return null}function wl(e){let t=e.writeText??(e=>navigator.clipboard.writeText(e)),n=document.createElement(`div`);n.className=`wc-copy-row`,n.style.cssText=`display:flex;justify-content:flex-start;margin:-8px 0 14px;`;let r=document.createElement(`slicc-press-button`);r.setAttribute(`tooltip`,`Copy last response · hold to copy chat`),r.setAttribute(`label`,`Copy last response — hold to copy entire chat`),r.setAttribute(`disable-double-click`,``),r.style.cssText=`color:var(--txt-3);cursor:pointer;display:inline-flex;`;let i=document.createRange();r.append(i.createContextualFragment(Sl));let a=()=>{r.style.color=`var(--green)`,setTimeout(()=>{r.style.color=`var(--txt-3)`},1500)};return r.addEventListener(`short-click`,()=>{(async()=>{let n=Cl(e.getMessages());await t(n??Pi([...e.getMessages()])),a()})()}),r.addEventListener(`long-press`,()=>{(async()=>{let n=Pi([...e.getMessages()]);n&&(await t(n),a())})()}),n.append(r),n}function $(){return`msg-${Date.now()}-${Math.random().toString(36).slice(2,8)}`}function Tl(e){try{let t=new DOMParser().parseFromString(e,`text/html`).querySelector(`.sprinkle-action-card__header`);if(t){t.querySelector(`.sprinkle-badge`)?.remove(),t.querySelector(`.sprinkle-action-card__meta`)?.remove();let e=t.textContent?.trim();if(e)return e}}catch{}return`Approval requested`}function El(e){return`
|
|
395
|
-
<div class="sprinkle-action-card">
|
|
396
|
-
<div class="sprinkle-action-card__header">${Qe(Tl(e))} <span class="sprinkle-badge sprinkle-badge--informative">pending</span></div>
|
|
397
|
-
<div class="sprinkle-action-card__body">Waiting for approval on the leader…</div>
|
|
398
|
-
</div>
|
|
399
|
-
`}function Dl(e){let t={id:e.id,text:e.content};return e.attachments?.length&&(t.attachments=e.attachments.length),t}var Ol=class e{#e;#t;#n;#r;#i;#a=null;#o;#s;#c;#l;#u;#d;#f;#p;#m;#h;#g;#_;#v;#y=[];#b=[];#x=null;#S=new Map;#C=null;#w=null;#T=``;#E=!1;#D=!1;#O=`thinking`;#k=0;#A=null;#j=new Set;#M=new Map;#N=new Map;#P=new Set;#F=!1;#I=null;constructor(e){this.#e=e.thread,this.#t=e.agent,this.#n=e.onProcessingChange,this.#r=e.onBusyPhaseChange,this.#i=e.onToolProgressChange,this.#o=e.onMessageRendered,this.#s=e.onMessageDisposed,this.#c=e.onTurnComplete,this.#l=e.resolveTelemetryContext,this.#u=e.onQueuedChange,this.#d=e.onLickBackpressureChange,this.#f=e.onQueuedCancel,this.#p=e.onToolUiAction,this.#m=e.readOnlyToolUi??!1,this.#h=e.agent.onEvent(e=>this.#q(e)),this.#v=e=>this.#me(e),this.#e.addEventListener(`slicc-error-retry`,this.#v)}dispose(){this.#h(),this.#e.removeEventListener(`slicc-error-retry`,this.#v);for(let e of[...this.#M.keys()])this.#pe(e);this.#N.clear(),this.#P.clear(),this.#fe()}setReadOnly(e){if(this.#F!==e&&(this.#F=e,e))for(let e of[...this.#M.keys()])this.#pe(e)}get readOnly(){return this.#F}get processing(){return this.#D}getMessages(){return this.#y.map(e=>({...e}))}setAgent(e){this.#h(),this.#t=e,this.#h=e.onEvent(e=>this.#q(e))}setOnLocalUserMessage(e){this.#g=e}setOnLocalProcessingChange(e){this.#_=e}addUserMessage(e,t,n){this.#_e({id:$(),role:`user`,content:e,timestamp:Date.now(),...n?{source:n}:{}})}getQueuedMessages(){return this.#b.map(Dl)}removeQueuedMessage(e){let t=this.#b.filter(t=>t.id!==e);t.length!==this.#b.length&&(this.#b=t,this.#z())}stashQueued(){let e=this.#I??[];this.#I=null;let t=this.#b;return t.length===0?e:(this.#b=[],this.#z(),[...e,...t])}restoreQueued(e){this.#I=e.length>0?[...e]:null}heldBackendPendingIds(e){if(!this.#I||!e?.length)return new Set;let t=new Set(e);return new Set(this.#I.filter(e=>t.has(e.id)).map(e=>e.id))}#L(e,t){if(!this.#I)return;let n=this.heldBackendPendingIds(t),r=new Set(e.map(e=>e.id)),i=this.#I.filter(e=>!r.has(e.id)||n.has(e.id));if(this.#I=null,i.length===0)return;if(!t){this.#b=i,this.#z();return}let a=new Map(t.map((e,t)=>[e,t])),o=i.filter(e=>a.has(e.id)).sort((e,t)=>(a.get(e.id)??0)-(a.get(t.id)??0)),s=i.filter(e=>!a.has(e.id));if(this.#b=this.#D?o:[...o,...s],this.#z(),this.#D)for(let e of s)this.#_e(e)}#R(){if(this.#b.length===0)return;let e=this.#b;this.#b=[];for(let t of e)this.#_e(t);this.#z()}#z(){this.#u?.(this.#b.map(Dl))}#B(){this.#d?.(this.#x)}setLickBackpressure(e,t,n){if(e<=0){if(!this.#x)return;this.#x=null,this.#B();return}this.#x={text:`${e} events waiting for the current turn`},this.#B();try{me(n,t)}catch{}}addAssistantMessage(e){this.#_e({id:$(),role:`assistant`,content:e,timestamp:Date.now()})}loadMessages(e,t){for(let e of this.#S.keys())this.#s?.(e);for(let e of[...this.#M.keys()])this.#pe(e);this.#N.clear(),this.#P.clear(),this.#fe();let n=this.#b.length>0;if(this.#b.length>0){if(this.#f)for(let e of this.#b)try{this.#f(e.id)}catch(e){console.error(`onQueuedCancel hook threw`,e)}this.#b=[]}n&&this.#z();let r=this.heldBackendPendingIds(t),i=r.size>0?e.filter(e=>!r.has(e.id)):e;this.#y=Ft(i);let a=[...this.#y].reverse().find(e=>e.isStreaming);this.#C=a?.id??null,a&&(this.#w=a.id),this.#T=``,this.#E=!1,this.#S.clear();let o=[],s=``;for(let e of this.#y){let t=new Date(e.timestamp).toDateString();t!==s&&(o.push(Mt(e.timestamp)),s=t);let n=this.#ge(e);this.#S.set(e.id,n),o.push(...n)}let c=this.#e;typeof c.replaceContent==`function`?c.replaceContent(...o):c.replaceChildren(...o),this.#xe();for(let e of this.#y)e.isStreaming||this.#o?.(e,this.#S.get(e.id)??[]);this.#K(),this.#Ce(),this.#V(),this.#L(e,t)}#V(){if(this.#e.getAttribute(`context`)!==`cone`||this.#y.length===0||!Se()||this.#D)return;let e=this.#y[this.#y.length-1];e.role!==`user`||e.source===`lick`||e.source===`delegation`||e.queued||this.#me(new Event(`slicc-error-retry`))}sendUserMessage(e,t,n){let r=e.trim();if(!r&&!t?.length)return;let i=n?.dictation?this.#H(r):r,a={id:$(),role:`user`,content:i,timestamp:Date.now(),attachments:t?.length?t:void 0};this.#D&&!n?.steer?(this.#b.push(a),this.#z()):this.#_e(a),n?.steer?this.#t.sendMessage(i,a.id,a.attachments,{steer:!0}):this.#t.sendMessage(i,a.id,a.attachments),this.#U();try{let e=n?.dictation?m(i):i;this.#g?.(e,a.id,a.attachments)}catch(e){console.error(`onLocalUserMessage hook threw`,e)}}#H(e){return f(e,p())}#U(){if(this.#l)try{let e=this.#l();if(!e)return;ge(e.scoopName,e.model)}catch{}}addLickMessage(e,t,n,r,i){let a=this.#y[this.#y.length-1];if(!(i||a?.lickId)&&a&&a.source===`lick`&&a.channel===n){a.lickParts=[...a.lickParts??[a.content],t],a.lickCount=a.lickParts.length,a.content+=`\n\n${t}`,this.#ve(a);return}this.#_e({id:e,role:`user`,content:t,timestamp:r,source:`lick`,channel:n,lickId:i,lickState:i?`pending`:void 0,queued:this.#D?!0:void 0})}updateLickState(e,t){let n=this.#y.find(t=>t.lickId===e);n&&(n.lickState=t,this.#ve(n))}setProcessing(e){if(this.#D!==e){this.#D=e,e&&(this.#w=null),e&&(this.#k=0,this.#W(`thinking`)),e&&this.#R(),e||(this.#x&&(this.#x=null,this.#B()),this.#K()),this.#n?.(e);try{this.#_?.(e)}catch(e){console.error(`onLocalProcessingChange hook threw`,e)}e||this.#G()}}#W(e){this.#O!==e&&(this.#O=e,this.#r?.(e))}#G(){let e=this.#w;if(this.#w=null,!this.#c)return;let t=e?this.#he(e):null;this.#c(t?{...t}:null)}#K(){let e=this.#y[this.#y.length-1];if(!(e?.role===`assistant`&&!e.isStreaming)){this.#A?.remove();return}this.#A??=wl({getMessages:()=>this.getMessages()}),(this.#e.inner??this.#e).append(this.#A)}#q(e){switch(e.type){case`message_start`:this.#J(e.messageId);break;case`content_delta`:this.#Y(e.messageId,e.text);break;case`content_done`:this.#Z(e.messageId,e.model,e.usage);break;case`tool_use_start`:this.#$(e.messageId,e.toolName,e.toolInput,e.toolCallId);break;case`tool_result`:this.#te(e.messageId,e.toolName,e.result,e.isError,e.toolCallId);break;case`tool_ui`:this.#se(e.messageId,e.requestId,e.html);break;case`tool_ui_done`:this.#ce(e.requestId);break;case`tool_progress`:this.#le(e.messageId,e.toolName,e.progress,e.toolCallId);break;case`turn_end`:this.#ie(e.messageId);break;case`compaction_notice`:this.#ne(e.messageId,e.marker);break;case`error`:this.#ae(e.error)}}#J(e){this.setProcessing(!0),this.#C=e,this.#w=e,this.#_e({id:e,role:`assistant`,content:``,timestamp:Date.now(),isStreaming:!0,toolCalls:[]})}#Y(e,t){this.#he(e)&&(this.#T+=t,!this.#E&&(this.#E=!0,requestAnimationFrame(()=>this.#X(e))))}#X(e){if(this.#E=!1,!this.#T)return;let t=this.#he(e);t&&(t.content+=this.#T,this.#T=``,this.#ve(t))}#Z(e,t,n){let r=this.#he(e);r&&(t&&(r.model=t),n&&(r.usage=n),this.#T&&this.#C===e&&(r.content+=this.#T),this.#T=``,this.#E=!1,r.isStreaming=!1,this.#ve(r))}static#Q(e,t){return`${e}:${t}`}#$(t,n,r,i){let a=this.#he(t);if(!a)return;a.toolCalls=a.toolCalls??[];let o=i?e.#Q(t,i):$();this.#P.add(o),a.toolCalls.push({id:o,name:n,input:r}),this.#k+=1,this.#W(`tool`),this.#ve(a)}#ee(t,n,r){let i=t?.toolCalls??[];if(r){let n=t?e.#Q(t.id,r):void 0;return i.find(e=>e.id===n)??i.find(e=>e.id===r)}return[...i].reverse().find(e=>e.name===n&&e.result===void 0)}#te(e,t,n,r,i){let a=this.#he(e),o=this.#ee(a,t,i);!a||!o||(o.result=n,o.isError=r,o.id&&(this.#N.delete(o.id),this.#fe()),this.#k=Math.max(0,this.#k-1),this.#k===0&&this.#W(`thinking`),this.#ve(a))}#ne(e,t){let n=this.#he(e);if(t.state===`discarded`){n&&this.#re(n);return}if(n){n.compaction=t,this.#ve(n);return}this.#_e({id:e,role:`assistant`,content:``,timestamp:Date.now(),compaction:t})}#re(e){this.#be(),this.#s?.(e.id);for(let t of this.#S.get(e.id)??[])t.remove();this.#S.delete(e.id),this.#y=this.#y.filter(t=>t!==e),this.#xe(),this.#de()}#ie(e){let t=this.#he(e);t?.isStreaming&&(t.isStreaming=!1,this.#ve(t)),this.#C=null,this.setProcessing(!1)}#ae(e){this.setProcessing(!1),this.#_e({id:$(),role:`assistant`,content:e,timestamp:Date.now(),error:!0}),this.#oe(e)}#oe(e){try{if(he(e))return;_e(`error-card`,e)}catch{}}#se(e,t,n){if(this.#F)return;this.#pe(t);let r=document.createElement(`div`);if(r.className=`msg__dip`,r.setAttribute(`data-tool-ui-request`,t),(this.#e.inner??this.#e).append(r),this.#m){let e=F(r,El(n),()=>{},!1);this.#M.set(t,{instance:e,container:r});return}let i=F(r,n,(e,n)=>{this.#p?.(t,e,n)},!1);this.#M.set(t,{instance:i,container:r}),this.#p?.(t,pe,void 0)}#ce(e){this.#pe(e)}#le(e,t,n,r){let i=this.#he(e),a=this.#ee(i,t,r);a?.id&&(n.phase===`end`?this.#N.delete(a.id):this.#N.set(a.id,n),this.#ue(a.id),this.#fe())}#ue(e){let t=this.#e.querySelector(`slicc-action-row[data-tool-id="${CSS.escape(e)}"]`);t&&Dt(t,this.#N.get(e)??null),this.#de()}#de(){let e=this.#e.querySelectorAll(`slicc-tool-cluster`);for(let t of e){let e=[...t.querySelectorAll(`slicc-action-row[data-tool-id]`)].filter(e=>e.dataset.toolId&&this.#P.has(e.dataset.toolId)).map(e=>{let t=e.dataset.toolId,n=e.getAttribute(`result`);return{done:n!==null&&n!==`…`,fraction:this.#N.get(t)?.fraction}});Et(t,Rt(e))}}#fe(){let e=null,t=[...this.#N.values()];t.length>0&&t.every(e=>typeof e.fraction==`number`)&&(e=t.reduce((e,t)=>e+t.fraction,0)/t.length),e!==this.#a&&(this.#a=e,this.#i?.(e))}#pe(e){let t=this.#M.get(e);if(t){this.#M.delete(e);try{t.instance.dispose()}catch{}t.container.remove()}}#me(e){if(this.#D)return;let t=e.detail?.messageId??null,n=this.#y.length;if(t){let e=this.#y.findIndex(e=>e.id===t);e>=0&&(n=e)}let r=n>0?this.#y[n-1]:void 0;if(r&&r.source===`lick`&&!r.queued){this.#t.sendMessage(r.content,$(),r.attachments);return}let i;for(let e=n-1;e>=0;e--){let t=this.#y[e];if(t.role===`user`&&t.source!==`lick`&&t.source!==`delegation`&&!t.queued){i=t;break}}i&&this.#t.sendMessage(i.content,$(),i.attachments)}#he(e){return this.#y.find(t=>t.id===e)}#ge(e){try{return kt(e,{readOnly:this.#F})}catch(t){console.error(`[wc-chat] message render failed — degrading to plain bubble`,t);let n=document.createElement(e.role===`assistant`?`slicc-agent-message`:`slicc-user-message`);return n.setAttribute(`text`,String(e.content??``)),[n]}}#_e(e){this.#be(),this.#y.push(e);let t=this.#ge(e);this.#S.set(e.id,t),this.#e.append(...t),this.#xe(),e.isStreaming||this.#o?.(e,t),e.role===`user`?this.#Ce():this.#we()}#ve(e){this.#be(),this.#s?.(e.id);let t=this.#S.get(e.id)??[],n=this.#ge(e),r=t[0]??null,i=r?.parentNode;if(i){for(let e of n)i.insertBefore(e,r);for(let e of t)e.remove()}else this.#e.append(...n);this.#S.set(e.id,n);for(let t of e.toolCalls??[])t.id&&this.#N.has(t.id)&&this.#ue(t.id);this.#xe(),this.#de(),e.isStreaming||this.#o?.(e,n),this.#we()}#ye(){return this.#e.inner??this.#e}#be(){St(this.#ye(),this.#j)}#xe(){Ot(this.#ye(),{openClusterAnchors:this.#j,toolCallLookup:(e,t)=>this.#Se(e,t)})}#Se(e,t){return this.#y.find(t=>t.id===e)?.toolCalls?.find(e=>e.id===t)}#Ce(){this.#e.scrollTop=this.#e.scrollHeight}#we(){let e=this.#e;typeof e.requestFollow==`function`?e.requestFollow():this.#Ce()}};function kl(e,n,i,a,o,s){let c=new Map;l(async()=>{let{loadDipStyles:e}=await import(`./legacy-styles-B3nS5QUo.js`);return{loadDipStyles:e}},__vite__mapDeps([52,13])).then(({loadDipStyles:e})=>e()).catch(()=>void 0);let u=[];i.subscribeList(e=>{u=e});let d=()=>n.addressableUnitId?n.addressableUnitId():a()?.id??null,f=xl(i,{getSelectedId:d,onError:e=>n.emitAgentError(e),onEvent:e=>n.onAgentEvent(e)});f.onEvent(t=>{(t.type===`tool_use_start`||t.type===`tool_result`)&&(t.type===`tool_result`&&t.isError&&e.switcher.glower(),l(async()=>{let{playCue:e}=await import(`./soundscape-lMcnjSro.js`);return{playCue:e}},__vite__mapDeps([53,1,46,8,12,13,14,15,16,17,18,19,20,21,22,23,24,3,25,26,27,28,29,30,31,32,34])).then(({playCue:e})=>e(t.type===`tool_use_start`?`tool-start`:`tool-finish`)).catch(()=>void 0))});let p=new Ol({thread:e.thread,agent:f,resolveTelemetryContext:()=>{let e=a();if(!e)return null;let n=en(e);try{let i=Xt(u,e.id);return{scoopName:n,model:(i?r(i.id,i.provider):t()).id}}catch{return{scoopName:n,model:``}}},onTurnComplete:e=>{n.speaksReplies&&l(async()=>{let{consumeVoiceSubmission:e,speakReplyMarkdown:t}=await import(`./voice-reply-oNIB61T4.js`);return{consumeVoiceSubmission:e,speakReplyMarkdown:t}},__vite__mapDeps([54,1,46,8,12,13,14,15,16,17,18,19,20,21,22,23,24,3,25,26,27,28,29,30,31,32,34,55,56,57,58,59])).then(async({consumeVoiceSubmission:t,speakReplyMarkdown:n})=>{if(!t())return;let{endVoiceTurn:r,setTtsActive:i}=await l(async()=>{let{endVoiceTurn:e,setTtsActive:t}=await import(`./soundscape-lMcnjSro.js`);return{endVoiceTurn:e,setTtsActive:t}},__vite__mapDeps([53,1,46,8,12,13,14,15,16,17,18,19,20,21,22,23,24,3,25,26,27,28,29,30,31,32,34]));try{if(e?.content){i(!0);try{await n(e.content)}finally{i(!1)}}}finally{r()}}).catch(()=>void 0)},onProcessingChange:t=>{e.frame.toggleAttribute(`data-processing`,t),e.inputCard.querySelector(`slicc-send-button`)?.toggleAttribute(`busy`,t),t||o?.()},onBusyPhaseChange:t=>{e.inputCard.querySelector(`slicc-send-button`)?.setAttribute(`phase`,t)},onToolProgressChange:t=>{let n=e.inputCard.querySelector(`slicc-send-button`);n&&(t===null?n.removeAttribute(`progress`):n.setAttribute(`progress`,t.toFixed(3)))},onMessageDisposed:e=>{let t=c.get(e);t&&(ir(t),c.delete(e))},onMessageRendered:(e,t)=>{let r=t[0];if(!r)return;n.onMessageRendered?.(r);let i=d()??void 0;c.set(e.id,rr(r,(e,t)=>{let r={type:`sprinkle`,sprinkleName:`inline`,timestamp:new Date().toISOString(),body:{action:e,data:t}};s?.intercept?.(r)||n.sendSprinkleLick(`inline`,{action:e,data:t},void 0,i)}))},onQueuedChange:t=>e.queuedStack.setMessages(t),onLickBackpressureChange:t=>{e.lickBackpressureNotice.textContent=t?.text??``,e.lickBackpressureNotice.toggleAttribute(`hidden`,t===null)},onToolUiAction:(e,t,r)=>{n.sendToolUiAction(e,t,r)},onQueuedCancel:e=>{let t=a()?.id;t&&n.deleteQueuedMessage(t,e).catch(()=>void 0)},...n.readOnlyToolUi?{readOnlyToolUi:!0}:{}});return e.queuedStack.addEventListener(`slicc-queued-remove`,e=>{let t=e.detail?.id;if(!t)return;p.removeQueuedMessage(t);let r=a()?.id;r&&n.deleteQueuedMessage(r,t).catch(()=>void 0)}),{controller:p,agentHandle:f}}function Al(e,t){let n=new bl,r=()=>{let r=t.currentUnits(),i=e.getSelected()?.id;e.refs.switcher.scoops=qt(r,i,xt,n.sync(r,i)),e.refreshConeActions?.()};return e.refreshScoops=r,t.subscribeList(()=>r()),r}function jl(e,t,n){let{refs:r}=e;e.setChatTransport(t,n);let{controller:i,agentHandle:a}=kl(r,n,t,()=>e.getSelected(),n.onTurnIdle,n.welcome);e.setController(i);let o=Al(e.wiring,t);return r.switcher.addEventListener(`slicc-scoop-select`,n=>{let r=n.detail?.key,i=t.currentUnits().find(e=>e.id===r);i&&i.id!==e.getSelected()?.id&&e.selectScoop(i)}),r.switcher.setAttribute(`gaze-target`,`slicc-input-card`),r.inputCard.addEventListener(`input`,()=>{r.switcher.scrutinize(),r.switcher.wake()}),r.inputCard.addEventListener(`submit`,t=>{let a=Pt(t),o=n.takeAttachments?.();if(!a&&!o?.length)return;e.wiring.awaitingInput=null,e.wiring.refreshScoops?.(),e.wiring.notifyScoopStateChanged?.();let s=t.detail?.source===`dictation`;s&&n.speaksReplies&&(l(async()=>{let{markVoiceSubmission:e}=await import(`./voice-reply-oNIB61T4.js`);return{markVoiceSubmission:e}},__vite__mapDeps([54,1,46,8,12,13,14,15,16,17,18,19,20,21,22,23,24,3,25,26,27,28,29,30,31,32,34,55,56,57,58,59])).then(({markVoiceSubmission:e})=>e()).catch(()=>void 0),l(async()=>{let{beginVoiceTurn:e,playCue:t}=await import(`./soundscape-lMcnjSro.js`);return{beginVoiceTurn:e,playCue:t}},__vite__mapDeps([53,1,46,8,12,13,14,15,16,17,18,19,20,21,22,23,24,3,25,26,27,28,29,30,31,32,34])).then(({beginVoiceTurn:e,playCue:t})=>{e(),t(`sent`)}).catch(()=>void 0)),i.sendUserMessage(a??``,o,{dictation:s,steer:Ct(t)}),r.inputCard.clear?.();let c=e.getSelected()?.id;c&&(r.switcher.setAttribute(`attention`,c),e.wiring.lastActivity.set(c,(a??``).slice(0,600)))}),r.inputCard.addEventListener(`stop`,()=>{e.getController()?.processing&&a.stop()}),{agentHandle:a,controller:i,publishStrip:o}}var Ml=e({floatKindForRuntimeMode:()=>Fl,floatLabelForKind:()=>Pl,resolveStandaloneFloatKind:()=>Il}),Nl={"slicc-server":`sliccstart`,"slicc-node-server":`npx`};function Pl(e){return _(e)}function Fl(e){switch(e){case`extension`:case`extension-detached`:return`extension`;case`cherry`:return`cherry`;case`hosted-leader`:return`hosted`;case`electron-overlay`:return`electron`;case`follower`:return`standalone`;default:return`standalone`}}async function Il(e){let t=e?.fetchFn??fetch,n=e?.timeoutMs??1500;try{let e=new AbortController,r=setTimeout(()=>e.abort(),n),i=await t(le(`/api/status`),{cache:`no-store`,signal:e.signal,headers:ue()}).finally(()=>clearTimeout(r));if(!i.ok)return`standalone`;let a=await i.json();return(a.service?Nl[a.service]:void 0)??`standalone`}catch{return`standalone`}}function Ll(e,t){let n=t.label??Pl(t.floatKind);e.setAttribute(`label`,n),e.setAttribute(`float-kind`,t.floatKind);let r=it(),i=xe(),a=()=>{let t=Rl(r,i);e.setAttribute(`connection`,t.connection),t.trayRole===`none`?e.removeAttribute(`tray-role`):e.setAttribute(`tray-role`,t.trayRole)},o=nt(e=>{r=e,a()}),s=ye(e=>{i=e,a()});return a(),()=>{o(),s()}}function Rl(e,t){return e.state===`inactive`?t.state===`inactive`?{connection:`offline`,trayRole:`none`}:{connection:Bl(t),trayRole:`follower`}:{connection:zl(e),trayRole:`leader`}}function zl(e){switch(e.state){case`connecting`:return`connecting`;case`leader`:return`live`;case`reconnecting`:return`reconnecting`;case`error`:return`error`;default:return`offline`}}function Bl(e){if(e.stalled)return`stalled`;switch(e.state){case`connecting`:return`connecting`;case`connected`:return`live`;case`reconnecting`:return`reconnecting`;case`error`:return`error`;default:return`offline`}}async function Vl(e,t,n){let r=n.floatLabel??Pl(n.floatKind),i=vd(e,r);Ll(i.refs.floatbar,{floatKind:n.floatKind,label:r});let a=await n.connect(i),o=jl(i,a.client,a.host);return await a.workbench?.(i,o),t.info(`WC shell mounted`,{floatKind:n.floatKind}),{boot:i,chat:o}}var Hl=36e5,Ul=2e3,Wl=class{#e=[];#t;#n;constructor(e=Hl,t=Ul){this.#t=Math.max(1,Math.floor(e)),this.#n=Math.max(2,Math.floor(t))}get windowMs(){return this.#t}push(e){this.#e.push(e);let t=e.at-this.#t;for(;this.#e.length>0&&this.#e[0].at<t;)this.#e.shift();for(;this.#e.length>this.#n;)this.#e.shift()}get size(){return this.#e.length}series(e){if(!(this.#e.length<2))return{points:this.#e.map(t=>({at:t.at,value:t[e]})),windowMs:this.#t}}peak(e){return this.#e.length===0?null:this.#e.reduce((t,n)=>Math.max(t,n[e]),-1/0)}windowLabel(){if(this.#e.length<2)return null;let e=this.#e[this.#e.length-1].at-this.#e[0].at,t=Math.max(1,Math.round(e/1e3));if(t<90)return`last ${t}s`;let n=Math.round(t/60);return n<90?`last ${n}m`:`last ${Math.round(n/60)}h`}},Gl=64,Kl=12,ql=/\b(feedback|reviews?|corrections?|learnings?|observations?|testing|verification)\b/i,Jl=/\b(user|preferences?|identit(?:y|ies)|accounts?|personal|interface|working rhythm|keyboard|accessibility)\b/i,Yl=/^Auto-extracted \(/;function Xl(e){let t=document.createRange();return t.selectNodeContents(document.body),t.createContextualFragment(e)}function Zl(e){return(Xl(zt(e)).textContent??``).replace(/\s+/g,` `).trim()}function Ql(e){let t=Zl(e);if(t.length<=Gl)return{title:t,summary:``,titleEnd:t.length,summaryStart:t.length};let n=[];for(let e of t.matchAll(/[.!?](?:[*_`'")\]]*)\s+|\s+[—–]\s+|[:;](?:[*_`]*)\s+|,\s+(?=(?:and|but|because|while|when|then|so)\b)/g)){let r=/^\s+[—–]|^[:;]/.test(e[0]),i=e.index+(r?0:e[0].trimEnd().length),a=e.index+e[0].length;t.slice(0,i).trim().length>=Kl&&i<=96&&t.slice(a).trim()&&n.push({titleEnd:i,summaryStart:a})}let r=n.sort((e,t)=>Math.abs(e.titleEnd-Gl)-Math.abs(t.titleEnd-Gl))[0];if(r)return{title:t.slice(0,r.titleEnd).trim(),summary:t.slice(r.summaryStart).trim(),titleEnd:r.titleEnd,summaryStart:r.summaryStart};let i=t.slice(0,97).lastIndexOf(` `),a=i>=Kl?i:96,o=t.slice(a).trim();return{title:t.slice(0,a).trim(),summary:o,titleEnd:a,summaryStart:t.indexOf(o,a)}}function $l(e,t){let n=Zl(e),r=Yl.test(t),i=r?n:`${t} ${n}`;return ql.test(i)?`feedback`:Jl.test(i)?`user`:r?null:`project`}function eu(e,t){let n=Ql(e);return{title:n.title,summary:n.summary,section:t,tag:$l(e,t),bodyHtml:zt(e),titleEnd:n.titleEnd,summaryStart:n.summaryStart}}function tu(e){let t=[],n=`Memory`,r=``,i=``,a=null,o=()=>[r||n,i].filter(Boolean).join(` / `),s=()=>{if(!a)return;let e=a.lines.join(` `).trim();e&&t.push(eu(e,a.section)),a=null};for(let t of e.split(`
|
|
400
|
-
`)){let e=/^(#{1,6})\s+(.+?)\s*#*\s*$/.exec(t.trim());if(e){s();let t=Zl(e[2]);e[1].length===1?(n=t||n,r=``,i=``):e[1].length===2?(r=t,i=``):e[1].length===3&&(i=t);continue}let c=/^\s*[-*]\s+(.*)$/.exec(t);c?(s(),a={lines:[c[1]],section:o()}):t.trim()?a?a.lines.push(t.trim()):a={lines:[t.trim()],section:o()}:s()}return s(),t}function nu(e,t){let n=document.createTreeWalker(e,NodeFilter.SHOW_TEXT),r=0,i=!1,a=!1,o=null,s=n.nextNode();for(;s;){for(let e=0;e<s.data.length;e+=1){if(/\s/.test(s.data[e])){i&&!a&&(a=!0,o={node:s,offset:e});continue}if(a){if(r===t)return o;r+=1}if(a=!1,o=null,r===t)return{node:s,offset:e};r+=1,i=!0}s=n.nextNode()}return r===t?{node:e,offset:e.childNodes.length}:null}function ru(e,t,n){let r=Xl(e),i=nu(r,t),a=n==null?{node:r,offset:r.childNodes.length}:nu(r,n);if(!i||!a)return document.createDocumentFragment();let o=document.createRange();o.setStart(i.node,i.offset),o.setEnd(a.node,a.offset);let s=o.cloneContents();for(let e of[...s.childNodes])e.nodeType===Node.TEXT_NODE&&!e.textContent?.trim()&&e.remove();let c=s.childNodes.length===1?s.firstChild:null;if(!(c instanceof HTMLParagraphElement))return s;let l=document.createDocumentFragment();return l.append(...c.childNodes),l}function iu(e){return tu(e).map(e=>{let t=document.createElement(`slicc-memrow`);return t.setAttribute(`heading`,e.title),e.summary&&t.setAttribute(`summary`,e.summary),t.setAttribute(`section`,e.section),e.tag&&t.setAttribute(`tag`,e.tag),t.setHeadingContent(ru(e.bodyHtml,0,e.titleEnd)),e.summary&&t.setBodyContent(ru(e.bodyHtml,e.summaryStart,null)),t})}async function au(e,t=I.memoryPath){let n=``;try{let r=await e.readFile(t,{encoding:`utf-8`});n=typeof r==`string`?r:new TextDecoder().decode(r)}catch{n=``}return iu(n)}function ou(e){let t=e.filter(e=>e.health===`stalled`).length,n=e.filter(e=>e.health!==`stalled`&&e.peerState===`connecting`).length,r=e.length-t-n,i=[r>0?`${r} connected`:``,n>0?`${n} connecting`:``,t>0?`${t} stalled`:``].filter(Boolean);return{id:`followers`,label:`Followers`,icon:`radio`,count:e.filter(e=>e.peerState===`connected`).length,meta:i.join(` · `)||`none paired`,accent:`cyan`,emptyText:`No followers connected yet. Pair a phone, tablet, or CLI follower to this tray.`,rows:e.map(e=>{let t=e.motd??e.runtime??`Connected follower`,n=e.hostOrigin?`${t} · ${e.hostOrigin}`:t,r=[e.exec?`ssh`:``,e.cdp?`playwright`:``].filter(Boolean);return{name:eo(e),sublabel:n,meta:Qa(e),icon:Ya(e),badges:r,status:Za(e)}})}}function su(e){return e.stalled||e.state===`reconnecting`?`warn`:e.state===`error`?`error`:e.state===`leader`||e.state===`connected`?`active`:`idle`}function cu(e){return e.stalled?`stalled`:e.state===`leader`?`connected`:e.state}function lu(e){let t=cu(e),n=e.sessionId?`Session ${qa(e.sessionId)}`:null,r=e.workerBaseUrl?`Worker · ${e.workerBaseUrl}`:null;return{id:`tray`,label:`Tray`,icon:e.role===`follower`?`radio`:`cloud`,count:1,meta:`${e.role} · ${t}`,accent:`waffle`,status:su(e),rows:[{name:e.role[0].toUpperCase()+e.role.slice(1),sublabel:[n,r].filter(Boolean).join(` · `)||`No tray session`,meta:t,icon:e.role===`follower`?`radio`:`cloud`,badges:e.joinUrl?[`join URL`]:[],status:su(e)}]}}function uu(e,t){let n=e.filter(e=>D(e)),r=t=>e.filter(e=>!D(e)&&e.parentJid===t),i=(e,n)=>{let r=t(e.jid);return{name:D(e)?`${e.name||`sliccy`} (cone)`:e.name,meta:r?`working`:`idle`,active:r,depth:n}},a=n.flatMap(e=>[i(e,0),...r(e.jid).map(e=>i(e,1))]),o=new Set(a.map(e=>e.name));for(let t of e){let e=i(t,0);o.has(e.name)||a.push(e)}let s=e.filter(e=>t(e.jid)).length;return{id:`scoops`,label:`Scoops`,icon:`bot`,count:e.length,meta:`${e.length} · ${s} working`,accent:`violet`,status:`active`,emptyText:`Delegate a focused task and its scoop will show up here.`,rows:a}}function du(e){let t=e.filter(e=>e.valid===!1).length;return{id:`mounts`,label:`Mounts`,icon:`hard-drive`,count:e.length,meta:t>0?`${e.length} · ${t} need${t===1?`s`:``} re-grant`:`${e.length} · all granted`,status:t>0?`warn`:`active`,emptyText:`Mount a folder to give the workspace access to files on disk.`,rows:e.map(e=>({name:e.targetPath,meta:e.valid===!1?`permission lost`:e.descriptor.kind,status:e.valid===!0?`active`:e.valid===!1?`warn`:`idle`}))}}function fu(e,t){let n=t.filter(e=>e.valid===!1).length,r=e.reduce((e,[,t])=>e+(t.tools?.length??0),0),i=[`${e.length} server${e.length===1?``:`s`}`,`${r} tool${r===1?``:`s`}`,n>0?`${n} account expired`:`${t.length} accounts valid`].join(` · `);return{id:`integrations`,label:`Integrations`,icon:`blocks`,count:e.length+t.length,meta:i,accent:`waffle`,status:n>0?`error`:`active`,emptyText:`Connect an MCP server or a provider account to extend the workspace.`,rows:[...e.map(([e,t])=>{let n=t.tools?.length??0;return{name:e,meta:`MCP · ${n} tool${n===1?``:`s`}`,status:`active`}}),...t.map(e=>({name:e.providerId,meta:e.valid===!1?`session expired`:`account`,status:e.valid===!0?`active`:e.valid===!1?`error`:`idle`}))]}}function pu(e,t){let n=[`${t.length} webhook${t.length===1?``:`s`}`,e.length>0?`${e.length} cron task${e.length===1?``:`s`}`:`no cron tasks`].join(` · `);return{id:`automations`,label:`Automations`,icon:`calendar-clock`,count:e.length+t.length,meta:n,accent:`amber`,emptyText:`Scheduled tasks and webhook-driven licks will appear here.`,rows:[...e.map(e=>({name:e.name,meta:e.cron,status:e.status===`active`?`active`:`idle`})),...t.map(e=>({name:e.name,meta:e.scoop?`→ ${e.scoop}`:`→ cone`,status:`idle`}))]}}function mu(e){let t=ke({percent:e.percent,status:e.status});return t===`critical`?`error`:t===`warn`?`warn`:`active`}function hu(e,t){let n=`${De(e.percent)}% used`,r=Oe(e.resetsAt,t);return{name:`${e.window[0]?.toUpperCase()??``}${e.window.slice(1)} budget`,sublabel:e.providerId?`${e.providerId} · rolling window`:`rolling window`,meta:e.status===`rate-limited`?`rate-limited · ${n}`:n,badges:r?[r]:void 0,status:mu(e)}}function gu(e,t){let n=e?.budget,r=e?.models??[],i=e?`$${e.totalCost.toFixed(2)} across ${r.length} models`:``,a=n?[n.status===`rate-limited`?`rate-limited`:``,`${De(n.percent)}% of ${n.window} budget`,i].filter(Boolean).join(` · `):e?i:`no spend yet`;return{id:`cost`,label:`Cost`,icon:`receipt`,count:r.length,meta:a,accent:`rose`,status:n?mu(n):void 0,emptyText:`Model usage will be summarized after the first turn.`,rows:[...n?[hu(n,t)]:[],...r.map(e=>({name:e.model,meta:`$${e.cost.toFixed(4)}`,status:`idle`}))]}}function _u(e){let t=[],n=vu(e.budget,e.now??Date.now());n&&t.push(n);for(let n of e.oauthProviders)n.valid===!1&&t.push({id:`oauth:${n.providerId}`,severity:`error`,icon:`key-round`,title:`${n.providerId} session expired`,detail:`Tool calls through this provider will fail until it is signed in again.`});let r=su(e.tray);(r===`error`||r===`warn`)&&t.push({id:`tray`,severity:r===`error`?`error`:`warn`,icon:`cloud-off`,title:`Tray ${cu(e.tray)}`,detail:e.tray.workerBaseUrl?`Worker · ${e.tray.workerBaseUrl}`:`No tray session is established.`});for(let n of e.followers)Za(n)===`warn`&&t.push({id:`follower:${n.runtimeId}`,severity:`warn`,icon:`radio`,title:`${eo(n)} stopped answering`,detail:n.motd??n.runtime??`No heartbeat from this follower.`,age:Qa(n)});for(let n of e.mounts)n.valid===!1&&t.push({id:`mount:${n.targetPath}`,severity:`warn`,icon:`folder-lock`,title:`${n.targetPath} needs re-grant`,detail:`File System Access permission is no longer granted for this handle.`});return t.sort((e,t)=>e.severity===t.severity?0:e.severity===`error`?-1:1)}function vu(e,t){if(!e||ke({percent:e.percent,status:e.status})===`ok`)return null;let n=Oe(e.resetsAt,t),r=`${De(e.percent)}%`;if(e.status===`rate-limited`)return{id:`budget:rate-limited`,severity:`error`,icon:`octagon-alert`,title:`${e.window} budget is rate-limited`,detail:`The provider is refusing calls until the window resets. ${r} of the allowance is used.`,age:n};let i=e.percent>=95;return{id:`budget:near-limit`,severity:i?`error`:`warn`,icon:`gauge`,title:`${r} of the ${e.window} budget used`,detail:i?`Past 95% of the allowance — calls may start being refused.`:`Past 80% of the allowance. Long runs may not finish before it resets.`,age:n}}function yu(e){return e>=100?`$${Math.round(e)}`:`$${e.toFixed(2)}`}function bu(e){let{stats:t,workingUnits:n,totalUnits:r,liveProcesses:i,terminated:a,history:o}=e,s=o?.windowLabel(),c=t?.burnRate??0,l=t?.fills??[],u=l.reduce((e,t)=>Math.max(e,t.fill),0),d=t?.budget,f=[{id:`burn`,label:`Burn rate`,value:yu(c),unit:`/hour`,hero:!d,accent:d?`rose`:void 0,series:o?.series(`burnRate`),foot:[t?`$${t.totalCost.toFixed(2)} this session`:`no spend yet`,s].filter(Boolean).join(` · `)},{id:`load`,label:`Agent load`,value:String(n),unit:`of ${r} working`,accent:`violet`,series:o?.series(`workingUnits`),foot:s??void 0}];return d||f.push({id:`processes`,label:`Live processes`,value:String(i),unit:i===1?`process`:`processes`,accent:`cyan`,series:o?.series(`liveProcesses`),foot:a>0?`${a.toLocaleString()} exited this session`:s??void 0}),l.length>0&&f.push({id:`context`,label:`Context fill`,value:String(Math.round(u*100)),unit:`%`,ratio:u,markers:Su(l,e.units??[]),accent:u>=.9?`rose`:u>=.7?`amber`:`green`,foot:`fullest of ${l.length} context window${l.length===1?``:`s`}`}),d?[xu(d,t,e.now??Date.now()),...f]:f}function xu(e,t,n){let r=ke({percent:e.percent,status:e.status});return{id:`budget`,label:`${e.window[0]?.toUpperCase()??``}${e.window.slice(1)} budget`,value:De(e.percent),unit:`% used`,hero:!0,ratio:Math.min(1,Math.max(0,e.percent/100)),accent:r===`critical`?`rose`:r===`warn`?`amber`:`green`,foot:[e.status===`rate-limited`?`rate-limited`:``,Oe(e.resetsAt,n)??``,t?`$${t.totalCost.toFixed(2)} this session`:``].filter(Boolean).join(` · `)}}function Su(e,t){let n=new Map(t.map(e=>[e.jid,e]));return e.map(({jid:e,fill:t})=>{let r=n.get(e),i=r?D(r):!1,a=r?.name||(r?`sliccy`:e);return{id:e,ratio:t,color:xt({isRoot:i,name:a}),label:`${i?`${a} (cone)`:a} — ${Math.round(t*100)}% full`}})}var Cu={running:`R`,pending:`S`,exited:`Z`,killed:`K`};function wu(e,t){if(!e)return;let n=Math.max(0,Math.round((t-e)/1e3));if(n<60)return`${n}s`;let r=Math.floor(n/60);return r<60?`${r}m ${n%60}s`:`${Math.floor(r/60)}h ${r%60}m`}function Tu(e,t){return{pid:e.pid,ppid:e.ppid,state:Cu[e.status]??`?`,status:e.status,command:e.argv,scoop:e.scoop,started:e.startedAt?new Date(e.startedAt).toTimeString().slice(0,5):void 0,elapsed:wu(e.startedAt,t)}}async function Eu(e,t){let n=e.getScoops(),r=e.getTrayInfo(),i=e.getConnectedFollowers(),[a,o,s,c,l,u]=await Promise.all([e.getCronTasks().catch(()=>[]),e.getWebhooks().catch(()=>[]),e.getMounts().catch(()=>[]),e.getMcpServers().catch(()=>({})),e.getSessionStats().catch(()=>null),e.getProcesses().catch(()=>({processes:[],terminated:0}))]),{processes:d,terminated:f}=u,p=e.getOAuthProviders(),m=Object.entries(c),h=n.filter(t=>e.isProcessing(t.jid)).length,g=Date.now();return t?.push({at:g,burnRate:l?.burnRate??0,workingUnits:h,liveProcesses:d.length}),{updated:`Streaming · updated just now`,vitals:bu({stats:l,workingUnits:h,totalUnits:n.length,liveProcesses:d.length,terminated:f,history:t,units:n,now:g}),alerts:_u({tray:r,followers:i,mounts:s,oauthProviders:p,budget:l?.budget,now:g}),sections:[lu(r),ou(i),uu(n,t=>e.isProcessing(t)),du(s),fu(m,p),pu(a,o),gu(l,g)],processes:{rows:d.map(e=>Tu(e,g)),terminated:f}}}var Du=`/shared`,Ou=3,ku=200;async function Au(e,t,n){let r;try{r=await e.readDir(t)}catch{return[]}let i=r.filter(e=>e.type===`directory`).sort((e,t)=>e.name.localeCompare(t.name)),a=r.filter(e=>e.type===`file`).sort((e,t)=>e.name.localeCompare(t.name)),o=[...i,...a].slice(0,ku),s=new Map,c=[];for(let e of o){if(e.type!==`file`)continue;let n=`${t}/${e.name}`;e.size===void 0?c.push(n):s.set(n,e.size)}let l=await Promise.allSettled(c.map(t=>e.stat(t)));c.forEach((e,t)=>{let n=l[t];n?.status===`fulfilled`&&s.set(e,n.value.size)});let u=[];for(let r of o){let i=`${t}/${r.name}`;if(r.type===`directory`)u.push({kind:`dir`,id:i,label:r.name,children:n<Ou?await Au(e,i,n+1):[]});else{let e=s.get(i);u.push({kind:`file`,id:i,label:r.name,path:i,size:e})}}return u}async function ju(e,t=I.root){let n=[];for(let r of[t,Du])n.push({kind:`dir`,id:r,label:r.replace(/^\/(cones\/)?/,``),open:!0,children:await Au(e,r,1)});return n}var Mu=200,Nu=1e3,Pu=3e3,Fu=45e3;function Iu(e){let t=null,n=!1,r=!1,i=!1,a=0,o=0,s=null,c=null,l=0,u=()=>{let t=++o;e.openFs().then(async n=>{let i=await ju(n,e.getWorkspace().root);t===o&&(e.fileTree.items=i,r||(r=!0,jt({fileTree:e.fileTree,openFs:e.openFs,openWriter:e.openWriter,insertReference:e.insertReference,toPreviewUrl:g,log:e.log})))}).catch(t=>e.log.error(`WC file tree refresh failed`,t))},d=()=>{if(!i)return;let e=Date.now();if(c==null)l=e;else if(e-l>=Nu){clearTimeout(c),c=null,u();return}c!=null&&clearTimeout(c),c=setTimeout(()=>{c=null,u()},Mu)},f=()=>{t??=setInterval(u,Pu)},p=()=>{let t=++a;s?.(),s=null;let n=[e.getWorkspace().root,Du];e.openFs().then(async e=>{if(!e.watch){t===a&&i&&f();return}let r=await e.watch(n,d);if(t!==a||!i){r();return}s=r}).catch(n=>{e.log.error(`WC file tree watch failed — falling back to polling`,n),t===a&&i&&f()})},m=()=>{n=!1,i=!1,a++,s?.(),s=null,c!=null&&(clearTimeout(c),c=null),t!=null&&(clearInterval(t),t=null)};return{open(){m(),i=!0,n=!0,e.onKernelReady(()=>{n&&(n=!1,u(),p())})},close:m,repoint(){!i||n||(u(),p())}}}function Lu(e){let t=!1,n=!1,r=!1,i=0,a=null,o=new Wl,s=Iu(e),c=()=>{a!=null&&(clearInterval(a),a=null)},l=()=>{let t=++i;e.openFs().then(async n=>{let r=await au(n,e.getWorkspace().memoryPath);t===i&&(e.memoryHost.setRows?e.memoryHost.setRows(r):e.memoryHost.replaceChildren(...r))}).catch(t=>e.log.error(`WC memory refresh failed`,t))},u=()=>{(async()=>{try{e.monitor.model=await Eu(e.getMonitorDeps(),o)}catch(t){e.log.error(`WC monitor refresh failed`,t)}})()};return e.monitor.addEventListener(`slicc-monitor-refresh`,u),{activate(i){if(i===`files`){s.open();return}if(i===`memory`){r=!0,l();return}if(i===`monitor`){c(),u(),a=setInterval(u,5e3);return}if(i===`term`&&!t){t=!0;let r=!1,i=n?null:setTimeout(()=>{r||(n=!0,t=!1,e.log.error(`WC terminal mount did not settle within ${Fu}ms; re-arming so the next term activation retries`))},Fu);e.mountTerminal(e.termSurface).catch(n=>{t=!1,e.log.error(`WC terminal mount failed`,n)}).finally(()=>{r=!0,i&&clearTimeout(i)})}},deactivate(e){e===`files`?s.close():e===`monitor`?c():e===`memory`&&(r=!1)},refreshMemory(){r&&l()},refreshFiles(){s.repoint()}}}var Ru=[`/workspace`,`/shared`,`/memory`,`/scoops`,`/mnt`],zu=new Set([`node_modules`,`.git`,`dist`,`build`,`out`,`coverage`,`.cache`,`.venv`,`venv`,`__pycache__`,`target`,`vendor`,`.next`,`.turbo`,`python_wheels`]),Bu=2e4,Vu=12,Hu=3e4;function Uu(e){let t=e.trim();for(;t.startsWith(`./`)||t.startsWith(`../`);)t=t.slice(t.startsWith(`./`)?2:3);return t.startsWith(`~/`)&&(t=t.slice(2)),t.replace(/\/{2,}/g,`/`)}function Wu(e){return e.slice(e.lastIndexOf(`/`)+1)}function Gu(e,t){return e===t?!0:e.endsWith(t)?e[e.length-t.length-1]===`/`:!1}function Ku(e,t){let n=Uu(e);return t.includes(`/`)?Gu(n,t):Wu(n)===t}function qu(e,t){let n=[],r=new Set;for(let i=t.length-1;i>=0;--i){let a=t[i];if(!(a===void 0||r.has(a))&&Ku(a,e)&&(r.add(a),n.push(Uu(a)),n.length>=Ju))break}return n}var Ju=4,Yu=class{#e;#t;#n;#r;#i;#a;#o=0;#s=null;#c=null;#l=new Map;#u=new Map;constructor(e,t={}){this.#e=e,this.#t=t.roots??Ru,this.#n=t.ignoredDirs??zu,this.#r=t.maxEntries??Bu,this.#i=t.maxDepth??Vu,this.#a=t.ttlMs??Hu}resolve(e,t=[]){this.#g();let n=Uu(e),r=this.#d(n),i=qu(n,t);return i.length===0?r:this.#f(n,r,i)}resolveAll(e,t=[]){return Promise.all(e.map(e=>this.resolve(e,t)))}invalidate(){this.#s=null,this.#c=null,this.#l.clear(),this.#u.clear()}#d(e){let t=this.#l.get(e);if(t)return t;let n=this.#m(e).catch(()=>({query:e,matches:[]}));return this.#l.set(e,n),n}async#f(e,t,n){let{matches:r}=await t,i=new Set(r),a=[];for(let e of n)!e.startsWith(`/`)||i.has(e)||await this.#p(e)&&a.push(e);let o=e=>n.findIndex(t=>Gu(e,t)),s=r.filter(e=>o(e)>=0).sort((e,t)=>o(e)-o(t)),c=new Set(s),l=r.filter(e=>!c.has(e));return{query:e,matches:[...a,...s,...l]}}#p(e){let t=this.#u.get(e);if(t)return t;let n=this.#h(e);return this.#u.set(e,n),n}async#m(e){if(e.startsWith(`/`))return{query:e,matches:await this.#h(e)?[e]:[]};let t=(await this.#_()).get(Wu(e))??[];return e.includes(`/`)?{query:e,matches:t.filter(t=>Gu(t,e)).sort(Xu)}:{query:e,matches:[...t].sort(Xu)}}async#h(e){try{return(await this.#e.stat(e)).type===`file`}catch{return!1}}#g(){!this.#s||this.#a===1/0||Date.now()-this.#o<this.#a||this.invalidate()}#_(){return this.#s?Promise.resolve(this.#s):(this.#c??=this.#v().then(e=>(this.#s=e,this.#o=Date.now(),e)),this.#c)}async#v(){let e=new Map,t={left:this.#r};for(let n of this.#t){if(t.left<=0)break;await this.#y(n,0,e,t)}return e}async#y(e,t,n,r){if(r.left<=0||t>this.#i)return;let i;try{i=await this.#e.readDir(e)}catch{return}let a=this.#b(e,i,n,r);for(let e of a){if(r.left<=0)break;await this.#y(e,t+1,n,r)}}#b(e,t,n,r){let i=[];for(let a of t){if(r.left<=0)break;let t=e===`/`?`/${a.name}`:`${e}/${a.name}`;if(a.type===`directory`){this.#n.has(a.name)||i.push(t);continue}let o=n.get(a.name);o?o.push(t):n.set(a.name,[t]),--r.left}return i}};function Xu(e,t){let n=e.split(`/`).length,r=t.split(`/`).length;return n===r?e.localeCompare(t):n-r}var Zu=`file-mention`,Qu=`data-file-mentions`;function $u(e){return`${e.childNodes.length}:${e.textContent?.length??0}`}var ed=new Set([`A`,`PRE`,`SCRIPT`,`STYLE`,`TEXTAREA`]),td=`file-mention-open`;async function nd(e,t,n=[]){let r=$u(e);if(e.getAttribute(Qu)===r)return;let i=rd(e);if(i.length===0){e.setAttribute(Qu,r);return}let a=[],o=new Set;for(let e of i){let t=Bt(e.data);if(t.length!==0){a.push({node:e,mentions:t});for(let e of t)o.add(e.path)}}if(a.length===0){e.setAttribute(Qu,r);return}let s=[...o],c=await t.resolveAll(s,n),l=new Map(s.map((e,t)=>[e,c[t]?.matches??[]]));for(let{node:e,mentions:t}of a){if(!e.isConnected)continue;let n=t.filter(e=>(l.get(e.path)?.length??0)>0);n.length!==0&&id(e,n,l)}e.setAttribute(Qu,$u(e))}function rd(e){let t=e.ownerDocument.createTreeWalker(e,NodeFilter.SHOW_TEXT,{acceptNode(t){if(!t.nodeValue||t.nodeValue.trim().length===0)return NodeFilter.FILTER_REJECT;for(let n=t.parentElement;n&&n!==e;n=n.parentElement)if(ed.has(n.tagName)||n.classList.contains(`file-mention`))return NodeFilter.FILTER_REJECT;return NodeFilter.FILTER_ACCEPT}}),n=[];for(let e=t.nextNode();e!==null;e=t.nextNode())n.push(e);return n}function id(e,t,n){let r=e.ownerDocument,i=e.data,a=r.createDocumentFragment(),o=0;for(let e of t){let t=n.get(e.path)??[],s=t[0];s&&(e.start>o&&a.appendChild(r.createTextNode(i.slice(o,e.start))),a.appendChild(ad(r,i.slice(e.start,e.end),s,t,e.line)),o=e.end)}o<i.length&&a.appendChild(r.createTextNode(i.slice(o))),e.parentNode?.replaceChild(a,e)}function ad(e,t,n,r,i){let a=e.createElement(`a`);return a.className=Zu,a.textContent=t,a.href=`#${n}`,a.dataset.path=n,i!==void 0&&(a.dataset.line=String(i)),a.title=r.length>1?`${n}\n(+${r.length-1} other match${r.length>2?`es`:``})`:n,a.addEventListener(`click`,e=>{e.preventDefault(),e.stopPropagation();let t={path:n,alternatives:r,...i===void 0?{}:{line:i}};a.dispatchEvent(new CustomEvent(td,{detail:t,bubbles:!0,composed:!0}))}),a}var od=`slicc-agent-message`,sd=`slicc-action-row[${Vt}]`;function cd(e,t){let n=[],r=e.querySelectorAll(sd);for(let e of r){if(t.compareDocumentPosition(e)&Node.DOCUMENT_POSITION_FOLLOWING)break;n.push(e.getAttribute(`data-file-paths`)??``)}return n.slice(-40).flatMap(e=>wt(e))}function ld(e){let t=globalThis.requestIdleCallback;typeof t==`function`?t(e):setTimeout(e,0)}function ud(e){try{return dd(e)}catch(t){return e.log.error(`File mention wiring failed; continuing without it`,t),()=>{}}}function dd(e){let{thread:t,openFs:n,log:r}=e;if(!(t instanceof Node))return()=>{};let i=null,a=()=>(i??=n().then(e=>new Yu(e)),i),o=e=>{if(!(e instanceof HTMLElement)||e.hasAttribute(`streaming`))return;let n=e.querySelector(`.body`)??e;Bt(n.textContent??``).length!==0&&ld(()=>{let i=cd(t,e);a().then(e=>nd(n,e,i)).catch(e=>r.error(`File mention linking failed`,e))})},s=e=>{for(let t of e.querySelectorAll(od))o(t)};s(t);let c=new MutationObserver(e=>{for(let t of e){if(t.type===`attributes`){t.target instanceof HTMLElement&&o(t.target);continue}for(let e of t.addedNodes)e instanceof HTMLElement&&(e.tagName.toLowerCase()===od?o(e):s(e));let e=t.target?.closest?.(od);e&&o(e)}});c.observe(t,{childList:!0,subtree:!0,attributes:!0,attributeFilter:[`streaming`]});let l=e=>{let{path:t,line:i}=e.detail;n().then(e=>Tt(e,t,i===void 0?{}:{line:i})).catch(e=>r.error(`File mention preview failed`,e))};return t.addEventListener(td,l),()=>{c.disconnect(),t.removeEventListener(td,l)}}var fd=e({DEFAULT_DOCK_TREE_ON_BOOT:()=>jd,DOCK_TREE_STORAGE_KEY:()=>Ad,attachWcWorkbench:()=>Pd,bootLeaderFloat:()=>Fd,makeSprinkleAttachImage:()=>Nd,prepareWcShell:()=>vd,wireDockTreePersistence:()=>Md,wireWcChipTips:()=>Td,workspaceForSelection:()=>gd});function pd(e){let{controller:t,held:n,jid:r,roster:i}=e,a=t?.stashQueued()??[];if(a.length===0)return;let o=i.find(e=>e.id===r),s=o?Ht(i,o)?.id??o.id:r;n.set(s,[...n.get(s)??[],...a])}function md(e){let{controller:t,destination:n,held:r,previousJid:i,roster:a}=e;if(i&&i!==n&&pd({controller:t,held:r,jid:i,roster:a}),a.some(e=>e.id===n))for(let e of[...r.keys()])a.some(t=>t.id===e)||r.delete(e);let o=r.get(n);o&&(r.delete(n),t?.restoreQueued(o))}function hd(e,t){let n=null,r=null;return{shownUnitId:()=>r,watch:i=>{r===i&&n||(n?.(),r=i,n=e().subscribe(i,e=>{e.type===`snapshot`&&r===i&&t(e.snapshot.messages,e.snapshot.queuedIds)}))}}}function gd(e){let{client:t,selectedId:n}=e,r=n===void 0?void 0:t.getScoop(n);return n!==void 0&&!r&&e.clearSelection(),br(t.getScoops(),r)}function _d(e){let{refs:t}=e,n=null,r=new Map;return{clear:()=>{n=null},getSelected:()=>n,holdQueue:()=>{let t=n?.id;t&&pd({controller:e.controller(),held:r,jid:t,roster:e.client().currentUnits()})},selectScoop:i=>{let a=n?.id??null;n=i;let o=Jt(Kt(i)),s=e.host();md({controller:e.controller(),destination:i.id,held:r,previousJid:a,roster:e.client().currentUnits()});let c=e.lickBackpressure.get(i.id);e.controller()?.setLickBackpressure(c?.count??0,c?.waitingMs??0,en(i)),e.controller()?.setReadOnly(o),o||t.inputCard.removeAttribute(`disabled`),Fc(t,i,e.client().currentUnits(),s.getRecord?.bind(s),{skipModelPill:s.ownsModelPill===!0}),e.client().snapshot(i.id).catch(()=>void 0),e.watchUnit(i.id),e.controller()?.setProcessing(e.client().currentUnits().find(e=>e.id===i.id)?.state===`working`),t.switcher.hasAttribute(`attention`)||t.switcher.setAttribute(`attention`,i.id),e.wiring().refreshScoops?.(),e.workbench()?.refreshMemory(),e.workbench()?.refreshFiles(),s.onSelectionApplied?.()}}}function vd(e,t){let n=At(e,{messages:[],scoops:[],floatLabel:t,placeholder:`Ask sliccy, or describe a change…`,urlState:!0}),r=null,i=null,a=yo,o=null,s=()=>o??Q(h),c=new Map,l=!1,u=null,d=new Set,f=hd(()=>s(),(e,t)=>{r?.loadMessages(e,t),a.onSnapshotRendered?.(e)}).watch,p=_d({client:s,controller:()=>r,host:()=>a,lickBackpressure:c,refs:n,watchUnit:f,wiring:()=>h,workbench:()=>u}),m=p.selectScoop,h={refs:n,statuses:new Map,fills:new Map,phases:new Map,turns:new Map,lickBackpressure:c,lastActivity:new Map,pendingUrlContext:n.thread.urlContext??null,getController:()=>r,getClient:()=>i,getSelected:()=>p.getSelected(),selectScoop:m,notifyReady:()=>{l=!0;for(let e of d)e()}};return{refs:n,wiring:h,setClient:e=>{i=e},setChatTransport:(e,t)=>{o=e,a=t},getChatHost:()=>a,selectScoop:m,getSelected:()=>p.getSelected(),clearSelection:()=>p.clear(),holdQueuedPile:()=>p.holdQueue(),watchUnit:f,getController:()=>r,setController:e=>{r=e},setActivateSurface:e=>{u=e;let t=new Set(n.dockTree.getSurfaceIds());for(let n of[`files`,`term`,`memory`,`monitor`])t.has(n)&&(l?e.activate(n):d.add(()=>e.activate(n)))},onClientReady:e=>{d.add(e),l&&e()}}}function yd(e){let t=null;return()=>(t??=(async()=>{let[{createRemoteVfsClient:t},{createRemoteWritableVfsClient:n}]=await Promise.all([l(()=>import(`./remote-vfs-client-DdFPlnwq.js`),__vite__mapDeps([60,61])),l(()=>import(`./writable-vfs-client-Czpbtd8Y.js`),__vite__mapDeps([62,61]))]);return{reader:t({transport:e.getTransport()}),writer:n({transport:e.getTransport()})}})(),t)}function bd(e,t,n,r,i){e.onClientReady(()=>{r.intercept||l(async()=>{let{wireWcOnboarding:e}=await import(`./wc-onboarding-hbn2eX0f.js`);return{wireWcOnboarding:e}},__vite__mapDeps([63,13,1,38,37,22,8,21,23,24,3,39,64])).then(({wireWcOnboarding:r})=>r({client:t,getController:()=>e.getController(),openVfs:n,log:i})).then(e=>{r.intercept=e.interceptWelcomeLick}).catch(e=>i.error(`WC onboarding wiring failed`,e))})}function xd(e,t){let n=()=>{t.getSessionStats?.().then(t=>{if(!t)return;e.refs.floatbar.setAttribute(`spent`,t.totalCost.toFixed(2)),typeof t.burnRate==`number`&&Number.isFinite(t.burnRate)?e.refs.floatbar.setAttribute(`rate`,t.burnRate.toFixed(2)):e.refs.floatbar.removeAttribute(`rate`);let n=e.refs.floatbar;t.models&&(n.costModels=t.models),t.scoops&&(n.costScoops=t.scoops),n.budget=t.budget?{percent:t.budget.percent,status:t.budget.status,window:t.budget.window,resets:Oe(t.budget.resetsAt)}:null,e.fills.clear();for(let n of t.fills)e.fills.set(n.jid,n.fill);e.refreshScoops?.()})};return setInterval(n,15e3),n}function Sd(e,t,n){let r=t.standalone;r&&l(async()=>{let{wireWcBrowser:e}=await import(`./wc-browser-DO1Pnegi.js`);return{wireWcBrowser:e}},__vite__mapDeps([65,66,37,67,1,68])).then(({wireWcBrowser:t})=>t({refs:e.refs,browser:r.browser,log:n})).catch(e=>n.error(`WC browser overlay wiring failed`,e))}function Cd(e){return{assistantLabel:e.assistantLabel,name:e.name,role:D(e)?`primary`:`child`}}function wd(e){return()=>{e.triggerPlaceholder();let t=e.boot.getSelected()?.id;if(e.boot.wiring.awaitingInput=t??null,e.boot.wiring.refreshScoops?.(),e.boot.wiring.notifyScoopStateChanged?.(),e.refreshStats(),!t)return;e.boot.refs.switcher.setAttribute(`attention`,t);let n=e.boot.getController()?.getMessages().filter(e=>e.role===`assistant`).at(-1);n&&e.boot.wiring.lastActivity.set(t,String(n.content??``).slice(0,600))}}function Td(e){let t=new Map,n=new Set;e.switcher.addEventListener(`pointerover`,r=>{let i=r.target?.closest?.(`.slicc-agent-tabs__segment`);if(!i||!e.switcher.contains(i))return;let a=i.dataset.k??``,o=e.getScoops().find(e=>e.jid===a);if(!o)return;let s=e.lastActivity.get(a)??``,c=t.get(a);if(c&&c.activity===s){i.title=c.tip;return}i.title||=Yt(Cd(o)),!(!s||n.has(a))&&(n.add(a),(async()=>{try{let n=await(e.labelFn??(await l(async()=>{let{quickLabel:e}=await import(`./quick-llm-DDPHThwA.js`).then(e=>e.n);return{quickLabel:e}},__vite__mapDeps([11,8,12,13,14,15,16,17,18,19,20,1,21,22,23,24,3,25,26,27,28,29,30,31,32,33,34]))).quickLabel)({system:`One line for a hover tooltip: at most 14 words, present tense, no quotes, no trailing period.`,prompt:`Summarize what this agent has been doing.\nAgent: ${D(o)?`${Yt(Cd(o))} (a main agent)`:o.name}\nMost recent activity:\n${s}`,maxTokens:40});n&&(t.set(a,{activity:s,tip:n}),i.title=n)}finally{n.delete(a)}})())})}async function Ed(e,t,n){let{RemoteTerminalView:r}=await l(async()=>{let{RemoteTerminalView:e}=await import(`./remote-terminal-view-D0AXaUk6.js`);return{RemoteTerminalView:e}},__vite__mapDeps([69,8,13,29,1,48,0,2,3,10,70,20,9,7,71])),{fetchSecretEnvVars:i}=await l(async()=>{let{fetchSecretEnvVars:e}=await import(`./secret-env-CtpVPUh5.js`);return{fetchSecretEnvVars:e}},__vite__mapDeps([72,1,22,8,13,21,23,24,3,25,26,27,28])),a=await i(),o=new r({client:t,cwd:`/`,env:Object.keys(a).length>0?a:void 0});await new Promise(t=>e.onClientReady(t)),await o.mount(n),globalThis.__slicc_terminal_view=o,window.addEventListener(`beforeunload`,()=>o.dispose(),{once:!0})}function Dd(e,t,n){let r=t=>{if(t.startsWith(`freezer:`)){n(t.slice(8));return}let r=Ut(Q(e.wiring).currentUnits(),t);r&&r.id!==e.getSelected()?.id&&e.selectScoop(r)};e.refs.thread.addEventListener(`slicc-url-context`,e=>{let t=e.detail?.context;t&&r(t)});let i=e.wiring.pendingUrlContext;i?.startsWith(`freezer:`)&&e.onClientReady(()=>{e.wiring.pendingUrlContext===i&&(e.wiring.pendingUrlContext=null,r(i))})}function Od(e,t,n,r){l(async()=>{let{installLeaderPermissionsSurface:e,installMountPendingConsumer:t}=await import(`./wc-permissions-Ch85s0Vv.js`);return{installLeaderPermissionsSurface:e,installMountPendingConsumer:t}},__vite__mapDeps([73,13,1,48])).then(async({installLeaderPermissionsSurface:r,installMountPendingConsumer:i})=>{let a=n.standalone?.runtimeMode??`standalone`,{buildLeaderPermissionProviders:o,isExtensionRuntime:s}=await l(async()=>{let{buildLeaderPermissionProviders:e,isExtensionRuntime:t}=await import(`./wc-permissions-providers-CVe-8jSH.js`);return{buildLeaderPermissionProviders:e,isExtensionRuntime:t}},__vite__mapDeps([74,13,3]));r({runtimeMode:a,providers:await o(s()||a===`extension`||a===`extension-detached`)}),i({runShell:kd(e,t)})}).catch(e=>r.warn(`WC permissions surface wiring failed`,e))}function kd(e,t){let n=null,r=()=>(n||=(async()=>{await new Promise(t=>e.onClientReady(t));let{TerminalSessionClient:n}=await l(async()=>{let{TerminalSessionClient:e}=await import(`./terminal-session-client-ADzaWGFd.js`).then(e=>e.n);return{TerminalSessionClient:e}},__vite__mapDeps([71,8])),r=new n({client:t,sid:`mount-drop-${Date.now()}`});return await r.open({cwd:`/workspace`}),r})().catch(e=>{throw n=null,e}),n);return async e=>(await r()).exec(e)}var Ad=`slicc-dock-tree:default`,jd={zones:{top:null,left:{type:`leaf`,surfaceId:`chat`},middle:null,right:null,bottom:null},rowFr:{top:1,center:1,bottom:1},colFr:{left:3,middle:1,right:1}};function Md(e,t){let n=e.dockTree,r=e.dockTree,i=e=>{try{localStorage.setItem(Ad,JSON.stringify(e))}catch{}};n.addEventListener(`dock-tree-change`,e=>{i(e.detail?.tree)}),n.addEventListener(`dock-tree-resize`,e=>{i(e.detail?.tree)});try{let e=localStorage.getItem(Ad);r.setTree(e?JSON.parse(e):jd)}catch(e){t.warn(`WC dock-tree restore failed — seeding the default layout`,e),r.setTree(jd)}}function Nd(e,t){return(n,r,i)=>{let a=e.getAttachStage();if(!a){t.warn(`sprinkle attachImage dropped: composer stage not ready yet`);return}let o=n.match(/^data:(image\/[^;]+);base64,([A-Za-z0-9+/=]+)$/),s=o?o[2]:n,c=o?o[1]:i??`image/png`,l=c.split(`/`)[1]?.replace(`jpeg`,`jpg`).replace(`svg+xml`,`svg`)??`png`,u=r??`annotation-${Date.now()}.${l}`;a.add({id:`att-${Date.now()}-${Math.random().toString(36).slice(2,8)}`,name:u,mimeType:c,size:Math.floor(s.length*3/4),kind:`image`,data:s})}}function Pd(e,t,n,r,i,a={}){l(async()=>{let{initTimestampPreference:e}=await import(`./wc-shortcuts-udkJj992.js`).then(e=>e.L);return{initTimestampPreference:e}},__vite__mapDeps([46,8,12,13,14,15,16,17,18,19,20,1,21,22,23,24,3,25,26,27,28,29,30,31,32,34])).then(({initTimestampPreference:e})=>e()).catch(()=>void 0);let{refs:o}=e;e.setClient(t),l(async()=>{let{watchSprinkleThemeBroadcast:e}=await import(`./theme-CXRqxpw6.js`).then(e=>e.i);return{watchSprinkleThemeBroadcast:e}},__vite__mapDeps([75,8,76,1])).then(({watchSprinkleThemeBroadcast:e})=>e()).catch(()=>void 0),l(async()=>{let{applyThemeOverrides:e}=await import(`./theme-engine-By4GU_Wc.js`).then(e=>e.p);return{applyThemeOverrides:e}},__vite__mapDeps([76,8,1])).then(({applyThemeOverrides:e})=>e()).catch(()=>void 0);let s=ve(`panel-layouts`);o.dockTree.tilesMovable=s,s||Md(o,i);let c=null,u=xd(e.wiring,t),d=()=>c?.(),f=r.welcome??{intercept:null},p=Q(e.wiring),{agentHandle:m}=n;e.onClientReady(u);let h=yd(t),g=async()=>(await h()).reader;a.standalone?.runtimeMode!==`cherry`&&a.standalone?.runtimeMode!==`hosted-leader`&&bd(e,t,h,f,i);let _=Lc({boot:e,client:t,setRefreshPlaceholder:e=>{c=e},triggerPlaceholder:d,openReader:g,openWriter:async()=>(await h()).writer,log:i});r.setAttachmentSource(()=>_.getAttachStage()?.take()),r.setTurnIdleHook(wd({boot:e,triggerPlaceholder:d,refreshStats:u})),Td({switcher:o.switcher,getScoops:()=>t.getScoops(),lastActivity:e.wiring.lastActivity}),Sd(e,a,i),Od(e,t,a,i);let v=Lu({fileTree:o.fileTree,termSurface:o.termSurface,memoryHost:o.memoryHost,monitor:o.monitor,openFs:g,openWriter:async()=>(await h()).writer,onKernelReady:t=>e.onClientReady(t),getMonitorDeps:()=>_l({client:t,openReader:g,storage:window.localStorage}),getWorkspace:()=>gd({client:t,clearSelection:e.clearSelection,selectedId:e.getSelected()?.id}),mountTerminal:n=>Ed(e,t,n),insertReference:e=>{let t=o.inputCard,n=t.value.trim();t.value=n?`${n} @${e}`:`@${e}`,t.focus()},log:i});e.setActivateSurface(v),s&&l(async()=>{let{panelizeShell:e}=await import(`./panelize-shell-BgTzzpy_.js`);return{panelizeShell:e}},__vite__mapDeps([77,1,46,8,12,13,14,15,16,17,18,19,20,21,22,23,24,3,25,26,27,28,29,30,31,32,34,78,79])).then(({panelizeShell:e})=>e(o,void 0,void 0,{onToolPanelActivate:e=>v.activate(e),onToolPanelDeactivate:e=>v.deactivate(e)})).catch(e=>i.error(`panelize failed — keeping the classic shell`,e)),ud({thread:o.thread,openFs:g,log:i}),o.floatbar.addEventListener(`click`,()=>{let e=o.dock;e.active===`monitor`?e.collapse():e.selectItem(`monitor`)});let y=il({refs:o,openVfs:h,client:t,getUnits:()=>p.currentUnits(),getController:()=>e.getController(),getSelected:()=>e.getSelected(),selectScoop:e.selectScoop,clearSelection:e.clearSelection,holdQueuedPile:e.holdQueuedPile,log:i}),{refreshFreezer:b,openFrozen:x,getViewedFrozenSessionId:ee}=y;if(b(),e.onClientReady(b),ve(`multiple-cones`)){let n=gc({freezer:o.freezer,client:t,getSelected:()=>e.getSelected(),getUnits:()=>p.currentUnits(),selectScoop:e.selectScoop,freezeCone:y.freezeCone,log:i});e.wiring.refreshConeActions=n.refresh,e.onClientReady(n.refresh)}Dd(e,t,x),e.onClientReady(()=>{h().then(async({reader:e,writer:t})=>{let{loadShortcutConfig:n}=await l(async()=>{let{loadShortcutConfig:e}=await import(`./wc-shortcut-config-DRFDW5Tg.js`);return{loadShortcutConfig:e}},__vite__mapDeps([80,1,46,8,12,13,14,15,16,17,18,19,20,21,22,23,24,3,25,26,27,28,29,30,31,32,34]));await n({reader:e,writer:t,apply:({keymap:e,trigger:t})=>{o.shortcuts.setKeymap(e),o.shortcuts.setTrigger(t)}})}).catch(e=>i.warn(`WC shortcut config load failed`,e))}),h().then(async({reader:e})=>{let{installPreviewVfsResponder:t}=await l(async()=>{let{installPreviewVfsResponder:e}=await import(`./preview-vfs-responder-CluNpFQR.js`);return{installPreviewVfsResponder:e}},[]);t({channel:new BroadcastChannel(`preview-vfs`),getReader:()=>e,logger:i})}).catch(e=>i.warn(`WC page-VFS support wiring failed`,e)),h().then(async({reader:n,writer:r})=>{let{createRemoteSprinkleVfs:s}=await l(async()=>{let{createRemoteSprinkleVfs:e}=await import(`./remote-sprinkle-vfs-BY9A-xsx.js`);return{createRemoteSprinkleVfs:e}},__vite__mapDeps([81,82,83,61])),c=(await l(async()=>{let{getPanelizedShell:e}=await import(`./panelize-shell-BgTzzpy_.js`);return{getPanelizedShell:e}},__vite__mapDeps([77,1,46,8,12,13,14,15,16,17,18,19,20,21,22,23,24,3,25,26,27,28,29,30,31,32,34,78,79]))).getPanelizedShell(),{wireWcSprinkles:u}=await l(async()=>{let{wireWcSprinkles:e}=await import(`./wc-sprinkles-CiVxUeGF.js`);return{wireWcSprinkles:e}},__vite__mapDeps([84,13,46,8,12,14,15,16,17,18,19,20,1,21,22,23,24,3,25,26,27,28,29,30,31,32,34,85,64])),d=await u({refs:o,client:t,getUnits:()=>p.currentUnits(),fs:s({reader:n,writer:r}),instanceId:a.instanceId,onAttachImage:Nd(_,i),onToolPanelActivate:e=>v.activate(e),onToolPanelDeactivate:e=>v.deactivate(e),hostSprinkleSurface:c?(e,t)=>c.hostSprinkleSurface(e,t):void 0,removeSprinkleSurface:c?e=>c.removeSprinkleSurface(e):void 0,log:i});e.onClientReady(()=>void d.resync());let{getPanelizedShell:f}=await l(async()=>{let{getPanelizedShell:e}=await import(`./panelize-shell-BgTzzpy_.js`);return{getPanelizedShell:e}},__vite__mapDeps([77,1,46,8,12,13,14,15,16,17,18,19,20,21,22,23,24,3,25,26,27,28,29,30,31,32,34,78,79])),y=f();if(y){let e=s({reader:n,writer:r});y.attachFs(e);let{registerAgentPanels:t}=await l(async()=>{let{registerAgentPanels:e}=await import(`./agent-panels-_ItKLnAu.js`);return{registerAgentPanels:e}},__vite__mapDeps([86,1,46,8,12,13,14,15,16,17,18,19,20,21,22,23,24,3,25,26,27,28,29,30,31,32,34]));await t(e).catch(e=>i.warn(`agent panel discovery failed`,e))}else{let{setLayoutApplier:e}=await l(async()=>{let{setLayoutApplier:e}=await import(`./layout-apply-registry-Cw730jao.js`);return{setLayoutApplier:e}},[]),{applyLayout:t}=await l(async()=>{let{applyLayout:e}=await import(`./apply-layout-B0AnPvJo.js`);return{applyLayout:e}},__vite__mapDeps([87,84,13,46,8,12,14,15,16,17,18,19,20,1,21,22,23,24,3,25,26,27,28,29,30,31,32,34,85,64]));e(e=>t(d.zone,e))}if(a.standalone&&a.instanceId){let{wireWcTray:n}=await l(async()=>{let{wireWcTray:e}=await import(`./wc-tray-B33mq_SX.js`);return{wireWcTray:e}},__vite__mapDeps([88,12,8,13,14,15,16,17,18,19,20,1,21,22,23,24,3,25,26,27,28,29,30,31,32,46,34,66,37,89,90,91,10,9,92,7,58,59,75,76,42,93,64,94,95,38,39,35,36,40,41,43,44,48,83,71,50,68,96,97,98,99,85])),r=d.zone.callbacks(),s=await n({refs:o,client:t,browser:a.standalone.browser,realCdpTransport:a.standalone.realCdpTransport,instanceId:a.instanceId,runtimeMode:a.standalone.runtimeMode,sprinkleManager:d.manager,addSprinkle:(e,t,n)=>r.addSprinkle(e,t,n),removeSprinkle:e=>r.removeSprinkle(e),getController:()=>e.getController(),getSelectedJid:()=>e.getSelected()?.id??`cone`,agentHandle:m,workUnits:p,restoreLocalChrome:()=>{e.wiring.refreshScoops?.();let n=e.getSelected();n&&Fc(o,n,p.currentUnits(),e=>t.getScoop(e))},openFs:g,openWriter:async()=>(await h()).writer,window,log:i});e.wiring.notifyScoopStateChanged=()=>s.scheduleScoopsListBroadcast()}}).catch(e=>i.error(`WC sprinkle/tray wiring failed`,e));{let n=new un,r=new hn,i=_n(new Vs({collection:{listScoops:()=>t.getScoops(),isProcessing:e=>t.isProcessing(e),getAgentMessages:()=>null,loadPersistedSessions:()=>n.loadAll(),loadUiChatSessions:async()=>{let e=await r.list();return(await Promise.all(e.map(e=>r.load(e)))).filter(e=>e!==null)},wait:e=>new Promise(t=>setTimeout(t,e))},knownSecrets:ac(),snapshotStore:{read:async e=>{let{reader:t}=await h();return Qs(t,e)},write:async(e,t)=>{let{writer:n}=await h();return Zs(n,e,t)}},vfs:{readFile:async(e,t)=>(await h()).reader.readFile(e,t),readDir:async e=>(await h()).reader.readDir(e),stat:async e=>(await h()).reader.stat(e)},getActiveSessionInfo:()=>{let t=$t(Q(e.wiring).currentUnits());return{id:t?.id??`session-${Date.now()}`,title:t?.name??`Active Session`}},version:`6.141.4`}));window.addEventListener(`unload`,i,{once:!0})}let S=!1,te=()=>S?Promise.resolve():(S=!0,(async()=>{try{let[{getTranscriptExportService:e},{transcriptZipToBlob:t,downloadTranscriptBlob:n}]=await Promise.all([l(()=>Promise.resolve().then(()=>gn),void 0),l(()=>import(`./wc-transcript-export-BCh_MVB_.js`),__vite__mapDeps([100,13,89,94,95,8]))]),r=ee(),i=r==null?{kind:`active`}:{kind:`frozen`,sessionId:r},a=await e().export(i,{}),{filename:o}=a;await n(await t(a),o)}catch(e){i.error(`Transcript export failed`,e),l(async()=>{let{showTranscriptExportFailure:e}=await import(`./wc-transcript-export-BCh_MVB_.js`);return{showTranscriptExportFailure:e}},__vite__mapDeps([100,13,89,94,95,8])).then(({showTranscriptExportFailure:t})=>t(e)).catch(e=>i.error(`Transcript export notice failed`,e))}finally{S=!1}})());if(l(async()=>{let{wireWcNav:e}=await import(`./wc-nav-BCixgrNu.js`);return{wireWcNav:e}},__vite__mapDeps([101,13,3,38,37,22,8,21,23,24,39,41,42,43,44,50,1,64,85])).then(({wireWcNav:e})=>e({refs:o,client:t,workUnits:p,getUnits:()=>p.currentUnits(),log:i,onExportTranscript:te,shortcuts:o.shortcuts,persistKeyboardTrigger:async e=>{let{writer:t,reader:n}=await h(),{writeShortcutTrigger:r}=await l(async()=>{let{writeShortcutTrigger:e}=await import(`./wc-shortcut-config-DRFDW5Tg.js`);return{writeShortcutTrigger:e}},__vite__mapDeps([80,1,46,8,12,13,14,15,16,17,18,19,20,21,22,23,24,3,25,26,27,28,29,30,31,32,34]));await r({reader:n,writer:t},e)}})).catch(e=>i.error(`WC nav wiring failed`,e)),l(async()=>{let{getComposerSpeech:e,setComposerSpeechInstanceId:t}=await import(`./composer-speech-4JiTrymN.js`);return{getComposerSpeech:e,setComposerSpeechInstanceId:t}},__vite__mapDeps([102,1,46,8,12,13,14,15,16,17,18,19,20,21,22,23,24,3,25,26,27,28,29,30,31,32,34,48,56,57,58,59,103])).then(({getComposerSpeech:e,setComposerSpeechInstanceId:t})=>{let n=o.composer;t(a.instanceId),n.speech=e(),n.setAttribute(`ptt`,``)}).catch(e=>i.error(`WC push-to-talk wiring failed`,e)),l(async()=>{let{setSpeakAssetsInstanceId:e}=await import(`./speak-DAMy1Kok.js`);return{setSpeakAssetsInstanceId:e}},__vite__mapDeps([55,13,1,3,56,57,46,8,12,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,34,58,59])).then(({setSpeakAssetsInstanceId:e})=>e(a.instanceId)).catch(e=>i.error(`WC say warmup wiring failed`,e)),a.standalone)return()=>{l(async()=>{let{schedulePendingSessionCatchup:e}=await import(`./new-session-Cvy359ZG.js`);return{schedulePendingSessionCatchup:e}},__vite__mapDeps([49,12,8,13,14,15,16,17,18,19,20,1,21,22,23,24,3,25,26,27,28,29,30,31,32,41,35,36,37,38,39,40,42,43,44,33])).then(({schedulePendingSessionCatchup:e})=>e({openVfs:async()=>(await h()).writer,onComplete:b})).catch(e=>i.warn(`Pending session catch-up scheduling failed`,e))}}async function Fd(e,t,n=`standalone`){let{browser:r,realCdpTransport:i,instanceId:a,localApiBaseUrl:o,bridgeToken:s,localLickWsUrl:c,extensionDelegateId:u,attachLickForwardingClient:d}=await we({runtimeMode:n,envBaseUrl:null,window,log:t}),{floatKindForRuntimeMode:f,floatLabelForKind:p,resolveStandaloneFloatKind:m}=await l(async()=>{let{floatKindForRuntimeMode:e,floatLabelForKind:t,resolveStandaloneFloatKind:n}=await Promise.resolve().then(()=>Ml);return{floatKindForRuntimeMode:e,floatLabelForKind:t,resolveStandaloneFloatKind:n}},void 0),h=n===`standalone`?await m():f(n),g=p(h);a&&Te(a);let{syncFsBridgeEnabled:_,syncFsChannelNonce:v}=yl(),y=!1,b,x,{boot:ee}=await Vl(e,t,{floatKind:h,floatLabel:g,connect:e=>{b=No({realCdpTransport:i,reconnectCdp:()=>r.reconnectIfNeeded(),instanceId:a,makeClient:t=>new go(yc(e.wiring),t),localApiBaseUrl:o,bridgeToken:s,syncFsBridgeEnabled:_,syncFsChannelNonce:v,localLickWsUrl:c,extensionDelegateId:u,flagFloat:n,onWorkerScriptError:()=>{Ce()},onReadyStall:e=>{y=!0,l(()=>import(`./boot-stall-overlay-Pxp4nHfq.js`).then(t=>t.showBootStallOverlay(document,e)),[])},onLateReady:()=>{Ce()}}),So({send:e=>b.client.sendRaw(e)}),d?.(b.client);let f=vo(b.client);return{client:Q(e.wiring),host:f,workbench:(e,o)=>{x=Pd(e,b.client,o,f,t,{instanceId:a,standalone:{browser:r,floatKind:h,realCdpTransport:i,runtimeMode:n}})}}}}),{setupSudoStandalone:S}=await l(async()=>{let{setupSudoStandalone:e}=await import(`./main-DRyLg5pd.js`).then(e=>e.i);return{setupSudoStandalone:e}},__vite__mapDeps([35,8,36,12,13,14,15,16,17,18,19,20,1,21,22,23,24,3,25,26,27,28,29,30,31,32,37,38,39,40,41,42,43,44]));await S({log:t});try{await b.ready}finally{y&&l(()=>import(`./boot-stall-overlay-Pxp4nHfq.js`).then(e=>e.removeBootStallOverlay(document)),[])}ee.wiring.notifyReady?.(),t.info(`WC live shell ready`,{scoops:b.client.getScoops().length}),x?.();let{consumeAutoPrompt:te}=await l(async()=>{let{consumeAutoPrompt:e}=await import(`./auto-prompt-Mj-vUQeB.js`);return{consumeAutoPrompt:e}},[]),C=te(window.location.search);C&&(ee.getController()?.sendUserMessage(C),t.info(`Auto-prompt submitted`,{length:C.length}))}export{eo as A,hn as B,go as C,Ya as D,to as E,Ga as F,Ea as I,Ln as L,na as M,Oa as N,Qa as O,ta as P,yn as R,vo as S,$a as T,xc as _,bl as a,Q as b,ul as c,ml as d,zc as f,Sc as g,bc as h,xl as i,no as j,Za as k,ol as l,Mc as m,fd as n,sl as o,Rc as p,Vl as r,fl as s,Pd as t,ll as u,Cc as v,Ka as w,xo as x,yc as y,gn as z};
|