@kortix/sdk 0.13.34 → 0.13.35
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/core/rest/projects-client/change-requests.d.ts +13 -1
- package/dist/core/rest/projects-client/change-requests.d.ts.map +1 -1
- package/dist/core/rest/projects-client/change-requests.js +9 -2
- package/dist/core/rest/projects-client/change-requests.js.map +1 -1
- package/dist/core/rest/projects-client/connectors.d.ts +24 -2
- package/dist/core/rest/projects-client/connectors.d.ts.map +1 -1
- package/dist/core/rest/projects-client/connectors.js +43 -7
- package/dist/core/rest/projects-client/connectors.js.map +1 -1
- package/dist/core/rest/projects-client/git-history.d.ts +13 -1
- package/dist/core/rest/projects-client/git-history.d.ts.map +1 -1
- package/dist/core/rest/projects-client/git-history.js +11 -2
- package/dist/core/rest/projects-client/git-history.js.map +1 -1
- package/dist/kortix.esm.min.js +3 -3
- package/dist/kortix.global.js +3 -3
- package/package.json +2 -2
package/dist/kortix.global.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";var Kortix=(()=>{var ns=Object.defineProperty;var xh=Object.getOwnPropertyDescriptor;var wh=Object.getOwnPropertyNames;var kh=Object.prototype.hasOwnProperty;var Ph=(e,t)=>{for(var n in t)ns(e,n,{get:t[n],enumerable:!0})},Sh=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of wh(t))!kh.call(e,s)&&s!==n&&ns(e,s,{get:()=>t[s],enumerable:!(r=xh(t,s))||r.enumerable});return e};var vh=e=>Sh(ns({},"__esModule",{value:!0}),e);var NI={};Ph(NI,{ABORT_REASONS:()=>Gy,ABORT_REASONS_NOT_YET_EMITTED:()=>bC,ACTIVE_INSTANCE_COOKIE:()=>mn,ANALYTICS_UNAVAILABLE_CODE:()=>Kg,ATTACHMENT_PART_REF_PREFIX:()=>nh,ApiError:()=>S,AuthError:()=>ie,BillingError:()=>Te,CONTEXT_TOOLS:()=>uy,COST_MARKUP:()=>Jd,DEFAULT_CONTEXT_TOOL_TRIGGER_LABELS:()=>py,DEFAULT_TRANSCRIPT_OPTIONS:()=>Pd,DESTRUCTIVE_PHASES:()=>Zy,FEATURE_DISABLED_CODE:()=>Cn,FEATURE_FLAG_KEYS:()=>ix,FEATURE_NOT_SUPPORTED_CODE:()=>Gg,FILE_VERBS:()=>qe,FileExistsError:()=>nt,HeadlessAuthError:()=>ft,HostBoundaryError:()=>Ae,IMPERSONATION_HEADER:()=>Ig,INBOX_OBSERVATION_MAX_MS:()=>uI,INSTANCE_SCOPED_ROUTES:()=>Ny,MAX_PROMPT_ATTACHMENTS_BYTES:()=>G_,MAX_PROMPT_ATTACHMENT_BYTES:()=>to,MAX_PROMPT_ATTACHMENT_FILES:()=>gm,MEMORY_VERBS:()=>ER,MODEL_NOT_SERVABLE_CODE:()=>Ng,NO_GROUP_ACTIVITY_TOOLS:()=>Nm,OPTIMISTIC_ABORT_MAX_MS:()=>dI,OPTIMISTIC_COMPACTION_MAX_MS:()=>_I,OPTIMISTIC_RECEIPT_MAX_MS:()=>aI,PLUMBING_TOOLS:()=>ly,PREVIEW_PROBE_TIMEOUT_MS:()=>eI,PROJECT_SESSION_NAME_LOOKUP_LIMIT:()=>Nx,PROJECT_SESSION_PAGE_DEFAULT_LIMIT:()=>Gx,PROJECT_SESSION_PAGE_MAX_LIMIT:()=>vm,PROVISION_IN_FLIGHT_CODE:()=>Wg,PublicSessionShareError:()=>lr,RequestTooLargeError:()=>Ue,RuntimeNotReadyError:()=>et,SANDBOX_FS_ROOTS:()=>Ln,SANDBOX_PORTS:()=>ke,SERVER_COMPACTION_REVALIDATE_MS:()=>ph,SERVER_OBSERVATION_MAX_MS:()=>cI,STANDALONE_TOOLS:()=>Wm,STREAM_OBSERVATION_MAX_MS:()=>lI,SandboxNotReadyError:()=>fn,SessionNotReadyError:()=>en,SessionStartError:()=>rr,TURN_END_LEDGER_LAG_MS:()=>pI,WAKE_ESCALATION_COOLDOWN_MS:()=>vI,WAKE_MAX_RESTARTS:()=>SI,WAKE_NO_PROGRESS_MS:()=>PI,WIRE_ID_BACKDATE_MS:()=>Or,WIRE_ID_CLOCK_TOLERANCE:()=>De,WIRE_ID_TIME_MASK:()=>Pe,WIRE_ID_TIME_SCALE:()=>bt,WIRE_MESSAGE_ID:()=>vf,__getConfigResolver:()=>Ch,__setConfigResolver:()=>Rh,abortErrorReason:()=>_C,acceptAccountInvite:()=>ko,acceptInvite:()=>VC,actReviewItem:()=>yp,activateConnection:()=>Xa,addGroupMembers:()=>Ku,addMarketplaceSource:()=>Kp,advanceWakeEscalation:()=>CI,allDescendantIds:()=>Kf,appendPreviewToken:()=>ug,approveProjectAccessRequest:()=>Yo,approveTask:()=>vb,archiveProject:()=>Xn,assignTicket:()=>Mb,attachGroupToProject:()=>ca,authMfa:()=>Rr,authUser:()=>Sr,authenticatedFetch:()=>q,authorizePreviewUrl:()=>ZT,backendApi:()=>c,bindSlackIdentity:()=>fw,bindTeamsIdentity:()=>yw,brokerProjectSecretRequest:()=>xa,buildInstancePath:()=>Ky,buildPresentationTemplateImageUrl:()=>rI,buildPresentationTemplatePdfUrl:()=>nI,buildPreviewAuthEndpoint:()=>lg,buildPublicTemplateUrl:()=>th,buildRuntimePresentationConversionUrl:()=>lh,buildSandboxTemplate:()=>Ic,buildScrapeFailureResults:()=>gy,buildStaticFileHealthPreviewUrl:()=>OP,buildStaticFileLocalUrl:()=>$P,buildStaticFilePreviewUrl:()=>MP,buildStaticFileServicePath:()=>tf,buildTunnelEventStreamUrl:()=>yh,buildWebProxyUrl:()=>LP,bulkActReviewItems:()=>hp,bulkDeletePolicies:()=>Uw,bulkImportPolicies:()=>Fw,burstSummary:()=>Vv,burstSummaryLabel:()=>Jv,callConnector:()=>Ba,cancelAccountDeletion:()=>Sk,cancelAccountInvite:()=>bo,cancelSandbox:()=>GC,cancelSandboxUpdate:()=>cT,cancelScheduledChange:()=>Ql,cancelSubscription:()=>Vl,checkAccessEmail:()=>wT,childMapByParent:()=>vv,claimComputer:()=>gT,claimNext:()=>ff,claimPerSeatBilling:()=>uw,claimWarmProjectSession:()=>al,classifyPart:()=>Td,classifyPreviewProbeStatus:()=>ch,classifyPtyClose:()=>em,classifyTurn:()=>Of,cleanErrorMessage:()=>qv,cleanResultSnippet:()=>nA,cleanWorkerOutput:()=>vR,clearImpersonationSession:()=>Ii,clearKortixAppViewerCache:()=>bh,clearModelDefault:()=>$l,clearSessionFresh:()=>Lx,closeChangeRequest:()=>Vc,closeMilestone:()=>a_,collectTurnParts:()=>wv,commentTicket:()=>Ob,commitSessionChanges:()=>Qc,compactionExpiryAtMs:()=>wI,compactionTurnInfo:()=>Xv,compareMessagesForDisplay:()=>yv,completeInFlight:()=>yf,completeSlackInstall:()=>lu,completeTeamsInstall:()=>uu,computeStatusFromPart:()=>Vd,configureAutoTopup:()=>tu,configureKortix:()=>xn,confirmCheckoutSession:()=>Hl,connectEmail:()=>bu,connectSlack:()=>au,connectionIsFaulted:()=>oI,connectionSharedWithEveryone:()=>wx,connectorConnect:()=>Pm,connectorFinalize:()=>Sm,contextLabelForTool:()=>pA,contextToolSummary:()=>Yv,contextToolTrigger:()=>Zv,convertPresentationToGoogleSlides:()=>Ok,convertRuntimePresentation:()=>sI,copyFile:()=>Ft,costExportUrl:()=>ru,countLiveInboxPrompts:()=>mI,countReviewItemsBySegment:()=>qk,createAccount:()=>oo,createAccountAuditWebhook:()=>$p,createAccountSecretResource:()=>Ia,createAccountToken:()=>vp,createApp:()=>Vp,createAppAccessSession:()=>td,createAppDeployment:()=>rd,createArtifactKind:()=>MA,createAssignment:()=>up,createAuditWebhook:()=>fk,createBackup:()=>QC,createCheckoutSession:()=>Kl,createConnector:()=>dc,createFile:()=>Ut,createGatewayKey:()=>Du,createGroup:()=>Bu,createHttpSessionSyncController:()=>fh,createInstance:()=>uT,createKortix:()=>pf,createKortixPty:()=>Ki,createKortixSession:()=>Tr,createMarketplaceInstallSession:()=>Yk,createMilestone:()=>i_,createOAuthClient:()=>ip,createPerSeatCheckout:()=>lw,createPolicy:()=>Ow,createPortalSession:()=>zl,createProject:()=>jo,createProjectAgent:()=>Kb,createProjectCliToken:()=>Cp,createProjectRepo:()=>Mo,createProjectResourceGrant:()=>da,createProjectSession:()=>gt,createProjectTrigger:()=>Al,createPromptAttachmentController:()=>so,createRole:()=>Qu,createSSEStream:()=>hh,createSandbox:()=>OC,createSandboxShare:()=>kp,createSandboxTemplate:()=>Rc,createScimToken:()=>Nw,createServiceAccountApi:()=>pk,createSessionPrompt:()=>dl,createSessionPublicShare:()=>sl,createSessionQueue:()=>gf,createSsoGroupMapping:()=>nk,createTask:()=>kb,createTicket:()=>Ib,createTunnelEventStream:()=>LI,declineAccountInvite:()=>Po,declineInvite:()=>JC,deleteAccountImmediately:()=>vk,deleteAccountSecretResource:()=>ja,deleteApp:()=>Qp,deleteAuditWebhook:()=>hk,deleteBackup:()=>ZC,deleteConnector:()=>mc,deleteCredential:()=>m_,deleteEnv:()=>Gi,deleteFile:()=>Be,deleteGatewayBudget:()=>$u,deleteGitHubInstallation:()=>Vo,deleteGroup:()=>Nu,deleteInstance:()=>pT,deleteKortixProject:()=>e_,deleteMilestone:()=>l_,deleteOAuthClient:()=>cp,deletePersonalProjectSecret:()=>Ra,deletePolicy:()=>qw,deleteProjectAgent:()=>zb,deleteProjectProviderOAuth:()=>Pa,deleteProjectResourceGrant:()=>ga,deleteProjectSecret:()=>va,deleteProjectSession:()=>bl,deleteProjectTrigger:()=>Cl,deletePromptAttachment:()=>pt,deleteRole:()=>ep,deleteSandboxTemplate:()=>Tc,deleteServiceAccountApi:()=>gk,deleteSessionPrompt:()=>ml,deleteSsoGroupMapping:()=>rk,deleteSsoProvider:()=>ek,deleteTask:()=>Ab,deleteTicket:()=>Db,describeAccountInvite:()=>wo,describeConnectorTool:()=>La,detachGroupFromProject:()=>ua,detectLocalhostUrls:()=>Qm,disableServiceAccountApi:()=>dk,disconnectEmail:()=>_u,disconnectGitHubApp:()=>KT,disconnectSlack:()=>du,discoverConnectionOAuth2:()=>vx,discoverConnectionOAuth2Resource:()=>Ax,discoverConnectorAuth:()=>gc,discoverLocalSandbox:()=>FC,downloadAccountAudit:()=>qT,dropClientForUrl:()=>P_,dropPublicClientForUrl:()=>A_,editQueued:()=>xf,enqueue:()=>mf,ensurePmSession:()=>Nb,ensurePreviewSessionCookie:()=>ah,ensureProjectConnectorConnection:()=>kx,ensureSandbox:()=>Yy,ensureWarmProjectSession:()=>ol,env:()=>Yg,exchangeCode:()=>wr,exportAccountAudit:()=>jp,extractGatewayErrorDetails:()=>ue,extractInstanceRoute:()=>Pt,extractSkillBaseDir:()=>Dy,extractSkillContent:()=>FR,extractSkillFiles:()=>Oy,extractWorkerPreview:()=>RR,failInFlight:()=>hf,fallbackBusyRowAfterTurnId:()=>sR,familyForTool:()=>Hr,featureDisabledKey:()=>Si,featureFlags:()=>kC,fetchAccountStateWithToken:()=>aw,fetchAccountsWithToken:()=>sx,fetchAttachmentPart:()=>HT,fetchCostExportCsv:()=>mw,fetchKortixAppViewer:()=>fg,fetchProjectArchive:()=>Oc,fetchProjectsForAccountWithToken:()=>mx,fetchSessionAttachment:()=>bd,filePhase:()=>IR,fileVerb:()=>TR,files:()=>dm,finalizeAppArtifact:()=>pr,finalizeConnectorSetupLink:()=>CT,findActiveTranscriptShare:()=>Wx,findFiles:()=>Dt,findLastTextPart:()=>kv,findSessionAttachments:()=>fP,findText:()=>qt,fireProjectTrigger:()=>Il,fixSandboxWithAgent:()=>Ac,flattenThought:()=>BA,formatBillingErrorForUI:()=>Ai,formatCost:()=>xR,formatDuration:()=>hR,formatJsonFailureOutput:()=>Uv,formatMessageDay:()=>zA,formatMessageExact:()=>VA,formatOpenCodeRuntimeError:()=>Jy,formatRawOutput:()=>tA,formatRuntimeError:()=>Jy,formatTokens:()=>wR,formatTranscript:()=>kf,freshSendHint:()=>aR,generateSessionId:()=>df,getAccount:()=>ao,getAccountBranding:()=>lo,getAccountDeletionStatus:()=>kk,getAccountState:()=>Ul,getAccountStateMinimal:()=>Fl,getActiveInstanceIdFromCookie:()=>zy,getAdminProviderAnalytics:()=>Ik,getAdminProviderDistribution:()=>Rk,getAdminProviderFallback:()=>jk,getAdminRole:()=>Ak,getAgentCardLabel:()=>Ff,getAgentConfig:()=>ew,getAgentPersona:()=>Vb,getAllVersions:()=>iT,getAnsweredQuestionParts:()=>Sv,getApp:()=>Jp,getAppAccess:()=>Yp,getAppDeployment:()=>id,getAppDeploymentLogs:()=>od,getApprovalLink:()=>Qk,getAuthToken:()=>Xe,getAuthTokenWithRetry:()=>tb,getAutoTopupSettings:()=>eu,getAutoTopupSetupStatus:()=>cw,getBillingCreditBreakdown:()=>Gl,getBillingTierConfigurations:()=>Wl,getBillingTransactionsSummary:()=>Bl,getBillingUsageHistory:()=>Nl,getChangeRequest:()=>Nc,getChangeRequestDiff:()=>Wc,getChangeRequestMergePreview:()=>Kc,getChildSessionError:()=>av,getChildSessionId:()=>ov,getChildSessionToolParts:()=>cv,getClient:()=>je,getClientForUrl:()=>xe,getConnectStatus:()=>bc,getConnectionOAuth2Application:()=>Sx,getConnectionOAuth2Status:()=>Ex,getConnectionPolicies:()=>jx,getConnectorCatalog:()=>Yn,getConnectorConfig:()=>lc,getConnectorPolicies:()=>ac,getConnectorSetupLink:()=>AT,getCostSummary:()=>gw,getCurrentInstanceIdFromPathname:()=>Hy,getCurrentInstanceIdFromWindow:()=>vC,getCurrentProject:()=>Zi,getDefaultAccountState:()=>sr,getDiagnostics:()=>pv,getDirectory:()=>Uf,getDiscoverConnector:()=>er,getDiscoverIntegration:()=>Ux,getEmailInstallation:()=>yu,getEmailMode:()=>hu,getEnterpriseDemo:()=>_k,getFileStatus:()=>Ot,getFileWithDir:()=>Id,getFilename:()=>qf,getFullChangelog:()=>eh,getGatewayBreakdown:()=>Tu,getGatewayBudgets:()=>ju,getGatewayErrors:()=>Eu,getGatewayKeys:()=>Ou,getGatewayLog:()=>Au,getGatewayOverview:()=>Ru,getGatewayRoutingPolicy:()=>wu,getGatewaySeries:()=>Cu,getGatewaySessions:()=>Iu,getGitHubAppStatus:()=>BT,getGitHubInstallation:()=>Bo,getGoogleAuthUrl:()=>$k,getGroup:()=>Lu,getHiddenToolParts:()=>rv,getImpersonationSession:()=>Mg,getInvite:()=>zC,getJustavpsServerTypes:()=>lT,getKortixProject:()=>Qb,getKortixProjectBySession:()=>Yb,getKortixPtyWebSocketUrl:()=>Vi,getLatestSandboxVersion:()=>sT,getMaintenanceConfig:()=>MT,getManagedGitBackend:()=>Jo,getManagedGitStatus:()=>ux,getMarketplaceCatalogItem:()=>Gp,getMarketplaceCatalogItemFile:()=>Np,getMfaRequired:()=>Kw,getMilestone:()=>r_,getModelDefaults:()=>jl,getOAuthClient:()=>sp,getOAuthConsentRequest:()=>ST,getOpenCodeConfigInvalidError:()=>ng,getPartText:()=>ev,getPatPolicy:()=>ck,getPermissionForTool:()=>dv,getProject:()=>Kn,getProjectActivity:()=>Jb,getProjectCommit:()=>Uc,getProjectCommitDiff:()=>Fc,getProjectDetail:()=>Hn,getProjectFileHistory:()=>Lc,getProjectGitToken:()=>Eo,getProjectLlmCatalog:()=>zn,getProjectLlmCatalogProviders:()=>ax,getProjectModelAccess:()=>dr,getProjectModelPicker:()=>Vn,getProjectSandboxHealth:()=>tr,getProjectSandboxProviderTransition:()=>px,getProjectSession:()=>nr,getProjectSessionConfigState:()=>_l,getProjectSessionScope:()=>kl,getProrationPreview:()=>Yl,getProviders:()=>MC,getProxyBaseUrl:()=>DP,getPublicClientForUrl:()=>v_,getPublicMarketplaceItem:()=>_T,getPublicMarketplaceItemFile:()=>xT,getPublicSessionShare:()=>Jk,getPublicSessionShareMessages:()=>Xk,getPublicShareByToken:()=>ET,getPublicTemplate:()=>LT,getQuestionForTool:()=>gv,getReferralCode:()=>Sw,getReferralStats:()=>Rw,getRetryInfo:()=>kR,getRetryMessage:()=>PR,getReviewItem:()=>mp,getRolePermissions:()=>Ju,getRoleUsage:()=>Xu,getSSHConnection:()=>tT,getSandbox:()=>$C,getSandboxById:()=>DC,getSandboxPortUrl:()=>jC,getSandboxProvisionStatus:()=>mT,getSandboxProvisionStreamUrl:()=>fT,getSandboxUpdateStatus:()=>rT,getSandboxUrl:()=>ig,getSecretSetupLink:()=>TT,getServerHealth:()=>Bn,getServiceLogs:()=>__,getSessionAudit:()=>cl,getSessionCost:()=>_R,getSessionCostRecord:()=>ar,getSessionHealth:()=>xd,getSessionOpenBundle:()=>Kx,getSessionOversight:()=>Vw,getSessionPolicy:()=>sk,getSessionPreviewCandidates:()=>nl,getSessionProviderSecretPool:()=>Da,getSessionTranscript:()=>ll,getSessionTranscriptSync:()=>ul,getSessionTurn:()=>pl,getShellModePart:()=>lR,getSlackChannelFile:()=>gu,getSlackInstallation:()=>ou,getSlackManifest:()=>pu,getSlackMode:()=>cu,getSsoProvider:()=>Xw,getStaticFileHealthPath:()=>nf,getSupabaseAccessToken:()=>En,getSupabaseAccessTokenWithRetry:()=>Je,getTask:()=>_b,getTaskStatus:()=>wb,getTemplate:()=>Zk,getTicket:()=>Cb,getToolInfo:()=>lv,getToolPrimaryArg:()=>Nr,getTranscriptFilename:()=>Pf,getTurnCost:()=>bR,getTurnError:()=>gR,getTurnErrorDetails:()=>fR,getTurnErrorRawText:()=>mR,getTurnStatus:()=>yR,getUsageRollup:()=>nu,getUserRolesWithToken:()=>OT,getVersionDiff:()=>Bc,getWorkingState:()=>pR,grantAccountSecretResource:()=>Ma,grantSandboxProjectAccess:()=>KC,grantSecretToAgent:()=>sw,groupMessagesIntoTurns:()=>bv,groupShowSegments:()=>QA,groupSteps:()=>Hd,hasDiffs:()=>SR,hasLocalhostUrls:()=>IP,hasPreviewTarget:()=>ef,hasRetryingAssistantTurn:()=>Rv,heartbeatGapEvent:()=>cf,holdSessionPrompts:()=>yl,humanizeReviewActionPath:()=>xp,humanizeSearchQuery:()=>cn,humanizeToolName:()=>Ur,impersonationHeaders:()=>Ei,importSsoProviderFromMetadata:()=>Yw,inboxObservationSupersedes:()=>gI,initialWakeEscalationState:()=>gg,installTemplate:()=>eP,invalidateTokenCache:()=>jn,inviteAccountMember:()=>yo,inviteProjectMember:()=>ra,inviteRepoCollaborator:()=>To,isAbortError:()=>gn,isAdminBypassEnabled:()=>Ug,isAgentPart:()=>XS,isAppRouteUrl:()=>Xm,isAttachment:()=>tv,isAttachmentPartRef:()=>rh,isBillingError:()=>vi,isCompactionPart:()=>QS,isConfigured:()=>wn,isContextTool:()=>Qv,isDestructivePhase:()=>nT,isEmptyShowPart:()=>mr,isErrorOutput:()=>jv,isExternalUrl:()=>NP,isFeatureDisabledError:()=>Pi,isFilePart:()=>Ed,isImpersonationSessionLive:()=>Eg,isInstanceDetailPath:()=>PC,isInstanceScopedAppPath:()=>Wy,isInternalLocalhostUrl:()=>FP,isInvisibleActivityPart:()=>dd,isInviteSent:()=>hx,isLastUserMessage:()=>uR,isManagedGithubProject:()=>ox,isNoGroupActivityTool:()=>pd,isOpenCodeConfigInvalidError:()=>TC,isPatchPart:()=>ZS,isPreviewUrl:()=>UP,isProxiableLocalhostUrl:()=>rf,isQuestionTool:()=>oP,isReasoningPart:()=>me,isRetryableTurnError:()=>Hf,isRuntimeReady:()=>_P,isSandboxNotReadyError:()=>yn,isServerReachable:()=>eo,isSessionAttachmentRef:()=>pP,isSessionFresh:()=>Zc,isSessionStartError:()=>Vx,isShellActivityTool:()=>iP,isShellMode:()=>Cy,isShortOutput:()=>AR,isShowContentUnavailable:()=>rP,isShowPayloadEmpty:()=>Xt,isSnapshotPart:()=>YS,isStandaloneActivityTool:()=>gd,isSubdomainPreviewUrl:()=>bn,isTextPart:()=>ge,isToolPart:()=>Z,isToolPartHidden:()=>sv,isUnderSandboxRoot:()=>Qi,isWebProxyUrl:()=>GP,isWireIdAheadOf:()=>Af,kortixAppViewerToken:()=>_h,kortixPty:()=>rm,leaveAccount:()=>Ao,linkGitHubInstallation:()=>zo,linkRepository:()=>Fo,listAccountAudit:()=>Ip,listAccountAuditWebhooks:()=>Mp,listAccountInvites:()=>ho,listAccountMembers:()=>fo,listAccountResourceGrants:()=>Mw,listAccountSecretResources:()=>Ta,listAccountSessions:()=>ok,listAccountTokens:()=>Sp,listAccounts:()=>io,listActions:()=>Lw,listAdminSandboxes:()=>Ck,listAgentIdentities:()=>Vu,listAllConnections:()=>Ka,listAppAgents:()=>Zp,listAppDeployments:()=>sd,listApps:()=>zp,listAssignments:()=>lp,listAuditEvents:()=>bk,listAuditWebhooks:()=>mk,listBackups:()=>XC,listBillingTransactions:()=>Ll,listChangeRequests:()=>Gc,listChannelBindings:()=>ww,listColumns:()=>qb,listConnectSections:()=>Dx,listConnectToolkits:()=>Ox,listConnections:()=>Wa,listConnectorAccounts:()=>Ga,listConnectorTools:()=>Ht,listConnectors:()=>nc,listCostByProject:()=>dw,listCredentialEvents:()=>p_,listCredentials:()=>u_,listDiscoverConnectors:()=>Zn,listDiscoverIntegrations:()=>qx,listDiscoverSections:()=>hc,listEnv:()=>Li,listFeaturedMarketplaces:()=>Bp,listFields:()=>Fb,listFiles:()=>it,listGatewayLogs:()=>vu,listGitHubInstallations:()=>Go,listGitHubRepositories:()=>Wo,listGitHubRepositoryBranches:()=>Ko,listGroupMembers:()=>Wu,listGroupProjectGrants:()=>Iw,listGroups:()=>Fu,listKortixProjectSessions:()=>Zb,listKortixProjects:()=>Xb,listKortixPty:()=>Wi,listLinkableGitHubInstallations:()=>No,listManagedGitRepositories:()=>Xo,listMarketplaceCatalogItems:()=>Fp,listMarketplaceSources:()=>Wp,listMarketplaces:()=>Lp,listMemberGroups:()=>Ew,listMemberProjectAccess:()=>jw,listMilestoneEvents:()=>s_,listMilestones:()=>n_,listMyAccountInvites:()=>xo,listOAuthClients:()=>rp,listPendingApprovals:()=>ma,listPendingProjectInvites:()=>sa,listPermissions:()=>dp,listPipedreamApps:()=>fc,listPipedreamSections:()=>yc,listPolicies:()=>$w,listProjectAccess:()=>ea,listProjectAccessRequests:()=>Qo,listProjectAgents:()=>Wb,listProjectAudit:()=>Ep,listProjectBranches:()=>Dc,listProjectCliTokens:()=>Rp,listProjectCommits:()=>qc,listProjectFiles:()=>jc,listProjectGroupGrants:()=>aa,listProjectPolicies:()=>wc,listProjectResourceGrants:()=>pa,listProjectSandboxTemplates:()=>Pc,listProjectSandboxes:()=>Ec,listProjectSecrets:()=>ha,listProjectSessions:()=>dt,listProjectSessionsPage:()=>el,listProjectSnapshots:()=>Sc,listProjectTriggers:()=>vl,listProjects:()=>Ge,listProjectsForAccount:()=>Co,listPublicMarketplaceItems:()=>hT,listPublicMarketplaces:()=>bT,listReferrals:()=>Cw,listReviewItems:()=>gp,listRoles:()=>zu,listSandboxProjectMembers:()=>WC,listSandboxShares:()=>wp,listSandboxes:()=>UC,listScimTokens:()=>Gw,listServiceAccountsApi:()=>uk,listServiceTemplates:()=>b_,listServices:()=>h_,listSessionConnectRequests:()=>$x,listSessionCosts:()=>iu,listSessionPrompts:()=>gl,listSessionProviderSecretPools:()=>qa,listSessionPublicShares:()=>rl,listSessionsNeedingInput:()=>fa,listSsoGroupMappings:()=>tk,listTaskEvents:()=>xb,listTasks:()=>bb,listTemplates:()=>Bb,listTicketEvents:()=>Tb,listTickets:()=>Rb,loadHttpSessionHistory:()=>mh,looksLikeError:()=>qd,looksLikeHtml:()=>oA,looksLikeJsonPayload:()=>eA,mapApiReviewItem:()=>Vk,markInstanceError:()=>dT,markSessionFresh:()=>zt,maxWireIdClock:()=>Sd,memoryRelPath:()=>jR,mergeBurstSteps:()=>UA,mergeChangeRequest:()=>zc,messageCreatedAt:()=>GA,messageTime:()=>vy,migrateAdminSandboxProvider:()=>Ek,mintWireMessageId:()=>Tf,mintWireMessageIdAbove:()=>vd,mkdir:()=>lt,narrateFailedStep:()=>Kd,narrateStep:()=>Wd,narrationToolName:()=>pn,narrowChatEvent:()=>lf,newestWireIdClock:()=>Rf,normalizeActivityToolName:()=>ae,normalizeAppPathname:()=>CC,normalizeExternalInput:()=>WP,normalizeName:()=>H,normalizeToolName:()=>tn,openChangeRequest:()=>Hc,openEventStream:()=>Mr,openStressTestStream:()=>UT,parseBillingError:()=>Ct,parseEmbeddedFailure:()=>rA,parseFlagOverride:()=>wC,parseJsonFailure:()=>ay,parseLocalhostUrl:()=>Zt,parseMemoryView:()=>MR,parseOpenCodeErrorPayload:()=>Vy,parsePresentationOutput:()=>DR,parseProxyHop:()=>_d,parseQuestionAnswersFromOutput:()=>qR,parseReadOutput:()=>UR,parseScrapeInputUrls:()=>dy,parseScrapeOutput:()=>my,parseSubdomainUrl:()=>kd,parseTaskRows:()=>CR,parseWebProxyUrl:()=>BP,parseWebSearchOutput:()=>Gd,partOutcome:()=>Ud,patchKortixProject:()=>t_,patchVerb:()=>OR,pipedreamConnect:()=>pc,pipedreamConnectConnection:()=>ec,pipedreamFinalize:()=>xc,pipedreamFinalizeConnection:()=>tc,platformConfig:()=>$,pollConnectionOAuth2DeviceAuthorization:()=>Ix,pollProjectProviderOAuth:()=>ka,previewGatewayRoute:()=>Su,previewMfaRequired:()=>Hw,previewSlackIdentity:()=>hw,previewTeamsIdentity:()=>bw,probeEffectivePermission:()=>tp,probeEffectivePermissions:()=>np,probePreviewPort:()=>tI,projectCompacting:()=>xI,projectSessionConnection:()=>iI,projectSessionStartSeed:()=>zx,projectWorking:()=>fI,provisionProject:()=>$o,provisionProjectStream:()=>lx,provisionProjectWithToken:()=>fx,proxyLocalhostUrl:()=>wd,proxyUrlToInternal:()=>qP,purchaseCredits:()=>Zl,putConnectionOAuth2Application:()=>Px,rawErrorText:()=>Cd,reactivateSandbox:()=>NC,reactivateSubscription:()=>Jl,readBlob:()=>at,readFile:()=>ot,readProjectFile:()=>$c,reasoningIsRunning:()=>xy,rebuildProjectSnapshot:()=>vc,reconcileConnection:()=>Ha,reconcileMemberConnection:()=>za,reconcileServices:()=>w_,recordPlatformLogout:()=>PT,recoverLinkResults:()=>Wr,refreshReferralCode:()=>vw,refreshSession:()=>yt,registerAppArtifact:()=>ur,registerConnectionOAuth2Client:()=>Rx,registerService:()=>k_,rejectProjectAccessRequest:()=>Zo,relativizePath:()=>uv,reloadProjectSessionConfig:()=>xl,reloadProjectSessionConfigStream:()=>wl,removeAccountAuditWebhook:()=>Dp,removeAccountBrandingAsset:()=>go,removeAccountMember:()=>So,removeGroupMember:()=>Hu,removeKortixPty:()=>zi,removeMarketplaceSource:()=>Hp,removeQueued:()=>_f,renameConnection:()=>Ya,renameFile:()=>Bt,renameSandbox:()=>qC,reopenChangeRequest:()=>Jc,reopenMilestone:()=>c_,reorderQueued:()=>wf,replaceColumns:()=>Ub,replaceFields:()=>Lb,replaceProjectRepository:()=>Lo,replaceTemplates:()=>Gb,requestAccountDeletion:()=>Pk,requestChangesOnChangeRequest:()=>Xc,requestProjectAccess:()=>yx,requestProjectConnector:()=>Up,requestProjectSecret:()=>qp,resendAccountInvite:()=>_o,resendPendingProjectInvite:()=>oa,resetAccountBranding:()=>mo,resetClient:()=>S_,resetGatewayRoutingPolicy:()=>Pu,resetPassword:()=>kr,resetPublicClient:()=>R_,resetSandboxUpdateStatus:()=>aT,resolveApproval:()=>ya,resolveScrapeResults:()=>aA,resolveWorkingTurn:()=>cR,resolvedPlan:()=>ow,restartProjectSession:()=>Vt,restartSandbox:()=>LC,restoreBackup:()=>YC,retryFailed:()=>bf,retrySessionPrompt:()=>fl,revealCredential:()=>g_,reviewItemTarget:()=>Dk,reviewSegmentForStatus:()=>Fm,reviewVerdictForStatus:()=>Uk,revokeAccountSecretResourceGrant:()=>$a,revokeAccountSession:()=>ak,revokeAccountToken:()=>Ap,revokeAssignment:()=>pp,revokeConnection:()=>Ja,revokeGatewayKey:()=>qu,revokePendingProjectInvite:()=>ia,revokeProjectAccess:()=>na,revokeProjectCliToken:()=>Tp,revokeSandboxProjectAccess:()=>HC,revokeSandboxShare:()=>Pp,revokeScimToken:()=>Ww,revokeSessionPublicShare:()=>il,rewriteLocalhostUrl:()=>$e,rollbackApp:()=>ld,rotateAccountSecretResource:()=>Ea,rotateOAuthClientSecret:()=>ap,runGatewayPlayground:()=>Uu,sanitizePtyChunk:()=>nm,saveGitHubInstallation:()=>Ho,scheduleDowngrade:()=>Xl,searchConnectorTools:()=>Fa,searchProjectFiles:()=>Mc,segmentTurn:()=>JA,sendMagicLink:()=>br,sendReferralEmails:()=>Tw,serverCompactionRevalidateAtMs:()=>kI,serviceAction:()=>x_,sessionParentId:()=>Bx,sessionStartKey:()=>Xx,setAccountSecretResourceAccess:()=>Oa,setActiveInstanceCookie:()=>AC,setAdminBypass:()=>qg,setAdminProviderDistribution:()=>Tk,setAdminProviderFallback:()=>Mk,setAgentScope:()=>Ol,setBootstrapAuthToken:()=>eb,setCachedAuthToken:()=>Zh,setConnectionPolicies:()=>Mx,setConnectorAuthorizationStrategy:()=>ic,setConnectorCredential:()=>_c,setConnectorCredentialMode:()=>sc,setConnectorName:()=>uc,setConnectorPolicies:()=>cc,setConnectorSecretBinding:()=>Fx,setConnectorSensitive:()=>oc,setDefaultConnection:()=>Qa,setEnterpriseDemo:()=>xk,setEnv:()=>Bi,setGatewayBudget:()=>Mu,setGatewayRoutingPolicy:()=>ku,setGitHubAppFromExisting:()=>NT,setGitHubAppPat:()=>WT,setImpersonationSession:()=>Vh,setMaintenanceConfig:()=>$T,setMemberSuperAdmin:()=>Bw,setMfaRequired:()=>zw,setModelDefault:()=>Ml,setPersonalProjectSecret:()=>Aa,setProjectModelAccess:()=>gr,setProjectModelEnablement:()=>Qx,setProjectOnboardingComplete:()=>Uo,setProjectOnboardingProfile:()=>gx,setProjectPolicies:()=>kc,setProjectSecretStrategy:()=>_a,setProjectSessionModel:()=>Sl,setProjectSessionScope:()=>Pl,setProjectSessionSharing:()=>tl,setProjectTriggersActivation:()=>Tl,setSessionOversight:()=>Jw,setSessionProviderSecretPool:()=>Ua,setupSSH:()=>eT,shareConnection:()=>Za,shellActivityGroupLabel:()=>aP,shellExitCode:()=>Yd,shouldAttachImpersonation:()=>$g,shouldHideResponsePart:()=>dR,shouldShowToolPart:()=>Df,shouldSuppressWorkingTurnBusy:()=>nR,showGroupItems:()=>eR,showTurnBusyIndicator:()=>zd,signInWithPassword:()=>hr,signInWithProvider:()=>xr,signInWithSso:()=>Ar,signOut:()=>Cr,signUp:()=>yr,skillDocumentPath:()=>KR,skillInputDir:()=>GR,sortSessions:()=>Av,splitUserParts:()=>nv,startApp:()=>ad,startConnectionOAuth2Authorization:()=>Cx,startConnectionOAuth2DeviceAuthorization:()=>Tx,startConnectorSetupLink:()=>RT,startGitHubAppManifest:()=>GT,startProjectProviderOAuth:()=>wa,startProjectSession:()=>Ne,startSessionWithToken:()=>jT,startTask:()=>Sb,stepLabel:()=>Fd,stopApp:()=>cd,stopProjectSession:()=>Jt,stopSandbox:()=>BC,stripAnsi:()=>fv,stripInstancePrefix:()=>SC,stripTrailingSlashes:()=>_e,submitAccessRequest:()=>kT,submitDemoRequest:()=>DT,submitOAuthConsent:()=>vT,submitReviewItem:()=>fp,submitSecretSetupLink:()=>IT,subscribeToImpersonation:()=>Jh,supabaseClient:()=>mb,syncConnectors:()=>rc,syncSubscription:()=>pw,systemReload:()=>T_,toDaemonPath:()=>Le,toInstanceAwarePath:()=>RC,toInternalUrl:()=>sf,toSandboxAbsolutePath:()=>st,toWorkspaceRelative:()=>Yi,toolInfo:()=>Fr,toolViewModel:()=>Ly,triggerSandboxUpdate:()=>oT,triggersRequest:()=>Zg,turnEndCause:()=>uh,turnEndNotice:()=>bI,turnHasSteps:()=>Pv,turnIsConfirmedActive:()=>iR,unassignTicket:()=>$b,unwrapError:()=>ce,updateAccountAuditWebhook:()=>Op,updateAccountBranding:()=>uo,updateAccountMemberRole:()=>vo,updateAccountName:()=>co,updateAgentConfig:()=>tw,updateApp:()=>Xp,updateAppAccess:()=>ed,updateAuditWebhook:()=>yk,updateChannelBinding:()=>kw,updateConnectionCredential:()=>Va,updateEmailPolicy:()=>xu,updateExperimentalFeature:()=>Do,updateFeatureFlag:()=>Oo,updateGroup:()=>Gu,updateKortixPty:()=>Hi,updateMilestone:()=>o_,updateOAuthClient:()=>op,updatePassword:()=>Pr,updatePatPolicy:()=>lk,updatePolicy:()=>Dw,updateProject:()=>Jn,updateProjectAccess:()=>ta,updateProjectAgent:()=>Hb,updateProjectDefaultAgent:()=>ql,updateProjectGroupGrant:()=>la,updateProjectSandboxProvider:()=>qo,updateProjectSession:()=>hl,updateProjectTrigger:()=>Rl,updateRole:()=>Yu,updateRolePermissions:()=>Zu,updateSandboxTemplate:()=>Cc,updateSessionPolicy:()=>ik,updateTask:()=>Pb,updateTemplateWarmPool:()=>dx,updateTicket:()=>Eb,updateTicketStatus:()=>jb,updateUserMetadata:()=>vr,uploadAccountBrandingAsset:()=>po,uploadAppArtifactArchive:()=>nd,uploadConnectorAttachment:()=>Na,uploadFile:()=>ct,uploadPromptAttachment:()=>Wt,uploadSessionAttachment:()=>hd,uploadSlackChannelFile:()=>mu,uploadTimeoutMsForBytes:()=>tt,upsertCredential:()=>d_,upsertProjectGitCredential:()=>Sa,upsertProjectSecret:()=>ba,upsertSsoProvider:()=>Qw,validateProjectManifest:()=>Io,validateReferralCode:()=>Aw,validateToken:()=>Ro,verifyGatewayProvider:()=>Pw,verifyOtp:()=>_r,verifySsoDomain:()=>Zw,wakeEscalationAttemptSummary:()=>jI,wakeEscalationNote:()=>II,wakeProgressFingerprint:()=>AI,wireIdClock:()=>We,wireIdClockAt:()=>_t,wireIdClockDelta:()=>Ke,workingExpiryAtMs:()=>yI,workingTurnDrawsBusyRow:()=>oR,writeActivityGroupLabel:()=>cP,writeFile:()=>Lt,wsDomain:()=>Kr,wsFavicon:()=>iA,wsRootDomain:()=>sA});var Ah={backendUrl:"",getToken:async()=>null},rs=null,_n=null;function Rh(e){_n=e}function Ch(){return _n}function xn(e,t){t?.global!==!1&&(rs=e)}function $(){return _n?.()??rs??Ah}function wn(){return rs!==null||_n?.()!==void 0}var yg=({onRequest:e,onSseError:t,onSseEvent:n,responseTransformer:r,responseValidator:s,sseDefaultRetryDelay:i,sseMaxRetryAttempts:o,sseMaxRetryDelay:a,sseSleepFn:p,url:g,...m})=>{let h,_=p??(P=>new Promise(M=>setTimeout(M,P)));return{stream:async function*(){let P=i??3e3,M=0,k=m.signal??new AbortController().signal;for(;!k.aborted;){M++;let d=m.headers instanceof Headers?m.headers:new Headers(m.headers);h!==void 0&&d.set("Last-Event-ID",h);try{let y={redirect:"follow",...m,body:m.serializedBody,headers:d,signal:k},l=new Request(g,y);e&&(l=await e(g,y));let R=await(m.fetch??globalThis.fetch)(l);if(!R.ok)throw new Error(`SSE failed: ${R.status} ${R.statusText}`);if(!R.body)throw new Error("No body in SSE response");let I=R.body.pipeThrough(new TextDecoderStream).getReader(),O="",N=()=>{try{I.cancel()}catch{}};k.addEventListener("abort",N);try{for(;;){let{done:E,value:K}=await I.read();if(E)break;O+=K,O=O.replace(/\r\n/g,`
|
|
1
|
+
"use strict";var Kortix=(()=>{var ns=Object.defineProperty;var xh=Object.getOwnPropertyDescriptor;var wh=Object.getOwnPropertyNames;var kh=Object.prototype.hasOwnProperty;var Ph=(e,t)=>{for(var n in t)ns(e,n,{get:t[n],enumerable:!0})},Sh=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of wh(t))!kh.call(e,s)&&s!==n&&ns(e,s,{get:()=>t[s],enumerable:!(r=xh(t,s))||r.enumerable});return e};var vh=e=>Sh(ns({},"__esModule",{value:!0}),e);var NI={};Ph(NI,{ABORT_REASONS:()=>Gy,ABORT_REASONS_NOT_YET_EMITTED:()=>bC,ACTIVE_INSTANCE_COOKIE:()=>mn,ANALYTICS_UNAVAILABLE_CODE:()=>Kg,ATTACHMENT_PART_REF_PREFIX:()=>nh,ApiError:()=>S,AuthError:()=>ie,BillingError:()=>Te,CONTEXT_TOOLS:()=>uy,COST_MARKUP:()=>Jd,DEFAULT_CONTEXT_TOOL_TRIGGER_LABELS:()=>py,DEFAULT_TRANSCRIPT_OPTIONS:()=>Pd,DESTRUCTIVE_PHASES:()=>Zy,FEATURE_DISABLED_CODE:()=>Cn,FEATURE_FLAG_KEYS:()=>ix,FEATURE_NOT_SUPPORTED_CODE:()=>Gg,FILE_VERBS:()=>qe,FileExistsError:()=>nt,HeadlessAuthError:()=>ft,HostBoundaryError:()=>Ae,IMPERSONATION_HEADER:()=>Ig,INBOX_OBSERVATION_MAX_MS:()=>uI,INSTANCE_SCOPED_ROUTES:()=>Ny,MAX_PROMPT_ATTACHMENTS_BYTES:()=>G_,MAX_PROMPT_ATTACHMENT_BYTES:()=>to,MAX_PROMPT_ATTACHMENT_FILES:()=>gm,MEMORY_VERBS:()=>ER,MODEL_NOT_SERVABLE_CODE:()=>Ng,NO_GROUP_ACTIVITY_TOOLS:()=>Nm,OPTIMISTIC_ABORT_MAX_MS:()=>dI,OPTIMISTIC_COMPACTION_MAX_MS:()=>_I,OPTIMISTIC_RECEIPT_MAX_MS:()=>aI,PLUMBING_TOOLS:()=>ly,PREVIEW_PROBE_TIMEOUT_MS:()=>eI,PROJECT_SESSION_NAME_LOOKUP_LIMIT:()=>Nx,PROJECT_SESSION_PAGE_DEFAULT_LIMIT:()=>Gx,PROJECT_SESSION_PAGE_MAX_LIMIT:()=>vm,PROVISION_IN_FLIGHT_CODE:()=>Wg,PublicSessionShareError:()=>lr,RequestTooLargeError:()=>Ue,RuntimeNotReadyError:()=>et,SANDBOX_FS_ROOTS:()=>Ln,SANDBOX_PORTS:()=>ke,SERVER_COMPACTION_REVALIDATE_MS:()=>ph,SERVER_OBSERVATION_MAX_MS:()=>cI,STANDALONE_TOOLS:()=>Wm,STREAM_OBSERVATION_MAX_MS:()=>lI,SandboxNotReadyError:()=>fn,SessionNotReadyError:()=>en,SessionStartError:()=>rr,TURN_END_LEDGER_LAG_MS:()=>pI,WAKE_ESCALATION_COOLDOWN_MS:()=>vI,WAKE_MAX_RESTARTS:()=>SI,WAKE_NO_PROGRESS_MS:()=>PI,WIRE_ID_BACKDATE_MS:()=>Or,WIRE_ID_CLOCK_TOLERANCE:()=>De,WIRE_ID_TIME_MASK:()=>Pe,WIRE_ID_TIME_SCALE:()=>bt,WIRE_MESSAGE_ID:()=>vf,__getConfigResolver:()=>Ch,__setConfigResolver:()=>Rh,abortErrorReason:()=>_C,acceptAccountInvite:()=>ko,acceptInvite:()=>VC,actReviewItem:()=>yp,activateConnection:()=>Xa,addGroupMembers:()=>Ku,addMarketplaceSource:()=>Kp,advanceWakeEscalation:()=>CI,allDescendantIds:()=>Kf,appendPreviewToken:()=>ug,approveProjectAccessRequest:()=>Yo,approveTask:()=>vb,archiveProject:()=>Xn,assignTicket:()=>Mb,attachGroupToProject:()=>ca,authMfa:()=>Rr,authUser:()=>Sr,authenticatedFetch:()=>q,authorizePreviewUrl:()=>ZT,backendApi:()=>c,bindSlackIdentity:()=>fw,bindTeamsIdentity:()=>yw,brokerProjectSecretRequest:()=>xa,buildInstancePath:()=>Ky,buildPresentationTemplateImageUrl:()=>rI,buildPresentationTemplatePdfUrl:()=>nI,buildPreviewAuthEndpoint:()=>lg,buildPublicTemplateUrl:()=>th,buildRuntimePresentationConversionUrl:()=>lh,buildSandboxTemplate:()=>Ic,buildScrapeFailureResults:()=>gy,buildStaticFileHealthPreviewUrl:()=>OP,buildStaticFileLocalUrl:()=>$P,buildStaticFilePreviewUrl:()=>MP,buildStaticFileServicePath:()=>tf,buildTunnelEventStreamUrl:()=>yh,buildWebProxyUrl:()=>LP,bulkActReviewItems:()=>hp,bulkDeletePolicies:()=>Uw,bulkImportPolicies:()=>Fw,burstSummary:()=>Vv,burstSummaryLabel:()=>Jv,callConnector:()=>Ba,cancelAccountDeletion:()=>Sk,cancelAccountInvite:()=>bo,cancelSandbox:()=>GC,cancelSandboxUpdate:()=>cT,cancelScheduledChange:()=>Ql,cancelSubscription:()=>Vl,checkAccessEmail:()=>wT,childMapByParent:()=>vv,claimComputer:()=>gT,claimNext:()=>ff,claimPerSeatBilling:()=>uw,claimWarmProjectSession:()=>al,classifyPart:()=>Td,classifyPreviewProbeStatus:()=>ch,classifyPtyClose:()=>em,classifyTurn:()=>Of,cleanErrorMessage:()=>qv,cleanResultSnippet:()=>nA,cleanWorkerOutput:()=>vR,clearImpersonationSession:()=>Ii,clearKortixAppViewerCache:()=>bh,clearModelDefault:()=>$l,clearSessionFresh:()=>Lx,closeChangeRequest:()=>Vc,closeMilestone:()=>a_,collectTurnParts:()=>wv,commentTicket:()=>Ob,commitSessionChanges:()=>Qc,compactionExpiryAtMs:()=>wI,compactionTurnInfo:()=>Xv,compareMessagesForDisplay:()=>yv,completeInFlight:()=>yf,completeSlackInstall:()=>lu,completeTeamsInstall:()=>uu,computeStatusFromPart:()=>Vd,configureAutoTopup:()=>tu,configureKortix:()=>xn,confirmCheckoutSession:()=>Hl,connectEmail:()=>bu,connectSlack:()=>au,connectionIsFaulted:()=>oI,connectionSharedWithEveryone:()=>wx,connectorConnect:()=>Pm,connectorFinalize:()=>Sm,contextLabelForTool:()=>pA,contextToolSummary:()=>Yv,contextToolTrigger:()=>Zv,convertPresentationToGoogleSlides:()=>Ok,convertRuntimePresentation:()=>sI,copyFile:()=>Ft,costExportUrl:()=>ru,countLiveInboxPrompts:()=>mI,countReviewItemsBySegment:()=>qk,createAccount:()=>oo,createAccountAuditWebhook:()=>$p,createAccountSecretResource:()=>Ia,createAccountToken:()=>vp,createApp:()=>Vp,createAppAccessSession:()=>td,createAppDeployment:()=>rd,createArtifactKind:()=>MA,createAssignment:()=>up,createAuditWebhook:()=>fk,createBackup:()=>QC,createCheckoutSession:()=>Kl,createConnector:()=>dc,createFile:()=>Ut,createGatewayKey:()=>Du,createGroup:()=>Bu,createHttpSessionSyncController:()=>fh,createInstance:()=>uT,createKortix:()=>pf,createKortixPty:()=>Ki,createKortixSession:()=>Tr,createMarketplaceInstallSession:()=>Yk,createMilestone:()=>i_,createOAuthClient:()=>ip,createPerSeatCheckout:()=>lw,createPolicy:()=>Ow,createPortalSession:()=>zl,createProject:()=>jo,createProjectAgent:()=>Kb,createProjectCliToken:()=>Cp,createProjectRepo:()=>Mo,createProjectResourceGrant:()=>da,createProjectSession:()=>gt,createProjectTrigger:()=>Al,createPromptAttachmentController:()=>so,createRole:()=>Qu,createSSEStream:()=>hh,createSandbox:()=>OC,createSandboxShare:()=>kp,createSandboxTemplate:()=>Rc,createScimToken:()=>Nw,createServiceAccountApi:()=>pk,createSessionPrompt:()=>dl,createSessionPublicShare:()=>sl,createSessionQueue:()=>gf,createSsoGroupMapping:()=>nk,createTask:()=>kb,createTicket:()=>Ib,createTunnelEventStream:()=>LI,declineAccountInvite:()=>Po,declineInvite:()=>JC,deleteAccountImmediately:()=>vk,deleteAccountSecretResource:()=>ja,deleteApp:()=>Qp,deleteAuditWebhook:()=>hk,deleteBackup:()=>ZC,deleteConnector:()=>mc,deleteCredential:()=>m_,deleteEnv:()=>Gi,deleteFile:()=>Be,deleteGatewayBudget:()=>$u,deleteGitHubInstallation:()=>Vo,deleteGroup:()=>Nu,deleteInstance:()=>pT,deleteKortixProject:()=>e_,deleteMilestone:()=>l_,deleteOAuthClient:()=>cp,deletePersonalProjectSecret:()=>Ra,deletePolicy:()=>qw,deleteProjectAgent:()=>zb,deleteProjectProviderOAuth:()=>Pa,deleteProjectResourceGrant:()=>ga,deleteProjectSecret:()=>va,deleteProjectSession:()=>bl,deleteProjectTrigger:()=>Cl,deletePromptAttachment:()=>pt,deleteRole:()=>ep,deleteSandboxTemplate:()=>Tc,deleteServiceAccountApi:()=>gk,deleteSessionPrompt:()=>ml,deleteSsoGroupMapping:()=>rk,deleteSsoProvider:()=>ek,deleteTask:()=>Ab,deleteTicket:()=>Db,describeAccountInvite:()=>wo,describeConnectorTool:()=>La,detachGroupFromProject:()=>ua,detectLocalhostUrls:()=>Qm,disableServiceAccountApi:()=>dk,disconnectEmail:()=>_u,disconnectGitHubApp:()=>KT,disconnectSlack:()=>du,discoverConnectionOAuth2:()=>vx,discoverConnectionOAuth2Resource:()=>Ax,discoverConnectorAuth:()=>gc,discoverLocalSandbox:()=>FC,downloadAccountAudit:()=>qT,dropClientForUrl:()=>P_,dropPublicClientForUrl:()=>A_,editQueued:()=>xf,enqueue:()=>mf,ensurePmSession:()=>Nb,ensurePreviewSessionCookie:()=>ah,ensureProjectConnectorConnection:()=>kx,ensureSandbox:()=>Yy,ensureWarmProjectSession:()=>ol,env:()=>Yg,exchangeCode:()=>wr,exportAccountAudit:()=>jp,extractGatewayErrorDetails:()=>ue,extractInstanceRoute:()=>Pt,extractSkillBaseDir:()=>Dy,extractSkillContent:()=>FR,extractSkillFiles:()=>Oy,extractWorkerPreview:()=>RR,failInFlight:()=>hf,fallbackBusyRowAfterTurnId:()=>sR,familyForTool:()=>Hr,featureDisabledKey:()=>Si,featureFlags:()=>kC,fetchAccountStateWithToken:()=>aw,fetchAccountsWithToken:()=>sx,fetchAttachmentPart:()=>HT,fetchCostExportCsv:()=>mw,fetchKortixAppViewer:()=>fg,fetchProjectArchive:()=>Oc,fetchProjectsForAccountWithToken:()=>mx,fetchSessionAttachment:()=>bd,filePhase:()=>IR,fileVerb:()=>TR,files:()=>dm,finalizeAppArtifact:()=>pr,finalizeConnectorSetupLink:()=>CT,findActiveTranscriptShare:()=>Wx,findFiles:()=>Dt,findLastTextPart:()=>kv,findSessionAttachments:()=>fP,findText:()=>qt,fireProjectTrigger:()=>Il,fixSandboxWithAgent:()=>Ac,flattenThought:()=>BA,formatBillingErrorForUI:()=>Ai,formatCost:()=>xR,formatDuration:()=>hR,formatJsonFailureOutput:()=>Uv,formatMessageDay:()=>zA,formatMessageExact:()=>VA,formatOpenCodeRuntimeError:()=>Jy,formatRawOutput:()=>tA,formatRuntimeError:()=>Jy,formatTokens:()=>wR,formatTranscript:()=>kf,freshSendHint:()=>aR,generateSessionId:()=>df,getAccount:()=>ao,getAccountBranding:()=>lo,getAccountDeletionStatus:()=>kk,getAccountState:()=>Ul,getAccountStateMinimal:()=>Fl,getActiveInstanceIdFromCookie:()=>zy,getAdminProviderAnalytics:()=>Ik,getAdminProviderDistribution:()=>Rk,getAdminProviderFallback:()=>jk,getAdminRole:()=>Ak,getAgentCardLabel:()=>Ff,getAgentConfig:()=>ew,getAgentPersona:()=>Vb,getAllVersions:()=>iT,getAnsweredQuestionParts:()=>Sv,getApp:()=>Jp,getAppAccess:()=>Yp,getAppDeployment:()=>id,getAppDeploymentLogs:()=>od,getApprovalLink:()=>Qk,getAuthToken:()=>Xe,getAuthTokenWithRetry:()=>tb,getAutoTopupSettings:()=>eu,getAutoTopupSetupStatus:()=>cw,getBillingCreditBreakdown:()=>Gl,getBillingTierConfigurations:()=>Wl,getBillingTransactionsSummary:()=>Bl,getBillingUsageHistory:()=>Nl,getChangeRequest:()=>Nc,getChangeRequestDiff:()=>Wc,getChangeRequestMergePreview:()=>Kc,getChildSessionError:()=>av,getChildSessionId:()=>ov,getChildSessionToolParts:()=>cv,getClient:()=>je,getClientForUrl:()=>xe,getConnectStatus:()=>bc,getConnectionOAuth2Application:()=>Sx,getConnectionOAuth2Status:()=>Ex,getConnectionPolicies:()=>jx,getConnectorCatalog:()=>Ht,getConnectorConfig:()=>lc,getConnectorPolicies:()=>ac,getConnectorSetupLink:()=>AT,getCostSummary:()=>gw,getCurrentInstanceIdFromPathname:()=>Hy,getCurrentInstanceIdFromWindow:()=>vC,getCurrentProject:()=>Zi,getDefaultAccountState:()=>sr,getDiagnostics:()=>pv,getDirectory:()=>Uf,getDiscoverConnector:()=>er,getDiscoverIntegration:()=>Ux,getEmailInstallation:()=>yu,getEmailMode:()=>hu,getEnterpriseDemo:()=>_k,getFileStatus:()=>Ot,getFileWithDir:()=>Id,getFilename:()=>qf,getFullChangelog:()=>eh,getGatewayBreakdown:()=>Tu,getGatewayBudgets:()=>ju,getGatewayErrors:()=>Eu,getGatewayKeys:()=>Ou,getGatewayLog:()=>Au,getGatewayOverview:()=>Ru,getGatewayRoutingPolicy:()=>wu,getGatewaySeries:()=>Cu,getGatewaySessions:()=>Iu,getGitHubAppStatus:()=>BT,getGitHubInstallation:()=>Bo,getGoogleAuthUrl:()=>$k,getGroup:()=>Lu,getHiddenToolParts:()=>rv,getImpersonationSession:()=>Mg,getInvite:()=>zC,getJustavpsServerTypes:()=>lT,getKortixProject:()=>Qb,getKortixProjectBySession:()=>Yb,getKortixPtyWebSocketUrl:()=>Vi,getLatestSandboxVersion:()=>sT,getMaintenanceConfig:()=>MT,getManagedGitBackend:()=>Jo,getManagedGitStatus:()=>ux,getMarketplaceCatalogItem:()=>Gp,getMarketplaceCatalogItemFile:()=>Np,getMfaRequired:()=>Kw,getMilestone:()=>r_,getModelDefaults:()=>jl,getOAuthClient:()=>sp,getOAuthConsentRequest:()=>ST,getOpenCodeConfigInvalidError:()=>ng,getPartText:()=>ev,getPatPolicy:()=>ck,getPermissionForTool:()=>dv,getProject:()=>Kn,getProjectActivity:()=>Jb,getProjectCommit:()=>Uc,getProjectCommitDiff:()=>Fc,getProjectDetail:()=>Hn,getProjectFileHistory:()=>Lc,getProjectGitToken:()=>Eo,getProjectLlmCatalog:()=>zn,getProjectLlmCatalogProviders:()=>ax,getProjectModelAccess:()=>dr,getProjectModelPicker:()=>Vn,getProjectSandboxHealth:()=>tr,getProjectSandboxProviderTransition:()=>px,getProjectSession:()=>nr,getProjectSessionConfigState:()=>_l,getProjectSessionScope:()=>kl,getProrationPreview:()=>Yl,getProviders:()=>MC,getProxyBaseUrl:()=>DP,getPublicClientForUrl:()=>v_,getPublicMarketplaceItem:()=>_T,getPublicMarketplaceItemFile:()=>xT,getPublicSessionShare:()=>Jk,getPublicSessionShareMessages:()=>Xk,getPublicShareByToken:()=>ET,getPublicTemplate:()=>LT,getQuestionForTool:()=>gv,getReferralCode:()=>Sw,getReferralStats:()=>Rw,getRetryInfo:()=>kR,getRetryMessage:()=>PR,getReviewItem:()=>mp,getRolePermissions:()=>Ju,getRoleUsage:()=>Xu,getSSHConnection:()=>tT,getSandbox:()=>$C,getSandboxById:()=>DC,getSandboxPortUrl:()=>jC,getSandboxProvisionStatus:()=>mT,getSandboxProvisionStreamUrl:()=>fT,getSandboxUpdateStatus:()=>rT,getSandboxUrl:()=>ig,getSecretSetupLink:()=>TT,getServerHealth:()=>Bn,getServiceLogs:()=>__,getSessionAudit:()=>cl,getSessionCost:()=>_R,getSessionCostRecord:()=>ar,getSessionHealth:()=>xd,getSessionOpenBundle:()=>Kx,getSessionOversight:()=>Vw,getSessionPolicy:()=>sk,getSessionPreviewCandidates:()=>nl,getSessionProviderSecretPool:()=>Da,getSessionTranscript:()=>ll,getSessionTranscriptSync:()=>ul,getSessionTurn:()=>pl,getShellModePart:()=>lR,getSlackChannelFile:()=>gu,getSlackInstallation:()=>ou,getSlackManifest:()=>pu,getSlackMode:()=>cu,getSsoProvider:()=>Xw,getStaticFileHealthPath:()=>nf,getSupabaseAccessToken:()=>En,getSupabaseAccessTokenWithRetry:()=>Je,getTask:()=>_b,getTaskStatus:()=>wb,getTemplate:()=>Zk,getTicket:()=>Cb,getToolInfo:()=>lv,getToolPrimaryArg:()=>Nr,getTranscriptFilename:()=>Pf,getTurnCost:()=>bR,getTurnError:()=>gR,getTurnErrorDetails:()=>fR,getTurnErrorRawText:()=>mR,getTurnStatus:()=>yR,getUsageRollup:()=>nu,getUserRolesWithToken:()=>OT,getVersionDiff:()=>Bc,getWorkingState:()=>pR,grantAccountSecretResource:()=>Ma,grantSandboxProjectAccess:()=>KC,grantSecretToAgent:()=>sw,groupMessagesIntoTurns:()=>bv,groupShowSegments:()=>QA,groupSteps:()=>Hd,hasDiffs:()=>SR,hasLocalhostUrls:()=>IP,hasPreviewTarget:()=>ef,hasRetryingAssistantTurn:()=>Rv,heartbeatGapEvent:()=>cf,holdSessionPrompts:()=>yl,humanizeReviewActionPath:()=>xp,humanizeSearchQuery:()=>cn,humanizeToolName:()=>Ur,impersonationHeaders:()=>Ei,importSsoProviderFromMetadata:()=>Yw,inboxObservationSupersedes:()=>gI,initialWakeEscalationState:()=>gg,installTemplate:()=>eP,invalidateTokenCache:()=>jn,inviteAccountMember:()=>yo,inviteProjectMember:()=>ra,inviteRepoCollaborator:()=>To,isAbortError:()=>gn,isAdminBypassEnabled:()=>Ug,isAgentPart:()=>XS,isAppRouteUrl:()=>Xm,isAttachment:()=>tv,isAttachmentPartRef:()=>rh,isBillingError:()=>vi,isCompactionPart:()=>QS,isConfigured:()=>wn,isContextTool:()=>Qv,isDestructivePhase:()=>nT,isEmptyShowPart:()=>mr,isErrorOutput:()=>jv,isExternalUrl:()=>NP,isFeatureDisabledError:()=>Pi,isFilePart:()=>Ed,isImpersonationSessionLive:()=>Eg,isInstanceDetailPath:()=>PC,isInstanceScopedAppPath:()=>Wy,isInternalLocalhostUrl:()=>FP,isInvisibleActivityPart:()=>dd,isInviteSent:()=>hx,isLastUserMessage:()=>uR,isManagedGithubProject:()=>ox,isNoGroupActivityTool:()=>pd,isOpenCodeConfigInvalidError:()=>TC,isPatchPart:()=>ZS,isPreviewUrl:()=>UP,isProxiableLocalhostUrl:()=>rf,isQuestionTool:()=>oP,isReasoningPart:()=>me,isRetryableTurnError:()=>Hf,isRuntimeReady:()=>_P,isSandboxNotReadyError:()=>yn,isServerReachable:()=>eo,isSessionAttachmentRef:()=>pP,isSessionFresh:()=>Zc,isSessionStartError:()=>Vx,isShellActivityTool:()=>iP,isShellMode:()=>Cy,isShortOutput:()=>AR,isShowContentUnavailable:()=>rP,isShowPayloadEmpty:()=>Xt,isSnapshotPart:()=>YS,isStandaloneActivityTool:()=>gd,isSubdomainPreviewUrl:()=>bn,isTextPart:()=>ge,isToolPart:()=>Z,isToolPartHidden:()=>sv,isUnderSandboxRoot:()=>Qi,isWebProxyUrl:()=>GP,isWireIdAheadOf:()=>Af,kortixAppViewerToken:()=>_h,kortixPty:()=>rm,leaveAccount:()=>Ao,linkGitHubInstallation:()=>zo,linkRepository:()=>Fo,listAccountAudit:()=>Ip,listAccountAuditWebhooks:()=>Mp,listAccountInvites:()=>ho,listAccountMembers:()=>fo,listAccountResourceGrants:()=>Mw,listAccountSecretResources:()=>Ta,listAccountSessions:()=>ok,listAccountTokens:()=>Sp,listAccounts:()=>io,listActions:()=>Lw,listAdminSandboxes:()=>Ck,listAgentIdentities:()=>Vu,listAllConnections:()=>Ka,listAppAgents:()=>Zp,listAppDeployments:()=>sd,listApps:()=>zp,listAssignments:()=>lp,listAuditEvents:()=>bk,listAuditWebhooks:()=>mk,listBackups:()=>XC,listBillingTransactions:()=>Ll,listChangeRequests:()=>Gc,listChannelBindings:()=>ww,listColumns:()=>qb,listConnectSections:()=>Dx,listConnectToolkits:()=>Ox,listConnections:()=>Wa,listConnectorAccounts:()=>Ga,listConnectorTools:()=>Yn,listConnectors:()=>nc,listCostByProject:()=>dw,listCredentialEvents:()=>p_,listCredentials:()=>u_,listDiscoverConnectors:()=>Zn,listDiscoverIntegrations:()=>qx,listDiscoverSections:()=>hc,listEnv:()=>Li,listFeaturedMarketplaces:()=>Bp,listFields:()=>Fb,listFiles:()=>it,listGatewayLogs:()=>vu,listGitHubInstallations:()=>Go,listGitHubRepositories:()=>Wo,listGitHubRepositoryBranches:()=>Ko,listGroupMembers:()=>Wu,listGroupProjectGrants:()=>Iw,listGroups:()=>Fu,listKortixProjectSessions:()=>Zb,listKortixProjects:()=>Xb,listKortixPty:()=>Wi,listLinkableGitHubInstallations:()=>No,listManagedGitRepositories:()=>Xo,listMarketplaceCatalogItems:()=>Fp,listMarketplaceSources:()=>Wp,listMarketplaces:()=>Lp,listMemberGroups:()=>Ew,listMemberProjectAccess:()=>jw,listMilestoneEvents:()=>s_,listMilestones:()=>n_,listMyAccountInvites:()=>xo,listOAuthClients:()=>rp,listPendingApprovals:()=>ma,listPendingProjectInvites:()=>sa,listPermissions:()=>dp,listPipedreamApps:()=>fc,listPipedreamSections:()=>yc,listPolicies:()=>$w,listProjectAccess:()=>ea,listProjectAccessRequests:()=>Qo,listProjectAgents:()=>Wb,listProjectAudit:()=>Ep,listProjectBranches:()=>Dc,listProjectCliTokens:()=>Rp,listProjectCommits:()=>qc,listProjectFiles:()=>jc,listProjectGroupGrants:()=>aa,listProjectPolicies:()=>wc,listProjectResourceGrants:()=>pa,listProjectSandboxTemplates:()=>Pc,listProjectSandboxes:()=>Ec,listProjectSecrets:()=>ha,listProjectSessions:()=>dt,listProjectSessionsPage:()=>el,listProjectSnapshots:()=>Sc,listProjectTriggers:()=>vl,listProjects:()=>Ge,listProjectsForAccount:()=>Co,listPublicMarketplaceItems:()=>hT,listPublicMarketplaces:()=>bT,listReferrals:()=>Cw,listReviewItems:()=>gp,listRoles:()=>zu,listSandboxProjectMembers:()=>WC,listSandboxShares:()=>wp,listSandboxes:()=>UC,listScimTokens:()=>Gw,listServiceAccountsApi:()=>uk,listServiceTemplates:()=>b_,listServices:()=>h_,listSessionConnectRequests:()=>$x,listSessionCosts:()=>iu,listSessionPrompts:()=>gl,listSessionProviderSecretPools:()=>qa,listSessionPublicShares:()=>rl,listSessionsNeedingInput:()=>fa,listSsoGroupMappings:()=>tk,listTaskEvents:()=>xb,listTasks:()=>bb,listTemplates:()=>Bb,listTicketEvents:()=>Tb,listTickets:()=>Rb,loadHttpSessionHistory:()=>mh,looksLikeError:()=>qd,looksLikeHtml:()=>oA,looksLikeJsonPayload:()=>eA,mapApiReviewItem:()=>Vk,markInstanceError:()=>dT,markSessionFresh:()=>zt,maxWireIdClock:()=>Sd,memoryRelPath:()=>jR,mergeBurstSteps:()=>UA,mergeChangeRequest:()=>zc,messageCreatedAt:()=>GA,messageTime:()=>vy,migrateAdminSandboxProvider:()=>Ek,mintWireMessageId:()=>Tf,mintWireMessageIdAbove:()=>vd,mkdir:()=>lt,narrateFailedStep:()=>Kd,narrateStep:()=>Wd,narrationToolName:()=>pn,narrowChatEvent:()=>lf,newestWireIdClock:()=>Rf,normalizeActivityToolName:()=>ae,normalizeAppPathname:()=>CC,normalizeExternalInput:()=>WP,normalizeName:()=>H,normalizeToolName:()=>tn,openChangeRequest:()=>Hc,openEventStream:()=>Mr,openStressTestStream:()=>UT,parseBillingError:()=>Ct,parseEmbeddedFailure:()=>rA,parseFlagOverride:()=>wC,parseJsonFailure:()=>ay,parseLocalhostUrl:()=>Zt,parseMemoryView:()=>MR,parseOpenCodeErrorPayload:()=>Vy,parsePresentationOutput:()=>DR,parseProxyHop:()=>_d,parseQuestionAnswersFromOutput:()=>qR,parseReadOutput:()=>UR,parseScrapeInputUrls:()=>dy,parseScrapeOutput:()=>my,parseSubdomainUrl:()=>kd,parseTaskRows:()=>CR,parseWebProxyUrl:()=>BP,parseWebSearchOutput:()=>Gd,partOutcome:()=>Ud,patchKortixProject:()=>t_,patchVerb:()=>OR,pipedreamConnect:()=>pc,pipedreamConnectConnection:()=>ec,pipedreamFinalize:()=>xc,pipedreamFinalizeConnection:()=>tc,platformConfig:()=>$,pollConnectionOAuth2DeviceAuthorization:()=>Ix,pollProjectProviderOAuth:()=>ka,previewGatewayRoute:()=>Su,previewMfaRequired:()=>Hw,previewSlackIdentity:()=>hw,previewTeamsIdentity:()=>bw,probeEffectivePermission:()=>tp,probeEffectivePermissions:()=>np,probePreviewPort:()=>tI,projectCompacting:()=>xI,projectSessionConnection:()=>iI,projectSessionStartSeed:()=>zx,projectWorking:()=>fI,provisionProject:()=>$o,provisionProjectStream:()=>lx,provisionProjectWithToken:()=>fx,proxyLocalhostUrl:()=>wd,proxyUrlToInternal:()=>qP,purchaseCredits:()=>Zl,putConnectionOAuth2Application:()=>Px,rawErrorText:()=>Cd,reactivateSandbox:()=>NC,reactivateSubscription:()=>Jl,readBlob:()=>at,readFile:()=>ot,readProjectFile:()=>$c,reasoningIsRunning:()=>xy,rebuildProjectSnapshot:()=>vc,reconcileConnection:()=>Ha,reconcileMemberConnection:()=>za,reconcileServices:()=>w_,recordPlatformLogout:()=>PT,recoverLinkResults:()=>Wr,refreshReferralCode:()=>vw,refreshSession:()=>yt,registerAppArtifact:()=>ur,registerConnectionOAuth2Client:()=>Rx,registerService:()=>k_,rejectProjectAccessRequest:()=>Zo,relativizePath:()=>uv,reloadProjectSessionConfig:()=>xl,reloadProjectSessionConfigStream:()=>wl,removeAccountAuditWebhook:()=>Dp,removeAccountBrandingAsset:()=>go,removeAccountMember:()=>So,removeGroupMember:()=>Hu,removeKortixPty:()=>zi,removeMarketplaceSource:()=>Hp,removeQueued:()=>_f,renameConnection:()=>Ya,renameFile:()=>Bt,renameSandbox:()=>qC,reopenChangeRequest:()=>Jc,reopenMilestone:()=>c_,reorderQueued:()=>wf,replaceColumns:()=>Ub,replaceFields:()=>Lb,replaceProjectRepository:()=>Lo,replaceTemplates:()=>Gb,requestAccountDeletion:()=>Pk,requestChangesOnChangeRequest:()=>Xc,requestProjectAccess:()=>yx,requestProjectConnector:()=>Up,requestProjectSecret:()=>qp,resendAccountInvite:()=>_o,resendPendingProjectInvite:()=>oa,resetAccountBranding:()=>mo,resetClient:()=>S_,resetGatewayRoutingPolicy:()=>Pu,resetPassword:()=>kr,resetPublicClient:()=>R_,resetSandboxUpdateStatus:()=>aT,resolveApproval:()=>ya,resolveScrapeResults:()=>aA,resolveWorkingTurn:()=>cR,resolvedPlan:()=>ow,restartProjectSession:()=>Vt,restartSandbox:()=>LC,restoreBackup:()=>YC,retryFailed:()=>bf,retrySessionPrompt:()=>fl,revealCredential:()=>g_,reviewItemTarget:()=>Dk,reviewSegmentForStatus:()=>Fm,reviewVerdictForStatus:()=>Uk,revokeAccountSecretResourceGrant:()=>$a,revokeAccountSession:()=>ak,revokeAccountToken:()=>Ap,revokeAssignment:()=>pp,revokeConnection:()=>Ja,revokeGatewayKey:()=>qu,revokePendingProjectInvite:()=>ia,revokeProjectAccess:()=>na,revokeProjectCliToken:()=>Tp,revokeSandboxProjectAccess:()=>HC,revokeSandboxShare:()=>Pp,revokeScimToken:()=>Ww,revokeSessionPublicShare:()=>il,rewriteLocalhostUrl:()=>$e,rollbackApp:()=>ld,rotateAccountSecretResource:()=>Ea,rotateOAuthClientSecret:()=>ap,runGatewayPlayground:()=>Uu,sanitizePtyChunk:()=>nm,saveGitHubInstallation:()=>Ho,scheduleDowngrade:()=>Xl,searchConnectorTools:()=>Fa,searchProjectFiles:()=>Mc,segmentTurn:()=>JA,sendMagicLink:()=>br,sendReferralEmails:()=>Tw,serverCompactionRevalidateAtMs:()=>kI,serviceAction:()=>x_,sessionParentId:()=>Bx,sessionStartKey:()=>Xx,setAccountSecretResourceAccess:()=>Oa,setActiveInstanceCookie:()=>AC,setAdminBypass:()=>qg,setAdminProviderDistribution:()=>Tk,setAdminProviderFallback:()=>Mk,setAgentScope:()=>Ol,setBootstrapAuthToken:()=>eb,setCachedAuthToken:()=>Zh,setConnectionPolicies:()=>Mx,setConnectorAuthorizationStrategy:()=>ic,setConnectorCredential:()=>_c,setConnectorCredentialMode:()=>sc,setConnectorName:()=>uc,setConnectorPolicies:()=>cc,setConnectorSecretBinding:()=>Fx,setConnectorSensitive:()=>oc,setDefaultConnection:()=>Qa,setEnterpriseDemo:()=>xk,setEnv:()=>Bi,setGatewayBudget:()=>Mu,setGatewayRoutingPolicy:()=>ku,setGitHubAppFromExisting:()=>NT,setGitHubAppPat:()=>WT,setImpersonationSession:()=>Vh,setMaintenanceConfig:()=>$T,setMemberSuperAdmin:()=>Bw,setMfaRequired:()=>zw,setModelDefault:()=>Ml,setPersonalProjectSecret:()=>Aa,setProjectModelAccess:()=>gr,setProjectModelEnablement:()=>Qx,setProjectOnboardingComplete:()=>Uo,setProjectOnboardingProfile:()=>gx,setProjectPolicies:()=>kc,setProjectSecretStrategy:()=>_a,setProjectSessionModel:()=>Sl,setProjectSessionScope:()=>Pl,setProjectSessionSharing:()=>tl,setProjectTriggersActivation:()=>Tl,setSessionOversight:()=>Jw,setSessionProviderSecretPool:()=>Ua,setupSSH:()=>eT,shareConnection:()=>Za,shellActivityGroupLabel:()=>aP,shellExitCode:()=>Yd,shouldAttachImpersonation:()=>$g,shouldHideResponsePart:()=>dR,shouldShowToolPart:()=>Df,shouldSuppressWorkingTurnBusy:()=>nR,showGroupItems:()=>eR,showTurnBusyIndicator:()=>zd,signInWithPassword:()=>hr,signInWithProvider:()=>xr,signInWithSso:()=>Ar,signOut:()=>Cr,signUp:()=>yr,skillDocumentPath:()=>KR,skillInputDir:()=>GR,sortSessions:()=>Av,splitUserParts:()=>nv,startApp:()=>ad,startConnectionOAuth2Authorization:()=>Cx,startConnectionOAuth2DeviceAuthorization:()=>Tx,startConnectorSetupLink:()=>RT,startGitHubAppManifest:()=>GT,startProjectProviderOAuth:()=>wa,startProjectSession:()=>Ne,startSessionWithToken:()=>jT,startTask:()=>Sb,stepLabel:()=>Fd,stopApp:()=>cd,stopProjectSession:()=>Jt,stopSandbox:()=>BC,stripAnsi:()=>fv,stripInstancePrefix:()=>SC,stripTrailingSlashes:()=>_e,submitAccessRequest:()=>kT,submitDemoRequest:()=>DT,submitOAuthConsent:()=>vT,submitReviewItem:()=>fp,submitSecretSetupLink:()=>IT,subscribeToImpersonation:()=>Jh,supabaseClient:()=>mb,syncConnectors:()=>rc,syncSubscription:()=>pw,systemReload:()=>T_,toDaemonPath:()=>Le,toInstanceAwarePath:()=>RC,toInternalUrl:()=>sf,toSandboxAbsolutePath:()=>st,toWorkspaceRelative:()=>Yi,toolInfo:()=>Fr,toolViewModel:()=>Ly,triggerSandboxUpdate:()=>oT,triggersRequest:()=>Zg,turnEndCause:()=>uh,turnEndNotice:()=>bI,turnHasSteps:()=>Pv,turnIsConfirmedActive:()=>iR,unassignTicket:()=>$b,unwrapError:()=>ce,updateAccountAuditWebhook:()=>Op,updateAccountBranding:()=>uo,updateAccountMemberRole:()=>vo,updateAccountName:()=>co,updateAgentConfig:()=>tw,updateApp:()=>Xp,updateAppAccess:()=>ed,updateAuditWebhook:()=>yk,updateChannelBinding:()=>kw,updateConnectionCredential:()=>Va,updateEmailPolicy:()=>xu,updateExperimentalFeature:()=>Do,updateFeatureFlag:()=>Oo,updateGroup:()=>Gu,updateKortixPty:()=>Hi,updateMilestone:()=>o_,updateOAuthClient:()=>op,updatePassword:()=>Pr,updatePatPolicy:()=>lk,updatePolicy:()=>Dw,updateProject:()=>Jn,updateProjectAccess:()=>ta,updateProjectAgent:()=>Hb,updateProjectDefaultAgent:()=>ql,updateProjectGroupGrant:()=>la,updateProjectSandboxProvider:()=>qo,updateProjectSession:()=>hl,updateProjectTrigger:()=>Rl,updateRole:()=>Yu,updateRolePermissions:()=>Zu,updateSandboxTemplate:()=>Cc,updateSessionPolicy:()=>ik,updateTask:()=>Pb,updateTemplateWarmPool:()=>dx,updateTicket:()=>Eb,updateTicketStatus:()=>jb,updateUserMetadata:()=>vr,uploadAccountBrandingAsset:()=>po,uploadAppArtifactArchive:()=>nd,uploadConnectorAttachment:()=>Na,uploadFile:()=>ct,uploadPromptAttachment:()=>Wt,uploadSessionAttachment:()=>hd,uploadSlackChannelFile:()=>mu,uploadTimeoutMsForBytes:()=>tt,upsertCredential:()=>d_,upsertProjectGitCredential:()=>Sa,upsertProjectSecret:()=>ba,upsertSsoProvider:()=>Qw,validateProjectManifest:()=>Io,validateReferralCode:()=>Aw,validateToken:()=>Ro,verifyGatewayProvider:()=>Pw,verifyOtp:()=>_r,verifySsoDomain:()=>Zw,wakeEscalationAttemptSummary:()=>jI,wakeEscalationNote:()=>II,wakeProgressFingerprint:()=>AI,wireIdClock:()=>We,wireIdClockAt:()=>_t,wireIdClockDelta:()=>Ke,workingExpiryAtMs:()=>yI,workingTurnDrawsBusyRow:()=>oR,writeActivityGroupLabel:()=>cP,writeFile:()=>Lt,wsDomain:()=>Kr,wsFavicon:()=>iA,wsRootDomain:()=>sA});var Ah={backendUrl:"",getToken:async()=>null},rs=null,_n=null;function Rh(e){_n=e}function Ch(){return _n}function xn(e,t){t?.global!==!1&&(rs=e)}function $(){return _n?.()??rs??Ah}function wn(){return rs!==null||_n?.()!==void 0}var yg=({onRequest:e,onSseError:t,onSseEvent:n,responseTransformer:r,responseValidator:s,sseDefaultRetryDelay:i,sseMaxRetryAttempts:o,sseMaxRetryDelay:a,sseSleepFn:p,url:g,...m})=>{let h,_=p??(P=>new Promise(M=>setTimeout(M,P)));return{stream:async function*(){let P=i??3e3,M=0,k=m.signal??new AbortController().signal;for(;!k.aborted;){M++;let d=m.headers instanceof Headers?m.headers:new Headers(m.headers);h!==void 0&&d.set("Last-Event-ID",h);try{let y={redirect:"follow",...m,body:m.serializedBody,headers:d,signal:k},l=new Request(g,y);e&&(l=await e(g,y));let R=await(m.fetch??globalThis.fetch)(l);if(!R.ok)throw new Error(`SSE failed: ${R.status} ${R.statusText}`);if(!R.body)throw new Error("No body in SSE response");let I=R.body.pipeThrough(new TextDecoderStream).getReader(),O="",N=()=>{try{I.cancel()}catch{}};k.addEventListener("abort",N);try{for(;;){let{done:E,value:K}=await I.read();if(E)break;O+=K,O=O.replace(/\r\n/g,`
|
|
2
2
|
`).replace(/\r/g,`
|
|
3
3
|
`);let F=O.split(`
|
|
4
4
|
|
|
@@ -10,14 +10,14 @@
|
|
|
10
10
|
|
|
11
11
|
`);for(;m!==-1;){let h=o.slice(0,m);o=o.slice(m+2),m=o.indexOf(`
|
|
12
12
|
|
|
13
|
-
`);let _=cx(h);if(_){if(t(_),_.type==="error")throw new S(_.error,{status:_.status,code:_.code});_.type==="done"&&(a=_.project)}}}}finally{s.cancel().catch(()=>{})}if(!a)throw new Error("Provision stream ended without a result");return a}async function ux(){try{return u(await c.get("/projects/managed-git/status",{showErrors:!1}))}catch{return{configured:!1,provider:"github"}}}async function Jn(e,t){return u(await c.patch(`/projects/${e}`,t))}async function Oo(e,t,n){return u(await c.patch(`/projects/${e}/features`,{feature:t,enabled:n}))}async function Do(e,t,n){return u(await c.patch(`/projects/${e}/experimental`,{feature:t,enabled:n}))}async function qo(e,t){return u(await c.patch(`/projects/${e}/sandbox-provider`,{provider:t}))}async function px(e,t){return u(await c.get(`/projects/${e}/sandbox-provider/transition`,{showErrors:!1,...t}))}async function dx(e,t){throw W("updateTemplateWarmPool")}async function Uo(e,t){return u(await c.patch(`/projects/${e}/onboarding`,{completed:t}))}async function gx(e,t){return u(await c.patch(`/projects/${e}/onboarding`,{profile:t}))}async function Xn(e){return u(await c.delete(`/projects/${e}`))}async function mx(e,t){return ut(e,`/v1/projects?account_id=${encodeURIComponent(t)}`)}async function fx(e,t){if(!e.backendUrl||!e.accessToken)return{ok:!1,limitReached:!1};let n=no(e.backendUrl);try{let r=await fetch(`${n}/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(r.ok){let s=await r.json().catch(()=>null);return s?.project_id?{ok:!0,project:s}:{ok:!1,limitReached:!1}}return r.status===403?{ok:!1,limitReached:(await r.json().catch(()=>null))?.code==="project_limit_reached"}:{ok:!1,limitReached:!1}}catch{return{ok:!1,limitReached:!1}}}async function Fo(e){return u(await c.post("/projects/link-repository",e,{showErrors:!1}))}async function Lo(e){let{project_id:t,...n}=e;return u(await c.put(`/projects/${encodeURIComponent(t)}/git/repository`,n,{showErrors:!1}))}async function Bo(e){return u(await c.get(`/projects/github/installation?account_id=${encodeURIComponent(e)}`,{showErrors:!1}))}async function Go(e){return u(await c.get(`/projects/github/installations?account_id=${encodeURIComponent(e)}`,{showErrors:!1}))}async function No(e){return u(await c.post("/projects/github/installations/linkable",e,{showErrors:!1}))}async function Wo(e,t,n){let r=new URLSearchParams({account_id:e});t&&r.set("installation_id",t);let s=n?.search?.trim();return s&&r.set("search",s),n?.limit!==void 0&&r.set("limit",String(n.limit)),u(await c.get(`/projects/github/repositories?${r.toString()}`,{showErrors:!1}))}async function Ko(e,t,n){let r=new URLSearchParams({account_id:e,installation_id:t,repo_full_name:n});return u(await c.get(`/projects/github/repository-branches?${r.toString()}`,{showErrors:!1}))}async function Ho(e){return u(await c.post("/projects/github/installation",e,{showErrors:!1}))}async function zo(e){return u(await c.post("/projects/github/installations/link",e,{showErrors:!1}))}async function Vo(e,t){let n=new URLSearchParams({account_id:e});return t&&n.set("installation_id",t),u(await c.delete(`/projects/github/installation?${n.toString()}`))}async function Jo(){return u(await c.get("/projects/git/backend",{showErrors:!1}))}async function Xo(e){let t=new URLSearchParams,n=e?.search?.trim();n&&t.set("search",n),e?.limit!==void 0&&t.set("limit",String(e.limit));let r=t.toString();return u(await c.get(`/projects/git/backend/repositories${r?`?${r}`:""}`,{showErrors:!1}))}async function yx(e,t){return u(await c.post(`/projects/${e}/access-requests`,{message:t?.trim()||void 0},{showErrors:!1}))}async function Qo(e,t){return u(await c.get(`/projects/${e}/access-requests`,t))}async function Yo(e,t,n="member"){return u(await c.post(`/projects/${e}/access-requests/${t}/approve`,{role:n}))}async function Zo(e,t){return u(await c.post(`/projects/${e}/access-requests/${t}/reject`,{}))}async function ea(e){return u(await c.get(`/projects/${e}/access`))}async function ta(e,t,n){return u(await c.put(`/projects/${e}/access/${t}`,{role:n}))}async function na(e,t){return u(await c.delete(`/projects/${e}/access/${t}`))}function hx(e){return"status"in e&&e.status==="invited"}async function ra(e,t,n,r){return u(await c.post(`/projects/${e}/access/invite`,{email:t,role:n,...r!==void 0?{expires_at:r}:{}}))}async function sa(e){return u(await c.get(`/projects/${e}/access/pending-invites`))}async function ia(e,t){return u(await c.delete(`/projects/${e}/access/pending-invites/${t}`))}async function oa(e,t){return u(await c.post(`/projects/${e}/access/pending-invites/${t}/resend`))}async function aa(e){return u(await c.get(`/projects/${e}/group-grants`))}async function ca(e,t,n,r){return u(await c.post(`/projects/${e}/group-grants`,r===void 0?{group_id:t,role:n}:{group_id:t,role:n,expires_at:r}))}async function la(e,t,n,r){return u(await c.patch(`/projects/${e}/group-grants/${t}`,r===void 0?{role:n}:{role:n,expires_at:r}))}async function ua(e,t){return u(await c.delete(`/projects/${e}/group-grants/${t}`))}async function pa(e){return u(await c.get(`/projects/${e}/resource-grants`))}async function da(e,t){return u(await c.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 ga(e,t){return u(await c.delete(`/projects/${e}/resource-grants/${t}`))}async function ma(e,t){return u(await c.get(`/projects/${e}/approvals`,{showErrors:t?.showErrors}))}async function fa(e,t){return u(await c.get(`/projects/${e}/approvals/needs-input`,{showErrors:t?.showErrors}))}async function ya(e,t,n){return u(await c.post(`/projects/${e}/approvals/${t}`,{decision:n}))}async function ha(e){return u(await c.get(`/projects/${e}/secrets`,{showErrors:!1}))}async function ba(e,t){return u(await c.post(`/projects/${e}/secrets`,t))}async function _a(e,t,n,r={}){return u(await c.put(`/projects/${e}/secrets/${encodeURIComponent(t)}/strategy`,{strategy:n,...r}))}async function xa(e,t,n){return u(await c.post(`/projects/${e}/secrets/${encodeURIComponent(t)}/broker`,n))}async function wa(e,t,n){return u(await c.post(`/projects/${e}/oauth/${t}/start`,{sharing:n?.sharing,...n?.resourceLabel===void 0?{}:{resource_label:n.resourceLabel},...n?.resourceId===void 0?{}:{resource_id:n.resourceId}}))}async function ka(e,t,n){return u(await c.post(`/projects/${e}/oauth/${t}/poll`,{flow_id:n}))}async function Pa(e,t){return u(await c.delete(`/projects/${e}/oauth/${encodeURIComponent(t)}`))}async function Sa(e,t){return u(await c.put(`/projects/${e}/git-credential`,t))}async function va(e,t){return u(await c.delete(`/projects/${e}/secrets/${encodeURIComponent(t)}`))}async function Aa(e,t,n){return u(await c.put(`/projects/${e}/secrets/${encodeURIComponent(t)}/personal`,n))}async function Ra(e,t){return u(await c.delete(`/projects/${e}/secrets/${encodeURIComponent(t)}/personal`))}var Ca=e=>`/accounts/${encodeURIComponent(e)}/secret-resources`,Kt=(e,t)=>`${Ca(e)}/${encodeURIComponent(t)}`,km=(e,t,n)=>`/projects/${encodeURIComponent(e)}/sessions/${encodeURIComponent(t)}/provider-secret-pools/${encodeURIComponent(n)}`;async function Ta(e,t){let n=t?`?project_id=${encodeURIComponent(t)}`:"";return u(await c.get(`${Ca(e)}${n}`))}async function Ia(e,t){return u(await c.post(Ca(e),t))}async function Ea(e,t,n){return u(await c.put(`${Kt(e,t)}/value`,{value:n}))}async function ja(e,t){return u(await c.delete(Kt(e,t)))}async function Ma(e,t,n,r){return u(await c.put(`${Kt(e,t)}/grants/${encodeURIComponent(n)}`,{},r))}async function $a(e,t,n,r){return u(await c.delete(`${Kt(e,t)}/grants/${encodeURIComponent(n)}`,r))}async function Oa(e,t,n,r){return u(await c.put(`${Kt(e,t)}/access`,{mode:n,user_ids:r}))}async function Da(e,t,n){return u(await c.get(km(e,t,n)))}async function qa(e,t){let n=`/projects/${encodeURIComponent(e)}/sessions/${encodeURIComponent(t)}/provider-secret-pools`;return u(await c.get(n))}async function Ua(e,t,n,r){return u(await c.put(km(e,t,n),{secret_ids:r}))}function Qn(e,t){return e?`/connectors/projects/${encodeURIComponent(e)}/${t}`:`/connectors/${t}`}async function Yn(e){return u(await c.get(Qn(e,"catalog"))).connectors??[]}async function Ht(e){let t=[];for(let n of await Yn(e))for(let r of n.actions)t.push({tool:`${n.slug}.${r.path}`,connector:n.slug,action:r.path,risk:r.risk,description:r.description||r.name,inputSchema:r.inputSchema});return t}async function Fa(e,t="",n={}){let r=t.trim().toLowerCase(),s=r.split(/\s+/).filter(Boolean),i=[],o=[];for(let a of await Ht(e)){let p=`${a.tool} ${a.description}`.toLowerCase();!r||p.includes(r)?i.push(a):s.every(g=>p.includes(g))&&o.push(a)}return[...i,...o].slice(0,n.limit??20)}async function La(e,t){return(await Ht(e)).find(n=>n.tool===t)??null}function bx(e){let t=e.indexOf("."),n=t<0?"":e.slice(0,t).trim(),r=t<0?"":e.slice(t+1).trim();if(!n||!r)throw new Error("tool must use the connector.action format");return{connector:n,action:r}}async function Ba(e,t,n={},r={}){let{connector:s,action:i}=bx(t),o=r.account?.trim();return u(await c.post(Qn(e,"call"),{connector:s,action:i,args:n,...o?{account:o}:{}}))}async function Ga(e,t){let n=await c.get(Qn(e,`connectors/${encodeURIComponent(t)}/accounts`));return u(n).accounts??[]}function _x(e,t){if(e&&typeof e=="object"){let n=e;for(let r of["reason","error","message","detail"])if(typeof n[r]=="string"&&n[r])return n[r]}return`HTTP ${t}`}function xx(e){let t=e.length;for(;t>0&&e.charCodeAt(t-1)===47;)t-=1;return t===e.length?e:e.slice(0,t)}async function Na(e,t,n){let r=n.filename.trim(),s=n.contentType.trim();if(!r)throw new Error("filename is required");if(!s)throw new Error("contentType is required");let i={"Content-Type":s,"X-Kortix-Attachment-Filename":encodeURIComponent(r),"X-Kortix-Attachment-Disposition":n.contentDisposition??"attachment"};n.contentId?.trim()&&(i["X-Kortix-Attachment-Content-Id"]=encodeURIComponent(n.contentId.trim())),n.connector?.trim()&&(i["X-Kortix-Attachment-Connector"]=encodeURIComponent(n.connector.trim()));let o=xx($().backendUrl),a=Qn(e,"attachments"),p=await q(`${o}${a}`,{method:"POST",headers:i,body:t},{timeoutMs:6e4}),g=await p.text(),m=null;if(g)try{m=JSON.parse(g)}catch{m=g}if(!p.ok)throw new S(_x(m,p.status),{status:p.status,code:String(m&&typeof m=="object"?m.code??p.status:p.status),details:m,response:p,endpoint:a});return m}function wx(e){if(e.owner_type!=="project")return!1;let t=e.shared_with??[];return t.length===0||t.some(n=>n.principal_type==="project")}async function Wa(e){return u(await c.get(`/projects/${e}/connections`))}async function Ka(e){return u(await c.get(`/projects/${e}/connections/all`))}async function Ha(e,t){return u(await c.post(`/projects/${e}/connections`,t))}async function za(e,t){return u(await c.post(`/projects/${e}/connections/me`,t))}async function Va(e,t,n){return u(await c.put(`/projects/${e}/connections/${t}/credential`,n))}function we(e,t,n){return`/projects/${e}/connections/${t}/oauth2/${n}`}async function kx(e,t){return u(await c.post(`/projects/${e}/connectors/${encodeURIComponent(t)}/oauth2/connection`,{}))}async function Px(e,t,n){return u(await c.put(we(e,t,"application"),n))}async function Sx(e,t){return u(await c.get(we(e,t,"application")))}async function vx(e,t,n){return u(await c.post(we(e,t,"discover"),n))}async function Ax(e,t,n={}){return u(await c.post(we(e,t,"discover-resource"),n))}async function Rx(e,t,n){return u(await c.post(we(e,t,"register"),n))}async function Cx(e,t,n){return u(await c.post(we(e,t,"authorize"),n))}async function Tx(e,t,n){return u(await c.post(we(e,t,"device"),n))}async function Ix(e,t,n){return u(await c.post(we(e,t,`device/${encodeURIComponent(n)}`),{}))}async function Ex(e,t){return u(await c.get(we(e,t,"status")))}async function Ja(e,t){return u(await c.put(`/projects/${e}/connections/${t}/revoke`,{}))}async function Xa(e,t){return u(await c.put(`/projects/${e}/connections/${t}/activate`,{}))}async function Qa(e,t){return u(await c.put(`/projects/${e}/connections/${t}/default`,{}))}async function Ya(e,t,n){return u(await c.put(`/projects/${e}/connections/${t}/label`,{label:n}))}async function Za(e,t,n=[]){return u(await c.post(`/projects/${e}/connections/${t}/share`,{principals:n}))}async function ec(e,t,n={}){return u(await c.post(`/projects/${e}/connections/${t}/connect`,n))}async function tc(e,t){return u(await c.post(`/projects/${e}/connections/${t}/connect/finalize`,{}))}async function nc(e){return u(await c.get(`/connectors/projects/${e}/connectors`,{showErrors:!1}))}async function rc(e){return u(await c.post(`/connectors/projects/${e}/connectors/sync`,{}))}async function sc(e,t,n){return u(await c.put(`/connectors/projects/${e}/connectors/${encodeURIComponent(t)}/credential-mode`,{mode:n}))}async function ic(e,t,n){return u(await c.put(`/connectors/projects/${e}/connectors/${encodeURIComponent(t)}/authorization-strategy`,{authorization_strategy:n}))}async function oc(e,t,n){return u(await c.put(`/connectors/projects/${e}/connectors/${encodeURIComponent(t)}/sensitive`,{sensitive:n}))}async function ac(e,t){return u(await c.get(`/connectors/projects/${e}/connectors/${encodeURIComponent(t)}/policies`))}async function cc(e,t,n){return u(await c.put(`/connectors/projects/${e}/connectors/${encodeURIComponent(t)}/policies`,{policies:n}))}async function jx(e,t){throw new Error("Connection-specific policies were removed. Use getConnectorPolicies(projectId, slug).")}async function Mx(e,t,n){throw new Error("Connection-specific policies were removed. Use setConnectorPolicies(projectId, slug, policies).")}async function lc(e,t){return u(await c.get(`/connectors/projects/${e}/connectors/${encodeURIComponent(t)}/config`))}async function uc(e,t,n){return u(await c.put(`/connectors/projects/${e}/connectors/${encodeURIComponent(t)}/name`,{name:n}))}async function Pm(e,t,n={}){return u(await c.post(`/connectors/projects/${e}/connectors/${encodeURIComponent(t)}/connect`,n.owner?{owner:n.owner}:{}))}var pc=Pm;async function $x(e,t){return u(await c.get(`/connectors/projects/${e}/sessions/${encodeURIComponent(t)}/connect-requests`)).connectors??[]}async function dc(e,t){return u(await c.post(`/connectors/projects/${e}/connectors`,t))}async function gc(e,t){return u(await c.post(`/connectors/projects/${e}/connectors/auth-discovery`,t))}async function mc(e,t){return u(await c.delete(`/connectors/projects/${e}/connectors/${encodeURIComponent(t)}`))}async function fc(e,t,n){let r=typeof t=="string"||t===void 0?{...t?{q:t}:{},...n?{cursor:n}:{}}:t,s=new URLSearchParams;r.q&&s.set("q",r.q),r.category&&s.set("category",r.category),r.cursor&&s.set("cursor",r.cursor),r.limit&&s.set("limit",String(r.limit));let i=s.toString();return u(await c.get(`/connectors/projects/${e}/pipedream/apps${i?`?${i}`:""}`))}async function yc(e,t){let n=new URLSearchParams;t?.perCategory&&n.set("perCategory",String(t.perCategory)),t?.maxCategories&&n.set("maxCategories",String(t.maxCategories));let r=n.toString();return u(await c.get(`/connectors/projects/${e}/pipedream/sections${r?`?${r}`:""}`))}async function Ox(e,t={}){let n=new URLSearchParams;t.q&&n.set("q",t.q),t.category&&n.set("category",t.category),t.cursor&&n.set("cursor",t.cursor),t.limit&&n.set("limit",String(t.limit));let r=n.toString(),s=u(await c.get(`/connectors/projects/${e}/connect/toolkits${r?`?${r}`:""}`));if("toolkits"in s)return s;let i=s.cursor?.trim()||void 0;return{provider:"composio",toolkits:s.items,nextCursor:i,hasMore:!!i}}async function Dx(e,t){let n=new URLSearchParams;t?.perCategory&&n.set("perCategory",String(t.perCategory)),t?.maxCategories&&n.set("maxCategories",String(t.maxCategories));let r=n.toString();return u(await c.get(`/connectors/projects/${e}/connect/sections${r?`?${r}`:""}`))}async function Zn(e,t,n){let r=typeof t=="string"||t===void 0?{...t?{q:t}:{},...n?{cursor:n}:{}}:t,s=new URLSearchParams;r.q&&s.set("q",r.q),r.category&&s.set("category",r.category),r.cursor&&s.set("cursor",r.cursor),r.limit&&s.set("limit",String(r.limit));let i=s.toString();return u(await c.get(`/connectors/projects/${e}/discover/connectors${i?`?${i}`:""}`))}async function hc(e,t){let n=new URLSearchParams;t?.perCategory&&n.set("perCategory",String(t.perCategory)),t?.maxCategories&&n.set("maxCategories",String(t.maxCategories));let r=n.toString();return u(await c.get(`/connectors/projects/${e}/discover/sections${r?`?${r}`:""}`))}async function er(e,t){let n=new URLSearchParams({id:t});return u(await c.get(`/connectors/projects/${e}/discover/connectors/detail?${n.toString()}`))}var qx=Zn,Ux=er;async function bc(){return u(await c.get("/connectors/connect-status"))}async function _c(e,t,n){let r=typeof n=="string"?{value:n}:n;return u(await c.put(`/connectors/projects/${e}/connectors/${encodeURIComponent(t)}/credential`,r))}async function Fx(e,t,n){return u(await c.put(`/connectors/projects/${e}/connectors/${encodeURIComponent(t)}/secret-binding`,{secret_identifier:n}))}async function Sm(e,t,n={}){let r={};return n.owner&&(r.owner=n.owner),n.connectionId&&(r.connection_id=n.connectionId),u(await c.post(`/connectors/projects/${e}/connectors/${encodeURIComponent(t)}/connect/finalize`,r))}var xc=Sm;async function wc(e){return u(await c.get(`/connectors/projects/${e}/policies`))}async function kc(e,t,n){return u(await c.put(`/connectors/projects/${e}/policies`,{policies:t,defaultMode:n}))}async function Pc(e){return u(await c.get(`/projects/${e}/sandboxes`))}async function Sc(e){return u(await c.get(`/projects/${e}/snapshots`))}async function tr(e){return u(await c.get(`/projects/${e}/sandbox-health`,{showErrors:!1,timeout:15e3}))}async function vc(e,t){return u(await c.post(`/projects/${e}/snapshots/rebuild`,t?{slug:t}:{}))}async function Ac(e){return u(await c.post(`/projects/${e}/snapshots/fix-with-agent`,{}))}async function Rc(e,t){return u(await c.post(`/projects/${e}/sandbox-templates`,t))}async function Cc(e,t,n){return u(await c.patch(`/projects/${e}/sandbox-templates/${t}`,n))}async function Tc(e,t){return u(await c.delete(`/projects/${e}/sandbox-templates/${t}`))}async function Ic(e,t){return u(await c.post(`/projects/${e}/sandbox-templates/${t}/build`,{}))}async function Ec(e){return u(await c.get(`/projects/${e}/sandboxes`))}async function jc(e,t){let n=new URLSearchParams;t?.ref&&n.set("ref",t.ref),t?.path&&n.set("path",t.path);let r=n.toString()?`?${n.toString()}`:"";return u(await c.get(`/projects/${e}/files${r}`,{showErrors:!1}))}async function Mc(e,t,n){let r=new URLSearchParams({q:t});return n?.content&&r.set("content","1"),n?.ref&&r.set("ref",n.ref),n?.limit&&r.set("limit",String(n.limit)),u(await c.get(`/projects/${e}/files/search?${r.toString()}`))}async function $c(e,t,n){let r=new URLSearchParams({path:t});return n&&r.set("ref",n),u(await c.get(`/projects/${e}/files/content?${r.toString()}`,{showErrors:!1}))}async function Oc(e,t,n){let r=new URLSearchParams;t&&r.set("ref",t),n&&r.set("path",n);let s=r.toString()?`?${r.toString()}`:"",i=await Je(),o=`${$().backendUrl||""}/projects/${e}/files/archive${s}`,a=await fetch(o,{method:"GET",headers:i?{Authorization:`Bearer ${i}`}:{}});if(!a.ok){let p=await a.text().catch(()=>"");throw new Error(p||`Failed to download (HTTP ${a.status})`)}return await a.blob()}async function Dc(e){return u(await c.get(`/projects/${e}/branches`))}async function qc(e,t){let n=new URLSearchParams;t?.ref&&n.set("ref",t.ref),t?.path&&n.set("path",t.path),t?.limit!=null&&n.set("limit",String(t.limit)),t?.skip!=null&&n.set("skip",String(t.skip));let r=n.toString()?`?${n.toString()}`:"";return u(await c.get(`/projects/${e}/commits${r}`))}async function Uc(e,t){return u(await c.get(`/projects/${e}/commits/${encodeURIComponent(t)}`))}async function Fc(e,t,n){let r=new URLSearchParams;n?.path&&r.set("path",n.path);let s=r.toString()?`?${r.toString()}`:"";return u(await c.get(`/projects/${e}/commits/${encodeURIComponent(t)}/diff${s}`))}async function Lc(e,t,n){let r=new URLSearchParams({path:t});return n?.ref&&r.set("ref",n.ref),n?.limit!=null&&r.set("limit",String(n.limit)),n?.skip!=null&&r.set("skip",String(n.skip)),u(await c.get(`/projects/${e}/files/history?${r.toString()}`))}async function Bc(e,t){let n=new URLSearchParams({from:t.from,into:t.into});return u(await c.get(`/projects/${e}/version-diff?${n.toString()}`))}async function Gc(e,t){let n=t?`?status=${t}`:"";return u(await c.get(`/projects/${e}/change-requests${n}`,{showErrors:!1,timeout:15e3}))}async function Nc(e,t){return u(await c.get(`/projects/${e}/change-requests/${t}`))}async function Wc(e,t){return u(await c.get(`/projects/${e}/change-requests/${t}/diff`))}async function Kc(e,t){return u(await c.get(`/projects/${e}/change-requests/${t}/merge-preview`))}async function Hc(e,t){return u(await c.post(`/projects/${e}/change-requests`,t))}async function zc(e,t,n){return u(await c.post(`/projects/${e}/change-requests/${t}/merge`,n??{},{showErrors:!1}))}async function Vc(e,t){return u(await c.post(`/projects/${e}/change-requests/${t}/close`,{}))}async function Jc(e,t){return u(await c.post(`/projects/${e}/change-requests/${t}/reopen`,{}))}async function Xc(e,t,n){return u(await c.post(`/projects/${e}/change-requests/${t}/request-changes`,{feedback:n}))}async function Qc(e,t,n){return u(await c.post(`/projects/${e}/sessions/${t}/commit-push`,n??{}))}var Yc=new Set;function zt(e){e&&Yc.add(e)}function Zc(e){return!!e&&Yc.has(e)}function Lx(e){e&&Yc.delete(e)}function Bx(e){let t=e.metadata?.spawned_by_session;if(typeof t!="string")return null;let n=t.trim();return!n||n===e.session_id?null:n}var Gx=50,vm=200,Nx=vm;function Am(e){let t=new URLSearchParams;return e?.scope&&e.scope!=="visible"&&t.set("scope",e.scope),e?.limit!==void 0&&t.set("limit",String(e.limit)),e?.cursor&&t.set("cursor",e.cursor),t.size>0?`?${t}`:""}async function el(e,t){let n=await c.get(`/projects/${e}/sessions${Am(t)}`);return{items:u(n),next_cursor:n.headers?.get("x-next-cursor")??null}}async function dt(e,t){return u(await c.get(`/projects/${e}/sessions${Am(t)}`))}async function tl(e,t,n){return u(await c.put(`/projects/${e}/sessions/${t}/sharing`,n))}function Wx(e,t=new Date){let n=null;for(let r of e)r.resource_type!=="transcript"||r.revoked_at||r.expires_at&&Date.parse(r.expires_at)<=t.getTime()||(!n||Date.parse(r.created_at)>Date.parse(n.created_at))&&(n=r);return n}async function nl(e,t){return u(await c.get(`/projects/${e}/sessions/${t}/previews`))}async function rl(e,t){return u(await c.get(`/projects/${e}/sessions/${t}/public-shares`,{showErrors:!1}))}async function sl(e,t,n){return u(await c.post(`/projects/${e}/sessions/${t}/public-shares`,n))}async function il(e,t,n){return u(await c.delete(`/projects/${e}/sessions/${t}/public-shares/${n}`))}async function gt(e,t){let n=u(await c.post(`/projects/${e}/sessions`,t??{}));return t?.initial_prompt||zt(n?.session_id),n}async function ol(e,t){let n=t?.excludeSessionId?{exclude_session_id:t.excludeSessionId}:{},r=u(await c.post(`/projects/${e}/sessions/warm`,n,{showErrors:!1}));return r.reused||zt(r.session.session_id),r}async function al(e,t){let n=u(await c.post(`/projects/${e}/sessions/warm/claim`,t,{showErrors:!1}));return zt(n.session_id),n}async function nr(e,t,n){return u(await c.get(`/projects/${e}/sessions/${t}`,{showErrors:n?.showErrors}))}async function cl(e,t,n,r){let s=new URLSearchParams;n&&s.set("limit",String(n)),r?.cursor&&s.set("cursor",r.cursor),r?.includeEvents!=null&&s.set("include_events",String(r.includeEvents));let i=s.toString();return u(await c.get(`/projects/${e}/sessions/${t}/audit${i?`?${i}`:""}`,{showErrors:r?.showErrors}))}async function ll(e,t,n){let r=new URLSearchParams;n?.limit!=null&&r.set("limit",String(n.limit)),n?.chars!=null&&r.set("chars",String(n.chars));let s=r.toString();return u(await c.get(`/projects/${e}/sessions/${t}/transcript${s?`?${s}`:""}`))}async function ul(e,t,n){let r=new URLSearchParams({shape:"sync"});return n?.limit!=null&&r.set("limit",String(n.limit)),n?.history&&r.set("history","true"),n?.before&&r.set("before",n.before),u(await c.get(`/projects/${e}/sessions/${t}/transcript?${r.toString()}`,{showErrors:!1,signal:n?.signal}))}async function pl(e,t){return u(await c.get(`/projects/${e}/sessions/${t}/turn`))}async function Kx(e,t,n){let r=new URLSearchParams;n?.transcript!=null&&r.set("transcript",String(n.transcript));let s=r.toString();return u(await c.get(`/projects/${e}/sessions/${t}/snapshot${s?`?${s}`:""}`,{signal:n?.signal,showErrors:!1}))}async function dl(e,t,n){return u(await c.post(`/projects/${e}/sessions/${t}/prompts`,{client_message_id:n.clientMessageId,message_id:n.messageId,parts:n.parts,...n.placement?{placement:n.placement}:{},...n.overrides?{overrides:n.overrides}:{},...n.remintOnDelivery?{remint_on_delivery:!0}:{},...typeof n.clientSentAtMs=="number"?{client_sent_at_ms:Math.trunc(n.clientSentAtMs)}:{}}))}async function gl(e,t){return u(await c.get(`/projects/${e}/sessions/${t}/prompts`,{showErrors:!1}))}async function ml(e,t,n){return u(await c.delete(`/projects/${e}/sessions/${t}/prompts/${n}`,{showErrors:!1})).removed}async function fl(e,t,n){return u(await c.post(`/projects/${e}/sessions/${t}/prompts/${n}/retry`,{},{showErrors:!1}))}async function yl(e,t,n){return u(await c.post(`/projects/${e}/sessions/${t}/prompts/hold`,{held:n},{showErrors:!1}))}async function hl(e,t,n){return u(await c.patch(`/projects/${e}/sessions/${t}`,n))}async function bl(e,t){return u(await c.delete(`/projects/${e}/sessions/${t}`))}async function Vt(e,t){return u(await c.post(`/projects/${e}/sessions/${t}/restart`,{}))}async function Jt(e,t){return u(await c.post(`/projects/${e}/sessions/${t}/stop`,{}))}async function _l(e,t){return u(await c.get(`/projects/${e}/sessions/${encodeURIComponent(t)}/config`,{showErrors:!1}))}function Hx(e){let t=e.split(`
|
|
13
|
+
`);let _=cx(h);if(_){if(t(_),_.type==="error")throw new S(_.error,{status:_.status,code:_.code});_.type==="done"&&(a=_.project)}}}}finally{s.cancel().catch(()=>{})}if(!a)throw new Error("Provision stream ended without a result");return a}async function ux(){try{return u(await c.get("/projects/managed-git/status",{showErrors:!1}))}catch{return{configured:!1,provider:"github"}}}async function Jn(e,t){return u(await c.patch(`/projects/${e}`,t))}async function Oo(e,t,n){return u(await c.patch(`/projects/${e}/features`,{feature:t,enabled:n}))}async function Do(e,t,n){return u(await c.patch(`/projects/${e}/experimental`,{feature:t,enabled:n}))}async function qo(e,t){return u(await c.patch(`/projects/${e}/sandbox-provider`,{provider:t}))}async function px(e,t){return u(await c.get(`/projects/${e}/sandbox-provider/transition`,{showErrors:!1,...t}))}async function dx(e,t){throw W("updateTemplateWarmPool")}async function Uo(e,t){return u(await c.patch(`/projects/${e}/onboarding`,{completed:t}))}async function gx(e,t){return u(await c.patch(`/projects/${e}/onboarding`,{profile:t}))}async function Xn(e){return u(await c.delete(`/projects/${e}`))}async function mx(e,t){return ut(e,`/v1/projects?account_id=${encodeURIComponent(t)}`)}async function fx(e,t){if(!e.backendUrl||!e.accessToken)return{ok:!1,limitReached:!1};let n=no(e.backendUrl);try{let r=await fetch(`${n}/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(r.ok){let s=await r.json().catch(()=>null);return s?.project_id?{ok:!0,project:s}:{ok:!1,limitReached:!1}}return r.status===403?{ok:!1,limitReached:(await r.json().catch(()=>null))?.code==="project_limit_reached"}:{ok:!1,limitReached:!1}}catch{return{ok:!1,limitReached:!1}}}async function Fo(e){return u(await c.post("/projects/link-repository",e,{showErrors:!1}))}async function Lo(e){let{project_id:t,...n}=e;return u(await c.put(`/projects/${encodeURIComponent(t)}/git/repository`,n,{showErrors:!1}))}async function Bo(e){return u(await c.get(`/projects/github/installation?account_id=${encodeURIComponent(e)}`,{showErrors:!1}))}async function Go(e){return u(await c.get(`/projects/github/installations?account_id=${encodeURIComponent(e)}`,{showErrors:!1}))}async function No(e){return u(await c.post("/projects/github/installations/linkable",e,{showErrors:!1}))}async function Wo(e,t,n){let r=new URLSearchParams({account_id:e});t&&r.set("installation_id",t);let s=n?.search?.trim();return s&&r.set("search",s),n?.limit!==void 0&&r.set("limit",String(n.limit)),u(await c.get(`/projects/github/repositories?${r.toString()}`,{showErrors:!1}))}async function Ko(e,t,n){let r=new URLSearchParams({account_id:e,installation_id:t,repo_full_name:n});return u(await c.get(`/projects/github/repository-branches?${r.toString()}`,{showErrors:!1}))}async function Ho(e){return u(await c.post("/projects/github/installation",e,{showErrors:!1}))}async function zo(e){return u(await c.post("/projects/github/installations/link",e,{showErrors:!1}))}async function Vo(e,t){let n=new URLSearchParams({account_id:e});return t&&n.set("installation_id",t),u(await c.delete(`/projects/github/installation?${n.toString()}`))}async function Jo(){return u(await c.get("/projects/git/backend",{showErrors:!1}))}async function Xo(e){let t=new URLSearchParams,n=e?.search?.trim();n&&t.set("search",n),e?.limit!==void 0&&t.set("limit",String(e.limit));let r=t.toString();return u(await c.get(`/projects/git/backend/repositories${r?`?${r}`:""}`,{showErrors:!1}))}async function yx(e,t){return u(await c.post(`/projects/${e}/access-requests`,{message:t?.trim()||void 0},{showErrors:!1}))}async function Qo(e,t){return u(await c.get(`/projects/${e}/access-requests`,t))}async function Yo(e,t,n="member"){return u(await c.post(`/projects/${e}/access-requests/${t}/approve`,{role:n}))}async function Zo(e,t){return u(await c.post(`/projects/${e}/access-requests/${t}/reject`,{}))}async function ea(e){return u(await c.get(`/projects/${e}/access`))}async function ta(e,t,n){return u(await c.put(`/projects/${e}/access/${t}`,{role:n}))}async function na(e,t){return u(await c.delete(`/projects/${e}/access/${t}`))}function hx(e){return"status"in e&&e.status==="invited"}async function ra(e,t,n,r){return u(await c.post(`/projects/${e}/access/invite`,{email:t,role:n,...r!==void 0?{expires_at:r}:{}}))}async function sa(e){return u(await c.get(`/projects/${e}/access/pending-invites`))}async function ia(e,t){return u(await c.delete(`/projects/${e}/access/pending-invites/${t}`))}async function oa(e,t){return u(await c.post(`/projects/${e}/access/pending-invites/${t}/resend`))}async function aa(e){return u(await c.get(`/projects/${e}/group-grants`))}async function ca(e,t,n,r){return u(await c.post(`/projects/${e}/group-grants`,r===void 0?{group_id:t,role:n}:{group_id:t,role:n,expires_at:r}))}async function la(e,t,n,r){return u(await c.patch(`/projects/${e}/group-grants/${t}`,r===void 0?{role:n}:{role:n,expires_at:r}))}async function ua(e,t){return u(await c.delete(`/projects/${e}/group-grants/${t}`))}async function pa(e){return u(await c.get(`/projects/${e}/resource-grants`))}async function da(e,t){return u(await c.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 ga(e,t){return u(await c.delete(`/projects/${e}/resource-grants/${t}`))}async function ma(e,t){return u(await c.get(`/projects/${e}/approvals`,{showErrors:t?.showErrors}))}async function fa(e,t){return u(await c.get(`/projects/${e}/approvals/needs-input`,{showErrors:t?.showErrors}))}async function ya(e,t,n){return u(await c.post(`/projects/${e}/approvals/${t}`,{decision:n}))}async function ha(e){return u(await c.get(`/projects/${e}/secrets`,{showErrors:!1}))}async function ba(e,t){return u(await c.post(`/projects/${e}/secrets`,t))}async function _a(e,t,n,r={}){return u(await c.put(`/projects/${e}/secrets/${encodeURIComponent(t)}/strategy`,{strategy:n,...r}))}async function xa(e,t,n){return u(await c.post(`/projects/${e}/secrets/${encodeURIComponent(t)}/broker`,n))}async function wa(e,t,n){return u(await c.post(`/projects/${e}/oauth/${t}/start`,{sharing:n?.sharing,...n?.resourceLabel===void 0?{}:{resource_label:n.resourceLabel},...n?.resourceId===void 0?{}:{resource_id:n.resourceId}}))}async function ka(e,t,n){return u(await c.post(`/projects/${e}/oauth/${t}/poll`,{flow_id:n}))}async function Pa(e,t){return u(await c.delete(`/projects/${e}/oauth/${encodeURIComponent(t)}`))}async function Sa(e,t){return u(await c.put(`/projects/${e}/git-credential`,t))}async function va(e,t){return u(await c.delete(`/projects/${e}/secrets/${encodeURIComponent(t)}`))}async function Aa(e,t,n){return u(await c.put(`/projects/${e}/secrets/${encodeURIComponent(t)}/personal`,n))}async function Ra(e,t){return u(await c.delete(`/projects/${e}/secrets/${encodeURIComponent(t)}/personal`))}var Ca=e=>`/accounts/${encodeURIComponent(e)}/secret-resources`,Kt=(e,t)=>`${Ca(e)}/${encodeURIComponent(t)}`,km=(e,t,n)=>`/projects/${encodeURIComponent(e)}/sessions/${encodeURIComponent(t)}/provider-secret-pools/${encodeURIComponent(n)}`;async function Ta(e,t){let n=t?`?project_id=${encodeURIComponent(t)}`:"";return u(await c.get(`${Ca(e)}${n}`))}async function Ia(e,t){return u(await c.post(Ca(e),t))}async function Ea(e,t,n){return u(await c.put(`${Kt(e,t)}/value`,{value:n}))}async function ja(e,t){return u(await c.delete(Kt(e,t)))}async function Ma(e,t,n,r){return u(await c.put(`${Kt(e,t)}/grants/${encodeURIComponent(n)}`,{},r))}async function $a(e,t,n,r){return u(await c.delete(`${Kt(e,t)}/grants/${encodeURIComponent(n)}`,r))}async function Oa(e,t,n,r){return u(await c.put(`${Kt(e,t)}/access`,{mode:n,user_ids:r}))}async function Da(e,t,n){return u(await c.get(km(e,t,n)))}async function qa(e,t){let n=`/projects/${encodeURIComponent(e)}/sessions/${encodeURIComponent(t)}/provider-secret-pools`;return u(await c.get(n))}async function Ua(e,t,n,r){return u(await c.put(km(e,t,n),{secret_ids:r}))}function Qn(e,t){return e?`/connectors/projects/${encodeURIComponent(e)}/${t}`:`/connectors/${t}`}async function Ht(e,t){let n=new URLSearchParams;t?.slug&&n.set("slug",t.slug),t?.includeSchemas!==void 0&&n.set("include_schemas",String(t.includeSchemas));let r=n.toString()?`?${n.toString()}`:"";return u(await c.get(`${Qn(e,"catalog")}${r}`)).connectors??[]}async function Yn(e){let t=[];for(let n of await Ht(e))for(let r of n.actions)t.push({tool:`${n.slug}.${r.path}`,connector:n.slug,action:r.path,risk:r.risk,description:r.description||r.name,inputSchema:r.inputSchema});return t}async function Fa(e,t="",n={}){let r=t.trim().toLowerCase(),s=r.split(/\s+/).filter(Boolean),i=[],o=[];for(let a of await Yn(e)){let p=`${a.tool} ${a.description}`.toLowerCase();!r||p.includes(r)?i.push(a):s.every(g=>p.includes(g))&&o.push(a)}return[...i,...o].slice(0,n.limit??20)}async function La(e,t){let n=t.indexOf(".");if(n<0)return null;let r=t.slice(0,n).trim();if(!r)return null;let s=(await Ht(e,{slug:r,includeSchemas:!0})).find(i=>i.slug===r);if(!s)return null;for(let i of s.actions){let o=`${s.slug}.${i.path}`;if(o===t)return{tool:o,connector:s.slug,action:i.path,risk:i.risk,description:i.description||i.name,inputSchema:i.inputSchema}}return null}function bx(e){let t=e.indexOf("."),n=t<0?"":e.slice(0,t).trim(),r=t<0?"":e.slice(t+1).trim();if(!n||!r)throw new Error("tool must use the connector.action format");return{connector:n,action:r}}async function Ba(e,t,n={},r={}){let{connector:s,action:i}=bx(t),o=r.account?.trim();return u(await c.post(Qn(e,"call"),{connector:s,action:i,args:n,...o?{account:o}:{}}))}async function Ga(e,t){let n=await c.get(Qn(e,`connectors/${encodeURIComponent(t)}/accounts`));return u(n).accounts??[]}function _x(e,t){if(e&&typeof e=="object"){let n=e;for(let r of["reason","error","message","detail"])if(typeof n[r]=="string"&&n[r])return n[r]}return`HTTP ${t}`}function xx(e){let t=e.length;for(;t>0&&e.charCodeAt(t-1)===47;)t-=1;return t===e.length?e:e.slice(0,t)}async function Na(e,t,n){let r=n.filename.trim(),s=n.contentType.trim();if(!r)throw new Error("filename is required");if(!s)throw new Error("contentType is required");let i={"Content-Type":s,"X-Kortix-Attachment-Filename":encodeURIComponent(r),"X-Kortix-Attachment-Disposition":n.contentDisposition??"attachment"};n.contentId?.trim()&&(i["X-Kortix-Attachment-Content-Id"]=encodeURIComponent(n.contentId.trim())),n.connector?.trim()&&(i["X-Kortix-Attachment-Connector"]=encodeURIComponent(n.connector.trim()));let o=xx($().backendUrl),a=Qn(e,"attachments"),p=await q(`${o}${a}`,{method:"POST",headers:i,body:t},{timeoutMs:6e4}),g=await p.text(),m=null;if(g)try{m=JSON.parse(g)}catch{m=g}if(!p.ok)throw new S(_x(m,p.status),{status:p.status,code:String(m&&typeof m=="object"?m.code??p.status:p.status),details:m,response:p,endpoint:a});return m}function wx(e){if(e.owner_type!=="project")return!1;let t=e.shared_with??[];return t.length===0||t.some(n=>n.principal_type==="project")}async function Wa(e){return u(await c.get(`/projects/${e}/connections`))}async function Ka(e){return u(await c.get(`/projects/${e}/connections/all`))}async function Ha(e,t){return u(await c.post(`/projects/${e}/connections`,t))}async function za(e,t){return u(await c.post(`/projects/${e}/connections/me`,t))}async function Va(e,t,n){return u(await c.put(`/projects/${e}/connections/${t}/credential`,n))}function we(e,t,n){return`/projects/${e}/connections/${t}/oauth2/${n}`}async function kx(e,t){return u(await c.post(`/projects/${e}/connectors/${encodeURIComponent(t)}/oauth2/connection`,{}))}async function Px(e,t,n){return u(await c.put(we(e,t,"application"),n))}async function Sx(e,t){return u(await c.get(we(e,t,"application")))}async function vx(e,t,n){return u(await c.post(we(e,t,"discover"),n))}async function Ax(e,t,n={}){return u(await c.post(we(e,t,"discover-resource"),n))}async function Rx(e,t,n){return u(await c.post(we(e,t,"register"),n))}async function Cx(e,t,n){return u(await c.post(we(e,t,"authorize"),n))}async function Tx(e,t,n){return u(await c.post(we(e,t,"device"),n))}async function Ix(e,t,n){return u(await c.post(we(e,t,`device/${encodeURIComponent(n)}`),{}))}async function Ex(e,t){return u(await c.get(we(e,t,"status")))}async function Ja(e,t){return u(await c.put(`/projects/${e}/connections/${t}/revoke`,{}))}async function Xa(e,t){return u(await c.put(`/projects/${e}/connections/${t}/activate`,{}))}async function Qa(e,t){return u(await c.put(`/projects/${e}/connections/${t}/default`,{}))}async function Ya(e,t,n){return u(await c.put(`/projects/${e}/connections/${t}/label`,{label:n}))}async function Za(e,t,n=[]){return u(await c.post(`/projects/${e}/connections/${t}/share`,{principals:n}))}async function ec(e,t,n={}){return u(await c.post(`/projects/${e}/connections/${t}/connect`,n))}async function tc(e,t){return u(await c.post(`/projects/${e}/connections/${t}/connect/finalize`,{}))}async function nc(e,t){let n=t?.includeSchemas===void 0?"":`?include_schemas=${t.includeSchemas}`;return u(await c.get(`/connectors/projects/${e}/connectors${n}`,{showErrors:!1}))}async function rc(e){return u(await c.post(`/connectors/projects/${e}/connectors/sync`,{}))}async function sc(e,t,n){return u(await c.put(`/connectors/projects/${e}/connectors/${encodeURIComponent(t)}/credential-mode`,{mode:n}))}async function ic(e,t,n){return u(await c.put(`/connectors/projects/${e}/connectors/${encodeURIComponent(t)}/authorization-strategy`,{authorization_strategy:n}))}async function oc(e,t,n){return u(await c.put(`/connectors/projects/${e}/connectors/${encodeURIComponent(t)}/sensitive`,{sensitive:n}))}async function ac(e,t){return u(await c.get(`/connectors/projects/${e}/connectors/${encodeURIComponent(t)}/policies`))}async function cc(e,t,n){return u(await c.put(`/connectors/projects/${e}/connectors/${encodeURIComponent(t)}/policies`,{policies:n}))}async function jx(e,t){throw new Error("Connection-specific policies were removed. Use getConnectorPolicies(projectId, slug).")}async function Mx(e,t,n){throw new Error("Connection-specific policies were removed. Use setConnectorPolicies(projectId, slug, policies).")}async function lc(e,t){return u(await c.get(`/connectors/projects/${e}/connectors/${encodeURIComponent(t)}/config`))}async function uc(e,t,n){return u(await c.put(`/connectors/projects/${e}/connectors/${encodeURIComponent(t)}/name`,{name:n}))}async function Pm(e,t,n={}){return u(await c.post(`/connectors/projects/${e}/connectors/${encodeURIComponent(t)}/connect`,n.owner?{owner:n.owner}:{}))}var pc=Pm;async function $x(e,t){return u(await c.get(`/connectors/projects/${e}/sessions/${encodeURIComponent(t)}/connect-requests`)).connectors??[]}async function dc(e,t){return u(await c.post(`/connectors/projects/${e}/connectors`,t))}async function gc(e,t){return u(await c.post(`/connectors/projects/${e}/connectors/auth-discovery`,t))}async function mc(e,t){return u(await c.delete(`/connectors/projects/${e}/connectors/${encodeURIComponent(t)}`))}async function fc(e,t,n){let r=typeof t=="string"||t===void 0?{...t?{q:t}:{},...n?{cursor:n}:{}}:t,s=new URLSearchParams;r.q&&s.set("q",r.q),r.category&&s.set("category",r.category),r.cursor&&s.set("cursor",r.cursor),r.limit&&s.set("limit",String(r.limit));let i=s.toString();return u(await c.get(`/connectors/projects/${e}/pipedream/apps${i?`?${i}`:""}`))}async function yc(e,t){let n=new URLSearchParams;t?.perCategory&&n.set("perCategory",String(t.perCategory)),t?.maxCategories&&n.set("maxCategories",String(t.maxCategories));let r=n.toString();return u(await c.get(`/connectors/projects/${e}/pipedream/sections${r?`?${r}`:""}`))}async function Ox(e,t={}){let n=new URLSearchParams;t.q&&n.set("q",t.q),t.category&&n.set("category",t.category),t.cursor&&n.set("cursor",t.cursor),t.limit&&n.set("limit",String(t.limit));let r=n.toString(),s=u(await c.get(`/connectors/projects/${e}/connect/toolkits${r?`?${r}`:""}`));if("toolkits"in s)return s;let i=s.cursor?.trim()||void 0;return{provider:"composio",toolkits:s.items,nextCursor:i,hasMore:!!i}}async function Dx(e,t){let n=new URLSearchParams;t?.perCategory&&n.set("perCategory",String(t.perCategory)),t?.maxCategories&&n.set("maxCategories",String(t.maxCategories));let r=n.toString();return u(await c.get(`/connectors/projects/${e}/connect/sections${r?`?${r}`:""}`))}async function Zn(e,t,n){let r=typeof t=="string"||t===void 0?{...t?{q:t}:{},...n?{cursor:n}:{}}:t,s=new URLSearchParams;r.q&&s.set("q",r.q),r.category&&s.set("category",r.category),r.cursor&&s.set("cursor",r.cursor),r.limit&&s.set("limit",String(r.limit));let i=s.toString();return u(await c.get(`/connectors/projects/${e}/discover/connectors${i?`?${i}`:""}`))}async function hc(e,t){let n=new URLSearchParams;t?.perCategory&&n.set("perCategory",String(t.perCategory)),t?.maxCategories&&n.set("maxCategories",String(t.maxCategories));let r=n.toString();return u(await c.get(`/connectors/projects/${e}/discover/sections${r?`?${r}`:""}`))}async function er(e,t){let n=new URLSearchParams({id:t});return u(await c.get(`/connectors/projects/${e}/discover/connectors/detail?${n.toString()}`))}var qx=Zn,Ux=er;async function bc(){return u(await c.get("/connectors/connect-status"))}async function _c(e,t,n){let r=typeof n=="string"?{value:n}:n;return u(await c.put(`/connectors/projects/${e}/connectors/${encodeURIComponent(t)}/credential`,r))}async function Fx(e,t,n){return u(await c.put(`/connectors/projects/${e}/connectors/${encodeURIComponent(t)}/secret-binding`,{secret_identifier:n}))}async function Sm(e,t,n={}){let r={};return n.owner&&(r.owner=n.owner),n.connectionId&&(r.connection_id=n.connectionId),u(await c.post(`/connectors/projects/${e}/connectors/${encodeURIComponent(t)}/connect/finalize`,r))}var xc=Sm;async function wc(e){return u(await c.get(`/connectors/projects/${e}/policies`))}async function kc(e,t,n){return u(await c.put(`/connectors/projects/${e}/policies`,{policies:t,defaultMode:n}))}async function Pc(e){return u(await c.get(`/projects/${e}/sandboxes`))}async function Sc(e){return u(await c.get(`/projects/${e}/snapshots`))}async function tr(e){return u(await c.get(`/projects/${e}/sandbox-health`,{showErrors:!1,timeout:15e3}))}async function vc(e,t){return u(await c.post(`/projects/${e}/snapshots/rebuild`,t?{slug:t}:{}))}async function Ac(e){return u(await c.post(`/projects/${e}/snapshots/fix-with-agent`,{}))}async function Rc(e,t){return u(await c.post(`/projects/${e}/sandbox-templates`,t))}async function Cc(e,t,n){return u(await c.patch(`/projects/${e}/sandbox-templates/${t}`,n))}async function Tc(e,t){return u(await c.delete(`/projects/${e}/sandbox-templates/${t}`))}async function Ic(e,t){return u(await c.post(`/projects/${e}/sandbox-templates/${t}/build`,{}))}async function Ec(e){return u(await c.get(`/projects/${e}/sandboxes`))}async function jc(e,t){let n=new URLSearchParams;t?.ref&&n.set("ref",t.ref),t?.path&&n.set("path",t.path);let r=n.toString()?`?${n.toString()}`:"";return u(await c.get(`/projects/${e}/files${r}`,{showErrors:!1}))}async function Mc(e,t,n){let r=new URLSearchParams({q:t});return n?.content&&r.set("content","1"),n?.ref&&r.set("ref",n.ref),n?.limit&&r.set("limit",String(n.limit)),u(await c.get(`/projects/${e}/files/search?${r.toString()}`))}async function $c(e,t,n){let r=new URLSearchParams({path:t});return n&&r.set("ref",n),u(await c.get(`/projects/${e}/files/content?${r.toString()}`,{showErrors:!1}))}async function Oc(e,t,n){let r=new URLSearchParams;t&&r.set("ref",t),n&&r.set("path",n);let s=r.toString()?`?${r.toString()}`:"",i=await Je(),o=`${$().backendUrl||""}/projects/${e}/files/archive${s}`,a=await fetch(o,{method:"GET",headers:i?{Authorization:`Bearer ${i}`}:{}});if(!a.ok){let p=await a.text().catch(()=>"");throw new Error(p||`Failed to download (HTTP ${a.status})`)}return await a.blob()}async function Dc(e,t){let n=new URLSearchParams;t?.q&&n.set("q",t.q),t?.limit!=null&&n.set("limit",String(t.limit)),t?.includeSessionBranches!==void 0&&n.set("include_session_branches",String(t.includeSessionBranches));let r=n.toString()?`?${n.toString()}`:"";return u(await c.get(`/projects/${e}/branches${r}`))}async function qc(e,t){let n=new URLSearchParams;t?.ref&&n.set("ref",t.ref),t?.path&&n.set("path",t.path),t?.limit!=null&&n.set("limit",String(t.limit)),t?.skip!=null&&n.set("skip",String(t.skip));let r=n.toString()?`?${n.toString()}`:"";return u(await c.get(`/projects/${e}/commits${r}`))}async function Uc(e,t){return u(await c.get(`/projects/${e}/commits/${encodeURIComponent(t)}`))}async function Fc(e,t,n){let r=new URLSearchParams;n?.path&&r.set("path",n.path);let s=r.toString()?`?${r.toString()}`:"";return u(await c.get(`/projects/${e}/commits/${encodeURIComponent(t)}/diff${s}`))}async function Lc(e,t,n){let r=new URLSearchParams({path:t});return n?.ref&&r.set("ref",n.ref),n?.limit!=null&&r.set("limit",String(n.limit)),n?.skip!=null&&r.set("skip",String(n.skip)),u(await c.get(`/projects/${e}/files/history?${r.toString()}`))}async function Bc(e,t){let n=new URLSearchParams({from:t.from,into:t.into});return u(await c.get(`/projects/${e}/version-diff?${n.toString()}`))}async function Gc(e,t,n){let r=new URLSearchParams;t&&r.set("status",t),n?.originSessionId&&r.set("origin_session_id",n.originSessionId),n?.limit!=null&&r.set("limit",String(n.limit));let s=r.toString()?`?${r.toString()}`:"";return u(await c.get(`/projects/${e}/change-requests${s}`,{showErrors:!1,timeout:15e3}))}async function Nc(e,t){return u(await c.get(`/projects/${e}/change-requests/${t}`))}async function Wc(e,t){return u(await c.get(`/projects/${e}/change-requests/${t}/diff`))}async function Kc(e,t){return u(await c.get(`/projects/${e}/change-requests/${t}/merge-preview`))}async function Hc(e,t){return u(await c.post(`/projects/${e}/change-requests`,t))}async function zc(e,t,n){return u(await c.post(`/projects/${e}/change-requests/${t}/merge`,n??{},{showErrors:!1}))}async function Vc(e,t){return u(await c.post(`/projects/${e}/change-requests/${t}/close`,{}))}async function Jc(e,t){return u(await c.post(`/projects/${e}/change-requests/${t}/reopen`,{}))}async function Xc(e,t,n){return u(await c.post(`/projects/${e}/change-requests/${t}/request-changes`,{feedback:n}))}async function Qc(e,t,n){return u(await c.post(`/projects/${e}/sessions/${t}/commit-push`,n??{}))}var Yc=new Set;function zt(e){e&&Yc.add(e)}function Zc(e){return!!e&&Yc.has(e)}function Lx(e){e&&Yc.delete(e)}function Bx(e){let t=e.metadata?.spawned_by_session;if(typeof t!="string")return null;let n=t.trim();return!n||n===e.session_id?null:n}var Gx=50,vm=200,Nx=vm;function Am(e){let t=new URLSearchParams;return e?.scope&&e.scope!=="visible"&&t.set("scope",e.scope),e?.limit!==void 0&&t.set("limit",String(e.limit)),e?.cursor&&t.set("cursor",e.cursor),t.size>0?`?${t}`:""}async function el(e,t){let n=await c.get(`/projects/${e}/sessions${Am(t)}`);return{items:u(n),next_cursor:n.headers?.get("x-next-cursor")??null}}async function dt(e,t){return u(await c.get(`/projects/${e}/sessions${Am(t)}`))}async function tl(e,t,n){return u(await c.put(`/projects/${e}/sessions/${t}/sharing`,n))}function Wx(e,t=new Date){let n=null;for(let r of e)r.resource_type!=="transcript"||r.revoked_at||r.expires_at&&Date.parse(r.expires_at)<=t.getTime()||(!n||Date.parse(r.created_at)>Date.parse(n.created_at))&&(n=r);return n}async function nl(e,t){return u(await c.get(`/projects/${e}/sessions/${t}/previews`))}async function rl(e,t){return u(await c.get(`/projects/${e}/sessions/${t}/public-shares`,{showErrors:!1}))}async function sl(e,t,n){return u(await c.post(`/projects/${e}/sessions/${t}/public-shares`,n))}async function il(e,t,n){return u(await c.delete(`/projects/${e}/sessions/${t}/public-shares/${n}`))}async function gt(e,t){let n=u(await c.post(`/projects/${e}/sessions`,t??{}));return t?.initial_prompt||zt(n?.session_id),n}async function ol(e,t){let n=t?.excludeSessionId?{exclude_session_id:t.excludeSessionId}:{},r=u(await c.post(`/projects/${e}/sessions/warm`,n,{showErrors:!1}));return r.reused||zt(r.session.session_id),r}async function al(e,t){let n=u(await c.post(`/projects/${e}/sessions/warm/claim`,t,{showErrors:!1}));return zt(n.session_id),n}async function nr(e,t,n){return u(await c.get(`/projects/${e}/sessions/${t}`,{showErrors:n?.showErrors}))}async function cl(e,t,n,r){let s=new URLSearchParams;n&&s.set("limit",String(n)),r?.cursor&&s.set("cursor",r.cursor),r?.includeEvents!=null&&s.set("include_events",String(r.includeEvents));let i=s.toString();return u(await c.get(`/projects/${e}/sessions/${t}/audit${i?`?${i}`:""}`,{showErrors:r?.showErrors}))}async function ll(e,t,n){let r=new URLSearchParams;n?.limit!=null&&r.set("limit",String(n.limit)),n?.chars!=null&&r.set("chars",String(n.chars));let s=r.toString();return u(await c.get(`/projects/${e}/sessions/${t}/transcript${s?`?${s}`:""}`))}async function ul(e,t,n){let r=new URLSearchParams({shape:"sync"});return n?.limit!=null&&r.set("limit",String(n.limit)),n?.history&&r.set("history","true"),n?.before&&r.set("before",n.before),u(await c.get(`/projects/${e}/sessions/${t}/transcript?${r.toString()}`,{showErrors:!1,signal:n?.signal}))}async function pl(e,t){return u(await c.get(`/projects/${e}/sessions/${t}/turn`))}async function Kx(e,t,n){let r=new URLSearchParams;n?.transcript!=null&&r.set("transcript",String(n.transcript));let s=r.toString();return u(await c.get(`/projects/${e}/sessions/${t}/snapshot${s?`?${s}`:""}`,{signal:n?.signal,showErrors:!1}))}async function dl(e,t,n){return u(await c.post(`/projects/${e}/sessions/${t}/prompts`,{client_message_id:n.clientMessageId,message_id:n.messageId,parts:n.parts,...n.placement?{placement:n.placement}:{},...n.overrides?{overrides:n.overrides}:{},...n.remintOnDelivery?{remint_on_delivery:!0}:{},...typeof n.clientSentAtMs=="number"?{client_sent_at_ms:Math.trunc(n.clientSentAtMs)}:{}}))}async function gl(e,t){return u(await c.get(`/projects/${e}/sessions/${t}/prompts`,{showErrors:!1}))}async function ml(e,t,n){return u(await c.delete(`/projects/${e}/sessions/${t}/prompts/${n}`,{showErrors:!1})).removed}async function fl(e,t,n){return u(await c.post(`/projects/${e}/sessions/${t}/prompts/${n}/retry`,{},{showErrors:!1}))}async function yl(e,t,n){return u(await c.post(`/projects/${e}/sessions/${t}/prompts/hold`,{held:n},{showErrors:!1}))}async function hl(e,t,n){return u(await c.patch(`/projects/${e}/sessions/${t}`,n))}async function bl(e,t){return u(await c.delete(`/projects/${e}/sessions/${t}`))}async function Vt(e,t){return u(await c.post(`/projects/${e}/sessions/${t}/restart`,{}))}async function Jt(e,t){return u(await c.post(`/projects/${e}/sessions/${t}/stop`,{}))}async function _l(e,t){return u(await c.get(`/projects/${e}/sessions/${encodeURIComponent(t)}/config`,{showErrors:!1}))}function Hx(e){let t=e.split(`
|
|
14
14
|
`).filter(n=>n.startsWith("data:")).map(n=>n.slice(5).replace(/^ /,""));if(t.length===0)return null;try{return JSON.parse(t.join(`
|
|
15
15
|
`))}catch(n){throw new Error("reloadProjectSessionConfigStream received an invalid SSE frame",{cause:n})}}async function xl(e,t,n={}){return u(await c.post(`/projects/${e}/sessions/${encodeURIComponent(t)}/reload`,n,{showErrors:!1}))}async function wl(e,t,n,r,s={}){let i=await c.postStream(`/projects/${e}/sessions/${encodeURIComponent(t)}/reload-stream`,n,s);if(!i.ok){let m=await i.json().catch(()=>null);throw new S(m?.error||`Reload failed: HTTP ${i.status}`,{status:i.status,code:m?.code,data:m})}let o=i.body?.getReader();if(!o)throw new Error("Reload stream is unavailable on this runtime (no response body)");let a=new TextDecoder,p="",g=null;try{for(;;){let{done:m,value:h}=await o.read();if(m)break;p+=a.decode(h,{stream:!0});let _=p.indexOf(`
|
|
16
16
|
|
|
17
17
|
`);for(;_!==-1;){let w=p.slice(0,_);p=p.slice(_+2),_=p.indexOf(`
|
|
18
18
|
|
|
19
19
|
`);let A=Hx(w);if(A){if(r(A),A.type==="error")throw new S(A.error,{status:A.status,code:A.code,data:{reason:A.reason}});A.type==="done"&&(g=A.result)}}}}finally{o.cancel().catch(()=>{})}if(!g)throw new Error("Reload stream ended without a result");return g}async function kl(e,t){return u(await c.get(`/projects/${e}/sessions/${encodeURIComponent(t)}/scope`))}async function Pl(e,t,n){return u(await c.put(`/projects/${e}/sessions/${encodeURIComponent(t)}/scope`,n))}async function Sl(e,t,n){return u(await c.put(`/projects/${e}/sessions/${encodeURIComponent(t)}/model`,{opencode_model:n}))}async function vl(e){return u(await c.get(`/projects/${e}/triggers`))}async function Al(e,t){return u(await c.post(`/projects/${e}/triggers`,t))}async function Rl(e,t,n){return u(await c.patch(`/projects/${e}/triggers/${t}`,n))}async function Cl(e,t){return u(await c.delete(`/projects/${e}/triggers/${t}`))}async function Tl(e,t){return u(await c.patch(`/projects/${e}/triggers/activation`,{paused:t}))}async function Il(e,t){return u(await c.post(`/projects/${e}/triggers/${t}/fire`,{}))}var Me=new Map;function El(e,t){return`${e}::${t}`}function Rm(e,t){Me.delete(e),Me.set(e,t)}function Cm(e,t){let n=El(e,t),r=Me.get(n);return r&&Rm(n,r),r}function Tm(e,t,n){let r=El(e,t);if(!Me.has(r)&&Me.size>=512){let s=Me.keys().next().value;s!==void 0&&Me.delete(s)}Rm(r,n)}function Im(e,t){Me.delete(El(e,t))}function zx(e){if(e.status!=="running"||!e.sandbox_id||!e.sandbox_provider||!e.sandbox_url||!e.opencode_session_id)return null;let t=e.sandbox_url.match(/\/p\/([^/]+)\//)?.[1];return t?{stage:"ready",agent_name:e.agent_name??"default",retriable:!0,sandbox:{sandbox_id:e.sandbox_id,session_id:e.session_id,project_id:e.project_id,account_id:e.account_id,provider:e.sandbox_provider,external_id:t,base_url:e.sandbox_url,status:"active",config:{},metadata:e.metadata,last_used_at:e.updated_at,created_at:e.created_at,updated_at:e.updated_at},opencode_session_id:e.opencode_session_id,runtime_url:e.sandbox_url}:null}var rr=class extends Error{status;code;terminal;constructor(t,n){super(t),this.name="SessionStartError",this.status=n.status,this.code=n.code,this.terminal=n.terminal}};function Vx(e){return e instanceof Error&&e.name==="SessionStartError"}function Jx(e){let t=e,n=t?.status,r=t?.code??t?.details?.code??t?.details?.error,s=t?.message||"Unable to start this session";return n&&n>=400&&n<500&&n!==408&&n!==429?new rr(s,{status:n,code:r,terminal:!0}):null}async function Ne(e,t,n){let r=typeof n=="number"?n:n?.waitMs,s=typeof n=="number"?void 0:n?.repositoryMode,i=new URLSearchParams;r&&r>0&&i.set("wait_ms",String(Math.floor(r))),s&&i.set("repository_mode",s);let o=i.size>0?`?${i.toString()}`:"",a=await c.post(`/projects/${e}/sessions/${t}/start${o}`,{},{showErrors:!1});if(!a.success||!a.data){let m=Jx(a.error);if(m&&!(m.status===404&&Zc(t)))throw m;return null}let p=a.data,g=p.sandbox?.external_id;return p.stage==="ready"&&g&&p.opencode_session_id&&Tm(e,t,{opencodeSessionId:p.opencode_session_id,runtimeUrl:Mn(g),sandboxId:g}),p}function Xx(e,t){return["session-start",e,t]}async function jl(e){return u(await c.get(`/projects/${e}/model-defaults`))}async function Ml(e,t){return u(await c.put(`/projects/${e}/model-defaults`,t))}async function $l(e,t){let n=new URLSearchParams({scope:t.scope,...t.agentName?{agentName:t.agentName}:{}}).toString();return u(await c.delete(`/projects/${e}/model-defaults?${n}`))}async function Qx(e,t){return u(await c.put(`/projects/${e}/model-enablement`,{modelOverrides:t}))}async function Ol(e,t,n){let r=Zx(n);return u(await c.put(`/projects/${e}/agents/${encodeURIComponent(t)}/scope`,r))}function Em(e){let t=[];for(let n of e){let r=n.trim();r&&!t.includes(r)&&t.push(r)}return t}function Yx(e,t){if(e.length!==t.length)return!1;let n=new Set(t);return e.every(r=>n.has(r))}function Zx(e){let t=e.connectors_required?Em(e.connectors_required):void 0,n=e.connectors_personal?Em(e.connectors_personal):void 0;if(t&&n&&!Yx(t,n))throw new Error("connectors_personal must match connectors_required when both fields are present");let r={...e};return delete r.connectors_personal,(t!==void 0||n!==void 0)&&(r.connectors_required=t??n),r}async function ew(e,t){let n=u(await c.get(`/projects/${e}/agents/${encodeURIComponent(t)}/config`));return{...n,block:n.block?Dl(n.block):null}}async function tw(e,t,n){let r=Dl(n,!0),s=u(await c.put(`/projects/${e}/agents/${encodeURIComponent(t)}/config`,r));return{...s,block:s.block?Dl(s.block):null}}function Dl(e,t=!1){let n=rw(e);if(n.workspace===void 0)return n;let r=n.workspace==="branch";if(n.repository_access!==void 0&&n.repository_access!==r)throw new Error("repository_access conflicts with workspace");if(t&&n.workspace==="read"&&n.repository_access===void 0)throw new Error("Legacy read is unavailable. Set repository_access explicitly.");return n.repository_access??=r,delete n.workspace,n}function jm(e){let t=[];for(let n of e){let r=n.trim();r&&!t.includes(r)&&t.push(r)}return t}function nw(e,t){if(e.length!==t.length)return!1;let n=new Set(t);return e.every(r=>n.has(r))}function rw(e){let t=e.connectors_required?jm(e.connectors_required):void 0,n=e.connectors_personal?jm(e.connectors_personal):void 0;if(t&&n&&!nw(t,n))throw new Error("connectors_personal must match connectors_required when both fields are present");let r={...e};return delete r.connectors_personal,(t!==void 0||n!==void 0)&&(r.connectors_required=t??n),r}async function sw(e,t,n){return u(await c.post(`/projects/${e}/secrets/${encodeURIComponent(t)}/grant`,{agent:n}))}async function ql(e,t){return u(await c.put(`/projects/${e}/default-agent`,{agent:t}))}function sr(){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}}}function iw(e){let t=e.trim().toLowerCase();return t===""||t==="free"||t==="none"?"free":t==="enterprise"?"enterprise":"team"}function ow(e){let t=e?.plan;if(t)return{family:t.family,label:t.label,sublabel:t.sublabel??null,isGrandfathered:t.is_grandfathered===!0};let n=e??sr(),r=(n.subscription?.tier_key||n.tier?.name||"none").toString(),s=(n.tier?.display_name||"").trim()||r;return{family:iw(r),label:s,sublabel:null,isGrandfathered:!1}}async function Ul(e){let t=new URLSearchParams;e?.skipCache&&t.set("skip_cache","true"),e?.accountId&&t.set("account_id",e.accountId);let n=t.toString(),r=n?`?${n}`:"",s=await c.get(`/billing/account-state${r}`,{showErrors:!1}),i=s.error?.status===404&&/billing is not enabled/i.test(s.error.message||"");if(s.error&&s.error.status!==401&&!i)throw s.error;return s.error?sr():s.data}async function Fl(e){let t=new URLSearchParams;e?.skipCache&&t.set("skip_cache","true"),e?.accountId&&t.set("account_id",e.accountId);let n=t.toString(),r=n?`?${n}`:"",s=await c.get(`/billing/account-state/minimal${r}`,{showErrors:!1}),i=s.error?.status===404&&/billing is not enabled/i.test(s.error.message||"");if(s.error&&s.error.status!==401&&!i)throw s.error;return s.error?sr():s.data}async function Ll(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 n=t.toString();return u(await c.get(`/billing/transactions${n?`?${n}`:""}`))}async function Bl(e){let t=new URLSearchParams;e?.accountId&&t.set("account_id",e.accountId),e?.days!=null&&t.set("days",String(e.days));let n=t.toString();return u(await c.get(`/billing/transactions/summary${n?`?${n}`:""}`))}async function Gl(){return u(await c.get("/billing/credit-breakdown"))}async function Nl(e){let t=e!=null?`?days=${e}`:"";return u(await c.get(`/billing/usage-history${t}`))}async function Wl(){return u(await c.get("/billing/tier-configurations"))}async function aw(e){let t=e.accountId?`?account_id=${encodeURIComponent(e.accountId)}`:"";return ut(e,`/v1/billing/account-state${t}`)}async function Kl(e){return u(await c.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 Hl(e,t){return u(await c.post("/billing/confirm-checkout-session",{account_id:t,session_id:e}),"Failed to confirm checkout session")}async function zl(e,t){return u(await c.post("/billing/create-portal-session",{account_id:t,return_url:e}),"Failed to create portal session")}async function Vl(e,t){return u(await c.post("/billing/cancel-subscription",{account_id:t,feedback:e}),"Failed to cancel subscription")}async function Jl(e){return u(await c.post("/billing/reactivate-subscription",{account_id:e}),"Failed to reactivate subscription")}async function Xl(e,t,n){return u(await c.post("/billing/schedule-downgrade",{account_id:n,target_tier_key:e,commitment_type:t}),"Failed to schedule downgrade")}async function Ql(e){return u(await c.post("/billing/cancel-scheduled-change",{account_id:e}),"Failed to cancel scheduled change")}async function Yl(e,t){let n=new URLSearchParams({new_price_id:e});return t&&n.set("account_id",t),u(await c.get(`/billing/proration-preview?${n.toString()}`),"Failed to load proration preview")}async function Zl(e){return u(await c.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 eu(e){let t=e?`?account_id=${encodeURIComponent(e)}`:"";return u(await c.get(`/billing/auto-topup/settings${t}`),"Failed to load auto-topup settings")}async function tu(e){return u(await c.post("/billing/auto-topup/configure",{account_id:e.accountId,enabled:e.enabled,threshold:e.threshold,amount:e.amount},{showErrors:!1}),"Failed to configure auto-topup")}async function cw(e){let t=e?`?account_id=${encodeURIComponent(e)}`:"";return u(await c.get(`/billing/auto-topup/setup-status${t}`,{timeout:8e3,showErrors:!1}),"Failed to load auto-topup setup status")}async function lw(e){return u(await c.post("/billing/create-per-seat-checkout",{account_id:e.accountId,success_url:e.successUrl,cancel_url:e.cancelUrl,locale:e.locale}),"Failed to create per-seat checkout")}async function uw(e){return u(await c.post("/billing/claim-per-seat",{account_id:e}),"Failed to switch to per-seat billing")}async function pw(e){return u(await c.post("/billing/sync-subscription",{account_id:e}),"Failed to sync subscription")}async function nu(e={}){let t=new URLSearchParams;e.start&&t.set("start",e.start),e.end&&t.set("end",e.end),(e.groupBy==="model"||e.groupBy==="provider"||e.groupBy==="day")&&t.set("group_by",e.groupBy),e.accountId&&t.set("account_id",e.accountId);let n=t.toString();return u(await c.get(`/usage${n?`?${n}`:""}`))}function su(e,t){t.accountId&&e.set("account_id",t.accountId),t.projectId&&e.set("project_id",t.projectId)}function ir(e,t){t.from&&e.set("from",t.from),t.to&&e.set("to",t.to)}function or(e){return e.size>0?`?${e}`:""}async function iu(e={}){let t=new URLSearchParams;return su(t,e),e.ownerId&&t.set("owner_id",e.ownerId),ir(t,e),e.sort&&t.set("sort",e.sort),e.limit!=null&&t.set("limit",String(e.limit)),e.offset!=null&&t.set("offset",String(e.offset)),u(await c.get(`/usage/session-costs${or(t)}`))}async function ar(e,t={}){let n=new URLSearchParams;return su(n,t),u(await c.get(`/usage/session-costs/${encodeURIComponent(e)}${or(n)}`))}async function dw(e={}){let t=new URLSearchParams;return e.accountId&&t.set("account_id",e.accountId),ir(t,e),e.sort&&t.set("sort",e.sort),e.limit!=null&&t.set("limit",String(e.limit)),e.offset!=null&&t.set("offset",String(e.offset)),u(await c.get(`/usage/cost-by-project${or(t)}`))}async function gw(e={}){let t=new URLSearchParams;return su(t,e),e.sessionId&&t.set("session_id",e.sessionId),ir(t,e),u(await c.get(`/usage/cost-summary${or(t)}`))}function ru(e,t={}){let n=new URLSearchParams;if(t.accountId&&n.set("account_id",t.accountId),e==="sessions"){let s=t;s.projectId&&n.set("project_id",s.projectId),s.ownerId&&n.set("owner_id",s.ownerId)}ir(n,t),t.sort&&n.set("sort",t.sort),n.set("format","csv");let r=e==="projects"?"/usage/cost-by-project":"/usage/session-costs";return`${$().backendUrl||""}${r}?${n}`}async function mw(e,t={}){let n=ru(e==="projects"?"projects":"sessions",t),r=await Je(),s=await fetch(n,{method:"GET",headers:r?{Authorization:`Bearer ${r}`}:{}});if(!s.ok){let p=await s.text().catch(()=>"");throw new Error(p||`Failed to export CSV (HTTP ${s.status})`)}let i=s.headers.get("x-kortix-row-cap"),o=i!=null?Number(i):NaN;return{blob:await s.blob(),rowCap:Number.isFinite(o)?o:null}}async function Mm(e,t){return u(await c.post(`/channels/${e}/identity/bind`,{token:t}),"Failed to connect your account")}function fw(e){return Mm("slack",e)}function yw(e){return Mm("teams",e)}async function $m(e,t){return u(await c.post(`/channels/${e}/identity/preview`,{token:t},{showErrors:!1}),"This link is invalid or has expired")}function hw(e){return $m("slack",e)}function bw(e){return $m("teams",e)}async function ou(e){let t=await c.get(`/projects/${encodeURIComponent(e)}/channels/slack/installation`,{showErrors:!1});return t.success?t.data??null:null}async function au(e,t){return u(await c.post(`/projects/${encodeURIComponent(e)}/channels/slack/connect`,t,{showErrors:!1}),"Failed to connect")}var _w={oauth_available:!1,install_url:null};async function cu(e){let t=await c.get(`/projects/${encodeURIComponent(e)}/channels/slack/mode`,{showErrors:!1});return!t.success||!t.data?_w:t.data}async function Om(e,t,n){return u(await c.post(`/projects/${encodeURIComponent(t)}/channels/${e}/oauth/complete`,{code:n.code,state:n.state},{showErrors:!1}),"Failed to finish the install")}function lu(e,t){return Om("slack",e,t)}function uu(e,t){return Om("teams",e,t)}async function pu(e){return u(await c.get(`/webhooks/slack/${encodeURIComponent(e)}/manifest`,{showErrors:!1}),"Failed to load Slack manifest")}async function du(e){let t=await c.delete(`/projects/${encodeURIComponent(e)}/channels/slack/installation`,{showErrors:!1});if(!t.success)throw new Error(t.error?.message??"Failed to disconnect")}async function gu(e,t){return u(await c.get(`/projects/${encodeURIComponent(e)}/channels/slack/file?url=${encodeURIComponent(t)}`,{showErrors:!1}),"Failed to download Slack file")}async function mu(e,t){return u(await c.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 fu(e){let t=e.connectionId??e.connection_id??null,n=e.connectorSlug??e.connector_slug??e.connectionSlug??e.connection_slug??"kortix_email";return{...e,connectionId:t,connectorSlug:n}}var xw={provider:"agentmail",managed_available:!1};async function yu(e,t){let n=t?`?connector_slug=${encodeURIComponent(t)}`:"",r=await c.get(`/projects/${encodeURIComponent(e)}/channels/email/installation${n}`,{showErrors:!1});return r.success&&r.data?fu(r.data):null}async function hu(e){let t=await c.get(`/projects/${encodeURIComponent(e)}/channels/email/mode`,{showErrors:!1});return!t.success||!t.data?xw:t.data}async function bu(e,t){let n=u(await c.post(`/projects/${encodeURIComponent(e)}/channels/email/connect`,t,{showErrors:!1}),"Failed to connect email");return fu(n)}async function _u(e,t){let n=t?`?connector_slug=${encodeURIComponent(t)}`:"",r=await c.delete(`/projects/${encodeURIComponent(e)}/channels/email/installation${n}`,{showErrors:!1});if(!r.success)throw new Error(r.error?.message??"Failed to disconnect email")}async function xu(e,t,n){let r=u(await c.patch(`/projects/${encodeURIComponent(e)}/channels/email/installation`,{connector_slug:t??"kortix_email",sender_policy:n},{showErrors:!1}),"Failed to update email policy");return fu(r)}async function ww(e){return u(await c.get(`/projects/${encodeURIComponent(e)}/channels/bindings`,{showErrors:!1}),"Failed to load channel bindings")}async function kw(e,t,n){return u(await c.patch(`/projects/${encodeURIComponent(e)}/channels/bindings/${encodeURIComponent(t)}`,n,{showErrors:!1}),"Failed to update channel binding")}async function wu(e){return u(await c.get(`/projects/${e}/gateway/routing-policy`),"Gateway routing policy request failed")}async function ku(e,t){return u(await c.put(`/projects/${e}/gateway/routing-policy`,t),"Gateway routing policy request failed")}async function Pu(e){return u(await c.delete(`/projects/${e}/gateway/routing-policy`),"Gateway routing policy request failed")}async function Su(e,t){return u(await c.post(`/projects/${e}/gateway/routing-policy/preview`,t),"Gateway route preview failed")}async function vu(e,t){let n=new URLSearchParams;t?.limit&&n.set("limit",String(t.limit)),t?.offset&&n.set("offset",String(t.offset)),t?.ok!==void 0&&n.set("ok",String(t.ok));let r=n.toString();return u(await c.get(`/projects/${e}/gateway/logs${r?`?${r}`:""}`),"Gateway request failed")}async function Au(e,t){return u(await c.get(`/projects/${e}/gateway/logs/${t}`),"Gateway request failed")}async function Ru(e,t){return u(await c.get(`/projects/${e}/gateway/overview${t?`?days=${t}`:""}`),"Gateway request failed")}async function Cu(e,t){return u(await c.get(`/projects/${e}/gateway/series${t?`?days=${t}`:""}`),"Gateway request failed")}async function Tu(e,t){return u(await c.get(`/projects/${e}/gateway/breakdown${t?`?days=${t}`:""}`),"Gateway request failed")}async function Iu(e,t){return u(await c.get(`/projects/${e}/gateway/sessions${t?`?days=${t}`:""}`),"Gateway request failed")}async function Eu(e,t){return u(await c.get(`/projects/${e}/gateway/errors${t?`?days=${t}`:""}`),"Gateway request failed")}async function ju(e){return u(await c.get(`/projects/${e}/gateway/budgets`),"Gateway request failed")}async function Mu(e,t){return u(await c.put(`/projects/${e}/gateway/budgets`,t),"Gateway request failed")}async function $u(e,t){return u(await c.delete(`/projects/${e}/gateway/budgets/${t}`),"Gateway request failed")}async function Ou(e){return u(await c.get(`/projects/${e}/gateway/keys`),"Gateway request failed")}async function Du(e,t){return u(await c.post(`/projects/${e}/gateway/keys`,{name:t}),"Gateway request failed")}async function qu(e,t){return u(await c.delete(`/projects/${e}/gateway/keys/${t}`),"Gateway request failed")}async function Uu(e,t,n,r,s){return u(await c.post(`/projects/${e}/gateway/playground`,{prompt:t,models:n,...r?{system:r}:{},...s&&Object.keys(s).length?{generationConfig:s}:{}}),"Gateway request failed")}async function Pw(e,t){return u(await c.post(`/projects/${e}/gateway/providers/${encodeURIComponent(t)}/verify`,{}),"Gateway provider verification failed")}async function Sw(){throw W("getReferralCode")}async function vw(){throw W("refreshReferralCode")}async function Aw(e){throw W("validateReferralCode")}async function Rw(){throw W("getReferralStats")}async function Cw(e={}){throw W("listReferrals")}async function Tw(e){throw W("sendReferralEmails")}function C(e){if(!e.success||e.data===void 0)throw e.error||new Error("Unexpected empty response");return e.data}function B(e){return c.get(e,{showErrors:!1})}async function Fu(e){return C(await B(`/accounts/${e}/iam/groups`)).groups}async function Lu(e,t){return C(await B(`/accounts/${e}/iam/groups/${t}`))}async function Bu(e,t){return C(await c.post(`/accounts/${e}/iam/groups`,t,{showErrors:!1}))}async function Gu(e,t,n){return C(await c.patch(`/accounts/${e}/iam/groups/${t}`,n))}async function Nu(e,t){return C(await c.delete(`/accounts/${e}/iam/groups/${t}`))}async function Wu(e,t){return C(await B(`/accounts/${e}/iam/groups/${t}/members`)).members}async function Ku(e,t,n){return C(await c.post(`/accounts/${e}/iam/groups/${t}/members`,{userIds:n}))}async function Iw(e,t){return C(await B(`/accounts/${e}/iam/groups/${t}/project-grants`)).grants}async function Hu(e,t,n){return C(await c.delete(`/accounts/${e}/iam/groups/${t}/members/${n}`))}async function Ew(e,t){return C(await B(`/accounts/${e}/iam/members/${t}/groups`)).groups}async function jw(e,t){let n=C(await B(`/accounts/${e}/iam/members/${t}/project-access`));return{projects:n.projects,account_wide_policies:n.account_wide_policies??[]}}async function Mw(e,t={}){let n=new URLSearchParams;t.resourceType&&n.set("resourceType",t.resourceType),t.principalType&&n.set("principalType",t.principalType),t.principalId&&n.set("principalId",t.principalId),t.projectId&&n.set("projectId",t.projectId);let r=n.toString();return C(await B(`/accounts/${e}/iam/resource-grants${r?`?${r}`:""}`)).grants}async function $w(e,t={}){let n=new URLSearchParams;t.principalType&&n.set("principalType",t.principalType),t.principalId&&n.set("principalId",t.principalId),t.scopeType&&n.set("scopeType",t.scopeType),t.scopeId!==void 0&&n.set("scopeId",t.scopeId===null?"null":t.scopeId);let r=n.toString();return C(await B(`/accounts/${e}/iam/policies${r?`?${r}`:""}`)).policies}async function Ow(e,t){return C(await c.post(`/accounts/${e}/iam/policies`,t,{showErrors:!1}))}async function Dw(e,t,n){return C(await c.patch(`/accounts/${e}/iam/policies/${t}`,n,{showErrors:!1}))}async function qw(e,t){return C(await c.delete(`/accounts/${e}/iam/policies/${t}`))}async function Uw(e,t){return C(await c.post(`/accounts/${e}/iam/policies:bulk-delete`,{policy_ids:t},{showErrors:!1}))}async function Fw(e,t){return C(await c.post(`/accounts/${e}/iam/policies:bulk-import`,{policies:t},{showErrors:!1}))}async function zu(e){return C(await B(`/accounts/${e}/iam/roles`)).roles}async function Vu(e){return C(await B(`/accounts/${e}/iam/agent-identities`)).agents}async function Ju(e,t){return C(await B(`/accounts/${e}/iam/roles/${t}/permissions`))}async function Lw(e){return C(await B(`/accounts/${e}/iam/actions`)).actions}async function Xu(e,t){return C(await B(`/accounts/${e}/iam/roles/${t}/usage`))}async function Qu(e,t){return C(await c.post(`/accounts/${e}/iam/roles`,t,{showErrors:!1}))}async function Yu(e,t,n){return C(await c.patch(`/accounts/${e}/iam/roles/${t}`,n,{showErrors:!1}))}async function Zu(e,t,n){return C(await c.put(`/accounts/${e}/iam/roles/${t}/permissions`,{actions:n},{showErrors:!1}))}async function ep(e,t){return C(await c.delete(`/accounts/${e}/iam/roles/${t}`,{showErrors:!1}))}async function Bw(e,t,n){return C(await c.patch(`/accounts/${e}/iam/members/${t}/super-admin`,{isSuperAdmin:n}))}async function Gw(e){return C(await B(`/accounts/${e}/iam/scim/tokens`)).tokens}async function Nw(e,t){return C(await c.post(`/accounts/${e}/iam/scim/tokens`,t,{showErrors:!1}))}async function Ww(e,t){return C(await c.delete(`/accounts/${e}/iam/scim/tokens/${t}`))}async function Kw(e){return C(await B(`/accounts/${e}/iam/mfa-required`))}async function Hw(e){return C(await B(`/accounts/${e}/iam/mfa-required/preview`))}async function zw(e,t){return C(await c.patch(`/accounts/${e}/iam/mfa-required`,{enabled:t},{showErrors:!1}))}async function Vw(e){return C(await B(`/accounts/${e}/iam/session-oversight`))}async function Jw(e,t){return C(await c.patch(`/accounts/${e}/iam/session-oversight`,{enabled:t},{showErrors:!1}))}async function Xw(e){return C(await B(`/accounts/${e}/iam/sso/provider`)).provider}async function Qw(e,t){return C(await c.put(`/accounts/${e}/iam/sso/provider`,t,{showErrors:!1})).provider}async function Yw(e,t){return C(await c.post(`/accounts/${e}/iam/sso/provider/from-metadata`,t,{showErrors:!1})).provider}async function Zw(e){return C(await c.post(`/accounts/${e}/iam/sso/provider/verify-domain`,{},{showErrors:!1})).provider}async function ek(e){return C(await c.delete(`/accounts/${e}/iam/sso/provider`))}async function tk(e){return C(await B(`/accounts/${e}/iam/sso/mappings`)).mappings}async function nk(e,t){return C(await c.post(`/accounts/${e}/iam/sso/mappings`,t,{showErrors:!1}))}async function rk(e,t){return C(await c.delete(`/accounts/${e}/iam/sso/mappings/${t}`))}async function sk(e){return C(await B(`/accounts/${e}/iam/session-policy`))}async function ik(e,t){return C(await c.patch(`/accounts/${e}/iam/session-policy`,t,{showErrors:!1}))}async function ok(e){return C(await B(`/accounts/${e}/iam/sessions`)).sessions}async function ak(e,t){return C(await c.post(`/accounts/${e}/iam/sessions/${t}/revoke`,{},{showErrors:!1}))}async function ck(e){return C(await B(`/accounts/${e}/iam/pat-policy`))}async function lk(e,t){return C(await c.patch(`/accounts/${e}/iam/pat-policy`,t,{showErrors:!1}))}async function uk(e){return C(await B(`/accounts/${e}/iam/service-accounts`)).service_accounts}async function pk(e,t){return C(await c.post(`/accounts/${e}/iam/service-accounts`,t,{showErrors:!1}))}async function dk(e,t){return C(await c.post(`/accounts/${e}/iam/service-accounts/${t}/disable`,{},{showErrors:!1}))}async function gk(e,t){return C(await c.delete(`/accounts/${e}/iam/service-accounts/${t}`))}async function mk(e){return C(await B(`/accounts/${e}/audit/webhooks`)).webhooks}async function fk(e,t){return C(await c.post(`/accounts/${e}/audit/webhooks`,t,{showErrors:!1}))}async function yk(e,t,n){return C(await c.patch(`/accounts/${e}/audit/webhooks/${t}`,n))}async function hk(e,t){return C(await c.delete(`/accounts/${e}/audit/webhooks/${t}`))}async function bk(e,t={}){let n=new URLSearchParams;t.action&&n.set("action",t.action),t.actor&&n.set("actor",t.actor),t.project_id&&n.set("project_id",t.project_id),t.session_id&&n.set("session_id",t.session_id),t.actor_type&&n.set("actor_type",t.actor_type),t.source&&n.set("source",t.source),t.phase&&n.set("phase",t.phase),t.outcome&&n.set("outcome",t.outcome),t.request_id&&n.set("request_id",t.request_id),t.correlation_id&&n.set("correlation_id",t.correlation_id),t.resource_type&&n.set("resource_type",t.resource_type),t.since&&n.set("since",t.since),t.until&&n.set("until",t.until),t.q&&n.set("q",t.q),t.cursor&&n.set("cursor",t.cursor),t.limit&&n.set("limit",String(t.limit));let r=n.toString();return C(await B(`/accounts/${e}/audit${r?`?${r}`:""}`))}async function tp(e,t,n){let r=new URLSearchParams;return r.set("action",n.action),n.resourceType&&r.set("resourceType",n.resourceType),n.resourceId&&r.set("resourceId",n.resourceId),C(await B(`/accounts/${e}/iam/members/${t}/effective?${r.toString()}`))}async function np(e,t,n){return n.length===0?[]:C(await c.post(`/accounts/${e}/iam/members/${t}/effective:batch`,{probes:n})).results}async function _k(e){return C(await B(`/accounts/${e}/iam/enterprise-demo`)).enabled}async function xk(e,t){return C(await c.put(`/accounts/${e}/iam/enterprise-demo`,{enabled:t})).enabled}async function rp(e){return u(await c.get(`/accounts/${e}/iam/oauth-clients`,{showErrors:!1}))}async function sp(e,t){return u(await c.get(`/accounts/${e}/iam/oauth-clients/${t}`,{showErrors:!1}))}async function ip(e,t){return u(await c.post(`/accounts/${e}/iam/oauth-clients`,t,{showErrors:!1}))}async function op(e,t,n){return u(await c.patch(`/accounts/${e}/iam/oauth-clients/${t}`,n,{showErrors:!1}))}async function ap(e,t){return u(await c.post(`/accounts/${e}/iam/oauth-clients/${t}/rotate-secret`,{},{showErrors:!1}))}async function cp(e,t){return u(await c.delete(`/accounts/${e}/iam/oauth-clients/${t}`,{showErrors:!1}))}function Dm(e){return c.get(e,{showErrors:!1})}function wk(e){let t=new URLSearchParams;e?.principalType&&t.set("principal_type",e.principalType),e?.principalId&&t.set("principal_id",e.principalId),e?.scopeType&&t.set("scope_type",e.scopeType),e?.scopeId&&t.set("scope_id",e.scopeId),e?.objectType&&t.set("object_type",e.objectType),e?.objectId&&t.set("object_id",e.objectId),e?.roleId&&t.set("role_id",e.roleId),e?.includeExpired&&t.set("include_expired","true");let n=t.toString();return n?`?${n}`:""}async function lp(e,t){return u(await Dm(`/accounts/${e}/iam/assignments${wk(t)}`)).assignments}async function up(e,t){let n={principal_type:t.principal.type,principal_id:t.principal.id,scope_type:t.scope.type,scope_id:t.scope.type==="project"?t.scope.id:null};return t.roleId?n.role_id=t.roleId:n.role_key=t.roleKey,t.object&&(n.object_type=t.object.type,n.object_id=t.object.id),t.expiresAt!==void 0&&(n.expires_at=t.expiresAt),u(await c.post(`/accounts/${e}/iam/assignments`,n))}async function pp(e,t){return u(await c.delete(`/accounts/${e}/iam/assignments/${t}`)).assignment}async function dp(e,t){let n=t?.scopeType?`?scope_type=${t.scopeType}`:"";return u(await Dm(`/accounts/${e}/iam/permissions${n}`)).permissions}async function kk(){let e=await c.get("/account/deletion-status",{showErrors:!1});return e.error?.status===404?null:u(e,"Failed to load account deletion status")}async function Pk(e="User requested deletion"){return u(await c.post("/account/request-deletion",{reason:e},{showErrors:!1}),"Failed to request account deletion")}async function Sk(){return u(await c.post("/account/cancel-deletion",void 0,{showErrors:!1}),"Failed to cancel account deletion")}async function vk(){return u(await c.delete("/account/delete-immediately",{showErrors:!1}),"Failed to delete account immediately")}async function Ak(){return(await c.get("/user-roles",{showErrors:!1})).data??{isAdmin:!1,role:null}}function Rk(){return c.get("/admin/api/provider-distribution").then(e=>u(e))}function Ck(e=300){return c.get(`/admin/api/sandboxes?limit=${e}`).then(t=>u(t))}function Tk(e){return c.put("/admin/api/provider-distribution",e).then(t=>u(t))}function Ik(e){return c.get(`/admin/api/provider-analytics?days=${e}`).then(t=>u(t))}function Ek(e,t){return c.post(`/admin/api/sandboxes/${encodeURIComponent(e)}/migrate`,{targetProvider:t}).then(n=>u(n))}function jk(){return c.get("/admin/api/provider-fallback").then(e=>u(e))}function Mk(e){return c.put("/admin/api/provider-fallback",{enabled:e}).then(t=>u(t))}var qm="Export the deck as PDF or PPTX with convertRuntimePresentation().";async function $k(e){throw W("getGoogleAuthUrl",qm)}async function Ok(e,t){throw W("convertPresentationToGoogleSlides",qm)}async function gp(e,t){let n=new URLSearchParams;t?.segment&&n.set("segment",t.segment),t?.kind&&n.set("kind",t.kind);let r=n.toString();return u(await c.get(`/projects/${e}/review/items${r?`?${r}`:""}`,{showErrors:!1}))}async function mp(e,t){return u(await c.get(`/projects/${e}/review/items/${t}`))}async function fp(e,t){return u(await c.post(`/projects/${e}/review/items`,t))}async function yp(e,t,n){return u(await c.post(`/projects/${e}/review/items/${t}/act`,n))}async function hp(e,t){return u(await c.post(`/projects/${e}/review/bulk`,t))}var bp="call:";function Dk(e){return e.startsWith("cr:")&&e.length>3?{type:"change_request",changeRequestId:e.slice(3)}:e.startsWith(bp)&&e.length>bp.length?{type:"connector_call",executionId:e.slice(bp.length)}:{type:"review_item",reviewItemId:e}}function Fm(e){return e==="needs_you"?"needs_you":e==="waiting"?"waiting":"done"}function qk(e){let t={needs_you:0,waiting:0,done:0};for(let n of e)t[Fm(n.status)]+=1;return t}function Uk(e){switch(e){case"approved":return"approve";case"rejected":return"reject";case"changes_requested":return"changes";case"done":return"answer";case"dismissed":return"dismiss";default:return null}}function _p(e){return e.split(/[._-]/).filter(Boolean).map(t=>t.charAt(0).toUpperCase()+t.slice(1)).join(" ")}function xp(e){let t=e.indexOf(".");return t<=0?_p(e):`(${_p(e.slice(0,t))}) ${_p(e.slice(t+1))}`}function Fk(e){let t=e.indexOf(".");return t>0?{connector:e.slice(0,t),action:e.slice(t+1)}:{connector:e,action:""}}var cr=e=>e&&typeof e=="object"&&!Array.isArray(e)?e:{},U=e=>typeof e=="string"&&e?e:void 0,de=e=>Array.isArray(e)?e:void 0,Um=e=>typeof e=="number"?e:0,Lk=e=>e.split(`
|
|
20
|
-
`).map(t=>t.trim()).filter(Boolean);function Bk(e,t){let n=cr(e.advanced),r=U(e.description),s=de(e.whatChanged)??(r?Lk(r):t.summary?[t.summary]:[]);return{crId:U(e.cr_id),number:typeof e.number=="number"?e.number:void 0,whatChanged:s,impact:U(e.impact)??"",verification:de(e.verification)??[],previewUrl:U(e.previewUrl)??U(e.preview_url),conflicts:de(e.conflicts),requestedChanges:de(e.requested_changes)??[],advanced:{headRef:U(n.headRef)??U(e.head_ref)??"",baseRef:U(n.baseRef)??U(e.base_ref)??"",headSha:U(n.headSha)??U(e.head_sha)??U(e.head_commit_sha)??"",baseSha:U(n.baseSha)??U(e.base_sha)??"",additions:Um(n.additions),deletions:Um(n.deletions),files:de(n.files)??[],mergeMode:U(n.mergeMode)??"merge"}}}function Gk(e,t){let n=de(e.actions);if(n)return{actions:n.map((p,g)=>({id:U(p.id)??`${t.review_item_id}-${g}`,title:U(p.title)??"Action",connector:U(p.connector)??"",action:U(p.action)??"",consequence:U(p.consequence)??"",risk:U(p.risk)??t.risk,icon:U(p.icon)??"generic",argsPreview:de(p.argsPreview)??[],policySource:U(p.policySource)??"Requires approval",decided:p.decided==="approved"||p.decided==="denied"?p.decided:void 0}))};let r=U(e.action_path)??"",{connector:s,action:i}=Fk(r),o=cr(e.args_preview),a=Object.keys(o).length>0;return{actions:[{id:U(e.execution_id)??t.review_item_id,title:r?xp(r):t.title||"Run action",connector:s,action:i,consequence:"Runs against the real connector once you approve",risk:t.risk,icon:"generic",argsPreview:Object.entries(o).map(([p,g])=>({key:p,value:g==="[redacted]"?"Hidden credential":typeof g=="string"?g:JSON.stringify(g,null,2)})),actionPath:r,rawArgsPreview:a?o:void 0,reviewComplete:e.args_preview_complete===!0,previewAuthorized:e.args_preview_authorized!==!1,connectorRisk:U(e.risk)??null,policySource:"Requires approval"}]}}function Nk(e,t){return{artifactKind:U(e.artifactKind)??"document",artifactLabel:U(e.artifactLabel)??"Output",previewUrl:U(e.previewUrl)??U(e.preview_url),preview:U(e.preview),files:de(e.files),note:U(e.note)??t.summary??""}}function Wk(e,t){return{question:U(e.question)??t.title??"",context:U(e.context),options:de(e.options)??[]}}function Kk(e,t){return{note:U(e.note)??t.summary??"",children:de(e.children)??[]}}function Hk(e){let t=cr(e.detail);switch(e.kind){case"change":return Bk(t,e);case"approval":return Gk(t,e);case"output":return Nk(t,e);case"decision":return Wk(t,e);case"batch":return Kk(t,e)}}function zk(e,t){let n=typeof e.number=="number"?e.number:void 0,r=U(e.base_ref);return n!=null&&r?`#${n} \u2192 ${r}`:t}function Vk(e,t={}){let n=cr(e.detail),r=e.origin_session_id??void 0,s=r?t.sessionLabels?.[r]:void 0,i=e.kind==="approval"?U(n.action_path):void 0,o=e.kind==="change"?zk(n,e.summary):e.kind==="approval"?s??(r?"From a running session":e.summary):e.summary;return{id:e.review_item_id,kind:e.kind,title:i?xp(i):e.title,summary:o,risk:e.risk,status:e.status,source:e.source,agent:e.agent||"Agent",createdAt:e.created_at,sessionId:r,detail:Hk(e)}}async function wp(e){return u(await c.get(`/p/share?sandbox_id=${encodeURIComponent(e)}`),"Failed to load public links").shares??[]}async function kp(e){return u(await c.post("/p/share",{sandbox_id:e.sandboxId,port:e.port,ttl:e.ttl,label:e.label}),"Failed to generate public URL")}async function Pp(e,t){let n=await c.delete(`/p/share/${encodeURIComponent(t)}?sandbox_id=${encodeURIComponent(e)}`);if(!n.success)throw new Error(n.error?.message??"Failed to revoke public link")}var lr=class extends Error{constructor(n,r){super(n);this.status=r;this.name="PublicSessionShareError"}status};function Lm(e,t=""){return`${Et()}/public/session-shares/${encodeURIComponent(e)}${t}`}async function Bm(e){let t=await fetch(e,{method:"GET",headers:{Accept:"application/json"}}),n=await t.text().catch(()=>""),r=null;try{r=n?JSON.parse(n):null}catch{}if(!t.ok){let s=(r&&typeof r=="object"&&"error"in r&&typeof r.error=="string"?r.error:null)||t.statusText||`HTTP ${t.status}`;throw new lr(s,t.status)}return r}async function Jk(e){return Bm(Lm(e))}async function Xk(e){return Bm(Lm(e,"/messages"))}async function Sp(e,t){let n=new URLSearchParams;e&&n.set("account_id",e),t?.mine&&n.set("mine","true");let r=n.size>0?`?${n.toString()}`:"";return u(await c.get(`/accounts/tokens${r}`))}async function vp(e){let{accountId:t,expiresAt:n,projectId:r,name:s}=e;return u(await c.post("/accounts/tokens",{name:s,...t?{account_id:t}:{},...n?{expires_at:n}:{},...r?{project_id:r}:{}}))}async function Ap(e,t){let n=t?`?account_id=${encodeURIComponent(t)}`:"";return u(await c.delete(`/accounts/tokens/${e}${n}`))}async function Rp(e){return u(await c.get(`/projects/${e}/cli-token`))}async function Cp(e,t){return u(await c.post(`/projects/${e}/cli-token`,t??{}))}async function Tp(e,t){return u(await c.delete(`/projects/${e}/cli-token/${t}`))}async function Ip(e,t){let n=new URLSearchParams;t?.action&&n.set("action",t.action),t?.actor&&n.set("actor",t.actor),t?.actorType&&n.set("actor_type",t.actorType),t?.projectId&&n.set("project_id",t.projectId),t?.sessionId&&n.set("session_id",t.sessionId),t?.source&&n.set("source",t.source),t?.phase&&n.set("phase",t.phase),t?.outcome&&n.set("outcome",t.outcome),t?.resourceType&&n.set("resource_type",t.resourceType),t?.requestId&&n.set("request_id",t.requestId),t?.correlationId&&n.set("correlation_id",t.correlationId),t?.since&&n.set("since",t.since),t?.until&&n.set("until",t.until),t?.q&&n.set("q",t.q),t?.cursor&&n.set("cursor",t.cursor),t?.limit!=null&&n.set("limit",String(t.limit));let r=n.toString();return u(await c.get(`/accounts/${e}/audit${r?`?${r}`:""}`))}async function Ep(e,t){let n=new URLSearchParams;t?.action&&n.set("action",t.action),t?.actor&&n.set("actor",t.actor),t?.actorType&&n.set("actor_type",t.actorType),t?.sessionId&&n.set("session_id",t.sessionId),t?.source&&n.set("source",t.source),t?.phase&&n.set("phase",t.phase),t?.outcome&&n.set("outcome",t.outcome),t?.resourceType&&n.set("resource_type",t.resourceType),t?.requestId&&n.set("request_id",t.requestId),t?.correlationId&&n.set("correlation_id",t.correlationId),t?.since&&n.set("since",t.since),t?.until&&n.set("until",t.until),t?.q&&n.set("q",t.q),t?.cursor&&n.set("cursor",t.cursor),t?.limit!=null&&n.set("limit",String(t.limit));let r=n.toString();return u(await c.get(`/projects/${e}/audit${r?`?${r}`:""}`))}async function jp(e,t){let n=new URLSearchParams;t?.format&&n.set("format",t.format),t?.action&&n.set("action",t.action),t?.actor&&n.set("actor",t.actor),t?.actorType&&n.set("actor_type",t.actorType),t?.projectId&&n.set("project_id",t.projectId),t?.sessionId&&n.set("session_id",t.sessionId),t?.source&&n.set("source",t.source),t?.phase&&n.set("phase",t.phase),t?.outcome&&n.set("outcome",t.outcome),t?.resourceType&&n.set("resource_type",t.resourceType),t?.requestId&&n.set("request_id",t.requestId),t?.correlationId&&n.set("correlation_id",t.correlationId),t?.since&&n.set("since",t.since),t?.until&&n.set("until",t.until),t?.q&&n.set("q",t.q),t?.cursor&&n.set("cursor",t.cursor),t?.limit!=null&&n.set("limit",String(t.limit));let r=n.toString();return u(await c.get(`/accounts/${e}/audit/export${r?`?${r}`:""}`))}async function Mp(e){return u(await c.get(`/accounts/${e}/audit/webhooks`))}async function $p(e,t){return u(await c.post(`/accounts/${e}/audit/webhooks`,t))}async function Op(e,t,n){return u(await c.patch(`/accounts/${e}/audit/webhooks/${t}`,n))}async function Dp(e,t){return u(await c.delete(`/accounts/${e}/audit/webhooks/${t}`))}async function qp(e,t){return u(await c.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 Up(e,t){return u(await c.post(`/projects/${e}/connect-requests`,{slug:t.slug,...t.owner?{owner:t.owner}:{},...t.label?{label:t.label}:{},expires_in_minutes:t.expiresInMinutes}),"Failed to mint connect link")}async function Qk(e){return u(await c.get(`/approval-links/${e}`),"Failed to load approval")}async function Fp(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),e?.limit!==void 0&&t.set("limit",String(e.limit)),e?.offset!==void 0&&t.set("offset",String(e.offset));let n=t.toString()?`?${t.toString()}`:"";return u(await c.get(`/marketplace/items${n}`))}async function Lp(){return u(await c.get("/marketplace/marketplaces"))}async function Bp(){return u(await c.get("/marketplace/marketplaces/featured"))}async function Gp(e){return u(await c.get(`/marketplace/items/${encodeURIComponent(e)}`),"Item not found")}async function Np(e,t){return u(await c.get(`/marketplace/items/${encodeURIComponent(e)}/file?path=${encodeURIComponent(t)}`),"File not found")}async function Wp(){return u(await c.get("/marketplace/sources"))}async function Kp(e){return u(await c.post("/marketplace/sources",e),"Failed to add marketplace source")}async function Hp(e){return u(await c.delete(`/marketplace/sources/${encodeURIComponent(e)}`),"Failed to remove marketplace source")}async function Yk(e,t){return u(await c.post(`/projects/${encodeURIComponent(e)}/marketplace/install-session`,{id:t}),"Failed to start marketplace install session")}async function Zk(e){throw W("getTemplate")}async function eP(e,t){throw W("installTemplate")}async function zp(e){return u(await c.get(`/projects/${e}/apps`),"Failed to list Apps").apps}async function Vp(e,t){return u(await c.post(`/projects/${e}/apps`,t),"Failed to create App")}async function Jp(e,t){return u(await c.get(`/projects/${e}/apps/${t}`),"Failed to load App")}async function Xp(e,t,n){return u(await c.patch(`/projects/${e}/apps/${t}`,n),"Failed to update App")}async function Qp(e,t){return u(await c.delete(`/projects/${e}/apps/${t}`),"Failed to delete App")}async function Yp(e,t){return u(await c.get(`/projects/${e}/apps/${t}/access`),"Failed to load App access policy")}async function Zp(e,t){return u(await c.get(`/projects/${e}/apps/${t}/agents`),"Failed to load the agents with access to this App").agents}async function ed(e,t,n){return u(await c.patch(`/projects/${e}/apps/${t}/access`,n),"Failed to update App access policy")}async function td(e,t){return u(await c.post(`/projects/${e}/apps/${t}/access-session`,{}),"Failed to create App access session")}async function ur(e,t){return u(await c.post(`/projects/${e}/apps/artifacts`,t),"Failed to register App artifact")}async function pr(e,t,n){return u(await c.post(`/projects/${e}/apps/artifacts/${t}/finalize`,n),"Failed to finalize App artifact")}async function tP(e){return e instanceof Uint8Array?e:new Uint8Array(await e.arrayBuffer())}async function nP(e){let t=Uint8Array.from(e),n=await globalThis.crypto.subtle.digest("SHA-256",t.buffer);return Array.from(new Uint8Array(n),r=>r.toString(16).padStart(2,"0")).join("")}async function nd(e,t,n={}){let r=await tP(t),s=n.mediaType??"application/gzip",i=await ur(e,{kind:"archive",media_type:s});if(!i.upload)throw new Error("App artifact registration did not return an upload URL");if(r.byteLength>i.upload.max_bytes)throw new Error(`App artifact exceeds ${i.upload.max_bytes} bytes`);n.onProgress?.(0,r.byteLength);let o=await fetch(i.upload.url,{method:"PUT",body:new Blob([Uint8Array.from(r).buffer],{type:s}),signal:n.signal,headers:{"content-type":s,"x-upsert":"false"}});if(!o.ok){let a=await o.text().catch(()=>"");throw new Error(`App artifact upload failed with HTTP ${o.status}${a?`: ${a}`:""}`)}return n.onProgress?.(r.byteLength,r.byteLength),pr(e,i.artifact.artifact_id,{sha256:await nP(r),size_bytes:r.byteLength})}async function rd(e,t,n){return u(await c.post(`/projects/${e}/apps/${t}/deployments`,n),"Failed to create App deployment")}async function sd(e,t){return u(await c.get(`/projects/${e}/apps/${t}/deployments`),"Failed to list App deployments").deployments}async function id(e,t,n){return u(await c.get(`/projects/${e}/apps/${t}/deployments/${n}`),"Failed to load App deployment")}async function od(e,t,n,r={}){let s=new URLSearchParams;r.after!==void 0&&s.set("after",String(r.after)),r.limit!==void 0&&s.set("limit",String(r.limit));let i=s.size?`?${s.toString()}`:"";return u(await c.get(`/projects/${e}/apps/${t}/deployments/${n}/logs${i}`),"Failed to load App logs")}async function ad(e,t){return u(await c.post(`/projects/${e}/apps/${t}/start`,{}),"Failed to start App")}async function cd(e,t){return u(await c.post(`/projects/${e}/apps/${t}/stop`,{}),"Failed to stop App")}async function ld(e,t,n){return u(await c.post(`/projects/${e}/apps/${t}/rollback`,{deployment_id:n}),"Failed to roll back App")}async function dr(e){return u(await c.get(`/projects/${e}/model-access`))}async function gr(e,t){return u(await c.put(`/projects/${e}/model-access`,t))}function rP(e){let{running:t,isCarousel:n,contentStatus:r,isWebsitePreview:s,previewHasError:i,previewIsLinkOnly:o}=e;return t||n?!1:s?i&&!o:r==="error"}function ud(e){return typeof e=="string"&&e.trim().length>0}function Gm(e){if(!e||typeof e!="object")return!1;let{path:t,url:n,content:r}=e;return ud(t)||ud(n)||ud(r)}function sP(e){if(Array.isArray(e))return e.length>0?e:null;if(typeof e!="string"||!e.trim())return null;try{let t=JSON.parse(e);return Array.isArray(t)&&t.length>0?t:null}catch{return null}}function Xt(e){if(!e)return!0;let t=sP(e.items);return t?!t.some(Gm):!Gm(e)}function ae(e){return(e??"").replace(/^oc-/,"").replace(/-/g,"_")}function iP(e){return ae(e)==="bash"}function oP(e){let t=ae(e);return t==="question"||t==="ask"}function aP(e,t){let n=Math.max(0,e);return`${t?"Running":"Ran"} ${n} command${n===1?"":"s"}`}var Nm=new Set(["show","show_user"]);function pd(e){return Nm.has(ae(e))}function cP(e,t){let n=Math.max(0,e);return`${t?"Writing":"Wrote"} ${n} file${n===1?"":"s"}`}function dd(e){return!!(e.type==="snapshot"||e.type==="patch"||e.type==="step-start"||e.type==="step-finish"||e.type==="text"&&!e.text?.trim()||mr(e))}function mr(e){let t=ae(e.tool);return t!=="show"&&t!=="show_user"||e.state?.status!=="completed"?!1:Xt(e.state?.input)}var Wm=new Set(["show","show_user","agent_spawn","agent_status","agent_message","agent_task_update","agent_stop"]);function gd(e){return Wm.has(ae(e))}var lP=50*1024*1024,md="[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}",uP=new RegExp(`^kortix-attachment://(${md})/(${md})/(${md})$`);function yd(e){if(typeof e!="string")return null;let t=uP.exec(e);return t?{projectId:t[1],sessionId:t[2],attachmentId:t[3]}:null}function pP(e){return yd(e)!==null}var fd=new WeakMap;async function hd(e,t,n,r={}){if(n.size>lP)throw new Error("Attachments must be 50 MiB or smaller.");let s=`${e}/${t}`,i=r.attachmentId?void 0:fd.get(n)?.get(s);if(i?.promise)return i.promise;let o=i??{id:r.attachmentId??crypto.randomUUID(),promise:void 0};if(!r.attachmentId){let p=fd.get(n)??new Map;p.set(s,o),fd.set(n,p)}let a=new FormData;return a.append("attachment_id",o.id),a.append("file",n,n.name),o.promise=c.upload(`/projects/${encodeURIComponent(e)}/sessions/${encodeURIComponent(t)}/attachments`,a,{signal:r.signal,timeout:12e4,showErrors:!1}).then(u).catch(p=>{throw o.promise=void 0,p}),o.promise}async function bd(e,t){let n=yd(e);if(!n)throw new Error("Invalid attachment reference");let r=$().backendUrl.replace(/\/$/,""),s=await q(`${r}/projects/${n.projectId}/sessions/${n.sessionId}/attachments/${n.attachmentId}`,{signal:t});if(!s.ok)throw new S("Could not load attachment",{status:s.status});return s.blob()}var dP=new Set(["show","show_user"]);function gP(e){let t=[],n=0;for(;;){let r=e.indexOf("<file",n);if(r===-1)return t;let s=r+5;if(s>=e.length||!/\s/.test(e[s])){n=s;continue}let i=e.indexOf(">",s);if(i===-1)return t;let o=e.indexOf("</file>",i+1);if(o===-1)return t;t.push(e.slice(s,i).trimStart()),n=o+7}}var mt=e=>!!e&&typeof e=="object"&&!Array.isArray(e),Qt=e=>typeof e=="string"&&e.length>0?e:null,Km=e=>typeof e=="string"?Qt(e.split("/").pop()):null;function fr(e,t){let n=e.match(new RegExp(`(?:^|\\s)${t}="([^"]*)"`))?.[1];return n===void 0?null:n.replace(/"/g,'"').replace(/</g,"<").replace(/>/g,">").replace(/&/g,"&")}function mP(e){if(Array.isArray(e))return e;if(typeof e!="string"||!e.trim())return[];try{let t=JSON.parse(e);return Array.isArray(t)?t:[]}catch{return[]}}function fP(e){if(!Array.isArray(e))return[];let t=[],n=new Set,r=(s,i,o,a,p)=>{let g=yd(s);!g||n.has(s)||(n.add(s),t.push({url:s,attachment_id:g.attachmentId,filename:i,mime:o,message_id:a,role:p}))};for(let s of e){if(!mt(s)||!mt(s.info)||!Array.isArray(s.parts))continue;let i=Qt(s.info.id);if(!i)continue;let o=Qt(s.info.role)??"unknown";for(let a of s.parts)if(mt(a)){if(a.type==="file")r(a.url,Qt(a.filename),Qt(a.mime),i,o);else if(a.type==="text"&&typeof a.text=="string")for(let p of gP(a.text))r(fr(p,"attachment"),fr(p,"filename")??Km(fr(p,"path")),fr(p,"mime"),i,o);else if(a.type==="tool"&&typeof a.tool=="string"&&dP.has(ae(a.tool))&&mt(a.state)&&mt(a.state.input)){let p=a.state.input;for(let g of[p,...mP(p.items)])mt(g)&&r(g.attachment,Km(g.path),null,i,o)}}}return t}var ft=class extends Error{constructor(n,r,s){super(r);this.code=n;this.status=s;this.name="HeadlessAuthError"}code;status};function yP(e){let t=_e(e?.backendUrl??$().backendUrl??"");if(!t)throw new ft("not_configured","backendUrl is not configured (configureKortix / createKortix first)",0);return t.endsWith("/v1")?t:`${t}/v1`}async function Y(e,t,n){let r=n?.fetch??$().fetch??((p,g)=>fetch(p,g)),s={accept:"application/json"};t.body!==void 0&&(s["content-type"]="application/json"),t.bearer&&(s.authorization=`Bearer ${t.bearer}`);let i=await r(`${yP(n)}${e}`,{method:t.method??(t.body!==void 0?"POST":"GET"),headers:s,...t.body!==void 0?{body:JSON.stringify(t.body)}:{},...n?.signal?{signal:n.signal}:{}}),o=await i.text().catch(()=>""),a=null;try{a=o?JSON.parse(o):null}catch{a=o}if(!i.ok){let p=a&&typeof a=="object"?a:{};throw new ft(typeof p.error=="string"?p.error:"auth_error",typeof p.error_description=="string"&&p.error_description?p.error_description:typeof p.error=="string"?p.error:i.statusText||`HTTP ${i.status}`,i.status)}return a}function yr(e,t){return Y("/auth/signup",{body:e},t)}function hr(e,t){return Y("/auth/sign-in/password",{body:e},t)}function br(e,t){return Y("/auth/sign-in/magic-link",{body:e},t)}function _r(e,t){return Y("/auth/verify-otp",{body:e},t)}function xr(e,t){return Y("/auth/sign-in/oauth",{body:e},t)}function wr(e,t){return Y("/auth/oauth/exchange",{body:e},t)}function yt(e,t){return Y("/auth/refresh",{body:e},t)}function kr(e,t){return Y("/auth/password/reset",{body:e},t)}function Pr(e,t,n){return Y("/auth/password/update",{body:e,bearer:t},n)}function Sr(e,t){return Y("/auth/user",{bearer:e},t)}function vr(e,t,n){return Y("/auth/user",{method:"PATCH",body:e,bearer:t},n)}function Ar(e,t){return Y("/auth/sign-in/sso",{body:e},t)}var Rr={enroll:(e,t,n)=>Y("/auth/mfa/factors",{body:e,bearer:t},n),challenge:(e,t={},n,r)=>Y(`/auth/mfa/factors/${encodeURIComponent(e)}/challenge`,{body:t,bearer:n},r),verify:(e,t,n,r)=>Y(`/auth/mfa/factors/${encodeURIComponent(e)}/verify`,{body:t,bearer:n},r),unenroll:(e,t,n)=>Y(`/auth/mfa/factors/${encodeURIComponent(e)}`,{method:"DELETE",bearer:t},n)};function Cr(e,t={},n){return Y("/auth/sign-out",{body:t,bearer:e},n)}function Tr(e={}){let t=e.refreshSkewSeconds??60,n=e.now??(()=>Date.now()),r=null,s=null,i=!e.storage,o=null,a=null,p=0,g=new Set,m=P=>(P.expires_at??0)*1e3,h=P=>m(P)-t*1e3<=n();async function _(){e.storage&&(r?await e.storage.set(JSON.stringify({session:r,user:s})):await e.storage.remove());for(let P of[...g])try{P(r)}catch{}try{e.onChange?.(r)}catch{}}async function w(){if(i)return r;if(!o){let P=p,M=(async()=>{let k=await e.storage.get();if(P===p&&k)try{let d=JSON.parse(k);d.session?.access_token&&d.session?.refresh_token&&(r=d.session,s=d.user??null)}catch{r=null}return i=!0,r})();o=M,M.then(()=>{o===M&&(o=null)},()=>{o===M&&(o=null)})}return o}async function A(){if(await w(),!r)return null;if(!a){let P=r.refresh_token,M=p,k=yt({refresh_token:P},e.request).then(async d=>(M!==p||(r=d.session,d.user&&(s=d.user),await _()),r)).catch(async d=>{if(M!==p)return r;let y=d&&typeof d=="object"&&"status"in d?d.status:0;if(y>=400&&y<500)return r=null,s=null,await _(),null;throw d}).finally(()=>{a===k&&(a=null)});a=k}return a}return{subscribe(P){return g.add(P),()=>{g.delete(P)}},current:()=>r,user:()=>s,load:w,async set(P,M){await w(),p+=1,a=null,r=P,M!==void 0&&(s=M),P||(s=null),await _()},async getToken(){return await w(),r?h(r)?(await A().catch(()=>r))?.access_token??null:r.access_token:null},refresh:A,async clear(){p+=1,a=null,r=null,s=null,i=!0,await _()}}}var bP=["control_plane","provider_ingress","daemon","upstream_port"];function _d(e){return typeof e=="string"&&bP.includes(e)?e:null}function _P(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 xd(e,t){let n=(e===void 0?be():e)||null;if(!n)return{status:0,ok:!1,health:null,body:"",hop:null,upstreamStatus:null};let r=await q(`${n}/kortix/health`,{method:"GET",...t},{retryOnAuthError:!1}),s=await r.text().catch(()=>""),i=null;try{i=s?JSON.parse(s):null}catch{i=null}let o=i,a=_d(r.headers.get("X-Kortix-Proxy-Hop"))??_d(i?.hop),p=Number(r.headers.get("X-Kortix-Upstream-Status")),g=i?.upstream_status,m=Number.isFinite(p)&&p>0?p:typeof g=="number"?g:null;return{status:r.status,ok:r.ok,health:o,body:s,hop:a,upstreamStatus:m}}var ke={DESKTOP:"6080",DESKTOP_HTTPS:"6081",PRESENTATION_VIEWER:"3210",STATIC_FILE_SERVER:"3211",KORTIX_MASTER:"8000",BROWSER_STREAM:"9223",BROWSER_VIEWER:"9224",SSH:"22"};var Hm=/https?:\/\/(?:localhost|127\.0\.0\.1):\d{1,5}[^\s)"'<>]*/g,zm=/^https?:\/\/p(\d+)-([^.]+)\.localhost(?::(\d+))?(\/.*)?$/,Vm=/^https?:\/\/(?:dev|staging|prod|preview)-p(\d+)-([a-z0-9-]+)\.[^/]+?(?::(\d+))?(\/.*)?$/i,Jm=new Set([22,4096,parseInt(ke.KORTIX_MASTER,10)]);function xP(e){return zm.test(e)}function Ir(e){if(!e)return"/";let t=e,n=t.indexOf("](");n!==-1&&(t=t.slice(0,n));let r=t.toLowerCase().indexOf("%5d(");return r!==-1&&(t=t.slice(0,r)),t?t.startsWith("/")?t:`/${t}`:"/"}function wP(e){let t=e.indexOf("](");return t===-1?e:e.slice(0,t)}var kP=new Set(["'",'"',"`","<","(","["]),PP=new Set([">","'",'"',"`",")","]",",",";",".","!","?"]);function SP(e){let t=0,n=e.length;for(;t<n&&(e[t]===" "||e[t]===" ");)t++;for(;n>t&&(e[n-1]===" "||e[n-1]===" ");)n--;for(;t<n&&kP.has(e[t]);)t++;for(;n>t&&PP.has(e[n-1]);)n--;return e.slice(t,n)}function vP(e){return e.match(/https?:\/\/(?:localhost|127\.0\.0\.1):\d{1,5}[^\s"'<>)]*/i)?.[0]??null}var AP=/^\/proxy\/(\d{1,5})(\/.*)?$/,RP=/^\/(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 Xm(e){if(!e)return!1;try{let t=new URL(e);return t.hostname!=="localhost"&&t.hostname!=="127.0.0.1"?!1:RP.test(t.pathname)}catch{return!1}}function Zt(e){if(!e)return null;let t=SP(wP(e.trim())),n=kd(t);if(n){let r=Ir(n.path||"/");return{originalUrl:`http://localhost:${n.port}${r}`,port:n.port,path:r}}try{let r=new URL(t);if(r.protocol!=="http:"&&r.protocol!=="https:"||r.hostname!=="localhost"&&r.hostname!=="127.0.0.1"||!r.port)return null;let s=parseInt(r.port,10);if(!Number.isInteger(s)||s<1||s>65535)return null;let i=`${r.pathname||"/"}${r.search}${r.hash}`,o=parseInt(ke.KORTIX_MASTER,10);if(s===o){let p=r.pathname.match(AP);if(p){let g=parseInt(p[1],10);if(g>=1&&g<=65535)return s=g,i=Ir(`${p[2]||"/"}${r.search}${r.hash}`),{originalUrl:`http://localhost:${s}${i}`,port:s,path:i}}}let a=Ir(i);return{originalUrl:`${r.protocol}//${r.hostname}:${s}${a}`,port:s,path:a}}catch{let r=vP(e);return r&&r!==e?Zt(r):null}}function CP(e){let t=[],n=/```[\s\S]*?```/g,r;for(;(r=n.exec(e))!==null;)t.push([r.index,r.index+r[0].length]);let s=/`[^`\n]+`/g;for(;(r=s.exec(e))!==null;){let i=r.index,o=i+r[0].length;t.some(([p,g])=>i>=p&&o<=g)||t.push([i,o])}return t}function TP(e,t){return t.some(([n,r])=>e>=n&&e<r)}function Qm(e){let t=[],n=new Set,r=CP(e);Hm.lastIndex=0;let s;for(;(s=Hm.exec(e))!==null;){let i=Zt(s[0]);if(!i)continue;let{originalUrl:o,port:a,path:p}=i;a<1||a>65535||Jm.has(a)||n.has(o)||(n.add(o),t.push({originalUrl:o,port:a,path:p,startIndex:s.index,endIndex:s.index+o.length,inCodeBlock:TP(s.index,r)}))}return t}function IP(e){return Qm(e).length>0}function EP(e){try{let{hostname:t}=new URL(e);return t==="localhost"||t==="127.0.0.1"}catch{return!1}}function Ym(e){return e.trim().toLowerCase().split("_").join("-")}function Zm(e){let t=e.length;for(;t>0&&e.charCodeAt(t-1)===47;)t--;return e.slice(0,t)}function jP(e,t,n){let r=n.previewUrlTemplate;if(!r||!r.includes("{port}")||!r.includes("{sandbox}"))return null;let s=r.split("{port}").join(String(e)).split("{sandbox}").join(Ym(n.sandboxId));return`${Zm(s)}${t}`}function ef(e){return e.sandboxId.trim().length>0}function $e(e,t,n){let r=Ir(t);if(!ef(n))return sf(e,r);let s=jP(e,r,n);return s||(EP(n.apiBaseUrl)?`http://p${e}-${Ym(n.sandboxId)}.localhost:${n.backendPort}${r}`:`${Zm(n.apiBaseUrl)}/p/${n.sandboxId}/${e}${r}`)}function MP(e,t){if(!e)return;let r=e.replace(/^\/workspace\//,"").replace(/^\/+/,"").split("/").filter(Boolean).map(s=>encodeURIComponent(s)).join("/");return $e(3211,`/open?path=/workspace/${r}`,t)}function tf(e){return`/open?path=/${(e.startsWith("/workspace")?e:`/workspace/${e.replace(/^\/+/,"")}`).split("/").filter(Boolean).map(r=>encodeURIComponent(r)).join("/")}`}function $P(e){return`http://localhost:3211${tf(e)}`}function nf(){return"/health"}function OP(e){return $e(3211,nf(),e)}function DP(e,t){return $e(e,"/",t)}function rf(e){let t=Zt(e);return!(!t||Jm.has(t.port)||Xm(e))}function wd(e,t){if(!e)return e;let n=Zt(e);return n?rf(n.originalUrl)?$e(n.port,n.path,t):n.originalUrl:e}function sf(e,t="/"){return`http://localhost:${e}${t}`}var of=/^https?:\/\/[^/]+\/v1\/p\/([^/]+)\/(\d+)(\/.*)?$/;function kd(e){let t=e.match(zm);if(t)return{port:parseInt(t[1],10),sandboxId:t[2],backendPort:t[3]?parseInt(t[3],10):80,path:t[4]||"/"};let n=e.match(Vm);if(n){let s=443;try{let i=new URL(e);s=i.port?parseInt(i.port,10):i.protocol==="https:"?443:80}catch{return null}return{port:parseInt(n[1],10),sandboxId:n[2],backendPort:s,path:n[4]||"/"}}let r=e.match(of);if(r)try{let s=new URL(e);return{port:parseInt(r[2],10),sandboxId:r[1],backendPort:parseInt(s.port,10)||(s.protocol==="https:"?443:80),path:r[3]||"/"}}catch{return null}return null}function qP(e){try{let t=kd(e);return t?`http://localhost:${t.port}${t.path}`:null}catch{return null}}function UP(e){return xP(e)||Vm.test(e)||of.test(e)}function FP(e){try{let{hostname:t,port:n}=new URL(e);return(t==="localhost"||t==="127.0.0.1")&&n!==""}catch{return!1}}var Yt="/web-proxy/";function LP(e,t){try{let n=new URL(e);if(n.protocol!=="http:"&&n.protocol!=="https:")return null;let r=n.protocol.replace(":",""),s=`${Yt}${r}/${n.host}${n.pathname}${n.search}${n.hash}`,i=parseInt(ke.KORTIX_MASTER,10);return`${$e(i,"/",t).replace(/\/$/,"")}${s}`}catch{return null}}function BP(e){try{let t=new URL(e),n=t.pathname.indexOf(Yt);if(n===-1)return null;let s=t.pathname.slice(n+Yt.length).match(/^(https?)\/([\w.\-]+(?::\d+)?)(\/.*)?$/);if(!s)return null;let i=s[1],o=s[2],a=s[3]||"/";return`${i}://${o}${a}${t.search}${t.hash}`}catch{return null}}function GP(e){try{return new URL(e).pathname.includes(Yt)}catch{return e.includes(Yt)}}function NP(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 WP(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 af="frontend";function Er(e,t,n){(e==="error"?console.error:e==="warn"?console.warn:e==="debug"?console.debug:console.log)(`[${af}] ${t}`,...n?[n]:[]);try{je().app.log({service:af,level:e,message:t,extra:n})}catch{}}var Oe={debug:(e,t)=>Er("debug",e,t),info:(e,t)=>Er("info",e,t),warn:(e,t)=>Er("warn",e,t),error:(e,t)=>Er("error",e,t)};function cf(e){return{type:"heartbeat-gap",gapMs:e}}function lf(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 KP={now:()=>Date.now(),setTimeout:(e,t)=>setTimeout(e,t),clearTimeout:e=>clearTimeout(e)},HP=16,zP=8,VP=6e4,JP=5e3,XP=250,QP=1e3,YP=3e4,ZP=5,eS=3e3,tS=3e4,nS=2e4,rS=2e3,sS=8;function iS(e){if(e.type==="session.status")return`session.status:${e.properties.sessionID}`;if(e.type==="lsp.updated")return"lsp.updated"}function uf(e){if(e.aborted)return{promise:Promise.resolve(),cleanup:()=>{}};let t=()=>{};return{promise:new Promise(r=>{t=()=>r(),e.addEventListener("abort",t,{once:!0})}),cleanup:()=>e.removeEventListener("abort",t)}}var jr=new WeakMap;function oS(e,t,n){let r=t.timers??KP,s=t.connectTimeoutMs??nS,i=t.heartbeatTimeoutMs??VP,o=t.maxConsecutiveHardFailures??sS,a=new AbortController;function p(k,...d){for(let y of n){let l=k(y);if(l)try{l(...d)}catch(x){console.warn("[opencode-events] subscriber handler threw, skipping",x)}}}let g=r.now(),m=null,h=[],_,w=0,A=new Map,P=()=>{if(_&&r.clearTimeout(_),_=void 0,h.length===0)return;let k=h;h=[],A.clear(),w=r.now(),g=r.now();for(let d of k)d&&p(y=>y.onEvent,d.event)},M=()=>{if(_)return;let k=r.now()-w;_=r.setTimeout(P,Math.max(0,HP-k))};return(async()=>{let k=0,d=0;for(;!a.signal.aborted;){let y=!1,l=!1,x=!1,R,I,O=null,N=r.now(),E=new AbortController,K=uf(a.signal);K.promise.then(()=>E.abort());try{let L=await new Promise((J,oe)=>{let Q=!1;I=r.setTimeout(()=>{Q||(Q=!0,Oe.warn("SSE connect timed out, forcing reconnect",{connectTimeoutMs:s}),E.abort(),oe(new Error(`SSE connect timed out after ${s}ms`)))},s),e.global.event({signal:E.signal,sseDefaultRetryDelay:eS,sseMaxRetryDelay:tS,sseMaxRetryAttempts:1}).then(le=>{Q||(Q=!0,r.clearTimeout(I),J(le))},le=>{Q||(Q=!0,r.clearTimeout(I),oe(le))})}),{stream:X}=L;if(m){let J=r.now()-m.lastActivityAt,oe=m.eventful;m=null,(oe||J>JP)&&p(Q=>Q.onGapRehydrate,J)}g=r.now();let G=()=>{r.clearTimeout(R),R=r.setTimeout(()=>{Oe.warn("SSE heartbeat timeout, forcing reconnect"),E.abort()},i)};G();let se=r.now(),Re=X[Symbol.asyncIterator]();for(;!E.signal.aborted;){let J=Re.next().then(Ce=>({kind:"next",result:Ce}),Ce=>({kind:"error",error:Ce})),oe=uf(E.signal),Q=await Promise.race([J,oe.promise.then(()=>({kind:"aborted"}))]);if(oe.cleanup(),Q.kind==="aborted")break;if(Q.kind==="error")throw Q.error;if(Q.result.done)break;y=!0,G();let le=Q.result.value,St=le&&typeof le=="object"&&"payload"in le?le.payload:le;if(!St?.type)continue;St.type!=="server.connected"&&(l=!0);let ts=iS(St);if(ts){let Ce=A.get(ts);Ce!==void 0&&(h[Ce]=void 0),A.set(ts,h.length)}h.push({type:St.type,event:St}),M(),!(r.now()-se<zP)&&(se=r.now(),await new Promise(Ce=>r.setTimeout(Ce,0)))}x=y}catch(L){if(a.signal.aborted)break;O=L;let X=String(L),G=X.includes("401")||X.includes("403")||X.includes("Unauthorized")||X.includes("Token refresh failed");if(Oe.error("SSE event stream error",{error:X,retryCount:k,isAuthError:G}),G)try{jn(),await En(),Oe.info("SSE: refreshed auth token after auth error")}catch(se){Oe.error("SSE: failed to refresh auth token",{error:String(se)})}}finally{r.clearTimeout(R),r.clearTimeout(I),E.abort(),K.cleanup(),P()}if(a.signal.aborted)break;let F=r.now()-N,b=O?.cause?.status;if(d=!y&&(typeof b=="number"&&b>=400||F<rS)?d+1:0,d>=o){Oe.error("SSE event stream parked \u2014 giving up after consecutive hard failures",{consecutiveFailures:d,lastError:String(O)}),p(L=>L.onParked,{consecutiveFailures:d,lastError:O});break}m={lastActivityAt:g,eventful:(m?.eventful??!1)||l},x?k=0:(k++,k>1&&Oe.warn("SSE event stream reconnecting",{retryCount:k}));let ee=x?XP:Math.min(QP*2**Math.min(k-1,ZP),YP);await new Promise(L=>{let X=r.setTimeout(L,ee),G=()=>{r.clearTimeout(X),L()};a.signal.addEventListener("abort",G,{once:!0})})}})(),{subscribers:n,teardown:()=>{a.abort(),_&&r.clearTimeout(_)}}}function Mr(e){let{client:t,onEvent:n,onGapRehydrate:r,onParked:s,signal:i}=e,o={onEvent:n,onGapRehydrate:r,onParked:s},a=jr.get(t);a?a.subscribers.add(o):(a=oS(t,e,new Set([o])),jr.set(t,a));let p=a,g=!1,m=()=>{g||(g=!0,i&&i.removeEventListener("abort",h),p.subscribers.delete(o),p.subscribers.size===0&&(p.teardown(),jr.get(t)===p&&jr.delete(t)))},h=()=>m();return i&&(i.aborted?m():i.addEventListener("abort",h,{once:!0})),{close:m}}function aS(){return je()}var $r=new Map;function cS(e){let t=`Session runtime not ready (stage: ${e?.stage??"unknown"})`,n=e?.failure,r=[];n?.category&&r.push(n.category),n?.message&&r.push(n.message);let s=n?.evidence?.error;return s&&s!==n?.message&&r.push(s),r.length===0&&e?.reason&&r.push(e.reason),r.length>0?`${t}: ${r.join(" \u2014 ")}`:t}var en=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 pf(e,t){xn(e,t);function n(d){try{return new URL(d)}catch{if(typeof window<"u"&&window.location?.origin)try{return new URL(d,window.location.origin)}catch{return null}throw new S(`Kortix SDK: backendUrl must be an absolute URL outside the browser (got ${JSON.stringify(d)}). 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 r(d){let y=$().backendUrl??e.backendUrl,l=80,x=n(y);return x&&(l=x.port?Number(x.port):x.protocol==="https:"?443:80),Qg({sandboxId:d,apiBaseUrl:y,backendPort:l})}let s={signUp:yr,signInWithPassword:hr,sendMagicLink:br,verifyOtp:_r,signInWithProvider:xr,exchangeCode:wr,refresh:yt,resetPassword:kr,updatePassword:Pr,updateUserMetadata:vr,signInWithSso:Ar,mfa:Rr,user:Sr,signOut:Cr,session:Tr},i={list:io,get:ao,create:oo,secretResources:{list:Ta,create:Ia,rotate:Ea,remove:ja,grant:Ma,revoke:$a,setAccess:Oa},updateName:co,branding:{get:lo,update:uo,uploadAsset:po,removeAsset:go,reset:mo},leave:Ao,members:fo,invite:yo,removeMember:So,updateMemberRole:vo,invites:ho,cancelInvite:bo,resendInvite:_o,tokens:{list:Sp,create:vp,revoke:Ap},audit:{log:Ip,export:jp,webhooks:{list:Mp,create:$p,update:Op,remove:Dp}}},o={assignments:{list:lp,create:up,revoke:pp},permissions:{list:dp,forRole:Ju},roles:{list:zu,create:Qu,update:Yu,setPermissions:Zu,remove:ep,usage:Xu},groups:{list:Fu,get:Lu,create:Bu,update:Gu,remove:Nu,members:{list:Wu,add:Ku,remove:Hu}},agentIdentities:Vu,oauthClients:{list:rp,get:sp,create:ip,update:op,rotateSecret:ap,remove:cp},can:tp,canBatch:np},a={accountState:Ul,accountStateMinimal:Fl,transactions:Ll,transactionsSummary:Bl,creditBreakdown:Gl,usageHistory:Nl,usageRollup:nu,sessionCosts:{list:iu,get:ar},tierConfigurations:Wl,checkout:{createSession:d=>Kl(d),confirmSession:(d,y)=>Hl(d,y)},subscription:{createPortalSession:(d,y)=>zl(d,y),cancel:(d,y)=>Vl(d,y),reactivate:d=>Jl(d),scheduleDowngrade:(d,y,l)=>Xl(d,y,l),cancelScheduledChange:d=>Ql(d),prorationPreview:(d,y)=>Yl(d,y)},credits:{purchase:d=>Zl(d),autoTopupSettings:d=>eu(d),configureAutoTopup:d=>tu(d)}},p={listMine:xo,describe:wo,accept:ko,decline:Po},g={list:Ge,listForAccount:Co,get:Kn,detail:Hn,create:jo,createRepo:Mo,provision:$o,update:Jn,archive:Xn,llmCatalog:zn,modelPicker:Vn,modelAccess:dr,setModelAccess:gr,sandboxHealth:tr,sandboxTemplates:Pc,sessions:dt,createSession:gt},m={linkRepository:Fo,replaceProjectRepository:Lo,getInstallation:Bo,listInstallations:Go,listLinkableInstallations:No,listRepositories:Wo,listRepositoryBranches:Ko,linkInstallation:zo,saveInstallation:Ho,deleteInstallation:Vo},h={get:Jo,repositories:Xo},_={list:wp,create:kp,revoke:Pp},w=bc,A={items:d=>Fp(d),item:d=>Gp(d),itemFile:(d,y)=>Np(d,y),marketplaces:()=>Lp(),featured:()=>Bp(),sources:{list:()=>Wp(),add:d=>Kp(d),remove:d=>Hp(d)}};function P(d){return{catalog:()=>Yn(d),tools:()=>Ht(d),search:(...y)=>Fa(d,...y),describe:(...y)=>La(d,...y),call:(...y)=>Ba(d,...y),accounts:(...y)=>Ga(d,...y),uploadAttachment:(...y)=>Na(d,...y)}}function M(d){let y={list:()=>Wa(d),listAll:()=>Ka(d),reconcile:(...l)=>Ha(d,...l),reconcileMember:(...l)=>za(d,...l),updateCredential:(...l)=>Va(d,...l),revoke:(...l)=>Ja(d,...l),activate:(...l)=>Xa(d,...l),setDefault:(...l)=>Qa(d,...l),rename:(...l)=>Ya(d,...l),share:(...l)=>Za(d,...l),pipedreamConnect:(...l)=>ec(d,...l),pipedreamFinalize:(...l)=>tc(d,...l)};return{attachments:{upload:(...l)=>Wt(d,...l),delete:(...l)=>pt(d,...l),createController:l=>so(d,l)},get:l=>Kn(d,l),detail:()=>Hn(d),audit:l=>Ep(d,l),update:l=>Jn(d,l),archive:()=>Xn(d),llmCatalog:()=>zn(d),modelPicker:()=>Vn(d),modelAccess:()=>dr(d),setModelAccess:l=>gr(d,l),sandboxHealth:()=>tr(d),onboardingComplete:(...l)=>Uo(d,...l),apps:{list:()=>zp(d),create:l=>Vp(d,l),get:l=>Jp(d,l),update:(...l)=>Xp(d,...l),access:{get:(...l)=>Yp(d,...l),update:(...l)=>ed(d,...l),session:(...l)=>td(d,...l),agents:l=>Zp(d,l)},remove:l=>Qp(d,l),artifacts:{register:l=>ur(d,l),uploadArchive:(...l)=>nd(d,...l),finalize:(...l)=>pr(d,...l)},deployments:{create:(...l)=>rd(d,...l),list:l=>sd(d,l),get:(...l)=>id(d,...l),logs:(...l)=>od(d,...l)},start:l=>ad(d,l),stop:l=>cd(d,l),rollback:(...l)=>ld(d,...l)},tokens:{list:()=>Rp(d),create:l=>Cp(d,l),revoke:l=>Tp(d,l)},setupLinks:{requestSecret:l=>qp(d,l),requestConnector:l=>Up(d,l)},validateManifest:l=>Io(d,l),gitToken:()=>Eo(d),secrets:{list:()=>ha(d),upsert:l=>ba(d,l),setStrategy:(...l)=>_a(d,...l),broker:(...l)=>xa(d,...l),remove:l=>va(d,l),setPersonal:(...l)=>Aa(d,...l),removePersonal:l=>Ra(d,l),setGitCredential:l=>Sa(d,l),startProviderOAuth:(...l)=>wa(d,...l),pollProviderOAuth:(...l)=>ka(d,...l),removeProviderOAuth:l=>Pa(d,l)},access:{list:()=>ea(d),invite:(...l)=>ra(d,...l),update:(...l)=>ta(d,...l),revoke:l=>na(d,l),pendingInvites:()=>sa(d),resendInvite:(...l)=>oa(d,...l),revokeInvite:(...l)=>ia(d,...l),requests:()=>Qo(d),approveRequest:(...l)=>Yo(d,...l),rejectRequest:(...l)=>Zo(d,...l),groupGrants:()=>aa(d),attachGroupGrant:(...l)=>ca(d,...l),updateGroupGrant:(...l)=>la(d,...l),detachGroupGrant:l=>ua(d,l),resourceGrants:{list:()=>pa(d),create:l=>da(d,l),remove:l=>ga(d,l)}},connectors:{...P(d),list:()=>nc(d),config:(...l)=>lc(d,...l),create:(...l)=>dc(d,...l),remove:(...l)=>mc(d,...l),sync:()=>rc(d),auth:{discover:(...l)=>gc(d,...l)},setName:(...l)=>uc(d,...l),setCredentialMode:(...l)=>sc(d,...l),setAuthorizationStrategy:(...l)=>ic(d,...l),setCredential:(...l)=>_c(d,...l),setSensitive:(...l)=>oc(d,...l),connections:y,policies:{get:(...l)=>ac(d,...l),set:(...l)=>cc(d,...l)},pipedream:{listApps:(...l)=>fc(d,...l),listSections:(...l)=>yc(d,...l),connect:(...l)=>pc(d,...l),finalize:(...l)=>xc(d,...l)},discover:{list:(...l)=>Zn(d,...l),sections:(...l)=>hc(d,...l),detail:(...l)=>er(d,...l)}},policies:{list:()=>wc(d),set:(...l)=>kc(d,...l)},triggers:{list:()=>vl(d),create:(...l)=>Al(d,...l),update:(...l)=>Rl(d,...l),remove:(...l)=>Cl(d,...l),fire:(...l)=>Il(d,...l),setActivation:(...l)=>Tl(d,...l)},files:{list:l=>jc(d,l),read:(l,x)=>$c(d,l,x),search:(...l)=>Mc(d,...l),archive:(...l)=>Oc(d,...l),history:(...l)=>Lc(d,...l)},git:{commits:()=>qc(d),commit:l=>Uc(d,l),commitDiff:l=>Fc(d,l),branches:()=>Dc(d),versionDiff:(...l)=>Bc(d,...l),inviteCollaborator:(...l)=>To(d,...l)},changeRequests:{list:()=>Gc(d),get:l=>Nc(d,l),diff:l=>Wc(d,l),mergePreview:l=>Kc(d,l),open:(...l)=>Hc(d,...l),merge:(...l)=>zc(d,...l),close:(...l)=>Vc(d,...l),reopen:(...l)=>Jc(d,...l),requestChanges:(...l)=>Xc(d,...l)},sessions:{list:l=>dt(d,l),listPage:l=>el(d,l),create:l=>gt(d,l),ensureWarm:()=>ol(d),claimWarm:l=>al(d,l)},review:{list:l=>gp(d,l),get:l=>mp(d,l),submit:l=>fp(d,l),act:(...l)=>yp(d,...l),bulkAct:l=>hp(d,l)},approvals:{list:l=>ma(d,l),resolve:(...l)=>ya(d,...l),sessionsNeedingInput:l=>fa(d,l)},gateway:{logs:l=>vu(d,l),log:l=>Au(d,l),overview:l=>Ru(d,l),series:l=>Cu(d,l),breakdown:l=>Tu(d,l),sessions:l=>Iu(d,l),errors:l=>Eu(d,l),budgets:()=>ju(d),setBudget:l=>Mu(d,l),deleteBudget:l=>$u(d,l),keys:()=>Ou(d),createKey:l=>Du(d,l),revokeKey:l=>qu(d,l),routing:{get:()=>wu(d),set:l=>ku(d,l),reset:()=>Pu(d),preview:l=>Su(d,l)},playground:(l,x,R)=>Uu(d,l,x,R)},channels:{slack:{installation:()=>ou(d),connect:l=>au(d,l),mode:()=>cu(d),completeInstall:l=>lu(d,l),manifest:()=>pu(d),disconnect:()=>du(d),getFile:l=>gu(d,l),uploadFile:l=>mu(d,l)},teams:{completeInstall:l=>uu(d,l)},email:{installation:l=>yu(d,l),mode:()=>hu(d),connect:l=>bu(d,l),disconnect:l=>_u(d,l),updatePolicy:(...l)=>xu(d,...l)}},updateFeatureFlag:(...l)=>Oo(d,...l),updateExperimentalFeature:(...l)=>Do(d,...l),modelDefaults:{get:()=>jl(d),set:l=>Ml(d,l),clear:l=>$l(d,l)},setDefaultAgent:l=>ql(d,l),sandbox:{list:()=>Ec(d),snapshots:()=>Sc(d),rebuildSnapshot:l=>vc(d,l),fixWithAgent:()=>Ac(d),createTemplate:l=>Rc(d,l),updateTemplate:(...l)=>Cc(d,...l),removeTemplate:l=>Tc(d,l),buildTemplate:l=>Ic(d,l),setProvider:l=>qo(d,l)},setAgentScope:(...l)=>Ol(d,...l),session:l=>k(d,l)}}function k(d,y){let l=null,x,R,I=null;async function O(){I||(I=nr(d,y,{showErrors:!1}).then(b=>{let T=typeof b.metadata?.opencode_model=="string"?b.metadata.opencode_model.trim():"",D=T.indexOf("/"),ee=D>0&&D<T.length-1?{providerID:T.slice(0,D),modelID:T.slice(D+1)}:void 0,L=b.agent_name?.trim()||void 0;return{model:ee,agent:L}}));try{return await I}catch(b){throw I=null,b}}function N(){if(l)return l;let b=Cm(d,y);return b&&(l=b),l}async function E(b){let T=N();if(T)return T;let D=b?.readyTimeoutMs??18e4,ee=Ye($().backendUrl??e.backendUrl).catch(()=>null),L=`${d}
|
|
20
|
+
`).map(t=>t.trim()).filter(Boolean);function Bk(e,t){let n=cr(e.advanced),r=U(e.description),s=de(e.whatChanged)??(r?Lk(r):t.summary?[t.summary]:[]);return{crId:U(e.cr_id),number:typeof e.number=="number"?e.number:void 0,whatChanged:s,impact:U(e.impact)??"",verification:de(e.verification)??[],previewUrl:U(e.previewUrl)??U(e.preview_url),conflicts:de(e.conflicts),requestedChanges:de(e.requested_changes)??[],advanced:{headRef:U(n.headRef)??U(e.head_ref)??"",baseRef:U(n.baseRef)??U(e.base_ref)??"",headSha:U(n.headSha)??U(e.head_sha)??U(e.head_commit_sha)??"",baseSha:U(n.baseSha)??U(e.base_sha)??"",additions:Um(n.additions),deletions:Um(n.deletions),files:de(n.files)??[],mergeMode:U(n.mergeMode)??"merge"}}}function Gk(e,t){let n=de(e.actions);if(n)return{actions:n.map((p,g)=>({id:U(p.id)??`${t.review_item_id}-${g}`,title:U(p.title)??"Action",connector:U(p.connector)??"",action:U(p.action)??"",consequence:U(p.consequence)??"",risk:U(p.risk)??t.risk,icon:U(p.icon)??"generic",argsPreview:de(p.argsPreview)??[],policySource:U(p.policySource)??"Requires approval",decided:p.decided==="approved"||p.decided==="denied"?p.decided:void 0}))};let r=U(e.action_path)??"",{connector:s,action:i}=Fk(r),o=cr(e.args_preview),a=Object.keys(o).length>0;return{actions:[{id:U(e.execution_id)??t.review_item_id,title:r?xp(r):t.title||"Run action",connector:s,action:i,consequence:"Runs against the real connector once you approve",risk:t.risk,icon:"generic",argsPreview:Object.entries(o).map(([p,g])=>({key:p,value:g==="[redacted]"?"Hidden credential":typeof g=="string"?g:JSON.stringify(g,null,2)})),actionPath:r,rawArgsPreview:a?o:void 0,reviewComplete:e.args_preview_complete===!0,previewAuthorized:e.args_preview_authorized!==!1,connectorRisk:U(e.risk)??null,policySource:"Requires approval"}]}}function Nk(e,t){return{artifactKind:U(e.artifactKind)??"document",artifactLabel:U(e.artifactLabel)??"Output",previewUrl:U(e.previewUrl)??U(e.preview_url),preview:U(e.preview),files:de(e.files),note:U(e.note)??t.summary??""}}function Wk(e,t){return{question:U(e.question)??t.title??"",context:U(e.context),options:de(e.options)??[]}}function Kk(e,t){return{note:U(e.note)??t.summary??"",children:de(e.children)??[]}}function Hk(e){let t=cr(e.detail);switch(e.kind){case"change":return Bk(t,e);case"approval":return Gk(t,e);case"output":return Nk(t,e);case"decision":return Wk(t,e);case"batch":return Kk(t,e)}}function zk(e,t){let n=typeof e.number=="number"?e.number:void 0,r=U(e.base_ref);return n!=null&&r?`#${n} \u2192 ${r}`:t}function Vk(e,t={}){let n=cr(e.detail),r=e.origin_session_id??void 0,s=r?t.sessionLabels?.[r]:void 0,i=e.kind==="approval"?U(n.action_path):void 0,o=e.kind==="change"?zk(n,e.summary):e.kind==="approval"?s??(r?"From a running session":e.summary):e.summary;return{id:e.review_item_id,kind:e.kind,title:i?xp(i):e.title,summary:o,risk:e.risk,status:e.status,source:e.source,agent:e.agent||"Agent",createdAt:e.created_at,sessionId:r,detail:Hk(e)}}async function wp(e){return u(await c.get(`/p/share?sandbox_id=${encodeURIComponent(e)}`),"Failed to load public links").shares??[]}async function kp(e){return u(await c.post("/p/share",{sandbox_id:e.sandboxId,port:e.port,ttl:e.ttl,label:e.label}),"Failed to generate public URL")}async function Pp(e,t){let n=await c.delete(`/p/share/${encodeURIComponent(t)}?sandbox_id=${encodeURIComponent(e)}`);if(!n.success)throw new Error(n.error?.message??"Failed to revoke public link")}var lr=class extends Error{constructor(n,r){super(n);this.status=r;this.name="PublicSessionShareError"}status};function Lm(e,t=""){return`${Et()}/public/session-shares/${encodeURIComponent(e)}${t}`}async function Bm(e){let t=await fetch(e,{method:"GET",headers:{Accept:"application/json"}}),n=await t.text().catch(()=>""),r=null;try{r=n?JSON.parse(n):null}catch{}if(!t.ok){let s=(r&&typeof r=="object"&&"error"in r&&typeof r.error=="string"?r.error:null)||t.statusText||`HTTP ${t.status}`;throw new lr(s,t.status)}return r}async function Jk(e){return Bm(Lm(e))}async function Xk(e){return Bm(Lm(e,"/messages"))}async function Sp(e,t){let n=new URLSearchParams;e&&n.set("account_id",e),t?.mine&&n.set("mine","true");let r=n.size>0?`?${n.toString()}`:"";return u(await c.get(`/accounts/tokens${r}`))}async function vp(e){let{accountId:t,expiresAt:n,projectId:r,name:s}=e;return u(await c.post("/accounts/tokens",{name:s,...t?{account_id:t}:{},...n?{expires_at:n}:{},...r?{project_id:r}:{}}))}async function Ap(e,t){let n=t?`?account_id=${encodeURIComponent(t)}`:"";return u(await c.delete(`/accounts/tokens/${e}${n}`))}async function Rp(e){return u(await c.get(`/projects/${e}/cli-token`))}async function Cp(e,t){return u(await c.post(`/projects/${e}/cli-token`,t??{}))}async function Tp(e,t){return u(await c.delete(`/projects/${e}/cli-token/${t}`))}async function Ip(e,t){let n=new URLSearchParams;t?.action&&n.set("action",t.action),t?.actor&&n.set("actor",t.actor),t?.actorType&&n.set("actor_type",t.actorType),t?.projectId&&n.set("project_id",t.projectId),t?.sessionId&&n.set("session_id",t.sessionId),t?.source&&n.set("source",t.source),t?.phase&&n.set("phase",t.phase),t?.outcome&&n.set("outcome",t.outcome),t?.resourceType&&n.set("resource_type",t.resourceType),t?.requestId&&n.set("request_id",t.requestId),t?.correlationId&&n.set("correlation_id",t.correlationId),t?.since&&n.set("since",t.since),t?.until&&n.set("until",t.until),t?.q&&n.set("q",t.q),t?.cursor&&n.set("cursor",t.cursor),t?.limit!=null&&n.set("limit",String(t.limit));let r=n.toString();return u(await c.get(`/accounts/${e}/audit${r?`?${r}`:""}`))}async function Ep(e,t){let n=new URLSearchParams;t?.action&&n.set("action",t.action),t?.actor&&n.set("actor",t.actor),t?.actorType&&n.set("actor_type",t.actorType),t?.sessionId&&n.set("session_id",t.sessionId),t?.source&&n.set("source",t.source),t?.phase&&n.set("phase",t.phase),t?.outcome&&n.set("outcome",t.outcome),t?.resourceType&&n.set("resource_type",t.resourceType),t?.requestId&&n.set("request_id",t.requestId),t?.correlationId&&n.set("correlation_id",t.correlationId),t?.since&&n.set("since",t.since),t?.until&&n.set("until",t.until),t?.q&&n.set("q",t.q),t?.cursor&&n.set("cursor",t.cursor),t?.limit!=null&&n.set("limit",String(t.limit));let r=n.toString();return u(await c.get(`/projects/${e}/audit${r?`?${r}`:""}`))}async function jp(e,t){let n=new URLSearchParams;t?.format&&n.set("format",t.format),t?.action&&n.set("action",t.action),t?.actor&&n.set("actor",t.actor),t?.actorType&&n.set("actor_type",t.actorType),t?.projectId&&n.set("project_id",t.projectId),t?.sessionId&&n.set("session_id",t.sessionId),t?.source&&n.set("source",t.source),t?.phase&&n.set("phase",t.phase),t?.outcome&&n.set("outcome",t.outcome),t?.resourceType&&n.set("resource_type",t.resourceType),t?.requestId&&n.set("request_id",t.requestId),t?.correlationId&&n.set("correlation_id",t.correlationId),t?.since&&n.set("since",t.since),t?.until&&n.set("until",t.until),t?.q&&n.set("q",t.q),t?.cursor&&n.set("cursor",t.cursor),t?.limit!=null&&n.set("limit",String(t.limit));let r=n.toString();return u(await c.get(`/accounts/${e}/audit/export${r?`?${r}`:""}`))}async function Mp(e){return u(await c.get(`/accounts/${e}/audit/webhooks`))}async function $p(e,t){return u(await c.post(`/accounts/${e}/audit/webhooks`,t))}async function Op(e,t,n){return u(await c.patch(`/accounts/${e}/audit/webhooks/${t}`,n))}async function Dp(e,t){return u(await c.delete(`/accounts/${e}/audit/webhooks/${t}`))}async function qp(e,t){return u(await c.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 Up(e,t){return u(await c.post(`/projects/${e}/connect-requests`,{slug:t.slug,...t.owner?{owner:t.owner}:{},...t.label?{label:t.label}:{},expires_in_minutes:t.expiresInMinutes}),"Failed to mint connect link")}async function Qk(e){return u(await c.get(`/approval-links/${e}`),"Failed to load approval")}async function Fp(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),e?.limit!==void 0&&t.set("limit",String(e.limit)),e?.offset!==void 0&&t.set("offset",String(e.offset));let n=t.toString()?`?${t.toString()}`:"";return u(await c.get(`/marketplace/items${n}`))}async function Lp(){return u(await c.get("/marketplace/marketplaces"))}async function Bp(){return u(await c.get("/marketplace/marketplaces/featured"))}async function Gp(e){return u(await c.get(`/marketplace/items/${encodeURIComponent(e)}`),"Item not found")}async function Np(e,t){return u(await c.get(`/marketplace/items/${encodeURIComponent(e)}/file?path=${encodeURIComponent(t)}`),"File not found")}async function Wp(){return u(await c.get("/marketplace/sources"))}async function Kp(e){return u(await c.post("/marketplace/sources",e),"Failed to add marketplace source")}async function Hp(e){return u(await c.delete(`/marketplace/sources/${encodeURIComponent(e)}`),"Failed to remove marketplace source")}async function Yk(e,t){return u(await c.post(`/projects/${encodeURIComponent(e)}/marketplace/install-session`,{id:t}),"Failed to start marketplace install session")}async function Zk(e){throw W("getTemplate")}async function eP(e,t){throw W("installTemplate")}async function zp(e){return u(await c.get(`/projects/${e}/apps`),"Failed to list Apps").apps}async function Vp(e,t){return u(await c.post(`/projects/${e}/apps`,t),"Failed to create App")}async function Jp(e,t){return u(await c.get(`/projects/${e}/apps/${t}`),"Failed to load App")}async function Xp(e,t,n){return u(await c.patch(`/projects/${e}/apps/${t}`,n),"Failed to update App")}async function Qp(e,t){return u(await c.delete(`/projects/${e}/apps/${t}`),"Failed to delete App")}async function Yp(e,t){return u(await c.get(`/projects/${e}/apps/${t}/access`),"Failed to load App access policy")}async function Zp(e,t){return u(await c.get(`/projects/${e}/apps/${t}/agents`),"Failed to load the agents with access to this App").agents}async function ed(e,t,n){return u(await c.patch(`/projects/${e}/apps/${t}/access`,n),"Failed to update App access policy")}async function td(e,t){return u(await c.post(`/projects/${e}/apps/${t}/access-session`,{}),"Failed to create App access session")}async function ur(e,t){return u(await c.post(`/projects/${e}/apps/artifacts`,t),"Failed to register App artifact")}async function pr(e,t,n){return u(await c.post(`/projects/${e}/apps/artifacts/${t}/finalize`,n),"Failed to finalize App artifact")}async function tP(e){return e instanceof Uint8Array?e:new Uint8Array(await e.arrayBuffer())}async function nP(e){let t=Uint8Array.from(e),n=await globalThis.crypto.subtle.digest("SHA-256",t.buffer);return Array.from(new Uint8Array(n),r=>r.toString(16).padStart(2,"0")).join("")}async function nd(e,t,n={}){let r=await tP(t),s=n.mediaType??"application/gzip",i=await ur(e,{kind:"archive",media_type:s});if(!i.upload)throw new Error("App artifact registration did not return an upload URL");if(r.byteLength>i.upload.max_bytes)throw new Error(`App artifact exceeds ${i.upload.max_bytes} bytes`);n.onProgress?.(0,r.byteLength);let o=await fetch(i.upload.url,{method:"PUT",body:new Blob([Uint8Array.from(r).buffer],{type:s}),signal:n.signal,headers:{"content-type":s,"x-upsert":"false"}});if(!o.ok){let a=await o.text().catch(()=>"");throw new Error(`App artifact upload failed with HTTP ${o.status}${a?`: ${a}`:""}`)}return n.onProgress?.(r.byteLength,r.byteLength),pr(e,i.artifact.artifact_id,{sha256:await nP(r),size_bytes:r.byteLength})}async function rd(e,t,n){return u(await c.post(`/projects/${e}/apps/${t}/deployments`,n),"Failed to create App deployment")}async function sd(e,t){return u(await c.get(`/projects/${e}/apps/${t}/deployments`),"Failed to list App deployments").deployments}async function id(e,t,n){return u(await c.get(`/projects/${e}/apps/${t}/deployments/${n}`),"Failed to load App deployment")}async function od(e,t,n,r={}){let s=new URLSearchParams;r.after!==void 0&&s.set("after",String(r.after)),r.limit!==void 0&&s.set("limit",String(r.limit));let i=s.size?`?${s.toString()}`:"";return u(await c.get(`/projects/${e}/apps/${t}/deployments/${n}/logs${i}`),"Failed to load App logs")}async function ad(e,t){return u(await c.post(`/projects/${e}/apps/${t}/start`,{}),"Failed to start App")}async function cd(e,t){return u(await c.post(`/projects/${e}/apps/${t}/stop`,{}),"Failed to stop App")}async function ld(e,t,n){return u(await c.post(`/projects/${e}/apps/${t}/rollback`,{deployment_id:n}),"Failed to roll back App")}async function dr(e){return u(await c.get(`/projects/${e}/model-access`))}async function gr(e,t){return u(await c.put(`/projects/${e}/model-access`,t))}function rP(e){let{running:t,isCarousel:n,contentStatus:r,isWebsitePreview:s,previewHasError:i,previewIsLinkOnly:o}=e;return t||n?!1:s?i&&!o:r==="error"}function ud(e){return typeof e=="string"&&e.trim().length>0}function Gm(e){if(!e||typeof e!="object")return!1;let{path:t,url:n,content:r}=e;return ud(t)||ud(n)||ud(r)}function sP(e){if(Array.isArray(e))return e.length>0?e:null;if(typeof e!="string"||!e.trim())return null;try{let t=JSON.parse(e);return Array.isArray(t)&&t.length>0?t:null}catch{return null}}function Xt(e){if(!e)return!0;let t=sP(e.items);return t?!t.some(Gm):!Gm(e)}function ae(e){return(e??"").replace(/^oc-/,"").replace(/-/g,"_")}function iP(e){return ae(e)==="bash"}function oP(e){let t=ae(e);return t==="question"||t==="ask"}function aP(e,t){let n=Math.max(0,e);return`${t?"Running":"Ran"} ${n} command${n===1?"":"s"}`}var Nm=new Set(["show","show_user"]);function pd(e){return Nm.has(ae(e))}function cP(e,t){let n=Math.max(0,e);return`${t?"Writing":"Wrote"} ${n} file${n===1?"":"s"}`}function dd(e){return!!(e.type==="snapshot"||e.type==="patch"||e.type==="step-start"||e.type==="step-finish"||e.type==="text"&&!e.text?.trim()||mr(e))}function mr(e){let t=ae(e.tool);return t!=="show"&&t!=="show_user"||e.state?.status!=="completed"?!1:Xt(e.state?.input)}var Wm=new Set(["show","show_user","agent_spawn","agent_status","agent_message","agent_task_update","agent_stop"]);function gd(e){return Wm.has(ae(e))}var lP=50*1024*1024,md="[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}",uP=new RegExp(`^kortix-attachment://(${md})/(${md})/(${md})$`);function yd(e){if(typeof e!="string")return null;let t=uP.exec(e);return t?{projectId:t[1],sessionId:t[2],attachmentId:t[3]}:null}function pP(e){return yd(e)!==null}var fd=new WeakMap;async function hd(e,t,n,r={}){if(n.size>lP)throw new Error("Attachments must be 50 MiB or smaller.");let s=`${e}/${t}`,i=r.attachmentId?void 0:fd.get(n)?.get(s);if(i?.promise)return i.promise;let o=i??{id:r.attachmentId??crypto.randomUUID(),promise:void 0};if(!r.attachmentId){let p=fd.get(n)??new Map;p.set(s,o),fd.set(n,p)}let a=new FormData;return a.append("attachment_id",o.id),a.append("file",n,n.name),o.promise=c.upload(`/projects/${encodeURIComponent(e)}/sessions/${encodeURIComponent(t)}/attachments`,a,{signal:r.signal,timeout:12e4,showErrors:!1}).then(u).catch(p=>{throw o.promise=void 0,p}),o.promise}async function bd(e,t){let n=yd(e);if(!n)throw new Error("Invalid attachment reference");let r=$().backendUrl.replace(/\/$/,""),s=await q(`${r}/projects/${n.projectId}/sessions/${n.sessionId}/attachments/${n.attachmentId}`,{signal:t});if(!s.ok)throw new S("Could not load attachment",{status:s.status});return s.blob()}var dP=new Set(["show","show_user"]);function gP(e){let t=[],n=0;for(;;){let r=e.indexOf("<file",n);if(r===-1)return t;let s=r+5;if(s>=e.length||!/\s/.test(e[s])){n=s;continue}let i=e.indexOf(">",s);if(i===-1)return t;let o=e.indexOf("</file>",i+1);if(o===-1)return t;t.push(e.slice(s,i).trimStart()),n=o+7}}var mt=e=>!!e&&typeof e=="object"&&!Array.isArray(e),Qt=e=>typeof e=="string"&&e.length>0?e:null,Km=e=>typeof e=="string"?Qt(e.split("/").pop()):null;function fr(e,t){let n=e.match(new RegExp(`(?:^|\\s)${t}="([^"]*)"`))?.[1];return n===void 0?null:n.replace(/"/g,'"').replace(/</g,"<").replace(/>/g,">").replace(/&/g,"&")}function mP(e){if(Array.isArray(e))return e;if(typeof e!="string"||!e.trim())return[];try{let t=JSON.parse(e);return Array.isArray(t)?t:[]}catch{return[]}}function fP(e){if(!Array.isArray(e))return[];let t=[],n=new Set,r=(s,i,o,a,p)=>{let g=yd(s);!g||n.has(s)||(n.add(s),t.push({url:s,attachment_id:g.attachmentId,filename:i,mime:o,message_id:a,role:p}))};for(let s of e){if(!mt(s)||!mt(s.info)||!Array.isArray(s.parts))continue;let i=Qt(s.info.id);if(!i)continue;let o=Qt(s.info.role)??"unknown";for(let a of s.parts)if(mt(a)){if(a.type==="file")r(a.url,Qt(a.filename),Qt(a.mime),i,o);else if(a.type==="text"&&typeof a.text=="string")for(let p of gP(a.text))r(fr(p,"attachment"),fr(p,"filename")??Km(fr(p,"path")),fr(p,"mime"),i,o);else if(a.type==="tool"&&typeof a.tool=="string"&&dP.has(ae(a.tool))&&mt(a.state)&&mt(a.state.input)){let p=a.state.input;for(let g of[p,...mP(p.items)])mt(g)&&r(g.attachment,Km(g.path),null,i,o)}}}return t}var ft=class extends Error{constructor(n,r,s){super(r);this.code=n;this.status=s;this.name="HeadlessAuthError"}code;status};function yP(e){let t=_e(e?.backendUrl??$().backendUrl??"");if(!t)throw new ft("not_configured","backendUrl is not configured (configureKortix / createKortix first)",0);return t.endsWith("/v1")?t:`${t}/v1`}async function Y(e,t,n){let r=n?.fetch??$().fetch??((p,g)=>fetch(p,g)),s={accept:"application/json"};t.body!==void 0&&(s["content-type"]="application/json"),t.bearer&&(s.authorization=`Bearer ${t.bearer}`);let i=await r(`${yP(n)}${e}`,{method:t.method??(t.body!==void 0?"POST":"GET"),headers:s,...t.body!==void 0?{body:JSON.stringify(t.body)}:{},...n?.signal?{signal:n.signal}:{}}),o=await i.text().catch(()=>""),a=null;try{a=o?JSON.parse(o):null}catch{a=o}if(!i.ok){let p=a&&typeof a=="object"?a:{};throw new ft(typeof p.error=="string"?p.error:"auth_error",typeof p.error_description=="string"&&p.error_description?p.error_description:typeof p.error=="string"?p.error:i.statusText||`HTTP ${i.status}`,i.status)}return a}function yr(e,t){return Y("/auth/signup",{body:e},t)}function hr(e,t){return Y("/auth/sign-in/password",{body:e},t)}function br(e,t){return Y("/auth/sign-in/magic-link",{body:e},t)}function _r(e,t){return Y("/auth/verify-otp",{body:e},t)}function xr(e,t){return Y("/auth/sign-in/oauth",{body:e},t)}function wr(e,t){return Y("/auth/oauth/exchange",{body:e},t)}function yt(e,t){return Y("/auth/refresh",{body:e},t)}function kr(e,t){return Y("/auth/password/reset",{body:e},t)}function Pr(e,t,n){return Y("/auth/password/update",{body:e,bearer:t},n)}function Sr(e,t){return Y("/auth/user",{bearer:e},t)}function vr(e,t,n){return Y("/auth/user",{method:"PATCH",body:e,bearer:t},n)}function Ar(e,t){return Y("/auth/sign-in/sso",{body:e},t)}var Rr={enroll:(e,t,n)=>Y("/auth/mfa/factors",{body:e,bearer:t},n),challenge:(e,t={},n,r)=>Y(`/auth/mfa/factors/${encodeURIComponent(e)}/challenge`,{body:t,bearer:n},r),verify:(e,t,n,r)=>Y(`/auth/mfa/factors/${encodeURIComponent(e)}/verify`,{body:t,bearer:n},r),unenroll:(e,t,n)=>Y(`/auth/mfa/factors/${encodeURIComponent(e)}`,{method:"DELETE",bearer:t},n)};function Cr(e,t={},n){return Y("/auth/sign-out",{body:t,bearer:e},n)}function Tr(e={}){let t=e.refreshSkewSeconds??60,n=e.now??(()=>Date.now()),r=null,s=null,i=!e.storage,o=null,a=null,p=0,g=new Set,m=P=>(P.expires_at??0)*1e3,h=P=>m(P)-t*1e3<=n();async function _(){e.storage&&(r?await e.storage.set(JSON.stringify({session:r,user:s})):await e.storage.remove());for(let P of[...g])try{P(r)}catch{}try{e.onChange?.(r)}catch{}}async function w(){if(i)return r;if(!o){let P=p,M=(async()=>{let k=await e.storage.get();if(P===p&&k)try{let d=JSON.parse(k);d.session?.access_token&&d.session?.refresh_token&&(r=d.session,s=d.user??null)}catch{r=null}return i=!0,r})();o=M,M.then(()=>{o===M&&(o=null)},()=>{o===M&&(o=null)})}return o}async function A(){if(await w(),!r)return null;if(!a){let P=r.refresh_token,M=p,k=yt({refresh_token:P},e.request).then(async d=>(M!==p||(r=d.session,d.user&&(s=d.user),await _()),r)).catch(async d=>{if(M!==p)return r;let y=d&&typeof d=="object"&&"status"in d?d.status:0;if(y>=400&&y<500)return r=null,s=null,await _(),null;throw d}).finally(()=>{a===k&&(a=null)});a=k}return a}return{subscribe(P){return g.add(P),()=>{g.delete(P)}},current:()=>r,user:()=>s,load:w,async set(P,M){await w(),p+=1,a=null,r=P,M!==void 0&&(s=M),P||(s=null),await _()},async getToken(){return await w(),r?h(r)?(await A().catch(()=>r))?.access_token??null:r.access_token:null},refresh:A,async clear(){p+=1,a=null,r=null,s=null,i=!0,await _()}}}var bP=["control_plane","provider_ingress","daemon","upstream_port"];function _d(e){return typeof e=="string"&&bP.includes(e)?e:null}function _P(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 xd(e,t){let n=(e===void 0?be():e)||null;if(!n)return{status:0,ok:!1,health:null,body:"",hop:null,upstreamStatus:null};let r=await q(`${n}/kortix/health`,{method:"GET",...t},{retryOnAuthError:!1}),s=await r.text().catch(()=>""),i=null;try{i=s?JSON.parse(s):null}catch{i=null}let o=i,a=_d(r.headers.get("X-Kortix-Proxy-Hop"))??_d(i?.hop),p=Number(r.headers.get("X-Kortix-Upstream-Status")),g=i?.upstream_status,m=Number.isFinite(p)&&p>0?p:typeof g=="number"?g:null;return{status:r.status,ok:r.ok,health:o,body:s,hop:a,upstreamStatus:m}}var ke={DESKTOP:"6080",DESKTOP_HTTPS:"6081",PRESENTATION_VIEWER:"3210",STATIC_FILE_SERVER:"3211",KORTIX_MASTER:"8000",BROWSER_STREAM:"9223",BROWSER_VIEWER:"9224",SSH:"22"};var Hm=/https?:\/\/(?:localhost|127\.0\.0\.1):\d{1,5}[^\s)"'<>]*/g,zm=/^https?:\/\/p(\d+)-([^.]+)\.localhost(?::(\d+))?(\/.*)?$/,Vm=/^https?:\/\/(?:dev|staging|prod|preview)-p(\d+)-([a-z0-9-]+)\.[^/]+?(?::(\d+))?(\/.*)?$/i,Jm=new Set([22,4096,parseInt(ke.KORTIX_MASTER,10)]);function xP(e){return zm.test(e)}function Ir(e){if(!e)return"/";let t=e,n=t.indexOf("](");n!==-1&&(t=t.slice(0,n));let r=t.toLowerCase().indexOf("%5d(");return r!==-1&&(t=t.slice(0,r)),t?t.startsWith("/")?t:`/${t}`:"/"}function wP(e){let t=e.indexOf("](");return t===-1?e:e.slice(0,t)}var kP=new Set(["'",'"',"`","<","(","["]),PP=new Set([">","'",'"',"`",")","]",",",";",".","!","?"]);function SP(e){let t=0,n=e.length;for(;t<n&&(e[t]===" "||e[t]===" ");)t++;for(;n>t&&(e[n-1]===" "||e[n-1]===" ");)n--;for(;t<n&&kP.has(e[t]);)t++;for(;n>t&&PP.has(e[n-1]);)n--;return e.slice(t,n)}function vP(e){return e.match(/https?:\/\/(?:localhost|127\.0\.0\.1):\d{1,5}[^\s"'<>)]*/i)?.[0]??null}var AP=/^\/proxy\/(\d{1,5})(\/.*)?$/,RP=/^\/(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 Xm(e){if(!e)return!1;try{let t=new URL(e);return t.hostname!=="localhost"&&t.hostname!=="127.0.0.1"?!1:RP.test(t.pathname)}catch{return!1}}function Zt(e){if(!e)return null;let t=SP(wP(e.trim())),n=kd(t);if(n){let r=Ir(n.path||"/");return{originalUrl:`http://localhost:${n.port}${r}`,port:n.port,path:r}}try{let r=new URL(t);if(r.protocol!=="http:"&&r.protocol!=="https:"||r.hostname!=="localhost"&&r.hostname!=="127.0.0.1"||!r.port)return null;let s=parseInt(r.port,10);if(!Number.isInteger(s)||s<1||s>65535)return null;let i=`${r.pathname||"/"}${r.search}${r.hash}`,o=parseInt(ke.KORTIX_MASTER,10);if(s===o){let p=r.pathname.match(AP);if(p){let g=parseInt(p[1],10);if(g>=1&&g<=65535)return s=g,i=Ir(`${p[2]||"/"}${r.search}${r.hash}`),{originalUrl:`http://localhost:${s}${i}`,port:s,path:i}}}let a=Ir(i);return{originalUrl:`${r.protocol}//${r.hostname}:${s}${a}`,port:s,path:a}}catch{let r=vP(e);return r&&r!==e?Zt(r):null}}function CP(e){let t=[],n=/```[\s\S]*?```/g,r;for(;(r=n.exec(e))!==null;)t.push([r.index,r.index+r[0].length]);let s=/`[^`\n]+`/g;for(;(r=s.exec(e))!==null;){let i=r.index,o=i+r[0].length;t.some(([p,g])=>i>=p&&o<=g)||t.push([i,o])}return t}function TP(e,t){return t.some(([n,r])=>e>=n&&e<r)}function Qm(e){let t=[],n=new Set,r=CP(e);Hm.lastIndex=0;let s;for(;(s=Hm.exec(e))!==null;){let i=Zt(s[0]);if(!i)continue;let{originalUrl:o,port:a,path:p}=i;a<1||a>65535||Jm.has(a)||n.has(o)||(n.add(o),t.push({originalUrl:o,port:a,path:p,startIndex:s.index,endIndex:s.index+o.length,inCodeBlock:TP(s.index,r)}))}return t}function IP(e){return Qm(e).length>0}function EP(e){try{let{hostname:t}=new URL(e);return t==="localhost"||t==="127.0.0.1"}catch{return!1}}function Ym(e){return e.trim().toLowerCase().split("_").join("-")}function Zm(e){let t=e.length;for(;t>0&&e.charCodeAt(t-1)===47;)t--;return e.slice(0,t)}function jP(e,t,n){let r=n.previewUrlTemplate;if(!r||!r.includes("{port}")||!r.includes("{sandbox}"))return null;let s=r.split("{port}").join(String(e)).split("{sandbox}").join(Ym(n.sandboxId));return`${Zm(s)}${t}`}function ef(e){return e.sandboxId.trim().length>0}function $e(e,t,n){let r=Ir(t);if(!ef(n))return sf(e,r);let s=jP(e,r,n);return s||(EP(n.apiBaseUrl)?`http://p${e}-${Ym(n.sandboxId)}.localhost:${n.backendPort}${r}`:`${Zm(n.apiBaseUrl)}/p/${n.sandboxId}/${e}${r}`)}function MP(e,t){if(!e)return;let r=e.replace(/^\/workspace\//,"").replace(/^\/+/,"").split("/").filter(Boolean).map(s=>encodeURIComponent(s)).join("/");return $e(3211,`/open?path=/workspace/${r}`,t)}function tf(e){return`/open?path=/${(e.startsWith("/workspace")?e:`/workspace/${e.replace(/^\/+/,"")}`).split("/").filter(Boolean).map(r=>encodeURIComponent(r)).join("/")}`}function $P(e){return`http://localhost:3211${tf(e)}`}function nf(){return"/health"}function OP(e){return $e(3211,nf(),e)}function DP(e,t){return $e(e,"/",t)}function rf(e){let t=Zt(e);return!(!t||Jm.has(t.port)||Xm(e))}function wd(e,t){if(!e)return e;let n=Zt(e);return n?rf(n.originalUrl)?$e(n.port,n.path,t):n.originalUrl:e}function sf(e,t="/"){return`http://localhost:${e}${t}`}var of=/^https?:\/\/[^/]+\/v1\/p\/([^/]+)\/(\d+)(\/.*)?$/;function kd(e){let t=e.match(zm);if(t)return{port:parseInt(t[1],10),sandboxId:t[2],backendPort:t[3]?parseInt(t[3],10):80,path:t[4]||"/"};let n=e.match(Vm);if(n){let s=443;try{let i=new URL(e);s=i.port?parseInt(i.port,10):i.protocol==="https:"?443:80}catch{return null}return{port:parseInt(n[1],10),sandboxId:n[2],backendPort:s,path:n[4]||"/"}}let r=e.match(of);if(r)try{let s=new URL(e);return{port:parseInt(r[2],10),sandboxId:r[1],backendPort:parseInt(s.port,10)||(s.protocol==="https:"?443:80),path:r[3]||"/"}}catch{return null}return null}function qP(e){try{let t=kd(e);return t?`http://localhost:${t.port}${t.path}`:null}catch{return null}}function UP(e){return xP(e)||Vm.test(e)||of.test(e)}function FP(e){try{let{hostname:t,port:n}=new URL(e);return(t==="localhost"||t==="127.0.0.1")&&n!==""}catch{return!1}}var Yt="/web-proxy/";function LP(e,t){try{let n=new URL(e);if(n.protocol!=="http:"&&n.protocol!=="https:")return null;let r=n.protocol.replace(":",""),s=`${Yt}${r}/${n.host}${n.pathname}${n.search}${n.hash}`,i=parseInt(ke.KORTIX_MASTER,10);return`${$e(i,"/",t).replace(/\/$/,"")}${s}`}catch{return null}}function BP(e){try{let t=new URL(e),n=t.pathname.indexOf(Yt);if(n===-1)return null;let s=t.pathname.slice(n+Yt.length).match(/^(https?)\/([\w.\-]+(?::\d+)?)(\/.*)?$/);if(!s)return null;let i=s[1],o=s[2],a=s[3]||"/";return`${i}://${o}${a}${t.search}${t.hash}`}catch{return null}}function GP(e){try{return new URL(e).pathname.includes(Yt)}catch{return e.includes(Yt)}}function NP(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 WP(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 af="frontend";function Er(e,t,n){(e==="error"?console.error:e==="warn"?console.warn:e==="debug"?console.debug:console.log)(`[${af}] ${t}`,...n?[n]:[]);try{je().app.log({service:af,level:e,message:t,extra:n})}catch{}}var Oe={debug:(e,t)=>Er("debug",e,t),info:(e,t)=>Er("info",e,t),warn:(e,t)=>Er("warn",e,t),error:(e,t)=>Er("error",e,t)};function cf(e){return{type:"heartbeat-gap",gapMs:e}}function lf(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 KP={now:()=>Date.now(),setTimeout:(e,t)=>setTimeout(e,t),clearTimeout:e=>clearTimeout(e)},HP=16,zP=8,VP=6e4,JP=5e3,XP=250,QP=1e3,YP=3e4,ZP=5,eS=3e3,tS=3e4,nS=2e4,rS=2e3,sS=8;function iS(e){if(e.type==="session.status")return`session.status:${e.properties.sessionID}`;if(e.type==="lsp.updated")return"lsp.updated"}function uf(e){if(e.aborted)return{promise:Promise.resolve(),cleanup:()=>{}};let t=()=>{};return{promise:new Promise(r=>{t=()=>r(),e.addEventListener("abort",t,{once:!0})}),cleanup:()=>e.removeEventListener("abort",t)}}var jr=new WeakMap;function oS(e,t,n){let r=t.timers??KP,s=t.connectTimeoutMs??nS,i=t.heartbeatTimeoutMs??VP,o=t.maxConsecutiveHardFailures??sS,a=new AbortController;function p(k,...d){for(let y of n){let l=k(y);if(l)try{l(...d)}catch(x){console.warn("[opencode-events] subscriber handler threw, skipping",x)}}}let g=r.now(),m=null,h=[],_,w=0,A=new Map,P=()=>{if(_&&r.clearTimeout(_),_=void 0,h.length===0)return;let k=h;h=[],A.clear(),w=r.now(),g=r.now();for(let d of k)d&&p(y=>y.onEvent,d.event)},M=()=>{if(_)return;let k=r.now()-w;_=r.setTimeout(P,Math.max(0,HP-k))};return(async()=>{let k=0,d=0;for(;!a.signal.aborted;){let y=!1,l=!1,x=!1,R,I,O=null,N=r.now(),E=new AbortController,K=uf(a.signal);K.promise.then(()=>E.abort());try{let L=await new Promise((J,oe)=>{let Q=!1;I=r.setTimeout(()=>{Q||(Q=!0,Oe.warn("SSE connect timed out, forcing reconnect",{connectTimeoutMs:s}),E.abort(),oe(new Error(`SSE connect timed out after ${s}ms`)))},s),e.global.event({signal:E.signal,sseDefaultRetryDelay:eS,sseMaxRetryDelay:tS,sseMaxRetryAttempts:1}).then(le=>{Q||(Q=!0,r.clearTimeout(I),J(le))},le=>{Q||(Q=!0,r.clearTimeout(I),oe(le))})}),{stream:X}=L;if(m){let J=r.now()-m.lastActivityAt,oe=m.eventful;m=null,(oe||J>JP)&&p(Q=>Q.onGapRehydrate,J)}g=r.now();let G=()=>{r.clearTimeout(R),R=r.setTimeout(()=>{Oe.warn("SSE heartbeat timeout, forcing reconnect"),E.abort()},i)};G();let se=r.now(),Re=X[Symbol.asyncIterator]();for(;!E.signal.aborted;){let J=Re.next().then(Ce=>({kind:"next",result:Ce}),Ce=>({kind:"error",error:Ce})),oe=uf(E.signal),Q=await Promise.race([J,oe.promise.then(()=>({kind:"aborted"}))]);if(oe.cleanup(),Q.kind==="aborted")break;if(Q.kind==="error")throw Q.error;if(Q.result.done)break;y=!0,G();let le=Q.result.value,St=le&&typeof le=="object"&&"payload"in le?le.payload:le;if(!St?.type)continue;St.type!=="server.connected"&&(l=!0);let ts=iS(St);if(ts){let Ce=A.get(ts);Ce!==void 0&&(h[Ce]=void 0),A.set(ts,h.length)}h.push({type:St.type,event:St}),M(),!(r.now()-se<zP)&&(se=r.now(),await new Promise(Ce=>r.setTimeout(Ce,0)))}x=y}catch(L){if(a.signal.aborted)break;O=L;let X=String(L),G=X.includes("401")||X.includes("403")||X.includes("Unauthorized")||X.includes("Token refresh failed");if(Oe.error("SSE event stream error",{error:X,retryCount:k,isAuthError:G}),G)try{jn(),await En(),Oe.info("SSE: refreshed auth token after auth error")}catch(se){Oe.error("SSE: failed to refresh auth token",{error:String(se)})}}finally{r.clearTimeout(R),r.clearTimeout(I),E.abort(),K.cleanup(),P()}if(a.signal.aborted)break;let F=r.now()-N,b=O?.cause?.status;if(d=!y&&(typeof b=="number"&&b>=400||F<rS)?d+1:0,d>=o){Oe.error("SSE event stream parked \u2014 giving up after consecutive hard failures",{consecutiveFailures:d,lastError:String(O)}),p(L=>L.onParked,{consecutiveFailures:d,lastError:O});break}m={lastActivityAt:g,eventful:(m?.eventful??!1)||l},x?k=0:(k++,k>1&&Oe.warn("SSE event stream reconnecting",{retryCount:k}));let ee=x?XP:Math.min(QP*2**Math.min(k-1,ZP),YP);await new Promise(L=>{let X=r.setTimeout(L,ee),G=()=>{r.clearTimeout(X),L()};a.signal.addEventListener("abort",G,{once:!0})})}})(),{subscribers:n,teardown:()=>{a.abort(),_&&r.clearTimeout(_)}}}function Mr(e){let{client:t,onEvent:n,onGapRehydrate:r,onParked:s,signal:i}=e,o={onEvent:n,onGapRehydrate:r,onParked:s},a=jr.get(t);a?a.subscribers.add(o):(a=oS(t,e,new Set([o])),jr.set(t,a));let p=a,g=!1,m=()=>{g||(g=!0,i&&i.removeEventListener("abort",h),p.subscribers.delete(o),p.subscribers.size===0&&(p.teardown(),jr.get(t)===p&&jr.delete(t)))},h=()=>m();return i&&(i.aborted?m():i.addEventListener("abort",h,{once:!0})),{close:m}}function aS(){return je()}var $r=new Map;function cS(e){let t=`Session runtime not ready (stage: ${e?.stage??"unknown"})`,n=e?.failure,r=[];n?.category&&r.push(n.category),n?.message&&r.push(n.message);let s=n?.evidence?.error;return s&&s!==n?.message&&r.push(s),r.length===0&&e?.reason&&r.push(e.reason),r.length>0?`${t}: ${r.join(" \u2014 ")}`:t}var en=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 pf(e,t){xn(e,t);function n(d){try{return new URL(d)}catch{if(typeof window<"u"&&window.location?.origin)try{return new URL(d,window.location.origin)}catch{return null}throw new S(`Kortix SDK: backendUrl must be an absolute URL outside the browser (got ${JSON.stringify(d)}). 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 r(d){let y=$().backendUrl??e.backendUrl,l=80,x=n(y);return x&&(l=x.port?Number(x.port):x.protocol==="https:"?443:80),Qg({sandboxId:d,apiBaseUrl:y,backendPort:l})}let s={signUp:yr,signInWithPassword:hr,sendMagicLink:br,verifyOtp:_r,signInWithProvider:xr,exchangeCode:wr,refresh:yt,resetPassword:kr,updatePassword:Pr,updateUserMetadata:vr,signInWithSso:Ar,mfa:Rr,user:Sr,signOut:Cr,session:Tr},i={list:io,get:ao,create:oo,secretResources:{list:Ta,create:Ia,rotate:Ea,remove:ja,grant:Ma,revoke:$a,setAccess:Oa},updateName:co,branding:{get:lo,update:uo,uploadAsset:po,removeAsset:go,reset:mo},leave:Ao,members:fo,invite:yo,removeMember:So,updateMemberRole:vo,invites:ho,cancelInvite:bo,resendInvite:_o,tokens:{list:Sp,create:vp,revoke:Ap},audit:{log:Ip,export:jp,webhooks:{list:Mp,create:$p,update:Op,remove:Dp}}},o={assignments:{list:lp,create:up,revoke:pp},permissions:{list:dp,forRole:Ju},roles:{list:zu,create:Qu,update:Yu,setPermissions:Zu,remove:ep,usage:Xu},groups:{list:Fu,get:Lu,create:Bu,update:Gu,remove:Nu,members:{list:Wu,add:Ku,remove:Hu}},agentIdentities:Vu,oauthClients:{list:rp,get:sp,create:ip,update:op,rotateSecret:ap,remove:cp},can:tp,canBatch:np},a={accountState:Ul,accountStateMinimal:Fl,transactions:Ll,transactionsSummary:Bl,creditBreakdown:Gl,usageHistory:Nl,usageRollup:nu,sessionCosts:{list:iu,get:ar},tierConfigurations:Wl,checkout:{createSession:d=>Kl(d),confirmSession:(d,y)=>Hl(d,y)},subscription:{createPortalSession:(d,y)=>zl(d,y),cancel:(d,y)=>Vl(d,y),reactivate:d=>Jl(d),scheduleDowngrade:(d,y,l)=>Xl(d,y,l),cancelScheduledChange:d=>Ql(d),prorationPreview:(d,y)=>Yl(d,y)},credits:{purchase:d=>Zl(d),autoTopupSettings:d=>eu(d),configureAutoTopup:d=>tu(d)}},p={listMine:xo,describe:wo,accept:ko,decline:Po},g={list:Ge,listForAccount:Co,get:Kn,detail:Hn,create:jo,createRepo:Mo,provision:$o,update:Jn,archive:Xn,llmCatalog:zn,modelPicker:Vn,modelAccess:dr,setModelAccess:gr,sandboxHealth:tr,sandboxTemplates:Pc,sessions:dt,createSession:gt},m={linkRepository:Fo,replaceProjectRepository:Lo,getInstallation:Bo,listInstallations:Go,listLinkableInstallations:No,listRepositories:Wo,listRepositoryBranches:Ko,linkInstallation:zo,saveInstallation:Ho,deleteInstallation:Vo},h={get:Jo,repositories:Xo},_={list:wp,create:kp,revoke:Pp},w=bc,A={items:d=>Fp(d),item:d=>Gp(d),itemFile:(d,y)=>Np(d,y),marketplaces:()=>Lp(),featured:()=>Bp(),sources:{list:()=>Wp(),add:d=>Kp(d),remove:d=>Hp(d)}};function P(d){return{catalog:()=>Ht(d),tools:()=>Yn(d),search:(...y)=>Fa(d,...y),describe:(...y)=>La(d,...y),call:(...y)=>Ba(d,...y),accounts:(...y)=>Ga(d,...y),uploadAttachment:(...y)=>Na(d,...y)}}function M(d){let y={list:()=>Wa(d),listAll:()=>Ka(d),reconcile:(...l)=>Ha(d,...l),reconcileMember:(...l)=>za(d,...l),updateCredential:(...l)=>Va(d,...l),revoke:(...l)=>Ja(d,...l),activate:(...l)=>Xa(d,...l),setDefault:(...l)=>Qa(d,...l),rename:(...l)=>Ya(d,...l),share:(...l)=>Za(d,...l),pipedreamConnect:(...l)=>ec(d,...l),pipedreamFinalize:(...l)=>tc(d,...l)};return{attachments:{upload:(...l)=>Wt(d,...l),delete:(...l)=>pt(d,...l),createController:l=>so(d,l)},get:l=>Kn(d,l),detail:()=>Hn(d),audit:l=>Ep(d,l),update:l=>Jn(d,l),archive:()=>Xn(d),llmCatalog:()=>zn(d),modelPicker:()=>Vn(d),modelAccess:()=>dr(d),setModelAccess:l=>gr(d,l),sandboxHealth:()=>tr(d),onboardingComplete:(...l)=>Uo(d,...l),apps:{list:()=>zp(d),create:l=>Vp(d,l),get:l=>Jp(d,l),update:(...l)=>Xp(d,...l),access:{get:(...l)=>Yp(d,...l),update:(...l)=>ed(d,...l),session:(...l)=>td(d,...l),agents:l=>Zp(d,l)},remove:l=>Qp(d,l),artifacts:{register:l=>ur(d,l),uploadArchive:(...l)=>nd(d,...l),finalize:(...l)=>pr(d,...l)},deployments:{create:(...l)=>rd(d,...l),list:l=>sd(d,l),get:(...l)=>id(d,...l),logs:(...l)=>od(d,...l)},start:l=>ad(d,l),stop:l=>cd(d,l),rollback:(...l)=>ld(d,...l)},tokens:{list:()=>Rp(d),create:l=>Cp(d,l),revoke:l=>Tp(d,l)},setupLinks:{requestSecret:l=>qp(d,l),requestConnector:l=>Up(d,l)},validateManifest:l=>Io(d,l),gitToken:()=>Eo(d),secrets:{list:()=>ha(d),upsert:l=>ba(d,l),setStrategy:(...l)=>_a(d,...l),broker:(...l)=>xa(d,...l),remove:l=>va(d,l),setPersonal:(...l)=>Aa(d,...l),removePersonal:l=>Ra(d,l),setGitCredential:l=>Sa(d,l),startProviderOAuth:(...l)=>wa(d,...l),pollProviderOAuth:(...l)=>ka(d,...l),removeProviderOAuth:l=>Pa(d,l)},access:{list:()=>ea(d),invite:(...l)=>ra(d,...l),update:(...l)=>ta(d,...l),revoke:l=>na(d,l),pendingInvites:()=>sa(d),resendInvite:(...l)=>oa(d,...l),revokeInvite:(...l)=>ia(d,...l),requests:()=>Qo(d),approveRequest:(...l)=>Yo(d,...l),rejectRequest:(...l)=>Zo(d,...l),groupGrants:()=>aa(d),attachGroupGrant:(...l)=>ca(d,...l),updateGroupGrant:(...l)=>la(d,...l),detachGroupGrant:l=>ua(d,l),resourceGrants:{list:()=>pa(d),create:l=>da(d,l),remove:l=>ga(d,l)}},connectors:{...P(d),list:()=>nc(d),config:(...l)=>lc(d,...l),create:(...l)=>dc(d,...l),remove:(...l)=>mc(d,...l),sync:()=>rc(d),auth:{discover:(...l)=>gc(d,...l)},setName:(...l)=>uc(d,...l),setCredentialMode:(...l)=>sc(d,...l),setAuthorizationStrategy:(...l)=>ic(d,...l),setCredential:(...l)=>_c(d,...l),setSensitive:(...l)=>oc(d,...l),connections:y,policies:{get:(...l)=>ac(d,...l),set:(...l)=>cc(d,...l)},pipedream:{listApps:(...l)=>fc(d,...l),listSections:(...l)=>yc(d,...l),connect:(...l)=>pc(d,...l),finalize:(...l)=>xc(d,...l)},discover:{list:(...l)=>Zn(d,...l),sections:(...l)=>hc(d,...l),detail:(...l)=>er(d,...l)}},policies:{list:()=>wc(d),set:(...l)=>kc(d,...l)},triggers:{list:()=>vl(d),create:(...l)=>Al(d,...l),update:(...l)=>Rl(d,...l),remove:(...l)=>Cl(d,...l),fire:(...l)=>Il(d,...l),setActivation:(...l)=>Tl(d,...l)},files:{list:l=>jc(d,l),read:(l,x)=>$c(d,l,x),search:(...l)=>Mc(d,...l),archive:(...l)=>Oc(d,...l),history:(...l)=>Lc(d,...l)},git:{commits:()=>qc(d),commit:l=>Uc(d,l),commitDiff:l=>Fc(d,l),branches:()=>Dc(d),versionDiff:(...l)=>Bc(d,...l),inviteCollaborator:(...l)=>To(d,...l)},changeRequests:{list:()=>Gc(d),get:l=>Nc(d,l),diff:l=>Wc(d,l),mergePreview:l=>Kc(d,l),open:(...l)=>Hc(d,...l),merge:(...l)=>zc(d,...l),close:(...l)=>Vc(d,...l),reopen:(...l)=>Jc(d,...l),requestChanges:(...l)=>Xc(d,...l)},sessions:{list:l=>dt(d,l),listPage:l=>el(d,l),create:l=>gt(d,l),ensureWarm:()=>ol(d),claimWarm:l=>al(d,l)},review:{list:l=>gp(d,l),get:l=>mp(d,l),submit:l=>fp(d,l),act:(...l)=>yp(d,...l),bulkAct:l=>hp(d,l)},approvals:{list:l=>ma(d,l),resolve:(...l)=>ya(d,...l),sessionsNeedingInput:l=>fa(d,l)},gateway:{logs:l=>vu(d,l),log:l=>Au(d,l),overview:l=>Ru(d,l),series:l=>Cu(d,l),breakdown:l=>Tu(d,l),sessions:l=>Iu(d,l),errors:l=>Eu(d,l),budgets:()=>ju(d),setBudget:l=>Mu(d,l),deleteBudget:l=>$u(d,l),keys:()=>Ou(d),createKey:l=>Du(d,l),revokeKey:l=>qu(d,l),routing:{get:()=>wu(d),set:l=>ku(d,l),reset:()=>Pu(d),preview:l=>Su(d,l)},playground:(l,x,R)=>Uu(d,l,x,R)},channels:{slack:{installation:()=>ou(d),connect:l=>au(d,l),mode:()=>cu(d),completeInstall:l=>lu(d,l),manifest:()=>pu(d),disconnect:()=>du(d),getFile:l=>gu(d,l),uploadFile:l=>mu(d,l)},teams:{completeInstall:l=>uu(d,l)},email:{installation:l=>yu(d,l),mode:()=>hu(d),connect:l=>bu(d,l),disconnect:l=>_u(d,l),updatePolicy:(...l)=>xu(d,...l)}},updateFeatureFlag:(...l)=>Oo(d,...l),updateExperimentalFeature:(...l)=>Do(d,...l),modelDefaults:{get:()=>jl(d),set:l=>Ml(d,l),clear:l=>$l(d,l)},setDefaultAgent:l=>ql(d,l),sandbox:{list:()=>Ec(d),snapshots:()=>Sc(d),rebuildSnapshot:l=>vc(d,l),fixWithAgent:()=>Ac(d),createTemplate:l=>Rc(d,l),updateTemplate:(...l)=>Cc(d,...l),removeTemplate:l=>Tc(d,l),buildTemplate:l=>Ic(d,l),setProvider:l=>qo(d,l)},setAgentScope:(...l)=>Ol(d,...l),session:l=>k(d,l)}}function k(d,y){let l=null,x,R,I=null;async function O(){I||(I=nr(d,y,{showErrors:!1}).then(b=>{let T=typeof b.metadata?.opencode_model=="string"?b.metadata.opencode_model.trim():"",D=T.indexOf("/"),ee=D>0&&D<T.length-1?{providerID:T.slice(0,D),modelID:T.slice(D+1)}:void 0,L=b.agent_name?.trim()||void 0;return{model:ee,agent:L}}));try{return await I}catch(b){throw I=null,b}}function N(){if(l)return l;let b=Cm(d,y);return b&&(l=b),l}async function E(b){let T=N();if(T)return T;let D=b?.readyTimeoutMs??18e4,ee=Ye($().backendUrl??e.backendUrl).catch(()=>null),L=`${d}
|
|
21
21
|
${y}`,X=$r.get(L);if(X)return l=await X,await ee,l;let G=(async()=>{let se=Date.now()+D,Re=()=>Math.max(0,se-Date.now()),J=await Ne(d,y,Math.min(3e4,Re()));for(;Date.now()<se&&(J==null||(J.stage==="provisioning"||J.stage==="starting")&&J.retriable);)await new Promise(le=>setTimeout(le,Math.min(1e3,Re()))),J=await Ne(d,y,Math.min(3e4,Re()));if(!J||J.stage!=="ready"||!J.sandbox||!J.opencode_session_id)throw new S(cS(J),{code:"RUNTIME_UNAVAILABLE"});let oe=J.sandbox.external_id;if(!oe)throw new S("Session sandbox has no external_id \u2014 cannot resolve its runtime URL",{code:"RUNTIME_UNAVAILABLE"});let Q=Mn(oe);return Fg(Q,oe),{opencodeSessionId:J.opencode_session_id,runtimeUrl:Q,sandboxId:oe}})();$r.set(L,G);try{return l=await G,await ee,l}finally{$r.get(L)===G&&$r.delete(L)}}function K(b){let T=N();if(!T)throw new en(b);return T}function F(){l=null,Im(d,y)}return{get:b=>nr(d,y,b),cost:()=>ar(y,{projectId:d}),update:b=>hl(d,y,b),delete:()=>(F(),bl(d,y)),start:(...b)=>Ne(d,y,...b),restart:()=>(F(),Vt(d,y)),stop:()=>(F(),Jt(d,y)),configState:()=>_l(d,y),reloadConfig:b=>(F(),xl(d,y,b)),reloadConfigStream:(...b)=>(F(),wl(d,y,...b)),setSharing:b=>tl(d,y,b),previews:()=>nl(d,y),commit:b=>Qc(d,y,b),publicShares:{list:()=>rl(d,y),create:(...b)=>sl(d,y,...b),revoke:(...b)=>il(d,y,...b)},audit:(b,T)=>cl(d,y,b,T),attachments:{upload:(b,T)=>hd(d,y,b,T),read:(b,T)=>bd(`kortix-attachment://${d}/${y}/${b}`,T)},transcript:b=>ll(d,y,b),transcriptSync:b=>ul(d,y,b),turn:()=>pl(d,y),prompts:{create:b=>dl(d,y,b),list:()=>gl(d,y),remove:b=>ml(d,y,b),retry:b=>fl(d,y,b),hold:b=>yl(d,y,b)},ensureReady:E,health:b=>xd(N()?.runtimeUrl??null,b),previewUrl:(b,T="/")=>$e(b,T,r(K("previewUrl").sandboxId)),proxyUrl:b=>wd(b,r(K("proxyUrl").sandboxId)),setModel:b=>{x=b},changeModel:async b=>{let T=await Sl(d,y,b);return I=null,T},scope:()=>kl(d,y),providerSecretPool:{list:()=>qa(d,y),get:b=>Da(d,y,b),set:(b,T)=>Ua(d,y,b,T)},rescope:b=>Pl(d,y,b),setAgent:b=>{R=b},send:async(b,T)=>{let{opencodeSessionId:D,runtimeUrl:ee}=await E(),L=T?.model??x,X=T?.agent??R,G=L&&X?{}:await O(),se=L??G.model,Re=X??G.agent;return xe(ee).session.prompt({sessionID:D,parts:[{type:"text",text:b}],...se?{model:se}:{},...Re?{agent:Re}:{}})},abort:async()=>{let{opencodeSessionId:b,runtimeUrl:T}=await E();return xe(T).session.abort({sessionID:b})},rewind:async b=>{let{opencodeSessionId:T,runtimeUrl:D}=await E();return xe(D).session.revert({sessionID:T,messageID:b})},restoreRewind:async()=>{let{opencodeSessionId:b,runtimeUrl:T}=await E();return xe(T).session.unrevert({sessionID:b})},stream:async b=>{let{runtimeUrl:T}=await E();return Mr({client:xe(T),onEvent:b.onEvent,onGapRehydrate:b.onGapRehydrate,signal:b.signal})},get runtime(){return xe(K("runtime").runtimeUrl)},files:{list:async b=>it(b,(await E()).runtimeUrl),read:async b=>ot(b,(await E()).runtimeUrl),readBlob:async b=>at(b,(await E()).runtimeUrl),status:async()=>Ot((await E()).runtimeUrl),findFiles:async(b,T)=>Dt(b,T,(await E()).runtimeUrl),findText:async b=>qt(b,(await E()).runtimeUrl),upload:async(b,T,D,ee)=>ct(b,T,D,(await E()).runtimeUrl,ee),write:async(b,T)=>Lt(b,T,(await E()).runtimeUrl),create:async b=>Ut(b,(await E()).runtimeUrl),copy:async(b,T)=>Ft(b,T,(await E()).runtimeUrl),remove:async b=>Be(b,(await E()).runtimeUrl),mkdir:async b=>lt(b,(await E()).runtimeUrl),rename:async(b,T)=>Bt(b,T,(await E()).runtimeUrl)}}}return{config:e,auth:s,accounts:i,iam:o,accountInvites:p,projects:g,connectors:P(),project:M,session:k,github:m,gitBackend:h,billing:a,sandboxShares:_,connectStatus:w,marketplace:A,validateToken:Ro,runtime:aS}}function df(){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 r=0;r<16;r++)t[r]=Math.floor(Math.random()*256);t[6]=t[6]&15|64,t[8]=t[8]&63|128;let n=[...t].map(r=>r.toString(16).padStart(2,"0"));return`${n[0]}${n[1]}${n[2]}${n[3]}-${n[4]}${n[5]}-${n[6]}${n[7]}-${n[8]}${n[9]}-${n.slice(10).join("")}`}function gf(){return{pending:[],failed:[],inFlightId:null,inFlightIds:[]}}function ht(e){return e.inFlightIds?.length?e.inFlightIds:e.inFlightId?[e.inFlightId]:[]}function mf(e,t){return{...e,pending:[...e.pending,{...t,attempts:0}]}}function ff(e){if(ht(e).length>0)return{state:e};let t=e.pending[0];if(!t)return{state:e};let n={...t,attempts:t.attempts+1};return{state:{...e,pending:[n,...e.pending.slice(1)],inFlightId:n.id,inFlightIds:[n.id]},claimed:n}}function yf(e){let t=ht(e);return t.length===0?e:{...e,pending:e.pending.filter(n=>!t.includes(n.id)),inFlightId:null,inFlightIds:[]}}function hf(e,t){let n=ht(e);if(n.length===0)return e;let r=e.pending.filter(s=>n.includes(s.id));return r.length===0?{...e,inFlightId:null,inFlightIds:[]}:{pending:e.pending.filter(s=>!n.includes(s.id)),failed:[...e.failed,...r.map(s=>({...s,lastError:t}))],inFlightId:null,inFlightIds:[]}}function bf(e,t){let n=e.failed.find(i=>i.id===t);if(!n)return e;let{lastError:r,...s}=n;return{...e,pending:[...e.pending,s],failed:e.failed.filter(i=>i.id!==t)}}function _f(e,t){return ht(e).includes(t)?e:e.pending.some(n=>n.id===t)?{...e,pending:e.pending.filter(n=>n.id!==t)}:e.failed.some(n=>n.id===t)?{...e,failed:e.failed.filter(n=>n.id!==t)}:e}function xf(e,t,n){return ht(e).includes(t)||!e.pending.some(r=>r.id===t)?e:{...e,pending:e.pending.map(r=>r.id===t?{...r,text:n}:r)}}function wf(e,t,n){let r=ht(e);if(r.includes(t))return e;let s=e.pending.findIndex(g=>g.id===t);if(s===-1)return e;let i=r.length,o=Math.min(Math.max(n,i),e.pending.length-1);if(o===s)return e;let a=[...e.pending],[p]=a.splice(s,1);return a.splice(o,0,p),{...e,pending:a}}var Pd={thinking:!1,toolDetails:!0,assistantMetadata:!0};function lS(e){return e&&e.charAt(0).toUpperCase()+e.slice(1)}function uS(e){let t=e/1e3;if(t<60)return`${t.toFixed(1)}s`;let n=Math.floor(t/60),r=t%60;return`${n}m ${r.toFixed(0)}s`}function pS(e,t){if(e.type==="text"&&!e.synthetic)return`${e.text??""}
|
|
22
22
|
|
|
23
23
|
`;if(e.type==="reasoning")return t.thinking?`> _Thinking:_
|