sliccy 6.238.8 → 6.239.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/ui/.vite/manifest.json +240 -180
- package/dist/ui/assets/{account-store-D0TqUNmX.js → account-store-D8_Dfaay.js} +1 -1
- package/dist/ui/assets/{account-store-DYJN3RGV.js → account-store-DIwBWa5E.js} +1 -1
- package/dist/ui/assets/{adobe-Q1fXZ8AC.js → adobe-4yG5Jojo.js} +1 -1
- package/dist/ui/assets/{adobe-DVShm7Dw.js → adobe-Dhbax_Br.js} +1 -1
- package/dist/ui/assets/{agent-panels-DhSzHTAV.js → agent-panels-C29MoSl4.js} +1 -1
- package/dist/ui/assets/{almost-bash-shell-headless-o54vLKKu.js → almost-bash-shell-headless-2CLmgbnr.js} +15 -15
- package/dist/ui/assets/{apply-layout-BRfsnfGb.js → apply-layout-Tf3-paMF.js} +1 -1
- package/dist/ui/assets/{azure-openai-DWUOdX_5.js → azure-openai-Bun6vpyO.js} +1 -1
- package/dist/ui/assets/{azure-openai-BKuN09o7.js → azure-openai-CV-fQjTG.js} +1 -1
- package/dist/ui/assets/{bunny-probe-BWGnwW6r.js → bunny-probe-JCwN6lp-.js} +1 -1
- package/dist/ui/assets/{bunny-run-XIIFCqVf.js → bunny-run-8NAeBrEY.js} +1 -1
- package/dist/ui/assets/{cdp-DUH19OCw.js → cdp-LW6tWTA_.js} +1 -1
- package/dist/ui/assets/{cerebras-C-azfZva.js → cerebras-CyKW7bZ0.js} +1 -1
- package/dist/ui/assets/{cerebras-D33k4Yza.js → cerebras-yHe16lDC.js} +1 -1
- package/dist/ui/assets/{composer-speech-CJAwELHd.js → composer-speech-DlI-Cx5J.js} +1 -1
- package/dist/ui/assets/{connect-surface-B8geWVoR.js → connect-surface-DeAt_ZAc.js} +1 -1
- package/dist/ui/assets/{directed-approval-Bnm1dj4G.js → directed-approval-C5pWtjRZ.js} +1 -1
- package/dist/ui/assets/{emscripten-vfs-hook-DHhvLFW-.js → emscripten-vfs-hook-DWEcz7cK.js} +1 -1
- package/dist/ui/assets/{fast-path-DDglW33_.js → fast-path-BtGQKOcK.js} +1 -1
- package/dist/ui/assets/frozen-archive-writer-BPn5tRZ0.js +8 -0
- package/dist/ui/assets/frozen-archive-writer-CMu6TvYW.js +8 -0
- package/dist/ui/assets/frozen-session-delete-D3Nn1hnH.js +1 -0
- package/dist/ui/assets/frozen-session-identity-BftVqDgr.js +1 -0
- package/dist/ui/assets/frozen-session-identity-Cjcq_2LL.js +1 -0
- package/dist/ui/assets/{gelatiere-unit-DrJGro4B.js → gelatiere-unit-DSTJIump.js} +1 -1
- package/dist/ui/assets/{github-C03kvUzc.js → github-BOEXMP5I.js} +1 -1
- package/dist/ui/assets/{github-DWRkZiCX.js → github-CDLDVvae.js} +1 -1
- package/dist/ui/assets/{github-copilot-DpE7PEcg.js → github-copilot-DmRSv3eX.js} +1 -1
- package/dist/ui/assets/{github-copilot-i9oWU5OG.js → github-copilot-GWf8yFqj.js} +1 -1
- package/dist/ui/assets/{hear-bivJkqjB.js → hear-COy7lJi8.js} +1 -1
- package/dist/ui/assets/{js-realm-worker-BuyrcMcl.js → js-realm-worker-BX6sSVEP.js} +2 -2
- package/dist/ui/assets/{jsh-executor-CpLjOisa.js → jsh-executor-DMD5ddFz.js} +2 -2
- package/dist/ui/assets/{kernel-worker-e1vUlLgV.js → kernel-worker-C4MiASR-.js} +67 -67
- package/dist/ui/assets/{lick-ws-bridge-CeFf2St2.js → lick-ws-bridge-C6ESiukL.js} +1 -1
- package/dist/ui/assets/{lick-ws-bridge-BqX4Fc2a.js → lick-ws-bridge-CNTM_E_X.js} +1 -1
- package/dist/ui/assets/live-session-curation-B2cEWodJ.js +1 -0
- package/dist/ui/assets/live-session-curation-BlJB9qzA.js +186 -0
- package/dist/ui/assets/{live-session-snapshot-BfoV4ZCP.js → live-session-snapshot-BctAuI5m.js} +1 -1
- package/dist/ui/assets/{local-llm-DzKe6sA4.js → local-llm-B7q3J_L2.js} +1 -1
- package/dist/ui/assets/{local-llm-DUOulQs1.js → local-llm-BdiGwRPz.js} +1 -1
- package/dist/ui/assets/{main-Nm8Ln4q3.js → main-CslAwAF2.js} +3 -3
- package/dist/ui/assets/{main-cherry-qRMu74pY.js → main-cherry-Cs1Ann97.js} +1 -1
- package/dist/ui/assets/{mcp-command-Tj8BzPra.js → mcp-command-CXofTqGH.js} +9 -9
- package/dist/ui/assets/{memory-curation-seam-3gqEcNpu.js → memory-curation-seam-BrcfUyLE.js} +1 -1
- package/dist/ui/assets/{memory-health-CDIj4o1S.js → memory-health-C9R7SlKi.js} +1 -1
- package/dist/ui/assets/{memory-write-execute-CNtd_Hx9.js → memory-write-execute-B5dvOReg.js} +1 -1
- package/dist/ui/assets/merge-folded-cost-into-frozen-lQrAjo3y.js +1 -0
- package/dist/ui/assets/new-session-Dp8xDbm-.js +2 -0
- package/dist/ui/assets/{oauth-bootstrap-u4lFXFxA.js → oauth-bootstrap-CHIy6Gm9.js} +2 -2
- package/dist/ui/assets/{onboarding-orchestrator-BzH-tJf2.js → onboarding-orchestrator-BFvm2xiq.js} +1 -1
- package/dist/ui/assets/{openai-codex-CMWGsVdC.js → openai-codex-B7o_kfeG.js} +1 -1
- package/dist/ui/assets/{openai-codex-DazFN0fF.js → openai-codex-C0v0bADZ.js} +1 -1
- package/dist/ui/assets/{openrouter-L6CYqofP.js → openrouter-BvYuCJyw.js} +1 -1
- package/dist/ui/assets/{openrouter-DcIT_nHE.js → openrouter-CjK8QxpD.js} +1 -1
- package/dist/ui/assets/{openrouter-free-BnWJ2ABS.js → openrouter-free-Ckg5PGJI.js} +1 -1
- package/dist/ui/assets/{openrouter-free-DGQQEFRf.js → openrouter-free-CpnGXHOt.js} +1 -1
- package/dist/ui/assets/{openrouter-oauth-CseLedXq.js → openrouter-oauth-B7SPH2rM.js} +1 -1
- package/dist/ui/assets/{openrouter-oauth-DTnVZ_UE.js → openrouter-oauth-Bn-kidmO.js} +1 -1
- package/dist/ui/assets/{panel-rpc-handlers-ByuPfUHm.js → panel-rpc-handlers-Cz6BSSZA.js} +2 -2
- package/dist/ui/assets/{panelize-shell-BootSuaW.js → panelize-shell-DuYIEVZp.js} +1 -1
- package/dist/ui/assets/{pi-edit-execution-DPDtgDlS.js → pi-edit-execution-DG6p7-5P.js} +1 -1
- package/dist/ui/assets/{provider-D_7CZquc.js → provider-9ZUgiMpB.js} +1 -1
- package/dist/ui/assets/{provider-BEnK5Lk6.js → provider-D2ZYPo-w.js} +1 -1
- package/dist/ui/assets/{provider-settings-CqJO1pyj.js → provider-settings-CQlHJFH1.js} +1 -1
- package/dist/ui/assets/provider-store-access-CD0n5Juv.js +1 -0
- package/dist/ui/assets/provider-store-access-CNt__qng.js +1 -0
- package/dist/ui/assets/{providers-DePGLLxQ.js → providers-BH5jcsI3.js} +2 -2
- package/dist/ui/assets/{providers-CpiMoxP2.js → providers-o3PSAZzA.js} +1 -1
- package/dist/ui/assets/{quick-llm-lj_1jQHe.js → quick-llm-CcF7noc9.js} +1 -1
- package/dist/ui/assets/{realm-inprocess-B8w8tqT8.js → realm-inprocess-liML3utD.js} +2 -2
- package/dist/ui/assets/{realm-unhandled-rejections-Bua1wYjO.js → realm-unhandled-rejections-BK0JhQwR.js} +1 -1
- package/dist/ui/assets/{realm-unhandled-rejections-Cp_plmS_.js → realm-unhandled-rejections-cG6AguM7.js} +1 -1
- package/dist/ui/assets/{recovery-screen-C6rhqUUH.js → recovery-screen-DBCfk0t-.js} +1 -1
- package/dist/ui/assets/{remote-terminal-view-_0P4IDpH.js → remote-terminal-view-BdwibNDb.js} +2 -2
- package/dist/ui/assets/{restore-CgdbLRS5.js → restore-DKKWE7qo.js} +1 -1
- package/dist/ui/assets/{run-C1H8fJIP.js → run-BJGzDxyk.js} +2 -2
- package/dist/ui/assets/{run-CEjTJBQx.js → run-CBmNeNV5.js} +2 -2
- package/dist/ui/assets/{run-Cf6ZRThe.js → run-CRTEPV5c.js} +2 -2
- package/dist/ui/assets/{run-DO6XazGf.js → run-CSqBGpbN.js} +1 -1
- package/dist/ui/assets/{run-B7TVAC25.js → run-DCCKDraC.js} +1 -1
- package/dist/ui/assets/{run-BqRP0ho6.js → run-DPb-_GVl.js} +2 -2
- package/dist/ui/assets/{run-dcwnpB-U.js → run-juG_3wwW.js} +1 -1
- package/dist/ui/assets/{session-command-memory-BqvRR1Pr.js → session-command-memory-a5EZNUwp.js} +2 -2
- package/dist/ui/assets/session-jsonl-DUdZghbY.js +4 -0
- package/dist/ui/assets/{session-jsonl-B8fJlzun.js → session-jsonl-_QWNiZX3.js} +1 -1
- package/dist/ui/assets/session-search-index-B-R--ndE.js +3 -0
- package/dist/ui/assets/{setup-feature-flags-remote-BLc8tm5e.js → setup-feature-flags-remote-DxCLsJ3k.js} +1 -1
- package/dist/ui/assets/{setup-model-catalog-BeK2KZVz.js → setup-model-catalog-CeqAS8Mo.js} +1 -1
- package/dist/ui/assets/{silent-renew-backoff-CKknZDcb.js → silent-renew-backoff-jTgRXFkn.js} +1 -1
- package/dist/ui/assets/slicc-version-CzxKLup1.js +1 -0
- package/dist/ui/assets/{soundscape-DnGFq-oy.js → soundscape-DRNmNI9R.js} +1 -1
- package/dist/ui/assets/{speak-BusE622B.js → speak-BhmMqs9a.js} +1 -1
- package/dist/ui/assets/{sprinkle-manager-6BczljOM.js → sprinkle-manager-DvWj32Aj.js} +1 -1
- package/dist/ui/assets/{sprinkle-renderer-Dja-QvIm.js → sprinkle-renderer-CDi2K0Gg.js} +1 -1
- package/dist/ui/assets/{src-CHbY4LCw.js → src-C5RTA17v.js} +79 -72
- package/dist/ui/assets/{ssh-BNRWir5e.js → ssh-CVu8tZ_S.js} +1 -1
- package/dist/ui/assets/{sudo-D50wpCPP.js → sudo-BDyQV9Rk.js} +1 -1
- package/dist/ui/assets/{supervisor-SrJ7wGuQ.js → supervisor-c8DDwpCe.js} +1 -1
- package/dist/ui/assets/{sync-dialog-rh5SsoU-.js → sync-dialog-DiBKt4y_.js} +1 -1
- package/dist/ui/assets/thinking-level-DCJktR5U.js +1 -0
- package/dist/ui/assets/{transformers-env-xaMKoY_u.js → transformers-env-DkclSft7.js} +1 -1
- package/dist/ui/assets/{tray-leader-LJ0WrWVz.js → tray-leader-DhQw8Vyo.js} +1 -1
- package/dist/ui/assets/{tray-leave-runtime-DS3xhtZX.js → tray-leave-runtime-CgYC8lzC.js} +1 -1
- package/dist/ui/assets/{tray-sidecar-DllFThbS.js → tray-sidecar-CTXFReb_.js} +1 -1
- package/dist/ui/assets/{upgrade-detection-1YcNNvEo.js → upgrade-detection-DJkzgh_V.js} +1 -1
- package/dist/ui/assets/{voice-reply-4Y8XE5qj.js → voice-reply-BDxhQxq3.js} +1 -1
- package/dist/ui/assets/{wc-attach-BpAfl-hq.js → wc-attach-Cz4Segxp.js} +2 -2
- package/dist/ui/assets/{wc-browser-Y5gd2z2o.js → wc-browser-DACcAKyw.js} +1 -1
- package/dist/ui/assets/{wc-computers-ChuSd7-K.js → wc-computers-DwbsWvJk.js} +1 -1
- package/dist/ui/assets/{wc-detached-DvoqDk3K.js → wc-detached-qHwBVBrK.js} +1 -1
- package/dist/ui/assets/{wc-extension-Dcct_6Zb.js → wc-extension-Z4I4Bju7.js} +2 -2
- package/dist/ui/assets/wc-follower-CGMjE8mK.js +17 -0
- package/dist/ui/assets/wc-follower-oauth-B7k4jnu8.js +5 -0
- package/dist/ui/assets/{wc-gelatiere-DSkLEJWA.js → wc-gelatiere-D-U3dAxD.js} +1 -1
- package/dist/ui/assets/wc-live-CrWRbzvC.js +248 -0
- package/dist/ui/assets/{wc-nav-BfgFifv9.js → wc-nav-nmgBtf5f.js} +2 -2
- package/dist/ui/assets/{wc-onboarding-DAabd4D0.js → wc-onboarding-BHk8sSaZ.js} +2 -2
- package/dist/ui/assets/{wc-permissions-BsWxtseN.js → wc-permissions-DAdJvlP4.js} +2 -2
- package/dist/ui/assets/{wc-placeholder-Cd8RcYU6.js → wc-placeholder-CegeCuXU.js} +3 -3
- package/dist/ui/assets/{wc-secret-request-DYWa12vP.js → wc-secret-request-bhtsXEeR.js} +1 -1
- package/dist/ui/assets/{wc-settings-CsNBxD6l.js → wc-settings-BoCRAYwI.js} +3 -3
- package/dist/ui/assets/{wc-shell-CpR39VTz.js → wc-shell-CuOqCSKv.js} +219 -180
- package/dist/ui/assets/{wc-shortcut-config-CI9MDlef.js → wc-shortcut-config-5vUzFHFF.js} +1 -1
- package/dist/ui/assets/{wc-sprinkles-_UL-jsvL.js → wc-sprinkles-HdCnSQzK.js} +2 -2
- package/dist/ui/assets/{wc-transcript-export-fIvPUKqc.js → wc-transcript-export-Bg4-Bg4b.js} +2 -2
- package/dist/ui/assets/{wc-tray-CxJ-2rTn.js → wc-tray-wYtpqxqQ.js} +4 -4
- package/dist/ui/assets/welcome-detection-C8enaOAA.js +1 -0
- package/dist/ui/assets/{whisper-session-B1F8ie2e.js → whisper-session-u58K2Q3y.js} +2 -2
- package/dist/ui/assets/{xai-grok-BiZZD21n.js → xai-grok-B_xnricm.js} +1 -1
- package/dist/ui/assets/{xai-grok-DkWxNM8U.js → xai-grok-COiWlii6.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/frozen-archive-writer-DI1Vr3NK.js +0 -8
- package/dist/ui/assets/live-session-curation-CaGvZIiB.js +0 -1
- package/dist/ui/assets/merge-folded-cost-into-frozen-XtMISyfB.js +0 -1
- package/dist/ui/assets/new-session-DYPm3kHj.js +0 -2
- package/dist/ui/assets/provider-store-access-CTW_VcPK.js +0 -1
- package/dist/ui/assets/provider-store-access-DeyEdUKL.js +0 -1
- package/dist/ui/assets/session-jsonl-sSMKZwgt.js +0 -11
- package/dist/ui/assets/session-search-index-lPQD_5ew.js +0 -3
- package/dist/ui/assets/slicc-version-DiBcXGio.js +0 -1
- package/dist/ui/assets/wc-follower-Ceswovhq.js +0 -17
- package/dist/ui/assets/wc-follower-oauth-C1Oua_Hy.js +0 -5
- package/dist/ui/assets/wc-live-CGASbmGD.js +0 -433
- package/dist/ui/assets/welcome-detection-aVdJIsd0.js +0 -1
|
@@ -1,433 +0,0 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/wc-shell-CpR39VTz.js","assets/rolldown-runtime-Dd_uD5pT.js","assets/preload-helper-Czpn1I53.js","assets/logger-DDBAeTLF.js","assets/mime-types-D0xZwlMO.js","assets/base64-ELzoYfwP.js","assets/bridge-protocol-C52CnDIj.js","assets/account-store-DYJN3RGV.js","assets/core-Cx9N3lmn.js","assets/compat-BAGLwgqY.js","assets/models-Xc0Gclrk.js","assets/diagnostics-Cag7MsZI.js","assets/env-api-keys-BXRkymgV.js","assets/provider-env-CTOcDKrQ.js","assets/__vite-browser-external-5eBdwsFd.js","assets/openrouter.models-DHpsqCCC.js","assets/libesm-BypnjKEL.js","assets/feature-flags-DvsApnS-.js","assets/proxied-fetch-4VBgrEIu.js","assets/proxy-error-BSFYY7jj.js","assets/api-endpoint-DuEQRZ4g.js","assets/runtime-env-Dlaokqg1.js","assets/secret-topology-hMRoGGjt.js","assets/float-topology-C_iRKPQK.js","assets/secrets-bridge-client-D734Xx8G.js","assets/port-bridge-client-B-gpiOVR.js","assets/panel-rpc-accessor-B4BfPLSo.js","assets/image-markers-q8JQTtid.js","assets/tool-ui-eSQ1g2I1.js","assets/providers-DePGLLxQ.js","assets/stored-accounts-ChNHYF68.js","assets/bedrock-camp-compat-B1oHsbyo.js","assets/bedrock-camp-extra-models-BYrxX19D.js","assets/claude-model-version-DZmbk9E2.js","assets/same-file-identity-OexpsaSD.js","assets/telemetry-B0sKnLBU.js","assets/types-D8gIX-W-.js","assets/icons-2DY2vYOc.js","assets/wc-shell-WkeczD9x.css","assets/mount-picker-popup-qcWGbpG5.js","assets/picker-popup-sQtXmfAo.js","assets/usb-picker-O-2gFMNl.js","assets/serial-picker-BQF_Eitc.js","assets/hid-picker-sFJ8vzUj.js","assets/usb-device-registry--JwKRTYp.js","assets/serial-port-registry-CCqklAEr.js","assets/hid-device-registry-B2R-0rNt.js","assets/quick-llm-lj_1jQHe.js","assets/llm-session-id-bZQs6gBN.js","assets/session-jsonl-sSMKZwgt.js","assets/slugify-BYJ6QVAt.js","assets/main-Nm8Ln4q3.js","assets/modulepreload-polyfill-P2Xu9kJm.js","assets/tray-follower-status-BAjnN7Ar.js","assets/clipboard-eqmn97SP.js","assets/wc-placeholder-Cd8RcYU6.js","assets/wc-attach-BpAfl-hq.js","assets/permissions-surface-registry-CilCRwhh.js","assets/wc-gelatiere-DSkLEJWA.js","assets/new-session-DYPm3kHj.js","assets/tray-leader-LJ0WrWVz.js","assets/mount-table-store-dY2IfQ5S.js","assets/legacy-styles-B3nS5QUo.js","assets/soundscape-DnGFq-oy.js","assets/voice-reply-4Y8XE5qj.js","assets/speak-BusE622B.js","assets/speech-assets-bridge-CFYafE89.js","assets/transformers-env-xaMKoY_u.js","assets/shared-DSEuryGJ.js","assets/remote-vfs-client-Cs1yUtQm.js","assets/writable-vfs-client-CQe6oZ75.js","assets/wc-onboarding-DAabd4D0.js","assets/record-CBv8rWFt.js","assets/wc-browser-Y5gd2z2o.js","assets/slicc-app-url-BKHBBuTR.js","assets/tab-teleport-C8QSKgl0.js","assets/teleport-storage-CyYkSZfJ.js","assets/wc-computers-ChuSd7-K.js","assets/scale-B8PGb3fG.js","assets/remote-terminal-view-_0P4IDpH.js","assets/browser-BhTdBqdp.js","assets/usb-operations-v1mGAdRY.js","assets/terminal-session-client-DmE-iBjP.js","assets/secret-env-z9SReONx.js","assets/wc-permissions-BsWxtseN.js","assets/wc-permissions-providers-DwX67umy.js","assets/wc-secret-request-DYWa12vP.js","assets/secret-request-registry-DrOMKR1H.js","assets/theme-CwPIBqJE.js","assets/theme-engine-ZV7CeqWw.js","assets/panelize-shell-BootSuaW.js","assets/virtual-device-paths-D45tpPP6.js","assets/layout-apply-registry-Cw730jao.js","assets/wc-shortcut-config-CI9MDlef.js","assets/remote-sprinkle-vfs-UzNBy5VJ.js","assets/bounded-walk-BjxKWNqp.js","assets/path-utils-DNJG-zQf.js","assets/wc-sprinkles-_UL-jsvL.js","assets/wc-unit-context-CZro7UrY.js","assets/agent-panels-DhSzHTAV.js","assets/apply-layout-BRfsnfGb.js","assets/wc-tray-CxJ-2rTn.js","assets/transcript-export-DP-r8eDz.js","assets/wc-follower-oauth-C1Oua_Hy.js","assets/sprinkle-renderer-Dja-QvIm.js","assets/hid-operations-C97SZtrY.js","assets/pending-request-table-k-D7ZZsL.js","assets/export-spool-CuNzzI8a.js","assets/src-BWaKqLvQ.js","assets/panel-rpc-sLZo8PD-.js","assets/types-DSxCdZw6.js","assets/synthetic-cdp-transport-OUVdC4zy.js","assets/sprinkle-instances-B8n7h-oP.js","assets/wc-transcript-export-fIvPUKqc.js","assets/wc-nav-BfgFifv9.js","assets/composer-speech-CJAwELHd.js","assets/whisper-session-B1F8ie2e.js"])))=>i.map(i=>d[i]);
|
|
2
|
-
import{n as e}from"./rolldown-runtime-Dd_uD5pT.js";import{d as t,l as n,u as r}from"./core-Cx9N3lmn.js";import{t as i}from"./preload-helper-Czpn1I53.js";import{t as a}from"./compat-BAGLwgqY.js";import{t as o}from"./logger-DDBAeTLF.js";import{$ as s,A as c,C as l,Ct as u,D as d,E as f,Et as p,I as m,O as h,P as g,S as _,St as v,T as y,Tt as b,a as ee,at as x,b as te,c as ne,ct as re,d as ie,dt as ae,ft as oe,i as se,k as ce,l as le,n as ue,nt as de,o as fe,pt as pe,r as me,t as he,tt as ge,u as _e,ut as ve,v as ye,w as be,wt as xe,x as Se,xt as Ce,y as we}from"./wc-shell-CpR39VTz.js";import{a as Te}from"./feature-flags-DvsApnS-.js";import{r as Ee,t as De}from"./base64-ELzoYfwP.js";import{a as Oe,c as ke,d as Ae,f as je,l as Me,n as Ne,o as Pe,s as Fe,u as Ie}from"./sprinkle-renderer-Dja-QvIm.js";import{B as Le,C as Re,u as ze,w as Be,z as Ve}from"./account-store-DYJN3RGV.js";import"./proxied-fetch-4VBgrEIu.js";import{n as He}from"./same-file-identity-OexpsaSD.js";import{n as Ue}from"./runtime-env-Dlaokqg1.js";import{t as We}from"./slugify-BYJ6QVAt.js";import{a as Ge,i as Ke,n as S,t as qe}from"./transcript-export-DP-r8eDz.js";import{C as Je,S as C,_ as Ye,a as Xe,b as Ze,c as Qe,d as $e,f as w,g as et,h as tt,l as nt,m as rt,n as it,o as at,p as ot,r as st,s as ct,t as lt,u as ut,v as T,x as dt,y as E}from"./session-jsonl-sSMKZwgt.js";import{d as ft,o as pt,s as mt,t as ht}from"./api-endpoint-DuEQRZ4g.js";import{n as gt}from"./float-topology-C_iRKPQK.js";import"./secret-topology-hMRoGGjt.js";import{n as _t}from"./secrets-bridge-client-D734Xx8G.js";import{t as vt}from"./tool-ui-eSQ1g2I1.js";import{a as yt,c as bt,l as xt,n as St,p as Ct,r as wt}from"./telemetry-B0sKnLBU.js";import{a as Tt,i as Et,t as Dt}from"./tray-follower-status-BAjnN7Ar.js";import{D as Ot,T as kt,b as At,f as jt,j as Mt,m as Nt,p as Pt,s as Ft}from"./main-Nm8Ln4q3.js";import{n as It}from"./src-BWaKqLvQ.js";import{n as Lt,r as Rt,t as zt}from"./provider-budget-LCzMPlKv.js";import{t as Bt}from"./permissions-surface-registry-CilCRwhh.js";import{t as Vt}from"./types-D8gIX-W-.js";import{n as Ht,r as Ut}from"./hid-device-registry-B2R-0rNt.js";import"./browser-BhTdBqdp.js";import{a as Wt,i as Gt}from"./serial-port-registry-CCqklAEr.js";import{c as Kt,d as qt,g as Jt,i as Yt,l as Xt,m as Zt,n as Qt,o as $t,p as en,r as tn,t as nn,u as rn}from"./hid-operations-C97SZtrY.js";import{a as an,t as on}from"./icons-2DY2vYOc.js";import{a as sn,i as cn}from"./usb-device-registry--JwKRTYp.js";import{f as ln,i as un,l as dn,s as fn,u as pn}from"./usb-operations-v1mGAdRY.js";import{a as mn,i as hn,r as gn}from"./tray-leader-LJ0WrWVz.js";import{a as _n,c as vn,f as D,h as yn,i as bn,l as xn,m as Sn,n as Cn,o as wn,s as Tn,t as En,u as O}from"./record-CBv8rWFt.js";import{a as Dn,i as On,n as kn,o as An,r as jn,s as Mn,t as k}from"./descriptor-CuhPBdq8.js";import{n as Nn,t as A}from"./types-CFfBWsH5.js";import"./shared-DSEuryGJ.js";import{a as Pn,n as Fn,r as In}from"./theme-CwPIBqJE.js";import{_ as Ln,a as Rn,d as zn,f as Bn,g as Vn,h as Hn,i as Un,l as Wn,n as Gn,o as Kn,p as qn,r as Jn,u as Yn}from"./wc-unit-context-CZro7UrY.js";var Xn=new Set([`summarized`,`fallback`]);function Zn(e){if(!A(e)||e===null||e.origin!==`agent-history`)return[];let t=[];for(let n of e.entries)n.kind!==`tool-call`&&n.message&&t.push(n.message);return t}async function Qn(e,t={}){if(!A(e)||e===null)return[];if(e.origin===`ui-projection`){let t=[];for(let n of e.entries)n.kind!==`tool-call`&&n.chat&&t.push(n.chat);return er(t,e.markers)}let n=e.projectionPrefix??[],r=Zn(e);if(r.length===0)return er([...n],e.markers);let{agentMessagesToChatMessages:a}=await i(async()=>{let{agentMessagesToChatMessages:e}=await import(`./wc-shell-CpR39VTz.js`).then(e=>e.lt);return{agentMessagesToChatMessages:e}},__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38])),o=$n(a(r,t),e.attachments);return er([...n,...o],e.markers)}function $n(e,t){if(!t?.length)return e;let n=[...t].sort((e,t)=>e.timestamp-t.timestamp),r=new Set;return e.map(e=>{if(e.role!==`user`||e.attachments?.length)return e;let t=e.content.trim(),i=n.findIndex((e,n)=>!r.has(n)&&e.body.trim()===t);return i<0?e:(r.add(i),{...e,attachments:n[i].attachments})})}function er(e,t){let n=(t??[]).filter(e=>e.kind!==`compaction`||Xn.has(e.compaction.state));if(n.length===0)return e;let r=[...n].sort((e,t)=>e.timestamp-t.timestamp),i=[],a=0;for(let t of e){let e=tr(t);for(;a<r.length&&r[a].timestamp<=e;)i.push(nr(r[a++]));i.push(t)}for(;a<r.length;)i.push(nr(r[a++]));return i}function tr(e){let t=e.timestamp;if(typeof t==`number`&&Number.isFinite(t))return t;if(typeof t==`string`){let e=Date.parse(t);if(!Number.isNaN(e))return e}return-1/0}function nr(e){return e.kind===`error`?{id:e.id,role:`assistant`,content:e.text,timestamp:e.timestamp,error:!0}:{id:e.id,role:`assistant`,content:``,timestamp:e.timestamp,compaction:e.compaction}}var rr=e({CanonicalSessionReader:()=>or,agentSessionFromRecord:()=>ar,chatSessionFromRecord:()=>ir});async function ir(e){return{id:e.legacyKeys.chatSessionId,messages:await Qn(e),createdAt:e.createdAt,updatedAt:e.updatedAt}}function ar(e){return{id:e.workUnitId,messages:Zn(e),config:{},createdAt:e.createdAt,updatedAt:e.updatedAt}}var or=class{store;constructor(e){this.store=e}async loadAgentSessions(){return(await this.latestPerUnit()).map(ar)}async loadChatSessions(){return Promise.all((await this.latestPerUnit()).map(ir))}async latestPerUnit(){let e=new Map;for(let t of await this.store.loadAll()){let n=e.get(t.workUnitId);(!n||t.updatedAt>n.updatedAt)&&e.set(t.workUnitId,t)}return[...e.values()]}async loadRootChatSession(e){let t=await this.store.loadLatestInWorkspace(Mn({parentJid:null,folder:e}).root);return t?ir(t):null}async load(e){return e.startsWith(`session-`)?this.loadRootChatSession(e.slice(8)):null}},sr=new Set([`scoop-notify`,`scoop-idle`,`scoop-wait`]);function cr(e){return`e${e}`}function lr(e){let t=[];for(let n of e){let e=dr(n),r=pr(n);if(e===`assistant`){let e=t.length,i=cr(e);t.push({id:i,seq:e,kind:`assistant`,timestamp:r,text:hr(n),message:n,model:mr(n)});for(let e of gr(n)){let n=t.length;t.push({id:cr(n),seq:n,kind:`tool-call`,timestamp:r,toolCallId:e.id,name:e.name,assistantEntryId:i})}continue}if(e===`toolResult`){let e=n,i=t.length;t.push({id:cr(i),seq:i,kind:`tool-result`,timestamp:r,text:hr(n),message:n,toolCallId:e.toolCallId??``,isError:e.isError});continue}let i=hr(n),a=e===`user`?ur(i):null,o=t.length,s=cr(o);a===null?t.push({id:s,seq:o,kind:`user`,timestamp:r,text:i,message:n}):sr.has(a)?t.push({id:s,seq:o,kind:`child-result`,timestamp:r,text:i,message:n,channel:a}):t.push({id:s,seq:o,kind:`external-event`,timestamp:r,text:i,message:n,channel:a})}return t}function ur(e){for(let t of oe(e)){let e=(t.sender?ae(t.sender):null)??ve(t.body);if(e)return e}return null}function dr(e){return e.role??``}function fr(e){if(typeof e==`number`)return e;if(typeof e==`string`){let t=Date.parse(e);return Number.isNaN(t)?0:t}return e instanceof Date?e.getTime():0}function pr(e){return fr(e.timestamp)}function mr(e){let t=e.model;return typeof t==`string`?t:void 0}function hr(e){let t=e.content;if(typeof t==`string`)return t;if(!Array.isArray(t))return``;let n=[];for(let e of t)e?.type===`text`&&n.push(e.text);return n.join(``)}function gr(e){let t=e.content;if(!Array.isArray(t))return[];let n=[];for(let e of t){if(e?.type!==`toolCall`)continue;let t=e;n.push({id:t.id??``,name:t.name??``})}return n}var _r=e({CONVERSATION_DB_NAME:()=>vr,WorkUnitConversationStore:()=>br}),j=o(`work-unit-conversation`),vr=`slicc-work-units`,yr=1,M=`conversations`,N=`migrations`,br=class{dbPromise=null;dbName;writeChains=new Map;constructor(e={}){this.dbName=e.dbName??`slicc-work-units`}async load(e){let t=await this.read(e);return t.status===`ok`?t.record:null}async read(e){try{let t=await Dr((await this.getDb()).transaction(M,`readonly`).objectStore(M).get(e));return t?A(t)?Array.isArray(t.entries)?{status:`ok`,record:t}:(j.warn(`Conversation record has no entry list`,{key:e}),{status:`malformed`,reason:`entries is not a list`}):(j.warn(`Ignoring conversation record from a newer schema`,{key:e,version:t.version}),{status:`incompatible`,version:t.version}):{status:`absent`}}catch(t){return j.warn(`Conversation record read failed`,{key:e,error:P(t)}),{status:`error`,reason:P(t)}}}async save(e){let t=e.version>2?e.version:Nn(e),n={...e,version:t},r=(await this.getDb()).transaction(M,`readwrite`);return r.objectStore(M).put(n),await Or(r),n}delete(e){return this.serialize(e,async()=>{try{let t=(await this.getDb()).transaction(M,`readwrite`);t.objectStore(M).delete(e),await Or(t)}catch(t){j.warn(`Conversation record delete failed`,{key:e,error:P(t)})}})}async rekey(e,t){if(e!==t.key)try{let n=await this.read(e);if(n.status!==`ok`)return;let r=await this.read(t.key);if(r.status===`incompatible`||r.status===`error`){j.warn(`Conversation rekey refused: target is not writable`,{fromKey:e,toKey:t.key,status:r.status});return}let i=Date.now();await this.save({...n.record,key:t.key,workUnitId:t.workUnitId,workspaceId:t.workspaceId,folder:t.folder,legacyKeys:t.legacyKeys,updatedAt:i}),await this.delete(e)}catch(n){j.warn(`Conversation rekey failed`,{fromKey:e,toKey:t.key,error:P(n)})}}async loadAll(){try{return(await Dr((await this.getDb()).transaction(M,`readonly`).objectStore(M).getAll())).filter(e=>A(e)&&Array.isArray(e.entries))}catch(e){return j.warn(`Conversation record listing failed`,{error:P(e)}),[]}}async loadLatestInWorkspace(e){try{let t=`${e}::`,n=await Dr((await this.getDb()).transaction(M,`readonly`).objectStore(M).getAll(IDBKeyRange.bound(t,`${t}\uffff`))),r=null;for(let e of n)!A(e)||!Array.isArray(e.entries)||(!r||e.updatedAt>r.updatedAt)&&(r=e);return r}catch(t){return j.warn(`Conversation workspace lookup failed`,{workspaceId:e,error:P(t)}),null}}async listKeys(){try{return(await Dr((await this.getDb()).transaction(M,`readonly`).objectStore(M).getAllKeys())).map(String)}catch(e){return j.warn(`Conversation key listing failed`,{error:P(e)}),[]}}async syncAgentMessages(e,t,n={}){let r=n.now??Date.now(),i=lr(t);return this.serialize(e.key,()=>this.ingestEntries(e,i,n,r))}async ingestEntries(e,t,n,r){try{let i=await this.read(e.key);if(i.status===`incompatible`||i.status===`error`)return null;let a=i.status===`ok`?i.record:null,o=xr(a,t,e,`agent-history`,{createdAt:n.createdAt??r,now:r});return o?await this.save(o):a}catch(t){return j.warn(`Conversation record write failed`,{key:e.key,error:P(t)}),null}}async putMarker(e,t,n={}){return this.withRecord(e,n.createWith,e=>{let n=(e.markers??[]).filter(e=>e.id!==t.id);return n.push(t),n.sort((e,t)=>e.timestamp-t.timestamp),{...e,markers:n.slice(-64)}})}async putAttachments(e,t){if(t.length===0)return!1;let n=new Set(t.map(e=>e.id));return this.withRecord(e.key,e,e=>({...e,attachments:[...(e.attachments??[]).filter(e=>!n.has(e.id)),...t].sort((e,t)=>e.timestamp-t.timestamp).slice(-256)}))}async deleteMarker(e,t){return this.withRecord(e,void 0,e=>{let n=(e.markers??[]).filter(e=>e.id!==t);return n.length===(e.markers?.length??0)?null:{...e,markers:n}})}withRecord(e,t,n){return this.serialize(e,()=>this.mutateRecord(e,t,n))}async mutateRecord(e,t,n){try{let r=await this.read(e),i=r.status===`ok`?r.record:r.status===`absent`&&t?Sr(t,Date.now()):null;if(!i)return!1;let a=n(i);return a?(await this.save({...a,updatedAt:Date.now()}),!0):!1}catch(t){return j.warn(`Conversation marker write failed`,{key:e,error:P(t)}),!1}}serialize(e,t){let n=(this.writeChains.get(e)??Promise.resolve()).then(t,t),r=n.then(()=>void 0,()=>void 0);return this.writeChains.set(e,r),r.then(()=>{this.writeChains.get(e)===r&&this.writeChains.delete(e)}),n}async getMigrationState(e){try{return await Dr((await this.getDb()).transaction(N,`readonly`).objectStore(N).get(e))??null}catch(t){return j.warn(`Migration state read failed`,{id:e,error:P(t)}),null}}async putMigrationState(e){try{let t=(await this.getDb()).transaction(N,`readwrite`);t.objectStore(N).put(e),await Or(t)}catch(t){j.warn(`Migration state write failed`,{id:e.id,error:P(t)})}}async clearAll(){let e=(await this.getDb()).transaction([M,N],`readwrite`);e.objectStore(M).clear(),e.objectStore(N).clear(),await Or(e)}getDb(){return this.dbPromise||(this.dbPromise=Er(this.dbName).then(e=>(e.onversionchange=()=>{e.close(),this.dbPromise=null},e.onclose=()=>{this.dbPromise=null},e)),this.dbPromise.catch(()=>{this.dbPromise=null})),this.dbPromise}};function xr(e,t,n,r,i){if(!e)return t.length===0?null:{key:n.key,version:2,workUnitId:n.workUnitId,workspaceId:n.workspaceId,folder:n.folder,origin:r,entries:t,createdAt:i.createdAt,updatedAt:i.now,legacyKeys:n.legacyKeys};if(e.origin===`ui-projection`&&r===`agent-history`)return t.length===0?null:{...e,version:2,origin:r,entries:t,projectionPrefix:[...e.projectionPrefix??[],...Cr(e)],updatedAt:i.now,legacyKeys:n.legacyKeys};let a=e.entries;if(t.length===a.length&&wr(a,t))return null;let o=t.length>a.length&&wr(a,t);return{...e,version:2,origin:r,entries:t,updatedAt:i.now,rewrites:o?e.rewrites:(e.rewrites??0)+1,legacyKeys:n.legacyKeys}}function Sr(e,t){return{key:e.key,version:2,workUnitId:e.workUnitId,workspaceId:e.workspaceId,folder:e.folder,origin:`agent-history`,entries:[],createdAt:t,updatedAt:t,legacyKeys:e.legacyKeys}}function Cr(e){let t=[];for(let n of e.entries)n.kind!==`tool-call`&&n.chat&&t.push(n.chat);return t}function wr(e,t){if(e.length>t.length)return!1;for(let n=0;n<e.length;n++)if(!Tr(e[n],t[n]))return!1;return!0}function Tr(e,t){return e.kind!==t.kind||e.seq!==t.seq?!1:e.kind===`tool-call`&&t.kind===`tool-call`?e.toolCallId===t.toolCallId&&e.name===t.name:(`text`in e?e.text:``)===(`text`in t?t.text:``)}function Er(e){return new Promise((t,n)=>{let r=indexedDB.open(e,yr);r.onupgradeneeded=()=>{let e=r.result;e.objectStoreNames.contains(M)||e.createObjectStore(M,{keyPath:`key`}),e.objectStoreNames.contains(N)||e.createObjectStore(N,{keyPath:`id`})},r.onsuccess=()=>t(r.result),r.onerror=()=>n(r.error)})}function Dr(e){return new Promise((t,n)=>{e.onsuccess=()=>t(e.result),e.onerror=()=>n(e.error)})}function Or(e){return new Promise((t,n)=>{e.oncomplete=()=>t(),e.onerror=()=>n(e.error),e.onabort=()=>n(e.error)})}function P(e){return e instanceof Error?e.message:String(e)}var kr=e({getTranscriptExportService:()=>jr,registerTranscriptExportService:()=>Ar}),F=null;function Ar(e){return F=e,()=>{F===e&&(F=null)}}function jr(){if(!F)throw new S(`session-not-found`);return F}var Mr=e({broadcastToDips:()=>Xr,disposeDips:()=>xi,handleDipPickerAction:()=>Si,hydrateDips:()=>bi,mountDip:()=>B,setDipExecHandler:()=>Qr}),Nr=Ue();i(()=>import(`./screen-share-approval-live-D388fVD9.js`).then(e=>{e.listenScreenShareApprovalChannel()}),[]);function Pr(e){if(typeof e!=`object`||!e||Array.isArray(e))return[];let t=e.filters;return Array.isArray(t)?t:[]}async function Fr(e,t){if(t?.aborted)throw new DOMException(`aborted`,`AbortError`);let n=await Rr(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 Ir=null;function Lr(){if(Ir)return Ir;if(typeof BroadcastChannel>`u`)return null;try{Ir=new BroadcastChannel(`preview-vfs`)}catch{return null}return Ir}async function Rr(e,t,n){let r=Lr();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 zr=[`/shared/sprinkles/`,`/workspace/skills/sprinkles/`,`/workspace/sprinkles/`],Br=[`/shared/`,`/workspace/skills/sprinkles/`,`/workspace/sprinkles/`];function Vr(e){return zr.some(t=>e.startsWith(t))}function Hr(e){return typeof e!=`string`||!e.startsWith(`/`)||e.includes(`..`)?!1:Br.some(t=>e.startsWith(t))}var I=new WeakSet,Ur=`,
|
|
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
|
-
}`,Wr=`,
|
|
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
|
-
}`,Gr=`,
|
|
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 Kr(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?Ur:``}${e?Wr:``}${e?Gr:``}
|
|
92
|
-
};
|
|
93
|
-
function reportHeight() {
|
|
94
|
-
parent.postMessage({ type: 'dip-height',
|
|
95
|
-
height: document.documentElement.scrollHeight }, '*');
|
|
96
|
-
}
|
|
97
|
-
${Ie}
|
|
98
|
-
${Me}
|
|
99
|
-
window.addEventListener('message', function(e) {
|
|
100
|
-
if (!e.data || typeof e.data.type !== 'string') return;
|
|
101
|
-
if (e.data.type === 'slicc-theme') {
|
|
102
|
-
applyIframeTheme(e);
|
|
103
|
-
return;
|
|
104
|
-
}
|
|
105
|
-
/* Pushed device events (currently 'hid:inputreport'). The host
|
|
106
|
-
attaches the underlying listener on slicc.hid.open(handle) for
|
|
107
|
-
this dip; teardown happens automatically on dispose. */
|
|
108
|
-
if (e.data.type === 'dip-device-event' && e.data.channel === 'hid:inputreport') {
|
|
109
|
-
_hidInputReportListeners.forEach(function(cb) {
|
|
110
|
-
try { cb(e.data.payload); } catch(ex) {}
|
|
111
|
-
});
|
|
112
|
-
return;
|
|
113
|
-
}
|
|
114
|
-
/* VFS callback responses target the originating call by id. */
|
|
115
|
-
if (e.data.id && _callbacks[e.data.id]) {
|
|
116
|
-
var cb = _callbacks[e.data.id];
|
|
117
|
-
delete _callbacks[e.data.id];
|
|
118
|
-
cb(e.data);
|
|
119
|
-
return;
|
|
120
|
-
}
|
|
121
|
-
/* Forward any other slicc-* message to in-page listeners via a
|
|
122
|
-
CustomEvent. Dips can opt in with
|
|
123
|
-
window.addEventListener('slicc-message', (ev) => ev.detail). */
|
|
124
|
-
if (e.data.type.indexOf('slicc-') === 0) {
|
|
125
|
-
try {
|
|
126
|
-
document.dispatchEvent(new CustomEvent('slicc-message', { detail: e.data }));
|
|
127
|
-
} catch (ex) {}
|
|
128
|
-
}
|
|
129
|
-
});
|
|
130
|
-
window.addEventListener('load', function() {
|
|
131
|
-
reportHeight();
|
|
132
|
-
new ResizeObserver(reportHeight).observe(document.body);
|
|
133
|
-
});
|
|
134
|
-
/* Support data-action attributes (Tool UI compat) — auto-lick on click.
|
|
135
|
-
Also intercept <a href> clicks and relay to the parent so links open
|
|
136
|
-
despite the iframe sandbox blocking top-level navigation. */
|
|
137
|
-
document.addEventListener('click', function(e) {
|
|
138
|
-
var el = e.target;
|
|
139
|
-
while (el && el !== document.body) {
|
|
140
|
-
if (el.dataset && el.dataset.action) {
|
|
141
|
-
var actionData = el.dataset.actionData;
|
|
142
|
-
if (actionData) { try { actionData = JSON.parse(actionData); } catch(ex) {} }
|
|
143
|
-
/* Picker hint (e.g. data-picker="directory") needs the parent to
|
|
144
|
-
run File System Access API on the click activation chain.
|
|
145
|
-
Forward as a separate message so the parent can run
|
|
146
|
-
showDirectoryPicker, stash the handle in IDB, then dispatch
|
|
147
|
-
the lick with the IDB key. */
|
|
148
|
-
var picker = el.dataset.picker;
|
|
149
|
-
if (picker) {
|
|
150
|
-
parent.postMessage({
|
|
151
|
-
type: 'dip-picker-action',
|
|
152
|
-
action: el.dataset.action,
|
|
153
|
-
data: actionData || null,
|
|
154
|
-
picker: picker,
|
|
155
|
-
}, '*');
|
|
156
|
-
} else {
|
|
157
|
-
window.slicc.lick({ action: el.dataset.action, data: actionData || null });
|
|
158
|
-
}
|
|
159
|
-
e.preventDefault();
|
|
160
|
-
e.stopPropagation();
|
|
161
|
-
return;
|
|
162
|
-
}
|
|
163
|
-
if (el.tagName === 'A' && el.getAttribute('href')) {
|
|
164
|
-
var href = el.getAttribute('href');
|
|
165
|
-
/* Allow in-iframe anchor navigation (#foo). Skip javascript: for safety. */
|
|
166
|
-
if (href.charAt(0) === '#') return;
|
|
167
|
-
if (/^javascript:/i.test(href)) { e.preventDefault(); return; }
|
|
168
|
-
/* Resolve relative URLs against the iframe's base. */
|
|
169
|
-
var resolved;
|
|
170
|
-
try { resolved = new URL(href, document.baseURI).href; } catch(ex) { resolved = href; }
|
|
171
|
-
parent.postMessage({ type: 'dip-open-link', url: resolved }, '*');
|
|
172
|
-
e.preventDefault();
|
|
173
|
-
e.stopPropagation();
|
|
174
|
-
return;
|
|
175
|
-
}
|
|
176
|
-
el = el.parentElement;
|
|
177
|
-
}
|
|
178
|
-
});
|
|
179
|
-
})();`}var qr=`html,body{margin:0;padding:0;overflow:hidden;background:transparent;box-sizing:border-box}
|
|
180
|
-
*,*::before,*::after{box-sizing:inherit}
|
|
181
|
-
/* Vertical breathing room around dip content. Horizontal padding is owned
|
|
182
|
-
by the dip's own content (e.g. .sprinkle-action-card__body) so shtml
|
|
183
|
-
widgets that already pad themselves don't end up double-indented. The
|
|
184
|
-
ResizeObserver on document.body reports the post-padding scrollHeight
|
|
185
|
-
correctly, so auto-height continues to work. The .sprinkle-inline rule
|
|
186
|
-
(set on the iframe body) carries 2px of horizontal padding so the 1px
|
|
187
|
-
focus ring (box-shadow:0 0 0 1px on inputs/select below) doesn't get
|
|
188
|
-
clipped at the iframe paint boundary. */
|
|
189
|
-
body{padding:12px 0;font-family:var(--s2-font-family, sans-serif);font-size:13px;color:var(--s2-content-default)}
|
|
190
|
-
.sprinkle-inline{padding:var(--s2-spacing-100) 2px}
|
|
191
|
-
.sprinkle-inline .sprinkle-btn{padding:4px 12px;font-size:12px;height:28px;box-shadow:none}
|
|
192
|
-
.sprinkle-inline .sprinkle-btn:not([class*="sprinkle-btn--"]){background:var(--s2-bg-elevated)}
|
|
193
|
-
.sprinkle-inline .sprinkle-card{box-shadow:none;margin:0}
|
|
194
|
-
.sprinkle-inline .sprinkle-action-card{margin:0;width:100%}
|
|
195
|
-
/* Stacked action cards in one dip need breathing room between them. The
|
|
196
|
-
margin:0 above zeroes the single-card case (iframe padding owns that
|
|
197
|
-
spacing); this adjacent-sibling rule outranks a plain authored class,
|
|
198
|
-
so multiple .sprinkle-action-card in one message no longer touch edge
|
|
199
|
-
to edge. See vfs-root/workspace/skills/dips/SKILL.md. */
|
|
200
|
-
.sprinkle-inline .sprinkle-action-card + .sprinkle-action-card{margin-top:12px}
|
|
201
|
-
.sprinkle-inline .sprinkle-action-card .sprinkle-table{width:100%}
|
|
202
|
-
.sprinkle-inline .sprinkle-grid{width:100%}
|
|
203
|
-
input[type="range"]{width:100%;height:4px;-webkit-appearance:none;appearance:none;background:var(--s2-gray-300);border-radius:2px;outline:none;cursor:default}
|
|
204
|
-
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)}
|
|
205
|
-
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)}
|
|
206
|
-
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}
|
|
207
|
-
input[type="text"]:focus,input[type="number"]:focus,textarea:focus{border-color:var(--s2-accent);box-shadow:0 0 0 1px var(--s2-accent)}
|
|
208
|
-
input[type="text"]::placeholder,textarea::placeholder{color:var(--s2-content-disabled,var(--s2-gray-400))}
|
|
209
|
-
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}
|
|
210
|
-
select:focus{border-color:var(--s2-accent);box-shadow:0 0 0 1px var(--s2-accent)}
|
|
211
|
-
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}
|
|
212
|
-
button:hover{background:color-mix(in srgb,var(--s2-content-default) 6%,transparent)}
|
|
213
|
-
button:disabled{opacity:0.4;pointer-events:none}
|
|
214
|
-
canvas{display:block;width:100%;border-radius:8px}
|
|
215
|
-
mark{background:color-mix(in srgb,var(--s2-accent) 25%,transparent);color:inherit;border-radius:2px;padding:0 2px}
|
|
216
|
-
.c-purple{background:#3C3489;color:#EEEDFE}.c-teal{background:#085041;color:#E1F5EE}
|
|
217
|
-
.c-coral{background:#712B13;color:#FAECE7}.c-pink{background:#72243E;color:#FBEAF0}
|
|
218
|
-
.c-gray{background:#444441;color:#F1EFE8}.c-blue{background:#0C447C;color:#E6F1FB}
|
|
219
|
-
.c-amber{background:#633806;color:#FAEEDA}.c-red{background:#791F1F;color:#FCEBEB}
|
|
220
|
-
.c-green{background:#27500A;color:#EAF3DE}`,Jr=`(function(){
|
|
221
|
-
window.addEventListener('message', function(e){
|
|
222
|
-
if (!e.data || e.data.type !== 'dip-draft-update') return;
|
|
223
|
-
var content = typeof e.data.content === 'string' ? e.data.content : '';
|
|
224
|
-
document.body.innerHTML = content;
|
|
225
|
-
if (window.lucide && typeof window.lucide.createIcons === 'function') {
|
|
226
|
-
try { window.lucide.createIcons(); } catch(ex){}
|
|
227
|
-
}
|
|
228
|
-
});
|
|
229
|
-
})();`;function Yr(e,t,n=!1){let r=Ne(),i=Fn()?` class="theme-light"`:``,a=t||e.includes(`<slicc-editor`),o=t||e.includes(`<slicc-diff`),s=t?`<script>${Jr}<\/script>`:``;return`<!DOCTYPE html>
|
|
230
|
-
<html${i}><head>
|
|
231
|
-
<meta charset="utf-8">
|
|
232
|
-
<style>${r}</style>
|
|
233
|
-
<style>${qr}</style>
|
|
234
|
-
<script>${Kr(n&&!t)}<\/script>
|
|
235
|
-
${s}
|
|
236
|
-
${a?`<script src="/slicc-editor.js"><\/script>`:``}
|
|
237
|
-
${o?`<script src="/slicc-diff.js"><\/script>`:``}
|
|
238
|
-
<script src="/lucide-icons.js"><\/script>
|
|
239
|
-
</head>
|
|
240
|
-
<body class="sprinkle-inline">${e}</body></html>`}var L=new Set;function Xr(e){if(typeof e?.type!=`string`||e.type.indexOf(`slicc-`)!==0)throw Error(`broadcastToDips: payload.type must start with 'slicc-'`);for(let t of L)try{t.postMessage(e,`*`)}catch{}}var Zr;function Qr(e){Zr=e}function R(e){return e.length===0?`''`:`'${e.replace(/'/g,`'\\''`)}'`}function $r(e,t){let n=t?.cwd??`.`,r=t?.allowedCommands??`*`,i=[`agent`];return t?.model&&i.push(`--model`,R(t.model)),t?.thinking&&i.push(`--thinking`,R(t.thinking)),t?.readOnly&&i.push(`--read-only`,R(t.readOnly)),i.push(R(n),R(r),R(e)),i.join(` `)}async function ei(e){if(!Zr)return{stdout:``,stderr:`exec: shell bridge not available
|
|
241
|
-
`,exitCode:127};try{return await Zr(e)}catch(e){return{stdout:``,stderr:`exec: ${e instanceof Error?e.message:String(e)}\n`,exitCode:1}}}async function ti(e,t){let n=await ei($r(e,t));return{stdout:n.stdout||n.stderr,exitCode:n.exitCode}}async function ni(e,t){let n=await Oe(ei,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 z=new WeakMap;function ri(e,t){try{e.postMessage({type:`dip-device-event`,channel:`hid:inputreport`,payload:t},`*`)}catch{}}async function ii(e,t){let n=z.get(e);if(n||(n=new Map,z.set(e,n)),n.has(t))return;let r=await Xt(Ut(),t,n=>{let r=n.bytes instanceof Uint8Array?n.bytes:new Uint8Array(n.bytes);ri(e,{handle:t,reportId:n.reportId,data:r})});n.set(t,r)}async function ai(e,t){let n=z.get(e);if(!n)return;let r=n.get(t);if(r){n.delete(t);try{await Promise.resolve(r())}catch{}}n.size===0&&z.delete(e)}function oi(e){let t=z.get(e);if(t){for(let e of t.values())try{Promise.resolve(e()).catch(()=>{})}catch{}z.delete(e)}}function si(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 ci(e,t,n){let r=Ut();switch(t){case`list`:{let e=Ht();if(!e)throw Error(`WebHID is unavailable in this browser`);return tn(r,e)}case`request`:{let e=Ht();if(!e)throw Error(`WebHID is unavailable in this browser`);return $t(r,Pe(e),n[0]??[])}case`info`:return Qt(r,n[0]);case`open`:{let t=n[0];return await Yt(r,t),await ii(e,t),{ok:!0}}case`close`:{let t=n[0];return await ai(e,t),await nn(r,t),{ok:!0}}case`sendReport`:{let e=n[0],t=n[1],i=si(n[2]),a=i.buffer.slice(i.byteOffset,i.byteOffset+i.byteLength);return await Kt(r,e,t,a),{ok:!0}}default:throw Error(`hid: unknown op '${t}'`)}}async function li(e,t){let n=Wt();switch(e){case`list`:{let e=Gt();if(!e)throw Error(`Web Serial is unavailable in this browser`);return en(n,e)}case`request`:{let e=Gt();if(!e)throw Error(`Web Serial is unavailable in this browser`);return Jt(n,Fe(e),t[0]??[])}case`info`:return qt(n,t[0]);case`open`:{let e=t[0],r=t[1]??{baudRate:9600};return await Zt(n,e,r),{ok:!0}}case`close`:return await rn(n,t[0]),{ok:!0};default:throw Error(`serial: unknown op '${e}'`)}}async function ui(e,t){let n=sn();switch(e){case`list`:{let e=cn();if(!e)throw Error(`WebUSB is unavailable in this browser`);return dn(n,e)}case`request`:{let e=cn();if(!e)throw Error(`WebUSB is unavailable in this browser`);return ln(n,ke(e),t[0]??[])}case`info`:return fn(n,t[0]);case`open`:return await pn(n,t[0]),{ok:!0};case`close`:return await un(n,t[0]),{ok:!0};default:throw Error(`usb: unknown op '${e}'`)}}async function di(e,t,n,r){switch(t){case`hid`:return ci(e,n,r);case`serial`:return li(n,r);case`usb`:return ui(n,r);default:throw Error(`unknown device channel '${t}'`)}}async function fi(e,t){if(!e||typeof t.id!=`number`)return!1;let n=n=>{try{e.postMessage({...n,id:t.id},`*`)}catch{}};if(!I.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 di(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 pi(e,t){if(!e||typeof t.id!=`number`)return!1;let n=n=>{try{e.postMessage({...n,id:t.id},`*`)}catch{}};if(!I.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 ei(typeof t.cmd==`string`?t.cmd:``)}),!0;if(t.type===`dip-agent`)return n({type:`dip-agent-response`,result:await ti(typeof t.prompt==`string`?t.prompt:``,t.opts)}),!0;if(t.type===`dip-jsh`){try{n({type:`dip-jsh-response`,result:await ni(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 B(e,t,n,r=!1){let i=Yr(t,!1,r);if(Nr)return ki(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&&(In(a.contentWindow),L.add(a.contentWindow),r&&I.add(a.contentWindow)),a.addEventListener(`load`,()=>{In(a.contentWindow),a.contentWindow&&(L.add(a.contentWindow),r&&I.add(a.contentWindow)),Ae()&&je(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`?hi(t.url):t.type===`dip-picker-action`?Si(t,n):t.type===`dip-readfile`||t.type===`dip-exists`||t.type===`dip-stat`?mi(a.contentWindow,t):t.type===`dip-exec`||t.type===`dip-agent`||t.type===`dip-jsh`?pi(a.contentWindow,t):t.type===`dip-device-op`&&fi(a.contentWindow,t))};window.addEventListener(`message`,o);let s=null;if(Ae()&&typeof IntersectionObserver<`u`){let e=!1,t=new IntersectionObserver(n=>{if(n[n.length-1].isIntersecting){if(e){e=!1;return}t.unobserve(a),je(a,()=>{e=!0,t.observe(a)})}});s=t,t.observe(a)}return{dispose(){s?.disconnect(),window.removeEventListener(`message`,o),Pn(a.contentWindow),a.contentWindow&&(L.delete(a.contentWindow),I.delete(a.contentWindow),oi(a.contentWindow)),a.remove()}}}async function mi(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(!I.has(e))return r({type:`${t.type}-response`,error:`VFS access not allowed for this dip`}),!0;if(!Hr(n))return r({type:`${t.type}-response`,error:`VFS path not allowed: ${n}`}),!0;if(t.type===`dip-readfile`){let e=await Rr(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 Rr(n,!0)!==null}),!0;if(t.type===`dip-stat`){let e=await Rr(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 hi(e){if(!(typeof e!=`string`||!e)&&/^(https?:|mailto:)/i.test(e))try{window.open(e,`_blank`,`noopener,noreferrer`)}catch{}}var gi=new WeakMap;function _i(){return typeof Element.prototype.moveBefore==`function`}function vi(e,t,n){let r=e.findIndex(e=>{let n=gi.get(e);return n?.key===t&&n.wrapper.isConnected}),i=e[r],a=i&&gi.get(i);if(!a)return null;try{n.parentNode.moveBefore(a.wrapper,n)}catch{return null}return n.remove(),e.splice(r,1),i}function yi(e,t,n){return gi.set(e,{key:t,wrapper:n}),e}function bi(e,t,n={}){let r=[],i=[...n.previous??[]],a=_i(),o=n.streaming===!0&&!a,c=e.querySelectorAll(`pre > code.language-shtml`);for(let e of c){let n=e.parentElement,c=e.textContent??``,l=`shtml:${c}`;if(o){n.replaceWith(n.ownerDocument.createRange().createContextualFragment(s));continue}let u=a?vi(i,l,n):null;if(u){r.push(u);continue}let d=document.createElement(`div`);d.className=`msg__dip`,n.replaceWith(d),r.push(yi(B(d,c,t,!1),l,d))}let l=e.querySelectorAll(`img[src$=".shtml"]`);for(let e of l){let n=e.getAttribute(`src`);if(!n||o)continue;let s=`img:${n}`,c=a?vi(i,s,e):null;if(c){r.push(c);continue}let l=document.createElement(`div`);l.className=`msg__dip`,e.alt&&l.setAttribute(`title`,e.alt),e.replaceWith(l);let u=new AbortController,d=null,f=!1;r.push(yi({dispose(){f=!0,u.abort(),d&&=(d.dispose(),null)}},s,l));let p=n.startsWith(`/`),m=typeof navigator<`u`&&!!navigator.serviceWorker?.controller,h=p?`/preview${n}`:n,g=async()=>{if(p&&!m)return Fr(n,u.signal);let e;try{e=await fetch(h,{signal:u.signal})}catch(e){if(e?.name===`AbortError`)throw e;if(p)return Fr(n,u.signal);throw e}if(e.ok)return e.text();if(p)return Fr(n,u.signal);throw Error(`HTTP ${e.status}`)},_=p&&Vr(n);g().then(e=>{f||!l.isConnected||(d=B(l,e,t,_))}).catch(e=>{f||e?.name===`AbortError`||(l.textContent=`Failed to load dip: ${n}`,l.style.cssText=`padding:8px;font-size:12px;color:var(--s2-negative);font-family:var(--s2-font-mono)`)})}return xi(i),r}function xi(e){for(let t of e)try{t.dispose()}catch{}e.length=0}async function Si(e,t){let n=Pr(e.data);if(e.picker===`screenshare`){await wi(e.action,t);return}if(Nr){await Ci(e.picker,e.action,n,t);return}switch(e.picker){case`directory`:await Ti(e.action,t);return;case`usb-device`:await Ei(e.action,n,t);return;case`serial-port`:await Di(e.action,n,t);return;case`hid-device`:await Oi(e.action,n,t);return;default:t(e.action,e.data);return}}async function Ci(e,t,n,r){try{switch(e){case`directory`:{let{openMountPickerPopup:e}=await i(async()=>{let{openMountPickerPopup:e}=await import(`./mount-picker-popup-qcWGbpG5.js`);return{openMountPickerPopup:e}},__vite__mapDeps([39,3,40,21])),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 i(async()=>{let{openUsbPickerPopup:e}=await import(`./usb-picker-O-2gFMNl.js`).then(e=>e.t);return{openUsbPickerPopup:e}},__vite__mapDeps([41,1,40,21])),a=await e(n);`cancelled`in a?r(t,{cancelled:!0}):`error`in a?r(t,{error:a.error}):r(t,{granted:!0,info:a.info});return}case`serial-port`:{let{openSerialPickerPopup:e}=await i(async()=>{let{openSerialPickerPopup:e}=await import(`./serial-picker-BQF_Eitc.js`);return{openSerialPickerPopup:e}},__vite__mapDeps([42,40,21])),a=await e(n);`cancelled`in a?r(t,{cancelled:!0}):`error`in a?r(t,{error:a.error}):r(t,{granted:!0,info:a.info});return}case`hid-device`:{let{openHidPickerPopup:e}=await i(async()=>{let{openHidPickerPopup:e}=await import(`./hid-picker-sFJ8vzUj.js`);return{openHidPickerPopup:e}},__vite__mapDeps([43,40,21])),a=await e(n);`cancelled`in a?r(t,{cancelled:!0}):`error`in a?r(t,{error:a.error}):r(t,{granted:!0,info:a.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 V(e,t){let n=Bt();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 H(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 wi(e,t){let n=await V(`screenshare`,{constraints:{video:!0}});if(!n){t(e,{error:`screen capture is not available`});return}if(!n.ok){H(e,n,`screen capture is not available`,t);return}let r=n.grant,{adoptDisplayStream:a,displaySessions:o}=await i(async()=>{let{adoptDisplayStream:e,displaySessions:t}=await import(`./screencapture-media-BxRLHqjA.js`);return{adoptDisplayStream:e,displaySessions:t}},[]);try{let n=await a(r.stream);if(!n.handle){t(e,{error:`screen share produced no handle`});return}let{keepAdoptedScreenShare:s}=await i(async()=>{let{keepAdoptedScreenShare:e}=await import(`./screen-share-approval-live-D388fVD9.js`);return{keepAdoptedScreenShare:e}},[]);if(!s(n.handle,e=>o.stop(e))){t(e,{cancelled:!0});return}t(e,{granted:!0,handle:n.handle})}catch(n){t(e,{error:n instanceof Error?n.message:String(n)})}}async function Ti(e,t){let n=await V(`filesystem`);if(!n){t(e,{error:`File System Access API not available`});return}if(!n.ok){H(e,n,`File System Access API not available`,t);return}let r=n.grant.handle,a=`pendingMount:dip-${Date.now().toString(36)}-${Math.random().toString(36).slice(2,10)}`;try{let{storePendingHandle:e}=await i(async()=>{let{storePendingHandle:e}=await import(`./mount-picker-popup-qcWGbpG5.js`);return{storePendingHandle:e}},__vite__mapDeps([39,3,40,21]));await e(a,r)}catch(n){t(e,{error:`failed to store directory handle: ${n instanceof Error?n.message:String(n)}`});return}t(e,{handleInIdb:!0,idbKey:a,dirName:r.name})}async function Ei(e,t,n){let r=await V(`usb`,{filters:t});if(!r){n(e,{error:`WebUSB is not available`});return}if(!r.ok){H(e,r,`WebUSB is not available`,n);return}let a=r.grant,{getSharedUsbRegistry:o,deviceToInfo:s}=await i(async()=>{let{getSharedUsbRegistry:e,deviceToInfo:t}=await import(`./usb-device-registry--JwKRTYp.js`).then(e=>e.c);return{getSharedUsbRegistry:e,deviceToInfo:t}},__vite__mapDeps([44,1])),c=o().register(a.device);n(e,{granted:!0,handle:c,info:s(c,a.device)})}async function Di(e,t,n){let r=await V(`serial`,t.length?{filters:t}:void 0);if(!r){n(e,{error:`Web Serial is not available`});return}if(!r.ok){H(e,r,`Web Serial is not available`,n);return}let a=r.grant,o=await i(()=>import(`./serial-port-registry-CCqklAEr.js`).then(e=>e.o),__vite__mapDeps([45,1])),s=o.getSharedSerialRegistry(),c=s.register(a.port),l=s.get(c);n(e,{granted:!0,handle:c,info:l?o.deviceToInfo(c,l):{handle:c}})}async function Oi(e,t,n){let r=await V(`hid`,{filters:t});if(!r){n(e,{error:`WebHID is not available`});return}if(!r.ok){H(e,r,`WebHID is not available`,n);return}let a=r.grant,{getSharedHidRegistry:o,hidDeviceToInfo:s}=await i(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([46,1])),c=o(),l=a.devices.map(e=>{let t=c.register(e);return s(t,e)}),u=l[0];n(e,{granted:!0,handle:u.handle,info:u,devices:l})}function ki(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`?hi(t.url):t.type===`dip-readfile`||t.type===`dip-exists`||t.type===`dip-stat`?mi(i.contentWindow,t):t.type===`dip-exec`||t.type===`dip-agent`||t.type===`dip-jsh`?pi(i.contentWindow,t):t.type===`dip-device-op`?fi(i.contentWindow,t):t.type===`dip-picker-action`&&Si(t,n))};return window.addEventListener(`message`,a),i.addEventListener(`load`,()=>{In(i.contentWindow),i.contentWindow&&(L.add(i.contentWindow),r&&I.add(i.contentWindow)),i.contentWindow?.postMessage({type:`dip-render`,srcdoc:t,isLight:Fn()},`*`)},{once:!0}),{dispose(){window.removeEventListener(`message`,a),Pn(i.contentWindow),i.contentWindow&&(L.delete(i.contentWindow),I.delete(i.contentWindow),oi(i.contentWindow)),i.remove()}}}var Ai=`---
|
|
242
|
-
writablePaths:
|
|
243
|
-
- /workspace/CLAUDE.md
|
|
244
|
-
- /shared/wiki/
|
|
245
|
-
visiblePaths:
|
|
246
|
-
- /sessions/
|
|
247
|
-
- /shared/
|
|
248
|
-
- /workspace/
|
|
249
|
-
allowedCommands:
|
|
250
|
-
- awk
|
|
251
|
-
- cat
|
|
252
|
-
- cp
|
|
253
|
-
- cut
|
|
254
|
-
- echo
|
|
255
|
-
- file
|
|
256
|
-
- find
|
|
257
|
-
- grep
|
|
258
|
-
- head
|
|
259
|
-
- jq # structured reads of JSON stores such as /shared/loose-ends.json and /sessions/index.json
|
|
260
|
-
- ls
|
|
261
|
-
- mkdir
|
|
262
|
-
- mv
|
|
263
|
-
- od # read-only byte inspection of corrupted stores
|
|
264
|
-
- printf
|
|
265
|
-
- rg # recursive, .gitignore-aware search; what the pass actually uses over find|xargs grep. Exit 1 = no match (\`-c\` prints nothing, not \`0\`); exit 2 = searchable-byte limit (stderr names the budget). Later commands still run.
|
|
266
|
-
- sed
|
|
267
|
-
- sort
|
|
268
|
-
- tail
|
|
269
|
-
- tr
|
|
270
|
-
- uniq
|
|
271
|
-
- uname # \`uname -r\` prints the running SLICC version; pin runtime claims to it rather than to a version named in the (possibly stale) snapshot
|
|
272
|
-
- upskill
|
|
273
|
-
- wc
|
|
274
|
-
timeoutSeconds: 1200
|
|
275
|
-
dreamTimeoutSeconds: 3600
|
|
276
|
-
thinkingLevel: medium
|
|
277
|
-
---
|
|
278
|
-
|
|
279
|
-
# Memory pass
|
|
280
|
-
|
|
281
|
-
You maintain one cone's durable memory: the file at {{MEMORY_PATH}}. Today's date is {{TODAY}}; {{SESSION_COUNT}} sessions are archived. The whole file has a hard budget of {{BUDGET_CHARS}} characters, with no exempt region.
|
|
282
|
-
|
|
283
|
-
## This pass
|
|
284
|
-
|
|
285
|
-
{{TASK}}
|
|
286
|
-
|
|
287
|
-
Read the entire current memory at {{MEMORY_PATH}} first. Every part of the file is editable and counts toward the budget.
|
|
288
|
-
|
|
289
|
-
You can read only {{VISIBLE_PATHS}} (plus your scratch folder). Everything else — \`/etc/\`, \`/cones/\`, another unit's folder — is **outside your visiblePaths**: a read there answers \`No such file or directory\` or a listing with the entry missing, and either answer means _unknown_, never _absent_. The runtime appends a \`[not visible from this pass]\` note to any command that probed such a path. Never record an invisible path, or what it holds, as missing, changed or wrong, and never refute a stored claim on that basis — \`memory_write\` refuses the line. Leave the claim standing and name the pair in your closing report.
|
|
290
|
-
|
|
291
|
-
## Mining the session archive (curation passes only)
|
|
292
|
-
|
|
293
|
-
Three things carry across sessions, and each has its own place in the archive:
|
|
294
|
-
|
|
295
|
-
| Look for | Where it lives |
|
|
296
|
-
| --------------- | ---------------------------------------------------------------------- |
|
|
297
|
-
| **Preferences** | the user's own messages — how they want things done, and what to avoid |
|
|
298
|
-
| **Projects** | tool-call arguments — the paths, repos and files actually worked on |
|
|
299
|
-
| **Pitfalls** | failed tool calls — what broke, and the error that proves it |
|
|
300
|
-
|
|
301
|
-
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.
|
|
302
|
-
|
|
303
|
-
**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.
|
|
304
|
-
|
|
305
|
-
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.
|
|
306
|
-
|
|
307
|
-
\`\`\`bash
|
|
308
|
-
wc -c {{SESSION_ARCHIVE_PATH}}
|
|
309
|
-
|
|
310
|
-
# Preferences — what the user asked for, in their words.
|
|
311
|
-
sed '/^<!-- slicc:session-data$/,/^-->$/d' {{SESSION_ARCHIVE_PATH}} \\
|
|
312
|
-
| awk '/^## User/{p=1;next} /^## (Assistant|Summary)/{p=0} /^### Tool/{p=0} p'
|
|
313
|
-
|
|
314
|
-
# Projects — the paths touched most, which name the work.
|
|
315
|
-
sed '/^<!-- slicc:session-data$/,/^-->$/d' {{SESSION_ARCHIVE_PATH}} \\
|
|
316
|
-
| grep -o '/[A-Za-z0-9_][A-Za-z0-9_./-]\\{3,\\}' \\
|
|
317
|
-
| sort | uniq -c | sort -rn | head -40
|
|
318
|
-
|
|
319
|
-
# Pitfalls — failed calls with the input that caused them.
|
|
320
|
-
sed '/^<!-- slicc:session-data$/,/^-->$/d' {{SESSION_ARCHIVE_PATH}} \\
|
|
321
|
-
| grep -B6 '^Result:.*\\(rror\\|not found\\|failed\\|denied\\|ENOENT\\|fatal\\)' \\
|
|
322
|
-
| cut -c1-200
|
|
323
|
-
\`\`\`
|
|
324
|
-
|
|
325
|
-
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.
|
|
326
|
-
|
|
327
|
-
### Suggesting a skill
|
|
328
|
-
|
|
329
|
-
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:
|
|
330
|
-
|
|
331
|
-
\`\`\`bash
|
|
332
|
-
upskill search <a few words from the pitfall>
|
|
333
|
-
upskill list # what is already installed — never suggest a duplicate
|
|
334
|
-
\`\`\`
|
|
335
|
-
|
|
336
|
-
\`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.
|
|
337
|
-
|
|
338
|
-
## Consolidating (every pass)
|
|
339
|
-
|
|
340
|
-
The file accumulates under time pressure; every pass leaves it better than it found it:
|
|
341
|
-
|
|
342
|
-
1. **Merge duplicates.** Across weeks the same preference or project fact accumulates near-identical phrasings. Keep one — the most recent, most specific version.
|
|
343
|
-
2. **Supersede contradictions.** When two lines contradict, the newer-dated one wins; rewrite in place so only one version stands — a claim and its correction must never survive together as prose. Resolve only with evidence you can actually read: a path outside your visiblePaths is evidence for neither side, and settling toward the copy you happen to see is exactly the error this rule exists to prevent. When the refuted claim is a trap worth remembering, record it under a \`## Not true\` section as \`- not: <refuted claim> — why: <evidence> — instead: <correction> (YYYY-MM-DD)\`. A fact contradicted by the session titles in the index (a project renamed, a tool replaced) goes too. Count contradictory claim pairs before and after the rewrite and put both numbers in the closing report; if the pass could not reduce the count, say so.
|
|
344
|
-
3. **Retire stale ephemera.** An entry whose \`stale_after: YYYY-MM-DD\` date has passed is unverified — re-verify it against the index or drop it. Sections whose last-verified date is old AND whose subject no longer appears in recent session titles are candidates for deletion — check before deleting:
|
|
345
|
-
|
|
346
|
-
\`\`\`bash
|
|
347
|
-
# Recent activity, to test whether an old section still matters.
|
|
348
|
-
jq -r '.[] | "\\(.frozenAt[0:10]) \\(.cone // "cone") \\(.title)"' /sessions/index.json | tail -40
|
|
349
|
-
\`\`\`
|
|
350
|
-
|
|
351
|
-
4. **Reorganize.** Fold orphan bullets into the per-topic section they belong to; split a section that has become two topics; order sections so the most-used topics lead. Every \`##\` and \`###\` heading keeps (or gains) its last-verified date in \`YYYY-MM-DD\` form.
|
|
352
|
-
5. **Move knowledge to the wiki.** When the file is over budget and a section is reference knowledge — facts about a domain, a system, a person — rather than working preferences or pitfalls, move it to a page under \`/shared/wiki/\` following \`/shared/wiki/WIKI.md\` (update \`index.md\`, append an \`ingest\` entry to \`log.md\`), and replace the section with one line naming the page. Move at most a couple of sections per pass; the memory file must keep working standalone.
|
|
353
|
-
6. **Land under budget.** The hard budget is {{BUDGET_CHARS}} characters for the whole file, no exempt region. When over budget, compact or remove the oldest-dated sections first.
|
|
354
|
-
|
|
355
|
-
A pass never adds facts that are not in the session archive, the file or the wiki, never installs anything, and never touches any file other than {{MEMORY_PATH}} and the wiki.
|
|
356
|
-
|
|
357
|
-
## Entry grammar: provenance and supersession
|
|
358
|
-
|
|
359
|
-
Facts age. Write every entry so a later pass can tell whether it still holds:
|
|
360
|
-
|
|
361
|
-
- Prefix entries with their actor: \`human:\` for what the user said, \`process:\` for what you inferred from tool output. Example: \`- human: prefers rebase over merge (2026-09-11)\`.
|
|
362
|
-
- Version-pin claims that can rot: name the version, commit, or file the claim was verified against, e.g. \`- process: coverage floor is 83% (coverage-thresholds.json @ 6.146.2)\`. Runtime version comes from \`uname -r\`, not from a version named in this file. Never record a confidence score — what ages is the pin, not a probability.
|
|
363
|
-
- A claim with a known expiry carries \`stale_after: YYYY-MM-DD\`, an absolute date, never a duration. Past that date the claim counts as unverified.
|
|
364
|
-
- **Supersede, never append.** When a session proves a stored claim wrong, rewrite the claim in place — a claim and its correction must never both stand as prose (see step 2 above for the \`## Not true\` form).
|
|
365
|
-
|
|
366
|
-
## Working within the budget
|
|
367
|
-
|
|
368
|
-
Measure, decide, then write. Do not converge on the budget by trial and error — each attempt re-reads your whole context and is billed accordingly.
|
|
369
|
-
|
|
370
|
-
1. \`wc -c {{MEMORY_PATH}}\` to get the current size, and subtract {{BUDGET_CHARS}} to get the exact surplus. Per-section costs come out of \`awk\`: \`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.
|
|
371
|
-
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.
|
|
372
|
-
3. Write with the \`memory_write\` tool (\`path: {{MEMORY_PATH}}\`). It is the only tool that can write the memory file — \`write_file\`, \`edit\`, \`cp\` and \`cat >\` are refused on it — and it refuses any write that would leave the file over budget without shrinking it. Prefer \`edits\` (exact replacements, one section at a time): every write leaves a whole, budget-checked file, and a run stopped at its bound lands whatever the file holds at that moment, so finished sections are never lost; use \`content\` for a whole-file rewrite at most once, already inside the budget, and never draft the whole file elsewhere first — emitting it twice is what runs a pass out of time. 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.
|
|
373
|
-
4. Read the size and the remaining room from the tool's result — it reports both, so do not spend a turn on \`wc -c\` afterwards. If it says you are still over, cut a whole section rather than shaving a few characters at a time.
|
|
374
|
-
|
|
375
|
-
Scratch for notes (not for drafting the whole file) is \`{{SCRATCH_DIR}}/\`: your own folder, writable without a grant and without an approval prompt, private to this pass, and deleted when the pass ends.
|
|
376
|
-
|
|
377
|
-
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.
|
|
378
|
-
|
|
379
|
-
## Rules
|
|
380
|
-
|
|
381
|
-
- Keep durable preferences, stable project facts, validated approaches, named resources, and the pitfalls worth not repeating.
|
|
382
|
-
- 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.
|
|
383
|
-
- Never write next to the memory file: backups and scratch copies beside it are noise. Do not draft in the shared \`/tmp/\` root either — every other unit can read and overwrite what you leave there.
|
|
384
|
-
- 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.
|
|
385
|
-
- 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.
|
|
386
|
-
- Re-stamp a heading with {{TODAY}} only when you wrote or actually re-verified its content this pass; otherwise keep its existing date. Treat undated headings as maximally stale and date them on this pass.
|
|
387
|
-
- Prioritize re-verifying the oldest-dated sections. Drop ephemera and duplicates; delete or merge sections that are stale, superseded, or unverifiable.
|
|
388
|
-
- Preserve concrete identifiers such as file paths, URLs, IDs, and names verbatim.
|
|
389
|
-
- A path outside your visiblePaths is unknown, not absent (see "This pass" above): never write it off as missing, never refute a claim about it, and report the unverifiable pair instead.
|
|
390
|
-
- Write the result to {{MEMORY_PATH}}; do not merely return it in your response.
|
|
391
|
-
- Close with a two-or-three-line report of what you kept, merged and dropped (plus any skill worth suggesting, and the contradiction-pair counts before and after) — that report is delivered to the cone.
|
|
392
|
-
|
|
393
|
-
<!-- How to customize
|
|
394
|
-
Add instructions here, for example: never drop sections mentioning a named project, or also consolidate a knowledge base at /path (extend visiblePaths or writablePaths above to grant access to extra stores). One document drives both passes: the per-session curation pass the freezer runs after a chat ends, and the nightly consolidation ("dreaming") pass the gelatiere starts with \`memory dream --all\` (\`memory dream\` runs one by hand). The runtime fills {{TASK}} with which pass this is; everything else in the document applies to both.
|
|
395
|
-
|
|
396
|
-
timeoutSeconds bounds a curation pass and dreamTimeoutSeconds a consolidation pass — the run is hard-stopped at the bound, and a rewrite only lands through the merge below, which is why the budget section asks for section-wise edits. The nightly has no time pressure, so its bound is generous; the curation pass runs while the user waits for memory to settle.
|
|
397
|
-
|
|
398
|
-
{{MEMORY_PATH}} resolves to a staged draft under /sessions/.curation/, not the live memory file: the pass snapshots the live file when it spawns, 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 pass runs survive; where both sides changed the same lines the pass's version wins. An entry in writablePaths naming the memory file is substituted with the draft automatically, so this file keeps working unchanged. A run stopped at its wall-clock bound has its draft merged as a truncated success (\`memory_write\` never leaves it half-written); any other failure leaves the live memory untouched. Either outcome is recorded at /sessions/.curation/<key>/status.json, and the cone's scoop-notify waits for that receipt so a non-zero exit is reported as failed (with the reason and status.json path) rather than completed. Writes under /shared/wiki/ are NOT staged — a wiki page lands immediately — which is safe because wiki moves are additive; the pointer line replacing the moved section only lands if the pass completes.
|
|
399
|
-
|
|
400
|
-
writablePaths defaults to the memory file plus the wiki rather than /workspace/, because the pass 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.
|
|
401
|
-
|
|
402
|
-
visiblePaths is the pass's whole world: a read outside it answers like a missing file (the shell's commands print "No such file or directory" for every error), so the runtime keeps a ledger of those blind reads, names them in a note on the command's result, and has memory_write refuse a line that records one as absent or refuted (slicc#3459). Add a root here — /etc/ for the policy files, say — when a task must verify facts there; that is the only way a pass can know what such a path holds.
|
|
403
|
-
|
|
404
|
-
Scratch space needs no entry here. Each pass spawns under a fixed per-cone name (memory-curator / memory-dreamer for the primary cone, -<folder> suffixed for extra cones), so the bridge grants it {{SCRATCH_DIR}} — private to the run, writable without a prompt, and removed when the pass ends. Parallel passes over DIFFERENT memory files never collide; two passes over the SAME file serialize. $TMPDIR is writable too and is this unit's own directory, but it outlives the run and stays readable by the cone, so durable memory does not belong there.
|
|
405
|
-
|
|
406
|
-
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.
|
|
407
|
-
|
|
408
|
-
This file is user-edited only: the pass intentionally cannot rewrite its own instructions. A bare / is rejected in writablePaths. It is seeded only when absent, so edits survive later boots; \`upgrade\` three-way-merges a changed bundled version onto your edits.
|
|
409
|
-
|
|
410
|
-
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/"].
|
|
411
|
-
-->
|
|
412
|
-
`,ji=`/etc/MEMORY.md`,Mi=4e3,Ni=2e3;function Pi(e){return Math.round(Mi+Ni*Math.log2((Number.isFinite(e)&&e>=0?e:0)+2))}var Fi=`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(`.`),Ii=`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(`.`);Fi.length*Ii.length;var Li=[`off`,`minimal`,`low`,`medium`,`high`,`xhigh`];function Ri(e){return typeof e==`string`&&Li.includes(e)}o(`agent-bridge`);var zi=`agent: name already in use`,Bi=o(`cone-memory-budget`),Vi=1.25,Hi=k.memoryPath,Ui=`/sessions/index.json`,Wi=4096,Gi=/^## Auto-extracted/m,Ki=`Consolidate the auto-extracted memory bullets below into a single tighter set of durable memories.
|
|
413
|
-
|
|
414
|
-
Rules:
|
|
415
|
-
- Output ONLY a single \`## Auto-extracted (consolidated)\` heading followed by markdown bullets.
|
|
416
|
-
- One fact per bullet. Drop duplicates and superseded facts. Keep the most recent / specific phrasing.
|
|
417
|
-
- Preserve concrete identifiers (file paths, URLs, IDs, names) verbatim.
|
|
418
|
-
- Be terse. Aim well under the original size.
|
|
419
|
-
- Do NOT add preamble, commentary, or any heading other than the single consolidated one.`;function qi(e){let t=Gi.exec(e);if(!t)return{header:e,autoExtracted:``};let n=t.index;return{header:e.slice(0,n),autoExtracted:e.slice(n)}}async function Ji(e){try{let t=await e.readFile(Ui,{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 Yi(e){let{header:t,autoExtracted:n}=qi(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.
|
|
420
|
-
|
|
421
|
-
<auto-extracted>
|
|
422
|
-
${n}
|
|
423
|
-
</auto-extracted>`,i={role:`user`,content:[{type:`text`,text:Ki}],timestamp:Date.now()},o=await a(e.model,{systemPrompt:r,messages:[i]},{apiKey:e.apiKey,maxTokens:Wi,headers:e.headers,signal:e.signal});if(o.stopReason===`error`)throw Error(`Restructure call failed: ${o.errorMessage||`Unknown error`}`);let s=o.content.filter(e=>e.type===`text`).map(e=>e.text).join(`
|
|
424
|
-
`).trim();if(!s)throw Error(`Restructure call returned empty content`);return`${t}${t.length===0||t.endsWith(`
|
|
425
|
-
`)?``:`
|
|
426
|
-
`}${s}\n`}async function Xi(e){if(!e.model||!e.apiKey)return{restructured:!1,reason:`no-llm`};let t=e.memoryPath??Hi,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 Ji(e.vfs),i=Pi(r),a=i*Vi;if(n.length<=a)return{restructured:!1,reason:`under-threshold`};Bi.info(`Cone memory over threshold — restructuring`,{size:n.length,budget:i,threshold:a,sessionCount:r});try{let r=await Yi({currentContent:n,budget:i,model:e.model,apiKey:e.apiKey,headers:e.headers,signal:e.signal});return await e.vfs.writeFile(t,r),Bi.info(`Cone memory restructured`,{before:n.length,after:r.length}),{restructured:!0}}catch(e){return Bi.warn(`Cone memory restructure failed — leaving appended content in place`,{error:e instanceof Error?e.message:String(e)}),{restructured:!1,reason:`error`}}}var Zi=o(`agentic-memory`),Qi=1200,$i=3600,ea=7200,ta=e=>[e.memoryPath],na=e=>[`/sessions/`,`/shared/`,...On(e)],ra=`awk.cat.cp.cut.date.diff.du.echo.file.find.grep.head.jq.ls.mkdir.mount.mv.nl.od.printf.readlink.rg.sed.sort.stat.tail.touch.tr.uniq.uname.upskill.wc.xxd`.split(`.`),ia={arrayKeys:new Set([`writablePaths`,`visiblePaths`,`allowedCommands`]),scalarKeys:new Set([`model`,`timeoutSeconds`,`dreamTimeoutSeconds`,`thinkingLevel`])},aa=`medium`,oa=3e4;function sa(e){return e===`cone`?`memory-curator`:`memory-curator-${e}`}var ca={kind:`curate`,nameFor:sa,rivalsFor:e=>[fa(e)]},la=`{{TASK}}`,ua=`(no session archive this pass)`;function da(e,t,n){return e.kind===`dream`?`**Consolidation pass** (the nightly dreaming): there is NO new session to mine — skip "Mining the session archive" entirely. Your whole job is to make the existing memory better: consolidated, current, and inside its budget. If the file is missing or empty, reply with one line saying so and stop; never invent memories. The run is hard-stopped after ${n} minutes; a run stopped at that bound lands whatever the memory file holds at that moment (every memory_write leaves a whole, budget-checked file), so consolidate section by section, writing as you go, and finish cleanly when you can.`:`**Curation pass**: mine the archived session at ${t} for what is worth carrying into future sessions, fold it into the memory, and consolidate the whole file in the same pass. Work fast: a pass should finish in well under 10 minutes and is hard-stopped after ${n} minutes — mine the three signals, write, and stop, rather than exploring the archive exhaustively.`}function fa(e){return e===`cone`?`memory-dreamer`:`memory-dreamer-${e}`}function pa(e,t){let n=e.nameFor(t);return ha.test(n)?n:e.nameFor(En)}function ma(e,t){let n=ha.test(e.nameFor(t))?t:En;return e.rivalsFor?.(n)??[]}var ha=/^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/;function ga(e,t){return`/scoops/agent-${pa(e,t)}`}function _a(e){return ga(ca,e)}var va=_a(En);function ya(e){return Mn({parentJid:null,folder:e?.folder??`cone`})}function ba(e,t){if(t.root===k.root)return e;if(e===k.memoryPath)return t.memoryPath;if(e===`/workspace/skills`||e.startsWith(`/workspace/skills/`))return e;let n=`${k.root}/`;return e===k.root?t.root:e.startsWith(n)?`${t.root}/${e.slice(n.length)}`:e}function xa(e,t){let n=`${kn}/`,r=e=>e.some(e=>n.startsWith(e.endsWith(`/`)?e:`${e}/`)),i=e.map(e=>ba(e,t));return r(e)&&!r(i)&&i.push(n),i}async function Sa(e){try{if(e.signal?.aborted)return{ok:!1,reason:`aborted`,legacyFallbackSafe:!1};let t=e.instructions??ca,n=ya(e.cone),r=ga(t,e.cone?.folder??`cone`),i=await Ca(e.vfs,n),a=t.kind===`dream`?i.dreamTimeoutSeconds:i.timeoutSeconds,o=Oa(e.sessionArchivePath);try{await Aa(e.vfs,n.memoryPath,e.sessionArchivePath)}catch(e){return{ok:!1,reason:`snapshot: ${Ia(e)}`,legacyFallbackSafe:!0}}let s=t.kind===`dream`?ua:e.sessionArchivePath,c=Math.max(1,Math.round(a/60)),l=da(t,s,c),u=Ma(i,a,Na(Pa(i.promptTemplate.includes(la)?i.promptTemplate:`${i.promptTemplate.trimEnd()}\n\n${la}`,{MEMORY_PATH:o,SESSION_ARCHIVE_PATH:s,SESSION_COUNT:String(e.sessionCount),BUDGET_CHARS:String(Pi(e.sessionCount)),SCRATCH_DIR:r,VISIBLE_PATHS:i.visiblePaths.join(`, `),TODAY:e.today??new Date().toISOString().slice(0,10),TIMEOUT_MINUTES:String(c),TASK:l}),r),e.sessionArchivePath,n,e.cone,t);e.signal&&(u.signal=e.signal);let d=await Fa(Promise.resolve().then(()=>e.spawn(u)),a*1e3+oa,e.signal);if(d.type===`timeout`)return Zi.warn(`Agentic memory wait timed out past the in-run bound + grace`,{timeoutSeconds:a,graceMs:oa}),{ok:!1,reason:`timeout`,legacyFallbackSafe:!1};if(d.type===`aborted`)return{ok:!1,reason:`aborted`,legacyFallbackSafe:!1};if(d.type===`error`)return{ok:!1,reason:Ia(d.error),legacyFallbackSafe:!0};if(d.result.exitCode!==0){let e=(d.result.finalText??``).startsWith(zi);return{ok:!1,reason:d.result.finalText||`exit-${d.result.exitCode}`,legacyFallbackSafe:!e}}return{ok:!0,report:d.result.finalText}}catch(e){return Zi.warn(`Agentic memory pass failed`,{error:Ia(e)}),{ok:!1,reason:Ia(e),legacyFallbackSafe:!1}}}async function Ca(e,t=k){try{let n=await e.readFile(ji,{encoding:`utf-8`});return wa(typeof n==`string`?n:new TextDecoder().decode(n),t)}catch(e){return Zi.warn(`Could not load valid ${ji}; using built-in default`,{error:Ia(e)}),wa(Ai,t)}}function wa(e,t=k){let n=b(e,`MEMORY.md`),r=Ce(n.frontmatter,ia),i=v(r,`writablePaths`,ta(t));if(i.length===0)throw Error(`writablePaths must not be empty`);p(i,`writablePaths`);let a=v(r,`visiblePaths`,na(t));p(a,`visiblePaths`);let o=u(r.timeoutSeconds,600,Qi),s=u(r.dreamTimeoutSeconds,$i,ea,`dreamTimeoutSeconds`),c=xe(r.model,`model`);return{writablePaths:i.map(e=>ba(e,t)),visiblePaths:xa(a,t),allowedCommands:[...new Set([...ra,...v(r,`allowedCommands`,[])])],...c?{model:c}:{},thinkingLevel:Ta(r.thinkingLevel),timeoutSeconds:o,dreamTimeoutSeconds:s,promptTemplate:n.body}}function Ta(e){if(e===void 0)return aa;if(typeof e!=`string`||!Ri(e))throw Error(`thinkingLevel must be one of ${Li.join(`, `)}`);return e}function Ea(e){return`/sessions/.curated/${e.slice(e.lastIndexOf(`/`)+1)}`}function U(e){return`/sessions/.curation/${e.slice(e.lastIndexOf(`/`)+1)}`}function Da(e){return`${U(e)}/base.md`}function Oa(e){return`${U(e)}/draft.md`}function ka(e){return`${U(e)}/status.json`}async function Aa(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(U(n),{recursive:!0}),await e.writeFile(Da(n),r),await e.writeFile(Oa(n),r)}function ja(e,t,n){let r=e.map(e=>e===t?n:e);return r.includes(n)?r:[...r,n]}function Ma(e,t,n,r,i,a,o){let s=e.model===`parent`||e.model===`cone`,c=Da(r),l=Oa(r);return{cwd:i.root,writablePaths:ja(e.writablePaths,i.memoryPath,l),visiblePaths:[...e.visiblePaths,`${U(r)}/`],allowedCommands:e.allowedCommands,prompt:n,thinkingLevel:e.thinkingLevel,persistSession:!0,name:pa(o,a?.folder??`cone`),exclusiveWith:ma(o,a?.folder??`cone`),...a?.jid?{parentJid:a.jid}:{},notifyOnComplete:!0,successReceiptPath:Ea(r),mergeOnSuccess:{targetPath:i.memoryPath,basePath:c,draftPath:l},outcomeReceiptPath:ka(r),maxWallClockMs:t*1e3,...!s&&e.model?{modelId:e.model}:{}}}function Na(e,t){if(t===va)return e;let n=`\0SCRATCH\0`;return e.replaceAll(t,n).replaceAll(va,t).replaceAll(n,t)}function Pa(e,t){let n=e;for(let[e,r]of Object.entries(t))n=n.replaceAll(`{{${e}}}`,r);return n}function Fa(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 Ia(e){return e instanceof Error?e.message:String(e)}function La(e){let t=0;for(let n of e)n.timestamp>t&&(t=n.timestamp);return t}function Ra(e,t){return t>0?e.filter(e=>e.timestamp>t):[...e]}o(`live-session-curation`);var za=8e4,Ba=`/sessions/.live-deltas`,Va={maxMessages:200,maxChars:za};function Ha(e,t,n){return`${Ba}/${e}-${t}-${n}.md`}function Ua(e,t=Va){if(e.length===0)return[];let n=[],r=0;for(let i of e){let e=Qa(i);if(n.length>=t.maxMessages||n.length>0&&r+e>t.maxChars)break;n.push(i),r+=e}n.length===0&&n.push(e[0]);let i=n[n.length-1].timestamp,a=n.length;for(;a<e.length&&e[a].timestamp===i;)n.push(e[a]),a+=1;return n}async function Wa(e,t,n,r){let i=t.curatedThrough??0,a=t.sessionId?await qa(e,t.sessionId,t.filename,n,i,r):i;return{through:a,caughtUp:a>0&&Ra(n,a).length===0}}async function Ga(e,t){let n=(t.curatedThrough??0)>0,r=await qa(e,t.sessionId,t.filename,t.messages,t.curatedThrough??0),i=Ra(t.messages,r);if(i.length===0)return{kind:`covered`,through:r};if(!n&&r===0)return{kind:`full`};let a=La(i),o=Ha(t.sessionId,r,a);return await Xa(e,o)?(await Ka(e,t.filename,a),{kind:`covered`,through:a}):(await Ja(e,t,i,o),{kind:`delta`,path:o,through:a,messages:[...i]})}async function Ka(e,t,n){n>0&&await w(async()=>{let r=await ut($a(e)),i=r.findIndex(e=>e.filename===t);if(i===-1||n<=(r[i].curatedThrough??0))return;let{memoryFailed:a,...o}=r[i],s=r.slice();s[i]={...o,curatedThrough:n},await et($a(e),s),await Ya(e,`${T}/${t}`,n),await e.flush?.()})}async function qa(e,t,n,r,i,a){let o=i;for(let n=0;n<50;n+=1){let n=Ra(r,o);if(n.length===0)break;let i=La(Ua(n,a??Va));if(i<=o||!await Xa(e,Ha(t,o,i)))break;o=i}return o>i&&await Ka(e,n,o),o}async function Ja(e,t,n,r){let i={id:t.sessionId,sessionId:t.sessionId,title:t.title,frozenAt:t.frozenAt,createdAt:n[0]?.timestamp??0,updatedAt:La(n),messageCount:n.length,messages:[...n],...t.cone?{cone:t.cone}:{},...t.coneLabel?{coneLabel:t.coneLabel}:{}};await e.mkdir(Ba,{recursive:!0}),await e.writeFile(r,ct(i))}async function Ya(e,t,n){let r;try{r=await Za(e,t)}catch(e){if(eo(e))return;throw e}let i=r.match(/^---\n([\s\S]*?)\n---\n/);if(!i)return;let a=`curatedThrough: ${n}`,o=/^curatedThrough:\s*\d+\s*$/m.test(i[1])?i[1].replace(/^curatedThrough:\s*\d+\s*$/m,a):`${i[1]}\n${a}`;o!==i[1]&&await e.writeFile(t,`---\n${o}\n---\n${r.slice(i[0].length)}`)}async function Xa(e,t){try{return await e.readFile(Ea(t),{encoding:`utf-8`}),!0}catch(e){if(eo(e))return!1;throw e}}async function Za(e,t){let n=await e.readFile(t,{encoding:`utf-8`});return typeof n==`string`?n:new TextDecoder().decode(n)}function Qa(e){let t=e.toolCalls?JSON.stringify(e.toolCalls).length:0;return e.content.length+t}function $a(e){return e}function eo(e){return e instanceof Vt?e.code===`ENOENT`:typeof e!=`object`||!e||!(`code`in e)?!1:e.code===`ENOENT`}var to=e({PENDING_SESSION_ATTEMPT_LIMIT:()=>3,SESSIONS_INDEX_PATH:()=>E,curateFrozenSessionMemories:()=>so,enrichPendingSession:()=>Fo,freezeConeSession:()=>oo,listPendingEnrichments:()=>Mo,markSnapshotUnavailable:()=>es,processPendingSessions:()=>No,readSessionsIndex:()=>C}),W=o(`session-freezer`),no=4,ro=2048,io=40,ao=`${T}/attachments`;async function oo(e){let t=await Eo(e.sessionStore,wo(e));if(!t||t.messages.length<no)return W.info(`Skipping freeze: session below threshold or missing`,{messageCount:t?.messages.length??0}),null;let n=Oo(t.messages),r=e.mode??`full`,i=r===`full`&&!!(e.apiKey&&e.model);!e.agenticMemorySpawn&&e.memory!==`skip`&&await fo(e,n,i);let a=await po(e,n,i)||Qe(t.messages);return await mo(e,t,a,r,i?await lo(e,a):void 0,!!e.agenticMemorySpawn&&e.memory!==`skip`)}async function so(e,t){let n=await Ga(e.vfs,{sessionId:t.sessionId||t.filename.replace(/\.md$/i,``),filename:t.filename,title:t.title,frozenAt:t.frozenAt,cone:t.cone,coneLabel:t.coneLabel,curatedThrough:t.curatedThrough,messages:t.archive.messages});if(n.kind===`covered`)return co(e,t,null);let r=n.kind===`delta`?n.path:Ze(t),i=n.kind===`delta`?n.messages:t.archive.messages,a;try{a=await Sa({spawn:e.agenticMemorySpawn,vfs:e.vfs,sessionArchivePath:r,sessionCount:await Ji(e.vfs),...e.cone?{cone:e.cone}:{}})}catch(e){a={ok:!1,reason:e instanceof Error?e.message:String(e),legacyFallbackSafe:!1}}return a.ok?(n.kind===`delta`&&await Ka(e.vfs,t.filename,n.through),co(e,t,r)):(await Zo(e.vfs,t.filename,a.reason),a.legacyFallbackSafe?(W.warn(`Agentic memory pass failed after finishing — falling back to legacy extraction`,{filename:t.filename,reason:a.reason}),await fo(e,Oo(i),!0),null):(W.warn(`Agentic memory pass unfinished — entry stays pending for boot catch-up`,{filename:t.filename,reason:a.reason,attemptLimit:3}),null))}async function co(e,t,n){let r=await Yo(e.vfs,t.filename);if(n){let t=n.slice(n.lastIndexOf(`/`)+1);await Ro(e.vfs,t)}return r?(delete t.memoryPending,W.info(`Agentic memory pass completed`,{filename:t.filename}),r):(W.info(`Agentic memory pass completed; index entry already gone`,{filename:t.filename}),null)}async function lo(e,t){try{return uo(await(e.pickIcon??(await i(async()=>{let{pickLucideIcon:e}=await import(`./quick-llm-lj_1jQHe.js`).then(e=>e.n);return{pickLucideIcon:e}},__vite__mapDeps([47,1,9,10,11,2,12,13,14,15,3,7,8,16,17,18,5,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,48,37]))).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 uo(e){if(e)return on(e)?e:void 0}async function fo(e,r,i){if(!i){W.info(`LLM unavailable — skipping memory extraction; freezing anyway`);return}let a=``;try{a=await t({messages:r,instruction:n,model:e.model,apiKey:e.apiKey,maxTokens:ro,headers:e.headers})}catch(e){W.warn(`Memory extraction call failed (freeze still proceeds)`,{error:e instanceof Error?e.message:String(e)});return}if(!a.trim()||a.trim()===`NONE`){W.info(`Memory extraction returned no durable memories`);return}try{await jo(e.vfs,To(wo(e)),a.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 po(e,n,i){if(!i)return``;try{return ko(await t({messages:n,instruction:r,model:e.model,apiKey:e.apiKey,maxTokens:io,headers:e.headers}))}catch(e){return W.warn(`Title generation call failed (using heuristic)`,{error:e instanceof Error?e.message:String(e)}),``}}async function mo(e,t,n,r,a,o=!1){let s=new Date().toISOString(),c=wo(e),l=await Do(e.vfs,c),u=l?.sessionId??crypto.randomUUID(),d=l?.filename??(r===`quick`?`pending-${ot()}.md`:`${s.replace(/[:.]/g,`-`)}-${rt(n)}.md`),f=ho(t.messages),p={cone:c,...c!==`cone`&&e.cone?.label?{coneLabel:e.cone.label}:{}},m={filename:d,sessionId:u,title:n,frozenAt:s,messageCount:t.messages.length,...f??{},...p,...a?{icon:a}:{},...r===`quick`||l?{pendingEnrichment:!0}:{},...o?{memoryPending:!0}:{},...e.memory===`skip`?{memorySkipped:!0}:{},...l?.curatedThrough?{curatedThrough:l.curatedThrough}:{}};try{await Ao(e.vfs,T);let r=await vo(e.vfs,t.messages,d.replace(/\.md$/,``)),a={id:t.id,sessionId:u,title:n,frozenAt:s,createdAt:t.createdAt,updatedAt:t.updatedAt,messageCount:t.messages.length,messages:r,...f??{},...p,...e.memory===`skip`?{memorySkipped:!0}:{},...l?.curatedThrough?{curatedThrough:l.curatedThrough}:{}};if(Te(`memory-v2`)){let{writeArchiveBundle:t}=await i(async()=>{let{writeArchiveBundle:e}=await import(`./session-jsonl-sSMKZwgt.js`).then(e=>e.i);return{writeArchiveBundle:e}},__vite__mapDeps([49,1,0,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,50]));await t(e.vfs,d,a)}else await e.vfs.writeFile(`${T}/${d}`,ct(a));return await tt(e.vfs,m),await e.vfs.flush(),W.info(`Cone session frozen`,{filename:d,title:n,cone:c,messageCount:t.messages.length,completedLiveSnapshot:!!l}),{...m,archive:a}}catch(e){return W.warn(`Failed to write frozen session to VFS`,{error:e instanceof Error?e.message:String(e)}),null}}function ho(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||!_o(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 go(e){return typeof e==`number`&&Number.isFinite(e)}function _o(e){let{cost:t}=e;return[e.input,e.output,e.cacheRead,e.cacheWrite].every(go)&&[t.input,t.output,t.cacheRead,t.cacheWrite,t.total].every(go)}async function vo(e,t,n){let r={vfs:e,archiveDir:`${ao}/${n}`,copiedPaths:new Map,fileIndex:0},i=[];for(let e of t){if(!e.attachments?.some(xo)){i.push(e);continue}let t=[];for(let n of e.attachments)t.push(await yo(r,n));i.push({...e,attachments:t})}return i}async function yo(e,t){if(!xo(t))return t;let n=e.copiedPaths.get(t.path);if(n)return{...t,path:n};let r=await bo(e.vfs,t.path);if(!r)return Co(t);let i=t.name.replace(/[^A-Za-z0-9._-]+/g,`_`)||`attachment`,a=`${e.archiveDir}/${e.fileIndex++}-${i}`;return await Ao(e.vfs,e.archiveDir),await e.vfs.writeFile(a,r),e.copiedPaths.set(t.path,a),{...t,path:a}}async function bo(e,t){try{if(!await So(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 xo(e){return typeof e.path==`string`&&e.path.startsWith(`/tmp/`)&&e.data===void 0&&e.text===void 0}async function So(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 Co(e){let{path:t,...n}=e;return{...n,error:e.error??`Archived attachment file is missing or unsafe to preserve.`}}function wo(e){return e.cone?.folder||`cone`}function To(e){return Mn({parentJid:null,folder:e}).memoryPath}async function Eo(e,t){let n=Cn({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 Do(e,t){try{return at(await ut(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 Oo(e){return e.map(e=>({role:e.role,content:[{type:`text`,text:e.content}],timestamp:e.timestamp}))}function ko(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 Ao(e,t){try{await e.mkdir(t,{recursive:!0})}catch{}}async function jo(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 Vt)||t.code!==`ENOENT`)throw t;await Ao(e,a.slice(0,a.lastIndexOf(`/`)))}let s=`## Auto-extracted (${new Date().toISOString().slice(0,10)}, ${r})`,c=`${o.length===0||o.endsWith(`
|
|
427
|
-
`)?``:`
|
|
428
|
-
`}\n${s}\n\n${n}\n`;await e.writeFile(a,o+c);try{await Xi({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 Mo(e){return(await C(e)).filter(e=>(e.pendingEnrichment===!0||e.memoryPending===!0)&&Po(e)<3)}async function No(e){let t={attempted:0,completed:0};if(!e.model||!e.apiKey)return t;try{for(let t of await C(e.vfs))t.memoryPending===!0&&t.memoryFailed===void 0&&Po(t)>=3&&await Zo(e.vfs,t.filename,`catch-up retries exhausted (3)`);let n=await Mo(e.vfs);for(let r of n)try{let n=await Xo(e.vfs,r.filename);if(!n)continue;t.attempted+=1,await Fo(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 Po(e){let t=e.pendingAttemptCount;return typeof t==`number`&&Number.isInteger(t)&&t>0?t:0}async function Fo(e,t,n){if(!t.pendingEnrichment&&!t.memoryPending)return null;let r=await Bo(e,t);if(r===null)return null;let i=await Vo(e,t,r);if(i===null)return null;let{agentMessages:a}=i,o=await Ho(e,t,i.chatMessages,n),s=o.curatorAlreadyRan,c=s||t.memorySkipped===!0?{...n,skipMemory:!0}:n,l=await Wo(t,a,c,o.memoryMessages);if(l===null)return null;let u=await zo(c,l.newTitle);await Go(e,t,l.bullets,c);let d=await qo(e,t,r,l.newTitle,u,n.skipMemory===!0);return d&&s&&(await Ro(e,t.filename),await Qo(e,d.filename),await Io(e,t.filename)),d}async function Io(e,t){for(let n of[Da(`/sessions/${t}`),Oa(`/sessions/${t}`)])try{await e.rm(n)}catch{}}async function Lo(e,t){try{return await e.stat(Ea(`/sessions/${t.filename}`)),!0}catch{return!1}}async function Ro(e,t){try{await e.rm(Ea(`/sessions/${t}`))}catch{}}async function zo(e,t){if(e.pickIcon)try{return await uo(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 Bo(e,t){try{let n=await e.readFile(Ze(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}}async function Vo(e,t,n){let r;try{r=(await it(e,n,t.filename)).messages}catch(e){return W.warn(`Failed to parse pending archive — leaving entry intact`,{filename:t.filename,error:e instanceof Error?e.message:String(e)}),null}return r.length===0?(W.info(`Pending archive has no messages — skipping enrichment`,{filename:t.filename}),null):{agentMessages:Oo(r),chatMessages:r}}async function Ho(e,t,n,r){let i=Oo([...n]);if(r.skipMemory===!0||t.memoryPending!==!0)return{curatorAlreadyRan:!1,memoryMessages:i};if(await Lo(e,t))return{curatorAlreadyRan:!0,memoryMessages:i};let a=await Wa(e,t,n);return a.caughtUp?{curatorAlreadyRan:!0,memoryMessages:i}:a.through>0?{curatorAlreadyRan:!1,memoryMessages:i.filter(e=>Uo(e)>a.through)}:{curatorAlreadyRan:!1,memoryMessages:i}}function Uo(e){let t=e.timestamp;return typeof t==`number`?t:0}async function Wo(e,i,a,o=i){let s=``;if(!a.skipMemory)try{s=await t({messages:o,instruction:n,model:a.model,apiKey:a.apiKey,maxTokens:ro,headers:a.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 c=``;try{c=ko(await t({messages:i,instruction:r,model:a.model,apiKey:a.apiKey,maxTokens:io,headers:a.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 c?{bullets:s,newTitle:c}:(W.info(`Enrichment title call returned empty — entry stays pending`,{filename:e.filename}),null)}async function Go(e,t,n,r){let i=n.trim();if(!(!i||i===`NONE`))try{await jo(e,To(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 Ko(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}:{},...e.curatedThrough?{curatedThrough:e.curatedThrough}:{},...a?{icon:a}:{},...e.completeSnapshotUnavailable?{completeSnapshotUnavailable:!0}:{},...i&&e.memoryPending?{memoryPending:!0}:{},...e.memorySkipped?{memorySkipped:!0}:{}}}async function qo(e,t,n,r,i,a=!1){let o=Ze(t),s=nt(t.filename),c=s?r:t.title,l=s?`${t.frozenAt.replace(/[:.]/g,`-`)}-${rt(r)}.md`:t.filename,u=`${T}/${l}`;if(s)try{await Ao(e,T);let r=Jo(n,c),i=Xe(t.filename),a=Xe(l),s=$e(r,o,u);if(s=$e(s,i,a),i!==a){let e=i.slice(i.lastIndexOf(`/`)+1),t=a.slice(a.lastIndexOf(`/`)+1);s=s.split(`sidecar: ${e}`).join(`sidecar: ${t}`)}await e.writeFile(u,s),await lt(e,t.filename,l)}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=Ko(t,l,c,i,a);try{await $o(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 st(e,t.filename)}catch(e){W.info(`Stale pending sidecar cleanup failed (harmless)`,{filename:t.filename,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 Jo(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 Yo(e,t){let n=null,r=w(async()=>{let r=await C(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(E,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 Xo(e,t){let n=null;return await w(async()=>{let r=await C(e),i=r.findIndex(e=>e.filename===t);if(i===-1)return;let a=r[i];if(!a.pendingEnrichment&&!a.memoryPending)return;let o=Po(a);if(o>=3)return;n={...a,pendingAttemptCount:o+1};let s=r.slice();s[i]=n,await e.writeFile(E,JSON.stringify(s,null,2)),await e.flush()}),n}async function Zo(e,t,n){let r=w(async()=>{let r=await C(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(E,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 Qo(e,t){let n=w(async()=>{let n=await C(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(E,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 $o(e,t,n){return w(async()=>{let r=[];try{let t=await e.readFile(E,{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 Vt)||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(E,JSON.stringify(a,null,2))})}async function es(e,t){return w(async()=>{let n=[];try{let t=await e.readFile(E,{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 Vt)||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(E,JSON.stringify(r,null,2))})}var ts=`slicc:followers-changed`;function ns(e){let t=e.replace(/^follower-/,``);return t.length>12?`${t.slice(0,8)}…`:t}function rs(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 is(e){return e.floatType===`ios`?`smartphone`:e.floatType===`electron`||e.floatType===`standalone`?`monitor`:e.floatType===`extension`?`blocks`:e.runtime?.includes(`cli`)?`terminal`:`radio`}function as(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 os(e){return e.health===`stalled`?`warn`:e.peerState===`connecting`?`idle`:e.peerState===`connected`&&e.health===`live`?`active`:`idle`}function ss(e,t=Date.now()){let n=e.health===`stalled`?`stalled`:e.peerState===`connecting`?`connecting`:`connected`,r=as(e.connectedAt,t);return r?`${n} ${r}`:n}function cs(e){let t=[];return e.exec&&t.push(`can run commands`),e.computer&&t.push(`native screen`),e.cdp&&t.push(`hosts tabs`),t}function ls(e){return`${rs(e)} · ${ns(e.runtimeId)}`}function us(e){return e.motd??e.runtime??void 0}function ds(e,t=Date.now()){return e.map(e=>({id:e.runtimeId,icon:is(e),title:ls(e),detail:us(e),state:os(e),stateText:ss(e,t),chips:cs(e)}))}function fs(e){return e.length>=8&&e[0]===137&&e[1]===80&&e[2]===78?`image/png`:e.length>=3&&e[0]===255&&e[1]===216&&e[2]===255?`image/jpeg`:null}function ps(e){if(e instanceof Uint8Array){let t=new Uint8Array(e.byteLength);return t.set(e),t}if(e instanceof ArrayBuffer)return new Uint8Array(e.slice(0));if(ArrayBuffer.isView(e)){let t=e;return new Uint8Array(t.buffer.slice(t.byteOffset,t.byteOffset+t.byteLength))}return Array.isArray(e)?Uint8Array.from(e):e&&typeof e==`object`?hs(e):new Uint8Array}function ms(e){if(typeof e.byteLength==`number`)return e.byteLength;if(typeof e.length==`number`)return e.length;let t=-1;for(let n of Object.keys(e)){if(!/^\d+$/.test(n))continue;let e=Number(n);e>t&&(t=e)}return t+1}function hs(e){let t=ms(e),n=new Uint8Array(t);for(let r=0;r<t;r++){let t=e[r];typeof t==`number`&&(n[r]=t&255)}return n}var gs=2,_s=768,vs=class{computers=[];frames=new Map;listListeners=new Set;frameListeners=new Set;invocationListeners=new Set;sender=null;watchSubs=new Map;kernelWatch=new Map;nextWatchToken=1;invocations=new Map;list(){return this.computers.slice()}get(e){return this.computers.find(t=>t.id===e)??null}lastFrame(e){return this.frames.get(e)??null}onList(e){return this.listListeners.add(e),()=>this.listListeners.delete(e)}onFrame(e){return this.frameListeners.add(e),()=>this.frameListeners.delete(e)}onInvocations(e){return this.invocationListeners.add(e),()=>this.invocationListeners.delete(e)}setSender(e){this.sender=e}isWatching(e){return(this.watchSubs.get(e)?.length??0)>0}watchRefCount(e){return this.watchSubs.get(e)?.length??0}watch(e,t=gs,n=_s){if(!this.sender)throw Error(`computers store has no kernel sender`);let r=this.nextWatchToken++,i=this.watchSubs.get(e)??[];return i.push({token:r,fps:t,maxWidth:n}),this.watchSubs.set(e,i),this.syncKernelWatch(e),r}unwatch(e,t){if(!this.sender)throw Error(`computers store has no kernel sender`);let n=this.watchSubs.get(e);if(!n?.length)return;let r=t===void 0?n.length-1:n.findIndex(e=>e.token===t);if(!(r<0)){if(n.splice(r,1),n.length===0){this.watchSubs.delete(e),this.kernelWatch.delete(e),this.sender({type:`computer-unwatch`,id:e});return}this.syncKernelWatch(e)}}syncKernelWatch(e){let t=this.watchSubs.get(e);if(!t?.length||!this.sender)return;let n=Math.max(...t.map(e=>e.fps)),r=Math.max(...t.map(e=>e.maxWidth)),i=this.kernelWatch.get(e);i&&i.fps===n&&i.maxWidth===r||(this.kernelWatch.set(e,{fps:n,maxWidth:r}),this.sender({type:`computer-watch`,id:e,fps:n,maxWidth:r}))}input(e,t){if(!this.sender)throw Error(`computers store has no kernel sender`);this.sender({type:`computer-input`,id:e,events:t})}recordInvocation(e,t){this.invocations.set(e,t);for(let e of[...this.invocationListeners])e()}newestInvocation(e){return this.invocations.get(e)??null}applyList(e){this.computers=e.computers.slice();let t=new Set(this.computers.map(e=>e.id));for(let e of[...this.invocations.keys()])t.has(e)||this.invocations.delete(e);for(let e of[...this.frames.keys()])t.has(e)||this.frames.delete(e);for(let e of[...this.listListeners])e(this.computers)}applyFrame(e){let t=this.frames.get(e.id);if(t&&t.seq>e.seq)return;let n={seq:e.seq,mime:e.mime,width:e.width,height:e.height,bytes:ps(e.bytes),...e.overCap?{overCap:!0}:{}};this.frames.set(e.id,n);for(let t of[...this.frameListeners])t(e.id,n)}},ys=null;function bs(){return ys||=new vs,ys}var xs=`__slicc_binary__`,Ss=`b64`;function Cs(e){if(!e||typeof e!=`object`)return!1;let t=e;return t[xs]===Ss&&typeof t.data==`string`}function ws(e){return typeof e==`object`&&!!e&&!Array.isArray(e)&&!(e instanceof Uint8Array)}function Ts(e){return typeof e==`object`&&!!e&&!Array.isArray(e)&&!(e instanceof Uint8Array)&&!Cs(e)}function Es(e){if(e instanceof Uint8Array)return{[xs]:Ss,data:Ee(e)};if(Array.isArray(e))return e.map(Es);if(ws(e)){let t={};for(let[n,r]of Object.entries(e))t[n]=Es(r);return t}return e}function Ds(e){if(Cs(e))return De(e.data);if(Array.isArray(e))return e.map(Ds);if(Ts(e)){let t={};for(let[n,r]of Object.entries(e))t[n]=Ds(r);return t}return e}var Os=o(`panel-transport`);function ks(e){return typeof e==`object`&&!!e&&`source`in e&&`payload`in e}function As(){return{onMessage:e=>{let t=(t,n,r)=>(ks(t)&&e(Ds(t)),!1);return chrome.runtime.onMessage.addListener(t),()=>chrome.runtime.onMessage.removeListener(t)},send:(e,t)=>{let n=Es(e);chrome.runtime.sendMessage({source:`panel`,payload:n}).catch(e=>{Os.error(`failed to send to offscreen`,{error:e instanceof Error?e.message:String(e)})})}}}var js={summarizing:`summarizing`,fallback:`fallback`,cancelled:`discarded`,idle:`summarized`},Ms=class{mintId;open=new Map;settled=new Map;constructor(e){this.mintId=e}apply(e,t,n,r){if(t===`extracting-memory`)return null;let i=this.open.get(e)??this.lateRetraction(e,t,n)??r;if(t!==`summarizing`&&!i)return null;t!==`summarizing`&&(this.open.delete(e),this.settled.delete(e));let a=i??this.mintId(e);if(t===`summarizing`&&this.open.set(e,a),(t===`idle`||t===`fallback`)&&n.roundId&&this.settled.set(e,{messageId:a,roundId:n.roundId}),t===`cancelled`)return{kind:`retract`,messageId:a};let o={trigger:n.trigger,state:js[t],...n.transcriptPath?{transcriptPath:n.transcriptPath}:{}};return t===`summarizing`?{kind:`open`,messageId:a,marker:o}:{kind:`settle`,messageId:a,marker:o}}forget(e){this.open.delete(e),this.settled.delete(e)}lateRetraction(e,t,n){if(t!==`cancelled`||!n.roundId)return;let r=this.settled.get(e);return r?.roundId===n.roundId?r.messageId:void 0}},Ns=2e3,Ps=5e3,G=o(`offscreen-client`),Fs=class{eventListeners=new Set;backgroundEventListeners=new Set;backgroundMessageId=new Map;callbacks;scoops=[];scoopStatuses=new Map;currentMessageId=new Map;compactionRows=new Ms(e=>`compaction-${e}-${K()}`);toolDepth=new Map;ready=!1;stateRetryTimer=null;localFs=null;pendingClearAcks=new Map;pendingWebhookDeliveries=new Map;pendingAgentSpawnRequests=new Map;pendingThinkingAcks=new Map;streamThinkingByUnit=new Map;pendingModelAcks=new Map;pendingUserMessageAcks=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.handOverOpenMessages(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??As(),this.setupMessageListener(),bs().setSender(e=>this.send(e))}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})}}}sendUserMessage(e){if(this.locked)return Promise.reject(Error(`This window is detached. Close it and use the detached tab.`));let t=`um-${K()}`,n=new Promise((e,n)=>{this.pendingUserMessageAcks.set(t,{resolve:e,reject:n})});this.send({type:`user-message`,requestId:t,scoopJid:e.scoopJid,text:e.text,messageId:e.messageId,...e.attachments?{attachments:[...e.attachments]}:{},...e.steer?{steer:!0}:{},...e.guestGate?{guestGate:e.guestGate}:{}});let r,i=new Promise((e,t)=>{r=setTimeout(()=>t(Error(`the kernel did not answer in time`)),Ps)});return Promise.race([n,i]).finally(()=>{r!==void 0&&clearTimeout(r),this.pendingUserMessageAcks.delete(t)})}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(!O(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&&O(t)&&D(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`,reason:`unavailable`}),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),Ns))])}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){if(!this.applySurfacePush(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`user-message-ack`:this.handleUserMessageAck(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;Is(t.leader,t.follower);break}case`forward-lick`:this.forwardLickHandler?.(e.event)}}applySurfacePush(e){if(e.type===`computers`)return bs().applyList(e),!0;if(e.type===`computer-frame`)return bs().applyFrame(e),!0;switch(e.type){case`terminal-status`:case`terminal-output`:case`terminal-media-preview`:case`terminal-exit`:case`terminal-cleared`:case`terminal-mode`: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)})}return!0;default:return!1}}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){this.translateTranscriptEvent(e,this.backgroundMessageId,t=>this.emitBackground(e.scoopJid,t));return}switch(e.eventType){case`tool_ui`:case`tool_ui_done`:case`tool_progress`:this.handleToolUiAgentEvent(e);break;default:this.translateTranscriptEvent(e,this.currentMessageId,e=>this.emitToUI(e))}}translateTranscriptEvent(e,t,n){let r=()=>{let r=t.get(e.scoopJid);return r||(r=`scoop-${e.scoopJid}-${K()}`,t.set(e.scoopJid,r),n({type:`message_start`,messageId:r})),r};switch(e.eventType){case`text_delta`:n({type:`content_delta`,messageId:r(),text:e.text??``});break;case`tool_start`:n({type:`tool_use_start`,messageId:r(),toolName:e.toolName??``,toolInput:e.toolInput,toolCallId:e.toolCallId});break;case`tool_end`:{let r=t.get(e.scoopJid);r&&n({type:`tool_result`,messageId:r,toolName:e.toolName??``,result:e.toolResult??``,isError:e.isError,toolCallId:e.toolCallId});break}case`response_done`:{let r=t.get(e.scoopJid);r&&(n({type:`content_done`,messageId:r,model:e.model,usage:e.usage}),t.delete(e.scoopJid));break}case`turn_end`:{let r=t.get(e.scoopJid)??`done-${e.scoopJid}-${K()}`;t.delete(e.scoopJid),n({type:`turn_end`,messageId:r});break}}}handOverOpenMessages(e,t){let n=(e,t)=>{t&&this.emitBackground(e,{type:`content_done`,messageId:t})};e&&n(e,this.currentMessageId.get(e)),t&&(n(t,this.backgroundMessageId.get(t)),this.backgroundMessageId.delete(t))}onBackgroundUnitEvent(e){return this.backgroundEventListeners.add(e),()=>this.backgroundEventListeners.delete(e)}emitBackground(e,t){for(let n of this.backgroundEventListeners)try{n(e,t)}catch(e){G.error(`Background listener error`,{error:e instanceof Error?e.message:String(e)})}}renderCompactionNotice(e,t,n,r){let i=this.compactionRows.apply(e,t,n,r);i&&e===this.selectedScoopJid&&this.emitToUI({type:`compaction_notice`,messageId:i.messageId,marker:i.kind===`retract`?{trigger:n.trigger,state:`discarded`}:i.marker})}handleCompactionState(e){let t={trigger:e.trigger??`threshold`,...e.transcriptPath?{transcriptPath:e.transcriptPath}:{},...e.failure?{failure:e.failure}:{},...e.roundId?{roundId:e.roundId}:{}};this.callbacks.onCompactionStateChange?.(e.scoopJid,e.state,t),this.renderCompactionNotice(e.scoopJid,e.state,t,e.rowId)}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=bn(e),n=xn(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)}getStreamThinking(e){return this.streamThinkingByUnit.get(e)}handleThinkingLevelAck(e){if(e.applied){let t=this.getScoop(e.scoopJid);t&&vn(t,e.level===void 0?void 0:{level:e.level,effortOverride:e.effortOverride}),e.resolvedLevel&&this.streamThinkingByUnit.set(e.scoopJid,{level:e.resolvedLevel===`max`?`xhigh`:e.resolvedLevel,...e.resolvedEffortOverride?{effortOverride:e.resolvedEffortOverride}:{}})}this.pendingThinkingAcks.get(e.requestId)?.(e.applied)}handleUserMessageAck(e){let t=this.pendingUserMessageAcks.get(e.requestId);t&&(e.ok?t.resolve():t.reject(Error(e.error?.trim()||`the kernel refused the message`)))}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&&Is(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){let t={type:`error`,error:e.error,...e.endTurn===!1?{endTurn:!1}:{}};e.scoopJid===this.selectedScoopJid?this.emitToUI(t):e.scoopJid&&this.emitBackground(e.scoopJid,t)}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 _n({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 Is(e,t){hn({state:e.state,error:e.error,reconnectAttempts:e.reconnectAttempts,session:e.session?{...e.session}:null}),Et({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 Ls(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 Rs={onAgentEvent:()=>()=>void 0,sendSprinkleLick:()=>void 0,sendToolUiAction:()=>void 0,deleteQueuedMessage:()=>Promise.resolve(),emitAgentError:()=>void 0},zs=`A follower cannot cancel the leader’s queued message`;function Bs(e){return{onAgentEvent:e.onAgentEvent,sendSprinkleLick:(t,n,r)=>e.getSync()?.sendSprinkleLick(t,n,r),sendToolUiAction:()=>void 0,deleteQueuedMessage:()=>Promise.reject(Error(zs)),emitAgentError:e.onAgentError,readOnlyToolUi:!0}}function Vs(e){return!e.includes(`\0`)}function Hs(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(!Vs(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(!Vs(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),!Vs(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),!Vs(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(Vs(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 Us(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 Ws(e){let t=Us(e);return{onMessage:e=>t.onMessage(e),send:(e,n)=>{t.send({source:`panel`,payload:e},n)}}}async function Gs(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 Ks(e,t){for(let[n,r]of t)e.off(n,r),e.on(n,r)}var qs=1e4;function Js(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`)),qs),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 Ys(e,t,n={}){let r=Us(e),i=null,a=n.reconnect?()=>(i||=(t.state===`connecting`?Js(t):n.reconnect()).finally(()=>{i=null}),i):null,o=new Map,s=r.onMessage(e=>{Gs(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`&&(Ks(t,o),r.send({type:`cdp-ready`}))}});return()=>{s(),u?.();for(let[e,n]of o)t.off(e,n);o.clear()}}function Xs(){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 Zs(e){let t=null,n=!1,r=!1,i=!1,a=0,o=Date.now(),s,c=()=>{t!==null&&(clearTimeout(t),t=null)},l=()=>{c(),!(n||r||i)&&(t=setTimeout(()=>{if(n||r||i)return;if(a+=1,a<e.readyStallLimit){e.onReadyStall?.({elapsedMs:Date.now()-o,stalls:a,stage:s}),l();return}i=!0,c();let t=e.readyTimeoutMs*e.readyStallLimit,u=s?` (last progress: ${s})`:``;e.onExhausted(`Kernel worker did not signal ready within ${t}ms${u}`)},e.readyTimeoutMs))};return{pause(){r||i||(n=!0,c())},restart(){r||i||(n=!1,a=0,o=Date.now(),l())},arm:l,clear(){r=!0,c()},noteProgress(t){r||i||(t&&(s=t,e.onBootProgress?.(t)),!n&&(a=0,l()))},timedOut:()=>i}}function Qs(e,t,n){let r=()=>{},i=()=>{},a=()=>{};return{ready:new Promise((o,s)=>{let c=null,l=Zs({readyTimeoutMs:n,readyStallLimit:Math.max(1,t.readyStallLimit??(t.onReadyStall?3:1)),onReadyStall:t.onReadyStall,onBootProgress:t.onBootProgress,onExhausted:e=>{t.onLateReady||r(),s(Error(e))}});i=()=>l.pause(),a=()=>l.restart(),r=()=>{c!==null&&(e.removeEventListener(`message`,c),c=null),l.clear()},c=e=>{let n=e.data;if(n?.type===`kernel-worker-boot-progress`){l.noteProgress(n.stage);return}if(n?.type===`kernel-worker-ready`){if(r(),l.timedOut()){t.onLateReady?.();return}o();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),s(i)}},e.addEventListener(`message`,c),l.arm()}),cleanup:()=>r(),pauseReadyDeadline:()=>i(),restartReadyDeadline:()=>a()}}function $s(e){let{worker:t,realCdpTransport:n}=e,r=e.readyTimeoutMs??3e4,i=e.localStorageSeed??{},a=new MessageChannel,o=new MessageChannel,s=Ws(a.port1),c=e.makeClient(s);e.onWorkerScriptError&&e.worker.addEventListener?.(`error`,()=>e.onWorkerScriptError());let l=Ys(o.port1,n,{...e.reconnectCdp?{reconnect:e.reconnectCdp}:{}}),{ready:u,cleanup:d,pauseReadyDeadline:f,restartReadyDeadline:p}=Qs(a.port1,e,r),m={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.238.8-muwgbewp`,pageLoadedAt:globalThis.performance?.timeOrigin??Date.now(),flagFloat:e.flagFloat??null,appPageUrl:globalThis.location?.href??null};t.postMessage(m,[a.port2,o.port2]);let h=!1;return{client:c,ready:u,pauseReadyDeadline:f,restartReadyDeadline:p,dispose(){if(!h){h=!0,d(),l();try{t.postMessage({type:`kernel-worker-shutdown`})}catch{}t.terminate(),a.port1.close(),o.port1.close()}}}}function ec(e){return $s({worker:e.workerUrl?new Worker(e.workerUrl,{type:`module`}):new Worker(new URL(`/assets/kernel-worker-e1vUlLgV.js`,``+import.meta.url),{type:`module`}),realCdpTransport:e.realCdpTransport,reconnectCdp:e.reconnectCdp,makeClient:e.makeClient,readyTimeoutMs:e.readyTimeoutMs,localStorageSeed:e.localStorageSeed??Xs(),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,onBootProgress:e.onBootProgress})}var tc=1048576,nc=`r`;function rc(e){return e.replace(/~/g,`~0`).replace(/\//g,`~1`)}function ic(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function ac(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++)ac(e[r],`${t}/${r}`,n);return}if(ic(e))for(let[r,i]of Object.entries(e))ac(i,`${t}/${rc(r)}`,n)}function oc(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=oc(e[a],`${t}/${a}`,n);o!==e[a]&&(r=!0),i.push(o)}return r?i:e}if(ic(e)){let r=!1,i={};for(let[a,o]of Object.entries(e)){let e=oc(o,`${t}/${rc(a)}`,n);e!==o&&(r=!0),i[a]=e}return r?i:e}return e}function sc(e,t,n){if(ic(e))return oc(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=sc(e[a],`${t}/${a}`,n);o!==e[a]&&(r=!0),i.push(o)}return r?i:e}return e}function cc(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 lc(e,t,n){let r=[],i=0;for(;i<e.length;){if(n?.aborted)throw new S(`redaction-unavailable`);let a=0,o=i;for(;o<e.length;){let t=e[o].length;if(o>i&&a+t>tc)break;a+=t,o++}let s=e.slice(i,o),c;try{c=await t.redact(s,n)}catch{throw new S(`redaction-unavailable`)}if(c.length!==s.length)throw new S(`redaction-unavailable`);r.push(...c),i=o}return r}function uc(e,t,n,r){let i=[],a=cc(e);for(let{category:e,id:t}of a.values())i.push({id:t,category:e,detector:`pre-obfuscated`,target:n});let o=cc(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}=Je(t,nc,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 dc(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 fc(e,t,n,r){if(r?.aborted)throw new S(`redaction-unavailable`);let{privacy:i,...a}=e,o=[];ac(a,``,o);let s=o.filter(e=>!Ke(e.pointer)),c=[...t.entries()],l=await lc([...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=uc(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)}dc(m,u,d);let h=new Map,g=s.length,_=[];for(let e=0;e<c.length;e++){let[t,n]=c[e],r=uc(n,l[g+e],{kind:`attachment`,attachmentId:t},f);f=r.nextId,h.set(t,r.finalText),_.push(r)}dc(_,u,d);let v=sc(e,``,p);return{document:{...v,privacy:{...v.privacy,redactionCounts:d,redactions:u}},textAttachments:h}}function pc(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`}var mc={"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 hc(e,t){return mc[e]??(t===`text-redacted`?`.txt`:`.bin`)}function gc(e,t,n){return`attachments/att-${String(e+1).padStart(4,`0`)}${hc(t,n)}`}function _c(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 vc(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 yc(e,t,n,r,i){let a=pc(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(_c(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=_c(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 bc(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:_c(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(yc(c.a,s.attachmentId,s.conversationId,s.messageId,r))}return{pendingPromises:i,mismatchedConvIds:a,processedUiPositions:o}}function xc(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 Sc(e,t,n,r,i,a,o){let s=xc(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(yc(i,l,n,e.id,o)),c.push({type:`attachment-ref`,attachmentId:l}))}return c}function Cc(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=Sc(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 wc(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,gc(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 Tc(e,t,n,r,i){let{rawAttachments:a,textMap:o}=wc(e,n),s,c;try{let e=await fc({...t,attachments:a},o,r,i);s=e.document,c=e.textAttachments}catch(e){throw e instanceof S?e:new S(`attachment-unreadable`)}let l=new Map;for(let t of e){if(l.has(t.attachmentId))throw new S(`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 S(`schema-invalid`);let n=t.handling===`text-redacted`?new TextEncoder().encode(c.get(t.attachmentId)??t.rawText??``):t.rawBytes,r=await He(n);return u.set(e.path,n),{...e,byteLength:n.length,sha256:r}}));return{redactedDocument:{...s,attachments:d},bundleFiles:u}}async function Ec(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}=bc(vc(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}=Cc(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 Tc(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 Dc=50;function Oc(e){return Cn(e)}function kc(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 Ac(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:O(t)?`cone`:`scoop`,name:t.name,...t.folder&&!O(t)?{folder:t.folder}:{},...t.parentJid?{parentConversationId:t.parentJid}:{},...t.originToolCallId?{originToolCallId:t.originToolCallId}:{},messages:e};o.push(n);let c=Oc(t),l=a.get(c);l&&s.set(t.jid,l.messages)}return{sources:o,chatMessagesByConversation:s}}async function jc(e,t,n={}){let r=e=>n.rootJid===void 0?e:Sn(e,n.rootJid);for(;;){let n=r(e.listScoops());for(;n.some(t=>e.isProcessing(t.jid));)if(t?.aborted||(await e.wait(Dc,t),t?.aborted))throw new S(`transfer-aborted`);let i=kc(n,e),[a,o]=await Promise.all([e.loadPersistedSessions(),e.loadUiChatSessions()]);if(t?.aborted)throw new S(`transfer-aborted`);let s=r(e.listScoops());if(i===kc(s,e))return Ac(s,a,o,e)}}function Mc(e,t){return`${e}-msg-${t.toString().padStart(6,`0`)}`}function Nc(e,t){return{type:`attachment-ref`,attachmentId:`${e}-img-${t}`}}function Pc(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(Nc(t,r++));return n}function Fc(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=Nc(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 Ic(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=Nc(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 Lc(e,t,n){let r=Mc(t,n),i=Pc(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 Rc(e,t,n){let r=Mc(t,n),{blocks:i,excluded:a,images:o}=Fc(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 zc(e,t,n){let r=Mc(t,n),{blocks:i,images:a}=Ic(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 Bc(e,t,n){return e.role===`user`?Lc(e,t,n):e.role===`assistant`?Rc(e,t,n):e.role===`toolResult`?zc(e,t,n):{message:null,excludedReasoningBlocks:0,images:new Map}}function Vc(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 Hc(e){let t=0,n=new Map;return{conversations:e.map(e=>{let r=e.messages.flatMap((r,i)=>{let a=Bc(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:Vc(e),excludedReasoningBlocks:t,canonicalImages:n}}var Uc=(()=>{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 Wc(e){let t=-1>>>0;for(let n=0;n<e.length;n++)t=t>>>8^Uc[(t^e[n])&255];return~t>>>0}var Gc=new TextEncoder;function q(e,t,n){e[t]=n&255,e[t+1]=n>>>8&255}function J(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 Kc(e,t,n){let r=new Uint8Array(30+e.length);return r[0]=80,r[1]=75,r[2]=3,r[3]=4,q(r,4,20),q(r,6,2048),q(r,8,0),q(r,10,0),q(r,12,0),J(r,14,n),J(r,18,t),J(r,22,t),q(r,26,e.length),q(r,28,0),r.set(e,30),r}function qc(e,t,n,r){let i=new Uint8Array(46+e.length);return i[0]=80,i[1]=75,i[2]=1,i[3]=2,q(i,4,20),q(i,6,20),q(i,8,2048),q(i,10,0),q(i,12,0),q(i,14,0),J(i,16,n),J(i,20,t),J(i,24,t),q(i,28,e.length),q(i,30,0),q(i,32,0),q(i,34,0),q(i,36,0),J(i,38,0),J(i,42,r),i.set(e,46),i}function Jc(e,t,n){let r=new Uint8Array(22);return r[0]=80,r[1]=75,r[2]=5,r[3]=6,q(r,4,0),q(r,6,0),q(r,8,e),q(r,10,e),J(r,12,t),J(r,16,n),q(r,20,0),r}function Yc(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 Xc(e){let t=e.export.generatedAt.slice(0,10),n=e.export.id.slice(0,8);return`slicc-${t}-${We(e.session.title,{maxLen:40,fallback:`transcript`})}-${n}.zip`}async function*Zc(e,t,n,r,i){if(n?.aborted)throw i(new S(`transfer-aborted`)),new S(`transfer-aborted`);let a=()=>i(new S(`transfer-aborted`));n?.addEventListener(`abort`,a,{once:!0});let o=It.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=Gc.encode(`transcript.json`),f=Wc(i),p=Kc(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 S(`transfer-aborted`);yield*d(i);for(let[e,r]of t){if(n?.aborted)throw new S(`transfer-aborted`);let t=Gc.encode(e),i=Wc(r),a=Kc(t,r.length,i);if(l.push({nameBytes:t,size:r.length,crc:i,localOffset:c}),yield*d(a),n?.aborted)throw new S(`transfer-aborted`);yield*d(r)}let m=c;for(let e of l){if(n?.aborted)throw new S(`transfer-aborted`);yield*d(qc(e.nameBytes,e.size,e.crc,e.localOffset))}if(n?.aborted)throw new S(`transfer-aborted`);yield*d(Jc(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 S(`transfer-aborted`)))}}var Qc=4294967295,$c=65535;function el(e,t,n){for(let e of t.keys())if(!Yc(e))throw new S(`schema-invalid`);if(t.size+1>$c)throw new S(`schema-invalid`);for(let e of t.values())if(e.byteLength>Qc)throw new S(`schema-invalid`);let r,i,a=new Promise((e,t)=>{r=e,i=t});return{filename:Xc(e),chunks:Zc(e,t,n,r,i),completion:a}}function tl(e,t,n,r,i,a={}){return{schemaVersion:1,export:{id:crypto.randomUUID(),generatedAt:new Date().toISOString(),producer:{application:`slicc`,version:i},format:qe},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 nl(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 rl(e){let t=Ge(e);if(!t.ok)throw new S(`schema-invalid`,t.error)}function il(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 al(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);return n?{...e,byteLength:n.length,sha256:await He(n)}:e}))}function ol(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 sl=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),rl(i.document),r?.({phase:`packaging`}),el(i.document,i.bundleFiles,n)}async captureFrozen(e,t){let n=await jc(this.deps.collection,t,{...e.rootJid?{rootJid:e.rootJid}:{}});if(e.rootJid&&n.sources.length===0)return;let r=Hc(n.sources),{document:i,bundleFiles:a}=await Ec({document:tl(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});if(rl(i),t?.aborted)throw new S(`transfer-aborted`);await this.deps.snapshotStore.write(e.sessionId,{document:i,attachments:a},t)}async buildActiveSnapshot(e,t){t?.({phase:`waiting-for-conversations`}),t?.({phase:`collecting`});let n=await jc(this.deps.collection,e),r=Hc(n.sources),{id:i,title:a}=this.deps.getActiveSessionInfo(),o=tl(i,a,`active`,r,this.deps.version);return t?.({phase:`redacting`}),Ec({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;try{r=await this.deps.snapshotStore.read(e)}catch(e){if(!(e instanceof S)||e.code!==`session-not-found`)throw e;r=null}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 fc(e.document,n,this.deps.knownSecrets,t);r=a.document,i=a.textAttachments}catch{throw new S(`redaction-unavailable`)}let a=il(r.attachments,i,e.attachments),o=await al(r.attachments,a);return{document:{...r,attachments:o},bundleFiles:a}}async buildLegacyPartial(e,t,n){let r=(await C(this.deps.vfs)).find(t=>t.sessionId===e||!t.sessionId&&t.filename===e);if(!r)throw new S(`session-not-found`);let a;try{let e=await this.deps.vfs.readFile(`/sessions/${r.filename}`,{encoding:`utf-8`});a=typeof e==`string`?e:new TextDecoder().decode(e)}catch{throw new S(`session-not-found`)}let{loadFrozenArchive:o}=await i(async()=>{let{loadFrozenArchive:e}=await import(`./session-jsonl-sSMKZwgt.js`).then(e=>e.i);return{loadFrozenArchive:e}},__vite__mapDeps([49,1,0,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,50])),{title:s,messages:c}=await o(this.deps.vfs,a,r.filename),l=`legacy-cone`,u=nl(c,l),d=ol(a),f={schemaVersion:1,export:{id:crypto.randomUUID(),generatedAt:new Date().toISOString(),producer:{application:`slicc`,version:this.deps.version},format:qe},session:{id:e,title:s,state:`frozen`,...r.frozenAt?{frozenAt:r.frozenAt}:{},...d,completeness:{status:`partial`,missing:[`complete-snapshot-unavailable`,`canonical-agent-history-unavailable`]}},privacy:{reasoningExcluded:!0,excludedReasoningBlocks:0,binaryAttachments:`included-unchanged`,redactionCounts:{},redactions:[]},conversations:[{id:l,kind:`cone`,name:s,messages:u}],delegations:[],attachments:[]},p=new Map([[l,c]]);return n?.({phase:`redacting`}),Ec({document:f,chatMessagesByConversation:p,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 S(`attachment-unreadable`);return t}},cl=`/sessions/data`,ll=`document.json`,ul=`.publishing`;function Y(e){if(e?.aborted)throw new S(`transfer-aborted`)}function dl(e){if(e.length===0||/[/\\\x00]/.test(e)||e===`..`||e===`.`||e.includes(`..`)||!/^[a-zA-Z0-9._-]+$/.test(e))throw new S(`session-not-found`)}function fl(e){return`${cl}/${e}`}function pl(e){return`${cl}/.tmp-${e}`}async function ml(e,t){try{await e.mkdir(t,{recursive:!0})}catch{}}async function hl(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 hl(e,n);try{await e.rm(n)}catch{}}try{await e.rm(t)}catch{}}async function gl(e,t){let n=await e.readDir(t);for(let r of n){if(r.name===ul)continue;let n=`${t}/${r.name}`;r.type===`directory`?await hl(e,n):await e.rm(n)}}async function _l(e,t,n,r){Y(r),await ml(e,n);let i=await e.readDir(t);for(let a of i){Y(r);let i=`${t}/${a.name}`,o=`${n}/${a.name}`;if(a.type===`directory`)await _l(e,i,o,r);else{let t=await e.readFile(i,{encoding:`binary`});await e.writeFile(o,t)}}}async function vl(e,t,n,r){dl(t);let i=pl(t),a=fl(t),o=new Map(n.document.attachments.filter(e=>e.present&&e.path).map(e=>[e.path,e]));for(let[e]of n.attachments)if(!o.has(e))throw new S(`schema-invalid`);Y(r),await ml(e,i);let s=!1;try{let t=[...n.document.attachments];for(let[e,i]of n.attachments){Y(r);let n=await He(i),a=o.get(e);if(a!==void 0){let e=t.indexOf(a);e!==-1&&(t[e]={...a,sha256:n,byteLength:i.length})}}let c={...n.document,attachments:t},l=JSON.stringify(c,null,2);if(await e.writeFile(`${i}/${ll}`,l),n.attachments.size>0)for(let[t,r]of n.attachments){let n=`${i}/${t}`,a=t.lastIndexOf(`/`);a!==-1&&await ml(e,`${i}/${t.slice(0,a)}`),await e.writeFile(n,r)}await e.flush(),Y(r),await ml(e,a),s=!0,await e.writeFile(`${a}/${ul}`,`in-progress`),await gl(e,a),Y(r),await _l(e,i,a,r),await e.flush(),Y(r),await e.rm(`${a}/${ul}`)}catch(t){if(s)try{await gl(e,a)}catch{}throw await hl(e,i),t}await hl(e,i)}async function yl(e,t){dl(t);let n=fl(t),r=`${n}/${ll}`;try{throw await e.stat(`${n}/${ul}`),new S(`session-not-found`)}catch(e){if(e instanceof S||e.code!==`ENOENT`)throw e}let i;try{let t=await e.readFile(r,{encoding:`utf-8`});i=typeof t==`string`?t:new TextDecoder().decode(t)}catch{throw new S(`session-not-found`)}let a;try{a=JSON.parse(i)}catch{throw new S(`schema-invalid`)}if(!Ge(a).ok)throw new S(`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 S(`transfer-corrupt`)}if(await He(i)!==t.sha256)throw new S(`transfer-corrupt`);o.set(t.path,i)}return{document:a,attachments:o}}function bl(e){return`error`in e}function X(){throw new S(`redaction-unavailable`)}function xl(e,t){return(typeof e!=`object`||!e||!Array.isArray(e.texts)||e.texts.length!==t)&&X(),e.texts}function Sl(){return{async redact(e){let t;try{t=await fetch(mt(`/api/secrets/redact-export`),{method:`POST`,headers:ht({"content-type":`application/json`}),body:JSON.stringify({texts:e})})}catch{X()}t.ok||X();let n;try{n=await t.json()}catch{X()}return xl(n,e.length)}}}function Cl(){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&&bl(t)&&X(),xl(t,e.length)}}}function wl(){return{async redact(e){let t;try{t=await _t(`secrets.redact-export`,{texts:e})}catch{X()}return t??X(),typeof t==`object`&&t&&bl(t)&&X(),xl(t,e.length)}}}function Tl(){return{async redact(e){X()}}}function El(){let e=gt();return e===`connect`?Tl():e===`extension-direct`?Cl():e===`extension-delegate`?wl():Sl()}var Dl=`Restoring session…`,Ol=`slicc-restoring-session`;function kl(e){let t=e.querySelector(`:scope > .slicc-thread__inner`)??e;for(let e of t.children)if(!e.classList.contains(Ol))return!1;return!0}function Al(e,t){let n=e.querySelector(`:scope > .slicc-thread__inner`)??e,r=n.querySelector(`:scope > .${Ol}`);if(!t){r?.remove();return}if(r)return;let i=e.ownerDocument.createElement(`p`);i.className=Ol,i.textContent=Dl,n.append(i)}function Z(e){switch(e){case`processing`:return`working`;case`error`:return`broken`;case`initializing`:return`initializing`;default:return`idle`}}function jl(e,t={}){let n=Z(t.status),r=bn(e);return{id:e.jid,parentId:e.parentJid,role:O(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 Ml(e,t=Date.now){let n=e.parentId===null,r=e.folder??e.name,i=n?e.config:Nl(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 Nl(e,t){let n=yn(e.workspace?.mode??e.config?.workspaceMode),r=e.workspace?.from??`/workspace`,i=jn(n,t,{root:r},e.workspace?.from),a=e.config;return{...a,workspaceMode:n,visiblePaths:a?.visiblePaths===void 0?i.visiblePaths:a.visiblePaths,writablePaths:a?.writablePaths===void 0?i.writablePaths:a.writablePaths}}var Pl=`padding:0.5rem 1.25rem;border-radius:0.375rem;cursor:pointer;font:inherit;font-size:0.875rem;`,Fl=`${Pl}border:none;background:var(--s2-accent-color,#0265dc);color:#fff;`,Il=`${Pl}border:none;background:#d23;color:#fff;`,Ll=`${Pl}background:transparent;border:1px solid var(--s2-border-color,#e0e0e0);color:inherit;`;function Rl(e,t,n){return{...Ml({parentId:null,name:e,folder:`cone-pending-${t.length+1}`}),assistantLabel:e,...n?{model:n}:{}}}function zl(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 Bl(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 Vl(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=()=>Kn(e.getUnits(),e.getSelected()),u=t=>e.getUnits().find(e=>e.id===t.jid)??jl(t),d=()=>{if(!s)return;let e=s;s=null,e.hide?.(),e.remove()},f=e=>{d();let t=zl(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=Rl(t.name,n.getScoops(),Vn(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=Bl(i,p);f({heading:`New cone`,body:e,actions:[{text:`Create`,style:Fl,data:`create`,onClick:()=>p(e.readDraft())},{text:`Cancel`,style:Ll,data:`cancel`,onClick:d}]}),queueMicrotask(()=>e.querySelector(`input`)?.focus())},h=t=>{d();let i=D(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=D(n.getScoops()).find(e=>e.jid!==a.jid);t&&e.selectScoop(u(t))}o=!1,_()})()},g=e=>{let t=Wn(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:Il,data:`drop`,onClick:()=>h(e.id)},{text:`Cancel`,style:Ll,data:`cancel`,onClick:d}]})},_=()=>{let t=D(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||D(n.getScoops()).length<=1||o||g(e)}),_(),{refresh:_,dialog:()=>s}}var Hl={"gelatiere-dismiss":{consume:!0,mode:`dismiss`},"gelatiere-install":{consume:!1,mode:`take`},"gelatiere-try":{consume:!1,mode:`take`}};function Ul(e){return t=>{if(t.type!==`sprinkle`||t.sprinkleName!==`welcome`&&t.sprinkleName!==`inline`&&t.sprinkleName!==`suggestions`)return!1;let n=t.body,r=Hl[typeof n?.action==`string`?n.action:``];if(!r)return!1;let a=n?.data,o=typeof a?.id==`string`&&a.id?a.id:null;return o&&e.openVfs().then(async e=>{let t=await i(()=>import(`./wc-shell-CpR39VTz.js`).then(e=>e.mt),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38]));return r.mode===`dismiss`?t.dismissGelatiereSuggestion(e,o):t.takeGelatiereSuggestion(e,o)}).catch(t=>e.log.warn(`gelatiere card settlement failed`,t)),r.consume}}var Wl=5e3,Gl=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 jl(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)},Wl)}}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)}}takeArrivedReplay(e){let t=this.orphanedReplays.get(e);if(!t)return null;let n=this.snapshotFor(e,t.messages,t.queuedIds);return n?(this.orphanedReplays.delete(e),this.lastSnapshots.set(e,n),n):null}snapshot(e){let t=this.deps.getClient();if(!t)return Promise.reject(Error(`kernel client not attached`));let n=this.takeArrivedReplay(e);if(n)return t.setSelectedScoopJid(e),Promise.resolve(n);let r=this.pendingSnapshots.get(e)??new Set;this.pendingSnapshots.set(e,r);let i=()=>{},a=new Promise(e=>{i=e,r.add(e)});t.setSelectedScoopJid(e),t.requestScoopMessages(e);let o,s=new Promise(t=>{o=setTimeout(()=>{o=void 0;let n=this.pendingSnapshots.get(e)?.has(i)===!0;this.forgetWaiter(e,i),n&&this.recoverUnanswered(e),t(this.snapshotFor(e,[],void 0))},Wl)});return Promise.race([a.then(e=>(o!==void 0&&(clearTimeout(o),o=void 0),e)),s]).then(t=>{if(!t)throw Error(`unknown work unit: ${e}`);return t})}send(e,t){let n=this.deps.getClient();if(!n)return Promise.reject(Error(`kernel client not attached`));let r=t.messageId??`msg-${Date.now()}-${Math.random().toString(36).slice(2,8)}`;return n.sendUserMessage({scoopJid:e,text:t.text,messageId:r,...t.attachments?{attachments:t.attachments}:{},...t.steer?{steer:!0}:{},...t.guestGate?{guestGate:t.guestGate}:{}})}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 Gl({fills:e.fills,getAwaiting:()=>e.awaitingInput,getClient:()=>e.getClient(),phases:e.phases,statuses:e.statuses,turns:e.turns}),e.workUnits}function Kl(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=zn(n,i);if(t){e.pendingUrlContext=null,e.selectScoop(t);return}}let a=Gn(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),i!==a&&e.notifyUnitStatus?.(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(jl(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`&&pe(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=qn(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 ql=`slicc:leader-local-model-state-changed`;function Jl(e=window){e.dispatchEvent(new Event(ql))}var Yl=`slicc:leader-model-catalog-changed`;function Xl(e=window){e.dispatchEvent(new Event(Yl))}var Zl={off:`off`,low:`low`,medium:`medium`,high:`high`,xhigh:`xhigh`,max:`xhigh`},Ql={off:`off`,minimal:`low`,low:`low`,medium:`medium`,high:`high`,xhigh:`xhigh`};function $l(e){return e?Zl[e]:void 0}function eu(e){return e===`max`?`max`:void 0}function tu(e,t){return t===`max`?`max`:(e&&Ql[e])??`off`}var nu=2e3,ru=1e4,iu=12e4;function au(e){let t=[],n=null,r=new Map,i=e.modelPickerEnabled!==!1,a=e.catalogRetryDelayMs??nu,o=e.catalogRetryMaxDelayMs??ru,s=e.catalogRetryWindowMs??iu,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=wn(n.activeModelId);return e&&r.set(t,e),n.activeModelId}let a=Vn(i,t,t?r.get(t):void 0);return t&&a&&r.set(t,a),a?Tn(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`,tu(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?wn(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=$l(i),o=e.getSelectedScoopJid()??n?.scoopJid;o&&a&&a!==`max`&&r.setThinkingLevel(o,a,eu(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 ou(e,t,n,r,i=Jl){let a=await e.setScoopThinkingLevel(t,n,r);return a&&i(),a}function su(e,t){return Un(e)===null||new URL(t.location.href).searchParams.get(`cherry`)===`1`||At(t.localStorage)}async function cu(e,t,n,r,a){let o=Bn(t),s=Jn(o);e.thread.setAttribute(`context`,Yn(t));let l=Hn(t),u=c({isRoot:l,name:t.name});e.thread.setAttribute(`accent`,u),e.switcher.setAttribute(`active`,t.id),me(e,l?{kind:`cone`}:{kind:`scoop`,accent:u}),ue(e,s);let d=localStorage.getItem(`slicc_locked_effort_level`),f=r?.(t.id);if(f||d){let t=f?xn(f):{};e.composerMeta.setAttribute(`thinking`,tu(d??t.level,t.effortOverride))}if(!a?.skipModelPill)try{let{resolveCurrentModel:r,resolveModelById:a}=await i(async()=>{let{resolveCurrentModel:e,resolveModelById:t}=await import(`./main-Nm8Ln4q3.js`).then(e=>e.i);return{resolveCurrentModel:e,resolveModelById:t}},__vite__mapDeps([51,1,52,8,9,10,11,2,12,13,14,15,16,3,17,18,5,19,20,21,22,23,24,25,26,27,28,6,7,29,30,31,32,33,35,53,54])),o=Vn(n,t.id),s=o?a(o.id,o.provider):r();e.composerMeta.setAttribute(`model`,s.name??s.id),e.composerMeta.toggleAttribute(`no-thinking`,s.reasoning!==!0||!!d)}catch{}}async function lu(e){if(su(e.pendingUrlContext,e.win))return;let t=Un(e.pendingUrlContext);if(t===null)return;let[{CanonicalSessionReader:n},{WorkUnitConversationStore:r}]=await Promise.all([i(()=>Promise.resolve().then(()=>rr),void 0),i(()=>Promise.resolve().then(()=>_r),void 0)]),a=await new n(new r).loadRootChatSession(t);a&&a.messages.length>0&&!e.hasSelection()&&(e.loadMessages(a.messages),e.onHydrated())}function uu(e){let{boot:t,client:n,openReader:r,log:a}=e,{refs:o}=t;i(async()=>{let{createPlaceholderRefresher:e}=await import(`./wc-placeholder-Cd8RcYU6.js`);return{createPlaceholderRefresher:e}},__vite__mapDeps([55,2,0,1,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38])).then(({createPlaceholderRefresher:n})=>{e.setRefreshPlaceholder(n({inputCard:o.inputCard,getMessages:()=>t.getController()?.getMessages()??[],defaultPlaceholder:o.inputCard.getAttribute(`placeholder`)??`Ask sliccy, or describe a change…`}))}),lu({pendingUrlContext:t.wiring.pendingUrlContext,win:window,hasSelection:()=>!!t.getSelected(),loadMessages:e=>t.getController()?.loadMessages(e),onHydrated:e.triggerPlaceholder}).catch(e=>a.warn(`WC session hydration failed`,e));let s=null;return i(async()=>{let{wireWcAttach:e}=await import(`./wc-attach-BpAfl-hq.js`);return{wireWcAttach:e}},__vite__mapDeps([56,2,5,57])).then(({wireWcAttach:t})=>{s=t({inputCard:o.inputCard,freezer:o.freezer,composer:o.composer,openReader:r,openWriter:e.openWriter,secretEntry:!0,listConversations:async()=>{let{readSessionsIndex:e}=await i(async()=>{let{readSessionsIndex:e}=await Promise.resolve().then(()=>to);return{readSessionsIndex:e}},void 0);return(await e(await r())).map(e=>({id:e.filename,label:e.title,sub:`${e.messageCount} turns`}))},log:a})}).catch(e=>a.error(`WC add-menu wiring failed`,e)),i(async()=>{let{wireWcHistoryNav:e}=await import(`./wc-history-nav-C5w8ianG.js`);return{wireWcHistoryNav:e}},[]).then(({wireWcHistoryNav:e})=>e({thread:o.thread,inputCard:o.inputCard})).catch(e=>a.error(`WC history nav wiring failed`,e)),o.composerMeta.addEventListener(`thinking-change`,e=>{if(localStorage.getItem(`slicc_locked_effort_level`))return;let r=e.detail?.thinking,i=$l(r),o=eu(r),s=t.getSelected();s&&i&&ou(n,s.id,i,o).catch(e=>a.warn(`local thinking update failed`,e))}),{getAttachStage:()=>s}}var du=`slicc:leader-run-new-session`,fu=`slicc:leader-broadcast-snapshot`;function pu(e){if(!(!e.cone||e.cone===`cone`))return e.coneLabel||e.cone.replace(/^cone-/,``)}function mu(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 hu(e){let t=document.createElement(`slicc-freezer-card`);return t.setAttribute(`title`,e.title),t.setAttribute(`meta`,mu(e)),t.setAttribute(`slug`,e.filename),e.icon&&t.setAttribute(`icon`,e.icon),t}async function gu(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 _u(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(E,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 _u(e){let t=await vu(e);return t.kind===`ok`?t.entries:t.kind===`missing`?[]:null}async function vu(e){let t;try{let n=await e.readFile(E,{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 yu(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(bu(r,i))}catch{}return n.sort((e,t)=>t.frozenAt.localeCompare(e.frozenAt)),n}function bu(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=dt(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.curatedThrough?{curatedThrough:o.curatedThrough}:{},...o.sessionId?{sessionId:o.sessionId}:{},...s?{pendingEnrichment:!0}:{}}}function xu(e,t){for(let t of Array.from(e.querySelectorAll(`slicc-freezer-card`)))t.remove();e.append(...t.map(hu))}async function Su(e,t){let n=await e.readFile(Ze(t),{encoding:`utf-8`}),r=typeof n==`string`?n:new TextDecoder().decode(n),i=await it(e,r,t.filename);return{title:i.title||t.title,messages:i.messages}}async function Cu(e,t,n){let{getTranscriptExportService:r}=await i(async()=>{let{getTranscriptExportService:e}=await Promise.resolve().then(()=>kr);return{getTranscriptExportService:e}},void 0);await r().captureFrozen({sessionId:t.sessionId??t.archive.sessionId??t.filename.replace(/\.md$/i,``),title:t.archive.title,frozenAt:t.archive.frozenAt,createdAt:t.archive.createdAt,updatedAt:t.archive.updatedAt,...e?{rootJid:e.jid}:{}},n)}function wu(e,t){if(t)return e.getScoops().find(e=>e.jid===t.id)}function Tu(e){return{folder:e.folder,label:Wn({assistantLabel:e.assistantLabel,name:e.name,role:O(e)?`primary`:`child`}),jid:e.jid}}async function Eu(e){let{root:t}=e,n=t?Tu(t):void 0,r=(e,n)=>Cu(t,e,n),a=t=>{i(async()=>{let{notifyGelatiereOfSessionEnd:e}=await import(`./wc-gelatiere-DSkLEJWA.js`);return{notifyGelatiereOfSessionEnd:e}},__vite__mapDeps([58,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38])).then(({notifyGelatiereOfSessionEnd:r})=>r({client:e.client,vfs:e.writer,log:e.log,cone:n,archive:t?.filename})).catch(t=>e.log.warn(`gelatiere notification failed to load`,t))};if(e.action!==`save`){await e.runNewSessionFreezeQuick({vfs:e.writer,cone:n,captureCompleteSnapshot:r,onSessionSettled:a});return}await e.runNewSessionFreeze({vfs:e.writer,cone:n,agenticMemorySpawn:t=>e.client.spawnAgent(t),captureCompleteSnapshot:r,onSessionSettled:a,onProgress:t=>{let n=e.freezerNew();n&&(t===null?n.removeAttribute(`progress`):n.setAttribute(`progress`,String(t)))},onBackgroundEnriched:e.refreshFreezer})}async function Du(e,t){e!==`erase`&&await Eu({...t,action:e})}async function Ou(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(fu)),i(async()=>{let{resetDictationPriming:e}=await import(`./wc-shell-CpR39VTz.js`).then(e=>e.rt);return{resetDictationPriming:e}},__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38])).then(({resetDictationPriming:e})=>e()).catch(()=>void 0)}function ku(e,t){(e.thread.inner??e.thread).prepend(Au(e.thread.ownerDocument,t)),e.thread.setAttribute(`accent`,he),me(e,{kind:`freezer`}),e.inputCard.setAttribute(`disabled`,``),e.switcher.removeAttribute(`active`)}function Au(e,t){let n=t?pu(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 ju(e){let{refs:t,openVfs:n,client:r,getController:a,getSelected:o,clearSelection:s,log:c}=e,l=[],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 a=await _u(n);if(a===null){if((await vu(n)).kind!==`corrupt`||(c.warn(`WC freezer index corrupt — rebuilding from archives`),a=await yu(n),a.length===0))return;await r.writeFile(E,JSON.stringify(a,null,2))}e===f&&(l=a,xu(t.freezer,a),!p&&a.some(e=>!e.icon&&!e.pendingEnrichment)&&(p=!0,i(async()=>{let{pickLucideIcon:e}=await import(`./quick-llm-lj_1jQHe.js`).then(e=>e.n);return{pickLucideIcon:e}},__vite__mapDeps([47,1,9,10,11,2,12,13,14,15,3,7,8,16,17,18,5,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,48,37])).then(({pickLucideIcon:e})=>gu({reader:n,writer:r,freezer:t.freezer,entries:a,pickIcon:t=>e({subject:t})})).catch(e=>c.warn(`WC freezer icon enrichment failed`,e)).finally(()=>{p=!1})))}).catch(e=>c.error(`WC freezer refresh failed`,e))},h=!1,g=()=>t.freezer.querySelector(`slicc-freezer-new`),_=t=>{h||(h=!0,g()?.setAttribute(`busy`,``),(async()=>{let s=wu(r,Kn(e.getUnits(),o()));try{let{writer:o}=await n(),{resetNewSessionTmp:l,runNewSessionFreeze:u,runNewSessionFreezeQuick:f}=await i(async()=>{let{resetNewSessionTmp:e,runNewSessionFreeze:t,runNewSessionFreezeQuick:n}=await import(`./new-session-DYPm3kHj.js`);return{resetNewSessionTmp:e,runNewSessionFreeze:t,runNewSessionFreezeQuick:n}},__vite__mapDeps([59,2,3,17,7,8,1,9,10,11,12,13,14,15,16,18,5,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,51,52,6,35,53,54,48]));await Du(t,{writer:o,root:s,client:r,freezerNew:g,refreshFreezer:m,runNewSessionFreeze:u,runNewSessionFreezeQuick:f,log:c}),await Ou({writer:o,root:s,client:r,getController:a,log:c,resetNewSessionTmp:l,tmpDir:An(r.getScoops(),s),discardLiveSnapshot:t===`erase`}),m();let p=e.getUnits().find(e=>e.id===s?.jid)??Gn(e.getUnits());p&&d(p)}catch(e){c.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 i(async()=>{let{runNewSessionArchiveOnly:e}=await import(`./new-session-DYPm3kHj.js`);return{runNewSessionArchiveOnly:e}},__vite__mapDeps([59,2,3,17,7,8,1,9,10,11,12,13,14,15,16,18,5,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,51,52,6,35,53,54,48]));await r({vfs:t,cone:Tu(e),captureCompleteSnapshot:(t,n)=>Cu(e,t,n)}),m()};Te(`agentic-memory`)&&g()?.setAttribute(`no-skip`,``),window.addEventListener(du,e=>{let t=e.detail?.action;(t===`save`||t===`skip`||t===`erase`)&&_(t)});let y=async r=>{let i=l.find(e=>e.filename===r);try{let{reader:o}=await n();i||=(await _u(o)??[]).find(e=>e.filename===r);let{messages:c}=await Su(o,i??{filename:r,title:r,frozenAt:``,messageCount:0});t.thread.setAttribute(`context`,`freezer:${i?.filename??r}`),u=i?.sessionId??i?.filename??null,e.holdQueuedPile(),a()?.loadMessages(c),ku(t,i),s()}catch(t){if(c.error(`WC thaw failed`,t),!o()){let t=Rn(e.getUnits(),i?.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}}o(`scoops.tray-leave`),o(`scoops.tray-join`);var Mu=null;function Nu(e){Mu=e}function Pu(){return Mu?.()??[]}var Fu=null;function Iu(e){Fu=e}function Lu(){return Fu??void 0}var Ru=`slicc.leaderTrayFollowers`;function zu(){return Bu()}function Bu(){if(Mu)return Mu();try{let e=globalThis.localStorage?.getItem(Ru);if(e)return JSON.parse(e)}catch{}return[]}function Vu(e,t=globalThis.localStorage){try{t?.setItem(Ru,JSON.stringify(e))}catch{}}function Hu(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 Uu(e){let t=Dt();if(t.state!==`inactive`)return{role:`follower`,state:t.state,joinUrl:t.joinUrl,sessionId:t.trayId,workerBaseUrl:kt(t.joinUrl)?.workerBaseUrl??null,stalled:t.stalled};let n=gn();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=Mt(e.getItem(Ot))}catch{}return{role:`standalone`,state:`inactive`,workerBaseUrl:r}}function Wu(e){let{client:t,openReader:n,storage:r}=e;return{getScoops:()=>t.getScoops(),isProcessing:e=>t.isProcessing(e),getCronTasks:async()=>{let{getAllCronTasks:e}=await i(async()=>{let{getAllCronTasks:e}=await import(`./tray-leader-LJ0WrWVz.js`).then(e=>e.o);return{getAllCronTasks:e}},__vite__mapDeps([60,1,3,19,20,21,51,52,8,9,10,11,2,12,13,14,15,16,17,18,5,22,23,24,25,26,27,28,6,7,29,30,31,32,33,35,53,54]));return e()},getWebhooks:async()=>{let{getAllWebhooks:e}=await i(async()=>{let{getAllWebhooks:e}=await import(`./tray-leader-LJ0WrWVz.js`).then(e=>e.o);return{getAllWebhooks:e}},__vite__mapDeps([60,1,3,19,20,21,51,52,8,9,10,11,2,12,13,14,15,16,17,18,5,22,23,24,25,26,27,28,6,7,29,30,31,32,33,35,53,54]));return e()},getMounts:async()=>{let{getAllMountEntries:e,loadMountHandle:t}=await i(async()=>{let{getAllMountEntries:e,loadMountHandle:t}=await import(`./mount-table-store-dY2IfQ5S.js`).then(e=>e.r);return{getAllMountEntries:e,loadMountHandle:t}},__vite__mapDeps([61,1])),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 n()).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 n of ze()){if(e.has(n.providerId))continue;if(e.add(n.providerId),!Be(n.providerId)?.isOAuth){t.push({providerId:n.providerId});continue}let r=Re(n.providerId),i=n.loggedOut?!1:r?!r.expired:!1;t.push({providerId:n.providerId,valid:i})}return t}catch{return[]}},getSessionStats:async()=>t.getSessionStats?.()??null,getProcesses:async()=>{try{let e=await(await n()).readFile(`/proc/table`,{encoding:`utf-8`});return Hu(typeof e==`string`?e:new TextDecoder().decode(e))}catch{return{processes:[],terminated:0}}},getTrayInfo:()=>Uu(r),getConnectedFollowers:Pu}}var Gu=`sync-fs-nonce`;function Ku(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:Gu,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 qu=class{#e=new Map;#t=new Map;#n=new Map;sync(e,t){let n=new Set;for(let r of e){if(!Hn(r))continue;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 Ju(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 Yu=`question`;function Xu(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone||void 0}catch{return}}function Zu(e,t,n){let r=e=>{let r=e.detail;if(!r||typeof r.answer!=`string`)return;let{question:i,kind:a,answer:o}=r,s=a===`datetime`||a===`date`?Xu():void 0;t(Yu,{action:`answer`,data:{question:i,kind:a,answer:o,...s?{timeZone:s}:{}}},void 0,n()??void 0)};return e.addEventListener(le,r),()=>e.removeEventListener(le,r)}var Qu=`<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 $u(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 ed(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(Qu));let a=()=>{r.style.color=`var(--green)`,setTimeout(()=>{r.style.color=`var(--txt-3)`},1500)};return r.addEventListener(`short-click`,()=>{(async()=>{let n=$u(e.getMessages());await t(n??Ye([...e.getMessages()])),a()})()}),r.addEventListener(`long-press`,()=>{(async()=>{let n=Ye([...e.getMessages()]);n&&(await t(n),a())})()}),n.append(r),n}function $(){return`msg-${Date.now()}-${Math.random().toString(36).slice(2,8)}`}function td(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 nd(e){return`
|
|
429
|
-
<div class="sprinkle-action-card">
|
|
430
|
-
<div class="sprinkle-action-card__header">${an(td(e))} <span class="sprinkle-badge sprinkle-badge--informative">pending</span></div>
|
|
431
|
-
<div class="sprinkle-action-card__body">Waiting for approval on the leader…</div>
|
|
432
|
-
</div>
|
|
433
|
-
`}function rd(e){let t={id:e.id,text:e.content};return e.attachments?.length&&(t.attachments=e.attachments.length),t}var id=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=null;#D=null;#O=!1;#k=`thinking`;#A=0;#j=null;#M=new Set;#N=new Map;#P=new Map;#F=new Set;#I=!1;#L=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.#J(e)),this.#v=e=>this.#ge(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.#N.keys()])this.#he(e);this.#P.clear(),this.#F.clear(),this.#me()}setReadOnly(e){if(this.#I!==e&&(this.#I=e,e))for(let e of[...this.#N.keys()])this.#he(e)}get readOnly(){return this.#I}get processing(){return this.#O}getMessages(){return this.#y.map(e=>({...e}))}setAgent(e){this.#h(),this.#t=e,this.#h=e.onEvent(e=>this.#J(e))}setOnLocalUserMessage(e){this.#g=e}setOnLocalProcessingChange(e){this.#_=e}addUserMessage(e,t,n){this.#ye({id:$(),role:`user`,content:e,timestamp:Date.now(),...n?{source:n}:{}})}getQueuedMessages(){return this.#b.map(rd)}removeQueuedMessage(e){let t=this.#b.filter(t=>t.id!==e);t.length!==this.#b.length&&(this.#b=t,this.#B())}stashQueued(){let e=this.#L??[];this.#L=null;let t=this.#b;return t.length===0?e:(this.#b=[],this.#B(),[...e,...t])}restoreQueued(e){this.#L=e.length>0?[...e]:null}heldBackendPendingIds(e){if(!this.#L||!e?.length)return new Set;let t=new Set(e);return new Set(this.#L.filter(e=>t.has(e.id)).map(e=>e.id))}#R(e,t){if(!this.#L)return;let n=this.heldBackendPendingIds(t),r=new Set(e.map(e=>e.id)),i=this.#L.filter(e=>!r.has(e.id)||n.has(e.id));if(this.#L=null,i.length===0)return;if(!t){this.#b=i,this.#B();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.#O?o:[...o,...s],this.#B(),this.#O)for(let e of s)this.#ye(e)}#z(){if(this.#b.length===0)return;let e=this.#b;this.#b=[];for(let t of e)this.#ye(t);this.#B()}#B(){this.#u?.(this.#b.map(rd))}#V(){this.#d?.(this.#x)}setLickBackpressure(e,t,n){if(e<=0){if(!this.#x)return;this.#x=null,this.#V();return}this.#x={text:`${e} events waiting for the current turn`},this.#V();try{yt(n,t)}catch{}}addAssistantMessage(e){this.#ye({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.#N.keys()])this.#he(e);this.#P.clear(),this.#F.clear(),this.#me();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.#B();let r=this.heldBackendPendingIds(t),i=r.size>0?e.filter(e=>!r.has(e.id)):e;this.#y=Se(i);let a=[...this.#y].reverse().find(e=>e.isStreaming);this.#C=a?.id??null,a&&(this.#w=a.id),this.#Q(),this.#S.clear();let o=[],s=``;for(let e of this.#y){let t=new Date(e.timestamp).toDateString();t!==s&&(o.push(_(e.timestamp)),s=t);let n=this.#ve(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.#Ce();for(let e of this.#y)this.#o?.(e,this.#S.get(e.id)??[]);this.#q(),this.#Te(),this.#H(),this.#R(e,t)}#H(){if(this.#e.getAttribute(`context`)!==`cone`||this.#y.length===0||!jt()||this.#O)return;let e=this.#y[this.#y.length-1];e.role!==`user`||e.source===`lick`||e.source===`delegation`||e.queued||this.#ge(new Event(`slicc-error-retry`))}sendUserMessage(e,t,n){let r=e.trim();if(!r&&!t?.length)return;let i=n?.dictation?this.#U(r):r,a={id:$(),role:`user`,content:i,timestamp:Date.now(),attachments:t?.length?t:void 0};this.#O&&!n?.steer?(this.#b.push(a),this.#B()):this.#ye(a),n?.steer?this.#t.sendMessage(i,a.id,a.attachments,{steer:!0}):this.#t.sendMessage(i,a.id,a.attachments),this.#W();try{let e=n?.dictation?x(i):i;this.#g?.(e,a.id,a.attachments)}catch(e){console.error(`onLocalUserMessage hook threw`,e)}}#U(e){return ge(e,de())}#W(){if(this.#l)try{let e=this.#l();if(!e)return;St(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.#be(a);return}this.#ye({id:e,role:`user`,content:t,timestamp:r,source:`lick`,channel:n,lickId:i,lickState:i?`pending`:void 0,queued:this.#O?!0:void 0})}updateLickState(e,t){let n=this.#y.find(t=>t.lickId===e);n&&(n.lickState=t,this.#be(n))}setProcessing(e){if(this.#O!==e){this.#O=e,e&&(this.#w=null),e&&(this.#A=0,this.#G(`thinking`)),e&&this.#z(),e||(this.#x&&(this.#x=null,this.#V()),this.#q()),this.#n?.(e);try{this.#_?.(e)}catch(e){console.error(`onLocalProcessingChange hook threw`,e)}e||this.#K()}}#G(e){this.#k!==e&&(this.#k=e,this.#r?.(e))}#K(){let e=this.#w;if(this.#w=null,!this.#c)return;let t=e?this.#_e(e):null;this.#c(t?{...t}:null)}#q(){let e=this.#y[this.#y.length-1];if(!(e?.role===`assistant`&&!e.isStreaming)){this.#j?.remove();return}this.#j??=ed({getMessages:()=>this.getMessages()}),(this.#e.inner??this.#e).append(this.#j)}#J(e){switch(e.type){case`message_start`:this.#Y(e.messageId);break;case`content_delta`:this.#X(e.messageId,e.text);break;case`content_done`:this.#$(e.messageId,e.model,e.usage);break;case`tool_use_start`:this.#te(e.messageId,e.toolName,e.toolInput,e.toolCallId);break;case`tool_result`:this.#re(e.messageId,e.toolName,e.result,e.isError,e.toolCallId);break;case`tool_ui`:this.#le(e.messageId,e.requestId,e.html);break;case`tool_ui_done`:this.#ue(e.requestId);break;case`tool_progress`:this.#de(e.messageId,e.toolName,e.progress,e.toolCallId);break;case`turn_end`:this.#oe(e.messageId);break;case`compaction_notice`:this.#ie(e.messageId,e.marker);break;case`error`:this.#se(e.error,e.endTurn!==!1)}}#Y(e){this.setProcessing(!0),this.#C=e,this.#w=e,this.#ye({id:e,role:`assistant`,content:``,timestamp:Date.now(),isStreaming:!0,toolCalls:[]})}#X(e,t){this.#_e(e)&&(this.#E!==e&&this.#Z(),this.#E=e,this.#T+=t,this.#D??=requestAnimationFrame(()=>this.#Z()))}#Z(){let e=this.#E,t=this.#T;this.#Q();let n=t&&e?this.#_e(e):void 0;n&&(n.content+=t,this.#be(n))}#Q(){this.#D!==null&&cancelAnimationFrame(this.#D),this.#D=null,this.#T=``,this.#E=null}#$(e,t,n){let r=this.#_e(e);r&&(t&&(r.model=t),n&&(r.usage=n),this.#E===e&&(r.content+=this.#T,this.#Q()),r.isStreaming=!1,this.#be(r))}static#ee(e,t){return`${e}:${t}`}#te(t,n,r,i){let a=this.#_e(t);if(!a)return;a.toolCalls=a.toolCalls??[];let o=i?e.#ee(t,i):$();this.#F.add(o),a.toolCalls.push({id:o,name:n,input:r}),this.#A+=1,this.#G(`tool`),this.#be(a)}#ne(t,n,r){let i=t?.toolCalls??[];if(r){let n=t?e.#ee(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)}#re(e,t,n,r,i){let a=this.#_e(e),o=this.#ne(a,t,i);!a||!o||(o.result=n,o.isError=r,o.id&&(this.#P.delete(o.id),this.#me()),this.#A=Math.max(0,this.#A-1),this.#A===0&&this.#G(`thinking`),this.#be(a))}#ie(e,t){let n=this.#_e(e);if(t.state===`discarded`){n&&this.#ae(n);return}if(n){n.compaction=t,this.#be(n);return}this.#ye({id:e,role:`assistant`,content:``,timestamp:Date.now(),compaction:t})}#ae(e){this.#Se(),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.#Ce(),this.#pe()}#oe(e){let t=this.#_e(e);t?.isStreaming&&(t.isStreaming=!1,this.#be(t)),this.#C=null,this.setProcessing(!1)}#se(e,t=!0){t&&this.setProcessing(!1),this.#ye({id:$(),role:`assistant`,content:typeof e==`string`?e:xt(e)??``,timestamp:Date.now(),error:!0}),this.#ce(e)}#ce(e){try{let t=typeof e==`string`?e:bt(e);if(typeof t==`string`&&Ct(t))return;wt(`error-card`,e)}catch{}}#le(e,t,n){if(this.#I)return;this.#he(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=B(r,nd(n),()=>{},!1);this.#N.set(t,{instance:e,container:r});return}let i=B(r,n,(e,n)=>{this.#p?.(t,e,n)},!1);this.#N.set(t,{instance:i,container:r}),this.#p?.(t,vt,void 0)}#ue(e){this.#he(e)}#de(e,t,n,r){let i=this.#_e(e),a=this.#ne(i,t,r);a?.id&&(n.phase===`end`?this.#P.delete(a.id):this.#P.set(a.id,n),this.#fe(a.id),this.#me())}#fe(e){let t=this.#e.querySelector(`slicc-action-row[data-tool-id="${CSS.escape(e)}"]`);t&&te(t,this.#P.get(e)??null),this.#pe()}#pe(){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.#F.has(e.dataset.toolId)).map(e=>{let t=e.dataset.toolId,n=e.getAttribute(`result`);return{done:n!==null&&n!==`…`,fraction:this.#P.get(t)?.fraction}});we(t,ye(e))}}#me(){let e=null,t=[...this.#P.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))}#he(e){let t=this.#N.get(e);if(t){this.#N.delete(e);try{t.instance.dispose()}catch{}t.container.remove()}}#ge(e){if(this.#O)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)}#_e(e){return this.#y.find(t=>t.id===e)}#ve(e){try{return l(e,{readOnly:this.#I})}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]}}#ye(e){this.#Se(),this.#y.push(e);let t=this.#ve(e);this.#S.set(e.id,t),this.#e.append(...t),this.#Ce(),this.#o?.(e,t),e.role===`user`?this.#Te():this.#Ee()}#be(e){this.#Se();let t=this.#S.get(e.id)??[],n=this.#ve(e),r=t[0]??null,i=r?.parentNode;if(i)for(let e of n)i.insertBefore(e,r);else this.#e.append(...n);this.#S.set(e.id,n),this.#o?.(e,n);for(let e of t)e.remove();for(let t of e.toolCalls??[])t.id&&this.#P.has(t.id)&&this.#fe(t.id);this.#Ce(),this.#pe(),this.#Ee()}#xe(){return this.#e.inner??this.#e}#Se(){y(this.#xe(),this.#M)}#Ce(){be(this.#xe(),{openClusterAnchors:this.#M,toolCallLookup:(e,t)=>this.#we(e,t)})}#we(e,t){return this.#y.find(t=>t.id===e)?.toolCalls?.find(e=>e.id===t)}#Te(){this.#e.scrollTop=this.#e.scrollHeight}#Ee(){let e=this.#e;typeof e.requestFollow==`function`?e.requestFollow():this.#Te()}};function ad(e,t,n,r,a,o){let s=new Map;i(async()=>{let{loadDipStyles:e}=await import(`./legacy-styles-B3nS5QUo.js`);return{loadDipStyles:e}},__vite__mapDeps([62,2])).then(({loadDipStyles:e})=>e()).catch(()=>void 0);let c=[];n.subscribeList(e=>{c=e});let l=()=>t.addressableUnitId?t.addressableUnitId():r()?.id??null,u=Ju(n,{getSelectedId:l,onError:e=>t.emitAgentError(e),onEvent:e=>t.onAgentEvent(e)});u.onEvent(t=>{(t.type===`tool_use_start`||t.type===`tool_result`)&&(t.type===`tool_result`&&t.isError&&e.switcher.glower(),i(async()=>{let{playCue:e}=await import(`./soundscape-DnGFq-oy.js`);return{playCue:e}},__vite__mapDeps([63,3,0,1,2,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38])).then(({playCue:e})=>e(t.type===`tool_use_start`?`tool-start`:`tool-finish`)).catch(()=>void 0))});let d=new id({thread:e.thread,agent:u,resolveTelemetryContext:()=>{let e=r();if(!e)return null;let t=qn(e);try{let n=Vn(c,e.id);return{scoopName:t,model:(n?Le(n.id,n.provider):Ve()).id}}catch{return{scoopName:t,model:``}}},onTurnComplete:e=>{t.speaksReplies&&i(async()=>{let{consumeVoiceSubmission:e,speakReplyMarkdown:t}=await import(`./voice-reply-4Y8XE5qj.js`);return{consumeVoiceSubmission:e,speakReplyMarkdown:t}},__vite__mapDeps([64,3,0,1,2,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,65,66,67,68])).then(async({consumeVoiceSubmission:t,speakReplyMarkdown:n})=>{if(!t())return;let{endVoiceTurn:r,setTtsActive:a}=await i(async()=>{let{endVoiceTurn:e,setTtsActive:t}=await import(`./soundscape-DnGFq-oy.js`);return{endVoiceTurn:e,setTtsActive:t}},__vite__mapDeps([63,3,0,1,2,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38]));try{if(e?.content){a(!0);try{await n(e.content)}finally{a(!1)}}}finally{r()}}).catch(()=>void 0)},onProcessingChange:t=>{e.frame.toggleAttribute(`data-processing`,t),e.inputCard.querySelector(`slicc-send-button`)?.toggleAttribute(`busy`,t),t||a?.()},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=s.get(e);t&&(xi(t),s.delete(e))},onMessageRendered:(e,n)=>{let r=s.get(e.id),i=n[0];if(!i){r&&xi(r),s.delete(e.id);return}t.onMessageRendered?.(i);let a=l()??void 0;s.set(e.id,bi(i,(e,n)=>{let r={type:`sprinkle`,sprinkleName:`inline`,timestamp:new Date().toISOString(),body:{action:e,data:n}};o?.intercept?.(r)||t.sendSprinkleLick(`inline`,{action:e,data:n},void 0,a)},{previous:r,streaming:e.isStreaming===!0}))},onQueuedChange:t=>e.queuedStack.setMessages(t),onLickBackpressureChange:t=>{e.lickBackpressureNotice.textContent=t?.text??``,e.lickBackpressureNotice.toggleAttribute(`hidden`,t===null)},onToolUiAction:(e,n,r)=>{t.sendToolUiAction(e,n,r)},onQueuedCancel:e=>{let n=r()?.id;n&&t.deleteQueuedMessage(n,e).catch(()=>void 0)},...t.readOnlyToolUi?{readOnlyToolUi:!0}:{}});return e.queuedStack.addEventListener(`slicc-queued-remove`,e=>{let n=e.detail?.id;if(!n)return;d.removeQueuedMessage(n);let i=r()?.id;i&&t.deleteQueuedMessage(i,n).catch(()=>void 0)}),Zu(e.thread,(e,n,r,i)=>t.sendSprinkleLick(e,n,r,i),l),{controller:d,agentHandle:u}}function od(e,t){let n=new qu,r=()=>{let r=t.currentUnits(),i=e.getSelected()?.id;e.refs.switcher.scoops=Ln(r,i,c,n.sync(r,i)),e.refreshConeActions?.()};return e.refreshScoops=r,t.subscribeList(()=>r()),r}function sd(e,t,n){let{refs:r}=e;e.setChatTransport(t,n);let{controller:a,agentHandle:o}=ad(r,n,t,()=>e.getSelected(),n.onTurnIdle,n.welcome);e.setController(a);let s=od(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 o=fe(t),s=n.takeAttachments?.();if(!o&&!s?.length)return;e.wiring.awaitingInput=null,e.wiring.refreshScoops?.(),e.wiring.notifyScoopStateChanged?.();let c=t.detail?.source===`dictation`;c&&n.speaksReplies&&(i(async()=>{let{markVoiceSubmission:e}=await import(`./voice-reply-4Y8XE5qj.js`);return{markVoiceSubmission:e}},__vite__mapDeps([64,3,0,1,2,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,65,66,67,68])).then(({markVoiceSubmission:e})=>e()).catch(()=>void 0),i(async()=>{let{beginVoiceTurn:e,playCue:t}=await import(`./soundscape-DnGFq-oy.js`);return{beginVoiceTurn:e,playCue:t}},__vite__mapDeps([63,3,0,1,2,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38])).then(({beginVoiceTurn:e,playCue:t})=>{e(),t(`sent`)}).catch(()=>void 0)),a.sendUserMessage(o??``,s,{dictation:c,steer:ee(t)}),r.inputCard.clear?.();let l=e.getSelected()?.id;l&&(r.switcher.setAttribute(`attention`,l),e.wiring.lastActivity.set(l,(o??``).slice(0,600)))}),r.inputCard.addEventListener(`stop`,()=>{e.getController()?.processing&&o.stop()}),{agentHandle:o,controller:a,publishStrip:s}}var cd=e({floatKindForRuntimeMode:()=>dd,floatLabelForKind:()=>ud,resolveStandaloneFloatKind:()=>fd}),ld={"slicc-server":`sliccstart`,"slicc-node-server":`npx`};function ud(e){return g(e)}function dd(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 fd(e){let t=e?.fetchFn??fetch,n=e?.timeoutMs??1500;try{let e=new AbortController,r=setTimeout(()=>e.abort(),n),i=await t(mt(`/api/status`),{cache:`no-store`,signal:e.signal,headers:ht()}).finally(()=>clearTimeout(r));if(await ft(i),!i.ok)return`standalone`;let a=await i.json();return(a.service?ld[a.service]:void 0)??`standalone`}catch(e){if(pt(e))throw e;return`standalone`}}function pd(e,t){let n=t.label??ud(t.floatKind);e.setAttribute(`label`,n),e.setAttribute(`float-kind`,t.floatKind);let r=gn(),i=Dt(),a=()=>{let t=md(r,i);e.setAttribute(`connection`,t.connection),t.trayRole===`none`?e.removeAttribute(`tray-role`):e.setAttribute(`tray-role`,t.trayRole)},o=mn(e=>{r=e,a()}),s=Tt(e=>{i=e,a()});return a(),()=>{o(),s()}}function md(e,t){return e.state===`inactive`?t.state===`inactive`?{connection:`offline`,trayRole:`none`}:{connection:gd(t),trayRole:`follower`}:{connection:hd(e),trayRole:`leader`}}function hd(e){switch(e.state){case`connecting`:return`connecting`;case`leader`:return`live`;case`reconnecting`:return`reconnecting`;case`error`:return`error`;default:return`offline`}}function gd(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 _d(e,t,n){let r=n.floatLabel??ud(n.floatKind),i=If(e,r);pd(i.refs.floatbar,{floatKind:n.floatKind,label:r});let a=await n.connect(i),o=sd(i,a.client,a.host);return await a.workbench?.(i,o),t.info(`WC shell mounted`,{floatKind:n.floatKind}),{boot:i,chat:o}}var vd=36e5,yd=2e3,bd=class{#e=[];#t;#n;constructor(e=vd,t=yd){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`}};function xd(e){return m(e,f)}async function Sd(e,t=k.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 xd(n)}function Cd(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:ls(e),sublabel:n,meta:ss(e),icon:is(e),badges:r,status:os(e)}})}}function wd(e){return e.stalled||e.state===`reconnecting`?`warn`:e.state===`error`?`error`:e.state===`leader`||e.state===`connected`?`active`:`idle`}function Td(e){return e.stalled?`stalled`:e.state===`leader`?`connected`:e.state}function Ed(e){let t=Td(e),n=e.sessionId?`Session ${ns(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:wd(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:wd(e)}]}}function Dd(e,t){let n=e.filter(e=>O(e)),r=t=>e.filter(e=>!O(e)&&e.parentJid===t),i=(e,n)=>{let r=t(e.jid);return{name:O(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 Od(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 kd(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 Ad(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 jd(e){let t=zt({percent:e.percent,status:e.status});return t===`critical`?`error`:t===`warn`?`warn`:`active`}function Md(e,t){let n=`${Lt(e.percent)}% used`,r=Rt(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:jd(e)}}function Nd(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`:``,`${Lt(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?jd(n):void 0,emptyText:`Model usage will be summarized after the first turn.`,rows:[...n?[Md(n,t)]:[],...r.map(e=>({name:e.model,meta:`$${e.cost.toFixed(4)}`,status:`idle`}))]}}function Pd(e){let t=[],n=Fd(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=wd(e.tray);(r===`error`||r===`warn`)&&t.push({id:`tray`,severity:r===`error`?`error`:`warn`,icon:`cloud-off`,title:`Tray ${Td(e.tray)}`,detail:e.tray.workerBaseUrl?`Worker · ${e.tray.workerBaseUrl}`:`No tray session is established.`});for(let n of e.followers)os(n)===`warn`&&t.push({id:`follower:${n.runtimeId}`,severity:`warn`,icon:`radio`,title:`${ls(n)} stopped answering`,detail:n.motd??n.runtime??`No heartbeat from this follower.`,age:ss(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 Fd(e,t){if(!e||zt({percent:e.percent,status:e.status})===`ok`)return null;let n=Rt(e.resetsAt,t),r=`${Lt(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 Id(e){return e>=100?`$${Math.round(e)}`:`$${e.toFixed(2)}`}function Ld(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:Id(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:zd(l,e.units??[]),accent:u>=.9?`rose`:u>=.7?`amber`:`green`,foot:`fullest of ${l.length} context window${l.length===1?``:`s`}`}),d?[Rd(d,t,e.now??Date.now()),...f]:f}function Rd(e,t,n){let r=zt({percent:e.percent,status:e.status});return{id:`budget`,label:`${e.window[0]?.toUpperCase()??``}${e.window.slice(1)} budget`,value:Lt(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`:``,Rt(e.resetsAt,n)??``,t?`$${t.totalCost.toFixed(2)} this session`:``].filter(Boolean).join(` · `)}}function zd(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?O(r):!1,a=r?.name||(r?`sliccy`:e);return{id:e,ratio:t,color:c({isRoot:i,name:a}),label:`${i?`${a} (cone)`:a} — ${Math.round(t*100)}% full`}})}var Bd={running:`R`,pending:`S`,exited:`Z`,killed:`K`};function Vd(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 Hd(e,t){return{pid:e.pid,ppid:e.ppid,state:Bd[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:Vd(e.startedAt,t)}}async function Ud(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:Ld({stats:l,workingUnits:h,totalUnits:n.length,liveProcesses:d.length,terminated:f,history:t,units:n,now:g}),alerts:Pd({tray:r,followers:i,mounts:s,oauthProviders:p,budget:l?.budget,now:g}),sections:[Ed(r),Cd(i),Dd(n,t=>e.isProcessing(t)),Od(s),kd(m,p),Ad(a,o),Nd(l,g)],processes:{rows:d.map(e=>Hd(e,g)),terminated:f}}}var Wd=`/shared`,Gd=3,Kd=200;async function qd(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,Kd),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<Gd?await qd(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 Jd(e,t=k.root){let n=[];for(let r of[t,Wd])n.push({kind:`dir`,id:r,label:r.replace(/^\/(cones\/)?/,``),open:!0,children:await qd(e,r,1)});return n}var Yd=200,Xd=1e3,Zd=3e3,Qd=45e3;function $d(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 Jd(n,e.getWorkspace().root);t===o&&(e.fileTree.items=i,r||(r=!0,ie({fileTree:e.fileTree,openFs:e.openFs,openWriter:e.openWriter,insertReference:e.insertReference,toPreviewUrl:re,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>=Xd){clearTimeout(c),c=null,u();return}c!=null&&clearTimeout(c),c=setTimeout(()=>{c=null,u()},Yd)},f=()=>{t??=setInterval(u,Zd)},p=()=>{let t=++a;s?.(),s=null;let n=[e.getWorkspace().root,Wd];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 ef(e){let t=!1,n=!1,r=!1,i=0,a=null,o=new bd,s=$d(e),c=()=>{a!=null&&(clearInterval(a),a=null)},l=()=>{let t=++i;e.openFs().then(async n=>{let r=await Sd(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 Ud(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 ${Qd}ms; re-arming so the next term activation retries`))},Qd);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 tf=[`/workspace`,`/shared`,`/memory`,`/scoops`,`/mnt`],nf=new Set([`node_modules`,`.git`,`dist`,`build`,`out`,`coverage`,`.cache`,`.venv`,`venv`,`__pycache__`,`target`,`vendor`,`.next`,`.turbo`,`python_wheels`]),rf=2e4,af=12,of=3e4;function sf(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 cf(e){return e.slice(e.lastIndexOf(`/`)+1)}function lf(e,t){return e===t?!0:e.endsWith(t)?e[e.length-t.length-1]===`/`:!1}function uf(e,t){let n=sf(e);return t.includes(`/`)?lf(n,t):cf(n)===t}function df(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))&&uf(a,e)&&(r.add(a),n.push(sf(a)),n.length>=ff))break}return n}var ff=4,pf=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??tf,this.#n=t.ignoredDirs??nf,this.#r=t.maxEntries??rf,this.#i=t.maxDepth??af,this.#a=t.ttlMs??of}resolve(e,t=[]){this.#g();let n=sf(e),r=this.#d(n),i=df(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!=null)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=>lf(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!=null)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(cf(e))??[];return e.includes(`/`)?{query:e,matches:t.filter(t=>lf(t,e)).sort(mf)}:{query:e,matches:[...t].sort(mf)}}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 mf(e,t){let n=e.split(`/`).length,r=t.split(`/`).length;return n===r?e.localeCompare(t):n-r}var hf=`file-mention`,gf=`data-file-mentions`;function _f(e){return`${e.childNodes.length}:${e.textContent?.length??0}`}var vf=new Set([`A`,`PRE`,`SCRIPT`,`STYLE`,`TEXTAREA`]),yf=`file-mention-open`;async function bf(e,t,n=[]){let r=_f(e);if(e.getAttribute(gf)===r)return;let i=xf(e);if(i.length===0){e.setAttribute(gf,r);return}let a=[],o=new Set;for(let e of i){let t=ce(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(gf,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&&Sf(e,n,l)}e.setAttribute(gf,_f(e))}function xf(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(vf.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 Sf(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(Cf(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 Cf(e,t,n,r,i){let a=e.createElement(`a`);return a.className=hf,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(yf,{detail:t,bubbles:!0,composed:!0}))}),a}var wf=`slicc-agent-message`,Tf=`slicc-action-row[${d}]`;function Ef(e,t){let n=[],r=e.querySelectorAll(Tf);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=>h(e))}function Df(e){let t=globalThis.requestIdleCallback;typeof t==`function`?t(e):setTimeout(e,0)}function Of(e){try{return kf(e)}catch(t){return e.log.error(`File mention wiring failed; continuing without it`,t),()=>{}}}function kf(e){let{thread:t,openFs:n,log:r}=e;if(!(t instanceof Node))return()=>{};let i=null,a=()=>(i??=n().then(e=>new pf(e)),i),o=e=>{if(!(e instanceof HTMLElement)||e.hasAttribute(`streaming`))return;let n=e.querySelector(`.body`)??e;ce(n.textContent??``).length!==0&&Df(()=>{let i=Ef(t,e);a().then(e=>bf(n,e,i)).catch(e=>r.error(`File mention linking failed`,e))})},s=e=>{for(let t of e.querySelectorAll(wf))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()===wf?o(e):s(e));let e=t.target?.closest?.(wf);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=>_e(e,t,i===void 0?{}:{line:i})).catch(e=>r.error(`File mention preview failed`,e))};return t.addEventListener(yf,l),()=>{c.disconnect(),t.removeEventListener(yf,l)}}var Af=e({DEFAULT_DOCK_TREE_ON_BOOT:()=>Yf,DOCK_TREE_STORAGE_KEY:()=>Jf,attachWcWorkbench:()=>Qf,bootLeaderFloat:()=>ep,makeSprinkleAttachImage:()=>Zf,prepareWcShell:()=>If,wireDockTreePersistence:()=>Xf,wireWcChipTips:()=>Uf,workspaceForSelection:()=>Pf});function jf(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?Kn(i,o)?.id??o.id:r;n.set(s,[...n.get(s)??[],...a])}function Mf(e){let{controller:t,destination:n,held:r,previousJid:i,roster:a}=e;if(i&&i!==n&&jf({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 Nf(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 Pf(e){let{client:t,selectedId:n}=e,r=n===void 0?void 0:t.getScoop(n);return n!==void 0&&!r&&e.clearSelection(),Dn(t.getScoops(),r)}function Ff(e){let{refs:t}=e,n=null,r=new Map;return{clear:()=>{n=null},getSelected:()=>n,holdQueue:()=>{let t=n?.id;t&&jf({controller:e.controller(),held:r,jid:t,roster:e.client().currentUnits()})},selectScoop:i=>{let a=n?.id??null;n=i;let o=Jn(Bn(i)),s=e.host();Mf({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,qn(i)),e.controller()?.setReadOnly(o),o||t.inputCard.removeAttribute(`disabled`),cu(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 If(e,t){let n=se(e,{messages:[],scoops:[],floatLabel:t,placeholder:`Ask sliccy, or describe a change…`,urlState:!0}),r=null,i=null,a=Rs,o=null,s=()=>o??Q(g),c=new Map,l=!1,u=null,d=!1,f=new Set,p=Nf(()=>s(),(e,t)=>{r?.loadMessages(e,t),Al(n.thread,e.length===0&&d),a.onSnapshotRendered?.(e)}).watch,m=Ff({client:s,controller:()=>r,host:()=>a,lickBackpressure:c,refs:n,watchUnit:p,wiring:()=>g,workbench:()=>u}),h=m.selectScoop,g={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:()=>m.getSelected(),selectScoop:h,notifyReady:()=>{l=!0;for(let e of f)e()}};return{refs:n,wiring:g,setClient:e=>{i=e},setChatTransport:(e,t)=>{o=e,a=t},getChatHost:()=>a,selectScoop:h,getSelected:()=>m.getSelected(),clearSelection:()=>m.clear(),holdQueuedPile:()=>m.holdQueue(),watchUnit:p,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):f.add(()=>e.activate(n)))},onClientReady:e=>{f.add(e),l&&e()},setRestoringSessions:e=>{d=e,Al(n.thread,e&&kl(n.thread))}}}function Lf(e){let t=null;return()=>(t??=(async()=>{let[{createRemoteVfsClient:t},{createRemoteWritableVfsClient:n}]=await Promise.all([i(()=>import(`./remote-vfs-client-Cs1yUtQm.js`),__vite__mapDeps([69,36])),i(()=>import(`./writable-vfs-client-CQe6oZ75.js`),__vite__mapDeps([70,36]))]);return{reader:t({transport:e.getTransport()}),writer:n({transport:e.getTransport()})}})(),t)}function Rf(e,t,n,r,a){e.onClientReady(()=>{r.intercept||i(async()=>{let{wireWcOnboarding:e}=await import(`./wc-onboarding-DAabd4D0.js`);return{wireWcOnboarding:e}},__vite__mapDeps([71,2,3,51,1,52,8,9,10,11,12,13,14,15,16,17,18,5,19,20,21,22,23,24,25,26,27,28,6,7,29,30,31,32,33,35,53,54,72])).then(({wireWcOnboarding:r})=>r({client:t,getController:()=>e.getController(),openVfs:n,log:a})).then(e=>{r.intercept=e.interceptWelcomeLick}).catch(e=>a.error(`WC onboarding wiring failed`,e))})}function zf(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:Rt(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 Bf(e,t,n){let r=t.standalone;r&&i(async()=>{let{wireWcBrowser:e}=await import(`./wc-browser-Y5gd2z2o.js`);return{wireWcBrowser:e}},__vite__mapDeps([73,74,6,75,3,76,77,0,1,2,4,5,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,78])).then(({wireWcBrowser:t})=>t({refs:e.refs,browser:r.browser,log:n})).catch(e=>n.error(`WC browser overlay wiring failed`,e))}function Vf(e){return{assistantLabel:e.assistantLabel,name:e.name,role:O(e)?`primary`:`child`}}function Hf(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 Uf(e){let t=new Map,n=new Set;e.switcher.addEventListener(`pointerover`,r=>{let a=r.target?.closest?.(`.slicc-agent-tabs__segment`);if(!a||!e.switcher.contains(a))return;let o=a.dataset.k??``,s=e.getScoops().find(e=>e.jid===o);if(!s)return;let c=e.lastActivity.get(o)??``,l=t.get(o);if(l&&l.activity===c){a.title=l.tip;return}a.title||=Wn(Vf(s)),!(!c||n.has(o))&&(n.add(o),(async()=>{try{let n=await(e.labelFn??(await i(async()=>{let{quickLabel:e}=await import(`./quick-llm-lj_1jQHe.js`).then(e=>e.n);return{quickLabel:e}},__vite__mapDeps([47,1,9,10,11,2,12,13,14,15,3,7,8,16,17,18,5,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,48,37]))).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: ${O(s)?`${Wn(Vf(s))} (a main agent)`:s.name}\nMost recent activity:\n${c}`,maxTokens:40});n&&(t.set(o,{activity:c,tip:n}),a.title=n)}finally{n.delete(o)}})())})}async function Wf(e,t,n,r){let{RemoteTerminalView:a}=await i(async()=>{let{RemoteTerminalView:e}=await import(`./remote-terminal-view-_0P4IDpH.js`);return{RemoteTerminalView:e}},__vite__mapDeps([79,2,28,3,57,39,40,21,46,1,80,16,45,44,81,82])),{fetchSecretEnvVars:o}=await i(async()=>{let{fetchSecretEnvVars:e}=await import(`./secret-env-z9SReONx.js`);return{fetchSecretEnvVars:e}},__vite__mapDeps([83,3,18,1,2,5,19,20,21,23,22,24,25,26])),s=await o(),c=new a({client:t,cwd:`/`,env:Object.keys(s).length>0?s:void 0});if(await new Promise(t=>e.onClientReady(t)),await c.mount(n),globalThis.__slicc_terminal_view=c,window.addEventListener(`beforeunload`,()=>c.dispose(),{once:!0}),new URLSearchParams(location.search).has(`wterm-image-demo`)){let e=await fetch(`/logos/sliccy-color-10scoops-128x128.png`);if(!e.ok)throw Error(`wterm demo image: HTTP ${e.status}`);let t=new Uint8Array(await e.arrayBuffer());await(await r()).writeFile(`/tmp/wterm-graphics-demo.png`,t);let n=await c.executeCommandInTerminal(`imgcat /tmp/wterm-graphics-demo.png`);if(n.exitCode!==0)throw Error(`wterm demo image: ${n.stderr}`)}}function Gf(e,t,n){let r=t=>{if(t.startsWith(`freezer:`)){n(t.slice(8));return}let r=zn(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 Kf(e,t,n,r){i(async()=>{let{installLeaderPermissionsSurface:e,installMountPendingConsumer:t}=await import(`./wc-permissions-BsWxtseN.js`);return{installLeaderPermissionsSurface:e,installMountPendingConsumer:t}},__vite__mapDeps([84,2,3,57])).then(async({installLeaderPermissionsSurface:r,installMountPendingConsumer:a})=>{let o=n.standalone?.runtimeMode??`standalone`,{buildLeaderPermissionProviders:s,isExtensionRuntime:c}=await i(async()=>{let{buildLeaderPermissionProviders:e,isExtensionRuntime:t}=await import(`./wc-permissions-providers-DwX67umy.js`);return{buildLeaderPermissionProviders:e,isExtensionRuntime:t}},__vite__mapDeps([85,2,21]));r({runtimeMode:o,providers:await s(c()||o===`extension`||o===`extension-detached`)}),a({runShell:qf(e,t)})}).catch(e=>r.warn(`WC permissions surface wiring failed`,e)),(n.standalone?.runtimeMode??`standalone`)!==`cherry`&&i(async()=>{let{installSecretRequestSurface:e}=await import(`./wc-secret-request-DYWa12vP.js`);return{installSecretRequestSurface:e}},__vite__mapDeps([86,3,0,1,2,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,87])).then(({installSecretRequestSurface:e})=>e()).catch(e=>r.warn(`WC secret request surface wiring failed`,e))}function qf(e,t){let n=null,r=()=>(n||=(async()=>{await new Promise(t=>e.onClientReady(t));let{TerminalSessionClient:n}=await i(async()=>{let{TerminalSessionClient:e}=await import(`./terminal-session-client-DmE-iBjP.js`).then(e=>e.n);return{TerminalSessionClient:e}},__vite__mapDeps([82,1])),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 Jf=`slicc-dock-tree:default`,Yf={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 Xf(e,t){let n=e.dockTree,r=e.dockTree,i=e=>{try{localStorage.setItem(Jf,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(Jf);r.setTree(e?JSON.parse(e):Yf)}catch(e){t.warn(`WC dock-tree restore failed — seeding the default layout`,e),r.setTree(Yf)}}function Zf(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 Qf(e,t,n,r,a,o={}){i(async()=>{let{initTimestampPreference:e}=await import(`./wc-shell-CpR39VTz.js`).then(e=>e.Q);return{initTimestampPreference:e}},__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38])).then(({initTimestampPreference:e})=>e()).catch(()=>void 0);let{refs:s}=e;e.setClient(t),i(async()=>{let{watchSprinkleThemeBroadcast:e}=await import(`./theme-CwPIBqJE.js`).then(e=>e.i);return{watchSprinkleThemeBroadcast:e}},__vite__mapDeps([88,1,89,3])).then(({watchSprinkleThemeBroadcast:e})=>e()).catch(()=>void 0),i(async()=>{let{applyThemeOverrides:e}=await import(`./theme-engine-ZV7CeqWw.js`).then(e=>e._);return{applyThemeOverrides:e}},__vite__mapDeps([89,1,3])).then(({applyThemeOverrides:e})=>e()).catch(()=>void 0);let c=Te(`panel-layouts`);s.dockTree.tilesMovable=c,c||Xf(s,a);let l=null,u=zf(e.wiring,t),d=()=>l?.(),f=r.welcome??{intercept:null},p=Q(e.wiring),{agentHandle:m}=n;e.onClientReady(u);let h=Lf(t),g=async()=>(await h()).reader;o.standalone?.runtimeMode!==`cherry`&&o.standalone?.runtimeMode!==`hosted-leader`?Rf(e,t,h,f,a):f.intercept=Ul({openVfs:async()=>(await h()).writer,log:a});let _=uu({boot:e,client:t,setRefreshPlaceholder:e=>{l=e},triggerPlaceholder:d,openReader:g,openWriter:async()=>(await h()).writer,log:a});r.setAttachmentSource(()=>_.getAttachStage()?.take()),r.setTurnIdleHook(Hf({boot:e,triggerPlaceholder:d,refreshStats:u})),Uf({switcher:s.switcher,getScoops:()=>t.getScoops(),lastActivity:e.wiring.lastActivity}),Bf(e,o,a),i(async()=>{let{installWcComputers:e}=await import(`./wc-computers-ChuSd7-K.js`);return{installWcComputers:e}},__vite__mapDeps([77,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,78])).then(({installWcComputers:e})=>e({openFs:g,log:a})).catch(e=>a.error(`WC computers wiring failed`,e)),Kf(e,t,o,a);let v=ef({fileTree:s.fileTree,termSurface:s.termSurface,memoryHost:s.memoryHost,monitor:s.monitor,openFs:g,openWriter:async()=>(await h()).writer,onKernelReady:t=>e.onClientReady(t),getMonitorDeps:()=>Wu({client:t,openReader:g,storage:window.localStorage}),getWorkspace:()=>Pf({client:t,clearSelection:e.clearSelection,selectedId:e.getSelected()?.id}),mountTerminal:n=>Wf(e,t,n,async()=>(await h()).writer),insertReference:e=>{let t=s.inputCard,n=t.value.trim();t.value=n?`${n} @${e}`:`@${e}`,t.focus()},log:a});e.setActivateSurface(v),c&&i(async()=>{let{panelizeShell:e}=await import(`./panelize-shell-BootSuaW.js`);return{panelizeShell:e}},__vite__mapDeps([90,3,0,1,2,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,91,92])).then(({panelizeShell:e})=>e(s,void 0,void 0,{onToolPanelActivate:e=>v.activate(e),onToolPanelDeactivate:e=>v.deactivate(e)})).catch(e=>a.error(`panelize failed — keeping the classic shell`,e)),Of({thread:s.thread,openFs:g,log:a}),ne(s.thread,g),s.floatbar.addEventListener(`click`,()=>{let e=s.dock;e.active===`monitor`?e.collapse():e.selectItem(`monitor`)});let y=ju({refs:s,openVfs:h,client:t,getUnits:()=>p.currentUnits(),getController:()=>e.getController(),getSelected:()=>e.getSelected(),selectScoop:e.selectScoop,clearSelection:e.clearSelection,holdQueuedPile:e.holdQueuedPile,log:a}),{refreshFreezer:b,openFrozen:ee,getViewedFrozenSessionId:x}=y;if(b(),e.onClientReady(b),Te(`multiple-cones`)){let n=Vl({freezer:s.freezer,client:t,getSelected:()=>e.getSelected(),getUnits:()=>p.currentUnits(),selectScoop:e.selectScoop,freezeCone:y.freezeCone,log:a});e.wiring.refreshConeActions=n.refresh,e.onClientReady(n.refresh)}Gf(e,t,ee),e.onClientReady(()=>{h().then(async({reader:e,writer:t})=>{let{loadShortcutConfig:n}=await i(async()=>{let{loadShortcutConfig:e}=await import(`./wc-shortcut-config-CI9MDlef.js`);return{loadShortcutConfig:e}},__vite__mapDeps([93,3,0,1,2,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38]));await n({reader:e,writer:t,apply:({keymap:e,trigger:t})=>{s.shortcuts.setKeymap(e),s.shortcuts.setTrigger(t)}})}).catch(e=>a.warn(`WC shortcut config load failed`,e))}),h().then(async({reader:e})=>{let{installPreviewVfsResponder:t}=await i(async()=>{let{installPreviewVfsResponder:e}=await import(`./preview-vfs-responder-Vn6wxJvK.js`);return{installPreviewVfsResponder:e}},[]);t({channel:new BroadcastChannel(`preview-vfs`),getReader:()=>e,logger:a})}).catch(e=>a.warn(`WC page-VFS support wiring failed`,e)),h().then(async({reader:n,writer:r})=>{let{createRemoteSprinkleVfs:c}=await i(async()=>{let{createRemoteSprinkleVfs:e}=await import(`./remote-sprinkle-vfs-UzNBy5VJ.js`);return{createRemoteSprinkleVfs:e}},__vite__mapDeps([94,36,95,96])),l=(await i(async()=>{let{getPanelizedShell:e}=await import(`./panelize-shell-BootSuaW.js`);return{getPanelizedShell:e}},__vite__mapDeps([90,3,0,1,2,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,91,92]))).getPanelizedShell(),{wireWcSprinkles:u}=await i(async()=>{let{wireWcSprinkles:e}=await import(`./wc-sprinkles-_UL-jsvL.js`);return{wireWcSprinkles:e}},__vite__mapDeps([97,2,0,1,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,98,72])),d=await u({refs:s,client:t,getUnits:()=>p.currentUnits(),getSelected:()=>e.getSelected(),selectScoop:t=>e.selectScoop(t),interceptWelcomeLick:e=>f.intercept?.(e)??!1,fs:c({reader:n,writer:r}),instanceId:o.instanceId,onAttachImage:Zf(_,a),onToolPanelActivate:e=>v.activate(e),onToolPanelDeactivate:e=>v.deactivate(e),hostSprinkleSurface:l?(e,t)=>l.hostSprinkleSurface(e,t):void 0,removeSprinkleSurface:l?e=>l.removeSprinkleSurface(e):void 0,log:a});e.onClientReady(()=>void d.resync());let{getPanelizedShell:y}=await i(async()=>{let{getPanelizedShell:e}=await import(`./panelize-shell-BootSuaW.js`);return{getPanelizedShell:e}},__vite__mapDeps([90,3,0,1,2,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,91,92])),b=y();if(b){let e=c({reader:n,writer:r});b.attachFs(e);let{registerAgentPanels:t}=await i(async()=>{let{registerAgentPanels:e}=await import(`./agent-panels-DhSzHTAV.js`);return{registerAgentPanels:e}},__vite__mapDeps([99,3,0,1,2,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38]));await t(e).catch(e=>a.warn(`agent panel discovery failed`,e))}else{let{setLayoutApplier:e}=await i(async()=>{let{setLayoutApplier:e}=await import(`./layout-apply-registry-Cw730jao.js`);return{setLayoutApplier:e}},[]),{applyLayout:t}=await i(async()=>{let{applyLayout:e}=await import(`./apply-layout-BRfsnfGb.js`);return{applyLayout:e}},__vite__mapDeps([100,97,2,0,1,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,98,72]));e(e=>t(d.zone,e))}if(o.standalone&&o.instanceId){let{wireWcTray:n}=await i(async()=>{let{wireWcTray:e}=await import(`./wc-tray-CxJ-2rTn.js`);return{wireWcTray:e}},__vite__mapDeps([101,8,1,9,10,11,2,12,13,14,15,16,3,17,18,5,19,20,21,22,23,24,25,26,27,28,0,4,6,7,29,30,31,32,33,34,35,36,37,38,74,102,103,104,57,46,45,105,44,81,68,88,89,53,106,72,107,108,109,51,52,54,96,82,60,76,110,111,112,98])),r=d.zone.callbacks(),c=await n({refs:s,client:t,browser:o.standalone.browser,realCdpTransport:o.standalone.realCdpTransport,instanceId:o.instanceId,runtimeMode:o.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&&cu(s,n,p.currentUnits(),e=>t.getScoop(e))},openFs:g,openWriter:async()=>(await h()).writer,window,log:a,kernelReadyDeadline:o.kernelReadyDeadline});e.wiring.notifyScoopStateChanged=()=>c.scheduleScoopsListBroadcast(),e.wiring.notifyUnitStatus=(e,t)=>c.broadcastUnitStatus(e,t===`processing`?`processing`:`ready`)}}).catch(e=>a.error(`WC sprinkle/tray wiring failed`,e));{let n=new or(new br),r=Ar(new sl({collection:{listScoops:()=>t.getScoops(),isProcessing:e=>t.isProcessing(e),getAgentMessages:()=>null,loadPersistedSessions:()=>n.loadAgentSessions(),loadUiChatSessions:()=>n.loadChatSessions(),wait:e=>new Promise(t=>setTimeout(t,e))},knownSecrets:El(),snapshotStore:{read:async e=>{let{reader:t}=await h();return yl(t,e)},write:async(e,t,n)=>{let{writer:r}=await h();return vl(r,e,t,n)}},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=Gn(Q(e.wiring).currentUnits());return{id:t?.id??`session-${Date.now()}`,title:t?.name??`Active Session`}},version:`6.238.8`}));window.addEventListener(`unload`,r,{once:!0})}let te=!1,re=()=>te?Promise.resolve():(te=!0,(async()=>{try{let[{getTranscriptExportService:e},{transcriptZipToBlob:t,downloadTranscriptBlob:n}]=await Promise.all([i(()=>Promise.resolve().then(()=>kr),void 0),i(()=>import(`./wc-transcript-export-fIvPUKqc.js`),__vite__mapDeps([113,2,102,107,108,1]))]),r=x(),a=r==null?{kind:`active`}:{kind:`frozen`,sessionId:r},o=await e().export(a,{}),{filename:s}=o;await n(await t(o),s)}catch(e){a.error(`Transcript export failed`,e),i(async()=>{let{showTranscriptExportFailure:e}=await import(`./wc-transcript-export-fIvPUKqc.js`);return{showTranscriptExportFailure:e}},__vite__mapDeps([113,2,102,107,108,1])).then(({showTranscriptExportFailure:t})=>t(e)).catch(e=>a.error(`Transcript export notice failed`,e))}finally{te=!1}})());if(i(async()=>{let{wireWcNav:e}=await import(`./wc-nav-BfgFifv9.js`);return{wireWcNav:e}},__vite__mapDeps([114,2,17,21,53,54,1,51,52,8,9,10,11,12,13,14,15,16,3,18,5,19,20,22,23,24,25,26,27,28,6,7,29,30,31,32,33,35,60,72,98])).then(({wireWcNav:e})=>e({refs:s,client:t,workUnits:p,getUnits:()=>p.currentUnits(),log:a,onExportTranscript:re,shortcuts:s.shortcuts,persistKeyboardTrigger:async e=>{let{writer:t,reader:n}=await h(),{writeShortcutTrigger:r}=await i(async()=>{let{writeShortcutTrigger:e}=await import(`./wc-shortcut-config-CI9MDlef.js`);return{writeShortcutTrigger:e}},__vite__mapDeps([93,3,0,1,2,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38]));await r({reader:n,writer:t},e)}})).catch(e=>a.error(`WC nav wiring failed`,e)),i(async()=>{let{getComposerSpeech:e,setComposerSpeechInstanceId:t}=await import(`./composer-speech-CJAwELHd.js`);return{getComposerSpeech:e,setComposerSpeechInstanceId:t}},__vite__mapDeps([115,3,0,1,2,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,57,66,67,68,116])).then(({getComposerSpeech:e,setComposerSpeechInstanceId:t})=>{let n=s.composer;t(o.instanceId),n.speech=e(),n.setAttribute(`ptt`,``)}).catch(e=>a.error(`WC push-to-talk wiring failed`,e)),i(async()=>{let{setSpeakAssetsInstanceId:e}=await import(`./speak-BusE622B.js`);return{setSpeakAssetsInstanceId:e}},__vite__mapDeps([65,2,3,21,66,67,0,1,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,68])).then(({setSpeakAssetsInstanceId:e})=>e(o.instanceId)).catch(e=>a.error(`WC say warmup wiring failed`,e)),o.standalone)return()=>{i(async()=>{let{schedulePendingSessionCatchup:e}=await import(`./new-session-DYPm3kHj.js`);return{schedulePendingSessionCatchup:e}},__vite__mapDeps([59,2,3,17,7,8,1,9,10,11,12,13,14,15,16,18,5,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,51,52,6,35,53,54,48])).then(({schedulePendingSessionCatchup:e})=>e({openVfs:async()=>(await h()).writer,onComplete:b})).catch(e=>a.warn(`Pending session catch-up scheduling failed`,e))}}function $f(e){let t=!1,n=()=>i(()=>import(`./boot-stall-overlay-Cs-FNlf8.js`),[]);return{onBootProgress:r=>{t=!0,n().then(t=>t.showBootStage(e,r))},onReadyStall:r=>{t=!0,n().then(t=>t.showBootStallOverlay(e,r))},dismiss:()=>{t&&n().then(t=>{t.removeBootStallOverlay(e),t.removeBootStage(e)})}}}async function ep(e,t,n=`standalone`){let{browser:r,realCdpTransport:a,instanceId:o,localApiBaseUrl:s,bridgeToken:c,localLickWsUrl:l,extensionDelegateId:u,attachLickForwardingClient:d}=await Ft({runtimeMode:n,envBaseUrl:null,window,log:t}),{floatKindForRuntimeMode:f,floatLabelForKind:p,resolveStandaloneFloatKind:m}=await i(async()=>{let{floatKindForRuntimeMode:e,floatLabelForKind:t,resolveStandaloneFloatKind:n}=await Promise.resolve().then(()=>cd);return{floatKindForRuntimeMode:e,floatLabelForKind:t,resolveStandaloneFloatKind:n}},void 0),h=n===`standalone`?await m():f(n),g=p(h);o&&Nt(o);let{syncFsBridgeEnabled:_,syncFsChannelNonce:v}=Ku(),y=$f(document),b,ee,{boot:x}=await _d(e,t,{floatKind:h,floatLabel:g,connect:e=>{b=ec({realCdpTransport:a,reconnectCdp:()=>r.reconnectIfNeeded(),instanceId:o,makeClient:t=>new Fs(Kl(e.wiring),t),localApiBaseUrl:s,bridgeToken:c,syncFsBridgeEnabled:_,syncFsChannelNonce:v,localLickWsUrl:l,extensionDelegateId:u,flagFloat:n,onWorkerScriptError:()=>{Pt()},onBootProgress:y.onBootProgress,onReadyStall:y.onReadyStall,onLateReady:()=>{Pt()}}),Hs({send:e=>b.client.sendRaw(e)}),d?.(b.client);let i=Ls(b.client);return{client:Q(e.wiring),host:i,workbench:(e,s)=>{ee=Qf(e,b.client,s,i,t,{instanceId:o,standalone:{browser:r,floatKind:h,realCdpTransport:a,runtimeMode:n},kernelReadyDeadline:{pause:()=>b.pauseReadyDeadline(),restart:()=>b.restartReadyDeadline()}})}}}});x.setRestoringSessions(!0);let{setupSudoStandalone:te}=await i(async()=>{let{setupSudoStandalone:e}=await import(`./main-Nm8Ln4q3.js`).then(e=>e.c);return{setupSudoStandalone:e}},__vite__mapDeps([51,1,52,8,9,10,11,2,12,13,14,15,16,3,17,18,5,19,20,21,22,23,24,25,26,27,28,6,7,29,30,31,32,33,35,53,54]));await te({log:t});try{await b.ready}finally{y.dismiss()}x.wiring.notifyReady?.(),x.setRestoringSessions(!1),globalThis.__slicc_kernel_ready=!0,t.info(`WC live shell ready`,{scoops:b.client.getScoops().length}),ee?.();let{consumeAutoPrompt:ne}=await i(async()=>{let{consumeAutoPrompt:e}=await import(`./auto-prompt-Mj-vUQeB.js`);return{consumeAutoPrompt:e}},[]),re=ne(window.location.search);re&&(x.getController()?.sendUserMessage(re),t.info(`Auto-prompt submitted`,{length:re.length}))}export{is as A,Li as B,Fs as C,ts as D,fs as E,so as F,or as G,Mr as H,Fo as I,oo as L,os as M,ls as N,cs as O,ds as P,es as R,Ls as S,ps as T,kr as U,Xr as V,br as W,Jl as _,qu as a,Q as b,Lu as c,Vu as d,fu as f,Yl as g,ql as h,Ju as i,ss as j,us as k,Nu as l,au as m,Af as n,Pu as o,du as p,_d as r,zu as s,Qf as t,Iu as u,Xl as v,bs as w,Bs as x,Kl as y,No as z};
|