@yuriai/web 0.2.25 → 0.2.27-beta.2
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 +21 -1
- package/dist/assets/AgentAvatar-BW4Zg8bo.js +1 -0
- package/dist/assets/AssistantView-Cl0ZeXwr.js +3 -0
- package/dist/assets/{DiagramView-DN_rHdr9.js → DiagramView-D6wdXRzu.js} +1 -1
- package/dist/assets/{FadeInOnReveal-555z1y1N.js → FadeInOnReveal-gOsILpSk.js} +1 -1
- package/dist/assets/{GuiPluginSurface-BPMATuPa.js → GuiPluginSurface-DOZAQKX0.js} +1 -1
- package/dist/assets/{GuiPluginWindow-CAmfr79x.js → GuiPluginWindow-tGvc4_0g.js} +1 -1
- package/dist/assets/Icon-DvUDsV1z.js +1 -0
- package/dist/assets/{ImageLoadingPlaceholder-BMsQLN_b.js → ImageLoadingPlaceholder-9xYbKqtf.js} +1 -1
- package/dist/assets/{LoadingImage-DI7sb_H_.js → LoadingImage-CiOcKPfb.js} +1 -1
- package/dist/assets/MarkdownRenderer-DZkP4UNr.js +2 -0
- package/dist/assets/{MarkdownRendererImpl-B9K5q0Lc.js → MarkdownRendererImpl-BXzPUEEo.js} +1 -1
- package/dist/assets/{MarkstreamRendererImpl-9gUEVQck.js → MarkstreamRendererImpl-B-NWd069.js} +1 -1
- package/dist/assets/MobileDetailNavigation-5U28hfYf.js +1 -0
- package/dist/assets/{MobileResizableSheet-_6OvPSMI.js → MobileResizableSheet-ZL-zPa3W.js} +1 -1
- package/dist/assets/{MobileShareBridge-BrdOiu_r.js → MobileShareBridge-JSH_Y8Ps.js} +3 -3
- package/dist/assets/MobileTabPageHeader-Bj9MIS38.js +2 -0
- package/dist/assets/MultiRunWindow-ZPz62Aqg.js +1 -0
- package/dist/assets/{OnboardingScreen-g8PDztN3.js → OnboardingScreen-BQNoy9o1.js} +1 -1
- package/dist/assets/{OverlayScrollbar-COv8rH_z.js → OverlayScrollbar-BwCFalSw.js} +1 -1
- package/dist/assets/SettingsView-B17qt8dh.js +29 -0
- package/dist/assets/SettingsWindow-CIFNHb-F.js +1 -0
- package/dist/assets/{TerminalView-BLer-ZhM.js → TerminalView-BZZ8LW4d.js} +1 -1
- package/dist/assets/{ToolOutputDialog-DI-s2TBb.js → ToolOutputDialog-BKuVpgEu.js} +2 -2
- package/dist/assets/{YuriLogo-BP4j1iqV.js → YuriLogo-C1Ty-RTB.js} +1 -1
- package/dist/assets/appThemeRegistry-DqGuzMaH.js +1 -0
- package/dist/assets/{assistant-attachment-cache-Cis9yYGt.js → assistant-attachment-cache-B9iHLlm2.js} +1 -1
- package/dist/assets/{button-Be1cqulG.js → button-DuHjvKJJ.js} +1 -1
- package/dist/assets/{capgoAdapter-B31jIkD8.js → capgoAdapter-B-tddboe.js} +1 -1
- package/dist/assets/collapsible-B8eL5nLo.js +1 -0
- package/dist/assets/{device-hj359GjJ.js → device-BjRYYXNT.js} +1 -1
- package/dist/assets/{diagram-hEIRiKol.js → diagram-ChoQDKzy.js} +1 -1
- package/dist/assets/dialog-CTYD3Sbr.css +1 -0
- package/dist/assets/dialog-CVhqZux0.js +1 -0
- package/dist/assets/{dropdown-menu.styles-xxM2ofOp.js → dropdown-menu.styles-DGvlOX_5.js} +1 -1
- package/dist/assets/{es-Clj7CS2r.js → es-B8sAsuo5.js} +3 -3
- package/dist/assets/{fileMentionTouchSelection-CTh0Mc2g.js → fileMentionTouchSelection-Dd-iSIe2.js} +2 -2
- package/dist/assets/{fileQueries-COS23nLq.js → fileQueries-5a1jkme2.js} +1 -1
- package/dist/assets/{fileReferenceActions-Cus9oSW7.js → fileReferenceActions-BAoEu4z8.js} +1 -1
- package/dist/assets/{fr-dmrFQLCO.js → fr-BPpW8T-l.js} +3 -3
- package/dist/assets/{gitApi-deADOzlN.js → gitApi-D43bAQh1.js} +1 -1
- package/dist/assets/{gitApiHttp-BBRKl9WX.js → gitApiHttp-DHrRqnYh.js} +3 -3
- package/dist/assets/{gui-BHEKelUx.js → gui-9enrif_1.js} +1 -1
- package/dist/assets/{host-DrqLUbqt.js → host-D1EpSUMR.js} +1 -1
- package/dist/assets/image-loading-Dq1g_wpm.js +1 -0
- package/dist/assets/{input-DTdHYZ6r.js → input-E_oYiXZT.js} +1 -1
- package/dist/assets/insertionBoundaries-BQjiZAmZ.js +1 -0
- package/dist/assets/{ja-Co0dxiN_.js → ja-DEoFDi7P.js} +3 -3
- package/dist/assets/{ko-BltElAGq.js → ko-B45xHN6I.js} +3 -3
- package/dist/assets/main-C6MDfyZy.js +2 -0
- package/dist/assets/main-u5iQScJs.js +169 -0
- package/dist/assets/{markdownHeightCache-DnR01ECa.js → markdownHeightCache-heNXHdzb.js} +1 -1
- package/dist/assets/{markdownTheme-DHoKvD6O.js → markdownTheme-hpURsgju.js} +1 -1
- package/dist/assets/{mcpQueries-Cpb22_60.js → mcpQueries-BqKVe4Su.js} +1 -1
- package/dist/assets/miniChat-Dhfn71Re.js +2 -0
- package/dist/assets/mobile-DSVdPfcG.js +2 -0
- package/dist/assets/{mobileBackNavigation-BibkyIeB.js → mobileBackNavigation-DHxFQ7SY.js} +1 -1
- package/dist/assets/{multirun-CPvUnP91.js → multirun-CPOzaEQj.js} +2 -2
- package/dist/assets/{native-BMAEg2E6.js → native-De1DIkLZ.js} +1 -1
- package/dist/assets/{native-config-DA8S8EqV.js → native-config-oauL2ekt.js} +1 -1
- package/dist/assets/{persistence-CBL0OOdj.js → persistence-JyLTFv27.js} +1 -1
- package/dist/assets/{pl-qd6Wnl7H.js → pl-Bm3Je_AX.js} +3 -3
- package/dist/assets/projectMeta-YDMdD3AP.js +1 -0
- package/dist/assets/{pt-BR-CsOFfQXS.js → pt-BR-BiQwFHhL.js} +3 -3
- package/dist/assets/{react-BYRXYlGz.js → react-CURmDhtB.js} +1 -1
- package/dist/assets/{readiness-RiznV1AX.js → readiness-BveVUOIb.js} +1 -1
- package/dist/assets/{renderElectronMiniChatApp-DdGqTh4X.js → renderElectronMiniChatApp-NC8iRPyy.js} +2 -2
- package/dist/assets/renderMobileApp-D5ai1i6y.js +28 -0
- package/dist/assets/{runtime-file-download-B_c7JBoS.js → runtime-file-download-CcNIVp7u.js} +1 -1
- package/dist/assets/{runtime-file-resource-DpTxBCsp.js → runtime-file-resource-6np6lzoV.js} +1 -1
- package/dist/assets/runtimeConfig-BpcgdIV9.js +2 -0
- package/dist/assets/runtimeEndpointReset-BL9hV6J1.css +1 -0
- package/dist/assets/runtimeEndpointReset-ByKa_0nu.js +149 -0
- package/dist/assets/scheduledTaskNavigation-CZfAnPD-.js +1 -0
- package/dist/assets/sessionChangeSummary-8C8nv-EP.css +1 -0
- package/dist/assets/sessionChangeSummary-D6NlE_5k.js +1 -0
- package/dist/assets/{sessionLookup-B7kUOIpO.js → sessionLookup-C70EoX-V.js} +1 -1
- package/dist/assets/{sortable-tabs-strip-CQZ16rbO.js → sortable-tabs-strip-aKussO2c.js} +1 -1
- package/dist/assets/speechSettingsQueries-B6qf-mCh.js +4 -0
- package/dist/assets/src-NKCZI3Lg.css +2 -0
- package/dist/assets/{store-7wItZZ7_.js → store-BeD2keas.js} +4 -4
- package/dist/assets/{terminalApi-C0_GUlPR.js → terminalApi-B5o8UqWA.js} +1 -1
- package/dist/assets/{textarea-BU8JtaSQ.js → textarea-DmKaqHSb.js} +1 -1
- package/dist/assets/{tooltip-C8DhNU1d.js → tooltip-DUKu4nC6.js} +1 -1
- package/dist/assets/{touch-gestures-zegXCZEP.js → touch-gestures-K2_ZOkKW.js} +1 -1
- package/dist/assets/types-DRTMRW4R.js +2 -0
- package/dist/assets/{uk-BNrdZFvK.js → uk-CYZXWdd7.js} +3 -3
- package/dist/assets/{useAppFontEffects-Bs6kVjrE.js → useAppFontEffects-BiQf6tgZ.js} +55 -51
- package/dist/assets/useAppFontEffects-RpgNbjA4.css +1 -0
- package/dist/assets/{useAssistantUIStore-NlYBroMc.js → useAssistantUIStore-C9FPlYQz.js} +1 -1
- package/dist/assets/{useDesktopWindowControlsLayout-COBTly74.js → useDesktopWindowControlsLayout-DJxNmCWb.js} +1 -1
- package/dist/assets/useEffectiveDirectory-B8q00InF.js +1 -0
- package/dist/assets/{useFontPreferences-DQAS94Z4.js → useFontPreferences-DMiP_Yy-.js} +1 -1
- package/dist/assets/useMobileNavigationStore-Bn4SaalY.js +418 -0
- package/dist/assets/{useThemeSystem-8jhE4Zyk.js → useThemeSystem-CGF5jnIh.js} +1 -1
- package/dist/assets/{useUIStore-96W41KFb.js → useUIStore-DI7va1HH.js} +1 -1
- package/dist/assets/{useWorkerHighlightedLines-BZUO0Si5.js → useWorkerHighlightedLines-B6lWNk01.js} +1 -1
- package/dist/assets/{vendor-base-ui-CdzJ6My_.js → vendor-base-ui-BQjbsJ43.js} +1 -1
- package/dist/assets/{vendor-cmdk-RDxC-9Iz.js → vendor-cmdk-C3oBVL9X.js} +1 -1
- package/dist/assets/{vendor-dnd-kit-accessibility-COSwgjFs.js → vendor-dnd-kit-accessibility-DxpFzZhi.js} +1 -1
- package/dist/assets/{vendor-dnd-kit-core-5pNnzVdw.js → vendor-dnd-kit-core-B3g3zWQd.js} +1 -1
- package/dist/assets/{vendor-dnd-kit-sortable-Dm50I0m7.js → vendor-dnd-kit-sortable-BKewx0Py.js} +1 -1
- package/dist/assets/{vendor-framer-motion-BQ3-sJMO.js → vendor-framer-motion-C1twy-GF.js} +1 -1
- package/dist/assets/{vendor-markstream-react-Bm0cO70Z.js → vendor-markstream-react-BlbOg72y.js} +3 -3
- package/dist/assets/vendor-motion-BmLx2V78.js +1 -0
- package/dist/assets/{vendor-opencode-client-fxfj4IA_.js → vendor-opencode-client-UL_TecvQ.js} +1 -1
- package/dist/assets/{vendor-opencode-plugin-CQ5ogY33.js → vendor-opencode-plugin-Bw7Q6Nv9.js} +1 -1
- package/dist/assets/{vendor-pierre-diffs-DPBtNDJ5.js → vendor-pierre-diffs-Bj9Nqn6w.js} +1 -1
- package/dist/assets/{vendor-react-BP2cRVqX.js → vendor-react-D5d-V1vN.js} +1 -1
- package/dist/assets/{vendor-react-drawio-Ck9ZKdNN.js → vendor-react-drawio-C-iPmmED.js} +1 -1
- package/dist/assets/{vendor-reactuses-core-BJ-jJ4YM.js → vendor-reactuses-core-BcebBLwF.js} +1 -1
- package/dist/assets/{vendor-solid-js-Dmt4_-Zk.js → vendor-solid-js-0T254UHG.js} +1 -1
- package/dist/assets/{vendor-sonner-ZS8XIOVl.js → vendor-sonner-r2EJnfoo.js} +1 -1
- package/dist/assets/{vendor-stream-diffs-TgIdH4lX.js → vendor-stream-diffs-BnLmeqg2.js} +2 -2
- package/dist/assets/{vendor-tanstack-react-query-CdqCAt40.js → vendor-tanstack-react-query-C4SG3JZB.js} +1 -1
- package/dist/assets/vendor-tanstack-react-virtual-BeZn51tF.js +1 -0
- package/dist/assets/{vendor-zustand-o69pgTEK.js → vendor-zustand-B43HCgwC.js} +1 -1
- package/dist/assets/{zh-CN-DMvJXS23.js → zh-CN-CMLBHipA.js} +3 -3
- package/dist/assets/{zh-TW-D0wsKLs1.js → zh-TW-CJlmnnhK.js} +3 -3
- package/dist/index.html +18 -18
- package/dist/mini-chat.html +18 -18
- package/dist/mobile.html +18 -18
- package/package.json +1 -1
- package/server/lib/assistants/DOCUMENTATION.md +58 -37
- package/server/lib/assistants/cards.js +4 -0
- package/server/lib/assistants/cards.test.js +11 -1
- package/server/lib/assistants/contact-attachments.http.test.js +31 -7
- package/server/lib/assistants/contact-store.js +54 -27
- package/server/lib/assistants/contact-store.test.js +69 -8
- package/server/lib/assistants/contact-tools.js +68 -84
- package/server/lib/assistants/contact-tools.test.js +85 -42
- package/server/lib/assistants/harness.js +6 -3
- package/server/lib/assistants/harness.test.js +25 -10
- package/server/lib/assistants/service.js +276 -145
- package/server/lib/assistants/service.test.js +954 -54
- package/server/lib/assistants/yuri-project.http.test.js +47 -0
- package/server/lib/assistants/yuri-tools.js +1 -1
- package/server/lib/assistants/yuri-tools.test.js +3 -2
- package/server/lib/git/DOCUMENTATION.md +6 -0
- package/server/lib/git/branches.test.js +18 -0
- package/server/lib/git/service.js +6 -3
- package/server/lib/llm/DOCUMENTATION.md +15 -7
- package/server/lib/llm/bridge-client.js +58 -34
- package/server/lib/llm/bridge-client.test.js +123 -16
- package/server/lib/notifications/APNS.md +7 -4
- package/server/lib/notifications/DOCUMENTATION.md +3 -1
- package/server/lib/notifications/apns-runtime.js +14 -8
- package/server/lib/notifications/apns-runtime.test.js +28 -0
- package/server/lib/notifications/family-completion-gate.js +37 -31
- package/server/lib/notifications/family-completion-gate.test.js +32 -0
- package/server/lib/opencode/DOCUMENTATION.md +6 -0
- package/server/lib/opencode/hmr-isolation.test.js +56 -0
- package/server/lib/opencode/lifecycle.js +23 -27
- package/server/lib/opencode/network-runtime.js +8 -14
- package/server/lib/opencode/network-runtime.test.js +4 -4
- package/server/lib/opencode/proxy.js +2 -1
- package/server/lib/opencode/proxy.test.js +1 -0
- package/server/lib/relay/DOCUMENTATION.md +8 -1
- package/server/lib/relay/relay-server.e2e.test.ts +102 -1
- package/server/lib/relay/service.js +1 -1
- package/server/lib/relay/service.test.js +14 -1
- package/server/lib/request-cors.js +1 -1
- package/server/lib/request-cors.test.js +13 -1
- package/server/lib/session-goal/DOCUMENTATION.md +3 -0
- package/server/lib/session-goal/runtime.js +0 -4
- package/server/lib/session-index/DOCUMENTATION.md +18 -4
- package/server/lib/session-index/event-ingest.js +6 -0
- package/server/lib/session-index/event-ingest.test.js +10 -0
- package/server/lib/session-index/service.js +89 -13
- package/server/lib/session-index/service.test.js +144 -1
- package/server/lib/session-metadata/routes.test.js +44 -0
- package/server/lib/tts/DOCUMENTATION.md +24 -2
- package/server/lib/tts/direct-speech.test.js +28 -3
- package/server/opencode-proxy.test.js +5 -5
- package/dist/assets/AgentAvatar--wjVXk3I.js +0 -1
- package/dist/assets/AssistantView-CSpW-4g6.js +0 -3
- package/dist/assets/Icon-Bn4Eec3Y.js +0 -1
- package/dist/assets/MarkdownRenderer-DP2a0lfG.js +0 -2
- package/dist/assets/MobileDetailNavigation-C9NHt08G.js +0 -1
- package/dist/assets/MobileTabPageHeader-qe23xT2-.js +0 -2
- package/dist/assets/MultiRunWindow-CvHADKf9.js +0 -1
- package/dist/assets/SettingsView-DK8Jkkhd.js +0 -29
- package/dist/assets/SettingsWindow-EP8KZok8.js +0 -1
- package/dist/assets/appThemeRegistry-BnQF2GlY.js +0 -1
- package/dist/assets/collapsible-DqfguRMp.js +0 -1
- package/dist/assets/dialog-BS-KgM5J.js +0 -1
- package/dist/assets/image-loading-DJZLvhMd.js +0 -1
- package/dist/assets/insertionBoundaries-h2be7xbf.js +0 -1
- package/dist/assets/main-BpBrYqtJ.js +0 -169
- package/dist/assets/main-C2QklNP4.js +0 -2
- package/dist/assets/miniChat-C-9deNrt.js +0 -2
- package/dist/assets/mobile-DW7tEL-k.js +0 -2
- package/dist/assets/projectMeta-BwAS96mf.js +0 -1
- package/dist/assets/renderMobileApp-Bipi0hKv.js +0 -28
- package/dist/assets/runtimeConfig-Dx7Y6Yvp.js +0 -2
- package/dist/assets/runtimeEndpointReset-0buInzjw.js +0 -149
- package/dist/assets/runtimeEndpointReset-HYSytKO-.css +0 -1
- package/dist/assets/scheduledTaskNavigation-CYozx15H.js +0 -1
- package/dist/assets/sessionChangeSummary-BGisROOB.js +0 -1
- package/dist/assets/sessionChangeSummary-CRYRvpy7.css +0 -1
- package/dist/assets/speechSettingsQueries-CWXTghOr.js +0 -4
- package/dist/assets/src-BFsc_2gs.css +0 -2
- package/dist/assets/types-C9aO7yfx.js +0 -2
- package/dist/assets/useEffectiveDirectory-Bg0LmEqP.js +0 -1
- package/dist/assets/useMobileNavigationStore-hhiMBg5n.js +0 -418
- package/dist/assets/vendor-motion-B4xmxmaP.js +0 -1
- package/dist/assets/vendor-tanstack-react-virtual-B_EO--9t.js +0 -1
package/dist/assets/{vendor-opencode-client-fxfj4IA_.js → vendor-opencode-client-UL_TecvQ.js}
RENAMED
|
@@ -9,4 +9,4 @@ import{n as e}from"./rolldown-runtime-hePW80VL.js";import{$ as t,$t as n,A as r,
|
|
|
9
9
|
`).flatMap(e=>e.startsWith(`data:`)?[e.slice(5).trimStart()]:[]).join(`
|
|
10
10
|
`);if(t!==``)try{yield JSON.parse(t)}catch(e){throw new Vt(`MalformedResponse`,{cause:e})}r=s.indexOf(`
|
|
11
11
|
|
|
12
|
-
`)}if(e.done)return}}finally{try{await a.cancel()}catch{}a.releaseLock()}}});return{server:{info:e=>a({method:`GET`,path:`/api/info`,successStatus:200,declaredStatuses:[400,401],empty:!1},e),pair:e=>a({method:`POST`,path:`/api/pair`,successStatus:200,declaredStatuses:[400,401],empty:!1},e),connect:(e,t)=>a({method:`GET`,path:`/auth/connect/${encodeURIComponent(e.code)}`,successStatus:200,declaredStatuses:[400,401],empty:!1},t)},location:{get:(e,t)=>a({method:`GET`,path:`/api/location`,query:{location:e?.location},successStatus:200,declaredStatuses:[400,401,404],empty:!1},t),reload:e=>a({method:`POST`,path:`/api/location/reload`,successStatus:204,declaredStatuses:[400,401,503],empty:!0},e)},agent:{list:(e,t)=>a({method:`GET`,path:`/api/agent`,query:{location:e?.location},successStatus:200,declaredStatuses:[400,401,404,503],empty:!1},t),get:(e,t)=>a({method:`GET`,path:`/api/agent/${encodeURIComponent(e.agentID)}`,query:{location:e.location},successStatus:200,declaredStatuses:[400,401,404],empty:!1},t)},plugin:{list:(e,t)=>a({method:`GET`,path:`/api/plugin`,query:{location:e?.location},successStatus:200,declaredStatuses:[400,401,404],empty:!1},t),gui:(e,t)=>a({method:`GET`,path:`/api/plugin/gui`,query:{location:e.location,id:e.id},successStatus:200,declaredStatuses:[400,401,404],empty:!1},t),check:(e,t)=>a({method:`POST`,path:`/api/plugin/check`,query:{location:e?.location},body:{target:e?.target},successStatus:200,declaredStatuses:[400,401,404],empty:!1},t),update:(e,t)=>a({method:`POST`,path:`/api/plugin/update`,query:{location:e.location},body:{targets:e.targets},successStatus:204,declaredStatuses:[400,401,404,503],empty:!0},t)},session:{list:(e,t)=>a({method:`GET`,path:`/api/session`,query:{limit:e?.limit,order:e?.order,search:e?.search,parentID:e?.parentID,archived:e?.archived,directory:e?.directory,project:e?.project,subpath:e?.subpath,cursor:e?.cursor},successStatus:200,declaredStatuses:[400,401],empty:!1},t),stats:(e,t)=>a({method:`GET`,path:`/api/experimental/session/stats`,query:{from:e?.from,to:e?.to,project:e?.project,timezone:e?.timezone,tools:e?.tools},successStatus:200,declaredStatuses:[400,401],empty:!1},t).then(e=>e.data),create:(e,t)=>a({method:`POST`,path:`/api/session`,body:{id:e?.id,parentID:e?.parentID,title:e?.title,agent:e?.agent,model:e?.model,location:e?.location,metadata:e?.metadata,permissions:e?.permissions},successStatus:200,declaredStatuses:[400,401,404],empty:!1},t).then(e=>e.data),import:(e,t)=>a({method:`POST`,path:`/api/experimental/session/import`,body:{info:e.info,messages:e.messages,location:e.location},successStatus:200,declaredStatuses:[400,401,404,409],empty:!1},t).then(e=>e.data),export:(e,t)=>a({method:`GET`,path:`/api/experimental/session/${encodeURIComponent(e.sessionID)}/export`,query:{sanitize:e.sanitize},successStatus:200,declaredStatuses:[400,401,404,500],empty:!1},t).then(e=>e.data),active:e=>a({method:`GET`,path:`/api/session/active`,successStatus:200,declaredStatuses:[400,401],empty:!1},e).then(e=>e.data),get:(e,t)=>a({method:`GET`,path:`/api/session/${encodeURIComponent(e.sessionID)}`,successStatus:200,declaredStatuses:[400,401,404],empty:!1},t).then(e=>e.data),remove:(e,t)=>a({method:`DELETE`,path:`/api/session/${encodeURIComponent(e.sessionID)}`,successStatus:204,declaredStatuses:[400,401,404],empty:!0},t),fork:(e,t)=>a({method:`POST`,path:`/api/session/${encodeURIComponent(e.sessionID)}/fork`,body:{before:e.before},successStatus:200,declaredStatuses:[400,401,404],empty:!1},t).then(e=>e.data),switchAgent:(e,t)=>a({method:`POST`,path:`/api/session/${encodeURIComponent(e.sessionID)}/agent`,body:{agent:e.agent},successStatus:204,declaredStatuses:[400,401,404],empty:!0},t),switchModel:(e,t)=>a({method:`POST`,path:`/api/session/${encodeURIComponent(e.sessionID)}/model`,body:{model:e.model},successStatus:204,declaredStatuses:[400,401,404],empty:!0},t),update:(e,t)=>a({method:`PATCH`,path:`/api/session/${encodeURIComponent(e.sessionID)}`,body:{title:e.title,metadata:e.metadata,permissions:e.permissions,archived:e.archived},successStatus:204,declaredStatuses:[400,401,404],empty:!0},t),move:(e,t)=>a({method:`POST`,path:`/api/session/${encodeURIComponent(e.sessionID)}/move`,body:{directory:e.directory,delivery:e.delivery},successStatus:204,declaredStatuses:[400,401,404],empty:!0},t),prompt:(e,t)=>a({method:`POST`,path:`/api/session/${encodeURIComponent(e.sessionID)}/prompt`,body:{id:e.id,text:e.text,files:e.files,agents:e.agents,skills:e.skills,metadata:e.metadata,delivery:e.delivery,resume:e.resume},successStatus:200,declaredStatuses:[400,401,404,409],empty:!1},t).then(e=>e.data),command:(e,t)=>a({method:`POST`,path:`/api/session/${encodeURIComponent(e.sessionID)}/command`,body:{name:e.name,text:e.text,files:e.files,agents:e.agents,skills:e.skills,delivery:e.delivery},successStatus:204,declaredStatuses:[400,401,404,500],empty:!0},t),skill:(e,t)=>a({method:`POST`,path:`/api/experimental/session/${encodeURIComponent(e.sessionID)}/skill`,body:{id:e.id,resume:e.resume},successStatus:204,declaredStatuses:[400,401,404],empty:!0},t),synthetic:(e,t)=>a({method:`POST`,path:`/api/session/${encodeURIComponent(e.sessionID)}/synthetic`,body:{id:e.id,text:e.text,description:e.description,metadata:e.metadata,delivery:e.delivery,resume:e.resume},successStatus:200,declaredStatuses:[400,401,404,409],empty:!1},t).then(e=>e.data),shell:(e,t)=>a({method:`POST`,path:`/api/session/${encodeURIComponent(e.sessionID)}/shell`,body:{id:e.id,command:e.command},successStatus:204,declaredStatuses:[400,401,404],empty:!0},t),compact:(e,t)=>a({method:`POST`,path:`/api/session/${encodeURIComponent(e.sessionID)}/compact`,body:{id:e.id,delivery:e.delivery},successStatus:200,declaredStatuses:[400,401,404,409],empty:!1},t).then(e=>e.data),wait:(e,t)=>a({method:`POST`,path:`/api/experimental/session/${encodeURIComponent(e.sessionID)}/wait`,successStatus:204,declaredStatuses:[400,401,404,503],empty:!0},t),revert:{stage:(e,t)=>a({method:`POST`,path:`/api/session/${encodeURIComponent(e.sessionID)}/revert/stage`,body:{messageID:e.messageID,files:e.files},successStatus:200,declaredStatuses:[400,401,404,409,500],empty:!1},t).then(e=>e.data),clear:(e,t)=>a({method:`DELETE`,path:`/api/session/${encodeURIComponent(e.sessionID)}/revert`,successStatus:204,declaredStatuses:[400,401,404,409,500],empty:!0},t),commit:(e,t)=>a({method:`POST`,path:`/api/session/${encodeURIComponent(e.sessionID)}/revert/commit`,successStatus:204,declaredStatuses:[400,401,404,409],empty:!0},t)},context:(e,t)=>a({method:`GET`,path:`/api/session/${encodeURIComponent(e.sessionID)}/context`,successStatus:200,declaredStatuses:[400,401,404,500],empty:!1},t).then(e=>e.data),diff:(e,t)=>a({method:`GET`,path:`/api/session/${encodeURIComponent(e.sessionID)}/diff`,query:{from:e.from,to:e.to,context:e.context},successStatus:200,declaredStatuses:[400,401,404,500],empty:!1},t).then(e=>e.data),inbox:{list:(e,t)=>a({method:`GET`,path:`/api/session/${encodeURIComponent(e.sessionID)}/inbox`,successStatus:200,declaredStatuses:[400,401,404],empty:!1},t).then(e=>e.data),cancel:(e,t)=>a({method:`DELETE`,path:`/api/session/${encodeURIComponent(e.sessionID)}/inbox/${encodeURIComponent(e.inboxID)}`,successStatus:204,declaredStatuses:[400,401,404],empty:!0},t),update:(e,t)=>a({method:`PATCH`,path:`/api/session/${encodeURIComponent(e.sessionID)}/inbox/${encodeURIComponent(e.inboxID)}`,body:{delivery:e.delivery},successStatus:204,declaredStatuses:[400,401,404,409],empty:!0},t)},instructions:{entry:{list:(e,t)=>a({method:`GET`,path:`/api/experimental/session/${encodeURIComponent(e.sessionID)}/instructions/entries`,successStatus:200,declaredStatuses:[400,401,404],empty:!1},t).then(e=>e.data),put:(e,t)=>a({method:`PUT`,path:`/api/experimental/session/${encodeURIComponent(e.sessionID)}/instructions/entries/${encodeURIComponent(e.key)}`,body:{value:e.value},successStatus:204,declaredStatuses:[400,401,404,413],empty:!0},t),remove:(e,t)=>a({method:`DELETE`,path:`/api/experimental/session/${encodeURIComponent(e.sessionID)}/instructions/entries/${encodeURIComponent(e.key)}`,successStatus:204,declaredStatuses:[400,401,404],empty:!0},t)}},generate:(e,t)=>a({method:`POST`,path:`/api/session/${encodeURIComponent(e.sessionID)}/generate`,body:{prompt:e.prompt},successStatus:200,declaredStatuses:[400,401,404,503],empty:!1},t).then(e=>e.data),log:(e,t)=>o({method:`GET`,path:`/api/experimental/session/${encodeURIComponent(e.sessionID)}/log`,query:{after:e.after,follow:e.follow},successStatus:200,declaredStatuses:[400,401,404],empty:!1},t),interrupt:(e,t)=>a({method:`POST`,path:`/api/session/${encodeURIComponent(e.sessionID)}/interrupt`,query:{resume:e.resume},successStatus:200,declaredStatuses:[400,401,404],empty:!1},t),background:(e,t)=>a({method:`POST`,path:`/api/session/${encodeURIComponent(e.sessionID)}/background`,successStatus:204,declaredStatuses:[400,401,404],empty:!0},t),message:{get:(e,t)=>a({method:`GET`,path:`/api/session/${encodeURIComponent(e.sessionID)}/message/${encodeURIComponent(e.messageID)}`,successStatus:200,declaredStatuses:[400,401,404],empty:!1},t).then(e=>e.data)},form:{list:(e,t)=>a({method:`GET`,path:`/api/session/${encodeURIComponent(e.sessionID)}/form`,successStatus:200,declaredStatuses:[400,401,404],empty:!1},t).then(e=>e.data),create:(e,t)=>a({method:`POST`,path:`/api/session/${encodeURIComponent(e.sessionID)}/form`,body:{id:e.id,title:e.title,metadata:e.metadata,fields:e.fields},successStatus:200,declaredStatuses:[400,401,404,409],empty:!1},t).then(e=>e.data),get:(e,t)=>a({method:`GET`,path:`/api/session/${encodeURIComponent(e.sessionID)}/form/${encodeURIComponent(e.formID)}`,successStatus:200,declaredStatuses:[400,401,404],empty:!1},t).then(e=>e.data),reply:(e,t)=>a({method:`POST`,path:`/api/session/${encodeURIComponent(e.sessionID)}/form/${encodeURIComponent(e.formID)}/reply`,body:{answer:e.answer},successStatus:204,declaredStatuses:[400,401,404,409],empty:!0},t),cancel:(e,t)=>a({method:`DELETE`,path:`/api/session/${encodeURIComponent(e.sessionID)}/form/${encodeURIComponent(e.formID)}`,query:{message:e.message},successStatus:204,declaredStatuses:[400,401,404,409],empty:!0},t)},environment:(e,t)=>a({method:`PUT`,path:`/api/session/${encodeURIComponent(e.sessionID)}/environment`,body:{variables:e.variables},successStatus:204,declaredStatuses:[400,401,404],empty:!0},t),view:(e,t)=>a({method:`POST`,path:`/api/session/${encodeURIComponent(e.sessionID)}/view`,body:{idle:e.idle},successStatus:204,declaredStatuses:[400,401,404],empty:!0},t)},message:{list:(e,t)=>a({method:`GET`,path:`/api/session/${encodeURIComponent(e.sessionID)}/message`,query:{limit:e.limit,order:e.order,cursor:e.cursor,type:e.type},successStatus:200,declaredStatuses:[400,401,404,500],empty:!1},t)},model:{list:(e,t)=>a({method:`GET`,path:`/api/model`,query:{location:e?.location,types:e?.types},successStatus:200,declaredStatuses:[400,401,404,503],empty:!1},t),default:(e,t)=>a({method:`GET`,path:`/api/model/default`,query:{location:e?.location},successStatus:200,declaredStatuses:[400,401,404,503],empty:!1},t)},generate:{text:(e,t)=>a({method:`POST`,path:`/api/experimental/generate/text`,body:{prompt:e.prompt,model:e.model},successStatus:200,declaredStatuses:[400,401,404,422,502,503],empty:!1},t).then(e=>e.data),image:(e,t)=>a({method:`POST`,path:`/api/experimental/generate/image`,body:{model:e.model,prompt:e.prompt,images:e.images,n:e.n,aspect:e.aspect,resolution:e.resolution},successStatus:200,declaredStatuses:[400,401,404,422,502,503],empty:!1},t).then(e=>e.data),decisions:(e,t)=>a({method:`POST`,path:`/api/experimental/generate/decisions`,body:{model:e.model,input:e.input,questions:e.questions},successStatus:200,declaredStatuses:[400,401,404,422,502,503],empty:!1},t).then(e=>e.data)},voice:{models:e=>a({method:`GET`,path:`/api/experimental/voice/models`,successStatus:200,declaredStatuses:[400,401,404,503],empty:!1},e).then(e=>e.data),session:(e,t)=>a({method:`POST`,path:`/api/experimental/voice/session`,body:{model:e.model,session:e.session,transport:e.transport},successStatus:200,declaredStatuses:[400,401,404,503],empty:!1},t).then(e=>e.data)},provider:{list:(e,t)=>a({method:`GET`,path:`/api/provider`,query:{location:e?.location},successStatus:200,declaredStatuses:[400,401,404,503],empty:!1},t),get:(e,t)=>a({method:`GET`,path:`/api/provider/${encodeURIComponent(e.providerID)}`,query:{location:e.location},successStatus:200,declaredStatuses:[400,401,404,503],empty:!1},t)},integration:{list:(e,t)=>a({method:`GET`,path:`/api/integration`,query:{location:e?.location},successStatus:200,declaredStatuses:[400,401,404],empty:!1},t),get:(e,t)=>a({method:`GET`,path:`/api/integration/${encodeURIComponent(e.integrationID)}`,query:{location:e.location},successStatus:200,declaredStatuses:[400,401,404],empty:!1},t),wellknown:{add:(e,t)=>a({method:`POST`,path:`/api/experimental/integration/wellknown`,query:{location:e.location},body:{url:e.url},successStatus:204,declaredStatuses:[400,401,404],empty:!0},t)},connect:{key:(e,t)=>a({method:`POST`,path:`/api/integration/${encodeURIComponent(e.integrationID)}/connect/key`,query:{location:e.location},body:{key:e.key,answer:e.answer,label:e.label},successStatus:204,declaredStatuses:[400,401,404],empty:!0},t),external:(e,t)=>a({method:`POST`,path:`/api/integration/${encodeURIComponent(e.integrationID)}/connect/external`,query:{location:e.location},body:{methodID:e.methodID,answer:e.answer,label:e.label},successStatus:204,declaredStatuses:[400,401,404],empty:!0},t)},oauth:{connect:(e,t)=>a({method:`POST`,path:`/api/integration/${encodeURIComponent(e.integrationID)}/connect/oauth`,query:{location:e.location},body:{methodID:e.methodID,answer:e.answer,label:e.label},successStatus:200,declaredStatuses:[400,401,404],empty:!1},t),status:(e,t)=>a({method:`GET`,path:`/api/integration/${encodeURIComponent(e.integrationID)}/connect/oauth/${encodeURIComponent(e.attemptID)}`,query:{location:e.location},successStatus:200,declaredStatuses:[400,401,404],empty:!1},t),complete:(e,t)=>a({method:`POST`,path:`/api/integration/${encodeURIComponent(e.integrationID)}/connect/oauth/${encodeURIComponent(e.attemptID)}/complete`,query:{location:e.location},body:{code:e.code},successStatus:204,declaredStatuses:[400,401,404],empty:!0},t),cancel:(e,t)=>a({method:`DELETE`,path:`/api/integration/${encodeURIComponent(e.integrationID)}/connect/oauth/${encodeURIComponent(e.attemptID)}`,query:{location:e.location},successStatus:204,declaredStatuses:[400,401,404],empty:!0},t)},command:{connect:(e,t)=>a({method:`POST`,path:`/api/integration/${encodeURIComponent(e.integrationID)}/connect/command`,query:{location:e.location},body:{methodID:e.methodID,label:e.label},successStatus:200,declaredStatuses:[400,401,404],empty:!1},t),status:(e,t)=>a({method:`GET`,path:`/api/integration/${encodeURIComponent(e.integrationID)}/connect/command/${encodeURIComponent(e.attemptID)}`,query:{location:e.location},successStatus:200,declaredStatuses:[400,401,404],empty:!1},t),cancel:(e,t)=>a({method:`DELETE`,path:`/api/integration/${encodeURIComponent(e.integrationID)}/connect/command/${encodeURIComponent(e.attemptID)}`,query:{location:e.location},successStatus:204,declaredStatuses:[400,401,404],empty:!0},t)}},mcp:{list:(e,t)=>a({method:`GET`,path:`/api/mcp`,query:{location:e?.location},successStatus:200,declaredStatuses:[400,401,404],empty:!1},t),add:(e,t)=>a({method:`PUT`,path:`/api/experimental/mcp/${encodeURIComponent(e.server)}`,query:{location:e.location},body:{config:e.config},successStatus:204,declaredStatuses:[400,401,404],empty:!0},t),remove:(e,t)=>a({method:`DELETE`,path:`/api/experimental/mcp/${encodeURIComponent(e.server)}`,query:{location:e.location},successStatus:204,declaredStatuses:[400,401,404],empty:!0},t),connect:(e,t)=>a({method:`POST`,path:`/api/experimental/mcp/${encodeURIComponent(e.server)}/connect`,query:{location:e.location},successStatus:204,declaredStatuses:[400,401,404],empty:!0},t),disconnect:(e,t)=>a({method:`POST`,path:`/api/experimental/mcp/${encodeURIComponent(e.server)}/disconnect`,query:{location:e.location},successStatus:204,declaredStatuses:[400,401,404],empty:!0},t),resource:{catalog:(e,t)=>a({method:`GET`,path:`/api/mcp/resource`,query:{location:e?.location},successStatus:200,declaredStatuses:[400,401,404],empty:!1},t)},client:{token:(e,t)=>a({method:`POST`,path:`/api/experimental/client-mcp/token`,query:{location:e.location,name:e.name},headers:{"x-opencode-ticket":e[`x-opencode-ticket`]},successStatus:200,declaredStatuses:[400,401,403,404],empty:!1},t)}},credential:{list:e=>a({method:`GET`,path:`/api/credential`,successStatus:200,declaredStatuses:[400,401],empty:!1},e).then(e=>e.data),create:(e,t)=>a({method:`POST`,path:`/api/credential`,body:{id:e.id,integrationID:e.integrationID,label:e.label,value:e.value,activate:e.activate},successStatus:200,declaredStatuses:[400,401,409],empty:!1},t).then(e=>e.data),update:(e,t)=>a({method:`PATCH`,path:`/api/credential/${encodeURIComponent(e.credentialID)}`,body:{label:e.label},successStatus:204,declaredStatuses:[400,401],empty:!0},t),activate:(e,t)=>a({method:`POST`,path:`/api/credential/${encodeURIComponent(e.credentialID)}/activate`,successStatus:204,declaredStatuses:[400,401],empty:!0},t),remove:(e,t)=>a({method:`DELETE`,path:`/api/credential/${encodeURIComponent(e.credentialID)}`,successStatus:204,declaredStatuses:[400,401],empty:!0},t)},project:{list:(e,t)=>a({method:`GET`,path:`/api/project`,query:{archived:e?.archived},successStatus:200,declaredStatuses:[400,401],empty:!1},t),update:(e,t)=>a({method:`PATCH`,path:`/api/project/${encodeURIComponent(e.projectID)}`,body:{canonical:e.canonical,name:e.name,icon:e.icon,commands:e.commands},successStatus:200,declaredStatuses:[400,401,404],empty:!1},t)},form:{list:(e,t)=>a({method:`GET`,path:`/api/form`,query:{location:e?.location},successStatus:200,declaredStatuses:[400,401,404],empty:!1},t)},permission:{request:{list:(e,t)=>a({method:`GET`,path:`/api/permission/request`,query:{location:e?.location},successStatus:200,declaredStatuses:[400,401,404],empty:!1},t)},saved:{list:(e,t)=>a({method:`GET`,path:`/api/permission/saved`,query:{projectID:e?.projectID},successStatus:200,declaredStatuses:[400,401,404],empty:!1},t).then(e=>e.data),update:(e,t)=>a({method:`PATCH`,path:`/api/permission/saved/${encodeURIComponent(e.id)}`,body:{action:e.action,resource:e.resource},successStatus:200,declaredStatuses:[400,401,404,409],empty:!1},t).then(e=>e.data),remove:(e,t)=>a({method:`DELETE`,path:`/api/permission/saved/${encodeURIComponent(e.id)}`,successStatus:204,declaredStatuses:[400,401],empty:!0},t)},create:(e,t)=>a({method:`POST`,path:`/api/session/${encodeURIComponent(e.sessionID)}/permission`,body:{id:e.id,action:e.action,resources:e.resources,save:e.save,metadata:e.metadata,source:e.source,agent:e.agent},successStatus:200,declaredStatuses:[400,401,404],empty:!1},t).then(e=>e.data),list:(e,t)=>a({method:`GET`,path:`/api/session/${encodeURIComponent(e.sessionID)}/permission`,successStatus:200,declaredStatuses:[400,401,404],empty:!1},t).then(e=>e.data),get:(e,t)=>a({method:`GET`,path:`/api/session/${encodeURIComponent(e.sessionID)}/permission/${encodeURIComponent(e.requestID)}`,successStatus:200,declaredStatuses:[400,401,404],empty:!1},t).then(e=>e.data),reply:(e,t)=>a({method:`POST`,path:`/api/session/${encodeURIComponent(e.sessionID)}/permission/${encodeURIComponent(e.requestID)}/reply`,body:{decision:e.decision,message:e.message},successStatus:204,declaredStatuses:[400,401,404],empty:!0},t)},file:{read:(e,t)=>a({method:`GET`,path:`/api/fs/read/${Wt(e.path)}`,query:{location:e.location},successStatus:200,declaredStatuses:[400,401,404],empty:!1,binary:!0},t),list:(e,t)=>a({method:`GET`,path:`/api/fs/list`,query:{location:e?.location,path:e?.path},successStatus:200,declaredStatuses:[400,401,404],empty:!1},t),find:(e,t)=>a({method:`GET`,path:`/api/fs/find`,query:{location:e.location,query:e.query,type:e.type,limit:e.limit},successStatus:200,declaredStatuses:[400,401,404],empty:!1},t),write:(e,t)=>a({method:`POST`,path:`/api/experimental/fs/write`,query:{location:e.location,path:e.path},body:e.payload,successStatus:200,declaredStatuses:[400,401,404],empty:!1,binaryBody:!0},t),watch:(e,t)=>a({method:`POST`,path:`/api/experimental/fs/watch`,query:{location:e.location},body:{path:e.path},successStatus:204,declaredStatuses:[400,401,404,503],empty:!0},t),unwatch:(e,t)=>a({method:`DELETE`,path:`/api/experimental/fs/watch`,query:{location:e.location},body:{path:e.path},successStatus:204,declaredStatuses:[400,401,404],empty:!0},t)},command:{list:(e,t)=>a({method:`GET`,path:`/api/command`,query:{location:e?.location},successStatus:200,declaredStatuses:[400,401,404],empty:!1},t)},skill:{list:(e,t)=>a({method:`GET`,path:`/api/skill`,query:{location:e?.location},successStatus:200,declaredStatuses:[400,401,404],empty:!1},t)},rpc:{call:(e,t)=>a({method:`POST`,path:`/api/rpc/${encodeURIComponent(e.rpcID)}/${encodeURIComponent(e.method)}`,query:{location:e.location},body:{input:e.input},successStatus:200,declaredStatuses:[400,401,404,500],empty:!1},t)},event:{subscribe:(e,t)=>o({method:`GET`,path:`/api/event`,query:{types:e?.types},successStatus:200,declaredStatuses:[400,401],empty:!1},t)},pty:{list:(e,t)=>a({method:`GET`,path:`/api/pty`,query:{location:e?.location},successStatus:200,declaredStatuses:[400,401,404],empty:!1},t),create:(e,t)=>a({method:`POST`,path:`/api/pty`,query:{location:e?.location},body:{command:e?.command,args:e?.args,cwd:e?.cwd,title:e?.title,env:e?.env},successStatus:200,declaredStatuses:[400,401,404],empty:!1},t),get:(e,t)=>a({method:`GET`,path:`/api/pty/${encodeURIComponent(e.ptyID)}`,query:{location:e.location},successStatus:200,declaredStatuses:[400,401,404],empty:!1},t),update:(e,t)=>a({method:`PUT`,path:`/api/pty/${encodeURIComponent(e.ptyID)}`,query:{location:e.location},body:{title:e.title,size:e.size},successStatus:200,declaredStatuses:[400,401,404],empty:!1},t),remove:(e,t)=>a({method:`DELETE`,path:`/api/pty/${encodeURIComponent(e.ptyID)}`,query:{location:e.location},successStatus:204,declaredStatuses:[400,401,404],empty:!0},t),connect:{token:(e,t)=>a({method:`POST`,path:`/api/pty/${encodeURIComponent(e.ptyID)}/connect-token`,query:{location:e.location},headers:{"x-opencode-ticket":e[`x-opencode-ticket`]},successStatus:200,declaredStatuses:[400,401,403,404],empty:!1},t)}},experimental:{persistentPty:{read:(e,t)=>a({method:`GET`,path:`/api/experimental/session/${encodeURIComponent(e.sessionID)}/terminal/read`,query:{lines:e.lines},successStatus:200,declaredStatuses:[400,401,503],empty:!1},t).then(e=>e.data),list:(e,t)=>a({method:`GET`,path:`/api/experimental/session/${encodeURIComponent(e.sessionID)}/terminal`,successStatus:200,declaredStatuses:[400,401,503],empty:!1},t).then(e=>e.data),create:(e,t)=>a({method:`POST`,path:`/api/experimental/session/${encodeURIComponent(e.sessionID)}/terminal`,body:{command:e.command,args:e.args,cwd:e.cwd,title:e.title,env:e.env,size:e.size},successStatus:200,declaredStatuses:[400,401,503],empty:!1},t).then(e=>e.data),shutdown:e=>a({method:`POST`,path:`/api/experimental/persistent-pty/shutdown`,successStatus:204,declaredStatuses:[400,401,503],empty:!0},e),handoff:e=>a({method:`POST`,path:`/api/experimental/persistent-pty/handoff`,successStatus:200,declaredStatuses:[400,401,503],empty:!1},e),get:(e,t)=>a({method:`GET`,path:`/api/experimental/persistent-pty/${encodeURIComponent(e.ptyID)}`,successStatus:200,declaredStatuses:[400,401,404,503],empty:!1},t).then(e=>e.data),update:(e,t)=>a({method:`PUT`,path:`/api/experimental/persistent-pty/${encodeURIComponent(e.ptyID)}`,body:{attachmentID:e.attachmentID,size:e.size},successStatus:200,declaredStatuses:[400,401,404,503],empty:!1},t).then(e=>e.data),snapshot:(e,t)=>a({method:`GET`,path:`/api/experimental/persistent-pty/${encodeURIComponent(e.ptyID)}/snapshot`,successStatus:200,declaredStatuses:[400,401,404,503],empty:!1},t).then(e=>e.data),remove:(e,t)=>a({method:`DELETE`,path:`/api/experimental/persistent-pty/${encodeURIComponent(e.ptyID)}`,successStatus:204,declaredStatuses:[400,401,404,503],empty:!0},t),connectToken:(e,t)=>a({method:`POST`,path:`/api/experimental/persistent-pty/${encodeURIComponent(e.ptyID)}/connect-token`,headers:{"x-opencode-ticket":e[`x-opencode-ticket`]},successStatus:200,declaredStatuses:[400,401,403,404,503],empty:!1},t).then(e=>e.data)},media:{get:(e,t)=>a({method:`GET`,path:`/api/experimental/media/${encodeURIComponent(e.hash)}`,successStatus:200,declaredStatuses:[400,401,404],empty:!1,binary:!0},t)}},shell:{list:(e,t)=>a({method:`GET`,path:`/api/shell`,query:{location:e?.location},successStatus:200,declaredStatuses:[400,401,404],empty:!1},t),create:(e,t)=>a({method:`POST`,path:`/api/shell`,query:{location:e.location},body:{command:e.command,cwd:e.cwd,timeout:e.timeout,metadata:e.metadata},successStatus:200,declaredStatuses:[400,401,404],empty:!1},t),get:(e,t)=>a({method:`GET`,path:`/api/shell/${encodeURIComponent(e.id)}`,query:{location:e.location},successStatus:200,declaredStatuses:[400,401,404],empty:!1},t),output:(e,t)=>a({method:`GET`,path:`/api/shell/${encodeURIComponent(e.id)}/output`,query:{location:e.location,cursor:e.cursor,limit:e.limit},successStatus:200,declaredStatuses:[400,401,404],empty:!1},t),remove:(e,t)=>a({method:`DELETE`,path:`/api/shell/${encodeURIComponent(e.id)}`,query:{location:e.location},successStatus:204,declaredStatuses:[400,401,404],empty:!0},t)},reference:{list:(e,t)=>a({method:`GET`,path:`/api/reference`,query:{location:e?.location},successStatus:200,declaredStatuses:[400,401,404],empty:!1},t)},worktree:{list:(e,t)=>a({method:`GET`,path:`/api/worktree`,query:{projectID:e.projectID},successStatus:200,declaredStatuses:[400,401,404],empty:!1},t),create:(e,t)=>a({method:`POST`,path:`/api/worktree`,body:{projectID:e.projectID,from:e.from,branch:e.branch,directory:e.directory,name:e.name},successStatus:200,declaredStatuses:[400,401,404],empty:!1},t),remove:(e,t)=>a({method:`DELETE`,path:`/api/worktree`,body:{projectID:e.projectID,directory:e.directory,force:e.force},successStatus:204,declaredStatuses:[400,401,404],empty:!0},t),refresh:(e,t)=>a({method:`POST`,path:`/api/worktree/refresh`,body:{projectID:e.projectID},successStatus:204,declaredStatuses:[400,401,404],empty:!0},t)},vcs:{init:(e,t)=>a({method:`POST`,path:`/api/vcs/init`,query:{location:e?.location,provider:e?.provider},successStatus:204,declaredStatuses:[400,401,404,409,501,503],empty:!0},t),get:(e,t)=>a({method:`GET`,path:`/api/vcs`,query:{location:e?.location},successStatus:200,declaredStatuses:[400,401,404],empty:!1},t),base:(e,t)=>a({method:`GET`,path:`/api/vcs/base`,query:{location:e?.location},successStatus:200,declaredStatuses:[400,401,404,503],empty:!1},t),status:(e,t)=>a({method:`GET`,path:`/api/vcs/status`,query:{location:e?.location},successStatus:200,declaredStatuses:[400,401,404],empty:!1},t),branch:{list:(e,t)=>a({method:`GET`,path:`/api/vcs/branch`,query:{location:e?.location,search:e?.search,limit:e?.limit},successStatus:200,declaredStatuses:[400,401,404],empty:!1},t)},diff:(e,t)=>a({method:`GET`,path:`/api/vcs/diff`,query:{location:e.location,mode:e.mode,base:e.base,context:e.context,untracked:e.untracked},successStatus:200,declaredStatuses:[400,401,404,503],empty:!1},t)},debug:{heapDump:(e,t)=>a({method:`POST`,path:`/api/debug/heap-dump`,query:{directory:e?.directory},successStatus:200,declaredStatuses:[400,401,500],empty:!1},t),location:{list:e=>a({method:`GET`,path:`/api/debug/location`,successStatus:200,declaredStatuses:[400,401],empty:!1},e),evict:(e,t)=>a({method:`DELETE`,path:`/api/debug/location`,query:{location:e?.location},successStatus:204,declaredStatuses:[400,401],empty:!0},t)}},migration:{v1:{status:e=>a({method:`GET`,path:`/api/experimental/migration/v1`,successStatus:200,declaredStatuses:[400,401],empty:!1},e)}},websearch:{providers:(e,t)=>a({method:`GET`,path:`/api/websearch/provider`,query:{location:e?.location},successStatus:200,declaredStatuses:[400,401,404,503],empty:!1},t),query:(e,t)=>a({method:`POST`,path:`/api/websearch`,query:{location:e.location},body:{query:e.query,providerID:e.providerID},successStatus:200,declaredStatuses:[400,401,404,503],empty:!1},t)},usage:{limits:(e,t)=>a({method:`GET`,path:`/api/experimental/usage/limits`,query:{location:e?.location},successStatus:200,declaredStatuses:[400,401,404,503],empty:!1},t)},config:{get:(e,t)=>a({method:`GET`,path:`/api/config`,query:{location:e?.location},successStatus:200,declaredStatuses:[400,401,404],empty:!1},t),shells:e=>a({method:`GET`,path:`/api/config/shell`,successStatus:200,declaredStatuses:[400,401,404],empty:!1},e),update:(e,t)=>a({method:`PATCH`,path:`/api/experimental/config`,body:{shell:e.shell},successStatus:204,declaredStatuses:[400,401,404],empty:!0},t)}}}function Wt(e){return e.split(`/`).map(encodeURIComponent).join(`/`)}function Gt(e,t,n){if(n!==void 0){if(n===null){e.append(t,`null`);return}if(Array.isArray(n)){for(let r of n)Gt(e,t,r);return}if(typeof n==`object`){for(let[r,i]of Object.entries(n))Gt(e,`${t}[${r}]`,i);return}e.append(t,String(n))}}async function Kt(e){if(!Jt(e,`application/json`)&&!e.headers.get(`content-type`)?.includes(`+json`)){try{await e.body?.cancel()}catch{}throw new Vt(`UnsupportedContentType`,{detail:e.headers.get(`content-type`)})}let t;try{t=await e.text()}catch(e){throw new Vt(`Transport`,{cause:e})}if(t===``)throw new Vt(`MalformedResponse`);try{return JSON.parse(t)}catch(e){throw new Vt(`MalformedResponse`,{cause:e})}}function qt(e){let t=Object.assign(Error(e.message??e.data?.message),e);return e._tag&&(t.name=e._tag),t}function Jt(e,t){return e.headers.get(`content-type`)?.split(`;`,1)[0]?.trim().toLowerCase()===t}var Yt=e=>typeof e==`object`&&!!e&&`_tag`in e&&e._tag===`InvalidRequestError`,Xt=e=>typeof e==`object`&&!!e&&`_tag`in e&&e._tag===`UnauthorizedError`,Zt=e=>typeof e==`object`&&!!e&&`_tag`in e&&e._tag===`LocationNotFoundError`,Qt=e=>typeof e==`object`&&!!e&&`_tag`in e&&e._tag===`ServiceUnavailableError`,$t=e=>typeof e==`object`&&!!e&&`_tag`in e&&e._tag===`AgentNotFoundError`,en=e=>typeof e==`object`&&!!e&&`_tag`in e&&e._tag===`PluginNotFoundError`,tn=e=>typeof e==`object`&&!!e&&`_tag`in e&&e._tag===`InvalidCursorError`,nn=e=>typeof e==`object`&&!!e&&`_tag`in e&&e._tag===`SessionNotFoundError`,rn=e=>typeof e==`object`&&!!e&&`_tag`in e&&e._tag===`ConflictError`,an=e=>typeof e==`object`&&!!e&&`_tag`in e&&e._tag===`UnknownError`,on=e=>typeof e==`object`&&!!e&&`_tag`in e&&e._tag===`MessageNotFoundError`,sn=e=>typeof e==`object`&&!!e&&`_tag`in e&&e._tag===`CommandNotFoundError`,cn=e=>typeof e==`object`&&!!e&&`_tag`in e&&e._tag===`CommandExecutionError`,ln=e=>typeof e==`object`&&!!e&&`_tag`in e&&e._tag===`SkillNotFoundError`,un=e=>typeof e==`object`&&!!e&&`_tag`in e&&e._tag===`SessionBusyError`,dn=e=>typeof e==`object`&&!!e&&`_tag`in e&&e._tag===`InstructionEntryValueTooLargeError`,fn=e=>typeof e==`object`&&!!e&&`_tag`in e&&e._tag===`FormNotFoundError`,pn=e=>typeof e==`object`&&!!e&&`_tag`in e&&e._tag===`FormInvalidAnswerError`,mn=e=>typeof e==`object`&&!!e&&`_tag`in e&&e._tag===`FormAlreadySettledError`,hn=e=>typeof e==`object`&&!!e&&`_tag`in e&&e._tag===`ProviderNotFoundError`,gn=e=>typeof e==`object`&&!!e&&`_tag`in e&&e._tag===`ModelNotFoundError`,_n=e=>typeof e==`object`&&!!e&&`_tag`in e&&e._tag===`UnsupportedModelError`,vn=e=>typeof e==`object`&&!!e&&`_tag`in e&&e._tag===`ProviderRequestError`,yn=e=>typeof e==`object`&&!!e&&`_tag`in e&&e._tag===`IntegrationNotFoundError`,bn=e=>typeof e==`object`&&!!e&&`_tag`in e&&e._tag===`IntegrationAttemptNotFoundError`,xn=e=>typeof e==`object`&&!!e&&`_tag`in e&&e._tag===`IntegrationMethodNotFoundError`,Sn=e=>typeof e==`object`&&!!e&&`_tag`in e&&e._tag===`McpServerNotFoundError`,Cn=e=>typeof e==`object`&&!!e&&`_tag`in e&&e._tag===`ForbiddenError`,wn=e=>typeof e==`object`&&!!e&&`_tag`in e&&e._tag===`ProjectNotFoundError`,Tn=e=>typeof e==`object`&&!!e&&`_tag`in e&&e._tag===`PermissionSavedNotFoundError`,En=e=>typeof e==`object`&&!!e&&`_tag`in e&&e._tag===`PermissionNotFoundError`,Dn=e=>typeof e==`object`&&!!e&&`_tag`in e&&e._tag===`FileNotFoundError`,On=e=>typeof e==`object`&&!!e&&`_tag`in e&&e._tag===`RpcError`,kn=e=>typeof e==`object`&&!!e&&`_tag`in e&&e._tag===`RpcInternalError`,An=e=>typeof e==`object`&&!!e&&`_tag`in e&&e._tag===`PtyNotFoundError`,jn=e=>typeof e==`object`&&!!e&&`_tag`in e&&e._tag===`ShellNotFoundError`,Mn=e=>typeof e==`object`&&!!e&&`_tag`in e&&e._tag===`WorktreeError`,Nn=e=>typeof e==`object`&&!!e&&`_tag`in e&&e._tag===`VcsInitNotSupportedError`;function Pn(e,t){return n=>{let r=(e,r)=>{if(!Object.hasOwn(n.events,e))throw Error(`Unknown RPC event: ${n.id}.${e}`);let i=Fn(n,e);return{[Symbol.asyncIterator](){let e=new AbortController,n=r?.signal?AbortSignal.any([e.signal,r.signal]):e.signal,a=async function*(){try{for await(let e of t.subscribe({signal:n})){if(n.aborted)return;e.type===i&&(yield e)}}catch(e){if(!n.aborted)throw e}finally{e.abort()}}();return{next:()=>a.next(),return:()=>(e.abort(),a.return())}}}};return Object.assign(Object.fromEntries(Object.keys(n.methods).map(t=>[t,async(r,i)=>{try{return(await e.rpc.call({rpcID:n.id,method:t,input:r,location:i?.location},{signal:i?.signal,headers:i?.headers})).output}catch(e){throw!On(e)&&!kn(e)?e:e.data===void 0?{type:e.type,message:e.message}:{type:e.type,message:e.message,data:e.data}}}])),{events:{subscribe:r,on:(e,t,n)=>{let i=new AbortController,a=n?.signal?AbortSignal.any([i.signal,n.signal]):i.signal,o=r(e,{signal:a});return(async()=>{for await(let e of o)await t(e)})().catch(e=>console.error(e)),()=>i.abort()}}})}}function Fn(e,t){return`rpc.${e.id}.${t}`}var In={};Rt(In,{OpenCode:()=>In,make:()=>Ln});function Ln(e){let t=Ut(e),n=Bt((e,n)=>t.event.subscribe(void 0,{signal:e,onActivity:n}));return{...t,rpc:Object.assign(Pn(t,n),t.rpc),event:n}}var Rn=e({ClientError:()=>Vt,OpenCode:()=>In,isAgentNotFoundError:()=>$t,isCommandExecutionError:()=>cn,isCommandNotFoundError:()=>sn,isConflictError:()=>rn,isFileNotFoundError:()=>Dn,isForbiddenError:()=>Cn,isFormAlreadySettledError:()=>mn,isFormInvalidAnswerError:()=>pn,isFormNotFoundError:()=>fn,isInstructionEntryValueTooLargeError:()=>dn,isIntegrationAttemptNotFoundError:()=>bn,isIntegrationMethodNotFoundError:()=>xn,isIntegrationNotFoundError:()=>yn,isInvalidCursorError:()=>tn,isInvalidRequestError:()=>Yt,isLocationNotFoundError:()=>Zt,isMcpServerNotFoundError:()=>Sn,isMessageNotFoundError:()=>on,isModelNotFoundError:()=>gn,isPermissionNotFoundError:()=>En,isPermissionSavedNotFoundError:()=>Tn,isPluginNotFoundError:()=>en,isProjectNotFoundError:()=>wn,isProviderNotFoundError:()=>hn,isProviderRequestError:()=>vn,isPtyNotFoundError:()=>An,isRpcError:()=>On,isRpcInternalError:()=>kn,isServiceUnavailableError:()=>Qt,isSessionBusyError:()=>un,isSessionNotFoundError:()=>nn,isShellNotFoundError:()=>jn,isSkillNotFoundError:()=>ln,isUnauthorizedError:()=>Xt,isUnknownError:()=>an,isUnsupportedModelError:()=>_n,isVcsInitNotSupportedError:()=>Nn,isWorktreeError:()=>Mn}),zn=e({$DEVCOMP:()=>fr,$PROXY:()=>lr,$TRACK:()=>dr,DEV:()=>void 0,ErrorBoundary:()=>Zi,For:()=>Wi,Index:()=>Gi,Match:()=>Ji,Show:()=>Ki,Suspense:()=>ta,SuspenseList:()=>ea,Switch:()=>qi,batch:()=>Ir,cancelCallback:()=>nr,catchError:()=>Vr,children:()=>$r,createComponent:()=>Ni,createComputed:()=>Dr,createContext:()=>Zr,createDeferred:()=>Pr,createEffect:()=>kr,createMemo:()=>jr,createReaction:()=>Ar,createRenderEffect:()=>Or,createResource:()=>Nr,createRoot:()=>Tr,createSelector:()=>Fr,createSignal:()=>Er,createUniqueId:()=>Hi,enableExternalSource:()=>ni,enableHydration:()=>Mi,enableScheduling:()=>Gr,equalFn:()=>cr,from:()=>Ei,getListener:()=>Hr,getOwner:()=>Ur,indexArray:()=>Ai,lazy:()=>Bi,mapArray:()=>ki,mergeProps:()=>Ri,observable:()=>Ti,on:()=>Rr,onCleanup:()=>Br,onError:()=>Ci,onMount:()=>zr,requestCallback:()=>tr,resetErrorBoundaries:()=>Xi,runWithOwner:()=>Wr,sharedConfig:()=>F,splitProps:()=>zi,startTransition:()=>Kr,untrack:()=>Lr,useContext:()=>Qr,useTransition:()=>Yr}),Bn=1,Vn=!1,Hn=!1,Un=[],Wn=null,Gn=null,Kn=5,qn=0,Jn=300,Yn=0,Xn=null,Zn=null,Qn=1073741823;function $n(){let e=new MessageChannel,t=e.port1,n=e.port2;if(typeof t.unref==`function`&&t.unref(),typeof n.unref==`function`&&n.unref(),Xn=()=>n.postMessage(null),t.onmessage=()=>{if(Zn!==null){let e=performance.now();qn=e+Kn,Yn=e+Jn;try{Zn(e)?n.postMessage(null):Zn=null}catch(e){throw n.postMessage(null),e}}},navigator&&navigator.scheduling&&navigator.scheduling.isInputPending){let e=navigator.scheduling;Gn=()=>{let t=performance.now();return t>=qn?e.isInputPending()?!0:t>=Yn:!1}}else Gn=()=>performance.now()>=qn}function er(e,t){function n(){let n=0,r=e.length-1;for(;n<=r;){let i=r+n>>1,a=t.expirationTime-e[i].expirationTime;if(a>0)n=i+1;else if(a<0)r=i-1;else return i}return n}e.splice(n(),0,t)}function tr(e,t){Xn||$n();let n=performance.now(),r=Qn;t&&t.timeout&&(r=t.timeout);let i={id:Bn++,fn:e,startTime:n,expirationTime:n+r};return er(Un,i),!Vn&&!Hn&&(Vn=!0,Zn=rr,Xn()),i}function nr(e){e.fn=null}function rr(e){Vn=!1,Hn=!0;try{return ir(e)}finally{Wn=null,Hn=!1}}function ir(e){let t=e;for(Wn=Un[0]||null;Wn!==null&&!(Wn.expirationTime>t&&Gn());){let e=Wn.fn;e===null?Un.shift():(Wn.fn=null,e(Wn.expirationTime<=t),t=performance.now(),Wn===Un[0]&&Un.shift()),Wn=Un[0]||null}return Wn!==null}var F={context:void 0,registry:void 0,effects:void 0,done:!1,getContextId(){return ar(this.context.count)},getNextContextId(){return ar(this.context.count++)}};function ar(e){let t=String(e),n=t.length-1;return F.context.id+(n?String.fromCharCode(96+n):``)+t}function or(e){F.context=e}function sr(){return{...F.context,id:F.getNextContextId(),count:0}}var cr=(e,t)=>e===t,lr=Symbol(`solid-proxy`),ur=typeof Proxy==`function`,dr=Symbol(`solid-track`),fr=Symbol(`solid-dev-component`),pr={equals:cr},mr=null,hr=di,gr=1,_r=2,vr={owned:null,cleanups:null,context:null,owner:null},yr={},I=null,L=null,br=null,xr=null,R=null,Sr=null,Cr=null,wr=0;function Tr(e,t){let n=R,r=I,i=e.length===0,a=t===void 0?r:t,o=i?vr:{owned:null,cleanups:null,context:a?a.context:null,owner:a},s=i?e:()=>e(()=>Lr(()=>gi(o)));I=o,R=null;try{return li(s,!0)}finally{R=n,I=r}}function Er(e,t){t=t?Object.assign({},pr,t):pr;let n={value:e,observers:null,observerSlots:null,comparator:t.equals||void 0};return[ri.bind(n),e=>(typeof e==`function`&&(e=L&&L.running&&L.sources.has(n)?e(n.tValue):e(n.value)),ii(n,e))]}function Dr(e,t,n){let r=si(e,t,!0,gr);br&&L&&L.running?Sr.push(r):ai(r)}function Or(e,t,n){let r=si(e,t,!1,gr);br&&L&&L.running?Sr.push(r):ai(r)}function kr(e,t,n){hr=pi;let r=si(e,t,!1,gr),i=ei&&Qr(ei);i&&(r.suspense=i),(!n||!n.render)&&(r.user=!0),Cr?Cr.push(r):ai(r)}function Ar(e,t){let n,r=si(()=>{n?n():Lr(e),n=void 0},void 0,!1,0),i=ei&&Qr(ei);return i&&(r.suspense=i),r.user=!0,e=>{n=e,ai(r)}}function jr(e,t,n){n=n?Object.assign({},pr,n):pr;let r=si(e,t,!0,0);return r.observers=null,r.observerSlots=null,r.comparator=n.equals||void 0,br&&L&&L.running?(r.tState=gr,Sr.push(r)):ai(r),ri.bind(r)}function Mr(e){return e&&typeof e==`object`&&`then`in e}function Nr(e,t,n){let r,i,a;typeof t==`function`?(r=e,i=t,a=n||{}):(r=!0,i=e,a=t||{});let o=null,s=yr,c=null,l=!1,u=!1,d=`initialValue`in a,f=typeof r==`function`&&jr(r),p=new Set,[ee,te]=(a.storage||Er)(a.initialValue),[m,h]=Er(void 0),[ne,re]=Er(void 0,{equals:!1}),[ie,ae]=Er(d?`ready`:`unresolved`);F.context&&(c=F.getNextContextId(),a.ssrLoadFrom===`initial`?s=a.initialValue:F.load&&F.has(c)&&(s=F.load(c)));function oe(e,t,n,r){return o===e&&(o=null,r!==void 0&&(d=!0),(e===s||t===s)&&a.onHydrated&&queueMicrotask(()=>a.onHydrated(r,{value:t})),s=yr,L&&e&&l?(L.promises.delete(e),l=!1,li(()=>{L.running=!0,se(t,n)},!1)):se(t,n)),t}function se(e,t){li(()=>{t===void 0&&te(()=>e),ae(t===void 0?d?`ready`:`unresolved`:`errored`),h(t);for(let e of p.keys())e.decrement();p.clear()},!1)}function ce(){let e=ei&&Qr(ei),t=ee(),n=m();if(n!==void 0&&!o)throw n;return R&&!R.user&&e&&Dr(()=>{ne(),o&&(e.resolved&&L&&l?L.promises.add(o):p.has(e)||(e.increment(),p.add(e)))}),t}function le(e=!0){if(e!==!1&&u)return;u=!1;let t=f?f():r;if(l=L&&L.running,t==null||t===!1){oe(o,Lr(ee));return}L&&o&&L.promises.delete(o);let n,a=s===yr?Lr(()=>{try{return i(t,{value:ee(),refetching:e})}catch(e){n=e}}):s;if(n!==void 0){oe(o,void 0,vi(n),t);return}return Mr(a)?(o=a,`v`in a?(a.s===1?oe(o,a.v,void 0,t):oe(o,void 0,vi(a.v),t),a):(u=!0,queueMicrotask(()=>u=!1),li(()=>{ae(d?`refreshing`:`pending`),re()},!1),a.then(e=>oe(a,e,void 0,t),e=>oe(a,void 0,vi(e),t)))):(oe(o,a,void 0,t),a)}Object.defineProperties(ce,{state:{get:()=>ie()},error:{get:()=>m()},loading:{get(){let e=ie();return e===`pending`||e===`refreshing`}},latest:{get(){if(!d)return ce();let e=m();if(e&&!o)throw e;return ee()}}});let ue=I;return f?Dr(()=>(ue=I,le(!1))):le(!1),[ce,{refetch:e=>Wr(ue,()=>le(e)),mutate:te}]}function Pr(e,t){let n,r=t?t.timeoutMs:void 0,i=si(()=>((!n||!n.fn)&&(n=tr(()=>o(()=>i.value),r===void 0?void 0:{timeout:r})),e()),void 0,!0),[a,o]=Er(L&&L.running&&L.sources.has(i)?i.tValue:i.value,t);return ai(i),o(()=>L&&L.running&&L.sources.has(i)?i.tValue:i.value),a}function Fr(e,t=cr,n){let r=new Map,i=si(n=>{let i=e();for(let[e,a]of r.entries())if(t(e,i)!==t(e,n))for(let e of a.values())e.state=gr,e.pure?Sr.push(e):Cr.push(e);return i},void 0,!0,gr);return ai(i),e=>{let n=R;if(n){let t;(t=r.get(e))?t.add(n):r.set(e,t=new Set([n])),Br(()=>{t.delete(n),!t.size&&r.delete(e)})}return t(e,L&&L.running&&L.sources.has(i)?i.tValue:i.value)}}function Ir(e){return li(e,!1)}function Lr(e){if(!xr&&R===null)return e();let t=R;R=null;try{return xr?xr.untrack(e):e()}finally{R=t}}function Rr(e,t,n){let r=Array.isArray(e),i,a=n&&n.defer;return n=>{let o;if(r){o=Array(e.length);for(let t=0;t<e.length;t++)o[t]=e[t]()}else o=e();if(a)return a=!1,n;let s=Lr(()=>t(o,i,n));return i=o,s}}function zr(e){kr(()=>Lr(e))}function Br(e){return I===null||(I.cleanups===null?I.cleanups=[e]:I.cleanups.push(e)),e}function Vr(e,t){mr||=Symbol(`error`),I=si(void 0,void 0,!0),I.context={...I.context,[mr]:[t]},L&&L.running&&L.sources.add(I);try{return e()}catch(e){bi(e)}finally{I=I.owner}}function Hr(){return R}function Ur(){return I}function Wr(e,t){let n=I,r=R;I=e,R=null;try{return li(t,!0)}catch(e){bi(e)}finally{I=n,R=r}}function Gr(e=tr){br=e}function Kr(e){if(L&&L.running)return e(),L.done;let t=R,n=I;return Promise.resolve().then(()=>{R=t,I=n;let r;return(br||ei)&&(r=L||={sources:new Set,effects:[],promises:new Set,disposed:new Set,queue:new Set,running:!0},r.done||(r.done=new Promise(e=>r.resolve=e)),r.running=!0),li(e,!1),R=I=null,r?r.done:void 0})}var[qr,Jr]=Er(!1);function Yr(){return[qr,Kr]}function Xr(e){Cr.push.apply(Cr,e),e.length=0}function Zr(e,t){let n=Symbol(`context`);return{id:n,Provider:Si(n),defaultValue:e}}function Qr(e){let t;return I&&I.context&&(t=I.context[e.id])!==void 0?t:e.defaultValue}function $r(e){let t=jr(e),n=jr(()=>xi(t()));return n.toArray=()=>{let e=n();return Array.isArray(e)?e:e==null?[]:[e]},n}var ei;function ti(){return ei||=Zr()}function ni(e,t=e=>e()){if(xr){let{factory:n,untrack:r}=xr;xr={factory:(t,r)=>{let i=n(t,r),a=e(e=>i.track(e),r);return{track:e=>a.track(e),dispose(){a.dispose(),i.dispose()}}},untrack:e=>r(()=>t(e))}}else xr={factory:e,untrack:t}}function ri(){let e=L&&L.running;if(this.sources&&(e?this.tState:this.state))if((e?this.tState:this.state)===gr)ai(this);else{let e=Sr;Sr=null,li(()=>mi(this),!1),Sr=e}if(R){let e=this.observers;if(!e||e[e.length-1]!==R){let t=e?e.length:0;R.sources?(R.sources.push(this),R.sourceSlots.push(t)):(R.sources=[this],R.sourceSlots=[t]),e?(e.push(R),this.observerSlots.push(R.sources.length-1)):(this.observers=[R],this.observerSlots=[R.sources.length-1])}}return e&&L.sources.has(this)?this.tValue:this.value}function ii(e,t,n){let r=L&&L.running&&L.sources.has(e)?e.tValue:e.value;if(!e.comparator||!e.comparator(r,t)){if(L){let r=L.running;(r||!n&&L.sources.has(e))&&(L.sources.add(e),e.tValue=t),r||(e.value=t)}else e.value=t;e.observers&&e.observers.length&&li(()=>{for(let t=0;t<e.observers.length;t+=1){let n=e.observers[t],r=L&&L.running;r&&L.disposed.has(n)||((r?!n.tState:!n.state)&&(n.pure?Sr.push(n):Cr.push(n),n.observers&&hi(n)),r?n.tState=gr:n.state=gr)}if(Sr.length>1e6)throw Sr=[],Error()},!1)}return t}function ai(e){if(!e.fn)return;gi(e);let t=wr;oi(e,L&&L.running&&L.sources.has(e)?e.tValue:e.value,t),L&&!L.running&&L.sources.has(e)&&queueMicrotask(()=>{li(()=>{L&&(L.running=!0),R=I=e,oi(e,e.tValue,t),R=I=null},!1)})}function oi(e,t,n){let r,i=I,a=R;R=I=e;try{r=e.fn(t)}catch(t){return e.pure&&(L&&L.running?(e.tState=gr,e.tOwned&&e.tOwned.forEach(gi),e.tOwned=void 0):(e.state=gr,e.owned&&e.owned.forEach(gi),e.owned=null)),e.updatedAt=n+1,bi(t)}finally{R=a,I=i}(!e.updatedAt||e.updatedAt<=n)&&(e.updatedAt!=null&&`observers`in e?ii(e,r,!0):L&&L.running&&e.pure?(L.sources.has(e)||(e.value=r),L.sources.add(e),e.tValue=r):e.value=r,e.updatedAt=n)}function si(e,t,n,r=gr,i){let a={fn:e,state:r,updatedAt:null,owned:null,sources:null,sourceSlots:null,cleanups:null,value:t,owner:I,context:I?I.context:null,pure:n};if(L&&L.running&&(a.state=0,a.tState=r),I===null||I!==vr&&(L&&L.running&&I.pure?I.tOwned?I.tOwned.push(a):I.tOwned=[a]:I.owned?I.owned.push(a):I.owned=[a]),xr&&a.fn){let e=a.fn,[t,n]=Er(void 0,{equals:!1}),r=xr.factory(e,n);Br(()=>r.dispose());let i,o=()=>Kr(n).then(()=>{i&&=(i.dispose(),void 0)});a.fn=n=>(t(),L&&L.running?(i||=xr.factory(e,o),i.track(n)):r.track(n))}return a}function ci(e){let t=L&&L.running;if((t?e.tState:e.state)===0)return;if((t?e.tState:e.state)===_r)return mi(e);if(e.suspense&&Lr(e.suspense.inFallback))return e.suspense.effects.push(e);let n=[e];for(;(e=e.owner)&&(!e.updatedAt||e.updatedAt<wr);){if(t&&L.disposed.has(e))return;(t?e.tState:e.state)&&n.push(e)}for(let r=n.length-1;r>=0;r--){if(e=n[r],t){let t=e,i=n[r+1];for(;(t=t.owner)&&t!==i;)if(L.disposed.has(t))return}if((t?e.tState:e.state)===gr)ai(e);else if((t?e.tState:e.state)===_r){let t=Sr;Sr=null,li(()=>mi(e,n[0]),!1),Sr=t}}}function li(e,t){if(Sr)return e();let n=!1;t||(Sr=[]),Cr?n=!0:Cr=[],wr++;try{let t=e();return ui(n),t}catch(e){n||(Cr=null),Sr=null,bi(e)}}function ui(e){if(Sr&&=(br&&L&&L.running?fi(Sr):di(Sr),null),e)return;let t;if(L){if(!L.promises.size&&!L.queue.size){let e=L.sources,n=L.disposed;Cr.push.apply(Cr,L.effects),t=L.resolve;for(let e of Cr)`tState`in e&&(e.state=e.tState),delete e.tState;L=null,li(()=>{for(let e of n)gi(e);for(let t of e){if(t.value=t.tValue,t.owned)for(let e=0,n=t.owned.length;e<n;e++)gi(t.owned[e]);t.tOwned&&(t.owned=t.tOwned),delete t.tValue,delete t.tOwned,t.tState=0}Jr(!1)},!1)}else if(L.running){L.running=!1,L.effects.push.apply(L.effects,Cr),Cr=null,Jr(!0);return}}let n=Cr;Cr=null,n.length&&li(()=>hr(n),!1),t&&t()}function di(e){for(let t=0;t<e.length;t++)ci(e[t])}function fi(e){for(let t=0;t<e.length;t++){let n=e[t],r=L.queue;r.has(n)||(r.add(n),br(()=>{r.delete(n),li(()=>{L.running=!0,ci(n)},!1),L&&(L.running=!1)}))}}function pi(e){let t,n=0;for(t=0;t<e.length;t++){let r=e[t];r.user?e[n++]=r:ci(r)}if(F.context){if(F.count){F.effects||=[],F.effects.push(...e.slice(0,n));return}or()}for(F.effects&&(F.done||!F.count)&&(e=[...F.effects,...e],n+=F.effects.length,delete F.effects),t=0;t<n;t++)ci(e[t])}function mi(e,t){let n=L&&L.running;n?e.tState=0:e.state=0;for(let r=0;r<e.sources.length;r+=1){let i=e.sources[r];if(i.sources){let e=n?i.tState:i.state;e===gr?i!==t&&(!i.updatedAt||i.updatedAt<wr)&&ci(i):e===_r&&mi(i,t)}}}function hi(e){let t=L&&L.running;for(let n=0;n<e.observers.length;n+=1){let r=e.observers[n];(t?!r.tState:!r.state)&&(t?r.tState=_r:r.state=_r,r.pure?Sr.push(r):Cr.push(r),r.observers&&hi(r))}}function gi(e){let t;if(e.sources)for(;e.sources.length;){let t=e.sources.pop(),n=e.sourceSlots.pop(),r=t.observers;if(r&&r.length){let e=r.pop(),i=t.observerSlots.pop();n<r.length&&(e.sourceSlots[i]=n,r[n]=e,t.observerSlots[n]=i)}}if(e.tOwned){for(t=e.tOwned.length-1;t>=0;t--)gi(e.tOwned[t]);delete e.tOwned}if(L&&L.running&&e.pure)_i(e,!0);else if(e.owned){for(t=e.owned.length-1;t>=0;t--)gi(e.owned[t]);e.owned=null}if(e.cleanups){for(t=e.cleanups.length-1;t>=0;t--)e.cleanups[t]();e.cleanups=null}L&&L.running?e.tState=0:e.state=0}function _i(e,t){if(t||(e.tState=0,L.disposed.add(e)),e.owned)for(let t=0;t<e.owned.length;t++)_i(e.owned[t])}function vi(e){return e instanceof Error?e:Error(typeof e==`string`?e:`Unknown error`,{cause:e})}function yi(e,t,n){try{for(let n of t)n(e)}catch(e){bi(e,n&&n.owner||null)}}function bi(e,t=I){let n=mr&&t&&t.context&&t.context[mr],r=vi(e);if(!n)throw r;Cr?Cr.push({fn(){yi(r,n,t)},state:gr}):yi(r,n,t)}function xi(e){if(typeof e==`function`&&!e.length)return xi(e());if(Array.isArray(e)){let t=[];for(let n=0;n<e.length;n++){let r=xi(e[n]);if(Array.isArray(r))if(r.length<32768)t.push.apply(t,r);else for(let e=0;e<r.length;e++)t.push(r[e]);else t.push(r)}return t}return e}function Si(e,t){return function(t){let n;return Or(()=>n=Lr(()=>(I.context={...I.context,[e]:t.value},$r(()=>t.children))),void 0),n}}function Ci(e){mr||=Symbol(`error`),I===null||(I.context===null||!I.context[mr]?(I.context={...I.context,[mr]:[e]},wi(I,mr,[e])):I.context[mr].push(e))}function wi(e,t,n){if(e.owned)for(let r=0;r<e.owned.length;r++)e.owned[r].context===e.context&&wi(e.owned[r],t,n),e.owned[r].context?e.owned[r].context[t]||(e.owned[r].context[t]=n,wi(e.owned[r],t,n)):(e.owned[r].context=e.context,wi(e.owned[r],t,n))}function Ti(e){return{subscribe(t){if(!(t instanceof Object)||t==null)throw TypeError(`Expected the observer to be an object.`);let n=typeof t==`function`?t:t.next&&t.next.bind(t);if(!n)return{unsubscribe(){}};let r=Tr(t=>(kr(()=>{let t=e();Lr(()=>n(t))}),t));return Ur()&&Br(r),{unsubscribe(){r()}}},[Symbol.observable||`@@observable`](){return this}}}function Ei(e,t=void 0){let[n,r]=Er(t,{equals:!1});if(`subscribe`in e){let t=e.subscribe(e=>r(()=>e));Br(()=>`unsubscribe`in t?t.unsubscribe():t())}else Br(e(r));return n}var Di=Symbol(`fallback`);function Oi(e){for(let t=0;t<e.length;t++)e[t]()}function ki(e,t,n={}){let r=[],i=[],a=[],o=0,s=t.length>1?[]:null;return Br(()=>Oi(a)),()=>{let c=e()||[],l=c.length,u,d;return c[dr],Lr(()=>{let e,t,p,ee,te,m,h,ne,re;if(l===0)o!==0&&(Oi(a),a=[],r=[],i=[],o=0,s&&=[]),n.fallback&&(r=[Di],i[0]=Tr(e=>(a[0]=e,n.fallback())),o=1);else if(o===0){for(i=Array(l),d=0;d<l;d++)r[d]=c[d],i[d]=Tr(f);o=l}else{for(p=Array(l),ee=Array(l),s&&(te=Array(l)),m=0,h=Math.min(o,l);m<h&&r[m]===c[m];m++);for(h=o-1,ne=l-1;h>=m&&ne>=m&&r[h]===c[ne];h--,ne--)p[ne]=i[h],ee[ne]=a[h],s&&(te[ne]=s[h]);for(e=new Map,t=Array(ne+1),d=ne;d>=m;d--)re=c[d],u=e.get(re),t[d]=u===void 0?-1:u,e.set(re,d);for(u=m;u<=h;u++)re=r[u],d=e.get(re),d!==void 0&&d!==-1?(p[d]=i[u],ee[d]=a[u],s&&(te[d]=s[u]),d=t[d],e.set(re,d)):a[u]();for(d=m;d<l;d++)d in p?(i[d]=p[d],a[d]=ee[d],s&&(s[d]=te[d],s[d](d))):i[d]=Tr(f);i=i.slice(0,o=l),r=c.slice(0)}return i});function f(e){if(a[d]=e,s){let[e,n]=Er(d);return s[d]=n,t(c[d],e)}return t(c[d])}}}function Ai(e,t,n={}){let r=[],i=[],a=[],o=[],s=0,c;return Br(()=>Oi(a)),()=>{let l=e()||[],u=l.length;return l[dr],Lr(()=>{if(u===0)return s!==0&&(Oi(a),a=[],r=[],i=[],s=0,o=[]),n.fallback&&(r=[Di],i[0]=Tr(e=>(a[0]=e,n.fallback())),s=1),i;for(r[0]===Di&&(a[0](),a=[],r=[],i=[],s=0),c=0;c<u;c++)c<r.length&&r[c]!==l[c]?o[c](()=>l[c]):c>=r.length&&(i[c]=Tr(d));for(;c<r.length;c++)a[c]();return s=o.length=a.length=u,r=l.slice(0),i=i.slice(0,s)});function d(e){a[c]=e;let[n,r]=Er(l[c]);return o[c]=r,t(n,c)}}}var ji=!1;function Mi(){ji=!0}function Ni(e,t){if(ji&&F.context){let n=F.context;or(sr());let r=Lr(()=>e(t||{}));return or(n),r}return Lr(()=>e(t||{}))}function Pi(){return!0}var Fi={get(e,t,n){return t===lr?n:e.get(t)},has(e,t){return t===lr||e.has(t)},set:Pi,deleteProperty:Pi,getOwnPropertyDescriptor(e,t){return{configurable:!0,enumerable:!0,get(){return e.get(t)},set:Pi,deleteProperty:Pi}},ownKeys(e){return e.keys()}};function Ii(e){return(e=typeof e==`function`?e():e)?e:{}}function Li(){for(let e=0,t=this.length;e<t;++e){let t=this[e]();if(t!==void 0)return t}}function Ri(...e){let t=!1;for(let n=0;n<e.length;n++){let r=e[n];t||=!!r&&lr in r,e[n]=typeof r==`function`?(t=!0,jr(r)):r}if(ur&&t)return new Proxy({get(t){for(let n=e.length-1;n>=0;n--){let r=Ii(e[n])[t];if(r!==void 0)return r}},has(t){for(let n=e.length-1;n>=0;n--)if(t in Ii(e[n]))return!0;return!1},keys(){let t=[];for(let n=0;n<e.length;n++)t.push(...Object.keys(Ii(e[n])));return[...new Set(t)]}},Fi);let n={},r=Object.create(null);for(let t=e.length-1;t>=0;t--){let i=e[t];if(!i)continue;let a=Object.getOwnPropertyNames(i);for(let e=a.length-1;e>=0;e--){let t=a[e];if(t===`__proto__`||t===`constructor`)continue;let o=Object.getOwnPropertyDescriptor(i,t);if(!r[t])r[t]=o.get?{enumerable:!0,configurable:!0,get:Li.bind(n[t]=[o.get.bind(i)])}:o.value===void 0?void 0:o;else{let e=n[t];e&&(o.get?e.push(o.get.bind(i)):o.value!==void 0&&e.push(()=>o.value))}}}let i={},a=Object.keys(r);for(let e=a.length-1;e>=0;e--){let t=a[e],n=r[t];n&&n.get?Object.defineProperty(i,t,n):i[t]=n?n.value:void 0}return i}function zi(e,...t){let n=t.length;if(ur&&lr in e){let r=n>1?t.flat():t[0],i=t.map(t=>new Proxy({get(n){return t.includes(n)?e[n]:void 0},has(n){return t.includes(n)&&n in e},keys(){return t.filter(t=>t in e)}},Fi));return i.push(new Proxy({get(t){return r.includes(t)?void 0:e[t]},has(t){return!r.includes(t)&&t in e},keys(){return Object.keys(e).filter(e=>!r.includes(e))}},Fi)),i}let r=[];for(let e=0;e<=n;e++)r[e]={};for(let i of Object.getOwnPropertyNames(e)){let a=n;for(let e=0;e<t.length;e++)if(t[e].includes(i)){a=e;break}let o=Object.getOwnPropertyDescriptor(e,i);!o.get&&!o.set&&o.enumerable&&o.writable&&o.configurable?r[a][i]=o.value:Object.defineProperty(r[a],i,o)}return r}function Bi(e){let t,n,r=r=>{let i=F.context;if(i){let[r,a]=Er();F.count||=0,F.count++,(n||=e()).then(e=>{!F.done&&or(i),F.count--,a(()=>e.default),or()}),t=r}else if(!t){let[r]=Nr(()=>(n||=e()).then(e=>e.default));t=r}let a;return jr(()=>(a=t())?Lr(()=>{if(!i||F.done)return a(r);let e=F.context;or(i);let t=a(r);return or(e),t}):``)};return r.preload=()=>n||((n=e()).then(e=>t=()=>e.default),n),r}var Vi=0;function Hi(){return F.context?F.getNextContextId():`cl-${Vi++}`}var Ui=e=>`Stale read from <${e}>.`;function Wi(e){let t=`fallback`in e&&{fallback:()=>e.fallback};return jr(ki(()=>e.each,e.children,t||void 0))}function Gi(e){let t=`fallback`in e&&{fallback:()=>e.fallback};return jr(Ai(()=>e.each,e.children,t||void 0))}function Ki(e){let t=e.keyed,n=jr(()=>e.when,void 0,void 0),r=t?n:jr(n,void 0,{equals:(e,t)=>!e==!t});return jr(()=>{let i=r();if(i){let a=e.children;return typeof a==`function`&&a.length>0?Lr(()=>a(t?i:()=>{if(!Lr(r))throw Ui(`Show`);return n()})):a}return e.fallback},void 0,void 0)}function qi(e){let t=$r(()=>e.children),n=jr(()=>{let e=t(),n=Array.isArray(e)?e:[e],r=()=>void 0;for(let e=0;e<n.length;e++){let t=e,i=n[e],a=r,o=jr(()=>a()?void 0:i.when,void 0,void 0),s=i.keyed?o:jr(o,void 0,{equals:(e,t)=>!e==!t});r=()=>a()||(s()?[t,o,i]:void 0)}return r});return jr(()=>{let t=n()();if(!t)return e.fallback;let[r,i,a]=t,o=a.children;return typeof o==`function`&&o.length>0?Lr(()=>o(a.keyed?i():()=>{if(Lr(n)()?.[0]!==r)throw Ui(`Match`);return i()})):o},void 0,void 0)}function Ji(e){return e}var Yi;function Xi(){Yi&&[...Yi].forEach(e=>e())}function Zi(e){let t;F.context&&F.load&&(t=F.load(F.getContextId()));let[n,r]=Er(t,void 0);return Yi||=new Set,Yi.add(r),Br(()=>Yi.delete(r)),jr(()=>{let t;if(t=n()){let n=e.fallback;return typeof n==`function`&&n.length?Lr(()=>n(t,()=>r())):n}return Vr(()=>e.children,r)},void 0,void 0)}var Qi=(e,t)=>e.showContent===t.showContent&&e.showFallback===t.showFallback,$i=Zr();function ea(e){let[t,n]=Er(()=>({inFallback:!1})),r,i=Qr($i),[a,o]=Er([]);i&&(r=i.register(jr(()=>t()().inFallback)));let s=jr(t=>{let n=e.revealOrder,i=e.tail,{showContent:o=!0,showFallback:s=!0}=r?r():{},c=a(),l=n===`backwards`;if(n===`together`){let e=c.every(e=>!e()),t=c.map(()=>({showContent:e&&o,showFallback:s}));return t.inFallback=!e,t}let u=!1,d=t.inFallback,f=[];for(let e=0,t=c.length;e<t;e++){let n=l?t-e-1:e,r=c[n]();if(!u&&!r)f[n]={showContent:o,showFallback:s};else{let e=!u;e&&(d=!0),f[n]={showContent:e,showFallback:!i||e&&i===`collapsed`?s:!1},u=!0}}return u||(d=!1),f.inFallback=d,f},{inFallback:!1});return n(()=>s),Ni($i.Provider,{value:{register:e=>{let t;return o(n=>(t=n.length,[...n,e])),jr(()=>s()[t],void 0,{equals:Qi})}},get children(){return e.children}})}function ta(e){let t=0,n,r,i,a,o,[s,c]=Er(!1),l=ti(),u={increment:()=>{++t===1&&c(!0)},decrement:()=>{--t===0&&c(!1)},inFallback:s,effects:[],resolved:!1},d=Ur();if(F.context&&F.load){let e=F.getContextId(),t=F.load(e);if(t&&(typeof t!=`object`||t.s!==1?i=t:F.gather(e)),i&&i!==`$$f`){let[t,n]=Er(void 0,{equals:!1});a=t,i.then(()=>{if(F.done)return n();F.gather(e),or(r),n(),or()},e=>{o=e,n()})}}let f=Qr($i);f&&(n=f.register(u.inFallback));let p;return Br(()=>p&&p()),Ni(l.Provider,{value:u,get children(){return jr(()=>{if(o)throw o;if(r=F.context,a){a(),a=void 0;return}r&&i===`$$f`&&or();let t=jr(()=>e.children);return jr(a=>{let o=u.inFallback(),{showContent:s=!0,showFallback:c=!0}=n?n():{};if((!o||i&&i!==`$$f`)&&s)return u.resolved=!0,p&&p(),p=r=i=void 0,Xr(u.effects),t();if(c)return p?a:Tr(t=>(p=t,r&&=(or({id:r.id+`F`,count:0}),void 0),e.fallback),d)})})}})}var na=e({$RAW:()=>ra,DEV:()=>void 0,createMutable:()=>Ta,createStore:()=>xa,modifyMutable:()=>Ea,produce:()=>Na,reconcile:()=>Aa,unwrap:()=>la}),ra=Symbol(`store-raw`),ia=Symbol(`store-node`),aa=Symbol(`store-has`),oa=Symbol(`store-self`);function sa(e){let t=e[lr];if(!t&&(Object.defineProperty(e,lr,{value:t=new Proxy(e,ha)}),!Array.isArray(e))){let n=Object.keys(e),r=Object.getOwnPropertyDescriptors(e),i=Object.getPrototypeOf(e),a=i!==null&&typeof e==`object`&&!!e&&!Array.isArray(e)&&i!==Object.prototype;if(a){let e=Object.getOwnPropertyDescriptors(i);n.push(...Object.keys(e)),Object.assign(r,e)}for(let i=0,o=n.length;i<o;i++){let o=n[i];a&&o===`constructor`||r[o].get&&Object.defineProperty(e,o,{configurable:!0,enumerable:r[o].enumerable,get:r[o].get.bind(t)})}}return t}function ca(e){let t;return typeof e==`object`&&!!e&&(e[lr]||!(t=Object.getPrototypeOf(e))||t===Object.prototype||Array.isArray(e))}function la(e,t=new Set){let n,r,i,a;if(n=e!=null&&e[ra])return n;if(!ca(e)||t.has(e))return e;if(Array.isArray(e)){Object.isFrozen(e)?e=e.slice(0):t.add(e);for(let n=0,a=e.length;n<a;n++)i=e[n],(r=la(i,t))!==i&&(e[n]=r)}else{Object.isFrozen(e)?e=Object.assign({},e):t.add(e);let n=Object.keys(e),o=Object.getOwnPropertyDescriptors(e);for(let s=0,c=n.length;s<c;s++)a=n[s],!o[a].get&&(i=e[a],(r=la(i,t))!==i&&(e[a]=r))}return e}function ua(e,t){let n=e[t];return n||Object.defineProperty(e,t,{value:n=Object.create(null)}),n}function da(e,t,n){if(e[t])return e[t];let[r,i]=Er(n,{equals:!1,internal:!0});return r.$=i,e[t]=r}function fa(e,t){let n=Reflect.getOwnPropertyDescriptor(e,t);return!n||n.get||!n.configurable||t===lr||t===ia?n:(delete n.value,delete n.writable,n.get=()=>e[lr][t],n)}function pa(e){Hr()&&da(ua(e,ia),oa)()}function ma(e){return pa(e),Reflect.ownKeys(e)}var ha={get(e,t,n){if(t===ra)return e;if(t===lr)return n;if(t===dr)return pa(e),n;let r=ua(e,ia),i=r[t],a=i?i():e[t];if(t===ia||t===aa||t===`__proto__`)return a;if(!i){let n=Object.getOwnPropertyDescriptor(e,t);Hr()&&(typeof a!=`function`||e.hasOwnProperty(t))&&!(n&&n.get)&&(a=da(r,t,a)())}return ca(a)?sa(a):a},has(e,t){return t===ra||t===lr||t===dr||t===ia||t===aa||t===`__proto__`||(Hr()&&da(ua(e,aa),t)(),t in e)},set(){return!0},deleteProperty(){return!0},ownKeys:ma,getOwnPropertyDescriptor:fa};function ga(e,t,n,r=!1){if(t===`__proto__`||!r&&e[t]===n)return;let i=e[t],a=e.length;n===void 0?(delete e[t],e[aa]&&e[aa][t]&&i!==void 0&&e[aa][t].$()):(e[t]=n,e[aa]&&e[aa][t]&&i===void 0&&e[aa][t].$());let o=ua(e,ia),s;if((s=da(o,t,i))&&s.$(()=>n),Array.isArray(e)&&e.length!==a){for(let t=e.length;t<a;t++)(s=o[t])&&s.$();(s=da(o,`length`,a))&&s.$(e.length)}(s=o[oa])&&s.$()}function _a(e,t){let n=Object.keys(t);for(let r=0;r<n.length;r+=1){let i=n[r];va(i)||ga(e,i,t[i])}}function va(e){return e===`__proto__`||e===`constructor`||e===`prototype`}function ya(e,t){if(typeof t==`function`&&(t=t(e)),t=la(t),Array.isArray(t)){if(e===t)return;let n=0,r=t.length;for(;n<r;n++){let r=t[n];e[n]!==r&&ga(e,n,r)}ga(e,`length`,r)}else _a(e,t)}function ba(e,t,n=[]){let r,i=e;if(t.length>1){r=t.shift();let a=typeof r,o=Array.isArray(e);if(a===`string`&&(r===`__proto__`||t.length>1&&va(r)))return;if(Array.isArray(r)){for(let i=0;i<r.length;i++)ba(e,[r[i]].concat(t),n);return}if(o&&a===`function`){for(let i=0;i<e.length;i++)r(e[i],i)&&ba(e,[i].concat(t),n);return}if(o&&a===`object`){let{from:i=0,to:a=e.length-1,by:o=1}=r;for(let r=i;r<=a;r+=o)ba(e,[r].concat(t),n);return}if(t.length>1){ba(e[r],t,[r].concat(n));return}i=e[r],n=[r].concat(n)}let a=t[0];typeof a==`function`&&(a=a(i,n),a===i)||(r!==void 0||a!=null)&&(a=la(a),r===void 0||ca(i)&&ca(a)&&!Array.isArray(a)?_a(i,a):ga(e,r,a))}function xa(...[e,t]){let n=la(e||{}),r=Array.isArray(n),i=sa(n);function a(...e){Ir(()=>{r&&e.length===1?ya(n,e[0]):ba(n,e)})}return[i,a]}function Sa(e,t){let n=Reflect.getOwnPropertyDescriptor(e,t);return!n||n.get||n.set||!n.configurable||t===lr||t===ia?n:(delete n.value,delete n.writable,n.get=()=>e[lr][t],n.set=n=>e[lr][t]=n,n)}var Ca={get(e,t,n){if(t===ra)return e;if(t===lr)return n;if(t===dr)return pa(e),n;let r=ua(e,ia),i=r[t],a=i?i():e[t];if(t===ia||t===aa||t===`__proto__`)return a;if(!i){let i=Object.getOwnPropertyDescriptor(e,t),o=typeof a==`function`;if(Hr()&&(!o||e.hasOwnProperty(t))&&!(i&&i.get))a=da(r,t,a)();else if(a!=null&&o&&a===Array.prototype[t])return(...e)=>Ir(()=>Array.prototype[t].apply(n,e))}return ca(a)?wa(a):a},has(e,t){return t===ra||t===lr||t===dr||t===ia||t===aa||t===`__proto__`||(Hr()&&da(ua(e,aa),t)(),t in e)},set(e,t,n){return Ir(()=>ga(e,t,la(n))),!0},deleteProperty(e,t){return Ir(()=>ga(e,t,void 0,!0)),!0},ownKeys:ma,getOwnPropertyDescriptor:Sa};function wa(e){let t=e[lr];if(!t){Object.defineProperty(e,lr,{value:t=new Proxy(e,Ca)});let n=Object.keys(e),r=Object.getOwnPropertyDescriptors(e),i=Object.getPrototypeOf(e),a=i!==null&&typeof e==`object`&&!!e&&!Array.isArray(e)&&i!==Object.prototype;if(a){let e=i;for(;e!=null;){let t=Object.getOwnPropertyDescriptors(e);n.push(...Object.keys(t)),Object.assign(r,t),e=Object.getPrototypeOf(e)}}for(let i=0,o=n.length;i<o;i++){let o=n[i];if(!(a&&o===`constructor`)){if(r[o].get){let n=r[o].get.bind(t);Object.defineProperty(e,o,{get:n,configurable:!0})}if(r[o].set){let n=r[o].set;Object.defineProperty(e,o,{set:e=>Ir(()=>n.call(t,e)),configurable:!0})}}}}return t}function Ta(e,t){return wa(la(e||{}))}function Ea(e,t){Ir(()=>t(la(e)))}var Da=Symbol(`store-root`);function Oa(e){return e===`__proto__`||e===`constructor`||e===`prototype`}function ka(e,t,n,r,i){if(Oa(n))return;let a=t[n];if(e===a)return;let o=Array.isArray(e);if(n!==Da&&(!ca(e)||!ca(a)||o!==Array.isArray(a)||i&&e[i]!==a[i])){ga(t,n,e);return}if(o){if(e.length&&a.length&&(!r||i&&e[0]&&e[0][i]!=null)){let t,n,o,s,c,l,u,d;for(o=0,s=Math.min(a.length,e.length);o<s&&(a[o]===e[o]||i&&a[o]&&e[o]&&a[o][i]&&a[o][i]===e[o][i]);o++)ka(e[o],a,o,r,i);let f=Array(e.length),p=new Map;for(s=a.length-1,c=e.length-1;s>=o&&c>=o&&(a[s]===e[c]||i&&a[s]&&e[c]&&a[s][i]&&a[s][i]===e[c][i]);s--,c--)f[c]=a[s];if(o>c||o>s){for(n=o;n<=c;n++)ga(a,n,e[n]);for(;n<e.length;n++)ga(a,n,f[n]),ka(e[n],a,n,r,i);a.length>e.length&&ga(a,`length`,e.length);return}for(u=Array(c+1),n=c;n>=o;n--)l=e[n],d=i&&l?l[i]:l,t=p.get(d),u[n]=t===void 0?-1:t,p.set(d,n);for(t=o;t<=s;t++)l=a[t],d=i&&l?l[i]:l,n=p.get(d),n!==void 0&&n!==-1&&(f[n]=a[t],n=u[n],p.set(d,n));for(n=o;n<e.length;n++)n in f?(ga(a,n,f[n]),ka(e[n],a,n,r,i)):ga(a,n,e[n])}else for(let t=0,n=e.length;t<n;t++)ka(e[t],a,t,r,i);a.length>e.length&&ga(a,`length`,e.length);return}let s=Object.keys(e);for(let t=0,n=s.length;t<n;t++)Oa(s[t])||ka(e[s[t]],a,s[t],r,i);let c=Object.keys(a);for(let t=0,n=c.length;t<n;t++)e[c[t]]===void 0&&ga(a,c[t],void 0)}function Aa(e,t={}){let{merge:n,key:r=`id`}=t,i=la(e);return e=>{if(!ca(e)||!ca(i))return i;let t=ka(i,{[Da]:e},Da,n,r);return t===void 0?e:t}}var ja=new WeakMap,Ma={get(e,t){if(t===ra)return e;let n=e[t];if(t===lr||t===dr||t===ia||t===aa||t===`__proto__`)return n;let r;return ca(n)?ja.get(n)||(ja.set(n,r=new Proxy(n,Ma)),r):n},set(e,t,n){return ga(e,t,la(n)),!0},deleteProperty(e,t){return ga(e,t,void 0,!0),!0}};function Na(e){return t=>{if(ca(t)){let n;(n=ja.get(t))||ja.set(t,n=new Proxy(t,Ma)),e(n)}return t}}var Pa=class extends t()(`ClientError`,{cause:le()}){},Fa=a.check(Nt(0)),z=a.check(Re(0)),Ia=x.pipe(M(`RelativePath`),O({identifier:`RelativePath`})),La=x.pipe(M(`AbsolutePath`),O({identifier:`AbsolutePath`})),B=e=>tt(e).pipe(wt(i(ue(e)),{decode:b({strict:!1}),encode:ce(Mt(e=>e!==void 0))})),Ra=(e,t)=>Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)),za=e=>t=>Ra(t,e(t)),Ba=P.pipe(wt(re,{decode:m(e=>ke(e)),encode:m(e=>Oe(e))})),Va=`0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz`,Ha=0,Ua=0;function Wa(){return Ka(!1)}function Ga(){return Ka(!0)}function Ka(e,t=Date.now()){t!==Ha&&(Ha=t,Ua=0),Ua++;let n=BigInt(t)*4096n+BigInt(Ua),r=e?~n:n,i=Array.from({length:6},(e,t)=>Number(r>>BigInt(40-8*t)&255n).toString(16).padStart(2,`0`)).join(``),a=crypto.getRandomValues(new Uint8Array(14));return i+Array.from(a,e=>Va[e%62]).join(``)}var qa=x.pipe(M(`Project.ID`),O({identifier:`Project.ID`}),za(e=>({global:e.make(`global`)}))),Ja=x.check(me(`wrk`)).pipe(M(`Workspace.ID`),O({identifier:`Workspace.ID`}),za(e=>{let t=()=>e.make(`wrk_`+Wa());return{ascending:n=>n?e.make(n):t(),create:t}})),Ya=e({Info:()=>Qa,Location:()=>Ya,PublicInfo:()=>$a,PublicRef:()=>Za,Ref:()=>Xa,response:()=>V}),Xa=C({directory:La,workspaceID:B(Ja)}).annotate({identifier:`Location.Ref`}),Za=C(o(Xa.fields,[`workspaceID`])).annotate({identifier:`Location.PublicRef`}),Qa=class extends p(`Location.Info`)({directory:La,workspaceID:B(Ja),project:C({id:qa,directory:La,canonical:La})}){},$a=C(o(Qa.fields,[`workspaceID`])).annotate({identifier:`Location.PublicInfo`});function V(e){return C({location:Za,data:e})}var eo=e({Event:()=>eo,ID:()=>to,Seq:()=>no,Version:()=>ro,durable:()=>H,durableMap:()=>so,ephemeral:()=>U,inventory:()=>W,latest:()=>ao,versionedType:()=>oo}),to=x.check(me(`evt_`)).pipe(M(`Event.ID`),O({identifier:`Event.ID`}),za(e=>({create:()=>e.make(`evt_`+Wa())}))),no=a.check(Re(0)).pipe(M(`Event.Seq`),O({identifier:`Event.Seq`})),ro=a.check(Re(1)).pipe(M(`Event.Version`),O({identifier:`Event.Version`})),io=C({aggregateID:x,seq:no,version:ro});function H(e){let t=C(e.schema),n=C({aggregateID:io.fields.aggregateID,seq:io.fields.seq,version:h(e.durable.version).pipe(wt(ue(ro),we({decode:()=>ro.make(e.durable.version),encode:()=>e.durable.version})))});return C({id:to,created:P,metadata:B(S(x,Ie)),type:h(e.type),durable:n,location:B(Xa),data:t}).annotate({identifier:e.identifier??e.type}).pipe(za(()=>({type:e.type,durability:`durable`,durable:e.durable,data:t})))}function U(e){let t=C(e.schema);return C({id:to,created:P,metadata:B(S(x,Ie)),type:h(e.type),location:B(Xa),data:t}).annotate({identifier:e.identifier??e.type}).pipe(za(()=>({type:e.type,durability:`ephemeral`,durable:void 0,data:t})))}function W(...e){return Object.freeze(e)}function ao(e){return co(e.reduce((e,t)=>{let n=e.get(t.type);if(!n)return e.set(t.type,t),e;if(t.durable&&n.durable&&t.durable.version!==n.durable.version)return t.durable.version>n.durable.version&&e.set(t.type,t),e;if(t!==n)throw Error(`Duplicate latest event definition for ${t.type}`);return e},new Map))}function oo(e,t){return`${e}.${t}`}function so(e){return co(e.reduce((e,t)=>{if(t.durability!==`durable`)return e;let n=oo(t.type,t.durable.version);if(e.has(n))throw Error(`Duplicate durable event definition for ${n}`);return e.set(n,t),e},new Map))}function co(e){let t=Object.freeze({get size(){return e.size},entries:()=>e.entries(),forEach:(n,r)=>e.forEach((e,i)=>n.call(r,e,i,t)),get:t=>e.get(t),has:t=>e.has(t),keys:()=>e.keys(),values:()=>e.values(),[Symbol.iterator]:()=>e[Symbol.iterator]()});return t}var lo=e({DirectorySource:()=>po,EmbeddedSource:()=>vo,Event:()=>_o,ID:()=>uo,Info:()=>ho,Name:()=>fo,Skill:()=>lo,Source:()=>yo,UrlSource:()=>mo}),uo=x.pipe(M(`Skill.ID`),O({identifier:`Skill.ID`})),fo=x.pipe(M(`Skill.Name`),O({identifier:`Skill.Name`})),po=C({type:_(`directory`),path:La}).annotate({identifier:`Skill.DirectorySource`}),mo=C({type:_(`url`),url:x}).annotate({identifier:`Skill.UrlSource`}),ho=C({id:uo,name:fo,description:x.pipe(B),autoinvoke:v.pipe(B),path:La,content:x}).annotate({identifier:`Skill.Info`}),go=U({type:`skill.updated`,schema:{}}),_o={Updated:go,Definitions:W(go)},vo=C({type:_(`embedded`),skill:fe(()=>ho)}).annotate({identifier:`Skill.EmbeddedSource`}),yo=Object.assign(E([po,mo,vo]).pipe(ie(`type`),O({identifier:`Skill.Source`})),{equals:(e,t)=>e.type===t.type?e.type===`directory`&&t.type===`directory`?e.path===t.path:e.type===`url`&&t.type===`url`?e.url===t.url:e.type===`embedded`&&t.type===`embedded`&&e.skill.id===t.skill.id:!1,key:e=>e.type===`directory`?`directory:${e.path}`:e.type===`url`?`url:${e.url}`:`embedded:${e.skill.id}`}),bo=class extends t()(`LocationNotFoundError`,{location:Za,message:x},{httpApiStatus:404}){},xo=class extends t()(`InvalidRequestError`,{message:x,kind:i(x),field:i(x)},{httpApiStatus:400}){},So=class extends t()(`RpcError`,{type:x,message:x,data:i(Ie)},{httpApiStatus:400}){},Co=class extends t()(`RpcInternalError`,{type:y([`rpc.internal`,`rpc.invalid_output`]),message:x,data:i(Ie)},{httpApiStatus:500}){},wo=class extends t()(`UnauthorizedError`,{message:x},{httpApiStatus:401}){},To=class extends t()(`ConflictError`,{message:x,resource:i(x)},{httpApiStatus:409}){},Eo=class extends t()(`SessionBusyError`,{sessionID:x,message:x},{httpApiStatus:409}){},Do=class extends t()(`ServiceUnavailableError`,{message:x,service:i(x)},{httpApiStatus:503}){},Oo=class extends t()(`UnknownError`,{message:x,ref:i(x)},{httpApiStatus:500}){},ko=class extends t()(`ProviderNotFoundError`,{providerID:x,message:x},{httpApiStatus:404}){},Ao=class extends t()(`IntegrationNotFoundError`,{integrationID:x,message:x},{httpApiStatus:404}){},jo=class extends t()(`IntegrationAttemptNotFoundError`,{integrationID:x,attemptID:x,message:x},{httpApiStatus:404}){},Mo=class extends t()(`IntegrationMethodNotFoundError`,{integrationID:x,methodID:x,message:x},{httpApiStatus:404}){},No=class extends t()(`ProjectNotFoundError`,{projectID:x,message:x},{httpApiStatus:404}){},Po=class extends t()(`FileNotFoundError`,{path:x,message:x},{httpApiStatus:404}){},Fo=class extends t()(`PluginNotFoundError`,{pluginID:x,message:x},{httpApiStatus:404}){},Io=class extends t()(`AgentNotFoundError`,{agentID:x,message:x},{httpApiStatus:404}){},G=class extends t()(`SessionNotFoundError`,{sessionID:x,message:x},{httpApiStatus:404}){},Lo=class extends t()(`MessageNotFoundError`,{sessionID:x,messageID:x,message:x},{httpApiStatus:404}){},Ro=class extends t()(`SkillNotFoundError`,{skill:uo,message:x},{httpApiStatus:404}){},zo=class extends t()(`McpServerNotFoundError`,{server:x,message:x},{httpApiStatus:404}){},Bo=class extends t()(`CommandNotFoundError`,{command:x,message:x},{httpApiStatus:404}){},Vo=class extends t()(`CommandExecutionError`,{command:x,message:x},{httpApiStatus:500}){},Ho=class extends t()(`InvalidCursorError`,{message:x},{httpApiStatus:400}){},Uo=class extends t()(`PermissionNotFoundError`,{requestID:x,message:x},{httpApiStatus:404}){},Wo=class extends t()(`PermissionSavedNotFoundError`,{id:x,message:x},{httpApiStatus:404}){},Go=class extends t()(`FormNotFoundError`,{id:x,message:x},{httpApiStatus:404}){},Ko=class extends t()(`FormAlreadySettledError`,{id:x,message:x},{httpApiStatus:409}){},qo=class extends t()(`FormInvalidAnswerError`,{id:x,message:x},{httpApiStatus:400}){},Jo=class extends t()(`ForbiddenError`,{message:x},{httpApiStatus:403}){},Yo=class extends t()(`PtyNotFoundError`,{ptyID:x,message:x},{httpApiStatus:404}){},Xo=class extends t()(`ShellNotFoundError`,{id:x,message:x},{httpApiStatus:404}){},Zo=class extends t()(`ModelNotFoundError`,{providerID:x,modelID:x,message:x},{httpApiStatus:404}){},Qo=class extends t()(`UnsupportedModelError`,{providerID:x,modelID:x,capability:x,message:x},{httpApiStatus:422}){},$o=class extends t()(`ProviderRequestError`,{providerID:x,reason:y([`authentication`,`rate_limit`,`content_filter`,`invalid_request`,`overloaded`,`provider`]),message:x,status:i(a),retryAfterMs:i(a)},{httpApiStatus:502}){},es=class extends Qe()(`@opencode/HttpApiSchemaError`,{error:xo}){},ts=x.pipe(M(`Integration.ID`),O({identifier:`Integration.ID`})),ns=x.pipe(M(`Integration.MethodID`),O({identifier:`Integration.MethodID`})),rs=e({CreateInput:()=>ps,Credential:()=>rs,Entry:()=>fs,Event:()=>ss,External:()=>us,ID:()=>is,Key:()=>ls,OAuth:()=>cs,Value:()=>ds}),is=x.pipe(M(`Credential.ID`),O({identifier:`Credential.ID`}),za(e=>({create:()=>e.make(`cred_`+Wa())}))),as=U({type:`credential.updated`,schema:{}}),os=U({type:`credential.switched`,schema:{integrationID:ts,credentialID:se(is)}}),ss={Updated:as,Switched:os,Definitions:W(as,os)},cs=C({type:h(`oauth`),methodID:ns,refresh:x,access:x,expires:z,metadata:B(S(x,Ie))}).annotate({identifier:`Credential.OAuth`}),ls=C({type:h(`key`),key:x,metadata:B(S(x,Ie))}).annotate({identifier:`Credential.Key`}),us=C({type:h(`external`),methodID:ns,metadata:B(S(x,Ie))}).annotate({identifier:`Credential.External`}),ds=E([cs,ls,us]).pipe(ie(`type`)).annotate({identifier:`Credential.Value`}),fs=C({id:is,integrationID:ts,label:x,active:v,value:ds}).annotate({identifier:`Credential.Entry`}),ps=C({id:B(is),integrationID:ts,label:B(x),value:ds,activate:B(v)}).annotate({identifier:`Credential.CreateInput`}),ms=C({status:y([`needs_auth`]),message:x,url:B(x)}).annotate({identifier:`Connection.Status`}),hs=C({type:h(`credential`),id:is,label:x,method:y([`key`,`oauth`,`external`]),status:B(ms)}).annotate({identifier:`Connection.CredentialInfo`}),gs=C({type:h(`env`),name:x,status:B(ms)}).annotate({identifier:`Connection.EnvInfo`}),_s=E([hs,gs]).pipe(ie(`type`)).annotate({identifier:`Connection.Info`}),vs=e({Answer:()=>Fs,BooleanField:()=>Ds,Detail:()=>Ls,Event:()=>Hs,ExternalField:()=>ks,Field:()=>As,Fields:()=>js,Form:()=>vs,ID:()=>ys,Info:()=>Ns,IntegerField:()=>Es,Metadata:()=>bs,MultiselectField:()=>Os,NumberField:()=>Ts,Option:()=>xs,Reply:()=>Rs,State:()=>Is,StringField:()=>ws,Value:()=>Ps,When:()=>Ss}),ys=x.check(me(`frm_`)).pipe(M(`Form.ID`),O({identifier:`Form.ID`})).pipe(za(e=>({create:t=>e.make(t??`frm_`+Wa())}))),bs=S(x,Ie).annotate({identifier:`Form.Metadata`}),xs=C({value:x,label:x,description:x.pipe(B)}).annotate({identifier:`Form.Option`}),Ss=C({key:x,op:y([`eq`,`neq`]),value:E([x,gt,v])}).annotate({identifier:`Form.When`}),Cs={key:x,title:x.pipe(B),description:x.pipe(B),required:v.pipe(B),hidden:v.pipe(B).annotate({description:`Skip the interactive authentication prompt and use the default unless an answer is supplied`}),when:g(Ss).pipe(B)},ws=C({...Cs,type:h(`string`),format:y([`email`,`uri`,`date`,`date-time`]).pipe(B),minLength:z.pipe(B),maxLength:z.pipe(B),pattern:x.pipe(B),placeholder:x.pipe(B),default:x.pipe(B),options:g(xs).pipe(B),custom:v.pipe(B)}).annotate({identifier:`Form.StringField`}),Ts=C({...Cs,type:h(`number`),minimum:gt.pipe(B),maximum:gt.pipe(B),default:gt.pipe(B)}).annotate({identifier:`Form.NumberField`}),Es=C({...Cs,type:h(`integer`),minimum:gt.pipe(B),maximum:gt.pipe(B),default:gt.pipe(B)}).annotate({identifier:`Form.IntegerField`}),Ds=C({...Cs,type:h(`boolean`),default:v.pipe(B)}).annotate({identifier:`Form.BooleanField`}),Os=C({...Cs,type:h(`multiselect`),options:g(xs),minItems:z.pipe(B),maxItems:z.pipe(B),custom:v.pipe(B),default:g(x).pipe(B)}).annotate({identifier:`Form.MultiselectField`}),ks=C({key:x,type:h(`external`),url:x,title:x.pipe(B),description:x.pipe(B)}).annotate({identifier:`Form.ExternalField`}),As=E([ws,Ts,Es,Ds,Os,ks]).pipe(ie(`type`),O({identifier:`Form.Field`})),js=De(As).annotate({identifier:`Form.Fields`}),Ms={id:ys,sessionID:x,title:x,metadata:bs.pipe(B)},Ns=C({...Ms,fields:js}).annotate({identifier:`Form.Info`}),Ps=E([x,gt,v,g(x)]).annotate({identifier:`Form.Value`}),Fs=S(x,Ps).annotate({identifier:`Form.Answer`}),Is=E([C({status:h(`pending`)}),C({status:h(`answered`),answer:Fs}),C({status:h(`cancelled`),message:x.pipe(B)})]).pipe(ie(`status`)).annotate({identifier:`Form.State`}),Ls=C({...Ns.fields,state:Is}).annotate({identifier:`Form.Detail`}),Rs=C({answer:Fs}).annotate({identifier:`Form.Reply`}),zs=U({type:`form.created`,schema:{form:Ns}}),Bs=U({type:`form.replied`,schema:{id:ys,sessionID:x,answer:Fs}}),Vs=U({type:`form.cancelled`,schema:{id:ys,sessionID:x}}),Hs={Created:zs,Replied:Bs,Cancelled:Vs,Definitions:W(zs,Bs,Vs)},Us=e({Attempt:()=>ic,AttemptID:()=>nc,AttemptStatus:()=>ac,CommandAttempt:()=>oc,CommandAttemptStatus:()=>sc,CommandMethod:()=>qs,EnvMethod:()=>Xs,Event:()=>$s,ExternalMethod:()=>Ys,ID:()=>Ws,Info:()=>tc,Integration:()=>Us,KeyMethod:()=>Js,Method:()=>Zs,MethodID:()=>Gs,OAuthMethod:()=>Ks,Ref:()=>ec}),Ws=ts,Gs=ns,Ks=C({id:Gs,type:h(`oauth`),label:x,form:B(js)}).annotate({identifier:`Integration.OAuthMethod`}),qs=C({id:Gs,type:h(`command`),label:x,command:g(x)}).annotate({identifier:`Integration.CommandMethod`}),Js=C({type:h(`key`),label:B(x),form:B(js)}).annotate({identifier:`Integration.KeyMethod`}),Ys=C({id:Gs,type:h(`external`),label:x,form:B(js)}).annotate({identifier:`Integration.ExternalMethod`}),Xs=C({type:h(`env`),names:g(x)}).annotate({identifier:`Integration.EnvMethod`}),Zs=E([Ks,qs,Js,Ys,Xs]).pipe(ie(`type`)).annotate({identifier:`Integration.Method`}),Qs=U({type:`integration.updated`,schema:{}}),$s={Updated:Qs,Definitions:W(Qs)},ec=C({id:Ws,name:x,metadata:B(S(x,et))}).annotate({identifier:`Integration.Ref`}),tc=C({id:Ws,name:x,metadata:B(S(x,et)),methods:g(Zs),connections:g(_s)}).annotate({identifier:`Integration.Info`}),nc=x.pipe(M(`Integration.AttemptID`),O({identifier:`Integration.AttemptID`}),za(e=>({create:()=>e.make(`con_`+Wa())}))),rc=C({created:gt,expires:gt}),ic=class extends p(`Integration.Attempt`)({attemptID:nc,url:x,instructions:x,mode:y([`auto`,`code`]),time:rc}){},ac=E([C({status:h(`pending`),time:rc}),C({status:h(`complete`),time:rc}),C({status:h(`failed`),message:x,time:rc}),C({status:h(`expired`),time:rc})]).pipe(ie(`status`)).annotate({identifier:`Integration.AttemptStatus`}),oc=C({attemptID:nc,time:rc}).annotate({identifier:`Integration.CommandAttempt`}),sc=E([C({status:h(`pending`),message:B(x),time:rc}),C({status:h(`complete`),time:rc}),C({status:h(`failed`),message:x,time:rc}),C({status:h(`expired`),time:rc})]).pipe(ie(`status`)).annotate({identifier:`Integration.CommandAttemptStatus`}),cc=E([y([`reasoning`,`reasoning_content`,`reasoning_text`]),x]).annotate({identifier:`Model.ReasoningField`}),lc=y([`max_completion_tokens`,`max_tokens`]).annotate({identifier:`Model.MaxTokensField`}),uc=y([`assets`,`state`,`root`]).annotate({identifier:`Model.MediaInput`}),dc=y([`anthropic`,`alibaba`]).annotate({identifier:`Model.CacheFormat`}),fc=C({reasoningField:cc.pipe(B),requireReasoning:v.pipe(B),maxTokensField:lc.pipe(B),requireFinishReason:v.pipe(B),requireAssistantAfterTool:v.pipe(B),supportsPromptCacheKey:v.pipe(B),streamUsage:v.pipe(B),cacheFormat:dc.pipe(B),supportsThinkingBlockBinding:v.pipe(B),supportsEffortUpdates:v.pipe(B),mediaInput:uc.pipe(B)}).annotate({identifier:`Model.Compatibility`}),pc=C(o(fc.fields,[`supportsThinkingBlockBinding`,`supportsEffortUpdates`])).annotate({identifier:`Provider.Compatibility`}),mc=e({Activation:()=>yc,Cache:()=>Cc,CacheTTL:()=>Sc,Compaction:()=>bc,Encoding:()=>wc,Event:()=>_c,ID:()=>hc,Info:()=>kc,Overlays:()=>Dc,Package:()=>vc,Provider:()=>mc,Request:()=>Oc,Settings:()=>Ec,Transport:()=>xc}),hc=x.pipe(M(`Provider.ID`),O({identifier:`Provider.ID`}),za(e=>({opencode:e.make(`opencode`),anthropic:e.make(`anthropic`),openai:e.make(`openai`),google:e.make(`google`),googleVertex:e.make(`google-vertex`),githubCopilot:e.make(`github-copilot`),amazonBedrock:e.make(`amazon-bedrock`),azure:e.make(`azure`),openrouter:e.make(`openrouter`),mistral:e.make(`mistral`),gitlab:e.make(`gitlab`)}))),gc=U({type:`provider.updated`,schema:{}}),_c={Updated:gc,Definitions:W(gc)},vc=x,yc=y([`auto`,`enabled`,`disabled`]),bc=E([C({type:h(`summary`)}),C({type:h(`native`)})]).pipe(ie(`type`)).annotate({identifier:`Provider.Compaction`}),xc=y([`http`,`websocket`]).annotate({identifier:`Provider.Transport`}),Sc=We([gt,y([`ms`,`s`,`m`,`h`,`d`])]).check(Ce(/^\d+(ms|s|m|h|d)$/)).annotate({identifier:`Provider.CacheTTL`}),Cc=C({ttl:Sc.pipe(B)}).annotate({identifier:`Provider.Cache`}),wc=y([`zstd`,`gzip`,`none`]).annotate({identifier:`Provider.Encoding`}),Tc=E([P,h(!1)]).pipe(B),Ec=ge(C({timeout:Tc,headerTimeout:Tc,chunkTimeout:Tc,compaction:bc.pipe(B),cache:Cc.pipe(B),transport:xc.pipe(B),encoding:wc.pipe(B)}),[S(x,et)]).annotate({identifier:`Provider.Settings`}),Dc={settings:Ec.pipe(B),headers:S(x,x).pipe(B),body:S(x,et).pipe(B)},Oc=C({settings:Ec.pipe(ye(Ve({}))),headers:S(x,x),body:S(x,et)}).annotate({identifier:`Provider.Request`}),kc=C({id:hc,canonical:hc.pipe(B),integrationID:Ws.pipe(B),name:x,activation:yc,package:vc,compatibility:pc.pipe(B),...Dc}).annotate({identifier:`Provider.Info`}).pipe(za(()=>({empty:e=>({id:e,name:e,activation:`auto`,package:``})}))),Ac=P.pipe(M(`Money.USD`),O({identifier:`Money.USD`}),za(e=>({zero:e.make(0)}))),jc=P.pipe(M(`Money.USDPerMillionTokens`),O({identifier:`Money.USDPerMillionTokens`}),za(e=>({zero:e.make(0)}))),Mc=e({Capabilities:()=>Hc,Compatibility:()=>fc,Cost:()=>Uc,Event:()=>Fc,Family:()=>Rc,ID:()=>Nc,Info:()=>Gc,MaxTokensField:()=>lc,MediaInput:()=>uc,Model:()=>Mc,Overlays:()=>Vc,ReasoningField:()=>cc,Ref:()=>Lc,Settings:()=>Bc,Type:()=>zc,Variant:()=>Wc,VariantID:()=>Ic}),Nc=x.pipe(M(`Model.ID`)),Pc=U({type:`model.updated`,schema:{}}),Fc={Updated:Pc,Definitions:W(Pc)},Ic=x.pipe(M(`Model.VariantID`)),Lc=C({id:Nc,providerID:hc,variant:Ic.pipe(B)}).annotate({identifier:`Model.Ref`}).pipe(za(e=>({parse:t=>{let n=t.indexOf(`/`);if(n<=0)throw Error(`Invalid model reference: ${t}`);let r=t.slice(0,n),i=t.indexOf(`#`,n+1),a=t.slice(n+1,i===-1?void 0:i),o=i===-1?void 0:t.slice(i+1);if(!a||r.includes(`#`)||o!==void 0&&(!o||o.includes(`#`)))throw Error(`Invalid model reference: ${t}`);return e.make({providerID:hc.make(r),id:Nc.make(a),...o?{variant:Ic.make(o)}:{}})}}))),Rc=x.pipe(M(`Model.Family`)),zc=E([y([`chat`,`decision`,`image`]),x]).annotate({identifier:`Model.Type`}),Bc=ge(C(Ee(Ec.schema.fields,[`compaction`,`cache`,`encoding`])),[S(x,et)]).annotate({identifier:`Model.Settings`}),Vc={settings:Bc.pipe(B),headers:S(x,x).pipe(B),body:S(x,et).pipe(B)},Hc=C({tools:v,input:g(x),output:g(x),temperature:v.pipe(B)}).annotate({identifier:`Model.Capabilities`}).pipe(za(()=>({default:()=>({tools:!0,input:[`text`,`image`],output:[`text`]})}))),Uc=C({tier:C({type:_(`context`),size:a}).pipe(B),input:jc,output:jc,cache:C({read:jc,write:jc})}).annotate({identifier:`Model.Cost`}),Wc=C({id:Ic,...Vc}).annotate({identifier:`Model.Variant`}),Gc=C({id:Nc,modelID:Nc,providerID:hc,canonical:hc.pipe(B),type:zc.pipe(B),family:Rc.pipe(B),name:x,compatibility:fc.pipe(B),package:vc.pipe(B),...Vc,capabilities:Hc,variants:g(Wc),time:C({released:P}),cost:g(Uc),status:y([`alpha`,`beta`,`deprecated`,`active`]),enabled:v,limit:C({context:a,input:a.pipe(B),output:a})}).annotate({identifier:`Model.Info`}).pipe(za(()=>({default:(e,t)=>({id:t,modelID:t,providerID:e,name:t,capabilities:Hc.default(),variants:[],time:{released:0},cost:[],status:`active`,enabled:!0,limit:{context:2e5,output:32e3}})}))),Kc=C({start:P,end:P,text:x}).annotate({identifier:`Prompt.Mention`}),qc=E([C({type:h(`inline`)}),C({type:h(`uri`),uri:x})]).pipe(ie(`type`)).annotate({identifier:`Prompt.FileSource`}),Jc=x.check(rt(e=>e.length%4==0&&/^[A-Za-z0-9+/]*={0,2}$/u.test(e),Ce(/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/u).annotations)).annotate({identifier:`Prompt.Base64`}),Yc=C({data:Jc,mime:x,source:qc,name:x.pipe(B),description:x.pipe(B),mention:Kc.pipe(B)}).annotate({identifier:`Prompt.FileAttachment`}).pipe(za(e=>({create:t=>e.make({data:t.data,mime:t.mime,source:t.source,name:t.name,description:t.description,mention:t.mention})}))),Xc=x.check(Ce(/^media:[0-9a-f]{64}$/)).annotate({identifier:`Prompt.MediaRef`}),{data:Zc,...Qc}=Yc.fields,$c=C({...Qc,uri:Xc,bytes:a.pipe(B),width:a.pipe(B),height:a.pipe(B)}).annotate({identifier:`Prompt.MediaFileAttachment`}),el=E([Yc,$c]).annotate({identifier:`Prompt.Attachment`}),tl=C({name:x,mention:Kc.pipe(B)}).annotate({identifier:`Prompt.AgentAttachment`}),nl=C({id:uo,name:fo,text:x.pipe(B),mention:Kc.pipe(B)}).annotate({identifier:`Prompt.SkillAttachment`}),rl=C({text:x,files:g(Yc).pipe(B),agents:g(tl).pipe(B),skills:g(nl).pipe(B)}).annotate({identifier:`Prompt`}).pipe(za(e=>({equivalence:ee(e),fromUserMessage:t=>e.make({text:t.text,...t.files===void 0?{}:{files:t.files},...t.agents===void 0?{}:{agents:t.agents},...t.skills===void 0?{}:{skills:t.skills}})}))),il=e=>({description:e}),al=C({data:Jc,mime:x,name:x.pipe(B)}).annotate({identifier:`Generate.File`}),ol=C({input:P.pipe(B),output:P.pipe(B)}).annotate({identifier:`Generate.Usage`,description:`Token counts, when the provider reports them`}),sl=S(x,Ie).annotate({identifier:`Generate.Native`,description:`Provider-specific data the shared fields do not cover`}),cl=We([gt,`:`,gt]).check(Ce(/^\d+(?:\.\d+)?:\d+(?:\.\d+)?$/)).annotate({identifier:`Generate.ImageAspect`,description:`Aspect ratio as width:height, for example 16:9`}),ll=E([y([`1K`,`2K`,`4K`]),x]).annotate({identifier:`Generate.ImageResolution`,description:`Size tier such as 1K, 2K or 4K; 1K is about as many pixels as 1024x1024 at the requested aspect`}),ul=C({model:Lc,prompt:x,images:g(al).pipe(B).annotate(il(`Edit sources or style and subject references, in order`)),n:Fa.pipe(B).annotate(il(`Number of images to generate; defaults to 1`)),aspect:cl.pipe(B),resolution:ll.pipe(B)}).annotate({identifier:`Generate.ImageRequest`}),dl=C({type:h(`image`),...al.fields}).annotate({identifier:`Generate.ImageOutput`}),fl=C({images:g(dl),cost:Ac.pipe(B),tokens:ol.pipe(B),native:sl.pipe(B)}).annotate({identifier:`Generate.ImageResult`}),pl=C({type:h(`text`),text:x}).annotate({identifier:`Generate.DecisionTextPart`}),ml=C({type:h(`json`),value:Te}).annotate({identifier:`Generate.DecisionJsonPart`}),hl=C({type:h(`file`),...al.fields}).annotate({identifier:`Generate.DecisionFilePart`}),gl=E([pl,ml,hl]).annotate({identifier:`Generate.DecisionPart`}),_l=E([x,v]).annotate({identifier:`Generate.ChoiceValue`,description:`Choice values are typed: true and "true" are different values`}),vl=x.annotate(il(`Unique within the request; echoed on the matching answer`)),yl=C({type:h(`predicate`),name:vl,instructions:x}).annotate({identifier:`Generate.PredicateQuestion`,description:`The probability that a statement is true`}),bl=C({type:h(`choice`),name:vl,instructions:x,choices:g(C({value:_l,description:x.pipe(B)})).check(c(1))}).annotate({identifier:`Generate.ChoiceQuestion`,description:`Pick one value from a fixed set`}),xl=C({type:h(`score`),name:vl,instructions:x,levels:g(C({label:x,description:x.pipe(B)})).check(c(1))}).annotate({identifier:`Generate.ScoreQuestion`,description:`Place the input on ordered levels, lowest first`}),Sl=E([yl,bl,xl]).annotate({identifier:`Generate.DecisionQuestion`}),Cl=C({model:Lc,input:g(gl).annotate(il(`The evidence every question is asked about, in order`)),questions:g(Sl).check(c(1)).annotate(il(`Question names must be unique; duplicates fail with InvalidRequestError`))}).annotate({identifier:`Generate.DecisionRequest`}),wl=P.check(Dt({minimum:0,maximum:1})),Tl=C({type:h(`predicate`),name:x,probability:wl}).annotate({identifier:`Generate.PredicateAnswer`}),El=C({type:h(`choice`),name:x,choice:_l,probabilities:g(C({value:_l,probability:wl})),confidence:wl}).annotate({identifier:`Generate.ChoiceAnswer`}),Dl=C({type:h(`score`),name:x,score:P.annotate(il(`Probability-weighted level index, so it can fall between levels`)),probabilities:g(C({value:a,label:x,probability:wl})),confidence:wl}).annotate({identifier:`Generate.ScoreAnswer`}),Ol=C({type:h(`error`),name:x,reason:x.annotate(il(`Why the question has no answer, for example refusal`)),message:x.pipe(B)}).annotate({identifier:`Generate.ErrorAnswer`,description:`This one question has no answer; the other answers still came back`}),kl=E([Tl,El,Dl,Ol]).annotate({identifier:`Generate.DecisionAnswer`}),Al=C({answers:g(kl).annotate(il(`One answer per question, in question order`)),cost:Ac.pipe(B),tokens:ol.pipe(B),native:sl.pipe(B)}).annotate({identifier:`Generate.DecisionResult`}),jl=[xo,ko,Zo,Qo,$o,Do,bo],Ml={payload:C({prompt:x,model:Lc.pipe(i)}),success:C({data:C({text:x})}).annotate({identifier:`GenerateTextResponse`}),error:jl},Nl=N(`server.generate`).add(D(`generate.text`,`/api/experimental/generate/text`,Ml).annotateMerge(k({identifier:`experimental.generate.text`,summary:`Generate text`,description:`Run one stateless model generation using the server's base configuration and return the assistant text. Uses the base configuration's default model when none is specified.`}))).add(D(`generate.textLegacy`,`/api/experimental/generate`,Ml).annotateMerge(k({identifier:`experimental.generate.textLegacy`,summary:`Generate text (deprecated path)`,description:`Deprecated alias of POST /api/experimental/generate/text.`,deprecated:!0}))).add(D(`generate.image`,`/api/experimental/generate/image`,{payload:ul,success:C({data:fl}).annotate({identifier:`GenerateImageResponse`}),error:jl}).annotateMerge(k({identifier:`experimental.generate.image`,summary:`Generate images`,description:`Generate or edit images with an image model using the server's base configuration and return them as base64. Stateless: nothing is stored.`}))).add(D(`generate.decisions`,`/api/experimental/generate/decisions`,{payload:Cl,success:C({data:Al}).annotate({identifier:`GenerateDecisionsResponse`}),error:jl}).annotateMerge(k({identifier:`experimental.generate.decisions`,summary:`Generate decisions`,description:`Ask a decision model typed predicate, choice and score questions about the input and return one probability-bearing answer per question, in question order. Stateless: nothing is stored.`}))).annotateMerge(k({title:`generate`,description:`Experimental one-shot generation routes.`})),Pl=x.check(Ce(/^[0-9a-f]{64}$/u)).annotate({identifier:`MediaHash`}),Fl=A(`media.get`,`/api/experimental/media/:hash`,{params:{hash:Pl},success:dt.pipe(mt()),error:[Po,xo]}).annotateMerge(k({identifier:`experimental.media.get`,summary:`Read media blob`,description:`Read a content-addressed media blob by SHA-256 hash with immutable Cache-Control, ETag, and 304 Not Modified support. Only blobs a stored message or inbox item still references are served. Experimental: may change without compatibility guarantees.`,transform:e=>({...e,tags:[`experimental`]})})),Il=e({CreateInput:()=>Wl,Event:()=>Ul,ID:()=>Ll,Info:()=>Rl,Pty:()=>Il,UpdateInput:()=>Gl}),Ll=x.check(me(`pty`)).pipe(M(`PtyID`),O({identifier:`Pty.ID`})).pipe(za(e=>{let t=()=>e.make(`pty_`+Wa());return{create:t,ascending:n=>n===void 0?t():e.make(n)}})),Rl=C({id:Ll,title:x,command:x,args:g(x),cwd:x,status:y([`running`,`exited`]),pid:z,exitCode:B(z)}).annotate({identifier:`Pty`}),zl=U({type:`pty.created`,schema:{info:Rl}}),Bl=U({type:`pty.updated`,schema:{info:Rl}}),Vl=U({type:`pty.exited`,schema:{id:Ll,exitCode:z}}),Hl=U({type:`pty.deleted`,schema:{id:Ll}}),Ul={Created:zl,Updated:Bl,Exited:Vl,Deleted:Hl,Definitions:W(zl,Bl,Vl,Hl)},Wl=C({command:B(x),args:B(g(x)),cwd:B(x),title:B(x),env:B(S(x,x))}),Gl=C({title:B(x),size:B(C({rows:Fa,cols:Fa}))}),Kl=x.check(me(`ses`)).pipe(M(`SessionID`),O({identifier:`Session.ID`}),za(e=>({create:()=>e.make(`ses_`+Ga())}))),ql=e({Effect:()=>nu,Event:()=>tu,ID:()=>Jl,Permission:()=>ql,Reply:()=>Ql,Request:()=>Zl,Rule:()=>ru,Ruleset:()=>iu,Source:()=>Yl}),Jl=x.check(me(`per`)).pipe(M(`Permission.ID`),O({identifier:`Permission.ID`}),za(e=>({create:t=>e.make(t??`per_`+Wa())}))),Yl=E([C({type:h(`tool`),messageID:x,id:x})]).annotate({identifier:`Permission.Source`}),Xl={sessionID:Kl,action:x,resources:g(x),save:g(x).pipe(B),metadata:S(x,Ie).pipe(B),source:Yl.pipe(B),message:x.pipe(B)},Zl=C({id:Jl,...Xl}).annotate({identifier:`Permission.Request`}),Ql=y([`once`,`always`,`reject`]).annotate({identifier:`Permission.Reply`}),$l=U({type:`permission.asked`,schema:Zl.fields}),eu=U({type:`permission.replied`,schema:{sessionID:Kl,requestID:Jl,reply:Ql}}),tu={Asked:$l,Replied:eu,Definitions:W($l,eu)},nu=y([`allow`,`deny`,`ask`]).annotate({identifier:`Permission.Effect`}),ru=C({action:x,resource:x,effect:nu}).annotate({identifier:`Permission.Rule`}),iu=g(ru).annotate({identifier:`Permission.Ruleset`}),au=e({Agent:()=>au,Color:()=>lu,Event:()=>du,ID:()=>su,Info:()=>uu,Name:()=>cu}),ou=U({type:`agent.updated`,schema:{}}),su=x.pipe(M(`Agent.ID`),O({identifier:`Agent.ID`})),cu=x.pipe(M(`Agent.Name`)),lu=x.annotate({identifier:`Agent.Color`}),uu=C({id:su,name:cu,model:Lc.pipe(B),request:Oc,system:x.pipe(B),description:x.pipe(B),mode:y([`subagent`,`primary`,`all`]),hidden:v,color:lu.pipe(B),steps:Fa.pipe(B),permissions:iu}).annotate({identifier:`Agent.Info`}).pipe(za(()=>({default:e=>({id:e,name:cu.make(e),request:{settings:{},headers:{},body:{}},mode:`primary`,hidden:!1,permissions:[{action:`*`,resource:`*`,effect:`allow`},{action:`read`,resource:`*.env`,effect:`ask`},{action:`read`,resource:`*.env.*`,effect:`ask`},{action:`read`,resource:`*.env.example`,effect:`allow`}]})}))),du={Updated:ou,Definitions:W(ou)},fu=e({Commands:()=>_u,Current:()=>hu,Event:()=>Su,ID:()=>pu,Icon:()=>gu,Info:()=>yu,Project:()=>fu,Time:()=>vu,UpdateInput:()=>bu,Vcs:()=>mu}),pu=qa,mu=x.check(Ce(/^[a-z][a-z0-9._-]*$/u)).annotate({identifier:`Project.Vcs`}),hu=C({id:pu,directory:La,canonical:La}).annotate({identifier:`Project.Current`}),gu=C({url:B(x),override:B(x),color:B(x)}).annotate({identifier:`Project.Icon`}),_u=C({start:B(x.annotate({description:`Startup script to run when creating a new workspace (worktree)`}))}).annotate({identifier:`Project.Commands`}),vu=C({created:z,updated:z,active:z,archived:B(z)}).annotate({identifier:`Project.Time`}),yu=C({id:pu,canonical:La,vcs:B(mu),name:B(x),icon:B(gu),commands:B(_u),time:vu,sandboxes:g(x)}).annotate({identifier:`Project`}),bu=C({projectID:pu,canonical:B(La),name:B(x),icon:B(gu),commands:B(_u)}).annotate({identifier:`Project.UpdateInput`}),xu=U({type:`project.updated`,schema:yu.fields}),Su={Updated:xu,Definitions:W(xu)},Cu=y([`stop`,`length`,`tool-calls`,`content-filter`,`error`,`unknown`]);x.pipe(M(`Tool.CallID`)),t()(`Tool.Error`,{message:x,error:i(le()),metadata:i(S(x,Ie))});var wu=C({type:h(`text`),text:x}).annotate({identifier:`Tool.TextContent`}),Tu=C({type:h(`file`),uri:x,mime:x,name:i(x)}).annotate({identifier:`Tool.FileContent`}),Eu=E([wu,Tu]).pipe(ie(`type`)).annotate({identifier:`Tool.Content`}),Du=S(x,Te).annotate({identifier:`Session.Metadata`}),Ou=x.check(me(`sh_`)).pipe(M(`Shell.ID`),O({identifier:`Shell.ID`})).pipe(za(e=>{let t=()=>e.make(`sh_`+Wa());return{create:t,ascending:n=>n===void 0?t():e.make(n)}})),ku=y([`running`,`exited`,`timeout`,`killed`]),Au=C({started:P.annotate({description:`Start time in milliseconds since the Unix epoch`}),completed:B(P).annotate({description:`Completion time in milliseconds since the Unix epoch`})}),ju=S(x,Ie),Mu=C({id:Ou,status:ku,command:x,cwd:x,shell:x,file:x,pid:B(z),exit:B(P),signal:B(x),metadata:ju,time:Au}).annotate({identifier:`Shell.Info`}),Nu=U({type:`shell.created`,schema:{info:Mu}}),Pu=U({type:`shell.exited`,schema:{id:Ou,exit:B(P),status:ku}}),Fu=U({type:`shell.deleted`,schema:{id:Ou}}),Iu={Created:Nu,Exited:Pu,Deleted:Fu,Definitions:W(Nu,Pu,Fu)},Lu=C({command:x,cwd:B(x),timeout:B(z),metadata:B(ju)}),Ru=C({cursor:B(z),limit:B(z)}),zu=C({output:x,cursor:z,size:z,truncated:v}),Bu=C({type:x,message:x,status:a.check(Dt({minimum:100,maximum:599})).pipe(B),response:C({body:x}).pipe(B),retryAfterMs:z.pipe(B)}).annotate({identifier:`Session.StructuredError`}),Vu=x.pipe(M(`Snapshot.ID`),O({identifier:`Snapshot.ID`})),Hu=C({input:P,output:P,reasoning:P,cache:C({read:P,write:P})}).annotate({identifier:`TokenUsage.Info`}),Uu=e({AgentSelected:()=>Ku,Assistant:()=>fd,AssistantContent:()=>ld,AssistantContentEncoded:()=>ud,AssistantReasoning:()=>cd,AssistantRetry:()=>dd,AssistantText:()=>sd,AssistantTool:()=>od,Compaction:()=>vd,CompactionCompleted:()=>gd,CompactionFailed:()=>_d,CompactionRunning:()=>hd,ID:()=>K,Idle:()=>yd,Info:()=>bd,LocationSwitched:()=>Ju,MediaInfo:()=>xd,MediaUser:()=>Xu,ModelSelected:()=>qu,Native:()=>Gu,SessionMessage:()=>Uu,Shell:()=>ed,Skill:()=>$u,Synthetic:()=>Zu,System:()=>Qu,ToolState:()=>ad,ToolStateCompleted:()=>rd,ToolStateError:()=>id,ToolStateRunning:()=>nd,ToolStateStreaming:()=>td,User:()=>Yu}),K=x.check(me(`msg_`)).pipe(M(`Session.Message.ID`),O({identifier:`Session.Message.ID`}),za(e=>({create:()=>e.make(`msg_`+Wa()),fromEvent:t=>e.make(t.replace(/^evt_/,`msg_`))}))),Wu={id:K,metadata:S(x,Ie).pipe(B),time:C({created:Ba})},Gu=S(x,Ie).annotate({identifier:`Session.Message.Native`}),Ku=C({...Wu,type:_(`agent-switched`),agent:su,previous:su.pipe(B)}).annotate({identifier:`Session.Message.AgentSelected`}),qu=C({...Wu,type:_(`model-switched`),model:Lc,previous:Lc.pipe(B)}).annotate({identifier:`Session.Message.ModelSelected`}),Ju=C({...Wu,type:_(`location-switched`),location:Xa,projectID:pu.pipe(B),subpath:Ia.pipe(B),previous:C({location:Xa,projectID:pu.pipe(B),subpath:Ia.pipe(B)}).pipe(B)}).annotate({identifier:`Session.Message.LocationSwitched`}),Yu=C({...Wu,text:rl.fields.text,files:rl.fields.files,agents:rl.fields.agents,skills:rl.fields.skills,type:_(`user`)}).annotate({identifier:`Session.Message.User`}),Xu=C({...Yu.fields,files:g(el).pipe(B)}).annotate({identifier:`Session.Message.MediaUser`}),Zu=C({...Wu,text:x,description:x.pipe(B),type:_(`synthetic`)}).annotate({identifier:`Session.Message.Synthetic`}),Qu=C({...Wu,type:_(`system`),text:x,description:x.pipe(B)}).annotate({identifier:`Session.Message.System`}),$u=C({...Wu,type:_(`skill`),skill:uo,name:fo,text:x}).annotate({identifier:`Session.Message.Skill`}),ed=C({...Wu,type:_(`shell`),shellID:Ou,command:x,status:ku,exit:gt.pipe(B),output:zu.pipe(B),time:C({created:Ba,completed:Ba.pipe(B)})}).annotate({identifier:`Session.Message.Shell`}),td=C({status:_(`streaming`),input:x}).annotate({identifier:`Session.Message.ToolState.Streaming`}),nd=C({status:_(`running`),input:S(x,Ie),metadata:S(x,Te)}).annotate({identifier:`Session.Message.ToolState.Running`}),rd=C({status:_(`completed`),input:S(x,Ie),content:De(Eu),metadata:S(x,Te).pipe(B)}).annotate({identifier:`Session.Message.ToolState.Completed`}),id=C({status:_(`error`),input:S(x,Ie),error:Bu,content:De(Eu).pipe(B),metadata:S(x,Te).pipe(B)}).annotate({identifier:`Session.Message.ToolState.Error`}),ad=E([td,nd,rd,id]).pipe(ie(`status`)),od=C({type:_(`tool`),id:x,name:x,executed:v.pipe(B),native:Gu.pipe(B),state:ad,time:C({created:Ba,ran:Ba.pipe(B),completed:Ba.pipe(B)})}).annotate({identifier:`Session.Message.Assistant.Tool`}),sd=C({type:_(`text`),text:x,native:Gu.pipe(B)}).annotate({identifier:`Session.Message.Assistant.Text`}),cd=C({type:_(`reasoning`),text:x,native:Gu.pipe(B),time:C({created:Ba,completed:Ba.pipe(B)}).pipe(B)}).annotate({identifier:`Session.Message.Assistant.Reasoning`}),ld=E([sd,cd,od]).pipe(ie(`type`)),ud=he(ld).annotate({identifier:`Session.Message.AssistantContent.Encoded`}),dd=C({attempt:Fa,at:Ba,error:Bu}).annotate({identifier:`Session.Message.Assistant.Retry`}),fd=C({...Wu,type:_(`assistant`),agent:su,model:Lc,content:ld.pipe(g),snapshot:C({start:Vu.pipe(B),end:Vu.pipe(B),files:g(Ia).pipe(B)}).pipe(B),finish:Cu.pipe(B),rawFinish:x.pipe(B),native:Gu.pipe(B),cost:Ac.pipe(B),tokens:Hu.pipe(B),error:Bu.pipe(B),retry:dd.pipe(B),time:C({created:Ba,streamed:Ba.pipe(B),completed:Ba.pipe(B)})}).annotate({identifier:`Session.Message.Assistant`}),pd={type:_(`compaction`),...Wu},md={cost:Ac.pipe(B),tokens:Hu.pipe(B)},hd=C({...pd,status:_(`running`),reason:y([`auto`,`manual`]),summary:x}).annotate({identifier:`Session.Message.Compaction.Running`}),gd=C({...pd,status:_(`completed`),reason:y([`auto`,`manual`]),model:Lc.pipe(B),native:Gu.pipe(B),summary:x,...md}).annotate({identifier:`Session.Message.Compaction.Completed`}),_d=C({...pd,status:_(`failed`),reason:y([`auto`,`manual`]),error:Bu,...md}).annotate({identifier:`Session.Message.Compaction.Failed`}),vd=E([hd,gd,_d]).pipe(ie(`status`),O({identifier:`Session.Message.Compaction`})),yd=C({...Wu,type:_(`idle`),outcome:y([`succeeded`,`failed`,`interrupted`]),error:Bu.pipe(B)}).annotate({identifier:`Session.Message.Idle`}),bd=E([Ku,qu,Ju,Yu,Zu,Qu,$u,ed,fd,vd,yd]).annotate({identifier:`Session.Message.Info`}),xd=E([Ku,qu,Ju,Xu,Zu,Qu,$u,ed,fd,vd,yd]).annotate({identifier:`Session.Message.MediaInfo`}),Sd=C({file:x,patch:x,additions:z,deletions:z,status:y([`added`,`deleted`,`modified`]),more:h(!0).pipe(B)}).annotate({identifier:`FileDiff.Info`}),Cd=C({file:x.pipe(B),patch:x.pipe(B),additions:P,deletions:P,status:y([`added`,`deleted`,`modified`]).pipe(B)}).annotate({identifier:`FileDiff.LegacyInfo`}),wd=C({messageID:K,partID:x.pipe(B),snapshot:Vu.pipe(B),files:g(Sd).pipe(B)}).annotate({identifier:`Session.Revert`}),Td=C({path:x,status:y([`added`,`modified`,`deleted`]),additions:P,deletions:P,patch:x}),Ed=C({messageID:K,partID:x.pipe(B),snapshot:x.pipe(B),diff:x.pipe(B),files:g(Td).pipe(B)}).annotate({identifier:`Session.RevertV1`}),Dd=wd.pipe(wt(C({source:_(`current`),revert:ue(wd)}),we({decode:e=>({source:`current`,revert:e}),encode:e=>e.revert}))),Od=Ed.pipe(wt(C({source:_(`legacy`),revert:ue(Ed)}),we({decode:e=>({source:`legacy`,revert:e}),encode:e=>e.revert})));E([Dd,Od]).pipe(ie(`source`),wt(ue(wd),we({decode:e=>e.source===`current`?e.revert:wd.make({messageID:e.revert.messageID,partID:e.revert.partID,snapshot:e.revert.snapshot?Vu.make(e.revert.snapshot):void 0,files:e.revert.files?.map(e=>({file:e.path,status:e.status,additions:e.additions,deletions:e.deletions,patch:e.patch}))}),encode:e=>({source:`current`,revert:e})})),O({identifier:`Session.Revert.Persisted`}));var kd=x.check(Ce(/^[a-z0-9][a-z0-9._-]*\/[a-z0-9][a-z0-9._/-]*$/u)).pipe(M(`Instruction.Key`),O({identifier:`Instruction.Key`})),Ad=x.check(Ce(/^[a-f0-9]{64}$/u)).pipe(M(`Instruction.Hash`),O({identifier:`Instruction.Hash`})),jd=S(kd,Ad),Md=h(`removed`);Md.make(`removed`);var Nd=S(x,E([Ad,Md])),Pd=x.check(Ce(/^[a-z0-9][a-z0-9._-]*$/u)).annotate({identifier:`InstructionEntry.Key`,description:`Instruction entry key (lowercase alphanumerics plus . _ -)`}),Fd=C({key:Pd,value:Te.annotate({description:`JSON value attached to the session's instructions`})}).annotate({identifier:`InstructionEntry.Info`}),Id=g(C({...Fd.fields,removed:v})).annotate({identifier:`InstructionEntry.Snapshot`}),Ld=class extends t()(`InstructionEntryValueTooLargeError`,{actualBytes:a,maxBytes:a,message:x},{httpApiStatus:413}){},Rd=e({Compaction:()=>ef,CompactionPayload:()=>Ud,Delivery:()=>zd,Info:()=>nf,Item:()=>Yd,MediaInfo:()=>rf,MediaUser:()=>Qd,MediaUserPayload:()=>Vd,Move:()=>tf,MovePayload:()=>Wd,SessionInbox:()=>Rd,Synthetic:()=>$d,SyntheticPayload:()=>Hd,User:()=>Zd,UserPayload:()=>Bd}),zd=y([`steer`,`queue`]).annotate({identifier:`Session.Inbox.Delivery`}),Bd=C({...rl.fields,metadata:S(x,Ie).pipe(B)}).annotate({identifier:`Session.Inbox.UserPayload`}),Vd=C({...Bd.fields,files:g(el).pipe(B)}).annotate({identifier:`Session.Inbox.MediaUserPayload`}),Hd=C({text:x,description:x.pipe(B),metadata:S(x,Ie).pipe(B)}).annotate({identifier:`Session.Inbox.SyntheticPayload`}),Ud=C({}).annotate({identifier:`Session.Inbox.CompactionPayload`}),Wd=C({location:Xa,projectID:pu,subpath:Ia.pipe(B)}).annotate({identifier:`Session.Inbox.MovePayload`}),Gd=C({type:_(`user`),payload:Bd,delivery:zd}),Kd=C({type:_(`synthetic`),payload:Hd,delivery:zd}),qd=C({type:_(`compaction`),payload:Ud,delivery:zd}),Jd=C({type:_(`move`),payload:Wd,delivery:zd}),Yd=E([Gd,Kd,qd,Jd]).pipe(ie(`type`),O({identifier:`Session.Inbox.Item`})),Xd={id:K,sessionID:Kl,time:C({created:Ba})},Zd=C({...Xd,...Gd.fields}).annotate({identifier:`Session.Inbox.User`}),Qd=C({...Zd.fields,payload:Vd}).annotate({identifier:`Session.Inbox.MediaUser`}),$d=C({...Xd,...Kd.fields}).annotate({identifier:`Session.Inbox.Synthetic`}),ef=C({...Xd,...qd.fields}).annotate({identifier:`Session.Inbox.Compaction`}),tf=C({...Xd,...Jd.fields}).annotate({identifier:`Session.Inbox.Move`}),nf=E([Zd,$d,ef,tf]).pipe(ie(`type`),O({identifier:`Session.Inbox.Info`})),rf=E([Qd,$d,ef,tf]).pipe(ie(`type`),O({identifier:`Session.Inbox.MediaInfo`})),af=E([C({type:h(`before`),messageID:K}),C({type:h(`through`),messageID:K})]).annotate({identifier:`Session.ForkBoundary`}),of=e({AgentSelected:()=>cf,All:()=>Uf,Archived:()=>hf,Compaction:()=>Lf,Created:()=>sf,Definitions:()=>zf,Deleted:()=>bf,Durable:()=>Hf,DurableDefinitions:()=>Bf,EphemeralDefinitions:()=>Vf,Execution:()=>Df,Forked:()=>xf,InboxCancelled:()=>Tf,InboxDelivered:()=>Cf,InboxDeliveryChanged:()=>Ef,InboxEnqueued:()=>wf,InstructionsUpdated:()=>Of,MessageContentUpdated:()=>_f,MetadataUpdated:()=>ff,ModelSelected:()=>lf,Moved:()=>uf,Permissions:()=>pf,Reasoning:()=>Pf,Renamed:()=>df,RetryScheduled:()=>If,RevertEvent:()=>Rf,SessionEvent:()=>of,Shell:()=>jf,Skill:()=>Af,Step:()=>Mf,Synthetic:()=>kf,Text:()=>Nf,Tool:()=>Ff,Unarchived:()=>gf,UsageRecorded:()=>vf,UsageUpdated:()=>yf,Viewed:()=>mf}),q={sessionID:Kl},J={durable:{aggregate:`sessionID`,version:1}},sf=H({type:`session.created`,...J,schema:{...q,projectID:pu,location:Xa,subpath:Ia.pipe(B),parentID:Kl.pipe(B),slug:x,title:x.pipe(B),agent:su.pipe(B),model:Lc.pipe(B),metadata:Du.pipe(B),permissions:iu.pipe(B),version:x}}),cf=H({type:`session.agent.selected`,...J,schema:{...q,agent:su,previous:su.pipe(B)}}),lf=H({type:`session.model.selected`,...J,schema:{...q,model:Lc,previous:Lc.pipe(B)}}),uf=H({type:`session.moved`,...J,schema:{...q,...Wd.fields}}),df=H({type:`session.renamed`,...J,schema:{...q,title:x}}),ff=H({type:`session.metadata.updated`,...J,schema:{...q,metadata:Du}}),pf=H({type:`session.permissions`,...J,schema:{...q,permissions:iu}}),mf=H({type:`session.viewed`,...J,schema:{...q,idle:P}}),hf=H({type:`session.archived`,...J,schema:q}),gf=H({type:`session.unarchived`,...J,schema:q}),_f=H({type:`session.message.content.updated`,...J,schema:{...q,messageID:K,content:g(ud)}}),vf=H({type:`session.usage.recorded`,...J,schema:{...q,source:y([`title`,`compaction`]),cost:Ac,tokens:Hu}}),yf=U({type:`session.usage.updated`,schema:{...q,cost:Ac,tokens:Hu}}),bf=H({type:`session.deleted`,durable:{aggregate:`sessionID`,version:2},schema:q}),xf=H({type:`session.forked`,durable:{aggregate:`sessionID`,version:2},schema:{...q,parentID:Kl,boundary:af,instructions:jd.pipe(B),instructionEntries:Id.pipe(B)}}),Sf={...q,inboxID:K},Cf=H({type:`session.inbox.delivered`,...J,schema:Sf}),wf=H({type:`session.inbox.enqueued`,...J,schema:{...Sf,item:Yd}}),Tf=H({type:`session.inbox.cancelled`,...J,schema:Sf}),Ef=H({type:`session.inbox.delivery.changed`,...J,schema:{...Sf,delivery:zd}}),Df;(function(e){e.Started=H({type:`session.execution.started`,...J,schema:q}),e.Succeeded=H({type:`session.execution.succeeded`,...J,schema:q}),e.Failed=H({type:`session.execution.failed`,...J,schema:{...q,error:Bu}}),e.Interrupted=H({type:`session.execution.interrupted`,...J,schema:{...q,reason:y([`user`,`shutdown`,`superseded`,`inactivity`])}})})(Df||={});var Of=H({type:`session.instructions.updated`,durable:{aggregate:`sessionID`,version:2},schema:{...q,delta:Nd,text:x.pipe(B)}}),kf=H({type:`session.synthetic`,...J,schema:{...q,text:x,description:x.pipe(B),metadata:S(x,Ie).pipe(B)}}),Af;(function(e){e.Activated=H({type:`session.skill.activated`,...J,schema:{...q,id:uo,name:fo,text:x}})})(Af||={});var jf;(function(e){e.Started=H({type:`session.shell.started`,...J,schema:{...q,shell:Mu}}),e.Ended=H({type:`session.shell.ended`,...J,schema:{...q,shell:Mu,output:zu}})})(jf||={});var Mf;(function(e){e.Started=H({type:`session.step.started`,...J,schema:{...q,assistantMessageID:K,agent:su,model:Lc,snapshot:Vu.pipe(B),started:z}}),e.Streamed=H({type:`session.step.streamed`,...J,schema:{...q,assistantMessageID:K}}),e.Ended=H({type:`session.step.ended`,...J,schema:{...q,assistantMessageID:K,finish:Cu,rawFinish:x.pipe(B),native:Gu.pipe(B),cost:Ac,tokens:Hu,snapshot:Vu.pipe(B),files:g(Ia).pipe(B)}}),e.Failed=H({type:`session.step.failed`,...J,schema:{...q,assistantMessageID:K,error:Bu,finish:y([`content-filter`]).pipe(B),rawFinish:x.pipe(B),native:Gu.pipe(B),cost:Ac.pipe(B),tokens:Hu.pipe(B),snapshot:Vu.pipe(B),files:g(Ia).pipe(B)}})})(Mf||={});var Nf;(function(e){e.Started=H({type:`session.text.started`,...J,schema:{...q,assistantMessageID:K,ordinal:z}}),e.Delta=U({type:`session.text.delta`,schema:{...q,assistantMessageID:K,ordinal:z,delta:x}}),e.Ended=H({type:`session.text.ended`,...J,schema:{...q,assistantMessageID:K,ordinal:z,text:x,native:Gu.pipe(B)}})})(Nf||={});var Pf;(function(e){e.Started=H({type:`session.reasoning.started`,...J,schema:{...q,assistantMessageID:K,ordinal:z,native:Gu.pipe(B)}}),e.Delta=U({type:`session.reasoning.delta`,schema:{...q,assistantMessageID:K,ordinal:z,delta:x}}),e.Ended=H({type:`session.reasoning.ended`,...J,schema:{...q,assistantMessageID:K,ordinal:z,text:x,native:Gu.pipe(B)}})})(Pf||={});var Ff;(function(e){let t={...q,assistantMessageID:K,id:x};(function(e){e.Started=H({type:`session.tool.input.started`,...J,schema:{...t,name:x}}),e.Delta=U({type:`session.tool.input.delta`,schema:{...t,delta:x}}),e.Ended=H({type:`session.tool.input.ended`,...J,schema:{...t,text:x}})})(e.Input||={}),e.Called=H({type:`session.tool.called`,...J,schema:{...t,input:S(x,Ie),executed:v,native:Gu.pipe(B)}}),e.Progress=U({type:`session.tool.progress`,schema:{...t,metadata:S(x,Te)}}),e.Success=H({type:`session.tool.success`,durable:{aggregate:`sessionID`,version:2},schema:{...t,content:De(Eu),metadata:S(x,Te).pipe(B),executed:v,native:Gu.pipe(B)}}),e.Failed=H({type:`session.tool.failed`,durable:{aggregate:`sessionID`,version:2},schema:{...t,error:Bu,content:De(Eu).pipe(B),metadata:S(x,Te).pipe(B),executed:v,native:Gu.pipe(B)}})})(Ff||={});var If=H({type:`session.retry.scheduled`,...J,schema:{...q,assistantMessageID:K,attempt:Fa,at:z,error:Bu}}),Lf;(function(e){e.Started=H({type:`session.compaction.started`,...J,schema:{...q,reason:y([`auto`,`manual`]),inputID:K.pipe(B)}}),e.Delta=U({type:`session.compaction.delta`,schema:{...q,text:x}}),e.Ended=H({type:`session.compaction.ended`,...J,schema:{...q,reason:e.Started.data.fields.reason,model:gd.fields.model,native:gd.fields.native,text:x,cost:gd.fields.cost,tokens:gd.fields.tokens}}),e.Failed=H({type:`session.compaction.failed`,...J,schema:{...q,reason:e.Started.data.fields.reason,error:Bu,inputID:K.pipe(B),cost:_d.fields.cost,tokens:_d.fields.tokens}})})(Lf||={});var Rf;(function(e){e.Staged=H({type:`session.revert.staged`,...J,schema:{...q,revert:wd}}),e.Cleared=H({type:`session.revert.cleared`,...J,schema:q}),e.Committed=H({type:`session.revert.committed`,...J,schema:{...q,to:K}})})(Rf||={});var zf=W(sf,cf,lf,uf,df,ff,pf,mf,hf,gf,yf,bf,xf,Cf,wf,Tf,Ef,Df.Started,Df.Succeeded,Df.Failed,Df.Interrupted,Of,kf,Af.Activated,jf.Started,jf.Ended,Mf.Started,Mf.Streamed,Mf.Ended,Mf.Failed,Nf.Started,Nf.Delta,Nf.Ended,Pf.Started,Pf.Delta,Pf.Ended,Ff.Input.Started,Ff.Input.Delta,Ff.Input.Ended,Ff.Called,Ff.Progress,Ff.Success,Ff.Failed,If,Lf.Started,Lf.Delta,Lf.Ended,Lf.Failed,Rf.Staged,Rf.Cleared,Rf.Committed),Bf=W(...zf.filter(e=>e.durability===`durable`),vf,_f),Vf=W(...zf.filter(e=>e.durability===`ephemeral`)),Hf=E(Bf,{mode:`oneOf`}).annotate({identifier:`Session.Event.Durable`}).pipe(ie(`type`)),Uf=E([Hf,...Vf],{mode:`oneOf`}).pipe(ie(`type`)),Wf=e({Event:()=>Kf,ForkBoundary:()=>qf,ID:()=>Y,Info:()=>Jf,ListAnchor:()=>Yf,ListCursor:()=>np,ListFilter:()=>Zf,Metadata:()=>Gf,Revert:()=>wd,Session:()=>Wf}),Y=Kl,Gf=Du,Kf=of,qf=af,Jf=C({id:Y,parentID:Y.pipe(B),fork:C({sessionID:Y,boundary:qf}).pipe(B),projectID:pu,agent:su.pipe(B),model:Lc.pipe(B),cost:Ac,tokens:Hu,outcome:y([`succeeded`,`failed`,`interrupted`]).pipe(B),time:C({created:Ba,updated:Ba,idle:Ba.pipe(B),viewed:Ba.pipe(B),archived:Ba.pipe(B)}),title:x.pipe(B),location:Xa,subpath:Ia.pipe(B),metadata:Gf.pipe(B),permissions:iu.pipe(B),revert:wd.pipe(B)}).annotate({identifier:`Session.Info`}),Yf=C({id:Y,time:P,direction:y([`previous`,`next`])}).annotate({identifier:`Session.ListAnchor`}),Xf={order:y([`asc`,`desc`]).pipe(i).annotate({description:`Session order for the first page. Use desc for newest first or asc for oldest first.`}),search:x.pipe(i),parentID:E([Y,te.pipe(Ze(h(`null`),{decode:m(()=>null),encode:m(()=>`null`)}))]).annotate({description:`Filter by parent session. Use null to return only root sessions.`}).pipe(i),archived:y([`true`,`false`]).pipe(wt(v,{decode:m(e=>e===`true`),encode:m(e=>e?`true`:`false`)})).annotate({description:`Filter by archive state. Use true to return only archived sessions or false to exclude them. Omit to include both.`}).pipe(i)},Zf=C({...Xf,directory:La.pipe(i),project:pu.pipe(i),subpath:Ia.pipe(i)}).annotate({identifier:`Session.ListFilter`}),Qf=E([C({...Xf,directory:La,anchor:Yf}),C({...Xf,project:pu,subpath:Ia.pipe(i),anchor:Yf}),C({...Xf,anchor:Yf})]),$f=Ne(Qf),ep=ct($f),tp=He($f),np=x.pipe(M(`SessionsCursor`),O({identifier:`SessionsCursor`,description:`Opaque pagination cursor returned as cursor.previous or cursor.next in the previous response.`}),za(e=>{let t=ne(e);return{make:e=>t(oe(ep(e))),parse:e=>ht(()=>{let t=_t(e);return Me(t)?ut(`Invalid cursor`):tp(t.success).pipe(w(()=>`Invalid cursor`))})}})),rp=C({...Rl.fields,sessionID:Y,foregroundProcess:se(x),size:C({cols:Fa,rows:Fa}),output:C({head:z,tail:z})}).annotate({identifier:`PersistentPty.Info`}),ip=C({directory:x,instanceID:x,ticket:x,expiresAt:gt}).annotate({identifier:`PersistentPty.Handoff`}),ap=C({command:B(x),args:g(x),cwd:B(x),title:x,env:S(x,x),size:B(C({cols:Fa,rows:Fa}))}).annotate({identifier:`PersistentPty.CreateInput`}),op=C({attachmentID:B(x),size:C({cols:Fa,rows:Fa})}).annotate({identifier:`PersistentPty.UpdateInput`}),sp=C({info:rp,text:x,checkpoint:dt,cursor:C({x:z,y:z})}).annotate({identifier:`PersistentPty.Snapshot`}),cp=Fa.check(xe(65535)).annotate({identifier:`PersistentPty.ReadLines`}),lp=C({ptyID:Ll,title:x,cwd:x,foregroundProcess:se(x),screen:C({text:x,cols:Fa,rows:Fa,cursor:sp.fields.cursor})}).annotate({identifier:`PersistentPty.ReadResult`}),up=U({type:`persistent-pty.added`,schema:{sessionID:Y,terminal:rp}}),dp=U({type:`persistent-pty.removed`,schema:{sessionID:Y,ptyID:Ll}}),fp={Added:up,Removed:dp,Definitions:W(up,dp)},pp=C({ticket:x,expires_in:Fa}).annotate({identifier:`PtyTicket.ConnectToken`}),X=C({location:i(C({directory:i(x)}))}).annotate({identifier:`LocationQuery`}),Z=k({transform:e=>{let t=e.parameters;return Array.isArray(t)?{...e,parameters:t.map(e=>e?.name===`location`&&e?.in===`query`?{...e,style:`deepObject`,explode:!0}:e)}:e}}),mp=e=>N(`server.location`).add(A(`location.get`,`/api/location`,{query:X,success:$a}).middleware(e).annotateMerge(Z).annotateMerge(k({identifier:`location.get`,summary:`Get location`,description:`Resolve the requested location or the server default location.`}))).add(D(`location.reload`,`/api/location/reload`,{success:T,error:Do}).annotateMerge(k({identifier:`location.reload`,summary:`Reload configuration`,description:`Shut down and rebuild every loaded location. Pending permissions and forms are cancelled; running sessions continue with fresh services at the next step boundary. Emits location.shutdown for client recovery and responds once all replacement builds settle.`}))).annotateMerge(k({title:`location`})),hp=`ticket`,gp=`x-opencode-ticket`,_p=`/api/pty/:ptyID/connect`,vp=e=>N(`server.pty`).add(A(`pty.list`,`/api/pty`,{query:X,success:V(g(Rl))}).annotateMerge(Z).annotateMerge(k({identifier:`pty.list`,summary:`List PTY sessions`,description:`List PTY sessions for a location, including exited sessions retained until removal.`}))).add(D(`pty.create`,`/api/pty`,{query:X,payload:Wl,success:V(Rl)}).annotateMerge(Z).annotateMerge(k({identifier:`pty.create`,summary:`Create PTY session`,description:`Create a pseudo-terminal session for a location.`}))).add(A(`pty.get`,`/api/pty/:ptyID`,{params:{ptyID:Ll},query:X,success:V(Rl),error:Yo}).annotateMerge(Z).annotateMerge(k({identifier:`pty.get`,summary:`Get PTY session`,description:`Get one PTY session, including its exit code once exited.`}))).add(St(`pty.update`,`/api/pty/:ptyID`,{params:{ptyID:Ll},query:X,payload:Gl,success:V(Rl),error:Yo}).annotateMerge(Z).annotateMerge(k({identifier:`pty.update`,summary:`Update PTY session`,description:`Update the title or viewport size of one PTY session.`}))).add(ft(`pty.remove`,`/api/pty/:ptyID`,{params:{ptyID:Ll},query:X,success:T,error:Yo}).annotateMerge(Z).annotateMerge(k({identifier:`pty.remove`,summary:`Remove PTY session`,description:`Terminate and remove one PTY session.`}))).add(D(`pty.connectToken`,`/api/pty/:ptyID/connect-token`,{params:{ptyID:Ll},query:X,headers:C({[gp]:i(x)}),success:V(pp),error:[Jo,Yo]}).annotateMerge(Z).annotateMerge(k({identifier:`pty.connect.token`,summary:`Create PTY WebSocket token`,description:`Create a short-lived single-use ticket for opening a PTY WebSocket connection.`}))).middleware(e).add(A(`pty.connect`,_p,{params:{ptyID:Ll},success:v,error:[Jo,Yo,bo]}).annotateMerge(k({identifier:`pty.connect`,summary:`Connect to PTY session`,description:`Establish a WebSocket connection streaming PTY output and accepting terminal input.`,transform:e=>({...e,"x-websocket":!0,parameters:[...e.parameters??[],...[`location[directory]`,`cursor`,hp].map(e=>({in:`query`,name:e,schema:{type:`string`}}))]})}))).annotateMerge(k({title:`pty`,description:`Experimental location-scoped PTY routes.`})),yp=`/api/experimental/persistent-pty/:ptyID/connect`,bp=[xo,Do],xp=[Yo,Do],Sp=N(`server.experimental`).add(A(`persistentPty.read`,`/api/experimental/session/:sessionID/terminal/read`,{params:{sessionID:Y},query:{lines:ae.pipe(wt(cp),i)},success:C({data:se(lp)}),error:[Do]}).annotateMerge(k({summary:`Read the session's most recently controlled terminal`,description:`Read the last physical rows without changing selection or taking control. Omitted lines uses the live terminal height; larger counts include retained history. Blank rows are preserved. Screen dimensions and cursor remain relative to the live screen. Returns null when no current terminal exists. Selection is server-local and resets on restart. Experimental: may change without compatibility guarantees.`}))).add(A(`persistentPty.list`,`/api/experimental/session/:sessionID/terminal`,{params:{sessionID:Y},success:C({data:g(rp)}),error:bp})).add(D(`persistentPty.create`,`/api/experimental/session/:sessionID/terminal`,{params:{sessionID:Y},payload:ap,success:C({data:rp}),error:bp})).add(D(`persistentPty.shutdown`,`/api/experimental/persistent-pty/shutdown`,{success:T,error:[Do]})).add(D(`persistentPty.handoff`,`/api/experimental/persistent-pty/handoff`,{success:C({handoff:se(ip)}),error:[Do]})).add(A(`persistentPty.get`,`/api/experimental/persistent-pty/:ptyID`,{params:{ptyID:Ll},success:C({data:rp}),error:xp})).add(St(`persistentPty.update`,`/api/experimental/persistent-pty/:ptyID`,{params:{ptyID:Ll},payload:op,success:C({data:rp}),error:xp})).add(A(`persistentPty.snapshot`,`/api/experimental/persistent-pty/:ptyID/snapshot`,{params:{ptyID:Ll},success:C({data:sp}),error:xp})).add(ft(`persistentPty.remove`,`/api/experimental/persistent-pty/:ptyID`,{params:{ptyID:Ll},success:T,error:xp})).add(D(`persistentPty.connectToken`,`/api/experimental/persistent-pty/:ptyID/connect-token`,{params:{ptyID:Ll},headers:C({[gp]:i(x)}),success:C({data:pp}),error:[Jo,Yo,Do]})).add(A(`persistentPty.connect`,yp,{params:{ptyID:Ll},success:v,error:[Jo,Yo,Do]}).annotateMerge(k({identifier:`persistentPty.connect`,summary:`Connect to a persistent PTY`,description:`Stream persistent PTY output through the OpenCode server.`,transform:e=>({...e,"x-websocket":!0,parameters:[...e.parameters??[],...[`cursor`,`role`,`attachment_id`,`takeover`,`input_protocol`,hp].map(e=>({in:`query`,name:e,schema:{type:`string`}}))]})}))).annotateMerge(k({title:`persistentPty`,description:`Prototype persistent PTY routes.`})).add(Fl),Cp=y([`webrtc`,`websocket`]).annotate({identifier:`VoiceTransportType`}),wp=C({model:x,provider:x,transports:g(Cp),available:v}).annotate({identifier:`VoiceModel`}),Tp=C({type:h(`webrtc`),sdp:x,dcid:i(gt)}).annotate({identifier:`VoiceWebRTCTransportInput`}),Ep=C({type:h(`websocket`)}).annotate({identifier:`VoiceWebSocketTransportInput`}),Dp=E([Tp,Ep]).annotate({identifier:`VoiceTransportInput`}),Op=C({type:h(`webrtc`),sdp:x}).annotate({identifier:`VoiceWebRTCTransport`}),kp=C({type:h(`websocket`),url:x,token:x,expiresAt:gt}).annotate({identifier:`VoiceWebSocketTransport`}),Ap=E([Op,kp]).annotate({identifier:`VoiceTransport`}),jp=N(`server.voice`).add(A(`voice.models`,`/api/experimental/voice/models`,{success:C({data:C({models:g(wp),default:i(x)})}).annotate({identifier:`VoiceModelsResponse`}),error:[Do,bo]}).annotateMerge(k({identifier:`experimental.voice.models`,summary:`List voice models`,description:`List supported voice models, their transports, and whether the server has a usable API key for each provider.`}))).add(D(`voice.session`,`/api/experimental/voice/session`,{payload:C({model:x,session:i(S(x,Ie)),transport:Dp}),success:C({data:C({transport:Ap})}).annotate({identifier:`VoiceSessionResponse`}),error:[xo,Do,bo]}).annotateMerge(k({identifier:`experimental.voice.session`,summary:`Create voice session`,description:`Create a server-brokered voice session using the server's configured provider credentials and return the WebRTC SDP answer or WebSocket ephemeral token.`}))).annotateMerge(k({title:`voice`,description:`Experimental server-brokered voice session routes.`})),Mp=C({limit:i(ae.check(jt(),Re(1),xe(200))).annotate({description:`Maximum number of messages to return. When omitted, the endpoint returns its default page size.`}),order:i(E([h(`asc`),h(`desc`)])).annotate({description:`Message order for the first page. Use desc for newest first or asc for oldest first.`}),cursor:i(x.annotate({description:`Opaque pagination cursor returned as cursor.previous or cursor.next in the previous response. Do not combine with order.`})),type:i(y(Object.keys({"agent-switched":!0,"model-switched":!0,"location-switched":!0,user:!0,synthetic:!0,system:!0,skill:!0,shell:!0,assistant:!0,compaction:!0,idle:!0}))).annotate({description:`Filter by message type before pagination. When omitted, all message types are returned. Pass the same type when following cursors.`})}).annotate({identifier:`SessionMessagesQuery`}),Np=C({...o(Ju.fields,[`location`,`previous`]),location:Za,previous:C({location:Za,projectID:Ju.fields.projectID,subpath:Ju.fields.subpath}).pipe(i)}).annotate({identifier:`Session.Message.LocationSwitched`}),Pp=E([Ku,qu,Np,Yu,Zu,Qu,$u,ed,fd,vd,yd]).annotate({identifier:`Session.Message.Info`}),Fp=E([Ku,qu,Np,Xu,Zu,Qu,$u,ed,fd,vd,yd]).annotate({identifier:`Session.Message.MediaInfo`}),Ip=C({previous:x.pipe(i),next:x.pipe(i)});C({data:g(Fp),cursor:Ip}),C({data:Fp});var Lp=N(`server.message`).add(A(`session.messages`,`/api/session/:sessionID/message`,{params:{sessionID:Y},query:Mp,success:C({data:g(Pp),cursor:Ip}).annotate({identifier:`SessionMessagesResponse`}),error:[Ho,G,Oo]}).annotateMerge(k({identifier:`session.message.list`,summary:`Get session messages`,description:`Retrieve projected messages for a session, optionally filtered by type. Items keep the requested order across pages; use cursor.next or cursor.previous to move through the ordered timeline, passing the same type filter on each page.`}))).annotateMerge(k({title:`session`,description:`Experimental message routes.`})),Rp=C({...X.fields,types:i(de(zc)).annotate({description:`Only list models of these types. Defaults to chat, the only type offered for sessions.`})}),zp=N(`server.model`).add(A(`model.list`,`/api/model`,{query:Rp,success:V(g(Gc)),error:Do}).annotateMerge(Z).annotateMerge(k({identifier:`model.list`,summary:`List models`,description:`Retrieve the current snapshot of available models of the requested types, chat by default, ordered by release date within each type. The snapshot may precede initial plugin settlement.`}))).add(A(`model.default`,`/api/model/default`,{query:X,success:V(yt(Gc)),error:Do}).annotateMerge(Z).annotateMerge(k({identifier:`model.default`,summary:`Get default model`,description:`Retrieve the model used when a session has no explicit model selection.`}))).annotateMerge(k({title:`model`,description:`Experimental model routes.`})),Bp=N(`server.provider`).add(A(`provider.list`,`/api/provider`,{query:X,success:V(g(kc)),error:Do}).annotateMerge(Z).annotateMerge(k({identifier:`provider.list`,summary:`List providers`,description:`Retrieve active AI providers so clients can show provider availability and configuration.`}))).add(A(`provider.get`,`/api/provider/:providerID`,{params:{providerID:hc},query:X,success:V(kc),error:[ko,Do]}).annotateMerge(Z).annotateMerge(k({identifier:`provider.get`,summary:`Get provider`,description:`Retrieve a single AI provider so clients can inspect its availability and endpoint settings.`}))).annotateMerge(k({title:`provider`,description:`Experimental provider routes.`})),Vp=e({FileAttachment:()=>Hp,Prompt:()=>Wp,PromptInput:()=>Vp,SkillAttachment:()=>Up}),Hp=C({uri:x,name:x.pipe(B),description:x.pipe(B),mention:Kc.pipe(B)}).annotate({identifier:`PromptInput.FileAttachment`}),Up=C({id:uo,mention:Kc.pipe(B)}).annotate({identifier:`PromptInput.SkillAttachment`}),Wp=C({text:x,files:g(Hp).pipe(B),agents:g(tl).pipe(B),skills:g(Up).pipe(B)}).annotate({identifier:`PromptInput`}),Gp=C({date:x,steps:z}).annotate({identifier:`SessionStats.Activity`}),Kp=C({model:Lc,steps:z,tokens:Hu,cost:Ac}).annotate({identifier:`SessionStats.ModelUsage`}),qp=C({name:x,calls:z,succeeded:z,failed:z,unfinished:z,durationP50:P.pipe(B)}).annotate({identifier:`SessionStats.ToolUsage`}),Jp=y([`none`,`summary`,`detail`]),Yp=C({calls:z,succeeded:z,failed:z,unfinished:z}).annotate({identifier:`SessionStats.ToolTotals`}),Xp=E([C({mode:h(`none`)}),C({mode:h(`summary`),totals:Yp}),C({mode:h(`detail`),totals:Yp,usage:g(qp)})]).annotate({identifier:`SessionStats.Tools`}),Zp=C({range:C({from:Ba,to:Ba}),sessions:z,subagents:z,prompts:z,steps:z,tokens:Hu,cost:Ac,tools:Xp,activeDays:z,streak:z,activity:g(Gp),models:g(Kp)}).annotate({identifier:`SessionStats.Info`});function Qp(e,t){return e===`assistant`?em(sm(t,`providerState`,`native`)):e===`compaction`?rm(nm(sm(t,`providerState`,`native`))):t}function $p(e){return e.map(e=>cm(e)?Qp(e.type,e):e)}function em(e){return Array.isArray(e.content)?{...e,content:e.content.map(tm)}:e}function tm(e){return cm(e)?e.type===`text`||e.type===`reasoning`?sm(e,`state`,`native`):e.type===`tool`?om(sm(e,`providerState`,`native`)):e:e}function nm(e){let t=e.recent,n=am(e,`recent`);if(typeof t!=`string`||!t)return n;let r=cm(n.metadata)?n.metadata:{};return{...n,metadata:{recent:t,...r}}}function rm(e){let t=e.providerContext,n=am(e,`providerContext`);return cm(t)?{...n,native:{messages:Array.isArray(t.messages)?t.messages.map(im):t.messages}}:n}function im(e){return!cm(e)||!Array.isArray(e.content)?e:{...e,content:e.content.map(e=>{if(!cm(e)||e.type!==`media`||e.media!==void 0||typeof e.data!=`string`)return e;let{mediaType:t,data:n,...r}=e;return{...r,media:{source:{type:`base64`,data:n,mediaType:t}}}})}}function am(e,t){if(!(t in e))return e;let{[t]:n,...r}=e;return r}function om(e){if(!(`providerResultState`in e))return e;let{providerResultState:t,...n}=e;return cm(t)?{...n,native:{...cm(n.native)?n.native:{},...t}}:n}function sm(e,t,n){if(!(t in e))return e;let{[t]:r,...i}=e;return n in i?i:{...i,[n]:r}}function cm(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}var lm=e({EventLog:()=>lm,Synced:()=>um}),um=C({type:h(`log.synced`),aggregateID:x,seq:B(no)}).annotate({identifier:`EventLog.Synced`,description:`Marker emitted once when a log read reaches its captured watermark. The reader holds every event committed at or below seq.`}),dm=C({type:h(`running`)}).annotate({identifier:`SessionActive`}),fm=C({...o(Jf.fields,[`location`]),location:Za}).annotate({identifier:`Session.Info`}),pm=C({info:fm,messages:g(Pp)}).annotate({identifier:`SessionTransfer.Data`}),mm=C({...o(Wd.fields,[`location`]),location:Za}).annotate({identifier:`Session.Inbox.MovePayload`}),hm=C({...o(tf.fields,[`payload`]),payload:mm}).annotate({identifier:`Session.Inbox.Move`}),gm=E([Zd,$d,ef,hm]).annotate({identifier:`Session.Inbox.Info`});C({data:g(E([Qd,$d,ef,hm]).annotate({identifier:`Session.Inbox.MediaInfo`}))});var _m=g(Te).pipe(wt(g(Ie),{decode:m($p),encode:b({strict:!1})}),wt(g(Pp),{decode:b({strict:!1}),encode:b({strict:!1})})),vm=C({id:ys.pipe(i),title:Ns.fields.title,metadata:Ns.fields.metadata,fields:Ns.fields.fields}).annotate({identifier:`Form.CreatePayload`}),ym=y([`true`,`false`]).pipe(wt(v,{decode:m(e=>e===`true`),encode:m(e=>e?`true`:`false`)})),bm=C({limit:ae.pipe(wt(Fa),i).annotate({description:`Maximum number of sessions to return. Defaults to the newest 50 sessions.`}),...Zf.fields,cursor:np.pipe(i)}).annotate({identifier:`SessionsQuery`}),xm=(e,t)=>N(`server.session`).add(A(`session.list`,`/api/session`,{query:bm,success:C({data:g(fm),cursor:C({previous:np.pipe(i),next:np.pipe(i)})}).annotate({identifier:`SessionsResponse`}),error:[Ho,xo]}).annotateMerge(k({identifier:`session.list`,summary:`List sessions`,description:`Retrieve sessions in the requested order. Items keep that order across pages; use cursor.next or cursor.previous to move through the ordered list.`}))).add(A(`session.stats`,`/api/experimental/session/stats`,{query:C({from:ae.pipe(i),to:ae.pipe(i),project:pu.pipe(i),timezone:x.pipe(i),tools:Jp.pipe(i)}),success:C({data:Zp}),error:xo}).annotateMerge(k({identifier:`experimental.session.stats`,summary:`Get session statistics`,description:`Aggregate local session activity, usage, and tool reliability for a time range.`}))).add(D(`session.create`,`/api/session`,{payload:C({id:Y.pipe(i),parentID:Y.pipe(i),title:x.pipe(i),agent:su.pipe(i),model:Lc.pipe(i),location:Za.pipe(i),metadata:Gf.pipe(i),permissions:iu.pipe(i)}),success:C({data:fm}),error:G}).annotateMerge(k({identifier:`session.create`,summary:`Create session`,description:`Create a session at the requested location. A parentID creates a linked child session at its parent's location.`}))).add(D(`session.import`,`/api/experimental/session/import`,{payload:C({info:pm.fields.info,messages:_m,location:Za.pipe(i)}),success:C({data:fm}),error:[To,G]}).annotateMerge(k({identifier:`experimental.session.import`,summary:`Import session`,description:`Import a projected session transcript at the requested location. Accepts transcripts exported by earlier releases. If parentID is supplied, the parent session must already exist; import parents before children.`}))).add(A(`session.export`,`/api/experimental/session/:sessionID/export`,{params:{sessionID:Y},query:C({sanitize:ym.pipe(i)}),success:C({data:pm}),error:[G,Oo]}).annotateMerge(k({identifier:`experimental.session.export`,summary:`Export session`,description:`Export a complete projected session transcript.`}))).add(A(`session.active`,`/api/session/active`,{success:C({data:S(Y,dm)})}).annotateMerge(k({identifier:`session.active`,summary:`List active sessions`,description:`Retrieve foreground Session drains currently owned by this OpenCode process. Sessions absent from the result are inactive.`}))).add(A(`session.get`,`/api/session/:sessionID`,{params:{sessionID:Y},success:C({data:fm}),error:G}).annotateMerge(k({identifier:`session.get`,summary:`Get session`,description:`Retrieve a session by ID.`}))).add(ft(`session.remove`,`/api/session/:sessionID`,{params:{sessionID:Y},success:T,error:G}).annotateMerge(k({identifier:`session.remove`,summary:`Delete session`,description:`Delete a session and its child sessions.`}))).add(D(`session.fork`,`/api/session/:sessionID/fork`,{params:{sessionID:Y},payload:C({before:K.pipe(i)}),success:C({data:fm}),error:[G,Lo,xo]}).annotateMerge(k({identifier:`session.fork`,summary:`Fork session`,description:`Create a child session by copying projected history before a message. Omit before to copy the full history.`}))).add(D(`session.switchAgent`,`/api/session/:sessionID/agent`,{params:{sessionID:Y},payload:C({agent:su}),success:T,error:G}).annotateMerge(k({identifier:`session.switchAgent`,summary:`Switch session agent`,description:`Switch the agent used by subsequent provider turns.`}))).add(D(`session.switchModel`,`/api/session/:sessionID/model`,{params:{sessionID:Y},payload:C({model:Lc}),success:T,error:G}).annotateMerge(k({identifier:`session.switchModel`,summary:`Switch session model`,description:`Switch the model used by subsequent provider turns.`}))).add(ze(`session.update`,`/api/session/:sessionID`,{params:{sessionID:Y},payload:C({title:x.pipe(i),metadata:Gf.pipe(i),permissions:iu.pipe(i),archived:v.pipe(i).annotate({description:`Archive the session with true or restore it with false. Repeating the current state is a no-op.`})}),success:T,error:[G,bo]}).annotateMerge(k({identifier:`session.update`,summary:`Update session`,description:`Update mutable session properties.`}))).add(D(`session.move`,`/api/session/:sessionID/move`,{params:{sessionID:Y},payload:C({...Za.fields,delivery:zd.pipe(i)}),success:T,error:[G,xo]}).annotateMerge(k({identifier:`session.move`,summary:`Move session`,description:`Move a session to another project directory at the requested delivery boundary.`}))).add(D(`session.prompt`,`/api/session/:sessionID/prompt`,{params:{sessionID:Y},payload:C({id:K.pipe(i),...Wp.fields,metadata:Bd.fields.metadata,delivery:zd.pipe(i),resume:v.pipe(i)}),success:C({data:Zd}),error:[To,xo,G]}).middleware(e).annotateMerge(k({identifier:`session.prompt`,summary:`Send message`,description:`Durably admit one session input and schedule agent-loop execution unless resume is false.`}))).add(D(`session.command`,`/api/session/:sessionID/command`,{params:{sessionID:Y},payload:C({name:x,...Wp.fields,delivery:zd.pipe(i)}),success:T,error:[G,Bo,Vo]}).middleware(e).annotateMerge(k({identifier:`session.command`,summary:`Run command`,description:`Execute a slash command callback immediately.`}))).add(D(`session.skill`,`/api/experimental/session/:sessionID/skill`,{params:{sessionID:Y},payload:C({id:uo,resume:v.pipe(i)}),success:T,error:[G,Ro]}).middleware(e).annotateMerge(k({identifier:`experimental.session.skill`,summary:`Activate skill`,description:`Activate a skill for a session by appending a skill message and resuming execution.`}))).add(D(`session.synthetic`,`/api/session/:sessionID/synthetic`,{params:{sessionID:Y},payload:C({id:K.pipe(i),text:x,description:x.pipe(i),metadata:Zu.fields.metadata,delivery:zd.pipe(i),resume:v.pipe(i)}),success:C({data:$d}),error:[To,G]}).middleware(e).annotateMerge(k({identifier:`session.synthetic`,summary:`Add synthetic message`,description:`Durably admit synthetic session input and schedule execution unless resume is false.`}))).add(D(`session.shell`,`/api/session/:sessionID/shell`,{params:{sessionID:Y},payload:C({id:K.pipe(i),command:x}),success:T,error:G}).middleware(e).annotateMerge(k({identifier:`session.shell`,summary:`Run shell command`,description:`Execute one shell command in the session's working directory. Emits a shell.started event before execution and a shell.ended event with the merged output after.`}))).add(D(`session.compact`,`/api/session/:sessionID/compact`,{params:{sessionID:Y},payload:C({id:K.pipe(i),delivery:zd.pipe(i)}),success:C({data:ef}),error:[To,G]}).middleware(e).annotateMerge(k({identifier:`session.compact`,summary:`Compact session`,description:`Durably admit a session compaction request. Steers by default: it runs at the next step boundary instead of waiting behind queued prompts.`}))).add(D(`session.wait`,`/api/experimental/session/:sessionID/wait`,{params:{sessionID:Y},success:T,error:[G,Do]}).annotateMerge(k({identifier:`experimental.session.wait`,summary:`Wait for session`,description:`Wait for a session agent loop to become idle.`}))).add(D(`session.revert.stage`,`/api/session/:sessionID/revert/stage`,{params:{sessionID:Y},payload:C({messageID:K,files:v.pipe(i)}),success:C({data:wd}),error:[Lo,G,Eo,Oo]}).middleware(e).annotateMerge(k({identifier:`session.revert.stage`,summary:`Stage session revert`,description:`Stage or move a reversible session boundary and optionally apply its file changes.`}))).add(ft(`session.revert.clear`,`/api/session/:sessionID/revert`,{params:{sessionID:Y},success:T,error:[G,Eo,Oo]}).middleware(e).annotateMerge(k({identifier:`session.revert.clear`,summary:`Clear staged revert`}))).add(D(`session.revert.commit`,`/api/session/:sessionID/revert/commit`,{params:{sessionID:Y},success:T,error:[G,Eo]}).annotateMerge(k({identifier:`session.revert.commit`,summary:`Commit staged revert`}))).add(A(`session.context`,`/api/session/:sessionID/context`,{params:{sessionID:Y},success:C({data:g(Pp)}),error:[G,Oo]}).annotateMerge(k({identifier:`session.context`,summary:`Get session context`,description:`Retrieve the active context messages for a session (all messages after the last compaction).`}))).add(A(`session.diff`,`/api/session/:sessionID/diff`,{params:{sessionID:Y},query:C({from:i(K).annotate({description:`User message whose turn to diff. Defaults to the turn of the newest user message.`}),to:i(K).annotate({description:"Later user message whose turn ends the range. Defaults to the turn of `from` alone."}),context:ae.pipe(wt(z),i).annotate({description:`Unchanged lines around each hunk. Omit for full-file patches.`})}),success:C({data:g(Sd)}),error:[xo,Lo,G,Oo,bo]}).annotateMerge(k({identifier:`session.diff`,summary:`Diff session turns`,description:"Structured per-file diffs of the files a turn changed. A turn runs from the first prompt after the session was last idle until its next idle marker, so prompts steered in while it was busy belong to the same turn; `to` extends the range through a later turn. Compares the range's first recorded snapshot with its last; a step still running in the active session compares against the working copy. Ranges that span a location change are rejected. In sessions without any idle marker, a prompt's turn spans until the next user message."}))).add(A(`session.inbox.list`,`/api/session/:sessionID/inbox`,{params:{sessionID:Y},success:C({data:g(gm)}),error:G}).annotateMerge(k({identifier:`session.inbox.list`,summary:`List session inbox`,description:`List durable enqueued session work not yet delivered, ordered by enqueue sequence. Includes user, synthetic, compaction, and move items.`}))).add(ft(`session.inbox.cancel`,`/api/session/:sessionID/inbox/:inboxID`,{params:{sessionID:Y,inboxID:K},success:T,error:G}).annotateMerge(k({identifier:`session.inbox.cancel`,summary:`Cancel inbox input`,description:`Cancel an inbox item that has not yet been delivered. Unavailable items are a no-op.`}))).add(ze(`session.inbox.update`,`/api/session/:sessionID/inbox/:inboxID`,{params:{sessionID:Y,inboxID:K},payload:C({delivery:zd}),success:T,error:[To,G]}).annotateMerge(k({identifier:`session.inbox.update`,summary:`Update inbox item`,description:`Change a pending inbox item's delivery mode. Steering wakes session execution.`}))).add(A(`session.instructions.entry.list`,`/api/experimental/session/:sessionID/instructions/entries`,{params:{sessionID:Y},success:C({data:g(Fd)}),error:G}).annotateMerge(k({identifier:`experimental.session.instructions.entry.list`,summary:`List instruction entries`,description:`List API-managed instruction entries attached to the session.`}))).add(St(`session.instructions.entry.put`,`/api/experimental/session/:sessionID/instructions/entries/:key`,{params:{sessionID:Y,key:Pd},payload:C({value:Te}),success:T,error:[G,Ld]}).annotateMerge(k({identifier:`experimental.session.instructions.entry.put`,summary:`Put instruction entry`,description:`Attach or replace one durable instruction entry. Changes announce as updates at the next step boundary.`}))).add(ft(`session.instructions.entry.remove`,`/api/experimental/session/:sessionID/instructions/entries/:key`,{params:{sessionID:Y,key:Pd},success:T,error:G}).annotateMerge(k({identifier:`experimental.session.instructions.entry.remove`,summary:`Remove instruction entry`,description:`Remove one instruction entry; the removal is announced to the model at the next step boundary.`}))).add(D(`session.generate`,`/api/session/:sessionID/generate`,{params:{sessionID:Y},payload:C({prompt:x}),success:C({data:C({text:x})}).annotate({identifier:`SessionGenerateResponse`}),error:[G,Do]}).middleware(e).annotateMerge(k({identifier:`session.generate`,summary:`Generate text from session context`,description:`Generate transient text from the current session context without mutating session history.`}))).add(A(`session.log`,`/api/experimental/session/:sessionID/log`,{params:{sessionID:Y},query:{after:ae.pipe(wt(no),i),follow:ym.pipe(i)},success:Ge({data:E([Hf,um]).annotate({identifier:`SessionLogItem`})}),error:G}).annotateMerge(k({identifier:`session.log`,summary:`Read the session log`,description:`Experimental durable session event log. Reads events after an exclusive aggregate sequence and continues with live events when follow=true.`}))).add(D(`session.interrupt`,`/api/session/:sessionID/interrupt`,{params:{sessionID:Y},query:{resume:ym.pipe(i)},success:C({interrupted:v.annotate({description:`Whether an active execution owned by this OpenCode process was interrupted.`})}).annotate({identifier:`SessionInterruptResponse`}),error:G}).annotateMerge(k({identifier:`session.interrupt`,summary:`Interrupt session execution`,description:`Interrupt active execution owned by this OpenCode process. Returns interrupted=true when an active execution was interrupted and false for the idle no-op. When resume=true, execution resumes pending steering input and next-in-line control items (manual compaction, moves) while queued prompts remain parked.`}))).add(D(`session.background`,`/api/session/:sessionID/background`,{params:{sessionID:Y},success:T,error:G}).annotateMerge(k({identifier:`session.background`,summary:`Background blocking session tools`,description:`Move active foreground backgroundable tools for this session into background observation. Idle requests are a no-op.`}))).add(A(`session.message`,`/api/session/:sessionID/message/:messageID`,{params:{sessionID:Y,messageID:K},success:C({data:Pp}),error:[G,Lo]}).annotateMerge(k({identifier:`session.message.get`,summary:`Get session message`,description:`Retrieve one projected message owned by the Session.`}))).add(A(`session.form.list`,`/api/session/:sessionID/form`,{params:{sessionID:x},success:C({data:g(Ns)}),error:G}).middleware(t).annotateMerge(k({identifier:`session.form.list`,summary:`List session forms`,description:`Retrieve pending forms for a session.`}))).add(D(`session.form.create`,`/api/session/:sessionID/form`,{params:{sessionID:x},payload:vm,success:C({data:Ns}),error:[G,To,xo]}).middleware(t).annotateMerge(k({identifier:`session.form.create`,summary:`Create session form`,description:`Create a form for a session.`}))).add(A(`session.form.get`,`/api/session/:sessionID/form/:formID`,{params:{sessionID:x,formID:ys},success:C({data:Ls}),error:[G,Go]}).middleware(t).annotateMerge(k({identifier:`session.form.get`,summary:`Get session form`,description:`Retrieve a form and its current state for a session.`}))).add(D(`session.form.reply`,`/api/session/:sessionID/form/:formID/reply`,{params:{sessionID:x,formID:ys},payload:Rs,success:T,error:[G,Ko,qo,Go]}).middleware(t).annotateMerge(k({identifier:`session.form.reply`,summary:`Reply to form`,description:`Submit an answer to a pending form.`}))).add(ft(`session.form.cancel`,`/api/session/:sessionID/form/:formID`,{params:{sessionID:x,formID:ys},query:C({message:i(x)}),success:T,error:[G,Ko,Go]}).middleware(t).annotateMerge(k({identifier:`session.form.cancel`,summary:`Cancel form`,description:`Cancel a pending form, optionally telling the asker why it was not answered.`}))).add(St(`session.environment`,`/api/session/:sessionID/environment`,{params:{sessionID:Y},payload:C({variables:S(x,x)}),success:T,error:G}).annotateMerge(k({identifier:`session.environment`,summary:`Set session environment`,description:`Replace the process environment used by local shell commands for this session.`}))).add(D(`session.view`,`/api/session/:sessionID/view`,{params:{sessionID:Y},payload:C({idle:Ba}),success:T,error:G}).annotateMerge(k({identifier:`session.view`,summary:`View session`,description:`Mark the idle transition observed by the viewer as viewed.`}))).annotateMerge(k({title:`session`,description:`Experimental session routes.`})),Sm=e({ID:()=>Cm,Info:()=>wm,PermissionSaved:()=>Sm}),Cm=x.pipe(M(`PermissionSaved.ID`),O({identifier:`PermissionSaved.ID`}),za(e=>({create:()=>e.make(`psv_`+Wa())}))),wm=C({id:Cm,projectID:qa,action:x,resource:x,time:C({created:Ba,updated:Ba})}).annotate({identifier:`PermissionSaved.Info`}),Tm=(e,t)=>N(`server.permission`).add(A(`permission.request.list`,`/api/permission/request`,{query:X,success:V(g(Zl))}).middleware(e).annotateMerge(Z).annotateMerge(k({identifier:`permission.request.list`,summary:`List pending permission requests`,description:`Retrieve pending permission requests for a location.`}))).add(A(`permission.saved.list`,`/api/permission/saved`,{query:C({projectID:pu.pipe(i)}),success:C({data:g(wm)})}).middleware(e).annotateMerge(k({identifier:`permission.saved.list`,summary:`List saved permissions`,description:`Retrieve saved permissions, optionally filtered by project.`}))).add(ze(`permission.saved.update`,`/api/permission/saved/:id`,{params:{id:Cm},payload:C({action:x.pipe(i),resource:x.pipe(i)}),success:C({data:wm}),error:[Wo,To]}).annotateMerge(k({identifier:`permission.saved.update`,summary:`Update saved permission`,description:`Change the action or resource of a saved permission. Fails with a conflict when the project already has a saved permission with the same action and resource.`}))).add(ft(`permission.saved.remove`,`/api/permission/saved/:id`,{params:{id:Cm},success:T}).annotateMerge(k({identifier:`permission.saved.remove`,summary:`Remove saved permission`,description:`Remove a saved permission by ID.`}))).add(D(`session.permission.create`,`/api/session/:sessionID/permission`,{params:{sessionID:Y},payload:C({id:Jl.pipe(i),action:Zl.fields.action,resources:Zl.fields.resources,save:Zl.fields.save,metadata:Zl.fields.metadata,source:Zl.fields.source,agent:su.pipe(i)}),success:C({data:C({id:Jl,effect:nu})}),error:G}).middleware(t).annotateMerge(k({identifier:`session.permission.create`,summary:`Create permission request`,description:`Evaluate and, when approval is required, create a permission request for a session.`}))).add(A(`session.permission.list`,`/api/session/:sessionID/permission`,{params:{sessionID:Y},success:C({data:g(Zl)}),error:[G,bo]}).annotateMerge(k({identifier:`session.permission.list`,summary:`List session permission requests`,description:`Retrieve pending permission requests owned by a session.`}))).add(A(`session.permission.get`,`/api/session/:sessionID/permission/:requestID`,{params:{sessionID:Y,requestID:Jl},success:C({data:Zl}),error:[G,Uo]}).middleware(t).annotateMerge(k({identifier:`session.permission.get`,summary:`Get permission request`,description:`Retrieve a pending permission request owned by a session.`}))).add(D(`session.permission.reply`,`/api/session/:sessionID/permission/:requestID/reply`,{params:{sessionID:Y,requestID:Jl},payload:C({decision:Ql,message:x.pipe(i)}),success:T,error:[G,Uo]}).middleware(t).annotateMerge(k({identifier:`session.permission.reply`,summary:`Reply to pending permission request`,description:`Respond to a pending permission request owned by a session.`}))).annotateMerge(k({title:`permission`,description:`Experimental permission routes.`})),Em=e({Entry:()=>km,Event:()=>Om,FileSystem:()=>Em,FindInput:()=>Mm,Match:()=>jm,Submatch:()=>Am,Write:()=>Nm}),Dm=U({type:`filesystem.changed`,schema:{file:x,event:y([`add`,`change`,`unlink`])}}),Om={Changed:Dm,Definitions:W(Dm)},km=C({path:Ia,type:y([`file`,`directory`])}).annotate({identifier:`FileSystem.Entry`}),Am=C({text:x,start:z,end:z}).annotate({identifier:`FileSystem.Submatch`}),jm=C({entry:km,line:Fa,offset:z,text:x,submatches:g(Am)}).annotate({identifier:`FileSystem.Match`}),Mm=class extends p(`FileSystem.FindInput`)({query:x,type:y([`file`,`directory`]).pipe(B),limit:Fa.pipe(B)}){},Nm=C({path:La}).annotate({identifier:`FileSystem.Write`}),Pm=C({...X.fields,path:x.pipe(i).annotate({description:`An absolute path or a path relative to the requested location. Defaults to the location directory.`})}),Fm=C({...X.fields,path:x.annotate({description:`An absolute path or a path relative to the requested location. Missing parent directories are created.`})}),Im=C({path:x.annotate({description:`A file path relative to the requested location.`})}),Lm=C({...X.fields,query:Mm.fields.query,type:Mm.fields.type,limit:ae.pipe(wt(Fa),i)}),Rm=N(`server.fs`).add(A(`fs.read`,`/api/fs/read/*`,{query:X,success:dt.pipe(mt()),error:Po}).annotateMerge(Z).annotateMerge(k({identifier:`fs.read`,summary:`Read file`,description:`Stream one file relative to the requested location with ETag, Last-Modified, and single-range HTTP Range support (206 Partial Content, 416 Range Not Satisfiable, and 304 Not Modified; multi-range and malformed Range headers fall back to 200).`}))).add(A(`fs.list`,`/api/fs/list`,{query:Pm,success:V(g(km)),error:Po}).annotateMerge(Z).annotateMerge(k({identifier:`fs.list`,summary:`List directory`,description:`List direct children using an absolute path or a path relative to the requested location, including parents and siblings outside its directory. Entry paths remain relative to the requested location; listing does not switch locations.`}))).add(A(`fs.find`,`/api/fs/find`,{query:Lm,success:V(g(km))}).annotateMerge(Z).annotateMerge(k({identifier:`fs.find`,summary:`Find files`,description:`Find recursively ranked filesystem entries relative to the requested location.`}))).add(D(`fs.write`,`/api/experimental/fs/write`,{query:Fm,payload:dt.pipe(mt()),success:V(Nm)}).annotateMerge(Z).annotateMerge(k({identifier:`experimental.fs.write`,summary:`Write file`,description:`Write the raw request body to an absolute path or a path relative to the requested location, creating parent directories, and return the resolved absolute path. Unlike read, the target is not confined to the location. Experimental: may change without compatibility guarantees.`}))).add(D(`fs.watch`,`/api/experimental/fs/watch`,{query:X,payload:Im,success:T,error:[Po,Do]}).annotateMerge(Z).annotateMerge(k({identifier:`experimental.fs.watch`,summary:`Watch file`,description:`Watch one file relative to the requested location for 24 hours, publishing filesystem.changed on that location when it changes. Watching an already watched file resets its expiry. Paths follow read confinement. Experimental: may change without compatibility guarantees.`}))).add(ft(`fs.unwatch`,`/api/experimental/fs/watch`,{query:X,payload:Im,success:T}).annotateMerge(Z).annotateMerge(k({identifier:`experimental.fs.unwatch`,summary:`Unwatch file`,description:`Stop watching one file relative to the requested location. Experimental: may change without compatibility guarantees.`}))).annotateMerge(k({title:`filesystem`,description:`Experimental location-scoped filesystem routes.`})),zm=e=>N(`server.form`).add(A(`form.list`,`/api/form`,{query:X,success:V(g(Ns))}).annotateMerge(Z).annotateMerge(k({identifier:`form.list`,summary:`List pending forms`,description:`Retrieve pending forms for a location.`}))).middleware(e).annotateMerge(k({title:`form`,description:`Location form routes.`})),Bm=e({Command:()=>Bm,Event:()=>Um,Info:()=>Hm}),Vm=U({type:`command.updated`,schema:{}}),Hm=C({name:x,description:x.pipe(B)}).annotate({identifier:`Command.Info`}),Um={Updated:Vm,Definitions:W(Vm)},Wm=N(`server.command`).add(A(`command.list`,`/api/command`,{query:X,success:V(g(Hm))}).annotateMerge(Z).annotateMerge(k({identifier:`command.list`,summary:`List commands`,description:`Retrieve currently registered commands.`}))).annotateMerge(k({title:`command`,description:`Experimental command routes.`})),Gm=N(`server.skill`).add(A(`skill.list`,`/api/skill`,{query:X,success:V(g(ho))}).annotateMerge(Z).annotateMerge(k({identifier:`skill.list`,summary:`List skills`,description:`Retrieve currently registered skills.`}))).annotateMerge(k({title:`skill`,description:`Experimental skill routes.`})),Km=C({input:B(Ie)}).annotate({identifier:`Rpc.Input`}),qm=C({output:tt(Ie)}).annotate({identifier:`Rpc.Output`}),Jm=N(`server.rpc`).add(D(`rpc.call`,`/api/rpc/:rpcID/:method`,{params:{rpcID:x,method:x},query:X,payload:Km,success:qm,error:[So,Co]}).annotateMerge(Z).annotateMerge(k({identifier:`rpc.call`,summary:`Call a plugin RPC`,description:`Dispatch a method to the currently registered RPC at the requested location.`}))).annotateMerge(k({title:`rpc`,description:`Plugin RPC routes.`})),Ym=hc.check(Ce(/^[^/#]+$/u)),Xm=Nc.check(Ce(/^[^#]+$/u)),Zm=Ic.check(Ce(/^[^#]+$/u)),Qm=C({providerID:Ym,model:Xm,variant:Zm.pipe(B)}),$m=x.check(Ce(/^[^/#]+\/[^#]+(?:#[^#]+)?$/u)),eh=E([$m,Qm]).pipe(wt(Qm,{decode:m(e=>typeof e==`string`?th(e):e),encode:b({strict:!1})})).annotate({identifier:`Config.ModelSelection`});function th(e){let t=Lc.parse(e);return{providerID:t.providerID,model:t.id,...t.variant?{variant:t.variant}:{}}}var nh=ge(C(Ec.schema.fields),[S(x,yt(Te))]).annotate({identifier:`Config.Provider.Settings`}),rh=ge(C(Bc.schema.fields),[S(x,yt(Te))]).annotate({identifier:`Config.Model.Settings`}),ih=S(x,Te),ah={settings:nh.pipe(B),headers:S(x,x).pipe(B),body:ih.pipe(B)},oh={settings:rh.pipe(B),headers:S(x,x).pipe(B),body:ih.pipe(B)},sh=class extends p(`Config.Provider.Request`)({headers:ah.headers,body:ah.body}){},ch=class extends p(`Config.Model.Cost.Cache`)({read:jc.pipe(B),write:jc.pipe(B)}){},lh=class extends p(`Config.Model.Cost`)({tier:C({type:h(`context`),size:a}).pipe(B),input:jc,output:jc,cache:ch.pipe(B)}){},uh=class extends p(`Config.Model.Limit`)({context:a.pipe(B),input:a.pipe(B),output:a.pipe(B)}){},dh=E([C({supported:h(!1)}),C({supported:h(!0),toggle:v.pipe(B),effort:x.pipe(g,B),budget:C({min:a.pipe(B),max:a.pipe(B)}).pipe(B)})]).annotate({identifier:`Config.Model.Reasoning`}),fh=class extends p(`Config.Model`)({modelID:Nc.pipe(B),type:zc.pipe(B),family:Rc.pipe(B),name:x.pipe(B),releaseDate:x.check(Ce(/^\d{4}-\d{2}(-\d{2})?$/u)).annotate({description:`Release date as YYYY-MM-DD or YYYY-MM`}).pipe(B),compatibility:fc.pipe(B),package:x.pipe(B),...oh,capabilities:Hc.mapFields(e=>({tools:B(e.tools),input:B(e.input),output:B(e.output),temperature:e.temperature,reasoning:dh.pipe(B)})).annotate({identifier:`Config.Model.Capabilities`}).pipe(B),variants:C({id:Ic,...oh}).pipe(g,B),cost:E([lh,lh.pipe(g)]).pipe(B),disabled:v.pipe(B),limit:uh.pipe(B)}){},ph=class extends p(`Config.Provider`)({canonical:hc.pipe(B),name:x.pipe(B),env:x.pipe(g,B),package:x.pipe(B),compatibility:pc.pipe(B),...ah,models:S(x,fh).pipe(B)}){},mh=x.check(Ce(/^#[0-9a-fA-F]{6}$/u)),hh=class extends p(`Config.Agent`)({model:eh.pipe(B),request:sh.pipe(B),system:x.pipe(B),description:x.pipe(B),mode:y([`subagent`,`primary`,`all`]).pipe(B),hidden:v.pipe(B),color:mh.pipe(Be(()=>Ke),B),steps:Fa.pipe(B),disabled:v.pipe(B),permissions:iu.pipe(B)}){},gh=class extends p(`Config.Media.Image`)({auto_resize:v.pipe(B),max_width:Fa.pipe(B),max_height:Fa.pipe(B),max_base64_bytes:Fa.pipe(B)}){},_h=class extends p(`Config.Media`)({image:gh.pipe(B)}){},vh=class extends p(`Config.Compaction.Keep`)({tokens:z.pipe(B)}){},yh=class extends p(`Config.Compaction`)({auto:v.pipe(B),keep:vh.pipe(B),buffer:z.pipe(B)}){},bh=class extends p(`Config.Command`)({template:x,description:x.pipe(B),agent:x.pipe(B),model:eh.pipe(B),subagent:v.pipe(B),subtask:v.annotate({description:`Deprecated alias for subagent.`}).pipe(B)}){},xh=y([`allow`,`deny`]),Sh=C({action:y([`provider.use`,`tool.use`,`integration.use`]),resource:x,effect:xh}),Ch=class extends p(`ConfigExperimental.Info`)({portable_shell_scanner:v.pipe(B).annotate({description:`Enable the experimental portable shell permission scanner. Defaults to false.`}),todo:v.pipe(B).annotate({description:`Enable the experimental todowrite tool. Defaults to false.`}),background_compaction:v.pipe(B).annotate({description:`Enable experimental background compaction: summarize the conversation in the background as it nears the compaction threshold, so automatic compaction does not wait for the summary. Background summaries that are never used still cost tokens. Defaults to false.`}),media_blob:v.pipe(B).annotate({description:`Store new session media once in a deduplicated blob table instead of inline in every message row. Defaults to false.`}),subagent_depth:z.pipe(B).annotate({description:`Maximum subagent nesting depth. Defaults to 1.`}),location_idle_timeout:E([ve,h(!1)]).pipe(B).annotate({description:`How long a location can go without session activity before its services are unloaded. Running sessions and background jobs keep a location loaded. Set to false to never unload (default: "60 minutes")`}),policies:Sh.pipe(g,B).annotate({description:`Deprecated: use top-level policies. Ordered policies controlling access to configured resources`})}){},wh=class extends p(`Config.Formatter.Entry`)({disabled:v.pipe(B),command:x.pipe(g,B),environment:S(x,x).pipe(B),extensions:x.pipe(g,B)}){},Th=E([v,S(x,wh)]),Eh=C({disabled:h(!0)}),Dh=class extends p(`Config.LSP.Server`)({command:x.pipe(g),extensions:x.pipe(g,B),disabled:v.pipe(B),env:S(x,x).pipe(B),initialization:S(x,Ie).pipe(B)}){},Oh=E([Eh,Dh]),kh=E([v,S(x,Oh)]),Ah=class extends p(`Mcp.TimeoutConfig`)({startup:Fa.pipe(B).annotate({description:`Maximum time in milliseconds to establish and initialize the MCP server.`}),catalog:Fa.pipe(B).annotate({description:`Maximum time in milliseconds to wait for MCP discovery requests such as tools/list and prompts/list.`}),execution:Fa.pipe(B).annotate({description:`Maximum time in milliseconds to wait for MCP tool and prompt execution.`})}){},jh=y([`legacy`,`auto`,`2026-07-28`]).annotate({identifier:`Mcp.Protocol`,description:`MCP protocol negotiation. "legacy" (default) opens with the initialize handshake and speaks protocol revisions up to 2025-11-25. "auto" probes for the 2026-07-28 revision and falls back to legacy when the server does not support it. "2026-07-28" requires that revision and fails otherwise.`}),Mh=class extends p(`Mcp.LocalConfig`)({type:h(`local`),command:x.pipe(g),cwd:x.pipe(B).annotate({description:`Working directory for the MCP server process. Relative paths resolve from the workspace directory.`}),environment:S(x,x).pipe(B),disabled:v.pipe(B),codemode:v.pipe(B).annotate({description:`Expose this server's tools through Code Mode. Defaults to true.`}),timeout:Ah.pipe(B),protocol:jh.pipe(B)}){},Nh=class extends p(`Mcp.OAuthConfig`)({client_id:x.pipe(B),client_secret:x.pipe(B),scope:x.pipe(B),callback_port:a.check(Dt({minimum:1,maximum:65535})).pipe(B),redirect_uri:x.pipe(B),auth_server_metadata_url:x.pipe(B).annotate({description:`URL of the OAuth or OpenID Connect authorization server metadata document. Set when the MCP server does not publish protected resource metadata that names its authorization server.`})}){},Ph=class extends p(`Mcp.RemoteConfig`)({type:h(`remote`),url:x,headers:S(x,x).pipe(B),oauth:E([Nh,h(!1)]).pipe(B),disabled:v.pipe(B),codemode:v.pipe(B).annotate({description:`Expose this server's tools through Code Mode. Defaults to true.`}),timeout:Ah.pipe(B),protocol:jh.pipe(B)}){},Fh=E([Mh,Ph]).pipe(ie(`type`)),Ih=C({status:h(`connected`)}).annotate({identifier:`Mcp.Status.Connected`}),Lh=C({status:h(`pending`)}).annotate({identifier:`Mcp.Status.Pending`}),Rh=C({status:h(`disabled`)}).annotate({identifier:`Mcp.Status.Disabled`}),zh=C({status:h(`failed`),error:x}).annotate({identifier:`Mcp.Status.Failed`}),Bh=C({status:h(`needs_auth`),error:x}).annotate({identifier:`Mcp.Status.NeedsAuth`}),Vh=E([Ih,Lh,Rh,zh,Bh]).pipe(ie(`status`)),Hh=C({name:x,status:Vh,title:B(x),integrationID:B(ts)}).annotate({identifier:`Mcp.Server`}),Uh=C({server:x,name:x,uri:x,description:B(x),mimeType:B(x)}).annotate({identifier:`Mcp.Resource`}),Wh=C({server:x,name:x,uriTemplate:x,description:B(x),mimeType:B(x)}).annotate({identifier:`Mcp.ResourceTemplate`}),Gh=C({resources:g(Uh),templates:g(Wh)}).annotate({identifier:`Mcp.ResourceCatalog`}),Kh=E([C({type:h(`text`),uri:x,text:x,mimeType:B(x)}),C({type:h(`blob`),uri:x,blob:x,mimeType:B(x)})]).pipe(ie(`type`),O({identifier:`Mcp.ResourceContentPart`}));C({server:x,uri:x,contents:g(Kh)}).annotate({identifier:`Mcp.ResourceContent`});var qh=Ah,Jh=Fh,Yh=class extends p(`Config.MCP`)({timeout:qh.pipe(B),servers:S(x,Jh).pipe(B)}){},Xh=class extends p(`Config.Plugin.Entry`)({package:x,options:S(x,Ie).pipe(B)}){},Zh=E([x,Xh]).pipe(g),Qh=class extends p(`Config.Reference.Git`)({repository:x,branch:x.pipe(B),description:x.pipe(B),hidden:v.pipe(B)}){},$h=class extends p(`Config.Reference.Local`)({path:x,description:x.pipe(B),hidden:v.pipe(B)}){},eg=E([x,Qh,$h]),tg=S(x,eg),ng=e({Event:()=>lg,ID:()=>rg,Input:()=>ag,Provider:()=>ig,Response:()=>sg,Result:()=>og,WebSearch:()=>ng}),rg=x.pipe(M(`WebSearch.ID`),O({identifier:`WebSearch.ID`})),ig=C({id:rg,name:x}).annotate({identifier:`WebSearch.Provider`}),ag=C({query:x,providerID:rg.pipe(B)}).annotate({identifier:`WebSearch.Input`}),og=C({url:x,title:x.pipe(B),content:x.pipe(B),time:C({published:P.pipe(B).annotate({description:`Publication time in milliseconds since the Unix epoch`})})}).annotate({identifier:`WebSearch.Result`}),sg=class extends p(`WebSearch.Response`)({providerID:rg,results:g(og)}){},cg=U({type:`websearch.updated`,schema:{}}),lg={Updated:cg,Definitions:W(cg)},ug=class extends p(`ConfigWebSearch.Info`)({provider:E([h(`random`).annotate({description:`Reuse a randomly selected provider until it is rate limited, then switch to another available provider.`}),rg])}){},dg=E([h(!1),ug]),fg=class extends p(`Config.ToolOutput`)({max_lines:Fa.pipe(B),max_bytes:Fa.pipe(B)}){},pg=class extends p(`Config.Watcher`)({ignore:x.pipe(g,B)}){},mg=class extends p(`Config.Warming`)({prompt:x.pipe(B).annotate({description:`Prompt sent for keep-alive requests`}),interval:ve.pipe(B).annotate({description:`Idle time between keep-alive requests (default: "4 minutes")`}),duration:ve.pipe(B).annotate({description:`Time after the last active request to keep a session warm (default: "30 minutes")`})}){},hg=E([v,mg]),gg=C({directory:xt.pipe(at(kt())).annotate({description:`Parent directory for new worktrees, relative to the project's primary checkout when not absolute`})}).annotate({identifier:`Config.Worktree`}),_g=e({Config:()=>_g,Directory:()=>xg,Document:()=>bg,Entry:()=>Sg,Event:()=>wg,Info:()=>vg,Patch:()=>yg}),vg=class extends p(`Config.Info`)({$schema:B(x).annotate({description:`JSON schema reference for configuration validation`}),shell:x.pipe(B).annotate({description:`Default shell to use for terminal and shell tool execution`}),model:eh.pipe(B).annotate({description:`Default model to use when no session or agent model is selected`}),default_agent:x.pipe(B).annotate({description:`Default primary agent to use when no session agent is selected`}),update:y([`disable`,`notify`,`auto`]).pipe(B).annotate({description:`Disable updates, notify when one is available, or install updates automatically`}),share:y([`manual`,`auto`,`disabled`]).pipe(B).annotate({description:`Control whether sessions may be shared manually, automatically, or not at all`}),enterprise:C({url:x.pipe(B)}).pipe(B).annotate({description:`Enterprise sharing service configuration`}),username:x.pipe(B).annotate({description:`Username displayed in conversations and used for telemetry identity`}),permissions:iu.pipe(B).annotate({description:`Ordered tool permission rules applied to agent tool use`}),policies:Sh.pipe(g,B).annotate({description:`Ordered policies controlling access to providers, tools, and integrations`}),agents:S(x,hh).pipe(B).annotate({description:`Named built-in agent overrides and custom agent definitions`}),snapshots:v.pipe(B).annotate({description:`Enable snapshots used for undo and revert behavior`}),watcher:pg.pipe(B).annotate({description:`Filesystem watcher configuration`}),formatter:Th.pipe(B).annotate({description:`Enable built-in formatters or configure formatter overrides`}),lsp:kh.pipe(B).annotate({description:`Enable built-in language servers or configure server overrides`}),media:_h.pipe(B).annotate({description:`Media processing configuration`}),tool_output:fg.pipe(B).annotate({description:`Tool output truncation thresholds`}),mcp:Yh.pipe(B).annotate({description:`MCP server configuration`}),compaction:yh.pipe(B).annotate({description:`Conversation compaction behavior`}),skills:x.pipe(g,B).annotate({description:`Additional paths or URLs to discover skills from`}),commands:S(x,bh).pipe(B).annotate({description:`Named slash command definitions`}),instructions:x.pipe(g,B).annotate({description:`Additional paths or URLs supplying ambient instructions`}),references:tg.pipe(B).annotate({description:`Named local directories or Git repositories available as external context`}),websearch:dg.pipe(B).annotate({description:`Web search provider selection`}),plugins:Zh.pipe(B).annotate({description:`Ordered plugin enablement directives and external package declarations`}),worktree:gg.pipe(B).annotate({description:`Directory defaults for local worktree creation`}),warming:hg.pipe(B).annotate({description:`Keep recently active sessions warm with transient model requests (default: false)`}),providers:S(x,ph).pipe(B),experimental:Ch.pipe(B)}){},yg=C({shell:se(x)}).annotate({identifier:`Config.Patch`}),bg=class extends p(`Config.Document`)({type:h(`document`),path:La.pipe(B),info:vg}){},xg=class extends p(`Config.Directory`)({type:h(`directory`),path:La}){},Sg=E([bg,xg]).annotate({identifier:`Config.Entry`}),Cg=U({type:`config.updated`,schema:{}}),wg={Updated:Cg,Definitions:W(Cg)},Tg=e({CreateInput:()=>Dg,Directory:()=>Ag,Event:()=>Ig,Info:()=>kg,List:()=>Ng,ListEntry:()=>jg,OperationError:()=>Mg,RemoveInput:()=>Og,StrategyID:()=>Eg,Worktree:()=>Tg,adopt:()=>Lg}),Eg=xt.pipe(at(kt()),M(`Worktree.StrategyID`)),Dg=C({projectID:pu,from:B(La),branch:B(xt.pipe(at(kt()))),directory:B(La).annotate({description:`Parent directory for the new worktree. Uses the project's canonical configuration, then defaults to the server's data directory under worktree/<first six project ID characters>.`}),name:B(x)}).annotate({identifier:`Worktree.CreateInput`}),Og=C({projectID:pu,directory:La,force:v}).annotate({identifier:`Worktree.RemoveInput`}),kg=C({directory:La}).annotate({identifier:`Worktree.Info`}),Ag=C({directory:La,strategy:B(x)}).annotate({identifier:`Worktree.Directory`}),jg=C({directory:La,type:y([`root`,`worktree`])}).annotate({identifier:`Worktree.ListEntry`}),Mg=class extends t()(`Worktree.OperationError`,{message:x,forceRequired:B(v)}){},Ng=g(Ag).annotate({identifier:`Worktree.List`}),Pg=U({type:`worktree.updated`,schema:{projectID:pu}}),Fg=H({type:`worktree.resolved`,durable:{aggregate:`projectID`,version:1},schema:{projectID:pu,directory:La,previous:pu,adopted:B(g(pu))}}),Ig={Updated:Pg,Resolved:Fg,Definitions:W(Pg,Fg)};function Lg(e,t){if(e.workspaceID||e.projectID!==t.previous&&e.projectID!==pu.global&&!t.adopted?.includes(e.projectID)||e.projectID===t.projectID)return;let n=e=>e.replaceAll(`\\`,`/`).split(`/`).reduce((e,t)=>!t||t===`.`?e:t===`..`?e.slice(0,e.lastIndexOf(`/`)):`${e}/${t}`,``),r=n(e.directory),i=n(t.directory),a=/^\/[a-z]:/i.test(i),o=a?r.toLowerCase():r,s=a?i.toLowerCase():i;if(!(o!==s&&!o.startsWith(s+`/`)))return{projectID:t.projectID,subpath:o===s?void 0:r.slice(i.length+1)}}so([...Bf,Ig.Resolved]);var Rg=U({type:`file.edited`,schema:{file:x}}),zg={Edited:Rg,Definitions:W(Rg)},Bg=W(U({type:`installation.updated`,schema:{version:x}}),U({type:`installation.update-available`,schema:{version:x}})),Vg=x.check(me(`per`)).pipe(M(`PermissionV1.ID`),za(e=>({ascending:t=>e.make(t??`per_`+Wa())}))),Hg=y([`allow`,`deny`,`ask`]).annotate({identifier:`PermissionV1.Action`}),Ug=C({permission:x,pattern:x,action:Hg}).annotate({identifier:`PermissionV1.Rule`}),Wg=g(Ug).annotate({identifier:`PermissionV1.Ruleset`}),Gg=C({id:Vg,sessionID:Kl,permission:x,patterns:g(x),metadata:S(x,Ie),always:g(x),tool:i(C({messageID:x,callID:x}))}).annotate({identifier:`PermissionV1.Request`}),Kg=y([`once`,`always`,`reject`]),qg=C({reply:Kg,message:i(x)}).annotate({identifier:`PermissionV1.ReplyBody`});C({projectID:pu,patterns:g(x)}).annotate({identifier:`PermissionV1.Approval`}),C({...Gg.fields,id:i(Vg),ruleset:Wg}).annotate({identifier:`PermissionV1.AskInput`}),C({requestID:Vg,...qg.fields}).annotate({identifier:`PermissionV1.ReplyInput`}),W(U({type:`permission.asked`,schema:Gg.fields}),U({type:`permission.replied`,schema:{sessionID:Kl,requestID:Vg,reply:Kg}}));var Jg=P.check(Re(0)),Yg=x.check(me(`msg`)).pipe(M(`SessionV1.MessageID`),za(e=>({ascending:t=>e.make(t??`msg_`+Wa())}))),Xg=x.check(me(`prt`)).pipe(M(`SessionV1.PartID`),za(e=>({ascending:t=>e.make(t??`prt_`+Wa())}))),Zg=(e,t)=>{let n=C({name:h(e),data:C(t)}).annotate({identifier:e});return{Schema:n,EffectSchema:n}},Qg=Zg(`MessageOutputLengthError`,{}),$g=Zg(`ProviderAuthError`,{providerID:x,message:x}),e_=Zg(`MessageAbortedError`,{message:x}),t_=Zg(`StructuredOutputError`,{message:x,retries:z}),n_=Zg(`APIError`,{message:x,statusCode:i(z),isRetryable:v,responseHeaders:i(S(x,x)),responseBody:i(x),metadata:i(S(x,x))}),r_=Zg(`ContextOverflowError`,{message:x,responseBody:i(x)}),i_=Zg(`ContentFilterError`,{message:x}),a_=class extends p(`OutputFormatText`)({type:h(`text`)}){},o_=class extends p(`OutputFormatJsonSchema`)({type:h(`json_schema`),schema:S(x,et).annotate({identifier:`SessionV1.JSONSchema`}),retryCount:z.pipe(i,Pt(Ve(2)))}){},s_=E([a_,o_]).annotate({discriminator:`type`,identifier:`SessionV1.OutputFormat`}),c_={id:Xg,sessionID:Kl,messageID:Yg},l_=C({...c_,type:h(`snapshot`),snapshot:x}).annotate({identifier:`SessionV1.SnapshotPart`}),u_=C({...c_,type:h(`patch`),hash:x,files:g(x)}).annotate({identifier:`SessionV1.PatchPart`}),d_=C({...c_,type:h(`text`),text:x,synthetic:i(v),ignored:i(v),time:i(C({start:z,end:i(z)})),metadata:i(S(x,et))}).annotate({identifier:`SessionV1.TextPart`}),f_=C({...c_,type:h(`reasoning`),text:x,metadata:i(S(x,et)),time:C({start:z,end:i(z)})}).annotate({identifier:`SessionV1.ReasoningPart`}),p_={text:C({value:x,start:P,end:P}).annotate({identifier:`SessionV1.FilePartSourceText`})},m_=C({start:C({line:z,character:z}),end:C({line:z,character:z})}).annotate({identifier:`SessionV1.Range`}),h_=C({...p_,type:h(`file`),path:x}).annotate({identifier:`SessionV1.FileSource`}),g_=C({...p_,type:h(`symbol`),path:x,range:m_,name:x,kind:z}).annotate({identifier:`SessionV1.SymbolSource`}),__=C({...p_,type:h(`resource`),clientName:x,uri:x}).annotate({identifier:`SessionV1.ResourceSource`}),v_=E([h_,g_,__]).annotate({discriminator:`type`,identifier:`SessionV1.FilePartSource`}),y_=C({...c_,type:h(`file`),mime:x,filename:i(x),url:x,source:i(v_)}).annotate({identifier:`SessionV1.FilePart`}),b_=C({...c_,type:h(`agent`),name:x,source:i(C({value:x,start:z,end:z}))}).annotate({identifier:`SessionV1.AgentPart`}),x_=C({...c_,type:h(`compaction`),auto:v,overflow:i(v),tail_start_id:i(Yg)}).annotate({identifier:`SessionV1.CompactionPart`}),S_=C({...c_,type:h(`subtask`),prompt:x,description:x,agent:x,model:i(C({providerID:hc,modelID:Nc})),command:i(x)}).annotate({identifier:`SessionV1.SubtaskPart`}),C_=C({...c_,type:h(`retry`),attempt:z,error:n_.EffectSchema,time:C({created:z})}).annotate({identifier:`SessionV1.RetryPart`}),w_=C({...c_,type:h(`step-start`),snapshot:i(x)}).annotate({identifier:`SessionV1.StepStartPart`}),T_=C({...c_,type:h(`step-finish`),reason:x,snapshot:i(x),cost:P,tokens:C({total:i(P),input:P,output:P,reasoning:P,cache:C({read:P,write:P})})}).annotate({identifier:`SessionV1.StepFinishPart`}),E_=C({status:h(`pending`),input:S(x,et),raw:x}).annotate({identifier:`SessionV1.ToolStatePending`}),D_=C({status:h(`running`),input:S(x,et),title:i(x),metadata:i(S(x,et)),time:C({start:z})}).annotate({identifier:`SessionV1.ToolStateRunning`}),O_=C({status:h(`completed`),input:S(x,et),output:x,title:x,metadata:S(x,et),time:C({start:z,end:z,compacted:i(z)}),attachments:i(g(y_))}).annotate({identifier:`SessionV1.ToolStateCompleted`}),k_=C({status:h(`error`),input:S(x,et),error:x,metadata:i(S(x,et)),time:C({start:z,end:z})}).annotate({identifier:`SessionV1.ToolStateError`}),A_=E([E_,D_,O_,k_]).annotate({discriminator:`status`,identifier:`SessionV1.ToolState`}),j_=C({...c_,type:h(`tool`),callID:x,tool:x,state:A_,metadata:i(S(x,et))}).annotate({identifier:`SessionV1.ToolPart`}),M_={id:Yg,sessionID:c_.sessionID},N_=C({...M_,role:h(`user`),time:C({created:Jg}),format:i(s_),summary:i(C({title:i(x),body:i(x),diffs:g(Cd)})),agent:x,model:C({providerID:hc,modelID:Nc,variant:i(x)}),system:i(x),tools:i(S(x,v))}).annotate({identifier:`SessionV1.UserMessage`}),P_=E([d_,S_,f_,y_,j_,w_,T_,l_,u_,b_,C_,x_]).annotate({discriminator:`type`,identifier:`SessionV1.Part`}),F_=E([$g.EffectSchema,Zg(`UnknownError`,{message:x,ref:i(x)}).EffectSchema,Qg.EffectSchema,e_.EffectSchema,t_.EffectSchema,r_.EffectSchema,i_.EffectSchema,n_.EffectSchema]).annotate({discriminator:`name`});C({id:i(Xg),type:h(`text`),text:x,synthetic:i(v),ignored:i(v),time:i(C({start:z,end:i(z)})),metadata:i(S(x,et))}).annotate({identifier:`SessionV1.TextPartInput`}),C({id:i(Xg),type:h(`file`),mime:x,filename:i(x),url:x,source:i(v_)}).annotate({identifier:`SessionV1.FilePartInput`}),C({id:i(Xg),type:h(`agent`),name:x,source:i(C({value:x,start:z,end:z}))}).annotate({identifier:`SessionV1.AgentPartInput`}),C({id:i(Xg),type:h(`subtask`),prompt:x,description:x,agent:x,model:i(C({providerID:hc,modelID:Nc})),command:i(x)}).annotate({identifier:`SessionV1.SubtaskPartInput`});var I_=C({...M_,role:h(`assistant`),time:C({created:z,completed:i(z)}),error:i(F_),parentID:Yg,modelID:Nc,providerID:hc,mode:x,agent:x,path:C({cwd:x,root:x}),summary:i(v),cost:P,tokens:C({total:i(P),input:P,output:P,reasoning:P,cache:C({read:P,write:P})}),structured:i(et),variant:i(x),finish:i(x)}).annotate({identifier:`SessionV1.AssistantMessage`}),L_=E([N_,I_]).annotate({discriminator:`role`,identifier:`SessionV1.Message`}),R_={durable:{aggregate:`sessionID`,version:1}},z_=C({additions:P,deletions:P,files:P,diffs:B(g(Cd))}),B_=C({input:P,output:P,reasoning:P,cache:C({read:P,write:P})}),V_=C({url:x}),H_=C({messageID:Yg,partID:B(Xg),snapshot:B(x),diff:B(x)}),U_=C({id:Nc,providerID:hc,variant:B(x)}),W_=C({id:Kl,slug:x,projectID:pu,workspaceID:B(Ja),directory:x,path:B(x),parentID:B(Kl),summary:B(z_),cost:B(P),tokens:B(B_),share:B(V_),title:B(x),agent:B(x),model:B(U_),version:x,metadata:B(S(x,et)),time:C({created:z,updated:z,compacting:B(z),archived:B(P)}),permission:B(Wg),revert:B(H_)}).annotate({identifier:`SessionV1.Info`}),G_={Created:H({type:`session.created`,...R_,schema:{sessionID:Kl,info:W_}}),Updated:H({type:`session.updated`,...R_,schema:{sessionID:Kl,info:W_}}),Deleted:H({type:`session.deleted`,...R_,schema:{sessionID:Kl,info:W_}}),MessageUpdated:H({type:`message.updated`,...R_,schema:{sessionID:Kl,info:L_}}),MessageRemoved:H({type:`message.removed`,...R_,schema:{sessionID:Kl,messageID:Yg}}),PartUpdated:H({type:`message.part.updated`,...R_,schema:{sessionID:Kl,part:P_,time:P}}),PartRemoved:H({type:`message.part.removed`,...R_,schema:{sessionID:Kl,messageID:Yg,partID:Xg}})},K_=U({type:`message.part.delta`,schema:{sessionID:Kl,messageID:Yg,partID:Xg,field:x,delta:x}}),q_=U({type:`session.diff`,schema:{sessionID:Kl,diff:g(Cd)}}),J_=U({type:`session.error`,schema:{sessionID:i(Kl),error:I_.fields.error}});({...G_}),W(G_.Created,G_.Updated,G_.Deleted,G_.MessageUpdated,G_.MessageRemoved,G_.PartUpdated,G_.PartRemoved,K_,q_,J_);var Y_=W(U({type:`command.executed`,schema:{name:x,sessionID:Kl,arguments:x,messageID:Yg}})),X_=W(U({type:`lsp.updated`,schema:{}})),Z_=W(U({type:`location.shutdown`,schema:{}})),Q_=U({type:`mcp.tools.changed`,schema:{server:x}}),$_=U({type:`mcp.resources.changed`,schema:{server:x}}),ev=U({type:`mcp.status.changed`,schema:{server:x}}),tv=W(Q_,$_,ev),nv=U({type:`models-dev.refreshed`,schema:{}}),rv={Refreshed:nv,Definitions:W(nv)},iv=x.pipe(M(`Plugin.ID`),O({identifier:`Plugin.ID`})),av=E([C({type:h(`builtin`)}),C({type:h(`package`),target:x,version:x.pipe(B),outdated:h(!0).pipe(B),updating:h(!0).pipe(B)}),C({type:h(`local`),path:x}),C({type:h(`sdk`)})]).annotate({identifier:`Plugin.Source`}),ov=C({server:h(!0).pipe(B),tui:h(!0).pipe(B),rpc:h(!0).pipe(B),gui:h(!0).pipe(B)}).annotate({identifier:`Plugin.Features`}),sv=C({code:x,revision:x,options:S(x,Te)}).annotate({identifier:`Plugin.GuiBundle`}),cv=E([C({status:h(`active`)}),C({status:h(`failed`),error:x,ref:x.pipe(B)})]).annotate({identifier:`Plugin.State`}),lv=C({id:iv.pipe(B),source:av,features:ov,state:cv}).annotate({identifier:`Plugin.Info`}),uv=U({type:`plugin.updated`,schema:{}}),dv={Updated:uv,Definitions:W(uv)},fv=e({Event:()=>mv,GitSource:()=>gv,Info:()=>vv,LocalSource:()=>hv,Reference:()=>fv,Source:()=>_v}),pv=U({type:`reference.updated`,schema:{}}),mv={Updated:pv,Definitions:W(pv)},hv=C({type:h(`local`),path:La,description:x.pipe(B),hidden:v.pipe(B)}).annotate({identifier:`Reference.LocalSource`}),gv=C({type:h(`git`),repository:x,branch:x.pipe(B),description:x.pipe(B),hidden:v.pipe(B)}).annotate({identifier:`Reference.GitSource`}),_v=E([hv,gv]).pipe(ie(`type`)).annotate({identifier:`Reference.Source`}),vv=C({name:x,path:La,description:x.pipe(B),hidden:v.pipe(B),source:_v}).annotate({identifier:`Reference.Info`}),yv=W(U({type:`server.connected`,schema:{}}),U({type:`global.disposed`,schema:{}})),bv=W(U({type:`session.status`,identifier:`SessionStatusUpdated`,schema:{sessionID:Kl,status:E([C({type:h(`idle`)}),C({type:h(`retry`),attempt:z,message:x,action:B(C({reason:x,provider:x,title:x,message:x,label:x,link:B(x)})),next:z}),C({type:h(`busy`)})]).annotate({identifier:`SessionStatus`})}}),U({type:`session.idle`,schema:{sessionID:Kl}})),xv=W(U({type:`tui.prompt.append`,schema:{text:x}}),U({type:`tui.command.execute`,schema:{command:E([y([`session.list`,`session.new`,`session.interrupt`,`session.background`,`session.compact`,`session.page.up`,`session.page.down`,`session.line.up`,`session.line.down`,`session.half.page.up`,`session.half.page.down`,`session.first`,`session.last`,`prompt.clear`,`prompt.submit`,`agent.cycle`]),x])}}),U({type:`tui.toast.show`,schema:{title:B(x),message:x,variant:y([`info`,`success`,`warning`,`error`]),duration:Fa.pipe(Pt(Ve(5e3))).annotate({description:`Duration in milliseconds`})}}),U({type:`tui.session.select`,schema:{sessionID:Kl.annotate({description:`Session ID to navigate to`})}})),Sv=W(U({type:`vcs.branch.updated`,schema:{branch:B(x)}})),Cv=C({workspaceID:Ja,status:y([`connected`,`connecting`,`disconnected`,`error`])}).annotate({identifier:`WorkspaceEvent.ConnectionStatus`}),wv=W(U({type:`workspace.ready`,schema:{name:x}}),U({type:`workspace.failed`,schema:{message:x}}),U({type:`workspace.status`,schema:Cv.fields})),Tv=W(U({type:`worktree.ready`,schema:{name:x,branch:B(x)}}),U({type:`worktree.failed`,schema:{message:x}})),Ev=W(...zf),Dv=W(...Z_,...rv.Definitions,...ss.Definitions,...$s.Definitions,..._c.Definitions,...Fc.Definitions,...du.Definitions,...Ev),Ov=W(...Om.Definitions,...mv.Definitions,...tu.Definitions,...dv.Definitions,...Su.Definitions,...Ig.Definitions,...Um.Definitions,...wg.Definitions,..._o.Definitions,...Ul.Definitions,...fp.Definitions,...Iu.Definitions,...Hs.Definitions,...lg.Definitions),kv=W(...Dv,...Ov,...bv,...xv,...Bg,...Sv,ev,$_);ao(kv),ao(W(...Dv,...Bg,...Ov,...X_,...xv,...tv,...Y_,...zg.Definitions,...bv,...Sv,...wv,...Tv,...yv));var Av={id:to,metadata:i(S(x,Ie)),location:i(Za)},jv=C({id:to,created:P,metadata:i(S(x,Ie)),type:We([`rpc.`,x]),location:Za,data:S(x,Ie)}).annotate({identifier:`V2Event.rpc`}),Mv=e=>E([...e,jv,...e.some(e=>e.type===`server.connected`)?[]:[C({...Av,type:h(`server.connected`),data:C({})}).annotate({identifier:`V2Event.server.connected`})]]).annotate({identifier:`V2Event`}),Nv=e=>C({types:i(de(E([y(e.map(e=>e.type)),jv.fields.type]))).annotate({description:`Only send events of these types, plus the initial server.connected event. When omitted, all events are sent.`})}).annotate({identifier:`EventSubscribeQuery`}),Pv=(e=>{let t=Mv(e);return{schema:t,group:N(`server.event`).add(A(`event.subscribe`,`/api/event`,{query:Nv(e),success:Ge({data:t})}).annotateMerge(k({identifier:`event.subscribe`,summary:`Subscribe to events`,description:`Subscribe to native events and plugin RPC events across all server locations. Volatile by contract: a slow consumer overflows and fails the stream, and events during disconnection are missed.`}))).annotateMerge(k({title:`event`,description:`Experimental event stream routes.`}))}})(kv),Fv=Pv.group;Pv.schema;var Iv=N(`server.agent`).add(A(`agent.list`,`/api/agent`,{query:X,success:V(g(uu)),error:Do}).annotateMerge(Z).annotateMerge(k({identifier:`agent.list`,summary:`List agents`,description:`Retrieve currently registered agents.`}))).add(A(`agent.get`,`/api/agent/:agentID`,{params:{agentID:su},query:X,success:V(uu),error:Io}).annotateMerge(Z).annotateMerge(k({identifier:`agent.get`,summary:`Get agent`,description:`Retrieve a single currently registered agent.`}))).annotateMerge(k({title:`agent`})),Lv=N(`server.plugin`).add(A(`plugin.list`,`/api/plugin`,{query:X,success:V(g(lv))}).annotateMerge(Z).annotateMerge(k({identifier:`plugin.list`,summary:`List plugins`,description:`Retrieve enabled server plugins and their current status.`}))).add(A(`plugin.gui`,`/api/plugin/gui`,{query:C({...X.fields,id:iv}),success:V(sv),error:Fo}).annotateMerge(Z).annotateMerge(k({identifier:`plugin.gui`,summary:`Read plugin GUI bundle`,description:"Read an active plugin's prebuilt CommonJS `./gui-experimental` bundle. Desktop app windows run its default export; the desktop app's main process runs its `main` export. Fails with not found when no active plugin has the id or the plugin exports no `./gui-experimental`."}))).add(D(`plugin.check`,`/api/plugin/check`,{query:X,payload:C({target:x.pipe(i)}),success:V(g(lv)),error:xo}).annotateMerge(Z).annotateMerge(k({identifier:`plugin.check`,summary:`Check plugin updates`,description:`Check one or all package plugins for available updates.`}))).add(D(`plugin.update`,`/api/plugin/update`,{query:X,payload:C({targets:g(x)}),success:T,error:[xo,Do]}).annotateMerge(Z).annotateMerge(k({identifier:`plugin.update`,summary:`Update plugins`,description:`Update package plugins concurrently and notify active locations to reload them. Responds once every update has finished; fails when any update fails.`}))).annotateMerge(k({title:`plugin`,description:`Experimental plugin routes.`})),Rv=C({version:x,pid:a.check(Re(0)),hostname:i(x),urls:g(x),paths:C({tmp:x}),capabilities:i(C({persistentPty:i(v)}))}).annotate({identifier:`ServerInfo`}),zv=C({code:x,expires_in:a}).annotate({identifier:`PairingCode`}),Bv=C({token:x}).annotate({identifier:`PairingSession`}),Vv=N(`server.server`).add(A(`server.info`,`/api/info`,{success:Rv}).annotateMerge(k({identifier:`server.info`,summary:`Get server info`,description:`Return the server identity, connection URLs, paths, and readiness status.`}))).add(D(`server.pair`,`/api/pair`,{success:zv}).annotateMerge(k({identifier:`server.pair`,summary:`Create pairing code`,description:`Create a short-lived, single-use code for a /auth/connect/:code pairing link.`}))).add(A(`server.connect`,`/auth/connect/:code`,{params:{code:x},success:Bv,error:wo}).annotateMerge(k({identifier:`server.connect`,summary:`Redeem pairing code`,description:`Redeem a pairing code. Browsers receive a session cookie and a redirect to the web app; requests that accept JSON receive a session token to use as the password.`}))).annotateMerge(k({title:`server`})),Hv=N(`server.debug`).add(D(`debug.heapDump`,`/api/debug/heap-dump`,{query:C({directory:x.pipe(i,O({description:`Absolute server-local directory to write the snapshot into, created when missing. Defaults to the server's log directory.`}))}),success:C({path:x,pid:a,memory:C({rss:gt,heapTotal:gt,heapUsed:gt,external:gt,arrayBuffers:gt}).annotate({description:`The server process's memory in bytes, read just before the snapshot (Node's process.memoryUsage()). rss covers native memory the snapshot cannot show.`})}),error:[xo,Oo]}).annotateMerge(k({identifier:`debug.heapDump`,summary:`Write a heap snapshot`,description:`Write a JavaScript heap snapshot of the server process into its log directory, or the requested directory, and return the server-local path once the file is complete. Pauses the server while the heap serializes and can temporarily increase its memory use. The snapshot can contain credentials, prompts, and file contents.`}))).add(A(`debug.location`,`/api/debug/location`,{success:g(Za)}).annotateMerge(k({identifier:`debug.location.list`,summary:`List loaded locations`,description:`List locations currently loaded by the server.`}))).add(ft(`debug.location.evict`,`/api/debug/location`,{query:X,success:T}).annotateMerge(Z).annotateMerge(k({identifier:`debug.location.evict`,summary:`Evict a loaded location`,description:`Dispose the requested location's cached services so its next use boots them fresh.`}))).annotateMerge(k({title:`debug`})),Uv=N(`server.shell`).add(A(`shell.list`,`/api/shell`,{query:X,success:V(g(Mu))}).annotateMerge(Z).annotateMerge(k({identifier:`shell.list`,summary:`List running shell commands`,description:`List currently running shell commands for a location. Exited commands are not included.`}))).add(D(`shell.create`,`/api/shell`,{query:X,payload:Lu,success:V(Mu)}).annotateMerge(Z).annotateMerge(k({identifier:`shell.create`,summary:`Run shell command`,description:`Spawn one non-interactive shell command for a location. Combined stdout/stderr is captured to a file pageable via output.`}))).add(A(`shell.get`,`/api/shell/:id`,{params:{id:Ou},query:X,success:V(Mu),error:Xo}).annotateMerge(Z).annotateMerge(k({identifier:`shell.get`,summary:`Get shell command`,description:`Get one shell command, including its status and exit code once exited.`}))).add(A(`shell.output`,`/api/shell/:id/output`,{params:{id:Ou},query:C({...X.fields,...Ru.fields}),success:V(zu),error:Xo}).annotateMerge(Z).annotateMerge(k({identifier:`shell.output`,summary:`Read shell output`,description:`Page through captured combined output by absolute byte cursor.`}))).add(ft(`shell.remove`,`/api/shell/:id`,{params:{id:Ou},query:X,success:T}).annotateMerge(Z).annotateMerge(k({identifier:`shell.remove`,summary:`Remove shell command`,description:`Terminate and remove one shell command and its retained output.`}))).annotateMerge(k({title:`shell`,description:`Location-scoped shell command routes.`})),Wv=C(o(hv.fields,[`description`,`hidden`])).annotate({identifier:`Reference.LocalSource`}),Gv=C(o(gv.fields,[`description`,`hidden`])).annotate({identifier:`Reference.GitSource`}),Kv=E([Wv,Gv]).pipe(ie(`type`)).annotate({identifier:`Reference.Source`}),qv=C({...o(vv.fields,[`source`]),source:Kv}).annotate({identifier:`Reference.Info`}),Jv=N(`server.reference`).add(A(`reference.list`,`/api/reference`,{query:X,success:V(g(qv))}).annotateMerge(Z).annotateMerge(k({identifier:`reference.list`,summary:`List references`,description:`List references available in the requested location.`}))).annotateMerge(k({title:`reference`,description:`Location-scoped project references.`})),Yv=class extends Qe()(`@opencode/HttpApiAuthorization`,{error:wo}){},Xv=N(`server.integration`).add(A(`integration.list`,`/api/integration`,{query:X,success:V(g(tc))}).annotateMerge(Z).annotateMerge(k({identifier:`integration.list`,summary:`List integrations`,description:`Retrieve available integrations and their authentication methods.`}))).add(A(`integration.get`,`/api/integration/:integrationID`,{params:{integrationID:Ws},query:X,success:V(tc),error:Ao}).annotateMerge(Z).annotateMerge(k({identifier:`integration.get`,summary:`Get integration`,description:`Retrieve one integration and its authentication methods.`}))).add(D(`integration.wellknown.add`,`/api/experimental/integration/wellknown`,{query:X,payload:C({url:x}),success:T,error:xo}).annotateMerge(Z).annotateMerge(k({identifier:`experimental.integration.wellknown.add`,summary:`Add wellknown integration`,description:`Discover and persist an experimental wellknown integration source.`}))).add(D(`integration.connect.key`,`/api/integration/:integrationID/connect/key`,{params:{integrationID:Ws},query:X,payload:C({key:x,answer:i(Fs),label:i(x)}),success:T,error:[Ao,xo]}).annotateMerge(Z).annotateMerge(k({identifier:`integration.connect.key`,summary:`Connect with key`,description:`Run a key authentication method and store the resulting credential.`}))).add(D(`integration.connect.external`,`/api/integration/:integrationID/connect/external`,{params:{integrationID:Ws},query:X,payload:C({methodID:Gs,answer:i(Fs),label:i(x)}),success:T,error:[Ao,xo]}).annotateMerge(Z).annotateMerge(k({identifier:`integration.connect.external`,summary:`Connect with external credentials`,description:`Run an external authentication method and store a reference to its credential source.`}))).add(D(`integration.oauth.connect`,`/api/integration/:integrationID/connect/oauth`,{params:{integrationID:Ws},query:X,payload:C({methodID:Gs,answer:i(Fs),label:i(x)}),success:V(ic),error:xo}).annotateMerge(Z).annotateMerge(k({identifier:`integration.oauth.connect`,summary:`Begin OAuth connection`,description:`Start an OAuth attempt and return the authorization details.`}))).add(A(`integration.oauth.status`,`/api/integration/:integrationID/connect/oauth/:attemptID`,{params:{integrationID:Ws,attemptID:nc},query:X,success:V(ac),error:[Ao,jo]}).annotateMerge(Z).annotateMerge(k({identifier:`integration.oauth.status`,summary:`Get OAuth attempt status`,description:`Poll the current status of an OAuth attempt.`}))).add(D(`integration.oauth.complete`,`/api/integration/:integrationID/connect/oauth/:attemptID/complete`,{params:{integrationID:Ws,attemptID:nc},query:X,payload:C({code:i(x)}),success:T,error:[Ao,jo,xo]}).annotateMerge(Z).annotateMerge(k({identifier:`integration.oauth.complete`,summary:`Complete OAuth connection`,description:`Complete a code-based OAuth attempt and store the resulting credential.`}))).add(ft(`integration.oauth.cancel`,`/api/integration/:integrationID/connect/oauth/:attemptID`,{params:{integrationID:Ws,attemptID:nc},query:X,success:T}).annotateMerge(Z).annotateMerge(k({identifier:`integration.oauth.cancel`,summary:`Cancel OAuth connection`,description:`Cancel an OAuth attempt and release its resources.`}))).add(D(`integration.command.connect`,`/api/integration/:integrationID/connect/command`,{params:{integrationID:Ws},query:X,payload:C({methodID:Gs,label:i(x)}),success:V(oc),error:[Ao,Mo,xo]}).annotateMerge(Z).annotateMerge(k({identifier:`integration.command.connect`,summary:`Begin command connection`,description:`Start a command authentication attempt.`}))).add(A(`integration.command.status`,`/api/integration/:integrationID/connect/command/:attemptID`,{params:{integrationID:Ws,attemptID:nc},query:X,success:V(sc),error:[Ao,jo]}).annotateMerge(Z).annotateMerge(k({identifier:`integration.command.status`,summary:`Get command attempt status`,description:`Poll the current status and output of a command authentication attempt.`}))).add(ft(`integration.command.cancel`,`/api/integration/:integrationID/connect/command/:attemptID`,{params:{integrationID:Ws,attemptID:nc},query:X,success:T}).annotateMerge(Z).annotateMerge(k({identifier:`integration.command.cancel`,summary:`Cancel command connection`,description:`Cancel a command authentication attempt and terminate its process.`}))).annotateMerge(k({title:`integration`,description:`Integration discovery and authentication routes.`})),Zv=N(`server.websearch`).add(A(`websearch.providers`,`/api/websearch/provider`,{query:X,success:V(g(ig)),error:Do}).annotateMerge(Z).annotateMerge(k({identifier:`websearch.providers`,summary:`List web search providers`,description:`Return the registered web search providers.`}))).add(D(`websearch.query`,`/api/websearch`,{query:X,payload:C(ag.fields),success:V(sg),error:[xo,Do]}).annotateMerge(Z).annotateMerge(k({identifier:`websearch.query`,summary:`Search the web`,description:`Run one web search through the selected provider. Specify a provider to override the configured default.`}))).annotateMerge(k({title:`websearch`,description:`Location-scoped web search routes.`})),Qv=P.check(Dt({minimum:0,maximum:100})),$v=P.annotate({description:`Milliseconds since the Unix epoch`}),ey=C({percent:Qv,limited:v,resetsAt:$v}).annotate({identifier:`UsageLimits.Meter`}),ty=C({rolling:ey,weekly:ey,monthly:ey}).annotate({identifier:`UsageLimits.Go`}),ny=C({providerID:hc,modelID:Nc,name:x,spent:Ac.pipe(B)}).annotate({identifier:`UsageLimits.BudgetModel`}),ry=C({id:x,limit:Ac,spent:Ac,scope:y([`each`,`combined`]),per:y([`set`,`model`]),coverage:y([`all`,`models`]),models:g(ny),vendors:g(x),inputPriceAtLeast:jc.pipe(B),picked:v,shared:v,resetsAt:$v}).annotate({identifier:`UsageLimits.Budget`}),iy=C({workspace:C({id:x,name:x.pipe(B),usageURL:x}),go:ty.pipe(B),budgets:g(ry)}).annotate({identifier:`UsageLimits.Info`}),ay=N(`server.usage`).add(A(`usage.limits`,`/api/experimental/usage/limits`,{query:X,success:V(se(iy)),error:Do}).annotateMerge(Z).annotateMerge(k({identifier:`experimental.usage.limits`,summary:`Get usage limits`,description:`Return the OpenCode Go allowance and Console budgets of the OpenCode Console workspace the location is signed in to, or null when it isn't signed in.`}))).annotateMerge(k({title:`usage`,description:`Experimental usage limit routes.`})),oy=`/api/experimental/client-mcp`,sy=C({...X.fields,name:x.check(Ce(/^[a-zA-Z0-9_-]+$/))}),cy=e=>N(`server.mcp`).add(A(`mcp.list`,`/api/mcp`,{query:X,success:V(g(Hh))}).annotateMerge(Z).annotateMerge(k({identifier:`mcp.list`,summary:`List MCP servers`,description:`Retrieve configured MCP servers and their connection status.`}))).add(St(`mcp.add`,`/api/experimental/mcp/:server`,{params:{server:x},query:X,payload:C({config:Fh}),success:T}).annotateMerge(Z).annotateMerge(k({identifier:`experimental.mcp.add`,summary:`Add MCP server`,description:`Add an MCP server at runtime or replace an existing one, connecting it immediately.`}))).add(ft(`mcp.remove`,`/api/experimental/mcp/:server`,{params:{server:x},query:X,success:T,error:zo}).annotateMerge(Z).annotateMerge(k({identifier:`experimental.mcp.remove`,summary:`Remove MCP server`,description:`Stop an MCP server and remove it from the runtime set until restart.`}))).add(D(`mcp.connect`,`/api/experimental/mcp/:server/connect`,{params:{server:x},query:X,success:T,error:zo}).annotateMerge(Z).annotateMerge(k({identifier:`experimental.mcp.connect`,summary:`Connect MCP server`,description:`Connect an MCP server at runtime, overriding a disabled configuration until restart.`}))).add(D(`mcp.disconnect`,`/api/experimental/mcp/:server/disconnect`,{params:{server:x},query:X,success:T,error:zo}).annotateMerge(Z).annotateMerge(k({identifier:`experimental.mcp.disconnect`,summary:`Disconnect MCP server`,description:`Disconnect an MCP server at runtime, removing its tools until reconnected.`}))).add(A(`mcp.resource.catalog`,`/api/mcp/resource`,{query:X,success:V(Gh)}).annotateMerge(Z).annotateMerge(k({identifier:`mcp.resource.catalog`,summary:`List MCP resources`,description:`Retrieve resources and resource templates from connected MCP servers.`}))).add(D(`mcp.clientToken`,`${oy}/token`,{query:sy,headers:C({[gp]:i(x)}),success:V(pp),error:Jo}).annotateMerge(Z).annotateMerge(k({identifier:`experimental.mcp.client.token`,summary:`Create client MCP WebSocket token`,description:`Create a short-lived single-use ticket for opening a client MCP WebSocket connection from a browser.`}))).middleware(e).add(A(`mcp.client`,oy,{query:C({...sy.fields,[hp]:i(x)}),success:v,error:[Jo,bo]}).annotateMerge(Z).annotateMerge(k({identifier:`experimental.mcp.client`,summary:`Attach client MCP server`,description:"Upgrade to a WebSocket over which the client hosts an MCP server named after `name`; its tools stay available while the socket is open. One JSON-RPC message per text frame. Experimental: may change without compatibility guarantees.",transform:e=>({...e,"x-websocket":!0})}))).annotateMerge(k({title:`mcp`,description:`MCP server and resource routes.`})),ly=N(`server.credential`).add(A(`credential.list`,`/api/credential`,{success:C({data:g(fs)})}).annotateMerge(k({identifier:`credential.list`,summary:`List credentials`,description:`List every stored integration credential, including its secret value.`}))).add(D(`credential.create`,`/api/credential`,{payload:ps,success:C({data:fs}),error:To}).annotateMerge(k({identifier:`credential.create`,summary:`Create credential`,description:`Store an integration credential. It becomes the integration's active credential unless activate is false and the integration already has one. Fails with a conflict when the requested ID already exists.`}))).add(ze(`credential.update`,`/api/credential/:credentialID`,{params:{credentialID:is},payload:C({label:x}),success:T}).annotateMerge(k({identifier:`credential.update`,summary:`Update credential`,description:`Update a stored credential label.`}))).annotateMerge(k({title:`credential`})).add(D(`credential.activate`,`/api/credential/:credentialID/activate`,{params:{credentialID:is},success:T}).annotateMerge(k({identifier:`credential.activate`,summary:`Activate credential`,description:`Activate a stored integration credential.`}))).add(ft(`credential.remove`,`/api/credential/:credentialID`,{params:{credentialID:is},success:T}).annotateMerge(k({identifier:`credential.remove`,summary:`Remove credential`,description:`Remove a stored integration credential.`}))),uy=`/api/project`,dy=C(o(bu.fields,[`projectID`])),fy=y([`true`,`false`]).pipe(wt(v,{decode:m(e=>e===`true`),encode:m(e=>e?`true`:`false`)})),py=N(`server.project`).add(A(`project.list`,uy,{query:C({archived:fy.pipe(i)}),success:g(yu)}).annotateMerge(k({identifier:`project.list`,summary:`List projects`,description:`List known projects. Archived projects are excluded unless archived=true.`}))).add(ze(`project.update`,`${uy}/:projectID`,{params:{projectID:pu},payload:dy,success:yu,error:No}).annotateMerge(k({identifier:`project.update`,summary:`Update project`,description:`Update the project canonical directory, display metadata, and workspace commands.`}))).annotateMerge(k({title:`project`,description:`Project routes.`})),my=`/api/worktree`,hy=class extends t()(`WorktreeError`,{name:h(`WorktreeError`),data:C({message:x,forceRequired:i(v)})},{httpApiStatus:400}){},gy=N(`server.worktree`).add(A(`worktree.list`,my,{query:C({projectID:pu}),success:Ng,error:No}).annotateMerge(k({identifier:`worktree.list`,summary:`List worktrees`,description:`Return the project's saved worktree inventory without loading configuration or running discovery.`}))).add(D(`worktree.create`,my,{payload:Dg,success:kg,error:[hy,No]}).annotateMerge(k({identifier:`worktree.create`,summary:`Create worktree`,description:`Load the project's canonical configuration, create a local worktree using its selected strategy, then run the project's setup script.`}))).add(ft(`worktree.remove`,my,{payload:Og,success:T,error:[hy,No]}).annotateMerge(k({identifier:`worktree.remove`,summary:`Remove worktree`,description:`Load the project's canonical configuration and remove a saved worktree using its recorded strategy.`}))).add(D(`worktree.refresh`,`${my}/refresh`,{payload:C({projectID:pu}),success:T,error:[hy,No]}).annotateMerge(k({identifier:`worktree.refresh`,summary:`Refresh worktrees`,description:`Load the project's canonical configuration, discover worktrees across known checkout roots using all available strategies, and reconcile saved state.`}))).annotateMerge(k({title:`worktree`,description:`Project-based worktree management routes.`})),_y=e({Base:()=>xy,Branch:()=>vy,BranchList:()=>by,FileStatus:()=>wy,Info:()=>yy,Mode:()=>Sy,Untracked:()=>Cy,Vcs:()=>_y}),vy=C({current:B(x),default:B(x)}).annotate({identifier:`Vcs.Branch`}),yy=C({provider:B(x),branch:vy}).annotate({identifier:`Vcs.Info`}),by=g(x).annotate({identifier:`Vcs.BranchList`}),xy=C({name:x,ref:x,source:y([`reflog`,`default`])}).annotate({identifier:`Vcs.Base`}),Sy=y([`working`,`branch`,`committed`]).annotate({identifier:`Vcs.Mode`}),Cy=y([`files`,`folders`]).annotate({identifier:`Vcs.Untracked`}),wy=C({file:x,additions:z,deletions:z,status:y([`added`,`deleted`,`modified`])}).annotate({identifier:`Vcs.FileStatus`}),Ty=C({...X.fields,provider:i(x)}),Ey=class extends t()(`VcsInitNotSupportedError`,{providerID:x,message:x},{httpApiStatus:501}){},Dy=C({...X.fields,search:i(x),limit:ae.pipe(wt(Fa),i)}),Oy=C({...X.fields,mode:Sy,base:B(x),context:ae.pipe(wt(z),i),untracked:B(Cy)}),ky=N(`server.vcs`).add(D(`vcs.init`,`/api/vcs/init`,{query:Ty,success:T,error:[To,xo,Ey,Do]}).annotateMerge(Z).annotateMerge(k({identifier:`vcs.init`,summary:`Initialize VCS repository`,description:`Initialize a repository using the selected VCS provider in a markerless project's directory and refresh its location services. Omitting provider defaults to git; built-in git and hg providers support initialization. An unknown provider returns 400; a registered provider without init returns 501.`}))).add(A(`vcs.get`,`/api/vcs`,{query:X,success:V(yy)}).annotateMerge(Z).annotateMerge(k({identifier:`vcs.get`,summary:`VCS info`,description:`Get current and default branch information for the requested location.`}))).add(A(`vcs.base`,`/api/vcs/base`,{query:X,success:V(se(xy)),error:Do}).annotateMerge(Z).annotateMerge(k({identifier:`vcs.base`,summary:`VCS review base`,description:`Infer a local review base from named branch creation history, or the repository default only when currently on that branch. Returns null before the first commit or when the provider lacks base metadata; ambiguous Git history requires an explicit base on diff requests.`}))).add(A(`vcs.status`,`/api/vcs/status`,{query:X,success:V(g(wy))}).annotateMerge(Z).annotateMerge(k({identifier:`vcs.status`,summary:`VCS status`,description:`List uncommitted working-copy changes relative to the requested location.`}))).add(A(`vcs.branch.list`,`/api/vcs/branch`,{query:Dy,success:V(by)}).annotateMerge(Z).annotateMerge(k({identifier:`vcs.branch.list`,summary:`VCS branches`,description:`List local and remote branches available at the requested location.`}))).add(A(`vcs.diff`,`/api/vcs/diff`,{query:Oy,success:V(g(Sd)),error:Do}).annotateMerge(Z).annotateMerge(k({identifier:`vcs.diff`,summary:`VCS diff`,description:`Diff HEAD to the working copy (working), the base merge-base to the working copy (branch), or the base merge-base to HEAD (committed). Omitting base preserves repository-default comparison; supplying it overrides the comparison without saving it.`}))).annotateMerge(k({title:`vcs`,description:`Location-scoped version control routes.`})),Ay=C({label:x,numerator:i(a.check(Re(0))),denominator:i(a.check(Re(0)))}),jy=E([C({status:y([`required`,`completed`])}),C({status:h(`running`),progress:Ay}),C({status:h(`error`),error:x})]),My=N(`server.migration`).add(A(`migration.v1.status`,`/api/experimental/migration/v1`,{success:jy}).annotateMerge(k({identifier:`experimental.migration.v1.status`,summary:`Get V1 migration status`,description:`Return the progress of the V1 to V2 session history migration.`}))).annotateMerge(k({title:`migration`})),Ny=C({path:x,name:x,acceptable:v}).annotate({identifier:`ConfigShell.Option`}),Py=N(`server.config`).add(A(`config.get`,`/api/config`,{query:X,success:g(Sg)}).annotateMerge(Z).annotateMerge(k({identifier:`config.get`,summary:`Get configuration`,description:`Return configuration documents and discovery sources for the requested location, from lowest to highest priority.`}))).add(A(`config.shells`,`/api/config/shell`,{success:g(Ny)}).annotateMerge(k({identifier:`config.shells`,summary:`List available shells`,description:`Return shells available to terminal and agent execution.`}))).add(ze(`config.update`,`/api/experimental/config`,{payload:yg,success:T}).annotateMerge(k({identifier:`experimental.config.update`,summary:`Update global configuration`,description:`Patch supported fields in the highest-precedence global configuration document.`}))).annotateMerge(k({title:`config`,description:`Location-scoped configuration routes.`})),Fy=(e,t,n,r)=>Pe(`server`).add(Vv).add(mp(t)).add(Iv.middleware(t)).add(Lv.middleware(t)).add(xm(r,n)).add(Lp).add(zp.middleware(t)).add(Nl).add(jp).add(Bp.middleware(t)).add(Xv.middleware(t)).add(cy(t)).add(ly).add(py).add(zm(t)).add(Tm(t,r)).add(Rm.middleware(t)).add(Wm.middleware(t)).add(Gm.middleware(t)).add(Jm.middleware(t)).add(e).add(vp(t)).add(Sp).add(Uv.middleware(t)).add(Jv.middleware(t)).add(gy).add(ky.middleware(t)).add(Hv).add(My).add(Zv.middleware(t)).add(ay.middleware(t)).add(Py.middleware(t)).annotateMerge(k({title:`opencode HttpApi`,version:`0.0.1`,description:`Experimental HttpApi surface for selected instance routes.`})).middleware(Yv).middleware(es),Iy=e=>Fy(Fv,e.locationMiddleware,e.formLocationMiddleware,e.sessionLocationMiddleware),Ly=class extends Qe()(`@opencode/client/LocationMiddleware`,{error:[bo]}){},Ry=class extends Qe()(`@opencode/client/SessionLocationMiddleware`,{error:[xo,G,bo]}){},zy=Iy({locationMiddleware:Ly,formLocationMiddleware:Ry,sessionLocationMiddleware:Ry});Rt({},{make:()=>sC});var Q=e=>Tt(e)||u(e)||ot.is(e)?new Pa({cause:e}):e,$=()=>e=>e,By=()=>e=>e,Vy=e=>()=>$()(e[`server.info`]({}).pipe(w(Q))),Hy=e=>()=>$()(e[`server.pair`]({}).pipe(w(Q))),Uy=e=>t=>$()(e[`server.connect`]({params:{code:t.code}}).pipe(w(Q))),Wy=e=>({info:Vy(e),pair:Hy(e),connect:Uy(e)}),Gy=e=>t=>$()(e[`location.get`]({query:{location:t?.location}}).pipe(w(Q))),Ky=e=>()=>$()(e[`location.reload`]({}).pipe(w(Q))),qy=e=>({get:Gy(e),reload:Ky(e)}),Jy=e=>t=>$()(e[`agent.list`]({query:{location:t?.location}}).pipe(w(Q))),Yy=e=>t=>$()(e[`agent.get`]({params:{agentID:t.agentID},query:{location:t.location}}).pipe(w(Q))),Xy=e=>({list:Jy(e),get:Yy(e)}),Zy=e=>t=>$()(e[`plugin.list`]({query:{location:t?.location}}).pipe(w(Q))),Qy=e=>t=>$()(e[`plugin.gui`]({query:{location:t.location,id:t.id}}).pipe(w(Q))),$y=e=>t=>$()(e[`plugin.check`]({query:{location:t?.location},payload:{target:t?.target}}).pipe(w(Q))),eb=e=>t=>$()(e[`plugin.update`]({query:{location:t.location},payload:{targets:t.targets}}).pipe(w(Q))),tb=e=>({list:Zy(e),gui:Qy(e),check:$y(e),update:eb(e)}),nb=e=>t=>$()(e[`session.list`]({query:{limit:t?.limit,order:t?.order,search:t?.search,parentID:t?.parentID,archived:t?.archived,directory:t?.directory,project:t?.project,subpath:t?.subpath,cursor:t?.cursor}}).pipe(w(Q))),rb=e=>t=>$()(e[`session.stats`]({query:{from:t?.from,to:t?.to,project:t?.project,timezone:t?.timezone,tools:t?.tools}}).pipe(w(Q),j(e=>e.data))),ib=e=>t=>$()(e[`session.create`]({payload:{id:t?.id,parentID:t?.parentID,title:t?.title,agent:t?.agent,model:t?.model,location:t?.location,metadata:t?.metadata,permissions:t?.permissions}}).pipe(w(Q),j(e=>e.data))),ab=e=>t=>$()(e[`session.import`]({payload:{info:t.info,messages:t.messages,location:t.location}}).pipe(w(Q),j(e=>e.data))),ob=e=>t=>$()(e[`session.export`]({params:{sessionID:t.sessionID},query:{sanitize:t.sanitize}}).pipe(w(Q),j(e=>e.data))),sb=e=>()=>$()(e[`session.active`]({}).pipe(w(Q),j(e=>e.data))),cb=e=>t=>$()(e[`session.get`]({params:{sessionID:t.sessionID}}).pipe(w(Q),j(e=>e.data))),lb=e=>t=>$()(e[`session.remove`]({params:{sessionID:t.sessionID}}).pipe(w(Q))),ub=e=>t=>$()(e[`session.fork`]({params:{sessionID:t.sessionID},payload:{before:t.before}}).pipe(w(Q),j(e=>e.data))),db=e=>t=>$()(e[`session.switchAgent`]({params:{sessionID:t.sessionID},payload:{agent:t.agent}}).pipe(w(Q))),fb=e=>t=>$()(e[`session.switchModel`]({params:{sessionID:t.sessionID},payload:{model:t.model}}).pipe(w(Q))),pb=e=>t=>$()(e[`session.update`]({params:{sessionID:t.sessionID},payload:{title:t.title,metadata:t.metadata,permissions:t.permissions,archived:t.archived}}).pipe(w(Q))),mb=e=>t=>$()(e[`session.move`]({params:{sessionID:t.sessionID},payload:{directory:t.directory,delivery:t.delivery}}).pipe(w(Q))),hb=e=>t=>$()(e[`session.prompt`]({params:{sessionID:t.sessionID},payload:{id:t.id,text:t.text,files:t.files,agents:t.agents,skills:t.skills,metadata:t.metadata,delivery:t.delivery,resume:t.resume}}).pipe(w(Q),j(e=>e.data))),gb=e=>t=>$()(e[`session.command`]({params:{sessionID:t.sessionID},payload:{name:t.name,text:t.text,files:t.files,agents:t.agents,skills:t.skills,delivery:t.delivery}}).pipe(w(Q))),_b=e=>t=>$()(e[`session.skill`]({params:{sessionID:t.sessionID},payload:{id:t.id,resume:t.resume}}).pipe(w(Q))),vb=e=>t=>$()(e[`session.synthetic`]({params:{sessionID:t.sessionID},payload:{id:t.id,text:t.text,description:t.description,metadata:t.metadata,delivery:t.delivery,resume:t.resume}}).pipe(w(Q),j(e=>e.data))),yb=e=>t=>$()(e[`session.shell`]({params:{sessionID:t.sessionID},payload:{id:t.id,command:t.command}}).pipe(w(Q))),bb=e=>t=>$()(e[`session.compact`]({params:{sessionID:t.sessionID},payload:{id:t.id,delivery:t.delivery}}).pipe(w(Q),j(e=>e.data))),xb=e=>t=>$()(e[`session.wait`]({params:{sessionID:t.sessionID}}).pipe(w(Q))),Sb=e=>t=>$()(e[`session.revert.stage`]({params:{sessionID:t.sessionID},payload:{messageID:t.messageID,files:t.files}}).pipe(w(Q),j(e=>e.data))),Cb=e=>t=>$()(e[`session.revert.clear`]({params:{sessionID:t.sessionID}}).pipe(w(Q))),wb=e=>t=>$()(e[`session.revert.commit`]({params:{sessionID:t.sessionID}}).pipe(w(Q))),Tb=e=>t=>$()(e[`session.context`]({params:{sessionID:t.sessionID}}).pipe(w(Q),j(e=>e.data))),Eb=e=>t=>$()(e[`session.diff`]({params:{sessionID:t.sessionID},query:{from:t.from,to:t.to,context:t.context}}).pipe(w(Q),j(e=>e.data))),Db=e=>t=>$()(e[`session.inbox.list`]({params:{sessionID:t.sessionID}}).pipe(w(Q),j(e=>e.data))),Ob=e=>t=>$()(e[`session.inbox.cancel`]({params:{sessionID:t.sessionID,inboxID:t.inboxID}}).pipe(w(Q))),kb=e=>t=>$()(e[`session.inbox.update`]({params:{sessionID:t.sessionID,inboxID:t.inboxID},payload:{delivery:t.delivery}}).pipe(w(Q))),Ab=e=>t=>$()(e[`session.instructions.entry.list`]({params:{sessionID:t.sessionID}}).pipe(w(Q),j(e=>e.data))),jb=e=>t=>$()(e[`session.instructions.entry.put`]({params:{sessionID:t.sessionID,key:t.key},payload:{value:t.value}}).pipe(w(Q))),Mb=e=>t=>$()(e[`session.instructions.entry.remove`]({params:{sessionID:t.sessionID,key:t.key}}).pipe(w(Q))),Nb=e=>t=>$()(e[`session.generate`]({params:{sessionID:t.sessionID},payload:{prompt:t.prompt}}).pipe(w(Q),j(e=>e.data))),Pb=e=>t=>By()(r(e[`session.log`]({params:{sessionID:t.sessionID},query:{after:t.after,follow:t.follow}}).pipe(w(Q),j(e=>e.pipe(pe(Q)))))),Fb=e=>t=>$()(e[`session.interrupt`]({params:{sessionID:t.sessionID},query:{resume:t.resume}}).pipe(w(Q))),Ib=e=>t=>$()(e[`session.background`]({params:{sessionID:t.sessionID}}).pipe(w(Q))),Lb=e=>t=>$()(e[`session.message`]({params:{sessionID:t.sessionID,messageID:t.messageID}}).pipe(w(Q),j(e=>e.data))),Rb=e=>t=>$()(e[`session.form.list`]({params:{sessionID:t.sessionID}}).pipe(w(Q),j(e=>e.data))),zb=e=>t=>$()(e[`session.form.create`]({params:{sessionID:t.sessionID},payload:{id:t.id,title:t.title,metadata:t.metadata,fields:t.fields}}).pipe(w(Q),j(e=>e.data))),Bb=e=>t=>$()(e[`session.form.get`]({params:{sessionID:t.sessionID,formID:t.formID}}).pipe(w(Q),j(e=>e.data))),Vb=e=>t=>$()(e[`session.form.reply`]({params:{sessionID:t.sessionID,formID:t.formID},payload:{answer:t.answer}}).pipe(w(Q))),Hb=e=>t=>$()(e[`session.form.cancel`]({params:{sessionID:t.sessionID,formID:t.formID},query:{message:t.message}}).pipe(w(Q))),Ub=e=>t=>$()(e[`session.environment`]({params:{sessionID:t.sessionID},payload:{variables:t.variables}}).pipe(w(Q))),Wb=e=>t=>$()(e[`session.view`]({params:{sessionID:t.sessionID},payload:{idle:t.idle}}).pipe(w(Q))),Gb=e=>({list:nb(e),stats:rb(e),create:ib(e),import:ab(e),export:ob(e),active:sb(e),get:cb(e),remove:lb(e),fork:ub(e),switchAgent:db(e),switchModel:fb(e),update:pb(e),move:mb(e),prompt:hb(e),command:gb(e),skill:_b(e),synthetic:vb(e),shell:yb(e),compact:bb(e),wait:xb(e),revert:{stage:Sb(e),clear:Cb(e),commit:wb(e)},context:Tb(e),diff:Eb(e),inbox:{list:Db(e),cancel:Ob(e),update:kb(e)},instructions:{entry:{list:Ab(e),put:jb(e),remove:Mb(e)}},generate:Nb(e),log:Pb(e),interrupt:Fb(e),background:Ib(e),message:{get:Lb(e)},form:{list:Rb(e),create:zb(e),get:Bb(e),reply:Vb(e),cancel:Hb(e)},environment:Ub(e),view:Wb(e)}),Kb=e=>t=>$()(e[`session.messages`]({params:{sessionID:t.sessionID},query:{limit:t.limit,order:t.order,cursor:t.cursor,type:t.type}}).pipe(w(Q))),qb=e=>({list:Kb(e)}),Jb=e=>t=>$()(e[`model.list`]({query:{location:t?.location,types:t?.types}}).pipe(w(Q))),Yb=e=>t=>$()(e[`model.default`]({query:{location:t?.location}}).pipe(w(Q))),Xb=e=>({list:Jb(e),default:Yb(e)}),Zb=e=>t=>$()(e[`generate.text`]({payload:{prompt:t.prompt,model:t.model}}).pipe(w(Q),j(e=>e.data))),Qb=e=>t=>$()(e[`generate.image`]({payload:{model:t.model,prompt:t.prompt,images:t.images,n:t.n,aspect:t.aspect,resolution:t.resolution}}).pipe(w(Q),j(e=>e.data))),$b=e=>t=>$()(e[`generate.decisions`]({payload:{model:t.model,input:t.input,questions:t.questions}}).pipe(w(Q),j(e=>e.data))),ex=e=>({text:Zb(e),image:Qb(e),decisions:$b(e)}),tx=e=>()=>$()(e[`voice.models`]({}).pipe(w(Q),j(e=>e.data))),nx=e=>t=>$()(e[`voice.session`]({payload:{model:t.model,session:t.session,transport:t.transport}}).pipe(w(Q),j(e=>e.data))),rx=e=>({models:tx(e),session:nx(e)}),ix=e=>t=>$()(e[`provider.list`]({query:{location:t?.location}}).pipe(w(Q))),ax=e=>t=>$()(e[`provider.get`]({params:{providerID:t.providerID},query:{location:t.location}}).pipe(w(Q))),ox=e=>({list:ix(e),get:ax(e)}),sx=e=>t=>$()(e[`integration.list`]({query:{location:t?.location}}).pipe(w(Q))),cx=e=>t=>$()(e[`integration.get`]({params:{integrationID:t.integrationID},query:{location:t.location}}).pipe(w(Q))),lx=e=>t=>$()(e[`integration.wellknown.add`]({query:{location:t.location},payload:{url:t.url}}).pipe(w(Q))),ux=e=>t=>$()(e[`integration.connect.key`]({params:{integrationID:t.integrationID},query:{location:t.location},payload:{key:t.key,answer:t.answer,label:t.label}}).pipe(w(Q))),dx=e=>t=>$()(e[`integration.connect.external`]({params:{integrationID:t.integrationID},query:{location:t.location},payload:{methodID:t.methodID,answer:t.answer,label:t.label}}).pipe(w(Q))),fx=e=>t=>$()(e[`integration.oauth.connect`]({params:{integrationID:t.integrationID},query:{location:t.location},payload:{methodID:t.methodID,answer:t.answer,label:t.label}}).pipe(w(Q))),px=e=>t=>$()(e[`integration.oauth.status`]({params:{integrationID:t.integrationID,attemptID:t.attemptID},query:{location:t.location}}).pipe(w(Q))),mx=e=>t=>$()(e[`integration.oauth.complete`]({params:{integrationID:t.integrationID,attemptID:t.attemptID},query:{location:t.location},payload:{code:t.code}}).pipe(w(Q))),hx=e=>t=>$()(e[`integration.oauth.cancel`]({params:{integrationID:t.integrationID,attemptID:t.attemptID},query:{location:t.location}}).pipe(w(Q))),gx=e=>t=>$()(e[`integration.command.connect`]({params:{integrationID:t.integrationID},query:{location:t.location},payload:{methodID:t.methodID,label:t.label}}).pipe(w(Q))),_x=e=>t=>$()(e[`integration.command.status`]({params:{integrationID:t.integrationID,attemptID:t.attemptID},query:{location:t.location}}).pipe(w(Q))),vx=e=>t=>$()(e[`integration.command.cancel`]({params:{integrationID:t.integrationID,attemptID:t.attemptID},query:{location:t.location}}).pipe(w(Q))),yx=e=>({list:sx(e),get:cx(e),wellknown:{add:lx(e)},connect:{key:ux(e),external:dx(e)},oauth:{connect:fx(e),status:px(e),complete:mx(e),cancel:hx(e)},command:{connect:gx(e),status:_x(e),cancel:vx(e)}}),bx=e=>t=>$()(e[`mcp.list`]({query:{location:t?.location}}).pipe(w(Q))),xx=e=>t=>$()(e[`mcp.add`]({params:{server:t.server},query:{location:t.location},payload:{config:t.config}}).pipe(w(Q))),Sx=e=>t=>$()(e[`mcp.remove`]({params:{server:t.server},query:{location:t.location}}).pipe(w(Q))),Cx=e=>t=>$()(e[`mcp.connect`]({params:{server:t.server},query:{location:t.location}}).pipe(w(Q))),wx=e=>t=>$()(e[`mcp.disconnect`]({params:{server:t.server},query:{location:t.location}}).pipe(w(Q))),Tx=e=>t=>$()(e[`mcp.resource.catalog`]({query:{location:t?.location}}).pipe(w(Q))),Ex=e=>t=>$()(e[`mcp.clientToken`]({query:{location:t.location,name:t.name},headers:{"x-opencode-ticket":t[`x-opencode-ticket`]}}).pipe(w(Q))),Dx=e=>({list:bx(e),add:xx(e),remove:Sx(e),connect:Cx(e),disconnect:wx(e),resource:{catalog:Tx(e)},client:{token:Ex(e)}}),Ox=e=>()=>$()(e[`credential.list`]({}).pipe(w(Q),j(e=>e.data))),kx=e=>t=>$()(e[`credential.create`]({payload:{id:t.id,integrationID:t.integrationID,label:t.label,value:t.value,activate:t.activate}}).pipe(w(Q),j(e=>e.data))),Ax=e=>t=>$()(e[`credential.update`]({params:{credentialID:t.credentialID},payload:{label:t.label}}).pipe(w(Q))),jx=e=>t=>$()(e[`credential.activate`]({params:{credentialID:t.credentialID}}).pipe(w(Q))),Mx=e=>t=>$()(e[`credential.remove`]({params:{credentialID:t.credentialID}}).pipe(w(Q))),Nx=e=>({list:Ox(e),create:kx(e),update:Ax(e),activate:jx(e),remove:Mx(e)}),Px=e=>t=>$()(e[`project.list`]({query:{archived:t?.archived}}).pipe(w(Q))),Fx=e=>t=>$()(e[`project.update`]({params:{projectID:t.projectID},payload:{canonical:t.canonical,name:t.name,icon:t.icon,commands:t.commands}}).pipe(w(Q))),Ix=e=>({list:Px(e),update:Fx(e)}),Lx=e=>t=>$()(e[`form.list`]({query:{location:t?.location}}).pipe(w(Q))),Rx=e=>({list:Lx(e)}),zx=e=>t=>$()(e[`permission.request.list`]({query:{location:t?.location}}).pipe(w(Q))),Bx=e=>t=>$()(e[`permission.saved.list`]({query:{projectID:t?.projectID}}).pipe(w(Q),j(e=>e.data))),Vx=e=>t=>$()(e[`permission.saved.update`]({params:{id:t.id},payload:{action:t.action,resource:t.resource}}).pipe(w(Q),j(e=>e.data))),Hx=e=>t=>$()(e[`permission.saved.remove`]({params:{id:t.id}}).pipe(w(Q))),Ux=e=>t=>$()(e[`session.permission.create`]({params:{sessionID:t.sessionID},payload:{id:t.id,action:t.action,resources:t.resources,save:t.save,metadata:t.metadata,source:t.source,agent:t.agent}}).pipe(w(Q),j(e=>e.data))),Wx=e=>t=>$()(e[`session.permission.list`]({params:{sessionID:t.sessionID}}).pipe(w(Q),j(e=>e.data))),Gx=e=>t=>$()(e[`session.permission.get`]({params:{sessionID:t.sessionID,requestID:t.requestID}}).pipe(w(Q),j(e=>e.data))),Kx=e=>t=>$()(e[`session.permission.reply`]({params:{sessionID:t.sessionID,requestID:t.requestID},payload:{decision:t.decision,message:t.message}}).pipe(w(Q))),qx=e=>({request:{list:zx(e)},saved:{list:Bx(e),update:Vx(e),remove:Hx(e)},create:Ux(e),list:Wx(e),get:Gx(e),reply:Kx(e)}),Jx=e=>t=>$()(e[`fs.list`]({query:{location:t?.location,path:t?.path}}).pipe(w(Q))),Yx=e=>t=>$()(e[`fs.find`]({query:{location:t.location,query:t.query,type:t.type,limit:t.limit}}).pipe(w(Q))),Xx=e=>t=>$()(e[`fs.watch`]({query:{location:t.location},payload:{path:t.path}}).pipe(w(Q))),Zx=e=>t=>$()(e[`fs.unwatch`]({query:{location:t.location},payload:{path:t.path}}).pipe(w(Q))),Qx=e=>({list:Jx(e),find:Yx(e),watch:Xx(e),unwatch:Zx(e)}),$x=e=>t=>$()(e[`command.list`]({query:{location:t?.location}}).pipe(w(Q))),eS=e=>({list:$x(e)}),tS=e=>t=>$()(e[`skill.list`]({query:{location:t?.location}}).pipe(w(Q))),nS=e=>({list:tS(e)}),rS=e=>t=>$()(e[`rpc.call`]({params:{rpcID:t.rpcID,method:t.method},query:{location:t.location},payload:{input:t.input}}).pipe(w(Q))),iS=e=>({call:rS(e)}),aS=e=>t=>By()(r(e[`event.subscribe`]({query:{types:t?.types}}).pipe(w(Q),j(e=>e.pipe(pe(Q)))))),oS=e=>({subscribe:aS(e)}),sS=e=>t=>$()(e[`pty.list`]({query:{location:t?.location}}).pipe(w(Q))),cS=e=>t=>$()(e[`pty.create`]({query:{location:t?.location},payload:{command:t?.command,args:t?.args,cwd:t?.cwd,title:t?.title,env:t?.env}}).pipe(w(Q))),lS=e=>t=>$()(e[`pty.get`]({params:{ptyID:t.ptyID},query:{location:t.location}}).pipe(w(Q))),uS=e=>t=>$()(e[`pty.update`]({params:{ptyID:t.ptyID},query:{location:t.location},payload:{title:t.title,size:t.size}}).pipe(w(Q))),dS=e=>t=>$()(e[`pty.remove`]({params:{ptyID:t.ptyID},query:{location:t.location}}).pipe(w(Q))),fS=e=>t=>$()(e[`pty.connectToken`]({params:{ptyID:t.ptyID},query:{location:t.location},headers:{"x-opencode-ticket":t[`x-opencode-ticket`]}}).pipe(w(Q))),pS=e=>({list:sS(e),create:cS(e),get:lS(e),update:uS(e),remove:dS(e),connect:{token:fS(e)}}),mS=e=>t=>$()(e[`persistentPty.read`]({params:{sessionID:t.sessionID},query:{lines:t.lines}}).pipe(w(Q),j(e=>e.data))),hS=e=>t=>$()(e[`persistentPty.list`]({params:{sessionID:t.sessionID}}).pipe(w(Q),j(e=>e.data))),gS=e=>t=>$()(e[`persistentPty.create`]({params:{sessionID:t.sessionID},payload:{command:t.command,args:t.args,cwd:t.cwd,title:t.title,env:t.env,size:t.size}}).pipe(w(Q),j(e=>e.data))),_S=e=>()=>$()(e[`persistentPty.shutdown`]({}).pipe(w(Q))),vS=e=>()=>$()(e[`persistentPty.handoff`]({}).pipe(w(Q))),yS=e=>t=>$()(e[`persistentPty.get`]({params:{ptyID:t.ptyID}}).pipe(w(Q),j(e=>e.data))),bS=e=>t=>$()(e[`persistentPty.update`]({params:{ptyID:t.ptyID},payload:{attachmentID:t.attachmentID,size:t.size}}).pipe(w(Q),j(e=>e.data))),xS=e=>t=>$()(e[`persistentPty.snapshot`]({params:{ptyID:t.ptyID}}).pipe(w(Q),j(e=>e.data))),SS=e=>t=>$()(e[`persistentPty.remove`]({params:{ptyID:t.ptyID}}).pipe(w(Q))),CS=e=>t=>$()(e[`persistentPty.connectToken`]({params:{ptyID:t.ptyID},headers:{"x-opencode-ticket":t[`x-opencode-ticket`]}}).pipe(w(Q),j(e=>e.data))),wS=e=>({persistentPty:{read:mS(e),list:hS(e),create:gS(e),shutdown:_S(e),handoff:vS(e),get:yS(e),update:bS(e),snapshot:xS(e),remove:SS(e),connectToken:CS(e)}}),TS=e=>t=>$()(e[`shell.list`]({query:{location:t?.location}}).pipe(w(Q))),ES=e=>t=>$()(e[`shell.create`]({query:{location:t.location},payload:{command:t.command,cwd:t.cwd,timeout:t.timeout,metadata:t.metadata}}).pipe(w(Q))),DS=e=>t=>$()(e[`shell.get`]({params:{id:t.id},query:{location:t.location}}).pipe(w(Q))),OS=e=>t=>$()(e[`shell.output`]({params:{id:t.id},query:{location:t.location,cursor:t.cursor,limit:t.limit}}).pipe(w(Q))),kS=e=>t=>$()(e[`shell.remove`]({params:{id:t.id},query:{location:t.location}}).pipe(w(Q))),AS=e=>({list:TS(e),create:ES(e),get:DS(e),output:OS(e),remove:kS(e)}),jS=e=>t=>$()(e[`reference.list`]({query:{location:t?.location}}).pipe(w(Q))),MS=e=>({list:jS(e)}),NS=e=>t=>$()(e[`worktree.list`]({query:{projectID:t.projectID}}).pipe(w(Q))),PS=e=>t=>$()(e[`worktree.create`]({payload:{projectID:t.projectID,from:t.from,branch:t.branch,directory:t.directory,name:t.name}}).pipe(w(Q))),FS=e=>t=>$()(e[`worktree.remove`]({payload:{projectID:t.projectID,directory:t.directory,force:t.force}}).pipe(w(Q))),IS=e=>t=>$()(e[`worktree.refresh`]({payload:{projectID:t.projectID}}).pipe(w(Q))),LS=e=>({list:NS(e),create:PS(e),remove:FS(e),refresh:IS(e)}),RS=e=>t=>$()(e[`vcs.init`]({query:{location:t?.location,provider:t?.provider}}).pipe(w(Q))),zS=e=>t=>$()(e[`vcs.get`]({query:{location:t?.location}}).pipe(w(Q))),BS=e=>t=>$()(e[`vcs.base`]({query:{location:t?.location}}).pipe(w(Q))),VS=e=>t=>$()(e[`vcs.status`]({query:{location:t?.location}}).pipe(w(Q))),HS=e=>t=>$()(e[`vcs.branch.list`]({query:{location:t?.location,search:t?.search,limit:t?.limit}}).pipe(w(Q))),US=e=>t=>$()(e[`vcs.diff`]({query:{location:t.location,mode:t.mode,base:t.base,context:t.context,untracked:t.untracked}}).pipe(w(Q))),WS=e=>({init:RS(e),get:zS(e),base:BS(e),status:VS(e),branch:{list:HS(e)},diff:US(e)}),GS=e=>t=>$()(e[`debug.heapDump`]({query:{directory:t?.directory}}).pipe(w(Q))),KS=e=>()=>$()(e[`debug.location`]({}).pipe(w(Q))),qS=e=>t=>$()(e[`debug.location.evict`]({query:{location:t?.location}}).pipe(w(Q))),JS=e=>({heapDump:GS(e),location:{list:KS(e),evict:qS(e)}}),YS=e=>()=>$()(e[`migration.v1.status`]({}).pipe(w(Q))),XS=e=>({v1:{status:YS(e)}}),ZS=e=>t=>$()(e[`websearch.providers`]({query:{location:t?.location}}).pipe(w(Q))),QS=e=>t=>$()(e[`websearch.query`]({query:{location:t.location},payload:{query:t.query,providerID:t.providerID}}).pipe(w(Q))),$S=e=>({providers:ZS(e),query:QS(e)}),eC=e=>t=>$()(e[`usage.limits`]({query:{location:t?.location}}).pipe(w(Q))),tC=e=>({limits:eC(e)}),nC=e=>t=>$()(e[`config.get`]({query:{location:t?.location}}).pipe(w(Q))),rC=e=>()=>$()(e[`config.shells`]({}).pipe(w(Q))),iC=e=>t=>$()(e[`config.update`]({payload:{shell:t.shell}}).pipe(w(Q))),aC=e=>({get:nC(e),shells:rC(e),update:iC(e)}),oC=e=>({server:Wy(e[`server.server`]),location:qy(e[`server.location`]),agent:Xy(e[`server.agent`]),plugin:tb(e[`server.plugin`]),session:Gb(e[`server.session`]),message:qb(e[`server.message`]),model:Xb(e[`server.model`]),generate:ex(e[`server.generate`]),voice:rx(e[`server.voice`]),provider:ox(e[`server.provider`]),integration:yx(e[`server.integration`]),mcp:Dx(e[`server.mcp`]),credential:Nx(e[`server.credential`]),project:Ix(e[`server.project`]),form:Rx(e[`server.form`]),permission:qx(e[`server.permission`]),file:Qx(e[`server.fs`]),command:eS(e[`server.command`]),skill:nS(e[`server.skill`]),rpc:iS(e[`server.rpc`]),event:oS(e[`server.event`]),pty:pS(e[`server.pty`]),experimental:wS(e[`server.experimental`]),shell:AS(e[`server.shell`]),reference:MS(e[`server.reference`]),worktree:LS(e[`server.worktree`]),vcs:WS(e[`server.vcs`]),debug:JS(e[`server.debug`]),migration:XS(e[`server.migration`]),websearch:$S(e[`server.websearch`]),usage:tC(e[`server.usage`]),config:aC(e[`server.config`])}),sC=e=>lt(zy,e).pipe(j(oC)),cC={};Rt(cC,{RpcRuntime:()=>cC,event:()=>dC,eventType:()=>fC,read:()=>lC,readError:()=>uC});function lC(e,t){return f(e)?He(e)(t):Ve(t)}function uC(e,t){return!(t instanceof So)&&!(t instanceof Co)?ut(t):!e.errors||!Object.hasOwn(e.errors,t.type)?ut(t.data===void 0?{type:t.type,message:t.message}:{type:t.type,message:t.message,data:t.data}):lC(e.errors[t.type],t.data).pipe(n(e=>bt(e)),vt(e=>ut(e===void 0?{type:t.type,message:t.message}:{type:t.type,message:t.message,data:e})))}var dC=$e(`Client.Rpc.event`)(function*(e,t,n,r){let i=yield*lC(n.schema,r.data);return{...r,type:fC(e,t),data:i}});function fC(e,t){return`rpc.${e.id}.${t}`}var pC={};Rt(pC,{RpcClientRuntime:()=>pC,aborted:()=>hC,make:()=>mC});function mC(e,t){return r=>{let i=Object.fromEntries(Object.entries(r.methods).map(([t,i])=>[t,(a,o)=>{let s=Fe(function*(){let n=yield*e({rpcID:r.id,method:t,input:a,location:o?.location},o);return yield*lC(i.output,n.output)}).pipe(n(e=>uC(i,e))),c=o?.signal;return c?ht(()=>c.aborted?pt:Ct(s,Ae(hC(c),pt))):s}]));return Object.assign(i,{events:{subscribe:e=>{let n=fC(r,e);if(!Object.hasOwn(r.events,e))return be(Error(`Unknown RPC event: ${n}`));let i=r.events[e];return t().pipe(Ot(e=>e.type===n),l(t=>dC(r,e,i,t)))}}})}}function hC(e){return _e(t=>{if(e.aborted)return t(Xe);let n=()=>t(Xe);return e.addEventListener(`abort`,n,{once:!0}),st(()=>e.removeEventListener(`abort`,n))})}var gC={};Rt(gC,{OpenCode:()=>gC,make:()=>vC});var _C=Et(`@opencode/client/effect/rpc/headers`,{defaultValue:()=>{}}),vC=$e(`OpenCode.make`)(function*(e){let t=yield*Ye,n=yield*sC(e).pipe(it(Ye,qe(t,e=>j(_C,t=>t?je(e,new Headers(t)):e)))),r=yield*Ue(),i=n.event.subscribe();class a{cause;constructor(e){this.cause=e}}let o=Bt(e=>nt(i.pipe(d(hC(e)),Le(e=>be(new a(e)))),r)),c=e=>Se(o.subscribe({types:e?.types}),e=>e).pipe(At(e=>s(e instanceof a?e.cause:Je(new Pa({cause:e})))));return{...n,event:{...n.event,subscribe:c},rpc:Object.assign(mC((e,t)=>n.rpc.call(e).pipe(it(_C,t?.headers)),c),n.rpc)}}),yC=e({Answer:()=>CC,Prompt:()=>SC,Question:()=>yC}),bC=C({label:x.annotate({description:`Display text (1-5 words, concise)`}),description:x.annotate({description:`Explanation of choice`})}),xC={question:x.annotate({description:`Complete question`}),header:x.annotate({description:`Very short label (max 30 chars)`}),options:g(bC).annotate({description:`Available choices`}),multiple:v.pipe(B).annotate({description:`Allow selecting multiple choices`})},SC=C(xC).annotate({identifier:`Question.Prompt`}),CC=g(x).annotate({identifier:`Question.Answer`}),wC=e({AbsolutePath:()=>La,Agent:()=>au,ClientError:()=>Pa,Command:()=>Bm,Config:()=>_g,Credential:()=>rs,Event:()=>eo,EventLog:()=>lm,FileSystem:()=>Em,Form:()=>vs,Integration:()=>Us,Location:()=>Ya,Model:()=>Mc,OpenCode:()=>gC,Permission:()=>ql,PermissionSaved:()=>Sm,Project:()=>fu,Prompt:()=>rl,PromptInput:()=>Vp,Provider:()=>mc,Pty:()=>Il,Question:()=>yC,Reference:()=>fv,RelativePath:()=>Ia,Session:()=>Wf,SessionInbox:()=>Rd,SessionMessage:()=>Uu,Skill:()=>lo,Vcs:()=>_y,WebSearch:()=>ng,Worktree:()=>Tg}),TC=20;function EC(e){return JSON.stringify([e.directory,e.workspaceID])}function DC(e){return{directory:e.directory}}function OC(e){let t=e?.flatMap(e=>{if(!e.uri.startsWith(`data:`))return[];let t=e.uri.indexOf(`,`);if(t<0)return[];let n=e.uri.slice(5,t).split(`;`);if(!n.slice(1).some(e=>e.toLowerCase()===`base64`))return[];let r={data:e.uri.slice(t+1),mime:n[0]||`application/octet-stream`,source:{type:`inline`}};return e.name!==void 0&&(r.name=e.name),e.description!==void 0&&(r.description=e.description),e.mention!==void 0&&(r.mention={...e.mention}),[r]});return t?.length?t:void 0}function kC(e){let t=e=>e.type===`file`&&e.uri.startsWith(`data:`)?{...e,uri:`data:${e.mime};base64,`}:e;return[t(e[0]),...e.slice(1).map(t)]}function AC(e){return e.type===`assistant`?{...e,content:e.content.map(e=>e.type===`tool`&&`content`in e.state&&e.state.content?{...e,state:{...e.state,content:kC(e.state.content)}}:e)}:e}function jC(e,t){if(!(e!==`global`||!t))return{headers:{"x-opencode-directory":encodeURIComponent(t.directory)}}}function MC(){let e=new Map,t=(t,n,r)=>{let i={promise:Promise.resolve(),invalidated:!1,started:!r};e.set(t,i);let a=()=>(i.started=!0,n());return i.promise=(r?r.catch(()=>{}).then(a):a()).then(()=>{e.get(t)===i&&!i.invalidated&&e.set(t,!0)}).finally(()=>{e.get(t)===i&&e.delete(t)}),i.promise};return{run(n,r){let i=e.get(n);return i===!0?Promise.resolve():i?i.invalidated?t(n,r,i.promise):i.promise:t(n,r)},complete(t){e.has(t)||e.set(t,!0)},has(t){return e.has(t)},pending(t){let n=e.get(t);return n!==void 0&&n!==!0},invalidate(t){if(t){let n=e.get(t);n===!0&&e.delete(t),n!==void 0&&n!==!0&&n.started&&(n.invalidated=!0);return}e.forEach((t,n)=>{t===!0&&e.delete(n),t!==!0&&t.started&&(t.invalidated=!0)})}}}var NC=200;function PC(e){let t=e.api,n=!1;Br(()=>n=!0);function r(t){n||e.connection&&e.connection.status()!==`connected`||t().catch(t=>{if(!(n||e.connection&&e.connection.status()!==`connected`)){if(e.onError)return e.onError(t);console.error(`Failed to refresh client data`,t)}})}let i=new Map;Br(()=>i.forEach(e=>clearTimeout(e)));function a(e,t){clearTimeout(i.get(e)),i.set(e,setTimeout(()=>{i.delete(e),r(t)},150))}let[o,s]=xa({session:{info:{},family:{},active:{},message:{},messageCursor:{},messageLoading:{},pending:{},permission:{},form:{}},project:{info:{},permission:{}},location:{}}),[c,l]=Er({directory:e.directory}),u=jr(()=>Object.values(o.session.info).toSorted((e,t)=>t.time.updated-e.time.updated)),d=new Map,f=t=>e.omitToolFileData?AC(t):t,p=MC(),ee,te=new Map;function m(e,t){ee?.set(e,t),s(`session`,`active`,e,t)}function h(e,t){t&&(te.get(e)?.set(t,void 0),o.session.pending[e]?.some(e=>e.id===t)&&s(`session`,`pending`,e,(o.session.pending[e]??[]).filter(e=>e.id!==t)))}function ne(e,t){let n=o.session.permission[e];n?.some(e=>e.id===t)&&s(`session`,`permission`,e,n.filter(e=>e.id!==t))}function re(e,t,n){let r=o.session.form[e];if(!r)return!1;let i=n&&EC(n),a=r.filter(n=>n.id===t?e!==`global`||!i?!1:!n.location||EC(n.location)!==i:!0);return a.length!==r.length&&(s(`session`,`form`,e,a),!0)}function ie(e,t,n){return n.catch(t=>{if(!fn(t)&&!mn(t)||t.id!==e.formID)throw t}).then(()=>{re(e.sessionID,e.formID,t)&&(b.session.form.invalidate(e.sessionID,t),b.session.form.sync(e.sessionID,t).catch(()=>{}))})}function ae(e,t,n){let r=o.session.pending[e]?.findIndex(e=>e.id===t)??-1,i=o.session.pending[e]?.[r];te.get(e)?.set(t,i?{...i,delivery:n}:n),!(r<0||!i||i.delivery===n)&&s(`session`,`pending`,e,r,{...i,delivery:n})}let oe=new Set,se=new Set,ce=new Map,le=new Map,ue=new Map,de=new Map;Br(()=>de.clear());function fe(e,t,n){e.set(t,n);let r=()=>{e.get(t)===n&&e.delete(t)};n.then(r,r)}function g(e,t,n){let r=ce.get(e),i=le.get(e),a=Promise.resolve().then(()=>Promise.all([n,r,i])).then(t);return fe(le,e,a.catch(()=>{})),a}function _(e){Ir(()=>{let t=o.session.pending[e.sessionID]??[],n=t.findIndex(t=>t.id===e.id);s(`session`,`pending`,e.sessionID,n<0?[...t,e]:t.map((t,r)=>r===n?e:t)),e.type!==`compaction`&&pe(e)})}function pe(e){(e.type===`user`||e.type===`synthetic`)&&v.update(e.sessionID,(t,n)=>{let r=e.type===`user`?{id:e.id,type:`user`,...e.payload,time:{created:e.time.created}}:{id:e.id,type:`synthetic`,...e.payload,time:{created:e.time.created}},i=n.get(e.id);if(i===void 0)return v.append(t,n,r);t[i]=r})}function me(e,t){Ir(()=>{h(e,t),d.get(e)?.has(t)&&v.update(e,(e,n)=>{let r=n.get(t);r!==void 0&&(e.splice(r,1),n.delete(t),v.reindex(e,n,r))})})}let v={update(e,t){s(`session`,`message`,Na(n=>{t(n[e]??=[],he(e))}))},append(e,t,n){t.has(n.id)||(t.set(n.id,e.length),e.push(n))},insert(e,t){v.update(e,(e,n)=>v.append(e,n,t))},editAssistant(e,t,n){d.get(e)?.has(t)&&v.update(e,(e,r)=>{let i=r.get(t),a=i===void 0?void 0:e[i];a?.type===`assistant`&&n(a)})},editTool(e,t,n,r){v.editAssistant(e,t,e=>{let t=e.content.findLast(e=>e.type===`tool`&&e.id===n);t&&r(t)})},editText(e,t,n){v.editAssistant(e,t,e=>{let t=e.content.findLast(e=>e.type===`text`);t&&n(t)})},editReasoning(e,t,n){v.editAssistant(e,t,e=>{let t=e.content.findLast(e=>e.type===`reasoning`&&!e.time?.completed);t&&n(t)})},activeAssistant(e){let t=e.findLast(e=>e.type===`assistant`&&!e.time.completed);return t?.type===`assistant`?t:void 0},shell(e,t){let n=e.findLast(e=>e.type===`shell`&&e.shellID===t);return n?.type===`shell`?n:void 0},compaction(e){let t=e.findLast(e=>e.type===`compaction`&&e.status===`running`);return t?.type===`compaction`?t:void 0},reindex(e,t,n){for(let r=n;r<e.length;r++){let n=e[r];n&&t.set(n.id,r)}}};function he(e){let t=d.get(e);if(t)return t;let n=new Map;return d.set(e,n),n}async function ge(e){let n=await t().session.list(e);return n.data.length<NC||!n.cursor.next?n.data:[...n.data,...await ge({cursor:n.cursor.next,limit:NC})]}function _e(e){let t=e,n=o.session.info[e]?.parentID,r=new Set([e]);for(;n&&!r.has(n);)r.add(n),t=n,n=o.session.info[n]?.parentID;return t}function ve(e){if(!o.session.info[e])return;let t=_e(e);s(`session`,`family`,Na(n=>{if(e!==t&&n[e]){let r=n[t]??=[];for(let t of n[e])r.includes(t)||r.push(t);delete n[e]}let r=n[t]??=[];r.includes(e)||r.push(e)}))}function ye(e){if(se.has(e))return;p.invalidate(`session.pending:${e}`),p.invalidate(`session.message:${e}`),ue.delete(e);let t=o.session.pending[e]?.filter(e=>oe.has(e.id))??[],n=o.session.message[e]?.filter(e=>oe.has(e.id))??[];d.delete(e),n.length&&d.set(e,new Map(n.map((e,t)=>[e.id,t]))),s(`session`,Na(r=>{delete r.message[e],delete r.messageCursor[e],delete r.messageLoading[e],delete r.pending[e],n.length&&(r.message[e]=n),t.length&&(r.pending[e]=t)}))}function be(e){ee?.set(e,void 0),o.session.pending[e]?.forEach(e=>oe.delete(e.id)),d.delete(e),p.invalidate(`session:${e}`),p.invalidate(`session.family:${e}`),p.invalidate(`session.pending:${e}`),p.invalidate(`session.message:${e}`),p.invalidate(`session.permission:${e}`),p.invalidate(`session.form:${e}:`),s(`session`,Na(t=>{delete t.info[e],delete t.active[e],delete t.message[e],delete t.messageCursor[e],delete t.messageLoading[e],delete t.pending[e],delete t.permission[e],delete t.form[e];for(let[n,r]of Object.entries(t.family)){let i=r.filter(t=>t!==e);i.length===0?delete t.family[n]:t.family[n]=i}}))}function xe(n){switch(n.type){case`server.connected`:{let e=new Map;ee=e,r(()=>t().session.active().then(t=>{if(ee!==e)return;let n=new Map(Object.keys(t).map(e=>[e,`running`]));e.forEach((e,t)=>{if(e===void 0)return n.delete(t);n.set(t,e)}),ee=void 0,s(`session`,`active`,Aa(Object.fromEntries(n))),n.forEach((e,t)=>{e===`running`&&!o.session.info[t]&&r(()=>b.session.sync(t))})}).catch(()=>{ee===e&&(ee=void 0)})),r(()=>t().location.get({location:DC(c())}).then(e=>{let t=EC(e);s(`location`,t,{info:e})})),r(()=>b.location.vcs.sync()),r(()=>b.project.sync());return}case`project.updated`:s(`project`,`info`,n.data.id,Aa(n.data));return;case`session.created`:se.delete(n.data.sessionID),b.session.invalidate(n.data.sessionID),r(()=>b.session.sync(n.data.sessionID)),p.complete(`session.pending:${n.data.sessionID}`),p.complete(`session.message:${n.data.sessionID}`);return;case`session.deleted`:be(n.data.sessionID);return;case`session.usage.updated`:o.session.info[n.data.sessionID]&&s(`session`,`info`,n.data.sessionID,{cost:n.data.cost,tokens:n.data.tokens});return;case`session.agent.selected`:{let e=o.session.info[n.data.sessionID]?.agent;o.session.info[n.data.sessionID]&&s(`session`,`info`,n.data.sessionID,`agent`,n.data.agent),v.insert(n.data.sessionID,{id:K.fromEvent(n.id),type:`agent-switched`,agent:n.data.agent,previous:e,time:{created:n.created}});return}case`session.model.selected`:{let e=n.data.previous??o.session.info[n.data.sessionID]?.model;if(o.session.info[n.data.sessionID]&&s(`session`,`info`,n.data.sessionID,`model`,n.data.model),!o.session.message[n.data.sessionID])return;v.insert(n.data.sessionID,{id:K.fromEvent(n.id),type:`model-switched`,model:n.data.model,previous:e,time:{created:n.created}}),r(()=>t().session.message.get({sessionID:n.data.sessionID,messageID:K.fromEvent(n.id)}).then(e=>{v.update(n.data.sessionID,(t,n)=>{let r=n.get(e.id);if(r===void 0)return v.append(t,n,e);t[r]=e})}));return}case`session.renamed`:r(()=>{let e=p.pending(`session.family:${n.data.sessionID}`)?b.session.sync(n.data.sessionID,{children:!0}):Promise.resolve();return Promise.all([b.session.sync(n.data.sessionID),e]).then(()=>{o.session.info[n.data.sessionID]&&s(`session`,`info`,n.data.sessionID,`title`,n.data.title)})});return;case`session.permissions`:o.session.info[n.data.sessionID]&&s(`session`,`info`,n.data.sessionID,`permissions`,n.data.permissions);return;case`session.archived`:o.session.info[n.data.sessionID]&&s(`session`,`info`,n.data.sessionID,`time`,`archived`,n.created);return;case`session.unarchived`:o.session.info[n.data.sessionID]&&s(`session`,`info`,n.data.sessionID,`time`,`archived`,void 0);return;case`session.moved`:{let e=o.session.info[n.data.sessionID];if(e){let t={location:{...e.location},projectID:e.projectID,subpath:e.subpath};s(`session`,`info`,n.data.sessionID,`location`,n.data.location),s(`session`,`info`,n.data.sessionID,`projectID`,n.data.projectID),s(`session`,`info`,n.data.sessionID,`subpath`,n.data.subpath),v.insert(n.data.sessionID,{id:K.fromEvent(n.id),type:`location-switched`,location:n.data.location,projectID:n.data.projectID,subpath:n.data.subpath,previous:t,time:{created:n.created}})}return}case`worktree.resolved`:for(let[e,t]of Object.entries(o.session.info)){let i=n.data.adopted?.includes(t.projectID)?o.project.info[t.projectID]?.canonical:t.location.directory;if(!i){b.session.invalidate(e),r(()=>b.session.sync(e));continue}let a=Lg({projectID:t.projectID,directory:i},n.data);a&&(s(`session`,`info`,e,`projectID`,a.projectID),s(`session`,`info`,e,`subpath`,a.subpath))}return;case`session.inbox.delivered`:{let e=b.session.input.has(n.data.sessionID,n.data.inboxID);h(n.data.sessionID,n.data.inboxID),v.update(n.data.sessionID,(t,r)=>{let i=r.get(n.data.inboxID);if(i===void 0)return;let a=t[i];!a||!e||(a.time.created=n.created,t.splice(i,1),t.push(a),v.reindex(t,r,i))}),de.get(n.data.sessionID)?.observed.add(n.data.inboxID);return}case`session.inbox.delivery.changed`:ae(n.data.sessionID,n.data.inboxID,n.data.delivery);return;case`session.inbox.cancelled`:me(n.data.sessionID,n.data.inboxID),de.get(n.data.sessionID)?.observed.add(n.data.inboxID);return;case`session.inbox.enqueued`:{oe.delete(n.data.inboxID);let e={id:n.data.inboxID,sessionID:n.data.sessionID,time:{created:n.created},...n.data.item};if(te.get(e.sessionID)?.set(e.id,e),_(e),n.data.item.type===`compaction`){let e=de.get(n.data.sessionID);e?.observed.add(n.data.inboxID),e&&e.id!==n.data.inboxID&&oe.delete(e.id)&&h(n.data.sessionID,e.id)}return}case`session.instructions.updated`:let i=n.data.text;if(i===void 0)return;v.insert(n.data.sessionID,{id:K.fromEvent(n.id),type:`system`,text:i,description:`Instructions updated: ${Object.keys(n.data.delta).join(`, `)}`,metadata:n.metadata,time:{created:n.created}});return;case`session.synthetic`:v.insert(n.data.sessionID,{id:K.fromEvent(n.id),type:`synthetic`,text:n.data.text,description:n.data.description,metadata:n.data.metadata,time:{created:n.created}});return;case`session.shell.started`:v.insert(n.data.sessionID,{id:K.fromEvent(n.id),type:`shell`,shellID:n.data.shell.id,command:n.data.shell.command,status:n.data.shell.status,exit:n.data.shell.exit,metadata:n.data.shell.metadata.background===!0?{...n.metadata,background:!0}:n.metadata,time:{created:n.created}});return;case`session.shell.ended`:if(!o.session.message[n.data.sessionID])return;v.update(n.data.sessionID,e=>{let t=v.shell(e,n.data.shell.id);t&&(t.status=n.data.shell.status,t.exit=n.data.shell.exit,t.output=n.data.output,t.time.completed=n.created)});return;case`session.step.started`:v.update(n.data.sessionID,(e,t)=>{let r=t.get(n.data.assistantMessageID),i=r===void 0?void 0:e[r];if(i?.type===`assistant`){i.agent=n.data.agent,i.model=n.data.model,i.retry=void 0,i.error=void 0,i.finish=void 0,i.rawFinish=void 0,i.native=void 0,i.time.created=n.data.started,i.time.streamed=void 0,i.time.completed=void 0,n.data.snapshot&&(i.snapshot={...i.snapshot,start:n.data.snapshot});return}let a=v.activeAssistant(e);a&&(a.retry=void 0,a.time.completed=n.created),v.append(e,t,{id:n.data.assistantMessageID,type:`assistant`,agent:n.data.agent,model:n.data.model,metadata:n.metadata,content:[],snapshot:n.data.snapshot?{start:n.data.snapshot}:void 0,time:{created:n.data.started}})});return;case`session.step.streamed`:v.editAssistant(n.data.sessionID,n.data.assistantMessageID,e=>{e.time.streamed=n.created});return;case`session.step.ended`:v.editAssistant(n.data.sessionID,n.data.assistantMessageID,e=>{e.time.completed=n.created,e.finish=n.data.finish,e.rawFinish=n.data.rawFinish,e.native=n.data.native,e.cost=n.data.cost,e.tokens=n.data.tokens,n.data.snapshot&&(e.snapshot={...e.snapshot,end:n.data.snapshot})});return;case`session.step.failed`:n.location&&(n.data.error.type===`provider.budget-limit`||n.data.error.type===`provider.model-budget-limit`)&&y(n.location),v.editAssistant(n.data.sessionID,n.data.assistantMessageID,e=>{e.time.completed=n.created,e.finish=n.data.finish??`error`,e.rawFinish=n.data.rawFinish,e.native=n.data.native,e.error=n.data.error,e.retry=void 0,n.data.cost!==void 0&&n.data.tokens!==void 0&&(e.cost=n.data.cost,e.tokens=n.data.tokens)});return;case`session.text.started`:v.editAssistant(n.data.sessionID,n.data.assistantMessageID,e=>{e.content.push({type:`text`,text:``})});return;case`session.text.delta`:v.editText(n.data.sessionID,n.data.assistantMessageID,e=>{e.text+=n.data.delta});return;case`session.text.ended`:v.editText(n.data.sessionID,n.data.assistantMessageID,e=>{e.text=n.data.text});return;case`session.tool.input.started`:v.editAssistant(n.data.sessionID,n.data.assistantMessageID,e=>{e.content.push({type:`tool`,id:n.data.id,name:n.data.name,time:{created:n.created},state:{status:`streaming`,input:``}})});return;case`session.tool.input.delta`:v.editTool(n.data.sessionID,n.data.assistantMessageID,n.data.id,e=>{e.state.status===`streaming`&&(e.state.input+=n.data.delta)});return;case`session.tool.input.ended`:v.editTool(n.data.sessionID,n.data.assistantMessageID,n.data.id,e=>{e.state.status===`streaming`&&(e.state.input=n.data.text)});return;case`session.tool.called`:v.editTool(n.data.sessionID,n.data.assistantMessageID,n.data.id,e=>{e.time.ran=n.created,e.executed=n.data.executed,e.native=n.data.native,e.state={status:`running`,input:n.data.input,metadata:{}}});return;case`session.tool.progress`:v.editTool(n.data.sessionID,n.data.assistantMessageID,n.data.id,e=>{e.state.status===`running`&&(e.state.metadata=n.data.metadata)});return;case`session.tool.success`:v.editTool(n.data.sessionID,n.data.assistantMessageID,n.data.id,t=>{t.state.status===`running`&&(t.state={status:`completed`,input:t.state.input,metadata:n.data.metadata,content:e.omitToolFileData?kC(n.data.content):[...n.data.content]},t.executed=n.data.executed||t.executed===!0,n.data.native&&(t.native={...t.native,...n.data.native}),t.time.completed=n.created)});return;case`session.tool.failed`:v.editTool(n.data.sessionID,n.data.assistantMessageID,n.data.id,t=>{(t.state.status===`streaming`||t.state.status===`running`)&&(t.state={status:`error`,error:n.data.error,input:typeof t.state.input==`string`?{}:t.state.input,metadata:n.data.metadata,content:e.omitToolFileData&&n.data.content?kC(n.data.content):n.data.content},t.executed=n.data.executed||t.executed===!0,n.data.native&&(t.native={...t.native,...n.data.native}),t.time.completed=n.created)});return;case`session.reasoning.started`:v.editAssistant(n.data.sessionID,n.data.assistantMessageID,e=>{e.content.push({type:`reasoning`,text:``,native:n.data.native,time:{created:n.created}})});return;case`session.reasoning.delta`:v.editReasoning(n.data.sessionID,n.data.assistantMessageID,e=>{e.text+=n.data.delta});return;case`session.reasoning.ended`:v.editReasoning(n.data.sessionID,n.data.assistantMessageID,e=>{e.text=n.data.text,e.time={created:e.time?.created??n.created,completed:n.created},n.data.native!==void 0&&(e.native=n.data.native)});return;case`session.retry.scheduled`:v.editAssistant(n.data.sessionID,n.data.assistantMessageID,e=>{e.retry={attempt:n.data.attempt,at:n.data.at,error:n.data.error}});return;case`session.execution.started`:m(n.data.sessionID,`running`);return;case`session.compaction.started`:n.data.inputID&&h(n.data.sessionID,n.data.inputID),v.insert(n.data.sessionID,{id:n.data.inputID??K.fromEvent(n.id),type:`compaction`,status:`running`,reason:n.data.reason,summary:``,time:{created:n.created}}),n.data.inputID&&de.get(n.data.sessionID)?.observed.add(n.data.inputID);return;case`session.execution.succeeded`:case`session.execution.failed`:case`session.execution.interrupted`:if(m(n.data.sessionID,`idle`),v.update(n.data.sessionID,e=>{let t=v.activeAssistant(e);t&&(t.retry=void 0)}),n.type===`session.execution.interrupted`&&n.data.reason===`shutdown`||(v.insert(n.data.sessionID,{id:K.fromEvent(n.id),type:`idle`,outcome:n.type===`session.execution.succeeded`?`succeeded`:n.type===`session.execution.failed`?`failed`:`interrupted`,...n.type===`session.execution.failed`?{error:n.data.error}:{},time:{created:n.created}}),o.session.message[n.data.sessionID]?.some(e=>e.type===`assistant`&&e.content.some(e=>e.type===`tool`&&(e.state.status===`streaming`||e.state.status===`running`)))&&(p.invalidate(`session.message:${n.data.sessionID}`),r(()=>b.session.message.sync(n.data.sessionID))),!o.session.info[n.data.sessionID]&&!p.has(`session:${n.data.sessionID}`)))return;b.session.invalidate(n.data.sessionID),r(()=>b.session.sync(n.data.sessionID));return;case`session.viewed`:if(!o.session.info[n.data.sessionID]&&!p.has(`session:${n.data.sessionID}`))return;b.session.invalidate(n.data.sessionID),r(()=>b.session.sync(n.data.sessionID));return;case`session.revert.staged`:o.session.info[n.data.sessionID]&&s(`session`,`info`,n.data.sessionID,`revert`,n.data.revert);return;case`session.revert.cleared`:o.session.info[n.data.sessionID]&&s(`session`,`info`,n.data.sessionID,`revert`,void 0);return;case`session.revert.committed`:o.session.info[n.data.sessionID]&&s(`session`,`info`,n.data.sessionID,`revert`,void 0),s(`session`,`pending`,n.data.sessionID,(o.session.pending[n.data.sessionID]??[]).filter(e=>e.id<n.data.to)),v.update(n.data.sessionID,(e,t)=>{let r=e.findIndex(e=>e.id>=n.data.to);if(r!==-1)for(let n of e.splice(r))t.delete(n.id)});return;case`session.compaction.delta`:if(!o.session.message[n.data.sessionID])return;v.update(n.data.sessionID,e=>{let t=v.compaction(e);t?.status===`running`&&(t.summary+=n.data.text)});return;case`session.compaction.ended`:v.update(n.data.sessionID,(e,t)=>{let r=e[e.findLastIndex(e=>e.type===`compaction`&&e.status===`running`)];if(r?.type===`compaction`){Object.assign(r,{status:`completed`,reason:n.data.reason,model:n.data.model,native:n.data.native,summary:n.data.text,cost:n.data.cost,tokens:n.data.tokens});return}v.append(e,t,{id:K.fromEvent(n.id),type:`compaction`,status:`completed`,reason:n.data.reason,model:n.data.model,native:n.data.native,summary:n.data.text,cost:n.data.cost,tokens:n.data.tokens,time:{created:n.created}})});return;case`session.compaction.failed`:n.data.inputID&&h(n.data.sessionID,n.data.inputID),v.update(n.data.sessionID,(e,t)=>{let r=e.findLastIndex(e=>e.type===`compaction`&&e.status===`running`),i=e[r],a={id:i?.id??n.data.inputID??K.fromEvent(n.id),type:`compaction`,status:`failed`,reason:n.data.reason,error:n.data.error,metadata:i?.type===`compaction`?i.metadata:n.metadata,cost:n.data.cost,tokens:n.data.tokens,time:i?.type===`compaction`?i.time:{created:n.created}};if(i?.type===`compaction`){e[r]=a;return}v.append(e,t,a)}),n.data.inputID&&de.get(n.data.sessionID)?.observed.add(n.data.inputID);return;case`permission.asked`:if(o.session.permission[n.data.sessionID]?.some(e=>e.id===n.data.id))return;s(`session`,`permission`,n.data.sessionID,[...o.session.permission[n.data.sessionID]??[],n.data]);return;case`permission.replied`:ne(n.data.sessionID,n.data.requestID);return;case`form.replied`:case`form.cancelled`:re(n.data.sessionID,n.data.id,n.location);return}if(n.type===`credential.updated`||n.type===`credential.switched`){Object.keys(o.location).forEach(e=>{let t=JSON.parse(e),i={directory:t[0],workspaceID:t[1]??void 0};if(y(i),n.type===`credential.updated`){Ce(`integration`,b.location.integration,i);return}o.location[e]?.integration&&s(`location`,e,e=>({integration:e?.integration?.map(e=>{if(e.id!==n.data.integrationID)return e;let t=e.connections.find(e=>e.type===`credential`&&e.id===n.data.credentialID);return t?{...e,connections:[t,...e.connections.filter(e=>e!==t)]}:e})}));let a=Se(`integration`,i)||Se(`model`,i)||Se(`provider`,i);b.location.model.invalidate(i),b.location.provider.invalidate(i),a&&r(()=>Promise.all([b.location.model.sync(i),b.location.provider.sync(i)]))});return}if(!n.location)return;let i=n.location;switch(n.type){case`provider.updated`:Ce(`provider`,b.location.provider,i);break;case`model.updated`:Ce(`model`,b.location.model,i);break;case`agent.updated`:Ce(`agent`,b.location.agent,i);break;case`command.updated`:Ce(`command`,b.location.command,i);break;case`skill.updated`:Ce(`skill`,b.location.skill,i);break;case`vcs.branch.updated`:Ce(`vcs`,b.location.vcs,i);break;case`form.created`:if(o.session.form[n.data.form.sessionID]?.some(e=>e.id===n.data.form.id))break;s(`session`,`form`,n.data.form.sessionID,[...o.session.form[n.data.form.sessionID]??[],n.data.form.sessionID===`global`?{...n.data.form,location:i}:n.data.form]);break;case`shell.created`:s(`location`,EC(i),e=>({shell:{...e?.shell,[n.data.info.id]:{...n.data.info,location:i}}}));break;case`shell.exited`:case`shell.deleted`:if(!o.location[EC(i)]?.shell?.[n.data.id])break;s(`location`,EC(i),e=>({shell:Object.fromEntries(Object.entries(e?.shell??{}).filter(([e])=>e!==n.data.id))}));break;case`reference.updated`:Ce(`reference`,b.location.reference,i);break;case`integration.updated`:{y(i);let e=Se(`integration`,i)||Se(`model`,i)||Se(`provider`,i);b.location.integration.invalidate(i),b.location.model.invalidate(i),b.location.provider.invalidate(i),e&&r(()=>Promise.all([b.location.integration.sync(i),b.location.model.sync(i),b.location.provider.sync(i)]));break}case`config.updated`:Ce(`config`,b.location.config,i),Se(`websearch`,i)&&r(()=>b.location.websearch.refresh(i));break;case`websearch.updated`:Se(`websearch`,i)&&r(()=>b.location.websearch.refresh(i));break;case`mcp.status.changed`:{let e=Se(`mcpServer`,i);b.location.mcp.server.invalidate(i),e&&a(`mcp.status:${EC(i)}`,()=>b.location.mcp.server.sync(i));break}case`mcp.resources.changed`:Ce(`mcpResource`,b.location.mcp.resource,i)}}function Se(e,t){let n=EC(t??c());return o.location[n]?.[e]!==void 0||p.has(`location.${e}:${n}`)}function Ce(e,t,n){let i=Se(e,n);t.invalidate(n),i&&r(()=>t.sync(n))}function y(e){let t=o.location[EC(e)]?.usageLimits!==void 0||p.has(`location.usageLimits:${EC(e)}`);Ee.invalidate(e),t&&r(()=>Ee.sync(e))}function we(e,t,n){let r=(t,n)=>s(`location`,t,{[e]:n});return{list:t=>o.location[EC(t??c())]?.[e],sync:i=>{let a=i??c(),o=EC(a);return p.run(`location.${e}:${o}`,async()=>{let e=await t(DC(a)),i=EC(e.location);r(i,e.data),n?.alias&&i!==o&&r(o,e.data)})},invalidate:t=>p.invalidate(`location.${e}:${EC(t??c())}`)}}let Te=we(`vcs`,e=>t().vcs.get({location:e})),Ee=we(`usageLimits`,e=>t().usage.limits({location:e})),De=we(`shell`,async e=>{let n=await t().shell.list({location:e}),r={directory:n.location.directory};return{location:n.location,data:Object.fromEntries(n.data.map(e=>[e.id,{...e,location:r}]))}}),b={on:e.event.on,listen:e.event.listen,session:{list(){return u()},get(e){return o.session.info[e]},creating(e){return ce.has(e)},remember(e){Ir(()=>{s(`session`,`info`,e.id,Aa(e)),p.complete(`session:${e.id}`),ve(e.id)})},setStatus(e,t){m(e,t)},root(e){return _e(e)},family(e){return o.session.family[_e(e)]??[]},evict(e){let t=_e(e);Ir(()=>{for(let n of new Set([t,e,...o.session.family[t]??[]]))ye(n)})},cost(e){let t=o.session.info[e];return t?t.parentID?t.cost:(o.session.family[e]??[e]).reduce((e,t)=>e+(o.session.info[t]?.cost??0),0):0},status(e){return o.session.active[e]??`idle`},active(){return Object.entries(o.session.active).flatMap(([e,t])=>t===`running`?[e]:[])},input:{list(e){return(o.session.pending[e]??[]).flatMap(e=>e.type===`compaction`?[]:[e.id])},has(e,t){return o.session.pending[e]?.some(e=>e.id===t&&e.type!==`compaction`)??!1}},pending:{list(e){return o.session.pending[e]??[]},status(e,t){let n=o.session.pending[e]??[],r=n.find(e=>e.id===t&&e.type===`user`);if(!r)return;if(r.delivery===`queue`)return`queued`;let i=o.session.message[e]??[],a=i.findLastIndex(e=>e.type===`idle`);return(o.session.active[e]??`idle`)===`idle`?a>=0&&r.time.created<=i[a].time.created?`stranded`:`starting`:i.slice(a+1).some(e=>e.type===`user`&&!n.some(t=>t.id===e.id))?`steering`:`starting`},sync(e){return p.run(`session.pending:${e}`,async()=>{let n=new Map;te.set(e,n);try{let r=await t().session.inbox.list({sessionID:e}),i=new Map(r.map(e=>[e.id,e]));n.forEach((e,t)=>{if(e===void 0)i.delete(t);else if(typeof e==`string`){let n=i.get(t);n&&i.set(t,{...n,delivery:e})}else i.set(t,e)});let a=[...i.values()];a.forEach(e=>oe.delete(e.id)),a.some(e=>e.type===`compaction`)&&o.session.pending[e]?.filter(e=>e.type===`compaction`).forEach(e=>oe.delete(e.id));let c=(o.session.pending[e]??[]).filter(e=>oe.has(e.id)),l=c.length===0?a:[...a,...c];Ir(()=>{s(`session`,`pending`,e,Aa(l)),l.forEach(pe)})}finally{te.get(e)===n&&te.delete(e)}})},invalidate(e){p.invalidate(`session.pending:${e}`)}},create(e){let{projectID:n,...r}=e,i=r.id??Kl.create(),a=r.location??c(),s=!o.session.info[i];if(s){let e=Date.now();se.add(i),b.session.remember({id:i,projectID:n??o.location[EC(a)]?.info?.project.id??``,agent:r.agent,model:r.model,cost:0,tokens:{input:0,output:0,reasoning:0,cache:{read:0,write:0}},time:{created:e,updated:e},title:r.title,location:a}),p.complete(`session.family:${i}`),p.complete(`session.pending:${i}`),p.complete(`session.message:${i}`)}let l=Promise.resolve().then(()=>t().session.create({...r,id:i,location:a})).then(e=>(se.delete(i),b.session.remember(e),e)).catch(e=>{throw s&&se.delete(i)&&be(i),e});return s&&fe(ce,i,l),{id:i,request:l}},compact(e){let n=de.get(e.sessionID);if(n)return n.request;let r=K.create();o.session.pending[e.sessionID]?.some(e=>e.type===`compaction`)||(oe.add(r),_({id:r,sessionID:e.sessionID,time:{created:Date.now()},type:`compaction`,delivery:`steer`,payload:{}}));let i=new Set,a=g(e.sessionID,async()=>(e.model&&await t().session.switchModel({sessionID:e.sessionID,model:e.model}),t().session.compact({sessionID:e.sessionID,id:r}))).then(t=>(Ir(()=>{oe.delete(r),t.id!==r&&h(e.sessionID,r),!i.has(t.id)&&!d.get(e.sessionID)?.has(t.id)&&_(t)}),t)).catch(t=>{throw oe.delete(r)&&h(e.sessionID,r),t}).finally(()=>{de.get(e.sessionID)?.request===a&&de.delete(e.sessionID)});return de.set(e.sessionID,{id:r,observed:i,request:a}),a},prompt(e){let{gate:n,prepare:r,...i}=e,a=i.id??K.create(),s=!d.get(i.sessionID)?.has(a)&&!o.session.pending[i.sessionID]?.some(e=>e.id===a);if(s){let e=OC(i.files),t={text:i.text,agents:i.agents?.map(e=>({...e})),metadata:i.metadata};e&&(t.files=e),oe.add(a),_({id:a,sessionID:i.sessionID,time:{created:Date.now()},type:`user`,delivery:i.delivery??`steer`,payload:t})}return g(i.sessionID,async()=>(await r?.(),t().session.prompt({...i,id:a})),n).catch(e=>{throw s&&oe.delete(a)&&me(i.sessionID,a),e})},sync(e,n){return p.run(n?.children?`session.family:${e}`:`session:${e}`,async()=>{let[r,i]=await Promise.all([t().session.get({sessionID:e}),n?.children?ge({parentID:e,order:`desc`,limit:NC}):[]]),a=[r,...i];Ir(()=>{s(`session`,`info`,Na(e=>{for(let t of a)e[t.id]=t}));for(let e of a)p.complete(`session:${e.id}`),ve(e.id)})})},invalidate(e){p.invalidate(`session:${e}`)},message:{list(e){return o.session.message[e]??[]},get(e,t){let n=o.session.message[e],r=d.get(e)?.get(t);return r===void 0?void 0:n?.[r]},sync(n){return p.run(`session.message:${n}`,async()=>{let r=await t().message.list({sessionID:n,limit:e.initialMessageLimit?.()??TC,order:`desc`}),i=r.data.toReversed().map(f),a=new Set(i.map(e=>e.id)),c=new Set((o.session.pending[n]??[]).flatMap(e=>e.type===`user`||e.type===`synthetic`?[e.id]:[])),l=(o.session.message[n]??[]).filter(e=>!a.has(e.id)&&(oe.has(e.id)||c.has(e.id))),u=l.length===0?i:[...i,...l];Ir(()=>{d.set(n,new Map(u.map((e,t)=>[e.id,t]))),s(`session`,`message`,n,Aa(u)),s(`session`,`messageCursor`,n,r.cursor.next??void 0)})})},more(e){return o.session.messageCursor[e]!==void 0},loading(e){return o.session.messageLoading[e]??!1},async loadMore(e,n){let r=n?.signal;if(r?.aborted)return;for(;ue.has(e);){let t=await(()=>{let t=ue.get(e);if(!r)return t;let n=Promise.withResolvers(),i=()=>n.resolve();return r.addEventListener(`abort`,i,{once:!0}),Promise.race([t,n.promise]).catch(e=>{if(!r.aborted)throw e}).finally(()=>r.removeEventListener(`abort`,i))})();if(!n?.all&&t||r?.aborted)return}let i=o.session.messageCursor[e];if(!i||r?.aborted)return;s(`session`,`messageLoading`,e,!0);let a=(async()=>{let a=[],c=i;do{let i=await t().message.list({sessionID:e,limit:n?.all?200:TC,cursor:c},{signal:r});if(r?.aborted)return;if(a.push(...i.data.map(f)),c=i.cursor.next??void 0,!n?.all)break}while(c);let l=o.session.message[e]??[],u=new Set(l.map(e=>e.id)),p=[...a.reverse().filter(e=>!u.has(e.id)),...l];return Ir(()=>{n?.beforePublish?.(),d.set(e,new Map(p.map((e,t)=>[e.id,t]))),s(`session`,`message`,e,Aa(p)),s(`session`,`messageCursor`,e,c)}),!0})().catch(e=>{if(!r?.aborted)throw e}).finally(()=>s(`session`,`messageLoading`,e,!1));fe(ue,e,a),await a},invalidate(e){p.invalidate(`session.message:${e}`)}},permission:{list(e){return o.session.permission[e]},sessions(){return Object.entries(o.session.permission).flatMap(([e,t])=>t.length>0?[e]:[])},sync(e){return p.run(`session.permission:${e}`,async()=>{s(`session`,`permission`,e,await t().permission.list({sessionID:e}))})},invalidate(e){p.invalidate(`session.permission:${e}`)},async reply(e){await t().permission.reply(e).catch(e=>{if(!En(e))throw e}),ne(e.sessionID,e.requestID)}},form:{list(e,t){let n=o.session.form[e];if(e!==`global`)return n;if(!t)return;let r=EC(t);return n?.filter(e=>e.location&&EC(e.location)===r)},sessions(){return Object.entries(o.session.form).flatMap(([e,t])=>e!==`global`&&t.length>0?[e]:[])},sync(e,n){let r=`session.form:${e}:${e===`global`?EC(n??c()):``}`;return p.run(r,async()=>{if(e===`global`){let r=await t().form.list({location:DC(n??c())}),i={directory:r.location.directory},a=EC(i);s(`session`,`form`,e,[...(o.session.form[e]??[]).filter(e=>e.location&&EC(e.location)!==a),...r.data.filter(e=>e.sessionID===`global`).map(e=>({...e,location:i}))]);return}s(`session`,`form`,e,await t().session.form.list({sessionID:e}))})},invalidate(e,t){p.invalidate(`session.form:${e}:${e===`global`?EC(t??c()):``}`)},reply(e,n){return ie(e,n,t().session.form.reply(e,jC(e.sessionID,n)))},cancel(e,n){return ie(e,n,t().session.form.cancel(e,jC(e.sessionID,n)))}}},project:{list(){return Object.values(o.project.info).filter(e=>e.time.archived===void 0).toSorted((e,t)=>t.time.active-e.time.active)},get(e){return o.project.info[e]},sync(){return p.run(`project`,async()=>{let e=await t().project.list();s(`project`,`info`,Aa(Object.fromEntries(e.map(e=>[e.id,e]))))})},invalidate(){p.invalidate(`project`)},permission:{list(e){return o.project.permission[e]},sync(e){return p.run(`project.permission:${e}`,async()=>{s(`project`,`permission`,e,await t().permission.saved.list({projectID:e}))})},invalidate(e){p.invalidate(`project.permission:${e}`)}}},shell:{list(e){return Object.values(De.list(e)??{})},listBySession(e){return Object.values(o.location).flatMap(e=>Object.values(e.shell??{})).filter(t=>t.metadata.sessionID===e)},get(e){return Object.values(o.location).map(t=>t.shell?.[e]).find(e=>e!==void 0)},sync:De.sync,invalidate:De.invalidate},location:{info(e){return o.location[EC(e??c())]?.info},default(){return c()},syncInfo(e){let n=e??c();return p.run(`location:${EC(n)}`,async()=>{let r=await t().location.get({location:DC(n)}),i=EC(r);o.location[i]||s(`location`,i,{}),s(`location`,i,`info`,r),e||l({directory:r.directory})})},async sync(e){await b.location.syncInfo(e);let t=e??c();await Promise.all([b.location.vcs.sync(t),b.location.agent.sync(t),b.location.command.sync(t),b.location.integration.sync(t),b.location.mcp.server.sync(t),b.location.mcp.resource.sync(t),b.location.model.sync(t),b.location.provider.sync(t),b.location.reference.sync(t),b.location.skill.sync(t),b.shell.sync(t),b.session.form.sync(`global`,t)])},invalidate(e){let t=e??c();p.invalidate(`location:${EC(t)}`),b.location.vcs.invalidate(t),b.location.agent.invalidate(t),b.location.command.invalidate(t),b.location.config.invalidate(t),b.location.integration.invalidate(t),b.location.mcp.server.invalidate(t),b.location.mcp.resource.invalidate(t),b.location.model.invalidate(t),b.location.provider.invalidate(t),b.location.reference.invalidate(t),b.location.skill.invalidate(t),b.shell.invalidate(t),b.session.form.invalidate(`global`,t)},vcs:{info:Te.list,sync:Te.sync,invalidate:Te.invalidate},usage:{limits:Ee.list,sync:Ee.sync,invalidate:Ee.invalidate},agent:we(`agent`,e=>t().agent.list({location:e})),command:we(`command`,e=>t().command.list({location:e})),config:we(`config`,async e=>({location:{directory:e.directory},data:await t().config.get({location:e})})),integration:we(`integration`,e=>t().integration.list({location:e})),mcp:{server:we(`mcpServer`,e=>t().mcp.list({location:e})),resource:we(`mcpResource`,async e=>{let n=await t().mcp.resource.catalog({location:e});return{location:n.location,data:n.data.resources}})},model:we(`model`,e=>t().model.list({location:e}),{alias:!0}),provider:we(`provider`,e=>t().provider.list({location:e}),{alias:!0}),reference:we(`reference`,e=>t().reference.list({location:e})),websearch:{list(e){return o.location[EC(e??c())]?.websearch},async refresh(e){let n={location:DC(e??c())},r=await t().websearch.providers(n),i=EC(r.location);s(`location`,i,{websearch:r.data})}},skill:we(`skill`,e=>t().skill.list({location:e}))}};return kr(()=>{e.connection?.status()!==`connected`&&p.invalidate()}),Br(e.event.listen(({details:e})=>{xe(e)})),b}var FC=2e3,IC=1e3,LC=50,RC=45e3,zC=2e4;function BC(e,t){let n=new AbortController,r=[],i=t.idleTimeout??45e3,[a,o]=xa({status:`connecting`,attempt:0}),s=e,c=[],l,u,d,f,p=!1,ee=0,te=0,m=!1;function h(e,t,n){r.push({type:`client.connection`,created:Date.now(),data:{status:e,attempt:t,error:n}}),r.length>LC&&r.shift()}function ne(e){c.push(e),!l&&(l=setTimeout(()=>{l=void 0;let e=c;c=[],Ir(()=>e.forEach(t.onEvent))},t.flushInterval??10))}async function re(e,n){let r,a=new AbortController;d=a;let c=()=>a.abort(e.reason),l=setTimeout(()=>a.abort(Error(`Timed out connecting to server`)),FC);e.addEventListener(`abort`,c,{once:!0});let u,f=()=>{te=Date.now(),r!==void 0&&(clearTimeout(u),u=setTimeout(()=>a.abort(Error(`Event stream stalled`)),i))};try{h(n===0?`connecting`:`reconnecting`,n),t.log?.info?.(`event stream connecting`,{attempt:n});let i=s.event.subscribe({signal:a.signal,onActivity:f})[Symbol.asyncIterator](),c=await i.next();if(e.aborted)return{error:void 0,connectedAt:r};if(c.done)return{error:a.signal.reason instanceof Error?a.signal.reason:Error(`Event stream disconnected`),connectedAt:r};if(c.value.type!==`server.connected`)return{error:Error(`Event stream did not start with server.connected`),connectedAt:r};for(clearTimeout(l),h(`connected`,n),r=Date.now(),f(),t.log?.info?.(`event stream connected`),ne(c.value),o({status:`connected`,attempt:0,error:void 0});!e.aborted;){let n=await i.next();if(e.aborted)return{error:void 0,connectedAt:r};if(n.done)return{error:a.signal.reason instanceof Error?a.signal.reason:Error(`Event stream disconnected`),connectedAt:r};f(),`durable`in n.value&&n.value.durable&&t.log?.debug?.(`event`,{type:n.value.type,aggregateID:n.value.durable.aggregateID,seq:n.value.durable.seq}),ne(n.value)}return{error:void 0,connectedAt:r}}catch(e){return{error:e,connectedAt:r}}finally{a.abort(),d===a&&(d=void 0),clearTimeout(l),clearTimeout(u),e.removeEventListener(`abort`,c)}}async function ie(e){let r=0;for(;!n.signal.aborted&&p&&ee===e;){o({status:r===0?`connecting`:`reconnecting`,attempt:r});let i=new AbortController;u=i;let a=()=>i.abort(n.signal.reason);n.signal.addEventListener(`abort`,a);let c=await re(i.signal,r);if(n.signal.removeEventListener(`abort`,a),n.signal.aborted||!p||ee!==e)return;c.connectedAt!==void 0&&Date.now()-c.connectedAt>=IC&&(r=0),r+=1;let l=VC(c.error);if(h(`disconnected`,r,l),t.log?.info?.(`event stream disconnected`,{attempt:r,error:l}),o({status:`reconnecting`,attempt:r,error:l}),t.reconnect){let a=await t.reconnect(i.signal).catch(e=>{i.signal.aborted||t.log?.info?.(`server resolution failed`,{attempt:r,error:VC(e)})});if(n.signal.aborted||i.signal.aborted||!p||ee!==e)return;if(a&&(s=a,r===1))continue}if(m){m=!1;continue}await HC(IC,i.signal)}}function ae(){if(p)return f;p=!0,m=!1;let e=++ee,t=f,n=(async()=>{t&&await t,await ie(e)})().finally(()=>{f===n&&(f=void 0)});return f=n,f}function oe(){p&&(p=!1,ee+=1,u?.abort(),o({status:`connecting`,attempt:0,error:void 0}))}function se(e){!p||a.status!==`connected`||(t.log?.info?.(`event stream resync`,{reason:e,idle:Date.now()-te}),m=!0,d?.abort(Error(e)))}if(t.pageLifecycle){let e=()=>oe(),t=()=>void ae(),n=()=>{document.visibilityState===`visible`&&(Date.now()-te<2e4||se(`Page returned to the foreground after the event stream went quiet`))},r=()=>se(`Network connection restored`);window.addEventListener(`pagehide`,e),window.addEventListener(`pageshow`,t),window.addEventListener(`online`,r),document.addEventListener(`visibilitychange`,n),Br(()=>{window.removeEventListener(`pagehide`,e),window.removeEventListener(`pageshow`,t),window.removeEventListener(`online`,r),document.removeEventListener(`visibilitychange`,n)})}return ae(),Br(()=>{oe(),n.abort(),l&&clearTimeout(l),c=[]}),{status:()=>a.status,attempt:()=>a.attempt,error:()=>a.error,internal:{history:()=>r.slice(),resync:se}}}function VC(e){if(e!==void 0)return e instanceof Error?e.message:String(e)}function HC(e,t){return new Promise(n=>{let r=setTimeout(i,e);t.addEventListener(`abort`,i,{once:!0});function i(){clearTimeout(r),t.removeEventListener(`abort`,i),n()}})}function UC(e,t){return{async connect(n){let r=await e.pty.connect.token({ptyID:n.ptyID,location:n.location,"x-opencode-ticket":`1`}),i=new URL(t.url);i.pathname.endsWith(`/`)||(i.pathname+=`/`);let a=new URL(`api/pty/${encodeURIComponent(n.ptyID)}/connect`,i);n.location?.directory&&a.searchParams.set(`location[directory]`,n.location.directory),n.cursor!==void 0&&a.searchParams.set(`cursor`,String(n.cursor)),a.searchParams.set(`ticket`,r.data.ticket),a.protocol=a.protocol===`https:`?`wss:`:`ws:`;let o=t.openSocket?.(a)??new WebSocket(a);return o.binaryType=`arraybuffer`,o}}}function WC(e,t){return{async connect(n){let r=await e.experimental.persistentPty.connectToken({ptyID:n.ptyID,"x-opencode-ticket":`1`}),i=new URL(t.url);i.pathname.endsWith(`/`)||(i.pathname+=`/`);let a=new URL(`api/experimental/persistent-pty/${encodeURIComponent(n.ptyID)}/connect`,i);a.searchParams.set(`ticket`,r.ticket),a.searchParams.set(`cursor`,String(n.cursor)),a.searchParams.set(`attachment_id`,n.attachmentID),a.searchParams.set(`takeover`,String(n.takeover??!1)),a.searchParams.set(`input_protocol`,`1`),a.protocol=a.protocol===`https:`?`wss:`:`ws:`;let o=t.openSocket?.(a)??new WebSocket(a);return o.binaryType=`arraybuffer`,o}}}function GC(e){let t,n=[],r=new Map;kr(()=>{let i=e.current(),a=i===void 0?void 0:e.session.root(i),o=new Set(e.keep().map(t=>e.session.root(t)));n=[...new Set([...i!==t&&a!==void 0?[a]:[],...n.map(t=>e.session.root(t))])],t=i;let s=new Set([...o,...n.filter(e=>!o.has(e)).slice(0,e.limit)]);a!==void 0&&s.add(a),n=n.filter(e=>s.has(e));let c=t=>Lr(()=>e.session.message?.list(t).length??0),l=new Map(e.session.list().flatMap(t=>{let n=e.session.root(t.id);return s.has(n)?[]:[[t.id,n]]})),u=new Set([...l].filter(([e,t])=>r.get(e)!==`${t}:${c(e)}`).map(([,e])=>e));Lr(()=>u.forEach(t=>e.session.evict(t))),r=new Map([...l].map(([e,t])=>[e,`${t}:${c(e)}`]))})}function KC(e,t){let n=t?e.findIndex(e=>e.id===t):-1;if(t&&n===-1)return;let r=n===-1?e.length:n,i=e.findLastIndex((e,t)=>e.type===`compaction`&&e.status===`completed`&&t<r);return e.findLast((e,t)=>e.type===`assistant`&&e.tokens!==void 0&&t>i&&t<r)}var qC=e({createClientConnection:()=>BC,createData:()=>PC,createPersistentPtyClient:()=>WC,createPtyClient:()=>UC,createSessionRetention:()=>GC,defaultIdleTimeout:()=>RC,foregroundIdleThreshold:()=>zC,lastAssistantWithUsage:()=>KC,locationKey:()=>EC,settleMs:()=>150});export{Wr as A,Er as C,Ri as D,Ur as E,Qr as F,Rn as I,In as L,zn as M,zi as N,Rr as O,Lr as P,En as R,Tr as S,Hr as T,Ni as _,na as a,jr as b,Wi as c,Ki as d,ta as f,Vr as g,Ir as h,Aa as i,F as j,Br as k,Gi as l,qi as m,wC as n,la as o,ea as p,xa as r,Zi as s,qC as t,Ji as u,Zr as v,Mi as w,Or as x,kr as y,Vt as z};
|
|
12
|
+
`)}if(e.done)return}}finally{try{await a.cancel()}catch{}a.releaseLock()}}});return{server:{info:e=>a({method:`GET`,path:`/api/info`,successStatus:200,declaredStatuses:[400,401],empty:!1},e),pair:e=>a({method:`POST`,path:`/api/pair`,successStatus:200,declaredStatuses:[400,401],empty:!1},e),connect:(e,t)=>a({method:`GET`,path:`/auth/connect/${encodeURIComponent(e.code)}`,successStatus:200,declaredStatuses:[400,401],empty:!1},t)},location:{get:(e,t)=>a({method:`GET`,path:`/api/location`,query:{location:e?.location},successStatus:200,declaredStatuses:[400,401,404],empty:!1},t),reload:e=>a({method:`POST`,path:`/api/location/reload`,successStatus:204,declaredStatuses:[400,401,503],empty:!0},e)},agent:{list:(e,t)=>a({method:`GET`,path:`/api/agent`,query:{location:e?.location},successStatus:200,declaredStatuses:[400,401,404,503],empty:!1},t),get:(e,t)=>a({method:`GET`,path:`/api/agent/${encodeURIComponent(e.agentID)}`,query:{location:e.location},successStatus:200,declaredStatuses:[400,401,404],empty:!1},t)},plugin:{list:(e,t)=>a({method:`GET`,path:`/api/plugin`,query:{location:e?.location},successStatus:200,declaredStatuses:[400,401,404],empty:!1},t),gui:(e,t)=>a({method:`GET`,path:`/api/plugin/gui`,query:{location:e.location,id:e.id},successStatus:200,declaredStatuses:[400,401,404],empty:!1},t),check:(e,t)=>a({method:`POST`,path:`/api/plugin/check`,query:{location:e?.location},body:{target:e?.target},successStatus:200,declaredStatuses:[400,401,404],empty:!1},t),update:(e,t)=>a({method:`POST`,path:`/api/plugin/update`,query:{location:e.location},body:{targets:e.targets},successStatus:204,declaredStatuses:[400,401,404,503],empty:!0},t)},session:{list:(e,t)=>a({method:`GET`,path:`/api/session`,query:{limit:e?.limit,order:e?.order,search:e?.search,parentID:e?.parentID,archived:e?.archived,directory:e?.directory,project:e?.project,subpath:e?.subpath,cursor:e?.cursor},successStatus:200,declaredStatuses:[400,401],empty:!1},t),stats:(e,t)=>a({method:`GET`,path:`/api/experimental/session/stats`,query:{from:e?.from,to:e?.to,project:e?.project,timezone:e?.timezone,tools:e?.tools},successStatus:200,declaredStatuses:[400,401],empty:!1},t).then(e=>e.data),create:(e,t)=>a({method:`POST`,path:`/api/session`,body:{id:e?.id,parentID:e?.parentID,title:e?.title,agent:e?.agent,model:e?.model,location:e?.location,metadata:e?.metadata,permissions:e?.permissions},successStatus:200,declaredStatuses:[400,401,404],empty:!1},t).then(e=>e.data),import:(e,t)=>a({method:`POST`,path:`/api/experimental/session/import`,body:{info:e.info,messages:e.messages,location:e.location},successStatus:200,declaredStatuses:[400,401,404,409],empty:!1},t).then(e=>e.data),export:(e,t)=>a({method:`GET`,path:`/api/experimental/session/${encodeURIComponent(e.sessionID)}/export`,query:{sanitize:e.sanitize},successStatus:200,declaredStatuses:[400,401,404,500],empty:!1},t).then(e=>e.data),active:e=>a({method:`GET`,path:`/api/session/active`,successStatus:200,declaredStatuses:[400,401],empty:!1},e).then(e=>e.data),get:(e,t)=>a({method:`GET`,path:`/api/session/${encodeURIComponent(e.sessionID)}`,successStatus:200,declaredStatuses:[400,401,404],empty:!1},t).then(e=>e.data),remove:(e,t)=>a({method:`DELETE`,path:`/api/session/${encodeURIComponent(e.sessionID)}`,successStatus:204,declaredStatuses:[400,401,404],empty:!0},t),fork:(e,t)=>a({method:`POST`,path:`/api/session/${encodeURIComponent(e.sessionID)}/fork`,body:{before:e.before},successStatus:200,declaredStatuses:[400,401,404],empty:!1},t).then(e=>e.data),switchAgent:(e,t)=>a({method:`POST`,path:`/api/session/${encodeURIComponent(e.sessionID)}/agent`,body:{agent:e.agent},successStatus:204,declaredStatuses:[400,401,404],empty:!0},t),switchModel:(e,t)=>a({method:`POST`,path:`/api/session/${encodeURIComponent(e.sessionID)}/model`,body:{model:e.model},successStatus:204,declaredStatuses:[400,401,404],empty:!0},t),update:(e,t)=>a({method:`PATCH`,path:`/api/session/${encodeURIComponent(e.sessionID)}`,body:{title:e.title,metadata:e.metadata,permissions:e.permissions,archived:e.archived},successStatus:204,declaredStatuses:[400,401,404],empty:!0},t),move:(e,t)=>a({method:`POST`,path:`/api/session/${encodeURIComponent(e.sessionID)}/move`,body:{directory:e.directory,delivery:e.delivery},successStatus:204,declaredStatuses:[400,401,404],empty:!0},t),prompt:(e,t)=>a({method:`POST`,path:`/api/session/${encodeURIComponent(e.sessionID)}/prompt`,body:{id:e.id,text:e.text,files:e.files,agents:e.agents,skills:e.skills,metadata:e.metadata,delivery:e.delivery,resume:e.resume},successStatus:200,declaredStatuses:[400,401,404,409],empty:!1},t).then(e=>e.data),command:(e,t)=>a({method:`POST`,path:`/api/session/${encodeURIComponent(e.sessionID)}/command`,body:{name:e.name,text:e.text,files:e.files,agents:e.agents,skills:e.skills,delivery:e.delivery},successStatus:204,declaredStatuses:[400,401,404,500],empty:!0},t),skill:(e,t)=>a({method:`POST`,path:`/api/experimental/session/${encodeURIComponent(e.sessionID)}/skill`,body:{id:e.id,resume:e.resume},successStatus:204,declaredStatuses:[400,401,404],empty:!0},t),synthetic:(e,t)=>a({method:`POST`,path:`/api/session/${encodeURIComponent(e.sessionID)}/synthetic`,body:{id:e.id,text:e.text,description:e.description,metadata:e.metadata,delivery:e.delivery,resume:e.resume},successStatus:200,declaredStatuses:[400,401,404,409],empty:!1},t).then(e=>e.data),shell:(e,t)=>a({method:`POST`,path:`/api/session/${encodeURIComponent(e.sessionID)}/shell`,body:{id:e.id,command:e.command},successStatus:204,declaredStatuses:[400,401,404],empty:!0},t),compact:(e,t)=>a({method:`POST`,path:`/api/session/${encodeURIComponent(e.sessionID)}/compact`,body:{id:e.id,delivery:e.delivery},successStatus:200,declaredStatuses:[400,401,404,409],empty:!1},t).then(e=>e.data),wait:(e,t)=>a({method:`POST`,path:`/api/experimental/session/${encodeURIComponent(e.sessionID)}/wait`,successStatus:204,declaredStatuses:[400,401,404,503],empty:!0},t),revert:{stage:(e,t)=>a({method:`POST`,path:`/api/session/${encodeURIComponent(e.sessionID)}/revert/stage`,body:{messageID:e.messageID,files:e.files},successStatus:200,declaredStatuses:[400,401,404,409,500],empty:!1},t).then(e=>e.data),clear:(e,t)=>a({method:`DELETE`,path:`/api/session/${encodeURIComponent(e.sessionID)}/revert`,successStatus:204,declaredStatuses:[400,401,404,409,500],empty:!0},t),commit:(e,t)=>a({method:`POST`,path:`/api/session/${encodeURIComponent(e.sessionID)}/revert/commit`,successStatus:204,declaredStatuses:[400,401,404,409],empty:!0},t)},context:(e,t)=>a({method:`GET`,path:`/api/session/${encodeURIComponent(e.sessionID)}/context`,successStatus:200,declaredStatuses:[400,401,404,500],empty:!1},t).then(e=>e.data),diff:(e,t)=>a({method:`GET`,path:`/api/session/${encodeURIComponent(e.sessionID)}/diff`,query:{from:e.from,to:e.to,context:e.context},successStatus:200,declaredStatuses:[400,401,404,500],empty:!1},t).then(e=>e.data),inbox:{list:(e,t)=>a({method:`GET`,path:`/api/session/${encodeURIComponent(e.sessionID)}/inbox`,successStatus:200,declaredStatuses:[400,401,404],empty:!1},t).then(e=>e.data),cancel:(e,t)=>a({method:`DELETE`,path:`/api/session/${encodeURIComponent(e.sessionID)}/inbox/${encodeURIComponent(e.inboxID)}`,successStatus:204,declaredStatuses:[400,401,404],empty:!0},t),update:(e,t)=>a({method:`PATCH`,path:`/api/session/${encodeURIComponent(e.sessionID)}/inbox/${encodeURIComponent(e.inboxID)}`,body:{delivery:e.delivery},successStatus:204,declaredStatuses:[400,401,404,409],empty:!0},t)},instructions:{entry:{list:(e,t)=>a({method:`GET`,path:`/api/experimental/session/${encodeURIComponent(e.sessionID)}/instructions/entries`,successStatus:200,declaredStatuses:[400,401,404],empty:!1},t).then(e=>e.data),put:(e,t)=>a({method:`PUT`,path:`/api/experimental/session/${encodeURIComponent(e.sessionID)}/instructions/entries/${encodeURIComponent(e.key)}`,body:{value:e.value},successStatus:204,declaredStatuses:[400,401,404,413],empty:!0},t),remove:(e,t)=>a({method:`DELETE`,path:`/api/experimental/session/${encodeURIComponent(e.sessionID)}/instructions/entries/${encodeURIComponent(e.key)}`,successStatus:204,declaredStatuses:[400,401,404],empty:!0},t)}},generate:(e,t)=>a({method:`POST`,path:`/api/session/${encodeURIComponent(e.sessionID)}/generate`,body:{prompt:e.prompt},successStatus:200,declaredStatuses:[400,401,404,503],empty:!1},t).then(e=>e.data),log:(e,t)=>o({method:`GET`,path:`/api/experimental/session/${encodeURIComponent(e.sessionID)}/log`,query:{after:e.after,follow:e.follow},successStatus:200,declaredStatuses:[400,401,404],empty:!1},t),interrupt:(e,t)=>a({method:`POST`,path:`/api/session/${encodeURIComponent(e.sessionID)}/interrupt`,query:{resume:e.resume},successStatus:200,declaredStatuses:[400,401,404],empty:!1},t),background:(e,t)=>a({method:`POST`,path:`/api/session/${encodeURIComponent(e.sessionID)}/background`,successStatus:204,declaredStatuses:[400,401,404],empty:!0},t),message:{get:(e,t)=>a({method:`GET`,path:`/api/session/${encodeURIComponent(e.sessionID)}/message/${encodeURIComponent(e.messageID)}`,successStatus:200,declaredStatuses:[400,401,404],empty:!1},t).then(e=>e.data)},form:{list:(e,t)=>a({method:`GET`,path:`/api/session/${encodeURIComponent(e.sessionID)}/form`,successStatus:200,declaredStatuses:[400,401,404],empty:!1},t).then(e=>e.data),create:(e,t)=>a({method:`POST`,path:`/api/session/${encodeURIComponent(e.sessionID)}/form`,body:{id:e.id,title:e.title,metadata:e.metadata,fields:e.fields},successStatus:200,declaredStatuses:[400,401,404,409],empty:!1},t).then(e=>e.data),get:(e,t)=>a({method:`GET`,path:`/api/session/${encodeURIComponent(e.sessionID)}/form/${encodeURIComponent(e.formID)}`,successStatus:200,declaredStatuses:[400,401,404],empty:!1},t).then(e=>e.data),reply:(e,t)=>a({method:`POST`,path:`/api/session/${encodeURIComponent(e.sessionID)}/form/${encodeURIComponent(e.formID)}/reply`,body:{answer:e.answer},successStatus:204,declaredStatuses:[400,401,404,409],empty:!0},t),cancel:(e,t)=>a({method:`DELETE`,path:`/api/session/${encodeURIComponent(e.sessionID)}/form/${encodeURIComponent(e.formID)}`,query:{message:e.message},successStatus:204,declaredStatuses:[400,401,404,409],empty:!0},t)},environment:(e,t)=>a({method:`PUT`,path:`/api/session/${encodeURIComponent(e.sessionID)}/environment`,body:{variables:e.variables},successStatus:204,declaredStatuses:[400,401,404],empty:!0},t),view:(e,t)=>a({method:`POST`,path:`/api/session/${encodeURIComponent(e.sessionID)}/view`,body:{idle:e.idle},successStatus:204,declaredStatuses:[400,401,404],empty:!0},t)},message:{list:(e,t)=>a({method:`GET`,path:`/api/session/${encodeURIComponent(e.sessionID)}/message`,query:{limit:e.limit,order:e.order,cursor:e.cursor,type:e.type},successStatus:200,declaredStatuses:[400,401,404,500],empty:!1},t)},model:{list:(e,t)=>a({method:`GET`,path:`/api/model`,query:{location:e?.location,types:e?.types},successStatus:200,declaredStatuses:[400,401,404,503],empty:!1},t),default:(e,t)=>a({method:`GET`,path:`/api/model/default`,query:{location:e?.location},successStatus:200,declaredStatuses:[400,401,404,503],empty:!1},t)},generate:{text:(e,t)=>a({method:`POST`,path:`/api/experimental/generate/text`,body:{prompt:e.prompt,model:e.model},successStatus:200,declaredStatuses:[400,401,404,422,502,503],empty:!1},t).then(e=>e.data),image:(e,t)=>a({method:`POST`,path:`/api/experimental/generate/image`,body:{model:e.model,prompt:e.prompt,images:e.images,n:e.n,aspect:e.aspect,resolution:e.resolution},successStatus:200,declaredStatuses:[400,401,404,422,502,503],empty:!1},t).then(e=>e.data),decisions:(e,t)=>a({method:`POST`,path:`/api/experimental/generate/decisions`,body:{model:e.model,input:e.input,questions:e.questions},successStatus:200,declaredStatuses:[400,401,404,422,502,503],empty:!1},t).then(e=>e.data)},voice:{models:e=>a({method:`GET`,path:`/api/experimental/voice/models`,successStatus:200,declaredStatuses:[400,401,404,503],empty:!1},e).then(e=>e.data),session:(e,t)=>a({method:`POST`,path:`/api/experimental/voice/session`,body:{model:e.model,session:e.session,transport:e.transport},successStatus:200,declaredStatuses:[400,401,404,503],empty:!1},t).then(e=>e.data)},provider:{list:(e,t)=>a({method:`GET`,path:`/api/provider`,query:{location:e?.location},successStatus:200,declaredStatuses:[400,401,404,503],empty:!1},t),get:(e,t)=>a({method:`GET`,path:`/api/provider/${encodeURIComponent(e.providerID)}`,query:{location:e.location},successStatus:200,declaredStatuses:[400,401,404,503],empty:!1},t)},integration:{list:(e,t)=>a({method:`GET`,path:`/api/integration`,query:{location:e?.location},successStatus:200,declaredStatuses:[400,401,404],empty:!1},t),get:(e,t)=>a({method:`GET`,path:`/api/integration/${encodeURIComponent(e.integrationID)}`,query:{location:e.location},successStatus:200,declaredStatuses:[400,401,404],empty:!1},t),wellknown:{add:(e,t)=>a({method:`POST`,path:`/api/experimental/integration/wellknown`,query:{location:e.location},body:{url:e.url},successStatus:204,declaredStatuses:[400,401,404],empty:!0},t)},connect:{key:(e,t)=>a({method:`POST`,path:`/api/integration/${encodeURIComponent(e.integrationID)}/connect/key`,query:{location:e.location},body:{key:e.key,answer:e.answer,label:e.label},successStatus:204,declaredStatuses:[400,401,404],empty:!0},t),external:(e,t)=>a({method:`POST`,path:`/api/integration/${encodeURIComponent(e.integrationID)}/connect/external`,query:{location:e.location},body:{methodID:e.methodID,answer:e.answer,label:e.label},successStatus:204,declaredStatuses:[400,401,404],empty:!0},t)},oauth:{connect:(e,t)=>a({method:`POST`,path:`/api/integration/${encodeURIComponent(e.integrationID)}/connect/oauth`,query:{location:e.location},body:{methodID:e.methodID,answer:e.answer,label:e.label},successStatus:200,declaredStatuses:[400,401,404],empty:!1},t),status:(e,t)=>a({method:`GET`,path:`/api/integration/${encodeURIComponent(e.integrationID)}/connect/oauth/${encodeURIComponent(e.attemptID)}`,query:{location:e.location},successStatus:200,declaredStatuses:[400,401,404],empty:!1},t),complete:(e,t)=>a({method:`POST`,path:`/api/integration/${encodeURIComponent(e.integrationID)}/connect/oauth/${encodeURIComponent(e.attemptID)}/complete`,query:{location:e.location},body:{code:e.code},successStatus:204,declaredStatuses:[400,401,404],empty:!0},t),cancel:(e,t)=>a({method:`DELETE`,path:`/api/integration/${encodeURIComponent(e.integrationID)}/connect/oauth/${encodeURIComponent(e.attemptID)}`,query:{location:e.location},successStatus:204,declaredStatuses:[400,401,404],empty:!0},t)},command:{connect:(e,t)=>a({method:`POST`,path:`/api/integration/${encodeURIComponent(e.integrationID)}/connect/command`,query:{location:e.location},body:{methodID:e.methodID,label:e.label},successStatus:200,declaredStatuses:[400,401,404],empty:!1},t),status:(e,t)=>a({method:`GET`,path:`/api/integration/${encodeURIComponent(e.integrationID)}/connect/command/${encodeURIComponent(e.attemptID)}`,query:{location:e.location},successStatus:200,declaredStatuses:[400,401,404],empty:!1},t),cancel:(e,t)=>a({method:`DELETE`,path:`/api/integration/${encodeURIComponent(e.integrationID)}/connect/command/${encodeURIComponent(e.attemptID)}`,query:{location:e.location},successStatus:204,declaredStatuses:[400,401,404],empty:!0},t)}},mcp:{list:(e,t)=>a({method:`GET`,path:`/api/mcp`,query:{location:e?.location},successStatus:200,declaredStatuses:[400,401,404],empty:!1},t),add:(e,t)=>a({method:`PUT`,path:`/api/experimental/mcp/${encodeURIComponent(e.server)}`,query:{location:e.location},body:{config:e.config},successStatus:204,declaredStatuses:[400,401,404],empty:!0},t),remove:(e,t)=>a({method:`DELETE`,path:`/api/experimental/mcp/${encodeURIComponent(e.server)}`,query:{location:e.location},successStatus:204,declaredStatuses:[400,401,404],empty:!0},t),connect:(e,t)=>a({method:`POST`,path:`/api/experimental/mcp/${encodeURIComponent(e.server)}/connect`,query:{location:e.location},successStatus:204,declaredStatuses:[400,401,404],empty:!0},t),disconnect:(e,t)=>a({method:`POST`,path:`/api/experimental/mcp/${encodeURIComponent(e.server)}/disconnect`,query:{location:e.location},successStatus:204,declaredStatuses:[400,401,404],empty:!0},t),resource:{catalog:(e,t)=>a({method:`GET`,path:`/api/mcp/resource`,query:{location:e?.location},successStatus:200,declaredStatuses:[400,401,404],empty:!1},t)},client:{token:(e,t)=>a({method:`POST`,path:`/api/experimental/client-mcp/token`,query:{location:e.location,name:e.name},headers:{"x-opencode-ticket":e[`x-opencode-ticket`]},successStatus:200,declaredStatuses:[400,401,403,404],empty:!1},t)}},credential:{list:e=>a({method:`GET`,path:`/api/credential`,successStatus:200,declaredStatuses:[400,401],empty:!1},e).then(e=>e.data),create:(e,t)=>a({method:`POST`,path:`/api/credential`,body:{id:e.id,integrationID:e.integrationID,label:e.label,value:e.value,activate:e.activate},successStatus:200,declaredStatuses:[400,401,409],empty:!1},t).then(e=>e.data),update:(e,t)=>a({method:`PATCH`,path:`/api/credential/${encodeURIComponent(e.credentialID)}`,body:{label:e.label},successStatus:204,declaredStatuses:[400,401],empty:!0},t),activate:(e,t)=>a({method:`POST`,path:`/api/credential/${encodeURIComponent(e.credentialID)}/activate`,successStatus:204,declaredStatuses:[400,401],empty:!0},t),remove:(e,t)=>a({method:`DELETE`,path:`/api/credential/${encodeURIComponent(e.credentialID)}`,successStatus:204,declaredStatuses:[400,401],empty:!0},t)},project:{list:(e,t)=>a({method:`GET`,path:`/api/project`,query:{archived:e?.archived},successStatus:200,declaredStatuses:[400,401],empty:!1},t),update:(e,t)=>a({method:`PATCH`,path:`/api/project/${encodeURIComponent(e.projectID)}`,body:{canonical:e.canonical,name:e.name,icon:e.icon,commands:e.commands},successStatus:200,declaredStatuses:[400,401,404],empty:!1},t)},form:{list:(e,t)=>a({method:`GET`,path:`/api/form`,query:{location:e?.location},successStatus:200,declaredStatuses:[400,401,404],empty:!1},t)},permission:{request:{list:(e,t)=>a({method:`GET`,path:`/api/permission/request`,query:{location:e?.location},successStatus:200,declaredStatuses:[400,401,404],empty:!1},t)},saved:{list:(e,t)=>a({method:`GET`,path:`/api/permission/saved`,query:{projectID:e?.projectID},successStatus:200,declaredStatuses:[400,401,404],empty:!1},t).then(e=>e.data),update:(e,t)=>a({method:`PATCH`,path:`/api/permission/saved/${encodeURIComponent(e.id)}`,body:{action:e.action,resource:e.resource},successStatus:200,declaredStatuses:[400,401,404,409],empty:!1},t).then(e=>e.data),remove:(e,t)=>a({method:`DELETE`,path:`/api/permission/saved/${encodeURIComponent(e.id)}`,successStatus:204,declaredStatuses:[400,401],empty:!0},t)},create:(e,t)=>a({method:`POST`,path:`/api/session/${encodeURIComponent(e.sessionID)}/permission`,body:{id:e.id,action:e.action,resources:e.resources,save:e.save,metadata:e.metadata,source:e.source,agent:e.agent},successStatus:200,declaredStatuses:[400,401,404],empty:!1},t).then(e=>e.data),list:(e,t)=>a({method:`GET`,path:`/api/session/${encodeURIComponent(e.sessionID)}/permission`,successStatus:200,declaredStatuses:[400,401,404],empty:!1},t).then(e=>e.data),get:(e,t)=>a({method:`GET`,path:`/api/session/${encodeURIComponent(e.sessionID)}/permission/${encodeURIComponent(e.requestID)}`,successStatus:200,declaredStatuses:[400,401,404],empty:!1},t).then(e=>e.data),reply:(e,t)=>a({method:`POST`,path:`/api/session/${encodeURIComponent(e.sessionID)}/permission/${encodeURIComponent(e.requestID)}/reply`,body:{decision:e.decision,message:e.message},successStatus:204,declaredStatuses:[400,401,404],empty:!0},t)},file:{read:(e,t)=>a({method:`GET`,path:`/api/fs/read/${Wt(e.path)}`,query:{location:e.location},successStatus:200,declaredStatuses:[400,401,404],empty:!1,binary:!0},t),list:(e,t)=>a({method:`GET`,path:`/api/fs/list`,query:{location:e?.location,path:e?.path},successStatus:200,declaredStatuses:[400,401,404],empty:!1},t),find:(e,t)=>a({method:`GET`,path:`/api/fs/find`,query:{location:e.location,query:e.query,type:e.type,limit:e.limit},successStatus:200,declaredStatuses:[400,401,404],empty:!1},t),write:(e,t)=>a({method:`POST`,path:`/api/experimental/fs/write`,query:{location:e.location,path:e.path},body:e.payload,successStatus:200,declaredStatuses:[400,401,404],empty:!1,binaryBody:!0},t),watch:(e,t)=>a({method:`POST`,path:`/api/experimental/fs/watch`,query:{location:e.location},body:{path:e.path},successStatus:204,declaredStatuses:[400,401,404,503],empty:!0},t),unwatch:(e,t)=>a({method:`DELETE`,path:`/api/experimental/fs/watch`,query:{location:e.location},body:{path:e.path},successStatus:204,declaredStatuses:[400,401,404],empty:!0},t)},command:{list:(e,t)=>a({method:`GET`,path:`/api/command`,query:{location:e?.location},successStatus:200,declaredStatuses:[400,401,404],empty:!1},t)},skill:{list:(e,t)=>a({method:`GET`,path:`/api/skill`,query:{location:e?.location},successStatus:200,declaredStatuses:[400,401,404],empty:!1},t)},rpc:{call:(e,t)=>a({method:`POST`,path:`/api/rpc/${encodeURIComponent(e.rpcID)}/${encodeURIComponent(e.method)}`,query:{location:e.location},body:{input:e.input},successStatus:200,declaredStatuses:[400,401,404,500],empty:!1},t)},event:{subscribe:(e,t)=>o({method:`GET`,path:`/api/event`,query:{types:e?.types},successStatus:200,declaredStatuses:[400,401],empty:!1},t)},pty:{list:(e,t)=>a({method:`GET`,path:`/api/pty`,query:{location:e?.location},successStatus:200,declaredStatuses:[400,401,404],empty:!1},t),create:(e,t)=>a({method:`POST`,path:`/api/pty`,query:{location:e?.location},body:{command:e?.command,args:e?.args,cwd:e?.cwd,title:e?.title,env:e?.env},successStatus:200,declaredStatuses:[400,401,404],empty:!1},t),get:(e,t)=>a({method:`GET`,path:`/api/pty/${encodeURIComponent(e.ptyID)}`,query:{location:e.location},successStatus:200,declaredStatuses:[400,401,404],empty:!1},t),update:(e,t)=>a({method:`PUT`,path:`/api/pty/${encodeURIComponent(e.ptyID)}`,query:{location:e.location},body:{title:e.title,size:e.size},successStatus:200,declaredStatuses:[400,401,404],empty:!1},t),remove:(e,t)=>a({method:`DELETE`,path:`/api/pty/${encodeURIComponent(e.ptyID)}`,query:{location:e.location},successStatus:204,declaredStatuses:[400,401,404],empty:!0},t),connect:{token:(e,t)=>a({method:`POST`,path:`/api/pty/${encodeURIComponent(e.ptyID)}/connect-token`,query:{location:e.location},headers:{"x-opencode-ticket":e[`x-opencode-ticket`]},successStatus:200,declaredStatuses:[400,401,403,404],empty:!1},t)}},experimental:{persistentPty:{read:(e,t)=>a({method:`GET`,path:`/api/experimental/session/${encodeURIComponent(e.sessionID)}/terminal/read`,query:{lines:e.lines},successStatus:200,declaredStatuses:[400,401,503],empty:!1},t).then(e=>e.data),list:(e,t)=>a({method:`GET`,path:`/api/experimental/session/${encodeURIComponent(e.sessionID)}/terminal`,successStatus:200,declaredStatuses:[400,401,503],empty:!1},t).then(e=>e.data),create:(e,t)=>a({method:`POST`,path:`/api/experimental/session/${encodeURIComponent(e.sessionID)}/terminal`,body:{command:e.command,args:e.args,cwd:e.cwd,title:e.title,env:e.env,size:e.size},successStatus:200,declaredStatuses:[400,401,503],empty:!1},t).then(e=>e.data),shutdown:e=>a({method:`POST`,path:`/api/experimental/persistent-pty/shutdown`,successStatus:204,declaredStatuses:[400,401,503],empty:!0},e),handoff:e=>a({method:`POST`,path:`/api/experimental/persistent-pty/handoff`,successStatus:200,declaredStatuses:[400,401,503],empty:!1},e),get:(e,t)=>a({method:`GET`,path:`/api/experimental/persistent-pty/${encodeURIComponent(e.ptyID)}`,successStatus:200,declaredStatuses:[400,401,404,503],empty:!1},t).then(e=>e.data),update:(e,t)=>a({method:`PUT`,path:`/api/experimental/persistent-pty/${encodeURIComponent(e.ptyID)}`,body:{attachmentID:e.attachmentID,size:e.size},successStatus:200,declaredStatuses:[400,401,404,503],empty:!1},t).then(e=>e.data),snapshot:(e,t)=>a({method:`GET`,path:`/api/experimental/persistent-pty/${encodeURIComponent(e.ptyID)}/snapshot`,successStatus:200,declaredStatuses:[400,401,404,503],empty:!1},t).then(e=>e.data),remove:(e,t)=>a({method:`DELETE`,path:`/api/experimental/persistent-pty/${encodeURIComponent(e.ptyID)}`,successStatus:204,declaredStatuses:[400,401,404,503],empty:!0},t),connectToken:(e,t)=>a({method:`POST`,path:`/api/experimental/persistent-pty/${encodeURIComponent(e.ptyID)}/connect-token`,headers:{"x-opencode-ticket":e[`x-opencode-ticket`]},successStatus:200,declaredStatuses:[400,401,403,404,503],empty:!1},t).then(e=>e.data)},media:{get:(e,t)=>a({method:`GET`,path:`/api/experimental/media/${encodeURIComponent(e.hash)}`,successStatus:200,declaredStatuses:[400,401,404],empty:!1,binary:!0},t)}},shell:{list:(e,t)=>a({method:`GET`,path:`/api/shell`,query:{location:e?.location},successStatus:200,declaredStatuses:[400,401,404],empty:!1},t),create:(e,t)=>a({method:`POST`,path:`/api/shell`,query:{location:e.location},body:{command:e.command,cwd:e.cwd,timeout:e.timeout,metadata:e.metadata},successStatus:200,declaredStatuses:[400,401,404],empty:!1},t),get:(e,t)=>a({method:`GET`,path:`/api/shell/${encodeURIComponent(e.id)}`,query:{location:e.location},successStatus:200,declaredStatuses:[400,401,404],empty:!1},t),output:(e,t)=>a({method:`GET`,path:`/api/shell/${encodeURIComponent(e.id)}/output`,query:{location:e.location,cursor:e.cursor,limit:e.limit},successStatus:200,declaredStatuses:[400,401,404],empty:!1},t),remove:(e,t)=>a({method:`DELETE`,path:`/api/shell/${encodeURIComponent(e.id)}`,query:{location:e.location},successStatus:204,declaredStatuses:[400,401,404],empty:!0},t)},reference:{list:(e,t)=>a({method:`GET`,path:`/api/reference`,query:{location:e?.location},successStatus:200,declaredStatuses:[400,401,404],empty:!1},t)},worktree:{list:(e,t)=>a({method:`GET`,path:`/api/worktree`,query:{projectID:e.projectID},successStatus:200,declaredStatuses:[400,401,404],empty:!1},t),create:(e,t)=>a({method:`POST`,path:`/api/worktree`,body:{projectID:e.projectID,from:e.from,branch:e.branch,directory:e.directory,name:e.name},successStatus:200,declaredStatuses:[400,401,404],empty:!1},t),remove:(e,t)=>a({method:`DELETE`,path:`/api/worktree`,body:{projectID:e.projectID,directory:e.directory,force:e.force},successStatus:204,declaredStatuses:[400,401,404],empty:!0},t),refresh:(e,t)=>a({method:`POST`,path:`/api/worktree/refresh`,body:{projectID:e.projectID},successStatus:204,declaredStatuses:[400,401,404],empty:!0},t)},vcs:{init:(e,t)=>a({method:`POST`,path:`/api/vcs/init`,query:{location:e?.location,provider:e?.provider},successStatus:204,declaredStatuses:[400,401,404,409,501,503],empty:!0},t),get:(e,t)=>a({method:`GET`,path:`/api/vcs`,query:{location:e?.location},successStatus:200,declaredStatuses:[400,401,404],empty:!1},t),base:(e,t)=>a({method:`GET`,path:`/api/vcs/base`,query:{location:e?.location},successStatus:200,declaredStatuses:[400,401,404,503],empty:!1},t),status:(e,t)=>a({method:`GET`,path:`/api/vcs/status`,query:{location:e?.location},successStatus:200,declaredStatuses:[400,401,404],empty:!1},t),branch:{list:(e,t)=>a({method:`GET`,path:`/api/vcs/branch`,query:{location:e?.location,search:e?.search,limit:e?.limit},successStatus:200,declaredStatuses:[400,401,404],empty:!1},t)},diff:(e,t)=>a({method:`GET`,path:`/api/vcs/diff`,query:{location:e.location,mode:e.mode,base:e.base,context:e.context,untracked:e.untracked},successStatus:200,declaredStatuses:[400,401,404,503],empty:!1},t)},debug:{heapDump:(e,t)=>a({method:`POST`,path:`/api/debug/heap-dump`,query:{directory:e?.directory},successStatus:200,declaredStatuses:[400,401,500],empty:!1},t),location:{list:e=>a({method:`GET`,path:`/api/debug/location`,successStatus:200,declaredStatuses:[400,401],empty:!1},e),evict:(e,t)=>a({method:`DELETE`,path:`/api/debug/location`,query:{location:e?.location},successStatus:204,declaredStatuses:[400,401],empty:!0},t)}},migration:{v1:{status:e=>a({method:`GET`,path:`/api/experimental/migration/v1`,successStatus:200,declaredStatuses:[400,401],empty:!1},e)}},websearch:{providers:(e,t)=>a({method:`GET`,path:`/api/websearch/provider`,query:{location:e?.location},successStatus:200,declaredStatuses:[400,401,404,503],empty:!1},t),query:(e,t)=>a({method:`POST`,path:`/api/websearch`,query:{location:e.location},body:{query:e.query,providerID:e.providerID},successStatus:200,declaredStatuses:[400,401,404,503],empty:!1},t)},usage:{limits:(e,t)=>a({method:`GET`,path:`/api/experimental/usage/limits`,query:{location:e?.location},successStatus:200,declaredStatuses:[400,401,404,503],empty:!1},t)},config:{get:(e,t)=>a({method:`GET`,path:`/api/config`,query:{location:e?.location},successStatus:200,declaredStatuses:[400,401,404],empty:!1},t),shells:e=>a({method:`GET`,path:`/api/config/shell`,successStatus:200,declaredStatuses:[400,401,404],empty:!1},e),update:(e,t)=>a({method:`PATCH`,path:`/api/experimental/config`,body:{shell:e.shell},successStatus:204,declaredStatuses:[400,401,404],empty:!0},t)}}}function Wt(e){return e.split(`/`).map(encodeURIComponent).join(`/`)}function Gt(e,t,n){if(n!==void 0){if(n===null){e.append(t,`null`);return}if(Array.isArray(n)){for(let r of n)Gt(e,t,r);return}if(typeof n==`object`){for(let[r,i]of Object.entries(n))Gt(e,`${t}[${r}]`,i);return}e.append(t,String(n))}}async function Kt(e){if(!Jt(e,`application/json`)&&!e.headers.get(`content-type`)?.includes(`+json`)){try{await e.body?.cancel()}catch{}throw new Vt(`UnsupportedContentType`,{detail:e.headers.get(`content-type`)})}let t;try{t=await e.text()}catch(e){throw new Vt(`Transport`,{cause:e})}if(t===``)throw new Vt(`MalformedResponse`);try{return JSON.parse(t)}catch(e){throw new Vt(`MalformedResponse`,{cause:e})}}function qt(e){let t=Object.assign(Error(e.message??e.data?.message),e);return e._tag&&(t.name=e._tag),t}function Jt(e,t){return e.headers.get(`content-type`)?.split(`;`,1)[0]?.trim().toLowerCase()===t}var Yt=e=>typeof e==`object`&&!!e&&`_tag`in e&&e._tag===`InvalidRequestError`,Xt=e=>typeof e==`object`&&!!e&&`_tag`in e&&e._tag===`UnauthorizedError`,Zt=e=>typeof e==`object`&&!!e&&`_tag`in e&&e._tag===`LocationNotFoundError`,Qt=e=>typeof e==`object`&&!!e&&`_tag`in e&&e._tag===`ServiceUnavailableError`,$t=e=>typeof e==`object`&&!!e&&`_tag`in e&&e._tag===`AgentNotFoundError`,en=e=>typeof e==`object`&&!!e&&`_tag`in e&&e._tag===`PluginNotFoundError`,tn=e=>typeof e==`object`&&!!e&&`_tag`in e&&e._tag===`InvalidCursorError`,nn=e=>typeof e==`object`&&!!e&&`_tag`in e&&e._tag===`SessionNotFoundError`,rn=e=>typeof e==`object`&&!!e&&`_tag`in e&&e._tag===`ConflictError`,an=e=>typeof e==`object`&&!!e&&`_tag`in e&&e._tag===`UnknownError`,on=e=>typeof e==`object`&&!!e&&`_tag`in e&&e._tag===`MessageNotFoundError`,sn=e=>typeof e==`object`&&!!e&&`_tag`in e&&e._tag===`CommandNotFoundError`,cn=e=>typeof e==`object`&&!!e&&`_tag`in e&&e._tag===`CommandExecutionError`,ln=e=>typeof e==`object`&&!!e&&`_tag`in e&&e._tag===`SkillNotFoundError`,un=e=>typeof e==`object`&&!!e&&`_tag`in e&&e._tag===`SessionBusyError`,dn=e=>typeof e==`object`&&!!e&&`_tag`in e&&e._tag===`InstructionEntryValueTooLargeError`,fn=e=>typeof e==`object`&&!!e&&`_tag`in e&&e._tag===`FormNotFoundError`,pn=e=>typeof e==`object`&&!!e&&`_tag`in e&&e._tag===`FormInvalidAnswerError`,mn=e=>typeof e==`object`&&!!e&&`_tag`in e&&e._tag===`FormAlreadySettledError`,hn=e=>typeof e==`object`&&!!e&&`_tag`in e&&e._tag===`ProviderNotFoundError`,gn=e=>typeof e==`object`&&!!e&&`_tag`in e&&e._tag===`ModelNotFoundError`,_n=e=>typeof e==`object`&&!!e&&`_tag`in e&&e._tag===`UnsupportedModelError`,vn=e=>typeof e==`object`&&!!e&&`_tag`in e&&e._tag===`ProviderRequestError`,yn=e=>typeof e==`object`&&!!e&&`_tag`in e&&e._tag===`IntegrationNotFoundError`,bn=e=>typeof e==`object`&&!!e&&`_tag`in e&&e._tag===`IntegrationAttemptNotFoundError`,xn=e=>typeof e==`object`&&!!e&&`_tag`in e&&e._tag===`IntegrationMethodNotFoundError`,Sn=e=>typeof e==`object`&&!!e&&`_tag`in e&&e._tag===`McpServerNotFoundError`,Cn=e=>typeof e==`object`&&!!e&&`_tag`in e&&e._tag===`ForbiddenError`,wn=e=>typeof e==`object`&&!!e&&`_tag`in e&&e._tag===`ProjectNotFoundError`,Tn=e=>typeof e==`object`&&!!e&&`_tag`in e&&e._tag===`PermissionSavedNotFoundError`,En=e=>typeof e==`object`&&!!e&&`_tag`in e&&e._tag===`PermissionNotFoundError`,Dn=e=>typeof e==`object`&&!!e&&`_tag`in e&&e._tag===`FileNotFoundError`,On=e=>typeof e==`object`&&!!e&&`_tag`in e&&e._tag===`RpcError`,kn=e=>typeof e==`object`&&!!e&&`_tag`in e&&e._tag===`RpcInternalError`,An=e=>typeof e==`object`&&!!e&&`_tag`in e&&e._tag===`PtyNotFoundError`,jn=e=>typeof e==`object`&&!!e&&`_tag`in e&&e._tag===`ShellNotFoundError`,Mn=e=>typeof e==`object`&&!!e&&`_tag`in e&&e._tag===`WorktreeError`,Nn=e=>typeof e==`object`&&!!e&&`_tag`in e&&e._tag===`VcsInitNotSupportedError`;function Pn(e,t){return n=>{let r=(e,r)=>{if(!Object.hasOwn(n.events,e))throw Error(`Unknown RPC event: ${n.id}.${e}`);let i=Fn(n,e);return{[Symbol.asyncIterator](){let e=new AbortController,n=r?.signal?AbortSignal.any([e.signal,r.signal]):e.signal,a=async function*(){try{for await(let e of t.subscribe({signal:n})){if(n.aborted)return;e.type===i&&(yield e)}}catch(e){if(!n.aborted)throw e}finally{e.abort()}}();return{next:()=>a.next(),return:()=>(e.abort(),a.return())}}}};return Object.assign(Object.fromEntries(Object.keys(n.methods).map(t=>[t,async(r,i)=>{try{return(await e.rpc.call({rpcID:n.id,method:t,input:r,location:i?.location},{signal:i?.signal,headers:i?.headers})).output}catch(e){throw!On(e)&&!kn(e)?e:e.data===void 0?{type:e.type,message:e.message}:{type:e.type,message:e.message,data:e.data}}}])),{events:{subscribe:r,on:(e,t,n)=>{let i=new AbortController,a=n?.signal?AbortSignal.any([i.signal,n.signal]):i.signal,o=r(e,{signal:a});return(async()=>{for await(let e of o)await t(e)})().catch(e=>console.error(e)),()=>i.abort()}}})}}function Fn(e,t){return`rpc.${e.id}.${t}`}var In={};Rt(In,{OpenCode:()=>In,make:()=>Ln});function Ln(e){let t=Ut(e),n=Bt((e,n)=>t.event.subscribe(void 0,{signal:e,onActivity:n}));return{...t,rpc:Object.assign(Pn(t,n),t.rpc),event:n}}var Rn=e({ClientError:()=>Vt,OpenCode:()=>In,isAgentNotFoundError:()=>$t,isCommandExecutionError:()=>cn,isCommandNotFoundError:()=>sn,isConflictError:()=>rn,isFileNotFoundError:()=>Dn,isForbiddenError:()=>Cn,isFormAlreadySettledError:()=>mn,isFormInvalidAnswerError:()=>pn,isFormNotFoundError:()=>fn,isInstructionEntryValueTooLargeError:()=>dn,isIntegrationAttemptNotFoundError:()=>bn,isIntegrationMethodNotFoundError:()=>xn,isIntegrationNotFoundError:()=>yn,isInvalidCursorError:()=>tn,isInvalidRequestError:()=>Yt,isLocationNotFoundError:()=>Zt,isMcpServerNotFoundError:()=>Sn,isMessageNotFoundError:()=>on,isModelNotFoundError:()=>gn,isPermissionNotFoundError:()=>En,isPermissionSavedNotFoundError:()=>Tn,isPluginNotFoundError:()=>en,isProjectNotFoundError:()=>wn,isProviderNotFoundError:()=>hn,isProviderRequestError:()=>vn,isPtyNotFoundError:()=>An,isRpcError:()=>On,isRpcInternalError:()=>kn,isServiceUnavailableError:()=>Qt,isSessionBusyError:()=>un,isSessionNotFoundError:()=>nn,isShellNotFoundError:()=>jn,isSkillNotFoundError:()=>ln,isUnauthorizedError:()=>Xt,isUnknownError:()=>an,isUnsupportedModelError:()=>_n,isVcsInitNotSupportedError:()=>Nn,isWorktreeError:()=>Mn}),zn=e({$DEVCOMP:()=>fr,$PROXY:()=>lr,$TRACK:()=>dr,DEV:()=>void 0,ErrorBoundary:()=>Zi,For:()=>Wi,Index:()=>Gi,Match:()=>Ji,Show:()=>Ki,Suspense:()=>ta,SuspenseList:()=>ea,Switch:()=>qi,batch:()=>Ir,cancelCallback:()=>nr,catchError:()=>Vr,children:()=>$r,createComponent:()=>Ni,createComputed:()=>Dr,createContext:()=>Zr,createDeferred:()=>Pr,createEffect:()=>kr,createMemo:()=>jr,createReaction:()=>Ar,createRenderEffect:()=>Or,createResource:()=>Nr,createRoot:()=>Tr,createSelector:()=>Fr,createSignal:()=>Er,createUniqueId:()=>Hi,enableExternalSource:()=>ni,enableHydration:()=>Mi,enableScheduling:()=>Gr,equalFn:()=>cr,from:()=>Ei,getListener:()=>Hr,getOwner:()=>Ur,indexArray:()=>Ai,lazy:()=>Bi,mapArray:()=>ki,mergeProps:()=>Ri,observable:()=>Ti,on:()=>Rr,onCleanup:()=>Br,onError:()=>Ci,onMount:()=>zr,requestCallback:()=>tr,resetErrorBoundaries:()=>Xi,runWithOwner:()=>Wr,sharedConfig:()=>F,splitProps:()=>zi,startTransition:()=>Kr,untrack:()=>Lr,useContext:()=>Qr,useTransition:()=>Yr}),Bn=1,Vn=!1,Hn=!1,Un=[],Wn=null,Gn=null,Kn=5,qn=0,Jn=300,Yn=0,Xn=null,Zn=null,Qn=1073741823;function $n(){let e=new MessageChannel,t=e.port1,n=e.port2;if(typeof t.unref==`function`&&t.unref(),typeof n.unref==`function`&&n.unref(),Xn=()=>n.postMessage(null),t.onmessage=()=>{if(Zn!==null){let e=performance.now();qn=e+Kn,Yn=e+Jn;try{Zn(e)?n.postMessage(null):Zn=null}catch(e){throw n.postMessage(null),e}}},navigator&&navigator.scheduling&&navigator.scheduling.isInputPending){let e=navigator.scheduling;Gn=()=>{let t=performance.now();return t>=qn?e.isInputPending()?!0:t>=Yn:!1}}else Gn=()=>performance.now()>=qn}function er(e,t){function n(){let n=0,r=e.length-1;for(;n<=r;){let i=r+n>>1,a=t.expirationTime-e[i].expirationTime;if(a>0)n=i+1;else if(a<0)r=i-1;else return i}return n}e.splice(n(),0,t)}function tr(e,t){Xn||$n();let n=performance.now(),r=Qn;t&&t.timeout&&(r=t.timeout);let i={id:Bn++,fn:e,startTime:n,expirationTime:n+r};return er(Un,i),!Vn&&!Hn&&(Vn=!0,Zn=rr,Xn()),i}function nr(e){e.fn=null}function rr(e){Vn=!1,Hn=!0;try{return ir(e)}finally{Wn=null,Hn=!1}}function ir(e){let t=e;for(Wn=Un[0]||null;Wn!==null&&!(Wn.expirationTime>t&&Gn());){let e=Wn.fn;e===null?Un.shift():(Wn.fn=null,e(Wn.expirationTime<=t),t=performance.now(),Wn===Un[0]&&Un.shift()),Wn=Un[0]||null}return Wn!==null}var F={context:void 0,registry:void 0,effects:void 0,done:!1,getContextId(){return ar(this.context.count)},getNextContextId(){return ar(this.context.count++)}};function ar(e){let t=String(e),n=t.length-1;return F.context.id+(n?String.fromCharCode(96+n):``)+t}function or(e){F.context=e}function sr(){return{...F.context,id:F.getNextContextId(),count:0}}var cr=(e,t)=>e===t,lr=Symbol(`solid-proxy`),ur=typeof Proxy==`function`,dr=Symbol(`solid-track`),fr=Symbol(`solid-dev-component`),pr={equals:cr},mr=null,hr=di,gr=1,_r=2,vr={owned:null,cleanups:null,context:null,owner:null},yr={},I=null,L=null,br=null,xr=null,R=null,Sr=null,Cr=null,wr=0;function Tr(e,t){let n=R,r=I,i=e.length===0,a=t===void 0?r:t,o=i?vr:{owned:null,cleanups:null,context:a?a.context:null,owner:a},s=i?e:()=>e(()=>Lr(()=>gi(o)));I=o,R=null;try{return li(s,!0)}finally{R=n,I=r}}function Er(e,t){t=t?Object.assign({},pr,t):pr;let n={value:e,observers:null,observerSlots:null,comparator:t.equals||void 0};return[ri.bind(n),e=>(typeof e==`function`&&(e=L&&L.running&&L.sources.has(n)?e(n.tValue):e(n.value)),ii(n,e))]}function Dr(e,t,n){let r=si(e,t,!0,gr);br&&L&&L.running?Sr.push(r):ai(r)}function Or(e,t,n){let r=si(e,t,!1,gr);br&&L&&L.running?Sr.push(r):ai(r)}function kr(e,t,n){hr=pi;let r=si(e,t,!1,gr),i=ei&&Qr(ei);i&&(r.suspense=i),(!n||!n.render)&&(r.user=!0),Cr?Cr.push(r):ai(r)}function Ar(e,t){let n,r=si(()=>{n?n():Lr(e),n=void 0},void 0,!1,0),i=ei&&Qr(ei);return i&&(r.suspense=i),r.user=!0,e=>{n=e,ai(r)}}function jr(e,t,n){n=n?Object.assign({},pr,n):pr;let r=si(e,t,!0,0);return r.observers=null,r.observerSlots=null,r.comparator=n.equals||void 0,br&&L&&L.running?(r.tState=gr,Sr.push(r)):ai(r),ri.bind(r)}function Mr(e){return e&&typeof e==`object`&&`then`in e}function Nr(e,t,n){let r,i,a;typeof t==`function`?(r=e,i=t,a=n||{}):(r=!0,i=e,a=t||{});let o=null,s=yr,c=null,l=!1,u=!1,d=`initialValue`in a,f=typeof r==`function`&&jr(r),p=new Set,[ee,te]=(a.storage||Er)(a.initialValue),[m,h]=Er(void 0),[ne,re]=Er(void 0,{equals:!1}),[ie,ae]=Er(d?`ready`:`unresolved`);F.context&&(c=F.getNextContextId(),a.ssrLoadFrom===`initial`?s=a.initialValue:F.load&&F.has(c)&&(s=F.load(c)));function oe(e,t,n,r){return o===e&&(o=null,r!==void 0&&(d=!0),(e===s||t===s)&&a.onHydrated&&queueMicrotask(()=>a.onHydrated(r,{value:t})),s=yr,L&&e&&l?(L.promises.delete(e),l=!1,li(()=>{L.running=!0,se(t,n)},!1)):se(t,n)),t}function se(e,t){li(()=>{t===void 0&&te(()=>e),ae(t===void 0?d?`ready`:`unresolved`:`errored`),h(t);for(let e of p.keys())e.decrement();p.clear()},!1)}function ce(){let e=ei&&Qr(ei),t=ee(),n=m();if(n!==void 0&&!o)throw n;return R&&!R.user&&e&&Dr(()=>{ne(),o&&(e.resolved&&L&&l?L.promises.add(o):p.has(e)||(e.increment(),p.add(e)))}),t}function le(e=!0){if(e!==!1&&u)return;u=!1;let t=f?f():r;if(l=L&&L.running,t==null||t===!1){oe(o,Lr(ee));return}L&&o&&L.promises.delete(o);let n,a=s===yr?Lr(()=>{try{return i(t,{value:ee(),refetching:e})}catch(e){n=e}}):s;if(n!==void 0){oe(o,void 0,vi(n),t);return}return Mr(a)?(o=a,`v`in a?(a.s===1?oe(o,a.v,void 0,t):oe(o,void 0,vi(a.v),t),a):(u=!0,queueMicrotask(()=>u=!1),li(()=>{ae(d?`refreshing`:`pending`),re()},!1),a.then(e=>oe(a,e,void 0,t),e=>oe(a,void 0,vi(e),t)))):(oe(o,a,void 0,t),a)}Object.defineProperties(ce,{state:{get:()=>ie()},error:{get:()=>m()},loading:{get(){let e=ie();return e===`pending`||e===`refreshing`}},latest:{get(){if(!d)return ce();let e=m();if(e&&!o)throw e;return ee()}}});let ue=I;return f?Dr(()=>(ue=I,le(!1))):le(!1),[ce,{refetch:e=>Wr(ue,()=>le(e)),mutate:te}]}function Pr(e,t){let n,r=t?t.timeoutMs:void 0,i=si(()=>((!n||!n.fn)&&(n=tr(()=>o(()=>i.value),r===void 0?void 0:{timeout:r})),e()),void 0,!0),[a,o]=Er(L&&L.running&&L.sources.has(i)?i.tValue:i.value,t);return ai(i),o(()=>L&&L.running&&L.sources.has(i)?i.tValue:i.value),a}function Fr(e,t=cr,n){let r=new Map,i=si(n=>{let i=e();for(let[e,a]of r.entries())if(t(e,i)!==t(e,n))for(let e of a.values())e.state=gr,e.pure?Sr.push(e):Cr.push(e);return i},void 0,!0,gr);return ai(i),e=>{let n=R;if(n){let t;(t=r.get(e))?t.add(n):r.set(e,t=new Set([n])),Br(()=>{t.delete(n),!t.size&&r.delete(e)})}return t(e,L&&L.running&&L.sources.has(i)?i.tValue:i.value)}}function Ir(e){return li(e,!1)}function Lr(e){if(!xr&&R===null)return e();let t=R;R=null;try{return xr?xr.untrack(e):e()}finally{R=t}}function Rr(e,t,n){let r=Array.isArray(e),i,a=n&&n.defer;return n=>{let o;if(r){o=Array(e.length);for(let t=0;t<e.length;t++)o[t]=e[t]()}else o=e();if(a)return a=!1,n;let s=Lr(()=>t(o,i,n));return i=o,s}}function zr(e){kr(()=>Lr(e))}function Br(e){return I===null||(I.cleanups===null?I.cleanups=[e]:I.cleanups.push(e)),e}function Vr(e,t){mr||=Symbol(`error`),I=si(void 0,void 0,!0),I.context={...I.context,[mr]:[t]},L&&L.running&&L.sources.add(I);try{return e()}catch(e){bi(e)}finally{I=I.owner}}function Hr(){return R}function Ur(){return I}function Wr(e,t){let n=I,r=R;I=e,R=null;try{return li(t,!0)}catch(e){bi(e)}finally{I=n,R=r}}function Gr(e=tr){br=e}function Kr(e){if(L&&L.running)return e(),L.done;let t=R,n=I;return Promise.resolve().then(()=>{R=t,I=n;let r;return(br||ei)&&(r=L||={sources:new Set,effects:[],promises:new Set,disposed:new Set,queue:new Set,running:!0},r.done||(r.done=new Promise(e=>r.resolve=e)),r.running=!0),li(e,!1),R=I=null,r?r.done:void 0})}var[qr,Jr]=Er(!1);function Yr(){return[qr,Kr]}function Xr(e){Cr.push.apply(Cr,e),e.length=0}function Zr(e,t){let n=Symbol(`context`);return{id:n,Provider:Si(n),defaultValue:e}}function Qr(e){let t;return I&&I.context&&(t=I.context[e.id])!==void 0?t:e.defaultValue}function $r(e){let t=jr(e),n=jr(()=>xi(t()));return n.toArray=()=>{let e=n();return Array.isArray(e)?e:e==null?[]:[e]},n}var ei;function ti(){return ei||=Zr()}function ni(e,t=e=>e()){if(xr){let{factory:n,untrack:r}=xr;xr={factory:(t,r)=>{let i=n(t,r),a=e(e=>i.track(e),r);return{track:e=>a.track(e),dispose(){a.dispose(),i.dispose()}}},untrack:e=>r(()=>t(e))}}else xr={factory:e,untrack:t}}function ri(){let e=L&&L.running;if(this.sources&&(e?this.tState:this.state))if((e?this.tState:this.state)===gr)ai(this);else{let e=Sr;Sr=null,li(()=>mi(this),!1),Sr=e}if(R){let e=this.observers;if(!e||e[e.length-1]!==R){let t=e?e.length:0;R.sources?(R.sources.push(this),R.sourceSlots.push(t)):(R.sources=[this],R.sourceSlots=[t]),e?(e.push(R),this.observerSlots.push(R.sources.length-1)):(this.observers=[R],this.observerSlots=[R.sources.length-1])}}return e&&L.sources.has(this)?this.tValue:this.value}function ii(e,t,n){let r=L&&L.running&&L.sources.has(e)?e.tValue:e.value;if(!e.comparator||!e.comparator(r,t)){if(L){let r=L.running;(r||!n&&L.sources.has(e))&&(L.sources.add(e),e.tValue=t),r||(e.value=t)}else e.value=t;e.observers&&e.observers.length&&li(()=>{for(let t=0;t<e.observers.length;t+=1){let n=e.observers[t],r=L&&L.running;r&&L.disposed.has(n)||((r?!n.tState:!n.state)&&(n.pure?Sr.push(n):Cr.push(n),n.observers&&hi(n)),r?n.tState=gr:n.state=gr)}if(Sr.length>1e6)throw Sr=[],Error()},!1)}return t}function ai(e){if(!e.fn)return;gi(e);let t=wr;oi(e,L&&L.running&&L.sources.has(e)?e.tValue:e.value,t),L&&!L.running&&L.sources.has(e)&&queueMicrotask(()=>{li(()=>{L&&(L.running=!0),R=I=e,oi(e,e.tValue,t),R=I=null},!1)})}function oi(e,t,n){let r,i=I,a=R;R=I=e;try{r=e.fn(t)}catch(t){return e.pure&&(L&&L.running?(e.tState=gr,e.tOwned&&e.tOwned.forEach(gi),e.tOwned=void 0):(e.state=gr,e.owned&&e.owned.forEach(gi),e.owned=null)),e.updatedAt=n+1,bi(t)}finally{R=a,I=i}(!e.updatedAt||e.updatedAt<=n)&&(e.updatedAt!=null&&`observers`in e?ii(e,r,!0):L&&L.running&&e.pure?(L.sources.has(e)||(e.value=r),L.sources.add(e),e.tValue=r):e.value=r,e.updatedAt=n)}function si(e,t,n,r=gr,i){let a={fn:e,state:r,updatedAt:null,owned:null,sources:null,sourceSlots:null,cleanups:null,value:t,owner:I,context:I?I.context:null,pure:n};if(L&&L.running&&(a.state=0,a.tState=r),I===null||I!==vr&&(L&&L.running&&I.pure?I.tOwned?I.tOwned.push(a):I.tOwned=[a]:I.owned?I.owned.push(a):I.owned=[a]),xr&&a.fn){let e=a.fn,[t,n]=Er(void 0,{equals:!1}),r=xr.factory(e,n);Br(()=>r.dispose());let i,o=()=>Kr(n).then(()=>{i&&=(i.dispose(),void 0)});a.fn=n=>(t(),L&&L.running?(i||=xr.factory(e,o),i.track(n)):r.track(n))}return a}function ci(e){let t=L&&L.running;if((t?e.tState:e.state)===0)return;if((t?e.tState:e.state)===_r)return mi(e);if(e.suspense&&Lr(e.suspense.inFallback))return e.suspense.effects.push(e);let n=[e];for(;(e=e.owner)&&(!e.updatedAt||e.updatedAt<wr);){if(t&&L.disposed.has(e))return;(t?e.tState:e.state)&&n.push(e)}for(let r=n.length-1;r>=0;r--){if(e=n[r],t){let t=e,i=n[r+1];for(;(t=t.owner)&&t!==i;)if(L.disposed.has(t))return}if((t?e.tState:e.state)===gr)ai(e);else if((t?e.tState:e.state)===_r){let t=Sr;Sr=null,li(()=>mi(e,n[0]),!1),Sr=t}}}function li(e,t){if(Sr)return e();let n=!1;t||(Sr=[]),Cr?n=!0:Cr=[],wr++;try{let t=e();return ui(n),t}catch(e){n||(Cr=null),Sr=null,bi(e)}}function ui(e){if(Sr&&=(br&&L&&L.running?fi(Sr):di(Sr),null),e)return;let t;if(L){if(!L.promises.size&&!L.queue.size){let e=L.sources,n=L.disposed;Cr.push.apply(Cr,L.effects),t=L.resolve;for(let e of Cr)`tState`in e&&(e.state=e.tState),delete e.tState;L=null,li(()=>{for(let e of n)gi(e);for(let t of e){if(t.value=t.tValue,t.owned)for(let e=0,n=t.owned.length;e<n;e++)gi(t.owned[e]);t.tOwned&&(t.owned=t.tOwned),delete t.tValue,delete t.tOwned,t.tState=0}Jr(!1)},!1)}else if(L.running){L.running=!1,L.effects.push.apply(L.effects,Cr),Cr=null,Jr(!0);return}}let n=Cr;Cr=null,n.length&&li(()=>hr(n),!1),t&&t()}function di(e){for(let t=0;t<e.length;t++)ci(e[t])}function fi(e){for(let t=0;t<e.length;t++){let n=e[t],r=L.queue;r.has(n)||(r.add(n),br(()=>{r.delete(n),li(()=>{L.running=!0,ci(n)},!1),L&&(L.running=!1)}))}}function pi(e){let t,n=0;for(t=0;t<e.length;t++){let r=e[t];r.user?e[n++]=r:ci(r)}if(F.context){if(F.count){F.effects||=[],F.effects.push(...e.slice(0,n));return}or()}for(F.effects&&(F.done||!F.count)&&(e=[...F.effects,...e],n+=F.effects.length,delete F.effects),t=0;t<n;t++)ci(e[t])}function mi(e,t){let n=L&&L.running;n?e.tState=0:e.state=0;for(let r=0;r<e.sources.length;r+=1){let i=e.sources[r];if(i.sources){let e=n?i.tState:i.state;e===gr?i!==t&&(!i.updatedAt||i.updatedAt<wr)&&ci(i):e===_r&&mi(i,t)}}}function hi(e){let t=L&&L.running;for(let n=0;n<e.observers.length;n+=1){let r=e.observers[n];(t?!r.tState:!r.state)&&(t?r.tState=_r:r.state=_r,r.pure?Sr.push(r):Cr.push(r),r.observers&&hi(r))}}function gi(e){let t;if(e.sources)for(;e.sources.length;){let t=e.sources.pop(),n=e.sourceSlots.pop(),r=t.observers;if(r&&r.length){let e=r.pop(),i=t.observerSlots.pop();n<r.length&&(e.sourceSlots[i]=n,r[n]=e,t.observerSlots[n]=i)}}if(e.tOwned){for(t=e.tOwned.length-1;t>=0;t--)gi(e.tOwned[t]);delete e.tOwned}if(L&&L.running&&e.pure)_i(e,!0);else if(e.owned){for(t=e.owned.length-1;t>=0;t--)gi(e.owned[t]);e.owned=null}if(e.cleanups){for(t=e.cleanups.length-1;t>=0;t--)e.cleanups[t]();e.cleanups=null}L&&L.running?e.tState=0:e.state=0}function _i(e,t){if(t||(e.tState=0,L.disposed.add(e)),e.owned)for(let t=0;t<e.owned.length;t++)_i(e.owned[t])}function vi(e){return e instanceof Error?e:Error(typeof e==`string`?e:`Unknown error`,{cause:e})}function yi(e,t,n){try{for(let n of t)n(e)}catch(e){bi(e,n&&n.owner||null)}}function bi(e,t=I){let n=mr&&t&&t.context&&t.context[mr],r=vi(e);if(!n)throw r;Cr?Cr.push({fn(){yi(r,n,t)},state:gr}):yi(r,n,t)}function xi(e){if(typeof e==`function`&&!e.length)return xi(e());if(Array.isArray(e)){let t=[];for(let n=0;n<e.length;n++){let r=xi(e[n]);if(Array.isArray(r))if(r.length<32768)t.push.apply(t,r);else for(let e=0;e<r.length;e++)t.push(r[e]);else t.push(r)}return t}return e}function Si(e,t){return function(t){let n;return Or(()=>n=Lr(()=>(I.context={...I.context,[e]:t.value},$r(()=>t.children))),void 0),n}}function Ci(e){mr||=Symbol(`error`),I===null||(I.context===null||!I.context[mr]?(I.context={...I.context,[mr]:[e]},wi(I,mr,[e])):I.context[mr].push(e))}function wi(e,t,n){if(e.owned)for(let r=0;r<e.owned.length;r++)e.owned[r].context===e.context&&wi(e.owned[r],t,n),e.owned[r].context?e.owned[r].context[t]||(e.owned[r].context[t]=n,wi(e.owned[r],t,n)):(e.owned[r].context=e.context,wi(e.owned[r],t,n))}function Ti(e){return{subscribe(t){if(!(t instanceof Object)||t==null)throw TypeError(`Expected the observer to be an object.`);let n=typeof t==`function`?t:t.next&&t.next.bind(t);if(!n)return{unsubscribe(){}};let r=Tr(t=>(kr(()=>{let t=e();Lr(()=>n(t))}),t));return Ur()&&Br(r),{unsubscribe(){r()}}},[Symbol.observable||`@@observable`](){return this}}}function Ei(e,t=void 0){let[n,r]=Er(t,{equals:!1});if(`subscribe`in e){let t=e.subscribe(e=>r(()=>e));Br(()=>`unsubscribe`in t?t.unsubscribe():t())}else Br(e(r));return n}var Di=Symbol(`fallback`);function Oi(e){for(let t=0;t<e.length;t++)e[t]()}function ki(e,t,n={}){let r=[],i=[],a=[],o=0,s=t.length>1?[]:null;return Br(()=>Oi(a)),()=>{let c=e()||[],l=c.length,u,d;return c[dr],Lr(()=>{let e,t,p,ee,te,m,h,ne,re;if(l===0)o!==0&&(Oi(a),a=[],r=[],i=[],o=0,s&&=[]),n.fallback&&(r=[Di],i[0]=Tr(e=>(a[0]=e,n.fallback())),o=1);else if(o===0){for(i=Array(l),d=0;d<l;d++)r[d]=c[d],i[d]=Tr(f);o=l}else{for(p=Array(l),ee=Array(l),s&&(te=Array(l)),m=0,h=Math.min(o,l);m<h&&r[m]===c[m];m++);for(h=o-1,ne=l-1;h>=m&&ne>=m&&r[h]===c[ne];h--,ne--)p[ne]=i[h],ee[ne]=a[h],s&&(te[ne]=s[h]);for(e=new Map,t=Array(ne+1),d=ne;d>=m;d--)re=c[d],u=e.get(re),t[d]=u===void 0?-1:u,e.set(re,d);for(u=m;u<=h;u++)re=r[u],d=e.get(re),d!==void 0&&d!==-1?(p[d]=i[u],ee[d]=a[u],s&&(te[d]=s[u]),d=t[d],e.set(re,d)):a[u]();for(d=m;d<l;d++)d in p?(i[d]=p[d],a[d]=ee[d],s&&(s[d]=te[d],s[d](d))):i[d]=Tr(f);i=i.slice(0,o=l),r=c.slice(0)}return i});function f(e){if(a[d]=e,s){let[e,n]=Er(d);return s[d]=n,t(c[d],e)}return t(c[d])}}}function Ai(e,t,n={}){let r=[],i=[],a=[],o=[],s=0,c;return Br(()=>Oi(a)),()=>{let l=e()||[],u=l.length;return l[dr],Lr(()=>{if(u===0)return s!==0&&(Oi(a),a=[],r=[],i=[],s=0,o=[]),n.fallback&&(r=[Di],i[0]=Tr(e=>(a[0]=e,n.fallback())),s=1),i;for(r[0]===Di&&(a[0](),a=[],r=[],i=[],s=0),c=0;c<u;c++)c<r.length&&r[c]!==l[c]?o[c](()=>l[c]):c>=r.length&&(i[c]=Tr(d));for(;c<r.length;c++)a[c]();return s=o.length=a.length=u,r=l.slice(0),i=i.slice(0,s)});function d(e){a[c]=e;let[n,r]=Er(l[c]);return o[c]=r,t(n,c)}}}var ji=!1;function Mi(){ji=!0}function Ni(e,t){if(ji&&F.context){let n=F.context;or(sr());let r=Lr(()=>e(t||{}));return or(n),r}return Lr(()=>e(t||{}))}function Pi(){return!0}var Fi={get(e,t,n){return t===lr?n:e.get(t)},has(e,t){return t===lr||e.has(t)},set:Pi,deleteProperty:Pi,getOwnPropertyDescriptor(e,t){return{configurable:!0,enumerable:!0,get(){return e.get(t)},set:Pi,deleteProperty:Pi}},ownKeys(e){return e.keys()}};function Ii(e){return(e=typeof e==`function`?e():e)?e:{}}function Li(){for(let e=0,t=this.length;e<t;++e){let t=this[e]();if(t!==void 0)return t}}function Ri(...e){let t=!1;for(let n=0;n<e.length;n++){let r=e[n];t||=!!r&&lr in r,e[n]=typeof r==`function`?(t=!0,jr(r)):r}if(ur&&t)return new Proxy({get(t){for(let n=e.length-1;n>=0;n--){let r=Ii(e[n])[t];if(r!==void 0)return r}},has(t){for(let n=e.length-1;n>=0;n--)if(t in Ii(e[n]))return!0;return!1},keys(){let t=[];for(let n=0;n<e.length;n++)t.push(...Object.keys(Ii(e[n])));return[...new Set(t)]}},Fi);let n={},r=Object.create(null);for(let t=e.length-1;t>=0;t--){let i=e[t];if(!i)continue;let a=Object.getOwnPropertyNames(i);for(let e=a.length-1;e>=0;e--){let t=a[e];if(t===`__proto__`||t===`constructor`)continue;let o=Object.getOwnPropertyDescriptor(i,t);if(!r[t])r[t]=o.get?{enumerable:!0,configurable:!0,get:Li.bind(n[t]=[o.get.bind(i)])}:o.value===void 0?void 0:o;else{let e=n[t];e&&(o.get?e.push(o.get.bind(i)):o.value!==void 0&&e.push(()=>o.value))}}}let i={},a=Object.keys(r);for(let e=a.length-1;e>=0;e--){let t=a[e],n=r[t];n&&n.get?Object.defineProperty(i,t,n):i[t]=n?n.value:void 0}return i}function zi(e,...t){let n=t.length;if(ur&&lr in e){let r=n>1?t.flat():t[0],i=t.map(t=>new Proxy({get(n){return t.includes(n)?e[n]:void 0},has(n){return t.includes(n)&&n in e},keys(){return t.filter(t=>t in e)}},Fi));return i.push(new Proxy({get(t){return r.includes(t)?void 0:e[t]},has(t){return!r.includes(t)&&t in e},keys(){return Object.keys(e).filter(e=>!r.includes(e))}},Fi)),i}let r=[];for(let e=0;e<=n;e++)r[e]={};for(let i of Object.getOwnPropertyNames(e)){let a=n;for(let e=0;e<t.length;e++)if(t[e].includes(i)){a=e;break}let o=Object.getOwnPropertyDescriptor(e,i);!o.get&&!o.set&&o.enumerable&&o.writable&&o.configurable?r[a][i]=o.value:Object.defineProperty(r[a],i,o)}return r}function Bi(e){let t,n,r=r=>{let i=F.context;if(i){let[r,a]=Er();F.count||=0,F.count++,(n||=e()).then(e=>{!F.done&&or(i),F.count--,a(()=>e.default),or()}),t=r}else if(!t){let[r]=Nr(()=>(n||=e()).then(e=>e.default));t=r}let a;return jr(()=>(a=t())?Lr(()=>{if(!i||F.done)return a(r);let e=F.context;or(i);let t=a(r);return or(e),t}):``)};return r.preload=()=>n||((n=e()).then(e=>t=()=>e.default),n),r}var Vi=0;function Hi(){return F.context?F.getNextContextId():`cl-${Vi++}`}var Ui=e=>`Stale read from <${e}>.`;function Wi(e){let t=`fallback`in e&&{fallback:()=>e.fallback};return jr(ki(()=>e.each,e.children,t||void 0))}function Gi(e){let t=`fallback`in e&&{fallback:()=>e.fallback};return jr(Ai(()=>e.each,e.children,t||void 0))}function Ki(e){let t=e.keyed,n=jr(()=>e.when,void 0,void 0),r=t?n:jr(n,void 0,{equals:(e,t)=>!e==!t});return jr(()=>{let i=r();if(i){let a=e.children;return typeof a==`function`&&a.length>0?Lr(()=>a(t?i:()=>{if(!Lr(r))throw Ui(`Show`);return n()})):a}return e.fallback},void 0,void 0)}function qi(e){let t=$r(()=>e.children),n=jr(()=>{let e=t(),n=Array.isArray(e)?e:[e],r=()=>void 0;for(let e=0;e<n.length;e++){let t=e,i=n[e],a=r,o=jr(()=>a()?void 0:i.when,void 0,void 0),s=i.keyed?o:jr(o,void 0,{equals:(e,t)=>!e==!t});r=()=>a()||(s()?[t,o,i]:void 0)}return r});return jr(()=>{let t=n()();if(!t)return e.fallback;let[r,i,a]=t,o=a.children;return typeof o==`function`&&o.length>0?Lr(()=>o(a.keyed?i():()=>{if(Lr(n)()?.[0]!==r)throw Ui(`Match`);return i()})):o},void 0,void 0)}function Ji(e){return e}var Yi;function Xi(){Yi&&[...Yi].forEach(e=>e())}function Zi(e){let t;F.context&&F.load&&(t=F.load(F.getContextId()));let[n,r]=Er(t,void 0);return Yi||=new Set,Yi.add(r),Br(()=>Yi.delete(r)),jr(()=>{let t;if(t=n()){let n=e.fallback;return typeof n==`function`&&n.length?Lr(()=>n(t,()=>r())):n}return Vr(()=>e.children,r)},void 0,void 0)}var Qi=(e,t)=>e.showContent===t.showContent&&e.showFallback===t.showFallback,$i=Zr();function ea(e){let[t,n]=Er(()=>({inFallback:!1})),r,i=Qr($i),[a,o]=Er([]);i&&(r=i.register(jr(()=>t()().inFallback)));let s=jr(t=>{let n=e.revealOrder,i=e.tail,{showContent:o=!0,showFallback:s=!0}=r?r():{},c=a(),l=n===`backwards`;if(n===`together`){let e=c.every(e=>!e()),t=c.map(()=>({showContent:e&&o,showFallback:s}));return t.inFallback=!e,t}let u=!1,d=t.inFallback,f=[];for(let e=0,t=c.length;e<t;e++){let n=l?t-e-1:e,r=c[n]();if(!u&&!r)f[n]={showContent:o,showFallback:s};else{let e=!u;e&&(d=!0),f[n]={showContent:e,showFallback:!i||e&&i===`collapsed`?s:!1},u=!0}}return u||(d=!1),f.inFallback=d,f},{inFallback:!1});return n(()=>s),Ni($i.Provider,{value:{register:e=>{let t;return o(n=>(t=n.length,[...n,e])),jr(()=>s()[t],void 0,{equals:Qi})}},get children(){return e.children}})}function ta(e){let t=0,n,r,i,a,o,[s,c]=Er(!1),l=ti(),u={increment:()=>{++t===1&&c(!0)},decrement:()=>{--t===0&&c(!1)},inFallback:s,effects:[],resolved:!1},d=Ur();if(F.context&&F.load){let e=F.getContextId(),t=F.load(e);if(t&&(typeof t!=`object`||t.s!==1?i=t:F.gather(e)),i&&i!==`$$f`){let[t,n]=Er(void 0,{equals:!1});a=t,i.then(()=>{if(F.done)return n();F.gather(e),or(r),n(),or()},e=>{o=e,n()})}}let f=Qr($i);f&&(n=f.register(u.inFallback));let p;return Br(()=>p&&p()),Ni(l.Provider,{value:u,get children(){return jr(()=>{if(o)throw o;if(r=F.context,a){a(),a=void 0;return}r&&i===`$$f`&&or();let t=jr(()=>e.children);return jr(a=>{let o=u.inFallback(),{showContent:s=!0,showFallback:c=!0}=n?n():{};if((!o||i&&i!==`$$f`)&&s)return u.resolved=!0,p&&p(),p=r=i=void 0,Xr(u.effects),t();if(c)return p?a:Tr(t=>(p=t,r&&=(or({id:r.id+`F`,count:0}),void 0),e.fallback),d)})})}})}var na=e({$RAW:()=>ra,DEV:()=>void 0,createMutable:()=>Ta,createStore:()=>xa,modifyMutable:()=>Ea,produce:()=>Na,reconcile:()=>Aa,unwrap:()=>la}),ra=Symbol(`store-raw`),ia=Symbol(`store-node`),aa=Symbol(`store-has`),oa=Symbol(`store-self`);function sa(e){let t=e[lr];if(!t&&(Object.defineProperty(e,lr,{value:t=new Proxy(e,ha)}),!Array.isArray(e))){let n=Object.keys(e),r=Object.getOwnPropertyDescriptors(e),i=Object.getPrototypeOf(e),a=i!==null&&typeof e==`object`&&!!e&&!Array.isArray(e)&&i!==Object.prototype;if(a){let e=Object.getOwnPropertyDescriptors(i);n.push(...Object.keys(e)),Object.assign(r,e)}for(let i=0,o=n.length;i<o;i++){let o=n[i];a&&o===`constructor`||r[o].get&&Object.defineProperty(e,o,{configurable:!0,enumerable:r[o].enumerable,get:r[o].get.bind(t)})}}return t}function ca(e){let t;return typeof e==`object`&&!!e&&(e[lr]||!(t=Object.getPrototypeOf(e))||t===Object.prototype||Array.isArray(e))}function la(e,t=new Set){let n,r,i,a;if(n=e!=null&&e[ra])return n;if(!ca(e)||t.has(e))return e;if(Array.isArray(e)){Object.isFrozen(e)?e=e.slice(0):t.add(e);for(let n=0,a=e.length;n<a;n++)i=e[n],(r=la(i,t))!==i&&(e[n]=r)}else{Object.isFrozen(e)?e=Object.assign({},e):t.add(e);let n=Object.keys(e),o=Object.getOwnPropertyDescriptors(e);for(let s=0,c=n.length;s<c;s++)a=n[s],!o[a].get&&(i=e[a],(r=la(i,t))!==i&&(e[a]=r))}return e}function ua(e,t){let n=e[t];return n||Object.defineProperty(e,t,{value:n=Object.create(null)}),n}function da(e,t,n){if(e[t])return e[t];let[r,i]=Er(n,{equals:!1,internal:!0});return r.$=i,e[t]=r}function fa(e,t){let n=Reflect.getOwnPropertyDescriptor(e,t);return!n||n.get||!n.configurable||t===lr||t===ia?n:(delete n.value,delete n.writable,n.get=()=>e[lr][t],n)}function pa(e){Hr()&&da(ua(e,ia),oa)()}function ma(e){return pa(e),Reflect.ownKeys(e)}var ha={get(e,t,n){if(t===ra)return e;if(t===lr)return n;if(t===dr)return pa(e),n;let r=ua(e,ia),i=r[t],a=i?i():e[t];if(t===ia||t===aa||t===`__proto__`)return a;if(!i){let n=Object.getOwnPropertyDescriptor(e,t);Hr()&&(typeof a!=`function`||e.hasOwnProperty(t))&&!(n&&n.get)&&(a=da(r,t,a)())}return ca(a)?sa(a):a},has(e,t){return t===ra||t===lr||t===dr||t===ia||t===aa||t===`__proto__`||(Hr()&&da(ua(e,aa),t)(),t in e)},set(){return!0},deleteProperty(){return!0},ownKeys:ma,getOwnPropertyDescriptor:fa};function ga(e,t,n,r=!1){if(t===`__proto__`||!r&&e[t]===n)return;let i=e[t],a=e.length;n===void 0?(delete e[t],e[aa]&&e[aa][t]&&i!==void 0&&e[aa][t].$()):(e[t]=n,e[aa]&&e[aa][t]&&i===void 0&&e[aa][t].$());let o=ua(e,ia),s;if((s=da(o,t,i))&&s.$(()=>n),Array.isArray(e)&&e.length!==a){for(let t=e.length;t<a;t++)(s=o[t])&&s.$();(s=da(o,`length`,a))&&s.$(e.length)}(s=o[oa])&&s.$()}function _a(e,t){let n=Object.keys(t);for(let r=0;r<n.length;r+=1){let i=n[r];va(i)||ga(e,i,t[i])}}function va(e){return e===`__proto__`||e===`constructor`||e===`prototype`}function ya(e,t){if(typeof t==`function`&&(t=t(e)),t=la(t),Array.isArray(t)){if(e===t)return;let n=0,r=t.length;for(;n<r;n++){let r=t[n];e[n]!==r&&ga(e,n,r)}ga(e,`length`,r)}else _a(e,t)}function ba(e,t,n=[]){let r,i=e;if(t.length>1){r=t.shift();let a=typeof r,o=Array.isArray(e);if(a===`string`&&(r===`__proto__`||t.length>1&&va(r)))return;if(Array.isArray(r)){for(let i=0;i<r.length;i++)ba(e,[r[i]].concat(t),n);return}if(o&&a===`function`){for(let i=0;i<e.length;i++)r(e[i],i)&&ba(e,[i].concat(t),n);return}if(o&&a===`object`){let{from:i=0,to:a=e.length-1,by:o=1}=r;for(let r=i;r<=a;r+=o)ba(e,[r].concat(t),n);return}if(t.length>1){ba(e[r],t,[r].concat(n));return}i=e[r],n=[r].concat(n)}let a=t[0];typeof a==`function`&&(a=a(i,n),a===i)||(r!==void 0||a!=null)&&(a=la(a),r===void 0||ca(i)&&ca(a)&&!Array.isArray(a)?_a(i,a):ga(e,r,a))}function xa(...[e,t]){let n=la(e||{}),r=Array.isArray(n),i=sa(n);function a(...e){Ir(()=>{r&&e.length===1?ya(n,e[0]):ba(n,e)})}return[i,a]}function Sa(e,t){let n=Reflect.getOwnPropertyDescriptor(e,t);return!n||n.get||n.set||!n.configurable||t===lr||t===ia?n:(delete n.value,delete n.writable,n.get=()=>e[lr][t],n.set=n=>e[lr][t]=n,n)}var Ca={get(e,t,n){if(t===ra)return e;if(t===lr)return n;if(t===dr)return pa(e),n;let r=ua(e,ia),i=r[t],a=i?i():e[t];if(t===ia||t===aa||t===`__proto__`)return a;if(!i){let i=Object.getOwnPropertyDescriptor(e,t),o=typeof a==`function`;if(Hr()&&(!o||e.hasOwnProperty(t))&&!(i&&i.get))a=da(r,t,a)();else if(a!=null&&o&&a===Array.prototype[t])return(...e)=>Ir(()=>Array.prototype[t].apply(n,e))}return ca(a)?wa(a):a},has(e,t){return t===ra||t===lr||t===dr||t===ia||t===aa||t===`__proto__`||(Hr()&&da(ua(e,aa),t)(),t in e)},set(e,t,n){return Ir(()=>ga(e,t,la(n))),!0},deleteProperty(e,t){return Ir(()=>ga(e,t,void 0,!0)),!0},ownKeys:ma,getOwnPropertyDescriptor:Sa};function wa(e){let t=e[lr];if(!t){Object.defineProperty(e,lr,{value:t=new Proxy(e,Ca)});let n=Object.keys(e),r=Object.getOwnPropertyDescriptors(e),i=Object.getPrototypeOf(e),a=i!==null&&typeof e==`object`&&!!e&&!Array.isArray(e)&&i!==Object.prototype;if(a){let e=i;for(;e!=null;){let t=Object.getOwnPropertyDescriptors(e);n.push(...Object.keys(t)),Object.assign(r,t),e=Object.getPrototypeOf(e)}}for(let i=0,o=n.length;i<o;i++){let o=n[i];if(!(a&&o===`constructor`)){if(r[o].get){let n=r[o].get.bind(t);Object.defineProperty(e,o,{get:n,configurable:!0})}if(r[o].set){let n=r[o].set;Object.defineProperty(e,o,{set:e=>Ir(()=>n.call(t,e)),configurable:!0})}}}}return t}function Ta(e,t){return wa(la(e||{}))}function Ea(e,t){Ir(()=>t(la(e)))}var Da=Symbol(`store-root`);function Oa(e){return e===`__proto__`||e===`constructor`||e===`prototype`}function ka(e,t,n,r,i){if(Oa(n))return;let a=t[n];if(e===a)return;let o=Array.isArray(e);if(n!==Da&&(!ca(e)||!ca(a)||o!==Array.isArray(a)||i&&e[i]!==a[i])){ga(t,n,e);return}if(o){if(e.length&&a.length&&(!r||i&&e[0]&&e[0][i]!=null)){let t,n,o,s,c,l,u,d;for(o=0,s=Math.min(a.length,e.length);o<s&&(a[o]===e[o]||i&&a[o]&&e[o]&&a[o][i]&&a[o][i]===e[o][i]);o++)ka(e[o],a,o,r,i);let f=Array(e.length),p=new Map;for(s=a.length-1,c=e.length-1;s>=o&&c>=o&&(a[s]===e[c]||i&&a[s]&&e[c]&&a[s][i]&&a[s][i]===e[c][i]);s--,c--)f[c]=a[s];if(o>c||o>s){for(n=o;n<=c;n++)ga(a,n,e[n]);for(;n<e.length;n++)ga(a,n,f[n]),ka(e[n],a,n,r,i);a.length>e.length&&ga(a,`length`,e.length);return}for(u=Array(c+1),n=c;n>=o;n--)l=e[n],d=i&&l?l[i]:l,t=p.get(d),u[n]=t===void 0?-1:t,p.set(d,n);for(t=o;t<=s;t++)l=a[t],d=i&&l?l[i]:l,n=p.get(d),n!==void 0&&n!==-1&&(f[n]=a[t],n=u[n],p.set(d,n));for(n=o;n<e.length;n++)n in f?(ga(a,n,f[n]),ka(e[n],a,n,r,i)):ga(a,n,e[n])}else for(let t=0,n=e.length;t<n;t++)ka(e[t],a,t,r,i);a.length>e.length&&ga(a,`length`,e.length);return}let s=Object.keys(e);for(let t=0,n=s.length;t<n;t++)Oa(s[t])||ka(e[s[t]],a,s[t],r,i);let c=Object.keys(a);for(let t=0,n=c.length;t<n;t++)e[c[t]]===void 0&&ga(a,c[t],void 0)}function Aa(e,t={}){let{merge:n,key:r=`id`}=t,i=la(e);return e=>{if(!ca(e)||!ca(i))return i;let t=ka(i,{[Da]:e},Da,n,r);return t===void 0?e:t}}var ja=new WeakMap,Ma={get(e,t){if(t===ra)return e;let n=e[t];if(t===lr||t===dr||t===ia||t===aa||t===`__proto__`)return n;let r;return ca(n)?ja.get(n)||(ja.set(n,r=new Proxy(n,Ma)),r):n},set(e,t,n){return ga(e,t,la(n)),!0},deleteProperty(e,t){return ga(e,t,void 0,!0),!0}};function Na(e){return t=>{if(ca(t)){let n;(n=ja.get(t))||ja.set(t,n=new Proxy(t,Ma)),e(n)}return t}}var Pa=class extends t()(`ClientError`,{cause:le()}){},Fa=a.check(Nt(0)),z=a.check(Re(0)),Ia=x.pipe(M(`RelativePath`),O({identifier:`RelativePath`})),La=x.pipe(M(`AbsolutePath`),O({identifier:`AbsolutePath`})),B=e=>tt(e).pipe(wt(i(ue(e)),{decode:b({strict:!1}),encode:ce(Mt(e=>e!==void 0))})),Ra=(e,t)=>Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)),za=e=>t=>Ra(t,e(t)),Ba=P.pipe(wt(re,{decode:m(e=>ke(e)),encode:m(e=>Oe(e))})),Va=`0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz`,Ha=0,Ua=0;function Wa(){return Ka(!1)}function Ga(){return Ka(!0)}function Ka(e,t=Date.now()){t!==Ha&&(Ha=t,Ua=0),Ua++;let n=BigInt(t)*4096n+BigInt(Ua),r=e?~n:n,i=Array.from({length:6},(e,t)=>Number(r>>BigInt(40-8*t)&255n).toString(16).padStart(2,`0`)).join(``),a=crypto.getRandomValues(new Uint8Array(14));return i+Array.from(a,e=>Va[e%62]).join(``)}var qa=x.pipe(M(`Project.ID`),O({identifier:`Project.ID`}),za(e=>({global:e.make(`global`)}))),Ja=x.check(me(`wrk`)).pipe(M(`Workspace.ID`),O({identifier:`Workspace.ID`}),za(e=>{let t=()=>e.make(`wrk_`+Wa());return{ascending:n=>n?e.make(n):t(),create:t}})),Ya=e({Info:()=>Qa,Location:()=>Ya,PublicInfo:()=>$a,PublicRef:()=>Za,Ref:()=>Xa,response:()=>V}),Xa=C({directory:La,workspaceID:B(Ja)}).annotate({identifier:`Location.Ref`}),Za=C(o(Xa.fields,[`workspaceID`])).annotate({identifier:`Location.PublicRef`}),Qa=class extends p(`Location.Info`)({directory:La,workspaceID:B(Ja),project:C({id:qa,directory:La,canonical:La})}){},$a=C(o(Qa.fields,[`workspaceID`])).annotate({identifier:`Location.PublicInfo`});function V(e){return C({location:Za,data:e})}var eo=e({Event:()=>eo,ID:()=>to,Seq:()=>no,Version:()=>ro,durable:()=>H,durableMap:()=>so,ephemeral:()=>U,inventory:()=>W,latest:()=>ao,versionedType:()=>oo}),to=x.check(me(`evt_`)).pipe(M(`Event.ID`),O({identifier:`Event.ID`}),za(e=>({create:()=>e.make(`evt_`+Wa())}))),no=a.check(Re(0)).pipe(M(`Event.Seq`),O({identifier:`Event.Seq`})),ro=a.check(Re(1)).pipe(M(`Event.Version`),O({identifier:`Event.Version`})),io=C({aggregateID:x,seq:no,version:ro});function H(e){let t=C(e.schema),n=C({aggregateID:io.fields.aggregateID,seq:io.fields.seq,version:h(e.durable.version).pipe(wt(ue(ro),we({decode:()=>ro.make(e.durable.version),encode:()=>e.durable.version})))});return C({id:to,created:P,metadata:B(S(x,Ie)),type:h(e.type),durable:n,location:B(Xa),data:t}).annotate({identifier:e.identifier??e.type}).pipe(za(()=>({type:e.type,durability:`durable`,durable:e.durable,data:t})))}function U(e){let t=C(e.schema);return C({id:to,created:P,metadata:B(S(x,Ie)),type:h(e.type),location:B(Xa),data:t}).annotate({identifier:e.identifier??e.type}).pipe(za(()=>({type:e.type,durability:`ephemeral`,durable:void 0,data:t})))}function W(...e){return Object.freeze(e)}function ao(e){return co(e.reduce((e,t)=>{let n=e.get(t.type);if(!n)return e.set(t.type,t),e;if(t.durable&&n.durable&&t.durable.version!==n.durable.version)return t.durable.version>n.durable.version&&e.set(t.type,t),e;if(t!==n)throw Error(`Duplicate latest event definition for ${t.type}`);return e},new Map))}function oo(e,t){return`${e}.${t}`}function so(e){return co(e.reduce((e,t)=>{if(t.durability!==`durable`)return e;let n=oo(t.type,t.durable.version);if(e.has(n))throw Error(`Duplicate durable event definition for ${n}`);return e.set(n,t),e},new Map))}function co(e){let t=Object.freeze({get size(){return e.size},entries:()=>e.entries(),forEach:(n,r)=>e.forEach((e,i)=>n.call(r,e,i,t)),get:t=>e.get(t),has:t=>e.has(t),keys:()=>e.keys(),values:()=>e.values(),[Symbol.iterator]:()=>e[Symbol.iterator]()});return t}var lo=e({DirectorySource:()=>po,EmbeddedSource:()=>vo,Event:()=>_o,ID:()=>uo,Info:()=>ho,Name:()=>fo,Skill:()=>lo,Source:()=>yo,UrlSource:()=>mo}),uo=x.pipe(M(`Skill.ID`),O({identifier:`Skill.ID`})),fo=x.pipe(M(`Skill.Name`),O({identifier:`Skill.Name`})),po=C({type:_(`directory`),path:La}).annotate({identifier:`Skill.DirectorySource`}),mo=C({type:_(`url`),url:x}).annotate({identifier:`Skill.UrlSource`}),ho=C({id:uo,name:fo,description:x.pipe(B),autoinvoke:v.pipe(B),path:La,content:x}).annotate({identifier:`Skill.Info`}),go=U({type:`skill.updated`,schema:{}}),_o={Updated:go,Definitions:W(go)},vo=C({type:_(`embedded`),skill:fe(()=>ho)}).annotate({identifier:`Skill.EmbeddedSource`}),yo=Object.assign(E([po,mo,vo]).pipe(ie(`type`),O({identifier:`Skill.Source`})),{equals:(e,t)=>e.type===t.type?e.type===`directory`&&t.type===`directory`?e.path===t.path:e.type===`url`&&t.type===`url`?e.url===t.url:e.type===`embedded`&&t.type===`embedded`&&e.skill.id===t.skill.id:!1,key:e=>e.type===`directory`?`directory:${e.path}`:e.type===`url`?`url:${e.url}`:`embedded:${e.skill.id}`}),bo=class extends t()(`LocationNotFoundError`,{location:Za,message:x},{httpApiStatus:404}){},xo=class extends t()(`InvalidRequestError`,{message:x,kind:i(x),field:i(x)},{httpApiStatus:400}){},So=class extends t()(`RpcError`,{type:x,message:x,data:i(Ie)},{httpApiStatus:400}){},Co=class extends t()(`RpcInternalError`,{type:y([`rpc.internal`,`rpc.invalid_output`]),message:x,data:i(Ie)},{httpApiStatus:500}){},wo=class extends t()(`UnauthorizedError`,{message:x},{httpApiStatus:401}){},To=class extends t()(`ConflictError`,{message:x,resource:i(x)},{httpApiStatus:409}){},Eo=class extends t()(`SessionBusyError`,{sessionID:x,message:x},{httpApiStatus:409}){},Do=class extends t()(`ServiceUnavailableError`,{message:x,service:i(x)},{httpApiStatus:503}){},Oo=class extends t()(`UnknownError`,{message:x,ref:i(x)},{httpApiStatus:500}){},ko=class extends t()(`ProviderNotFoundError`,{providerID:x,message:x},{httpApiStatus:404}){},Ao=class extends t()(`IntegrationNotFoundError`,{integrationID:x,message:x},{httpApiStatus:404}){},jo=class extends t()(`IntegrationAttemptNotFoundError`,{integrationID:x,attemptID:x,message:x},{httpApiStatus:404}){},Mo=class extends t()(`IntegrationMethodNotFoundError`,{integrationID:x,methodID:x,message:x},{httpApiStatus:404}){},No=class extends t()(`ProjectNotFoundError`,{projectID:x,message:x},{httpApiStatus:404}){},Po=class extends t()(`FileNotFoundError`,{path:x,message:x},{httpApiStatus:404}){},Fo=class extends t()(`PluginNotFoundError`,{pluginID:x,message:x},{httpApiStatus:404}){},Io=class extends t()(`AgentNotFoundError`,{agentID:x,message:x},{httpApiStatus:404}){},G=class extends t()(`SessionNotFoundError`,{sessionID:x,message:x},{httpApiStatus:404}){},Lo=class extends t()(`MessageNotFoundError`,{sessionID:x,messageID:x,message:x},{httpApiStatus:404}){},Ro=class extends t()(`SkillNotFoundError`,{skill:uo,message:x},{httpApiStatus:404}){},zo=class extends t()(`McpServerNotFoundError`,{server:x,message:x},{httpApiStatus:404}){},Bo=class extends t()(`CommandNotFoundError`,{command:x,message:x},{httpApiStatus:404}){},Vo=class extends t()(`CommandExecutionError`,{command:x,message:x},{httpApiStatus:500}){},Ho=class extends t()(`InvalidCursorError`,{message:x},{httpApiStatus:400}){},Uo=class extends t()(`PermissionNotFoundError`,{requestID:x,message:x},{httpApiStatus:404}){},Wo=class extends t()(`PermissionSavedNotFoundError`,{id:x,message:x},{httpApiStatus:404}){},Go=class extends t()(`FormNotFoundError`,{id:x,message:x},{httpApiStatus:404}){},Ko=class extends t()(`FormAlreadySettledError`,{id:x,message:x},{httpApiStatus:409}){},qo=class extends t()(`FormInvalidAnswerError`,{id:x,message:x},{httpApiStatus:400}){},Jo=class extends t()(`ForbiddenError`,{message:x},{httpApiStatus:403}){},Yo=class extends t()(`PtyNotFoundError`,{ptyID:x,message:x},{httpApiStatus:404}){},Xo=class extends t()(`ShellNotFoundError`,{id:x,message:x},{httpApiStatus:404}){},Zo=class extends t()(`ModelNotFoundError`,{providerID:x,modelID:x,message:x},{httpApiStatus:404}){},Qo=class extends t()(`UnsupportedModelError`,{providerID:x,modelID:x,capability:x,message:x},{httpApiStatus:422}){},$o=class extends t()(`ProviderRequestError`,{providerID:x,reason:y([`authentication`,`rate_limit`,`content_filter`,`invalid_request`,`overloaded`,`provider`]),message:x,status:i(a),retryAfterMs:i(a)},{httpApiStatus:502}){},es=class extends Qe()(`@opencode/HttpApiSchemaError`,{error:xo}){},ts=x.pipe(M(`Integration.ID`),O({identifier:`Integration.ID`})),ns=x.pipe(M(`Integration.MethodID`),O({identifier:`Integration.MethodID`})),rs=e({CreateInput:()=>ps,Credential:()=>rs,Entry:()=>fs,Event:()=>ss,External:()=>us,ID:()=>is,Key:()=>ls,OAuth:()=>cs,Value:()=>ds}),is=x.pipe(M(`Credential.ID`),O({identifier:`Credential.ID`}),za(e=>({create:()=>e.make(`cred_`+Wa())}))),as=U({type:`credential.updated`,schema:{}}),os=U({type:`credential.switched`,schema:{integrationID:ts,credentialID:se(is)}}),ss={Updated:as,Switched:os,Definitions:W(as,os)},cs=C({type:h(`oauth`),methodID:ns,refresh:x,access:x,expires:z,metadata:B(S(x,Ie))}).annotate({identifier:`Credential.OAuth`}),ls=C({type:h(`key`),key:x,metadata:B(S(x,Ie))}).annotate({identifier:`Credential.Key`}),us=C({type:h(`external`),methodID:ns,metadata:B(S(x,Ie))}).annotate({identifier:`Credential.External`}),ds=E([cs,ls,us]).pipe(ie(`type`)).annotate({identifier:`Credential.Value`}),fs=C({id:is,integrationID:ts,label:x,active:v,value:ds}).annotate({identifier:`Credential.Entry`}),ps=C({id:B(is),integrationID:ts,label:B(x),value:ds,activate:B(v)}).annotate({identifier:`Credential.CreateInput`}),ms=C({status:y([`needs_auth`]),message:x,url:B(x)}).annotate({identifier:`Connection.Status`}),hs=C({type:h(`credential`),id:is,label:x,method:y([`key`,`oauth`,`external`]),status:B(ms)}).annotate({identifier:`Connection.CredentialInfo`}),gs=C({type:h(`env`),name:x,status:B(ms)}).annotate({identifier:`Connection.EnvInfo`}),_s=E([hs,gs]).pipe(ie(`type`)).annotate({identifier:`Connection.Info`}),vs=e({Answer:()=>Fs,BooleanField:()=>Ds,Detail:()=>Ls,Event:()=>Hs,ExternalField:()=>ks,Field:()=>As,Fields:()=>js,Form:()=>vs,ID:()=>ys,Info:()=>Ns,IntegerField:()=>Es,Metadata:()=>bs,MultiselectField:()=>Os,NumberField:()=>Ts,Option:()=>xs,Reply:()=>Rs,State:()=>Is,StringField:()=>ws,Value:()=>Ps,When:()=>Ss}),ys=x.check(me(`frm_`)).pipe(M(`Form.ID`),O({identifier:`Form.ID`})).pipe(za(e=>({create:t=>e.make(t??`frm_`+Wa())}))),bs=S(x,Ie).annotate({identifier:`Form.Metadata`}),xs=C({value:x,label:x,description:x.pipe(B)}).annotate({identifier:`Form.Option`}),Ss=C({key:x,op:y([`eq`,`neq`]),value:E([x,gt,v])}).annotate({identifier:`Form.When`}),Cs={key:x,title:x.pipe(B),description:x.pipe(B),required:v.pipe(B),hidden:v.pipe(B).annotate({description:`Skip the interactive authentication prompt and use the default unless an answer is supplied`}),when:g(Ss).pipe(B)},ws=C({...Cs,type:h(`string`),format:y([`email`,`uri`,`date`,`date-time`]).pipe(B),minLength:z.pipe(B),maxLength:z.pipe(B),pattern:x.pipe(B),placeholder:x.pipe(B),default:x.pipe(B),options:g(xs).pipe(B),custom:v.pipe(B)}).annotate({identifier:`Form.StringField`}),Ts=C({...Cs,type:h(`number`),minimum:gt.pipe(B),maximum:gt.pipe(B),default:gt.pipe(B)}).annotate({identifier:`Form.NumberField`}),Es=C({...Cs,type:h(`integer`),minimum:gt.pipe(B),maximum:gt.pipe(B),default:gt.pipe(B)}).annotate({identifier:`Form.IntegerField`}),Ds=C({...Cs,type:h(`boolean`),default:v.pipe(B)}).annotate({identifier:`Form.BooleanField`}),Os=C({...Cs,type:h(`multiselect`),options:g(xs),minItems:z.pipe(B),maxItems:z.pipe(B),custom:v.pipe(B),default:g(x).pipe(B)}).annotate({identifier:`Form.MultiselectField`}),ks=C({key:x,type:h(`external`),url:x,title:x.pipe(B),description:x.pipe(B)}).annotate({identifier:`Form.ExternalField`}),As=E([ws,Ts,Es,Ds,Os,ks]).pipe(ie(`type`),O({identifier:`Form.Field`})),js=De(As).annotate({identifier:`Form.Fields`}),Ms={id:ys,sessionID:x,title:x,metadata:bs.pipe(B)},Ns=C({...Ms,fields:js}).annotate({identifier:`Form.Info`}),Ps=E([x,gt,v,g(x)]).annotate({identifier:`Form.Value`}),Fs=S(x,Ps).annotate({identifier:`Form.Answer`}),Is=E([C({status:h(`pending`)}),C({status:h(`answered`),answer:Fs}),C({status:h(`cancelled`),message:x.pipe(B)})]).pipe(ie(`status`)).annotate({identifier:`Form.State`}),Ls=C({...Ns.fields,state:Is}).annotate({identifier:`Form.Detail`}),Rs=C({answer:Fs}).annotate({identifier:`Form.Reply`}),zs=U({type:`form.created`,schema:{form:Ns}}),Bs=U({type:`form.replied`,schema:{id:ys,sessionID:x,answer:Fs}}),Vs=U({type:`form.cancelled`,schema:{id:ys,sessionID:x}}),Hs={Created:zs,Replied:Bs,Cancelled:Vs,Definitions:W(zs,Bs,Vs)},Us=e({Attempt:()=>ic,AttemptID:()=>nc,AttemptStatus:()=>ac,CommandAttempt:()=>oc,CommandAttemptStatus:()=>sc,CommandMethod:()=>qs,EnvMethod:()=>Xs,Event:()=>$s,ExternalMethod:()=>Ys,ID:()=>Ws,Info:()=>tc,Integration:()=>Us,KeyMethod:()=>Js,Method:()=>Zs,MethodID:()=>Gs,OAuthMethod:()=>Ks,Ref:()=>ec}),Ws=ts,Gs=ns,Ks=C({id:Gs,type:h(`oauth`),label:x,form:B(js)}).annotate({identifier:`Integration.OAuthMethod`}),qs=C({id:Gs,type:h(`command`),label:x,command:g(x)}).annotate({identifier:`Integration.CommandMethod`}),Js=C({type:h(`key`),label:B(x),form:B(js)}).annotate({identifier:`Integration.KeyMethod`}),Ys=C({id:Gs,type:h(`external`),label:x,form:B(js)}).annotate({identifier:`Integration.ExternalMethod`}),Xs=C({type:h(`env`),names:g(x)}).annotate({identifier:`Integration.EnvMethod`}),Zs=E([Ks,qs,Js,Ys,Xs]).pipe(ie(`type`)).annotate({identifier:`Integration.Method`}),Qs=U({type:`integration.updated`,schema:{}}),$s={Updated:Qs,Definitions:W(Qs)},ec=C({id:Ws,name:x,metadata:B(S(x,et))}).annotate({identifier:`Integration.Ref`}),tc=C({id:Ws,name:x,metadata:B(S(x,et)),methods:g(Zs),connections:g(_s)}).annotate({identifier:`Integration.Info`}),nc=x.pipe(M(`Integration.AttemptID`),O({identifier:`Integration.AttemptID`}),za(e=>({create:()=>e.make(`con_`+Wa())}))),rc=C({created:gt,expires:gt}),ic=class extends p(`Integration.Attempt`)({attemptID:nc,url:x,instructions:x,mode:y([`auto`,`code`]),time:rc}){},ac=E([C({status:h(`pending`),time:rc}),C({status:h(`complete`),time:rc}),C({status:h(`failed`),message:x,time:rc}),C({status:h(`expired`),time:rc})]).pipe(ie(`status`)).annotate({identifier:`Integration.AttemptStatus`}),oc=C({attemptID:nc,time:rc}).annotate({identifier:`Integration.CommandAttempt`}),sc=E([C({status:h(`pending`),message:B(x),time:rc}),C({status:h(`complete`),time:rc}),C({status:h(`failed`),message:x,time:rc}),C({status:h(`expired`),time:rc})]).pipe(ie(`status`)).annotate({identifier:`Integration.CommandAttemptStatus`}),cc=E([y([`reasoning`,`reasoning_content`,`reasoning_text`]),x]).annotate({identifier:`Model.ReasoningField`}),lc=y([`max_completion_tokens`,`max_tokens`]).annotate({identifier:`Model.MaxTokensField`}),uc=y([`assets`,`state`,`root`]).annotate({identifier:`Model.MediaInput`}),dc=y([`anthropic`,`alibaba`]).annotate({identifier:`Model.CacheFormat`}),fc=C({reasoningField:cc.pipe(B),requireReasoning:v.pipe(B),maxTokensField:lc.pipe(B),requireFinishReason:v.pipe(B),requireAssistantAfterTool:v.pipe(B),supportsPromptCacheKey:v.pipe(B),streamUsage:v.pipe(B),cacheFormat:dc.pipe(B),supportsThinkingBlockBinding:v.pipe(B),supportsEffortUpdates:v.pipe(B),mediaInput:uc.pipe(B)}).annotate({identifier:`Model.Compatibility`}),pc=C(o(fc.fields,[`supportsThinkingBlockBinding`,`supportsEffortUpdates`])).annotate({identifier:`Provider.Compatibility`}),mc=e({Activation:()=>yc,Cache:()=>Cc,CacheTTL:()=>Sc,Compaction:()=>bc,Encoding:()=>wc,Event:()=>_c,ID:()=>hc,Info:()=>kc,Overlays:()=>Dc,Package:()=>vc,Provider:()=>mc,Request:()=>Oc,Settings:()=>Ec,Transport:()=>xc}),hc=x.pipe(M(`Provider.ID`),O({identifier:`Provider.ID`}),za(e=>({opencode:e.make(`opencode`),anthropic:e.make(`anthropic`),openai:e.make(`openai`),google:e.make(`google`),googleVertex:e.make(`google-vertex`),githubCopilot:e.make(`github-copilot`),amazonBedrock:e.make(`amazon-bedrock`),azure:e.make(`azure`),openrouter:e.make(`openrouter`),mistral:e.make(`mistral`),gitlab:e.make(`gitlab`)}))),gc=U({type:`provider.updated`,schema:{}}),_c={Updated:gc,Definitions:W(gc)},vc=x,yc=y([`auto`,`enabled`,`disabled`]),bc=E([C({type:h(`summary`)}),C({type:h(`native`)})]).pipe(ie(`type`)).annotate({identifier:`Provider.Compaction`}),xc=y([`http`,`websocket`]).annotate({identifier:`Provider.Transport`}),Sc=We([gt,y([`ms`,`s`,`m`,`h`,`d`])]).check(Ce(/^\d+(ms|s|m|h|d)$/)).annotate({identifier:`Provider.CacheTTL`}),Cc=C({ttl:Sc.pipe(B)}).annotate({identifier:`Provider.Cache`}),wc=y([`zstd`,`gzip`,`none`]).annotate({identifier:`Provider.Encoding`}),Tc=E([P,h(!1)]).pipe(B),Ec=ge(C({timeout:Tc,headerTimeout:Tc,chunkTimeout:Tc,compaction:bc.pipe(B),cache:Cc.pipe(B),transport:xc.pipe(B),encoding:wc.pipe(B)}),[S(x,et)]).annotate({identifier:`Provider.Settings`}),Dc={settings:Ec.pipe(B),headers:S(x,x).pipe(B),body:S(x,et).pipe(B)},Oc=C({settings:Ec.pipe(ye(Ve({}))),headers:S(x,x),body:S(x,et)}).annotate({identifier:`Provider.Request`}),kc=C({id:hc,canonical:hc.pipe(B),integrationID:Ws.pipe(B),name:x,activation:yc,package:vc,compatibility:pc.pipe(B),...Dc}).annotate({identifier:`Provider.Info`}).pipe(za(()=>({empty:e=>({id:e,name:e,activation:`auto`,package:``})}))),Ac=P.pipe(M(`Money.USD`),O({identifier:`Money.USD`}),za(e=>({zero:e.make(0)}))),jc=P.pipe(M(`Money.USDPerMillionTokens`),O({identifier:`Money.USDPerMillionTokens`}),za(e=>({zero:e.make(0)}))),Mc=e({Capabilities:()=>Hc,Compatibility:()=>fc,Cost:()=>Uc,Event:()=>Fc,Family:()=>Rc,ID:()=>Nc,Info:()=>Gc,MaxTokensField:()=>lc,MediaInput:()=>uc,Model:()=>Mc,Overlays:()=>Vc,ReasoningField:()=>cc,Ref:()=>Lc,Settings:()=>Bc,Type:()=>zc,Variant:()=>Wc,VariantID:()=>Ic}),Nc=x.pipe(M(`Model.ID`)),Pc=U({type:`model.updated`,schema:{}}),Fc={Updated:Pc,Definitions:W(Pc)},Ic=x.pipe(M(`Model.VariantID`)),Lc=C({id:Nc,providerID:hc,variant:Ic.pipe(B)}).annotate({identifier:`Model.Ref`}).pipe(za(e=>({parse:t=>{let n=t.indexOf(`/`);if(n<=0)throw Error(`Invalid model reference: ${t}`);let r=t.slice(0,n),i=t.indexOf(`#`,n+1),a=t.slice(n+1,i===-1?void 0:i),o=i===-1?void 0:t.slice(i+1);if(!a||r.includes(`#`)||o!==void 0&&(!o||o.includes(`#`)))throw Error(`Invalid model reference: ${t}`);return e.make({providerID:hc.make(r),id:Nc.make(a),...o?{variant:Ic.make(o)}:{}})}}))),Rc=x.pipe(M(`Model.Family`)),zc=E([y([`chat`,`decision`,`image`]),x]).annotate({identifier:`Model.Type`}),Bc=ge(C(Ee(Ec.schema.fields,[`compaction`,`cache`,`encoding`])),[S(x,et)]).annotate({identifier:`Model.Settings`}),Vc={settings:Bc.pipe(B),headers:S(x,x).pipe(B),body:S(x,et).pipe(B)},Hc=C({tools:v,input:g(x),output:g(x),temperature:v.pipe(B)}).annotate({identifier:`Model.Capabilities`}).pipe(za(()=>({default:()=>({tools:!0,input:[`text`,`image`],output:[`text`]})}))),Uc=C({tier:C({type:_(`context`),size:a}).pipe(B),input:jc,output:jc,cache:C({read:jc,write:jc})}).annotate({identifier:`Model.Cost`}),Wc=C({id:Ic,...Vc}).annotate({identifier:`Model.Variant`}),Gc=C({id:Nc,modelID:Nc,providerID:hc,canonical:hc.pipe(B),type:zc.pipe(B),family:Rc.pipe(B),name:x,compatibility:fc.pipe(B),package:vc.pipe(B),...Vc,capabilities:Hc,variants:g(Wc),time:C({released:P}),cost:g(Uc),status:y([`alpha`,`beta`,`deprecated`,`active`]),enabled:v,limit:C({context:a,input:a.pipe(B),output:a})}).annotate({identifier:`Model.Info`}).pipe(za(()=>({default:(e,t)=>({id:t,modelID:t,providerID:e,name:t,capabilities:Hc.default(),variants:[],time:{released:0},cost:[],status:`active`,enabled:!0,limit:{context:2e5,output:32e3}})}))),Kc=C({start:P,end:P,text:x}).annotate({identifier:`Prompt.Mention`}),qc=E([C({type:h(`inline`)}),C({type:h(`uri`),uri:x})]).pipe(ie(`type`)).annotate({identifier:`Prompt.FileSource`}),Jc=x.check(rt(e=>e.length%4==0&&/^[A-Za-z0-9+/]*={0,2}$/u.test(e),Ce(/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/u).annotations)).annotate({identifier:`Prompt.Base64`}),Yc=C({data:Jc,mime:x,source:qc,name:x.pipe(B),description:x.pipe(B),mention:Kc.pipe(B)}).annotate({identifier:`Prompt.FileAttachment`}).pipe(za(e=>({create:t=>e.make({data:t.data,mime:t.mime,source:t.source,name:t.name,description:t.description,mention:t.mention})}))),Xc=x.check(Ce(/^media:[0-9a-f]{64}$/)).annotate({identifier:`Prompt.MediaRef`}),{data:Zc,...Qc}=Yc.fields,$c=C({...Qc,uri:Xc,bytes:a.pipe(B),width:a.pipe(B),height:a.pipe(B)}).annotate({identifier:`Prompt.MediaFileAttachment`}),el=E([Yc,$c]).annotate({identifier:`Prompt.Attachment`}),tl=C({name:x,mention:Kc.pipe(B)}).annotate({identifier:`Prompt.AgentAttachment`}),nl=C({id:uo,name:fo,text:x.pipe(B),mention:Kc.pipe(B)}).annotate({identifier:`Prompt.SkillAttachment`}),rl=C({text:x,files:g(Yc).pipe(B),agents:g(tl).pipe(B),skills:g(nl).pipe(B)}).annotate({identifier:`Prompt`}).pipe(za(e=>({equivalence:ee(e),fromUserMessage:t=>e.make({text:t.text,...t.files===void 0?{}:{files:t.files},...t.agents===void 0?{}:{agents:t.agents},...t.skills===void 0?{}:{skills:t.skills}})}))),il=e=>({description:e}),al=C({data:Jc,mime:x,name:x.pipe(B)}).annotate({identifier:`Generate.File`}),ol=C({input:P.pipe(B),output:P.pipe(B)}).annotate({identifier:`Generate.Usage`,description:`Token counts, when the provider reports them`}),sl=S(x,Ie).annotate({identifier:`Generate.Native`,description:`Provider-specific data the shared fields do not cover`}),cl=We([gt,`:`,gt]).check(Ce(/^\d+(?:\.\d+)?:\d+(?:\.\d+)?$/)).annotate({identifier:`Generate.ImageAspect`,description:`Aspect ratio as width:height, for example 16:9`}),ll=E([y([`1K`,`2K`,`4K`]),x]).annotate({identifier:`Generate.ImageResolution`,description:`Size tier such as 1K, 2K or 4K; 1K is about as many pixels as 1024x1024 at the requested aspect`}),ul=C({model:Lc,prompt:x,images:g(al).pipe(B).annotate(il(`Edit sources or style and subject references, in order`)),n:Fa.pipe(B).annotate(il(`Number of images to generate; defaults to 1`)),aspect:cl.pipe(B),resolution:ll.pipe(B)}).annotate({identifier:`Generate.ImageRequest`}),dl=C({type:h(`image`),...al.fields}).annotate({identifier:`Generate.ImageOutput`}),fl=C({images:g(dl),cost:Ac.pipe(B),tokens:ol.pipe(B),native:sl.pipe(B)}).annotate({identifier:`Generate.ImageResult`}),pl=C({type:h(`text`),text:x}).annotate({identifier:`Generate.DecisionTextPart`}),ml=C({type:h(`json`),value:Te}).annotate({identifier:`Generate.DecisionJsonPart`}),hl=C({type:h(`file`),...al.fields}).annotate({identifier:`Generate.DecisionFilePart`}),gl=E([pl,ml,hl]).annotate({identifier:`Generate.DecisionPart`}),_l=E([x,v]).annotate({identifier:`Generate.ChoiceValue`,description:`Choice values are typed: true and "true" are different values`}),vl=x.annotate(il(`Unique within the request; echoed on the matching answer`)),yl=C({type:h(`predicate`),name:vl,instructions:x}).annotate({identifier:`Generate.PredicateQuestion`,description:`The probability that a statement is true`}),bl=C({type:h(`choice`),name:vl,instructions:x,choices:g(C({value:_l,description:x.pipe(B)})).check(c(1))}).annotate({identifier:`Generate.ChoiceQuestion`,description:`Pick one value from a fixed set`}),xl=C({type:h(`score`),name:vl,instructions:x,levels:g(C({label:x,description:x.pipe(B)})).check(c(1))}).annotate({identifier:`Generate.ScoreQuestion`,description:`Place the input on ordered levels, lowest first`}),Sl=E([yl,bl,xl]).annotate({identifier:`Generate.DecisionQuestion`}),Cl=C({model:Lc,input:g(gl).annotate(il(`The evidence every question is asked about, in order`)),questions:g(Sl).check(c(1)).annotate(il(`Question names must be unique; duplicates fail with InvalidRequestError`))}).annotate({identifier:`Generate.DecisionRequest`}),wl=P.check(Dt({minimum:0,maximum:1})),Tl=C({type:h(`predicate`),name:x,probability:wl}).annotate({identifier:`Generate.PredicateAnswer`}),El=C({type:h(`choice`),name:x,choice:_l,probabilities:g(C({value:_l,probability:wl})),confidence:wl}).annotate({identifier:`Generate.ChoiceAnswer`}),Dl=C({type:h(`score`),name:x,score:P.annotate(il(`Probability-weighted level index, so it can fall between levels`)),probabilities:g(C({value:a,label:x,probability:wl})),confidence:wl}).annotate({identifier:`Generate.ScoreAnswer`}),Ol=C({type:h(`error`),name:x,reason:x.annotate(il(`Why the question has no answer, for example refusal`)),message:x.pipe(B)}).annotate({identifier:`Generate.ErrorAnswer`,description:`This one question has no answer; the other answers still came back`}),kl=E([Tl,El,Dl,Ol]).annotate({identifier:`Generate.DecisionAnswer`}),Al=C({answers:g(kl).annotate(il(`One answer per question, in question order`)),cost:Ac.pipe(B),tokens:ol.pipe(B),native:sl.pipe(B)}).annotate({identifier:`Generate.DecisionResult`}),jl=[xo,ko,Zo,Qo,$o,Do,bo],Ml={payload:C({prompt:x,model:Lc.pipe(i)}),success:C({data:C({text:x})}).annotate({identifier:`GenerateTextResponse`}),error:jl},Nl=N(`server.generate`).add(D(`generate.text`,`/api/experimental/generate/text`,Ml).annotateMerge(k({identifier:`experimental.generate.text`,summary:`Generate text`,description:`Run one stateless model generation using the server's base configuration and return the assistant text. Uses the base configuration's default model when none is specified.`}))).add(D(`generate.textLegacy`,`/api/experimental/generate`,Ml).annotateMerge(k({identifier:`experimental.generate.textLegacy`,summary:`Generate text (deprecated path)`,description:`Deprecated alias of POST /api/experimental/generate/text.`,deprecated:!0}))).add(D(`generate.image`,`/api/experimental/generate/image`,{payload:ul,success:C({data:fl}).annotate({identifier:`GenerateImageResponse`}),error:jl}).annotateMerge(k({identifier:`experimental.generate.image`,summary:`Generate images`,description:`Generate or edit images with an image model using the server's base configuration and return them as base64. Stateless: nothing is stored.`}))).add(D(`generate.decisions`,`/api/experimental/generate/decisions`,{payload:Cl,success:C({data:Al}).annotate({identifier:`GenerateDecisionsResponse`}),error:jl}).annotateMerge(k({identifier:`experimental.generate.decisions`,summary:`Generate decisions`,description:`Ask a decision model typed predicate, choice and score questions about the input and return one probability-bearing answer per question, in question order. Stateless: nothing is stored.`}))).annotateMerge(k({title:`generate`,description:`Experimental one-shot generation routes.`})),Pl=x.check(Ce(/^[0-9a-f]{64}$/u)).annotate({identifier:`MediaHash`}),Fl=A(`media.get`,`/api/experimental/media/:hash`,{params:{hash:Pl},success:dt.pipe(mt()),error:[Po,xo]}).annotateMerge(k({identifier:`experimental.media.get`,summary:`Read media blob`,description:`Read a content-addressed media blob by SHA-256 hash with immutable Cache-Control, ETag, and 304 Not Modified support. Only blobs a stored message or inbox item still references are served. Experimental: may change without compatibility guarantees.`,transform:e=>({...e,tags:[`experimental`]})})),Il=e({CreateInput:()=>Wl,Event:()=>Ul,ID:()=>Ll,Info:()=>Rl,Pty:()=>Il,UpdateInput:()=>Gl}),Ll=x.check(me(`pty`)).pipe(M(`PtyID`),O({identifier:`Pty.ID`})).pipe(za(e=>{let t=()=>e.make(`pty_`+Wa());return{create:t,ascending:n=>n===void 0?t():e.make(n)}})),Rl=C({id:Ll,title:x,command:x,args:g(x),cwd:x,status:y([`running`,`exited`]),pid:z,exitCode:B(z)}).annotate({identifier:`Pty`}),zl=U({type:`pty.created`,schema:{info:Rl}}),Bl=U({type:`pty.updated`,schema:{info:Rl}}),Vl=U({type:`pty.exited`,schema:{id:Ll,exitCode:z}}),Hl=U({type:`pty.deleted`,schema:{id:Ll}}),Ul={Created:zl,Updated:Bl,Exited:Vl,Deleted:Hl,Definitions:W(zl,Bl,Vl,Hl)},Wl=C({command:B(x),args:B(g(x)),cwd:B(x),title:B(x),env:B(S(x,x))}),Gl=C({title:B(x),size:B(C({rows:Fa,cols:Fa}))}),Kl=x.check(me(`ses`)).pipe(M(`SessionID`),O({identifier:`Session.ID`}),za(e=>({create:()=>e.make(`ses_`+Ga())}))),ql=e({Effect:()=>nu,Event:()=>tu,ID:()=>Jl,Permission:()=>ql,Reply:()=>Ql,Request:()=>Zl,Rule:()=>ru,Ruleset:()=>iu,Source:()=>Yl}),Jl=x.check(me(`per`)).pipe(M(`Permission.ID`),O({identifier:`Permission.ID`}),za(e=>({create:t=>e.make(t??`per_`+Wa())}))),Yl=E([C({type:h(`tool`),messageID:x,id:x})]).annotate({identifier:`Permission.Source`}),Xl={sessionID:Kl,action:x,resources:g(x),save:g(x).pipe(B),metadata:S(x,Ie).pipe(B),source:Yl.pipe(B),message:x.pipe(B)},Zl=C({id:Jl,...Xl}).annotate({identifier:`Permission.Request`}),Ql=y([`once`,`always`,`reject`]).annotate({identifier:`Permission.Reply`}),$l=U({type:`permission.asked`,schema:Zl.fields}),eu=U({type:`permission.replied`,schema:{sessionID:Kl,requestID:Jl,reply:Ql}}),tu={Asked:$l,Replied:eu,Definitions:W($l,eu)},nu=y([`allow`,`deny`,`ask`]).annotate({identifier:`Permission.Effect`}),ru=C({action:x,resource:x,effect:nu}).annotate({identifier:`Permission.Rule`}),iu=g(ru).annotate({identifier:`Permission.Ruleset`}),au=e({Agent:()=>au,Color:()=>lu,Event:()=>du,ID:()=>su,Info:()=>uu,Name:()=>cu}),ou=U({type:`agent.updated`,schema:{}}),su=x.pipe(M(`Agent.ID`),O({identifier:`Agent.ID`})),cu=x.pipe(M(`Agent.Name`)),lu=x.annotate({identifier:`Agent.Color`}),uu=C({id:su,name:cu,model:Lc.pipe(B),request:Oc,system:x.pipe(B),description:x.pipe(B),mode:y([`subagent`,`primary`,`all`]),hidden:v,color:lu.pipe(B),steps:Fa.pipe(B),permissions:iu}).annotate({identifier:`Agent.Info`}).pipe(za(()=>({default:e=>({id:e,name:cu.make(e),request:{settings:{},headers:{},body:{}},mode:`primary`,hidden:!1,permissions:[{action:`*`,resource:`*`,effect:`allow`},{action:`read`,resource:`*.env`,effect:`ask`},{action:`read`,resource:`*.env.*`,effect:`ask`},{action:`read`,resource:`*.env.example`,effect:`allow`}]})}))),du={Updated:ou,Definitions:W(ou)},fu=e({Commands:()=>_u,Current:()=>hu,Event:()=>Su,ID:()=>pu,Icon:()=>gu,Info:()=>yu,Project:()=>fu,Time:()=>vu,UpdateInput:()=>bu,Vcs:()=>mu}),pu=qa,mu=x.check(Ce(/^[a-z][a-z0-9._-]*$/u)).annotate({identifier:`Project.Vcs`}),hu=C({id:pu,directory:La,canonical:La}).annotate({identifier:`Project.Current`}),gu=C({url:B(x),override:B(x),color:B(x)}).annotate({identifier:`Project.Icon`}),_u=C({start:B(x.annotate({description:`Startup script to run when creating a new workspace (worktree)`}))}).annotate({identifier:`Project.Commands`}),vu=C({created:z,updated:z,active:z,archived:B(z)}).annotate({identifier:`Project.Time`}),yu=C({id:pu,canonical:La,vcs:B(mu),name:B(x),icon:B(gu),commands:B(_u),time:vu,sandboxes:g(x)}).annotate({identifier:`Project`}),bu=C({projectID:pu,canonical:B(La),name:B(x),icon:B(gu),commands:B(_u)}).annotate({identifier:`Project.UpdateInput`}),xu=U({type:`project.updated`,schema:yu.fields}),Su={Updated:xu,Definitions:W(xu)},Cu=y([`stop`,`length`,`tool-calls`,`content-filter`,`error`,`unknown`]);x.pipe(M(`Tool.CallID`)),t()(`Tool.Error`,{message:x,error:i(le()),metadata:i(S(x,Ie))});var wu=C({type:h(`text`),text:x}).annotate({identifier:`Tool.TextContent`}),Tu=C({type:h(`file`),uri:x,mime:x,name:i(x)}).annotate({identifier:`Tool.FileContent`}),Eu=E([wu,Tu]).pipe(ie(`type`)).annotate({identifier:`Tool.Content`}),Du=S(x,Te).annotate({identifier:`Session.Metadata`}),Ou=x.check(me(`sh_`)).pipe(M(`Shell.ID`),O({identifier:`Shell.ID`})).pipe(za(e=>{let t=()=>e.make(`sh_`+Wa());return{create:t,ascending:n=>n===void 0?t():e.make(n)}})),ku=y([`running`,`exited`,`timeout`,`killed`]),Au=C({started:P.annotate({description:`Start time in milliseconds since the Unix epoch`}),completed:B(P).annotate({description:`Completion time in milliseconds since the Unix epoch`})}),ju=S(x,Ie),Mu=C({id:Ou,status:ku,command:x,cwd:x,shell:x,file:x,pid:B(z),exit:B(P),signal:B(x),metadata:ju,time:Au}).annotate({identifier:`Shell.Info`}),Nu=U({type:`shell.created`,schema:{info:Mu}}),Pu=U({type:`shell.exited`,schema:{id:Ou,exit:B(P),status:ku}}),Fu=U({type:`shell.deleted`,schema:{id:Ou}}),Iu={Created:Nu,Exited:Pu,Deleted:Fu,Definitions:W(Nu,Pu,Fu)},Lu=C({command:x,cwd:B(x),timeout:B(z),metadata:B(ju)}),Ru=C({cursor:B(z),limit:B(z)}),zu=C({output:x,cursor:z,size:z,truncated:v}),Bu=C({type:x,message:x,status:a.check(Dt({minimum:100,maximum:599})).pipe(B),response:C({body:x}).pipe(B),retryAfterMs:z.pipe(B)}).annotate({identifier:`Session.StructuredError`}),Vu=x.pipe(M(`Snapshot.ID`),O({identifier:`Snapshot.ID`})),Hu=C({input:P,output:P,reasoning:P,cache:C({read:P,write:P})}).annotate({identifier:`TokenUsage.Info`}),Uu=e({AgentSelected:()=>Ku,Assistant:()=>fd,AssistantContent:()=>ld,AssistantContentEncoded:()=>ud,AssistantReasoning:()=>cd,AssistantRetry:()=>dd,AssistantText:()=>sd,AssistantTool:()=>od,Compaction:()=>vd,CompactionCompleted:()=>gd,CompactionFailed:()=>_d,CompactionRunning:()=>hd,ID:()=>K,Idle:()=>yd,Info:()=>bd,LocationSwitched:()=>Ju,MediaInfo:()=>xd,MediaUser:()=>Xu,ModelSelected:()=>qu,Native:()=>Gu,SessionMessage:()=>Uu,Shell:()=>ed,Skill:()=>$u,Synthetic:()=>Zu,System:()=>Qu,ToolState:()=>ad,ToolStateCompleted:()=>rd,ToolStateError:()=>id,ToolStateRunning:()=>nd,ToolStateStreaming:()=>td,User:()=>Yu}),K=x.check(me(`msg_`)).pipe(M(`Session.Message.ID`),O({identifier:`Session.Message.ID`}),za(e=>({create:()=>e.make(`msg_`+Wa()),fromEvent:t=>e.make(t.replace(/^evt_/,`msg_`))}))),Wu={id:K,metadata:S(x,Ie).pipe(B),time:C({created:Ba})},Gu=S(x,Ie).annotate({identifier:`Session.Message.Native`}),Ku=C({...Wu,type:_(`agent-switched`),agent:su,previous:su.pipe(B)}).annotate({identifier:`Session.Message.AgentSelected`}),qu=C({...Wu,type:_(`model-switched`),model:Lc,previous:Lc.pipe(B)}).annotate({identifier:`Session.Message.ModelSelected`}),Ju=C({...Wu,type:_(`location-switched`),location:Xa,projectID:pu.pipe(B),subpath:Ia.pipe(B),previous:C({location:Xa,projectID:pu.pipe(B),subpath:Ia.pipe(B)}).pipe(B)}).annotate({identifier:`Session.Message.LocationSwitched`}),Yu=C({...Wu,text:rl.fields.text,files:rl.fields.files,agents:rl.fields.agents,skills:rl.fields.skills,type:_(`user`)}).annotate({identifier:`Session.Message.User`}),Xu=C({...Yu.fields,files:g(el).pipe(B)}).annotate({identifier:`Session.Message.MediaUser`}),Zu=C({...Wu,text:x,description:x.pipe(B),type:_(`synthetic`)}).annotate({identifier:`Session.Message.Synthetic`}),Qu=C({...Wu,type:_(`system`),text:x,description:x.pipe(B)}).annotate({identifier:`Session.Message.System`}),$u=C({...Wu,type:_(`skill`),skill:uo,name:fo,text:x}).annotate({identifier:`Session.Message.Skill`}),ed=C({...Wu,type:_(`shell`),shellID:Ou,command:x,status:ku,exit:gt.pipe(B),output:zu.pipe(B),time:C({created:Ba,completed:Ba.pipe(B)})}).annotate({identifier:`Session.Message.Shell`}),td=C({status:_(`streaming`),input:x}).annotate({identifier:`Session.Message.ToolState.Streaming`}),nd=C({status:_(`running`),input:S(x,Ie),metadata:S(x,Te)}).annotate({identifier:`Session.Message.ToolState.Running`}),rd=C({status:_(`completed`),input:S(x,Ie),content:De(Eu),metadata:S(x,Te).pipe(B)}).annotate({identifier:`Session.Message.ToolState.Completed`}),id=C({status:_(`error`),input:S(x,Ie),error:Bu,content:De(Eu).pipe(B),metadata:S(x,Te).pipe(B)}).annotate({identifier:`Session.Message.ToolState.Error`}),ad=E([td,nd,rd,id]).pipe(ie(`status`)),od=C({type:_(`tool`),id:x,name:x,executed:v.pipe(B),native:Gu.pipe(B),state:ad,time:C({created:Ba,ran:Ba.pipe(B),completed:Ba.pipe(B)})}).annotate({identifier:`Session.Message.Assistant.Tool`}),sd=C({type:_(`text`),text:x,native:Gu.pipe(B)}).annotate({identifier:`Session.Message.Assistant.Text`}),cd=C({type:_(`reasoning`),text:x,native:Gu.pipe(B),time:C({created:Ba,completed:Ba.pipe(B)}).pipe(B)}).annotate({identifier:`Session.Message.Assistant.Reasoning`}),ld=E([sd,cd,od]).pipe(ie(`type`)),ud=he(ld).annotate({identifier:`Session.Message.AssistantContent.Encoded`}),dd=C({attempt:Fa,at:Ba,error:Bu}).annotate({identifier:`Session.Message.Assistant.Retry`}),fd=C({...Wu,type:_(`assistant`),agent:su,model:Lc,content:ld.pipe(g),snapshot:C({start:Vu.pipe(B),end:Vu.pipe(B),files:g(Ia).pipe(B)}).pipe(B),finish:Cu.pipe(B),rawFinish:x.pipe(B),native:Gu.pipe(B),cost:Ac.pipe(B),tokens:Hu.pipe(B),error:Bu.pipe(B),retry:dd.pipe(B),time:C({created:Ba,streamed:Ba.pipe(B),completed:Ba.pipe(B)})}).annotate({identifier:`Session.Message.Assistant`}),pd={type:_(`compaction`),...Wu},md={cost:Ac.pipe(B),tokens:Hu.pipe(B)},hd=C({...pd,status:_(`running`),reason:y([`auto`,`manual`]),summary:x}).annotate({identifier:`Session.Message.Compaction.Running`}),gd=C({...pd,status:_(`completed`),reason:y([`auto`,`manual`]),model:Lc.pipe(B),native:Gu.pipe(B),summary:x,...md}).annotate({identifier:`Session.Message.Compaction.Completed`}),_d=C({...pd,status:_(`failed`),reason:y([`auto`,`manual`]),error:Bu,...md}).annotate({identifier:`Session.Message.Compaction.Failed`}),vd=E([hd,gd,_d]).pipe(ie(`status`),O({identifier:`Session.Message.Compaction`})),yd=C({...Wu,type:_(`idle`),outcome:y([`succeeded`,`failed`,`interrupted`]),error:Bu.pipe(B)}).annotate({identifier:`Session.Message.Idle`}),bd=E([Ku,qu,Ju,Yu,Zu,Qu,$u,ed,fd,vd,yd]).annotate({identifier:`Session.Message.Info`}),xd=E([Ku,qu,Ju,Xu,Zu,Qu,$u,ed,fd,vd,yd]).annotate({identifier:`Session.Message.MediaInfo`}),Sd=C({file:x,patch:x,additions:z,deletions:z,status:y([`added`,`deleted`,`modified`]),more:h(!0).pipe(B)}).annotate({identifier:`FileDiff.Info`}),Cd=C({file:x.pipe(B),patch:x.pipe(B),additions:P,deletions:P,status:y([`added`,`deleted`,`modified`]).pipe(B)}).annotate({identifier:`FileDiff.LegacyInfo`}),wd=C({messageID:K,partID:x.pipe(B),snapshot:Vu.pipe(B),files:g(Sd).pipe(B)}).annotate({identifier:`Session.Revert`}),Td=C({path:x,status:y([`added`,`modified`,`deleted`]),additions:P,deletions:P,patch:x}),Ed=C({messageID:K,partID:x.pipe(B),snapshot:x.pipe(B),diff:x.pipe(B),files:g(Td).pipe(B)}).annotate({identifier:`Session.RevertV1`}),Dd=wd.pipe(wt(C({source:_(`current`),revert:ue(wd)}),we({decode:e=>({source:`current`,revert:e}),encode:e=>e.revert}))),Od=Ed.pipe(wt(C({source:_(`legacy`),revert:ue(Ed)}),we({decode:e=>({source:`legacy`,revert:e}),encode:e=>e.revert})));E([Dd,Od]).pipe(ie(`source`),wt(ue(wd),we({decode:e=>e.source===`current`?e.revert:wd.make({messageID:e.revert.messageID,partID:e.revert.partID,snapshot:e.revert.snapshot?Vu.make(e.revert.snapshot):void 0,files:e.revert.files?.map(e=>({file:e.path,status:e.status,additions:e.additions,deletions:e.deletions,patch:e.patch}))}),encode:e=>({source:`current`,revert:e})})),O({identifier:`Session.Revert.Persisted`}));var kd=x.check(Ce(/^[a-z0-9][a-z0-9._-]*\/[a-z0-9][a-z0-9._/-]*$/u)).pipe(M(`Instruction.Key`),O({identifier:`Instruction.Key`})),Ad=x.check(Ce(/^[a-f0-9]{64}$/u)).pipe(M(`Instruction.Hash`),O({identifier:`Instruction.Hash`})),jd=S(kd,Ad),Md=h(`removed`);Md.make(`removed`);var Nd=S(x,E([Ad,Md])),Pd=x.check(Ce(/^[a-z0-9][a-z0-9._-]*$/u)).annotate({identifier:`InstructionEntry.Key`,description:`Instruction entry key (lowercase alphanumerics plus . _ -)`}),Fd=C({key:Pd,value:Te.annotate({description:`JSON value attached to the session's instructions`})}).annotate({identifier:`InstructionEntry.Info`}),Id=g(C({...Fd.fields,removed:v})).annotate({identifier:`InstructionEntry.Snapshot`}),Ld=class extends t()(`InstructionEntryValueTooLargeError`,{actualBytes:a,maxBytes:a,message:x},{httpApiStatus:413}){},Rd=e({Compaction:()=>ef,CompactionPayload:()=>Ud,Delivery:()=>zd,Info:()=>nf,Item:()=>Yd,MediaInfo:()=>rf,MediaUser:()=>Qd,MediaUserPayload:()=>Vd,Move:()=>tf,MovePayload:()=>Wd,SessionInbox:()=>Rd,Synthetic:()=>$d,SyntheticPayload:()=>Hd,User:()=>Zd,UserPayload:()=>Bd}),zd=y([`steer`,`queue`]).annotate({identifier:`Session.Inbox.Delivery`}),Bd=C({...rl.fields,metadata:S(x,Ie).pipe(B)}).annotate({identifier:`Session.Inbox.UserPayload`}),Vd=C({...Bd.fields,files:g(el).pipe(B)}).annotate({identifier:`Session.Inbox.MediaUserPayload`}),Hd=C({text:x,description:x.pipe(B),metadata:S(x,Ie).pipe(B)}).annotate({identifier:`Session.Inbox.SyntheticPayload`}),Ud=C({}).annotate({identifier:`Session.Inbox.CompactionPayload`}),Wd=C({location:Xa,projectID:pu,subpath:Ia.pipe(B)}).annotate({identifier:`Session.Inbox.MovePayload`}),Gd=C({type:_(`user`),payload:Bd,delivery:zd}),Kd=C({type:_(`synthetic`),payload:Hd,delivery:zd}),qd=C({type:_(`compaction`),payload:Ud,delivery:zd}),Jd=C({type:_(`move`),payload:Wd,delivery:zd}),Yd=E([Gd,Kd,qd,Jd]).pipe(ie(`type`),O({identifier:`Session.Inbox.Item`})),Xd={id:K,sessionID:Kl,time:C({created:Ba})},Zd=C({...Xd,...Gd.fields}).annotate({identifier:`Session.Inbox.User`}),Qd=C({...Zd.fields,payload:Vd}).annotate({identifier:`Session.Inbox.MediaUser`}),$d=C({...Xd,...Kd.fields}).annotate({identifier:`Session.Inbox.Synthetic`}),ef=C({...Xd,...qd.fields}).annotate({identifier:`Session.Inbox.Compaction`}),tf=C({...Xd,...Jd.fields}).annotate({identifier:`Session.Inbox.Move`}),nf=E([Zd,$d,ef,tf]).pipe(ie(`type`),O({identifier:`Session.Inbox.Info`})),rf=E([Qd,$d,ef,tf]).pipe(ie(`type`),O({identifier:`Session.Inbox.MediaInfo`})),af=E([C({type:h(`before`),messageID:K}),C({type:h(`through`),messageID:K})]).annotate({identifier:`Session.ForkBoundary`}),of=e({AgentSelected:()=>cf,All:()=>Uf,Archived:()=>hf,Compaction:()=>Lf,Created:()=>sf,Definitions:()=>zf,Deleted:()=>bf,Durable:()=>Hf,DurableDefinitions:()=>Bf,EphemeralDefinitions:()=>Vf,Execution:()=>Df,Forked:()=>xf,InboxCancelled:()=>Tf,InboxDelivered:()=>Cf,InboxDeliveryChanged:()=>Ef,InboxEnqueued:()=>wf,InstructionsUpdated:()=>Of,MessageContentUpdated:()=>_f,MetadataUpdated:()=>ff,ModelSelected:()=>lf,Moved:()=>uf,Permissions:()=>pf,Reasoning:()=>Pf,Renamed:()=>df,RetryScheduled:()=>If,RevertEvent:()=>Rf,SessionEvent:()=>of,Shell:()=>jf,Skill:()=>Af,Step:()=>Mf,Synthetic:()=>kf,Text:()=>Nf,Tool:()=>Ff,Unarchived:()=>gf,UsageRecorded:()=>vf,UsageUpdated:()=>yf,Viewed:()=>mf}),q={sessionID:Kl},J={durable:{aggregate:`sessionID`,version:1}},sf=H({type:`session.created`,...J,schema:{...q,projectID:pu,location:Xa,subpath:Ia.pipe(B),parentID:Kl.pipe(B),slug:x,title:x.pipe(B),agent:su.pipe(B),model:Lc.pipe(B),metadata:Du.pipe(B),permissions:iu.pipe(B),version:x}}),cf=H({type:`session.agent.selected`,...J,schema:{...q,agent:su,previous:su.pipe(B)}}),lf=H({type:`session.model.selected`,...J,schema:{...q,model:Lc,previous:Lc.pipe(B)}}),uf=H({type:`session.moved`,...J,schema:{...q,...Wd.fields}}),df=H({type:`session.renamed`,...J,schema:{...q,title:x}}),ff=H({type:`session.metadata.updated`,...J,schema:{...q,metadata:Du}}),pf=H({type:`session.permissions`,...J,schema:{...q,permissions:iu}}),mf=H({type:`session.viewed`,...J,schema:{...q,idle:P}}),hf=H({type:`session.archived`,...J,schema:q}),gf=H({type:`session.unarchived`,...J,schema:q}),_f=H({type:`session.message.content.updated`,...J,schema:{...q,messageID:K,content:g(ud)}}),vf=H({type:`session.usage.recorded`,...J,schema:{...q,source:y([`title`,`compaction`]),cost:Ac,tokens:Hu}}),yf=U({type:`session.usage.updated`,schema:{...q,cost:Ac,tokens:Hu}}),bf=H({type:`session.deleted`,durable:{aggregate:`sessionID`,version:2},schema:q}),xf=H({type:`session.forked`,durable:{aggregate:`sessionID`,version:2},schema:{...q,parentID:Kl,boundary:af,instructions:jd.pipe(B),instructionEntries:Id.pipe(B)}}),Sf={...q,inboxID:K},Cf=H({type:`session.inbox.delivered`,...J,schema:Sf}),wf=H({type:`session.inbox.enqueued`,...J,schema:{...Sf,item:Yd}}),Tf=H({type:`session.inbox.cancelled`,...J,schema:Sf}),Ef=H({type:`session.inbox.delivery.changed`,...J,schema:{...Sf,delivery:zd}}),Df;(function(e){e.Started=H({type:`session.execution.started`,...J,schema:q}),e.Succeeded=H({type:`session.execution.succeeded`,...J,schema:q}),e.Failed=H({type:`session.execution.failed`,...J,schema:{...q,error:Bu}}),e.Interrupted=H({type:`session.execution.interrupted`,...J,schema:{...q,reason:y([`user`,`shutdown`,`superseded`,`inactivity`])}})})(Df||={});var Of=H({type:`session.instructions.updated`,durable:{aggregate:`sessionID`,version:2},schema:{...q,delta:Nd,text:x.pipe(B)}}),kf=H({type:`session.synthetic`,...J,schema:{...q,text:x,description:x.pipe(B),metadata:S(x,Ie).pipe(B)}}),Af;(function(e){e.Activated=H({type:`session.skill.activated`,...J,schema:{...q,id:uo,name:fo,text:x}})})(Af||={});var jf;(function(e){e.Started=H({type:`session.shell.started`,...J,schema:{...q,shell:Mu}}),e.Ended=H({type:`session.shell.ended`,...J,schema:{...q,shell:Mu,output:zu}})})(jf||={});var Mf;(function(e){e.Started=H({type:`session.step.started`,...J,schema:{...q,assistantMessageID:K,agent:su,model:Lc,snapshot:Vu.pipe(B),started:z}}),e.Streamed=H({type:`session.step.streamed`,...J,schema:{...q,assistantMessageID:K}}),e.Ended=H({type:`session.step.ended`,...J,schema:{...q,assistantMessageID:K,finish:Cu,rawFinish:x.pipe(B),native:Gu.pipe(B),cost:Ac,tokens:Hu,snapshot:Vu.pipe(B),files:g(Ia).pipe(B)}}),e.Failed=H({type:`session.step.failed`,...J,schema:{...q,assistantMessageID:K,error:Bu,finish:y([`content-filter`]).pipe(B),rawFinish:x.pipe(B),native:Gu.pipe(B),cost:Ac.pipe(B),tokens:Hu.pipe(B),snapshot:Vu.pipe(B),files:g(Ia).pipe(B)}})})(Mf||={});var Nf;(function(e){e.Started=H({type:`session.text.started`,...J,schema:{...q,assistantMessageID:K,ordinal:z}}),e.Delta=U({type:`session.text.delta`,schema:{...q,assistantMessageID:K,ordinal:z,delta:x}}),e.Ended=H({type:`session.text.ended`,...J,schema:{...q,assistantMessageID:K,ordinal:z,text:x,native:Gu.pipe(B)}})})(Nf||={});var Pf;(function(e){e.Started=H({type:`session.reasoning.started`,...J,schema:{...q,assistantMessageID:K,ordinal:z,native:Gu.pipe(B)}}),e.Delta=U({type:`session.reasoning.delta`,schema:{...q,assistantMessageID:K,ordinal:z,delta:x}}),e.Ended=H({type:`session.reasoning.ended`,...J,schema:{...q,assistantMessageID:K,ordinal:z,text:x,native:Gu.pipe(B)}})})(Pf||={});var Ff;(function(e){let t={...q,assistantMessageID:K,id:x};(function(e){e.Started=H({type:`session.tool.input.started`,...J,schema:{...t,name:x}}),e.Delta=U({type:`session.tool.input.delta`,schema:{...t,delta:x}}),e.Ended=H({type:`session.tool.input.ended`,...J,schema:{...t,text:x}})})(e.Input||={}),e.Called=H({type:`session.tool.called`,...J,schema:{...t,input:S(x,Ie),executed:v,native:Gu.pipe(B)}}),e.Progress=U({type:`session.tool.progress`,schema:{...t,metadata:S(x,Te)}}),e.Success=H({type:`session.tool.success`,durable:{aggregate:`sessionID`,version:2},schema:{...t,content:De(Eu),metadata:S(x,Te).pipe(B),executed:v,native:Gu.pipe(B)}}),e.Failed=H({type:`session.tool.failed`,durable:{aggregate:`sessionID`,version:2},schema:{...t,error:Bu,content:De(Eu).pipe(B),metadata:S(x,Te).pipe(B),executed:v,native:Gu.pipe(B)}})})(Ff||={});var If=H({type:`session.retry.scheduled`,...J,schema:{...q,assistantMessageID:K,attempt:Fa,at:z,error:Bu}}),Lf;(function(e){e.Started=H({type:`session.compaction.started`,...J,schema:{...q,reason:y([`auto`,`manual`]),inputID:K.pipe(B)}}),e.Delta=U({type:`session.compaction.delta`,schema:{...q,text:x}}),e.Ended=H({type:`session.compaction.ended`,...J,schema:{...q,reason:e.Started.data.fields.reason,model:gd.fields.model,native:gd.fields.native,text:x,cost:gd.fields.cost,tokens:gd.fields.tokens}}),e.Failed=H({type:`session.compaction.failed`,...J,schema:{...q,reason:e.Started.data.fields.reason,error:Bu,inputID:K.pipe(B),cost:_d.fields.cost,tokens:_d.fields.tokens}})})(Lf||={});var Rf;(function(e){e.Staged=H({type:`session.revert.staged`,...J,schema:{...q,revert:wd}}),e.Cleared=H({type:`session.revert.cleared`,...J,schema:q}),e.Committed=H({type:`session.revert.committed`,...J,schema:{...q,to:K}})})(Rf||={});var zf=W(sf,cf,lf,uf,df,ff,pf,mf,hf,gf,yf,bf,xf,Cf,wf,Tf,Ef,Df.Started,Df.Succeeded,Df.Failed,Df.Interrupted,Of,kf,Af.Activated,jf.Started,jf.Ended,Mf.Started,Mf.Streamed,Mf.Ended,Mf.Failed,Nf.Started,Nf.Delta,Nf.Ended,Pf.Started,Pf.Delta,Pf.Ended,Ff.Input.Started,Ff.Input.Delta,Ff.Input.Ended,Ff.Called,Ff.Progress,Ff.Success,Ff.Failed,If,Lf.Started,Lf.Delta,Lf.Ended,Lf.Failed,Rf.Staged,Rf.Cleared,Rf.Committed),Bf=W(...zf.filter(e=>e.durability===`durable`),vf,_f),Vf=W(...zf.filter(e=>e.durability===`ephemeral`)),Hf=E(Bf,{mode:`oneOf`}).annotate({identifier:`Session.Event.Durable`}).pipe(ie(`type`)),Uf=E([Hf,...Vf],{mode:`oneOf`}).pipe(ie(`type`)),Wf=e({Event:()=>Kf,ForkBoundary:()=>qf,ID:()=>Y,Info:()=>Jf,ListAnchor:()=>Yf,ListCursor:()=>np,ListFilter:()=>Zf,Metadata:()=>Gf,Revert:()=>wd,Session:()=>Wf}),Y=Kl,Gf=Du,Kf=of,qf=af,Jf=C({id:Y,parentID:Y.pipe(B),fork:C({sessionID:Y,boundary:qf}).pipe(B),projectID:pu,agent:su.pipe(B),model:Lc.pipe(B),cost:Ac,tokens:Hu,outcome:y([`succeeded`,`failed`,`interrupted`]).pipe(B),time:C({created:Ba,updated:Ba,idle:Ba.pipe(B),viewed:Ba.pipe(B),archived:Ba.pipe(B)}),title:x.pipe(B),location:Xa,subpath:Ia.pipe(B),metadata:Gf.pipe(B),permissions:iu.pipe(B),revert:wd.pipe(B)}).annotate({identifier:`Session.Info`}),Yf=C({id:Y,time:P,direction:y([`previous`,`next`])}).annotate({identifier:`Session.ListAnchor`}),Xf={order:y([`asc`,`desc`]).pipe(i).annotate({description:`Session order for the first page. Use desc for newest first or asc for oldest first.`}),search:x.pipe(i),parentID:E([Y,te.pipe(Ze(h(`null`),{decode:m(()=>null),encode:m(()=>`null`)}))]).annotate({description:`Filter by parent session. Use null to return only root sessions.`}).pipe(i),archived:y([`true`,`false`]).pipe(wt(v,{decode:m(e=>e===`true`),encode:m(e=>e?`true`:`false`)})).annotate({description:`Filter by archive state. Use true to return only archived sessions or false to exclude them. Omit to include both.`}).pipe(i)},Zf=C({...Xf,directory:La.pipe(i),project:pu.pipe(i),subpath:Ia.pipe(i)}).annotate({identifier:`Session.ListFilter`}),Qf=E([C({...Xf,directory:La,anchor:Yf}),C({...Xf,project:pu,subpath:Ia.pipe(i),anchor:Yf}),C({...Xf,anchor:Yf})]),$f=Ne(Qf),ep=ct($f),tp=He($f),np=x.pipe(M(`SessionsCursor`),O({identifier:`SessionsCursor`,description:`Opaque pagination cursor returned as cursor.previous or cursor.next in the previous response.`}),za(e=>{let t=ne(e);return{make:e=>t(oe(ep(e))),parse:e=>ht(()=>{let t=_t(e);return Me(t)?ut(`Invalid cursor`):tp(t.success).pipe(w(()=>`Invalid cursor`))})}})),rp=C({...Rl.fields,sessionID:Y,foregroundProcess:se(x),size:C({cols:Fa,rows:Fa}),output:C({head:z,tail:z})}).annotate({identifier:`PersistentPty.Info`}),ip=C({directory:x,instanceID:x,ticket:x,expiresAt:gt}).annotate({identifier:`PersistentPty.Handoff`}),ap=C({command:B(x),args:g(x),cwd:B(x),title:x,env:S(x,x),size:B(C({cols:Fa,rows:Fa}))}).annotate({identifier:`PersistentPty.CreateInput`}),op=C({attachmentID:B(x),size:C({cols:Fa,rows:Fa})}).annotate({identifier:`PersistentPty.UpdateInput`}),sp=C({info:rp,text:x,checkpoint:dt,cursor:C({x:z,y:z})}).annotate({identifier:`PersistentPty.Snapshot`}),cp=Fa.check(xe(65535)).annotate({identifier:`PersistentPty.ReadLines`}),lp=C({ptyID:Ll,title:x,cwd:x,foregroundProcess:se(x),screen:C({text:x,cols:Fa,rows:Fa,cursor:sp.fields.cursor})}).annotate({identifier:`PersistentPty.ReadResult`}),up=U({type:`persistent-pty.added`,schema:{sessionID:Y,terminal:rp}}),dp=U({type:`persistent-pty.removed`,schema:{sessionID:Y,ptyID:Ll}}),fp={Added:up,Removed:dp,Definitions:W(up,dp)},pp=C({ticket:x,expires_in:Fa}).annotate({identifier:`PtyTicket.ConnectToken`}),X=C({location:i(C({directory:i(x)}))}).annotate({identifier:`LocationQuery`}),Z=k({transform:e=>{let t=e.parameters;return Array.isArray(t)?{...e,parameters:t.map(e=>e?.name===`location`&&e?.in===`query`?{...e,style:`deepObject`,explode:!0}:e)}:e}}),mp=e=>N(`server.location`).add(A(`location.get`,`/api/location`,{query:X,success:$a}).middleware(e).annotateMerge(Z).annotateMerge(k({identifier:`location.get`,summary:`Get location`,description:`Resolve the requested location or the server default location.`}))).add(D(`location.reload`,`/api/location/reload`,{success:T,error:Do}).annotateMerge(k({identifier:`location.reload`,summary:`Reload configuration`,description:`Shut down and rebuild every loaded location. Pending permissions and forms are cancelled; running sessions continue with fresh services at the next step boundary. Emits location.shutdown for client recovery and responds once all replacement builds settle.`}))).annotateMerge(k({title:`location`})),hp=`ticket`,gp=`x-opencode-ticket`,_p=`/api/pty/:ptyID/connect`,vp=e=>N(`server.pty`).add(A(`pty.list`,`/api/pty`,{query:X,success:V(g(Rl))}).annotateMerge(Z).annotateMerge(k({identifier:`pty.list`,summary:`List PTY sessions`,description:`List PTY sessions for a location, including exited sessions retained until removal.`}))).add(D(`pty.create`,`/api/pty`,{query:X,payload:Wl,success:V(Rl)}).annotateMerge(Z).annotateMerge(k({identifier:`pty.create`,summary:`Create PTY session`,description:`Create a pseudo-terminal session for a location.`}))).add(A(`pty.get`,`/api/pty/:ptyID`,{params:{ptyID:Ll},query:X,success:V(Rl),error:Yo}).annotateMerge(Z).annotateMerge(k({identifier:`pty.get`,summary:`Get PTY session`,description:`Get one PTY session, including its exit code once exited.`}))).add(St(`pty.update`,`/api/pty/:ptyID`,{params:{ptyID:Ll},query:X,payload:Gl,success:V(Rl),error:Yo}).annotateMerge(Z).annotateMerge(k({identifier:`pty.update`,summary:`Update PTY session`,description:`Update the title or viewport size of one PTY session.`}))).add(ft(`pty.remove`,`/api/pty/:ptyID`,{params:{ptyID:Ll},query:X,success:T,error:Yo}).annotateMerge(Z).annotateMerge(k({identifier:`pty.remove`,summary:`Remove PTY session`,description:`Terminate and remove one PTY session.`}))).add(D(`pty.connectToken`,`/api/pty/:ptyID/connect-token`,{params:{ptyID:Ll},query:X,headers:C({[gp]:i(x)}),success:V(pp),error:[Jo,Yo]}).annotateMerge(Z).annotateMerge(k({identifier:`pty.connect.token`,summary:`Create PTY WebSocket token`,description:`Create a short-lived single-use ticket for opening a PTY WebSocket connection.`}))).middleware(e).add(A(`pty.connect`,_p,{params:{ptyID:Ll},success:v,error:[Jo,Yo,bo]}).annotateMerge(k({identifier:`pty.connect`,summary:`Connect to PTY session`,description:`Establish a WebSocket connection streaming PTY output and accepting terminal input.`,transform:e=>({...e,"x-websocket":!0,parameters:[...e.parameters??[],...[`location[directory]`,`cursor`,hp].map(e=>({in:`query`,name:e,schema:{type:`string`}}))]})}))).annotateMerge(k({title:`pty`,description:`Experimental location-scoped PTY routes.`})),yp=`/api/experimental/persistent-pty/:ptyID/connect`,bp=[xo,Do],xp=[Yo,Do],Sp=N(`server.experimental`).add(A(`persistentPty.read`,`/api/experimental/session/:sessionID/terminal/read`,{params:{sessionID:Y},query:{lines:ae.pipe(wt(cp),i)},success:C({data:se(lp)}),error:[Do]}).annotateMerge(k({summary:`Read the session's most recently controlled terminal`,description:`Read the last physical rows without changing selection or taking control. Omitted lines uses the live terminal height; larger counts include retained history. Blank rows are preserved. Screen dimensions and cursor remain relative to the live screen. Returns null when no current terminal exists. Selection is server-local and resets on restart. Experimental: may change without compatibility guarantees.`}))).add(A(`persistentPty.list`,`/api/experimental/session/:sessionID/terminal`,{params:{sessionID:Y},success:C({data:g(rp)}),error:bp})).add(D(`persistentPty.create`,`/api/experimental/session/:sessionID/terminal`,{params:{sessionID:Y},payload:ap,success:C({data:rp}),error:bp})).add(D(`persistentPty.shutdown`,`/api/experimental/persistent-pty/shutdown`,{success:T,error:[Do]})).add(D(`persistentPty.handoff`,`/api/experimental/persistent-pty/handoff`,{success:C({handoff:se(ip)}),error:[Do]})).add(A(`persistentPty.get`,`/api/experimental/persistent-pty/:ptyID`,{params:{ptyID:Ll},success:C({data:rp}),error:xp})).add(St(`persistentPty.update`,`/api/experimental/persistent-pty/:ptyID`,{params:{ptyID:Ll},payload:op,success:C({data:rp}),error:xp})).add(A(`persistentPty.snapshot`,`/api/experimental/persistent-pty/:ptyID/snapshot`,{params:{ptyID:Ll},success:C({data:sp}),error:xp})).add(ft(`persistentPty.remove`,`/api/experimental/persistent-pty/:ptyID`,{params:{ptyID:Ll},success:T,error:xp})).add(D(`persistentPty.connectToken`,`/api/experimental/persistent-pty/:ptyID/connect-token`,{params:{ptyID:Ll},headers:C({[gp]:i(x)}),success:C({data:pp}),error:[Jo,Yo,Do]})).add(A(`persistentPty.connect`,yp,{params:{ptyID:Ll},success:v,error:[Jo,Yo,Do]}).annotateMerge(k({identifier:`persistentPty.connect`,summary:`Connect to a persistent PTY`,description:`Stream persistent PTY output through the OpenCode server.`,transform:e=>({...e,"x-websocket":!0,parameters:[...e.parameters??[],...[`cursor`,`role`,`attachment_id`,`takeover`,`input_protocol`,hp].map(e=>({in:`query`,name:e,schema:{type:`string`}}))]})}))).annotateMerge(k({title:`persistentPty`,description:`Prototype persistent PTY routes.`})).add(Fl),Cp=y([`webrtc`,`websocket`]).annotate({identifier:`VoiceTransportType`}),wp=C({model:x,provider:x,transports:g(Cp),available:v}).annotate({identifier:`VoiceModel`}),Tp=C({type:h(`webrtc`),sdp:x,dcid:i(gt)}).annotate({identifier:`VoiceWebRTCTransportInput`}),Ep=C({type:h(`websocket`)}).annotate({identifier:`VoiceWebSocketTransportInput`}),Dp=E([Tp,Ep]).annotate({identifier:`VoiceTransportInput`}),Op=C({type:h(`webrtc`),sdp:x}).annotate({identifier:`VoiceWebRTCTransport`}),kp=C({type:h(`websocket`),url:x,token:x,expiresAt:gt}).annotate({identifier:`VoiceWebSocketTransport`}),Ap=E([Op,kp]).annotate({identifier:`VoiceTransport`}),jp=N(`server.voice`).add(A(`voice.models`,`/api/experimental/voice/models`,{success:C({data:C({models:g(wp),default:i(x)})}).annotate({identifier:`VoiceModelsResponse`}),error:[Do,bo]}).annotateMerge(k({identifier:`experimental.voice.models`,summary:`List voice models`,description:`List supported voice models, their transports, and whether the server has a usable API key for each provider.`}))).add(D(`voice.session`,`/api/experimental/voice/session`,{payload:C({model:x,session:i(S(x,Ie)),transport:Dp}),success:C({data:C({transport:Ap})}).annotate({identifier:`VoiceSessionResponse`}),error:[xo,Do,bo]}).annotateMerge(k({identifier:`experimental.voice.session`,summary:`Create voice session`,description:`Create a server-brokered voice session using the server's configured provider credentials and return the WebRTC SDP answer or WebSocket ephemeral token.`}))).annotateMerge(k({title:`voice`,description:`Experimental server-brokered voice session routes.`})),Mp=C({limit:i(ae.check(jt(),Re(1),xe(200))).annotate({description:`Maximum number of messages to return. When omitted, the endpoint returns its default page size.`}),order:i(E([h(`asc`),h(`desc`)])).annotate({description:`Message order for the first page. Use desc for newest first or asc for oldest first.`}),cursor:i(x.annotate({description:`Opaque pagination cursor returned as cursor.previous or cursor.next in the previous response. Do not combine with order.`})),type:i(y(Object.keys({"agent-switched":!0,"model-switched":!0,"location-switched":!0,user:!0,synthetic:!0,system:!0,skill:!0,shell:!0,assistant:!0,compaction:!0,idle:!0}))).annotate({description:`Filter by message type before pagination. When omitted, all message types are returned. Pass the same type when following cursors.`})}).annotate({identifier:`SessionMessagesQuery`}),Np=C({...o(Ju.fields,[`location`,`previous`]),location:Za,previous:C({location:Za,projectID:Ju.fields.projectID,subpath:Ju.fields.subpath}).pipe(i)}).annotate({identifier:`Session.Message.LocationSwitched`}),Pp=E([Ku,qu,Np,Yu,Zu,Qu,$u,ed,fd,vd,yd]).annotate({identifier:`Session.Message.Info`}),Fp=E([Ku,qu,Np,Xu,Zu,Qu,$u,ed,fd,vd,yd]).annotate({identifier:`Session.Message.MediaInfo`}),Ip=C({previous:x.pipe(i),next:x.pipe(i)});C({data:g(Fp),cursor:Ip}),C({data:Fp});var Lp=N(`server.message`).add(A(`session.messages`,`/api/session/:sessionID/message`,{params:{sessionID:Y},query:Mp,success:C({data:g(Pp),cursor:Ip}).annotate({identifier:`SessionMessagesResponse`}),error:[Ho,G,Oo]}).annotateMerge(k({identifier:`session.message.list`,summary:`Get session messages`,description:`Retrieve projected messages for a session, optionally filtered by type. Items keep the requested order across pages; use cursor.next or cursor.previous to move through the ordered timeline, passing the same type filter on each page.`}))).annotateMerge(k({title:`session`,description:`Experimental message routes.`})),Rp=C({...X.fields,types:i(de(zc)).annotate({description:`Only list models of these types. Defaults to chat, the only type offered for sessions.`})}),zp=N(`server.model`).add(A(`model.list`,`/api/model`,{query:Rp,success:V(g(Gc)),error:Do}).annotateMerge(Z).annotateMerge(k({identifier:`model.list`,summary:`List models`,description:`Retrieve the current snapshot of available models of the requested types, chat by default, ordered by release date within each type. The snapshot may precede initial plugin settlement.`}))).add(A(`model.default`,`/api/model/default`,{query:X,success:V(yt(Gc)),error:Do}).annotateMerge(Z).annotateMerge(k({identifier:`model.default`,summary:`Get default model`,description:`Retrieve the model used when a session has no explicit model selection.`}))).annotateMerge(k({title:`model`,description:`Experimental model routes.`})),Bp=N(`server.provider`).add(A(`provider.list`,`/api/provider`,{query:X,success:V(g(kc)),error:Do}).annotateMerge(Z).annotateMerge(k({identifier:`provider.list`,summary:`List providers`,description:`Retrieve active AI providers so clients can show provider availability and configuration.`}))).add(A(`provider.get`,`/api/provider/:providerID`,{params:{providerID:hc},query:X,success:V(kc),error:[ko,Do]}).annotateMerge(Z).annotateMerge(k({identifier:`provider.get`,summary:`Get provider`,description:`Retrieve a single AI provider so clients can inspect its availability and endpoint settings.`}))).annotateMerge(k({title:`provider`,description:`Experimental provider routes.`})),Vp=e({FileAttachment:()=>Hp,Prompt:()=>Wp,PromptInput:()=>Vp,SkillAttachment:()=>Up}),Hp=C({uri:x,name:x.pipe(B),description:x.pipe(B),mention:Kc.pipe(B)}).annotate({identifier:`PromptInput.FileAttachment`}),Up=C({id:uo,mention:Kc.pipe(B)}).annotate({identifier:`PromptInput.SkillAttachment`}),Wp=C({text:x,files:g(Hp).pipe(B),agents:g(tl).pipe(B),skills:g(Up).pipe(B)}).annotate({identifier:`PromptInput`}),Gp=C({date:x,steps:z}).annotate({identifier:`SessionStats.Activity`}),Kp=C({model:Lc,steps:z,tokens:Hu,cost:Ac}).annotate({identifier:`SessionStats.ModelUsage`}),qp=C({name:x,calls:z,succeeded:z,failed:z,unfinished:z,durationP50:P.pipe(B)}).annotate({identifier:`SessionStats.ToolUsage`}),Jp=y([`none`,`summary`,`detail`]),Yp=C({calls:z,succeeded:z,failed:z,unfinished:z}).annotate({identifier:`SessionStats.ToolTotals`}),Xp=E([C({mode:h(`none`)}),C({mode:h(`summary`),totals:Yp}),C({mode:h(`detail`),totals:Yp,usage:g(qp)})]).annotate({identifier:`SessionStats.Tools`}),Zp=C({range:C({from:Ba,to:Ba}),sessions:z,subagents:z,prompts:z,steps:z,tokens:Hu,cost:Ac,tools:Xp,activeDays:z,streak:z,activity:g(Gp),models:g(Kp)}).annotate({identifier:`SessionStats.Info`});function Qp(e,t){return e===`assistant`?em(sm(t,`providerState`,`native`)):e===`compaction`?rm(nm(sm(t,`providerState`,`native`))):t}function $p(e){return e.map(e=>cm(e)?Qp(e.type,e):e)}function em(e){return Array.isArray(e.content)?{...e,content:e.content.map(tm)}:e}function tm(e){return cm(e)?e.type===`text`||e.type===`reasoning`?sm(e,`state`,`native`):e.type===`tool`?om(sm(e,`providerState`,`native`)):e:e}function nm(e){let t=e.recent,n=am(e,`recent`);if(typeof t!=`string`||!t)return n;let r=cm(n.metadata)?n.metadata:{};return{...n,metadata:{recent:t,...r}}}function rm(e){let t=e.providerContext,n=am(e,`providerContext`);return cm(t)?{...n,native:{messages:Array.isArray(t.messages)?t.messages.map(im):t.messages}}:n}function im(e){return!cm(e)||!Array.isArray(e.content)?e:{...e,content:e.content.map(e=>{if(!cm(e)||e.type!==`media`||e.media!==void 0||typeof e.data!=`string`)return e;let{mediaType:t,data:n,...r}=e;return{...r,media:{source:{type:`base64`,data:n,mediaType:t}}}})}}function am(e,t){if(!(t in e))return e;let{[t]:n,...r}=e;return r}function om(e){if(!(`providerResultState`in e))return e;let{providerResultState:t,...n}=e;return cm(t)?{...n,native:{...cm(n.native)?n.native:{},...t}}:n}function sm(e,t,n){if(!(t in e))return e;let{[t]:r,...i}=e;return n in i?i:{...i,[n]:r}}function cm(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}var lm=e({EventLog:()=>lm,Synced:()=>um}),um=C({type:h(`log.synced`),aggregateID:x,seq:B(no)}).annotate({identifier:`EventLog.Synced`,description:`Marker emitted once when a log read reaches its captured watermark. The reader holds every event committed at or below seq.`}),dm=C({type:h(`running`)}).annotate({identifier:`SessionActive`}),fm=C({...o(Jf.fields,[`location`]),location:Za}).annotate({identifier:`Session.Info`}),pm=C({info:fm,messages:g(Pp)}).annotate({identifier:`SessionTransfer.Data`}),mm=C({...o(Wd.fields,[`location`]),location:Za}).annotate({identifier:`Session.Inbox.MovePayload`}),hm=C({...o(tf.fields,[`payload`]),payload:mm}).annotate({identifier:`Session.Inbox.Move`}),gm=E([Zd,$d,ef,hm]).annotate({identifier:`Session.Inbox.Info`});C({data:g(E([Qd,$d,ef,hm]).annotate({identifier:`Session.Inbox.MediaInfo`}))});var _m=g(Te).pipe(wt(g(Ie),{decode:m($p),encode:b({strict:!1})}),wt(g(Pp),{decode:b({strict:!1}),encode:b({strict:!1})})),vm=C({id:ys.pipe(i),title:Ns.fields.title,metadata:Ns.fields.metadata,fields:Ns.fields.fields}).annotate({identifier:`Form.CreatePayload`}),ym=y([`true`,`false`]).pipe(wt(v,{decode:m(e=>e===`true`),encode:m(e=>e?`true`:`false`)})),bm=C({limit:ae.pipe(wt(Fa),i).annotate({description:`Maximum number of sessions to return. Defaults to the newest 50 sessions.`}),...Zf.fields,cursor:np.pipe(i)}).annotate({identifier:`SessionsQuery`}),xm=(e,t)=>N(`server.session`).add(A(`session.list`,`/api/session`,{query:bm,success:C({data:g(fm),cursor:C({previous:np.pipe(i),next:np.pipe(i)})}).annotate({identifier:`SessionsResponse`}),error:[Ho,xo]}).annotateMerge(k({identifier:`session.list`,summary:`List sessions`,description:`Retrieve sessions in the requested order. Items keep that order across pages; use cursor.next or cursor.previous to move through the ordered list.`}))).add(A(`session.stats`,`/api/experimental/session/stats`,{query:C({from:ae.pipe(i),to:ae.pipe(i),project:pu.pipe(i),timezone:x.pipe(i),tools:Jp.pipe(i)}),success:C({data:Zp}),error:xo}).annotateMerge(k({identifier:`experimental.session.stats`,summary:`Get session statistics`,description:`Aggregate local session activity, usage, and tool reliability for a time range.`}))).add(D(`session.create`,`/api/session`,{payload:C({id:Y.pipe(i),parentID:Y.pipe(i),title:x.pipe(i),agent:su.pipe(i),model:Lc.pipe(i),location:Za.pipe(i),metadata:Gf.pipe(i),permissions:iu.pipe(i)}),success:C({data:fm}),error:G}).annotateMerge(k({identifier:`session.create`,summary:`Create session`,description:`Create a session at the requested location. A parentID creates a linked child session at its parent's location.`}))).add(D(`session.import`,`/api/experimental/session/import`,{payload:C({info:pm.fields.info,messages:_m,location:Za.pipe(i)}),success:C({data:fm}),error:[To,G]}).annotateMerge(k({identifier:`experimental.session.import`,summary:`Import session`,description:`Import a projected session transcript at the requested location. Accepts transcripts exported by earlier releases. If parentID is supplied, the parent session must already exist; import parents before children.`}))).add(A(`session.export`,`/api/experimental/session/:sessionID/export`,{params:{sessionID:Y},query:C({sanitize:ym.pipe(i)}),success:C({data:pm}),error:[G,Oo]}).annotateMerge(k({identifier:`experimental.session.export`,summary:`Export session`,description:`Export a complete projected session transcript.`}))).add(A(`session.active`,`/api/session/active`,{success:C({data:S(Y,dm)})}).annotateMerge(k({identifier:`session.active`,summary:`List active sessions`,description:`Retrieve foreground Session drains currently owned by this OpenCode process. Sessions absent from the result are inactive.`}))).add(A(`session.get`,`/api/session/:sessionID`,{params:{sessionID:Y},success:C({data:fm}),error:G}).annotateMerge(k({identifier:`session.get`,summary:`Get session`,description:`Retrieve a session by ID.`}))).add(ft(`session.remove`,`/api/session/:sessionID`,{params:{sessionID:Y},success:T,error:G}).annotateMerge(k({identifier:`session.remove`,summary:`Delete session`,description:`Delete a session and its child sessions.`}))).add(D(`session.fork`,`/api/session/:sessionID/fork`,{params:{sessionID:Y},payload:C({before:K.pipe(i)}),success:C({data:fm}),error:[G,Lo,xo]}).annotateMerge(k({identifier:`session.fork`,summary:`Fork session`,description:`Create a child session by copying projected history before a message. Omit before to copy the full history.`}))).add(D(`session.switchAgent`,`/api/session/:sessionID/agent`,{params:{sessionID:Y},payload:C({agent:su}),success:T,error:G}).annotateMerge(k({identifier:`session.switchAgent`,summary:`Switch session agent`,description:`Switch the agent used by subsequent provider turns.`}))).add(D(`session.switchModel`,`/api/session/:sessionID/model`,{params:{sessionID:Y},payload:C({model:Lc}),success:T,error:G}).annotateMerge(k({identifier:`session.switchModel`,summary:`Switch session model`,description:`Switch the model used by subsequent provider turns.`}))).add(ze(`session.update`,`/api/session/:sessionID`,{params:{sessionID:Y},payload:C({title:x.pipe(i),metadata:Gf.pipe(i),permissions:iu.pipe(i),archived:v.pipe(i).annotate({description:`Archive the session with true or restore it with false. Repeating the current state is a no-op.`})}),success:T,error:[G,bo]}).annotateMerge(k({identifier:`session.update`,summary:`Update session`,description:`Update mutable session properties.`}))).add(D(`session.move`,`/api/session/:sessionID/move`,{params:{sessionID:Y},payload:C({...Za.fields,delivery:zd.pipe(i)}),success:T,error:[G,xo]}).annotateMerge(k({identifier:`session.move`,summary:`Move session`,description:`Move a session to another project directory at the requested delivery boundary.`}))).add(D(`session.prompt`,`/api/session/:sessionID/prompt`,{params:{sessionID:Y},payload:C({id:K.pipe(i),...Wp.fields,metadata:Bd.fields.metadata,delivery:zd.pipe(i),resume:v.pipe(i)}),success:C({data:Zd}),error:[To,xo,G]}).middleware(e).annotateMerge(k({identifier:`session.prompt`,summary:`Send message`,description:`Durably admit one session input and schedule agent-loop execution unless resume is false.`}))).add(D(`session.command`,`/api/session/:sessionID/command`,{params:{sessionID:Y},payload:C({name:x,...Wp.fields,delivery:zd.pipe(i)}),success:T,error:[G,Bo,Vo]}).middleware(e).annotateMerge(k({identifier:`session.command`,summary:`Run command`,description:`Execute a slash command callback immediately.`}))).add(D(`session.skill`,`/api/experimental/session/:sessionID/skill`,{params:{sessionID:Y},payload:C({id:uo,resume:v.pipe(i)}),success:T,error:[G,Ro]}).middleware(e).annotateMerge(k({identifier:`experimental.session.skill`,summary:`Activate skill`,description:`Activate a skill for a session by appending a skill message and resuming execution.`}))).add(D(`session.synthetic`,`/api/session/:sessionID/synthetic`,{params:{sessionID:Y},payload:C({id:K.pipe(i),text:x,description:x.pipe(i),metadata:Zu.fields.metadata,delivery:zd.pipe(i),resume:v.pipe(i)}),success:C({data:$d}),error:[To,G]}).middleware(e).annotateMerge(k({identifier:`session.synthetic`,summary:`Add synthetic message`,description:`Durably admit synthetic session input and schedule execution unless resume is false.`}))).add(D(`session.shell`,`/api/session/:sessionID/shell`,{params:{sessionID:Y},payload:C({id:K.pipe(i),command:x}),success:T,error:G}).middleware(e).annotateMerge(k({identifier:`session.shell`,summary:`Run shell command`,description:`Execute one shell command in the session's working directory. Emits a shell.started event before execution and a shell.ended event with the merged output after.`}))).add(D(`session.compact`,`/api/session/:sessionID/compact`,{params:{sessionID:Y},payload:C({id:K.pipe(i),delivery:zd.pipe(i)}),success:C({data:ef}),error:[To,G]}).middleware(e).annotateMerge(k({identifier:`session.compact`,summary:`Compact session`,description:`Durably admit a session compaction request. Steers by default: it runs at the next step boundary instead of waiting behind queued prompts.`}))).add(D(`session.wait`,`/api/experimental/session/:sessionID/wait`,{params:{sessionID:Y},success:T,error:[G,Do]}).annotateMerge(k({identifier:`experimental.session.wait`,summary:`Wait for session`,description:`Wait for a session agent loop to become idle.`}))).add(D(`session.revert.stage`,`/api/session/:sessionID/revert/stage`,{params:{sessionID:Y},payload:C({messageID:K,files:v.pipe(i)}),success:C({data:wd}),error:[Lo,G,Eo,Oo]}).middleware(e).annotateMerge(k({identifier:`session.revert.stage`,summary:`Stage session revert`,description:`Stage or move a reversible session boundary and optionally apply its file changes.`}))).add(ft(`session.revert.clear`,`/api/session/:sessionID/revert`,{params:{sessionID:Y},success:T,error:[G,Eo,Oo]}).middleware(e).annotateMerge(k({identifier:`session.revert.clear`,summary:`Clear staged revert`}))).add(D(`session.revert.commit`,`/api/session/:sessionID/revert/commit`,{params:{sessionID:Y},success:T,error:[G,Eo]}).annotateMerge(k({identifier:`session.revert.commit`,summary:`Commit staged revert`}))).add(A(`session.context`,`/api/session/:sessionID/context`,{params:{sessionID:Y},success:C({data:g(Pp)}),error:[G,Oo]}).annotateMerge(k({identifier:`session.context`,summary:`Get session context`,description:`Retrieve the active context messages for a session (all messages after the last compaction).`}))).add(A(`session.diff`,`/api/session/:sessionID/diff`,{params:{sessionID:Y},query:C({from:i(K).annotate({description:`User message whose turn to diff. Defaults to the turn of the newest user message.`}),to:i(K).annotate({description:"Later user message whose turn ends the range. Defaults to the turn of `from` alone."}),context:ae.pipe(wt(z),i).annotate({description:`Unchanged lines around each hunk. Omit for full-file patches.`})}),success:C({data:g(Sd)}),error:[xo,Lo,G,Oo,bo]}).annotateMerge(k({identifier:`session.diff`,summary:`Diff session turns`,description:"Structured per-file diffs of the files a turn changed. A turn runs from the first prompt after the session was last idle until its next idle marker, so prompts steered in while it was busy belong to the same turn; `to` extends the range through a later turn. Compares the range's first recorded snapshot with its last; a step still running in the active session compares against the working copy. Ranges that span a location change are rejected. In sessions without any idle marker, a prompt's turn spans until the next user message."}))).add(A(`session.inbox.list`,`/api/session/:sessionID/inbox`,{params:{sessionID:Y},success:C({data:g(gm)}),error:G}).annotateMerge(k({identifier:`session.inbox.list`,summary:`List session inbox`,description:`List durable enqueued session work not yet delivered, ordered by enqueue sequence. Includes user, synthetic, compaction, and move items.`}))).add(ft(`session.inbox.cancel`,`/api/session/:sessionID/inbox/:inboxID`,{params:{sessionID:Y,inboxID:K},success:T,error:G}).annotateMerge(k({identifier:`session.inbox.cancel`,summary:`Cancel inbox input`,description:`Cancel an inbox item that has not yet been delivered. Unavailable items are a no-op.`}))).add(ze(`session.inbox.update`,`/api/session/:sessionID/inbox/:inboxID`,{params:{sessionID:Y,inboxID:K},payload:C({delivery:zd}),success:T,error:[To,G]}).annotateMerge(k({identifier:`session.inbox.update`,summary:`Update inbox item`,description:`Change a pending inbox item's delivery mode. Steering wakes session execution.`}))).add(A(`session.instructions.entry.list`,`/api/experimental/session/:sessionID/instructions/entries`,{params:{sessionID:Y},success:C({data:g(Fd)}),error:G}).annotateMerge(k({identifier:`experimental.session.instructions.entry.list`,summary:`List instruction entries`,description:`List API-managed instruction entries attached to the session.`}))).add(St(`session.instructions.entry.put`,`/api/experimental/session/:sessionID/instructions/entries/:key`,{params:{sessionID:Y,key:Pd},payload:C({value:Te}),success:T,error:[G,Ld]}).annotateMerge(k({identifier:`experimental.session.instructions.entry.put`,summary:`Put instruction entry`,description:`Attach or replace one durable instruction entry. Changes announce as updates at the next step boundary.`}))).add(ft(`session.instructions.entry.remove`,`/api/experimental/session/:sessionID/instructions/entries/:key`,{params:{sessionID:Y,key:Pd},success:T,error:G}).annotateMerge(k({identifier:`experimental.session.instructions.entry.remove`,summary:`Remove instruction entry`,description:`Remove one instruction entry; the removal is announced to the model at the next step boundary.`}))).add(D(`session.generate`,`/api/session/:sessionID/generate`,{params:{sessionID:Y},payload:C({prompt:x}),success:C({data:C({text:x})}).annotate({identifier:`SessionGenerateResponse`}),error:[G,Do]}).middleware(e).annotateMerge(k({identifier:`session.generate`,summary:`Generate text from session context`,description:`Generate transient text from the current session context without mutating session history.`}))).add(A(`session.log`,`/api/experimental/session/:sessionID/log`,{params:{sessionID:Y},query:{after:ae.pipe(wt(no),i),follow:ym.pipe(i)},success:Ge({data:E([Hf,um]).annotate({identifier:`SessionLogItem`})}),error:G}).annotateMerge(k({identifier:`session.log`,summary:`Read the session log`,description:`Experimental durable session event log. Reads events after an exclusive aggregate sequence and continues with live events when follow=true.`}))).add(D(`session.interrupt`,`/api/session/:sessionID/interrupt`,{params:{sessionID:Y},query:{resume:ym.pipe(i)},success:C({interrupted:v.annotate({description:`Whether an active execution owned by this OpenCode process was interrupted.`})}).annotate({identifier:`SessionInterruptResponse`}),error:G}).annotateMerge(k({identifier:`session.interrupt`,summary:`Interrupt session execution`,description:`Interrupt active execution owned by this OpenCode process. Returns interrupted=true when an active execution was interrupted and false for the idle no-op. When resume=true, execution resumes pending steering input and next-in-line control items (manual compaction, moves) while queued prompts remain parked.`}))).add(D(`session.background`,`/api/session/:sessionID/background`,{params:{sessionID:Y},success:T,error:G}).annotateMerge(k({identifier:`session.background`,summary:`Background blocking session tools`,description:`Move active foreground backgroundable tools for this session into background observation. Idle requests are a no-op.`}))).add(A(`session.message`,`/api/session/:sessionID/message/:messageID`,{params:{sessionID:Y,messageID:K},success:C({data:Pp}),error:[G,Lo]}).annotateMerge(k({identifier:`session.message.get`,summary:`Get session message`,description:`Retrieve one projected message owned by the Session.`}))).add(A(`session.form.list`,`/api/session/:sessionID/form`,{params:{sessionID:x},success:C({data:g(Ns)}),error:G}).middleware(t).annotateMerge(k({identifier:`session.form.list`,summary:`List session forms`,description:`Retrieve pending forms for a session.`}))).add(D(`session.form.create`,`/api/session/:sessionID/form`,{params:{sessionID:x},payload:vm,success:C({data:Ns}),error:[G,To,xo]}).middleware(t).annotateMerge(k({identifier:`session.form.create`,summary:`Create session form`,description:`Create a form for a session.`}))).add(A(`session.form.get`,`/api/session/:sessionID/form/:formID`,{params:{sessionID:x,formID:ys},success:C({data:Ls}),error:[G,Go]}).middleware(t).annotateMerge(k({identifier:`session.form.get`,summary:`Get session form`,description:`Retrieve a form and its current state for a session.`}))).add(D(`session.form.reply`,`/api/session/:sessionID/form/:formID/reply`,{params:{sessionID:x,formID:ys},payload:Rs,success:T,error:[G,Ko,qo,Go]}).middleware(t).annotateMerge(k({identifier:`session.form.reply`,summary:`Reply to form`,description:`Submit an answer to a pending form.`}))).add(ft(`session.form.cancel`,`/api/session/:sessionID/form/:formID`,{params:{sessionID:x,formID:ys},query:C({message:i(x)}),success:T,error:[G,Ko,Go]}).middleware(t).annotateMerge(k({identifier:`session.form.cancel`,summary:`Cancel form`,description:`Cancel a pending form, optionally telling the asker why it was not answered.`}))).add(St(`session.environment`,`/api/session/:sessionID/environment`,{params:{sessionID:Y},payload:C({variables:S(x,x)}),success:T,error:G}).annotateMerge(k({identifier:`session.environment`,summary:`Set session environment`,description:`Replace the process environment used by local shell commands for this session.`}))).add(D(`session.view`,`/api/session/:sessionID/view`,{params:{sessionID:Y},payload:C({idle:Ba}),success:T,error:G}).annotateMerge(k({identifier:`session.view`,summary:`View session`,description:`Mark the idle transition observed by the viewer as viewed.`}))).annotateMerge(k({title:`session`,description:`Experimental session routes.`})),Sm=e({ID:()=>Cm,Info:()=>wm,PermissionSaved:()=>Sm}),Cm=x.pipe(M(`PermissionSaved.ID`),O({identifier:`PermissionSaved.ID`}),za(e=>({create:()=>e.make(`psv_`+Wa())}))),wm=C({id:Cm,projectID:qa,action:x,resource:x,time:C({created:Ba,updated:Ba})}).annotate({identifier:`PermissionSaved.Info`}),Tm=(e,t)=>N(`server.permission`).add(A(`permission.request.list`,`/api/permission/request`,{query:X,success:V(g(Zl))}).middleware(e).annotateMerge(Z).annotateMerge(k({identifier:`permission.request.list`,summary:`List pending permission requests`,description:`Retrieve pending permission requests for a location.`}))).add(A(`permission.saved.list`,`/api/permission/saved`,{query:C({projectID:pu.pipe(i)}),success:C({data:g(wm)})}).middleware(e).annotateMerge(k({identifier:`permission.saved.list`,summary:`List saved permissions`,description:`Retrieve saved permissions, optionally filtered by project.`}))).add(ze(`permission.saved.update`,`/api/permission/saved/:id`,{params:{id:Cm},payload:C({action:x.pipe(i),resource:x.pipe(i)}),success:C({data:wm}),error:[Wo,To]}).annotateMerge(k({identifier:`permission.saved.update`,summary:`Update saved permission`,description:`Change the action or resource of a saved permission. Fails with a conflict when the project already has a saved permission with the same action and resource.`}))).add(ft(`permission.saved.remove`,`/api/permission/saved/:id`,{params:{id:Cm},success:T}).annotateMerge(k({identifier:`permission.saved.remove`,summary:`Remove saved permission`,description:`Remove a saved permission by ID.`}))).add(D(`session.permission.create`,`/api/session/:sessionID/permission`,{params:{sessionID:Y},payload:C({id:Jl.pipe(i),action:Zl.fields.action,resources:Zl.fields.resources,save:Zl.fields.save,metadata:Zl.fields.metadata,source:Zl.fields.source,agent:su.pipe(i)}),success:C({data:C({id:Jl,effect:nu})}),error:G}).middleware(t).annotateMerge(k({identifier:`session.permission.create`,summary:`Create permission request`,description:`Evaluate and, when approval is required, create a permission request for a session.`}))).add(A(`session.permission.list`,`/api/session/:sessionID/permission`,{params:{sessionID:Y},success:C({data:g(Zl)}),error:[G,bo]}).annotateMerge(k({identifier:`session.permission.list`,summary:`List session permission requests`,description:`Retrieve pending permission requests owned by a session.`}))).add(A(`session.permission.get`,`/api/session/:sessionID/permission/:requestID`,{params:{sessionID:Y,requestID:Jl},success:C({data:Zl}),error:[G,Uo]}).middleware(t).annotateMerge(k({identifier:`session.permission.get`,summary:`Get permission request`,description:`Retrieve a pending permission request owned by a session.`}))).add(D(`session.permission.reply`,`/api/session/:sessionID/permission/:requestID/reply`,{params:{sessionID:Y,requestID:Jl},payload:C({decision:Ql,message:x.pipe(i)}),success:T,error:[G,Uo]}).middleware(t).annotateMerge(k({identifier:`session.permission.reply`,summary:`Reply to pending permission request`,description:`Respond to a pending permission request owned by a session.`}))).annotateMerge(k({title:`permission`,description:`Experimental permission routes.`})),Em=e({Entry:()=>km,Event:()=>Om,FileSystem:()=>Em,FindInput:()=>Mm,Match:()=>jm,Submatch:()=>Am,Write:()=>Nm}),Dm=U({type:`filesystem.changed`,schema:{file:x,event:y([`add`,`change`,`unlink`])}}),Om={Changed:Dm,Definitions:W(Dm)},km=C({path:Ia,type:y([`file`,`directory`])}).annotate({identifier:`FileSystem.Entry`}),Am=C({text:x,start:z,end:z}).annotate({identifier:`FileSystem.Submatch`}),jm=C({entry:km,line:Fa,offset:z,text:x,submatches:g(Am)}).annotate({identifier:`FileSystem.Match`}),Mm=class extends p(`FileSystem.FindInput`)({query:x,type:y([`file`,`directory`]).pipe(B),limit:Fa.pipe(B)}){},Nm=C({path:La}).annotate({identifier:`FileSystem.Write`}),Pm=C({...X.fields,path:x.pipe(i).annotate({description:`An absolute path or a path relative to the requested location. Defaults to the location directory.`})}),Fm=C({...X.fields,path:x.annotate({description:`An absolute path or a path relative to the requested location. Missing parent directories are created.`})}),Im=C({path:x.annotate({description:`A file path relative to the requested location.`})}),Lm=C({...X.fields,query:Mm.fields.query,type:Mm.fields.type,limit:ae.pipe(wt(Fa),i)}),Rm=N(`server.fs`).add(A(`fs.read`,`/api/fs/read/*`,{query:X,success:dt.pipe(mt()),error:Po}).annotateMerge(Z).annotateMerge(k({identifier:`fs.read`,summary:`Read file`,description:`Stream one file relative to the requested location with ETag, Last-Modified, and single-range HTTP Range support (206 Partial Content, 416 Range Not Satisfiable, and 304 Not Modified; multi-range and malformed Range headers fall back to 200).`}))).add(A(`fs.list`,`/api/fs/list`,{query:Pm,success:V(g(km)),error:Po}).annotateMerge(Z).annotateMerge(k({identifier:`fs.list`,summary:`List directory`,description:`List direct children using an absolute path or a path relative to the requested location, including parents and siblings outside its directory. Entry paths remain relative to the requested location; listing does not switch locations.`}))).add(A(`fs.find`,`/api/fs/find`,{query:Lm,success:V(g(km))}).annotateMerge(Z).annotateMerge(k({identifier:`fs.find`,summary:`Find files`,description:`Find recursively ranked filesystem entries relative to the requested location.`}))).add(D(`fs.write`,`/api/experimental/fs/write`,{query:Fm,payload:dt.pipe(mt()),success:V(Nm)}).annotateMerge(Z).annotateMerge(k({identifier:`experimental.fs.write`,summary:`Write file`,description:`Write the raw request body to an absolute path or a path relative to the requested location, creating parent directories, and return the resolved absolute path. Unlike read, the target is not confined to the location. Experimental: may change without compatibility guarantees.`}))).add(D(`fs.watch`,`/api/experimental/fs/watch`,{query:X,payload:Im,success:T,error:[Po,Do]}).annotateMerge(Z).annotateMerge(k({identifier:`experimental.fs.watch`,summary:`Watch file`,description:`Watch one file relative to the requested location for 24 hours, publishing filesystem.changed on that location when it changes. Watching an already watched file resets its expiry. Paths follow read confinement. Experimental: may change without compatibility guarantees.`}))).add(ft(`fs.unwatch`,`/api/experimental/fs/watch`,{query:X,payload:Im,success:T}).annotateMerge(Z).annotateMerge(k({identifier:`experimental.fs.unwatch`,summary:`Unwatch file`,description:`Stop watching one file relative to the requested location. Experimental: may change without compatibility guarantees.`}))).annotateMerge(k({title:`filesystem`,description:`Experimental location-scoped filesystem routes.`})),zm=e=>N(`server.form`).add(A(`form.list`,`/api/form`,{query:X,success:V(g(Ns))}).annotateMerge(Z).annotateMerge(k({identifier:`form.list`,summary:`List pending forms`,description:`Retrieve pending forms for a location.`}))).middleware(e).annotateMerge(k({title:`form`,description:`Location form routes.`})),Bm=e({Command:()=>Bm,Event:()=>Um,Info:()=>Hm}),Vm=U({type:`command.updated`,schema:{}}),Hm=C({name:x,description:x.pipe(B)}).annotate({identifier:`Command.Info`}),Um={Updated:Vm,Definitions:W(Vm)},Wm=N(`server.command`).add(A(`command.list`,`/api/command`,{query:X,success:V(g(Hm))}).annotateMerge(Z).annotateMerge(k({identifier:`command.list`,summary:`List commands`,description:`Retrieve currently registered commands.`}))).annotateMerge(k({title:`command`,description:`Experimental command routes.`})),Gm=N(`server.skill`).add(A(`skill.list`,`/api/skill`,{query:X,success:V(g(ho))}).annotateMerge(Z).annotateMerge(k({identifier:`skill.list`,summary:`List skills`,description:`Retrieve currently registered skills.`}))).annotateMerge(k({title:`skill`,description:`Experimental skill routes.`})),Km=C({input:B(Ie)}).annotate({identifier:`Rpc.Input`}),qm=C({output:tt(Ie)}).annotate({identifier:`Rpc.Output`}),Jm=N(`server.rpc`).add(D(`rpc.call`,`/api/rpc/:rpcID/:method`,{params:{rpcID:x,method:x},query:X,payload:Km,success:qm,error:[So,Co]}).annotateMerge(Z).annotateMerge(k({identifier:`rpc.call`,summary:`Call a plugin RPC`,description:`Dispatch a method to the currently registered RPC at the requested location.`}))).annotateMerge(k({title:`rpc`,description:`Plugin RPC routes.`})),Ym=hc.check(Ce(/^[^/#]+$/u)),Xm=Nc.check(Ce(/^[^#]+$/u)),Zm=Ic.check(Ce(/^[^#]+$/u)),Qm=C({providerID:Ym,model:Xm,variant:Zm.pipe(B)}),$m=x.check(Ce(/^[^/#]+\/[^#]+(?:#[^#]+)?$/u)),eh=E([$m,Qm]).pipe(wt(Qm,{decode:m(e=>typeof e==`string`?th(e):e),encode:b({strict:!1})})).annotate({identifier:`Config.ModelSelection`});function th(e){let t=Lc.parse(e);return{providerID:t.providerID,model:t.id,...t.variant?{variant:t.variant}:{}}}var nh=ge(C(Ec.schema.fields),[S(x,yt(Te))]).annotate({identifier:`Config.Provider.Settings`}),rh=ge(C(Bc.schema.fields),[S(x,yt(Te))]).annotate({identifier:`Config.Model.Settings`}),ih=S(x,Te),ah={settings:nh.pipe(B),headers:S(x,x).pipe(B),body:ih.pipe(B)},oh={settings:rh.pipe(B),headers:S(x,x).pipe(B),body:ih.pipe(B)},sh=class extends p(`Config.Provider.Request`)({headers:ah.headers,body:ah.body}){},ch=class extends p(`Config.Model.Cost.Cache`)({read:jc.pipe(B),write:jc.pipe(B)}){},lh=class extends p(`Config.Model.Cost`)({tier:C({type:h(`context`),size:a}).pipe(B),input:jc,output:jc,cache:ch.pipe(B)}){},uh=class extends p(`Config.Model.Limit`)({context:a.pipe(B),input:a.pipe(B),output:a.pipe(B)}){},dh=E([C({supported:h(!1)}),C({supported:h(!0),toggle:v.pipe(B),effort:x.pipe(g,B),budget:C({min:a.pipe(B),max:a.pipe(B)}).pipe(B)})]).annotate({identifier:`Config.Model.Reasoning`}),fh=class extends p(`Config.Model`)({modelID:Nc.pipe(B),type:zc.pipe(B),family:Rc.pipe(B),name:x.pipe(B),releaseDate:x.check(Ce(/^\d{4}-\d{2}(-\d{2})?$/u)).annotate({description:`Release date as YYYY-MM-DD or YYYY-MM`}).pipe(B),compatibility:fc.pipe(B),package:x.pipe(B),...oh,capabilities:Hc.mapFields(e=>({tools:B(e.tools),input:B(e.input),output:B(e.output),temperature:e.temperature,reasoning:dh.pipe(B)})).annotate({identifier:`Config.Model.Capabilities`}).pipe(B),variants:C({id:Ic,...oh}).pipe(g,B),cost:E([lh,lh.pipe(g)]).pipe(B),disabled:v.pipe(B),limit:uh.pipe(B)}){},ph=class extends p(`Config.Provider`)({canonical:hc.pipe(B),name:x.pipe(B),env:x.pipe(g,B),package:x.pipe(B),compatibility:pc.pipe(B),...ah,models:S(x,fh).pipe(B)}){},mh=x.check(Ce(/^#[0-9a-fA-F]{6}$/u)),hh=class extends p(`Config.Agent`)({model:eh.pipe(B),request:sh.pipe(B),system:x.pipe(B),description:x.pipe(B),mode:y([`subagent`,`primary`,`all`]).pipe(B),hidden:v.pipe(B),color:mh.pipe(Be(()=>Ke),B),steps:Fa.pipe(B),disabled:v.pipe(B),permissions:iu.pipe(B)}){},gh=class extends p(`Config.Media.Image`)({auto_resize:v.pipe(B),max_width:Fa.pipe(B),max_height:Fa.pipe(B),max_base64_bytes:Fa.pipe(B)}){},_h=class extends p(`Config.Media`)({image:gh.pipe(B)}){},vh=class extends p(`Config.Compaction.Keep`)({tokens:z.pipe(B)}){},yh=class extends p(`Config.Compaction`)({auto:v.pipe(B),keep:vh.pipe(B),buffer:z.pipe(B)}){},bh=class extends p(`Config.Command`)({template:x,description:x.pipe(B),agent:x.pipe(B),model:eh.pipe(B),subagent:v.pipe(B),subtask:v.annotate({description:`Deprecated alias for subagent.`}).pipe(B)}){},xh=y([`allow`,`deny`]),Sh=C({action:y([`provider.use`,`tool.use`,`integration.use`]),resource:x,effect:xh}),Ch=class extends p(`ConfigExperimental.Info`)({portable_shell_scanner:v.pipe(B).annotate({description:`Enable the experimental portable shell permission scanner. Defaults to false.`}),todo:v.pipe(B).annotate({description:`Enable the experimental todowrite tool. Defaults to false.`}),background_compaction:v.pipe(B).annotate({description:`Enable experimental background compaction: summarize the conversation in the background as it nears the compaction threshold, so automatic compaction does not wait for the summary. Background summaries that are never used still cost tokens. Defaults to false.`}),media_blob:v.pipe(B).annotate({description:`Store new session media once in a deduplicated blob table instead of inline in every message row. Defaults to false.`}),subagent_depth:z.pipe(B).annotate({description:`Maximum subagent nesting depth. Defaults to 1.`}),location_idle_timeout:E([ve,h(!1)]).pipe(B).annotate({description:`How long a location can go without session activity before its services are unloaded. Running sessions and background jobs keep a location loaded. Set to false to never unload (default: "60 minutes")`}),policies:Sh.pipe(g,B).annotate({description:`Deprecated: use top-level policies. Ordered policies controlling access to configured resources`})}){},wh=class extends p(`Config.Formatter.Entry`)({disabled:v.pipe(B),command:x.pipe(g,B),environment:S(x,x).pipe(B),extensions:x.pipe(g,B)}){},Th=E([v,S(x,wh)]),Eh=C({disabled:h(!0)}),Dh=class extends p(`Config.LSP.Server`)({command:x.pipe(g),extensions:x.pipe(g,B),disabled:v.pipe(B),env:S(x,x).pipe(B),initialization:S(x,Ie).pipe(B)}){},Oh=E([Eh,Dh]),kh=E([v,S(x,Oh)]),Ah=class extends p(`Mcp.TimeoutConfig`)({startup:Fa.pipe(B).annotate({description:`Maximum time in milliseconds to establish and initialize the MCP server.`}),catalog:Fa.pipe(B).annotate({description:`Maximum time in milliseconds to wait for MCP discovery requests such as tools/list and prompts/list.`}),execution:Fa.pipe(B).annotate({description:`Maximum time in milliseconds to wait for MCP tool and prompt execution.`})}){},jh=y([`legacy`,`auto`,`2026-07-28`]).annotate({identifier:`Mcp.Protocol`,description:`MCP protocol negotiation. "legacy" (default) opens with the initialize handshake and speaks protocol revisions up to 2025-11-25. "auto" probes for the 2026-07-28 revision and falls back to legacy when the server does not support it. "2026-07-28" requires that revision and fails otherwise.`}),Mh=class extends p(`Mcp.LocalConfig`)({type:h(`local`),command:x.pipe(g),cwd:x.pipe(B).annotate({description:`Working directory for the MCP server process. Relative paths resolve from the workspace directory.`}),environment:S(x,x).pipe(B),disabled:v.pipe(B),codemode:v.pipe(B).annotate({description:`Expose this server's tools through Code Mode. Defaults to true.`}),timeout:Ah.pipe(B),protocol:jh.pipe(B)}){},Nh=class extends p(`Mcp.OAuthConfig`)({client_id:x.pipe(B),client_secret:x.pipe(B),scope:x.pipe(B),callback_port:a.check(Dt({minimum:1,maximum:65535})).pipe(B),redirect_uri:x.pipe(B),auth_server_metadata_url:x.pipe(B).annotate({description:`URL of the OAuth or OpenID Connect authorization server metadata document. Set when the MCP server does not publish protected resource metadata that names its authorization server.`})}){},Ph=class extends p(`Mcp.RemoteConfig`)({type:h(`remote`),url:x,headers:S(x,x).pipe(B),oauth:E([Nh,h(!1)]).pipe(B),disabled:v.pipe(B),codemode:v.pipe(B).annotate({description:`Expose this server's tools through Code Mode. Defaults to true.`}),timeout:Ah.pipe(B),protocol:jh.pipe(B)}){},Fh=E([Mh,Ph]).pipe(ie(`type`)),Ih=C({status:h(`connected`)}).annotate({identifier:`Mcp.Status.Connected`}),Lh=C({status:h(`pending`)}).annotate({identifier:`Mcp.Status.Pending`}),Rh=C({status:h(`disabled`)}).annotate({identifier:`Mcp.Status.Disabled`}),zh=C({status:h(`failed`),error:x}).annotate({identifier:`Mcp.Status.Failed`}),Bh=C({status:h(`needs_auth`),error:x}).annotate({identifier:`Mcp.Status.NeedsAuth`}),Vh=E([Ih,Lh,Rh,zh,Bh]).pipe(ie(`status`)),Hh=C({name:x,status:Vh,title:B(x),integrationID:B(ts)}).annotate({identifier:`Mcp.Server`}),Uh=C({server:x,name:x,uri:x,description:B(x),mimeType:B(x)}).annotate({identifier:`Mcp.Resource`}),Wh=C({server:x,name:x,uriTemplate:x,description:B(x),mimeType:B(x)}).annotate({identifier:`Mcp.ResourceTemplate`}),Gh=C({resources:g(Uh),templates:g(Wh)}).annotate({identifier:`Mcp.ResourceCatalog`}),Kh=E([C({type:h(`text`),uri:x,text:x,mimeType:B(x)}),C({type:h(`blob`),uri:x,blob:x,mimeType:B(x)})]).pipe(ie(`type`),O({identifier:`Mcp.ResourceContentPart`}));C({server:x,uri:x,contents:g(Kh)}).annotate({identifier:`Mcp.ResourceContent`});var qh=Ah,Jh=Fh,Yh=class extends p(`Config.MCP`)({timeout:qh.pipe(B),servers:S(x,Jh).pipe(B)}){},Xh=class extends p(`Config.Plugin.Entry`)({package:x,options:S(x,Ie).pipe(B)}){},Zh=E([x,Xh]).pipe(g),Qh=class extends p(`Config.Reference.Git`)({repository:x,branch:x.pipe(B),description:x.pipe(B),hidden:v.pipe(B)}){},$h=class extends p(`Config.Reference.Local`)({path:x,description:x.pipe(B),hidden:v.pipe(B)}){},eg=E([x,Qh,$h]),tg=S(x,eg),ng=e({Event:()=>lg,ID:()=>rg,Input:()=>ag,Provider:()=>ig,Response:()=>sg,Result:()=>og,WebSearch:()=>ng}),rg=x.pipe(M(`WebSearch.ID`),O({identifier:`WebSearch.ID`})),ig=C({id:rg,name:x}).annotate({identifier:`WebSearch.Provider`}),ag=C({query:x,providerID:rg.pipe(B)}).annotate({identifier:`WebSearch.Input`}),og=C({url:x,title:x.pipe(B),content:x.pipe(B),time:C({published:P.pipe(B).annotate({description:`Publication time in milliseconds since the Unix epoch`})})}).annotate({identifier:`WebSearch.Result`}),sg=class extends p(`WebSearch.Response`)({providerID:rg,results:g(og)}){},cg=U({type:`websearch.updated`,schema:{}}),lg={Updated:cg,Definitions:W(cg)},ug=class extends p(`ConfigWebSearch.Info`)({provider:E([h(`random`).annotate({description:`Reuse a randomly selected provider until it is rate limited, then switch to another available provider.`}),rg])}){},dg=E([h(!1),ug]),fg=class extends p(`Config.ToolOutput`)({max_lines:Fa.pipe(B),max_bytes:Fa.pipe(B)}){},pg=class extends p(`Config.Watcher`)({ignore:x.pipe(g,B)}){},mg=class extends p(`Config.Warming`)({prompt:x.pipe(B).annotate({description:`Prompt sent for keep-alive requests`}),interval:ve.pipe(B).annotate({description:`Idle time between keep-alive requests (default: "4 minutes")`}),duration:ve.pipe(B).annotate({description:`Time after the last active request to keep a session warm (default: "30 minutes")`})}){},hg=E([v,mg]),gg=C({directory:xt.pipe(at(kt())).annotate({description:`Parent directory for new worktrees, relative to the project's primary checkout when not absolute`})}).annotate({identifier:`Config.Worktree`}),_g=e({Config:()=>_g,Directory:()=>xg,Document:()=>bg,Entry:()=>Sg,Event:()=>wg,Info:()=>vg,Patch:()=>yg}),vg=class extends p(`Config.Info`)({$schema:B(x).annotate({description:`JSON schema reference for configuration validation`}),shell:x.pipe(B).annotate({description:`Default shell to use for terminal and shell tool execution`}),model:eh.pipe(B).annotate({description:`Default model to use when no session or agent model is selected`}),default_agent:x.pipe(B).annotate({description:`Default primary agent to use when no session agent is selected`}),update:y([`disable`,`notify`,`auto`]).pipe(B).annotate({description:`Disable updates, notify when one is available, or install updates automatically`}),share:y([`manual`,`auto`,`disabled`]).pipe(B).annotate({description:`Control whether sessions may be shared manually, automatically, or not at all`}),enterprise:C({url:x.pipe(B)}).pipe(B).annotate({description:`Enterprise sharing service configuration`}),username:x.pipe(B).annotate({description:`Username displayed in conversations and used for telemetry identity`}),permissions:iu.pipe(B).annotate({description:`Ordered tool permission rules applied to agent tool use`}),policies:Sh.pipe(g,B).annotate({description:`Ordered policies controlling access to providers, tools, and integrations`}),agents:S(x,hh).pipe(B).annotate({description:`Named built-in agent overrides and custom agent definitions`}),snapshots:v.pipe(B).annotate({description:`Enable snapshots used for undo and revert behavior`}),watcher:pg.pipe(B).annotate({description:`Filesystem watcher configuration`}),formatter:Th.pipe(B).annotate({description:`Enable built-in formatters or configure formatter overrides`}),lsp:kh.pipe(B).annotate({description:`Enable built-in language servers or configure server overrides`}),media:_h.pipe(B).annotate({description:`Media processing configuration`}),tool_output:fg.pipe(B).annotate({description:`Tool output truncation thresholds`}),mcp:Yh.pipe(B).annotate({description:`MCP server configuration`}),compaction:yh.pipe(B).annotate({description:`Conversation compaction behavior`}),skills:x.pipe(g,B).annotate({description:`Additional paths or URLs to discover skills from`}),commands:S(x,bh).pipe(B).annotate({description:`Named slash command definitions`}),instructions:x.pipe(g,B).annotate({description:`Additional paths or URLs supplying ambient instructions`}),references:tg.pipe(B).annotate({description:`Named local directories or Git repositories available as external context`}),websearch:dg.pipe(B).annotate({description:`Web search provider selection`}),plugins:Zh.pipe(B).annotate({description:`Ordered plugin enablement directives and external package declarations`}),worktree:gg.pipe(B).annotate({description:`Directory defaults for local worktree creation`}),warming:hg.pipe(B).annotate({description:`Keep recently active sessions warm with transient model requests (default: false)`}),providers:S(x,ph).pipe(B),experimental:Ch.pipe(B)}){},yg=C({shell:se(x)}).annotate({identifier:`Config.Patch`}),bg=class extends p(`Config.Document`)({type:h(`document`),path:La.pipe(B),info:vg}){},xg=class extends p(`Config.Directory`)({type:h(`directory`),path:La}){},Sg=E([bg,xg]).annotate({identifier:`Config.Entry`}),Cg=U({type:`config.updated`,schema:{}}),wg={Updated:Cg,Definitions:W(Cg)},Tg=e({CreateInput:()=>Dg,Directory:()=>Ag,Event:()=>Ig,Info:()=>kg,List:()=>Ng,ListEntry:()=>jg,OperationError:()=>Mg,RemoveInput:()=>Og,StrategyID:()=>Eg,Worktree:()=>Tg,adopt:()=>Lg}),Eg=xt.pipe(at(kt()),M(`Worktree.StrategyID`)),Dg=C({projectID:pu,from:B(La),branch:B(xt.pipe(at(kt()))),directory:B(La).annotate({description:`Parent directory for the new worktree. Uses the project's canonical configuration, then defaults to the server's data directory under worktree/<first six project ID characters>.`}),name:B(x)}).annotate({identifier:`Worktree.CreateInput`}),Og=C({projectID:pu,directory:La,force:v}).annotate({identifier:`Worktree.RemoveInput`}),kg=C({directory:La}).annotate({identifier:`Worktree.Info`}),Ag=C({directory:La,strategy:B(x)}).annotate({identifier:`Worktree.Directory`}),jg=C({directory:La,type:y([`root`,`worktree`])}).annotate({identifier:`Worktree.ListEntry`}),Mg=class extends t()(`Worktree.OperationError`,{message:x,forceRequired:B(v)}){},Ng=g(Ag).annotate({identifier:`Worktree.List`}),Pg=U({type:`worktree.updated`,schema:{projectID:pu}}),Fg=H({type:`worktree.resolved`,durable:{aggregate:`projectID`,version:1},schema:{projectID:pu,directory:La,previous:pu,adopted:B(g(pu))}}),Ig={Updated:Pg,Resolved:Fg,Definitions:W(Pg,Fg)};function Lg(e,t){if(e.workspaceID||e.projectID!==t.previous&&e.projectID!==pu.global&&!t.adopted?.includes(e.projectID)||e.projectID===t.projectID)return;let n=e=>e.replaceAll(`\\`,`/`).split(`/`).reduce((e,t)=>!t||t===`.`?e:t===`..`?e.slice(0,e.lastIndexOf(`/`)):`${e}/${t}`,``),r=n(e.directory),i=n(t.directory),a=/^\/[a-z]:/i.test(i),o=a?r.toLowerCase():r,s=a?i.toLowerCase():i;if(!(o!==s&&!o.startsWith(s+`/`)))return{projectID:t.projectID,subpath:o===s?void 0:r.slice(i.length+1)}}so([...Bf,Ig.Resolved]);var Rg=U({type:`file.edited`,schema:{file:x}}),zg={Edited:Rg,Definitions:W(Rg)},Bg=W(U({type:`installation.updated`,schema:{version:x}}),U({type:`installation.update-available`,schema:{version:x}})),Vg=x.check(me(`per`)).pipe(M(`PermissionV1.ID`),za(e=>({ascending:t=>e.make(t??`per_`+Wa())}))),Hg=y([`allow`,`deny`,`ask`]).annotate({identifier:`PermissionV1.Action`}),Ug=C({permission:x,pattern:x,action:Hg}).annotate({identifier:`PermissionV1.Rule`}),Wg=g(Ug).annotate({identifier:`PermissionV1.Ruleset`}),Gg=C({id:Vg,sessionID:Kl,permission:x,patterns:g(x),metadata:S(x,Ie),always:g(x),tool:i(C({messageID:x,callID:x}))}).annotate({identifier:`PermissionV1.Request`}),Kg=y([`once`,`always`,`reject`]),qg=C({reply:Kg,message:i(x)}).annotate({identifier:`PermissionV1.ReplyBody`});C({projectID:pu,patterns:g(x)}).annotate({identifier:`PermissionV1.Approval`}),C({...Gg.fields,id:i(Vg),ruleset:Wg}).annotate({identifier:`PermissionV1.AskInput`}),C({requestID:Vg,...qg.fields}).annotate({identifier:`PermissionV1.ReplyInput`}),W(U({type:`permission.asked`,schema:Gg.fields}),U({type:`permission.replied`,schema:{sessionID:Kl,requestID:Vg,reply:Kg}}));var Jg=P.check(Re(0)),Yg=x.check(me(`msg`)).pipe(M(`SessionV1.MessageID`),za(e=>({ascending:t=>e.make(t??`msg_`+Wa())}))),Xg=x.check(me(`prt`)).pipe(M(`SessionV1.PartID`),za(e=>({ascending:t=>e.make(t??`prt_`+Wa())}))),Zg=(e,t)=>{let n=C({name:h(e),data:C(t)}).annotate({identifier:e});return{Schema:n,EffectSchema:n}},Qg=Zg(`MessageOutputLengthError`,{}),$g=Zg(`ProviderAuthError`,{providerID:x,message:x}),e_=Zg(`MessageAbortedError`,{message:x}),t_=Zg(`StructuredOutputError`,{message:x,retries:z}),n_=Zg(`APIError`,{message:x,statusCode:i(z),isRetryable:v,responseHeaders:i(S(x,x)),responseBody:i(x),metadata:i(S(x,x))}),r_=Zg(`ContextOverflowError`,{message:x,responseBody:i(x)}),i_=Zg(`ContentFilterError`,{message:x}),a_=class extends p(`OutputFormatText`)({type:h(`text`)}){},o_=class extends p(`OutputFormatJsonSchema`)({type:h(`json_schema`),schema:S(x,et).annotate({identifier:`SessionV1.JSONSchema`}),retryCount:z.pipe(i,Pt(Ve(2)))}){},s_=E([a_,o_]).annotate({discriminator:`type`,identifier:`SessionV1.OutputFormat`}),c_={id:Xg,sessionID:Kl,messageID:Yg},l_=C({...c_,type:h(`snapshot`),snapshot:x}).annotate({identifier:`SessionV1.SnapshotPart`}),u_=C({...c_,type:h(`patch`),hash:x,files:g(x)}).annotate({identifier:`SessionV1.PatchPart`}),d_=C({...c_,type:h(`text`),text:x,synthetic:i(v),ignored:i(v),time:i(C({start:z,end:i(z)})),metadata:i(S(x,et))}).annotate({identifier:`SessionV1.TextPart`}),f_=C({...c_,type:h(`reasoning`),text:x,metadata:i(S(x,et)),time:C({start:z,end:i(z)})}).annotate({identifier:`SessionV1.ReasoningPart`}),p_={text:C({value:x,start:P,end:P}).annotate({identifier:`SessionV1.FilePartSourceText`})},m_=C({start:C({line:z,character:z}),end:C({line:z,character:z})}).annotate({identifier:`SessionV1.Range`}),h_=C({...p_,type:h(`file`),path:x}).annotate({identifier:`SessionV1.FileSource`}),g_=C({...p_,type:h(`symbol`),path:x,range:m_,name:x,kind:z}).annotate({identifier:`SessionV1.SymbolSource`}),__=C({...p_,type:h(`resource`),clientName:x,uri:x}).annotate({identifier:`SessionV1.ResourceSource`}),v_=E([h_,g_,__]).annotate({discriminator:`type`,identifier:`SessionV1.FilePartSource`}),y_=C({...c_,type:h(`file`),mime:x,filename:i(x),url:x,source:i(v_)}).annotate({identifier:`SessionV1.FilePart`}),b_=C({...c_,type:h(`agent`),name:x,source:i(C({value:x,start:z,end:z}))}).annotate({identifier:`SessionV1.AgentPart`}),x_=C({...c_,type:h(`compaction`),auto:v,overflow:i(v),tail_start_id:i(Yg)}).annotate({identifier:`SessionV1.CompactionPart`}),S_=C({...c_,type:h(`subtask`),prompt:x,description:x,agent:x,model:i(C({providerID:hc,modelID:Nc})),command:i(x)}).annotate({identifier:`SessionV1.SubtaskPart`}),C_=C({...c_,type:h(`retry`),attempt:z,error:n_.EffectSchema,time:C({created:z})}).annotate({identifier:`SessionV1.RetryPart`}),w_=C({...c_,type:h(`step-start`),snapshot:i(x)}).annotate({identifier:`SessionV1.StepStartPart`}),T_=C({...c_,type:h(`step-finish`),reason:x,snapshot:i(x),cost:P,tokens:C({total:i(P),input:P,output:P,reasoning:P,cache:C({read:P,write:P})})}).annotate({identifier:`SessionV1.StepFinishPart`}),E_=C({status:h(`pending`),input:S(x,et),raw:x}).annotate({identifier:`SessionV1.ToolStatePending`}),D_=C({status:h(`running`),input:S(x,et),title:i(x),metadata:i(S(x,et)),time:C({start:z})}).annotate({identifier:`SessionV1.ToolStateRunning`}),O_=C({status:h(`completed`),input:S(x,et),output:x,title:x,metadata:S(x,et),time:C({start:z,end:z,compacted:i(z)}),attachments:i(g(y_))}).annotate({identifier:`SessionV1.ToolStateCompleted`}),k_=C({status:h(`error`),input:S(x,et),error:x,metadata:i(S(x,et)),time:C({start:z,end:z})}).annotate({identifier:`SessionV1.ToolStateError`}),A_=E([E_,D_,O_,k_]).annotate({discriminator:`status`,identifier:`SessionV1.ToolState`}),j_=C({...c_,type:h(`tool`),callID:x,tool:x,state:A_,metadata:i(S(x,et))}).annotate({identifier:`SessionV1.ToolPart`}),M_={id:Yg,sessionID:c_.sessionID},N_=C({...M_,role:h(`user`),time:C({created:Jg}),format:i(s_),summary:i(C({title:i(x),body:i(x),diffs:g(Cd)})),agent:x,model:C({providerID:hc,modelID:Nc,variant:i(x)}),system:i(x),tools:i(S(x,v))}).annotate({identifier:`SessionV1.UserMessage`}),P_=E([d_,S_,f_,y_,j_,w_,T_,l_,u_,b_,C_,x_]).annotate({discriminator:`type`,identifier:`SessionV1.Part`}),F_=E([$g.EffectSchema,Zg(`UnknownError`,{message:x,ref:i(x)}).EffectSchema,Qg.EffectSchema,e_.EffectSchema,t_.EffectSchema,r_.EffectSchema,i_.EffectSchema,n_.EffectSchema]).annotate({discriminator:`name`});C({id:i(Xg),type:h(`text`),text:x,synthetic:i(v),ignored:i(v),time:i(C({start:z,end:i(z)})),metadata:i(S(x,et))}).annotate({identifier:`SessionV1.TextPartInput`}),C({id:i(Xg),type:h(`file`),mime:x,filename:i(x),url:x,source:i(v_)}).annotate({identifier:`SessionV1.FilePartInput`}),C({id:i(Xg),type:h(`agent`),name:x,source:i(C({value:x,start:z,end:z}))}).annotate({identifier:`SessionV1.AgentPartInput`}),C({id:i(Xg),type:h(`subtask`),prompt:x,description:x,agent:x,model:i(C({providerID:hc,modelID:Nc})),command:i(x)}).annotate({identifier:`SessionV1.SubtaskPartInput`});var I_=C({...M_,role:h(`assistant`),time:C({created:z,completed:i(z)}),error:i(F_),parentID:Yg,modelID:Nc,providerID:hc,mode:x,agent:x,path:C({cwd:x,root:x}),summary:i(v),cost:P,tokens:C({total:i(P),input:P,output:P,reasoning:P,cache:C({read:P,write:P})}),structured:i(et),variant:i(x),finish:i(x)}).annotate({identifier:`SessionV1.AssistantMessage`}),L_=E([N_,I_]).annotate({discriminator:`role`,identifier:`SessionV1.Message`}),R_={durable:{aggregate:`sessionID`,version:1}},z_=C({additions:P,deletions:P,files:P,diffs:B(g(Cd))}),B_=C({input:P,output:P,reasoning:P,cache:C({read:P,write:P})}),V_=C({url:x}),H_=C({messageID:Yg,partID:B(Xg),snapshot:B(x),diff:B(x)}),U_=C({id:Nc,providerID:hc,variant:B(x)}),W_=C({id:Kl,slug:x,projectID:pu,workspaceID:B(Ja),directory:x,path:B(x),parentID:B(Kl),summary:B(z_),cost:B(P),tokens:B(B_),share:B(V_),title:B(x),agent:B(x),model:B(U_),version:x,metadata:B(S(x,et)),time:C({created:z,updated:z,compacting:B(z),archived:B(P)}),permission:B(Wg),revert:B(H_)}).annotate({identifier:`SessionV1.Info`}),G_={Created:H({type:`session.created`,...R_,schema:{sessionID:Kl,info:W_}}),Updated:H({type:`session.updated`,...R_,schema:{sessionID:Kl,info:W_}}),Deleted:H({type:`session.deleted`,...R_,schema:{sessionID:Kl,info:W_}}),MessageUpdated:H({type:`message.updated`,...R_,schema:{sessionID:Kl,info:L_}}),MessageRemoved:H({type:`message.removed`,...R_,schema:{sessionID:Kl,messageID:Yg}}),PartUpdated:H({type:`message.part.updated`,...R_,schema:{sessionID:Kl,part:P_,time:P}}),PartRemoved:H({type:`message.part.removed`,...R_,schema:{sessionID:Kl,messageID:Yg,partID:Xg}})},K_=U({type:`message.part.delta`,schema:{sessionID:Kl,messageID:Yg,partID:Xg,field:x,delta:x}}),q_=U({type:`session.diff`,schema:{sessionID:Kl,diff:g(Cd)}}),J_=U({type:`session.error`,schema:{sessionID:i(Kl),error:I_.fields.error}});({...G_}),W(G_.Created,G_.Updated,G_.Deleted,G_.MessageUpdated,G_.MessageRemoved,G_.PartUpdated,G_.PartRemoved,K_,q_,J_);var Y_=W(U({type:`command.executed`,schema:{name:x,sessionID:Kl,arguments:x,messageID:Yg}})),X_=W(U({type:`lsp.updated`,schema:{}})),Z_=W(U({type:`location.shutdown`,schema:{}})),Q_=U({type:`mcp.tools.changed`,schema:{server:x}}),$_=U({type:`mcp.resources.changed`,schema:{server:x}}),ev=U({type:`mcp.status.changed`,schema:{server:x}}),tv=W(Q_,$_,ev),nv=U({type:`models-dev.refreshed`,schema:{}}),rv={Refreshed:nv,Definitions:W(nv)},iv=x.pipe(M(`Plugin.ID`),O({identifier:`Plugin.ID`})),av=E([C({type:h(`builtin`)}),C({type:h(`package`),target:x,version:x.pipe(B),outdated:h(!0).pipe(B),updating:h(!0).pipe(B)}),C({type:h(`local`),path:x}),C({type:h(`sdk`)})]).annotate({identifier:`Plugin.Source`}),ov=C({server:h(!0).pipe(B),tui:h(!0).pipe(B),rpc:h(!0).pipe(B),gui:h(!0).pipe(B)}).annotate({identifier:`Plugin.Features`}),sv=C({code:x,revision:x,options:S(x,Te)}).annotate({identifier:`Plugin.GuiBundle`}),cv=E([C({status:h(`active`)}),C({status:h(`failed`),error:x,ref:x.pipe(B)})]).annotate({identifier:`Plugin.State`}),lv=C({id:iv.pipe(B),source:av,features:ov,state:cv}).annotate({identifier:`Plugin.Info`}),uv=U({type:`plugin.updated`,schema:{}}),dv={Updated:uv,Definitions:W(uv)},fv=e({Event:()=>mv,GitSource:()=>gv,Info:()=>vv,LocalSource:()=>hv,Reference:()=>fv,Source:()=>_v}),pv=U({type:`reference.updated`,schema:{}}),mv={Updated:pv,Definitions:W(pv)},hv=C({type:h(`local`),path:La,description:x.pipe(B),hidden:v.pipe(B)}).annotate({identifier:`Reference.LocalSource`}),gv=C({type:h(`git`),repository:x,branch:x.pipe(B),description:x.pipe(B),hidden:v.pipe(B)}).annotate({identifier:`Reference.GitSource`}),_v=E([hv,gv]).pipe(ie(`type`)).annotate({identifier:`Reference.Source`}),vv=C({name:x,path:La,description:x.pipe(B),hidden:v.pipe(B),source:_v}).annotate({identifier:`Reference.Info`}),yv=W(U({type:`server.connected`,schema:{}}),U({type:`global.disposed`,schema:{}})),bv=W(U({type:`session.status`,identifier:`SessionStatusUpdated`,schema:{sessionID:Kl,status:E([C({type:h(`idle`)}),C({type:h(`retry`),attempt:z,message:x,action:B(C({reason:x,provider:x,title:x,message:x,label:x,link:B(x)})),next:z}),C({type:h(`busy`)})]).annotate({identifier:`SessionStatus`})}}),U({type:`session.idle`,schema:{sessionID:Kl}})),xv=W(U({type:`tui.prompt.append`,schema:{text:x}}),U({type:`tui.command.execute`,schema:{command:E([y([`session.list`,`session.new`,`session.interrupt`,`session.background`,`session.compact`,`session.page.up`,`session.page.down`,`session.line.up`,`session.line.down`,`session.half.page.up`,`session.half.page.down`,`session.first`,`session.last`,`prompt.clear`,`prompt.submit`,`agent.cycle`]),x])}}),U({type:`tui.toast.show`,schema:{title:B(x),message:x,variant:y([`info`,`success`,`warning`,`error`]),duration:Fa.pipe(Pt(Ve(5e3))).annotate({description:`Duration in milliseconds`})}}),U({type:`tui.session.select`,schema:{sessionID:Kl.annotate({description:`Session ID to navigate to`})}})),Sv=W(U({type:`vcs.branch.updated`,schema:{branch:B(x)}})),Cv=C({workspaceID:Ja,status:y([`connected`,`connecting`,`disconnected`,`error`])}).annotate({identifier:`WorkspaceEvent.ConnectionStatus`}),wv=W(U({type:`workspace.ready`,schema:{name:x}}),U({type:`workspace.failed`,schema:{message:x}}),U({type:`workspace.status`,schema:Cv.fields})),Tv=W(U({type:`worktree.ready`,schema:{name:x,branch:B(x)}}),U({type:`worktree.failed`,schema:{message:x}})),Ev=W(...zf),Dv=W(...Z_,...rv.Definitions,...ss.Definitions,...$s.Definitions,..._c.Definitions,...Fc.Definitions,...du.Definitions,...Ev),Ov=W(...Om.Definitions,...mv.Definitions,...tu.Definitions,...dv.Definitions,...Su.Definitions,...Ig.Definitions,...Um.Definitions,...wg.Definitions,..._o.Definitions,...Ul.Definitions,...fp.Definitions,...Iu.Definitions,...Hs.Definitions,...lg.Definitions),kv=W(...Dv,...Ov,...bv,...xv,...Bg,...Sv,ev,$_);ao(kv),ao(W(...Dv,...Bg,...Ov,...X_,...xv,...tv,...Y_,...zg.Definitions,...bv,...Sv,...wv,...Tv,...yv));var Av={id:to,metadata:i(S(x,Ie)),location:i(Za)},jv=C({id:to,created:P,metadata:i(S(x,Ie)),type:We([`rpc.`,x]),location:Za,data:S(x,Ie)}).annotate({identifier:`V2Event.rpc`}),Mv=e=>E([...e,jv,...e.some(e=>e.type===`server.connected`)?[]:[C({...Av,type:h(`server.connected`),data:C({})}).annotate({identifier:`V2Event.server.connected`})]]).annotate({identifier:`V2Event`}),Nv=e=>C({types:i(de(E([y(e.map(e=>e.type)),jv.fields.type]))).annotate({description:`Only send events of these types, plus the initial server.connected event. When omitted, all events are sent.`})}).annotate({identifier:`EventSubscribeQuery`}),Pv=(e=>{let t=Mv(e);return{schema:t,group:N(`server.event`).add(A(`event.subscribe`,`/api/event`,{query:Nv(e),success:Ge({data:t})}).annotateMerge(k({identifier:`event.subscribe`,summary:`Subscribe to events`,description:`Subscribe to native events and plugin RPC events across all server locations. Volatile by contract: a slow consumer overflows and fails the stream, and events during disconnection are missed.`}))).annotateMerge(k({title:`event`,description:`Experimental event stream routes.`}))}})(kv),Fv=Pv.group;Pv.schema;var Iv=N(`server.agent`).add(A(`agent.list`,`/api/agent`,{query:X,success:V(g(uu)),error:Do}).annotateMerge(Z).annotateMerge(k({identifier:`agent.list`,summary:`List agents`,description:`Retrieve currently registered agents.`}))).add(A(`agent.get`,`/api/agent/:agentID`,{params:{agentID:su},query:X,success:V(uu),error:Io}).annotateMerge(Z).annotateMerge(k({identifier:`agent.get`,summary:`Get agent`,description:`Retrieve a single currently registered agent.`}))).annotateMerge(k({title:`agent`})),Lv=N(`server.plugin`).add(A(`plugin.list`,`/api/plugin`,{query:X,success:V(g(lv))}).annotateMerge(Z).annotateMerge(k({identifier:`plugin.list`,summary:`List plugins`,description:`Retrieve enabled server plugins and their current status.`}))).add(A(`plugin.gui`,`/api/plugin/gui`,{query:C({...X.fields,id:iv}),success:V(sv),error:Fo}).annotateMerge(Z).annotateMerge(k({identifier:`plugin.gui`,summary:`Read plugin GUI bundle`,description:"Read an active plugin's prebuilt CommonJS `./gui-experimental` bundle. Desktop app windows run its default export; the desktop app's main process runs its `main` export. Fails with not found when no active plugin has the id or the plugin exports no `./gui-experimental`."}))).add(D(`plugin.check`,`/api/plugin/check`,{query:X,payload:C({target:x.pipe(i)}),success:V(g(lv)),error:xo}).annotateMerge(Z).annotateMerge(k({identifier:`plugin.check`,summary:`Check plugin updates`,description:`Check one or all package plugins for available updates.`}))).add(D(`plugin.update`,`/api/plugin/update`,{query:X,payload:C({targets:g(x)}),success:T,error:[xo,Do]}).annotateMerge(Z).annotateMerge(k({identifier:`plugin.update`,summary:`Update plugins`,description:`Update package plugins concurrently and notify active locations to reload them. Responds once every update has finished; fails when any update fails.`}))).annotateMerge(k({title:`plugin`,description:`Experimental plugin routes.`})),Rv=C({version:x,pid:a.check(Re(0)),hostname:i(x),urls:g(x),paths:C({tmp:x}),capabilities:i(C({persistentPty:i(v)}))}).annotate({identifier:`ServerInfo`}),zv=C({code:x,expires_in:a}).annotate({identifier:`PairingCode`}),Bv=C({token:x}).annotate({identifier:`PairingSession`}),Vv=N(`server.server`).add(A(`server.info`,`/api/info`,{success:Rv}).annotateMerge(k({identifier:`server.info`,summary:`Get server info`,description:`Return the server identity, connection URLs, paths, and readiness status.`}))).add(D(`server.pair`,`/api/pair`,{success:zv}).annotateMerge(k({identifier:`server.pair`,summary:`Create pairing code`,description:`Create a short-lived, single-use code for a /auth/connect/:code pairing link.`}))).add(A(`server.connect`,`/auth/connect/:code`,{params:{code:x},success:Bv,error:wo}).annotateMerge(k({identifier:`server.connect`,summary:`Redeem pairing code`,description:`Redeem a pairing code. Browsers receive a session cookie and a redirect to the web app; requests that accept JSON receive a session token to use as the password.`}))).annotateMerge(k({title:`server`})),Hv=N(`server.debug`).add(D(`debug.heapDump`,`/api/debug/heap-dump`,{query:C({directory:x.pipe(i,O({description:`Absolute server-local directory to write the snapshot into, created when missing. Defaults to the server's log directory.`}))}),success:C({path:x,pid:a,memory:C({rss:gt,heapTotal:gt,heapUsed:gt,external:gt,arrayBuffers:gt}).annotate({description:`The server process's memory in bytes, read just before the snapshot (Node's process.memoryUsage()). rss covers native memory the snapshot cannot show.`})}),error:[xo,Oo]}).annotateMerge(k({identifier:`debug.heapDump`,summary:`Write a heap snapshot`,description:`Write a JavaScript heap snapshot of the server process into its log directory, or the requested directory, and return the server-local path once the file is complete. Pauses the server while the heap serializes and can temporarily increase its memory use. The snapshot can contain credentials, prompts, and file contents.`}))).add(A(`debug.location`,`/api/debug/location`,{success:g(Za)}).annotateMerge(k({identifier:`debug.location.list`,summary:`List loaded locations`,description:`List locations currently loaded by the server.`}))).add(ft(`debug.location.evict`,`/api/debug/location`,{query:X,success:T}).annotateMerge(Z).annotateMerge(k({identifier:`debug.location.evict`,summary:`Evict a loaded location`,description:`Dispose the requested location's cached services so its next use boots them fresh.`}))).annotateMerge(k({title:`debug`})),Uv=N(`server.shell`).add(A(`shell.list`,`/api/shell`,{query:X,success:V(g(Mu))}).annotateMerge(Z).annotateMerge(k({identifier:`shell.list`,summary:`List running shell commands`,description:`List currently running shell commands for a location. Exited commands are not included.`}))).add(D(`shell.create`,`/api/shell`,{query:X,payload:Lu,success:V(Mu)}).annotateMerge(Z).annotateMerge(k({identifier:`shell.create`,summary:`Run shell command`,description:`Spawn one non-interactive shell command for a location. Combined stdout/stderr is captured to a file pageable via output.`}))).add(A(`shell.get`,`/api/shell/:id`,{params:{id:Ou},query:X,success:V(Mu),error:Xo}).annotateMerge(Z).annotateMerge(k({identifier:`shell.get`,summary:`Get shell command`,description:`Get one shell command, including its status and exit code once exited.`}))).add(A(`shell.output`,`/api/shell/:id/output`,{params:{id:Ou},query:C({...X.fields,...Ru.fields}),success:V(zu),error:Xo}).annotateMerge(Z).annotateMerge(k({identifier:`shell.output`,summary:`Read shell output`,description:`Page through captured combined output by absolute byte cursor.`}))).add(ft(`shell.remove`,`/api/shell/:id`,{params:{id:Ou},query:X,success:T}).annotateMerge(Z).annotateMerge(k({identifier:`shell.remove`,summary:`Remove shell command`,description:`Terminate and remove one shell command and its retained output.`}))).annotateMerge(k({title:`shell`,description:`Location-scoped shell command routes.`})),Wv=C(o(hv.fields,[`description`,`hidden`])).annotate({identifier:`Reference.LocalSource`}),Gv=C(o(gv.fields,[`description`,`hidden`])).annotate({identifier:`Reference.GitSource`}),Kv=E([Wv,Gv]).pipe(ie(`type`)).annotate({identifier:`Reference.Source`}),qv=C({...o(vv.fields,[`source`]),source:Kv}).annotate({identifier:`Reference.Info`}),Jv=N(`server.reference`).add(A(`reference.list`,`/api/reference`,{query:X,success:V(g(qv))}).annotateMerge(Z).annotateMerge(k({identifier:`reference.list`,summary:`List references`,description:`List references available in the requested location.`}))).annotateMerge(k({title:`reference`,description:`Location-scoped project references.`})),Yv=class extends Qe()(`@opencode/HttpApiAuthorization`,{error:wo}){},Xv=N(`server.integration`).add(A(`integration.list`,`/api/integration`,{query:X,success:V(g(tc))}).annotateMerge(Z).annotateMerge(k({identifier:`integration.list`,summary:`List integrations`,description:`Retrieve available integrations and their authentication methods.`}))).add(A(`integration.get`,`/api/integration/:integrationID`,{params:{integrationID:Ws},query:X,success:V(tc),error:Ao}).annotateMerge(Z).annotateMerge(k({identifier:`integration.get`,summary:`Get integration`,description:`Retrieve one integration and its authentication methods.`}))).add(D(`integration.wellknown.add`,`/api/experimental/integration/wellknown`,{query:X,payload:C({url:x}),success:T,error:xo}).annotateMerge(Z).annotateMerge(k({identifier:`experimental.integration.wellknown.add`,summary:`Add wellknown integration`,description:`Discover and persist an experimental wellknown integration source.`}))).add(D(`integration.connect.key`,`/api/integration/:integrationID/connect/key`,{params:{integrationID:Ws},query:X,payload:C({key:x,answer:i(Fs),label:i(x)}),success:T,error:[Ao,xo]}).annotateMerge(Z).annotateMerge(k({identifier:`integration.connect.key`,summary:`Connect with key`,description:`Run a key authentication method and store the resulting credential.`}))).add(D(`integration.connect.external`,`/api/integration/:integrationID/connect/external`,{params:{integrationID:Ws},query:X,payload:C({methodID:Gs,answer:i(Fs),label:i(x)}),success:T,error:[Ao,xo]}).annotateMerge(Z).annotateMerge(k({identifier:`integration.connect.external`,summary:`Connect with external credentials`,description:`Run an external authentication method and store a reference to its credential source.`}))).add(D(`integration.oauth.connect`,`/api/integration/:integrationID/connect/oauth`,{params:{integrationID:Ws},query:X,payload:C({methodID:Gs,answer:i(Fs),label:i(x)}),success:V(ic),error:xo}).annotateMerge(Z).annotateMerge(k({identifier:`integration.oauth.connect`,summary:`Begin OAuth connection`,description:`Start an OAuth attempt and return the authorization details.`}))).add(A(`integration.oauth.status`,`/api/integration/:integrationID/connect/oauth/:attemptID`,{params:{integrationID:Ws,attemptID:nc},query:X,success:V(ac),error:[Ao,jo]}).annotateMerge(Z).annotateMerge(k({identifier:`integration.oauth.status`,summary:`Get OAuth attempt status`,description:`Poll the current status of an OAuth attempt.`}))).add(D(`integration.oauth.complete`,`/api/integration/:integrationID/connect/oauth/:attemptID/complete`,{params:{integrationID:Ws,attemptID:nc},query:X,payload:C({code:i(x)}),success:T,error:[Ao,jo,xo]}).annotateMerge(Z).annotateMerge(k({identifier:`integration.oauth.complete`,summary:`Complete OAuth connection`,description:`Complete a code-based OAuth attempt and store the resulting credential.`}))).add(ft(`integration.oauth.cancel`,`/api/integration/:integrationID/connect/oauth/:attemptID`,{params:{integrationID:Ws,attemptID:nc},query:X,success:T}).annotateMerge(Z).annotateMerge(k({identifier:`integration.oauth.cancel`,summary:`Cancel OAuth connection`,description:`Cancel an OAuth attempt and release its resources.`}))).add(D(`integration.command.connect`,`/api/integration/:integrationID/connect/command`,{params:{integrationID:Ws},query:X,payload:C({methodID:Gs,label:i(x)}),success:V(oc),error:[Ao,Mo,xo]}).annotateMerge(Z).annotateMerge(k({identifier:`integration.command.connect`,summary:`Begin command connection`,description:`Start a command authentication attempt.`}))).add(A(`integration.command.status`,`/api/integration/:integrationID/connect/command/:attemptID`,{params:{integrationID:Ws,attemptID:nc},query:X,success:V(sc),error:[Ao,jo]}).annotateMerge(Z).annotateMerge(k({identifier:`integration.command.status`,summary:`Get command attempt status`,description:`Poll the current status and output of a command authentication attempt.`}))).add(ft(`integration.command.cancel`,`/api/integration/:integrationID/connect/command/:attemptID`,{params:{integrationID:Ws,attemptID:nc},query:X,success:T}).annotateMerge(Z).annotateMerge(k({identifier:`integration.command.cancel`,summary:`Cancel command connection`,description:`Cancel a command authentication attempt and terminate its process.`}))).annotateMerge(k({title:`integration`,description:`Integration discovery and authentication routes.`})),Zv=N(`server.websearch`).add(A(`websearch.providers`,`/api/websearch/provider`,{query:X,success:V(g(ig)),error:Do}).annotateMerge(Z).annotateMerge(k({identifier:`websearch.providers`,summary:`List web search providers`,description:`Return the registered web search providers.`}))).add(D(`websearch.query`,`/api/websearch`,{query:X,payload:C(ag.fields),success:V(sg),error:[xo,Do]}).annotateMerge(Z).annotateMerge(k({identifier:`websearch.query`,summary:`Search the web`,description:`Run one web search through the selected provider. Specify a provider to override the configured default.`}))).annotateMerge(k({title:`websearch`,description:`Location-scoped web search routes.`})),Qv=P.check(Dt({minimum:0,maximum:100})),$v=P.annotate({description:`Milliseconds since the Unix epoch`}),ey=C({percent:Qv,limited:v,resetsAt:$v}).annotate({identifier:`UsageLimits.Meter`}),ty=C({rolling:ey,weekly:ey,monthly:ey}).annotate({identifier:`UsageLimits.Go`}),ny=C({providerID:hc,modelID:Nc,name:x,spent:Ac.pipe(B)}).annotate({identifier:`UsageLimits.BudgetModel`}),ry=C({id:x,limit:Ac,spent:Ac,scope:y([`each`,`combined`]),per:y([`set`,`model`]),coverage:y([`all`,`models`]),models:g(ny),vendors:g(x),inputPriceAtLeast:jc.pipe(B),picked:v,shared:v,resetsAt:$v}).annotate({identifier:`UsageLimits.Budget`}),iy=C({workspace:C({id:x,name:x.pipe(B),usageURL:x}),go:ty.pipe(B),budgets:g(ry)}).annotate({identifier:`UsageLimits.Info`}),ay=N(`server.usage`).add(A(`usage.limits`,`/api/experimental/usage/limits`,{query:X,success:V(se(iy)),error:Do}).annotateMerge(Z).annotateMerge(k({identifier:`experimental.usage.limits`,summary:`Get usage limits`,description:`Return the OpenCode Go allowance and Console budgets of the OpenCode Console workspace the location is signed in to, or null when it isn't signed in.`}))).annotateMerge(k({title:`usage`,description:`Experimental usage limit routes.`})),oy=`/api/experimental/client-mcp`,sy=C({...X.fields,name:x.check(Ce(/^[a-zA-Z0-9_-]+$/))}),cy=e=>N(`server.mcp`).add(A(`mcp.list`,`/api/mcp`,{query:X,success:V(g(Hh))}).annotateMerge(Z).annotateMerge(k({identifier:`mcp.list`,summary:`List MCP servers`,description:`Retrieve configured MCP servers and their connection status.`}))).add(St(`mcp.add`,`/api/experimental/mcp/:server`,{params:{server:x},query:X,payload:C({config:Fh}),success:T}).annotateMerge(Z).annotateMerge(k({identifier:`experimental.mcp.add`,summary:`Add MCP server`,description:`Add an MCP server at runtime or replace an existing one, connecting it immediately.`}))).add(ft(`mcp.remove`,`/api/experimental/mcp/:server`,{params:{server:x},query:X,success:T,error:zo}).annotateMerge(Z).annotateMerge(k({identifier:`experimental.mcp.remove`,summary:`Remove MCP server`,description:`Stop an MCP server and remove it from the runtime set until restart.`}))).add(D(`mcp.connect`,`/api/experimental/mcp/:server/connect`,{params:{server:x},query:X,success:T,error:zo}).annotateMerge(Z).annotateMerge(k({identifier:`experimental.mcp.connect`,summary:`Connect MCP server`,description:`Connect an MCP server at runtime, overriding a disabled configuration until restart.`}))).add(D(`mcp.disconnect`,`/api/experimental/mcp/:server/disconnect`,{params:{server:x},query:X,success:T,error:zo}).annotateMerge(Z).annotateMerge(k({identifier:`experimental.mcp.disconnect`,summary:`Disconnect MCP server`,description:`Disconnect an MCP server at runtime, removing its tools until reconnected.`}))).add(A(`mcp.resource.catalog`,`/api/mcp/resource`,{query:X,success:V(Gh)}).annotateMerge(Z).annotateMerge(k({identifier:`mcp.resource.catalog`,summary:`List MCP resources`,description:`Retrieve resources and resource templates from connected MCP servers.`}))).add(D(`mcp.clientToken`,`${oy}/token`,{query:sy,headers:C({[gp]:i(x)}),success:V(pp),error:Jo}).annotateMerge(Z).annotateMerge(k({identifier:`experimental.mcp.client.token`,summary:`Create client MCP WebSocket token`,description:`Create a short-lived single-use ticket for opening a client MCP WebSocket connection from a browser.`}))).middleware(e).add(A(`mcp.client`,oy,{query:C({...sy.fields,[hp]:i(x)}),success:v,error:[Jo,bo]}).annotateMerge(Z).annotateMerge(k({identifier:`experimental.mcp.client`,summary:`Attach client MCP server`,description:"Upgrade to a WebSocket over which the client hosts an MCP server named after `name`; its tools stay available while the socket is open. One JSON-RPC message per text frame. Experimental: may change without compatibility guarantees.",transform:e=>({...e,"x-websocket":!0})}))).annotateMerge(k({title:`mcp`,description:`MCP server and resource routes.`})),ly=N(`server.credential`).add(A(`credential.list`,`/api/credential`,{success:C({data:g(fs)})}).annotateMerge(k({identifier:`credential.list`,summary:`List credentials`,description:`List every stored integration credential, including its secret value.`}))).add(D(`credential.create`,`/api/credential`,{payload:ps,success:C({data:fs}),error:To}).annotateMerge(k({identifier:`credential.create`,summary:`Create credential`,description:`Store an integration credential. It becomes the integration's active credential unless activate is false and the integration already has one. Fails with a conflict when the requested ID already exists.`}))).add(ze(`credential.update`,`/api/credential/:credentialID`,{params:{credentialID:is},payload:C({label:x}),success:T}).annotateMerge(k({identifier:`credential.update`,summary:`Update credential`,description:`Update a stored credential label.`}))).annotateMerge(k({title:`credential`})).add(D(`credential.activate`,`/api/credential/:credentialID/activate`,{params:{credentialID:is},success:T}).annotateMerge(k({identifier:`credential.activate`,summary:`Activate credential`,description:`Activate a stored integration credential.`}))).add(ft(`credential.remove`,`/api/credential/:credentialID`,{params:{credentialID:is},success:T}).annotateMerge(k({identifier:`credential.remove`,summary:`Remove credential`,description:`Remove a stored integration credential.`}))),uy=`/api/project`,dy=C(o(bu.fields,[`projectID`])),fy=y([`true`,`false`]).pipe(wt(v,{decode:m(e=>e===`true`),encode:m(e=>e?`true`:`false`)})),py=N(`server.project`).add(A(`project.list`,uy,{query:C({archived:fy.pipe(i)}),success:g(yu)}).annotateMerge(k({identifier:`project.list`,summary:`List projects`,description:`List known projects. Archived projects are excluded unless archived=true.`}))).add(ze(`project.update`,`${uy}/:projectID`,{params:{projectID:pu},payload:dy,success:yu,error:No}).annotateMerge(k({identifier:`project.update`,summary:`Update project`,description:`Update the project canonical directory, display metadata, and workspace commands.`}))).annotateMerge(k({title:`project`,description:`Project routes.`})),my=`/api/worktree`,hy=class extends t()(`WorktreeError`,{name:h(`WorktreeError`),data:C({message:x,forceRequired:i(v)})},{httpApiStatus:400}){},gy=N(`server.worktree`).add(A(`worktree.list`,my,{query:C({projectID:pu}),success:Ng,error:No}).annotateMerge(k({identifier:`worktree.list`,summary:`List worktrees`,description:`Return the project's saved worktree inventory without loading configuration or running discovery.`}))).add(D(`worktree.create`,my,{payload:Dg,success:kg,error:[hy,No]}).annotateMerge(k({identifier:`worktree.create`,summary:`Create worktree`,description:`Load the project's canonical configuration, create a local worktree using its selected strategy, then run the project's setup script.`}))).add(ft(`worktree.remove`,my,{payload:Og,success:T,error:[hy,No]}).annotateMerge(k({identifier:`worktree.remove`,summary:`Remove worktree`,description:`Load the project's canonical configuration and remove a saved worktree using its recorded strategy.`}))).add(D(`worktree.refresh`,`${my}/refresh`,{payload:C({projectID:pu}),success:T,error:[hy,No]}).annotateMerge(k({identifier:`worktree.refresh`,summary:`Refresh worktrees`,description:`Load the project's canonical configuration, discover worktrees across known checkout roots using all available strategies, and reconcile saved state.`}))).annotateMerge(k({title:`worktree`,description:`Project-based worktree management routes.`})),_y=e({Base:()=>xy,Branch:()=>vy,BranchList:()=>by,FileStatus:()=>wy,Info:()=>yy,Mode:()=>Sy,Untracked:()=>Cy,Vcs:()=>_y}),vy=C({current:B(x),default:B(x)}).annotate({identifier:`Vcs.Branch`}),yy=C({provider:B(x),branch:vy}).annotate({identifier:`Vcs.Info`}),by=g(x).annotate({identifier:`Vcs.BranchList`}),xy=C({name:x,ref:x,source:y([`reflog`,`default`])}).annotate({identifier:`Vcs.Base`}),Sy=y([`working`,`branch`,`committed`]).annotate({identifier:`Vcs.Mode`}),Cy=y([`files`,`folders`]).annotate({identifier:`Vcs.Untracked`}),wy=C({file:x,additions:z,deletions:z,status:y([`added`,`deleted`,`modified`])}).annotate({identifier:`Vcs.FileStatus`}),Ty=C({...X.fields,provider:i(x)}),Ey=class extends t()(`VcsInitNotSupportedError`,{providerID:x,message:x},{httpApiStatus:501}){},Dy=C({...X.fields,search:i(x),limit:ae.pipe(wt(Fa),i)}),Oy=C({...X.fields,mode:Sy,base:B(x),context:ae.pipe(wt(z),i),untracked:B(Cy)}),ky=N(`server.vcs`).add(D(`vcs.init`,`/api/vcs/init`,{query:Ty,success:T,error:[To,xo,Ey,Do]}).annotateMerge(Z).annotateMerge(k({identifier:`vcs.init`,summary:`Initialize VCS repository`,description:`Initialize a repository using the selected VCS provider in a markerless project's directory and refresh its location services. Omitting provider defaults to git; built-in git and hg providers support initialization. An unknown provider returns 400; a registered provider without init returns 501.`}))).add(A(`vcs.get`,`/api/vcs`,{query:X,success:V(yy)}).annotateMerge(Z).annotateMerge(k({identifier:`vcs.get`,summary:`VCS info`,description:`Get current and default branch information for the requested location.`}))).add(A(`vcs.base`,`/api/vcs/base`,{query:X,success:V(se(xy)),error:Do}).annotateMerge(Z).annotateMerge(k({identifier:`vcs.base`,summary:`VCS review base`,description:`Infer a local review base from named branch creation history, or the repository default only when currently on that branch. Returns null before the first commit or when the provider lacks base metadata; ambiguous Git history requires an explicit base on diff requests.`}))).add(A(`vcs.status`,`/api/vcs/status`,{query:X,success:V(g(wy))}).annotateMerge(Z).annotateMerge(k({identifier:`vcs.status`,summary:`VCS status`,description:`List uncommitted working-copy changes relative to the requested location.`}))).add(A(`vcs.branch.list`,`/api/vcs/branch`,{query:Dy,success:V(by)}).annotateMerge(Z).annotateMerge(k({identifier:`vcs.branch.list`,summary:`VCS branches`,description:`List local and remote branches available at the requested location.`}))).add(A(`vcs.diff`,`/api/vcs/diff`,{query:Oy,success:V(g(Sd)),error:Do}).annotateMerge(Z).annotateMerge(k({identifier:`vcs.diff`,summary:`VCS diff`,description:`Diff HEAD to the working copy (working), the base merge-base to the working copy (branch), or the base merge-base to HEAD (committed). Omitting base preserves repository-default comparison; supplying it overrides the comparison without saving it.`}))).annotateMerge(k({title:`vcs`,description:`Location-scoped version control routes.`})),Ay=C({label:x,numerator:i(a.check(Re(0))),denominator:i(a.check(Re(0)))}),jy=E([C({status:y([`required`,`completed`])}),C({status:h(`running`),progress:Ay}),C({status:h(`error`),error:x})]),My=N(`server.migration`).add(A(`migration.v1.status`,`/api/experimental/migration/v1`,{success:jy}).annotateMerge(k({identifier:`experimental.migration.v1.status`,summary:`Get V1 migration status`,description:`Return the progress of the V1 to V2 session history migration.`}))).annotateMerge(k({title:`migration`})),Ny=C({path:x,name:x,acceptable:v}).annotate({identifier:`ConfigShell.Option`}),Py=N(`server.config`).add(A(`config.get`,`/api/config`,{query:X,success:g(Sg)}).annotateMerge(Z).annotateMerge(k({identifier:`config.get`,summary:`Get configuration`,description:`Return configuration documents and discovery sources for the requested location, from lowest to highest priority.`}))).add(A(`config.shells`,`/api/config/shell`,{success:g(Ny)}).annotateMerge(k({identifier:`config.shells`,summary:`List available shells`,description:`Return shells available to terminal and agent execution.`}))).add(ze(`config.update`,`/api/experimental/config`,{payload:yg,success:T}).annotateMerge(k({identifier:`experimental.config.update`,summary:`Update global configuration`,description:`Patch supported fields in the highest-precedence global configuration document.`}))).annotateMerge(k({title:`config`,description:`Location-scoped configuration routes.`})),Fy=(e,t,n,r)=>Pe(`server`).add(Vv).add(mp(t)).add(Iv.middleware(t)).add(Lv.middleware(t)).add(xm(r,n)).add(Lp).add(zp.middleware(t)).add(Nl).add(jp).add(Bp.middleware(t)).add(Xv.middleware(t)).add(cy(t)).add(ly).add(py).add(zm(t)).add(Tm(t,r)).add(Rm.middleware(t)).add(Wm.middleware(t)).add(Gm.middleware(t)).add(Jm.middleware(t)).add(e).add(vp(t)).add(Sp).add(Uv.middleware(t)).add(Jv.middleware(t)).add(gy).add(ky.middleware(t)).add(Hv).add(My).add(Zv.middleware(t)).add(ay.middleware(t)).add(Py.middleware(t)).annotateMerge(k({title:`opencode HttpApi`,version:`0.0.1`,description:`Experimental HttpApi surface for selected instance routes.`})).middleware(Yv).middleware(es),Iy=e=>Fy(Fv,e.locationMiddleware,e.formLocationMiddleware,e.sessionLocationMiddleware),Ly=class extends Qe()(`@opencode/client/LocationMiddleware`,{error:[bo]}){},Ry=class extends Qe()(`@opencode/client/SessionLocationMiddleware`,{error:[xo,G,bo]}){},zy=Iy({locationMiddleware:Ly,formLocationMiddleware:Ry,sessionLocationMiddleware:Ry});Rt({},{make:()=>sC});var Q=e=>Tt(e)||u(e)||ot.is(e)?new Pa({cause:e}):e,$=()=>e=>e,By=()=>e=>e,Vy=e=>()=>$()(e[`server.info`]({}).pipe(w(Q))),Hy=e=>()=>$()(e[`server.pair`]({}).pipe(w(Q))),Uy=e=>t=>$()(e[`server.connect`]({params:{code:t.code}}).pipe(w(Q))),Wy=e=>({info:Vy(e),pair:Hy(e),connect:Uy(e)}),Gy=e=>t=>$()(e[`location.get`]({query:{location:t?.location}}).pipe(w(Q))),Ky=e=>()=>$()(e[`location.reload`]({}).pipe(w(Q))),qy=e=>({get:Gy(e),reload:Ky(e)}),Jy=e=>t=>$()(e[`agent.list`]({query:{location:t?.location}}).pipe(w(Q))),Yy=e=>t=>$()(e[`agent.get`]({params:{agentID:t.agentID},query:{location:t.location}}).pipe(w(Q))),Xy=e=>({list:Jy(e),get:Yy(e)}),Zy=e=>t=>$()(e[`plugin.list`]({query:{location:t?.location}}).pipe(w(Q))),Qy=e=>t=>$()(e[`plugin.gui`]({query:{location:t.location,id:t.id}}).pipe(w(Q))),$y=e=>t=>$()(e[`plugin.check`]({query:{location:t?.location},payload:{target:t?.target}}).pipe(w(Q))),eb=e=>t=>$()(e[`plugin.update`]({query:{location:t.location},payload:{targets:t.targets}}).pipe(w(Q))),tb=e=>({list:Zy(e),gui:Qy(e),check:$y(e),update:eb(e)}),nb=e=>t=>$()(e[`session.list`]({query:{limit:t?.limit,order:t?.order,search:t?.search,parentID:t?.parentID,archived:t?.archived,directory:t?.directory,project:t?.project,subpath:t?.subpath,cursor:t?.cursor}}).pipe(w(Q))),rb=e=>t=>$()(e[`session.stats`]({query:{from:t?.from,to:t?.to,project:t?.project,timezone:t?.timezone,tools:t?.tools}}).pipe(w(Q),j(e=>e.data))),ib=e=>t=>$()(e[`session.create`]({payload:{id:t?.id,parentID:t?.parentID,title:t?.title,agent:t?.agent,model:t?.model,location:t?.location,metadata:t?.metadata,permissions:t?.permissions}}).pipe(w(Q),j(e=>e.data))),ab=e=>t=>$()(e[`session.import`]({payload:{info:t.info,messages:t.messages,location:t.location}}).pipe(w(Q),j(e=>e.data))),ob=e=>t=>$()(e[`session.export`]({params:{sessionID:t.sessionID},query:{sanitize:t.sanitize}}).pipe(w(Q),j(e=>e.data))),sb=e=>()=>$()(e[`session.active`]({}).pipe(w(Q),j(e=>e.data))),cb=e=>t=>$()(e[`session.get`]({params:{sessionID:t.sessionID}}).pipe(w(Q),j(e=>e.data))),lb=e=>t=>$()(e[`session.remove`]({params:{sessionID:t.sessionID}}).pipe(w(Q))),ub=e=>t=>$()(e[`session.fork`]({params:{sessionID:t.sessionID},payload:{before:t.before}}).pipe(w(Q),j(e=>e.data))),db=e=>t=>$()(e[`session.switchAgent`]({params:{sessionID:t.sessionID},payload:{agent:t.agent}}).pipe(w(Q))),fb=e=>t=>$()(e[`session.switchModel`]({params:{sessionID:t.sessionID},payload:{model:t.model}}).pipe(w(Q))),pb=e=>t=>$()(e[`session.update`]({params:{sessionID:t.sessionID},payload:{title:t.title,metadata:t.metadata,permissions:t.permissions,archived:t.archived}}).pipe(w(Q))),mb=e=>t=>$()(e[`session.move`]({params:{sessionID:t.sessionID},payload:{directory:t.directory,delivery:t.delivery}}).pipe(w(Q))),hb=e=>t=>$()(e[`session.prompt`]({params:{sessionID:t.sessionID},payload:{id:t.id,text:t.text,files:t.files,agents:t.agents,skills:t.skills,metadata:t.metadata,delivery:t.delivery,resume:t.resume}}).pipe(w(Q),j(e=>e.data))),gb=e=>t=>$()(e[`session.command`]({params:{sessionID:t.sessionID},payload:{name:t.name,text:t.text,files:t.files,agents:t.agents,skills:t.skills,delivery:t.delivery}}).pipe(w(Q))),_b=e=>t=>$()(e[`session.skill`]({params:{sessionID:t.sessionID},payload:{id:t.id,resume:t.resume}}).pipe(w(Q))),vb=e=>t=>$()(e[`session.synthetic`]({params:{sessionID:t.sessionID},payload:{id:t.id,text:t.text,description:t.description,metadata:t.metadata,delivery:t.delivery,resume:t.resume}}).pipe(w(Q),j(e=>e.data))),yb=e=>t=>$()(e[`session.shell`]({params:{sessionID:t.sessionID},payload:{id:t.id,command:t.command}}).pipe(w(Q))),bb=e=>t=>$()(e[`session.compact`]({params:{sessionID:t.sessionID},payload:{id:t.id,delivery:t.delivery}}).pipe(w(Q),j(e=>e.data))),xb=e=>t=>$()(e[`session.wait`]({params:{sessionID:t.sessionID}}).pipe(w(Q))),Sb=e=>t=>$()(e[`session.revert.stage`]({params:{sessionID:t.sessionID},payload:{messageID:t.messageID,files:t.files}}).pipe(w(Q),j(e=>e.data))),Cb=e=>t=>$()(e[`session.revert.clear`]({params:{sessionID:t.sessionID}}).pipe(w(Q))),wb=e=>t=>$()(e[`session.revert.commit`]({params:{sessionID:t.sessionID}}).pipe(w(Q))),Tb=e=>t=>$()(e[`session.context`]({params:{sessionID:t.sessionID}}).pipe(w(Q),j(e=>e.data))),Eb=e=>t=>$()(e[`session.diff`]({params:{sessionID:t.sessionID},query:{from:t.from,to:t.to,context:t.context}}).pipe(w(Q),j(e=>e.data))),Db=e=>t=>$()(e[`session.inbox.list`]({params:{sessionID:t.sessionID}}).pipe(w(Q),j(e=>e.data))),Ob=e=>t=>$()(e[`session.inbox.cancel`]({params:{sessionID:t.sessionID,inboxID:t.inboxID}}).pipe(w(Q))),kb=e=>t=>$()(e[`session.inbox.update`]({params:{sessionID:t.sessionID,inboxID:t.inboxID},payload:{delivery:t.delivery}}).pipe(w(Q))),Ab=e=>t=>$()(e[`session.instructions.entry.list`]({params:{sessionID:t.sessionID}}).pipe(w(Q),j(e=>e.data))),jb=e=>t=>$()(e[`session.instructions.entry.put`]({params:{sessionID:t.sessionID,key:t.key},payload:{value:t.value}}).pipe(w(Q))),Mb=e=>t=>$()(e[`session.instructions.entry.remove`]({params:{sessionID:t.sessionID,key:t.key}}).pipe(w(Q))),Nb=e=>t=>$()(e[`session.generate`]({params:{sessionID:t.sessionID},payload:{prompt:t.prompt}}).pipe(w(Q),j(e=>e.data))),Pb=e=>t=>By()(r(e[`session.log`]({params:{sessionID:t.sessionID},query:{after:t.after,follow:t.follow}}).pipe(w(Q),j(e=>e.pipe(pe(Q)))))),Fb=e=>t=>$()(e[`session.interrupt`]({params:{sessionID:t.sessionID},query:{resume:t.resume}}).pipe(w(Q))),Ib=e=>t=>$()(e[`session.background`]({params:{sessionID:t.sessionID}}).pipe(w(Q))),Lb=e=>t=>$()(e[`session.message`]({params:{sessionID:t.sessionID,messageID:t.messageID}}).pipe(w(Q),j(e=>e.data))),Rb=e=>t=>$()(e[`session.form.list`]({params:{sessionID:t.sessionID}}).pipe(w(Q),j(e=>e.data))),zb=e=>t=>$()(e[`session.form.create`]({params:{sessionID:t.sessionID},payload:{id:t.id,title:t.title,metadata:t.metadata,fields:t.fields}}).pipe(w(Q),j(e=>e.data))),Bb=e=>t=>$()(e[`session.form.get`]({params:{sessionID:t.sessionID,formID:t.formID}}).pipe(w(Q),j(e=>e.data))),Vb=e=>t=>$()(e[`session.form.reply`]({params:{sessionID:t.sessionID,formID:t.formID},payload:{answer:t.answer}}).pipe(w(Q))),Hb=e=>t=>$()(e[`session.form.cancel`]({params:{sessionID:t.sessionID,formID:t.formID},query:{message:t.message}}).pipe(w(Q))),Ub=e=>t=>$()(e[`session.environment`]({params:{sessionID:t.sessionID},payload:{variables:t.variables}}).pipe(w(Q))),Wb=e=>t=>$()(e[`session.view`]({params:{sessionID:t.sessionID},payload:{idle:t.idle}}).pipe(w(Q))),Gb=e=>({list:nb(e),stats:rb(e),create:ib(e),import:ab(e),export:ob(e),active:sb(e),get:cb(e),remove:lb(e),fork:ub(e),switchAgent:db(e),switchModel:fb(e),update:pb(e),move:mb(e),prompt:hb(e),command:gb(e),skill:_b(e),synthetic:vb(e),shell:yb(e),compact:bb(e),wait:xb(e),revert:{stage:Sb(e),clear:Cb(e),commit:wb(e)},context:Tb(e),diff:Eb(e),inbox:{list:Db(e),cancel:Ob(e),update:kb(e)},instructions:{entry:{list:Ab(e),put:jb(e),remove:Mb(e)}},generate:Nb(e),log:Pb(e),interrupt:Fb(e),background:Ib(e),message:{get:Lb(e)},form:{list:Rb(e),create:zb(e),get:Bb(e),reply:Vb(e),cancel:Hb(e)},environment:Ub(e),view:Wb(e)}),Kb=e=>t=>$()(e[`session.messages`]({params:{sessionID:t.sessionID},query:{limit:t.limit,order:t.order,cursor:t.cursor,type:t.type}}).pipe(w(Q))),qb=e=>({list:Kb(e)}),Jb=e=>t=>$()(e[`model.list`]({query:{location:t?.location,types:t?.types}}).pipe(w(Q))),Yb=e=>t=>$()(e[`model.default`]({query:{location:t?.location}}).pipe(w(Q))),Xb=e=>({list:Jb(e),default:Yb(e)}),Zb=e=>t=>$()(e[`generate.text`]({payload:{prompt:t.prompt,model:t.model}}).pipe(w(Q),j(e=>e.data))),Qb=e=>t=>$()(e[`generate.image`]({payload:{model:t.model,prompt:t.prompt,images:t.images,n:t.n,aspect:t.aspect,resolution:t.resolution}}).pipe(w(Q),j(e=>e.data))),$b=e=>t=>$()(e[`generate.decisions`]({payload:{model:t.model,input:t.input,questions:t.questions}}).pipe(w(Q),j(e=>e.data))),ex=e=>({text:Zb(e),image:Qb(e),decisions:$b(e)}),tx=e=>()=>$()(e[`voice.models`]({}).pipe(w(Q),j(e=>e.data))),nx=e=>t=>$()(e[`voice.session`]({payload:{model:t.model,session:t.session,transport:t.transport}}).pipe(w(Q),j(e=>e.data))),rx=e=>({models:tx(e),session:nx(e)}),ix=e=>t=>$()(e[`provider.list`]({query:{location:t?.location}}).pipe(w(Q))),ax=e=>t=>$()(e[`provider.get`]({params:{providerID:t.providerID},query:{location:t.location}}).pipe(w(Q))),ox=e=>({list:ix(e),get:ax(e)}),sx=e=>t=>$()(e[`integration.list`]({query:{location:t?.location}}).pipe(w(Q))),cx=e=>t=>$()(e[`integration.get`]({params:{integrationID:t.integrationID},query:{location:t.location}}).pipe(w(Q))),lx=e=>t=>$()(e[`integration.wellknown.add`]({query:{location:t.location},payload:{url:t.url}}).pipe(w(Q))),ux=e=>t=>$()(e[`integration.connect.key`]({params:{integrationID:t.integrationID},query:{location:t.location},payload:{key:t.key,answer:t.answer,label:t.label}}).pipe(w(Q))),dx=e=>t=>$()(e[`integration.connect.external`]({params:{integrationID:t.integrationID},query:{location:t.location},payload:{methodID:t.methodID,answer:t.answer,label:t.label}}).pipe(w(Q))),fx=e=>t=>$()(e[`integration.oauth.connect`]({params:{integrationID:t.integrationID},query:{location:t.location},payload:{methodID:t.methodID,answer:t.answer,label:t.label}}).pipe(w(Q))),px=e=>t=>$()(e[`integration.oauth.status`]({params:{integrationID:t.integrationID,attemptID:t.attemptID},query:{location:t.location}}).pipe(w(Q))),mx=e=>t=>$()(e[`integration.oauth.complete`]({params:{integrationID:t.integrationID,attemptID:t.attemptID},query:{location:t.location},payload:{code:t.code}}).pipe(w(Q))),hx=e=>t=>$()(e[`integration.oauth.cancel`]({params:{integrationID:t.integrationID,attemptID:t.attemptID},query:{location:t.location}}).pipe(w(Q))),gx=e=>t=>$()(e[`integration.command.connect`]({params:{integrationID:t.integrationID},query:{location:t.location},payload:{methodID:t.methodID,label:t.label}}).pipe(w(Q))),_x=e=>t=>$()(e[`integration.command.status`]({params:{integrationID:t.integrationID,attemptID:t.attemptID},query:{location:t.location}}).pipe(w(Q))),vx=e=>t=>$()(e[`integration.command.cancel`]({params:{integrationID:t.integrationID,attemptID:t.attemptID},query:{location:t.location}}).pipe(w(Q))),yx=e=>({list:sx(e),get:cx(e),wellknown:{add:lx(e)},connect:{key:ux(e),external:dx(e)},oauth:{connect:fx(e),status:px(e),complete:mx(e),cancel:hx(e)},command:{connect:gx(e),status:_x(e),cancel:vx(e)}}),bx=e=>t=>$()(e[`mcp.list`]({query:{location:t?.location}}).pipe(w(Q))),xx=e=>t=>$()(e[`mcp.add`]({params:{server:t.server},query:{location:t.location},payload:{config:t.config}}).pipe(w(Q))),Sx=e=>t=>$()(e[`mcp.remove`]({params:{server:t.server},query:{location:t.location}}).pipe(w(Q))),Cx=e=>t=>$()(e[`mcp.connect`]({params:{server:t.server},query:{location:t.location}}).pipe(w(Q))),wx=e=>t=>$()(e[`mcp.disconnect`]({params:{server:t.server},query:{location:t.location}}).pipe(w(Q))),Tx=e=>t=>$()(e[`mcp.resource.catalog`]({query:{location:t?.location}}).pipe(w(Q))),Ex=e=>t=>$()(e[`mcp.clientToken`]({query:{location:t.location,name:t.name},headers:{"x-opencode-ticket":t[`x-opencode-ticket`]}}).pipe(w(Q))),Dx=e=>({list:bx(e),add:xx(e),remove:Sx(e),connect:Cx(e),disconnect:wx(e),resource:{catalog:Tx(e)},client:{token:Ex(e)}}),Ox=e=>()=>$()(e[`credential.list`]({}).pipe(w(Q),j(e=>e.data))),kx=e=>t=>$()(e[`credential.create`]({payload:{id:t.id,integrationID:t.integrationID,label:t.label,value:t.value,activate:t.activate}}).pipe(w(Q),j(e=>e.data))),Ax=e=>t=>$()(e[`credential.update`]({params:{credentialID:t.credentialID},payload:{label:t.label}}).pipe(w(Q))),jx=e=>t=>$()(e[`credential.activate`]({params:{credentialID:t.credentialID}}).pipe(w(Q))),Mx=e=>t=>$()(e[`credential.remove`]({params:{credentialID:t.credentialID}}).pipe(w(Q))),Nx=e=>({list:Ox(e),create:kx(e),update:Ax(e),activate:jx(e),remove:Mx(e)}),Px=e=>t=>$()(e[`project.list`]({query:{archived:t?.archived}}).pipe(w(Q))),Fx=e=>t=>$()(e[`project.update`]({params:{projectID:t.projectID},payload:{canonical:t.canonical,name:t.name,icon:t.icon,commands:t.commands}}).pipe(w(Q))),Ix=e=>({list:Px(e),update:Fx(e)}),Lx=e=>t=>$()(e[`form.list`]({query:{location:t?.location}}).pipe(w(Q))),Rx=e=>({list:Lx(e)}),zx=e=>t=>$()(e[`permission.request.list`]({query:{location:t?.location}}).pipe(w(Q))),Bx=e=>t=>$()(e[`permission.saved.list`]({query:{projectID:t?.projectID}}).pipe(w(Q),j(e=>e.data))),Vx=e=>t=>$()(e[`permission.saved.update`]({params:{id:t.id},payload:{action:t.action,resource:t.resource}}).pipe(w(Q),j(e=>e.data))),Hx=e=>t=>$()(e[`permission.saved.remove`]({params:{id:t.id}}).pipe(w(Q))),Ux=e=>t=>$()(e[`session.permission.create`]({params:{sessionID:t.sessionID},payload:{id:t.id,action:t.action,resources:t.resources,save:t.save,metadata:t.metadata,source:t.source,agent:t.agent}}).pipe(w(Q),j(e=>e.data))),Wx=e=>t=>$()(e[`session.permission.list`]({params:{sessionID:t.sessionID}}).pipe(w(Q),j(e=>e.data))),Gx=e=>t=>$()(e[`session.permission.get`]({params:{sessionID:t.sessionID,requestID:t.requestID}}).pipe(w(Q),j(e=>e.data))),Kx=e=>t=>$()(e[`session.permission.reply`]({params:{sessionID:t.sessionID,requestID:t.requestID},payload:{decision:t.decision,message:t.message}}).pipe(w(Q))),qx=e=>({request:{list:zx(e)},saved:{list:Bx(e),update:Vx(e),remove:Hx(e)},create:Ux(e),list:Wx(e),get:Gx(e),reply:Kx(e)}),Jx=e=>t=>$()(e[`fs.list`]({query:{location:t?.location,path:t?.path}}).pipe(w(Q))),Yx=e=>t=>$()(e[`fs.find`]({query:{location:t.location,query:t.query,type:t.type,limit:t.limit}}).pipe(w(Q))),Xx=e=>t=>$()(e[`fs.watch`]({query:{location:t.location},payload:{path:t.path}}).pipe(w(Q))),Zx=e=>t=>$()(e[`fs.unwatch`]({query:{location:t.location},payload:{path:t.path}}).pipe(w(Q))),Qx=e=>({list:Jx(e),find:Yx(e),watch:Xx(e),unwatch:Zx(e)}),$x=e=>t=>$()(e[`command.list`]({query:{location:t?.location}}).pipe(w(Q))),eS=e=>({list:$x(e)}),tS=e=>t=>$()(e[`skill.list`]({query:{location:t?.location}}).pipe(w(Q))),nS=e=>({list:tS(e)}),rS=e=>t=>$()(e[`rpc.call`]({params:{rpcID:t.rpcID,method:t.method},query:{location:t.location},payload:{input:t.input}}).pipe(w(Q))),iS=e=>({call:rS(e)}),aS=e=>t=>By()(r(e[`event.subscribe`]({query:{types:t?.types}}).pipe(w(Q),j(e=>e.pipe(pe(Q)))))),oS=e=>({subscribe:aS(e)}),sS=e=>t=>$()(e[`pty.list`]({query:{location:t?.location}}).pipe(w(Q))),cS=e=>t=>$()(e[`pty.create`]({query:{location:t?.location},payload:{command:t?.command,args:t?.args,cwd:t?.cwd,title:t?.title,env:t?.env}}).pipe(w(Q))),lS=e=>t=>$()(e[`pty.get`]({params:{ptyID:t.ptyID},query:{location:t.location}}).pipe(w(Q))),uS=e=>t=>$()(e[`pty.update`]({params:{ptyID:t.ptyID},query:{location:t.location},payload:{title:t.title,size:t.size}}).pipe(w(Q))),dS=e=>t=>$()(e[`pty.remove`]({params:{ptyID:t.ptyID},query:{location:t.location}}).pipe(w(Q))),fS=e=>t=>$()(e[`pty.connectToken`]({params:{ptyID:t.ptyID},query:{location:t.location},headers:{"x-opencode-ticket":t[`x-opencode-ticket`]}}).pipe(w(Q))),pS=e=>({list:sS(e),create:cS(e),get:lS(e),update:uS(e),remove:dS(e),connect:{token:fS(e)}}),mS=e=>t=>$()(e[`persistentPty.read`]({params:{sessionID:t.sessionID},query:{lines:t.lines}}).pipe(w(Q),j(e=>e.data))),hS=e=>t=>$()(e[`persistentPty.list`]({params:{sessionID:t.sessionID}}).pipe(w(Q),j(e=>e.data))),gS=e=>t=>$()(e[`persistentPty.create`]({params:{sessionID:t.sessionID},payload:{command:t.command,args:t.args,cwd:t.cwd,title:t.title,env:t.env,size:t.size}}).pipe(w(Q),j(e=>e.data))),_S=e=>()=>$()(e[`persistentPty.shutdown`]({}).pipe(w(Q))),vS=e=>()=>$()(e[`persistentPty.handoff`]({}).pipe(w(Q))),yS=e=>t=>$()(e[`persistentPty.get`]({params:{ptyID:t.ptyID}}).pipe(w(Q),j(e=>e.data))),bS=e=>t=>$()(e[`persistentPty.update`]({params:{ptyID:t.ptyID},payload:{attachmentID:t.attachmentID,size:t.size}}).pipe(w(Q),j(e=>e.data))),xS=e=>t=>$()(e[`persistentPty.snapshot`]({params:{ptyID:t.ptyID}}).pipe(w(Q),j(e=>e.data))),SS=e=>t=>$()(e[`persistentPty.remove`]({params:{ptyID:t.ptyID}}).pipe(w(Q))),CS=e=>t=>$()(e[`persistentPty.connectToken`]({params:{ptyID:t.ptyID},headers:{"x-opencode-ticket":t[`x-opencode-ticket`]}}).pipe(w(Q),j(e=>e.data))),wS=e=>({persistentPty:{read:mS(e),list:hS(e),create:gS(e),shutdown:_S(e),handoff:vS(e),get:yS(e),update:bS(e),snapshot:xS(e),remove:SS(e),connectToken:CS(e)}}),TS=e=>t=>$()(e[`shell.list`]({query:{location:t?.location}}).pipe(w(Q))),ES=e=>t=>$()(e[`shell.create`]({query:{location:t.location},payload:{command:t.command,cwd:t.cwd,timeout:t.timeout,metadata:t.metadata}}).pipe(w(Q))),DS=e=>t=>$()(e[`shell.get`]({params:{id:t.id},query:{location:t.location}}).pipe(w(Q))),OS=e=>t=>$()(e[`shell.output`]({params:{id:t.id},query:{location:t.location,cursor:t.cursor,limit:t.limit}}).pipe(w(Q))),kS=e=>t=>$()(e[`shell.remove`]({params:{id:t.id},query:{location:t.location}}).pipe(w(Q))),AS=e=>({list:TS(e),create:ES(e),get:DS(e),output:OS(e),remove:kS(e)}),jS=e=>t=>$()(e[`reference.list`]({query:{location:t?.location}}).pipe(w(Q))),MS=e=>({list:jS(e)}),NS=e=>t=>$()(e[`worktree.list`]({query:{projectID:t.projectID}}).pipe(w(Q))),PS=e=>t=>$()(e[`worktree.create`]({payload:{projectID:t.projectID,from:t.from,branch:t.branch,directory:t.directory,name:t.name}}).pipe(w(Q))),FS=e=>t=>$()(e[`worktree.remove`]({payload:{projectID:t.projectID,directory:t.directory,force:t.force}}).pipe(w(Q))),IS=e=>t=>$()(e[`worktree.refresh`]({payload:{projectID:t.projectID}}).pipe(w(Q))),LS=e=>({list:NS(e),create:PS(e),remove:FS(e),refresh:IS(e)}),RS=e=>t=>$()(e[`vcs.init`]({query:{location:t?.location,provider:t?.provider}}).pipe(w(Q))),zS=e=>t=>$()(e[`vcs.get`]({query:{location:t?.location}}).pipe(w(Q))),BS=e=>t=>$()(e[`vcs.base`]({query:{location:t?.location}}).pipe(w(Q))),VS=e=>t=>$()(e[`vcs.status`]({query:{location:t?.location}}).pipe(w(Q))),HS=e=>t=>$()(e[`vcs.branch.list`]({query:{location:t?.location,search:t?.search,limit:t?.limit}}).pipe(w(Q))),US=e=>t=>$()(e[`vcs.diff`]({query:{location:t.location,mode:t.mode,base:t.base,context:t.context,untracked:t.untracked}}).pipe(w(Q))),WS=e=>({init:RS(e),get:zS(e),base:BS(e),status:VS(e),branch:{list:HS(e)},diff:US(e)}),GS=e=>t=>$()(e[`debug.heapDump`]({query:{directory:t?.directory}}).pipe(w(Q))),KS=e=>()=>$()(e[`debug.location`]({}).pipe(w(Q))),qS=e=>t=>$()(e[`debug.location.evict`]({query:{location:t?.location}}).pipe(w(Q))),JS=e=>({heapDump:GS(e),location:{list:KS(e),evict:qS(e)}}),YS=e=>()=>$()(e[`migration.v1.status`]({}).pipe(w(Q))),XS=e=>({v1:{status:YS(e)}}),ZS=e=>t=>$()(e[`websearch.providers`]({query:{location:t?.location}}).pipe(w(Q))),QS=e=>t=>$()(e[`websearch.query`]({query:{location:t.location},payload:{query:t.query,providerID:t.providerID}}).pipe(w(Q))),$S=e=>({providers:ZS(e),query:QS(e)}),eC=e=>t=>$()(e[`usage.limits`]({query:{location:t?.location}}).pipe(w(Q))),tC=e=>({limits:eC(e)}),nC=e=>t=>$()(e[`config.get`]({query:{location:t?.location}}).pipe(w(Q))),rC=e=>()=>$()(e[`config.shells`]({}).pipe(w(Q))),iC=e=>t=>$()(e[`config.update`]({payload:{shell:t.shell}}).pipe(w(Q))),aC=e=>({get:nC(e),shells:rC(e),update:iC(e)}),oC=e=>({server:Wy(e[`server.server`]),location:qy(e[`server.location`]),agent:Xy(e[`server.agent`]),plugin:tb(e[`server.plugin`]),session:Gb(e[`server.session`]),message:qb(e[`server.message`]),model:Xb(e[`server.model`]),generate:ex(e[`server.generate`]),voice:rx(e[`server.voice`]),provider:ox(e[`server.provider`]),integration:yx(e[`server.integration`]),mcp:Dx(e[`server.mcp`]),credential:Nx(e[`server.credential`]),project:Ix(e[`server.project`]),form:Rx(e[`server.form`]),permission:qx(e[`server.permission`]),file:Qx(e[`server.fs`]),command:eS(e[`server.command`]),skill:nS(e[`server.skill`]),rpc:iS(e[`server.rpc`]),event:oS(e[`server.event`]),pty:pS(e[`server.pty`]),experimental:wS(e[`server.experimental`]),shell:AS(e[`server.shell`]),reference:MS(e[`server.reference`]),worktree:LS(e[`server.worktree`]),vcs:WS(e[`server.vcs`]),debug:JS(e[`server.debug`]),migration:XS(e[`server.migration`]),websearch:$S(e[`server.websearch`]),usage:tC(e[`server.usage`]),config:aC(e[`server.config`])}),sC=e=>lt(zy,e).pipe(j(oC)),cC={};Rt(cC,{RpcRuntime:()=>cC,event:()=>dC,eventType:()=>fC,read:()=>lC,readError:()=>uC});function lC(e,t){return f(e)?He(e)(t):Ve(t)}function uC(e,t){return!(t instanceof So)&&!(t instanceof Co)?ut(t):!e.errors||!Object.hasOwn(e.errors,t.type)?ut(t.data===void 0?{type:t.type,message:t.message}:{type:t.type,message:t.message,data:t.data}):lC(e.errors[t.type],t.data).pipe(n(e=>bt(e)),vt(e=>ut(e===void 0?{type:t.type,message:t.message}:{type:t.type,message:t.message,data:e})))}var dC=$e(`Client.Rpc.event`)(function*(e,t,n,r){let i=yield*lC(n.schema,r.data);return{...r,type:fC(e,t),data:i}});function fC(e,t){return`rpc.${e.id}.${t}`}var pC={};Rt(pC,{RpcClientRuntime:()=>pC,aborted:()=>hC,make:()=>mC});function mC(e,t){return r=>{let i=Object.fromEntries(Object.entries(r.methods).map(([t,i])=>[t,(a,o)=>{let s=Fe(function*(){let n=yield*e({rpcID:r.id,method:t,input:a,location:o?.location},o);return yield*lC(i.output,n.output)}).pipe(n(e=>uC(i,e))),c=o?.signal;return c?ht(()=>c.aborted?pt:Ct(s,Ae(hC(c),pt))):s}]));return Object.assign(i,{events:{subscribe:e=>{let n=fC(r,e);if(!Object.hasOwn(r.events,e))return be(Error(`Unknown RPC event: ${n}`));let i=r.events[e];return t().pipe(Ot(e=>e.type===n),l(t=>dC(r,e,i,t)))}}})}}function hC(e){return _e(t=>{if(e.aborted)return t(Xe);let n=()=>t(Xe);return e.addEventListener(`abort`,n,{once:!0}),st(()=>e.removeEventListener(`abort`,n))})}var gC={};Rt(gC,{OpenCode:()=>gC,make:()=>vC});var _C=Et(`@opencode/client/effect/rpc/headers`,{defaultValue:()=>{}}),vC=$e(`OpenCode.make`)(function*(e){let t=yield*Ye,n=yield*sC(e).pipe(it(Ye,qe(t,e=>j(_C,t=>t?je(e,new Headers(t)):e)))),r=yield*Ue(),i=n.event.subscribe();class a{cause;constructor(e){this.cause=e}}let o=Bt(e=>nt(i.pipe(d(hC(e)),Le(e=>be(new a(e)))),r)),c=e=>Se(o.subscribe({types:e?.types}),e=>e).pipe(At(e=>s(e instanceof a?e.cause:Je(new Pa({cause:e})))));return{...n,event:{...n.event,subscribe:c},rpc:Object.assign(mC((e,t)=>n.rpc.call(e).pipe(it(_C,t?.headers)),c),n.rpc)}}),yC=e({Answer:()=>CC,Prompt:()=>SC,Question:()=>yC}),bC=C({label:x.annotate({description:`Display text (1-5 words, concise)`}),description:x.annotate({description:`Explanation of choice`})}),xC={question:x.annotate({description:`Complete question`}),header:x.annotate({description:`Very short label (max 30 chars)`}),options:g(bC).annotate({description:`Available choices`}),multiple:v.pipe(B).annotate({description:`Allow selecting multiple choices`})},SC=C(xC).annotate({identifier:`Question.Prompt`}),CC=g(x).annotate({identifier:`Question.Answer`}),wC=e({AbsolutePath:()=>La,Agent:()=>au,ClientError:()=>Pa,Command:()=>Bm,Config:()=>_g,Credential:()=>rs,Event:()=>eo,EventLog:()=>lm,FileSystem:()=>Em,Form:()=>vs,Integration:()=>Us,Location:()=>Ya,Model:()=>Mc,OpenCode:()=>gC,Permission:()=>ql,PermissionSaved:()=>Sm,Project:()=>fu,Prompt:()=>rl,PromptInput:()=>Vp,Provider:()=>mc,Pty:()=>Il,Question:()=>yC,Reference:()=>fv,RelativePath:()=>Ia,Session:()=>Wf,SessionInbox:()=>Rd,SessionMessage:()=>Uu,Skill:()=>lo,Vcs:()=>_y,WebSearch:()=>ng,Worktree:()=>Tg}),TC=20;function EC(e){return JSON.stringify([e.directory,e.workspaceID])}function DC(e){return{directory:e.directory}}function OC(e){let t=e?.flatMap(e=>{if(!e.uri.startsWith(`data:`))return[];let t=e.uri.indexOf(`,`);if(t<0)return[];let n=e.uri.slice(5,t).split(`;`);if(!n.slice(1).some(e=>e.toLowerCase()===`base64`))return[];let r={data:e.uri.slice(t+1),mime:n[0]||`application/octet-stream`,source:{type:`inline`}};return e.name!==void 0&&(r.name=e.name),e.description!==void 0&&(r.description=e.description),e.mention!==void 0&&(r.mention={...e.mention}),[r]});return t?.length?t:void 0}function kC(e){let t=e=>e.type===`file`&&e.uri.startsWith(`data:`)?{...e,uri:`data:${e.mime};base64,`}:e;return[t(e[0]),...e.slice(1).map(t)]}function AC(e){return e.type===`assistant`?{...e,content:e.content.map(e=>e.type===`tool`&&`content`in e.state&&e.state.content?{...e,state:{...e.state,content:kC(e.state.content)}}:e)}:e}function jC(e,t){if(!(e!==`global`||!t))return{headers:{"x-opencode-directory":encodeURIComponent(t.directory)}}}function MC(){let e=new Map,t=(t,n,r)=>{let i={promise:Promise.resolve(),invalidated:!1,started:!r};e.set(t,i);let a=()=>(i.started=!0,n());return i.promise=(r?r.catch(()=>{}).then(a):a()).then(()=>{e.get(t)===i&&!i.invalidated&&e.set(t,!0)}).finally(()=>{e.get(t)===i&&e.delete(t)}),i.promise};return{run(n,r){let i=e.get(n);return i===!0?Promise.resolve():i?i.invalidated?t(n,r,i.promise):i.promise:t(n,r)},complete(t){e.has(t)||e.set(t,!0)},has(t){return e.has(t)},pending(t){let n=e.get(t);return n!==void 0&&n!==!0},invalidate(t){if(t){let n=e.get(t);n===!0&&e.delete(t),n!==void 0&&n!==!0&&n.started&&(n.invalidated=!0);return}e.forEach((t,n)=>{t===!0&&e.delete(n),t!==!0&&t.started&&(t.invalidated=!0)})}}}var NC=200;function PC(e){let t=e.api,n=!1;Br(()=>n=!0);function r(t){n||e.connection&&e.connection.status()!==`connected`||t().catch(t=>{if(!(n||e.connection&&e.connection.status()!==`connected`)){if(e.onError)return e.onError(t);console.error(`Failed to refresh client data`,t)}})}let i=new Map;Br(()=>i.forEach(e=>clearTimeout(e)));function a(e,t){clearTimeout(i.get(e)),i.set(e,setTimeout(()=>{i.delete(e),r(t)},150))}let[o,s]=xa({session:{info:{},family:{},active:{},message:{},messageCursor:{},messageLoading:{},pending:{},permission:{},form:{}},project:{info:{},permission:{}},location:{}}),[c,l]=Er({directory:e.directory}),u=jr(()=>Object.values(o.session.info).toSorted((e,t)=>t.time.updated-e.time.updated)),d=new Map,f=t=>e.omitToolFileData?AC(t):t,p=MC(),ee,te=new Map;function m(e,t){ee?.set(e,t),s(`session`,`active`,e,t)}function h(e,t){t&&(te.get(e)?.set(t,void 0),o.session.pending[e]?.some(e=>e.id===t)&&s(`session`,`pending`,e,(o.session.pending[e]??[]).filter(e=>e.id!==t)))}function ne(e,t){let n=o.session.permission[e];n?.some(e=>e.id===t)&&s(`session`,`permission`,e,n.filter(e=>e.id!==t))}function re(e,t,n){let r=o.session.form[e];if(!r)return!1;let i=n&&EC(n),a=r.filter(n=>n.id===t?e!==`global`||!i?!1:!n.location||EC(n.location)!==i:!0);return a.length!==r.length&&(s(`session`,`form`,e,a),!0)}function ie(e,t,n){return n.catch(t=>{if(!fn(t)&&!mn(t)||t.id!==e.formID)throw t}).then(()=>{re(e.sessionID,e.formID,t)&&(b.session.form.invalidate(e.sessionID,t),b.session.form.sync(e.sessionID,t).catch(()=>{}))})}function ae(e,t,n){let r=o.session.pending[e]?.findIndex(e=>e.id===t)??-1,i=o.session.pending[e]?.[r];te.get(e)?.set(t,i?{...i,delivery:n}:n),!(r<0||!i||i.delivery===n)&&s(`session`,`pending`,e,r,{...i,delivery:n})}let oe=new Set,se=new Set,ce=new Map,le=new Map,ue=new Map,de=new Map;Br(()=>de.clear());function fe(e,t,n){e.set(t,n);let r=()=>{e.get(t)===n&&e.delete(t)};n.then(r,r)}function g(e,t,n){let r=ce.get(e),i=le.get(e),a=Promise.resolve().then(()=>Promise.all([n,r,i])).then(t);return fe(le,e,a.catch(()=>{})),a}function _(e){Ir(()=>{let t=o.session.pending[e.sessionID]??[],n=t.findIndex(t=>t.id===e.id);s(`session`,`pending`,e.sessionID,n<0?[...t,e]:t.map((t,r)=>r===n?e:t)),e.type!==`compaction`&&pe(e)})}function pe(e){(e.type===`user`||e.type===`synthetic`)&&v.update(e.sessionID,(t,n)=>{let r=e.type===`user`?{id:e.id,type:`user`,...e.payload,time:{created:e.time.created}}:{id:e.id,type:`synthetic`,...e.payload,time:{created:e.time.created}},i=n.get(e.id);if(i===void 0)return v.append(t,n,r);t[i]=r})}function me(e,t){Ir(()=>{h(e,t),d.get(e)?.has(t)&&v.update(e,(e,n)=>{let r=n.get(t);r!==void 0&&(e.splice(r,1),n.delete(t),v.reindex(e,n,r))})})}let v={update(e,t){s(`session`,`message`,Na(n=>{t(n[e]??=[],he(e))}))},append(e,t,n){t.has(n.id)||(t.set(n.id,e.length),e.push(n))},insert(e,t){v.update(e,(e,n)=>v.append(e,n,t))},editAssistant(e,t,n){d.get(e)?.has(t)&&v.update(e,(e,r)=>{let i=r.get(t),a=i===void 0?void 0:e[i];a?.type===`assistant`&&n(a)})},editTool(e,t,n,r){v.editAssistant(e,t,e=>{let t=e.content.findLast(e=>e.type===`tool`&&e.id===n);t&&r(t)})},editText(e,t,n){v.editAssistant(e,t,e=>{let t=e.content.findLast(e=>e.type===`text`);t&&n(t)})},editReasoning(e,t,n){v.editAssistant(e,t,e=>{let t=e.content.findLast(e=>e.type===`reasoning`&&!e.time?.completed);t&&n(t)})},activeAssistant(e){let t=e.findLast(e=>e.type===`assistant`&&!e.time.completed);return t?.type===`assistant`?t:void 0},shell(e,t){let n=e.findLast(e=>e.type===`shell`&&e.shellID===t);return n?.type===`shell`?n:void 0},compaction(e){let t=e.findLast(e=>e.type===`compaction`&&e.status===`running`);return t?.type===`compaction`?t:void 0},reindex(e,t,n){for(let r=n;r<e.length;r++){let n=e[r];n&&t.set(n.id,r)}}};function he(e){let t=d.get(e);if(t)return t;let n=new Map;return d.set(e,n),n}async function ge(e){let n=await t().session.list(e);return n.data.length<NC||!n.cursor.next?n.data:[...n.data,...await ge({cursor:n.cursor.next,limit:NC})]}function _e(e){let t=e,n=o.session.info[e]?.parentID,r=new Set([e]);for(;n&&!r.has(n);)r.add(n),t=n,n=o.session.info[n]?.parentID;return t}function ve(e){if(!o.session.info[e])return;let t=_e(e);s(`session`,`family`,Na(n=>{if(e!==t&&n[e]){let r=n[t]??=[];for(let t of n[e])r.includes(t)||r.push(t);delete n[e]}let r=n[t]??=[];r.includes(e)||r.push(e)}))}function ye(e){if(se.has(e))return;p.invalidate(`session.pending:${e}`),p.invalidate(`session.message:${e}`),ue.delete(e);let t=o.session.pending[e]?.filter(e=>oe.has(e.id))??[],n=o.session.message[e]?.filter(e=>oe.has(e.id))??[];d.delete(e),n.length&&d.set(e,new Map(n.map((e,t)=>[e.id,t]))),s(`session`,Na(r=>{delete r.message[e],delete r.messageCursor[e],delete r.messageLoading[e],delete r.pending[e],n.length&&(r.message[e]=n),t.length&&(r.pending[e]=t)}))}function be(e){ee?.set(e,void 0),o.session.pending[e]?.forEach(e=>oe.delete(e.id)),d.delete(e),p.invalidate(`session:${e}`),p.invalidate(`session.family:${e}`),p.invalidate(`session.pending:${e}`),p.invalidate(`session.message:${e}`),p.invalidate(`session.permission:${e}`),p.invalidate(`session.form:${e}:`),s(`session`,Na(t=>{delete t.info[e],delete t.active[e],delete t.message[e],delete t.messageCursor[e],delete t.messageLoading[e],delete t.pending[e],delete t.permission[e],delete t.form[e];for(let[n,r]of Object.entries(t.family)){let i=r.filter(t=>t!==e);i.length===0?delete t.family[n]:t.family[n]=i}}))}function xe(n){switch(n.type){case`server.connected`:{let e=new Map;ee=e,r(()=>t().session.active().then(t=>{if(ee!==e)return;let n=new Map(Object.keys(t).map(e=>[e,`running`]));e.forEach((e,t)=>{if(e===void 0)return n.delete(t);n.set(t,e)}),ee=void 0,s(`session`,`active`,Aa(Object.fromEntries(n))),n.forEach((e,t)=>{e===`running`&&!o.session.info[t]&&r(()=>b.session.sync(t))})}).catch(()=>{ee===e&&(ee=void 0)})),r(()=>t().location.get({location:DC(c())}).then(e=>{let t=EC(e);s(`location`,t,{info:e})})),r(()=>b.location.vcs.sync()),r(()=>b.project.sync());return}case`project.updated`:s(`project`,`info`,n.data.id,Aa(n.data));return;case`session.created`:se.delete(n.data.sessionID),b.session.invalidate(n.data.sessionID),r(()=>b.session.sync(n.data.sessionID)),p.complete(`session.pending:${n.data.sessionID}`),p.complete(`session.message:${n.data.sessionID}`);return;case`session.deleted`:be(n.data.sessionID);return;case`session.usage.updated`:o.session.info[n.data.sessionID]&&s(`session`,`info`,n.data.sessionID,{cost:n.data.cost,tokens:n.data.tokens});return;case`session.agent.selected`:{let e=o.session.info[n.data.sessionID]?.agent;o.session.info[n.data.sessionID]&&s(`session`,`info`,n.data.sessionID,`agent`,n.data.agent),v.insert(n.data.sessionID,{id:K.fromEvent(n.id),type:`agent-switched`,agent:n.data.agent,previous:e,time:{created:n.created}});return}case`session.model.selected`:{let e=n.data.previous??o.session.info[n.data.sessionID]?.model;if(o.session.info[n.data.sessionID]&&s(`session`,`info`,n.data.sessionID,`model`,n.data.model),!o.session.message[n.data.sessionID])return;v.insert(n.data.sessionID,{id:K.fromEvent(n.id),type:`model-switched`,model:n.data.model,previous:e,time:{created:n.created}}),r(()=>t().session.message.get({sessionID:n.data.sessionID,messageID:K.fromEvent(n.id)}).then(e=>{v.update(n.data.sessionID,(t,n)=>{let r=n.get(e.id);if(r===void 0)return v.append(t,n,e);t[r]=e})}));return}case`session.renamed`:r(()=>{let e=p.pending(`session.family:${n.data.sessionID}`)?b.session.sync(n.data.sessionID,{children:!0}):Promise.resolve();return Promise.all([b.session.sync(n.data.sessionID),e]).then(()=>{o.session.info[n.data.sessionID]&&s(`session`,`info`,n.data.sessionID,`title`,n.data.title)})});return;case`session.permissions`:o.session.info[n.data.sessionID]&&s(`session`,`info`,n.data.sessionID,`permissions`,n.data.permissions);return;case`session.archived`:o.session.info[n.data.sessionID]&&s(`session`,`info`,n.data.sessionID,`time`,`archived`,n.created);return;case`session.unarchived`:o.session.info[n.data.sessionID]&&s(`session`,`info`,n.data.sessionID,`time`,`archived`,void 0);return;case`session.moved`:{let e=o.session.info[n.data.sessionID];if(e){let t={location:{...e.location},projectID:e.projectID,subpath:e.subpath};s(`session`,`info`,n.data.sessionID,`location`,n.data.location),s(`session`,`info`,n.data.sessionID,`projectID`,n.data.projectID),s(`session`,`info`,n.data.sessionID,`subpath`,n.data.subpath),v.insert(n.data.sessionID,{id:K.fromEvent(n.id),type:`location-switched`,location:n.data.location,projectID:n.data.projectID,subpath:n.data.subpath,previous:t,time:{created:n.created}})}return}case`worktree.resolved`:for(let[e,t]of Object.entries(o.session.info)){let i=n.data.adopted?.includes(t.projectID)?o.project.info[t.projectID]?.canonical:t.location.directory;if(!i){b.session.invalidate(e),r(()=>b.session.sync(e));continue}let a=Lg({projectID:t.projectID,directory:i},n.data);a&&(s(`session`,`info`,e,`projectID`,a.projectID),s(`session`,`info`,e,`subpath`,a.subpath))}return;case`session.inbox.delivered`:{let e=b.session.input.has(n.data.sessionID,n.data.inboxID);h(n.data.sessionID,n.data.inboxID),v.update(n.data.sessionID,(t,r)=>{let i=r.get(n.data.inboxID);if(i===void 0)return;let a=t[i];!a||!e||(a.time.created=n.created,t.splice(i,1),t.push(a),v.reindex(t,r,i))}),de.get(n.data.sessionID)?.observed.add(n.data.inboxID);return}case`session.inbox.delivery.changed`:ae(n.data.sessionID,n.data.inboxID,n.data.delivery);return;case`session.inbox.cancelled`:me(n.data.sessionID,n.data.inboxID),de.get(n.data.sessionID)?.observed.add(n.data.inboxID);return;case`session.inbox.enqueued`:{oe.delete(n.data.inboxID);let e={id:n.data.inboxID,sessionID:n.data.sessionID,time:{created:n.created},...n.data.item};if(te.get(e.sessionID)?.set(e.id,e),_(e),n.data.item.type===`compaction`){let e=de.get(n.data.sessionID);e?.observed.add(n.data.inboxID),e&&e.id!==n.data.inboxID&&oe.delete(e.id)&&h(n.data.sessionID,e.id)}return}case`session.instructions.updated`:let i=n.data.text;if(i===void 0)return;v.insert(n.data.sessionID,{id:K.fromEvent(n.id),type:`system`,text:i,description:`Instructions updated: ${Object.keys(n.data.delta).join(`, `)}`,metadata:n.metadata,time:{created:n.created}});return;case`session.synthetic`:v.insert(n.data.sessionID,{id:K.fromEvent(n.id),type:`synthetic`,text:n.data.text,description:n.data.description,metadata:n.data.metadata,time:{created:n.created}});return;case`session.shell.started`:v.insert(n.data.sessionID,{id:K.fromEvent(n.id),type:`shell`,shellID:n.data.shell.id,command:n.data.shell.command,status:n.data.shell.status,exit:n.data.shell.exit,metadata:n.data.shell.metadata.background===!0?{...n.metadata,background:!0}:n.metadata,time:{created:n.created}});return;case`session.shell.ended`:if(!o.session.message[n.data.sessionID])return;v.update(n.data.sessionID,e=>{let t=v.shell(e,n.data.shell.id);t&&(t.status=n.data.shell.status,t.exit=n.data.shell.exit,t.output=n.data.output,t.time.completed=n.created)});return;case`session.step.started`:v.update(n.data.sessionID,(e,t)=>{let r=t.get(n.data.assistantMessageID),i=r===void 0?void 0:e[r];if(i?.type===`assistant`){i.agent=n.data.agent,i.model=n.data.model,i.retry=void 0,i.error=void 0,i.finish=void 0,i.rawFinish=void 0,i.native=void 0,i.time.created=n.data.started,i.time.streamed=void 0,i.time.completed=void 0,n.data.snapshot&&(i.snapshot={...i.snapshot,start:n.data.snapshot});return}let a=v.activeAssistant(e);a&&(a.retry=void 0,a.time.completed=n.created),v.append(e,t,{id:n.data.assistantMessageID,type:`assistant`,agent:n.data.agent,model:n.data.model,metadata:n.metadata,content:[],snapshot:n.data.snapshot?{start:n.data.snapshot}:void 0,time:{created:n.data.started}})});return;case`session.step.streamed`:v.editAssistant(n.data.sessionID,n.data.assistantMessageID,e=>{e.time.streamed=n.created});return;case`session.step.ended`:v.editAssistant(n.data.sessionID,n.data.assistantMessageID,e=>{e.time.completed=n.created,e.finish=n.data.finish,e.rawFinish=n.data.rawFinish,e.native=n.data.native,e.cost=n.data.cost,e.tokens=n.data.tokens,n.data.snapshot&&(e.snapshot={...e.snapshot,end:n.data.snapshot})});return;case`session.step.failed`:n.location&&(n.data.error.type===`provider.budget-limit`||n.data.error.type===`provider.model-budget-limit`)&&y(n.location),v.editAssistant(n.data.sessionID,n.data.assistantMessageID,e=>{e.time.completed=n.created,e.finish=n.data.finish??`error`,e.rawFinish=n.data.rawFinish,e.native=n.data.native,e.error=n.data.error,e.retry=void 0,n.data.cost!==void 0&&n.data.tokens!==void 0&&(e.cost=n.data.cost,e.tokens=n.data.tokens)});return;case`session.text.started`:v.editAssistant(n.data.sessionID,n.data.assistantMessageID,e=>{e.content.push({type:`text`,text:``})});return;case`session.text.delta`:v.editText(n.data.sessionID,n.data.assistantMessageID,e=>{e.text+=n.data.delta});return;case`session.text.ended`:v.editText(n.data.sessionID,n.data.assistantMessageID,e=>{e.text=n.data.text});return;case`session.tool.input.started`:v.editAssistant(n.data.sessionID,n.data.assistantMessageID,e=>{e.content.push({type:`tool`,id:n.data.id,name:n.data.name,time:{created:n.created},state:{status:`streaming`,input:``}})});return;case`session.tool.input.delta`:v.editTool(n.data.sessionID,n.data.assistantMessageID,n.data.id,e=>{e.state.status===`streaming`&&(e.state.input+=n.data.delta)});return;case`session.tool.input.ended`:v.editTool(n.data.sessionID,n.data.assistantMessageID,n.data.id,e=>{e.state.status===`streaming`&&(e.state.input=n.data.text)});return;case`session.tool.called`:v.editTool(n.data.sessionID,n.data.assistantMessageID,n.data.id,e=>{e.time.ran=n.created,e.executed=n.data.executed,e.native=n.data.native,e.state={status:`running`,input:n.data.input,metadata:{}}});return;case`session.tool.progress`:v.editTool(n.data.sessionID,n.data.assistantMessageID,n.data.id,e=>{e.state.status===`running`&&(e.state.metadata=n.data.metadata)});return;case`session.tool.success`:v.editTool(n.data.sessionID,n.data.assistantMessageID,n.data.id,t=>{t.state.status===`running`&&(t.state={status:`completed`,input:t.state.input,metadata:n.data.metadata,content:e.omitToolFileData?kC(n.data.content):[...n.data.content]},t.executed=n.data.executed||t.executed===!0,n.data.native&&(t.native={...t.native,...n.data.native}),t.time.completed=n.created)});return;case`session.tool.failed`:v.editTool(n.data.sessionID,n.data.assistantMessageID,n.data.id,t=>{(t.state.status===`streaming`||t.state.status===`running`)&&(t.state={status:`error`,error:n.data.error,input:typeof t.state.input==`string`?{}:t.state.input,metadata:n.data.metadata,content:e.omitToolFileData&&n.data.content?kC(n.data.content):n.data.content},t.executed=n.data.executed||t.executed===!0,n.data.native&&(t.native={...t.native,...n.data.native}),t.time.completed=n.created)});return;case`session.reasoning.started`:v.editAssistant(n.data.sessionID,n.data.assistantMessageID,e=>{e.content.push({type:`reasoning`,text:``,native:n.data.native,time:{created:n.created}})});return;case`session.reasoning.delta`:v.editReasoning(n.data.sessionID,n.data.assistantMessageID,e=>{e.text+=n.data.delta});return;case`session.reasoning.ended`:v.editReasoning(n.data.sessionID,n.data.assistantMessageID,e=>{e.text=n.data.text,e.time={created:e.time?.created??n.created,completed:n.created},n.data.native!==void 0&&(e.native=n.data.native)});return;case`session.retry.scheduled`:v.editAssistant(n.data.sessionID,n.data.assistantMessageID,e=>{e.retry={attempt:n.data.attempt,at:n.data.at,error:n.data.error}});return;case`session.execution.started`:m(n.data.sessionID,`running`);return;case`session.compaction.started`:n.data.inputID&&h(n.data.sessionID,n.data.inputID),v.insert(n.data.sessionID,{id:n.data.inputID??K.fromEvent(n.id),type:`compaction`,status:`running`,reason:n.data.reason,summary:``,time:{created:n.created}}),n.data.inputID&&de.get(n.data.sessionID)?.observed.add(n.data.inputID);return;case`session.execution.succeeded`:case`session.execution.failed`:case`session.execution.interrupted`:if(m(n.data.sessionID,`idle`),v.update(n.data.sessionID,e=>{let t=v.activeAssistant(e);t&&(t.retry=void 0)}),n.type===`session.execution.interrupted`&&n.data.reason===`shutdown`||(v.insert(n.data.sessionID,{id:K.fromEvent(n.id),type:`idle`,outcome:n.type===`session.execution.succeeded`?`succeeded`:n.type===`session.execution.failed`?`failed`:`interrupted`,...n.type===`session.execution.failed`?{error:n.data.error}:{},time:{created:n.created}}),o.session.message[n.data.sessionID]?.some(e=>e.type===`assistant`&&e.content.some(e=>e.type===`tool`&&(e.state.status===`streaming`||e.state.status===`running`)))&&(p.invalidate(`session.message:${n.data.sessionID}`),r(()=>b.session.message.sync(n.data.sessionID))),!o.session.info[n.data.sessionID]&&!p.has(`session:${n.data.sessionID}`)))return;b.session.invalidate(n.data.sessionID),r(()=>b.session.sync(n.data.sessionID));return;case`session.viewed`:if(!o.session.info[n.data.sessionID]&&!p.has(`session:${n.data.sessionID}`))return;b.session.invalidate(n.data.sessionID),r(()=>b.session.sync(n.data.sessionID));return;case`session.revert.staged`:o.session.info[n.data.sessionID]&&s(`session`,`info`,n.data.sessionID,`revert`,n.data.revert);return;case`session.revert.cleared`:o.session.info[n.data.sessionID]&&s(`session`,`info`,n.data.sessionID,`revert`,void 0);return;case`session.revert.committed`:o.session.info[n.data.sessionID]&&s(`session`,`info`,n.data.sessionID,`revert`,void 0),s(`session`,`pending`,n.data.sessionID,(o.session.pending[n.data.sessionID]??[]).filter(e=>e.id<n.data.to)),v.update(n.data.sessionID,(e,t)=>{let r=e.findIndex(e=>e.id>=n.data.to);if(r!==-1)for(let n of e.splice(r))t.delete(n.id)});return;case`session.compaction.delta`:if(!o.session.message[n.data.sessionID])return;v.update(n.data.sessionID,e=>{let t=v.compaction(e);t?.status===`running`&&(t.summary+=n.data.text)});return;case`session.compaction.ended`:v.update(n.data.sessionID,(e,t)=>{let r=e[e.findLastIndex(e=>e.type===`compaction`&&e.status===`running`)];if(r?.type===`compaction`){Object.assign(r,{status:`completed`,reason:n.data.reason,model:n.data.model,native:n.data.native,summary:n.data.text,cost:n.data.cost,tokens:n.data.tokens});return}v.append(e,t,{id:K.fromEvent(n.id),type:`compaction`,status:`completed`,reason:n.data.reason,model:n.data.model,native:n.data.native,summary:n.data.text,cost:n.data.cost,tokens:n.data.tokens,time:{created:n.created}})});return;case`session.compaction.failed`:n.data.inputID&&h(n.data.sessionID,n.data.inputID),v.update(n.data.sessionID,(e,t)=>{let r=e.findLastIndex(e=>e.type===`compaction`&&e.status===`running`),i=e[r],a={id:i?.id??n.data.inputID??K.fromEvent(n.id),type:`compaction`,status:`failed`,reason:n.data.reason,error:n.data.error,metadata:i?.type===`compaction`?i.metadata:n.metadata,cost:n.data.cost,tokens:n.data.tokens,time:i?.type===`compaction`?i.time:{created:n.created}};if(i?.type===`compaction`){e[r]=a;return}v.append(e,t,a)}),n.data.inputID&&de.get(n.data.sessionID)?.observed.add(n.data.inputID);return;case`permission.asked`:if(o.session.permission[n.data.sessionID]?.some(e=>e.id===n.data.id))return;s(`session`,`permission`,n.data.sessionID,[...o.session.permission[n.data.sessionID]??[],n.data]);return;case`permission.replied`:ne(n.data.sessionID,n.data.requestID);return;case`form.replied`:case`form.cancelled`:re(n.data.sessionID,n.data.id,n.location);return}if(n.type===`credential.updated`||n.type===`credential.switched`){Object.keys(o.location).forEach(e=>{let t=JSON.parse(e),i={directory:t[0],workspaceID:t[1]??void 0};if(y(i),n.type===`credential.updated`){Ce(`integration`,b.location.integration,i);return}o.location[e]?.integration&&s(`location`,e,e=>({integration:e?.integration?.map(e=>{if(e.id!==n.data.integrationID)return e;let t=e.connections.find(e=>e.type===`credential`&&e.id===n.data.credentialID);return t?{...e,connections:[t,...e.connections.filter(e=>e!==t)]}:e})}));let a=Se(`integration`,i)||Se(`model`,i)||Se(`provider`,i);b.location.model.invalidate(i),b.location.provider.invalidate(i),a&&r(()=>Promise.all([b.location.model.sync(i),b.location.provider.sync(i)]))});return}if(!n.location)return;let i=n.location;switch(n.type){case`provider.updated`:Ce(`provider`,b.location.provider,i);break;case`model.updated`:Ce(`model`,b.location.model,i);break;case`agent.updated`:Ce(`agent`,b.location.agent,i);break;case`command.updated`:Ce(`command`,b.location.command,i);break;case`skill.updated`:Ce(`skill`,b.location.skill,i);break;case`vcs.branch.updated`:Ce(`vcs`,b.location.vcs,i);break;case`form.created`:if(o.session.form[n.data.form.sessionID]?.some(e=>e.id===n.data.form.id))break;s(`session`,`form`,n.data.form.sessionID,[...o.session.form[n.data.form.sessionID]??[],n.data.form.sessionID===`global`?{...n.data.form,location:i}:n.data.form]);break;case`shell.created`:s(`location`,EC(i),e=>({shell:{...e?.shell,[n.data.info.id]:{...n.data.info,location:i}}}));break;case`shell.exited`:case`shell.deleted`:if(!o.location[EC(i)]?.shell?.[n.data.id])break;s(`location`,EC(i),e=>({shell:Object.fromEntries(Object.entries(e?.shell??{}).filter(([e])=>e!==n.data.id))}));break;case`reference.updated`:Ce(`reference`,b.location.reference,i);break;case`integration.updated`:{y(i);let e=Se(`integration`,i)||Se(`model`,i)||Se(`provider`,i);b.location.integration.invalidate(i),b.location.model.invalidate(i),b.location.provider.invalidate(i),e&&r(()=>Promise.all([b.location.integration.sync(i),b.location.model.sync(i),b.location.provider.sync(i)]));break}case`config.updated`:Ce(`config`,b.location.config,i),Se(`websearch`,i)&&r(()=>b.location.websearch.refresh(i));break;case`websearch.updated`:Se(`websearch`,i)&&r(()=>b.location.websearch.refresh(i));break;case`mcp.status.changed`:{let e=Se(`mcpServer`,i);b.location.mcp.server.invalidate(i),e&&a(`mcp.status:${EC(i)}`,()=>b.location.mcp.server.sync(i));break}case`mcp.resources.changed`:Ce(`mcpResource`,b.location.mcp.resource,i)}}function Se(e,t){let n=EC(t??c());return o.location[n]?.[e]!==void 0||p.has(`location.${e}:${n}`)}function Ce(e,t,n){let i=Se(e,n);t.invalidate(n),i&&r(()=>t.sync(n))}function y(e){let t=o.location[EC(e)]?.usageLimits!==void 0||p.has(`location.usageLimits:${EC(e)}`);Ee.invalidate(e),t&&r(()=>Ee.sync(e))}function we(e,t,n){let r=(t,n)=>s(`location`,t,{[e]:n});return{list:t=>o.location[EC(t??c())]?.[e],sync:i=>{let a=i??c(),o=EC(a);return p.run(`location.${e}:${o}`,async()=>{let e=await t(DC(a)),i=EC(e.location);r(i,e.data),n?.alias&&i!==o&&r(o,e.data)})},invalidate:t=>p.invalidate(`location.${e}:${EC(t??c())}`)}}let Te=we(`vcs`,e=>t().vcs.get({location:e})),Ee=we(`usageLimits`,e=>t().usage.limits({location:e})),De=we(`shell`,async e=>{let n=await t().shell.list({location:e}),r={directory:n.location.directory};return{location:n.location,data:Object.fromEntries(n.data.map(e=>[e.id,{...e,location:r}]))}}),b={on:e.event.on,listen:e.event.listen,session:{list(){return u()},get(e){return o.session.info[e]},creating(e){return ce.has(e)},remember(e){Ir(()=>{s(`session`,`info`,e.id,Aa(e)),p.complete(`session:${e.id}`),ve(e.id)})},setStatus(e,t){m(e,t)},root(e){return _e(e)},family(e){return o.session.family[_e(e)]??[]},evict(e){let t=_e(e);Ir(()=>{for(let n of new Set([t,e,...o.session.family[t]??[]]))ye(n)})},cost(e){let t=o.session.info[e];return t?t.parentID?t.cost:(o.session.family[e]??[e]).reduce((e,t)=>e+(o.session.info[t]?.cost??0),0):0},status(e){return o.session.active[e]??`idle`},active(){return Object.entries(o.session.active).flatMap(([e,t])=>t===`running`?[e]:[])},input:{list(e){return(o.session.pending[e]??[]).flatMap(e=>e.type===`compaction`?[]:[e.id])},has(e,t){return o.session.pending[e]?.some(e=>e.id===t&&e.type!==`compaction`)??!1}},pending:{list(e){return o.session.pending[e]??[]},status(e,t){let n=o.session.pending[e]??[],r=n.find(e=>e.id===t&&e.type===`user`);if(!r)return;if(r.delivery===`queue`)return`queued`;let i=o.session.message[e]??[],a=i.findLastIndex(e=>e.type===`idle`);return(o.session.active[e]??`idle`)===`idle`?a>=0&&r.time.created<=i[a].time.created?`stranded`:`starting`:i.slice(a+1).some(e=>e.type===`user`&&!n.some(t=>t.id===e.id))?`steering`:`starting`},sync(e){return p.run(`session.pending:${e}`,async()=>{let n=new Map;te.set(e,n);try{let r=await t().session.inbox.list({sessionID:e}),i=new Map(r.map(e=>[e.id,e]));n.forEach((e,t)=>{if(e===void 0)i.delete(t);else if(typeof e==`string`){let n=i.get(t);n&&i.set(t,{...n,delivery:e})}else i.set(t,e)});let a=[...i.values()];a.forEach(e=>oe.delete(e.id)),a.some(e=>e.type===`compaction`)&&o.session.pending[e]?.filter(e=>e.type===`compaction`).forEach(e=>oe.delete(e.id));let c=(o.session.pending[e]??[]).filter(e=>oe.has(e.id)),l=c.length===0?a:[...a,...c];Ir(()=>{s(`session`,`pending`,e,Aa(l)),l.forEach(pe)})}finally{te.get(e)===n&&te.delete(e)}})},invalidate(e){p.invalidate(`session.pending:${e}`)}},create(e){let{projectID:n,...r}=e,i=r.id??Kl.create(),a=r.location??c(),s=!o.session.info[i];if(s){let e=Date.now();se.add(i),b.session.remember({id:i,projectID:n??o.location[EC(a)]?.info?.project.id??``,agent:r.agent,model:r.model,cost:0,tokens:{input:0,output:0,reasoning:0,cache:{read:0,write:0}},time:{created:e,updated:e},title:r.title,location:a}),p.complete(`session.family:${i}`),p.complete(`session.pending:${i}`),p.complete(`session.message:${i}`)}let l=Promise.resolve().then(()=>t().session.create({...r,id:i,location:a})).then(e=>(se.delete(i),b.session.remember(e),e)).catch(e=>{throw s&&se.delete(i)&&be(i),e});return s&&fe(ce,i,l),{id:i,request:l}},compact(e){let n=de.get(e.sessionID);if(n)return n.request;let r=K.create();o.session.pending[e.sessionID]?.some(e=>e.type===`compaction`)||(oe.add(r),_({id:r,sessionID:e.sessionID,time:{created:Date.now()},type:`compaction`,delivery:`steer`,payload:{}}));let i=new Set,a=g(e.sessionID,async()=>(e.model&&await t().session.switchModel({sessionID:e.sessionID,model:e.model}),t().session.compact({sessionID:e.sessionID,id:r}))).then(t=>(Ir(()=>{oe.delete(r),t.id!==r&&h(e.sessionID,r),!i.has(t.id)&&!d.get(e.sessionID)?.has(t.id)&&_(t)}),t)).catch(t=>{throw oe.delete(r)&&h(e.sessionID,r),t}).finally(()=>{de.get(e.sessionID)?.request===a&&de.delete(e.sessionID)});return de.set(e.sessionID,{id:r,observed:i,request:a}),a},prompt(e){let{gate:n,prepare:r,...i}=e,a=i.id??K.create(),s=!d.get(i.sessionID)?.has(a)&&!o.session.pending[i.sessionID]?.some(e=>e.id===a);if(s){let e=OC(i.files),t={text:i.text,agents:i.agents?.map(e=>({...e})),metadata:i.metadata};e&&(t.files=e),oe.add(a),_({id:a,sessionID:i.sessionID,time:{created:Date.now()},type:`user`,delivery:i.delivery??`steer`,payload:t})}return g(i.sessionID,async()=>(await r?.(),t().session.prompt({...i,id:a})),n).catch(e=>{throw s&&oe.delete(a)&&me(i.sessionID,a),e})},sync(e,n){return p.run(n?.children?`session.family:${e}`:`session:${e}`,async()=>{let[r,i]=await Promise.all([t().session.get({sessionID:e}),n?.children?ge({parentID:e,order:`desc`,limit:NC}):[]]),a=[r,...i];Ir(()=>{s(`session`,`info`,Na(e=>{for(let t of a)e[t.id]=t}));for(let e of a)p.complete(`session:${e.id}`),ve(e.id)})})},invalidate(e){p.invalidate(`session:${e}`)},message:{list(e){return o.session.message[e]??[]},get(e,t){let n=o.session.message[e],r=d.get(e)?.get(t);return r===void 0?void 0:n?.[r]},sync(n){return p.run(`session.message:${n}`,async()=>{let r=await t().message.list({sessionID:n,limit:e.initialMessageLimit?.()??TC,order:`desc`}),i=r.data.toReversed().map(f),a=new Set(i.map(e=>e.id)),c=new Set((o.session.pending[n]??[]).flatMap(e=>e.type===`user`||e.type===`synthetic`?[e.id]:[])),l=(o.session.message[n]??[]).filter(e=>!a.has(e.id)&&(oe.has(e.id)||c.has(e.id))),u=l.length===0?i:[...i,...l];Ir(()=>{d.set(n,new Map(u.map((e,t)=>[e.id,t]))),s(`session`,`message`,n,Aa(u)),s(`session`,`messageCursor`,n,r.cursor.next??void 0)})})},more(e){return o.session.messageCursor[e]!==void 0},loading(e){return o.session.messageLoading[e]??!1},async loadMore(e,n){let r=n?.signal;if(r?.aborted)return;for(;ue.has(e);){let t=await(()=>{let t=ue.get(e);if(!r)return t;let n=Promise.withResolvers(),i=()=>n.resolve();return r.addEventListener(`abort`,i,{once:!0}),Promise.race([t,n.promise]).catch(e=>{if(!r.aborted)throw e}).finally(()=>r.removeEventListener(`abort`,i))})();if(!n?.all&&t||r?.aborted)return}let i=o.session.messageCursor[e];if(!i||r?.aborted)return;s(`session`,`messageLoading`,e,!0);let a=(async()=>{let a=[],c=i;do{let i=await t().message.list({sessionID:e,limit:n?.all?200:TC,cursor:c},{signal:r});if(r?.aborted)return;if(a.push(...i.data.map(f)),c=i.cursor.next??void 0,!n?.all)break}while(c);let l=o.session.message[e]??[],u=new Set(l.map(e=>e.id)),p=[...a.reverse().filter(e=>!u.has(e.id)),...l];return Ir(()=>{n?.beforePublish?.(),d.set(e,new Map(p.map((e,t)=>[e.id,t]))),s(`session`,`message`,e,Aa(p)),s(`session`,`messageCursor`,e,c)}),!0})().catch(e=>{if(!r?.aborted)throw e}).finally(()=>s(`session`,`messageLoading`,e,!1));fe(ue,e,a),await a},invalidate(e){p.invalidate(`session.message:${e}`)}},permission:{list(e){return o.session.permission[e]},sessions(){return Object.entries(o.session.permission).flatMap(([e,t])=>t.length>0?[e]:[])},sync(e){return p.run(`session.permission:${e}`,async()=>{s(`session`,`permission`,e,await t().permission.list({sessionID:e}))})},invalidate(e){p.invalidate(`session.permission:${e}`)},async reply(e){await t().permission.reply(e).catch(e=>{if(!En(e))throw e}),ne(e.sessionID,e.requestID)}},form:{list(e,t){let n=o.session.form[e];if(e!==`global`)return n;if(!t)return;let r=EC(t);return n?.filter(e=>e.location&&EC(e.location)===r)},sessions(){return Object.entries(o.session.form).flatMap(([e,t])=>e!==`global`&&t.length>0?[e]:[])},sync(e,n){let r=`session.form:${e}:${e===`global`?EC(n??c()):``}`;return p.run(r,async()=>{if(e===`global`){let r=await t().form.list({location:DC(n??c())}),i={directory:r.location.directory},a=EC(i);s(`session`,`form`,e,[...(o.session.form[e]??[]).filter(e=>e.location&&EC(e.location)!==a),...r.data.filter(e=>e.sessionID===`global`).map(e=>({...e,location:i}))]);return}s(`session`,`form`,e,await t().session.form.list({sessionID:e}))})},invalidate(e,t){p.invalidate(`session.form:${e}:${e===`global`?EC(t??c()):``}`)},reply(e,n){return ie(e,n,t().session.form.reply(e,jC(e.sessionID,n)))},cancel(e,n){return ie(e,n,t().session.form.cancel(e,jC(e.sessionID,n)))}}},project:{list(){return Object.values(o.project.info).filter(e=>e.time.archived===void 0).toSorted((e,t)=>t.time.active-e.time.active)},get(e){return o.project.info[e]},sync(){return p.run(`project`,async()=>{let e=await t().project.list();s(`project`,`info`,Aa(Object.fromEntries(e.map(e=>[e.id,e]))))})},invalidate(){p.invalidate(`project`)},permission:{list(e){return o.project.permission[e]},sync(e){return p.run(`project.permission:${e}`,async()=>{s(`project`,`permission`,e,await t().permission.saved.list({projectID:e}))})},invalidate(e){p.invalidate(`project.permission:${e}`)}}},shell:{list(e){return Object.values(De.list(e)??{})},listBySession(e){return Object.values(o.location).flatMap(e=>Object.values(e.shell??{})).filter(t=>t.metadata.sessionID===e)},get(e){return Object.values(o.location).map(t=>t.shell?.[e]).find(e=>e!==void 0)},sync:De.sync,invalidate:De.invalidate},location:{info(e){return o.location[EC(e??c())]?.info},default(){return c()},syncInfo(e){let n=e??c();return p.run(`location:${EC(n)}`,async()=>{let r=await t().location.get({location:DC(n)}),i=EC(r);o.location[i]||s(`location`,i,{}),s(`location`,i,`info`,r),e||l({directory:r.directory})})},async sync(e){await b.location.syncInfo(e);let t=e??c();await Promise.all([b.location.vcs.sync(t),b.location.agent.sync(t),b.location.command.sync(t),b.location.integration.sync(t),b.location.mcp.server.sync(t),b.location.mcp.resource.sync(t),b.location.model.sync(t),b.location.provider.sync(t),b.location.reference.sync(t),b.location.skill.sync(t),b.shell.sync(t),b.session.form.sync(`global`,t)])},invalidate(e){let t=e??c();p.invalidate(`location:${EC(t)}`),b.location.vcs.invalidate(t),b.location.agent.invalidate(t),b.location.command.invalidate(t),b.location.config.invalidate(t),b.location.integration.invalidate(t),b.location.mcp.server.invalidate(t),b.location.mcp.resource.invalidate(t),b.location.model.invalidate(t),b.location.provider.invalidate(t),b.location.reference.invalidate(t),b.location.skill.invalidate(t),b.shell.invalidate(t),b.session.form.invalidate(`global`,t)},vcs:{info:Te.list,sync:Te.sync,invalidate:Te.invalidate},usage:{limits:Ee.list,sync:Ee.sync,invalidate:Ee.invalidate},agent:we(`agent`,e=>t().agent.list({location:e})),command:we(`command`,e=>t().command.list({location:e})),config:we(`config`,async e=>({location:{directory:e.directory},data:await t().config.get({location:e})})),integration:we(`integration`,e=>t().integration.list({location:e})),mcp:{server:we(`mcpServer`,e=>t().mcp.list({location:e})),resource:we(`mcpResource`,async e=>{let n=await t().mcp.resource.catalog({location:e});return{location:n.location,data:n.data.resources}})},model:we(`model`,e=>t().model.list({location:e}),{alias:!0}),provider:we(`provider`,e=>t().provider.list({location:e}),{alias:!0}),reference:we(`reference`,e=>t().reference.list({location:e})),websearch:{list(e){return o.location[EC(e??c())]?.websearch},async refresh(e){let n={location:DC(e??c())},r=await t().websearch.providers(n),i=EC(r.location);s(`location`,i,{websearch:r.data})}},skill:we(`skill`,e=>t().skill.list({location:e}))}};return kr(()=>{e.connection?.status()!==`connected`&&p.invalidate()}),Br(e.event.listen(({details:e})=>{xe(e)})),b}var FC=2e3,IC=1e3,LC=50,RC=45e3,zC=2e4;function BC(e,t){let n=new AbortController,r=[],i=t.idleTimeout??45e3,[a,o]=xa({status:`connecting`,attempt:0}),s=e,c=[],l,u,d,f,p=!1,ee=0,te=0,m=!1;function h(e,t,n){r.push({type:`client.connection`,created:Date.now(),data:{status:e,attempt:t,error:n}}),r.length>LC&&r.shift()}function ne(e){c.push(e),!l&&(l=setTimeout(()=>{l=void 0;let e=c;c=[],Ir(()=>e.forEach(t.onEvent))},t.flushInterval??10))}async function re(e,n){let r,a=new AbortController;d=a;let c=()=>a.abort(e.reason),l=setTimeout(()=>a.abort(Error(`Timed out connecting to server`)),FC);e.addEventListener(`abort`,c,{once:!0});let u,f=()=>{te=Date.now(),r!==void 0&&(clearTimeout(u),u=setTimeout(()=>a.abort(Error(`Event stream stalled`)),i))};try{h(n===0?`connecting`:`reconnecting`,n),t.log?.info?.(`event stream connecting`,{attempt:n});let i=s.event.subscribe({signal:a.signal,onActivity:f})[Symbol.asyncIterator](),c=await i.next();if(e.aborted)return{error:void 0,connectedAt:r};if(c.done)return{error:a.signal.reason instanceof Error?a.signal.reason:Error(`Event stream disconnected`),connectedAt:r};if(c.value.type!==`server.connected`)return{error:Error(`Event stream did not start with server.connected`),connectedAt:r};for(clearTimeout(l),h(`connected`,n),r=Date.now(),f(),t.log?.info?.(`event stream connected`),ne(c.value),o({status:`connected`,attempt:0,error:void 0});!e.aborted;){let n=await i.next();if(e.aborted)return{error:void 0,connectedAt:r};if(n.done)return{error:a.signal.reason instanceof Error?a.signal.reason:Error(`Event stream disconnected`),connectedAt:r};f(),`durable`in n.value&&n.value.durable&&t.log?.debug?.(`event`,{type:n.value.type,aggregateID:n.value.durable.aggregateID,seq:n.value.durable.seq}),ne(n.value)}return{error:void 0,connectedAt:r}}catch(e){return{error:e,connectedAt:r}}finally{a.abort(),d===a&&(d=void 0),clearTimeout(l),clearTimeout(u),e.removeEventListener(`abort`,c)}}async function ie(e){let r=0;for(;!n.signal.aborted&&p&&ee===e;){o({status:r===0?`connecting`:`reconnecting`,attempt:r});let i=new AbortController;u=i;let a=()=>i.abort(n.signal.reason);n.signal.addEventListener(`abort`,a);let c=await re(i.signal,r);if(n.signal.removeEventListener(`abort`,a),n.signal.aborted||!p||ee!==e)return;c.connectedAt!==void 0&&Date.now()-c.connectedAt>=IC&&(r=0),r+=1;let l=VC(c.error);if(h(`disconnected`,r,l),t.log?.info?.(`event stream disconnected`,{attempt:r,error:l}),o({status:`reconnecting`,attempt:r,error:l}),t.reconnect){let a=await t.reconnect(i.signal).catch(e=>{i.signal.aborted||t.log?.info?.(`server resolution failed`,{attempt:r,error:VC(e)})});if(n.signal.aborted||i.signal.aborted||!p||ee!==e)return;if(a&&(s=a,r===1))continue}if(m){m=!1;continue}await HC(IC,i.signal)}}function ae(){if(p)return f;p=!0,m=!1;let e=++ee,t=f,n=(async()=>{t&&await t,await ie(e)})().finally(()=>{f===n&&(f=void 0)});return f=n,f}function oe(){p&&(p=!1,ee+=1,u?.abort(),o({status:`connecting`,attempt:0,error:void 0}))}function se(e){!p||a.status!==`connected`||(t.log?.info?.(`event stream resync`,{reason:e,idle:Date.now()-te}),m=!0,d?.abort(Error(e)))}if(t.pageLifecycle){let e=()=>oe(),t=()=>void ae(),n=()=>{document.visibilityState===`visible`&&(Date.now()-te<2e4||se(`Page returned to the foreground after the event stream went quiet`))},r=()=>se(`Network connection restored`);window.addEventListener(`pagehide`,e),window.addEventListener(`pageshow`,t),window.addEventListener(`online`,r),document.addEventListener(`visibilitychange`,n),Br(()=>{window.removeEventListener(`pagehide`,e),window.removeEventListener(`pageshow`,t),window.removeEventListener(`online`,r),document.removeEventListener(`visibilitychange`,n)})}return ae(),Br(()=>{oe(),n.abort(),l&&clearTimeout(l),c=[]}),{status:()=>a.status,attempt:()=>a.attempt,error:()=>a.error,internal:{history:()=>r.slice(),resync:se}}}function VC(e){if(e!==void 0)return e instanceof Error?e.message:String(e)}function HC(e,t){return new Promise(n=>{let r=setTimeout(i,e);t.addEventListener(`abort`,i,{once:!0});function i(){clearTimeout(r),t.removeEventListener(`abort`,i),n()}})}function UC(e,t){return{async connect(n){let r=await e.pty.connect.token({ptyID:n.ptyID,location:n.location,"x-opencode-ticket":`1`}),i=new URL(t.url);i.pathname.endsWith(`/`)||(i.pathname+=`/`);let a=new URL(`api/pty/${encodeURIComponent(n.ptyID)}/connect`,i);n.location?.directory&&a.searchParams.set(`location[directory]`,n.location.directory),n.cursor!==void 0&&a.searchParams.set(`cursor`,String(n.cursor)),a.searchParams.set(`ticket`,r.data.ticket),a.protocol=a.protocol===`https:`?`wss:`:`ws:`;let o=t.openSocket?.(a)??new WebSocket(a);return o.binaryType=`arraybuffer`,o}}}function WC(e,t){return{async connect(n){let r=await e.experimental.persistentPty.connectToken({ptyID:n.ptyID,"x-opencode-ticket":`1`}),i=new URL(t.url);i.pathname.endsWith(`/`)||(i.pathname+=`/`);let a=new URL(`api/experimental/persistent-pty/${encodeURIComponent(n.ptyID)}/connect`,i);a.searchParams.set(`ticket`,r.ticket),a.searchParams.set(`cursor`,String(n.cursor)),a.searchParams.set(`attachment_id`,n.attachmentID),a.searchParams.set(`takeover`,String(n.takeover??!1)),a.searchParams.set(`input_protocol`,`1`),a.protocol=a.protocol===`https:`?`wss:`:`ws:`;let o=t.openSocket?.(a)??new WebSocket(a);return o.binaryType=`arraybuffer`,o}}}function GC(e){let t,n=[],r=new Map;kr(()=>{let i=e.current(),a=i===void 0?void 0:e.session.root(i),o=new Set(e.keep().map(t=>e.session.root(t)));n=[...new Set([...i!==t&&a!==void 0?[a]:[],...n.map(t=>e.session.root(t))])],t=i;let s=new Set([...o,...n.filter(e=>!o.has(e)).slice(0,e.limit)]);a!==void 0&&s.add(a),n=n.filter(e=>s.has(e));let c=t=>Lr(()=>e.session.message?.list(t).length??0),l=new Map(e.session.list().flatMap(t=>{let n=e.session.root(t.id);return s.has(n)?[]:[[t.id,n]]})),u=new Set([...l].filter(([e,t])=>r.get(e)!==`${t}:${c(e)}`).map(([,e])=>e));Lr(()=>u.forEach(t=>e.session.evict(t))),r=new Map([...l].map(([e,t])=>[e,`${t}:${c(e)}`]))})}function KC(e,t){let n=t?e.findIndex(e=>e.id===t):-1;if(t&&n===-1)return;let r=n===-1?e.length:n,i=e.findLastIndex((e,t)=>e.type===`compaction`&&e.status===`completed`&&t<r);return e.findLast((e,t)=>e.type===`assistant`&&e.tokens!==void 0&&t>i&&t<r)}var qC=e({createClientConnection:()=>BC,createData:()=>PC,createPersistentPtyClient:()=>WC,createPtyClient:()=>UC,createSessionRetention:()=>GC,defaultIdleTimeout:()=>RC,foregroundIdleThreshold:()=>zC,lastAssistantWithUsage:()=>KC,locationKey:()=>EC,settleMs:()=>150});export{Wr as A,Vt as B,Er as C,Ri as D,Ur as E,Qr as F,Rn as I,In as L,zn as M,zi as N,Rr as O,Lr as P,Zt as R,Tr as S,Hr as T,Ni as _,na as a,jr as b,Wi as c,Ki as d,ta as f,Vr as g,Ir as h,Aa as i,F as j,Br as k,Gi as l,qi as m,wC as n,la as o,ea as p,xa as r,Zi as s,qC as t,Ji as u,Zr as v,Mi as w,Or as x,kr as y,En as z};
|