@inkeep/open-knowledge 0.20.0-beta.7 → 0.20.0-beta.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/assets/skills/discovery/SKILL.md +1 -1
- package/dist/assets/skills/project/SKILL.md +1 -1
- package/dist/cli.mjs +9 -9
- package/dist/constants-guHl6645.mjs +2 -0
- package/dist/{dist-BD4HwRwv.mjs → dist-CX2NKvL3.mjs} +5 -5
- package/dist/{dist-C7UX8Qzt.mjs → dist-n9uYOrGl.mjs} +1 -1
- package/dist/{gh-detect-BDIdc7oG.mjs → gh-detect-D4j_2KZA.mjs} +2 -2
- package/dist/index.mjs +1 -1
- package/dist/{init-tXC9WSsK.mjs → init-CMfDQGkl.mjs} +4 -4
- package/dist/init-xPihugg8.mjs +1 -0
- package/dist/loader-C8nqTo1Q.mjs +1 -0
- package/dist/{loader-Djfd-Wlm.mjs → loader-C9FLjkmp.mjs} +2 -2
- package/dist/{preview-C6hRCpi4.mjs → preview-D2CQ6yHX.mjs} +2 -2
- package/dist/preview-DVTHD8sU.mjs +1 -0
- package/dist/public/assets/{ActivityModeContent-Bw1oRtQH.js → ActivityModeContent-DbFWb8AO.js} +1 -1
- package/dist/public/assets/{DocumentContext-o-LUu0wz.js → DocumentContext-B2qgy31k.js} +2 -2
- package/dist/public/assets/{GraphPanel-BVt0SfrM.js → GraphPanel-sDi-_TRH.js} +1 -1
- package/dist/public/assets/{ManagedArtifactProperties-D-xwymUR.js → ManagedArtifactProperties-D40g_fzP.js} +1 -1
- package/dist/public/assets/{PropertyPanel-CeeQNbcR.js → PropertyPanel-Ca0E5GKl.js} +1 -1
- package/dist/public/assets/{SettingsDialogBody-wC0Rm8N5.js → SettingsDialogBody-DAgimxsR.js} +2 -2
- package/dist/public/assets/{SkillEditorActions-Y_e1zC_b.js → SkillEditorActions-DKVNhzBj.js} +1 -1
- package/dist/public/assets/{SourceEditor-4ljQqBHw.js → SourceEditor-DxmNPlc5.js} +2 -2
- package/dist/public/assets/{TerminalPanel-C9rmhBG2.js → TerminalPanel-DIRUaDNy.js} +1 -1
- package/dist/public/assets/{config-validation-events-mtT7Nmop.js → config-validation-events-Ct_n4YVx.js} +4 -4
- package/dist/public/assets/dist-BrFh1X3E.js +524 -0
- package/dist/public/assets/{documents-events-DMS5a4By.js → documents-events-keB3Tua2.js} +1 -1
- package/dist/public/assets/index-JZXtAkn1.js +2004 -0
- package/dist/public/assets/{keyboard-shortcuts-DGu1nhPQ.js → keyboard-shortcuts-DWO3dbNP.js} +1 -1
- package/dist/public/assets/{open-managed-artifact-tab-Bvt3X7yV.js → open-managed-artifact-tab-BpWVbrq3.js} +1 -1
- package/dist/public/assets/{prop-types-Cf7ylXsu.js → prop-types-DAdpyyQb.js} +1 -1
- package/dist/public/assets/{selection-context-CFA_dZau.js → selection-context-CvCY4HqN.js} +1 -1
- package/dist/public/assets/{skill-actions-CQ-n4sOB.js → skill-actions-IJVLen8G.js} +1 -1
- package/dist/public/assets/{skills-api-q4V5pwth.js → skills-api-BNk9GDF4.js} +1 -1
- package/dist/public/assets/{target-navigation-intent-CCRb_XMp.js → target-navigation-intent-UQ8it6hJ.js} +1 -1
- package/dist/public/assets/{typing-burst-detector-BfS-xBMY.js → typing-burst-detector-DunF9z9v.js} +2 -2
- package/dist/public/index.html +14 -14
- package/dist/{repair-launch-json-TUK_SdBP.mjs → repair-launch-json-C9KJ4bPN.mjs} +2 -2
- package/dist/{repair-mcp-configs-AXgjVWOZ.mjs → repair-mcp-configs-BtoZ6M_S.mjs} +2 -2
- package/dist/{repair-skills-DSxz7qY4.mjs → repair-skills-B98v58k0.mjs} +2 -2
- package/dist/repair-skills-BnIHtXhN.mjs +1 -0
- package/dist/server-lock-8Lv6A-Xa-Cwb8QI-d.mjs +1 -0
- package/dist/{server-lock-CN2YHwpP-COM23IWb.mjs → server-lock-CN2YHwpP-BhBKViGp.mjs} +114 -114
- package/dist/{src-CjUcbTUv.mjs → src-CThY_5pJ.mjs} +2 -2
- package/dist/{start-D6KVRcwv.mjs → start-Bc4ER1Ku.mjs} +2 -2
- package/dist/start-D8Ns1Flr.mjs +1 -0
- package/dist/{write-project-skill-CHLl9ySs.mjs → write-project-skill-C4u_YHBP.mjs} +2 -2
- package/package.json +1 -1
- package/dist/constants-C1DCSZPa.mjs +0 -2
- package/dist/init-DaBG9Vt5.mjs +0 -1
- package/dist/loader-CpxBkx-l.mjs +0 -1
- package/dist/preview-DmtYPtUD.mjs +0 -1
- package/dist/public/assets/dist-Dst_hB5H.js +0 -524
- package/dist/public/assets/index-BZo7KSQC.js +0 -2004
- package/dist/repair-skills-CLwWZbvZ.mjs +0 -1
- package/dist/server-lock-8Lv6A-Xa-iDqi_bbE.mjs +0 -1
- package/dist/start-DYwAiJfq.mjs +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import{Fi as e,Gt as t,Hi as n,In as r,Y as i,a,c as o,d as s,di as c,dn as l,f as u,g as d,gn as f,h as p,i as m,jn as h,l as g,m as _,n as v,o as y,on as b,p as x,r as S,s as C,t as w,u as T}from"./server-lock-CN2YHwpP-COM23IWb.mjs";import{$ as E,$i as D,$n as O,$r as k,$t as A,A as j,Ai as M,An as N,Ar as P,At as F,B as I,Bi as L,Bn as R,Br as z,Bt as B,C as V,Ci as H,Cn as U,Cr as W,Ct as G,D as K,Di as q,Dn as J,Dr as Y,Dt as X,E as Z,Ei as Q,En as $,Er as ee,Et as te,F as ne,Fi as re,Fn as ie,Fr as ae,Ft as oe,G as se,Gi as ce,Gn as le,Gr as ue,Gt as de,H as fe,Hi as pe,Hn as me,Hr as he,Ht as ge,I as _e,Ii as ve,In as ye,Ir as be,It as xe,J as Se,Ji as Ce,Jn as we,Jr as Te,Jt as Ee,K as De,Ki as Oe,Kn as ke,Kr as Ae,Kt as je,L as Me,Li as Ne,Ln as Pe,Lr as Fe,Lt as Ie,M as Le,Mi as Re,Mn as ze,Mr as Be,Mt as Ve,N as He,Ni as Ue,Nn as We,Nr as Ge,Nt as Ke,O as qe,Oi as Je,On as Ye,Or as Xe,Ot as Ze,P as Qe,Pi as $e,Pn as et,Pr as tt,Pt as nt,Q as rt,Qi as it,Qn as at,Qr as ot,Qt as st,R as ct,Ri as lt,Rn as ut,Rr as dt,Rt as ft,S as pt,Si as mt,Sn as ht,Sr as gt,St as _t,T as vt,Ti as yt,Tn as bt,Tr as xt,Tt as St,U as Ct,Ui as wt,Un as Tt,Ur as Et,Ut as Dt,V as Ot,Vi as kt,Vn as At,Vr as jt,Vt as Mt,W as Nt,Wi as Pt,Wn as Ft,Wr as It,Wt as Lt,X as Rt,Xi as zt,Xn as Bt,Xr as Vt,Xt as Ht,Y as Ut,Yi as Wt,Yn as Gt,Yr as Kt,Yt as qt,Z as Jt,Zi as Yt,Zn as Xt,Zr as Zt,Zt as Qt,_ as $t,_i as en,_n as tn,_r as nn,_t as rn,a as an,ai as on,an as sn,ar as cn,at as ln,b as un,bi as dn,bn as fn,br as pn,bt as mn,c as hn,ci as gn,cn as _n,cr as vn,ct as yn,d as bn,di as xn,dn as Sn,dr as Cn,dt as wn,ea as Tn,ei as En,en as Dn,er as On,et as kn,f as An,fa as jn,fi as Mn,fn as Nn,fr as Pn,ft as Fn,g as In,gi as Ln,gn as Rn,gr as zn,gt as Bn,h as Vn,hi as Hn,hn as Un,hr as Wn,ht as Gn,i as Kn,ii as qn,in as Jn,ir as Yn,it as Xn,j as Zn,ji as Qn,jn as $n,jr as er,jt as tr,k as nr,ki as rr,kn as ir,kr as ar,kt as or,l as sr,li as cr,ln as lr,lr as ur,lt as dr,m as fr,mi as pr,mn as mr,mr as hr,mt as gr,n as _r,ni as vr,nn as yr,nr as br,nt as xr,o as Sr,oi as Cr,on as wr,or as Tr,ot as Er,p as Dr,pa as Or,pi as kr,pn as Ar,pr as jr,pt as Mr,q as Nr,qi as Pr,qn as Fr,qr as Ir,qt as Lr,r as Rr,ri as zr,rn as Br,rr as Vr,rt as Hr,s as Ur,si as Wr,sn as Gr,sr as Kr,st as qr,t as Jr,ti as Yr,tn as Xr,tr as Zr,tt as Qr,u as $r,ui as ei,un as ti,ur as ni,ut as ri,v as ii,vi as ai,vn as oi,vr as si,vt as ci,w as li,wi as ui,wn as di,wr as fi,wt as pi,x as mi,xi as hi,xn as gi,xr as _i,xt as vi,y as yi,yi as bi,yn as xi,yr as Si,yt as Ci,z as wi,zi as Ti,zn as Ei,zr as Di,zt as Oi}from"./dist-BD4HwRwv.mjs";export{Jr as AGENT_ID_MAX_LEN,_r as AGENT_ID_RE,Rr as AGENT_WRITE_ORIGIN,Kn as AgentFocusBroadcaster,an as AgentPresenceBroadcaster,Sr as AgentSessionCapacityError,Ur as AgentSessionManager,hn as AutoStartDisabledError,sr as BUNDLE_IDS,$r as BUNDLE_SCOPE,bn as BUNDLE_SKILL_NAME,An as BacklinkIndex,Dr as CC1Broadcaster,i as CC1_CONTRACT_VERSION,fr as CONFIG_FILENAME,Vn as CONFLICT_MARKER_RE,In as CURSOR_BUNDLE_PATHS_BY_PLATFORM,$t as ConfigSchema,ii as DEFAULT_CHECKPOINT_RETENTION,yi as DEFAULT_EMBEDDINGS_DIMENSIONS,un as DEFAULT_PACK_ID,mi as EMBEDDINGS_API_KEY_ENV,pt as FILE_SYSTEM_WRITER,V as FILE_WATCHER_ORIGIN,li as FileEmbeddingsBackend,vt as GIT_PREFLIGHT_FAIL_SPAN_NAME,Z as GIT_UPSTREAM_WRITER,jn as GitDirAccessError,K as GitNotAvailableError,qe as GitTooOldError,nr as HOCUSPOCUS_AUTH_REJECTION_REASONS,j as HocuspocusAuthRejection,Zn as HocuspocusAuthTokenSchema,Le as INSTALLED_AGENTS_SCHEMES,t as LINEAGE_EPOCH_KEY,He as LIVE_DERIVED_INDEX_DEBOUNCE_MS,Qe as LOG_MD_TEMPLATE,ne as MANAGED_RENAME_ORIGIN,_e as MAX_AGENT_SESSIONS,Me as MCP_CONNECTION_ID_HEADER,b as MCP_SERVER_NAME,ct as MIN_GIT_VERSION,wi as MISSING_OK_CONFIG_MESSAGE,Or as MalformedGitPointerError,I as McpLogger,Ot as MissingOkConfigError,fe as OBSERVER_SYNC_ORIGIN,Ct as OK_OKIGNORE_TEMPLATE,l as ORPHAN_MODES,Nt as PANE_TARGET_TTL_MS,f as PROTOCOL_VERSION,se as PinoLogger,w as ProcessLockCollisionError,De as ProjectGitInitError,Nr as ROLLBACK_ORIGIN,Se as ROOT_GITIGNORE_TEMPLATE,v as RUNTIME_VERSION,Ut as SERVICE_WRITER,Rt as SKILL_INSTALL_EVENTS_FILE_REL,h as SKILL_STATE_TARGETS,Jt as STARTER_FOLDERS,rt as STARTER_FOLDER_FRONTMATTER_FILENAME,E as STARTER_PACKS,kn as STARTER_PACK_IDS,Qr as STARTER_TEMPLATES,xr as STATE_MANIFEST_FILENAME,S as STATE_SCHEMA_VERSION,r as SYSTEM_DOC_NAME,Hr as SeedPrerequisiteError,Xn as SeedRootDirError,m as ServerLockCollisionError,ln as SingleFileNotAFileError,Er as SingleFileNotFoundError,qr as SingleFileNotMarkdownError,yn as StateManifestError,dr as TagIndex,ri as USER_GLOBAL_BUNDLE_IDS,wn as UiLockCollisionError,Fn as __getShowAllWalkStatsForTesting,Mr as __resetShowAllWalkStatsForTesting,a as acquireProcessLock,y as acquireServerLock,gr as acquireUiLock,Gn as applyAgentMarkdownWrite,Bn as applyExternalChange,rn as applySeed,ci as armPaneTarget,Ci as assertCompatibleStateManifest,mn as assertGitAvailable,vi as assertNeverDiskEvent,_t as attachIdleShutdown,G as bootServer,pi as buildAndOpenSkill,St as buildConfigYmlContent,te as buildExecResult,X as buildSkillZip,Ze as buildStarterFolderFrontmatterYaml,or as buildWipTree,F as bundleSkillMdPath,tr as classifyEvents,Ve as classifyFsPath,Ke as clearArmedPaneTarget,nt as clearContributors,oe as clearEmbeddingsKeyFromAllBackends,xe as coercePackId,c as colorFromSeed,Ie as commitUpstreamImport,ft as commitWip,Oi as commitWipFromTree,B as compareSemver,Mt as containsConflictMarkers,ge as contentHash,Dt as contributorCount,Lt as countShadowObjects,de as countStaleAgentWipRefs,je as countWipRefs,Lr as createApiExtension,Ee as createAssetServeMiddleware,qt as createContentFilter,Ht as createContentFilterAsync,Qt as createEmbeddingsSecretStore,st as createEphemeralProjectDir,A as createExternalChangeHandler,Dn as createFileLogger,Xr as createLiveDerivedIndexExtension,yr as createMcpHttpHandler,Br as createOsProbe,Jn as createPersistenceExtension,sn as createServer,wr as createServerObserverExtension,Gr as createStreamingErrorWriter,_n as createTestLogger,lr as describeStoredEmbeddingsKey,ti as detectClaudeDesktopPresence,Sn as detectGit,Nn as detectProjectShape,Ar as emitPreflightFailureSpan,mr as encodeDocName,Un as encodeFolderRoute,Rn as ensureProjectGit,tn as errorResponse,oi as evictStaleTrackerEntries,xi as extractWikiLinksFromMarkdown,fn as fallbackPaths,gi as findEnclosingGitRoot,ht as findEnclosingProjectRoot,U as flushFileLogger,di as formatAuthRejectionWire,bt as formatContributors,$ as formatContributorsFrom,J as formatPackRationale,Ye as gcCheckpointRefs,ir as getCurrentMcpLogger,N as getLocalDir,$n as getLogFilePath,ze as getLogger,We as getLogsDir,et as getMeter,ie as getMetrics,ye as getTracer,Pe as handleCollabSocketError,ut as handleSpawnCursor,Ei as hasGcLogLatch,e as iconFromClientName,R as incrementCollabSocketFilteredError,At as incrementServerObserverFire,me as initContent,Tt as initShadowRepo,Ft as initTelemetry,le as initToleranceTelemetryWriter,ke as installPrettyZodErrors,Fr as installTestLoggers,we as installUserSkill,Gt as isAllowedApiOrigin,Bt as isAllowedWorkspaceHostHeader,Xt as isConfigDoc,at as isHocuspocusAuthRejectionReason,O as isKnownPackId,On as isLinkIndexExcludedDoc,Zr as isLoopbackAddress,br as isManagedArtifactDoc,n as isOrphanMode,Vr as isPairedWriteOrigin,Yn as isPathWithinDir,C as isProcessAlive,cn as isProjectRoot,Tr as isProjectSkillManaged,Kr as isReservedForUserTree,vn as isSelfWrite,ur as isSystemDoc,ni as isToleranceTelemetryEnabled,o as isValidLockPid,Cn as lastKnownHash,Pn as listRescueCheckpoints,jr as listStarterPacks,hr as loadPrincipal,g as lockFilePath,Wn as loggerFactory,zn as logsCurrentPath,nn as logsPreviousPath,si as makeLazyEmbeddingsKeyStore,Si as mountMcpAndApi,pn as normalizeFsPath,_i as packageVersionMajorMinor,gt as parseAuthRejectionWire,W as parseGitVersion,fi as parseHocuspocusAuthToken,xt as parseKeepaliveConnectionId,ee as pathToDocName,Y as planSeed,Xe as prepareSingleFileOpen,ar as readAllTargets,P as readArmedPaneTarget,er as readBranchFromHead,T as readProcessLock,s as readProcessLockDetailed,Be as readProjectLocalSemanticConfig,u as readServerLock,Ge as readServerPackageVersion,tt as readSkillInstallStateSnapshot,ae as readSkillManagement,be as readStateManifest,Fe as readTargetRecordedAt,dt as readTargetVersion,Di as readUiLock,z as reconcile,jt as recordContributor,he as recordSkillInstallEvent,Et as registerAllTools,It as registerWrite,x as releaseProcessLock,_ as releaseServerLock,ue as releaseUiLock,Ae as removeLastKnownHash,Ir as resetMetrics,Te as resolveBundledSkillDir,Kt as resolveContentDir,Vt as resolveCursorBinaryDefault,Zt as resolveCursorSpawnInvocation,ot as resolveLockDir,k as resolvePack,En as resolvePackageVersion,Yr as resolveUiInfo,vr as restoreContributors,zr as restoreLifecycleFromConflictsJson,qn as rewriteMarkdownLinksForDocumentRename,on as rewriteWikiLinksForDocumentRename,Cr as runAuthReposSubprocess,Wr as runAuthStatusSubprocess,gn as runCloneSubprocess,cr as runDeviceFlowSubprocess,ei as runWithMcpLogger,xn as safeContentPath,Mn as safeSubdir,kr as safetyCheckpoint,pr as sanitizeClientName,Hn as saveInMemoryCheckpoint,Ln as saveVersion,en as seedBasenameIndex,ai as serializeError,bi as setActiveSpanAttributes,dn as shadowGit,hi as shutdownTelemetry,mt as skillManagementPath,H as spansCurrentPath,ui as spansPreviousPath,yt as spawnDetached,Q as splitMarkdownBlocks,q as startWatcher,Je as streamingProblemEvent,rr as swapContributors,M as teardownToleranceTelemetryWriter,Qn as toBroadcasterKey,Re as tracedAppendFileSync,Ue as tracedLinkSync,$e as tracedMkdir,re as tracedMkdirSync,ve as tracedRename,Ne as tracedRenameSync,lt as tracedRmSync,Ti as tracedRmdirSync,L as tracedUnlinkSync,kt as tracedWriteFile,pe as tracedWriteFileSync,wt as updateLastKnownHash,p as updateProcessLockPort,d as updateServerLockPort,Pt as updateUiLockPort,ce as validateAgentId,Oe as validateCloneInputs,Pr as validateSkillZip,Ce as withSpan,Wt as withSpanSync,zt as writeRootGitignoreForNewRepo,Yt as writeSkillManagement,it as writeStateManifest,D as writeTargetVersion,Tn as writeTracker};
|
|
1
|
+
import{Fi as e,Gt as t,Hi as n,In as r,Y as i,a,c as o,d as s,di as c,dn as l,f as u,g as d,gn as f,h as p,i as m,jn as h,l as g,m as _,n as v,o as y,on as b,p as x,r as S,s as C,t as w,u as T}from"./server-lock-CN2YHwpP-BhBKViGp.mjs";import{$ as E,$i as D,$n as O,$r as k,$t as A,A as j,Ai as M,An as N,Ar as P,At as F,B as I,Bi as L,Bn as R,Br as z,Bt as B,C as V,Ci as H,Cn as U,Cr as W,Ct as G,D as K,Di as q,Dn as J,Dr as Y,Dt as X,E as Z,Ei as Q,En as $,Er as ee,Et as te,F as ne,Fi as re,Fn as ie,Fr as ae,Ft as oe,G as se,Gi as ce,Gn as le,Gr as ue,Gt as de,H as fe,Hi as pe,Hn as me,Hr as he,Ht as ge,I as _e,Ii as ve,In as ye,Ir as be,It as xe,J as Se,Ji as Ce,Jn as we,Jr as Te,Jt as Ee,K as De,Ki as Oe,Kn as ke,Kr as Ae,Kt as je,L as Me,Li as Ne,Ln as Pe,Lr as Fe,Lt as Ie,M as Le,Mi as Re,Mn as ze,Mr as Be,Mt as Ve,N as He,Ni as Ue,Nn as We,Nr as Ge,Nt as Ke,O as qe,Oi as Je,On as Ye,Or as Xe,Ot as Ze,P as Qe,Pi as $e,Pn as et,Pr as tt,Pt as nt,Q as rt,Qi as it,Qn as at,Qr as ot,Qt as st,R as ct,Ri as lt,Rn as ut,Rr as dt,Rt as ft,S as pt,Si as mt,Sn as ht,Sr as gt,St as _t,T as vt,Ti as yt,Tn as bt,Tr as xt,Tt as St,U as Ct,Ui as wt,Un as Tt,Ur as Et,Ut as Dt,V as Ot,Vi as kt,Vn as At,Vr as jt,Vt as Mt,W as Nt,Wi as Pt,Wn as Ft,Wr as It,Wt as Lt,X as Rt,Xi as zt,Xn as Bt,Xr as Vt,Xt as Ht,Y as Ut,Yi as Wt,Yn as Gt,Yr as Kt,Yt as qt,Z as Jt,Zi as Yt,Zn as Xt,Zr as Zt,Zt as Qt,_ as $t,_i as en,_n as tn,_r as nn,_t as rn,a as an,ai as on,an as sn,ar as cn,at as ln,b as un,bi as dn,bn as fn,br as pn,bt as mn,c as hn,ci as gn,cn as _n,cr as vn,ct as yn,d as bn,di as xn,dn as Sn,dr as Cn,dt as wn,ea as Tn,ei as En,en as Dn,er as On,et as kn,f as An,fa as jn,fi as Mn,fn as Nn,fr as Pn,ft as Fn,g as In,gi as Ln,gn as Rn,gr as zn,gt as Bn,h as Vn,hi as Hn,hn as Un,hr as Wn,ht as Gn,i as Kn,ii as qn,in as Jn,ir as Yn,it as Xn,j as Zn,ji as Qn,jn as $n,jr as er,jt as tr,k as nr,ki as rr,kn as ir,kr as ar,kt as or,l as sr,li as cr,ln as lr,lr as ur,lt as dr,m as fr,mi as pr,mn as mr,mr as hr,mt as gr,n as _r,ni as vr,nn as yr,nr as br,nt as xr,o as Sr,oi as Cr,on as wr,or as Tr,ot as Er,p as Dr,pa as Or,pi as kr,pn as Ar,pr as jr,pt as Mr,q as Nr,qi as Pr,qn as Fr,qr as Ir,qt as Lr,r as Rr,ri as zr,rn as Br,rr as Vr,rt as Hr,s as Ur,si as Wr,sn as Gr,sr as Kr,st as qr,t as Jr,ti as Yr,tn as Xr,tr as Zr,tt as Qr,u as $r,ui as ei,un as ti,ur as ni,ut as ri,v as ii,vi as ai,vn as oi,vr as si,vt as ci,w as li,wi as ui,wn as di,wr as fi,wt as pi,x as mi,xi as hi,xn as gi,xr as _i,xt as vi,y as yi,yi as bi,yn as xi,yr as Si,yt as Ci,z as wi,zi as Ti,zn as Ei,zr as Di,zt as Oi}from"./dist-CX2NKvL3.mjs";export{Jr as AGENT_ID_MAX_LEN,_r as AGENT_ID_RE,Rr as AGENT_WRITE_ORIGIN,Kn as AgentFocusBroadcaster,an as AgentPresenceBroadcaster,Sr as AgentSessionCapacityError,Ur as AgentSessionManager,hn as AutoStartDisabledError,sr as BUNDLE_IDS,$r as BUNDLE_SCOPE,bn as BUNDLE_SKILL_NAME,An as BacklinkIndex,Dr as CC1Broadcaster,i as CC1_CONTRACT_VERSION,fr as CONFIG_FILENAME,Vn as CONFLICT_MARKER_RE,In as CURSOR_BUNDLE_PATHS_BY_PLATFORM,$t as ConfigSchema,ii as DEFAULT_CHECKPOINT_RETENTION,yi as DEFAULT_EMBEDDINGS_DIMENSIONS,un as DEFAULT_PACK_ID,mi as EMBEDDINGS_API_KEY_ENV,pt as FILE_SYSTEM_WRITER,V as FILE_WATCHER_ORIGIN,li as FileEmbeddingsBackend,vt as GIT_PREFLIGHT_FAIL_SPAN_NAME,Z as GIT_UPSTREAM_WRITER,jn as GitDirAccessError,K as GitNotAvailableError,qe as GitTooOldError,nr as HOCUSPOCUS_AUTH_REJECTION_REASONS,j as HocuspocusAuthRejection,Zn as HocuspocusAuthTokenSchema,Le as INSTALLED_AGENTS_SCHEMES,t as LINEAGE_EPOCH_KEY,He as LIVE_DERIVED_INDEX_DEBOUNCE_MS,Qe as LOG_MD_TEMPLATE,ne as MANAGED_RENAME_ORIGIN,_e as MAX_AGENT_SESSIONS,Me as MCP_CONNECTION_ID_HEADER,b as MCP_SERVER_NAME,ct as MIN_GIT_VERSION,wi as MISSING_OK_CONFIG_MESSAGE,Or as MalformedGitPointerError,I as McpLogger,Ot as MissingOkConfigError,fe as OBSERVER_SYNC_ORIGIN,Ct as OK_OKIGNORE_TEMPLATE,l as ORPHAN_MODES,Nt as PANE_TARGET_TTL_MS,f as PROTOCOL_VERSION,se as PinoLogger,w as ProcessLockCollisionError,De as ProjectGitInitError,Nr as ROLLBACK_ORIGIN,Se as ROOT_GITIGNORE_TEMPLATE,v as RUNTIME_VERSION,Ut as SERVICE_WRITER,Rt as SKILL_INSTALL_EVENTS_FILE_REL,h as SKILL_STATE_TARGETS,Jt as STARTER_FOLDERS,rt as STARTER_FOLDER_FRONTMATTER_FILENAME,E as STARTER_PACKS,kn as STARTER_PACK_IDS,Qr as STARTER_TEMPLATES,xr as STATE_MANIFEST_FILENAME,S as STATE_SCHEMA_VERSION,r as SYSTEM_DOC_NAME,Hr as SeedPrerequisiteError,Xn as SeedRootDirError,m as ServerLockCollisionError,ln as SingleFileNotAFileError,Er as SingleFileNotFoundError,qr as SingleFileNotMarkdownError,yn as StateManifestError,dr as TagIndex,ri as USER_GLOBAL_BUNDLE_IDS,wn as UiLockCollisionError,Fn as __getShowAllWalkStatsForTesting,Mr as __resetShowAllWalkStatsForTesting,a as acquireProcessLock,y as acquireServerLock,gr as acquireUiLock,Gn as applyAgentMarkdownWrite,Bn as applyExternalChange,rn as applySeed,ci as armPaneTarget,Ci as assertCompatibleStateManifest,mn as assertGitAvailable,vi as assertNeverDiskEvent,_t as attachIdleShutdown,G as bootServer,pi as buildAndOpenSkill,St as buildConfigYmlContent,te as buildExecResult,X as buildSkillZip,Ze as buildStarterFolderFrontmatterYaml,or as buildWipTree,F as bundleSkillMdPath,tr as classifyEvents,Ve as classifyFsPath,Ke as clearArmedPaneTarget,nt as clearContributors,oe as clearEmbeddingsKeyFromAllBackends,xe as coercePackId,c as colorFromSeed,Ie as commitUpstreamImport,ft as commitWip,Oi as commitWipFromTree,B as compareSemver,Mt as containsConflictMarkers,ge as contentHash,Dt as contributorCount,Lt as countShadowObjects,de as countStaleAgentWipRefs,je as countWipRefs,Lr as createApiExtension,Ee as createAssetServeMiddleware,qt as createContentFilter,Ht as createContentFilterAsync,Qt as createEmbeddingsSecretStore,st as createEphemeralProjectDir,A as createExternalChangeHandler,Dn as createFileLogger,Xr as createLiveDerivedIndexExtension,yr as createMcpHttpHandler,Br as createOsProbe,Jn as createPersistenceExtension,sn as createServer,wr as createServerObserverExtension,Gr as createStreamingErrorWriter,_n as createTestLogger,lr as describeStoredEmbeddingsKey,ti as detectClaudeDesktopPresence,Sn as detectGit,Nn as detectProjectShape,Ar as emitPreflightFailureSpan,mr as encodeDocName,Un as encodeFolderRoute,Rn as ensureProjectGit,tn as errorResponse,oi as evictStaleTrackerEntries,xi as extractWikiLinksFromMarkdown,fn as fallbackPaths,gi as findEnclosingGitRoot,ht as findEnclosingProjectRoot,U as flushFileLogger,di as formatAuthRejectionWire,bt as formatContributors,$ as formatContributorsFrom,J as formatPackRationale,Ye as gcCheckpointRefs,ir as getCurrentMcpLogger,N as getLocalDir,$n as getLogFilePath,ze as getLogger,We as getLogsDir,et as getMeter,ie as getMetrics,ye as getTracer,Pe as handleCollabSocketError,ut as handleSpawnCursor,Ei as hasGcLogLatch,e as iconFromClientName,R as incrementCollabSocketFilteredError,At as incrementServerObserverFire,me as initContent,Tt as initShadowRepo,Ft as initTelemetry,le as initToleranceTelemetryWriter,ke as installPrettyZodErrors,Fr as installTestLoggers,we as installUserSkill,Gt as isAllowedApiOrigin,Bt as isAllowedWorkspaceHostHeader,Xt as isConfigDoc,at as isHocuspocusAuthRejectionReason,O as isKnownPackId,On as isLinkIndexExcludedDoc,Zr as isLoopbackAddress,br as isManagedArtifactDoc,n as isOrphanMode,Vr as isPairedWriteOrigin,Yn as isPathWithinDir,C as isProcessAlive,cn as isProjectRoot,Tr as isProjectSkillManaged,Kr as isReservedForUserTree,vn as isSelfWrite,ur as isSystemDoc,ni as isToleranceTelemetryEnabled,o as isValidLockPid,Cn as lastKnownHash,Pn as listRescueCheckpoints,jr as listStarterPacks,hr as loadPrincipal,g as lockFilePath,Wn as loggerFactory,zn as logsCurrentPath,nn as logsPreviousPath,si as makeLazyEmbeddingsKeyStore,Si as mountMcpAndApi,pn as normalizeFsPath,_i as packageVersionMajorMinor,gt as parseAuthRejectionWire,W as parseGitVersion,fi as parseHocuspocusAuthToken,xt as parseKeepaliveConnectionId,ee as pathToDocName,Y as planSeed,Xe as prepareSingleFileOpen,ar as readAllTargets,P as readArmedPaneTarget,er as readBranchFromHead,T as readProcessLock,s as readProcessLockDetailed,Be as readProjectLocalSemanticConfig,u as readServerLock,Ge as readServerPackageVersion,tt as readSkillInstallStateSnapshot,ae as readSkillManagement,be as readStateManifest,Fe as readTargetRecordedAt,dt as readTargetVersion,Di as readUiLock,z as reconcile,jt as recordContributor,he as recordSkillInstallEvent,Et as registerAllTools,It as registerWrite,x as releaseProcessLock,_ as releaseServerLock,ue as releaseUiLock,Ae as removeLastKnownHash,Ir as resetMetrics,Te as resolveBundledSkillDir,Kt as resolveContentDir,Vt as resolveCursorBinaryDefault,Zt as resolveCursorSpawnInvocation,ot as resolveLockDir,k as resolvePack,En as resolvePackageVersion,Yr as resolveUiInfo,vr as restoreContributors,zr as restoreLifecycleFromConflictsJson,qn as rewriteMarkdownLinksForDocumentRename,on as rewriteWikiLinksForDocumentRename,Cr as runAuthReposSubprocess,Wr as runAuthStatusSubprocess,gn as runCloneSubprocess,cr as runDeviceFlowSubprocess,ei as runWithMcpLogger,xn as safeContentPath,Mn as safeSubdir,kr as safetyCheckpoint,pr as sanitizeClientName,Hn as saveInMemoryCheckpoint,Ln as saveVersion,en as seedBasenameIndex,ai as serializeError,bi as setActiveSpanAttributes,dn as shadowGit,hi as shutdownTelemetry,mt as skillManagementPath,H as spansCurrentPath,ui as spansPreviousPath,yt as spawnDetached,Q as splitMarkdownBlocks,q as startWatcher,Je as streamingProblemEvent,rr as swapContributors,M as teardownToleranceTelemetryWriter,Qn as toBroadcasterKey,Re as tracedAppendFileSync,Ue as tracedLinkSync,$e as tracedMkdir,re as tracedMkdirSync,ve as tracedRename,Ne as tracedRenameSync,lt as tracedRmSync,Ti as tracedRmdirSync,L as tracedUnlinkSync,kt as tracedWriteFile,pe as tracedWriteFileSync,wt as updateLastKnownHash,p as updateProcessLockPort,d as updateServerLockPort,Pt as updateUiLockPort,ce as validateAgentId,Oe as validateCloneInputs,Pr as validateSkillZip,Ce as withSpan,Wt as withSpanSync,zt as writeRootGitignoreForNewRepo,Yt as writeSkillManagement,it as writeStateManifest,D as writeTargetVersion,Tn as writeTracker};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import{No as e}from"./server-lock-CN2YHwpP-
|
|
1
|
+
import{No as e}from"./server-lock-CN2YHwpP-BhBKViGp.mjs";import{execFileSync as t}from"node:child_process";import{existsSync as n,mkdirSync as r,readFileSync as i,writeFileSync as a}from"node:fs";import{dirname as o,join as s}from"node:path";import{homedir as c}from"node:os";var l=e();const u=`open-knowledge`;function d(e){try{e()}catch{}}var f=class{backend=`keyring`;constructor(e){this.onKeychainRead=e}async get(e){let{Entry:t}=await import(`@napi-rs/keyring`),n;try{n=new t(u,e).getPassword()}catch(t){return d(()=>this.onKeychainRead?.({kind:`read-error`,host:e,error:t instanceof Error?t.name:`unknown`})),null}if(n==null)return d(()=>this.onKeychainRead?.({kind:`absent`,host:e})),null;try{return JSON.parse(n)}catch{return d(()=>this.onKeychainRead?.({kind:`corrupt-entry`,host:e,error:`corrupt-entry`})),null}}async set(e,t,n,r){let{Entry:i}=await import(`@napi-rs/keyring`),a=new i(u,e),o={login:t,token:n,...r};a.setPassword(JSON.stringify(o))}async clear(e){let{Entry:t}=await import(`@napi-rs/keyring`);try{new t(u,e).deletePassword()}catch{}}},p=class{backend=`file`;authFile;constructor(e){this.authFile=e??s(c(),`.ok`,`auth.yml`)}read(){if(!n(this.authFile))return{};try{return(0,l.parse)(i(this.authFile,`utf-8`))??{}}catch(e){let t=e instanceof Error?e.message:`unknown error`;return process.stderr.write(`[auth] Failed to parse ${this.authFile}: ${t}. Starting with empty credentials.\n`),{}}}write(e){let t=o(this.authFile);n(t)||r(t,{recursive:!0,mode:448}),a(this.authFile,(0,l.stringify)(e),{mode:384})}async get(e){return this.read()[e]??null}async set(e,t,n,r){let i=this.read();i[e]={login:t,token:n,...r},this.write(i)}async clear(e){let t=this.read();delete t[e],this.write(t)}},m=class{backend=`keyring`;constructor(e,t){this.keychain=e,this.file=t}async get(e){let t=await this.keychain.get(e);if(t!=null)return t;let n=await this.file.get(e);if(n==null)return null;try{await this.keychain.set(e,n.login,n.token,{gitProtocol:n.gitProtocol,name:n.name,email:n.email}),await this.file.clear(e),process.stderr.write(`[auth] migrated ${e} credential from ~/.ok/auth.yml to the OS keychain\n`)}catch{}return n}set(e,t,n,r){return this.keychain.set(e,t,n,r)}async clear(e){await this.keychain.clear(e),await this.file.get(e)!=null&&await this.file.clear(e)}};async function h(e,t){try{let{Entry:n}=await import(`@napi-rs/keyring`);return new n(u,`__probe__`),process.stderr.write(`[auth] token storage: OS keychain
|
|
2
2
|
`),d(()=>t?.onBackendSelected?.({backend:`keyring`})),new m(new f(t?.onKeychainRead),new p(e))}catch(n){let r=n instanceof Error?`${n.name}: ${n.message}`:String(n);return process.stderr.write(`[auth] token storage: file (~/.ok/auth.yml) — OS keychain unavailable: ${r}\n`),d(()=>t?.onBackendSelected?.({backend:`file`,reason:r})),new p(e)}}function g(e){let t=null;return function(){if(t)return t;let n=2e3;return t=(async()=>{let t=null,r=new Promise(r=>{t=setTimeout(()=>{process.stderr.write(`[auth] token storage: keyring init exceeded ${n}ms; falling back to file (~/.ok/auth.yml)\n`),r(new p(e))},n)});try{return await Promise.race([h(e),r])}catch{return new p(e)}finally{t!==null&&clearTimeout(t)}})(),t}}function _(e){let t=g(e);return{async get(e){let n=await(await t()).get(e);return n===null?null:{token:n.token}}}}function v(e){let t=g(e);return{backend:`file`,async get(e){return(await t()).get(e)},async set(e,n,r,i){return(await t()).set(e,n,r,i)},async clear(e){return(await t()).clear(e)}}}async function y(e,t){let n=[],r=new p(t);await r.get(e)!=null&&(await r.clear(e),n.push(`file`));try{let{Entry:t}=await import(`@napi-rs/keyring`);new t(u,`__probe__`);let r=new f;await r.get(e)!=null&&(await r.clear(e),n.push(`keychain`))}catch{}return{touched:n}}const b=[`/opt/homebrew/bin/gh`,`/usr/local/bin/gh`,`/opt/local/bin/gh`,`/snap/bin/gh`,`/usr/bin/gh`];function x(e,r={}){let i=r._exec??t,a=r._fileExists??n,o=[`auth`,`token`,...e?[`--hostname`,e]:[]],s=[`gh`,...b.filter(a)];for(let e of s)try{let t=i(e,o,{encoding:`utf-8`,stdio:[`ignore`,`pipe`,`pipe`],timeout:5e3}).toString().trim();if(t.length>0)return{available:!0,token:t}}catch{}return{available:!1}}export{v as a,_ as i,y as n,h as r,x as t};
|
|
3
|
-
//# sourceMappingURL=gh-detect-
|
|
3
|
+
//# sourceMappingURL=gh-detect-D4j_2KZA.mjs.map
|
package/dist/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{i as e,r as t,t as n}from"./gh-detect-
|
|
1
|
+
import{i as e,r as t,t as n}from"./gh-detect-D4j_2KZA.mjs";import{C as r,E as i,S as a,T as o,_ as s,b as c,d as l,g as u,h as d,i as f,o as p,r as m,s as h,t as g,w as _,x as v,y}from"./init-CMfDQGkl.mjs";import{d as b,f as x,m as S,n as C,p as w,r as T,t as E}from"./src-CThY_5pJ.mjs";import{a as D,c as O,l as k,o as A,r as j,s as M,t as N,u as P}from"./write-project-skill-C4u_YHBP.mjs";import{n as F}from"./loader-C9FLjkmp.mjs";import{n as I}from"./preview-D2CQ6yHX.mjs";import{n as L,t as R}from"./mcp-migrate-event-D0NrGjvc.mjs";export{j as ALL_EDITOR_IDS,D as EDITOR_LABELS,A as EDITOR_TARGETS,M as HOSTS_WITH_USER_SKILL_DIR,g as LAUNCH_CONFIG_NAME,m as LAUNCH_UI_CHAIN_SENTINEL,f as LAUNCH_UI_CHAIN_V1,c as addOkPathsToGitExclude,N as assertProjectPathSafe,O as buildManagedServerEntry,R as buildMcpConfigMigrateEvent,p as classifyExistingMcpEntry,t as createTokenStore,n as detectGh,h as detectInstalledEditors,v as formatTrackedRemediation,a as getExcludedOkPaths,r as getOkArtifactPaths,k as isEntryUpToDate,P as isOwnManagedEntry,F as loadConfig,e as makeLazyProbeTokenStore,b as parseGitHubBlobUrl,x as parseGitHubShareUrl,w as parseGitHubTreeUrl,S as parseGitUrl,I as previewContent,_ as probeTrackedOkPaths,l as readExistingMcpEntry,o as readSharingMode,i as removeOkPathsFromGitExclude,y as resolveProjectRoot,T as runStop,d as scaffoldLaunchJson,L as truncatePriorEntry,C as validateLocalFolderForShare,u as writeEditorMcpConfig,E as writeProjectAiIntegrations,s as writeUserMcpConfigs};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{a as e,s as t,t as n}from"./chunk-C94x7I9S.mjs";import{r,t as i}from"./esm-BLMtE3s6.mjs";import{Bt as a,Tt as o,Xi as s,bn as c,wt as l,y as u,yi as d,zt as f}from"./server-lock-CN2YHwpP-COM23IWb.mjs";import{Hn as p,Jn as m,K as h,Xi as g,Xn as _,Yn as v,ar as y,gn as b,ha as x,sa as S,tr as C,ua as w}from"./dist-BD4HwRwv.mjs";import"./constants-C1DCSZPa.mjs";import{d as ee,f as T,n as te,o as E,r as ne,t as re}from"./write-project-skill-CHLl9ySs.mjs";import{t as D}from"./is-object-Cg453afR.mjs";import{i as O,o as k,r as A,s as j,t as M}from"./colors-8SzMRIVy.mjs";import{t as ie}from"./preview-C6hRCpi4.mjs";import{execFileSync as ae}from"node:child_process";import{existsSync as N,mkdirSync as P,readFileSync as F,realpathSync as oe,writeFileSync as I}from"node:fs";import se,{dirname as L,isAbsolute as ce,join as R,relative as z,resolve as le,sep as ue}from"node:path";import B from"node:process";import{homedir as de}from"node:os";import{randomUUID as fe}from"node:crypto";import{stripVTControlCharacters as pe,styleText as V}from"node:util";import{AsyncLocalStorage as me,AsyncResource as H}from"node:async_hooks";import{createServer as he,request as ge}from"node:http";import*as _e from"node:readline";import{connect as ve}from"node:net";function ye(){return B.platform.startsWith(`win`)?!!B.env.CI||!!B.env.WT_SESSION||!!B.env.TERMINUS_SUBLIME||B.env.ConEmuTask===`{cmd::Cmder}`||B.env.TERM_PROGRAM===`Terminus-Sublime`||B.env.TERM_PROGRAM===`vscode`||B.env.TERM===`xterm-256color`||B.env.TERM===`alacritty`||B.env.TERMINAL_EMULATOR===`JetBrains-JediTerm`:B.env.TERM!==`linux`}const be={circleQuestionMark:`(?)`,questionMarkPrefix:`(?)`,square:`█`,squareDarkShade:`▓`,squareMediumShade:`▒`,squareLightShade:`░`,squareTop:`▀`,squareBottom:`▄`,squareLeft:`▌`,squareRight:`▐`,squareCenter:`■`,bullet:`●`,dot:`․`,ellipsis:`…`,pointerSmall:`›`,triangleUp:`▲`,triangleUpSmall:`▴`,triangleDown:`▼`,triangleDownSmall:`▾`,triangleLeftSmall:`◂`,triangleRightSmall:`▸`,home:`⌂`,heart:`♥`,musicNote:`♪`,musicNoteBeamed:`♫`,arrowUp:`↑`,arrowDown:`↓`,arrowLeft:`←`,arrowRight:`→`,arrowLeftRight:`↔`,arrowUpDown:`↕`,almostEqual:`≈`,notEqual:`≠`,lessOrEqual:`≤`,greaterOrEqual:`≥`,identical:`≡`,infinity:`∞`,subscriptZero:`₀`,subscriptOne:`₁`,subscriptTwo:`₂`,subscriptThree:`₃`,subscriptFour:`₄`,subscriptFive:`₅`,subscriptSix:`₆`,subscriptSeven:`₇`,subscriptEight:`₈`,subscriptNine:`₉`,oneHalf:`½`,oneThird:`⅓`,oneQuarter:`¼`,oneFifth:`⅕`,oneSixth:`⅙`,oneEighth:`⅛`,twoThirds:`⅔`,twoFifths:`⅖`,threeQuarters:`¾`,threeFifths:`⅗`,threeEighths:`⅜`,fourFifths:`⅘`,fiveSixths:`⅚`,fiveEighths:`⅝`,sevenEighths:`⅞`,line:`─`,lineBold:`━`,lineDouble:`═`,lineDashed0:`┄`,lineDashed1:`┅`,lineDashed2:`┈`,lineDashed3:`┉`,lineDashed4:`╌`,lineDashed5:`╍`,lineDashed6:`╴`,lineDashed7:`╶`,lineDashed8:`╸`,lineDashed9:`╺`,lineDashed10:`╼`,lineDashed11:`╾`,lineDashed12:`−`,lineDashed13:`–`,lineDashed14:`‐`,lineDashed15:`⁃`,lineVertical:`│`,lineVerticalBold:`┃`,lineVerticalDouble:`║`,lineVerticalDashed0:`┆`,lineVerticalDashed1:`┇`,lineVerticalDashed2:`┊`,lineVerticalDashed3:`┋`,lineVerticalDashed4:`╎`,lineVerticalDashed5:`╏`,lineVerticalDashed6:`╵`,lineVerticalDashed7:`╷`,lineVerticalDashed8:`╹`,lineVerticalDashed9:`╻`,lineVerticalDashed10:`╽`,lineVerticalDashed11:`╿`,lineDownLeft:`┐`,lineDownLeftArc:`╮`,lineDownBoldLeftBold:`┓`,lineDownBoldLeft:`┒`,lineDownLeftBold:`┑`,lineDownDoubleLeftDouble:`╗`,lineDownDoubleLeft:`╖`,lineDownLeftDouble:`╕`,lineDownRight:`┌`,lineDownRightArc:`╭`,lineDownBoldRightBold:`┏`,lineDownBoldRight:`┎`,lineDownRightBold:`┍`,lineDownDoubleRightDouble:`╔`,lineDownDoubleRight:`╓`,lineDownRightDouble:`╒`,lineUpLeft:`┘`,lineUpLeftArc:`╯`,lineUpBoldLeftBold:`┛`,lineUpBoldLeft:`┚`,lineUpLeftBold:`┙`,lineUpDoubleLeftDouble:`╝`,lineUpDoubleLeft:`╜`,lineUpLeftDouble:`╛`,lineUpRight:`└`,lineUpRightArc:`╰`,lineUpBoldRightBold:`┗`,lineUpBoldRight:`┖`,lineUpRightBold:`┕`,lineUpDoubleRightDouble:`╚`,lineUpDoubleRight:`╙`,lineUpRightDouble:`╘`,lineUpDownLeft:`┤`,lineUpBoldDownBoldLeftBold:`┫`,lineUpBoldDownBoldLeft:`┨`,lineUpDownLeftBold:`┥`,lineUpBoldDownLeftBold:`┩`,lineUpDownBoldLeftBold:`┪`,lineUpDownBoldLeft:`┧`,lineUpBoldDownLeft:`┦`,lineUpDoubleDownDoubleLeftDouble:`╣`,lineUpDoubleDownDoubleLeft:`╢`,lineUpDownLeftDouble:`╡`,lineUpDownRight:`├`,lineUpBoldDownBoldRightBold:`┣`,lineUpBoldDownBoldRight:`┠`,lineUpDownRightBold:`┝`,lineUpBoldDownRightBold:`┡`,lineUpDownBoldRightBold:`┢`,lineUpDownBoldRight:`┟`,lineUpBoldDownRight:`┞`,lineUpDoubleDownDoubleRightDouble:`╠`,lineUpDoubleDownDoubleRight:`╟`,lineUpDownRightDouble:`╞`,lineDownLeftRight:`┬`,lineDownBoldLeftBoldRightBold:`┳`,lineDownLeftBoldRightBold:`┯`,lineDownBoldLeftRight:`┰`,lineDownBoldLeftBoldRight:`┱`,lineDownBoldLeftRightBold:`┲`,lineDownLeftRightBold:`┮`,lineDownLeftBoldRight:`┭`,lineDownDoubleLeftDoubleRightDouble:`╦`,lineDownDoubleLeftRight:`╥`,lineDownLeftDoubleRightDouble:`╤`,lineUpLeftRight:`┴`,lineUpBoldLeftBoldRightBold:`┻`,lineUpLeftBoldRightBold:`┷`,lineUpBoldLeftRight:`┸`,lineUpBoldLeftBoldRight:`┹`,lineUpBoldLeftRightBold:`┺`,lineUpLeftRightBold:`┶`,lineUpLeftBoldRight:`┵`,lineUpDoubleLeftDoubleRightDouble:`╩`,lineUpDoubleLeftRight:`╨`,lineUpLeftDoubleRightDouble:`╧`,lineUpDownLeftRight:`┼`,lineUpBoldDownBoldLeftBoldRightBold:`╋`,lineUpDownBoldLeftBoldRightBold:`╈`,lineUpBoldDownLeftBoldRightBold:`╇`,lineUpBoldDownBoldLeftRightBold:`╊`,lineUpBoldDownBoldLeftBoldRight:`╉`,lineUpBoldDownLeftRight:`╀`,lineUpDownBoldLeftRight:`╁`,lineUpDownLeftBoldRight:`┽`,lineUpDownLeftRightBold:`┾`,lineUpBoldDownBoldLeftRight:`╂`,lineUpDownLeftBoldRightBold:`┿`,lineUpBoldDownLeftBoldRight:`╃`,lineUpBoldDownLeftRightBold:`╄`,lineUpDownBoldLeftBoldRight:`╅`,lineUpDownBoldLeftRightBold:`╆`,lineUpDoubleDownDoubleLeftDoubleRightDouble:`╬`,lineUpDoubleDownDoubleLeftRight:`╫`,lineUpDownLeftDoubleRightDouble:`╪`,lineCross:`╳`,lineBackslash:`╲`,lineSlash:`╱`},xe={tick:`✔`,info:`ℹ`,warning:`⚠`,cross:`✘`,squareSmall:`◻`,squareSmallFilled:`◼`,circle:`◯`,circleFilled:`◉`,circleDotted:`◌`,circleDouble:`◎`,circleCircle:`ⓞ`,circleCross:`ⓧ`,circlePipe:`Ⓘ`,radioOn:`◉`,radioOff:`◯`,checkboxOn:`☒`,checkboxOff:`☐`,checkboxCircleOn:`ⓧ`,checkboxCircleOff:`Ⓘ`,pointer:`❯`,triangleUpOutline:`△`,triangleLeft:`◀`,triangleRight:`▶`,lozenge:`◆`,lozengeOutline:`◇`,hamburger:`☰`,smiley:`㋡`,mustache:`෴`,star:`★`,play:`▶`,nodejs:`⬢`,oneSeventh:`⅐`,oneNinth:`⅑`,oneTenth:`⅒`},Se={tick:`√`,info:`i`,warning:`‼`,cross:`×`,squareSmall:`□`,squareSmallFilled:`■`,circle:`( )`,circleFilled:`(*)`,circleDotted:`( )`,circleDouble:`( )`,circleCircle:`(○)`,circleCross:`(×)`,circlePipe:`(│)`,radioOn:`(*)`,radioOff:`( )`,checkboxOn:`[×]`,checkboxOff:`[ ]`,checkboxCircleOn:`(×)`,checkboxCircleOff:`( )`,pointer:`>`,triangleUpOutline:`∆`,triangleLeft:`◄`,triangleRight:`►`,lozenge:`♦`,lozengeOutline:`◊`,hamburger:`≡`,smiley:`☺`,mustache:`┌─┐`,star:`✶`,play:`►`,nodejs:`♦`,oneSeventh:`1/7`,oneNinth:`1/9`,oneTenth:`1/10`},Ce={...be,...xe},we={...be,...Se},U=ye()?Ce:we;Object.entries(xe);var Te=n(((t,n)=>{n.exports=i;function r(t){let n={defaultWidth:0,output:process.stdout,tty:e(`tty`)};return t?(Object.keys(n).forEach(function(e){t[e]||(t[e]=n[e])}),t):n}function i(e){let t=r(e);if(t.output.getWindowSize)return t.output.getWindowSize()[0]||t.defaultWidth;if(t.tty.getWindowSize)return t.tty.getWindowSize()[1]||t.defaultWidth;if(t.output.columns)return t.output.columns;if(process.env.CLI_WIDTH){let e=parseInt(process.env.CLI_WIDTH,10);if(!isNaN(e)&&e!==0)return e}return t.defaultWidth}}));const Ee=(()=>{let e=/[\uD800-\uDBFF][\uDC00-\uDFFF]/g;return t=>{let n=0;for(e.lastIndex=0;e.test(t);)n+=1;return t.length-n}})(),De=e=>e===12288||e>=65281&&e<=65376||e>=65504&&e<=65510,Oe=e=>e===8987||e===9001||e>=12272&&e<=12287||e>=12289&&e<=12350||e>=12441&&e<=12543||e>=12549&&e<=12591||e>=12593&&e<=12686||e>=12688&&e<=12771||e>=12783&&e<=12830||e>=12832&&e<=12871||e>=12880&&e<=19903||e>=65040&&e<=65049||e>=65072&&e<=65106||e>=65108&&e<=65126||e>=65128&&e<=65131||e>=127488&&e<=127490||e>=127504&&e<=127547||e>=127552&&e<=127560||e>=131072&&e<=196605||e>=196608&&e<=262141,ke=/[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]|\u001b\]8;[^;]*;.*?(?:\u0007|\u001b\u005c)/y,Ae=/[\x00-\x08\x0A-\x1F\x7F-\x9F]{1,1000}/y,je=/(?:(?![\uFF61-\uFF9F\uFF00-\uFFEF])[\p{Script=Han}\p{Script=Hiragana}\p{Script=Katakana}\p{Script=Hangul}\p{Script=Tangut}]){1,1000}/uy,Me=/\t{1,1000}/y,Ne=/[\u{1F1E6}-\u{1F1FF}]{2}|\u{1F3F4}[\u{E0061}-\u{E007A}]{2}[\u{E0030}-\u{E0039}\u{E0061}-\u{E007A}]{1,3}\u{E007F}|(?:\p{Emoji}\uFE0F\u20E3?|\p{Emoji_Modifier_Base}\p{Emoji_Modifier}?|\p{Emoji_Presentation})(?:\u200D(?:\p{Emoji_Modifier_Base}\p{Emoji_Modifier}?|\p{Emoji_Presentation}|\p{Emoji}\uFE0F\u20E3?))*/uy,Pe=/(?:[\x20-\x7E\xA0-\xFF](?!\uFE0F)){1,1000}/y,Fe=/\p{M}+/gu,Ie={limit:1/0,ellipsis:``},Le=(e,t={},n={})=>{let r=t.limit??1/0,i=t.ellipsis??``,a=t?.ellipsisWidth??(i?Le(i,Ie,n).width:0),o=n.controlWidth??0,s=n.tabWidth??8,c=n.emojiWidth??2,l=n.regularWidth??1,u=n.wideWidth??2,d=[[Pe,l],[ke,0],[Ae,o],[Me,s],[Ne,c],[je,u]],f=0,p=0,m=e.length,h=0,g=!1,_=m,v=Math.max(0,r-a),y=0,b=0,x=0,S=0;outer:for(;;){if(b>y||p>=m&&p>f){let t=e.slice(y,b)||e.slice(f,p);h=0;for(let e of t.replaceAll(Fe,``)){let t=e.codePointAt(0)||0;if(S=De(t)?2:Oe(t)?u:l,x+S>v&&(_=Math.min(_,Math.max(y,f)+h)),x+S>r){g=!0;break outer}h+=e.length,x+=S}y=b=0}if(p>=m)break outer;for(let t=0,n=d.length;t<n;t++){let[n,i]=d[t];if(n.lastIndex=p,n.test(e)){if(h=n===je?Ee(e.slice(p,n.lastIndex)):n===Ne?1:n.lastIndex-p,S=h*i,x+S>v&&(_=Math.min(_,p+Math.floor((v-x)/i))),x+S>r){g=!0;break outer}x+=S,y=f,b=p,p=f=n.lastIndex;continue outer}}p+=1}return{width:g?v:x,index:g?_:m,truncated:g,ellipsed:g&&r>=a}},Re={limit:1/0,ellipsis:``,ellipsisWidth:0},W=(e,t={})=>Le(e,Re,t).width,ze=`]8;;`,Be=RegExp(`(?:\\[(?<code>\\d+)m|\\${ze}(?<uri>.*))`,`y`),Ve=e=>{if(e>=30&&e<=37||e>=90&&e<=97)return 39;if(e>=40&&e<=47||e>=100&&e<=107)return 49;if(e===1||e===2)return 22;if(e===3)return 23;if(e===4)return 24;if(e===7)return 27;if(e===8)return 28;if(e===9)return 29;if(e===0)return 0},He=e=>`[${e}m`,Ue=e=>`${ze}${e}`,We=(e,t,n)=>{let r=t[Symbol.iterator](),i=!1,a=!1,o=e.at(-1),s=o===void 0?0:W(o),c=r.next(),l=r.next(),u=0;for(;!c.done;){let o=c.value,d=W(o);s+d<=n?e[e.length-1]+=o:(e.push(o),s=0),(o===`\x1B`||o===``)&&(i=!0,a=t.startsWith(ze,u+1)),i?a?o===`\x07`&&(i=!1,a=!1):o===`m`&&(i=!1):(s+=d,s===n&&!l.done&&(e.push(``),s=0)),c=l,l=r.next(),u+=o.length}o=e.at(-1),!s&&o!==void 0&&o.length&&e.length>1&&(e[e.length-2]+=e.pop())},Ge=e=>{let t=e.split(` `),n=t.length;for(;n&&!W(t[n-1]);)n--;return n===t.length?e:t.slice(0,n).join(` `)+t.slice(n).join(``)},Ke=(e,t,n={})=>{if(n.trim!==!1&&e.trim()===``)return``;let r=``,i,a,o=e.split(` `),s=[``],c=0;for(let e=0;e<o.length;e++){let r=o[e];if(n.trim!==!1){let e=s.at(-1)??``,t=e.trimStart();e.length!==t.length&&(s[s.length-1]=t,c=W(t))}e!==0&&(c>=t&&(n.wordWrap===!1||n.trim===!1)&&(s.push(``),c=0),(c||n.trim===!1)&&(s[s.length-1]+=` `,c++));let i=W(r);if(n.hard&&i>t){let e=t-c,n=1+Math.floor((i-e-1)/t);Math.floor((i-1)/t)<n&&s.push(``),We(s,r,t),c=W(s.at(-1)??``);continue}if(c+i>t&&c&&i){if(n.wordWrap===!1&&c<t){We(s,r,t),c=W(s.at(-1)??``);continue}s.push(``),c=0}if(c+i>t&&n.wordWrap===!1){We(s,r,t),c=W(s.at(-1)??``);continue}s[s.length-1]+=r,c+=i}n.trim!==!1&&(s=s.map(e=>Ge(e)));let l=s.join(`
|
|
1
|
+
import{a as e,s as t,t as n}from"./chunk-C94x7I9S.mjs";import{r,t as i}from"./esm-BLMtE3s6.mjs";import{Bt as a,Tt as o,Xi as s,bn as c,wt as l,y as u,yi as d,zt as f}from"./server-lock-CN2YHwpP-BhBKViGp.mjs";import{Hn as p,Jn as m,K as h,Xi as g,Xn as _,Yn as v,ar as y,gn as b,ha as x,sa as S,tr as C,ua as w}from"./dist-CX2NKvL3.mjs";import"./constants-guHl6645.mjs";import{d as ee,f as T,n as te,o as E,r as ne,t as re}from"./write-project-skill-C4u_YHBP.mjs";import{t as D}from"./is-object-Cg453afR.mjs";import{i as O,o as k,r as A,s as j,t as M}from"./colors-8SzMRIVy.mjs";import{t as ie}from"./preview-D2CQ6yHX.mjs";import{execFileSync as ae}from"node:child_process";import{existsSync as N,mkdirSync as P,readFileSync as F,realpathSync as oe,writeFileSync as I}from"node:fs";import se,{dirname as L,isAbsolute as ce,join as R,relative as z,resolve as le,sep as ue}from"node:path";import B from"node:process";import{homedir as de}from"node:os";import{randomUUID as fe}from"node:crypto";import{stripVTControlCharacters as pe,styleText as V}from"node:util";import{AsyncLocalStorage as me,AsyncResource as H}from"node:async_hooks";import{createServer as he,request as ge}from"node:http";import*as _e from"node:readline";import{connect as ve}from"node:net";function ye(){return B.platform.startsWith(`win`)?!!B.env.CI||!!B.env.WT_SESSION||!!B.env.TERMINUS_SUBLIME||B.env.ConEmuTask===`{cmd::Cmder}`||B.env.TERM_PROGRAM===`Terminus-Sublime`||B.env.TERM_PROGRAM===`vscode`||B.env.TERM===`xterm-256color`||B.env.TERM===`alacritty`||B.env.TERMINAL_EMULATOR===`JetBrains-JediTerm`:B.env.TERM!==`linux`}const be={circleQuestionMark:`(?)`,questionMarkPrefix:`(?)`,square:`█`,squareDarkShade:`▓`,squareMediumShade:`▒`,squareLightShade:`░`,squareTop:`▀`,squareBottom:`▄`,squareLeft:`▌`,squareRight:`▐`,squareCenter:`■`,bullet:`●`,dot:`․`,ellipsis:`…`,pointerSmall:`›`,triangleUp:`▲`,triangleUpSmall:`▴`,triangleDown:`▼`,triangleDownSmall:`▾`,triangleLeftSmall:`◂`,triangleRightSmall:`▸`,home:`⌂`,heart:`♥`,musicNote:`♪`,musicNoteBeamed:`♫`,arrowUp:`↑`,arrowDown:`↓`,arrowLeft:`←`,arrowRight:`→`,arrowLeftRight:`↔`,arrowUpDown:`↕`,almostEqual:`≈`,notEqual:`≠`,lessOrEqual:`≤`,greaterOrEqual:`≥`,identical:`≡`,infinity:`∞`,subscriptZero:`₀`,subscriptOne:`₁`,subscriptTwo:`₂`,subscriptThree:`₃`,subscriptFour:`₄`,subscriptFive:`₅`,subscriptSix:`₆`,subscriptSeven:`₇`,subscriptEight:`₈`,subscriptNine:`₉`,oneHalf:`½`,oneThird:`⅓`,oneQuarter:`¼`,oneFifth:`⅕`,oneSixth:`⅙`,oneEighth:`⅛`,twoThirds:`⅔`,twoFifths:`⅖`,threeQuarters:`¾`,threeFifths:`⅗`,threeEighths:`⅜`,fourFifths:`⅘`,fiveSixths:`⅚`,fiveEighths:`⅝`,sevenEighths:`⅞`,line:`─`,lineBold:`━`,lineDouble:`═`,lineDashed0:`┄`,lineDashed1:`┅`,lineDashed2:`┈`,lineDashed3:`┉`,lineDashed4:`╌`,lineDashed5:`╍`,lineDashed6:`╴`,lineDashed7:`╶`,lineDashed8:`╸`,lineDashed9:`╺`,lineDashed10:`╼`,lineDashed11:`╾`,lineDashed12:`−`,lineDashed13:`–`,lineDashed14:`‐`,lineDashed15:`⁃`,lineVertical:`│`,lineVerticalBold:`┃`,lineVerticalDouble:`║`,lineVerticalDashed0:`┆`,lineVerticalDashed1:`┇`,lineVerticalDashed2:`┊`,lineVerticalDashed3:`┋`,lineVerticalDashed4:`╎`,lineVerticalDashed5:`╏`,lineVerticalDashed6:`╵`,lineVerticalDashed7:`╷`,lineVerticalDashed8:`╹`,lineVerticalDashed9:`╻`,lineVerticalDashed10:`╽`,lineVerticalDashed11:`╿`,lineDownLeft:`┐`,lineDownLeftArc:`╮`,lineDownBoldLeftBold:`┓`,lineDownBoldLeft:`┒`,lineDownLeftBold:`┑`,lineDownDoubleLeftDouble:`╗`,lineDownDoubleLeft:`╖`,lineDownLeftDouble:`╕`,lineDownRight:`┌`,lineDownRightArc:`╭`,lineDownBoldRightBold:`┏`,lineDownBoldRight:`┎`,lineDownRightBold:`┍`,lineDownDoubleRightDouble:`╔`,lineDownDoubleRight:`╓`,lineDownRightDouble:`╒`,lineUpLeft:`┘`,lineUpLeftArc:`╯`,lineUpBoldLeftBold:`┛`,lineUpBoldLeft:`┚`,lineUpLeftBold:`┙`,lineUpDoubleLeftDouble:`╝`,lineUpDoubleLeft:`╜`,lineUpLeftDouble:`╛`,lineUpRight:`└`,lineUpRightArc:`╰`,lineUpBoldRightBold:`┗`,lineUpBoldRight:`┖`,lineUpRightBold:`┕`,lineUpDoubleRightDouble:`╚`,lineUpDoubleRight:`╙`,lineUpRightDouble:`╘`,lineUpDownLeft:`┤`,lineUpBoldDownBoldLeftBold:`┫`,lineUpBoldDownBoldLeft:`┨`,lineUpDownLeftBold:`┥`,lineUpBoldDownLeftBold:`┩`,lineUpDownBoldLeftBold:`┪`,lineUpDownBoldLeft:`┧`,lineUpBoldDownLeft:`┦`,lineUpDoubleDownDoubleLeftDouble:`╣`,lineUpDoubleDownDoubleLeft:`╢`,lineUpDownLeftDouble:`╡`,lineUpDownRight:`├`,lineUpBoldDownBoldRightBold:`┣`,lineUpBoldDownBoldRight:`┠`,lineUpDownRightBold:`┝`,lineUpBoldDownRightBold:`┡`,lineUpDownBoldRightBold:`┢`,lineUpDownBoldRight:`┟`,lineUpBoldDownRight:`┞`,lineUpDoubleDownDoubleRightDouble:`╠`,lineUpDoubleDownDoubleRight:`╟`,lineUpDownRightDouble:`╞`,lineDownLeftRight:`┬`,lineDownBoldLeftBoldRightBold:`┳`,lineDownLeftBoldRightBold:`┯`,lineDownBoldLeftRight:`┰`,lineDownBoldLeftBoldRight:`┱`,lineDownBoldLeftRightBold:`┲`,lineDownLeftRightBold:`┮`,lineDownLeftBoldRight:`┭`,lineDownDoubleLeftDoubleRightDouble:`╦`,lineDownDoubleLeftRight:`╥`,lineDownLeftDoubleRightDouble:`╤`,lineUpLeftRight:`┴`,lineUpBoldLeftBoldRightBold:`┻`,lineUpLeftBoldRightBold:`┷`,lineUpBoldLeftRight:`┸`,lineUpBoldLeftBoldRight:`┹`,lineUpBoldLeftRightBold:`┺`,lineUpLeftRightBold:`┶`,lineUpLeftBoldRight:`┵`,lineUpDoubleLeftDoubleRightDouble:`╩`,lineUpDoubleLeftRight:`╨`,lineUpLeftDoubleRightDouble:`╧`,lineUpDownLeftRight:`┼`,lineUpBoldDownBoldLeftBoldRightBold:`╋`,lineUpDownBoldLeftBoldRightBold:`╈`,lineUpBoldDownLeftBoldRightBold:`╇`,lineUpBoldDownBoldLeftRightBold:`╊`,lineUpBoldDownBoldLeftBoldRight:`╉`,lineUpBoldDownLeftRight:`╀`,lineUpDownBoldLeftRight:`╁`,lineUpDownLeftBoldRight:`┽`,lineUpDownLeftRightBold:`┾`,lineUpBoldDownBoldLeftRight:`╂`,lineUpDownLeftBoldRightBold:`┿`,lineUpBoldDownLeftBoldRight:`╃`,lineUpBoldDownLeftRightBold:`╄`,lineUpDownBoldLeftBoldRight:`╅`,lineUpDownBoldLeftRightBold:`╆`,lineUpDoubleDownDoubleLeftDoubleRightDouble:`╬`,lineUpDoubleDownDoubleLeftRight:`╫`,lineUpDownLeftDoubleRightDouble:`╪`,lineCross:`╳`,lineBackslash:`╲`,lineSlash:`╱`},xe={tick:`✔`,info:`ℹ`,warning:`⚠`,cross:`✘`,squareSmall:`◻`,squareSmallFilled:`◼`,circle:`◯`,circleFilled:`◉`,circleDotted:`◌`,circleDouble:`◎`,circleCircle:`ⓞ`,circleCross:`ⓧ`,circlePipe:`Ⓘ`,radioOn:`◉`,radioOff:`◯`,checkboxOn:`☒`,checkboxOff:`☐`,checkboxCircleOn:`ⓧ`,checkboxCircleOff:`Ⓘ`,pointer:`❯`,triangleUpOutline:`△`,triangleLeft:`◀`,triangleRight:`▶`,lozenge:`◆`,lozengeOutline:`◇`,hamburger:`☰`,smiley:`㋡`,mustache:`෴`,star:`★`,play:`▶`,nodejs:`⬢`,oneSeventh:`⅐`,oneNinth:`⅑`,oneTenth:`⅒`},Se={tick:`√`,info:`i`,warning:`‼`,cross:`×`,squareSmall:`□`,squareSmallFilled:`■`,circle:`( )`,circleFilled:`(*)`,circleDotted:`( )`,circleDouble:`( )`,circleCircle:`(○)`,circleCross:`(×)`,circlePipe:`(│)`,radioOn:`(*)`,radioOff:`( )`,checkboxOn:`[×]`,checkboxOff:`[ ]`,checkboxCircleOn:`(×)`,checkboxCircleOff:`( )`,pointer:`>`,triangleUpOutline:`∆`,triangleLeft:`◄`,triangleRight:`►`,lozenge:`♦`,lozengeOutline:`◊`,hamburger:`≡`,smiley:`☺`,mustache:`┌─┐`,star:`✶`,play:`►`,nodejs:`♦`,oneSeventh:`1/7`,oneNinth:`1/9`,oneTenth:`1/10`},Ce={...be,...xe},we={...be,...Se},U=ye()?Ce:we;Object.entries(xe);var Te=n(((t,n)=>{n.exports=i;function r(t){let n={defaultWidth:0,output:process.stdout,tty:e(`tty`)};return t?(Object.keys(n).forEach(function(e){t[e]||(t[e]=n[e])}),t):n}function i(e){let t=r(e);if(t.output.getWindowSize)return t.output.getWindowSize()[0]||t.defaultWidth;if(t.tty.getWindowSize)return t.tty.getWindowSize()[1]||t.defaultWidth;if(t.output.columns)return t.output.columns;if(process.env.CLI_WIDTH){let e=parseInt(process.env.CLI_WIDTH,10);if(!isNaN(e)&&e!==0)return e}return t.defaultWidth}}));const Ee=(()=>{let e=/[\uD800-\uDBFF][\uDC00-\uDFFF]/g;return t=>{let n=0;for(e.lastIndex=0;e.test(t);)n+=1;return t.length-n}})(),De=e=>e===12288||e>=65281&&e<=65376||e>=65504&&e<=65510,Oe=e=>e===8987||e===9001||e>=12272&&e<=12287||e>=12289&&e<=12350||e>=12441&&e<=12543||e>=12549&&e<=12591||e>=12593&&e<=12686||e>=12688&&e<=12771||e>=12783&&e<=12830||e>=12832&&e<=12871||e>=12880&&e<=19903||e>=65040&&e<=65049||e>=65072&&e<=65106||e>=65108&&e<=65126||e>=65128&&e<=65131||e>=127488&&e<=127490||e>=127504&&e<=127547||e>=127552&&e<=127560||e>=131072&&e<=196605||e>=196608&&e<=262141,ke=/[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]|\u001b\]8;[^;]*;.*?(?:\u0007|\u001b\u005c)/y,Ae=/[\x00-\x08\x0A-\x1F\x7F-\x9F]{1,1000}/y,je=/(?:(?![\uFF61-\uFF9F\uFF00-\uFFEF])[\p{Script=Han}\p{Script=Hiragana}\p{Script=Katakana}\p{Script=Hangul}\p{Script=Tangut}]){1,1000}/uy,Me=/\t{1,1000}/y,Ne=/[\u{1F1E6}-\u{1F1FF}]{2}|\u{1F3F4}[\u{E0061}-\u{E007A}]{2}[\u{E0030}-\u{E0039}\u{E0061}-\u{E007A}]{1,3}\u{E007F}|(?:\p{Emoji}\uFE0F\u20E3?|\p{Emoji_Modifier_Base}\p{Emoji_Modifier}?|\p{Emoji_Presentation})(?:\u200D(?:\p{Emoji_Modifier_Base}\p{Emoji_Modifier}?|\p{Emoji_Presentation}|\p{Emoji}\uFE0F\u20E3?))*/uy,Pe=/(?:[\x20-\x7E\xA0-\xFF](?!\uFE0F)){1,1000}/y,Fe=/\p{M}+/gu,Ie={limit:1/0,ellipsis:``},Le=(e,t={},n={})=>{let r=t.limit??1/0,i=t.ellipsis??``,a=t?.ellipsisWidth??(i?Le(i,Ie,n).width:0),o=n.controlWidth??0,s=n.tabWidth??8,c=n.emojiWidth??2,l=n.regularWidth??1,u=n.wideWidth??2,d=[[Pe,l],[ke,0],[Ae,o],[Me,s],[Ne,c],[je,u]],f=0,p=0,m=e.length,h=0,g=!1,_=m,v=Math.max(0,r-a),y=0,b=0,x=0,S=0;outer:for(;;){if(b>y||p>=m&&p>f){let t=e.slice(y,b)||e.slice(f,p);h=0;for(let e of t.replaceAll(Fe,``)){let t=e.codePointAt(0)||0;if(S=De(t)?2:Oe(t)?u:l,x+S>v&&(_=Math.min(_,Math.max(y,f)+h)),x+S>r){g=!0;break outer}h+=e.length,x+=S}y=b=0}if(p>=m)break outer;for(let t=0,n=d.length;t<n;t++){let[n,i]=d[t];if(n.lastIndex=p,n.test(e)){if(h=n===je?Ee(e.slice(p,n.lastIndex)):n===Ne?1:n.lastIndex-p,S=h*i,x+S>v&&(_=Math.min(_,p+Math.floor((v-x)/i))),x+S>r){g=!0;break outer}x+=S,y=f,b=p,p=f=n.lastIndex;continue outer}}p+=1}return{width:g?v:x,index:g?_:m,truncated:g,ellipsed:g&&r>=a}},Re={limit:1/0,ellipsis:``,ellipsisWidth:0},W=(e,t={})=>Le(e,Re,t).width,ze=`]8;;`,Be=RegExp(`(?:\\[(?<code>\\d+)m|\\${ze}(?<uri>.*))`,`y`),Ve=e=>{if(e>=30&&e<=37||e>=90&&e<=97)return 39;if(e>=40&&e<=47||e>=100&&e<=107)return 49;if(e===1||e===2)return 22;if(e===3)return 23;if(e===4)return 24;if(e===7)return 27;if(e===8)return 28;if(e===9)return 29;if(e===0)return 0},He=e=>`[${e}m`,Ue=e=>`${ze}${e}`,We=(e,t,n)=>{let r=t[Symbol.iterator](),i=!1,a=!1,o=e.at(-1),s=o===void 0?0:W(o),c=r.next(),l=r.next(),u=0;for(;!c.done;){let o=c.value,d=W(o);s+d<=n?e[e.length-1]+=o:(e.push(o),s=0),(o===`\x1B`||o===``)&&(i=!0,a=t.startsWith(ze,u+1)),i?a?o===`\x07`&&(i=!1,a=!1):o===`m`&&(i=!1):(s+=d,s===n&&!l.done&&(e.push(``),s=0)),c=l,l=r.next(),u+=o.length}o=e.at(-1),!s&&o!==void 0&&o.length&&e.length>1&&(e[e.length-2]+=e.pop())},Ge=e=>{let t=e.split(` `),n=t.length;for(;n&&!W(t[n-1]);)n--;return n===t.length?e:t.slice(0,n).join(` `)+t.slice(n).join(``)},Ke=(e,t,n={})=>{if(n.trim!==!1&&e.trim()===``)return``;let r=``,i,a,o=e.split(` `),s=[``],c=0;for(let e=0;e<o.length;e++){let r=o[e];if(n.trim!==!1){let e=s.at(-1)??``,t=e.trimStart();e.length!==t.length&&(s[s.length-1]=t,c=W(t))}e!==0&&(c>=t&&(n.wordWrap===!1||n.trim===!1)&&(s.push(``),c=0),(c||n.trim===!1)&&(s[s.length-1]+=` `,c++));let i=W(r);if(n.hard&&i>t){let e=t-c,n=1+Math.floor((i-e-1)/t);Math.floor((i-1)/t)<n&&s.push(``),We(s,r,t),c=W(s.at(-1)??``);continue}if(c+i>t&&c&&i){if(n.wordWrap===!1&&c<t){We(s,r,t),c=W(s.at(-1)??``);continue}s.push(``),c=0}if(c+i>t&&n.wordWrap===!1){We(s,r,t),c=W(s.at(-1)??``);continue}s[s.length-1]+=r,c+=i}n.trim!==!1&&(s=s.map(e=>Ge(e)));let l=s.join(`
|
|
2
2
|
`),u=!1;for(let e=0;e<l.length;e++){let t=l[e];if(r+=t,u)u=!1;else if(u=t>=`\ud800`&&t<=`\udbff`,u)continue;if(t===`\x1B`||t===``){Be.lastIndex=e+1;let t=Be.exec(l)?.groups;if(t?.code!==void 0){let e=Number.parseFloat(t.code);i=e===39?void 0:e}else t?.uri!==void 0&&(a=t.uri.length===0?void 0:t.uri)}if(l[e+1]===`
|
|
3
3
|
`){a&&(r+=Ue(``));let e=i?Ve(i):void 0;i&&e&&(r+=He(e))}else t===`
|
|
4
4
|
`&&(i&&Ve(i)&&(r+=He(i)),a&&(r+=Ue(a)))}return r},qe=/\r?\n/;function Je(e,t,n){return String(e).normalize().split(qe).map(e=>Ke(e,t,n)).join(`
|
|
@@ -281,7 +281,7 @@ let oi=/^[a-z0-9-_]+$/i;function si(e){let t=typeof e;if(t===`object`){if(Array.
|
|
|
281
281
|
`}}return e&&(a||!o)&&(a=a?`[${e}]\n${a}`:`[${e}]`),a&&o?`${a}\n${o}`:a||o}function hi(e,{maxDepth:t=1e3,numbersAsFloat:n=!1}={}){if(si(e)!==`object`)throw TypeError(`stringify can only be called with an object`);let r=mi(0,e,``,t,n);return r[r.length-1]===`
|
|
282
282
|
`?r:r+`
|
|
283
283
|
`}function gi(e,t){let n=z(t,e);return n.length>0&&!n.startsWith(`..`)&&!ce(n)}const _i=e=>{try{let t=ae(`git`,[`rev-parse`,`--show-toplevel`],{cwd:e,encoding:`utf8`,stdio:[`ignore`,`pipe`,`ignore`]}).trim();return t.length>0?t:null}catch{return null}};function vi(e,t={}){let n=t.homeDir??de(),r=t.gitTopLevel??_i,i=le(e),a;try{a=oe(i)}catch{a=i}let o=a,s=0;for(;s<30&&!(o===n||o===`/`||o===``);){if(y(o))return{projectRoot:o,defaultContentDir:`.`,ancestorPromoted:o!==a,gitRootPromoted:!1};let e=L(o);if(e===o)break;o=e,s+=1}let c=r(a);return c!==null&&gi(c,n)?c===a?{projectRoot:i,defaultContentDir:`.`,ancestorPromoted:!1,gitRootPromoted:!1}:{projectRoot:c,defaultContentDir:`.`,ancestorPromoted:!1,gitRootPromoted:!0}:{projectRoot:i,defaultContentDir:`.`,ancestorPromoted:!1,gitRootPromoted:!1}}function $(e,t,n,r,i){let a=`urn:uuid:${fe()}`;if(e.headersSent||e.writableEnded||e.destroyed){console.error(`[ok ui] emitProblem called after headers sent — suppressed`,{type:n,status:t,instance:a});return}let o={type:n,title:r,status:t,instance:a,...i===void 0?{}:{detail:i}},s=c.safeParse(o);if(!s.success){console.error(`[ok ui] emitProblem produced an invalid ProblemDetails body:`,{issues:s.error.issues,originalStatus:t,body:o}),e.writeHead(500,{"Content-Type":`application/problem+json`,"X-Content-Type-Options":`nosniff`,"Cache-Control":`no-store`}),e.end(JSON.stringify({type:`urn:ok:error:internal-server-error`,title:`Internal server error.`,status:500,instance:a}));return}e.writeHead(t,{"Content-Type":`application/problem+json`,"X-Content-Type-Options":`nosniff`,"Cache-Control":`no-store`}),e.end(JSON.stringify(o))}const yi=1e4;function bi(e,t){let n=e.socket?.remoteAddress;if(n!==void 0&&!C(n))return $(t,403,`urn:ok:error:loopback-required`,`Request must originate from a loopback address.`),!0;if(!_(e.headers.host))return $(t,403,`urn:ok:error:host-not-allowed`,`Host header is not in the loopback allowlist.`),!0;let r=e.headers.origin;return r!==void 0&&!v(r)?($(t,403,`urn:ok:error:invalid-origin`,`Origin header is not in the loopback allowlist.`),!0):!1}const xi=3e4;function Si(e,t){let n=e.socket?.remoteAddress;if(n!==void 0&&!C(n)||!_(e.headers.host))return t.destroy(),!0;let r=e.headers.origin;return typeof r==`string`&&!v(r)?(t.destroy(),!0):!1}function Ci(e,t,n,r,i,a){a.add(t),t.once(`close`,()=>a.delete(t));let o=ve({host:r,port:i,timeout:yi});a.add(o),o.once(`close`,()=>a.delete(o));let s=!1,c=n=>{if(!s){if(s=!0,n!==void 0){let t=n.err;console.warn(JSON.stringify({event:n.event,upstreamHost:r,upstreamPort:i,url:e.url,code:t instanceof Error?t.code:void 0,message:t instanceof Error?t.message:void 0}))}try{o.destroy()}catch{}try{t.destroy()}catch{}}};o.once(`connect`,()=>{o.setTimeout(0);let a=[`${e.method??`GET`} ${e.url??`/`} HTTP/1.1`,`host: ${r}:${i}`];for(let[t,n]of Object.entries(e.headers))if(t.toLowerCase()!==`host`&&n!==void 0)if(Array.isArray(n))for(let e of n)a.push(`${t}: ${e}`);else a.push(`${t}: ${n}`);try{o.write(`${a.join(`\r
|
|
284
|
-
`)}\r\n\r\n`),n.length>0&&o.write(n)}catch(e){c({event:`proxy-upgrade-handshake-write-failed`,err:e});return}o.on(`data`,e=>{t.writable&&t.write(e)}),t.on(`data`,e=>{o.writable&&o.write(e)})}),o.once(`timeout`,()=>{c({event:`proxy-upgrade-upstream-connect-timeout`})}),o.on(`error`,e=>c({event:`proxy-upgrade-upstream-error`,err:e})),t.on(`error`,e=>c({event:`proxy-upgrade-client-error`,err:e})),o.once(`close`,()=>c()),t.once(`close`,()=>c())}const wi=[`connection`,`keep-alive`,`proxy-authenticate`,`proxy-authorization`,`te`,`trailer`,`transfer-encoding`,`upgrade`,`cookie`,`set-cookie`];async function Ti(e){let t=e.upstreamTimeoutMs??yi,n=new Set,r=he((n,r)=>{bi(n,r)||Di(n,r,e.upstreamHost,e.upstreamPort,t)});r.on(`upgrade`,(t,r,i)=>{Si(t,r)||Ci(t,r,i,e.upstreamHost,e.upstreamPort,n)}),await new Promise((t,n)=>{let i=e=>n(e);r.once(`error`,i),r.listen(e.listenPort,e.host,()=>{r.off(`error`,i),t()})});let i=r.address();return{httpServer:r,port:typeof i==`object`&&i?i.port:e.listenPort,close:()=>new Promise(e=>{for(let e of n)try{e.destroy()}catch{}n.clear(),r.close(()=>e()),r.closeIdleConnections()})}}function Ei(e,t,n){Di(e,t,n.upstreamHost,n.upstreamPort,n.upstreamTimeoutMs??yi)}function Di(e,t,n,r,i){let a={...e.headers};delete a.host;for(let e of wi)delete a[e];e.setTimeout(xi,()=>{if(t.headersSent)try{t.end()}catch{}else try{$(t,408,`urn:ok:error:request-timeout`,`Proxy request exceeded the per-request deadline.`,`Slow-loris-class: client did not finish within ${xi/1e3}s.`)}catch{}try{e.socket?.destroy()}catch{}});let o=ge({host:n,port:r,method:e.method,path:e.url,headers:{...a,host:`${n}:${r}`}},e=>{let n={...e.headers};for(let e of wi)delete n[e];t.writeHead(e.statusCode??502,n),e.pipe(t),e.once(`error`,()=>{try{t.end()}catch{}})});i>0&&o.setTimeout(i,()=>{if(!t.headersSent)$(t,504,`urn:ok:error:gateway-timeout`,`Upstream did not respond before the gateway deadline.`,`Upstream timeout: ${i/1e3}s elapsed without a response.`);else try{t.end()}catch{}o.destroy()}),o.on(`error`,()=>{if(!t.headersSent)$(t,502,`urn:ok:error:collab-server-not-running`,`Collab server is unreachable.`,`Upstream connection failed or dropped before a response was received.`);else try{t.end()}catch{}}),e.on(`error`,()=>{o.destroy()}),e.pipe(o)}const Oi=39847,ki=39848;async function Ai(e){await Promise.all(e.map(e=>new Promise(t=>{e.close(()=>t())})))}async function ji(e){let{existsSync:t}=await import(`node:fs`),{createServer:n}=await import(`node:http`),{resolve:r}=await import(`node:path`),{acquireUiLock:i,clearArmedPaneTarget:a,createAssetServeMiddleware:s,createContentFilter:c,readArmedPaneTarget:l,readServerLock:p,releaseUiLock:m,updateUiLockPort:h}=await import(`./dist-C7UX8Qzt.mjs`),{default:g}=await import(`./build-CCDQyip-.mjs`),{resolveContentDir:_,resolveLockDir:v}=await import(`./dist-C7UX8Qzt.mjs`),y=_(e.config,e.cwd),b=v(e.cwd);i(b,{port:0,worktreeRoot:e.cwd});let x=import.meta.dirname??new URL(`.`,import.meta.url).pathname,S=[r(x,`public`),r(x,`../../app/dist`),r(x,`../../../app/dist`)],C=e.assetDir??S.find(e=>t(e)),w=C?g(C,{single:!0,gzip:!0,etag:!0,dev:!0,extensions:[]}):null,ee=t(y)?s({contentFilter:c({projectDir:e.cwd,contentDir:y}),contentSirv:g(y,{dotfiles:!1,dev:!0,extensions:[]}),inlineExtensions:f,assetExtensions:u,blocklistExtensions:o}):null,T=e.port,te=null,E=(e,t)=>{let n=e.url?.split(`?`)[0];if(e.method===`GET`&&(n===`/`||n===``)){let e=l(b);if(e&&!/[\r\n]/.test(e)){a(b),t.statusCode=302,t.setHeader(`Location`,`/${e}`),t.setHeader(`Cache-Control`,`no-store`),t.end();return}}if((n===`/`||n===``)&&(e.url=`/index.html`),!(n?.startsWith(`/api/`)&&bi(e,t))){if(n===`/api/config`&&e.method===`DELETE`){a(b),t.setHeader(`Cache-Control`,`no-store`),t.statusCode=204,t.end();return}if(n===`/api/config`&&(e.method===`GET`||e.method===`HEAD`)){te?.();let n=p(b),r=e.headers.host??`localhost:${T}`,i=n&&n.port>0?`ws://${r}/collab`:null,a=l(b),o=JSON.stringify({collabUrl:i,previewUrl:null,port:T,paneTarget:a});t.setHeader(`Content-Type`,`application/json`),t.setHeader(`Cache-Control`,`no-store`),t.setHeader(`X-Content-Type-Options`,`nosniff`),t.statusCode=200,e.method===`HEAD`?t.end():t.end(o);return}if(n?.startsWith(`/api/`)){te?.();let r=p(b);if(!r||r.port<=0){$(t,503,`urn:ok:error:collab-server-not-running`,"Collab server not running. Start `ok start` or run `ok status`.",`Path: ${n}`);return}Ei(e,t,{upstreamHost:`localhost`,upstreamPort:r.port});return}if(w&&n?.startsWith(`/assets/`)){w(e,t,()=>{ee?ee(e,t,()=>Mi(t)):Mi(t)});return}if(ee){ee(e,t,()=>{w?w(e,t):Mi(t)});return}if(w){w(e,t);return}Mi(t)}},ne=new Set,re=(e,t,n)=>{if(Si(e,t))return;let r=e.url?.split(`?`)[0]??``;if(r!==`/collab`&&!r.startsWith(`/collab/`)){t.destroy();return}let i=p(b);if(!i||i.port<=0){console.warn(JSON.stringify({event:`ok-ui-upgrade-no-collab-lock`,url:r,reason:"server.lock missing or port unbound — is `ok start` running?"})),t.destroy();return}Ci(e,t,n,`localhost`,i.port,ne)},D=()=>{for(let e of ne)try{e.destroy()}catch{}ne.clear()},O=e.host===void 0?[`::1`,`127.0.0.1`]:[e.host],k=[],A=e.port,j=e=>e instanceof Error&&e.code===`EADDRINUSE`,M=async()=>{await Promise.all(k.splice(0).map(e=>new Promise(t=>{try{e.close(()=>t())}catch{t()}})))},ie=async e=>{A=e;for(let e of O){let t=n(E);t.on(`upgrade`,re),k.push(t),await new Promise((n,r)=>{let i=e=>r(e);t.once(`error`,i),t.listen(A,e,()=>{t.off(`error`,i);let e=t.address();typeof e==`object`&&e&&(A=e.port),n()})})}};try{try{await ie(e.port)}catch(t){if(e.fallbackToKernel===!0&&j(t))await M(),await ie(0);else throw t}}catch(e){await M();try{m(b)}catch{}throw e}let ae=A;T=ae,h(b,ae);let N=e.scheduler??d,P=e.safetyNetMs??432e5,F=null,oe=!1,I=!1,se=()=>{oe||(oe=!0,F!==null&&(N.clearTimeout(F),F=null))},L=()=>{if(se(),!I){I=!0;try{m(b)}catch{}}},ce=()=>{oe||P<=0||(F!==null&&(N.clearTimeout(F),F=null),F=N.setTimeout(()=>{F=null,console.warn(`[ui] safety-net (${P}ms) reached — shutting down (D-025 backstop)`);try{e.onSafetyNet?.()}catch{}D();for(let e of k)try{e.close()}catch{}L()},P))},R=()=>{oe||P<=0||ce()};return te=R,ce(),{httpServers:k,port:ae,release:L,detachSafetyNet:se,nudgeSafetyNet:R,drainUpgradeSockets:D}}function Mi(e){e.headersSent||e.writableEnded||e.destroyed||(e.setHeader(`X-Content-Type-Options`,`nosniff`),e.setHeader(`Cache-Control`,`no-store`),e.statusCode=404,e.end())}function Ni(e,t){if(e!==void 0){let t=Number.parseInt(e,10);if(Number.isNaN(t)||t<0||t>65535)throw Error(`Invalid --port value '${e}'`);return{port:t,fallbackToKernel:!1}}if(t!==void 0&&t!==``){let e=Number.parseInt(t,10);if(Number.isNaN(e)||e<0||e>65535)throw Error(`Invalid PORT env value '${t}'`);return{port:e,fallbackToKernel:!1}}return{port:Oi,fallbackToKernel:!0}}async function Pi(e){let t=e.readLock??(async()=>{let{readUiLock:t}=await import(`./dist-C7UX8Qzt.mjs`);return t(e.lockDir)}),n=await t();if(!n)throw Error(`UI lock collision reported but the lock disappeared before handling — retry acquiring.`);if(n.port===e.requestedPort&&n.port>0)return{mode:`already-running`,port:n.port};let r=n.port;if(r===0){let n=Date.now()+(e.pollDeadlineMs??2e3),i=e.pollIntervalMs??100;for(;Date.now()<n;){await new Promise(e=>{setTimeout(e,i)});let e=await t();if(e&&e.port>0){r=e.port;break}}if(r===0)throw Error("UI did not bind within 2s; run `ok clean`");if(r===e.requestedPort)return{mode:`already-running`,port:r}}return{mode:`proxy`,handle:await Ti({listenPort:e.requestedPort,host:e.host,upstreamHost:`localhost`,upstreamPort:r}),upstreamPort:r}}function Fi(e){return new i(`ui`).description(`Serve the OpenKnowledge React editor UI`).option(`-p, --port <port>`,`UI port (default: $PORT env or ${Oi}, kernel-allocated fallback if busy)`).option(`-H, --host <host>`,"UI host. Default: two-socket loopback bind (`[::1]` + `127.0.0.1`) so cross-family collisions fail loud. Pass an explicit host (e.g. `127.0.0.1`, `0.0.0.0`) to bind a single socket on that host.").action(async t=>{let{dim:n}=await import(`./colors-CmkIIbww.mjs`),{UiLockCollisionError:r}=await import(`./dist-C7UX8Qzt.mjs`),{resolveLockDir:i}=await import(`./dist-C7UX8Qzt.mjs`),a=e(),o=t.host,s;try{s=Ni(t.port,process.env.PORT)}catch(e){console.error(e instanceof Error?e.message:String(e)),process.exitCode=1;return}let c=s.port;try{let e=await ji({config:a,cwd:process.cwd(),port:c,fallbackToKernel:s.fallbackToKernel,host:o}),t=o===void 0||o===`::`||o===`0.0.0.0`?`localhost`:o;console.log(`${n(`[ui]`)} listening on http://${t}:${e.port}`);let r=!1,i=t=>{if(r)return;r=!0,console.log(n(`\n[ui] Shutting down (${t})`)),e.detachSafetyNet();let i=()=>{try{e.release()}finally{process.exit(process.exitCode??0)}};e.drainUpgradeSockets(),Ai(e.httpServers).then(i,i),setTimeout(i,2e3).unref()};process.once(`SIGINT`,()=>i(`SIGINT`)),process.once(`SIGTERM`,()=>i(`SIGTERM`));return}catch(e){if(!(e instanceof r))throw e;let t=i(process.cwd()),a=o??`localhost`,s;try{s=await Pi({requestedPort:c,host:a,lockDir:t})}catch(e){console.error(e instanceof Error?e.message:String(e)),process.exit(1)}if(s.mode===`already-running`){if(console.log(`UI already running at http://${a}:${s.port}`),Ii(process)){await new Promise(e=>{let t=t=>{console.log(n(`\n[ui-keepalive] Shutting down (${t})`)),e()};process.once(`SIGINT`,()=>t(`SIGINT`)),process.once(`SIGTERM`,()=>t(`SIGTERM`))});return}process.exit(0)}console.log(`UI running at http://${a}:${s.upstreamPort}; acting as HTTP proxy on port ${s.handle.port}`);let l=!1,u=e=>{l||(l=!0,console.log(n(`\n[ui-proxy] Shutting down (${e})`)),s.handle.close().finally(()=>process.exit(process.exitCode??0)),setTimeout(()=>process.exit(process.exitCode??0),2e3).unref())};process.once(`SIGINT`,()=>u(`SIGINT`)),process.once(`SIGTERM`,()=>u(`SIGTERM`))}})}function Ii(e){let t=e.stdout.isTTY===!0,n=typeof e.env.PORT==`string`&&e.env.PORT!==``;return!t||n}function Li(e){if(!N(e))return{};let t=F(e,`utf-8`).trim();if(t===``)return{};try{let n=JSON.parse(t);if(D(n))return n;throw Error(`${e} root must be a JSON object`)}catch(t){throw t instanceof SyntaxError?Error(`${e} contains invalid JSON: ${t.message}`):t}}function Ri(e){if(!N(e))return{};let t=F(e,`utf-8`).trim();if(t===``)return{};try{let n=ai(t);if(D(n))return n;throw Error(`${e} root must be a TOML table`)}catch(t){throw Error(`${e} contains invalid TOML: ${t instanceof Error?t.message:String(t)}`)}}function zi(e,t){S(e,`${JSON.stringify(t,null,2)}\n`)}function Bi(e,t){let n=hi(t);S(e,n.endsWith(`
|
|
284
|
+
`)}\r\n\r\n`),n.length>0&&o.write(n)}catch(e){c({event:`proxy-upgrade-handshake-write-failed`,err:e});return}o.on(`data`,e=>{t.writable&&t.write(e)}),t.on(`data`,e=>{o.writable&&o.write(e)})}),o.once(`timeout`,()=>{c({event:`proxy-upgrade-upstream-connect-timeout`})}),o.on(`error`,e=>c({event:`proxy-upgrade-upstream-error`,err:e})),t.on(`error`,e=>c({event:`proxy-upgrade-client-error`,err:e})),o.once(`close`,()=>c()),t.once(`close`,()=>c())}const wi=[`connection`,`keep-alive`,`proxy-authenticate`,`proxy-authorization`,`te`,`trailer`,`transfer-encoding`,`upgrade`,`cookie`,`set-cookie`];async function Ti(e){let t=e.upstreamTimeoutMs??yi,n=new Set,r=he((n,r)=>{bi(n,r)||Di(n,r,e.upstreamHost,e.upstreamPort,t)});r.on(`upgrade`,(t,r,i)=>{Si(t,r)||Ci(t,r,i,e.upstreamHost,e.upstreamPort,n)}),await new Promise((t,n)=>{let i=e=>n(e);r.once(`error`,i),r.listen(e.listenPort,e.host,()=>{r.off(`error`,i),t()})});let i=r.address();return{httpServer:r,port:typeof i==`object`&&i?i.port:e.listenPort,close:()=>new Promise(e=>{for(let e of n)try{e.destroy()}catch{}n.clear(),r.close(()=>e()),r.closeIdleConnections()})}}function Ei(e,t,n){Di(e,t,n.upstreamHost,n.upstreamPort,n.upstreamTimeoutMs??yi)}function Di(e,t,n,r,i){let a={...e.headers};delete a.host;for(let e of wi)delete a[e];e.setTimeout(xi,()=>{if(t.headersSent)try{t.end()}catch{}else try{$(t,408,`urn:ok:error:request-timeout`,`Proxy request exceeded the per-request deadline.`,`Slow-loris-class: client did not finish within ${xi/1e3}s.`)}catch{}try{e.socket?.destroy()}catch{}});let o=ge({host:n,port:r,method:e.method,path:e.url,headers:{...a,host:`${n}:${r}`}},e=>{let n={...e.headers};for(let e of wi)delete n[e];t.writeHead(e.statusCode??502,n),e.pipe(t),e.once(`error`,()=>{try{t.end()}catch{}})});i>0&&o.setTimeout(i,()=>{if(!t.headersSent)$(t,504,`urn:ok:error:gateway-timeout`,`Upstream did not respond before the gateway deadline.`,`Upstream timeout: ${i/1e3}s elapsed without a response.`);else try{t.end()}catch{}o.destroy()}),o.on(`error`,()=>{if(!t.headersSent)$(t,502,`urn:ok:error:collab-server-not-running`,`Collab server is unreachable.`,`Upstream connection failed or dropped before a response was received.`);else try{t.end()}catch{}}),e.on(`error`,()=>{o.destroy()}),e.pipe(o)}const Oi=39847,ki=39848;async function Ai(e){await Promise.all(e.map(e=>new Promise(t=>{e.close(()=>t())})))}async function ji(e){let{existsSync:t}=await import(`node:fs`),{createServer:n}=await import(`node:http`),{resolve:r}=await import(`node:path`),{acquireUiLock:i,clearArmedPaneTarget:a,createAssetServeMiddleware:s,createContentFilter:c,readArmedPaneTarget:l,readServerLock:p,releaseUiLock:m,updateUiLockPort:h}=await import(`./dist-n9uYOrGl.mjs`),{default:g}=await import(`./build-CCDQyip-.mjs`),{resolveContentDir:_,resolveLockDir:v}=await import(`./dist-n9uYOrGl.mjs`),y=_(e.config,e.cwd),b=v(e.cwd);i(b,{port:0,worktreeRoot:e.cwd});let x=import.meta.dirname??new URL(`.`,import.meta.url).pathname,S=[r(x,`public`),r(x,`../../app/dist`),r(x,`../../../app/dist`)],C=e.assetDir??S.find(e=>t(e)),w=C?g(C,{single:!0,gzip:!0,etag:!0,dev:!0,extensions:[]}):null,ee=t(y)?s({contentFilter:c({projectDir:e.cwd,contentDir:y}),contentSirv:g(y,{dotfiles:!1,dev:!0,extensions:[]}),inlineExtensions:f,assetExtensions:u,blocklistExtensions:o}):null,T=e.port,te=null,E=(e,t)=>{let n=e.url?.split(`?`)[0];if(e.method===`GET`&&(n===`/`||n===``)){let e=l(b);if(e&&!/[\r\n]/.test(e)){a(b),t.statusCode=302,t.setHeader(`Location`,`/${e}`),t.setHeader(`Cache-Control`,`no-store`),t.end();return}}if((n===`/`||n===``)&&(e.url=`/index.html`),!(n?.startsWith(`/api/`)&&bi(e,t))){if(n===`/api/config`&&e.method===`DELETE`){a(b),t.setHeader(`Cache-Control`,`no-store`),t.statusCode=204,t.end();return}if(n===`/api/config`&&(e.method===`GET`||e.method===`HEAD`)){te?.();let n=p(b),r=e.headers.host??`localhost:${T}`,i=n&&n.port>0?`ws://${r}/collab`:null,a=l(b),o=JSON.stringify({collabUrl:i,previewUrl:null,port:T,paneTarget:a});t.setHeader(`Content-Type`,`application/json`),t.setHeader(`Cache-Control`,`no-store`),t.setHeader(`X-Content-Type-Options`,`nosniff`),t.statusCode=200,e.method===`HEAD`?t.end():t.end(o);return}if(n?.startsWith(`/api/`)){te?.();let r=p(b);if(!r||r.port<=0){$(t,503,`urn:ok:error:collab-server-not-running`,"Collab server not running. Start `ok start` or run `ok status`.",`Path: ${n}`);return}Ei(e,t,{upstreamHost:`localhost`,upstreamPort:r.port});return}if(w&&n?.startsWith(`/assets/`)){w(e,t,()=>{ee?ee(e,t,()=>Mi(t)):Mi(t)});return}if(ee){ee(e,t,()=>{w?w(e,t):Mi(t)});return}if(w){w(e,t);return}Mi(t)}},ne=new Set,re=(e,t,n)=>{if(Si(e,t))return;let r=e.url?.split(`?`)[0]??``;if(r!==`/collab`&&!r.startsWith(`/collab/`)){t.destroy();return}let i=p(b);if(!i||i.port<=0){console.warn(JSON.stringify({event:`ok-ui-upgrade-no-collab-lock`,url:r,reason:"server.lock missing or port unbound — is `ok start` running?"})),t.destroy();return}Ci(e,t,n,`localhost`,i.port,ne)},D=()=>{for(let e of ne)try{e.destroy()}catch{}ne.clear()},O=e.host===void 0?[`::1`,`127.0.0.1`]:[e.host],k=[],A=e.port,j=e=>e instanceof Error&&e.code===`EADDRINUSE`,M=async()=>{await Promise.all(k.splice(0).map(e=>new Promise(t=>{try{e.close(()=>t())}catch{t()}})))},ie=async e=>{A=e;for(let e of O){let t=n(E);t.on(`upgrade`,re),k.push(t),await new Promise((n,r)=>{let i=e=>r(e);t.once(`error`,i),t.listen(A,e,()=>{t.off(`error`,i);let e=t.address();typeof e==`object`&&e&&(A=e.port),n()})})}};try{try{await ie(e.port)}catch(t){if(e.fallbackToKernel===!0&&j(t))await M(),await ie(0);else throw t}}catch(e){await M();try{m(b)}catch{}throw e}let ae=A;T=ae,h(b,ae);let N=e.scheduler??d,P=e.safetyNetMs??432e5,F=null,oe=!1,I=!1,se=()=>{oe||(oe=!0,F!==null&&(N.clearTimeout(F),F=null))},L=()=>{if(se(),!I){I=!0;try{m(b)}catch{}}},ce=()=>{oe||P<=0||(F!==null&&(N.clearTimeout(F),F=null),F=N.setTimeout(()=>{F=null,console.warn(`[ui] safety-net (${P}ms) reached — shutting down (D-025 backstop)`);try{e.onSafetyNet?.()}catch{}D();for(let e of k)try{e.close()}catch{}L()},P))},R=()=>{oe||P<=0||ce()};return te=R,ce(),{httpServers:k,port:ae,release:L,detachSafetyNet:se,nudgeSafetyNet:R,drainUpgradeSockets:D}}function Mi(e){e.headersSent||e.writableEnded||e.destroyed||(e.setHeader(`X-Content-Type-Options`,`nosniff`),e.setHeader(`Cache-Control`,`no-store`),e.statusCode=404,e.end())}function Ni(e,t){if(e!==void 0){let t=Number.parseInt(e,10);if(Number.isNaN(t)||t<0||t>65535)throw Error(`Invalid --port value '${e}'`);return{port:t,fallbackToKernel:!1}}if(t!==void 0&&t!==``){let e=Number.parseInt(t,10);if(Number.isNaN(e)||e<0||e>65535)throw Error(`Invalid PORT env value '${t}'`);return{port:e,fallbackToKernel:!1}}return{port:Oi,fallbackToKernel:!0}}async function Pi(e){let t=e.readLock??(async()=>{let{readUiLock:t}=await import(`./dist-n9uYOrGl.mjs`);return t(e.lockDir)}),n=await t();if(!n)throw Error(`UI lock collision reported but the lock disappeared before handling — retry acquiring.`);if(n.port===e.requestedPort&&n.port>0)return{mode:`already-running`,port:n.port};let r=n.port;if(r===0){let n=Date.now()+(e.pollDeadlineMs??2e3),i=e.pollIntervalMs??100;for(;Date.now()<n;){await new Promise(e=>{setTimeout(e,i)});let e=await t();if(e&&e.port>0){r=e.port;break}}if(r===0)throw Error("UI did not bind within 2s; run `ok clean`");if(r===e.requestedPort)return{mode:`already-running`,port:r}}return{mode:`proxy`,handle:await Ti({listenPort:e.requestedPort,host:e.host,upstreamHost:`localhost`,upstreamPort:r}),upstreamPort:r}}function Fi(e){return new i(`ui`).description(`Serve the OpenKnowledge React editor UI`).option(`-p, --port <port>`,`UI port (default: $PORT env or ${Oi}, kernel-allocated fallback if busy)`).option(`-H, --host <host>`,"UI host. Default: two-socket loopback bind (`[::1]` + `127.0.0.1`) so cross-family collisions fail loud. Pass an explicit host (e.g. `127.0.0.1`, `0.0.0.0`) to bind a single socket on that host.").action(async t=>{let{dim:n}=await import(`./colors-CmkIIbww.mjs`),{UiLockCollisionError:r}=await import(`./dist-n9uYOrGl.mjs`),{resolveLockDir:i}=await import(`./dist-n9uYOrGl.mjs`),a=e(),o=t.host,s;try{s=Ni(t.port,process.env.PORT)}catch(e){console.error(e instanceof Error?e.message:String(e)),process.exitCode=1;return}let c=s.port;try{let e=await ji({config:a,cwd:process.cwd(),port:c,fallbackToKernel:s.fallbackToKernel,host:o}),t=o===void 0||o===`::`||o===`0.0.0.0`?`localhost`:o;console.log(`${n(`[ui]`)} listening on http://${t}:${e.port}`);let r=!1,i=t=>{if(r)return;r=!0,console.log(n(`\n[ui] Shutting down (${t})`)),e.detachSafetyNet();let i=()=>{try{e.release()}finally{process.exit(process.exitCode??0)}};e.drainUpgradeSockets(),Ai(e.httpServers).then(i,i),setTimeout(i,2e3).unref()};process.once(`SIGINT`,()=>i(`SIGINT`)),process.once(`SIGTERM`,()=>i(`SIGTERM`));return}catch(e){if(!(e instanceof r))throw e;let t=i(process.cwd()),a=o??`localhost`,s;try{s=await Pi({requestedPort:c,host:a,lockDir:t})}catch(e){console.error(e instanceof Error?e.message:String(e)),process.exit(1)}if(s.mode===`already-running`){if(console.log(`UI already running at http://${a}:${s.port}`),Ii(process)){await new Promise(e=>{let t=t=>{console.log(n(`\n[ui-keepalive] Shutting down (${t})`)),e()};process.once(`SIGINT`,()=>t(`SIGINT`)),process.once(`SIGTERM`,()=>t(`SIGTERM`))});return}process.exit(0)}console.log(`UI running at http://${a}:${s.upstreamPort}; acting as HTTP proxy on port ${s.handle.port}`);let l=!1,u=e=>{l||(l=!0,console.log(n(`\n[ui-proxy] Shutting down (${e})`)),s.handle.close().finally(()=>process.exit(process.exitCode??0)),setTimeout(()=>process.exit(process.exitCode??0),2e3).unref())};process.once(`SIGINT`,()=>u(`SIGINT`)),process.once(`SIGTERM`,()=>u(`SIGTERM`))}})}function Ii(e){let t=e.stdout.isTTY===!0,n=typeof e.env.PORT==`string`&&e.env.PORT!==``;return!t||n}function Li(e){if(!N(e))return{};let t=F(e,`utf-8`).trim();if(t===``)return{};try{let n=JSON.parse(t);if(D(n))return n;throw Error(`${e} root must be a JSON object`)}catch(t){throw t instanceof SyntaxError?Error(`${e} contains invalid JSON: ${t.message}`):t}}function Ri(e){if(!N(e))return{};let t=F(e,`utf-8`).trim();if(t===``)return{};try{let n=ai(t);if(D(n))return n;throw Error(`${e} root must be a TOML table`)}catch(t){throw Error(`${e} contains invalid TOML: ${t instanceof Error?t.message:String(t)}`)}}function zi(e,t){S(e,`${JSON.stringify(t,null,2)}\n`)}function Bi(e,t){let n=hi(t);S(e,n.endsWith(`
|
|
285
285
|
`)?n:`${n}\n`)}const Vi=e=>e!==`project`,Hi=e=>e!==`user`;async function Ui(){let e=await En({message:`Where should the MCP server be configured?
|
|
286
286
|
`,required:!1,theme:{icon:{checked:`[x]`,unchecked:`[ ]`}},choices:[{name:`User-level (~/.claude.json, ~/.cursor/mcp.json, …)`,value:`user`,checked:!0},{name:`Project-level (.mcp.json, .cursor/mcp.json, …)`,value:`project`,checked:!0}]});return e.includes(`user`)&&e.includes(`project`)?`both`:e.includes(`user`)?`user`:e.includes(`project`)?`project`:null}async function Wi(e){return e.mcp===!1?null:e.scope?e.scope:e.isTTY??process.stdout.isTTY?(e.promptFn??Ui)():`both`}async function Gi(e){return Fr({message:`How do you want to handle OpenKnowledge config files (.ok/, .mcp.json, project skills, launch.json)?`,default:e,choices:[{name:`Share with my team (commit alongside content)`,value:`shared`,description:`OK config gets committed alongside your project content.`},{name:`Local only (keep out of git via .git/info/exclude)`,value:`local-only`,description:"OK config stays on this machine only; teammates do not see it. Safe escape hatch via `ok config-sharing share`."}]})}async function Ki(e){if(e.sharing!==void 0)return e.sharing;let t=yt(e.projectRoot)===`local-only`?`local-only`:`shared`;return e.isTTY??process.stdout.isTTY?(e.promptFn??Gi)(t):t}const qi=`0.0.1`,Ji=`open-knowledge-ui`,Yi=[`-y`,`@inkeep/open-knowledge@latest`,`ui`],Xi=`# ok-ui-v1`,Zi=`${Xi}
|
|
287
287
|
UIPORT="\${PORT:-${ki}}"
|
|
@@ -300,6 +300,6 @@ UIPORT="\${PORT:-${ki}}"
|
|
|
300
300
|
unset PORT
|
|
301
301
|
exec node "${ee()}" start --ui-port "$UIPORT"`],port:ki,autoPort:!0}:{name:Ji,runtimeExecutable:`/bin/sh`,runtimeArgs:[`-l`,`-c`,Zi],port:ki,autoPort:!0};try{if(re(n,e),!N(n))return P(L(n),{recursive:!0}),I(n,`${JSON.stringify({version:qi,configurations:[r]},null,2)}\n`,`utf-8`),{action:`created`,configPath:n};let t=F(n,`utf-8`).trim(),i=t?JSON.parse(t):{};if(!D(i))return{action:`failed`,configPath:n,error:`launch.json root is not an object`};let a=Array.isArray(i.configurations)?i.configurations:[],o=a.findIndex(e=>D(e)&&e.name===`open-knowledge-ui`);o>=0?a[o]=r:a.push(r);let s={...i,version:i.version??qi,configurations:a};return I(n,`${JSON.stringify(s,null,2)}\n`,`utf-8`),{action:o>=0?`merged`:`created`,configPath:n}}catch(e){return{action:`failed`,configPath:n,error:e instanceof Error?e.message:String(e)}}}function $i(e,t,n){try{return N(e.detectPath?.(t,n)??L(e.configPath(t,n)))}catch{return!1}}function ea(e,t,n,r,i){let a=e.serverName(t),o;try{o=i??e.configPath(t,r)}catch(t){return{editorId:e.id,label:e.label,action:`failed`,configPath:``,serverName:a,error:t instanceof Error?t.message:String(t)}}if(!i&&!n.skipAvailabilityCheck&&!$i(e,t,r))return{editorId:e.id,label:e.label,action:`skipped-missing`,configPath:o,serverName:a};if(i!==void 0)try{re(o,t)}catch(t){return{editorId:e.id,label:e.label,action:`failed`,configPath:o,serverName:a,error:t instanceof Error?t.message:String(t),configScope:`project`}}let s;try{s=e.buildEntry(t,n)}catch(t){return{editorId:e.id,label:e.label,action:`failed`,configPath:o,serverName:a,error:t instanceof Error?t.message:String(t),...i===void 0?{}:{configScope:`project`}}}try{P(L(o),{recursive:!0})}catch(t){return{editorId:e.id,label:e.label,action:`failed`,configPath:o,serverName:a,error:t instanceof Error?t.message:String(t),...i===void 0?{}:{configScope:`project`}}}let c,l;try{w(`${o}.lock`,()=>{let t=e.format===`toml`?Ri(o):Li(o),n=t[e.topLevelKey]??{};c=n[a];let r={...t,[e.topLevelKey]:{...n,[a]:s}};e.format===`toml`?Bi(o,r):zi(o,r)},{onWarn:(e,t)=>process.stderr.write(`[ok] ${e} ${JSON.stringify(t)}\n`)})}catch(e){l=e instanceof Error?e:Error(String(e))}return l?{editorId:e.id,label:e.label,action:`failed`,configPath:o,serverName:a,error:l.message,...i===void 0?{}:{configScope:`project`}}:{editorId:e.id,label:e.label,action:c===void 0?`written`:`overwritten`,configPath:o,serverName:a,...i===void 0?{}:{configScope:`project`}}}function ta(e,t){let n=e.projectConfigPath?.(t);if(!(!n||!N(n)))return{editorId:e.id,label:e.label,path:n}}async function na(e){let t=T(e.editors),n={mode:`published`,skipAvailabilityCheck:!0};return t.map(t=>ea(t,``,n,e.home))}function ra(e,t,n,r){let i=ia(e,t,n,r);return i.kind===`present`?i.entry:null}function ia(e,t,n,r){let i;try{i=r??e.configPath(t,n)}catch{return{kind:`absent`}}if(!N(i))return{kind:`absent`};let a;try{a=F(i,`utf-8`)}catch(e){return{kind:`corrupt`,error:e instanceof Error?e.message:String(e)}}if(a.trim()===``)return{kind:`corrupt`,error:`file is empty`};let o;try{o=e.format===`toml`?Ri(i):Li(i)}catch(e){return{kind:`corrupt`,error:e instanceof Error?e.message:String(e)}}let s=o[e.topLevelKey];if(!D(s))return{kind:`no-entry`};let c=s[e.serverName(t)];return D(c)?{kind:`present`,entry:c}:{kind:`no-entry`}}async function aa(e={}){let t=le(e.cwd??process.cwd()),n=vi(t,{homeDir:e.home}),r=n.projectRoot,i=!N(R(r,`.ok`));n.ancestorPromoted?console.log(`[ok] Opened existing project at ${r}`):n.gitRootPromoted&&i&&console.log(`[ok] Initialized OK at ${r} — opened parent of ${z(r,t)} because it contains a .git folder`);let a={mode:e.devMcp?`dev`:`published`},o=await b(r),s;try{s=p(r,{contentDir:n.defaultContentDir})}catch(t){let n=E.claude.configPath(r,e.home);return{projectRoot:r,contentCreated:[],contentUpdated:[],contentSkipped:[],editors:[],projectSkills:[],legacyProjectConfigs:[],didGitInit:o.didInit,rootGitignoreCreated:!1,mcpAction:`failed`,mcpPath:n,mcpError:`Content scaffolding failed: ${t instanceof Error?t.message:String(t)}`,sharing:{kind:`no-exclude`,reason:`no-git`,localOnlyRequested:!1}}}let c=!1;if(o.didInit)try{c=g(r)===`created`}catch(e){console.warn(`[ok] Skipping .gitignore seed at ${r}: ${e instanceof Error?e.message:String(e)}`)}let l=await Wi({scope:e.scope,mcp:e.mcp,isTTY:e.isTTY,promptFn:e.promptFn}),u=e.editors??la(r,e.home),d=e.editors??ne.filter(e=>E[e].projectConfigPath!==void 0),f=T(u),h=T(d),_=e.mcp===!1||l===null,v=Array.from(new Map([...f,..._?[]:h].map(e=>[e.id,e])).values()),y=f.filter(t=>$i(t,r,e.home)),x=[],S=[],C=new Set;for(let t of v){if(_){let n=``;try{n=t.configPath(r,e.home)}catch{}x.push({editorId:t.id,label:t.label,action:`skipped-flag`,configPath:n,serverName:t.serverName(r)});continue}if(Vi(l)&&f.includes(t)&&x.push(ea(t,r,a,e.home)),Hi(l)&&h.includes(t)&&t.projectConfigPath){let n=t.projectConfigPath(r),i=ea(t,r,a,e.home,n);x.push(i),(i.action===`written`||i.action===`overwritten`)&&C.add(n)}}let w=new Set;for(let e of h){let t=e.projectSkillPath?.(r);!t||w.has(t)||(w.add(t),S.push(te(e,r)))}let ee=!_&&l!==null&&Hi(l)?h.filter(e=>!e.projectConfigPath).map(e=>e.label):void 0,re=_?[]:y.map(e=>ta(e,r)).filter(e=>e!==void 0).filter(e=>!C.has(e.path)),D=y.some(e=>e.id===`claude`)&&!_?Qi(r,a):void 0,O=await(e.installUserSkill??m)({home:e.home}),k=_?`skipped-flag`:`skipped-missing`,A=x.find(e=>e.editorId===`claude`)??x[0]??{action:k,configPath:E.claude.configPath(r,e.home)},j=await oa({projectRoot:r,desiredMode:await Ki({sharing:e.sharing,projectRoot:r,isTTY:e.isTTY,promptFn:e.sharingPromptFn}),explicitFlag:e.sharing});return{projectRoot:r,contentCreated:s.created,contentUpdated:s.updated,contentSkipped:s.skipped,editors:x,projectSkills:S,legacyProjectConfigs:re,launchJson:D,skillInstall:O,didGitInit:o.didInit,rootGitignoreCreated:c,mcpAction:A.action,mcpPath:A.configPath,mcpError:`error`in A?A.error:void 0,projectScopeUnsupportedLabels:ee,sharing:j}}async function oa(e){let{projectRoot:t,desiredMode:n,explicitFlag:r}=e,i=yt(t);if(i===`no-git`)return{kind:`no-exclude`,reason:`no-git`,localOnlyRequested:r===`local-only`};let a=gt(t);if(n===`local-only`){let e=_t(t,a);if(e.kind===`refused-tracked`){let t=e;return{kind:`refused-tracked`,tracked:t.tracked,remediation:t.remediation}}return e.kind===`no-exclude`?{kind:`no-exclude`,reason:e.reason,localOnlyRequested:r===`local-only`}:sa(t,e,`add`)}if(i===`shared`)return{kind:`applied`,mode:`shared`,action:`noop`,appended:[],alreadyPresent:[],removed:[]};let o=vt(t,a);return o.kind===`no-exclude`?{kind:`no-exclude`,reason:o.reason,localOnlyRequested:!1}:sa(t,o,`remove`)}function sa(e,t,n){let r=yt(e);return n===`add`?{kind:`applied`,mode:r,action:t.appended.length>0?`added`:`noop`,appended:t.appended,alreadyPresent:t.alreadyPresent,removed:[]}:{kind:`applied`,mode:r,action:`removed`,appended:[],alreadyPresent:[],removed:t.removed}}function ca(e,t){let n=[],r=e.editors.some(e=>e.action===`written`||e.action===`overwritten`),i=e.editors.some(e=>e.action===`failed`)||e.projectSkills.some(e=>e.action===`failed`),a=e.editors.length>0&&e.editors.every(e=>e.action===`skipped-flag`),o=e.editors.length>0&&e.editors.every(e=>e.action===`skipped-missing`),s=e=>{let n=e.configPath.startsWith(t)?z(t,e.configPath):e.configPath;switch(e.action){case`created`:return` app preview server ${n} configured for Claude Code Desktop embedded browser`;case`merged`:return` app preview server ${n} updated for Claude Code Desktop embedded browser`;case`failed`:return` app preview server ${n} FAILED: ${e.error}`}};e.didGitInit&&n.push(`Initialized git repo at ${t}/.git/ (default branch: main)`),e.rootGitignoreCreated&&n.push(`Seeded .gitignore at ${t}/.gitignore (.DS_Store)`);let c=R(t,`.ok`);if(e.contentCreated.length>0||e.contentUpdated.length>0?(n.push(M(`Content scaffolded at ${c}/`)),e.contentCreated.length>0&&n.push(` Created: ${e.contentCreated.join(`, `)}`),e.contentUpdated.length>0&&n.push(` Updated: ${e.contentUpdated.join(`, `)}`)):n.push(M(`Content already present at ${c}/`)),e.contentSkipped.length>0&&n.push(` Skipped (already exist): ${e.contentSkipped.join(`, `)}`),n.push(``),e.mcpError&&e.editors.length===0)n.push(`Warning: ${e.mcpError}`);else if(e.editors.length===0)if(n.push(M(`MCP server configuration:`)),e.mcpAction===`skipped-flag`)n.push(` MCP config not written — use without --no-mcp to configure editors`);else if(e.projectScopeUnsupportedLabels&&e.projectScopeUnsupportedLabels.length>0){let t=e.projectScopeUnsupportedLabels.join(`, `),r=e.projectScopeUnsupportedLabels.length===1?`does`:`do`;n.push(` ${t} ${r} not support project-level config; skipped`)}else n.push(` No supported editor config directories detected; skipped MCP registration`);else if(a)n.push(`MCP config not written — use without --no-mcp to configure editors`);else if(o)n.push(M(`MCP server configuration:`)),n.push(` No supported editor config directories detected; skipped MCP registration`);else{n.push(M(`MCP server configuration:`));for(let r of e.editors){let i=r.configPath.startsWith(t)?z(t,r.configPath):r.configPath.replace(/^\/Users\/[^/]+/,`~`),a=r.serverName===`open-knowledge`?``:` (${r.serverName})`,o=r.configScope===`project`?` (project)`:``,c=`${r.label}${o}`,l=` `.repeat(Math.max(1,20-c.length)),u=r.editorId===`claude-desktop`&&(r.action===`written`||r.action===`overwritten`)?` — quit and relaunch Claude Desktop to activate`:``;switch(r.action){case`written`:n.push(` ${c}${l}${i} ${k(`registered`)}${a}${u}`);break;case`overwritten`:n.push(` ${c}${l}${i} ${k(`updated`)}${a}${u}`);break;case`skipped-missing`:n.push(` ${c}${l}${i} config root missing; skipped`);break;case`failed`:n.push(` ${c}${l}${i} ${A(`FAILED`)}: ${r.error}`);break;case`skipped-flag`:break}r.editorId===`claude`&&e.launchJson&&n.push(s(e.launchJson))}if(e.projectScopeUnsupportedLabels&&e.projectScopeUnsupportedLabels.length>0){let t=e.projectScopeUnsupportedLabels.join(`, `),r=e.projectScopeUnsupportedLabels.length===1?`does`:`do`;n.push(` ${t} ${r} not support project-level config; skipped`)}}if(e.projectSkills.length>0){n.push(``),n.push(M(`Project-local skills:`));for(let r of e.projectSkills){let e=`${r.label} (project)`,i=` `.repeat(Math.max(1,20-e.length)),a=r.path?z(t,r.path):``;switch(r.action){case`written`:n.push(` ${e}${i}${a} ${k(`installed`)}`);break;case`overwritten`:n.push(` ${e}${i}${a} ${k(`updated`)}`);break;case`skipped-unsupported`:n.push(` ${e}${i}no known project skill surface; skipped`);break;case`failed`:n.push(` ${e}${i}${a} ${A(`FAILED`)}: ${r.error}`);break}}}if(i&&(n.push(``),n.push(`For failed editors, add the MCP server entry or project skill manually. See:`),n.push(` https://github.com/inkeep/open-knowledge#mcp-setup`)),e.legacyProjectConfigs.length>0){n.push(``),n.push(`Project MCP configs found:`);for(let r of e.legacyProjectConfigs)n.push(` ${r.label} ${z(t,r.path)}`);n.push(` These project-local files may override the global config. Remove them if you want fully user-scoped MCP setup in this project.`)}if(e.skillInstall)switch(n.push(``),n.push(M(`User-global skill:`)),e.skillInstall){case`installed`:n.push(` open-knowledge ${k(`installed to detected agent hosts`)} via \`npx skills\``);break;case`skip-current`:n.push(` open-knowledge ${k(`already installed at current version`)}`);break;case`failed`:n.push(` ${j(`open-knowledge install failed — MCP still configured; run manually:`)}`),n.push(` ${j(` npx skills@~1.5.0 add <bundled-path> --agent '*' -g -y --copy`)}`);break}if(e.preview?(n.push(``),n.push(ie(e.preview,t))):e.previewWarning&&(n.push(``),n.push(`Content preview unavailable: ${e.previewWarning}`)),n.push(``),n.push(...da(e.sharing,t)),r){let t=new Set,r=e.editors.filter(e=>e.action===`written`||e.action===`overwritten`).filter(e=>!t.has(e.editorId)&&t.add(e.editorId)).map(e=>e.label);n.push(``),n.push(`${k(`✓`)} ${M(`Next steps:`)}`),n.push(` 1. Open your editor (${O(r.join(` / `))})`),n.push(` 2. Approve the MCP server when prompted`),n.push(` 3. (Optional) scaffold the starter knowledge-base structure:`),n.push(` - ${O(`ok seed`)} — empty repo, Karpathy 3-layer`),n.push(` - ${O(`mcp__open-knowledge__discover`)} — existing repo, extract conventions`),n.push(` 4. Use the MCP workflow tools as you build the wiki:`),n.push(` - ${O(`mcp__open-knowledge__ingest`)} — capture an external source`),n.push(` - ${O(`mcp__open-knowledge__research`)} — gather sources and write findings`),n.push(` - ${O(`mcp__open-knowledge__consolidate`)} — promote research to canonical articles`)}return n.join(`
|
|
302
302
|
`)}function la(e,t){let n=[];for(let r of ne)$i(E[r],e,t)&&n.push(r);return n}function ua(){return new i(`init`).description(`Scaffold .ok/ in the current directory and register the MCP server for your editor(s)`).option(`--mcp`,`Register the MCP server for selected editors (default: true)`,!0).option(`--no-mcp`,`Scaffold the .ok/ directory but do not touch MCP config`).option(`--dev-mcp`,`Register a local dev MCP entry using node + packages/cli/dist/cli.mjs with debug logging`).addOption(new r(`--scope <scope>`,`Write MCP config at user level, project level, or both`).choices([`user`,`project`,`both`])).addOption(new r(`--shared`,`Commit OK config alongside content (the default for fresh repos)`).conflicts(`localOnly`)).addOption(new r(`--local-only`,`Keep OK config out of git via .git/info/exclude (per-clone, not committed)`).conflicts(`shared`)).action(async e=>{let t=process.cwd(),n=e.shared?`shared`:e.localOnly?`local-only`:void 0,r;try{r=await aa({cwd:t,mcp:e.mcp,devMcp:e.devMcp,scope:e.scope,sharing:n})}catch(e){if(e instanceof h){process.stderr.write(`open-knowledge requires git to initialize a parent repo. Install git or run 'git init' yourself, then re-run.
|
|
303
|
-
`),e.stderr&&process.stderr.write(`${e.stderr.trim()}\n`),process.exitCode=1;return}throw e}try{let{previewContent:e}=await import(`./preview-
|
|
303
|
+
`),e.stderr&&process.stderr.write(`${e.stderr.trim()}\n`),process.exitCode=1;return}throw e}try{let{previewContent:e}=await import(`./preview-DVTHD8sU.mjs`),{loadConfig:t}=await import(`./loader-C8nqTo1Q.mjs`),{resolveContentDir:n}=await import(`./dist-n9uYOrGl.mjs`),{config:i}=t(r.projectRoot),a=n(i,r.projectRoot);r.preview=e({projectDir:r.projectRoot,contentDir:a})}catch(e){r.previewWarning=e instanceof Error?e.message:String(e)}process.stdout.write(`${ca(r,r.projectRoot)}\n`),(r.editors.some(e=>e.action===`failed`)||r.mcpAction===`failed`)&&(process.exitCode=1)})}function da(e,t){let n=[];switch(e.kind){case`applied`:return n.push(M(`Sharing mode:`)),e.mode===`local-only`?e.action===`added`?n.push(` ${k(`local-only`)} — appended ${e.appended.length} path(s) to ${M(`${t}/.git/info/exclude`)} (per-clone, not committed).`):e.action===`noop`&&e.alreadyPresent.length>0?n.push(` ${k(`local-only`)} — already excluded; nothing to do.`):n.push(` ${k(`local-only`)}`):e.action===`removed`?n.push(` ${k(`shared`)} — removed OK paths from ${M(`${t}/.git/info/exclude`)}; commit the files to share with teammates.`):n.push(` ${k(`shared`)} — OK config will be committed alongside content.`),n;case`refused-tracked`:n.push(j(`Sharing mode: switch to local-only deferred`));for(let t of e.remediation.split(`
|
|
304
304
|
`))n.push(t.length>0?` ${t}`:``);return n.push(` Re-run ${O(`ok config-sharing unshare`)} after resolving to complete the switch.`),n;case`no-exclude`:if(e.localOnlyRequested)n.push(j(`Sharing mode: --local-only requested but no git repo found — option ignored`)),n.push(` Run ${O(`git init`)} (or open this folder via OK Desktop, which can scaffold a repo) and then ${O(`ok config-sharing unshare`)}.`);else if(e.reason===`no-git`)return[];else n.push(j(`Sharing mode unavailable: ${e.reason}.`));return n}}export{pt as A,gt as C,ft as D,vt as E,Je as F,Te as I,U as L,ht as M,ot as N,lt as O,Ye as P,bt as S,yt as T,na as _,oa as a,_t as b,ca as c,ra as d,Wi as f,ea as g,Qi as h,Zi as i,dt as j,ut as k,da as l,aa as m,Yi as n,ia as o,Ki as p,Xi as r,la as s,Ji as t,ua as u,Fi as v,xt as w,St as x,vi as y};
|
|
305
|
-
//# sourceMappingURL=init-
|
|
305
|
+
//# sourceMappingURL=init-CMfDQGkl.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{m as e}from"./init-CMfDQGkl.mjs";export{e as runInit};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{n as e}from"./loader-C9FLjkmp.mjs";export{e as loadConfig};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{Ha as e,No as t,Va as n,Wa as r}from"./server-lock-CN2YHwpP-
|
|
1
|
+
import{Ha as e,No as t,Va as n,Wa as r}from"./server-lock-CN2YHwpP-BhBKViGp.mjs";import{_ as i,ca as a,la as o}from"./dist-CX2NKvL3.mjs";import{t as s}from"./constants-guHl6645.mjs";import{t as c}from"./is-object-Cg453afR.mjs";import{existsSync as l,readFileSync as u}from"node:fs";import{resolve as d}from"node:path";import{realpath as f}from"node:fs/promises";async function p(e){let t=d(e);try{return await f(t)}catch(e){if(e.code!==`ENOENT`){let n=e instanceof Error?e.message:String(e);console.warn(`[normalize-cwd] realpath failed for ${t}: ${n}`)}return t}}var m=t();function h(e,t){let n={...e};for(let r of Object.keys(t)){let i=e[r],a=t[r];c(a)&&c(i)?n[r]=h(i,a):a!==void 0&&(n[r]=a)}return n}function g(e){if(!l(e))return{value:null,path:e,source:null,doc:null};let t;try{t=u(e,`utf-8`)}catch(t){return console.warn(`[config] Failed to read ${e}: ${t instanceof Error?t.message:t}`),{value:null,path:e,source:null,doc:null}}let n=(0,m.parseDocument)(t);if(n.errors.length>0)return console.warn(`[config] Failed to parse ${e}: ${n.errors.map(e=>e.message).join(`; `)}`),{value:null,path:e,source:t,doc:null};let r=n.toJSON();return c(r)?{value:r,path:e,source:t,doc:n}:{value:null,path:e,source:t,doc:n}}function _(e,t){return e.map(e=>{let n=e.path.map(e=>typeof e==`symbol`?String(e):e),i={path:n,message:e.message,issueCode:e.code};if(t.doc!==null&&t.source!==null){let e=r({file:t.path,source:t.source,doc:t.doc,path:n});if(e!==void 0)return{...i,source:e}}return i})}function v(t){let r=t??process.cwd(),c=[],l=o(`user`,r),u=a({absPath:l}),f={};u.valid&&u.source!==void 0?(f=h(f,u.value),c.push(l)):u.valid;let p=d(r,`.ok`,s),m=g(p);if(m.value!==null){let t=n({value:m.value,file:m.path,source:m.source,doc:m.doc});if(t.length>0)throw Error(t.map(e).join(`
|
|
2
2
|
|
|
3
3
|
`));f=h(f,m.value),c.push(p)}let v=i.safeParse(f);if(!v.success){let t={code:`SCHEMA_INVALID`,issues:_(v.error.issues,m)};throw Error(e(t))}return{config:v.data,sources:c}}function y(e){let t=e.cacheMs??1e3,n=e.loadConfigFn??v,r=new Map,i=new Map,a=p(e.startupCwd);return async o=>{let s=await p(o??e.startupCwd),c=Date.now(),l=r.get(s);if(l&&l.expiresAt>c)return l.config;let u=i.get(s);if(u)return await u;let d=(async()=>{if(s===await a)return r.set(s,{config:e.startupConfig,expiresAt:Date.now()+t}),e.startupConfig;let i=n(s).config;return r.set(s,{config:i,expiresAt:Date.now()+t}),i})();i.set(s,d);try{return await d}finally{i.delete(s)}}}export{v as n,y as t};
|
|
4
|
-
//# sourceMappingURL=loader-
|
|
4
|
+
//# sourceMappingURL=loader-C9FLjkmp.mjs.map
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import{Yt as e}from"./dist-
|
|
1
|
+
import{Yt as e}from"./dist-CX2NKvL3.mjs";import"./constants-guHl6645.mjs";import{existsSync as t,lstatSync as n,readdirSync as r,realpathSync as i,statSync as a}from"node:fs";import{join as o,relative as s}from"node:path";function c(t){let{projectDir:c,contentDir:l,sampleCap:u=5}=t,d=[],f=[];try{n(l)}catch(e){return{totalCount:0,sample:[],contentDir:l,warnings:[`cannot access content directory ${l}: ${e instanceof Error?e.message:String(e)}`]}}let p;try{p=e({projectDir:c,contentDir:l})}catch(e){return{totalCount:0,sample:[],contentDir:l,warnings:[e instanceof Error?e.message:String(e)]}}function m(e){let t;try{t=r(e,{withFileTypes:!0})}catch(t){let n=t instanceof Error?t.message:String(t);d.push(`could not read directory ${s(l,e)||`.`}: ${n}`);return}for(let n of t){let t=o(e,n.name);if(n.isSymbolicLink()){let e;try{e=i(t)}catch(e){let n=e.code;n===`ENOENT`||n===`ELOOP`?d.push(`broken or cyclic symlink: ${s(l,t)}`):d.push(`cannot resolve symlink ${s(l,t)}: ${n??`unknown error`}`);continue}let n;try{n=a(e)}catch{continue}if(n.isDirectory()){let e=s(l,t);if(p.isDirExcluded(e))continue;m(t)}else if(n.isFile()){let e=s(l,t);if(p.isExcluded(e))continue;f.push(e)}}else if(n.isDirectory()){let e=s(l,t);if(p.isDirExcluded(e))continue;m(t)}else if(n.isFile()){let e=s(l,t);if(p.isExcluded(e))continue;f.push(e)}}}return m(l),{totalCount:f.length,sample:f.slice(0,u),contentDir:l,warnings:d}}function l(e,n){let r=[],i=s(n,e.contentDir),a=i===``?`./`:`./${i}`;if(r.push(`Content:`),r.push(` Found ${e.totalCount} markdown files in ${a}`),e.sample.length>0){let t=e.sample.join(`, `),n=e.totalCount>e.sample.length?`, …`:``;r.push(` Sample: ${t}${n}`)}if(e.warnings.length>0)for(let t of e.warnings)r.push(` Warning: ${t}`);return r.push(``),t(o(n,`.ok`,`config.yml`))?(r.push(` To adjust scope, add patterns to .okignore at the project root.`),r.push(` To change the content root, edit .ok/config.yml → content.dir.`)):r.push(" Run `open-knowledge init` to scaffold config + .okignore."),r.push(``),r.push(` Re-check anytime: open-knowledge preview`),r.join(`
|
|
2
2
|
`)}export{c as n,l as t};
|
|
3
|
-
//# sourceMappingURL=preview-
|
|
3
|
+
//# sourceMappingURL=preview-D2CQ6yHX.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{n as e,t}from"./preview-D2CQ6yHX.mjs";export{t as formatPreviewBlock,e as previewContent};
|
package/dist/public/assets/{ActivityModeContent-Bw1oRtQH.js → ActivityModeContent-DbFWb8AO.js}
RENAMED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./ActivityPanelDiffView-BXoGtJMu.js","./chunk-CFjPhJqf.js","./dist-CQw2y-s3.js","./compiler-runtime-CVnuRdak.js","./ActivityPanelDiffView-legcy4jI.css"])))=>i.map(i=>d[i]);
|
|
2
|
-
import{o as e}from"./chunk-CFjPhJqf.js";import{t}from"./preload-helper-2ej06EnG.js";import{n,r,t as i}from"./compiler-runtime-CVnuRdak.js";import{Dr as a,n as o,pt as s,r as c}from"./DocumentContext-o-LUu0wz.js";import{n as l,r as u}from"./dist-CQw2y-s3.js";import{lt as d,o as f,s as p}from"./dist-Dst_hB5H.js";import{t as m,u as h}from"./button-DGf25ccp.js";import{c as g,i as _,l as v,r as y,t as b}from"./agent-presence-CPRnxEOl.js";import{a as x,c as S,i as C,o as w,s as T,t as E}from"./dialog-Bt8vN5IM.js";import{t as ee}from"./chevron-down-BaPMAfbX.js";import{t as te}from"./chevron-right-jyIhGBkw.js";import{i as D,l as O}from"./prop-types-Cf7ylXsu.js";import{d as k}from"./config-context-DhhN0rlf.js";import{n as A}from"./dist-BLu8fLv5.js";import{o as j,u as M}from"./documents-events-DMS5a4By.js";import{i as ne,n as re,t as ie}from"./tooltip-D-omjYEX.js";var ae=h(`rewind`,[[`path`,{d:`M12 6a2 2 0 0 0-3.414-1.414l-6 6a2 2 0 0 0 0 2.828l6 6A2 2 0 0 0 12 18z`,key:`2a1g8i`}],[`path`,{d:`M22 6a2 2 0 0 0-3.414-1.414l-6 6a2 2 0 0 0 0 2.828l6 6A2 2 0 0 0 22 18z`,key:`rg3s36`}]]),N=i(),P=e(n(),1),oe=500,F=64;async function se(e){let t=`/api/agent-activity?agentId=${encodeURIComponent(e)}`,n=await fetch(t),r;try{r=await n.json()}catch(e){throw new s(`Could not parse /api/agent-activity response.`,{cause:e,status:n.status})}if(!n.ok){let e=d.safeParse(r);throw e.success?Error(e.data.title):new s(`/api/agent-activity returned a non-RFC-9457 error response.`,{cause:e.error,status:n.status})}let i=f.safeParse(r);if(!i.success)throw new s(`/api/agent-activity returned a body that did not match AgentActivitySuccessSchema.`,{cause:i.error,status:n.status});return i.data}async function ce(e,t,n){let r=`/api/agent-burst-diff?agentId=${encodeURIComponent(e)}&docName=${encodeURIComponent(t)}&stackIndex=${n}`,i=await fetch(r),a;try{a=await i.json()}catch(e){throw new s(`Could not parse /api/agent-burst-diff response.`,{cause:e,status:i.status})}if(!i.ok){let e=d.safeParse(a);throw e.success?Error(e.data.title):new s(`/api/agent-burst-diff returned a non-RFC-9457 error response.`,{cause:e.error,status:i.status})}let o=p.safeParse(a);if(!o.success)throw new s(`/api/agent-burst-diff returned a body that did not match AgentBurstDiffSuccessSchema.`,{cause:o.error,status:i.status});return o.data.diff}function le(e){let t=(0,N.c)(23),{systemProvider:n}=o(),[r,i]=(0,P.useState)(null),[a,s]=(0,P.useState)(`idle`),[c,l]=(0,P.useState)(null),u;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(u=new _(F),t[0]=u):u=t[0];let d=(0,P.useRef)(u),f=(0,P.useRef)(0),p;t[1]===n?p=t[2]:(p=e=>{let t=f.current+=1;s(`loading`),l(null),se(e).then(r=>{if(f.current!==t)return;let a=de(n,e);i({...r,writingDocs:a}),s(`ready`)}).catch(e=>{f.current===t&&(l(e instanceof Error?e.message:String(e)),s(`error`))})},t[1]=n,t[2]=p);let m=p,h;t[3]!==e||t[4]!==m?(h=()=>{if(!e){f.current+=1,i(null),s(`idle`),l(null),d.current.clear();return}d.current.clear(),m(e);let t=null,n=j(n=>{n.includes(`session-activity`)&&(t&&clearTimeout(t),t=setTimeout(()=>{t=null,m(e)},oe))});return()=>{t&&clearTimeout(t),n()}},t[3]=e,t[4]=m,t[5]=h):h=t[5];let g;t[6]===e?g=t[7]:(g=[e],t[6]=e,t[7]=g),(0,P.useEffect)(h,g);let v,y;t[8]!==e||t[9]!==n?(v=()=>{if(!e||!n)return;let t=()=>{if(!n.awareness)return;let t=de(n,e);i(e=>!e||ue(e.writingDocs,t)?e:{...e,writingDocs:t})},r=n.awareness;if(!r||typeof r.on!=`function`){t();return}r.on(`update`,t),t();let a=setInterval(t,1e3);return()=>{clearInterval(a),typeof r.off==`function`&&r.off(`update`,t)}},y=[e,n],t[8]=e,t[9]=n,t[10]=v,t[11]=y):(v=t[10],y=t[11]),(0,P.useEffect)(v,y);let b;t[12]===e?b=t[13]:(b=async(t,n)=>{if(!e)return``;let r=`${t}\0${n}`,i=d.current.get(r);if(i!==void 0)return i;let a=await ce(e,t,n);return d.current.set(r,a),a},t[12]=e,t[13]=b);let x=b,S;t[14]!==e||t[15]!==m?(S=()=>{e&&m(e)},t[14]=e,t[15]=m,t[16]=S):S=t[16];let C=S,w;return t[17]!==r||t[18]!==c||t[19]!==x||t[20]!==C||t[21]!==a?(w={data:r,status:a,error:c,reload:C,fetchBurstDiff:x},t[17]=r,t[18]=c,t[19]=x,t[20]=C,t[21]=a,t[22]=w):w=t[22],w}function ue(e,t){if(e.size!==t.size)return!1;for(let n of e)if(!t.has(n))return!1;return!0}function de(e,t){let n=new Set;if(!e)return n;let r=e.awareness;if(!b(r))return n;let i=[t,t.startsWith(`agent-`)?t.slice(6):`agent-${t}`];for(let e of r.getStates().values()){let t=e.agentPresence;if(t)for(let e of i){let r=t[e];r&&r.mode===`writing`&&r.currentDoc&&n.add(r.currentDoc)}}return n}var I=r(),fe=(0,P.lazy)(async()=>({default:(await t(()=>import(`./ActivityPanelDiffView-BXoGtJMu.js`),__vite__mapDeps([0,1,2,3,4]),import.meta.url)).ActivityPanelDiffView}));function pe(e,t){let n=Math.max(0,t-e);if(n<6e4){let e=Math.round(n/1e3);return M._({id:`pbwTg6`,values:{seconds:e}})}if(n<36e5){let e=Math.round(n/6e4);return M._({id:`_rP3HI`,values:{minutes:e}})}return new Date(e).toLocaleTimeString(void 0,{hour:`2-digit`,minute:`2-digit`,second:`2-digit`})}function me(e){let t=(0,N.c)(42),{burst:n,docName:r,fetchBurstDiff:i}=e,{_:a}=u(),[o,s]=(0,P.useState)(!1),[c,d]=(0,P.useState)(null),[f,p]=(0,P.useState)(null),[m,h]=(0,P.useState)(!1),[g,_]=(0,P.useState)(L),v,y;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(v=()=>{let e=setInterval(()=>_(Date.now()),3e4);return()=>clearInterval(e)},y=[],t[0]=v,t[1]=y):(v=t[0],y=t[1]),(0,P.useEffect)(v,y);let b;t[2]!==n.stackIndex||t[3]!==c||t[4]!==r||t[5]!==o||t[6]!==i||t[7]!==m?(b=()=>{let e=!o;s(e),e&&c===null&&!m&&(h(!0),p(null),i(r,n.stackIndex).then(e=>{d(e),h(!1)}).catch(e=>{p(e instanceof Error?e.message:String(e)),h(!1)}))},t[2]=n.stackIndex,t[3]=c,t[4]=r,t[5]=o,t[6]=i,t[7]=m,t[8]=b):b=t[8];let x=b,S=n.stackIndex+1,C;t[9]!==a||t[10]!==S||t[11]!==o?(C=a(o?{id:`-i7ik4`,values:{burstNumber:S}}:{id:`EeRZnZ`,values:{burstNumber:S}}),t[9]=a,t[10]=S,t[11]=o,t[12]=C):C=t[12];let w;t[13]===o?w=t[14]:(w=o?(0,I.jsx)(ee,{className:`size-3 shrink-0`,"aria-hidden":`true`}):(0,I.jsx)(te,{className:`size-3 shrink-0`,"aria-hidden":`true`}),t[13]=o,t[14]=w);let T;t[15]!==n.ts||t[16]!==g?(T=pe(n.ts,g),t[15]=n.ts,t[16]=g,t[17]=T):T=t[17];let E;t[18]===T?E=t[19]:(E=(0,I.jsx)(`span`,{className:`font-mono`,children:T}),t[18]=T,t[19]=E);let D;t[20]===n.additions?D=t[21]:(D=(0,I.jsxs)(`span`,{className:`text-green-600 dark:text-green-400`,children:[`+`,n.additions]}),t[20]=n.additions,t[21]=D);let O;t[22]===n.deletions?O=t[23]:(O=(0,I.jsxs)(`span`,{className:`text-red-600 dark:text-red-400`,children:[`−`,n.deletions]}),t[22]=n.deletions,t[23]=O);let k;t[24]!==D||t[25]!==O?(k=(0,I.jsxs)(`span`,{className:`ml-auto font-mono`,children:[D,` `,O]}),t[24]=D,t[25]=O,t[26]=k):k=t[26];let A;t[27]!==o||t[28]!==k||t[29]!==C||t[30]!==w||t[31]!==E||t[32]!==x?(A=(0,I.jsxs)(`button`,{type:`button`,onClick:x,className:`flex w-full items-center gap-2 px-4 py-1.5 text-xs text-muted-foreground hover:bg-muted/40`,"aria-expanded":o,"aria-label":C,children:[w,E,k]}),t[27]=o,t[28]=k,t[29]=C,t[30]=w,t[31]=E,t[32]=x,t[33]=A):A=t[33];let j;t[34]!==c||t[35]!==o||t[36]!==f||t[37]!==m?(j=o?(0,I.jsx)(`div`,{className:`bg-muted/20`,children:m?(0,I.jsx)(`div`,{className:`px-4 py-2 text-xs text-muted-foreground italic`,children:(0,I.jsx)(l,{id:`38foVZ`})}):f?(0,I.jsx)(`div`,{className:`px-4 py-2 text-xs text-destructive`,children:(0,I.jsx)(l,{id:`pmKdif`,values:{loadError:f}})}):c===null?(0,I.jsx)(`div`,{className:`px-4 py-2 text-xs text-muted-foreground italic`,children:(0,I.jsx)(l,{id:`iNFKkm`})}):(0,I.jsx)(P.Suspense,{fallback:(0,I.jsx)(`div`,{className:`px-4 py-2 text-xs text-muted-foreground italic`,children:(0,I.jsx)(l,{id:`38foVZ`})}),children:(0,I.jsx)(fe,{diff:c})})}):null,t[34]=c,t[35]=o,t[36]=f,t[37]=m,t[38]=j):j=t[38];let M;return t[39]!==A||t[40]!==j?(M=(0,I.jsxs)(`div`,{className:`border-t border-border/50`,children:[A,j]}),t[39]=A,t[40]=j,t[41]=M):M=t[41],M}function L(){return Date.now()}function he(e,t){let n=Math.max(0,t-e);if(n<6e4){let e=Math.round(n/1e3);return M._({id:`pbwTg6`,values:{seconds:e}})}if(n<36e5){let e=Math.round(n/6e4);return M._({id:`_rP3HI`,values:{minutes:e}})}let r=Math.round(n/36e5);return M._({id:`nYeBmY`,values:{hours:r}})}function R(e){let t=(0,N.c)(118),{file:n,sessionAlive:r,isWriting:i,onNavigate:a,onUndoLast:o,onUndoAll:s,fetchBurstDiff:c}=e,{_:d}=u(),{docName:f}=n,[p,h]=(0,P.useState)(!1),[_,v]=(0,P.useState)(!1),[y,b]=(0,P.useState)(!1),[D,O]=(0,P.useState)(_e),k,A;if(t[0]===Symbol.for(`react.memo_cache_sentinel`)?(k=()=>{let e=setInterval(()=>O(Date.now()),3e4);return()=>clearInterval(e)},A=[],t[0]=k,t[1]=A):(k=t[0],A=t[1]),(0,P.useEffect)(k,A),n.bursts.length===0)return null;let j=!r||n.bursts.length===0||y,M=n.bursts.length,oe;t[2]!==d||t[3]!==n.bursts.length||t[4]!==r?(oe=r?n.bursts.length===0?d({id:`2fkdnR`}):null:d({id:`NzFvyK`}),t[2]=d,t[3]=n.bursts.length,t[4]=r,t[5]=oe):oe=t[5];let F=oe,se;t[6]!==j||t[7]!==n.docName||t[8]!==o?(se=e=>{e.stopPropagation(),!j&&(b(!0),Promise.resolve(o(n.docName)).finally(()=>b(!1)))},t[6]=j,t[7]=n.docName,t[8]=o,t[9]=se):se=t[9];let ce=se,le;t[10]===j?le=t[11]:(le=e=>{e.stopPropagation(),!j&&v(!0)},t[10]=j,t[11]=le);let ue=le,de;t[12]!==j||t[13]!==n.docName||t[14]!==s?(de=()=>{v(!1),!j&&(b(!0),Promise.resolve(s(n.docName)).finally(()=>b(!1)))},t[12]=j,t[13]=n.docName,t[14]=s,t[15]=de):de=t[15];let fe=de,pe;t[16]===Symbol.for(`react.memo_cache_sentinel`)?(pe=()=>h(ge),t[16]=pe):pe=t[16];let L;t[17]!==d||t[18]!==f||t[19]!==p?(L=d(p?{id:`rVgSRB`,values:{docName:f}}:{id:`tW_yvQ`,values:{docName:f}}),t[17]=d,t[18]=f,t[19]=p,t[20]=L):L=t[20];let R;t[21]===p?R=t[22]:(R=p?(0,I.jsx)(ee,{className:`size-4`,"aria-hidden":`true`}):(0,I.jsx)(te,{className:`size-4`,"aria-hidden":`true`}),t[21]=p,t[22]=R);let z;t[23]!==p||t[24]!==L||t[25]!==R?(z=(0,I.jsx)(`button`,{type:`button`,onClick:pe,className:`flex size-5 shrink-0 items-center justify-center rounded hover:bg-muted`,"aria-expanded":p,"aria-label":L,"data-testid":`activity-panel-file-row-carrot`,children:R}),t[23]=p,t[24]=L,t[25]=R,t[26]=z):z=t[26];let B;t[27]!==n.docName||t[28]!==a?(B=()=>a(n.docName),t[27]=n.docName,t[28]=a,t[29]=B):B=t[29];let V;t[30]!==d||t[31]!==f?(V=d({id:`QcpeeE`,values:{docName:f}}),t[30]=d,t[31]=f,t[32]=V):V=t[32];let H;t[33]!==n.docName||t[34]!==B||t[35]!==V?(H=(0,I.jsx)(`button`,{type:`button`,onClick:B,className:`min-w-0 flex-1 truncate text-left text-foreground hover:underline focus-visible:outline-ring`,"aria-label":V,"data-testid":`activity-panel-file-row-filename`,title:n.docName,children:n.docName}),t[33]=n.docName,t[34]=B,t[35]=V,t[36]=H):H=t[36];let U;t[37]!==d||t[38]!==f?(U=d({id:`m4v3XT`,values:{docName:f}}),t[37]=d,t[38]=f,t[39]=U):U=t[39];let W;t[40]===Symbol.for(`react.memo_cache_sentinel`)?(W=(0,I.jsx)(g,{className:`size-3.5`,"aria-hidden":`true`}),t[40]=W):W=t[40];let G;t[41]!==j||t[42]!==ce||t[43]!==U?(G=(0,I.jsx)(ne,{asChild:!0,children:(0,I.jsx)(m,{type:`button`,variant:`ghost`,size:`icon`,className:`size-6 shrink-0`,onClick:ce,disabled:j,"aria-label":U,"data-testid":`activity-panel-undo-last`,children:W})}),t[41]=j,t[42]=ce,t[43]=U,t[44]=G):G=t[44];let K;t[45]!==d||t[46]!==F?(K=F??d({id:`ArBWJf`}),t[45]=d,t[46]=F,t[47]=K):K=t[47];let q;t[48]===K?q=t[49]:(q=(0,I.jsx)(re,{side:`bottom`,children:K}),t[48]=K,t[49]=q);let J;t[50]!==G||t[51]!==q?(J=(0,I.jsxs)(ie,{children:[G,q]}),t[50]=G,t[51]=q,t[52]=J):J=t[52];let Y;t[53]!==d||t[54]!==f?(Y=d({id:`J2MgzQ`,values:{docName:f}}),t[53]=d,t[54]=f,t[55]=Y):Y=t[55];let ve;t[56]===Symbol.for(`react.memo_cache_sentinel`)?(ve=(0,I.jsx)(ae,{className:`size-3.5`,"aria-hidden":`true`}),t[56]=ve):ve=t[56];let X;t[57]!==j||t[58]!==ue||t[59]!==Y?(X=(0,I.jsx)(ne,{asChild:!0,children:(0,I.jsx)(m,{type:`button`,variant:`ghost`,size:`icon`,className:`size-6 shrink-0`,onClick:ue,disabled:j,"aria-label":Y,"data-testid":`activity-panel-undo-all`,children:ve})}),t[57]=j,t[58]=ue,t[59]=Y,t[60]=X):X=t[60];let Z;t[61]!==d||t[62]!==F?(Z=F??d({id:`mNY1G6`}),t[61]=d,t[62]=F,t[63]=Z):Z=t[63];let ye;t[64]===Z?ye=t[65]:(ye=(0,I.jsx)(re,{side:`bottom`,children:Z}),t[64]=Z,t[65]=ye);let be;t[66]!==X||t[67]!==ye?(be=(0,I.jsxs)(ie,{children:[X,ye]}),t[66]=X,t[67]=ye,t[68]=be):be=t[68];let xe;t[69]===n.additionsTotal?xe=t[70]:(xe=(0,I.jsxs)(`span`,{className:`text-green-600 dark:text-green-400`,children:[`+`,n.additionsTotal]}),t[69]=n.additionsTotal,t[70]=xe);let Se;t[71]===n.deletionsTotal?Se=t[72]:(Se=(0,I.jsxs)(`span`,{className:`text-red-600 dark:text-red-400`,children:[`−`,n.deletionsTotal]}),t[71]=n.deletionsTotal,t[72]=Se);let Ce;t[73]!==xe||t[74]!==Se?(Ce=(0,I.jsxs)(`span`,{className:`shrink-0 font-mono text-xs`,children:[xe,` `,Se]}),t[73]=xe,t[74]=Se,t[75]=Ce):Ce=t[75];let we;t[76]!==n.lastTs||t[77]!==D?(we=he(n.lastTs,D),t[76]=n.lastTs,t[77]=D,t[78]=we):we=t[78];let Q;t[79]===we?Q=t[80]:(Q=(0,I.jsx)(`span`,{className:`shrink-0 font-mono text-[11px] text-muted-foreground`,children:we}),t[79]=we,t[80]=Q);let Te;t[81]===i?Te=t[82]:(Te=i?(0,I.jsx)(`span`,{className:`shrink-0 text-[11px] text-primary animate-pulse`,role:`status`,children:(0,I.jsx)(l,{id:`6q0rnH`})}):null,t[81]=i,t[82]=Te);let Ee;t[83]!==z||t[84]!==H||t[85]!==J||t[86]!==be||t[87]!==Ce||t[88]!==Q||t[89]!==Te?(Ee=(0,I.jsxs)(`div`,{className:`flex items-center gap-2 px-3 py-2 text-sm`,children:[z,H,J,be,Ce,Q,Te]}),t[83]=z,t[84]=H,t[85]=J,t[86]=be,t[87]=Ce,t[88]=Q,t[89]=Te,t[90]=Ee):Ee=t[90];let De;t[91]!==p||t[92]!==c||t[93]!==n.bursts||t[94]!==n.docName?(De=p?(0,I.jsx)(`div`,{children:n.bursts.map(e=>(0,I.jsx)(me,{burst:e,docName:n.docName,fetchBurstDiff:c},`${n.docName}:${e.stackIndex}`))}):null,t[91]=p,t[92]=c,t[93]=n.bursts,t[94]=n.docName,t[95]=De):De=t[95];let Oe;t[96]===Symbol.for(`react.memo_cache_sentinel`)?(Oe=(0,I.jsx)(S,{children:(0,I.jsx)(l,{id:`SEYWYq`})}),t[96]=Oe):Oe=t[96];let ke;t[97]!==M||t[98]!==f?(ke={docName:f,burstCount:M},t[97]=M,t[98]=f,t[99]=ke):ke=t[99];let Ae;t[100]===Symbol.for(`react.memo_cache_sentinel`)?(Ae={0:(0,I.jsx)(`span`,{className:`font-mono text-foreground`})},t[100]=Ae):Ae=t[100];let je;t[101]===ke?je=t[102]:(je=(0,I.jsxs)(T,{children:[Oe,(0,I.jsx)(x,{children:(0,I.jsx)(l,{id:`ZBYKxv`,values:ke,components:Ae})})]}),t[101]=ke,t[102]=je);let Me;t[103]===Symbol.for(`react.memo_cache_sentinel`)?(Me=()=>v(!1),t[103]=Me):Me=t[103];let Ne;t[104]===Symbol.for(`react.memo_cache_sentinel`)?(Ne=(0,I.jsx)(m,{type:`button`,variant:`outline`,onClick:Me,"data-testid":`activity-panel-undo-all-cancel`,children:(0,I.jsx)(l,{id:`dEgA5A`})}),t[104]=Ne):Ne=t[104];let Pe;t[105]===Symbol.for(`react.memo_cache_sentinel`)?(Pe=(0,I.jsx)(l,{id:`MWrUEd`}),t[105]=Pe):Pe=t[105];let Fe;t[106]===fe?Fe=t[107]:(Fe=(0,I.jsxs)(w,{children:[Ne,(0,I.jsx)(m,{type:`button`,variant:`destructive`,onClick:fe,"data-testid":`activity-panel-undo-all-confirm`,children:Pe})]}),t[106]=fe,t[107]=Fe);let Ie;t[108]!==je||t[109]!==Fe?(Ie=(0,I.jsxs)(C,{className:`sm:max-w-md`,children:[je,Fe]}),t[108]=je,t[109]=Fe,t[110]=Ie):Ie=t[110];let $;t[111]!==_||t[112]!==Ie?($=(0,I.jsx)(E,{open:_,onOpenChange:v,children:Ie}),t[111]=_,t[112]=Ie,t[113]=$):$=t[113];let Le;return t[114]!==Ee||t[115]!==De||t[116]!==$?(Le=(0,I.jsxs)(`div`,{className:`border-b border-border`,"data-testid":`activity-panel-file-row`,children:[Ee,De,$]}),t[114]=Ee,t[115]=De,t[116]=$,t[117]=Le):Le=t[117],Le}function ge(e){return!e}function _e(){return Date.now()}async function z(e){let t=await fetch(`/api/agent-undo`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({...e,agentId:e.connectionId})});if(!t.ok)throw Error(`agent-undo failed: HTTP ${t.status}`)}function B(e){return`#/${e.split(`/`).map(e=>encodeURIComponent(e)).join(`/`)}`}function V(e){typeof window>`u`||(window.location.hash=B(e))}function H(){let e=(0,N.c)(2),t;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,I.jsx)(k,{className:`mr-2 size-4 animate-spin`,"aria-hidden":`true`}),e[0]=t):t=e[0];let n;return e[1]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,I.jsxs)(`div`,{className:`flex h-full items-center justify-center p-6 text-muted-foreground`,role:`status`,"aria-busy":`true`,children:[t,(0,I.jsx)(`span`,{className:`text-sm`,children:(0,I.jsx)(l,{id:`ONPvOb`})})]}),e[1]=n):n=e[1],n}function U(e){let t=(0,N.c)(10),{error:n,onRetry:r}=e,i;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(i=(0,I.jsx)(a,{className:`size-6 text-destructive`,"aria-hidden":`true`}),t[0]=i):i=t[0];let o;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(o=(0,I.jsx)(`p`,{className:`text-sm font-medium`,children:(0,I.jsx)(l,{id:`DhLHEb`})}),t[1]=o):o=t[1];let s;t[2]===n?s=t[3]:(s=(0,I.jsxs)(`div`,{className:`space-y-1`,children:[o,(0,I.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:n})]}),t[2]=n,t[3]=s);let c;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(c=(0,I.jsx)(l,{id:`6gRgw8`}),t[4]=c):c=t[4];let u;t[5]===r?u=t[6]:(u=(0,I.jsx)(m,{type:`button`,variant:`outline`,size:`sm`,onClick:r,children:c}),t[5]=r,t[6]=u);let d;return t[7]!==s||t[8]!==u?(d=(0,I.jsxs)(`div`,{className:`flex flex-col items-center gap-3 p-6 text-center`,role:`alert`,"data-testid":`activity-panel-error`,children:[i,s,u]}),t[7]=s,t[8]=u,t[9]=d):d=t[9],d}function W(){let e=(0,N.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,I.jsx)(`div`,{className:`flex h-full items-center justify-center p-6 text-muted-foreground`,"data-testid":`activity-panel-empty`,children:(0,I.jsx)(`p`,{className:`text-sm italic`,children:(0,I.jsx)(l,{id:`iuTKci`})})}),e[0]=t):t=e[0],t}function G(e){let t=(0,N.c)(12),{onExit:n,showBackButton:r}=e,{_:i}=u(),a;t[0]===i?a=t[1]:(a=i({id:`kYL1lH`}),t[0]=i,t[1]=a);let o;t[2]!==n||t[3]!==r?(o=r?(0,I.jsx)(K,{onClick:n}):null,t[2]=n,t[3]=r,t[4]=o):o=t[4];let s;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(s=(0,I.jsx)(`h2`,{className:`truncate text-sm font-medium`,children:(0,I.jsx)(l,{id:`kYL1lH`})}),t[5]=s):s=t[5];let c;t[6]===o?c=t[7]:(c=(0,I.jsxs)(`div`,{className:`flex shrink-0 flex-row items-center gap-2 border-b border-border px-3 py-2`,children:[o,s]}),t[6]=o,t[7]=c);let d;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(d=(0,I.jsx)(`div`,{className:`flex flex-1 items-center justify-center p-6 text-muted-foreground`,children:(0,I.jsx)(`p`,{className:`text-center text-sm italic`,children:(0,I.jsx)(l,{id:`D_WKe_`})})}),t[8]=d):d=t[8];let f;return t[9]!==a||t[10]!==c?(f=(0,I.jsxs)(`section`,{className:`flex h-full min-h-0 flex-col`,"data-testid":`activity-panel-no-agent`,"aria-label":a,children:[c,d]}),t[9]=a,t[10]=c,t[11]=f):f=t[11],f}function K(e){let t=(0,N.c)(9),{onClick:n}=e,{_:r}=u(),i;t[0]===r?i=t[1]:(i=r({id:`ogAuyr`}),t[0]=r,t[1]=i);let a;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(a=(0,I.jsx)(v,{}),t[2]=a):a=t[2];let o;t[3]!==n||t[4]!==i?(o=(0,I.jsx)(ne,{asChild:!0,children:(0,I.jsx)(m,{type:`button`,variant:`ghost`,size:`icon`,className:`size-7 shrink-0`,onClick:n,"aria-label":i,"data-testid":`docpanel-exit-agent-mode`,children:a})}),t[3]=n,t[4]=i,t[5]=o):o=t[5];let s;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(s=(0,I.jsx)(re,{side:`bottom`,children:(0,I.jsx)(l,{id:`ogAuyr`})}),t[6]=s):s=t[6];let c;return t[7]===o?c=t[8]:(c=(0,I.jsxs)(ie,{children:[o,s]}),t[7]=o,t[8]=c),c}function q(e){let t=(0,N.c)(9),{lastTs:n}=e,[r]=(0,P.useState)(J),i;t[0]!==n||t[1]!==r?(i=n?Y(r-n):null,t[0]=n,t[1]=r,t[2]=i):i=t[2];let a=i,o;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(o=(0,I.jsx)(`span`,{className:`font-medium`,children:(0,I.jsx)(l,{id:`LCUy_N`})}),t[3]=o):o=t[3];let s;t[4]===a?s=t[5]:(s=a?(0,I.jsxs)(`span`,{children:[` · `,a]}):null,t[4]=a,t[5]=s);let c;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(c=(0,I.jsx)(`div`,{className:`mt-1 opacity-80`,children:(0,I.jsx)(l,{id:`GK-IRZ`})}),t[6]=c):c=t[6];let u;return t[7]===s?u=t[8]:(u=(0,I.jsxs)(`div`,{className:`border-b border-border bg-muted/40 px-4 py-3 text-xs text-muted-foreground`,"data-testid":`activity-panel-session-ended`,children:[o,s,c]}),t[7]=s,t[8]=u),u}function J(){return Date.now()}function Y(e){let t=Math.max(0,e);if(t<6e4){let e=Math.round(t/1e3);return M._({id:`pbwTg6`,values:{seconds:e}})}if(t<36e5){let e=Math.round(t/6e4);return M._({id:`_rP3HI`,values:{minutes:e}})}let n=Math.round(t/36e5);return M._({id:`nYeBmY`,values:{hours:n}})}function ve(e){let t=(0,N.c)(10),{agent:n,size:r}=e,i=r===void 0?28:r,a;t[0]!==n.color||t[1]!==i?(a={backgroundColor:n.color,width:i,height:i},t[0]=n.color,t[1]=i,t[2]=a):a=t[2];let o=i*.57,s=i*.57,c;t[3]!==n.icon||t[4]!==o||t[5]!==s?(c=(0,I.jsx)(y,{icon:n.icon,width:o,height:s}),t[3]=n.icon,t[4]=o,t[5]=s,t[6]=c):c=t[6];let l;return t[7]!==a||t[8]!==c?(l=(0,I.jsx)(`span`,{className:`inline-flex shrink-0 items-center justify-center rounded-full text-white ring-2 ring-background`,style:a,"aria-hidden":`true`,children:c}),t[7]=a,t[8]=c,t[9]=l):l=t[9],l}function X(e){let t=(0,N.c)(26),{data:n,status:r,error:i,reload:a,fetchBurstDiff:o,onExit:s,onNavigate:c,onUndoLast:d,onUndoAll:f,showBackButton:p}=e,{_:m}=u(),h=n?.files?.[0]?.lastTs??null,g=n?.files?.length??0,_;t[0]===m?_=t[1]:(_=m({id:`kYL1lH`}),t[0]=m,t[1]=_);let v;t[2]!==s||t[3]!==p?(v=p?(0,I.jsx)(K,{onClick:s}):null,t[2]=s,t[3]=p,t[4]=v):v=t[4];let y;t[5]!==n||t[6]!==g||t[7]!==h?(y=n?.agent?(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(ve,{agent:n.agent}),(0,I.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,I.jsx)(`h2`,{className:`truncate text-sm font-medium`,children:n.agent.displayName}),(0,I.jsxs)(`p`,{className:`truncate text-xs text-muted-foreground`,children:[n.sessionAlive?(0,I.jsx)(l,{id:`F6pfE9`}):h===null?(0,I.jsx)(l,{id:`PMyJ9C`}):(0,I.jsx)(l,{id:`237hSL`}),n.files.length>0?(0,I.jsxs)(I.Fragment,{children:[` · `,(0,I.jsx)(l,{id:`u3BOHd`,values:{fileCount:g}})]}):null]})]})]}):(0,I.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,I.jsx)(`h2`,{className:`truncate text-sm font-medium`,children:(0,I.jsx)(l,{id:`kYL1lH`})})}),t[5]=n,t[6]=g,t[7]=h,t[8]=y):y=t[8];let b;t[9]!==v||t[10]!==y?(b=(0,I.jsxs)(`div`,{className:`flex flex-row items-center gap-2 border-b border-border px-3 py-2 shrink-0`,children:[v,y]}),t[9]=v,t[10]=y,t[11]=b):b=t[11];let x;t[12]!==n||t[13]!==i||t[14]!==o||t[15]!==h||t[16]!==c||t[17]!==f||t[18]!==d||t[19]!==a||t[20]!==r?(x=(0,I.jsx)(`div`,{className:`flex-1 overflow-y-auto`,"data-testid":`activity-panel-body`,children:r===`loading`&&n===null?(0,I.jsx)(H,{}):r===`error`&&i?(0,I.jsx)(U,{error:i,onRetry:a}):n===null?(0,I.jsx)(W,{}):(0,I.jsxs)(I.Fragment,{children:[!n.sessionAlive&&h!==null?(0,I.jsx)(q,{lastTs:h}):null,n.files.length===0?(0,I.jsx)(W,{}):n.files.map(e=>(0,I.jsx)(R,{file:e,sessionAlive:n.sessionAlive,isWriting:n.writingDocs.has(e.docName),onNavigate:c,onUndoLast:d,onUndoAll:f,fetchBurstDiff:o},e.docName))]})}),t[12]=n,t[13]=i,t[14]=o,t[15]=h,t[16]=c,t[17]=f,t[18]=d,t[19]=a,t[20]=r,t[21]=x):x=t[21];let S;return t[22]!==_||t[23]!==b||t[24]!==x?(S=(0,I.jsxs)(`section`,{className:`flex h-full min-h-0 flex-col`,"data-testid":`activity-panel`,"aria-label":_,children:[b,x]}),t[22]=_,t[23]=b,t[24]=x,t[25]=S):S=t[25],S}function Z(e){let t=(0,N.c)(29),n;t[0]===e?n=t[1]:(n=e===void 0?{}:e,t[0]=e,t[1]=n);let{showBackButton:r}=n,i=r===void 0?!0:r,{_:a}=u(),{docPanelAgentId:s,closeActivityPanel:l}=o(),{openTargetTransition:d}=c(),{pageMeta:f}=D(),{data:p,status:m,error:h,reload:g,fetchBurstDiff:_}=le(s);if(s===null){let e;return t[2]!==l||t[3]!==i?(e=(0,I.jsx)(G,{onExit:l,showBackButton:i}),t[2]=l,t[3]=i,t[4]=e):e=t[4],e}let v;t[5]!==d||t[6]!==f?(v=e=>{d(O({kind:`doc`,target:e,docName:e},f)),V(e)},t[5]=d,t[6]=f,t[7]=v):v=t[7];let y=v,b;t[8]!==a||t[9]!==p||t[10]!==s||t[11]!==g?(b=async e=>{try{await z({connectionId:s,docName:e,scope:`last`,agentName:p?.agent?.displayName}),g()}catch(e){let t=e,n=t instanceof Error?t.message:String(t);A.error(a({id:`EqrC_R`,values:{message:n}})),g()}},t[8]=a,t[9]=p,t[10]=s,t[11]=g,t[12]=b):b=t[12];let x=b,S;t[13]!==a||t[14]!==p||t[15]!==s||t[16]!==g?(S=async e=>{try{await z({connectionId:s,docName:e,scope:`file`,agentName:p?.agent?.displayName}),A.success(a({id:`pRc-Im`,values:{docName:e}})),g()}catch(e){let t=e,n=t instanceof Error?t.message:String(t);A.error(a({id:`7KeV5F`,values:{message:n}})),g()}},t[13]=a,t[14]=p,t[15]=s,t[16]=g,t[17]=S):S=t[17];let C=S,w;return t[18]!==l||t[19]!==p||t[20]!==h||t[21]!==_||t[22]!==y||t[23]!==C||t[24]!==x||t[25]!==g||t[26]!==i||t[27]!==m?(w=(0,I.jsx)(X,{data:p,status:m,error:h,reload:g,fetchBurstDiff:_,onExit:l,onNavigate:y,onUndoLast:x,onUndoAll:C,showBackButton:i}),t[18]=l,t[19]=p,t[20]=h,t[21]=_,t[22]=y,t[23]=C,t[24]=x,t[25]=g,t[26]=i,t[27]=m,t[28]=w):w=t[28],w}export{Z as ActivityModeContent};
|
|
2
|
+
import{o as e}from"./chunk-CFjPhJqf.js";import{t}from"./preload-helper-2ej06EnG.js";import{n,r,t as i}from"./compiler-runtime-CVnuRdak.js";import{Or as a,n as o,pt as s,r as c}from"./DocumentContext-B2qgy31k.js";import{n as l,r as u}from"./dist-CQw2y-s3.js";import{lt as d,o as f,s as p}from"./dist-BrFh1X3E.js";import{t as m,u as h}from"./button-DGf25ccp.js";import{c as g,i as _,l as v,r as y,t as b}from"./agent-presence-CPRnxEOl.js";import{a as x,c as S,i as C,o as w,s as T,t as E}from"./dialog-Bt8vN5IM.js";import{t as ee}from"./chevron-down-BaPMAfbX.js";import{t as te}from"./chevron-right-jyIhGBkw.js";import{i as D,l as O}from"./prop-types-DAdpyyQb.js";import{d as k}from"./config-context-DhhN0rlf.js";import{n as A}from"./dist-BLu8fLv5.js";import{o as j,u as M}from"./documents-events-keB3Tua2.js";import{i as ne,n as re,t as ie}from"./tooltip-D-omjYEX.js";var ae=h(`rewind`,[[`path`,{d:`M12 6a2 2 0 0 0-3.414-1.414l-6 6a2 2 0 0 0 0 2.828l6 6A2 2 0 0 0 12 18z`,key:`2a1g8i`}],[`path`,{d:`M22 6a2 2 0 0 0-3.414-1.414l-6 6a2 2 0 0 0 0 2.828l6 6A2 2 0 0 0 22 18z`,key:`rg3s36`}]]),N=i(),P=e(n(),1),oe=500,F=64;async function se(e){let t=`/api/agent-activity?agentId=${encodeURIComponent(e)}`,n=await fetch(t),r;try{r=await n.json()}catch(e){throw new s(`Could not parse /api/agent-activity response.`,{cause:e,status:n.status})}if(!n.ok){let e=d.safeParse(r);throw e.success?Error(e.data.title):new s(`/api/agent-activity returned a non-RFC-9457 error response.`,{cause:e.error,status:n.status})}let i=f.safeParse(r);if(!i.success)throw new s(`/api/agent-activity returned a body that did not match AgentActivitySuccessSchema.`,{cause:i.error,status:n.status});return i.data}async function ce(e,t,n){let r=`/api/agent-burst-diff?agentId=${encodeURIComponent(e)}&docName=${encodeURIComponent(t)}&stackIndex=${n}`,i=await fetch(r),a;try{a=await i.json()}catch(e){throw new s(`Could not parse /api/agent-burst-diff response.`,{cause:e,status:i.status})}if(!i.ok){let e=d.safeParse(a);throw e.success?Error(e.data.title):new s(`/api/agent-burst-diff returned a non-RFC-9457 error response.`,{cause:e.error,status:i.status})}let o=p.safeParse(a);if(!o.success)throw new s(`/api/agent-burst-diff returned a body that did not match AgentBurstDiffSuccessSchema.`,{cause:o.error,status:i.status});return o.data.diff}function le(e){let t=(0,N.c)(23),{systemProvider:n}=o(),[r,i]=(0,P.useState)(null),[a,s]=(0,P.useState)(`idle`),[c,l]=(0,P.useState)(null),u;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(u=new _(F),t[0]=u):u=t[0];let d=(0,P.useRef)(u),f=(0,P.useRef)(0),p;t[1]===n?p=t[2]:(p=e=>{let t=f.current+=1;s(`loading`),l(null),se(e).then(r=>{if(f.current!==t)return;let a=de(n,e);i({...r,writingDocs:a}),s(`ready`)}).catch(e=>{f.current===t&&(l(e instanceof Error?e.message:String(e)),s(`error`))})},t[1]=n,t[2]=p);let m=p,h;t[3]!==e||t[4]!==m?(h=()=>{if(!e){f.current+=1,i(null),s(`idle`),l(null),d.current.clear();return}d.current.clear(),m(e);let t=null,n=j(n=>{n.includes(`session-activity`)&&(t&&clearTimeout(t),t=setTimeout(()=>{t=null,m(e)},oe))});return()=>{t&&clearTimeout(t),n()}},t[3]=e,t[4]=m,t[5]=h):h=t[5];let g;t[6]===e?g=t[7]:(g=[e],t[6]=e,t[7]=g),(0,P.useEffect)(h,g);let v,y;t[8]!==e||t[9]!==n?(v=()=>{if(!e||!n)return;let t=()=>{if(!n.awareness)return;let t=de(n,e);i(e=>!e||ue(e.writingDocs,t)?e:{...e,writingDocs:t})},r=n.awareness;if(!r||typeof r.on!=`function`){t();return}r.on(`update`,t),t();let a=setInterval(t,1e3);return()=>{clearInterval(a),typeof r.off==`function`&&r.off(`update`,t)}},y=[e,n],t[8]=e,t[9]=n,t[10]=v,t[11]=y):(v=t[10],y=t[11]),(0,P.useEffect)(v,y);let b;t[12]===e?b=t[13]:(b=async(t,n)=>{if(!e)return``;let r=`${t}\0${n}`,i=d.current.get(r);if(i!==void 0)return i;let a=await ce(e,t,n);return d.current.set(r,a),a},t[12]=e,t[13]=b);let x=b,S;t[14]!==e||t[15]!==m?(S=()=>{e&&m(e)},t[14]=e,t[15]=m,t[16]=S):S=t[16];let C=S,w;return t[17]!==r||t[18]!==c||t[19]!==x||t[20]!==C||t[21]!==a?(w={data:r,status:a,error:c,reload:C,fetchBurstDiff:x},t[17]=r,t[18]=c,t[19]=x,t[20]=C,t[21]=a,t[22]=w):w=t[22],w}function ue(e,t){if(e.size!==t.size)return!1;for(let n of e)if(!t.has(n))return!1;return!0}function de(e,t){let n=new Set;if(!e)return n;let r=e.awareness;if(!b(r))return n;let i=[t,t.startsWith(`agent-`)?t.slice(6):`agent-${t}`];for(let e of r.getStates().values()){let t=e.agentPresence;if(t)for(let e of i){let r=t[e];r&&r.mode===`writing`&&r.currentDoc&&n.add(r.currentDoc)}}return n}var I=r(),fe=(0,P.lazy)(async()=>({default:(await t(()=>import(`./ActivityPanelDiffView-BXoGtJMu.js`),__vite__mapDeps([0,1,2,3,4]),import.meta.url)).ActivityPanelDiffView}));function pe(e,t){let n=Math.max(0,t-e);if(n<6e4){let e=Math.round(n/1e3);return M._({id:`pbwTg6`,values:{seconds:e}})}if(n<36e5){let e=Math.round(n/6e4);return M._({id:`_rP3HI`,values:{minutes:e}})}return new Date(e).toLocaleTimeString(void 0,{hour:`2-digit`,minute:`2-digit`,second:`2-digit`})}function me(e){let t=(0,N.c)(42),{burst:n,docName:r,fetchBurstDiff:i}=e,{_:a}=u(),[o,s]=(0,P.useState)(!1),[c,d]=(0,P.useState)(null),[f,p]=(0,P.useState)(null),[m,h]=(0,P.useState)(!1),[g,_]=(0,P.useState)(L),v,y;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(v=()=>{let e=setInterval(()=>_(Date.now()),3e4);return()=>clearInterval(e)},y=[],t[0]=v,t[1]=y):(v=t[0],y=t[1]),(0,P.useEffect)(v,y);let b;t[2]!==n.stackIndex||t[3]!==c||t[4]!==r||t[5]!==o||t[6]!==i||t[7]!==m?(b=()=>{let e=!o;s(e),e&&c===null&&!m&&(h(!0),p(null),i(r,n.stackIndex).then(e=>{d(e),h(!1)}).catch(e=>{p(e instanceof Error?e.message:String(e)),h(!1)}))},t[2]=n.stackIndex,t[3]=c,t[4]=r,t[5]=o,t[6]=i,t[7]=m,t[8]=b):b=t[8];let x=b,S=n.stackIndex+1,C;t[9]!==a||t[10]!==S||t[11]!==o?(C=a(o?{id:`-i7ik4`,values:{burstNumber:S}}:{id:`EeRZnZ`,values:{burstNumber:S}}),t[9]=a,t[10]=S,t[11]=o,t[12]=C):C=t[12];let w;t[13]===o?w=t[14]:(w=o?(0,I.jsx)(ee,{className:`size-3 shrink-0`,"aria-hidden":`true`}):(0,I.jsx)(te,{className:`size-3 shrink-0`,"aria-hidden":`true`}),t[13]=o,t[14]=w);let T;t[15]!==n.ts||t[16]!==g?(T=pe(n.ts,g),t[15]=n.ts,t[16]=g,t[17]=T):T=t[17];let E;t[18]===T?E=t[19]:(E=(0,I.jsx)(`span`,{className:`font-mono`,children:T}),t[18]=T,t[19]=E);let D;t[20]===n.additions?D=t[21]:(D=(0,I.jsxs)(`span`,{className:`text-green-600 dark:text-green-400`,children:[`+`,n.additions]}),t[20]=n.additions,t[21]=D);let O;t[22]===n.deletions?O=t[23]:(O=(0,I.jsxs)(`span`,{className:`text-red-600 dark:text-red-400`,children:[`−`,n.deletions]}),t[22]=n.deletions,t[23]=O);let k;t[24]!==D||t[25]!==O?(k=(0,I.jsxs)(`span`,{className:`ml-auto font-mono`,children:[D,` `,O]}),t[24]=D,t[25]=O,t[26]=k):k=t[26];let A;t[27]!==o||t[28]!==k||t[29]!==C||t[30]!==w||t[31]!==E||t[32]!==x?(A=(0,I.jsxs)(`button`,{type:`button`,onClick:x,className:`flex w-full items-center gap-2 px-4 py-1.5 text-xs text-muted-foreground hover:bg-muted/40`,"aria-expanded":o,"aria-label":C,children:[w,E,k]}),t[27]=o,t[28]=k,t[29]=C,t[30]=w,t[31]=E,t[32]=x,t[33]=A):A=t[33];let j;t[34]!==c||t[35]!==o||t[36]!==f||t[37]!==m?(j=o?(0,I.jsx)(`div`,{className:`bg-muted/20`,children:m?(0,I.jsx)(`div`,{className:`px-4 py-2 text-xs text-muted-foreground italic`,children:(0,I.jsx)(l,{id:`38foVZ`})}):f?(0,I.jsx)(`div`,{className:`px-4 py-2 text-xs text-destructive`,children:(0,I.jsx)(l,{id:`pmKdif`,values:{loadError:f}})}):c===null?(0,I.jsx)(`div`,{className:`px-4 py-2 text-xs text-muted-foreground italic`,children:(0,I.jsx)(l,{id:`iNFKkm`})}):(0,I.jsx)(P.Suspense,{fallback:(0,I.jsx)(`div`,{className:`px-4 py-2 text-xs text-muted-foreground italic`,children:(0,I.jsx)(l,{id:`38foVZ`})}),children:(0,I.jsx)(fe,{diff:c})})}):null,t[34]=c,t[35]=o,t[36]=f,t[37]=m,t[38]=j):j=t[38];let M;return t[39]!==A||t[40]!==j?(M=(0,I.jsxs)(`div`,{className:`border-t border-border/50`,children:[A,j]}),t[39]=A,t[40]=j,t[41]=M):M=t[41],M}function L(){return Date.now()}function he(e,t){let n=Math.max(0,t-e);if(n<6e4){let e=Math.round(n/1e3);return M._({id:`pbwTg6`,values:{seconds:e}})}if(n<36e5){let e=Math.round(n/6e4);return M._({id:`_rP3HI`,values:{minutes:e}})}let r=Math.round(n/36e5);return M._({id:`nYeBmY`,values:{hours:r}})}function R(e){let t=(0,N.c)(118),{file:n,sessionAlive:r,isWriting:i,onNavigate:a,onUndoLast:o,onUndoAll:s,fetchBurstDiff:c}=e,{_:d}=u(),{docName:f}=n,[p,h]=(0,P.useState)(!1),[_,v]=(0,P.useState)(!1),[y,b]=(0,P.useState)(!1),[D,O]=(0,P.useState)(_e),k,A;if(t[0]===Symbol.for(`react.memo_cache_sentinel`)?(k=()=>{let e=setInterval(()=>O(Date.now()),3e4);return()=>clearInterval(e)},A=[],t[0]=k,t[1]=A):(k=t[0],A=t[1]),(0,P.useEffect)(k,A),n.bursts.length===0)return null;let j=!r||n.bursts.length===0||y,M=n.bursts.length,oe;t[2]!==d||t[3]!==n.bursts.length||t[4]!==r?(oe=r?n.bursts.length===0?d({id:`2fkdnR`}):null:d({id:`NzFvyK`}),t[2]=d,t[3]=n.bursts.length,t[4]=r,t[5]=oe):oe=t[5];let F=oe,se;t[6]!==j||t[7]!==n.docName||t[8]!==o?(se=e=>{e.stopPropagation(),!j&&(b(!0),Promise.resolve(o(n.docName)).finally(()=>b(!1)))},t[6]=j,t[7]=n.docName,t[8]=o,t[9]=se):se=t[9];let ce=se,le;t[10]===j?le=t[11]:(le=e=>{e.stopPropagation(),!j&&v(!0)},t[10]=j,t[11]=le);let ue=le,de;t[12]!==j||t[13]!==n.docName||t[14]!==s?(de=()=>{v(!1),!j&&(b(!0),Promise.resolve(s(n.docName)).finally(()=>b(!1)))},t[12]=j,t[13]=n.docName,t[14]=s,t[15]=de):de=t[15];let fe=de,pe;t[16]===Symbol.for(`react.memo_cache_sentinel`)?(pe=()=>h(ge),t[16]=pe):pe=t[16];let L;t[17]!==d||t[18]!==f||t[19]!==p?(L=d(p?{id:`rVgSRB`,values:{docName:f}}:{id:`tW_yvQ`,values:{docName:f}}),t[17]=d,t[18]=f,t[19]=p,t[20]=L):L=t[20];let R;t[21]===p?R=t[22]:(R=p?(0,I.jsx)(ee,{className:`size-4`,"aria-hidden":`true`}):(0,I.jsx)(te,{className:`size-4`,"aria-hidden":`true`}),t[21]=p,t[22]=R);let z;t[23]!==p||t[24]!==L||t[25]!==R?(z=(0,I.jsx)(`button`,{type:`button`,onClick:pe,className:`flex size-5 shrink-0 items-center justify-center rounded hover:bg-muted`,"aria-expanded":p,"aria-label":L,"data-testid":`activity-panel-file-row-carrot`,children:R}),t[23]=p,t[24]=L,t[25]=R,t[26]=z):z=t[26];let B;t[27]!==n.docName||t[28]!==a?(B=()=>a(n.docName),t[27]=n.docName,t[28]=a,t[29]=B):B=t[29];let V;t[30]!==d||t[31]!==f?(V=d({id:`QcpeeE`,values:{docName:f}}),t[30]=d,t[31]=f,t[32]=V):V=t[32];let H;t[33]!==n.docName||t[34]!==B||t[35]!==V?(H=(0,I.jsx)(`button`,{type:`button`,onClick:B,className:`min-w-0 flex-1 truncate text-left text-foreground hover:underline focus-visible:outline-ring`,"aria-label":V,"data-testid":`activity-panel-file-row-filename`,title:n.docName,children:n.docName}),t[33]=n.docName,t[34]=B,t[35]=V,t[36]=H):H=t[36];let U;t[37]!==d||t[38]!==f?(U=d({id:`m4v3XT`,values:{docName:f}}),t[37]=d,t[38]=f,t[39]=U):U=t[39];let W;t[40]===Symbol.for(`react.memo_cache_sentinel`)?(W=(0,I.jsx)(g,{className:`size-3.5`,"aria-hidden":`true`}),t[40]=W):W=t[40];let G;t[41]!==j||t[42]!==ce||t[43]!==U?(G=(0,I.jsx)(ne,{asChild:!0,children:(0,I.jsx)(m,{type:`button`,variant:`ghost`,size:`icon`,className:`size-6 shrink-0`,onClick:ce,disabled:j,"aria-label":U,"data-testid":`activity-panel-undo-last`,children:W})}),t[41]=j,t[42]=ce,t[43]=U,t[44]=G):G=t[44];let K;t[45]!==d||t[46]!==F?(K=F??d({id:`ArBWJf`}),t[45]=d,t[46]=F,t[47]=K):K=t[47];let q;t[48]===K?q=t[49]:(q=(0,I.jsx)(re,{side:`bottom`,children:K}),t[48]=K,t[49]=q);let J;t[50]!==G||t[51]!==q?(J=(0,I.jsxs)(ie,{children:[G,q]}),t[50]=G,t[51]=q,t[52]=J):J=t[52];let Y;t[53]!==d||t[54]!==f?(Y=d({id:`J2MgzQ`,values:{docName:f}}),t[53]=d,t[54]=f,t[55]=Y):Y=t[55];let ve;t[56]===Symbol.for(`react.memo_cache_sentinel`)?(ve=(0,I.jsx)(ae,{className:`size-3.5`,"aria-hidden":`true`}),t[56]=ve):ve=t[56];let X;t[57]!==j||t[58]!==ue||t[59]!==Y?(X=(0,I.jsx)(ne,{asChild:!0,children:(0,I.jsx)(m,{type:`button`,variant:`ghost`,size:`icon`,className:`size-6 shrink-0`,onClick:ue,disabled:j,"aria-label":Y,"data-testid":`activity-panel-undo-all`,children:ve})}),t[57]=j,t[58]=ue,t[59]=Y,t[60]=X):X=t[60];let Z;t[61]!==d||t[62]!==F?(Z=F??d({id:`mNY1G6`}),t[61]=d,t[62]=F,t[63]=Z):Z=t[63];let ye;t[64]===Z?ye=t[65]:(ye=(0,I.jsx)(re,{side:`bottom`,children:Z}),t[64]=Z,t[65]=ye);let be;t[66]!==X||t[67]!==ye?(be=(0,I.jsxs)(ie,{children:[X,ye]}),t[66]=X,t[67]=ye,t[68]=be):be=t[68];let xe;t[69]===n.additionsTotal?xe=t[70]:(xe=(0,I.jsxs)(`span`,{className:`text-green-600 dark:text-green-400`,children:[`+`,n.additionsTotal]}),t[69]=n.additionsTotal,t[70]=xe);let Se;t[71]===n.deletionsTotal?Se=t[72]:(Se=(0,I.jsxs)(`span`,{className:`text-red-600 dark:text-red-400`,children:[`−`,n.deletionsTotal]}),t[71]=n.deletionsTotal,t[72]=Se);let Ce;t[73]!==xe||t[74]!==Se?(Ce=(0,I.jsxs)(`span`,{className:`shrink-0 font-mono text-xs`,children:[xe,` `,Se]}),t[73]=xe,t[74]=Se,t[75]=Ce):Ce=t[75];let we;t[76]!==n.lastTs||t[77]!==D?(we=he(n.lastTs,D),t[76]=n.lastTs,t[77]=D,t[78]=we):we=t[78];let Q;t[79]===we?Q=t[80]:(Q=(0,I.jsx)(`span`,{className:`shrink-0 font-mono text-[11px] text-muted-foreground`,children:we}),t[79]=we,t[80]=Q);let Te;t[81]===i?Te=t[82]:(Te=i?(0,I.jsx)(`span`,{className:`shrink-0 text-[11px] text-primary animate-pulse`,role:`status`,children:(0,I.jsx)(l,{id:`6q0rnH`})}):null,t[81]=i,t[82]=Te);let Ee;t[83]!==z||t[84]!==H||t[85]!==J||t[86]!==be||t[87]!==Ce||t[88]!==Q||t[89]!==Te?(Ee=(0,I.jsxs)(`div`,{className:`flex items-center gap-2 px-3 py-2 text-sm`,children:[z,H,J,be,Ce,Q,Te]}),t[83]=z,t[84]=H,t[85]=J,t[86]=be,t[87]=Ce,t[88]=Q,t[89]=Te,t[90]=Ee):Ee=t[90];let De;t[91]!==p||t[92]!==c||t[93]!==n.bursts||t[94]!==n.docName?(De=p?(0,I.jsx)(`div`,{children:n.bursts.map(e=>(0,I.jsx)(me,{burst:e,docName:n.docName,fetchBurstDiff:c},`${n.docName}:${e.stackIndex}`))}):null,t[91]=p,t[92]=c,t[93]=n.bursts,t[94]=n.docName,t[95]=De):De=t[95];let Oe;t[96]===Symbol.for(`react.memo_cache_sentinel`)?(Oe=(0,I.jsx)(S,{children:(0,I.jsx)(l,{id:`SEYWYq`})}),t[96]=Oe):Oe=t[96];let ke;t[97]!==M||t[98]!==f?(ke={docName:f,burstCount:M},t[97]=M,t[98]=f,t[99]=ke):ke=t[99];let Ae;t[100]===Symbol.for(`react.memo_cache_sentinel`)?(Ae={0:(0,I.jsx)(`span`,{className:`font-mono text-foreground`})},t[100]=Ae):Ae=t[100];let je;t[101]===ke?je=t[102]:(je=(0,I.jsxs)(T,{children:[Oe,(0,I.jsx)(x,{children:(0,I.jsx)(l,{id:`ZBYKxv`,values:ke,components:Ae})})]}),t[101]=ke,t[102]=je);let Me;t[103]===Symbol.for(`react.memo_cache_sentinel`)?(Me=()=>v(!1),t[103]=Me):Me=t[103];let Ne;t[104]===Symbol.for(`react.memo_cache_sentinel`)?(Ne=(0,I.jsx)(m,{type:`button`,variant:`outline`,onClick:Me,"data-testid":`activity-panel-undo-all-cancel`,children:(0,I.jsx)(l,{id:`dEgA5A`})}),t[104]=Ne):Ne=t[104];let Pe;t[105]===Symbol.for(`react.memo_cache_sentinel`)?(Pe=(0,I.jsx)(l,{id:`MWrUEd`}),t[105]=Pe):Pe=t[105];let Fe;t[106]===fe?Fe=t[107]:(Fe=(0,I.jsxs)(w,{children:[Ne,(0,I.jsx)(m,{type:`button`,variant:`destructive`,onClick:fe,"data-testid":`activity-panel-undo-all-confirm`,children:Pe})]}),t[106]=fe,t[107]=Fe);let Ie;t[108]!==je||t[109]!==Fe?(Ie=(0,I.jsxs)(C,{className:`sm:max-w-md`,children:[je,Fe]}),t[108]=je,t[109]=Fe,t[110]=Ie):Ie=t[110];let $;t[111]!==_||t[112]!==Ie?($=(0,I.jsx)(E,{open:_,onOpenChange:v,children:Ie}),t[111]=_,t[112]=Ie,t[113]=$):$=t[113];let Le;return t[114]!==Ee||t[115]!==De||t[116]!==$?(Le=(0,I.jsxs)(`div`,{className:`border-b border-border`,"data-testid":`activity-panel-file-row`,children:[Ee,De,$]}),t[114]=Ee,t[115]=De,t[116]=$,t[117]=Le):Le=t[117],Le}function ge(e){return!e}function _e(){return Date.now()}async function z(e){let t=await fetch(`/api/agent-undo`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({...e,agentId:e.connectionId})});if(!t.ok)throw Error(`agent-undo failed: HTTP ${t.status}`)}function B(e){return`#/${e.split(`/`).map(e=>encodeURIComponent(e)).join(`/`)}`}function V(e){typeof window>`u`||(window.location.hash=B(e))}function H(){let e=(0,N.c)(2),t;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,I.jsx)(k,{className:`mr-2 size-4 animate-spin`,"aria-hidden":`true`}),e[0]=t):t=e[0];let n;return e[1]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,I.jsxs)(`div`,{className:`flex h-full items-center justify-center p-6 text-muted-foreground`,role:`status`,"aria-busy":`true`,children:[t,(0,I.jsx)(`span`,{className:`text-sm`,children:(0,I.jsx)(l,{id:`ONPvOb`})})]}),e[1]=n):n=e[1],n}function U(e){let t=(0,N.c)(10),{error:n,onRetry:r}=e,i;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(i=(0,I.jsx)(a,{className:`size-6 text-destructive`,"aria-hidden":`true`}),t[0]=i):i=t[0];let o;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(o=(0,I.jsx)(`p`,{className:`text-sm font-medium`,children:(0,I.jsx)(l,{id:`DhLHEb`})}),t[1]=o):o=t[1];let s;t[2]===n?s=t[3]:(s=(0,I.jsxs)(`div`,{className:`space-y-1`,children:[o,(0,I.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:n})]}),t[2]=n,t[3]=s);let c;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(c=(0,I.jsx)(l,{id:`6gRgw8`}),t[4]=c):c=t[4];let u;t[5]===r?u=t[6]:(u=(0,I.jsx)(m,{type:`button`,variant:`outline`,size:`sm`,onClick:r,children:c}),t[5]=r,t[6]=u);let d;return t[7]!==s||t[8]!==u?(d=(0,I.jsxs)(`div`,{className:`flex flex-col items-center gap-3 p-6 text-center`,role:`alert`,"data-testid":`activity-panel-error`,children:[i,s,u]}),t[7]=s,t[8]=u,t[9]=d):d=t[9],d}function W(){let e=(0,N.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,I.jsx)(`div`,{className:`flex h-full items-center justify-center p-6 text-muted-foreground`,"data-testid":`activity-panel-empty`,children:(0,I.jsx)(`p`,{className:`text-sm italic`,children:(0,I.jsx)(l,{id:`iuTKci`})})}),e[0]=t):t=e[0],t}function G(e){let t=(0,N.c)(12),{onExit:n,showBackButton:r}=e,{_:i}=u(),a;t[0]===i?a=t[1]:(a=i({id:`kYL1lH`}),t[0]=i,t[1]=a);let o;t[2]!==n||t[3]!==r?(o=r?(0,I.jsx)(K,{onClick:n}):null,t[2]=n,t[3]=r,t[4]=o):o=t[4];let s;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(s=(0,I.jsx)(`h2`,{className:`truncate text-sm font-medium`,children:(0,I.jsx)(l,{id:`kYL1lH`})}),t[5]=s):s=t[5];let c;t[6]===o?c=t[7]:(c=(0,I.jsxs)(`div`,{className:`flex shrink-0 flex-row items-center gap-2 border-b border-border px-3 py-2`,children:[o,s]}),t[6]=o,t[7]=c);let d;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(d=(0,I.jsx)(`div`,{className:`flex flex-1 items-center justify-center p-6 text-muted-foreground`,children:(0,I.jsx)(`p`,{className:`text-center text-sm italic`,children:(0,I.jsx)(l,{id:`D_WKe_`})})}),t[8]=d):d=t[8];let f;return t[9]!==a||t[10]!==c?(f=(0,I.jsxs)(`section`,{className:`flex h-full min-h-0 flex-col`,"data-testid":`activity-panel-no-agent`,"aria-label":a,children:[c,d]}),t[9]=a,t[10]=c,t[11]=f):f=t[11],f}function K(e){let t=(0,N.c)(9),{onClick:n}=e,{_:r}=u(),i;t[0]===r?i=t[1]:(i=r({id:`ogAuyr`}),t[0]=r,t[1]=i);let a;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(a=(0,I.jsx)(v,{}),t[2]=a):a=t[2];let o;t[3]!==n||t[4]!==i?(o=(0,I.jsx)(ne,{asChild:!0,children:(0,I.jsx)(m,{type:`button`,variant:`ghost`,size:`icon`,className:`size-7 shrink-0`,onClick:n,"aria-label":i,"data-testid":`docpanel-exit-agent-mode`,children:a})}),t[3]=n,t[4]=i,t[5]=o):o=t[5];let s;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(s=(0,I.jsx)(re,{side:`bottom`,children:(0,I.jsx)(l,{id:`ogAuyr`})}),t[6]=s):s=t[6];let c;return t[7]===o?c=t[8]:(c=(0,I.jsxs)(ie,{children:[o,s]}),t[7]=o,t[8]=c),c}function q(e){let t=(0,N.c)(9),{lastTs:n}=e,[r]=(0,P.useState)(J),i;t[0]!==n||t[1]!==r?(i=n?Y(r-n):null,t[0]=n,t[1]=r,t[2]=i):i=t[2];let a=i,o;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(o=(0,I.jsx)(`span`,{className:`font-medium`,children:(0,I.jsx)(l,{id:`LCUy_N`})}),t[3]=o):o=t[3];let s;t[4]===a?s=t[5]:(s=a?(0,I.jsxs)(`span`,{children:[` · `,a]}):null,t[4]=a,t[5]=s);let c;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(c=(0,I.jsx)(`div`,{className:`mt-1 opacity-80`,children:(0,I.jsx)(l,{id:`GK-IRZ`})}),t[6]=c):c=t[6];let u;return t[7]===s?u=t[8]:(u=(0,I.jsxs)(`div`,{className:`border-b border-border bg-muted/40 px-4 py-3 text-xs text-muted-foreground`,"data-testid":`activity-panel-session-ended`,children:[o,s,c]}),t[7]=s,t[8]=u),u}function J(){return Date.now()}function Y(e){let t=Math.max(0,e);if(t<6e4){let e=Math.round(t/1e3);return M._({id:`pbwTg6`,values:{seconds:e}})}if(t<36e5){let e=Math.round(t/6e4);return M._({id:`_rP3HI`,values:{minutes:e}})}let n=Math.round(t/36e5);return M._({id:`nYeBmY`,values:{hours:n}})}function ve(e){let t=(0,N.c)(10),{agent:n,size:r}=e,i=r===void 0?28:r,a;t[0]!==n.color||t[1]!==i?(a={backgroundColor:n.color,width:i,height:i},t[0]=n.color,t[1]=i,t[2]=a):a=t[2];let o=i*.57,s=i*.57,c;t[3]!==n.icon||t[4]!==o||t[5]!==s?(c=(0,I.jsx)(y,{icon:n.icon,width:o,height:s}),t[3]=n.icon,t[4]=o,t[5]=s,t[6]=c):c=t[6];let l;return t[7]!==a||t[8]!==c?(l=(0,I.jsx)(`span`,{className:`inline-flex shrink-0 items-center justify-center rounded-full text-white ring-2 ring-background`,style:a,"aria-hidden":`true`,children:c}),t[7]=a,t[8]=c,t[9]=l):l=t[9],l}function X(e){let t=(0,N.c)(26),{data:n,status:r,error:i,reload:a,fetchBurstDiff:o,onExit:s,onNavigate:c,onUndoLast:d,onUndoAll:f,showBackButton:p}=e,{_:m}=u(),h=n?.files?.[0]?.lastTs??null,g=n?.files?.length??0,_;t[0]===m?_=t[1]:(_=m({id:`kYL1lH`}),t[0]=m,t[1]=_);let v;t[2]!==s||t[3]!==p?(v=p?(0,I.jsx)(K,{onClick:s}):null,t[2]=s,t[3]=p,t[4]=v):v=t[4];let y;t[5]!==n||t[6]!==g||t[7]!==h?(y=n?.agent?(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(ve,{agent:n.agent}),(0,I.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,I.jsx)(`h2`,{className:`truncate text-sm font-medium`,children:n.agent.displayName}),(0,I.jsxs)(`p`,{className:`truncate text-xs text-muted-foreground`,children:[n.sessionAlive?(0,I.jsx)(l,{id:`F6pfE9`}):h===null?(0,I.jsx)(l,{id:`PMyJ9C`}):(0,I.jsx)(l,{id:`237hSL`}),n.files.length>0?(0,I.jsxs)(I.Fragment,{children:[` · `,(0,I.jsx)(l,{id:`u3BOHd`,values:{fileCount:g}})]}):null]})]})]}):(0,I.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,I.jsx)(`h2`,{className:`truncate text-sm font-medium`,children:(0,I.jsx)(l,{id:`kYL1lH`})})}),t[5]=n,t[6]=g,t[7]=h,t[8]=y):y=t[8];let b;t[9]!==v||t[10]!==y?(b=(0,I.jsxs)(`div`,{className:`flex flex-row items-center gap-2 border-b border-border px-3 py-2 shrink-0`,children:[v,y]}),t[9]=v,t[10]=y,t[11]=b):b=t[11];let x;t[12]!==n||t[13]!==i||t[14]!==o||t[15]!==h||t[16]!==c||t[17]!==f||t[18]!==d||t[19]!==a||t[20]!==r?(x=(0,I.jsx)(`div`,{className:`flex-1 overflow-y-auto`,"data-testid":`activity-panel-body`,children:r===`loading`&&n===null?(0,I.jsx)(H,{}):r===`error`&&i?(0,I.jsx)(U,{error:i,onRetry:a}):n===null?(0,I.jsx)(W,{}):(0,I.jsxs)(I.Fragment,{children:[!n.sessionAlive&&h!==null?(0,I.jsx)(q,{lastTs:h}):null,n.files.length===0?(0,I.jsx)(W,{}):n.files.map(e=>(0,I.jsx)(R,{file:e,sessionAlive:n.sessionAlive,isWriting:n.writingDocs.has(e.docName),onNavigate:c,onUndoLast:d,onUndoAll:f,fetchBurstDiff:o},e.docName))]})}),t[12]=n,t[13]=i,t[14]=o,t[15]=h,t[16]=c,t[17]=f,t[18]=d,t[19]=a,t[20]=r,t[21]=x):x=t[21];let S;return t[22]!==_||t[23]!==b||t[24]!==x?(S=(0,I.jsxs)(`section`,{className:`flex h-full min-h-0 flex-col`,"data-testid":`activity-panel`,"aria-label":_,children:[b,x]}),t[22]=_,t[23]=b,t[24]=x,t[25]=S):S=t[25],S}function Z(e){let t=(0,N.c)(29),n;t[0]===e?n=t[1]:(n=e===void 0?{}:e,t[0]=e,t[1]=n);let{showBackButton:r}=n,i=r===void 0?!0:r,{_:a}=u(),{docPanelAgentId:s,closeActivityPanel:l}=o(),{openTargetTransition:d}=c(),{pageMeta:f}=D(),{data:p,status:m,error:h,reload:g,fetchBurstDiff:_}=le(s);if(s===null){let e;return t[2]!==l||t[3]!==i?(e=(0,I.jsx)(G,{onExit:l,showBackButton:i}),t[2]=l,t[3]=i,t[4]=e):e=t[4],e}let v;t[5]!==d||t[6]!==f?(v=e=>{d(O({kind:`doc`,target:e,docName:e},f)),V(e)},t[5]=d,t[6]=f,t[7]=v):v=t[7];let y=v,b;t[8]!==a||t[9]!==p||t[10]!==s||t[11]!==g?(b=async e=>{try{await z({connectionId:s,docName:e,scope:`last`,agentName:p?.agent?.displayName}),g()}catch(e){let t=e,n=t instanceof Error?t.message:String(t);A.error(a({id:`EqrC_R`,values:{message:n}})),g()}},t[8]=a,t[9]=p,t[10]=s,t[11]=g,t[12]=b):b=t[12];let x=b,S;t[13]!==a||t[14]!==p||t[15]!==s||t[16]!==g?(S=async e=>{try{await z({connectionId:s,docName:e,scope:`file`,agentName:p?.agent?.displayName}),A.success(a({id:`pRc-Im`,values:{docName:e}})),g()}catch(e){let t=e,n=t instanceof Error?t.message:String(t);A.error(a({id:`7KeV5F`,values:{message:n}})),g()}},t[13]=a,t[14]=p,t[15]=s,t[16]=g,t[17]=S):S=t[17];let C=S,w;return t[18]!==l||t[19]!==p||t[20]!==h||t[21]!==_||t[22]!==y||t[23]!==C||t[24]!==x||t[25]!==g||t[26]!==i||t[27]!==m?(w=(0,I.jsx)(X,{data:p,status:m,error:h,reload:g,fetchBurstDiff:_,onExit:l,onNavigate:y,onUndoLast:x,onUndoAll:C,showBackButton:i}),t[18]=l,t[19]=p,t[20]=h,t[21]=_,t[22]=y,t[23]=C,t[24]=x,t[25]=g,t[26]=i,t[27]=m,t[28]=w):w=t[28],w}export{Z as ActivityModeContent};
|