@kortix/sdk 0.9.108 → 0.10.1

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.
Files changed (99) hide show
  1. package/README.md +6 -2
  2. package/dist/core/client/kortix.d.ts +11 -31
  3. package/dist/core/client/kortix.d.ts.map +1 -1
  4. package/dist/core/client/kortix.js +9 -30
  5. package/dist/core/client/kortix.js.map +1 -1
  6. package/dist/core/http/api/errors.d.ts.map +1 -1
  7. package/dist/core/http/api/errors.js +10 -1
  8. package/dist/core/http/api/errors.js.map +1 -1
  9. package/dist/core/http/api-client.d.ts.map +1 -1
  10. package/dist/core/http/api-client.js +91 -3
  11. package/dist/core/http/api-client.js.map +1 -1
  12. package/dist/core/rest/platform-client/github-app.d.ts +80 -0
  13. package/dist/core/rest/platform-client/github-app.d.ts.map +1 -0
  14. package/dist/core/rest/platform-client/github-app.js +81 -0
  15. package/dist/core/rest/platform-client/github-app.js.map +1 -0
  16. package/dist/core/rest/platform-client/index.d.ts +1 -0
  17. package/dist/core/rest/platform-client/index.d.ts.map +1 -1
  18. package/dist/core/rest/platform-client/index.js +1 -0
  19. package/dist/core/rest/platform-client/index.js.map +1 -1
  20. package/dist/core/rest/platform-client/instance-admin.d.ts +13 -6
  21. package/dist/core/rest/platform-client/instance-admin.d.ts.map +1 -1
  22. package/dist/core/rest/platform-client/instance-admin.js +12 -23
  23. package/dist/core/rest/platform-client/instance-admin.js.map +1 -1
  24. package/dist/core/rest/platform-client/lifecycle.d.ts +2 -3
  25. package/dist/core/rest/platform-client/lifecycle.d.ts.map +1 -1
  26. package/dist/core/rest/platform-client/lifecycle.js +8 -5
  27. package/dist/core/rest/platform-client/lifecycle.js.map +1 -1
  28. package/dist/core/rest/platform-client/types.d.ts +1 -1
  29. package/dist/core/rest/platform-client/types.d.ts.map +1 -1
  30. package/dist/core/rest/platform-client/updates.d.ts +2 -2
  31. package/dist/core/rest/projects-client/gateway.d.ts +55 -0
  32. package/dist/core/rest/projects-client/gateway.d.ts.map +1 -1
  33. package/dist/core/rest/projects-client/gateway.js +12 -0
  34. package/dist/core/rest/projects-client/gateway.js.map +1 -1
  35. package/dist/core/rest/projects-client/github.d.ts +13 -0
  36. package/dist/core/rest/projects-client/github.d.ts.map +1 -1
  37. package/dist/core/rest/projects-client/github.js +8 -0
  38. package/dist/core/rest/projects-client/github.js.map +1 -1
  39. package/dist/core/rest/projects-client/index.d.ts +0 -2
  40. package/dist/core/rest/projects-client/index.d.ts.map +1 -1
  41. package/dist/core/rest/projects-client/index.js +0 -2
  42. package/dist/core/rest/projects-client/index.js.map +1 -1
  43. package/dist/core/rest/projects-client/projects.d.ts +29 -10
  44. package/dist/core/rest/projects-client/projects.d.ts.map +1 -1
  45. package/dist/core/rest/projects-client/projects.js +30 -4
  46. package/dist/core/rest/projects-client/projects.js.map +1 -1
  47. package/dist/core/rest/projects-client/sandbox.d.ts +25 -0
  48. package/dist/core/rest/projects-client/sandbox.d.ts.map +1 -1
  49. package/dist/core/rest/projects-client/sandbox.js.map +1 -1
  50. package/dist/core/rest/projects-client/session-sandbox.d.ts +1 -1
  51. package/dist/core/rest/projects-client/session-sandbox.d.ts.map +1 -1
  52. package/dist/core/rest/projects-client/sessions.d.ts +2 -2
  53. package/dist/core/rest/projects-client/sessions.d.ts.map +1 -1
  54. package/dist/core/rest/projects-client/triggers.d.ts +15 -0
  55. package/dist/core/rest/projects-client/triggers.d.ts.map +1 -1
  56. package/dist/core/rest/projects-client/triggers.js.map +1 -1
  57. package/dist/core/session/server-store/url-helpers.d.ts +1 -1
  58. package/dist/core/session/server-store/url-helpers.js +1 -1
  59. package/dist/core/session/url.js +1 -1
  60. package/dist/core/session/url.js.map +1 -1
  61. package/dist/core/stream/event-stream.d.ts +1 -0
  62. package/dist/core/stream/event-stream.d.ts.map +1 -1
  63. package/dist/core/stream/event-stream.js +28 -0
  64. package/dist/core/stream/event-stream.js.map +1 -1
  65. package/dist/index.d.ts +1 -1
  66. package/dist/index.d.ts.map +1 -1
  67. package/dist/index.js.map +1 -1
  68. package/dist/kortix.esm.min.js +17 -17
  69. package/dist/kortix.global.js +17 -17
  70. package/dist/react/index.d.ts +1 -0
  71. package/dist/react/index.d.ts.map +1 -1
  72. package/dist/react/index.js +1 -0
  73. package/dist/react/index.js.map +1 -1
  74. package/dist/react/model-lookup.d.ts +3 -0
  75. package/dist/react/model-lookup.d.ts.map +1 -0
  76. package/dist/react/model-lookup.js +4 -0
  77. package/dist/react/model-lookup.js.map +1 -0
  78. package/dist/react/use-gateway-routing-policy.d.ts +8 -0
  79. package/dist/react/use-gateway-routing-policy.d.ts.map +1 -0
  80. package/dist/react/use-gateway-routing-policy.js +32 -0
  81. package/dist/react/use-gateway-routing-policy.js.map +1 -0
  82. package/dist/react/use-model-store.d.ts.map +1 -1
  83. package/dist/react/use-model-store.js +5 -3
  84. package/dist/react/use-model-store.js.map +1 -1
  85. package/dist/react/use-opencode-sessions/providers.js +2 -2
  86. package/dist/react/use-opencode-sessions/providers.js.map +1 -1
  87. package/dist/react/use-project-models.d.ts +4 -5
  88. package/dist/react/use-project-models.d.ts.map +1 -1
  89. package/dist/react/use-project-models.js +7 -8
  90. package/dist/react/use-project-models.js.map +1 -1
  91. package/package.json +2 -2
  92. package/dist/core/rest/projects-client/apps.d.ts +0 -98
  93. package/dist/core/rest/projects-client/apps.d.ts.map +0 -1
  94. package/dist/core/rest/projects-client/apps.js +0 -29
  95. package/dist/core/rest/projects-client/apps.js.map +0 -1
  96. package/dist/core/rest/projects-client/marketplace.d.ts +0 -80
  97. package/dist/core/rest/projects-client/marketplace.d.ts.map +0 -1
  98. package/dist/core/rest/projects-client/marketplace.js +0 -52
  99. package/dist/core/rest/projects-client/marketplace.js.map +0 -1
@@ -1,11 +1,11 @@
1
- "use strict";var Kortix=(()=>{var Dt=Object.defineProperty;var Ml=Object.getOwnPropertyDescriptor;var Ul=Object.getOwnPropertyNames;var Ol=Object.prototype.hasOwnProperty;var Ll=(e,t)=>{for(var r in t)Dt(e,r,{get:t[r],enumerable:!0})},Fl=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of Ul(t))!Ol.call(e,s)&&s!==r&&Dt(e,s,{get:()=>t[s],enumerable:!(n=Ml(t,s))||n.enumerable});return e};var Bl=e=>Fl(Dt({},"__esModule",{value:!0}),e);var Uf={};Ll(Uf,{ACTIVE_INSTANCE_COOKIE:()=>Ne,ApiError:()=>v,AuthError:()=>de,BillingError:()=>te,COST_MARKUP:()=>ec,DEFAULT_TRANSCRIPT_OPTIONS:()=>Xa,DESTRUCTIVE_PHASES:()=>El,INSTANCE_SCOPED_ROUTES:()=>_l,PublicSessionShareError:()=>kt,RequestTooLargeError:()=>ge,RuntimeNotReadyError:()=>ot,SANDBOX_PORTS:()=>V,SessionNotReadyError:()=>Fe,SessionStartError:()=>xt,__getConfigResolver:()=>Nl,__setConfigResolver:()=>Kl,acceptAccountInvite:()=>Dn,acceptInvite:()=>pf,actReviewItem:()=>ca,activateConnectionProfile:()=>Ds,addMarketplaceSource:()=>Ha,addSandboxMember:()=>Ym,allDescendantIds:()=>pl,appendPreviewToken:()=>Mf,approveProjectAccessRequest:()=>ss,approveTask:()=>ku,archiveProject:()=>ht,assignTicket:()=>Tu,attachGroupToProject:()=>ms,authenticatedFetch:()=>C,backendApi:()=>o,buildInstancePath:()=>Sl,buildPreviewAuthEndpoint:()=>qf,buildSandboxTemplate:()=>oi,buildWebProxyUrl:()=>Sd,bulkActReviewItems:()=>la,cancelAccountInvite:()=>En,cancelSandbox:()=>Jm,cancelSandboxUpdate:()=>Rf,cancelScheduledChange:()=>mo,cancelSubscription:()=>uo,childMapByParent:()=>Kg,claimComputer:()=>jf,classifyPart:()=>Qa,classifyTurn:()=>sl,clearModelDefault:()=>Xi,clearSessionFresh:()=>Wp,closeChangeRequest:()=>Si,closeMilestone:()=>rp,collectTurnParts:()=>Lg,commentTicket:()=>ju,commitSessionChanges:()=>Ci,computeStatusFromPart:()=>Za,configureAutoTopup:()=>bo,configureKortix:()=>Xe,confirmCheckoutSession:()=>co,connectEmail:()=>Io,connectSlack:()=>ko,createAccount:()=>vn,createAccountAuditWebhook:()=>qa,createAccountToken:()=>ma,createBackup:()=>mf,createCheckoutSession:()=>ao,createConnector:()=>Hs,createGatewayKey:()=>zo,createInstance:()=>Cf,createKortix:()=>el,createKortixPty:()=>un,createMilestone:()=>ep,createPortalSession:()=>lo,createProject:()=>Hn,createProjectAgent:()=>Fu,createProjectApp:()=>Yo,createProjectCliToken:()=>ha,createProjectRepo:()=>Wn,createProjectResourceGrant:()=>bs,createProjectSession:()=>xe,createProjectTrigger:()=>Gi,createSandbox:()=>Gm,createSandboxShare:()=>pa,createSandboxTemplate:()=>ni,createSessionPublicShare:()=>qi,createTask:()=>hu,createTicket:()=>Ru,declineAccountInvite:()=>Mn,declineInvite:()=>df,deleteBackup:()=>yf,deleteConnector:()=>Ws,deleteCredential:()=>lp,deleteEnv:()=>cn,deleteGatewayBudget:()=>Wo,deleteGitHubInstallation:()=>rs,deleteInstance:()=>Tf,deleteKortixProject:()=>Ju,deleteMilestone:()=>sp,deletePersonalProjectSecret:()=>js,deleteProjectAgent:()=>Gu,deleteProjectApp:()=>ea,deleteProjectResourceGrant:()=>xs,deleteProjectSecret:()=>Ts,deleteProjectSession:()=>Fi,deleteProjectTrigger:()=>Ni,deleteSandboxTemplate:()=>ii,deleteTask:()=>Pu,deleteTicket:()=>Au,deployProjectApp:()=>ta,describeAccountInvite:()=>qn,detachGroupFromProject:()=>ys,detectLocalhostUrls:()=>Vc,disconnectEmail:()=>jo,disconnectSlack:()=>wo,discoverLocalSandbox:()=>Wm,dropClientForUrl:()=>bp,dropPublicClientForUrl:()=>Pp,ensurePmSession:()=>Ou,ensureSandbox:()=>Al,env:()=>Tc,exportAccountAudit:()=>Ea,extractInstanceRoute:()=>we,featureFlags:()=>Im,fetchAccountStateWithToken:()=>Yp,fetchAccountsWithToken:()=>Lp,fetchProjectArchive:()=>pi,fetchProjectsForAccountWithToken:()=>Gp,files:()=>Mc,findLastTextPart:()=>Fg,fireProjectTrigger:()=>Wi,fixSandboxWithAgent:()=>ri,formatBillingErrorForUI:()=>Cc,formatCost:()=>em,formatDuration:()=>Qg,formatOpenCodeRuntimeError:()=>Um,formatTokens:()=>tm,formatTranscript:()=>rl,generateSessionId:()=>tl,getAccount:()=>Cn,getAccountState:()=>eo,getAccountStateMinimal:()=>to,getActiveInstanceIdFromCookie:()=>vl,getAgentCardLabel:()=>ul,getAgentConfig:()=>Xp,getAgentPersona:()=>Ku,getAllVersions:()=>_f,getAnsweredQuestionParts:()=>Gg,getAuthToken:()=>Ae,getAuthTokenWithRetry:()=>rn,getAutoTopupSettings:()=>ho,getBillingCreditBreakdown:()=>so,getBillingTierConfigurations:()=>oo,getBillingTransactionsSummary:()=>no,getBillingUsageHistory:()=>io,getChangeRequest:()=>xi,getChangeRequestDiff:()=>ki,getChangeRequestMergePreview:()=>Pi,getChildSessionError:()=>Ig,getChildSessionId:()=>Tg,getChildSessionToolParts:()=>jg,getClient:()=>X,getClientForUrl:()=>ne,getConnectStatus:()=>zs,getConnectorConfig:()=>Gs,getConnectorPolicies:()=>Fs,getCurrentInstanceIdFromPathname:()=>Rl,getCurrentInstanceIdFromWindow:()=>Em,getDefaultAccountState:()=>Zi,getDiagnostics:()=>$g,getDirectory:()=>ll,getEmailInstallation:()=>Co,getEmailMode:()=>To,getFileWithDir:()=>Ya,getFilename:()=>cl,getFullChangelog:()=>$l,getGatewayBreakdown:()=>Bo,getGatewayBudgets:()=>No,getGatewayErrors:()=>Ko,getGatewayKeys:()=>Vo,getGatewayLog:()=>Oo,getGatewayOverview:()=>Lo,getGatewaySeries:()=>Fo,getGatewaySessions:()=>Go,getGitHubInstallation:()=>Yn,getHiddenToolParts:()=>Rg,getInvite:()=>uf,getJustavpsServerTypes:()=>vf,getKortixProject:()=>Wu,getKortixProjectBySession:()=>Vu,getKortixPtyWebSocketUrl:()=>gn,getLatestSandboxVersion:()=>Pf,getMarketplaceCatalogItem:()=>Ga,getMarketplaceCatalogItemFile:()=>Ka,getMarketplaceUpdates:()=>Pa,getMeetVoices:()=>Eo,getMilestone:()=>Yu,getModelDefaults:()=>zi,getOpenCodeConfigInvalidError:()=>nc,getPartText:()=>wg,getPermissionForTool:()=>qg,getProject:()=>dt,getProjectActivity:()=>Nu,getProjectAppLogs:()=>na,getProjectCommit:()=>mi,getProjectCommitDiff:()=>fi,getProjectDetail:()=>gt,getProjectFileHistory:()=>yi,getProjectGitToken:()=>Nn,getProjectLlmCatalog:()=>mt,getProjectSandboxHealth:()=>bt,getProjectSession:()=>Mi,getProrationPreview:()=>fo,getProviders:()=>Fm,getProxyBaseUrl:()=>kd,getPublicClientForUrl:()=>kp,getPublicSessionShare:()=>nd,getPublicSessionShareMessages:()=>sd,getQuestionForTool:()=>Dg,getRegistryUpdates:()=>Ca,getRetryInfo:()=>rm,getRetryMessage:()=>nm,getReviewItem:()=>oa,getSSHConnection:()=>bf,getSandbox:()=>Bm,getSandboxById:()=>Km,getSandboxMemberScopes:()=>nf,getSandboxPortUrl:()=>Lm,getSandboxProvisionStatus:()=>Af,getSandboxProvisionStreamUrl:()=>Ef,getSandboxUpdateStatus:()=>kf,getSandboxUrl:()=>oc,getServiceLogs:()=>mp,getSessionAudit:()=>Ui,getSessionCost:()=>Zg,getSessionHealth:()=>Va,getSessionPreviewCandidates:()=>Ei,getSessionTranscript:()=>Oi,getShellModePart:()=>Hg,getSlackChannelFile:()=>So,getSlackInstallation:()=>xo,getSlackManifest:()=>_o,getSlackMode:()=>Po,getSupabaseAccessToken:()=>rt,getSupabaseAccessTokenWithRetry:()=>ue,getTask:()=>mu,getTaskStatus:()=>yu,getTemplate:()=>id,getTicket:()=>wu,getToolInfo:()=>Ag,getTranscriptFilename:()=>nl,getTurnCost:()=>Yg,getTurnError:()=>Jg,getTurnStatus:()=>Xg,getVersionDiff:()=>hi,getViewerSandboxScopes:()=>rf,getWorkingState:()=>Vg,grantSandboxProjectAccess:()=>af,groupMessagesIntoTurns:()=>Og,hasDiffs:()=>sm,hasLocalhostUrls:()=>bd,heartbeatGapEvent:()=>Qc,humanizeToolName:()=>vt,installMarketplaceItem:()=>xa,installRegistryItem:()=>Ra,installTemplate:()=>od,invalidateTokenCache:()=>je,inviteAccountMember:()=>jn,inviteProjectMember:()=>ls,inviteRepoCollaborator:()=>Gn,isAdminBypassEnabled:()=>Up,isAgentPart:()=>xg,isAppRouteUrl:()=>Wc,isAttachment:()=>ol,isBillingError:()=>vc,isCompactionPart:()=>kg,isConfigured:()=>Qe,isDestructivePhase:()=>xf,isExternalUrl:()=>Cd,isFilePart:()=>il,isInstanceDetailPath:()=>jm,isInstanceScopedAppPath:()=>wl,isInviteSent:()=>Hp,isLastUserMessage:()=>Wg,isManagedGithubProject:()=>Fp,isOpenCodeConfigInvalidError:()=>Mm,isPatchPart:()=>_g,isPreviewUrl:()=>wd,isProxiableLocalhostUrl:()=>zc,isReasoningPart:()=>Tt,isRuntimeReady:()=>ad,isSessionFresh:()=>ji,isSessionStartError:()=>Vp,isShellMode:()=>dl,isSnapshotPart:()=>Pg,isSubdomainPreviewUrl:()=>Df,isTextPart:()=>ee,isToolPart:()=>z,isToolPartHidden:()=>vg,isWebProxyUrl:()=>vd,kortixPty:()=>jc,leaveAccount:()=>Ln,linkRepository:()=>Qn,listAccountAudit:()=>Aa,listAccountAuditWebhooks:()=>$a,listAccountInvites:()=>An,listAccountMembers:()=>In,listAccountTokens:()=>ga,listAccounts:()=>Rn,listBackups:()=>gf,listBillingTransactions:()=>ro,listChangeRequests:()=>bi,listChannelBindings:()=>td,listColumns:()=>Eu,listConnectionProfiles:()=>As,listConnectors:()=>Ms,listCredentialEvents:()=>op,listCredentials:()=>ip,listEnv:()=>on,listFeaturedMarketplaces:()=>Ba,listFields:()=>qu,listGatewayLogs:()=>Uo,listGitHubInstallations:()=>Zn,listGitHubRepositories:()=>es,listInstalledMarketplaceItems:()=>ka,listInstalledRegistryItems:()=>va,listKortixProjectSessions:()=>zu,listKortixProjects:()=>Hu,listKortixPty:()=>ln,listMarketplaceCatalogItems:()=>La,listMarketplaceSources:()=>Na,listMarketplaces:()=>Fa,listMilestoneEvents:()=>Zu,listMilestones:()=>Qu,listPendingApprovals:()=>ks,listPendingProjectInvites:()=>us,listPipedreamApps:()=>Vs,listProjectAccess:()=>os,listProjectAccessRequests:()=>ns,listProjectAgents:()=>Lu,listProjectApps:()=>Qo,listProjectBranches:()=>di,listProjectCliTokens:()=>ya,listProjectCommits:()=>gi,listProjectFiles:()=>ci,listProjectGroupGrants:()=>gs,listProjectPolicies:()=>Qs,listProjectResourceGrants:()=>hs,listProjectSandboxTemplates:()=>Zs,listProjectSandboxes:()=>ai,listProjectSecrets:()=>ws,listProjectSessions:()=>be,listProjectSnapshots:()=>ei,listProjectTriggers:()=>Bi,listProjects:()=>ie,listProjectsForAccount:()=>Bn,listReviewItems:()=>ia,listSandboxMembers:()=>Qm,listSandboxProjectMembers:()=>of,listSandboxShares:()=>ua,listSandboxes:()=>Hm,listServiceTemplates:()=>gp,listServices:()=>dp,listSessionPublicShares:()=>$i,listSessionsNeedingInput:()=>Ps,listTaskEvents:()=>fu,listTasks:()=>gu,listTemplates:()=>Mu,listTicketEvents:()=>Su,listTickets:()=>_u,markInstanceError:()=>If,markSessionFresh:()=>Ii,mergeChangeRequest:()=>wi,narrowChatEvent:()=>Yc,normalizeAppPathname:()=>Dm,normalizeExternalInput:()=>Td,normalizeToolName:()=>Be,openChangeRequest:()=>_i,openEventStream:()=>wt,parseBillingError:()=>me,parseFlagOverride:()=>Tm,parseLocalhostUrl:()=>Le,parseOpenCodeErrorPayload:()=>Tl,parseSubdomainUrl:()=>Ja,parseWebProxyUrl:()=>Rd,patchKortixProject:()=>Xu,pipedreamConnect:()=>Ns,pipedreamFinalize:()=>Xs,platformConfig:()=>T,pollProjectProviderOAuth:()=>vs,previewMeetVoice:()=>Do,provisionProject:()=>Vn,provisionProjectWithToken:()=>Kp,proxyLocalhostUrl:()=>za,proxyUrlToInternal:()=>_d,purchaseCredits:()=>yo,reactivateSandbox:()=>Xm,reactivateSubscription:()=>po,readProjectFile:()=>ui,rebuildProjectSnapshot:()=>ti,reconcileConnectionProfile:()=>Es,reconcileServices:()=>yp,registerService:()=>hp,rejectProjectAccessRequest:()=>is,relativizePath:()=>Eg,removeAccountAuditWebhook:()=>Ma,removeAccountMember:()=>Un,removeKortixPty:()=>dn,removeMarketplaceItem:()=>Sa,removeMarketplaceSource:()=>Wa,removeRegistryItem:()=>ja,removeSandboxMember:()=>Zm,renameSandbox:()=>Nm,reopenChangeRequest:()=>Ri,reopenMilestone:()=>np,replaceColumns:()=>$u,replaceFields:()=>Du,replaceTemplates:()=>Uu,requestChangesOnChangeRequest:()=>vi,requestProjectAccess:()=>Np,requestProjectConnector:()=>Oa,requestProjectSecret:()=>Ua,resendAccountInvite:()=>$n,resendPendingProjectInvite:()=>ds,resetClient:()=>xp,resetPublicClient:()=>_p,resetSandboxUpdateStatus:()=>Sf,resolveApproval:()=>_s,restartProjectSession:()=>Me,restartSandbox:()=>Vm,restoreBackup:()=>ff,revealCredential:()=>cp,revokeAccountToken:()=>fa,revokeConnectionProfile:()=>qs,revokeGatewayKey:()=>Jo,revokePendingProjectInvite:()=>ps,revokeProjectAccess:()=>cs,revokeProjectCliToken:()=>ba,revokeSandboxInvite:()=>lf,revokeSandboxProjectAccess:()=>cf,revokeSandboxShare:()=>da,revokeSessionPublicShare:()=>Di,rewriteLocalhostUrl:()=>Pe,runGatewayPlayground:()=>Xo,saveGitHubInstallation:()=>ts,scheduleDowngrade:()=>go,searchProjectFiles:()=>li,serviceAction:()=>fp,sessionStartKey:()=>Jp,setActiveInstanceCookie:()=>$m,setAdminBypass:()=>Mp,setAgentScope:()=>Qi,setBootstrapAuthToken:()=>lu,setCachedAuthToken:()=>cu,setConnectorCredential:()=>Js,setConnectorCredentialMode:()=>Os,setConnectorName:()=>Ks,setConnectorPolicies:()=>Bs,setConnectorSensitive:()=>Ls,setEnv:()=>an,setGatewayBudget:()=>Ho,setMeetBotName:()=>qo,setMeetVoice:()=>$o,setModelDefault:()=>Ji,setPersonalProjectSecret:()=>Is,setProjectOnboardingComplete:()=>Xn,setProjectPolicies:()=>Ys,setProjectSessionSharing:()=>Ai,setProjectTriggersActivation:()=>Hi,setupSSH:()=>hf,shouldHideResponsePart:()=>zg,shouldShowToolPart:()=>al,sortSessions:()=>Ng,speakInMeeting:()=>Mo,splitUserParts:()=>Sg,startProjectProviderOAuth:()=>Rs,startProjectSession:()=>ke,startTask:()=>xu,stopProjectApp:()=>ra,stopProjectSession:()=>Ue,stopSandbox:()=>zm,stripAnsi:()=>Ug,stripInstancePrefix:()=>Am,stripTrailingSlashes:()=>re,submitReviewItem:()=>aa,supabaseClient:()=>Op,syncConnectors:()=>Us,systemReload:()=>Sp,toInstanceAwarePath:()=>qm,toInternalUrl:()=>Pd,toolInfo:()=>Ct,toolViewModel:()=>kl,transcribeAudio:()=>sa,triggerSandboxUpdate:()=>wf,triggersRequest:()=>Ic,turnHasSteps:()=>Bg,unassignTicket:()=>Iu,unwrapError:()=>K,updateAccountAuditWebhook:()=>Da,updateAccountMemberRole:()=>On,updateAccountName:()=>Tn,updateAgentConfig:()=>Qp,updateAllMarketplaceItems:()=>wa,updateAllRegistryItems:()=>Ia,updateAppsConfig:()=>Jn,updateChannelBinding:()=>rd,updateConnectionProfileCredential:()=>$s,updateEmailPolicy:()=>Ao,updateExperimentalFeature:()=>yt,updateKortixPty:()=>pn,updateMarketplaceItem:()=>_a,updateMilestone:()=>tp,updateProject:()=>ft,updateProjectAccess:()=>as,updateProjectAgent:()=>Bu,updateProjectApp:()=>Zo,updateProjectDefaultAgent:()=>Yi,updateProjectGroupGrant:()=>fs,updateProjectSandboxProvider:()=>zn,updateProjectSession:()=>Li,updateProjectTrigger:()=>Ki,updateRegistryItem:()=>Ta,updateSandboxMemberRole:()=>ef,updateSandboxMemberScope:()=>sf,updateSandboxMemberSpendCap:()=>tf,updateSandboxTemplate:()=>si,updateTask:()=>bu,updateTemplateWarmPool:()=>Bp,updateTicket:()=>vu,updateTicketStatus:()=>Cu,uploadSlackChannelFile:()=>Ro,upsertCredential:()=>ap,upsertProjectGitCredential:()=>Cs,upsertProjectSecret:()=>Ss,validateProjectManifest:()=>Kn,validateToken:()=>Fn});var Gl={backendUrl:"",getToken:async()=>null},Mt=null,Je=null;function Kl(e){Je=e}function Nl(){return Je}function Xe(e,t){t?.global!==!1&&(Mt=e)}function T(){return Je?.()??Mt??Gl}function Qe(){return Mt!==null||Je?.()!==void 0}var cc=({onRequest:e,onSseError:t,onSseEvent:r,responseTransformer:n,responseValidator:s,sseDefaultRetryDelay:l,sseMaxRetryAttempts:u,sseMaxRetryDelay:d,sseSleepFn:g,url:h,...m})=>{let x,k=g??(i=>new Promise(P=>setTimeout(P,i)));return{stream:async function*(){let i=l??3e3,P=0,w=m.signal??new AbortController().signal;for(;!w.aborted;){P++;let M=m.headers instanceof Headers?m.headers:new Headers(m.headers);x!==void 0&&M.set("Last-Event-ID",x);try{let A={redirect:"follow",...m,body:m.serializedBody,headers:M,signal:w},R=new Request(h,A);e&&(R=await e(h,A));let j=await(m.fetch??globalThis.fetch)(R);if(!j.ok)throw new Error(`SSE failed: ${j.status} ${j.statusText}`);if(!j.body)throw new Error("No body in SSE response");let f=j.body.pipeThrough(new TextDecoderStream).getReader(),S="",U=()=>{try{f.cancel()}catch{}};w.addEventListener("abort",U);try{for(;;){let{done:N,value:D}=await f.read();if(N)break;S+=D,S=S.replace(/\r\n/g,`
1
+ "use strict";var Kortix=(()=>{var qt=Object.defineProperty;var wl=Object.getOwnPropertyDescriptor;var _l=Object.getOwnPropertyNames;var Sl=Object.prototype.hasOwnProperty;var vl=(e,t)=>{for(var r in t)qt(e,r,{get:t[r],enumerable:!0})},Cl=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of _l(t))!Sl.call(e,s)&&s!==r&&qt(e,s,{get:()=>t[s],enumerable:!(n=wl(t,s))||n.enumerable});return e};var Rl=e=>Cl(qt({},"__esModule",{value:!0}),e);var $f={};vl($f,{ACTIVE_INSTANCE_COOKIE:()=>Ke,ApiError:()=>C,AuthError:()=>pe,BillingError:()=>te,COST_MARKUP:()=>La,DEFAULT_TRANSCRIPT_OPTIONS:()=>Da,DESTRUCTIVE_PHASES:()=>bl,INSTANCE_SCOPED_ROUTES:()=>cl,PublicSessionShareError:()=>xt,RequestTooLargeError:()=>de,RuntimeNotReadyError:()=>it,SANDBOX_PORTS:()=>V,SessionNotReadyError:()=>Le,SessionStartError:()=>bt,__getConfigResolver:()=>jl,__setConfigResolver:()=>Il,acceptAccountInvite:()=>qn,acceptInvite:()=>tf,actReviewItem:()=>ia,activateConnectionProfile:()=>Ds,addMarketplaceSource:()=>ja,addSandboxMember:()=>Km,allDescendantIds:()=>Qc,appendPreviewToken:()=>Ef,approveProjectAccessRequest:()=>ss,approveTask:()=>ou,archiveProject:()=>yt,assignTicket:()=>mu,attachGroupToProject:()=>ms,authenticatedFetch:()=>R,backendApi:()=>o,buildInstancePath:()=>ul,buildPreviewAuthEndpoint:()=>jf,buildSandboxTemplate:()=>oi,buildWebProxyUrl:()=>fd,bulkActReviewItems:()=>oa,cancelAccountInvite:()=>An,cancelSandbox:()=>Fm,cancelSandboxUpdate:()=>yf,cancelScheduledChange:()=>mo,cancelSubscription:()=>uo,childMapByParent:()=>qg,claimComputer:()=>Pf,classifyPart:()=>Ma,classifyTurn:()=>Nc,clearModelDefault:()=>Xi,clearSessionFresh:()=>Up,closeChangeRequest:()=>Si,closeMilestone:()=>Bu,collectTurnParts:()=>jg,commentTicket:()=>yu,commitSessionChanges:()=>Ri,computeStatusFromPart:()=>Oa,configureAutoTopup:()=>bo,configureKortix:()=>Je,confirmCheckoutSession:()=>co,connectEmail:()=>Io,connectSlack:()=>ko,createAccount:()=>vn,createAccountAuditWebhook:()=>xa,createAccountToken:()=>pa,createBackup:()=>sf,createCheckoutSession:()=>ao,createConnector:()=>Hs,createGatewayKey:()=>Yo,createInstance:()=>bf,createKortix:()=>Fc,createKortixPty:()=>ln,createMilestone:()=>Fu,createPortalSession:()=>lo,createProject:()=>Nn,createProjectAgent:()=>Cu,createProjectCliToken:()=>ma,createProjectRepo:()=>Hn,createProjectResourceGrant:()=>bs,createProjectSession:()=>be,createProjectTrigger:()=>Bi,createSandbox:()=>$m,createSandboxShare:()=>ca,createSandboxTemplate:()=>ni,createSessionPublicShare:()=>qi,createTask:()=>nu,createTicket:()=>pu,declineAccountInvite:()=>Dn,declineInvite:()=>rf,deleteBackup:()=>af,deleteConnector:()=>Ws,deleteCredential:()=>Ju,deleteEnv:()=>an,deleteGatewayBudget:()=>Xo,deleteGitHubInstallation:()=>rs,deleteInstance:()=>xf,deleteKortixProject:()=>Du,deleteMilestone:()=>Nu,deletePersonalProjectSecret:()=>js,deleteProjectAgent:()=>Tu,deleteProjectResourceGrant:()=>xs,deleteProjectSecret:()=>Ts,deleteProjectSession:()=>Fi,deleteProjectTrigger:()=>Ni,deleteSandboxTemplate:()=>ii,deleteTask:()=>au,deleteTicket:()=>hu,describeAccountInvite:()=>$n,detachGroupFromProject:()=>ys,detectLocalhostUrls:()=>$c,disconnectEmail:()=>jo,disconnectGitHubApp:()=>Tf,disconnectSlack:()=>_o,discoverLocalSandbox:()=>Um,dropClientForUrl:()=>sp,dropPublicClientForUrl:()=>ap,ensurePmSession:()=>Su,ensureSandbox:()=>hl,env:()=>gc,exportAccountAudit:()=>ha,extractInstanceRoute:()=>we,featureFlags:()=>km,fetchAccountStateWithToken:()=>Kp,fetchAccountsWithToken:()=>Ip,fetchProjectArchive:()=>pi,fetchProjectsForAccountWithToken:()=>$p,files:()=>Pc,findLastTextPart:()=>Ag,fireProjectTrigger:()=>Wi,fixSandboxWithAgent:()=>ri,formatBillingErrorForUI:()=>dc,formatCost:()=>Hg,formatDuration:()=>Bg,formatOpenCodeRuntimeError:()=>Tm,formatTokens:()=>Wg,formatTranscript:()=>Bc,generateSessionId:()=>Gc,getAccount:()=>Cn,getAccountState:()=>eo,getAccountStateMinimal:()=>to,getActiveInstanceIdFromCookie:()=>dl,getAgentCardLabel:()=>Xc,getAgentConfig:()=>Gp,getAgentPersona:()=>Iu,getAllVersions:()=>gf,getAnsweredQuestionParts:()=>$g,getAuthToken:()=>je,getAuthTokenWithRetry:()=>tn,getAutoTopupSettings:()=>ho,getBillingCreditBreakdown:()=>so,getBillingTierConfigurations:()=>oo,getBillingTransactionsSummary:()=>no,getBillingUsageHistory:()=>io,getChangeRequest:()=>xi,getChangeRequestDiff:()=>ki,getChangeRequestMergePreview:()=>Pi,getChildSessionError:()=>kg,getChildSessionId:()=>xg,getChildSessionToolParts:()=>Pg,getClient:()=>X,getClientForUrl:()=>ne,getConnectStatus:()=>zs,getConnectorConfig:()=>Bs,getConnectorPolicies:()=>Fs,getCurrentInstanceIdFromPathname:()=>pl,getCurrentInstanceIdFromWindow:()=>_m,getDefaultAccountState:()=>Zi,getDiagnostics:()=>Sg,getDirectory:()=>Jc,getEmailInstallation:()=>Ro,getEmailMode:()=>To,getFileWithDir:()=>Ua,getFilename:()=>zc,getFullChangelog:()=>xl,getGatewayBreakdown:()=>Ho,getGatewayBudgets:()=>zo,getGatewayErrors:()=>Vo,getGatewayKeys:()=>Qo,getGatewayLog:()=>Bo,getGatewayOverview:()=>Ko,getGatewayRoutingPolicy:()=>Uo,getGatewaySeries:()=>No,getGatewaySessions:()=>Wo,getGitHubAppStatus:()=>Sf,getGitHubInstallation:()=>Qn,getHiddenToolParts:()=>yg,getInvite:()=>ef,getJustavpsServerTypes:()=>hf,getKortixProject:()=>Eu,getKortixProjectBySession:()=>$u,getKortixPtyWebSocketUrl:()=>dn,getLatestSandboxVersion:()=>df,getManagedGitStatus:()=>Ap,getMarketplaceCatalogItem:()=>Ra,getMarketplaceCatalogItemFile:()=>Ta,getMeetVoices:()=>Eo,getMilestone:()=>Ou,getModelDefaults:()=>zi,getOpenCodeConfigInvalidError:()=>Ba,getPartText:()=>mg,getPermissionForTool:()=>vg,getProject:()=>pt,getProjectActivity:()=>ju,getProjectCommit:()=>mi,getProjectCommitDiff:()=>fi,getProjectDetail:()=>dt,getProjectFileHistory:()=>yi,getProjectGitToken:()=>Kn,getProjectLlmCatalog:()=>gt,getProjectModelPicker:()=>mt,getProjectSandboxHealth:()=>ht,getProjectSession:()=>Mi,getProrationPreview:()=>fo,getProviders:()=>Am,getProxyBaseUrl:()=>pd,getPublicClientForUrl:()=>op,getPublicSessionShare:()=>zp,getPublicSessionShareMessages:()=>Jp,getQuestionForTool:()=>Cg,getRetryInfo:()=>Vg,getRetryMessage:()=>zg,getReviewItem:()=>na,getSSHConnection:()=>lf,getSandbox:()=>Em,getSandboxById:()=>qm,getSandboxMemberScopes:()=>zm,getSandboxPortUrl:()=>jm,getSandboxProvisionStatus:()=>wf,getSandboxProvisionStreamUrl:()=>_f,getSandboxUpdateStatus:()=>pf,getSandboxUrl:()=>Ha,getServiceLogs:()=>ep,getSessionAudit:()=>Ui,getSessionCost:()=>Ng,getSessionHealth:()=>Ea,getSessionPreviewCandidates:()=>Ei,getSessionTranscript:()=>Oi,getShellModePart:()=>Mg,getSlackChannelFile:()=>So,getSlackInstallation:()=>xo,getSlackManifest:()=>wo,getSlackMode:()=>Po,getSupabaseAccessToken:()=>tt,getSupabaseAccessTokenWithRetry:()=>le,getTask:()=>eu,getTaskStatus:()=>ru,getTemplate:()=>Xp,getTicket:()=>lu,getToolInfo:()=>wg,getTranscriptFilename:()=>Kc,getTurnCost:()=>Kg,getTurnError:()=>Fg,getTurnStatus:()=>Gg,getVersionDiff:()=>hi,getViewerSandboxScopes:()=>Vm,getWorkingState:()=>Og,grantSandboxProjectAccess:()=>Qm,groupMessagesIntoTurns:()=>Ig,hasDiffs:()=>Jg,hasLocalhostUrls:()=>ld,heartbeatGapEvent:()=>Uc,humanizeToolName:()=>vt,installTemplate:()=>Qp,invalidateTokenCache:()=>Ie,inviteAccountMember:()=>In,inviteProjectMember:()=>ls,inviteRepoCollaborator:()=>Gn,isAdminBypassEnabled:()=>Rp,isAgentPart:()=>ug,isAppRouteUrl:()=>Ec,isAttachment:()=>Wc,isBillingError:()=>pc,isCompactionPart:()=>pg,isConfigured:()=>Xe,isDestructivePhase:()=>uf,isExternalUrl:()=>bd,isFilePart:()=>Hc,isInstanceDetailPath:()=>Pm,isInstanceScopedAppPath:()=>ll,isInviteSent:()=>Mp,isLastUserMessage:()=>Ug,isManagedGithubProject:()=>jp,isOpenCodeConfigInvalidError:()=>Rm,isPatchPart:()=>gg,isPreviewUrl:()=>md,isProxiableLocalhostUrl:()=>qc,isReasoningPart:()=>Rt,isRuntimeReady:()=>Yp,isSessionFresh:()=>ji,isSessionStartError:()=>Op,isShellMode:()=>Yc,isSnapshotPart:()=>dg,isSubdomainPreviewUrl:()=>Af,isTextPart:()=>ee,isToolPart:()=>z,isToolPartHidden:()=>hg,isWebProxyUrl:()=>hd,kortixPty:()=>fc,leaveAccount:()=>On,linkRepository:()=>Xn,listAccountAudit:()=>ya,listAccountAuditWebhooks:()=>ba,listAccountInvites:()=>jn,listAccountMembers:()=>Tn,listAccountTokens:()=>ua,listAccounts:()=>Sn,listBackups:()=>nf,listBillingTransactions:()=>ro,listChangeRequests:()=>bi,listChannelBindings:()=>Wp,listColumns:()=>bu,listConnectionProfiles:()=>As,listConnectors:()=>Ms,listCredentialEvents:()=>Wu,listCredentials:()=>Hu,listEnv:()=>sn,listFeaturedMarketplaces:()=>Ca,listFields:()=>ku,listGatewayLogs:()=>Go,listGitHubInstallations:()=>Yn,listGitHubRepositories:()=>Zn,listGitHubRepositoryBranches:()=>es,listKortixProjectSessions:()=>qu,listKortixProjects:()=>Au,listKortixPty:()=>cn,listMarketplaceCatalogItems:()=>Sa,listMarketplaceSources:()=>Ia,listMarketplaces:()=>va,listMilestoneEvents:()=>Lu,listMilestones:()=>Uu,listPendingApprovals:()=>ks,listPendingProjectInvites:()=>us,listPipedreamApps:()=>Vs,listProjectAccess:()=>os,listProjectAccessRequests:()=>ns,listProjectAgents:()=>vu,listProjectBranches:()=>di,listProjectCliTokens:()=>ga,listProjectCommits:()=>gi,listProjectFiles:()=>ci,listProjectGroupGrants:()=>gs,listProjectPolicies:()=>Qs,listProjectResourceGrants:()=>hs,listProjectSandboxTemplates:()=>Zs,listProjectSandboxes:()=>ai,listProjectSecrets:()=>_s,listProjectSessions:()=>he,listProjectSnapshots:()=>ei,listProjectTriggers:()=>Gi,listProjects:()=>ie,listProjectsForAccount:()=>Fn,listReviewItems:()=>ra,listSandboxMembers:()=>Bm,listSandboxProjectMembers:()=>Xm,listSandboxShares:()=>aa,listSandboxes:()=>Mm,listServiceTemplates:()=>Zu,listServices:()=>Yu,listSessionPublicShares:()=>$i,listSessionsNeedingInput:()=>Ps,listTaskEvents:()=>tu,listTasks:()=>Zl,listTemplates:()=>wu,listTicketEvents:()=>uu,listTickets:()=>cu,markInstanceError:()=>kf,markSessionFresh:()=>Ii,mergeChangeRequest:()=>_i,narrowChatEvent:()=>Oc,normalizeAppPathname:()=>Cm,normalizeExternalInput:()=>xd,normalizeToolName:()=>Fe,openChangeRequest:()=>wi,openEventStream:()=>wt,parseBillingError:()=>ge,parseFlagOverride:()=>xm,parseLocalhostUrl:()=>Oe,parseOpenCodeErrorPayload:()=>ml,parseSubdomainUrl:()=>qa,parseWebProxyUrl:()=>yd,patchKortixProject:()=>Mu,pipedreamConnect:()=>Ns,pipedreamFinalize:()=>Xs,platformConfig:()=>T,pollProjectProviderOAuth:()=>Cs,previewGatewayRoute:()=>Fo,previewMeetVoice:()=>Do,provisionProject:()=>Wn,provisionProjectWithToken:()=>qp,proxyLocalhostUrl:()=>$a,proxyUrlToInternal:()=>gd,purchaseCredits:()=>yo,reactivateSandbox:()=>Gm,reactivateSubscription:()=>po,readProjectFile:()=>ui,rebuildProjectSnapshot:()=>ti,reconcileConnectionProfile:()=>Es,reconcileServices:()=>rp,registerService:()=>np,rejectProjectAccessRequest:()=>is,relativizePath:()=>_g,removeAccountAuditWebhook:()=>Pa,removeAccountMember:()=>Mn,removeKortixPty:()=>pn,removeMarketplaceSource:()=>Aa,removeSandboxMember:()=>Nm,renameSandbox:()=>Dm,reopenChangeRequest:()=>vi,reopenMilestone:()=>Ku,replaceColumns:()=>xu,replaceFields:()=>Pu,replaceTemplates:()=>_u,requestChangesOnChangeRequest:()=>Ci,requestProjectAccess:()=>Dp,requestProjectConnector:()=>_a,requestProjectSecret:()=>wa,resendAccountInvite:()=>En,resendPendingProjectInvite:()=>ds,resetClient:()=>ip,resetGatewayRoutingPolicy:()=>Lo,resetPublicClient:()=>cp,resetSandboxUpdateStatus:()=>ff,resolveApproval:()=>ws,restartProjectSession:()=>De,restartSandbox:()=>Om,restoreBackup:()=>of,revealCredential:()=>zu,revokeAccountToken:()=>da,revokeConnectionProfile:()=>qs,revokeGatewayKey:()=>Zo,revokePendingProjectInvite:()=>ps,revokeProjectAccess:()=>cs,revokeProjectCliToken:()=>fa,revokeSandboxInvite:()=>Zm,revokeSandboxProjectAccess:()=>Ym,revokeSandboxShare:()=>la,revokeSessionPublicShare:()=>Di,rewriteLocalhostUrl:()=>ke,runGatewayPlayground:()=>ea,saveGitHubInstallation:()=>ts,scheduleDowngrade:()=>go,searchProjectFiles:()=>li,serviceAction:()=>tp,sessionStartKey:()=>Fp,setActiveInstanceCookie:()=>Sm,setAdminBypass:()=>Cp,setAgentScope:()=>Qi,setBootstrapAuthToken:()=>Jl,setCachedAuthToken:()=>zl,setConnectorCredential:()=>Js,setConnectorCredentialMode:()=>Os,setConnectorName:()=>Ks,setConnectorPolicies:()=>Gs,setConnectorSensitive:()=>Ls,setEnv:()=>on,setGatewayBudget:()=>Jo,setGatewayRoutingPolicy:()=>Oo,setGitHubAppFromExisting:()=>Cf,setGitHubAppPat:()=>Rf,setMeetBotName:()=>qo,setMeetVoice:()=>$o,setModelDefault:()=>Ji,setPersonalProjectSecret:()=>Is,setProjectOnboardingComplete:()=>Jn,setProjectPolicies:()=>Ys,setProjectSessionSharing:()=>Ai,setProjectTriggersActivation:()=>Hi,setupSSH:()=>cf,shouldHideResponsePart:()=>Lg,shouldShowToolPart:()=>Vc,sortSessions:()=>Dg,speakInMeeting:()=>Mo,splitUserParts:()=>fg,startGitHubAppManifest:()=>vf,startProjectProviderOAuth:()=>vs,startProjectSession:()=>xe,startTask:()=>iu,stopProjectSession:()=>Me,stopSandbox:()=>Lm,stripAnsi:()=>Tg,stripInstancePrefix:()=>wm,stripTrailingSlashes:()=>re,submitReviewItem:()=>sa,supabaseClient:()=>Tp,syncConnectors:()=>Us,systemReload:()=>up,toInstanceAwarePath:()=>vm,toInternalUrl:()=>dd,toolInfo:()=>Ct,toolViewModel:()=>ol,transcribeAudio:()=>ta,triggerSandboxUpdate:()=>mf,triggersRequest:()=>mc,turnHasSteps:()=>Eg,unassignTicket:()=>fu,unwrapError:()=>K,updateAccountAuditWebhook:()=>ka,updateAccountMemberRole:()=>Un,updateAccountName:()=>Rn,updateAgentConfig:()=>Bp,updateChannelBinding:()=>Vp,updateConnectionProfileCredential:()=>$s,updateEmailPolicy:()=>Ao,updateExperimentalFeature:()=>Vn,updateKortixPty:()=>un,updateMilestone:()=>Gu,updateProject:()=>ft,updateProjectAccess:()=>as,updateProjectAgent:()=>Ru,updateProjectDefaultAgent:()=>Yi,updateProjectGroupGrant:()=>fs,updateProjectSandboxProvider:()=>zn,updateProjectSession:()=>Li,updateProjectTrigger:()=>Ki,updateSandboxMemberRole:()=>Hm,updateSandboxMemberScope:()=>Jm,updateSandboxMemberSpendCap:()=>Wm,updateSandboxTemplate:()=>si,updateTask:()=>su,updateTemplateWarmPool:()=>Ep,updateTicket:()=>du,updateTicketStatus:()=>gu,uploadSlackChannelFile:()=>vo,upsertCredential:()=>Vu,upsertProjectGitCredential:()=>Rs,upsertProjectSecret:()=>Ss,validateProjectManifest:()=>Bn,validateToken:()=>Ln});var Tl={backendUrl:"",getToken:async()=>null},Dt=null,ze=null;function Il(e){ze=e}function jl(){return ze}function Je(e,t){t?.global!==!1&&(Dt=e)}function T(){return ze?.()??Dt??Tl}function Xe(){return Dt!==null||ze?.()!==void 0}var Va=({onRequest:e,onSseError:t,onSseEvent:r,responseTransformer:n,responseValidator:s,sseDefaultRetryDelay:c,sseMaxRetryAttempts:u,sseMaxRetryDelay:d,sseSleepFn:g,url:h,...m})=>{let x,w=g??(i=>new Promise(P=>setTimeout(P,i)));return{stream:async function*(){let i=c??3e3,P=0,_=m.signal??new AbortController().signal;for(;!_.aborted;){P++;let D=m.headers instanceof Headers?m.headers:new Headers(m.headers);x!==void 0&&D.set("Last-Event-ID",x);try{let A={redirect:"follow",...m,body:m.serializedBody,headers:D,signal:_},v=new Request(h,A);e&&(v=await e(h,A));let j=await(m.fetch??globalThis.fetch)(v);if(!j.ok)throw new Error(`SSE failed: ${j.status} ${j.statusText}`);if(!j.body)throw new Error("No body in SSE response");let f=j.body.pipeThrough(new TextDecoderStream).getReader(),S="",U=()=>{try{f.cancel()}catch{}};_.addEventListener("abort",U);try{for(;;){let{done:N,value:M}=await f.read();if(N)break;S+=M,S=S.replace(/\r\n/g,`
2
2
  `).replace(/\r/g,`
3
3
  `);let O=S.split(`
4
4
 
5
- `);S=O.pop()??"";for(let ce of O){let We=ce.split(`
6
- `),Se=[],Re;for(let E of We)if(E.startsWith("data:"))Se.push(E.replace(/^data:\s*/,""));else if(E.startsWith("event:"))Re=E.replace(/^event:\s*/,"");else if(E.startsWith("id:"))x=E.replace(/^id:\s*/,"");else if(E.startsWith("retry:")){let G=Number.parseInt(E.replace(/^retry:\s*/,""),10);Number.isNaN(G)||(i=G)}let H,F=!1;if(Se.length){let E=Se.join(`
7
- `);try{H=JSON.parse(E),F=!0}catch{H=E}}F&&(s&&await s(H),n&&(H=await n(H))),r?.({data:H,event:Re,id:x,retry:i}),Se.length&&(yield H)}}}finally{w.removeEventListener("abort",U),f.releaseLock()}break}catch(A){if(t?.(A),u!==void 0&&P>=u)break;let R=Math.min(i*2**(P-1),d??3e4);await k(R)}}}()}};var Hl=e=>{switch(e){case"label":return".";case"matrix":return";";case"simple":return",";default:return"&"}},Wl=e=>{switch(e){case"form":return",";case"pipeDelimited":return"|";case"spaceDelimited":return"%20";default:return","}},Vl=e=>{switch(e){case"label":return".";case"matrix":return";";case"simple":return",";default:return"&"}},Ye=({allowReserved:e,explode:t,name:r,style:n,value:s})=>{if(!t){let d=(e?s:s.map(g=>encodeURIComponent(g))).join(Wl(n));switch(n){case"label":return`.${d}`;case"matrix":return`;${r}=${d}`;case"simple":return d;default:return`${r}=${d}`}}let l=Hl(n),u=s.map(d=>n==="label"||n==="simple"?e?d:encodeURIComponent(d):le({allowReserved:e,name:r,value:d})).join(l);return n==="label"||n==="matrix"?l+u:u},le=({allowReserved:e,name:t,value:r})=>{if(r==null)return"";if(typeof r=="object")throw new Error("Deeply-nested arrays/objects aren\u2019t supported. Provide your own `querySerializer()` to handle these.");return`${t}=${e?r:encodeURIComponent(r)}`},Ze=({allowReserved:e,explode:t,name:r,style:n,value:s,valueOnly:l})=>{if(s instanceof Date)return l?s.toISOString():`${r}=${s.toISOString()}`;if(n!=="deepObject"&&!t){let g=[];Object.entries(s).forEach(([m,x])=>{g=[...g,m,e?x:encodeURIComponent(x)]});let h=g.join(",");switch(n){case"form":return`${r}=${h}`;case"label":return`.${h}`;case"matrix":return`;${r}=${h}`;default:return h}}let u=Vl(n),d=Object.entries(s).map(([g,h])=>le({allowReserved:e,name:n==="deepObject"?`${r}[${g}]`:g,value:h})).join(u);return n==="label"||n==="matrix"?u+d:d};var zl=/\{[^{}]+\}/g,Jl=({path:e,url:t})=>{let r=t,n=t.match(zl);if(n)for(let s of n){let l=!1,u=s.substring(1,s.length-1),d="simple";u.endsWith("*")&&(l=!0,u=u.substring(0,u.length-1)),u.startsWith(".")?(u=u.substring(1),d="label"):u.startsWith(";")&&(u=u.substring(1),d="matrix");let g=e[u];if(g==null)continue;if(Array.isArray(g)){r=r.replace(s,Ye({explode:l,name:u,style:d,value:g}));continue}if(typeof g=="object"){r=r.replace(s,Ze({explode:l,name:u,style:d,value:g,valueOnly:!0}));continue}if(d==="matrix"){r=r.replace(s,`;${le({name:u,value:g})}`);continue}let h=encodeURIComponent(d==="label"?`.${g}`:g);r=r.replace(s,h)}return r},lc=({baseUrl:e,path:t,query:r,querySerializer:n,url:s})=>{let l=s.startsWith("/")?s:`/${s}`,u=(e??"")+l;t&&(u=Jl({path:t,url:u}));let d=r?n(r):"";return d.startsWith("?")&&(d=d.substring(1)),d&&(u+=`?${d}`),u};function Ut(e){let t=e.body!==void 0;if(t&&e.bodySerializer)return"serializedBody"in e?e.serializedBody!==void 0&&e.serializedBody!==""?e.serializedBody:null:e.body!==""?e.body:null;if(t)return e.body}var uc=async(e,t)=>{let r=typeof t=="function"?await t(e):t;if(r)return e.scheme==="bearer"?`Bearer ${r}`:e.scheme==="basic"?`Basic ${btoa(r)}`:r};var Ot={bodySerializer:e=>JSON.stringify(e,(t,r)=>typeof r=="bigint"?r.toString():r)};var pc=({parameters:e={},...t}={})=>n=>{let s=[];if(n&&typeof n=="object")for(let l in n){let u=n[l];if(u==null)continue;let d=e[l]||t;if(Array.isArray(u)){let g=Ye({allowReserved:d.allowReserved,explode:!0,name:l,style:"form",value:u,...d.array});g&&s.push(g)}else if(typeof u=="object"){let g=Ze({allowReserved:d.allowReserved,explode:!0,name:l,style:"deepObject",value:u,...d.object});g&&s.push(g)}else{let g=le({allowReserved:d.allowReserved,name:l,value:u});g&&s.push(g)}}return s.join("&")},dc=e=>{if(!e)return"stream";let t=e.split(";")[0]?.trim();if(t){if(t.startsWith("application/json")||t.endsWith("+json"))return"json";if(t==="multipart/form-data")return"formData";if(["application/","audio/","image/","video/"].some(r=>t.startsWith(r)))return"blob";if(t.startsWith("text/"))return"text"}},Xl=(e,t)=>t?!!(e.headers.has(t)||e.query?.[t]||e.headers.get("Cookie")?.includes(`${t}=`)):!1,gc=async({security:e,...t})=>{for(let r of e){if(Xl(t,r.name))continue;let n=await uc(r,t.auth);if(!n)continue;let s=r.name??"Authorization";switch(r.in){case"query":t.query||(t.query={}),t.query[s]=n;break;case"cookie":t.headers.append("Cookie",`${s}=${n}`);break;default:t.headers.set(s,n);break}}},Lt=e=>lc({baseUrl:e.baseUrl,path:e.path,query:e.query,querySerializer:typeof e.querySerializer=="function"?e.querySerializer:pc(e.querySerializer),url:e.url}),Ft=(e,t)=>{let r={...e,...t};return r.baseUrl?.endsWith("/")&&(r.baseUrl=r.baseUrl.substring(0,r.baseUrl.length-1)),r.headers=et(e.headers,t.headers),r},Ql=e=>{let t=[];return e.forEach((r,n)=>{t.push([n,r])}),t},et=(...e)=>{let t=new Headers;for(let r of e){if(!r)continue;let n=r instanceof Headers?Ql(r):Object.entries(r);for(let[s,l]of n)if(l===null)t.delete(s);else if(Array.isArray(l))for(let u of l)t.append(s,u);else l!==void 0&&t.set(s,typeof l=="object"?JSON.stringify(l):l)}return t},Ce=class{fns=[];clear(){this.fns=[]}eject(t){let r=this.getInterceptorIndex(t);this.fns[r]&&(this.fns[r]=null)}exists(t){let r=this.getInterceptorIndex(t);return!!this.fns[r]}getInterceptorIndex(t){return typeof t=="number"?this.fns[t]?t:-1:this.fns.indexOf(t)}update(t,r){let n=this.getInterceptorIndex(t);return this.fns[n]?(this.fns[n]=r,t):!1}use(t){return this.fns.push(t),this.fns.length-1}},mc=()=>({error:new Ce,request:new Ce,response:new Ce}),Yl=pc({allowReserved:!1,array:{explode:!0,style:"form"},object:{explode:!0,style:"deepObject"}}),Zl={"Content-Type":"application/json"},Te=(e={})=>({...Ot,headers:Zl,parseAs:"auto",querySerializer:Yl,...e});var Ie=(e={})=>{let t=Ft(Te(),e),r=()=>({...t}),n=h=>(t=Ft(t,h),r()),s=mc(),l=async h=>{let m={...t,...h,fetch:h.fetch??t.fetch??globalThis.fetch,headers:et(t.headers,h.headers),serializedBody:void 0};m.security&&await gc({...m,security:m.security}),m.requestValidator&&await m.requestValidator(m),m.body!==void 0&&m.bodySerializer&&(m.serializedBody=m.bodySerializer(m.body)),(m.body===void 0||m.serializedBody==="")&&m.headers.delete("Content-Type");let x=Lt(m);return{opts:m,url:x}},u=async h=>{let{opts:m,url:x}=await l(h),k={redirect:"follow",...m,body:Ut(m)},_=new Request(x,k);for(let I of s.request.fns)I&&(_=await I(_,m));let c=m.fetch,i;try{i=await c(_)}catch(I){let j=I;for(let f of s.error.fns)f&&(j=await f(I,void 0,_,m));if(j=j||{},m.throwOnError)throw j;return m.responseStyle==="data"?void 0:{error:j,request:_,response:void 0}}for(let I of s.response.fns)I&&(i=await I(i,_,m));let P={request:_,response:i};if(i.ok){let I=(m.parseAs==="auto"?dc(i.headers.get("Content-Type")):m.parseAs)??"json";if(i.status===204||i.headers.get("Content-Length")==="0"){let f;switch(I){case"arrayBuffer":case"blob":case"text":f=await i[I]();break;case"formData":f=new FormData;break;case"stream":f=i.body;break;default:f={};break}return m.responseStyle==="data"?f:{data:f,...P}}let j;switch(I){case"arrayBuffer":case"blob":case"formData":case"text":j=await i[I]();break;case"json":{let f=await i.text();j=f?JSON.parse(f):{};break}case"stream":return m.responseStyle==="data"?i.body:{data:i.body,...P}}return I==="json"&&(m.responseValidator&&await m.responseValidator(j),m.responseTransformer&&(j=await m.responseTransformer(j))),m.responseStyle==="data"?j:{data:j,...P}}let w=await i.text(),M;try{M=JSON.parse(w)}catch{}let A=M??w,R=A;for(let I of s.error.fns)I&&(R=await I(A,i,_,m));if(R=R||{},m.throwOnError)throw R;return m.responseStyle==="data"?void 0:{error:R,...P}},d=h=>m=>u({...m,method:h}),g=h=>async m=>{let{opts:x,url:k}=await l(m);return cc({...x,body:x.body,headers:x.headers,method:h,onRequest:async(_,c)=>{let i=new Request(_,c);for(let P of s.request.fns)P&&(i=await P(i,x));return i},serializedBody:Ut(x),url:k})};return{buildUrl:Lt,connect:d("CONNECT"),delete:d("DELETE"),get:d("GET"),getConfig:r,head:d("HEAD"),interceptors:s,options:d("OPTIONS"),patch:d("PATCH"),post:d("POST"),put:d("PUT"),request:u,setConfig:n,sse:{connect:g("CONNECT"),delete:g("DELETE"),get:g("GET"),head:g("HEAD"),options:g("OPTIONS"),patch:g("PATCH"),post:g("POST"),put:g("PUT"),trace:g("TRACE")},trace:d("TRACE")}};var eu={$body_:"body",$headers_:"headers",$path_:"path",$query_:"query"},tu=Object.entries(eu),fc=(e,t)=>{t||(t=new Map);for(let r of e)"in"in r?r.key&&t.set(r.key,{in:r.in,map:r.map}):"key"in r?t.set(r.key,{map:r.map}):r.args&&fc(r.args,t);return t},ru=e=>{for(let[t,r]of Object.entries(e))r&&typeof r=="object"&&!Object.keys(r).length&&delete e[t]},p=(e,t)=>{let r={body:{},headers:{},path:{},query:{}},n=fc(t),s;for(let[l,u]of e.entries())if(t[l]&&(s=t[l]),!!s)if("in"in s)if(s.key){let d=n.get(s.key),g=d.map||s.key;d.in&&(r[d.in][g]=u)}else r.body=u;else for(let[d,g]of Object.entries(u??{})){let h=n.get(d);if(h)if(h.in){let m=h.map||d;r[h.in][m]=g}else r[h.map]=g;else{let m=tu.find(([x])=>d.startsWith(x));if(m){let[x,k]=m;r[k][d.slice(x.length)]=g}else if("allowExtra"in s&&s.allowExtra){for(let[x,k]of Object.entries(s.allowExtra))if(k){r[x][d]=g;break}}}}return ru(r),r};var yc=Ie(Te({baseUrl:"http://localhost:4096"}));var y=class{client;constructor(t){this.client=t?.client??yc}},Bt=class{defaultKey="default";instances=new Map;get(t){let r=this.instances.get(t??this.defaultKey);if(!r)throw new Error('No SDK client found. Create one with "new OpencodeClient()" to fix this error.');return r}set(t,r){this.instances.set(r??this.defaultKey,t)}},Gt=class extends y{remove(t,r){let n=p([t],[{args:[{in:"path",key:"providerID"}]}]);return(r?.client??this.client).delete({url:"/auth/{providerID}",...r,...n})}set(t,r){let n=p([t],[{args:[{in:"path",key:"providerID"},{key:"auth",map:"body"}]}]);return(r?.client??this.client).put({url:"/auth/{providerID}",...r,...n,headers:{"Content-Type":"application/json",...r?.headers,...n.headers}})}},Kt=class extends y{log(t,r){let n=p([t],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"},{in:"body",key:"service"},{in:"body",key:"level"},{in:"body",key:"message"},{in:"body",key:"extra"}]}]);return(r?.client??this.client).post({url:"/log",...r,...n,headers:{"Content-Type":"application/json",...r?.headers,...n.headers}})}agents(t,r){let n=p([t],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(r?.client??this.client).get({url:"/agent",...r,...n})}skills(t,r){let n=p([t],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(r?.client??this.client).get({url:"/skill",...r,...n})}},Nt=class extends y{moveSession(t,r){let n=p([t],[{args:[{in:"body",key:"sessionID"},{in:"body",key:"destination"},{in:"body",key:"moveChanges"}]}]);return(r?.client??this.client).post({url:"/experimental/control-plane/move-session",...r,...n,headers:{"Content-Type":"application/json",...r?.headers,...n.headers}})}},Ht=class extends y{get(t,r){let n=p([t],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(r?.client??this.client).get({url:"/experimental/capabilities",...r,...n})}},Wt=class extends y{get(t,r){let n=p([t],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(r?.client??this.client).get({url:"/experimental/console",...r,...n})}listOrgs(t,r){let n=p([t],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(r?.client??this.client).get({url:"/experimental/console/orgs",...r,...n})}switchOrg(t,r){let n=p([t],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"},{in:"body",key:"accountID"},{in:"body",key:"orgID"}]}]);return(r?.client??this.client).post({url:"/experimental/console/switch",...r,...n,headers:{"Content-Type":"application/json",...r?.headers,...n.headers}})}},Vt=class extends y{list(t,r){let n=p([t],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"},{in:"query",key:"roots"},{in:"query",key:"start"},{in:"query",key:"cursor"},{in:"query",key:"search"},{in:"query",key:"limit"},{in:"query",key:"archived"}]}]);return(r?.client??this.client).get({url:"/experimental/session",...r,...n})}background(t,r){let n=p([t],[{args:[{in:"path",key:"sessionID"},{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(r?.client??this.client).post({url:"/experimental/session/{sessionID}/background",...r,...n})}},zt=class extends y{list(t,r){let n=p([t],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(r?.client??this.client).get({url:"/experimental/resource",...r,...n})}},Jt=class extends y{generateName(t,r){let n=p([t],[{args:[{in:"path",key:"projectID"},{in:"query",key:"directory"},{in:"query",key:"workspace"},{in:"body",key:"context"}]}]);return(r?.client??this.client).post({url:"/experimental/project/{projectID}/copy/generate-name",...r,...n,headers:{"Content-Type":"application/json",...r?.headers,...n.headers}})}},Xt=class extends y{list(t,r){let n=p([t],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(r?.client??this.client).get({url:"/experimental/workspace/adapter",...r,...n})}},Qt=class extends y{list(t,r){let n=p([t],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(r?.client??this.client).get({url:"/experimental/workspace",...r,...n})}create(t,r){let n=p([t],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"},{in:"body",key:"id"},{in:"body",key:"type"},{in:"body",key:"branch"},{in:"body",key:"extra"}]}]);return(r?.client??this.client).post({url:"/experimental/workspace",...r,...n,headers:{"Content-Type":"application/json",...r?.headers,...n.headers}})}syncList(t,r){let n=p([t],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(r?.client??this.client).post({url:"/experimental/workspace/sync-list",...r,...n})}status(t,r){let n=p([t],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(r?.client??this.client).get({url:"/experimental/workspace/status",...r,...n})}remove(t,r){let n=p([t],[{args:[{in:"path",key:"id"},{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(r?.client??this.client).delete({url:"/experimental/workspace/{id}",...r,...n})}warp(t,r){let n=p([t],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"},{in:"body",key:"id"},{in:"body",key:"sessionID"},{in:"body",key:"copyChanges"}]}]);return(r?.client??this.client).post({url:"/experimental/workspace/warp",...r,...n,headers:{"Content-Type":"application/json",...r?.headers,...n.headers}})}_adapter;get adapter(){return this._adapter??=new Xt({client:this.client})}},Yt=class extends y{_controlPlane;get controlPlane(){return this._controlPlane??=new Nt({client:this.client})}_capabilities;get capabilities(){return this._capabilities??=new Ht({client:this.client})}_console;get console(){return this._console??=new Wt({client:this.client})}_session;get session(){return this._session??=new Vt({client:this.client})}_resource;get resource(){return this._resource??=new zt({client:this.client})}_projectCopy;get projectCopy(){return this._projectCopy??=new Jt({client:this.client})}_workspace;get workspace(){return this._workspace??=new Qt({client:this.client})}},Zt=class extends y{get(t){return(t?.client??this.client).get({url:"/global/config",...t})}update(t,r){let n=p([t],[{args:[{key:"config",map:"body"}]}]);return(r?.client??this.client).patch({url:"/global/config",...r,...n,headers:{"Content-Type":"application/json",...r?.headers,...n.headers}})}},er=class extends y{health(t){return(t?.client??this.client).get({url:"/global/health",...t})}event(t){return(t?.client??this.client).sse.get({url:"/global/event",...t})}dispose(t){return(t?.client??this.client).post({url:"/global/dispose",...t})}upgrade(t,r){let n=p([t],[{args:[{in:"body",key:"target"}]}]);return(r?.client??this.client).post({url:"/global/upgrade",...r,...n,headers:{"Content-Type":"application/json",...r?.headers,...n.headers}})}_config;get config(){return this._config??=new Zt({client:this.client})}},tr=class extends y{subscribe(t,r){let n=p([t],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(r?.client??this.client).sse.get({url:"/event",...r,...n})}},rr=class extends y{get(t,r){let n=p([t],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(r?.client??this.client).get({url:"/config",...r,...n})}update(t,r){let n=p([t],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"},{key:"config",map:"body"}]}]);return(r?.client??this.client).patch({url:"/config",...r,...n,headers:{"Content-Type":"application/json",...r?.headers,...n.headers}})}providers(t,r){let n=p([t],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(r?.client??this.client).get({url:"/config/providers",...r,...n})}},nr=class extends y{list(t,r){let n=p([t],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"},{in:"query",key:"provider"},{in:"query",key:"model"}]}]);return(r?.client??this.client).get({url:"/experimental/tool",...r,...n})}ids(t,r){let n=p([t],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(r?.client??this.client).get({url:"/experimental/tool/ids",...r,...n})}},sr=class extends y{remove(t,r){let n=p([t],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"},{key:"worktreeRemoveInput",map:"body"}]}]);return(r?.client??this.client).delete({url:"/experimental/worktree",...r,...n,headers:{"Content-Type":"application/json",...r?.headers,...n.headers}})}list(t,r){let n=p([t],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(r?.client??this.client).get({url:"/experimental/worktree",...r,...n})}create(t,r){let n=p([t],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"},{key:"worktreeCreateInput",map:"body"}]}]);return(r?.client??this.client).post({url:"/experimental/worktree",...r,...n,headers:{"Content-Type":"application/json",...r?.headers,...n.headers}})}reset(t,r){let n=p([t],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"},{key:"worktreeResetInput",map:"body"}]}]);return(r?.client??this.client).post({url:"/experimental/worktree/reset",...r,...n,headers:{"Content-Type":"application/json",...r?.headers,...n.headers}})}},ir=class extends y{text(t,r){let n=p([t],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"},{in:"query",key:"pattern"}]}]);return(r?.client??this.client).get({url:"/find",...r,...n})}files(t,r){let n=p([t],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"},{in:"query",key:"query"},{in:"query",key:"dirs"},{in:"query",key:"type"},{in:"query",key:"limit"}]}]);return(r?.client??this.client).get({url:"/find/file",...r,...n})}symbols(t,r){let n=p([t],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"},{in:"query",key:"query"}]}]);return(r?.client??this.client).get({url:"/find/symbol",...r,...n})}},or=class extends y{list(t,r){let n=p([t],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"},{in:"query",key:"path"}]}]);return(r?.client??this.client).get({url:"/file",...r,...n})}read(t,r){let n=p([t],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"},{in:"query",key:"path"}]}]);return(r?.client??this.client).get({url:"/file/content",...r,...n})}status(t,r){let n=p([t],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(r?.client??this.client).get({url:"/file/status",...r,...n})}},ar=class extends y{dispose(t,r){let n=p([t],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(r?.client??this.client).post({url:"/instance/dispose",...r,...n})}},cr=class extends y{get(t,r){let n=p([t],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(r?.client??this.client).get({url:"/path",...r,...n})}},lr=class extends y{raw(t,r){let n=p([t],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(r?.client??this.client).get({url:"/vcs/diff/raw",...r,...n})}},ur=class extends y{get(t,r){let n=p([t],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(r?.client??this.client).get({url:"/vcs",...r,...n})}status(t,r){let n=p([t],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(r?.client??this.client).get({url:"/vcs/status",...r,...n})}diff(t,r){let n=p([t],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"},{in:"query",key:"mode"},{in:"query",key:"context"}]}]);return(r?.client??this.client).get({url:"/vcs/diff",...r,...n})}apply(t,r){let n=p([t],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"},{in:"body",key:"patch"}]}]);return(r?.client??this.client).post({url:"/vcs/apply",...r,...n,headers:{"Content-Type":"application/json",...r?.headers,...n.headers}})}_diff;get diff2(){return this._diff??=new lr({client:this.client})}},pr=class extends y{list(t,r){let n=p([t],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(r?.client??this.client).get({url:"/command",...r,...n})}},dr=class extends y{status(t,r){let n=p([t],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(r?.client??this.client).get({url:"/lsp",...r,...n})}},gr=class extends y{status(t,r){let n=p([t],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(r?.client??this.client).get({url:"/formatter",...r,...n})}},mr=class extends y{remove(t,r){let n=p([t],[{args:[{in:"path",key:"name"},{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(r?.client??this.client).delete({url:"/mcp/{name}/auth",...r,...n})}start(t,r){let n=p([t],[{args:[{in:"path",key:"name"},{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(r?.client??this.client).post({url:"/mcp/{name}/auth",...r,...n})}callback(t,r){let n=p([t],[{args:[{in:"path",key:"name"},{in:"query",key:"directory"},{in:"query",key:"workspace"},{in:"body",key:"code"}]}]);return(r?.client??this.client).post({url:"/mcp/{name}/auth/callback",...r,...n,headers:{"Content-Type":"application/json",...r?.headers,...n.headers}})}authenticate(t,r){let n=p([t],[{args:[{in:"path",key:"name"},{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(r?.client??this.client).post({url:"/mcp/{name}/auth/authenticate",...r,...n})}},fr=class extends y{status(t,r){let n=p([t],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(r?.client??this.client).get({url:"/mcp",...r,...n})}add(t,r){let n=p([t],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"},{in:"body",key:"name"},{in:"body",key:"config"}]}]);return(r?.client??this.client).post({url:"/mcp",...r,...n,headers:{"Content-Type":"application/json",...r?.headers,...n.headers}})}connect(t,r){let n=p([t],[{args:[{in:"path",key:"name"},{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(r?.client??this.client).post({url:"/mcp/{name}/connect",...r,...n})}disconnect(t,r){let n=p([t],[{args:[{in:"path",key:"name"},{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(r?.client??this.client).post({url:"/mcp/{name}/disconnect",...r,...n})}_auth;get auth(){return this._auth??=new mr({client:this.client})}},yr=class extends y{list(t,r){let n=p([t],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(r?.client??this.client).get({url:"/project",...r,...n})}current(t,r){let n=p([t],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(r?.client??this.client).get({url:"/project/current",...r,...n})}initGit(t,r){let n=p([t],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(r?.client??this.client).post({url:"/project/git/init",...r,...n})}update(t,r){let n=p([t],[{args:[{in:"path",key:"projectID"},{in:"query",key:"directory"},{in:"query",key:"workspace"},{in:"body",key:"name"},{in:"body",key:"icon"},{in:"body",key:"commands"}]}]);return(r?.client??this.client).patch({url:"/project/{projectID}",...r,...n,headers:{"Content-Type":"application/json",...r?.headers,...n.headers}})}directories(t,r){let n=p([t],[{args:[{in:"path",key:"projectID"},{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(r?.client??this.client).get({url:"/project/{projectID}/directories",...r,...n})}},hr=class extends y{shells(t,r){let n=p([t],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(r?.client??this.client).get({url:"/pty/shells",...r,...n})}list(t,r){let n=p([t],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(r?.client??this.client).get({url:"/pty",...r,...n})}create(t,r){let n=p([t],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"},{in:"body",key:"command"},{in:"body",key:"args"},{in:"body",key:"cwd"},{in:"body",key:"title"},{in:"body",key:"env"}]}]);return(r?.client??this.client).post({url:"/pty",...r,...n,headers:{"Content-Type":"application/json",...r?.headers,...n.headers}})}remove(t,r){let n=p([t],[{args:[{in:"path",key:"ptyID"},{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(r?.client??this.client).delete({url:"/pty/{ptyID}",...r,...n})}get(t,r){let n=p([t],[{args:[{in:"path",key:"ptyID"},{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(r?.client??this.client).get({url:"/pty/{ptyID}",...r,...n})}update(t,r){let n=p([t],[{args:[{in:"path",key:"ptyID"},{in:"query",key:"directory"},{in:"query",key:"workspace"},{in:"body",key:"title"},{in:"body",key:"size"}]}]);return(r?.client??this.client).put({url:"/pty/{ptyID}",...r,...n,headers:{"Content-Type":"application/json",...r?.headers,...n.headers}})}connectToken(t,r){let n=p([t],[{args:[{in:"path",key:"ptyID"},{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(r?.client??this.client).post({url:"/pty/{ptyID}/connect-token",...r,...n})}connect(t,r){let n=p([t],[{args:[{in:"path",key:"ptyID"},{in:"query",key:"directory"},{in:"query",key:"workspace"},{in:"query",key:"cursor"},{in:"query",key:"ticket"}]}]);return(r?.client??this.client).get({url:"/pty/{ptyID}/connect",...r,...n})}},br=class extends y{list(t,r){let n=p([t],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(r?.client??this.client).get({url:"/question",...r,...n})}reply(t,r){let n=p([t],[{args:[{in:"path",key:"requestID"},{in:"query",key:"directory"},{in:"query",key:"workspace"},{in:"body",key:"answers"}]}]);return(r?.client??this.client).post({url:"/question/{requestID}/reply",...r,...n,headers:{"Content-Type":"application/json",...r?.headers,...n.headers}})}reject(t,r){let n=p([t],[{args:[{in:"path",key:"requestID"},{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(r?.client??this.client).post({url:"/question/{requestID}/reject",...r,...n})}},xr=class extends y{list(t,r){let n=p([t],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(r?.client??this.client).get({url:"/permission",...r,...n})}reply(t,r){let n=p([t],[{args:[{in:"path",key:"requestID"},{in:"query",key:"directory"},{in:"query",key:"workspace"},{in:"body",key:"reply"},{in:"body",key:"message"}]}]);return(r?.client??this.client).post({url:"/permission/{requestID}/reply",...r,...n,headers:{"Content-Type":"application/json",...r?.headers,...n.headers}})}respond(t,r){let n=p([t],[{args:[{in:"path",key:"sessionID"},{in:"path",key:"permissionID"},{in:"query",key:"directory"},{in:"query",key:"workspace"},{in:"body",key:"response"}]}]);return(r?.client??this.client).post({url:"/session/{sessionID}/permissions/{permissionID}",...r,...n,headers:{"Content-Type":"application/json",...r?.headers,...n.headers}})}},kr=class extends y{authorize(t,r){let n=p([t],[{args:[{in:"path",key:"providerID"},{in:"query",key:"directory"},{in:"query",key:"workspace"},{in:"body",key:"method"},{in:"body",key:"inputs"}]}]);return(r?.client??this.client).post({url:"/provider/{providerID}/oauth/authorize",...r,...n,headers:{"Content-Type":"application/json",...r?.headers,...n.headers}})}callback(t,r){let n=p([t],[{args:[{in:"path",key:"providerID"},{in:"query",key:"directory"},{in:"query",key:"workspace"},{in:"body",key:"method"},{in:"body",key:"code"}]}]);return(r?.client??this.client).post({url:"/provider/{providerID}/oauth/callback",...r,...n,headers:{"Content-Type":"application/json",...r?.headers,...n.headers}})}},Pr=class extends y{list(t,r){let n=p([t],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(r?.client??this.client).get({url:"/provider",...r,...n})}auth(t,r){let n=p([t],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(r?.client??this.client).get({url:"/provider/auth",...r,...n})}_oauth;get oauth(){return this._oauth??=new kr({client:this.client})}},_r=class extends y{list(t,r){let n=p([t],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"},{in:"query",key:"scope"},{in:"query",key:"path"},{in:"query",key:"roots"},{in:"query",key:"start"},{in:"query",key:"search"},{in:"query",key:"limit"}]}]);return(r?.client??this.client).get({url:"/session",...r,...n})}create(t,r){let n=p([t],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"},{in:"body",key:"parentID"},{in:"body",key:"title"},{in:"body",key:"agent"},{in:"body",key:"model"},{in:"body",key:"metadata"},{in:"body",key:"permission"},{in:"body",key:"workspaceID"}]}]);return(r?.client??this.client).post({url:"/session",...r,...n,headers:{"Content-Type":"application/json",...r?.headers,...n.headers}})}status(t,r){let n=p([t],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(r?.client??this.client).get({url:"/session/status",...r,...n})}delete(t,r){let n=p([t],[{args:[{in:"path",key:"sessionID"},{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(r?.client??this.client).delete({url:"/session/{sessionID}",...r,...n})}get(t,r){let n=p([t],[{args:[{in:"path",key:"sessionID"},{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(r?.client??this.client).get({url:"/session/{sessionID}",...r,...n})}update(t,r){let n=p([t],[{args:[{in:"path",key:"sessionID"},{in:"query",key:"directory"},{in:"query",key:"workspace"},{in:"body",key:"title"},{in:"body",key:"metadata"},{in:"body",key:"permission"},{in:"body",key:"time"}]}]);return(r?.client??this.client).patch({url:"/session/{sessionID}",...r,...n,headers:{"Content-Type":"application/json",...r?.headers,...n.headers}})}children(t,r){let n=p([t],[{args:[{in:"path",key:"sessionID"},{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(r?.client??this.client).get({url:"/session/{sessionID}/children",...r,...n})}todo(t,r){let n=p([t],[{args:[{in:"path",key:"sessionID"},{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(r?.client??this.client).get({url:"/session/{sessionID}/todo",...r,...n})}diff(t,r){let n=p([t],[{args:[{in:"path",key:"sessionID"},{in:"query",key:"directory"},{in:"query",key:"workspace"},{in:"query",key:"messageID"}]}]);return(r?.client??this.client).get({url:"/session/{sessionID}/diff",...r,...n})}messages(t,r){let n=p([t],[{args:[{in:"path",key:"sessionID"},{in:"query",key:"directory"},{in:"query",key:"workspace"},{in:"query",key:"limit"},{in:"query",key:"before"}]}]);return(r?.client??this.client).get({url:"/session/{sessionID}/message",...r,...n})}prompt(t,r){let n=p([t],[{args:[{in:"path",key:"sessionID"},{in:"query",key:"directory"},{in:"query",key:"workspace"},{in:"body",key:"messageID"},{in:"body",key:"model"},{in:"body",key:"agent"},{in:"body",key:"noReply"},{in:"body",key:"tools"},{in:"body",key:"format"},{in:"body",key:"system"},{in:"body",key:"variant"},{in:"body",key:"parts"}]}]);return(r?.client??this.client).post({url:"/session/{sessionID}/message",...r,...n,headers:{"Content-Type":"application/json",...r?.headers,...n.headers}})}deleteMessage(t,r){let n=p([t],[{args:[{in:"path",key:"sessionID"},{in:"path",key:"messageID"},{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(r?.client??this.client).delete({url:"/session/{sessionID}/message/{messageID}",...r,...n})}message(t,r){let n=p([t],[{args:[{in:"path",key:"sessionID"},{in:"path",key:"messageID"},{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(r?.client??this.client).get({url:"/session/{sessionID}/message/{messageID}",...r,...n})}fork(t,r){let n=p([t],[{args:[{in:"path",key:"sessionID"},{in:"query",key:"directory"},{in:"query",key:"workspace"},{in:"body",key:"messageID"}]}]);return(r?.client??this.client).post({url:"/session/{sessionID}/fork",...r,...n,headers:{"Content-Type":"application/json",...r?.headers,...n.headers}})}abort(t,r){let n=p([t],[{args:[{in:"path",key:"sessionID"},{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(r?.client??this.client).post({url:"/session/{sessionID}/abort",...r,...n})}init(t,r){let n=p([t],[{args:[{in:"path",key:"sessionID"},{in:"query",key:"directory"},{in:"query",key:"workspace"},{in:"body",key:"modelID"},{in:"body",key:"providerID"},{in:"body",key:"messageID"}]}]);return(r?.client??this.client).post({url:"/session/{sessionID}/init",...r,...n,headers:{"Content-Type":"application/json",...r?.headers,...n.headers}})}unshare(t,r){let n=p([t],[{args:[{in:"path",key:"sessionID"},{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(r?.client??this.client).delete({url:"/session/{sessionID}/share",...r,...n})}share(t,r){let n=p([t],[{args:[{in:"path",key:"sessionID"},{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(r?.client??this.client).post({url:"/session/{sessionID}/share",...r,...n})}summarize(t,r){let n=p([t],[{args:[{in:"path",key:"sessionID"},{in:"query",key:"directory"},{in:"query",key:"workspace"},{in:"body",key:"providerID"},{in:"body",key:"modelID"},{in:"body",key:"auto"}]}]);return(r?.client??this.client).post({url:"/session/{sessionID}/summarize",...r,...n,headers:{"Content-Type":"application/json",...r?.headers,...n.headers}})}promptAsync(t,r){let n=p([t],[{args:[{in:"path",key:"sessionID"},{in:"query",key:"directory"},{in:"query",key:"workspace"},{in:"body",key:"messageID"},{in:"body",key:"model"},{in:"body",key:"agent"},{in:"body",key:"noReply"},{in:"body",key:"tools"},{in:"body",key:"format"},{in:"body",key:"system"},{in:"body",key:"variant"},{in:"body",key:"parts"}]}]);return(r?.client??this.client).post({url:"/session/{sessionID}/prompt_async",...r,...n,headers:{"Content-Type":"application/json",...r?.headers,...n.headers}})}command(t,r){let n=p([t],[{args:[{in:"path",key:"sessionID"},{in:"query",key:"directory"},{in:"query",key:"workspace"},{in:"body",key:"messageID"},{in:"body",key:"agent"},{in:"body",key:"model"},{in:"body",key:"arguments"},{in:"body",key:"command"},{in:"body",key:"variant"},{in:"body",key:"parts"}]}]);return(r?.client??this.client).post({url:"/session/{sessionID}/command",...r,...n,headers:{"Content-Type":"application/json",...r?.headers,...n.headers}})}shell(t,r){let n=p([t],[{args:[{in:"path",key:"sessionID"},{in:"query",key:"directory"},{in:"query",key:"workspace"},{in:"body",key:"messageID"},{in:"body",key:"agent"},{in:"body",key:"model"},{in:"body",key:"command"}]}]);return(r?.client??this.client).post({url:"/session/{sessionID}/shell",...r,...n,headers:{"Content-Type":"application/json",...r?.headers,...n.headers}})}revert(t,r){let n=p([t],[{args:[{in:"path",key:"sessionID"},{in:"query",key:"directory"},{in:"query",key:"workspace"},{in:"body",key:"messageID"},{in:"body",key:"partID"}]}]);return(r?.client??this.client).post({url:"/session/{sessionID}/revert",...r,...n,headers:{"Content-Type":"application/json",...r?.headers,...n.headers}})}unrevert(t,r){let n=p([t],[{args:[{in:"path",key:"sessionID"},{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(r?.client??this.client).post({url:"/session/{sessionID}/unrevert",...r,...n})}},wr=class extends y{delete(t,r){let n=p([t],[{args:[{in:"path",key:"sessionID"},{in:"path",key:"messageID"},{in:"path",key:"partID"},{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(r?.client??this.client).delete({url:"/session/{sessionID}/message/{messageID}/part/{partID}",...r,...n})}update(t,r){let n=p([t],[{args:[{in:"path",key:"sessionID"},{in:"path",key:"messageID"},{in:"path",key:"partID"},{in:"query",key:"directory"},{in:"query",key:"workspace"},{key:"part",map:"body"}]}]);return(r?.client??this.client).patch({url:"/session/{sessionID}/message/{messageID}/part/{partID}",...r,...n,headers:{"Content-Type":"application/json",...r?.headers,...n.headers}})}},Sr=class extends y{list(t,r){let n=p([t],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"},{key:"body",map:"body"}]}]);return(r?.client??this.client).post({url:"/sync/history",...r,...n,headers:{"Content-Type":"application/json",...r?.headers,...n.headers}})}},Rr=class extends y{start(t,r){let n=p([t],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(r?.client??this.client).post({url:"/sync/start",...r,...n})}replay(t,r){let n=p([t],[{args:[{in:"query",key:"query_directory",map:"directory"},{in:"query",key:"workspace"},{in:"body",key:"body_directory",map:"directory"},{in:"body",key:"events"}]}]);return(r?.client??this.client).post({url:"/sync/replay",...r,...n,headers:{"Content-Type":"application/json",...r?.headers,...n.headers}})}steal(t,r){let n=p([t],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"},{in:"body",key:"sessionID"}]}]);return(r?.client??this.client).post({url:"/sync/steal",...r,...n,headers:{"Content-Type":"application/json",...r?.headers,...n.headers}})}_history;get history(){return this._history??=new Sr({client:this.client})}},vr=class extends y{next(t,r){let n=p([t],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(r?.client??this.client).get({url:"/tui/control/next",...r,...n})}response(t,r){let n=p([t],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"},{key:"body",map:"body"}]}]);return(r?.client??this.client).post({url:"/tui/control/response",...r,...n,headers:{"Content-Type":"application/json",...r?.headers,...n.headers}})}},Cr=class extends y{appendPrompt(t,r){let n=p([t],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"},{in:"body",key:"text"}]}]);return(r?.client??this.client).post({url:"/tui/append-prompt",...r,...n,headers:{"Content-Type":"application/json",...r?.headers,...n.headers}})}openHelp(t,r){let n=p([t],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(r?.client??this.client).post({url:"/tui/open-help",...r,...n})}openSessions(t,r){let n=p([t],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(r?.client??this.client).post({url:"/tui/open-sessions",...r,...n})}openThemes(t,r){let n=p([t],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(r?.client??this.client).post({url:"/tui/open-themes",...r,...n})}openModels(t,r){let n=p([t],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(r?.client??this.client).post({url:"/tui/open-models",...r,...n})}submitPrompt(t,r){let n=p([t],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(r?.client??this.client).post({url:"/tui/submit-prompt",...r,...n})}clearPrompt(t,r){let n=p([t],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(r?.client??this.client).post({url:"/tui/clear-prompt",...r,...n})}executeCommand(t,r){let n=p([t],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"},{in:"body",key:"command"}]}]);return(r?.client??this.client).post({url:"/tui/execute-command",...r,...n,headers:{"Content-Type":"application/json",...r?.headers,...n.headers}})}showToast(t,r){let n=p([t],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"},{in:"body",key:"title"},{in:"body",key:"message"},{in:"body",key:"variant"},{in:"body",key:"duration"}]}]);return(r?.client??this.client).post({url:"/tui/show-toast",...r,...n,headers:{"Content-Type":"application/json",...r?.headers,...n.headers}})}publish(t,r){let n=p([t],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"},{key:"body",map:"body"}]}]);return(r?.client??this.client).post({url:"/tui/publish",...r,...n,headers:{"Content-Type":"application/json",...r?.headers,...n.headers}})}selectSession(t,r){let n=p([t],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"},{in:"body",key:"sessionID"}]}]);return(r?.client??this.client).post({url:"/tui/select-session",...r,...n,headers:{"Content-Type":"application/json",...r?.headers,...n.headers}})}_control;get control(){return this._control??=new vr({client:this.client})}},Tr=class extends y{get(t){return(t?.client??this.client).get({url:"/api/health",...t})}},Ir=class extends y{get(t,r){let n=p([t],[{args:[{in:"query",key:"location"}]}]);return(r?.client??this.client).get({url:"/api/location",...r,...n})}},jr=class extends y{list(t,r){let n=p([t],[{args:[{in:"query",key:"location"}]}]);return(r?.client??this.client).get({url:"/api/agent",...r,...n})}},Ar=class extends y{stage(t,r){let n=p([t],[{args:[{in:"path",key:"sessionID"},{in:"body",key:"messageID"},{in:"body",key:"files"}]}]);return(r?.client??this.client).post({url:"/api/session/{sessionID}/revert/stage",...r,...n,headers:{"Content-Type":"application/json",...r?.headers,...n.headers}})}clear(t,r){let n=p([t],[{args:[{in:"path",key:"sessionID"}]}]);return(r?.client??this.client).post({url:"/api/session/{sessionID}/revert/clear",...r,...n})}commit(t,r){let n=p([t],[{args:[{in:"path",key:"sessionID"}]}]);return(r?.client??this.client).post({url:"/api/session/{sessionID}/revert/commit",...r,...n})}},Er=class extends y{list(t,r){let n=p([t],[{args:[{in:"path",key:"sessionID"}]}]);return(r?.client??this.client).get({url:"/api/session/{sessionID}/permission",...r,...n})}reply(t,r){let n=p([t],[{args:[{in:"path",key:"sessionID"},{in:"path",key:"requestID"},{in:"body",key:"reply"},{in:"body",key:"message"}]}]);return(r?.client??this.client).post({url:"/api/session/{sessionID}/permission/{requestID}/reply",...r,...n,headers:{"Content-Type":"application/json",...r?.headers,...n.headers}})}},$r=class extends y{list(t,r){let n=p([t],[{args:[{in:"path",key:"sessionID"}]}]);return(r?.client??this.client).get({url:"/api/session/{sessionID}/question",...r,...n})}reply(t,r){let n=p([t],[{args:[{in:"path",key:"sessionID"},{in:"path",key:"requestID"},{key:"questionV2Reply",map:"body"}]}]);return(r?.client??this.client).post({url:"/api/session/{sessionID}/question/{requestID}/reply",...r,...n,headers:{"Content-Type":"application/json",...r?.headers,...n.headers}})}reject(t,r){let n=p([t],[{args:[{in:"path",key:"sessionID"},{in:"path",key:"requestID"}]}]);return(r?.client??this.client).post({url:"/api/session/{sessionID}/question/{requestID}/reject",...r,...n})}},qr=class extends y{list(t,r){let n=p([t],[{args:[{in:"query",key:"workspace"},{in:"query",key:"limit"},{in:"query",key:"order"},{in:"query",key:"search"},{in:"query",key:"directory"},{in:"query",key:"project"},{in:"query",key:"subpath"},{in:"query",key:"cursor"}]}]);return(r?.client??this.client).get({url:"/api/session",...r,...n})}create(t,r){let n=p([t],[{args:[{in:"body",key:"id"},{in:"body",key:"agent"},{in:"body",key:"model"},{in:"body",key:"location"}]}]);return(r?.client??this.client).post({url:"/api/session",...r,...n,headers:{"Content-Type":"application/json",...r?.headers,...n.headers}})}get(t,r){let n=p([t],[{args:[{in:"path",key:"sessionID"}]}]);return(r?.client??this.client).get({url:"/api/session/{sessionID}",...r,...n})}switchAgent(t,r){let n=p([t],[{args:[{in:"path",key:"sessionID"},{in:"body",key:"agent"}]}]);return(r?.client??this.client).post({url:"/api/session/{sessionID}/agent",...r,...n,headers:{"Content-Type":"application/json",...r?.headers,...n.headers}})}switchModel(t,r){let n=p([t],[{args:[{in:"path",key:"sessionID"},{in:"body",key:"model"}]}]);return(r?.client??this.client).post({url:"/api/session/{sessionID}/model",...r,...n,headers:{"Content-Type":"application/json",...r?.headers,...n.headers}})}prompt(t,r){let n=p([t],[{args:[{in:"path",key:"sessionID"},{in:"body",key:"id"},{in:"body",key:"prompt"},{in:"body",key:"delivery"},{in:"body",key:"resume"}]}]);return(r?.client??this.client).post({url:"/api/session/{sessionID}/prompt",...r,...n,headers:{"Content-Type":"application/json",...r?.headers,...n.headers}})}compact(t,r){let n=p([t],[{args:[{in:"path",key:"sessionID"}]}]);return(r?.client??this.client).post({url:"/api/session/{sessionID}/compact",...r,...n})}wait(t,r){let n=p([t],[{args:[{in:"path",key:"sessionID"}]}]);return(r?.client??this.client).post({url:"/api/session/{sessionID}/wait",...r,...n})}context(t,r){let n=p([t],[{args:[{in:"path",key:"sessionID"}]}]);return(r?.client??this.client).get({url:"/api/session/{sessionID}/context",...r,...n})}messages(t,r){let n=p([t],[{args:[{in:"path",key:"sessionID"},{in:"query",key:"limit"},{in:"query",key:"order"},{in:"query",key:"cursor"}]}]);return(r?.client??this.client).get({url:"/api/session/{sessionID}/message",...r,...n})}_revert;get revert(){return this._revert??=new Ar({client:this.client})}_permission;get permission(){return this._permission??=new Er({client:this.client})}_question;get question(){return this._question??=new $r({client:this.client})}},Dr=class extends y{list(t,r){let n=p([t],[{args:[{in:"query",key:"location"}]}]);return(r?.client??this.client).get({url:"/api/model",...r,...n})}},Mr=class extends y{list(t,r){let n=p([t],[{args:[{in:"query",key:"location"}]}]);return(r?.client??this.client).get({url:"/api/provider",...r,...n})}get(t,r){let n=p([t],[{args:[{in:"path",key:"providerID"},{in:"query",key:"location"}]}]);return(r?.client??this.client).get({url:"/api/provider/{providerID}",...r,...n})}},Ur=class extends y{key(t,r){let n=p([t],[{args:[{in:"path",key:"integrationID"},{in:"query",key:"location"},{in:"body",key:"key"},{in:"body",key:"label"}]}]);return(r?.client??this.client).post({url:"/api/integration/{integrationID}/connect/key",...r,...n,headers:{"Content-Type":"application/json",...r?.headers,...n.headers}})}oauth(t,r){let n=p([t],[{args:[{in:"path",key:"integrationID"},{in:"query",key:"location"},{in:"body",key:"methodID"},{in:"body",key:"inputs"},{in:"body",key:"label"}]}]);return(r?.client??this.client).post({url:"/api/integration/{integrationID}/connect/oauth",...r,...n,headers:{"Content-Type":"application/json",...r?.headers,...n.headers}})}},Or=class extends y{cancel(t,r){let n=p([t],[{args:[{in:"path",key:"attemptID"},{in:"query",key:"location"}]}]);return(r?.client??this.client).delete({url:"/api/integration/attempt/{attemptID}",...r,...n})}status(t,r){let n=p([t],[{args:[{in:"path",key:"attemptID"},{in:"query",key:"location"}]}]);return(r?.client??this.client).get({url:"/api/integration/attempt/{attemptID}",...r,...n})}complete(t,r){let n=p([t],[{args:[{in:"path",key:"attemptID"},{in:"query",key:"location"},{in:"body",key:"code"}]}]);return(r?.client??this.client).post({url:"/api/integration/attempt/{attemptID}/complete",...r,...n,headers:{"Content-Type":"application/json",...r?.headers,...n.headers}})}},Lr=class extends y{list(t,r){let n=p([t],[{args:[{in:"query",key:"location"}]}]);return(r?.client??this.client).get({url:"/api/integration",...r,...n})}get(t,r){let n=p([t],[{args:[{in:"path",key:"integrationID"},{in:"query",key:"location"}]}]);return(r?.client??this.client).get({url:"/api/integration/{integrationID}",...r,...n})}_connect;get connect(){return this._connect??=new Ur({client:this.client})}_attempt;get attempt(){return this._attempt??=new Or({client:this.client})}},Fr=class extends y{remove(t,r){let n=p([t],[{args:[{in:"path",key:"credentialID"},{in:"query",key:"location"}]}]);return(r?.client??this.client).delete({url:"/api/credential/{credentialID}",...r,...n})}update(t,r){let n=p([t],[{args:[{in:"path",key:"credentialID"},{in:"query",key:"location"},{in:"body",key:"label"}]}]);return(r?.client??this.client).patch({url:"/api/credential/{credentialID}",...r,...n,headers:{"Content-Type":"application/json",...r?.headers,...n.headers}})}},Br=class extends y{list(t,r){let n=p([t],[{args:[{in:"query",key:"location"}]}]);return(r?.client??this.client).get({url:"/api/permission/request",...r,...n})}},Gr=class extends y{list(t,r){let n=p([t],[{args:[{in:"query",key:"projectID"}]}]);return(r?.client??this.client).get({url:"/api/permission/saved",...r,...n})}remove(t,r){let n=p([t],[{args:[{in:"path",key:"id"}]}]);return(r?.client??this.client).delete({url:"/api/permission/saved/{id}",...r,...n})}},Kr=class extends y{_request;get request(){return this._request??=new Br({client:this.client})}_saved;get saved(){return this._saved??=new Gr({client:this.client})}},Nr=class extends y{read(t,r){let n=p([t],[{args:[{in:"query",key:"location"}]}]);return(r?.client??this.client).get({url:"/api/fs/read/*",...r,...n})}list(t,r){let n=p([t],[{args:[{in:"query",key:"location"},{in:"query",key:"path"}]}]);return(r?.client??this.client).get({url:"/api/fs/list",...r,...n})}find(t,r){let n=p([t],[{args:[{in:"query",key:"location"},{in:"query",key:"query"},{in:"query",key:"type"},{in:"query",key:"limit"}]}]);return(r?.client??this.client).get({url:"/api/fs/find",...r,...n})}},Hr=class extends y{list(t,r){let n=p([t],[{args:[{in:"query",key:"location"}]}]);return(r?.client??this.client).get({url:"/api/command",...r,...n})}},Wr=class extends y{list(t,r){let n=p([t],[{args:[{in:"query",key:"location"}]}]);return(r?.client??this.client).get({url:"/api/skill",...r,...n})}},Vr=class extends y{subscribe(t){return(t?.client??this.client).sse.get({url:"/api/event",...t})}},zr=class extends y{list(t,r){let n=p([t],[{args:[{in:"query",key:"location"}]}]);return(r?.client??this.client).get({url:"/api/pty",...r,...n})}create(t,r){let n=p([t],[{args:[{in:"query",key:"location"},{in:"body",key:"command"},{in:"body",key:"args"},{in:"body",key:"cwd"},{in:"body",key:"title"},{in:"body",key:"env"}]}]);return(r?.client??this.client).post({url:"/api/pty",...r,...n,headers:{"Content-Type":"application/json",...r?.headers,...n.headers}})}remove(t,r){let n=p([t],[{args:[{in:"path",key:"ptyID"},{in:"query",key:"location"}]}]);return(r?.client??this.client).delete({url:"/api/pty/{ptyID}",...r,...n})}get(t,r){let n=p([t],[{args:[{in:"path",key:"ptyID"},{in:"query",key:"location"}]}]);return(r?.client??this.client).get({url:"/api/pty/{ptyID}",...r,...n})}update(t,r){let n=p([t],[{args:[{in:"path",key:"ptyID"},{in:"query",key:"location"},{in:"body",key:"title"},{in:"body",key:"size"}]}]);return(r?.client??this.client).put({url:"/api/pty/{ptyID}",...r,...n,headers:{"Content-Type":"application/json",...r?.headers,...n.headers}})}connectToken(t,r){let n=p([t],[{args:[{in:"path",key:"ptyID"},{in:"query",key:"location"}]}]);return(r?.client??this.client).post({url:"/api/pty/{ptyID}/connect-token",...r,...n})}connect(t,r){let n=p([t],[{args:[{in:"path",key:"ptyID"},{in:"query",key:"location[directory]"},{in:"query",key:"location[workspace]"},{in:"query",key:"cursor"},{in:"query",key:"ticket"}]}]);return(r?.client??this.client).get({url:"/api/pty/{ptyID}/connect",...r,...n})}},Jr=class extends y{list(t,r){let n=p([t],[{args:[{in:"query",key:"location"}]}]);return(r?.client??this.client).get({url:"/api/question/request",...r,...n})}},Xr=class extends y{_request;get request(){return this._request??=new Jr({client:this.client})}},Qr=class extends y{list(t,r){let n=p([t],[{args:[{in:"query",key:"location"}]}]);return(r?.client??this.client).get({url:"/api/reference",...r,...n})}},Yr=class extends y{remove(t,r){let n=p([t],[{args:[{in:"path",key:"projectID"},{in:"query",key:"location"},{in:"body",key:"directory"},{in:"body",key:"force"}]}]);return(r?.client??this.client).delete({url:"/experimental/project/{projectID}/copy",...r,...n,headers:{"Content-Type":"application/json",...r?.headers,...n.headers}})}create(t,r){let n=p([t],[{args:[{in:"path",key:"projectID"},{in:"query",key:"location"},{in:"body",key:"strategy"},{in:"body",key:"directory"},{in:"body",key:"name"}]}]);return(r?.client??this.client).post({url:"/experimental/project/{projectID}/copy",...r,...n,headers:{"Content-Type":"application/json",...r?.headers,...n.headers}})}refresh(t,r){let n=p([t],[{args:[{in:"path",key:"projectID"},{in:"query",key:"location"}]}]);return(r?.client??this.client).post({url:"/experimental/project/{projectID}/copy/refresh",...r,...n})}},Zr=class extends y{_health;get health(){return this._health??=new Tr({client:this.client})}_location;get location(){return this._location??=new Ir({client:this.client})}_agent;get agent(){return this._agent??=new jr({client:this.client})}_session;get session(){return this._session??=new qr({client:this.client})}_model;get model(){return this._model??=new Dr({client:this.client})}_provider;get provider(){return this._provider??=new Mr({client:this.client})}_integration;get integration(){return this._integration??=new Lr({client:this.client})}_credential;get credential(){return this._credential??=new Fr({client:this.client})}_permission;get permission(){return this._permission??=new Kr({client:this.client})}_fs;get fs(){return this._fs??=new Nr({client:this.client})}_command;get command(){return this._command??=new Hr({client:this.client})}_skill;get skill(){return this._skill??=new Wr({client:this.client})}_event;get event(){return this._event??=new Vr({client:this.client})}_pty;get pty(){return this._pty??=new zr({client:this.client})}_question;get question(){return this._question??=new Xr({client:this.client})}_reference;get reference(){return this._reference??=new Qr({client:this.client})}_projectCopy;get projectCopy(){return this._projectCopy??=new Yr({client:this.client})}},tt=class e extends y{static __registry=new Bt;constructor(t){super(t),e.__registry.set(this,t?.key)}_auth;get auth(){return this._auth??=new Gt({client:this.client})}_app;get app(){return this._app??=new Kt({client:this.client})}_experimental;get experimental(){return this._experimental??=new Yt({client:this.client})}_global;get global(){return this._global??=new er({client:this.client})}_event;get event(){return this._event??=new tr({client:this.client})}_config;get config(){return this._config??=new rr({client:this.client})}_tool;get tool(){return this._tool??=new nr({client:this.client})}_worktree;get worktree(){return this._worktree??=new sr({client:this.client})}_find;get find(){return this._find??=new ir({client:this.client})}_file;get file(){return this._file??=new or({client:this.client})}_instance;get instance(){return this._instance??=new ar({client:this.client})}_path;get path(){return this._path??=new cr({client:this.client})}_vcs;get vcs(){return this._vcs??=new ur({client:this.client})}_command;get command(){return this._command??=new pr({client:this.client})}_lsp;get lsp(){return this._lsp??=new dr({client:this.client})}_formatter;get formatter(){return this._formatter??=new gr({client:this.client})}_mcp;get mcp(){return this._mcp??=new fr({client:this.client})}_project;get project(){return this._project??=new yr({client:this.client})}_pty;get pty(){return this._pty??=new hr({client:this.client})}_question;get question(){return this._question??=new br({client:this.client})}_permission;get permission(){return this._permission??=new xr({client:this.client})}_provider;get provider(){return this._provider??=new Pr({client:this.client})}_session;get session(){return this._session??=new _r({client:this.client})}_part;get part(){return this._part??=new wr({client:this.client})}_sync;get sync(){return this._sync??=new Rr({client:this.client})}_tui;get tui(){return this._tui??=new Cr({client:this.client})}_v2;get v2(){return this._v2??=new Zr({client:this.client})}};function bc(e,t,r,n){if(!n?.throwOnError||e instanceof Error)return e;if(typeof e=="object"&&e!==null&&Object.keys(e).length>0){let l=e,u=typeof l.data?.message=="string"&&l.data.message||typeof l.message=="string"&&l.message||typeof l.name=="string"&&l.name||hc(r,t);return new Error(u,{cause:{body:e,status:t?.status}})}if(typeof e=="string"&&e.length>0)return new Error(e,{cause:{body:e,status:t?.status}});let s=t?"(empty response body)":"network error (no response)";return new Error(`opencode server ${hc(r,t)}: ${s}`,{cause:{body:e,status:t?.status}})}function hc(e,t){let r=e?.method??"?",n=e?.url??"?",s=t?.status,l=t?.statusText;return`${r} ${n}${s?" \u2192 "+s:""}${l?" "+l:""}`}function nu(e,t,r){if(e)return t&&(e===t||r&&e===r(t))?t:e}function su(e,t){if(e.method!=="GET"&&e.method!=="HEAD")return e;let r=new URL(e.url),n=!1;for(let[l,u]of[["x-opencode-directory","directory"],["x-opencode-workspace","workspace"]]){let d=nu(e.headers.get(l),u==="directory"?t.directory:t.workspace,u==="directory"?encodeURIComponent:void 0);if(d){for(let g of r.pathname.startsWith("/api/")?[u,`location[${u}]`]:[u])r.searchParams.has(g)||r.searchParams.set(g,d);n=!0}}if(!n)return e;let s=new Request(r,e);return s.headers.delete("x-opencode-directory"),s.headers.delete("x-opencode-workspace"),s}function en(e){e?.fetch||(e={...e,fetch:n=>(n.timeout=!1,fetch(n))}),e?.directory&&(e.headers={...e.headers,"x-opencode-directory":encodeURIComponent(e.directory)}),e?.experimental_workspaceID&&(e.headers={...e.headers,"x-opencode-workspace":e.experimental_workspaceID});let t=Ie(e);return t.interceptors.request.use(r=>su(r,{directory:e?.directory,workspace:e?.experimental_workspaceID})),t.interceptors.response.use(r=>{if(r.headers.get("content-type")==="text/html")throw new Error("Request is not supported by this version of OpenCode Server (Server responded with text/html)");return r}),t.interceptors.error.use(bc),new tt({client:t})}function iu(e){return new Promise(t=>setTimeout(t,e))}async function xc(e,t,r){let n=Math.max(1,t?.attempts??1),s=t?.baseDelayMs??0,l=t?.invalidateBetweenAttempts??!1,u=null;for(let d=0;d<n;d++)if(d>0&&(l&&r?.(),s>0&&await iu(s)),u=await e(),u)return u;return u}var ou=3e4;function au(e){return(e instanceof Request?e.url:String(e)).includes("/global/event")}function kc(e,t,r=ou){let n=e instanceof Request?e.signal:t?.signal;if(au(e))return n??void 0;let s=AbortSignal.timeout(r);return n?typeof AbortSignal.any=="function"?AbortSignal.any([n,s]):n:s}function tn(e,t,r){let n=new Headers(e instanceof Request?e.headers:void 0);return t?.headers&&new Headers(t.headers).forEach((s,l)=>{n.set(l,s)}),r&&!n.has("Authorization")&&n.set("Authorization",`Bearer ${r}`),n}function Pc(){return new Response(JSON.stringify({error:"Not authenticated"}),{status:401,headers:{"Content-Type":"application/json"}})}async function rt(){return T().getToken()}async function ue(e){return xc(()=>T().getToken(),e,je)}function je(){}function cu(e){}function lu(e){}async function Ae(){return rt()}async function rn(e){return ue(e)}function _c(e,t,r,n){if(e instanceof Request){let s=new Request(e,{headers:r,...n?{signal:n}:{}});return fetch(s)}return fetch(e,{...t,headers:r,...n?{signal:n}:{}})}async function C(e,t,r){let{retryOnAuthError:n=!0}=r??{},s=await rn();if(!s)return Pc();let l=tn(e,t,s),u=kc(e,t),d=await _c(e,t,l,u);if(d.status===401&&n&&s){je();let g=await rn({attempts:2,baseDelayMs:200});if(g&&g!==s){let h=tn(e,t,g);return _c(e,t,h,u)}}return d}var pe={url:null,sandboxId:null,dbSandboxId:null,version:0},uu=new Set;function wc(e,t=null,r=null){if(!(pe.url===e&&pe.sandboxId===t&&pe.dbSandboxId===r)){pe={url:e,sandboxId:t,dbSandboxId:r,version:pe.version+1};for(let n of uu)n()}}function Sc(){return pe.url}function pu(e){let t=e.length;for(;t>0&&e.charCodeAt(t-1)===47;)t--;return e.slice(0,t)}function Ee(){return pu(T().backendUrl||"http://localhost:8008/v1")}function Rc(){let e=T().sandboxId||"";return`${Ee()}/p/${e}/8000`}function du(e){return`${Ee()}/p/${e}/8000`}function nt(e){return du(e)}function $(){let e=Sc();return e||(T().billingEnabled??!1?"":Rc())}var v=class extends Error{status;code;details;data;detail;response;url;endpoint;timeout;constructor(t,r={}){super(t),this.name="ApiError";let{name:n,stack:s,...l}=r;Object.assign(this,l),n&&(this.name=n),s&&(this.stack=s),Object.defineProperty(this,"message",{value:t,enumerable:!0,writable:!0,configurable:!0}),Object.setPrototypeOf(this,new.target.prototype)}},de=class extends v{constructor(t="Not authenticated"){super(t,{code:"NO_SESSION"}),this.name="AuthError"}},te=class e extends Error{status;detail;constructor(t,r,n){super(n||r.message||`Billing Error: ${t}`),this.name="BillingError",this.status=t,this.detail=r,Object.setPrototypeOf(this,e.prototype)}},ge=class e extends Error{status;detail;constructor(t=431,r,n){let s="Request headers are too large",l="Try uploading files one at a time, or reduce the number of files in a single request.";super(n||r?.message||s),this.name="RequestTooLargeError",this.status=t,this.detail={message:r?.message||s,suggestion:r?.suggestion||l},Object.setPrototypeOf(this,e.prototype)}};function me(e){let t=e.response?.status||e.status;if(t!==402)return e;let r=e.response?.data||e.data||e.detail||{},n=r?.detail||r;return new te(t,{message:n?.message||e.message||"Billing error",...n})}function vc(e){return e instanceof te}function Cc(e){if(!(e instanceof te))return null;let t=e.detail?.message?.toLowerCase()||"";return t.includes("credit")||t.includes("balance")||t.includes("insufficient")?{alertTitle:"You ran out of credits",alertSubtitle:"Upgrade your plan to get more credits and continue using the AI assistant."}:{alertTitle:"Billing check failed",alertSubtitle:e.detail?.message||"Please upgrade to continue."}}async function nn(e,t){return(await e.json().catch(()=>({})))?.error||e.statusText||t}function sn(e){if(!e)throw new Error("[opencode-sdk] Server URL not ready \u2014 sandbox is still loading");return e}async function on(e){let t=sn(e),r=await C(`${t}/env`);if(!r.ok)throw new Error(await nn(r,"Failed to load secrets"));return(await r.json()).secrets??{}}async function an(e,t,r){let n=sn(e),s=await C(`${n}/env/${encodeURIComponent(t)}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({value:r})});if(!s.ok)throw new Error(await nn(s,"Failed to save secret"))}async function cn(e,t){let r=sn(e),n=await C(`${r}/env/${encodeURIComponent(t)}`,{method:"DELETE"});if(!n.ok)throw new Error(await nn(n,"Failed to delete secret"))}var Tc={list:on,set:an,delete:cn};async function Ic(e,t,r){let n=e;for(;n.endsWith("/");)n=n.slice(0,-1);let s=await C(`${n}/kortix/triggers${t}`,{...r,headers:{"Content-Type":"application/json",...r?.headers}}),l=await s.json();if(!s.ok)throw new Error(l?.error||l?.message||`Request failed with ${s.status}`);return l}function re(e){let t=e.length;for(;t>0&&e.charCodeAt(t-1)===47;)t--;return t===e.length?e:e.slice(0,t)}async function st(e,t){let r=await e.json().catch(()=>({}));return r?.error||r?.message||e.statusText||t}function $e(e){if(!e)throw new Error("[kortix-pty] Server URL not ready \u2014 sandbox is still loading");return re(e)}async function ln(e){let t=$e(e),r=await C(`${t}/kortix/pty`);if(!r.ok)throw new Error(await st(r,"Failed to list terminals"));return r.json()}async function un(e,t){let r=$e(e),n=await C(`${r}/kortix/pty`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t??{})});if(!n.ok)throw new Error(await st(n,"Failed to create terminal"));return n.json()}async function pn(e,t,r){let n=$e(e),s=await C(`${n}/kortix/pty/${encodeURIComponent(t)}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify(r)});if(!s.ok)throw new Error(await st(s,"Failed to update terminal"));return s.json()}async function dn(e,t){let r=$e(e),n=await C(`${r}/kortix/pty/${encodeURIComponent(t)}`,{method:"DELETE"});if(!n.ok)throw new Error(await st(n,"Failed to remove terminal"))}async function gn(e,t){let r=$e(t),s=`${(()=>{try{let d=new URL(r);return d.protocol==="https:"?d.protocol="wss:":d.protocol==="http:"&&(d.protocol="ws:"),typeof window<"u"&&window.location.protocol==="https:"&&d.protocol==="ws:"&&(d.protocol="wss:"),re(d.toString())}catch{return r.replace("https://","wss://").replace("http://","ws://")}})()}/kortix/pty/${encodeURIComponent(e)}/connect`,l=await Ae();if(!l)return s;let u=s.includes("?")?"&":"?";return`${s}${u}token=${encodeURIComponent(l)}`}var jc={list:ln,create:un,update:pn,remove:dn,webSocketUrl:gn};async function b(e,t,r,n){let s=e;for(;s.endsWith("/");)s=s.slice(0,-1);let l=await C(`${s}${t}`,{...r,headers:{"Content-Type":"application/json",...r?.headers}},n),u=await l.text(),d={};try{d=u?JSON.parse(u):{}}catch{d={}}if(!l.ok)throw new Error(d?.error||d?.message||d?.details||u.slice(0,200)||`Request failed with ${l.status}`);return d}async function gu(e,t={}){let r=new URLSearchParams;t.projectId&&r.set("project_id",t.projectId),t.status&&r.set("status",t.status);let n=r.toString()?`?${r}`:"";return b(e,`/kortix/tasks${n}`)}async function mu(e,t){return b(e,`/kortix/tasks/${encodeURIComponent(t)}`)}async function fu(e,t){return b(e,`/kortix/tasks/${encodeURIComponent(t)}/events`)}async function yu(e,t){return b(e,`/kortix/tasks/${encodeURIComponent(t)}/status`)}async function hu(e,t){return b(e,"/kortix/tasks",{method:"POST",body:JSON.stringify(t)})}async function bu(e,t,r){return b(e,`/kortix/tasks/${encodeURIComponent(t)}`,{method:"PATCH",body:JSON.stringify(r)})}async function xu(e,t){return b(e,`/kortix/tasks/${encodeURIComponent(t)}/start`,{method:"POST"})}async function ku(e,t){return b(e,`/kortix/tasks/${encodeURIComponent(t)}/approve`,{method:"POST"})}async function Pu(e,t){return b(e,`/kortix/tasks/${encodeURIComponent(t)}`,{method:"DELETE"})}async function _u(e,t){let r=t?`?project_id=${encodeURIComponent(t)}`:"";return b(e,`/kortix/tickets${r}`)}async function wu(e,t){return b(e,`/kortix/tickets/${encodeURIComponent(t)}`)}async function Su(e,t){return b(e,`/kortix/tickets/${encodeURIComponent(t)}/events`)}async function Ru(e,t){return b(e,"/kortix/tickets",{method:"POST",body:JSON.stringify(t)})}async function vu(e,t,r){return b(e,`/kortix/tickets/${encodeURIComponent(t)}`,{method:"PATCH",body:JSON.stringify(r)})}async function Cu(e,t,r){return b(e,`/kortix/tickets/${encodeURIComponent(t)}/status`,{method:"POST",body:JSON.stringify(r)})}async function Tu(e,t,r){return b(e,`/kortix/tickets/${encodeURIComponent(t)}/assign`,{method:"POST",body:JSON.stringify(r)})}async function Iu(e,t,r){return b(e,`/kortix/tickets/${encodeURIComponent(t)}/unassign`,{method:"POST",body:JSON.stringify(r)})}async function ju(e,t,r){return b(e,`/kortix/tickets/${encodeURIComponent(t)}/comments`,{method:"POST",body:JSON.stringify(r)})}async function Au(e,t){return b(e,`/kortix/tickets/${encodeURIComponent(t)}`,{method:"DELETE"})}async function Eu(e,t){return b(e,`/kortix/projects/${encodeURIComponent(t)}/columns`)}async function $u(e,t,r){return b(e,`/kortix/projects/${encodeURIComponent(t)}/columns`,{method:"PUT",body:JSON.stringify({columns:r})})}async function qu(e,t){return b(e,`/kortix/projects/${encodeURIComponent(t)}/fields`)}async function Du(e,t,r){return b(e,`/kortix/projects/${encodeURIComponent(t)}/fields`,{method:"PUT",body:JSON.stringify({fields:r})})}async function Mu(e,t){return b(e,`/kortix/projects/${encodeURIComponent(t)}/templates`)}async function Uu(e,t,r){return b(e,`/kortix/projects/${encodeURIComponent(t)}/templates`,{method:"PUT",body:JSON.stringify({templates:r})})}async function Ou(e,t){return b(e,`/kortix/projects/${encodeURIComponent(t)}/pm-session`,{method:"POST"})}async function Lu(e,t){return b(e,`/kortix/projects/${encodeURIComponent(t)}/agents`)}async function Fu(e,t,r){return b(e,`/kortix/projects/${encodeURIComponent(t)}/agents`,{method:"POST",body:JSON.stringify(r)})}async function Bu(e,t,r,n){return b(e,`/kortix/projects/${encodeURIComponent(t)}/agents/${encodeURIComponent(r)}`,{method:"PATCH",body:JSON.stringify(n)})}async function Gu(e,t,r){return b(e,`/kortix/projects/${encodeURIComponent(t)}/agents/${encodeURIComponent(r)}`,{method:"DELETE"})}async function Ku(e,t,r){return b(e,`/kortix/projects/${encodeURIComponent(t)}/agents/${encodeURIComponent(r)}/persona`)}async function Nu(e,t,r=200){return b(e,`/kortix/projects/${encodeURIComponent(t)}/activity?limit=${r}`)}async function Hu(e){return b(e,"/kortix/projects")}async function Wu(e,t){return b(e,`/kortix/projects/${encodeURIComponent(t)}`)}async function Vu(e,t){return b(e,`/kortix/projects/by-session/${encodeURIComponent(t)}`)}async function zu(e,t){return b(e,`/kortix/projects/${encodeURIComponent(t)}/sessions`)}async function Ju(e,t){return b(e,`/kortix/projects/${encodeURIComponent(t)}`,{method:"DELETE"})}async function Xu(e,t,r){return b(e,`/kortix/projects/${encodeURIComponent(t)}`,{method:"PATCH",body:JSON.stringify(r)})}async function Qu(e,t,r="all"){return b(e,`/kortix/projects/${encodeURIComponent(t)}/milestones?status=${r}`)}async function Yu(e,t,r){return b(e,`/kortix/projects/${encodeURIComponent(t)}/milestones/${encodeURIComponent(r)}`)}async function Zu(e,t,r){return b(e,`/kortix/projects/${encodeURIComponent(t)}/milestones/${encodeURIComponent(r)}/events`)}async function ep(e,t,r){return b(e,`/kortix/projects/${encodeURIComponent(t)}/milestones`,{method:"POST",body:JSON.stringify(r)})}async function tp(e,t,r,n){return b(e,`/kortix/projects/${encodeURIComponent(t)}/milestones/${encodeURIComponent(r)}`,{method:"PATCH",body:JSON.stringify(n)})}async function rp(e,t,r,n){return b(e,`/kortix/projects/${encodeURIComponent(t)}/milestones/${encodeURIComponent(r)}/close`,{method:"POST",body:JSON.stringify(n)})}async function np(e,t,r){return b(e,`/kortix/projects/${encodeURIComponent(t)}/milestones/${encodeURIComponent(r)}/reopen`,{method:"POST"})}async function sp(e,t,r){return b(e,`/kortix/projects/${encodeURIComponent(t)}/milestones/${encodeURIComponent(r)}`,{method:"DELETE"})}async function ip(e,t){return b(e,`/kortix/projects/${encodeURIComponent(t)}/credentials`)}async function op(e,t,r){return b(e,`/kortix/projects/${encodeURIComponent(t)}/credentials/${encodeURIComponent(r)}/events`)}async function ap(e,t,r){return b(e,`/kortix/projects/${encodeURIComponent(t)}/credentials`,{method:"POST",body:JSON.stringify(r)})}async function cp(e,t,r){return b(e,`/kortix/projects/${encodeURIComponent(t)}/credentials/${encodeURIComponent(r)}`)}async function lp(e,t,r){return b(e,`/kortix/projects/${encodeURIComponent(t)}/credentials/${encodeURIComponent(r)}`,{method:"DELETE"})}var up=1e4,pp={retryOnAuthError:!1};function fe(e,t,r){return b(e,t,{signal:AbortSignal.timeout(up),...r},pp)}async function dp(e,t=!1){return(await fe(e,`/kortix/services${t?"?all=true":""}`)).services??[]}async function gp(e){return(await fe(e,"/kortix/services/templates")).templates??[]}async function mp(e,t){return(await fe(e,`/kortix/services/${encodeURIComponent(t)}/logs`)).logs??[]}async function fp(e,t,r){let n=r==="delete",s=n?`/kortix/services/${encodeURIComponent(t)}`:`/kortix/services/${encodeURIComponent(t)}/${r}`;return fe(e,s,{method:n?"DELETE":"POST"})}async function yp(e,t){return fe(e,`/kortix/services/reconcile${t?"?reload=true":""}`,{method:"POST"})}async function hp(e,t){return fe(e,"/kortix/services/register",{method:"POST",body:JSON.stringify(t)})}var it=new Map,ot=class extends Error{constructor(t="[opencode-sdk] Server URL not ready \u2014 sandbox is still loading"){super(t),this.name="RuntimeNotReadyError"}};function X(){let e=$();if(!e)throw new ot;return ne(e)}function ne(e){if(!e)throw new Error("[opencode-sdk] getClientForUrl called without a url");let t=it.get(e);if(t)return t;if(!Qe())throw new Error("[opencode-sdk] No auth token provider configured \u2014 call configureKortix()/createKortix() before talking to a sandbox runtime.");let r=en({baseUrl:e,fetch:C});return it.set(e,r),r}function bp(e){it.delete(e)}function xp(){it.clear()}var at=new Map;function kp(e){if(!e)throw new Error("[opencode-sdk] getPublicClientForUrl called without a url");let t=at.get(e);if(t)return t;let r=en({baseUrl:e,fetch});return at.set(e,r),r}function Pp(e){at.delete(e)}function _p(){at.clear()}async function wp(e){let t=await e.text().catch(()=>"");try{let r=JSON.parse(t);return r?.error||r?.message||t||e.statusText||`HTTP ${e.status}`}catch{return t||e.statusText||`HTTP ${e.status}`}}async function Sp(e){let t=$();if(!t)throw new v("[opencode-sdk] Server URL not ready \u2014 sandbox is still loading",{code:"RUNTIME_UNAVAILABLE"});let r=await C(`${t}/kortix/services/system/reload`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({mode:e})});if(!r.ok)throw new v(`System reload failed (${r.status}): ${await wp(r)}`,{status:r.status,response:r,code:"RUNTIME_UNAVAILABLE"});return r.json()}function Ec(e){if(e.error){let t=e.error,r=t?.data?.message||t?.message||(typeof t?.error=="string"?t.error:null)||"SDK request failed";throw new v(r,{status:t?.response?.status??t?.status,response:t?.response,details:t})}return e.data}async function ye(e){let t=await e.text().catch(()=>""),r=null;try{r=JSON.parse(t)}catch{}return r?.error||t||e.statusText||`HTTP ${e.status}`}async function ct(e,t=$()){let r=await C(`${t}${e}`);if(!r.ok)throw new v(await ye(r),{status:r.status,response:r});return r.json()}var $c=["/workspace","/tmp","/home","/opt"],Rp=$c.filter(e=>e!=="/workspace");function vp(e){return $c.some(t=>e===t||e.startsWith(`${t}/`))}function Cp(e){return vp(e)?e:`/workspace/${e.replace(/^\/+/,"")}`}function De(e){let t=e||"";if(t==="/workspace"||t==="/workspace/")return"";if(t.startsWith("/workspace/"))t=t.slice(11);else if(Rp.some(r=>t===r||t.startsWith(`${r}/`)))return t;for(;t.startsWith("/");)t=t.slice(1);return t}var Tp=De;async function mn(e,t=$()){let r=De(e)||".";return(await ct(`/file?path=${encodeURIComponent(r)}`,t)).map(s=>({...s,path:s.absolute||`/workspace/${s.path}`}))}async function lt(e,t=$()){let r=De(e),n=await C(`${t}/file/content?path=${encodeURIComponent(r)}`);if(!n.ok)throw new v(await ye(n),{status:n.status,response:n});return n.json()}async function Ip(e,t,r=$()){let n=De(e),s=await C(`${r}/file/raw?path=${encodeURIComponent(n)}`);if(!s.ok)throw new v(await ye(s),{status:s.status,response:s});if((s.headers.get("content-type")||"").includes("text/html"))throw new v("File could not be loaded (raw byte route unavailable)",{status:s.status,response:s,code:"INVALID_CONTENT_TYPE"});let l=await s.blob();return t&&(!l.type||l.type==="application/octet-stream")?new Blob([l],{type:t}):l}async function ut(e,t=$()){try{return await Ip(e,void 0,t)}catch{}let r=await lt(e,t);if(r.encoding==="base64"&&r.content){let n=Uint8Array.from(atob(r.content),s=>s.charCodeAt(0));return new Blob([n],{type:r.mimeType||"application/octet-stream"})}return new Blob([r.content??""],{type:r.mimeType||"text/plain;charset=utf-8"})}function fn(e=$()){return ct("/file/status",e)}async function yn(e,t,r=$()){let n=new URLSearchParams({query:e});return t?.type&&n.set("type",t.type),t?.limit&&n.set("limit",String(t.limit)),ct(`/find/file?${n.toString()}`,r)}async function hn(e,t=$()){return(await ct(`/find?pattern=${encodeURIComponent(e)}`,t)).map(n=>({path:typeof n.path=="string"?n.path:n.path?.text??"",lines:typeof n.lines=="string"?n.lines:n.lines?.text??"",line_number:n.line_number,absolute_offset:n.absolute_offset,submatches:(n.submatches??[]).map(s=>({start:s.start,end:s.end}))}))}var qe=[400,1200],jp=e=>e===408||e===429||e===502||e===503||e===504,Ac=e=>new Promise(t=>setTimeout(t,e));async function Ap(e){let t=await e.text().catch(()=>""),r=null;try{r=t?JSON.parse(t):null}catch{}let n=r?.error||r?.message||r?.data?.message;return typeof n=="string"&&n.trim()?n.trim():(e.headers.get("content-type")||"").includes("text/html")||/<html[\s>]/i.test(t)?e.status===502||/bad gateway/i.test(t)?"Bad gateway while reaching the sandbox upload service. Please retry.":e.statusText||`HTTP ${e.status}`:t.replace(/\s+/g," ").trim().slice(0,500)||e.statusText||`HTTP ${e.status}`}async function qc(e,t){let r;for(let s=0;s<=qe.length;s++){let l;try{l=await t(e())}catch(d){if(r=d,s===qe.length)break;await Ac(qe[s]);continue}if(l.ok)return l.json();let u=await Ap(l);if(r=new v(`Upload failed (${l.status}): ${u}`,{status:l.status,response:l}),!jp(l.status)||s===qe.length)throw r;await Ac(qe[s])}if(r instanceof v)throw r;let n=r instanceof Error?r.message:String(r||"request failed");throw new v(`Upload failed: ${n}`)}function pt(e,t,r,n=$()){return qc(()=>{let s=new FormData,l=(t??"").trim();return l&&s.append("path",l.startsWith("/")?l:`/${l}`),r?s.append("file",e,r):s.append("file",e),s},s=>C(`${n}/file/upload`,{method:"POST",body:s}))}function Ep(e,t,r=$()){return qc(()=>{let n=new FormData;return n.append(e,t,e.split("/").pop()||"file"),n},async n=>{let s={},l=await Ae();return l&&(s.Authorization=`Bearer ${l}`),fetch(`${r}/file/upload`,{method:"POST",body:n,headers:s})})}function bn(e,t=$()){let r=e.trim(),s=(r.startsWith("/")?r:`/${r}`).split("/"),l=s.pop()||"untitled",u=s.join("/")||"/workspace";return pt(new File([" "],l,{type:"application/octet-stream"}),u,void 0,t)}async function xn(e,t,r=$()){return Ep(t,await ut(e,r),r)}async function kn(e,t=$()){let r=await C(`${t}/file`,{method:"DELETE",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:e})});if(!r.ok)throw new v(`Delete failed (${r.status}): ${await ye(r)}`,{status:r.status,response:r});return r.json()}async function Pn(e,t=$()){let r=await C(`${t}/file/mkdir`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:e})});if(!r.ok)throw new v(`Mkdir failed (${r.status}): ${await ye(r)}`,{status:r.status,response:r});return r.json()}async function _n(e,t,r=$()){let n=await C(`${r}/file/rename`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({from:e,to:t})});if(!n.ok)throw new v(`Rename failed (${n.status}): ${await ye(n)}`,{status:n.status,response:n});return n.json()}async function $p(){return Ec(await X().project.current())}async function Dc(){return Ec(await X().global.health())}async function qp(){try{return(await Dc()).healthy===!0}catch{return!1}}var Mc={list:mn,read:lt,readBlob:ut,status:fn,findFiles:yn,findText:hn,upload:pt,create:bn,copy:xn,remove:kn,mkdir:Pn,rename:_n,currentProject:$p,health:Dc,isReachable:qp,toDaemonPath:De,toSandboxAbsolutePath:Cp,toWorkspaceRelative:Tp};var Q=()=>T().backendUrl||"",wn=!1;function Mp(e){wn=e}function Up(){return wn}async function se(e,t={}){let{showErrors:r=!0,errorContext:n,timeout:s=3e4,...l}=t,u=new AbortController,d=null,g=!1,h=!1;try{d=setTimeout(()=>{!g&&!u.signal.aborted&&(g=!0,h=!0,u.abort())},s);let m=await ue(),x=l.body instanceof FormData,k={};if(x||(k["Content-Type"]="application/json"),Object.assign(k,l.headers),wn&&(k["x-kortix-admin-bypass"]="1"),m)k.Authorization=`Bearer ${m}`;else return{error:new de,success:!1};let _=await fetch(e,{...l,headers:k,signal:u.signal,credentials:l.credentials??"omit"});if(d&&(clearTimeout(d),d=null),!_.ok){let P=`HTTP ${_.status}: ${_.statusText}`,w=null;try{w=await _.json(),w.message?P=w.message:w.error&&typeof w.error=="string"?P=w.error:typeof w.detail=="string"?P=w.detail:w.detail?.message&&(P=w.detail.message)}catch{}let M=new v(P,{status:_.status,response:_,details:w||void 0,data:w,detail:w?.detail,code:w?.code||w?.error_code||w?.detail?.error_code||_.status.toString()});return _.status===402&&(M=me(M)),_.status===431&&(M=new ge(431,{message:"Request is too large to process",suggestion:"Try uploading files one at a time, or reduce the number of files attached to your message."})),r&&T().onError?.(M,n),{error:M,success:!1}}let c,i=_.headers.get("content-type");return i?.includes("application/json")?c=await _.json():i?.includes("text/")?c=await _.text():c=await _.blob(),{data:c,success:!0}}catch(m){d&&(clearTimeout(d),d=null);let x=m?.name==="AbortError"||m?.name==="AbortSignal"||m instanceof Error&&m.message.includes("aborted");x&&(g=!0);let k;if(x){if(!h)return{error:new v("Request aborted",{name:"AbortError",code:"ABORTED"}),success:!1};let _=e.replace(Q(),"")||e;k=new v(`Request timed out after ${Math.round(s/1e3)}s: ${_}`,{code:"TIMEOUT",url:e,endpoint:_,timeout:s}),r&&T().onError?.(k,n)}else m instanceof Error?(k=new v(m.message,{name:m.name||"ApiError",stack:m.stack}),r&&T().onError?.(k,n)):(k=new v(String(m)),r&&T().onError?.(k,n));return{error:k,success:!1}}}var Op={async execute(e,t){try{let{data:r,error:n}=await e();if(n){let s=new v(n.message||"Database error",{code:n.code,details:n});return T().onError?.(s,t),{error:s,success:!1}}return{data:r,success:!0}}catch(r){let n=r instanceof Error?new v(r.message,{name:r.name||"ApiError",stack:r.stack}):new v(String(r));return T().onError?.(n,t),{error:n,success:!1}}}},o={get:(e,t)=>se(`${Q()}${e}`,{...t,method:"GET"}),post:(e,t,r)=>se(`${Q()}${e}`,{...r,method:"POST",body:t?JSON.stringify(t):void 0}),put:(e,t,r)=>se(`${Q()}${e}`,{...r,method:"PUT",body:t?JSON.stringify(t):void 0}),patch:(e,t,r)=>se(`${Q()}${e}`,{...r,method:"PATCH",body:t?JSON.stringify(t):void 0}),delete:(e,t)=>se(`${Q()}${e}`,{...t,method:"DELETE"}),upload:(e,t,r)=>{let{headers:n,...s}=r||{},l={...n};return delete l["Content-Type"],se(`${Q()}${e}`,{...s,method:"POST",body:t,headers:l})},uploadPut:(e,t,r)=>{let{headers:n,...s}=r||{},l={...n};return delete l["Content-Type"],se(`${Q()}${e}`,{...s,method:"PUT",body:t,headers:l})}};function a(e,t="Project request failed"){if(!e.success||e.data===void 0)throw e.error??new Error(t);return e.data}function Sn(e){return e.replace(/\/v1\/?$/,"")}async function he(e,t){if(!e.backendUrl||!e.accessToken)return null;let r=Sn(e.backendUrl);try{let n=await fetch(`${r}${t}`,{headers:{Authorization:`Bearer ${e.accessToken}`,"Content-Type":"application/json"},signal:AbortSignal.timeout(e.timeoutMs??8e3)});return n.ok?await n.json():null}catch{return null}}async function Rn(){return a(await o.get("/accounts"))}async function vn(e){return a(await o.post("/accounts",e))}async function Cn(e){return a(await o.get(`/accounts/${e}`))}async function Tn(e,t){return a(await o.patch(`/accounts/${e}`,{name:t}))}async function In(e){return a(await o.get(`/accounts/${e}/members`))}async function jn(e,t){return a(await o.post(`/accounts/${e}/members`,t,{showErrors:!1}))}async function An(e){return a(await o.get(`/accounts/${e}/invites`))}async function En(e,t){return a(await o.delete(`/accounts/${e}/invites/${t}`))}async function $n(e,t){return a(await o.post(`/accounts/${e}/invites/${t}/resend`,{}))}async function qn(e){return a(await o.get(`/account-invites/${e}`,{showErrors:!1}))}async function Dn(e){return a(await o.post(`/account-invites/${e}/accept`,{}))}async function Mn(e){return a(await o.post(`/account-invites/${e}/decline`,{}))}async function Un(e,t){return a(await o.delete(`/accounts/${e}/members/${t}`))}async function On(e,t,r){return a(await o.patch(`/accounts/${e}/members/${t}`,{role:r}))}async function Ln(e){return a(await o.post(`/accounts/${e}/leave`,{}))}async function Lp(e){return he(e,"/v1/accounts")}async function Fn(){let e=await o.get("/accounts/me",{showErrors:!1});return!e.success||!e.data?{valid:!1,error:e.error}:{valid:!0,identity:e.data}}async function ie(){return a(await o.get("/projects"))}async function Bn(e){let t=e?`?account_id=${encodeURIComponent(e)}`:"";return a(await o.get(`/projects${t}`))}async function dt(e,t){return a(await o.get(`/projects/${e}`,t))}async function Gn(e,t,r="write"){return a(await o.post(`/projects/${e}/git/collaborators`,{github_username:t,permission:r}))}async function Kn(e,t){return a(await o.post(`/projects/${e}/manifest/validate`,{raw:t}),"Failed to validate manifest")}async function Nn(e){return a(await o.post(`/projects/${e}/git-token`,{}),"Failed to mint git token")}function Fp(e){let t=e.metadata?.git;return t?.provider==="github"&&t?.managed===!0}async function gt(e,t){return a(await o.get(`/projects/${e}/detail`,{showErrors:!1,...t}))}async function mt(e,t){return a(await o.get(`/projects/${e}/llm-catalog`,{showErrors:!1,...t}))}async function Hn(e){return a(await o.post("/projects",e))}async function Wn(e){return a(await o.post("/projects/create-repo",e))}async function Vn(e){return a(await o.post("/projects/provision",{seed_starter:!0,...e}))}async function ft(e,t){return a(await o.patch(`/projects/${e}`,t))}async function yt(e,t,r){return a(await o.patch(`/projects/${e}/experimental`,{feature:t,enabled:r}))}async function zn(e,t){return a(await o.patch(`/projects/${e}/sandbox-provider`,{provider:t}))}async function Jn(e,t){return yt(e,"apps",t.enabled)}async function Bp(e,t){return a(await o.patch(`/projects/${e}/warm-pool`,t))}async function Xn(e,t){return a(await o.patch(`/projects/${e}/onboarding`,{completed:t}))}async function ht(e){return a(await o.delete(`/projects/${e}`))}async function Gp(e,t){return he(e,`/v1/projects?account_id=${encodeURIComponent(t)}`)}async function Kp(e,t){if(!e.backendUrl||!e.accessToken)return{ok:!1,limitReached:!1};let r=Sn(e.backendUrl);try{let n=await fetch(`${r}/v1/projects/provision`,{method:"POST",headers:{Authorization:`Bearer ${e.accessToken}`,"Content-Type":"application/json"},body:JSON.stringify({seed_starter:!0,...t}),signal:AbortSignal.timeout(e.timeoutMs??9e4)});if(n.ok){let s=await n.json().catch(()=>null);return s?.project_id?{ok:!0,project:s}:{ok:!1,limitReached:!1}}return n.status===403?{ok:!1,limitReached:(await n.json().catch(()=>null))?.code==="project_limit_reached"}:{ok:!1,limitReached:!1}}catch{return{ok:!1,limitReached:!1}}}async function Qn(e){return a(await o.post("/projects/link-repository",e,{showErrors:!1}))}async function Yn(e){return a(await o.get(`/projects/github/installation?account_id=${encodeURIComponent(e)}`,{showErrors:!1}))}async function Zn(e){return a(await o.get(`/projects/github/installations?account_id=${encodeURIComponent(e)}`,{showErrors:!1}))}async function es(e,t){let r=new URLSearchParams({account_id:e});return t&&r.set("installation_id",t),a(await o.get(`/projects/github/repositories?${r.toString()}`,{showErrors:!1}))}async function ts(e){return a(await o.post("/projects/github/installation",e,{showErrors:!1}))}async function rs(e,t){let r=new URLSearchParams({account_id:e});return t&&r.set("installation_id",t),a(await o.delete(`/projects/github/installation?${r.toString()}`))}async function Np(e,t){return a(await o.post(`/projects/${e}/access-requests`,{message:t?.trim()||void 0},{showErrors:!1}))}async function ns(e,t){return a(await o.get(`/projects/${e}/access-requests`,t))}async function ss(e,t,r="member"){return a(await o.post(`/projects/${e}/access-requests/${t}/approve`,{role:r}))}async function is(e,t){return a(await o.post(`/projects/${e}/access-requests/${t}/reject`,{}))}async function os(e){return a(await o.get(`/projects/${e}/access`))}async function as(e,t,r){return a(await o.put(`/projects/${e}/access/${t}`,{role:r}))}async function cs(e,t){return a(await o.delete(`/projects/${e}/access/${t}`))}function Hp(e){return"status"in e&&e.status==="invited"}async function ls(e,t,r,n){return a(await o.post(`/projects/${e}/access/invite`,{email:t,role:r,...n!==void 0?{expires_at:n}:{}}))}async function us(e){return a(await o.get(`/projects/${e}/access/pending-invites`))}async function ps(e,t){return a(await o.delete(`/projects/${e}/access/pending-invites/${t}`))}async function ds(e,t){return a(await o.post(`/projects/${e}/access/pending-invites/${t}/resend`))}async function gs(e){return a(await o.get(`/projects/${e}/group-grants`))}async function ms(e,t,r,n){return a(await o.post(`/projects/${e}/group-grants`,n===void 0?{group_id:t,role:r}:{group_id:t,role:r,expires_at:n}))}async function fs(e,t,r,n){return a(await o.patch(`/projects/${e}/group-grants/${t}`,n===void 0?{role:r}:{role:r,expires_at:n}))}async function ys(e,t){return a(await o.delete(`/projects/${e}/group-grants/${t}`))}async function hs(e){return a(await o.get(`/projects/${e}/resource-grants`))}async function bs(e,t){return a(await o.post(`/projects/${e}/resource-grants`,{resource_type:t.resourceType,resource_id:t.resourceId,principal_type:t.principalType,principal_id:t.principalId,...t.expiresAt!==void 0?{expires_at:t.expiresAt}:{}}))}async function xs(e,t){return a(await o.delete(`/projects/${e}/resource-grants/${t}`))}async function ks(e,t){return a(await o.get(`/projects/${e}/approvals`,{showErrors:t?.showErrors}))}async function Ps(e,t){return a(await o.get(`/projects/${e}/approvals/needs-input`,{showErrors:t?.showErrors}))}async function _s(e,t,r,n="once"){return a(await o.post(`/projects/${e}/approvals/${t}`,{decision:r,scope:n}))}async function ws(e){return a(await o.get(`/projects/${e}/secrets`,{showErrors:!1}))}async function Ss(e,t){return a(await o.post(`/projects/${e}/secrets`,t))}async function Rs(e,t,r){return a(await o.post(`/projects/${e}/oauth/${t}/start`,{sharing:r?.sharing}))}async function vs(e,t,r){return a(await o.post(`/projects/${e}/oauth/${t}/poll`,{flow_id:r}))}async function Cs(e,t){return a(await o.put(`/projects/${e}/git-credential`,t))}async function Ts(e,t){return a(await o.delete(`/projects/${e}/secrets/${encodeURIComponent(t)}`))}async function Is(e,t,r){return a(await o.put(`/projects/${e}/secrets/${encodeURIComponent(t)}/personal`,r))}async function js(e,t){return a(await o.delete(`/projects/${e}/secrets/${encodeURIComponent(t)}/personal`))}async function As(e){return a(await o.get(`/projects/${e}/connector-profiles`))}async function Es(e,t){return a(await o.post(`/projects/${e}/connector-profiles`,t))}async function $s(e,t,r){return a(await o.put(`/projects/${e}/connector-profiles/${t}/credential`,r))}async function qs(e,t){return a(await o.put(`/projects/${e}/connector-profiles/${t}/revoke`,{}))}async function Ds(e,t){return a(await o.put(`/projects/${e}/connector-profiles/${t}/activate`,{}))}async function Ms(e){return a(await o.get(`/executor/projects/${e}/connectors`,{showErrors:!1}))}async function Us(e){return a(await o.post(`/executor/projects/${e}/connectors/sync`,{}))}async function Os(e,t,r){return a(await o.put(`/executor/projects/${e}/connectors/${encodeURIComponent(t)}/credential-mode`,{mode:r}))}async function Ls(e,t,r){return a(await o.put(`/executor/projects/${e}/connectors/${encodeURIComponent(t)}/sensitive`,{sensitive:r}))}async function Fs(e,t){return a(await o.get(`/executor/projects/${e}/connectors/${encodeURIComponent(t)}/policies`))}async function Bs(e,t,r){return a(await o.put(`/executor/projects/${e}/connectors/${encodeURIComponent(t)}/policies`,{policies:r}))}async function Gs(e,t){return a(await o.get(`/executor/projects/${e}/connectors/${encodeURIComponent(t)}/config`))}async function Ks(e,t,r){return a(await o.put(`/executor/projects/${e}/connectors/${encodeURIComponent(t)}/name`,{name:r}))}async function Ns(e,t){return a(await o.post(`/executor/projects/${e}/connectors/${encodeURIComponent(t)}/connect`,{}))}async function Hs(e,t){return a(await o.post(`/executor/projects/${e}/connectors`,t))}async function Ws(e,t){return a(await o.delete(`/executor/projects/${e}/connectors/${encodeURIComponent(t)}`))}async function Vs(e,t,r){let n=new URLSearchParams;t&&n.set("q",t),r&&n.set("cursor",r);let s=n.toString();return a(await o.get(`/executor/projects/${e}/pipedream/apps${s?`?${s}`:""}`))}async function zs(){return a(await o.get("/executor/connect-status"))}async function Js(e,t,r){return a(await o.put(`/executor/projects/${e}/connectors/${encodeURIComponent(t)}/credential`,{value:r}))}async function Xs(e,t){return a(await o.post(`/executor/projects/${e}/connectors/${encodeURIComponent(t)}/connect/finalize`,{}))}async function Qs(e){return a(await o.get(`/executor/projects/${e}/policies`))}async function Ys(e,t,r){return a(await o.put(`/executor/projects/${e}/policies`,{policies:t,defaultMode:r}))}async function Zs(e){return a(await o.get(`/projects/${e}/sandboxes`))}async function ei(e){return a(await o.get(`/projects/${e}/snapshots`))}async function bt(e){return a(await o.get(`/projects/${e}/sandbox-health`,{showErrors:!1,timeout:15e3}))}async function ti(e,t){return a(await o.post(`/projects/${e}/snapshots/rebuild`,t?{slug:t}:{}))}async function ri(e){return a(await o.post(`/projects/${e}/snapshots/fix-with-agent`,{}))}async function ni(e,t){return a(await o.post(`/projects/${e}/sandbox-templates`,t))}async function si(e,t,r){return a(await o.patch(`/projects/${e}/sandbox-templates/${t}`,r))}async function ii(e,t){return a(await o.delete(`/projects/${e}/sandbox-templates/${t}`))}async function oi(e,t){return a(await o.post(`/projects/${e}/sandbox-templates/${t}/build`,{}))}async function ai(e){return a(await o.get(`/projects/${e}/sandboxes`))}async function ci(e,t){let r=new URLSearchParams;t?.ref&&r.set("ref",t.ref),t?.path&&r.set("path",t.path);let n=r.toString()?`?${r.toString()}`:"";return a(await o.get(`/projects/${e}/files${n}`,{showErrors:!1}))}async function li(e,t,r){let n=new URLSearchParams({q:t});return r?.content&&n.set("content","1"),r?.ref&&n.set("ref",r.ref),r?.limit&&n.set("limit",String(r.limit)),a(await o.get(`/projects/${e}/files/search?${n.toString()}`))}async function ui(e,t,r){let n=new URLSearchParams({path:t});return r&&n.set("ref",r),a(await o.get(`/projects/${e}/files/content?${n.toString()}`))}async function pi(e,t,r){let n=new URLSearchParams;t&&n.set("ref",t),r&&n.set("path",r);let s=n.toString()?`?${n.toString()}`:"",l=await ue(),u=`${T().backendUrl||""}/projects/${e}/files/archive${s}`,d=await fetch(u,{method:"GET",headers:l?{Authorization:`Bearer ${l}`}:{}});if(!d.ok){let g=await d.text().catch(()=>"");throw new Error(g||`Failed to download (HTTP ${d.status})`)}return await d.blob()}async function di(e){return a(await o.get(`/projects/${e}/branches`))}async function gi(e,t){let r=new URLSearchParams;t?.ref&&r.set("ref",t.ref),t?.path&&r.set("path",t.path),t?.limit!=null&&r.set("limit",String(t.limit)),t?.skip!=null&&r.set("skip",String(t.skip));let n=r.toString()?`?${r.toString()}`:"";return a(await o.get(`/projects/${e}/commits${n}`))}async function mi(e,t){return a(await o.get(`/projects/${e}/commits/${encodeURIComponent(t)}`))}async function fi(e,t,r){let n=new URLSearchParams;r?.path&&n.set("path",r.path);let s=n.toString()?`?${n.toString()}`:"";return a(await o.get(`/projects/${e}/commits/${encodeURIComponent(t)}/diff${s}`))}async function yi(e,t,r){let n=new URLSearchParams({path:t});return r?.ref&&n.set("ref",r.ref),r?.limit!=null&&n.set("limit",String(r.limit)),r?.skip!=null&&n.set("skip",String(r.skip)),a(await o.get(`/projects/${e}/files/history?${n.toString()}`))}async function hi(e,t){let r=new URLSearchParams({from:t.from,into:t.into});return a(await o.get(`/projects/${e}/version-diff?${r.toString()}`))}async function bi(e,t){let r=t?`?status=${t}`:"";return a(await o.get(`/projects/${e}/change-requests${r}`,{showErrors:!1,timeout:15e3}))}async function xi(e,t){return a(await o.get(`/projects/${e}/change-requests/${t}`))}async function ki(e,t){return a(await o.get(`/projects/${e}/change-requests/${t}/diff`))}async function Pi(e,t){return a(await o.get(`/projects/${e}/change-requests/${t}/merge-preview`))}async function _i(e,t){return a(await o.post(`/projects/${e}/change-requests`,t))}async function wi(e,t,r){return a(await o.post(`/projects/${e}/change-requests/${t}/merge`,r??{},{showErrors:!1}))}async function Si(e,t){return a(await o.post(`/projects/${e}/change-requests/${t}/close`,{}))}async function Ri(e,t){return a(await o.post(`/projects/${e}/change-requests/${t}/reopen`,{}))}async function vi(e,t,r){return a(await o.post(`/projects/${e}/change-requests/${t}/request-changes`,{feedback:r}))}async function Ci(e,t,r){return a(await o.post(`/projects/${e}/sessions/${t}/commit-push`,r??{}))}var Ti=new Set;function Ii(e){e&&Ti.add(e)}function ji(e){return!!e&&Ti.has(e)}function Wp(e){e&&Ti.delete(e)}async function be(e){return a(await o.get(`/projects/${e}/sessions`))}async function Ai(e,t,r){return a(await o.put(`/projects/${e}/sessions/${t}/sharing`,r))}async function Ei(e,t){return a(await o.get(`/projects/${e}/sessions/${t}/previews`))}async function $i(e,t){return a(await o.get(`/projects/${e}/sessions/${t}/public-shares`,{showErrors:!1}))}async function qi(e,t,r){return a(await o.post(`/projects/${e}/sessions/${t}/public-shares`,r))}async function Di(e,t,r){return a(await o.delete(`/projects/${e}/sessions/${t}/public-shares/${r}`))}async function xe(e,t){let r=a(await o.post(`/projects/${e}/sessions`,t??{}));return t?.initial_prompt||Ii(r?.session_id),r}async function Mi(e,t,r){return a(await o.get(`/projects/${e}/sessions/${t}`,{showErrors:r?.showErrors}))}async function Ui(e,t,r,n){let s=r?`?limit=${r}`:"";return a(await o.get(`/projects/${e}/sessions/${t}/audit${s}`,{showErrors:n?.showErrors}))}async function Oi(e,t,r){let n=new URLSearchParams;r?.limit!=null&&n.set("limit",String(r.limit)),r?.chars!=null&&n.set("chars",String(r.chars));let s=n.toString();return a(await o.get(`/projects/${e}/sessions/${t}/transcript${s?`?${s}`:""}`))}async function Li(e,t,r){return a(await o.patch(`/projects/${e}/sessions/${t}`,r))}async function Fi(e,t){return a(await o.delete(`/projects/${e}/sessions/${t}`))}async function Me(e,t){return a(await o.post(`/projects/${e}/sessions/${t}/restart`,{}))}async function Ue(e,t){return a(await o.post(`/projects/${e}/sessions/${t}/stop`,{}))}async function Bi(e){return a(await o.get(`/projects/${e}/triggers`))}async function Gi(e,t){return a(await o.post(`/projects/${e}/triggers`,t))}async function Ki(e,t,r){return a(await o.patch(`/projects/${e}/triggers/${t}`,r))}async function Ni(e,t){return a(await o.delete(`/projects/${e}/triggers/${t}`))}async function Hi(e,t){return a(await o.patch(`/projects/${e}/triggers/activation`,{paused:t}))}async function Wi(e,t){return a(await o.post(`/projects/${e}/triggers/${t}/fire`,{}))}var Y=new Map;function Vi(e,t){return`${e}::${t}`}function Uc(e,t){Y.delete(e),Y.set(e,t)}function Oc(e,t){let r=Vi(e,t),n=Y.get(r);return n&&Uc(r,n),n}function Lc(e,t,r){let n=Vi(e,t);if(!Y.has(n)&&Y.size>=512){let s=Y.keys().next().value;s!==void 0&&Y.delete(s)}Uc(n,r)}function Fc(e,t){Y.delete(Vi(e,t))}var xt=class extends Error{status;code;terminal;constructor(t,r){super(t),this.name="SessionStartError",this.status=r.status,this.code=r.code,this.terminal=r.terminal}};function Vp(e){return e instanceof Error&&e.name==="SessionStartError"}function zp(e){let t=e,r=t?.status,n=t?.code??t?.details?.code??t?.details?.error,s=t?.message||"Unable to start this session";return r&&r>=400&&r<500&&r!==408&&r!==429?new xt(s,{status:r,code:n,terminal:!0}):null}async function ke(e,t,r){let n=r&&r>0?`?wait_ms=${Math.floor(r)}`:"",s=await o.post(`/projects/${e}/sessions/${t}/start${n}`,{},{showErrors:!1});if(!s.success||!s.data){let d=zp(s.error);if(d&&!(d.status===404&&ji(t)))throw d;return null}let l=s.data,u=l.sandbox?.external_id;return l.stage==="ready"&&u&&l.opencode_session_id&&Lc(e,t,{opencodeSessionId:l.opencode_session_id,runtimeUrl:nt(u),sandboxId:u}),l}function Jp(e,t){return["session-start",e,t]}async function zi(e){return a(await o.get(`/projects/${e}/model-defaults`))}async function Ji(e,t){return a(await o.put(`/projects/${e}/model-defaults`,t))}async function Xi(e,t){let r=new URLSearchParams({scope:t.scope,...t.agentName?{agentName:t.agentName}:{}}).toString();return a(await o.delete(`/projects/${e}/model-defaults?${r}`))}async function Qi(e,t,r){return a(await o.put(`/projects/${e}/agents/${encodeURIComponent(t)}/scope`,r))}async function Xp(e,t){return a(await o.get(`/projects/${e}/agents/${encodeURIComponent(t)}/config`))}async function Qp(e,t,r){return a(await o.put(`/projects/${e}/agents/${encodeURIComponent(t)}/config`,r))}async function Yi(e,t){return a(await o.put(`/projects/${e}/default-agent`,{agent:t}))}function Zi(){return{credits:{total:0,daily:0,monthly:0,extra:0,can_run:!1,daily_refresh:null},subscription:{tier_key:"none",tier_display_name:"No Plan",status:"no_subscription",billing_period:null,provider:"stripe",subscription_id:null,current_period_end:null,cancel_at_period_end:!1,is_cancelled:!1,cancellation_effective_date:null,has_scheduled_change:!1,scheduled_change:null,commitment:{has_commitment:!1,can_cancel:!0,commitment_type:null,months_remaining:null,commitment_end_date:null},can_purchase_credits:!1},models:[],limits:{concurrent_runs:{running_count:0,limit:0,can_start:!1,tier_name:"none"},ai_worker_count:{current_count:0,limit:0,can_create:!1,tier_name:"none"},custom_mcp_count:{current_count:0,limit:0,can_create:!1,tier_name:"none"}},tier:{name:"none",display_name:"No Plan",monthly_credits:0,can_purchase_credits:!1}}}async function eo(e){let t=new URLSearchParams;e?.skipCache&&t.set("skip_cache","true"),e?.accountId&&t.set("account_id",e.accountId);let r=t.toString(),n=r?`?${r}`:"",s=await o.get(`/billing/account-state${n}`,{showErrors:!1}),l=s.error?.status===404&&/billing is not enabled/i.test(s.error.message||"");if(s.error&&s.error.status!==401&&!l)throw s.error;return s.error?Zi():s.data}async function to(e){let t=new URLSearchParams;e?.skipCache&&t.set("skip_cache","true"),e?.accountId&&t.set("account_id",e.accountId);let r=t.toString(),n=r?`?${r}`:"",s=await o.get(`/billing/account-state/minimal${n}`,{showErrors:!1}),l=s.error?.status===404&&/billing is not enabled/i.test(s.error.message||"");if(s.error&&s.error.status!==401&&!l)throw s.error;return s.error?Zi():s.data}async function ro(e){let t=new URLSearchParams;e?.accountId&&t.set("account_id",e.accountId),e?.limit!=null&&t.set("limit",String(e.limit)),e?.offset!=null&&t.set("offset",String(e.offset)),e?.typeFilter&&t.set("type_filter",Array.isArray(e.typeFilter)?e.typeFilter.join(","):e.typeFilter);let r=t.toString();return a(await o.get(`/billing/transactions${r?`?${r}`:""}`))}async function no(e){let t=new URLSearchParams;e?.accountId&&t.set("account_id",e.accountId),e?.days!=null&&t.set("days",String(e.days));let r=t.toString();return a(await o.get(`/billing/transactions/summary${r?`?${r}`:""}`))}async function so(){return a(await o.get("/billing/credit-breakdown"))}async function io(e){let t=e!=null?`?days=${e}`:"";return a(await o.get(`/billing/usage-history${t}`))}async function oo(){return a(await o.get("/billing/tier-configurations"))}async function Yp(e){let t=e.accountId?`?account_id=${encodeURIComponent(e.accountId)}`:"";return he(e,`/v1/billing/account-state${t}`)}async function ao(e){return a(await o.post("/billing/create-checkout-session",{account_id:e.accountId,tier_key:e.tierKey,success_url:e.successUrl,cancel_url:e.cancelUrl,commitment_type:e.commitmentType,locale:e.locale,server_type:e.serverType,location:e.location}),"Failed to create checkout session")}async function co(e,t){return a(await o.post("/billing/confirm-checkout-session",{account_id:t,session_id:e}),"Failed to confirm checkout session")}async function lo(e,t){return a(await o.post("/billing/create-portal-session",{account_id:t,return_url:e}),"Failed to create portal session")}async function uo(e,t){return a(await o.post("/billing/cancel-subscription",{account_id:t,feedback:e}),"Failed to cancel subscription")}async function po(e){return a(await o.post("/billing/reactivate-subscription",{account_id:e}),"Failed to reactivate subscription")}async function go(e,t,r){return a(await o.post("/billing/schedule-downgrade",{account_id:r,target_tier_key:e,commitment_type:t}),"Failed to schedule downgrade")}async function mo(e){return a(await o.post("/billing/cancel-scheduled-change",{account_id:e}),"Failed to cancel scheduled change")}async function fo(e,t){let r=new URLSearchParams({new_price_id:e});return t&&r.set("account_id",t),a(await o.get(`/billing/proration-preview?${r.toString()}`),"Failed to load proration preview")}async function yo(e){return a(await o.post("/billing/purchase-credits",{amount:e.amount,account_id:e.accountId,success_url:e.successUrl,cancel_url:e.cancelUrl}),"Failed to purchase credits")}async function ho(e){let t=e?`?account_id=${encodeURIComponent(e)}`:"";return a(await o.get(`/billing/auto-topup/settings${t}`),"Failed to load auto-topup settings")}async function bo(e){return a(await o.post("/billing/auto-topup/configure",{account_id:e.accountId,enabled:e.enabled,threshold:e.threshold,amount:e.amount}),"Failed to configure auto-topup")}async function xo(e){let t=await o.get(`/projects/${encodeURIComponent(e)}/channels/slack/installation`,{showErrors:!1});return t.success?t.data??null:null}async function ko(e,t){return a(await o.post(`/projects/${encodeURIComponent(e)}/channels/slack/connect`,t,{showErrors:!1}),"Failed to connect")}var Zp={oauth_available:!1,install_url:null};async function Po(e){let t=await o.get(`/projects/${encodeURIComponent(e)}/channels/slack/mode`,{showErrors:!1});return!t.success||!t.data?Zp:t.data}async function _o(e){return a(await o.get(`/webhooks/slack/${encodeURIComponent(e)}/manifest`,{showErrors:!1}),"Failed to load Slack manifest")}async function wo(e){let t=await o.delete(`/projects/${encodeURIComponent(e)}/channels/slack/installation`,{showErrors:!1});if(!t.success)throw new Error(t.error?.message??"Failed to disconnect")}async function So(e,t){return a(await o.get(`/projects/${encodeURIComponent(e)}/channels/slack/file?url=${encodeURIComponent(t)}`,{showErrors:!1}),"Failed to download Slack file")}async function Ro(e,t){return a(await o.post(`/projects/${encodeURIComponent(e)}/channels/slack/file/upload`,{channel:t.channel,filename:t.filename,content_base64:t.contentBase64,comment:t.comment,thread_ts:t.threadTs},{showErrors:!1}),"Failed to upload Slack file")}function vo(e){return{...e,profileId:e.profileId??e.profile_id??null}}var ed={provider:"agentmail",managed_available:!1};async function Co(e,t){let r=t?`?connector_slug=${encodeURIComponent(t)}`:"",n=await o.get(`/projects/${encodeURIComponent(e)}/channels/email/installation${r}`,{showErrors:!1});return n.success&&n.data?vo(n.data):null}async function To(e){let t=await o.get(`/projects/${encodeURIComponent(e)}/channels/email/mode`,{showErrors:!1});return!t.success||!t.data?ed:t.data}async function Io(e,t){let r=a(await o.post(`/projects/${encodeURIComponent(e)}/channels/email/connect`,t,{showErrors:!1}),"Failed to connect email");return vo(r)}async function jo(e,t){let r=t?`?connector_slug=${encodeURIComponent(t)}`:"",n=await o.delete(`/projects/${encodeURIComponent(e)}/channels/email/installation${r}`,{showErrors:!1});if(!n.success)throw new Error(n.error?.message??"Failed to disconnect email")}async function Ao(e,t,r){let n=a(await o.patch(`/projects/${encodeURIComponent(e)}/channels/email/installation`,{connector_slug:t??"kortix_email",sender_policy:r},{showErrors:!1}),"Failed to update email policy");return vo(n)}async function Eo(e){let t=await o.get(`/projects/${encodeURIComponent(e)}/channels/meet/voices`,{showErrors:!1});return t.success?t.data??null:null}async function $o(e,t){return a(await o.put(`/projects/${encodeURIComponent(e)}/channels/meet/voice`,{voice:t},{showErrors:!1}),"Failed to save voice")}async function qo(e,t){return a(await o.put(`/projects/${encodeURIComponent(e)}/channels/meet/name`,{name:t},{showErrors:!1}),"Failed to save name")}async function Do(e,t){let r=await o.post(`/projects/${encodeURIComponent(e)}/channels/meet/voices/${encodeURIComponent(t)}/preview`,{},{showErrors:!1});return!r.success||!r.data?.b64?null:r.data.b64}async function td(e){return a(await o.get(`/projects/${encodeURIComponent(e)}/channels/bindings`,{showErrors:!1}),"Failed to load channel bindings")}async function rd(e,t,r){return a(await o.patch(`/projects/${encodeURIComponent(e)}/channels/bindings/${encodeURIComponent(t)}`,r,{showErrors:!1}),"Failed to update channel binding")}async function Mo(e,t,r,n){return a(await o.post(`/projects/${encodeURIComponent(e)}/channels/meet/speak`,{bot_id:t,text:r,voice:n},{showErrors:!1}),"Failed to speak in meeting")}async function Uo(e,t){let r=new URLSearchParams;t?.limit&&r.set("limit",String(t.limit)),t?.offset&&r.set("offset",String(t.offset)),t?.ok!==void 0&&r.set("ok",String(t.ok));let n=r.toString();return a(await o.get(`/projects/${e}/gateway/logs${n?`?${n}`:""}`),"Gateway request failed")}async function Oo(e,t){return a(await o.get(`/projects/${e}/gateway/logs/${t}`),"Gateway request failed")}async function Lo(e,t){return a(await o.get(`/projects/${e}/gateway/overview${t?`?days=${t}`:""}`),"Gateway request failed")}async function Fo(e,t){return a(await o.get(`/projects/${e}/gateway/series${t?`?days=${t}`:""}`),"Gateway request failed")}async function Bo(e,t){return a(await o.get(`/projects/${e}/gateway/breakdown${t?`?days=${t}`:""}`),"Gateway request failed")}async function Go(e,t){return a(await o.get(`/projects/${e}/gateway/sessions${t?`?days=${t}`:""}`),"Gateway request failed")}async function Ko(e,t){return a(await o.get(`/projects/${e}/gateway/errors${t?`?days=${t}`:""}`),"Gateway request failed")}async function No(e){return a(await o.get(`/projects/${e}/gateway/budgets`),"Gateway request failed")}async function Ho(e,t){return a(await o.put(`/projects/${e}/gateway/budgets`,t),"Gateway request failed")}async function Wo(e,t){return a(await o.delete(`/projects/${e}/gateway/budgets/${t}`),"Gateway request failed")}async function Vo(e){return a(await o.get(`/projects/${e}/gateway/keys`),"Gateway request failed")}async function zo(e,t){return a(await o.post(`/projects/${e}/gateway/keys`,{name:t}),"Gateway request failed")}async function Jo(e,t){return a(await o.delete(`/projects/${e}/gateway/keys/${t}`),"Gateway request failed")}async function Xo(e,t,r){return a(await o.post(`/projects/${e}/gateway/playground`,{prompt:t,models:r}),"Gateway request failed")}var oe=e=>`/projects/${e}/apps`;async function Qo(e){return a(await o.get(oe(e)))}async function Yo(e,t){return a(await o.post(oe(e),t))}async function Zo(e,t,r){return a(await o.patch(`${oe(e)}/${t}`,r))}async function ea(e,t){return a(await o.delete(`${oe(e)}/${t}`))}async function ta(e,t){return a(await o.post(`${oe(e)}/${t}/deploy`,{}))}async function ra(e,t){return a(await o.post(`${oe(e)}/${t}/stop`,{}))}async function na(e,t){return a(await o.get(`${oe(e)}/${t}/logs`))}async function sa(e){let t=new FormData;t.append("audio_file",e);let r=await o.upload("/transcription",t,{showErrors:!0});if(r.error)throw new Error(`Error transcribing audio: ${r.error.message} (${r.error.status})`);return r.data}async function ia(e,t){let r=new URLSearchParams;t?.segment&&r.set("segment",t.segment),t?.kind&&r.set("kind",t.kind);let n=r.toString();return a(await o.get(`/projects/${e}/review/items${n?`?${n}`:""}`,{showErrors:!1}))}async function oa(e,t){return a(await o.get(`/projects/${e}/review/items/${t}`))}async function aa(e,t){return a(await o.post(`/projects/${e}/review/items`,t))}async function ca(e,t,r){return a(await o.post(`/projects/${e}/review/items/${t}/act`,r))}async function la(e,t){return a(await o.post(`/projects/${e}/review/bulk`,t))}async function ua(e){return a(await o.get(`/p/share?sandbox_id=${encodeURIComponent(e)}`),"Failed to load public links").shares??[]}async function pa(e){return a(await o.post("/p/share",{sandbox_id:e.sandboxId,port:e.port,ttl:e.ttl,label:e.label}),"Failed to generate public URL")}async function da(e,t){let r=await o.delete(`/p/share/${encodeURIComponent(t)}?sandbox_id=${encodeURIComponent(e)}`);if(!r.success)throw new Error(r.error?.message??"Failed to revoke public link")}var kt=class extends Error{constructor(r,n){super(r);this.status=n;this.name="PublicSessionShareError"}status};function Bc(e,t=""){return`${Ee()}/public/session-shares/${encodeURIComponent(e)}${t}`}async function Gc(e){let t=await fetch(e,{method:"GET",headers:{Accept:"application/json"}}),r=await t.text().catch(()=>""),n=null;try{n=r?JSON.parse(r):null}catch{}if(!t.ok){let s=(n&&typeof n=="object"&&"error"in n&&typeof n.error=="string"?n.error:null)||t.statusText||`HTTP ${t.status}`;throw new kt(s,t.status)}return n}async function nd(e){return Gc(Bc(e))}async function sd(e){return Gc(Bc(e,"/messages"))}async function ga(e){let t=e?`?account_id=${encodeURIComponent(e)}`:"";return a(await o.get(`/accounts/tokens${t}`))}async function ma(e){let{accountId:t,expiresAt:r,projectId:n,name:s}=e;return a(await o.post("/accounts/tokens",{name:s,...t?{account_id:t}:{},...r?{expires_at:r}:{},...n?{project_id:n}:{}}))}async function fa(e,t){let r=t?`?account_id=${encodeURIComponent(t)}`:"";return a(await o.delete(`/accounts/tokens/${e}${r}`))}async function ya(e){return a(await o.get(`/projects/${e}/cli-token`))}async function ha(e,t){return a(await o.post(`/projects/${e}/cli-token`,t??{}))}async function ba(e,t){return a(await o.delete(`/projects/${e}/cli-token/${t}`))}async function xa(e,t){return a(await o.post(`/projects/${e}/marketplace/install`,{id:t}))}async function ka(e){return a(await o.get(`/projects/${e}/marketplace`))}async function Pa(e){return a(await o.get(`/projects/${e}/marketplace/updates`))}async function _a(e,t){return a(await o.post(`/projects/${e}/marketplace/update`,{name:t}))}async function wa(e){return a(await o.post(`/projects/${e}/marketplace/update-all`,{}))}async function Sa(e,t){return a(await o.delete(`/projects/${e}/marketplace/${encodeURIComponent(t)}`))}async function Ra(e,t){return a(await o.post(`/projects/${e}/registry/install`,{id:t}))}async function va(e){return a(await o.get(`/projects/${e}/registry`))}async function Ca(e){return a(await o.get(`/projects/${e}/registry/updates`))}async function Ta(e,t){return a(await o.post(`/projects/${e}/registry/update`,{name:t}))}async function Ia(e){return a(await o.post(`/projects/${e}/registry/update-all`,{}))}async function ja(e,t){return a(await o.delete(`/projects/${e}/registry/${encodeURIComponent(t)}`))}async function Aa(e,t){let r=new URLSearchParams;t?.action&&r.set("action",t.action),t?.since&&r.set("since",t.since),t?.cursor&&r.set("cursor",t.cursor),t?.limit!=null&&r.set("limit",String(t.limit));let n=r.toString();return a(await o.get(`/accounts/${e}/audit${n?`?${n}`:""}`))}async function Ea(e,t){let r=new URLSearchParams;t?.format&&r.set("format",t.format),t?.action&&r.set("action",t.action),t?.since&&r.set("since",t.since);let n=r.toString();return a(await o.get(`/accounts/${e}/audit/export${n?`?${n}`:""}`))}async function $a(e){return a(await o.get(`/accounts/${e}/audit/webhooks`))}async function qa(e,t){return a(await o.post(`/accounts/${e}/audit/webhooks`,t))}async function Da(e,t,r){return a(await o.patch(`/accounts/${e}/audit/webhooks/${t}`,r))}async function Ma(e,t){return a(await o.delete(`/accounts/${e}/audit/webhooks/${t}`))}async function Ua(e,t){return a(await o.post(`/projects/${e}/secret-requests`,{names:t.names,labels:t.labels,descriptions:t.descriptions,scope:t.scope,expires_in_minutes:t.expiresInMinutes}),"Failed to mint secret-entry link")}async function Oa(e,t){return a(await o.post(`/projects/${e}/connect-requests`,{slug:t.slug,expires_in_minutes:t.expiresInMinutes}),"Failed to mint connect link")}async function La(e){let t=new URLSearchParams;e?.query&&t.set("query",e.query),e?.type&&t.set("type",e.type),e?.source&&t.set("source",e.source);let r=t.toString()?`?${t.toString()}`:"";return a(await o.get(`/marketplace/items${r}`))}async function Fa(){return a(await o.get("/marketplace/marketplaces"))}async function Ba(){return a(await o.get("/marketplace/marketplaces/featured"))}async function Ga(e){return a(await o.get(`/marketplace/items/${encodeURIComponent(e)}`),"Item not found")}async function Ka(e,t){return a(await o.get(`/marketplace/items/${encodeURIComponent(e)}/file?path=${encodeURIComponent(t)}`),"File not found")}async function Na(){return a(await o.get("/marketplace/sources"))}async function Ha(e){return a(await o.post("/marketplace/sources",e),"Failed to add marketplace source")}async function Wa(e){return a(await o.delete(`/marketplace/sources/${encodeURIComponent(e)}`),"Failed to remove marketplace source")}async function id(e){return a(await o.get(`/templates/${encodeURIComponent(e)}`))}async function od(e,t){return a(await o.post(`/templates/${encodeURIComponent(e)}/install`,t))}function ad(e){return e?e.runtimeReady!==void 0?e.runtimeReady===!0:e.opencode!==void 0?e.opencode==="ok"||e.opencode===!0:e.status!=="starting"&&e.status!=="down"&&e.status!=="error":!1}async function Va(e,t){let r=(e===void 0?$():e)||null;if(!r)return{status:0,ok:!1,health:null,body:""};let n=await C(`${r}/kortix/health`,{method:"GET",...t},{retryOnAuthError:!1}),s=await n.text().catch(()=>""),l=null;try{l=s?JSON.parse(s):null}catch{l=null}return{status:n.status,ok:n.ok,health:l,body:s}}var V={DESKTOP:"6080",DESKTOP_HTTPS:"6081",PRESENTATION_VIEWER:"3210",STATIC_FILE_SERVER:"3211",KORTIX_MASTER:"8000",BROWSER_STREAM:"9223",BROWSER_VIEWER:"9224",SSH:"22"};var Kc=/https?:\/\/(?:localhost|127\.0\.0\.1):\d{1,5}[^\s)"'<>]*/g,Nc=/^https?:\/\/p(\d+)-([^.]+)\.localhost(?::(\d+))?(\/.*)?$/,Hc=new Set([22,4096,parseInt(V.KORTIX_MASTER,10)]);function cd(e){return Nc.test(e)}function Pt(e){if(!e)return"/";let t=e,r=t.indexOf("](");r!==-1&&(t=t.slice(0,r));let n=t.toLowerCase().indexOf("%5d(");return n!==-1&&(t=t.slice(0,n)),t?t.startsWith("/")?t:`/${t}`:"/"}function ld(e){let t=e.indexOf("](");return t===-1?e:e.slice(0,t)}var ud=new Set(["'",'"',"`","<","(","["]),pd=new Set([">","'",'"',"`",")","]",",",";",".","!","?"]);function dd(e){let t=0,r=e.length;for(;t<r&&(e[t]===" "||e[t]===" ");)t++;for(;r>t&&(e[r-1]===" "||e[r-1]===" ");)r--;for(;t<r&&ud.has(e[t]);)t++;for(;r>t&&pd.has(e[r-1]);)r--;return e.slice(t,r)}function gd(e){return e.match(/https?:\/\/(?:localhost|127\.0\.0\.1):\d{1,5}[^\s"'<>)]*/i)?.[0]??null}var md=/^\/proxy\/(\d{1,5})(\/.*)?$/,fd=/^\/(connectors|settings|dashboard|projects|agents|skills|tools|commands|deployments|support|changelog|files|p|browser|desktop|terminal|sessions|services|workspace|channels|scheduled-tasks|marketplace|templates|tunnel|admin|auth)(\/|$|\?)/;function Wc(e){if(!e)return!1;try{let t=new URL(e);return t.hostname!=="localhost"&&t.hostname!=="127.0.0.1"?!1:fd.test(t.pathname)}catch{return!1}}function Le(e){if(!e)return null;let t=dd(ld(e.trim())),r=Ja(t);if(r){let n=Pt(r.path||"/");return{originalUrl:`http://localhost:${r.port}${n}`,port:r.port,path:n}}try{let n=new URL(t);if(n.protocol!=="http:"&&n.protocol!=="https:"||n.hostname!=="localhost"&&n.hostname!=="127.0.0.1"||!n.port)return null;let s=parseInt(n.port,10);if(!Number.isInteger(s)||s<1||s>65535)return null;let l=`${n.pathname||"/"}${n.search}${n.hash}`,u=parseInt(V.KORTIX_MASTER,10);if(s===u){let g=n.pathname.match(md);if(g){let h=parseInt(g[1],10);if(h>=1&&h<=65535)return s=h,l=Pt(`${g[2]||"/"}${n.search}${n.hash}`),{originalUrl:`http://localhost:${s}${l}`,port:s,path:l}}}let d=Pt(l);return{originalUrl:`${n.protocol}//${n.hostname}:${s}${d}`,port:s,path:d}}catch{let n=gd(e);return n&&n!==e?Le(n):null}}function yd(e){let t=[],r=/```[\s\S]*?```/g,n;for(;(n=r.exec(e))!==null;)t.push([n.index,n.index+n[0].length]);let s=/`[^`\n]+`/g;for(;(n=s.exec(e))!==null;){let l=n.index,u=l+n[0].length;t.some(([g,h])=>l>=g&&u<=h)||t.push([l,u])}return t}function hd(e,t){return t.some(([r,n])=>e>=r&&e<n)}function Vc(e){let t=[],r=new Set,n=yd(e);Kc.lastIndex=0;let s;for(;(s=Kc.exec(e))!==null;){let l=Le(s[0]);if(!l)continue;let{originalUrl:u,port:d,path:g}=l;d<1||d>65535||Hc.has(d)||r.has(u)||(r.add(u),t.push({originalUrl:u,port:d,path:g,startIndex:s.index,endIndex:s.index+u.length,inCodeBlock:hd(s.index,n)}))}return t}function bd(e){return Vc(e).length>0}function xd(e){try{let{hostname:t}=new URL(e);return t==="localhost"||t==="127.0.0.1"}catch{return!1}}function Pe(e,t,r){let n=Pt(t);if(!xd(r.apiBaseUrl)){let s=r.apiBaseUrl.length;for(;s>0&&r.apiBaseUrl.charCodeAt(s-1)===47;)s--;return`${r.apiBaseUrl.slice(0,s)}/p/${r.sandboxId}/${e}${n}`}return`http://p${e}-${r.sandboxId}.localhost:${r.backendPort}${n}`}function kd(e,t){return Pe(e,"/",t)}function zc(e){let t=Le(e);return!(!t||Hc.has(t.port)||Wc(e))}function za(e,t){if(!e)return e;let r=Le(e);return r?zc(r.originalUrl)?Pe(r.port,r.path,t):r.originalUrl:e}function Pd(e,t="/"){return`http://localhost:${e}${t}`}var Jc=/^https?:\/\/[^/]+\/v1\/p\/([^/]+)\/(\d+)(\/.*)?$/;function Ja(e){let t=e.match(Nc);if(t)return{port:parseInt(t[1],10),sandboxId:t[2],backendPort:t[3]?parseInt(t[3],10):80,path:t[4]||"/"};let r=e.match(Jc);if(r)try{let n=new URL(e);return{port:parseInt(r[2],10),sandboxId:r[1],backendPort:parseInt(n.port,10)||(n.protocol==="https:"?443:80),path:r[3]||"/"}}catch{return null}return null}function _d(e){try{let t=Ja(e);return t?`http://localhost:${t.port}${t.path}`:null}catch{return null}}function wd(e){return cd(e)||Jc.test(e)}var Oe="/web-proxy/";function Sd(e,t){try{let r=new URL(e);if(r.protocol!=="http:"&&r.protocol!=="https:")return null;let n=r.protocol.replace(":",""),s=`${Oe}${n}/${r.host}${r.pathname}${r.search}${r.hash}`,l=parseInt(V.KORTIX_MASTER,10);return`${Pe(l,"/",t).replace(/\/$/,"")}${s}`}catch{return null}}function Rd(e){try{let t=new URL(e),r=t.pathname.indexOf(Oe);if(r===-1)return null;let s=t.pathname.slice(r+Oe.length).match(/^(https?)\/([\w.\-]+(?::\d+)?)(\/.*)?$/);if(!s)return null;let l=s[1],u=s[2],d=s[3]||"/";return`${l}://${u}${d}${t.search}${t.hash}`}catch{return null}}function vd(e){try{return new URL(e).pathname.includes(Oe)}catch{return e.includes(Oe)}}function Cd(e){if(!e)return!1;let t=e.trim();return!!(/^https?:\/\/(?!localhost|127\.0\.0\.1)/i.test(t)||/^[a-z0-9][\w.-]*\.[a-z]{2,}/i.test(t))}function Td(e){let t=e.trim();return t?/^https?:\/\//i.test(t)?t:/^[a-z0-9][\w.-]*\.[a-z]{2,}/i.test(t)?`https://${t}`:null:null}var Xc="frontend";function _t(e,t,r){(e==="error"?console.error:e==="warn"?console.warn:e==="debug"?console.debug:console.log)(`[${Xc}] ${t}`,...r?[r]:[]);try{X().app.log({service:Xc,level:e,message:t,extra:r})}catch{}}var Z={debug:(e,t)=>_t("debug",e,t),info:(e,t)=>_t("info",e,t),warn:(e,t)=>_t("warn",e,t),error:(e,t)=>_t("error",e,t)};function Qc(e){return{type:"heartbeat-gap",gapMs:e}}function Yc(e){switch(e.type){case"message.updated":return{type:"message.updated",sessionID:e.properties.sessionID,message:e.properties.info};case"message.removed":return{type:"message.removed",sessionID:e.properties.sessionID,messageID:e.properties.messageID};case"message.part.updated":return{type:"message.part.updated",sessionID:e.properties.sessionID,part:e.properties.part};case"message.part.removed":return{type:"message.part.removed",sessionID:e.properties.sessionID,messageID:e.properties.messageID,partID:e.properties.partID};case"session.status":return{type:"session.status",sessionID:e.properties.sessionID,status:e.properties.status};case"session.idle":return{type:"session.idle",sessionID:e.properties.sessionID};case"session.error":return{type:"session.error",sessionID:e.properties.sessionID,error:e.properties.error};case"question.asked":return{type:"question.asked",sessionID:e.properties.sessionID,requestID:e.properties.id,questions:e.properties.questions,tool:e.properties.tool};case"question.replied":return{type:"question.answered",sessionID:e.properties.sessionID,requestID:e.properties.requestID,outcome:"replied",answers:e.properties.answers};case"question.rejected":return{type:"question.answered",sessionID:e.properties.sessionID,requestID:e.properties.requestID,outcome:"rejected"};case"permission.asked":return{type:"permission.asked",sessionID:e.properties.sessionID,requestID:e.properties.id,permission:e.properties.permission,patterns:e.properties.patterns,tool:e.properties.tool};case"permission.replied":return{type:"permission.replied",sessionID:e.properties.sessionID,requestID:e.properties.requestID,reply:e.properties.reply};case"todo.updated":return{type:"todo.updated",sessionID:e.properties.sessionID,todos:e.properties.todos};case"server.connected":return{type:"connection",status:"connected"};default:return null}}var Id={now:()=>Date.now(),setTimeout:(e,t)=>setTimeout(e,t),clearTimeout:e=>clearTimeout(e)},jd=16,Ad=8,Ed=6e4,$d=5e3,qd=250,Dd=1e3,Md=3e4,Ud=5,Od=3e3,Ld=3e4,Fd=2e4,Bd=2e3,Gd=8;function Kd(e){if(e.type==="session.status")return`session.status:${e.properties.sessionID}`;if(e.type==="lsp.updated")return"lsp.updated"}function Zc(e){if(e.aborted)return{promise:Promise.resolve(),cleanup:()=>{}};let t=()=>{};return{promise:new Promise(n=>{t=()=>n(),e.addEventListener("abort",t,{once:!0})}),cleanup:()=>e.removeEventListener("abort",t)}}function wt(e){let{client:t,onEvent:r,onGapRehydrate:n,onParked:s,signal:l}=e,u=e.timers??Id,d=e.connectTimeoutMs??Fd,g=e.heartbeatTimeoutMs??Ed,h=e.maxConsecutiveHardFailures??Gd,m=new AbortController,x=()=>m.abort();l&&(l.aborted?m.abort():l.addEventListener("abort",x,{once:!0}));let k=u.now(),_=[],c,i=0,P=new Map,w=()=>{if(c&&u.clearTimeout(c),c=void 0,_.length===0)return;let A=_;_=[],P.clear(),i=u.now(),k=u.now();for(let R of A)if(R)try{r(R.event)}catch(I){console.warn("[opencode-events] event handler threw, skipping",I)}},M=()=>{if(c)return;let A=u.now()-i;c=u.setTimeout(w,Math.max(0,jd-A))};return(async()=>{let A=0,R=0;for(;!m.signal.aborted;){let I=!1,j=!1,f,S,U=null,N=u.now(),D=new AbortController,O=Zc(m.signal);O.promise.then(()=>D.abort());try{let F=await new Promise(($t,ve)=>{let B=!1;S=u.setTimeout(()=>{B||(B=!0,Z.warn("SSE connect timed out, forcing reconnect",{connectTimeoutMs:d}),D.abort(),ve(new Error(`SSE connect timed out after ${d}ms`)))},d),t.global.event({signal:D.signal,sseDefaultRetryDelay:Od,sseMaxRetryDelay:Ld}).then(W=>{B||(B=!0,u.clearTimeout(S),$t(W))},W=>{B||(B=!0,u.clearTimeout(S),ve(W))})}),{stream:E}=F;k=u.now();let G=()=>{u.clearTimeout(f),f=u.setTimeout(()=>{Z.warn("SSE heartbeat timeout, forcing reconnect"),D.abort()},g)};G();let Ve=u.now(),Dl=E[Symbol.asyncIterator]();for(;!D.signal.aborted;){let $t=Dl.next().then(J=>({kind:"next",result:J}),J=>({kind:"error",error:J})),ve=Zc(D.signal),B=await Promise.race([$t,ve.promise.then(()=>({kind:"aborted"}))]);if(ve.cleanup(),B.kind==="aborted")break;if(B.kind==="error")throw B.error;if(B.result.done)break;I=!0,G();let W=B.result.value,ze=W&&typeof W=="object"&&"payload"in W?W.payload:W;if(!ze?.type)continue;let qt=Kd(ze);if(qt){let J=P.get(qt);J!==void 0&&(_[J]=void 0),P.set(qt,_.length)}_.push({type:ze.type,event:ze}),M(),!(u.now()-Ve<Ad)&&(Ve=u.now(),await new Promise(J=>u.setTimeout(J,0)))}j=I}catch(F){if(m.signal.aborted)break;U=F;let E=String(F),G=E.includes("401")||E.includes("403")||E.includes("Unauthorized")||E.includes("Token refresh failed");if(Z.error("SSE event stream error",{error:E,retryCount:A,isAuthError:G}),G)try{je(),await rt(),Z.info("SSE: refreshed auth token after auth error")}catch(Ve){Z.error("SSE: failed to refresh auth token",{error:String(Ve)})}}finally{u.clearTimeout(f),u.clearTimeout(S),D.abort(),O.cleanup(),w()}if(m.signal.aborted)break;let ce=u.now()-N,We=U?.cause?.status;if(R=!I&&(typeof We=="number"&&We>=400||ce<Bd)?R+1:0,R>=h){Z.error("SSE event stream parked \u2014 giving up after consecutive hard failures",{consecutiveFailures:R,lastError:String(U)});try{s?.({consecutiveFailures:R,lastError:U})}catch(F){console.warn("[opencode-events] onParked handler threw",F)}break}let Re=u.now()-k;Re>$d&&n?.(Re),j?A=0:(A++,A>1&&Z.warn("SSE event stream reconnecting",{retryCount:A}));let H=j?qd:Math.min(Dd*2**Math.min(A-1,Ud),Md);await new Promise(F=>{let E=u.setTimeout(F,H),G=()=>{u.clearTimeout(E),F()};m.signal.addEventListener("abort",G,{once:!0})})}})(),{close:()=>{m.abort(),l&&l.removeEventListener("abort",x),c&&u.clearTimeout(c)}}}function Nd(){return X()}var St=new Map,Fe=class extends Error{constructor(t){super(`Session runtime not ready \u2014 call \`await session.ensureReady()\` (it drives \`start()\` to completion and resolves this session's own sandbox runtime) before calling \`${t}\`.`),this.name="SessionNotReadyError"}};function el(e,t){Xe(e,t);function r(c){try{return new URL(c)}catch{if(typeof window<"u"&&window.location?.origin)try{return new URL(c,window.location.origin)}catch{return null}throw new v(`Kortix SDK: backendUrl must be an absolute URL outside the browser (got ${JSON.stringify(c)}). Relative paths like "/api/kortix" only resolve against a page origin \u2014 configure an absolute backendUrl for server-side hosts.`,{code:"INVALID_BACKEND_URL"})}}function n(c){let i=T().backendUrl??e.backendUrl,P=80,w=r(i);return w&&(P=w.port?Number(w.port):w.protocol==="https:"?443:80),{sandboxId:c,backendPort:P,apiBaseUrl:i}}let s={list:Rn,get:Cn,create:vn,updateName:Tn,leave:Ln,members:In,invite:jn,removeMember:Un,updateMemberRole:On,invites:An,cancelInvite:En,resendInvite:$n,tokens:{list:ga,create:ma,revoke:fa},audit:{log:Aa,export:Ea,webhooks:{list:$a,create:qa,update:Da,remove:Ma}}},l={accountState:eo,accountStateMinimal:to,transactions:ro,transactionsSummary:no,creditBreakdown:so,usageHistory:io,tierConfigurations:oo,checkout:{createSession:c=>ao(c),confirmSession:(c,i)=>co(c,i)},subscription:{createPortalSession:(c,i)=>lo(c,i),cancel:(c,i)=>uo(c,i),reactivate:c=>po(c),scheduleDowngrade:(c,i,P)=>go(c,i,P),cancelScheduledChange:c=>mo(c),prorationPreview:(c,i)=>fo(c,i)},credits:{purchase:c=>yo(c),autoTopupSettings:c=>ho(c),configureAutoTopup:c=>bo(c)}},u={describe:qn,accept:Dn,decline:Mn},d={list:ie,listForAccount:Bn,get:dt,detail:gt,create:Hn,createRepo:Wn,provision:Vn,update:ft,archive:ht,llmCatalog:mt,sandboxHealth:bt,sandboxTemplates:Zs,sessions:be,createSession:xe},g={linkRepository:Qn,getInstallation:Yn,listInstallations:Zn,listRepositories:es,saveInstallation:ts,deleteInstallation:rs},h={list:ua,create:pa,revoke:da},m=zs,x={items:c=>La(c),item:c=>Ga(c),itemFile:(c,i)=>Ka(c,i),marketplaces:()=>Fa(),featured:()=>Ba(),sources:{list:()=>Na(),add:c=>Ha(c),remove:c=>Wa(c)}};function k(c){return{get:i=>dt(c,i),detail:()=>gt(c),update:i=>ft(c,i),archive:()=>ht(c),llmCatalog:()=>mt(c),sandboxHealth:()=>bt(c),onboardingComplete:(...i)=>Xn(c,...i),tokens:{list:()=>ya(c),create:i=>ha(c,i),revoke:i=>ba(c,i)},setupLinks:{requestSecret:i=>Ua(c,i),requestConnector:i=>Oa(c,i)},validateManifest:i=>Kn(c,i),gitToken:()=>Nn(c),marketplace:{list:()=>ka(c),install:i=>xa(c,i),updates:()=>Pa(c),update:i=>_a(c,i),updateAll:()=>wa(c),remove:i=>Sa(c,i)},registry:{list:()=>va(c),install:i=>Ra(c,i),updates:()=>Ca(c),update:i=>Ta(c,i),updateAll:()=>Ia(c),remove:i=>ja(c,i)},secrets:{list:()=>ws(c),upsert:i=>Ss(c,i),remove:i=>Ts(c,i),setPersonal:(...i)=>Is(c,...i),removePersonal:i=>js(c,i),setGitCredential:i=>Cs(c,i),startProviderOAuth:(...i)=>Rs(c,...i),pollProviderOAuth:(...i)=>vs(c,...i)},access:{list:()=>os(c),invite:(...i)=>ls(c,...i),update:(...i)=>as(c,...i),revoke:i=>cs(c,i),pendingInvites:()=>us(c),resendInvite:(...i)=>ds(c,...i),revokeInvite:(...i)=>ps(c,...i),requests:()=>ns(c),approveRequest:(...i)=>ss(c,...i),rejectRequest:(...i)=>is(c,...i),groupGrants:()=>gs(c),attachGroupGrant:(...i)=>ms(c,...i),updateGroupGrant:(...i)=>fs(c,...i),detachGroupGrant:i=>ys(c,i),resourceGrants:{list:()=>hs(c),create:i=>bs(c,i),remove:i=>xs(c,i)}},connectors:{list:()=>Ms(c),config:(...i)=>Gs(c,...i),create:(...i)=>Hs(c,...i),remove:(...i)=>Ws(c,...i),sync:()=>Us(c),setName:(...i)=>Ks(c,...i),setCredentialMode:(...i)=>Os(c,...i),setCredential:(...i)=>Js(c,...i),setSensitive:(...i)=>Ls(c,...i),profiles:{list:()=>As(c),reconcile:(...i)=>Es(c,...i),updateCredential:(...i)=>$s(c,...i),revoke:(...i)=>qs(c,...i),activate:(...i)=>Ds(c,...i)},policies:{get:(...i)=>Fs(c,...i),set:(...i)=>Bs(c,...i)},pipedream:{listApps:(...i)=>Vs(c,...i),connect:(...i)=>Ns(c,...i),finalize:(...i)=>Xs(c,...i)}},policies:{list:()=>Qs(c),set:(...i)=>Ys(c,...i)},triggers:{list:()=>Bi(c),create:(...i)=>Gi(c,...i),update:(...i)=>Ki(c,...i),remove:(...i)=>Ni(c,...i),fire:(...i)=>Wi(c,...i),setActivation:(...i)=>Hi(c,...i)},files:{list:i=>ci(c,i),read:(i,P)=>ui(c,i,P),search:(...i)=>li(c,...i),archive:(...i)=>pi(c,...i),history:(...i)=>yi(c,...i)},git:{commits:()=>gi(c),commit:i=>mi(c,i),commitDiff:i=>fi(c,i),branches:()=>di(c),versionDiff:(...i)=>hi(c,...i),inviteCollaborator:(...i)=>Gn(c,...i)},changeRequests:{list:()=>bi(c),get:i=>xi(c,i),diff:i=>ki(c,i),mergePreview:i=>Pi(c,i),open:(...i)=>_i(c,...i),merge:(...i)=>wi(c,...i),close:(...i)=>Si(c,...i),reopen:(...i)=>Ri(c,...i),requestChanges:(...i)=>vi(c,...i)},sessions:{list:()=>be(c),create:i=>xe(c,i)},review:{list:i=>ia(c,i),get:i=>oa(c,i),submit:i=>aa(c,i),act:(...i)=>ca(c,...i),bulkAct:i=>la(c,i)},approvals:{list:i=>ks(c,i),resolve:(...i)=>_s(c,...i),sessionsNeedingInput:i=>Ps(c,i)},gateway:{logs:i=>Uo(c,i),log:i=>Oo(c,i),overview:i=>Lo(c,i),series:i=>Fo(c,i),breakdown:i=>Bo(c,i),sessions:i=>Go(c,i),errors:i=>Ko(c,i),budgets:()=>No(c),setBudget:i=>Ho(c,i),deleteBudget:i=>Wo(c,i),keys:()=>Vo(c),createKey:i=>zo(c,i),revokeKey:i=>Jo(c,i),playground:(i,P)=>Xo(c,i,P)},channels:{slack:{installation:()=>xo(c),connect:i=>ko(c,i),mode:()=>Po(c),manifest:()=>_o(c),disconnect:()=>wo(c),getFile:i=>So(c,i),uploadFile:i=>Ro(c,i)},email:{installation:i=>Co(c,i),mode:()=>To(c),connect:i=>Io(c,i),disconnect:i=>jo(c,i),updatePolicy:(...i)=>Ao(c,...i)},meet:{voices:()=>Eo(c),setVoice:i=>$o(c,i),setBotName:i=>qo(c,i),previewVoice:i=>Do(c,i),speak:(i,P,w)=>Mo(c,i,P,w)}},apps:{list:()=>Qo(c),create:i=>Yo(c,i),update:(...i)=>Zo(c,...i),remove:i=>ea(c,i),deploy:i=>ta(c,i),stop:i=>ra(c,i),logs:i=>na(c,i),updateConfig:i=>Jn(c,i)},updateExperimentalFeature:(...i)=>yt(c,...i),modelDefaults:{get:()=>zi(c),set:i=>Ji(c,i),clear:i=>Xi(c,i)},setDefaultAgent:i=>Yi(c,i),sandbox:{list:()=>ai(c),snapshots:()=>ei(c),rebuildSnapshot:i=>ti(c,i),fixWithAgent:()=>ri(c),createTemplate:i=>ni(c,i),updateTemplate:(...i)=>si(c,...i),removeTemplate:i=>ii(c,i),buildTemplate:i=>oi(c,i),setProvider:i=>zn(c,i)},setAgentScope:(...i)=>Qi(c,...i),session:i=>_(c,i)}}function _(c,i){let P=null,w,M;function A(){if(P)return P;let f=Oc(c,i);return f&&(P=f),P}async function R(){let f=A();if(f)return f;let S=`${c}
8
- ${i}`,U=St.get(S);if(U)return P=await U,P;let N=(async()=>{let D=await ke(c,i,3e4);if(!D||D.stage!=="ready"||!D.sandbox||!D.opencode_session_id)throw new v(`Session runtime not ready (stage: ${D?.stage??"unknown"})`,{code:"RUNTIME_UNAVAILABLE"});let O=D.sandbox.external_id;if(!O)throw new v("Session sandbox has no external_id \u2014 cannot resolve its runtime URL",{code:"RUNTIME_UNAVAILABLE"});let ce=nt(O);return wc(ce,O),{opencodeSessionId:D.opencode_session_id,runtimeUrl:ce,sandboxId:O}})();St.set(S,N);try{return P=await N,P}finally{St.get(S)===N&&St.delete(S)}}function I(f){let S=A();if(!S)throw new Fe(f);return S}function j(){P=null,Fc(c,i)}return{get:f=>Mi(c,i,f),update:f=>Li(c,i,f),delete:()=>(j(),Fi(c,i)),start:(...f)=>ke(c,i,...f),restart:()=>(j(),Me(c,i)),stop:()=>(j(),Ue(c,i)),setSharing:f=>Ai(c,i,f),previews:()=>Ei(c,i),commit:f=>Ci(c,i,f),publicShares:{list:()=>$i(c,i),create:(...f)=>qi(c,i,...f),revoke:(...f)=>Di(c,i,...f)},audit:(f,S)=>Ui(c,i,f,S),transcript:f=>Oi(c,i,f),ensureReady:R,health:f=>Va(A()?.runtimeUrl??null,f),previewUrl:(f,S="/")=>Pe(f,S,n(I("previewUrl").sandboxId)),proxyUrl:f=>za(f,n(I("proxyUrl").sandboxId)),setModel:f=>{w=f},setAgent:f=>{M=f},send:async(f,S)=>{let{opencodeSessionId:U,runtimeUrl:N}=await R(),D=S?.model??w,O=S?.agent??M;return ne(N).session.prompt({sessionID:U,parts:[{type:"text",text:f}],...D?{model:D}:{},...O?{agent:O}:{}})},abort:async()=>{let{opencodeSessionId:f,runtimeUrl:S}=await R();return ne(S).session.abort({sessionID:f})},stream:async f=>{let{runtimeUrl:S}=await R();return wt({client:ne(S),onEvent:f.onEvent,onGapRehydrate:f.onGapRehydrate,signal:f.signal})},get runtime(){return ne(I("runtime").runtimeUrl)},files:{list:async f=>mn(f,(await R()).runtimeUrl),read:async f=>lt(f,(await R()).runtimeUrl),readBlob:async f=>ut(f,(await R()).runtimeUrl),status:async()=>fn((await R()).runtimeUrl),findFiles:async(f,S)=>yn(f,S,(await R()).runtimeUrl),findText:async f=>hn(f,(await R()).runtimeUrl),upload:async(f,S,U)=>pt(f,S,U,(await R()).runtimeUrl),create:async f=>bn(f,(await R()).runtimeUrl),copy:async(f,S)=>xn(f,S,(await R()).runtimeUrl),remove:async f=>kn(f,(await R()).runtimeUrl),mkdir:async f=>Pn(f,(await R()).runtimeUrl),rename:async(f,S)=>_n(f,S,(await R()).runtimeUrl)}}}return{config:e,accounts:s,accountInvites:u,projects:d,project:k,session:_,github:g,billing:l,sandboxShares:h,transcribe:sa,connectStatus:m,marketplace:x,validateToken:Fn,runtime:Nd}}function tl(){let e=typeof crypto<"u"?crypto:void 0;if(e?.randomUUID)return e.randomUUID();let t=new Uint8Array(16);if(e?.getRandomValues)e.getRandomValues(t);else for(let n=0;n<16;n++)t[n]=Math.floor(Math.random()*256);t[6]=t[6]&15|64,t[8]=t[8]&63|128;let r=[...t].map(n=>n.toString(16).padStart(2,"0"));return`${r[0]}${r[1]}${r[2]}${r[3]}-${r[4]}${r[5]}-${r[6]}${r[7]}-${r[8]}${r[9]}-${r.slice(10).join("")}`}var Xa={thinking:!1,toolDetails:!0,assistantMetadata:!0};function Hd(e){return e&&e.charAt(0).toUpperCase()+e.slice(1)}function Wd(e){let t=e/1e3;if(t<60)return`${t.toFixed(1)}s`;let r=Math.floor(t/60),n=t%60;return`${r}m ${n.toFixed(0)}s`}function Vd(e,t){if(e.type==="text"&&!("synthetic"in e&&e.synthetic))return`${e.text}
5
+ `);S=O.pop()??"";for(let ae of O){let He=ae.split(`
6
+ `),_e=[],Se;for(let E of He)if(E.startsWith("data:"))_e.push(E.replace(/^data:\s*/,""));else if(E.startsWith("event:"))Se=E.replace(/^event:\s*/,"");else if(E.startsWith("id:"))x=E.replace(/^id:\s*/,"");else if(E.startsWith("retry:")){let B=Number.parseInt(E.replace(/^retry:\s*/,""),10);Number.isNaN(B)||(i=B)}let H,F=!1;if(_e.length){let E=_e.join(`
7
+ `);try{H=JSON.parse(E),F=!0}catch{H=E}}F&&(s&&await s(H),n&&(H=await n(H))),r?.({data:H,event:Se,id:x,retry:i}),_e.length&&(yield H)}}}finally{_.removeEventListener("abort",U),f.releaseLock()}break}catch(A){if(t?.(A),u!==void 0&&P>=u)break;let v=Math.min(i*2**(P-1),d??3e4);await w(v)}}}()}};var Al=e=>{switch(e){case"label":return".";case"matrix":return";";case"simple":return",";default:return"&"}},El=e=>{switch(e){case"form":return",";case"pipeDelimited":return"|";case"spaceDelimited":return"%20";default:return","}},$l=e=>{switch(e){case"label":return".";case"matrix":return";";case"simple":return",";default:return"&"}},Qe=({allowReserved:e,explode:t,name:r,style:n,value:s})=>{if(!t){let d=(e?s:s.map(g=>encodeURIComponent(g))).join(El(n));switch(n){case"label":return`.${d}`;case"matrix":return`;${r}=${d}`;case"simple":return d;default:return`${r}=${d}`}}let c=Al(n),u=s.map(d=>n==="label"||n==="simple"?e?d:encodeURIComponent(d):ce({allowReserved:e,name:r,value:d})).join(c);return n==="label"||n==="matrix"?c+u:u},ce=({allowReserved:e,name:t,value:r})=>{if(r==null)return"";if(typeof r=="object")throw new Error("Deeply-nested arrays/objects aren\u2019t supported. Provide your own `querySerializer()` to handle these.");return`${t}=${e?r:encodeURIComponent(r)}`},Ye=({allowReserved:e,explode:t,name:r,style:n,value:s,valueOnly:c})=>{if(s instanceof Date)return c?s.toISOString():`${r}=${s.toISOString()}`;if(n!=="deepObject"&&!t){let g=[];Object.entries(s).forEach(([m,x])=>{g=[...g,m,e?x:encodeURIComponent(x)]});let h=g.join(",");switch(n){case"form":return`${r}=${h}`;case"label":return`.${h}`;case"matrix":return`;${r}=${h}`;default:return h}}let u=$l(n),d=Object.entries(s).map(([g,h])=>ce({allowReserved:e,name:n==="deepObject"?`${r}[${g}]`:g,value:h})).join(u);return n==="label"||n==="matrix"?u+d:d};var ql=/\{[^{}]+\}/g,Dl=({path:e,url:t})=>{let r=t,n=t.match(ql);if(n)for(let s of n){let c=!1,u=s.substring(1,s.length-1),d="simple";u.endsWith("*")&&(c=!0,u=u.substring(0,u.length-1)),u.startsWith(".")?(u=u.substring(1),d="label"):u.startsWith(";")&&(u=u.substring(1),d="matrix");let g=e[u];if(g==null)continue;if(Array.isArray(g)){r=r.replace(s,Qe({explode:c,name:u,style:d,value:g}));continue}if(typeof g=="object"){r=r.replace(s,Ye({explode:c,name:u,style:d,value:g,valueOnly:!0}));continue}if(d==="matrix"){r=r.replace(s,`;${ce({name:u,value:g})}`);continue}let h=encodeURIComponent(d==="label"?`.${g}`:g);r=r.replace(s,h)}return r},za=({baseUrl:e,path:t,query:r,querySerializer:n,url:s})=>{let c=s.startsWith("/")?s:`/${s}`,u=(e??"")+c;t&&(u=Dl({path:t,url:u}));let d=r?n(r):"";return d.startsWith("?")&&(d=d.substring(1)),d&&(u+=`?${d}`),u};function Mt(e){let t=e.body!==void 0;if(t&&e.bodySerializer)return"serializedBody"in e?e.serializedBody!==void 0&&e.serializedBody!==""?e.serializedBody:null:e.body!==""?e.body:null;if(t)return e.body}var Ja=async(e,t)=>{let r=typeof t=="function"?await t(e):t;if(r)return e.scheme==="bearer"?`Bearer ${r}`:e.scheme==="basic"?`Basic ${btoa(r)}`:r};var Ut={bodySerializer:e=>JSON.stringify(e,(t,r)=>typeof r=="bigint"?r.toString():r)};var Xa=({parameters:e={},...t}={})=>n=>{let s=[];if(n&&typeof n=="object")for(let c in n){let u=n[c];if(u==null)continue;let d=e[c]||t;if(Array.isArray(u)){let g=Qe({allowReserved:d.allowReserved,explode:!0,name:c,style:"form",value:u,...d.array});g&&s.push(g)}else if(typeof u=="object"){let g=Ye({allowReserved:d.allowReserved,explode:!0,name:c,style:"deepObject",value:u,...d.object});g&&s.push(g)}else{let g=ce({allowReserved:d.allowReserved,name:c,value:u});g&&s.push(g)}}return s.join("&")},Qa=e=>{if(!e)return"stream";let t=e.split(";")[0]?.trim();if(t){if(t.startsWith("application/json")||t.endsWith("+json"))return"json";if(t==="multipart/form-data")return"formData";if(["application/","audio/","image/","video/"].some(r=>t.startsWith(r)))return"blob";if(t.startsWith("text/"))return"text"}},Ml=(e,t)=>t?!!(e.headers.has(t)||e.query?.[t]||e.headers.get("Cookie")?.includes(`${t}=`)):!1,Ya=async({security:e,...t})=>{for(let r of e){if(Ml(t,r.name))continue;let n=await Ja(r,t.auth);if(!n)continue;let s=r.name??"Authorization";switch(r.in){case"query":t.query||(t.query={}),t.query[s]=n;break;case"cookie":t.headers.append("Cookie",`${s}=${n}`);break;default:t.headers.set(s,n);break}}},Ot=e=>za({baseUrl:e.baseUrl,path:e.path,query:e.query,querySerializer:typeof e.querySerializer=="function"?e.querySerializer:Xa(e.querySerializer),url:e.url}),Lt=(e,t)=>{let r={...e,...t};return r.baseUrl?.endsWith("/")&&(r.baseUrl=r.baseUrl.substring(0,r.baseUrl.length-1)),r.headers=Ze(e.headers,t.headers),r},Ul=e=>{let t=[];return e.forEach((r,n)=>{t.push([n,r])}),t},Ze=(...e)=>{let t=new Headers;for(let r of e){if(!r)continue;let n=r instanceof Headers?Ul(r):Object.entries(r);for(let[s,c]of n)if(c===null)t.delete(s);else if(Array.isArray(c))for(let u of c)t.append(s,u);else c!==void 0&&t.set(s,typeof c=="object"?JSON.stringify(c):c)}return t},Ce=class{fns=[];clear(){this.fns=[]}eject(t){let r=this.getInterceptorIndex(t);this.fns[r]&&(this.fns[r]=null)}exists(t){let r=this.getInterceptorIndex(t);return!!this.fns[r]}getInterceptorIndex(t){return typeof t=="number"?this.fns[t]?t:-1:this.fns.indexOf(t)}update(t,r){let n=this.getInterceptorIndex(t);return this.fns[n]?(this.fns[n]=r,t):!1}use(t){return this.fns.push(t),this.fns.length-1}},Za=()=>({error:new Ce,request:new Ce,response:new Ce}),Ol=Xa({allowReserved:!1,array:{explode:!0,style:"form"},object:{explode:!0,style:"deepObject"}}),Ll={"Content-Type":"application/json"},Re=(e={})=>({...Ut,headers:Ll,parseAs:"auto",querySerializer:Ol,...e});var Te=(e={})=>{let t=Lt(Re(),e),r=()=>({...t}),n=h=>(t=Lt(t,h),r()),s=Za(),c=async h=>{let m={...t,...h,fetch:h.fetch??t.fetch??globalThis.fetch,headers:Ze(t.headers,h.headers),serializedBody:void 0};m.security&&await Ya({...m,security:m.security}),m.requestValidator&&await m.requestValidator(m),m.body!==void 0&&m.bodySerializer&&(m.serializedBody=m.bodySerializer(m.body)),(m.body===void 0||m.serializedBody==="")&&m.headers.delete("Content-Type");let x=Ot(m);return{opts:m,url:x}},u=async h=>{let{opts:m,url:x}=await c(h),w={redirect:"follow",...m,body:Mt(m)},k=new Request(x,w);for(let I of s.request.fns)I&&(k=await I(k,m));let l=m.fetch,i;try{i=await l(k)}catch(I){let j=I;for(let f of s.error.fns)f&&(j=await f(I,void 0,k,m));if(j=j||{},m.throwOnError)throw j;return m.responseStyle==="data"?void 0:{error:j,request:k,response:void 0}}for(let I of s.response.fns)I&&(i=await I(i,k,m));let P={request:k,response:i};if(i.ok){let I=(m.parseAs==="auto"?Qa(i.headers.get("Content-Type")):m.parseAs)??"json";if(i.status===204||i.headers.get("Content-Length")==="0"){let f;switch(I){case"arrayBuffer":case"blob":case"text":f=await i[I]();break;case"formData":f=new FormData;break;case"stream":f=i.body;break;default:f={};break}return m.responseStyle==="data"?f:{data:f,...P}}let j;switch(I){case"arrayBuffer":case"blob":case"formData":case"text":j=await i[I]();break;case"json":{let f=await i.text();j=f?JSON.parse(f):{};break}case"stream":return m.responseStyle==="data"?i.body:{data:i.body,...P}}return I==="json"&&(m.responseValidator&&await m.responseValidator(j),m.responseTransformer&&(j=await m.responseTransformer(j))),m.responseStyle==="data"?j:{data:j,...P}}let _=await i.text(),D;try{D=JSON.parse(_)}catch{}let A=D??_,v=A;for(let I of s.error.fns)I&&(v=await I(A,i,k,m));if(v=v||{},m.throwOnError)throw v;return m.responseStyle==="data"?void 0:{error:v,...P}},d=h=>m=>u({...m,method:h}),g=h=>async m=>{let{opts:x,url:w}=await c(m);return Va({...x,body:x.body,headers:x.headers,method:h,onRequest:async(k,l)=>{let i=new Request(k,l);for(let P of s.request.fns)P&&(i=await P(i,x));return i},serializedBody:Mt(x),url:w})};return{buildUrl:Ot,connect:d("CONNECT"),delete:d("DELETE"),get:d("GET"),getConfig:r,head:d("HEAD"),interceptors:s,options:d("OPTIONS"),patch:d("PATCH"),post:d("POST"),put:d("PUT"),request:u,setConfig:n,sse:{connect:g("CONNECT"),delete:g("DELETE"),get:g("GET"),head:g("HEAD"),options:g("OPTIONS"),patch:g("PATCH"),post:g("POST"),put:g("PUT"),trace:g("TRACE")},trace:d("TRACE")}};var Fl={$body_:"body",$headers_:"headers",$path_:"path",$query_:"query"},Gl=Object.entries(Fl),ec=(e,t)=>{t||(t=new Map);for(let r of e)"in"in r?r.key&&t.set(r.key,{in:r.in,map:r.map}):"key"in r?t.set(r.key,{map:r.map}):r.args&&ec(r.args,t);return t},Bl=e=>{for(let[t,r]of Object.entries(e))r&&typeof r=="object"&&!Object.keys(r).length&&delete e[t]},p=(e,t)=>{let r={body:{},headers:{},path:{},query:{}},n=ec(t),s;for(let[c,u]of e.entries())if(t[c]&&(s=t[c]),!!s)if("in"in s)if(s.key){let d=n.get(s.key),g=d.map||s.key;d.in&&(r[d.in][g]=u)}else r.body=u;else for(let[d,g]of Object.entries(u??{})){let h=n.get(d);if(h)if(h.in){let m=h.map||d;r[h.in][m]=g}else r[h.map]=g;else{let m=Gl.find(([x])=>d.startsWith(x));if(m){let[x,w]=m;r[w][d.slice(x.length)]=g}else if("allowExtra"in s&&s.allowExtra){for(let[x,w]of Object.entries(s.allowExtra))if(w){r[x][d]=g;break}}}}return Bl(r),r};var tc=Te(Re({baseUrl:"http://localhost:4096"}));var y=class{client;constructor(t){this.client=t?.client??tc}},Ft=class{defaultKey="default";instances=new Map;get(t){let r=this.instances.get(t??this.defaultKey);if(!r)throw new Error('No SDK client found. Create one with "new OpencodeClient()" to fix this error.');return r}set(t,r){this.instances.set(r??this.defaultKey,t)}},Gt=class extends y{remove(t,r){let n=p([t],[{args:[{in:"path",key:"providerID"}]}]);return(r?.client??this.client).delete({url:"/auth/{providerID}",...r,...n})}set(t,r){let n=p([t],[{args:[{in:"path",key:"providerID"},{key:"auth",map:"body"}]}]);return(r?.client??this.client).put({url:"/auth/{providerID}",...r,...n,headers:{"Content-Type":"application/json",...r?.headers,...n.headers}})}},Bt=class extends y{log(t,r){let n=p([t],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"},{in:"body",key:"service"},{in:"body",key:"level"},{in:"body",key:"message"},{in:"body",key:"extra"}]}]);return(r?.client??this.client).post({url:"/log",...r,...n,headers:{"Content-Type":"application/json",...r?.headers,...n.headers}})}agents(t,r){let n=p([t],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(r?.client??this.client).get({url:"/agent",...r,...n})}skills(t,r){let n=p([t],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(r?.client??this.client).get({url:"/skill",...r,...n})}},Kt=class extends y{moveSession(t,r){let n=p([t],[{args:[{in:"body",key:"sessionID"},{in:"body",key:"destination"},{in:"body",key:"moveChanges"}]}]);return(r?.client??this.client).post({url:"/experimental/control-plane/move-session",...r,...n,headers:{"Content-Type":"application/json",...r?.headers,...n.headers}})}},Nt=class extends y{get(t,r){let n=p([t],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(r?.client??this.client).get({url:"/experimental/capabilities",...r,...n})}},Ht=class extends y{get(t,r){let n=p([t],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(r?.client??this.client).get({url:"/experimental/console",...r,...n})}listOrgs(t,r){let n=p([t],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(r?.client??this.client).get({url:"/experimental/console/orgs",...r,...n})}switchOrg(t,r){let n=p([t],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"},{in:"body",key:"accountID"},{in:"body",key:"orgID"}]}]);return(r?.client??this.client).post({url:"/experimental/console/switch",...r,...n,headers:{"Content-Type":"application/json",...r?.headers,...n.headers}})}},Wt=class extends y{list(t,r){let n=p([t],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"},{in:"query",key:"roots"},{in:"query",key:"start"},{in:"query",key:"cursor"},{in:"query",key:"search"},{in:"query",key:"limit"},{in:"query",key:"archived"}]}]);return(r?.client??this.client).get({url:"/experimental/session",...r,...n})}background(t,r){let n=p([t],[{args:[{in:"path",key:"sessionID"},{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(r?.client??this.client).post({url:"/experimental/session/{sessionID}/background",...r,...n})}},Vt=class extends y{list(t,r){let n=p([t],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(r?.client??this.client).get({url:"/experimental/resource",...r,...n})}},zt=class extends y{generateName(t,r){let n=p([t],[{args:[{in:"path",key:"projectID"},{in:"query",key:"directory"},{in:"query",key:"workspace"},{in:"body",key:"context"}]}]);return(r?.client??this.client).post({url:"/experimental/project/{projectID}/copy/generate-name",...r,...n,headers:{"Content-Type":"application/json",...r?.headers,...n.headers}})}},Jt=class extends y{list(t,r){let n=p([t],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(r?.client??this.client).get({url:"/experimental/workspace/adapter",...r,...n})}},Xt=class extends y{list(t,r){let n=p([t],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(r?.client??this.client).get({url:"/experimental/workspace",...r,...n})}create(t,r){let n=p([t],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"},{in:"body",key:"id"},{in:"body",key:"type"},{in:"body",key:"branch"},{in:"body",key:"extra"}]}]);return(r?.client??this.client).post({url:"/experimental/workspace",...r,...n,headers:{"Content-Type":"application/json",...r?.headers,...n.headers}})}syncList(t,r){let n=p([t],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(r?.client??this.client).post({url:"/experimental/workspace/sync-list",...r,...n})}status(t,r){let n=p([t],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(r?.client??this.client).get({url:"/experimental/workspace/status",...r,...n})}remove(t,r){let n=p([t],[{args:[{in:"path",key:"id"},{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(r?.client??this.client).delete({url:"/experimental/workspace/{id}",...r,...n})}warp(t,r){let n=p([t],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"},{in:"body",key:"id"},{in:"body",key:"sessionID"},{in:"body",key:"copyChanges"}]}]);return(r?.client??this.client).post({url:"/experimental/workspace/warp",...r,...n,headers:{"Content-Type":"application/json",...r?.headers,...n.headers}})}_adapter;get adapter(){return this._adapter??=new Jt({client:this.client})}},Qt=class extends y{_controlPlane;get controlPlane(){return this._controlPlane??=new Kt({client:this.client})}_capabilities;get capabilities(){return this._capabilities??=new Nt({client:this.client})}_console;get console(){return this._console??=new Ht({client:this.client})}_session;get session(){return this._session??=new Wt({client:this.client})}_resource;get resource(){return this._resource??=new Vt({client:this.client})}_projectCopy;get projectCopy(){return this._projectCopy??=new zt({client:this.client})}_workspace;get workspace(){return this._workspace??=new Xt({client:this.client})}},Yt=class extends y{get(t){return(t?.client??this.client).get({url:"/global/config",...t})}update(t,r){let n=p([t],[{args:[{key:"config",map:"body"}]}]);return(r?.client??this.client).patch({url:"/global/config",...r,...n,headers:{"Content-Type":"application/json",...r?.headers,...n.headers}})}},Zt=class extends y{health(t){return(t?.client??this.client).get({url:"/global/health",...t})}event(t){return(t?.client??this.client).sse.get({url:"/global/event",...t})}dispose(t){return(t?.client??this.client).post({url:"/global/dispose",...t})}upgrade(t,r){let n=p([t],[{args:[{in:"body",key:"target"}]}]);return(r?.client??this.client).post({url:"/global/upgrade",...r,...n,headers:{"Content-Type":"application/json",...r?.headers,...n.headers}})}_config;get config(){return this._config??=new Yt({client:this.client})}},er=class extends y{subscribe(t,r){let n=p([t],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(r?.client??this.client).sse.get({url:"/event",...r,...n})}},tr=class extends y{get(t,r){let n=p([t],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(r?.client??this.client).get({url:"/config",...r,...n})}update(t,r){let n=p([t],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"},{key:"config",map:"body"}]}]);return(r?.client??this.client).patch({url:"/config",...r,...n,headers:{"Content-Type":"application/json",...r?.headers,...n.headers}})}providers(t,r){let n=p([t],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(r?.client??this.client).get({url:"/config/providers",...r,...n})}},rr=class extends y{list(t,r){let n=p([t],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"},{in:"query",key:"provider"},{in:"query",key:"model"}]}]);return(r?.client??this.client).get({url:"/experimental/tool",...r,...n})}ids(t,r){let n=p([t],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(r?.client??this.client).get({url:"/experimental/tool/ids",...r,...n})}},nr=class extends y{remove(t,r){let n=p([t],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"},{key:"worktreeRemoveInput",map:"body"}]}]);return(r?.client??this.client).delete({url:"/experimental/worktree",...r,...n,headers:{"Content-Type":"application/json",...r?.headers,...n.headers}})}list(t,r){let n=p([t],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(r?.client??this.client).get({url:"/experimental/worktree",...r,...n})}create(t,r){let n=p([t],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"},{key:"worktreeCreateInput",map:"body"}]}]);return(r?.client??this.client).post({url:"/experimental/worktree",...r,...n,headers:{"Content-Type":"application/json",...r?.headers,...n.headers}})}reset(t,r){let n=p([t],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"},{key:"worktreeResetInput",map:"body"}]}]);return(r?.client??this.client).post({url:"/experimental/worktree/reset",...r,...n,headers:{"Content-Type":"application/json",...r?.headers,...n.headers}})}},sr=class extends y{text(t,r){let n=p([t],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"},{in:"query",key:"pattern"}]}]);return(r?.client??this.client).get({url:"/find",...r,...n})}files(t,r){let n=p([t],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"},{in:"query",key:"query"},{in:"query",key:"dirs"},{in:"query",key:"type"},{in:"query",key:"limit"}]}]);return(r?.client??this.client).get({url:"/find/file",...r,...n})}symbols(t,r){let n=p([t],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"},{in:"query",key:"query"}]}]);return(r?.client??this.client).get({url:"/find/symbol",...r,...n})}},ir=class extends y{list(t,r){let n=p([t],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"},{in:"query",key:"path"}]}]);return(r?.client??this.client).get({url:"/file",...r,...n})}read(t,r){let n=p([t],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"},{in:"query",key:"path"}]}]);return(r?.client??this.client).get({url:"/file/content",...r,...n})}status(t,r){let n=p([t],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(r?.client??this.client).get({url:"/file/status",...r,...n})}},or=class extends y{dispose(t,r){let n=p([t],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(r?.client??this.client).post({url:"/instance/dispose",...r,...n})}},ar=class extends y{get(t,r){let n=p([t],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(r?.client??this.client).get({url:"/path",...r,...n})}},cr=class extends y{raw(t,r){let n=p([t],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(r?.client??this.client).get({url:"/vcs/diff/raw",...r,...n})}},lr=class extends y{get(t,r){let n=p([t],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(r?.client??this.client).get({url:"/vcs",...r,...n})}status(t,r){let n=p([t],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(r?.client??this.client).get({url:"/vcs/status",...r,...n})}diff(t,r){let n=p([t],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"},{in:"query",key:"mode"},{in:"query",key:"context"}]}]);return(r?.client??this.client).get({url:"/vcs/diff",...r,...n})}apply(t,r){let n=p([t],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"},{in:"body",key:"patch"}]}]);return(r?.client??this.client).post({url:"/vcs/apply",...r,...n,headers:{"Content-Type":"application/json",...r?.headers,...n.headers}})}_diff;get diff2(){return this._diff??=new cr({client:this.client})}},ur=class extends y{list(t,r){let n=p([t],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(r?.client??this.client).get({url:"/command",...r,...n})}},pr=class extends y{status(t,r){let n=p([t],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(r?.client??this.client).get({url:"/lsp",...r,...n})}},dr=class extends y{status(t,r){let n=p([t],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(r?.client??this.client).get({url:"/formatter",...r,...n})}},gr=class extends y{remove(t,r){let n=p([t],[{args:[{in:"path",key:"name"},{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(r?.client??this.client).delete({url:"/mcp/{name}/auth",...r,...n})}start(t,r){let n=p([t],[{args:[{in:"path",key:"name"},{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(r?.client??this.client).post({url:"/mcp/{name}/auth",...r,...n})}callback(t,r){let n=p([t],[{args:[{in:"path",key:"name"},{in:"query",key:"directory"},{in:"query",key:"workspace"},{in:"body",key:"code"}]}]);return(r?.client??this.client).post({url:"/mcp/{name}/auth/callback",...r,...n,headers:{"Content-Type":"application/json",...r?.headers,...n.headers}})}authenticate(t,r){let n=p([t],[{args:[{in:"path",key:"name"},{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(r?.client??this.client).post({url:"/mcp/{name}/auth/authenticate",...r,...n})}},mr=class extends y{status(t,r){let n=p([t],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(r?.client??this.client).get({url:"/mcp",...r,...n})}add(t,r){let n=p([t],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"},{in:"body",key:"name"},{in:"body",key:"config"}]}]);return(r?.client??this.client).post({url:"/mcp",...r,...n,headers:{"Content-Type":"application/json",...r?.headers,...n.headers}})}connect(t,r){let n=p([t],[{args:[{in:"path",key:"name"},{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(r?.client??this.client).post({url:"/mcp/{name}/connect",...r,...n})}disconnect(t,r){let n=p([t],[{args:[{in:"path",key:"name"},{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(r?.client??this.client).post({url:"/mcp/{name}/disconnect",...r,...n})}_auth;get auth(){return this._auth??=new gr({client:this.client})}},fr=class extends y{list(t,r){let n=p([t],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(r?.client??this.client).get({url:"/project",...r,...n})}current(t,r){let n=p([t],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(r?.client??this.client).get({url:"/project/current",...r,...n})}initGit(t,r){let n=p([t],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(r?.client??this.client).post({url:"/project/git/init",...r,...n})}update(t,r){let n=p([t],[{args:[{in:"path",key:"projectID"},{in:"query",key:"directory"},{in:"query",key:"workspace"},{in:"body",key:"name"},{in:"body",key:"icon"},{in:"body",key:"commands"}]}]);return(r?.client??this.client).patch({url:"/project/{projectID}",...r,...n,headers:{"Content-Type":"application/json",...r?.headers,...n.headers}})}directories(t,r){let n=p([t],[{args:[{in:"path",key:"projectID"},{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(r?.client??this.client).get({url:"/project/{projectID}/directories",...r,...n})}},yr=class extends y{shells(t,r){let n=p([t],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(r?.client??this.client).get({url:"/pty/shells",...r,...n})}list(t,r){let n=p([t],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(r?.client??this.client).get({url:"/pty",...r,...n})}create(t,r){let n=p([t],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"},{in:"body",key:"command"},{in:"body",key:"args"},{in:"body",key:"cwd"},{in:"body",key:"title"},{in:"body",key:"env"}]}]);return(r?.client??this.client).post({url:"/pty",...r,...n,headers:{"Content-Type":"application/json",...r?.headers,...n.headers}})}remove(t,r){let n=p([t],[{args:[{in:"path",key:"ptyID"},{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(r?.client??this.client).delete({url:"/pty/{ptyID}",...r,...n})}get(t,r){let n=p([t],[{args:[{in:"path",key:"ptyID"},{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(r?.client??this.client).get({url:"/pty/{ptyID}",...r,...n})}update(t,r){let n=p([t],[{args:[{in:"path",key:"ptyID"},{in:"query",key:"directory"},{in:"query",key:"workspace"},{in:"body",key:"title"},{in:"body",key:"size"}]}]);return(r?.client??this.client).put({url:"/pty/{ptyID}",...r,...n,headers:{"Content-Type":"application/json",...r?.headers,...n.headers}})}connectToken(t,r){let n=p([t],[{args:[{in:"path",key:"ptyID"},{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(r?.client??this.client).post({url:"/pty/{ptyID}/connect-token",...r,...n})}connect(t,r){let n=p([t],[{args:[{in:"path",key:"ptyID"},{in:"query",key:"directory"},{in:"query",key:"workspace"},{in:"query",key:"cursor"},{in:"query",key:"ticket"}]}]);return(r?.client??this.client).get({url:"/pty/{ptyID}/connect",...r,...n})}},hr=class extends y{list(t,r){let n=p([t],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(r?.client??this.client).get({url:"/question",...r,...n})}reply(t,r){let n=p([t],[{args:[{in:"path",key:"requestID"},{in:"query",key:"directory"},{in:"query",key:"workspace"},{in:"body",key:"answers"}]}]);return(r?.client??this.client).post({url:"/question/{requestID}/reply",...r,...n,headers:{"Content-Type":"application/json",...r?.headers,...n.headers}})}reject(t,r){let n=p([t],[{args:[{in:"path",key:"requestID"},{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(r?.client??this.client).post({url:"/question/{requestID}/reject",...r,...n})}},br=class extends y{list(t,r){let n=p([t],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(r?.client??this.client).get({url:"/permission",...r,...n})}reply(t,r){let n=p([t],[{args:[{in:"path",key:"requestID"},{in:"query",key:"directory"},{in:"query",key:"workspace"},{in:"body",key:"reply"},{in:"body",key:"message"}]}]);return(r?.client??this.client).post({url:"/permission/{requestID}/reply",...r,...n,headers:{"Content-Type":"application/json",...r?.headers,...n.headers}})}respond(t,r){let n=p([t],[{args:[{in:"path",key:"sessionID"},{in:"path",key:"permissionID"},{in:"query",key:"directory"},{in:"query",key:"workspace"},{in:"body",key:"response"}]}]);return(r?.client??this.client).post({url:"/session/{sessionID}/permissions/{permissionID}",...r,...n,headers:{"Content-Type":"application/json",...r?.headers,...n.headers}})}},xr=class extends y{authorize(t,r){let n=p([t],[{args:[{in:"path",key:"providerID"},{in:"query",key:"directory"},{in:"query",key:"workspace"},{in:"body",key:"method"},{in:"body",key:"inputs"}]}]);return(r?.client??this.client).post({url:"/provider/{providerID}/oauth/authorize",...r,...n,headers:{"Content-Type":"application/json",...r?.headers,...n.headers}})}callback(t,r){let n=p([t],[{args:[{in:"path",key:"providerID"},{in:"query",key:"directory"},{in:"query",key:"workspace"},{in:"body",key:"method"},{in:"body",key:"code"}]}]);return(r?.client??this.client).post({url:"/provider/{providerID}/oauth/callback",...r,...n,headers:{"Content-Type":"application/json",...r?.headers,...n.headers}})}},kr=class extends y{list(t,r){let n=p([t],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(r?.client??this.client).get({url:"/provider",...r,...n})}auth(t,r){let n=p([t],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(r?.client??this.client).get({url:"/provider/auth",...r,...n})}_oauth;get oauth(){return this._oauth??=new xr({client:this.client})}},Pr=class extends y{list(t,r){let n=p([t],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"},{in:"query",key:"scope"},{in:"query",key:"path"},{in:"query",key:"roots"},{in:"query",key:"start"},{in:"query",key:"search"},{in:"query",key:"limit"}]}]);return(r?.client??this.client).get({url:"/session",...r,...n})}create(t,r){let n=p([t],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"},{in:"body",key:"parentID"},{in:"body",key:"title"},{in:"body",key:"agent"},{in:"body",key:"model"},{in:"body",key:"metadata"},{in:"body",key:"permission"},{in:"body",key:"workspaceID"}]}]);return(r?.client??this.client).post({url:"/session",...r,...n,headers:{"Content-Type":"application/json",...r?.headers,...n.headers}})}status(t,r){let n=p([t],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(r?.client??this.client).get({url:"/session/status",...r,...n})}delete(t,r){let n=p([t],[{args:[{in:"path",key:"sessionID"},{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(r?.client??this.client).delete({url:"/session/{sessionID}",...r,...n})}get(t,r){let n=p([t],[{args:[{in:"path",key:"sessionID"},{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(r?.client??this.client).get({url:"/session/{sessionID}",...r,...n})}update(t,r){let n=p([t],[{args:[{in:"path",key:"sessionID"},{in:"query",key:"directory"},{in:"query",key:"workspace"},{in:"body",key:"title"},{in:"body",key:"metadata"},{in:"body",key:"permission"},{in:"body",key:"time"}]}]);return(r?.client??this.client).patch({url:"/session/{sessionID}",...r,...n,headers:{"Content-Type":"application/json",...r?.headers,...n.headers}})}children(t,r){let n=p([t],[{args:[{in:"path",key:"sessionID"},{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(r?.client??this.client).get({url:"/session/{sessionID}/children",...r,...n})}todo(t,r){let n=p([t],[{args:[{in:"path",key:"sessionID"},{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(r?.client??this.client).get({url:"/session/{sessionID}/todo",...r,...n})}diff(t,r){let n=p([t],[{args:[{in:"path",key:"sessionID"},{in:"query",key:"directory"},{in:"query",key:"workspace"},{in:"query",key:"messageID"}]}]);return(r?.client??this.client).get({url:"/session/{sessionID}/diff",...r,...n})}messages(t,r){let n=p([t],[{args:[{in:"path",key:"sessionID"},{in:"query",key:"directory"},{in:"query",key:"workspace"},{in:"query",key:"limit"},{in:"query",key:"before"}]}]);return(r?.client??this.client).get({url:"/session/{sessionID}/message",...r,...n})}prompt(t,r){let n=p([t],[{args:[{in:"path",key:"sessionID"},{in:"query",key:"directory"},{in:"query",key:"workspace"},{in:"body",key:"messageID"},{in:"body",key:"model"},{in:"body",key:"agent"},{in:"body",key:"noReply"},{in:"body",key:"tools"},{in:"body",key:"format"},{in:"body",key:"system"},{in:"body",key:"variant"},{in:"body",key:"parts"}]}]);return(r?.client??this.client).post({url:"/session/{sessionID}/message",...r,...n,headers:{"Content-Type":"application/json",...r?.headers,...n.headers}})}deleteMessage(t,r){let n=p([t],[{args:[{in:"path",key:"sessionID"},{in:"path",key:"messageID"},{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(r?.client??this.client).delete({url:"/session/{sessionID}/message/{messageID}",...r,...n})}message(t,r){let n=p([t],[{args:[{in:"path",key:"sessionID"},{in:"path",key:"messageID"},{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(r?.client??this.client).get({url:"/session/{sessionID}/message/{messageID}",...r,...n})}fork(t,r){let n=p([t],[{args:[{in:"path",key:"sessionID"},{in:"query",key:"directory"},{in:"query",key:"workspace"},{in:"body",key:"messageID"}]}]);return(r?.client??this.client).post({url:"/session/{sessionID}/fork",...r,...n,headers:{"Content-Type":"application/json",...r?.headers,...n.headers}})}abort(t,r){let n=p([t],[{args:[{in:"path",key:"sessionID"},{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(r?.client??this.client).post({url:"/session/{sessionID}/abort",...r,...n})}init(t,r){let n=p([t],[{args:[{in:"path",key:"sessionID"},{in:"query",key:"directory"},{in:"query",key:"workspace"},{in:"body",key:"modelID"},{in:"body",key:"providerID"},{in:"body",key:"messageID"}]}]);return(r?.client??this.client).post({url:"/session/{sessionID}/init",...r,...n,headers:{"Content-Type":"application/json",...r?.headers,...n.headers}})}unshare(t,r){let n=p([t],[{args:[{in:"path",key:"sessionID"},{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(r?.client??this.client).delete({url:"/session/{sessionID}/share",...r,...n})}share(t,r){let n=p([t],[{args:[{in:"path",key:"sessionID"},{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(r?.client??this.client).post({url:"/session/{sessionID}/share",...r,...n})}summarize(t,r){let n=p([t],[{args:[{in:"path",key:"sessionID"},{in:"query",key:"directory"},{in:"query",key:"workspace"},{in:"body",key:"providerID"},{in:"body",key:"modelID"},{in:"body",key:"auto"}]}]);return(r?.client??this.client).post({url:"/session/{sessionID}/summarize",...r,...n,headers:{"Content-Type":"application/json",...r?.headers,...n.headers}})}promptAsync(t,r){let n=p([t],[{args:[{in:"path",key:"sessionID"},{in:"query",key:"directory"},{in:"query",key:"workspace"},{in:"body",key:"messageID"},{in:"body",key:"model"},{in:"body",key:"agent"},{in:"body",key:"noReply"},{in:"body",key:"tools"},{in:"body",key:"format"},{in:"body",key:"system"},{in:"body",key:"variant"},{in:"body",key:"parts"}]}]);return(r?.client??this.client).post({url:"/session/{sessionID}/prompt_async",...r,...n,headers:{"Content-Type":"application/json",...r?.headers,...n.headers}})}command(t,r){let n=p([t],[{args:[{in:"path",key:"sessionID"},{in:"query",key:"directory"},{in:"query",key:"workspace"},{in:"body",key:"messageID"},{in:"body",key:"agent"},{in:"body",key:"model"},{in:"body",key:"arguments"},{in:"body",key:"command"},{in:"body",key:"variant"},{in:"body",key:"parts"}]}]);return(r?.client??this.client).post({url:"/session/{sessionID}/command",...r,...n,headers:{"Content-Type":"application/json",...r?.headers,...n.headers}})}shell(t,r){let n=p([t],[{args:[{in:"path",key:"sessionID"},{in:"query",key:"directory"},{in:"query",key:"workspace"},{in:"body",key:"messageID"},{in:"body",key:"agent"},{in:"body",key:"model"},{in:"body",key:"command"}]}]);return(r?.client??this.client).post({url:"/session/{sessionID}/shell",...r,...n,headers:{"Content-Type":"application/json",...r?.headers,...n.headers}})}revert(t,r){let n=p([t],[{args:[{in:"path",key:"sessionID"},{in:"query",key:"directory"},{in:"query",key:"workspace"},{in:"body",key:"messageID"},{in:"body",key:"partID"}]}]);return(r?.client??this.client).post({url:"/session/{sessionID}/revert",...r,...n,headers:{"Content-Type":"application/json",...r?.headers,...n.headers}})}unrevert(t,r){let n=p([t],[{args:[{in:"path",key:"sessionID"},{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(r?.client??this.client).post({url:"/session/{sessionID}/unrevert",...r,...n})}},wr=class extends y{delete(t,r){let n=p([t],[{args:[{in:"path",key:"sessionID"},{in:"path",key:"messageID"},{in:"path",key:"partID"},{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(r?.client??this.client).delete({url:"/session/{sessionID}/message/{messageID}/part/{partID}",...r,...n})}update(t,r){let n=p([t],[{args:[{in:"path",key:"sessionID"},{in:"path",key:"messageID"},{in:"path",key:"partID"},{in:"query",key:"directory"},{in:"query",key:"workspace"},{key:"part",map:"body"}]}]);return(r?.client??this.client).patch({url:"/session/{sessionID}/message/{messageID}/part/{partID}",...r,...n,headers:{"Content-Type":"application/json",...r?.headers,...n.headers}})}},_r=class extends y{list(t,r){let n=p([t],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"},{key:"body",map:"body"}]}]);return(r?.client??this.client).post({url:"/sync/history",...r,...n,headers:{"Content-Type":"application/json",...r?.headers,...n.headers}})}},Sr=class extends y{start(t,r){let n=p([t],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(r?.client??this.client).post({url:"/sync/start",...r,...n})}replay(t,r){let n=p([t],[{args:[{in:"query",key:"query_directory",map:"directory"},{in:"query",key:"workspace"},{in:"body",key:"body_directory",map:"directory"},{in:"body",key:"events"}]}]);return(r?.client??this.client).post({url:"/sync/replay",...r,...n,headers:{"Content-Type":"application/json",...r?.headers,...n.headers}})}steal(t,r){let n=p([t],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"},{in:"body",key:"sessionID"}]}]);return(r?.client??this.client).post({url:"/sync/steal",...r,...n,headers:{"Content-Type":"application/json",...r?.headers,...n.headers}})}_history;get history(){return this._history??=new _r({client:this.client})}},vr=class extends y{next(t,r){let n=p([t],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(r?.client??this.client).get({url:"/tui/control/next",...r,...n})}response(t,r){let n=p([t],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"},{key:"body",map:"body"}]}]);return(r?.client??this.client).post({url:"/tui/control/response",...r,...n,headers:{"Content-Type":"application/json",...r?.headers,...n.headers}})}},Cr=class extends y{appendPrompt(t,r){let n=p([t],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"},{in:"body",key:"text"}]}]);return(r?.client??this.client).post({url:"/tui/append-prompt",...r,...n,headers:{"Content-Type":"application/json",...r?.headers,...n.headers}})}openHelp(t,r){let n=p([t],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(r?.client??this.client).post({url:"/tui/open-help",...r,...n})}openSessions(t,r){let n=p([t],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(r?.client??this.client).post({url:"/tui/open-sessions",...r,...n})}openThemes(t,r){let n=p([t],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(r?.client??this.client).post({url:"/tui/open-themes",...r,...n})}openModels(t,r){let n=p([t],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(r?.client??this.client).post({url:"/tui/open-models",...r,...n})}submitPrompt(t,r){let n=p([t],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(r?.client??this.client).post({url:"/tui/submit-prompt",...r,...n})}clearPrompt(t,r){let n=p([t],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(r?.client??this.client).post({url:"/tui/clear-prompt",...r,...n})}executeCommand(t,r){let n=p([t],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"},{in:"body",key:"command"}]}]);return(r?.client??this.client).post({url:"/tui/execute-command",...r,...n,headers:{"Content-Type":"application/json",...r?.headers,...n.headers}})}showToast(t,r){let n=p([t],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"},{in:"body",key:"title"},{in:"body",key:"message"},{in:"body",key:"variant"},{in:"body",key:"duration"}]}]);return(r?.client??this.client).post({url:"/tui/show-toast",...r,...n,headers:{"Content-Type":"application/json",...r?.headers,...n.headers}})}publish(t,r){let n=p([t],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"},{key:"body",map:"body"}]}]);return(r?.client??this.client).post({url:"/tui/publish",...r,...n,headers:{"Content-Type":"application/json",...r?.headers,...n.headers}})}selectSession(t,r){let n=p([t],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"},{in:"body",key:"sessionID"}]}]);return(r?.client??this.client).post({url:"/tui/select-session",...r,...n,headers:{"Content-Type":"application/json",...r?.headers,...n.headers}})}_control;get control(){return this._control??=new vr({client:this.client})}},Rr=class extends y{get(t){return(t?.client??this.client).get({url:"/api/health",...t})}},Tr=class extends y{get(t,r){let n=p([t],[{args:[{in:"query",key:"location"}]}]);return(r?.client??this.client).get({url:"/api/location",...r,...n})}},Ir=class extends y{list(t,r){let n=p([t],[{args:[{in:"query",key:"location"}]}]);return(r?.client??this.client).get({url:"/api/agent",...r,...n})}},jr=class extends y{stage(t,r){let n=p([t],[{args:[{in:"path",key:"sessionID"},{in:"body",key:"messageID"},{in:"body",key:"files"}]}]);return(r?.client??this.client).post({url:"/api/session/{sessionID}/revert/stage",...r,...n,headers:{"Content-Type":"application/json",...r?.headers,...n.headers}})}clear(t,r){let n=p([t],[{args:[{in:"path",key:"sessionID"}]}]);return(r?.client??this.client).post({url:"/api/session/{sessionID}/revert/clear",...r,...n})}commit(t,r){let n=p([t],[{args:[{in:"path",key:"sessionID"}]}]);return(r?.client??this.client).post({url:"/api/session/{sessionID}/revert/commit",...r,...n})}},Ar=class extends y{list(t,r){let n=p([t],[{args:[{in:"path",key:"sessionID"}]}]);return(r?.client??this.client).get({url:"/api/session/{sessionID}/permission",...r,...n})}reply(t,r){let n=p([t],[{args:[{in:"path",key:"sessionID"},{in:"path",key:"requestID"},{in:"body",key:"reply"},{in:"body",key:"message"}]}]);return(r?.client??this.client).post({url:"/api/session/{sessionID}/permission/{requestID}/reply",...r,...n,headers:{"Content-Type":"application/json",...r?.headers,...n.headers}})}},Er=class extends y{list(t,r){let n=p([t],[{args:[{in:"path",key:"sessionID"}]}]);return(r?.client??this.client).get({url:"/api/session/{sessionID}/question",...r,...n})}reply(t,r){let n=p([t],[{args:[{in:"path",key:"sessionID"},{in:"path",key:"requestID"},{key:"questionV2Reply",map:"body"}]}]);return(r?.client??this.client).post({url:"/api/session/{sessionID}/question/{requestID}/reply",...r,...n,headers:{"Content-Type":"application/json",...r?.headers,...n.headers}})}reject(t,r){let n=p([t],[{args:[{in:"path",key:"sessionID"},{in:"path",key:"requestID"}]}]);return(r?.client??this.client).post({url:"/api/session/{sessionID}/question/{requestID}/reject",...r,...n})}},$r=class extends y{list(t,r){let n=p([t],[{args:[{in:"query",key:"workspace"},{in:"query",key:"limit"},{in:"query",key:"order"},{in:"query",key:"search"},{in:"query",key:"directory"},{in:"query",key:"project"},{in:"query",key:"subpath"},{in:"query",key:"cursor"}]}]);return(r?.client??this.client).get({url:"/api/session",...r,...n})}create(t,r){let n=p([t],[{args:[{in:"body",key:"id"},{in:"body",key:"agent"},{in:"body",key:"model"},{in:"body",key:"location"}]}]);return(r?.client??this.client).post({url:"/api/session",...r,...n,headers:{"Content-Type":"application/json",...r?.headers,...n.headers}})}get(t,r){let n=p([t],[{args:[{in:"path",key:"sessionID"}]}]);return(r?.client??this.client).get({url:"/api/session/{sessionID}",...r,...n})}switchAgent(t,r){let n=p([t],[{args:[{in:"path",key:"sessionID"},{in:"body",key:"agent"}]}]);return(r?.client??this.client).post({url:"/api/session/{sessionID}/agent",...r,...n,headers:{"Content-Type":"application/json",...r?.headers,...n.headers}})}switchModel(t,r){let n=p([t],[{args:[{in:"path",key:"sessionID"},{in:"body",key:"model"}]}]);return(r?.client??this.client).post({url:"/api/session/{sessionID}/model",...r,...n,headers:{"Content-Type":"application/json",...r?.headers,...n.headers}})}prompt(t,r){let n=p([t],[{args:[{in:"path",key:"sessionID"},{in:"body",key:"id"},{in:"body",key:"prompt"},{in:"body",key:"delivery"},{in:"body",key:"resume"}]}]);return(r?.client??this.client).post({url:"/api/session/{sessionID}/prompt",...r,...n,headers:{"Content-Type":"application/json",...r?.headers,...n.headers}})}compact(t,r){let n=p([t],[{args:[{in:"path",key:"sessionID"}]}]);return(r?.client??this.client).post({url:"/api/session/{sessionID}/compact",...r,...n})}wait(t,r){let n=p([t],[{args:[{in:"path",key:"sessionID"}]}]);return(r?.client??this.client).post({url:"/api/session/{sessionID}/wait",...r,...n})}context(t,r){let n=p([t],[{args:[{in:"path",key:"sessionID"}]}]);return(r?.client??this.client).get({url:"/api/session/{sessionID}/context",...r,...n})}messages(t,r){let n=p([t],[{args:[{in:"path",key:"sessionID"},{in:"query",key:"limit"},{in:"query",key:"order"},{in:"query",key:"cursor"}]}]);return(r?.client??this.client).get({url:"/api/session/{sessionID}/message",...r,...n})}_revert;get revert(){return this._revert??=new jr({client:this.client})}_permission;get permission(){return this._permission??=new Ar({client:this.client})}_question;get question(){return this._question??=new Er({client:this.client})}},qr=class extends y{list(t,r){let n=p([t],[{args:[{in:"query",key:"location"}]}]);return(r?.client??this.client).get({url:"/api/model",...r,...n})}},Dr=class extends y{list(t,r){let n=p([t],[{args:[{in:"query",key:"location"}]}]);return(r?.client??this.client).get({url:"/api/provider",...r,...n})}get(t,r){let n=p([t],[{args:[{in:"path",key:"providerID"},{in:"query",key:"location"}]}]);return(r?.client??this.client).get({url:"/api/provider/{providerID}",...r,...n})}},Mr=class extends y{key(t,r){let n=p([t],[{args:[{in:"path",key:"integrationID"},{in:"query",key:"location"},{in:"body",key:"key"},{in:"body",key:"label"}]}]);return(r?.client??this.client).post({url:"/api/integration/{integrationID}/connect/key",...r,...n,headers:{"Content-Type":"application/json",...r?.headers,...n.headers}})}oauth(t,r){let n=p([t],[{args:[{in:"path",key:"integrationID"},{in:"query",key:"location"},{in:"body",key:"methodID"},{in:"body",key:"inputs"},{in:"body",key:"label"}]}]);return(r?.client??this.client).post({url:"/api/integration/{integrationID}/connect/oauth",...r,...n,headers:{"Content-Type":"application/json",...r?.headers,...n.headers}})}},Ur=class extends y{cancel(t,r){let n=p([t],[{args:[{in:"path",key:"attemptID"},{in:"query",key:"location"}]}]);return(r?.client??this.client).delete({url:"/api/integration/attempt/{attemptID}",...r,...n})}status(t,r){let n=p([t],[{args:[{in:"path",key:"attemptID"},{in:"query",key:"location"}]}]);return(r?.client??this.client).get({url:"/api/integration/attempt/{attemptID}",...r,...n})}complete(t,r){let n=p([t],[{args:[{in:"path",key:"attemptID"},{in:"query",key:"location"},{in:"body",key:"code"}]}]);return(r?.client??this.client).post({url:"/api/integration/attempt/{attemptID}/complete",...r,...n,headers:{"Content-Type":"application/json",...r?.headers,...n.headers}})}},Or=class extends y{list(t,r){let n=p([t],[{args:[{in:"query",key:"location"}]}]);return(r?.client??this.client).get({url:"/api/integration",...r,...n})}get(t,r){let n=p([t],[{args:[{in:"path",key:"integrationID"},{in:"query",key:"location"}]}]);return(r?.client??this.client).get({url:"/api/integration/{integrationID}",...r,...n})}_connect;get connect(){return this._connect??=new Mr({client:this.client})}_attempt;get attempt(){return this._attempt??=new Ur({client:this.client})}},Lr=class extends y{remove(t,r){let n=p([t],[{args:[{in:"path",key:"credentialID"},{in:"query",key:"location"}]}]);return(r?.client??this.client).delete({url:"/api/credential/{credentialID}",...r,...n})}update(t,r){let n=p([t],[{args:[{in:"path",key:"credentialID"},{in:"query",key:"location"},{in:"body",key:"label"}]}]);return(r?.client??this.client).patch({url:"/api/credential/{credentialID}",...r,...n,headers:{"Content-Type":"application/json",...r?.headers,...n.headers}})}},Fr=class extends y{list(t,r){let n=p([t],[{args:[{in:"query",key:"location"}]}]);return(r?.client??this.client).get({url:"/api/permission/request",...r,...n})}},Gr=class extends y{list(t,r){let n=p([t],[{args:[{in:"query",key:"projectID"}]}]);return(r?.client??this.client).get({url:"/api/permission/saved",...r,...n})}remove(t,r){let n=p([t],[{args:[{in:"path",key:"id"}]}]);return(r?.client??this.client).delete({url:"/api/permission/saved/{id}",...r,...n})}},Br=class extends y{_request;get request(){return this._request??=new Fr({client:this.client})}_saved;get saved(){return this._saved??=new Gr({client:this.client})}},Kr=class extends y{read(t,r){let n=p([t],[{args:[{in:"query",key:"location"}]}]);return(r?.client??this.client).get({url:"/api/fs/read/*",...r,...n})}list(t,r){let n=p([t],[{args:[{in:"query",key:"location"},{in:"query",key:"path"}]}]);return(r?.client??this.client).get({url:"/api/fs/list",...r,...n})}find(t,r){let n=p([t],[{args:[{in:"query",key:"location"},{in:"query",key:"query"},{in:"query",key:"type"},{in:"query",key:"limit"}]}]);return(r?.client??this.client).get({url:"/api/fs/find",...r,...n})}},Nr=class extends y{list(t,r){let n=p([t],[{args:[{in:"query",key:"location"}]}]);return(r?.client??this.client).get({url:"/api/command",...r,...n})}},Hr=class extends y{list(t,r){let n=p([t],[{args:[{in:"query",key:"location"}]}]);return(r?.client??this.client).get({url:"/api/skill",...r,...n})}},Wr=class extends y{subscribe(t){return(t?.client??this.client).sse.get({url:"/api/event",...t})}},Vr=class extends y{list(t,r){let n=p([t],[{args:[{in:"query",key:"location"}]}]);return(r?.client??this.client).get({url:"/api/pty",...r,...n})}create(t,r){let n=p([t],[{args:[{in:"query",key:"location"},{in:"body",key:"command"},{in:"body",key:"args"},{in:"body",key:"cwd"},{in:"body",key:"title"},{in:"body",key:"env"}]}]);return(r?.client??this.client).post({url:"/api/pty",...r,...n,headers:{"Content-Type":"application/json",...r?.headers,...n.headers}})}remove(t,r){let n=p([t],[{args:[{in:"path",key:"ptyID"},{in:"query",key:"location"}]}]);return(r?.client??this.client).delete({url:"/api/pty/{ptyID}",...r,...n})}get(t,r){let n=p([t],[{args:[{in:"path",key:"ptyID"},{in:"query",key:"location"}]}]);return(r?.client??this.client).get({url:"/api/pty/{ptyID}",...r,...n})}update(t,r){let n=p([t],[{args:[{in:"path",key:"ptyID"},{in:"query",key:"location"},{in:"body",key:"title"},{in:"body",key:"size"}]}]);return(r?.client??this.client).put({url:"/api/pty/{ptyID}",...r,...n,headers:{"Content-Type":"application/json",...r?.headers,...n.headers}})}connectToken(t,r){let n=p([t],[{args:[{in:"path",key:"ptyID"},{in:"query",key:"location"}]}]);return(r?.client??this.client).post({url:"/api/pty/{ptyID}/connect-token",...r,...n})}connect(t,r){let n=p([t],[{args:[{in:"path",key:"ptyID"},{in:"query",key:"location[directory]"},{in:"query",key:"location[workspace]"},{in:"query",key:"cursor"},{in:"query",key:"ticket"}]}]);return(r?.client??this.client).get({url:"/api/pty/{ptyID}/connect",...r,...n})}},zr=class extends y{list(t,r){let n=p([t],[{args:[{in:"query",key:"location"}]}]);return(r?.client??this.client).get({url:"/api/question/request",...r,...n})}},Jr=class extends y{_request;get request(){return this._request??=new zr({client:this.client})}},Xr=class extends y{list(t,r){let n=p([t],[{args:[{in:"query",key:"location"}]}]);return(r?.client??this.client).get({url:"/api/reference",...r,...n})}},Qr=class extends y{remove(t,r){let n=p([t],[{args:[{in:"path",key:"projectID"},{in:"query",key:"location"},{in:"body",key:"directory"},{in:"body",key:"force"}]}]);return(r?.client??this.client).delete({url:"/experimental/project/{projectID}/copy",...r,...n,headers:{"Content-Type":"application/json",...r?.headers,...n.headers}})}create(t,r){let n=p([t],[{args:[{in:"path",key:"projectID"},{in:"query",key:"location"},{in:"body",key:"strategy"},{in:"body",key:"directory"},{in:"body",key:"name"}]}]);return(r?.client??this.client).post({url:"/experimental/project/{projectID}/copy",...r,...n,headers:{"Content-Type":"application/json",...r?.headers,...n.headers}})}refresh(t,r){let n=p([t],[{args:[{in:"path",key:"projectID"},{in:"query",key:"location"}]}]);return(r?.client??this.client).post({url:"/experimental/project/{projectID}/copy/refresh",...r,...n})}},Yr=class extends y{_health;get health(){return this._health??=new Rr({client:this.client})}_location;get location(){return this._location??=new Tr({client:this.client})}_agent;get agent(){return this._agent??=new Ir({client:this.client})}_session;get session(){return this._session??=new $r({client:this.client})}_model;get model(){return this._model??=new qr({client:this.client})}_provider;get provider(){return this._provider??=new Dr({client:this.client})}_integration;get integration(){return this._integration??=new Or({client:this.client})}_credential;get credential(){return this._credential??=new Lr({client:this.client})}_permission;get permission(){return this._permission??=new Br({client:this.client})}_fs;get fs(){return this._fs??=new Kr({client:this.client})}_command;get command(){return this._command??=new Nr({client:this.client})}_skill;get skill(){return this._skill??=new Hr({client:this.client})}_event;get event(){return this._event??=new Wr({client:this.client})}_pty;get pty(){return this._pty??=new Vr({client:this.client})}_question;get question(){return this._question??=new Jr({client:this.client})}_reference;get reference(){return this._reference??=new Xr({client:this.client})}_projectCopy;get projectCopy(){return this._projectCopy??=new Qr({client:this.client})}},et=class e extends y{static __registry=new Ft;constructor(t){super(t),e.__registry.set(this,t?.key)}_auth;get auth(){return this._auth??=new Gt({client:this.client})}_app;get app(){return this._app??=new Bt({client:this.client})}_experimental;get experimental(){return this._experimental??=new Qt({client:this.client})}_global;get global(){return this._global??=new Zt({client:this.client})}_event;get event(){return this._event??=new er({client:this.client})}_config;get config(){return this._config??=new tr({client:this.client})}_tool;get tool(){return this._tool??=new rr({client:this.client})}_worktree;get worktree(){return this._worktree??=new nr({client:this.client})}_find;get find(){return this._find??=new sr({client:this.client})}_file;get file(){return this._file??=new ir({client:this.client})}_instance;get instance(){return this._instance??=new or({client:this.client})}_path;get path(){return this._path??=new ar({client:this.client})}_vcs;get vcs(){return this._vcs??=new lr({client:this.client})}_command;get command(){return this._command??=new ur({client:this.client})}_lsp;get lsp(){return this._lsp??=new pr({client:this.client})}_formatter;get formatter(){return this._formatter??=new dr({client:this.client})}_mcp;get mcp(){return this._mcp??=new mr({client:this.client})}_project;get project(){return this._project??=new fr({client:this.client})}_pty;get pty(){return this._pty??=new yr({client:this.client})}_question;get question(){return this._question??=new hr({client:this.client})}_permission;get permission(){return this._permission??=new br({client:this.client})}_provider;get provider(){return this._provider??=new kr({client:this.client})}_session;get session(){return this._session??=new Pr({client:this.client})}_part;get part(){return this._part??=new wr({client:this.client})}_sync;get sync(){return this._sync??=new Sr({client:this.client})}_tui;get tui(){return this._tui??=new Cr({client:this.client})}_v2;get v2(){return this._v2??=new Yr({client:this.client})}};function nc(e,t,r,n){if(!n?.throwOnError||e instanceof Error)return e;if(typeof e=="object"&&e!==null&&Object.keys(e).length>0){let c=e,u=typeof c.data?.message=="string"&&c.data.message||typeof c.message=="string"&&c.message||typeof c.name=="string"&&c.name||rc(r,t);return new Error(u,{cause:{body:e,status:t?.status}})}if(typeof e=="string"&&e.length>0)return new Error(e,{cause:{body:e,status:t?.status}});let s=t?"(empty response body)":"network error (no response)";return new Error(`opencode server ${rc(r,t)}: ${s}`,{cause:{body:e,status:t?.status}})}function rc(e,t){let r=e?.method??"?",n=e?.url??"?",s=t?.status,c=t?.statusText;return`${r} ${n}${s?" \u2192 "+s:""}${c?" "+c:""}`}function Kl(e,t,r){if(e)return t&&(e===t||r&&e===r(t))?t:e}function Nl(e,t){if(e.method!=="GET"&&e.method!=="HEAD")return e;let r=new URL(e.url),n=!1;for(let[c,u]of[["x-opencode-directory","directory"],["x-opencode-workspace","workspace"]]){let d=Kl(e.headers.get(c),u==="directory"?t.directory:t.workspace,u==="directory"?encodeURIComponent:void 0);if(d){for(let g of r.pathname.startsWith("/api/")?[u,`location[${u}]`]:[u])r.searchParams.has(g)||r.searchParams.set(g,d);n=!0}}if(!n)return e;let s=new Request(r,e);return s.headers.delete("x-opencode-directory"),s.headers.delete("x-opencode-workspace"),s}function Zr(e){e?.fetch||(e={...e,fetch:n=>(n.timeout=!1,fetch(n))}),e?.directory&&(e.headers={...e.headers,"x-opencode-directory":encodeURIComponent(e.directory)}),e?.experimental_workspaceID&&(e.headers={...e.headers,"x-opencode-workspace":e.experimental_workspaceID});let t=Te(e);return t.interceptors.request.use(r=>Nl(r,{directory:e?.directory,workspace:e?.experimental_workspaceID})),t.interceptors.response.use(r=>{if(r.headers.get("content-type")==="text/html")throw new Error("Request is not supported by this version of OpenCode Server (Server responded with text/html)");return r}),t.interceptors.error.use(nc),new et({client:t})}function Hl(e){return new Promise(t=>setTimeout(t,e))}async function sc(e,t,r){let n=Math.max(1,t?.attempts??1),s=t?.baseDelayMs??0,c=t?.invalidateBetweenAttempts??!1,u=null;for(let d=0;d<n;d++)if(d>0&&(c&&r?.(),s>0&&await Hl(s)),u=await e(),u)return u;return u}var Wl=3e4;function Vl(e){return(e instanceof Request?e.url:String(e)).includes("/global/event")}function ic(e,t,r=Wl){let n=e instanceof Request?e.signal:t?.signal;if(Vl(e))return n??void 0;let s=AbortSignal.timeout(r);return n?typeof AbortSignal.any=="function"?AbortSignal.any([n,s]):n:s}function en(e,t,r){let n=new Headers(e instanceof Request?e.headers:void 0);return t?.headers&&new Headers(t.headers).forEach((s,c)=>{n.set(c,s)}),r&&!n.has("Authorization")&&n.set("Authorization",`Bearer ${r}`),n}function oc(){return new Response(JSON.stringify({error:"Not authenticated"}),{status:401,headers:{"Content-Type":"application/json"}})}async function tt(){return T().getToken()}async function le(e){return sc(()=>T().getToken(),e,Ie)}function Ie(){}function zl(e){}function Jl(e){}async function je(){return tt()}async function tn(e){return le(e)}function ac(e,t,r,n){if(e instanceof Request){let s=new Request(e,{headers:r,...n?{signal:n}:{}});return fetch(s)}return fetch(e,{...t,headers:r,...n?{signal:n}:{}})}async function R(e,t,r){let{retryOnAuthError:n=!0}=r??{},s=await tn();if(!s)return oc();let c=en(e,t,s),u=ic(e,t),d=await ac(e,t,c,u);if(d.status===401&&n&&s){Ie();let g=await tn({attempts:2,baseDelayMs:200});if(g&&g!==s){let h=en(e,t,g);return ac(e,t,h,u)}}return d}var ue={url:null,sandboxId:null,dbSandboxId:null,version:0},Xl=new Set;function cc(e,t=null,r=null){if(!(ue.url===e&&ue.sandboxId===t&&ue.dbSandboxId===r)){ue={url:e,sandboxId:t,dbSandboxId:r,version:ue.version+1};for(let n of Xl)n()}}function lc(){return ue.url}function Ql(e){let t=e.length;for(;t>0&&e.charCodeAt(t-1)===47;)t--;return e.slice(0,t)}function Ae(){return Ql(T().backendUrl||"http://localhost:8008/v1")}function uc(){let e=T().sandboxId||"";return`${Ae()}/p/${e}/8000`}function Yl(e){return`${Ae()}/p/${e}/8000`}function rt(e){return Yl(e)}function $(){let e=lc();return e||(T().billingEnabled??!1?"":uc())}var C=class extends Error{status;code;details;data;detail;response;url;endpoint;timeout;constructor(t,r={}){super(t),this.name="ApiError";let{name:n,stack:s,...c}=r;Object.assign(this,c),n&&(this.name=n),s&&(this.stack=s);let u=typeof t=="string"?t:t==null?"":String(t);Object.defineProperty(this,"message",{value:u,enumerable:!0,writable:!0,configurable:!0}),Object.setPrototypeOf(this,new.target.prototype)}},pe=class extends C{constructor(t="Not authenticated"){super(t,{code:"NO_SESSION"}),this.name="AuthError"}},te=class e extends Error{status;detail;constructor(t,r,n){super(n||r.message||`Billing Error: ${t}`),this.name="BillingError",this.status=t,this.detail=r,Object.setPrototypeOf(this,e.prototype)}},de=class e extends Error{status;detail;constructor(t=431,r,n){let s="Request headers are too large",c="Try uploading files one at a time, or reduce the number of files in a single request.";super(n||r?.message||s),this.name="RequestTooLargeError",this.status=t,this.detail={message:r?.message||s,suggestion:r?.suggestion||c},Object.setPrototypeOf(this,e.prototype)}};function ge(e){let t=e.response?.status||e.status;if(t!==402)return e;let r=e.response?.data||e.data||e.detail||{},n=r?.detail||r;return new te(t,{message:n?.message||e.message||"Billing error",...n})}function pc(e){return e instanceof te}function dc(e){if(!(e instanceof te))return null;let t=e.detail?.message?.toLowerCase()||"";return t.includes("credit")||t.includes("balance")||t.includes("insufficient")?{alertTitle:"You ran out of credits",alertSubtitle:"Upgrade your plan to get more credits and continue using the AI assistant."}:{alertTitle:"Billing check failed",alertSubtitle:e.detail?.message||"Please upgrade to continue."}}async function rn(e,t){return(await e.json().catch(()=>({})))?.error||e.statusText||t}function nn(e){if(!e)throw new Error("[opencode-sdk] Server URL not ready \u2014 sandbox is still loading");return e}async function sn(e){let t=nn(e),r=await R(`${t}/env`);if(!r.ok)throw new Error(await rn(r,"Failed to load secrets"));return(await r.json()).secrets??{}}async function on(e,t,r){let n=nn(e),s=await R(`${n}/env/${encodeURIComponent(t)}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({value:r})});if(!s.ok)throw new Error(await rn(s,"Failed to save secret"))}async function an(e,t){let r=nn(e),n=await R(`${r}/env/${encodeURIComponent(t)}`,{method:"DELETE"});if(!n.ok)throw new Error(await rn(n,"Failed to delete secret"))}var gc={list:sn,set:on,delete:an};async function mc(e,t,r){let n=e;for(;n.endsWith("/");)n=n.slice(0,-1);let s=await R(`${n}/kortix/triggers${t}`,{...r,headers:{"Content-Type":"application/json",...r?.headers}}),c=await s.json();if(!s.ok)throw new Error(c?.error||c?.message||`Request failed with ${s.status}`);return c}function re(e){let t=e.length;for(;t>0&&e.charCodeAt(t-1)===47;)t--;return t===e.length?e:e.slice(0,t)}async function nt(e,t){let r=await e.json().catch(()=>({}));return r?.error||r?.message||e.statusText||t}function Ee(e){if(!e)throw new Error("[kortix-pty] Server URL not ready \u2014 sandbox is still loading");return re(e)}async function cn(e){let t=Ee(e),r=await R(`${t}/kortix/pty`);if(!r.ok)throw new Error(await nt(r,"Failed to list terminals"));return r.json()}async function ln(e,t){let r=Ee(e),n=await R(`${r}/kortix/pty`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t??{})});if(!n.ok)throw new Error(await nt(n,"Failed to create terminal"));return n.json()}async function un(e,t,r){let n=Ee(e),s=await R(`${n}/kortix/pty/${encodeURIComponent(t)}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify(r)});if(!s.ok)throw new Error(await nt(s,"Failed to update terminal"));return s.json()}async function pn(e,t){let r=Ee(e),n=await R(`${r}/kortix/pty/${encodeURIComponent(t)}`,{method:"DELETE"});if(!n.ok)throw new Error(await nt(n,"Failed to remove terminal"))}async function dn(e,t){let r=Ee(t),s=`${(()=>{try{let d=new URL(r);return d.protocol==="https:"?d.protocol="wss:":d.protocol==="http:"&&(d.protocol="ws:"),typeof window<"u"&&window.location.protocol==="https:"&&d.protocol==="ws:"&&(d.protocol="wss:"),re(d.toString())}catch{return r.replace("https://","wss://").replace("http://","ws://")}})()}/kortix/pty/${encodeURIComponent(e)}/connect`,c=await je();if(!c)return s;let u=s.includes("?")?"&":"?";return`${s}${u}token=${encodeURIComponent(c)}`}var fc={list:cn,create:ln,update:un,remove:pn,webSocketUrl:dn};async function b(e,t,r,n){let s=e;for(;s.endsWith("/");)s=s.slice(0,-1);let c=await R(`${s}${t}`,{...r,headers:{"Content-Type":"application/json",...r?.headers}},n),u=await c.text(),d={};try{d=u?JSON.parse(u):{}}catch{d={}}if(!c.ok)throw new Error(d?.error||d?.message||d?.details||u.slice(0,200)||`Request failed with ${c.status}`);return d}async function Zl(e,t={}){let r=new URLSearchParams;t.projectId&&r.set("project_id",t.projectId),t.status&&r.set("status",t.status);let n=r.toString()?`?${r}`:"";return b(e,`/kortix/tasks${n}`)}async function eu(e,t){return b(e,`/kortix/tasks/${encodeURIComponent(t)}`)}async function tu(e,t){return b(e,`/kortix/tasks/${encodeURIComponent(t)}/events`)}async function ru(e,t){return b(e,`/kortix/tasks/${encodeURIComponent(t)}/status`)}async function nu(e,t){return b(e,"/kortix/tasks",{method:"POST",body:JSON.stringify(t)})}async function su(e,t,r){return b(e,`/kortix/tasks/${encodeURIComponent(t)}`,{method:"PATCH",body:JSON.stringify(r)})}async function iu(e,t){return b(e,`/kortix/tasks/${encodeURIComponent(t)}/start`,{method:"POST"})}async function ou(e,t){return b(e,`/kortix/tasks/${encodeURIComponent(t)}/approve`,{method:"POST"})}async function au(e,t){return b(e,`/kortix/tasks/${encodeURIComponent(t)}`,{method:"DELETE"})}async function cu(e,t){let r=t?`?project_id=${encodeURIComponent(t)}`:"";return b(e,`/kortix/tickets${r}`)}async function lu(e,t){return b(e,`/kortix/tickets/${encodeURIComponent(t)}`)}async function uu(e,t){return b(e,`/kortix/tickets/${encodeURIComponent(t)}/events`)}async function pu(e,t){return b(e,"/kortix/tickets",{method:"POST",body:JSON.stringify(t)})}async function du(e,t,r){return b(e,`/kortix/tickets/${encodeURIComponent(t)}`,{method:"PATCH",body:JSON.stringify(r)})}async function gu(e,t,r){return b(e,`/kortix/tickets/${encodeURIComponent(t)}/status`,{method:"POST",body:JSON.stringify(r)})}async function mu(e,t,r){return b(e,`/kortix/tickets/${encodeURIComponent(t)}/assign`,{method:"POST",body:JSON.stringify(r)})}async function fu(e,t,r){return b(e,`/kortix/tickets/${encodeURIComponent(t)}/unassign`,{method:"POST",body:JSON.stringify(r)})}async function yu(e,t,r){return b(e,`/kortix/tickets/${encodeURIComponent(t)}/comments`,{method:"POST",body:JSON.stringify(r)})}async function hu(e,t){return b(e,`/kortix/tickets/${encodeURIComponent(t)}`,{method:"DELETE"})}async function bu(e,t){return b(e,`/kortix/projects/${encodeURIComponent(t)}/columns`)}async function xu(e,t,r){return b(e,`/kortix/projects/${encodeURIComponent(t)}/columns`,{method:"PUT",body:JSON.stringify({columns:r})})}async function ku(e,t){return b(e,`/kortix/projects/${encodeURIComponent(t)}/fields`)}async function Pu(e,t,r){return b(e,`/kortix/projects/${encodeURIComponent(t)}/fields`,{method:"PUT",body:JSON.stringify({fields:r})})}async function wu(e,t){return b(e,`/kortix/projects/${encodeURIComponent(t)}/templates`)}async function _u(e,t,r){return b(e,`/kortix/projects/${encodeURIComponent(t)}/templates`,{method:"PUT",body:JSON.stringify({templates:r})})}async function Su(e,t){return b(e,`/kortix/projects/${encodeURIComponent(t)}/pm-session`,{method:"POST"})}async function vu(e,t){return b(e,`/kortix/projects/${encodeURIComponent(t)}/agents`)}async function Cu(e,t,r){return b(e,`/kortix/projects/${encodeURIComponent(t)}/agents`,{method:"POST",body:JSON.stringify(r)})}async function Ru(e,t,r,n){return b(e,`/kortix/projects/${encodeURIComponent(t)}/agents/${encodeURIComponent(r)}`,{method:"PATCH",body:JSON.stringify(n)})}async function Tu(e,t,r){return b(e,`/kortix/projects/${encodeURIComponent(t)}/agents/${encodeURIComponent(r)}`,{method:"DELETE"})}async function Iu(e,t,r){return b(e,`/kortix/projects/${encodeURIComponent(t)}/agents/${encodeURIComponent(r)}/persona`)}async function ju(e,t,r=200){return b(e,`/kortix/projects/${encodeURIComponent(t)}/activity?limit=${r}`)}async function Au(e){return b(e,"/kortix/projects")}async function Eu(e,t){return b(e,`/kortix/projects/${encodeURIComponent(t)}`)}async function $u(e,t){return b(e,`/kortix/projects/by-session/${encodeURIComponent(t)}`)}async function qu(e,t){return b(e,`/kortix/projects/${encodeURIComponent(t)}/sessions`)}async function Du(e,t){return b(e,`/kortix/projects/${encodeURIComponent(t)}`,{method:"DELETE"})}async function Mu(e,t,r){return b(e,`/kortix/projects/${encodeURIComponent(t)}`,{method:"PATCH",body:JSON.stringify(r)})}async function Uu(e,t,r="all"){return b(e,`/kortix/projects/${encodeURIComponent(t)}/milestones?status=${r}`)}async function Ou(e,t,r){return b(e,`/kortix/projects/${encodeURIComponent(t)}/milestones/${encodeURIComponent(r)}`)}async function Lu(e,t,r){return b(e,`/kortix/projects/${encodeURIComponent(t)}/milestones/${encodeURIComponent(r)}/events`)}async function Fu(e,t,r){return b(e,`/kortix/projects/${encodeURIComponent(t)}/milestones`,{method:"POST",body:JSON.stringify(r)})}async function Gu(e,t,r,n){return b(e,`/kortix/projects/${encodeURIComponent(t)}/milestones/${encodeURIComponent(r)}`,{method:"PATCH",body:JSON.stringify(n)})}async function Bu(e,t,r,n){return b(e,`/kortix/projects/${encodeURIComponent(t)}/milestones/${encodeURIComponent(r)}/close`,{method:"POST",body:JSON.stringify(n)})}async function Ku(e,t,r){return b(e,`/kortix/projects/${encodeURIComponent(t)}/milestones/${encodeURIComponent(r)}/reopen`,{method:"POST"})}async function Nu(e,t,r){return b(e,`/kortix/projects/${encodeURIComponent(t)}/milestones/${encodeURIComponent(r)}`,{method:"DELETE"})}async function Hu(e,t){return b(e,`/kortix/projects/${encodeURIComponent(t)}/credentials`)}async function Wu(e,t,r){return b(e,`/kortix/projects/${encodeURIComponent(t)}/credentials/${encodeURIComponent(r)}/events`)}async function Vu(e,t,r){return b(e,`/kortix/projects/${encodeURIComponent(t)}/credentials`,{method:"POST",body:JSON.stringify(r)})}async function zu(e,t,r){return b(e,`/kortix/projects/${encodeURIComponent(t)}/credentials/${encodeURIComponent(r)}`)}async function Ju(e,t,r){return b(e,`/kortix/projects/${encodeURIComponent(t)}/credentials/${encodeURIComponent(r)}`,{method:"DELETE"})}var Xu=1e4,Qu={retryOnAuthError:!1};function me(e,t,r){return b(e,t,{signal:AbortSignal.timeout(Xu),...r},Qu)}async function Yu(e,t=!1){return(await me(e,`/kortix/services${t?"?all=true":""}`)).services??[]}async function Zu(e){return(await me(e,"/kortix/services/templates")).templates??[]}async function ep(e,t){return(await me(e,`/kortix/services/${encodeURIComponent(t)}/logs`)).logs??[]}async function tp(e,t,r){let n=r==="delete",s=n?`/kortix/services/${encodeURIComponent(t)}`:`/kortix/services/${encodeURIComponent(t)}/${r}`;return me(e,s,{method:n?"DELETE":"POST"})}async function rp(e,t){return me(e,`/kortix/services/reconcile${t?"?reload=true":""}`,{method:"POST"})}async function np(e,t){return me(e,"/kortix/services/register",{method:"POST",body:JSON.stringify(t)})}var st=new Map,it=class extends Error{constructor(t="[opencode-sdk] Server URL not ready \u2014 sandbox is still loading"){super(t),this.name="RuntimeNotReadyError"}};function X(){let e=$();if(!e)throw new it;return ne(e)}function ne(e){if(!e)throw new Error("[opencode-sdk] getClientForUrl called without a url");let t=st.get(e);if(t)return t;if(!Xe())throw new Error("[opencode-sdk] No auth token provider configured \u2014 call configureKortix()/createKortix() before talking to a sandbox runtime.");let r=Zr({baseUrl:e,fetch:R});return st.set(e,r),r}function sp(e){st.delete(e)}function ip(){st.clear()}var ot=new Map;function op(e){if(!e)throw new Error("[opencode-sdk] getPublicClientForUrl called without a url");let t=ot.get(e);if(t)return t;let r=Zr({baseUrl:e,fetch});return ot.set(e,r),r}function ap(e){ot.delete(e)}function cp(){ot.clear()}async function lp(e){let t=await e.text().catch(()=>"");try{let r=JSON.parse(t);return r?.error||r?.message||t||e.statusText||`HTTP ${e.status}`}catch{return t||e.statusText||`HTTP ${e.status}`}}async function up(e){let t=$();if(!t)throw new C("[opencode-sdk] Server URL not ready \u2014 sandbox is still loading",{code:"RUNTIME_UNAVAILABLE"});let r=await R(`${t}/kortix/services/system/reload`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({mode:e})});if(!r.ok)throw new C(`System reload failed (${r.status}): ${await lp(r)}`,{status:r.status,response:r,code:"RUNTIME_UNAVAILABLE"});return r.json()}function hc(e){if(e.error){let t=e.error,r=t?.data?.message||t?.message||(typeof t?.error=="string"?t.error:null)||"SDK request failed";throw new C(r,{status:t?.response?.status??t?.status,response:t?.response,details:t})}return e.data}async function fe(e){let t=await e.text().catch(()=>""),r=null;try{r=JSON.parse(t)}catch{}return r?.error||t||e.statusText||`HTTP ${e.status}`}async function at(e,t=$()){let r=await R(`${t}${e}`);if(!r.ok)throw new C(await fe(r),{status:r.status,response:r});return r.json()}var bc=["/workspace","/tmp","/home","/opt"],pp=bc.filter(e=>e!=="/workspace");function dp(e){return bc.some(t=>e===t||e.startsWith(`${t}/`))}function gp(e){return dp(e)?e:`/workspace/${e.replace(/^\/+/,"")}`}function qe(e){let t=e||"";if(t==="/workspace"||t==="/workspace/")return"";if(t.startsWith("/workspace/"))t=t.slice(11);else if(pp.some(r=>t===r||t.startsWith(`${r}/`)))return t;for(;t.startsWith("/");)t=t.slice(1);return t}var mp=qe;async function gn(e,t=$()){let r=qe(e)||".";return(await at(`/file?path=${encodeURIComponent(r)}`,t)).map(s=>({...s,path:s.absolute||`/workspace/${s.path}`}))}async function ct(e,t=$()){let r=qe(e),n=await R(`${t}/file/content?path=${encodeURIComponent(r)}`);if(!n.ok)throw new C(await fe(n),{status:n.status,response:n});return n.json()}async function fp(e,t,r=$()){let n=qe(e),s=await R(`${r}/file/raw?path=${encodeURIComponent(n)}`);if(!s.ok)throw new C(await fe(s),{status:s.status,response:s});if((s.headers.get("content-type")||"").includes("text/html"))throw new C("File could not be loaded (raw byte route unavailable)",{status:s.status,response:s,code:"INVALID_CONTENT_TYPE"});let c=await s.blob();return t&&(!c.type||c.type==="application/octet-stream")?new Blob([c],{type:t}):c}async function lt(e,t=$()){try{return await fp(e,void 0,t)}catch{}let r=await ct(e,t);if(r.encoding==="base64"&&r.content){let n=Uint8Array.from(atob(r.content),s=>s.charCodeAt(0));return new Blob([n],{type:r.mimeType||"application/octet-stream"})}return new Blob([r.content??""],{type:r.mimeType||"text/plain;charset=utf-8"})}function mn(e=$()){return at("/file/status",e)}async function fn(e,t,r=$()){let n=new URLSearchParams({query:e});return t?.type&&n.set("type",t.type),t?.limit&&n.set("limit",String(t.limit)),at(`/find/file?${n.toString()}`,r)}async function yn(e,t=$()){return(await at(`/find?pattern=${encodeURIComponent(e)}`,t)).map(n=>({path:typeof n.path=="string"?n.path:n.path?.text??"",lines:typeof n.lines=="string"?n.lines:n.lines?.text??"",line_number:n.line_number,absolute_offset:n.absolute_offset,submatches:(n.submatches??[]).map(s=>({start:s.start,end:s.end}))}))}var $e=[400,1200],yp=e=>e===408||e===429||e===502||e===503||e===504,yc=e=>new Promise(t=>setTimeout(t,e));async function hp(e){let t=await e.text().catch(()=>""),r=null;try{r=t?JSON.parse(t):null}catch{}let n=r?.error||r?.message||r?.data?.message;return typeof n=="string"&&n.trim()?n.trim():(e.headers.get("content-type")||"").includes("text/html")||/<html[\s>]/i.test(t)?e.status===502||/bad gateway/i.test(t)?"Bad gateway while reaching the sandbox upload service. Please retry.":e.statusText||`HTTP ${e.status}`:t.replace(/\s+/g," ").trim().slice(0,500)||e.statusText||`HTTP ${e.status}`}async function xc(e,t){let r;for(let s=0;s<=$e.length;s++){let c;try{c=await t(e())}catch(d){if(r=d,s===$e.length)break;await yc($e[s]);continue}if(c.ok)return c.json();let u=await hp(c);if(r=new C(`Upload failed (${c.status}): ${u}`,{status:c.status,response:c}),!yp(c.status)||s===$e.length)throw r;await yc($e[s])}if(r instanceof C)throw r;let n=r instanceof Error?r.message:String(r||"request failed");throw new C(`Upload failed: ${n}`)}function ut(e,t,r,n=$()){return xc(()=>{let s=new FormData,c=(t??"").trim();return c&&s.append("path",c.startsWith("/")?c:`/${c}`),r?s.append("file",e,r):s.append("file",e),s},s=>R(`${n}/file/upload`,{method:"POST",body:s}))}function bp(e,t,r=$()){return xc(()=>{let n=new FormData;return n.append(e,t,e.split("/").pop()||"file"),n},async n=>{let s={},c=await je();return c&&(s.Authorization=`Bearer ${c}`),fetch(`${r}/file/upload`,{method:"POST",body:n,headers:s})})}function hn(e,t=$()){let r=e.trim(),s=(r.startsWith("/")?r:`/${r}`).split("/"),c=s.pop()||"untitled",u=s.join("/")||"/workspace";return ut(new File([" "],c,{type:"application/octet-stream"}),u,void 0,t)}async function bn(e,t,r=$()){return bp(t,await lt(e,r),r)}async function xn(e,t=$()){let r=await R(`${t}/file`,{method:"DELETE",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:e})});if(!r.ok)throw new C(`Delete failed (${r.status}): ${await fe(r)}`,{status:r.status,response:r});return r.json()}async function kn(e,t=$()){let r=await R(`${t}/file/mkdir`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:e})});if(!r.ok)throw new C(`Mkdir failed (${r.status}): ${await fe(r)}`,{status:r.status,response:r});return r.json()}async function Pn(e,t,r=$()){let n=await R(`${r}/file/rename`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({from:e,to:t})});if(!n.ok)throw new C(`Rename failed (${n.status}): ${await fe(n)}`,{status:n.status,response:n});return n.json()}async function xp(){return hc(await X().project.current())}async function kc(){return hc(await X().global.health())}async function kp(){try{return(await kc()).healthy===!0}catch{return!1}}var Pc={list:gn,read:ct,readBlob:lt,status:mn,findFiles:fn,findText:yn,upload:ut,create:hn,copy:bn,remove:xn,mkdir:kn,rename:Pn,currentProject:xp,health:kc,isReachable:kp,toDaemonPath:qe,toSandboxAbsolutePath:gp,toWorkspaceRelative:mp};var Q=()=>T().backendUrl||"",wp=e=>new Promise(t=>setTimeout(t,e)),_p=new Set([502,503,504]),wc=e=>_p.has(e),Sp=e=>{let t=(e??"GET").toUpperCase();return t==="GET"||t==="HEAD"},vp=2,wn=!1;function Cp(e){wn=e}function Rp(){return wn}async function se(e,t={}){let{showErrors:r=!0,errorContext:n,timeout:s=3e4,...c}=t,u=new AbortController,d=null,g=!1,h=!1;try{d=setTimeout(()=>{!g&&!u.signal.aborted&&(g=!0,h=!0,u.abort())},s);let m=await le(),x=c.body instanceof FormData,w={};if(x||(w["Content-Type"]="application/json"),Object.assign(w,c.headers),wn&&(w["x-kortix-admin-bypass"]="1"),m)w.Authorization=`Bearer ${m}`;else return{error:new pe,success:!1};let k=await fetch(e,{...c,headers:w,signal:u.signal,credentials:c.credentials??"omit"});if(d&&(clearTimeout(d),d=null),!k.ok&&Sp(c.method)&&wc(k.status))for(let P=0;P<vp;P++){try{await k.arrayBuffer()}catch{}await wp(250*2**P);let _=new AbortController,D=setTimeout(()=>{_.abort()},s);try{k=await fetch(e,{...c,headers:w,signal:_.signal,credentials:c.credentials??"omit"})}catch{break}finally{D&&(clearTimeout(D),D=null)}if(k.ok||!wc(k.status))break}if(!k.ok){let P=`HTTP ${k.status}: ${k.statusText}`,_=null;try{_=await k.json(),typeof _.message=="string"?P=_.message:_.error&&typeof _.error=="string"?P=_.error:typeof _.detail=="string"?P=_.detail:typeof _.detail?.message=="string"&&(P=_.detail.message)}catch{}let D=new C(P,{status:k.status,response:k,details:_||void 0,data:_,detail:_?.detail,code:_?.code||_?.error_code||_?.detail?.error_code||k.status.toString()});if(k.status===402&&(D=ge(D)),k.status===403&&_?.code==="account_mfa_required"&&typeof window<"u"&&typeof window.dispatchEvent=="function")try{window.dispatchEvent(new CustomEvent("kortix:mfa-required"))}catch{}return k.status===431&&(D=new de(431,{message:"Request is too large to process",suggestion:"Try uploading files one at a time, or reduce the number of files attached to your message."})),r&&T().onError?.(D,n),{error:D,success:!1}}let l,i=k.headers.get("content-type");return i?.includes("application/json")?l=await k.json():i?.includes("text/")?l=await k.text():l=await k.blob(),{data:l,success:!0}}catch(m){d&&(clearTimeout(d),d=null);let x=m?.name==="AbortError"||m?.name==="AbortSignal"||m instanceof Error&&m.message.includes("aborted");x&&(g=!0);let w;if(x){if(!h)return{error:new C("Request aborted",{name:"AbortError",code:"ABORTED"}),success:!1};let k=e.replace(Q(),"")||e;w=new C(`Request timed out after ${Math.round(s/1e3)}s: ${k}`,{code:"TIMEOUT",url:e,endpoint:k,timeout:s}),r&&T().onError?.(w,n)}else m instanceof Error?(w=new C(m.message,{name:m.name||"ApiError",stack:m.stack}),r&&T().onError?.(w,n)):(w=new C(String(m)),r&&T().onError?.(w,n));return{error:w,success:!1}}}var Tp={async execute(e,t){try{let{data:r,error:n}=await e();if(n){let s=new C(n.message||"Database error",{code:n.code,details:n});return T().onError?.(s,t),{error:s,success:!1}}return{data:r,success:!0}}catch(r){let n=r instanceof Error?new C(r.message,{name:r.name||"ApiError",stack:r.stack}):new C(String(r));return T().onError?.(n,t),{error:n,success:!1}}}},o={get:(e,t)=>se(`${Q()}${e}`,{...t,method:"GET"}),post:(e,t,r)=>se(`${Q()}${e}`,{...r,method:"POST",body:t?JSON.stringify(t):void 0}),put:(e,t,r)=>se(`${Q()}${e}`,{...r,method:"PUT",body:t?JSON.stringify(t):void 0}),patch:(e,t,r)=>se(`${Q()}${e}`,{...r,method:"PATCH",body:t?JSON.stringify(t):void 0}),delete:(e,t)=>se(`${Q()}${e}`,{...t,method:"DELETE"}),upload:(e,t,r)=>{let{headers:n,...s}=r||{},c={...n};return delete c["Content-Type"],se(`${Q()}${e}`,{...s,method:"POST",body:t,headers:c})},uploadPut:(e,t,r)=>{let{headers:n,...s}=r||{},c={...n};return delete c["Content-Type"],se(`${Q()}${e}`,{...s,method:"PUT",body:t,headers:c})}};function a(e,t="Project request failed"){if(!e.success||e.data===void 0)throw e.error??new Error(t);return e.data}function _n(e){return e.replace(/\/v1\/?$/,"")}async function ye(e,t){if(!e.backendUrl||!e.accessToken)return null;let r=_n(e.backendUrl);try{let n=await fetch(`${r}${t}`,{headers:{Authorization:`Bearer ${e.accessToken}`,"Content-Type":"application/json"},signal:AbortSignal.timeout(e.timeoutMs??8e3)});return n.ok?await n.json():null}catch{return null}}async function Sn(){return a(await o.get("/accounts"))}async function vn(e){return a(await o.post("/accounts",e))}async function Cn(e){return a(await o.get(`/accounts/${e}`))}async function Rn(e,t){return a(await o.patch(`/accounts/${e}`,{name:t}))}async function Tn(e){return a(await o.get(`/accounts/${e}/members`))}async function In(e,t){return a(await o.post(`/accounts/${e}/members`,t,{showErrors:!1}))}async function jn(e){return a(await o.get(`/accounts/${e}/invites`))}async function An(e,t){return a(await o.delete(`/accounts/${e}/invites/${t}`))}async function En(e,t){return a(await o.post(`/accounts/${e}/invites/${t}/resend`,{}))}async function $n(e){return a(await o.get(`/account-invites/${e}`,{showErrors:!1}))}async function qn(e){return a(await o.post(`/account-invites/${e}/accept`,{}))}async function Dn(e){return a(await o.post(`/account-invites/${e}/decline`,{}))}async function Mn(e,t){return a(await o.delete(`/accounts/${e}/members/${t}`))}async function Un(e,t,r){return a(await o.patch(`/accounts/${e}/members/${t}`,{role:r}))}async function On(e){return a(await o.post(`/accounts/${e}/leave`,{}))}async function Ip(e){return ye(e,"/v1/accounts")}async function Ln(){let e=await o.get("/accounts/me",{showErrors:!1});return!e.success||!e.data?{valid:!1,error:e.error}:{valid:!0,identity:e.data}}async function ie(){return a(await o.get("/projects"))}async function Fn(e){let t=e?`?account_id=${encodeURIComponent(e)}`:"";return a(await o.get(`/projects${t}`))}async function pt(e,t){return a(await o.get(`/projects/${e}`,t))}async function Gn(e,t,r="write"){return a(await o.post(`/projects/${e}/git/collaborators`,{github_username:t,permission:r}))}async function Bn(e,t){return a(await o.post(`/projects/${e}/manifest/validate`,{raw:t}),"Failed to validate manifest")}async function Kn(e){return a(await o.post(`/projects/${e}/git-token`,{}),"Failed to mint git token")}function jp(e){let t=e.metadata?.git;return t?.provider==="github"&&t?.managed===!0}async function dt(e,t){return a(await o.get(`/projects/${e}/detail`,{showErrors:!1,...t}))}async function gt(e,t){return a(await o.get(`/projects/${e}/llm-catalog`,{showErrors:!1,...t}))}async function mt(e,t){return a(await o.get(`/projects/${e}/model-picker`,{showErrors:!1,...t}))}async function Nn(e){return a(await o.post("/projects",e))}async function Hn(e){return a(await o.post("/projects/create-repo",e))}async function Wn(e){return a(await o.post("/projects/provision",{seed_starter:!0,...e}))}async function Ap(){try{return a(await o.get("/projects/managed-git/status",{showErrors:!1}))}catch{return{configured:!1,provider:"github"}}}async function ft(e,t){return a(await o.patch(`/projects/${e}`,t))}async function Vn(e,t,r){return a(await o.patch(`/projects/${e}/experimental`,{feature:t,enabled:r}))}async function zn(e,t){return a(await o.patch(`/projects/${e}/sandbox-provider`,{provider:t}))}async function Ep(e,t){return a(await o.patch(`/projects/${e}/warm-pool`,t))}async function Jn(e,t){return a(await o.patch(`/projects/${e}/onboarding`,{completed:t}))}async function yt(e){return a(await o.delete(`/projects/${e}`))}async function $p(e,t){return ye(e,`/v1/projects?account_id=${encodeURIComponent(t)}`)}async function qp(e,t){if(!e.backendUrl||!e.accessToken)return{ok:!1,limitReached:!1};let r=_n(e.backendUrl);try{let n=await fetch(`${r}/v1/projects/provision`,{method:"POST",headers:{Authorization:`Bearer ${e.accessToken}`,"Content-Type":"application/json"},body:JSON.stringify({seed_starter:!0,...t}),signal:AbortSignal.timeout(e.timeoutMs??9e4)});if(n.ok){let s=await n.json().catch(()=>null);return s?.project_id?{ok:!0,project:s}:{ok:!1,limitReached:!1}}return n.status===403?{ok:!1,limitReached:(await n.json().catch(()=>null))?.code==="project_limit_reached"}:{ok:!1,limitReached:!1}}catch{return{ok:!1,limitReached:!1}}}async function Xn(e){return a(await o.post("/projects/link-repository",e,{showErrors:!1}))}async function Qn(e){return a(await o.get(`/projects/github/installation?account_id=${encodeURIComponent(e)}`,{showErrors:!1}))}async function Yn(e){return a(await o.get(`/projects/github/installations?account_id=${encodeURIComponent(e)}`,{showErrors:!1}))}async function Zn(e,t){let r=new URLSearchParams({account_id:e});return t&&r.set("installation_id",t),a(await o.get(`/projects/github/repositories?${r.toString()}`,{showErrors:!1}))}async function es(e,t,r){let n=new URLSearchParams({account_id:e,installation_id:t,repo_full_name:r});return a(await o.get(`/projects/github/repository-branches?${n.toString()}`,{showErrors:!1}))}async function ts(e){return a(await o.post("/projects/github/installation",e,{showErrors:!1}))}async function rs(e,t){let r=new URLSearchParams({account_id:e});return t&&r.set("installation_id",t),a(await o.delete(`/projects/github/installation?${r.toString()}`))}async function Dp(e,t){return a(await o.post(`/projects/${e}/access-requests`,{message:t?.trim()||void 0},{showErrors:!1}))}async function ns(e,t){return a(await o.get(`/projects/${e}/access-requests`,t))}async function ss(e,t,r="member"){return a(await o.post(`/projects/${e}/access-requests/${t}/approve`,{role:r}))}async function is(e,t){return a(await o.post(`/projects/${e}/access-requests/${t}/reject`,{}))}async function os(e){return a(await o.get(`/projects/${e}/access`))}async function as(e,t,r){return a(await o.put(`/projects/${e}/access/${t}`,{role:r}))}async function cs(e,t){return a(await o.delete(`/projects/${e}/access/${t}`))}function Mp(e){return"status"in e&&e.status==="invited"}async function ls(e,t,r,n){return a(await o.post(`/projects/${e}/access/invite`,{email:t,role:r,...n!==void 0?{expires_at:n}:{}}))}async function us(e){return a(await o.get(`/projects/${e}/access/pending-invites`))}async function ps(e,t){return a(await o.delete(`/projects/${e}/access/pending-invites/${t}`))}async function ds(e,t){return a(await o.post(`/projects/${e}/access/pending-invites/${t}/resend`))}async function gs(e){return a(await o.get(`/projects/${e}/group-grants`))}async function ms(e,t,r,n){return a(await o.post(`/projects/${e}/group-grants`,n===void 0?{group_id:t,role:r}:{group_id:t,role:r,expires_at:n}))}async function fs(e,t,r,n){return a(await o.patch(`/projects/${e}/group-grants/${t}`,n===void 0?{role:r}:{role:r,expires_at:n}))}async function ys(e,t){return a(await o.delete(`/projects/${e}/group-grants/${t}`))}async function hs(e){return a(await o.get(`/projects/${e}/resource-grants`))}async function bs(e,t){return a(await o.post(`/projects/${e}/resource-grants`,{resource_type:t.resourceType,resource_id:t.resourceId,principal_type:t.principalType,principal_id:t.principalId,...t.expiresAt!==void 0?{expires_at:t.expiresAt}:{}}))}async function xs(e,t){return a(await o.delete(`/projects/${e}/resource-grants/${t}`))}async function ks(e,t){return a(await o.get(`/projects/${e}/approvals`,{showErrors:t?.showErrors}))}async function Ps(e,t){return a(await o.get(`/projects/${e}/approvals/needs-input`,{showErrors:t?.showErrors}))}async function ws(e,t,r,n="once"){return a(await o.post(`/projects/${e}/approvals/${t}`,{decision:r,scope:n}))}async function _s(e){return a(await o.get(`/projects/${e}/secrets`,{showErrors:!1}))}async function Ss(e,t){return a(await o.post(`/projects/${e}/secrets`,t))}async function vs(e,t,r){return a(await o.post(`/projects/${e}/oauth/${t}/start`,{sharing:r?.sharing}))}async function Cs(e,t,r){return a(await o.post(`/projects/${e}/oauth/${t}/poll`,{flow_id:r}))}async function Rs(e,t){return a(await o.put(`/projects/${e}/git-credential`,t))}async function Ts(e,t){return a(await o.delete(`/projects/${e}/secrets/${encodeURIComponent(t)}`))}async function Is(e,t,r){return a(await o.put(`/projects/${e}/secrets/${encodeURIComponent(t)}/personal`,r))}async function js(e,t){return a(await o.delete(`/projects/${e}/secrets/${encodeURIComponent(t)}/personal`))}async function As(e){return a(await o.get(`/projects/${e}/connector-profiles`))}async function Es(e,t){return a(await o.post(`/projects/${e}/connector-profiles`,t))}async function $s(e,t,r){return a(await o.put(`/projects/${e}/connector-profiles/${t}/credential`,r))}async function qs(e,t){return a(await o.put(`/projects/${e}/connector-profiles/${t}/revoke`,{}))}async function Ds(e,t){return a(await o.put(`/projects/${e}/connector-profiles/${t}/activate`,{}))}async function Ms(e){return a(await o.get(`/executor/projects/${e}/connectors`,{showErrors:!1}))}async function Us(e){return a(await o.post(`/executor/projects/${e}/connectors/sync`,{}))}async function Os(e,t,r){return a(await o.put(`/executor/projects/${e}/connectors/${encodeURIComponent(t)}/credential-mode`,{mode:r}))}async function Ls(e,t,r){return a(await o.put(`/executor/projects/${e}/connectors/${encodeURIComponent(t)}/sensitive`,{sensitive:r}))}async function Fs(e,t){return a(await o.get(`/executor/projects/${e}/connectors/${encodeURIComponent(t)}/policies`))}async function Gs(e,t,r){return a(await o.put(`/executor/projects/${e}/connectors/${encodeURIComponent(t)}/policies`,{policies:r}))}async function Bs(e,t){return a(await o.get(`/executor/projects/${e}/connectors/${encodeURIComponent(t)}/config`))}async function Ks(e,t,r){return a(await o.put(`/executor/projects/${e}/connectors/${encodeURIComponent(t)}/name`,{name:r}))}async function Ns(e,t){return a(await o.post(`/executor/projects/${e}/connectors/${encodeURIComponent(t)}/connect`,{}))}async function Hs(e,t){return a(await o.post(`/executor/projects/${e}/connectors`,t))}async function Ws(e,t){return a(await o.delete(`/executor/projects/${e}/connectors/${encodeURIComponent(t)}`))}async function Vs(e,t,r){let n=new URLSearchParams;t&&n.set("q",t),r&&n.set("cursor",r);let s=n.toString();return a(await o.get(`/executor/projects/${e}/pipedream/apps${s?`?${s}`:""}`))}async function zs(){return a(await o.get("/executor/connect-status"))}async function Js(e,t,r){return a(await o.put(`/executor/projects/${e}/connectors/${encodeURIComponent(t)}/credential`,{value:r}))}async function Xs(e,t){return a(await o.post(`/executor/projects/${e}/connectors/${encodeURIComponent(t)}/connect/finalize`,{}))}async function Qs(e){return a(await o.get(`/executor/projects/${e}/policies`))}async function Ys(e,t,r){return a(await o.put(`/executor/projects/${e}/policies`,{policies:t,defaultMode:r}))}async function Zs(e){return a(await o.get(`/projects/${e}/sandboxes`))}async function ei(e){return a(await o.get(`/projects/${e}/snapshots`))}async function ht(e){return a(await o.get(`/projects/${e}/sandbox-health`,{showErrors:!1,timeout:15e3}))}async function ti(e,t){return a(await o.post(`/projects/${e}/snapshots/rebuild`,t?{slug:t}:{}))}async function ri(e){return a(await o.post(`/projects/${e}/snapshots/fix-with-agent`,{}))}async function ni(e,t){return a(await o.post(`/projects/${e}/sandbox-templates`,t))}async function si(e,t,r){return a(await o.patch(`/projects/${e}/sandbox-templates/${t}`,r))}async function ii(e,t){return a(await o.delete(`/projects/${e}/sandbox-templates/${t}`))}async function oi(e,t){return a(await o.post(`/projects/${e}/sandbox-templates/${t}/build`,{}))}async function ai(e){return a(await o.get(`/projects/${e}/sandboxes`))}async function ci(e,t){let r=new URLSearchParams;t?.ref&&r.set("ref",t.ref),t?.path&&r.set("path",t.path);let n=r.toString()?`?${r.toString()}`:"";return a(await o.get(`/projects/${e}/files${n}`,{showErrors:!1}))}async function li(e,t,r){let n=new URLSearchParams({q:t});return r?.content&&n.set("content","1"),r?.ref&&n.set("ref",r.ref),r?.limit&&n.set("limit",String(r.limit)),a(await o.get(`/projects/${e}/files/search?${n.toString()}`))}async function ui(e,t,r){let n=new URLSearchParams({path:t});return r&&n.set("ref",r),a(await o.get(`/projects/${e}/files/content?${n.toString()}`))}async function pi(e,t,r){let n=new URLSearchParams;t&&n.set("ref",t),r&&n.set("path",r);let s=n.toString()?`?${n.toString()}`:"",c=await le(),u=`${T().backendUrl||""}/projects/${e}/files/archive${s}`,d=await fetch(u,{method:"GET",headers:c?{Authorization:`Bearer ${c}`}:{}});if(!d.ok){let g=await d.text().catch(()=>"");throw new Error(g||`Failed to download (HTTP ${d.status})`)}return await d.blob()}async function di(e){return a(await o.get(`/projects/${e}/branches`))}async function gi(e,t){let r=new URLSearchParams;t?.ref&&r.set("ref",t.ref),t?.path&&r.set("path",t.path),t?.limit!=null&&r.set("limit",String(t.limit)),t?.skip!=null&&r.set("skip",String(t.skip));let n=r.toString()?`?${r.toString()}`:"";return a(await o.get(`/projects/${e}/commits${n}`))}async function mi(e,t){return a(await o.get(`/projects/${e}/commits/${encodeURIComponent(t)}`))}async function fi(e,t,r){let n=new URLSearchParams;r?.path&&n.set("path",r.path);let s=n.toString()?`?${n.toString()}`:"";return a(await o.get(`/projects/${e}/commits/${encodeURIComponent(t)}/diff${s}`))}async function yi(e,t,r){let n=new URLSearchParams({path:t});return r?.ref&&n.set("ref",r.ref),r?.limit!=null&&n.set("limit",String(r.limit)),r?.skip!=null&&n.set("skip",String(r.skip)),a(await o.get(`/projects/${e}/files/history?${n.toString()}`))}async function hi(e,t){let r=new URLSearchParams({from:t.from,into:t.into});return a(await o.get(`/projects/${e}/version-diff?${r.toString()}`))}async function bi(e,t){let r=t?`?status=${t}`:"";return a(await o.get(`/projects/${e}/change-requests${r}`,{showErrors:!1,timeout:15e3}))}async function xi(e,t){return a(await o.get(`/projects/${e}/change-requests/${t}`))}async function ki(e,t){return a(await o.get(`/projects/${e}/change-requests/${t}/diff`))}async function Pi(e,t){return a(await o.get(`/projects/${e}/change-requests/${t}/merge-preview`))}async function wi(e,t){return a(await o.post(`/projects/${e}/change-requests`,t))}async function _i(e,t,r){return a(await o.post(`/projects/${e}/change-requests/${t}/merge`,r??{},{showErrors:!1}))}async function Si(e,t){return a(await o.post(`/projects/${e}/change-requests/${t}/close`,{}))}async function vi(e,t){return a(await o.post(`/projects/${e}/change-requests/${t}/reopen`,{}))}async function Ci(e,t,r){return a(await o.post(`/projects/${e}/change-requests/${t}/request-changes`,{feedback:r}))}async function Ri(e,t,r){return a(await o.post(`/projects/${e}/sessions/${t}/commit-push`,r??{}))}var Ti=new Set;function Ii(e){e&&Ti.add(e)}function ji(e){return!!e&&Ti.has(e)}function Up(e){e&&Ti.delete(e)}async function he(e){return a(await o.get(`/projects/${e}/sessions`))}async function Ai(e,t,r){return a(await o.put(`/projects/${e}/sessions/${t}/sharing`,r))}async function Ei(e,t){return a(await o.get(`/projects/${e}/sessions/${t}/previews`))}async function $i(e,t){return a(await o.get(`/projects/${e}/sessions/${t}/public-shares`,{showErrors:!1}))}async function qi(e,t,r){return a(await o.post(`/projects/${e}/sessions/${t}/public-shares`,r))}async function Di(e,t,r){return a(await o.delete(`/projects/${e}/sessions/${t}/public-shares/${r}`))}async function be(e,t){let r=a(await o.post(`/projects/${e}/sessions`,t??{}));return t?.initial_prompt||Ii(r?.session_id),r}async function Mi(e,t,r){return a(await o.get(`/projects/${e}/sessions/${t}`,{showErrors:r?.showErrors}))}async function Ui(e,t,r,n){let s=r?`?limit=${r}`:"";return a(await o.get(`/projects/${e}/sessions/${t}/audit${s}`,{showErrors:n?.showErrors}))}async function Oi(e,t,r){let n=new URLSearchParams;r?.limit!=null&&n.set("limit",String(r.limit)),r?.chars!=null&&n.set("chars",String(r.chars));let s=n.toString();return a(await o.get(`/projects/${e}/sessions/${t}/transcript${s?`?${s}`:""}`))}async function Li(e,t,r){return a(await o.patch(`/projects/${e}/sessions/${t}`,r))}async function Fi(e,t){return a(await o.delete(`/projects/${e}/sessions/${t}`))}async function De(e,t){return a(await o.post(`/projects/${e}/sessions/${t}/restart`,{}))}async function Me(e,t){return a(await o.post(`/projects/${e}/sessions/${t}/stop`,{}))}async function Gi(e){return a(await o.get(`/projects/${e}/triggers`))}async function Bi(e,t){return a(await o.post(`/projects/${e}/triggers`,t))}async function Ki(e,t,r){return a(await o.patch(`/projects/${e}/triggers/${t}`,r))}async function Ni(e,t){return a(await o.delete(`/projects/${e}/triggers/${t}`))}async function Hi(e,t){return a(await o.patch(`/projects/${e}/triggers/activation`,{paused:t}))}async function Wi(e,t){return a(await o.post(`/projects/${e}/triggers/${t}/fire`,{}))}var Y=new Map;function Vi(e,t){return`${e}::${t}`}function _c(e,t){Y.delete(e),Y.set(e,t)}function Sc(e,t){let r=Vi(e,t),n=Y.get(r);return n&&_c(r,n),n}function vc(e,t,r){let n=Vi(e,t);if(!Y.has(n)&&Y.size>=512){let s=Y.keys().next().value;s!==void 0&&Y.delete(s)}_c(n,r)}function Cc(e,t){Y.delete(Vi(e,t))}var bt=class extends Error{status;code;terminal;constructor(t,r){super(t),this.name="SessionStartError",this.status=r.status,this.code=r.code,this.terminal=r.terminal}};function Op(e){return e instanceof Error&&e.name==="SessionStartError"}function Lp(e){let t=e,r=t?.status,n=t?.code??t?.details?.code??t?.details?.error,s=t?.message||"Unable to start this session";return r&&r>=400&&r<500&&r!==408&&r!==429?new bt(s,{status:r,code:n,terminal:!0}):null}async function xe(e,t,r){let n=r&&r>0?`?wait_ms=${Math.floor(r)}`:"",s=await o.post(`/projects/${e}/sessions/${t}/start${n}`,{},{showErrors:!1});if(!s.success||!s.data){let d=Lp(s.error);if(d&&!(d.status===404&&ji(t)))throw d;return null}let c=s.data,u=c.sandbox?.external_id;return c.stage==="ready"&&u&&c.opencode_session_id&&vc(e,t,{opencodeSessionId:c.opencode_session_id,runtimeUrl:rt(u),sandboxId:u}),c}function Fp(e,t){return["session-start",e,t]}async function zi(e){return a(await o.get(`/projects/${e}/model-defaults`))}async function Ji(e,t){return a(await o.put(`/projects/${e}/model-defaults`,t))}async function Xi(e,t){let r=new URLSearchParams({scope:t.scope,...t.agentName?{agentName:t.agentName}:{}}).toString();return a(await o.delete(`/projects/${e}/model-defaults?${r}`))}async function Qi(e,t,r){return a(await o.put(`/projects/${e}/agents/${encodeURIComponent(t)}/scope`,r))}async function Gp(e,t){return a(await o.get(`/projects/${e}/agents/${encodeURIComponent(t)}/config`))}async function Bp(e,t,r){return a(await o.put(`/projects/${e}/agents/${encodeURIComponent(t)}/config`,r))}async function Yi(e,t){return a(await o.put(`/projects/${e}/default-agent`,{agent:t}))}function Zi(){return{credits:{total:0,daily:0,monthly:0,extra:0,can_run:!1,daily_refresh:null},subscription:{tier_key:"none",tier_display_name:"No Plan",status:"no_subscription",billing_period:null,provider:"stripe",subscription_id:null,current_period_end:null,cancel_at_period_end:!1,is_cancelled:!1,cancellation_effective_date:null,has_scheduled_change:!1,scheduled_change:null,commitment:{has_commitment:!1,can_cancel:!0,commitment_type:null,months_remaining:null,commitment_end_date:null},can_purchase_credits:!1},models:[],limits:{concurrent_runs:{running_count:0,limit:0,can_start:!1,tier_name:"none"},ai_worker_count:{current_count:0,limit:0,can_create:!1,tier_name:"none"},custom_mcp_count:{current_count:0,limit:0,can_create:!1,tier_name:"none"}},tier:{name:"none",display_name:"No Plan",monthly_credits:0,can_purchase_credits:!1}}}async function eo(e){let t=new URLSearchParams;e?.skipCache&&t.set("skip_cache","true"),e?.accountId&&t.set("account_id",e.accountId);let r=t.toString(),n=r?`?${r}`:"",s=await o.get(`/billing/account-state${n}`,{showErrors:!1}),c=s.error?.status===404&&/billing is not enabled/i.test(s.error.message||"");if(s.error&&s.error.status!==401&&!c)throw s.error;return s.error?Zi():s.data}async function to(e){let t=new URLSearchParams;e?.skipCache&&t.set("skip_cache","true"),e?.accountId&&t.set("account_id",e.accountId);let r=t.toString(),n=r?`?${r}`:"",s=await o.get(`/billing/account-state/minimal${n}`,{showErrors:!1}),c=s.error?.status===404&&/billing is not enabled/i.test(s.error.message||"");if(s.error&&s.error.status!==401&&!c)throw s.error;return s.error?Zi():s.data}async function ro(e){let t=new URLSearchParams;e?.accountId&&t.set("account_id",e.accountId),e?.limit!=null&&t.set("limit",String(e.limit)),e?.offset!=null&&t.set("offset",String(e.offset)),e?.typeFilter&&t.set("type_filter",Array.isArray(e.typeFilter)?e.typeFilter.join(","):e.typeFilter);let r=t.toString();return a(await o.get(`/billing/transactions${r?`?${r}`:""}`))}async function no(e){let t=new URLSearchParams;e?.accountId&&t.set("account_id",e.accountId),e?.days!=null&&t.set("days",String(e.days));let r=t.toString();return a(await o.get(`/billing/transactions/summary${r?`?${r}`:""}`))}async function so(){return a(await o.get("/billing/credit-breakdown"))}async function io(e){let t=e!=null?`?days=${e}`:"";return a(await o.get(`/billing/usage-history${t}`))}async function oo(){return a(await o.get("/billing/tier-configurations"))}async function Kp(e){let t=e.accountId?`?account_id=${encodeURIComponent(e.accountId)}`:"";return ye(e,`/v1/billing/account-state${t}`)}async function ao(e){return a(await o.post("/billing/create-checkout-session",{account_id:e.accountId,tier_key:e.tierKey,success_url:e.successUrl,cancel_url:e.cancelUrl,commitment_type:e.commitmentType,locale:e.locale,server_type:e.serverType,location:e.location}),"Failed to create checkout session")}async function co(e,t){return a(await o.post("/billing/confirm-checkout-session",{account_id:t,session_id:e}),"Failed to confirm checkout session")}async function lo(e,t){return a(await o.post("/billing/create-portal-session",{account_id:t,return_url:e}),"Failed to create portal session")}async function uo(e,t){return a(await o.post("/billing/cancel-subscription",{account_id:t,feedback:e}),"Failed to cancel subscription")}async function po(e){return a(await o.post("/billing/reactivate-subscription",{account_id:e}),"Failed to reactivate subscription")}async function go(e,t,r){return a(await o.post("/billing/schedule-downgrade",{account_id:r,target_tier_key:e,commitment_type:t}),"Failed to schedule downgrade")}async function mo(e){return a(await o.post("/billing/cancel-scheduled-change",{account_id:e}),"Failed to cancel scheduled change")}async function fo(e,t){let r=new URLSearchParams({new_price_id:e});return t&&r.set("account_id",t),a(await o.get(`/billing/proration-preview?${r.toString()}`),"Failed to load proration preview")}async function yo(e){return a(await o.post("/billing/purchase-credits",{amount:e.amount,account_id:e.accountId,success_url:e.successUrl,cancel_url:e.cancelUrl}),"Failed to purchase credits")}async function ho(e){let t=e?`?account_id=${encodeURIComponent(e)}`:"";return a(await o.get(`/billing/auto-topup/settings${t}`),"Failed to load auto-topup settings")}async function bo(e){return a(await o.post("/billing/auto-topup/configure",{account_id:e.accountId,enabled:e.enabled,threshold:e.threshold,amount:e.amount}),"Failed to configure auto-topup")}async function xo(e){let t=await o.get(`/projects/${encodeURIComponent(e)}/channels/slack/installation`,{showErrors:!1});return t.success?t.data??null:null}async function ko(e,t){return a(await o.post(`/projects/${encodeURIComponent(e)}/channels/slack/connect`,t,{showErrors:!1}),"Failed to connect")}var Np={oauth_available:!1,install_url:null};async function Po(e){let t=await o.get(`/projects/${encodeURIComponent(e)}/channels/slack/mode`,{showErrors:!1});return!t.success||!t.data?Np:t.data}async function wo(e){return a(await o.get(`/webhooks/slack/${encodeURIComponent(e)}/manifest`,{showErrors:!1}),"Failed to load Slack manifest")}async function _o(e){let t=await o.delete(`/projects/${encodeURIComponent(e)}/channels/slack/installation`,{showErrors:!1});if(!t.success)throw new Error(t.error?.message??"Failed to disconnect")}async function So(e,t){return a(await o.get(`/projects/${encodeURIComponent(e)}/channels/slack/file?url=${encodeURIComponent(t)}`,{showErrors:!1}),"Failed to download Slack file")}async function vo(e,t){return a(await o.post(`/projects/${encodeURIComponent(e)}/channels/slack/file/upload`,{channel:t.channel,filename:t.filename,content_base64:t.contentBase64,comment:t.comment,thread_ts:t.threadTs},{showErrors:!1}),"Failed to upload Slack file")}function Co(e){return{...e,profileId:e.profileId??e.profile_id??null}}var Hp={provider:"agentmail",managed_available:!1};async function Ro(e,t){let r=t?`?connector_slug=${encodeURIComponent(t)}`:"",n=await o.get(`/projects/${encodeURIComponent(e)}/channels/email/installation${r}`,{showErrors:!1});return n.success&&n.data?Co(n.data):null}async function To(e){let t=await o.get(`/projects/${encodeURIComponent(e)}/channels/email/mode`,{showErrors:!1});return!t.success||!t.data?Hp:t.data}async function Io(e,t){let r=a(await o.post(`/projects/${encodeURIComponent(e)}/channels/email/connect`,t,{showErrors:!1}),"Failed to connect email");return Co(r)}async function jo(e,t){let r=t?`?connector_slug=${encodeURIComponent(t)}`:"",n=await o.delete(`/projects/${encodeURIComponent(e)}/channels/email/installation${r}`,{showErrors:!1});if(!n.success)throw new Error(n.error?.message??"Failed to disconnect email")}async function Ao(e,t,r){let n=a(await o.patch(`/projects/${encodeURIComponent(e)}/channels/email/installation`,{connector_slug:t??"kortix_email",sender_policy:r},{showErrors:!1}),"Failed to update email policy");return Co(n)}async function Eo(e){let t=await o.get(`/projects/${encodeURIComponent(e)}/channels/meet/voices`,{showErrors:!1});return t.success?t.data??null:null}async function $o(e,t){return a(await o.put(`/projects/${encodeURIComponent(e)}/channels/meet/voice`,{voice:t},{showErrors:!1}),"Failed to save voice")}async function qo(e,t){return a(await o.put(`/projects/${encodeURIComponent(e)}/channels/meet/name`,{name:t},{showErrors:!1}),"Failed to save name")}async function Do(e,t){let r=await o.post(`/projects/${encodeURIComponent(e)}/channels/meet/voices/${encodeURIComponent(t)}/preview`,{},{showErrors:!1});return!r.success||!r.data?.b64?null:r.data.b64}async function Wp(e){return a(await o.get(`/projects/${encodeURIComponent(e)}/channels/bindings`,{showErrors:!1}),"Failed to load channel bindings")}async function Vp(e,t,r){return a(await o.patch(`/projects/${encodeURIComponent(e)}/channels/bindings/${encodeURIComponent(t)}`,r,{showErrors:!1}),"Failed to update channel binding")}async function Mo(e,t,r,n){return a(await o.post(`/projects/${encodeURIComponent(e)}/channels/meet/speak`,{bot_id:t,text:r,voice:n},{showErrors:!1}),"Failed to speak in meeting")}async function Uo(e){return a(await o.get(`/projects/${e}/gateway/routing-policy`),"Gateway routing policy request failed")}async function Oo(e,t){return a(await o.put(`/projects/${e}/gateway/routing-policy`,t),"Gateway routing policy request failed")}async function Lo(e){return a(await o.delete(`/projects/${e}/gateway/routing-policy`),"Gateway routing policy request failed")}async function Fo(e,t){return a(await o.post(`/projects/${e}/gateway/routing-policy/preview`,t),"Gateway route preview failed")}async function Go(e,t){let r=new URLSearchParams;t?.limit&&r.set("limit",String(t.limit)),t?.offset&&r.set("offset",String(t.offset)),t?.ok!==void 0&&r.set("ok",String(t.ok));let n=r.toString();return a(await o.get(`/projects/${e}/gateway/logs${n?`?${n}`:""}`),"Gateway request failed")}async function Bo(e,t){return a(await o.get(`/projects/${e}/gateway/logs/${t}`),"Gateway request failed")}async function Ko(e,t){return a(await o.get(`/projects/${e}/gateway/overview${t?`?days=${t}`:""}`),"Gateway request failed")}async function No(e,t){return a(await o.get(`/projects/${e}/gateway/series${t?`?days=${t}`:""}`),"Gateway request failed")}async function Ho(e,t){return a(await o.get(`/projects/${e}/gateway/breakdown${t?`?days=${t}`:""}`),"Gateway request failed")}async function Wo(e,t){return a(await o.get(`/projects/${e}/gateway/sessions${t?`?days=${t}`:""}`),"Gateway request failed")}async function Vo(e,t){return a(await o.get(`/projects/${e}/gateway/errors${t?`?days=${t}`:""}`),"Gateway request failed")}async function zo(e){return a(await o.get(`/projects/${e}/gateway/budgets`),"Gateway request failed")}async function Jo(e,t){return a(await o.put(`/projects/${e}/gateway/budgets`,t),"Gateway request failed")}async function Xo(e,t){return a(await o.delete(`/projects/${e}/gateway/budgets/${t}`),"Gateway request failed")}async function Qo(e){return a(await o.get(`/projects/${e}/gateway/keys`),"Gateway request failed")}async function Yo(e,t){return a(await o.post(`/projects/${e}/gateway/keys`,{name:t}),"Gateway request failed")}async function Zo(e,t){return a(await o.delete(`/projects/${e}/gateway/keys/${t}`),"Gateway request failed")}async function ea(e,t,r){return a(await o.post(`/projects/${e}/gateway/playground`,{prompt:t,models:r}),"Gateway request failed")}async function ta(e){let t=new FormData;t.append("audio_file",e);let r=await o.upload("/transcription",t,{showErrors:!0});if(r.error)throw new Error(`Error transcribing audio: ${r.error.message} (${r.error.status})`);return r.data}async function ra(e,t){let r=new URLSearchParams;t?.segment&&r.set("segment",t.segment),t?.kind&&r.set("kind",t.kind);let n=r.toString();return a(await o.get(`/projects/${e}/review/items${n?`?${n}`:""}`,{showErrors:!1}))}async function na(e,t){return a(await o.get(`/projects/${e}/review/items/${t}`))}async function sa(e,t){return a(await o.post(`/projects/${e}/review/items`,t))}async function ia(e,t,r){return a(await o.post(`/projects/${e}/review/items/${t}/act`,r))}async function oa(e,t){return a(await o.post(`/projects/${e}/review/bulk`,t))}async function aa(e){return a(await o.get(`/p/share?sandbox_id=${encodeURIComponent(e)}`),"Failed to load public links").shares??[]}async function ca(e){return a(await o.post("/p/share",{sandbox_id:e.sandboxId,port:e.port,ttl:e.ttl,label:e.label}),"Failed to generate public URL")}async function la(e,t){let r=await o.delete(`/p/share/${encodeURIComponent(t)}?sandbox_id=${encodeURIComponent(e)}`);if(!r.success)throw new Error(r.error?.message??"Failed to revoke public link")}var xt=class extends Error{constructor(r,n){super(r);this.status=n;this.name="PublicSessionShareError"}status};function Rc(e,t=""){return`${Ae()}/public/session-shares/${encodeURIComponent(e)}${t}`}async function Tc(e){let t=await fetch(e,{method:"GET",headers:{Accept:"application/json"}}),r=await t.text().catch(()=>""),n=null;try{n=r?JSON.parse(r):null}catch{}if(!t.ok){let s=(n&&typeof n=="object"&&"error"in n&&typeof n.error=="string"?n.error:null)||t.statusText||`HTTP ${t.status}`;throw new xt(s,t.status)}return n}async function zp(e){return Tc(Rc(e))}async function Jp(e){return Tc(Rc(e,"/messages"))}async function ua(e){let t=e?`?account_id=${encodeURIComponent(e)}`:"";return a(await o.get(`/accounts/tokens${t}`))}async function pa(e){let{accountId:t,expiresAt:r,projectId:n,name:s}=e;return a(await o.post("/accounts/tokens",{name:s,...t?{account_id:t}:{},...r?{expires_at:r}:{},...n?{project_id:n}:{}}))}async function da(e,t){let r=t?`?account_id=${encodeURIComponent(t)}`:"";return a(await o.delete(`/accounts/tokens/${e}${r}`))}async function ga(e){return a(await o.get(`/projects/${e}/cli-token`))}async function ma(e,t){return a(await o.post(`/projects/${e}/cli-token`,t??{}))}async function fa(e,t){return a(await o.delete(`/projects/${e}/cli-token/${t}`))}async function ya(e,t){let r=new URLSearchParams;t?.action&&r.set("action",t.action),t?.since&&r.set("since",t.since),t?.cursor&&r.set("cursor",t.cursor),t?.limit!=null&&r.set("limit",String(t.limit));let n=r.toString();return a(await o.get(`/accounts/${e}/audit${n?`?${n}`:""}`))}async function ha(e,t){let r=new URLSearchParams;t?.format&&r.set("format",t.format),t?.action&&r.set("action",t.action),t?.since&&r.set("since",t.since);let n=r.toString();return a(await o.get(`/accounts/${e}/audit/export${n?`?${n}`:""}`))}async function ba(e){return a(await o.get(`/accounts/${e}/audit/webhooks`))}async function xa(e,t){return a(await o.post(`/accounts/${e}/audit/webhooks`,t))}async function ka(e,t,r){return a(await o.patch(`/accounts/${e}/audit/webhooks/${t}`,r))}async function Pa(e,t){return a(await o.delete(`/accounts/${e}/audit/webhooks/${t}`))}async function wa(e,t){return a(await o.post(`/projects/${e}/secret-requests`,{names:t.names,labels:t.labels,descriptions:t.descriptions,scope:t.scope,expires_in_minutes:t.expiresInMinutes}),"Failed to mint secret-entry link")}async function _a(e,t){return a(await o.post(`/projects/${e}/connect-requests`,{slug:t.slug,expires_in_minutes:t.expiresInMinutes}),"Failed to mint connect link")}async function Sa(e){let t=new URLSearchParams;e?.query&&t.set("query",e.query),e?.type&&t.set("type",e.type),e?.source&&t.set("source",e.source);let r=t.toString()?`?${t.toString()}`:"";return a(await o.get(`/marketplace/items${r}`))}async function va(){return a(await o.get("/marketplace/marketplaces"))}async function Ca(){return a(await o.get("/marketplace/marketplaces/featured"))}async function Ra(e){return a(await o.get(`/marketplace/items/${encodeURIComponent(e)}`),"Item not found")}async function Ta(e,t){return a(await o.get(`/marketplace/items/${encodeURIComponent(e)}/file?path=${encodeURIComponent(t)}`),"File not found")}async function Ia(){return a(await o.get("/marketplace/sources"))}async function ja(e){return a(await o.post("/marketplace/sources",e),"Failed to add marketplace source")}async function Aa(e){return a(await o.delete(`/marketplace/sources/${encodeURIComponent(e)}`),"Failed to remove marketplace source")}async function Xp(e){return a(await o.get(`/templates/${encodeURIComponent(e)}`))}async function Qp(e,t){return a(await o.post(`/templates/${encodeURIComponent(e)}/install`,t))}function Yp(e){return e?e.runtimeReady!==void 0?e.runtimeReady===!0:e.opencode!==void 0?e.opencode==="ok"||e.opencode===!0:e.status!=="starting"&&e.status!=="down"&&e.status!=="error":!1}async function Ea(e,t){let r=(e===void 0?$():e)||null;if(!r)return{status:0,ok:!1,health:null,body:""};let n=await R(`${r}/kortix/health`,{method:"GET",...t},{retryOnAuthError:!1}),s=await n.text().catch(()=>""),c=null;try{c=s?JSON.parse(s):null}catch{c=null}return{status:n.status,ok:n.ok,health:c,body:s}}var V={DESKTOP:"6080",DESKTOP_HTTPS:"6081",PRESENTATION_VIEWER:"3210",STATIC_FILE_SERVER:"3211",KORTIX_MASTER:"8000",BROWSER_STREAM:"9223",BROWSER_VIEWER:"9224",SSH:"22"};var Ic=/https?:\/\/(?:localhost|127\.0\.0\.1):\d{1,5}[^\s)"'<>]*/g,jc=/^https?:\/\/p(\d+)-([^.]+)\.localhost(?::(\d+))?(\/.*)?$/,Ac=new Set([22,4096,parseInt(V.KORTIX_MASTER,10)]);function Zp(e){return jc.test(e)}function kt(e){if(!e)return"/";let t=e,r=t.indexOf("](");r!==-1&&(t=t.slice(0,r));let n=t.toLowerCase().indexOf("%5d(");return n!==-1&&(t=t.slice(0,n)),t?t.startsWith("/")?t:`/${t}`:"/"}function ed(e){let t=e.indexOf("](");return t===-1?e:e.slice(0,t)}var td=new Set(["'",'"',"`","<","(","["]),rd=new Set([">","'",'"',"`",")","]",",",";",".","!","?"]);function nd(e){let t=0,r=e.length;for(;t<r&&(e[t]===" "||e[t]===" ");)t++;for(;r>t&&(e[r-1]===" "||e[r-1]===" ");)r--;for(;t<r&&td.has(e[t]);)t++;for(;r>t&&rd.has(e[r-1]);)r--;return e.slice(t,r)}function sd(e){return e.match(/https?:\/\/(?:localhost|127\.0\.0\.1):\d{1,5}[^\s"'<>)]*/i)?.[0]??null}var id=/^\/proxy\/(\d{1,5})(\/.*)?$/,od=/^\/(connectors|settings|dashboard|projects|agents|skills|tools|commands|support|changelog|files|p|browser|desktop|terminal|sessions|services|workspace|channels|scheduled-tasks|marketplace|templates|tunnel|admin|auth)(\/|$|\?)/;function Ec(e){if(!e)return!1;try{let t=new URL(e);return t.hostname!=="localhost"&&t.hostname!=="127.0.0.1"?!1:od.test(t.pathname)}catch{return!1}}function Oe(e){if(!e)return null;let t=nd(ed(e.trim())),r=qa(t);if(r){let n=kt(r.path||"/");return{originalUrl:`http://localhost:${r.port}${n}`,port:r.port,path:n}}try{let n=new URL(t);if(n.protocol!=="http:"&&n.protocol!=="https:"||n.hostname!=="localhost"&&n.hostname!=="127.0.0.1"||!n.port)return null;let s=parseInt(n.port,10);if(!Number.isInteger(s)||s<1||s>65535)return null;let c=`${n.pathname||"/"}${n.search}${n.hash}`,u=parseInt(V.KORTIX_MASTER,10);if(s===u){let g=n.pathname.match(id);if(g){let h=parseInt(g[1],10);if(h>=1&&h<=65535)return s=h,c=kt(`${g[2]||"/"}${n.search}${n.hash}`),{originalUrl:`http://localhost:${s}${c}`,port:s,path:c}}}let d=kt(c);return{originalUrl:`${n.protocol}//${n.hostname}:${s}${d}`,port:s,path:d}}catch{let n=sd(e);return n&&n!==e?Oe(n):null}}function ad(e){let t=[],r=/```[\s\S]*?```/g,n;for(;(n=r.exec(e))!==null;)t.push([n.index,n.index+n[0].length]);let s=/`[^`\n]+`/g;for(;(n=s.exec(e))!==null;){let c=n.index,u=c+n[0].length;t.some(([g,h])=>c>=g&&u<=h)||t.push([c,u])}return t}function cd(e,t){return t.some(([r,n])=>e>=r&&e<n)}function $c(e){let t=[],r=new Set,n=ad(e);Ic.lastIndex=0;let s;for(;(s=Ic.exec(e))!==null;){let c=Oe(s[0]);if(!c)continue;let{originalUrl:u,port:d,path:g}=c;d<1||d>65535||Ac.has(d)||r.has(u)||(r.add(u),t.push({originalUrl:u,port:d,path:g,startIndex:s.index,endIndex:s.index+u.length,inCodeBlock:cd(s.index,n)}))}return t}function ld(e){return $c(e).length>0}function ud(e){try{let{hostname:t}=new URL(e);return t==="localhost"||t==="127.0.0.1"}catch{return!1}}function ke(e,t,r){let n=kt(t);if(!ud(r.apiBaseUrl)){let s=r.apiBaseUrl.length;for(;s>0&&r.apiBaseUrl.charCodeAt(s-1)===47;)s--;return`${r.apiBaseUrl.slice(0,s)}/p/${r.sandboxId}/${e}${n}`}return`http://p${e}-${r.sandboxId}.localhost:${r.backendPort}${n}`}function pd(e,t){return ke(e,"/",t)}function qc(e){let t=Oe(e);return!(!t||Ac.has(t.port)||Ec(e))}function $a(e,t){if(!e)return e;let r=Oe(e);return r?qc(r.originalUrl)?ke(r.port,r.path,t):r.originalUrl:e}function dd(e,t="/"){return`http://localhost:${e}${t}`}var Dc=/^https?:\/\/[^/]+\/v1\/p\/([^/]+)\/(\d+)(\/.*)?$/;function qa(e){let t=e.match(jc);if(t)return{port:parseInt(t[1],10),sandboxId:t[2],backendPort:t[3]?parseInt(t[3],10):80,path:t[4]||"/"};let r=e.match(Dc);if(r)try{let n=new URL(e);return{port:parseInt(r[2],10),sandboxId:r[1],backendPort:parseInt(n.port,10)||(n.protocol==="https:"?443:80),path:r[3]||"/"}}catch{return null}return null}function gd(e){try{let t=qa(e);return t?`http://localhost:${t.port}${t.path}`:null}catch{return null}}function md(e){return Zp(e)||Dc.test(e)}var Ue="/web-proxy/";function fd(e,t){try{let r=new URL(e);if(r.protocol!=="http:"&&r.protocol!=="https:")return null;let n=r.protocol.replace(":",""),s=`${Ue}${n}/${r.host}${r.pathname}${r.search}${r.hash}`,c=parseInt(V.KORTIX_MASTER,10);return`${ke(c,"/",t).replace(/\/$/,"")}${s}`}catch{return null}}function yd(e){try{let t=new URL(e),r=t.pathname.indexOf(Ue);if(r===-1)return null;let s=t.pathname.slice(r+Ue.length).match(/^(https?)\/([\w.\-]+(?::\d+)?)(\/.*)?$/);if(!s)return null;let c=s[1],u=s[2],d=s[3]||"/";return`${c}://${u}${d}${t.search}${t.hash}`}catch{return null}}function hd(e){try{return new URL(e).pathname.includes(Ue)}catch{return e.includes(Ue)}}function bd(e){if(!e)return!1;let t=e.trim();return!!(/^https?:\/\/(?!localhost|127\.0\.0\.1)/i.test(t)||/^[a-z0-9][\w.-]*\.[a-z]{2,}/i.test(t))}function xd(e){let t=e.trim();return t?/^https?:\/\//i.test(t)?t:/^[a-z0-9][\w.-]*\.[a-z]{2,}/i.test(t)?`https://${t}`:null:null}var Mc="frontend";function Pt(e,t,r){(e==="error"?console.error:e==="warn"?console.warn:e==="debug"?console.debug:console.log)(`[${Mc}] ${t}`,...r?[r]:[]);try{X().app.log({service:Mc,level:e,message:t,extra:r})}catch{}}var Z={debug:(e,t)=>Pt("debug",e,t),info:(e,t)=>Pt("info",e,t),warn:(e,t)=>Pt("warn",e,t),error:(e,t)=>Pt("error",e,t)};function Uc(e){return{type:"heartbeat-gap",gapMs:e}}function Oc(e){switch(e.type){case"message.updated":return{type:"message.updated",sessionID:e.properties.sessionID,message:e.properties.info};case"message.removed":return{type:"message.removed",sessionID:e.properties.sessionID,messageID:e.properties.messageID};case"message.part.updated":return{type:"message.part.updated",sessionID:e.properties.sessionID,part:e.properties.part};case"message.part.removed":return{type:"message.part.removed",sessionID:e.properties.sessionID,messageID:e.properties.messageID,partID:e.properties.partID};case"session.status":return{type:"session.status",sessionID:e.properties.sessionID,status:e.properties.status};case"session.idle":return{type:"session.idle",sessionID:e.properties.sessionID};case"session.error":return{type:"session.error",sessionID:e.properties.sessionID,error:e.properties.error};case"question.asked":return{type:"question.asked",sessionID:e.properties.sessionID,requestID:e.properties.id,questions:e.properties.questions,tool:e.properties.tool};case"question.replied":return{type:"question.answered",sessionID:e.properties.sessionID,requestID:e.properties.requestID,outcome:"replied",answers:e.properties.answers};case"question.rejected":return{type:"question.answered",sessionID:e.properties.sessionID,requestID:e.properties.requestID,outcome:"rejected"};case"permission.asked":return{type:"permission.asked",sessionID:e.properties.sessionID,requestID:e.properties.id,permission:e.properties.permission,patterns:e.properties.patterns,tool:e.properties.tool};case"permission.replied":return{type:"permission.replied",sessionID:e.properties.sessionID,requestID:e.properties.requestID,reply:e.properties.reply};case"todo.updated":return{type:"todo.updated",sessionID:e.properties.sessionID,todos:e.properties.todos};case"server.connected":return{type:"connection",status:"connected"};default:return null}}var kd={now:()=>Date.now(),setTimeout:(e,t)=>setTimeout(e,t),clearTimeout:e=>clearTimeout(e)},Pd=16,wd=8,_d=6e4,Sd=5e3,vd=250,Cd=1e3,Rd=3e4,Td=5,Id=3e3,jd=3e4,Ad=2e4,Ed=2e3,$d=8;function qd(e){if(e.type==="session.status")return`session.status:${e.properties.sessionID}`;if(e.type==="lsp.updated")return"lsp.updated"}function Lc(e){if(e.aborted)return{promise:Promise.resolve(),cleanup:()=>{}};let t=()=>{};return{promise:new Promise(n=>{t=()=>n(),e.addEventListener("abort",t,{once:!0})}),cleanup:()=>e.removeEventListener("abort",t)}}function wt(e){let{client:t,onEvent:r,onGapRehydrate:n,onParked:s,signal:c}=e,u=e.timers??kd,d=e.connectTimeoutMs??Ad,g=e.heartbeatTimeoutMs??_d,h=e.maxConsecutiveHardFailures??$d,m=new AbortController,x=()=>m.abort();c&&(c.aborted?m.abort():c.addEventListener("abort",x,{once:!0}));let w=u.now(),k=[],l,i=0,P=new Map,_=()=>{if(l&&u.clearTimeout(l),l=void 0,k.length===0)return;let A=k;k=[],P.clear(),i=u.now(),w=u.now();for(let v of A)if(v)try{r(v.event)}catch(I){console.warn("[opencode-events] event handler threw, skipping",I)}},D=()=>{if(l)return;let A=u.now()-i;l=u.setTimeout(_,Math.max(0,Pd-A))};return(async()=>{let A=0,v=0;for(;!m.signal.aborted;){let I=!1,j=!1,f,S,U=null,N=u.now(),M=new AbortController,O=Lc(m.signal);O.promise.then(()=>M.abort());try{let F=await new Promise((Et,ve)=>{let G=!1;S=u.setTimeout(()=>{G||(G=!0,Z.warn("SSE connect timed out, forcing reconnect",{connectTimeoutMs:d}),M.abort(),ve(new Error(`SSE connect timed out after ${d}ms`)))},d),t.global.event({signal:M.signal,sseDefaultRetryDelay:Id,sseMaxRetryDelay:jd,sseMaxRetryAttempts:1}).then(W=>{G||(G=!0,u.clearTimeout(S),Et(W))},W=>{G||(G=!0,u.clearTimeout(S),ve(W))})}),{stream:E}=F;w=u.now();let B=()=>{u.clearTimeout(f),f=u.setTimeout(()=>{Z.warn("SSE heartbeat timeout, forcing reconnect"),M.abort()},g)};B();let We=u.now(),Pl=E[Symbol.asyncIterator]();for(;!M.signal.aborted;){let Et=Pl.next().then(J=>({kind:"next",result:J}),J=>({kind:"error",error:J})),ve=Lc(M.signal),G=await Promise.race([Et,ve.promise.then(()=>({kind:"aborted"}))]);if(ve.cleanup(),G.kind==="aborted")break;if(G.kind==="error")throw G.error;if(G.result.done)break;I=!0,B();let W=G.result.value,Ve=W&&typeof W=="object"&&"payload"in W?W.payload:W;if(!Ve?.type)continue;let $t=qd(Ve);if($t){let J=P.get($t);J!==void 0&&(k[J]=void 0),P.set($t,k.length)}k.push({type:Ve.type,event:Ve}),D(),!(u.now()-We<wd)&&(We=u.now(),await new Promise(J=>u.setTimeout(J,0)))}j=I}catch(F){if(m.signal.aborted)break;U=F;let E=String(F),B=E.includes("401")||E.includes("403")||E.includes("Unauthorized")||E.includes("Token refresh failed");if(Z.error("SSE event stream error",{error:E,retryCount:A,isAuthError:B}),B)try{Ie(),await tt(),Z.info("SSE: refreshed auth token after auth error")}catch(We){Z.error("SSE: failed to refresh auth token",{error:String(We)})}}finally{u.clearTimeout(f),u.clearTimeout(S),M.abort(),O.cleanup(),_()}if(m.signal.aborted)break;let ae=u.now()-N,He=U?.cause?.status;if(v=!I&&(typeof He=="number"&&He>=400||ae<Ed)?v+1:0,v>=h){Z.error("SSE event stream parked \u2014 giving up after consecutive hard failures",{consecutiveFailures:v,lastError:String(U)});try{s?.({consecutiveFailures:v,lastError:U})}catch(F){console.warn("[opencode-events] onParked handler threw",F)}break}let Se=u.now()-w;Se>Sd&&n?.(Se),j?A=0:(A++,A>1&&Z.warn("SSE event stream reconnecting",{retryCount:A}));let H=j?vd:Math.min(Cd*2**Math.min(A-1,Td),Rd);await new Promise(F=>{let E=u.setTimeout(F,H),B=()=>{u.clearTimeout(E),F()};m.signal.addEventListener("abort",B,{once:!0})})}})(),{close:()=>{m.abort(),c&&c.removeEventListener("abort",x),l&&u.clearTimeout(l)}}}function Dd(){return X()}var _t=new Map,Le=class extends Error{constructor(t){super(`Session runtime not ready \u2014 call \`await session.ensureReady()\` (it drives \`start()\` to completion and resolves this session's own sandbox runtime) before calling \`${t}\`.`),this.name="SessionNotReadyError"}};function Fc(e,t){Je(e,t);function r(l){try{return new URL(l)}catch{if(typeof window<"u"&&window.location?.origin)try{return new URL(l,window.location.origin)}catch{return null}throw new C(`Kortix SDK: backendUrl must be an absolute URL outside the browser (got ${JSON.stringify(l)}). Relative paths like "/api/kortix" only resolve against a page origin \u2014 configure an absolute backendUrl for server-side hosts.`,{code:"INVALID_BACKEND_URL"})}}function n(l){let i=T().backendUrl??e.backendUrl,P=80,_=r(i);return _&&(P=_.port?Number(_.port):_.protocol==="https:"?443:80),{sandboxId:l,backendPort:P,apiBaseUrl:i}}let s={list:Sn,get:Cn,create:vn,updateName:Rn,leave:On,members:Tn,invite:In,removeMember:Mn,updateMemberRole:Un,invites:jn,cancelInvite:An,resendInvite:En,tokens:{list:ua,create:pa,revoke:da},audit:{log:ya,export:ha,webhooks:{list:ba,create:xa,update:ka,remove:Pa}}},c={accountState:eo,accountStateMinimal:to,transactions:ro,transactionsSummary:no,creditBreakdown:so,usageHistory:io,tierConfigurations:oo,checkout:{createSession:l=>ao(l),confirmSession:(l,i)=>co(l,i)},subscription:{createPortalSession:(l,i)=>lo(l,i),cancel:(l,i)=>uo(l,i),reactivate:l=>po(l),scheduleDowngrade:(l,i,P)=>go(l,i,P),cancelScheduledChange:l=>mo(l),prorationPreview:(l,i)=>fo(l,i)},credits:{purchase:l=>yo(l),autoTopupSettings:l=>ho(l),configureAutoTopup:l=>bo(l)}},u={describe:$n,accept:qn,decline:Dn},d={list:ie,listForAccount:Fn,get:pt,detail:dt,create:Nn,createRepo:Hn,provision:Wn,update:ft,archive:yt,llmCatalog:gt,modelPicker:mt,sandboxHealth:ht,sandboxTemplates:Zs,sessions:he,createSession:be},g={linkRepository:Xn,getInstallation:Qn,listInstallations:Yn,listRepositories:Zn,listRepositoryBranches:es,saveInstallation:ts,deleteInstallation:rs},h={list:aa,create:ca,revoke:la},m=zs,x={items:l=>Sa(l),item:l=>Ra(l),itemFile:(l,i)=>Ta(l,i),marketplaces:()=>va(),featured:()=>Ca(),sources:{list:()=>Ia(),add:l=>ja(l),remove:l=>Aa(l)}};function w(l){return{get:i=>pt(l,i),detail:()=>dt(l),update:i=>ft(l,i),archive:()=>yt(l),llmCatalog:()=>gt(l),modelPicker:()=>mt(l),sandboxHealth:()=>ht(l),onboardingComplete:(...i)=>Jn(l,...i),tokens:{list:()=>ga(l),create:i=>ma(l,i),revoke:i=>fa(l,i)},setupLinks:{requestSecret:i=>wa(l,i),requestConnector:i=>_a(l,i)},validateManifest:i=>Bn(l,i),gitToken:()=>Kn(l),secrets:{list:()=>_s(l),upsert:i=>Ss(l,i),remove:i=>Ts(l,i),setPersonal:(...i)=>Is(l,...i),removePersonal:i=>js(l,i),setGitCredential:i=>Rs(l,i),startProviderOAuth:(...i)=>vs(l,...i),pollProviderOAuth:(...i)=>Cs(l,...i)},access:{list:()=>os(l),invite:(...i)=>ls(l,...i),update:(...i)=>as(l,...i),revoke:i=>cs(l,i),pendingInvites:()=>us(l),resendInvite:(...i)=>ds(l,...i),revokeInvite:(...i)=>ps(l,...i),requests:()=>ns(l),approveRequest:(...i)=>ss(l,...i),rejectRequest:(...i)=>is(l,...i),groupGrants:()=>gs(l),attachGroupGrant:(...i)=>ms(l,...i),updateGroupGrant:(...i)=>fs(l,...i),detachGroupGrant:i=>ys(l,i),resourceGrants:{list:()=>hs(l),create:i=>bs(l,i),remove:i=>xs(l,i)}},connectors:{list:()=>Ms(l),config:(...i)=>Bs(l,...i),create:(...i)=>Hs(l,...i),remove:(...i)=>Ws(l,...i),sync:()=>Us(l),setName:(...i)=>Ks(l,...i),setCredentialMode:(...i)=>Os(l,...i),setCredential:(...i)=>Js(l,...i),setSensitive:(...i)=>Ls(l,...i),profiles:{list:()=>As(l),reconcile:(...i)=>Es(l,...i),updateCredential:(...i)=>$s(l,...i),revoke:(...i)=>qs(l,...i),activate:(...i)=>Ds(l,...i)},policies:{get:(...i)=>Fs(l,...i),set:(...i)=>Gs(l,...i)},pipedream:{listApps:(...i)=>Vs(l,...i),connect:(...i)=>Ns(l,...i),finalize:(...i)=>Xs(l,...i)}},policies:{list:()=>Qs(l),set:(...i)=>Ys(l,...i)},triggers:{list:()=>Gi(l),create:(...i)=>Bi(l,...i),update:(...i)=>Ki(l,...i),remove:(...i)=>Ni(l,...i),fire:(...i)=>Wi(l,...i),setActivation:(...i)=>Hi(l,...i)},files:{list:i=>ci(l,i),read:(i,P)=>ui(l,i,P),search:(...i)=>li(l,...i),archive:(...i)=>pi(l,...i),history:(...i)=>yi(l,...i)},git:{commits:()=>gi(l),commit:i=>mi(l,i),commitDiff:i=>fi(l,i),branches:()=>di(l),versionDiff:(...i)=>hi(l,...i),inviteCollaborator:(...i)=>Gn(l,...i)},changeRequests:{list:()=>bi(l),get:i=>xi(l,i),diff:i=>ki(l,i),mergePreview:i=>Pi(l,i),open:(...i)=>wi(l,...i),merge:(...i)=>_i(l,...i),close:(...i)=>Si(l,...i),reopen:(...i)=>vi(l,...i),requestChanges:(...i)=>Ci(l,...i)},sessions:{list:()=>he(l),create:i=>be(l,i)},review:{list:i=>ra(l,i),get:i=>na(l,i),submit:i=>sa(l,i),act:(...i)=>ia(l,...i),bulkAct:i=>oa(l,i)},approvals:{list:i=>ks(l,i),resolve:(...i)=>ws(l,...i),sessionsNeedingInput:i=>Ps(l,i)},gateway:{logs:i=>Go(l,i),log:i=>Bo(l,i),overview:i=>Ko(l,i),series:i=>No(l,i),breakdown:i=>Ho(l,i),sessions:i=>Wo(l,i),errors:i=>Vo(l,i),budgets:()=>zo(l),setBudget:i=>Jo(l,i),deleteBudget:i=>Xo(l,i),keys:()=>Qo(l),createKey:i=>Yo(l,i),revokeKey:i=>Zo(l,i),routing:{get:()=>Uo(l),set:i=>Oo(l,i),reset:()=>Lo(l),preview:i=>Fo(l,i)},playground:(i,P)=>ea(l,i,P)},channels:{slack:{installation:()=>xo(l),connect:i=>ko(l,i),mode:()=>Po(l),manifest:()=>wo(l),disconnect:()=>_o(l),getFile:i=>So(l,i),uploadFile:i=>vo(l,i)},email:{installation:i=>Ro(l,i),mode:()=>To(l),connect:i=>Io(l,i),disconnect:i=>jo(l,i),updatePolicy:(...i)=>Ao(l,...i)},meet:{voices:()=>Eo(l),setVoice:i=>$o(l,i),setBotName:i=>qo(l,i),previewVoice:i=>Do(l,i),speak:(i,P,_)=>Mo(l,i,P,_)}},updateExperimentalFeature:(...i)=>Vn(l,...i),modelDefaults:{get:()=>zi(l),set:i=>Ji(l,i),clear:i=>Xi(l,i)},setDefaultAgent:i=>Yi(l,i),sandbox:{list:()=>ai(l),snapshots:()=>ei(l),rebuildSnapshot:i=>ti(l,i),fixWithAgent:()=>ri(l),createTemplate:i=>ni(l,i),updateTemplate:(...i)=>si(l,...i),removeTemplate:i=>ii(l,i),buildTemplate:i=>oi(l,i),setProvider:i=>zn(l,i)},setAgentScope:(...i)=>Qi(l,...i),session:i=>k(l,i)}}function k(l,i){let P=null,_,D;function A(){if(P)return P;let f=Sc(l,i);return f&&(P=f),P}async function v(){let f=A();if(f)return f;let S=`${l}
8
+ ${i}`,U=_t.get(S);if(U)return P=await U,P;let N=(async()=>{let M=await xe(l,i,3e4);if(!M||M.stage!=="ready"||!M.sandbox||!M.opencode_session_id)throw new C(`Session runtime not ready (stage: ${M?.stage??"unknown"})`,{code:"RUNTIME_UNAVAILABLE"});let O=M.sandbox.external_id;if(!O)throw new C("Session sandbox has no external_id \u2014 cannot resolve its runtime URL",{code:"RUNTIME_UNAVAILABLE"});let ae=rt(O);return cc(ae,O),{opencodeSessionId:M.opencode_session_id,runtimeUrl:ae,sandboxId:O}})();_t.set(S,N);try{return P=await N,P}finally{_t.get(S)===N&&_t.delete(S)}}function I(f){let S=A();if(!S)throw new Le(f);return S}function j(){P=null,Cc(l,i)}return{get:f=>Mi(l,i,f),update:f=>Li(l,i,f),delete:()=>(j(),Fi(l,i)),start:(...f)=>xe(l,i,...f),restart:()=>(j(),De(l,i)),stop:()=>(j(),Me(l,i)),setSharing:f=>Ai(l,i,f),previews:()=>Ei(l,i),commit:f=>Ri(l,i,f),publicShares:{list:()=>$i(l,i),create:(...f)=>qi(l,i,...f),revoke:(...f)=>Di(l,i,...f)},audit:(f,S)=>Ui(l,i,f,S),transcript:f=>Oi(l,i,f),ensureReady:v,health:f=>Ea(A()?.runtimeUrl??null,f),previewUrl:(f,S="/")=>ke(f,S,n(I("previewUrl").sandboxId)),proxyUrl:f=>$a(f,n(I("proxyUrl").sandboxId)),setModel:f=>{_=f},setAgent:f=>{D=f},send:async(f,S)=>{let{opencodeSessionId:U,runtimeUrl:N}=await v(),M=S?.model??_,O=S?.agent??D;return ne(N).session.prompt({sessionID:U,parts:[{type:"text",text:f}],...M?{model:M}:{},...O?{agent:O}:{}})},abort:async()=>{let{opencodeSessionId:f,runtimeUrl:S}=await v();return ne(S).session.abort({sessionID:f})},stream:async f=>{let{runtimeUrl:S}=await v();return wt({client:ne(S),onEvent:f.onEvent,onGapRehydrate:f.onGapRehydrate,signal:f.signal})},get runtime(){return ne(I("runtime").runtimeUrl)},files:{list:async f=>gn(f,(await v()).runtimeUrl),read:async f=>ct(f,(await v()).runtimeUrl),readBlob:async f=>lt(f,(await v()).runtimeUrl),status:async()=>mn((await v()).runtimeUrl),findFiles:async(f,S)=>fn(f,S,(await v()).runtimeUrl),findText:async f=>yn(f,(await v()).runtimeUrl),upload:async(f,S,U)=>ut(f,S,U,(await v()).runtimeUrl),create:async f=>hn(f,(await v()).runtimeUrl),copy:async(f,S)=>bn(f,S,(await v()).runtimeUrl),remove:async f=>xn(f,(await v()).runtimeUrl),mkdir:async f=>kn(f,(await v()).runtimeUrl),rename:async(f,S)=>Pn(f,S,(await v()).runtimeUrl)}}}return{config:e,accounts:s,accountInvites:u,projects:d,project:w,session:k,github:g,billing:c,sandboxShares:h,transcribe:ta,connectStatus:m,marketplace:x,validateToken:Ln,runtime:Dd}}function Gc(){let e=typeof crypto<"u"?crypto:void 0;if(e?.randomUUID)return e.randomUUID();let t=new Uint8Array(16);if(e?.getRandomValues)e.getRandomValues(t);else for(let n=0;n<16;n++)t[n]=Math.floor(Math.random()*256);t[6]=t[6]&15|64,t[8]=t[8]&63|128;let r=[...t].map(n=>n.toString(16).padStart(2,"0"));return`${r[0]}${r[1]}${r[2]}${r[3]}-${r[4]}${r[5]}-${r[6]}${r[7]}-${r[8]}${r[9]}-${r.slice(10).join("")}`}var Da={thinking:!1,toolDetails:!0,assistantMetadata:!0};function Md(e){return e&&e.charAt(0).toUpperCase()+e.slice(1)}function Ud(e){let t=e/1e3;if(t<60)return`${t.toFixed(1)}s`;let r=Math.floor(t/60),n=t%60;return`${r}m ${n.toFixed(0)}s`}function Od(e,t){if(e.type==="text"&&!("synthetic"in e&&e.synthetic))return`${e.text}
9
9
 
10
10
  `;if(e.type==="reasoning")return t.thinking?`> _Thinking:_
11
11
  >
@@ -22,13 +22,13 @@ ${s}
22
22
  \`\`\`
23
23
 
24
24
  </details>
25
- `}catch{}if(t.toolDetails&&r.state?.status==="completed"&&r.state?.output){let s=r.state.output,l=s.length>2e3?s.slice(0,2e3)+`
25
+ `}catch{}if(t.toolDetails&&r.state?.status==="completed"&&r.state?.output){let s=r.state.output,c=s.length>2e3?s.slice(0,2e3)+`
26
26
  ... (truncated)`:s;n+=`
27
27
  <details>
28
28
  <summary>Output</summary>
29
29
 
30
30
  \`\`\`
31
- ${l}
31
+ ${c}
32
32
  \`\`\`
33
33
 
34
34
  </details>
@@ -38,15 +38,15 @@ ${l}
38
38
  ${r.state.error}
39
39
  \`\`\`
40
40
  `),n+=`
41
- `,n}return""}function zd(e,t){if(!t)return`## Assistant
41
+ `,n}return""}function Ld(e,t){if(!t)return`## Assistant
42
42
 
43
- `;let r=e.agent?Hd(e.agent):"Assistant",n=e.modelID||"",s="";e.time?.completed&&e.time?.created&&(s=Wd(e.time.completed-e.time.created));let l=[n,s].filter(Boolean).join(" \xB7 ");return l?`## ${r} (${l})
43
+ `;let r=e.agent?Md(e.agent):"Assistant",n=e.modelID||"",s="";e.time?.completed&&e.time?.created&&(s=Ud(e.time.completed-e.time.created));let c=[n,s].filter(Boolean).join(" \xB7 ");return c?`## ${r} (${c})
44
44
 
45
45
  `:`## ${r}
46
46
 
47
- `}function Jd(e,t,r){let n="";e.role==="user"?n+=`## User
47
+ `}function Fd(e,t,r){let n="";e.role==="user"?n+=`## User
48
48
 
49
- `:n+=zd(e,r.assistantMetadata);for(let s of t)n+=Vd(s,r);return n}function rl(e,t,r=Xa){let n=`# ${e.title||"Untitled Session"}
49
+ `:n+=Ld(e,r.assistantMetadata);for(let s of t)n+=Od(s,r);return n}function Bc(e,t,r=Da){let n=`# ${e.title||"Untitled Session"}
50
50
 
51
51
  `;n+=`**Session ID:** \`${e.id}\`
52
52
  `,n+=`**Created:** ${new Date(e.time.created).toLocaleString()}
@@ -54,11 +54,11 @@ ${r.state.error}
54
54
 
55
55
  `,n+=`---
56
56
 
57
- `;for(let s of t)n+=Jd(s.info,s.parts,r),n+=`---
57
+ `;for(let s of t)n+=Fd(s.info,s.parts,r),n+=`---
58
58
 
59
- `;return n}function nl(e,t){return`session-${e}.md`}function K(e){if(!e)return"An error occurred";if(typeof e=="string"){let t=e.startsWith("Error: ")?e.slice(7):e;try{let r=JSON.parse(t);if(typeof r=="string"){t=r;try{let n=JSON.parse(t);return Rt(n)||t}catch{return t}}return Rt(r)||t}catch{return Xd(t)??t}}return typeof e=="object"?Rt(e)||"An error occurred":String(e)}function Xd(e){let t=e.indexOf("{"),r=e.lastIndexOf("}");if(!(t===-1||r===-1||r<=t))try{let n=JSON.parse(e.slice(t,r+1));return Rt(n)}catch{return}}function Rt(e){if(typeof e!="object"||e===null||Array.isArray(e))return;let t=e;if(typeof t.message=="string"&&t.message)return t.message;if(typeof t.error=="string"&&t.error)return t.error;let r=t.data;if(typeof r?.message=="string")return r.message;let n=t.error;if(typeof n?.message=="string")return n.message}var Qd={bash:{label:"Shell",category:"shell"},pty_spawn:{label:"Spawn Terminal",category:"shell"},pty_read:{label:"Terminal Output",category:"shell"},pty_write:{label:"Terminal Input",category:"shell"},pty_input:{label:"Terminal Input",category:"shell"},pty_kill:{label:"Kill Process",category:"shell"},read:{label:"Read File",category:"files"},list:{label:"List Directory",category:"files"},ls:{label:"List Directory",category:"files"},write:{label:"Write File",category:"edit"},edit:{label:"Edit File",category:"edit"},multiedit:{label:"Edit File",category:"edit"},morph_edit:{label:"Edit File",category:"edit"},apply_patch:{label:"Apply Patch",category:"edit"},patch:{label:"Apply Patch",category:"edit"},grep:{label:"Search Code",category:"search"},glob:{label:"Find Files",category:"search"},image_search:{label:"Image Search",category:"search"},session_search:{label:"Search Sessions",category:"search"},webfetch:{label:"Fetch Page",category:"web"},scrape_webpage:{label:"Scrape Page",category:"web"},websearch:{label:"Web Search",category:"web"},web_search:{label:"Web Search",category:"web"},image_gen:{label:"Generate Image",category:"web"},video_gen:{label:"Generate Video",category:"web"},task:{label:"Delegate to Agent",category:"task"},todowrite:{label:"Plan Tasks",category:"task"},todoread:{label:"Read Plan",category:"task"},question:{label:"Ask Question",category:"task"},presentation_gen:{label:"Presentation",category:"task"},show:{label:"Show Output",category:"task"},show_user:{label:"Show Output",category:"task"},prune:{label:"Prune Context",category:"other"},distill:{label:"Distill Context",category:"other"},compress:{label:"Compress Context",category:"other"},context_info:{label:"Context Info",category:"other"}},Yd=[{prefix:"pty_",category:"shell"},{prefix:"agent_",category:"task"},{prefix:"session_",category:"task"},{prefix:"task_",category:"task"},{prefix:"trigger_",category:"task"},{prefix:"project_",category:"task"}];function Zd(e){return e.replace(/^oc[-_]/,"")}function Be(e){return Zd(e).replace(/-/g,"_")}function vt(e){return Be(e).split(/[_\s]+/).filter(Boolean).map(r=>r.charAt(0).toUpperCase()+r.slice(1)).join(" ")}function Ct(e){let t=Be(e),r=Qd[t];if(r)return r;for(let{prefix:n,category:s}of Yd)if(t.startsWith(n))return{label:vt(e),category:s};return{label:vt(e),category:"other"}}var eg=256*1024;function tg(e){switch(e.status){case"pending":return"pending";case"running":return"running";case"completed":return"done";case"error":return"error";default:return e}}function rg(e){if(e===void 0)return{};if(e.length>eg)return{outputText:e};try{return{outputParsed:JSON.parse(e),outputText:e}}catch{return{outputText:e}}}function ng(e){if(typeof e!="object"||e===null||Array.isArray(e))return;let t=e,r=t.success===!1,n=t.error,s=typeof n=="string"&&n.length>0||typeof n=="object"&&n!==null;if(!(!r&&!s))return s?K(n):typeof t.message=="string"&&t.message?t.message:"Tool reported failure"}function sg(e,t){let r="title"in t?t.title:void 0,n=t.status==="completed"?t.output:void 0,{outputParsed:s,outputText:l}=rg(n),u=tg(t),d=t.status==="error"?t.error:void 0;if(u==="done"){let g=ng(s);g&&(u="error",d=g)}return{name:e,title:r||Ct(e).label,status:u,input:t.input,output:n,outputParsed:s,outputText:l,error:d}}function ig(e){return{kind:"text",id:e.id,text:e.text,synthetic:!!e.synthetic}}function og(e){return{kind:"reasoning",id:e.id,text:e.text}}function ag(e){return{kind:"tool",id:e.id,tool:sg(e.tool,e.state)}}function cg(e){let t=e.mime;return{kind:"file",id:e.id,filename:e.filename,mime:t,url:e.url,isImage:t.startsWith("image/"),isPdf:t==="application/pdf"}}function lg(e){return{kind:"subtask",id:e.id,description:e.description,agent:e.agent,prompt:e.prompt,model:e.model}}function ug(e){return{kind:"patch",id:e.id,hash:e.hash,files:e.files,fileCount:e.files.length}}function pg(e){return{kind:"snapshot",id:e.id,snapshot:e.snapshot}}function dg(e){return{kind:"agent",id:e.id,name:e.name}}function gg(e){return{kind:"retry",id:e.id,attempt:e.attempt,message:K(e.error),createdAt:e.time.created}}function mg(e){return{kind:"compaction",id:e.id,auto:e.auto,overflow:!!e.overflow,tailStartId:e.tail_start_id}}function fg(e){return{kind:"step",id:e.id,phase:"start",snapshot:e.snapshot}}function yg(e){return{kind:"step",id:e.id,phase:"finish",snapshot:e.snapshot,reason:e.reason,cost:e.cost,tokens:e.tokens}}function Qa(e){switch(e.type){case"text":return ig(e);case"reasoning":return og(e);case"tool":return ag(e);case"file":return cg(e);case"subtask":return lg(e);case"patch":return ug(e);case"snapshot":return pg(e);case"agent":return dg(e);case"retry":return gg(e);case"compaction":return mg(e);case"step-start":return fg(e);case"step-finish":return yg(e);default:return{kind:"unknown",raw:e}}}function hg(e){return e?{name:typeof e=="object"&&"name"in e&&typeof e.name=="string"?e.name:"Error",message:K(e)}:void 0}function bg(e){switch(e.kind){case"text":case"reasoning":return e.text.trim().length>0;case"step":return!1;default:return!0}}function sl(e){let t=e.parts.map(Qa),r=e.info.role==="assistant"?e.info.error:void 0,n=hg(r),s=!n&&!t.some(bg);return{parts:t,error:n,isEmpty:s}}function ee(e){return e.type==="text"}function Tt(e){return e.type==="reasoning"}function z(e){return e.type==="tool"}function il(e){return e.type==="file"}function xg(e){return e.type==="agent"}function kg(e){return e.type==="compaction"}function Pg(e){return e.type==="snapshot"}function _g(e){return e.type==="patch"}function wg(e){if(ee(e)||Tt(e))return e.text}function ol(e){if(!il(e))return!1;let t=e.mime;return t.startsWith("image/")||t==="application/pdf"}function Sg(e){let t=[],r=[];for(let n of e)ol(n)?t.push(n):r.push(n);return{attachments:t,stickyParts:r}}function Rg(e,t){let r=[];return e?.tool&&r.push(e.tool),t?.tool&&r.push(t.tool),r}function vg(e,t,r){return r.some(n=>n.messageID===t&&n.callID===e.callID)}var Cg=new Set(["todoread","context_info"]);function al(e){return!Cg.has(e.tool)}function Tg(e){let t=e.tool||"";if(t==="task"||t==="agent_spawn"||t==="agent-spawn"||t==="agent_message"||t==="agent-message"||t==="agent_task"||t==="agent-task"||t==="agent_task_update"||t==="agent-task-update"||t==="agent_task_message"||t==="agent-task-message"||t==="agent_task_start"||t==="agent-task-start"||t==="task_create"||t==="task-create"||t==="task_start"||t==="task-start"||t==="task_update"||t==="task-update"||t==="task_message"||t==="task-message"){let n=e.state?.metadata?.sessionId;if(typeof n=="string"&&n)return n;let s=e.state?.title;if(s){let u=s.match(/\bses_[a-zA-Z0-9]+/);if(u)return u[0]}let l=e.state?.output;if(l){let u=l.match(/\bses_[a-zA-Z0-9]+/);if(u)return u[0]}return}let r=e.tool?.replace(/-/g,"_")||"";if(r==="session_spawn"||r==="session_start_background"){let n=e.state?.output;if(n){let s=n.match(/\*?\*?Session:?\*?\*?\s*(ses_[a-zA-Z0-9]+)/);if(s)return s[1]}return}}function Ig(e){if(e)for(let t=e.length-1;t>=0;t--){let r=e[t]?.info;if(r?.role==="assistant"&&r.error)return K(r.error)}}function jg(e){let t=[];for(let r of e)if(r.info.role==="assistant")for(let n of r.parts)z(n)&&al(n)&&t.push(n);return t}function Ag(e,t={}){switch(e){case"read":return{icon:"glasses",title:"Read",subtitle:cl(t.filePath)};case"list":return{icon:"list",title:"List",subtitle:ll(t.path)};case"glob":return{icon:"search",title:"Glob",subtitle:t.pattern};case"grep":return{icon:"search",title:"Grep",subtitle:t.pattern};case"webfetch":return{icon:"globe",title:"Web Fetch",subtitle:t.url};case"websearch":case"web-search":case"web_search":return{icon:"search",title:"Web Search",subtitle:t.query};case"scrape-webpage":return{icon:"globe",title:"Scrape",subtitle:t.urls?.split?.(",")[0]};case"image-search":return{icon:"image",title:"Image Search",subtitle:t.query};case"image-gen":return{icon:"image",title:"Image Gen",subtitle:t.prompt?.slice?.(0,40)};case"video-gen":return{icon:"cpu",title:"Video Gen",subtitle:t.prompt?.slice?.(0,40)};case"presentation-gen":{let r=t.action||"";return{icon:"presentation",title:{create_slide:"Create Slide",list_slides:"List Slides",preview:"Preview",export_pdf:"Export PDF",export_pptx:"Export PPTX"}[r]||"Presentation",subtitle:t.slide_title||t.presentation_name}}case"show":case"show-user":return{icon:"globe",title:"Output",subtitle:t.title||t.description};case"task":return{icon:"square-kanban",title:`Agent (${t.subagent_type||"task"})`,subtitle:ul(t)};case"session_spawn":case"session_start_background":case"session-spawn":case"session-start-background":case"oc-session_spawn":case"oc-session-spawn":case"oc-session_start_background":case"oc-session-start-background":return{icon:"square-kanban",title:`Worker (${t.agent||"KortixWorker"})`,subtitle:t.description||t.prompt?.slice(0,60)};case"bash":return{icon:"terminal",title:"Shell",subtitle:t.description};case"edit":case"morph_edit":return{icon:"file-pen",title:"Edit",subtitle:Ya(t.filePath)};case"write":return{icon:"file-pen",title:"Write",subtitle:Ya(t.filePath)};case"apply_patch":return{icon:"file-pen",title:"Patch",subtitle:t.files?.length?`${t.files.length} file${t.files.length>1?"s":""}`:void 0};case"todowrite":return{icon:"check-square",title:"Todos"};case"todoread":return{icon:"check-square",title:"Todos (read)"};case"question":return{icon:"message-circle",title:"Questions"};case"prune":return{icon:"scissors",title:"DCP Prune",subtitle:t.reason};case"distill":return{icon:"scissors",title:"DCP Distill"};case"compress":return{icon:"scissors",title:"DCP Compress",subtitle:t.topic};case"context_info":return{icon:"scissors",title:"Context Info"};case"session_read":case"session-read":case"oc-session_read":case"oc-session-read":return{icon:"glasses",title:`Session Read (${t.mode||"summary"})`,subtitle:t.session_id?.slice(-12)};case"session_search":case"session-search":case"oc-session_search":case"oc-session-search":return{icon:"search",title:"Session Search",subtitle:t.query};case"session_message":case"session-message":case"oc-session_message":case"oc-session-message":return{icon:"message-circle",title:"Message \u2192 Session",subtitle:t.session_id?.slice(-12)};case"session_lineage":case"session-lineage":case"oc-session_lineage":case"oc-session-lineage":return{icon:"list-tree",title:"Session Lineage",subtitle:t.session_id?.slice(-12)};case"session_list_background":case"session-list-background":case"session_list_spawned":case"session-list-spawned":case"oc-session_list_background":case"oc-session-list-background":case"oc-session_list_spawned":case"oc-session-list-spawned":return{icon:"layers",title:"Background Sessions",subtitle:t.project||"all"};case"session_stats":case"session-stats":case"oc-session_stats":case"oc-session-stats":return{icon:"layers",title:"Session Stats",subtitle:t.session_id?.slice(-12)||"current"};case"session_list":case"session-list":case"oc-session_list":case"oc-session-list":return{icon:"list",title:"Session List",subtitle:t.search};case"session_get":case"session-get":case"oc-session_get":case"oc-session-get":return{icon:"book-open",title:"Session Get",subtitle:t.session_id?.slice(-12)};case"session_context":case"session-context":case"oc-session_context":case"oc-session-context":return{icon:"book-open",title:"Session Context",subtitle:t.session_id?.slice(-12)};case"project_delete":case"project-delete":case"oc-project_delete":case"oc-project-delete":return{icon:"trash-2",title:"Workspace Delete Disabled",subtitle:t.project};case"project_list":case"project-list":case"oc-project_list":case"oc-project-list":return{icon:"folder",title:"Projects"};case"project_get":case"project-get":case"oc-project_get":case"oc-project-get":case"project_update":case"project-update":case"oc-project_update":case"oc-project-update":return{icon:"folder",title:"Project",subtitle:t.name||t.project};case"project_select":case"project-select":case"oc-project_select":case"oc-project-select":return{icon:"folder",title:"Project Select",subtitle:t.project};case"project_create":case"project-create":case"oc-project_create":case"oc-project-create":return{icon:"folder-plus",title:"Project Create",subtitle:t.name};case"triggers":case"trigger_create":case"trigger-create":case"oc-trigger_create":case"oc-trigger-create":return{icon:"clock",title:"Create Trigger",subtitle:t.name};case"trigger_list":case"trigger-list":case"oc-trigger_list":case"oc-trigger-list":return{icon:"clock",title:"List Triggers"};case"trigger_get":case"trigger-get":case"oc-trigger_get":case"oc-trigger-get":return{icon:"clock",title:"Trigger Details",subtitle:t.name||t.id};case"trigger_delete":case"trigger-delete":case"oc-trigger_delete":case"oc-trigger-delete":return{icon:"clock",title:"Delete Trigger",subtitle:t.name||t.id};case"trigger_update":case"trigger-update":case"oc-trigger_update":case"oc-trigger-update":return{icon:"clock",title:"Update Trigger",subtitle:t.name||t.id};case"trigger_test":case"trigger-test":case"oc-trigger_test":case"oc-trigger-test":return{icon:"clock",title:"Test Trigger",subtitle:t.name||t.id};case"trigger_pause":case"trigger-pause":case"oc-trigger_pause":case"oc-trigger-pause":return{icon:"clock",title:"Pause Trigger",subtitle:t.name||t.id};case"trigger_resume":case"trigger-resume":case"oc-trigger_resume":case"oc-trigger-resume":return{icon:"clock",title:"Resume Trigger",subtitle:t.name||t.id};case"agent_spawn":case"agent-spawn":return{icon:"cpu",title:`Agent (${t.agent_type||"worker"})`,subtitle:t.description};case"agent_message":case"agent-message":return{icon:"message-circle",title:"Agent Message",subtitle:t.agent_id};case"agent_stop":case"agent-stop":return{icon:"ban",title:"Agent Stop",subtitle:t.agent_id};case"agent_status":case"agent-status":return{icon:"layers",title:"Agent Status"};case"agent_task":case"agent-task":case"oc-agent_task":case"oc-agent-task":return{icon:"check-square",title:"Create Task",subtitle:t.title};case"agent_task_update":case"agent-task-update":case"oc-agent_task_update":case"oc-agent-task-update":return{icon:"check-square",title:"Update Task",subtitle:t.task_id};case"agent_task_list":case"agent-task-list":case"oc-agent_task_list":case"oc-agent-task-list":return{icon:"check-square",title:"List Tasks"};case"agent_task_get":case"agent-task-get":case"oc-agent_task_get":case"oc-agent-task-get":return{icon:"check-square",title:"Task Details",subtitle:t.task_id};case"task_create":case"task-create":return{icon:"plus",title:"Create Task",subtitle:t.title};case"task_list":case"task-list":return{icon:"list",title:"Tasks",subtitle:t.status||"all"};case"task_update":case"task-update":return{icon:"refresh-cw",title:"Update Task",subtitle:t.id};case"task_done":case"task-done":return{icon:"check-circle",title:"Task Done",subtitle:t.id};case"task_delete":case"task-delete":return{icon:"trash-2",title:"Delete Task",subtitle:t.id};case"pty_spawn":return{icon:"terminal",title:"Spawn",subtitle:t.title||t.command};case"pty_read":return{icon:"terminal",title:"Terminal Output",subtitle:t.id};case"pty_write":case"pty_input":return{icon:"terminal",title:"Terminal Input",subtitle:t.id};case"pty_kill":return{icon:"terminal",title:"Kill Process",subtitle:t.id};default:return{icon:"cpu",title:e}}}function cl(e){if(!e)return;let t=e.split("/");return t[t.length-1]||e}function Ya(e){if(!e)return;let t=e.split("/"),r=t[t.length-1]||e;if(t.length<=1)return r;let n=t[t.length-2];return n?`${r} /${n}`:r}function ll(e){if(!e)return;let t=e.lastIndexOf("/");if(!(t<0))return e.slice(0,t)||"/"}function Eg(e,t){if(!t)return e;if(e.startsWith(t)){let r=e.slice(t.length);return r.startsWith("/")?r.slice(1):r}return e}function Ge(e,t=120){if(typeof e!="string")return"";let r=e.split(`
60
- `).map(n=>n.trim()).find(Boolean);return r?r.length>t?`${r.slice(0,t).trim()}\u2026`:r:""}function ul(e){let t=Ge(e.description);if(t)return t;let r=Ge(e.title,80);if(r)return r;let n=Ge(e.message);if(n)return n;let s=Ge(e.prompt);if(s)return s;let l=Ge(e.agent_id,40);return l?`Agent ${l}`:"Worker task"}function $g(e,t){return!e||!t?[]:(e[t]??[]).filter(n=>n.severity===1).slice(0,3)}function qg(e,t){return e.find(r=>r.tool?.callID===t)}function Dg(e,t){return e.find(r=>r.tool?.callID===t)}var Mg=/\x1B\[[\d;]*[A-Za-z]|\x1B\][^\x07]{0,512}\x07|\x1B[()#][A-Z0-9]|\x1B\[?[\d;]*[hl]|\x1B[>=<]|\x1B\[[?]?\d*[A-Z]|\x1B\[\d*[JKHG]|\x1B\[\d*;\d*[Hf]|\x1b\[[0-9;]*m/g;function Ug(e){return e?e.replace(Mg,""):""}function Og(e){let t=[],r=new Map;for(let s of e)if(s.info.role==="user"){if(r.has(s.info.id))continue;let l={userMessage:s,assistantMessages:[]};t.push(l),r.set(s.info.id,l)}let n=null;for(let s of e){if(s.info.role==="user"){n=r.get(s.info.id)??null;continue}if(s.info.role!=="assistant")continue;let l=s.info;if(l.parentID){let d=r.get(l.parentID);if(d){d.assistantMessages.push(s);continue}}if(n){n.assistantMessages.push(s);continue}if(t.length>0){t[0].assistantMessages.unshift(s);continue}let u={userMessage:s,assistantMessages:[]};t.push(u)}return t}function Lg(e){let t=[];for(let r of e.assistantMessages)for(let n of r.parts)t.push({part:n,message:r});return t}function Fg(e){for(let t=e.length-1;t>=0;t--){let r=e[t].part;if(ee(r)&&r.text?.trim())return r}}function Bg(e){return e.some(({part:t})=>t.type==="tool"||t.type==="compaction"||t.type==="snapshot"||t.type==="patch")}function Gg(e,t,r){if(r)return[];let n=[];for(let s of e.assistantMessages)for(let l of s.parts){if(!z(l))continue;let u=l,d=u.state?.metadata?.answers;u.tool==="question"&&(d?.length??0)>0&&n.push({part:l,message:s})}return n}function Kg(e){let t=new Map;for(let r of e){if(!r.parentID)continue;let n=t.get(r.parentID);n?n.push(r.id):t.set(r.parentID,[r.id])}return t}function Ng(e){let t=e-6e4;return(r,n)=>{let s=r.time.updated??r.time.created,l=n.time.updated??n.time.created,u=s>t,d=l>t;return u&&d?r.id<n.id?-1:r.id>n.id?1:0:u&&!d?-1:!u&&d?1:l-s}}function pl(e,t){let r=e.get(t);if(!r||r.length===0)return[];let n=[];for(let s of r)n.push(s),n.push(...pl(e,s));return n}function dl(e){let t=e.userMessage.parts;if(t.length===0||!t.every(l=>ee(l)&&l.synthetic)||e.assistantMessages.length!==1)return!1;let n=e.assistantMessages[0].parts;if(n.length!==1)return!1;let s=n[0];return z(s)&&s.tool==="bash"}function Hg(e){if(dl(e))return e.assistantMessages[0].parts[0]}function Wg(e,t){for(let r=t.length-1;r>=0;r--)if(t[r].info.role==="user")return t[r].info.id===e;return!1}function Vg(e,t){return!t||!e?!1:e.type!=="idle"}function zg(e,t){return!e&&!!t}function Jg(e){for(let t of e.assistantMessages){let r=t.info;if(r.error)return K(r.error)}}function Za(e){if(e){if(z(e))switch(e.tool){case"task":case"session_spawn":case"session_start_background":case"session-spawn":case"session-start-background":return"Delegating to agent...";case"agent_spawn":case"agent-spawn":case"agent_task":case"agent-task":return"Delegating to agent...";case"agent_task_update":case"agent-task-update":case"task_update":case"task-update":return"Updating task...";case"agent_message":case"agent-message":case"agent_task_message":case"agent-task-message":case"task_message":case"task-message":return"Messaging agent...";case"task_create":case"task-create":case"task_start":case"task-start":return"Creating task...";case"task_list":case"task-list":return"Listing tasks...";case"task_done":case"task-done":return"Updating task...";case"todowrite":case"todoread":return"Planning...";case"read":return"Gathering context...";case"list":case"grep":case"glob":return"Searching codebase...";case"webfetch":case"scrape-webpage":return"Fetching web page...";case"websearch":case"web-search":case"web_search":return"Searching web...";case"image-search":return"Searching images...";case"image-gen":return"Generating image...";case"video-gen":return"Generating video...";case"presentation-gen":return"Creating presentation...";case"show":case"show-user":return"Showing output...";case"edit":case"write":case"morph_edit":return"Making edits...";case"bash":return"Running commands...";case"apply_patch":return"Applying patches...";case"prune":return"Pruning context...";case"distill":return"Distilling context...";case"compress":return"Compressing context...";case"context_info":return"Updating context info...";default:return`Running ${e.tool}...`}if(Tt(e)){let t=e.text?.trimStart();if(t){let r=t.match(/^\*\*(.+?)\*\*/);if(r)return`Thinking about ${r[1].trim()}...`}return"Thinking..."}if(ee(e))return"Gathering thoughts..."}}function Xg(e,t){for(let r=e.length-1;r>=0;r--){let n=e[r].part,s=z(n)?n:void 0;if(s&&(s.tool==="task"||s.tool==="agent_task"||s.tool==="agent-task"||s.tool==="task_create"||s.tool==="task-create"||s.tool==="task_start"||s.tool==="task-start")&&s.state.status==="running"&&t&&t.length>0){for(let u=t.length-1;u>=0;u--){let d=t[u];if(d.info.role==="assistant")for(let g=d.parts.length-1;g>=0;g--){let h=Za(d.parts[g]);if(h)return h}}return"Delegating to agent..."}let l=Za(n);if(l)return l}return"Considering next steps..."}function Qg(e){if(!Number.isFinite(e)||e<1e3)return"";let t=Math.floor(e/1e3);if(t<60)return`${t}s`;let r=Math.floor(t/60),n=t%60;return n>0?`${r}m ${n}s`:`${r}m`}var ec=1.2;function gl(e,t){if(!e)return 0;let r=e.input??0,n=(e.output??0)+(e.reasoning??0),s=e.cache?.read??0,l=e.cache?.write??0,d=Math.max(0,r-s-l)/1e6*t.inputPer1M;return d+=n/1e6*t.outputPer1M,s>0&&(d+=s/1e6*(t.cacheReadPer1M??t.inputPer1M)),l>0&&(d+=l/1e6*t.inputPer1M),d}function ml(e,t,r,n){let s=e.cost||0;if(s>0)return s;if(!n||!t||!r)return 0;let l=n(t,r);return l?gl(e.tokens,l):0}function fl(e){if(e.role!=="assistant")return{};let t=e;return{providerID:t.providerID,modelID:t.modelID}}function Yg(e,t){let r=0,n=0,s=0,l=0,u=0,d=0,g=!1;for(let{part:h,message:m}of e)if(h.type==="step-finish"){g=!0;let x=h,{providerID:k,modelID:_}=fl(m.info);r+=ml(x,k,_,t),n+=x.tokens?.input||0,s+=x.tokens?.output||0,l+=x.tokens?.reasoning||0,u+=x.tokens?.cache?.read||0,d+=x.tokens?.cache?.write||0}if(!g)for(let{message:h}of e){if(h.info.role!=="assistant")continue;let m=h.info,x=yl(m,t);if(x<=0)continue;g=!0,r+=x;let k=m.tokens;k&&(n+=k.input??0,s+=k.output??0,l+=k.reasoning??0,u+=k.cache?.read??0,d+=k.cache?.write??0)}if(g)return{cost:r*ec,tokens:{input:n,output:s,reasoning:l,cacheRead:u,cacheWrite:d}}}function yl(e,t){if(!t||!e.providerID||!e.modelID||!e.tokens)return 0;let r=t(e.providerID,e.modelID);return r?gl({input:e.tokens.input,output:e.tokens.output,reasoning:e.tokens.reasoning,cache:e.tokens.cache},r):0}function Zg(e,t){let r=0;for(let n of e){if(n.info?.role!=="assistant")continue;let s=n.info,{providerID:l,modelID:u}=fl(s),d=0,g=!1;for(let h of n.parts)h.type==="step-finish"&&(g=!0,d+=ml(h,l,u,t));g||(d+=yl(s,t)),r+=d}return r*ec}function em(e){return e===0?"$0.00":e<.001?`$${e.toFixed(4)}`:e<.01?`$${e.toFixed(3)}`:`$${e.toFixed(2)}`}function tm(e){return e<1e3?String(e):e<1e4?`${(e/1e3).toFixed(1)}k`:`${Math.round(e/1e3)}k`}function rm(e){if(!e||e.type!=="retry")return;let t=e;return{attempt:t.attempt,message:t.message.length>60?`${t.message.slice(0,60)}...`:t.message,next:t.next}}function nm(e){if(!(!e||e.type!=="retry"))return K(e.message)}function sm(e){return(e.info.summary?.diffs?.length??0)>0}var im=4e3;function Ke(e,t=im){return e.length>t?`${e.slice(0,t)}
61
- \u2026`:e}function hl(e){if(e!==void 0)try{return Ke(JSON.stringify(e,null,2))}catch{return}}function q(...e){for(let t of e)if(typeof t=="string"&&t.length>0)return t}function _e(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)?e:void 0}function om(e){let t=q(e.input?.query)??"";if(e.status==="error")return{kind:"web-search",query:t,error:e.error??"Search failed"};let r=_e(e.outputParsed);if(!r)return{kind:"web-search",query:t};let s=(Array.isArray(r.results)?r.results:Array.isArray(r.images)?r.images:[]).slice(0,50).map(l=>{let u=_e(l)??{};return{title:q(u.title)??"",url:q(u.url,u.link)??"",snippet:q(u.snippet,u.description,u.source)}});return{kind:"web-search",query:q(r.query)??t,results:s.length>0?s:void 0,answer:q(r.answer)}}var am=/<exit_code>\s*(-?\d+)\s*<\/exit_code>/;function cm(e,t,r){let n="",s=0;for(;;){let l=e.indexOf(t,s);if(l===-1)return n+e.slice(s);let u=e.indexOf(r,l+t.length);if(u===-1)return n+e.slice(s);n+=e.slice(s,l),s=u+r.length}}var lm=["<system_info>","</system_info>","<exit_code>","</exit_code>","<stderr_note>","</stderr_note>"];function um(e){let t=-1;for(let r of lm){let n=e.indexOf(r);n!==-1&&(t===-1||n<t)&&(t=n)}return t===-1?e:e.slice(0,t)}var pm=/\x1B\[[\d;]*[A-Za-z]|\x1B\][^\x07]{0,512}\x07|\x1B[()#][A-Z0-9]|\x1B\[?[\d;]*[hl]|\x1B[>=<]|\x1B\[[?]?\d*[A-Z]|\x1B\[\d*[JKHG]|\x1B\[\d*;\d*[Hf]|\x1b\[[0-9;]*m/g;function dm(e){return e.replace(pm,"")}function gm(e){let t=q(e.input?.command)??"",r=e.output??"",n=r.match(am),s=n?Number(n[1]):void 0,u=dm(um(cm(r,"<bash_metadata>","</bash_metadata>"))).trim()||(e.status==="error"?e.error:void 0);return{kind:"shell",command:t,stdout:u||void 0,exitCode:s}}function rc(e){return q(e.input?.filePath,e.input?.file_path,e.input?.path)??""}function mm(e){let t=e.status==="error"?e.error:e.output&&Ke(e.output)||void 0;return{kind:"file-read",path:rc(e),preview:t}}function fm(e){let t=q(e.input?.content),r=e.status==="error"?e.error:Ke(t??e.output??"")||void 0;return{kind:"file-write",path:rc(e),preview:r}}var ym=256*1024;function hm(e,t){if(e.length+t.length>ym)return;let r=e.split(`
59
+ `;return n}function Kc(e,t){return`session-${e}.md`}function K(e){if(!e)return"An error occurred";if(typeof e=="string"){let t=e.startsWith("Error: ")?e.slice(7):e;try{let r=JSON.parse(t);if(typeof r=="string"){t=r;try{let n=JSON.parse(t);return St(n)||t}catch{return t}}return St(r)||t}catch{return Gd(t)??t}}return typeof e=="object"?St(e)||"An error occurred":String(e)}function Gd(e){let t=e.indexOf("{"),r=e.lastIndexOf("}");if(!(t===-1||r===-1||r<=t))try{let n=JSON.parse(e.slice(t,r+1));return St(n)}catch{return}}function St(e){if(typeof e!="object"||e===null||Array.isArray(e))return;let t=e;if(typeof t.message=="string"&&t.message)return t.message;if(typeof t.error=="string"&&t.error)return t.error;let r=t.data;if(typeof r?.message=="string")return r.message;let n=t.error;if(typeof n?.message=="string")return n.message}var Bd={bash:{label:"Shell",category:"shell"},pty_spawn:{label:"Spawn Terminal",category:"shell"},pty_read:{label:"Terminal Output",category:"shell"},pty_write:{label:"Terminal Input",category:"shell"},pty_input:{label:"Terminal Input",category:"shell"},pty_kill:{label:"Kill Process",category:"shell"},read:{label:"Read File",category:"files"},list:{label:"List Directory",category:"files"},ls:{label:"List Directory",category:"files"},write:{label:"Write File",category:"edit"},edit:{label:"Edit File",category:"edit"},multiedit:{label:"Edit File",category:"edit"},morph_edit:{label:"Edit File",category:"edit"},apply_patch:{label:"Apply Patch",category:"edit"},patch:{label:"Apply Patch",category:"edit"},grep:{label:"Search Code",category:"search"},glob:{label:"Find Files",category:"search"},image_search:{label:"Image Search",category:"search"},session_search:{label:"Search Sessions",category:"search"},webfetch:{label:"Fetch Page",category:"web"},scrape_webpage:{label:"Scrape Page",category:"web"},websearch:{label:"Web Search",category:"web"},web_search:{label:"Web Search",category:"web"},image_gen:{label:"Generate Image",category:"web"},video_gen:{label:"Generate Video",category:"web"},task:{label:"Delegate to Agent",category:"task"},todowrite:{label:"Plan Tasks",category:"task"},todoread:{label:"Read Plan",category:"task"},question:{label:"Ask Question",category:"task"},presentation_gen:{label:"Presentation",category:"task"},show:{label:"Show Output",category:"task"},show_user:{label:"Show Output",category:"task"},prune:{label:"Prune Context",category:"other"},distill:{label:"Distill Context",category:"other"},compress:{label:"Compress Context",category:"other"},context_info:{label:"Context Info",category:"other"}},Kd=[{prefix:"pty_",category:"shell"},{prefix:"agent_",category:"task"},{prefix:"session_",category:"task"},{prefix:"task_",category:"task"},{prefix:"trigger_",category:"task"},{prefix:"project_",category:"task"}];function Nd(e){return e.replace(/^oc[-_]/,"")}function Fe(e){return Nd(e).replace(/-/g,"_")}function vt(e){return Fe(e).split(/[_\s]+/).filter(Boolean).map(r=>r.charAt(0).toUpperCase()+r.slice(1)).join(" ")}function Ct(e){let t=Fe(e),r=Bd[t];if(r)return r;for(let{prefix:n,category:s}of Kd)if(t.startsWith(n))return{label:vt(e),category:s};return{label:vt(e),category:"other"}}var Hd=256*1024;function Wd(e){switch(e.status){case"pending":return"pending";case"running":return"running";case"completed":return"done";case"error":return"error";default:return e}}function Vd(e){if(e===void 0)return{};if(e.length>Hd)return{outputText:e};try{return{outputParsed:JSON.parse(e),outputText:e}}catch{return{outputText:e}}}function zd(e){if(typeof e!="object"||e===null||Array.isArray(e))return;let t=e,r=t.success===!1,n=t.error,s=typeof n=="string"&&n.length>0||typeof n=="object"&&n!==null;if(!(!r&&!s))return s?K(n):typeof t.message=="string"&&t.message?t.message:"Tool reported failure"}function Jd(e,t){let r="title"in t?t.title:void 0,n=t.status==="completed"?t.output:void 0,{outputParsed:s,outputText:c}=Vd(n),u=Wd(t),d=t.status==="error"?t.error:void 0;if(u==="done"){let g=zd(s);g&&(u="error",d=g)}return{name:e,title:r||Ct(e).label,status:u,input:t.input,output:n,outputParsed:s,outputText:c,error:d}}function Xd(e){return{kind:"text",id:e.id,text:e.text,synthetic:!!e.synthetic}}function Qd(e){return{kind:"reasoning",id:e.id,text:e.text}}function Yd(e){return{kind:"tool",id:e.id,tool:Jd(e.tool,e.state)}}function Zd(e){let t=e.mime;return{kind:"file",id:e.id,filename:e.filename,mime:t,url:e.url,isImage:t.startsWith("image/"),isPdf:t==="application/pdf"}}function eg(e){return{kind:"subtask",id:e.id,description:e.description,agent:e.agent,prompt:e.prompt,model:e.model}}function tg(e){return{kind:"patch",id:e.id,hash:e.hash,files:e.files,fileCount:e.files.length}}function rg(e){return{kind:"snapshot",id:e.id,snapshot:e.snapshot}}function ng(e){return{kind:"agent",id:e.id,name:e.name}}function sg(e){return{kind:"retry",id:e.id,attempt:e.attempt,message:K(e.error),createdAt:e.time.created}}function ig(e){return{kind:"compaction",id:e.id,auto:e.auto,overflow:!!e.overflow,tailStartId:e.tail_start_id}}function og(e){return{kind:"step",id:e.id,phase:"start",snapshot:e.snapshot}}function ag(e){return{kind:"step",id:e.id,phase:"finish",snapshot:e.snapshot,reason:e.reason,cost:e.cost,tokens:e.tokens}}function Ma(e){switch(e.type){case"text":return Xd(e);case"reasoning":return Qd(e);case"tool":return Yd(e);case"file":return Zd(e);case"subtask":return eg(e);case"patch":return tg(e);case"snapshot":return rg(e);case"agent":return ng(e);case"retry":return sg(e);case"compaction":return ig(e);case"step-start":return og(e);case"step-finish":return ag(e);default:return{kind:"unknown",raw:e}}}function cg(e){return e?{name:typeof e=="object"&&"name"in e&&typeof e.name=="string"?e.name:"Error",message:K(e)}:void 0}function lg(e){switch(e.kind){case"text":case"reasoning":return e.text.trim().length>0;case"step":return!1;default:return!0}}function Nc(e){let t=e.parts.map(Ma),r=e.info.role==="assistant"?e.info.error:void 0,n=cg(r),s=!n&&!t.some(lg);return{parts:t,error:n,isEmpty:s}}function ee(e){return e.type==="text"}function Rt(e){return e.type==="reasoning"}function z(e){return e.type==="tool"}function Hc(e){return e.type==="file"}function ug(e){return e.type==="agent"}function pg(e){return e.type==="compaction"}function dg(e){return e.type==="snapshot"}function gg(e){return e.type==="patch"}function mg(e){if(ee(e)||Rt(e))return e.text}function Wc(e){if(!Hc(e))return!1;let t=e.mime;return t.startsWith("image/")||t==="application/pdf"}function fg(e){let t=[],r=[];for(let n of e)Wc(n)?t.push(n):r.push(n);return{attachments:t,stickyParts:r}}function yg(e,t){let r=[];return e?.tool&&r.push(e.tool),t?.tool&&r.push(t.tool),r}function hg(e,t,r){return r.some(n=>n.messageID===t&&n.callID===e.callID)}var bg=new Set(["todoread","context_info"]);function Vc(e){return!bg.has(e.tool)}function xg(e){let t=e.tool||"";if(t==="task"||t==="agent_spawn"||t==="agent-spawn"||t==="agent_message"||t==="agent-message"||t==="agent_task"||t==="agent-task"||t==="agent_task_update"||t==="agent-task-update"||t==="agent_task_message"||t==="agent-task-message"||t==="agent_task_start"||t==="agent-task-start"||t==="task_create"||t==="task-create"||t==="task_start"||t==="task-start"||t==="task_update"||t==="task-update"||t==="task_message"||t==="task-message"){let n=e.state?.metadata?.sessionId;if(typeof n=="string"&&n)return n;let s=e.state?.title;if(s){let u=s.match(/\bses_[a-zA-Z0-9]+/);if(u)return u[0]}let c=e.state?.output;if(c){let u=c.match(/\bses_[a-zA-Z0-9]+/);if(u)return u[0]}return}let r=e.tool?.replace(/-/g,"_")||"";if(r==="session_spawn"||r==="session_start_background"){let n=e.state?.output;if(n){let s=n.match(/\*?\*?Session:?\*?\*?\s*(ses_[a-zA-Z0-9]+)/);if(s)return s[1]}return}}function kg(e){if(e)for(let t=e.length-1;t>=0;t--){let r=e[t]?.info;if(r?.role==="assistant"&&r.error)return K(r.error)}}function Pg(e){let t=[];for(let r of e)if(r.info.role==="assistant")for(let n of r.parts)z(n)&&Vc(n)&&t.push(n);return t}function wg(e,t={}){switch(e){case"read":return{icon:"glasses",title:"Read",subtitle:zc(t.filePath)};case"list":return{icon:"list",title:"List",subtitle:Jc(t.path)};case"glob":return{icon:"search",title:"Glob",subtitle:t.pattern};case"grep":return{icon:"search",title:"Grep",subtitle:t.pattern};case"webfetch":return{icon:"globe",title:"Web Fetch",subtitle:t.url};case"websearch":case"web-search":case"web_search":return{icon:"search",title:"Web Search",subtitle:t.query};case"scrape-webpage":return{icon:"globe",title:"Scrape",subtitle:t.urls?.split?.(",")[0]};case"image-search":return{icon:"image",title:"Image Search",subtitle:t.query};case"image-gen":return{icon:"image",title:"Image Gen",subtitle:t.prompt?.slice?.(0,40)};case"video-gen":return{icon:"cpu",title:"Video Gen",subtitle:t.prompt?.slice?.(0,40)};case"presentation-gen":{let r=t.action||"";return{icon:"presentation",title:{create_slide:"Create Slide",list_slides:"List Slides",preview:"Preview",export_pdf:"Export PDF",export_pptx:"Export PPTX"}[r]||"Presentation",subtitle:t.slide_title||t.presentation_name}}case"show":case"show-user":return{icon:"globe",title:"Output",subtitle:t.title||t.description};case"task":return{icon:"square-kanban",title:`Agent (${t.subagent_type||"task"})`,subtitle:Xc(t)};case"session_spawn":case"session_start_background":case"session-spawn":case"session-start-background":case"oc-session_spawn":case"oc-session-spawn":case"oc-session_start_background":case"oc-session-start-background":return{icon:"square-kanban",title:`Worker (${t.agent||"KortixWorker"})`,subtitle:t.description||t.prompt?.slice(0,60)};case"bash":return{icon:"terminal",title:"Shell",subtitle:t.description};case"edit":case"morph_edit":return{icon:"file-pen",title:"Edit",subtitle:Ua(t.filePath)};case"write":return{icon:"file-pen",title:"Write",subtitle:Ua(t.filePath)};case"apply_patch":return{icon:"file-pen",title:"Patch",subtitle:t.files?.length?`${t.files.length} file${t.files.length>1?"s":""}`:void 0};case"todowrite":return{icon:"check-square",title:"Todos"};case"todoread":return{icon:"check-square",title:"Todos (read)"};case"question":return{icon:"message-circle",title:"Questions"};case"prune":return{icon:"scissors",title:"DCP Prune",subtitle:t.reason};case"distill":return{icon:"scissors",title:"DCP Distill"};case"compress":return{icon:"scissors",title:"DCP Compress",subtitle:t.topic};case"context_info":return{icon:"scissors",title:"Context Info"};case"session_read":case"session-read":case"oc-session_read":case"oc-session-read":return{icon:"glasses",title:`Session Read (${t.mode||"summary"})`,subtitle:t.session_id?.slice(-12)};case"session_search":case"session-search":case"oc-session_search":case"oc-session-search":return{icon:"search",title:"Session Search",subtitle:t.query};case"session_message":case"session-message":case"oc-session_message":case"oc-session-message":return{icon:"message-circle",title:"Message \u2192 Session",subtitle:t.session_id?.slice(-12)};case"session_lineage":case"session-lineage":case"oc-session_lineage":case"oc-session-lineage":return{icon:"list-tree",title:"Session Lineage",subtitle:t.session_id?.slice(-12)};case"session_list_background":case"session-list-background":case"session_list_spawned":case"session-list-spawned":case"oc-session_list_background":case"oc-session-list-background":case"oc-session_list_spawned":case"oc-session-list-spawned":return{icon:"layers",title:"Background Sessions",subtitle:t.project||"all"};case"session_stats":case"session-stats":case"oc-session_stats":case"oc-session-stats":return{icon:"layers",title:"Session Stats",subtitle:t.session_id?.slice(-12)||"current"};case"session_list":case"session-list":case"oc-session_list":case"oc-session-list":return{icon:"list",title:"Session List",subtitle:t.search};case"session_get":case"session-get":case"oc-session_get":case"oc-session-get":return{icon:"book-open",title:"Session Get",subtitle:t.session_id?.slice(-12)};case"session_context":case"session-context":case"oc-session_context":case"oc-session-context":return{icon:"book-open",title:"Session Context",subtitle:t.session_id?.slice(-12)};case"project_delete":case"project-delete":case"oc-project_delete":case"oc-project-delete":return{icon:"trash-2",title:"Workspace Delete Disabled",subtitle:t.project};case"project_list":case"project-list":case"oc-project_list":case"oc-project-list":return{icon:"folder",title:"Projects"};case"project_get":case"project-get":case"oc-project_get":case"oc-project-get":case"project_update":case"project-update":case"oc-project_update":case"oc-project-update":return{icon:"folder",title:"Project",subtitle:t.name||t.project};case"project_select":case"project-select":case"oc-project_select":case"oc-project-select":return{icon:"folder",title:"Project Select",subtitle:t.project};case"project_create":case"project-create":case"oc-project_create":case"oc-project-create":return{icon:"folder-plus",title:"Project Create",subtitle:t.name};case"triggers":case"trigger_create":case"trigger-create":case"oc-trigger_create":case"oc-trigger-create":return{icon:"clock",title:"Create Trigger",subtitle:t.name};case"trigger_list":case"trigger-list":case"oc-trigger_list":case"oc-trigger-list":return{icon:"clock",title:"List Triggers"};case"trigger_get":case"trigger-get":case"oc-trigger_get":case"oc-trigger-get":return{icon:"clock",title:"Trigger Details",subtitle:t.name||t.id};case"trigger_delete":case"trigger-delete":case"oc-trigger_delete":case"oc-trigger-delete":return{icon:"clock",title:"Delete Trigger",subtitle:t.name||t.id};case"trigger_update":case"trigger-update":case"oc-trigger_update":case"oc-trigger-update":return{icon:"clock",title:"Update Trigger",subtitle:t.name||t.id};case"trigger_test":case"trigger-test":case"oc-trigger_test":case"oc-trigger-test":return{icon:"clock",title:"Test Trigger",subtitle:t.name||t.id};case"trigger_pause":case"trigger-pause":case"oc-trigger_pause":case"oc-trigger-pause":return{icon:"clock",title:"Pause Trigger",subtitle:t.name||t.id};case"trigger_resume":case"trigger-resume":case"oc-trigger_resume":case"oc-trigger-resume":return{icon:"clock",title:"Resume Trigger",subtitle:t.name||t.id};case"agent_spawn":case"agent-spawn":return{icon:"cpu",title:`Agent (${t.agent_type||"worker"})`,subtitle:t.description};case"agent_message":case"agent-message":return{icon:"message-circle",title:"Agent Message",subtitle:t.agent_id};case"agent_stop":case"agent-stop":return{icon:"ban",title:"Agent Stop",subtitle:t.agent_id};case"agent_status":case"agent-status":return{icon:"layers",title:"Agent Status"};case"agent_task":case"agent-task":case"oc-agent_task":case"oc-agent-task":return{icon:"check-square",title:"Create Task",subtitle:t.title};case"agent_task_update":case"agent-task-update":case"oc-agent_task_update":case"oc-agent-task-update":return{icon:"check-square",title:"Update Task",subtitle:t.task_id};case"agent_task_list":case"agent-task-list":case"oc-agent_task_list":case"oc-agent-task-list":return{icon:"check-square",title:"List Tasks"};case"agent_task_get":case"agent-task-get":case"oc-agent_task_get":case"oc-agent-task-get":return{icon:"check-square",title:"Task Details",subtitle:t.task_id};case"task_create":case"task-create":return{icon:"plus",title:"Create Task",subtitle:t.title};case"task_list":case"task-list":return{icon:"list",title:"Tasks",subtitle:t.status||"all"};case"task_update":case"task-update":return{icon:"refresh-cw",title:"Update Task",subtitle:t.id};case"task_done":case"task-done":return{icon:"check-circle",title:"Task Done",subtitle:t.id};case"task_delete":case"task-delete":return{icon:"trash-2",title:"Delete Task",subtitle:t.id};case"pty_spawn":return{icon:"terminal",title:"Spawn",subtitle:t.title||t.command};case"pty_read":return{icon:"terminal",title:"Terminal Output",subtitle:t.id};case"pty_write":case"pty_input":return{icon:"terminal",title:"Terminal Input",subtitle:t.id};case"pty_kill":return{icon:"terminal",title:"Kill Process",subtitle:t.id};default:return{icon:"cpu",title:e}}}function zc(e){if(!e)return;let t=e.split("/");return t[t.length-1]||e}function Ua(e){if(!e)return;let t=e.split("/"),r=t[t.length-1]||e;if(t.length<=1)return r;let n=t[t.length-2];return n?`${r} /${n}`:r}function Jc(e){if(!e)return;let t=e.lastIndexOf("/");if(!(t<0))return e.slice(0,t)||"/"}function _g(e,t){if(!t)return e;if(e.startsWith(t)){let r=e.slice(t.length);return r.startsWith("/")?r.slice(1):r}return e}function Ge(e,t=120){if(typeof e!="string")return"";let r=e.split(`
60
+ `).map(n=>n.trim()).find(Boolean);return r?r.length>t?`${r.slice(0,t).trim()}\u2026`:r:""}function Xc(e){let t=Ge(e.description);if(t)return t;let r=Ge(e.title,80);if(r)return r;let n=Ge(e.message);if(n)return n;let s=Ge(e.prompt);if(s)return s;let c=Ge(e.agent_id,40);return c?`Agent ${c}`:"Worker task"}function Sg(e,t){return!e||!t?[]:(e[t]??[]).filter(n=>n.severity===1).slice(0,3)}function vg(e,t){return e.find(r=>r.tool?.callID===t)}function Cg(e,t){return e.find(r=>r.tool?.callID===t)}var Rg=/\x1B\[[\d;]*[A-Za-z]|\x1B\][^\x07]{0,512}\x07|\x1B[()#][A-Z0-9]|\x1B\[?[\d;]*[hl]|\x1B[>=<]|\x1B\[[?]?\d*[A-Z]|\x1B\[\d*[JKHG]|\x1B\[\d*;\d*[Hf]|\x1b\[[0-9;]*m/g;function Tg(e){return e?e.replace(Rg,""):""}function Ig(e){let t=[],r=new Map;for(let s of e)if(s.info.role==="user"){if(r.has(s.info.id))continue;let c={userMessage:s,assistantMessages:[]};t.push(c),r.set(s.info.id,c)}let n=null;for(let s of e){if(s.info.role==="user"){n=r.get(s.info.id)??null;continue}if(s.info.role!=="assistant")continue;let c=s.info;if(c.parentID){let d=r.get(c.parentID);if(d){d.assistantMessages.push(s);continue}}if(n){n.assistantMessages.push(s);continue}if(t.length>0){t[0].assistantMessages.unshift(s);continue}let u={userMessage:s,assistantMessages:[]};t.push(u)}return t}function jg(e){let t=[];for(let r of e.assistantMessages)for(let n of r.parts)t.push({part:n,message:r});return t}function Ag(e){for(let t=e.length-1;t>=0;t--){let r=e[t].part;if(ee(r)&&r.text?.trim())return r}}function Eg(e){return e.some(({part:t})=>t.type==="tool"||t.type==="compaction"||t.type==="snapshot"||t.type==="patch")}function $g(e,t,r){if(r)return[];let n=[];for(let s of e.assistantMessages)for(let c of s.parts){if(!z(c))continue;let u=c,d=u.state?.metadata?.answers;u.tool==="question"&&(d?.length??0)>0&&n.push({part:c,message:s})}return n}function qg(e){let t=new Map;for(let r of e){if(!r.parentID)continue;let n=t.get(r.parentID);n?n.push(r.id):t.set(r.parentID,[r.id])}return t}function Dg(e){let t=e-6e4;return(r,n)=>{let s=r.time.updated??r.time.created,c=n.time.updated??n.time.created,u=s>t,d=c>t;return u&&d?r.id<n.id?-1:r.id>n.id?1:0:u&&!d?-1:!u&&d?1:c-s}}function Qc(e,t){let r=e.get(t);if(!r||r.length===0)return[];let n=[];for(let s of r)n.push(s),n.push(...Qc(e,s));return n}function Yc(e){let t=e.userMessage.parts;if(t.length===0||!t.every(c=>ee(c)&&c.synthetic)||e.assistantMessages.length!==1)return!1;let n=e.assistantMessages[0].parts;if(n.length!==1)return!1;let s=n[0];return z(s)&&s.tool==="bash"}function Mg(e){if(Yc(e))return e.assistantMessages[0].parts[0]}function Ug(e,t){for(let r=t.length-1;r>=0;r--)if(t[r].info.role==="user")return t[r].info.id===e;return!1}function Og(e,t){return!t||!e?!1:e.type!=="idle"}function Lg(e,t){return!e&&!!t}function Fg(e){for(let t of e.assistantMessages){let r=t.info;if(r.error)return K(r.error)}}function Oa(e){if(e){if(z(e))switch(e.tool){case"task":case"session_spawn":case"session_start_background":case"session-spawn":case"session-start-background":return"Delegating to agent...";case"agent_spawn":case"agent-spawn":case"agent_task":case"agent-task":return"Delegating to agent...";case"agent_task_update":case"agent-task-update":case"task_update":case"task-update":return"Updating task...";case"agent_message":case"agent-message":case"agent_task_message":case"agent-task-message":case"task_message":case"task-message":return"Messaging agent...";case"task_create":case"task-create":case"task_start":case"task-start":return"Creating task...";case"task_list":case"task-list":return"Listing tasks...";case"task_done":case"task-done":return"Updating task...";case"todowrite":case"todoread":return"Planning...";case"read":return"Gathering context...";case"list":case"grep":case"glob":return"Searching codebase...";case"webfetch":case"scrape-webpage":return"Fetching web page...";case"websearch":case"web-search":case"web_search":return"Searching web...";case"image-search":return"Searching images...";case"image-gen":return"Generating image...";case"video-gen":return"Generating video...";case"presentation-gen":return"Creating presentation...";case"show":case"show-user":return"Showing output...";case"edit":case"write":case"morph_edit":return"Making edits...";case"bash":return"Running commands...";case"apply_patch":return"Applying patches...";case"prune":return"Pruning context...";case"distill":return"Distilling context...";case"compress":return"Compressing context...";case"context_info":return"Updating context info...";default:return`Running ${e.tool}...`}if(Rt(e)){let t=e.text?.trimStart();if(t){let r=t.match(/^\*\*(.+?)\*\*/);if(r)return`Thinking about ${r[1].trim()}...`}return"Thinking..."}if(ee(e))return"Gathering thoughts..."}}function Gg(e,t){for(let r=e.length-1;r>=0;r--){let n=e[r].part,s=z(n)?n:void 0;if(s&&(s.tool==="task"||s.tool==="agent_task"||s.tool==="agent-task"||s.tool==="task_create"||s.tool==="task-create"||s.tool==="task_start"||s.tool==="task-start")&&s.state.status==="running"&&t&&t.length>0){for(let u=t.length-1;u>=0;u--){let d=t[u];if(d.info.role==="assistant")for(let g=d.parts.length-1;g>=0;g--){let h=Oa(d.parts[g]);if(h)return h}}return"Delegating to agent..."}let c=Oa(n);if(c)return c}return"Considering next steps..."}function Bg(e){if(!Number.isFinite(e)||e<1e3)return"";let t=Math.floor(e/1e3);if(t<60)return`${t}s`;let r=Math.floor(t/60),n=t%60;return n>0?`${r}m ${n}s`:`${r}m`}var La=1.2;function Zc(e,t){if(!e)return 0;let r=e.input??0,n=(e.output??0)+(e.reasoning??0),s=e.cache?.read??0,c=e.cache?.write??0,d=Math.max(0,r-s-c)/1e6*t.inputPer1M;return d+=n/1e6*t.outputPer1M,s>0&&(d+=s/1e6*(t.cacheReadPer1M??t.inputPer1M)),c>0&&(d+=c/1e6*t.inputPer1M),d}function el(e,t,r,n){let s=e.cost||0;if(s>0)return s;if(!n||!t||!r)return 0;let c=n(t,r);return c?Zc(e.tokens,c):0}function tl(e){if(e.role!=="assistant")return{};let t=e;return{providerID:t.providerID,modelID:t.modelID}}function Kg(e,t){let r=0,n=0,s=0,c=0,u=0,d=0,g=!1;for(let{part:h,message:m}of e)if(h.type==="step-finish"){g=!0;let x=h,{providerID:w,modelID:k}=tl(m.info);r+=el(x,w,k,t),n+=x.tokens?.input||0,s+=x.tokens?.output||0,c+=x.tokens?.reasoning||0,u+=x.tokens?.cache?.read||0,d+=x.tokens?.cache?.write||0}if(!g)for(let{message:h}of e){if(h.info.role!=="assistant")continue;let m=h.info,x=rl(m,t);if(x<=0)continue;g=!0,r+=x;let w=m.tokens;w&&(n+=w.input??0,s+=w.output??0,c+=w.reasoning??0,u+=w.cache?.read??0,d+=w.cache?.write??0)}if(g)return{cost:r*La,tokens:{input:n,output:s,reasoning:c,cacheRead:u,cacheWrite:d}}}function rl(e,t){if(!t||!e.providerID||!e.modelID||!e.tokens)return 0;let r=t(e.providerID,e.modelID);return r?Zc({input:e.tokens.input,output:e.tokens.output,reasoning:e.tokens.reasoning,cache:e.tokens.cache},r):0}function Ng(e,t){let r=0;for(let n of e){if(n.info?.role!=="assistant")continue;let s=n.info,{providerID:c,modelID:u}=tl(s),d=0,g=!1;for(let h of n.parts)h.type==="step-finish"&&(g=!0,d+=el(h,c,u,t));g||(d+=rl(s,t)),r+=d}return r*La}function Hg(e){return e===0?"$0.00":e<.001?`$${e.toFixed(4)}`:e<.01?`$${e.toFixed(3)}`:`$${e.toFixed(2)}`}function Wg(e){return e<1e3?String(e):e<1e4?`${(e/1e3).toFixed(1)}k`:`${Math.round(e/1e3)}k`}function Vg(e){if(!e||e.type!=="retry")return;let t=e;return{attempt:t.attempt,message:t.message.length>60?`${t.message.slice(0,60)}...`:t.message,next:t.next}}function zg(e){if(!(!e||e.type!=="retry"))return K(e.message)}function Jg(e){return(e.info.summary?.diffs?.length??0)>0}var Xg=4e3;function Be(e,t=Xg){return e.length>t?`${e.slice(0,t)}
61
+ \u2026`:e}function nl(e){if(e!==void 0)try{return Be(JSON.stringify(e,null,2))}catch{return}}function q(...e){for(let t of e)if(typeof t=="string"&&t.length>0)return t}function Pe(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)?e:void 0}function Qg(e){let t=q(e.input?.query)??"";if(e.status==="error")return{kind:"web-search",query:t,error:e.error??"Search failed"};let r=Pe(e.outputParsed);if(!r)return{kind:"web-search",query:t};let s=(Array.isArray(r.results)?r.results:Array.isArray(r.images)?r.images:[]).slice(0,50).map(c=>{let u=Pe(c)??{};return{title:q(u.title)??"",url:q(u.url,u.link)??"",snippet:q(u.snippet,u.description,u.source)}});return{kind:"web-search",query:q(r.query)??t,results:s.length>0?s:void 0,answer:q(r.answer)}}var Yg=/<exit_code>\s*(-?\d+)\s*<\/exit_code>/;function Zg(e,t,r){let n="",s=0;for(;;){let c=e.indexOf(t,s);if(c===-1)return n+e.slice(s);let u=e.indexOf(r,c+t.length);if(u===-1)return n+e.slice(s);n+=e.slice(s,c),s=u+r.length}}var em=["<system_info>","</system_info>","<exit_code>","</exit_code>","<stderr_note>","</stderr_note>"];function tm(e){let t=-1;for(let r of em){let n=e.indexOf(r);n!==-1&&(t===-1||n<t)&&(t=n)}return t===-1?e:e.slice(0,t)}var rm=/\x1B\[[\d;]*[A-Za-z]|\x1B\][^\x07]{0,512}\x07|\x1B[()#][A-Z0-9]|\x1B\[?[\d;]*[hl]|\x1B[>=<]|\x1B\[[?]?\d*[A-Z]|\x1B\[\d*[JKHG]|\x1B\[\d*;\d*[Hf]|\x1b\[[0-9;]*m/g;function nm(e){return e.replace(rm,"")}function sm(e){let t=q(e.input?.command)??"",r=e.output??"",n=r.match(Yg),s=n?Number(n[1]):void 0,u=nm(tm(Zg(r,"<bash_metadata>","</bash_metadata>"))).trim()||(e.status==="error"?e.error:void 0);return{kind:"shell",command:t,stdout:u||void 0,exitCode:s}}function Ga(e){return q(e.input?.filePath,e.input?.file_path,e.input?.path)??""}function im(e){let t=e.status==="error"?e.error:e.output&&Be(e.output)||void 0;return{kind:"file-read",path:Ga(e),preview:t}}function om(e){let t=q(e.input?.content),r=e.status==="error"?e.error:Be(t??e.output??"")||void 0;return{kind:"file-write",path:Ga(e),preview:r}}var am=256*1024;function cm(e,t){if(e.length+t.length>am)return;let r=e.split(`
62
62
  `),n=t.split(`
63
- `),s=0;for(;s<r.length&&s<n.length&&r[s]===n[s];)s++;let l=r.length,u=n.length;for(;l>s&&u>s&&r[l-1]===n[u-1];)l--,u--;let d=[];for(let g=0;g<s;g++)d.push({type:"unchanged",text:r[g]});for(let g=s;g<l;g++)d.push({type:"removed",text:r[g]});for(let g=s;g<u;g++)d.push({type:"added",text:n[g]});for(let g=l;g<r.length;g++)d.push({type:"unchanged",text:r[g]});return d}function bm(e){let t=q(e.input?.oldString),r=q(e.input?.newString),n=t!==void 0&&r!==void 0?hm(t,r):void 0;return{kind:"file-edit",path:rc(e),diff:n}}var xl=/^Found\s+(\d+)\s+match/i,xm=/^(\/[^:]+?):\s*/,bl=/Line\s+(\d+):/g;function km(e){let t=e.trim(),r=t.match(xl),n=r?t.slice(r[0].length).trim():t;if(!n)return[];let s=[];for(let l of n.split(/\n\n+/)){let u=l.trim();if(!u)continue;let d=u.match(xm);if(!d)continue;let g=d[1],h=u.slice(d[0].length),m=[],x;for(bl.lastIndex=0;(x=bl.exec(h))!==null;)m.push({line:Number(x[1]),contentStart:x.index+x[0].length,headerStart:x.index});for(let k=0;k<m.length;k++){let _=k+1<m.length?m[k+1].headerStart:h.length,c=h.slice(m[k].contentStart,_).trim();s.push({path:g,line:m[k].line,content:c.endsWith(";")?c.slice(0,-1):c})}}return s}function Pm(e){return e.trim().split(`
64
- `).map(t=>t.trim()).filter(t=>t.startsWith("/")||t.startsWith("./")||t.startsWith("~")).map(t=>({path:t}))}function _m(e){let t=q(e.input?.pattern,e.input?.query)??"";if(e.status==="error"||!e.output)return{kind:"search",pattern:t};let r=xl.test(e.output.trim())?km(e.output):Pm(e.output);return{kind:"search",pattern:t,matches:r.length>0?r.slice(0,200):void 0}}function wm(e){let t=q(e.input?.description,e.input?.title,e.input?.prompt)??e.title,r=q(e.input?.subagent_type,e.input?.agent);return{kind:"task",description:t,agent:r}}function tc(e){let t=_e(e)??{};return{content:q(t.content)??"",status:q(t.status)??"pending",priority:q(t.priority)}}function Sm(e){let t=e.input?.todos;if(Array.isArray(t))return{kind:"todo",items:t.map(tc)};if(Array.isArray(e.outputParsed))return{kind:"todo",items:e.outputParsed.map(tc)};let r=_e(e.outputParsed);return r&&Array.isArray(r.todos)?{kind:"todo",items:r.todos.map(tc)}:{kind:"todo",items:[]}}function Rm(e){return{kind:"question",questions:(Array.isArray(e.input?.questions)?e.input.questions:[]).map(n=>{let s=_e(n)??{},u=(Array.isArray(s.options)?s.options:[]).flatMap(d=>{let g=_e(d),h=g&&q(g.label);return h?[{label:h,description:g?q(g.description):void 0}]:[]});return{question:q(s.question)??"",header:q(s.header),options:u}})}}function vm(e){let r=e.input&&Object.keys(e.input).length>0?hl(e.input):void 0,n;return e.outputParsed!==void 0?n=typeof e.outputParsed=="string"?Ke(e.outputParsed):hl(e.outputParsed):e.outputText!==void 0?n=Ke(e.outputText):n=e.error,{kind:"generic",label:e.title,inputPretty:r,outputPretty:n}}function kl(e){switch(Be(e.name)){case"web_search":case"websearch":case"image_search":return om(e);case"bash":return gm(e);case"read":return mm(e);case"write":return fm(e);case"edit":case"morph_edit":return bm(e);case"grep":case"glob":return _m(e);case"task":return wm(e);case"todowrite":return Sm(e);case"question":case"ask":return Rm(e);default:return vm(e)}}var It=[{id:"claude-opus-4.8",name:"Claude Opus 4.8",upstreamModelId:"us.anthropic.claude-opus-4-8",transport:"bedrock",pricingRef:"anthropic/claude-opus-4.8",tier:"flagship",vision:!0,limit:{context:1e6,output:64e3}},{id:"claude-sonnet-4.6",name:"Claude Sonnet 4.6",upstreamModelId:"us.anthropic.claude-sonnet-4-6",transport:"bedrock",pricingRef:"anthropic/claude-sonnet-4.6",tier:"balanced",vision:!0,limit:{context:1e6,output:64e3}},{id:"glm-5.2",name:"GLM 5.2",upstreamModelId:"z-ai/glm-5.2",transport:"openrouter",pricingRef:"z-ai/glm-5.2",tier:"balanced",vision:!1,limit:{context:1e6,output:131072},openrouterProvider:{order:["z-ai"],allow_fallbacks:!0}},{id:"qwen3.7-max",name:"Qwen3.7 Max",upstreamModelId:"qwen/qwen3.7-max",transport:"openrouter",pricingRef:"qwen/qwen3.7-max",tier:"balanced",vision:!1,limit:{context:1048576,output:64e3}},{id:"deepseek-v4-pro",name:"DeepSeek V4 Pro",upstreamModelId:"deepseek/deepseek-v4-pro",transport:"openrouter",pricingRef:"deepseek/deepseek-v4-pro",tier:"balanced",vision:!1,limit:{context:1048576,output:64e3}},{id:"deepseek-v4-flash",name:"DeepSeek V4 Flash",upstreamModelId:"deepseek/deepseek-v4-flash",transport:"openrouter",pricingRef:"deepseek/deepseek-v4-flash",tier:"balanced",vision:!1,limit:{context:1048576,output:64e3}}],Kx=new Map(It.map(e=>[e.id,e]));var Nx=It.map(e=>e.id),Hx=(It.find(e=>e.tier==="flagship")??It[0]).id;var Pl=!1;function jt(e){try{return typeof process<"u"?process.env?.[e]:void 0}catch{return}}function Cm(e,t){if(e==null)return t;let r=e.trim().toLowerCase();return["1","true","yes","y","on"].includes(r)?!0:["0","false","no","n","off"].includes(r)?!1:t}function Tm(e){if(e==null)return;let t=e.trim().toLowerCase();if(["1","true","yes","y","on"].includes(t))return!0;if(["0","false","no","n","off"].includes(t))return!1}function At(e,t,r){return e!==void 0?e:Cm(jt(t),r)}var Im={get disableMobileAdvertising(){return At(T().featureFlags?.disableMobileAdvertising,"NEXT_PUBLIC_DISABLE_MOBILE_ADVERTISING",!1)},get enableDinoGame(){return At(T().featureFlags?.enableDinoGame,"NEXT_PUBLIC_ENABLE_DINO_GAME",!1)},get enableProjects(){return At(T().featureFlags?.enableProjects,"NEXT_PUBLIC_ENABLE_PROJECTS",!1)},get enableAutoModel(){return At(T().featureFlags?.enableAutoModel,"NEXT_PUBLIC_ENABLE_AUTO_MODEL",Pl)}};var Ne="kortix-active-instance",_l=["/dashboard","/agents","/p","/workspace","/settings","/browser","/desktop","/services","/sessions","/terminal","/files","/scheduled-tasks","/commands","/tools","/configuration","/changelog","/legacy","/credits-explained"];function wl(e){return _l.some(t=>e===t||e.startsWith(`${t}/`))}function we(e){let t=e.match(/^\/instances\/([^/]+)(?:\/(.*))?$/);if(!t)return null;let r=decodeURIComponent(t[1]),n=t[2]??"";return{instanceId:r,innerPath:n?`/${n}`:""}}function jm(e){let t=we(e);return!!t&&t.innerPath===""}function Am(e){let t=we(e);return!t||!t.innerPath?e:t.innerPath}function Sl(e,t){if(!e)return t;if(t.startsWith("/")||(t=`/${t}`),t.startsWith("/instances/")){let r=we(t);return r?`/instances/${encodeURIComponent(e)}${r.innerPath}`:t}return wl(t)?`/instances/${encodeURIComponent(e)}${t}`:t}function Rl(e){return e?we(e)?.instanceId??null:null}function Em(){return typeof window>"u"?null:Rl(window.location.pathname)||vl()}function vl(){if(typeof document>"u")return null;let e=document.cookie.match(new RegExp(`(?:^|; )${Ne}=([^;]+)`));return e?decodeURIComponent(e[1]):null}function $m(e){if(typeof document>"u")return;let t=r=>{document.cookie=r};if(typeof window<"u"&&window.location.pathname.startsWith("/projects")){t(`${Ne}=; Max-Age=0; Path=/; SameSite=Lax`);return}if(!e){t(`${Ne}=; Max-Age=0; Path=/; SameSite=Lax`);return}t(`${Ne}=${encodeURIComponent(e)}; Path=/; SameSite=Lax`)}function qm(e,t){return t?Sl(t,e):e}function Dm(e){let t=we(e);return t?t.innerPath||"/dashboard":e}function Cl(e){if(e instanceof Error)return e.message;if(typeof e=="string")return e;if(e&&typeof e=="object")try{return JSON.stringify(e)}catch{return String(e)}return String(e??"")}function Tl(e){let t=Cl(e).trim();if(!t)return null;let r=[t,t.replace(/^Failed to perform action:\s*/i,"").trim()],n=t.indexOf("{");n>=0&&r.push(t.slice(n));for(let s of r)if(s)try{return JSON.parse(s)}catch{}return null}function nc(e){let t=Tl(e);if(!t||typeof t!="object")return null;let r=t;return r.name==="ConfigInvalidError"?r:null}function Mm(e){return nc(e)!==null}function Um(e){let t=nc(e);if(t){let s=(t.data?.path??"OpenCode config").replace(/^\/workspace\//,""),l=t.data?.issues?.[0]?.message,u=t.data?.issues?.[0]?.path?.join("."),d=u?.startsWith("permission")?"Remove the invalid permission frontmatter entry or replace it with valid OpenCode permission config.":"Fix the invalid config entry, then restart this session.";return{title:"OpenCode config is invalid",message:`${s} is preventing OpenCode from loading. ${d}`,detail:l?`${u?`${u}: `:""}${l}`:void 0}}return{title:"OpenCode failed to load",message:Cl(e)||"The sandbox is running, but OpenCode returned an error."}}function L(){let e=jt("BACKEND_URL")||T().backendUrl;return e||"http://localhost:8008/v1"}function He(e){if(typeof e=="string"){let t=e.trim();return t.length>0?t:void 0}if(Array.isArray(e)){for(let t of e){let r=He(t);if(r)return r}return}if(e&&typeof e=="object"){let t=e;return He(t.sandboxId??t.id??t.slug??Object.values(t)[0])}}var Il=["http://localhost:8008/v1","http://127.0.0.1:8008/v1"];function jl(e){let t=e.length;for(;t>0&&e.charCodeAt(t-1)===47;)t--;return`${e.slice(0,t)}/platform/local-bridge/status`}function Om(e){return e==="running"||e==="active"?"active":e==="queued"||e==="branching"||e==="provisioning"?"provisioning":e==="failed"||e==="error"?"error":e==="stopped"||e==="completed"||e==="archived"?"stopped":e||"unknown"}function sc(e,t,r){let n=r?.external_id||t.sandbox_url?.match(/\/p\/([^/]+)\//)?.[1]||t.sandbox_id;return{sandbox_id:r?.sandbox_id||t.sandbox_id||t.session_id,external_id:n,name:t.name||`${e.name} session`,provider:r?.provider||t.sandbox_provider||"daytona",base_url:r?.base_url||t.sandbox_url||(r?.external_id?`${L()}/p/${r.external_id}/${V.KORTIX_MASTER}`:""),status:Om(r?.status||t.status),metadata:{...t.metadata??{},project_id:e.project_id,session_id:t.session_id,project_name:e.name,runtime_status:r?.status,error:t.error},created_at:r?.created_at||t.created_at,updated_at:r?.updated_at||t.updated_at}}async function ic(){let e=await ie(),t=[];for(let r of e){let n=await be(r.project_id).catch(()=>[]);for(let s of n)t.push({project:r,session:s,runtime:null,sandbox:sc(r,s,null)})}return t.sort((r,n)=>{let s={active:0,provisioning:1,stopped:2,error:3},l=(s[r.sandbox.status]??99)-(s[n.sandbox.status]??99);return l!==0?l:Date.parse(n.sandbox.updated_at)-Date.parse(r.sandbox.updated_at)})}async function ae(e){let t=await ic();return e?t.find(r=>r.sandbox.sandbox_id===e||r.sandbox.external_id===e||r.session.session_id===e||r.runtime?.external_id===e)??null:t[0]??null}async function Et(e,t={}){let r={"Content-Type":"application/json",...t.headers},n=t.signal??AbortSignal.timeout(3e4),s=await C(`${L()}${e}`,{...t,headers:r,signal:n}),l=await s.text().catch(()=>{}),u;if(l)try{u=JSON.parse(l)}catch{}if(!s.ok){let d=u?.error||u?.message||u?.detail||l||`Platform API error ${s.status}`,g=new v(d,{status:s.status,code:u?.code||u?.error_code||String(s.status),details:u??(l?{rawText:l}:void 0),response:s,endpoint:e});throw s.status===402&&(g=me(Object.assign(g,{response:s,status:s.status,data:u}))),g}return u}function oc(e){if(!e.external_id){if(e.base_url)return e.base_url;throw new Error(`Cannot build sandbox URL: missing external_id for ${e.provider} sandbox "${e.sandbox_id}"`)}return`${L()}/p/${e.external_id}/${V.KORTIX_MASTER}`}function Lm(e,t){return e.external_id?`${L()}/p/${e.external_id}/${t}`:null}async function Fm(){return{providers:["daytona"],default:"daytona"}}async function Al(e){let t=await ae();if(t)return{sandbox:t.sandbox,created:!1};let n=(await ie())[0];if(!n)throw new Error("Create a project before starting a sandbox");let s=await xe(n.project_id,{...e?.provider?{agent_name:e.provider}:{}}),l=(await ke(n.project_id,s.session_id))?.sandbox??null;return{sandbox:sc(n,s,l),created:!0}}async function Bm(){return(await ae().catch(()=>null))?.sandbox??null}async function Gm(e){return{sandbox:(await Al(e)).sandbox}}async function Km(e){let t=He(e);return t?(await ae(t).catch(()=>null))?.sandbox??null:null}async function Nm(e,t){throw await ae(e)?new Error("Renaming project-session sandboxes is not exposed by the current API"):new Error("Project session sandbox not found")}async function Hm(e){let t=He(e);return(await ic().catch(()=>[])).map(n=>n.sandbox).filter(n=>!t||n.sandbox_id===t||n.external_id===t)}async function Wm(){if(typeof window>"u")return null;let e=L(),t=Array.from(new Set([e,...Il]));for(let r of t)try{let n=await fetch(jl(r),{method:"GET",signal:AbortSignal.timeout(1500),headers:{Accept:"application/json"}});if(!n.ok)continue;let s=await n.json();if(!s.success||s.status!=="ready"||!s.data?.sandbox_id)continue;return s.data}catch{continue}return null}async function Vm(e){if(!e)throw new Error("No sandbox selected for workload restart");let t=await ae(e);if(!t)throw new Error("Project session sandbox not found");await Me(t.project.project_id,t.session.session_id)}async function zm(e){if(!e)throw new Error("No sandbox selected to stop");let t=await ae(e);if(!t)throw new Error("Project session sandbox not found");await Ue(t.project.project_id,t.session.session_id)}async function Jm(e){throw new Error("Cancellation is not exposed for project-session sandboxes")}async function Xm(e){throw new Error("Reactivation is not exposed for project-session sandboxes")}async function Qm(e){throw new Error("Sandbox members moved to project access; use project members for project-session sandboxes")}async function Ym(e,t,r="member"){throw new Error("Sandbox members moved to project access; invite the user to the project instead")}async function Zm(e,t){throw new Error("Sandbox members moved to project access; update project access instead")}async function ef(e,t,r){throw new Error("Sandbox members moved to project access; update project access instead")}async function tf(e,t,r){throw new Error("Sandbox member spend caps are not exposed for project-session sandboxes")}async function rf(e){throw new Error("Sandbox scopes moved to project access for project-session sandboxes")}async function nf(e,t){throw new Error("Sandbox scopes moved to project access for project-session sandboxes")}async function sf(e,t,r,n){throw new Error("Sandbox scopes moved to project access for project-session sandboxes")}async function ac(e,t,r){let n=oc(e),s=await C(`${re(n)}${t}`,{signal:AbortSignal.timeout(8e3),headers:{"Content-Type":"application/json"},...r});if(!s.ok){let l=await s.text().catch(()=>"");throw new Error(l||`Request failed (${s.status})`)}return await s.json()}async function of(e,t){return ac(e,`/kortix/projects/${encodeURIComponent(t)}/members`,{method:"GET"})}async function af(e,t,r,n="member"){await ac(e,`/kortix/projects/${encodeURIComponent(t)}/members`,{method:"POST",body:JSON.stringify({user_id:r,role:n})})}async function cf(e,t,r){await ac(e,`/kortix/projects/${encodeURIComponent(t)}/members/${encodeURIComponent(r)}`,{method:"DELETE"})}async function lf(e,t){throw new Error("Sandbox invites moved to project access for project-session sandboxes")}async function uf(e){let t=await Et(`/platform/invites/${encodeURIComponent(e)}`,{method:"GET"});if(!t.success||!t.data)throw new Error(t.error||"Invite not found");return t.data}async function pf(e){let t=await Et(`/platform/invites/${encodeURIComponent(e)}/accept`,{method:"POST"});if(!t.success||!t.data)throw new Error(t.error||"Failed to accept invite");return t.data}async function df(e){let t=await Et(`/platform/invites/${encodeURIComponent(e)}/decline`,{method:"POST"});if(!t.success)throw new Error(t.error||"Failed to decline invite")}async function gf(e){throw new Error("Backups are not exposed for project-session sandboxes")}async function mf(e,t){throw new Error("Backups are not exposed for project-session sandboxes")}async function ff(e,t){throw new Error("Backups are not exposed for project-session sandboxes")}async function yf(e,t){throw new Error("Backups are not exposed for project-session sandboxes")}async function hf(e){throw new Error("SSH setup is not exposed for project-session sandboxes")}async function bf(e){throw new Error("SSH connection details are not exposed for project-session sandboxes")}var El=["pulling","patching","stopping","removing","recreating","restarting","verifying","starting","health_check"];function xf(e){return El.includes(e)}async function kf(e){return{phase:"idle",progress:0,message:"Sandbox image updates are managed by project-session provisioning.",targetVersion:null,previousVersion:null,currentVersion:e?.version??null,error:null,startedAt:null,updatedAt:null}}async function Pf(e){let t=e?`?channel=${e}`:"",r=await fetch(`${L()}/platform/sandbox/version/latest${t}`,{headers:{Accept:"application/json"}});if(!r.ok)throw new Error(`Version check failed: ${r.status}`);let n=await r.json();try{let s=await $l(e||"stable");n.changelog=s.find(l=>l.version===n.version)??s[0]??null}catch{n.changelog=null}return n}async function $l(e){let t=e?`?channel=${e}`:"",r=await fetch(`${L()}/platform/sandbox/version/changelog${t}`,{headers:{Accept:"application/json"}});if(!r.ok)throw new Error(`Changelog fetch failed: ${r.status}`);return(await r.json()).changelog}async function _f(){let e=await fetch(`${L()}/platform/sandbox/version/all`,{headers:{Accept:"application/json"}});if(!e.ok)throw new Error(`All versions fetch failed: ${e.status}`);return e.json()}async function wf(e,t){throw new Error("Sandbox image updates are managed by project-session provisioning")}async function Sf(e){}async function Rf(e){}async function vf(e){let t=e?`?location=${e}`:"",r=await o.get(`/platform/sandbox/justavps/server-types${t}`);if(r.error){if(r.error.status===404&&/justavps provider is not enabled/i.test(r.error.message||""))return{serverTypes:[],location:e||"hel1"};throw r.error}return r.data}async function Cf(e){let t=await o.post("/platform/sandbox",e,{timeout:18e4});if(t.error)throw t.error;return t.data}async function Tf(e){let t=await o.delete(`/platform/sandbox?sandbox_id=${e}`);if(t.error)throw t.error;return t.data}async function If(e,t){await o.post("/platform/sandbox/mark-error",{sandbox_id:e,error_message:t},{showErrors:!1,timeout:1e4})}async function jf(){let e=await o.post("/platform/sandbox/claim-computer",{},{timeout:6e4});if(e.error)throw e.error;return e.data}async function Af(e){let t=await o.get(`/platform/sandbox/${e}/status`,{showErrors:!1,timeout:1e4});return t.success?t.data??null:null}function Ef(e,t){return`${L()}/platform/sandbox/${e}/provision-stream?token=${encodeURIComponent(t)}`}function ql(e){try{let t=new URL(e);if(/^\/proxy\/\d+(?:\/|$)/.test(t.pathname))return`${t.origin}/v1/p/auth`;let r=t.pathname.indexOf("/p/");return r!==-1?`${t.origin}${t.pathname.slice(0,r)}/p/auth`:`${t.origin}/v1/p/auth`}catch{return null}}function $f(e,t){try{let r=new URL(e),n=r.pathname;if(!(/^\/v1\/p\/[^/]+\/\d+(?:\/|$)/.test(n)||/^\/proxy\/\d+(?:\/|$)/.test(n)))return!1;let l=new Set;if(t)try{l.add(new URL(t).origin)}catch{}return typeof window<"u"&&l.add(window.location.origin),l.size===0||l.has(r.origin)}catch{return!1}}function qf(e,t){return $f(e,t)?(t?ql(t):null)??ql(e):null}function Df(e){try{return/^p\d+-[^.]+\./.test(new URL(e).hostname)}catch{return!1}}function Mf(e,t){try{let r=new URL(e);return r.searchParams.set("token",t),r.toString()}catch{return e}}return Bl(Uf);})();
63
+ `),s=0;for(;s<r.length&&s<n.length&&r[s]===n[s];)s++;let c=r.length,u=n.length;for(;c>s&&u>s&&r[c-1]===n[u-1];)c--,u--;let d=[];for(let g=0;g<s;g++)d.push({type:"unchanged",text:r[g]});for(let g=s;g<c;g++)d.push({type:"removed",text:r[g]});for(let g=s;g<u;g++)d.push({type:"added",text:n[g]});for(let g=c;g<r.length;g++)d.push({type:"unchanged",text:r[g]});return d}function lm(e){let t=q(e.input?.oldString),r=q(e.input?.newString),n=t!==void 0&&r!==void 0?cm(t,r):void 0;return{kind:"file-edit",path:Ga(e),diff:n}}var il=/^Found\s+(\d+)\s+match/i,um=/^(\/[^:]+?):\s*/,sl=/Line\s+(\d+):/g;function pm(e){let t=e.trim(),r=t.match(il),n=r?t.slice(r[0].length).trim():t;if(!n)return[];let s=[];for(let c of n.split(/\n\n+/)){let u=c.trim();if(!u)continue;let d=u.match(um);if(!d)continue;let g=d[1],h=u.slice(d[0].length),m=[],x;for(sl.lastIndex=0;(x=sl.exec(h))!==null;)m.push({line:Number(x[1]),contentStart:x.index+x[0].length,headerStart:x.index});for(let w=0;w<m.length;w++){let k=w+1<m.length?m[w+1].headerStart:h.length,l=h.slice(m[w].contentStart,k).trim();s.push({path:g,line:m[w].line,content:l.endsWith(";")?l.slice(0,-1):l})}}return s}function dm(e){return e.trim().split(`
64
+ `).map(t=>t.trim()).filter(t=>t.startsWith("/")||t.startsWith("./")||t.startsWith("~")).map(t=>({path:t}))}function gm(e){let t=q(e.input?.pattern,e.input?.query)??"";if(e.status==="error"||!e.output)return{kind:"search",pattern:t};let r=il.test(e.output.trim())?pm(e.output):dm(e.output);return{kind:"search",pattern:t,matches:r.length>0?r.slice(0,200):void 0}}function mm(e){let t=q(e.input?.description,e.input?.title,e.input?.prompt)??e.title,r=q(e.input?.subagent_type,e.input?.agent);return{kind:"task",description:t,agent:r}}function Fa(e){let t=Pe(e)??{};return{content:q(t.content)??"",status:q(t.status)??"pending",priority:q(t.priority)}}function fm(e){let t=e.input?.todos;if(Array.isArray(t))return{kind:"todo",items:t.map(Fa)};if(Array.isArray(e.outputParsed))return{kind:"todo",items:e.outputParsed.map(Fa)};let r=Pe(e.outputParsed);return r&&Array.isArray(r.todos)?{kind:"todo",items:r.todos.map(Fa)}:{kind:"todo",items:[]}}function ym(e){return{kind:"question",questions:(Array.isArray(e.input?.questions)?e.input.questions:[]).map(n=>{let s=Pe(n)??{},u=(Array.isArray(s.options)?s.options:[]).flatMap(d=>{let g=Pe(d),h=g&&q(g.label);return h?[{label:h,description:g?q(g.description):void 0}]:[]});return{question:q(s.question)??"",header:q(s.header),options:u}})}}function hm(e){let r=e.input&&Object.keys(e.input).length>0?nl(e.input):void 0,n;return e.outputParsed!==void 0?n=typeof e.outputParsed=="string"?Be(e.outputParsed):nl(e.outputParsed):e.outputText!==void 0?n=Be(e.outputText):n=e.error,{kind:"generic",label:e.title,inputPretty:r,outputPretty:n}}function ol(e){switch(Fe(e.name)){case"web_search":case"websearch":case"image_search":return Qg(e);case"bash":return sm(e);case"read":return im(e);case"write":return om(e);case"edit":case"morph_edit":return lm(e);case"grep":case"glob":return gm(e);case"task":return mm(e);case"todowrite":return fm(e);case"question":case"ask":return ym(e);default:return hm(e)}}var Tt=[{id:"claude-opus-4.8",name:"Claude Opus 4.8",upstreamModelId:"us.anthropic.claude-opus-4-8",transport:"bedrock",pricingRef:"anthropic/claude-opus-4.8",tier:"flagship",vision:!0,limit:{context:1e6,output:64e3}},{id:"claude-sonnet-4.6",name:"Claude Sonnet 4.6",upstreamModelId:"us.anthropic.claude-sonnet-4-6",transport:"bedrock",pricingRef:"anthropic/claude-sonnet-4.6",tier:"balanced",vision:!0,limit:{context:1e6,output:64e3}},{id:"glm-5.2",name:"GLM 5.2",upstreamModelId:"z-ai/glm-5.2",transport:"openrouter",pricingRef:"z-ai/glm-5.2",tier:"balanced",vision:!1,limit:{context:1e6,output:131072},openrouterProvider:{order:["z-ai"],allow_fallbacks:!0}},{id:"qwen3.7-max",name:"Qwen3.7 Max",upstreamModelId:"qwen/qwen3.7-max",transport:"openrouter",pricingRef:"qwen/qwen3.7-max",tier:"balanced",vision:!1,limit:{context:1048576,output:64e3}},{id:"deepseek-v4-pro",name:"DeepSeek V4 Pro",upstreamModelId:"deepseek/deepseek-v4-pro",transport:"openrouter",pricingRef:"deepseek/deepseek-v4-pro",tier:"balanced",vision:!1,limit:{context:1048576,output:64e3}},{id:"deepseek-v4-flash",name:"DeepSeek V4 Flash",upstreamModelId:"deepseek/deepseek-v4-flash",transport:"openrouter",pricingRef:"deepseek/deepseek-v4-flash",tier:"balanced",vision:!1,limit:{context:1048576,output:64e3}}],$x=new Map(Tt.map(e=>[e.id,e]));var qx=Tt.map(e=>e.id),Dx=(Tt.find(e=>e.tier==="flagship")??Tt[0]).id;var al=!1;function It(e){try{return typeof process<"u"?process.env?.[e]:void 0}catch{return}}function bm(e,t){if(e==null)return t;let r=e.trim().toLowerCase();return["1","true","yes","y","on"].includes(r)?!0:["0","false","no","n","off"].includes(r)?!1:t}function xm(e){if(e==null)return;let t=e.trim().toLowerCase();if(["1","true","yes","y","on"].includes(t))return!0;if(["0","false","no","n","off"].includes(t))return!1}function jt(e,t,r){return e!==void 0?e:bm(It(t),r)}var km={get disableMobileAdvertising(){return jt(T().featureFlags?.disableMobileAdvertising,"NEXT_PUBLIC_DISABLE_MOBILE_ADVERTISING",!1)},get enableDinoGame(){return jt(T().featureFlags?.enableDinoGame,"NEXT_PUBLIC_ENABLE_DINO_GAME",!1)},get enableProjects(){return jt(T().featureFlags?.enableProjects,"NEXT_PUBLIC_ENABLE_PROJECTS",!1)},get enableAutoModel(){return jt(T().featureFlags?.enableAutoModel,"NEXT_PUBLIC_ENABLE_AUTO_MODEL",al)}};var Ke="kortix-active-instance",cl=["/dashboard","/agents","/p","/workspace","/settings","/browser","/desktop","/services","/sessions","/terminal","/files","/scheduled-tasks","/commands","/tools","/configuration","/changelog","/legacy","/credits-explained"];function ll(e){return cl.some(t=>e===t||e.startsWith(`${t}/`))}function we(e){let t=e.match(/^\/instances\/([^/]+)(?:\/(.*))?$/);if(!t)return null;let r=decodeURIComponent(t[1]),n=t[2]??"";return{instanceId:r,innerPath:n?`/${n}`:""}}function Pm(e){let t=we(e);return!!t&&t.innerPath===""}function wm(e){let t=we(e);return!t||!t.innerPath?e:t.innerPath}function ul(e,t){if(!e)return t;if(t.startsWith("/")||(t=`/${t}`),t.startsWith("/instances/")){let r=we(t);return r?`/instances/${encodeURIComponent(e)}${r.innerPath}`:t}return ll(t)?`/instances/${encodeURIComponent(e)}${t}`:t}function pl(e){return e?we(e)?.instanceId??null:null}function _m(){return typeof window>"u"?null:pl(window.location.pathname)||dl()}function dl(){if(typeof document>"u")return null;let e=document.cookie.match(new RegExp(`(?:^|; )${Ke}=([^;]+)`));return e?decodeURIComponent(e[1]):null}function Sm(e){if(typeof document>"u")return;let t=r=>{document.cookie=r};if(typeof window<"u"&&window.location.pathname.startsWith("/projects")){t(`${Ke}=; Max-Age=0; Path=/; SameSite=Lax`);return}if(!e){t(`${Ke}=; Max-Age=0; Path=/; SameSite=Lax`);return}t(`${Ke}=${encodeURIComponent(e)}; Path=/; SameSite=Lax`)}function vm(e,t){return t?ul(t,e):e}function Cm(e){let t=we(e);return t?t.innerPath||"/dashboard":e}function gl(e){if(e instanceof Error)return e.message;if(typeof e=="string")return e;if(e&&typeof e=="object")try{return JSON.stringify(e)}catch{return String(e)}return String(e??"")}function ml(e){let t=gl(e).trim();if(!t)return null;let r=[t,t.replace(/^Failed to perform action:\s*/i,"").trim()],n=t.indexOf("{");n>=0&&r.push(t.slice(n));for(let s of r)if(s)try{return JSON.parse(s)}catch{}return null}function Ba(e){let t=ml(e);if(!t||typeof t!="object")return null;let r=t;return r.name==="ConfigInvalidError"?r:null}function Rm(e){return Ba(e)!==null}function Tm(e){let t=Ba(e);if(t){let s=(t.data?.path??"OpenCode config").replace(/^\/workspace\//,""),c=t.data?.issues?.[0]?.message,u=t.data?.issues?.[0]?.path?.join("."),d=u?.startsWith("permission")?"Remove the invalid permission frontmatter entry or replace it with valid OpenCode permission config.":"Fix the invalid config entry, then restart this session.";return{title:"OpenCode config is invalid",message:`${s} is preventing OpenCode from loading. ${d}`,detail:c?`${u?`${u}: `:""}${c}`:void 0}}return{title:"OpenCode failed to load",message:gl(e)||"The sandbox is running, but OpenCode returned an error."}}function L(){let e=It("BACKEND_URL")||T().backendUrl;return e||"http://localhost:8008/v1"}function Ne(e){if(typeof e=="string"){let t=e.trim();return t.length>0?t:void 0}if(Array.isArray(e)){for(let t of e){let r=Ne(t);if(r)return r}return}if(e&&typeof e=="object"){let t=e;return Ne(t.sandboxId??t.id??t.slug??Object.values(t)[0])}}var fl=["http://localhost:8008/v1","http://127.0.0.1:8008/v1"];function yl(e){let t=e.length;for(;t>0&&e.charCodeAt(t-1)===47;)t--;return`${e.slice(0,t)}/platform/local-bridge/status`}function Im(e){return e==="running"||e==="active"?"active":e==="queued"||e==="branching"||e==="provisioning"?"provisioning":e==="failed"||e==="error"?"error":e==="stopped"||e==="completed"||e==="archived"?"stopped":e||"unknown"}function Ka(e,t,r){let n=r?.external_id||t.sandbox_url?.match(/\/p\/([^/]+)\//)?.[1]||t.sandbox_id;return{sandbox_id:r?.sandbox_id||t.sandbox_id||t.session_id,external_id:n,name:t.name||`${e.name} session`,provider:r?.provider||t.sandbox_provider||"daytona",base_url:r?.base_url||t.sandbox_url||(r?.external_id?`${L()}/p/${r.external_id}/${V.KORTIX_MASTER}`:""),status:Im(r?.status||t.status),metadata:{...t.metadata??{},project_id:e.project_id,session_id:t.session_id,project_name:e.name,runtime_status:r?.status,error:t.error},created_at:r?.created_at||t.created_at,updated_at:r?.updated_at||t.updated_at}}async function Na(){let e=await ie(),t=[];for(let r of e){let n=await he(r.project_id).catch(()=>[]);for(let s of n)t.push({project:r,session:s,runtime:null,sandbox:Ka(r,s,null)})}return t.sort((r,n)=>{let s={active:0,provisioning:1,stopped:2,error:3},c=(s[r.sandbox.status]??99)-(s[n.sandbox.status]??99);return c!==0?c:Date.parse(n.sandbox.updated_at)-Date.parse(r.sandbox.updated_at)})}async function oe(e){let t=await Na();return e?t.find(r=>r.sandbox.sandbox_id===e||r.sandbox.external_id===e||r.session.session_id===e||r.runtime?.external_id===e)??null:t[0]??null}async function At(e,t={}){let r={"Content-Type":"application/json",...t.headers},n=t.signal??AbortSignal.timeout(3e4),s=await R(`${L()}${e}`,{...t,headers:r,signal:n}),c=await s.text().catch(()=>{}),u;if(c)try{u=JSON.parse(c)}catch{}if(!s.ok){let d=u?.error||u?.message||u?.detail||c||`Platform API error ${s.status}`,g=new C(d,{status:s.status,code:u?.code||u?.error_code||String(s.status),details:u??(c?{rawText:c}:void 0),response:s,endpoint:e});throw s.status===402&&(g=ge(Object.assign(g,{response:s,status:s.status,data:u}))),g}return u}function Ha(e){if(!e.external_id){if(e.base_url)return e.base_url;throw new Error(`Cannot build sandbox URL: missing external_id for ${e.provider} sandbox "${e.sandbox_id}"`)}return`${L()}/p/${e.external_id}/${V.KORTIX_MASTER}`}function jm(e,t){return e.external_id?`${L()}/p/${e.external_id}/${t}`:null}async function Am(){let e=await o.get("/setup/sandbox-providers");if(e.error)throw e.error;return e.data}async function hl(e){let t=await oe();if(t)return{sandbox:t.sandbox,created:!1};let n=(await ie())[0];if(!n)throw new Error("Create a project before starting a sandbox");let s=await be(n.project_id,{...e?.provider?{provider:e.provider}:{}}),c=(await xe(n.project_id,s.session_id))?.sandbox??null;return{sandbox:Ka(n,s,c),created:!0}}async function Em(){return(await oe().catch(()=>null))?.sandbox??null}async function $m(e){return{sandbox:(await hl(e)).sandbox}}async function qm(e){let t=Ne(e);return t?(await oe(t).catch(()=>null))?.sandbox??null:null}async function Dm(e,t){throw await oe(e)?new Error("Renaming project-session sandboxes is not exposed by the current API"):new Error("Project session sandbox not found")}async function Mm(e){let t=Ne(e);return(await Na().catch(()=>[])).map(n=>n.sandbox).filter(n=>!t||n.sandbox_id===t||n.external_id===t)}async function Um(){if(typeof window>"u")return null;let e=L(),t=Array.from(new Set([e,...fl]));for(let r of t)try{let n=await fetch(yl(r),{method:"GET",signal:AbortSignal.timeout(1500),headers:{Accept:"application/json"}});if(!n.ok)continue;let s=await n.json();if(!s.success||s.status!=="ready"||!s.data?.sandbox_id)continue;return s.data}catch{continue}return null}async function Om(e){if(!e)throw new Error("No sandbox selected for workload restart");let t=await oe(e);if(!t)throw new Error("Project session sandbox not found");await De(t.project.project_id,t.session.session_id)}async function Lm(e){if(!e)throw new Error("No sandbox selected to stop");let t=await oe(e);if(!t)throw new Error("Project session sandbox not found");await Me(t.project.project_id,t.session.session_id)}async function Fm(e){throw new Error("Cancellation is not exposed for project-session sandboxes")}async function Gm(e){throw new Error("Reactivation is not exposed for project-session sandboxes")}async function Bm(e){throw new Error("Sandbox members moved to project access; use project members for project-session sandboxes")}async function Km(e,t,r="member"){throw new Error("Sandbox members moved to project access; invite the user to the project instead")}async function Nm(e,t){throw new Error("Sandbox members moved to project access; update project access instead")}async function Hm(e,t,r){throw new Error("Sandbox members moved to project access; update project access instead")}async function Wm(e,t,r){throw new Error("Sandbox member spend caps are not exposed for project-session sandboxes")}async function Vm(e){throw new Error("Sandbox scopes moved to project access for project-session sandboxes")}async function zm(e,t){throw new Error("Sandbox scopes moved to project access for project-session sandboxes")}async function Jm(e,t,r,n){throw new Error("Sandbox scopes moved to project access for project-session sandboxes")}async function Wa(e,t,r){let n=Ha(e),s=await R(`${re(n)}${t}`,{signal:AbortSignal.timeout(8e3),headers:{"Content-Type":"application/json"},...r});if(!s.ok){let c=await s.text().catch(()=>"");throw new Error(c||`Request failed (${s.status})`)}return await s.json()}async function Xm(e,t){return Wa(e,`/kortix/projects/${encodeURIComponent(t)}/members`,{method:"GET"})}async function Qm(e,t,r,n="member"){await Wa(e,`/kortix/projects/${encodeURIComponent(t)}/members`,{method:"POST",body:JSON.stringify({user_id:r,role:n})})}async function Ym(e,t,r){await Wa(e,`/kortix/projects/${encodeURIComponent(t)}/members/${encodeURIComponent(r)}`,{method:"DELETE"})}async function Zm(e,t){throw new Error("Sandbox invites moved to project access for project-session sandboxes")}async function ef(e){let t=await At(`/platform/invites/${encodeURIComponent(e)}`,{method:"GET"});if(!t.success||!t.data)throw new Error(t.error||"Invite not found");return t.data}async function tf(e){let t=await At(`/platform/invites/${encodeURIComponent(e)}/accept`,{method:"POST"});if(!t.success||!t.data)throw new Error(t.error||"Failed to accept invite");return t.data}async function rf(e){let t=await At(`/platform/invites/${encodeURIComponent(e)}/decline`,{method:"POST"});if(!t.success)throw new Error(t.error||"Failed to decline invite")}async function nf(e){throw new Error("Backups are not exposed for project-session sandboxes")}async function sf(e,t){throw new Error("Backups are not exposed for project-session sandboxes")}async function of(e,t){throw new Error("Backups are not exposed for project-session sandboxes")}async function af(e,t){throw new Error("Backups are not exposed for project-session sandboxes")}async function cf(e){throw new Error("SSH setup is not exposed for project-session sandboxes")}async function lf(e){throw new Error("SSH connection details are not exposed for project-session sandboxes")}var bl=["pulling","patching","stopping","removing","recreating","restarting","verifying","starting","health_check"];function uf(e){return bl.includes(e)}async function pf(e){return{phase:"idle",progress:0,message:"Sandbox image updates are managed by project-session provisioning.",targetVersion:null,previousVersion:null,currentVersion:e?.version??null,error:null,startedAt:null,updatedAt:null}}async function df(e){let t=e?`?channel=${e}`:"",r=await fetch(`${L()}/platform/sandbox/version/latest${t}`,{headers:{Accept:"application/json"}});if(!r.ok)throw new Error(`Version check failed: ${r.status}`);let n=await r.json();try{let s=await xl(e||"stable");n.changelog=s.find(c=>c.version===n.version)??s[0]??null}catch{n.changelog=null}return n}async function xl(e){let t=e?`?channel=${e}`:"",r=await fetch(`${L()}/platform/sandbox/version/changelog${t}`,{headers:{Accept:"application/json"}});if(!r.ok)throw new Error(`Changelog fetch failed: ${r.status}`);return(await r.json()).changelog}async function gf(){let e=await fetch(`${L()}/platform/sandbox/version/all`,{headers:{Accept:"application/json"}});if(!e.ok)throw new Error(`All versions fetch failed: ${e.status}`);return e.json()}async function mf(e,t){throw new Error("Sandbox image updates are managed by project-session provisioning")}async function ff(e){}async function yf(e){}async function hf(e){return{serverTypes:[],location:e||"hel1"}}async function bf(e){throw new Error("Retired instance provisioning is unavailable. Create a project session with daytona, platinum, or e2b.")}async function xf(e){let t=await o.delete(`/platform/sandbox?sandbox_id=${e}`);if(t.error)throw t.error;return t.data}async function kf(e,t){await o.post("/platform/sandbox/mark-error",{sandbox_id:e,error_message:t},{showErrors:!1,timeout:1e4})}async function Pf(){let e=await o.post("/platform/sandbox/claim-computer",{},{timeout:6e4});if(e.error)throw e.error;return e.data}async function wf(e){let t=await o.get(`/platform/sandbox/${e}/status`,{showErrors:!1,timeout:1e4});return t.success?t.data??null:null}function _f(e,t){return`${L()}/platform/sandbox/${e}/provision-stream?token=${encodeURIComponent(t)}`}async function Sf(){let e=await o.get("/platform/github-app/status",{showErrors:!1});if(e.error)throw e.error;if(!e.data)throw new Error("GitHub App status request failed");return e.data}async function vf(e={}){let t=await o.post("/platform/github-app/manifest-start",e,{showErrors:!1});if(t.error)throw t.error;if(!t.data)throw new Error("GitHub App manifest-start request failed");return t.data}async function Cf(e){let t=await o.post("/platform/github-app/app",{app_id:e.appId,private_key:e.privateKey,installation_id:e.installationId,slug:e.slug},{showErrors:!1});if(t.error)throw t.error;if(!t.data)throw new Error("GitHub App configuration request failed");return t.data}async function Rf(e){let t=await o.post("/platform/github-app/pat",e,{showErrors:!1});if(t.error)throw t.error;if(!t.data)throw new Error("GitHub token configuration request failed");return t.data}async function Tf(){let e=await o.delete("/platform/github-app",{showErrors:!1});if(e.error)throw e.error;if(!e.data)throw new Error("GitHub App disconnect request failed");return e.data}function kl(e){try{let t=new URL(e);if(/^\/proxy\/\d+(?:\/|$)/.test(t.pathname))return`${t.origin}/v1/p/auth`;let r=t.pathname.indexOf("/p/");return r!==-1?`${t.origin}${t.pathname.slice(0,r)}/p/auth`:`${t.origin}/v1/p/auth`}catch{return null}}function If(e,t){try{let r=new URL(e),n=r.pathname;if(!(/^\/v1\/p\/[^/]+\/\d+(?:\/|$)/.test(n)||/^\/proxy\/\d+(?:\/|$)/.test(n)))return!1;let c=new Set;if(t)try{c.add(new URL(t).origin)}catch{}return typeof window<"u"&&c.add(window.location.origin),c.size===0||c.has(r.origin)}catch{return!1}}function jf(e,t){return If(e,t)?(t?kl(t):null)??kl(e):null}function Af(e){try{return/^p\d+-[^.]+\./.test(new URL(e).hostname)}catch{return!1}}function Ef(e,t){try{let r=new URL(e);return r.searchParams.set("token",t),r.toString()}catch{return e}}return Rl($f);})();