@inkeep/open-knowledge 0.59.0-beta.40 → 0.59.0-beta.41
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/acp-harness-probe-BtuZH5xB.mjs +6 -0
- package/dist/cli.mjs +60 -60
- package/dist/constants-CY13LmEx.mjs +2 -0
- package/dist/index.d.mts +129 -18
- package/dist/index.mjs +206 -203
- package/dist/{init-DJQw_oSo.mjs → init-DQD6jW3w.mjs} +43 -43
- package/dist/init-XPSM_ZEq.mjs +1 -0
- package/dist/{launch-json-removal-D9jr3Cym.mjs → launch-json-removal-BGWZalRw.mjs} +2 -2
- package/dist/{loader-lM2dlAdG.mjs → loader-BJs1nphI.mjs} +2 -2
- package/dist/loader-aSuKwxwq.mjs +1 -0
- package/dist/{open-browser-CldvWM5B.mjs → open-browser-Ch6OlrUp.mjs} +2 -2
- package/dist/{preview-P4lIN2Xz.mjs → preview-D3B8IpV0.mjs} +2 -2
- package/dist/preview-VR9ntyuJ.mjs +1 -0
- package/dist/public/assets/{ActivityModeContent-B6cXYk7E.js → ActivityModeContent-DgUvDc0z.js} +1 -1
- package/dist/public/assets/{AgentDiffPane-Bh5zJLhI.js → AgentDiffPane-6Xvyv1ij.js} +1 -1
- package/dist/public/assets/{AgentThreadClientBinder-DXqc9G_d.js → AgentThreadClientBinder-C1JrAGMt.js} +1 -1
- package/dist/public/assets/{CodeMirrorPropInput-ONJdKGBm.js → CodeMirrorPropInput-DsPE0Ftk.js} +1 -1
- package/dist/public/assets/{DocumentContext-CoYCdUTn.js → DocumentContext-DjeS2Iep.js} +1 -1
- package/dist/public/assets/{EditorModeToggle-Cvt1TW83.js → EditorModeToggle-DJhhf9CF.js} +1 -1
- package/dist/public/assets/{EnableSyncConfirmDialog-CAa7STLG.js → EnableSyncConfirmDialog-DDSxyh5R.js} +1 -1
- package/dist/public/assets/{ExcalidrawDocEditor-DESqJPaH.js → ExcalidrawDocEditor-0ruIdk-O.js} +1 -1
- package/dist/public/assets/FeedbackForm-3KH2dlV7.js +1 -0
- package/dist/public/assets/{ImportSkillDialog-CUfIX2Eq.js → ImportSkillDialog-zQ6liFZc.js} +1 -1
- package/dist/public/assets/{LintConfigEditor-DeQ2Zl6N.js → LintConfigEditor-DdBS7-rm.js} +1 -1
- package/dist/public/assets/ManagedArtifactProperties-DQyHwL-a.js +1 -0
- package/dist/public/assets/{ManagedArtifactProperties-C0w77LVG.js → ManagedArtifactProperties-brGGfShz.js} +1 -1
- package/dist/public/assets/{MermaidDocEditor-DxmG30L8.js → MermaidDocEditor-mbELBjiD.js} +1 -1
- package/dist/public/assets/{PropertyDisplayRow-B6rCTA9W.js → PropertyDisplayRow-CEl7G8Hh.js} +1 -1
- package/dist/public/assets/{SchemaConfigEditor-C1OVUId-.js → SchemaConfigEditor-CX1lrMyx.js} +1 -1
- package/dist/public/assets/{SessionsHost-DfN_SR22.js → SessionsHost-2CzBb6OP.js} +2 -2
- package/dist/public/assets/{SettingsDialogBody-zm5oYc1W.js → SettingsDialogBody-ChyWIo94.js} +1 -1
- package/dist/public/assets/{ShareReceiveMissDialog-Dv1AenCZ.js → ShareReceiveMissDialog-2y7f-ZUX.js} +1 -1
- package/dist/public/assets/{SkillInstallMenu-ChmuKg2U.js → SkillInstallMenu-BDvh1LrE.js} +1 -1
- package/dist/public/assets/{SkillToolbarControls-CfDZO8oD.js → SkillToolbarControls-CFmtenmi.js} +1 -1
- package/dist/public/assets/{SourceEditor-CmjhgcpS.js → SourceEditor-B5PkYeQ1.js} +1 -1
- package/dist/public/assets/{TerminalWindowApp-D243fYSc.js → TerminalWindowApp-Bwi7BYpX.js} +1 -1
- package/dist/public/assets/{TextDocEditor-CKfjEUc-.js → TextDocEditor-23dW9L3H.js} +1 -1
- package/dist/public/assets/{ThreadView-D9vhfjoU.js → ThreadView-CC-VavdV.js} +4 -4
- package/dist/public/assets/{TimelineDiffPane-DpxUnCr7.js → TimelineDiffPane-DuAFZCuC.js} +1 -1
- package/dist/public/assets/{agent-diff-store-S2i2o6of.js → agent-diff-store-CVZoOkdc.js} +1 -1
- package/dist/public/assets/{auth-state-cache-CyUM6zjr.js → auth-state-cache-B0ZRmrMy.js} +1 -1
- package/dist/public/assets/{comment-chips-CoL6Cjh4.js → comment-chips-DPP4WbWD.js} +1 -1
- package/dist/public/assets/{config-provider-BEy0uWv0.js → config-provider-PxPHWQK1.js} +3 -3
- package/dist/public/assets/i18n-BILgtwZc.js +1 -0
- package/dist/public/assets/{index-BEbGyHpc.js → index-BLkd02I5.js} +7 -7
- package/dist/public/assets/messages-BBOavCsg.js +1 -0
- package/dist/public/assets/messages-BLwf6BPC.js +1 -0
- package/dist/public/assets/messages-BWoDaP3l.js +1 -0
- package/dist/public/assets/messages-CJc6Fwhy.js +1 -0
- package/dist/public/assets/messages-CVX6T0zf.js +1 -0
- package/dist/public/assets/messages-Cctjaczm.js +1 -0
- package/dist/public/assets/messages-D7ueLI0N.js +1 -0
- package/dist/public/assets/messages-Do2GOztj.js +1 -0
- package/dist/public/assets/messages-DpWEt-bz.js +1 -0
- package/dist/public/assets/messages-QZSRIG9j.js +1 -0
- package/dist/public/assets/messages-_lezxuNr.js +1 -0
- package/dist/public/assets/messages-fK0eB8Up.js +1 -0
- package/dist/public/assets/{pending-receive-nav-store-BmPJ0hig.js → pending-receive-nav-store-D7ZVE5MM.js} +1 -1
- package/dist/public/assets/{progress-BI1WoFwX.js → progress-ByrCliGb.js} +1 -1
- package/dist/public/assets/{selection-context-BIBH9g3O.js → selection-context-DeYn-FzA.js} +1 -1
- package/dist/public/assets/{skill-actions-D5hCSoeU.js → skill-actions--JCMpZsz.js} +1 -1
- package/dist/public/assets/{src-7zCAXVHf.js → src-D55kPVxd.js} +1 -1
- package/dist/public/assets/thread-client-BUOJIDSk.js +1 -0
- package/dist/public/assets/{typing-burst-detector-BNdl6EaU.js → typing-burst-detector-lJRmgSu_.js} +1 -1
- package/dist/public/assets/{uninstall-nSAdScfe.js → uninstall-ByzOPpbn.js} +1 -1
- package/dist/public/assets/{use-activity-panel-BUNW6oNK.js → use-activity-panel-BIGwAxkm.js} +1 -1
- package/dist/public/assets/{use-open-skill-Bjriumns.js → use-open-skill-tFppbCbr.js} +1 -1
- package/dist/public/assets/{use-popular-skills-HmcJCaX6.js → use-popular-skills-Cno-Yq25.js} +1 -1
- package/dist/public/assets/{use-terminal-enabled-UtVaQQM1.js → use-terminal-enabled-BpHLSpMP.js} +1 -1
- package/dist/public/assets/{use-timeline-entry-diff-DijUR0V_.js → use-timeline-entry-diff-ZXh6l0vh.js} +1 -1
- package/dist/public/index.html +21 -21
- package/dist/public/uninstall.html +3 -3
- package/dist/{repair-launch-json-CdSGcXNS.mjs → repair-launch-json-CHctvIyf.mjs} +2 -2
- package/dist/{repair-mcp-configs-6T3iELeJ.mjs → repair-mcp-configs-CxpzvuTr.mjs} +2 -2
- package/dist/{repair-skills-DdLknuYw.mjs → repair-skills-BzH72pUo.mjs} +3 -3
- package/dist/repair-skills-Drrx-xv7.mjs +1 -0
- package/dist/{resolve-project-root-CHFE5Tp7.mjs → resolve-project-root-CXTFWDeF.mjs} +3 -3
- package/dist/{skill-teardown-DcAF7q_b.mjs → skill-teardown-D5P-vpe_.mjs} +2 -2
- package/dist/src-B7h6Rdfy.mjs +20 -0
- package/dist/src-CNeIF6hC.mjs +1 -0
- package/dist/src-CpD0HabK.mjs +2029 -0
- package/dist/src-DtdQZJU9.mjs +1 -0
- package/dist/start-CIhdgT-b.mjs +1 -0
- package/dist/start-DGV1Y2SQ.mjs +4 -0
- package/package.json +4 -4
- package/dist/acp-harness-probe-BXaEG9XN.mjs +0 -3
- package/dist/constants-DzwYLdlF.mjs +0 -2
- package/dist/init-DiyB7t8-.mjs +0 -1
- package/dist/loader-DN5VV8rd.mjs +0 -1
- package/dist/preview-DfNrt9nH.mjs +0 -1
- package/dist/public/assets/FeedbackForm-Be8PVK4s.js +0 -1
- package/dist/public/assets/ManagedArtifactProperties-C-2tXobc.js +0 -1
- package/dist/public/assets/i18n-DgDGD96k.js +0 -1
- package/dist/public/assets/messages-CUxjY1bg.js +0 -1
- package/dist/public/assets/messages-CbJcA1a-.js +0 -1
- package/dist/public/assets/messages-CcamDXr_.js +0 -1
- package/dist/public/assets/messages-CoC8VCIg.js +0 -1
- package/dist/public/assets/messages-DBHRMUAC.js +0 -1
- package/dist/public/assets/messages-DayldphK.js +0 -1
- package/dist/public/assets/messages-NxV5iFe4.js +0 -1
- package/dist/public/assets/messages-TD09LIiN.js +0 -1
- package/dist/public/assets/messages-_8bTGBiH.js +0 -1
- package/dist/public/assets/messages-eTs_IzNw.js +0 -1
- package/dist/public/assets/messages-j2csGD4E.js +0 -1
- package/dist/public/assets/messages-lFIWwgmW.js +0 -1
- package/dist/public/assets/thread-client-BprEkf79.js +0 -1
- package/dist/repair-skills-CS2_jKX3.mjs +0 -1
- package/dist/src-B8QX7oNJ.mjs +0 -20
- package/dist/src-BoSNO_uo.mjs +0 -1
- package/dist/src-CKvbaaFV.mjs +0 -2029
- package/dist/src-nk8WfDCB.mjs +0 -1
- package/dist/start-CoLYZ46p.mjs +0 -1
- package/dist/start-DzgWu5RH.mjs +0 -4
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{o as e}from"./chunk-CYidjpOJ.js";import{t}from"./react-f2sANaYj.js";import{t as n}from"./compiler-runtime-BfE3aGVn.js";import{n as r}from"./dist-DTX2HxC82.js";import{t as i}from"./dist-BgXDUIPy.js";var a=e(t(),1),o=n(),s=`ok-acp-agent-settings-v1`;function c(e){return`${e.source}:${e.id}`}function l(){try{let e=localStorage.getItem(s);if(e===null)return{};let t=JSON.parse(e);return typeof t==`object`&&t?t:{}}catch{return{}}}function u(e){try{localStorage.setItem(s,JSON.stringify(e))}catch(e){console.warn(`[acp-settings] could not persist agent settings`,e)}}function d(e,t,n){let r=l(),i=r[e]??{};r[e]={...i,config:{...i.config,[t]:n}},u(r)}function f(e){let t=l()[e]?.config;if(typeof t!=`object`||!t)return;let n={};for(let[e,r]of Object.entries(t))(typeof r==`string`||typeof r==`boolean`)&&(n[e]=r);return Object.keys(n).length>0?n:void 0}function p(e,t){if(t===``)return;let n=l();n[e]={...n[e]??{},modeId:t},u(n)}function m(e){let t=l()[e]?.modeId;return typeof t==`string`&&t!==``?t:void 0}var h=64e3;function g(e){if(typeof e!=`object`||!e)return null;let t=e;return t.type===`text`&&typeof t.text==`string`?t.text:null}function _(e){return e!==null&&(e.reason===`connect`||e.reason===`session-setup`||e.reason===`auth-required`)}var v=class{items=[];plan=[];turnActive=!1;tokenUsage=null;terminals={};toolCallIndex=new Map;permissionIndex=new Map;permissionByToolCall=new Map;permissionsByToolCall={};messageIndex=new Map;runtimeConsentIndex=new Map;lastConsentIndex=null;appliedCount=0;dirty=!1;snapshot={items:[],plan:[],turnActive:!1,tokenUsage:null,terminals:{},permissionsByToolCall:{}};sync(e){e.length<this.appliedCount&&this.reset();for(let t=this.appliedCount;t<e.length;t++)this.applyEvent(e[t]);return this.appliedCount=e.length,this.dirty&&=(this.snapshot={items:[...this.items],plan:this.plan,turnActive:this.turnActive,tokenUsage:this.tokenUsage,terminals:{...this.terminals},permissionsByToolCall:{...this.permissionsByToolCall}},!1),this.snapshot}reset(){this.items=[],this.plan=[],this.turnActive=!1,this.tokenUsage=null,this.terminals={},this.toolCallIndex=new Map,this.permissionIndex=new Map,this.permissionByToolCall=new Map,this.permissionsByToolCall={},this.messageIndex=new Map,this.runtimeConsentIndex=new Map,this.lastConsentIndex=null,this.appliedCount=0,this.dirty=!0}applyEvent(e){switch(this.dirty=!0,e.kind){case`user_message`:{let t={kind:`message`,role:`user`,text:e.content,messageId:`user-${this.items.length}`};e.attachments!==void 0&&e.attachments.length>0&&(t.attachments=e.attachments),this.items.push(t),this.messageIndex.clear();break}case`turn_started`:this.turnActive=!0;break;case`turn_ended`:this.turnActive=!1,this.messageIndex.clear();break;case`status`:if(e.status===`exited`&&(this.turnActive=!1),this.lastConsentIndex!==null){let t=this.items[this.lastConsentIndex];t?.kind===`runtime_consent`&&t.install===`running`&&(e.status===`spawning`||e.status===`ready`||e.status===`running`?this.items[this.lastConsentIndex]={...t,install:`done`}:(e.status===`error`||e.status===`exited`)&&(this.items[this.lastConsentIndex]={...t,install:`failed`}))}if(e.status===`ready`)for(let e=0;e<this.items.length;e+=1){let t=this.items[e];t?.kind===`notice`&&t.superseded!==!0&&_(t.failure)&&(this.items[e]={...t,superseded:!0})}if((e.status===`error`||e.status===`auth_required`)&&(e.failure!==void 0||(e.detail??``)!==``)){let t={kind:`notice`,text:e.detail??``,tone:e.status===`error`?`error`:`info`,failure:e.failure??null,attempts:1},n=this.items[this.items.length-1];n?.kind===`notice`&&n.superseded!==!0&&S(n,t)?this.items[this.items.length-1]={...n,attempts:n.attempts+1}:this.items.push(t)}break;case`permission_request`:{let t=e.toolCall.toolCallId??null,n={kind:`permission`,requestId:e.requestId,title:e.toolCall.title??i._({id:`Ya3PlJ`}),toolKind:e.toolCall.kind??`other`,options:e.options,resolved:null,toolCallId:t,mergedIntoToolCall:t!==null&&this.toolCallIndex.has(t)};this.permissionIndex.set(e.requestId,this.items.length),t!==null&&(this.permissionByToolCall.set(t,this.items.length),this.permissionsByToolCall[t]=n),this.items.push(n);break}case`permission_resolved`:{let t=this.permissionIndex.get(e.requestId);if(t===void 0)break;let n=this.items[t];if(n.kind!==`permission`)break;let r={...n,resolved:{optionId:e.optionId,auto:e.auto}};this.items[t]=r,r.toolCallId!==null&&(this.permissionsByToolCall[r.toolCallId]=r);break}case`runtime_consent_request`:this.runtimeConsentIndex.set(e.requestId,this.items.length),this.lastConsentIndex=this.items.length,this.items.push({kind:`runtime_consent`,requestId:e.requestId,runtime:e.runtime,displayName:e.displayName,provides:e.provides,version:e.version,approxSizeMB:e.approxSizeMB,sourceHost:e.sourceHost,agentName:e.agentName,reason:e.reason??`missing`,resolved:null,install:null,progress:null});break;case`runtime_consent_resolved`:{let t=this.runtimeConsentIndex.get(e.requestId);if(t===void 0)break;let n=this.items[t];if(n.kind!==`runtime_consent`)break;this.items[t]={...n,resolved:e.decision,install:e.decision===`granted`?`running`:null};break}case`runtime_install_progress`:{if(this.lastConsentIndex===null)break;let t=this.items[this.lastConsentIndex];if(t===void 0||t.kind!==`runtime_consent`)break;this.items[this.lastConsentIndex]={...t,progress:{receivedBytes:e.receivedBytes??0,totalBytes:e.totalBytes??null}};break}case`terminal_created`:this.terminals[e.terminalId]={terminalId:e.terminalId,command:e.command,args:e.args,output:``,truncated:!1,exit:null};break;case`terminal_output`:{let t=this.terminals[e.terminalId];if(t===void 0)break;let n=t.output+e.chunk,r=t.truncated;n.length>h&&(n=n.slice(-h),r=!0),this.terminals[e.terminalId]={...t,output:n,truncated:r};break}case`terminal_exit`:{let t=this.terminals[e.terminalId];if(t===void 0)break;this.terminals[e.terminalId]={...t,exit:{exitCode:e.exitCode,signal:e.signal}};break}case`session_update`:this.applyUpdate(e.update);break;default:break}}mergePermissionInto(e){let t=this.permissionByToolCall.get(e);if(t===void 0)return;let n=this.items[t];if(n===void 0||n.kind!==`permission`||n.mergedIntoToolCall)return;let r={...n,mergedIntoToolCall:!0};this.items[t]=r,this.permissionsByToolCall[e]=r}pushMessageChunk(e,t,n){let r=`${e}:${t}`,i=this.messageIndex.get(r);if(i!==void 0&&i===this.items.length-1){let e=this.items[i];this.items[i]={...e,text:e.text+n};return}this.messageIndex.set(r,this.items.length),this.items.push({kind:`message`,role:e,text:n,messageId:t})}applyUpdate(e){switch(e.sessionUpdate){case`agent_message_chunk`:{let t=g(e.content);t!==null&&this.pushMessageChunk(`agent`,b(e),t);break}case`agent_thought_chunk`:{let t=g(e.content);t!==null&&this.pushMessageChunk(`thought`,b(e),t);break}case`user_message_chunk`:{let t=g(e.content);t!==null&&this.pushMessageChunk(`user`,b(e),t);break}case`tool_call`:{let t={kind:`tool_call`,toolCallId:e.toolCallId,title:e.title??i._({id:`EvIJVD`}),toolKind:e.kind??`other`,status:e.status??`pending`,diffs:[],terminalIds:[],content:[],locations:x(e.locations),rawInput:e.rawInput};C(t,e.content),this.toolCallIndex.set(e.toolCallId,this.items.length),this.items.push(t),this.mergePermissionInto(e.toolCallId);break}case`tool_call_update`:{let t=this.toolCallIndex.get(e.toolCallId);if(t===void 0)break;let n=this.items[t];if(n.kind!==`tool_call`)break;let r={...n,diffs:[...n.diffs],terminalIds:[...n.terminalIds],content:[...n.content]};e.status&&(r.status=e.status),e.title&&(r.title=e.title),e.locations&&(r.locations=x(e.locations));let i=e.rawInput;i!==void 0&&(r.rawInput=i),C(r,e.content),this.items[t]=r;break}case`plan`:{let t=e.entries;Array.isArray(t)&&(this.plan=t.map(e=>e).filter(e=>typeof e.content==`string`).map(e=>({content:e.content,priority:typeof e.priority==`string`?e.priority:void 0,status:typeof e.status==`string`?e.status:void 0})));break}case`usage_update`:{let t=e;this.tokenUsage={used:typeof t.used==`number`?t.used:void 0,size:typeof t.size==`number`?t.size:void 0};break}default:{let t=e.usage;t!==void 0&&(this.tokenUsage={used:t.used,size:t.size});break}}}};function y(e){let t=e.resolved;if(t===null)return null;if(t.optionId===null)return t.auto?{kind:`dismissed`}:{kind:`denied`,auto:!1,optionName:null};let n=e.options.find(e=>e.optionId===t.optionId);if(n===void 0)return{kind:`dismissed`};let r=n.kind.startsWith(`reject`),i=n.kind.startsWith(`allow`);return!r&&!i?{kind:`dismissed`}:{kind:r?`denied`:`approved`,auto:t.auto,optionName:n.name}}function b(e){let t=e.messageId;return typeof t==`string`?t:`default`}function x(e){return Array.isArray(e)?e.map(e=>e).filter(e=>typeof e.path==`string`).map(e=>({path:e.path,line:typeof e.line==`number`?e.line:void 0})):[]}function S(e,t){return!(e.tone!==t.tone||e.text!==t.text||e.failure===null!=(t.failure===null)||e.failure!==null&&t.failure!==null&&(e.failure.reason!==t.failure.reason||(e.failure.agentMessage??``)!==(t.failure.agentMessage??``)||(e.failure.machineDetail??``)!==(t.failure.machineDetail??``)))}function C(e,t){if(Array.isArray(t))for(let n of t){let t=n;if(t.type===`diff`&&typeof t.path==`string`&&typeof t.newText==`string`)e.diffs.push({path:t.path,oldText:typeof t.oldText==`string`?t.oldText:null,newText:t.newText});else if(t.type===`terminal`&&typeof t.terminalId==`string`)e.terminalIds.includes(t.terminalId)||e.terminalIds.push(t.terminalId);else if(t.type===`content`){let n=g(t.content);n!==null&&e.content.push(n)}else{let n=g(t);n!==null&&e.content.push(n)}}}var w=500,T=15e3,E=3e4,D=9e4,O=9e4,k=18e4,A=8e3,j=1e4,M=class extends Error{code;constructor(e,t){super(t),this.name=`ThreadResumeError`,this.code=e}},N=class extends Error{constructor(){super(`agent-thread channel is not connected`),this.name=`ThreadChannelUnavailableError`}},P=class{url=null;ws=null;reconnectDelay=w;reconnectTimer=null;threads=new Map;listeners=new Set;pendingCreates=new Map;pendingResumes=new Map;pendingRetries=new Map;pendingAuths=new Map;pendingQueueEdits=new Map;openedArchived=new Set;reqCounter=0;status=`idle`;version=0;setUrl(e){e!==this.url&&(this.url=e,this.teardownSocket(),e===null?this.setStatus(`idle`):this.connect())}subscribe=e=>(this.listeners.add(e),()=>this.listeners.delete(e));threadsSnapshot=[];threadsSnapshotVersion=-1;getThreads=()=>(this.threadsSnapshotVersion!==this.version&&(this.threadsSnapshot=[...this.threads.values()].map(e=>e.info).sort((e,t)=>e.createdAt-t.createdAt),this.threadsSnapshotVersion=this.version),this.threadsSnapshot);openTabsSnapshot=[];openTabsSnapshotVersion=-1;getOpenTabs=()=>(this.openTabsSnapshotVersion!==this.version&&(this.openTabsSnapshot=[...this.threads.values()].map(e=>e.info).filter(e=>e.archived!==!0||this.openedArchived.has(e.threadId)).sort((e,t)=>e.createdAt-t.createdAt),this.openTabsSnapshotVersion=this.version),this.openTabsSnapshot);archivedSnapshot=[];archivedSnapshotVersion=-1;getArchivedThreads=()=>(this.archivedSnapshotVersion!==this.version&&(this.archivedSnapshot=[...this.threads.values()].map(e=>e.info).filter(e=>e.archived===!0).sort((e,t)=>t.lastActivityAt-e.lastActivityAt),this.archivedSnapshotVersion=this.version),this.archivedSnapshot);getThread=e=>this.threads.get(e)??null;modelBuilders=new Map;getThreadModel=e=>{let t=this.threads.get(e);if(t===void 0)return null;let n=this.modelBuilders.get(e);return n===void 0&&(n=new v,this.modelBuilders.set(e,n)),n.sync(t.events)};getConnectionStatus=()=>this.status;async createThread(e){this.connectNow(),await this.waitForOpen(A),this.reqCounter+=1;let t=`create-${this.reqCounter}`,n=new Promise((e,n)=>{let r=setTimeout(()=>{this.pendingCreates.delete(t),n(Error(`thread creation timed out`))},E);this.pendingCreates.set(t,{resolve:e,reject:n,timer:r})}),r=c(e.agent),i=f(r),a=m(r),o=i!==void 0||a!==void 0?{...i===void 0?{}:{config:i},...a===void 0?{}:{modeId:a}}:void 0;return this.send({op:`create`,reqId:t,...e,...o===void 0?{}:{settings:o}}),n}prompt(e,t,n){let r=t.trim(),i=n!==void 0&&n.length>0;r===``&&!i||(this.reqCounter+=1,this.send({op:`prompt`,threadId:e,reqId:`prompt-${this.reqCounter}`,content:r,...i?{attachments:n}:{}}))}steer(e,t,n){let r=t.trim(),i=n!==void 0&&n.length>0;r===``&&!i||(this.reqCounter+=1,this.send({op:`steer`,threadId:e,reqId:`steer-${this.reqCounter}`,content:r,...i?{attachments:n}:{}}))}editQueued(e,t,n){let r=n.trim();if(r===``)return Promise.resolve();this.reqCounter+=1;let i=`queue-edit-${this.reqCounter}`,a=new Promise((e,t)=>{let n=setTimeout(()=>{this.pendingQueueEdits.delete(i),e()},j);this.pendingQueueEdits.set(i,{resolve:e,reject:t,timer:n})});return this.send({op:`queue_edit`,threadId:e,id:t,content:r,reqId:i}),a}holdQueued(e,t,n){this.send({op:`queue_hold`,threadId:e,id:t,held:n})}removeQueued(e,t){this.send({op:`queue_remove`,threadId:e,id:t})}respondPermission(e,t,n){this.send({op:`permission_response`,threadId:e,requestId:t,outcome:n})}respondRuntimeConsent(e,t,n){this.send({op:`runtime_consent_response`,threadId:e,requestId:t,outcome:n})}cancel(e){this.send({op:`cancel`,threadId:e})}setMode(e,t){this.send({op:`set_mode`,threadId:e,modeId:t})}renameThread(e,t){let n=t.trim();n!==``&&this.send({op:`rename`,threadId:e,title:n})}setConfigOption(e,t,n){this.send({op:`set_config_option`,threadId:e,configId:t,value:n})}closeThread(e){let t=this.threads.get(e);if(t?.info.archived===!0){this.send({op:`unsubscribe`,threadId:e}),this.openedArchived.delete(e),this.modelBuilders.delete(e),this.threads.set(e,{info:t.info,events:[],lastSeq:-1}),this.bump();return}this.send({op:`close`,threadId:e}),this.openedArchived.delete(e),this.modelBuilders.delete(e),this.threads.delete(e)&&this.bump()}openArchivedThread(e){let t=this.threads.get(e);t===void 0||t.info.archived!==!0||this.openedArchived.has(e)||(this.openedArchived.add(e),this.send({op:`subscribe`,threadId:e,sinceSeq:t.lastSeq+1}),this.bump())}deleteThread(e){this.send({op:`delete`,threadId:e}),this.openedArchived.delete(e),this.modelBuilders.delete(e),this.threads.delete(e)&&this.bump()}async resumeThread(e,t,n){this.connectNow(),await this.waitForOpen(A),this.reqCounter+=1;let r=`resume-${this.reqCounter}`,i=new Promise((e,t)=>{let n=setTimeout(()=>{this.pendingResumes.delete(r),t(new M(`timeout`,`resume timed out`))},D);this.pendingResumes.set(r,{resolve:e,reject:t,timer:n})});return this.send({op:`resume`,threadId:e,reqId:r,prompt:t,...n!==void 0&&n.length>0?{attachments:n}:{}}),i}async retryThread(e){this.connectNow(),await this.waitForOpen(A),this.reqCounter+=1;let t=`retry-${this.reqCounter}`,n=new Promise((e,n)=>{let r=setTimeout(()=>{this.pendingRetries.delete(t),n(Error(`retry timed out`))},O);this.pendingRetries.set(t,{resolve:e,reject:n,timer:r})});return this.send({op:`retry`,threadId:e,reqId:t}),n}async authenticateThread(e,t){this.connectNow(),await this.waitForOpen(A),this.reqCounter+=1;let n=`authenticate-${this.reqCounter}`,r=new Promise((e,t)=>{let r=setTimeout(()=>{this.pendingAuths.delete(n),t(Error(`sign-in timed out`))},k);this.pendingAuths.set(n,{resolve:e,reject:t,timer:r})});return this.send({op:`authenticate`,threadId:e,reqId:n,methodId:t}),r}connectNow(){this.url===null||this.ws!==null||(this.reconnectTimer!==null&&(clearTimeout(this.reconnectTimer),this.reconnectTimer=null),this.reconnectDelay=w,this.connect())}waitForOpen(e){return this.ws!==null&&this.ws.readyState===WebSocket.OPEN?Promise.resolve():new Promise((t,n)=>{let r=e=>{clearTimeout(a),i(),e?t():n(new N)},i=this.subscribe(()=>{this.ws!==null&&this.ws.readyState===WebSocket.OPEN&&r(!0)}),a=setTimeout(()=>r(!1),e)})}connect(){if(this.url===null)return;this.setStatus(`connecting`);let e;try{e=new WebSocket(this.url)}catch{this.scheduleReconnect();return}this.ws=e,e.onopen=()=>{if(this.ws===e){this.reconnectDelay=w,this.setStatus(`open`),this.send({op:`list`});for(let[e,t]of this.threads)t.info.archived===!0&&!this.openedArchived.has(e)||this.send({op:`subscribe`,threadId:e,sinceSeq:t.lastSeq+1})}},e.onmessage=t=>{if(this.ws!==e||typeof t.data!=`string`)return;let n;try{n=JSON.parse(t.data)}catch{return}this.handleFrame(n)},e.onclose=()=>{this.ws===e&&(this.ws=null,this.setStatus(`closed`),this.scheduleReconnect())},e.onerror=()=>{}}teardownSocket(){this.reconnectTimer!==null&&(clearTimeout(this.reconnectTimer),this.reconnectTimer=null);for(let e of this.pendingCreates.values())clearTimeout(e.timer),e.reject(new N);this.pendingCreates.clear();for(let e of this.pendingResumes.values())clearTimeout(e.timer),e.reject(new N);this.pendingResumes.clear();for(let e of this.pendingRetries.values())clearTimeout(e.timer),e.reject(new N);this.pendingRetries.clear();for(let e of this.pendingAuths.values())clearTimeout(e.timer),e.reject(new N);this.pendingAuths.clear();for(let e of this.pendingQueueEdits.values())clearTimeout(e.timer),e.resolve();this.pendingQueueEdits.clear();let e=this.ws;if(this.ws=null,e!==null)try{e.close()}catch{}}scheduleReconnect(){if(this.url===null||this.reconnectTimer!==null)return;let e=this.reconnectDelay;this.reconnectDelay=Math.min(this.reconnectDelay*2,T),this.reconnectTimer=setTimeout(()=>{this.reconnectTimer=null,this.connect()},e)}send(e){let t=this.ws;if(!(t===null||t.readyState!==WebSocket.OPEN))try{t.send(JSON.stringify(e))}catch{}}handleFrame(e){switch(e.op){case`created`:{let t=this.pendingCreates.get(e.reqId);t!==void 0&&(this.pendingCreates.delete(e.reqId),clearTimeout(t.timer),t.resolve(e.info)),this.upsertInfo(e.info);return}case`threads`:{let t=new Set;for(let n of e.threads){t.add(n.threadId);let e=this.threads.has(n.threadId);this.upsertInfo(n),!e&&n.archived!==!0&&this.send({op:`subscribe`,threadId:n.threadId,sinceSeq:0})}let n=!1;for(let e of Array.from(this.threads.keys()))t.has(e)||(this.threads.delete(e),this.modelBuilders.delete(e),this.openedArchived.delete(e),n=!0);n&&this.bump();return}case`resumed`:{let t=this.pendingResumes.get(e.reqId);t!==void 0&&(this.pendingResumes.delete(e.reqId),clearTimeout(t.timer),t.resolve(e.info)),this.upsertInfo(e.info);return}case`retried`:{let t=this.pendingRetries.get(e.reqId);t!==void 0&&(this.pendingRetries.delete(e.reqId),clearTimeout(t.timer),t.resolve(e.info)),this.upsertInfo(e.info);return}case`authenticated`:{let t=this.pendingAuths.get(e.reqId);t!==void 0&&(this.pendingAuths.delete(e.reqId),clearTimeout(t.timer),t.resolve(e.info)),this.upsertInfo(e.info);return}case`subscribed`:this.upsertInfo(e.info);return;case`queue_edited`:{let t=this.pendingQueueEdits.get(e.reqId);t!==void 0&&(this.pendingQueueEdits.delete(e.reqId),clearTimeout(t.timer),t.resolve());return}case`info`:this.upsertInfo(e.info);return;case`event`:this.appendEvents(e.threadId,e.seq,[e.event]);return;case`events`:this.appendEvents(e.threadId,e.fromSeq,e.events);return;case`error`:if(e.reqId!==void 0){let t=this.pendingCreates.get(e.reqId);if(t!==void 0){this.pendingCreates.delete(e.reqId),clearTimeout(t.timer),t.reject(Error(e.message));return}let n=this.pendingResumes.get(e.reqId);if(n!==void 0){this.pendingResumes.delete(e.reqId),clearTimeout(n.timer),n.reject(new M(e.code,e.message));return}let a=this.pendingRetries.get(e.reqId);if(a!==void 0){this.pendingRetries.delete(e.reqId),clearTimeout(a.timer),a.reject(Error(e.message));return}let o=this.pendingAuths.get(e.reqId);if(o!==void 0){this.pendingAuths.delete(e.reqId),clearTimeout(o.timer),o.reject(Error(e.message));return}let s=this.pendingQueueEdits.get(e.reqId);if(s!==void 0){this.pendingQueueEdits.delete(e.reqId),clearTimeout(s.timer),s.reject(Error(e.message));return}if(e.reqId.startsWith(`prompt-`)||e.reqId.startsWith(`steer-`)){r.error(i._({id:`XNBGZw`,values:{0:e.message}}));return}}console.warn(`[agent-threads] server error frame:`,e.code,e.message);return;default:return}}appendEvents(e,t,n){let r=this.threads.get(e);if(r===void 0||n.length===0)return;let i=Math.max(r.lastSeq+1-t,0);if(i>=n.length)return;let a=i===0?n:n.slice(i),o=r.info;for(let e of a)o=F(o,e);this.threads.set(e,{info:o,events:[...r.events,...a],lastSeq:t+n.length-1}),this.bump()}upsertInfo(e){let t=this.threads.get(e.threadId);t===void 0?this.threads.set(e.threadId,{info:e,events:[],lastSeq:-1}):e.archived===!0&&t.info.archived!==!0?(this.openedArchived.delete(e.threadId),this.modelBuilders.delete(e.threadId),this.threads.set(e.threadId,{info:e,events:[],lastSeq:-1})):this.threads.set(e.threadId,{...t,info:e}),this.bump()}setStatus(e){this.status!==e&&(this.status=e,this.bump())}bump(){this.version+=1;for(let e of this.listeners)e()}};function F(e,t){switch(t.kind){case`status`:return{...e,status:t.status,lastActivityAt:t.ts};case`title_changed`:return{...e,title:t.title,lastActivityAt:t.ts};default:return{...e,lastActivityAt:t.ts}}}var I=new P;function L(){return I}function R(){return(0,a.useSyncExternalStore)(I.subscribe,I.getOpenTabs,I.getOpenTabs)}function z(){return(0,a.useSyncExternalStore)(I.subscribe,I.getArchivedThreads,I.getArchivedThreads)}function B(e){let t=(0,o.c)(2),n;t[0]===e?n=t[1]:(n=()=>I.getThread(e),t[0]=e,t[1]=n);let r=n;return(0,a.useSyncExternalStore)(I.subscribe,r,r)}function V(e){let t=(0,o.c)(2),n;t[0]===e?n=t[1]:(n=()=>I.getThreadModel(e),t[0]=e,t[1]=n);let r=n;return(0,a.useSyncExternalStore)(I.subscribe,r,r)}function H(){return(0,a.useSyncExternalStore)(I.subscribe,I.getConnectionStatus,I.getConnectionStatus)}function U(e){if(e===null)return null;try{let t=new URL(e);return t.pathname=`/collab/thread`,t.search=``,t.toString()}catch{return null}}export{B as a,z as c,c as d,d as f,U as i,R as l,M as n,H as o,p,L as r,V as s,N as t,y as u};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{t as e}from"./repair-skills-DdLknuYw.mjs";export{e as repairSkills};
|
package/dist/src-B8QX7oNJ.mjs
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import{o as e}from"./chunk-DTipWd-i.mjs";import{K as t,pt as n,q as r}from"./sleep-DhRrtbfG.mjs";import{Dc as i,Ec as a,bo as o,ct as s,jc as c,lt as l}from"./src-BD1wHyiU.mjs";import{Ci as u,Pn as ee,at as d,ei as f,it as p,ot as m,rt as h}from"./src-CKvbaaFV.mjs";import{D as g,F as _,I as v,k as y}from"./fs-traced-2B_-YK-g.mjs";import{C as b,S as x,_ as S,f as C,r as w}from"./server-lock-RKPNHNqb.mjs";import{t as T}from"./yazl-DZr4PyKA.mjs";import{b as E,h as D,m as te}from"./resolve-project-root-CHFE5Tp7.mjs";import{c as ne}from"./colors-DSyAT9Cz.mjs";import{n as O}from"./acp-harness-probe-BXaEG9XN.mjs";import{E as k,T as re,_ as ie,b as A,o as ae,w as j,x as oe}from"./init-DJQw_oSo.mjs";import{n as se}from"./constants-DzwYLdlF.mjs";import{t as ce}from"./is-object-Bw0-z8qH.mjs";import"./loader-lM2dlAdG.mjs";import"./skill-teardown-DcAF7q_b.mjs";import"./preview-P4lIN2Xz.mjs";import{execSync as le,spawnSync as M}from"node:child_process";import{basename as N,dirname as P,join as F,relative as ue,resolve as I,sep as de}from"node:path";import{cpSync as fe,createWriteStream as pe,existsSync as L,lstatSync as me,mkdirSync as R,mkdtempSync as he,readFileSync as z,readdirSync as B,readlinkSync as ge,rmSync as _e,statSync as ve,writeFileSync as V}from"node:fs";import{arch as ye,freemem as be,homedir as H,hostname as xe,platform as Se,release as Ce,tmpdir as we,totalmem as Te,type as Ee,uptime as De}from"node:os";import"node:fs/promises";import{createHash as Oe}from"node:crypto";var ke=n();const Ae=new Set([`start`,`stop`,`status`,`clean`,`ui`,`mcp`,`preview`,`lint`,`deinit`,`auth`]);function je(e,t,n=ee){if(e!==void 0&&!Ae.has(e))return null;let r=n(t);return r===null||r.distance===0?null:r.rootPath}let Me=null;function Ne(e){Me=e}function Pe(){return Me??process.cwd()}function U(){return F(H(),`.ok`,`bug-reports`)}function Fe(e=new Date){let t=e.toISOString().replace(/[:.]/g,`-`),n=U(),r=`${t}-bugreport`,i=F(n,`${r}.zip`);for(let e=2;L(i);e+=1)i=F(n,`${r}-${e}.zip`);return i}function Ie(e,t){let n=F(e,`.ok`,`config.yml`);if(L(n))try{let e=z(n,`utf8`).match(/^\s*name:\s*['"]?(.+?)['"]?\s*$/m);if(e?.[1])return e[1]}catch(e){t?.warn({configPath:n,err:e},`bug-report: failed to read .ok/config.yml for project slug; using path-hash fallback`)}return L(F(e,`.ok`))?Oe(`sha256`).update(I(e)).digest(`hex`).slice(0,12):null}function Le(){let e={timestamp:new Date().toISOString(),platform:Se(),osType:Ee(),osRelease:Ce(),hostname:`[redacted]`,uptime:De(),freeMem:be(),totalMem:Te(),nodeVersion:process.version,bunVersion:process.versions.bun??null,v8Version:process.versions.v8??null,pid:process.pid};try{e.macosVersion=le(`sw_vers -productVersion 2>/dev/null`,f({encoding:`utf8`})).trim()}catch{}try{let t=F(__dirname,`..`,`..`,`package.json`);L(t)&&(e.okVersion=JSON.parse(z(t,`utf8`)).version)}catch{}return e}const Re=[{prefix:`cli`,projectTagged:!0},{prefix:`desktop`,projectTagged:!1},{prefix:`mcp`,projectTagged:!1}];function ze(e){let t=N(e);return Re.some(e=>e.projectTagged&&t.startsWith(`${e.prefix}.`))}function Be(e,t){return We(e,t).files}const Ve=[`ShipIt_stderr.log`,`ShipIt_stdout.log`];function He(e,t=O){let n=F(e,`${t}.ShipIt`);return L(n)?Ve.map(e=>F(n,e)).filter(e=>L(e)):[]}function Ue(e){if(!L(e))return[];try{return B(e).filter(e=>e.endsWith(`.yaml`)).sort().slice(-25).map(t=>F(e,t))}catch{return[]}}function We(e,t){if(!L(t))return{files:[],excludedByProjectSlug:0};let n=B(t).filter(e=>e.endsWith(`.log`)||/\.log\.\d+$/.test(e)).map(e=>F(t,e));if(!e)return{files:n,excludedByProjectSlug:0};let r=n.filter(ze),i=[],a=r.filter(t=>{try{return z(t,`utf8`).includes(`"project":"${e}"`)}catch{return i.push(t),!1}});if(a.length===0)return{files:n,excludedByProjectSlug:0};let o=new Set([...a,...i]);return{files:n.filter(e=>!ze(e)||o.has(e)),excludedByProjectSlug:r.length-o.size}}function Ge(e){let t=F(e,`.ok`,`local`);return L(t)?{files:[`server.lock`,`last-spawn-error.log`,s].map(e=>F(t,e)).filter(e=>L(e))}:{files:[]}}function Ke(e){let t=F(e,`.ok`,`local`,`logs`);return L(t)?{files:[`server-current.jsonl`,`server-prev.jsonl`].map(e=>F(t,e)).filter(e=>L(e))}:{files:[]}}function qe(e){if(e.redact){let{redacted:t,patterns:n,lineCount:r}=i(e.content);e.zipfile.addBuffer(Buffer.from(t,`utf8`),e.name),e.bundleFiles.push(e.name),n.length>0&&e.redactions.push({file:e.name,lineCount:r,patterns:n})}else e.zipfile.addBuffer(Buffer.from(e.content,`utf8`),e.name),e.bundleFiles.push(e.name)}function W(e){for(let t of e.files)try{qe({zipfile:e.zipfile,name:`${e.prefix}/${N(t)}`,content:z(t,`utf8`),redact:e.redact,bundleFiles:e.bundleFiles,redactions:e.redactions})}catch(n){e.logger?.warn({file:t,prefix:e.prefix,err:n},`bug-report: skipped unreadable file`)}}async function Je(t){let{redact:n,outputPath:r,logger:i}=t,o=t.userLogsDir??F(H(),`.ok`,`logs`),s=t.projectDir?Ie(t.projectDir,i):null;R(P(r),{recursive:!0}),i?.info({projectSlug:s},`gathering diagnostic data`);let l=Le();l.desktop=t.desktop??null,l.language=t.language??null;let{files:u,excludedByProjectSlug:ee}=We(s,o),{files:d}=t.projectDir?Ge(t.projectDir):{files:[]},{files:f}=t.projectDir?Ke(t.projectDir):{files:[]},p=t.shipItLogFiles??[];i?.info({logFileCount:u.length,logFilesExcludedByProjectSlug:ee,lockFileCount:d.length,localSinkFileCount:f.length,shipItLogFileCount:p.length},`files collected`);let m=[],h=[],{ZipFile:g}=await import(`./yazl-jVENrf5i.mjs`).then(t=>e(t.default,1)),_=new g;W({zipfile:_,files:[...u,...p],prefix:`logs`,redact:n,bundleFiles:h,redactions:m,logger:i}),W({zipfile:_,files:d,prefix:`lockdir`,redact:n,bundleFiles:h,redactions:m,logger:i}),W({zipfile:_,files:f,prefix:`local-logs`,redact:n,bundleFiles:h,redactions:m,logger:i}),W({zipfile:_,files:t.bugReportLedgerFiles??[],prefix:c,redact:n,bundleFiles:h,redactions:m,logger:i});for(let e of t.extraFiles??[])try{let t=z(e.sourcePath),n=`extra/${e.zipName??N(e.sourcePath)}`;_.addBuffer(t,n),h.push(n)}catch(t){i?.warn({sourcePath:e.sourcePath,err:t},`extra file unreadable; omitted from bundle`)}t.note&&qe({zipfile:_,name:`note.txt`,content:t.note,redact:n,bundleFiles:h,redactions:m});let v=JSON.stringify(l,null,2);_.addBuffer(Buffer.from(v,`utf8`),`sysinfo.json`),h.push(`sysinfo.json`);let y={generatedAt:new Date().toISOString(),disciplineVersion:`1.0.0`,projectSlug:s,files:h,redactions:m,sysinfo:l};_.addBuffer(Buffer.from(JSON.stringify(y,null,2),`utf8`),`MANIFEST.json`);let b=m.reduce((e,t)=>e+t.lineCount,0),x=new Set(p.map(e=>`logs/${N(e)}`)),S=h.filter(e=>x.has(e)),C=new Set((t.bugReportLedgerFiles??[]).map(e=>`${c}/${N(e)}`)),w=h.filter(e=>C.has(e)),T=s?h.filter(e=>e.startsWith(`logs/`)&&!ze(e)&&!x.has(e)):[],E=[`# Bug Report Bundle`,``,`Generated: ${y.generatedAt}`,`Project: ${s??`(unscoped)`}`,`Discipline version: ${y.disciplineVersion}`,``,`## Contents`,``,...h.map(e=>`- ${e}`),``,`## Privacy`,``,...T.length>0?[`Scope: some collected logs are user-wide rather than project-scoped.`,`These are written once per machine per day and can contain activity`,`from other projects open on this machine, including captured console`,`output:`,...T.map(e=>`- ${e}`),``]:[],...S.length>0?[`Installer logs: written by the macOS update helper rather than by`,`OpenKnowledge itself, and machine-wide rather than scoped to any one`,`project. They record the install and update history of this app on`,`this machine. Only this app is collected, never other applications`,`that use the same update mechanism:`,...S.map(e=>`- ${e}`),``]:[],...w.length>0?[`Send history: one small record per bug report previously generated`,`on this machine — when it was generated, whether sending it`,`succeeded, and why it failed if it did. This is what makes a failed`,`send diagnosable at all. It is machine-wide rather than scoped to`,`this project, so it names the other projects reports were filed`,`from. It carries no document content:`,...w.map(e=>`- ${e}`),``]:[],...n?[`This bundle was auto-redacted before packaging.`,`Patterns checked: ${a.join(`, `)}`,b>0?`${b} line(s) were scrubbed across ${m.length} file(s).`:`No redactions were needed.`,`See MANIFEST.json for the full redaction audit report.`,``,`This bundle is safe to attach to a GitHub issue.`]:[`Redaction was disabled for this bundle; file contents are unmodified.`]].join(`
|
|
2
|
-
`);_.addBuffer(Buffer.from(E,`utf8`),`README.md`),_.end();let D=pe(r);return _.outputStream.pipe(D),await new Promise((e,t)=>{D.on(`close`,e),D.on(`error`,t)}),i?.info({bundlePath:r,fileCount:h.length,redactionCount:b},`bundle written`),{zipPath:r,summary:{projectSlug:s,files:h,redactions:m,redactedLineCount:b,generatedAt:y.generatedAt}}}var Ye=e(T(),1),G=e(ne(),1);function Xe(e){return v({absPath:y(`user`,e,e),sideline:!1,warn:()=>{}}).value.appearance?.language??`system`}function Ze({home:e=H(),env:n=process.env}={}){let i=Xe(e),{override:a,preferenceList:s}=g(n),{locale:c,source:l}=o({override:a,storedPreference:i,supportedLocales:r,preferenceList:s,autoDetectableLocales:t});return{preference:i,locale:c,source:l,systemLanguages:s}}function Qe(e,t){return t.length===0||!e.includes(t)?e:e.split(t).join(`<CONTENT_DIR>`)}function $e(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function K(e,t){if(typeof e==`string`)return Qe(e,t.contentDir);if(Array.isArray(e))return e.map(e=>K(e,t));if(!$e(e))return e;let n={};for(let[r,i]of Object.entries(e))n[r]=K(i,t);return n}function et(e,t){let n=z(e,`utf-8`);if(n.length===0)return;let r=n.endsWith(`
|
|
3
|
-
`),i=n.split(`
|
|
4
|
-
`),a=[];for(let e=0;e<i.length;e++){let n=i[e]??``;if(!(e===i.length-1&&n===``)){if(n.length===0){a.push(``);continue}try{let e=K(JSON.parse(n),t);a.push(JSON.stringify(e))}catch{a.push(n)}}}V(e,r?`${a.join(`
|
|
5
|
-
`)}\n`:a.join(`
|
|
6
|
-
`))}function tt(e,t){let n=z(e,`utf-8`);if(n.trim().length!==0)try{let r=K(JSON.parse(n),t),i=n.endsWith(`
|
|
7
|
-
`)?`
|
|
8
|
-
`:``;V(e,`${JSON.stringify(r,null,2)}${i}`)}catch{let r=Qe(n,t.contentDir);r!==n&&V(e,r)}}function nt(e,t){let n=z(e,`utf-8`),r=Qe(n,t.contentDir);r!==n&&V(e,r)}function rt(e){try{return B(e,{withFileTypes:!0}).filter(e=>e.isFile()).map(t=>F(e,t.name))}catch{return[]}}const it=new Set([`agent-presence.json`,`agent-effects.json`,`runtime.json`]);function at(e){return/\.log\.\d+$/.test(e)}function ot(e){return e.endsWith(`.jsonl`)||e.endsWith(`.log`)||at(e)}function st(e){let t={contentDir:e.contentDir};for(let n of[`telemetry`,`logs`,`process`])for(let r of rt(F(e.stagingDir,n)))ot(r)?et(r,t):r.endsWith(`.json`)?tt(r,t):nt(r,t);for(let n of rt(F(e.stagingDir,`state`))){let e=N(n);n.endsWith(`.jsonl`)?et(n,t):it.has(e)?tt(n,t):nt(n,t)}}const ct=[`.ok`,`local`,`telemetry`],lt=[`.ok`,`local`,`logs`],ut=[`.ok`,`local`,`loss-capture`],dt=`spans-current.jsonl`,ft=`spans-prev.jsonl`,pt=`server-current.jsonl`,mt=`server-prev.jsonl`,ht=`loss-current.jsonl`,gt=`loss-prev.jsonl`;function _t(e){return F(e,...ct,dt)}function vt(e){return F(e,...ct,ft)}function yt(e){return F(e,...lt,pt)}function bt(e){return F(e,...lt,mt)}function xt(e){return F(e,...ut,ht)}function St(e){return F(e,...ut,gt)}const Ct=1e3;async function wt(e){try{let t=await fetch(`http://127.0.0.1:${e}/api/metrics/agent-presence`,{signal:AbortSignal.timeout(Ct)});return t.ok?await t.text():null}catch{return null}}async function Tt(e){try{let t=await fetch(`http://127.0.0.1:${e}/api/metrics/agent-effects`,{signal:AbortSignal.timeout(Ct)});return t.ok?await t.text():null}catch{return null}}async function Et(e){try{let t=await fetch(`http://127.0.0.1:${e}/api/metrics/watcher-recent`,{signal:AbortSignal.timeout(Ct)});return t.ok?await t.text():null}catch{return null}}function Dt(e){try{let t=JSON.parse(e);if(typeof t!=`object`||!t)return null;let n=t.decisions;return Array.isArray(n)?n.length===0?``:`${n.map(e=>JSON.stringify(e)).join(`
|
|
9
|
-
`)}\n`:null}catch{return null}}function Ot(e){let t=F(e,`.git`,`ok`);if(!L(t))return null;let n=M(`git`,[`-C`,t,`log`,`--oneline`,`-50`],f({encoding:`utf-8`,timeout:2e3}));return n.error||n.status!==0?null:n.stdout??``}function kt(e){let t=F(e,`.git`,`ok`);if(!L(t))return null;let n=M(`git`,[`-C`,t,`for-each-ref`,`--sort=-creatordate`,`--count=50`,`--format=%(refname)%09%(creatordate:iso-strict)%09%(contents:subject)`,`refs/checkpoints/`],f({encoding:`utf-8`,timeout:2e3}));return n.error||n.status!==0?null:n.stdout??``}function At(){let e=process.env.OK_DESKTOP_VERSION,t=process.env.OK_DESKTOP_PACKAGED,n=process.env.OK_DESKTOP_CHANNEL;return e===void 0||t===void 0||n===void 0?null:{electronVersion:e,packaged:t===`1`||t.toLowerCase()===`true`,channel:n}}function jt(){return{nodeVersion:process.version,platform:Se(),arch:ye()}}function Mt(){return process.env.OTEL_SDK_DISABLED===`false`}function q(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function Nt(e){if(!L(e))return{};let t;try{t=(0,ke.parse)(z(e,`utf-8`))}catch(t){return console.warn(`[ok diagnose bundle] failed to parse ${e} for manifest config; manifest will report schema defaults. Reason: ${t instanceof Error?t.message:String(t)}`),{}}if(!q(t))return{};let n=t.telemetry;if(!q(n))return{};let r=n.localSink;return q(r)?r:{}}function Pt(e){return typeof e==`boolean`?e:void 0}function Ft(e){return typeof e==`number`&&Number.isFinite(e)&&e>0?e:void 0}function J(e){if(q(e))return Ft(e.maxBytes)}function It(e){let t=Nt(y(`project`,e)),n=Nt(y(`project-local`,e));return{enabled:Pt(n.enabled)??Pt(t.enabled)??!0,spansMaxBytes:J(n.spans)??J(t.spans)??52428800,logsMaxBytes:J(n.logs)??J(t.logs)??26214400}}function Lt(e){return Oe(`sha256`).update(e).digest(`hex`)}function Rt(e){let t=z(e),n=0;for(let e=0;e<t.length;e++)t[e]===10&&n++;return n}function zt(e){let t=z(e,`utf-8`),n=`"doc.name"`,r=0,i=t.indexOf(n);for(;i!==-1;)r++,i=t.indexOf(n,i+10);return r}function Y(e,t){if(!L(e))return!1;try{return R(P(t),{recursive:!0}),fe(e,t),!0}catch{return!1}}function Bt(e){let t=[],n=e=>{let r=B(e,{withFileTypes:!0});for(let i of r){let r=F(e,i.name);i.isDirectory()?n(r):i.isFile()&&t.push(r)}};return n(e),t.sort()}const Vt=new Set([`.jsonl`]);function Ht(e){let t=e.lastIndexOf(`.`);return t===-1?!1:Vt.has(e.slice(t))}const Ut=new Set([`.jsonl`,`.json`,`.txt`,`.log`,`.lock`,`.yaml`,`.yml`]);function Wt(e){if(at(e))return!0;let t=e.lastIndexOf(`.`);return t===-1?!1:Ut.has(e.slice(t))}function Gt(e){let t=[];for(let n of Bt(e)){let r=Kt(e,n);if(!Wt(r))continue;let{redacted:a,patterns:o,lineCount:s}=i(z(n,`utf-8`));o.length!==0&&(V(n,a),t.push({file:r,lineCount:s,patterns:o}))}return{redactions:t,redactedLineCount:t.reduce((e,t)=>e+t.lineCount,0)}}function Kt(e,t){return ue(e,t).split(de).join(`/`)}async function qt(e){let t=I(e.contentDir),n=I(e.projectDir??e.contentDir),r=e.deps??{},i=r.fetchAgentPresence??wt,a=r.fetchAgentEffects??Tt,o=r.fetchWatcherRecent??Et,u=r.readShadowHead??Ot,ee=r.readCheckpointRefs??kt,d=r.now??(()=>new Date),f=r.okVersion??(()=>se),p=r.readDesktopEnv??At,m=r.readLanguage??Ze,h=r.readRuntime??jt,g=r.isOtlpPushEnabled??Mt,_=he(F(we(),`ok-bundle-`));try{R(F(_,`telemetry`),{recursive:!0}),R(F(_,`logs`),{recursive:!0}),R(F(_,`state`),{recursive:!0}),Y(_t(n),F(_,`telemetry`,dt)),Y(vt(n),F(_,`telemetry`,ft)),Y(yt(n),F(_,`logs`,pt)),Y(bt(n),F(_,`logs`,mt));for(let t of e.userLogFiles??[])Y(t,F(_,`logs`,N(t)));for(let t of e.userStateFiles??[])Y(t,F(_,c,N(t)));let v=F(n,`.ok`,`local`),y=F(v,`server.lock`),b=`not-running`,x=`no server.lock`,S=null;if(L(y)){Y(y,F(_,`state`,`server.lock`));try{let e=z(y,`utf-8`),t=JSON.parse(e);typeof t.port==`number`?S=t.port:x=`lock present but no port`}catch{x=`lock present but unparseable`}}if(S!==null){let e=await i(S);e===null?x=`agent-presence endpoint at :${S} unreachable`:(V(F(_,`state`,`agent-presence.json`),e),b=`running`,x=``);let t=await a(S);t!==null&&V(F(_,`state`,`agent-effects.json`),t);let n=await o(S);if(n!==null){let e=Dt(n);e!==null&&V(F(_,`state`,`watcher-recent.jsonl`),e)}}let C=u(t);C!==null&&V(F(_,`state`,`shadow-head.txt`),C);let w=ee(t);w!==null&&V(F(_,`state`,`checkpoint-refs.txt`),w),Y(xt(n),F(_,`state`,ht)),Y(St(n),F(_,`state`,gt)),Y(F(v,`last-spawn-error.log`),F(_,`state`,`last-spawn-error.log`)),Y(F(v,l),F(_,`state`,l)),Y(F(v,s),F(_,`state`,s));let T=h(),E=p(),D=m(),te={ok:{version:f(),nodeVersion:T.nodeVersion,platform:T.platform,arch:T.arch},host:{desktop:E,language:D}};V(F(_,`state`,`runtime.json`),`${JSON.stringify(te,null,2)}\n`);let ne=b===`running`?`running
|
|
10
|
-
`:`not-running (${x})\n`;if(V(F(_,`state`,`server-status.txt`),ne),e.processDir&&L(e.processDir)){let t=F(_,`process`);R(t,{recursive:!0}),fe(e.processDir,t,{recursive:!0})}let O=e.redact===!0;O&&st({stagingDir:_,contentDir:t}),e.note&&V(F(_,`note.txt`),e.note);let k=null;e.scrubSecrets===!0&&(k=Gt(_));for(let t of e.extraFiles??[])Y(t.sourcePath,F(_,`extra`,t.zipName??N(t.sourcePath)))||r.logger?.warn({sourcePath:t.sourcePath},`extra file missing; omitted from bundle`);let re=It(n),ie=Bt(_),A=[],ae=0,j=0;for(let e of ie){let t=Kt(_,e),n=ve(e).size,r=Ht(t)?Rt(e):0;A.push({path:t,bytes:n,lines:r}),ae+=n,t.startsWith(`telemetry/`)&&Ht(t)&&(j+=zt(e))}let oe={applied:O};k!==null&&(oe.secretScrub=k);let se={schemaVersion:2,createdAt:d().toISOString(),ok:{version:f(),nodeVersion:T.nodeVersion,platform:T.platform,arch:T.arch},host:{desktop:E,language:D},contentDir:{pathSha256:Lt(t),absolutePath:O?`<CONTENT_DIR>`:t},telemetry:{localSink:re,otlpPushEnabled:g()},redaction:oe,serverStatus:b,files:A};V(F(_,`manifest.json`),`${JSON.stringify(se,null,2)}\n`);let ce=ie.some(e=>{try{return z(e,`utf-8`).includes(t)}catch{return!1}}),le={totalBytes:ae,fileCount:A.length,docNameCount:j,contentDirVisible:ce,redacted:O},M=!1;return{stagingDir:_,manifest:se,summary:le,cleanup:()=>{M||(M=!0,_e(_,{recursive:!0,force:!0}))}}}catch(e){throw _e(_,{recursive:!0,force:!0}),e}}async function Jt(e){let{collected:t,outputPath:n}=e,r=P(n);if(!L(r))throw Error(`ok diagnose bundle: parent directory does not exist: ${r}. Create it or pass --out with an existing parent.`);let i=new Ye.ZipFile,a=Bt(t.stagingDir);for(let e of a){let n=Kt(t.stagingDir,e);i.addFile(e,n)}i.end();let o=pe(n);return i.outputStream.pipe(o),await new Promise((e,t)=>{o.on(`close`,e),o.on(`error`,t),i.outputStream.on(`error`,t)}),n}function Yt(e,t){let n=F(e,`.ok`,`config.yml`);if(L(n))try{let t=(0,ke.parse)(z(n,`utf-8`)),r=ce(t)?t.content:void 0,i=ce(r)?r.dir:void 0;if(typeof i==`string`&&i.length>0)return I(e,i)}catch(e){t?.warn({configPath:n,err:e},`bug-report: failed to read .ok/config.yml; falling back to project root as content dir`)}return I(e)}async function Xt(e,t,n,r){let i=Ie(t,e.logger),a=await qt({contentDir:Yt(t,e.logger),projectDir:t,redact:e.redact,scrubSecrets:e.redact,note:e.note,extraFiles:e.extraFiles,userLogFiles:[...Be(i,e.userLogsDir??F(H(),`.ok`,`logs`)),...He(e.cachesDir??F(H(),`Library`,`Caches`))],userStateFiles:Ue(e.bugReportsDir??U()),deps:{readDesktopEnv:n,readLanguage:r,logger:e.logger}});try{R(P(e.outputPath),{recursive:!0}),await Jt({collected:a,outputPath:e.outputPath});let t=a.manifest.redaction.secretScrub;return{zipPath:e.outputPath,summary:{level:`full`,systemWide:!1,projectSlug:i,files:a.manifest.files.map(e=>e.path),redactions:t?.redactions??[],redactedLineCount:t?.redactedLineCount??0,generatedAt:a.manifest.createdAt}}}finally{a.cleanup()}}async function Zt(e){let{projectDir:t}=e,n=e.readDesktopEnv??At,r=e.readLanguage??Ze;if(e.level===`full`&&t!==void 0)return Xt(e,t,n,r);let{zipPath:i,summary:a}=await Je({projectDir:t,redact:e.redact,outputPath:e.outputPath,userLogsDir:e.userLogsDir,shipItLogFiles:He(e.cachesDir??F(H(),`Library`,`Caches`)),bugReportLedgerFiles:Ue(e.bugReportsDir??U()),logger:e.logger,note:e.note,extraFiles:e.extraFiles,desktop:n(),language:r()});return{zipPath:i,summary:{level:e.level,systemWide:t===void 0,projectSlug:a.projectSlug,files:a.files,redactions:a.redactions,redactedLineCount:a.redactedLineCount,generatedAt:a.generatedAt}}}function Qt(e,t){if(!L(e))return{status:`missing`,lockPath:e};let n;try{n=JSON.parse(z(e,`utf-8`))}catch{return{status:`corrupt`,lockPath:e}}if(!n||typeof n!=`object`||!b(n.pid))return{status:`corrupt`,lockPath:e};let r=n;if(!(t.isAlive??x)(r.pid))return{status:`dead-pid`,lockPath:e,lock:r};if(typeof r.machineId==`string`)return r.machineId===(t.machineId??S())?{status:`alive`,lockPath:e,lock:r}:{status:`foreign-host`,lockPath:e,lock:r};let i=t.host??xe();return r.hostname===i?{status:`alive`,lockPath:e,lock:r}:{status:`foreign-host`,lockPath:e,lock:r}}function X(e,t,n={}){return Qt(C(e,t),n)}function Z(e,t={}){return Qt(F(e,`ui.lock`),t)}function $t(e){return e.replace(/:\d+$/,``)}function en(e){let t=e.trim();if(!t)return null;{let e=/^https?:\/\/([^/?#]+)\/([\w.\-~%]+)\/([\w.\-~%]+?)(?:\.git)?\/?$/.exec(t);if(e)return{protocol:`https`,hostname:$t(e[1]),owner:e[2],name:e[3]}}{let e=/^ssh:\/\/(?:[\w.-]+@)?([^/?#]+)\/([\w.\-~%]+)\/([\w.\-~%]+?)(?:\.git)?\/?$/.exec(t);if(e)return{protocol:`ssh`,hostname:$t(e[1]),owner:e[2],name:e[3]}}{let e=/^git:\/\/([^/?#]+)\/([\w.\-~%]+)\/([\w.\-~%]+?)(?:\.git)?\/?$/.exec(t);if(e)return{protocol:`git`,hostname:$t(e[1]),owner:e[2],name:e[3]}}{let e=/^(?:[\w.-]+@)?([\w.-]+):([\w.\-~%]+)\/([\w.\-~%]+?)(?:\.git)?$/.exec(t);if(e?.[1].includes(`.`)||e&&t.startsWith(`git@`))return{protocol:`ssh`,hostname:e[1],owner:e[2],name:e[3]}}{let e=/^git:([\w.-]+)\/([\w.\-~%]+)\/([\w.\-~%]+?)(?:\.git)?\/?$/.exec(t);if(e)return{protocol:`git`,hostname:e[1],owner:e[2],name:e[3]}}if(!t.includes(`://`)&&!t.includes(`@`)&&!t.startsWith(`/`)){let e=/^([\w.-]+)\/([\w.\-~%]+?)(?:\.git)?$/.exec(t);if(e)return{protocol:`https`,hostname:`github.com`,owner:e[1],name:e[2]}}return null}const tn=/^# >>> open-knowledge cli >>>\n[\s\S]*?^# <<< open-knowledge cli <<<\n?/m;function nn(e){return F(e,`Library`,`Application Support`,`OpenKnowledge`,`path-install.json`)}const rn={existsSync:e=>L(e),readFileSync:(e,t)=>z(e,t),lstatSync:e=>me(e),readlinkSync:e=>ge(e)};function an(e,t=rn){let n=nn(e);if(!t.existsSync(n))return null;try{let e=JSON.parse(t.readFileSync(n,`utf8`));return e?.version===1?e:null}catch{return null}}function on(e){let t=e.replace(tn,``);return{text:t,changed:t!==e,emptyAfter:t.trim()===``}}function sn(e,t,n=rn){try{return n.lstatSync(e).isSymbolicLink()?n.readlinkSync(e)===t:!1}catch{return!1}}function cn(e){return te(e)||D(e)||oe(e)}const ln=10*1024*1024;function un(e,t,n,r){let i=ae(e,t,n,r);if(i.kind===`absent`||i.kind===`no-entry`)return{kind:`not-present`};if(i.kind===`decline`)return{kind:`declined`,reason:i.reason};if(!cn(i.entry))return{kind:`left-foreign`};let a;try{a=r??e.configPath(t,n)}catch{return{kind:`not-present`}}let o=e.serverName(t);return e.format===`file`?(_e(a,{force:!0}),{kind:`removed`}):e.format===`toml`?pn(a,o):e.format===`yaml`?fn(a,e.topLevelKey,o):dn(a,e.topLevelKey,e.serverMapSubKey,o)}function dn(e,t,n,r){let i;try{i=z(e,`utf-8`)}catch{return{kind:`declined`,reason:`unparseable`}}if(Buffer.byteLength(i,`utf-8`)>ln)return{kind:`declined`,reason:`oversize`};let{text:a,changed:o}=k(i,ie(t,n,r));return o?(_(e,a,{mode:j(e)}),{kind:`removed`}):{kind:`not-present`}}function fn(e,t,n){let r;try{r=z(e,`utf-8`)}catch{return{kind:`declined`,reason:`unparseable`}}if(Buffer.byteLength(r,`utf-8`)>ln)return{kind:`declined`,reason:`oversize`};let i=r.charCodeAt(0)===65279,a=i?r.slice(1):r,o=(0,ke.parseDocument)(a);if(o.errors.length>0)return{kind:`declined`,reason:`unparseable`};let s=[t,n];if(!o.hasIn(s))return{kind:`not-present`};o.deleteIn(s);let c=o.toString(),l=re(a);a.trim()===``||a.endsWith(`
|
|
11
|
-
`)?c.endsWith(`
|
|
12
|
-
`)||(c=`${c}\n`):c=c.replace(/\n+$/,``),l&&(c=c.replace(/\r\n/g,`
|
|
13
|
-
`).replace(/\n/g,`\r
|
|
14
|
-
`));let u=`${i?``:``}${c}`;return u!==r&&_(e,u,{mode:j(e)}),{kind:`removed`}}function pn(e,t){let n=A();if(n.backend===`fallback`)return{kind:`declined`,reason:`no-native-writer`};let r;try{r=z(e,`utf-8`)}catch{return{kind:`declined`,reason:`unparseable`}}let i=r.charCodeAt(0)===65279,a=i?r.slice(1):r,o=re(a),s=a.trim()===``||a.endsWith(`
|
|
15
|
-
`),c;try{c=n.removeEntry(a,t)}catch{return{kind:`declined`,reason:`unparseable`}}if(!c.existed)return{kind:`not-present`};let l=c.text;s?l.endsWith(`
|
|
16
|
-
`)||(l=`${l}\n`):l=l.replace(/\n+$/,``),o&&(l=l.replace(/\r\n/g,`
|
|
17
|
-
`).replace(/\n/g,`\r
|
|
18
|
-
`));let u=`${i?``:``}${l}`;return u!==r&&_(e,u,{mode:j(e)}),{kind:`removed`}}function mn(e){return e==null?!1:e.includes(`--type=utility`)&&e.includes(`--utility-sub-type=node.mojom.NodeService`)}function hn(e,t=Date.now()){let n=new Date(e).getTime();if(Number.isNaN(n))return`—`;let r=t-n,i=Math.floor(r/1e3);if(i<60)return`${i}s`;let a=Math.floor(i/60);if(a<60)return`${a}m ago`;let o=Math.floor(a/60);return o<24?`${o}h ago`:`${Math.floor(o/24)}d ago`}function gn(e,t,n,r){if(t.status===`missing`||t.status===`corrupt`)return null;let i=t.lock,a=t.status===`alive`&&w(i)?{port:i.port,status:t.status,pid:i.pid,startedAt:i.startedAt,usage:r}:null;return{directory:i.worktreeRoot,server:{port:i.port,status:t.status,pid:i.pid,startedAt:i.startedAt,usage:r},ui:a,hostname:i.hostname,lockPath:t.lockPath,binary:n==null?null:p(n),command:n,isDesktop:mn(n)}}function Q(e){let t=e.server.status;return t===`alive`||t===`foreign-host`?e.isDesktop?`desktop`:t===`alive`?`running`:`foreign`:`stale`}const _n=new Set([`running`,`desktop`,`foreign`]);function vn(e){switch(e){case`running`:return G.default.green(e);case`desktop`:return G.default.blue(e);case`foreign`:return G.default.cyan(e);case`stale`:return G.default.yellow(e)}}function yn(e){return e==null?`—`:`${e.cpuPercent.toFixed(1)}% / ${e.memPercent.toFixed(1)}%`}function bn(e){return`${yn(e.server.usage)} | ${yn(e.ui?.usage??null)}`}function xn(e){return`${e.server.port===0?`(starting)`:String(e.server.port)} / ${e.ui==null?`—`:String(e.ui.port)}`}function Sn(e){if(e.length===0)return`No open-knowledge servers found.`;let t=[`DIRECTORY`,`PORTS (API/UI)`,`CPU/MEM (API | UI)`,`STATUS`,`PID`,`STARTED`,`BINARY`],n=e.map(e=>[e.directory,xn(e),bn(e),Q(e),String(e.server.pid),hn(e.server.startedAt),e.binary??`—`]),r=t.length,i=t.map(e=>e.length);for(let e of n)for(let t=0;t<r;t++)i[t]=Math.max(i[t]??0,(e[t]??``).length);let a=t.map((e,t)=>e.padEnd(i[t]??0)).join(` `).trimEnd(),o=e.map((e,t)=>{let a=n[t]??[],o=[];for(let t=0;t<r;t++){let n=(a[t]??``).padEnd(i[t]??0);if(t===3){let r=a[t]??``;n=vn(Q(e))+` `.repeat(Math.max(0,(i[t]??0)-r.length))}o.push(n)}return o.join(` `).trimEnd()}),s=G.default.dim(`To stop a server: ok stop <port|pid|directory|all>`);return[a,...o,``,s].join(`
|
|
19
|
-
`)}async function Cn(e={}){let t=e.discover??h,n=e.inspect??X,r=e.log??(e=>console.log(e)),i=e.resolveCommand??d,a=e.resolveUsage??m,o=await t(),s=[];for(let e of o){let t=n(e,`server`),r=gn(e,t,t.status===`missing`||t.status===`corrupt`?null:i(t.lock.pid),t.status===`missing`||t.status===`corrupt`?null:a(t.lock.pid));r!=null&&s.push(r)}if(e.json){let e=s.map(e=>({...e,displayStatus:Q(e)}));r(JSON.stringify(e,null,2));return}r(Sn(e.all?s:s.filter(e=>_n.has(Q(e)))))}function wn(){return new E(`ps`).description(`List all running open-knowledge servers`).argument(`[modifier]`,`"all" to include stale (dead-pid) entries`).option(`--all`,`Include stale (dead-pid) entries (foreign-host shows by default)`).option(`--json`,`Emit structured JSON (always includes all statuses)`).action(async(e,t)=>{await Cn({all:t.all===!0||e===`all`,json:t.json===!0})})}function Tn(e,t,n={}){let r=n.isAlive??x,i=[];for(let[n,a]of[[`server`,e],[`ui`,t]])(a.status===`alive`||a.status===`foreign-host`&&r(a.lock.pid))&&i.push({name:n,pid:a.lock.pid,port:a.lock.port});return{targets:i}}function En(e){let t=e.inspect??(t=>t===`ui`?Z(e.lockDir):X(e.lockDir,t)),n=e.kill??((e,t)=>process.kill(e,t)),r=e.log??(e=>console.log(e)),i=e.error??(e=>console.error(e)),a=Tn(t(`server`),t(`ui`),{isAlive:e.isAlive});if(a.targets.length===0)return r(`No running open-knowledge processes.`),{stopped:[],failed:[],hadTargets:!1};let o=[],s=[];for(let e of a.targets)try{n(e.pid,`SIGTERM`),o.push(e)}catch(t){s.push({target:e,error:t instanceof Error?t.message:String(t)})}return o.length>0&&r(`Stopped: ${o.map(e=>`${e.name} (pid=${e.pid}, port=${e.port})`).join(`, `)}`),s.length>0&&i(`Failed to stop: ${s.map(({target:e,error:t})=>`${e.name} (pid=${e.pid}): ${t}`).join(`; `)}`),{stopped:o,failed:s,hadTargets:!0}}function $(e,t){return e.status===`alive`?!0:e.status===`foreign-host`?t(e.lock.pid):!1}async function Dn(e,t=x){let n=await h(),r=null;for(let i of n){let n=X(i,`server`),a=Z(i);if($(n,t)&&n.lock.port===e||$(a,t)&&a.lock.port===e)return i;r===null&&($(n,t)&&n.lock.pid===e||$(a,t)&&a.lock.pid===e)&&(r=i)}return r}function On(e){let t=En({lockDir:e});return t.failed.length>0&&(process.exitCode=1),t}function kn(e){return new E(`stop`).description(`Stop open-knowledge server(s). With no argument: stops the server for the current directory. Pass a port number, a directory path, or "all" to target globally.`).argument(`[target...]`,`port number, directory path (spaces OK), or "all"`).action(async t=>{let n=t.length===0?void 0:t.join(` `);if(n===void 0){e();let t=En({lockDir:u(process.cwd()),log:()=>{}});if(t.hadTargets){if(t.stopped.length>0){let e=t.stopped.map(e=>`${e.name} (pid=${e.pid}, port=${e.port})`).join(`, `);console.log(`Stopped: ${e}`)}t.failed.length>0&&(process.exitCode=1)}else await Cn({});return}if(n===`all`){let e=await h();if(e.length===0){console.log(`No running open-knowledge servers found.`);return}let t=0;for(let n of e){let e=X(n,`server`),r=Z(n);!$(e,x)&&!$(r,x)||(On(n),t++)}t===0&&console.log(`No running open-knowledge servers found.`);return}if(/^\d+$/.test(n)){let e=Number.parseInt(n,10),t=await Dn(e);if(t===null){console.log(`No running open-knowledge server found with port or PID ${e}.`);return}On(t);return}On(u(I(Pe(),n)))})}export{U as _,tn as a,je as b,an as c,Z as d,X as f,Fe as g,Jt as h,un as i,on as l,qt as m,kn as n,sn as o,Zt as p,wn as r,nn as s,En as t,en as u,Pe as v,Ne as y};
|
|
20
|
-
//# sourceMappingURL=src-B8QX7oNJ.mjs.map
|
package/dist/src-BoSNO_uo.mjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import"./src-BD1wHyiU.mjs";import"./resolve-project-root-CHFE5Tp7.mjs";import"./src-B8QX7oNJ.mjs";import"./acp-harness-probe-BXaEG9XN.mjs";import"./init-DJQw_oSo.mjs";import{n as e}from"./loader-lM2dlAdG.mjs";import"./skill-teardown-DcAF7q_b.mjs";import"./preview-P4lIN2Xz.mjs";import"./mcp-migrate-event-9DFnNzHa.mjs";export{e as loadConfig};
|