@yuriai/web 0.2.40-beta.5 → 0.2.40-beta.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/assets/{AgentAvatar-B7KbxN8Y.js → AgentAvatar-BTLQDhXH.js} +1 -1
- package/dist/assets/AssistantConversationSurface-B59k-lXE.css +1 -0
- package/dist/assets/AssistantConversationSurface-CMMUXPIG.js +3 -0
- package/dist/assets/AssistantSessionCard-CZWiX3PR.js +2 -0
- package/dist/assets/{AssistantUnreadBadge-vu4ZhTft.js → AssistantUnreadBadge-B5I8avUG.js} +1 -1
- package/dist/assets/{AssistantView-CEfEWUIr.js → AssistantView-COHkH9qm.js} +1 -1
- package/dist/assets/{DiagramView-Dlzr08J_.js → DiagramView-DiwpnazQ.js} +1 -1
- package/dist/assets/{FadeInOnReveal-DMRmNsau.js → FadeInOnReveal-BxelcK76.js} +1 -1
- package/dist/assets/{GuiPluginPage-DVug4z_p.js → GuiPluginPage-CLD3qMom.js} +1 -1
- package/dist/assets/{GuiPluginSurface-L43o6Xv8.js → GuiPluginSurface-Cra2RdI2.js} +1 -1
- package/dist/assets/{GuiPluginWindow-tHXkS18H.js → GuiPluginWindow-CX4PYIEy.js} +1 -1
- package/dist/assets/{Icon-DizeYahT.js → Icon-BN1Zz-it.js} +1 -1
- package/dist/assets/{ImageLoadingPlaceholder-BZC5m_km.js → ImageLoadingPlaceholder-CZFYt1Xf.js} +1 -1
- package/dist/assets/{LoadingImage-Csw4L-Dr.js → LoadingImage-BCMztEsC.js} +1 -1
- package/dist/assets/{MarkdownRenderer-D_0iKhQN.js → MarkdownRenderer-194nc-0S.js} +2 -2
- package/dist/assets/{MarkdownRendererImpl-BZ0XgjS0.js → MarkdownRendererImpl-0-mJL1TL.js} +1 -1
- package/dist/assets/{MarkstreamRendererImpl-DBd6Glg9.js → MarkstreamRendererImpl-DaTyfTOH.js} +1 -1
- package/dist/assets/MobileDetailNavigation-CXAtNLak.js +1 -0
- package/dist/assets/{MobileResizableSheet-CQQ7O-2X.js → MobileResizableSheet-BvwMTE7L.js} +1 -1
- package/dist/assets/{MobileShareBridge-IO45gM2G.js → MobileShareBridge-BpO-ZEFG.js} +1 -1
- package/dist/assets/MobileSurface-DIhzZpb9.js +2 -0
- package/dist/assets/{MultiRunWindow-fJ3XfntS.js → MultiRunWindow-ErbLasVC.js} +1 -1
- package/dist/assets/{OnboardingScreen-MJS5T5rL.js → OnboardingScreen-C_rigW9c.js} +1 -1
- package/dist/assets/{OverlayScrollbar-jtMYTn1y.js → OverlayScrollbar-BopzmDhe.js} +1 -1
- package/dist/assets/RemoteAssistantSessionCard-6ktwRL7R.js +1 -0
- package/dist/assets/{SettingsView-ZWFLpPSI.js → SettingsView--qdcJENp.js} +10 -10
- package/dist/assets/{SettingsWindow-DGRmrIWz.js → SettingsWindow-BbJoqFSB.js} +1 -1
- package/dist/assets/{SetupTourDialog-BYbAubwA.js → SetupTourDialog-CT3NmpEw.js} +1 -1
- package/dist/assets/{TerminalView-CoJ6_9P1.js → TerminalView-Cw-p34fv.js} +1 -1
- package/dist/assets/{ToolOutputDialog-5xBwOJ6a.js → ToolOutputDialog-Bph7Tjg_.js} +1 -1
- package/dist/assets/{VoiceSettings-CN33koSc.js → VoiceSettings-B8jYVsYS.js} +2 -2
- package/dist/assets/{YuriLogo-CvyJy_R9.js → YuriLogo-VXtP1vhh.js} +1 -1
- package/dist/assets/{YuriWordmark-DnFAS-Ko.js → YuriWordmark-B7lmpLRB.js} +1 -1
- package/dist/assets/{capgoAdapter-CCLtBZL1.js → capgoAdapter-BQCbf31K.js} +1 -1
- package/dist/assets/{checkbox-rOV6DjeG.js → checkbox-q45nTdJl.js} +1 -1
- package/dist/assets/{client-uz8O6TPX.js → client-1Fk5IbQR.js} +3 -3
- package/dist/assets/{collapsible-CKswuqAw.js → collapsible-GtMRfwfw.js} +1 -1
- package/dist/assets/{context-menu-B4njwT_M.js → context-menu-efudajQ5.js} +1 -1
- package/dist/assets/{diagram-BppQ_USn.js → diagram-D39tZKkF.js} +1 -1
- package/dist/assets/{dialog-Bg8MJnOV.js → dialog-BtnUw5J1.js} +1 -1
- package/dist/assets/{es-Ba3NUCtE.js → es-DuTK1iYh.js} +1 -1
- package/dist/assets/{fileMentionTouchSelection-D-AdTJVr.js → fileMentionTouchSelection-CJ78x95X.js} +1 -1
- package/dist/assets/{fr-CRhp3hyT.js → fr-C_XToFWm.js} +1 -1
- package/dist/assets/{gitApi-DVx_V1x6.js → gitApi-CBnJOeVr.js} +1 -1
- package/dist/assets/gitApiHttp-B0FJaIhU.js +3 -0
- package/dist/assets/{gui-DN2sVP96.js → gui-BMN3-WPc.js} +1 -1
- package/dist/assets/{host-DrGjjO6K.js → host-D9EDWNmx.js} +1 -1
- package/dist/assets/{i18n-RH7UieOS.js → i18n-qHllte6P.js} +1 -1
- package/dist/assets/{input-DRjuZMeA.js → input-KETIwVja.js} +1 -1
- package/dist/assets/{input-store-CjUOfpyA.js → input-store-CsY-uaSj.js} +1 -1
- package/dist/assets/insertionBoundaries-CodoJFbE.js +1 -0
- package/dist/assets/{ja-D-UPjDY2.js → ja-D0pDybpB.js} +1 -1
- package/dist/assets/{ko-x-z9J5z7.js → ko-CAzlaaDJ.js} +1 -1
- package/dist/assets/main-Cgg4eDdr.js +2 -0
- package/dist/assets/{main-D2s9J_jN.js → main-D4t2Tw1D.js} +14 -14
- package/dist/assets/{markdownHeightCache-BL99DlhC.js → markdownHeightCache-BCzMmJds.js} +1 -1
- package/dist/assets/{mcpQueries-HzYMEVWd.js → mcpQueries-BIvH9V8j.js} +1 -1
- package/dist/assets/miniChat-CKw0itTX.js +2 -0
- package/dist/assets/mobile-w1JspRFK.js +2 -0
- package/dist/assets/{mobileBackNavigation--ZdrI-Yj.js → mobileBackNavigation-qI9CYpqm.js} +1 -1
- package/dist/assets/{mobileConnections-C3eGEOPy.js → mobileConnections-Cbt8y7gt.js} +2 -2
- package/dist/assets/{multirun-CDYNyLBH.js → multirun-DOmwPpvA.js} +1 -1
- package/dist/assets/{native-DsqzO52u.js → native-CDqNKjmz.js} +1 -1
- package/dist/assets/{native-config-DOawZfln.js → native-config-BIePc5av.js} +1 -1
- package/dist/assets/{navigation-Ibk_Pw-q.js → navigation-CxKtO3Tu.js} +2 -2
- package/dist/assets/openRemoteProjectSession-DbQYpcai.js +1 -0
- package/dist/assets/{pl-Cqo1FJwM.js → pl-BvjbUcJV.js} +1 -1
- package/dist/assets/{projectMeta-D1Ytss9U.js → projectMeta-AxnyOG6N.js} +1 -1
- package/dist/assets/prompt-attachment-upload-9fjmgafL.js +1 -0
- package/dist/assets/{pt-BR-C930XU1k.js → pt-BR-D71qrP91.js} +1 -1
- package/dist/assets/{pwa-CXupOTsD.js → pwa-BGo_AGpg.js} +1 -1
- package/dist/assets/{queue-abort-optimistic-CQXpIlq6.js → queue-abort-optimistic-CZ3DN-Qo.js} +1 -1
- package/dist/assets/{react-CgRToPwO.js → react-CTU-HLp4.js} +1 -1
- package/dist/assets/{readiness-BfuZm6Yw.js → readiness-Bu7mTG2d.js} +2 -2
- package/dist/assets/reference-history-n4Bw_yN2.js +1 -0
- package/dist/assets/{remote-input-store-BOdCWpQY.js → remote-input-store-84i8uDyM.js} +1 -1
- package/dist/assets/remoteProjectQueries-BZjiHj-6.js +1 -0
- package/dist/assets/remoteSessionReference-CQ0m6LgV.js +1 -0
- package/dist/assets/renderElectronMiniChatApp-B8nOPC1J.js +2 -0
- package/dist/assets/renderMobileApp-BvamjumJ.js +29 -0
- package/dist/assets/{runtimeConfig-tHm7o_0I.js → runtimeConfig-CbHzjd7l.js} +1 -1
- package/dist/assets/runtimeEndpointReset-CMyx_9Vr.js +151 -0
- package/dist/assets/scheduledTaskNavigation-y5g8D2ee.js +1 -0
- package/dist/assets/{select-B1On-Y4Z.js → select-Df_svQ9u.js} +1 -1
- package/dist/assets/sessionLookup-BN82Y0hu.js +1 -0
- package/dist/assets/{sortable-tabs-strip-nD1Me06z.js → sortable-tabs-strip-ByO3KYNT.js} +1 -1
- package/dist/assets/{speechSettingsQueries-BYhNpzDJ.js → speechSettingsQueries-DRAueMIJ.js} +1 -1
- package/dist/assets/src-INJJ62RE.css +2 -0
- package/dist/assets/{store-DunGyOfe.js → store-BOD3jjMl.js} +3 -3
- package/dist/assets/{terminalApi-madXrfqA.js → terminalApi-Cq0vjFe1.js} +1 -1
- package/dist/assets/{textarea-Qt06OhhX.js → textarea-BYUo-pZK.js} +1 -1
- package/dist/assets/{tooltip-D382RCy1.js → tooltip-CBCE3mxe.js} +1 -1
- package/dist/assets/tour-CMXP3Kif.js +1 -0
- package/dist/assets/{types-CHszLAS3.js → types-Bj4r_-Qe.js} +1 -1
- package/dist/assets/{uk-OXQSdzuT.js → uk-C7c1Zece.js} +1 -1
- package/dist/assets/{useAppFontEffects-CqXrCJVt.js → useAppFontEffects-DxY0a-0K.js} +61 -61
- package/dist/assets/useDesktopWindowControlsLayout-I02la7LE.js +1 -0
- package/dist/assets/{useDictation-Bs7TWO9r.js → useDictation-De8WB_Z7.js} +1 -1
- package/dist/assets/{useEffectiveDirectory-CCKRdyK9.js → useEffectiveDirectory-CYzFju6z.js} +1 -1
- package/dist/assets/{useFontPreferences-CPrl1_3z.js → useFontPreferences-CO-L-Gd7.js} +1 -1
- package/dist/assets/{useMobileNavigationStore-BNtVrnSw.js → useMobileNavigationStore-7nhBtrXS.js} +9 -9
- package/dist/assets/{usePluginsStore-bMuGciUE.js → usePluginsStore-1D6-GAgq.js} +1 -1
- package/dist/assets/{useProjectRuntimeAPIs-BFCXBu2J.js → useProjectRuntimeAPIs-CNOqSvoZ.js} +1 -1
- package/dist/assets/{useStreamingTextThrottle-C8xAqcgP.js → useStreamingTextThrottle-BsaiiBxk.js} +1 -1
- package/dist/assets/{vendor-opencode-client-cQ47ywrT.js → vendor-opencode-client-BM2r1f0o.js} +3 -3
- package/dist/assets/{vendor-opencode-plugin-BmdTE4Te.js → vendor-opencode-plugin-ZhpPgHCL.js} +1 -1
- package/dist/assets/{vendor-solid-js-D98iXT7C.js → vendor-solid-js-BBVUd3Hw.js} +1 -1
- package/dist/assets/{zh-CN-B5X8yCZV.js → zh-CN-D2ENuI1-.js} +1 -1
- package/dist/assets/{zh-TW-CF6zr1fk.js → zh-TW-C40BXFhK.js} +1 -1
- package/dist/index.html +11 -11
- package/dist/mini-chat.html +11 -11
- package/dist/mobile.html +2 -2
- package/package.json +1 -1
- package/server/index.js +1 -0
- package/server/lib/assistants/DOCUMENTATION.md +87 -0
- package/server/lib/assistants/assign.js +10 -7
- package/server/lib/assistants/builtin-skills.js +1 -0
- package/server/lib/assistants/builtin-skills.test.js +1 -1
- package/server/lib/assistants/cards.js +6 -1
- package/server/lib/assistants/contact-store.js +22 -5
- package/server/lib/assistants/contact-tools.js +46 -26
- package/server/lib/assistants/execution-target.js +136 -0
- package/server/lib/assistants/opencode-tools.js +22 -9
- package/server/lib/assistants/remote-execution.test.js +378 -0
- package/server/lib/assistants/remote-watch-reconciler.js +43 -0
- package/server/lib/assistants/remote-watch-reconciler.test.js +88 -0
- package/server/lib/assistants/routes.js +1 -0
- package/server/lib/assistants/service.js +302 -99
- package/server/lib/assistants/yuri-project.http.test.js +2 -2
- package/server/lib/gui-customization/DOCUMENTATION.md +8 -2
- package/server/lib/gui-customization/projects-client.mjs +10 -8
- package/server/lib/gui-customization/projects-remote.js +101 -0
- package/server/lib/gui-customization/projects-remote.test.js +125 -0
- package/server/lib/gui-customization/projects.js +30 -6
- package/server/lib/gui-customization/projects.test.js +66 -1
- package/server/lib/gui-customization/session-skill.js +2 -2
- package/server/lib/gui-customization/session-skill.test.js +4 -0
- package/server/lib/gui-customization/skill/SKILL.md +3 -1
- package/server/lib/gui-customization/skill/references/projects.md +30 -3
- package/server/lib/gui-customization/skill/references/remote-connections.md +2 -0
- package/server/lib/opencode/DOCUMENTATION.md +6 -0
- package/server/lib/opencode/feature-routes-runtime.js +2 -0
- package/server/lib/opencode/v2-client.js +9 -4
- package/server/lib/remote-hosts/DOCUMENTATION.md +58 -0
- package/server/lib/remote-hosts/gateway.js +149 -40
- package/server/lib/remote-hosts/json-lifecycle.test.js +35 -0
- package/server/lib/remote-hosts/routes.js +10 -13
- package/server/lib/remote-hosts/routes.test.js +302 -1
- package/server/lib/remote-hosts/store.js +17 -3
- package/server/lib/remote-hosts/store.test.js +19 -0
- package/server/lib/remote-hosts/task-client.js +25 -0
- package/server/lib/remote-hosts/task-client.test.js +60 -0
- package/server/lib/remote-hosts/transport.js +7 -2
- package/server/lib/request-cors.js +1 -1
- package/server/lib/request-cors.test.js +1 -0
- package/server/lib/scheduled-tasks/session-skill.test.js +33 -2
- package/dist/assets/AssistantConversationSurface-BnK_KTBO.js +0 -3
- package/dist/assets/AssistantConversationSurface-n9w_Av0k.css +0 -1
- package/dist/assets/MobileDetailNavigation-xgwvsQuR.js +0 -1
- package/dist/assets/MobileSurface-DmYgZONB.js +0 -2
- package/dist/assets/gitApiHttp-DvTBxvX8.js +0 -3
- package/dist/assets/insertionBoundaries-DZtQt2Ah.js +0 -1
- package/dist/assets/main-BMFY9mtb.js +0 -2
- package/dist/assets/miniChat-BbJ0GKpk.js +0 -2
- package/dist/assets/mobile-_zUth69Z.js +0 -2
- package/dist/assets/prompt-attachment-upload-BNhDXymd.js +0 -1
- package/dist/assets/remoteProjectQueries-CkxdZNw4.js +0 -1
- package/dist/assets/renderElectronMiniChatApp-pJ59iC34.js +0 -2
- package/dist/assets/renderMobileApp-BQFC-gOA.js +0 -29
- package/dist/assets/runtimeEndpointReset-BhHWFNvo.js +0 -150
- package/dist/assets/scheduledTaskNavigation-BIDtQ4wN.js +0 -1
- package/dist/assets/sessionLookup-RcyTTDOy.js +0 -1
- package/dist/assets/src-BZCFf9_1.css +0 -2
- package/dist/assets/tour-CQMBn8gJ.js +0 -1
- package/dist/assets/useDesktopWindowControlsLayout-KH4UP7Gj.js +0 -1
- /package/dist/assets/{sessionLookup-8C8nv-EP.css → reference-history-8C8nv-EP.css} +0 -0
package/dist/assets/{vendor-opencode-client-cQ47ywrT.js → vendor-opencode-client-BM2r1f0o.js}
RENAMED
|
@@ -9,7 +9,7 @@ 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 Ht(`MalformedResponse`,{cause:e})}r=s.indexOf(`
|
|
11
11
|
|
|
12
|
-
`)}if(e.done)return}}finally{try{await a.cancel()}catch{}a.releaseLock()}}}),s={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),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),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),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),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)},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),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)},experimental:{session:{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),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),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),wait:(e,t)=>a({method:`POST`,path:`/api/experimental/session/${encodeURIComponent(e.sessionID)}/wait`,successStatus:204,declaredStatuses:[400,401,404,503],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)}},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)},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)},integration:{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)}},mcp:{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),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)}},file:{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)},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)},schedule:{create:(e,t)=>a({method:`POST`,path:`/api/experimental/schedule`,body:{sessionID:e.sessionID,name:e.name,when:e.when,ends:e.ends,prompt:e.prompt},successStatus:200,declaredStatuses:[400,401,403,404],empty:!1},t).then(e=>e.data),list:(e,t)=>a({method:`GET`,path:`/api/experimental/schedule`,query:{sessionID:e.sessionID},successStatus:200,declaredStatuses:[400,401,403,404],empty:!1},t).then(e=>e.data),get:(e,t)=>a({method:`GET`,path:`/api/experimental/schedule/${encodeURIComponent(e.scheduleID)}`,successStatus:200,declaredStatuses:[400,401,403,404],empty:!1},t).then(e=>e.data),pause:(e,t)=>a({method:`POST`,path:`/api/experimental/schedule/${encodeURIComponent(e.scheduleID)}/pause`,successStatus:200,declaredStatuses:[400,401,403,404],empty:!1},t).then(e=>e.data),resume:(e,t)=>a({method:`POST`,path:`/api/experimental/schedule/${encodeURIComponent(e.scheduleID)}/resume`,successStatus:200,declaredStatuses:[400,401,403,404],empty:!1},t).then(e=>e.data),delete:(e,t)=>a({method:`DELETE`,path:`/api/experimental/schedule/${encodeURIComponent(e.scheduleID)}`,successStatus:204,declaredStatuses:[400,401,403,404],empty:!0},t)},migration:{v1:{status:e=>a({method:`GET`,path:`/api/experimental/migration/v1`,successStatus:200,declaredStatuses:[400,401],empty:!1},e)}},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:{update:(e,t)=>a({method:`PATCH`,path:`/api/experimental/config`,body:{shell:e.shell},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)},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),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),resource:{catalog:(e,t)=>a({method:`GET`,path:`/api/mcp/resource`,query:{location:e?.location},successStatus:200,declaredStatuses:[400,401,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/${Gt(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)},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)}},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)}},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)},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)}};return{...s,session:{...s.session,stats:s.experimental.session.stats,import:s.experimental.session.import,export:s.experimental.session.export,skill:s.experimental.session.skill,wait:s.experimental.session.wait,instructions:{entry:{list:s.experimental.session.instructions.entry.list,put:s.experimental.session.instructions.entry.put,remove:s.experimental.session.instructions.entry.remove}},log:s.experimental.session.log},generate:{text:s.experimental.generate.text,image:s.experimental.generate.image,decisions:s.experimental.generate.decisions},voice:{models:s.experimental.voice.models,session:s.experimental.voice.session},integration:{...s.integration,wellknown:{add:s.experimental.integration.wellknown.add}},mcp:{...s.mcp,add:s.experimental.mcp.add,remove:s.experimental.mcp.remove,connect:s.experimental.mcp.connect,disconnect:s.experimental.mcp.disconnect,client:{token:s.experimental.mcp.client.token}},file:{...s.file,write:s.experimental.file.write,watch:s.experimental.file.watch,unwatch:s.experimental.file.unwatch},migration:{v1:{status:s.experimental.migration.v1.status}},usage:{limits:s.experimental.usage.limits},config:{...s.config,update:s.experimental.config.update}}}function Gt(e){return e.split(`/`).map(encodeURIComponent).join(`/`)}function Kt(e,t,n){if(n!==void 0){if(n===null){e.append(t,`null`);return}if(Array.isArray(n)){for(let r of n)Kt(e,t,r);return}if(typeof n==`object`){for(let[r,i]of Object.entries(n))Kt(e,`${t}[${r}]`,i);return}e.append(t,String(n))}}async function qt(e){if(!Yt(e,`application/json`)&&!e.headers.get(`content-type`)?.includes(`+json`)){try{await e.body?.cancel()}catch{}throw new Ht(`UnsupportedContentType`,{detail:e.headers.get(`content-type`)})}let t;try{t=await e.text()}catch(e){throw new Ht(`Transport`,{cause:e})}if(t===``)throw new Ht(`MalformedResponse`);try{return JSON.parse(t)}catch(e){throw new Ht(`MalformedResponse`,{cause:e})}}function Jt(e){let t=Object.assign(Error(e.message??e.data?.message),e);return e._tag&&(t.name=e._tag),t}function Yt(e,t){return e.headers.get(`content-type`)?.split(`;`,1)[0]?.trim().toLowerCase()===t}var Xt=e=>typeof e==`object`&&!!e&&`_tag`in e&&e._tag===`LocationNotFoundError`,Zt=e=>typeof e==`object`&&!!e&&`_tag`in e&&e._tag===`PermissionNotFoundError`,Qt=e=>typeof e==`object`&&!!e&&`_tag`in e&&e._tag===`RpcError`,$t=e=>typeof e==`object`&&!!e&&`_tag`in e&&e._tag===`RpcInternalError`;function en(e,t){return n=>{let r=(e,r)=>{if(!Object.hasOwn(n.events,e))throw Error(`Unknown RPC event: ${n.id}.${e}`);let i=tn(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!Qt(e)&&!$t(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 tn(e,t){return`rpc.${e.id}.${t}`}var nn={};zt(nn,{OpenCode:()=>nn,make:()=>rn});function rn(e){let t=Wt(e),n=Vt((e,n)=>t.event.subscribe(void 0,{signal:e,onActivity:n}));return{...t,rpc:Object.assign(en(t,n),t.rpc),event:n}}var an=e({$DEVCOMP:()=>Mn,$PROXY:()=>kn,$TRACK:()=>jn,DEV:()=>void 0,ErrorBoundary:()=>_i,For:()=>ui,Index:()=>di,Match:()=>mi,Show:()=>fi,Suspense:()=>xi,SuspenseList:()=>bi,Switch:()=>pi,batch:()=>nr,cancelCallback:()=>Sn,catchError:()=>sr,children:()=>yr,createComponent:()=>$r,createComputed:()=>qn,createContext:()=>_r,createDeferred:()=>er,createEffect:()=>Yn,createMemo:()=>Zn,createReaction:()=>Xn,createRenderEffect:()=>Jn,createResource:()=>$n,createRoot:()=>Gn,createSelector:()=>tr,createSignal:()=>Kn,createUniqueId:()=>ci,enableExternalSource:()=>Sr,enableHydration:()=>Qr,enableScheduling:()=>dr,equalFn:()=>On,from:()=>Kr,getListener:()=>cr,getOwner:()=>lr,indexArray:()=>Xr,lazy:()=>oi,mapArray:()=>Yr,mergeProps:()=>ii,observable:()=>Gr,on:()=>ir,onCleanup:()=>or,onError:()=>Ur,onMount:()=>ar,requestCallback:()=>xn,resetErrorBoundaries:()=>gi,runWithOwner:()=>ur,sharedConfig:()=>P,splitProps:()=>ai,startTransition:()=>fr,untrack:()=>rr,useContext:()=>vr,useTransition:()=>hr}),on=1,sn=!1,cn=!1,ln=[],un=null,dn=null,fn=5,pn=0,mn=300,hn=0,gn=null,_n=null,vn=1073741823;function yn(){let e=new MessageChannel,t=e.port1,n=e.port2;if(typeof t.unref==`function`&&t.unref(),typeof n.unref==`function`&&n.unref(),gn=()=>n.postMessage(null),t.onmessage=()=>{if(_n!==null){let e=performance.now();pn=e+fn,hn=e+mn;try{_n(e)?n.postMessage(null):_n=null}catch(e){throw n.postMessage(null),e}}},navigator&&navigator.scheduling&&navigator.scheduling.isInputPending){let e=navigator.scheduling;dn=()=>{let t=performance.now();return t>=pn?e.isInputPending()?!0:t>=hn:!1}}else dn=()=>performance.now()>=pn}function bn(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 xn(e,t){gn||yn();let n=performance.now(),r=vn;t&&t.timeout&&(r=t.timeout);let i={id:on++,fn:e,startTime:n,expirationTime:n+r};return bn(ln,i),!sn&&!cn&&(sn=!0,_n=Cn,gn()),i}function Sn(e){e.fn=null}function Cn(e){sn=!1,cn=!0;try{return wn(e)}finally{un=null,cn=!1}}function wn(e){let t=e;for(un=ln[0]||null;un!==null&&!(un.expirationTime>t&&dn());){let e=un.fn;e===null?ln.shift():(un.fn=null,e(un.expirationTime<=t),t=performance.now(),un===ln[0]&&ln.shift()),un=ln[0]||null}return un!==null}var P={context:void 0,registry:void 0,effects:void 0,done:!1,getContextId(){return Tn(this.context.count)},getNextContextId(){return Tn(this.context.count++)}};function Tn(e){let t=String(e),n=t.length-1;return P.context.id+(n?String.fromCharCode(96+n):``)+t}function En(e){P.context=e}function Dn(){return{...P.context,id:P.getNextContextId(),count:0}}var On=(e,t)=>e===t,kn=Symbol(`solid-proxy`),An=typeof Proxy==`function`,jn=Symbol(`solid-track`),Mn=Symbol(`solid-dev-component`),Nn={equals:On},Pn=null,Fn=jr,In=1,Ln=2,Rn={owned:null,cleanups:null,context:null,owner:null},zn={},F=null,I=null,Bn=null,Vn=null,L=null,Hn=null,Un=null,Wn=0;function Gn(e,t){let n=L,r=F,i=e.length===0,a=t===void 0?r:t,o=i?Rn:{owned:null,cleanups:null,context:a?a.context:null,owner:a},s=i?e:()=>e(()=>rr(()=>Ir(o)));F=o,L=null;try{return kr(s,!0)}finally{L=n,F=r}}function Kn(e,t){t=t?Object.assign({},Nn,t):Nn;let n={value:e,observers:null,observerSlots:null,comparator:t.equals||void 0};return[Cr.bind(n),e=>(typeof e==`function`&&(e=I&&I.running&&I.sources.has(n)?e(n.tValue):e(n.value)),wr(n,e))]}function qn(e,t,n){let r=Dr(e,t,!0,In);Bn&&I&&I.running?Hn.push(r):Tr(r)}function Jn(e,t,n){let r=Dr(e,t,!1,In);Bn&&I&&I.running?Hn.push(r):Tr(r)}function Yn(e,t,n){Fn=Nr;let r=Dr(e,t,!1,In),i=br&&vr(br);i&&(r.suspense=i),(!n||!n.render)&&(r.user=!0),Un?Un.push(r):Tr(r)}function Xn(e,t){let n,r=Dr(()=>{n?n():rr(e),n=void 0},void 0,!1,0),i=br&&vr(br);return i&&(r.suspense=i),r.user=!0,e=>{n=e,Tr(r)}}function Zn(e,t,n){n=n?Object.assign({},Nn,n):Nn;let r=Dr(e,t,!0,0);return r.observers=null,r.observerSlots=null,r.comparator=n.equals||void 0,Bn&&I&&I.running?(r.tState=In,Hn.push(r)):Tr(r),Cr.bind(r)}function Qn(e){return e&&typeof e==`object`&&`then`in e}function $n(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=zn,c=null,l=!1,u=!1,d=`initialValue`in a,f=typeof r==`function`&&Zn(r),p=new Set,[ee,te]=(a.storage||Kn)(a.initialValue),[ne,m]=Kn(void 0),[re,ie]=Kn(void 0,{equals:!1}),[ae,oe]=Kn(d?`ready`:`unresolved`);P.context&&(c=P.getNextContextId(),a.ssrLoadFrom===`initial`?s=a.initialValue:P.load&&P.has(c)&&(s=P.load(c)));function se(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=zn,I&&e&&l?(I.promises.delete(e),l=!1,kr(()=>{I.running=!0,ce(t,n)},!1)):ce(t,n)),t}function ce(e,t){kr(()=>{t===void 0&&te(()=>e),oe(t===void 0?d?`ready`:`unresolved`:`errored`),m(t);for(let e of p.keys())e.decrement();p.clear()},!1)}function le(){let e=br&&vr(br),t=ee(),n=ne();if(n!==void 0&&!o)throw n;return L&&!L.user&&e&&qn(()=>{re(),o&&(e.resolved&&I&&l?I.promises.add(o):p.has(e)||(e.increment(),p.add(e)))}),t}function ue(e=!0){if(e!==!1&&u)return;u=!1;let t=f?f():r;if(l=I&&I.running,t==null||t===!1){se(o,rr(ee));return}I&&o&&I.promises.delete(o);let n,a=s===zn?rr(()=>{try{return i(t,{value:ee(),refetching:e})}catch(e){n=e}}):s;if(n!==void 0){se(o,void 0,Rr(n),t);return}return Qn(a)?(o=a,`v`in a?(a.s===1?se(o,a.v,void 0,t):se(o,void 0,Rr(a.v),t),a):(u=!0,queueMicrotask(()=>u=!1),kr(()=>{oe(d?`refreshing`:`pending`),ie()},!1),a.then(e=>se(a,e,void 0,t),e=>se(a,void 0,Rr(e),t)))):(se(o,a,void 0,t),a)}Object.defineProperties(le,{state:{get:()=>ae()},error:{get:()=>ne()},loading:{get(){let e=ae();return e===`pending`||e===`refreshing`}},latest:{get(){if(!d)return le();let e=ne();if(e&&!o)throw e;return ee()}}});let de=F;return f?qn(()=>(de=F,ue(!1))):ue(!1),[le,{refetch:e=>ur(de,()=>ue(e)),mutate:te}]}function er(e,t){let n,r=t?t.timeoutMs:void 0,i=Dr(()=>((!n||!n.fn)&&(n=xn(()=>o(()=>i.value),r===void 0?void 0:{timeout:r})),e()),void 0,!0),[a,o]=Kn(I&&I.running&&I.sources.has(i)?i.tValue:i.value,t);return Tr(i),o(()=>I&&I.running&&I.sources.has(i)?i.tValue:i.value),a}function tr(e,t=On,n){let r=new Map,i=Dr(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=In,e.pure?Hn.push(e):Un.push(e);return i},void 0,!0,In);return Tr(i),e=>{let n=L;if(n){let t;(t=r.get(e))?t.add(n):r.set(e,t=new Set([n])),or(()=>{t.delete(n),!t.size&&r.delete(e)})}return t(e,I&&I.running&&I.sources.has(i)?i.tValue:i.value)}}function nr(e){return kr(e,!1)}function rr(e){if(!Vn&&L===null)return e();let t=L;L=null;try{return Vn?Vn.untrack(e):e()}finally{L=t}}function ir(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=rr(()=>t(o,i,n));return i=o,s}}function ar(e){Yn(()=>rr(e))}function or(e){return F===null||(F.cleanups===null?F.cleanups=[e]:F.cleanups.push(e)),e}function sr(e,t){Pn||=Symbol(`error`),F=Dr(void 0,void 0,!0),F.context={...F.context,[Pn]:[t]},I&&I.running&&I.sources.add(F);try{return e()}catch(e){Br(e)}finally{F=F.owner}}function cr(){return L}function lr(){return F}function ur(e,t){let n=F,r=L;F=e,L=null;try{return kr(t,!0)}catch(e){Br(e)}finally{F=n,L=r}}function dr(e=xn){Bn=e}function fr(e){if(I&&I.running)return e(),I.done;let t=L,n=F;return Promise.resolve().then(()=>{L=t,F=n;let r;return(Bn||br)&&(r=I||={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),kr(e,!1),L=F=null,r?r.done:void 0})}var[pr,mr]=Kn(!1);function hr(){return[pr,fr]}function gr(e){Un.push.apply(Un,e),e.length=0}function _r(e,t){let n=Symbol(`context`);return{id:n,Provider:Hr(n),defaultValue:e}}function vr(e){let t;return F&&F.context&&(t=F.context[e.id])!==void 0?t:e.defaultValue}function yr(e){let t=Zn(e),n=Zn(()=>Vr(t()));return n.toArray=()=>{let e=n();return Array.isArray(e)?e:e==null?[]:[e]},n}var br;function xr(){return br||=_r()}function Sr(e,t=e=>e()){if(Vn){let{factory:n,untrack:r}=Vn;Vn={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 Vn={factory:e,untrack:t}}function Cr(){let e=I&&I.running;if(this.sources&&(e?this.tState:this.state))if((e?this.tState:this.state)===In)Tr(this);else{let e=Hn;Hn=null,kr(()=>Pr(this),!1),Hn=e}if(L){let e=this.observers;if(!e||e[e.length-1]!==L){let t=e?e.length:0;L.sources?(L.sources.push(this),L.sourceSlots.push(t)):(L.sources=[this],L.sourceSlots=[t]),e?(e.push(L),this.observerSlots.push(L.sources.length-1)):(this.observers=[L],this.observerSlots=[L.sources.length-1])}}return e&&I.sources.has(this)?this.tValue:this.value}function wr(e,t,n){let r=I&&I.running&&I.sources.has(e)?e.tValue:e.value;if(!e.comparator||!e.comparator(r,t)){if(I){let r=I.running;(r||!n&&I.sources.has(e))&&(I.sources.add(e),e.tValue=t),r||(e.value=t)}else e.value=t;e.observers&&e.observers.length&&kr(()=>{for(let t=0;t<e.observers.length;t+=1){let n=e.observers[t],r=I&&I.running;r&&I.disposed.has(n)||((r?!n.tState:!n.state)&&(n.pure?Hn.push(n):Un.push(n),n.observers&&Fr(n)),r?n.tState=In:n.state=In)}if(Hn.length>1e6)throw Hn=[],Error()},!1)}return t}function Tr(e){if(!e.fn)return;Ir(e);let t=Wn;Er(e,I&&I.running&&I.sources.has(e)?e.tValue:e.value,t),I&&!I.running&&I.sources.has(e)&&queueMicrotask(()=>{kr(()=>{I&&(I.running=!0),L=F=e,Er(e,e.tValue,t),L=F=null},!1)})}function Er(e,t,n){let r,i=F,a=L;L=F=e;try{r=e.fn(t)}catch(t){return e.pure&&(I&&I.running?(e.tState=In,e.tOwned&&e.tOwned.forEach(Ir),e.tOwned=void 0):(e.state=In,e.owned&&e.owned.forEach(Ir),e.owned=null)),e.updatedAt=n+1,Br(t)}finally{L=a,F=i}(!e.updatedAt||e.updatedAt<=n)&&(e.updatedAt!=null&&`observers`in e?wr(e,r,!0):I&&I.running&&e.pure?(I.sources.has(e)||(e.value=r),I.sources.add(e),e.tValue=r):e.value=r,e.updatedAt=n)}function Dr(e,t,n,r=In,i){let a={fn:e,state:r,updatedAt:null,owned:null,sources:null,sourceSlots:null,cleanups:null,value:t,owner:F,context:F?F.context:null,pure:n};if(I&&I.running&&(a.state=0,a.tState=r),F===null||F!==Rn&&(I&&I.running&&F.pure?F.tOwned?F.tOwned.push(a):F.tOwned=[a]:F.owned?F.owned.push(a):F.owned=[a]),Vn&&a.fn){let e=a.fn,[t,n]=Kn(void 0,{equals:!1}),r=Vn.factory(e,n);or(()=>r.dispose());let i,o=()=>fr(n).then(()=>{i&&=(i.dispose(),void 0)});a.fn=n=>(t(),I&&I.running?(i||=Vn.factory(e,o),i.track(n)):r.track(n))}return a}function Or(e){let t=I&&I.running;if((t?e.tState:e.state)===0)return;if((t?e.tState:e.state)===Ln)return Pr(e);if(e.suspense&&rr(e.suspense.inFallback))return e.suspense.effects.push(e);let n=[e];for(;(e=e.owner)&&(!e.updatedAt||e.updatedAt<Wn);){if(t&&I.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(I.disposed.has(t))return}if((t?e.tState:e.state)===In)Tr(e);else if((t?e.tState:e.state)===Ln){let t=Hn;Hn=null,kr(()=>Pr(e,n[0]),!1),Hn=t}}}function kr(e,t){if(Hn)return e();let n=!1;t||(Hn=[]),Un?n=!0:Un=[],Wn++;try{let t=e();return Ar(n),t}catch(e){n||(Un=null),Hn=null,Br(e)}}function Ar(e){if(Hn&&=(Bn&&I&&I.running?Mr(Hn):jr(Hn),null),e)return;let t;if(I){if(!I.promises.size&&!I.queue.size){let e=I.sources,n=I.disposed;Un.push.apply(Un,I.effects),t=I.resolve;for(let e of Un)`tState`in e&&(e.state=e.tState),delete e.tState;I=null,kr(()=>{for(let e of n)Ir(e);for(let t of e){if(t.value=t.tValue,t.owned)for(let e=0,n=t.owned.length;e<n;e++)Ir(t.owned[e]);t.tOwned&&(t.owned=t.tOwned),delete t.tValue,delete t.tOwned,t.tState=0}mr(!1)},!1)}else if(I.running){I.running=!1,I.effects.push.apply(I.effects,Un),Un=null,mr(!0);return}}let n=Un;Un=null,n.length&&kr(()=>Fn(n),!1),t&&t()}function jr(e){for(let t=0;t<e.length;t++)Or(e[t])}function Mr(e){for(let t=0;t<e.length;t++){let n=e[t],r=I.queue;r.has(n)||(r.add(n),Bn(()=>{r.delete(n),kr(()=>{I.running=!0,Or(n)},!1),I&&(I.running=!1)}))}}function Nr(e){let t,n=0;for(t=0;t<e.length;t++){let r=e[t];r.user?e[n++]=r:Or(r)}if(P.context){if(P.count){P.effects||=[],P.effects.push(...e.slice(0,n));return}En()}for(P.effects&&(P.done||!P.count)&&(e=[...P.effects,...e],n+=P.effects.length,delete P.effects),t=0;t<n;t++)Or(e[t])}function Pr(e,t){let n=I&&I.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===In?i!==t&&(!i.updatedAt||i.updatedAt<Wn)&&Or(i):e===Ln&&Pr(i,t)}}}function Fr(e){let t=I&&I.running;for(let n=0;n<e.observers.length;n+=1){let r=e.observers[n];(t?!r.tState:!r.state)&&(t?r.tState=Ln:r.state=Ln,r.pure?Hn.push(r):Un.push(r),r.observers&&Fr(r))}}function Ir(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--)Ir(e.tOwned[t]);delete e.tOwned}if(I&&I.running&&e.pure)Lr(e,!0);else if(e.owned){for(t=e.owned.length-1;t>=0;t--)Ir(e.owned[t]);e.owned=null}if(e.cleanups){for(t=e.cleanups.length-1;t>=0;t--)e.cleanups[t]();e.cleanups=null}I&&I.running?e.tState=0:e.state=0}function Lr(e,t){if(t||(e.tState=0,I.disposed.add(e)),e.owned)for(let t=0;t<e.owned.length;t++)Lr(e.owned[t])}function Rr(e){return e instanceof Error?e:Error(typeof e==`string`?e:`Unknown error`,{cause:e})}function zr(e,t,n){try{for(let n of t)n(e)}catch(e){Br(e,n&&n.owner||null)}}function Br(e,t=F){let n=Pn&&t&&t.context&&t.context[Pn],r=Rr(e);if(!n)throw r;Un?Un.push({fn(){zr(r,n,t)},state:In}):zr(r,n,t)}function Vr(e){if(typeof e==`function`&&!e.length)return Vr(e());if(Array.isArray(e)){let t=[];for(let n=0;n<e.length;n++){let r=Vr(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 Hr(e,t){return function(t){let n;return Jn(()=>n=rr(()=>(F.context={...F.context,[e]:t.value},yr(()=>t.children))),void 0),n}}function Ur(e){Pn||=Symbol(`error`),F===null||(F.context===null||!F.context[Pn]?(F.context={...F.context,[Pn]:[e]},Wr(F,Pn,[e])):F.context[Pn].push(e))}function Wr(e,t,n){if(e.owned)for(let r=0;r<e.owned.length;r++)e.owned[r].context===e.context&&Wr(e.owned[r],t,n),e.owned[r].context?e.owned[r].context[t]||(e.owned[r].context[t]=n,Wr(e.owned[r],t,n)):(e.owned[r].context=e.context,Wr(e.owned[r],t,n))}function Gr(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=Gn(t=>(Yn(()=>{let t=e();rr(()=>n(t))}),t));return lr()&&or(r),{unsubscribe(){r()}}},[Symbol.observable||`@@observable`](){return this}}}function Kr(e,t=void 0){let[n,r]=Kn(t,{equals:!1});if(`subscribe`in e){let t=e.subscribe(e=>r(()=>e));or(()=>`unsubscribe`in t?t.unsubscribe():t())}else or(e(r));return n}var qr=Symbol(`fallback`);function Jr(e){for(let t=0;t<e.length;t++)e[t]()}function Yr(e,t,n={}){let r=[],i=[],a=[],o=0,s=t.length>1?[]:null;return or(()=>Jr(a)),()=>{let c=e()||[],l=c.length,u,d;return c[jn],rr(()=>{let e,t,p,ee,te,ne,m,re,ie;if(l===0)o!==0&&(Jr(a),a=[],r=[],i=[],o=0,s&&=[]),n.fallback&&(r=[qr],i[0]=Gn(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]=Gn(f);o=l}else{for(p=Array(l),ee=Array(l),s&&(te=Array(l)),ne=0,m=Math.min(o,l);ne<m&&r[ne]===c[ne];ne++);for(m=o-1,re=l-1;m>=ne&&re>=ne&&r[m]===c[re];m--,re--)p[re]=i[m],ee[re]=a[m],s&&(te[re]=s[m]);for(e=new Map,t=Array(re+1),d=re;d>=ne;d--)ie=c[d],u=e.get(ie),t[d]=u===void 0?-1:u,e.set(ie,d);for(u=ne;u<=m;u++)ie=r[u],d=e.get(ie),d!==void 0&&d!==-1?(p[d]=i[u],ee[d]=a[u],s&&(te[d]=s[u]),d=t[d],e.set(ie,d)):a[u]();for(d=ne;d<l;d++)d in p?(i[d]=p[d],a[d]=ee[d],s&&(s[d]=te[d],s[d](d))):i[d]=Gn(f);i=i.slice(0,o=l),r=c.slice(0)}return i});function f(e){if(a[d]=e,s){let[e,n]=Kn(d);return s[d]=n,t(c[d],e)}return t(c[d])}}}function Xr(e,t,n={}){let r=[],i=[],a=[],o=[],s=0,c;return or(()=>Jr(a)),()=>{let l=e()||[],u=l.length;return l[jn],rr(()=>{if(u===0)return s!==0&&(Jr(a),a=[],r=[],i=[],s=0,o=[]),n.fallback&&(r=[qr],i[0]=Gn(e=>(a[0]=e,n.fallback())),s=1),i;for(r[0]===qr&&(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]=Gn(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]=Kn(l[c]);return o[c]=r,t(n,c)}}}var Zr=!1;function Qr(){Zr=!0}function $r(e,t){if(Zr&&P.context){let n=P.context;En(Dn());let r=rr(()=>e(t||{}));return En(n),r}return rr(()=>e(t||{}))}function ei(){return!0}var ti={get(e,t,n){return t===kn?n:e.get(t)},has(e,t){return t===kn||e.has(t)},set:ei,deleteProperty:ei,getOwnPropertyDescriptor(e,t){return{configurable:!0,enumerable:!0,get(){return e.get(t)},set:ei,deleteProperty:ei}},ownKeys(e){return e.keys()}};function ni(e){return(e=typeof e==`function`?e():e)?e:{}}function ri(){for(let e=0,t=this.length;e<t;++e){let t=this[e]();if(t!==void 0)return t}}function ii(...e){let t=!1;for(let n=0;n<e.length;n++){let r=e[n];t||=!!r&&kn in r,e[n]=typeof r==`function`?(t=!0,Zn(r)):r}if(An&&t)return new Proxy({get(t){for(let n=e.length-1;n>=0;n--){let r=ni(e[n])[t];if(r!==void 0)return r}},has(t){for(let n=e.length-1;n>=0;n--)if(t in ni(e[n]))return!0;return!1},keys(){let t=[];for(let n=0;n<e.length;n++)t.push(...Object.keys(ni(e[n])));return[...new Set(t)]}},ti);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:ri.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 ai(e,...t){let n=t.length;if(An&&kn 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)}},ti));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))}},ti)),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 oi(e){let t,n,r=r=>{let i=P.context;if(i){let[r,a]=Kn();P.count||=0,P.count++,(n||=e()).then(e=>{!P.done&&En(i),P.count--,a(()=>e.default),En()}),t=r}else if(!t){let[r]=$n(()=>(n||=e()).then(e=>e.default));t=r}let a;return Zn(()=>(a=t())?rr(()=>{if(!i||P.done)return a(r);let e=P.context;En(i);let t=a(r);return En(e),t}):``)};return r.preload=()=>n||((n=e()).then(e=>t=()=>e.default),n),r}var si=0;function ci(){return P.context?P.getNextContextId():`cl-${si++}`}var li=e=>`Stale read from <${e}>.`;function ui(e){let t=`fallback`in e&&{fallback:()=>e.fallback};return Zn(Yr(()=>e.each,e.children,t||void 0))}function di(e){let t=`fallback`in e&&{fallback:()=>e.fallback};return Zn(Xr(()=>e.each,e.children,t||void 0))}function fi(e){let t=e.keyed,n=Zn(()=>e.when,void 0,void 0),r=t?n:Zn(n,void 0,{equals:(e,t)=>!e==!t});return Zn(()=>{let i=r();if(i){let a=e.children;return typeof a==`function`&&a.length>0?rr(()=>a(t?i:()=>{if(!rr(r))throw li(`Show`);return n()})):a}return e.fallback},void 0,void 0)}function pi(e){let t=yr(()=>e.children),n=Zn(()=>{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=Zn(()=>a()?void 0:i.when,void 0,void 0),s=i.keyed?o:Zn(o,void 0,{equals:(e,t)=>!e==!t});r=()=>a()||(s()?[t,o,i]:void 0)}return r});return Zn(()=>{let t=n()();if(!t)return e.fallback;let[r,i,a]=t,o=a.children;return typeof o==`function`&&o.length>0?rr(()=>o(a.keyed?i():()=>{if(rr(n)()?.[0]!==r)throw li(`Match`);return i()})):o},void 0,void 0)}function mi(e){return e}var hi;function gi(){hi&&[...hi].forEach(e=>e())}function _i(e){let t;P.context&&P.load&&(t=P.load(P.getContextId()));let[n,r]=Kn(t,void 0);return hi||=new Set,hi.add(r),or(()=>hi.delete(r)),Zn(()=>{let t;if(t=n()){let n=e.fallback;return typeof n==`function`&&n.length?rr(()=>n(t,()=>r())):n}return sr(()=>e.children,r)},void 0,void 0)}var vi=(e,t)=>e.showContent===t.showContent&&e.showFallback===t.showFallback,yi=_r();function bi(e){let[t,n]=Kn(()=>({inFallback:!1})),r,i=vr(yi),[a,o]=Kn([]);i&&(r=i.register(Zn(()=>t()().inFallback)));let s=Zn(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),$r(yi.Provider,{value:{register:e=>{let t;return o(n=>(t=n.length,[...n,e])),Zn(()=>s()[t],void 0,{equals:vi})}},get children(){return e.children}})}function xi(e){let t=0,n,r,i,a,o,[s,c]=Kn(!1),l=xr(),u={increment:()=>{++t===1&&c(!0)},decrement:()=>{--t===0&&c(!1)},inFallback:s,effects:[],resolved:!1},d=lr();if(P.context&&P.load){let e=P.getContextId(),t=P.load(e);if(t&&(typeof t!=`object`||t.s!==1?i=t:P.gather(e)),i&&i!==`$$f`){let[t,n]=Kn(void 0,{equals:!1});a=t,i.then(()=>{if(P.done)return n();P.gather(e),En(r),n(),En()},e=>{o=e,n()})}}let f=vr(yi);f&&(n=f.register(u.inFallback));let p;return or(()=>p&&p()),$r(l.Provider,{value:u,get children(){return Zn(()=>{if(o)throw o;if(r=P.context,a){a(),a=void 0;return}r&&i===`$$f`&&En();let t=Zn(()=>e.children);return Zn(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,gr(u.effects),t();if(c)return p?a:Gn(t=>(p=t,r&&=(En({id:r.id+`F`,count:0}),void 0),e.fallback),d)})})}})}var Si=e({$RAW:()=>Ci,DEV:()=>void 0,createMutable:()=>Gi,createStore:()=>Vi,modifyMutable:()=>Ki,produce:()=>$i,reconcile:()=>Xi,unwrap:()=>ki}),Ci=Symbol(`store-raw`),wi=Symbol(`store-node`),Ti=Symbol(`store-has`),Ei=Symbol(`store-self`);function Di(e){let t=e[kn];if(!t&&(Object.defineProperty(e,kn,{value:t=new Proxy(e,Fi)}),!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 Oi(e){let t;return typeof e==`object`&&!!e&&(e[kn]||!(t=Object.getPrototypeOf(e))||t===Object.prototype||Array.isArray(e))}function ki(e,t=new Set){let n,r,i,a;if(n=e!=null&&e[Ci])return n;if(!Oi(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=ki(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=ki(i,t))!==i&&(e[a]=r))}return e}function Ai(e,t){let n=e[t];return n||Object.defineProperty(e,t,{value:n=Object.create(null)}),n}function ji(e,t,n){if(e[t])return e[t];let[r,i]=Kn(n,{equals:!1,internal:!0});return r.$=i,e[t]=r}function Mi(e,t){let n=Reflect.getOwnPropertyDescriptor(e,t);return!n||n.get||!n.configurable||t===kn||t===wi?n:(delete n.value,delete n.writable,n.get=()=>e[kn][t],n)}function Ni(e){cr()&&ji(Ai(e,wi),Ei)()}function Pi(e){return Ni(e),Reflect.ownKeys(e)}var Fi={get(e,t,n){if(t===Ci)return e;if(t===kn)return n;if(t===jn)return Ni(e),n;let r=Ai(e,wi),i=r[t],a=i?i():e[t];if(t===wi||t===Ti||t===`__proto__`)return a;if(!i){let n=Object.getOwnPropertyDescriptor(e,t);cr()&&(typeof a!=`function`||e.hasOwnProperty(t))&&!(n&&n.get)&&(a=ji(r,t,a)())}return Oi(a)?Di(a):a},has(e,t){return t===Ci||t===kn||t===jn||t===wi||t===Ti||t===`__proto__`||(cr()&&ji(Ai(e,Ti),t)(),t in e)},set(){return!0},deleteProperty(){return!0},ownKeys:Pi,getOwnPropertyDescriptor:Mi};function Ii(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[Ti]&&e[Ti][t]&&i!==void 0&&e[Ti][t].$()):(e[t]=n,e[Ti]&&e[Ti][t]&&i===void 0&&e[Ti][t].$());let o=Ai(e,wi),s;if((s=ji(o,t,i))&&s.$(()=>n),Array.isArray(e)&&e.length!==a){for(let t=e.length;t<a;t++)(s=o[t])&&s.$();(s=ji(o,`length`,a))&&s.$(e.length)}(s=o[Ei])&&s.$()}function Li(e,t){let n=Object.keys(t);for(let r=0;r<n.length;r+=1){let i=n[r];Ri(i)||Ii(e,i,t[i])}}function Ri(e){return e===`__proto__`||e===`constructor`||e===`prototype`}function zi(e,t){if(typeof t==`function`&&(t=t(e)),t=ki(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&&Ii(e,n,r)}Ii(e,`length`,r)}else Li(e,t)}function Bi(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&&Ri(r)))return;if(Array.isArray(r)){for(let i=0;i<r.length;i++)Bi(e,[r[i]].concat(t),n);return}if(o&&a===`function`){for(let i=0;i<e.length;i++)r(e[i],i)&&Bi(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)Bi(e,[r].concat(t),n);return}if(t.length>1){Bi(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=ki(a),r===void 0||Oi(i)&&Oi(a)&&!Array.isArray(a)?Li(i,a):Ii(e,r,a))}function Vi(...[e,t]){let n=ki(e||{}),r=Array.isArray(n),i=Di(n);function a(...e){nr(()=>{r&&e.length===1?zi(n,e[0]):Bi(n,e)})}return[i,a]}function Hi(e,t){let n=Reflect.getOwnPropertyDescriptor(e,t);return!n||n.get||n.set||!n.configurable||t===kn||t===wi?n:(delete n.value,delete n.writable,n.get=()=>e[kn][t],n.set=n=>e[kn][t]=n,n)}var Ui={get(e,t,n){if(t===Ci)return e;if(t===kn)return n;if(t===jn)return Ni(e),n;let r=Ai(e,wi),i=r[t],a=i?i():e[t];if(t===wi||t===Ti||t===`__proto__`)return a;if(!i){let i=Object.getOwnPropertyDescriptor(e,t),o=typeof a==`function`;if(cr()&&(!o||e.hasOwnProperty(t))&&!(i&&i.get))a=ji(r,t,a)();else if(a!=null&&o&&a===Array.prototype[t])return(...e)=>nr(()=>Array.prototype[t].apply(n,e))}return Oi(a)?Wi(a):a},has(e,t){return t===Ci||t===kn||t===jn||t===wi||t===Ti||t===`__proto__`||(cr()&&ji(Ai(e,Ti),t)(),t in e)},set(e,t,n){return nr(()=>Ii(e,t,ki(n))),!0},deleteProperty(e,t){return nr(()=>Ii(e,t,void 0,!0)),!0},ownKeys:Pi,getOwnPropertyDescriptor:Hi};function Wi(e){let t=e[kn];if(!t){Object.defineProperty(e,kn,{value:t=new Proxy(e,Ui)});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=>nr(()=>n.call(t,e)),configurable:!0})}}}}return t}function Gi(e,t){return Wi(ki(e||{}))}function Ki(e,t){nr(()=>t(ki(e)))}var qi=Symbol(`store-root`);function Ji(e){return e===`__proto__`||e===`constructor`||e===`prototype`}function Yi(e,t,n,r,i){if(Ji(n))return;let a=t[n];if(e===a)return;let o=Array.isArray(e);if(n!==qi&&(!Oi(e)||!Oi(a)||o!==Array.isArray(a)||i&&e[i]!==a[i])){Ii(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++)Yi(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++)Ii(a,n,e[n]);for(;n<e.length;n++)Ii(a,n,f[n]),Yi(e[n],a,n,r,i);a.length>e.length&&Ii(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?(Ii(a,n,f[n]),Yi(e[n],a,n,r,i)):Ii(a,n,e[n])}else for(let t=0,n=e.length;t<n;t++)Yi(e[t],a,t,r,i);a.length>e.length&&Ii(a,`length`,e.length);return}let s=Object.keys(e);for(let t=0,n=s.length;t<n;t++)Ji(s[t])||Yi(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&&Ii(a,c[t],void 0)}function Xi(e,t={}){let{merge:n,key:r=`id`}=t,i=ki(e);return e=>{if(!Oi(e)||!Oi(i))return i;let t=Yi(i,{[qi]:e},qi,n,r);return t===void 0?e:t}}var Zi=new WeakMap,Qi={get(e,t){if(t===Ci)return e;let n=e[t];if(t===kn||t===jn||t===wi||t===Ti||t===`__proto__`)return n;let r;return Oi(n)?Zi.get(n)||(Zi.set(n,r=new Proxy(n,Qi)),r):n},set(e,t,n){return Ii(e,t,ki(n)),!0},deleteProperty(e,t){return Ii(e,t,void 0,!0),!0}};function $i(e){return t=>{if(Oi(t)){let n;(n=Zi.get(t))||Zi.set(t,n=new Proxy(t,Qi)),e(n)}return t}}var ea=Object.defineProperty,ta=e=>e;function na(e,t){this[e]=ta.bind(null,t)}var ra=(e,t)=>{for(var n in t)ea(e,n,{get:t[n],enumerable:!0,configurable:!0,set:na.bind(t,n)})},ia={};ra(ia,{SharedEvents:()=>ia,make:()=>aa});function aa(e){let t,n=4096;function r(e){e.connected=void 0,e.controller.abort(),t===e&&(t=void 0)}async function i(t){let n,i={};try{if(t.controller.signal.aborted)return;for(n=e(t.controller.signal,()=>{t.subscribers.forEach(e=>e.activity?.())})[Symbol.asyncIterator]();!t.controller.signal.aborted;){let e=await n.next();if(e.done||t.controller.signal.aborted)break;e.value.type===`server.connected`&&(t.connected=e.value),t.subscribers.forEach(t=>t.push(e.value))}}catch(e){i={error:e}}finally{r(t);try{await n?.return?.()}catch(e){`error`in i||(i={error:e})}t.subscribers.forEach(e=>e.finish(i))}}return{subscribe(e){return{[Symbol.asyncIterator](){let a=[],o=[],s=!1,c,l,u=e?.types?.length?new Set(e.types):void 0,d=e=>!u||e.type===`server.connected`||u.has(e.type);function f(t,n=!0){c=t,n&&(o.length=0),e?.signal?.removeEventListener(`abort`,p),l?.subscribers.delete(ee)&&!l.subscribers.size&&r(l),a.splice(0).forEach(e=>{`error`in t?e.reject(t.error):e.resolve({done:!0,value:void 0})})}function p(){f({})}let ee={activity:e?.onActivity,finish(e){f(e,!1)},push(e){if(c||!d(e))return;let t=a.shift();if(t){t.resolve({done:!1,value:e});return}if(o.length===n){f({error:Error(`Event subscriber exceeded its ${n}-event capacity`)});return}o.push(e)}};function te(){if(c)return;let e=!t;l=t??{controller:new AbortController,subscribers:new Set},t=l,l.subscribers.add(ee),l.connected&&ee.push(l.connected),e&&i(l)}return{next(){let t=o.shift();if(t)return Promise.resolve({done:!1,value:t});if(c)return`error`in c?Promise.reject(c.error):Promise.resolve({done:!0,value:void 0});if(e?.signal?.aborted)return p(),Promise.resolve({done:!0,value:void 0});let n=Promise.withResolvers();return a.push(n),s||(s=!0,e?.signal?.addEventListener(`abort`,p,{once:!0}),te()),n.promise},return(){return f({}),Promise.resolve({done:!0,value:void 0})}}}}}}}var oa=class extends Error{reason;name=`ClientError`;constructor(e,t){let n=t?.detail??(t?.cause instanceof Error?t.cause.message:void 0);super(n?`${e}: ${n}`:e,t),this.reason=e}};ra({},{make:()=>ca});var sa=16777216;function ca(e){let t=e.fetch??globalThis.fetch,n=(t,n)=>{let r=new URL(e.baseUrl);r.pathname.endsWith(`/`)||(r.pathname+=`/`);let i=new URL(t.path.slice(1),r);for(let[e,n]of Object.entries(t.query??{}))ua(i.searchParams,e,n);let a=new Headers(e.headers);for(let[e,n]of Object.entries(t.headers??{}))n!=null&&a.set(e,String(n));for(let[e,t]of new Headers(n?.headers))a.set(e,t);return t.body!==void 0&&!a.has(`content-type`)&&a.set(`content-type`,t.binaryBody?`application/octet-stream`:`application/json`),{url:i,init:{method:t.method,signal:n?.signal,headers:a,body:t.body===void 0?void 0:t.binaryBody?t.body:JSON.stringify(t.body)}}},r=async(e,r)=>{try{let i=n(e,r);return await t(i.url,i.init)}catch(e){throw new oa(`Transport`,{cause:e})}},i=async(e,t)=>{if(t.declaredStatuses.includes(e.status))throw fa(await da(e));try{await e.body?.cancel()}catch{}throw new oa(`UnexpectedStatus`,{cause:{status:e.status},detail:String(e.status)})},a=async(e,t)=>{let n=await r(e,t);if(n.status!==e.successStatus)return i(n,e);if(e.binary)return new Uint8Array(await n.arrayBuffer());if(e.empty){try{await n.body?.cancel()}catch{}return}return await da(n)},o=(e,t)=>({async*[Symbol.asyncIterator](){let n=await r(e,t);if(n.status!==e.successStatus&&await i(n,e),!pa(n,`text/event-stream`)){try{await n.body?.cancel()}catch{}throw new oa(`UnsupportedContentType`,{detail:n.headers.get(`content-type`)})}if(n.body===null)throw new oa(`MalformedResponse`);let a=n.body.getReader(),o=new TextDecoder,s=``;try{for(;;){let e;try{e=await a.read()}catch(e){throw new oa(`Transport`,{cause:e})}if(e.done||t?.onActivity?.(),s+=o.decode(e.value,{stream:!e.done}),s.length>sa)throw new oa(`SseEventTooLarge`);let n=!e.done&&s.endsWith(`\r`);n&&(s=s.slice(0,-1)),s=s.replaceAll(`\r
|
|
12
|
+
`)}if(e.done)return}}finally{try{await a.cancel()}catch{}a.releaseLock()}}}),s={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),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),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),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),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)},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),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)},experimental:{session:{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),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),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),wait:(e,t)=>a({method:`POST`,path:`/api/experimental/session/${encodeURIComponent(e.sessionID)}/wait`,successStatus:204,declaredStatuses:[400,401,404,503],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)}},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)},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)},integration:{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)}},mcp:{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),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)}},file:{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)},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)},schedule:{create:(e,t)=>a({method:`POST`,path:`/api/experimental/schedule`,body:{sessionID:e.sessionID,name:e.name,when:e.when,ends:e.ends,prompt:e.prompt},successStatus:200,declaredStatuses:[400,401,403,404],empty:!1},t).then(e=>e.data),list:(e,t)=>a({method:`GET`,path:`/api/experimental/schedule`,query:{sessionID:e.sessionID},successStatus:200,declaredStatuses:[400,401,403,404],empty:!1},t).then(e=>e.data),get:(e,t)=>a({method:`GET`,path:`/api/experimental/schedule/${encodeURIComponent(e.scheduleID)}`,successStatus:200,declaredStatuses:[400,401,403,404],empty:!1},t).then(e=>e.data),pause:(e,t)=>a({method:`POST`,path:`/api/experimental/schedule/${encodeURIComponent(e.scheduleID)}/pause`,successStatus:200,declaredStatuses:[400,401,403,404],empty:!1},t).then(e=>e.data),resume:(e,t)=>a({method:`POST`,path:`/api/experimental/schedule/${encodeURIComponent(e.scheduleID)}/resume`,successStatus:200,declaredStatuses:[400,401,403,404],empty:!1},t).then(e=>e.data),delete:(e,t)=>a({method:`DELETE`,path:`/api/experimental/schedule/${encodeURIComponent(e.scheduleID)}`,successStatus:204,declaredStatuses:[400,401,403,404],empty:!0},t)},migration:{v1:{status:e=>a({method:`GET`,path:`/api/experimental/migration/v1`,successStatus:200,declaredStatuses:[400,401],empty:!1},e)}},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:{update:(e,t)=>a({method:`PATCH`,path:`/api/experimental/config`,body:{shell:e.shell},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)},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),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),resource:{catalog:(e,t)=>a({method:`GET`,path:`/api/mcp/resource`,query:{location:e?.location},successStatus:200,declaredStatuses:[400,401,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/${Gt(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)},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)}},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)}},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)},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)}};return{...s,session:{...s.session,stats:s.experimental.session.stats,import:s.experimental.session.import,export:s.experimental.session.export,skill:s.experimental.session.skill,wait:s.experimental.session.wait,instructions:{entry:{list:s.experimental.session.instructions.entry.list,put:s.experimental.session.instructions.entry.put,remove:s.experimental.session.instructions.entry.remove}},log:s.experimental.session.log},generate:{text:s.experimental.generate.text,image:s.experimental.generate.image,decisions:s.experimental.generate.decisions},voice:{models:s.experimental.voice.models,session:s.experimental.voice.session},integration:{...s.integration,wellknown:{add:s.experimental.integration.wellknown.add}},mcp:{...s.mcp,add:s.experimental.mcp.add,remove:s.experimental.mcp.remove,connect:s.experimental.mcp.connect,disconnect:s.experimental.mcp.disconnect,client:{token:s.experimental.mcp.client.token}},file:{...s.file,write:s.experimental.file.write,watch:s.experimental.file.watch,unwatch:s.experimental.file.unwatch},migration:{v1:{status:s.experimental.migration.v1.status}},usage:{limits:s.experimental.usage.limits},config:{...s.config,update:s.experimental.config.update}}}function Gt(e){return e.split(`/`).map(encodeURIComponent).join(`/`)}function Kt(e,t,n){if(n!==void 0){if(n===null){e.append(t,`null`);return}if(Array.isArray(n)){for(let r of n)Kt(e,t,r);return}if(typeof n==`object`){for(let[r,i]of Object.entries(n))Kt(e,`${t}[${r}]`,i);return}e.append(t,String(n))}}async function qt(e){if(!Yt(e,`application/json`)&&!e.headers.get(`content-type`)?.includes(`+json`)){try{await e.body?.cancel()}catch{}throw new Ht(`UnsupportedContentType`,{detail:e.headers.get(`content-type`)})}let t;try{t=await e.text()}catch(e){throw new Ht(`Transport`,{cause:e})}if(t===``)throw new Ht(`MalformedResponse`);try{return JSON.parse(t)}catch(e){throw new Ht(`MalformedResponse`,{cause:e})}}function Jt(e){let t=Object.assign(Error(e.message??e.data?.message),e);return e._tag&&(t.name=e._tag),t}function Yt(e,t){return e.headers.get(`content-type`)?.split(`;`,1)[0]?.trim().toLowerCase()===t}var Xt=e=>typeof e==`object`&&!!e&&`_tag`in e&&e._tag===`LocationNotFoundError`,Zt=e=>typeof e==`object`&&!!e&&`_tag`in e&&e._tag===`SessionNotFoundError`,Qt=e=>typeof e==`object`&&!!e&&`_tag`in e&&e._tag===`PermissionNotFoundError`,$t=e=>typeof e==`object`&&!!e&&`_tag`in e&&e._tag===`RpcError`,en=e=>typeof e==`object`&&!!e&&`_tag`in e&&e._tag===`RpcInternalError`;function tn(e,t){return n=>{let r=(e,r)=>{if(!Object.hasOwn(n.events,e))throw Error(`Unknown RPC event: ${n.id}.${e}`);let i=nn(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!$t(e)&&!en(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 nn(e,t){return`rpc.${e.id}.${t}`}var rn={};zt(rn,{OpenCode:()=>rn,make:()=>an});function an(e){let t=Wt(e),n=Vt((e,n)=>t.event.subscribe(void 0,{signal:e,onActivity:n}));return{...t,rpc:Object.assign(tn(t,n),t.rpc),event:n}}var on=e({$DEVCOMP:()=>Nn,$PROXY:()=>An,$TRACK:()=>Mn,DEV:()=>void 0,ErrorBoundary:()=>vi,For:()=>di,Index:()=>fi,Match:()=>hi,Show:()=>pi,Suspense:()=>Si,SuspenseList:()=>xi,Switch:()=>mi,batch:()=>rr,cancelCallback:()=>Cn,catchError:()=>cr,children:()=>br,createComponent:()=>ei,createComputed:()=>Jn,createContext:()=>vr,createDeferred:()=>tr,createEffect:()=>Xn,createMemo:()=>Qn,createReaction:()=>Zn,createRenderEffect:()=>Yn,createResource:()=>er,createRoot:()=>Kn,createSelector:()=>nr,createSignal:()=>qn,createUniqueId:()=>li,enableExternalSource:()=>Cr,enableHydration:()=>$r,enableScheduling:()=>fr,equalFn:()=>kn,from:()=>qr,getListener:()=>lr,getOwner:()=>ur,indexArray:()=>Zr,lazy:()=>si,mapArray:()=>Xr,mergeProps:()=>ai,observable:()=>Kr,on:()=>ar,onCleanup:()=>sr,onError:()=>Wr,onMount:()=>or,requestCallback:()=>Sn,resetErrorBoundaries:()=>_i,runWithOwner:()=>dr,sharedConfig:()=>P,splitProps:()=>oi,startTransition:()=>pr,untrack:()=>ir,useContext:()=>yr,useTransition:()=>gr}),sn=1,cn=!1,ln=!1,un=[],dn=null,fn=null,pn=5,mn=0,hn=300,gn=0,_n=null,vn=null,yn=1073741823;function bn(){let e=new MessageChannel,t=e.port1,n=e.port2;if(typeof t.unref==`function`&&t.unref(),typeof n.unref==`function`&&n.unref(),_n=()=>n.postMessage(null),t.onmessage=()=>{if(vn!==null){let e=performance.now();mn=e+pn,gn=e+hn;try{vn(e)?n.postMessage(null):vn=null}catch(e){throw n.postMessage(null),e}}},navigator&&navigator.scheduling&&navigator.scheduling.isInputPending){let e=navigator.scheduling;fn=()=>{let t=performance.now();return t>=mn?e.isInputPending()?!0:t>=gn:!1}}else fn=()=>performance.now()>=mn}function xn(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 Sn(e,t){_n||bn();let n=performance.now(),r=yn;t&&t.timeout&&(r=t.timeout);let i={id:sn++,fn:e,startTime:n,expirationTime:n+r};return xn(un,i),!cn&&!ln&&(cn=!0,vn=wn,_n()),i}function Cn(e){e.fn=null}function wn(e){cn=!1,ln=!0;try{return Tn(e)}finally{dn=null,ln=!1}}function Tn(e){let t=e;for(dn=un[0]||null;dn!==null&&!(dn.expirationTime>t&&fn());){let e=dn.fn;e===null?un.shift():(dn.fn=null,e(dn.expirationTime<=t),t=performance.now(),dn===un[0]&&un.shift()),dn=un[0]||null}return dn!==null}var P={context:void 0,registry:void 0,effects:void 0,done:!1,getContextId(){return En(this.context.count)},getNextContextId(){return En(this.context.count++)}};function En(e){let t=String(e),n=t.length-1;return P.context.id+(n?String.fromCharCode(96+n):``)+t}function Dn(e){P.context=e}function On(){return{...P.context,id:P.getNextContextId(),count:0}}var kn=(e,t)=>e===t,An=Symbol(`solid-proxy`),jn=typeof Proxy==`function`,Mn=Symbol(`solid-track`),Nn=Symbol(`solid-dev-component`),Pn={equals:kn},Fn=null,In=Mr,Ln=1,Rn=2,zn={owned:null,cleanups:null,context:null,owner:null},Bn={},F=null,I=null,Vn=null,Hn=null,L=null,Un=null,Wn=null,Gn=0;function Kn(e,t){let n=L,r=F,i=e.length===0,a=t===void 0?r:t,o=i?zn:{owned:null,cleanups:null,context:a?a.context:null,owner:a},s=i?e:()=>e(()=>ir(()=>Lr(o)));F=o,L=null;try{return Ar(s,!0)}finally{L=n,F=r}}function qn(e,t){t=t?Object.assign({},Pn,t):Pn;let n={value:e,observers:null,observerSlots:null,comparator:t.equals||void 0};return[wr.bind(n),e=>(typeof e==`function`&&(e=I&&I.running&&I.sources.has(n)?e(n.tValue):e(n.value)),Tr(n,e))]}function Jn(e,t,n){let r=Or(e,t,!0,Ln);Vn&&I&&I.running?Un.push(r):Er(r)}function Yn(e,t,n){let r=Or(e,t,!1,Ln);Vn&&I&&I.running?Un.push(r):Er(r)}function Xn(e,t,n){In=Pr;let r=Or(e,t,!1,Ln),i=xr&&yr(xr);i&&(r.suspense=i),(!n||!n.render)&&(r.user=!0),Wn?Wn.push(r):Er(r)}function Zn(e,t){let n,r=Or(()=>{n?n():ir(e),n=void 0},void 0,!1,0),i=xr&&yr(xr);return i&&(r.suspense=i),r.user=!0,e=>{n=e,Er(r)}}function Qn(e,t,n){n=n?Object.assign({},Pn,n):Pn;let r=Or(e,t,!0,0);return r.observers=null,r.observerSlots=null,r.comparator=n.equals||void 0,Vn&&I&&I.running?(r.tState=Ln,Un.push(r)):Er(r),wr.bind(r)}function $n(e){return e&&typeof e==`object`&&`then`in e}function er(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=Bn,c=null,l=!1,u=!1,d=`initialValue`in a,f=typeof r==`function`&&Qn(r),p=new Set,[ee,te]=(a.storage||qn)(a.initialValue),[ne,m]=qn(void 0),[re,ie]=qn(void 0,{equals:!1}),[ae,oe]=qn(d?`ready`:`unresolved`);P.context&&(c=P.getNextContextId(),a.ssrLoadFrom===`initial`?s=a.initialValue:P.load&&P.has(c)&&(s=P.load(c)));function se(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=Bn,I&&e&&l?(I.promises.delete(e),l=!1,Ar(()=>{I.running=!0,ce(t,n)},!1)):ce(t,n)),t}function ce(e,t){Ar(()=>{t===void 0&&te(()=>e),oe(t===void 0?d?`ready`:`unresolved`:`errored`),m(t);for(let e of p.keys())e.decrement();p.clear()},!1)}function le(){let e=xr&&yr(xr),t=ee(),n=ne();if(n!==void 0&&!o)throw n;return L&&!L.user&&e&&Jn(()=>{re(),o&&(e.resolved&&I&&l?I.promises.add(o):p.has(e)||(e.increment(),p.add(e)))}),t}function ue(e=!0){if(e!==!1&&u)return;u=!1;let t=f?f():r;if(l=I&&I.running,t==null||t===!1){se(o,ir(ee));return}I&&o&&I.promises.delete(o);let n,a=s===Bn?ir(()=>{try{return i(t,{value:ee(),refetching:e})}catch(e){n=e}}):s;if(n!==void 0){se(o,void 0,zr(n),t);return}return $n(a)?(o=a,`v`in a?(a.s===1?se(o,a.v,void 0,t):se(o,void 0,zr(a.v),t),a):(u=!0,queueMicrotask(()=>u=!1),Ar(()=>{oe(d?`refreshing`:`pending`),ie()},!1),a.then(e=>se(a,e,void 0,t),e=>se(a,void 0,zr(e),t)))):(se(o,a,void 0,t),a)}Object.defineProperties(le,{state:{get:()=>ae()},error:{get:()=>ne()},loading:{get(){let e=ae();return e===`pending`||e===`refreshing`}},latest:{get(){if(!d)return le();let e=ne();if(e&&!o)throw e;return ee()}}});let de=F;return f?Jn(()=>(de=F,ue(!1))):ue(!1),[le,{refetch:e=>dr(de,()=>ue(e)),mutate:te}]}function tr(e,t){let n,r=t?t.timeoutMs:void 0,i=Or(()=>((!n||!n.fn)&&(n=Sn(()=>o(()=>i.value),r===void 0?void 0:{timeout:r})),e()),void 0,!0),[a,o]=qn(I&&I.running&&I.sources.has(i)?i.tValue:i.value,t);return Er(i),o(()=>I&&I.running&&I.sources.has(i)?i.tValue:i.value),a}function nr(e,t=kn,n){let r=new Map,i=Or(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=Ln,e.pure?Un.push(e):Wn.push(e);return i},void 0,!0,Ln);return Er(i),e=>{let n=L;if(n){let t;(t=r.get(e))?t.add(n):r.set(e,t=new Set([n])),sr(()=>{t.delete(n),!t.size&&r.delete(e)})}return t(e,I&&I.running&&I.sources.has(i)?i.tValue:i.value)}}function rr(e){return Ar(e,!1)}function ir(e){if(!Hn&&L===null)return e();let t=L;L=null;try{return Hn?Hn.untrack(e):e()}finally{L=t}}function ar(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=ir(()=>t(o,i,n));return i=o,s}}function or(e){Xn(()=>ir(e))}function sr(e){return F===null||(F.cleanups===null?F.cleanups=[e]:F.cleanups.push(e)),e}function cr(e,t){Fn||=Symbol(`error`),F=Or(void 0,void 0,!0),F.context={...F.context,[Fn]:[t]},I&&I.running&&I.sources.add(F);try{return e()}catch(e){Vr(e)}finally{F=F.owner}}function lr(){return L}function ur(){return F}function dr(e,t){let n=F,r=L;F=e,L=null;try{return Ar(t,!0)}catch(e){Vr(e)}finally{F=n,L=r}}function fr(e=Sn){Vn=e}function pr(e){if(I&&I.running)return e(),I.done;let t=L,n=F;return Promise.resolve().then(()=>{L=t,F=n;let r;return(Vn||xr)&&(r=I||={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),Ar(e,!1),L=F=null,r?r.done:void 0})}var[mr,hr]=qn(!1);function gr(){return[mr,pr]}function _r(e){Wn.push.apply(Wn,e),e.length=0}function vr(e,t){let n=Symbol(`context`);return{id:n,Provider:Ur(n),defaultValue:e}}function yr(e){let t;return F&&F.context&&(t=F.context[e.id])!==void 0?t:e.defaultValue}function br(e){let t=Qn(e),n=Qn(()=>Hr(t()));return n.toArray=()=>{let e=n();return Array.isArray(e)?e:e==null?[]:[e]},n}var xr;function Sr(){return xr||=vr()}function Cr(e,t=e=>e()){if(Hn){let{factory:n,untrack:r}=Hn;Hn={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 Hn={factory:e,untrack:t}}function wr(){let e=I&&I.running;if(this.sources&&(e?this.tState:this.state))if((e?this.tState:this.state)===Ln)Er(this);else{let e=Un;Un=null,Ar(()=>Fr(this),!1),Un=e}if(L){let e=this.observers;if(!e||e[e.length-1]!==L){let t=e?e.length:0;L.sources?(L.sources.push(this),L.sourceSlots.push(t)):(L.sources=[this],L.sourceSlots=[t]),e?(e.push(L),this.observerSlots.push(L.sources.length-1)):(this.observers=[L],this.observerSlots=[L.sources.length-1])}}return e&&I.sources.has(this)?this.tValue:this.value}function Tr(e,t,n){let r=I&&I.running&&I.sources.has(e)?e.tValue:e.value;if(!e.comparator||!e.comparator(r,t)){if(I){let r=I.running;(r||!n&&I.sources.has(e))&&(I.sources.add(e),e.tValue=t),r||(e.value=t)}else e.value=t;e.observers&&e.observers.length&&Ar(()=>{for(let t=0;t<e.observers.length;t+=1){let n=e.observers[t],r=I&&I.running;r&&I.disposed.has(n)||((r?!n.tState:!n.state)&&(n.pure?Un.push(n):Wn.push(n),n.observers&&Ir(n)),r?n.tState=Ln:n.state=Ln)}if(Un.length>1e6)throw Un=[],Error()},!1)}return t}function Er(e){if(!e.fn)return;Lr(e);let t=Gn;Dr(e,I&&I.running&&I.sources.has(e)?e.tValue:e.value,t),I&&!I.running&&I.sources.has(e)&&queueMicrotask(()=>{Ar(()=>{I&&(I.running=!0),L=F=e,Dr(e,e.tValue,t),L=F=null},!1)})}function Dr(e,t,n){let r,i=F,a=L;L=F=e;try{r=e.fn(t)}catch(t){return e.pure&&(I&&I.running?(e.tState=Ln,e.tOwned&&e.tOwned.forEach(Lr),e.tOwned=void 0):(e.state=Ln,e.owned&&e.owned.forEach(Lr),e.owned=null)),e.updatedAt=n+1,Vr(t)}finally{L=a,F=i}(!e.updatedAt||e.updatedAt<=n)&&(e.updatedAt!=null&&`observers`in e?Tr(e,r,!0):I&&I.running&&e.pure?(I.sources.has(e)||(e.value=r),I.sources.add(e),e.tValue=r):e.value=r,e.updatedAt=n)}function Or(e,t,n,r=Ln,i){let a={fn:e,state:r,updatedAt:null,owned:null,sources:null,sourceSlots:null,cleanups:null,value:t,owner:F,context:F?F.context:null,pure:n};if(I&&I.running&&(a.state=0,a.tState=r),F===null||F!==zn&&(I&&I.running&&F.pure?F.tOwned?F.tOwned.push(a):F.tOwned=[a]:F.owned?F.owned.push(a):F.owned=[a]),Hn&&a.fn){let e=a.fn,[t,n]=qn(void 0,{equals:!1}),r=Hn.factory(e,n);sr(()=>r.dispose());let i,o=()=>pr(n).then(()=>{i&&=(i.dispose(),void 0)});a.fn=n=>(t(),I&&I.running?(i||=Hn.factory(e,o),i.track(n)):r.track(n))}return a}function kr(e){let t=I&&I.running;if((t?e.tState:e.state)===0)return;if((t?e.tState:e.state)===Rn)return Fr(e);if(e.suspense&&ir(e.suspense.inFallback))return e.suspense.effects.push(e);let n=[e];for(;(e=e.owner)&&(!e.updatedAt||e.updatedAt<Gn);){if(t&&I.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(I.disposed.has(t))return}if((t?e.tState:e.state)===Ln)Er(e);else if((t?e.tState:e.state)===Rn){let t=Un;Un=null,Ar(()=>Fr(e,n[0]),!1),Un=t}}}function Ar(e,t){if(Un)return e();let n=!1;t||(Un=[]),Wn?n=!0:Wn=[],Gn++;try{let t=e();return jr(n),t}catch(e){n||(Wn=null),Un=null,Vr(e)}}function jr(e){if(Un&&=(Vn&&I&&I.running?Nr(Un):Mr(Un),null),e)return;let t;if(I){if(!I.promises.size&&!I.queue.size){let e=I.sources,n=I.disposed;Wn.push.apply(Wn,I.effects),t=I.resolve;for(let e of Wn)`tState`in e&&(e.state=e.tState),delete e.tState;I=null,Ar(()=>{for(let e of n)Lr(e);for(let t of e){if(t.value=t.tValue,t.owned)for(let e=0,n=t.owned.length;e<n;e++)Lr(t.owned[e]);t.tOwned&&(t.owned=t.tOwned),delete t.tValue,delete t.tOwned,t.tState=0}hr(!1)},!1)}else if(I.running){I.running=!1,I.effects.push.apply(I.effects,Wn),Wn=null,hr(!0);return}}let n=Wn;Wn=null,n.length&&Ar(()=>In(n),!1),t&&t()}function Mr(e){for(let t=0;t<e.length;t++)kr(e[t])}function Nr(e){for(let t=0;t<e.length;t++){let n=e[t],r=I.queue;r.has(n)||(r.add(n),Vn(()=>{r.delete(n),Ar(()=>{I.running=!0,kr(n)},!1),I&&(I.running=!1)}))}}function Pr(e){let t,n=0;for(t=0;t<e.length;t++){let r=e[t];r.user?e[n++]=r:kr(r)}if(P.context){if(P.count){P.effects||=[],P.effects.push(...e.slice(0,n));return}Dn()}for(P.effects&&(P.done||!P.count)&&(e=[...P.effects,...e],n+=P.effects.length,delete P.effects),t=0;t<n;t++)kr(e[t])}function Fr(e,t){let n=I&&I.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===Ln?i!==t&&(!i.updatedAt||i.updatedAt<Gn)&&kr(i):e===Rn&&Fr(i,t)}}}function Ir(e){let t=I&&I.running;for(let n=0;n<e.observers.length;n+=1){let r=e.observers[n];(t?!r.tState:!r.state)&&(t?r.tState=Rn:r.state=Rn,r.pure?Un.push(r):Wn.push(r),r.observers&&Ir(r))}}function Lr(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--)Lr(e.tOwned[t]);delete e.tOwned}if(I&&I.running&&e.pure)Rr(e,!0);else if(e.owned){for(t=e.owned.length-1;t>=0;t--)Lr(e.owned[t]);e.owned=null}if(e.cleanups){for(t=e.cleanups.length-1;t>=0;t--)e.cleanups[t]();e.cleanups=null}I&&I.running?e.tState=0:e.state=0}function Rr(e,t){if(t||(e.tState=0,I.disposed.add(e)),e.owned)for(let t=0;t<e.owned.length;t++)Rr(e.owned[t])}function zr(e){return e instanceof Error?e:Error(typeof e==`string`?e:`Unknown error`,{cause:e})}function Br(e,t,n){try{for(let n of t)n(e)}catch(e){Vr(e,n&&n.owner||null)}}function Vr(e,t=F){let n=Fn&&t&&t.context&&t.context[Fn],r=zr(e);if(!n)throw r;Wn?Wn.push({fn(){Br(r,n,t)},state:Ln}):Br(r,n,t)}function Hr(e){if(typeof e==`function`&&!e.length)return Hr(e());if(Array.isArray(e)){let t=[];for(let n=0;n<e.length;n++){let r=Hr(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 Ur(e,t){return function(t){let n;return Yn(()=>n=ir(()=>(F.context={...F.context,[e]:t.value},br(()=>t.children))),void 0),n}}function Wr(e){Fn||=Symbol(`error`),F===null||(F.context===null||!F.context[Fn]?(F.context={...F.context,[Fn]:[e]},Gr(F,Fn,[e])):F.context[Fn].push(e))}function Gr(e,t,n){if(e.owned)for(let r=0;r<e.owned.length;r++)e.owned[r].context===e.context&&Gr(e.owned[r],t,n),e.owned[r].context?e.owned[r].context[t]||(e.owned[r].context[t]=n,Gr(e.owned[r],t,n)):(e.owned[r].context=e.context,Gr(e.owned[r],t,n))}function Kr(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=Kn(t=>(Xn(()=>{let t=e();ir(()=>n(t))}),t));return ur()&&sr(r),{unsubscribe(){r()}}},[Symbol.observable||`@@observable`](){return this}}}function qr(e,t=void 0){let[n,r]=qn(t,{equals:!1});if(`subscribe`in e){let t=e.subscribe(e=>r(()=>e));sr(()=>`unsubscribe`in t?t.unsubscribe():t())}else sr(e(r));return n}var Jr=Symbol(`fallback`);function Yr(e){for(let t=0;t<e.length;t++)e[t]()}function Xr(e,t,n={}){let r=[],i=[],a=[],o=0,s=t.length>1?[]:null;return sr(()=>Yr(a)),()=>{let c=e()||[],l=c.length,u,d;return c[Mn],ir(()=>{let e,t,p,ee,te,ne,m,re,ie;if(l===0)o!==0&&(Yr(a),a=[],r=[],i=[],o=0,s&&=[]),n.fallback&&(r=[Jr],i[0]=Kn(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]=Kn(f);o=l}else{for(p=Array(l),ee=Array(l),s&&(te=Array(l)),ne=0,m=Math.min(o,l);ne<m&&r[ne]===c[ne];ne++);for(m=o-1,re=l-1;m>=ne&&re>=ne&&r[m]===c[re];m--,re--)p[re]=i[m],ee[re]=a[m],s&&(te[re]=s[m]);for(e=new Map,t=Array(re+1),d=re;d>=ne;d--)ie=c[d],u=e.get(ie),t[d]=u===void 0?-1:u,e.set(ie,d);for(u=ne;u<=m;u++)ie=r[u],d=e.get(ie),d!==void 0&&d!==-1?(p[d]=i[u],ee[d]=a[u],s&&(te[d]=s[u]),d=t[d],e.set(ie,d)):a[u]();for(d=ne;d<l;d++)d in p?(i[d]=p[d],a[d]=ee[d],s&&(s[d]=te[d],s[d](d))):i[d]=Kn(f);i=i.slice(0,o=l),r=c.slice(0)}return i});function f(e){if(a[d]=e,s){let[e,n]=qn(d);return s[d]=n,t(c[d],e)}return t(c[d])}}}function Zr(e,t,n={}){let r=[],i=[],a=[],o=[],s=0,c;return sr(()=>Yr(a)),()=>{let l=e()||[],u=l.length;return l[Mn],ir(()=>{if(u===0)return s!==0&&(Yr(a),a=[],r=[],i=[],s=0,o=[]),n.fallback&&(r=[Jr],i[0]=Kn(e=>(a[0]=e,n.fallback())),s=1),i;for(r[0]===Jr&&(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]=Kn(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]=qn(l[c]);return o[c]=r,t(n,c)}}}var Qr=!1;function $r(){Qr=!0}function ei(e,t){if(Qr&&P.context){let n=P.context;Dn(On());let r=ir(()=>e(t||{}));return Dn(n),r}return ir(()=>e(t||{}))}function ti(){return!0}var ni={get(e,t,n){return t===An?n:e.get(t)},has(e,t){return t===An||e.has(t)},set:ti,deleteProperty:ti,getOwnPropertyDescriptor(e,t){return{configurable:!0,enumerable:!0,get(){return e.get(t)},set:ti,deleteProperty:ti}},ownKeys(e){return e.keys()}};function ri(e){return(e=typeof e==`function`?e():e)?e:{}}function ii(){for(let e=0,t=this.length;e<t;++e){let t=this[e]();if(t!==void 0)return t}}function ai(...e){let t=!1;for(let n=0;n<e.length;n++){let r=e[n];t||=!!r&&An in r,e[n]=typeof r==`function`?(t=!0,Qn(r)):r}if(jn&&t)return new Proxy({get(t){for(let n=e.length-1;n>=0;n--){let r=ri(e[n])[t];if(r!==void 0)return r}},has(t){for(let n=e.length-1;n>=0;n--)if(t in ri(e[n]))return!0;return!1},keys(){let t=[];for(let n=0;n<e.length;n++)t.push(...Object.keys(ri(e[n])));return[...new Set(t)]}},ni);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:ii.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 oi(e,...t){let n=t.length;if(jn&&An 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)}},ni));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))}},ni)),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 si(e){let t,n,r=r=>{let i=P.context;if(i){let[r,a]=qn();P.count||=0,P.count++,(n||=e()).then(e=>{!P.done&&Dn(i),P.count--,a(()=>e.default),Dn()}),t=r}else if(!t){let[r]=er(()=>(n||=e()).then(e=>e.default));t=r}let a;return Qn(()=>(a=t())?ir(()=>{if(!i||P.done)return a(r);let e=P.context;Dn(i);let t=a(r);return Dn(e),t}):``)};return r.preload=()=>n||((n=e()).then(e=>t=()=>e.default),n),r}var ci=0;function li(){return P.context?P.getNextContextId():`cl-${ci++}`}var ui=e=>`Stale read from <${e}>.`;function di(e){let t=`fallback`in e&&{fallback:()=>e.fallback};return Qn(Xr(()=>e.each,e.children,t||void 0))}function fi(e){let t=`fallback`in e&&{fallback:()=>e.fallback};return Qn(Zr(()=>e.each,e.children,t||void 0))}function pi(e){let t=e.keyed,n=Qn(()=>e.when,void 0,void 0),r=t?n:Qn(n,void 0,{equals:(e,t)=>!e==!t});return Qn(()=>{let i=r();if(i){let a=e.children;return typeof a==`function`&&a.length>0?ir(()=>a(t?i:()=>{if(!ir(r))throw ui(`Show`);return n()})):a}return e.fallback},void 0,void 0)}function mi(e){let t=br(()=>e.children),n=Qn(()=>{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=Qn(()=>a()?void 0:i.when,void 0,void 0),s=i.keyed?o:Qn(o,void 0,{equals:(e,t)=>!e==!t});r=()=>a()||(s()?[t,o,i]:void 0)}return r});return Qn(()=>{let t=n()();if(!t)return e.fallback;let[r,i,a]=t,o=a.children;return typeof o==`function`&&o.length>0?ir(()=>o(a.keyed?i():()=>{if(ir(n)()?.[0]!==r)throw ui(`Match`);return i()})):o},void 0,void 0)}function hi(e){return e}var gi;function _i(){gi&&[...gi].forEach(e=>e())}function vi(e){let t;P.context&&P.load&&(t=P.load(P.getContextId()));let[n,r]=qn(t,void 0);return gi||=new Set,gi.add(r),sr(()=>gi.delete(r)),Qn(()=>{let t;if(t=n()){let n=e.fallback;return typeof n==`function`&&n.length?ir(()=>n(t,()=>r())):n}return cr(()=>e.children,r)},void 0,void 0)}var yi=(e,t)=>e.showContent===t.showContent&&e.showFallback===t.showFallback,bi=vr();function xi(e){let[t,n]=qn(()=>({inFallback:!1})),r,i=yr(bi),[a,o]=qn([]);i&&(r=i.register(Qn(()=>t()().inFallback)));let s=Qn(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),ei(bi.Provider,{value:{register:e=>{let t;return o(n=>(t=n.length,[...n,e])),Qn(()=>s()[t],void 0,{equals:yi})}},get children(){return e.children}})}function Si(e){let t=0,n,r,i,a,o,[s,c]=qn(!1),l=Sr(),u={increment:()=>{++t===1&&c(!0)},decrement:()=>{--t===0&&c(!1)},inFallback:s,effects:[],resolved:!1},d=ur();if(P.context&&P.load){let e=P.getContextId(),t=P.load(e);if(t&&(typeof t!=`object`||t.s!==1?i=t:P.gather(e)),i&&i!==`$$f`){let[t,n]=qn(void 0,{equals:!1});a=t,i.then(()=>{if(P.done)return n();P.gather(e),Dn(r),n(),Dn()},e=>{o=e,n()})}}let f=yr(bi);f&&(n=f.register(u.inFallback));let p;return sr(()=>p&&p()),ei(l.Provider,{value:u,get children(){return Qn(()=>{if(o)throw o;if(r=P.context,a){a(),a=void 0;return}r&&i===`$$f`&&Dn();let t=Qn(()=>e.children);return Qn(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,_r(u.effects),t();if(c)return p?a:Kn(t=>(p=t,r&&=(Dn({id:r.id+`F`,count:0}),void 0),e.fallback),d)})})}})}var Ci=e({$RAW:()=>wi,DEV:()=>void 0,createMutable:()=>Ki,createStore:()=>Hi,modifyMutable:()=>qi,produce:()=>ea,reconcile:()=>Zi,unwrap:()=>Ai}),wi=Symbol(`store-raw`),Ti=Symbol(`store-node`),Ei=Symbol(`store-has`),Di=Symbol(`store-self`);function Oi(e){let t=e[An];if(!t&&(Object.defineProperty(e,An,{value:t=new Proxy(e,Ii)}),!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 ki(e){let t;return typeof e==`object`&&!!e&&(e[An]||!(t=Object.getPrototypeOf(e))||t===Object.prototype||Array.isArray(e))}function Ai(e,t=new Set){let n,r,i,a;if(n=e!=null&&e[wi])return n;if(!ki(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=Ai(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=Ai(i,t))!==i&&(e[a]=r))}return e}function ji(e,t){let n=e[t];return n||Object.defineProperty(e,t,{value:n=Object.create(null)}),n}function Mi(e,t,n){if(e[t])return e[t];let[r,i]=qn(n,{equals:!1,internal:!0});return r.$=i,e[t]=r}function Ni(e,t){let n=Reflect.getOwnPropertyDescriptor(e,t);return!n||n.get||!n.configurable||t===An||t===Ti?n:(delete n.value,delete n.writable,n.get=()=>e[An][t],n)}function Pi(e){lr()&&Mi(ji(e,Ti),Di)()}function Fi(e){return Pi(e),Reflect.ownKeys(e)}var Ii={get(e,t,n){if(t===wi)return e;if(t===An)return n;if(t===Mn)return Pi(e),n;let r=ji(e,Ti),i=r[t],a=i?i():e[t];if(t===Ti||t===Ei||t===`__proto__`)return a;if(!i){let n=Object.getOwnPropertyDescriptor(e,t);lr()&&(typeof a!=`function`||e.hasOwnProperty(t))&&!(n&&n.get)&&(a=Mi(r,t,a)())}return ki(a)?Oi(a):a},has(e,t){return t===wi||t===An||t===Mn||t===Ti||t===Ei||t===`__proto__`||(lr()&&Mi(ji(e,Ei),t)(),t in e)},set(){return!0},deleteProperty(){return!0},ownKeys:Fi,getOwnPropertyDescriptor:Ni};function Li(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[Ei]&&e[Ei][t]&&i!==void 0&&e[Ei][t].$()):(e[t]=n,e[Ei]&&e[Ei][t]&&i===void 0&&e[Ei][t].$());let o=ji(e,Ti),s;if((s=Mi(o,t,i))&&s.$(()=>n),Array.isArray(e)&&e.length!==a){for(let t=e.length;t<a;t++)(s=o[t])&&s.$();(s=Mi(o,`length`,a))&&s.$(e.length)}(s=o[Di])&&s.$()}function Ri(e,t){let n=Object.keys(t);for(let r=0;r<n.length;r+=1){let i=n[r];zi(i)||Li(e,i,t[i])}}function zi(e){return e===`__proto__`||e===`constructor`||e===`prototype`}function Bi(e,t){if(typeof t==`function`&&(t=t(e)),t=Ai(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&&Li(e,n,r)}Li(e,`length`,r)}else Ri(e,t)}function Vi(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&&zi(r)))return;if(Array.isArray(r)){for(let i=0;i<r.length;i++)Vi(e,[r[i]].concat(t),n);return}if(o&&a===`function`){for(let i=0;i<e.length;i++)r(e[i],i)&&Vi(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)Vi(e,[r].concat(t),n);return}if(t.length>1){Vi(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=Ai(a),r===void 0||ki(i)&&ki(a)&&!Array.isArray(a)?Ri(i,a):Li(e,r,a))}function Hi(...[e,t]){let n=Ai(e||{}),r=Array.isArray(n),i=Oi(n);function a(...e){rr(()=>{r&&e.length===1?Bi(n,e[0]):Vi(n,e)})}return[i,a]}function Ui(e,t){let n=Reflect.getOwnPropertyDescriptor(e,t);return!n||n.get||n.set||!n.configurable||t===An||t===Ti?n:(delete n.value,delete n.writable,n.get=()=>e[An][t],n.set=n=>e[An][t]=n,n)}var Wi={get(e,t,n){if(t===wi)return e;if(t===An)return n;if(t===Mn)return Pi(e),n;let r=ji(e,Ti),i=r[t],a=i?i():e[t];if(t===Ti||t===Ei||t===`__proto__`)return a;if(!i){let i=Object.getOwnPropertyDescriptor(e,t),o=typeof a==`function`;if(lr()&&(!o||e.hasOwnProperty(t))&&!(i&&i.get))a=Mi(r,t,a)();else if(a!=null&&o&&a===Array.prototype[t])return(...e)=>rr(()=>Array.prototype[t].apply(n,e))}return ki(a)?Gi(a):a},has(e,t){return t===wi||t===An||t===Mn||t===Ti||t===Ei||t===`__proto__`||(lr()&&Mi(ji(e,Ei),t)(),t in e)},set(e,t,n){return rr(()=>Li(e,t,Ai(n))),!0},deleteProperty(e,t){return rr(()=>Li(e,t,void 0,!0)),!0},ownKeys:Fi,getOwnPropertyDescriptor:Ui};function Gi(e){let t=e[An];if(!t){Object.defineProperty(e,An,{value:t=new Proxy(e,Wi)});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=>rr(()=>n.call(t,e)),configurable:!0})}}}}return t}function Ki(e,t){return Gi(Ai(e||{}))}function qi(e,t){rr(()=>t(Ai(e)))}var Ji=Symbol(`store-root`);function Yi(e){return e===`__proto__`||e===`constructor`||e===`prototype`}function Xi(e,t,n,r,i){if(Yi(n))return;let a=t[n];if(e===a)return;let o=Array.isArray(e);if(n!==Ji&&(!ki(e)||!ki(a)||o!==Array.isArray(a)||i&&e[i]!==a[i])){Li(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++)Xi(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++)Li(a,n,e[n]);for(;n<e.length;n++)Li(a,n,f[n]),Xi(e[n],a,n,r,i);a.length>e.length&&Li(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?(Li(a,n,f[n]),Xi(e[n],a,n,r,i)):Li(a,n,e[n])}else for(let t=0,n=e.length;t<n;t++)Xi(e[t],a,t,r,i);a.length>e.length&&Li(a,`length`,e.length);return}let s=Object.keys(e);for(let t=0,n=s.length;t<n;t++)Yi(s[t])||Xi(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&&Li(a,c[t],void 0)}function Zi(e,t={}){let{merge:n,key:r=`id`}=t,i=Ai(e);return e=>{if(!ki(e)||!ki(i))return i;let t=Xi(i,{[Ji]:e},Ji,n,r);return t===void 0?e:t}}var Qi=new WeakMap,$i={get(e,t){if(t===wi)return e;let n=e[t];if(t===An||t===Mn||t===Ti||t===Ei||t===`__proto__`)return n;let r;return ki(n)?Qi.get(n)||(Qi.set(n,r=new Proxy(n,$i)),r):n},set(e,t,n){return Li(e,t,Ai(n)),!0},deleteProperty(e,t){return Li(e,t,void 0,!0),!0}};function ea(e){return t=>{if(ki(t)){let n;(n=Qi.get(t))||Qi.set(t,n=new Proxy(t,$i)),e(n)}return t}}var ta=Object.defineProperty,na=e=>e;function ra(e,t){this[e]=na.bind(null,t)}var ia=(e,t)=>{for(var n in t)ta(e,n,{get:t[n],enumerable:!0,configurable:!0,set:ra.bind(t,n)})},aa={};ia(aa,{SharedEvents:()=>aa,make:()=>oa});function oa(e){let t,n=4096;function r(e){e.connected=void 0,e.controller.abort(),t===e&&(t=void 0)}async function i(t){let n,i={};try{if(t.controller.signal.aborted)return;for(n=e(t.controller.signal,()=>{t.subscribers.forEach(e=>e.activity?.())})[Symbol.asyncIterator]();!t.controller.signal.aborted;){let e=await n.next();if(e.done||t.controller.signal.aborted)break;e.value.type===`server.connected`&&(t.connected=e.value),t.subscribers.forEach(t=>t.push(e.value))}}catch(e){i={error:e}}finally{r(t);try{await n?.return?.()}catch(e){`error`in i||(i={error:e})}t.subscribers.forEach(e=>e.finish(i))}}return{subscribe(e){return{[Symbol.asyncIterator](){let a=[],o=[],s=!1,c,l,u=e?.types?.length?new Set(e.types):void 0,d=e=>!u||e.type===`server.connected`||u.has(e.type);function f(t,n=!0){c=t,n&&(o.length=0),e?.signal?.removeEventListener(`abort`,p),l?.subscribers.delete(ee)&&!l.subscribers.size&&r(l),a.splice(0).forEach(e=>{`error`in t?e.reject(t.error):e.resolve({done:!0,value:void 0})})}function p(){f({})}let ee={activity:e?.onActivity,finish(e){f(e,!1)},push(e){if(c||!d(e))return;let t=a.shift();if(t){t.resolve({done:!1,value:e});return}if(o.length===n){f({error:Error(`Event subscriber exceeded its ${n}-event capacity`)});return}o.push(e)}};function te(){if(c)return;let e=!t;l=t??{controller:new AbortController,subscribers:new Set},t=l,l.subscribers.add(ee),l.connected&&ee.push(l.connected),e&&i(l)}return{next(){let t=o.shift();if(t)return Promise.resolve({done:!1,value:t});if(c)return`error`in c?Promise.reject(c.error):Promise.resolve({done:!0,value:void 0});if(e?.signal?.aborted)return p(),Promise.resolve({done:!0,value:void 0});let n=Promise.withResolvers();return a.push(n),s||(s=!0,e?.signal?.addEventListener(`abort`,p,{once:!0}),te()),n.promise},return(){return f({}),Promise.resolve({done:!0,value:void 0})}}}}}}}var sa=class extends Error{reason;name=`ClientError`;constructor(e,t){let n=t?.detail??(t?.cause instanceof Error?t.cause.message:void 0);super(n?`${e}: ${n}`:e,t),this.reason=e}};ia({},{make:()=>la});var ca=16777216;function la(e){let t=e.fetch??globalThis.fetch,n=(t,n)=>{let r=new URL(e.baseUrl);r.pathname.endsWith(`/`)||(r.pathname+=`/`);let i=new URL(t.path.slice(1),r);for(let[e,n]of Object.entries(t.query??{}))da(i.searchParams,e,n);let a=new Headers(e.headers);for(let[e,n]of Object.entries(t.headers??{}))n!=null&&a.set(e,String(n));for(let[e,t]of new Headers(n?.headers))a.set(e,t);return t.body!==void 0&&!a.has(`content-type`)&&a.set(`content-type`,t.binaryBody?`application/octet-stream`:`application/json`),{url:i,init:{method:t.method,signal:n?.signal,headers:a,body:t.body===void 0?void 0:t.binaryBody?t.body:JSON.stringify(t.body)}}},r=async(e,r)=>{try{let i=n(e,r);return await t(i.url,i.init)}catch(e){throw new sa(`Transport`,{cause:e})}},i=async(e,t)=>{if(t.declaredStatuses.includes(e.status))throw pa(await fa(e));try{await e.body?.cancel()}catch{}throw new sa(`UnexpectedStatus`,{cause:{status:e.status},detail:String(e.status)})},a=async(e,t)=>{let n=await r(e,t);if(n.status!==e.successStatus)return i(n,e);if(e.binary)return new Uint8Array(await n.arrayBuffer());if(e.empty){try{await n.body?.cancel()}catch{}return}return await fa(n)},o=(e,t)=>({async*[Symbol.asyncIterator](){let n=await r(e,t);if(n.status!==e.successStatus&&await i(n,e),!ma(n,`text/event-stream`)){try{await n.body?.cancel()}catch{}throw new sa(`UnsupportedContentType`,{detail:n.headers.get(`content-type`)})}if(n.body===null)throw new sa(`MalformedResponse`);let a=n.body.getReader(),o=new TextDecoder,s=``;try{for(;;){let e;try{e=await a.read()}catch(e){throw new sa(`Transport`,{cause:e})}if(e.done||t?.onActivity?.(),s+=o.decode(e.value,{stream:!e.done}),s.length>ca)throw new sa(`SseEventTooLarge`);let n=!e.done&&s.endsWith(`\r`);n&&(s=s.slice(0,-1)),s=s.replaceAll(`\r
|
|
13
13
|
`,`
|
|
14
14
|
`).replaceAll(`\r`,`
|
|
15
15
|
`),n&&(s+=`\r`),e.done&&s!==``&&(s+=`
|
|
@@ -18,6 +18,6 @@ import{n as e}from"./rolldown-runtime-hePW80VL.js";import{$ as t,$t as n,A as r,
|
|
|
18
18
|
|
|
19
19
|
`);for(;r>=0;){let e=s.slice(0,r);s=s.slice(r+2);let t=e.split(`
|
|
20
20
|
`).flatMap(e=>e.startsWith(`data:`)?[e.slice(5).trimStart()]:[]).join(`
|
|
21
|
-
`);if(t!==``)try{yield JSON.parse(t)}catch(e){throw new
|
|
21
|
+
`);if(t!==``)try{yield JSON.parse(t)}catch(e){throw new sa(`MalformedResponse`,{cause:e})}r=s.indexOf(`
|
|
22
22
|
|
|
23
|
-
`)}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/${la(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 la(e){return e.split(`/`).map(encodeURIComponent).join(`/`)}function ua(e,t,n){if(n!==void 0){if(n===null){e.append(t,`null`);return}if(Array.isArray(n)){for(let r of n)ua(e,t,r);return}if(typeof n==`object`){for(let[r,i]of Object.entries(n))ua(e,`${t}[${r}]`,i);return}e.append(t,String(n))}}async function da(e){if(!pa(e,`application/json`)&&!e.headers.get(`content-type`)?.includes(`+json`)){try{await e.body?.cancel()}catch{}throw new oa(`UnsupportedContentType`,{detail:e.headers.get(`content-type`)})}let t;try{t=await e.text()}catch(e){throw new oa(`Transport`,{cause:e})}if(t===``)throw new oa(`MalformedResponse`);try{return JSON.parse(t)}catch(e){throw new oa(`MalformedResponse`,{cause:e})}}function fa(e){let t=Object.assign(Error(e.message??e.data?.message),e);return e._tag&&(t.name=e._tag),t}function pa(e,t){return e.headers.get(`content-type`)?.split(`;`,1)[0]?.trim().toLowerCase()===t}var ma=e=>typeof e==`object`&&!!e&&`_tag`in e&&e._tag===`InvalidRequestError`,ha=e=>typeof e==`object`&&!!e&&`_tag`in e&&e._tag===`UnauthorizedError`,ga=e=>typeof e==`object`&&!!e&&`_tag`in e&&e._tag===`LocationNotFoundError`,_a=e=>typeof e==`object`&&!!e&&`_tag`in e&&e._tag===`ServiceUnavailableError`,va=e=>typeof e==`object`&&!!e&&`_tag`in e&&e._tag===`AgentNotFoundError`,ya=e=>typeof e==`object`&&!!e&&`_tag`in e&&e._tag===`PluginNotFoundError`,ba=e=>typeof e==`object`&&!!e&&`_tag`in e&&e._tag===`InvalidCursorError`,xa=e=>typeof e==`object`&&!!e&&`_tag`in e&&e._tag===`SessionNotFoundError`,Sa=e=>typeof e==`object`&&!!e&&`_tag`in e&&e._tag===`ConflictError`,Ca=e=>typeof e==`object`&&!!e&&`_tag`in e&&e._tag===`UnknownError`,wa=e=>typeof e==`object`&&!!e&&`_tag`in e&&e._tag===`MessageNotFoundError`,Ta=e=>typeof e==`object`&&!!e&&`_tag`in e&&e._tag===`CommandNotFoundError`,Ea=e=>typeof e==`object`&&!!e&&`_tag`in e&&e._tag===`CommandExecutionError`,Da=e=>typeof e==`object`&&!!e&&`_tag`in e&&e._tag===`SkillNotFoundError`,Oa=e=>typeof e==`object`&&!!e&&`_tag`in e&&e._tag===`SessionBusyError`,ka=e=>typeof e==`object`&&!!e&&`_tag`in e&&e._tag===`InstructionEntryValueTooLargeError`,Aa=e=>typeof e==`object`&&!!e&&`_tag`in e&&e._tag===`FormNotFoundError`,ja=e=>typeof e==`object`&&!!e&&`_tag`in e&&e._tag===`FormInvalidAnswerError`,Ma=e=>typeof e==`object`&&!!e&&`_tag`in e&&e._tag===`FormAlreadySettledError`,Na=e=>typeof e==`object`&&!!e&&`_tag`in e&&e._tag===`ProviderNotFoundError`,Pa=e=>typeof e==`object`&&!!e&&`_tag`in e&&e._tag===`ModelNotFoundError`,Fa=e=>typeof e==`object`&&!!e&&`_tag`in e&&e._tag===`UnsupportedModelError`,Ia=e=>typeof e==`object`&&!!e&&`_tag`in e&&e._tag===`ProviderRequestError`,La=e=>typeof e==`object`&&!!e&&`_tag`in e&&e._tag===`IntegrationNotFoundError`,Ra=e=>typeof e==`object`&&!!e&&`_tag`in e&&e._tag===`IntegrationAttemptNotFoundError`,za=e=>typeof e==`object`&&!!e&&`_tag`in e&&e._tag===`IntegrationMethodNotFoundError`,Ba=e=>typeof e==`object`&&!!e&&`_tag`in e&&e._tag===`McpServerNotFoundError`,Va=e=>typeof e==`object`&&!!e&&`_tag`in e&&e._tag===`ForbiddenError`,Ha=e=>typeof e==`object`&&!!e&&`_tag`in e&&e._tag===`ProjectNotFoundError`,Ua=e=>typeof e==`object`&&!!e&&`_tag`in e&&e._tag===`PermissionSavedNotFoundError`,Wa=e=>typeof e==`object`&&!!e&&`_tag`in e&&e._tag===`PermissionNotFoundError`,Ga=e=>typeof e==`object`&&!!e&&`_tag`in e&&e._tag===`FileNotFoundError`,Ka=e=>typeof e==`object`&&!!e&&`_tag`in e&&e._tag===`RpcError`,qa=e=>typeof e==`object`&&!!e&&`_tag`in e&&e._tag===`RpcInternalError`,Ja=e=>typeof e==`object`&&!!e&&`_tag`in e&&e._tag===`PtyNotFoundError`,Ya=e=>typeof e==`object`&&!!e&&`_tag`in e&&e._tag===`ShellNotFoundError`,Xa=e=>typeof e==`object`&&!!e&&`_tag`in e&&e._tag===`WorktreeError`,Za=e=>typeof e==`object`&&!!e&&`_tag`in e&&e._tag===`VcsInitNotSupportedError`;function Qa(e,t){return n=>{let r=(e,r)=>{if(!Object.hasOwn(n.events,e))throw Error(`Unknown RPC event: ${n.id}.${e}`);let i=$a(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!Ka(e)&&!qa(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 $a(e,t){return`rpc.${e.id}.${t}`}var eo={};ra(eo,{OpenCode:()=>eo,make:()=>to});function to(e){let t=ca(e),n=aa((e,n)=>t.event.subscribe(void 0,{signal:e,onActivity:n}));return{...t,rpc:Object.assign(Qa(t,n),t.rpc),event:n}}var no=e({ClientError:()=>oa,OpenCode:()=>eo,isAgentNotFoundError:()=>va,isCommandExecutionError:()=>Ea,isCommandNotFoundError:()=>Ta,isConflictError:()=>Sa,isFileNotFoundError:()=>Ga,isForbiddenError:()=>Va,isFormAlreadySettledError:()=>Ma,isFormInvalidAnswerError:()=>ja,isFormNotFoundError:()=>Aa,isInstructionEntryValueTooLargeError:()=>ka,isIntegrationAttemptNotFoundError:()=>Ra,isIntegrationMethodNotFoundError:()=>za,isIntegrationNotFoundError:()=>La,isInvalidCursorError:()=>ba,isInvalidRequestError:()=>ma,isLocationNotFoundError:()=>ga,isMcpServerNotFoundError:()=>Ba,isMessageNotFoundError:()=>wa,isModelNotFoundError:()=>Pa,isPermissionNotFoundError:()=>Wa,isPermissionSavedNotFoundError:()=>Ua,isPluginNotFoundError:()=>ya,isProjectNotFoundError:()=>Ha,isProviderNotFoundError:()=>Na,isProviderRequestError:()=>Ia,isPtyNotFoundError:()=>Ja,isRpcError:()=>Ka,isRpcInternalError:()=>qa,isServiceUnavailableError:()=>_a,isSessionBusyError:()=>Oa,isSessionNotFoundError:()=>xa,isShellNotFoundError:()=>Ya,isSkillNotFoundError:()=>Da,isUnauthorizedError:()=>ha,isUnknownError:()=>Ca,isUnsupportedModelError:()=>Fa,isVcsInitNotSupportedError:()=>Za,isWorktreeError:()=>Xa}),ro=class extends t()(`ClientError`,{cause:ue()}){},R=a.check(ze(0)),z=a.check(Mt(0)),io=y.pipe(A(`RelativePath`),D({identifier:`RelativePath`})),ao=y.pipe(A(`AbsolutePath`),D({identifier:`AbsolutePath`})),B=e=>fe(e).pipe(wt(w(Ft(e)),{decode:le({strict:!1}),encode:se(jt(e=>e!==void 0))})),oo=(e,t)=>Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)),so=e=>t=>oo(t,e(t)),co=N.pipe(wt(ie,{decode:_t(e=>je(e)),encode:_t(e=>_e(e))})),lo=`0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz`,uo=0,fo=0;function po(){return ho(!1)}function mo(){return ho(!0)}function ho(e,t=Date.now()){t!==uo&&(uo=t,fo=0),fo++;let n=BigInt(t)*4096n+BigInt(fo),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=>lo[e%62]).join(``)}var go=y.pipe(A(`Project.ID`),D({identifier:`Project.ID`}),so(e=>({global:e.make(`global`)}))),_o=y.check(at(`wrk`)).pipe(A(`Workspace.ID`),D({identifier:`Workspace.ID`}),so(e=>{let t=()=>e.make(`wrk_`+po());return{ascending:n=>n?e.make(n):t(),create:t}})),vo=e({Info:()=>xo,Location:()=>vo,PublicInfo:()=>So,PublicRef:()=>bo,Ref:()=>yo,response:()=>V}),yo=x({directory:ao,workspaceID:B(_o)}).annotate({identifier:`Location.Ref`}),bo=x(re(yo.fields,[`workspaceID`])).annotate({identifier:`Location.PublicRef`}),xo=class extends p(`Location.Info`)({directory:ao,workspaceID:B(_o),project:x({id:go,directory:ao,canonical:ao})}){},So=x(re(xo.fields,[`workspaceID`])).annotate({identifier:`Location.PublicInfo`});function V(e){return x({location:bo,data:e})}var Co=e({Event:()=>Co,ID:()=>wo,Seq:()=>To,Version:()=>Eo,durable:()=>H,durableMap:()=>Ao,ephemeral:()=>U,inventory:()=>W,latest:()=>Oo,versionedType:()=>ko}),wo=y.check(at(`evt_`)).pipe(A(`Event.ID`),D({identifier:`Event.ID`}),so(e=>({create:()=>e.make(`evt_`+po())}))),To=a.check(Mt(0)).pipe(A(`Event.Seq`),D({identifier:`Event.Seq`})),Eo=a.check(Mt(1)).pipe(A(`Event.Version`),D({identifier:`Event.Version`})),Do=x({aggregateID:y,seq:To,version:Eo});function H(e){let t=x(e.schema),n=x({aggregateID:Do.fields.aggregateID,seq:Do.fields.seq,version:m(e.durable.version).pipe(wt(Ft(Eo),ne({decode:()=>Eo.make(e.durable.version),encode:()=>e.durable.version})))});return x({id:wo,created:N,metadata:B(b(y,Ie)),type:m(e.type),durable:n,location:B(yo),data:t}).annotate({identifier:e.identifier??e.type}).pipe(so(()=>({type:e.type,durability:`durable`,durable:e.durable,data:t})))}function U(e){let t=x(e.schema);return x({id:wo,created:N,metadata:B(b(y,Ie)),type:m(e.type),location:B(yo),data:t}).annotate({identifier:e.identifier??e.type}).pipe(so(()=>({type:e.type,durability:`ephemeral`,durable:void 0,data:t})))}function W(...e){return Object.freeze(e)}function Oo(e){return jo(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 ko(e,t){return`${e}.${t}`}function Ao(e){return jo(e.reduce((e,t)=>{if(t.durability!==`durable`)return e;let n=ko(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 jo(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 Mo=e({DirectorySource:()=>Fo,EmbeddedSource:()=>Bo,Event:()=>zo,ID:()=>No,Info:()=>Lo,Name:()=>Po,Skill:()=>Mo,Source:()=>Vo,UrlSource:()=>Io}),No=y.pipe(A(`Skill.ID`),D({identifier:`Skill.ID`})),Po=y.pipe(A(`Skill.Name`),D({identifier:`Skill.Name`})),Fo=x({type:_(`directory`),path:ao}).annotate({identifier:`Skill.DirectorySource`}),Io=x({type:_(`url`),url:y}).annotate({identifier:`Skill.UrlSource`}),Lo=x({id:No,name:Po,description:y.pipe(B),autoinvoke:g.pipe(B),path:ao,content:y}).annotate({identifier:`Skill.Info`}),Ro=U({type:`skill.updated`,schema:{}}),zo={Updated:Ro,Definitions:W(Ro)},Bo=x({type:_(`embedded`),skill:pe(()=>Lo)}).annotate({identifier:`Skill.EmbeddedSource`}),Vo=Object.assign(C([Fo,Io,Bo]).pipe(ye(`type`),D({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}`}),Ho=class extends t()(`LocationNotFoundError`,{location:bo,message:y},{httpApiStatus:404}){},Uo=class extends t()(`InvalidRequestError`,{message:y,kind:w(y),field:w(y)},{httpApiStatus:400}){},Wo=class extends t()(`RpcError`,{type:y,message:y,data:w(Ie)},{httpApiStatus:400}){},Go=class extends t()(`RpcInternalError`,{type:v([`rpc.internal`,`rpc.invalid_output`]),message:y,data:w(Ie)},{httpApiStatus:500}){},Ko=class extends t()(`UnauthorizedError`,{message:y},{httpApiStatus:401}){},qo=class extends t()(`ConflictError`,{message:y,resource:w(y)},{httpApiStatus:409}){},Jo=class extends t()(`SessionBusyError`,{sessionID:y,message:y},{httpApiStatus:409}){},Yo=class extends t()(`ServiceUnavailableError`,{message:y,service:w(y)},{httpApiStatus:503}){},Xo=class extends t()(`UnknownError`,{message:y,ref:w(y)},{httpApiStatus:500}){},Zo=class extends t()(`ProviderNotFoundError`,{providerID:y,message:y},{httpApiStatus:404}){},Qo=class extends t()(`IntegrationNotFoundError`,{integrationID:y,message:y},{httpApiStatus:404}){},$o=class extends t()(`IntegrationAttemptNotFoundError`,{integrationID:y,attemptID:y,message:y},{httpApiStatus:404}){},es=class extends t()(`IntegrationMethodNotFoundError`,{integrationID:y,methodID:y,message:y},{httpApiStatus:404}){},ts=class extends t()(`ProjectNotFoundError`,{projectID:y,message:y},{httpApiStatus:404}){},ns=class extends t()(`FileNotFoundError`,{path:y,message:y},{httpApiStatus:404}){},rs=class extends t()(`PluginNotFoundError`,{pluginID:y,message:y},{httpApiStatus:404}){},is=class extends t()(`AgentNotFoundError`,{agentID:y,message:y},{httpApiStatus:404}){},G=class extends t()(`SessionNotFoundError`,{sessionID:y,message:y},{httpApiStatus:404}){},as=class extends t()(`MessageNotFoundError`,{sessionID:y,messageID:y,message:y},{httpApiStatus:404}){},os=class extends t()(`SkillNotFoundError`,{skill:No,message:y},{httpApiStatus:404}){},ss=class extends t()(`McpServerNotFoundError`,{server:y,message:y},{httpApiStatus:404}){},cs=class extends t()(`CommandNotFoundError`,{command:y,message:y},{httpApiStatus:404}){},ls=class extends t()(`CommandExecutionError`,{command:y,message:y},{httpApiStatus:500}){},us=class extends t()(`InvalidCursorError`,{message:y},{httpApiStatus:400}){},ds=class extends t()(`PermissionNotFoundError`,{requestID:y,message:y},{httpApiStatus:404}){},fs=class extends t()(`PermissionSavedNotFoundError`,{id:y,message:y},{httpApiStatus:404}){},ps=class extends t()(`FormNotFoundError`,{id:y,message:y},{httpApiStatus:404}){},ms=class extends t()(`FormAlreadySettledError`,{id:y,message:y},{httpApiStatus:409}){},hs=class extends t()(`FormInvalidAnswerError`,{id:y,message:y},{httpApiStatus:400}){},gs=class extends t()(`ForbiddenError`,{message:y},{httpApiStatus:403}){},_s=class extends t()(`PtyNotFoundError`,{ptyID:y,message:y},{httpApiStatus:404}){},vs=class extends t()(`ShellNotFoundError`,{id:y,message:y},{httpApiStatus:404}){},ys=class extends t()(`ModelNotFoundError`,{providerID:y,modelID:y,message:y},{httpApiStatus:404}){},bs=class extends t()(`UnsupportedModelError`,{providerID:y,modelID:y,capability:y,message:y},{httpApiStatus:422}){},xs=class extends t()(`ProviderRequestError`,{providerID:y,reason:v([`authentication`,`rate_limit`,`content_filter`,`invalid_request`,`overloaded`,`provider`]),message:y,status:w(a),retryAfterMs:w(a)},{httpApiStatus:502}){},Ss=class extends tt()(`@opencode/HttpApiSchemaError`,{error:Uo}){},Cs=y.pipe(A(`Integration.ID`),D({identifier:`Integration.ID`})),ws=y.pipe(A(`Integration.MethodID`),D({identifier:`Integration.MethodID`})),Ts=e({CreateInput:()=>Fs,Credential:()=>Ts,Entry:()=>Ps,Event:()=>ks,External:()=>Ms,ID:()=>Es,Key:()=>js,OAuth:()=>As,Value:()=>Ns}),Es=y.pipe(A(`Credential.ID`),D({identifier:`Credential.ID`}),so(e=>({create:()=>e.make(`cred_`+po())}))),Ds=U({type:`credential.updated`,schema:{}}),Os=U({type:`credential.switched`,schema:{integrationID:Cs,credentialID:ce(Es)}}),ks={Updated:Ds,Switched:Os,Definitions:W(Ds,Os)},As=x({type:m(`oauth`),methodID:ws,refresh:y,access:y,expires:z,metadata:B(b(y,Ie))}).annotate({identifier:`Credential.OAuth`}),js=x({type:m(`key`),key:y,metadata:B(b(y,Ie))}).annotate({identifier:`Credential.Key`}),Ms=x({type:m(`external`),methodID:ws,metadata:B(b(y,Ie))}).annotate({identifier:`Credential.External`}),Ns=C([As,js,Ms]).pipe(ye(`type`)).annotate({identifier:`Credential.Value`}),Ps=x({id:Es,integrationID:Cs,label:y,active:g,value:Ns}).annotate({identifier:`Credential.Entry`}),Fs=x({id:B(Es),integrationID:Cs,label:B(y),value:Ns,activate:B(g)}).annotate({identifier:`Credential.CreateInput`}),Is=x({status:v([`needs_auth`]),message:y,url:B(y)}).annotate({identifier:`Connection.Status`}),Ls=x({type:m(`credential`),id:Es,label:y,method:v([`key`,`oauth`,`external`]),status:B(Is)}).annotate({identifier:`Connection.CredentialInfo`}),Rs=x({type:m(`env`),name:y,status:B(Is)}).annotate({identifier:`Connection.EnvInfo`}),zs=C([Ls,Rs]).pipe(ye(`type`)).annotate({identifier:`Connection.Info`}),Bs=e({Answer:()=>rc,BooleanField:()=>Ys,Detail:()=>ac,Event:()=>uc,ExternalField:()=>Zs,Field:()=>Qs,Fields:()=>$s,Form:()=>Bs,ID:()=>Vs,Info:()=>tc,IntegerField:()=>Js,Metadata:()=>Hs,MultiselectField:()=>Xs,NumberField:()=>qs,Option:()=>Us,Reply:()=>oc,State:()=>ic,StringField:()=>Ks,Value:()=>nc,When:()=>Ws}),Vs=y.check(at(`frm_`)).pipe(A(`Form.ID`),D({identifier:`Form.ID`})).pipe(so(e=>({create:t=>e.make(t??`frm_`+po())}))),Hs=b(y,Ie).annotate({identifier:`Form.Metadata`}),Us=x({value:y,label:y,description:y.pipe(B)}).annotate({identifier:`Form.Option`}),Ws=x({key:y,op:v([`eq`,`neq`]),value:C([y,gt,g])}).annotate({identifier:`Form.When`}),Gs={key:y,title:y.pipe(B),description:y.pipe(B),required:g.pipe(B),hidden:g.pipe(B).annotate({description:`Skip the interactive authentication prompt and use the default unless an answer is supplied`}),when:h(Ws).pipe(B)},Ks=x({...Gs,type:m(`string`),format:v([`email`,`uri`,`date`,`date-time`]).pipe(B),minLength:z.pipe(B),maxLength:z.pipe(B),pattern:y.pipe(B),placeholder:y.pipe(B),default:y.pipe(B),options:h(Us).pipe(B),custom:g.pipe(B)}).annotate({identifier:`Form.StringField`}),qs=x({...Gs,type:m(`number`),minimum:gt.pipe(B),maximum:gt.pipe(B),default:gt.pipe(B)}).annotate({identifier:`Form.NumberField`}),Js=x({...Gs,type:m(`integer`),minimum:gt.pipe(B),maximum:gt.pipe(B),default:gt.pipe(B)}).annotate({identifier:`Form.IntegerField`}),Ys=x({...Gs,type:m(`boolean`),default:g.pipe(B)}).annotate({identifier:`Form.BooleanField`}),Xs=x({...Gs,type:m(`multiselect`),options:h(Us),minItems:z.pipe(B),maxItems:z.pipe(B),custom:g.pipe(B),default:h(y).pipe(B)}).annotate({identifier:`Form.MultiselectField`}),Zs=x({key:y,type:m(`external`),url:y,title:y.pipe(B),description:y.pipe(B)}).annotate({identifier:`Form.ExternalField`}),Qs=C([Ks,qs,Js,Ys,Xs,Zs]).pipe(ye(`type`),D({identifier:`Form.Field`})),$s=De(Qs).annotate({identifier:`Form.Fields`}),ec={id:Vs,sessionID:y,title:y,metadata:Hs.pipe(B)},tc=x({...ec,fields:$s}).annotate({identifier:`Form.Info`}),nc=C([y,gt,g,h(y)]).annotate({identifier:`Form.Value`}),rc=b(y,nc).annotate({identifier:`Form.Answer`}),ic=C([x({status:m(`pending`)}),x({status:m(`answered`),answer:rc}),x({status:m(`cancelled`),message:y.pipe(B)})]).pipe(ye(`status`)).annotate({identifier:`Form.State`}),ac=x({...tc.fields,state:ic}).annotate({identifier:`Form.Detail`}),oc=x({answer:rc}).annotate({identifier:`Form.Reply`}),sc=U({type:`form.created`,schema:{form:tc}}),cc=U({type:`form.replied`,schema:{id:Vs,sessionID:y,answer:rc}}),lc=U({type:`form.cancelled`,schema:{id:Vs,sessionID:y}}),uc={Created:sc,Replied:cc,Cancelled:lc,Definitions:W(sc,cc,lc)},dc=e({Attempt:()=>Ec,AttemptID:()=>wc,AttemptStatus:()=>Dc,CommandAttempt:()=>Oc,CommandAttemptStatus:()=>kc,CommandMethod:()=>hc,EnvMethod:()=>vc,Event:()=>xc,ExternalMethod:()=>_c,ID:()=>fc,Info:()=>Cc,Integration:()=>dc,KeyMethod:()=>gc,Method:()=>yc,MethodID:()=>pc,OAuthMethod:()=>mc,Ref:()=>Sc}),fc=Cs,pc=ws,mc=x({id:pc,type:m(`oauth`),label:y,form:B($s)}).annotate({identifier:`Integration.OAuthMethod`}),hc=x({id:pc,type:m(`command`),label:y,command:h(y)}).annotate({identifier:`Integration.CommandMethod`}),gc=x({type:m(`key`),label:B(y),form:B($s)}).annotate({identifier:`Integration.KeyMethod`}),_c=x({id:pc,type:m(`external`),label:y,form:B($s)}).annotate({identifier:`Integration.ExternalMethod`}),vc=x({type:m(`env`),names:h(y)}).annotate({identifier:`Integration.EnvMethod`}),yc=C([mc,hc,gc,_c,vc]).pipe(ye(`type`)).annotate({identifier:`Integration.Method`}),bc=U({type:`integration.updated`,schema:{}}),xc={Updated:bc,Definitions:W(bc)},Sc=x({id:fc,name:y,metadata:B(b(y,rt))}).annotate({identifier:`Integration.Ref`}),Cc=x({id:fc,name:y,metadata:B(b(y,rt)),methods:h(yc),connections:h(zs)}).annotate({identifier:`Integration.Info`}),wc=y.pipe(A(`Integration.AttemptID`),D({identifier:`Integration.AttemptID`}),so(e=>({create:()=>e.make(`con_`+po())}))),Tc=x({created:gt,expires:gt}),Ec=class extends p(`Integration.Attempt`)({attemptID:wc,url:y,instructions:y,mode:v([`auto`,`code`]),time:Tc}){},Dc=C([x({status:m(`pending`),time:Tc}),x({status:m(`complete`),time:Tc}),x({status:m(`failed`),message:y,time:Tc}),x({status:m(`expired`),time:Tc})]).pipe(ye(`status`)).annotate({identifier:`Integration.AttemptStatus`}),Oc=x({attemptID:wc,time:Tc}).annotate({identifier:`Integration.CommandAttempt`}),kc=C([x({status:m(`pending`),message:B(y),time:Tc}),x({status:m(`complete`),time:Tc}),x({status:m(`failed`),message:y,time:Tc}),x({status:m(`expired`),time:Tc})]).pipe(ye(`status`)).annotate({identifier:`Integration.CommandAttemptStatus`}),Ac=C([v([`reasoning`,`reasoning_content`,`reasoning_text`]),y]).annotate({identifier:`Model.ReasoningField`}),jc=v([`max_completion_tokens`,`max_tokens`]).annotate({identifier:`Model.MaxTokensField`}),Mc=v([`assets`,`state`,`root`]).annotate({identifier:`Model.MediaInput`}),Nc=v([`anthropic`,`alibaba`]).annotate({identifier:`Model.CacheFormat`}),Pc=x({reasoningField:Ac.pipe(B),requireReasoning:g.pipe(B),maxTokensField:jc.pipe(B),requireFinishReason:g.pipe(B),requireAssistantAfterTool:g.pipe(B),supportsPromptCacheKey:g.pipe(B),streamUsage:g.pipe(B),cacheFormat:Nc.pipe(B),supportsThinkingBlockBinding:g.pipe(B),supportsEffortUpdates:g.pipe(B),mediaInput:Mc.pipe(B)}).annotate({identifier:`Model.Compatibility`}),Fc=x(re(Pc.fields,[`supportsThinkingBlockBinding`,`supportsEffortUpdates`])).annotate({identifier:`Provider.Compatibility`}),Ic=e({Activation:()=>Vc,Cache:()=>Gc,CacheTTL:()=>Wc,Compaction:()=>Hc,Encoding:()=>Kc,Event:()=>zc,ID:()=>Lc,Info:()=>Zc,Overlays:()=>Yc,Package:()=>Bc,Provider:()=>Ic,Request:()=>Xc,Settings:()=>Jc,Transport:()=>Uc}),Lc=y.pipe(A(`Provider.ID`),D({identifier:`Provider.ID`}),so(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`)}))),Rc=U({type:`provider.updated`,schema:{}}),zc={Updated:Rc,Definitions:W(Rc)},Bc=y,Vc=v([`auto`,`enabled`,`disabled`]),Hc=C([x({type:m(`summary`)}),x({type:m(`native`)})]).pipe(ye(`type`)).annotate({identifier:`Provider.Compaction`}),Uc=v([`http`,`websocket`]).annotate({identifier:`Provider.Transport`}),Wc=Ke([gt,v([`ms`,`s`,`m`,`h`,`d`])]).check(f(/^\d+(ms|s|m|h|d)$/)).annotate({identifier:`Provider.CacheTTL`}),Gc=x({ttl:Wc.pipe(B)}).annotate({identifier:`Provider.Cache`}),Kc=v([`zstd`,`gzip`,`none`]).annotate({identifier:`Provider.Encoding`}),qc=C([N,m(!1)]).pipe(B),Jc=ge(x({timeout:qc,headerTimeout:qc,chunkTimeout:qc,compaction:Hc.pipe(B),cache:Gc.pipe(B),transport:Uc.pipe(B),encoding:Kc.pipe(B)}),[b(y,rt)]).annotate({identifier:`Provider.Settings`}),Yc={settings:Jc.pipe(B),headers:b(y,y).pipe(B),body:b(y,rt).pipe(B)},Xc=x({settings:Jc.pipe(o(ht({}))),headers:b(y,y),body:b(y,rt)}).annotate({identifier:`Provider.Request`}),Zc=x({id:Lc,canonical:Lc.pipe(B),integrationID:fc.pipe(B),name:y,activation:Vc,package:Bc,compatibility:Fc.pipe(B),...Yc}).annotate({identifier:`Provider.Info`}).pipe(so(()=>({empty:e=>({id:e,name:e,activation:`auto`,package:``})}))),Qc=N.pipe(A(`Money.USD`),D({identifier:`Money.USD`}),so(e=>({zero:e.make(0)}))),$c=N.pipe(A(`Money.USDPerMillionTokens`),D({identifier:`Money.USDPerMillionTokens`}),so(e=>({zero:e.make(0)}))),el=e({Capabilities:()=>ul,Compatibility:()=>Pc,Cost:()=>dl,Event:()=>rl,Family:()=>ol,ID:()=>tl,Info:()=>pl,MaxTokensField:()=>jc,MediaInput:()=>Mc,Model:()=>el,Overlays:()=>ll,ReasoningField:()=>Ac,Ref:()=>al,Settings:()=>cl,Type:()=>sl,Variant:()=>fl,VariantID:()=>il}),tl=y.pipe(A(`Model.ID`)),nl=U({type:`model.updated`,schema:{}}),rl={Updated:nl,Definitions:W(nl)},il=y.pipe(A(`Model.VariantID`)),al=x({id:tl,providerID:Lc,variant:il.pipe(B)}).annotate({identifier:`Model.Ref`}).pipe(so(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:Lc.make(r),id:tl.make(a),...o?{variant:il.make(o)}:{}})}}))),ol=y.pipe(A(`Model.Family`)),sl=C([v([`chat`,`decision`,`image`]),y]).annotate({identifier:`Model.Type`}),cl=ge(x(we(Jc.schema.fields,[`compaction`,`cache`,`encoding`])),[b(y,rt)]).annotate({identifier:`Model.Settings`}),ll={settings:cl.pipe(B),headers:b(y,y).pipe(B),body:b(y,rt).pipe(B)},ul=x({tools:g,input:h(y),output:h(y),temperature:g.pipe(B)}).annotate({identifier:`Model.Capabilities`}).pipe(so(()=>({default:()=>({tools:!0,input:[`text`,`image`],output:[`text`]})}))),dl=x({tier:x({type:_(`context`),size:a}).pipe(B),input:$c,output:$c,cache:x({read:$c,write:$c})}).annotate({identifier:`Model.Cost`}),fl=x({id:il,...ll}).annotate({identifier:`Model.Variant`}),pl=x({id:tl,modelID:tl,providerID:Lc,canonical:Lc.pipe(B),type:sl.pipe(B),family:ol.pipe(B),name:y,compatibility:Pc.pipe(B),package:Bc.pipe(B),...ll,capabilities:ul,variants:h(fl),time:x({released:N}),cost:h(dl),status:v([`alpha`,`beta`,`deprecated`,`active`]),enabled:g,limit:x({context:a,input:a.pipe(B),output:a})}).annotate({identifier:`Model.Info`}).pipe(so(()=>({default:(e,t)=>({id:t,modelID:t,providerID:e,name:t,capabilities:ul.default(),variants:[],time:{released:0},cost:[],status:`active`,enabled:!0,limit:{context:2e5,output:32e3}})}))),ml=x({start:N,end:N,text:y}).annotate({identifier:`Prompt.Mention`}),hl=C([x({type:m(`inline`)}),x({type:m(`uri`),uri:y})]).pipe(ye(`type`)).annotate({identifier:`Prompt.FileSource`}),gl=y.check(i(e=>e.length%4==0&&/^[A-Za-z0-9+/]*={0,2}$/u.test(e),f(/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/u).annotations)).annotate({identifier:`Prompt.Base64`}),_l=x({data:gl,mime:y,source:hl,name:y.pipe(B),description:y.pipe(B),mention:ml.pipe(B)}).annotate({identifier:`Prompt.FileAttachment`}).pipe(so(e=>({create:t=>e.make({data:t.data,mime:t.mime,source:t.source,name:t.name,description:t.description,mention:t.mention})}))),vl=y.check(f(/^media:[0-9a-f]{64}$/)).annotate({identifier:`Prompt.MediaRef`}),{data:yl,...bl}=_l.fields,xl=x({...bl,uri:vl,bytes:a.pipe(B),width:a.pipe(B),height:a.pipe(B)}).annotate({identifier:`Prompt.MediaFileAttachment`}),Sl=C([_l,xl]).annotate({identifier:`Prompt.Attachment`}),Cl=x({name:y,mention:ml.pipe(B)}).annotate({identifier:`Prompt.AgentAttachment`}),wl=x({id:No,name:Po,text:y.pipe(B),mention:ml.pipe(B)}).annotate({identifier:`Prompt.SkillAttachment`}),Tl=x({text:y,files:h(_l).pipe(B),agents:h(Cl).pipe(B),skills:h(wl).pipe(B)}).annotate({identifier:`Prompt`}).pipe(so(e=>({equivalence:ae(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}})}))),El=e=>({description:e}),Dl=x({data:gl,mime:y,name:y.pipe(B)}).annotate({identifier:`Generate.File`}),Ol=x({input:N.pipe(B),output:N.pipe(B)}).annotate({identifier:`Generate.Usage`,description:`Token counts, when the provider reports them`}),kl=b(y,Ie).annotate({identifier:`Generate.Native`,description:`Provider-specific data the shared fields do not cover`}),Al=Ke([gt,`:`,gt]).check(f(/^\d+(?:\.\d+)?:\d+(?:\.\d+)?$/)).annotate({identifier:`Generate.ImageAspect`,description:`Aspect ratio as width:height, for example 16:9`}),jl=C([v([`1K`,`2K`,`4K`]),y]).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`}),Ml=x({model:al,prompt:y,images:h(Dl).pipe(B).annotate(El(`Edit sources or style and subject references, in order`)),n:R.pipe(B).annotate(El(`Number of images to generate; defaults to 1`)),aspect:Al.pipe(B),resolution:jl.pipe(B)}).annotate({identifier:`Generate.ImageRequest`}),Nl=x({type:m(`image`),...Dl.fields}).annotate({identifier:`Generate.ImageOutput`}),Pl=x({images:h(Nl),cost:Qc.pipe(B),tokens:Ol.pipe(B),native:kl.pipe(B)}).annotate({identifier:`Generate.ImageResult`}),Fl=x({type:m(`text`),text:y}).annotate({identifier:`Generate.DecisionTextPart`}),Il=x({type:m(`json`),value:Te}).annotate({identifier:`Generate.DecisionJsonPart`}),Ll=x({type:m(`file`),...Dl.fields}).annotate({identifier:`Generate.DecisionFilePart`}),Rl=C([Fl,Il,Ll]).annotate({identifier:`Generate.DecisionPart`}),zl=C([y,g]).annotate({identifier:`Generate.ChoiceValue`,description:`Choice values are typed: true and "true" are different values`}),Bl=y.annotate(El(`Unique within the request; echoed on the matching answer`)),Vl=x({type:m(`predicate`),name:Bl,instructions:y}).annotate({identifier:`Generate.PredicateQuestion`,description:`The probability that a statement is true`}),Hl=x({type:m(`choice`),name:Bl,instructions:y,choices:h(x({value:zl,description:y.pipe(B)})).check(kt(1))}).annotate({identifier:`Generate.ChoiceQuestion`,description:`Pick one value from a fixed set`}),Ul=x({type:m(`score`),name:Bl,instructions:y,levels:h(x({label:y,description:y.pipe(B)})).check(kt(1))}).annotate({identifier:`Generate.ScoreQuestion`,description:`Place the input on ordered levels, lowest first`}),Wl=C([Vl,Hl,Ul]).annotate({identifier:`Generate.DecisionQuestion`}),Gl=x({model:al,input:h(Rl).annotate(El(`The evidence every question is asked about, in order`)),questions:h(Wl).check(kt(1)).annotate(El(`Question names must be unique; duplicates fail with InvalidRequestError`))}).annotate({identifier:`Generate.DecisionRequest`}),Kl=N.check(Pt({minimum:0,maximum:1})),ql=x({type:m(`predicate`),name:y,probability:Kl}).annotate({identifier:`Generate.PredicateAnswer`}),Jl=x({type:m(`choice`),name:y,choice:zl,probabilities:h(x({value:zl,probability:Kl})),confidence:Kl}).annotate({identifier:`Generate.ChoiceAnswer`}),Yl=x({type:m(`score`),name:y,score:N.annotate(El(`Probability-weighted level index, so it can fall between levels`)),probabilities:h(x({value:a,label:y,probability:Kl})),confidence:Kl}).annotate({identifier:`Generate.ScoreAnswer`}),Xl=x({type:m(`error`),name:y,reason:y.annotate(El(`Why the question has no answer, for example refusal`)),message:y.pipe(B)}).annotate({identifier:`Generate.ErrorAnswer`,description:`This one question has no answer; the other answers still came back`}),Zl=C([ql,Jl,Yl,Xl]).annotate({identifier:`Generate.DecisionAnswer`}),Ql=x({answers:h(Zl).annotate(El(`One answer per question, in question order`)),cost:Qc.pipe(B),tokens:Ol.pipe(B),native:kl.pipe(B)}).annotate({identifier:`Generate.DecisionResult`}),$l=[Uo,Zo,ys,bs,xs,Yo,Ho],eu={payload:x({prompt:y,model:al.pipe(w)}),success:x({data:x({text:y})}).annotate({identifier:`GenerateTextResponse`}),error:$l},tu=j(`server.generate`).add(T(`generate.text`,`/api/experimental/generate/text`,eu).annotateMerge(O({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(T(`generate.textLegacy`,`/api/experimental/generate`,eu).annotateMerge(O({identifier:`experimental.generate.textLegacy`,summary:`Generate text (deprecated path)`,description:`Deprecated alias of POST /api/experimental/generate/text.`,deprecated:!0}))).add(T(`generate.image`,`/api/experimental/generate/image`,{payload:Ml,success:x({data:Pl}).annotate({identifier:`GenerateImageResponse`}),error:$l}).annotateMerge(O({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(T(`generate.decisions`,`/api/experimental/generate/decisions`,{payload:Gl,success:x({data:Ql}).annotate({identifier:`GenerateDecisionsResponse`}),error:$l}).annotateMerge(O({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(O({title:`generate`,description:`Experimental one-shot generation routes.`})),nu=y.check(f(/^[0-9a-f]{64}$/u)).annotate({identifier:`MediaHash`}),ru=k(`media.get`,`/api/experimental/media/:hash`,{params:{hash:nu},success:dt.pipe(mt()),error:[ns,Uo]}).annotateMerge(O({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`]})})),iu=e({CreateInput:()=>fu,Event:()=>du,ID:()=>au,Info:()=>ou,Pty:()=>iu,UpdateInput:()=>pu}),au=y.check(at(`pty`)).pipe(A(`PtyID`),D({identifier:`Pty.ID`})).pipe(so(e=>{let t=()=>e.make(`pty_`+po());return{create:t,ascending:n=>n===void 0?t():e.make(n)}})),ou=x({id:au,title:y,command:y,args:h(y),cwd:y,status:v([`running`,`exited`]),pid:z,exitCode:B(z)}).annotate({identifier:`Pty`}),su=U({type:`pty.created`,schema:{info:ou}}),cu=U({type:`pty.updated`,schema:{info:ou}}),lu=U({type:`pty.exited`,schema:{id:au,exitCode:z}}),uu=U({type:`pty.deleted`,schema:{id:au}}),du={Created:su,Updated:cu,Exited:lu,Deleted:uu,Definitions:W(su,cu,lu,uu)},fu=x({command:B(y),args:B(h(y)),cwd:B(y),title:B(y),env:B(b(y,y))}),pu=x({title:B(y),size:B(x({rows:R,cols:R}))}),mu=y.check(at(`ses`)).pipe(A(`SessionID`),D({identifier:`Session.ID`}),so(e=>({create:()=>e.make(`ses_`+mo())}))),hu=e({Effect:()=>wu,Event:()=>Cu,ID:()=>gu,Permission:()=>hu,Reply:()=>bu,Request:()=>yu,Rule:()=>Tu,Ruleset:()=>Eu,Source:()=>_u}),gu=y.check(at(`per`)).pipe(A(`Permission.ID`),D({identifier:`Permission.ID`}),so(e=>({create:t=>e.make(t??`per_`+po())}))),_u=C([x({type:m(`tool`),messageID:y,id:y})]).annotate({identifier:`Permission.Source`}),vu={sessionID:mu,action:y,resources:h(y),save:h(y).pipe(B),metadata:b(y,Ie).pipe(B),source:_u.pipe(B),message:y.pipe(B)},yu=x({id:gu,...vu}).annotate({identifier:`Permission.Request`}),bu=v([`once`,`always`,`reject`]).annotate({identifier:`Permission.Reply`}),xu=U({type:`permission.asked`,schema:yu.fields}),Su=U({type:`permission.replied`,schema:{sessionID:mu,requestID:gu,reply:bu}}),Cu={Asked:xu,Replied:Su,Definitions:W(xu,Su)},wu=v([`allow`,`deny`,`ask`]).annotate({identifier:`Permission.Effect`}),Tu=x({action:y,resource:y,effect:wu}).annotate({identifier:`Permission.Rule`}),Eu=h(Tu).annotate({identifier:`Permission.Ruleset`}),Du=e({Agent:()=>Du,Color:()=>ju,Event:()=>Nu,ID:()=>ku,Info:()=>Mu,Name:()=>Au}),Ou=U({type:`agent.updated`,schema:{}}),ku=y.pipe(A(`Agent.ID`),D({identifier:`Agent.ID`})),Au=y.pipe(A(`Agent.Name`)),ju=y.annotate({identifier:`Agent.Color`}),Mu=x({id:ku,name:Au,model:al.pipe(B),request:Xc,system:y.pipe(B),description:y.pipe(B),mode:v([`subagent`,`primary`,`all`]),hidden:g,color:ju.pipe(B),steps:R.pipe(B),permissions:Eu}).annotate({identifier:`Agent.Info`}).pipe(so(()=>({default:e=>({id:e,name:Au.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`}]})}))),Nu={Updated:Ou,Definitions:W(Ou)},Pu=e({Commands:()=>zu,Current:()=>Lu,Event:()=>Wu,ID:()=>Fu,Icon:()=>Ru,Info:()=>Vu,Project:()=>Pu,Time:()=>Bu,UpdateInput:()=>Hu,Vcs:()=>Iu}),Fu=go,Iu=y.check(f(/^[a-z][a-z0-9._-]*$/u)).annotate({identifier:`Project.Vcs`}),Lu=x({id:Fu,directory:ao,canonical:ao}).annotate({identifier:`Project.Current`}),Ru=x({url:B(y),override:B(y),color:B(y)}).annotate({identifier:`Project.Icon`}),zu=x({start:B(y.annotate({description:`Startup script to run when creating a new workspace (worktree)`}))}).annotate({identifier:`Project.Commands`}),Bu=x({created:z,updated:z,active:z,archived:B(z)}).annotate({identifier:`Project.Time`}),Vu=x({id:Fu,canonical:ao,vcs:B(Iu),name:B(y),icon:B(Ru),commands:B(zu),time:Bu,sandboxes:h(y)}).annotate({identifier:`Project`}),Hu=x({projectID:Fu,canonical:B(ao),name:B(y),icon:B(Ru),commands:B(zu)}).annotate({identifier:`Project.UpdateInput`}),Uu=U({type:`project.updated`,schema:Vu.fields}),Wu={Updated:Uu,Definitions:W(Uu)},Gu=v([`stop`,`length`,`tool-calls`,`content-filter`,`error`,`unknown`]);y.pipe(A(`Tool.CallID`)),t()(`Tool.Error`,{message:y,error:w(ue()),metadata:w(b(y,Ie))});var Ku=x({type:m(`text`),text:y}).annotate({identifier:`Tool.TextContent`}),qu=x({type:m(`file`),uri:y,mime:y,name:w(y)}).annotate({identifier:`Tool.FileContent`}),Ju=C([Ku,qu]).pipe(ye(`type`)).annotate({identifier:`Tool.Content`}),Yu=b(y,Te).annotate({identifier:`Session.Metadata`}),Xu=y.check(at(`sh_`)).pipe(A(`Shell.ID`),D({identifier:`Shell.ID`})).pipe(so(e=>{let t=()=>e.make(`sh_`+po());return{create:t,ascending:n=>n===void 0?t():e.make(n)}})),Zu=v([`running`,`exited`,`timeout`,`killed`]),Qu=x({started:N.annotate({description:`Start time in milliseconds since the Unix epoch`}),completed:B(N).annotate({description:`Completion time in milliseconds since the Unix epoch`})}),$u=b(y,Ie),ed=x({id:Xu,status:Zu,command:y,cwd:y,shell:y,file:y,pid:B(z),exit:B(N),signal:B(y),metadata:$u,time:Qu}).annotate({identifier:`Shell.Info`}),td=U({type:`shell.created`,schema:{info:ed}}),nd=U({type:`shell.exited`,schema:{id:Xu,exit:B(N),status:Zu}}),rd=U({type:`shell.deleted`,schema:{id:Xu}}),id={Created:td,Exited:nd,Deleted:rd,Definitions:W(td,nd,rd)},ad=x({command:y,cwd:B(y),timeout:B(z),metadata:B($u)}),od=x({cursor:B(z),limit:B(z)}),sd=x({output:y,cursor:z,size:z,truncated:g}),cd=x({type:y,message:y,status:a.check(Pt({minimum:100,maximum:599})).pipe(B),response:x({body:y}).pipe(B),retryAfterMs:z.pipe(B)}).annotate({identifier:`Session.StructuredError`}),ld=y.pipe(A(`Snapshot.ID`),D({identifier:`Snapshot.ID`})),ud=x({input:N,output:N,reasoning:N,cache:x({read:N,write:N})}).annotate({identifier:`TokenUsage.Info`}),dd=e({AgentSelected:()=>md,Assistant:()=>Pd,AssistantContent:()=>jd,AssistantContentEncoded:()=>Md,AssistantReasoning:()=>Ad,AssistantRetry:()=>Nd,AssistantText:()=>kd,AssistantTool:()=>Od,Compaction:()=>Bd,CompactionCompleted:()=>Rd,CompactionFailed:()=>zd,CompactionRunning:()=>Ld,ID:()=>K,Idle:()=>Vd,Info:()=>Hd,LocationSwitched:()=>gd,MediaInfo:()=>Ud,MediaUser:()=>vd,ModelSelected:()=>hd,Native:()=>pd,SessionMessage:()=>dd,Shell:()=>Sd,Skill:()=>xd,Synthetic:()=>yd,System:()=>bd,ToolState:()=>Dd,ToolStateCompleted:()=>Td,ToolStateError:()=>Ed,ToolStateRunning:()=>wd,ToolStateStreaming:()=>Cd,User:()=>_d}),K=y.check(at(`msg_`)).pipe(A(`Session.Message.ID`),D({identifier:`Session.Message.ID`}),so(e=>({create:()=>e.make(`msg_`+po()),fromEvent:t=>e.make(t.replace(/^evt_/,`msg_`))}))),fd={id:K,metadata:b(y,Ie).pipe(B),time:x({created:co})},pd=b(y,Ie).annotate({identifier:`Session.Message.Native`}),md=x({...fd,type:_(`agent-switched`),agent:ku,previous:ku.pipe(B)}).annotate({identifier:`Session.Message.AgentSelected`}),hd=x({...fd,type:_(`model-switched`),model:al,previous:al.pipe(B)}).annotate({identifier:`Session.Message.ModelSelected`}),gd=x({...fd,type:_(`location-switched`),location:yo,projectID:Fu.pipe(B),subpath:io.pipe(B),previous:x({location:yo,projectID:Fu.pipe(B),subpath:io.pipe(B)}).pipe(B)}).annotate({identifier:`Session.Message.LocationSwitched`}),_d=x({...fd,text:Tl.fields.text,files:Tl.fields.files,agents:Tl.fields.agents,skills:Tl.fields.skills,type:_(`user`)}).annotate({identifier:`Session.Message.User`}),vd=x({..._d.fields,files:h(Sl).pipe(B)}).annotate({identifier:`Session.Message.MediaUser`}),yd=x({...fd,text:y,description:y.pipe(B),type:_(`synthetic`)}).annotate({identifier:`Session.Message.Synthetic`}),bd=x({...fd,type:_(`system`),text:y,description:y.pipe(B)}).annotate({identifier:`Session.Message.System`}),xd=x({...fd,type:_(`skill`),skill:No,name:Po,text:y}).annotate({identifier:`Session.Message.Skill`}),Sd=x({...fd,type:_(`shell`),shellID:Xu,command:y,status:Zu,exit:gt.pipe(B),output:sd.pipe(B),time:x({created:co,completed:co.pipe(B)})}).annotate({identifier:`Session.Message.Shell`}),Cd=x({status:_(`streaming`),input:y}).annotate({identifier:`Session.Message.ToolState.Streaming`}),wd=x({status:_(`running`),input:b(y,Ie),metadata:b(y,Te)}).annotate({identifier:`Session.Message.ToolState.Running`}),Td=x({status:_(`completed`),input:b(y,Ie),content:De(Ju),metadata:b(y,Te).pipe(B)}).annotate({identifier:`Session.Message.ToolState.Completed`}),Ed=x({status:_(`error`),input:b(y,Ie),error:cd,content:De(Ju).pipe(B),metadata:b(y,Te).pipe(B)}).annotate({identifier:`Session.Message.ToolState.Error`}),Dd=C([Cd,wd,Td,Ed]).pipe(ye(`status`)),Od=x({type:_(`tool`),id:y,name:y,executed:g.pipe(B),native:pd.pipe(B),state:Dd,time:x({created:co,ran:co.pipe(B),completed:co.pipe(B)})}).annotate({identifier:`Session.Message.Assistant.Tool`}),kd=x({type:_(`text`),text:y,native:pd.pipe(B)}).annotate({identifier:`Session.Message.Assistant.Text`}),Ad=x({type:_(`reasoning`),text:y,native:pd.pipe(B),time:x({created:co,completed:co.pipe(B)}).pipe(B)}).annotate({identifier:`Session.Message.Assistant.Reasoning`}),jd=C([kd,Ad,Od]).pipe(ye(`type`)),Md=ee(jd).annotate({identifier:`Session.Message.AssistantContent.Encoded`}),Nd=x({attempt:R,at:co,error:cd}).annotate({identifier:`Session.Message.Assistant.Retry`}),Pd=x({...fd,type:_(`assistant`),agent:ku,model:al,content:jd.pipe(h),snapshot:x({start:ld.pipe(B),end:ld.pipe(B),files:h(io).pipe(B)}).pipe(B),finish:Gu.pipe(B),rawFinish:y.pipe(B),native:pd.pipe(B),cost:Qc.pipe(B),tokens:ud.pipe(B),error:cd.pipe(B),retry:Nd.pipe(B),time:x({created:co,streamed:co.pipe(B),completed:co.pipe(B)})}).annotate({identifier:`Session.Message.Assistant`}),Fd={type:_(`compaction`),...fd},Id={cost:Qc.pipe(B),tokens:ud.pipe(B)},Ld=x({...Fd,status:_(`running`),reason:v([`auto`,`manual`]),summary:y}).annotate({identifier:`Session.Message.Compaction.Running`}),Rd=x({...Fd,status:_(`completed`),reason:v([`auto`,`manual`]),model:al.pipe(B),native:pd.pipe(B),summary:y,...Id}).annotate({identifier:`Session.Message.Compaction.Completed`}),zd=x({...Fd,status:_(`failed`),reason:v([`auto`,`manual`]),error:cd,...Id}).annotate({identifier:`Session.Message.Compaction.Failed`}),Bd=C([Ld,Rd,zd]).pipe(ye(`status`),D({identifier:`Session.Message.Compaction`})),Vd=x({...fd,type:_(`idle`),outcome:v([`succeeded`,`failed`,`interrupted`]),error:cd.pipe(B)}).annotate({identifier:`Session.Message.Idle`}),Hd=C([md,hd,gd,_d,yd,bd,xd,Sd,Pd,Bd,Vd]).annotate({identifier:`Session.Message.Info`}),Ud=C([md,hd,gd,vd,yd,bd,xd,Sd,Pd,Bd,Vd]).annotate({identifier:`Session.Message.MediaInfo`}),Wd=x({file:y,patch:y,additions:z,deletions:z,status:v([`added`,`deleted`,`modified`]),more:m(!0).pipe(B)}).annotate({identifier:`FileDiff.Info`}),Gd=x({file:y.pipe(B),patch:y.pipe(B),additions:N,deletions:N,status:v([`added`,`deleted`,`modified`]).pipe(B)}).annotate({identifier:`FileDiff.LegacyInfo`}),Kd=x({messageID:K,partID:y.pipe(B),snapshot:ld.pipe(B),files:h(Wd).pipe(B)}).annotate({identifier:`Session.Revert`}),qd=x({path:y,status:v([`added`,`modified`,`deleted`]),additions:N,deletions:N,patch:y}),Jd=x({messageID:K,partID:y.pipe(B),snapshot:y.pipe(B),diff:y.pipe(B),files:h(qd).pipe(B)}).annotate({identifier:`Session.RevertV1`}),Yd=Kd.pipe(wt(x({source:_(`current`),revert:Ft(Kd)}),ne({decode:e=>({source:`current`,revert:e}),encode:e=>e.revert}))),Xd=Jd.pipe(wt(x({source:_(`legacy`),revert:Ft(Jd)}),ne({decode:e=>({source:`legacy`,revert:e}),encode:e=>e.revert})));C([Yd,Xd]).pipe(ye(`source`),wt(Ft(Kd),ne({decode:e=>e.source===`current`?e.revert:Kd.make({messageID:e.revert.messageID,partID:e.revert.partID,snapshot:e.revert.snapshot?ld.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})})),D({identifier:`Session.Revert.Persisted`}));var Zd=y.check(f(/^[a-z0-9][a-z0-9._-]*\/[a-z0-9][a-z0-9._/-]*$/u)).pipe(A(`Instruction.Key`),D({identifier:`Instruction.Key`})),Qd=y.check(f(/^[a-f0-9]{64}$/u)).pipe(A(`Instruction.Hash`),D({identifier:`Instruction.Hash`})),$d=b(Zd,Qd),ef=m(`removed`);ef.make(`removed`);var tf=b(y,C([Qd,ef])),nf=y.check(f(/^[a-z0-9][a-z0-9._-]*$/u)).annotate({identifier:`InstructionEntry.Key`,description:`Instruction entry key (lowercase alphanumerics plus . _ -)`}),rf=x({key:nf,value:Te.annotate({description:`JSON value attached to the session's instructions`})}).annotate({identifier:`InstructionEntry.Info`}),af=h(x({...rf.fields,removed:g})).annotate({identifier:`InstructionEntry.Snapshot`}),of=class extends t()(`InstructionEntryValueTooLargeError`,{actualBytes:a,maxBytes:a,message:y},{httpApiStatus:413}){},sf=e({Compaction:()=>Cf,CompactionPayload:()=>ff,Delivery:()=>cf,Info:()=>Tf,Item:()=>vf,MediaInfo:()=>Ef,MediaUser:()=>xf,MediaUserPayload:()=>uf,Move:()=>wf,MovePayload:()=>pf,SessionInbox:()=>sf,Synthetic:()=>Sf,SyntheticPayload:()=>df,User:()=>bf,UserPayload:()=>lf}),cf=v([`steer`,`queue`]).annotate({identifier:`Session.Inbox.Delivery`}),lf=x({...Tl.fields,metadata:b(y,Ie).pipe(B)}).annotate({identifier:`Session.Inbox.UserPayload`}),uf=x({...lf.fields,files:h(Sl).pipe(B)}).annotate({identifier:`Session.Inbox.MediaUserPayload`}),df=x({text:y,description:y.pipe(B),metadata:b(y,Ie).pipe(B)}).annotate({identifier:`Session.Inbox.SyntheticPayload`}),ff=x({}).annotate({identifier:`Session.Inbox.CompactionPayload`}),pf=x({location:yo,projectID:Fu,subpath:io.pipe(B)}).annotate({identifier:`Session.Inbox.MovePayload`}),mf=x({type:_(`user`),payload:lf,delivery:cf}),hf=x({type:_(`synthetic`),payload:df,delivery:cf}),gf=x({type:_(`compaction`),payload:ff,delivery:cf}),_f=x({type:_(`move`),payload:pf,delivery:cf}),vf=C([mf,hf,gf,_f]).pipe(ye(`type`),D({identifier:`Session.Inbox.Item`})),yf={id:K,sessionID:mu,time:x({created:co})},bf=x({...yf,...mf.fields}).annotate({identifier:`Session.Inbox.User`}),xf=x({...bf.fields,payload:uf}).annotate({identifier:`Session.Inbox.MediaUser`}),Sf=x({...yf,...hf.fields}).annotate({identifier:`Session.Inbox.Synthetic`}),Cf=x({...yf,...gf.fields}).annotate({identifier:`Session.Inbox.Compaction`}),wf=x({...yf,..._f.fields}).annotate({identifier:`Session.Inbox.Move`}),Tf=C([bf,Sf,Cf,wf]).pipe(ye(`type`),D({identifier:`Session.Inbox.Info`})),Ef=C([xf,Sf,Cf,wf]).pipe(ye(`type`),D({identifier:`Session.Inbox.MediaInfo`})),Df=C([x({type:m(`before`),messageID:K}),x({type:m(`through`),messageID:K})]).annotate({identifier:`Session.ForkBoundary`}),Of=e({AgentSelected:()=>Af,All:()=>dp,Archived:()=>Lf,Compaction:()=>ap,Created:()=>kf,Definitions:()=>sp,Deleted:()=>Hf,Durable:()=>up,DurableDefinitions:()=>cp,EphemeralDefinitions:()=>lp,Execution:()=>Yf,Forked:()=>Uf,InboxCancelled:()=>qf,InboxDelivered:()=>Gf,InboxDeliveryChanged:()=>Jf,InboxEnqueued:()=>Kf,InstructionsUpdated:()=>Xf,MessageContentUpdated:()=>zf,MetadataUpdated:()=>Pf,ModelSelected:()=>jf,Moved:()=>Mf,Permissions:()=>Ff,Reasoning:()=>np,Renamed:()=>Nf,RetryScheduled:()=>ip,RevertEvent:()=>op,SessionEvent:()=>Of,Shell:()=>$f,Skill:()=>Qf,Step:()=>ep,Synthetic:()=>Zf,Text:()=>tp,Tool:()=>rp,Unarchived:()=>Rf,UsageRecorded:()=>Bf,UsageUpdated:()=>Vf,Viewed:()=>If}),q={sessionID:mu},J={durable:{aggregate:`sessionID`,version:1}},kf=H({type:`session.created`,...J,schema:{...q,projectID:Fu,location:yo,subpath:io.pipe(B),parentID:mu.pipe(B),slug:y,title:y.pipe(B),agent:ku.pipe(B),model:al.pipe(B),metadata:Yu.pipe(B),permissions:Eu.pipe(B),version:y}}),Af=H({type:`session.agent.selected`,...J,schema:{...q,agent:ku,previous:ku.pipe(B)}}),jf=H({type:`session.model.selected`,...J,schema:{...q,model:al,previous:al.pipe(B)}}),Mf=H({type:`session.moved`,...J,schema:{...q,...pf.fields}}),Nf=H({type:`session.renamed`,...J,schema:{...q,title:y}}),Pf=H({type:`session.metadata.updated`,...J,schema:{...q,metadata:Yu}}),Ff=H({type:`session.permissions`,...J,schema:{...q,permissions:Eu}}),If=H({type:`session.viewed`,...J,schema:{...q,idle:N}}),Lf=H({type:`session.archived`,...J,schema:q}),Rf=H({type:`session.unarchived`,...J,schema:q}),zf=H({type:`session.message.content.updated`,...J,schema:{...q,messageID:K,content:h(Md)}}),Bf=H({type:`session.usage.recorded`,...J,schema:{...q,source:v([`title`,`compaction`]),cost:Qc,tokens:ud}}),Vf=U({type:`session.usage.updated`,schema:{...q,cost:Qc,tokens:ud}}),Hf=H({type:`session.deleted`,durable:{aggregate:`sessionID`,version:2},schema:q}),Uf=H({type:`session.forked`,durable:{aggregate:`sessionID`,version:2},schema:{...q,parentID:mu,boundary:Df,instructions:$d.pipe(B),instructionEntries:af.pipe(B)}}),Wf={...q,inboxID:K},Gf=H({type:`session.inbox.delivered`,...J,schema:Wf}),Kf=H({type:`session.inbox.enqueued`,...J,schema:{...Wf,item:vf}}),qf=H({type:`session.inbox.cancelled`,...J,schema:Wf}),Jf=H({type:`session.inbox.delivery.changed`,...J,schema:{...Wf,delivery:cf}}),Yf;(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:cd}}),e.Interrupted=H({type:`session.execution.interrupted`,...J,schema:{...q,reason:v([`user`,`shutdown`,`superseded`,`inactivity`])}})})(Yf||={});var Xf=H({type:`session.instructions.updated`,durable:{aggregate:`sessionID`,version:2},schema:{...q,delta:tf,text:y.pipe(B)}}),Zf=H({type:`session.synthetic`,...J,schema:{...q,text:y,description:y.pipe(B),metadata:b(y,Ie).pipe(B)}}),Qf;(function(e){e.Activated=H({type:`session.skill.activated`,...J,schema:{...q,id:No,name:Po,text:y}})})(Qf||={});var $f;(function(e){e.Started=H({type:`session.shell.started`,...J,schema:{...q,shell:ed}}),e.Ended=H({type:`session.shell.ended`,...J,schema:{...q,shell:ed,output:sd}})})($f||={});var ep;(function(e){e.Started=H({type:`session.step.started`,...J,schema:{...q,assistantMessageID:K,agent:ku,model:al,snapshot:ld.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:Gu,rawFinish:y.pipe(B),native:pd.pipe(B),cost:Qc,tokens:ud,snapshot:ld.pipe(B),files:h(io).pipe(B)}}),e.Failed=H({type:`session.step.failed`,...J,schema:{...q,assistantMessageID:K,error:cd,finish:v([`content-filter`]).pipe(B),rawFinish:y.pipe(B),native:pd.pipe(B),cost:Qc.pipe(B),tokens:ud.pipe(B),snapshot:ld.pipe(B),files:h(io).pipe(B)}})})(ep||={});var tp;(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:y}}),e.Ended=H({type:`session.text.ended`,...J,schema:{...q,assistantMessageID:K,ordinal:z,text:y,native:pd.pipe(B)}})})(tp||={});var np;(function(e){e.Started=H({type:`session.reasoning.started`,...J,schema:{...q,assistantMessageID:K,ordinal:z,native:pd.pipe(B)}}),e.Delta=U({type:`session.reasoning.delta`,schema:{...q,assistantMessageID:K,ordinal:z,delta:y}}),e.Ended=H({type:`session.reasoning.ended`,...J,schema:{...q,assistantMessageID:K,ordinal:z,text:y,native:pd.pipe(B)}})})(np||={});var rp;(function(e){let t={...q,assistantMessageID:K,id:y};(function(e){e.Started=H({type:`session.tool.input.started`,...J,schema:{...t,name:y}}),e.Delta=U({type:`session.tool.input.delta`,schema:{...t,delta:y}}),e.Ended=H({type:`session.tool.input.ended`,...J,schema:{...t,text:y}})})(e.Input||={}),e.Called=H({type:`session.tool.called`,...J,schema:{...t,input:b(y,Ie),executed:g,native:pd.pipe(B)}}),e.Progress=U({type:`session.tool.progress`,schema:{...t,metadata:b(y,Te)}}),e.Success=H({type:`session.tool.success`,durable:{aggregate:`sessionID`,version:2},schema:{...t,content:De(Ju),metadata:b(y,Te).pipe(B),executed:g,native:pd.pipe(B)}}),e.Failed=H({type:`session.tool.failed`,durable:{aggregate:`sessionID`,version:2},schema:{...t,error:cd,content:De(Ju).pipe(B),metadata:b(y,Te).pipe(B),executed:g,native:pd.pipe(B)}})})(rp||={});var ip=H({type:`session.retry.scheduled`,...J,schema:{...q,assistantMessageID:K,attempt:R,at:z,error:cd}}),ap;(function(e){e.Started=H({type:`session.compaction.started`,...J,schema:{...q,reason:v([`auto`,`manual`]),inputID:K.pipe(B)}}),e.Delta=U({type:`session.compaction.delta`,schema:{...q,text:y}}),e.Ended=H({type:`session.compaction.ended`,...J,schema:{...q,reason:e.Started.data.fields.reason,model:Rd.fields.model,native:Rd.fields.native,text:y,cost:Rd.fields.cost,tokens:Rd.fields.tokens}}),e.Failed=H({type:`session.compaction.failed`,...J,schema:{...q,reason:e.Started.data.fields.reason,error:cd,inputID:K.pipe(B),cost:zd.fields.cost,tokens:zd.fields.tokens}})})(ap||={});var op;(function(e){e.Staged=H({type:`session.revert.staged`,...J,schema:{...q,revert:Kd}}),e.Cleared=H({type:`session.revert.cleared`,...J,schema:q}),e.Committed=H({type:`session.revert.committed`,...J,schema:{...q,to:K}})})(op||={});var sp=W(kf,Af,jf,Mf,Nf,Pf,Ff,If,Lf,Rf,Vf,Hf,Uf,Gf,Kf,qf,Jf,Yf.Started,Yf.Succeeded,Yf.Failed,Yf.Interrupted,Xf,Zf,Qf.Activated,$f.Started,$f.Ended,ep.Started,ep.Streamed,ep.Ended,ep.Failed,tp.Started,tp.Delta,tp.Ended,np.Started,np.Delta,np.Ended,rp.Input.Started,rp.Input.Delta,rp.Input.Ended,rp.Called,rp.Progress,rp.Success,rp.Failed,ip,ap.Started,ap.Delta,ap.Ended,ap.Failed,op.Staged,op.Cleared,op.Committed),cp=W(...sp.filter(e=>e.durability===`durable`),Bf,zf),lp=W(...sp.filter(e=>e.durability===`ephemeral`)),up=C(cp,{mode:`oneOf`}).annotate({identifier:`Session.Event.Durable`}).pipe(ye(`type`)),dp=C([up,...lp],{mode:`oneOf`}).pipe(ye(`type`)),fp=e({Event:()=>mp,ForkBoundary:()=>hp,ID:()=>Y,Info:()=>gp,ListAnchor:()=>_p,ListCursor:()=>wp,ListFilter:()=>yp,Metadata:()=>pp,Revert:()=>Kd,Session:()=>fp}),Y=mu,pp=Yu,mp=Of,hp=Df,gp=x({id:Y,parentID:Y.pipe(B),fork:x({sessionID:Y,boundary:hp}).pipe(B),projectID:Fu,agent:ku.pipe(B),model:al.pipe(B),cost:Qc,tokens:ud,outcome:v([`succeeded`,`failed`,`interrupted`]).pipe(B),time:x({created:co,updated:co,idle:co.pipe(B),viewed:co.pipe(B),archived:co.pipe(B)}),title:y.pipe(B),location:yo,subpath:io.pipe(B),metadata:pp.pipe(B),permissions:Eu.pipe(B),revert:Kd.pipe(B)}).annotate({identifier:`Session.Info`}),_p=x({id:Y,time:N,direction:v([`previous`,`next`])}).annotate({identifier:`Session.ListAnchor`}),vp={order:v([`asc`,`desc`]).pipe(w).annotate({description:`Session order for the first page. Use desc for newest first or asc for oldest first.`}),search:y.pipe(w),parentID:C([Y,te.pipe(Ze(m(`null`),{decode:_t(()=>null),encode:_t(()=>`null`)}))]).annotate({description:`Filter by parent session. Use null to return only root sessions.`}).pipe(w),archived:v([`true`,`false`]).pipe(wt(g,{decode:_t(e=>e===`true`),encode:_t(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(w)},yp=x({...vp,directory:ao.pipe(w),project:Fu.pipe(w),subpath:io.pipe(w)}).annotate({identifier:`Session.ListFilter`}),bp=C([x({...vp,directory:ao,anchor:_p}),x({...vp,project:Fu,subpath:io.pipe(w),anchor:_p}),x({...vp,anchor:_p})]),xp=Dt(bp),Sp=et(xp),Cp=We(xp),wp=y.pipe(A(`SessionsCursor`),D({identifier:`SessionsCursor`,description:`Opaque pagination cursor returned as cursor.previous or cursor.next in the previous response.`}),so(e=>{let t=Oe(e);return{make:e=>t(ke(Sp(e))),parse:e=>$e(()=>{let t=Ae(e);return Nt(t)?nt(`Invalid cursor`):Cp(t.success).pipe(M(()=>`Invalid cursor`))})}})),Tp=x({...ou.fields,sessionID:Y,foregroundProcess:ce(y),size:x({cols:R,rows:R}),output:x({head:z,tail:z})}).annotate({identifier:`PersistentPty.Info`}),Ep=x({directory:y,instanceID:y,ticket:y,expiresAt:gt}).annotate({identifier:`PersistentPty.Handoff`}),Dp=x({command:B(y),args:h(y),cwd:B(y),title:y,env:b(y,y),size:B(x({cols:R,rows:R}))}).annotate({identifier:`PersistentPty.CreateInput`}),Op=x({attachmentID:B(y),size:x({cols:R,rows:R})}).annotate({identifier:`PersistentPty.UpdateInput`}),kp=x({info:Tp,text:y,checkpoint:dt,cursor:x({x:z,y:z})}).annotate({identifier:`PersistentPty.Snapshot`}),Ap=R.check(c(65535)).annotate({identifier:`PersistentPty.ReadLines`}),jp=x({ptyID:au,title:y,cwd:y,foregroundProcess:ce(y),screen:x({text:y,cols:R,rows:R,cursor:kp.fields.cursor})}).annotate({identifier:`PersistentPty.ReadResult`}),Mp=U({type:`persistent-pty.added`,schema:{sessionID:Y,terminal:Tp}}),Np=U({type:`persistent-pty.removed`,schema:{sessionID:Y,ptyID:au}}),Pp={Added:Mp,Removed:Np,Definitions:W(Mp,Np)},Fp=x({ticket:y,expires_in:R}).annotate({identifier:`PtyTicket.ConnectToken`}),X=x({location:w(x({directory:w(y)}))}).annotate({identifier:`LocationQuery`}),Z=O({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}}),Ip=e=>j(`server.location`).add(k(`location.get`,`/api/location`,{query:X,success:So}).middleware(e).annotateMerge(Z).annotateMerge(O({identifier:`location.get`,summary:`Get location`,description:`Resolve the requested location or the server default location.`}))).add(T(`location.reload`,`/api/location/reload`,{success:S,error:Yo}).annotateMerge(O({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(O({title:`location`})),Lp=`ticket`,Rp=`x-opencode-ticket`,zp=`/api/pty/:ptyID/connect`,Bp=e=>j(`server.pty`).add(k(`pty.list`,`/api/pty`,{query:X,success:V(h(ou))}).annotateMerge(Z).annotateMerge(O({identifier:`pty.list`,summary:`List PTY sessions`,description:`List PTY sessions for a location, including exited sessions retained until removal.`}))).add(T(`pty.create`,`/api/pty`,{query:X,payload:fu,success:V(ou)}).annotateMerge(Z).annotateMerge(O({identifier:`pty.create`,summary:`Create PTY session`,description:`Create a pseudo-terminal session for a location.`}))).add(k(`pty.get`,`/api/pty/:ptyID`,{params:{ptyID:au},query:X,success:V(ou),error:_s}).annotateMerge(Z).annotateMerge(O({identifier:`pty.get`,summary:`Get PTY session`,description:`Get one PTY session, including its exit code once exited.`}))).add(Ct(`pty.update`,`/api/pty/:ptyID`,{params:{ptyID:au},query:X,payload:pu,success:V(ou),error:_s}).annotateMerge(Z).annotateMerge(O({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:au},query:X,success:S,error:_s}).annotateMerge(Z).annotateMerge(O({identifier:`pty.remove`,summary:`Remove PTY session`,description:`Terminate and remove one PTY session.`}))).add(T(`pty.connectToken`,`/api/pty/:ptyID/connect-token`,{params:{ptyID:au},query:X,headers:x({[Rp]:w(y)}),success:V(Fp),error:[gs,_s]}).annotateMerge(Z).annotateMerge(O({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(k(`pty.connect`,zp,{params:{ptyID:au},success:g,error:[gs,_s,Ho]}).annotateMerge(O({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`,Lp].map(e=>({in:`query`,name:e,schema:{type:`string`}}))]})}))).annotateMerge(O({title:`pty`,description:`Experimental location-scoped PTY routes.`})),Vp=`/api/experimental/persistent-pty/:ptyID/connect`,Hp=[Uo,Yo],Up=[_s,Yo],Wp=j(`server.experimental`).add(k(`persistentPty.read`,`/api/experimental/session/:sessionID/terminal/read`,{params:{sessionID:Y},query:{lines:oe.pipe(wt(Ap),w)},success:x({data:ce(jp)}),error:[Yo]}).annotateMerge(O({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(k(`persistentPty.list`,`/api/experimental/session/:sessionID/terminal`,{params:{sessionID:Y},success:x({data:h(Tp)}),error:Hp})).add(T(`persistentPty.create`,`/api/experimental/session/:sessionID/terminal`,{params:{sessionID:Y},payload:Dp,success:x({data:Tp}),error:Hp})).add(T(`persistentPty.shutdown`,`/api/experimental/persistent-pty/shutdown`,{success:S,error:[Yo]})).add(T(`persistentPty.handoff`,`/api/experimental/persistent-pty/handoff`,{success:x({handoff:ce(Ep)}),error:[Yo]})).add(k(`persistentPty.get`,`/api/experimental/persistent-pty/:ptyID`,{params:{ptyID:au},success:x({data:Tp}),error:Up})).add(Ct(`persistentPty.update`,`/api/experimental/persistent-pty/:ptyID`,{params:{ptyID:au},payload:Op,success:x({data:Tp}),error:Up})).add(k(`persistentPty.snapshot`,`/api/experimental/persistent-pty/:ptyID/snapshot`,{params:{ptyID:au},success:x({data:kp}),error:Up})).add(ft(`persistentPty.remove`,`/api/experimental/persistent-pty/:ptyID`,{params:{ptyID:au},success:S,error:Up})).add(T(`persistentPty.connectToken`,`/api/experimental/persistent-pty/:ptyID/connect-token`,{params:{ptyID:au},headers:x({[Rp]:w(y)}),success:x({data:Fp}),error:[gs,_s,Yo]})).add(k(`persistentPty.connect`,Vp,{params:{ptyID:au},success:g,error:[gs,_s,Yo]}).annotateMerge(O({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`,Lp].map(e=>({in:`query`,name:e,schema:{type:`string`}}))]})}))).annotateMerge(O({title:`persistentPty`,description:`Prototype persistent PTY routes.`})).add(ru),Gp=v([`webrtc`,`websocket`]).annotate({identifier:`VoiceTransportType`}),Kp=x({model:y,provider:y,transports:h(Gp),available:g}).annotate({identifier:`VoiceModel`}),qp=x({type:m(`webrtc`),sdp:y,dcid:w(gt)}).annotate({identifier:`VoiceWebRTCTransportInput`}),Jp=x({type:m(`websocket`)}).annotate({identifier:`VoiceWebSocketTransportInput`}),Yp=C([qp,Jp]).annotate({identifier:`VoiceTransportInput`}),Xp=x({type:m(`webrtc`),sdp:y}).annotate({identifier:`VoiceWebRTCTransport`}),Zp=x({type:m(`websocket`),url:y,token:y,expiresAt:gt}).annotate({identifier:`VoiceWebSocketTransport`}),Qp=C([Xp,Zp]).annotate({identifier:`VoiceTransport`}),$p=j(`server.voice`).add(k(`voice.models`,`/api/experimental/voice/models`,{success:x({data:x({models:h(Kp),default:w(y)})}).annotate({identifier:`VoiceModelsResponse`}),error:[Yo,Ho]}).annotateMerge(O({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(T(`voice.session`,`/api/experimental/voice/session`,{payload:x({model:y,session:w(b(y,Ie)),transport:Yp}),success:x({data:x({transport:Qp})}).annotate({identifier:`VoiceSessionResponse`}),error:[Uo,Yo,Ho]}).annotateMerge(O({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(O({title:`voice`,description:`Experimental server-brokered voice session routes.`})),em=x({limit:w(oe.check(xe(),Mt(1),c(200))).annotate({description:`Maximum number of messages to return. When omitted, the endpoint returns its default page size.`}),order:w(C([m(`asc`),m(`desc`)])).annotate({description:`Message order for the first page. Use desc for newest first or asc for oldest first.`}),cursor:w(y.annotate({description:`Opaque pagination cursor returned as cursor.previous or cursor.next in the previous response. Do not combine with order.`})),type:w(v(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`}),tm=x({...re(gd.fields,[`location`,`previous`]),location:bo,previous:x({location:bo,projectID:gd.fields.projectID,subpath:gd.fields.subpath}).pipe(w)}).annotate({identifier:`Session.Message.LocationSwitched`}),nm=C([md,hd,tm,_d,yd,bd,xd,Sd,Pd,Bd,Vd]).annotate({identifier:`Session.Message.Info`}),rm=C([md,hd,tm,vd,yd,bd,xd,Sd,Pd,Bd,Vd]).annotate({identifier:`Session.Message.MediaInfo`}),im=x({previous:y.pipe(w),next:y.pipe(w)});x({data:h(rm),cursor:im}),x({data:rm});var am=j(`server.message`).add(k(`session.messages`,`/api/session/:sessionID/message`,{params:{sessionID:Y},query:em,success:x({data:h(nm),cursor:im}).annotate({identifier:`SessionMessagesResponse`}),error:[us,G,Xo]}).annotateMerge(O({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(O({title:`session`,description:`Experimental message routes.`})),om=x({...X.fields,types:w(de(sl)).annotate({description:`Only list models of these types. Defaults to chat, the only type offered for sessions.`})}),sm=j(`server.model`).add(k(`model.list`,`/api/model`,{query:om,success:V(h(pl)),error:Yo}).annotateMerge(Z).annotateMerge(O({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(k(`model.default`,`/api/model/default`,{query:X,success:V(yt(pl)),error:Yo}).annotateMerge(Z).annotateMerge(O({identifier:`model.default`,summary:`Get default model`,description:`Retrieve the model used when a session has no explicit model selection.`}))).annotateMerge(O({title:`model`,description:`Experimental model routes.`})),cm=j(`server.provider`).add(k(`provider.list`,`/api/provider`,{query:X,success:V(h(Zc)),error:Yo}).annotateMerge(Z).annotateMerge(O({identifier:`provider.list`,summary:`List providers`,description:`Retrieve active AI providers so clients can show provider availability and configuration.`}))).add(k(`provider.get`,`/api/provider/:providerID`,{params:{providerID:Lc},query:X,success:V(Zc),error:[Zo,Yo]}).annotateMerge(Z).annotateMerge(O({identifier:`provider.get`,summary:`Get provider`,description:`Retrieve a single AI provider so clients can inspect its availability and endpoint settings.`}))).annotateMerge(O({title:`provider`,description:`Experimental provider routes.`})),lm=e({FileAttachment:()=>um,Prompt:()=>fm,PromptInput:()=>lm,SkillAttachment:()=>dm}),um=x({uri:y,name:y.pipe(B),description:y.pipe(B),mention:ml.pipe(B)}).annotate({identifier:`PromptInput.FileAttachment`}),dm=x({id:No,mention:ml.pipe(B)}).annotate({identifier:`PromptInput.SkillAttachment`}),fm=x({text:y,files:h(um).pipe(B),agents:h(Cl).pipe(B),skills:h(dm).pipe(B)}).annotate({identifier:`PromptInput`}),pm=x({date:y,steps:z}).annotate({identifier:`SessionStats.Activity`}),mm=x({model:al,steps:z,tokens:ud,cost:Qc}).annotate({identifier:`SessionStats.ModelUsage`}),hm=x({name:y,calls:z,succeeded:z,failed:z,unfinished:z,durationP50:N.pipe(B)}).annotate({identifier:`SessionStats.ToolUsage`}),gm=v([`none`,`summary`,`detail`]),_m=x({calls:z,succeeded:z,failed:z,unfinished:z}).annotate({identifier:`SessionStats.ToolTotals`}),vm=C([x({mode:m(`none`)}),x({mode:m(`summary`),totals:_m}),x({mode:m(`detail`),totals:_m,usage:h(hm)})]).annotate({identifier:`SessionStats.Tools`}),ym=x({range:x({from:co,to:co}),sessions:z,subagents:z,prompts:z,steps:z,tokens:ud,cost:Qc,tools:vm,activeDays:z,streak:z,activity:h(pm),models:h(mm)}).annotate({identifier:`SessionStats.Info`});function bm(e,t){return e===`assistant`?Sm(km(t,`providerState`,`native`)):e===`compaction`?Tm(wm(km(t,`providerState`,`native`))):t}function xm(e){return e.map(e=>Am(e)?bm(e.type,e):e)}function Sm(e){return Array.isArray(e.content)?{...e,content:e.content.map(Cm)}:e}function Cm(e){return Am(e)?e.type===`text`||e.type===`reasoning`?km(e,`state`,`native`):e.type===`tool`?Om(km(e,`providerState`,`native`)):e:e}function wm(e){let t=e.recent,n=Dm(e,`recent`);if(typeof t!=`string`||!t)return n;let r=Am(n.metadata)?n.metadata:{};return{...n,metadata:{recent:t,...r}}}function Tm(e){let t=e.providerContext,n=Dm(e,`providerContext`);return Am(t)?{...n,native:{messages:Array.isArray(t.messages)?t.messages.map(Em):t.messages}}:n}function Em(e){return!Am(e)||!Array.isArray(e.content)?e:{...e,content:e.content.map(e=>{if(!Am(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 Dm(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 Am(t)?{...n,native:{...Am(n.native)?n.native:{},...t}}:n}function km(e,t,n){if(!(t in e))return e;let{[t]:r,...i}=e;return n in i?i:{...i,[n]:r}}function Am(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}var jm=e({EventLog:()=>jm,Synced:()=>Mm}),Mm=x({type:m(`log.synced`),aggregateID:y,seq:B(To)}).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.`}),Nm=x({type:m(`running`)}).annotate({identifier:`SessionActive`}),Pm=x({...re(gp.fields,[`location`]),location:bo}).annotate({identifier:`Session.Info`}),Fm=x({info:Pm,messages:h(nm)}).annotate({identifier:`SessionTransfer.Data`}),Im=x({...re(pf.fields,[`location`]),location:bo}).annotate({identifier:`Session.Inbox.MovePayload`}),Lm=x({...re(wf.fields,[`payload`]),payload:Im}).annotate({identifier:`Session.Inbox.Move`}),Rm=C([bf,Sf,Cf,Lm]).annotate({identifier:`Session.Inbox.Info`});x({data:h(C([xf,Sf,Cf,Lm]).annotate({identifier:`Session.Inbox.MediaInfo`}))});var zm=h(Te).pipe(wt(h(Ie),{decode:_t(xm),encode:le({strict:!1})}),wt(h(nm),{decode:le({strict:!1}),encode:le({strict:!1})})),Bm=x({id:Vs.pipe(w),title:tc.fields.title,metadata:tc.fields.metadata,fields:tc.fields.fields}).annotate({identifier:`Form.CreatePayload`}),Vm=v([`true`,`false`]).pipe(wt(g,{decode:_t(e=>e===`true`),encode:_t(e=>e?`true`:`false`)})),Hm=x({limit:oe.pipe(wt(R),w).annotate({description:`Maximum number of sessions to return. Defaults to the newest 50 sessions.`}),...yp.fields,cursor:wp.pipe(w)}).annotate({identifier:`SessionsQuery`}),Um=(e,t)=>j(`server.session`).add(k(`session.list`,`/api/session`,{query:Hm,success:x({data:h(Pm),cursor:x({previous:wp.pipe(w),next:wp.pipe(w)})}).annotate({identifier:`SessionsResponse`}),error:[us,Uo]}).annotateMerge(O({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(k(`session.stats`,`/api/experimental/session/stats`,{query:x({from:oe.pipe(w),to:oe.pipe(w),project:Fu.pipe(w),timezone:y.pipe(w),tools:gm.pipe(w)}),success:x({data:ym}),error:Uo}).annotateMerge(O({identifier:`experimental.session.stats`,summary:`Get session statistics`,description:`Aggregate local session activity, usage, and tool reliability for a time range.`}))).add(T(`session.create`,`/api/session`,{payload:x({id:Y.pipe(w),parentID:Y.pipe(w),title:y.pipe(w),agent:ku.pipe(w),model:al.pipe(w),location:bo.pipe(w),metadata:pp.pipe(w),permissions:Eu.pipe(w)}),success:x({data:Pm}),error:G}).annotateMerge(O({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(T(`session.import`,`/api/experimental/session/import`,{payload:x({info:Fm.fields.info,messages:zm,location:bo.pipe(w)}),success:x({data:Pm}),error:[qo,G]}).annotateMerge(O({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(k(`session.export`,`/api/experimental/session/:sessionID/export`,{params:{sessionID:Y},query:x({sanitize:Vm.pipe(w)}),success:x({data:Fm}),error:[G,Xo]}).annotateMerge(O({identifier:`experimental.session.export`,summary:`Export session`,description:`Export a complete projected session transcript.`}))).add(k(`session.active`,`/api/session/active`,{success:x({data:b(Y,Nm)})}).annotateMerge(O({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(k(`session.get`,`/api/session/:sessionID`,{params:{sessionID:Y},success:x({data:Pm}),error:G}).annotateMerge(O({identifier:`session.get`,summary:`Get session`,description:`Retrieve a session by ID.`}))).add(ft(`session.remove`,`/api/session/:sessionID`,{params:{sessionID:Y},success:S,error:G}).annotateMerge(O({identifier:`session.remove`,summary:`Delete session`,description:`Delete a session and its child sessions.`}))).add(T(`session.fork`,`/api/session/:sessionID/fork`,{params:{sessionID:Y},payload:x({before:K.pipe(w)}),success:x({data:Pm}),error:[G,as,Uo]}).annotateMerge(O({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(T(`session.switchAgent`,`/api/session/:sessionID/agent`,{params:{sessionID:Y},payload:x({agent:ku}),success:S,error:G}).annotateMerge(O({identifier:`session.switchAgent`,summary:`Switch session agent`,description:`Switch the agent used by subsequent provider turns.`}))).add(T(`session.switchModel`,`/api/session/:sessionID/model`,{params:{sessionID:Y},payload:x({model:al}),success:S,error:G}).annotateMerge(O({identifier:`session.switchModel`,summary:`Switch session model`,description:`Switch the model used by subsequent provider turns.`}))).add(Be(`session.update`,`/api/session/:sessionID`,{params:{sessionID:Y},payload:x({title:y.pipe(w),metadata:pp.pipe(w),permissions:Eu.pipe(w),archived:g.pipe(w).annotate({description:`Archive the session with true or restore it with false. Repeating the current state is a no-op.`})}),success:S,error:[G,Ho]}).annotateMerge(O({identifier:`session.update`,summary:`Update session`,description:`Update mutable session properties.`}))).add(T(`session.move`,`/api/session/:sessionID/move`,{params:{sessionID:Y},payload:x({...bo.fields,delivery:cf.pipe(w)}),success:S,error:[G,Uo]}).annotateMerge(O({identifier:`session.move`,summary:`Move session`,description:`Move a session to another project directory at the requested delivery boundary.`}))).add(T(`session.prompt`,`/api/session/:sessionID/prompt`,{params:{sessionID:Y},payload:x({id:K.pipe(w),...fm.fields,metadata:lf.fields.metadata,delivery:cf.pipe(w),resume:g.pipe(w)}),success:x({data:bf}),error:[qo,Uo,G]}).middleware(e).annotateMerge(O({identifier:`session.prompt`,summary:`Send message`,description:`Durably admit one session input and schedule agent-loop execution unless resume is false.`}))).add(T(`session.command`,`/api/session/:sessionID/command`,{params:{sessionID:Y},payload:x({name:y,...fm.fields,delivery:cf.pipe(w)}),success:S,error:[G,cs,ls]}).middleware(e).annotateMerge(O({identifier:`session.command`,summary:`Run command`,description:`Execute a slash command callback immediately.`}))).add(T(`session.skill`,`/api/experimental/session/:sessionID/skill`,{params:{sessionID:Y},payload:x({id:No,resume:g.pipe(w)}),success:S,error:[G,os]}).middleware(e).annotateMerge(O({identifier:`experimental.session.skill`,summary:`Activate skill`,description:`Activate a skill for a session by appending a skill message and resuming execution.`}))).add(T(`session.synthetic`,`/api/session/:sessionID/synthetic`,{params:{sessionID:Y},payload:x({id:K.pipe(w),text:y,description:y.pipe(w),metadata:yd.fields.metadata,delivery:cf.pipe(w),resume:g.pipe(w)}),success:x({data:Sf}),error:[qo,G]}).middleware(e).annotateMerge(O({identifier:`session.synthetic`,summary:`Add synthetic message`,description:`Durably admit synthetic session input and schedule execution unless resume is false.`}))).add(T(`session.shell`,`/api/session/:sessionID/shell`,{params:{sessionID:Y},payload:x({id:K.pipe(w),command:y}),success:S,error:G}).middleware(e).annotateMerge(O({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(T(`session.compact`,`/api/session/:sessionID/compact`,{params:{sessionID:Y},payload:x({id:K.pipe(w),delivery:cf.pipe(w)}),success:x({data:Cf}),error:[qo,G]}).middleware(e).annotateMerge(O({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(T(`session.wait`,`/api/experimental/session/:sessionID/wait`,{params:{sessionID:Y},success:S,error:[G,Yo]}).annotateMerge(O({identifier:`experimental.session.wait`,summary:`Wait for session`,description:`Wait for a session agent loop to become idle.`}))).add(T(`session.revert.stage`,`/api/session/:sessionID/revert/stage`,{params:{sessionID:Y},payload:x({messageID:K,files:g.pipe(w)}),success:x({data:Kd}),error:[as,G,Jo,Xo]}).middleware(e).annotateMerge(O({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:S,error:[G,Jo,Xo]}).middleware(e).annotateMerge(O({identifier:`session.revert.clear`,summary:`Clear staged revert`}))).add(T(`session.revert.commit`,`/api/session/:sessionID/revert/commit`,{params:{sessionID:Y},success:S,error:[G,Jo]}).annotateMerge(O({identifier:`session.revert.commit`,summary:`Commit staged revert`}))).add(k(`session.context`,`/api/session/:sessionID/context`,{params:{sessionID:Y},success:x({data:h(nm)}),error:[G,Xo]}).annotateMerge(O({identifier:`session.context`,summary:`Get session context`,description:`Retrieve the active context messages for a session (all messages after the last compaction).`}))).add(k(`session.diff`,`/api/session/:sessionID/diff`,{params:{sessionID:Y},query:x({from:w(K).annotate({description:`User message whose turn to diff. Defaults to the turn of the newest user message.`}),to:w(K).annotate({description:"Later user message whose turn ends the range. Defaults to the turn of `from` alone."}),context:oe.pipe(wt(z),w).annotate({description:`Unchanged lines around each hunk. Omit for full-file patches.`})}),success:x({data:h(Wd)}),error:[Uo,as,G,Xo,Ho]}).annotateMerge(O({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(k(`session.inbox.list`,`/api/session/:sessionID/inbox`,{params:{sessionID:Y},success:x({data:h(Rm)}),error:G}).annotateMerge(O({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:S,error:G}).annotateMerge(O({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(Be(`session.inbox.update`,`/api/session/:sessionID/inbox/:inboxID`,{params:{sessionID:Y,inboxID:K},payload:x({delivery:cf}),success:S,error:[qo,G]}).annotateMerge(O({identifier:`session.inbox.update`,summary:`Update inbox item`,description:`Change a pending inbox item's delivery mode. Steering wakes session execution.`}))).add(k(`session.instructions.entry.list`,`/api/experimental/session/:sessionID/instructions/entries`,{params:{sessionID:Y},success:x({data:h(rf)}),error:G}).annotateMerge(O({identifier:`experimental.session.instructions.entry.list`,summary:`List instruction entries`,description:`List API-managed instruction entries attached to the session.`}))).add(Ct(`session.instructions.entry.put`,`/api/experimental/session/:sessionID/instructions/entries/:key`,{params:{sessionID:Y,key:nf},payload:x({value:Te}),success:S,error:[G,of]}).annotateMerge(O({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:nf},success:S,error:G}).annotateMerge(O({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(T(`session.generate`,`/api/session/:sessionID/generate`,{params:{sessionID:Y},payload:x({prompt:y}),success:x({data:x({text:y})}).annotate({identifier:`SessionGenerateResponse`}),error:[G,Yo]}).middleware(e).annotateMerge(O({identifier:`session.generate`,summary:`Generate text from session context`,description:`Generate transient text from the current session context without mutating session history.`}))).add(k(`session.log`,`/api/experimental/session/:sessionID/log`,{params:{sessionID:Y},query:{after:oe.pipe(wt(To),w),follow:Vm.pipe(w)},success:qe({data:C([up,Mm]).annotate({identifier:`SessionLogItem`})}),error:G}).annotateMerge(O({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(T(`session.interrupt`,`/api/session/:sessionID/interrupt`,{params:{sessionID:Y},query:{resume:Vm.pipe(w)},success:x({interrupted:g.annotate({description:`Whether an active execution owned by this OpenCode process was interrupted.`})}).annotate({identifier:`SessionInterruptResponse`}),error:G}).annotateMerge(O({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(T(`session.background`,`/api/session/:sessionID/background`,{params:{sessionID:Y},success:S,error:G}).annotateMerge(O({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(k(`session.message`,`/api/session/:sessionID/message/:messageID`,{params:{sessionID:Y,messageID:K},success:x({data:nm}),error:[G,as]}).annotateMerge(O({identifier:`session.message.get`,summary:`Get session message`,description:`Retrieve one projected message owned by the Session.`}))).add(k(`session.form.list`,`/api/session/:sessionID/form`,{params:{sessionID:y},success:x({data:h(tc)}),error:G}).middleware(t).annotateMerge(O({identifier:`session.form.list`,summary:`List session forms`,description:`Retrieve pending forms for a session.`}))).add(T(`session.form.create`,`/api/session/:sessionID/form`,{params:{sessionID:y},payload:Bm,success:x({data:tc}),error:[G,qo,Uo]}).middleware(t).annotateMerge(O({identifier:`session.form.create`,summary:`Create session form`,description:`Create a form for a session.`}))).add(k(`session.form.get`,`/api/session/:sessionID/form/:formID`,{params:{sessionID:y,formID:Vs},success:x({data:ac}),error:[G,ps]}).middleware(t).annotateMerge(O({identifier:`session.form.get`,summary:`Get session form`,description:`Retrieve a form and its current state for a session.`}))).add(T(`session.form.reply`,`/api/session/:sessionID/form/:formID/reply`,{params:{sessionID:y,formID:Vs},payload:oc,success:S,error:[G,ms,hs,ps]}).middleware(t).annotateMerge(O({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:y,formID:Vs},query:x({message:w(y)}),success:S,error:[G,ms,ps]}).middleware(t).annotateMerge(O({identifier:`session.form.cancel`,summary:`Cancel form`,description:`Cancel a pending form, optionally telling the asker why it was not answered.`}))).add(Ct(`session.environment`,`/api/session/:sessionID/environment`,{params:{sessionID:Y},payload:x({variables:b(y,y)}),success:S,error:G}).annotateMerge(O({identifier:`session.environment`,summary:`Set session environment`,description:`Replace the process environment used by local shell commands for this session.`}))).add(T(`session.view`,`/api/session/:sessionID/view`,{params:{sessionID:Y},payload:x({idle:co}),success:S,error:G}).annotateMerge(O({identifier:`session.view`,summary:`View session`,description:`Mark the idle transition observed by the viewer as viewed.`}))).annotateMerge(O({title:`session`,description:`Experimental session routes.`})),Wm=e({ID:()=>Gm,Info:()=>Km,PermissionSaved:()=>Wm}),Gm=y.pipe(A(`PermissionSaved.ID`),D({identifier:`PermissionSaved.ID`}),so(e=>({create:()=>e.make(`psv_`+po())}))),Km=x({id:Gm,projectID:go,action:y,resource:y,time:x({created:co,updated:co})}).annotate({identifier:`PermissionSaved.Info`}),qm=(e,t)=>j(`server.permission`).add(k(`permission.request.list`,`/api/permission/request`,{query:X,success:V(h(yu))}).middleware(e).annotateMerge(Z).annotateMerge(O({identifier:`permission.request.list`,summary:`List pending permission requests`,description:`Retrieve pending permission requests for a location.`}))).add(k(`permission.saved.list`,`/api/permission/saved`,{query:x({projectID:Fu.pipe(w)}),success:x({data:h(Km)})}).middleware(e).annotateMerge(O({identifier:`permission.saved.list`,summary:`List saved permissions`,description:`Retrieve saved permissions, optionally filtered by project.`}))).add(Be(`permission.saved.update`,`/api/permission/saved/:id`,{params:{id:Gm},payload:x({action:y.pipe(w),resource:y.pipe(w)}),success:x({data:Km}),error:[fs,qo]}).annotateMerge(O({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:Gm},success:S}).annotateMerge(O({identifier:`permission.saved.remove`,summary:`Remove saved permission`,description:`Remove a saved permission by ID.`}))).add(T(`session.permission.create`,`/api/session/:sessionID/permission`,{params:{sessionID:Y},payload:x({id:gu.pipe(w),action:yu.fields.action,resources:yu.fields.resources,save:yu.fields.save,metadata:yu.fields.metadata,source:yu.fields.source,agent:ku.pipe(w)}),success:x({data:x({id:gu,effect:wu})}),error:G}).middleware(t).annotateMerge(O({identifier:`session.permission.create`,summary:`Create permission request`,description:`Evaluate and, when approval is required, create a permission request for a session.`}))).add(k(`session.permission.list`,`/api/session/:sessionID/permission`,{params:{sessionID:Y},success:x({data:h(yu)}),error:[G,Ho]}).annotateMerge(O({identifier:`session.permission.list`,summary:`List session permission requests`,description:`Retrieve pending permission requests owned by a session.`}))).add(k(`session.permission.get`,`/api/session/:sessionID/permission/:requestID`,{params:{sessionID:Y,requestID:gu},success:x({data:yu}),error:[G,ds]}).middleware(t).annotateMerge(O({identifier:`session.permission.get`,summary:`Get permission request`,description:`Retrieve a pending permission request owned by a session.`}))).add(T(`session.permission.reply`,`/api/session/:sessionID/permission/:requestID/reply`,{params:{sessionID:Y,requestID:gu},payload:x({decision:bu,message:y.pipe(w)}),success:S,error:[G,ds]}).middleware(t).annotateMerge(O({identifier:`session.permission.reply`,summary:`Reply to pending permission request`,description:`Respond to a pending permission request owned by a session.`}))).annotateMerge(O({title:`permission`,description:`Experimental permission routes.`})),Jm=e({Entry:()=>Zm,Event:()=>Xm,FileSystem:()=>Jm,FindInput:()=>eh,Match:()=>$m,Submatch:()=>Qm,Write:()=>th}),Ym=U({type:`filesystem.changed`,schema:{file:y,event:v([`add`,`change`,`unlink`])}}),Xm={Changed:Ym,Definitions:W(Ym)},Zm=x({path:io,type:v([`file`,`directory`])}).annotate({identifier:`FileSystem.Entry`}),Qm=x({text:y,start:z,end:z}).annotate({identifier:`FileSystem.Submatch`}),$m=x({entry:Zm,line:R,offset:z,text:y,submatches:h(Qm)}).annotate({identifier:`FileSystem.Match`}),eh=class extends p(`FileSystem.FindInput`)({query:y,type:v([`file`,`directory`]).pipe(B),limit:R.pipe(B)}){},th=x({path:ao}).annotate({identifier:`FileSystem.Write`}),nh=x({...X.fields,path:y.pipe(w).annotate({description:`An absolute path or a path relative to the requested location. Defaults to the location directory.`})}),rh=x({...X.fields,path:y.annotate({description:`An absolute path or a path relative to the requested location. Missing parent directories are created.`})}),ih=x({path:y.annotate({description:`A file path relative to the requested location.`})}),ah=x({...X.fields,query:eh.fields.query,type:eh.fields.type,limit:oe.pipe(wt(R),w)}),oh=j(`server.fs`).add(k(`fs.read`,`/api/fs/read/*`,{query:X,success:dt.pipe(mt()),error:ns}).annotateMerge(Z).annotateMerge(O({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(k(`fs.list`,`/api/fs/list`,{query:nh,success:V(h(Zm)),error:ns}).annotateMerge(Z).annotateMerge(O({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(k(`fs.find`,`/api/fs/find`,{query:ah,success:V(h(Zm))}).annotateMerge(Z).annotateMerge(O({identifier:`fs.find`,summary:`Find files`,description:`Find recursively ranked filesystem entries relative to the requested location.`}))).add(T(`fs.write`,`/api/experimental/fs/write`,{query:rh,payload:dt.pipe(mt()),success:V(th)}).annotateMerge(Z).annotateMerge(O({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(T(`fs.watch`,`/api/experimental/fs/watch`,{query:X,payload:ih,success:S,error:[ns,Yo]}).annotateMerge(Z).annotateMerge(O({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:ih,success:S}).annotateMerge(Z).annotateMerge(O({identifier:`experimental.fs.unwatch`,summary:`Unwatch file`,description:`Stop watching one file relative to the requested location. Experimental: may change without compatibility guarantees.`}))).annotateMerge(O({title:`filesystem`,description:`Experimental location-scoped filesystem routes.`})),sh=e=>j(`server.form`).add(k(`form.list`,`/api/form`,{query:X,success:V(h(tc))}).annotateMerge(Z).annotateMerge(O({identifier:`form.list`,summary:`List pending forms`,description:`Retrieve pending forms for a location.`}))).middleware(e).annotateMerge(O({title:`form`,description:`Location form routes.`})),ch=e({Command:()=>ch,Event:()=>dh,Info:()=>uh}),lh=U({type:`command.updated`,schema:{}}),uh=x({name:y,description:y.pipe(B)}).annotate({identifier:`Command.Info`}),dh={Updated:lh,Definitions:W(lh)},fh=j(`server.command`).add(k(`command.list`,`/api/command`,{query:X,success:V(h(uh))}).annotateMerge(Z).annotateMerge(O({identifier:`command.list`,summary:`List commands`,description:`Retrieve currently registered commands.`}))).annotateMerge(O({title:`command`,description:`Experimental command routes.`})),ph=j(`server.skill`).add(k(`skill.list`,`/api/skill`,{query:X,success:V(h(Lo))}).annotateMerge(Z).annotateMerge(O({identifier:`skill.list`,summary:`List skills`,description:`Retrieve currently registered skills.`}))).annotateMerge(O({title:`skill`,description:`Experimental skill routes.`})),mh=x({input:B(Ie)}).annotate({identifier:`Rpc.Input`}),hh=x({output:fe(Ie)}).annotate({identifier:`Rpc.Output`}),gh=j(`server.rpc`).add(T(`rpc.call`,`/api/rpc/:rpcID/:method`,{params:{rpcID:y,method:y},query:X,payload:mh,success:hh,error:[Wo,Go]}).annotateMerge(Z).annotateMerge(O({identifier:`rpc.call`,summary:`Call a plugin RPC`,description:`Dispatch a method to the currently registered RPC at the requested location.`}))).annotateMerge(O({title:`rpc`,description:`Plugin RPC routes.`})),_h=Lc.check(f(/^[^/#]+$/u)),vh=tl.check(f(/^[^#]+$/u)),yh=il.check(f(/^[^#]+$/u)),bh=x({providerID:_h,model:vh,variant:yh.pipe(B)}),xh=y.check(f(/^[^/#]+\/[^#]+(?:#[^#]+)?$/u)),Sh=C([xh,bh]).pipe(wt(bh,{decode:_t(e=>typeof e==`string`?Ch(e):e),encode:le({strict:!1})})).annotate({identifier:`Config.ModelSelection`});function Ch(e){let t=al.parse(e);return{providerID:t.providerID,model:t.id,...t.variant?{variant:t.variant}:{}}}var wh=ge(x(Jc.schema.fields),[b(y,yt(Te))]).annotate({identifier:`Config.Provider.Settings`}),Th=ge(x(cl.schema.fields),[b(y,yt(Te))]).annotate({identifier:`Config.Model.Settings`}),Eh=b(y,Te),Dh={settings:wh.pipe(B),headers:b(y,y).pipe(B),body:Eh.pipe(B)},Oh={settings:Th.pipe(B),headers:b(y,y).pipe(B),body:Eh.pipe(B)},kh=class extends p(`Config.Provider.Request`)({headers:Dh.headers,body:Dh.body}){},Ah=class extends p(`Config.Model.Cost.Cache`)({read:$c.pipe(B),write:$c.pipe(B)}){},jh=class extends p(`Config.Model.Cost`)({tier:x({type:m(`context`),size:a}).pipe(B),input:$c,output:$c,cache:Ah.pipe(B)}){},Mh=class extends p(`Config.Model.Limit`)({context:a.pipe(B),input:a.pipe(B),output:a.pipe(B)}){},Nh=C([x({supported:m(!1)}),x({supported:m(!0),toggle:g.pipe(B),effort:y.pipe(h,B),budget:x({min:a.pipe(B),max:a.pipe(B)}).pipe(B)})]).annotate({identifier:`Config.Model.Reasoning`}),Ph=class extends p(`Config.Model`)({modelID:tl.pipe(B),type:sl.pipe(B),family:ol.pipe(B),name:y.pipe(B),releaseDate:y.check(f(/^\d{4}-\d{2}(-\d{2})?$/u)).annotate({description:`Release date as YYYY-MM-DD or YYYY-MM`}).pipe(B),compatibility:Pc.pipe(B),package:y.pipe(B),...Oh,capabilities:ul.mapFields(e=>({tools:B(e.tools),input:B(e.input),output:B(e.output),temperature:e.temperature,reasoning:Nh.pipe(B)})).annotate({identifier:`Config.Model.Capabilities`}).pipe(B),variants:x({id:il,...Oh}).pipe(h,B),cost:C([jh,jh.pipe(h)]).pipe(B),disabled:g.pipe(B),limit:Mh.pipe(B)}){},Fh=class extends p(`Config.Provider`)({canonical:Lc.pipe(B),name:y.pipe(B),env:y.pipe(h,B),package:y.pipe(B),compatibility:Fc.pipe(B),...Dh,models:b(y,Ph).pipe(B)}){},Ih=y.check(f(/^#[0-9a-fA-F]{6}$/u)),Lh=class extends p(`Config.Agent`)({model:Sh.pipe(B),request:kh.pipe(B),system:y.pipe(B),description:y.pipe(B),mode:v([`subagent`,`primary`,`all`]).pipe(B),hidden:g.pipe(B),color:Ih.pipe(He(()=>ct),B),steps:R.pipe(B),disabled:g.pipe(B),permissions:Eu.pipe(B)}){},Rh=class extends p(`Config.Media.Image`)({auto_resize:g.pipe(B),max_width:R.pipe(B),max_height:R.pipe(B),max_base64_bytes:R.pipe(B)}){},zh=class extends p(`Config.Media`)({image:Rh.pipe(B)}){},Bh=class extends p(`Config.Compaction.Keep`)({tokens:z.pipe(B)}){},Vh=class extends p(`Config.Compaction`)({auto:g.pipe(B),keep:Bh.pipe(B),buffer:z.pipe(B)}){},Hh=class extends p(`Config.Command`)({template:y,description:y.pipe(B),agent:y.pipe(B),model:Sh.pipe(B),subagent:g.pipe(B),subtask:g.annotate({description:`Deprecated alias for subagent.`}).pipe(B)}){},Uh=v([`allow`,`deny`]),Wh=x({action:v([`provider.use`,`tool.use`,`integration.use`]),resource:y,effect:Uh}),Gh=class extends p(`ConfigExperimental.Info`)({portable_shell_scanner:g.pipe(B).annotate({description:`Enable the experimental portable shell permission scanner. Defaults to false.`}),todo:g.pipe(B).annotate({description:`Enable the experimental todowrite tool. Defaults to false.`}),background_compaction:g.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:g.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:C([ve,m(!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:Wh.pipe(h,B).annotate({description:`Deprecated: use top-level policies. Ordered policies controlling access to configured resources`})}){},Kh=class extends p(`Config.Formatter.Entry`)({disabled:g.pipe(B),command:y.pipe(h,B),environment:b(y,y).pipe(B),extensions:y.pipe(h,B)}){},qh=C([g,b(y,Kh)]),Jh=x({disabled:m(!0)}),Yh=class extends p(`Config.LSP.Server`)({command:y.pipe(h),extensions:y.pipe(h,B),disabled:g.pipe(B),env:b(y,y).pipe(B),initialization:b(y,Ie).pipe(B)}){},Xh=C([Jh,Yh]),Zh=C([g,b(y,Xh)]),Qh=class extends p(`Mcp.TimeoutConfig`)({startup:R.pipe(B).annotate({description:`Maximum time in milliseconds to establish and initialize the MCP server.`}),catalog:R.pipe(B).annotate({description:`Maximum time in milliseconds to wait for MCP discovery requests such as tools/list and prompts/list.`}),execution:R.pipe(B).annotate({description:`Maximum time in milliseconds to wait for MCP tool and prompt execution.`})}){},$h=v([`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.`}),eg=class extends p(`Mcp.LocalConfig`)({type:m(`local`),command:y.pipe(h),cwd:y.pipe(B).annotate({description:`Working directory for the MCP server process. Relative paths resolve from the workspace directory.`}),environment:b(y,y).pipe(B),disabled:g.pipe(B),codemode:g.pipe(B).annotate({description:`Expose this server's tools through Code Mode. Defaults to true.`}),timeout:Qh.pipe(B),protocol:$h.pipe(B)}){},tg=class extends p(`Mcp.OAuthConfig`)({client_id:y.pipe(B),client_secret:y.pipe(B),scope:y.pipe(B),callback_port:a.check(Pt({minimum:1,maximum:65535})).pipe(B),redirect_uri:y.pipe(B),auth_server_metadata_url:y.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.`})}){},ng=class extends p(`Mcp.RemoteConfig`)({type:m(`remote`),url:y,headers:b(y,y).pipe(B),oauth:C([tg,m(!1)]).pipe(B),disabled:g.pipe(B),codemode:g.pipe(B).annotate({description:`Expose this server's tools through Code Mode. Defaults to true.`}),timeout:Qh.pipe(B),protocol:$h.pipe(B)}){},rg=C([eg,ng]).pipe(ye(`type`)),ig=x({status:m(`connected`)}).annotate({identifier:`Mcp.Status.Connected`}),ag=x({status:m(`pending`)}).annotate({identifier:`Mcp.Status.Pending`}),og=x({status:m(`disabled`)}).annotate({identifier:`Mcp.Status.Disabled`}),sg=x({status:m(`failed`),error:y}).annotate({identifier:`Mcp.Status.Failed`}),cg=x({status:m(`needs_auth`),error:y}).annotate({identifier:`Mcp.Status.NeedsAuth`}),lg=C([ig,ag,og,sg,cg]).pipe(ye(`status`)),ug=x({name:y,status:lg,title:B(y),integrationID:B(Cs)}).annotate({identifier:`Mcp.Server`}),dg=x({server:y,name:y,uri:y,description:B(y),mimeType:B(y)}).annotate({identifier:`Mcp.Resource`}),fg=x({server:y,name:y,uriTemplate:y,description:B(y),mimeType:B(y)}).annotate({identifier:`Mcp.ResourceTemplate`}),pg=x({resources:h(dg),templates:h(fg)}).annotate({identifier:`Mcp.ResourceCatalog`}),mg=C([x({type:m(`text`),uri:y,text:y,mimeType:B(y)}),x({type:m(`blob`),uri:y,blob:y,mimeType:B(y)})]).pipe(ye(`type`),D({identifier:`Mcp.ResourceContentPart`}));x({server:y,uri:y,contents:h(mg)}).annotate({identifier:`Mcp.ResourceContent`});var hg=Qh,gg=rg,_g=class extends p(`Config.MCP`)({timeout:hg.pipe(B),servers:b(y,gg).pipe(B)}){},vg=class extends p(`Config.Plugin.Entry`)({package:y,options:b(y,Ie).pipe(B)}){},yg=C([y,vg]).pipe(h),bg=class extends p(`Config.Reference.Git`)({repository:y,branch:y.pipe(B),description:y.pipe(B),hidden:g.pipe(B)}){},xg=class extends p(`Config.Reference.Local`)({path:y,description:y.pipe(B),hidden:g.pipe(B)}){},Sg=C([y,bg,xg]),Cg=b(y,Sg),wg=e({Event:()=>jg,ID:()=>Tg,Input:()=>Dg,Provider:()=>Eg,Response:()=>kg,Result:()=>Og,WebSearch:()=>wg}),Tg=y.pipe(A(`WebSearch.ID`),D({identifier:`WebSearch.ID`})),Eg=x({id:Tg,name:y}).annotate({identifier:`WebSearch.Provider`}),Dg=x({query:y,providerID:Tg.pipe(B)}).annotate({identifier:`WebSearch.Input`}),Og=x({url:y,title:y.pipe(B),content:y.pipe(B),time:x({published:N.pipe(B).annotate({description:`Publication time in milliseconds since the Unix epoch`})})}).annotate({identifier:`WebSearch.Result`}),kg=class extends p(`WebSearch.Response`)({providerID:Tg,results:h(Og)}){},Ag=U({type:`websearch.updated`,schema:{}}),jg={Updated:Ag,Definitions:W(Ag)},Mg=class extends p(`ConfigWebSearch.Info`)({provider:C([m(`random`).annotate({description:`Reuse a randomly selected provider until it is rate limited, then switch to another available provider.`}),Tg])}){},Ng=C([m(!1),Mg]),Pg=class extends p(`Config.ToolOutput`)({max_lines:R.pipe(B),max_bytes:R.pipe(B)}){},Fg=class extends p(`Config.Watcher`)({ignore:y.pipe(h,B)}){},Ig=class extends p(`Config.Warming`)({prompt:y.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")`})}){},Lg=C([g,Ig]),Rg=x({directory:St.pipe(ot(Ce())).annotate({description:`Parent directory for new worktrees, relative to the project's primary checkout when not absolute`})}).annotate({identifier:`Config.Worktree`}),zg=e({Config:()=>zg,Directory:()=>Ug,Document:()=>Hg,Entry:()=>Wg,Event:()=>Kg,Info:()=>Bg,Patch:()=>Vg}),Bg=class extends p(`Config.Info`)({$schema:B(y).annotate({description:`JSON schema reference for configuration validation`}),shell:y.pipe(B).annotate({description:`Default shell to use for terminal and shell tool execution`}),model:Sh.pipe(B).annotate({description:`Default model to use when no session or agent model is selected`}),default_agent:y.pipe(B).annotate({description:`Default primary agent to use when no session agent is selected`}),update:v([`disable`,`notify`,`auto`]).pipe(B).annotate({description:`Disable updates, notify when one is available, or install updates automatically`}),share:v([`manual`,`auto`,`disabled`]).pipe(B).annotate({description:`Control whether sessions may be shared manually, automatically, or not at all`}),enterprise:x({url:y.pipe(B)}).pipe(B).annotate({description:`Enterprise sharing service configuration`}),username:y.pipe(B).annotate({description:`Username displayed in conversations and used for telemetry identity`}),permissions:Eu.pipe(B).annotate({description:`Ordered tool permission rules applied to agent tool use`}),policies:Wh.pipe(h,B).annotate({description:`Ordered policies controlling access to providers, tools, and integrations`}),agents:b(y,Lh).pipe(B).annotate({description:`Named built-in agent overrides and custom agent definitions`}),snapshots:g.pipe(B).annotate({description:`Enable snapshots used for undo and revert behavior`}),watcher:Fg.pipe(B).annotate({description:`Filesystem watcher configuration`}),formatter:qh.pipe(B).annotate({description:`Enable built-in formatters or configure formatter overrides`}),lsp:Zh.pipe(B).annotate({description:`Enable built-in language servers or configure server overrides`}),media:zh.pipe(B).annotate({description:`Media processing configuration`}),tool_output:Pg.pipe(B).annotate({description:`Tool output truncation thresholds`}),mcp:_g.pipe(B).annotate({description:`MCP server configuration`}),compaction:Vh.pipe(B).annotate({description:`Conversation compaction behavior`}),skills:y.pipe(h,B).annotate({description:`Additional paths or URLs to discover skills from`}),commands:b(y,Hh).pipe(B).annotate({description:`Named slash command definitions`}),instructions:y.pipe(h,B).annotate({description:`Additional paths or URLs supplying ambient instructions`}),references:Cg.pipe(B).annotate({description:`Named local directories or Git repositories available as external context`}),websearch:Ng.pipe(B).annotate({description:`Web search provider selection`}),plugins:yg.pipe(B).annotate({description:`Ordered plugin enablement directives and external package declarations`}),worktree:Rg.pipe(B).annotate({description:`Directory defaults for local worktree creation`}),warming:Lg.pipe(B).annotate({description:`Keep recently active sessions warm with transient model requests (default: false)`}),providers:b(y,Fh).pipe(B),experimental:Gh.pipe(B)}){},Vg=x({shell:ce(y)}).annotate({identifier:`Config.Patch`}),Hg=class extends p(`Config.Document`)({type:m(`document`),path:ao.pipe(B),info:Bg}){},Ug=class extends p(`Config.Directory`)({type:m(`directory`),path:ao}){},Wg=C([Hg,Ug]).annotate({identifier:`Config.Entry`}),Gg=U({type:`config.updated`,schema:{}}),Kg={Updated:Gg,Definitions:W(Gg)},qg=e({CreateInput:()=>Yg,Directory:()=>Qg,Event:()=>i_,Info:()=>Zg,List:()=>t_,ListEntry:()=>$g,OperationError:()=>e_,RemoveInput:()=>Xg,StrategyID:()=>Jg,Worktree:()=>qg,adopt:()=>a_}),Jg=St.pipe(ot(Ce()),A(`Worktree.StrategyID`)),Yg=x({projectID:Fu,from:B(ao),branch:B(St.pipe(ot(Ce()))),directory:B(ao).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(y)}).annotate({identifier:`Worktree.CreateInput`}),Xg=x({projectID:Fu,directory:ao,force:g}).annotate({identifier:`Worktree.RemoveInput`}),Zg=x({directory:ao}).annotate({identifier:`Worktree.Info`}),Qg=x({directory:ao,strategy:B(y)}).annotate({identifier:`Worktree.Directory`}),$g=x({directory:ao,type:v([`root`,`worktree`])}).annotate({identifier:`Worktree.ListEntry`}),e_=class extends t()(`Worktree.OperationError`,{message:y,forceRequired:B(g)}){},t_=h(Qg).annotate({identifier:`Worktree.List`}),n_=U({type:`worktree.updated`,schema:{projectID:Fu}}),r_=H({type:`worktree.resolved`,durable:{aggregate:`projectID`,version:1},schema:{projectID:Fu,directory:ao,previous:Fu,adopted:B(h(Fu))}}),i_={Updated:n_,Resolved:r_,Definitions:W(n_,r_)};function a_(e,t){if(e.workspaceID||e.projectID!==t.previous&&e.projectID!==Fu.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)}}Ao([...cp,i_.Resolved]);var o_=U({type:`file.edited`,schema:{file:y}}),s_={Edited:o_,Definitions:W(o_)},c_=W(U({type:`installation.updated`,schema:{version:y}}),U({type:`installation.update-available`,schema:{version:y}})),l_=y.check(at(`per`)).pipe(A(`PermissionV1.ID`),so(e=>({ascending:t=>e.make(t??`per_`+po())}))),u_=v([`allow`,`deny`,`ask`]).annotate({identifier:`PermissionV1.Action`}),d_=x({permission:y,pattern:y,action:u_}).annotate({identifier:`PermissionV1.Rule`}),f_=h(d_).annotate({identifier:`PermissionV1.Ruleset`}),p_=x({id:l_,sessionID:mu,permission:y,patterns:h(y),metadata:b(y,Ie),always:h(y),tool:w(x({messageID:y,callID:y}))}).annotate({identifier:`PermissionV1.Request`}),m_=v([`once`,`always`,`reject`]),h_=x({reply:m_,message:w(y)}).annotate({identifier:`PermissionV1.ReplyBody`});x({projectID:Fu,patterns:h(y)}).annotate({identifier:`PermissionV1.Approval`}),x({...p_.fields,id:w(l_),ruleset:f_}).annotate({identifier:`PermissionV1.AskInput`}),x({requestID:l_,...h_.fields}).annotate({identifier:`PermissionV1.ReplyInput`}),W(U({type:`permission.asked`,schema:p_.fields}),U({type:`permission.replied`,schema:{sessionID:mu,requestID:l_,reply:m_}}));var g_=N.check(Mt(0)),__=y.check(at(`msg`)).pipe(A(`SessionV1.MessageID`),so(e=>({ascending:t=>e.make(t??`msg_`+po())}))),v_=y.check(at(`prt`)).pipe(A(`SessionV1.PartID`),so(e=>({ascending:t=>e.make(t??`prt_`+po())}))),y_=(e,t)=>{let n=x({name:m(e),data:x(t)}).annotate({identifier:e});return{Schema:n,EffectSchema:n}},b_=y_(`MessageOutputLengthError`,{}),x_=y_(`ProviderAuthError`,{providerID:y,message:y}),S_=y_(`MessageAbortedError`,{message:y}),C_=y_(`StructuredOutputError`,{message:y,retries:z}),w_=y_(`APIError`,{message:y,statusCode:w(z),isRetryable:g,responseHeaders:w(b(y,y)),responseBody:w(y),metadata:w(b(y,y))}),T_=y_(`ContextOverflowError`,{message:y,responseBody:w(y)}),E_=y_(`ContentFilterError`,{message:y}),D_=class extends p(`OutputFormatText`)({type:m(`text`)}){},O_=class extends p(`OutputFormatJsonSchema`)({type:m(`json_schema`),schema:b(y,rt).annotate({identifier:`SessionV1.JSONSchema`}),retryCount:z.pipe(w,Ee(ht(2)))}){},k_=C([D_,O_]).annotate({discriminator:`type`,identifier:`SessionV1.OutputFormat`}),A_={id:v_,sessionID:mu,messageID:__},j_=x({...A_,type:m(`snapshot`),snapshot:y}).annotate({identifier:`SessionV1.SnapshotPart`}),M_=x({...A_,type:m(`patch`),hash:y,files:h(y)}).annotate({identifier:`SessionV1.PatchPart`}),N_=x({...A_,type:m(`text`),text:y,synthetic:w(g),ignored:w(g),time:w(x({start:z,end:w(z)})),metadata:w(b(y,rt))}).annotate({identifier:`SessionV1.TextPart`}),P_=x({...A_,type:m(`reasoning`),text:y,metadata:w(b(y,rt)),time:x({start:z,end:w(z)})}).annotate({identifier:`SessionV1.ReasoningPart`}),F_={text:x({value:y,start:N,end:N}).annotate({identifier:`SessionV1.FilePartSourceText`})},I_=x({start:x({line:z,character:z}),end:x({line:z,character:z})}).annotate({identifier:`SessionV1.Range`}),L_=x({...F_,type:m(`file`),path:y}).annotate({identifier:`SessionV1.FileSource`}),R_=x({...F_,type:m(`symbol`),path:y,range:I_,name:y,kind:z}).annotate({identifier:`SessionV1.SymbolSource`}),z_=x({...F_,type:m(`resource`),clientName:y,uri:y}).annotate({identifier:`SessionV1.ResourceSource`}),B_=C([L_,R_,z_]).annotate({discriminator:`type`,identifier:`SessionV1.FilePartSource`}),V_=x({...A_,type:m(`file`),mime:y,filename:w(y),url:y,source:w(B_)}).annotate({identifier:`SessionV1.FilePart`}),H_=x({...A_,type:m(`agent`),name:y,source:w(x({value:y,start:z,end:z}))}).annotate({identifier:`SessionV1.AgentPart`}),U_=x({...A_,type:m(`compaction`),auto:g,overflow:w(g),tail_start_id:w(__)}).annotate({identifier:`SessionV1.CompactionPart`}),W_=x({...A_,type:m(`subtask`),prompt:y,description:y,agent:y,model:w(x({providerID:Lc,modelID:tl})),command:w(y)}).annotate({identifier:`SessionV1.SubtaskPart`}),G_=x({...A_,type:m(`retry`),attempt:z,error:w_.EffectSchema,time:x({created:z})}).annotate({identifier:`SessionV1.RetryPart`}),K_=x({...A_,type:m(`step-start`),snapshot:w(y)}).annotate({identifier:`SessionV1.StepStartPart`}),q_=x({...A_,type:m(`step-finish`),reason:y,snapshot:w(y),cost:N,tokens:x({total:w(N),input:N,output:N,reasoning:N,cache:x({read:N,write:N})})}).annotate({identifier:`SessionV1.StepFinishPart`}),J_=x({status:m(`pending`),input:b(y,rt),raw:y}).annotate({identifier:`SessionV1.ToolStatePending`}),Y_=x({status:m(`running`),input:b(y,rt),title:w(y),metadata:w(b(y,rt)),time:x({start:z})}).annotate({identifier:`SessionV1.ToolStateRunning`}),X_=x({status:m(`completed`),input:b(y,rt),output:y,title:y,metadata:b(y,rt),time:x({start:z,end:z,compacted:w(z)}),attachments:w(h(V_))}).annotate({identifier:`SessionV1.ToolStateCompleted`}),Z_=x({status:m(`error`),input:b(y,rt),error:y,metadata:w(b(y,rt)),time:x({start:z,end:z})}).annotate({identifier:`SessionV1.ToolStateError`}),Q_=C([J_,Y_,X_,Z_]).annotate({discriminator:`status`,identifier:`SessionV1.ToolState`}),$_=x({...A_,type:m(`tool`),callID:y,tool:y,state:Q_,metadata:w(b(y,rt))}).annotate({identifier:`SessionV1.ToolPart`}),ev={id:__,sessionID:A_.sessionID},tv=x({...ev,role:m(`user`),time:x({created:g_}),format:w(k_),summary:w(x({title:w(y),body:w(y),diffs:h(Gd)})),agent:y,model:x({providerID:Lc,modelID:tl,variant:w(y)}),system:w(y),tools:w(b(y,g))}).annotate({identifier:`SessionV1.UserMessage`}),nv=C([N_,W_,P_,V_,$_,K_,q_,j_,M_,H_,G_,U_]).annotate({discriminator:`type`,identifier:`SessionV1.Part`}),rv=C([x_.EffectSchema,y_(`UnknownError`,{message:y,ref:w(y)}).EffectSchema,b_.EffectSchema,S_.EffectSchema,C_.EffectSchema,T_.EffectSchema,E_.EffectSchema,w_.EffectSchema]).annotate({discriminator:`name`});x({id:w(v_),type:m(`text`),text:y,synthetic:w(g),ignored:w(g),time:w(x({start:z,end:w(z)})),metadata:w(b(y,rt))}).annotate({identifier:`SessionV1.TextPartInput`}),x({id:w(v_),type:m(`file`),mime:y,filename:w(y),url:y,source:w(B_)}).annotate({identifier:`SessionV1.FilePartInput`}),x({id:w(v_),type:m(`agent`),name:y,source:w(x({value:y,start:z,end:z}))}).annotate({identifier:`SessionV1.AgentPartInput`}),x({id:w(v_),type:m(`subtask`),prompt:y,description:y,agent:y,model:w(x({providerID:Lc,modelID:tl})),command:w(y)}).annotate({identifier:`SessionV1.SubtaskPartInput`});var iv=x({...ev,role:m(`assistant`),time:x({created:z,completed:w(z)}),error:w(rv),parentID:__,modelID:tl,providerID:Lc,mode:y,agent:y,path:x({cwd:y,root:y}),summary:w(g),cost:N,tokens:x({total:w(N),input:N,output:N,reasoning:N,cache:x({read:N,write:N})}),structured:w(rt),variant:w(y),finish:w(y)}).annotate({identifier:`SessionV1.AssistantMessage`}),av=C([tv,iv]).annotate({discriminator:`role`,identifier:`SessionV1.Message`}),ov={durable:{aggregate:`sessionID`,version:1}},sv=x({additions:N,deletions:N,files:N,diffs:B(h(Gd))}),cv=x({input:N,output:N,reasoning:N,cache:x({read:N,write:N})}),lv=x({url:y}),uv=x({messageID:__,partID:B(v_),snapshot:B(y),diff:B(y)}),dv=x({id:tl,providerID:Lc,variant:B(y)}),fv=x({id:mu,slug:y,projectID:Fu,workspaceID:B(_o),directory:y,path:B(y),parentID:B(mu),summary:B(sv),cost:B(N),tokens:B(cv),share:B(lv),title:B(y),agent:B(y),model:B(dv),version:y,metadata:B(b(y,rt)),time:x({created:z,updated:z,compacting:B(z),archived:B(N)}),permission:B(f_),revert:B(uv)}).annotate({identifier:`SessionV1.Info`}),pv={Created:H({type:`session.created`,...ov,schema:{sessionID:mu,info:fv}}),Updated:H({type:`session.updated`,...ov,schema:{sessionID:mu,info:fv}}),Deleted:H({type:`session.deleted`,...ov,schema:{sessionID:mu,info:fv}}),MessageUpdated:H({type:`message.updated`,...ov,schema:{sessionID:mu,info:av}}),MessageRemoved:H({type:`message.removed`,...ov,schema:{sessionID:mu,messageID:__}}),PartUpdated:H({type:`message.part.updated`,...ov,schema:{sessionID:mu,part:nv,time:N}}),PartRemoved:H({type:`message.part.removed`,...ov,schema:{sessionID:mu,messageID:__,partID:v_}})},mv=U({type:`message.part.delta`,schema:{sessionID:mu,messageID:__,partID:v_,field:y,delta:y}}),hv=U({type:`session.diff`,schema:{sessionID:mu,diff:h(Gd)}}),gv=U({type:`session.error`,schema:{sessionID:w(mu),error:iv.fields.error}});({...pv}),W(pv.Created,pv.Updated,pv.Deleted,pv.MessageUpdated,pv.MessageRemoved,pv.PartUpdated,pv.PartRemoved,mv,hv,gv);var _v=W(U({type:`command.executed`,schema:{name:y,sessionID:mu,arguments:y,messageID:__}})),vv=W(U({type:`lsp.updated`,schema:{}})),yv=W(U({type:`location.shutdown`,schema:{}})),bv=U({type:`mcp.tools.changed`,schema:{server:y}}),xv=U({type:`mcp.resources.changed`,schema:{server:y}}),Sv=U({type:`mcp.status.changed`,schema:{server:y}}),Cv=W(bv,xv,Sv),wv=U({type:`models-dev.refreshed`,schema:{}}),Tv={Refreshed:wv,Definitions:W(wv)},Ev=y.pipe(A(`Plugin.ID`),D({identifier:`Plugin.ID`})),Dv=C([x({type:m(`builtin`)}),x({type:m(`package`),target:y,version:y.pipe(B),outdated:m(!0).pipe(B),updating:m(!0).pipe(B)}),x({type:m(`local`),path:y}),x({type:m(`sdk`)})]).annotate({identifier:`Plugin.Source`}),Ov=x({server:m(!0).pipe(B),tui:m(!0).pipe(B),rpc:m(!0).pipe(B),gui:m(!0).pipe(B)}).annotate({identifier:`Plugin.Features`}),kv=x({code:y,revision:y,options:b(y,Te)}).annotate({identifier:`Plugin.GuiBundle`}),Av=C([x({status:m(`active`)}),x({status:m(`failed`),error:y,ref:y.pipe(B)})]).annotate({identifier:`Plugin.State`}),jv=x({id:Ev.pipe(B),source:Dv,features:Ov,state:Av}).annotate({identifier:`Plugin.Info`}),Mv=U({type:`plugin.updated`,schema:{}}),Nv={Updated:Mv,Definitions:W(Mv)},Pv=e({Event:()=>Iv,GitSource:()=>Rv,Info:()=>Bv,LocalSource:()=>Lv,Reference:()=>Pv,Source:()=>zv}),Fv=U({type:`reference.updated`,schema:{}}),Iv={Updated:Fv,Definitions:W(Fv)},Lv=x({type:m(`local`),path:ao,description:y.pipe(B),hidden:g.pipe(B)}).annotate({identifier:`Reference.LocalSource`}),Rv=x({type:m(`git`),repository:y,branch:y.pipe(B),description:y.pipe(B),hidden:g.pipe(B)}).annotate({identifier:`Reference.GitSource`}),zv=C([Lv,Rv]).pipe(ye(`type`)).annotate({identifier:`Reference.Source`}),Bv=x({name:y,path:ao,description:y.pipe(B),hidden:g.pipe(B),source:zv}).annotate({identifier:`Reference.Info`}),Vv=W(U({type:`server.connected`,schema:{}}),U({type:`global.disposed`,schema:{}})),Hv=W(U({type:`session.status`,identifier:`SessionStatusUpdated`,schema:{sessionID:mu,status:C([x({type:m(`idle`)}),x({type:m(`retry`),attempt:z,message:y,action:B(x({reason:y,provider:y,title:y,message:y,label:y,link:B(y)})),next:z}),x({type:m(`busy`)})]).annotate({identifier:`SessionStatus`})}}),U({type:`session.idle`,schema:{sessionID:mu}})),Uv=W(U({type:`tui.prompt.append`,schema:{text:y}}),U({type:`tui.command.execute`,schema:{command:C([v([`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`]),y])}}),U({type:`tui.toast.show`,schema:{title:B(y),message:y,variant:v([`info`,`success`,`warning`,`error`]),duration:R.pipe(Ee(ht(5e3))).annotate({description:`Duration in milliseconds`})}}),U({type:`tui.session.select`,schema:{sessionID:mu.annotate({description:`Session ID to navigate to`})}})),Wv=W(U({type:`vcs.branch.updated`,schema:{branch:B(y)}})),Gv=x({workspaceID:_o,status:v([`connected`,`connecting`,`disconnected`,`error`])}).annotate({identifier:`WorkspaceEvent.ConnectionStatus`}),Kv=W(U({type:`workspace.ready`,schema:{name:y}}),U({type:`workspace.failed`,schema:{message:y}}),U({type:`workspace.status`,schema:Gv.fields})),qv=W(U({type:`worktree.ready`,schema:{name:y,branch:B(y)}}),U({type:`worktree.failed`,schema:{message:y}})),Jv=W(...sp),Yv=W(...yv,...Tv.Definitions,...ks.Definitions,...xc.Definitions,...zc.Definitions,...rl.Definitions,...Nu.Definitions,...Jv),Xv=W(...Xm.Definitions,...Iv.Definitions,...Cu.Definitions,...Nv.Definitions,...Wu.Definitions,...i_.Definitions,...dh.Definitions,...Kg.Definitions,...zo.Definitions,...du.Definitions,...Pp.Definitions,...id.Definitions,...uc.Definitions,...jg.Definitions),Zv=W(...Yv,...Xv,...Hv,...Uv,...c_,...Wv,Sv,xv);Oo(Zv),Oo(W(...Yv,...c_,...Xv,...vv,...Uv,...Cv,..._v,...s_.Definitions,...Hv,...Wv,...Kv,...qv,...Vv));var Qv={id:wo,metadata:w(b(y,Ie)),location:w(bo)},$v=x({id:wo,created:N,metadata:w(b(y,Ie)),type:Ke([`rpc.`,y]),location:bo,data:b(y,Ie)}).annotate({identifier:`V2Event.rpc`}),ey=e=>C([...e,$v,...e.some(e=>e.type===`server.connected`)?[]:[x({...Qv,type:m(`server.connected`),data:x({})}).annotate({identifier:`V2Event.server.connected`})]]).annotate({identifier:`V2Event`}),ty=e=>x({types:w(de(C([v(e.map(e=>e.type)),$v.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`}),ny=(e=>{let t=ey(e);return{schema:t,group:j(`server.event`).add(k(`event.subscribe`,`/api/event`,{query:ty(e),success:qe({data:t})}).annotateMerge(O({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(O({title:`event`,description:`Experimental event stream routes.`}))}})(Zv),ry=ny.group;ny.schema;var iy=j(`server.agent`).add(k(`agent.list`,`/api/agent`,{query:X,success:V(h(Mu)),error:Yo}).annotateMerge(Z).annotateMerge(O({identifier:`agent.list`,summary:`List agents`,description:`Retrieve currently registered agents.`}))).add(k(`agent.get`,`/api/agent/:agentID`,{params:{agentID:ku},query:X,success:V(Mu),error:is}).annotateMerge(Z).annotateMerge(O({identifier:`agent.get`,summary:`Get agent`,description:`Retrieve a single currently registered agent.`}))).annotateMerge(O({title:`agent`})),ay=j(`server.plugin`).add(k(`plugin.list`,`/api/plugin`,{query:X,success:V(h(jv))}).annotateMerge(Z).annotateMerge(O({identifier:`plugin.list`,summary:`List plugins`,description:`Retrieve enabled server plugins and their current status.`}))).add(k(`plugin.gui`,`/api/plugin/gui`,{query:x({...X.fields,id:Ev}),success:V(kv),error:rs}).annotateMerge(Z).annotateMerge(O({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(T(`plugin.check`,`/api/plugin/check`,{query:X,payload:x({target:y.pipe(w)}),success:V(h(jv)),error:Uo}).annotateMerge(Z).annotateMerge(O({identifier:`plugin.check`,summary:`Check plugin updates`,description:`Check one or all package plugins for available updates.`}))).add(T(`plugin.update`,`/api/plugin/update`,{query:X,payload:x({targets:h(y)}),success:S,error:[Uo,Yo]}).annotateMerge(Z).annotateMerge(O({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(O({title:`plugin`,description:`Experimental plugin routes.`})),oy=x({version:y,pid:a.check(Mt(0)),hostname:w(y),urls:h(y),paths:x({tmp:y}),capabilities:w(x({persistentPty:w(g)}))}).annotate({identifier:`ServerInfo`}),sy=x({code:y,expires_in:a}).annotate({identifier:`PairingCode`}),cy=x({token:y}).annotate({identifier:`PairingSession`}),ly=j(`server.server`).add(k(`server.info`,`/api/info`,{success:oy}).annotateMerge(O({identifier:`server.info`,summary:`Get server info`,description:`Return the server identity, connection URLs, paths, and readiness status.`}))).add(T(`server.pair`,`/api/pair`,{success:sy}).annotateMerge(O({identifier:`server.pair`,summary:`Create pairing code`,description:`Create a short-lived, single-use code for a /auth/connect/:code pairing link.`}))).add(k(`server.connect`,`/auth/connect/:code`,{params:{code:y},success:cy,error:Ko}).annotateMerge(O({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(O({title:`server`})),uy=j(`server.debug`).add(T(`debug.heapDump`,`/api/debug/heap-dump`,{query:x({directory:y.pipe(w,D({description:`Absolute server-local directory to write the snapshot into, created when missing. Defaults to the server's log directory.`}))}),success:x({path:y,pid:a,memory:x({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:[Uo,Xo]}).annotateMerge(O({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(k(`debug.location`,`/api/debug/location`,{success:h(bo)}).annotateMerge(O({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:S}).annotateMerge(Z).annotateMerge(O({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(O({title:`debug`})),dy=j(`server.shell`).add(k(`shell.list`,`/api/shell`,{query:X,success:V(h(ed))}).annotateMerge(Z).annotateMerge(O({identifier:`shell.list`,summary:`List running shell commands`,description:`List currently running shell commands for a location. Exited commands are not included.`}))).add(T(`shell.create`,`/api/shell`,{query:X,payload:ad,success:V(ed)}).annotateMerge(Z).annotateMerge(O({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(k(`shell.get`,`/api/shell/:id`,{params:{id:Xu},query:X,success:V(ed),error:vs}).annotateMerge(Z).annotateMerge(O({identifier:`shell.get`,summary:`Get shell command`,description:`Get one shell command, including its status and exit code once exited.`}))).add(k(`shell.output`,`/api/shell/:id/output`,{params:{id:Xu},query:x({...X.fields,...od.fields}),success:V(sd),error:vs}).annotateMerge(Z).annotateMerge(O({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:Xu},query:X,success:S}).annotateMerge(Z).annotateMerge(O({identifier:`shell.remove`,summary:`Remove shell command`,description:`Terminate and remove one shell command and its retained output.`}))).annotateMerge(O({title:`shell`,description:`Location-scoped shell command routes.`})),fy=x(re(Lv.fields,[`description`,`hidden`])).annotate({identifier:`Reference.LocalSource`}),py=x(re(Rv.fields,[`description`,`hidden`])).annotate({identifier:`Reference.GitSource`}),my=C([fy,py]).pipe(ye(`type`)).annotate({identifier:`Reference.Source`}),hy=x({...re(Bv.fields,[`source`]),source:my}).annotate({identifier:`Reference.Info`}),gy=j(`server.reference`).add(k(`reference.list`,`/api/reference`,{query:X,success:V(h(hy))}).annotateMerge(Z).annotateMerge(O({identifier:`reference.list`,summary:`List references`,description:`List references available in the requested location.`}))).annotateMerge(O({title:`reference`,description:`Location-scoped project references.`})),_y=class extends tt()(`@opencode/HttpApiAuthorization`,{error:Ko}){},vy=j(`server.integration`).add(k(`integration.list`,`/api/integration`,{query:X,success:V(h(Cc))}).annotateMerge(Z).annotateMerge(O({identifier:`integration.list`,summary:`List integrations`,description:`Retrieve available integrations and their authentication methods.`}))).add(k(`integration.get`,`/api/integration/:integrationID`,{params:{integrationID:fc},query:X,success:V(Cc),error:Qo}).annotateMerge(Z).annotateMerge(O({identifier:`integration.get`,summary:`Get integration`,description:`Retrieve one integration and its authentication methods.`}))).add(T(`integration.wellknown.add`,`/api/experimental/integration/wellknown`,{query:X,payload:x({url:y}),success:S,error:Uo}).annotateMerge(Z).annotateMerge(O({identifier:`experimental.integration.wellknown.add`,summary:`Add wellknown integration`,description:`Discover and persist an experimental wellknown integration source.`}))).add(T(`integration.connect.key`,`/api/integration/:integrationID/connect/key`,{params:{integrationID:fc},query:X,payload:x({key:y,answer:w(rc),label:w(y)}),success:S,error:[Qo,Uo]}).annotateMerge(Z).annotateMerge(O({identifier:`integration.connect.key`,summary:`Connect with key`,description:`Run a key authentication method and store the resulting credential.`}))).add(T(`integration.connect.external`,`/api/integration/:integrationID/connect/external`,{params:{integrationID:fc},query:X,payload:x({methodID:pc,answer:w(rc),label:w(y)}),success:S,error:[Qo,Uo]}).annotateMerge(Z).annotateMerge(O({identifier:`integration.connect.external`,summary:`Connect with external credentials`,description:`Run an external authentication method and store a reference to its credential source.`}))).add(T(`integration.oauth.connect`,`/api/integration/:integrationID/connect/oauth`,{params:{integrationID:fc},query:X,payload:x({methodID:pc,answer:w(rc),label:w(y)}),success:V(Ec),error:Uo}).annotateMerge(Z).annotateMerge(O({identifier:`integration.oauth.connect`,summary:`Begin OAuth connection`,description:`Start an OAuth attempt and return the authorization details.`}))).add(k(`integration.oauth.status`,`/api/integration/:integrationID/connect/oauth/:attemptID`,{params:{integrationID:fc,attemptID:wc},query:X,success:V(Dc),error:[Qo,$o]}).annotateMerge(Z).annotateMerge(O({identifier:`integration.oauth.status`,summary:`Get OAuth attempt status`,description:`Poll the current status of an OAuth attempt.`}))).add(T(`integration.oauth.complete`,`/api/integration/:integrationID/connect/oauth/:attemptID/complete`,{params:{integrationID:fc,attemptID:wc},query:X,payload:x({code:w(y)}),success:S,error:[Qo,$o,Uo]}).annotateMerge(Z).annotateMerge(O({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:fc,attemptID:wc},query:X,success:S}).annotateMerge(Z).annotateMerge(O({identifier:`integration.oauth.cancel`,summary:`Cancel OAuth connection`,description:`Cancel an OAuth attempt and release its resources.`}))).add(T(`integration.command.connect`,`/api/integration/:integrationID/connect/command`,{params:{integrationID:fc},query:X,payload:x({methodID:pc,label:w(y)}),success:V(Oc),error:[Qo,es,Uo]}).annotateMerge(Z).annotateMerge(O({identifier:`integration.command.connect`,summary:`Begin command connection`,description:`Start a command authentication attempt.`}))).add(k(`integration.command.status`,`/api/integration/:integrationID/connect/command/:attemptID`,{params:{integrationID:fc,attemptID:wc},query:X,success:V(kc),error:[Qo,$o]}).annotateMerge(Z).annotateMerge(O({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:fc,attemptID:wc},query:X,success:S}).annotateMerge(Z).annotateMerge(O({identifier:`integration.command.cancel`,summary:`Cancel command connection`,description:`Cancel a command authentication attempt and terminate its process.`}))).annotateMerge(O({title:`integration`,description:`Integration discovery and authentication routes.`})),yy=j(`server.websearch`).add(k(`websearch.providers`,`/api/websearch/provider`,{query:X,success:V(h(Eg)),error:Yo}).annotateMerge(Z).annotateMerge(O({identifier:`websearch.providers`,summary:`List web search providers`,description:`Return the registered web search providers.`}))).add(T(`websearch.query`,`/api/websearch`,{query:X,payload:x(Dg.fields),success:V(kg),error:[Uo,Yo]}).annotateMerge(Z).annotateMerge(O({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(O({title:`websearch`,description:`Location-scoped web search routes.`})),by=N.check(Pt({minimum:0,maximum:100})),xy=N.annotate({description:`Milliseconds since the Unix epoch`}),Sy=x({percent:by,limited:g,resetsAt:xy}).annotate({identifier:`UsageLimits.Meter`}),Cy=x({rolling:Sy,weekly:Sy,monthly:Sy}).annotate({identifier:`UsageLimits.Go`}),wy=x({providerID:Lc,modelID:tl,name:y,spent:Qc.pipe(B)}).annotate({identifier:`UsageLimits.BudgetModel`}),Ty=x({id:y,limit:Qc,spent:Qc,scope:v([`each`,`combined`]),per:v([`set`,`model`]),coverage:v([`all`,`models`]),models:h(wy),vendors:h(y),inputPriceAtLeast:$c.pipe(B),picked:g,shared:g,resetsAt:xy}).annotate({identifier:`UsageLimits.Budget`}),Ey=x({workspace:x({id:y,name:y.pipe(B),usageURL:y}),go:Cy.pipe(B),budgets:h(Ty)}).annotate({identifier:`UsageLimits.Info`}),Dy=j(`server.usage`).add(k(`usage.limits`,`/api/experimental/usage/limits`,{query:X,success:V(ce(Ey)),error:Yo}).annotateMerge(Z).annotateMerge(O({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(O({title:`usage`,description:`Experimental usage limit routes.`})),Oy=`/api/experimental/client-mcp`,ky=x({...X.fields,name:y.check(f(/^[a-zA-Z0-9_-]+$/))}),Ay=e=>j(`server.mcp`).add(k(`mcp.list`,`/api/mcp`,{query:X,success:V(h(ug))}).annotateMerge(Z).annotateMerge(O({identifier:`mcp.list`,summary:`List MCP servers`,description:`Retrieve configured MCP servers and their connection status.`}))).add(Ct(`mcp.add`,`/api/experimental/mcp/:server`,{params:{server:y},query:X,payload:x({config:rg}),success:S}).annotateMerge(Z).annotateMerge(O({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:y},query:X,success:S,error:ss}).annotateMerge(Z).annotateMerge(O({identifier:`experimental.mcp.remove`,summary:`Remove MCP server`,description:`Stop an MCP server and remove it from the runtime set until restart.`}))).add(T(`mcp.connect`,`/api/experimental/mcp/:server/connect`,{params:{server:y},query:X,success:S,error:ss}).annotateMerge(Z).annotateMerge(O({identifier:`experimental.mcp.connect`,summary:`Connect MCP server`,description:`Connect an MCP server at runtime, overriding a disabled configuration until restart.`}))).add(T(`mcp.disconnect`,`/api/experimental/mcp/:server/disconnect`,{params:{server:y},query:X,success:S,error:ss}).annotateMerge(Z).annotateMerge(O({identifier:`experimental.mcp.disconnect`,summary:`Disconnect MCP server`,description:`Disconnect an MCP server at runtime, removing its tools until reconnected.`}))).add(k(`mcp.resource.catalog`,`/api/mcp/resource`,{query:X,success:V(pg)}).annotateMerge(Z).annotateMerge(O({identifier:`mcp.resource.catalog`,summary:`List MCP resources`,description:`Retrieve resources and resource templates from connected MCP servers.`}))).add(T(`mcp.clientToken`,`${Oy}/token`,{query:ky,headers:x({[Rp]:w(y)}),success:V(Fp),error:gs}).annotateMerge(Z).annotateMerge(O({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(k(`mcp.client`,Oy,{query:x({...ky.fields,[Lp]:w(y)}),success:g,error:[gs,Ho]}).annotateMerge(Z).annotateMerge(O({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(O({title:`mcp`,description:`MCP server and resource routes.`})),jy=j(`server.credential`).add(k(`credential.list`,`/api/credential`,{success:x({data:h(Ps)})}).annotateMerge(O({identifier:`credential.list`,summary:`List credentials`,description:`List every stored integration credential, including its secret value.`}))).add(T(`credential.create`,`/api/credential`,{payload:Fs,success:x({data:Ps}),error:qo}).annotateMerge(O({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(Be(`credential.update`,`/api/credential/:credentialID`,{params:{credentialID:Es},payload:x({label:y}),success:S}).annotateMerge(O({identifier:`credential.update`,summary:`Update credential`,description:`Update a stored credential label.`}))).annotateMerge(O({title:`credential`})).add(T(`credential.activate`,`/api/credential/:credentialID/activate`,{params:{credentialID:Es},success:S}).annotateMerge(O({identifier:`credential.activate`,summary:`Activate credential`,description:`Activate a stored integration credential.`}))).add(ft(`credential.remove`,`/api/credential/:credentialID`,{params:{credentialID:Es},success:S}).annotateMerge(O({identifier:`credential.remove`,summary:`Remove credential`,description:`Remove a stored integration credential.`}))),My=`/api/project`,Ny=x(re(Hu.fields,[`projectID`])),Py=v([`true`,`false`]).pipe(wt(g,{decode:_t(e=>e===`true`),encode:_t(e=>e?`true`:`false`)})),Fy=j(`server.project`).add(k(`project.list`,My,{query:x({archived:Py.pipe(w)}),success:h(Vu)}).annotateMerge(O({identifier:`project.list`,summary:`List projects`,description:`List known projects. Archived projects are excluded unless archived=true.`}))).add(Be(`project.update`,`${My}/:projectID`,{params:{projectID:Fu},payload:Ny,success:Vu,error:ts}).annotateMerge(O({identifier:`project.update`,summary:`Update project`,description:`Update the project canonical directory, display metadata, and workspace commands.`}))).annotateMerge(O({title:`project`,description:`Project routes.`})),Iy=`/api/worktree`,Ly=class extends t()(`WorktreeError`,{name:m(`WorktreeError`),data:x({message:y,forceRequired:w(g)})},{httpApiStatus:400}){},Ry=j(`server.worktree`).add(k(`worktree.list`,Iy,{query:x({projectID:Fu}),success:t_,error:ts}).annotateMerge(O({identifier:`worktree.list`,summary:`List worktrees`,description:`Return the project's saved worktree inventory without loading configuration or running discovery.`}))).add(T(`worktree.create`,Iy,{payload:Yg,success:Zg,error:[Ly,ts]}).annotateMerge(O({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`,Iy,{payload:Xg,success:S,error:[Ly,ts]}).annotateMerge(O({identifier:`worktree.remove`,summary:`Remove worktree`,description:`Load the project's canonical configuration and remove a saved worktree using its recorded strategy.`}))).add(T(`worktree.refresh`,`${Iy}/refresh`,{payload:x({projectID:Fu}),success:S,error:[Ly,ts]}).annotateMerge(O({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(O({title:`worktree`,description:`Project-based worktree management routes.`})),zy=e({Base:()=>Uy,Branch:()=>By,BranchList:()=>Hy,FileStatus:()=>Ky,Info:()=>Vy,Mode:()=>Wy,Untracked:()=>Gy,Vcs:()=>zy}),By=x({current:B(y),default:B(y)}).annotate({identifier:`Vcs.Branch`}),Vy=x({provider:B(y),branch:By}).annotate({identifier:`Vcs.Info`}),Hy=h(y).annotate({identifier:`Vcs.BranchList`}),Uy=x({name:y,ref:y,source:v([`reflog`,`default`])}).annotate({identifier:`Vcs.Base`}),Wy=v([`working`,`branch`,`committed`]).annotate({identifier:`Vcs.Mode`}),Gy=v([`files`,`folders`]).annotate({identifier:`Vcs.Untracked`}),Ky=x({file:y,additions:z,deletions:z,status:v([`added`,`deleted`,`modified`])}).annotate({identifier:`Vcs.FileStatus`}),qy=x({...X.fields,provider:w(y)}),Jy=class extends t()(`VcsInitNotSupportedError`,{providerID:y,message:y},{httpApiStatus:501}){},Yy=x({...X.fields,search:w(y),limit:oe.pipe(wt(R),w)}),Xy=x({...X.fields,mode:Wy,base:B(y),context:oe.pipe(wt(z),w),untracked:B(Gy)}),Zy=j(`server.vcs`).add(T(`vcs.init`,`/api/vcs/init`,{query:qy,success:S,error:[qo,Uo,Jy,Yo]}).annotateMerge(Z).annotateMerge(O({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(k(`vcs.get`,`/api/vcs`,{query:X,success:V(Vy)}).annotateMerge(Z).annotateMerge(O({identifier:`vcs.get`,summary:`VCS info`,description:`Get current and default branch information for the requested location.`}))).add(k(`vcs.base`,`/api/vcs/base`,{query:X,success:V(ce(Uy)),error:Yo}).annotateMerge(Z).annotateMerge(O({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(k(`vcs.status`,`/api/vcs/status`,{query:X,success:V(h(Ky))}).annotateMerge(Z).annotateMerge(O({identifier:`vcs.status`,summary:`VCS status`,description:`List uncommitted working-copy changes relative to the requested location.`}))).add(k(`vcs.branch.list`,`/api/vcs/branch`,{query:Yy,success:V(Hy)}).annotateMerge(Z).annotateMerge(O({identifier:`vcs.branch.list`,summary:`VCS branches`,description:`List local and remote branches available at the requested location.`}))).add(k(`vcs.diff`,`/api/vcs/diff`,{query:Xy,success:V(h(Wd)),error:Yo}).annotateMerge(Z).annotateMerge(O({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(O({title:`vcs`,description:`Location-scoped version control routes.`})),Qy=x({label:y,numerator:w(a.check(Mt(0))),denominator:w(a.check(Mt(0)))}),$y=C([x({status:v([`required`,`completed`])}),x({status:m(`running`),progress:Qy}),x({status:m(`error`),error:y})]),eb=j(`server.migration`).add(k(`migration.v1.status`,`/api/experimental/migration/v1`,{success:$y}).annotateMerge(O({identifier:`experimental.migration.v1.status`,summary:`Get V1 migration status`,description:`Return the progress of the V1 to V2 session history migration.`}))).annotateMerge(O({title:`migration`})),tb=x({path:y,name:y,acceptable:g}).annotate({identifier:`ConfigShell.Option`}),nb=j(`server.config`).add(k(`config.get`,`/api/config`,{query:X,success:h(Wg)}).annotateMerge(Z).annotateMerge(O({identifier:`config.get`,summary:`Get configuration`,description:`Return configuration documents and discovery sources for the requested location, from lowest to highest priority.`}))).add(k(`config.shells`,`/api/config/shell`,{success:h(tb)}).annotateMerge(O({identifier:`config.shells`,summary:`List available shells`,description:`Return shells available to terminal and agent execution.`}))).add(Be(`config.update`,`/api/experimental/config`,{payload:Vg,success:S}).annotateMerge(O({identifier:`experimental.config.update`,summary:`Update global configuration`,description:`Patch supported fields in the highest-precedence global configuration document.`}))).annotateMerge(O({title:`config`,description:`Location-scoped configuration routes.`})),rb=(e,t,n,r)=>Pe(`server`).add(ly).add(Ip(t)).add(iy.middleware(t)).add(ay.middleware(t)).add(Um(r,n)).add(am).add(sm.middleware(t)).add(tu).add($p).add(cm.middleware(t)).add(vy.middleware(t)).add(Ay(t)).add(jy).add(Fy).add(sh(t)).add(qm(t,r)).add(oh.middleware(t)).add(fh.middleware(t)).add(ph.middleware(t)).add(gh.middleware(t)).add(e).add(Bp(t)).add(Wp).add(dy.middleware(t)).add(gy.middleware(t)).add(Ry).add(Zy.middleware(t)).add(uy).add(eb).add(yy.middleware(t)).add(Dy.middleware(t)).add(nb.middleware(t)).annotateMerge(O({title:`opencode HttpApi`,version:`0.0.1`,description:`Experimental HttpApi surface for selected instance routes.`})).middleware(_y).middleware(Ss),ib=e=>rb(ry,e.locationMiddleware,e.formLocationMiddleware,e.sessionLocationMiddleware),ab=class extends tt()(`@opencode/client/LocationMiddleware`,{error:[Ho]}){},ob=class extends tt()(`@opencode/client/SessionLocationMiddleware`,{error:[Uo,G,Ho]}){},sb=ib({locationMiddleware:ab,formLocationMiddleware:ob,sessionLocationMiddleware:ob});ra({},{make:()=>kC});var Q=e=>Tt(e)||he(e)||st.is(e)?new ro({cause:e}):e,$=()=>e=>e,cb=()=>e=>e,lb=e=>()=>$()(e[`server.info`]({}).pipe(M(Q))),ub=e=>()=>$()(e[`server.pair`]({}).pipe(M(Q))),db=e=>t=>$()(e[`server.connect`]({params:{code:t.code}}).pipe(M(Q))),fb=e=>({info:lb(e),pair:ub(e),connect:db(e)}),pb=e=>t=>$()(e[`location.get`]({query:{location:t?.location}}).pipe(M(Q))),mb=e=>()=>$()(e[`location.reload`]({}).pipe(M(Q))),hb=e=>({get:pb(e),reload:mb(e)}),gb=e=>t=>$()(e[`agent.list`]({query:{location:t?.location}}).pipe(M(Q))),_b=e=>t=>$()(e[`agent.get`]({params:{agentID:t.agentID},query:{location:t.location}}).pipe(M(Q))),vb=e=>({list:gb(e),get:_b(e)}),yb=e=>t=>$()(e[`plugin.list`]({query:{location:t?.location}}).pipe(M(Q))),bb=e=>t=>$()(e[`plugin.gui`]({query:{location:t.location,id:t.id}}).pipe(M(Q))),xb=e=>t=>$()(e[`plugin.check`]({query:{location:t?.location},payload:{target:t?.target}}).pipe(M(Q))),Sb=e=>t=>$()(e[`plugin.update`]({query:{location:t.location},payload:{targets:t.targets}}).pipe(M(Q))),Cb=e=>({list:yb(e),gui:bb(e),check:xb(e),update:Sb(e)}),wb=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(M(Q))),Tb=e=>t=>$()(e[`session.stats`]({query:{from:t?.from,to:t?.to,project:t?.project,timezone:t?.timezone,tools:t?.tools}}).pipe(M(Q),E(e=>e.data))),Eb=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(M(Q),E(e=>e.data))),Db=e=>t=>$()(e[`session.import`]({payload:{info:t.info,messages:t.messages,location:t.location}}).pipe(M(Q),E(e=>e.data))),Ob=e=>t=>$()(e[`session.export`]({params:{sessionID:t.sessionID},query:{sanitize:t.sanitize}}).pipe(M(Q),E(e=>e.data))),kb=e=>()=>$()(e[`session.active`]({}).pipe(M(Q),E(e=>e.data))),Ab=e=>t=>$()(e[`session.get`]({params:{sessionID:t.sessionID}}).pipe(M(Q),E(e=>e.data))),jb=e=>t=>$()(e[`session.remove`]({params:{sessionID:t.sessionID}}).pipe(M(Q))),Mb=e=>t=>$()(e[`session.fork`]({params:{sessionID:t.sessionID},payload:{before:t.before}}).pipe(M(Q),E(e=>e.data))),Nb=e=>t=>$()(e[`session.switchAgent`]({params:{sessionID:t.sessionID},payload:{agent:t.agent}}).pipe(M(Q))),Pb=e=>t=>$()(e[`session.switchModel`]({params:{sessionID:t.sessionID},payload:{model:t.model}}).pipe(M(Q))),Fb=e=>t=>$()(e[`session.update`]({params:{sessionID:t.sessionID},payload:{title:t.title,metadata:t.metadata,permissions:t.permissions,archived:t.archived}}).pipe(M(Q))),Ib=e=>t=>$()(e[`session.move`]({params:{sessionID:t.sessionID},payload:{directory:t.directory,delivery:t.delivery}}).pipe(M(Q))),Lb=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(M(Q),E(e=>e.data))),Rb=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(M(Q))),zb=e=>t=>$()(e[`session.skill`]({params:{sessionID:t.sessionID},payload:{id:t.id,resume:t.resume}}).pipe(M(Q))),Bb=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(M(Q),E(e=>e.data))),Vb=e=>t=>$()(e[`session.shell`]({params:{sessionID:t.sessionID},payload:{id:t.id,command:t.command}}).pipe(M(Q))),Hb=e=>t=>$()(e[`session.compact`]({params:{sessionID:t.sessionID},payload:{id:t.id,delivery:t.delivery}}).pipe(M(Q),E(e=>e.data))),Ub=e=>t=>$()(e[`session.wait`]({params:{sessionID:t.sessionID}}).pipe(M(Q))),Wb=e=>t=>$()(e[`session.revert.stage`]({params:{sessionID:t.sessionID},payload:{messageID:t.messageID,files:t.files}}).pipe(M(Q),E(e=>e.data))),Gb=e=>t=>$()(e[`session.revert.clear`]({params:{sessionID:t.sessionID}}).pipe(M(Q))),Kb=e=>t=>$()(e[`session.revert.commit`]({params:{sessionID:t.sessionID}}).pipe(M(Q))),qb=e=>t=>$()(e[`session.context`]({params:{sessionID:t.sessionID}}).pipe(M(Q),E(e=>e.data))),Jb=e=>t=>$()(e[`session.diff`]({params:{sessionID:t.sessionID},query:{from:t.from,to:t.to,context:t.context}}).pipe(M(Q),E(e=>e.data))),Yb=e=>t=>$()(e[`session.inbox.list`]({params:{sessionID:t.sessionID}}).pipe(M(Q),E(e=>e.data))),Xb=e=>t=>$()(e[`session.inbox.cancel`]({params:{sessionID:t.sessionID,inboxID:t.inboxID}}).pipe(M(Q))),Zb=e=>t=>$()(e[`session.inbox.update`]({params:{sessionID:t.sessionID,inboxID:t.inboxID},payload:{delivery:t.delivery}}).pipe(M(Q))),Qb=e=>t=>$()(e[`session.instructions.entry.list`]({params:{sessionID:t.sessionID}}).pipe(M(Q),E(e=>e.data))),$b=e=>t=>$()(e[`session.instructions.entry.put`]({params:{sessionID:t.sessionID,key:t.key},payload:{value:t.value}}).pipe(M(Q))),ex=e=>t=>$()(e[`session.instructions.entry.remove`]({params:{sessionID:t.sessionID,key:t.key}}).pipe(M(Q))),tx=e=>t=>$()(e[`session.generate`]({params:{sessionID:t.sessionID},payload:{prompt:t.prompt}}).pipe(M(Q),E(e=>e.data))),nx=e=>t=>cb()(r(e[`session.log`]({params:{sessionID:t.sessionID},query:{after:t.after,follow:t.follow}}).pipe(M(Q),E(e=>e.pipe(me(Q)))))),rx=e=>t=>$()(e[`session.interrupt`]({params:{sessionID:t.sessionID},query:{resume:t.resume}}).pipe(M(Q))),ix=e=>t=>$()(e[`session.background`]({params:{sessionID:t.sessionID}}).pipe(M(Q))),ax=e=>t=>$()(e[`session.message`]({params:{sessionID:t.sessionID,messageID:t.messageID}}).pipe(M(Q),E(e=>e.data))),ox=e=>t=>$()(e[`session.form.list`]({params:{sessionID:t.sessionID}}).pipe(M(Q),E(e=>e.data))),sx=e=>t=>$()(e[`session.form.create`]({params:{sessionID:t.sessionID},payload:{id:t.id,title:t.title,metadata:t.metadata,fields:t.fields}}).pipe(M(Q),E(e=>e.data))),cx=e=>t=>$()(e[`session.form.get`]({params:{sessionID:t.sessionID,formID:t.formID}}).pipe(M(Q),E(e=>e.data))),lx=e=>t=>$()(e[`session.form.reply`]({params:{sessionID:t.sessionID,formID:t.formID},payload:{answer:t.answer}}).pipe(M(Q))),ux=e=>t=>$()(e[`session.form.cancel`]({params:{sessionID:t.sessionID,formID:t.formID},query:{message:t.message}}).pipe(M(Q))),dx=e=>t=>$()(e[`session.environment`]({params:{sessionID:t.sessionID},payload:{variables:t.variables}}).pipe(M(Q))),fx=e=>t=>$()(e[`session.view`]({params:{sessionID:t.sessionID},payload:{idle:t.idle}}).pipe(M(Q))),px=e=>({list:wb(e),stats:Tb(e),create:Eb(e),import:Db(e),export:Ob(e),active:kb(e),get:Ab(e),remove:jb(e),fork:Mb(e),switchAgent:Nb(e),switchModel:Pb(e),update:Fb(e),move:Ib(e),prompt:Lb(e),command:Rb(e),skill:zb(e),synthetic:Bb(e),shell:Vb(e),compact:Hb(e),wait:Ub(e),revert:{stage:Wb(e),clear:Gb(e),commit:Kb(e)},context:qb(e),diff:Jb(e),inbox:{list:Yb(e),cancel:Xb(e),update:Zb(e)},instructions:{entry:{list:Qb(e),put:$b(e),remove:ex(e)}},generate:tx(e),log:nx(e),interrupt:rx(e),background:ix(e),message:{get:ax(e)},form:{list:ox(e),create:sx(e),get:cx(e),reply:lx(e),cancel:ux(e)},environment:dx(e),view:fx(e)}),mx=e=>t=>$()(e[`session.messages`]({params:{sessionID:t.sessionID},query:{limit:t.limit,order:t.order,cursor:t.cursor,type:t.type}}).pipe(M(Q))),hx=e=>({list:mx(e)}),gx=e=>t=>$()(e[`model.list`]({query:{location:t?.location,types:t?.types}}).pipe(M(Q))),_x=e=>t=>$()(e[`model.default`]({query:{location:t?.location}}).pipe(M(Q))),vx=e=>({list:gx(e),default:_x(e)}),yx=e=>t=>$()(e[`generate.text`]({payload:{prompt:t.prompt,model:t.model}}).pipe(M(Q),E(e=>e.data))),bx=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(M(Q),E(e=>e.data))),xx=e=>t=>$()(e[`generate.decisions`]({payload:{model:t.model,input:t.input,questions:t.questions}}).pipe(M(Q),E(e=>e.data))),Sx=e=>({text:yx(e),image:bx(e),decisions:xx(e)}),Cx=e=>()=>$()(e[`voice.models`]({}).pipe(M(Q),E(e=>e.data))),wx=e=>t=>$()(e[`voice.session`]({payload:{model:t.model,session:t.session,transport:t.transport}}).pipe(M(Q),E(e=>e.data))),Tx=e=>({models:Cx(e),session:wx(e)}),Ex=e=>t=>$()(e[`provider.list`]({query:{location:t?.location}}).pipe(M(Q))),Dx=e=>t=>$()(e[`provider.get`]({params:{providerID:t.providerID},query:{location:t.location}}).pipe(M(Q))),Ox=e=>({list:Ex(e),get:Dx(e)}),kx=e=>t=>$()(e[`integration.list`]({query:{location:t?.location}}).pipe(M(Q))),Ax=e=>t=>$()(e[`integration.get`]({params:{integrationID:t.integrationID},query:{location:t.location}}).pipe(M(Q))),jx=e=>t=>$()(e[`integration.wellknown.add`]({query:{location:t.location},payload:{url:t.url}}).pipe(M(Q))),Mx=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(M(Q))),Nx=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(M(Q))),Px=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(M(Q))),Fx=e=>t=>$()(e[`integration.oauth.status`]({params:{integrationID:t.integrationID,attemptID:t.attemptID},query:{location:t.location}}).pipe(M(Q))),Ix=e=>t=>$()(e[`integration.oauth.complete`]({params:{integrationID:t.integrationID,attemptID:t.attemptID},query:{location:t.location},payload:{code:t.code}}).pipe(M(Q))),Lx=e=>t=>$()(e[`integration.oauth.cancel`]({params:{integrationID:t.integrationID,attemptID:t.attemptID},query:{location:t.location}}).pipe(M(Q))),Rx=e=>t=>$()(e[`integration.command.connect`]({params:{integrationID:t.integrationID},query:{location:t.location},payload:{methodID:t.methodID,label:t.label}}).pipe(M(Q))),zx=e=>t=>$()(e[`integration.command.status`]({params:{integrationID:t.integrationID,attemptID:t.attemptID},query:{location:t.location}}).pipe(M(Q))),Bx=e=>t=>$()(e[`integration.command.cancel`]({params:{integrationID:t.integrationID,attemptID:t.attemptID},query:{location:t.location}}).pipe(M(Q))),Vx=e=>({list:kx(e),get:Ax(e),wellknown:{add:jx(e)},connect:{key:Mx(e),external:Nx(e)},oauth:{connect:Px(e),status:Fx(e),complete:Ix(e),cancel:Lx(e)},command:{connect:Rx(e),status:zx(e),cancel:Bx(e)}}),Hx=e=>t=>$()(e[`mcp.list`]({query:{location:t?.location}}).pipe(M(Q))),Ux=e=>t=>$()(e[`mcp.add`]({params:{server:t.server},query:{location:t.location},payload:{config:t.config}}).pipe(M(Q))),Wx=e=>t=>$()(e[`mcp.remove`]({params:{server:t.server},query:{location:t.location}}).pipe(M(Q))),Gx=e=>t=>$()(e[`mcp.connect`]({params:{server:t.server},query:{location:t.location}}).pipe(M(Q))),Kx=e=>t=>$()(e[`mcp.disconnect`]({params:{server:t.server},query:{location:t.location}}).pipe(M(Q))),qx=e=>t=>$()(e[`mcp.resource.catalog`]({query:{location:t?.location}}).pipe(M(Q))),Jx=e=>t=>$()(e[`mcp.clientToken`]({query:{location:t.location,name:t.name},headers:{"x-opencode-ticket":t[`x-opencode-ticket`]}}).pipe(M(Q))),Yx=e=>({list:Hx(e),add:Ux(e),remove:Wx(e),connect:Gx(e),disconnect:Kx(e),resource:{catalog:qx(e)},client:{token:Jx(e)}}),Xx=e=>()=>$()(e[`credential.list`]({}).pipe(M(Q),E(e=>e.data))),Zx=e=>t=>$()(e[`credential.create`]({payload:{id:t.id,integrationID:t.integrationID,label:t.label,value:t.value,activate:t.activate}}).pipe(M(Q),E(e=>e.data))),Qx=e=>t=>$()(e[`credential.update`]({params:{credentialID:t.credentialID},payload:{label:t.label}}).pipe(M(Q))),$x=e=>t=>$()(e[`credential.activate`]({params:{credentialID:t.credentialID}}).pipe(M(Q))),eS=e=>t=>$()(e[`credential.remove`]({params:{credentialID:t.credentialID}}).pipe(M(Q))),tS=e=>({list:Xx(e),create:Zx(e),update:Qx(e),activate:$x(e),remove:eS(e)}),nS=e=>t=>$()(e[`project.list`]({query:{archived:t?.archived}}).pipe(M(Q))),rS=e=>t=>$()(e[`project.update`]({params:{projectID:t.projectID},payload:{canonical:t.canonical,name:t.name,icon:t.icon,commands:t.commands}}).pipe(M(Q))),iS=e=>({list:nS(e),update:rS(e)}),aS=e=>t=>$()(e[`form.list`]({query:{location:t?.location}}).pipe(M(Q))),oS=e=>({list:aS(e)}),sS=e=>t=>$()(e[`permission.request.list`]({query:{location:t?.location}}).pipe(M(Q))),cS=e=>t=>$()(e[`permission.saved.list`]({query:{projectID:t?.projectID}}).pipe(M(Q),E(e=>e.data))),lS=e=>t=>$()(e[`permission.saved.update`]({params:{id:t.id},payload:{action:t.action,resource:t.resource}}).pipe(M(Q),E(e=>e.data))),uS=e=>t=>$()(e[`permission.saved.remove`]({params:{id:t.id}}).pipe(M(Q))),dS=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(M(Q),E(e=>e.data))),fS=e=>t=>$()(e[`session.permission.list`]({params:{sessionID:t.sessionID}}).pipe(M(Q),E(e=>e.data))),pS=e=>t=>$()(e[`session.permission.get`]({params:{sessionID:t.sessionID,requestID:t.requestID}}).pipe(M(Q),E(e=>e.data))),mS=e=>t=>$()(e[`session.permission.reply`]({params:{sessionID:t.sessionID,requestID:t.requestID},payload:{decision:t.decision,message:t.message}}).pipe(M(Q))),hS=e=>({request:{list:sS(e)},saved:{list:cS(e),update:lS(e),remove:uS(e)},create:dS(e),list:fS(e),get:pS(e),reply:mS(e)}),gS=e=>t=>$()(e[`fs.list`]({query:{location:t?.location,path:t?.path}}).pipe(M(Q))),_S=e=>t=>$()(e[`fs.find`]({query:{location:t.location,query:t.query,type:t.type,limit:t.limit}}).pipe(M(Q))),vS=e=>t=>$()(e[`fs.watch`]({query:{location:t.location},payload:{path:t.path}}).pipe(M(Q))),yS=e=>t=>$()(e[`fs.unwatch`]({query:{location:t.location},payload:{path:t.path}}).pipe(M(Q))),bS=e=>({list:gS(e),find:_S(e),watch:vS(e),unwatch:yS(e)}),xS=e=>t=>$()(e[`command.list`]({query:{location:t?.location}}).pipe(M(Q))),SS=e=>({list:xS(e)}),CS=e=>t=>$()(e[`skill.list`]({query:{location:t?.location}}).pipe(M(Q))),wS=e=>({list:CS(e)}),TS=e=>t=>$()(e[`rpc.call`]({params:{rpcID:t.rpcID,method:t.method},query:{location:t.location},payload:{input:t.input}}).pipe(M(Q))),ES=e=>({call:TS(e)}),DS=e=>t=>cb()(r(e[`event.subscribe`]({query:{types:t?.types}}).pipe(M(Q),E(e=>e.pipe(me(Q)))))),OS=e=>({subscribe:DS(e)}),kS=e=>t=>$()(e[`pty.list`]({query:{location:t?.location}}).pipe(M(Q))),AS=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(M(Q))),jS=e=>t=>$()(e[`pty.get`]({params:{ptyID:t.ptyID},query:{location:t.location}}).pipe(M(Q))),MS=e=>t=>$()(e[`pty.update`]({params:{ptyID:t.ptyID},query:{location:t.location},payload:{title:t.title,size:t.size}}).pipe(M(Q))),NS=e=>t=>$()(e[`pty.remove`]({params:{ptyID:t.ptyID},query:{location:t.location}}).pipe(M(Q))),PS=e=>t=>$()(e[`pty.connectToken`]({params:{ptyID:t.ptyID},query:{location:t.location},headers:{"x-opencode-ticket":t[`x-opencode-ticket`]}}).pipe(M(Q))),FS=e=>({list:kS(e),create:AS(e),get:jS(e),update:MS(e),remove:NS(e),connect:{token:PS(e)}}),IS=e=>t=>$()(e[`persistentPty.read`]({params:{sessionID:t.sessionID},query:{lines:t.lines}}).pipe(M(Q),E(e=>e.data))),LS=e=>t=>$()(e[`persistentPty.list`]({params:{sessionID:t.sessionID}}).pipe(M(Q),E(e=>e.data))),RS=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(M(Q),E(e=>e.data))),zS=e=>()=>$()(e[`persistentPty.shutdown`]({}).pipe(M(Q))),BS=e=>()=>$()(e[`persistentPty.handoff`]({}).pipe(M(Q))),VS=e=>t=>$()(e[`persistentPty.get`]({params:{ptyID:t.ptyID}}).pipe(M(Q),E(e=>e.data))),HS=e=>t=>$()(e[`persistentPty.update`]({params:{ptyID:t.ptyID},payload:{attachmentID:t.attachmentID,size:t.size}}).pipe(M(Q),E(e=>e.data))),US=e=>t=>$()(e[`persistentPty.snapshot`]({params:{ptyID:t.ptyID}}).pipe(M(Q),E(e=>e.data))),WS=e=>t=>$()(e[`persistentPty.remove`]({params:{ptyID:t.ptyID}}).pipe(M(Q))),GS=e=>t=>$()(e[`persistentPty.connectToken`]({params:{ptyID:t.ptyID},headers:{"x-opencode-ticket":t[`x-opencode-ticket`]}}).pipe(M(Q),E(e=>e.data))),KS=e=>({persistentPty:{read:IS(e),list:LS(e),create:RS(e),shutdown:zS(e),handoff:BS(e),get:VS(e),update:HS(e),snapshot:US(e),remove:WS(e),connectToken:GS(e)}}),qS=e=>t=>$()(e[`shell.list`]({query:{location:t?.location}}).pipe(M(Q))),JS=e=>t=>$()(e[`shell.create`]({query:{location:t.location},payload:{command:t.command,cwd:t.cwd,timeout:t.timeout,metadata:t.metadata}}).pipe(M(Q))),YS=e=>t=>$()(e[`shell.get`]({params:{id:t.id},query:{location:t.location}}).pipe(M(Q))),XS=e=>t=>$()(e[`shell.output`]({params:{id:t.id},query:{location:t.location,cursor:t.cursor,limit:t.limit}}).pipe(M(Q))),ZS=e=>t=>$()(e[`shell.remove`]({params:{id:t.id},query:{location:t.location}}).pipe(M(Q))),QS=e=>({list:qS(e),create:JS(e),get:YS(e),output:XS(e),remove:ZS(e)}),$S=e=>t=>$()(e[`reference.list`]({query:{location:t?.location}}).pipe(M(Q))),eC=e=>({list:$S(e)}),tC=e=>t=>$()(e[`worktree.list`]({query:{projectID:t.projectID}}).pipe(M(Q))),nC=e=>t=>$()(e[`worktree.create`]({payload:{projectID:t.projectID,from:t.from,branch:t.branch,directory:t.directory,name:t.name}}).pipe(M(Q))),rC=e=>t=>$()(e[`worktree.remove`]({payload:{projectID:t.projectID,directory:t.directory,force:t.force}}).pipe(M(Q))),iC=e=>t=>$()(e[`worktree.refresh`]({payload:{projectID:t.projectID}}).pipe(M(Q))),aC=e=>({list:tC(e),create:nC(e),remove:rC(e),refresh:iC(e)}),oC=e=>t=>$()(e[`vcs.init`]({query:{location:t?.location,provider:t?.provider}}).pipe(M(Q))),sC=e=>t=>$()(e[`vcs.get`]({query:{location:t?.location}}).pipe(M(Q))),cC=e=>t=>$()(e[`vcs.base`]({query:{location:t?.location}}).pipe(M(Q))),lC=e=>t=>$()(e[`vcs.status`]({query:{location:t?.location}}).pipe(M(Q))),uC=e=>t=>$()(e[`vcs.branch.list`]({query:{location:t?.location,search:t?.search,limit:t?.limit}}).pipe(M(Q))),dC=e=>t=>$()(e[`vcs.diff`]({query:{location:t.location,mode:t.mode,base:t.base,context:t.context,untracked:t.untracked}}).pipe(M(Q))),fC=e=>({init:oC(e),get:sC(e),base:cC(e),status:lC(e),branch:{list:uC(e)},diff:dC(e)}),pC=e=>t=>$()(e[`debug.heapDump`]({query:{directory:t?.directory}}).pipe(M(Q))),mC=e=>()=>$()(e[`debug.location`]({}).pipe(M(Q))),hC=e=>t=>$()(e[`debug.location.evict`]({query:{location:t?.location}}).pipe(M(Q))),gC=e=>({heapDump:pC(e),location:{list:mC(e),evict:hC(e)}}),_C=e=>()=>$()(e[`migration.v1.status`]({}).pipe(M(Q))),vC=e=>({v1:{status:_C(e)}}),yC=e=>t=>$()(e[`websearch.providers`]({query:{location:t?.location}}).pipe(M(Q))),bC=e=>t=>$()(e[`websearch.query`]({query:{location:t.location},payload:{query:t.query,providerID:t.providerID}}).pipe(M(Q))),xC=e=>({providers:yC(e),query:bC(e)}),SC=e=>t=>$()(e[`usage.limits`]({query:{location:t?.location}}).pipe(M(Q))),CC=e=>({limits:SC(e)}),wC=e=>t=>$()(e[`config.get`]({query:{location:t?.location}}).pipe(M(Q))),TC=e=>()=>$()(e[`config.shells`]({}).pipe(M(Q))),EC=e=>t=>$()(e[`config.update`]({payload:{shell:t.shell}}).pipe(M(Q))),DC=e=>({get:wC(e),shells:TC(e),update:EC(e)}),OC=e=>({server:fb(e[`server.server`]),location:hb(e[`server.location`]),agent:vb(e[`server.agent`]),plugin:Cb(e[`server.plugin`]),session:px(e[`server.session`]),message:hx(e[`server.message`]),model:vx(e[`server.model`]),generate:Sx(e[`server.generate`]),voice:Tx(e[`server.voice`]),provider:Ox(e[`server.provider`]),integration:Vx(e[`server.integration`]),mcp:Yx(e[`server.mcp`]),credential:tS(e[`server.credential`]),project:iS(e[`server.project`]),form:oS(e[`server.form`]),permission:hS(e[`server.permission`]),file:bS(e[`server.fs`]),command:SS(e[`server.command`]),skill:wS(e[`server.skill`]),rpc:ES(e[`server.rpc`]),event:OS(e[`server.event`]),pty:FS(e[`server.pty`]),experimental:KS(e[`server.experimental`]),shell:QS(e[`server.shell`]),reference:eC(e[`server.reference`]),worktree:aC(e[`server.worktree`]),vcs:fC(e[`server.vcs`]),debug:gC(e[`server.debug`]),migration:vC(e[`server.migration`]),websearch:xC(e[`server.websearch`]),usage:CC(e[`server.usage`]),config:DC(e[`server.config`])}),kC=e=>lt(sb,e).pipe(E(OC)),AC={};ra(AC,{RpcRuntime:()=>AC,event:()=>NC,eventType:()=>PC,read:()=>jC,readError:()=>MC});function jC(e,t){return u(e)?We(e)(t):ht(t)}function MC(e,t){return!(t instanceof Wo)&&!(t instanceof Go)?nt(t):!e.errors||!Object.hasOwn(e.errors,t.type)?nt(t.data===void 0?{type:t.type,message:t.message}:{type:t.type,message:t.message,data:t.data}):jC(e.errors[t.type],t.data).pipe(xt(e=>vt(e)),Fe(e=>nt(e===void 0?{type:t.type,message:t.message}:{type:t.type,message:t.message,data:e})))}var NC=pt(`Client.Rpc.event`)(function*(e,t,n,r){let i=yield*jC(n.schema,r.data);return{...r,type:PC(e,t),data:i}});function PC(e,t){return`rpc.${e.id}.${t}`}var FC={};ra(FC,{RpcClientRuntime:()=>FC,aborted:()=>LC,make:()=>IC});function IC(e,t){return r=>{let i=Object.fromEntries(Object.entries(r.methods).map(([t,i])=>[t,(a,o)=>{let s=bt(function*(){let n=yield*e({rpcID:r.id,method:t,input:a,location:o?.location},o);return yield*jC(i.output,n.output)}).pipe(xt(e=>MC(i,e))),c=o?.signal;return c?$e(()=>c.aborted?Ve:Je(s,n(LC(c),Ve))):s}]));return Object.assign(i,{events:{subscribe:e=>{let n=PC(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=>NC(r,e,i,t)))}}})}}function LC(e){return Ge(t=>{if(e.aborted)return t(Ne);let n=()=>t(Ne);return e.addEventListener(`abort`,n,{once:!0}),Xe(()=>e.removeEventListener(`abort`,n))})}var RC={};ra(RC,{OpenCode:()=>RC,make:()=>BC});var zC=Re(`@opencode/client/effect/rpc/headers`,{defaultValue:()=>{}}),BC=pt(`OpenCode.make`)(function*(e){let t=yield*Qe,n=yield*kC(e).pipe(Ue(Qe,Ye(t,e=>E(zC,t=>t?Me(e,new Headers(t)):e)))),r=yield*ut(),i=n.event.subscribe();class a{cause;constructor(e){this.cause=e}}let o=aa(e=>it(i.pipe(d(LC(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:Et(new ro({cause:e})))));return{...n,event:{...n.event,subscribe:c},rpc:Object.assign(IC((e,t)=>n.rpc.call(e).pipe(Ue(zC,t?.headers)),c),n.rpc)}}),VC=e({Answer:()=>GC,Prompt:()=>WC,Question:()=>VC}),HC=x({label:y.annotate({description:`Display text (1-5 words, concise)`}),description:y.annotate({description:`Explanation of choice`})}),UC={question:y.annotate({description:`Complete question`}),header:y.annotate({description:`Very short label (max 30 chars)`}),options:h(HC).annotate({description:`Available choices`}),multiple:g.pipe(B).annotate({description:`Allow selecting multiple choices`})},WC=x(UC).annotate({identifier:`Question.Prompt`}),GC=h(y).annotate({identifier:`Question.Answer`}),KC=e({AbsolutePath:()=>ao,Agent:()=>Du,ClientError:()=>ro,Command:()=>ch,Config:()=>zg,Credential:()=>Ts,Event:()=>Co,EventLog:()=>jm,FileSystem:()=>Jm,Form:()=>Bs,Integration:()=>dc,Location:()=>vo,Model:()=>el,OpenCode:()=>RC,Permission:()=>hu,PermissionSaved:()=>Wm,Project:()=>Pu,Prompt:()=>Tl,PromptInput:()=>lm,Provider:()=>Ic,Pty:()=>iu,Question:()=>VC,Reference:()=>Pv,RelativePath:()=>io,Session:()=>fp,SessionInbox:()=>sf,SessionMessage:()=>dd,Skill:()=>Mo,Vcs:()=>zy,WebSearch:()=>wg,Worktree:()=>qg}),qC=20;function JC(e){return JSON.stringify([e.directory,e.workspaceID])}function YC(e){return{directory:e.directory}}function XC(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 ZC(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 QC(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:ZC(e.state.content)}}:e)}:e}function $C(e,t){if(!(e!==`global`||!t))return{headers:{"x-opencode-directory":encodeURIComponent(t.directory)}}}function ew(){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 tw=200;function nw(e){let t=e.api,n=!1;or(()=>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;or(()=>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]=Vi({session:{info:{},family:{},active:{},message:{},messageCursor:{},messageLoading:{},pending:{},permission:{},form:{}},project:{info:{},permission:{}},location:{}}),[c,l]=Kn({directory:e.directory}),u=Zn(()=>Object.values(o.session.info).toSorted((e,t)=>t.time.updated-e.time.updated)),d=new Map,f=t=>e.omitToolFileData?QC(t):t,p=ew(),ee,te=new Map;function ne(e,t){ee?.set(e,t),s(`session`,`active`,e,t)}function m(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 re(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 ie(e,t,n){let r=o.session.form[e];if(!r)return!1;let i=n&&JC(n),a=r.filter(n=>n.id===t?e!==`global`||!i?!1:!n.location||JC(n.location)!==i:!0);return a.length!==r.length&&(s(`session`,`form`,e,a),!0)}function ae(e,t,n){return n.catch(t=>{if(!Aa(t)&&!Ma(t)||t.id!==e.formID)throw t}).then(()=>{ie(e.sessionID,e.formID,t)&&(y.session.form.invalidate(e.sessionID,t),y.session.form.sync(e.sessionID,t).catch(()=>{}))})}function oe(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 se=new Set,ce=new Set,le=new Map,ue=new Map,de=new Map,fe=new Map;or(()=>fe.clear());function h(e,t,n){e.set(t,n);let r=()=>{e.get(t)===n&&e.delete(t)};n.then(r,r)}function pe(e,t,n){let r=le.get(e),i=ue.get(e),a=Promise.resolve().then(()=>Promise.all([n,r,i])).then(t);return h(ue,e,a.catch(()=>{})),a}function me(e){nr(()=>{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`&&he(e)})}function he(e){(e.type===`user`||e.type===`synthetic`)&&_.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 _.append(t,n,r);t[i]=r})}function g(e,t){nr(()=>{m(e,t),d.get(e)?.has(t)&&_.update(e,(e,n)=>{let r=n.get(t);r!==void 0&&(e.splice(r,1),n.delete(t),_.reindex(e,n,r))})})}let _={update(e,t){s(`session`,`message`,$i(n=>{t(n[e]??=[],ge(e))}))},append(e,t,n){t.has(n.id)||(t.set(n.id,e.length),e.push(n))},insert(e,t){_.update(e,(e,n)=>_.append(e,n,t))},editAssistant(e,t,n){d.get(e)?.has(t)&&_.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){_.editAssistant(e,t,e=>{let t=e.content.findLast(e=>e.type===`tool`&&e.id===n);t&&r(t)})},editText(e,t,n){_.editAssistant(e,t,e=>{let t=e.content.findLast(e=>e.type===`text`);t&&n(t)})},editReasoning(e,t,n){_.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 ge(e){let t=d.get(e);if(t)return t;let n=new Map;return d.set(e,n),n}async function _e(e){let n=await t().session.list(e);return n.data.length<tw||!n.cursor.next?n.data:[...n.data,...await _e({cursor:n.cursor.next,limit:tw})]}function ve(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 ye(e){if(!o.session.info[e])return;let t=ve(e);s(`session`,`family`,$i(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 be(e){if(ce.has(e))return;p.invalidate(`session.pending:${e}`),p.invalidate(`session.message:${e}`),de.delete(e);let t=o.session.pending[e]?.filter(e=>se.has(e.id))??[],n=o.session.message[e]?.filter(e=>se.has(e.id))??[];d.delete(e),n.length&&d.set(e,new Map(n.map((e,t)=>[e.id,t]))),s(`session`,$i(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 xe(e){ee?.set(e,void 0),o.session.pending[e]?.forEach(e=>se.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`,$i(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 Se(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`,Xi(Object.fromEntries(n))),n.forEach((e,t)=>{e===`running`&&!o.session.info[t]&&r(()=>y.session.sync(t))})}).catch(()=>{ee===e&&(ee=void 0)})),r(()=>t().location.get({location:YC(c())}).then(e=>{let t=JC(e);s(`location`,t,{info:e})})),r(()=>y.location.vcs.sync()),r(()=>y.project.sync());return}case`project.updated`:s(`project`,`info`,n.data.id,Xi(n.data));return;case`session.created`:ce.delete(n.data.sessionID),y.session.invalidate(n.data.sessionID),r(()=>y.session.sync(n.data.sessionID)),p.complete(`session.pending:${n.data.sessionID}`),p.complete(`session.message:${n.data.sessionID}`);return;case`session.deleted`:xe(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),_.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;_.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=>{_.update(n.data.sessionID,(t,n)=>{let r=n.get(e.id);if(r===void 0)return _.append(t,n,e);t[r]=e})}));return}case`session.renamed`:r(()=>{let e=p.pending(`session.family:${n.data.sessionID}`)?y.session.sync(n.data.sessionID,{children:!0}):Promise.resolve();return Promise.all([y.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),_.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){y.session.invalidate(e),r(()=>y.session.sync(e));continue}let a=a_({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=y.session.input.has(n.data.sessionID,n.data.inboxID);m(n.data.sessionID,n.data.inboxID),_.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),_.reindex(t,r,i))}),fe.get(n.data.sessionID)?.observed.add(n.data.inboxID);return}case`session.inbox.delivery.changed`:oe(n.data.sessionID,n.data.inboxID,n.data.delivery);return;case`session.inbox.cancelled`:g(n.data.sessionID,n.data.inboxID),fe.get(n.data.sessionID)?.observed.add(n.data.inboxID);return;case`session.inbox.enqueued`:{se.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),me(e),n.data.item.type===`compaction`){let e=fe.get(n.data.sessionID);e?.observed.add(n.data.inboxID),e&&e.id!==n.data.inboxID&&se.delete(e.id)&&m(n.data.sessionID,e.id)}return}case`session.instructions.updated`:let i=n.data.text;if(i===void 0)return;_.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`:_.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`:_.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;_.update(n.data.sessionID,e=>{let t=_.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`:_.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=_.activeAssistant(e);a&&(a.retry=void 0,a.time.completed=n.created),_.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`:_.editAssistant(n.data.sessionID,n.data.assistantMessageID,e=>{e.time.streamed=n.created});return;case`session.step.ended`:_.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`)&&we(n.location),_.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`:_.editAssistant(n.data.sessionID,n.data.assistantMessageID,e=>{e.content.push({type:`text`,text:``})});return;case`session.text.delta`:_.editText(n.data.sessionID,n.data.assistantMessageID,e=>{e.text+=n.data.delta});return;case`session.text.ended`:_.editText(n.data.sessionID,n.data.assistantMessageID,e=>{e.text=n.data.text});return;case`session.tool.input.started`:_.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`:_.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`:_.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`:_.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`:_.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`:_.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?ZC(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`:_.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?ZC(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`:_.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`:_.editReasoning(n.data.sessionID,n.data.assistantMessageID,e=>{e.text+=n.data.delta});return;case`session.reasoning.ended`:_.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`:_.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`:ne(n.data.sessionID,`running`);return;case`session.compaction.started`:n.data.inputID&&m(n.data.sessionID,n.data.inputID),_.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&&fe.get(n.data.sessionID)?.observed.add(n.data.inputID);return;case`session.execution.succeeded`:case`session.execution.failed`:case`session.execution.interrupted`:if(ne(n.data.sessionID,`idle`),_.update(n.data.sessionID,e=>{let t=_.activeAssistant(e);t&&(t.retry=void 0)}),n.type===`session.execution.interrupted`&&n.data.reason===`shutdown`||(_.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(()=>y.session.message.sync(n.data.sessionID))),!o.session.info[n.data.sessionID]&&!p.has(`session:${n.data.sessionID}`)))return;y.session.invalidate(n.data.sessionID),r(()=>y.session.sync(n.data.sessionID));return;case`session.viewed`:if(!o.session.info[n.data.sessionID]&&!p.has(`session:${n.data.sessionID}`))return;y.session.invalidate(n.data.sessionID),r(()=>y.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)),_.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;_.update(n.data.sessionID,e=>{let t=_.compaction(e);t?.status===`running`&&(t.summary+=n.data.text)});return;case`session.compaction.ended`:_.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}_.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&&m(n.data.sessionID,n.data.inputID),_.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}_.append(e,t,a)}),n.data.inputID&&fe.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`:re(n.data.sessionID,n.data.requestID);return;case`form.replied`:case`form.cancelled`:ie(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(we(i),n.type===`credential.updated`){v(`integration`,y.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=Ce(`integration`,i)||Ce(`model`,i)||Ce(`provider`,i);y.location.model.invalidate(i),y.location.provider.invalidate(i),a&&r(()=>Promise.all([y.location.model.sync(i),y.location.provider.sync(i)]))});return}if(!n.location)return;let i=n.location;switch(n.type){case`provider.updated`:v(`provider`,y.location.provider,i);break;case`model.updated`:v(`model`,y.location.model,i);break;case`agent.updated`:v(`agent`,y.location.agent,i);break;case`command.updated`:v(`command`,y.location.command,i);break;case`skill.updated`:v(`skill`,y.location.skill,i);break;case`vcs.branch.updated`:v(`vcs`,y.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`,JC(i),e=>({shell:{...e?.shell,[n.data.info.id]:{...n.data.info,location:i}}}));break;case`shell.exited`:case`shell.deleted`:if(!o.location[JC(i)]?.shell?.[n.data.id])break;s(`location`,JC(i),e=>({shell:Object.fromEntries(Object.entries(e?.shell??{}).filter(([e])=>e!==n.data.id))}));break;case`reference.updated`:v(`reference`,y.location.reference,i);break;case`integration.updated`:{we(i);let e=Ce(`integration`,i)||Ce(`model`,i)||Ce(`provider`,i);y.location.integration.invalidate(i),y.location.model.invalidate(i),y.location.provider.invalidate(i),e&&r(()=>Promise.all([y.location.integration.sync(i),y.location.model.sync(i),y.location.provider.sync(i)]));break}case`config.updated`:v(`config`,y.location.config,i),Ce(`websearch`,i)&&r(()=>y.location.websearch.refresh(i));break;case`websearch.updated`:Ce(`websearch`,i)&&r(()=>y.location.websearch.refresh(i));break;case`mcp.status.changed`:{let e=Ce(`mcpServer`,i);y.location.mcp.server.invalidate(i),e&&a(`mcp.status:${JC(i)}`,()=>y.location.mcp.server.sync(i));break}case`mcp.resources.changed`:v(`mcpResource`,y.location.mcp.resource,i)}}function Ce(e,t){let n=JC(t??c());return o.location[n]?.[e]!==void 0||p.has(`location.${e}:${n}`)}function v(e,t,n){let i=Ce(e,n);t.invalidate(n),i&&r(()=>t.sync(n))}function we(e){let t=o.location[JC(e)]?.usageLimits!==void 0||p.has(`location.usageLimits:${JC(e)}`);De.invalidate(e),t&&r(()=>De.sync(e))}function Te(e,t,n){let r=(t,n)=>s(`location`,t,{[e]:n});return{list:t=>o.location[JC(t??c())]?.[e],sync:i=>{let a=i??c(),o=JC(a);return p.run(`location.${e}:${o}`,async()=>{let e=await t(YC(a)),i=JC(e.location);r(i,e.data),n?.alias&&i!==o&&r(o,e.data)})},invalidate:t=>p.invalidate(`location.${e}:${JC(t??c())}`)}}let Ee=Te(`vcs`,e=>t().vcs.get({location:e})),De=Te(`usageLimits`,e=>t().usage.limits({location:e})),Oe=Te(`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}]))}}),y={on:e.event.on,listen:e.event.listen,session:{list(){return u()},get(e){return o.session.info[e]},creating(e){return le.has(e)},remember(e){nr(()=>{s(`session`,`info`,e.id,Xi(e)),p.complete(`session:${e.id}`),ye(e.id)})},setStatus(e,t){ne(e,t)},root(e){return ve(e)},family(e){return o.session.family[ve(e)]??[]},evict(e){let t=ve(e);nr(()=>{for(let n of new Set([t,e,...o.session.family[t]??[]]))be(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=>se.delete(e.id)),a.some(e=>e.type===`compaction`)&&o.session.pending[e]?.filter(e=>e.type===`compaction`).forEach(e=>se.delete(e.id));let c=(o.session.pending[e]??[]).filter(e=>se.has(e.id)),l=c.length===0?a:[...a,...c];nr(()=>{s(`session`,`pending`,e,Xi(l)),l.forEach(he)})}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??mu.create(),a=r.location??c(),s=!o.session.info[i];if(s){let e=Date.now();ce.add(i),y.session.remember({id:i,projectID:n??o.location[JC(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=>(ce.delete(i),y.session.remember(e),e)).catch(e=>{throw s&&ce.delete(i)&&xe(i),e});return s&&h(le,i,l),{id:i,request:l}},compact(e){let n=fe.get(e.sessionID);if(n)return n.request;let r=K.create();o.session.pending[e.sessionID]?.some(e=>e.type===`compaction`)||(se.add(r),me({id:r,sessionID:e.sessionID,time:{created:Date.now()},type:`compaction`,delivery:`steer`,payload:{}}));let i=new Set,a=pe(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=>(nr(()=>{se.delete(r),t.id!==r&&m(e.sessionID,r),!i.has(t.id)&&!d.get(e.sessionID)?.has(t.id)&&me(t)}),t)).catch(t=>{throw se.delete(r)&&m(e.sessionID,r),t}).finally(()=>{fe.get(e.sessionID)?.request===a&&fe.delete(e.sessionID)});return fe.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=XC(i.files),t={text:i.text,agents:i.agents?.map(e=>({...e})),metadata:i.metadata};e&&(t.files=e),se.add(a),me({id:a,sessionID:i.sessionID,time:{created:Date.now()},type:`user`,delivery:i.delivery??`steer`,payload:t})}return pe(i.sessionID,async()=>(await r?.(),t().session.prompt({...i,id:a})),n).catch(e=>{throw s&&se.delete(a)&&g(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?_e({parentID:e,order:`desc`,limit:tw}):[]]),a=[r,...i];nr(()=>{s(`session`,`info`,$i(e=>{for(let t of a)e[t.id]=t}));for(let e of a)p.complete(`session:${e.id}`),ye(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?.()??qC,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)&&(se.has(e.id)||c.has(e.id))),u=l.length===0?i:[...i,...l];nr(()=>{d.set(n,new Map(u.map((e,t)=>[e.id,t]))),s(`session`,`message`,n,Xi(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(;de.has(e);){let t=await(()=>{let t=de.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:qC,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 nr(()=>{n?.beforePublish?.(),d.set(e,new Map(p.map((e,t)=>[e.id,t]))),s(`session`,`message`,e,Xi(p)),s(`session`,`messageCursor`,e,c)}),!0})().catch(e=>{if(!r?.aborted)throw e}).finally(()=>s(`session`,`messageLoading`,e,!1));h(de,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(!Wa(e))throw e}),re(e.sessionID,e.requestID)}},form:{list(e,t){let n=o.session.form[e];if(e!==`global`)return n;if(!t)return;let r=JC(t);return n?.filter(e=>e.location&&JC(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`?JC(n??c()):``}`;return p.run(r,async()=>{if(e===`global`){let r=await t().form.list({location:YC(n??c())}),i={directory:r.location.directory},a=JC(i);s(`session`,`form`,e,[...(o.session.form[e]??[]).filter(e=>e.location&&JC(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`?JC(t??c()):``}`)},reply(e,n){return ae(e,n,t().session.form.reply(e,$C(e.sessionID,n)))},cancel(e,n){return ae(e,n,t().session.form.cancel(e,$C(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`,Xi(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(Oe.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:Oe.sync,invalidate:Oe.invalidate},location:{info(e){return o.location[JC(e??c())]?.info},default(){return c()},syncInfo(e){let n=e??c();return p.run(`location:${JC(n)}`,async()=>{let r=await t().location.get({location:YC(n)}),i=JC(r);o.location[i]||s(`location`,i,{}),s(`location`,i,`info`,r),e||l({directory:r.directory})})},async sync(e){await y.location.syncInfo(e);let t=e??c();await Promise.all([y.location.vcs.sync(t),y.location.agent.sync(t),y.location.command.sync(t),y.location.integration.sync(t),y.location.mcp.server.sync(t),y.location.mcp.resource.sync(t),y.location.model.sync(t),y.location.provider.sync(t),y.location.reference.sync(t),y.location.skill.sync(t),y.shell.sync(t),y.session.form.sync(`global`,t)])},invalidate(e){let t=e??c();p.invalidate(`location:${JC(t)}`),y.location.vcs.invalidate(t),y.location.agent.invalidate(t),y.location.command.invalidate(t),y.location.config.invalidate(t),y.location.integration.invalidate(t),y.location.mcp.server.invalidate(t),y.location.mcp.resource.invalidate(t),y.location.model.invalidate(t),y.location.provider.invalidate(t),y.location.reference.invalidate(t),y.location.skill.invalidate(t),y.shell.invalidate(t),y.session.form.invalidate(`global`,t)},vcs:{info:Ee.list,sync:Ee.sync,invalidate:Ee.invalidate},usage:{limits:De.list,sync:De.sync,invalidate:De.invalidate},agent:Te(`agent`,e=>t().agent.list({location:e})),command:Te(`command`,e=>t().command.list({location:e})),config:Te(`config`,async e=>({location:{directory:e.directory},data:await t().config.get({location:e})})),integration:Te(`integration`,e=>t().integration.list({location:e})),mcp:{server:Te(`mcpServer`,e=>t().mcp.list({location:e})),resource:Te(`mcpResource`,async e=>{let n=await t().mcp.resource.catalog({location:e});return{location:n.location,data:n.data.resources}})},model:Te(`model`,e=>t().model.list({location:e}),{alias:!0}),provider:Te(`provider`,e=>t().provider.list({location:e}),{alias:!0}),reference:Te(`reference`,e=>t().reference.list({location:e})),websearch:{list(e){return o.location[JC(e??c())]?.websearch},async refresh(e){let n={location:YC(e??c())},r=await t().websearch.providers(n),i=JC(r.location);s(`location`,i,{websearch:r.data})}},skill:Te(`skill`,e=>t().skill.list({location:e}))}};return Yn(()=>{e.connection?.status()!==`connected`&&p.invalidate()}),or(e.event.listen(({details:e})=>{Se(e)})),y}var rw=2e3,iw=1e3,aw=50,ow=45e3,sw=2e4;function cw(e,t){let n=new AbortController,r=[],i=t.idleTimeout??45e3,[a,o]=Vi({status:`connecting`,attempt:0}),s=e,c=[],l,u,d,f,p=!1,ee=0,te=0,ne=!1;function m(e,t,n){r.push({type:`client.connection`,created:Date.now(),data:{status:e,attempt:t,error:n}}),r.length>aw&&r.shift()}function re(e){c.push(e),!l&&(l=setTimeout(()=>{l=void 0;let e=c;c=[],nr(()=>e.forEach(t.onEvent))},t.flushInterval??10))}async function ie(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`)),rw);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{m(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),m(`connected`,n),r=Date.now(),f(),t.log?.info?.(`event stream connected`),re(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}),re(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 ae(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 ie(i.signal,r);if(n.signal.removeEventListener(`abort`,a),n.signal.aborted||!p||ee!==e)return;c.connectedAt!==void 0&&Date.now()-c.connectedAt>=iw&&(r=0),r+=1;let l=lw(c.error);if(m(`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:lw(e)})});if(n.signal.aborted||i.signal.aborted||!p||ee!==e)return;if(a&&(s=a,r===1))continue}if(ne){ne=!1;continue}await uw(iw,i.signal)}}function oe(){if(p)return f;p=!0,ne=!1;let e=++ee,t=f,n=(async()=>{t&&await t,await ae(e)})().finally(()=>{f===n&&(f=void 0)});return f=n,f}function se(){p&&(p=!1,ee+=1,u?.abort(),o({status:`connecting`,attempt:0,error:void 0}))}function ce(e){!p||a.status!==`connected`||(t.log?.info?.(`event stream resync`,{reason:e,idle:Date.now()-te}),ne=!0,d?.abort(Error(e)))}if(t.pageLifecycle){let e=()=>se(),t=()=>void oe(),n=()=>{document.visibilityState===`visible`&&(Date.now()-te<2e4||ce(`Page returned to the foreground after the event stream went quiet`))},r=()=>ce(`Network connection restored`);window.addEventListener(`pagehide`,e),window.addEventListener(`pageshow`,t),window.addEventListener(`online`,r),document.addEventListener(`visibilitychange`,n),or(()=>{window.removeEventListener(`pagehide`,e),window.removeEventListener(`pageshow`,t),window.removeEventListener(`online`,r),document.removeEventListener(`visibilitychange`,n)})}return oe(),or(()=>{se(),n.abort(),l&&clearTimeout(l),c=[]}),{status:()=>a.status,attempt:()=>a.attempt,error:()=>a.error,internal:{history:()=>r.slice(),resync:ce}}}function lw(e){if(e!==void 0)return e instanceof Error?e.message:String(e)}function uw(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 dw(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 fw(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 pw(e){let t,n=[],r=new Map;Yn(()=>{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=>rr(()=>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));rr(()=>u.forEach(t=>e.session.evict(t))),r=new Map([...l].map(([e,t])=>[e,`${t}:${c(e)}`]))})}function mw(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 hw=e({createClientConnection:()=>cw,createData:()=>nw,createPersistentPtyClient:()=>fw,createPtyClient:()=>dw,createSessionRetention:()=>pw,defaultIdleTimeout:()=>ow,foregroundIdleThreshold:()=>sw,lastAssistantWithUsage:()=>mw,locationKey:()=>JC,settleMs:()=>150});export{ir as A,Zt as B,Jn as C,cr as D,Qr as E,ai as F,rr as I,vr as L,ur as M,P as N,lr as O,an as P,nn as R,Zn as S,Kn as T,Ht as V,nr as _,Vi as a,_r as b,ki as c,di as d,mi as f,pi as g,bi as h,eo as i,or as j,ii as k,_i as l,xi as m,KC as n,Xi as o,fi as p,no as r,Si as s,hw as t,ui as u,sr as v,Gn as w,Yn as x,$r as y,Xt as z};
|
|
23
|
+
`)}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/${ua(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 ua(e){return e.split(`/`).map(encodeURIComponent).join(`/`)}function da(e,t,n){if(n!==void 0){if(n===null){e.append(t,`null`);return}if(Array.isArray(n)){for(let r of n)da(e,t,r);return}if(typeof n==`object`){for(let[r,i]of Object.entries(n))da(e,`${t}[${r}]`,i);return}e.append(t,String(n))}}async function fa(e){if(!ma(e,`application/json`)&&!e.headers.get(`content-type`)?.includes(`+json`)){try{await e.body?.cancel()}catch{}throw new sa(`UnsupportedContentType`,{detail:e.headers.get(`content-type`)})}let t;try{t=await e.text()}catch(e){throw new sa(`Transport`,{cause:e})}if(t===``)throw new sa(`MalformedResponse`);try{return JSON.parse(t)}catch(e){throw new sa(`MalformedResponse`,{cause:e})}}function pa(e){let t=Object.assign(Error(e.message??e.data?.message),e);return e._tag&&(t.name=e._tag),t}function ma(e,t){return e.headers.get(`content-type`)?.split(`;`,1)[0]?.trim().toLowerCase()===t}var ha=e=>typeof e==`object`&&!!e&&`_tag`in e&&e._tag===`InvalidRequestError`,ga=e=>typeof e==`object`&&!!e&&`_tag`in e&&e._tag===`UnauthorizedError`,_a=e=>typeof e==`object`&&!!e&&`_tag`in e&&e._tag===`LocationNotFoundError`,va=e=>typeof e==`object`&&!!e&&`_tag`in e&&e._tag===`ServiceUnavailableError`,ya=e=>typeof e==`object`&&!!e&&`_tag`in e&&e._tag===`AgentNotFoundError`,ba=e=>typeof e==`object`&&!!e&&`_tag`in e&&e._tag===`PluginNotFoundError`,xa=e=>typeof e==`object`&&!!e&&`_tag`in e&&e._tag===`InvalidCursorError`,Sa=e=>typeof e==`object`&&!!e&&`_tag`in e&&e._tag===`SessionNotFoundError`,Ca=e=>typeof e==`object`&&!!e&&`_tag`in e&&e._tag===`ConflictError`,wa=e=>typeof e==`object`&&!!e&&`_tag`in e&&e._tag===`UnknownError`,Ta=e=>typeof e==`object`&&!!e&&`_tag`in e&&e._tag===`MessageNotFoundError`,Ea=e=>typeof e==`object`&&!!e&&`_tag`in e&&e._tag===`CommandNotFoundError`,Da=e=>typeof e==`object`&&!!e&&`_tag`in e&&e._tag===`CommandExecutionError`,Oa=e=>typeof e==`object`&&!!e&&`_tag`in e&&e._tag===`SkillNotFoundError`,ka=e=>typeof e==`object`&&!!e&&`_tag`in e&&e._tag===`SessionBusyError`,Aa=e=>typeof e==`object`&&!!e&&`_tag`in e&&e._tag===`InstructionEntryValueTooLargeError`,ja=e=>typeof e==`object`&&!!e&&`_tag`in e&&e._tag===`FormNotFoundError`,Ma=e=>typeof e==`object`&&!!e&&`_tag`in e&&e._tag===`FormInvalidAnswerError`,Na=e=>typeof e==`object`&&!!e&&`_tag`in e&&e._tag===`FormAlreadySettledError`,Pa=e=>typeof e==`object`&&!!e&&`_tag`in e&&e._tag===`ProviderNotFoundError`,Fa=e=>typeof e==`object`&&!!e&&`_tag`in e&&e._tag===`ModelNotFoundError`,Ia=e=>typeof e==`object`&&!!e&&`_tag`in e&&e._tag===`UnsupportedModelError`,La=e=>typeof e==`object`&&!!e&&`_tag`in e&&e._tag===`ProviderRequestError`,Ra=e=>typeof e==`object`&&!!e&&`_tag`in e&&e._tag===`IntegrationNotFoundError`,za=e=>typeof e==`object`&&!!e&&`_tag`in e&&e._tag===`IntegrationAttemptNotFoundError`,Ba=e=>typeof e==`object`&&!!e&&`_tag`in e&&e._tag===`IntegrationMethodNotFoundError`,Va=e=>typeof e==`object`&&!!e&&`_tag`in e&&e._tag===`McpServerNotFoundError`,Ha=e=>typeof e==`object`&&!!e&&`_tag`in e&&e._tag===`ForbiddenError`,Ua=e=>typeof e==`object`&&!!e&&`_tag`in e&&e._tag===`ProjectNotFoundError`,Wa=e=>typeof e==`object`&&!!e&&`_tag`in e&&e._tag===`PermissionSavedNotFoundError`,Ga=e=>typeof e==`object`&&!!e&&`_tag`in e&&e._tag===`PermissionNotFoundError`,Ka=e=>typeof e==`object`&&!!e&&`_tag`in e&&e._tag===`FileNotFoundError`,qa=e=>typeof e==`object`&&!!e&&`_tag`in e&&e._tag===`RpcError`,Ja=e=>typeof e==`object`&&!!e&&`_tag`in e&&e._tag===`RpcInternalError`,Ya=e=>typeof e==`object`&&!!e&&`_tag`in e&&e._tag===`PtyNotFoundError`,Xa=e=>typeof e==`object`&&!!e&&`_tag`in e&&e._tag===`ShellNotFoundError`,Za=e=>typeof e==`object`&&!!e&&`_tag`in e&&e._tag===`WorktreeError`,Qa=e=>typeof e==`object`&&!!e&&`_tag`in e&&e._tag===`VcsInitNotSupportedError`;function $a(e,t){return n=>{let r=(e,r)=>{if(!Object.hasOwn(n.events,e))throw Error(`Unknown RPC event: ${n.id}.${e}`);let i=eo(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!qa(e)&&!Ja(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 eo(e,t){return`rpc.${e.id}.${t}`}var to={};ia(to,{OpenCode:()=>to,make:()=>no});function no(e){let t=la(e),n=oa((e,n)=>t.event.subscribe(void 0,{signal:e,onActivity:n}));return{...t,rpc:Object.assign($a(t,n),t.rpc),event:n}}var ro=e({ClientError:()=>sa,OpenCode:()=>to,isAgentNotFoundError:()=>ya,isCommandExecutionError:()=>Da,isCommandNotFoundError:()=>Ea,isConflictError:()=>Ca,isFileNotFoundError:()=>Ka,isForbiddenError:()=>Ha,isFormAlreadySettledError:()=>Na,isFormInvalidAnswerError:()=>Ma,isFormNotFoundError:()=>ja,isInstructionEntryValueTooLargeError:()=>Aa,isIntegrationAttemptNotFoundError:()=>za,isIntegrationMethodNotFoundError:()=>Ba,isIntegrationNotFoundError:()=>Ra,isInvalidCursorError:()=>xa,isInvalidRequestError:()=>ha,isLocationNotFoundError:()=>_a,isMcpServerNotFoundError:()=>Va,isMessageNotFoundError:()=>Ta,isModelNotFoundError:()=>Fa,isPermissionNotFoundError:()=>Ga,isPermissionSavedNotFoundError:()=>Wa,isPluginNotFoundError:()=>ba,isProjectNotFoundError:()=>Ua,isProviderNotFoundError:()=>Pa,isProviderRequestError:()=>La,isPtyNotFoundError:()=>Ya,isRpcError:()=>qa,isRpcInternalError:()=>Ja,isServiceUnavailableError:()=>va,isSessionBusyError:()=>ka,isSessionNotFoundError:()=>Sa,isShellNotFoundError:()=>Xa,isSkillNotFoundError:()=>Oa,isUnauthorizedError:()=>ga,isUnknownError:()=>wa,isUnsupportedModelError:()=>Ia,isVcsInitNotSupportedError:()=>Qa,isWorktreeError:()=>Za}),io=class extends t()(`ClientError`,{cause:ue()}){},R=a.check(ze(0)),z=a.check(Mt(0)),ao=y.pipe(A(`RelativePath`),D({identifier:`RelativePath`})),oo=y.pipe(A(`AbsolutePath`),D({identifier:`AbsolutePath`})),B=e=>fe(e).pipe(wt(w(Ft(e)),{decode:le({strict:!1}),encode:se(jt(e=>e!==void 0))})),so=(e,t)=>Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)),co=e=>t=>so(t,e(t)),lo=N.pipe(wt(ie,{decode:_t(e=>je(e)),encode:_t(e=>_e(e))})),uo=`0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz`,fo=0,po=0;function mo(){return go(!1)}function ho(){return go(!0)}function go(e,t=Date.now()){t!==fo&&(fo=t,po=0),po++;let n=BigInt(t)*4096n+BigInt(po),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=>uo[e%62]).join(``)}var _o=y.pipe(A(`Project.ID`),D({identifier:`Project.ID`}),co(e=>({global:e.make(`global`)}))),vo=y.check(at(`wrk`)).pipe(A(`Workspace.ID`),D({identifier:`Workspace.ID`}),co(e=>{let t=()=>e.make(`wrk_`+mo());return{ascending:n=>n?e.make(n):t(),create:t}})),yo=e({Info:()=>So,Location:()=>yo,PublicInfo:()=>Co,PublicRef:()=>xo,Ref:()=>bo,response:()=>V}),bo=x({directory:oo,workspaceID:B(vo)}).annotate({identifier:`Location.Ref`}),xo=x(re(bo.fields,[`workspaceID`])).annotate({identifier:`Location.PublicRef`}),So=class extends p(`Location.Info`)({directory:oo,workspaceID:B(vo),project:x({id:_o,directory:oo,canonical:oo})}){},Co=x(re(So.fields,[`workspaceID`])).annotate({identifier:`Location.PublicInfo`});function V(e){return x({location:xo,data:e})}var wo=e({Event:()=>wo,ID:()=>To,Seq:()=>Eo,Version:()=>Do,durable:()=>H,durableMap:()=>jo,ephemeral:()=>U,inventory:()=>W,latest:()=>ko,versionedType:()=>Ao}),To=y.check(at(`evt_`)).pipe(A(`Event.ID`),D({identifier:`Event.ID`}),co(e=>({create:()=>e.make(`evt_`+mo())}))),Eo=a.check(Mt(0)).pipe(A(`Event.Seq`),D({identifier:`Event.Seq`})),Do=a.check(Mt(1)).pipe(A(`Event.Version`),D({identifier:`Event.Version`})),Oo=x({aggregateID:y,seq:Eo,version:Do});function H(e){let t=x(e.schema),n=x({aggregateID:Oo.fields.aggregateID,seq:Oo.fields.seq,version:m(e.durable.version).pipe(wt(Ft(Do),ne({decode:()=>Do.make(e.durable.version),encode:()=>e.durable.version})))});return x({id:To,created:N,metadata:B(b(y,Ie)),type:m(e.type),durable:n,location:B(bo),data:t}).annotate({identifier:e.identifier??e.type}).pipe(co(()=>({type:e.type,durability:`durable`,durable:e.durable,data:t})))}function U(e){let t=x(e.schema);return x({id:To,created:N,metadata:B(b(y,Ie)),type:m(e.type),location:B(bo),data:t}).annotate({identifier:e.identifier??e.type}).pipe(co(()=>({type:e.type,durability:`ephemeral`,durable:void 0,data:t})))}function W(...e){return Object.freeze(e)}function ko(e){return Mo(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 Ao(e,t){return`${e}.${t}`}function jo(e){return Mo(e.reduce((e,t)=>{if(t.durability!==`durable`)return e;let n=Ao(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 Mo(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 No=e({DirectorySource:()=>Io,EmbeddedSource:()=>Vo,Event:()=>Bo,ID:()=>Po,Info:()=>Ro,Name:()=>Fo,Skill:()=>No,Source:()=>Ho,UrlSource:()=>Lo}),Po=y.pipe(A(`Skill.ID`),D({identifier:`Skill.ID`})),Fo=y.pipe(A(`Skill.Name`),D({identifier:`Skill.Name`})),Io=x({type:_(`directory`),path:oo}).annotate({identifier:`Skill.DirectorySource`}),Lo=x({type:_(`url`),url:y}).annotate({identifier:`Skill.UrlSource`}),Ro=x({id:Po,name:Fo,description:y.pipe(B),autoinvoke:g.pipe(B),path:oo,content:y}).annotate({identifier:`Skill.Info`}),zo=U({type:`skill.updated`,schema:{}}),Bo={Updated:zo,Definitions:W(zo)},Vo=x({type:_(`embedded`),skill:pe(()=>Ro)}).annotate({identifier:`Skill.EmbeddedSource`}),Ho=Object.assign(C([Io,Lo,Vo]).pipe(ye(`type`),D({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}`}),Uo=class extends t()(`LocationNotFoundError`,{location:xo,message:y},{httpApiStatus:404}){},Wo=class extends t()(`InvalidRequestError`,{message:y,kind:w(y),field:w(y)},{httpApiStatus:400}){},Go=class extends t()(`RpcError`,{type:y,message:y,data:w(Ie)},{httpApiStatus:400}){},Ko=class extends t()(`RpcInternalError`,{type:v([`rpc.internal`,`rpc.invalid_output`]),message:y,data:w(Ie)},{httpApiStatus:500}){},qo=class extends t()(`UnauthorizedError`,{message:y},{httpApiStatus:401}){},Jo=class extends t()(`ConflictError`,{message:y,resource:w(y)},{httpApiStatus:409}){},Yo=class extends t()(`SessionBusyError`,{sessionID:y,message:y},{httpApiStatus:409}){},Xo=class extends t()(`ServiceUnavailableError`,{message:y,service:w(y)},{httpApiStatus:503}){},Zo=class extends t()(`UnknownError`,{message:y,ref:w(y)},{httpApiStatus:500}){},Qo=class extends t()(`ProviderNotFoundError`,{providerID:y,message:y},{httpApiStatus:404}){},$o=class extends t()(`IntegrationNotFoundError`,{integrationID:y,message:y},{httpApiStatus:404}){},es=class extends t()(`IntegrationAttemptNotFoundError`,{integrationID:y,attemptID:y,message:y},{httpApiStatus:404}){},ts=class extends t()(`IntegrationMethodNotFoundError`,{integrationID:y,methodID:y,message:y},{httpApiStatus:404}){},ns=class extends t()(`ProjectNotFoundError`,{projectID:y,message:y},{httpApiStatus:404}){},rs=class extends t()(`FileNotFoundError`,{path:y,message:y},{httpApiStatus:404}){},is=class extends t()(`PluginNotFoundError`,{pluginID:y,message:y},{httpApiStatus:404}){},as=class extends t()(`AgentNotFoundError`,{agentID:y,message:y},{httpApiStatus:404}){},G=class extends t()(`SessionNotFoundError`,{sessionID:y,message:y},{httpApiStatus:404}){},os=class extends t()(`MessageNotFoundError`,{sessionID:y,messageID:y,message:y},{httpApiStatus:404}){},ss=class extends t()(`SkillNotFoundError`,{skill:Po,message:y},{httpApiStatus:404}){},cs=class extends t()(`McpServerNotFoundError`,{server:y,message:y},{httpApiStatus:404}){},ls=class extends t()(`CommandNotFoundError`,{command:y,message:y},{httpApiStatus:404}){},us=class extends t()(`CommandExecutionError`,{command:y,message:y},{httpApiStatus:500}){},ds=class extends t()(`InvalidCursorError`,{message:y},{httpApiStatus:400}){},fs=class extends t()(`PermissionNotFoundError`,{requestID:y,message:y},{httpApiStatus:404}){},ps=class extends t()(`PermissionSavedNotFoundError`,{id:y,message:y},{httpApiStatus:404}){},ms=class extends t()(`FormNotFoundError`,{id:y,message:y},{httpApiStatus:404}){},hs=class extends t()(`FormAlreadySettledError`,{id:y,message:y},{httpApiStatus:409}){},gs=class extends t()(`FormInvalidAnswerError`,{id:y,message:y},{httpApiStatus:400}){},_s=class extends t()(`ForbiddenError`,{message:y},{httpApiStatus:403}){},vs=class extends t()(`PtyNotFoundError`,{ptyID:y,message:y},{httpApiStatus:404}){},ys=class extends t()(`ShellNotFoundError`,{id:y,message:y},{httpApiStatus:404}){},bs=class extends t()(`ModelNotFoundError`,{providerID:y,modelID:y,message:y},{httpApiStatus:404}){},xs=class extends t()(`UnsupportedModelError`,{providerID:y,modelID:y,capability:y,message:y},{httpApiStatus:422}){},Ss=class extends t()(`ProviderRequestError`,{providerID:y,reason:v([`authentication`,`rate_limit`,`content_filter`,`invalid_request`,`overloaded`,`provider`]),message:y,status:w(a),retryAfterMs:w(a)},{httpApiStatus:502}){},Cs=class extends tt()(`@opencode/HttpApiSchemaError`,{error:Wo}){},ws=y.pipe(A(`Integration.ID`),D({identifier:`Integration.ID`})),Ts=y.pipe(A(`Integration.MethodID`),D({identifier:`Integration.MethodID`})),Es=e({CreateInput:()=>Is,Credential:()=>Es,Entry:()=>Fs,Event:()=>As,External:()=>Ns,ID:()=>Ds,Key:()=>Ms,OAuth:()=>js,Value:()=>Ps}),Ds=y.pipe(A(`Credential.ID`),D({identifier:`Credential.ID`}),co(e=>({create:()=>e.make(`cred_`+mo())}))),Os=U({type:`credential.updated`,schema:{}}),ks=U({type:`credential.switched`,schema:{integrationID:ws,credentialID:ce(Ds)}}),As={Updated:Os,Switched:ks,Definitions:W(Os,ks)},js=x({type:m(`oauth`),methodID:Ts,refresh:y,access:y,expires:z,metadata:B(b(y,Ie))}).annotate({identifier:`Credential.OAuth`}),Ms=x({type:m(`key`),key:y,metadata:B(b(y,Ie))}).annotate({identifier:`Credential.Key`}),Ns=x({type:m(`external`),methodID:Ts,metadata:B(b(y,Ie))}).annotate({identifier:`Credential.External`}),Ps=C([js,Ms,Ns]).pipe(ye(`type`)).annotate({identifier:`Credential.Value`}),Fs=x({id:Ds,integrationID:ws,label:y,active:g,value:Ps}).annotate({identifier:`Credential.Entry`}),Is=x({id:B(Ds),integrationID:ws,label:B(y),value:Ps,activate:B(g)}).annotate({identifier:`Credential.CreateInput`}),Ls=x({status:v([`needs_auth`]),message:y,url:B(y)}).annotate({identifier:`Connection.Status`}),Rs=x({type:m(`credential`),id:Ds,label:y,method:v([`key`,`oauth`,`external`]),status:B(Ls)}).annotate({identifier:`Connection.CredentialInfo`}),zs=x({type:m(`env`),name:y,status:B(Ls)}).annotate({identifier:`Connection.EnvInfo`}),Bs=C([Rs,zs]).pipe(ye(`type`)).annotate({identifier:`Connection.Info`}),Vs=e({Answer:()=>ic,BooleanField:()=>Xs,Detail:()=>oc,Event:()=>dc,ExternalField:()=>Qs,Field:()=>$s,Fields:()=>ec,Form:()=>Vs,ID:()=>Hs,Info:()=>nc,IntegerField:()=>Ys,Metadata:()=>Us,MultiselectField:()=>Zs,NumberField:()=>Js,Option:()=>Ws,Reply:()=>sc,State:()=>ac,StringField:()=>qs,Value:()=>rc,When:()=>Gs}),Hs=y.check(at(`frm_`)).pipe(A(`Form.ID`),D({identifier:`Form.ID`})).pipe(co(e=>({create:t=>e.make(t??`frm_`+mo())}))),Us=b(y,Ie).annotate({identifier:`Form.Metadata`}),Ws=x({value:y,label:y,description:y.pipe(B)}).annotate({identifier:`Form.Option`}),Gs=x({key:y,op:v([`eq`,`neq`]),value:C([y,gt,g])}).annotate({identifier:`Form.When`}),Ks={key:y,title:y.pipe(B),description:y.pipe(B),required:g.pipe(B),hidden:g.pipe(B).annotate({description:`Skip the interactive authentication prompt and use the default unless an answer is supplied`}),when:h(Gs).pipe(B)},qs=x({...Ks,type:m(`string`),format:v([`email`,`uri`,`date`,`date-time`]).pipe(B),minLength:z.pipe(B),maxLength:z.pipe(B),pattern:y.pipe(B),placeholder:y.pipe(B),default:y.pipe(B),options:h(Ws).pipe(B),custom:g.pipe(B)}).annotate({identifier:`Form.StringField`}),Js=x({...Ks,type:m(`number`),minimum:gt.pipe(B),maximum:gt.pipe(B),default:gt.pipe(B)}).annotate({identifier:`Form.NumberField`}),Ys=x({...Ks,type:m(`integer`),minimum:gt.pipe(B),maximum:gt.pipe(B),default:gt.pipe(B)}).annotate({identifier:`Form.IntegerField`}),Xs=x({...Ks,type:m(`boolean`),default:g.pipe(B)}).annotate({identifier:`Form.BooleanField`}),Zs=x({...Ks,type:m(`multiselect`),options:h(Ws),minItems:z.pipe(B),maxItems:z.pipe(B),custom:g.pipe(B),default:h(y).pipe(B)}).annotate({identifier:`Form.MultiselectField`}),Qs=x({key:y,type:m(`external`),url:y,title:y.pipe(B),description:y.pipe(B)}).annotate({identifier:`Form.ExternalField`}),$s=C([qs,Js,Ys,Xs,Zs,Qs]).pipe(ye(`type`),D({identifier:`Form.Field`})),ec=De($s).annotate({identifier:`Form.Fields`}),tc={id:Hs,sessionID:y,title:y,metadata:Us.pipe(B)},nc=x({...tc,fields:ec}).annotate({identifier:`Form.Info`}),rc=C([y,gt,g,h(y)]).annotate({identifier:`Form.Value`}),ic=b(y,rc).annotate({identifier:`Form.Answer`}),ac=C([x({status:m(`pending`)}),x({status:m(`answered`),answer:ic}),x({status:m(`cancelled`),message:y.pipe(B)})]).pipe(ye(`status`)).annotate({identifier:`Form.State`}),oc=x({...nc.fields,state:ac}).annotate({identifier:`Form.Detail`}),sc=x({answer:ic}).annotate({identifier:`Form.Reply`}),cc=U({type:`form.created`,schema:{form:nc}}),lc=U({type:`form.replied`,schema:{id:Hs,sessionID:y,answer:ic}}),uc=U({type:`form.cancelled`,schema:{id:Hs,sessionID:y}}),dc={Created:cc,Replied:lc,Cancelled:uc,Definitions:W(cc,lc,uc)},fc=e({Attempt:()=>Dc,AttemptID:()=>Tc,AttemptStatus:()=>Oc,CommandAttempt:()=>kc,CommandAttemptStatus:()=>Ac,CommandMethod:()=>gc,EnvMethod:()=>yc,Event:()=>Sc,ExternalMethod:()=>vc,ID:()=>pc,Info:()=>wc,Integration:()=>fc,KeyMethod:()=>_c,Method:()=>bc,MethodID:()=>mc,OAuthMethod:()=>hc,Ref:()=>Cc}),pc=ws,mc=Ts,hc=x({id:mc,type:m(`oauth`),label:y,form:B(ec)}).annotate({identifier:`Integration.OAuthMethod`}),gc=x({id:mc,type:m(`command`),label:y,command:h(y)}).annotate({identifier:`Integration.CommandMethod`}),_c=x({type:m(`key`),label:B(y),form:B(ec)}).annotate({identifier:`Integration.KeyMethod`}),vc=x({id:mc,type:m(`external`),label:y,form:B(ec)}).annotate({identifier:`Integration.ExternalMethod`}),yc=x({type:m(`env`),names:h(y)}).annotate({identifier:`Integration.EnvMethod`}),bc=C([hc,gc,_c,vc,yc]).pipe(ye(`type`)).annotate({identifier:`Integration.Method`}),xc=U({type:`integration.updated`,schema:{}}),Sc={Updated:xc,Definitions:W(xc)},Cc=x({id:pc,name:y,metadata:B(b(y,rt))}).annotate({identifier:`Integration.Ref`}),wc=x({id:pc,name:y,metadata:B(b(y,rt)),methods:h(bc),connections:h(Bs)}).annotate({identifier:`Integration.Info`}),Tc=y.pipe(A(`Integration.AttemptID`),D({identifier:`Integration.AttemptID`}),co(e=>({create:()=>e.make(`con_`+mo())}))),Ec=x({created:gt,expires:gt}),Dc=class extends p(`Integration.Attempt`)({attemptID:Tc,url:y,instructions:y,mode:v([`auto`,`code`]),time:Ec}){},Oc=C([x({status:m(`pending`),time:Ec}),x({status:m(`complete`),time:Ec}),x({status:m(`failed`),message:y,time:Ec}),x({status:m(`expired`),time:Ec})]).pipe(ye(`status`)).annotate({identifier:`Integration.AttemptStatus`}),kc=x({attemptID:Tc,time:Ec}).annotate({identifier:`Integration.CommandAttempt`}),Ac=C([x({status:m(`pending`),message:B(y),time:Ec}),x({status:m(`complete`),time:Ec}),x({status:m(`failed`),message:y,time:Ec}),x({status:m(`expired`),time:Ec})]).pipe(ye(`status`)).annotate({identifier:`Integration.CommandAttemptStatus`}),jc=C([v([`reasoning`,`reasoning_content`,`reasoning_text`]),y]).annotate({identifier:`Model.ReasoningField`}),Mc=v([`max_completion_tokens`,`max_tokens`]).annotate({identifier:`Model.MaxTokensField`}),Nc=v([`assets`,`state`,`root`]).annotate({identifier:`Model.MediaInput`}),Pc=v([`anthropic`,`alibaba`]).annotate({identifier:`Model.CacheFormat`}),Fc=x({reasoningField:jc.pipe(B),requireReasoning:g.pipe(B),maxTokensField:Mc.pipe(B),requireFinishReason:g.pipe(B),requireAssistantAfterTool:g.pipe(B),supportsPromptCacheKey:g.pipe(B),streamUsage:g.pipe(B),cacheFormat:Pc.pipe(B),supportsThinkingBlockBinding:g.pipe(B),supportsEffortUpdates:g.pipe(B),mediaInput:Nc.pipe(B)}).annotate({identifier:`Model.Compatibility`}),Ic=x(re(Fc.fields,[`supportsThinkingBlockBinding`,`supportsEffortUpdates`])).annotate({identifier:`Provider.Compatibility`}),Lc=e({Activation:()=>Hc,Cache:()=>Kc,CacheTTL:()=>Gc,Compaction:()=>Uc,Encoding:()=>qc,Event:()=>Bc,ID:()=>Rc,Info:()=>Qc,Overlays:()=>Xc,Package:()=>Vc,Provider:()=>Lc,Request:()=>Zc,Settings:()=>Yc,Transport:()=>Wc}),Rc=y.pipe(A(`Provider.ID`),D({identifier:`Provider.ID`}),co(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`)}))),zc=U({type:`provider.updated`,schema:{}}),Bc={Updated:zc,Definitions:W(zc)},Vc=y,Hc=v([`auto`,`enabled`,`disabled`]),Uc=C([x({type:m(`summary`)}),x({type:m(`native`)})]).pipe(ye(`type`)).annotate({identifier:`Provider.Compaction`}),Wc=v([`http`,`websocket`]).annotate({identifier:`Provider.Transport`}),Gc=Ke([gt,v([`ms`,`s`,`m`,`h`,`d`])]).check(f(/^\d+(ms|s|m|h|d)$/)).annotate({identifier:`Provider.CacheTTL`}),Kc=x({ttl:Gc.pipe(B)}).annotate({identifier:`Provider.Cache`}),qc=v([`zstd`,`gzip`,`none`]).annotate({identifier:`Provider.Encoding`}),Jc=C([N,m(!1)]).pipe(B),Yc=ge(x({timeout:Jc,headerTimeout:Jc,chunkTimeout:Jc,compaction:Uc.pipe(B),cache:Kc.pipe(B),transport:Wc.pipe(B),encoding:qc.pipe(B)}),[b(y,rt)]).annotate({identifier:`Provider.Settings`}),Xc={settings:Yc.pipe(B),headers:b(y,y).pipe(B),body:b(y,rt).pipe(B)},Zc=x({settings:Yc.pipe(o(ht({}))),headers:b(y,y),body:b(y,rt)}).annotate({identifier:`Provider.Request`}),Qc=x({id:Rc,canonical:Rc.pipe(B),integrationID:pc.pipe(B),name:y,activation:Hc,package:Vc,compatibility:Ic.pipe(B),...Xc}).annotate({identifier:`Provider.Info`}).pipe(co(()=>({empty:e=>({id:e,name:e,activation:`auto`,package:``})}))),$c=N.pipe(A(`Money.USD`),D({identifier:`Money.USD`}),co(e=>({zero:e.make(0)}))),el=N.pipe(A(`Money.USDPerMillionTokens`),D({identifier:`Money.USDPerMillionTokens`}),co(e=>({zero:e.make(0)}))),tl=e({Capabilities:()=>dl,Compatibility:()=>Fc,Cost:()=>fl,Event:()=>il,Family:()=>sl,ID:()=>nl,Info:()=>ml,MaxTokensField:()=>Mc,MediaInput:()=>Nc,Model:()=>tl,Overlays:()=>ul,ReasoningField:()=>jc,Ref:()=>ol,Settings:()=>ll,Type:()=>cl,Variant:()=>pl,VariantID:()=>al}),nl=y.pipe(A(`Model.ID`)),rl=U({type:`model.updated`,schema:{}}),il={Updated:rl,Definitions:W(rl)},al=y.pipe(A(`Model.VariantID`)),ol=x({id:nl,providerID:Rc,variant:al.pipe(B)}).annotate({identifier:`Model.Ref`}).pipe(co(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:Rc.make(r),id:nl.make(a),...o?{variant:al.make(o)}:{}})}}))),sl=y.pipe(A(`Model.Family`)),cl=C([v([`chat`,`decision`,`image`]),y]).annotate({identifier:`Model.Type`}),ll=ge(x(we(Yc.schema.fields,[`compaction`,`cache`,`encoding`])),[b(y,rt)]).annotate({identifier:`Model.Settings`}),ul={settings:ll.pipe(B),headers:b(y,y).pipe(B),body:b(y,rt).pipe(B)},dl=x({tools:g,input:h(y),output:h(y),temperature:g.pipe(B)}).annotate({identifier:`Model.Capabilities`}).pipe(co(()=>({default:()=>({tools:!0,input:[`text`,`image`],output:[`text`]})}))),fl=x({tier:x({type:_(`context`),size:a}).pipe(B),input:el,output:el,cache:x({read:el,write:el})}).annotate({identifier:`Model.Cost`}),pl=x({id:al,...ul}).annotate({identifier:`Model.Variant`}),ml=x({id:nl,modelID:nl,providerID:Rc,canonical:Rc.pipe(B),type:cl.pipe(B),family:sl.pipe(B),name:y,compatibility:Fc.pipe(B),package:Vc.pipe(B),...ul,capabilities:dl,variants:h(pl),time:x({released:N}),cost:h(fl),status:v([`alpha`,`beta`,`deprecated`,`active`]),enabled:g,limit:x({context:a,input:a.pipe(B),output:a})}).annotate({identifier:`Model.Info`}).pipe(co(()=>({default:(e,t)=>({id:t,modelID:t,providerID:e,name:t,capabilities:dl.default(),variants:[],time:{released:0},cost:[],status:`active`,enabled:!0,limit:{context:2e5,output:32e3}})}))),hl=x({start:N,end:N,text:y}).annotate({identifier:`Prompt.Mention`}),gl=C([x({type:m(`inline`)}),x({type:m(`uri`),uri:y})]).pipe(ye(`type`)).annotate({identifier:`Prompt.FileSource`}),_l=y.check(i(e=>e.length%4==0&&/^[A-Za-z0-9+/]*={0,2}$/u.test(e),f(/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/u).annotations)).annotate({identifier:`Prompt.Base64`}),vl=x({data:_l,mime:y,source:gl,name:y.pipe(B),description:y.pipe(B),mention:hl.pipe(B)}).annotate({identifier:`Prompt.FileAttachment`}).pipe(co(e=>({create:t=>e.make({data:t.data,mime:t.mime,source:t.source,name:t.name,description:t.description,mention:t.mention})}))),yl=y.check(f(/^media:[0-9a-f]{64}$/)).annotate({identifier:`Prompt.MediaRef`}),{data:bl,...xl}=vl.fields,Sl=x({...xl,uri:yl,bytes:a.pipe(B),width:a.pipe(B),height:a.pipe(B)}).annotate({identifier:`Prompt.MediaFileAttachment`}),Cl=C([vl,Sl]).annotate({identifier:`Prompt.Attachment`}),wl=x({name:y,mention:hl.pipe(B)}).annotate({identifier:`Prompt.AgentAttachment`}),Tl=x({id:Po,name:Fo,text:y.pipe(B),mention:hl.pipe(B)}).annotate({identifier:`Prompt.SkillAttachment`}),El=x({text:y,files:h(vl).pipe(B),agents:h(wl).pipe(B),skills:h(Tl).pipe(B)}).annotate({identifier:`Prompt`}).pipe(co(e=>({equivalence:ae(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}})}))),Dl=e=>({description:e}),Ol=x({data:_l,mime:y,name:y.pipe(B)}).annotate({identifier:`Generate.File`}),kl=x({input:N.pipe(B),output:N.pipe(B)}).annotate({identifier:`Generate.Usage`,description:`Token counts, when the provider reports them`}),Al=b(y,Ie).annotate({identifier:`Generate.Native`,description:`Provider-specific data the shared fields do not cover`}),jl=Ke([gt,`:`,gt]).check(f(/^\d+(?:\.\d+)?:\d+(?:\.\d+)?$/)).annotate({identifier:`Generate.ImageAspect`,description:`Aspect ratio as width:height, for example 16:9`}),Ml=C([v([`1K`,`2K`,`4K`]),y]).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`}),Nl=x({model:ol,prompt:y,images:h(Ol).pipe(B).annotate(Dl(`Edit sources or style and subject references, in order`)),n:R.pipe(B).annotate(Dl(`Number of images to generate; defaults to 1`)),aspect:jl.pipe(B),resolution:Ml.pipe(B)}).annotate({identifier:`Generate.ImageRequest`}),Pl=x({type:m(`image`),...Ol.fields}).annotate({identifier:`Generate.ImageOutput`}),Fl=x({images:h(Pl),cost:$c.pipe(B),tokens:kl.pipe(B),native:Al.pipe(B)}).annotate({identifier:`Generate.ImageResult`}),Il=x({type:m(`text`),text:y}).annotate({identifier:`Generate.DecisionTextPart`}),Ll=x({type:m(`json`),value:Te}).annotate({identifier:`Generate.DecisionJsonPart`}),Rl=x({type:m(`file`),...Ol.fields}).annotate({identifier:`Generate.DecisionFilePart`}),zl=C([Il,Ll,Rl]).annotate({identifier:`Generate.DecisionPart`}),Bl=C([y,g]).annotate({identifier:`Generate.ChoiceValue`,description:`Choice values are typed: true and "true" are different values`}),Vl=y.annotate(Dl(`Unique within the request; echoed on the matching answer`)),Hl=x({type:m(`predicate`),name:Vl,instructions:y}).annotate({identifier:`Generate.PredicateQuestion`,description:`The probability that a statement is true`}),Ul=x({type:m(`choice`),name:Vl,instructions:y,choices:h(x({value:Bl,description:y.pipe(B)})).check(kt(1))}).annotate({identifier:`Generate.ChoiceQuestion`,description:`Pick one value from a fixed set`}),Wl=x({type:m(`score`),name:Vl,instructions:y,levels:h(x({label:y,description:y.pipe(B)})).check(kt(1))}).annotate({identifier:`Generate.ScoreQuestion`,description:`Place the input on ordered levels, lowest first`}),Gl=C([Hl,Ul,Wl]).annotate({identifier:`Generate.DecisionQuestion`}),Kl=x({model:ol,input:h(zl).annotate(Dl(`The evidence every question is asked about, in order`)),questions:h(Gl).check(kt(1)).annotate(Dl(`Question names must be unique; duplicates fail with InvalidRequestError`))}).annotate({identifier:`Generate.DecisionRequest`}),ql=N.check(Pt({minimum:0,maximum:1})),Jl=x({type:m(`predicate`),name:y,probability:ql}).annotate({identifier:`Generate.PredicateAnswer`}),Yl=x({type:m(`choice`),name:y,choice:Bl,probabilities:h(x({value:Bl,probability:ql})),confidence:ql}).annotate({identifier:`Generate.ChoiceAnswer`}),Xl=x({type:m(`score`),name:y,score:N.annotate(Dl(`Probability-weighted level index, so it can fall between levels`)),probabilities:h(x({value:a,label:y,probability:ql})),confidence:ql}).annotate({identifier:`Generate.ScoreAnswer`}),Zl=x({type:m(`error`),name:y,reason:y.annotate(Dl(`Why the question has no answer, for example refusal`)),message:y.pipe(B)}).annotate({identifier:`Generate.ErrorAnswer`,description:`This one question has no answer; the other answers still came back`}),Ql=C([Jl,Yl,Xl,Zl]).annotate({identifier:`Generate.DecisionAnswer`}),$l=x({answers:h(Ql).annotate(Dl(`One answer per question, in question order`)),cost:$c.pipe(B),tokens:kl.pipe(B),native:Al.pipe(B)}).annotate({identifier:`Generate.DecisionResult`}),eu=[Wo,Qo,bs,xs,Ss,Xo,Uo],tu={payload:x({prompt:y,model:ol.pipe(w)}),success:x({data:x({text:y})}).annotate({identifier:`GenerateTextResponse`}),error:eu},nu=j(`server.generate`).add(T(`generate.text`,`/api/experimental/generate/text`,tu).annotateMerge(O({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(T(`generate.textLegacy`,`/api/experimental/generate`,tu).annotateMerge(O({identifier:`experimental.generate.textLegacy`,summary:`Generate text (deprecated path)`,description:`Deprecated alias of POST /api/experimental/generate/text.`,deprecated:!0}))).add(T(`generate.image`,`/api/experimental/generate/image`,{payload:Nl,success:x({data:Fl}).annotate({identifier:`GenerateImageResponse`}),error:eu}).annotateMerge(O({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(T(`generate.decisions`,`/api/experimental/generate/decisions`,{payload:Kl,success:x({data:$l}).annotate({identifier:`GenerateDecisionsResponse`}),error:eu}).annotateMerge(O({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(O({title:`generate`,description:`Experimental one-shot generation routes.`})),ru=y.check(f(/^[0-9a-f]{64}$/u)).annotate({identifier:`MediaHash`}),iu=k(`media.get`,`/api/experimental/media/:hash`,{params:{hash:ru},success:dt.pipe(mt()),error:[rs,Wo]}).annotateMerge(O({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`]})})),au=e({CreateInput:()=>pu,Event:()=>fu,ID:()=>ou,Info:()=>su,Pty:()=>au,UpdateInput:()=>mu}),ou=y.check(at(`pty`)).pipe(A(`PtyID`),D({identifier:`Pty.ID`})).pipe(co(e=>{let t=()=>e.make(`pty_`+mo());return{create:t,ascending:n=>n===void 0?t():e.make(n)}})),su=x({id:ou,title:y,command:y,args:h(y),cwd:y,status:v([`running`,`exited`]),pid:z,exitCode:B(z)}).annotate({identifier:`Pty`}),cu=U({type:`pty.created`,schema:{info:su}}),lu=U({type:`pty.updated`,schema:{info:su}}),uu=U({type:`pty.exited`,schema:{id:ou,exitCode:z}}),du=U({type:`pty.deleted`,schema:{id:ou}}),fu={Created:cu,Updated:lu,Exited:uu,Deleted:du,Definitions:W(cu,lu,uu,du)},pu=x({command:B(y),args:B(h(y)),cwd:B(y),title:B(y),env:B(b(y,y))}),mu=x({title:B(y),size:B(x({rows:R,cols:R}))}),hu=y.check(at(`ses`)).pipe(A(`SessionID`),D({identifier:`Session.ID`}),co(e=>({create:()=>e.make(`ses_`+ho())}))),gu=e({Effect:()=>Tu,Event:()=>wu,ID:()=>_u,Permission:()=>gu,Reply:()=>xu,Request:()=>bu,Rule:()=>Eu,Ruleset:()=>Du,Source:()=>vu}),_u=y.check(at(`per`)).pipe(A(`Permission.ID`),D({identifier:`Permission.ID`}),co(e=>({create:t=>e.make(t??`per_`+mo())}))),vu=C([x({type:m(`tool`),messageID:y,id:y})]).annotate({identifier:`Permission.Source`}),yu={sessionID:hu,action:y,resources:h(y),save:h(y).pipe(B),metadata:b(y,Ie).pipe(B),source:vu.pipe(B),message:y.pipe(B)},bu=x({id:_u,...yu}).annotate({identifier:`Permission.Request`}),xu=v([`once`,`always`,`reject`]).annotate({identifier:`Permission.Reply`}),Su=U({type:`permission.asked`,schema:bu.fields}),Cu=U({type:`permission.replied`,schema:{sessionID:hu,requestID:_u,reply:xu}}),wu={Asked:Su,Replied:Cu,Definitions:W(Su,Cu)},Tu=v([`allow`,`deny`,`ask`]).annotate({identifier:`Permission.Effect`}),Eu=x({action:y,resource:y,effect:Tu}).annotate({identifier:`Permission.Rule`}),Du=h(Eu).annotate({identifier:`Permission.Ruleset`}),Ou=e({Agent:()=>Ou,Color:()=>Mu,Event:()=>Pu,ID:()=>Au,Info:()=>Nu,Name:()=>ju}),ku=U({type:`agent.updated`,schema:{}}),Au=y.pipe(A(`Agent.ID`),D({identifier:`Agent.ID`})),ju=y.pipe(A(`Agent.Name`)),Mu=y.annotate({identifier:`Agent.Color`}),Nu=x({id:Au,name:ju,model:ol.pipe(B),request:Zc,system:y.pipe(B),description:y.pipe(B),mode:v([`subagent`,`primary`,`all`]),hidden:g,color:Mu.pipe(B),steps:R.pipe(B),permissions:Du}).annotate({identifier:`Agent.Info`}).pipe(co(()=>({default:e=>({id:e,name:ju.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`}]})}))),Pu={Updated:ku,Definitions:W(ku)},Fu=e({Commands:()=>Bu,Current:()=>Ru,Event:()=>Gu,ID:()=>Iu,Icon:()=>zu,Info:()=>Hu,Project:()=>Fu,Time:()=>Vu,UpdateInput:()=>Uu,Vcs:()=>Lu}),Iu=_o,Lu=y.check(f(/^[a-z][a-z0-9._-]*$/u)).annotate({identifier:`Project.Vcs`}),Ru=x({id:Iu,directory:oo,canonical:oo}).annotate({identifier:`Project.Current`}),zu=x({url:B(y),override:B(y),color:B(y)}).annotate({identifier:`Project.Icon`}),Bu=x({start:B(y.annotate({description:`Startup script to run when creating a new workspace (worktree)`}))}).annotate({identifier:`Project.Commands`}),Vu=x({created:z,updated:z,active:z,archived:B(z)}).annotate({identifier:`Project.Time`}),Hu=x({id:Iu,canonical:oo,vcs:B(Lu),name:B(y),icon:B(zu),commands:B(Bu),time:Vu,sandboxes:h(y)}).annotate({identifier:`Project`}),Uu=x({projectID:Iu,canonical:B(oo),name:B(y),icon:B(zu),commands:B(Bu)}).annotate({identifier:`Project.UpdateInput`}),Wu=U({type:`project.updated`,schema:Hu.fields}),Gu={Updated:Wu,Definitions:W(Wu)},Ku=v([`stop`,`length`,`tool-calls`,`content-filter`,`error`,`unknown`]);y.pipe(A(`Tool.CallID`)),t()(`Tool.Error`,{message:y,error:w(ue()),metadata:w(b(y,Ie))});var qu=x({type:m(`text`),text:y}).annotate({identifier:`Tool.TextContent`}),Ju=x({type:m(`file`),uri:y,mime:y,name:w(y)}).annotate({identifier:`Tool.FileContent`}),Yu=C([qu,Ju]).pipe(ye(`type`)).annotate({identifier:`Tool.Content`}),Xu=b(y,Te).annotate({identifier:`Session.Metadata`}),Zu=y.check(at(`sh_`)).pipe(A(`Shell.ID`),D({identifier:`Shell.ID`})).pipe(co(e=>{let t=()=>e.make(`sh_`+mo());return{create:t,ascending:n=>n===void 0?t():e.make(n)}})),Qu=v([`running`,`exited`,`timeout`,`killed`]),$u=x({started:N.annotate({description:`Start time in milliseconds since the Unix epoch`}),completed:B(N).annotate({description:`Completion time in milliseconds since the Unix epoch`})}),ed=b(y,Ie),td=x({id:Zu,status:Qu,command:y,cwd:y,shell:y,file:y,pid:B(z),exit:B(N),signal:B(y),metadata:ed,time:$u}).annotate({identifier:`Shell.Info`}),nd=U({type:`shell.created`,schema:{info:td}}),rd=U({type:`shell.exited`,schema:{id:Zu,exit:B(N),status:Qu}}),id=U({type:`shell.deleted`,schema:{id:Zu}}),ad={Created:nd,Exited:rd,Deleted:id,Definitions:W(nd,rd,id)},od=x({command:y,cwd:B(y),timeout:B(z),metadata:B(ed)}),sd=x({cursor:B(z),limit:B(z)}),cd=x({output:y,cursor:z,size:z,truncated:g}),ld=x({type:y,message:y,status:a.check(Pt({minimum:100,maximum:599})).pipe(B),response:x({body:y}).pipe(B),retryAfterMs:z.pipe(B)}).annotate({identifier:`Session.StructuredError`}),ud=y.pipe(A(`Snapshot.ID`),D({identifier:`Snapshot.ID`})),dd=x({input:N,output:N,reasoning:N,cache:x({read:N,write:N})}).annotate({identifier:`TokenUsage.Info`}),fd=e({AgentSelected:()=>hd,Assistant:()=>Fd,AssistantContent:()=>Md,AssistantContentEncoded:()=>Nd,AssistantReasoning:()=>jd,AssistantRetry:()=>Pd,AssistantText:()=>Ad,AssistantTool:()=>kd,Compaction:()=>Vd,CompactionCompleted:()=>zd,CompactionFailed:()=>Bd,CompactionRunning:()=>Rd,ID:()=>K,Idle:()=>Hd,Info:()=>Ud,LocationSwitched:()=>_d,MediaInfo:()=>Wd,MediaUser:()=>yd,ModelSelected:()=>gd,Native:()=>md,SessionMessage:()=>fd,Shell:()=>Cd,Skill:()=>Sd,Synthetic:()=>bd,System:()=>xd,ToolState:()=>Od,ToolStateCompleted:()=>Ed,ToolStateError:()=>Dd,ToolStateRunning:()=>Td,ToolStateStreaming:()=>wd,User:()=>vd}),K=y.check(at(`msg_`)).pipe(A(`Session.Message.ID`),D({identifier:`Session.Message.ID`}),co(e=>({create:()=>e.make(`msg_`+mo()),fromEvent:t=>e.make(t.replace(/^evt_/,`msg_`))}))),pd={id:K,metadata:b(y,Ie).pipe(B),time:x({created:lo})},md=b(y,Ie).annotate({identifier:`Session.Message.Native`}),hd=x({...pd,type:_(`agent-switched`),agent:Au,previous:Au.pipe(B)}).annotate({identifier:`Session.Message.AgentSelected`}),gd=x({...pd,type:_(`model-switched`),model:ol,previous:ol.pipe(B)}).annotate({identifier:`Session.Message.ModelSelected`}),_d=x({...pd,type:_(`location-switched`),location:bo,projectID:Iu.pipe(B),subpath:ao.pipe(B),previous:x({location:bo,projectID:Iu.pipe(B),subpath:ao.pipe(B)}).pipe(B)}).annotate({identifier:`Session.Message.LocationSwitched`}),vd=x({...pd,text:El.fields.text,files:El.fields.files,agents:El.fields.agents,skills:El.fields.skills,type:_(`user`)}).annotate({identifier:`Session.Message.User`}),yd=x({...vd.fields,files:h(Cl).pipe(B)}).annotate({identifier:`Session.Message.MediaUser`}),bd=x({...pd,text:y,description:y.pipe(B),type:_(`synthetic`)}).annotate({identifier:`Session.Message.Synthetic`}),xd=x({...pd,type:_(`system`),text:y,description:y.pipe(B)}).annotate({identifier:`Session.Message.System`}),Sd=x({...pd,type:_(`skill`),skill:Po,name:Fo,text:y}).annotate({identifier:`Session.Message.Skill`}),Cd=x({...pd,type:_(`shell`),shellID:Zu,command:y,status:Qu,exit:gt.pipe(B),output:cd.pipe(B),time:x({created:lo,completed:lo.pipe(B)})}).annotate({identifier:`Session.Message.Shell`}),wd=x({status:_(`streaming`),input:y}).annotate({identifier:`Session.Message.ToolState.Streaming`}),Td=x({status:_(`running`),input:b(y,Ie),metadata:b(y,Te)}).annotate({identifier:`Session.Message.ToolState.Running`}),Ed=x({status:_(`completed`),input:b(y,Ie),content:De(Yu),metadata:b(y,Te).pipe(B)}).annotate({identifier:`Session.Message.ToolState.Completed`}),Dd=x({status:_(`error`),input:b(y,Ie),error:ld,content:De(Yu).pipe(B),metadata:b(y,Te).pipe(B)}).annotate({identifier:`Session.Message.ToolState.Error`}),Od=C([wd,Td,Ed,Dd]).pipe(ye(`status`)),kd=x({type:_(`tool`),id:y,name:y,executed:g.pipe(B),native:md.pipe(B),state:Od,time:x({created:lo,ran:lo.pipe(B),completed:lo.pipe(B)})}).annotate({identifier:`Session.Message.Assistant.Tool`}),Ad=x({type:_(`text`),text:y,native:md.pipe(B)}).annotate({identifier:`Session.Message.Assistant.Text`}),jd=x({type:_(`reasoning`),text:y,native:md.pipe(B),time:x({created:lo,completed:lo.pipe(B)}).pipe(B)}).annotate({identifier:`Session.Message.Assistant.Reasoning`}),Md=C([Ad,jd,kd]).pipe(ye(`type`)),Nd=ee(Md).annotate({identifier:`Session.Message.AssistantContent.Encoded`}),Pd=x({attempt:R,at:lo,error:ld}).annotate({identifier:`Session.Message.Assistant.Retry`}),Fd=x({...pd,type:_(`assistant`),agent:Au,model:ol,content:Md.pipe(h),snapshot:x({start:ud.pipe(B),end:ud.pipe(B),files:h(ao).pipe(B)}).pipe(B),finish:Ku.pipe(B),rawFinish:y.pipe(B),native:md.pipe(B),cost:$c.pipe(B),tokens:dd.pipe(B),error:ld.pipe(B),retry:Pd.pipe(B),time:x({created:lo,streamed:lo.pipe(B),completed:lo.pipe(B)})}).annotate({identifier:`Session.Message.Assistant`}),Id={type:_(`compaction`),...pd},Ld={cost:$c.pipe(B),tokens:dd.pipe(B)},Rd=x({...Id,status:_(`running`),reason:v([`auto`,`manual`]),summary:y}).annotate({identifier:`Session.Message.Compaction.Running`}),zd=x({...Id,status:_(`completed`),reason:v([`auto`,`manual`]),model:ol.pipe(B),native:md.pipe(B),summary:y,...Ld}).annotate({identifier:`Session.Message.Compaction.Completed`}),Bd=x({...Id,status:_(`failed`),reason:v([`auto`,`manual`]),error:ld,...Ld}).annotate({identifier:`Session.Message.Compaction.Failed`}),Vd=C([Rd,zd,Bd]).pipe(ye(`status`),D({identifier:`Session.Message.Compaction`})),Hd=x({...pd,type:_(`idle`),outcome:v([`succeeded`,`failed`,`interrupted`]),error:ld.pipe(B)}).annotate({identifier:`Session.Message.Idle`}),Ud=C([hd,gd,_d,vd,bd,xd,Sd,Cd,Fd,Vd,Hd]).annotate({identifier:`Session.Message.Info`}),Wd=C([hd,gd,_d,yd,bd,xd,Sd,Cd,Fd,Vd,Hd]).annotate({identifier:`Session.Message.MediaInfo`}),Gd=x({file:y,patch:y,additions:z,deletions:z,status:v([`added`,`deleted`,`modified`]),more:m(!0).pipe(B)}).annotate({identifier:`FileDiff.Info`}),Kd=x({file:y.pipe(B),patch:y.pipe(B),additions:N,deletions:N,status:v([`added`,`deleted`,`modified`]).pipe(B)}).annotate({identifier:`FileDiff.LegacyInfo`}),qd=x({messageID:K,partID:y.pipe(B),snapshot:ud.pipe(B),files:h(Gd).pipe(B)}).annotate({identifier:`Session.Revert`}),Jd=x({path:y,status:v([`added`,`modified`,`deleted`]),additions:N,deletions:N,patch:y}),Yd=x({messageID:K,partID:y.pipe(B),snapshot:y.pipe(B),diff:y.pipe(B),files:h(Jd).pipe(B)}).annotate({identifier:`Session.RevertV1`}),Xd=qd.pipe(wt(x({source:_(`current`),revert:Ft(qd)}),ne({decode:e=>({source:`current`,revert:e}),encode:e=>e.revert}))),Zd=Yd.pipe(wt(x({source:_(`legacy`),revert:Ft(Yd)}),ne({decode:e=>({source:`legacy`,revert:e}),encode:e=>e.revert})));C([Xd,Zd]).pipe(ye(`source`),wt(Ft(qd),ne({decode:e=>e.source===`current`?e.revert:qd.make({messageID:e.revert.messageID,partID:e.revert.partID,snapshot:e.revert.snapshot?ud.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})})),D({identifier:`Session.Revert.Persisted`}));var Qd=y.check(f(/^[a-z0-9][a-z0-9._-]*\/[a-z0-9][a-z0-9._/-]*$/u)).pipe(A(`Instruction.Key`),D({identifier:`Instruction.Key`})),$d=y.check(f(/^[a-f0-9]{64}$/u)).pipe(A(`Instruction.Hash`),D({identifier:`Instruction.Hash`})),ef=b(Qd,$d),tf=m(`removed`);tf.make(`removed`);var nf=b(y,C([$d,tf])),rf=y.check(f(/^[a-z0-9][a-z0-9._-]*$/u)).annotate({identifier:`InstructionEntry.Key`,description:`Instruction entry key (lowercase alphanumerics plus . _ -)`}),af=x({key:rf,value:Te.annotate({description:`JSON value attached to the session's instructions`})}).annotate({identifier:`InstructionEntry.Info`}),of=h(x({...af.fields,removed:g})).annotate({identifier:`InstructionEntry.Snapshot`}),sf=class extends t()(`InstructionEntryValueTooLargeError`,{actualBytes:a,maxBytes:a,message:y},{httpApiStatus:413}){},cf=e({Compaction:()=>wf,CompactionPayload:()=>pf,Delivery:()=>lf,Info:()=>Ef,Item:()=>yf,MediaInfo:()=>Df,MediaUser:()=>Sf,MediaUserPayload:()=>df,Move:()=>Tf,MovePayload:()=>mf,SessionInbox:()=>cf,Synthetic:()=>Cf,SyntheticPayload:()=>ff,User:()=>xf,UserPayload:()=>uf}),lf=v([`steer`,`queue`]).annotate({identifier:`Session.Inbox.Delivery`}),uf=x({...El.fields,metadata:b(y,Ie).pipe(B)}).annotate({identifier:`Session.Inbox.UserPayload`}),df=x({...uf.fields,files:h(Cl).pipe(B)}).annotate({identifier:`Session.Inbox.MediaUserPayload`}),ff=x({text:y,description:y.pipe(B),metadata:b(y,Ie).pipe(B)}).annotate({identifier:`Session.Inbox.SyntheticPayload`}),pf=x({}).annotate({identifier:`Session.Inbox.CompactionPayload`}),mf=x({location:bo,projectID:Iu,subpath:ao.pipe(B)}).annotate({identifier:`Session.Inbox.MovePayload`}),hf=x({type:_(`user`),payload:uf,delivery:lf}),gf=x({type:_(`synthetic`),payload:ff,delivery:lf}),_f=x({type:_(`compaction`),payload:pf,delivery:lf}),vf=x({type:_(`move`),payload:mf,delivery:lf}),yf=C([hf,gf,_f,vf]).pipe(ye(`type`),D({identifier:`Session.Inbox.Item`})),bf={id:K,sessionID:hu,time:x({created:lo})},xf=x({...bf,...hf.fields}).annotate({identifier:`Session.Inbox.User`}),Sf=x({...xf.fields,payload:df}).annotate({identifier:`Session.Inbox.MediaUser`}),Cf=x({...bf,...gf.fields}).annotate({identifier:`Session.Inbox.Synthetic`}),wf=x({...bf,..._f.fields}).annotate({identifier:`Session.Inbox.Compaction`}),Tf=x({...bf,...vf.fields}).annotate({identifier:`Session.Inbox.Move`}),Ef=C([xf,Cf,wf,Tf]).pipe(ye(`type`),D({identifier:`Session.Inbox.Info`})),Df=C([Sf,Cf,wf,Tf]).pipe(ye(`type`),D({identifier:`Session.Inbox.MediaInfo`})),Of=C([x({type:m(`before`),messageID:K}),x({type:m(`through`),messageID:K})]).annotate({identifier:`Session.ForkBoundary`}),kf=e({AgentSelected:()=>jf,All:()=>fp,Archived:()=>Rf,Compaction:()=>op,Created:()=>Af,Definitions:()=>cp,Deleted:()=>Uf,Durable:()=>dp,DurableDefinitions:()=>lp,EphemeralDefinitions:()=>up,Execution:()=>Xf,Forked:()=>Wf,InboxCancelled:()=>Jf,InboxDelivered:()=>Kf,InboxDeliveryChanged:()=>Yf,InboxEnqueued:()=>qf,InstructionsUpdated:()=>Zf,MessageContentUpdated:()=>Bf,MetadataUpdated:()=>Ff,ModelSelected:()=>Mf,Moved:()=>Nf,Permissions:()=>If,Reasoning:()=>rp,Renamed:()=>Pf,RetryScheduled:()=>ap,RevertEvent:()=>sp,SessionEvent:()=>kf,Shell:()=>ep,Skill:()=>$f,Step:()=>tp,Synthetic:()=>Qf,Text:()=>np,Tool:()=>ip,Unarchived:()=>zf,UsageRecorded:()=>Vf,UsageUpdated:()=>Hf,Viewed:()=>Lf}),q={sessionID:hu},J={durable:{aggregate:`sessionID`,version:1}},Af=H({type:`session.created`,...J,schema:{...q,projectID:Iu,location:bo,subpath:ao.pipe(B),parentID:hu.pipe(B),slug:y,title:y.pipe(B),agent:Au.pipe(B),model:ol.pipe(B),metadata:Xu.pipe(B),permissions:Du.pipe(B),version:y}}),jf=H({type:`session.agent.selected`,...J,schema:{...q,agent:Au,previous:Au.pipe(B)}}),Mf=H({type:`session.model.selected`,...J,schema:{...q,model:ol,previous:ol.pipe(B)}}),Nf=H({type:`session.moved`,...J,schema:{...q,...mf.fields}}),Pf=H({type:`session.renamed`,...J,schema:{...q,title:y}}),Ff=H({type:`session.metadata.updated`,...J,schema:{...q,metadata:Xu}}),If=H({type:`session.permissions`,...J,schema:{...q,permissions:Du}}),Lf=H({type:`session.viewed`,...J,schema:{...q,idle:N}}),Rf=H({type:`session.archived`,...J,schema:q}),zf=H({type:`session.unarchived`,...J,schema:q}),Bf=H({type:`session.message.content.updated`,...J,schema:{...q,messageID:K,content:h(Nd)}}),Vf=H({type:`session.usage.recorded`,...J,schema:{...q,source:v([`title`,`compaction`]),cost:$c,tokens:dd}}),Hf=U({type:`session.usage.updated`,schema:{...q,cost:$c,tokens:dd}}),Uf=H({type:`session.deleted`,durable:{aggregate:`sessionID`,version:2},schema:q}),Wf=H({type:`session.forked`,durable:{aggregate:`sessionID`,version:2},schema:{...q,parentID:hu,boundary:Of,instructions:ef.pipe(B),instructionEntries:of.pipe(B)}}),Gf={...q,inboxID:K},Kf=H({type:`session.inbox.delivered`,...J,schema:Gf}),qf=H({type:`session.inbox.enqueued`,...J,schema:{...Gf,item:yf}}),Jf=H({type:`session.inbox.cancelled`,...J,schema:Gf}),Yf=H({type:`session.inbox.delivery.changed`,...J,schema:{...Gf,delivery:lf}}),Xf;(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:ld}}),e.Interrupted=H({type:`session.execution.interrupted`,...J,schema:{...q,reason:v([`user`,`shutdown`,`superseded`,`inactivity`])}})})(Xf||={});var Zf=H({type:`session.instructions.updated`,durable:{aggregate:`sessionID`,version:2},schema:{...q,delta:nf,text:y.pipe(B)}}),Qf=H({type:`session.synthetic`,...J,schema:{...q,text:y,description:y.pipe(B),metadata:b(y,Ie).pipe(B)}}),$f;(function(e){e.Activated=H({type:`session.skill.activated`,...J,schema:{...q,id:Po,name:Fo,text:y}})})($f||={});var ep;(function(e){e.Started=H({type:`session.shell.started`,...J,schema:{...q,shell:td}}),e.Ended=H({type:`session.shell.ended`,...J,schema:{...q,shell:td,output:cd}})})(ep||={});var tp;(function(e){e.Started=H({type:`session.step.started`,...J,schema:{...q,assistantMessageID:K,agent:Au,model:ol,snapshot:ud.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:Ku,rawFinish:y.pipe(B),native:md.pipe(B),cost:$c,tokens:dd,snapshot:ud.pipe(B),files:h(ao).pipe(B)}}),e.Failed=H({type:`session.step.failed`,...J,schema:{...q,assistantMessageID:K,error:ld,finish:v([`content-filter`]).pipe(B),rawFinish:y.pipe(B),native:md.pipe(B),cost:$c.pipe(B),tokens:dd.pipe(B),snapshot:ud.pipe(B),files:h(ao).pipe(B)}})})(tp||={});var np;(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:y}}),e.Ended=H({type:`session.text.ended`,...J,schema:{...q,assistantMessageID:K,ordinal:z,text:y,native:md.pipe(B)}})})(np||={});var rp;(function(e){e.Started=H({type:`session.reasoning.started`,...J,schema:{...q,assistantMessageID:K,ordinal:z,native:md.pipe(B)}}),e.Delta=U({type:`session.reasoning.delta`,schema:{...q,assistantMessageID:K,ordinal:z,delta:y}}),e.Ended=H({type:`session.reasoning.ended`,...J,schema:{...q,assistantMessageID:K,ordinal:z,text:y,native:md.pipe(B)}})})(rp||={});var ip;(function(e){let t={...q,assistantMessageID:K,id:y};(function(e){e.Started=H({type:`session.tool.input.started`,...J,schema:{...t,name:y}}),e.Delta=U({type:`session.tool.input.delta`,schema:{...t,delta:y}}),e.Ended=H({type:`session.tool.input.ended`,...J,schema:{...t,text:y}})})(e.Input||={}),e.Called=H({type:`session.tool.called`,...J,schema:{...t,input:b(y,Ie),executed:g,native:md.pipe(B)}}),e.Progress=U({type:`session.tool.progress`,schema:{...t,metadata:b(y,Te)}}),e.Success=H({type:`session.tool.success`,durable:{aggregate:`sessionID`,version:2},schema:{...t,content:De(Yu),metadata:b(y,Te).pipe(B),executed:g,native:md.pipe(B)}}),e.Failed=H({type:`session.tool.failed`,durable:{aggregate:`sessionID`,version:2},schema:{...t,error:ld,content:De(Yu).pipe(B),metadata:b(y,Te).pipe(B),executed:g,native:md.pipe(B)}})})(ip||={});var ap=H({type:`session.retry.scheduled`,...J,schema:{...q,assistantMessageID:K,attempt:R,at:z,error:ld}}),op;(function(e){e.Started=H({type:`session.compaction.started`,...J,schema:{...q,reason:v([`auto`,`manual`]),inputID:K.pipe(B)}}),e.Delta=U({type:`session.compaction.delta`,schema:{...q,text:y}}),e.Ended=H({type:`session.compaction.ended`,...J,schema:{...q,reason:e.Started.data.fields.reason,model:zd.fields.model,native:zd.fields.native,text:y,cost:zd.fields.cost,tokens:zd.fields.tokens}}),e.Failed=H({type:`session.compaction.failed`,...J,schema:{...q,reason:e.Started.data.fields.reason,error:ld,inputID:K.pipe(B),cost:Bd.fields.cost,tokens:Bd.fields.tokens}})})(op||={});var sp;(function(e){e.Staged=H({type:`session.revert.staged`,...J,schema:{...q,revert:qd}}),e.Cleared=H({type:`session.revert.cleared`,...J,schema:q}),e.Committed=H({type:`session.revert.committed`,...J,schema:{...q,to:K}})})(sp||={});var cp=W(Af,jf,Mf,Nf,Pf,Ff,If,Lf,Rf,zf,Hf,Uf,Wf,Kf,qf,Jf,Yf,Xf.Started,Xf.Succeeded,Xf.Failed,Xf.Interrupted,Zf,Qf,$f.Activated,ep.Started,ep.Ended,tp.Started,tp.Streamed,tp.Ended,tp.Failed,np.Started,np.Delta,np.Ended,rp.Started,rp.Delta,rp.Ended,ip.Input.Started,ip.Input.Delta,ip.Input.Ended,ip.Called,ip.Progress,ip.Success,ip.Failed,ap,op.Started,op.Delta,op.Ended,op.Failed,sp.Staged,sp.Cleared,sp.Committed),lp=W(...cp.filter(e=>e.durability===`durable`),Vf,Bf),up=W(...cp.filter(e=>e.durability===`ephemeral`)),dp=C(lp,{mode:`oneOf`}).annotate({identifier:`Session.Event.Durable`}).pipe(ye(`type`)),fp=C([dp,...up],{mode:`oneOf`}).pipe(ye(`type`)),pp=e({Event:()=>hp,ForkBoundary:()=>gp,ID:()=>Y,Info:()=>_p,ListAnchor:()=>vp,ListCursor:()=>Tp,ListFilter:()=>bp,Metadata:()=>mp,Revert:()=>qd,Session:()=>pp}),Y=hu,mp=Xu,hp=kf,gp=Of,_p=x({id:Y,parentID:Y.pipe(B),fork:x({sessionID:Y,boundary:gp}).pipe(B),projectID:Iu,agent:Au.pipe(B),model:ol.pipe(B),cost:$c,tokens:dd,outcome:v([`succeeded`,`failed`,`interrupted`]).pipe(B),time:x({created:lo,updated:lo,idle:lo.pipe(B),viewed:lo.pipe(B),archived:lo.pipe(B)}),title:y.pipe(B),location:bo,subpath:ao.pipe(B),metadata:mp.pipe(B),permissions:Du.pipe(B),revert:qd.pipe(B)}).annotate({identifier:`Session.Info`}),vp=x({id:Y,time:N,direction:v([`previous`,`next`])}).annotate({identifier:`Session.ListAnchor`}),yp={order:v([`asc`,`desc`]).pipe(w).annotate({description:`Session order for the first page. Use desc for newest first or asc for oldest first.`}),search:y.pipe(w),parentID:C([Y,te.pipe(Ze(m(`null`),{decode:_t(()=>null),encode:_t(()=>`null`)}))]).annotate({description:`Filter by parent session. Use null to return only root sessions.`}).pipe(w),archived:v([`true`,`false`]).pipe(wt(g,{decode:_t(e=>e===`true`),encode:_t(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(w)},bp=x({...yp,directory:oo.pipe(w),project:Iu.pipe(w),subpath:ao.pipe(w)}).annotate({identifier:`Session.ListFilter`}),xp=C([x({...yp,directory:oo,anchor:vp}),x({...yp,project:Iu,subpath:ao.pipe(w),anchor:vp}),x({...yp,anchor:vp})]),Sp=Dt(xp),Cp=et(Sp),wp=We(Sp),Tp=y.pipe(A(`SessionsCursor`),D({identifier:`SessionsCursor`,description:`Opaque pagination cursor returned as cursor.previous or cursor.next in the previous response.`}),co(e=>{let t=Oe(e);return{make:e=>t(ke(Cp(e))),parse:e=>$e(()=>{let t=Ae(e);return Nt(t)?nt(`Invalid cursor`):wp(t.success).pipe(M(()=>`Invalid cursor`))})}})),Ep=x({...su.fields,sessionID:Y,foregroundProcess:ce(y),size:x({cols:R,rows:R}),output:x({head:z,tail:z})}).annotate({identifier:`PersistentPty.Info`}),Dp=x({directory:y,instanceID:y,ticket:y,expiresAt:gt}).annotate({identifier:`PersistentPty.Handoff`}),Op=x({command:B(y),args:h(y),cwd:B(y),title:y,env:b(y,y),size:B(x({cols:R,rows:R}))}).annotate({identifier:`PersistentPty.CreateInput`}),kp=x({attachmentID:B(y),size:x({cols:R,rows:R})}).annotate({identifier:`PersistentPty.UpdateInput`}),Ap=x({info:Ep,text:y,checkpoint:dt,cursor:x({x:z,y:z})}).annotate({identifier:`PersistentPty.Snapshot`}),jp=R.check(c(65535)).annotate({identifier:`PersistentPty.ReadLines`}),Mp=x({ptyID:ou,title:y,cwd:y,foregroundProcess:ce(y),screen:x({text:y,cols:R,rows:R,cursor:Ap.fields.cursor})}).annotate({identifier:`PersistentPty.ReadResult`}),Np=U({type:`persistent-pty.added`,schema:{sessionID:Y,terminal:Ep}}),Pp=U({type:`persistent-pty.removed`,schema:{sessionID:Y,ptyID:ou}}),Fp={Added:Np,Removed:Pp,Definitions:W(Np,Pp)},Ip=x({ticket:y,expires_in:R}).annotate({identifier:`PtyTicket.ConnectToken`}),X=x({location:w(x({directory:w(y)}))}).annotate({identifier:`LocationQuery`}),Z=O({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}}),Lp=e=>j(`server.location`).add(k(`location.get`,`/api/location`,{query:X,success:Co}).middleware(e).annotateMerge(Z).annotateMerge(O({identifier:`location.get`,summary:`Get location`,description:`Resolve the requested location or the server default location.`}))).add(T(`location.reload`,`/api/location/reload`,{success:S,error:Xo}).annotateMerge(O({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(O({title:`location`})),Rp=`ticket`,zp=`x-opencode-ticket`,Bp=`/api/pty/:ptyID/connect`,Vp=e=>j(`server.pty`).add(k(`pty.list`,`/api/pty`,{query:X,success:V(h(su))}).annotateMerge(Z).annotateMerge(O({identifier:`pty.list`,summary:`List PTY sessions`,description:`List PTY sessions for a location, including exited sessions retained until removal.`}))).add(T(`pty.create`,`/api/pty`,{query:X,payload:pu,success:V(su)}).annotateMerge(Z).annotateMerge(O({identifier:`pty.create`,summary:`Create PTY session`,description:`Create a pseudo-terminal session for a location.`}))).add(k(`pty.get`,`/api/pty/:ptyID`,{params:{ptyID:ou},query:X,success:V(su),error:vs}).annotateMerge(Z).annotateMerge(O({identifier:`pty.get`,summary:`Get PTY session`,description:`Get one PTY session, including its exit code once exited.`}))).add(Ct(`pty.update`,`/api/pty/:ptyID`,{params:{ptyID:ou},query:X,payload:mu,success:V(su),error:vs}).annotateMerge(Z).annotateMerge(O({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:ou},query:X,success:S,error:vs}).annotateMerge(Z).annotateMerge(O({identifier:`pty.remove`,summary:`Remove PTY session`,description:`Terminate and remove one PTY session.`}))).add(T(`pty.connectToken`,`/api/pty/:ptyID/connect-token`,{params:{ptyID:ou},query:X,headers:x({[zp]:w(y)}),success:V(Ip),error:[_s,vs]}).annotateMerge(Z).annotateMerge(O({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(k(`pty.connect`,Bp,{params:{ptyID:ou},success:g,error:[_s,vs,Uo]}).annotateMerge(O({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`,Rp].map(e=>({in:`query`,name:e,schema:{type:`string`}}))]})}))).annotateMerge(O({title:`pty`,description:`Experimental location-scoped PTY routes.`})),Hp=`/api/experimental/persistent-pty/:ptyID/connect`,Up=[Wo,Xo],Wp=[vs,Xo],Gp=j(`server.experimental`).add(k(`persistentPty.read`,`/api/experimental/session/:sessionID/terminal/read`,{params:{sessionID:Y},query:{lines:oe.pipe(wt(jp),w)},success:x({data:ce(Mp)}),error:[Xo]}).annotateMerge(O({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(k(`persistentPty.list`,`/api/experimental/session/:sessionID/terminal`,{params:{sessionID:Y},success:x({data:h(Ep)}),error:Up})).add(T(`persistentPty.create`,`/api/experimental/session/:sessionID/terminal`,{params:{sessionID:Y},payload:Op,success:x({data:Ep}),error:Up})).add(T(`persistentPty.shutdown`,`/api/experimental/persistent-pty/shutdown`,{success:S,error:[Xo]})).add(T(`persistentPty.handoff`,`/api/experimental/persistent-pty/handoff`,{success:x({handoff:ce(Dp)}),error:[Xo]})).add(k(`persistentPty.get`,`/api/experimental/persistent-pty/:ptyID`,{params:{ptyID:ou},success:x({data:Ep}),error:Wp})).add(Ct(`persistentPty.update`,`/api/experimental/persistent-pty/:ptyID`,{params:{ptyID:ou},payload:kp,success:x({data:Ep}),error:Wp})).add(k(`persistentPty.snapshot`,`/api/experimental/persistent-pty/:ptyID/snapshot`,{params:{ptyID:ou},success:x({data:Ap}),error:Wp})).add(ft(`persistentPty.remove`,`/api/experimental/persistent-pty/:ptyID`,{params:{ptyID:ou},success:S,error:Wp})).add(T(`persistentPty.connectToken`,`/api/experimental/persistent-pty/:ptyID/connect-token`,{params:{ptyID:ou},headers:x({[zp]:w(y)}),success:x({data:Ip}),error:[_s,vs,Xo]})).add(k(`persistentPty.connect`,Hp,{params:{ptyID:ou},success:g,error:[_s,vs,Xo]}).annotateMerge(O({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`,Rp].map(e=>({in:`query`,name:e,schema:{type:`string`}}))]})}))).annotateMerge(O({title:`persistentPty`,description:`Prototype persistent PTY routes.`})).add(iu),Kp=v([`webrtc`,`websocket`]).annotate({identifier:`VoiceTransportType`}),qp=x({model:y,provider:y,transports:h(Kp),available:g}).annotate({identifier:`VoiceModel`}),Jp=x({type:m(`webrtc`),sdp:y,dcid:w(gt)}).annotate({identifier:`VoiceWebRTCTransportInput`}),Yp=x({type:m(`websocket`)}).annotate({identifier:`VoiceWebSocketTransportInput`}),Xp=C([Jp,Yp]).annotate({identifier:`VoiceTransportInput`}),Zp=x({type:m(`webrtc`),sdp:y}).annotate({identifier:`VoiceWebRTCTransport`}),Qp=x({type:m(`websocket`),url:y,token:y,expiresAt:gt}).annotate({identifier:`VoiceWebSocketTransport`}),$p=C([Zp,Qp]).annotate({identifier:`VoiceTransport`}),em=j(`server.voice`).add(k(`voice.models`,`/api/experimental/voice/models`,{success:x({data:x({models:h(qp),default:w(y)})}).annotate({identifier:`VoiceModelsResponse`}),error:[Xo,Uo]}).annotateMerge(O({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(T(`voice.session`,`/api/experimental/voice/session`,{payload:x({model:y,session:w(b(y,Ie)),transport:Xp}),success:x({data:x({transport:$p})}).annotate({identifier:`VoiceSessionResponse`}),error:[Wo,Xo,Uo]}).annotateMerge(O({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(O({title:`voice`,description:`Experimental server-brokered voice session routes.`})),tm=x({limit:w(oe.check(xe(),Mt(1),c(200))).annotate({description:`Maximum number of messages to return. When omitted, the endpoint returns its default page size.`}),order:w(C([m(`asc`),m(`desc`)])).annotate({description:`Message order for the first page. Use desc for newest first or asc for oldest first.`}),cursor:w(y.annotate({description:`Opaque pagination cursor returned as cursor.previous or cursor.next in the previous response. Do not combine with order.`})),type:w(v(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`}),nm=x({...re(_d.fields,[`location`,`previous`]),location:xo,previous:x({location:xo,projectID:_d.fields.projectID,subpath:_d.fields.subpath}).pipe(w)}).annotate({identifier:`Session.Message.LocationSwitched`}),rm=C([hd,gd,nm,vd,bd,xd,Sd,Cd,Fd,Vd,Hd]).annotate({identifier:`Session.Message.Info`}),im=C([hd,gd,nm,yd,bd,xd,Sd,Cd,Fd,Vd,Hd]).annotate({identifier:`Session.Message.MediaInfo`}),am=x({previous:y.pipe(w),next:y.pipe(w)});x({data:h(im),cursor:am}),x({data:im});var om=j(`server.message`).add(k(`session.messages`,`/api/session/:sessionID/message`,{params:{sessionID:Y},query:tm,success:x({data:h(rm),cursor:am}).annotate({identifier:`SessionMessagesResponse`}),error:[ds,G,Zo]}).annotateMerge(O({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(O({title:`session`,description:`Experimental message routes.`})),sm=x({...X.fields,types:w(de(cl)).annotate({description:`Only list models of these types. Defaults to chat, the only type offered for sessions.`})}),cm=j(`server.model`).add(k(`model.list`,`/api/model`,{query:sm,success:V(h(ml)),error:Xo}).annotateMerge(Z).annotateMerge(O({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(k(`model.default`,`/api/model/default`,{query:X,success:V(yt(ml)),error:Xo}).annotateMerge(Z).annotateMerge(O({identifier:`model.default`,summary:`Get default model`,description:`Retrieve the model used when a session has no explicit model selection.`}))).annotateMerge(O({title:`model`,description:`Experimental model routes.`})),lm=j(`server.provider`).add(k(`provider.list`,`/api/provider`,{query:X,success:V(h(Qc)),error:Xo}).annotateMerge(Z).annotateMerge(O({identifier:`provider.list`,summary:`List providers`,description:`Retrieve active AI providers so clients can show provider availability and configuration.`}))).add(k(`provider.get`,`/api/provider/:providerID`,{params:{providerID:Rc},query:X,success:V(Qc),error:[Qo,Xo]}).annotateMerge(Z).annotateMerge(O({identifier:`provider.get`,summary:`Get provider`,description:`Retrieve a single AI provider so clients can inspect its availability and endpoint settings.`}))).annotateMerge(O({title:`provider`,description:`Experimental provider routes.`})),um=e({FileAttachment:()=>dm,Prompt:()=>pm,PromptInput:()=>um,SkillAttachment:()=>fm}),dm=x({uri:y,name:y.pipe(B),description:y.pipe(B),mention:hl.pipe(B)}).annotate({identifier:`PromptInput.FileAttachment`}),fm=x({id:Po,mention:hl.pipe(B)}).annotate({identifier:`PromptInput.SkillAttachment`}),pm=x({text:y,files:h(dm).pipe(B),agents:h(wl).pipe(B),skills:h(fm).pipe(B)}).annotate({identifier:`PromptInput`}),mm=x({date:y,steps:z}).annotate({identifier:`SessionStats.Activity`}),hm=x({model:ol,steps:z,tokens:dd,cost:$c}).annotate({identifier:`SessionStats.ModelUsage`}),gm=x({name:y,calls:z,succeeded:z,failed:z,unfinished:z,durationP50:N.pipe(B)}).annotate({identifier:`SessionStats.ToolUsage`}),_m=v([`none`,`summary`,`detail`]),vm=x({calls:z,succeeded:z,failed:z,unfinished:z}).annotate({identifier:`SessionStats.ToolTotals`}),ym=C([x({mode:m(`none`)}),x({mode:m(`summary`),totals:vm}),x({mode:m(`detail`),totals:vm,usage:h(gm)})]).annotate({identifier:`SessionStats.Tools`}),bm=x({range:x({from:lo,to:lo}),sessions:z,subagents:z,prompts:z,steps:z,tokens:dd,cost:$c,tools:ym,activeDays:z,streak:z,activity:h(mm),models:h(hm)}).annotate({identifier:`SessionStats.Info`});function xm(e,t){return e===`assistant`?Cm(Am(t,`providerState`,`native`)):e===`compaction`?Em(Tm(Am(t,`providerState`,`native`))):t}function Sm(e){return e.map(e=>jm(e)?xm(e.type,e):e)}function Cm(e){return Array.isArray(e.content)?{...e,content:e.content.map(wm)}:e}function wm(e){return jm(e)?e.type===`text`||e.type===`reasoning`?Am(e,`state`,`native`):e.type===`tool`?km(Am(e,`providerState`,`native`)):e:e}function Tm(e){let t=e.recent,n=Om(e,`recent`);if(typeof t!=`string`||!t)return n;let r=jm(n.metadata)?n.metadata:{};return{...n,metadata:{recent:t,...r}}}function Em(e){let t=e.providerContext,n=Om(e,`providerContext`);return jm(t)?{...n,native:{messages:Array.isArray(t.messages)?t.messages.map(Dm):t.messages}}:n}function Dm(e){return!jm(e)||!Array.isArray(e.content)?e:{...e,content:e.content.map(e=>{if(!jm(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 Om(e,t){if(!(t in e))return e;let{[t]:n,...r}=e;return r}function km(e){if(!(`providerResultState`in e))return e;let{providerResultState:t,...n}=e;return jm(t)?{...n,native:{...jm(n.native)?n.native:{},...t}}:n}function Am(e,t,n){if(!(t in e))return e;let{[t]:r,...i}=e;return n in i?i:{...i,[n]:r}}function jm(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}var Mm=e({EventLog:()=>Mm,Synced:()=>Nm}),Nm=x({type:m(`log.synced`),aggregateID:y,seq:B(Eo)}).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.`}),Pm=x({type:m(`running`)}).annotate({identifier:`SessionActive`}),Fm=x({...re(_p.fields,[`location`]),location:xo}).annotate({identifier:`Session.Info`}),Im=x({info:Fm,messages:h(rm)}).annotate({identifier:`SessionTransfer.Data`}),Lm=x({...re(mf.fields,[`location`]),location:xo}).annotate({identifier:`Session.Inbox.MovePayload`}),Rm=x({...re(Tf.fields,[`payload`]),payload:Lm}).annotate({identifier:`Session.Inbox.Move`}),zm=C([xf,Cf,wf,Rm]).annotate({identifier:`Session.Inbox.Info`});x({data:h(C([Sf,Cf,wf,Rm]).annotate({identifier:`Session.Inbox.MediaInfo`}))});var Bm=h(Te).pipe(wt(h(Ie),{decode:_t(Sm),encode:le({strict:!1})}),wt(h(rm),{decode:le({strict:!1}),encode:le({strict:!1})})),Vm=x({id:Hs.pipe(w),title:nc.fields.title,metadata:nc.fields.metadata,fields:nc.fields.fields}).annotate({identifier:`Form.CreatePayload`}),Hm=v([`true`,`false`]).pipe(wt(g,{decode:_t(e=>e===`true`),encode:_t(e=>e?`true`:`false`)})),Um=x({limit:oe.pipe(wt(R),w).annotate({description:`Maximum number of sessions to return. Defaults to the newest 50 sessions.`}),...bp.fields,cursor:Tp.pipe(w)}).annotate({identifier:`SessionsQuery`}),Wm=(e,t)=>j(`server.session`).add(k(`session.list`,`/api/session`,{query:Um,success:x({data:h(Fm),cursor:x({previous:Tp.pipe(w),next:Tp.pipe(w)})}).annotate({identifier:`SessionsResponse`}),error:[ds,Wo]}).annotateMerge(O({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(k(`session.stats`,`/api/experimental/session/stats`,{query:x({from:oe.pipe(w),to:oe.pipe(w),project:Iu.pipe(w),timezone:y.pipe(w),tools:_m.pipe(w)}),success:x({data:bm}),error:Wo}).annotateMerge(O({identifier:`experimental.session.stats`,summary:`Get session statistics`,description:`Aggregate local session activity, usage, and tool reliability for a time range.`}))).add(T(`session.create`,`/api/session`,{payload:x({id:Y.pipe(w),parentID:Y.pipe(w),title:y.pipe(w),agent:Au.pipe(w),model:ol.pipe(w),location:xo.pipe(w),metadata:mp.pipe(w),permissions:Du.pipe(w)}),success:x({data:Fm}),error:G}).annotateMerge(O({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(T(`session.import`,`/api/experimental/session/import`,{payload:x({info:Im.fields.info,messages:Bm,location:xo.pipe(w)}),success:x({data:Fm}),error:[Jo,G]}).annotateMerge(O({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(k(`session.export`,`/api/experimental/session/:sessionID/export`,{params:{sessionID:Y},query:x({sanitize:Hm.pipe(w)}),success:x({data:Im}),error:[G,Zo]}).annotateMerge(O({identifier:`experimental.session.export`,summary:`Export session`,description:`Export a complete projected session transcript.`}))).add(k(`session.active`,`/api/session/active`,{success:x({data:b(Y,Pm)})}).annotateMerge(O({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(k(`session.get`,`/api/session/:sessionID`,{params:{sessionID:Y},success:x({data:Fm}),error:G}).annotateMerge(O({identifier:`session.get`,summary:`Get session`,description:`Retrieve a session by ID.`}))).add(ft(`session.remove`,`/api/session/:sessionID`,{params:{sessionID:Y},success:S,error:G}).annotateMerge(O({identifier:`session.remove`,summary:`Delete session`,description:`Delete a session and its child sessions.`}))).add(T(`session.fork`,`/api/session/:sessionID/fork`,{params:{sessionID:Y},payload:x({before:K.pipe(w)}),success:x({data:Fm}),error:[G,os,Wo]}).annotateMerge(O({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(T(`session.switchAgent`,`/api/session/:sessionID/agent`,{params:{sessionID:Y},payload:x({agent:Au}),success:S,error:G}).annotateMerge(O({identifier:`session.switchAgent`,summary:`Switch session agent`,description:`Switch the agent used by subsequent provider turns.`}))).add(T(`session.switchModel`,`/api/session/:sessionID/model`,{params:{sessionID:Y},payload:x({model:ol}),success:S,error:G}).annotateMerge(O({identifier:`session.switchModel`,summary:`Switch session model`,description:`Switch the model used by subsequent provider turns.`}))).add(Be(`session.update`,`/api/session/:sessionID`,{params:{sessionID:Y},payload:x({title:y.pipe(w),metadata:mp.pipe(w),permissions:Du.pipe(w),archived:g.pipe(w).annotate({description:`Archive the session with true or restore it with false. Repeating the current state is a no-op.`})}),success:S,error:[G,Uo]}).annotateMerge(O({identifier:`session.update`,summary:`Update session`,description:`Update mutable session properties.`}))).add(T(`session.move`,`/api/session/:sessionID/move`,{params:{sessionID:Y},payload:x({...xo.fields,delivery:lf.pipe(w)}),success:S,error:[G,Wo]}).annotateMerge(O({identifier:`session.move`,summary:`Move session`,description:`Move a session to another project directory at the requested delivery boundary.`}))).add(T(`session.prompt`,`/api/session/:sessionID/prompt`,{params:{sessionID:Y},payload:x({id:K.pipe(w),...pm.fields,metadata:uf.fields.metadata,delivery:lf.pipe(w),resume:g.pipe(w)}),success:x({data:xf}),error:[Jo,Wo,G]}).middleware(e).annotateMerge(O({identifier:`session.prompt`,summary:`Send message`,description:`Durably admit one session input and schedule agent-loop execution unless resume is false.`}))).add(T(`session.command`,`/api/session/:sessionID/command`,{params:{sessionID:Y},payload:x({name:y,...pm.fields,delivery:lf.pipe(w)}),success:S,error:[G,ls,us]}).middleware(e).annotateMerge(O({identifier:`session.command`,summary:`Run command`,description:`Execute a slash command callback immediately.`}))).add(T(`session.skill`,`/api/experimental/session/:sessionID/skill`,{params:{sessionID:Y},payload:x({id:Po,resume:g.pipe(w)}),success:S,error:[G,ss]}).middleware(e).annotateMerge(O({identifier:`experimental.session.skill`,summary:`Activate skill`,description:`Activate a skill for a session by appending a skill message and resuming execution.`}))).add(T(`session.synthetic`,`/api/session/:sessionID/synthetic`,{params:{sessionID:Y},payload:x({id:K.pipe(w),text:y,description:y.pipe(w),metadata:bd.fields.metadata,delivery:lf.pipe(w),resume:g.pipe(w)}),success:x({data:Cf}),error:[Jo,G]}).middleware(e).annotateMerge(O({identifier:`session.synthetic`,summary:`Add synthetic message`,description:`Durably admit synthetic session input and schedule execution unless resume is false.`}))).add(T(`session.shell`,`/api/session/:sessionID/shell`,{params:{sessionID:Y},payload:x({id:K.pipe(w),command:y}),success:S,error:G}).middleware(e).annotateMerge(O({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(T(`session.compact`,`/api/session/:sessionID/compact`,{params:{sessionID:Y},payload:x({id:K.pipe(w),delivery:lf.pipe(w)}),success:x({data:wf}),error:[Jo,G]}).middleware(e).annotateMerge(O({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(T(`session.wait`,`/api/experimental/session/:sessionID/wait`,{params:{sessionID:Y},success:S,error:[G,Xo]}).annotateMerge(O({identifier:`experimental.session.wait`,summary:`Wait for session`,description:`Wait for a session agent loop to become idle.`}))).add(T(`session.revert.stage`,`/api/session/:sessionID/revert/stage`,{params:{sessionID:Y},payload:x({messageID:K,files:g.pipe(w)}),success:x({data:qd}),error:[os,G,Yo,Zo]}).middleware(e).annotateMerge(O({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:S,error:[G,Yo,Zo]}).middleware(e).annotateMerge(O({identifier:`session.revert.clear`,summary:`Clear staged revert`}))).add(T(`session.revert.commit`,`/api/session/:sessionID/revert/commit`,{params:{sessionID:Y},success:S,error:[G,Yo]}).annotateMerge(O({identifier:`session.revert.commit`,summary:`Commit staged revert`}))).add(k(`session.context`,`/api/session/:sessionID/context`,{params:{sessionID:Y},success:x({data:h(rm)}),error:[G,Zo]}).annotateMerge(O({identifier:`session.context`,summary:`Get session context`,description:`Retrieve the active context messages for a session (all messages after the last compaction).`}))).add(k(`session.diff`,`/api/session/:sessionID/diff`,{params:{sessionID:Y},query:x({from:w(K).annotate({description:`User message whose turn to diff. Defaults to the turn of the newest user message.`}),to:w(K).annotate({description:"Later user message whose turn ends the range. Defaults to the turn of `from` alone."}),context:oe.pipe(wt(z),w).annotate({description:`Unchanged lines around each hunk. Omit for full-file patches.`})}),success:x({data:h(Gd)}),error:[Wo,os,G,Zo,Uo]}).annotateMerge(O({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(k(`session.inbox.list`,`/api/session/:sessionID/inbox`,{params:{sessionID:Y},success:x({data:h(zm)}),error:G}).annotateMerge(O({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:S,error:G}).annotateMerge(O({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(Be(`session.inbox.update`,`/api/session/:sessionID/inbox/:inboxID`,{params:{sessionID:Y,inboxID:K},payload:x({delivery:lf}),success:S,error:[Jo,G]}).annotateMerge(O({identifier:`session.inbox.update`,summary:`Update inbox item`,description:`Change a pending inbox item's delivery mode. Steering wakes session execution.`}))).add(k(`session.instructions.entry.list`,`/api/experimental/session/:sessionID/instructions/entries`,{params:{sessionID:Y},success:x({data:h(af)}),error:G}).annotateMerge(O({identifier:`experimental.session.instructions.entry.list`,summary:`List instruction entries`,description:`List API-managed instruction entries attached to the session.`}))).add(Ct(`session.instructions.entry.put`,`/api/experimental/session/:sessionID/instructions/entries/:key`,{params:{sessionID:Y,key:rf},payload:x({value:Te}),success:S,error:[G,sf]}).annotateMerge(O({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:rf},success:S,error:G}).annotateMerge(O({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(T(`session.generate`,`/api/session/:sessionID/generate`,{params:{sessionID:Y},payload:x({prompt:y}),success:x({data:x({text:y})}).annotate({identifier:`SessionGenerateResponse`}),error:[G,Xo]}).middleware(e).annotateMerge(O({identifier:`session.generate`,summary:`Generate text from session context`,description:`Generate transient text from the current session context without mutating session history.`}))).add(k(`session.log`,`/api/experimental/session/:sessionID/log`,{params:{sessionID:Y},query:{after:oe.pipe(wt(Eo),w),follow:Hm.pipe(w)},success:qe({data:C([dp,Nm]).annotate({identifier:`SessionLogItem`})}),error:G}).annotateMerge(O({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(T(`session.interrupt`,`/api/session/:sessionID/interrupt`,{params:{sessionID:Y},query:{resume:Hm.pipe(w)},success:x({interrupted:g.annotate({description:`Whether an active execution owned by this OpenCode process was interrupted.`})}).annotate({identifier:`SessionInterruptResponse`}),error:G}).annotateMerge(O({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(T(`session.background`,`/api/session/:sessionID/background`,{params:{sessionID:Y},success:S,error:G}).annotateMerge(O({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(k(`session.message`,`/api/session/:sessionID/message/:messageID`,{params:{sessionID:Y,messageID:K},success:x({data:rm}),error:[G,os]}).annotateMerge(O({identifier:`session.message.get`,summary:`Get session message`,description:`Retrieve one projected message owned by the Session.`}))).add(k(`session.form.list`,`/api/session/:sessionID/form`,{params:{sessionID:y},success:x({data:h(nc)}),error:G}).middleware(t).annotateMerge(O({identifier:`session.form.list`,summary:`List session forms`,description:`Retrieve pending forms for a session.`}))).add(T(`session.form.create`,`/api/session/:sessionID/form`,{params:{sessionID:y},payload:Vm,success:x({data:nc}),error:[G,Jo,Wo]}).middleware(t).annotateMerge(O({identifier:`session.form.create`,summary:`Create session form`,description:`Create a form for a session.`}))).add(k(`session.form.get`,`/api/session/:sessionID/form/:formID`,{params:{sessionID:y,formID:Hs},success:x({data:oc}),error:[G,ms]}).middleware(t).annotateMerge(O({identifier:`session.form.get`,summary:`Get session form`,description:`Retrieve a form and its current state for a session.`}))).add(T(`session.form.reply`,`/api/session/:sessionID/form/:formID/reply`,{params:{sessionID:y,formID:Hs},payload:sc,success:S,error:[G,hs,gs,ms]}).middleware(t).annotateMerge(O({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:y,formID:Hs},query:x({message:w(y)}),success:S,error:[G,hs,ms]}).middleware(t).annotateMerge(O({identifier:`session.form.cancel`,summary:`Cancel form`,description:`Cancel a pending form, optionally telling the asker why it was not answered.`}))).add(Ct(`session.environment`,`/api/session/:sessionID/environment`,{params:{sessionID:Y},payload:x({variables:b(y,y)}),success:S,error:G}).annotateMerge(O({identifier:`session.environment`,summary:`Set session environment`,description:`Replace the process environment used by local shell commands for this session.`}))).add(T(`session.view`,`/api/session/:sessionID/view`,{params:{sessionID:Y},payload:x({idle:lo}),success:S,error:G}).annotateMerge(O({identifier:`session.view`,summary:`View session`,description:`Mark the idle transition observed by the viewer as viewed.`}))).annotateMerge(O({title:`session`,description:`Experimental session routes.`})),Gm=e({ID:()=>Km,Info:()=>qm,PermissionSaved:()=>Gm}),Km=y.pipe(A(`PermissionSaved.ID`),D({identifier:`PermissionSaved.ID`}),co(e=>({create:()=>e.make(`psv_`+mo())}))),qm=x({id:Km,projectID:_o,action:y,resource:y,time:x({created:lo,updated:lo})}).annotate({identifier:`PermissionSaved.Info`}),Jm=(e,t)=>j(`server.permission`).add(k(`permission.request.list`,`/api/permission/request`,{query:X,success:V(h(bu))}).middleware(e).annotateMerge(Z).annotateMerge(O({identifier:`permission.request.list`,summary:`List pending permission requests`,description:`Retrieve pending permission requests for a location.`}))).add(k(`permission.saved.list`,`/api/permission/saved`,{query:x({projectID:Iu.pipe(w)}),success:x({data:h(qm)})}).middleware(e).annotateMerge(O({identifier:`permission.saved.list`,summary:`List saved permissions`,description:`Retrieve saved permissions, optionally filtered by project.`}))).add(Be(`permission.saved.update`,`/api/permission/saved/:id`,{params:{id:Km},payload:x({action:y.pipe(w),resource:y.pipe(w)}),success:x({data:qm}),error:[ps,Jo]}).annotateMerge(O({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:Km},success:S}).annotateMerge(O({identifier:`permission.saved.remove`,summary:`Remove saved permission`,description:`Remove a saved permission by ID.`}))).add(T(`session.permission.create`,`/api/session/:sessionID/permission`,{params:{sessionID:Y},payload:x({id:_u.pipe(w),action:bu.fields.action,resources:bu.fields.resources,save:bu.fields.save,metadata:bu.fields.metadata,source:bu.fields.source,agent:Au.pipe(w)}),success:x({data:x({id:_u,effect:Tu})}),error:G}).middleware(t).annotateMerge(O({identifier:`session.permission.create`,summary:`Create permission request`,description:`Evaluate and, when approval is required, create a permission request for a session.`}))).add(k(`session.permission.list`,`/api/session/:sessionID/permission`,{params:{sessionID:Y},success:x({data:h(bu)}),error:[G,Uo]}).annotateMerge(O({identifier:`session.permission.list`,summary:`List session permission requests`,description:`Retrieve pending permission requests owned by a session.`}))).add(k(`session.permission.get`,`/api/session/:sessionID/permission/:requestID`,{params:{sessionID:Y,requestID:_u},success:x({data:bu}),error:[G,fs]}).middleware(t).annotateMerge(O({identifier:`session.permission.get`,summary:`Get permission request`,description:`Retrieve a pending permission request owned by a session.`}))).add(T(`session.permission.reply`,`/api/session/:sessionID/permission/:requestID/reply`,{params:{sessionID:Y,requestID:_u},payload:x({decision:xu,message:y.pipe(w)}),success:S,error:[G,fs]}).middleware(t).annotateMerge(O({identifier:`session.permission.reply`,summary:`Reply to pending permission request`,description:`Respond to a pending permission request owned by a session.`}))).annotateMerge(O({title:`permission`,description:`Experimental permission routes.`})),Ym=e({Entry:()=>Qm,Event:()=>Zm,FileSystem:()=>Ym,FindInput:()=>th,Match:()=>eh,Submatch:()=>$m,Write:()=>nh}),Xm=U({type:`filesystem.changed`,schema:{file:y,event:v([`add`,`change`,`unlink`])}}),Zm={Changed:Xm,Definitions:W(Xm)},Qm=x({path:ao,type:v([`file`,`directory`])}).annotate({identifier:`FileSystem.Entry`}),$m=x({text:y,start:z,end:z}).annotate({identifier:`FileSystem.Submatch`}),eh=x({entry:Qm,line:R,offset:z,text:y,submatches:h($m)}).annotate({identifier:`FileSystem.Match`}),th=class extends p(`FileSystem.FindInput`)({query:y,type:v([`file`,`directory`]).pipe(B),limit:R.pipe(B)}){},nh=x({path:oo}).annotate({identifier:`FileSystem.Write`}),rh=x({...X.fields,path:y.pipe(w).annotate({description:`An absolute path or a path relative to the requested location. Defaults to the location directory.`})}),ih=x({...X.fields,path:y.annotate({description:`An absolute path or a path relative to the requested location. Missing parent directories are created.`})}),ah=x({path:y.annotate({description:`A file path relative to the requested location.`})}),oh=x({...X.fields,query:th.fields.query,type:th.fields.type,limit:oe.pipe(wt(R),w)}),sh=j(`server.fs`).add(k(`fs.read`,`/api/fs/read/*`,{query:X,success:dt.pipe(mt()),error:rs}).annotateMerge(Z).annotateMerge(O({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(k(`fs.list`,`/api/fs/list`,{query:rh,success:V(h(Qm)),error:rs}).annotateMerge(Z).annotateMerge(O({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(k(`fs.find`,`/api/fs/find`,{query:oh,success:V(h(Qm))}).annotateMerge(Z).annotateMerge(O({identifier:`fs.find`,summary:`Find files`,description:`Find recursively ranked filesystem entries relative to the requested location.`}))).add(T(`fs.write`,`/api/experimental/fs/write`,{query:ih,payload:dt.pipe(mt()),success:V(nh)}).annotateMerge(Z).annotateMerge(O({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(T(`fs.watch`,`/api/experimental/fs/watch`,{query:X,payload:ah,success:S,error:[rs,Xo]}).annotateMerge(Z).annotateMerge(O({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:ah,success:S}).annotateMerge(Z).annotateMerge(O({identifier:`experimental.fs.unwatch`,summary:`Unwatch file`,description:`Stop watching one file relative to the requested location. Experimental: may change without compatibility guarantees.`}))).annotateMerge(O({title:`filesystem`,description:`Experimental location-scoped filesystem routes.`})),ch=e=>j(`server.form`).add(k(`form.list`,`/api/form`,{query:X,success:V(h(nc))}).annotateMerge(Z).annotateMerge(O({identifier:`form.list`,summary:`List pending forms`,description:`Retrieve pending forms for a location.`}))).middleware(e).annotateMerge(O({title:`form`,description:`Location form routes.`})),lh=e({Command:()=>lh,Event:()=>fh,Info:()=>dh}),uh=U({type:`command.updated`,schema:{}}),dh=x({name:y,description:y.pipe(B)}).annotate({identifier:`Command.Info`}),fh={Updated:uh,Definitions:W(uh)},ph=j(`server.command`).add(k(`command.list`,`/api/command`,{query:X,success:V(h(dh))}).annotateMerge(Z).annotateMerge(O({identifier:`command.list`,summary:`List commands`,description:`Retrieve currently registered commands.`}))).annotateMerge(O({title:`command`,description:`Experimental command routes.`})),mh=j(`server.skill`).add(k(`skill.list`,`/api/skill`,{query:X,success:V(h(Ro))}).annotateMerge(Z).annotateMerge(O({identifier:`skill.list`,summary:`List skills`,description:`Retrieve currently registered skills.`}))).annotateMerge(O({title:`skill`,description:`Experimental skill routes.`})),hh=x({input:B(Ie)}).annotate({identifier:`Rpc.Input`}),gh=x({output:fe(Ie)}).annotate({identifier:`Rpc.Output`}),_h=j(`server.rpc`).add(T(`rpc.call`,`/api/rpc/:rpcID/:method`,{params:{rpcID:y,method:y},query:X,payload:hh,success:gh,error:[Go,Ko]}).annotateMerge(Z).annotateMerge(O({identifier:`rpc.call`,summary:`Call a plugin RPC`,description:`Dispatch a method to the currently registered RPC at the requested location.`}))).annotateMerge(O({title:`rpc`,description:`Plugin RPC routes.`})),vh=Rc.check(f(/^[^/#]+$/u)),yh=nl.check(f(/^[^#]+$/u)),bh=al.check(f(/^[^#]+$/u)),xh=x({providerID:vh,model:yh,variant:bh.pipe(B)}),Sh=y.check(f(/^[^/#]+\/[^#]+(?:#[^#]+)?$/u)),Ch=C([Sh,xh]).pipe(wt(xh,{decode:_t(e=>typeof e==`string`?wh(e):e),encode:le({strict:!1})})).annotate({identifier:`Config.ModelSelection`});function wh(e){let t=ol.parse(e);return{providerID:t.providerID,model:t.id,...t.variant?{variant:t.variant}:{}}}var Th=ge(x(Yc.schema.fields),[b(y,yt(Te))]).annotate({identifier:`Config.Provider.Settings`}),Eh=ge(x(ll.schema.fields),[b(y,yt(Te))]).annotate({identifier:`Config.Model.Settings`}),Dh=b(y,Te),Oh={settings:Th.pipe(B),headers:b(y,y).pipe(B),body:Dh.pipe(B)},kh={settings:Eh.pipe(B),headers:b(y,y).pipe(B),body:Dh.pipe(B)},Ah=class extends p(`Config.Provider.Request`)({headers:Oh.headers,body:Oh.body}){},jh=class extends p(`Config.Model.Cost.Cache`)({read:el.pipe(B),write:el.pipe(B)}){},Mh=class extends p(`Config.Model.Cost`)({tier:x({type:m(`context`),size:a}).pipe(B),input:el,output:el,cache:jh.pipe(B)}){},Nh=class extends p(`Config.Model.Limit`)({context:a.pipe(B),input:a.pipe(B),output:a.pipe(B)}){},Ph=C([x({supported:m(!1)}),x({supported:m(!0),toggle:g.pipe(B),effort:y.pipe(h,B),budget:x({min:a.pipe(B),max:a.pipe(B)}).pipe(B)})]).annotate({identifier:`Config.Model.Reasoning`}),Fh=class extends p(`Config.Model`)({modelID:nl.pipe(B),type:cl.pipe(B),family:sl.pipe(B),name:y.pipe(B),releaseDate:y.check(f(/^\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:y.pipe(B),...kh,capabilities:dl.mapFields(e=>({tools:B(e.tools),input:B(e.input),output:B(e.output),temperature:e.temperature,reasoning:Ph.pipe(B)})).annotate({identifier:`Config.Model.Capabilities`}).pipe(B),variants:x({id:al,...kh}).pipe(h,B),cost:C([Mh,Mh.pipe(h)]).pipe(B),disabled:g.pipe(B),limit:Nh.pipe(B)}){},Ih=class extends p(`Config.Provider`)({canonical:Rc.pipe(B),name:y.pipe(B),env:y.pipe(h,B),package:y.pipe(B),compatibility:Ic.pipe(B),...Oh,models:b(y,Fh).pipe(B)}){},Lh=y.check(f(/^#[0-9a-fA-F]{6}$/u)),Rh=class extends p(`Config.Agent`)({model:Ch.pipe(B),request:Ah.pipe(B),system:y.pipe(B),description:y.pipe(B),mode:v([`subagent`,`primary`,`all`]).pipe(B),hidden:g.pipe(B),color:Lh.pipe(He(()=>ct),B),steps:R.pipe(B),disabled:g.pipe(B),permissions:Du.pipe(B)}){},zh=class extends p(`Config.Media.Image`)({auto_resize:g.pipe(B),max_width:R.pipe(B),max_height:R.pipe(B),max_base64_bytes:R.pipe(B)}){},Bh=class extends p(`Config.Media`)({image:zh.pipe(B)}){},Vh=class extends p(`Config.Compaction.Keep`)({tokens:z.pipe(B)}){},Hh=class extends p(`Config.Compaction`)({auto:g.pipe(B),keep:Vh.pipe(B),buffer:z.pipe(B)}){},Uh=class extends p(`Config.Command`)({template:y,description:y.pipe(B),agent:y.pipe(B),model:Ch.pipe(B),subagent:g.pipe(B),subtask:g.annotate({description:`Deprecated alias for subagent.`}).pipe(B)}){},Wh=v([`allow`,`deny`]),Gh=x({action:v([`provider.use`,`tool.use`,`integration.use`]),resource:y,effect:Wh}),Kh=class extends p(`ConfigExperimental.Info`)({portable_shell_scanner:g.pipe(B).annotate({description:`Enable the experimental portable shell permission scanner. Defaults to false.`}),todo:g.pipe(B).annotate({description:`Enable the experimental todowrite tool. Defaults to false.`}),background_compaction:g.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:g.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:C([ve,m(!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:Gh.pipe(h,B).annotate({description:`Deprecated: use top-level policies. Ordered policies controlling access to configured resources`})}){},qh=class extends p(`Config.Formatter.Entry`)({disabled:g.pipe(B),command:y.pipe(h,B),environment:b(y,y).pipe(B),extensions:y.pipe(h,B)}){},Jh=C([g,b(y,qh)]),Yh=x({disabled:m(!0)}),Xh=class extends p(`Config.LSP.Server`)({command:y.pipe(h),extensions:y.pipe(h,B),disabled:g.pipe(B),env:b(y,y).pipe(B),initialization:b(y,Ie).pipe(B)}){},Zh=C([Yh,Xh]),Qh=C([g,b(y,Zh)]),$h=class extends p(`Mcp.TimeoutConfig`)({startup:R.pipe(B).annotate({description:`Maximum time in milliseconds to establish and initialize the MCP server.`}),catalog:R.pipe(B).annotate({description:`Maximum time in milliseconds to wait for MCP discovery requests such as tools/list and prompts/list.`}),execution:R.pipe(B).annotate({description:`Maximum time in milliseconds to wait for MCP tool and prompt execution.`})}){},eg=v([`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.`}),tg=class extends p(`Mcp.LocalConfig`)({type:m(`local`),command:y.pipe(h),cwd:y.pipe(B).annotate({description:`Working directory for the MCP server process. Relative paths resolve from the workspace directory.`}),environment:b(y,y).pipe(B),disabled:g.pipe(B),codemode:g.pipe(B).annotate({description:`Expose this server's tools through Code Mode. Defaults to true.`}),timeout:$h.pipe(B),protocol:eg.pipe(B)}){},ng=class extends p(`Mcp.OAuthConfig`)({client_id:y.pipe(B),client_secret:y.pipe(B),scope:y.pipe(B),callback_port:a.check(Pt({minimum:1,maximum:65535})).pipe(B),redirect_uri:y.pipe(B),auth_server_metadata_url:y.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.`})}){},rg=class extends p(`Mcp.RemoteConfig`)({type:m(`remote`),url:y,headers:b(y,y).pipe(B),oauth:C([ng,m(!1)]).pipe(B),disabled:g.pipe(B),codemode:g.pipe(B).annotate({description:`Expose this server's tools through Code Mode. Defaults to true.`}),timeout:$h.pipe(B),protocol:eg.pipe(B)}){},ig=C([tg,rg]).pipe(ye(`type`)),ag=x({status:m(`connected`)}).annotate({identifier:`Mcp.Status.Connected`}),og=x({status:m(`pending`)}).annotate({identifier:`Mcp.Status.Pending`}),sg=x({status:m(`disabled`)}).annotate({identifier:`Mcp.Status.Disabled`}),cg=x({status:m(`failed`),error:y}).annotate({identifier:`Mcp.Status.Failed`}),lg=x({status:m(`needs_auth`),error:y}).annotate({identifier:`Mcp.Status.NeedsAuth`}),ug=C([ag,og,sg,cg,lg]).pipe(ye(`status`)),dg=x({name:y,status:ug,title:B(y),integrationID:B(ws)}).annotate({identifier:`Mcp.Server`}),fg=x({server:y,name:y,uri:y,description:B(y),mimeType:B(y)}).annotate({identifier:`Mcp.Resource`}),pg=x({server:y,name:y,uriTemplate:y,description:B(y),mimeType:B(y)}).annotate({identifier:`Mcp.ResourceTemplate`}),mg=x({resources:h(fg),templates:h(pg)}).annotate({identifier:`Mcp.ResourceCatalog`}),hg=C([x({type:m(`text`),uri:y,text:y,mimeType:B(y)}),x({type:m(`blob`),uri:y,blob:y,mimeType:B(y)})]).pipe(ye(`type`),D({identifier:`Mcp.ResourceContentPart`}));x({server:y,uri:y,contents:h(hg)}).annotate({identifier:`Mcp.ResourceContent`});var gg=$h,_g=ig,vg=class extends p(`Config.MCP`)({timeout:gg.pipe(B),servers:b(y,_g).pipe(B)}){},yg=class extends p(`Config.Plugin.Entry`)({package:y,options:b(y,Ie).pipe(B)}){},bg=C([y,yg]).pipe(h),xg=class extends p(`Config.Reference.Git`)({repository:y,branch:y.pipe(B),description:y.pipe(B),hidden:g.pipe(B)}){},Sg=class extends p(`Config.Reference.Local`)({path:y,description:y.pipe(B),hidden:g.pipe(B)}){},Cg=C([y,xg,Sg]),wg=b(y,Cg),Tg=e({Event:()=>Mg,ID:()=>Eg,Input:()=>Og,Provider:()=>Dg,Response:()=>Ag,Result:()=>kg,WebSearch:()=>Tg}),Eg=y.pipe(A(`WebSearch.ID`),D({identifier:`WebSearch.ID`})),Dg=x({id:Eg,name:y}).annotate({identifier:`WebSearch.Provider`}),Og=x({query:y,providerID:Eg.pipe(B)}).annotate({identifier:`WebSearch.Input`}),kg=x({url:y,title:y.pipe(B),content:y.pipe(B),time:x({published:N.pipe(B).annotate({description:`Publication time in milliseconds since the Unix epoch`})})}).annotate({identifier:`WebSearch.Result`}),Ag=class extends p(`WebSearch.Response`)({providerID:Eg,results:h(kg)}){},jg=U({type:`websearch.updated`,schema:{}}),Mg={Updated:jg,Definitions:W(jg)},Ng=class extends p(`ConfigWebSearch.Info`)({provider:C([m(`random`).annotate({description:`Reuse a randomly selected provider until it is rate limited, then switch to another available provider.`}),Eg])}){},Pg=C([m(!1),Ng]),Fg=class extends p(`Config.ToolOutput`)({max_lines:R.pipe(B),max_bytes:R.pipe(B)}){},Ig=class extends p(`Config.Watcher`)({ignore:y.pipe(h,B)}){},Lg=class extends p(`Config.Warming`)({prompt:y.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")`})}){},Rg=C([g,Lg]),zg=x({directory:St.pipe(ot(Ce())).annotate({description:`Parent directory for new worktrees, relative to the project's primary checkout when not absolute`})}).annotate({identifier:`Config.Worktree`}),Bg=e({Config:()=>Bg,Directory:()=>Wg,Document:()=>Ug,Entry:()=>Gg,Event:()=>qg,Info:()=>Vg,Patch:()=>Hg}),Vg=class extends p(`Config.Info`)({$schema:B(y).annotate({description:`JSON schema reference for configuration validation`}),shell:y.pipe(B).annotate({description:`Default shell to use for terminal and shell tool execution`}),model:Ch.pipe(B).annotate({description:`Default model to use when no session or agent model is selected`}),default_agent:y.pipe(B).annotate({description:`Default primary agent to use when no session agent is selected`}),update:v([`disable`,`notify`,`auto`]).pipe(B).annotate({description:`Disable updates, notify when one is available, or install updates automatically`}),share:v([`manual`,`auto`,`disabled`]).pipe(B).annotate({description:`Control whether sessions may be shared manually, automatically, or not at all`}),enterprise:x({url:y.pipe(B)}).pipe(B).annotate({description:`Enterprise sharing service configuration`}),username:y.pipe(B).annotate({description:`Username displayed in conversations and used for telemetry identity`}),permissions:Du.pipe(B).annotate({description:`Ordered tool permission rules applied to agent tool use`}),policies:Gh.pipe(h,B).annotate({description:`Ordered policies controlling access to providers, tools, and integrations`}),agents:b(y,Rh).pipe(B).annotate({description:`Named built-in agent overrides and custom agent definitions`}),snapshots:g.pipe(B).annotate({description:`Enable snapshots used for undo and revert behavior`}),watcher:Ig.pipe(B).annotate({description:`Filesystem watcher configuration`}),formatter:Jh.pipe(B).annotate({description:`Enable built-in formatters or configure formatter overrides`}),lsp:Qh.pipe(B).annotate({description:`Enable built-in language servers or configure server overrides`}),media:Bh.pipe(B).annotate({description:`Media processing configuration`}),tool_output:Fg.pipe(B).annotate({description:`Tool output truncation thresholds`}),mcp:vg.pipe(B).annotate({description:`MCP server configuration`}),compaction:Hh.pipe(B).annotate({description:`Conversation compaction behavior`}),skills:y.pipe(h,B).annotate({description:`Additional paths or URLs to discover skills from`}),commands:b(y,Uh).pipe(B).annotate({description:`Named slash command definitions`}),instructions:y.pipe(h,B).annotate({description:`Additional paths or URLs supplying ambient instructions`}),references:wg.pipe(B).annotate({description:`Named local directories or Git repositories available as external context`}),websearch:Pg.pipe(B).annotate({description:`Web search provider selection`}),plugins:bg.pipe(B).annotate({description:`Ordered plugin enablement directives and external package declarations`}),worktree:zg.pipe(B).annotate({description:`Directory defaults for local worktree creation`}),warming:Rg.pipe(B).annotate({description:`Keep recently active sessions warm with transient model requests (default: false)`}),providers:b(y,Ih).pipe(B),experimental:Kh.pipe(B)}){},Hg=x({shell:ce(y)}).annotate({identifier:`Config.Patch`}),Ug=class extends p(`Config.Document`)({type:m(`document`),path:oo.pipe(B),info:Vg}){},Wg=class extends p(`Config.Directory`)({type:m(`directory`),path:oo}){},Gg=C([Ug,Wg]).annotate({identifier:`Config.Entry`}),Kg=U({type:`config.updated`,schema:{}}),qg={Updated:Kg,Definitions:W(Kg)},Jg=e({CreateInput:()=>Xg,Directory:()=>$g,Event:()=>a_,Info:()=>Qg,List:()=>n_,ListEntry:()=>e_,OperationError:()=>t_,RemoveInput:()=>Zg,StrategyID:()=>Yg,Worktree:()=>Jg,adopt:()=>o_}),Yg=St.pipe(ot(Ce()),A(`Worktree.StrategyID`)),Xg=x({projectID:Iu,from:B(oo),branch:B(St.pipe(ot(Ce()))),directory:B(oo).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(y)}).annotate({identifier:`Worktree.CreateInput`}),Zg=x({projectID:Iu,directory:oo,force:g}).annotate({identifier:`Worktree.RemoveInput`}),Qg=x({directory:oo}).annotate({identifier:`Worktree.Info`}),$g=x({directory:oo,strategy:B(y)}).annotate({identifier:`Worktree.Directory`}),e_=x({directory:oo,type:v([`root`,`worktree`])}).annotate({identifier:`Worktree.ListEntry`}),t_=class extends t()(`Worktree.OperationError`,{message:y,forceRequired:B(g)}){},n_=h($g).annotate({identifier:`Worktree.List`}),r_=U({type:`worktree.updated`,schema:{projectID:Iu}}),i_=H({type:`worktree.resolved`,durable:{aggregate:`projectID`,version:1},schema:{projectID:Iu,directory:oo,previous:Iu,adopted:B(h(Iu))}}),a_={Updated:r_,Resolved:i_,Definitions:W(r_,i_)};function o_(e,t){if(e.workspaceID||e.projectID!==t.previous&&e.projectID!==Iu.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)}}jo([...lp,a_.Resolved]);var s_=U({type:`file.edited`,schema:{file:y}}),c_={Edited:s_,Definitions:W(s_)},l_=W(U({type:`installation.updated`,schema:{version:y}}),U({type:`installation.update-available`,schema:{version:y}})),u_=y.check(at(`per`)).pipe(A(`PermissionV1.ID`),co(e=>({ascending:t=>e.make(t??`per_`+mo())}))),d_=v([`allow`,`deny`,`ask`]).annotate({identifier:`PermissionV1.Action`}),f_=x({permission:y,pattern:y,action:d_}).annotate({identifier:`PermissionV1.Rule`}),p_=h(f_).annotate({identifier:`PermissionV1.Ruleset`}),m_=x({id:u_,sessionID:hu,permission:y,patterns:h(y),metadata:b(y,Ie),always:h(y),tool:w(x({messageID:y,callID:y}))}).annotate({identifier:`PermissionV1.Request`}),h_=v([`once`,`always`,`reject`]),g_=x({reply:h_,message:w(y)}).annotate({identifier:`PermissionV1.ReplyBody`});x({projectID:Iu,patterns:h(y)}).annotate({identifier:`PermissionV1.Approval`}),x({...m_.fields,id:w(u_),ruleset:p_}).annotate({identifier:`PermissionV1.AskInput`}),x({requestID:u_,...g_.fields}).annotate({identifier:`PermissionV1.ReplyInput`}),W(U({type:`permission.asked`,schema:m_.fields}),U({type:`permission.replied`,schema:{sessionID:hu,requestID:u_,reply:h_}}));var __=N.check(Mt(0)),v_=y.check(at(`msg`)).pipe(A(`SessionV1.MessageID`),co(e=>({ascending:t=>e.make(t??`msg_`+mo())}))),y_=y.check(at(`prt`)).pipe(A(`SessionV1.PartID`),co(e=>({ascending:t=>e.make(t??`prt_`+mo())}))),b_=(e,t)=>{let n=x({name:m(e),data:x(t)}).annotate({identifier:e});return{Schema:n,EffectSchema:n}},x_=b_(`MessageOutputLengthError`,{}),S_=b_(`ProviderAuthError`,{providerID:y,message:y}),C_=b_(`MessageAbortedError`,{message:y}),w_=b_(`StructuredOutputError`,{message:y,retries:z}),T_=b_(`APIError`,{message:y,statusCode:w(z),isRetryable:g,responseHeaders:w(b(y,y)),responseBody:w(y),metadata:w(b(y,y))}),E_=b_(`ContextOverflowError`,{message:y,responseBody:w(y)}),D_=b_(`ContentFilterError`,{message:y}),O_=class extends p(`OutputFormatText`)({type:m(`text`)}){},k_=class extends p(`OutputFormatJsonSchema`)({type:m(`json_schema`),schema:b(y,rt).annotate({identifier:`SessionV1.JSONSchema`}),retryCount:z.pipe(w,Ee(ht(2)))}){},A_=C([O_,k_]).annotate({discriminator:`type`,identifier:`SessionV1.OutputFormat`}),j_={id:y_,sessionID:hu,messageID:v_},M_=x({...j_,type:m(`snapshot`),snapshot:y}).annotate({identifier:`SessionV1.SnapshotPart`}),N_=x({...j_,type:m(`patch`),hash:y,files:h(y)}).annotate({identifier:`SessionV1.PatchPart`}),P_=x({...j_,type:m(`text`),text:y,synthetic:w(g),ignored:w(g),time:w(x({start:z,end:w(z)})),metadata:w(b(y,rt))}).annotate({identifier:`SessionV1.TextPart`}),F_=x({...j_,type:m(`reasoning`),text:y,metadata:w(b(y,rt)),time:x({start:z,end:w(z)})}).annotate({identifier:`SessionV1.ReasoningPart`}),I_={text:x({value:y,start:N,end:N}).annotate({identifier:`SessionV1.FilePartSourceText`})},L_=x({start:x({line:z,character:z}),end:x({line:z,character:z})}).annotate({identifier:`SessionV1.Range`}),R_=x({...I_,type:m(`file`),path:y}).annotate({identifier:`SessionV1.FileSource`}),z_=x({...I_,type:m(`symbol`),path:y,range:L_,name:y,kind:z}).annotate({identifier:`SessionV1.SymbolSource`}),B_=x({...I_,type:m(`resource`),clientName:y,uri:y}).annotate({identifier:`SessionV1.ResourceSource`}),V_=C([R_,z_,B_]).annotate({discriminator:`type`,identifier:`SessionV1.FilePartSource`}),H_=x({...j_,type:m(`file`),mime:y,filename:w(y),url:y,source:w(V_)}).annotate({identifier:`SessionV1.FilePart`}),U_=x({...j_,type:m(`agent`),name:y,source:w(x({value:y,start:z,end:z}))}).annotate({identifier:`SessionV1.AgentPart`}),W_=x({...j_,type:m(`compaction`),auto:g,overflow:w(g),tail_start_id:w(v_)}).annotate({identifier:`SessionV1.CompactionPart`}),G_=x({...j_,type:m(`subtask`),prompt:y,description:y,agent:y,model:w(x({providerID:Rc,modelID:nl})),command:w(y)}).annotate({identifier:`SessionV1.SubtaskPart`}),K_=x({...j_,type:m(`retry`),attempt:z,error:T_.EffectSchema,time:x({created:z})}).annotate({identifier:`SessionV1.RetryPart`}),q_=x({...j_,type:m(`step-start`),snapshot:w(y)}).annotate({identifier:`SessionV1.StepStartPart`}),J_=x({...j_,type:m(`step-finish`),reason:y,snapshot:w(y),cost:N,tokens:x({total:w(N),input:N,output:N,reasoning:N,cache:x({read:N,write:N})})}).annotate({identifier:`SessionV1.StepFinishPart`}),Y_=x({status:m(`pending`),input:b(y,rt),raw:y}).annotate({identifier:`SessionV1.ToolStatePending`}),X_=x({status:m(`running`),input:b(y,rt),title:w(y),metadata:w(b(y,rt)),time:x({start:z})}).annotate({identifier:`SessionV1.ToolStateRunning`}),Z_=x({status:m(`completed`),input:b(y,rt),output:y,title:y,metadata:b(y,rt),time:x({start:z,end:z,compacted:w(z)}),attachments:w(h(H_))}).annotate({identifier:`SessionV1.ToolStateCompleted`}),Q_=x({status:m(`error`),input:b(y,rt),error:y,metadata:w(b(y,rt)),time:x({start:z,end:z})}).annotate({identifier:`SessionV1.ToolStateError`}),$_=C([Y_,X_,Z_,Q_]).annotate({discriminator:`status`,identifier:`SessionV1.ToolState`}),ev=x({...j_,type:m(`tool`),callID:y,tool:y,state:$_,metadata:w(b(y,rt))}).annotate({identifier:`SessionV1.ToolPart`}),tv={id:v_,sessionID:j_.sessionID},nv=x({...tv,role:m(`user`),time:x({created:__}),format:w(A_),summary:w(x({title:w(y),body:w(y),diffs:h(Kd)})),agent:y,model:x({providerID:Rc,modelID:nl,variant:w(y)}),system:w(y),tools:w(b(y,g))}).annotate({identifier:`SessionV1.UserMessage`}),rv=C([P_,G_,F_,H_,ev,q_,J_,M_,N_,U_,K_,W_]).annotate({discriminator:`type`,identifier:`SessionV1.Part`}),iv=C([S_.EffectSchema,b_(`UnknownError`,{message:y,ref:w(y)}).EffectSchema,x_.EffectSchema,C_.EffectSchema,w_.EffectSchema,E_.EffectSchema,D_.EffectSchema,T_.EffectSchema]).annotate({discriminator:`name`});x({id:w(y_),type:m(`text`),text:y,synthetic:w(g),ignored:w(g),time:w(x({start:z,end:w(z)})),metadata:w(b(y,rt))}).annotate({identifier:`SessionV1.TextPartInput`}),x({id:w(y_),type:m(`file`),mime:y,filename:w(y),url:y,source:w(V_)}).annotate({identifier:`SessionV1.FilePartInput`}),x({id:w(y_),type:m(`agent`),name:y,source:w(x({value:y,start:z,end:z}))}).annotate({identifier:`SessionV1.AgentPartInput`}),x({id:w(y_),type:m(`subtask`),prompt:y,description:y,agent:y,model:w(x({providerID:Rc,modelID:nl})),command:w(y)}).annotate({identifier:`SessionV1.SubtaskPartInput`});var av=x({...tv,role:m(`assistant`),time:x({created:z,completed:w(z)}),error:w(iv),parentID:v_,modelID:nl,providerID:Rc,mode:y,agent:y,path:x({cwd:y,root:y}),summary:w(g),cost:N,tokens:x({total:w(N),input:N,output:N,reasoning:N,cache:x({read:N,write:N})}),structured:w(rt),variant:w(y),finish:w(y)}).annotate({identifier:`SessionV1.AssistantMessage`}),ov=C([nv,av]).annotate({discriminator:`role`,identifier:`SessionV1.Message`}),sv={durable:{aggregate:`sessionID`,version:1}},cv=x({additions:N,deletions:N,files:N,diffs:B(h(Kd))}),lv=x({input:N,output:N,reasoning:N,cache:x({read:N,write:N})}),uv=x({url:y}),dv=x({messageID:v_,partID:B(y_),snapshot:B(y),diff:B(y)}),fv=x({id:nl,providerID:Rc,variant:B(y)}),pv=x({id:hu,slug:y,projectID:Iu,workspaceID:B(vo),directory:y,path:B(y),parentID:B(hu),summary:B(cv),cost:B(N),tokens:B(lv),share:B(uv),title:B(y),agent:B(y),model:B(fv),version:y,metadata:B(b(y,rt)),time:x({created:z,updated:z,compacting:B(z),archived:B(N)}),permission:B(p_),revert:B(dv)}).annotate({identifier:`SessionV1.Info`}),mv={Created:H({type:`session.created`,...sv,schema:{sessionID:hu,info:pv}}),Updated:H({type:`session.updated`,...sv,schema:{sessionID:hu,info:pv}}),Deleted:H({type:`session.deleted`,...sv,schema:{sessionID:hu,info:pv}}),MessageUpdated:H({type:`message.updated`,...sv,schema:{sessionID:hu,info:ov}}),MessageRemoved:H({type:`message.removed`,...sv,schema:{sessionID:hu,messageID:v_}}),PartUpdated:H({type:`message.part.updated`,...sv,schema:{sessionID:hu,part:rv,time:N}}),PartRemoved:H({type:`message.part.removed`,...sv,schema:{sessionID:hu,messageID:v_,partID:y_}})},hv=U({type:`message.part.delta`,schema:{sessionID:hu,messageID:v_,partID:y_,field:y,delta:y}}),gv=U({type:`session.diff`,schema:{sessionID:hu,diff:h(Kd)}}),_v=U({type:`session.error`,schema:{sessionID:w(hu),error:av.fields.error}});({...mv}),W(mv.Created,mv.Updated,mv.Deleted,mv.MessageUpdated,mv.MessageRemoved,mv.PartUpdated,mv.PartRemoved,hv,gv,_v);var vv=W(U({type:`command.executed`,schema:{name:y,sessionID:hu,arguments:y,messageID:v_}})),yv=W(U({type:`lsp.updated`,schema:{}})),bv=W(U({type:`location.shutdown`,schema:{}})),xv=U({type:`mcp.tools.changed`,schema:{server:y}}),Sv=U({type:`mcp.resources.changed`,schema:{server:y}}),Cv=U({type:`mcp.status.changed`,schema:{server:y}}),wv=W(xv,Sv,Cv),Tv=U({type:`models-dev.refreshed`,schema:{}}),Ev={Refreshed:Tv,Definitions:W(Tv)},Dv=y.pipe(A(`Plugin.ID`),D({identifier:`Plugin.ID`})),Ov=C([x({type:m(`builtin`)}),x({type:m(`package`),target:y,version:y.pipe(B),outdated:m(!0).pipe(B),updating:m(!0).pipe(B)}),x({type:m(`local`),path:y}),x({type:m(`sdk`)})]).annotate({identifier:`Plugin.Source`}),kv=x({server:m(!0).pipe(B),tui:m(!0).pipe(B),rpc:m(!0).pipe(B),gui:m(!0).pipe(B)}).annotate({identifier:`Plugin.Features`}),Av=x({code:y,revision:y,options:b(y,Te)}).annotate({identifier:`Plugin.GuiBundle`}),jv=C([x({status:m(`active`)}),x({status:m(`failed`),error:y,ref:y.pipe(B)})]).annotate({identifier:`Plugin.State`}),Mv=x({id:Dv.pipe(B),source:Ov,features:kv,state:jv}).annotate({identifier:`Plugin.Info`}),Nv=U({type:`plugin.updated`,schema:{}}),Pv={Updated:Nv,Definitions:W(Nv)},Fv=e({Event:()=>Lv,GitSource:()=>zv,Info:()=>Vv,LocalSource:()=>Rv,Reference:()=>Fv,Source:()=>Bv}),Iv=U({type:`reference.updated`,schema:{}}),Lv={Updated:Iv,Definitions:W(Iv)},Rv=x({type:m(`local`),path:oo,description:y.pipe(B),hidden:g.pipe(B)}).annotate({identifier:`Reference.LocalSource`}),zv=x({type:m(`git`),repository:y,branch:y.pipe(B),description:y.pipe(B),hidden:g.pipe(B)}).annotate({identifier:`Reference.GitSource`}),Bv=C([Rv,zv]).pipe(ye(`type`)).annotate({identifier:`Reference.Source`}),Vv=x({name:y,path:oo,description:y.pipe(B),hidden:g.pipe(B),source:Bv}).annotate({identifier:`Reference.Info`}),Hv=W(U({type:`server.connected`,schema:{}}),U({type:`global.disposed`,schema:{}})),Uv=W(U({type:`session.status`,identifier:`SessionStatusUpdated`,schema:{sessionID:hu,status:C([x({type:m(`idle`)}),x({type:m(`retry`),attempt:z,message:y,action:B(x({reason:y,provider:y,title:y,message:y,label:y,link:B(y)})),next:z}),x({type:m(`busy`)})]).annotate({identifier:`SessionStatus`})}}),U({type:`session.idle`,schema:{sessionID:hu}})),Wv=W(U({type:`tui.prompt.append`,schema:{text:y}}),U({type:`tui.command.execute`,schema:{command:C([v([`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`]),y])}}),U({type:`tui.toast.show`,schema:{title:B(y),message:y,variant:v([`info`,`success`,`warning`,`error`]),duration:R.pipe(Ee(ht(5e3))).annotate({description:`Duration in milliseconds`})}}),U({type:`tui.session.select`,schema:{sessionID:hu.annotate({description:`Session ID to navigate to`})}})),Gv=W(U({type:`vcs.branch.updated`,schema:{branch:B(y)}})),Kv=x({workspaceID:vo,status:v([`connected`,`connecting`,`disconnected`,`error`])}).annotate({identifier:`WorkspaceEvent.ConnectionStatus`}),qv=W(U({type:`workspace.ready`,schema:{name:y}}),U({type:`workspace.failed`,schema:{message:y}}),U({type:`workspace.status`,schema:Kv.fields})),Jv=W(U({type:`worktree.ready`,schema:{name:y,branch:B(y)}}),U({type:`worktree.failed`,schema:{message:y}})),Yv=W(...cp),Xv=W(...bv,...Ev.Definitions,...As.Definitions,...Sc.Definitions,...Bc.Definitions,...il.Definitions,...Pu.Definitions,...Yv),Zv=W(...Zm.Definitions,...Lv.Definitions,...wu.Definitions,...Pv.Definitions,...Gu.Definitions,...a_.Definitions,...fh.Definitions,...qg.Definitions,...Bo.Definitions,...fu.Definitions,...Fp.Definitions,...ad.Definitions,...dc.Definitions,...Mg.Definitions),Qv=W(...Xv,...Zv,...Uv,...Wv,...l_,...Gv,Cv,Sv);ko(Qv),ko(W(...Xv,...l_,...Zv,...yv,...Wv,...wv,...vv,...c_.Definitions,...Uv,...Gv,...qv,...Jv,...Hv));var $v={id:To,metadata:w(b(y,Ie)),location:w(xo)},ey=x({id:To,created:N,metadata:w(b(y,Ie)),type:Ke([`rpc.`,y]),location:xo,data:b(y,Ie)}).annotate({identifier:`V2Event.rpc`}),ty=e=>C([...e,ey,...e.some(e=>e.type===`server.connected`)?[]:[x({...$v,type:m(`server.connected`),data:x({})}).annotate({identifier:`V2Event.server.connected`})]]).annotate({identifier:`V2Event`}),ny=e=>x({types:w(de(C([v(e.map(e=>e.type)),ey.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`}),ry=(e=>{let t=ty(e);return{schema:t,group:j(`server.event`).add(k(`event.subscribe`,`/api/event`,{query:ny(e),success:qe({data:t})}).annotateMerge(O({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(O({title:`event`,description:`Experimental event stream routes.`}))}})(Qv),iy=ry.group;ry.schema;var ay=j(`server.agent`).add(k(`agent.list`,`/api/agent`,{query:X,success:V(h(Nu)),error:Xo}).annotateMerge(Z).annotateMerge(O({identifier:`agent.list`,summary:`List agents`,description:`Retrieve currently registered agents.`}))).add(k(`agent.get`,`/api/agent/:agentID`,{params:{agentID:Au},query:X,success:V(Nu),error:as}).annotateMerge(Z).annotateMerge(O({identifier:`agent.get`,summary:`Get agent`,description:`Retrieve a single currently registered agent.`}))).annotateMerge(O({title:`agent`})),oy=j(`server.plugin`).add(k(`plugin.list`,`/api/plugin`,{query:X,success:V(h(Mv))}).annotateMerge(Z).annotateMerge(O({identifier:`plugin.list`,summary:`List plugins`,description:`Retrieve enabled server plugins and their current status.`}))).add(k(`plugin.gui`,`/api/plugin/gui`,{query:x({...X.fields,id:Dv}),success:V(Av),error:is}).annotateMerge(Z).annotateMerge(O({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(T(`plugin.check`,`/api/plugin/check`,{query:X,payload:x({target:y.pipe(w)}),success:V(h(Mv)),error:Wo}).annotateMerge(Z).annotateMerge(O({identifier:`plugin.check`,summary:`Check plugin updates`,description:`Check one or all package plugins for available updates.`}))).add(T(`plugin.update`,`/api/plugin/update`,{query:X,payload:x({targets:h(y)}),success:S,error:[Wo,Xo]}).annotateMerge(Z).annotateMerge(O({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(O({title:`plugin`,description:`Experimental plugin routes.`})),sy=x({version:y,pid:a.check(Mt(0)),hostname:w(y),urls:h(y),paths:x({tmp:y}),capabilities:w(x({persistentPty:w(g)}))}).annotate({identifier:`ServerInfo`}),cy=x({code:y,expires_in:a}).annotate({identifier:`PairingCode`}),ly=x({token:y}).annotate({identifier:`PairingSession`}),uy=j(`server.server`).add(k(`server.info`,`/api/info`,{success:sy}).annotateMerge(O({identifier:`server.info`,summary:`Get server info`,description:`Return the server identity, connection URLs, paths, and readiness status.`}))).add(T(`server.pair`,`/api/pair`,{success:cy}).annotateMerge(O({identifier:`server.pair`,summary:`Create pairing code`,description:`Create a short-lived, single-use code for a /auth/connect/:code pairing link.`}))).add(k(`server.connect`,`/auth/connect/:code`,{params:{code:y},success:ly,error:qo}).annotateMerge(O({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(O({title:`server`})),dy=j(`server.debug`).add(T(`debug.heapDump`,`/api/debug/heap-dump`,{query:x({directory:y.pipe(w,D({description:`Absolute server-local directory to write the snapshot into, created when missing. Defaults to the server's log directory.`}))}),success:x({path:y,pid:a,memory:x({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:[Wo,Zo]}).annotateMerge(O({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(k(`debug.location`,`/api/debug/location`,{success:h(xo)}).annotateMerge(O({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:S}).annotateMerge(Z).annotateMerge(O({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(O({title:`debug`})),fy=j(`server.shell`).add(k(`shell.list`,`/api/shell`,{query:X,success:V(h(td))}).annotateMerge(Z).annotateMerge(O({identifier:`shell.list`,summary:`List running shell commands`,description:`List currently running shell commands for a location. Exited commands are not included.`}))).add(T(`shell.create`,`/api/shell`,{query:X,payload:od,success:V(td)}).annotateMerge(Z).annotateMerge(O({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(k(`shell.get`,`/api/shell/:id`,{params:{id:Zu},query:X,success:V(td),error:ys}).annotateMerge(Z).annotateMerge(O({identifier:`shell.get`,summary:`Get shell command`,description:`Get one shell command, including its status and exit code once exited.`}))).add(k(`shell.output`,`/api/shell/:id/output`,{params:{id:Zu},query:x({...X.fields,...sd.fields}),success:V(cd),error:ys}).annotateMerge(Z).annotateMerge(O({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:Zu},query:X,success:S}).annotateMerge(Z).annotateMerge(O({identifier:`shell.remove`,summary:`Remove shell command`,description:`Terminate and remove one shell command and its retained output.`}))).annotateMerge(O({title:`shell`,description:`Location-scoped shell command routes.`})),py=x(re(Rv.fields,[`description`,`hidden`])).annotate({identifier:`Reference.LocalSource`}),my=x(re(zv.fields,[`description`,`hidden`])).annotate({identifier:`Reference.GitSource`}),hy=C([py,my]).pipe(ye(`type`)).annotate({identifier:`Reference.Source`}),gy=x({...re(Vv.fields,[`source`]),source:hy}).annotate({identifier:`Reference.Info`}),_y=j(`server.reference`).add(k(`reference.list`,`/api/reference`,{query:X,success:V(h(gy))}).annotateMerge(Z).annotateMerge(O({identifier:`reference.list`,summary:`List references`,description:`List references available in the requested location.`}))).annotateMerge(O({title:`reference`,description:`Location-scoped project references.`})),vy=class extends tt()(`@opencode/HttpApiAuthorization`,{error:qo}){},yy=j(`server.integration`).add(k(`integration.list`,`/api/integration`,{query:X,success:V(h(wc))}).annotateMerge(Z).annotateMerge(O({identifier:`integration.list`,summary:`List integrations`,description:`Retrieve available integrations and their authentication methods.`}))).add(k(`integration.get`,`/api/integration/:integrationID`,{params:{integrationID:pc},query:X,success:V(wc),error:$o}).annotateMerge(Z).annotateMerge(O({identifier:`integration.get`,summary:`Get integration`,description:`Retrieve one integration and its authentication methods.`}))).add(T(`integration.wellknown.add`,`/api/experimental/integration/wellknown`,{query:X,payload:x({url:y}),success:S,error:Wo}).annotateMerge(Z).annotateMerge(O({identifier:`experimental.integration.wellknown.add`,summary:`Add wellknown integration`,description:`Discover and persist an experimental wellknown integration source.`}))).add(T(`integration.connect.key`,`/api/integration/:integrationID/connect/key`,{params:{integrationID:pc},query:X,payload:x({key:y,answer:w(ic),label:w(y)}),success:S,error:[$o,Wo]}).annotateMerge(Z).annotateMerge(O({identifier:`integration.connect.key`,summary:`Connect with key`,description:`Run a key authentication method and store the resulting credential.`}))).add(T(`integration.connect.external`,`/api/integration/:integrationID/connect/external`,{params:{integrationID:pc},query:X,payload:x({methodID:mc,answer:w(ic),label:w(y)}),success:S,error:[$o,Wo]}).annotateMerge(Z).annotateMerge(O({identifier:`integration.connect.external`,summary:`Connect with external credentials`,description:`Run an external authentication method and store a reference to its credential source.`}))).add(T(`integration.oauth.connect`,`/api/integration/:integrationID/connect/oauth`,{params:{integrationID:pc},query:X,payload:x({methodID:mc,answer:w(ic),label:w(y)}),success:V(Dc),error:Wo}).annotateMerge(Z).annotateMerge(O({identifier:`integration.oauth.connect`,summary:`Begin OAuth connection`,description:`Start an OAuth attempt and return the authorization details.`}))).add(k(`integration.oauth.status`,`/api/integration/:integrationID/connect/oauth/:attemptID`,{params:{integrationID:pc,attemptID:Tc},query:X,success:V(Oc),error:[$o,es]}).annotateMerge(Z).annotateMerge(O({identifier:`integration.oauth.status`,summary:`Get OAuth attempt status`,description:`Poll the current status of an OAuth attempt.`}))).add(T(`integration.oauth.complete`,`/api/integration/:integrationID/connect/oauth/:attemptID/complete`,{params:{integrationID:pc,attemptID:Tc},query:X,payload:x({code:w(y)}),success:S,error:[$o,es,Wo]}).annotateMerge(Z).annotateMerge(O({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:pc,attemptID:Tc},query:X,success:S}).annotateMerge(Z).annotateMerge(O({identifier:`integration.oauth.cancel`,summary:`Cancel OAuth connection`,description:`Cancel an OAuth attempt and release its resources.`}))).add(T(`integration.command.connect`,`/api/integration/:integrationID/connect/command`,{params:{integrationID:pc},query:X,payload:x({methodID:mc,label:w(y)}),success:V(kc),error:[$o,ts,Wo]}).annotateMerge(Z).annotateMerge(O({identifier:`integration.command.connect`,summary:`Begin command connection`,description:`Start a command authentication attempt.`}))).add(k(`integration.command.status`,`/api/integration/:integrationID/connect/command/:attemptID`,{params:{integrationID:pc,attemptID:Tc},query:X,success:V(Ac),error:[$o,es]}).annotateMerge(Z).annotateMerge(O({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:pc,attemptID:Tc},query:X,success:S}).annotateMerge(Z).annotateMerge(O({identifier:`integration.command.cancel`,summary:`Cancel command connection`,description:`Cancel a command authentication attempt and terminate its process.`}))).annotateMerge(O({title:`integration`,description:`Integration discovery and authentication routes.`})),by=j(`server.websearch`).add(k(`websearch.providers`,`/api/websearch/provider`,{query:X,success:V(h(Dg)),error:Xo}).annotateMerge(Z).annotateMerge(O({identifier:`websearch.providers`,summary:`List web search providers`,description:`Return the registered web search providers.`}))).add(T(`websearch.query`,`/api/websearch`,{query:X,payload:x(Og.fields),success:V(Ag),error:[Wo,Xo]}).annotateMerge(Z).annotateMerge(O({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(O({title:`websearch`,description:`Location-scoped web search routes.`})),xy=N.check(Pt({minimum:0,maximum:100})),Sy=N.annotate({description:`Milliseconds since the Unix epoch`}),Cy=x({percent:xy,limited:g,resetsAt:Sy}).annotate({identifier:`UsageLimits.Meter`}),wy=x({rolling:Cy,weekly:Cy,monthly:Cy}).annotate({identifier:`UsageLimits.Go`}),Ty=x({providerID:Rc,modelID:nl,name:y,spent:$c.pipe(B)}).annotate({identifier:`UsageLimits.BudgetModel`}),Ey=x({id:y,limit:$c,spent:$c,scope:v([`each`,`combined`]),per:v([`set`,`model`]),coverage:v([`all`,`models`]),models:h(Ty),vendors:h(y),inputPriceAtLeast:el.pipe(B),picked:g,shared:g,resetsAt:Sy}).annotate({identifier:`UsageLimits.Budget`}),Dy=x({workspace:x({id:y,name:y.pipe(B),usageURL:y}),go:wy.pipe(B),budgets:h(Ey)}).annotate({identifier:`UsageLimits.Info`}),Oy=j(`server.usage`).add(k(`usage.limits`,`/api/experimental/usage/limits`,{query:X,success:V(ce(Dy)),error:Xo}).annotateMerge(Z).annotateMerge(O({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(O({title:`usage`,description:`Experimental usage limit routes.`})),ky=`/api/experimental/client-mcp`,Ay=x({...X.fields,name:y.check(f(/^[a-zA-Z0-9_-]+$/))}),jy=e=>j(`server.mcp`).add(k(`mcp.list`,`/api/mcp`,{query:X,success:V(h(dg))}).annotateMerge(Z).annotateMerge(O({identifier:`mcp.list`,summary:`List MCP servers`,description:`Retrieve configured MCP servers and their connection status.`}))).add(Ct(`mcp.add`,`/api/experimental/mcp/:server`,{params:{server:y},query:X,payload:x({config:ig}),success:S}).annotateMerge(Z).annotateMerge(O({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:y},query:X,success:S,error:cs}).annotateMerge(Z).annotateMerge(O({identifier:`experimental.mcp.remove`,summary:`Remove MCP server`,description:`Stop an MCP server and remove it from the runtime set until restart.`}))).add(T(`mcp.connect`,`/api/experimental/mcp/:server/connect`,{params:{server:y},query:X,success:S,error:cs}).annotateMerge(Z).annotateMerge(O({identifier:`experimental.mcp.connect`,summary:`Connect MCP server`,description:`Connect an MCP server at runtime, overriding a disabled configuration until restart.`}))).add(T(`mcp.disconnect`,`/api/experimental/mcp/:server/disconnect`,{params:{server:y},query:X,success:S,error:cs}).annotateMerge(Z).annotateMerge(O({identifier:`experimental.mcp.disconnect`,summary:`Disconnect MCP server`,description:`Disconnect an MCP server at runtime, removing its tools until reconnected.`}))).add(k(`mcp.resource.catalog`,`/api/mcp/resource`,{query:X,success:V(mg)}).annotateMerge(Z).annotateMerge(O({identifier:`mcp.resource.catalog`,summary:`List MCP resources`,description:`Retrieve resources and resource templates from connected MCP servers.`}))).add(T(`mcp.clientToken`,`${ky}/token`,{query:Ay,headers:x({[zp]:w(y)}),success:V(Ip),error:_s}).annotateMerge(Z).annotateMerge(O({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(k(`mcp.client`,ky,{query:x({...Ay.fields,[Rp]:w(y)}),success:g,error:[_s,Uo]}).annotateMerge(Z).annotateMerge(O({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(O({title:`mcp`,description:`MCP server and resource routes.`})),My=j(`server.credential`).add(k(`credential.list`,`/api/credential`,{success:x({data:h(Fs)})}).annotateMerge(O({identifier:`credential.list`,summary:`List credentials`,description:`List every stored integration credential, including its secret value.`}))).add(T(`credential.create`,`/api/credential`,{payload:Is,success:x({data:Fs}),error:Jo}).annotateMerge(O({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(Be(`credential.update`,`/api/credential/:credentialID`,{params:{credentialID:Ds},payload:x({label:y}),success:S}).annotateMerge(O({identifier:`credential.update`,summary:`Update credential`,description:`Update a stored credential label.`}))).annotateMerge(O({title:`credential`})).add(T(`credential.activate`,`/api/credential/:credentialID/activate`,{params:{credentialID:Ds},success:S}).annotateMerge(O({identifier:`credential.activate`,summary:`Activate credential`,description:`Activate a stored integration credential.`}))).add(ft(`credential.remove`,`/api/credential/:credentialID`,{params:{credentialID:Ds},success:S}).annotateMerge(O({identifier:`credential.remove`,summary:`Remove credential`,description:`Remove a stored integration credential.`}))),Ny=`/api/project`,Py=x(re(Uu.fields,[`projectID`])),Fy=v([`true`,`false`]).pipe(wt(g,{decode:_t(e=>e===`true`),encode:_t(e=>e?`true`:`false`)})),Iy=j(`server.project`).add(k(`project.list`,Ny,{query:x({archived:Fy.pipe(w)}),success:h(Hu)}).annotateMerge(O({identifier:`project.list`,summary:`List projects`,description:`List known projects. Archived projects are excluded unless archived=true.`}))).add(Be(`project.update`,`${Ny}/:projectID`,{params:{projectID:Iu},payload:Py,success:Hu,error:ns}).annotateMerge(O({identifier:`project.update`,summary:`Update project`,description:`Update the project canonical directory, display metadata, and workspace commands.`}))).annotateMerge(O({title:`project`,description:`Project routes.`})),Ly=`/api/worktree`,Ry=class extends t()(`WorktreeError`,{name:m(`WorktreeError`),data:x({message:y,forceRequired:w(g)})},{httpApiStatus:400}){},zy=j(`server.worktree`).add(k(`worktree.list`,Ly,{query:x({projectID:Iu}),success:n_,error:ns}).annotateMerge(O({identifier:`worktree.list`,summary:`List worktrees`,description:`Return the project's saved worktree inventory without loading configuration or running discovery.`}))).add(T(`worktree.create`,Ly,{payload:Xg,success:Qg,error:[Ry,ns]}).annotateMerge(O({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`,Ly,{payload:Zg,success:S,error:[Ry,ns]}).annotateMerge(O({identifier:`worktree.remove`,summary:`Remove worktree`,description:`Load the project's canonical configuration and remove a saved worktree using its recorded strategy.`}))).add(T(`worktree.refresh`,`${Ly}/refresh`,{payload:x({projectID:Iu}),success:S,error:[Ry,ns]}).annotateMerge(O({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(O({title:`worktree`,description:`Project-based worktree management routes.`})),By=e({Base:()=>Wy,Branch:()=>Vy,BranchList:()=>Uy,FileStatus:()=>qy,Info:()=>Hy,Mode:()=>Gy,Untracked:()=>Ky,Vcs:()=>By}),Vy=x({current:B(y),default:B(y)}).annotate({identifier:`Vcs.Branch`}),Hy=x({provider:B(y),branch:Vy}).annotate({identifier:`Vcs.Info`}),Uy=h(y).annotate({identifier:`Vcs.BranchList`}),Wy=x({name:y,ref:y,source:v([`reflog`,`default`])}).annotate({identifier:`Vcs.Base`}),Gy=v([`working`,`branch`,`committed`]).annotate({identifier:`Vcs.Mode`}),Ky=v([`files`,`folders`]).annotate({identifier:`Vcs.Untracked`}),qy=x({file:y,additions:z,deletions:z,status:v([`added`,`deleted`,`modified`])}).annotate({identifier:`Vcs.FileStatus`}),Jy=x({...X.fields,provider:w(y)}),Yy=class extends t()(`VcsInitNotSupportedError`,{providerID:y,message:y},{httpApiStatus:501}){},Xy=x({...X.fields,search:w(y),limit:oe.pipe(wt(R),w)}),Zy=x({...X.fields,mode:Gy,base:B(y),context:oe.pipe(wt(z),w),untracked:B(Ky)}),Qy=j(`server.vcs`).add(T(`vcs.init`,`/api/vcs/init`,{query:Jy,success:S,error:[Jo,Wo,Yy,Xo]}).annotateMerge(Z).annotateMerge(O({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(k(`vcs.get`,`/api/vcs`,{query:X,success:V(Hy)}).annotateMerge(Z).annotateMerge(O({identifier:`vcs.get`,summary:`VCS info`,description:`Get current and default branch information for the requested location.`}))).add(k(`vcs.base`,`/api/vcs/base`,{query:X,success:V(ce(Wy)),error:Xo}).annotateMerge(Z).annotateMerge(O({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(k(`vcs.status`,`/api/vcs/status`,{query:X,success:V(h(qy))}).annotateMerge(Z).annotateMerge(O({identifier:`vcs.status`,summary:`VCS status`,description:`List uncommitted working-copy changes relative to the requested location.`}))).add(k(`vcs.branch.list`,`/api/vcs/branch`,{query:Xy,success:V(Uy)}).annotateMerge(Z).annotateMerge(O({identifier:`vcs.branch.list`,summary:`VCS branches`,description:`List local and remote branches available at the requested location.`}))).add(k(`vcs.diff`,`/api/vcs/diff`,{query:Zy,success:V(h(Gd)),error:Xo}).annotateMerge(Z).annotateMerge(O({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(O({title:`vcs`,description:`Location-scoped version control routes.`})),$y=x({label:y,numerator:w(a.check(Mt(0))),denominator:w(a.check(Mt(0)))}),eb=C([x({status:v([`required`,`completed`])}),x({status:m(`running`),progress:$y}),x({status:m(`error`),error:y})]),tb=j(`server.migration`).add(k(`migration.v1.status`,`/api/experimental/migration/v1`,{success:eb}).annotateMerge(O({identifier:`experimental.migration.v1.status`,summary:`Get V1 migration status`,description:`Return the progress of the V1 to V2 session history migration.`}))).annotateMerge(O({title:`migration`})),nb=x({path:y,name:y,acceptable:g}).annotate({identifier:`ConfigShell.Option`}),rb=j(`server.config`).add(k(`config.get`,`/api/config`,{query:X,success:h(Gg)}).annotateMerge(Z).annotateMerge(O({identifier:`config.get`,summary:`Get configuration`,description:`Return configuration documents and discovery sources for the requested location, from lowest to highest priority.`}))).add(k(`config.shells`,`/api/config/shell`,{success:h(nb)}).annotateMerge(O({identifier:`config.shells`,summary:`List available shells`,description:`Return shells available to terminal and agent execution.`}))).add(Be(`config.update`,`/api/experimental/config`,{payload:Hg,success:S}).annotateMerge(O({identifier:`experimental.config.update`,summary:`Update global configuration`,description:`Patch supported fields in the highest-precedence global configuration document.`}))).annotateMerge(O({title:`config`,description:`Location-scoped configuration routes.`})),ib=(e,t,n,r)=>Pe(`server`).add(uy).add(Lp(t)).add(ay.middleware(t)).add(oy.middleware(t)).add(Wm(r,n)).add(om).add(cm.middleware(t)).add(nu).add(em).add(lm.middleware(t)).add(yy.middleware(t)).add(jy(t)).add(My).add(Iy).add(ch(t)).add(Jm(t,r)).add(sh.middleware(t)).add(ph.middleware(t)).add(mh.middleware(t)).add(_h.middleware(t)).add(e).add(Vp(t)).add(Gp).add(fy.middleware(t)).add(_y.middleware(t)).add(zy).add(Qy.middleware(t)).add(dy).add(tb).add(by.middleware(t)).add(Oy.middleware(t)).add(rb.middleware(t)).annotateMerge(O({title:`opencode HttpApi`,version:`0.0.1`,description:`Experimental HttpApi surface for selected instance routes.`})).middleware(vy).middleware(Cs),ab=e=>ib(iy,e.locationMiddleware,e.formLocationMiddleware,e.sessionLocationMiddleware),ob=class extends tt()(`@opencode/client/LocationMiddleware`,{error:[Uo]}){},sb=class extends tt()(`@opencode/client/SessionLocationMiddleware`,{error:[Wo,G,Uo]}){},cb=ab({locationMiddleware:ob,formLocationMiddleware:sb,sessionLocationMiddleware:sb});ia({},{make:()=>AC});var Q=e=>Tt(e)||he(e)||st.is(e)?new io({cause:e}):e,$=()=>e=>e,lb=()=>e=>e,ub=e=>()=>$()(e[`server.info`]({}).pipe(M(Q))),db=e=>()=>$()(e[`server.pair`]({}).pipe(M(Q))),fb=e=>t=>$()(e[`server.connect`]({params:{code:t.code}}).pipe(M(Q))),pb=e=>({info:ub(e),pair:db(e),connect:fb(e)}),mb=e=>t=>$()(e[`location.get`]({query:{location:t?.location}}).pipe(M(Q))),hb=e=>()=>$()(e[`location.reload`]({}).pipe(M(Q))),gb=e=>({get:mb(e),reload:hb(e)}),_b=e=>t=>$()(e[`agent.list`]({query:{location:t?.location}}).pipe(M(Q))),vb=e=>t=>$()(e[`agent.get`]({params:{agentID:t.agentID},query:{location:t.location}}).pipe(M(Q))),yb=e=>({list:_b(e),get:vb(e)}),bb=e=>t=>$()(e[`plugin.list`]({query:{location:t?.location}}).pipe(M(Q))),xb=e=>t=>$()(e[`plugin.gui`]({query:{location:t.location,id:t.id}}).pipe(M(Q))),Sb=e=>t=>$()(e[`plugin.check`]({query:{location:t?.location},payload:{target:t?.target}}).pipe(M(Q))),Cb=e=>t=>$()(e[`plugin.update`]({query:{location:t.location},payload:{targets:t.targets}}).pipe(M(Q))),wb=e=>({list:bb(e),gui:xb(e),check:Sb(e),update:Cb(e)}),Tb=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(M(Q))),Eb=e=>t=>$()(e[`session.stats`]({query:{from:t?.from,to:t?.to,project:t?.project,timezone:t?.timezone,tools:t?.tools}}).pipe(M(Q),E(e=>e.data))),Db=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(M(Q),E(e=>e.data))),Ob=e=>t=>$()(e[`session.import`]({payload:{info:t.info,messages:t.messages,location:t.location}}).pipe(M(Q),E(e=>e.data))),kb=e=>t=>$()(e[`session.export`]({params:{sessionID:t.sessionID},query:{sanitize:t.sanitize}}).pipe(M(Q),E(e=>e.data))),Ab=e=>()=>$()(e[`session.active`]({}).pipe(M(Q),E(e=>e.data))),jb=e=>t=>$()(e[`session.get`]({params:{sessionID:t.sessionID}}).pipe(M(Q),E(e=>e.data))),Mb=e=>t=>$()(e[`session.remove`]({params:{sessionID:t.sessionID}}).pipe(M(Q))),Nb=e=>t=>$()(e[`session.fork`]({params:{sessionID:t.sessionID},payload:{before:t.before}}).pipe(M(Q),E(e=>e.data))),Pb=e=>t=>$()(e[`session.switchAgent`]({params:{sessionID:t.sessionID},payload:{agent:t.agent}}).pipe(M(Q))),Fb=e=>t=>$()(e[`session.switchModel`]({params:{sessionID:t.sessionID},payload:{model:t.model}}).pipe(M(Q))),Ib=e=>t=>$()(e[`session.update`]({params:{sessionID:t.sessionID},payload:{title:t.title,metadata:t.metadata,permissions:t.permissions,archived:t.archived}}).pipe(M(Q))),Lb=e=>t=>$()(e[`session.move`]({params:{sessionID:t.sessionID},payload:{directory:t.directory,delivery:t.delivery}}).pipe(M(Q))),Rb=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(M(Q),E(e=>e.data))),zb=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(M(Q))),Bb=e=>t=>$()(e[`session.skill`]({params:{sessionID:t.sessionID},payload:{id:t.id,resume:t.resume}}).pipe(M(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(M(Q),E(e=>e.data))),Hb=e=>t=>$()(e[`session.shell`]({params:{sessionID:t.sessionID},payload:{id:t.id,command:t.command}}).pipe(M(Q))),Ub=e=>t=>$()(e[`session.compact`]({params:{sessionID:t.sessionID},payload:{id:t.id,delivery:t.delivery}}).pipe(M(Q),E(e=>e.data))),Wb=e=>t=>$()(e[`session.wait`]({params:{sessionID:t.sessionID}}).pipe(M(Q))),Gb=e=>t=>$()(e[`session.revert.stage`]({params:{sessionID:t.sessionID},payload:{messageID:t.messageID,files:t.files}}).pipe(M(Q),E(e=>e.data))),Kb=e=>t=>$()(e[`session.revert.clear`]({params:{sessionID:t.sessionID}}).pipe(M(Q))),qb=e=>t=>$()(e[`session.revert.commit`]({params:{sessionID:t.sessionID}}).pipe(M(Q))),Jb=e=>t=>$()(e[`session.context`]({params:{sessionID:t.sessionID}}).pipe(M(Q),E(e=>e.data))),Yb=e=>t=>$()(e[`session.diff`]({params:{sessionID:t.sessionID},query:{from:t.from,to:t.to,context:t.context}}).pipe(M(Q),E(e=>e.data))),Xb=e=>t=>$()(e[`session.inbox.list`]({params:{sessionID:t.sessionID}}).pipe(M(Q),E(e=>e.data))),Zb=e=>t=>$()(e[`session.inbox.cancel`]({params:{sessionID:t.sessionID,inboxID:t.inboxID}}).pipe(M(Q))),Qb=e=>t=>$()(e[`session.inbox.update`]({params:{sessionID:t.sessionID,inboxID:t.inboxID},payload:{delivery:t.delivery}}).pipe(M(Q))),$b=e=>t=>$()(e[`session.instructions.entry.list`]({params:{sessionID:t.sessionID}}).pipe(M(Q),E(e=>e.data))),ex=e=>t=>$()(e[`session.instructions.entry.put`]({params:{sessionID:t.sessionID,key:t.key},payload:{value:t.value}}).pipe(M(Q))),tx=e=>t=>$()(e[`session.instructions.entry.remove`]({params:{sessionID:t.sessionID,key:t.key}}).pipe(M(Q))),nx=e=>t=>$()(e[`session.generate`]({params:{sessionID:t.sessionID},payload:{prompt:t.prompt}}).pipe(M(Q),E(e=>e.data))),rx=e=>t=>lb()(r(e[`session.log`]({params:{sessionID:t.sessionID},query:{after:t.after,follow:t.follow}}).pipe(M(Q),E(e=>e.pipe(me(Q)))))),ix=e=>t=>$()(e[`session.interrupt`]({params:{sessionID:t.sessionID},query:{resume:t.resume}}).pipe(M(Q))),ax=e=>t=>$()(e[`session.background`]({params:{sessionID:t.sessionID}}).pipe(M(Q))),ox=e=>t=>$()(e[`session.message`]({params:{sessionID:t.sessionID,messageID:t.messageID}}).pipe(M(Q),E(e=>e.data))),sx=e=>t=>$()(e[`session.form.list`]({params:{sessionID:t.sessionID}}).pipe(M(Q),E(e=>e.data))),cx=e=>t=>$()(e[`session.form.create`]({params:{sessionID:t.sessionID},payload:{id:t.id,title:t.title,metadata:t.metadata,fields:t.fields}}).pipe(M(Q),E(e=>e.data))),lx=e=>t=>$()(e[`session.form.get`]({params:{sessionID:t.sessionID,formID:t.formID}}).pipe(M(Q),E(e=>e.data))),ux=e=>t=>$()(e[`session.form.reply`]({params:{sessionID:t.sessionID,formID:t.formID},payload:{answer:t.answer}}).pipe(M(Q))),dx=e=>t=>$()(e[`session.form.cancel`]({params:{sessionID:t.sessionID,formID:t.formID},query:{message:t.message}}).pipe(M(Q))),fx=e=>t=>$()(e[`session.environment`]({params:{sessionID:t.sessionID},payload:{variables:t.variables}}).pipe(M(Q))),px=e=>t=>$()(e[`session.view`]({params:{sessionID:t.sessionID},payload:{idle:t.idle}}).pipe(M(Q))),mx=e=>({list:Tb(e),stats:Eb(e),create:Db(e),import:Ob(e),export:kb(e),active:Ab(e),get:jb(e),remove:Mb(e),fork:Nb(e),switchAgent:Pb(e),switchModel:Fb(e),update:Ib(e),move:Lb(e),prompt:Rb(e),command:zb(e),skill:Bb(e),synthetic:Vb(e),shell:Hb(e),compact:Ub(e),wait:Wb(e),revert:{stage:Gb(e),clear:Kb(e),commit:qb(e)},context:Jb(e),diff:Yb(e),inbox:{list:Xb(e),cancel:Zb(e),update:Qb(e)},instructions:{entry:{list:$b(e),put:ex(e),remove:tx(e)}},generate:nx(e),log:rx(e),interrupt:ix(e),background:ax(e),message:{get:ox(e)},form:{list:sx(e),create:cx(e),get:lx(e),reply:ux(e),cancel:dx(e)},environment:fx(e),view:px(e)}),hx=e=>t=>$()(e[`session.messages`]({params:{sessionID:t.sessionID},query:{limit:t.limit,order:t.order,cursor:t.cursor,type:t.type}}).pipe(M(Q))),gx=e=>({list:hx(e)}),_x=e=>t=>$()(e[`model.list`]({query:{location:t?.location,types:t?.types}}).pipe(M(Q))),vx=e=>t=>$()(e[`model.default`]({query:{location:t?.location}}).pipe(M(Q))),yx=e=>({list:_x(e),default:vx(e)}),bx=e=>t=>$()(e[`generate.text`]({payload:{prompt:t.prompt,model:t.model}}).pipe(M(Q),E(e=>e.data))),xx=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(M(Q),E(e=>e.data))),Sx=e=>t=>$()(e[`generate.decisions`]({payload:{model:t.model,input:t.input,questions:t.questions}}).pipe(M(Q),E(e=>e.data))),Cx=e=>({text:bx(e),image:xx(e),decisions:Sx(e)}),wx=e=>()=>$()(e[`voice.models`]({}).pipe(M(Q),E(e=>e.data))),Tx=e=>t=>$()(e[`voice.session`]({payload:{model:t.model,session:t.session,transport:t.transport}}).pipe(M(Q),E(e=>e.data))),Ex=e=>({models:wx(e),session:Tx(e)}),Dx=e=>t=>$()(e[`provider.list`]({query:{location:t?.location}}).pipe(M(Q))),Ox=e=>t=>$()(e[`provider.get`]({params:{providerID:t.providerID},query:{location:t.location}}).pipe(M(Q))),kx=e=>({list:Dx(e),get:Ox(e)}),Ax=e=>t=>$()(e[`integration.list`]({query:{location:t?.location}}).pipe(M(Q))),jx=e=>t=>$()(e[`integration.get`]({params:{integrationID:t.integrationID},query:{location:t.location}}).pipe(M(Q))),Mx=e=>t=>$()(e[`integration.wellknown.add`]({query:{location:t.location},payload:{url:t.url}}).pipe(M(Q))),Nx=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(M(Q))),Px=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(M(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(M(Q))),Ix=e=>t=>$()(e[`integration.oauth.status`]({params:{integrationID:t.integrationID,attemptID:t.attemptID},query:{location:t.location}}).pipe(M(Q))),Lx=e=>t=>$()(e[`integration.oauth.complete`]({params:{integrationID:t.integrationID,attemptID:t.attemptID},query:{location:t.location},payload:{code:t.code}}).pipe(M(Q))),Rx=e=>t=>$()(e[`integration.oauth.cancel`]({params:{integrationID:t.integrationID,attemptID:t.attemptID},query:{location:t.location}}).pipe(M(Q))),zx=e=>t=>$()(e[`integration.command.connect`]({params:{integrationID:t.integrationID},query:{location:t.location},payload:{methodID:t.methodID,label:t.label}}).pipe(M(Q))),Bx=e=>t=>$()(e[`integration.command.status`]({params:{integrationID:t.integrationID,attemptID:t.attemptID},query:{location:t.location}}).pipe(M(Q))),Vx=e=>t=>$()(e[`integration.command.cancel`]({params:{integrationID:t.integrationID,attemptID:t.attemptID},query:{location:t.location}}).pipe(M(Q))),Hx=e=>({list:Ax(e),get:jx(e),wellknown:{add:Mx(e)},connect:{key:Nx(e),external:Px(e)},oauth:{connect:Fx(e),status:Ix(e),complete:Lx(e),cancel:Rx(e)},command:{connect:zx(e),status:Bx(e),cancel:Vx(e)}}),Ux=e=>t=>$()(e[`mcp.list`]({query:{location:t?.location}}).pipe(M(Q))),Wx=e=>t=>$()(e[`mcp.add`]({params:{server:t.server},query:{location:t.location},payload:{config:t.config}}).pipe(M(Q))),Gx=e=>t=>$()(e[`mcp.remove`]({params:{server:t.server},query:{location:t.location}}).pipe(M(Q))),Kx=e=>t=>$()(e[`mcp.connect`]({params:{server:t.server},query:{location:t.location}}).pipe(M(Q))),qx=e=>t=>$()(e[`mcp.disconnect`]({params:{server:t.server},query:{location:t.location}}).pipe(M(Q))),Jx=e=>t=>$()(e[`mcp.resource.catalog`]({query:{location:t?.location}}).pipe(M(Q))),Yx=e=>t=>$()(e[`mcp.clientToken`]({query:{location:t.location,name:t.name},headers:{"x-opencode-ticket":t[`x-opencode-ticket`]}}).pipe(M(Q))),Xx=e=>({list:Ux(e),add:Wx(e),remove:Gx(e),connect:Kx(e),disconnect:qx(e),resource:{catalog:Jx(e)},client:{token:Yx(e)}}),Zx=e=>()=>$()(e[`credential.list`]({}).pipe(M(Q),E(e=>e.data))),Qx=e=>t=>$()(e[`credential.create`]({payload:{id:t.id,integrationID:t.integrationID,label:t.label,value:t.value,activate:t.activate}}).pipe(M(Q),E(e=>e.data))),$x=e=>t=>$()(e[`credential.update`]({params:{credentialID:t.credentialID},payload:{label:t.label}}).pipe(M(Q))),eS=e=>t=>$()(e[`credential.activate`]({params:{credentialID:t.credentialID}}).pipe(M(Q))),tS=e=>t=>$()(e[`credential.remove`]({params:{credentialID:t.credentialID}}).pipe(M(Q))),nS=e=>({list:Zx(e),create:Qx(e),update:$x(e),activate:eS(e),remove:tS(e)}),rS=e=>t=>$()(e[`project.list`]({query:{archived:t?.archived}}).pipe(M(Q))),iS=e=>t=>$()(e[`project.update`]({params:{projectID:t.projectID},payload:{canonical:t.canonical,name:t.name,icon:t.icon,commands:t.commands}}).pipe(M(Q))),aS=e=>({list:rS(e),update:iS(e)}),oS=e=>t=>$()(e[`form.list`]({query:{location:t?.location}}).pipe(M(Q))),sS=e=>({list:oS(e)}),cS=e=>t=>$()(e[`permission.request.list`]({query:{location:t?.location}}).pipe(M(Q))),lS=e=>t=>$()(e[`permission.saved.list`]({query:{projectID:t?.projectID}}).pipe(M(Q),E(e=>e.data))),uS=e=>t=>$()(e[`permission.saved.update`]({params:{id:t.id},payload:{action:t.action,resource:t.resource}}).pipe(M(Q),E(e=>e.data))),dS=e=>t=>$()(e[`permission.saved.remove`]({params:{id:t.id}}).pipe(M(Q))),fS=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(M(Q),E(e=>e.data))),pS=e=>t=>$()(e[`session.permission.list`]({params:{sessionID:t.sessionID}}).pipe(M(Q),E(e=>e.data))),mS=e=>t=>$()(e[`session.permission.get`]({params:{sessionID:t.sessionID,requestID:t.requestID}}).pipe(M(Q),E(e=>e.data))),hS=e=>t=>$()(e[`session.permission.reply`]({params:{sessionID:t.sessionID,requestID:t.requestID},payload:{decision:t.decision,message:t.message}}).pipe(M(Q))),gS=e=>({request:{list:cS(e)},saved:{list:lS(e),update:uS(e),remove:dS(e)},create:fS(e),list:pS(e),get:mS(e),reply:hS(e)}),_S=e=>t=>$()(e[`fs.list`]({query:{location:t?.location,path:t?.path}}).pipe(M(Q))),vS=e=>t=>$()(e[`fs.find`]({query:{location:t.location,query:t.query,type:t.type,limit:t.limit}}).pipe(M(Q))),yS=e=>t=>$()(e[`fs.watch`]({query:{location:t.location},payload:{path:t.path}}).pipe(M(Q))),bS=e=>t=>$()(e[`fs.unwatch`]({query:{location:t.location},payload:{path:t.path}}).pipe(M(Q))),xS=e=>({list:_S(e),find:vS(e),watch:yS(e),unwatch:bS(e)}),SS=e=>t=>$()(e[`command.list`]({query:{location:t?.location}}).pipe(M(Q))),CS=e=>({list:SS(e)}),wS=e=>t=>$()(e[`skill.list`]({query:{location:t?.location}}).pipe(M(Q))),TS=e=>({list:wS(e)}),ES=e=>t=>$()(e[`rpc.call`]({params:{rpcID:t.rpcID,method:t.method},query:{location:t.location},payload:{input:t.input}}).pipe(M(Q))),DS=e=>({call:ES(e)}),OS=e=>t=>lb()(r(e[`event.subscribe`]({query:{types:t?.types}}).pipe(M(Q),E(e=>e.pipe(me(Q)))))),kS=e=>({subscribe:OS(e)}),AS=e=>t=>$()(e[`pty.list`]({query:{location:t?.location}}).pipe(M(Q))),jS=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(M(Q))),MS=e=>t=>$()(e[`pty.get`]({params:{ptyID:t.ptyID},query:{location:t.location}}).pipe(M(Q))),NS=e=>t=>$()(e[`pty.update`]({params:{ptyID:t.ptyID},query:{location:t.location},payload:{title:t.title,size:t.size}}).pipe(M(Q))),PS=e=>t=>$()(e[`pty.remove`]({params:{ptyID:t.ptyID},query:{location:t.location}}).pipe(M(Q))),FS=e=>t=>$()(e[`pty.connectToken`]({params:{ptyID:t.ptyID},query:{location:t.location},headers:{"x-opencode-ticket":t[`x-opencode-ticket`]}}).pipe(M(Q))),IS=e=>({list:AS(e),create:jS(e),get:MS(e),update:NS(e),remove:PS(e),connect:{token:FS(e)}}),LS=e=>t=>$()(e[`persistentPty.read`]({params:{sessionID:t.sessionID},query:{lines:t.lines}}).pipe(M(Q),E(e=>e.data))),RS=e=>t=>$()(e[`persistentPty.list`]({params:{sessionID:t.sessionID}}).pipe(M(Q),E(e=>e.data))),zS=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(M(Q),E(e=>e.data))),BS=e=>()=>$()(e[`persistentPty.shutdown`]({}).pipe(M(Q))),VS=e=>()=>$()(e[`persistentPty.handoff`]({}).pipe(M(Q))),HS=e=>t=>$()(e[`persistentPty.get`]({params:{ptyID:t.ptyID}}).pipe(M(Q),E(e=>e.data))),US=e=>t=>$()(e[`persistentPty.update`]({params:{ptyID:t.ptyID},payload:{attachmentID:t.attachmentID,size:t.size}}).pipe(M(Q),E(e=>e.data))),WS=e=>t=>$()(e[`persistentPty.snapshot`]({params:{ptyID:t.ptyID}}).pipe(M(Q),E(e=>e.data))),GS=e=>t=>$()(e[`persistentPty.remove`]({params:{ptyID:t.ptyID}}).pipe(M(Q))),KS=e=>t=>$()(e[`persistentPty.connectToken`]({params:{ptyID:t.ptyID},headers:{"x-opencode-ticket":t[`x-opencode-ticket`]}}).pipe(M(Q),E(e=>e.data))),qS=e=>({persistentPty:{read:LS(e),list:RS(e),create:zS(e),shutdown:BS(e),handoff:VS(e),get:HS(e),update:US(e),snapshot:WS(e),remove:GS(e),connectToken:KS(e)}}),JS=e=>t=>$()(e[`shell.list`]({query:{location:t?.location}}).pipe(M(Q))),YS=e=>t=>$()(e[`shell.create`]({query:{location:t.location},payload:{command:t.command,cwd:t.cwd,timeout:t.timeout,metadata:t.metadata}}).pipe(M(Q))),XS=e=>t=>$()(e[`shell.get`]({params:{id:t.id},query:{location:t.location}}).pipe(M(Q))),ZS=e=>t=>$()(e[`shell.output`]({params:{id:t.id},query:{location:t.location,cursor:t.cursor,limit:t.limit}}).pipe(M(Q))),QS=e=>t=>$()(e[`shell.remove`]({params:{id:t.id},query:{location:t.location}}).pipe(M(Q))),$S=e=>({list:JS(e),create:YS(e),get:XS(e),output:ZS(e),remove:QS(e)}),eC=e=>t=>$()(e[`reference.list`]({query:{location:t?.location}}).pipe(M(Q))),tC=e=>({list:eC(e)}),nC=e=>t=>$()(e[`worktree.list`]({query:{projectID:t.projectID}}).pipe(M(Q))),rC=e=>t=>$()(e[`worktree.create`]({payload:{projectID:t.projectID,from:t.from,branch:t.branch,directory:t.directory,name:t.name}}).pipe(M(Q))),iC=e=>t=>$()(e[`worktree.remove`]({payload:{projectID:t.projectID,directory:t.directory,force:t.force}}).pipe(M(Q))),aC=e=>t=>$()(e[`worktree.refresh`]({payload:{projectID:t.projectID}}).pipe(M(Q))),oC=e=>({list:nC(e),create:rC(e),remove:iC(e),refresh:aC(e)}),sC=e=>t=>$()(e[`vcs.init`]({query:{location:t?.location,provider:t?.provider}}).pipe(M(Q))),cC=e=>t=>$()(e[`vcs.get`]({query:{location:t?.location}}).pipe(M(Q))),lC=e=>t=>$()(e[`vcs.base`]({query:{location:t?.location}}).pipe(M(Q))),uC=e=>t=>$()(e[`vcs.status`]({query:{location:t?.location}}).pipe(M(Q))),dC=e=>t=>$()(e[`vcs.branch.list`]({query:{location:t?.location,search:t?.search,limit:t?.limit}}).pipe(M(Q))),fC=e=>t=>$()(e[`vcs.diff`]({query:{location:t.location,mode:t.mode,base:t.base,context:t.context,untracked:t.untracked}}).pipe(M(Q))),pC=e=>({init:sC(e),get:cC(e),base:lC(e),status:uC(e),branch:{list:dC(e)},diff:fC(e)}),mC=e=>t=>$()(e[`debug.heapDump`]({query:{directory:t?.directory}}).pipe(M(Q))),hC=e=>()=>$()(e[`debug.location`]({}).pipe(M(Q))),gC=e=>t=>$()(e[`debug.location.evict`]({query:{location:t?.location}}).pipe(M(Q))),_C=e=>({heapDump:mC(e),location:{list:hC(e),evict:gC(e)}}),vC=e=>()=>$()(e[`migration.v1.status`]({}).pipe(M(Q))),yC=e=>({v1:{status:vC(e)}}),bC=e=>t=>$()(e[`websearch.providers`]({query:{location:t?.location}}).pipe(M(Q))),xC=e=>t=>$()(e[`websearch.query`]({query:{location:t.location},payload:{query:t.query,providerID:t.providerID}}).pipe(M(Q))),SC=e=>({providers:bC(e),query:xC(e)}),CC=e=>t=>$()(e[`usage.limits`]({query:{location:t?.location}}).pipe(M(Q))),wC=e=>({limits:CC(e)}),TC=e=>t=>$()(e[`config.get`]({query:{location:t?.location}}).pipe(M(Q))),EC=e=>()=>$()(e[`config.shells`]({}).pipe(M(Q))),DC=e=>t=>$()(e[`config.update`]({payload:{shell:t.shell}}).pipe(M(Q))),OC=e=>({get:TC(e),shells:EC(e),update:DC(e)}),kC=e=>({server:pb(e[`server.server`]),location:gb(e[`server.location`]),agent:yb(e[`server.agent`]),plugin:wb(e[`server.plugin`]),session:mx(e[`server.session`]),message:gx(e[`server.message`]),model:yx(e[`server.model`]),generate:Cx(e[`server.generate`]),voice:Ex(e[`server.voice`]),provider:kx(e[`server.provider`]),integration:Hx(e[`server.integration`]),mcp:Xx(e[`server.mcp`]),credential:nS(e[`server.credential`]),project:aS(e[`server.project`]),form:sS(e[`server.form`]),permission:gS(e[`server.permission`]),file:xS(e[`server.fs`]),command:CS(e[`server.command`]),skill:TS(e[`server.skill`]),rpc:DS(e[`server.rpc`]),event:kS(e[`server.event`]),pty:IS(e[`server.pty`]),experimental:qS(e[`server.experimental`]),shell:$S(e[`server.shell`]),reference:tC(e[`server.reference`]),worktree:oC(e[`server.worktree`]),vcs:pC(e[`server.vcs`]),debug:_C(e[`server.debug`]),migration:yC(e[`server.migration`]),websearch:SC(e[`server.websearch`]),usage:wC(e[`server.usage`]),config:OC(e[`server.config`])}),AC=e=>lt(cb,e).pipe(E(kC)),jC={};ia(jC,{RpcRuntime:()=>jC,event:()=>PC,eventType:()=>FC,read:()=>MC,readError:()=>NC});function MC(e,t){return u(e)?We(e)(t):ht(t)}function NC(e,t){return!(t instanceof Go)&&!(t instanceof Ko)?nt(t):!e.errors||!Object.hasOwn(e.errors,t.type)?nt(t.data===void 0?{type:t.type,message:t.message}:{type:t.type,message:t.message,data:t.data}):MC(e.errors[t.type],t.data).pipe(xt(e=>vt(e)),Fe(e=>nt(e===void 0?{type:t.type,message:t.message}:{type:t.type,message:t.message,data:e})))}var PC=pt(`Client.Rpc.event`)(function*(e,t,n,r){let i=yield*MC(n.schema,r.data);return{...r,type:FC(e,t),data:i}});function FC(e,t){return`rpc.${e.id}.${t}`}var IC={};ia(IC,{RpcClientRuntime:()=>IC,aborted:()=>RC,make:()=>LC});function LC(e,t){return r=>{let i=Object.fromEntries(Object.entries(r.methods).map(([t,i])=>[t,(a,o)=>{let s=bt(function*(){let n=yield*e({rpcID:r.id,method:t,input:a,location:o?.location},o);return yield*MC(i.output,n.output)}).pipe(xt(e=>NC(i,e))),c=o?.signal;return c?$e(()=>c.aborted?Ve:Je(s,n(RC(c),Ve))):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=>PC(r,e,i,t)))}}})}}function RC(e){return Ge(t=>{if(e.aborted)return t(Ne);let n=()=>t(Ne);return e.addEventListener(`abort`,n,{once:!0}),Xe(()=>e.removeEventListener(`abort`,n))})}var zC={};ia(zC,{OpenCode:()=>zC,make:()=>VC});var BC=Re(`@opencode/client/effect/rpc/headers`,{defaultValue:()=>{}}),VC=pt(`OpenCode.make`)(function*(e){let t=yield*Qe,n=yield*AC(e).pipe(Ue(Qe,Ye(t,e=>E(BC,t=>t?Me(e,new Headers(t)):e)))),r=yield*ut(),i=n.event.subscribe();class a{cause;constructor(e){this.cause=e}}let o=oa(e=>it(i.pipe(d(RC(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:Et(new io({cause:e})))));return{...n,event:{...n.event,subscribe:c},rpc:Object.assign(LC((e,t)=>n.rpc.call(e).pipe(Ue(BC,t?.headers)),c),n.rpc)}}),HC=e({Answer:()=>KC,Prompt:()=>GC,Question:()=>HC}),UC=x({label:y.annotate({description:`Display text (1-5 words, concise)`}),description:y.annotate({description:`Explanation of choice`})}),WC={question:y.annotate({description:`Complete question`}),header:y.annotate({description:`Very short label (max 30 chars)`}),options:h(UC).annotate({description:`Available choices`}),multiple:g.pipe(B).annotate({description:`Allow selecting multiple choices`})},GC=x(WC).annotate({identifier:`Question.Prompt`}),KC=h(y).annotate({identifier:`Question.Answer`}),qC=e({AbsolutePath:()=>oo,Agent:()=>Ou,ClientError:()=>io,Command:()=>lh,Config:()=>Bg,Credential:()=>Es,Event:()=>wo,EventLog:()=>Mm,FileSystem:()=>Ym,Form:()=>Vs,Integration:()=>fc,Location:()=>yo,Model:()=>tl,OpenCode:()=>zC,Permission:()=>gu,PermissionSaved:()=>Gm,Project:()=>Fu,Prompt:()=>El,PromptInput:()=>um,Provider:()=>Lc,Pty:()=>au,Question:()=>HC,Reference:()=>Fv,RelativePath:()=>ao,Session:()=>pp,SessionInbox:()=>cf,SessionMessage:()=>fd,Skill:()=>No,Vcs:()=>By,WebSearch:()=>Tg,Worktree:()=>Jg}),JC=20;function YC(e){return JSON.stringify([e.directory,e.workspaceID])}function XC(e){return{directory:e.directory}}function ZC(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 QC(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 $C(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:QC(e.state.content)}}:e)}:e}function ew(e,t){if(!(e!==`global`||!t))return{headers:{"x-opencode-directory":encodeURIComponent(t.directory)}}}function tw(){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 nw=200;function rw(e){let t=e.api,n=!1;sr(()=>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;sr(()=>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]=Hi({session:{info:{},family:{},active:{},message:{},messageCursor:{},messageLoading:{},pending:{},permission:{},form:{}},project:{info:{},permission:{}},location:{}}),[c,l]=qn({directory:e.directory}),u=Qn(()=>Object.values(o.session.info).toSorted((e,t)=>t.time.updated-e.time.updated)),d=new Map,f=t=>e.omitToolFileData?$C(t):t,p=tw(),ee,te=new Map;function ne(e,t){ee?.set(e,t),s(`session`,`active`,e,t)}function m(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 re(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 ie(e,t,n){let r=o.session.form[e];if(!r)return!1;let i=n&&YC(n),a=r.filter(n=>n.id===t?e!==`global`||!i?!1:!n.location||YC(n.location)!==i:!0);return a.length!==r.length&&(s(`session`,`form`,e,a),!0)}function ae(e,t,n){return n.catch(t=>{if(!ja(t)&&!Na(t)||t.id!==e.formID)throw t}).then(()=>{ie(e.sessionID,e.formID,t)&&(y.session.form.invalidate(e.sessionID,t),y.session.form.sync(e.sessionID,t).catch(()=>{}))})}function oe(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 se=new Set,ce=new Set,le=new Map,ue=new Map,de=new Map,fe=new Map;sr(()=>fe.clear());function h(e,t,n){e.set(t,n);let r=()=>{e.get(t)===n&&e.delete(t)};n.then(r,r)}function pe(e,t,n){let r=le.get(e),i=ue.get(e),a=Promise.resolve().then(()=>Promise.all([n,r,i])).then(t);return h(ue,e,a.catch(()=>{})),a}function me(e){rr(()=>{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`&&he(e)})}function he(e){(e.type===`user`||e.type===`synthetic`)&&_.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 _.append(t,n,r);t[i]=r})}function g(e,t){rr(()=>{m(e,t),d.get(e)?.has(t)&&_.update(e,(e,n)=>{let r=n.get(t);r!==void 0&&(e.splice(r,1),n.delete(t),_.reindex(e,n,r))})})}let _={update(e,t){s(`session`,`message`,ea(n=>{t(n[e]??=[],ge(e))}))},append(e,t,n){t.has(n.id)||(t.set(n.id,e.length),e.push(n))},insert(e,t){_.update(e,(e,n)=>_.append(e,n,t))},editAssistant(e,t,n){d.get(e)?.has(t)&&_.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){_.editAssistant(e,t,e=>{let t=e.content.findLast(e=>e.type===`tool`&&e.id===n);t&&r(t)})},editText(e,t,n){_.editAssistant(e,t,e=>{let t=e.content.findLast(e=>e.type===`text`);t&&n(t)})},editReasoning(e,t,n){_.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 ge(e){let t=d.get(e);if(t)return t;let n=new Map;return d.set(e,n),n}async function _e(e){let n=await t().session.list(e);return n.data.length<nw||!n.cursor.next?n.data:[...n.data,...await _e({cursor:n.cursor.next,limit:nw})]}function ve(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 ye(e){if(!o.session.info[e])return;let t=ve(e);s(`session`,`family`,ea(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 be(e){if(ce.has(e))return;p.invalidate(`session.pending:${e}`),p.invalidate(`session.message:${e}`),de.delete(e);let t=o.session.pending[e]?.filter(e=>se.has(e.id))??[],n=o.session.message[e]?.filter(e=>se.has(e.id))??[];d.delete(e),n.length&&d.set(e,new Map(n.map((e,t)=>[e.id,t]))),s(`session`,ea(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 xe(e){ee?.set(e,void 0),o.session.pending[e]?.forEach(e=>se.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`,ea(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 Se(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`,Zi(Object.fromEntries(n))),n.forEach((e,t)=>{e===`running`&&!o.session.info[t]&&r(()=>y.session.sync(t))})}).catch(()=>{ee===e&&(ee=void 0)})),r(()=>t().location.get({location:XC(c())}).then(e=>{let t=YC(e);s(`location`,t,{info:e})})),r(()=>y.location.vcs.sync()),r(()=>y.project.sync());return}case`project.updated`:s(`project`,`info`,n.data.id,Zi(n.data));return;case`session.created`:ce.delete(n.data.sessionID),y.session.invalidate(n.data.sessionID),r(()=>y.session.sync(n.data.sessionID)),p.complete(`session.pending:${n.data.sessionID}`),p.complete(`session.message:${n.data.sessionID}`);return;case`session.deleted`:xe(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),_.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;_.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=>{_.update(n.data.sessionID,(t,n)=>{let r=n.get(e.id);if(r===void 0)return _.append(t,n,e);t[r]=e})}));return}case`session.renamed`:r(()=>{let e=p.pending(`session.family:${n.data.sessionID}`)?y.session.sync(n.data.sessionID,{children:!0}):Promise.resolve();return Promise.all([y.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),_.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){y.session.invalidate(e),r(()=>y.session.sync(e));continue}let a=o_({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=y.session.input.has(n.data.sessionID,n.data.inboxID);m(n.data.sessionID,n.data.inboxID),_.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),_.reindex(t,r,i))}),fe.get(n.data.sessionID)?.observed.add(n.data.inboxID);return}case`session.inbox.delivery.changed`:oe(n.data.sessionID,n.data.inboxID,n.data.delivery);return;case`session.inbox.cancelled`:g(n.data.sessionID,n.data.inboxID),fe.get(n.data.sessionID)?.observed.add(n.data.inboxID);return;case`session.inbox.enqueued`:{se.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),me(e),n.data.item.type===`compaction`){let e=fe.get(n.data.sessionID);e?.observed.add(n.data.inboxID),e&&e.id!==n.data.inboxID&&se.delete(e.id)&&m(n.data.sessionID,e.id)}return}case`session.instructions.updated`:let i=n.data.text;if(i===void 0)return;_.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`:_.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`:_.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;_.update(n.data.sessionID,e=>{let t=_.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`:_.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=_.activeAssistant(e);a&&(a.retry=void 0,a.time.completed=n.created),_.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`:_.editAssistant(n.data.sessionID,n.data.assistantMessageID,e=>{e.time.streamed=n.created});return;case`session.step.ended`:_.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`)&&we(n.location),_.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`:_.editAssistant(n.data.sessionID,n.data.assistantMessageID,e=>{e.content.push({type:`text`,text:``})});return;case`session.text.delta`:_.editText(n.data.sessionID,n.data.assistantMessageID,e=>{e.text+=n.data.delta});return;case`session.text.ended`:_.editText(n.data.sessionID,n.data.assistantMessageID,e=>{e.text=n.data.text});return;case`session.tool.input.started`:_.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`:_.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`:_.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`:_.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`:_.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`:_.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?QC(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`:_.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?QC(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`:_.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`:_.editReasoning(n.data.sessionID,n.data.assistantMessageID,e=>{e.text+=n.data.delta});return;case`session.reasoning.ended`:_.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`:_.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`:ne(n.data.sessionID,`running`);return;case`session.compaction.started`:n.data.inputID&&m(n.data.sessionID,n.data.inputID),_.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&&fe.get(n.data.sessionID)?.observed.add(n.data.inputID);return;case`session.execution.succeeded`:case`session.execution.failed`:case`session.execution.interrupted`:if(ne(n.data.sessionID,`idle`),_.update(n.data.sessionID,e=>{let t=_.activeAssistant(e);t&&(t.retry=void 0)}),n.type===`session.execution.interrupted`&&n.data.reason===`shutdown`||(_.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(()=>y.session.message.sync(n.data.sessionID))),!o.session.info[n.data.sessionID]&&!p.has(`session:${n.data.sessionID}`)))return;y.session.invalidate(n.data.sessionID),r(()=>y.session.sync(n.data.sessionID));return;case`session.viewed`:if(!o.session.info[n.data.sessionID]&&!p.has(`session:${n.data.sessionID}`))return;y.session.invalidate(n.data.sessionID),r(()=>y.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)),_.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;_.update(n.data.sessionID,e=>{let t=_.compaction(e);t?.status===`running`&&(t.summary+=n.data.text)});return;case`session.compaction.ended`:_.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}_.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&&m(n.data.sessionID,n.data.inputID),_.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}_.append(e,t,a)}),n.data.inputID&&fe.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`:re(n.data.sessionID,n.data.requestID);return;case`form.replied`:case`form.cancelled`:ie(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(we(i),n.type===`credential.updated`){v(`integration`,y.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=Ce(`integration`,i)||Ce(`model`,i)||Ce(`provider`,i);y.location.model.invalidate(i),y.location.provider.invalidate(i),a&&r(()=>Promise.all([y.location.model.sync(i),y.location.provider.sync(i)]))});return}if(!n.location)return;let i=n.location;switch(n.type){case`provider.updated`:v(`provider`,y.location.provider,i);break;case`model.updated`:v(`model`,y.location.model,i);break;case`agent.updated`:v(`agent`,y.location.agent,i);break;case`command.updated`:v(`command`,y.location.command,i);break;case`skill.updated`:v(`skill`,y.location.skill,i);break;case`vcs.branch.updated`:v(`vcs`,y.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`,YC(i),e=>({shell:{...e?.shell,[n.data.info.id]:{...n.data.info,location:i}}}));break;case`shell.exited`:case`shell.deleted`:if(!o.location[YC(i)]?.shell?.[n.data.id])break;s(`location`,YC(i),e=>({shell:Object.fromEntries(Object.entries(e?.shell??{}).filter(([e])=>e!==n.data.id))}));break;case`reference.updated`:v(`reference`,y.location.reference,i);break;case`integration.updated`:{we(i);let e=Ce(`integration`,i)||Ce(`model`,i)||Ce(`provider`,i);y.location.integration.invalidate(i),y.location.model.invalidate(i),y.location.provider.invalidate(i),e&&r(()=>Promise.all([y.location.integration.sync(i),y.location.model.sync(i),y.location.provider.sync(i)]));break}case`config.updated`:v(`config`,y.location.config,i),Ce(`websearch`,i)&&r(()=>y.location.websearch.refresh(i));break;case`websearch.updated`:Ce(`websearch`,i)&&r(()=>y.location.websearch.refresh(i));break;case`mcp.status.changed`:{let e=Ce(`mcpServer`,i);y.location.mcp.server.invalidate(i),e&&a(`mcp.status:${YC(i)}`,()=>y.location.mcp.server.sync(i));break}case`mcp.resources.changed`:v(`mcpResource`,y.location.mcp.resource,i)}}function Ce(e,t){let n=YC(t??c());return o.location[n]?.[e]!==void 0||p.has(`location.${e}:${n}`)}function v(e,t,n){let i=Ce(e,n);t.invalidate(n),i&&r(()=>t.sync(n))}function we(e){let t=o.location[YC(e)]?.usageLimits!==void 0||p.has(`location.usageLimits:${YC(e)}`);De.invalidate(e),t&&r(()=>De.sync(e))}function Te(e,t,n){let r=(t,n)=>s(`location`,t,{[e]:n});return{list:t=>o.location[YC(t??c())]?.[e],sync:i=>{let a=i??c(),o=YC(a);return p.run(`location.${e}:${o}`,async()=>{let e=await t(XC(a)),i=YC(e.location);r(i,e.data),n?.alias&&i!==o&&r(o,e.data)})},invalidate:t=>p.invalidate(`location.${e}:${YC(t??c())}`)}}let Ee=Te(`vcs`,e=>t().vcs.get({location:e})),De=Te(`usageLimits`,e=>t().usage.limits({location:e})),Oe=Te(`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}]))}}),y={on:e.event.on,listen:e.event.listen,session:{list(){return u()},get(e){return o.session.info[e]},creating(e){return le.has(e)},remember(e){rr(()=>{s(`session`,`info`,e.id,Zi(e)),p.complete(`session:${e.id}`),ye(e.id)})},setStatus(e,t){ne(e,t)},root(e){return ve(e)},family(e){return o.session.family[ve(e)]??[]},evict(e){let t=ve(e);rr(()=>{for(let n of new Set([t,e,...o.session.family[t]??[]]))be(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=>se.delete(e.id)),a.some(e=>e.type===`compaction`)&&o.session.pending[e]?.filter(e=>e.type===`compaction`).forEach(e=>se.delete(e.id));let c=(o.session.pending[e]??[]).filter(e=>se.has(e.id)),l=c.length===0?a:[...a,...c];rr(()=>{s(`session`,`pending`,e,Zi(l)),l.forEach(he)})}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??hu.create(),a=r.location??c(),s=!o.session.info[i];if(s){let e=Date.now();ce.add(i),y.session.remember({id:i,projectID:n??o.location[YC(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=>(ce.delete(i),y.session.remember(e),e)).catch(e=>{throw s&&ce.delete(i)&&xe(i),e});return s&&h(le,i,l),{id:i,request:l}},compact(e){let n=fe.get(e.sessionID);if(n)return n.request;let r=K.create();o.session.pending[e.sessionID]?.some(e=>e.type===`compaction`)||(se.add(r),me({id:r,sessionID:e.sessionID,time:{created:Date.now()},type:`compaction`,delivery:`steer`,payload:{}}));let i=new Set,a=pe(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=>(rr(()=>{se.delete(r),t.id!==r&&m(e.sessionID,r),!i.has(t.id)&&!d.get(e.sessionID)?.has(t.id)&&me(t)}),t)).catch(t=>{throw se.delete(r)&&m(e.sessionID,r),t}).finally(()=>{fe.get(e.sessionID)?.request===a&&fe.delete(e.sessionID)});return fe.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=ZC(i.files),t={text:i.text,agents:i.agents?.map(e=>({...e})),metadata:i.metadata};e&&(t.files=e),se.add(a),me({id:a,sessionID:i.sessionID,time:{created:Date.now()},type:`user`,delivery:i.delivery??`steer`,payload:t})}return pe(i.sessionID,async()=>(await r?.(),t().session.prompt({...i,id:a})),n).catch(e=>{throw s&&se.delete(a)&&g(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?_e({parentID:e,order:`desc`,limit:nw}):[]]),a=[r,...i];rr(()=>{s(`session`,`info`,ea(e=>{for(let t of a)e[t.id]=t}));for(let e of a)p.complete(`session:${e.id}`),ye(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?.()??JC,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)&&(se.has(e.id)||c.has(e.id))),u=l.length===0?i:[...i,...l];rr(()=>{d.set(n,new Map(u.map((e,t)=>[e.id,t]))),s(`session`,`message`,n,Zi(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(;de.has(e);){let t=await(()=>{let t=de.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:JC,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 rr(()=>{n?.beforePublish?.(),d.set(e,new Map(p.map((e,t)=>[e.id,t]))),s(`session`,`message`,e,Zi(p)),s(`session`,`messageCursor`,e,c)}),!0})().catch(e=>{if(!r?.aborted)throw e}).finally(()=>s(`session`,`messageLoading`,e,!1));h(de,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(!Ga(e))throw e}),re(e.sessionID,e.requestID)}},form:{list(e,t){let n=o.session.form[e];if(e!==`global`)return n;if(!t)return;let r=YC(t);return n?.filter(e=>e.location&&YC(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`?YC(n??c()):``}`;return p.run(r,async()=>{if(e===`global`){let r=await t().form.list({location:XC(n??c())}),i={directory:r.location.directory},a=YC(i);s(`session`,`form`,e,[...(o.session.form[e]??[]).filter(e=>e.location&&YC(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`?YC(t??c()):``}`)},reply(e,n){return ae(e,n,t().session.form.reply(e,ew(e.sessionID,n)))},cancel(e,n){return ae(e,n,t().session.form.cancel(e,ew(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`,Zi(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(Oe.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:Oe.sync,invalidate:Oe.invalidate},location:{info(e){return o.location[YC(e??c())]?.info},default(){return c()},syncInfo(e){let n=e??c();return p.run(`location:${YC(n)}`,async()=>{let r=await t().location.get({location:XC(n)}),i=YC(r);o.location[i]||s(`location`,i,{}),s(`location`,i,`info`,r),e||l({directory:r.directory})})},async sync(e){await y.location.syncInfo(e);let t=e??c();await Promise.all([y.location.vcs.sync(t),y.location.agent.sync(t),y.location.command.sync(t),y.location.integration.sync(t),y.location.mcp.server.sync(t),y.location.mcp.resource.sync(t),y.location.model.sync(t),y.location.provider.sync(t),y.location.reference.sync(t),y.location.skill.sync(t),y.shell.sync(t),y.session.form.sync(`global`,t)])},invalidate(e){let t=e??c();p.invalidate(`location:${YC(t)}`),y.location.vcs.invalidate(t),y.location.agent.invalidate(t),y.location.command.invalidate(t),y.location.config.invalidate(t),y.location.integration.invalidate(t),y.location.mcp.server.invalidate(t),y.location.mcp.resource.invalidate(t),y.location.model.invalidate(t),y.location.provider.invalidate(t),y.location.reference.invalidate(t),y.location.skill.invalidate(t),y.shell.invalidate(t),y.session.form.invalidate(`global`,t)},vcs:{info:Ee.list,sync:Ee.sync,invalidate:Ee.invalidate},usage:{limits:De.list,sync:De.sync,invalidate:De.invalidate},agent:Te(`agent`,e=>t().agent.list({location:e})),command:Te(`command`,e=>t().command.list({location:e})),config:Te(`config`,async e=>({location:{directory:e.directory},data:await t().config.get({location:e})})),integration:Te(`integration`,e=>t().integration.list({location:e})),mcp:{server:Te(`mcpServer`,e=>t().mcp.list({location:e})),resource:Te(`mcpResource`,async e=>{let n=await t().mcp.resource.catalog({location:e});return{location:n.location,data:n.data.resources}})},model:Te(`model`,e=>t().model.list({location:e}),{alias:!0}),provider:Te(`provider`,e=>t().provider.list({location:e}),{alias:!0}),reference:Te(`reference`,e=>t().reference.list({location:e})),websearch:{list(e){return o.location[YC(e??c())]?.websearch},async refresh(e){let n={location:XC(e??c())},r=await t().websearch.providers(n),i=YC(r.location);s(`location`,i,{websearch:r.data})}},skill:Te(`skill`,e=>t().skill.list({location:e}))}};return Xn(()=>{e.connection?.status()!==`connected`&&p.invalidate()}),sr(e.event.listen(({details:e})=>{Se(e)})),y}var iw=2e3,aw=1e3,ow=50,sw=45e3,cw=2e4;function lw(e,t){let n=new AbortController,r=[],i=t.idleTimeout??45e3,[a,o]=Hi({status:`connecting`,attempt:0}),s=e,c=[],l,u,d,f,p=!1,ee=0,te=0,ne=!1;function m(e,t,n){r.push({type:`client.connection`,created:Date.now(),data:{status:e,attempt:t,error:n}}),r.length>ow&&r.shift()}function re(e){c.push(e),!l&&(l=setTimeout(()=>{l=void 0;let e=c;c=[],rr(()=>e.forEach(t.onEvent))},t.flushInterval??10))}async function ie(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`)),iw);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{m(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),m(`connected`,n),r=Date.now(),f(),t.log?.info?.(`event stream connected`),re(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}),re(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 ae(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 ie(i.signal,r);if(n.signal.removeEventListener(`abort`,a),n.signal.aborted||!p||ee!==e)return;c.connectedAt!==void 0&&Date.now()-c.connectedAt>=aw&&(r=0),r+=1;let l=uw(c.error);if(m(`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:uw(e)})});if(n.signal.aborted||i.signal.aborted||!p||ee!==e)return;if(a&&(s=a,r===1))continue}if(ne){ne=!1;continue}await dw(aw,i.signal)}}function oe(){if(p)return f;p=!0,ne=!1;let e=++ee,t=f,n=(async()=>{t&&await t,await ae(e)})().finally(()=>{f===n&&(f=void 0)});return f=n,f}function se(){p&&(p=!1,ee+=1,u?.abort(),o({status:`connecting`,attempt:0,error:void 0}))}function ce(e){!p||a.status!==`connected`||(t.log?.info?.(`event stream resync`,{reason:e,idle:Date.now()-te}),ne=!0,d?.abort(Error(e)))}if(t.pageLifecycle){let e=()=>se(),t=()=>void oe(),n=()=>{document.visibilityState===`visible`&&(Date.now()-te<2e4||ce(`Page returned to the foreground after the event stream went quiet`))},r=()=>ce(`Network connection restored`);window.addEventListener(`pagehide`,e),window.addEventListener(`pageshow`,t),window.addEventListener(`online`,r),document.addEventListener(`visibilitychange`,n),sr(()=>{window.removeEventListener(`pagehide`,e),window.removeEventListener(`pageshow`,t),window.removeEventListener(`online`,r),document.removeEventListener(`visibilitychange`,n)})}return oe(),sr(()=>{se(),n.abort(),l&&clearTimeout(l),c=[]}),{status:()=>a.status,attempt:()=>a.attempt,error:()=>a.error,internal:{history:()=>r.slice(),resync:ce}}}function uw(e){if(e!==void 0)return e instanceof Error?e.message:String(e)}function dw(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 fw(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 pw(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 mw(e){let t,n=[],r=new Map;Xn(()=>{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=>ir(()=>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));ir(()=>u.forEach(t=>e.session.evict(t))),r=new Map([...l].map(([e,t])=>[e,`${t}:${c(e)}`]))})}function hw(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 gw=e({createClientConnection:()=>lw,createData:()=>rw,createPersistentPtyClient:()=>pw,createPtyClient:()=>fw,createSessionRetention:()=>mw,defaultIdleTimeout:()=>sw,foregroundIdleThreshold:()=>cw,lastAssistantWithUsage:()=>hw,locationKey:()=>YC,settleMs:()=>150});export{ar as A,Qt as B,Yn as C,lr as D,$r as E,oi as F,Ht as H,ir as I,yr as L,dr as M,P as N,ur as O,on as P,rn as R,Qn as S,qn as T,Zt as V,rr as _,Hi as a,vr as b,Ai as c,fi as d,hi as f,mi as g,xi as h,to as i,sr as j,ai as k,vi as l,Si as m,qC as n,Zi as o,pi as p,ro as r,Ci as s,gw as t,di as u,cr as v,Kn as w,Xn as x,ei as y,Xt as z};
|