@inkeep/open-knowledge 0.43.0-beta.13 → 0.43.0-beta.14
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/{acp-harness-probe-ByCqmbsD.mjs → acp-harness-probe-C9B2T64O.mjs} +2 -2
- package/dist/assets/skills/discovery/SKILL.md +1 -1
- package/dist/assets/skills/project/SKILL.md +1 -1
- package/dist/cli.mjs +50 -50
- package/dist/constants-CLbzDwIP.mjs +2 -0
- package/dist/{git-handle-BQBchhaT.mjs → git-handle-BWeZLLiM.mjs} +2 -2
- package/dist/git-handle-DWVVkQjB.mjs +1 -0
- package/dist/index.mjs +1 -1
- package/dist/{init-DQsXw80Y.mjs → init-CUJ7SCtW.mjs} +12 -12
- package/dist/init-DesRVARs.mjs +1 -0
- package/dist/{launch-json-removal-CZAv1jvE.mjs → launch-json-removal-BsFqv9J_.mjs} +2 -2
- package/dist/loader-Bv89rEJ8.mjs +1 -0
- package/dist/{loader-BeCeqNda.mjs → loader-CWirEDmB.mjs} +2 -2
- package/dist/md-manager-4IM456U3.mjs +2 -0
- package/dist/{open-browser-DzAgUCZN.mjs → open-browser-Blmbk-om.mjs} +2 -2
- package/dist/parse-worker.mjs +1 -1
- package/dist/{preview-_Dw3Db9A.mjs → preview-BHq9Lqqb.mjs} +2 -2
- package/dist/preview-CjWzC7ZW.mjs +1 -0
- package/dist/public/assets/{ActivityModeContent-Caft32Vd.js → ActivityModeContent-vTyFr3qQ.js} +1 -1
- package/dist/public/assets/{AgentDiffPane-Df0qkLU-.js → AgentDiffPane-GxKPWE8k.js} +1 -1
- package/dist/public/assets/{AgentThreadClientBinder-CTEgUWNh.js → AgentThreadClientBinder-C0HVi3JD.js} +1 -1
- package/dist/public/assets/CodeMirrorPropInput-CrQK1HuR.js +3 -0
- package/dist/public/assets/{DocumentContext-DBWuhdCp.js → DocumentContext-CAS2W4f1.js} +20 -20
- package/dist/public/assets/{EditorModeToggle-BNXpG7rF.js → EditorModeToggle-D6Iuqqkv.js} +1 -1
- package/dist/public/assets/{EnableSyncConfirmDialog-BTIznANH.js → EnableSyncConfirmDialog-3FD0CEyo.js} +1 -1
- package/dist/public/assets/FeedbackForm-fKK2B1DE.js +1 -0
- package/dist/public/assets/{GraphPanel-CgrlHWWr.js → GraphPanel-DrT-_ku2.js} +1 -1
- package/dist/public/assets/{LintConfigEditor-Ctq5lSfH.js → LintConfigEditor-CDtT8Se-.js} +1 -1
- package/dist/public/assets/{ManagedArtifactProperties-BpYPi-b4.js → ManagedArtifactProperties-DpOGcCjc.js} +1 -1
- package/dist/public/assets/{McpConsentDialogBody-DhngjZQA.js → McpConsentDialogBody-Dpk8KrcG.js} +1 -1
- package/dist/public/assets/{MermaidDocEditor-D2kbc4NK.js → MermaidDocEditor-DLLqc7Ae.js} +1 -1
- package/dist/public/assets/{PropertyPanel-DHZsTX3r.js → PropertyPanel-BbRn8bAL.js} +1 -1
- package/dist/public/assets/{ReportBugDialogBody-xmSVX-QG.js → ReportBugDialogBody-lZ69K9r7.js} +1 -1
- package/dist/public/assets/{SchemaConfigEditor-BKOYyQt7.js → SchemaConfigEditor-6gHxc1lB.js} +1 -1
- package/dist/public/assets/{SettingsDialogBody-BGUPoYMW.js → SettingsDialogBody-CDyeN7KP.js} +3 -3
- package/dist/public/assets/{ShareBranchSwitchDialog-BhHuyb7L.js → ShareBranchSwitchDialog-DAgfjIM3.js} +1 -1
- package/dist/public/assets/{ShareReceiveDialog-5coq0aKX.js → ShareReceiveDialog-qvDthpch.js} +1 -1
- package/dist/public/assets/{ShareReceiveMissDialog-DCoXgT3O.js → ShareReceiveMissDialog-BC4nNiVw.js} +1 -1
- package/dist/public/assets/{SkillEditorActions-u7-TVviY.js → SkillEditorActions-3iEUQnvf.js} +1 -1
- package/dist/public/assets/SourceEditor-DSuyTF9U.js +1 -0
- package/dist/public/assets/{TerminalPanel-GSkaDXhO.js → TerminalPanel-Chi9UCzm.js} +3 -3
- package/dist/public/assets/{TerminalSessionsHost-DFK7SKXj.js → TerminalSessionsHost-JAswmWIz.js} +2 -2
- package/dist/public/assets/{TerminalWindowApp-BE8T-nBp.js → TerminalWindowApp-De-lFCxU.js} +1 -1
- package/dist/public/assets/{ThreadView-DXtF-UeZ.js → ThreadView-C9iEBRPQ.js} +2 -2
- package/dist/public/assets/{TimelineDiffPane-Dd90Gidv.js → TimelineDiffPane-Bw3ccuoQ.js} +1 -1
- package/dist/public/assets/{agent-diff-store-D1nhdJoB.js → agent-diff-store-Dyl5c4Ms.js} +1 -1
- package/dist/public/assets/{agent-visibility-BdXqjex3.js → agent-visibility-DhSEBFR1.js} +1 -1
- package/dist/public/assets/auth-state-cache-BwKs3LET.js +11 -0
- package/dist/public/assets/{client-version-BM5GE9Bo.js → client-version-ZyTDej8q.js} +1 -1
- package/dist/public/assets/{config-provider-D0FL7RXj.js → config-provider-imFEGIFA.js} +1 -1
- package/dist/public/assets/{dist-DJVm0s5Q.js → dist-va2k1MkO.js} +170 -170
- package/dist/public/assets/{doc-hash-CzVDYRfE.js → doc-hash-OWciT39T.js} +1 -1
- package/dist/public/assets/{documents-events-Bo_vtEwF.js → documents-events-BOnV4hx1.js} +1 -1
- package/dist/public/assets/{file-tree-adapter-BqoVN_LL.js → file-tree-adapter-BBFNQL6F.js} +1 -1
- package/dist/public/assets/{file-tree-utils-DMD__4-l.js → file-tree-utils-DRNMh6K3.js} +1 -1
- package/dist/public/assets/index-CfdP3__y.js +2013 -0
- package/dist/public/assets/{lint-config-client-DHqwjtcr.js → lint-config-client-BhiOgYGY.js} +1 -1
- package/dist/public/assets/{markdownlint-rule-browser-CXOqtMRz.js → markdownlint-rule-browser-Bdo9w64M.js} +1 -1
- package/dist/public/assets/{navigation-targets-yk_ftK5e.js → navigation-targets-BFtUSa7x.js} +1 -1
- package/dist/public/assets/{open-managed-artifact-tab-BKDY8Ljl.js → open-managed-artifact-tab-Dz-iUx5S.js} +1 -1
- package/dist/public/assets/{pending-receive-nav-store-BFkHLr4z.js → pending-receive-nav-store-CqsYulil.js} +1 -1
- package/dist/public/assets/{prop-types-C4C0yVjX.js → prop-types-DL9hVsb5.js} +1 -1
- package/dist/public/assets/{receive-store-3GZiQlZq.js → receive-store-DujeigJk.js} +1 -1
- package/dist/public/assets/{selection-context-Cb5R_n8T.js → selection-context-DC9PBu0g.js} +1 -1
- package/dist/public/assets/{skill-actions-DrS0GWjR.js → skill-actions-BbP3ZCgd.js} +1 -1
- package/dist/public/assets/{skills-api-CcJW9MXE.js → skills-api-BQ668HV0.js} +1 -1
- package/dist/public/assets/{src-DHoFr5NH.js → src-C44T1Zzj.js} +1 -1
- package/dist/public/assets/{tag-pill-input-6LF5Ew7c.js → tag-pill-input-gR6qmVHR.js} +1 -1
- package/dist/public/assets/{target-navigation-intent-B9S3uLuM.js → target-navigation-intent-ByUnw3xt.js} +1 -1
- package/dist/public/assets/{terminal-launch-events-qFzt0nab.js → terminal-launch-events-CTaHMSeq.js} +1 -1
- package/dist/public/assets/{terminal-telemetry-CN5zh704.js → terminal-telemetry-DEeK29Cb.js} +1 -1
- package/dist/public/assets/typing-burst-detector-Dyw3G-_I.js +8 -0
- package/dist/public/assets/{uninstall-CYjxBKsK.js → uninstall-C-MsN8GV.js} +1 -1
- package/dist/public/assets/{use-activity-panel-CJo_D7xH.js → use-activity-panel-BVO3v9MF.js} +1 -1
- package/dist/public/assets/{use-apply-config-color-theme-BJoYMJ5D.js → use-apply-config-color-theme-6_7624zA.js} +1 -1
- package/dist/public/assets/{use-collab-url-CaRb8gBS.js → use-collab-url-q0L5wUfG.js} +1 -1
- package/dist/public/assets/{use-live-xterm-theme-D38mA6sa.js → use-live-xterm-theme-BWQFyEwH.js} +1 -1
- package/dist/public/assets/{use-settings-route-B1YAIjw7.js → use-settings-route-Z3qgrdnL.js} +1 -1
- package/dist/public/assets/{use-terminal-enabled-Co0iiHJG.js → use-terminal-enabled-CypSFKLB.js} +1 -1
- package/dist/public/assets/use-timeline-entry-diff-7LP9u2Jh.js +6 -0
- package/dist/public/assets/{use-workspace-JLsRReFz.js → use-workspace-Cr3fJTq2.js} +1 -1
- package/dist/public/assets/{workspace-paths-Bg75xrRc.js → workspace-paths-DTLYSfpn.js} +1 -1
- package/dist/public/index.html +35 -35
- package/dist/public/uninstall.html +2 -2
- package/dist/{repair-launch-json-By9LDC45.mjs → repair-launch-json-9XTHkXcU.mjs} +2 -2
- package/dist/{repair-mcp-configs-CDJq4Ve2.mjs → repair-mcp-configs-0uLPQ_lS.mjs} +2 -2
- package/dist/repair-skills-BBckxGa0.mjs +1 -0
- package/dist/{repair-skills-5K_XeFog.mjs → repair-skills-C4w0RoPe.mjs} +2 -2
- package/dist/{server-lock-CE0z40lI.mjs → server-lock-CcKfnBVl.mjs} +2 -2
- package/dist/server-lock-S4nBSWNN.mjs +1 -0
- package/dist/{src-DeZ1D7q7.mjs → src-B0klb50O.mjs} +256 -256
- package/dist/src-CIOr7Lie.mjs +1 -0
- package/dist/{src-BVK8_kFb.mjs → src-CslgYdG3.mjs} +3 -3
- package/dist/{src-H4ZV7b5v.mjs → src-jbLmpusB.mjs} +2 -2
- package/dist/{start-CC_NUunW.mjs → start-Brg7Qf35.mjs} +3 -3
- package/dist/start-DI9PbH8b.mjs +1 -0
- package/dist/{write-project-skill-C6Fs5yeK.mjs → write-project-skill-C5NP_pT9.mjs} +3 -3
- package/package.json +4 -4
- package/dist/constants-k1x9z874.mjs +0 -2
- package/dist/git-handle-CgCHlb8d.mjs +0 -1
- package/dist/init-Q5f00yyT.mjs +0 -1
- package/dist/loader-D4TaTEEF.mjs +0 -1
- package/dist/md-manager-RI1L8gfa.mjs +0 -2
- package/dist/preview-1B2mSgUw.mjs +0 -1
- package/dist/public/assets/CodeMirrorPropInput-Cso0PRhw.js +0 -3
- package/dist/public/assets/FeedbackForm-DDU9D8tt.js +0 -1
- package/dist/public/assets/SourceEditor-DYWv57uN.js +0 -1
- package/dist/public/assets/auth-state-cache-D2opY-FF.js +0 -11
- package/dist/public/assets/index-CWRnTo0h.js +0 -2013
- package/dist/public/assets/typing-burst-detector-BtpWDk3c.js +0 -8
- package/dist/public/assets/use-timeline-entry-diff-DVXnI1OV.js +0 -6
- package/dist/repair-skills-Cjwz2l5i.mjs +0 -1
- package/dist/server-lock-DsOeCfiP.mjs +0 -1
- package/dist/src-BmUGNQeQ.mjs +0 -1
- package/dist/start-CcYGWRIZ.mjs +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{Fa as e,Ia as t,Pa as n,Qa as r,So as i,Xa as a,b as o,co as s,d as c,l,w as u}from"./src-jbLmpusB.mjs";import{$ as d,$i as f,$n as p,$r as m,$t as h,A as g,Ai as _,An as v,At as y,B as b,Bi as x,Bn as S,Br as C,Bt as w,C as T,Ci as E,Cn as D,Cr as O,Ct as k,D as A,Di as j,Dn as M,Dr as N,Dt as P,E as F,Ei as I,En as L,Er as R,Et as z,F as B,Fi as V,Fn as H,Fr as U,Ft as W,G,Gi as K,Gn as q,Gr as J,Gt as Y,H as X,Hi as Z,Hn as Q,Hr as $,Ht as ee,I as te,Ii as ne,In as re,Ir as ie,It as ae,J as oe,Ji as se,Jn as ce,Jr as le,Jt as ue,K as de,Ki as fe,Kn as pe,Kr as me,Kt as he,L as ge,Li as _e,Ln as ve,Lr as ye,Lt as be,M as xe,Mi as Se,Mn as Ce,Mt as we,N as Te,Ni as Ee,Nn as De,Nr as Oe,Nt as ke,O as Ae,Oi as je,On as Me,Ot as Ne,P as Pe,Pi as Fe,Pn as Ie,Pr as Le,Pt as Re,Q as ze,Qi as Be,Qn as Ve,Qr as He,Qt as Ue,R as We,Ri as Ge,Rn as Ke,Rr as qe,Rt as Je,S as Ye,Si as Xe,Sn as Ze,Sr as Qe,St as $e,T as et,Ti as tt,Tn as nt,Tr as rt,Tt as it,U as at,Ui as ot,Un as st,Ur as ct,Ut as lt,V as ut,Vi as dt,Vn as ft,Vr as pt,Vt as mt,W as ht,Wi as gt,Wn as _t,Wr as vt,Wt as yt,X as bt,Xi as xt,Xn as St,Xr as Ct,Xt as wt,Y as Tt,Yi as Et,Yn as Dt,Yr as Ot,Yt as kt,Z as At,Zi as jt,Zn as Mt,Zr as Nt,Zt as Pt,_ as Ft,_a as It,_i as Lt,_n as Rt,_r as zt,_t as Bt,a as Vt,aa as Ht,ai as Ut,an as Wt,ar as Gt,at as Kt,b as qt,ba as Jt,bi as Yt,bn as Xt,br as Zt,bt as Qt,c as $t,ca as en,ci as tn,cn as nn,cr as rn,ct as an,d as on,da as sn,di as cn,dn as ln,dr as un,ea as dn,ei as fn,en as pn,er as mn,et as hn,f as gn,fa as _n,fi as vn,fn as yn,fr as bn,g as xn,ga as Sn,gi as Cn,gn as wn,gr as Tn,gt as En,h as Dn,ha as On,hi as kn,hn as An,hr as jn,ht as Mn,i as Nn,ia as Pn,ii as Fn,in as In,ir as Ln,it as Rn,j as zn,ji as Bn,jn as Vn,jt as Hn,k as Un,ki as Wn,kn as Gn,kt as Kn,l as qn,la as Jn,li as Yn,ln as Xn,lr as Zn,m as Qn,ma as $n,mi as er,mn as tr,mr as nr,n as rr,na as ir,ni as ar,nn as or,nr as sr,nt as cr,o as lr,oa as ur,oi as dr,on as fr,or as pr,ot as mr,p as hr,pa as gr,pi as _r,pn as vr,pr as yr,q as br,qi as xr,qn as Sr,qr as Cr,qt as wr,r as Tr,ra as Er,ri as Dr,rn as Or,rr as kr,rt as Ar,s as jr,sa as Mr,si as Nr,sn as Pr,sr as Fr,st as Ir,t as Lr,ta as Rr,ti as zr,tn as Br,tr as Vr,tt as Hr,u as Ur,ua as Wr,ui as Gr,un as Kr,ur as qr,v as Jr,va as Yr,vi as Xr,vn as Zr,vr as Qr,vt as $r,w as ei,wi as ti,wn as ni,wr as ri,wt as ii,x as ai,xi as oi,xn as si,xr as ci,xt as li,y as ui,ya as di,yi as fi,yn as pi,yr as mi,yt as hi,z as gi,zi as _i,zn as vi,zr as yi,zt as bi}from"./src-B0klb50O.mjs";import{C as xi,E as Si,T as Ci,_ as wi,b as Ti,c as Ei,d as Di,g as Oi,i as ki,l as Ai,m as ji,n as Mi,p as Ni,s as Pi,t as Fi,u as Ii,v as Li,w as Ri,x as zi,y as Bi}from"./fs-traced-DDm-belY.mjs";import{a as Vi,d as Hi,f as Ui,i as Wi,l as Gi,n as Ki,r as qi,t as Ji,u as Yi}from"./logger-B7Z8XO-z.mjs";import{S as Xi,_ as Zi,a as Qi,c as $i,f as ea,g as ta,h as na,i as ra,l as ia,m as aa,n as oa,o as sa,p as ca,r as la,s as ua,t as da,u as fa,v as pa,x as ma}from"./server-lock-CcKfnBVl.mjs";export{sn as AGENT_ID_MAX_LEN,_n as AGENT_ID_RE,j as AGENT_WRITE_ORIGIN,Yr as AcpPermissionStore,On as AcpRegistry,ti as AcpThreadManager,Xe as AgentFocusBroadcaster,oi as AgentPresenceBroadcaster,je as AgentSessionCapacityError,Wn as AgentSessionManager,En as AutoStartDisabledError,yr as BUNDLE_IDS,nr as BUNDLE_SCOPE,jn as BUNDLE_SKILL_NAME,Ce as BacklinkIndex,_i as CC1Broadcaster,r as CC1_CONTRACT_VERSION,or as CONFIG_FILENAME,L as CONFLICT_MARKER_RE,ye as CURSOR_BUNDLE_PATHS_BY_PLATFORM,Ft as ConfigSchema,K as DEFAULT_CHECKPOINT_RETENTION,m as DEFAULT_EMBEDDINGS_DIMENSIONS,W as DEFAULT_PACK_ID,ut as DocumentDurabilityState,fn as EMBEDDINGS_API_KEY_ENV,Sn as FEATURED_AGENT_IDS,fe as FILE_SYSTEM_WRITER,v as FILE_WATCHER_ORIGIN,Cr as FileEmbeddingsBackend,Pt as GIT_PREFLIGHT_FAIL_SPAN_NAME,xr as GIT_UPSTREAM_WRITER,di as GitDirAccessError,vi as GitNotAvailableError,S as GitTooOldError,Bt as HOCUSPOCUS_AUTH_REJECTION_REASONS,$r as HocuspocusAuthRejection,hi as HocuspocusAuthTokenSchema,ct as INSTALLED_AGENTS_SCHEMES,a as LINEAGE_EPOCH_KEY,We as LIVE_DERIVED_INDEX_DEBOUNCE_MS,ae as LOG_MD_TEMPLATE,it as MANAGED_RENAME_ORIGIN,tt as MAX_ACP_THREADS,_ as MAX_AGENT_SESSIONS,Ir as MCP_CONNECTION_ID_HEADER,n as MCP_SERVER_NAME,Bn as MIN_EVICTABLE_IDLE_MS,ft as MIN_GIT_VERSION,X as MISSING_OK_CONFIG_MESSAGE,Jt as MalformedGitPointerError,d as McpLogger,at as MissingOkConfigError,Ee as OBSERVER_SYNC_ORIGIN,Or as OK_OKIGNORE_TEMPLATE,e as ORPHAN_MODES,i as PROTOCOL_VERSION,Ji as PinoLogger,$i as ProcessLockCollisionError,qn as ProjectGitInitError,z as ROLLBACK_ORIGIN,In as ROOT_GITIGNORE_TEMPLATE,ta as RUNTIME_VERSION,kn as RemoteConfigError,se as SERVICE_WRITER,rn as SKILL_INSTALL_EVENTS_FILE_REL,o as SKILL_STATE_TARGETS,be as STARTER_FOLDERS,Je as STARTER_FOLDER_FRONTMATTER_FILENAME,bi as STARTER_PACKS,w as STARTER_PACK_IDS,mt as STARTER_TEMPLATES,et as STATE_MANIFEST_FILENAME,Zi as STATE_SCHEMA_VERSION,s as SYSTEM_DOC_NAME,wr as SeedPrerequisiteError,ue as SeedRootDirError,da as ServerLockCollisionError,Lr as SingleFileNotAFileError,rr as SingleFileNotFoundError,Tr as SingleFileNotMarkdownError,F as StateManifestError,Vn as TagIndex,Tn as USER_GLOBAL_BUNDLE_IDS,Ie as UiLockCollisionError,P as __getShowAllWalkStatsForTesting,Ne as __resetShowAllWalkStatsForTesting,ia as acquireProcessLock,oa as acquireServerLock,H as acquireUiLock,Se as applyAgentMarkdownWrite,ni as applyExternalChange,Re as applySeed,A as assertCompatibleStateManifest,Q as assertGitAvailable,yn as assertNeverDiskEvent,E as attachAcpThreadSocket,Mn as attachIdleShutdown,Jr as bootServer,Mt as buildAndOpenSkill,Wt as buildConfigYmlContent,oe as buildExecResult,I as buildOkMcpStdioCommand,qr as buildSkillZip,ee as buildStarterFolderFrontmatterYaml,Et as buildWipTree,zt as bundleSkillMdPath,le as canonicalProjectKey,vr as classifyEvents,Fi as classifyFsPath,Ot as clearAllEmbeddingsKeys,ar as clearContributors,lt as coercePackId,l as colorFromSeed,xt as commitUpstreamImport,jt as commitWip,Be as commitWipFromTree,st as compareSemver,Zt as composeEffectiveLinterConfig,ci as composeFrontmatterSchemasConfig,M as containsConflictMarkers,tr as contentHash,Dr as contributorCount,Pe as countShadowObjects,B as countStaleAgentWipRefs,te as countWipRefs,Kn as createApiExtension,vn as createAssetServeMiddleware,Oe as createContentFilter,Le as createContentFilterAsync,Ct as createEmbeddingsSecretStore,Nn as createEphemeralProjectDir,nt as createExternalChangeHandler,gn as createFileLogger,gi as createLiveDerivedIndexExtension,de as createMcpHttpHandler,vt as createOsProbe,Te as createPersistenceExtension,T as createServer,zn as createServerObserverExtension,ne as createStreamingErrorWriter,Ki as createTestLogger,Nt as describeStoredEmbeddingsKey,xn as detectClaudeDesktopPresence,_t as detectGit,Ae as detectProjectShape,Ve as detectUserSkillHosts,cr as discoverLockDirs,ri as discoverMarkdownlintConfig,Ue as emitPreflightFailureSpan,Tt as encodeDocName,bt as encodeFolderRoute,At as encodeSkillRoute,Ur as ensureProjectGit,fr as ensureProjectSkillGitignore,_e as errorResponse,An as evictStaleTrackerEntries,y as extractHeadings,Ar as extractOkBinaryPath,De as extractWikiLinksFromMarkdown,q as fallbackPaths,on as findEnclosingGitRoot,Kr as findEnclosingProjectRoot,rt as findNativeMarkdownlintFile,hr as flushFileLogger,Qt as formatAuthRejectionWire,Fn as formatContributors,Ut as formatContributorsFrom,we as formatPackRationale,f as gcCheckpointRefs,hn as getCurrentMcpLogger,Yn as getLocalDir,Qn as getLogFilePath,qi as getLogger,Dn as getLogsDir,pa as getMachineId,Bi as getMeter,ur as getMetrics,Ti as getTracer,Mr as handleCollabSocketError,qe as handleSpawnCursor,Cn as hasForwardingHeaders,ge as hasGcLogLatch,c as iconFromClientName,en as incrementCollabSocketFilteredError,Jn as incrementServerObserverFire,Pr as initContent,dn as initShadowRepo,zi as initTelemetry,qt as initToleranceTelemetryWriter,mr as installPrettyZodErrors,Wi as installTestLoggers,p as installUserSkill,er as isAllowedApiOrigin,fi as isAllowedWorkspaceHostHeader,x as isConfigDoc,li as isHocuspocusAuthRejectionReason,yt as isKnownPackId,dt as isLinkIndexExcludedDoc,Yt as isLoopbackAddress,Z as isManagedArtifactDoc,t as isOrphanMode,Fe as isPairedWriteOrigin,yi as isPathWithinDir,ma as isProcessAlive,ln as isProjectRoot,Sr as isProjectSkillManaged,Lt as isRemoteAdmitted,ot as isReservedForUserTree,wn as isSelfWrite,gt as isSystemDoc,ai as isToleranceTelemetryEnabled,Xi as isValidLockPid,Rt as lastKnownHash,Rr as listRescueCheckpoints,Y as listStarterPacks,It as loadCustomAgents,xe as loadPrincipal,fa as lockFilePath,Vi as loggerFactory,Gi as logsCurrentPath,Yi as logsPreviousPath,He as makeLazyEmbeddingsKeyStore,la as markServerLockDraining,ht as mountMcpAndApi,Mi as normalizeFsPath,Qr as originGitHubHost,nn as packageVersionMajorMinor,$e as parseAuthRejectionWire,pe as parseGitVersion,k as parseHocuspocusAuthToken,G as parseKeepaliveConnectionId,Zr as pathToDocName,ke as planSeed,Vt as prepareSingleFileOpen,Rn as processCommand,Kt as processUsage,mn as readAllTargets,Vr as readBundleDecision,R as readOwnNativeRules,ea as readProcessLock,ca as readProcessLockDetailed,b as readProjectHeadState,me as readProjectLocalSemanticConfig,ra as readServerLock,sr as readServerPackageVersion,kr as readSkillInstallStateSnapshot,ce as readSkillManagement,Un as readStateManifest,Ln as readTargetRecordedAt,Gt as readTargetVersion,re as readUiLock,Me as reconcile,dr as recordContributor,Zn as recordSkillInstallEvent,br as registerAllTools,pi as registerWrite,aa as releaseProcessLock,Qi as releaseServerLock,ve as releaseUiLock,Xt as removeLastKnownHash,Wr as resetMetrics,u as resolveBundleEnabled,un as resolveBundledSkillDir,Gr as resolveContentDir,C as resolveCursorBinaryDefault,pt as resolveCursorSpawnInvocation,Qe as resolveEffectiveLinterConfig,zr as resolveEmbeddingsCredential,cn as resolveLockDir,O as resolveNativeConfigForDoc,N as resolveNativeMarkdownlintConfig,he as resolvePack,jr as resolvePackageVersion,Xr as resolveRemoteAccess,ze as resolveUiInfo,Nr as restoreContributors,ui as restoreLifecycleFromConflictsJson,U as rewriteMarkdownLinksForDocumentRename,ie as rewriteWikiLinksForDocumentRename,h as runAuthReposSubprocess,pn as runAuthStatusSubprocess,kt as runCloneSubprocess,Br as runDeviceFlowSubprocess,Hr as runWithMcpLogger,_r as safeContentPath,Hn as safeSubdir,ir as safetyCheckpoint,an as sanitizeClientName,Er as saveInMemoryCheckpoint,Pn as saveVersion,ii as seedBasenameIndex,lr as serializeError,xi as setActiveSpanAttributes,V as setupServerObservers,Ht as shadowGit,Ri as shutdownTelemetry,Dt as skillManagementPath,Hi as spansCurrentPath,Ui as spansPreviousPath,$ as spawnDetached,Gn as splitMarkdownBlocks,si as startWatcher,Ge as streamingProblemEvent,tn as swapContributors,Ye as teardownToleranceTelemetryWriter,gr as toBroadcasterKey,ki as tracedAppendFileSync,Pi as tracedLinkSync,Ei as tracedMkdir,Ai as tracedMkdirSync,Ii as tracedRename,Di as tracedRenameSync,Ni as tracedRmSync,ji as tracedRmdirSync,Oi as tracedUnlinkSync,wi as tracedWriteFile,Li as tracedWriteFileSync,ei as trustSystemCertificates,$t as untrackTrackedProjectSkillProjection,Ze as updateLastKnownHash,na as updateProcessLockPort,sa as updateServerLockPort,Ke as updateUiLockPort,$n as validateAgentId,wt as validateCloneInputs,bn as validateSkillZip,ua as waitForServerLockDrain,J as withHiddenWindowsConsole,Ci as withSpan,Si as withSpanSync,pr as writeBundleDecision,mi as writeMarkdownlintRule,Xn as writeRootGitignoreForNewRepo,St as writeSkillManagement,g as writeStateManifest,Fr as writeTargetVersion,D as writeTracker};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{o as e}from"./chunk-DTipWd-i.mjs";import{
|
|
1
|
+
import{o as e}from"./chunk-DTipWd-i.mjs";import{I as t,L as n,vo as r,yo as i,za as a}from"./src-jbLmpusB.mjs";import{Ca as o,Gr as s,at as c,di as l,it as u,nt as d,rt as f,un as p}from"./src-B0klb50O.mjs";import{K as m}from"./sleep-DDnWCWup.mjs";import{O as h,P as g}from"./fs-traced-DDm-belY.mjs";import{S as _,u as v,v as y,x as b}from"./server-lock-CcKfnBVl.mjs";import{t as x}from"./yazl-BafwB467.mjs";import{C as S,d as C,i as w,v as T,y as ee}from"./write-project-skill-C5NP_pT9.mjs";import{c as te}from"./colors-BsmVIwfM.mjs";import"./acp-harness-probe-C9B2T64O.mjs";import{D as E,E as D,S as ne,T as O,_ as k,b as re,o as ie,v as A}from"./init-CUJ7SCtW.mjs";import{n as ae}from"./constants-CLbzDwIP.mjs";import{t as j}from"./is-object-ByG7RnjH.mjs";import"./loader-CWirEDmB.mjs";import"./preview-BHq9Lqqb.mjs";import{execSync as oe,spawnSync as M}from"node:child_process";import{basename as N,dirname as P,isAbsolute as se,join as F,relative as ce,resolve as I,sep as le}from"node:path";import{cpSync as ue,createWriteStream as de,existsSync as L,lstatSync as fe,mkdirSync as R,mkdtempSync as pe,readFileSync as z,readdirSync as me,readlinkSync as he,rmSync as ge,statSync as _e,writeFileSync as B}from"node:fs";import{arch as ve,freemem as ye,homedir as be,hostname as xe,platform as Se,release as Ce,tmpdir as we,totalmem as Te,type as Ee,uptime as De}from"node:os";import{realpath as V}from"node:fs/promises";import{createHash as Oe}from"node:crypto";var H=m();const ke=new Set([`start`,`stop`,`status`,`clean`,`ui`,`mcp`,`preview`,`lint`,`deinit`,`auth`]);function Ae(e,t,n=p){if(e!==void 0&&!ke.has(e))return null;let r=n(t);return r===null||r.distance===0?null:r.rootPath}let je=null;function Me(e){je=e}function Ne(){return je??process.cwd()}function Pe(){return F(be(),`.ok`,`bug-reports`)}function Fe(e=new Date){let t=e.toISOString().replace(/[:.]/g,`-`),n=Pe(),r=`${t}-bugreport`,i=F(n,`${r}.zip`);for(let e=2;L(i);e+=1)i=F(n,`${r}-${e}.zip`);return i}function Ie(e,t){let n=F(e,`.ok`,`config.yml`);if(L(n))try{let e=z(n,`utf8`).match(/^\s*name:\s*['"]?(.+?)['"]?\s*$/m);if(e?.[1])return e[1]}catch(e){t?.warn({configPath:n,err:e},`bug-report: failed to read .ok/config.yml for project slug; using path-hash fallback`)}return L(F(e,`.ok`))?Oe(`sha256`).update(I(e)).digest(`hex`).slice(0,12):null}function Le(){let e={timestamp:new Date().toISOString(),platform:Se(),osType:Ee(),osRelease:Ce(),hostname:`[redacted]`,uptime:De(),freeMem:ye(),totalMem:Te(),nodeVersion:process.version,bunVersion:process.versions.bun??null,v8Version:process.versions.v8??null,pid:process.pid};try{e.macosVersion=oe(`sw_vers -productVersion 2>/dev/null`,s({encoding:`utf8`})).trim()}catch{}try{let t=F(__dirname,`..`,`..`,`package.json`);L(t)&&(e.okVersion=JSON.parse(z(t,`utf8`)).version)}catch{}return e}function Re(e,t){return ze(e,t).files}function ze(e,t){if(!L(t))return{files:[]};let n=me(t).filter(e=>e.endsWith(`.log`)||/\.log\.\d+$/.test(e)).map(e=>F(t,e));if(e&&n.length>0){let t=n.filter(t=>{try{return z(t,`utf8`).includes(`"project":"${e}"`)}catch{return!0}});t.length>0&&(n=t)}return{files:n}}function Be(e){let n=F(e,`.ok`,`local`);return L(n)?{files:[`server.lock`,`last-spawn-error.log`,t].map(e=>F(n,e)).filter(e=>L(e))}:{files:[]}}function Ve(e){let t=F(e,`.ok`,`local`,`logs`);return L(t)?{files:[`server-current.jsonl`,`server-prev.jsonl`].map(e=>F(t,e)).filter(e=>L(e))}:{files:[]}}function He(e){if(e.redact){let{redacted:t,patterns:n,lineCount:r}=i(e.content);e.zipfile.addBuffer(Buffer.from(t,`utf8`),e.name),e.bundleFiles.push(e.name),n.length>0&&e.redactions.push({file:e.name,lineCount:r,patterns:n})}else e.zipfile.addBuffer(Buffer.from(e.content,`utf8`),e.name),e.bundleFiles.push(e.name)}function U(e){for(let t of e.files)try{He({zipfile:e.zipfile,name:`${e.prefix}/${N(t)}`,content:z(t,`utf8`),redact:e.redact,bundleFiles:e.bundleFiles,redactions:e.redactions})}catch(n){e.logger?.warn({file:t,prefix:e.prefix,err:n},`bug-report: skipped unreadable file`)}}async function Ue(t){let{redact:n,outputPath:i,logger:a}=t,o=t.userLogsDir??F(be(),`.ok`,`logs`),s=t.projectDir?Ie(t.projectDir,a):null;R(P(i),{recursive:!0}),a?.info({projectSlug:s},`gathering diagnostic data`);let c=Le();c.desktop=t.desktop??null;let{files:l}=ze(s,o),{files:u}=t.projectDir?Be(t.projectDir):{files:[]},{files:d}=t.projectDir?Ve(t.projectDir):{files:[]};a?.info({logFileCount:l.length,lockFileCount:u.length,localSinkFileCount:d.length},`files collected`);let f=[],p=[],{ZipFile:m}=await import(`./yazl-vwTkB7U0.mjs`).then(t=>e(t.default,1)),h=new m;U({zipfile:h,files:l,prefix:`logs`,redact:n,bundleFiles:p,redactions:f,logger:a}),U({zipfile:h,files:u,prefix:`lockdir`,redact:n,bundleFiles:p,redactions:f,logger:a}),U({zipfile:h,files:d,prefix:`local-logs`,redact:n,bundleFiles:p,redactions:f,logger:a});for(let e of t.extraFiles??[])try{let t=z(e.sourcePath),n=`extra/${e.zipName??N(e.sourcePath)}`;h.addBuffer(t,n),p.push(n)}catch(t){a?.warn({sourcePath:e.sourcePath,err:t},`extra file unreadable; omitted from bundle`)}t.note&&He({zipfile:h,name:`note.txt`,content:t.note,redact:n,bundleFiles:p,redactions:f});let g=JSON.stringify(c,null,2);h.addBuffer(Buffer.from(g,`utf8`),`sysinfo.json`),p.push(`sysinfo.json`);let _={generatedAt:new Date().toISOString(),disciplineVersion:`1.0.0`,projectSlug:s,files:p,redactions:f,sysinfo:c};h.addBuffer(Buffer.from(JSON.stringify(_,null,2),`utf8`),`MANIFEST.json`);let v=f.reduce((e,t)=>e+t.lineCount,0),y=[`# Bug Report Bundle`,``,`Generated: ${_.generatedAt}`,`Project: ${s??`(unscoped)`}`,`Discipline version: ${_.disciplineVersion}`,``,`## Contents`,``,...p.map(e=>`- ${e}`),``,`## Privacy`,``,...n?[`This bundle was auto-redacted before packaging.`,`Patterns checked: ${r.join(`, `)}`,v>0?`${v} line(s) were scrubbed across ${f.length} file(s).`:`No redactions were needed.`,`See MANIFEST.json for the full redaction audit report.`,``,`This bundle is safe to attach to a GitHub issue.`]:[`Redaction was disabled for this bundle; file contents are unmodified.`]].join(`
|
|
2
2
|
`);h.addBuffer(Buffer.from(y,`utf8`),`README.md`),h.end();let b=de(i);return h.outputStream.pipe(b),await new Promise((e,t)=>{b.on(`close`,e),b.on(`error`,t)}),a?.info({bundlePath:i,fileCount:p.length,redactionCount:v},`bundle written`),{zipPath:i,summary:{projectSlug:s,files:p,redactions:f,redactedLineCount:v,generatedAt:_.generatedAt}}}var We=e(x(),1),W=e(te(),1);function G(e,t){return t.length===0||!e.includes(t)?e:e.split(t).join(`<CONTENT_DIR>`)}function Ge(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function K(e,t){if(typeof e==`string`)return G(e,t.contentDir);if(Array.isArray(e))return e.map(e=>K(e,t));if(!Ge(e))return e;let n={};for(let[r,i]of Object.entries(e))n[r]=K(i,t);return n}function Ke(e,t){let n=z(e,`utf-8`);if(n.length===0)return;let r=n.endsWith(`
|
|
3
3
|
`),i=n.split(`
|
|
4
4
|
`),a=[];for(let e=0;e<i.length;e++){let n=i[e]??``;if(!(e===i.length-1&&n===``)){if(n.length===0){a.push(``);continue}try{let e=K(JSON.parse(n),t);a.push(JSON.stringify(e))}catch{a.push(n)}}}B(e,r?`${a.join(`
|
|
@@ -16,5 +16,5 @@ import{o as e}from"./chunk-DTipWd-i.mjs";import{F as t,I as n,vo as r,yo as i,za
|
|
|
16
16
|
`)||(l=`${l}\n`):l=l.replace(/\n+$/,``),o&&(l=l.replace(/\r\n/g,`
|
|
17
17
|
`).replace(/\n/g,`\r
|
|
18
18
|
`));let u=`${i?``:``}${l}`;return u!==r&&g(e,u,{mode:O(e)}),{kind:`removed`}}function ln(e){return e==null?!1:e.includes(`--type=utility`)&&e.includes(`--utility-sub-type=node.mojom.NodeService`)}function un(e,t=Date.now()){let n=new Date(e).getTime();if(Number.isNaN(n))return`—`;let r=t-n,i=Math.floor(r/1e3);if(i<60)return`${i}s`;let a=Math.floor(i/60);if(a<60)return`${a}m ago`;let o=Math.floor(a/60);return o<24?`${o}h ago`:`${Math.floor(o/24)}d ago`}function dn(e,t,n,r,i,a){if(t.status===`missing`||t.status===`corrupt`)return null;let o=t.lock,s=null;if(n.status!==`missing`&&n.status!==`corrupt`){let e=n.lock;s={port:e.port,status:n.status,pid:e.pid,startedAt:e.startedAt,usage:a}}return{directory:o.worktreeRoot,server:{port:o.port,status:t.status,pid:o.pid,startedAt:o.startedAt,usage:i},ui:s,hostname:o.hostname,lockPath:t.lockPath,binary:r==null?null:f(r),command:r,isDesktop:ln(r)}}function fn(e){return e.ui==null?!1:e.ui.status===`alive`||e.ui.status===`foreign-host`}function Q(e){let t=e.server.status;return t===`alive`||t===`foreign-host`?e.isDesktop?`desktop`:t===`alive`?`running`:`foreign`:t===`dead-pid`&&fn(e)?`ui-orphan`:`stale`}const pn=new Set([`running`,`desktop`,`foreign`,`ui-orphan`]);function mn(e){switch(e){case`running`:return W.default.green(e);case`desktop`:return W.default.blue(e);case`foreign`:return W.default.cyan(e);case`ui-orphan`:return W.default.magenta(e);case`stale`:return W.default.yellow(e)}}function hn(e){return e==null?`—`:`${e.cpuPercent.toFixed(1)}% / ${e.memPercent.toFixed(1)}%`}function gn(e){return`${hn(e.server.usage)} | ${hn(e.ui?.usage??null)}`}function _n(e){return`${e.server.port===0?`(starting)`:String(e.server.port)} / ${e.ui==null||e.ui.status===`dead-pid`?`—`:String(e.ui.port)}`}function vn(e){if(e.length===0)return`No open-knowledge servers found.`;let t=[`DIRECTORY`,`PORTS (API/UI)`,`CPU/MEM (API | UI)`,`STATUS`,`PID`,`STARTED`,`BINARY`],n=e.map(e=>{let t=Q(e),n=t===`ui-orphan`&&e.ui!=null?e.ui.pid:e.server.pid;return[e.directory,_n(e),gn(e),t,String(n),un(e.server.startedAt),e.binary??`—`]}),r=t.length,i=t.map(e=>e.length);for(let e of n)for(let t=0;t<r;t++)i[t]=Math.max(i[t]??0,(e[t]??``).length);let a=t.map((e,t)=>e.padEnd(i[t]??0)).join(` `).trimEnd(),o=e.map((e,t)=>{let a=n[t]??[],o=[];for(let t=0;t<r;t++){let n=(a[t]??``).padEnd(i[t]??0);if(t===3){let r=a[t]??``;n=mn(Q(e))+` `.repeat(Math.max(0,(i[t]??0)-r.length))}o.push(n)}return o.join(` `).trimEnd()}),s=W.default.dim(`To stop a server: ok stop <port|pid|directory|all>`);return[a,...o,``,s].join(`
|
|
19
|
-
`)}async function yn(e={}){let t=e.discover??d,n=e.inspect??Z,r=e.log??(e=>console.log(e)),i=e.resolveCommand??
|
|
20
|
-
//# sourceMappingURL=src-
|
|
19
|
+
`)}async function yn(e={}){let t=e.discover??d,n=e.inspect??Z,r=e.log??(e=>console.log(e)),i=e.resolveCommand??u,a=e.resolveUsage??c,o=await t(),s=[];for(let e of o){let t=n(e,`server`),r=n(e,`ui`),o=dn(e,t,r,t.status===`missing`||t.status===`corrupt`?null:i(t.lock.pid),t.status===`missing`||t.status===`corrupt`?null:a(t.lock.pid),r.status===`missing`||r.status===`corrupt`?null:a(r.lock.pid));o!=null&&s.push(o)}if(e.json){let e=s.map(e=>({...e,displayStatus:Q(e)}));r(JSON.stringify(e,null,2));return}r(vn(e.all?s:s.filter(e=>pn.has(Q(e)))))}function bn(){return new S(`ps`).description(`List all running open-knowledge servers`).argument(`[modifier]`,`"all" to include stale (dead-pid) entries`).option(`--all`,`Include stale (dead-pid) entries (foreign-host shows by default)`).option(`--json`,`Emit structured JSON (always includes all statuses)`).action(async(e,t)=>{await yn({all:t.all===!0||e===`all`,json:t.json===!0})})}function xn(e,t,n={}){let r=n.isAlive??b,i=[];for(let[n,a]of[[`server`,e],[`ui`,t]])(a.status===`alive`||a.status===`foreign-host`&&r(a.lock.pid))&&i.push({name:n,pid:a.lock.pid,port:a.lock.port});return{targets:i}}function Sn(e){let t=e.inspect??(t=>Z(e.lockDir,t)),n=e.kill??((e,t)=>process.kill(e,t)),r=e.log??(e=>console.log(e)),i=e.error??(e=>console.error(e)),a=xn(t(`server`),t(`ui`),{isAlive:e.isAlive});if(a.targets.length===0)return r(`No running open-knowledge processes.`),{stopped:[],failed:[],hadTargets:!1};let o=[],s=[];for(let e of a.targets)try{n(e.pid,`SIGTERM`),o.push(e)}catch(t){s.push({target:e,error:t instanceof Error?t.message:String(t)})}return o.length>0&&r(`Stopped: ${o.map(e=>`${e.name} (pid=${e.pid}, port=${e.port})`).join(`, `)}`),s.length>0&&i(`Failed to stop: ${s.map(({target:e,error:t})=>`${e.name} (pid=${e.pid}): ${t}`).join(`; `)}`),{stopped:o,failed:s,hadTargets:!0}}function $(e,t){return e.status===`alive`?!0:e.status===`foreign-host`?t(e.lock.pid):!1}async function Cn(e,t=b){let n=await d(),r=null;for(let i of n){let n=Z(i,`server`),a=Z(i,`ui`);if($(n,t)&&n.lock.port===e||$(a,t)&&a.lock.port===e)return i;r===null&&($(n,t)&&n.lock.pid===e||$(a,t)&&a.lock.pid===e)&&(r=i)}return r}function wn(e){let t=Sn({lockDir:e});return t.failed.length>0&&(process.exitCode=1),t}function Tn(e){return new S(`stop`).description(`Stop open-knowledge server(s). With no argument: stops the server for the current directory. Pass a port number, a directory path, or "all" to target globally.`).argument(`[target...]`,`port number, directory path (spaces OK), or "all"`).action(async t=>{let n=t.length===0?void 0:t.join(` `);if(n===void 0){e();let t=Sn({lockDir:l(process.cwd()),log:()=>{}});if(t.hadTargets){if(t.stopped.length>0){let e=t.stopped.map(e=>`${e.name} (pid=${e.pid}, port=${e.port})`).join(`, `);console.log(`Stopped: ${e}`)}t.failed.length>0&&(process.exitCode=1)}else await yn({});return}if(n===`all`){let e=await d();if(e.length===0){console.log(`No running open-knowledge servers found.`);return}let t=0;for(let n of e){let e=Z(n,`server`),r=Z(n,`ui`);!$(e,b)&&!$(r,b)||(wn(n),t++)}t===0&&console.log(`No running open-knowledge servers found.`);return}if(/^\d+$/.test(n)){let e=Number.parseInt(n,10),t=await Cn(e);if(t===null){console.log(`No running open-knowledge server found with port or PID ${e}.`);return}wn(t);return}wn(l(I(Ne(),n)))})}function En(e){return{event:`mcp-config-decline`,scope:e.scope,surface:e.surface,editorId:e.editorId,reason:e.reason}}async function Dn(e,t){let n,r;try{n=await V(I(e)),r=await V(I(P(e)))}catch{return{kind:`not-git`}}if(!On(n,r))return{kind:`symlink-escape`};let i=F(n,`.git`),s;try{s=_e(i)}catch{return{kind:`not-git`}}if(s.isDirectory()){let e;try{e=await V(i)}catch{return{kind:`not-git`}}if(!On(e,n))return{kind:`symlink-escape`}}else if(!s.isFile())return{kind:`not-git`};let c=o(n);if(c.kind!==`repository`)return{kind:`not-git`};let l=c.repository.readRemoteUrl(`origin`);if(l.kind===`unreadable`)return{kind:`not-git`};if(l.kind===`absent`)return l.reason===`config-missing`?{kind:`not-git`}:{kind:`no-origin`};let u=l.url,d=Wt(u);if(d===null)return{kind:`non-github`};let f=a(d.hostname);if(f===null)return{kind:`non-github`};let p=f===t.host.toLowerCase(),m=d.owner.toLowerCase()===t.owner.toLowerCase(),h=d.name.toLowerCase()===t.repo.toLowerCase();return!p&&m&&h?{kind:`wrong-host`,actualHost:f}:!p||!m||!h?{kind:`wrong-repo`,actualOwner:d.owner,actualRepo:d.name}:{kind:`ok`,gitRemoteUrl:`https://${f}/${d.owner}/${d.name}.git`}}function On(e,t){if(e===t)return!0;let n=ce(t,e);return n.length>0&&!n.startsWith(`..`)&&!se(n)}const kn=[{id:`mcp-config`,write(e,t,n){let r=e.projectConfigPath?.(t);if(!r)return{integration:`mcp-config`,editorId:e.id,action:`skipped-unsupported`};try{let i=A(e,t,n,void 0,r);return i.action===`written`||i.action===`overwritten`?{integration:`mcp-config`,editorId:e.id,action:i.action,path:i.configPath}:i.action===`failed`?{integration:`mcp-config`,editorId:e.id,action:`failed`,path:i.configPath,error:i.error??`unknown failure`}:i.action===`declined`?{integration:`mcp-config`,editorId:e.id,action:`declined`,path:i.configPath,...i.declineReason===void 0?{}:{reason:i.declineReason}}:{integration:`mcp-config`,editorId:e.id,action:`failed`,path:i.configPath,error:`unexpected project-scope action: ${i.action}`}}catch(t){return{integration:`mcp-config`,editorId:e.id,action:`failed`,path:r,error:t instanceof Error?t.message:String(t)}}}},{id:`project-skill`,write(e,t,n){try{let r=w(e,t,{home:n.home});return{integration:`project-skill`,editorId:e.id,action:r.action,...r.path?{path:r.path}:{},...r.error?{error:r.error}:{}}}catch(t){return{integration:`project-skill`,editorId:e.id,action:`failed`,error:t instanceof Error?t.message:String(t)}}}}];function An(e,t,n={},r=kn){let i=[];for(let a of t){let t=C[a];for(let a of r)i.push(a.write(t,e,n))}return i}function jn(e,t,n={}){return{integrations:An(e,t,n)}}export{Fe as C,Ae as D,Me as E,zt as S,Ne as T,Kt as _,Tn as a,Ht as b,Jt as c,tn as d,Zt as f,qt as g,Gt as h,Sn as i,Xt as l,en as m,Dn as n,bn as o,$t as p,En as r,an as s,jn as t,Yt as u,Wt as v,Pe as w,Rt as x,Z as y};
|
|
20
|
+
//# sourceMappingURL=src-CslgYdG3.mjs.map
|
|
@@ -332,5 +332,5 @@ Read more at https://docs.orama.com/docs/orama-js/plugins/plugin-secure-proxy#pl
|
|
|
332
332
|
`,ANSWER_SESSION_LAST_MESSAGE_IS_NOT_ASSISTANT:`The last message in the session is not an assistant message. Cannot regenerate non-assistant messages.`,PLUGIN_COMPONENT_CONFLICT:`The component "%s" is already defined. The plugin "%s" is trying to redefine it.`};function A0(e,...t){let n=Error(s0(k0[e]??`Unsupported Orama Error code: ${e}`,...t));return n.code=e,`captureStackTrace`in Error.prototype&&Error.captureStackTrace(n),n}function j0(e){return{raw:Number(e),formatted:d0(e)}}function M0(e){if(e.id){if(typeof e.id!=`string`)throw A0(`DOCUMENT_ID_MUST_BE_STRING`,typeof e.id);return e.id}return p0()}function N0(e,t){for(let[n,r]of Object.entries(t)){let t=e[n];if(t!==void 0&&!(r===`geopoint`&&typeof t==`object`&&typeof t.lon==`number`&&typeof t.lat==`number`)&&!(r===`enum`&&(typeof t==`string`||typeof t==`number`))){if(r===`enum[]`&&Array.isArray(t)){let e=t.length;for(let r=0;r<e;r++)if(typeof t[r]!=`string`&&typeof t[r]!=`number`)return n+`.`+r;continue}if(L0(r)){let e=B0(r);if(!Array.isArray(t)||t.length!==e)throw A0(`INVALID_INPUT_VECTOR`,n,e,t.length);continue}if(R0(r)){if(!Array.isArray(t))return n;let e=z0(r),i=t.length;for(let r=0;r<i;r++)if(typeof t[r]!==e)return n+`.`+r;continue}if(typeof r==`object`){if(!t||typeof t!=`object`)return n;let e=N0(t,r);if(e)return n+`.`+e;continue}if(typeof t!==r)return n}}}const P0={string:!1,number:!1,boolean:!1,enum:!1,geopoint:!1,"string[]":!0,"number[]":!0,"boolean[]":!0,"enum[]":!0},F0={"string[]":`string`,"number[]":`number`,"boolean[]":`boolean`,"enum[]":`enum`};function I0(e){return e===`geopoint`}function L0(e){return typeof e==`string`&&/^vector\[\d+\]$/.test(e)}function R0(e){return typeof e==`string`&&P0[e]}function z0(e){return F0[e]}function B0(e){let t=Number(e.slice(7,-1));switch(!0){case isNaN(t):throw A0(`INVALID_VECTOR_VALUE`,e);case t<=0:throw A0(`INVALID_VECTOR_SIZE`,e);default:return t}}function V0(){return{idToInternalId:new Map,internalIdToId:[],save:H0,load:U0}}function H0(e){return{internalIdToId:e.internalIdToId}}function U0(e,t){let{internalIdToId:n}=t;e.internalDocumentIDStore.idToInternalId.clear(),e.internalDocumentIDStore.internalIdToId=[];let r=n.length;for(let t=0;t<r;t++){let r=n[t];e.internalDocumentIDStore.idToInternalId.set(r,t+1),e.internalDocumentIDStore.internalIdToId.push(r)}}function W0(e,t){if(typeof t==`string`){let n=e.idToInternalId.get(t);if(n)return n;let r=e.idToInternalId.size+1;return e.idToInternalId.set(t,r),e.internalIdToId.push(t),r}return t>e.internalIdToId.length?W0(e,t.toString()):t}function G0(e,t){if(e.internalIdToId.length<t)throw Error(`Invalid internalId ${t}`);return e.internalIdToId[t-1]}function K0(e,t){return{sharedInternalDocumentStore:t,docs:{},count:0}}function q0(e,t){let n=W0(e.sharedInternalDocumentStore,t);return e.docs[n]}function J0(e,t){let n=t.length,r=Array.from({length:n});for(let i=0;i<n;i++){let n=W0(e.sharedInternalDocumentStore,t[i]);r[i]=e.docs[n]}return r}function Y0(e){return e.docs}function X0(e,t,n,r){return e.docs[n]===void 0?(e.docs[n]=r,e.count++,!0):!1}function Z0(e,t){let n=W0(e.sharedInternalDocumentStore,t);return e.docs[n]===void 0?!1:(delete e.docs[n],e.count--,!0)}function Q0(e){return e.count}function $0(e,t){let n=t;return{docs:n.docs,count:n.count,sharedInternalDocumentStore:e}}function e2(e){return{docs:e.docs,count:e.count}}function t2(){return{create:K0,get:q0,getMultiple:J0,getAll:Y0,store:X0,remove:Z0,count:Q0,load:$0,save:e2}}const n2=[`beforeInsert`,`afterInsert`,`beforeRemove`,`afterRemove`,`beforeUpdate`,`afterUpdate`,`beforeUpsert`,`afterUpsert`,`beforeSearch`,`afterSearch`,`beforeInsertMultiple`,`afterInsertMultiple`,`beforeRemoveMultiple`,`afterRemoveMultiple`,`beforeUpdateMultiple`,`afterUpdateMultiple`,`beforeUpsertMultiple`,`afterUpsertMultiple`,`beforeLoad`,`afterLoad`,`afterCreate`];function r2(e,t){let n=[],r=e.plugins?.length;if(!r)return n;for(let i=0;i<r;i++)try{let r=e.plugins[i];typeof r[t]==`function`&&n.push(r[t])}catch(e){throw console.error(`Caught error in getAllPluginsByHook:`,e),A0(`PLUGIN_CRASHED`)}return n}const i2=[`tokenizer`,`index`,`documentsStore`,`sorter`,`pinning`],a2=[`validateSchema`,`getDocumentIndexId`,`getDocumentProperties`,`formatElapsedTime`];function o2(e,t,n,r){if(e.some(S0))return(async()=>{for(let i of e)await i(t,n,r)})();for(let i of e)i(t,n,r)}function s2(e,t,n){if(e.some(S0))return(async()=>{for(let r of e)await r(t,n)})();for(let r of e)r(t,n)}function c2(e,t,n,r,i){if(e.some(S0))return(async()=>{for(let a of e)await a(t,n,r,i)})();for(let a of e)a(t,n,r,i)}function l2(e,t,n,r){if(e.some(S0))return(async()=>{for(let i of e)await i(t,n,r)})();for(let i of e)i(t,n,r)}function u2(e,t){if(e.some(S0))return(async()=>{for(let n of e)await n(t)})();for(let n of e)n(t)}var d2=class e{k;v;l=null;r=null;h=1;constructor(e,t){this.k=e,this.v=new Set(t)}updateHeight(){this.h=Math.max(e.getHeight(this.l),e.getHeight(this.r))+1}static getHeight(e){return e?e.h:0}getBalanceFactor(){return e.getHeight(this.l)-e.getHeight(this.r)}rotateLeft(){let e=this.r;return this.r=e.l,e.l=this,this.updateHeight(),e.updateHeight(),e}rotateRight(){let e=this.l;return this.l=e.r,e.r=this,this.updateHeight(),e.updateHeight(),e}toJSON(){return{k:this.k,v:Array.from(this.v),l:this.l?this.l.toJSON():null,r:this.r?this.r.toJSON():null,h:this.h}}static fromJSON(t){let n=new e(t.k,t.v);return n.l=t.l?e.fromJSON(t.l):null,n.r=t.r?e.fromJSON(t.r):null,n.h=t.h,n}},f2=class e{root=null;insertCount=0;constructor(e,t){e!==void 0&&t!==void 0&&(this.root=new d2(e,t))}insert(e,t,n=1e3){this.root=this.insertNode(this.root,e,t,n)}insertMultiple(e,t,n=1e3){for(let r of t)this.insert(e,r,n)}rebalance(){this.root&&=this.rebalanceNode(this.root)}toJSON(){return{root:this.root?this.root.toJSON():null,insertCount:this.insertCount}}static fromJSON(t){let n=new e;return n.root=t.root?d2.fromJSON(t.root):null,n.insertCount=t.insertCount||0,n}insertNode(e,t,n,r){if(e===null)return new d2(t,[n]);let i=[],a=e,o=null;for(;a!==null;)if(i.push({parent:o,node:a}),t<a.k)if(a.l===null){a.l=new d2(t,[n]),i.push({parent:a,node:a.l});break}else o=a,a=a.l;else if(t>a.k)if(a.r===null){a.r=new d2(t,[n]),i.push({parent:a,node:a.r});break}else o=a,a=a.r;else return a.v.add(n),e;let s=!1;this.insertCount++%r===0&&(s=!0);for(let t=i.length-1;t>=0;t--){let{parent:n,node:r}=i[t];if(r.updateHeight(),s){let t=this.rebalanceNode(r);n?n.l===r?n.l=t:n.r===r&&(n.r=t):e=t}}return e}rebalanceNode(e){let t=e.getBalanceFactor();if(t>1){if(e.l&&e.l.getBalanceFactor()>=0)return e.rotateRight();if(e.l)return e.l=e.l.rotateLeft(),e.rotateRight()}if(t<-1){if(e.r&&e.r.getBalanceFactor()<=0)return e.rotateLeft();if(e.r)return e.r=e.r.rotateRight(),e.rotateLeft()}return e}find(e){let t=this.findNodeByKey(e);return t?t.v:null}contains(e){return this.find(e)!==null}getSize(){let e=0,t=[],n=this.root;for(;n||t.length>0;){for(;n;)t.push(n),n=n.l;n=t.pop(),e++,n=n.r}return e}isBalanced(){if(!this.root)return!0;let e=[this.root];for(;e.length>0;){let t=e.pop(),n=t.getBalanceFactor();if(Math.abs(n)>1)return!1;t.l&&e.push(t.l),t.r&&e.push(t.r)}return!0}remove(e){this.root=this.removeNode(this.root,e)}removeDocument(e,t){let n=this.findNodeByKey(e);n&&(n.v.size===1?this.root=this.removeNode(this.root,e):n.v=new Set([...n.v.values()].filter(e=>e!==t)))}findNodeByKey(e){let t=this.root;for(;t;)if(e<t.k)t=t.l;else if(e>t.k)t=t.r;else return t;return null}removeNode(e,t){if(e===null)return null;let n=[],r=e;for(;r!==null&&r.k!==t;)n.push(r),r=t<r.k?r.l:r.r;if(r===null)return e;if(r.l===null||r.r===null){let t=r.l?r.l:r.r;if(n.length===0)e=t;else{let e=n[n.length-1];e.l===r?e.l=t:e.r=t}}else{let e=r,t=r.r;for(;t.l!==null;)e=t,t=t.l;r.k=t.k,r.v=t.v,e.l===t?e.l=t.r:e.r=t.r,r=e}n.push(r);for(let t=n.length-1;t>=0;t--){let r=n[t];r.updateHeight();let i=this.rebalanceNode(r);if(t>0){let e=n[t-1];e.l===r?e.l=i:e.r===r&&(e.r=i)}else e=i}return e}rangeSearch(e,t){let n=new Set,r=[],i=this.root;for(;i||r.length>0;){for(;i;)r.push(i),i=i.l;if(i=r.pop(),i.k>=e&&i.k<=t)for(let e of i.v)n.add(e);if(i.k>t)break;i=i.r}return n}greaterThan(e,t=!1){let n=new Set,r=[],i=this.root;for(;i||r.length>0;){for(;i;)r.push(i),i=i.r;if(i=r.pop(),t&&i.k>=e||!t&&i.k>e)for(let e of i.v)n.add(e);else if(i.k<=e)break;i=i.l}return n}lessThan(e,t=!1){let n=new Set,r=[],i=this.root;for(;i||r.length>0;){for(;i;)r.push(i),i=i.l;if(i=r.pop(),t&&i.k<=e||!t&&i.k<e)for(let e of i.v)n.add(e);else if(i.k>e)break;i=i.r}return n}},p2=class e{numberToDocumentId;constructor(){this.numberToDocumentId=new Map}insert(e,t){this.numberToDocumentId.has(e)?this.numberToDocumentId.get(e).add(t):this.numberToDocumentId.set(e,new Set([t]))}find(e){let t=this.numberToDocumentId.get(e);return t?Array.from(t):null}remove(e){this.numberToDocumentId.delete(e)}removeDocument(e,t){let n=this.numberToDocumentId.get(t);n&&(n.delete(e),n.size===0&&this.numberToDocumentId.delete(t))}contains(e){return this.numberToDocumentId.has(e)}getSize(){let e=0;for(let t of this.numberToDocumentId.values())e+=t.size;return e}filter(e){let t=Object.keys(e);if(t.length!==1)throw Error(`Invalid operation`);let n=t[0];switch(n){case`eq`:{let t=e[n],r=this.numberToDocumentId.get(t);return r?Array.from(r):[]}case`in`:{let t=e[n],r=new Set;for(let e of t){let t=this.numberToDocumentId.get(e);if(t)for(let e of t)r.add(e)}return Array.from(r)}case`nin`:{let t=new Set(e[n]),r=new Set;for(let[e,n]of this.numberToDocumentId.entries())if(!t.has(e))for(let e of n)r.add(e);return Array.from(r)}default:throw Error(`Invalid operation`)}}filterArr(e){let t=Object.keys(e);if(t.length!==1)throw Error(`Invalid operation`);let n=t[0];switch(n){case`containsAll`:{let t=e[n].map(e=>this.numberToDocumentId.get(e)??new Set);if(t.length===0)return[];let r=t.reduce((e,t)=>new Set([...e].filter(e=>t.has(e))));return Array.from(r)}case`containsAny`:{let t=e[n].map(e=>this.numberToDocumentId.get(e)??new Set);if(t.length===0)return[];let r=t.reduce((e,t)=>new Set([...e,...t]));return Array.from(r)}default:throw Error(`Invalid operation`)}}static fromJSON(t){if(!t.numberToDocumentId)throw Error(`Invalid Flat Tree JSON`);let n=new e;for(let[e,r]of t.numberToDocumentId)n.numberToDocumentId.set(e,new Set(r));return n}toJSON(){return{numberToDocumentId:Array.from(this.numberToDocumentId.entries()).map(([e,t])=>[e,Array.from(t)])}}};function m2(e,t,n){if(n<0)return-1;if(e===t)return 0;let r=e.length,i=t.length;if(r===0)return i<=n?i:-1;if(i===0)return r<=n?r:-1;let a=Math.abs(r-i);if(e.startsWith(t))return a<=n?a:-1;if(t.startsWith(e))return 0;if(a>n)return-1;let o=[];for(let e=0;e<=r;e++){o[e]=[e];for(let t=1;t<=i;t++)o[e][t]=e===0?t:0}for(let a=1;a<=r;a++){let r=1/0;for(let n=1;n<=i;n++)e[a-1]===t[n-1]?o[a][n]=o[a-1][n-1]:o[a][n]=Math.min(o[a-1][n]+1,o[a][n-1]+1,o[a-1][n-1]+1),r=Math.min(r,o[a][n]);if(r>n)return-1}return o[r][i]<=n?o[r][i]:-1}function h2(e,t,n){let r=m2(e,t,n);return{distance:r,isBounded:r>=0}}var g2=class e{k;s;c=new Map;d=new Set;e;w=``;constructor(e,t,n){this.k=e,this.s=t,this.e=n}updateParent(e){this.w=e.w+this.s}addDocument(e){this.d.add(e)}removeDocument(e){return this.d.delete(e)}findAllWords(e,t,n,r){let i=[this];for(;i.length>0;){let a=i.pop();if(a.e){let{w:i,d:o}=a;if(n&&i!==t)continue;if(m0(e,i)!==null)if(r)if(Math.abs(t.length-i.length)<=r&&h2(t,i,r).isBounded)e[i]=[];else continue;else e[i]=[];if(m0(e,i)!=null&&o.size>0){let t=e[i];for(let e of o)t.includes(e)||t.push(e)}}a.c.size>0&&i.push(...a.c.values())}return e}insert(t,n){let r=this,i=0,a=t.length;for(;i<a;){let o=t[i],s=r.c.get(o);if(s){let o=s.s,c=o.length,l=0;for(;l<c&&i+l<a&&o[l]===t[i+l];)l++;if(l===c){if(r=s,i+=l,i===a){s.e||=!0,s.addDocument(n);return}continue}let u=o.slice(0,l),d=o.slice(l),f=t.slice(i+l),p=new e(u[0],u,!1);if(r.c.set(u[0],p),p.updateParent(r),s.s=d,s.k=d[0],p.c.set(d[0],s),s.updateParent(p),f){let t=new e(f[0],f,!0);t.addDocument(n),p.c.set(f[0],t),t.updateParent(p)}else p.e=!0,p.addDocument(n);return}else{let a=new e(o,t.slice(i),!0);a.addDocument(n),r.c.set(o,a),a.updateParent(r);return}}r.e||=!0,r.addDocument(n)}_findLevenshtein(e,t,n,r,i){let a=[{node:this,index:t,tolerance:n}];for(;a.length>0;){let{node:t,index:n,tolerance:o}=a.pop();if(t.w.startsWith(e)){t.findAllWords(i,e,!1,0);continue}if(o<0)continue;if(t.e){let{w:n,d:a}=t;if(n&&(h2(e,n,r).isBounded&&(i[n]=[]),m0(i,n)!==void 0&&a.size>0)){let e=new Set(i[n]);for(let t of a)e.add(t);i[n]=Array.from(e)}}if(n>=e.length)continue;let s=e[n];if(t.c.has(s)){let e=t.c.get(s);a.push({node:e,index:n+1,tolerance:o})}a.push({node:t,index:n+1,tolerance:o-1});for(let[e,r]of t.c)a.push({node:r,index:n,tolerance:o-1}),e!==s&&a.push({node:r,index:n+1,tolerance:o-1})}}find(e){let{term:t,exact:n,tolerance:r}=e;if(r&&!n){let e={};return this._findLevenshtein(t,0,r,r,e),e}else{let e=this,i=0,a=t.length;for(;i<a;){let o=t[i],s=e.c.get(o);if(s){let o=s.s,c=o.length,l=0;for(;l<c&&i+l<a&&o[l]===t[i+l];)l++;if(l===c)e=s,i+=l;else if(i+l===a)if(l===a-i){if(n)return{};{let e={};return s.findAllWords(e,t,n,r),e}}else return{};else return{}}else return{}}let o={};return e.findAllWords(o,t,n,r),o}}contains(e){let t=this,n=0,r=e.length;for(;n<r;){let i=e[n],a=t.c.get(i);if(a){let i=a.s,o=i.length,s=0;for(;s<o&&n+s<r&&i[s]===e[n+s];)s++;if(s<o)return!1;n+=o,t=a}else return!1}return!0}removeWord(e){if(!e)return!1;let t=this,n=e.length,r=[];for(let i=0;i<n;i++){let n=e[i];if(t.c.has(n)){let e=t.c.get(n);r.push({parent:t,character:n}),i+=e.s.length-1,t=e}else return!1}for(t.d.clear(),t.e=!1;r.length>0&&t.c.size===0&&!t.e&&t.d.size===0;){let{parent:e,character:n}=r.pop();e.c.delete(n),t=e}return!0}removeDocumentByWord(e,t,n=!0){if(!e)return!0;let r=this,i=e.length;for(let a=0;a<i;a++){let i=e[a];if(r.c.has(i)){let o=r.c.get(i);a+=o.s.length-1,r=o,n&&r.w!==e||r.removeDocument(t)}else return!1}return!0}static getCommonPrefix(e,t){let n=Math.min(e.length,t.length),r=0;for(;r<n&&e.charCodeAt(r)===t.charCodeAt(r);)r++;return e.slice(0,r)}toJSON(){return{w:this.w,s:this.s,e:this.e,k:this.k,d:Array.from(this.d),c:Array.from(this.c?.entries())?.map(([e,t])=>[e,t.toJSON()])}}static fromJSON(t){let n=new e(t.k,t.s,t.e);return n.w=t.w,n.d=new Set(t.d),n.c=new Map(t?.c?.map(([t,n])=>[t,e.fromJSON(n)])||[]),n}},_2=class e extends g2{constructor(){super(``,``,!1)}static fromJSON(t){let n=new e;return n.w=t.w,n.s=t.s,n.e=t.e,n.k=t.k,n.d=new Set(t.d),n.c=new Map(t?.c?.map(([e,t])=>[e,g2.fromJSON(t)])||[]),n}toJSON(){return super.toJSON()}},v2=class e{point;docIDs;left;right;parent;constructor(e,t){this.point=e,this.docIDs=new Set(t),this.left=null,this.right=null,this.parent=null}toJSON(){return{point:this.point,docIDs:Array.from(this.docIDs),left:this.left?this.left.toJSON():null,right:this.right?this.right.toJSON():null}}static fromJSON(t,n=null){let r=new e(t.point,t.docIDs);return r.parent=n,t.left&&(r.left=e.fromJSON(t.left,r)),t.right&&(r.right=e.fromJSON(t.right,r)),r}},y2=class e{root;nodeMap;constructor(){this.root=null,this.nodeMap=new Map}getPointKey(e){return`${e.lon},${e.lat}`}insert(e,t){let n=this.getPointKey(e),r=this.nodeMap.get(n);if(r){t.forEach(e=>r.docIDs.add(e));return}let i=new v2(e,t);if(this.nodeMap.set(n,i),this.root==null){this.root=i;return}let a=this.root,o=0;for(;;){if(o%2==0)if(e.lon<a.point.lon){if(a.left==null){a.left=i,i.parent=a;return}a=a.left}else{if(a.right==null){a.right=i,i.parent=a;return}a=a.right}else if(e.lat<a.point.lat){if(a.left==null){a.left=i,i.parent=a;return}a=a.left}else{if(a.right==null){a.right=i,i.parent=a;return}a=a.right}o++}}contains(e){let t=this.getPointKey(e);return this.nodeMap.has(t)}getDocIDsByCoordinates(e){let t=this.getPointKey(e),n=this.nodeMap.get(t);return n?Array.from(n.docIDs):null}removeDocByID(e,t){let n=this.getPointKey(e),r=this.nodeMap.get(n);r&&(r.docIDs.delete(t),r.docIDs.size===0&&(this.nodeMap.delete(n),this.deleteNode(r)))}deleteNode(e){let t=e.parent,n=e.left?e.left:e.right;n&&(n.parent=t),t?t.left===e?t.left=n:t.right===e&&(t.right=n):(this.root=n,this.root&&(this.root.parent=null))}searchByRadius(t,n,r=!0,i=`asc`,a=!1){let o=a?e.vincentyDistance:e.haversineDistance,s=[{node:this.root,depth:0}],c=[];for(;s.length>0;){let{node:e,depth:i}=s.pop();if(e==null)continue;let a=o(t,e.point);(r?a<=n:a>n)&&c.push({point:e.point,docIDs:Array.from(e.docIDs)}),e.left!=null&&s.push({node:e.left,depth:i+1}),e.right!=null&&s.push({node:e.right,depth:i+1})}return i&&c.sort((e,n)=>{let r=o(t,e.point),a=o(t,n.point);return i.toLowerCase()===`asc`?r-a:a-r}),c}searchByPolygon(t,n=!0,r=null,i=!1){let a=[{node:this.root,depth:0}],o=[];for(;a.length>0;){let{node:r,depth:i}=a.pop();if(r==null)continue;r.left!=null&&a.push({node:r.left,depth:i+1}),r.right!=null&&a.push({node:r.right,depth:i+1});let s=e.isPointInPolygon(t,r.point);(s&&n||!s&&!n)&&o.push({point:r.point,docIDs:Array.from(r.docIDs)})}let s=e.calculatePolygonCentroid(t);if(r){let t=i?e.vincentyDistance:e.haversineDistance;o.sort((e,n)=>{let i=t(s,e.point),a=t(s,n.point);return r.toLowerCase()===`asc`?i-a:a-i})}return o}toJSON(){return{root:this.root?this.root.toJSON():null}}static fromJSON(t){let n=new e;return t.root&&(n.root=v2.fromJSON(t.root),n.buildNodeMap(n.root)),n}buildNodeMap(e){if(e==null)return;let t=this.getPointKey(e.point);this.nodeMap.set(t,e),e.left&&this.buildNodeMap(e.left),e.right&&this.buildNodeMap(e.right)}static calculatePolygonCentroid(e){let t=0,n=0,r=0,i=e.length;for(let a=0,o=i-1;a<i;o=a++){let i=e[a].lon,s=e[a].lat,c=e[o].lon,l=e[o].lat,u=i*l-c*s;t+=u,n+=(i+c)*u,r+=(s+l)*u}t/=2;let a=6*t;return n/=a,r/=a,{lon:n,lat:r}}static isPointInPolygon(e,t){let n=!1,r=t.lon,i=t.lat,a=e.length;for(let t=0,o=a-1;t<a;o=t++){let a=e[t].lon,s=e[t].lat,c=e[o].lon,l=e[o].lat;s>i!=l>i&&r<(c-a)*(i-s)/(l-s)+a&&(n=!n)}return n}static haversineDistance(e,t){let n=Math.PI/180,r=e.lat*n,i=t.lat*n,a=(t.lat-e.lat)*n,o=(t.lon-e.lon)*n,s=Math.sin(a/2)*Math.sin(a/2)+Math.cos(r)*Math.cos(i)*Math.sin(o/2)*Math.sin(o/2);return 6371e3*(2*Math.atan2(Math.sqrt(s),Math.sqrt(1-s)))}static vincentyDistance(e,t){let n=6378137,r=1/298.257223563,i=(1-r)*n,a=Math.PI/180,o=e.lat*a,s=t.lat*a,c=(t.lon-e.lon)*a,l=Math.atan((1-r)*Math.tan(o)),u=Math.atan((1-r)*Math.tan(s)),d=Math.sin(l),f=Math.cos(l),p=Math.sin(u),m=Math.cos(u),h=c,g,_=1e3,v,y,b,x,S,C;do{let e=Math.sin(h),t=Math.cos(h);if(v=Math.sqrt(m*e*(m*e)+(f*p-d*m*t)*(f*p-d*m*t)),v===0)return 0;y=d*p+f*m*t,b=Math.atan2(v,y),x=f*m*e/v,S=1-x*x,C=y-2*d*p/S,isNaN(C)&&(C=0);let n=r/16*S*(4+r*(4-3*S));g=h,h=c+(1-n)*r*x*(b+n*v*(C+n*y*(-1+2*C*C)))}while(Math.abs(h-g)>1e-12&&--_>0);if(_===0)return NaN;let w=S*(n*n-i*i)/(i*i),T=1+w/16384*(4096+w*(-768+w*(320-175*w))),E=w/1024*(256+w*(-128+w*(74-47*w))),D=E*v*(C+E/4*(y*(-1+2*C*C)-E/6*C*(-3+4*v*v)*(-3+4*C*C)));return i*T*(b-D)}},b2=class e{true;false;constructor(){this.true=new Set,this.false=new Set}insert(e,t){t?this.true.add(e):this.false.add(e)}delete(e,t){t?this.true.delete(e):this.false.delete(e)}getSize(){return this.true.size+this.false.size}toJSON(){return{true:Array.from(this.true),false:Array.from(this.false)}}static fromJSON(t){let n=new e;return n.true=new Set(t.true),n.false=new Set(t.false),n}};function x2(e,t,n,r,i,{k:a,b:o,d:s}){return Math.log(1+(n-t+.5)/(t+.5))*(s+e*(a+1))/(e+a*(1-o+o*r/i))}var S2=class e{size;vectors=new Map;constructor(e){this.size=e}add(e,t){t instanceof Float32Array||(t=new Float32Array(t));let n=C2(t,this.size);this.vectors.set(e,[n,t])}remove(e){this.vectors.delete(e)}find(e,t,n){return e instanceof Float32Array||(e=new Float32Array(e)),w2(e,n,this.vectors,this.size,t)}toJSON(){let e=[];for(let[t,[n,r]]of this.vectors)e.push([t,[n,Array.from(r)]]);return{size:this.size,vectors:e}}static fromJSON(t){let n=t,r=new e(n.size);for(let[e,[t,i]]of n.vectors)r.vectors.set(e,[t,new Float32Array(i)]);return r}};function C2(e,t){let n=0;for(let r=0;r<t;r++)n+=e[r]*e[r];return Math.sqrt(n)}function w2(e,t,n,r,i){let a=C2(e,r),o=[],s=t||n.keys();for(let t of s){let s=n.get(t);if(!s)continue;let c=s[0],l=s[1],u=0;for(let t=0;t<r;t++)u+=e[t]*l[t];let d=u/(a*c);d>=i&&o.push([t,d])}return o}function T2(e,t,n,r,i){let a=W0(e.sharedInternalDocumentStore,n);e.avgFieldLength[t]=((e.avgFieldLength[t]??0)*(i-1)+r.length)/i,e.fieldLengths[t][a]=r.length,e.frequencies[t][a]={}}function E2(e,t,n,r,i){let a=0;for(let e of r)e===i&&a++;let o=W0(e.sharedInternalDocumentStore,n),s=a/r.length;e.frequencies[t][o][i]=s,i in e.tokenOccurrences[t]||(e.tokenOccurrences[t][i]=0),e.tokenOccurrences[t][i]=(e.tokenOccurrences[t][i]??0)+1}function D2(e,t,n,r){let i=W0(e.sharedInternalDocumentStore,n);r>1?e.avgFieldLength[t]=(e.avgFieldLength[t]*r-e.fieldLengths[t][i])/(r-1):e.avgFieldLength[t]=void 0,e.fieldLengths[t][i]=void 0,e.frequencies[t][i]=void 0}function O2(e,t,n){e.tokenOccurrences[t][n]--}function k2(e,t,n,r,i=``){r||={sharedInternalDocumentStore:t,indexes:{},vectorIndexes:{},searchableProperties:[],searchablePropertiesWithTypes:{},frequencies:{},tokenOccurrences:{},avgFieldLength:{},fieldLengths:{}};for(let[a,o]of Object.entries(n)){let n=`${i}${i?`.`:``}${a}`;if(typeof o==`object`&&!Array.isArray(o)){k2(e,t,o,r,n);continue}if(L0(o))r.searchableProperties.push(n),r.searchablePropertiesWithTypes[n]=o,r.vectorIndexes[n]={type:`Vector`,node:new S2(B0(o)),isArray:!1};else{let e=/\[/.test(o);switch(o){case`boolean`:case`boolean[]`:r.indexes[n]={type:`Bool`,node:new b2,isArray:e};break;case`number`:case`number[]`:r.indexes[n]={type:`AVL`,node:new f2(0,[]),isArray:e};break;case`string`:case`string[]`:r.indexes[n]={type:`Radix`,node:new _2,isArray:e},r.avgFieldLength[n]=0,r.frequencies[n]={},r.tokenOccurrences[n]={},r.fieldLengths[n]={};break;case`enum`:case`enum[]`:r.indexes[n]={type:`Flat`,node:new p2,isArray:e};break;case`geopoint`:r.indexes[n]={type:`BKD`,node:new y2,isArray:e};break;default:throw A0(`INVALID_SCHEMA_TYPE`,Array.isArray(o)?`array`:o,n)}r.searchableProperties.push(n),r.searchablePropertiesWithTypes[n]=o}}return r}function A2(e,t,n,r,i,a,o,s){return c=>{let{type:l,node:u}=t.indexes[n];switch(l){case`Bool`:u[c?`true`:`false`].add(r);break;case`AVL`:{let e=s?.avlRebalanceThreshold??1;u.insert(c,r,e);break}case`Radix`:{let s=a.tokenize(c,i,n,!1);e.insertDocumentScoreParameters(t,n,r,s,o);for(let i of s)e.insertTokenScoreParameters(t,n,r,s,i),u.insert(i,r);break}case`Flat`:u.insert(c,r);break;case`BKD`:u.insert(c,[r]);break}}}function j2(e,t,n,r,i,a,o,s,c,l,u){if(L0(o))return M2(t,n,a,r,i);let d=A2(e,t,n,i,s,c,l,u);if(!R0(o))return d(a);let f=a,p=f.length;for(let e=0;e<p;e++)d(f[e])}function M2(e,t,n,r,i){e.vectorIndexes[t].node.add(i,n)}function N2(e,t,n,r,i,a,o,s,c,l){if(L0(o))return t.vectorIndexes[n].node.remove(i),!0;let{type:u,node:d}=t.indexes[n];switch(u){case`AVL`:return d.removeDocument(a,i),!0;case`Bool`:return d[a?`true`:`false`].delete(i),!0;case`Radix`:{let o=c.tokenize(a,s,n);e.removeDocumentScoreParameters(t,n,r,l);for(let r of o)e.removeTokenScoreParameters(t,n,r),d.removeDocumentByWord(r,i);return!0}case`Flat`:return d.removeDocument(i,a),!0;case`BKD`:return d.removeDocByID(a,i),!1}}function P2(e,t,n,r,i,a,o,s,c,l){if(!R0(o))return N2(e,t,n,r,i,a,o,s,c,l);let u=z0(o),d=a,f=d.length;for(let a=0;a<f;a++)N2(e,t,n,r,i,d[a],u,s,c,l);return!0}function F2(e,t,n,r,i,a,o,s,c,l){let u=Array.from(r),d=e.avgFieldLength[t],f=e.fieldLengths[t],p=e.tokenOccurrences[t],m=e.frequencies[t],h=typeof p[n]==`number`?p[n]??0:0,g=u.length;for(let e=0;e<g;e++){let r=u[e];if(c&&!c.has(r))continue;l.has(r)||l.set(r,new Map);let p=l.get(r);p.set(t,(p.get(t)||0)+1);let g=x2(m?.[r]?.[n]??0,h,i,f[r],d,a);o.has(r)?o.set(r,o.get(r)+g*s):o.set(r,g*s)}}function I2(e,t,n,r,i,a,o,s,c,l,u,d=0){let f=n.tokenize(t,r),p=f.length||1,m=new Map,h=new Map,g=new Map;for(let n of i){if(!(n in e.indexes))continue;let r=e.indexes[n],{type:i}=r;if(i!==`Radix`)throw A0(`WRONG_SEARCH_PROPERTY_TYPE`,n);let d=s[n]??1;if(d<=0)throw A0(`INVALID_BOOST_VALUE`,d);f.length===0&&!t&&f.push(``);let p=f.length;for(let t=0;t<p;t++){let i=f[t],s=r.node.find({term:i,exact:a,tolerance:o}),p=Object.keys(s);p.length>0&&h.set(i,!0);let _=p.length;for(let t=0;t<_;t++){let r=p[t],i=s[r];F2(e,n,r,i,l,c,g,d,u,m)}}}let _=Array.from(g.entries()).map(([e,t])=>[e,t]).sort((e,t)=>t[1]-e[1]);if(_.length===0)return[];if(d===1)return _;if(d===0){if(p===1)return _;for(let e of f)if(!h.get(e))return[];return _.filter(([e])=>{let t=m.get(e);return t?Array.from(t.values()).some(e=>e===p):!1})}let v=_.filter(([e])=>{let t=m.get(e);return t?Array.from(t.values()).some(e=>e===p):!1});if(v.length>0){let e=_.filter(([e])=>!v.some(([t])=>t===e)),t=Math.ceil(e.length*d);return[...v,...e.slice(0,t)]}return _}function L2(e,t,n,r){if(`and`in n&&n.and&&Array.isArray(n.and)){let i=n.and;return i.length===0?new Set:w0(...i.map(n=>L2(e,t,n,r)))}if(`or`in n&&n.or&&Array.isArray(n.or)){let i=n.or;return i.length===0?new Set:i.map(n=>L2(e,t,n,r)).reduce((e,t)=>E0(e,t),new Set)}if(`not`in n&&n.not){let i=n.not,a=new Set,o=e.sharedInternalDocumentStore;for(let e=1;e<=o.internalIdToId.length;e++)a.add(e);return D0(a,L2(e,t,i,r))}let i=Object.keys(n),a=i.reduce((e,t)=>({[t]:new Set,...e}),{});for(let o of i){let i=n[o];if(e.indexes[o]===void 0)throw A0(`UNKNOWN_FILTER_PROPERTY`,o);let{node:s,type:c,isArray:l}=e.indexes[o];if(c===`Bool`){let e=s,t=i?e.true:e.false;a[o]=E0(a[o],t);continue}if(c===`BKD`){let e;if(`radius`in i)e=`radius`;else if(`polygon`in i)e=`polygon`;else throw Error(`Invalid operation ${i}`);if(e===`radius`){let{value:t,coordinates:n,unit:r=`m`,inside:c=!0,highPrecision:l=!1}=i[e],u=b0(t,r),d=s.searchByRadius(n,u,c,void 0,l);a[o]=U2(a[o],d)}else{let{coordinates:t,inside:n=!0,highPrecision:r=!1}=i[e],c=s.searchByPolygon(t,n,void 0,r);a[o]=U2(a[o],c)}continue}if(c===`Radix`&&(typeof i==`string`||Array.isArray(i))){for(let e of[i].flat()){let n=t.tokenize(e,r,o);for(let e of n){let t=s.find({term:e,exact:!0});a[o]=q2(a[o],t)}}continue}let u=Object.keys(i);if(u.length>1)throw A0(`INVALID_FILTER_OPERATION`,u.length);if(c===`Flat`){let e=new Set(l?s.filterArr(i):s.filter(i));a[o]=E0(a[o],e);continue}if(c===`AVL`){let e=u[0],t=i[e],n;switch(e){case`gt`:n=s.greaterThan(t,!1);break;case`gte`:n=s.greaterThan(t,!0);break;case`lt`:n=s.lessThan(t,!1);break;case`lte`:n=s.lessThan(t,!0);break;case`eq`:n=s.find(t)??new Set;break;case`between`:{let[e,r]=t;n=s.rangeSearch(e,r);break}default:throw A0(`INVALID_FILTER_OPERATION`,e)}a[o]=E0(a[o],n)}}return w0(...Object.values(a))}function R2(e){return e.searchableProperties}function z2(e){return e.searchablePropertiesWithTypes}function B2(e,t){let{indexes:n,vectorIndexes:r,searchableProperties:i,searchablePropertiesWithTypes:a,frequencies:o,tokenOccurrences:s,avgFieldLength:c,fieldLengths:l}=t,u={},d={};for(let e of Object.keys(n)){let{node:t,type:r,isArray:i}=n[e];switch(r){case`Radix`:u[e]={type:`Radix`,node:_2.fromJSON(t),isArray:i};break;case`Flat`:u[e]={type:`Flat`,node:p2.fromJSON(t),isArray:i};break;case`AVL`:u[e]={type:`AVL`,node:f2.fromJSON(t),isArray:i};break;case`BKD`:u[e]={type:`BKD`,node:y2.fromJSON(t),isArray:i};break;case`Bool`:u[e]={type:`Bool`,node:b2.fromJSON(t),isArray:i};break;default:u[e]=n[e]}}for(let e of Object.keys(r))d[e]={type:`Vector`,isArray:!1,node:S2.fromJSON(r[e])};return{sharedInternalDocumentStore:e,indexes:u,vectorIndexes:d,searchableProperties:i,searchablePropertiesWithTypes:a,frequencies:o,tokenOccurrences:s,avgFieldLength:c,fieldLengths:l}}function V2(e){let{indexes:t,vectorIndexes:n,searchableProperties:r,searchablePropertiesWithTypes:i,frequencies:a,tokenOccurrences:o,avgFieldLength:s,fieldLengths:c}=e,l={};for(let e of Object.keys(n))l[e]=n[e].node.toJSON();let u={};for(let e of Object.keys(t)){let{type:n,node:r,isArray:i}=t[e];n===`Flat`||n===`Radix`||n===`AVL`||n===`BKD`||n===`Bool`?u[e]={type:n,node:r.toJSON(),isArray:i}:(u[e]=t[e],u[e].node=u[e].node.toJSON())}return{indexes:u,vectorIndexes:l,searchableProperties:r,searchablePropertiesWithTypes:i,frequencies:a,tokenOccurrences:o,avgFieldLength:s,fieldLengths:c}}function H2(){return{create:k2,insert:j2,remove:P2,insertDocumentScoreParameters:T2,insertTokenScoreParameters:E2,removeDocumentScoreParameters:D2,removeTokenScoreParameters:O2,calculateResultScores:F2,search:I2,searchByWhereClause:L2,getSearchableProperties:R2,getSearchablePropertiesWithTypes:z2,load:B2,save:V2}}function U2(e,t){e||=new Set;let n=t.length;for(let r=0;r<n;r++){let n=t[r].docIDs,i=n.length;for(let t=0;t<i;t++)e.add(n[t])}return e}function W2(e,t,n=!1){let r=n?y2.vincentyDistance:y2.haversineDistance,i=[],a=[];for(let{point:n}of e)a.push(r(t,n));let o=Math.max(...a),s=0;for(let{docIDs:t}of e){let e=o-a[s]+1;for(let n of t)i.push([n,e]);s++}return i.sort((e,t)=>t[1]-e[1]),i}function G2(e,t){let n=Object.keys(e);if(n.length!==1)return{isGeoOnly:!1};let r=n[0],i=e[r];if(t.indexes[r]===void 0)return{isGeoOnly:!1};let{type:a}=t.indexes[r];return a===`BKD`&&i&&(`radius`in i||`polygon`in i)?{isGeoOnly:!0,geoProperty:r,geoOperation:i}:{isGeoOnly:!1}}function K2(e,t){let n=e,r=G2(t,n);if(!r.isGeoOnly||!r.geoProperty||!r.geoOperation)return null;let{node:i}=n.indexes[r.geoProperty],a=r.geoOperation,o=i,s;if(`radius`in a){let{value:e,coordinates:t,unit:n=`m`,inside:r=!0,highPrecision:i=!1}=a.radius,c=t,l=b0(e,n);return s=o.searchByRadius(c,l,r,`asc`,i),W2(s,c,i)}else if(`polygon`in a){let{coordinates:e,inside:t=!0,highPrecision:n=!1}=a.polygon;s=o.searchByPolygon(e,t,`asc`,n);let r=y2.calculatePolygonCentroid(e);return W2(s,r,n)}return null}function q2(e,t){e||=new Set;let n=Object.keys(t),r=n.length;for(let i=0;i<r;i++){let r=t[n[i]],a=r.length;for(let t=0;t<a;t++)e.add(r[t])}return e}function J2(e,t,n,r,i){let a={language:e.tokenizer.language,sharedInternalDocumentStore:t,enabled:!0,isSorted:!0,sortableProperties:[],sortablePropertiesWithTypes:{},sorts:{}};for(let[o,s]of Object.entries(n)){let n=`${i}${i?`.`:``}${o}`;if(!r.includes(n)){if(typeof s==`object`&&!Array.isArray(s)){let i=J2(e,t,s,r,n);o0(a.sortableProperties,i.sortableProperties),a.sorts={...a.sorts,...i.sorts},a.sortablePropertiesWithTypes={...a.sortablePropertiesWithTypes,...i.sortablePropertiesWithTypes};continue}if(!L0(s))switch(s){case`boolean`:case`number`:case`string`:a.sortableProperties.push(n),a.sortablePropertiesWithTypes[n]=s,a.sorts[n]={docs:new Map,orderedDocsToRemove:new Map,orderedDocs:[],type:s};break;case`geopoint`:case`enum`:continue;case`enum[]`:case`boolean[]`:case`number[]`:case`string[]`:continue;default:throw A0(`INVALID_SORT_SCHEMA_TYPE`,Array.isArray(s)?`array`:s,n)}}}return a}function Y2(e,t,n,r){return r?.enabled===!1?{disabled:!0}:J2(e,t,n,(r||{}).unsortableProperties||[],``)}function X2(e,t,n,r){if(!e.enabled)return;e.isSorted=!1;let i=W0(e.sharedInternalDocumentStore,n),a=e.sorts[t];a.orderedDocsToRemove.has(i)&&r4(e,t),a.docs.set(i,a.orderedDocs.length),a.orderedDocs.push([i,r])}function Z2(e){if(e.isSorted||!e.enabled)return;let t=Object.keys(e.sorts);for(let n of t)t4(e,n);e.isSorted=!0}function Q2(e,t,n){return t[1].localeCompare(n[1],$1(e))}function $2(e,t){return e[1]-t[1]}function e4(e,t){return t[1]?-1:1}function t4(e,t){let n=e.sorts[t],r;switch(n.type){case`string`:r=Q2.bind(null,e.language);break;case`number`:r=$2.bind(null);break;case`boolean`:r=e4.bind(null);break}n.orderedDocs.sort(r);let i=n.orderedDocs.length;for(let e=0;e<i;e++){let t=n.orderedDocs[e][0];n.docs.set(t,e)}}function n4(e){let t=Object.keys(e.sorts);for(let n of t)r4(e,n)}function r4(e,t){let n=e.sorts[t];n.orderedDocsToRemove.size&&(n.orderedDocs=n.orderedDocs.filter(e=>!n.orderedDocsToRemove.has(e[0])),n.orderedDocsToRemove.clear())}function i4(e,t,n){if(!e.enabled)return;let r=e.sorts[t],i=W0(e.sharedInternalDocumentStore,n);r.docs.get(i)&&(r.docs.delete(i),r.orderedDocsToRemove.set(i,!0))}function a4(e,t,n){if(!e.enabled)throw A0(`SORT_DISABLED`);let r=n.property,i=n.order===`DESC`,a=e.sorts[r];if(!a)throw A0(`UNABLE_TO_SORT_ON_UNKNOWN_FIELD`,r,e.sortableProperties.join(`, `));return r4(e,r),Z2(e),t.sort((t,n)=>{let r=a.docs.get(W0(e.sharedInternalDocumentStore,t[0])),o=a.docs.get(W0(e.sharedInternalDocumentStore,n[0])),s=r!==void 0,c=o!==void 0;return!s&&!c?0:s?c?i?o-r:r-o:-1:1}),t}function o4(e){return e.enabled?e.sortableProperties:[]}function s4(e){return e.enabled?e.sortablePropertiesWithTypes:{}}function c4(e,t){let n=t;if(!n.enabled)return{enabled:!1};let r=Object.keys(n.sorts).reduce((e,t)=>{let{docs:r,orderedDocs:i,type:a}=n.sorts[t];return e[t]={docs:new Map(Object.entries(r).map(([e,t])=>[+e,t])),orderedDocsToRemove:new Map,orderedDocs:i,type:a},e},{});return{sharedInternalDocumentStore:e,language:n.language,sortableProperties:n.sortableProperties,sortablePropertiesWithTypes:n.sortablePropertiesWithTypes,sorts:r,enabled:!0,isSorted:n.isSorted}}function l4(e){if(!e.enabled)return{enabled:!1};n4(e),Z2(e);let t=Object.keys(e.sorts).reduce((t,n)=>{let{docs:r,orderedDocs:i,type:a}=e.sorts[n];return t[n]={docs:Object.fromEntries(r.entries()),orderedDocs:i,type:a},t},{});return{language:e.language,sortableProperties:e.sortableProperties,sortablePropertiesWithTypes:e.sortablePropertiesWithTypes,sorts:t,enabled:e.enabled,isSorted:e.isSorted}}function u4(){return{create:Y2,insert:X2,remove:i4,save:l4,load:c4,sortBy:a4,getSortableProperties:o4,getSortablePropertiesWithTypes:s4}}const d4=[65,65,65,65,65,65,65,67,69,69,69,69,73,73,73,73,69,78,79,79,79,79,79,null,79,85,85,85,85,89,80,115,97,97,97,97,97,97,97,99,101,101,101,101,105,105,105,105,101,110,111,111,111,111,111,null,111,117,117,117,117,121,112,121,65,97,65,97,65,97,67,99,67,99,67,99,67,99,68,100,68,100,69,101,69,101,69,101,69,101,69,101,71,103,71,103,71,103,71,103,72,104,72,104,73,105,73,105,73,105,73,105,73,105,73,105,74,106,75,107,107,76,108,76,108,76,108,76,108,76,108,78,110,78,110,78,110,110,78,110,79,111,79,111,79,111,79,111,82,114,82,114,82,114,83,115,83,115,83,115,83,115,84,116,84,116,84,116,85,117,85,117,85,117,85,117,85,117,85,117,87,119,89,121,89,90,122,90,122,90,122,115];function f4(e){return e<192||e>383?e:d4[e-192]||e}function p4(e){let t=[];for(let n=0;n<e.length;n++)t[n]=f4(e.charCodeAt(n));return String.fromCharCode(...t)}const m4={ational:`ate`,tional:`tion`,enci:`ence`,anci:`ance`,izer:`ize`,bli:`ble`,alli:`al`,entli:`ent`,eli:`e`,ousli:`ous`,ization:`ize`,ation:`ate`,ator:`ate`,alism:`al`,iveness:`ive`,fulness:`ful`,ousness:`ous`,aliti:`al`,iviti:`ive`,biliti:`ble`,logi:`log`},h4={icate:`ic`,ative:``,alize:`al`,iciti:`ic`,ical:`ic`,ful:``,ness:``},g4=`[aeiouy]`,_4=`[^aeiou][^aeiouy]*`;g4+``;const v4=`^(`+_4+`)?[aeiouy][aeiou]*[^aeiou][^aeiouy]*`;``+_4;const y4=`^(`+_4+`)?[aeiouy][aeiou]*[^aeiou][^aeiouy]*[aeiouy][aeiou]*[^aeiou][^aeiouy]*`,b4=`^(`+_4+`)?[aeiouy]`;function x4(e){let t,n,r,i,a,o;if(e.length<3)return e;let s=e.substring(0,1);if(s==`y`&&(e=s.toUpperCase()+e.substring(1)),r=/^(.+?)(ss|i)es$/,i=/^(.+?)([^s])s$/,r.test(e)?e=e.replace(r,`$1$2`):i.test(e)&&(e=e.replace(i,`$1$2`)),r=/^(.+?)eed$/,i=/^(.+?)(ed|ing)$/,r.test(e)){let t=r.exec(e);r=new RegExp(v4),r.test(t[1])&&(r=/.$/,e=e.replace(r,``))}else i.test(e)&&(t=i.exec(e)[1],i=new RegExp(b4),i.test(t)&&(e=t,i=/(at|bl|iz)$/,a=RegExp(`([^aeiouylsz])\\1$`),o=RegExp(`^`+_4+g4+`[^aeiouwxy]$`),i.test(e)?e+=`e`:a.test(e)?(r=/.$/,e=e.replace(r,``)):o.test(e)&&(e+=`e`)));if(r=/^(.+?)y$/,r.test(e)&&(t=r.exec(e)?.[1],r=new RegExp(b4),t&&r.test(t)&&(e=t+`i`)),r=/^(.+?)(ational|tional|enci|anci|izer|bli|alli|entli|eli|ousli|ization|ation|ator|alism|iveness|fulness|ousness|aliti|iviti|biliti|logi)$/,r.test(e)){let i=r.exec(e);t=i?.[1],n=i?.[2],r=new RegExp(v4),t&&r.test(t)&&(e=t+m4[n])}if(r=/^(.+?)(icate|ative|alize|iciti|ical|ful|ness)$/,r.test(e)){let i=r.exec(e);t=i?.[1],n=i?.[2],r=new RegExp(v4),t&&r.test(t)&&(e=t+h4[n])}if(r=/^(.+?)(al|ance|ence|er|ic|able|ible|ant|ement|ment|ent|ou|ism|ate|iti|ous|ive|ize)$/,i=/^(.+?)(s|t)(ion)$/,r.test(e))t=r.exec(e)?.[1],r=new RegExp(y4),t&&r.test(t)&&(e=t);else if(i.test(e)){let n=i.exec(e);t=n?.[1]??``+n?.[2]??``,i=new RegExp(y4),i.test(t)&&(e=t)}return r=/^(.+?)e$/,r.test(e)&&(t=r.exec(e)?.[1],r=new RegExp(y4),i=RegExp(`^([^aeiou][^aeiouy]*)?[aeiouy][aeiou]*[^aeiou][^aeiouy]*([aeiouy][aeiou]*)?$`),a=RegExp(`^`+_4+g4+`[^aeiouwxy]$`),t&&(r.test(t)||i.test(t)&&!a.test(t))&&(e=t)),r=/ll$/,i=new RegExp(y4),r.test(e)&&i.test(e)&&(r=/.$/,e=e.replace(r,``)),s==`y`&&(e=s.toLowerCase()+e.substring(1)),e}function S4(e,t,n=!0){let r=`${this.language}:${e}:${t}`;return n&&this.normalizationCache.has(r)?this.normalizationCache.get(r):this.stopWords?.includes(t)?(n&&this.normalizationCache.set(r,``),``):(this.stemmer&&!this.stemmerSkipProperties.has(e)&&(t=this.stemmer(t)),t=p4(t),n&&this.normalizationCache.set(r,t),t)}function C4(e){for(;e[e.length-1]===``;)e.pop();for(;e[0]===``;)e.shift();return e}function w4(e,t,n,r=!0){if(t&&t!==this.language)throw A0(`LANGUAGE_NOT_SUPPORTED`,t);if(typeof e!=`string`)return[e];let i=this.normalizeToken.bind(this,n??``),a;if(n&&this.tokenizeSkipProperties.has(n))a=[i(e,r)];else{let t=Z1[this.language];a=e.toLowerCase().split(t).map(e=>i(e,r)).filter(Boolean)}let o=C4(a);return this.allowDuplicates?o:Array.from(new Set(o))}function T4(e={}){if(!e.language)e.language=`english`;else if(!Q1.includes(e.language))throw A0(`LANGUAGE_NOT_SUPPORTED`,e.language);let t;if(e.stemming||e.stemmer&&!(`stemming`in e))if(e.stemmer){if(typeof e.stemmer!=`function`)throw A0(`INVALID_STEMMER_FUNCTION_TYPE`);t=e.stemmer}else if(e.language===`english`)t=x4;else throw A0(`MISSING_STEMMER`,e.language);let n;if(e.stopWords!==!1){if(n=[],Array.isArray(e.stopWords))n=e.stopWords;else if(typeof e.stopWords==`function`)n=e.stopWords(n);else if(e.stopWords)throw A0(`CUSTOM_STOP_WORDS_MUST_BE_FUNCTION_OR_ARRAY`);if(!Array.isArray(n))throw A0(`CUSTOM_STOP_WORDS_MUST_BE_FUNCTION_OR_ARRAY`);for(let e of n)if(typeof e!=`string`)throw A0(`CUSTOM_STOP_WORDS_MUST_BE_FUNCTION_OR_ARRAY`)}let r={tokenize:w4,language:e.language,stemmer:t,stemmerSkipProperties:new Set(e.stemmerSkipProperties?[e.stemmerSkipProperties].flat():[]),tokenizeSkipProperties:new Set(e.tokenizeSkipProperties?[e.tokenizeSkipProperties].flat():[]),stopWords:n,allowDuplicates:!!e.allowDuplicates,normalizeToken:S4,normalizationCache:new Map};return r.tokenize=w4.bind(r),r.normalizeToken=S4,r}function E4(e){return{sharedInternalDocumentStore:e,rules:new Map}}function D4(e,t){if(e.rules.has(t.id))throw Error(`PINNING_RULE_ALREADY_EXISTS: A pinning rule with id "${t.id}" already exists. Use updateRule to modify it.`);e.rules.set(t.id,t)}function O4(e,t){if(!e.rules.has(t.id))throw Error(`PINNING_RULE_NOT_FOUND: Cannot update pinning rule with id "${t.id}" because it does not exist. Use addRule to create it.`);e.rules.set(t.id,t)}function k4(e,t){return e.rules.delete(t)}function A4(e,t){return e.rules.get(t)}function j4(e){return Array.from(e.rules.values())}function M4(e,t){let n=e.toLowerCase().trim(),r=t.pattern.toLowerCase().trim();switch(t.anchoring){case`is`:return n===r;case`starts_with`:return n.startsWith(r);case`contains`:return n.includes(r);default:return!1}}function N4(e,t){return e?t.conditions.every(t=>M4(e,t)):!1}function P4(e,t){if(!t)return[];let n=[];for(let r of e.rules.values())N4(t,r)&&n.push(r);return n}function F4(e,t){return{sharedInternalDocumentStore:e,rules:new Map(t?.rules??[])}}function I4(e){return{rules:Array.from(e.rules.entries())}}function L4(){return{create:E4,addRule:D4,updateRule:O4,removeRule:k4,getRule:A4,getAllRules:j4,getMatchingRules:P4,load:F4,save:I4}}function R4(e){let t={formatElapsedTime:j0,getDocumentIndexId:M0,getDocumentProperties:_0,validateSchema:N0};for(let n of a2){let r=n;if(e[r]){if(typeof e[r]!=`function`)throw A0(`COMPONENT_MUST_BE_FUNCTION`,r)}else e[r]=t[r]}for(let t of Object.keys(e))if(!i2.includes(t)&&!a2.includes(t))throw A0(`UNSUPPORTED_COMPONENT`,t)}function z4({schema:e,sort:t,language:n,components:r,id:i,plugins:a}){r||={};for(let t of a??[]){if(!(`getComponents`in t)||typeof t.getComponents!=`function`)continue;let n=t.getComponents(e),i=Object.keys(n);for(let e of i)if(r[e])throw A0(`PLUGIN_COMPONENT_CONFLICT`,e,t.name);r={...r,...n}}i||=p0();let o=r.tokenizer,s=r.index,c=r.documentsStore,l=r.sorter,u=r.pinning;if(o=o?o.tokenize?o:T4(o):T4({language:n??`english`}),r.tokenizer&&n)throw A0(`NO_LANGUAGE_WITH_CUSTOM_TOKENIZER`);let d=V0();s||=H2(),l||=u4(),c||=t2(),u||=L4(),R4(r);let{getDocumentProperties:f,getDocumentIndexId:p,validateSchema:m,formatElapsedTime:h}=r,g={data:{},caches:{},schema:e,tokenizer:o,index:s,sorter:l,documentsStore:c,pinning:u,internalDocumentIDStore:d,getDocumentProperties:f,getDocumentIndexId:p,validateSchema:m,beforeInsert:[],afterInsert:[],beforeRemove:[],afterRemove:[],beforeUpdate:[],afterUpdate:[],beforeUpsert:[],afterUpsert:[],beforeSearch:[],afterSearch:[],beforeInsertMultiple:[],afterInsertMultiple:[],beforeRemoveMultiple:[],afterRemoveMultiple:[],beforeUpdateMultiple:[],afterUpdateMultiple:[],beforeUpsertMultiple:[],afterUpsertMultiple:[],afterCreate:[],formatElapsedTime:h,id:i,plugins:a,version:B4()};g.data={index:g.index.create(g,d,e),docs:g.documentsStore.create(g,d),sorting:g.sorter.create(g,d,e,t),pinning:g.pinning.create(d)};for(let e of n2)g[e]=(g[e]??[]).concat(r2(g,e));let _=g.afterCreate;return _&&u2(_,g),g}function B4(){return`{{VERSION}}`}function V4(e){return e.documentsStore.count(e.data.docs)}function H4(e,t,n,r,i){let a=e.validateSchema(t,e.schema);if(a)throw A0(`SCHEMA_VALIDATION_FAILURE`,a);return S0(e.beforeInsert)||S0(e.afterInsert)||S0(e.index.beforeInsert)||S0(e.index.insert)||S0(e.index.afterInsert)?G4(e,t,n,r,i):K4(e,t,n,r,i)}const U4=new Set([`enum`,`enum[]`]),W4=new Set([`string`,`number`]);async function G4(e,t,n,r,i){let{index:a,docs:o}=e.data,s=e.getDocumentIndexId(t);if(typeof s!=`string`)throw A0(`DOCUMENT_ID_MUST_BE_STRING`,typeof s);let c=W0(e.internalDocumentIDStore,s);if(r||await o2(e.beforeInsert,e,s,t),!e.documentsStore.store(o,s,c,t))throw A0(`DOCUMENT_ALREADY_EXISTS`,s);let l=e.documentsStore.count(o),u=e.index.getSearchableProperties(a),d=e.index.getSearchablePropertiesWithTypes(a),f=e.getDocumentProperties(t,u);for(let[e,t]of Object.entries(f)){if(t===void 0)continue;let n=typeof t,r=d[e];q4(n,r,e,t)}return await J4(e,s,u,f,l,n,t,i),r||await o2(e.afterInsert,e,s,t),s}function K4(e,t,n,r,i){let{index:a,docs:o}=e.data,s=e.getDocumentIndexId(t);if(typeof s!=`string`)throw A0(`DOCUMENT_ID_MUST_BE_STRING`,typeof s);let c=W0(e.internalDocumentIDStore,s);if(r||o2(e.beforeInsert,e,s,t),!e.documentsStore.store(o,s,c,t))throw A0(`DOCUMENT_ALREADY_EXISTS`,s);let l=e.documentsStore.count(o),u=e.index.getSearchableProperties(a),d=e.index.getSearchablePropertiesWithTypes(a),f=e.getDocumentProperties(t,u);for(let[e,t]of Object.entries(f)){if(t===void 0)continue;let n=typeof t,r=d[e];q4(n,r,e,t)}return Y4(e,s,u,f,l,n,t,i),r||o2(e.afterInsert,e,s,t),s}function q4(e,t,n,r){if(!(I0(t)&&typeof r==`object`&&typeof r.lon==`number`&&typeof r.lat==`number`)&&!(L0(t)&&Array.isArray(r))&&!(R0(t)&&Array.isArray(r))&&!(U4.has(t)&&W4.has(e))&&e!==t)throw A0(`INVALID_DOCUMENT_PROPERTY`,n,t,e)}async function J4(e,t,n,r,i,a,o,s){for(let o of n){let n=r[o];if(n===void 0)continue;let c=e.index.getSearchablePropertiesWithTypes(e.data.index)[o];await e.index.beforeInsert?.(e.data.index,o,t,n,c,a,e.tokenizer,i);let l=e.internalDocumentIDStore.idToInternalId.get(t);await e.index.insert(e.index,e.data.index,o,t,l,n,c,a,e.tokenizer,i,s),await e.index.afterInsert?.(e.data.index,o,t,n,c,a,e.tokenizer,i)}let c=e.sorter.getSortableProperties(e.data.sorting),l=e.getDocumentProperties(o,c);for(let n of c){let r=l[n];if(r===void 0)continue;let i=e.sorter.getSortablePropertiesWithTypes(e.data.sorting)[n];e.sorter.insert(e.data.sorting,n,t,r,i,a)}}function Y4(e,t,n,r,i,a,o,s){for(let o of n){let n=r[o];if(n===void 0)continue;let c=e.index.getSearchablePropertiesWithTypes(e.data.index)[o],l=W0(e.internalDocumentIDStore,t);e.index.beforeInsert?.(e.data.index,o,t,n,c,a,e.tokenizer,i),e.index.insert(e.index,e.data.index,o,t,l,n,c,a,e.tokenizer,i,s),e.index.afterInsert?.(e.data.index,o,t,n,c,a,e.tokenizer,i)}let c=e.sorter.getSortableProperties(e.data.sorting),l=e.getDocumentProperties(o,c);for(let n of c){let r=l[n];if(r===void 0)continue;let i=e.sorter.getSortablePropertiesWithTypes(e.data.sorting)[n];e.sorter.insert(e.data.sorting,n,t,r,i,a)}}function X4(e,t,n,r,i,a){return S0(e.afterInsertMultiple)||S0(e.beforeInsertMultiple)||S0(e.index.beforeInsert)||S0(e.index.insert)||S0(e.index.afterInsert)?Z4(e,t,n,r,i,a):Q4(e,t,n,r,i,a)}async function Z4(e,t,n=1e3,r,i,a=0){let o=[],s=async a=>{let s=Math.min(a+n,t.length),c=t.slice(a,s);for(let t of c){let n=await H4(e,t,r,i,{avlRebalanceThreshold:c.length});o.push(n)}return s};return await(async()=>{let e=0;for(;e<t.length;){let t=Date.now();if(e=await s(e),a>0){let e=a-(Date.now()-t);e>0&&O0(e)}}})(),i||await s2(e.afterInsertMultiple,e,t),o}function Q4(e,t,n=1e3,r,i,a=0){let o=[],s=0;function c(){let a=t.slice(s*n,(s+1)*n);if(a.length===0)return!1;for(let t of a){let n=H4(e,t,r,i,{avlRebalanceThreshold:a.length});o.push(n)}return s++,!0}function l(){let e=Date.now();for(;c();)if(a>0){let t=Date.now()-e;if(t>=a){let e=a-t%a;e>0&&O0(e)}}}return l(),i||s2(e.afterInsertMultiple,e,t),o}function $4(e,t,n,r){return S0(e.index.beforeRemove)||S0(e.index.remove)||S0(e.index.afterRemove)?e3(e,t,n,r):t3(e,t,n,r)}async function e3(e,t,n,r){let i=!0,{index:a,docs:o}=e.data,s=e.documentsStore.get(o,t);if(!s)return!1;let c=W0(e.internalDocumentIDStore,t),l=G0(e.internalDocumentIDStore,c),u=e.documentsStore.count(o);r||await o2(e.beforeRemove,e,l);let d=e.index.getSearchableProperties(a),f=e.index.getSearchablePropertiesWithTypes(a),p=e.getDocumentProperties(s,d);for(let r of d){let a=p[r];if(a===void 0)continue;let o=f[r];await e.index.beforeRemove?.(e.data.index,r,l,a,o,n,e.tokenizer,u),await e.index.remove(e.index,e.data.index,r,t,c,a,o,n,e.tokenizer,u)||(i=!1),await e.index.afterRemove?.(e.data.index,r,l,a,o,n,e.tokenizer,u)}let m=await e.sorter.getSortableProperties(e.data.sorting),h=await e.getDocumentProperties(s,m);for(let n of m)h[n]!==void 0&&e.sorter.remove(e.data.sorting,n,t);return r||await o2(e.afterRemove,e,l),e.documentsStore.remove(e.data.docs,t,c),i}function t3(e,t,n,r){let i=!0,{index:a,docs:o}=e.data,s=e.documentsStore.get(o,t);if(!s)return!1;let c=W0(e.internalDocumentIDStore,t),l=G0(e.internalDocumentIDStore,c),u=e.documentsStore.count(o);r||o2(e.beforeRemove,e,l);let d=e.index.getSearchableProperties(a),f=e.index.getSearchablePropertiesWithTypes(a),p=e.getDocumentProperties(s,d);for(let r of d){let a=p[r];if(a===void 0)continue;let o=f[r];e.index.beforeRemove?.(e.data.index,r,l,a,o,n,e.tokenizer,u),e.index.remove(e.index,e.data.index,r,t,c,a,o,n,e.tokenizer,u)||(i=!1),e.index.afterRemove?.(e.data.index,r,l,a,o,n,e.tokenizer,u)}let m=e.sorter.getSortableProperties(e.data.sorting),h=e.getDocumentProperties(s,m);for(let n of m)h[n]!==void 0&&e.sorter.remove(e.data.sorting,n,t);return r||o2(e.afterRemove,e,l),e.documentsStore.remove(e.data.docs,t,c),i}function n3(e,t,n,r,i){return S0(e.index.beforeRemove)||S0(e.index.remove)||S0(e.index.afterRemove)||S0(e.beforeRemoveMultiple)||S0(e.afterRemoveMultiple)?r3(e,t,n,r,i):i3(e,t,n,r,i)}async function r3(e,t,n,r,i){let a=0;n||=1e3;let o=i?[]:t.map(t=>G0(e.internalDocumentIDStore,W0(e.internalDocumentIDStore,t)));return i||await s2(e.beforeRemoveMultiple,e,o),await new Promise((o,s)=>{let c=0;async function l(){let u=t.slice(c*n,++c*n);if(!u.length)return o();for(let t of u)try{await $4(e,t,r,i)&&a++}catch(e){s(e)}setTimeout(l,0)}setTimeout(l,0)}),i||await s2(e.afterRemoveMultiple,e,o),a}function i3(e,t,n,r,i){let a=0;n||=1e3;let o=i?[]:t.map(t=>G0(e.internalDocumentIDStore,W0(e.internalDocumentIDStore,t)));i||s2(e.beforeRemoveMultiple,e,o);let s=0;function c(){let o=t.slice(s*n,++s*n);if(o.length){for(let t of o)$4(e,t,r,i)&&a++;setTimeout(c,0)}}return c(),i||s2(e.afterRemoveMultiple,e,o),a}function a3(e,t){return e[1]-t[1]}function o3(e,t){return t[1]-e[1]}function s3(e=`desc`){return e.toLowerCase()===`asc`?a3:o3}function c3(e,t,n){let r={},i=t.map(([e])=>e),a=e.documentsStore.getMultiple(e.data.docs,i),o=Object.keys(n),s=e.index.getSearchablePropertiesWithTypes(e.data.index);for(let e of o){let t;if(s[e]===`number`){let{ranges:r}=n[e],i=r.length,a=Array.from({length:i});for(let e=0;e<i;e++){let t=r[e];a[e]=[`${t.from}-${t.to}`,0]}t=Object.fromEntries(a)}r[e]={count:0,values:t??{}}}let c=a.length;for(let e=0;e<c;e++){let t=a[e];for(let e of o){let i=e.includes(`.`)?v0(t,e):t[e],a=s[e],o=r[e].values;switch(a){case`number`:{let t=n[e].ranges;l3(t,o)(i);break}case`number[]`:{let t=new Set,r=n[e].ranges,a=l3(r,o,t);for(let e of i)a(e);break}case`boolean`:case`enum`:case`string`:u3(o,a)(i);break;case`boolean[]`:case`enum[]`:case`string[]`:{let e=u3(o,a===`boolean[]`?`boolean`:`string`,new Set);for(let t of i)e(t);break}default:throw A0(`FACET_NOT_SUPPORTED`,a)}}}for(let e of o){let t=r[e];if(t.count=Object.keys(t.values).length,s[e]===`string`){let r=n[e],i=s3(r.sort);t.values=Object.fromEntries(Object.entries(t.values).sort(i).slice(r.offset??0,r.limit??10))}}return r}function l3(e,t,n){return r=>{for(let i of e){let e=`${i.from}-${i.to}`;n?.has(e)||r>=i.from&&r<=i.to&&(t[e]===void 0?t[e]=1:(t[e]++,n?.add(e)))}}}function u3(e,t,n){let r=t===`boolean`?`false`:``;return t=>{let i=t?.toString()??r;n?.has(i)||(e[i]=(e[i]??0)+1,n?.add(i))}}const d3={reducer:(e,t,n,r)=>(t[r]=n,t),getInitialValue:e=>Array.from({length:e})},f3=[`string`,`number`,`boolean`];function p3(e,t,n){let r=n.properties,i=r.length,a=e.index.getSearchablePropertiesWithTypes(e.data.index);for(let e=0;e<i;e++){let t=r[e];if(a[t]===void 0)throw A0(`UNKNOWN_GROUP_BY_PROPERTY`,t);if(!f3.includes(a[t]))throw A0(`INVALID_GROUP_BY_PROPERTY`,t,f3.join(`, `),a[t])}let o=t.map(([t])=>G0(e.internalDocumentIDStore,t)),s=e.documentsStore.getMultiple(e.data.docs,o),c=s.length,l=n.maxResult||2**53-1,u=[],d={};for(let e=0;e<i;e++){let t=r[e],n={property:t,perValue:{}},i=new Set;for(let e=0;e<c;e++){let r=s[e],a=v0(r,t);if(a===void 0)continue;let o=typeof a==`boolean`?``+a:a,c=n.perValue[o]??{indexes:[],count:0};c.count>=l||(c.indexes.push(e),c.count++,n.perValue[o]=c,i.add(a))}u.push(Array.from(i)),d[t]=n}let f=m3(u),p=f.length,m=[];for(let e=0;e<p;e++){let t=f[e],n=t.length,i={values:[],indexes:[]},a=[];for(let e=0;e<n;e++){let n=t[e],o=r[e];a.push(d[o].perValue[typeof n==`boolean`?``+n:n].indexes),i.values.push(n)}i.indexes=g0(a).sort((e,t)=>e-t),i.indexes.length!==0&&m.push(i)}let h=m.length,g=Array.from({length:h});for(let e=0;e<h;e++){let r=m[e],i=n.reduce||d3,a=r.indexes.map(e=>({id:o[e],score:t[e][1],document:s[e]})),c=i.reducer.bind(null,r.values),l=i.getInitialValue(r.indexes.length),u=a.reduce(c,l);g[e]={values:r.values,result:u}}return g}function m3(e,t=0){if(t+1===e.length)return e[t].map(e=>[e]);let n=e[t],r=m3(e,t+1),i=[];for(let e of n)for(let t of r){let n=[e];o0(n,t),i.push(n)}return i}function h3(e,t,n,r){let i=P4(t,r);if(i.length===0)return n;let a=i.flatMap(e=>e.consequence.promote);a.sort((e,t)=>e.position-t.position);let o=new Set,s=new Map,c=new Set;for(let t of a){let n=W0(e.internalDocumentIDStore,t.doc_id);if(n!==void 0){if(s.has(n)){let e=s.get(n);t.position<e&&s.set(n,t.position);continue}c.has(t.position)||(o.add(n),s.set(n,t.position),c.add(t.position))}}if(s.size===0)return n;let l=n.filter(([e])=>!o.has(e)),u=[];for(let[t,r]of s.entries())n.find(([e])=>e===t)?u.push([t,1e6-r]):e.documentsStore.get(e.data.docs,t)&&u.push([t,0]);u.sort((e,t)=>(s.get(e[0])??1/0)-(s.get(t[0])??1/0));let d=[],f=new Map;for(let e of u){let t=s.get(e[0]);f.set(t,e)}let p=0,m=0;for(;m<l.length+u.length;)if(f.has(m))d.push(f.get(m)),m++;else if(p<l.length)d.push(l[p]),p++,m++;else break;for(let[e,t]of f.entries())e>=d.length&&d.push(t);return d}function g3(e,t,n){let{term:r,properties:i}=t,a=e.data.index,o=e.caches.propertiesToSearch;if(!o){let t=e.index.getSearchablePropertiesWithTypes(a);o=e.index.getSearchableProperties(a),o=o.filter(e=>t[e].startsWith(`string`)),e.caches.propertiesToSearch=o}if(i&&i!==`*`){for(let e of i)if(!o.includes(e))throw A0(`UNKNOWN_INDEX`,e,o.join(`, `));o=o.filter(e=>i.includes(e))}let s=Object.keys(t.where??{}).length>0,c;s&&(c=e.index.searchByWhereClause(a,e.tokenizer,t.where,n));let l,u=t.threshold!==void 0&&t.threshold!==null?t.threshold:1;if(r||i){let i=V4(e);if(l=e.index.search(a,r||``,e.tokenizer,n,o,t.exact||!1,t.tolerance||0,t.boost||{},x3(t.relevance),i,c,u),t.exact&&r){let t=r.trim().split(/\s+/);l=l.filter(([n])=>{let r=e.documentsStore.get(e.data.docs,n);if(!r)return!1;for(let e of o){let n=v3(r,e);if(typeof n==`string`&&t.every(e=>RegExp(`\\b${_3(e)}\\b`).test(n)))return!0}return!1})}}else l=s?K2(a,t.where)||(c?Array.from(c):[]).map(e=>[+e,0]):Object.keys(e.documentsStore.getAll(e.data.docs)).map(e=>[+e,0]);return l}function _3(e){return e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}function v3(e,t){let n=t.split(`.`),r=e;for(let e of n)if(r&&typeof r==`object`&&e in r)r=r[e];else return;return r}function y3(e,t,n){let r=f0();function i(){let i=Object.keys(e.data.index.vectorIndexes),a=t.facets&&Object.keys(t.facets).length>0,{limit:o=10,offset:s=0,distinctOn:c,includeVectors:l=!1}=t,u=t.preflight===!0,d=g3(e,t,n);if(t.sortBy)if(typeof t.sortBy==`function`){let n=d.map(([e])=>e),r=e.documentsStore.getMultiple(e.data.docs,n).map((e,t)=>[d[t][0],d[t][1],e]);r.sort(t.sortBy),d=r.map(([e,t])=>[e,t])}else d=e.sorter.sortBy(e.data.sorting,d,t.sortBy).map(([t,n])=>[W0(e.internalDocumentIDStore,t),n]);else d=d.sort(h0);d=h3(e,e.data.pinning,d,t.term);let f;u||(f=c?N3(e,d,s,o,c):P3(e,d,s,o));let p={elapsed:{formatted:``,raw:0},hits:[],count:d.length};return f!==void 0&&(p.hits=f.filter(Boolean),l||x0(p,i)),a&&(p.facets=c3(e,d,t.facets)),t.groupBy&&(p.groups=p3(e,d,t.groupBy)),p.elapsed=e.formatElapsedTime(f0()-r),p}async function a(){e.beforeSearch&&await l2(e.beforeSearch,e,t,n);let r=i();return e.afterSearch&&await c2(e.afterSearch,e,t,n,r),r}return e.beforeSearch?.length||e.afterSearch?.length?a():i()}const b3={k:1.2,b:.75,d:.5};function x3(e){let t=e??{};return t.k=t.k??b3.k,t.b=t.b??b3.b,t.d=t.d??b3.d,t}function S3(e,t,n){let r=t.vector;if(r&&(!(`value`in r)||!(`property`in r)))throw A0(`INVALID_VECTOR_INPUT`,Object.keys(r).join(`, `));let i=e.data.index.vectorIndexes[r.property];if(!i)throw A0(`UNKNOWN_VECTOR_PROPERTY`,r.property);let a=i.node.size;if(r?.value.length!==a)throw r?.property===void 0||r?.value.length===void 0?A0(`INVALID_INPUT_VECTOR`,`undefined`,a,`undefined`):A0(`INVALID_INPUT_VECTOR`,r.property,a,r.value.length);let o=e.data.index,s;return Object.keys(t.where??{}).length>0&&(s=e.index.searchByWhereClause(o,e.tokenizer,t.where,n)),i.node.find(r.value,t.similarity??.8,s)}function C3(e,t,n=`english`){let r=f0();function i(){let i=S3(e,t,n).sort(h0);i=h3(e,e.data.pinning,i,void 0);let a=[];t.facets&&Object.keys(t.facets).length>0&&(a=c3(e,i,t.facets));let o=t.vector.property,s=t.includeVectors??!1,c=t.limit??10,l=t.offset??0,u=Array.from({length:c});for(let t=0;t<c;t++){let n=i[t+l];if(!n)break;let r=e.data.docs.docs[n[0]];r&&(s||(r[o]=null),u[t]={id:G0(e.internalDocumentIDStore,n[0]),score:n[1],document:r})}let d=[];t.groupBy&&(d=p3(e,i,t.groupBy));let f=f0()-r;return{count:i.length,hits:u.filter(Boolean),elapsed:{raw:Number(f),formatted:d0(f)},...a?{facets:a}:{},...d?{groups:d}:{}}}async function a(){e.beforeSearch&&await l2(e.beforeSearch,e,t,n);let r=i();return e.afterSearch&&await c2(e.afterSearch,e,t,n,r),r}return e.beforeSearch?.length||e.afterSearch?.length?a():i()}function w3(e,t,n){let r=D3(g3(e,t,n)),i=S3(e,t,n),a=t.hybridWeights;return A3(r,i,t.term??``,a)}function T3(e,t,n){let r=f0();function i(){let i=w3(e,t,n);i=h3(e,e.data.pinning,i,t.term);let a;t.facets&&Object.keys(t.facets).length>0&&(a=c3(e,i,t.facets));let o;t.groupBy&&(o=p3(e,i,t.groupBy));let s=t.offset??0,c=t.limit??10,l=P3(e,i,s,c).filter(Boolean),u=f0(),d={count:i.length,elapsed:{raw:Number(u-r),formatted:d0(u-r)},hits:l,...a?{facets:a}:{},...o?{groups:o}:{}};return(t.includeVectors??!1)||x0(d,Object.keys(e.data.index.vectorIndexes)),d}async function a(){e.beforeSearch&&await l2(e.beforeSearch,e,t,n);let r=i();return e.afterSearch&&await c2(e.afterSearch,e,t,n,r),r}return e.beforeSearch?.length||e.afterSearch?.length?a():i()}function E3(e){return e[1]}function D3(e){let t=Math.max.apply(Math,e.map(E3));return e.map(([e,n])=>[e,n/t])}function O3(e,t){return e/t}function k3(e,t){return(n,r)=>n*e+r*t}function A3(e,t,n,r){let i=Math.max.apply(Math,e.map(E3)),a=Math.max.apply(Math,t.map(E3)),{text:o,vector:s}=r&&r.text&&r.vector?r:j3(n),c=new Map,l=e.length,u=k3(o,s);for(let t=0;t<l;t++){let[n,r]=e[t],a=u(O3(r,i),0);c.set(n,a)}let d=t.length;for(let e=0;e<d;e++){let[n,r]=t[e],i=O3(r,a),o=c.get(n)??0;c.set(n,o+u(0,i))}return[...c].sort((e,t)=>t[1]-e[1])}function j3(e){return{text:.5,vector:.5}}function M3(e,t,n){let r=t.mode??`fulltext`;if(r===`fulltext`)return y3(e,t,n);if(r===`vector`)return C3(e,t);if(r===`hybrid`)return T3(e,t);throw A0(`INVALID_SEARCH_MODE`,r)}function N3(e,t,n,r,i){let a=e.data.docs,o=new Map,s=[],c=new Set,l=t.length,u=0;for(let d=0;d<l;d++){let l=t[d];if(l===void 0)continue;let[f,p]=l;if(c.has(f))continue;let m=e.documentsStore.get(a,f),h=v0(m,i);if(!(h===void 0||o.has(h))&&(o.set(h,!0),u++,!(u<=n)&&(s.push({id:G0(e.internalDocumentIDStore,f),score:p,document:m}),c.add(f),u>=n+r)))break}return s}function P3(e,t,n,r){let i=e.data.docs,a=Array.from({length:r}),o=new Set;for(let s=n;s<r+n;s++){let n=t[s];if(n===void 0)break;let[r,c]=n;if(!o.has(r)){let t=e.documentsStore.get(i,r);a[s]={id:G0(e.internalDocumentIDStore,r),score:c,document:t},o.add(r)}}return a}const F3={id:`string`,kind:`enum`,path:`string`,title:`string`,name:`string`,pathSegments:`string`,content:`string`,modifiedTs:`number`},I3=new WeakMap;function L3(e){return e===void 0||!Number.isFinite(e)?20:Math.max(1,Math.min(100,Math.trunc(e)))}function R3(e){return e.trim().toLowerCase()}const z3=/\.(?:md|mdx)$/;function B3(e,t){if(t!==`page`)return e;let n=e.replace(z3,``);return n.length>0?n:e}function V3(e){let t=e.split(`/`).filter(Boolean);return t[t.length-1]??e}function H3(e){let t=V3(e.path),n=e.title?.trim()||t,r=e.modifiedTs??0,i=e.path.split(`/`).filter(Boolean),a=new Set(i),o=[...new Set((e.aliases??[]).flatMap(e=>e.split(`/`).filter(Boolean)).filter(e=>!a.has(e)))];return{id:`${e.kind}:${e.path}`,kind:e.kind,path:e.path,title:n,name:t,pathSegments:[...i,...o].join(` `),content:e.content??``,modifiedTs:Number.isFinite(r)?r:0}}function U3(e){let t=z4({schema:F3});return e.length>0&&X4(t,e),t}function W3(e){let t={documents:e};return I3.set(t,U3(e)),t}function G3(e){let t=I3.get(e);if(t)return t;let n=U3(e.documents);return I3.set(e,n),n}const K3=new WeakSet;function q3(e,t){return e===t||e.kind===t.kind&&e.path===t.path&&e.title===t.title&&e.name===t.name&&e.pathSegments===t.pathSegments&&e.modifiedTs===t.modifiedTs&&e.content===t.content}function J3(e,t){let n=e=>({corpus:W3(t),inserted:0,updated:0,removed:0,rebuilt:!0,rebuildReason:e}),r=I3.get(e);if(!r)return n(`no-index`);if(K3.has(e))return n(`stale-base`);let i=new Map(t.map(e=>[e.id,e]));if(i.size!==t.length)return n(`duplicate-id`);let a=[],o=[],s=0;for(let t of e.documents){let e=i.get(t.id);e?q3(t,e)||(a.push(t.id),o.push(e),s+=1):a.push(t.id)}let c=new Set(e.documents.map(e=>e.id));for(let e of t)c.has(e.id)||o.push(e);if(a.length+o.length>t.length)return n(`bulk-change`);K3.add(e);try{if(a.length>0&&n3(r,a),o.length>0&&X4(r,o),V4(r)!==t.length)throw Error(`Search index count ${V4(r)} diverged from document count ${t.length} after incremental update`)}catch{return n(`mutation-failed`)}let l={documents:t};return I3.set(l,r),{corpus:l,inserted:o.length-s,updated:s,removed:a.length-s,rebuilt:!1}}function Y3(e){return e===`autocomplete`?[`page`]:e===`full_text`?[`page`,`content`,`file`]:[`page`,`folder`,`file`]}function X3(e,t){return t.has(e.kind)?!0:e.kind===`page`&&t.has(`content`)}function Z3(e,t){let n=R3(t);if(!n)return 0;let r=B3(n,e.kind),i=R3(e.title),a=R3(e.name),o=R3(e.path),s=o.split(`/`);return i===r||a===r?700:o===r?650:i.startsWith(r)||a.startsWith(r)?600:s.some(e=>e.startsWith(r))?550:i.includes(r)||a.includes(r)?500:o.includes(r)?450:-1}function Q3(e,t){let n=Z3(e,t);return n<=0?n:my(e.path)?n*.5:n}function $3(e){return e===`file`?-60:0}function e6(e,t,n,r,i){let a=i>0?t/i:0,o=n/50,s=r===`file`?-.001:0,c=1*a+1*o+s;return e*1e3+c}function t6(e,t,n,r){return e+t*20+n+$3(r)}function n6(e,t,n,r,i,a){return e===`relevance`?t6(t,n,r,i):e6(t,n,r,i,a)}function r6(e,t){return t||(e===`full_text`?`relevance`:`navigation`)}function i6(e,t){let n=0;for(let r of e){let e=t.get(r.id)??0;e>n&&(n=e)}return n}function a6(e){let t=e.map(e=>e.modifiedTs).filter(e=>Number.isFinite(e)&&e>0);if(t.length===0)return new Map;let n=1/0,r=-1/0;for(let e of t)e<n&&(n=e),e>r&&(r=e);let i=Math.max(1,r-n);return new Map(e.map(e=>[e.id,e.modifiedTs>0?(e.modifiedTs-n)/i*50:0]))}function o6(e){return e===`full_text`?[`title`,`name`,`path`,`pathSegments`,`content`]:[`title`,`name`,`path`,`pathSegments`]}function s6(e){return e===`full_text`?{title:8,name:7,path:5,pathSegments:4,content:1}:e===`autocomplete`?{title:10,name:9,path:5,pathSegments:4}:{title:8,name:7,path:5,pathSegments:4}}function c6(e,t){return R3(t).length<4?0:+(e===`full_text`)}function l6(e){let{lexical:t,fullText:n}=e.signals;return t>=500?`lexical`:t===450&&n<=0?`pathOnly`:`body`}function u6(e){let t=[],n=[],r=[];for(let i of e){let e=l6(i);e===`lexical`?t.length<100&&t.push(i):e===`body`?n.length<6&&n.push(i):r.length<4&&r.push(i)}return[...t,...n,...r]}function d6(e,t,n){if(t===`relevance`)return e.slice(0,n);let r=u6(e),i=[],a=0,o=0;for(let e of r){if(e.document.kind===`folder`){if(a>=3)continue;a+=1}else if(e.document.kind===`file`){if(o>=3)continue;o+=1}if(i.push(e),i.length>=n)break}return i}function f6(e,t,n={}){let r=n.intent??`omnibar`,i=r6(r,n.ranking),a=L3(n.limit),o=new Set(n.scopes??Y3(r)),s=e.documents.filter(e=>X3(e,o)),c=R3(t);if(!c)return s.slice().sort((e,t)=>e.path.localeCompare(t.path)).slice(0,a).map(e=>({document:e,score:0,signals:{lexical:0,fullText:0,recency:0}}));let l=M3(G3(e),{term:c,properties:o6(r),boost:s6(r),tolerance:c6(r,c),limit:Math.max(a*4,40)}),u=new Map(l.hits.filter(e=>X3(e.document,o)).map(e=>[e.document.id,e.score])),d=a6(s),f=new Map;for(let e of s)Q3(e,c)>=0&&f.set(e.id,e);for(let e of l.hits)X3(e.document,o)&&f.set(e.document.id,e.document);if(!n.semantic){let e=i6(f.values(),u);return d6([...f.values()].map(t=>{let n=Math.max(0,Q3(t,c)),r=u.get(t.id)??0,a=d.get(t.id)??0;return{document:t,score:n6(i,n,r,a,t.kind,e),signals:{lexical:n,fullText:r,recency:a}}}).sort((e,t)=>e.score===t.score?e.document.path.localeCompare(t.document.path):t.score-e.score),i,a)}return d6(m6({scopedDocuments:s,candidates:f,fullTextScores:u,recency:d,normalizedQuery:c,ranking:i,semantic:n.semantic}),i,a)}function p6(e){let t=new Map;return e.forEach((e,n)=>{t.set(e,n+1)}),t}function m6(e){let{scopedDocuments:t,candidates:n,fullTextScores:r,recency:i,normalizedQuery:a,ranking:o,semantic:s}=e,c=s.rrfK??60,l=s.candidateLimit??64,u=s.similarityFloor??0,d=s.scores,f=new Map(t.map(e=>[e.id,e])),p=[...d.entries()].filter(([e,t])=>t>=u&&f.has(e)).sort((e,t)=>t[1]-e[1]||e[0].localeCompare(t[0])).slice(0,l);for(let[e]of p)if(!n.has(e)){let t=f.get(e);t&&n.set(e,t)}let m=i6(n.values(),r),h=[...n.values()].map(e=>{let t=Math.max(0,Q3(e,a)),n=r.get(e.id)??0,s=i.get(e.id)??0,c=d.get(e.id),l=c!==void 0&&c>=u;return{document:e,score:t>0?n6(o,t,n,s,e.kind,m):t6(t,n,s,e.kind),signals:l?{lexical:t,fullText:n,recency:s,vector:c}:{lexical:t,fullText:n,recency:s},lexical:t,fullText:n,recency:s,cosine:c}}),g=p6(h.filter(e=>e.fullText>0).sort((e,t)=>t.fullText-e.fullText||e.document.path.localeCompare(t.document.path)).map(e=>e.document.id)),_=p6(h.filter(e=>e.cosine!==void 0&&e.cosine>=u).sort((e,t)=>t.cosine-e.cosine||e.document.path.localeCompare(t.document.path)).map(e=>e.document.id)),v=e=>{let t=0,n=g.get(e);n!==void 0&&(t+=1/(c+n));let r=_.get(e);return r!==void 0&&(t+=1/(c+r)),t};return h.sort((e,t)=>{let n=+(e.lexical>0),r=+(t.lexical>0);if(n!==r)return r-n;if(n===1)return e.score===t.score?e.document.path.localeCompare(t.document.path):t.score-e.score;let i=v(e.document.id),a=v(t.document.id);return i===a?e.recency===t.recency?e.document.path.localeCompare(t.document.path):t.recency-e.recency:a-i}).map(({document:e,score:t,signals:n})=>({document:e,score:t,signals:n}))}const h6=Symbol.for(`@inkeep/open-knowledge/skill-state-field-registry`),g6=globalThis;g6[h6]===void 0&&(g6[h6]=p());const _6=g6[h6],v6=[`.ok`,`skill-state.yml`],y6=[`claude-cowork`,`cli-hosts`],b6=[`server-build-and-open`,`electron-build-and-open`,`cli-npx-skills-add`,`desktop-direct`,`cli-start`],x6=/^\d+\.\d+\.\d+(?:[-+][\w.-]+)?$/,S6=w({version:b().regex(x6,`version must match /^\\d+\\.\\d+\\.\\d+(?:[-+][\\w.-]+)?$/`).register(_6,{description:`Recorded skill version for this target.`}),recordedAt:ne().register(_6,{description:`ISO 8601 timestamp of the most recent successful write. Updated on every write, including reinstalls of the same version.`}),surface:d(b6).register(_6,{description:`Install-source surface that recorded this entry.`}).optional()}),C6=w({enabled:E().register(_6,{description:`Whether this user-global skill bundle is opted in.`}),decidedAt:ne().register(_6,{description:`ISO 8601 timestamp of the opt-in / opt-out decision.`})}),w6=w({schema:_(1).register(_6,{description:`Schema major version. Bumped only on breaking shape changes.`}),targets:w({"claude-cowork":S6.optional(),"cli-hosts":S6.optional()}).register(_6,{description:`Per-target install-state entries. Absent target = no recorded install.`}).default({}),bundles:T(b(),C6).register(_6,{description:`Per-bundle opt-in decisions keyed by install name. Absent key = no recorded decision.`}).optional()});function T6(e,t){return e??t.installedOnDisk}function E6(){return{schema:1,targets:{}}}const D6=`template`;function O6(e){if(e.trim()===``)return{};let t;try{t=(0,je.parse)(e)}catch{return{}}return typeof t!=`object`||!t||Array.isArray(t)?{}:t}function k6(e,t){return e.trim()===``?t:`---\n${e}\n---\n${t}`}function A6(e){let{frontmatter:t,body:n}=zp(e);return t===``?{docFrontmatterText:``,markdown:e}:{docFrontmatterText:Vp(t),markdown:n}}function j6(e){let t=e.split(`
|
|
333
333
|
`);if(!(t[0]??``).startsWith(`template:`))return null;let n=[t[0]??``],r=1;for(;r<t.length;){let e=t[r]??``;if(/^[ \t]/.test(e)){n.push(e),r++;continue}if(e.trim()===``){let i=r+1;for(;i<t.length&&(t[i]??``).trim()===``;)i++;if(i<t.length&&/^[ \t]/.test(t[i]??``)){n.push(e),r++;continue}}break}let i=O6(n.join(`
|
|
334
334
|
`))[D6];return{identity:typeof i==`object`&&i&&!Array.isArray(i)?i:{},docFrontmatterText:t.slice(r).join(`
|
|
335
|
-
`).replace(/\n+$/,``)}}function M6(e){let t=e.charCodeAt(0)===65279?e.slice(1):e,{frontmatter:n,body:r}=zp(t);if(n===``)return{identity:{},starterContent:t};let i=Vp(n),a=j6(i);if(a)return{identity:a.identity,starterContent:k6(a.docFrontmatterText,r)};let{frontmatter:o}=zp(r);if(o!==``)return{identity:O6(i),starterContent:r};let s=O6(i);return typeof s.title==`string`?{identity:s,starterContent:r}:{identity:{},starterContent:k6(i,r)}}function N6(e,t){let{docFrontmatterText:n,markdown:r}=A6(t),i={};for(let[t,n]of Object.entries(e))n!==void 0&&(i[t]=n);let a=(0,je.stringify)({[D6]:i});return`---\n${n.trim()===``?a:`${a}${n}\n`}---\n${r}`}function P6(e){return M6(e).starterContent}const F6=`(agent thread)`;function I6(){let e=!1,t=``,n=0;return r=>{let i=L6(r);return e?(i&&i.char===t&&i.len>=n&&!i.hasInfo&&(e=!1,t=``,n=0),!0):i?(e=!0,t=i.char,n=i.len,!0):!1}}function L6(e){let t=(e.endsWith(`\r`)?e.slice(0,-1):e).match(/^ {0,3}([`~])(\1{2,})(.*)$/);return t?{char:t[1],len:1+t[2].length,hasInfo:t[3].trim()!==``}:null}const R6=[`#D97757`,`#1B1912`,`#F9F3E9`,`#7A9DFF`,`#8534F3`,`#9663F0`,`#727CF3`],
|
|
336
|
-
//# sourceMappingURL=src-
|
|
335
|
+
`).replace(/\n+$/,``)}}function M6(e){let t=e.charCodeAt(0)===65279?e.slice(1):e,{frontmatter:n,body:r}=zp(t);if(n===``)return{identity:{},starterContent:t};let i=Vp(n),a=j6(i);if(a)return{identity:a.identity,starterContent:k6(a.docFrontmatterText,r)};let{frontmatter:o}=zp(r);if(o!==``)return{identity:O6(i),starterContent:r};let s=O6(i);return typeof s.title==`string`?{identity:s,starterContent:r}:{identity:{},starterContent:k6(i,r)}}function N6(e,t){let{docFrontmatterText:n,markdown:r}=A6(t),i={};for(let[t,n]of Object.entries(e))n!==void 0&&(i[t]=n);let a=(0,je.stringify)({[D6]:i});return`---\n${n.trim()===``?a:`${a}${n}\n`}---\n${r}`}function P6(e){return M6(e).starterContent}const F6=`(agent thread)`;function I6(){let e=!1,t=``,n=0;return r=>{let i=L6(r);return e?(i&&i.char===t&&i.len>=n&&!i.hasInfo&&(e=!1,t=``,n=0),!0):i?(e=!0,t=i.char,n=i.len,!0):!1}}function L6(e){let t=(e.endsWith(`\r`)?e.slice(0,-1):e).match(/^ {0,3}([`~])(\1{2,})(.*)$/);return t?{char:t[1],len:1+t[2].length,hasInfo:t[3].trim()!==``}:null}const R6=/^(#{1,6})\s+(.+)$/;function z6(e,t){let n=(e.endsWith(`\r`)?e.slice(0,-1):e).match(R6);if(!n)return null;let r=n[2].trim(),i=qJ(r,t);return i?{level:n[1].length,text:r,slug:i}:null}const B6=[`#D97757`,`#1B1912`,`#F9F3E9`,`#7A9DFF`,`#8534F3`,`#9663F0`,`#727CF3`],V6={claude:`#D97757`,cursor:`#1B1912`,windsurf:`#0B100F`,openai:`#7A9DFF`,github:`#8534F3`,cline:`#9663F0`,bot:`#727CF3`};function H6(e,t=B6){let n=0;for(let t of e)n=(n<<5)-n+t.charCodeAt(0)|0;return t[Math.abs(n)%t.length]}const U6={"claude-code":`claude`,"claude-ai":`claude`,cursor:`cursor`,"cursor-vscode":`cursor`,cascade:`windsurf`,codex:`openai`,"codex-mcp-client":`openai`,copilot:`github`,cline:`cline`};function W6(e){return e?U6[e]||(e.startsWith(`local-agent-mode-`)?`claude`:`bot`):`bot`}const G6={claude:`Claude`,cursor:`Cursor`,windsurf:`Windsurf`,openai:`Codex`,github:`Copilot`,cline:`Cline`};function K6(e){let t=e?.trim();return t?G6[W6(t)]??t:`Agent`}function q6(e,t){let n=e.trim();if(!n||/^[a-zA-Z][a-zA-Z\d+\-.]*:/.test(n)||n.startsWith(`//`)||n.startsWith(`#`))return null;let r=n.indexOf(`#`),i=r>=0?n.slice(0,r):n,a=r>=0?n.slice(r+1):null,o=(i.split(`?`)[0]??``).trim();if(!o)return null;let s=(o.split(`/`).pop()??``).match(/\.([a-z0-9]+)$/i);if(s){let e=(s[1]??``).toLowerCase();if(e!==`md`&&e!==`mdx`)return null}let c=o.toLowerCase(),l=c.endsWith(`.mdx`)?o.slice(0,-4):c.endsWith(`.md`)?o.slice(0,-3):o,u=l.startsWith(`/`),d=u?l.slice(1):l,f=u?[]:t.includes(`/`)?t.split(`/`).slice(0,-1):[];for(let e of d.split(`/`))if(e===`..`){if(f.length===0)return null;f.pop()}else e!==`.`&&e!==``&&f.push(e);return f.length===0?null:{docName:f.join(`/`),anchor:a||null}}const J6=/^[a-zA-Z][a-zA-Z\d+\-.]*:/;function Y6(e){let t=(e.split(/[?#]/)[0]??e).match(/\.([a-z0-9]+)$/i);return t?(t[1]??``).toLowerCase():null}function X6(e){let t=e.trim();return J6.test(t)||t.startsWith(`//`)}function Z6(e,t){let n=e.trim();if(!n)return null;if(n.startsWith(`#`)){let e=n.slice(1).trim();return e?{kind:`anchor`,anchor:e}:null}if(X6(n))return{kind:`external`,url:n};let r=q6(n,t);if(r)return{kind:`doc`,docName:r.docName,anchor:r.anchor};let i=Y6(n);return i&&i!==`md`&&i!==`mdx`?{kind:`asset`,url:n,ext:i}:null}function Q6(e,t){let n=e.trim();if(!n)return null;if(X6(n))return{kind:`external`,url:t?`${n}#${t}`:n};let r=Y6(n);return r&&r!==`md`&&r!==`mdx`?{kind:`asset`,url:n,ext:r}:{kind:`doc`,docName:n,anchor:t?.trim()||null}}function $6(e,t){let n=e.trim();if(!n||J6.test(n)||n.startsWith(`//`)||n.startsWith(`#`))return null;let r=n.indexOf(`#`),i=((r>=0?n.slice(0,r):n).split(`?`)[0]??``).trim();if(!i)return null;let a=i.startsWith(`/`),o=a?i.slice(1):i,s=a?[]:t.includes(`/`)?t.split(`/`).slice(0,-1):[];for(let e of o.split(`/`))if(e===`..`){if(s.length===0)return null;s.pop()}else e!==`.`&&e!==``&&s.push(e);return s.length===0?null:s.join(`/`)}function e8(e){let t=e;return t.startsWith(`./`)&&(t=t.slice(2)),t.startsWith(`/`)&&(t=t.slice(1)),t}function t8(e){let t=e.lastIndexOf(`/`);return t===-1?e:e.slice(t+1)}function n8(e){let t=e.lastIndexOf(`/`);return t===-1?``:e.slice(0,t)}function r8(e){return e.split(`/`).filter(e=>e!==``)}function i8(e,t){let n=n8(t);return e===``||n===e?!0:n.startsWith(`${e}/`)}function a8(e,t){let n=n8(t);if(e===n)return 0;let r=e===``?n:n.slice(e.length+1);return r===``?0:r8(r).length}function o8(e,t){let n=r8(e),r=r8(t),i=0;for(;i<n.length&&i<r.length&&n[i]===r[i];)i++;return n.length-i+(r.length-i)}function s8(){let e=new Map;function t(t){let n=e8(t);if(n===``)return;let r=t8(n);if(r===``)return;let i=r.toLowerCase(),a=e.get(i);if(!a){e.set(i,[n]);return}a.includes(n)||a.push(n)}function n(t){let n=e8(t),r=t8(n).toLowerCase(),i=e.get(r);if(!i)return;let a=i.indexOf(n);a!==-1&&(i.splice(a,1),i.length===0&&e.delete(r))}function r(e,r){n(e),t(r)}function i(t,n){let r=t.toLowerCase(),i=e.get(r);if(!i||i.length===0)return null;if(i.length===1)return i[0];let a=n8(e8(n)),o=[],s=[];for(let e of i)i8(a,e)?o.push(e):s.push(e);return o.length>0?(e=>{let t=e[0],n=a8(a,t);for(let r=1;r<e.length;r++){let i=e[r],o=a8(a,i);(o<n||o===n&&i<t)&&(t=i,n=o)}return t})(o):(e=>{let t=e[0],n=o8(a,n8(t));for(let r=1;r<e.length;r++){let i=e[r],o=o8(a,n8(i));(o<n||o===n&&i<t)&&(t=i,n=o)}return t})(s)}function a(){let t=new Map;for(let[n,r]of e)t.set(n,[...r]);return t}function o(){e.clear()}return{add:t,remove:n,rename:r,resolveEmbed:i,clear:o,snapshot:a,size:()=>e.size}}function c8(e){if(!e)return[];let t=e.split(`/`),n=[],r=``;for(let e of t)r=r?`${r}/${e}`:e,n.push(r);return n}function l8(e,t){if(e.size===0)return new Set;if(t===``)return new Set(e);let n=new Set,r=`${t}/`;for(let i of e)(i===t||i.startsWith(r))&&n.add(i);return n}export{L$ as $,ze as $a,nb as $i,KX as $n,jY as $r,OQ as $t,q1 as A,wt as Aa,VU as Ai,CZ as An,lX as Ar,PQ as At,N1 as B,mt as Ba,_V as Bi,iZ as Bn,$Y as Br,BQ as Bt,E6 as C,Bp as Ca,_J as Ci,MZ as Cn,ge as Co,pX as Cr,WQ as Ct,f6 as D,vi as Da,bJ as Di,EZ as Dn,F as Do,fX as Dr,qZ as Dt,H3 as E,Ad as Ea,dJ as Ei,kZ as En,_e as Eo,dX as Er,KZ as Et,F1 as F,vt as Fa,RU as Fi,$X as Fn,JY as Fr,CQ as Ft,b1 as G,ft as Ga,eb as Gi,uZ as Gn,NY as Gr,mQ as Gt,x1 as H,st as Ha,$L as Hi,sZ as Hn,HY as Hr,vQ as Ht,R1 as I,yt as Ia,zU as Ii,eZ as In,qY as Ir,xQ as It,e1 as J,ut as Ja,rb as Ji,pZ as Jn,FY as Jr,aQ as Jt,_1 as K,lt as Ka,ob as Ki,hZ as Kn,bY as Kr,MQ as Kt,L1 as L,ht as La,TU as Li,dZ as Ln,GY as Lr,SQ as Lt,Y1 as M,xt as Ma,HU as Mi,TZ as Mn,iX as Mr,LQ as Mt,U1 as N,St as Na,tW as Ni,tZ as Nn,cX as Nr,_Q as Nt,J3 as O,I as Oa,sJ as Oi,DZ as On,pe as Oo,oX as Or,JZ as Ot,z1 as P,bt as Pa,qU as Pi,nZ as Pn,nX as Pr,wQ as Pt,B$ as Q,Pe as Qa,ib as Qi,JX as Qn,_Y as Qr,DQ as Qt,I1 as R,gt as Ra,WH as Ri,fZ as Rn,WY as Rr,dQ as Rt,w6 as S,ey as Sa,lJ as Si,jZ as Sn,be as So,mX as Sr,GQ as St,W3 as T,Vp as Ta,SJ as Ti,AZ as Tn,me as To,uX as Tr,VQ as Tt,D1 as U,pt as Ua,GN as Ui,aZ as Un,DY as Ur,yQ as Ut,O1 as V,ot as Va,gV as Vi,QX as Vn,VY as Vr,EQ as Vt,y1 as W,ct as Wa,LM as Wi,lZ as Wn,yY as Wr,pQ as Wt,J$ as X,it as Xa,sb as Xi,FX as Xn,vY as Xr,AQ as Xt,K$ as Y,at as Ya,Qy as Yi,mZ as Yn,RY as Yr,kQ as Yt,z$ as Z,rt as Za,ab as Zi,IX as Zn,MY as Zr,jQ as Zt,P6 as _,fy as _a,PJ as _i,BZ as _n,Me as _o,wX as _r,ZQ as _t,Q6 as a,Cy as aa,$J as ai,UZ as an,Ve as ao,BX as ar,O$ as at,y6 as b,sy as ba,pJ as bi,IZ as bn,xe as bo,bX as br,qQ as bt,V6 as c,jy as ca,GJ as ci,eQ as cn,Ne as co,LX as cr,h$ as ct,W6 as d,Xy as da,RJ as di,iQ as dn,Ze as do,xX as dr,d$ as dt,Gy as ea,kY as ei,hQ as en,Re as eo,WX as er,P$ as et,z6 as f,Hy as fa,zJ as fi,QZ as fn,et as fo,SX as fr,u$ as ft,N6 as g,my as ga,TJ as gi,zZ as gn,Qe as go,TX as gr,QQ as gt,D6 as h,Py as ha,CJ as hi,cQ as hn,qe as ho,kX as hr,JQ as ht,Z6 as i,wy as ia,gY as ii,GZ as in,Be as io,YX as ir,k$ as it,J1 as j,Ct as ja,UU as ji,wZ as jn,rX as jr,RQ as jt,W1 as k,Tt as ka,oJ as ki,OZ as kn,de as ko,sX as kr,oQ as kt,H6 as l,Ny as la,VJ as li,tQ as ln,Ue as lo,AX as lr,g$ as lt,F6 as m,Uy as ma,kJ as mi,ZZ as mn,Ge as mo,OX as mr,a$ as mt,l8 as n,Jy as na,BY as ni,fQ as nn,Le as no,VX as nr,M$ as nt,$6 as o,ky as oa,cY as oi,nQ as on,He as oo,RX as or,b$ as ot,I6 as p,Iy as pa,EJ as pi,$Z as pn,Ye as po,CX as pr,e$ as pt,X$ as q,dt as qa,$y as qi,gZ as qn,PY as qr,NQ as qt,s8 as r,xy as ra,pY as ri,lQ as rn,Ie as ro,qX as rr,A$ as rt,q6 as s,Oy as sa,lY as si,XZ as sn,We as so,zX as sr,C$ as st,c8 as t,Ky as ta,zY as ti,gQ as tn,Fe as to,HX as tr,N$ as tt,K6 as u,Yy as ua,BJ as ui,rQ as un,nt as uo,jX as ur,y$ as ut,M6 as v,uy as va,FJ as vi,VZ as vn,we as vo,DX as vr,YQ as vt,T6 as w,zp as wa,xJ as wi,FZ as wn,he as wo,_X as wr,UQ as wt,x6 as x,iy as xa,vJ as xi,RZ as xn,Se as xo,gX as xr,HQ as xt,v6 as y,ly as ya,fJ as yi,HZ as yn,Te as yo,vX as yr,XQ as yt,P1 as z,_t as za,kV as zi,rZ as zn,XY as zr,TQ as zt};
|
|
336
|
+
//# sourceMappingURL=src-jbLmpusB.mjs.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{L as e,P as t}from"./src-H4ZV7b5v.mjs";import{Wr as n,Zr as r,a as i,un as a}from"./src-DeZ1D7q7.mjs";import{C as o,w as s}from"./write-project-skill-C6Fs5yeK.mjs";import{a as c,n as l,t as u}from"./acp-harness-probe-ByCqmbsD.mjs";import{n as d}from"./constants-k1x9z874.mjs";import{spawn as f}from"node:child_process";import{basename as p,join as m,posix as h,resolve as g,win32 as _}from"node:path";import{closeSync as v,existsSync as y,mkdirSync as b,openSync as x,statSync as S}from"node:fs";import{homedir as C}from"node:os";import{rm as w}from"node:fs/promises";import{setTimeout as T}from"node:timers/promises";function E(e){let t={...e};return delete t.ELECTRON_RUN_AS_NODE,t}function D(e,t,r={}){let i=(r.spawn??f)(e,[...t],n({detached:!0,stdio:`ignore`,env:E(r.env??process.env)}));return i.unref(),i}const O=`OpenKnowledge.app`,k=`/Applications/${O}`;function A(){return{platform:process.platform,env:process.env,execPath:process.execPath,isTTY:process.stdout.isTTY,statSync:e=>{try{return S(e,{throwIfNoEntry:!1})??null}catch{return null}}}}function j(e){if(e.env.ELECTRON_RUN_AS_NODE===`1`){let t=/(.+?\.app)\/Contents\/MacOS\//.exec(e.execPath);if(t?.[1])return t[1]}if(M(e,k))return k;let t=m(e.homeDir??C(),`Applications`,O);return M(e,t)?t:null}function M(e,t){return N(e,m(t,`Contents`,`MacOS`,`OpenKnowledge`))}function N(e,t){try{let n=e.statSync(t);return n&&typeof n.isFile==`function`?n.isFile():!1}catch{return!1}}const ee=[`@inkeepopen-knowledge-desktop`,`OpenKnowledge`];function P(e){if(e.env.ELECTRON_RUN_AS_NODE===`1`&&/\\OpenKnowledge\.exe$/i.test(e.execPath))return e.execPath;let t=e.env.LOCALAPPDATA;if(t)for(let n of ee){let r=_.join(t,`Programs`,n,`OpenKnowledge.exe`);if(N(e,r))return r}return null}function F(e){if(e.env.ELECTRON_RUN_AS_NODE===`1`&&e.execPath.endsWith(`/openknowledge`))return e.execPath;let t=`/opt/OpenKnowledge/openknowledge`;return N(e,t)?t:null}function I(e){if(e.env.OK_FORCE_BROWSER===`1`)return{available:!1,reason:`force-browser`};if(e.platform!==`darwin`&&e.platform!==`win32`&&e.platform!==`linux`)return{available:!1,reason:`unsupported-platform`};let t;try{t=e.platform===`darwin`?j(e):e.platform===`win32`?P(e):F(e)}catch{return{available:!1,reason:`stat-error`}}return t?e.env.OK_FORCE_DESKTOP===`1`?{available:!0,reason:`available`,bundlePath:t}:!(e.isTTY===!0||e.platform===`win32`&&e.isTTY===void 0&&!e.env.CI)||e.env.SSH_CONNECTION||e.env.SSH_TTY||e.platform===`linux`&&!e.env.DISPLAY&&!e.env.WAYLAND_DISPLAY?{available:!1,reason:`headless`,bundlePath:t}:{available:!0,reason:`available`,bundlePath:t}:{available:!1,reason:`no-bundle`}}function L(e,t){let n=e.log??(e=>console.error(e)),r=e.platform??process.platform;if(n("Launching OpenKnowledge desktop (use `ok start` for the browser server, or `OK_FORCE_BROWSER=1` to always skip)"),r===`darwin`){D(`open`,[`-b`,`com.inkeep.open-knowledge`],{spawn:e.spawn});return}let i=t?.bundlePath;if(!i){n(`Desktop launch skipped: no resolved desktop executable (caller bug).`);return}D(i,[],{spawn:e.spawn})}function R(e=`no-bundle`){switch(e){case`no-bundle`:return`Desktop app not found (checked the standard install locations for this OS). Install it, or omit --mode for browser mode.`;case`darwin-only`:case`unsupported-platform`:return`Desktop app is not available on this platform. Use --mode=browser, or omit --mode for the server fallback.`;case`headless`:return`Desktop launch is gated in headless contexts (CI, SSH, non-TTY stdout). Set OK_FORCE_DESKTOP=1 to override, or use --mode=browser.`;case`force-browser`:return`OK_FORCE_BROWSER=1 is set — desktop dispatch is disabled. Unset it to use --mode=app.`;case`stat-error`:return`Failed to inspect the desktop install (filesystem error). Check permissions or use --mode=browser.`;case`available`:return`Desktop app appears available but launch dispatch did not fire (caller bug).`}}function z(e){return h.join(h.dirname(e),`..`,`Frameworks`,`OpenKnowledge Server.app`,`Contents`,`MacOS`,`OpenKnowledge Helper`)}const te=/\/[^/]+\.app\/Contents\/MacOS\/[^/]+$/;function ne(e){if(e.platform!==`darwin`||!te.test(e.execPath))return null;let t=z(e.execPath);return e.exists(t)?t:null}function B(e={}){let t=e.execPath??process.execPath,n=e.platform??process.platform,r=e.argv??process.argv,i=e.exists??y,a=r[1];return a?{command:ne({execPath:t,platform:n,exists:i})??t,prefixArgs:[a]}:(console.warn(`[self-spawn] process.argv[1] is empty — falling back to \`npx -y @inkeep/open-knowledge@latest\`. This re-introduces the registry-fetch surface that re-exec was fixing. Observed argv: ${JSON.stringify(r)}`),{command:`npx`,prefixArgs:[`-y`,`@inkeep/open-knowledge@latest`]})}function V(e,t){return e.host??t.HOST??`127.0.0.1`}function H(e,t){return t&&(e===`::`||e===`::1`||e===`[::1]`||e===`localhost`||e===`0.0.0.0`)?{host:`127.0.0.1`,coerced:!0}:{host:e,coerced:!1}}function U(e){let t=p(e).replace(/[^\x20-\x7E]/g,``).trim().slice(0,64);return`open-knowledge-server ${t.length>0?t:`unknown`}`}var W=class extends Error{cwd;constructor(e){super("This directory isn't set up yet. Run `ok init` first, then `ok start` again."),this.name=`OkDirMissingError`,this.cwd=e}};function G(e){return e.uiLock?e.isAlive(e.uiLock.pid)?{action:`skip`,reason:`alive`,pid:e.uiLock.pid,port:e.uiLock.port}:{action:`spawn`,reason:`stale`,stalePid:e.uiLock.pid}:{action:`spawn`,reason:`absent`}}function K(t){y(t.lockDir)||b(t.lockDir,{recursive:!0});let n=x(m(t.lockDir,e),`w`),r=t.spawn??f,{PORT:i,...a}=process.env,o=B();try{let e=r(o.command,[...o.prefixArgs,...t.args??[`ui`]],{detached:!0,stdio:[`ignore`,`ignore`,n],windowsHide:!0,cwd:t.cwd,env:{...a,ELECTRON_RUN_AS_NODE:`1`}});return e.unref(),e}finally{try{v(n)}catch{}}}function q(e,t,n,r=!1){return e??(n!==void 0||r?void 0:t)}function J(e,t){return e!==void 0&&t!==null&&t.port>0&&t.draining!==!0}function Y(e,t,n){return e??+(t!=null&&!n)}async function X(e){let t=e.spawn??f,n=B(),{PORT:r,...i}=process.env,a=t(n.command,[...n.prefixArgs,`ui`,`--port`,String(e.uiPort)],{cwd:e.cwd,stdio:`inherit`,windowsHide:!0,env:{...i,ELECTRON_RUN_AS_NODE:`1`}}),o=!1,s=e=>{o=!0;try{a.kill(e)}catch{}},c=()=>s(`SIGINT`),l=()=>s(`SIGTERM`);process.once(`SIGINT`,c),process.once(`SIGTERM`,l),await new Promise(e=>{a.on(`exit`,(t,n)=>{process.exitCode=Y(t,n,o),e()}),a.on(`error`,t=>{console.error(`[start] connect fallback: failed to spawn ok ui — ${t instanceof Error?t.message:String(t)}`),process.exitCode=1,e()})}),process.removeListener(`SIGINT`,c),process.removeListener(`SIGTERM`,l)}async function Z(e){let t=e.now()+e.timeoutMs;for(;e.now()<t;){let t=e.readUiLock();if(t&&t.port>0)return t.port;await e.sleep(e.pollIntervalMs)}let n=e.readUiLock();return n&&n.port>0?n.port:null}const re=t;function ie(e,t,n=e=>w(e,{recursive:!0,force:!0})){return async()=>{try{await e()}finally{try{await n(t)}catch(e){process.stderr.write(`[start] ephemeral temp dir reap failed for ${t}: ${e instanceof Error?e.message:String(e)}\n`)}}}}function ae(e,t={}){let n=t.exit??(e=>process.exit(e)),r=t.getActiveHandles??(()=>{let e=process._getActiveHandles;return e?e.call(process):null});return async()=>{let i=!1;try{await e()}catch(e){i=!0,t.log?.error({err:e},`idle-shutdown: destroy failed — exiting anyway`)}finally{let e=null;try{let t=r();if(t!==null){e={};for(let n of t){let t=n?.constructor?.name??`unknown`;e[t]=(e[t]??0)+1}}}catch{e=null}t.log?.info({event:`idle-shutdown-exit`,exitCode:+!!i,openHandles:e??{},handlesAvailable:e!==null},`idle-shutdown: teardown finished — exiting process`),n(+!!i)}}}async function Q(e){let t=e.sigtermGraceMs??re,n=e.sigtermPollIntervalMs??200,r=e.sleep??(e=>T(e)),i=e.reason??`teardown`;try{let a=e.readUiLock(),o=e.spawnedUiPid();if(a&&e.isAlive(a.pid)&&a.pid!==o)e.log?.info({pid:a.pid,port:a.port,spawnedUiPid:o},`${i}: ui.lock holder is not our spawned sibling — leaving it alone`);else if(a&&e.isAlive(a.pid))try{e.killPid(a.pid,`SIGTERM`),e.log?.info({pid:a.pid,port:a.port},`${i}: SIGTERM UI sibling`);let o=Date.now()+t;for(;Date.now()<o&&e.isAlive(a.pid);)await r(n);if(e.isAlive(a.pid))try{e.killPid(a.pid,`SIGKILL`),e.log?.warn({pid:a.pid,graceMs:t},`${i}: SIGTERM grace expired — escalated to SIGKILL`)}catch(t){e.log?.error({pid:a.pid,err:t},`${i}: SIGKILL failed`)}}catch(t){e.log?.warn({pid:a.pid,err:t},`${i}: failed to SIGTERM UI sibling`)}}catch(t){e.log?.warn({err:t},`${i}: UI lookup failed; proceeding`)}}function oe(e){let{destroy:t,...n}=e;return async()=>{await Q({...n,reason:`idle-shutdown`}),await t()}}async function se(e){let{config:t,cwd:n,host:o}=e,s=e.skipAutoInit??!1,d=e.skipUiAutoSpawn??!1,f=e.idleThresholdMs??18e5,{existsSync:p,mkdirSync:m}=await import(`node:fs`),{basename:h,dirname:g}=await import(`node:path`),{bootServer:_,getLogger:v,isProcessAlive:y,readUiLock:b,resolveContentDir:x,resolveLockDir:S,waitForServerLockDrain:C}=await import(`./src-BmUGNQeQ.mjs`),w=e.log??v(`start`),E=e.singleFile!==void 0,D=e.projectDir??n,O=E?i(e.singleFile).canonicalFilePath:void 0,k=O?g(O):void 0,A=O?h(O):void 0;if(!E){if(!s&&!a(n))throw new W(n);let t=process.env.OK_RECLAIM_DISABLE??null,r=e=>{let t=typeof e.event==`string`?e.event:``;(t.endsWith(`-failed`)||t.endsWith(`-error`)||t.endsWith(`-missing`))&&w.warn({event:e},`[start] reclaim sweep reported a problem`)};try{(e.repairMcpConfigsFn??(await import(`./repair-mcp-configs-CDJq4Ve2.mjs`)).repairMcpConfigs)({projectDir:n,reclaimDisableEnv:t,logger:r})}catch(e){w.warn({err:e},`[start] mcp-config repair sweep failed; continuing`)}try{(e.repairLaunchJsonFn??(await import(`./repair-launch-json-By9LDC45.mjs`)).repairLaunchJson)({projectDir:n,reclaimDisableEnv:t,logger:r})}catch(e){w.warn({err:e},`[start] launch.json repair sweep failed; continuing`)}try{await(e.repairSkillsFn??(await import(`./repair-skills-Cjwz2l5i.mjs`)).repairSkills)({projectDir:n,reclaimDisableEnv:t,logger:r})}catch(e){w.warn({err:e},`[start] skill repair sweep failed; continuing`)}}let j=k??x(t,n);!E&&!p(j)&&(m(j,{recursive:!0}),w.info({contentDir:j},`Created content directory`));let M=null,N=null,ee=async({lockDir:t})=>{if(M=G({uiLock:b(t),isAlive:y}),M.action===`spawn`&&!d)try{let r=e.uiPort===void 0?void 0:[`ui`,`--port`,String(e.uiPort)];N=K({lockDir:t,cwd:n,spawn:e.spawn,args:r}).pid??null,w.info({reason:M.reason,uiPort:e.uiPort},`[start] auto-spawned ok ui sibling`)}catch(e){console.warn(`[start] failed to auto-spawn ok ui: ${e instanceof Error?e.message:String(e)}`)}else M.action===`skip`&&w.info({port:M.port,pid:M.pid},`UI already running at port ${M.port}`)},P=e.reactShellDistDir===void 0,F=c(),I=r();{let e=S(E?D:n),t=Date.now(),r=await C(e);r!==`no-drain`&&w.info({event:`start-waited-for-draining-predecessor`,outcome:r,waitedMs:Date.now()-t,drainLockDir:e},r===`released`?`[start] predecessor server finished draining — proceeding`:`[start] predecessor server still draining after wait — proceeding to collide`)}let L=await _({config:t,contentDir:j,projectDir:E?D:n,contentRoot:E?void 0:t.content.dir,port:e.port,host:o,...e.enableRemote===!0?{enableRemote:!0}:{},quiet:!1,detectGh:l,tokenStore:F,embeddingsKeyStore:I,...E?{ephemeral:!0,singleDocRelPath:A,gitEnabled:!1,gitPreflight:()=>({ok:!0,version:`0.0.0`,resolvedPath:`git`,source:`PATH`})}:{},localOpCliArgs:[process.execPath,process.argv[1]],probeHarnessManagedMcpEntry:(e,t)=>u(e,t),attachUiSibling:P,idleShutdownMs:f,skipAutoInit:!0,...P?{spawnUiSiblingFn:ee}:{},idleShutdownHandler:t=>{let n=oe({readUiLock:()=>b(L.lockDir),spawnedUiPid:()=>N,isAlive:y,killPid:(e,t)=>{process.kill(e,t)},destroy:t,log:w});return ae(E?ie(n,D):n,{log:w,exit:e.idleExit})},log:w,...e.serveContentAssets===void 0?{}:{serveContentAssets:e.serveContentAssets},...e.reactShellDistDir?{reactShellDistDir:e.reactShellDistDir}:{}});M||={action:`skip`,reason:`alive`,pid:0,port:0};let R=M,z=null;if(R.action===`skip`)z=R.port>0?R.port:null;else if(!d){let t=e.uiBindTimeoutMs??3e3;z=await Z({readUiLock:()=>b(L.lockDir),now:Date.now,sleep:e=>T(e),timeoutMs:t,pollIntervalMs:50}),z===null&&w.warn({timeoutMs:t},`[start] ok ui did not bind within timeout — banner falls back to API URL`)}return{httpServer:L.httpServer,destroy:L.destroy,lockDir:L.lockDir,contentDir:j,port:L.port,ready:L.ready,degraded:L.degraded,uiSpawnDecision:M,spawnedUiPid:N,resolvedUiPort:z}}function ce(e){if(e===`browser`||e===`app`)return e;throw new s(`--mode must be 'browser' or 'app'`)}function le(e){let t=Number.parseInt(e,10);if(Number.isNaN(t)||t<1||t>65535)throw new s(`--ui-port must be a port number between 1 and 65535`);return t}function ue(e){return e.OK_CONSOLE_LEVEL!==void 0||e.LOG_LEVEL!==void 0?null:`warn`}function $(e){let t=[`Stopping OpenKnowledge…`,`Saving pending changes and releasing the server lock — this can take a few seconds.`];return e===`SIGINT`&&t.push(`Press Ctrl+C again to force quit.`),t}async function de(e,t){let n=ue(process.env);n!==null&&(process.env.OK_CONSOLE_LEVEL=n);let{renderBanner:r}=await import(`./banner--DGfdMN8.mjs`),{accent:i,dim:a,error:o,warning:s}=await import(`./colors-MGDi6UGf.mjs`),c=process.cwd(),l=t.remote!==void 0&&t.remote!==!1,u=typeof t.remote==`string`?t.remote:void 0,f=u===void 0?e:{...e,remote:{...e.remote,url:u}};process.title=U(c),l&&(typeof f.remote?.url!=`string`||f.remote.url===``)&&(console.error(o("--remote requires a public tunnel URL — pass it (`ok start --remote https://<your-tunnel-host>`) or set remote.url in .ok/config.yml.")),process.exit(78)),l&&console.warn(s([``,`⚠ REMOTE ACCESS ENABLED — no server-side authentication.`,` Anyone who can reach ${f.remote?.url} has FULL control of this`,` knowledge base, including sync, publishing, credentials, and local operations.`,` Restrict who can reach it at the tunnel: ngrok OAuth, Cloudflare Access,`,` Tailscale ACLs, or equivalent edge auth.`,``].join(`
|
|
2
|
-
`)));let p=V(t,process.env),m=H(p,l);m.coerced&&console.warn(`remote access is enabled and ${p} is not an IPv4 loopback bind — tunnels proxy to 127.0.0.1, so binding ${p} would leave the tunnel dialing a dead port. Using 127.0.0.1.`);let h=m.host,_=t.port===void 0?void 0:Number(t.port),v=process.env.PORT?Number(process.env.PORT):void 0,b=t.uiPort===void 0?void 0:Number(t.uiPort);l&&_===void 0&&v!==void 0&&console.warn(`remote access is enabled — ignoring env PORT=${process.env.PORT}; the tunnel's port mapping targets the stable remote port (${f.remote?.port}). Pass --port to override deliberately.`);let x=q(_,v,b,l)??(l?f.remote?.port:void 0);if(b!==void 0){let{readServerLock:e,resolveLockDir:t}=await import(`./src-
|
|
1
|
+
import{F as e,R as t}from"./src-jbLmpusB.mjs";import{Gr as n,Qr as r,a as i,dn as a}from"./src-B0klb50O.mjs";import{C as o,w as s}from"./write-project-skill-C5NP_pT9.mjs";import{a as c,n as l,t as u}from"./acp-harness-probe-C9B2T64O.mjs";import{n as d}from"./constants-CLbzDwIP.mjs";import{spawn as f}from"node:child_process";import{basename as p,join as m,posix as h,resolve as g,win32 as _}from"node:path";import{closeSync as v,existsSync as y,mkdirSync as b,openSync as x,statSync as S}from"node:fs";import{homedir as C}from"node:os";import{rm as w}from"node:fs/promises";import{setTimeout as T}from"node:timers/promises";function E(e){let t={...e};return delete t.ELECTRON_RUN_AS_NODE,t}function D(e,t,r={}){let i=(r.spawn??f)(e,[...t],n({detached:!0,stdio:`ignore`,env:E(r.env??process.env)}));return i.unref(),i}const O=`OpenKnowledge.app`,k=`/Applications/${O}`;function A(){return{platform:process.platform,env:process.env,execPath:process.execPath,isTTY:process.stdout.isTTY,statSync:e=>{try{return S(e,{throwIfNoEntry:!1})??null}catch{return null}}}}function j(e){if(e.env.ELECTRON_RUN_AS_NODE===`1`){let t=/(.+?\.app)\/Contents\/MacOS\//.exec(e.execPath);if(t?.[1])return t[1]}if(M(e,k))return k;let t=m(e.homeDir??C(),`Applications`,O);return M(e,t)?t:null}function M(e,t){return N(e,m(t,`Contents`,`MacOS`,`OpenKnowledge`))}function N(e,t){try{let n=e.statSync(t);return n&&typeof n.isFile==`function`?n.isFile():!1}catch{return!1}}const ee=[`@inkeepopen-knowledge-desktop`,`OpenKnowledge`];function P(e){if(e.env.ELECTRON_RUN_AS_NODE===`1`&&/\\OpenKnowledge\.exe$/i.test(e.execPath))return e.execPath;let t=e.env.LOCALAPPDATA;if(t)for(let n of ee){let r=_.join(t,`Programs`,n,`OpenKnowledge.exe`);if(N(e,r))return r}return null}function F(e){if(e.env.ELECTRON_RUN_AS_NODE===`1`&&e.execPath.endsWith(`/openknowledge`))return e.execPath;let t=`/opt/OpenKnowledge/openknowledge`;return N(e,t)?t:null}function I(e){if(e.env.OK_FORCE_BROWSER===`1`)return{available:!1,reason:`force-browser`};if(e.platform!==`darwin`&&e.platform!==`win32`&&e.platform!==`linux`)return{available:!1,reason:`unsupported-platform`};let t;try{t=e.platform===`darwin`?j(e):e.platform===`win32`?P(e):F(e)}catch{return{available:!1,reason:`stat-error`}}return t?e.env.OK_FORCE_DESKTOP===`1`?{available:!0,reason:`available`,bundlePath:t}:!(e.isTTY===!0||e.platform===`win32`&&e.isTTY===void 0&&!e.env.CI)||e.env.SSH_CONNECTION||e.env.SSH_TTY||e.platform===`linux`&&!e.env.DISPLAY&&!e.env.WAYLAND_DISPLAY?{available:!1,reason:`headless`,bundlePath:t}:{available:!0,reason:`available`,bundlePath:t}:{available:!1,reason:`no-bundle`}}function L(e,t){let n=e.log??(e=>console.error(e)),r=e.platform??process.platform;if(n("Launching OpenKnowledge desktop (use `ok start` for the browser server, or `OK_FORCE_BROWSER=1` to always skip)"),r===`darwin`){D(`open`,[`-b`,`com.inkeep.open-knowledge`],{spawn:e.spawn});return}let i=t?.bundlePath;if(!i){n(`Desktop launch skipped: no resolved desktop executable (caller bug).`);return}D(i,[],{spawn:e.spawn})}function R(e=`no-bundle`){switch(e){case`no-bundle`:return`Desktop app not found (checked the standard install locations for this OS). Install it, or omit --mode for browser mode.`;case`darwin-only`:case`unsupported-platform`:return`Desktop app is not available on this platform. Use --mode=browser, or omit --mode for the server fallback.`;case`headless`:return`Desktop launch is gated in headless contexts (CI, SSH, non-TTY stdout). Set OK_FORCE_DESKTOP=1 to override, or use --mode=browser.`;case`force-browser`:return`OK_FORCE_BROWSER=1 is set — desktop dispatch is disabled. Unset it to use --mode=app.`;case`stat-error`:return`Failed to inspect the desktop install (filesystem error). Check permissions or use --mode=browser.`;case`available`:return`Desktop app appears available but launch dispatch did not fire (caller bug).`}}function z(e){return h.join(h.dirname(e),`..`,`Frameworks`,`OpenKnowledge Server.app`,`Contents`,`MacOS`,`OpenKnowledge Helper`)}const te=/\/[^/]+\.app\/Contents\/MacOS\/[^/]+$/;function ne(e){if(e.platform!==`darwin`||!te.test(e.execPath))return null;let t=z(e.execPath);return e.exists(t)?t:null}function B(e={}){let t=e.execPath??process.execPath,n=e.platform??process.platform,r=e.argv??process.argv,i=e.exists??y,a=r[1];return a?{command:ne({execPath:t,platform:n,exists:i})??t,prefixArgs:[a]}:(console.warn(`[self-spawn] process.argv[1] is empty — falling back to \`npx -y @inkeep/open-knowledge@latest\`. This re-introduces the registry-fetch surface that re-exec was fixing. Observed argv: ${JSON.stringify(r)}`),{command:`npx`,prefixArgs:[`-y`,`@inkeep/open-knowledge@latest`]})}function V(e,t){return e.host??t.HOST??`127.0.0.1`}function H(e,t){return t&&(e===`::`||e===`::1`||e===`[::1]`||e===`localhost`||e===`0.0.0.0`)?{host:`127.0.0.1`,coerced:!0}:{host:e,coerced:!1}}function U(e){let t=p(e).replace(/[^\x20-\x7E]/g,``).trim().slice(0,64);return`open-knowledge-server ${t.length>0?t:`unknown`}`}var W=class extends Error{cwd;constructor(e){super("This directory isn't set up yet. Run `ok init` first, then `ok start` again."),this.name=`OkDirMissingError`,this.cwd=e}};function G(e){return e.uiLock?e.isAlive(e.uiLock.pid)?{action:`skip`,reason:`alive`,pid:e.uiLock.pid,port:e.uiLock.port}:{action:`spawn`,reason:`stale`,stalePid:e.uiLock.pid}:{action:`spawn`,reason:`absent`}}function K(e){y(e.lockDir)||b(e.lockDir,{recursive:!0});let n=x(m(e.lockDir,t),`w`),r=e.spawn??f,{PORT:i,...a}=process.env,o=B();try{let t=r(o.command,[...o.prefixArgs,...e.args??[`ui`]],{detached:!0,stdio:[`ignore`,`ignore`,n],windowsHide:!0,cwd:e.cwd,env:{...a,ELECTRON_RUN_AS_NODE:`1`}});return t.unref(),t}finally{try{v(n)}catch{}}}function q(e,t,n,r=!1){return e??(n!==void 0||r?void 0:t)}function J(e,t){return e!==void 0&&t!==null&&t.port>0&&t.draining!==!0}function Y(e,t,n){return e??+(t!=null&&!n)}async function X(e){let t=e.spawn??f,n=B(),{PORT:r,...i}=process.env,a=t(n.command,[...n.prefixArgs,`ui`,`--port`,String(e.uiPort)],{cwd:e.cwd,stdio:`inherit`,windowsHide:!0,env:{...i,ELECTRON_RUN_AS_NODE:`1`}}),o=!1,s=e=>{o=!0;try{a.kill(e)}catch{}},c=()=>s(`SIGINT`),l=()=>s(`SIGTERM`);process.once(`SIGINT`,c),process.once(`SIGTERM`,l),await new Promise(e=>{a.on(`exit`,(t,n)=>{process.exitCode=Y(t,n,o),e()}),a.on(`error`,t=>{console.error(`[start] connect fallback: failed to spawn ok ui — ${t instanceof Error?t.message:String(t)}`),process.exitCode=1,e()})}),process.removeListener(`SIGINT`,c),process.removeListener(`SIGTERM`,l)}async function Z(e){let t=e.now()+e.timeoutMs;for(;e.now()<t;){let t=e.readUiLock();if(t&&t.port>0)return t.port;await e.sleep(e.pollIntervalMs)}let n=e.readUiLock();return n&&n.port>0?n.port:null}const re=e;function ie(e,t,n=e=>w(e,{recursive:!0,force:!0})){return async()=>{try{await e()}finally{try{await n(t)}catch(e){process.stderr.write(`[start] ephemeral temp dir reap failed for ${t}: ${e instanceof Error?e.message:String(e)}\n`)}}}}function ae(e,t={}){let n=t.exit??(e=>process.exit(e)),r=t.getActiveHandles??(()=>{let e=process._getActiveHandles;return e?e.call(process):null});return async()=>{let i=!1;try{await e()}catch(e){i=!0,t.log?.error({err:e},`idle-shutdown: destroy failed — exiting anyway`)}finally{let e=null;try{let t=r();if(t!==null){e={};for(let n of t){let t=n?.constructor?.name??`unknown`;e[t]=(e[t]??0)+1}}}catch{e=null}t.log?.info({event:`idle-shutdown-exit`,exitCode:+!!i,openHandles:e??{},handlesAvailable:e!==null},`idle-shutdown: teardown finished — exiting process`),n(+!!i)}}}async function Q(e){let t=e.sigtermGraceMs??re,n=e.sigtermPollIntervalMs??200,r=e.sleep??(e=>T(e)),i=e.reason??`teardown`;try{let a=e.readUiLock(),o=e.spawnedUiPid();if(a&&e.isAlive(a.pid)&&a.pid!==o)e.log?.info({pid:a.pid,port:a.port,spawnedUiPid:o},`${i}: ui.lock holder is not our spawned sibling — leaving it alone`);else if(a&&e.isAlive(a.pid))try{e.killPid(a.pid,`SIGTERM`),e.log?.info({pid:a.pid,port:a.port},`${i}: SIGTERM UI sibling`);let o=Date.now()+t;for(;Date.now()<o&&e.isAlive(a.pid);)await r(n);if(e.isAlive(a.pid))try{e.killPid(a.pid,`SIGKILL`),e.log?.warn({pid:a.pid,graceMs:t},`${i}: SIGTERM grace expired — escalated to SIGKILL`)}catch(t){e.log?.error({pid:a.pid,err:t},`${i}: SIGKILL failed`)}}catch(t){e.log?.warn({pid:a.pid,err:t},`${i}: failed to SIGTERM UI sibling`)}}catch(t){e.log?.warn({err:t},`${i}: UI lookup failed; proceeding`)}}function oe(e){let{destroy:t,...n}=e;return async()=>{await Q({...n,reason:`idle-shutdown`}),await t()}}async function se(e){let{config:t,cwd:n,host:o}=e,s=e.skipAutoInit??!1,d=e.skipUiAutoSpawn??!1,f=e.idleThresholdMs??18e5,{existsSync:p,mkdirSync:m}=await import(`node:fs`),{basename:h,dirname:g}=await import(`node:path`),{bootServer:_,getLogger:v,isProcessAlive:y,readUiLock:b,resolveContentDir:x,resolveLockDir:S,waitForServerLockDrain:C}=await import(`./src-CIOr7Lie.mjs`),w=e.log??v(`start`),E=e.singleFile!==void 0,D=e.projectDir??n,O=E?i(e.singleFile).canonicalFilePath:void 0,k=O?g(O):void 0,A=O?h(O):void 0;if(!E){if(!s&&!a(n))throw new W(n);let t=process.env.OK_RECLAIM_DISABLE??null,r=e=>{let t=typeof e.event==`string`?e.event:``;(t.endsWith(`-failed`)||t.endsWith(`-error`)||t.endsWith(`-missing`))&&w.warn({event:e},`[start] reclaim sweep reported a problem`)};try{(e.repairMcpConfigsFn??(await import(`./repair-mcp-configs-0uLPQ_lS.mjs`)).repairMcpConfigs)({projectDir:n,reclaimDisableEnv:t,logger:r})}catch(e){w.warn({err:e},`[start] mcp-config repair sweep failed; continuing`)}try{(e.repairLaunchJsonFn??(await import(`./repair-launch-json-9XTHkXcU.mjs`)).repairLaunchJson)({projectDir:n,reclaimDisableEnv:t,logger:r})}catch(e){w.warn({err:e},`[start] launch.json repair sweep failed; continuing`)}try{await(e.repairSkillsFn??(await import(`./repair-skills-BBckxGa0.mjs`)).repairSkills)({projectDir:n,reclaimDisableEnv:t,logger:r})}catch(e){w.warn({err:e},`[start] skill repair sweep failed; continuing`)}}let j=k??x(t,n);!E&&!p(j)&&(m(j,{recursive:!0}),w.info({contentDir:j},`Created content directory`));let M=null,N=null,ee=async({lockDir:t})=>{if(M=G({uiLock:b(t),isAlive:y}),M.action===`spawn`&&!d)try{let r=e.uiPort===void 0?void 0:[`ui`,`--port`,String(e.uiPort)];N=K({lockDir:t,cwd:n,spawn:e.spawn,args:r}).pid??null,w.info({reason:M.reason,uiPort:e.uiPort},`[start] auto-spawned ok ui sibling`)}catch(e){console.warn(`[start] failed to auto-spawn ok ui: ${e instanceof Error?e.message:String(e)}`)}else M.action===`skip`&&w.info({port:M.port,pid:M.pid},`UI already running at port ${M.port}`)},P=e.reactShellDistDir===void 0,F=c(),I=r();{let e=S(E?D:n),t=Date.now(),r=await C(e);r!==`no-drain`&&w.info({event:`start-waited-for-draining-predecessor`,outcome:r,waitedMs:Date.now()-t,drainLockDir:e},r===`released`?`[start] predecessor server finished draining — proceeding`:`[start] predecessor server still draining after wait — proceeding to collide`)}let L=await _({config:t,contentDir:j,projectDir:E?D:n,contentRoot:E?void 0:t.content.dir,port:e.port,host:o,...e.enableRemote===!0?{enableRemote:!0}:{},quiet:!1,detectGh:l,tokenStore:F,embeddingsKeyStore:I,...E?{ephemeral:!0,singleDocRelPath:A,gitEnabled:!1,gitPreflight:()=>({ok:!0,version:`0.0.0`,resolvedPath:`git`,source:`PATH`})}:{},localOpCliArgs:[process.execPath,process.argv[1]],probeHarnessManagedMcpEntry:(e,t)=>u(e,t),attachUiSibling:P,idleShutdownMs:f,skipAutoInit:!0,...P?{spawnUiSiblingFn:ee}:{},idleShutdownHandler:t=>{let n=oe({readUiLock:()=>b(L.lockDir),spawnedUiPid:()=>N,isAlive:y,killPid:(e,t)=>{process.kill(e,t)},destroy:t,log:w});return ae(E?ie(n,D):n,{log:w,exit:e.idleExit})},log:w,...e.serveContentAssets===void 0?{}:{serveContentAssets:e.serveContentAssets},...e.reactShellDistDir?{reactShellDistDir:e.reactShellDistDir}:{}});M||={action:`skip`,reason:`alive`,pid:0,port:0};let R=M,z=null;if(R.action===`skip`)z=R.port>0?R.port:null;else if(!d){let t=e.uiBindTimeoutMs??3e3;z=await Z({readUiLock:()=>b(L.lockDir),now:Date.now,sleep:e=>T(e),timeoutMs:t,pollIntervalMs:50}),z===null&&w.warn({timeoutMs:t},`[start] ok ui did not bind within timeout — banner falls back to API URL`)}return{httpServer:L.httpServer,destroy:L.destroy,lockDir:L.lockDir,contentDir:j,port:L.port,ready:L.ready,degraded:L.degraded,uiSpawnDecision:M,spawnedUiPid:N,resolvedUiPort:z}}function ce(e){if(e===`browser`||e===`app`)return e;throw new s(`--mode must be 'browser' or 'app'`)}function le(e){let t=Number.parseInt(e,10);if(Number.isNaN(t)||t<1||t>65535)throw new s(`--ui-port must be a port number between 1 and 65535`);return t}function ue(e){return e.OK_CONSOLE_LEVEL!==void 0||e.LOG_LEVEL!==void 0?null:`warn`}function $(e){let t=[`Stopping OpenKnowledge…`,`Saving pending changes and releasing the server lock — this can take a few seconds.`];return e===`SIGINT`&&t.push(`Press Ctrl+C again to force quit.`),t}async function de(e,t){let n=ue(process.env);n!==null&&(process.env.OK_CONSOLE_LEVEL=n);let{renderBanner:r}=await import(`./banner--DGfdMN8.mjs`),{accent:i,dim:a,error:o,warning:s}=await import(`./colors-MGDi6UGf.mjs`),c=process.cwd(),l=t.remote!==void 0&&t.remote!==!1,u=typeof t.remote==`string`?t.remote:void 0,f=u===void 0?e:{...e,remote:{...e.remote,url:u}};process.title=U(c),l&&(typeof f.remote?.url!=`string`||f.remote.url===``)&&(console.error(o("--remote requires a public tunnel URL — pass it (`ok start --remote https://<your-tunnel-host>`) or set remote.url in .ok/config.yml.")),process.exit(78)),l&&console.warn(s([``,`⚠ REMOTE ACCESS ENABLED — no server-side authentication.`,` Anyone who can reach ${f.remote?.url} has FULL control of this`,` knowledge base, including sync, publishing, credentials, and local operations.`,` Restrict who can reach it at the tunnel: ngrok OAuth, Cloudflare Access,`,` Tailscale ACLs, or equivalent edge auth.`,``].join(`
|
|
2
|
+
`)));let p=V(t,process.env),m=H(p,l);m.coerced&&console.warn(`remote access is enabled and ${p} is not an IPv4 loopback bind — tunnels proxy to 127.0.0.1, so binding ${p} would leave the tunnel dialing a dead port. Using 127.0.0.1.`);let h=m.host,_=t.port===void 0?void 0:Number(t.port),v=process.env.PORT?Number(process.env.PORT):void 0,b=t.uiPort===void 0?void 0:Number(t.uiPort);l&&_===void 0&&v!==void 0&&console.warn(`remote access is enabled — ignoring env PORT=${process.env.PORT}; the tunnel's port mapping targets the stable remote port (${f.remote?.port}). Pass --port to override deliberately.`);let x=q(_,v,b,l)??(l?f.remote?.port:void 0);if(b!==void 0){let{readServerLock:e,resolveLockDir:t}=await import(`./src-CIOr7Lie.mjs`);if(J(b,e(t(c)))){await X({cwd:c,uiPort:b});return}}let S=t.reactShellDistDir;if(l&&S===void 0){let e=import.meta.dirname??new URL(`.`,import.meta.url).pathname;S=[g(e,`public`),g(e,`../../app/dist`),g(e,`../../../app/dist`)].find(e=>y(e)),S===void 0&&console.warn(`remote access: bundled web UI not found — serving /mcp and /api only over the tunnel.`)}let C;try{C=await se({config:f,cwd:c,host:h,port:x,...b===void 0?{}:{uiPort:b},...t.serveContentAssets===void 0?{}:{serveContentAssets:t.serveContentAssets},...S?{reactShellDistDir:S}:{},...t.singleFile?{singleFile:t.singleFile}:{},...t.projectDir?{projectDir:t.projectDir}:{},...l?{enableRemote:!0}:{}})}catch(e){e instanceof W&&(console.error(o(e.message)),process.exit(1));let t=await import(`./src-CIOr7Lie.mjs`);if((e instanceof t.GitNotAvailableError||e instanceof t.GitTooOldError)&&process.exit(78),e instanceof t.RemoteConfigError&&(console.error(o(e.message)),process.exit(78)),(e instanceof t.SingleFileNotFoundError||e instanceof t.SingleFileNotAFileError||e instanceof t.SingleFileNotMarkdownError)&&(console.error(o(e.message)),process.exit(1)),b!==void 0&&fe(e,t)){await X({cwd:c,uiPort:b});return}let n=pe(e,c,t);n!==null&&(console.error(o(n)),process.exit(1)),console.error(`${o(`Failed to start:`)} ${e instanceof Error?e.stack??e.message:String(e)}`),process.exit(1)}let w=!1,T=async e=>{if(w)return;w=!0;let[t,...n]=$(e);console.log(i(`\n${t}`));for(let e of n)console.log(a(` ${e}`));if(C.spawnedUiPid!==null)try{let{getLogger:e,isProcessAlive:t,readUiLock:n}=await import(`./src-CIOr7Lie.mjs`);await Q({readUiLock:()=>n(C.lockDir),spawnedUiPid:()=>C.spawnedUiPid,isAlive:t,killPid:(e,t)=>process.kill(e,t),log:e(`start`),reason:`shutdown`})}catch(e){console.error(`${o(`ui sibling teardown failed:`)} ${e instanceof Error?e.stack??e.message:String(e)}`)}try{await C.destroy()}catch(e){console.error(`${o(`destroy() failed:`)} ${e instanceof Error?e.stack??e.message:String(e)}`),process.exitCode=1}process.exit(process.exitCode??0)};process.once(`SIGINT`,()=>{T(`SIGINT`)}),process.once(`SIGTERM`,()=>{T(`SIGTERM`)});let E=`http://${h}:${C.port}`,D=h===`0.0.0.0`||h===`::`?`http://0.0.0.0:${C.port}`:void 0,O=C.resolvedUiPort,k=O!==null&&O>0?`http://${h}:${O}`:E;console.log(r({name:`open-knowledge`,version:d,localUrl:k,apiUrl:k===E?void 0:E,networkUrl:D,nextSteps:[`Open the Editor URL in your browser to start editing.`]}));let A={"shadow-repo":`Version history and branch-switch safety unavailable`,"file-watcher":`External file changes will not sync to the editor`,"head-watcher":`Git branch switches may cause document inconsistency`};C.ready.then(async()=>{if(C.degraded.length>0){console.log();for(let e of C.degraded){let t=A[e]??`${e} (check server logs for details)`;console.warn(` ${s(`⚠`)} ${s(e)}: ${a(t)}`)}console.log()}if(t.open){let{openBrowser:e}=await import(`./open-browser-Blmbk-om.mjs`);e(k)}}).catch(e=>{console.error(` ${o(`Server initialization failed:`)} ${e instanceof Error?e.message:String(e)}`)})}function fe(e,t){let n=t.ServerLockCollisionError;return n!==void 0&&e instanceof n}function pe(e,t,n){let r=n.ServerLockCollisionError;if(r===void 0||!(e instanceof r))return null;try{let e=m(t,`.ok`),r=n.readServerLock(e);return r?r.kind===`interactive`?`OpenKnowledge desktop is currently running on this project. Quit it or use --cwd to point elsewhere.`:r.kind===`mcp-spawned`?"An MCP-spawned server holds this lock; it should release on idle-shutdown (~30 min). Or run `ok stop`.":"OpenKnowledge server is already running on this project — check `ok status` or `ok stop`.":"OpenKnowledge server is already running on this project — check `ok status` or `ok stop`."}catch{return null}}function me(e){return new o(`start`).description(`Start the knowledge base collab server`).option(`-p, --port <port>`,`Server port`,void 0).option(`--ui-port <port>`,`Pin the ok ui sibling to <port> and connect (not exit) if a server already runs here — the worktree-preview recipe path`,le).option(`-H, --host <host>`,`Server host`,void 0).option(`--open`,`Open browser after start`).option(`--mode <mode>`,`Force dispatch mode: 'browser' or 'app'`,ce).option(`--serve-content-assets`,`Serve content assets from this server (now the default; kept for compatibility)`).option(`--react-shell-dist-dir <path>`,`Serve React shell from <path> (suppresses ok ui sibling)`).option(`--single-file <path>`,`No-project ephemeral single-file mode: scope the server to one markdown file (git + MCP off)`).option(`--project-dir <dir>`,`Throwaway project root for --single-file (where ephemeral .ok/ state lives)`).option(`--remote [url]`,`Serve through a tunnel: admit requests carrying the tunnel Host with NO server-side auth (anyone who can reach the URL has full control — restrict access at the tunnel with edge auth). Bare --remote uses remote.url from .ok/config.yml; --remote <url> supplies it for this run.`).action(async t=>{let n=e();if(t.mode===`app`){t.open&&(process.stderr.write(`error: option '--mode=app' cannot be combined with '--open' (--open opens a browser tab against the local server, which app mode does not boot)
|
|
3
3
|
`),process.exit(2));let e=[];if(t.port!==void 0&&e.push(`--port`),t.uiPort!==void 0&&e.push(`--ui-port`),t.host!==void 0&&e.push(`--host`),e.length>0){let t=process.env.OK_LOG_LEVEL??`info`;(t===`debug`||t===`trace`)&&console.error(`--mode=app: ignoring ${e.join(`, `)}`)}let n=I(A());if(n.available){L({spawn:f},n);return}console.error(R(n.reason)),process.exit(1)}await de(n,t)})}export{B as C,D,L as E,ae as S,I as T,K as _,H as a,pe as b,G as c,fe as d,q as f,J as g,de as h,oe as i,U as l,ue as m,Z as n,Y as o,V as p,se as r,X as s,W as t,$ as u,me as v,A as w,ie as x,Q as y};
|
|
4
|
-
//# sourceMappingURL=start-
|
|
4
|
+
//# sourceMappingURL=start-Brg7Qf35.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{p as e,r as t,v as n}from"./start-Brg7Qf35.mjs";export{t as bootStartServer,e as resolveHost,n as startCommand};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{i as e,o as t,t as n}from"./chunk-DTipWd-i.mjs";import{Ga as r,Ha as i,Pa as a,Va as o}from"./src-
|
|
1
|
+
import{i as e,o as t,t as n}from"./chunk-DTipWd-i.mjs";import{Ga as r,Ha as i,Pa as a,Va as o}from"./src-jbLmpusB.mjs";import{dr as s,gr as c,hr as l,jr as u}from"./src-B0klb50O.mjs";import{basename as d,dirname as f,isAbsolute as p,join as m,posix as h,relative as g,resolve as _,sep as v,win32 as y}from"node:path";import{cpSync as ee,existsSync as b,lstatSync as x,mkdirSync as te,readFileSync as ne,readdirSync as re,realpathSync as S,rmSync as C,rmdirSync as ie,statSync as ae}from"node:fs";import{homedir as w}from"node:os";var T=n((e=>{var t=class extends Error{constructor(e,t,n){super(n),Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name,this.code=t,this.exitCode=e,this.nestedError=void 0}},n=class extends t{constructor(e){super(1,`commander.invalidArgument`,e),Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name}};e.CommanderError=t,e.InvalidArgumentError=n})),E=n((e=>{let{InvalidArgumentError:t}=T();var n=class{constructor(e,t){switch(this.description=t||``,this.variadic=!1,this.parseArg=void 0,this.defaultValue=void 0,this.defaultValueDescription=void 0,this.argChoices=void 0,e[0]){case`<`:this.required=!0,this._name=e.slice(1,-1);break;case`[`:this.required=!1,this._name=e.slice(1,-1);break;default:this.required=!0,this._name=e;break}this._name.endsWith(`...`)&&(this.variadic=!0,this._name=this._name.slice(0,-3))}name(){return this._name}_collectValue(e,t){return t===this.defaultValue||!Array.isArray(t)?[e]:(t.push(e),t)}default(e,t){return this.defaultValue=e,this.defaultValueDescription=t,this}argParser(e){return this.parseArg=e,this}choices(e){return this.argChoices=e.slice(),this.parseArg=(e,n)=>{if(!this.argChoices.includes(e))throw new t(`Allowed choices are ${this.argChoices.join(`, `)}.`);return this.variadic?this._collectValue(e,n):e},this}argRequired(){return this.required=!0,this}argOptional(){return this.required=!1,this}};function r(e){let t=e.name()+(e.variadic===!0?`...`:``);return e.required?`<`+t+`>`:`[`+t+`]`}e.Argument=n,e.humanReadableArgName=r})),D=n((e=>{let{humanReadableArgName:t}=E();var n=class{constructor(){this.helpWidth=void 0,this.minWidthToWrap=40,this.sortSubcommands=!1,this.sortOptions=!1,this.showGlobalOptions=!1}prepareContext(e){this.helpWidth=this.helpWidth??e.helpWidth??80}visibleCommands(e){let t=e.commands.filter(e=>!e._hidden),n=e._getHelpCommand();return n&&!n._hidden&&t.push(n),this.sortSubcommands&&t.sort((e,t)=>e.name().localeCompare(t.name())),t}compareOptions(e,t){let n=e=>e.short?e.short.replace(/^-/,``):e.long.replace(/^--/,``);return n(e).localeCompare(n(t))}visibleOptions(e){let t=e.options.filter(e=>!e.hidden),n=e._getHelpOption();if(n&&!n.hidden){let r=n.short&&e._findOption(n.short),i=n.long&&e._findOption(n.long);!r&&!i?t.push(n):n.long&&!i?t.push(e.createOption(n.long,n.description)):n.short&&!r&&t.push(e.createOption(n.short,n.description))}return this.sortOptions&&t.sort(this.compareOptions),t}visibleGlobalOptions(e){if(!this.showGlobalOptions)return[];let t=[];for(let n=e.parent;n;n=n.parent){let e=n.options.filter(e=>!e.hidden);t.push(...e)}return this.sortOptions&&t.sort(this.compareOptions),t}visibleArguments(e){return e._argsDescription&&e.registeredArguments.forEach(t=>{t.description=t.description||e._argsDescription[t.name()]||``}),e.registeredArguments.find(e=>e.description)?e.registeredArguments:[]}subcommandTerm(e){let n=e.registeredArguments.map(e=>t(e)).join(` `);return e._name+(e._aliases[0]?`|`+e._aliases[0]:``)+(e.options.length?` [options]`:``)+(n?` `+n:``)}optionTerm(e){return e.flags}argumentTerm(e){return e.name()}longestSubcommandTermLength(e,t){return t.visibleCommands(e).reduce((e,n)=>Math.max(e,this.displayWidth(t.styleSubcommandTerm(t.subcommandTerm(n)))),0)}longestOptionTermLength(e,t){return t.visibleOptions(e).reduce((e,n)=>Math.max(e,this.displayWidth(t.styleOptionTerm(t.optionTerm(n)))),0)}longestGlobalOptionTermLength(e,t){return t.visibleGlobalOptions(e).reduce((e,n)=>Math.max(e,this.displayWidth(t.styleOptionTerm(t.optionTerm(n)))),0)}longestArgumentTermLength(e,t){return t.visibleArguments(e).reduce((e,n)=>Math.max(e,this.displayWidth(t.styleArgumentTerm(t.argumentTerm(n)))),0)}commandUsage(e){let t=e._name;e._aliases[0]&&(t=t+`|`+e._aliases[0]);let n=``;for(let t=e.parent;t;t=t.parent)n=t.name()+` `+n;return n+t+` `+e.usage()}commandDescription(e){return e.description()}subcommandDescription(e){return e.summary()||e.description()}optionDescription(e){let t=[];if(e.argChoices&&t.push(`choices: ${e.argChoices.map(e=>JSON.stringify(e)).join(`, `)}`),e.defaultValue!==void 0&&(e.required||e.optional||e.isBoolean()&&typeof e.defaultValue==`boolean`)&&t.push(`default: ${e.defaultValueDescription||JSON.stringify(e.defaultValue)}`),e.presetArg!==void 0&&e.optional&&t.push(`preset: ${JSON.stringify(e.presetArg)}`),e.envVar!==void 0&&t.push(`env: ${e.envVar}`),t.length>0){let n=`(${t.join(`, `)})`;return e.description?`${e.description} ${n}`:n}return e.description}argumentDescription(e){let t=[];if(e.argChoices&&t.push(`choices: ${e.argChoices.map(e=>JSON.stringify(e)).join(`, `)}`),e.defaultValue!==void 0&&t.push(`default: ${e.defaultValueDescription||JSON.stringify(e.defaultValue)}`),t.length>0){let n=`(${t.join(`, `)})`;return e.description?`${e.description} ${n}`:n}return e.description}formatItemList(e,t,n){return t.length===0?[]:[n.styleTitle(e),...t,``]}groupItems(e,t,n){let r=new Map;return e.forEach(e=>{let t=n(e);r.has(t)||r.set(t,[])}),t.forEach(e=>{let t=n(e);r.has(t)||r.set(t,[]),r.get(t).push(e)}),r}formatHelp(e,t){let n=t.padWidth(e,t),r=t.helpWidth??80;function i(e,r){return t.formatItem(e,n,r,t)}let a=[`${t.styleTitle(`Usage:`)} ${t.styleUsage(t.commandUsage(e))}`,``],o=t.commandDescription(e);o.length>0&&(a=a.concat([t.boxWrap(t.styleCommandDescription(o),r),``]));let s=t.visibleArguments(e).map(e=>i(t.styleArgumentTerm(t.argumentTerm(e)),t.styleArgumentDescription(t.argumentDescription(e))));if(a=a.concat(this.formatItemList(`Arguments:`,s,t)),this.groupItems(e.options,t.visibleOptions(e),e=>e.helpGroupHeading??`Options:`).forEach((e,n)=>{let r=e.map(e=>i(t.styleOptionTerm(t.optionTerm(e)),t.styleOptionDescription(t.optionDescription(e))));a=a.concat(this.formatItemList(n,r,t))}),t.showGlobalOptions){let n=t.visibleGlobalOptions(e).map(e=>i(t.styleOptionTerm(t.optionTerm(e)),t.styleOptionDescription(t.optionDescription(e))));a=a.concat(this.formatItemList(`Global Options:`,n,t))}return this.groupItems(e.commands,t.visibleCommands(e),e=>e.helpGroup()||`Commands:`).forEach((e,n)=>{let r=e.map(e=>i(t.styleSubcommandTerm(t.subcommandTerm(e)),t.styleSubcommandDescription(t.subcommandDescription(e))));a=a.concat(this.formatItemList(n,r,t))}),a.join(`
|
|
2
2
|
`)}displayWidth(e){return r(e).length}styleTitle(e){return e}styleUsage(e){return e.split(` `).map(e=>e===`[options]`?this.styleOptionText(e):e===`[command]`?this.styleSubcommandText(e):e[0]===`[`||e[0]===`<`?this.styleArgumentText(e):this.styleCommandText(e)).join(` `)}styleCommandDescription(e){return this.styleDescriptionText(e)}styleOptionDescription(e){return this.styleDescriptionText(e)}styleSubcommandDescription(e){return this.styleDescriptionText(e)}styleArgumentDescription(e){return this.styleDescriptionText(e)}styleDescriptionText(e){return e}styleOptionTerm(e){return this.styleOptionText(e)}styleSubcommandTerm(e){return e.split(` `).map(e=>e===`[options]`?this.styleOptionText(e):e[0]===`[`||e[0]===`<`?this.styleArgumentText(e):this.styleSubcommandText(e)).join(` `)}styleArgumentTerm(e){return this.styleArgumentText(e)}styleOptionText(e){return e}styleArgumentText(e){return e}styleSubcommandText(e){return e}styleCommandText(e){return e}padWidth(e,t){return Math.max(t.longestOptionTermLength(e,t),t.longestGlobalOptionTermLength(e,t),t.longestSubcommandTermLength(e,t),t.longestArgumentTermLength(e,t))}preformatted(e){return/\n[^\S\r\n]/.test(e)}formatItem(e,t,n,r){let i=` `.repeat(2);if(!n)return i+e;let a=e.padEnd(t+e.length-r.displayWidth(e)),o=(this.helpWidth??80)-t-2-2,s;return s=o<this.minWidthToWrap||r.preformatted(n)?n:r.boxWrap(n,o).replace(/\n/g,`
|
|
3
3
|
`+` `.repeat(t+2)),i+a+` `.repeat(2)+s.replace(/\n/g,`\n${i}`)}boxWrap(e,t){if(t<this.minWidthToWrap)return e;let n=e.split(/\r\n|\n/),r=/[\s]*[^\s]+/g,i=[];return n.forEach(e=>{let n=e.match(r);if(n===null){i.push(``);return}let a=[n.shift()],o=this.displayWidth(a[0]);n.forEach(e=>{let n=this.displayWidth(e);if(o+n<=t){a.push(e),o+=n;return}i.push(a.join(``));let r=e.trimStart();a=[r],o=this.displayWidth(r)}),i.push(a.join(``))}),i.join(`
|
|
4
4
|
`)}};function r(e){return e.replace(/\x1b\[\d*(;\d*)*m/g,``)}e.Help=n,e.stripColor=r})),O=n((e=>{let{InvalidArgumentError:t}=T();var n=class{constructor(e,t){this.flags=e,this.description=t||``,this.required=e.includes(`<`),this.optional=e.includes(`[`),this.variadic=/\w\.\.\.[>\]]$/.test(e),this.mandatory=!1;let n=a(e);this.short=n.shortFlag,this.long=n.longFlag,this.negate=!1,this.long&&(this.negate=this.long.startsWith(`--no-`)),this.defaultValue=void 0,this.defaultValueDescription=void 0,this.presetArg=void 0,this.envVar=void 0,this.parseArg=void 0,this.hidden=!1,this.argChoices=void 0,this.conflictsWith=[],this.implied=void 0,this.helpGroupHeading=void 0}default(e,t){return this.defaultValue=e,this.defaultValueDescription=t,this}preset(e){return this.presetArg=e,this}conflicts(e){return this.conflictsWith=this.conflictsWith.concat(e),this}implies(e){let t=e;return typeof e==`string`&&(t={[e]:!0}),this.implied=Object.assign(this.implied||{},t),this}env(e){return this.envVar=e,this}argParser(e){return this.parseArg=e,this}makeOptionMandatory(e=!0){return this.mandatory=!!e,this}hideHelp(e=!0){return this.hidden=!!e,this}_collectValue(e,t){return t===this.defaultValue||!Array.isArray(t)?[e]:(t.push(e),t)}choices(e){return this.argChoices=e.slice(),this.parseArg=(e,n)=>{if(!this.argChoices.includes(e))throw new t(`Allowed choices are ${this.argChoices.join(`, `)}.`);return this.variadic?this._collectValue(e,n):e},this}name(){return this.long?this.long.replace(/^--/,``):this.short.replace(/^-/,``)}attributeName(){return this.negate?i(this.name().replace(/^no-/,``)):i(this.name())}helpGroup(e){return this.helpGroupHeading=e,this}is(e){return this.short===e||this.long===e}isBoolean(){return!this.required&&!this.optional&&!this.negate}},r=class{constructor(e){this.positiveOptions=new Map,this.negativeOptions=new Map,this.dualOptions=new Set,e.forEach(e=>{e.negate?this.negativeOptions.set(e.attributeName(),e):this.positiveOptions.set(e.attributeName(),e)}),this.negativeOptions.forEach((e,t)=>{this.positiveOptions.has(t)&&this.dualOptions.add(t)})}valueFromOption(e,t){let n=t.attributeName();if(!this.dualOptions.has(n))return!0;let r=this.negativeOptions.get(n).presetArg,i=r===void 0?!1:r;return t.negate===(i===e)}};function i(e){return e.split(`-`).reduce((e,t)=>e+t[0].toUpperCase()+t.slice(1))}function a(e){let t,n,r=/^-[^-]$/,i=/^--[^-]/,a=e.split(/[ |,]+/).concat(`guard`);if(r.test(a[0])&&(t=a.shift()),i.test(a[0])&&(n=a.shift()),!t&&r.test(a[0])&&(t=a.shift()),!t&&i.test(a[0])&&(t=n,n=a.shift()),a[0].startsWith(`-`)){let t=a[0],n=`option creation failed due to '${t}' in option flags '${e}'`;throw/^-[^-][^-]/.test(t)?Error(`${n}
|
|
@@ -52,5 +52,5 @@ foreach ($d in $dirs) {
|
|
|
52
52
|
if (Test-Path -LiteralPath $probe -PathType Leaf) { & $probe -y '@inkeep/open-knowledge@latest' mcp; exit $LASTEXITCODE }
|
|
53
53
|
}
|
|
54
54
|
[Console]::Error.WriteLine('OpenKnowledge: install Node.js 24+ (npm i -g @inkeep/open-knowledge), then restart your editor')
|
|
55
|
-
exit 127`,I=`// ok-pi-bridge`,L=`${I}-v1`,ye=`ok-pi-managed-extension`;function be(e){if(typeof e!=`object`||!e)return!1;let t=e;if(t.command===`/bin/sh`){if(!Array.isArray(t.args)||t.args[0]!==`-l`||t.args[1]!==`-c`)return!1;let e=t.args[2];return typeof e==`string`&&e.includes(`# ok-mcp-v2`)}if(t.command===`powershell`){if(!Array.isArray(t.args)||t.args[0]!==`-NoProfile`||t.args[1]!==`-NonInteractive`||t.args[2]!==`-Command`)return!1;let e=t.args[3];return typeof e==`string`&&e.includes(`# ok-mcp-win-v1`)}if(t.type===`local`&&Array.isArray(t.command)){if(t.command[0]===`/bin/sh`){if(t.command[1]!==`-l`||t.command[2]!==`-c`)return!1;let e=t.command[3];return typeof e==`string`&&e.includes(`# ok-mcp-v2`)}if(t.command[0]===`powershell`){if(t.command[1]!==`-NoProfile`||t.command[2]!==`-NonInteractive`||t.command[3]!==`-Command`)return!1;let e=t.command[4];return typeof e==`string`&&e.includes(`# ok-mcp-win-v1`)}return!1}if(t.command===`ok-pi-managed-extension`){if(!Array.isArray(t.args))return!1;let e=t.args[0];return typeof e==`string`&&e.startsWith(L)}return!1}function R(e=process.argv[1]){if(!e)throw Error(`Cannot infer the local CLI entry for --dev-mcp because process.argv[1] is empty.`);let t=_(e);if(d(t)===`cli.mjs`&&d(f(t))===`dist`)return t;let n=t.split(v),r=n.lastIndexOf(`packages`);if(r===-1||n[r+1]!==`cli`)throw Error(`Cannot infer the repo root for --dev-mcp from ${t}. Run the local CLI from this repo so the built dist path can be derived.`);let i=n.slice(0,r);return m(i.length===0?v:i.join(v),`packages`,`cli`,`dist`,`cli.mjs`)}function z(e={}){return e.mode===`dev`?{command:M,args:[R(),`mcp`],env:{...N}}:(e.platformName??process.platform)===`win32`?{command:`powershell`,args:[`-NoProfile`,`-NonInteractive`,`-Command`,F]}:{command:`/bin/sh`,args:[`-l`,`-c`,P]}}function xe(e={}){return e.mode===`dev`?{type:`local`,enabled:!0,command:[M,R(),`mcp`],environment:{...N}}:(e.platformName??process.platform)===`win32`?{type:`local`,enabled:!0,command:[`powershell`,`-NoProfile`,`-NonInteractive`,`-Command`,F]}:{type:`local`,enabled:!0,command:[`/bin/sh`,`-l`,`-c`,P]}}function Se(e){if(typeof e!=`object`||!e)return!1;let t=e;return B(t,z({mode:`published`,platformName:`darwin`}))||B(t,z({mode:`published`,platformName:`win32`}))}function B(e,t){return Object.keys(e).length===Object.keys(t).length?Ce(e,t):!1}function Ce(e,t){if(e.command!==t.command)return!1;let n=t.args;return!Array.isArray(n)||!Array.isArray(e.args)||e.args.length!==n.length?!1:e.args.every((e,t)=>e===n[t])}function V(e,t){let n=e=>typeof e==`string`&&e.includes(`# ok-mcp`);return t===`/bin/sh`?e[0]===`-l`&&e[1]===`-c`&&n(e[2]):t===`powershell`?e[0]===`-NoProfile`&&e[1]===`-NonInteractive`&&e[2]===`-Command`&&n(e[3]):!1}function we(e){if(typeof e!=`object`||!e)return!1;let t=e;return t.enabled===!1||typeof t.command!=`string`||!Array.isArray(t.args)?!1:V(t.args,t.command)}function Te(e){if(typeof e!=`object`||!e)return!1;let t=e;if(t.type!==`local`||t.enabled===!1||!Array.isArray(t.command))return!1;let[n,...r]=t.command;return typeof n==`string`&&V(r,n)}function H(e){return e===`win32`?y:h}function Ee(e={}){let t=e.platformName??process.platform,n=e.home??w(),r=e.env??process.env,i=H(t);return t===`darwin`?i.join(n,`Library`,`Application Support`):t===`win32`?r.APPDATA??i.join(n,`AppData`,`Roaming`):r.XDG_CONFIG_HOME??i.join(n,`.config`)}function De(e={}){let t=e.platformName??process.platform,n=e.home??w();return H(t).join(n,`.claude.json`)}function U(e={}){let t=e.platformName??process.platform,n=e.home??w(),r=e.env??process.env;if(t===`darwin`)return h.join(n,`Library`,`Application Support`,`Claude`,`claude_desktop_config.json`);if(t===`win32`){let e=r.APPDATA??y.join(n,`AppData`,`Roaming`);return y.join(e,`Claude`,`claude_desktop_config.json`)}throw Error(`Claude Desktop is not available on ${t}. Supported: macOS, Windows.`)}function W(e={}){let t=e.platformName??process.platform,n=e.home??w();return H(t).join(n,`.cursor`,`mcp.json`)}function Oe(e={}){let t=e.platformName??process.platform,n=e.home??w();return(e.env??process.env).CODEX_HOME??H(t).join(n,`.codex`)}function G(e={}){return H(e.platformName??process.platform).join(Oe(e),`config.toml`)}function K(e={}){let t=e.platformName??process.platform,n=e.home??w(),r=(e.env??process.env).COPILOT_HOME??H(t).join(n,`.copilot`);return H(t).join(r,`mcp-config.json`)}function ke(e={}){let t=e.platformName??process.platform,n=e.home??w(),r=e.env??process.env,i=H(t);if(t===`win32`){let e=r.APPDATA??i.join(n,`AppData`,`Roaming`);return i.join(e,`opencode`)}let a=r.XDG_CONFIG_HOME??i.join(n,`.config`);return i.join(a,`opencode`)}function q(e={}){return H(e.platformName??process.platform).join(ke(e),`opencode.json`)}function Ae(e={}){let t=e.platformName??process.platform,n=e.home??w();return H(t).join(n,`.openclaw`,`openclaw.json`)}function je(e={}){let t=e.platformName??process.platform,n=e.home??w();return H(t).join(n,`.hermes`,`config.yaml`)}function Me(e={}){let t=e.platformName??process.platform,n=e.home??w();return(e.env??process.env).PI_CODING_AGENT_DIR??H(t).join(n,`.pi`,`agent`)}function Ne(e={}){let t=e.platformName??process.platform,n=e.home??w();return H(t).join(n,`.gemini`,`config`,`mcp_config.json`)}function Pe(e,t){let n=H(t),r=n.join(e,`.lmstudio`,`mcp.json`),i=n.join(e,`.cache`,`lm-studio`,`mcp.json`);return t===`darwin`?[i,r]:[r,i]}function J(e={}){let t=e.platformName??process.platform,n=Pe(e.home??w(),t);return n.find(e=>b(e))||n.find(e=>b(f(e)))||n[0]}const Y={claude:{id:`claude`,label:A.claude,configPath:(e,t)=>De({home:t}),format:`json`,topLevelKey:`mcpServers`,serverName:()=>a,buildEntry:(e,t)=>z(t),scope:`global`,detectPath:(e,t)=>m(t??w(),`.claude`),projectConfigPath:e=>m(e,`.mcp.json`),projectSkillPath:e=>m(e,`.claude`,`skills`,`open-knowledge`,`SKILL.md`)},"claude-desktop":{id:`claude-desktop`,label:A[`claude-desktop`],configPath:(e,t)=>U({home:t}),format:`json`,topLevelKey:`mcpServers`,serverName:()=>a,buildEntry:(e,t)=>z(t),scope:`global`,detectPath:(e,t)=>f(U({home:t}))},cursor:{id:`cursor`,label:A.cursor,configPath:(e,t)=>W({home:t}),format:`json`,topLevelKey:`mcpServers`,serverName:()=>a,buildEntry:(e,t)=>z(t),scope:`global`,detectPath:(e,t)=>f(W({home:t})),projectConfigPath:e=>m(e,`.cursor`,`mcp.json`),projectSkillPath:e=>m(e,`.cursor`,`skills`,`open-knowledge`,`SKILL.md`)},codex:{id:`codex`,label:A.codex,configPath:(e,t)=>G({home:t}),format:`toml`,topLevelKey:`mcp_servers`,serverName:()=>a,buildEntry:(e,t)=>z(t),scope:`global`,detectPath:(e,t)=>f(G({home:t})),projectConfigPath:e=>m(e,`.codex`,`config.toml`),projectSkillPath:e=>m(e,`.codex`,`skills`,`open-knowledge`,`SKILL.md`)},copilot:{id:`copilot`,label:A.copilot,configPath:(e,t)=>K({home:t}),format:`json`,topLevelKey:`mcpServers`,serverName:()=>a,buildEntry:(e,t)=>z(t),scope:`global`,detectPath:(e,t)=>f(K({home:t})),projectSkillPath:e=>m(e,`.github`,`skills`,`open-knowledge`,`SKILL.md`)},opencode:{id:`opencode`,label:A.opencode,configPath:(e,t)=>q({home:t}),format:`json`,topLevelKey:`mcp`,serverName:()=>a,buildEntry:(e,t)=>xe(t),scope:`global`,detectPath:(e,t)=>f(q({home:t})),projectConfigPath:e=>m(e,`opencode.json`),projectSkillPath:e=>m(e,`.opencode`,`skills`,`open-knowledge`,`SKILL.md`)},openclaw:{id:`openclaw`,label:A.openclaw,configPath:(e,t)=>Ae({home:t}),format:`json`,topLevelKey:`mcp`,serverMapSubKey:`servers`,serverName:()=>a,buildEntry:(e,t)=>z(t),scope:`global`,detectPath:(e,t)=>m(t??w(),`.openclaw`),offerOnlyWhenDetected:!0},pi:{id:`pi`,label:A.pi,configPath:()=>{throw Error("Pi has no user-global MCP config; OK's integration is the project-scoped bridge extension at .pi/extensions/open-knowledge.ts (run `ok init` in the project).")},format:`file`,topLevelKey:`mcpServers`,serverName:()=>a,buildEntry:()=>{throw Error(`Pi has no MCP entry shape; the managed bridge file is built by buildPiExtensionSource (integrations/pi-extension.ts).`)},scope:`project`,detectPath:(e,t)=>Me({home:t}),projectConfigPath:e=>m(e,`.pi`,`extensions`,`open-knowledge.ts`),projectSkillPath:e=>m(e,`.pi`,`skills`,`open-knowledge`,`SKILL.md`)},antigravity:{id:`antigravity`,label:A.antigravity,configPath:(e,t)=>Ne({home:t}),format:`json`,topLevelKey:`mcpServers`,serverName:()=>a,buildEntry:(e,t)=>z(t),scope:`global`,detectPath:(e,t)=>m(t??w(),`.gemini`),offerOnlyWhenDetected:!0},"lm-studio":{id:`lm-studio`,label:A[`lm-studio`],configPath:(e,t)=>J({home:t}),format:`json`,topLevelKey:`mcpServers`,serverName:()=>a,buildEntry:(e,t)=>z(t),scope:`global`,detectPath:(e,t)=>f(J({home:t})),offerOnlyWhenDetected:!0},hermes:{id:`hermes`,label:A.hermes,configPath:(e,t)=>je({home:t}),format:`yaml`,topLevelKey:`mcp_servers`,serverName:()=>a,buildEntry:(e,t)=>z(t),scope:`global`,detectPath:(e,t)=>m(t??w(),`.hermes`),offerOnlyWhenDetected:!0}};function Fe(e){let t=e.filter(e=>!Object.hasOwn(Y,e));if(t.length>0)throw Error(`Unknown editor(s): ${t.join(`, `)}. Valid options: ${k.join(`, `)}`);return e.map(e=>Y[e])}const Ie=[{hostDir:`.adal`,pruneRoot:`.adal`},{hostDir:`.aider-desk`,pruneRoot:`.aider-desk`},{hostDir:`.astrbot/data`,pruneRoot:`.astrbot`},{hostDir:`.augment`,pruneRoot:`.augment`},{hostDir:`.autohand`,pruneRoot:`.autohand`},{hostDir:`.bob`,pruneRoot:`.bob`},{hostDir:`.codeartsdoer`,pruneRoot:`.codeartsdoer`},{hostDir:`.codebuddy`,pruneRoot:`.codebuddy`},{hostDir:`.codeium/windsurf`,pruneRoot:`.codeium`},{hostDir:`.codemaker`,pruneRoot:`.codemaker`},{hostDir:`.codestudio`,pruneRoot:`.codestudio`},{hostDir:`.commandcode`,pruneRoot:`.commandcode`},{hostDir:`.config/crush`,pruneRoot:`.config/crush`},{hostDir:`.config/devin`,pruneRoot:`.config/devin`},{hostDir:`.config/goose`,pruneRoot:`.config/goose`},{hostDir:`.config/kimchi/harness`,pruneRoot:`.config/kimchi`},{hostDir:`.continue`,pruneRoot:`.continue`},{hostDir:`.factory`,pruneRoot:`.factory`},{hostDir:`.forge`,pruneRoot:`.forge`},{hostDir:`.grok`,pruneRoot:`.grok`},{hostDir:`.iflow`,pruneRoot:`.iflow`},{hostDir:`.inferencesh`,pruneRoot:`.inferencesh`},{hostDir:`.jazz`,pruneRoot:`.jazz`},{hostDir:`.junie`,pruneRoot:`.junie`},{hostDir:`.kilocode`,pruneRoot:`.kilocode`},{hostDir:`.kiro`,pruneRoot:`.kiro`},{hostDir:`.kode`,pruneRoot:`.kode`},{hostDir:`.lingma`,pruneRoot:`.lingma`},{hostDir:`.mcpjam`,pruneRoot:`.mcpjam`},{hostDir:`.moxby`,pruneRoot:`.moxby`},{hostDir:`.mux`,pruneRoot:`.mux`},{hostDir:`.neovate`,pruneRoot:`.neovate`},{hostDir:`.ona`,pruneRoot:`.ona`},{hostDir:`.openhands`,pruneRoot:`.openhands`},{hostDir:`.pochi`,pruneRoot:`.pochi`},{hostDir:`.qoder`,pruneRoot:`.qoder`},{hostDir:`.qoder-cn`,pruneRoot:`.qoder-cn`},{hostDir:`.qwen`,pruneRoot:`.qwen`},{hostDir:`.reasonix`,pruneRoot:`.reasonix`},{hostDir:`.roo`,pruneRoot:`.roo`},{hostDir:`.rovodev`,pruneRoot:`.rovodev`},{hostDir:`.snowflake/cortex`,pruneRoot:`.snowflake`},{hostDir:`.tabnine/agent`,pruneRoot:`.tabnine`},{hostDir:`.terramind`,pruneRoot:`.terramind`},{hostDir:`.tinycloud`,pruneRoot:`.tinycloud`},{hostDir:`.trae`,pruneRoot:`.trae`},{hostDir:`.trae-cn`,pruneRoot:`.trae-cn`},{hostDir:`.vibe`,pruneRoot:`.vibe`},{hostDir:`.zcode`,pruneRoot:`.zcode`},{hostDir:`.zencoder`,pruneRoot:`.zencoder`}],Le=[...c.map(e=>l[e]),`open-knowledge`];function X(e){if(!p(e))throw Error(`skill cleanup requires an absolute home directory; got ${JSON.stringify(e)}`);let t=_(e);if(t===v||f(t)===t)throw Error(`skill cleanup refuses to operate on the filesystem root (${t})`);return t}function Z(e,t){let n=g(e,t);if(n.startsWith(`..`)||p(n))return!1;let r=e;for(let e of n.split(v)){r=m(r,e);try{if(!x(r).isDirectory())return!1}catch{return!1}}return!0}function Re(e,t){try{return re(e).every(n=>t.has(m(e,n)))}catch{return!1}}function ze(e){let t=X(e),n=[],r=[],i=new Set;for(let e of Ie){let a=m(t,e.hostDir,`skills`);if(!Z(t,a))continue;let o=Le.map(e=>m(a,e)).filter(e=>b(e));n.push(...o);for(let e of o)i.add(e);let s=m(t,e.pruneRoot),c=a;for(;Re(c,i)&&(r.push(c),i.add(c),c!==s);){let e=f(c);if(e===c||e===t||!e.startsWith(t+v))break;c=e}}return{skillDirs:n,emptyDirs:r}}function Be(e){try{if(!x(e).isDirectory())return!1;let t=re(e);return t.length===0||t.includes(`SKILL.md`)}catch{return!1}}function Ve(e){let t=new Set,n=new Set;for(let r of Ie){let i=m(e,r.hostDir,`skills`);for(let e of Le)t.add(m(i,e));let a=m(e,r.pruneRoot),o=i;for(;n.add(o),o!==a;){let t=f(o);if(t===o||t===e||!t.startsWith(e+v))break;o=t}}return{skillDirs:t,emptyDirs:n}}function He(e,t){let n=X(e),r=Ve(n),i=[...t.skillDirs.filter(e=>!r.skillDirs.has(e)),...t.emptyDirs.filter(e=>!r.emptyDirs.has(e))];if(i.length>0)throw Error(`refusing skill cleanup — ${i.length} path(s) outside the known legacy set: ${i.join(`, `)}`);let a=[];for(let e of t.skillDirs)if(Z(n,e)&&Be(e))try{C(e,{recursive:!0,force:!0}),a.push(e)}catch{}for(let e of t.emptyDirs)if(Z(n,e))try{ie(e),a.push(e)}catch{}return a}function Q(e){let t=X(e),n=[];for(let e of c){let r=l[e];n.push({path:m(t,`.agents`,`skills`,r),bundleId:e,scope:`central`});for(let i of j)n.push({path:m(t,i.hostDir,`skills`,r),bundleId:e,scope:`host`,hostDir:i.hostDir})}return n}function Ue(e,t){let n=[];for(let r of Q(e))if(r.bundleId===t)try{C(r.path,{recursive:!0,force:!0})}catch(e){n.push(e instanceof Error?e:Error(String(e)))}if(n.length>0)throw AggregateError(n,`Failed to remove ${n.length} path(s) for ${t}`)}function We(e,t){let n;try{n=x(e)}catch(e){if(e.code!==`ENOENT`)throw e}if(n?.isSymbolicLink())throw Error(`Refusing to write through a symbolic link at ${e}. Remove the symlink and re-run project setup.`);Ke(e,t)}function Ge(e,t){Ke(e,t)}function Ke(e,t){let n;try{n=S(t)}catch{n=_(t)}let r=f(e);for(;r.length>1&&r!==v;){let t;try{t=S(r)}catch(e){if(e.code===`ENOENT`){r=f(r);continue}throw e}let i=g(n,t);if(i===``||!i.startsWith(`..`)&&!p(i))return;throw Error(`Refusing to write at ${e}: ancestor ${r} resolves to ${t}, which is outside the project directory ${n}. A symbolic link in the path likely escapes the project. Remove the symlink and re-run project setup.`)}}function $(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function qe(e,t,n){try{if(ae(n).size>10485760)return!1}catch{return!1}let r;try{r=ne(n,`utf-8`)}catch{return!1}let i=[],a=s(r.charCodeAt(0)===65279?r.slice(1):r,i,{allowTrailingComma:!0,disallowComments:!1});if(i.length>0||!$(a))return!1;let o=a[e.topLevelKey];if(!$(o))return!1;let c=e.serverMapSubKey?o[e.serverMapSubKey]:o;return $(c)?$(c[e.serverName(t)]):!1}function Je(e,t,n={}){if(e.id!==`copilot`)return!0;try{return qe(e,t,e.configPath(t,n.home))}catch{return!1}}function Ye(e,t,n={}){let r=e.projectSkillPath?.(t);if(!r)return{editorId:e.id,label:e.label,action:`skipped-unsupported`,path:``};if(!Je(e,t,n))return{editorId:e.id,label:e.label,action:`skipped-prerequisite`,path:r};try{let n=u(`project`,{checkDesktop:!0}),i=f(r);We(i,t);let a=b(r)?`overwritten`:`written`;return C(i,{recursive:!0,force:!0}),te(f(i),{recursive:!0}),ee(n,i,{recursive:!0}),{editorId:e.id,label:e.label,action:a,path:r}}catch(t){return{editorId:e.id,label:e.label,action:`failed`,path:r,error:t instanceof Error?t.message:String(t)}}}function Xe(e,t){let n=e.projectSkillPath?.(t);if(!n)return{editorId:e.id,label:e.label,action:`skipped-unsupported`,path:``};try{let r=f(n);return b(n)?(Ge(r,t),C(r,{recursive:!0,force:!0}),{editorId:e.id,label:e.label,action:`removed`,path:n}):{editorId:e.id,label:e.label,action:`not-present`,path:n}}catch(t){return{editorId:e.id,label:e.label,action:`failed`,path:n,error:t instanceof Error?t.message:String(t)}}}export{he as C,Fe as S,_e as T,we as _,He as a,Te as b,Q as c,Y as d,j as f,z as g,ye as h,Ye as i,k as l,L as m,Ge as n,ze as o,I as p,Xe as r,Ue as s,We as t,A as u,be as v,pe as w,Ee as x,Se as y};
|
|
56
|
-
//# sourceMappingURL=write-project-skill-
|
|
55
|
+
exit 127`,I=`// ok-pi-bridge`,L=`${I}-v1`,ye=`ok-pi-managed-extension`;function be(e){if(typeof e!=`object`||!e)return!1;let t=e;if(t.command===`/bin/sh`){if(!Array.isArray(t.args)||t.args[0]!==`-l`||t.args[1]!==`-c`)return!1;let e=t.args[2];return typeof e==`string`&&e.includes(`# ok-mcp-v2`)}if(t.command===`powershell`){if(!Array.isArray(t.args)||t.args[0]!==`-NoProfile`||t.args[1]!==`-NonInteractive`||t.args[2]!==`-Command`)return!1;let e=t.args[3];return typeof e==`string`&&e.includes(`# ok-mcp-win-v1`)}if(t.type===`local`&&Array.isArray(t.command)){if(t.command[0]===`/bin/sh`){if(t.command[1]!==`-l`||t.command[2]!==`-c`)return!1;let e=t.command[3];return typeof e==`string`&&e.includes(`# ok-mcp-v2`)}if(t.command[0]===`powershell`){if(t.command[1]!==`-NoProfile`||t.command[2]!==`-NonInteractive`||t.command[3]!==`-Command`)return!1;let e=t.command[4];return typeof e==`string`&&e.includes(`# ok-mcp-win-v1`)}return!1}if(t.command===`ok-pi-managed-extension`){if(!Array.isArray(t.args))return!1;let e=t.args[0];return typeof e==`string`&&e.startsWith(L)}return!1}function R(e=process.argv[1]){if(!e)throw Error(`Cannot infer the local CLI entry for --dev-mcp because process.argv[1] is empty.`);let t=_(e);if(d(t)===`cli.mjs`&&d(f(t))===`dist`)return t;let n=t.split(v),r=n.lastIndexOf(`packages`);if(r===-1||n[r+1]!==`cli`)throw Error(`Cannot infer the repo root for --dev-mcp from ${t}. Run the local CLI from this repo so the built dist path can be derived.`);let i=n.slice(0,r);return m(i.length===0?v:i.join(v),`packages`,`cli`,`dist`,`cli.mjs`)}function z(e={}){return e.mode===`dev`?{command:M,args:[R(),`mcp`],env:{...N}}:(e.platformName??process.platform)===`win32`?{command:`powershell`,args:[`-NoProfile`,`-NonInteractive`,`-Command`,F]}:{command:`/bin/sh`,args:[`-l`,`-c`,P]}}function xe(e={}){return e.mode===`dev`?{type:`local`,enabled:!0,command:[M,R(),`mcp`],environment:{...N}}:(e.platformName??process.platform)===`win32`?{type:`local`,enabled:!0,command:[`powershell`,`-NoProfile`,`-NonInteractive`,`-Command`,F]}:{type:`local`,enabled:!0,command:[`/bin/sh`,`-l`,`-c`,P]}}function Se(e){if(typeof e!=`object`||!e)return!1;let t=e;return B(t,z({mode:`published`,platformName:`darwin`}))||B(t,z({mode:`published`,platformName:`win32`}))}function B(e,t){return Object.keys(e).length===Object.keys(t).length?Ce(e,t):!1}function Ce(e,t){if(e.command!==t.command)return!1;let n=t.args;return!Array.isArray(n)||!Array.isArray(e.args)||e.args.length!==n.length?!1:e.args.every((e,t)=>e===n[t])}function V(e,t){let n=e=>typeof e==`string`&&e.includes(`# ok-mcp`);return t===`/bin/sh`?e[0]===`-l`&&e[1]===`-c`&&n(e[2]):t===`powershell`?e[0]===`-NoProfile`&&e[1]===`-NonInteractive`&&e[2]===`-Command`&&n(e[3]):!1}function we(e){if(typeof e!=`object`||!e)return!1;let t=e;return t.enabled===!1||typeof t.command!=`string`||!Array.isArray(t.args)?!1:V(t.args,t.command)}function Te(e){if(typeof e!=`object`||!e)return!1;let t=e;if(t.type!==`local`||t.enabled===!1||!Array.isArray(t.command))return!1;let[n,...r]=t.command;return typeof n==`string`&&V(r,n)}function H(e){return e===`win32`?y:h}function Ee(e={}){let t=e.platformName??process.platform,n=e.home??w(),r=e.env??process.env,i=H(t);return t===`darwin`?i.join(n,`Library`,`Application Support`):t===`win32`?r.APPDATA??i.join(n,`AppData`,`Roaming`):r.XDG_CONFIG_HOME??i.join(n,`.config`)}function De(e={}){let t=e.platformName??process.platform,n=e.home??w();return H(t).join(n,`.claude.json`)}function U(e={}){let t=e.platformName??process.platform,n=e.home??w(),r=e.env??process.env;if(t===`darwin`)return h.join(n,`Library`,`Application Support`,`Claude`,`claude_desktop_config.json`);if(t===`win32`){let e=r.APPDATA??y.join(n,`AppData`,`Roaming`);return y.join(e,`Claude`,`claude_desktop_config.json`)}throw Error(`Claude Desktop is not available on ${t}. Supported: macOS, Windows.`)}function W(e={}){let t=e.platformName??process.platform,n=e.home??w();return H(t).join(n,`.cursor`,`mcp.json`)}function Oe(e={}){let t=e.platformName??process.platform,n=e.home??w();return(e.env??process.env).CODEX_HOME??H(t).join(n,`.codex`)}function G(e={}){return H(e.platformName??process.platform).join(Oe(e),`config.toml`)}function K(e={}){let t=e.platformName??process.platform,n=e.home??w(),r=(e.env??process.env).COPILOT_HOME??H(t).join(n,`.copilot`);return H(t).join(r,`mcp-config.json`)}function ke(e={}){let t=e.platformName??process.platform,n=e.home??w(),r=e.env??process.env,i=H(t);if(t===`win32`){let e=r.APPDATA??i.join(n,`AppData`,`Roaming`);return i.join(e,`opencode`)}let a=r.XDG_CONFIG_HOME??i.join(n,`.config`);return i.join(a,`opencode`)}function q(e={}){return H(e.platformName??process.platform).join(ke(e),`opencode.json`)}function Ae(e={}){let t=e.platformName??process.platform,n=e.home??w();return H(t).join(n,`.openclaw`,`openclaw.json`)}function je(e={}){let t=e.platformName??process.platform,n=e.home??w();return H(t).join(n,`.hermes`,`config.yaml`)}function Me(e={}){let t=e.platformName??process.platform,n=e.home??w();return(e.env??process.env).PI_CODING_AGENT_DIR??H(t).join(n,`.pi`,`agent`)}function Ne(e={}){let t=e.platformName??process.platform,n=e.home??w();return H(t).join(n,`.gemini`,`config`,`mcp_config.json`)}function Pe(e,t){let n=H(t),r=n.join(e,`.lmstudio`,`mcp.json`),i=n.join(e,`.cache`,`lm-studio`,`mcp.json`);return t===`darwin`?[i,r]:[r,i]}function J(e={}){let t=e.platformName??process.platform,n=Pe(e.home??w(),t);return n.find(e=>b(e))||n.find(e=>b(f(e)))||n[0]}const Y={claude:{id:`claude`,label:A.claude,configPath:(e,t)=>De({home:t}),format:`json`,topLevelKey:`mcpServers`,serverName:()=>a,buildEntry:(e,t)=>z(t),scope:`global`,detectPath:(e,t)=>m(t??w(),`.claude`),projectConfigPath:e=>m(e,`.mcp.json`),projectSkillPath:e=>m(e,`.claude`,`skills`,`open-knowledge`,`SKILL.md`)},"claude-desktop":{id:`claude-desktop`,label:A[`claude-desktop`],configPath:(e,t)=>U({home:t}),format:`json`,topLevelKey:`mcpServers`,serverName:()=>a,buildEntry:(e,t)=>z(t),scope:`global`,detectPath:(e,t)=>f(U({home:t}))},cursor:{id:`cursor`,label:A.cursor,configPath:(e,t)=>W({home:t}),format:`json`,topLevelKey:`mcpServers`,serverName:()=>a,buildEntry:(e,t)=>z(t),scope:`global`,detectPath:(e,t)=>f(W({home:t})),projectConfigPath:e=>m(e,`.cursor`,`mcp.json`),projectSkillPath:e=>m(e,`.cursor`,`skills`,`open-knowledge`,`SKILL.md`)},codex:{id:`codex`,label:A.codex,configPath:(e,t)=>G({home:t}),format:`toml`,topLevelKey:`mcp_servers`,serverName:()=>a,buildEntry:(e,t)=>z(t),scope:`global`,detectPath:(e,t)=>f(G({home:t})),projectConfigPath:e=>m(e,`.codex`,`config.toml`),projectSkillPath:e=>m(e,`.codex`,`skills`,`open-knowledge`,`SKILL.md`)},copilot:{id:`copilot`,label:A.copilot,configPath:(e,t)=>K({home:t}),format:`json`,topLevelKey:`mcpServers`,serverName:()=>a,buildEntry:(e,t)=>z(t),scope:`global`,detectPath:(e,t)=>f(K({home:t})),projectSkillPath:e=>m(e,`.github`,`skills`,`open-knowledge`,`SKILL.md`)},opencode:{id:`opencode`,label:A.opencode,configPath:(e,t)=>q({home:t}),format:`json`,topLevelKey:`mcp`,serverName:()=>a,buildEntry:(e,t)=>xe(t),scope:`global`,detectPath:(e,t)=>f(q({home:t})),projectConfigPath:e=>m(e,`opencode.json`),projectSkillPath:e=>m(e,`.opencode`,`skills`,`open-knowledge`,`SKILL.md`)},openclaw:{id:`openclaw`,label:A.openclaw,configPath:(e,t)=>Ae({home:t}),format:`json`,topLevelKey:`mcp`,serverMapSubKey:`servers`,serverName:()=>a,buildEntry:(e,t)=>z(t),scope:`global`,detectPath:(e,t)=>m(t??w(),`.openclaw`),offerOnlyWhenDetected:!0},pi:{id:`pi`,label:A.pi,configPath:()=>{throw Error("Pi has no user-global MCP config; OK's integration is the project-scoped bridge extension at .pi/extensions/open-knowledge.ts (run `ok init` in the project).")},format:`file`,topLevelKey:`mcpServers`,serverName:()=>a,buildEntry:()=>{throw Error(`Pi has no MCP entry shape; the managed bridge file is built by buildPiExtensionSource (integrations/pi-extension.ts).`)},scope:`project`,detectPath:(e,t)=>Me({home:t}),projectConfigPath:e=>m(e,`.pi`,`extensions`,`open-knowledge.ts`),projectSkillPath:e=>m(e,`.pi`,`skills`,`open-knowledge`,`SKILL.md`)},antigravity:{id:`antigravity`,label:A.antigravity,configPath:(e,t)=>Ne({home:t}),format:`json`,topLevelKey:`mcpServers`,serverName:()=>a,buildEntry:(e,t)=>z(t),scope:`global`,detectPath:(e,t)=>m(t??w(),`.gemini`),offerOnlyWhenDetected:!0},"lm-studio":{id:`lm-studio`,label:A[`lm-studio`],configPath:(e,t)=>J({home:t}),format:`json`,topLevelKey:`mcpServers`,serverName:()=>a,buildEntry:(e,t)=>z(t),scope:`global`,detectPath:(e,t)=>f(J({home:t})),offerOnlyWhenDetected:!0},hermes:{id:`hermes`,label:A.hermes,configPath:(e,t)=>je({home:t}),format:`yaml`,topLevelKey:`mcp_servers`,serverName:()=>a,buildEntry:(e,t)=>z(t),scope:`global`,detectPath:(e,t)=>m(t??w(),`.hermes`),offerOnlyWhenDetected:!0}};function Fe(e){let t=e.filter(e=>!Object.hasOwn(Y,e));if(t.length>0)throw Error(`Unknown editor(s): ${t.join(`, `)}. Valid options: ${k.join(`, `)}`);return e.map(e=>Y[e])}const Ie=[{hostDir:`.adal`,pruneRoot:`.adal`},{hostDir:`.aider-desk`,pruneRoot:`.aider-desk`},{hostDir:`.astrbot/data`,pruneRoot:`.astrbot`},{hostDir:`.augment`,pruneRoot:`.augment`},{hostDir:`.autohand`,pruneRoot:`.autohand`},{hostDir:`.bob`,pruneRoot:`.bob`},{hostDir:`.codeartsdoer`,pruneRoot:`.codeartsdoer`},{hostDir:`.codebuddy`,pruneRoot:`.codebuddy`},{hostDir:`.codeium/windsurf`,pruneRoot:`.codeium`},{hostDir:`.codemaker`,pruneRoot:`.codemaker`},{hostDir:`.codestudio`,pruneRoot:`.codestudio`},{hostDir:`.commandcode`,pruneRoot:`.commandcode`},{hostDir:`.config/crush`,pruneRoot:`.config/crush`},{hostDir:`.config/devin`,pruneRoot:`.config/devin`},{hostDir:`.config/goose`,pruneRoot:`.config/goose`},{hostDir:`.config/kimchi/harness`,pruneRoot:`.config/kimchi`},{hostDir:`.continue`,pruneRoot:`.continue`},{hostDir:`.factory`,pruneRoot:`.factory`},{hostDir:`.forge`,pruneRoot:`.forge`},{hostDir:`.grok`,pruneRoot:`.grok`},{hostDir:`.iflow`,pruneRoot:`.iflow`},{hostDir:`.inferencesh`,pruneRoot:`.inferencesh`},{hostDir:`.jazz`,pruneRoot:`.jazz`},{hostDir:`.junie`,pruneRoot:`.junie`},{hostDir:`.kilocode`,pruneRoot:`.kilocode`},{hostDir:`.kiro`,pruneRoot:`.kiro`},{hostDir:`.kode`,pruneRoot:`.kode`},{hostDir:`.lingma`,pruneRoot:`.lingma`},{hostDir:`.mcpjam`,pruneRoot:`.mcpjam`},{hostDir:`.moxby`,pruneRoot:`.moxby`},{hostDir:`.mux`,pruneRoot:`.mux`},{hostDir:`.neovate`,pruneRoot:`.neovate`},{hostDir:`.ona`,pruneRoot:`.ona`},{hostDir:`.openhands`,pruneRoot:`.openhands`},{hostDir:`.pochi`,pruneRoot:`.pochi`},{hostDir:`.qoder`,pruneRoot:`.qoder`},{hostDir:`.qoder-cn`,pruneRoot:`.qoder-cn`},{hostDir:`.qwen`,pruneRoot:`.qwen`},{hostDir:`.reasonix`,pruneRoot:`.reasonix`},{hostDir:`.roo`,pruneRoot:`.roo`},{hostDir:`.rovodev`,pruneRoot:`.rovodev`},{hostDir:`.snowflake/cortex`,pruneRoot:`.snowflake`},{hostDir:`.tabnine/agent`,pruneRoot:`.tabnine`},{hostDir:`.terramind`,pruneRoot:`.terramind`},{hostDir:`.tinycloud`,pruneRoot:`.tinycloud`},{hostDir:`.trae`,pruneRoot:`.trae`},{hostDir:`.trae-cn`,pruneRoot:`.trae-cn`},{hostDir:`.vibe`,pruneRoot:`.vibe`},{hostDir:`.zcode`,pruneRoot:`.zcode`},{hostDir:`.zencoder`,pruneRoot:`.zencoder`}],Le=[...c.map(e=>l[e]),`open-knowledge`];function X(e){if(!p(e))throw Error(`skill cleanup requires an absolute home directory; got ${JSON.stringify(e)}`);let t=_(e);if(t===v||f(t)===t)throw Error(`skill cleanup refuses to operate on the filesystem root (${t})`);return t}function Z(e,t){let n=g(e,t);if(n.startsWith(`..`)||p(n))return!1;let r=e;for(let e of n.split(v)){r=m(r,e);try{if(!x(r).isDirectory())return!1}catch{return!1}}return!0}function Re(e,t){try{return re(e).every(n=>t.has(m(e,n)))}catch{return!1}}function ze(e){let t=X(e),n=[],r=[],i=new Set;for(let e of Ie){let a=m(t,e.hostDir,`skills`);if(!Z(t,a))continue;let o=Le.map(e=>m(a,e)).filter(e=>b(e));n.push(...o);for(let e of o)i.add(e);let s=m(t,e.pruneRoot),c=a;for(;Re(c,i)&&(r.push(c),i.add(c),c!==s);){let e=f(c);if(e===c||e===t||!e.startsWith(t+v))break;c=e}}return{skillDirs:n,emptyDirs:r}}function Be(e){try{if(!x(e).isDirectory())return!1;let t=re(e);return t.length===0||t.includes(`SKILL.md`)}catch{return!1}}function Ve(e){let t=new Set,n=new Set;for(let r of Ie){let i=m(e,r.hostDir,`skills`);for(let e of Le)t.add(m(i,e));let a=m(e,r.pruneRoot),o=i;for(;n.add(o),o!==a;){let t=f(o);if(t===o||t===e||!t.startsWith(e+v))break;o=t}}return{skillDirs:t,emptyDirs:n}}function He(e,t){let n=X(e),r=Ve(n),i=[...t.skillDirs.filter(e=>!r.skillDirs.has(e)),...t.emptyDirs.filter(e=>!r.emptyDirs.has(e))];if(i.length>0)throw Error(`refusing skill cleanup — ${i.length} path(s) outside the known legacy set: ${i.join(`, `)}`);let a=[];for(let e of t.skillDirs)if(Z(n,e)&&Be(e))try{C(e,{recursive:!0,force:!0}),a.push(e)}catch{}for(let e of t.emptyDirs)if(Z(n,e))try{ie(e),a.push(e)}catch{}return a}function Q(e){let t=X(e),n=[];for(let e of c){let r=l[e];n.push({path:m(t,`.agents`,`skills`,r),bundleId:e,scope:`central`});for(let i of j)n.push({path:m(t,i.hostDir,`skills`,r),bundleId:e,scope:`host`,hostDir:i.hostDir})}return n}function Ue(e,t){let n=[];for(let r of Q(e))if(r.bundleId===t)try{C(r.path,{recursive:!0,force:!0})}catch(e){n.push(e instanceof Error?e:Error(String(e)))}if(n.length>0)throw AggregateError(n,`Failed to remove ${n.length} path(s) for ${t}`)}function We(e,t){let n;try{n=x(e)}catch(e){if(e.code!==`ENOENT`)throw e}if(n?.isSymbolicLink())throw Error(`Refusing to write through a symbolic link at ${e}. Remove the symlink and re-run project setup.`);Ke(e,t)}function Ge(e,t){Ke(e,t)}function Ke(e,t){let n;try{n=S(t)}catch{n=_(t)}let r=f(e);for(;r.length>1&&r!==v;){let t;try{t=S(r)}catch(e){if(e.code===`ENOENT`){r=f(r);continue}throw e}let i=g(n,t);if(i===``||!i.startsWith(`..`)&&!p(i))return;throw Error(`Refusing to write at ${e}: ancestor ${r} resolves to ${t}, which is outside the project directory ${n}. A symbolic link in the path likely escapes the project. Remove the symlink and re-run project setup.`)}}function $(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function qe(e,t,n){try{if(ae(n).size>10485760)return!1}catch{return!1}let r;try{r=ne(n,`utf-8`)}catch{return!1}let i=[],a=u(r.charCodeAt(0)===65279?r.slice(1):r,i,{allowTrailingComma:!0,disallowComments:!1});if(i.length>0||!$(a))return!1;let o=a[e.topLevelKey];if(!$(o))return!1;let s=e.serverMapSubKey?o[e.serverMapSubKey]:o;return $(s)?$(s[e.serverName(t)]):!1}function Je(e,t,n={}){if(e.id!==`copilot`)return!0;try{return qe(e,t,e.configPath(t,n.home))}catch{return!1}}function Ye(e,t,n={}){let r=e.projectSkillPath?.(t);if(!r)return{editorId:e.id,label:e.label,action:`skipped-unsupported`,path:``};if(!Je(e,t,n))return{editorId:e.id,label:e.label,action:`skipped-prerequisite`,path:r};try{let n=s(`project`,{checkDesktop:!0}),i=f(r);We(i,t);let a=b(r)?`overwritten`:`written`;return C(i,{recursive:!0,force:!0}),te(f(i),{recursive:!0}),ee(n,i,{recursive:!0}),{editorId:e.id,label:e.label,action:a,path:r}}catch(t){return{editorId:e.id,label:e.label,action:`failed`,path:r,error:t instanceof Error?t.message:String(t)}}}function Xe(e,t){let n=e.projectSkillPath?.(t);if(!n)return{editorId:e.id,label:e.label,action:`skipped-unsupported`,path:``};try{let r=f(n);return b(n)?(Ge(r,t),C(r,{recursive:!0,force:!0}),{editorId:e.id,label:e.label,action:`removed`,path:n}):{editorId:e.id,label:e.label,action:`not-present`,path:n}}catch(t){return{editorId:e.id,label:e.label,action:`failed`,path:n,error:t instanceof Error?t.message:String(t)}}}export{he as C,Fe as S,_e as T,we as _,He as a,Te as b,Q as c,Y as d,j as f,z as g,ye as h,Ye as i,k as l,L as m,Ge as n,ze as o,I as p,Xe as r,Ue as s,We as t,A as u,be as v,pe as w,Ee as x,Se as y};
|
|
56
|
+
//# sourceMappingURL=write-project-skill-C5NP_pT9.mjs.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@inkeep/open-knowledge",
|
|
3
|
-
"version": "0.43.0-beta.
|
|
3
|
+
"version": "0.43.0-beta.14",
|
|
4
4
|
"license": "GPL-3.0-or-later",
|
|
5
5
|
"private": false,
|
|
6
6
|
"type": "module",
|
|
@@ -61,10 +61,10 @@
|
|
|
61
61
|
"ajv-formats": "^3.0.1",
|
|
62
62
|
"tsdown": "^0.21.7",
|
|
63
63
|
"typescript": "^5.9.3",
|
|
64
|
-
"@inkeep/open-knowledge-
|
|
64
|
+
"@inkeep/open-knowledge-core": "0.43.0-beta.14",
|
|
65
|
+
"@inkeep/open-knowledge-app": "0.43.0-beta.14",
|
|
65
66
|
"@inkeep/open-knowledge-native-config": "0.0.0",
|
|
66
|
-
"@inkeep/open-knowledge-
|
|
67
|
-
"@inkeep/open-knowledge-server": "0.43.0-beta.13"
|
|
67
|
+
"@inkeep/open-knowledge-server": "0.43.0-beta.14"
|
|
68
68
|
},
|
|
69
69
|
"scripts": {
|
|
70
70
|
"build:cli": "tsdown",
|