@inkeep/open-knowledge 0.69.0-beta.8 → 0.69.0-beta.9
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/THIRD_PARTY_NOTICES.md +14 -4
- package/dist/cli.mjs +67 -65
- package/dist/constants-CCuK4nUG.mjs +1 -0
- package/dist/{dist-CJ5qX39u.mjs → dist-CGh73TLX.mjs} +1 -1
- package/dist/{dist-B_lhaeFJ.mjs → dist-asnPGf9w.mjs} +1 -1
- package/dist/index.d.mts +48 -16
- package/dist/index.mjs +228 -224
- package/dist/init-ACza8zdW.mjs +1 -0
- package/dist/{init-CoCCZEvS.mjs → init-DzKFDT_8.mjs} +18 -18
- package/dist/launch-json-removal-BkycSqGv.mjs +1 -0
- package/dist/loader-C6NXM2jh.mjs +1 -0
- package/dist/{loader-B0EV14F-.mjs → loader-DpwyreRY.mjs} +1 -1
- package/dist/native/native-config.darwin-arm64.node +0 -0
- package/dist/native/native-config.darwin-x64.node +0 -0
- package/dist/native/native-config.linux-arm64-gnu.node +0 -0
- package/dist/native/native-config.linux-arm64-musl.node +0 -0
- package/dist/native/native-config.linux-x64-musl.node +0 -0
- package/dist/native/native-config.win32-arm64-msvc.node +0 -0
- package/dist/native/native-config.win32-x64-msvc.node +0 -0
- package/dist/{open-browser-CdtzidpR.mjs → open-browser-BtsloeTq.mjs} +1 -1
- package/dist/{preview-BWs_Rq1J.mjs → preview-C97i0S8P.mjs} +1 -1
- package/dist/preview-NxKFiLb_.mjs +1 -0
- package/dist/public/assets/{ActivityModeContent-CximtPXo.js → ActivityModeContent-CJlrWQa-.js} +1 -1
- package/dist/public/assets/{AddPropertiesButton-CLAxY4Kp.js → AddPropertiesButton-D468kNkw.js} +1 -1
- package/dist/public/assets/{AgentDiffPane-CZ6Irl2N.js → AgentDiffPane-sN8K8hX3.js} +1 -1
- package/dist/public/assets/{CodeMirrorPropInput-DyT36_0H.js → CodeMirrorPropInput-YBL6ju2M.js} +1 -1
- package/dist/public/assets/{DocumentContext-DS_dUWBr.js → DocumentContext-lxWo-jIX.js} +1 -1
- package/dist/public/assets/{EditorModeToggle-Nq_bPbVL.js → EditorModeToggle-txU-peDb.js} +1 -1
- package/dist/public/assets/{EnableSyncConfirmDialog-N-3Oe5uz.js → EnableSyncConfirmDialog-CP-AFV9K.js} +1 -1
- package/dist/public/assets/{ExcalidrawDocEditor-C-NOBDVO.js → ExcalidrawDocEditor-Cstpu2_d.js} +1 -1
- package/dist/public/assets/FeedbackForm-E4Q8vBaR.js +1 -0
- package/dist/public/assets/{ImportSkillDialog-BASlWroD.js → ImportSkillDialog-5TJ-bV4O.js} +1 -1
- package/dist/public/assets/{LintConfigEditor-BL1ZjbK7.js → LintConfigEditor-BpZOqNp4.js} +1 -1
- package/dist/public/assets/ManagedArtifactProperties-Biz5eD2a.js +1 -0
- package/dist/public/assets/{ManagedArtifactProperties-E5_ddR_p.js → ManagedArtifactProperties-Kaq-aeZC.js} +1 -1
- package/dist/public/assets/{MermaidDocEditor-DE4hSQJD.js → MermaidDocEditor-S6EkQTtg.js} +1 -1
- package/dist/public/assets/{PropertyDisplayRow-B3v_6w4O.js → PropertyDisplayRow-B4v4jTNF.js} +1 -1
- package/dist/public/assets/{SchemaConfigEditor-DlZbi0BH.js → SchemaConfigEditor-CETZMgsw.js} +1 -1
- package/dist/public/assets/{SessionsHost-Df5IVb6O.js → SessionsHost-COCtd6o1.js} +2 -2
- package/dist/public/assets/{SettingsDialogBody-BOCtv6zl.js → SettingsDialogBody-CcRSiycI.js} +1 -1
- package/dist/public/assets/{ShareReceiveMissDialog-CrjCM6hU.js → ShareReceiveMissDialog-BjdTmTYS.js} +1 -1
- package/dist/public/assets/{SkillInstallMenu-CVK9zId1.js → SkillInstallMenu-WFsTLGd_.js} +1 -1
- package/dist/public/assets/{SkillToolbarControls-CMvIOhEL.js → SkillToolbarControls-BnFTgfQe.js} +1 -1
- package/dist/public/assets/{SourceEditor-C74huF53.js → SourceEditor-DPQ2zSrD.js} +1 -1
- package/dist/public/assets/{TerminalWindowApp-BusqUG6y.js → TerminalWindowApp-D81J8emi.js} +1 -1
- package/dist/public/assets/{TextDocEditor-LT7YyAwm.js → TextDocEditor-CqczBIHK.js} +1 -1
- package/dist/public/assets/{ThreadView-CMGgpD7W.js → ThreadView-DfQx3701.js} +2 -2
- package/dist/public/assets/{TimelineDiffPane-Bv8dQirf.js → TimelineDiffPane-Dn6JCVyO.js} +1 -1
- package/dist/public/assets/{agent-diff-store-Cle15UKh.js → agent-diff-store-CpmA3--m.js} +1 -1
- package/dist/public/assets/{auth-state-cache-qvH-oSfq.js → auth-state-cache-vp_V8EAT.js} +1 -1
- package/dist/public/assets/{comment-chips-vgbpHTuL.js → comment-chips-CJc_efRz.js} +1 -1
- package/dist/public/assets/{config-provider-Ck1DNDm7.js → config-provider-BQeo1rKk.js} +3 -3
- package/dist/public/assets/{doc-undo-manager-VvINx_vq.js → doc-undo-manager-C6JcFJSX.js} +1 -1
- package/dist/public/assets/globals-_QjAtVtE.css +1 -0
- package/dist/public/assets/i18n-DM0BEdRu.js +1 -0
- package/dist/public/assets/{index-IpcP5FTX.js → index-B53eHRq2.js} +7 -7
- package/dist/public/assets/{messages-Bx4IehS7.js → messages-B-oO73eg.js} +1 -1
- package/dist/public/assets/{messages-c4jjA_8H.js → messages-Bg2HaNYA.js} +1 -1
- package/dist/public/assets/{messages-DGVl_E7x.js → messages-BiprhPpU.js} +1 -1
- package/dist/public/assets/{messages-CUzLexij.js → messages-BqoENAsj.js} +1 -1
- package/dist/public/assets/{messages-CR_I7Cp3.js → messages-BxQHRPNQ.js} +1 -1
- package/dist/public/assets/{messages-Bms9ZCX3.js → messages-BxQj38iM.js} +1 -1
- package/dist/public/assets/{messages-CX2LIRPQ.js → messages-CmyAC5iB.js} +1 -1
- package/dist/public/assets/{messages-BvsAGBeC.js → messages-CxtA76-S.js} +1 -1
- package/dist/public/assets/{messages-GcLNaJaR.js → messages-FlRc5cWj.js} +1 -1
- package/dist/public/assets/{messages-BjR7N346.js → messages-W23UWkLV.js} +1 -1
- package/dist/public/assets/{messages-C3zAHKSk.js → messages-YdP7RJ5x.js} +1 -1
- package/dist/public/assets/{messages-zMV5QHq9.js → messages-jHGaUnYF.js} +1 -1
- package/dist/public/assets/{pending-receive-nav-store-X1voDf8F.js → pending-receive-nav-store-BqDvv-YD.js} +1 -1
- package/dist/public/assets/{progress-tXfeh49A.js → progress-qgBnDfAe.js} +1 -1
- package/dist/public/assets/{selection-context-VgoGxndZ.js → selection-context-h5CTJIN3.js} +1 -1
- package/dist/public/assets/{src-_s2f2_6g.js → src-Cn36aoiu.js} +1 -1
- package/dist/public/assets/{typing-burst-detector-BIDnBCHc.js → typing-burst-detector-CS7W7tHL.js} +1 -1
- package/dist/public/assets/uninstall-_xLJMVOG.js +1 -0
- package/dist/public/assets/{use-activity-panel-0Kzpvkwn.js → use-activity-panel-Bpfx38V_.js} +1 -1
- package/dist/public/assets/{use-open-skill-CCmJFvMI.js → use-open-skill-nfPlyj-n.js} +1 -1
- package/dist/public/assets/{use-terminal-enabled-BlfoUmdn.js → use-terminal-enabled-TCwFmXL1.js} +1 -1
- package/dist/public/assets/{use-timeline-entry-diff-BUFMqeVp.js → use-timeline-entry-diff-CdGbaZQg.js} +1 -1
- package/dist/public/index.html +22 -22
- package/dist/public/uninstall.html +5 -5
- package/dist/registry-probes-D2kUXGAq.mjs +17 -0
- package/dist/removal-file-path-fM0ywRil.mjs +1 -0
- package/dist/{repair-launch-json-I0JPbY-j.mjs → repair-launch-json-BKo3Lz3S.mjs} +1 -1
- package/dist/repair-mcp-configs-yh6okVpv.mjs +1 -0
- package/dist/src-DvVUm3ha.mjs +11 -0
- package/dist/src-Pb0YKsZP.mjs +1 -0
- package/dist/start-Bh73EAYz.mjs +5 -0
- package/dist/start-Db5WX93d.mjs +1 -0
- package/package.json +7 -5
- package/dist/constants-C2Waxo4E.mjs +0 -1
- package/dist/init-AV62II7K.mjs +0 -1
- package/dist/launch-json-removal-DOsPqTe0.mjs +0 -1
- package/dist/loader-BJKo02P9.mjs +0 -1
- package/dist/preview-BFGhI49k.mjs +0 -1
- package/dist/public/assets/FeedbackForm-Cbz8L9V-.js +0 -1
- package/dist/public/assets/ManagedArtifactProperties-1Jje2JUZ.js +0 -1
- package/dist/public/assets/globals-D927wlz4.css +0 -1
- package/dist/public/assets/i18n-LLIw89QS.js +0 -1
- package/dist/public/assets/uninstall-BPhdiudT.js +0 -1
- package/dist/registry-probes-B_UapTQA.mjs +0 -13
- package/dist/repair-mcp-configs-CHDcjBGn.mjs +0 -1
- package/dist/src-BVPWIiic.mjs +0 -11
- package/dist/src-e37AQ3jI.mjs +0 -1
- package/dist/start-CV9e5XLw.mjs +0 -5
- package/dist/start-DtlPjkSc.mjs +0 -1
- /package/dist/public/assets/{globals-BoP7p4Dy.js → globals-BeDeKpJB.js} +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import"./md-manager-BGnqyqi1-Eez8IlhB.mjs";var e=`0.69.0-beta.9`;const t=`config.yml`,n=e;export{n,t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{Bn as e,Do as t,It as n,Jc as r,Xl as i,_o as a,ll as o,pn as s,us as c,vn as l,ya as u}from"./md-manager-BGnqyqi1-Eez8IlhB.mjs";import{$ as d,$a as f,$i as p,$n as m,$r as h,$t as g,A as _,Aa as v,Ai as y,An as b,Ar as x,At as S,B as C,Ba as w,Bi as T,Bn as E,Bo as D,Br as O,Bt as k,C as A,Ca as j,Ci as M,Cn as N,Cr as P,Ct as F,D as I,Da as L,Di as R,Dn as z,Do as B,Dr as V,Dt as H,E as U,Ea as W,Ei as G,En as K,Er as q,Et as J,F as Y,Fa as X,Fi as Z,Fn as Q,Fo as $,Fr as ee,Ft as te,G as ne,Ga as re,Gi as ie,Gn as ae,Gr as oe,Gt as se,H as ce,Ha as le,Hi as ue,Hn as de,Hr as fe,Ht as pe,I as me,Ia as he,Ii as ge,In as _e,Io as ve,Ir as ye,It as be,J as xe,Ja as Se,Ji as Ce,Jn as we,Jr as Te,Jt as Ee,K as De,Ka as Oe,Ki as ke,Kn as Ae,Kr as je,Kt as Me,L as Ne,La as Pe,Li as Fe,Ln as Ie,Lo as Le,Lr as Re,Lt as ze,M as Be,Ma as Ve,Mi as He,Mn as Ue,Mo as We,Mr as Ge,Mt as Ke,N as qe,Na as Je,Ni as Ye,Nn as Xe,No as Ze,Nr as Qe,Nt as $e,O as et,Oa as tt,Oi as nt,On as rt,Oo as it,Or as at,Ot as ot,P as st,Pa as ct,Pi as lt,Pn as ut,Po as dt,Pr as ft,Pt as pt,Q as mt,Qa as ht,Qi as gt,Qn as _t,Qr as vt,Qt as yt,R as bt,Ra as xt,Ri as St,Rn as Ct,Ro as wt,Rr as Tt,Rt as Et,S as Dt,Sa as Ot,Si as kt,Sn as At,Sr as jt,St as Mt,T as Nt,Ta as Pt,Ti as Ft,Tn as It,Tr as Lt,Tt as Rt,U as zt,Ua as Bt,Ui as Vt,Un as Ht,Ur as Ut,Ut as Wt,V as Gt,Va as Kt,Vi as qt,Vn as Jt,Vr as Yt,Vt as Xt,W as Zt,Wa as Qt,Wi as $t,Wn as en,Wr as tn,Wt as nn,X as rn,Xa as an,Xi as on,Xn as sn,Xr as cn,Xt as ln,Y as un,Ya as dn,Yi as fn,Yn as pn,Yr as mn,Yt as hn,Z as gn,Za as _n,Zi as vn,Zn as yn,Zr as bn,Zt as xn,_ as Sn,_a as Cn,_i as wn,_n as Tn,_r as En,_t as Dn,a as On,aa as kn,ai as An,an as jn,ar as Mn,at as Nn,b as Pn,ba as Fn,bi as In,bn as Ln,br as Rn,bt as zn,c as Bn,ca as Vn,ci as Hn,cn as Un,cr as Wn,ct as Gn,d as Kn,da as qn,di as Jn,dn as Yn,dr as Xn,dt as Zn,ea as Qn,ei as $n,en as er,eo as tr,er as nr,et as rr,f as ir,fa as ar,fi as or,fn as sr,fr as cr,ft as lr,g as ur,ga as dr,gi as fr,gn as pr,gr as mr,gt as hr,h as gr,ha as _r,hi as vr,hn as yr,hr as br,ht as xr,i as Sr,ia as Cr,ii as wr,in as Tr,io as Er,ir as Dr,it as Or,j as kr,ja as Ar,ji as jr,jn as Mr,jr as Nr,jt as Pr,k as Fr,ka as Ir,ki as Lr,kn as Rr,kr as zr,kt as Br,l as Vr,la as Hr,li as Ur,ln as Wr,lr as Gr,lt as Kr,m as qr,ma as Jr,mi as Yr,mn as Xr,mr as Zr,mt as Qr,n as $r,na as ei,ni as ti,nn as ni,no as ri,nr as ii,nt as ai,o as oi,oa as si,oi as ci,on as li,or as ui,ot as di,p as fi,pa as pi,pi as mi,pn as hi,pr as gi,pt as _i,q as vi,qa as yi,qi as bi,qn as xi,qr as Si,qt as Ci,r as wi,ra as Ti,ri as Ei,rn as Di,ro as Oi,rr as ki,rt as Ai,s as ji,sa as Mi,si as Ni,sn as Pi,sr as Fi,st as Ii,t as Li,ta as Ri,ti as zi,tn as Bi,to as Vi,tr as Hi,tt as Ui,u as Wi,ua as Gi,ui as Ki,un as qi,ur as Ji,ut as Yi,v as Xi,va as Zi,vi as Qi,vn as $i,vr as ea,vt as ta,w as na,wa as ra,wi as ia,wn as aa,wr as oa,wt as sa,x as ca,xa as la,xi as ua,xn as da,xr as fa,xt as pa,y as ma,ya as ha,yi as ga,yn as _a,yr as va,yt as ya,z as ba,za as xa,zi as Sa,zn as Ca,zo as wa,zr as Ta,zt as Ea}from"./dist-B_lhaeFJ.mjs";export{Li as AGENT_ID_MAX_LEN,$r as AGENT_ID_RE,wi as AGENT_WRITE_ORIGIN,Sr as AcpPermissionStore,On as AcpRegistry,oi as AcpThreadManager,ji as AgentFocusBroadcaster,Bn as AgentPresenceBroadcaster,Vr as AgentSessionCapacityError,Wi as AgentSessionManager,Kn as AutoStartDisabledError,ir as BUNDLE_IDS,fi as BUNDLE_SCOPE,qr as BUNDLE_SKILL_NAME,gr as BacklinkIndex,ur as CC1Broadcaster,r as CC1_CONTRACT_VERSION,Sn as CONFIG_FILENAME,Xi as CONFLICT_MARKER_RE,ma as CURSOR_BUNDLE_PATHS_BY_PLATFORM,Pn as ConfigSchema,ca as DEFAULT_CHECKPOINT_RETENTION,Dt as DEFAULT_EMBEDDINGS_DIMENSIONS,A as DEFAULT_PACK_ID,na as DocumentDurabilityState,Nt as EMBEDDINGS_API_KEY_ENV,U as EPHEMERAL_PROJECT_DIR_PREFIX,I as ExposureConsentError,et as FEATURED_AGENT_IDS,Fr as FILE_SYSTEM_WRITER,_ as FILE_WATCHER_ORIGIN,kr as FileEmbeddingsBackend,Be as GIT_PREFLIGHT_FAIL_SPAN_NAME,qe as GIT_UPSTREAM_WRITER,B as GitDirAccessError,st as GitNotAvailableError,Y as GitTooOldError,me as HOCUSPOCUS_AUTH_REJECTION_REASONS,Ne as HocuspocusAuthRejection,bt as HocuspocusAuthTokenSchema,ba as HomeProjectRootError,C as INSTALLED_AGENTS_SCHEMES,Gt as JSON_SCHEMA_DIALECT_2020_12,n as LINEAGE_EPOCH_KEY,ce as LIVE_DERIVED_INDEX_DEBOUNCE_MS,zt as MANAGED_RENAME_ORIGIN,Zt as MAX_ACP_THREADS,ne as MAX_AGENT_SESSIONS,De as MCP_CONNECTION_ID_HEADER,i as MCP_SERVER_NAME,vi as MIN_EVICTABLE_IDLE_MS,xe as MIN_GIT_VERSION,un as MISSING_OK_CONFIG_MESSAGE,it as MalformedGitPointerError,rn as McpLogger,gn as MissingOkConfigError,mt as OBSERVER_SYNC_ORIGIN,d as OK_OKIGNORE_TEMPLATE,rr as ONBOARDING_BUNDLE_IDS,s as ORPHAN_MODES,l as PROTOCOL_VERSION,We as PinoLogger,Ui as ProcessLockCollisionError,ai as ProjectGitInitError,Ai as ROLLBACK_ORIGIN,Or as ROOT_GITIGNORE_TEMPLATE,Nn as RUNTIME_VERSION,di as SERVICE_WRITER,Ii as SKILL_INSTALL_EVENTS_FILE_REL,e as SKILL_STATE_TARGETS,Gn as STARTER_FOLDER_FRONTMATTER_FILENAME,Kr as STARTER_PACKS,Yi as STARTER_PACK_IDS,Zn as STATE_MANIFEST_FILENAME,lr as STATE_SCHEMA_VERSION,o as SYSTEM_DOC_NAME,_i as SeedPrerequisiteError,Qr as SeedRootDirError,xr as ServerLockCollisionError,hr as SingleFileNotAFileError,Dn as SingleFileNotFoundError,ta as SingleFileNotMarkdownError,ya as SingleFileProjectOverrideError,zn as StateManifestError,pa as TagIndex,Mt as USER_GLOBAL_BUNDLE_IDS,F as __getShowAllWalkStatsForTesting,sa as __resetShowAllWalkStatsForTesting,Rt as acquireProcessLock,J as acquireServerLock,H as applyAgentMarkdownWrite,ot as applyExternalChange,Br as applySeed,S as assertCompatibleStateManifest,Pr as assertGitAvailable,Ke as assertNeverDiskEvent,$e as assertNotHomeProjectRoot,pt as attachAcpThreadSocket,te as attachCollabClientCounter,be as attachIdleShutdown,ze as bootServer,Et as buildAndOpenSkill,Ea as buildConfigYmlContent,k as buildExecResult,Xt as buildIngressPolicy,pe as buildOkMcpStdioCommand,Wt as buildSkillZip,nn as buildStarterFolderFrontmatterYaml,se as buildWipTree,Me as bundleSkillMdPath,Ci as canonicalProjectKey,Ee as canonicalizeForCompare,hn as classifyEvents,ln as classifyFsPath,xn as clearAllEmbeddingsKeys,yt as coercePackId,g as collectServerHostSnapshot,u as colorFromSeed,er as commitUpstreamImport,Bi as commitWip,ni as commitWipFromTree,Di as compareSemver,Tr as composeEffectiveLinterConfig,jn as composeFrontmatterSchemasConfig,li as containsConflictMarkers,Pi as contentHash,Un as contributorCount,Wr as countShadowObjects,qi as countStaleAgentWipRefs,Yn as countWipRefs,sr as createApiExtension,hi as createAssetServeMiddleware,Xr as createCollaborationHost,yr as createContentFilter,pr as createContentFilterAsync,Tn as createEmbeddingsSecretStore,$i as createEphemeralProjectDir,_a as createExternalChangeHandler,Ln as createFileLogger,da as createLiveDerivedIndexExtension,At as createMcpHttpHandler,N as createOsProbe,aa as createPersistenceExtension,It as createServer,K as createServerObserverExtension,z as createServerProbeResolver,rt as createStreamingErrorWriter,Ze as createTestLogger,Rr as describeStoredEmbeddingsKey,b as detectClaudeDesktopPresence,Mr as detectGit,Ue as detectProjectShape,Xe as detectUserSkillHosts,ut as discoverLockDirs,Q as discoverMarkdownlintConfig,_e as emitPreflightFailureSpan,Ie as encodeDocName,Ct as encodeFolderRoute,Ca as encodeSkillRoute,E as ensureProjectGit,Jt as errorResponse,de as evictStaleTrackerEntries,Ht as extractHeadings,en as extractOkBinaryPath,ae as extractWikiLinksFromMarkdown,Ae as fallbackPaths,xi as findEnclosingGitRoot,we as findEnclosingProjectRoot,pn as findNativeMarkdownlintFile,sn as flushFileLogger,yn as formatAuthRejectionWire,_t as formatContributorsFrom,m as formatPackRationale,nr as gcCheckpointRefs,Hi as getCurrentMcpLogger,ii as getIngressContext,ki as getLocalDir,Dr as getLogFilePath,dt as getLogger,Mn as getLogsDir,ui as getMachineId,Fi as getMeter,Wn as getMetrics,Gr as getTracer,Ji as handleCollabSocketError,Xn as handleSpawnCursor,cr as hasForwardingHeaders,gi as hasGcLogLatch,a as iconFromClientName,Zr as incrementCollabSocketFilteredError,br as incrementServerObserverFire,mr as initContent,En as initShadowRepo,ea as initTelemetry,va as initToleranceTelemetryWriter,Rn as installJsonSchemaDialect,fa as installPrettyZodErrors,$ as installTestLoggers,jt as installUserSkill,P as isAllowedApiOrigin,oa as isAllowedWorkspaceHostHeader,Lt as isConfigDoc,q as isHocuspocusAuthRejectionReason,V as isHomeDir,at as isHostAdmitted,zr as isKnownPackId,x as isLinkIndexExcludedDoc,Nr as isLoopbackAddress,Ge as isManagedArtifactDoc,Qe as isOriginAdmitted,t as isOrphanMode,ft as isPairedWriteOrigin,ee as isPathWithinDir,ye as isPeerAdmitted,Re as isProcessAlive,Tt as isProjectRoot,Ta as isReservedForUserTree,O as isSelfWrite,Yt as isSystemDoc,fe as isToleranceTelemetryEnabled,Ut as isValidLockPid,tn as lastKnownHash,oe as listRescueCheckpoints,je as listStarterPacks,Si as loadCustomAgents,Te as loadPrincipal,mn as lockAdvertisesUi,cn as lockBaseUrl,bn as lockFilePath,ve as loggerFactory,vt as loginShapedUserinfoUser,Le as logsCurrentPath,wt as logsPreviousPath,h as makeLazyEmbeddingsKeyStore,$n as markServerLockDraining,zi as mountMcpAndApi,ti as normalizeFsPath,Ei as observeReadiness,wr as originGitHubHost,An as packageVersionMajorMinor,ci as parseAuthRejectionWire,Ni as parseGitVersion,Hn as parseHocuspocusAuthToken,Ur as parseKeepaliveConnectionId,Ki as pathToDocName,Jn as planSeed,or as prepareSingleFileOpen,mi as processCommand,Yr as processUsage,vr as readAllTargets,fr as readBundleDecision,wn as readOwnNativeRules,Qi as readProcessLock,ga as readProcessLockDetailed,In as readProjectHeadState,ua as readProjectLocalSemanticConfig,kt as readServerLock,M as readServerPackageVersion,ia as readSkillInstallStateSnapshot,Ft as readStateManifest,G as readTargetRecordedAt,R as readTargetVersion,nt as reconcile,Lr as recordContributor,y as recordSkillInstallEvent,jr as redactShareSubprocessStderr,He as registerAllTools,Ye as registerWrite,lt as releaseProcessLock,Z as releaseServerLock,ge as removeLastKnownHash,Fe as removeProjectSkillGitignoreBlock,St as reportSkillInstall,Sa as resetMetrics,T as resolveBuiltinSkillHosts,c as resolveBundleEnabled,qt as resolveBundledSkillDir,ue as resolveContentDir,Vt as resolveCursorBinaryDefault,$t as resolveCursorSpawnInvocation,ie as resolveEffectiveLinterConfig,ke as resolveEmbeddingsCredential,bi as resolveGitHubAccountFromUrl,Ce as resolveLockDir,fn as resolveNativeConfigForDoc,on as resolveNativeMarkdownlintConfig,vn as resolvePack,gt as resolvePackageVersion,p as resolveSkillInstallReportSettings,Qn as resolveUiInfo,Ri as restoreContributors,ei as restoreLifecycleFromConflictsJson,Ti as rewriteMarkdownLinksForDocumentRename,Cr as rewriteWikiLinksForDocumentRename,kn as runAuthReposSubprocess,si as runAuthStatusSubprocess,Mi as runCloneSubprocess,Vn as runDeviceFlowSubprocess,Hr as runWithMcpLogger,Gi as safeContentPath,qn as safeSubdir,ar as safetyCheckpoint,pi as sameGitHubLogin,Jr as sanitizeClientName,_r as saveInMemoryCheckpoint,dr as saveVersion,Cn as seedBasenameIndex,Zi as seedEphemeralProjectDir,ha as serializeError,Fn as setActiveSpanAttributes,la as setupServerObservers,Ot as shadowGit,j as shutdownTelemetry,wa as spansCurrentPath,D as spansPreviousPath,ra as spawnDetached,Pt as splitMarkdownBlocks,W as startWatcher,L as streamingProblemEvent,tt as swapContributors,Ir as teardownToleranceTelemetryWriter,v as toBroadcasterKey,Ar as tracedAppendFileSync,Ve as tracedLinkSync,Je as tracedMkdir,ct as tracedMkdirSync,X as tracedRename,he as tracedRenameSync,Pe as tracedRmSync,xt as tracedRmdirSync,xa as tracedUnlinkSync,w as tracedWriteFile,Kt as tracedWriteFileSync,le as trustSystemCertificates,Bt as updateLastKnownHash,Qt as updateProcessLockPort,re as updateServerLockPort,Oe as validateAgentId,yi as validateCloneInputs,Se as validateSkillZip,dn as waitForServerLockDrain,an as withHiddenWindowsConsole,_n as withSpan,ht as withSpanSync,f as writeBundleDecision,tr as writeMarkdownlintRule,Vi as writeRootGitignoreForNewRepo,ri as writeStateManifest,Oi as writeTargetVersion,Er as writeTracker};
|
|
1
|
+
import{Bn as e,Do as t,It as n,Jc as r,Xl as i,_o as a,ll as o,pn as s,us as c,vn as l,ya as u}from"./md-manager-BGnqyqi1-Eez8IlhB.mjs";import{$ as d,$a as f,$i as p,$n as m,$r as h,$t as g,A as _,Aa as v,Ai as y,An as b,Ar as x,At as S,B as C,Ba as w,Bi as T,Bn as E,Bo as D,Br as O,Bt as k,C as A,Ca as j,Ci as M,Cn as N,Cr as P,Ct as F,D as I,Da as L,Di as R,Dn as z,Do as B,Dr as V,Dt as H,E as U,Ea as W,Ei as G,En as K,Er as q,Et as J,F as Y,Fa as X,Fi as Z,Fn as Q,Fo as $,Fr as ee,Ft as te,G as ne,Ga as re,Gi as ie,Gn as ae,Gr as oe,Gt as se,H as ce,Ha as le,Hi as ue,Hn as de,Hr as fe,Ht as pe,I as me,Ia as he,Ii as ge,In as _e,Io as ve,Ir as ye,It as be,J as xe,Ja as Se,Ji as Ce,Jn as we,Jr as Te,Jt as Ee,K as De,Ka as Oe,Ki as ke,Kn as Ae,Kr as je,Kt as Me,L as Ne,La as Pe,Li as Fe,Ln as Ie,Lo as Le,Lr as Re,Lt as ze,M as Be,Ma as Ve,Mi as He,Mn as Ue,Mo as We,Mr as Ge,Mt as Ke,N as qe,Na as Je,Ni as Ye,Nn as Xe,No as Ze,Nr as Qe,Nt as $e,O as et,Oa as tt,Oi as nt,On as rt,Oo as it,Or as at,Ot as ot,P as st,Pa as ct,Pi as lt,Pn as ut,Po as dt,Pr as ft,Pt as pt,Q as mt,Qa as ht,Qi as gt,Qn as _t,Qr as vt,Qt as yt,R as bt,Ra as xt,Ri as St,Rn as Ct,Ro as wt,Rr as Tt,Rt as Et,S as Dt,Sa as Ot,Si as kt,Sn as At,Sr as jt,St as Mt,T as Nt,Ta as Pt,Ti as Ft,Tn as It,Tr as Lt,Tt as Rt,U as zt,Ua as Bt,Ui as Vt,Un as Ht,Ur as Ut,Ut as Wt,V as Gt,Va as Kt,Vi as qt,Vn as Jt,Vr as Yt,Vt as Xt,W as Zt,Wa as Qt,Wi as $t,Wn as en,Wr as tn,Wt as nn,X as rn,Xa as an,Xi as on,Xn as sn,Xr as cn,Xt as ln,Y as un,Ya as dn,Yi as fn,Yn as pn,Yr as mn,Yt as hn,Z as gn,Za as _n,Zi as vn,Zn as yn,Zr as bn,Zt as xn,_ as Sn,_a as Cn,_i as wn,_n as Tn,_r as En,_t as Dn,a as On,aa as kn,ai as An,an as jn,ar as Mn,at as Nn,b as Pn,ba as Fn,bi as In,bn as Ln,br as Rn,bt as zn,c as Bn,ca as Vn,ci as Hn,cn as Un,cr as Wn,ct as Gn,d as Kn,da as qn,di as Jn,dn as Yn,dr as Xn,dt as Zn,ea as Qn,ei as $n,en as er,eo as tr,er as nr,et as rr,f as ir,fa as ar,fi as or,fn as sr,fr as cr,ft as lr,g as ur,ga as dr,gi as fr,gn as pr,gr as mr,gt as hr,h as gr,ha as _r,hi as vr,hn as yr,hr as br,ht as xr,i as Sr,ia as Cr,ii as wr,in as Tr,io as Er,ir as Dr,it as Or,j as kr,ja as Ar,ji as jr,jn as Mr,jr as Nr,jt as Pr,k as Fr,ka as Ir,ki as Lr,kn as Rr,kr as zr,kt as Br,l as Vr,la as Hr,li as Ur,ln as Wr,lr as Gr,lt as Kr,m as qr,ma as Jr,mi as Yr,mn as Xr,mr as Zr,mt as Qr,n as $r,na as ei,ni as ti,nn as ni,no as ri,nr as ii,nt as ai,o as oi,oa as si,oi as ci,on as li,or as ui,ot as di,p as fi,pa as pi,pi as mi,pn as hi,pr as gi,pt as _i,q as vi,qa as yi,qi as bi,qn as xi,qr as Si,qt as Ci,r as wi,ra as Ti,ri as Ei,rn as Di,ro as Oi,rr as ki,rt as Ai,s as ji,sa as Mi,si as Ni,sn as Pi,sr as Fi,st as Ii,t as Li,ta as Ri,ti as zi,tn as Bi,to as Vi,tr as Hi,tt as Ui,u as Wi,ua as Gi,ui as Ki,un as qi,ur as Ji,ut as Yi,v as Xi,va as Zi,vi as Qi,vn as $i,vr as ea,vt as ta,w as na,wa as ra,wi as ia,wn as aa,wr as oa,wt as sa,x as ca,xa as la,xi as ua,xn as da,xr as fa,xt as pa,y as ma,ya as ha,yi as ga,yn as _a,yr as va,yt as ya,z as ba,za as xa,zi as Sa,zn as Ca,zo as wa,zr as Ta,zt as Ea}from"./dist-asnPGf9w.mjs";export{Li as AGENT_ID_MAX_LEN,$r as AGENT_ID_RE,wi as AGENT_WRITE_ORIGIN,Sr as AcpPermissionStore,On as AcpRegistry,oi as AcpThreadManager,ji as AgentFocusBroadcaster,Bn as AgentPresenceBroadcaster,Vr as AgentSessionCapacityError,Wi as AgentSessionManager,Kn as AutoStartDisabledError,ir as BUNDLE_IDS,fi as BUNDLE_SCOPE,qr as BUNDLE_SKILL_NAME,gr as BacklinkIndex,ur as CC1Broadcaster,r as CC1_CONTRACT_VERSION,Sn as CONFIG_FILENAME,Xi as CONFLICT_MARKER_RE,ma as CURSOR_BUNDLE_PATHS_BY_PLATFORM,Pn as ConfigSchema,ca as DEFAULT_CHECKPOINT_RETENTION,Dt as DEFAULT_EMBEDDINGS_DIMENSIONS,A as DEFAULT_PACK_ID,na as DocumentDurabilityState,Nt as EMBEDDINGS_API_KEY_ENV,U as EPHEMERAL_PROJECT_DIR_PREFIX,I as ExposureConsentError,et as FEATURED_AGENT_IDS,Fr as FILE_SYSTEM_WRITER,_ as FILE_WATCHER_ORIGIN,kr as FileEmbeddingsBackend,Be as GIT_PREFLIGHT_FAIL_SPAN_NAME,qe as GIT_UPSTREAM_WRITER,B as GitDirAccessError,st as GitNotAvailableError,Y as GitTooOldError,me as HOCUSPOCUS_AUTH_REJECTION_REASONS,Ne as HocuspocusAuthRejection,bt as HocuspocusAuthTokenSchema,ba as HomeProjectRootError,C as INSTALLED_AGENTS_SCHEMES,Gt as JSON_SCHEMA_DIALECT_2020_12,n as LINEAGE_EPOCH_KEY,ce as LIVE_DERIVED_INDEX_DEBOUNCE_MS,zt as MANAGED_RENAME_ORIGIN,Zt as MAX_ACP_THREADS,ne as MAX_AGENT_SESSIONS,De as MCP_CONNECTION_ID_HEADER,i as MCP_SERVER_NAME,vi as MIN_EVICTABLE_IDLE_MS,xe as MIN_GIT_VERSION,un as MISSING_OK_CONFIG_MESSAGE,it as MalformedGitPointerError,rn as McpLogger,gn as MissingOkConfigError,mt as OBSERVER_SYNC_ORIGIN,d as OK_OKIGNORE_TEMPLATE,rr as ONBOARDING_BUNDLE_IDS,s as ORPHAN_MODES,l as PROTOCOL_VERSION,We as PinoLogger,Ui as ProcessLockCollisionError,ai as ProjectGitInitError,Ai as ROLLBACK_ORIGIN,Or as ROOT_GITIGNORE_TEMPLATE,Nn as RUNTIME_VERSION,di as SERVICE_WRITER,Ii as SKILL_INSTALL_EVENTS_FILE_REL,e as SKILL_STATE_TARGETS,Gn as STARTER_FOLDER_FRONTMATTER_FILENAME,Kr as STARTER_PACKS,Yi as STARTER_PACK_IDS,Zn as STATE_MANIFEST_FILENAME,lr as STATE_SCHEMA_VERSION,o as SYSTEM_DOC_NAME,_i as SeedPrerequisiteError,Qr as SeedRootDirError,xr as ServerLockCollisionError,hr as SingleFileNotAFileError,Dn as SingleFileNotFoundError,ta as SingleFileNotMarkdownError,ya as SingleFileProjectOverrideError,zn as StateManifestError,pa as TagIndex,Mt as USER_GLOBAL_BUNDLE_IDS,F as __getShowAllWalkStatsForTesting,sa as __resetShowAllWalkStatsForTesting,Rt as acquireProcessLock,J as acquireServerLock,H as applyAgentMarkdownWrite,ot as applyExternalChange,Br as applySeed,S as assertCompatibleStateManifest,Pr as assertGitAvailable,Ke as assertNeverDiskEvent,$e as assertNotHomeProjectRoot,pt as attachAcpThreadSocket,te as attachCollabClientCounter,be as attachIdleShutdown,ze as bootServer,Et as buildAndOpenSkill,Ea as buildConfigYmlContent,k as buildExecResult,Xt as buildIngressPolicy,pe as buildOkMcpStdioCommand,Wt as buildSkillZip,nn as buildStarterFolderFrontmatterYaml,se as buildWipTree,Me as bundleSkillMdPath,Ci as canonicalProjectKey,Ee as canonicalizeForCompare,hn as classifyEvents,ln as classifyFsPath,xn as clearAllEmbeddingsKeys,yt as coercePackId,g as collectServerHostSnapshot,u as colorFromSeed,er as commitUpstreamImport,Bi as commitWip,ni as commitWipFromTree,Di as compareSemver,Tr as composeEffectiveLinterConfig,jn as composeFrontmatterSchemasConfig,li as containsConflictMarkers,Pi as contentHash,Un as contributorCount,Wr as countShadowObjects,qi as countStaleAgentWipRefs,Yn as countWipRefs,sr as createApiExtension,hi as createAssetServeMiddleware,Xr as createCollaborationHost,yr as createContentFilter,pr as createContentFilterAsync,Tn as createEmbeddingsSecretStore,$i as createEphemeralProjectDir,_a as createExternalChangeHandler,Ln as createFileLogger,da as createLiveDerivedIndexExtension,At as createMcpHttpHandler,N as createOsProbe,aa as createPersistenceExtension,It as createServer,K as createServerObserverExtension,z as createServerProbeResolver,rt as createStreamingErrorWriter,Ze as createTestLogger,Rr as describeStoredEmbeddingsKey,b as detectClaudeDesktopPresence,Mr as detectGit,Ue as detectProjectShape,Xe as detectUserSkillHosts,ut as discoverLockDirs,Q as discoverMarkdownlintConfig,_e as emitPreflightFailureSpan,Ie as encodeDocName,Ct as encodeFolderRoute,Ca as encodeSkillRoute,E as ensureProjectGit,Jt as errorResponse,de as evictStaleTrackerEntries,Ht as extractHeadings,en as extractOkBinaryPath,ae as extractWikiLinksFromMarkdown,Ae as fallbackPaths,xi as findEnclosingGitRoot,we as findEnclosingProjectRoot,pn as findNativeMarkdownlintFile,sn as flushFileLogger,yn as formatAuthRejectionWire,_t as formatContributorsFrom,m as formatPackRationale,nr as gcCheckpointRefs,Hi as getCurrentMcpLogger,ii as getIngressContext,ki as getLocalDir,Dr as getLogFilePath,dt as getLogger,Mn as getLogsDir,ui as getMachineId,Fi as getMeter,Wn as getMetrics,Gr as getTracer,Ji as handleCollabSocketError,Xn as handleSpawnCursor,cr as hasForwardingHeaders,gi as hasGcLogLatch,a as iconFromClientName,Zr as incrementCollabSocketFilteredError,br as incrementServerObserverFire,mr as initContent,En as initShadowRepo,ea as initTelemetry,va as initToleranceTelemetryWriter,Rn as installJsonSchemaDialect,fa as installPrettyZodErrors,$ as installTestLoggers,jt as installUserSkill,P as isAllowedApiOrigin,oa as isAllowedWorkspaceHostHeader,Lt as isConfigDoc,q as isHocuspocusAuthRejectionReason,V as isHomeDir,at as isHostAdmitted,zr as isKnownPackId,x as isLinkIndexExcludedDoc,Nr as isLoopbackAddress,Ge as isManagedArtifactDoc,Qe as isOriginAdmitted,t as isOrphanMode,ft as isPairedWriteOrigin,ee as isPathWithinDir,ye as isPeerAdmitted,Re as isProcessAlive,Tt as isProjectRoot,Ta as isReservedForUserTree,O as isSelfWrite,Yt as isSystemDoc,fe as isToleranceTelemetryEnabled,Ut as isValidLockPid,tn as lastKnownHash,oe as listRescueCheckpoints,je as listStarterPacks,Si as loadCustomAgents,Te as loadPrincipal,mn as lockAdvertisesUi,cn as lockBaseUrl,bn as lockFilePath,ve as loggerFactory,vt as loginShapedUserinfoUser,Le as logsCurrentPath,wt as logsPreviousPath,h as makeLazyEmbeddingsKeyStore,$n as markServerLockDraining,zi as mountMcpAndApi,ti as normalizeFsPath,Ei as observeReadiness,wr as originGitHubHost,An as packageVersionMajorMinor,ci as parseAuthRejectionWire,Ni as parseGitVersion,Hn as parseHocuspocusAuthToken,Ur as parseKeepaliveConnectionId,Ki as pathToDocName,Jn as planSeed,or as prepareSingleFileOpen,mi as processCommand,Yr as processUsage,vr as readAllTargets,fr as readBundleDecision,wn as readOwnNativeRules,Qi as readProcessLock,ga as readProcessLockDetailed,In as readProjectHeadState,ua as readProjectLocalSemanticConfig,kt as readServerLock,M as readServerPackageVersion,ia as readSkillInstallStateSnapshot,Ft as readStateManifest,G as readTargetRecordedAt,R as readTargetVersion,nt as reconcile,Lr as recordContributor,y as recordSkillInstallEvent,jr as redactShareSubprocessStderr,He as registerAllTools,Ye as registerWrite,lt as releaseProcessLock,Z as releaseServerLock,ge as removeLastKnownHash,Fe as removeProjectSkillGitignoreBlock,St as reportSkillInstall,Sa as resetMetrics,T as resolveBuiltinSkillHosts,c as resolveBundleEnabled,qt as resolveBundledSkillDir,ue as resolveContentDir,Vt as resolveCursorBinaryDefault,$t as resolveCursorSpawnInvocation,ie as resolveEffectiveLinterConfig,ke as resolveEmbeddingsCredential,bi as resolveGitHubAccountFromUrl,Ce as resolveLockDir,fn as resolveNativeConfigForDoc,on as resolveNativeMarkdownlintConfig,vn as resolvePack,gt as resolvePackageVersion,p as resolveSkillInstallReportSettings,Qn as resolveUiInfo,Ri as restoreContributors,ei as restoreLifecycleFromConflictsJson,Ti as rewriteMarkdownLinksForDocumentRename,Cr as rewriteWikiLinksForDocumentRename,kn as runAuthReposSubprocess,si as runAuthStatusSubprocess,Mi as runCloneSubprocess,Vn as runDeviceFlowSubprocess,Hr as runWithMcpLogger,Gi as safeContentPath,qn as safeSubdir,ar as safetyCheckpoint,pi as sameGitHubLogin,Jr as sanitizeClientName,_r as saveInMemoryCheckpoint,dr as saveVersion,Cn as seedBasenameIndex,Zi as seedEphemeralProjectDir,ha as serializeError,Fn as setActiveSpanAttributes,la as setupServerObservers,Ot as shadowGit,j as shutdownTelemetry,wa as spansCurrentPath,D as spansPreviousPath,ra as spawnDetached,Pt as splitMarkdownBlocks,W as startWatcher,L as streamingProblemEvent,tt as swapContributors,Ir as teardownToleranceTelemetryWriter,v as toBroadcasterKey,Ar as tracedAppendFileSync,Ve as tracedLinkSync,Je as tracedMkdir,ct as tracedMkdirSync,X as tracedRename,he as tracedRenameSync,Pe as tracedRmSync,xt as tracedRmdirSync,xa as tracedUnlinkSync,w as tracedWriteFile,Kt as tracedWriteFileSync,le as trustSystemCertificates,Bt as updateLastKnownHash,Qt as updateProcessLockPort,re as updateServerLockPort,Oe as validateAgentId,yi as validateCloneInputs,Se as validateSkillZip,dn as waitForServerLockDrain,an as withHiddenWindowsConsole,_n as withSpan,ht as withSpanSync,f as writeBundleDecision,tr as writeMarkdownlintRule,Vi as writeRootGitignoreForNewRepo,ri as writeStateManifest,Oi as writeTargetVersion,Er as writeTracker};
|
|
@@ -819,7 +819,7 @@ ${e.terminator}`}function FLe(e){return`(${tq(e.body)})${eq(e.redirections)}`}fu
|
|
|
819
819
|
`)}\n`;this.enqueue(e,async()=>{if(!this.appendBroken.has(e))try{await iY(this.eventsPath(e),n)}catch(t){this.appendBroken.add(e),this.log.error({err:t,threadId:e},`[acp-persist] event append failed; thread continues memory-only`)}})}queueMetaWrite(e,t){this.pinHome(e);let n=`${JSON.stringify(t,null,1)}\n`;this.enqueue(e,async()=>{let t=this.metaPath(e),r=`${t}.tmp`;try{await rY(r,n),await oY(r,t)}catch(t){this.log.warn({err:t,threadId:e},`[acp-persist] meta write failed`);try{await aY(r,{force:!0})}catch{}}})}whenIdle(e){return this.writeQueues.get(e)??Promise.resolve()}async scan(){let e=[],t=new Set,n=this.cwd===null?null:await TGe(this.cwd);return await this.scanDir(this.primaryThreadsDir,n,e,t),this.legacyThreadsDir!==null&&this.legacyThreadsDir!==this.primaryThreadsDir&&await this.scanDir(this.legacyThreadsDir,null,e,t),e}async scanDir(e,t,n,r){let i;try{i=await Ks(e)}catch(t){t.code!==`ENOENT`&&this.log.warn({err:t,dir:e},`[acp-persist] could not read a threads dir`);return}for(let a of i){if(!a.endsWith(`.meta.json`))continue;let i=V(e,a),o;try{o=JSON.parse(await Gs(i,`utf8`))}catch(e){this.log.warn({err:e,path:i},`[acp-persist] skipping unreadable thread meta`);continue}if(o.version!==1||typeof o.info!=`object`||o.info===null||typeof o.info.threadId!=`string`||typeof o.cwd!=`string`||typeof o.agentRef!=`object`||o.agentRef===null){this.log.warn({path:i},`[acp-persist] skipping unreadable thread meta`);continue}let s=o,c=s.info.threadId;r.has(c)||(t===null||await TGe(s.cwd)===t)&&(r.add(c),this.homeByThread.has(c)||this.homeByThread.set(c,e),n.push(s))}}async resolveEventLog(e){let t=this.eventsPath(e);if(!W(t))return{count:0,midTurn:!1};let n=0,r=!1;return await this.forEachCompleteLine(t,e=>(n+=1,e.startsWith(`{"kind":"turn_started"`)?r=!0:e.startsWith(`{"kind":"turn_ended"`)&&(r=!1),!0)),{count:n,midTurn:r}}async readEvents(e,t,n,r){let i=this.eventsPath(e);if(t>=n||!W(i))return;let a=0,o=[],s=t,c=()=>{o.length!==0&&(r(s,o),s+=o.length,o=[])};await this.forEachCompleteLine(i,e=>a>=n?!1:(a>=t&&(o.push(wGe(e)),o.length>=512&&c()),a+=1,!0)),c()}async delete(e){this.appendBroken.delete(e),this.writeQueues.delete(e);let t=[this.eventsPath(e),this.metaPath(e)],n=await Promise.allSettled(t.map(e=>aY(e,{force:!0})));this.homeByThread.delete(e);for(let[r,i]of n.entries())i.status===`rejected`&&this.log.warn({err:i.reason,threadId:e,path:t[r]},`[acp-persist] thread file removal failed`)}async forEachCompleteLine(e,t){let n=vs(e,{encoding:`utf8`}),r=null;n.on(`error`,e=>{r=e});let i=Oie({input:n,crlfDelay:1/0}),a=!1,o=null,s=!1;try{for await(let e of i){if(o!==null&&!t(o)){s=!0;break}o=e}s||(a=await CGe(e),o!==null&&a&&t(o))}finally{i.close(),n.destroy()}if(r!==null)throw r}};async function CGe(e){let{open:t}=await import(`node:fs/promises`),n=await t(e,`r`);try{let{size:e}=await n.stat();if(e===0)return!1;let t=Buffer.alloc(1);return await n.read(t,0,1,e-1),t[0]===10}finally{await n.close()}}function wGe(e){try{return JSON.parse(e)}catch{return{kind:`agent_stderr`,line:`[unreadable log entry]`,ts:0}}}async function TGe(e){try{return await qs(e)}catch{return U(e)}}const EGe=RegExp(`^(?:${`do you mind.i would like you to.i'd like you to.i want you to.i need you to.i would like to.i'd like to.i want to.i need to.we need to.we want to.we should.go ahead and.take a look at.have a look at.look into.look at.help me with.help me to.help me.can you.could you.would you.will you.can we.could we.should we.let's.lets.try to.please.kindly.hello.alright.actually.anyway.also.okay.hey.hi.yo.ok.so.pls.plz.just.maybe`.split(`.`).map(e=>e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)).join(`|`)})\\b(?:[\\s,:;!.\\-–—]+|$)`,`i`),DGe=/^(?:[#>]+\s*|[-*]\s+|\d+[.)]\s+)+/,OGe=/^[\s,:;.!?\-–—•|]+(?=\s|$)/;function kGe(e){return e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}function AGe(e){return(e.trim().split(`
|
|
820
820
|
`)[0]??``).trim()}function NQ(e){let t=AGe(e);if(t.length<=48)return t;let n=t.slice(0,47),r=n.lastIndexOf(` `);return`${(r>=24?n.slice(0,r):n).trimEnd()}…`}function jGe(e,t){let n=AGe(e),r=n.replace(DGe,``);if(t!==void 0&&t.trim()!==``){let e=kGe(t.trim()),n=String.raw`[,:;!.?\-–—•|]`,i=RegExp(`^(?:@${e}\\b(?:\\s+|${n}+(?:\\s+|$)|$)|${e}\\b\\s*${n}+(?:\\s+|$)|@?${e}\\b$)`,`i`);r=r.replace(i,``)}for(let e=0;e<6;e++){let e=r.replace(EGe,``);if(e===r)break;r=e}r=r.replace(OGe,``).trim();let i=r.split(/\s+/).filter(e=>e!==``).length;return!(r!==``&&(i>=2||r.length>=12))||r===n?NQ(n):NQ(r.charAt(0).toUpperCase()+r.slice(1))}const MGe=8,NGe=5e3,PQ=3e5,FQ=45e3,PGe=5e3,FGe=2e3;var IQ=class extends Error{code;constructor(e,t){super(t),this.name=`ThreadOpError`,this.code=e}},IGe=class extends Error{constructor(){super(`authenticate timed out`),this.name=`AuthenticateTimeoutError`}},LGe=class extends Error{constructor(){super(`prompt build cancelled before dispatch`),this.name=`PromptCancelledBeforeDispatchError`}};function RGe(){return new IQ(`not-ready`,`the thread was restarted during the sign-in`)}function zGe(e){return e.source===`registry`&&lJ[e.id]===`pi`}function BGe(e,t,n){let[r=`open-knowledge`,...i]=e&&e.length>0?e:[`open-knowledge`],a=[...i,`mcp`,`--port`,String(t)];if(r.includes(`/`)||r.includes(`\\`))return{command:r,args:a};let o=(n?.resolveCommand??(e=>$Z(e,EWe())))(r);return o===null?(n?.log?.warn({command:r},`[acp-threads] OK MCP stdio command did not resolve on PATH — injecting the bare name, which fails for harnesses that spawn MCP children under a minimal PATH`),{command:r,args:a}):{command:o,args:a}}var VGe=class{opts;threads=new Map;reapTimer;maxThreads;idleReapMs;steerStallMs;authenticateTimeoutMs;unwatchedTurnCancelMs;unwatchedTurnKillMs;persistence;resolveLoginShellPath;healthyInterpreters=new Set;destroyed=!1;initialized=!1;constructor(e){this.opts=e,this.resolveLoginShellPath=e.resolveLoginShellPath??(()=>yWe(e.log)()),this.maxThreads=e.maxThreads??8,this.idleReapMs=e.idleReapMs??36e5,this.steerStallMs=e.steerStallMs??1e4,this.authenticateTimeoutMs=e.authenticateTimeoutMs??3e5,this.unwatchedTurnCancelMs=e.unwatchedTurnCancelMs??6e5,this.unwatchedTurnKillMs=e.unwatchedTurnKillMs??12e5,this.persistence=new SGe({primaryDir:e.globalDir??e.localDir,legacyDir:e.globalDir===null?null:e.localDir,cwd:e.globalDir===null?null:e.contentDir,log:e.log}),this.reapTimer=setInterval(()=>this.reapIdleThreads(),3e5),this.reapTimer.unref?.()}async init(){if(this.initialized)return;this.initialized=!0,this.resolveLoginShellPath().catch(()=>{}),await this.persistence.init();let e=await this.persistence.scan();for(let t of e){let e=t.info.threadId;this.threads.has(e)||this.threads.set(e,UGe(t))}e.length>0&&this.opts.log.info({count:e.length},`[acp-threads] rehydrated archived threads`)}listThreads(){return[...this.threads.values()].map(e=>({...e.info}))}liveThreadCount(){let e=0;for(let t of this.threads.values())t.info.archived!==!0&&(e+=1);return e}getInfo(e){let t=this.threads.get(e);return t===void 0?void 0:{...t.info}}async subscribe(e,t,n){let r=this.mustGet(e);await this.ensureLogResolved(r);let i=Math.max(t,0);n({op:`subscribed`,threadId:e,fromSeq:i,info:{...r.info}});let a=i;for(;a<r.baseSeq;){let t=r.baseSeq;await this.persistence.whenIdle(e),await this.persistence.readEvents(e,a,t,(t,r)=>{n({op:`events`,threadId:e,fromSeq:t,events:r})}),a=t}this.flushBroadcast(r);let o=Math.max(i,r.baseSeq),s=r.baseSeq+r.events.length;for(let t=o;t<s;t+=512){let i=Math.min(t+512,s);n({op:`events`,threadId:e,fromSeq:t,events:r.events.slice(t-r.baseSeq,i-r.baseSeq)})}return r.subscribers.add(n),r.unwatchedSince=null,r.unwatchedCancelSent=!1,{...r.info}}ensureLogResolved(e){return e.logResolved?Promise.resolve():(e.logResolution??=(async()=>{try{let t=await this.persistence.resolveEventLog(e.info.threadId);e.baseSeq=t.count,e.midTurnOnDisk=t.midTurn,e.info.lastSeq=t.count-1,e.logResolved=!0}catch(t){throw e.logResolution=null,this.opts.log.error({err:t,threadId:e.info.threadId},`[acp-threads] durable log resolution failed`),t}})(),e.logResolution)}unsubscribe(e,t){let n=this.threads.get(e);n!==void 0&&(n.subscribers.delete(t),n.subscribers.size===0&&n.unwatchedSince===null&&(n.unwatchedSince=Date.now()))}async createThread(e){if(this.destroyed)throw new IQ(`capacity`,`server is shutting down`);if(this.liveThreadCount()>=this.maxThreads)throw new IQ(`capacity`,`maximum of ${this.maxThreads} concurrent agent threads`);let{info:t,custom:n}=await this.resolveAgentInfo(e.agent);if(await CJ({site:`acp-thread`,agentId:n===null?In(t.id)??t.id:t.id,mode:`acp`,log:this.opts.log,snapshot:this.opts.hostSnapshot}),this.destroyed)throw new IQ(`capacity`,`server is shutting down`);if(this.liveThreadCount()>=this.maxThreads)throw new IQ(`capacity`,`maximum of ${this.maxThreads} concurrent agent threads`);let r=crypto.randomUUID(),i=Date.now(),a={info:{threadId:r,agent:t,title:t.name,status:`installing`,createdAt:i,lastActivityAt:i,promptCapabilities:null,modes:null,configOptions:null,availableCommands:null,lastSeq:-1,archived:!1},docName:e.docName,agentRef:{source:e.agent.source,id:e.agent.id},launchSettings:e.settings,cwd:this.opts.contentDir,child:null,conn:null,lastInit:null,sessionId:null,agentSessionId:`acp-${r}`,events:[],baseSeq:0,logResolved:!0,logResolution:null,midTurnOnDisk:!1,resumeInFlight:!1,authInFlight:!1,suppressUpdates:!1,lastSuppressedAt:0,subscribers:new Set,pendingPermissions:new Map,pendingRuntimeConsent:new Map,pendingPiBridgeConsent:new Map,piBridgeDeclined:!1,lastPiBridgeStatus:null,stderrTail:[],authStderr:null,terminals:null,turnActive:!1,cancelRequested:!1,steerStallTimer:null,unwatchedSince:i,unwatchedCancelSent:!1,pendingBroadcast:[],pendingBroadcastFromSeq:0,flushTimer:null,closed:!1,hadUserMessage:!1,titleHint:e.titleHint,envNotePending:!1};return this.threads.set(r,a),this.emitStatus(a,`installing`),this.startThread(a,e,n).catch(e=>{this.opts.log.error({err:e,threadId:r},`[acp-threads] thread start failed`),this.emitStatus(a,`error`,e instanceof Error?e.message:String(e))}),{...a.info}}async resolveAgentInfo(e){if(e.source===`custom`){let t=(await hJ(this.opts.localDir,this.opts.log)).find(t=>t.id===e.id);if(t===void 0)throw new IQ(`unknown-agent`,`no custom agent '${e.id}'`);return{info:{id:t.id,name:t.name,source:`custom`},custom:t}}let t;try{t=await this.opts.registry.getAgent(e.id)}catch(e){throw new IQ(`install-failed`,`agent registry unavailable: ${e instanceof Error?e.message:String(e)}`)}if(t===void 0)throw new IQ(`unknown-agent`,`agent '${e.id}' is not in the registry`);return{info:{id:t.id,name:t.name,iconUrl:t.icon,source:`registry`,version:t.version},custom:null}}async connectAgent(e,t){let n;if(t!==null)n=kWe(t);else{let t=await this.opts.registry.getAgent(e.agentRef.id);if(t===void 0)throw new IQ(`unknown-agent`,`agent vanished`);n=await OWe(t,fJ(),this.opts.log)}if(e.closed)return null;let r=await this.ensureLaunchable(e,n);if(r===null||(n=r,e.closed))return null;let i=await this.resolveLoginShellPath().catch(()=>null);if(e.closed)return null;let a=new bGe({defaultCwd:e.cwd,emit:t=>this.appendEvent(e,t),log:this.opts.log,loginShellPath:i});this.emitStatus(e,`spawning`);let o=$We(n,e.cwd);if(e.child=o,e.terminals=a,o.stderr?.setEncoding(`utf8`),o.stderr?.on(`data`,t=>{for(let n of t.split(`
|
|
821
821
|
`))n.trim()!==``&&(e.stderrTail.push(n.slice(0,500)),e.stderrTail.length>40&&e.stderrTail.shift(),e.authStderr!==null&&(e.authStderr.push(n.slice(0,500)),e.authStderr.length>6&&e.authStderr.shift(),e.info.signInOutput=[...e.authStderr],this.broadcastInfo(e)))}),o.on(`error`,t=>{this.emitStatus(e,`error`,`agent failed to start: ${t.message}`,{reason:`connect`,agentMessage:t.message})}),o.on(`exit`,(t,n)=>{if(e.child=null,a.disposeAll().catch(t=>{this.opts.log.warn({err:t,threadId:e.info.threadId},`[acp-threads] terminal cleanup on agent exit failed`)}),e.closed||e.info.archived===!0)return;if(e.info.status===`error`){this.failPendingPermissions(e);return}let r=e.stderrTail.slice(-10).join(`
|
|
822
|
-
`);this.opts.log.warn({threadId:e.info.threadId,agentId:e.info.agent.id,code:t,signal:n,machineDetail:BQ(e)},`[acp-threads] agent exited unexpectedly`),this.emitStatus(e,`exited`,`agent exited (${n??t??`unknown`})${r?`\n${r}`:``}`),this.failPendingPermissions(e)}),o.stdin===null||o.stdout===null)throw new IQ(`spawn-failed`,`agent process has no stdio`);let s=cge(Qs.toWeb(o.stdin),Zs.toWeb(o.stdout)),c=Bge({name:`open-knowledge`}).onRequest(dE.client.session.requestPermission,t=>this.handlePermissionRequest(e,t.params.toolCall,t.params.options)).onRequest(dE.client.fs.readTextFile,e=>this.handleFsRead(e.params.path,e.params.line??null,e.params.limit??null)).onRequest(dE.client.fs.writeTextFile,async t=>(await this.handleFsWrite(e,t.params.path,t.params.content),{})).onRequest(dE.client.terminal.create,t=>(e.info.lastActivityAt=Date.now(),a.create(t.params))).onRequest(dE.client.terminal.output,e=>a.output(e.params.terminalId)).onRequest(dE.client.terminal.waitForExit,e=>a.waitForExit(e.params.terminalId)).onRequest(dE.client.terminal.kill,async e=>(await a.kill(e.params.terminalId),{})).onRequest(dE.client.terminal.release,async e=>(await a.release(e.params.terminalId),{})).onNotification(dE.client.session.update,t=>this.handleSessionUpdate(e,t.params)).connect(s);e.conn=c,c.closed.then(()=>{!e.closed&&e.info.archived!==!0&&e.info.status!==`exited`&&e.info.status!==`error`&&this.emitStatus(e,`exited`,`agent connection closed`)},t=>{this.opts.log.warn({err:t,threadId:e.info.threadId},`[acp-threads] agent connection closed with error`),!e.closed&&e.info.archived!==!0&&e.info.status!==`exited`&&e.info.status!==`error`&&this.emitStatus(e,`error`,`agent connection failed: ${t instanceof Error?t.message:String(t)}`)});let l;try{l=await c.agent.request(dE.agent.initialize,{protocolVersion:1,clientInfo:{name:`open-knowledge`,title:`Open Knowledge`,version:tQ},clientCapabilities:{fs:{readTextFile:!0,writeTextFile:!0},terminal:!0,session:{configOptions:{boolean:{}}}}})}catch(t){throw this.opts.log.warn({err:t,threadId:e.info.threadId},`[acp-threads] initialize failed`),new IQ(`spawn-failed`,`initialize failed: ${RQ(t)}`)}return e.closed?null:(e.lastInit=l,e.info.promptCapabilities=l.agentCapabilities?.promptCapabilities??{},this.emitInfo(e),{conn:c,init:l,launch:n})}async ensureLaunchable(e,t){let n;try{await hQ(t),n=await this.withLoginShellPathIfEligible(t)}catch(r){if(!(r instanceof uQ)||r.code!==`command-not-found`)throw r;let i=await this.retryWithLoginShellPath(t);if(i===null)return this.fallbackToManagedRuntime(e,t,r);n=i}return e.closed?null:this.ensureInterpreterRuns(e,n)}async ensureInterpreterRuns(e,t){if(t.kind!==`npx`&&t.kind!==`uvx`)return t;let n=await this.probeInterpreterOnce(t);if(e.closed)return null;if(n===null)return t;if(n.kind===`incompatible`){let n=await this.withPreferredLoginShellPathIfEligible(t);if(e.closed)return null;if(_Q(n.env)!==_Q(t.env))try{await hQ(n);let t=await this.probeInterpreterOnce(n);if(e.closed)return null;if(t===null)return this.opts.log.info({threadId:e.info.threadId,agentId:e.info.agent.id},`[acp-threads] compatible Node resolved via the preferred login-shell PATH`),n;this.opts.log.debug({threadId:e.info.threadId,agentId:e.info.agent.id,cmd:n.cmd,kind:n.kind,failureKind:t.kind,detail:t.detail},`[acp-threads] preferred login-shell PATH did not provide a compatible Node`)}catch(e){if(!(e instanceof uQ)||e.code!==`command-not-found`)throw e}}this.opts.log.warn({threadId:e.info.threadId,agentId:e.info.agent.id,cmd:t.cmd,kind:t.kind,failureKind:n.kind,detail:n.detail},`[acp-threads] interpreter cannot run this agent — offering the managed runtime`);let r=new uQ(`command-not-found`,n.kind===`incompatible`?JWe(t,n.detail):VWe(t,n.detail));return this.fallbackToManagedRuntime(e,t,r,r)}async fallbackToManagedRuntime(e,t,n,r){if(t.kind!==`npx`&&t.kind!==`uvx`)throw n;let i=iGe(t.kind);if(!uGe(i))throw n;let a=await this.provideManagedRuntime(e,i,r===void 0?`missing`:`broken`).catch(e=>{throw r!==void 0&&e instanceof uQ&&e.code===`command-not-found`?r:e});if(a===null)return null;let o=AWe(t,a);await hQ(o);let s=await this.probeInterpreterOnce(o);if(s===null)return o;if(s.kind===`incompatible`)throw new uQ(`install-failed`,UWe(s.detail));return this.repairManagedRuntime(e,t,i,s.detail)}async repairManagedRuntime(e,t,n,r){let i={threadId:e.info.threadId,agentId:e.info.agent.id,runtime:n,detail:r};if(this.opts.log.warn(i,`[acp-threads] OK's own managed runtime failed to run — replacing it`),!await hGe(n,this.opts.log,this.opts.runtimeInstall?.root))throw new uQ(`install-failed`,WWe(t,r));let a=await this.provideManagedRuntime(e,n,`damaged`).catch(e=>{throw e instanceof uQ&&e.code===`command-not-found`?new uQ(`command-not-found`,GWe(t)):e});if(a===null)return null;let o=AWe(t,a);await hQ(o);let s=await this.probeInterpreterOnce(o);if(s===null)return o;throw this.opts.log.error({...i,detail:s.detail},`[acp-threads] a freshly downloaded managed runtime failed to run`),new uQ(`install-failed`,s.kind===`incompatible`?UWe(s.detail):HWe(o,s.detail))}async probeInterpreterOnce(e){let t=JSON.stringify([e.cmd,_Q(e.env)??``]);if(this.healthyInterpreters.has(t))return null;let n=await KWe(e,void 0,this.opts.log);if(n!==null)return{kind:`unhealthy`,detail:n};if(e.kind===`npx`){let t=await qWe(e,void 0,this.opts.log);if(t!==null)return{kind:`incompatible`,detail:t}}return this.healthyInterpreters.add(t),null}async retryWithLoginShellPath(e){let t=await this.withLoginShellPathIfEligible(e);if(_Q(t.env)===_Q(e.env))return null;try{await hQ(t)}catch(t){if(!(t instanceof uQ))throw t;return this.opts.log.debug({cmd:e.cmd,kind:e.kind},`[acp] login-shell PATH did not resolve the command either`),null}return this.opts.log.info({cmd:e.cmd,kind:e.kind},`[acp] command resolved via the login-shell PATH; skipping the managed-runtime offer`),t}async withLoginShellPathIfEligible(e){if(e.pathFromOverlay||vQ(e.cmd))return e;let t=await this.resolveLoginShellPath().catch(()=>null);return t===null?e:jWe(e,t)}async withPreferredLoginShellPathIfEligible(e){if(e.pathFromOverlay||vQ(e.cmd))return e;let t=await this.resolveLoginShellPath().catch(()=>null);return t===null?e:MWe(e,t)}async provideManagedRuntime(e,t,n){let r=this.opts.runtimeInstall?.root;await mGe(t,this.opts.log,r);let i=await pGe(t,r).catch(()=>null);if(i!==null)return i;let a=await this.requestRuntimeConsent(e,t,n);if(a===`closed`||e.closed)return null;if(a!==`granted`)throw new uQ(`command-not-found`,WGe(t));try{let n=await this.downloadRuntime(e,t);return e.closed?null:n}catch(e){let n=DQ(t).displayName;throw new uQ(`install-failed`,`couldn't install ${n}: ${e instanceof Error?e.message:String(e)}`)}}requestRuntimeConsent(e,t,n){let r=crypto.randomUUID(),i=DQ(t);return this.appendEvent(e,{kind:`runtime_consent_request`,requestId:r,runtime:t,displayName:i.displayName,provides:i.provides,version:i.version,approxSizeMB:i.approxSizeMB,sourceHost:i.sourceHost,agentName:e.info.agent.name,reason:n,ts:Date.now()}),new Promise(t=>{let n=setTimeout(()=>{e.pendingRuntimeConsent.delete(r),this.appendEvent(e,{kind:`runtime_consent_resolved`,requestId:r,decision:`timeout`,ts:Date.now()}),t(`timeout`)},PQ);n.unref?.(),e.pendingRuntimeConsent.set(r,{resolve:t,timer:n})})}respondRuntimeConsent(e,t,n){let r=this.mustGet(e),i=r.pendingRuntimeConsent.get(t);if(i===void 0)return;r.pendingRuntimeConsent.delete(t),clearTimeout(i.timer);let a=n.kind===`granted`?`granted`:`declined`;this.appendEvent(r,{kind:`runtime_consent_resolved`,requestId:t,decision:a,ts:Date.now()}),i.resolve(a)}async downloadRuntime(e,t){this.emitStatus(e,`installing`);let n=0;return gGe(t,this.opts.log,{root:this.opts.runtimeInstall?.root,fetchImpl:this.opts.runtimeInstall?.fetchImpl,onProgress:r=>{let i=Date.now();i-n<400||(n=i,!e.closed&&this.appendEvent(e,{kind:`runtime_install_progress`,runtime:t,phase:`downloading`,receivedBytes:r.receivedBytes,totalBytes:r.totalBytes??void 0,ts:i}))}})}async buildMcpServers(e,t,n=PQ){let r=[],i;if(zGe(e.agentRef))i=await this.settlePiBridge(e,n)===`unavailable`?`none`:`unknown`;else if(await this.harnessAlreadyHasOkMcp(e)!==null)i=`unknown`;else{let e=this.opts.getServerUrl?.();if(e!==void 0&&t.agentCapabilities?.mcpCapabilities?.http===!0)r.push({type:`http`,name:`open-knowledge`,url:`${e}/mcp`,headers:[{name:VUe,value:`1`}]}),i=`http-header`;else{let e=this.opts.getMcpStdioCommand?.(),t=EWe();e==null?i=`none`:(r.push({name:`open-knowledge`,command:e.command,args:[...e.args],env:[{name:$r,value:`1`},...t!==void 0&&t!==``?[{name:`PATH`,value:t}]:[]]}),i=`stdio-entry-env`)}}return i===`none`?this.opts.log.warn({threadId:e.info.threadId,agentId:e.agentRef.id},`[acp-threads] no OK MCP transport available for this agent — it starts without OK tools`):this.opts.log.info({threadId:e.info.threadId,agentId:e.agentRef.id,hostedMarker:i},`[acp-threads] OK MCP injection outcome`),{servers:r,hostedMarker:i}}async harnessAlreadyHasOkMcp(e){let t=this.opts.probeHarnessManagedMcpEntry;if(t===void 0||e.agentRef.source!==`registry`)return null;let n=lJ[e.agentRef.id];if(n===void 0)return null;let r;try{r=await t(n,e.cwd)}catch(t){return this.opts.log.warn({err:t,threadId:e.info.threadId,editorId:n},`[acp-threads] harness MCP-config probe failed — injecting OK MCP`),null}return r!==null&&this.opts.log.info({threadId:e.info.threadId,agentId:e.agentRef.id,editorId:r.editorId,scope:r.scope,configPath:r.configPath},`[acp-threads] skipping OK MCP injection — the agent's harness already loads OK's managed entry`),r}async settlePiBridge(e,t){let n=this.opts.probePiAcpBridge,r=e.info.threadId;if(n===void 0)return this.opts.log.debug({threadId:r,agentId:e.agentRef.id},`[acp-threads] no Pi bridge probe wired — OK tools depend on whether the project was already wired`),`unknown`;let i;try{i=await n(e.cwd)}catch(e){return this.opts.log.warn({err:e,threadId:r},`[acp-threads] Pi bridge probe failed`),`unknown`}if(e.closed)return`unknown`;if(i.bridgeLoadable)return this.opts.log.info({threadId:r,bridge:i.bridge,bridgePath:i.bridgePath},`[acp-threads] Pi already loads the OK bridge extension for this project`),`loadable`;if(i.bridge===`foreign`||i.bridge===`unreadable`)return this.opts.log.warn({threadId:r,bridge:i.bridge,bridgePath:i.bridgePath},`[acp-threads] OK can't claim the Pi bridge path — leaving it alone; this thread has no OK tools`),this.emitPiBridgeStatus(e,{kind:`pi_bridge_status`,state:i.bridge===`foreign`?`foreign-file`:`unreadable-file`,bridgePath:i.bridgePath,ts:Date.now()}),`unavailable`;if(e.piBridgeDeclined)return this.opts.log.debug({threadId:r},`[acp-threads] Pi bridge prompt already declined for this thread — not re-asking`),`unavailable`;let a=this.opts.ensurePiAcpBridge;if(a===void 0)return this.opts.log.warn({threadId:r},`[acp-threads] Pi bridge is not provisioned and no provisioning seam is wired — not prompting`),`unavailable`;let o=crypto.randomUUID(),s=await this.requestPiBridgeConsent(e,o,i,t);if(s===`declined`&&(e.piBridgeDeclined=!0),e.closed)return`unknown`;if(s!==`granted`)return this.opts.log.info({threadId:r,decision:s},`[acp-threads] Pi bridge not provisioned — the thread continues without OK tools`),`unavailable`;let c;try{c=await a(e.cwd)}catch(t){let n=t instanceof Error?t.message:String(t);return this.opts.log.warn({err:t,threadId:r},`[acp-threads] Pi bridge provisioning threw`),this.appendPiBridgeFailure(e,o,`bridge-failed`,i.bridgePath,{detail:n}),`unavailable`}if(c.ok)return this.opts.log.info({threadId:r,bridge:c.bridge,trust:c.trust,bridgePath:c.bridgePath},`[acp-threads] provisioned the Pi bridge extension for this project`),e.closed?`unknown`:(this.appendEvent(e,{kind:`pi_bridge_status`,requestId:o,state:`ready`,bridgePath:c.bridgePath,bridge:c.bridge,trust:c.trust,ts:Date.now()}),`loadable`);let l=c.bridge===`written`||c.bridge===`refreshed`||c.bridge===`unchanged`,u=c.bridge===`refused-foreign`?`foreign-file`:c.bridge===`refused-unreadable`?`unreadable-file`:l?`trust-failed`:`bridge-failed`;return this.opts.log.warn({threadId:r,bridge:c.bridge,trust:c.trust,bridgePath:c.bridgePath,err:c.error},`[acp-threads] Pi bridge provisioning did not complete — the thread continues without OK tools`),this.appendPiBridgeFailure(e,o,u,c.bridgePath,{bridge:c.bridge,trust:c.trust,...c.error===void 0?{}:{detail:c.error}}),`unavailable`}appendPiBridgeFailure(e,t,n,r,i){e.closed||this.appendEvent(e,{kind:`pi_bridge_status`,requestId:t,state:n,bridgePath:r,...i,ts:Date.now()})}emitPiBridgeStatus(e,t){e.lastPiBridgeStatus!==t.state&&(e.lastPiBridgeStatus=t.state,this.appendEvent(e,t))}requestPiBridgeConsent(e,t,n,r){return this.appendEvent(e,{kind:`pi_bridge_consent_request`,requestId:t,agentName:e.info.agent.name,bridgePath:n.bridgePath,cwd:e.cwd,otherExtensions:n.otherExtensions,ts:Date.now()}),new Promise(n=>{let i=setTimeout(()=>{e.pendingPiBridgeConsent.delete(t),this.appendEvent(e,{kind:`pi_bridge_consent_resolved`,requestId:t,decision:`timeout`,ts:Date.now()}),n(`timeout`)},r);i.unref?.(),e.pendingPiBridgeConsent.set(t,{resolve:n,timer:i})})}respondPiBridgeConsent(e,t,n){let r=this.mustGet(e),i=r.pendingPiBridgeConsent.get(t);if(i===void 0)return;r.pendingPiBridgeConsent.delete(t),clearTimeout(i.timer);let a=n.kind===`granted`?`granted`:`declined`;this.appendEvent(r,{kind:`pi_bridge_consent_resolved`,requestId:t,decision:a,ts:Date.now()}),i.resolve(a)}async startThread(e,t,n,r=PQ){let i;try{i=await this.connectAgent(e,n)}catch(t){let n=t instanceof uQ||t instanceof IQ?t.message:String(t);this.emitStatus(e,`error`,n,{reason:`connect`,agentMessage:n,machineDetail:BQ(e)}),await this.teardownFailedAgent(e);return}if(i===null)return;let{conn:a,init:o,launch:s}=i;await this.openSession(e,a,o,t.settings,`park`,r)===!0&&(this.opts.log.info({threadId:e.info.threadId,agentId:e.info.agent.id,launchKind:s.kind,msToReady:Date.now()-e.info.createdAt},`[acp-threads] agent ready`),(t.prompt!==void 0&&t.prompt!==``||t.attachments!==void 0&&t.attachments.length>0)&&this.sendPrompt(e.info.threadId,t.prompt??``,t.attachments))}async openSession(e,t,n,r,i=`park`,a=PQ){e.info.availableCommands=null;let{servers:o}=await this.buildMcpServers(e,n,a);try{let n=await t.agent.request(dE.agent.session.new,{cwd:e.cwd,mcpServers:o});e.sessionId=n.sessionId,e.envNotePending=!0,this.persistence.queueMetaWrite(e.info.threadId,this.buildMeta(e)),n.modes!==void 0&&n.modes!==null&&(e.info.modes=n.modes,this.emitInfo(e)),n.configOptions!==void 0&&n.configOptions!==null&&(e.info.configOptions=n.configOptions,this.emitInfo(e))}catch(t){if(GGe(t)){if(i===`report`)return`auth-required`;this.emitStatus(e,`auth_required`,`sign in required: ${RQ(t)}`,{reason:`auth-required`,agentMessage:RQ(t),machineDetail:HQ(t,e),authMethods:UQ(n.authMethods)})}else this.emitStatus(e,`error`,`session setup failed: ${RQ(t)}`,{reason:`session-setup`,agentMessage:RQ(t),machineDetail:VQ(zQ(t),BQ(e))}),await this.teardownFailedAgent(e);return!1}return e.closed||r?.config!==void 0&&(await this.applyInitialConfig(e,t,r.config),e.closed)||r?.modeId!==void 0&&(await this.applyInitialMode(e,t,r.modeId),e.closed)?!1:(this.emitStatus(e,`ready`),!0)}async resumeThread(e,t,n){if(this.destroyed)throw new IQ(`capacity`,`server is shutting down`);let r=this.mustGet(e);if(r.info.archived!==!0)throw new IQ(`not-ready`,`thread is not archived`);if(r.resumeInFlight)throw new IQ(`not-ready`,`a resume is already in progress`);if(this.liveThreadCount()>=this.maxThreads)throw new IQ(`capacity`,`maximum of ${this.maxThreads} concurrent agent threads`);r.resumeInFlight=!0;let i=Date.now();try{await this.ensureLogResolved(r);let a=r.sessionId,{info:o,custom:s}=await this.resolveAgentInfo(r.agentRef);if(this.destroyed)throw new IQ(`capacity`,`server is shutting down`);if(this.liveThreadCount()>=this.maxThreads)throw new IQ(`capacity`,`maximum of ${this.maxThreads} concurrent agent threads`);r.info.agent=o,r.info.archived=!1,r.info.availableCommands=null,r.stderrTail=[],r.midTurnOnDisk&&(r.midTurnOnDisk=!1,this.appendEvent(r,{kind:`turn_ended`,stopReason:`cancelled`,ts:Date.now()}));let c=t!==void 0&&t!==``||n!==void 0&&n.length>0;c&&(this.echoUserMessage(r,t??``,n),this.flushBroadcast(r)),this.emitStatus(r,`installing`);try{if(a===null)throw new IQ(`resume-unsupported`,`this thread never completed an agent session`);let o=await this.connectAgent(r,s);if(o===null)throw new IQ(`not-ready`,`thread closed during resume`);let{conn:l,init:u}=o,{servers:d}=await this.buildMcpServers(r,u,FQ),f=u.agentCapabilities,p=f?.sessionCapabilities?.resume!=null,m;if(p)m=await l.agent.request(dE.agent.session.resume,{sessionId:a,cwd:r.cwd,mcpServers:d});else if(f?.loadSession===!0){r.suppressUpdates=!0,r.lastSuppressedAt=Date.now();try{m=await l.agent.request(dE.agent.session.load,{sessionId:a,cwd:r.cwd,mcpServers:d}),await this.awaitReplayQuiescence(r)}finally{r.suppressUpdates=!1}}else throw new IQ(`resume-unsupported`,`${r.info.agent.name} doesn't support resuming previous sessions`);r.sessionId=a;let h=Object.fromEntries((r.info.configOptions??[]).map(e=>[e.id,e.currentValue])),g=r.info.modes?.currentModeId,_=m.modes;_!=null&&(r.info.modes=_);let v=m.configOptions;if(v!=null&&(r.info.configOptions=v),await this.applyInitialConfig(r,l,h,v==null),r.closed||g!==void 0&&(await this.applyInitialMode(r,l,g,_==null),r.closed))throw new IQ(`not-ready`,`thread closed during resume`);return this.emitStatus(r,`ready`),this.opts.log.info({threadId:e,agentId:r.info.agent.id,method:p?`session/resume`:`session/load`,msToResumed:Date.now()-i},`[acp-threads] thread resumed`),c&&this.dispatchPrompt(r,t??``,n,{echo:!1}),{...r.info}}catch(t){throw await this.abortResume(r),t instanceof IQ?t:t instanceof uQ?new IQ(t.code===`install-failed`?`install-failed`:`spawn-failed`,t.message):(this.opts.log.warn({err:t,threadId:e},`[acp-threads] resume rejected by the agent`),new IQ(`resume-unsupported`,`couldn't resume the previous session: ${RQ(t)}`))}}finally{r.resumeInFlight=!1}}async retryThread(e){if(this.destroyed)throw new IQ(`capacity`,`server is shutting down`);let t=this.mustGet(e);if(t.info.archived===!0)throw new IQ(`not-ready`,`the thread is archived — resume it instead`);if(t.info.status!==`error`&&t.info.status!==`auth_required`&&!t.authInFlight)throw new IQ(`not-ready`,`this thread did not fail to start`);if(t.sessionId!==null)throw new IQ(`not-ready`,`this thread already has an agent session`);if(t.resumeInFlight)throw new IQ(`not-ready`,`a retry is already in progress`);t.resumeInFlight=!0;try{bWe(),this.healthyInterpreters.clear();let{info:n,custom:r}=await this.resolveAgentInfo(t.agentRef);await this.teardownFailedAgent(t),t.info.agent=n,t.stderrTail=[],t.cancelRequested=!1,t.turnActive=!1,this.emitStatus(t,`installing`);try{await this.startThread(t,{agent:t.agentRef,settings:t.launchSettings},r,FQ)}catch(e){let n=e instanceof Error?e.message:String(e);throw this.emitStatus(t,`error`,n,{reason:`connect`,agentMessage:n}),new IQ(`spawn-failed`,n)}if(t.closed)throw new IQ(`not-ready`,`thread closed during retry`);let i=this.getInfo(e)?.status;if(i===`ready`||i===`running`)return this.opts.log.info({threadId:e,agentId:t.info.agent.id},`[acp-threads] thread retry succeeded`),{...t.info};throw new IQ(`spawn-failed`,KGe(t)??`the agent failed to start`)}finally{t.resumeInFlight=!1}}async authenticateThread(e,t){if(this.destroyed)throw new IQ(`capacity`,`server is shutting down`);let n=this.mustGet(e);if(n.info.archived===!0)throw new IQ(`not-ready`,`the thread is archived — resume it instead`);if(n.info.status!==`auth_required`)throw new IQ(`not-ready`,`this thread is not waiting for a sign-in`);let r=n.conn,i=n.lastInit;if(r===null||i===null||n.child===null)throw new IQ(`not-ready`,`${n.info.agent.name} is no longer running — use Retry to start it again`);if(n.resumeInFlight)throw new IQ(`not-ready`,`the thread is starting over — wait for the retry`);if(n.authInFlight)throw new IQ(`not-ready`,`a sign-in is already in progress`);n.authInFlight=!0,n.authStderr=[],n.info.signInOutput=void 0;try{this.emitStatus(n,`authenticating`);try{await this.requestAuthenticate(r,t)}catch(e){if(n.conn!==r)throw RGe();let t=e instanceof IGe?`the sign-in didn't complete in time — try again`:RQ(e);throw this.emitStatus(n,`auth_required`,`sign-in failed: ${t}`,{reason:`auth-required`,agentMessage:t,machineDetail:HQ(e,n),authMethods:UQ(i.authMethods)}),new IQ(`not-ready`,t)}if(n.closed)throw new IQ(`not-ready`,`thread closed during sign-in`);if(n.conn!==r)throw RGe();let a=await this.openSession(n,r,i,n.launchSettings,`report`,FQ);if(a===`auth-required`){this.opts.log.info({threadId:e,agentId:n.info.agent.id,methodId:t},`[acp-threads] signed in but session still refused — relaunching the agent`),this.closeSignInCapture(n);try{return await this.retryThread(e)}catch(t){throw this.getInfo(e)?.status===`authenticating`&&this.emitStatus(n,`auth_required`,`sign in required: ${RQ(t)}`,{reason:`auth-required`,agentMessage:RQ(t),machineDetail:HQ(t,n),authMethods:UQ(i.authMethods)}),t}}if(a!==!0)throw new IQ(`not-ready`,KGe(n)??`${n.info.agent.name} still couldn't start a conversation`);return this.opts.log.info({threadId:e,agentId:n.info.agent.id,methodId:t},`[acp-threads] thread signed in`),{...n.info}}finally{n.authInFlight=!1,this.closeSignInCapture(n)}}async requestAuthenticate(e,t){let n,r=new Promise((e,t)=>{n=setTimeout(()=>t(new IGe),this.authenticateTimeoutMs),n.unref?.()});try{await Promise.race([e.agent.request(dE.agent.authenticate,{methodId:t}),r])}finally{n!==void 0&&clearTimeout(n)}}async abortResume(e){e.closed=!0,e.suppressUpdates=!1,this.failPendingPermissions(e),this.failPendingConsents(e);try{e.conn?.close()}catch{}let t=e.child;t!==null&&await wQ(t,{graceMs:FGe}),e.child=null,e.conn=null,e.lastInit=null,e.closed=!1,e.turnActive=!1,this.opts.agentPresenceBroadcaster?.clearPresence(yJ(e.agentSessionId)),e.info.archived=!0,this.emitStatus(e,`exited`,`resume failed`),this.flushBroadcast(e),this.persistence.queueMetaWrite(e.info.threadId,this.buildMeta(e)),await this.persistence.whenIdle(e.info.threadId),e.baseSeq=e.info.lastSeq+1,e.events=[]}async awaitReplayQuiescence(e){let t=Date.now()+3e3;for(;Date.now()-e.lastSuppressedAt<300&&Date.now()<t;)await new Promise(e=>setTimeout(e,50))}sendPrompt(e,t,n){let r=this.mustGet(e);if(r.info.archived===!0)throw new IQ(`not-ready`,`the thread is archived — resume it first`);if(r.resumeInFlight)throw new IQ(`not-ready`,`the thread is still resuming`);if(r.authInFlight)throw new IQ(`not-ready`,`the thread is still signing in`);if(r.sessionId===null||r.conn===null)throw new IQ(`not-ready`,`thread has no live agent session`);if(r.turnActive){let e=r.info.queue??[];if(e.length>=20)throw new IQ(`not-ready`,`20 messages are already waiting — let the agent catch up`);let i={id:crypto.randomUUID(),content:t,ts:Date.now()};n!==void 0&&n.length>0&&(i.attachments=n),r.info.queue=[...e,i],r.info.lastActivityAt=Date.now(),this.emitInfo(r);return}this.dispatchPrompt(r,t,n,{echo:!0})}steerPrompt(e,t,n){let r=this.mustGet(e);if(r.info.archived===!0)throw new IQ(`not-ready`,`the thread is archived — resume it first`);if(r.resumeInFlight)throw new IQ(`not-ready`,`the thread is still resuming`);if(r.authInFlight)throw new IQ(`not-ready`,`the thread is still signing in`);if(r.sessionId===null||r.conn===null)throw new IQ(`not-ready`,`thread has no live agent session`);if(!r.turnActive){this.dispatchPrompt(r,t,n,{echo:!0});return}this.clearSteer(r);let i={content:t,ts:Date.now()};n!==void 0&&n.length>0&&(i.attachments=n),r.info.steer=i,r.info.lastActivityAt=Date.now(),this.emitInfo(r);let a=setTimeout(()=>this.demoteStalledSteer(r),this.steerStallMs);a.unref?.(),r.steerStallTimer=a,this.cancelTurn(r,{clearQueue:!1})}demoteStalledSteer(e){e.steerStallTimer=null;let t=e.info.steer;if(t===void 0||e.closed||!e.turnActive)return;e.info.steer=void 0;let n={id:crypto.randomUUID(),content:t.content,ts:t.ts};t.attachments!==void 0&&t.attachments.length>0&&(n.attachments=t.attachments),e.info.queue=[n,...e.info.queue??[]],this.emitInfo(e)}clearSteer(e){e.steerStallTimer!==null&&(clearTimeout(e.steerStallTimer),e.steerStallTimer=null),e.info.steer=void 0}takeSteer(e){let t=e.info.steer;return t===void 0?null:(this.clearSteer(e),t)}editQueued(e,t,n){let r=this.mustGet(e),i=r.info.queue??[];return i.some(e=>e.id===t)?(r.info.queue=i.map(e=>e.id===t?{...e,content:n,held:!1}:e),this.emitInfo(r),this.drainIfIdle(r),!0):!1}holdQueued(e,t,n){let r=this.mustGet(e),i=r.info.queue??[];return i.some(e=>e.id===t)?(r.info.queue=i.map(e=>e.id===t?{...e,held:n}:e),this.emitInfo(r),n||this.drainIfIdle(r),!0):!1}removeQueued(e,t){let n=this.mustGet(e),r=n.info.queue??[],i=r.filter(e=>e.id!==t);return i.length!==r.length&&(n.info.queue=i.length>0?i:void 0,this.emitInfo(n),!0)}drainIfIdle(e){if(e.turnActive||e.closed||e.resumeInFlight||e.info.archived===!0||e.sessionId===null||e.conn===null)return;let t=this.takeNextQueued(e);t!==null&&this.dispatchPrompt(e,t.content,t.attachments,{echo:!0})}takeNextQueued(e){let t=e.info.queue;if(t===void 0||t.length===0)return null;let n=t.findIndex(e=>e.held!==!0);if(n===-1)return null;let r=t[n],i=[...t.slice(0,n),...t.slice(n+1)];return e.info.queue=i.length>0?i:void 0,r??null}echoUserMessage(e,t,n){if(e.hadUserMessage=!0,e.info.title===e.info.agent.name&&t.trim()!==``){let n=e.titleHint!==void 0&&e.titleHint.trim()!==``?e.titleHint:t;e.titleHint=void 0,e.info.title=jGe(n,e.info.agent.name),this.appendEvent(e,{kind:`title_changed`,title:e.info.title,ts:Date.now()}),this.emitInfo(e)}let r={kind:`user_message`,content:t,ts:Date.now()};n!==void 0&&n.length>0&&(r.attachments=n),this.appendEvent(e,r)}async renameThread(e,t){let n=this.mustGet(e);if(n.closed)throw new IQ(`not-ready`,`the thread is closing`);let r=NQ(t);r!==``&&r!==n.info.title&&(await this.ensureLogResolved(n),n.info.title=r,n.info.lastActivityAt=Date.now(),this.appendEvent(n,{kind:`title_changed`,title:r,ts:Date.now()}),this.flushBroadcast(n),this.emitInfo(n),await this.persistence.whenIdle(n.info.threadId))}dispatchPrompt(e,t,n,r){if(e.sessionId===null||e.conn===null)throw new IQ(`not-ready`,`thread has no live agent session`);r.echo&&this.echoUserMessage(e,t,n);let i=t;e.envNotePending&&!t.startsWith(`/`)&&(e.envNotePending=!1,i=`Note on your environment: you are running inside the OpenKnowledge app, connected over ACP (Agent Client Protocol) — not inside your own terminal app. Your host CLI's terminal UI is not present, so its built-in slash commands (such as /tasks or /bashes) and keyboard shortcuts (such as Ctrl+O) do not exist here; never recommend them. The only slash commands available to the user are the ones you advertise over ACP.\n\n${t}`),e.turnActive=!0,e.cancelRequested=!1,this.appendEvent(e,{kind:`turn_started`,ts:Date.now()}),this.emitStatus(e,`running`);let a=e.sessionId;YUe(i,n,e.info.promptCapabilities,e=>this.confinePath(e).then(({abs:e,rel:t})=>({abs:e,rel:t}))).then(t=>{if(t.dropped.length>0){this.opts.log.warn({threadId:e.info.threadId,dropped:t.dropped.map(e=>({kind:e.part.kind,reason:e.reason}))},`[acp-threads] dropped attachment parts before session/prompt`);let n=Date.now();for(let r of t.dropped){let t=r.part.kind===`image`||r.part.kind===`blob`?r.part.name:r.part.name||r.part.path;this.appendEvent(e,{kind:`agent_stderr`,line:`[attachment dropped] ${t}: ${r.reason}`,ts:n})}}if(e.sessionId===null||e.conn===null)throw new IQ(`not-ready`,`thread has no live agent session`);if(e.cancelRequested)throw new LGe;return e.conn.agent.request(dE.agent.session.prompt,{sessionId:a,prompt:[...t.blocks]})}).then(t=>{if(e.turnActive=!1,!e.closed){if(this.appendEvent(e,{kind:`turn_ended`,stopReason:t.stopReason,ts:Date.now()}),e.sessionId!==null&&e.conn!==null){let t=this.takeSteer(e);if(t!==null){this.dispatchPrompt(e,t.content,t.attachments,{echo:!0});return}let n=this.takeNextQueued(e);if(n!==null){this.dispatchPrompt(e,n.content,n.attachments,{echo:!0});return}}this.emitStatus(e,`ready`)}}).catch(t=>{if(e.turnActive=!1,!e.closed){if(this.appendEvent(e,{kind:`turn_ended`,stopReason:`cancelled`,ts:Date.now()}),e.sessionId!==null&&e.conn!==null){let t=this.takeSteer(e);if(t!==null){this.dispatchPrompt(e,t.content,t.attachments,{echo:!0});return}}if(e.cancelRequested){this.emitStatus(e,`ready`),this.drainIfIdle(e);return}if(GGe(t)){this.emitStatus(e,`auth_required`,`sign in required: ${RQ(t)}`,{reason:`auth-required`,agentMessage:RQ(t),machineDetail:HQ(t,e),authMethods:UQ(e.lastInit?.authMethods)});return}this.emitStatus(e,`error`,`prompt failed: ${RQ(t)}`,{reason:`prompt`,agentMessage:RQ(t),machineDetail:VQ(zQ(t),BQ(e))})}})}cancel(e){this.cancelTurn(this.mustGet(e),{clearQueue:!0})}cancelTurn(e,t){t.clearQueue&&(e.info.queue!==void 0||e.info.steer!==void 0)&&(e.info.queue=void 0,this.clearSteer(e),this.emitInfo(e)),e.conn!==null&&e.sessionId!==null&&(e.turnActive&&(e.cancelRequested=!0),this.failPendingPermissions(e),this.restoreRunningAfterPermission(e),e.conn.agent.notify(dE.agent.session.cancel,{sessionId:e.sessionId}).catch(t=>{this.opts.log.debug({err:t,threadId:e.info.threadId},`[acp-threads] cancel notification never reached the agent`)}))}setMode(e,t){let n=this.mustGet(e);if(n.info.archived===!0){let e=n.info.modes;if(e==null||!e.availableModes.some(e=>e.id===t))throw new IQ(`not-ready`,`no such mode: ${t}`);n.info.modes={...e,currentModeId:t},this.emitInfo(n);return}if(n.resumeInFlight)throw new IQ(`not-ready`,`the thread is still resuming`);if(n.conn===null||n.sessionId===null)throw new IQ(`not-ready`,`thread has no live agent session`);n.conn.agent.request(dE.agent.session.setMode,{sessionId:n.sessionId,modeId:t}).then(()=>{n.info.modes&&(n.info.modes={...n.info.modes,currentModeId:t},this.emitInfo(n))}).catch(t=>{this.opts.log.warn({err:t,threadId:e},`[acp-threads] set_mode failed`)})}setConfigOption(e,t,n){let r=this.mustGet(e);if(r.info.archived===!0){let e=(r.info.configOptions??[]).find(e=>e.id===t);if(e===void 0)throw new IQ(`not-ready`,`no such config option: ${t}`);if(!LQ(e,n))throw new IQ(`not-ready`,`invalid value for ${t}`);r.info.configOptions=(r.info.configOptions??[]).map(e=>e.id===t?{...e,currentValue:n}:e),this.emitInfo(r);return}if(r.resumeInFlight)throw new IQ(`not-ready`,`the thread is still resuming`);if(r.conn===null||r.sessionId===null)throw new IQ(`not-ready`,`thread has no live agent session`);let i=typeof n==`boolean`?{sessionId:r.sessionId,configId:t,type:`boolean`,value:n}:{sessionId:r.sessionId,configId:t,value:n};r.conn.agent.request(dE.agent.session.setConfigOption,i).then(e=>{r.info.configOptions=e.configOptions,this.emitInfo(r)}).catch(n=>{this.opts.log.warn({err:n,threadId:e,configId:t},`[acp-threads] set_config_option failed`)})}async applyInitialConfig(e,t,n,r=!1){let i=e.sessionId;if(i===null)return;let a=t=>(e.info.configOptions??[]).find(e=>e.id===t)?.category===`model`,o=Object.keys(n).sort((e,t)=>Number(a(t))-Number(a(e))),s=!1,c=[];for(let a of o){let o=n[a];if(o===void 0)continue;let l=(e.info.configOptions??[]).find(e=>e.id===a);if(l===void 0||!r&&l.currentValue===o||!LQ(l,o))continue;let u=typeof o==`boolean`?{sessionId:i,configId:a,type:`boolean`,value:o}:{sessionId:i,configId:a,value:o};try{let n=await t.agent.request(dE.agent.session.setConfigOption,u);e.info.configOptions=n.configOptions,s=!0}catch(t){c.push(a),this.opts.log.warn({err:t,threadId:e.info.threadId,configId:a},`[acp-threads] initial config apply failed`)}if(e.closed)return}c.length>0&&this.opts.log.warn({threadId:e.info.threadId,rejectedConfigIds:c,sessionStateUnknown:r},`[acp-threads] some remembered config options could not be applied to the new session`),s&&this.emitInfo(e)}async applyInitialMode(e,t,n,r=!1){let i=e.sessionId;if(i===null)return;let a=e.info.modes;if(a!=null&&a.availableModes.some(e=>e.id===n)){if(!r&&a.currentModeId===n)return;try{await t.agent.request(dE.agent.session.setMode,{sessionId:i,modeId:n}),e.info.modes={...a,currentModeId:n},this.emitInfo(e)}catch(t){this.opts.log.warn({err:t,threadId:e.info.threadId,modeId:n,method:`set_mode`},`[acp-threads] initial mode apply failed`)}return}let o=(e.info.configOptions??[]).find(e=>e.category===`mode`&&LQ(e,n));if(o!==void 0&&!(!r&&o.currentValue===n))try{let r=await t.agent.request(dE.agent.session.setConfigOption,{sessionId:i,configId:o.id,value:n});e.info.configOptions=r.configOptions,this.emitInfo(e)}catch(t){this.opts.log.warn({err:t,threadId:e.info.threadId,modeId:n,method:`set_config_option`},`[acp-threads] initial mode apply failed`)}}respondPermission(e,t,n){let r=this.mustGet(e),i=r.pendingPermissions.get(t);i!==void 0&&(r.pendingPermissions.delete(t),clearTimeout(i.timer),n.kind===`selected`?(i.resolve({outcome:{outcome:`selected`,optionId:n.optionId}}),this.appendEvent(r,{kind:`permission_resolved`,requestId:t,optionId:n.optionId,auto:!1,ts:Date.now()})):(i.resolve({outcome:{outcome:`cancelled`}}),this.appendEvent(r,{kind:`permission_resolved`,requestId:t,optionId:null,auto:!1,ts:Date.now()})),this.restoreRunningAfterPermission(r))}restoreRunningAfterPermission(e){e.pendingPermissions.size===0&&e.turnActive&&e.info.status===`awaiting_permission`&&this.emitStatus(e,`running`)}async closeThread(e,t){let n=this.threads.get(e);if(n===void 0||n.info.archived===!0||n.closed)return;n.closed=!0,this.clearSteer(n),this.failPendingPermissions(n),this.failPendingConsents(n);try{n.conn?.close()}catch{}let r=n.child;r!==null&&(await wQ(r,{graceMs:t?.killGraceMs??PGe})||this.opts.log.error({threadId:e,pid:r.pid},`[acp-threads] agent process survived SIGKILL escalation`)),n.child=null,n.conn=null,n.lastInit=null,await n.terminals?.disposeAll(),n.terminals=null,this.opts.agentPresenceBroadcaster?.clearPresence(yJ(n.agentSessionId)),await this.opts.sessionManager.closeAllForAgent(n.agentSessionId).catch(t=>{this.opts.log.warn({err:t,threadId:e},`[acp-threads] session cleanup failed`)});let i=n.info.status===`error`||n.info.status===`auth_required`;if(!n.hadUserMessage&&!i){this.threads.delete(e),n.subscribers.clear(),n.flushTimer!==null&&(clearTimeout(n.flushTimer),n.flushTimer=null),await this.persistence.whenIdle(e),await this.persistence.delete(e),this.opts.log.info({threadId:e},`[acp-threads] empty thread discarded on close`);return}n.turnActive&&(n.turnActive=!1,this.appendEvent(n,{kind:`turn_ended`,stopReason:`cancelled`,ts:Date.now()})),n.info.archived=!0,this.emitStatus(n,`exited`,`thread closed`),this.flushBroadcast(n),this.persistence.queueMetaWrite(e,this.buildMeta(n)),await this.persistence.whenIdle(e),n.baseSeq=n.info.lastSeq+1,n.events=[],n.pendingBroadcast=[],n.closed=!1,this.opts.log.info({threadId:e},`[acp-threads] thread archived`)}async deleteThread(e){let t=this.mustGet(e);if(t.info.archived!==!0)throw new IQ(`not-ready`,`close the thread before deleting it`);if(t.resumeInFlight)throw new IQ(`not-ready`,`a resume is in progress`);this.threads.delete(e),t.subscribers.clear(),t.flushTimer!==null&&(clearTimeout(t.flushTimer),t.flushTimer=null),await this.persistence.whenIdle(e),await this.persistence.delete(e),this.opts.log.info({threadId:e},`[acp-threads] thread deleted`)}async destroy(){this.destroyed=!0,clearInterval(this.reapTimer),await Promise.allSettled([...this.threads.keys()].map(e=>this.closeThread(e,{killGraceMs:FGe})))}async handlePermissionRequest(e,t,n){e.info.lastActivityAt=Date.now();let r=this.opts.permissions.decide(e.info.agent.id,t,n);if(r.auto!==null){let t=crypto.randomUUID();return this.appendEvent(e,{kind:`permission_resolved`,requestId:t,optionId:r.auto.optionId,auto:!0,ts:Date.now()}),{outcome:{outcome:`selected`,optionId:r.auto.optionId}}}let i=crypto.randomUUID();return this.appendEvent(e,{kind:`permission_request`,requestId:i,toolCall:t,options:n,ts:Date.now()}),e.turnActive&&e.info.status===`running`&&this.emitStatus(e,`awaiting_permission`),new Promise(r=>{let a=setTimeout(()=>{e.pendingPermissions.delete(i),this.appendEvent(e,{kind:`permission_resolved`,requestId:i,optionId:null,auto:!0,ts:Date.now()}),this.restoreRunningAfterPermission(e),r({outcome:{outcome:`cancelled`}})},6e5);a.unref?.(),e.pendingPermissions.set(i,{timer:a,resolve:i=>{if(i.outcome.outcome===`selected`){let r=n.find(e=>i.outcome.outcome===`selected`&&e.optionId===i.outcome.optionId);r!==void 0&&this.opts.permissions.recordChoice(e.info.agent.id,t,r)}r(i)}})})}handleSessionUpdate(e,t){e.info.lastActivityAt=Date.now();let n=t.update;if(n.sessionUpdate===`current_mode_update`&&e.info.modes&&(e.info.modes={...e.info.modes,currentModeId:n.currentModeId},this.emitInfo(e)),n.sessionUpdate===`config_option_update`&&(e.info.configOptions=n.configOptions,this.emitInfo(e)),n.sessionUpdate===`available_commands_update`&&(e.info.availableCommands=n.availableCommands,this.emitInfo(e)),e.suppressUpdates){e.lastSuppressedAt=Date.now();return}this.appendEvent(e,{kind:`session_update`,update:ZUe(n),ts:Date.now()})}async handleFsRead(e,t,n){let r=await this.confinePath(e),i;if(i=r.docName===null?await Gs(r.abs,`utf8`):this.opts.getLoadedDocText?.(r.docName)??await Gs(r.abs,`utf8`),t!==null||n!==null){let e=i.split(`
|
|
822
|
+
`);this.opts.log.warn({threadId:e.info.threadId,agentId:e.info.agent.id,code:t,signal:n,machineDetail:BQ(e)},`[acp-threads] agent exited unexpectedly`),this.emitStatus(e,`exited`,`agent exited (${n??t??`unknown`})${r?`\n${r}`:``}`),this.failPendingPermissions(e)}),o.stdin===null||o.stdout===null)throw new IQ(`spawn-failed`,`agent process has no stdio`);let s=cge(Qs.toWeb(o.stdin),Zs.toWeb(o.stdout)),c=Bge({name:`open-knowledge`}).onRequest(dE.client.session.requestPermission,t=>this.handlePermissionRequest(e,t.params.toolCall,t.params.options)).onRequest(dE.client.fs.readTextFile,e=>this.handleFsRead(e.params.path,e.params.line??null,e.params.limit??null)).onRequest(dE.client.fs.writeTextFile,async t=>(await this.handleFsWrite(e,t.params.path,t.params.content),{})).onRequest(dE.client.terminal.create,t=>(e.info.lastActivityAt=Date.now(),a.create(t.params))).onRequest(dE.client.terminal.output,e=>a.output(e.params.terminalId)).onRequest(dE.client.terminal.waitForExit,e=>a.waitForExit(e.params.terminalId)).onRequest(dE.client.terminal.kill,async e=>(await a.kill(e.params.terminalId),{})).onRequest(dE.client.terminal.release,async e=>(await a.release(e.params.terminalId),{})).onNotification(dE.client.session.update,t=>this.handleSessionUpdate(e,t.params)).connect(s);e.conn=c,c.closed.then(()=>{!e.closed&&e.info.archived!==!0&&e.info.status!==`exited`&&e.info.status!==`error`&&this.emitStatus(e,`exited`,`agent connection closed`)},t=>{this.opts.log.warn({err:t,threadId:e.info.threadId},`[acp-threads] agent connection closed with error`),!e.closed&&e.info.archived!==!0&&e.info.status!==`exited`&&e.info.status!==`error`&&this.emitStatus(e,`error`,`agent connection failed: ${t instanceof Error?t.message:String(t)}`)});let l;try{l=await c.agent.request(dE.agent.initialize,{protocolVersion:1,clientInfo:{name:`open-knowledge`,title:`Open Knowledge`,version:tQ},clientCapabilities:{fs:{readTextFile:!0,writeTextFile:!0},terminal:!0,session:{configOptions:{boolean:{}}}}})}catch(t){throw this.opts.log.warn({err:t,threadId:e.info.threadId},`[acp-threads] initialize failed`),new IQ(`spawn-failed`,`initialize failed: ${RQ(t)}`)}return e.closed?null:(e.lastInit=l,e.info.promptCapabilities=l.agentCapabilities?.promptCapabilities??{},this.emitInfo(e),{conn:c,init:l,launch:n})}async ensureLaunchable(e,t){let n;try{await hQ(t),n=await this.withLoginShellPathIfEligible(t)}catch(r){if(!(r instanceof uQ)||r.code!==`command-not-found`)throw r;let i=await this.retryWithLoginShellPath(t);if(i===null)return this.fallbackToManagedRuntime(e,t,r);n=i}return e.closed?null:this.ensureInterpreterRuns(e,n)}async ensureInterpreterRuns(e,t){if(t.kind!==`npx`&&t.kind!==`uvx`)return t;let n=await this.probeInterpreterOnce(t);if(e.closed)return null;if(n===null)return t;if(n.kind===`incompatible`){let n=await this.withPreferredLoginShellPathIfEligible(t);if(e.closed)return null;if(_Q(n.env)!==_Q(t.env))try{await hQ(n);let t=await this.probeInterpreterOnce(n);if(e.closed)return null;if(t===null)return this.opts.log.info({threadId:e.info.threadId,agentId:e.info.agent.id},`[acp-threads] compatible Node resolved via the preferred login-shell PATH`),n;this.opts.log.debug({threadId:e.info.threadId,agentId:e.info.agent.id,cmd:n.cmd,kind:n.kind,failureKind:t.kind,detail:t.detail},`[acp-threads] preferred login-shell PATH did not provide a compatible Node`)}catch(e){if(!(e instanceof uQ)||e.code!==`command-not-found`)throw e}}this.opts.log.warn({threadId:e.info.threadId,agentId:e.info.agent.id,cmd:t.cmd,kind:t.kind,failureKind:n.kind,detail:n.detail},`[acp-threads] interpreter cannot run this agent — offering the managed runtime`);let r=new uQ(`command-not-found`,n.kind===`incompatible`?JWe(t,n.detail):VWe(t,n.detail));return this.fallbackToManagedRuntime(e,t,r,r)}async fallbackToManagedRuntime(e,t,n,r){if(t.kind!==`npx`&&t.kind!==`uvx`)throw n;let i=iGe(t.kind);if(!uGe(i))throw n;let a=await this.provideManagedRuntime(e,i,r===void 0?`missing`:`broken`).catch(e=>{throw r!==void 0&&e instanceof uQ&&e.code===`command-not-found`?r:e});if(a===null)return null;let o=AWe(t,a);await hQ(o);let s=await this.probeInterpreterOnce(o);if(s===null)return o;if(s.kind===`incompatible`)throw new uQ(`install-failed`,UWe(s.detail));return this.repairManagedRuntime(e,t,i,s.detail)}async repairManagedRuntime(e,t,n,r){let i={threadId:e.info.threadId,agentId:e.info.agent.id,runtime:n,detail:r};if(this.opts.log.warn(i,`[acp-threads] OK's own managed runtime failed to run — replacing it`),!await hGe(n,this.opts.log,this.opts.runtimeInstall?.root))throw new uQ(`install-failed`,WWe(t,r));let a=await this.provideManagedRuntime(e,n,`damaged`).catch(e=>{throw e instanceof uQ&&e.code===`command-not-found`?new uQ(`command-not-found`,GWe(t)):e});if(a===null)return null;let o=AWe(t,a);await hQ(o);let s=await this.probeInterpreterOnce(o);if(s===null)return o;throw this.opts.log.error({...i,detail:s.detail},`[acp-threads] a freshly downloaded managed runtime failed to run`),new uQ(`install-failed`,s.kind===`incompatible`?UWe(s.detail):HWe(o,s.detail))}async probeInterpreterOnce(e){let t=JSON.stringify([e.cmd,_Q(e.env)??``]);if(this.healthyInterpreters.has(t))return null;let n=await KWe(e,void 0,this.opts.log);if(n!==null)return{kind:`unhealthy`,detail:n};if(e.kind===`npx`){let t=await qWe(e,void 0,this.opts.log);if(t!==null)return{kind:`incompatible`,detail:t}}return this.healthyInterpreters.add(t),null}async retryWithLoginShellPath(e){let t=await this.withLoginShellPathIfEligible(e);if(_Q(t.env)===_Q(e.env))return null;try{await hQ(t)}catch(t){if(!(t instanceof uQ))throw t;return this.opts.log.debug({cmd:e.cmd,kind:e.kind},`[acp] login-shell PATH did not resolve the command either`),null}return this.opts.log.info({cmd:e.cmd,kind:e.kind},`[acp] command resolved via the login-shell PATH; skipping the managed-runtime offer`),t}async withLoginShellPathIfEligible(e){if(e.pathFromOverlay||vQ(e.cmd))return e;let t=await this.resolveLoginShellPath().catch(()=>null);return t===null?e:jWe(e,t)}async withPreferredLoginShellPathIfEligible(e){if(e.pathFromOverlay||vQ(e.cmd))return e;let t=await this.resolveLoginShellPath().catch(()=>null);return t===null?e:MWe(e,t)}async provideManagedRuntime(e,t,n){let r=this.opts.runtimeInstall?.root;await mGe(t,this.opts.log,r);let i=await pGe(t,r).catch(()=>null);if(i!==null)return i;let a=await this.requestRuntimeConsent(e,t,n);if(a===`closed`||e.closed)return null;if(a!==`granted`)throw new uQ(`command-not-found`,WGe(t));try{let n=await this.downloadRuntime(e,t);return e.closed?null:n}catch(e){let n=DQ(t).displayName;throw new uQ(`install-failed`,`couldn't install ${n}: ${e instanceof Error?e.message:String(e)}`)}}requestRuntimeConsent(e,t,n){let r=crypto.randomUUID(),i=DQ(t);return this.appendEvent(e,{kind:`runtime_consent_request`,requestId:r,runtime:t,displayName:i.displayName,provides:i.provides,version:i.version,approxSizeMB:i.approxSizeMB,sourceHost:i.sourceHost,agentName:e.info.agent.name,reason:n,ts:Date.now()}),new Promise(t=>{let n=setTimeout(()=>{e.pendingRuntimeConsent.delete(r),this.appendEvent(e,{kind:`runtime_consent_resolved`,requestId:r,decision:`timeout`,ts:Date.now()}),t(`timeout`)},PQ);n.unref?.(),e.pendingRuntimeConsent.set(r,{resolve:t,timer:n})})}respondRuntimeConsent(e,t,n){let r=this.mustGet(e),i=r.pendingRuntimeConsent.get(t);if(i===void 0)return;r.pendingRuntimeConsent.delete(t),clearTimeout(i.timer);let a=n.kind===`granted`?`granted`:`declined`;this.appendEvent(r,{kind:`runtime_consent_resolved`,requestId:t,decision:a,ts:Date.now()}),i.resolve(a)}async downloadRuntime(e,t){this.emitStatus(e,`installing`);let n=0;return gGe(t,this.opts.log,{root:this.opts.runtimeInstall?.root,fetchImpl:this.opts.runtimeInstall?.fetchImpl,onProgress:r=>{let i=Date.now();i-n<400||(n=i,!e.closed&&this.appendEvent(e,{kind:`runtime_install_progress`,runtime:t,phase:`downloading`,receivedBytes:r.receivedBytes,totalBytes:r.totalBytes??void 0,ts:i}))}})}async buildMcpServers(e,t,n=PQ){let r=[],i;if(zGe(e.agentRef))i=await this.settlePiBridge(e,n)===`unavailable`?`none`:`unknown`;else if(await this.harnessAlreadyHasOkMcp(e)!==null)i=`unknown`;else{let e=this.opts.getServerUrl?.();if(e!==void 0&&t.agentCapabilities?.mcpCapabilities?.http===!0)r.push({type:`http`,name:`open-knowledge`,url:`${e}/mcp`,headers:[{name:VUe,value:`1`}]}),i=`http-header`;else{let e=this.opts.getMcpStdioCommand?.(),t=EWe();e==null?i=`none`:(r.push({name:`open-knowledge`,command:e.command,args:[...e.args],env:[{name:$r,value:`1`},...t!==void 0&&t!==``?[{name:`PATH`,value:t}]:[]]}),i=`stdio-entry-env`)}}return i===`none`?this.opts.log.warn({threadId:e.info.threadId,agentId:e.agentRef.id},`[acp-threads] no OK MCP transport available for this agent — it starts without OK tools`):this.opts.log.info({threadId:e.info.threadId,agentId:e.agentRef.id,hostedMarker:i},`[acp-threads] OK MCP injection outcome`),{servers:r,hostedMarker:i}}async harnessAlreadyHasOkMcp(e){let t=this.opts.probeHarnessManagedMcpEntry;if(t===void 0||e.agentRef.source!==`registry`)return null;let n=lJ[e.agentRef.id];if(n===void 0)return null;let r;try{r=await t(n,e.cwd)}catch(t){return this.opts.log.warn({err:t,threadId:e.info.threadId,editorId:n},`[acp-threads] harness MCP-config probe failed — injecting OK MCP`),null}return r!==null&&this.opts.log.info({threadId:e.info.threadId,agentId:e.agentRef.id,editorId:r.editorId,scope:r.scope,configPath:r.configPath},`[acp-threads] skipping OK MCP injection — the agent's harness already loads OK's managed entry`),r}async settlePiBridge(e,t){let n=this.opts.probePiAcpBridge,r=e.info.threadId;if(n===void 0)return this.opts.log.debug({threadId:r,agentId:e.agentRef.id},`[acp-threads] no Pi bridge probe wired — OK tools depend on whether the project was already wired`),`unknown`;let i;try{i=await n(e.cwd)}catch(e){return this.opts.log.warn({err:e,threadId:r},`[acp-threads] Pi bridge probe failed`),`unknown`}if(e.closed)return`unknown`;if(i.project===`unavailable`)return this.opts.log.warn({threadId:r,cwd:i.cwd,err:Error(i.error)},`[acp-threads] Pi project folder is unavailable; this thread has no OK tools`),this.emitPiBridgeStatus(e,{kind:`pi_bridge_status`,state:`project-path-unavailable`,bridgePath:i.bridgePath,detail:i.error,ts:Date.now()}),`unavailable`;if(i.bridgeLoadable)return this.opts.log.info({threadId:r,bridge:i.bridge,bridgePath:i.bridgePath},`[acp-threads] Pi already loads the OK bridge extension for this project`),`loadable`;if(i.bridge===`foreign`||i.bridge===`unreadable`)return this.opts.log.warn({threadId:r,bridge:i.bridge,bridgePath:i.bridgePath},`[acp-threads] OK can't claim the Pi bridge path — leaving it alone; this thread has no OK tools`),this.emitPiBridgeStatus(e,{kind:`pi_bridge_status`,state:i.bridge===`foreign`?`foreign-file`:`unreadable-file`,bridgePath:i.bridgePath,ts:Date.now()}),`unavailable`;if(e.piBridgeDeclined)return this.opts.log.debug({threadId:r},`[acp-threads] Pi bridge prompt already declined for this thread — not re-asking`),`unavailable`;let a=this.opts.ensurePiAcpBridge;if(a===void 0)return this.opts.log.warn({threadId:r},`[acp-threads] Pi bridge is not provisioned and no provisioning seam is wired — not prompting`),`unavailable`;let o=crypto.randomUUID(),s=await this.requestPiBridgeConsent(e,o,i,t);if(s===`declined`&&(e.piBridgeDeclined=!0),e.closed)return`unknown`;if(s!==`granted`)return this.opts.log.info({threadId:r,decision:s},`[acp-threads] Pi bridge not provisioned — the thread continues without OK tools`),`unavailable`;let c;try{c=await a(e.cwd,i.canonicalCwd)}catch(t){let n=t instanceof Error?t.message:String(t);return this.opts.log.warn({err:t,threadId:r},`[acp-threads] Pi bridge provisioning threw`),this.appendPiBridgeFailure(e,o,`bridge-failed`,i.bridgePath,{detail:n}),`unavailable`}if(c.ok)return this.opts.log.info({threadId:r,bridge:c.bridge,trust:c.trust,bridgePath:c.bridgePath},`[acp-threads] provisioned the Pi bridge extension for this project`),e.closed?`unknown`:(this.appendEvent(e,{kind:`pi_bridge_status`,requestId:o,state:`ready`,bridgePath:c.bridgePath,bridge:c.bridge,trust:c.trust,ts:Date.now()}),`loadable`);let l=c.bridge===`written`||c.bridge===`refreshed`||c.bridge===`unchanged`,u=c.bridge===`refused-project-path`?`project-path-unavailable`:c.bridge===`refused-foreign`?`foreign-file`:c.bridge===`refused-unreadable`?`unreadable-file`:l?`trust-failed`:`bridge-failed`;return this.opts.log.warn({threadId:r,bridge:c.bridge,trust:c.trust,bridgePath:c.bridgePath,err:c.error},`[acp-threads] Pi bridge provisioning did not complete — the thread continues without OK tools`),this.appendPiBridgeFailure(e,o,u,c.bridgePath,{bridge:c.bridge,trust:c.trust,...c.error===void 0?{}:{detail:c.error}}),`unavailable`}appendPiBridgeFailure(e,t,n,r,i){e.closed||this.appendEvent(e,{kind:`pi_bridge_status`,requestId:t,state:n,bridgePath:r,...i,ts:Date.now()})}emitPiBridgeStatus(e,t){e.lastPiBridgeStatus!==t.state&&(e.lastPiBridgeStatus=t.state,this.appendEvent(e,t))}requestPiBridgeConsent(e,t,n,r){return this.appendEvent(e,{kind:`pi_bridge_consent_request`,requestId:t,agentName:e.info.agent.name,bridgePath:n.bridgePath,cwd:n.canonicalCwd,otherExtensions:n.otherExtensions,ts:Date.now()}),new Promise(n=>{let i=setTimeout(()=>{e.pendingPiBridgeConsent.delete(t),this.appendEvent(e,{kind:`pi_bridge_consent_resolved`,requestId:t,decision:`timeout`,ts:Date.now()}),n(`timeout`)},r);i.unref?.(),e.pendingPiBridgeConsent.set(t,{resolve:n,timer:i})})}respondPiBridgeConsent(e,t,n){let r=this.mustGet(e),i=r.pendingPiBridgeConsent.get(t);if(i===void 0)return;r.pendingPiBridgeConsent.delete(t),clearTimeout(i.timer);let a=n.kind===`granted`?`granted`:`declined`;this.appendEvent(r,{kind:`pi_bridge_consent_resolved`,requestId:t,decision:a,ts:Date.now()}),i.resolve(a)}async startThread(e,t,n,r=PQ){let i;try{i=await this.connectAgent(e,n)}catch(t){let n=t instanceof uQ||t instanceof IQ?t.message:String(t);this.emitStatus(e,`error`,n,{reason:`connect`,agentMessage:n,machineDetail:BQ(e)}),await this.teardownFailedAgent(e);return}if(i===null)return;let{conn:a,init:o,launch:s}=i;await this.openSession(e,a,o,t.settings,`park`,r)===!0&&(this.opts.log.info({threadId:e.info.threadId,agentId:e.info.agent.id,launchKind:s.kind,msToReady:Date.now()-e.info.createdAt},`[acp-threads] agent ready`),(t.prompt!==void 0&&t.prompt!==``||t.attachments!==void 0&&t.attachments.length>0)&&this.sendPrompt(e.info.threadId,t.prompt??``,t.attachments))}async openSession(e,t,n,r,i=`park`,a=PQ){e.info.availableCommands=null;let{servers:o}=await this.buildMcpServers(e,n,a);try{let n=await t.agent.request(dE.agent.session.new,{cwd:e.cwd,mcpServers:o});e.sessionId=n.sessionId,e.envNotePending=!0,this.persistence.queueMetaWrite(e.info.threadId,this.buildMeta(e)),n.modes!==void 0&&n.modes!==null&&(e.info.modes=n.modes,this.emitInfo(e)),n.configOptions!==void 0&&n.configOptions!==null&&(e.info.configOptions=n.configOptions,this.emitInfo(e))}catch(t){if(GGe(t)){if(i===`report`)return`auth-required`;this.emitStatus(e,`auth_required`,`sign in required: ${RQ(t)}`,{reason:`auth-required`,agentMessage:RQ(t),machineDetail:HQ(t,e),authMethods:UQ(n.authMethods)})}else this.emitStatus(e,`error`,`session setup failed: ${RQ(t)}`,{reason:`session-setup`,agentMessage:RQ(t),machineDetail:VQ(zQ(t),BQ(e))}),await this.teardownFailedAgent(e);return!1}return e.closed||r?.config!==void 0&&(await this.applyInitialConfig(e,t,r.config),e.closed)||r?.modeId!==void 0&&(await this.applyInitialMode(e,t,r.modeId),e.closed)?!1:(this.emitStatus(e,`ready`),!0)}async resumeThread(e,t,n){if(this.destroyed)throw new IQ(`capacity`,`server is shutting down`);let r=this.mustGet(e);if(r.info.archived!==!0)throw new IQ(`not-ready`,`thread is not archived`);if(r.resumeInFlight)throw new IQ(`not-ready`,`a resume is already in progress`);if(this.liveThreadCount()>=this.maxThreads)throw new IQ(`capacity`,`maximum of ${this.maxThreads} concurrent agent threads`);r.resumeInFlight=!0;let i=Date.now();try{await this.ensureLogResolved(r);let a=r.sessionId,{info:o,custom:s}=await this.resolveAgentInfo(r.agentRef);if(this.destroyed)throw new IQ(`capacity`,`server is shutting down`);if(this.liveThreadCount()>=this.maxThreads)throw new IQ(`capacity`,`maximum of ${this.maxThreads} concurrent agent threads`);r.info.agent=o,r.info.archived=!1,r.info.availableCommands=null,r.stderrTail=[],r.midTurnOnDisk&&(r.midTurnOnDisk=!1,this.appendEvent(r,{kind:`turn_ended`,stopReason:`cancelled`,ts:Date.now()}));let c=t!==void 0&&t!==``||n!==void 0&&n.length>0;c&&(this.echoUserMessage(r,t??``,n),this.flushBroadcast(r)),this.emitStatus(r,`installing`);try{if(a===null)throw new IQ(`resume-unsupported`,`this thread never completed an agent session`);let o=await this.connectAgent(r,s);if(o===null)throw new IQ(`not-ready`,`thread closed during resume`);let{conn:l,init:u}=o,{servers:d}=await this.buildMcpServers(r,u,FQ),f=u.agentCapabilities,p=f?.sessionCapabilities?.resume!=null,m;if(p)m=await l.agent.request(dE.agent.session.resume,{sessionId:a,cwd:r.cwd,mcpServers:d});else if(f?.loadSession===!0){r.suppressUpdates=!0,r.lastSuppressedAt=Date.now();try{m=await l.agent.request(dE.agent.session.load,{sessionId:a,cwd:r.cwd,mcpServers:d}),await this.awaitReplayQuiescence(r)}finally{r.suppressUpdates=!1}}else throw new IQ(`resume-unsupported`,`${r.info.agent.name} doesn't support resuming previous sessions`);r.sessionId=a;let h=Object.fromEntries((r.info.configOptions??[]).map(e=>[e.id,e.currentValue])),g=r.info.modes?.currentModeId,_=m.modes;_!=null&&(r.info.modes=_);let v=m.configOptions;if(v!=null&&(r.info.configOptions=v),await this.applyInitialConfig(r,l,h,v==null),r.closed||g!==void 0&&(await this.applyInitialMode(r,l,g,_==null),r.closed))throw new IQ(`not-ready`,`thread closed during resume`);return this.emitStatus(r,`ready`),this.opts.log.info({threadId:e,agentId:r.info.agent.id,method:p?`session/resume`:`session/load`,msToResumed:Date.now()-i},`[acp-threads] thread resumed`),c&&this.dispatchPrompt(r,t??``,n,{echo:!1}),{...r.info}}catch(t){throw await this.abortResume(r),t instanceof IQ?t:t instanceof uQ?new IQ(t.code===`install-failed`?`install-failed`:`spawn-failed`,t.message):(this.opts.log.warn({err:t,threadId:e},`[acp-threads] resume rejected by the agent`),new IQ(`resume-unsupported`,`couldn't resume the previous session: ${RQ(t)}`))}}finally{r.resumeInFlight=!1}}async retryThread(e){if(this.destroyed)throw new IQ(`capacity`,`server is shutting down`);let t=this.mustGet(e);if(t.info.archived===!0)throw new IQ(`not-ready`,`the thread is archived — resume it instead`);if(t.info.status!==`error`&&t.info.status!==`auth_required`&&!t.authInFlight)throw new IQ(`not-ready`,`this thread did not fail to start`);if(t.sessionId!==null)throw new IQ(`not-ready`,`this thread already has an agent session`);if(t.resumeInFlight)throw new IQ(`not-ready`,`a retry is already in progress`);t.resumeInFlight=!0;try{bWe(),this.healthyInterpreters.clear();let{info:n,custom:r}=await this.resolveAgentInfo(t.agentRef);await this.teardownFailedAgent(t),t.info.agent=n,t.stderrTail=[],t.cancelRequested=!1,t.turnActive=!1,this.emitStatus(t,`installing`);try{await this.startThread(t,{agent:t.agentRef,settings:t.launchSettings},r,FQ)}catch(e){let n=e instanceof Error?e.message:String(e);throw this.emitStatus(t,`error`,n,{reason:`connect`,agentMessage:n}),new IQ(`spawn-failed`,n)}if(t.closed)throw new IQ(`not-ready`,`thread closed during retry`);let i=this.getInfo(e)?.status;if(i===`ready`||i===`running`)return this.opts.log.info({threadId:e,agentId:t.info.agent.id},`[acp-threads] thread retry succeeded`),{...t.info};throw new IQ(`spawn-failed`,KGe(t)??`the agent failed to start`)}finally{t.resumeInFlight=!1}}async authenticateThread(e,t){if(this.destroyed)throw new IQ(`capacity`,`server is shutting down`);let n=this.mustGet(e);if(n.info.archived===!0)throw new IQ(`not-ready`,`the thread is archived — resume it instead`);if(n.info.status!==`auth_required`)throw new IQ(`not-ready`,`this thread is not waiting for a sign-in`);let r=n.conn,i=n.lastInit;if(r===null||i===null||n.child===null)throw new IQ(`not-ready`,`${n.info.agent.name} is no longer running — use Retry to start it again`);if(n.resumeInFlight)throw new IQ(`not-ready`,`the thread is starting over — wait for the retry`);if(n.authInFlight)throw new IQ(`not-ready`,`a sign-in is already in progress`);n.authInFlight=!0,n.authStderr=[],n.info.signInOutput=void 0;try{this.emitStatus(n,`authenticating`);try{await this.requestAuthenticate(r,t)}catch(e){if(n.conn!==r)throw RGe();let t=e instanceof IGe?`the sign-in didn't complete in time — try again`:RQ(e);throw this.emitStatus(n,`auth_required`,`sign-in failed: ${t}`,{reason:`auth-required`,agentMessage:t,machineDetail:HQ(e,n),authMethods:UQ(i.authMethods)}),new IQ(`not-ready`,t)}if(n.closed)throw new IQ(`not-ready`,`thread closed during sign-in`);if(n.conn!==r)throw RGe();let a=await this.openSession(n,r,i,n.launchSettings,`report`,FQ);if(a===`auth-required`){this.opts.log.info({threadId:e,agentId:n.info.agent.id,methodId:t},`[acp-threads] signed in but session still refused — relaunching the agent`),this.closeSignInCapture(n);try{return await this.retryThread(e)}catch(t){throw this.getInfo(e)?.status===`authenticating`&&this.emitStatus(n,`auth_required`,`sign in required: ${RQ(t)}`,{reason:`auth-required`,agentMessage:RQ(t),machineDetail:HQ(t,n),authMethods:UQ(i.authMethods)}),t}}if(a!==!0)throw new IQ(`not-ready`,KGe(n)??`${n.info.agent.name} still couldn't start a conversation`);return this.opts.log.info({threadId:e,agentId:n.info.agent.id,methodId:t},`[acp-threads] thread signed in`),{...n.info}}finally{n.authInFlight=!1,this.closeSignInCapture(n)}}async requestAuthenticate(e,t){let n,r=new Promise((e,t)=>{n=setTimeout(()=>t(new IGe),this.authenticateTimeoutMs),n.unref?.()});try{await Promise.race([e.agent.request(dE.agent.authenticate,{methodId:t}),r])}finally{n!==void 0&&clearTimeout(n)}}async abortResume(e){e.closed=!0,e.suppressUpdates=!1,this.failPendingPermissions(e),this.failPendingConsents(e);try{e.conn?.close()}catch{}let t=e.child;t!==null&&await wQ(t,{graceMs:FGe}),e.child=null,e.conn=null,e.lastInit=null,e.closed=!1,e.turnActive=!1,this.opts.agentPresenceBroadcaster?.clearPresence(yJ(e.agentSessionId)),e.info.archived=!0,this.emitStatus(e,`exited`,`resume failed`),this.flushBroadcast(e),this.persistence.queueMetaWrite(e.info.threadId,this.buildMeta(e)),await this.persistence.whenIdle(e.info.threadId),e.baseSeq=e.info.lastSeq+1,e.events=[]}async awaitReplayQuiescence(e){let t=Date.now()+3e3;for(;Date.now()-e.lastSuppressedAt<300&&Date.now()<t;)await new Promise(e=>setTimeout(e,50))}sendPrompt(e,t,n){let r=this.mustGet(e);if(r.info.archived===!0)throw new IQ(`not-ready`,`the thread is archived — resume it first`);if(r.resumeInFlight)throw new IQ(`not-ready`,`the thread is still resuming`);if(r.authInFlight)throw new IQ(`not-ready`,`the thread is still signing in`);if(r.sessionId===null||r.conn===null)throw new IQ(`not-ready`,`thread has no live agent session`);if(r.turnActive){let e=r.info.queue??[];if(e.length>=20)throw new IQ(`not-ready`,`20 messages are already waiting — let the agent catch up`);let i={id:crypto.randomUUID(),content:t,ts:Date.now()};n!==void 0&&n.length>0&&(i.attachments=n),r.info.queue=[...e,i],r.info.lastActivityAt=Date.now(),this.emitInfo(r);return}this.dispatchPrompt(r,t,n,{echo:!0})}steerPrompt(e,t,n){let r=this.mustGet(e);if(r.info.archived===!0)throw new IQ(`not-ready`,`the thread is archived — resume it first`);if(r.resumeInFlight)throw new IQ(`not-ready`,`the thread is still resuming`);if(r.authInFlight)throw new IQ(`not-ready`,`the thread is still signing in`);if(r.sessionId===null||r.conn===null)throw new IQ(`not-ready`,`thread has no live agent session`);if(!r.turnActive){this.dispatchPrompt(r,t,n,{echo:!0});return}this.clearSteer(r);let i={content:t,ts:Date.now()};n!==void 0&&n.length>0&&(i.attachments=n),r.info.steer=i,r.info.lastActivityAt=Date.now(),this.emitInfo(r);let a=setTimeout(()=>this.demoteStalledSteer(r),this.steerStallMs);a.unref?.(),r.steerStallTimer=a,this.cancelTurn(r,{clearQueue:!1})}demoteStalledSteer(e){e.steerStallTimer=null;let t=e.info.steer;if(t===void 0||e.closed||!e.turnActive)return;e.info.steer=void 0;let n={id:crypto.randomUUID(),content:t.content,ts:t.ts};t.attachments!==void 0&&t.attachments.length>0&&(n.attachments=t.attachments),e.info.queue=[n,...e.info.queue??[]],this.emitInfo(e)}clearSteer(e){e.steerStallTimer!==null&&(clearTimeout(e.steerStallTimer),e.steerStallTimer=null),e.info.steer=void 0}takeSteer(e){let t=e.info.steer;return t===void 0?null:(this.clearSteer(e),t)}editQueued(e,t,n){let r=this.mustGet(e),i=r.info.queue??[];return i.some(e=>e.id===t)?(r.info.queue=i.map(e=>e.id===t?{...e,content:n,held:!1}:e),this.emitInfo(r),this.drainIfIdle(r),!0):!1}holdQueued(e,t,n){let r=this.mustGet(e),i=r.info.queue??[];return i.some(e=>e.id===t)?(r.info.queue=i.map(e=>e.id===t?{...e,held:n}:e),this.emitInfo(r),n||this.drainIfIdle(r),!0):!1}removeQueued(e,t){let n=this.mustGet(e),r=n.info.queue??[],i=r.filter(e=>e.id!==t);return i.length!==r.length&&(n.info.queue=i.length>0?i:void 0,this.emitInfo(n),!0)}drainIfIdle(e){if(e.turnActive||e.closed||e.resumeInFlight||e.info.archived===!0||e.sessionId===null||e.conn===null)return;let t=this.takeNextQueued(e);t!==null&&this.dispatchPrompt(e,t.content,t.attachments,{echo:!0})}takeNextQueued(e){let t=e.info.queue;if(t===void 0||t.length===0)return null;let n=t.findIndex(e=>e.held!==!0);if(n===-1)return null;let r=t[n],i=[...t.slice(0,n),...t.slice(n+1)];return e.info.queue=i.length>0?i:void 0,r??null}echoUserMessage(e,t,n){if(e.hadUserMessage=!0,e.info.title===e.info.agent.name&&t.trim()!==``){let n=e.titleHint!==void 0&&e.titleHint.trim()!==``?e.titleHint:t;e.titleHint=void 0,e.info.title=jGe(n,e.info.agent.name),this.appendEvent(e,{kind:`title_changed`,title:e.info.title,ts:Date.now()}),this.emitInfo(e)}let r={kind:`user_message`,content:t,ts:Date.now()};n!==void 0&&n.length>0&&(r.attachments=n),this.appendEvent(e,r)}async renameThread(e,t){let n=this.mustGet(e);if(n.closed)throw new IQ(`not-ready`,`the thread is closing`);let r=NQ(t);r!==``&&r!==n.info.title&&(await this.ensureLogResolved(n),n.info.title=r,n.info.lastActivityAt=Date.now(),this.appendEvent(n,{kind:`title_changed`,title:r,ts:Date.now()}),this.flushBroadcast(n),this.emitInfo(n),await this.persistence.whenIdle(n.info.threadId))}dispatchPrompt(e,t,n,r){if(e.sessionId===null||e.conn===null)throw new IQ(`not-ready`,`thread has no live agent session`);r.echo&&this.echoUserMessage(e,t,n);let i=t;e.envNotePending&&!t.startsWith(`/`)&&(e.envNotePending=!1,i=`Note on your environment: you are running inside the OpenKnowledge app, connected over ACP (Agent Client Protocol) — not inside your own terminal app. Your host CLI's terminal UI is not present, so its built-in slash commands (such as /tasks or /bashes) and keyboard shortcuts (such as Ctrl+O) do not exist here; never recommend them. The only slash commands available to the user are the ones you advertise over ACP.\n\n${t}`),e.turnActive=!0,e.cancelRequested=!1,this.appendEvent(e,{kind:`turn_started`,ts:Date.now()}),this.emitStatus(e,`running`);let a=e.sessionId;YUe(i,n,e.info.promptCapabilities,e=>this.confinePath(e).then(({abs:e,rel:t})=>({abs:e,rel:t}))).then(t=>{if(t.dropped.length>0){this.opts.log.warn({threadId:e.info.threadId,dropped:t.dropped.map(e=>({kind:e.part.kind,reason:e.reason}))},`[acp-threads] dropped attachment parts before session/prompt`);let n=Date.now();for(let r of t.dropped){let t=r.part.kind===`image`||r.part.kind===`blob`?r.part.name:r.part.name||r.part.path;this.appendEvent(e,{kind:`agent_stderr`,line:`[attachment dropped] ${t}: ${r.reason}`,ts:n})}}if(e.sessionId===null||e.conn===null)throw new IQ(`not-ready`,`thread has no live agent session`);if(e.cancelRequested)throw new LGe;return e.conn.agent.request(dE.agent.session.prompt,{sessionId:a,prompt:[...t.blocks]})}).then(t=>{if(e.turnActive=!1,!e.closed){if(this.appendEvent(e,{kind:`turn_ended`,stopReason:t.stopReason,ts:Date.now()}),e.sessionId!==null&&e.conn!==null){let t=this.takeSteer(e);if(t!==null){this.dispatchPrompt(e,t.content,t.attachments,{echo:!0});return}let n=this.takeNextQueued(e);if(n!==null){this.dispatchPrompt(e,n.content,n.attachments,{echo:!0});return}}this.emitStatus(e,`ready`)}}).catch(t=>{if(e.turnActive=!1,!e.closed){if(this.appendEvent(e,{kind:`turn_ended`,stopReason:`cancelled`,ts:Date.now()}),e.sessionId!==null&&e.conn!==null){let t=this.takeSteer(e);if(t!==null){this.dispatchPrompt(e,t.content,t.attachments,{echo:!0});return}}if(e.cancelRequested){this.emitStatus(e,`ready`),this.drainIfIdle(e);return}if(GGe(t)){this.emitStatus(e,`auth_required`,`sign in required: ${RQ(t)}`,{reason:`auth-required`,agentMessage:RQ(t),machineDetail:HQ(t,e),authMethods:UQ(e.lastInit?.authMethods)});return}this.emitStatus(e,`error`,`prompt failed: ${RQ(t)}`,{reason:`prompt`,agentMessage:RQ(t),machineDetail:VQ(zQ(t),BQ(e))})}})}cancel(e){this.cancelTurn(this.mustGet(e),{clearQueue:!0})}cancelTurn(e,t){t.clearQueue&&(e.info.queue!==void 0||e.info.steer!==void 0)&&(e.info.queue=void 0,this.clearSteer(e),this.emitInfo(e)),e.conn!==null&&e.sessionId!==null&&(e.turnActive&&(e.cancelRequested=!0),this.failPendingPermissions(e),this.restoreRunningAfterPermission(e),e.conn.agent.notify(dE.agent.session.cancel,{sessionId:e.sessionId}).catch(t=>{this.opts.log.debug({err:t,threadId:e.info.threadId},`[acp-threads] cancel notification never reached the agent`)}))}setMode(e,t){let n=this.mustGet(e);if(n.info.archived===!0){let e=n.info.modes;if(e==null||!e.availableModes.some(e=>e.id===t))throw new IQ(`not-ready`,`no such mode: ${t}`);n.info.modes={...e,currentModeId:t},this.emitInfo(n);return}if(n.resumeInFlight)throw new IQ(`not-ready`,`the thread is still resuming`);if(n.conn===null||n.sessionId===null)throw new IQ(`not-ready`,`thread has no live agent session`);n.conn.agent.request(dE.agent.session.setMode,{sessionId:n.sessionId,modeId:t}).then(()=>{n.info.modes&&(n.info.modes={...n.info.modes,currentModeId:t},this.emitInfo(n))}).catch(t=>{this.opts.log.warn({err:t,threadId:e},`[acp-threads] set_mode failed`)})}setConfigOption(e,t,n){let r=this.mustGet(e);if(r.info.archived===!0){let e=(r.info.configOptions??[]).find(e=>e.id===t);if(e===void 0)throw new IQ(`not-ready`,`no such config option: ${t}`);if(!LQ(e,n))throw new IQ(`not-ready`,`invalid value for ${t}`);r.info.configOptions=(r.info.configOptions??[]).map(e=>e.id===t?{...e,currentValue:n}:e),this.emitInfo(r);return}if(r.resumeInFlight)throw new IQ(`not-ready`,`the thread is still resuming`);if(r.conn===null||r.sessionId===null)throw new IQ(`not-ready`,`thread has no live agent session`);let i=typeof n==`boolean`?{sessionId:r.sessionId,configId:t,type:`boolean`,value:n}:{sessionId:r.sessionId,configId:t,value:n};r.conn.agent.request(dE.agent.session.setConfigOption,i).then(e=>{r.info.configOptions=e.configOptions,this.emitInfo(r)}).catch(n=>{this.opts.log.warn({err:n,threadId:e,configId:t},`[acp-threads] set_config_option failed`)})}async applyInitialConfig(e,t,n,r=!1){let i=e.sessionId;if(i===null)return;let a=t=>(e.info.configOptions??[]).find(e=>e.id===t)?.category===`model`,o=Object.keys(n).sort((e,t)=>Number(a(t))-Number(a(e))),s=!1,c=[];for(let a of o){let o=n[a];if(o===void 0)continue;let l=(e.info.configOptions??[]).find(e=>e.id===a);if(l===void 0||!r&&l.currentValue===o||!LQ(l,o))continue;let u=typeof o==`boolean`?{sessionId:i,configId:a,type:`boolean`,value:o}:{sessionId:i,configId:a,value:o};try{let n=await t.agent.request(dE.agent.session.setConfigOption,u);e.info.configOptions=n.configOptions,s=!0}catch(t){c.push(a),this.opts.log.warn({err:t,threadId:e.info.threadId,configId:a},`[acp-threads] initial config apply failed`)}if(e.closed)return}c.length>0&&this.opts.log.warn({threadId:e.info.threadId,rejectedConfigIds:c,sessionStateUnknown:r},`[acp-threads] some remembered config options could not be applied to the new session`),s&&this.emitInfo(e)}async applyInitialMode(e,t,n,r=!1){let i=e.sessionId;if(i===null)return;let a=e.info.modes;if(a!=null&&a.availableModes.some(e=>e.id===n)){if(!r&&a.currentModeId===n)return;try{await t.agent.request(dE.agent.session.setMode,{sessionId:i,modeId:n}),e.info.modes={...a,currentModeId:n},this.emitInfo(e)}catch(t){this.opts.log.warn({err:t,threadId:e.info.threadId,modeId:n,method:`set_mode`},`[acp-threads] initial mode apply failed`)}return}let o=(e.info.configOptions??[]).find(e=>e.category===`mode`&&LQ(e,n));if(o!==void 0&&!(!r&&o.currentValue===n))try{let r=await t.agent.request(dE.agent.session.setConfigOption,{sessionId:i,configId:o.id,value:n});e.info.configOptions=r.configOptions,this.emitInfo(e)}catch(t){this.opts.log.warn({err:t,threadId:e.info.threadId,modeId:n,method:`set_config_option`},`[acp-threads] initial mode apply failed`)}}respondPermission(e,t,n){let r=this.mustGet(e),i=r.pendingPermissions.get(t);i!==void 0&&(r.pendingPermissions.delete(t),clearTimeout(i.timer),n.kind===`selected`?(i.resolve({outcome:{outcome:`selected`,optionId:n.optionId}}),this.appendEvent(r,{kind:`permission_resolved`,requestId:t,optionId:n.optionId,auto:!1,ts:Date.now()})):(i.resolve({outcome:{outcome:`cancelled`}}),this.appendEvent(r,{kind:`permission_resolved`,requestId:t,optionId:null,auto:!1,ts:Date.now()})),this.restoreRunningAfterPermission(r))}restoreRunningAfterPermission(e){e.pendingPermissions.size===0&&e.turnActive&&e.info.status===`awaiting_permission`&&this.emitStatus(e,`running`)}async closeThread(e,t){let n=this.threads.get(e);if(n===void 0||n.info.archived===!0||n.closed)return;n.closed=!0,this.clearSteer(n),this.failPendingPermissions(n),this.failPendingConsents(n);try{n.conn?.close()}catch{}let r=n.child;r!==null&&(await wQ(r,{graceMs:t?.killGraceMs??PGe})||this.opts.log.error({threadId:e,pid:r.pid},`[acp-threads] agent process survived SIGKILL escalation`)),n.child=null,n.conn=null,n.lastInit=null,await n.terminals?.disposeAll(),n.terminals=null,this.opts.agentPresenceBroadcaster?.clearPresence(yJ(n.agentSessionId)),await this.opts.sessionManager.closeAllForAgent(n.agentSessionId).catch(t=>{this.opts.log.warn({err:t,threadId:e},`[acp-threads] session cleanup failed`)});let i=n.info.status===`error`||n.info.status===`auth_required`;if(!n.hadUserMessage&&!i){this.threads.delete(e),n.subscribers.clear(),n.flushTimer!==null&&(clearTimeout(n.flushTimer),n.flushTimer=null),await this.persistence.whenIdle(e),await this.persistence.delete(e),this.opts.log.info({threadId:e},`[acp-threads] empty thread discarded on close`);return}n.turnActive&&(n.turnActive=!1,this.appendEvent(n,{kind:`turn_ended`,stopReason:`cancelled`,ts:Date.now()})),n.info.archived=!0,this.emitStatus(n,`exited`,`thread closed`),this.flushBroadcast(n),this.persistence.queueMetaWrite(e,this.buildMeta(n)),await this.persistence.whenIdle(e),n.baseSeq=n.info.lastSeq+1,n.events=[],n.pendingBroadcast=[],n.closed=!1,this.opts.log.info({threadId:e},`[acp-threads] thread archived`)}async deleteThread(e){let t=this.mustGet(e);if(t.info.archived!==!0)throw new IQ(`not-ready`,`close the thread before deleting it`);if(t.resumeInFlight)throw new IQ(`not-ready`,`a resume is in progress`);this.threads.delete(e),t.subscribers.clear(),t.flushTimer!==null&&(clearTimeout(t.flushTimer),t.flushTimer=null),await this.persistence.whenIdle(e),await this.persistence.delete(e),this.opts.log.info({threadId:e},`[acp-threads] thread deleted`)}async destroy(){this.destroyed=!0,clearInterval(this.reapTimer),await Promise.allSettled([...this.threads.keys()].map(e=>this.closeThread(e,{killGraceMs:FGe})))}async handlePermissionRequest(e,t,n){e.info.lastActivityAt=Date.now();let r=this.opts.permissions.decide(e.info.agent.id,t,n);if(r.auto!==null){let t=crypto.randomUUID();return this.appendEvent(e,{kind:`permission_resolved`,requestId:t,optionId:r.auto.optionId,auto:!0,ts:Date.now()}),{outcome:{outcome:`selected`,optionId:r.auto.optionId}}}let i=crypto.randomUUID();return this.appendEvent(e,{kind:`permission_request`,requestId:i,toolCall:t,options:n,ts:Date.now()}),e.turnActive&&e.info.status===`running`&&this.emitStatus(e,`awaiting_permission`),new Promise(r=>{let a=setTimeout(()=>{e.pendingPermissions.delete(i),this.appendEvent(e,{kind:`permission_resolved`,requestId:i,optionId:null,auto:!0,ts:Date.now()}),this.restoreRunningAfterPermission(e),r({outcome:{outcome:`cancelled`}})},6e5);a.unref?.(),e.pendingPermissions.set(i,{timer:a,resolve:i=>{if(i.outcome.outcome===`selected`){let r=n.find(e=>i.outcome.outcome===`selected`&&e.optionId===i.outcome.optionId);r!==void 0&&this.opts.permissions.recordChoice(e.info.agent.id,t,r)}r(i)}})})}handleSessionUpdate(e,t){e.info.lastActivityAt=Date.now();let n=t.update;if(n.sessionUpdate===`current_mode_update`&&e.info.modes&&(e.info.modes={...e.info.modes,currentModeId:n.currentModeId},this.emitInfo(e)),n.sessionUpdate===`config_option_update`&&(e.info.configOptions=n.configOptions,this.emitInfo(e)),n.sessionUpdate===`available_commands_update`&&(e.info.availableCommands=n.availableCommands,this.emitInfo(e)),e.suppressUpdates){e.lastSuppressedAt=Date.now();return}this.appendEvent(e,{kind:`session_update`,update:ZUe(n),ts:Date.now()})}async handleFsRead(e,t,n){let r=await this.confinePath(e),i;if(i=r.docName===null?await Gs(r.abs,`utf8`):this.opts.getLoadedDocText?.(r.docName)??await Gs(r.abs,`utf8`),t!==null||n!==null){let e=i.split(`
|
|
823
823
|
`),r=Math.max((t??1)-1,0),a=n===null?e.length:r+n;i=e.slice(r,a).join(`
|
|
824
824
|
`)}return{content:i}}async handleFsWrite(e,t,n){e.info.lastActivityAt=Date.now();let r=await this.confinePath(t);if(r.docName!==null){let t=await this.opts.sessionManager.getSession(r.docName,e.agentSessionId,{displayName:e.info.agent.name,colorSeed:e.agentSessionId,clientName:e.info.agent.id}),i=this.opts.resolveEmbed===void 0?void 0:{resolveEmbed:this.opts.resolveEmbed,sourcePath:r.rel};t.dc.document.transact(()=>{let r=WZ(t.dc.document);UZ(t.dc.document,n,`replace`,i,void 0,VZ(t));let a=Sa(r,WZ(t.dc.document))??void 0;t.dc.document.getMap(`agent-flash`).set(e.agentSessionId,{agentId:e.agentSessionId,timestamp:Date.now(),type:`insert`,description:`Added (${e.info.agent.name}): ${n.slice(0,50)}`,...a===void 0?{}:{changedBlocks:a}})},t.origin),this.setPresence(e,r.docName)}else{if(this.opts.isIgnoredPath(r.rel))throw Error(`path is excluded from the project content scope: ${t}`);let{tracedMkdir:e,tracedWriteFile:i}=await Promise.resolve().then(()=>QJ);await e(B(r.abs),{recursive:!0}),await i(r.abs,n)}}confinePath(e){return HGe(this.opts.contentDir,e,this.opts.isExcludedPath)}mustGet(e){let t=this.threads.get(e);if(t===void 0)throw new IQ(`unknown-thread`,`no thread '${e}'`);return t}appendEvent(e,t){let n=e.pendingBroadcast;if(n.length>0&&nWe(n[n.length-1],t,e.info.agent))return;let r=e.baseSeq+e.events.length;if(e.events.push(t),e.info.lastSeq=r,e.events.length>NGe){let t=e.events.length-NGe;e.events.splice(0,t),e.baseSeq+=t}e.pendingBroadcast.length===0&&(e.pendingBroadcastFromSeq=r),e.pendingBroadcast.push(t),e.flushTimer===null&&(e.flushTimer=setTimeout(()=>this.flushBroadcast(e),25),e.flushTimer.unref?.())}flushBroadcast(e){if(e.flushTimer!==null&&(clearTimeout(e.flushTimer),e.flushTimer=null),e.pendingBroadcast.length===0)return;let t={op:`events`,threadId:e.info.threadId,fromSeq:e.pendingBroadcastFromSeq,events:e.pendingBroadcast};this.persistence.appendEvents(e.info.threadId,e.pendingBroadcast),e.pendingBroadcast=[];for(let n of e.subscribers)try{n(t)}catch{}}emitStatus(e,t,n,r){(t===`exited`||t===`error`)&&(e.info.queue=void 0,this.clearSteer(e)),e.info.status=t,e.info.lastActivityAt=Date.now(),(t===`error`||t===`auth_required`)&&this.opts.log.warn({threadId:e.info.threadId,agentId:e.info.agent.id,status:t,detail:n,reason:r?.reason,machineDetail:r?.machineDetail},`[acp-threads] thread failure status`),this.appendEvent(e,{kind:`status`,status:t,detail:n,...r===void 0?{}:{failure:r},ts:Date.now()}),this.emitInfo(e)}async teardownFailedAgent(e){let t=e.child,n=e.conn,r=e.terminals;e.child=null,e.conn=null,e.lastInit=null,e.terminals=null;try{n?.close()}catch{}await r?.disposeAll().catch(t=>{this.opts.log.warn({err:t,threadId:e.info.threadId},`[acp-threads] terminal cleanup on failed-agent teardown failed`)}),t!==null&&await wQ(t,{graceMs:PGe})}emitInfo(e){this.persistence.queueMetaWrite(e.info.threadId,this.buildMeta(e)),this.broadcastInfo(e)}broadcastInfo(e){for(let t of e.subscribers)try{t({op:`info`,info:{...e.info}})}catch{}}closeSignInCapture(e){e.authStderr=null,e.info.signInOutput!==void 0&&(e.info.signInOutput=void 0,this.broadcastInfo(e))}buildMeta(e){let{queue:t,steer:n,signInOutput:r,...i}=e.info;return{version:1,info:i,sessionId:e.sessionId,cwd:e.cwd,agentRef:e.agentRef,docName:e.docName}}failPendingPermissions(e){for(let[t,n]of e.pendingPermissions)clearTimeout(n.timer),n.resolve({outcome:{outcome:`cancelled`}}),this.appendEvent(e,{kind:`permission_resolved`,requestId:t,optionId:null,auto:!0,ts:Date.now()});e.pendingPermissions.clear()}failPendingConsents(e){for(let t of[e.pendingRuntimeConsent,e.pendingPiBridgeConsent]){for(let e of t.values())clearTimeout(e.timer),e.resolve(`closed`);t.clear()}}setPresence(e,t){let n=this.opts.agentPresenceBroadcaster;if(n!=null)try{let r=li(e.info.agent.id),i=Da[r]??La(e.agentSessionId);n.setPresence(yJ(e.agentSessionId),{displayName:e.info.agent.name,icon:r,color:i,currentDoc:t,mode:`writing`,ts:Date.now(),docTs:Date.now()})}catch(e){this.opts.log.warn({err:e},`[acp-threads] presence update failed`)}}reapIdleThreads(){let e=Date.now(),t=e-this.idleReapMs;for(let n of this.threads.values()){if(n.info.archived===!0)continue;if(n.subscribers.size===0&&!n.turnActive&&n.info.lastActivityAt<t){this.opts.log.info({threadId:n.info.threadId},`[acp-threads] reaping idle thread`),this.closeThread(n.info.threadId).catch(e=>{this.opts.log.error({err:e,threadId:n.info.threadId},`[acp-threads] reap failed`)});continue}if(!n.turnActive||n.unwatchedSince===null)continue;let r=e-n.unwatchedSince;r>=this.unwatchedTurnKillMs?(this.opts.log.warn({threadId:n.info.threadId,unwatchedFor:r},`[acp-threads] force-closing unwatched turn that ignored cancel`),this.closeThread(n.info.threadId).catch(e=>{this.opts.log.error({err:e,threadId:n.info.threadId},`[acp-threads] force-close failed`)})):r>=this.unwatchedTurnCancelMs&&!n.unwatchedCancelSent&&(n.unwatchedCancelSent=!0,this.opts.log.warn({threadId:n.info.threadId,unwatchedFor:r},`[acp-threads] cancelling turn running with zero subscribers`),this.cancel(n.info.threadId))}}};async function HGe(e,t,n){let r=await qs(e),i=ss(os(t)?t:U(r,t)),a=i,o=``;for(;;)try{let e=await qs(a),i=o===``?e:V(e,o),s=H(r,i);if(s===``||s.startsWith(`..`)||os(s))throw Error(`path escapes the content directory: ${t}`);let c=/\.(md|mdx)$/.exec(s),l=null;if(c!==null){let e=s.slice(0,-c[0].length).split(us).join(`/`),t=s.split(us).join(`/`);!wX(e)&&!TX(e)&&!n(t)&&(l=e)}return{abs:i,rel:s.split(us).join(`/`),docName:l}}catch(e){if(e.code!==`ENOENT`)throw e;let t=B(a);if(t===a)throw e;o=o===``?i.slice(t.length+1):V(a.slice(t.length+1),o),a=t}}function UGe(e){let t=e.info.status===`error`?`error`:`exited`;return{info:{...e.info,status:t,archived:!0,queue:void 0,steer:void 0,signInOutput:void 0},docName:e.docName,agentRef:e.agentRef,cwd:e.cwd,child:null,conn:null,lastInit:null,sessionId:e.sessionId,agentSessionId:`acp-${e.info.threadId}`,events:[],baseSeq:e.info.lastSeq+1,logResolved:!1,logResolution:null,midTurnOnDisk:!1,resumeInFlight:!1,authInFlight:!1,suppressUpdates:!1,lastSuppressedAt:0,subscribers:new Set,pendingPermissions:new Map,pendingRuntimeConsent:new Map,pendingPiBridgeConsent:new Map,piBridgeDeclined:!1,lastPiBridgeStatus:null,stderrTail:[],authStderr:null,terminals:null,turnActive:!1,cancelRequested:!1,steerStallTimer:null,unwatchedSince:null,unwatchedCancelSent:!1,pendingBroadcast:[],pendingBroadcastFromSeq:0,flushTimer:null,closed:!1,hadUserMessage:!0,envNotePending:!1}}function LQ(e,t){if(typeof t==`boolean`)return e.type===`boolean`;if(e.type!==`select`)return!1;for(let n of e.options)if(`value`in n){if(n.value===t)return!0}else if(n.options.some(e=>e.value===t))return!0;return!1}function WGe(e){let t=DQ(e),n=e===`node`?`https://nodejs.org`:`https://docs.astral.sh/uv/getting-started/installation/`;return`This agent needs \`${t.provides}\`, which isn't installed. OK can download a private copy of ${t.displayName} for you, or install ${t.displayName} yourself (${n}) and it'll be used automatically.`}function GGe(e){if(typeof e!=`object`||!e)return!1;let t=e;return t.code===-32e3||typeof t.data==`object`&&t.data!==null&&t.data.errorKind===`authentication_failed`}function RQ(e){return e instanceof Error?e.message:String(e)}function zQ(e){if(typeof e!=`object`||!e)return;let t=e.data;if(t!=null)try{return JSON.stringify(t).slice(0,300)}catch{return}}function KGe(e){for(let t=e.events.length-1;t>=0;--t){let n=e.events[t];if(n!==void 0&&n.kind===`status`&&(n.status===`error`||n.status===`auth_required`))return n.detail??n.failure?.agentMessage}}function BQ(e){let t=e.stderrTail.join(`
|
|
825
825
|
`);return t===``?void 0:t}function VQ(...e){let t=e.filter(e=>e!==void 0&&e!==``).join(`
|
package/dist/index.d.mts
CHANGED
|
@@ -11539,6 +11539,7 @@ interface EditorMcpTargetBase {
|
|
|
11539
11539
|
}
|
|
11540
11540
|
interface ManagedFileEditorTarget extends EditorMcpTargetBase {
|
|
11541
11541
|
format: 'file';
|
|
11542
|
+
projectConfigPath: (cwd: string) => string;
|
|
11542
11543
|
buildEntry?: undefined;
|
|
11543
11544
|
}
|
|
11544
11545
|
interface EntryEditorTarget extends EditorMcpTargetBase {
|
|
@@ -11548,7 +11549,9 @@ interface EntryEditorTarget extends EditorMcpTargetBase {
|
|
|
11548
11549
|
type EditorMcpTarget = ManagedFileEditorTarget | EntryEditorTarget;
|
|
11549
11550
|
declare function editorEntryLocator(target: EditorMcpTarget): string;
|
|
11550
11551
|
declare function editorConfigPathDisplay(target: EditorMcpTarget, home: string): string | null;
|
|
11551
|
-
declare const EDITOR_TARGETS: Record<EditorId, EditorMcpTarget
|
|
11552
|
+
declare const EDITOR_TARGETS: Record<EditorId, EditorMcpTarget> & {
|
|
11553
|
+
pi: ManagedFileEditorTarget;
|
|
11554
|
+
};
|
|
11552
11555
|
//#endregion
|
|
11553
11556
|
//#region src/commands/acp-harness-probe.d.ts
|
|
11554
11557
|
interface OwnManagedMcpEntryHit {
|
|
@@ -11586,7 +11589,7 @@ interface BundleExtraFile {
|
|
|
11586
11589
|
}
|
|
11587
11590
|
//#endregion
|
|
11588
11591
|
//#region ../core/dist/acp-thread-protocol.d.mts
|
|
11589
|
-
type PiBridgeWriteAction = 'unchanged' | 'written' | 'refreshed' | 'refused-foreign' | 'refused-unreadable' | 'failed';
|
|
11592
|
+
type PiBridgeWriteAction = 'unchanged' | 'written' | 'refreshed' | 'refused-foreign' | 'refused-unreadable' | 'refused-project-path' | 'failed';
|
|
11590
11593
|
type PiTrustWriteAction = 'already-trusted' | 'added' | 'skipped' | 'refused-unreadable' | 'failed';
|
|
11591
11594
|
//#endregion
|
|
11592
11595
|
//#region ../server/dist/index.d.mts
|
|
@@ -11676,6 +11679,9 @@ declare function probeTrackedOkPaths(projectRoot: string, paths: readonly string
|
|
|
11676
11679
|
};
|
|
11677
11680
|
declare function formatTrackedRemediation(tracked: readonly string[]): string;
|
|
11678
11681
|
//#endregion
|
|
11682
|
+
//#region src/utils/config-file-error.d.ts
|
|
11683
|
+
type ConfigFileDeclineReason = 'permission-denied' | 'missing-symlink-target' | 'unresolved-symlink' | 'not-a-file' | 'disappeared' | 'unreadable';
|
|
11684
|
+
//#endregion
|
|
11679
11685
|
//#region src/commands/init.d.ts
|
|
11680
11686
|
interface EditorMcpResult {
|
|
11681
11687
|
editorId: EditorId;
|
|
@@ -11684,7 +11690,7 @@ interface EditorMcpResult {
|
|
|
11684
11690
|
configPath: string;
|
|
11685
11691
|
serverName: string;
|
|
11686
11692
|
error?: string;
|
|
11687
|
-
declineReason?:
|
|
11693
|
+
declineReason?: McpWriteDeclineReason;
|
|
11688
11694
|
configScope?: 'project';
|
|
11689
11695
|
}
|
|
11690
11696
|
declare const LAUNCH_CONFIG_NAME = "open-knowledge-ui";
|
|
@@ -11697,7 +11703,9 @@ interface UserMcpConfigsOptions {
|
|
|
11697
11703
|
}
|
|
11698
11704
|
declare function writeUserMcpConfigs(opts: UserMcpConfigsOptions): Promise<EditorMcpResult[]>;
|
|
11699
11705
|
declare function readExistingMcpEntry(target: EditorMcpTarget, cwd: string, home?: string, configPathOverride?: string): Record<string, unknown> | null;
|
|
11700
|
-
type
|
|
11706
|
+
type McpConfigDeclineReason = ConfigFileDeclineReason | 'unparseable' | 'duplicate-container' | 'oversize' | 'no-native-writer';
|
|
11707
|
+
type McpDeclineReason = McpConfigDeclineReason | McpLauncherDeclineReason;
|
|
11708
|
+
type McpWriteDeclineReason = Exclude<McpConfigDeclineReason, 'missing-symlink-target'>;
|
|
11701
11709
|
type McpEntryClassification = {
|
|
11702
11710
|
kind: 'absent';
|
|
11703
11711
|
} | {
|
|
@@ -11707,7 +11715,7 @@ type McpEntryClassification = {
|
|
|
11707
11715
|
entry: Record<string, unknown>;
|
|
11708
11716
|
} | {
|
|
11709
11717
|
kind: 'decline';
|
|
11710
|
-
reason:
|
|
11718
|
+
reason: McpConfigDeclineReason;
|
|
11711
11719
|
};
|
|
11712
11720
|
declare function classifyExistingMcpEntry(target: EditorMcpTarget, cwd: string, home?: string, configPathOverride?: string): McpEntryClassification;
|
|
11713
11721
|
declare function detectInstalledEditors(cwd: string, home?: string): EditorId[];
|
|
@@ -11715,16 +11723,35 @@ declare function detectInstalledEditors(cwd: string, home?: string): EditorId[];
|
|
|
11715
11723
|
//#region src/commands/pi-acp-bridge.d.ts
|
|
11716
11724
|
type PiBridgeFileState = 'absent' | 'own-current' | 'own-stale' | 'foreign' | 'unreadable';
|
|
11717
11725
|
type PiTrustState = 'trusted' | 'untrusted' | 'unreadable';
|
|
11718
|
-
|
|
11726
|
+
type PiBridgeState = {
|
|
11719
11727
|
cwd: string;
|
|
11720
11728
|
bridgePath: string;
|
|
11721
11729
|
trustPath: string;
|
|
11730
|
+
} & ({
|
|
11731
|
+
project: 'unavailable';
|
|
11732
|
+
error: string;
|
|
11733
|
+
} | {
|
|
11734
|
+
project: 'ready';
|
|
11735
|
+
canonicalCwd: string;
|
|
11722
11736
|
bridge: PiBridgeFileState;
|
|
11723
11737
|
trust: PiTrustState;
|
|
11724
11738
|
bridgeLoadable: boolean;
|
|
11725
11739
|
otherExtensions: readonly string[];
|
|
11726
|
-
}
|
|
11727
|
-
type
|
|
11740
|
+
});
|
|
11741
|
+
type PiTrustRemoveResult = {
|
|
11742
|
+
action: 'removed' | 'not-present';
|
|
11743
|
+
error?: never;
|
|
11744
|
+
detail?: never;
|
|
11745
|
+
} | {
|
|
11746
|
+
action: 'kept-shared' | 'kept-unowned';
|
|
11747
|
+
detail: string;
|
|
11748
|
+
error?: never;
|
|
11749
|
+
} | {
|
|
11750
|
+
action: 'kept-unverified' | 'refused-unreadable' | 'failed';
|
|
11751
|
+
error: string;
|
|
11752
|
+
detail?: never;
|
|
11753
|
+
};
|
|
11754
|
+
type PiTrustRemoveAction = PiTrustRemoveResult['action'];
|
|
11728
11755
|
interface EnsurePiBridgeResult {
|
|
11729
11756
|
ok: boolean;
|
|
11730
11757
|
cwd: string;
|
|
@@ -11734,23 +11761,28 @@ interface EnsurePiBridgeResult {
|
|
|
11734
11761
|
trust: PiTrustWriteAction;
|
|
11735
11762
|
error?: string;
|
|
11736
11763
|
}
|
|
11737
|
-
declare function probePiBridgeState(cwd: string, home?: string): PiBridgeState;
|
|
11738
|
-
declare function ensurePiBridge(cwd: string, options?: McpInstallOptions, home?: string): Promise<EnsurePiBridgeResult>;
|
|
11764
|
+
declare function probePiBridgeState(cwd: string, home?: string, env?: NodeJS.ProcessEnv): PiBridgeState;
|
|
11765
|
+
declare function ensurePiBridge(cwd: string, options?: McpInstallOptions, home?: string, env?: NodeJS.ProcessEnv, approvedCanonicalCwd?: string): Promise<EnsurePiBridgeResult>;
|
|
11739
11766
|
//#endregion
|
|
11740
11767
|
//#region src/commands/mcp-config-removal.d.ts
|
|
11741
|
-
type
|
|
11742
|
-
|
|
11743
|
-
|
|
11744
|
-
trustError?: string;
|
|
11768
|
+
type McpTrustRemoval = {
|
|
11769
|
+
trust?: Extract<PiTrustRemoveAction, 'removed' | 'not-present'>;
|
|
11770
|
+
trustDetail?: never;
|
|
11745
11771
|
} | {
|
|
11772
|
+
trust: Extract<PiTrustRemoveAction, 'kept-shared' | 'kept-unowned'>;
|
|
11773
|
+
trustDetail: string;
|
|
11774
|
+
};
|
|
11775
|
+
type McpRemoveOutcome = ({
|
|
11776
|
+
kind: 'removed';
|
|
11777
|
+
} & McpTrustRemoval) | {
|
|
11746
11778
|
kind: 'not-present';
|
|
11747
11779
|
} | {
|
|
11748
11780
|
kind: 'left-foreign';
|
|
11749
11781
|
} | {
|
|
11750
11782
|
kind: 'declined';
|
|
11751
|
-
reason:
|
|
11783
|
+
reason: McpConfigDeclineReason;
|
|
11752
11784
|
};
|
|
11753
|
-
declare function removeOwnMcpEntry(target: EditorMcpTarget, cwd: string, home?: string, configPathOverride?: string): McpRemoveOutcome;
|
|
11785
|
+
declare function removeOwnMcpEntry(target: EditorMcpTarget, cwd: string, home?: string, configPathOverride?: string, env?: NodeJS.ProcessEnv): McpRemoveOutcome;
|
|
11754
11786
|
//#endregion
|
|
11755
11787
|
//#region src/commands/mcp-decline-event.d.ts
|
|
11756
11788
|
type McpConfigDeclineScope = 'user' | 'project';
|