@inkeep/open-knowledge 0.5.0-beta.24 → 0.5.0-beta.26
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/assets/skills/open-knowledge/SKILL.md +66 -16
- package/dist/cli.mjs +4 -4
- package/dist/constants-N3KA3gdq.mjs +2 -0
- package/dist/{dist-CibAeq--.mjs → dist-D1HyCuHh.mjs} +22 -18
- package/dist/{dist-C2u-rxF1.mjs → dist-DnmXfGWp.mjs} +1 -1
- package/dist/index.mjs +1 -1
- package/dist/{init-CWEExvCP.mjs → init-B8tzV3F-.mjs} +4 -4
- package/dist/init-BH5dCcI3.mjs +1 -0
- package/dist/loader-CNbNj3fg.mjs +1 -0
- package/dist/{loader-B8GTCsV6.mjs → loader-rYeE94aY.mjs} +2 -2
- package/dist/{preview-DDcsbT6L.mjs → preview-BgafVsFZ.mjs} +2 -2
- package/dist/preview-DYu8yg0V.mjs +1 -0
- package/dist/public/assets/ActivityModeContent-BJDdu4Nn.js +2 -0
- package/dist/public/assets/DocumentContext-DHsPuqhl.js +52 -0
- package/dist/public/assets/{GraphPanel-BGdpuLXE.js → GraphPanel-MJE4uTfy.js} +2 -2
- package/dist/public/assets/{SettingsDialog-rqnF7gS-.js → SettingsDialog-D_hqsuN-.js} +2 -2
- package/dist/public/assets/{SourceEditor-CZ1jZux8.js → SourceEditor-CjxbBvjc.js} +1 -1
- package/dist/public/assets/{config-validation-events-Cg1WEsqb.js → config-validation-events-CKTxHLXG.js} +3 -3
- package/dist/public/assets/{doc-hash-CGOOAxMs.js → doc-hash-8BtTwv21.js} +121 -120
- package/dist/public/assets/index-Ch6NS9p9.js +1853 -0
- package/dist/public/assets/index-D4NdqT_p.css +1 -0
- package/dist/public/assets/{target-navigation-intent-B4Stg_GZ.js → target-navigation-intent-Nd4Mwd33.js} +1 -1
- package/dist/public/assets/{telemetry-impl-C6x9yckj.js → telemetry-impl-IWNN1g1D.js} +1 -1
- package/dist/public/assets/{toggle-group-FOEgJa6h.js → toggle-group-4JFWFjGS.js} +1 -1
- package/dist/public/assets/{tooltip-1yQ0AYa7.js → tooltip-0G4OCxcX.js} +1 -1
- package/dist/public/assets/{typing-burst-detector-CPAaH_c3.js → typing-burst-detector-CAdcgWjh.js} +1 -1
- package/dist/public/index.html +9 -9
- package/dist/{repair-launch-json-CfW2OcfI.mjs → repair-launch-json-DCk5QB13.mjs} +2 -2
- package/dist/{repair-mcp-configs-C4h9Cere.mjs → repair-mcp-configs-Cf_D8oiF.mjs} +2 -2
- package/dist/{src-DhYhRB3U.mjs → src-B37eTbSY.mjs} +2 -2
- package/dist/start-BQue1F9V.mjs +1 -0
- package/dist/{start-qGNJkMnp.mjs → start-D6i_BQSW.mjs} +2 -2
- package/package.json +1 -1
- package/dist/constants-Deow6nk1.mjs +0 -2
- package/dist/init-BMRmWZ_f.mjs +0 -1
- package/dist/loader-NzmQDL0I.mjs +0 -1
- package/dist/preview-Bae0MG8_.mjs +0 -1
- package/dist/public/assets/ActivityModeContent-4zLTqVCC.js +0 -2
- package/dist/public/assets/DocumentContext-mhvvV02u.js +0 -52
- package/dist/public/assets/index-BMFglQhL.js +0 -1853
- package/dist/public/assets/index-slmhtD5o.css +0 -1
- package/dist/start-DL2EG5cj.mjs +0 -1
package/dist/public/index.html
CHANGED
|
@@ -48,7 +48,7 @@
|
|
|
48
48
|
-->
|
|
49
49
|
<script>(() => { let t = 'system'; try { const r = localStorage.getItem('ok-theme-v1'); if (r === 'light' || r === 'dark' || r === 'system') t = r; } catch {} let dark = t === 'dark'; if (t === 'system') { try { dark = window.matchMedia('(prefers-color-scheme: dark)').matches; } catch {} } if (dark) document.documentElement.classList.add('dark'); if (window.okDesktop) document.documentElement.classList.add('electron-mode'); })();</script>
|
|
50
50
|
<style>html { background-color: #fafafa } html.dark { background-color: #171717 }</style>
|
|
51
|
-
<script type="module" crossorigin src="./assets/index-
|
|
51
|
+
<script type="module" crossorigin src="./assets/index-Ch6NS9p9.js"></script>
|
|
52
52
|
<link rel="modulepreload" crossorigin href="./assets/chunk-CFjPhJqf.js">
|
|
53
53
|
<link rel="modulepreload" crossorigin href="./assets/preload-helper-2ej06EnG.js">
|
|
54
54
|
<link rel="modulepreload" crossorigin href="./assets/w3c-keyname-B5t0fahT.js">
|
|
@@ -62,24 +62,24 @@
|
|
|
62
62
|
<link rel="modulepreload" crossorigin href="./assets/compiler-runtime-CVnuRdak.js">
|
|
63
63
|
<link rel="modulepreload" crossorigin href="./assets/button-jHkzz0kg.js">
|
|
64
64
|
<link rel="modulepreload" crossorigin href="./assets/dist-CcCHwIMj.js">
|
|
65
|
-
<link rel="modulepreload" crossorigin href="./assets/doc-hash-
|
|
65
|
+
<link rel="modulepreload" crossorigin href="./assets/doc-hash-8BtTwv21.js">
|
|
66
66
|
<link rel="modulepreload" crossorigin href="./assets/propagation-api-3kmMXRwS.js">
|
|
67
67
|
<link rel="modulepreload" crossorigin href="./assets/dialog-aTGC_OHs.js">
|
|
68
68
|
<link rel="modulepreload" crossorigin href="./assets/dist-BpKSkQFf.js">
|
|
69
69
|
<link rel="modulepreload" crossorigin href="./assets/input-_NgekzP6.js">
|
|
70
|
-
<link rel="modulepreload" crossorigin href="./assets/DocumentContext-
|
|
70
|
+
<link rel="modulepreload" crossorigin href="./assets/DocumentContext-DHsPuqhl.js">
|
|
71
71
|
<link rel="modulepreload" crossorigin href="./assets/panel-DfWmoeYO.js">
|
|
72
|
-
<link rel="modulepreload" crossorigin href="./assets/typing-burst-detector-
|
|
72
|
+
<link rel="modulepreload" crossorigin href="./assets/typing-burst-detector-CAdcgWjh.js">
|
|
73
73
|
<link rel="modulepreload" crossorigin href="./assets/label-D3fsVWmW.js">
|
|
74
|
-
<link rel="modulepreload" crossorigin href="./assets/toggle-group-
|
|
74
|
+
<link rel="modulepreload" crossorigin href="./assets/toggle-group-4JFWFjGS.js">
|
|
75
75
|
<link rel="modulepreload" crossorigin href="./assets/textarea-BSSBCXzx.js">
|
|
76
|
-
<link rel="modulepreload" crossorigin href="./assets/config-validation-events-
|
|
76
|
+
<link rel="modulepreload" crossorigin href="./assets/config-validation-events-CKTxHLXG.js">
|
|
77
77
|
<link rel="modulepreload" crossorigin href="./assets/mcp-consent-store-Cf5AdDXf.js">
|
|
78
|
-
<link rel="modulepreload" crossorigin href="./assets/tooltip-
|
|
78
|
+
<link rel="modulepreload" crossorigin href="./assets/tooltip-0G4OCxcX.js">
|
|
79
79
|
<link rel="modulepreload" crossorigin href="./assets/agent-presence-C9zIlaSm.js">
|
|
80
|
-
<link rel="modulepreload" crossorigin href="./assets/target-navigation-intent-
|
|
80
|
+
<link rel="modulepreload" crossorigin href="./assets/target-navigation-intent-Nd4Mwd33.js">
|
|
81
81
|
<link rel="modulepreload" crossorigin href="./assets/project-paths-hiY0fNWB.js">
|
|
82
|
-
<link rel="stylesheet" crossorigin href="./assets/index-
|
|
82
|
+
<link rel="stylesheet" crossorigin href="./assets/index-D4NdqT_p.css">
|
|
83
83
|
</head>
|
|
84
84
|
|
|
85
85
|
<body class="antialiased">
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{l as e,n as t}from"./init-
|
|
2
|
-
//# sourceMappingURL=repair-launch-json-
|
|
1
|
+
import{l as e,n as t}from"./init-B8tzV3F-.mjs";import{t as n}from"./is-object-DF0ZeuvD.mjs";import{join as r}from"node:path";import{existsSync as i,readFileSync as a}from"node:fs";const o=[[`@inkeep/open-knowledge`,`ui`],[`-y`,`@inkeep/open-knowledge`,`ui`]];function s(e){if(e.runtimeExecutable!==`npx`||!Array.isArray(e.runtimeArgs))return`preserved`;if(c(e.runtimeArgs,t))return`canonical`;for(let t of o)if(c(e.runtimeArgs,t))return`legacy-bare`;return`preserved`}function c(e,t){if(e.length!==t.length)return!1;for(let n=0;n<t.length;n++)if(e[n]!==t[n])return!1;return!0}function l(t){let o=t.logger??u,c=r(t.projectDir,`.claude`,`launch.json`);if(!i(c))return{outcome:{configPath:c,outcome:`no-file`},repairedCount:0};let l;try{let e=a(c,`utf-8`).trim();l=e?JSON.parse(e):{}}catch(e){let t=e instanceof Error?e.message:String(e);return o({event:`launch-json-repair-read-failed`,configPath:c,error:t}),{outcome:{configPath:c,outcome:`read-failed`,error:t},repairedCount:0}}if(!n(l)){let e=`launch.json root is not an object`;return o({event:`launch-json-repair-read-failed`,configPath:c,error:e}),{outcome:{configPath:c,outcome:`read-failed`,error:e},repairedCount:0}}let d=l.configurations;if(!Array.isArray(d))return{outcome:{configPath:c,outcome:`no-entry`},repairedCount:0};let f=d.find(e=>n(e)&&e.name===`open-knowledge-ui`);if(!f)return{outcome:{configPath:c,outcome:`no-entry`},repairedCount:0};let p=s(f);if(p===`canonical`)return{outcome:{configPath:c,outcome:`canonical`},repairedCount:0};if(p===`preserved`)return{outcome:{configPath:c,outcome:`preserved`},repairedCount:0};let m=e(t.projectDir,{mode:`published`});if(m.action===`failed`){let e=m.error??`unknown write failure`;return o({event:`launch-json-repair-write-failed`,configPath:c,error:e}),{outcome:{configPath:c,outcome:`write-failed`,error:e},repairedCount:0}}return o({event:`launch-json-repair-applied`,configPath:c}),{outcome:{configPath:c,outcome:`repaired`},repairedCount:1}}function u(e){process.stderr.write(`${JSON.stringify(e)}\n`)}export{l as repairLaunchJson};
|
|
2
|
+
//# sourceMappingURL=repair-launch-json-DCk5QB13.mjs.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{g as e,h as t,o as n,p as r,u as i}from"./init-
|
|
2
|
-
//# sourceMappingURL=repair-mcp-configs-
|
|
1
|
+
import{g as e,h as t,o as n,p as r,u as i}from"./init-B8tzV3F-.mjs";import{homedir as a}from"node:os";const o=[[`@inkeep/open-knowledge`,`mcp`],[`-y`,`@inkeep/open-knowledge`,`mcp`]];function s(t){if(t.command!==`npx`||!Array.isArray(t.args))return`preserved`;if(c(t.args,e))return`canonical`;for(let e of o)if(c(t.args,e))return`legacy-bare`;return`preserved`}function c(e,t){if(e.length!==t.length)return!1;for(let n=0;n<t.length;n++)if(e[n]!==t[n])return!1;return!0}function l(e){let n=e.logger??f,i=e.home??a(),o=[];for(let a of r){let r=t[a],s=u(()=>r.configPath(``,i));if(s!==null&&o.push(d({scope:`user`,editorId:a,target:r,home:i,cwd:``,configPath:s,configPathOverride:void 0,logger:n})),r.projectConfigPath){let t=r.projectConfigPath,i=u(()=>t(e.projectDir));i!==null&&o.push(d({scope:`project`,editorId:a,target:r,home:void 0,cwd:e.projectDir,configPath:i,configPathOverride:i,logger:n}))}}return{outcomes:o,repairedCount:o.filter(e=>e.outcome===`repaired`).length}}function u(e){try{return e()}catch{return null}}function d(e){let t={scope:e.scope,editorId:e.editorId,configPath:e.configPath},r=n(e.target,e.cwd,e.home,e.configPathOverride);if(r===null)return{...t,outcome:`no-entry`};let a=s(r);if(a===`canonical`)return{...t,outcome:`canonical`};if(a===`preserved`)return{...t,outcome:`preserved`};let o=i(e.target,e.cwd,{mode:`published`,skipAvailabilityCheck:!0},e.home,e.configPathOverride);if(o.action===`failed`){let n=o.error??`unknown write failure`;return e.logger({event:`mcp-config-repair-write-failed`,scope:e.scope,editorId:e.editorId,configPath:e.configPath,error:n}),{...t,outcome:`write-failed`,error:n}}return e.logger({event:`mcp-config-repair-applied`,scope:e.scope,editorId:e.editorId,configPath:e.configPath}),{...t,outcome:`repaired`}}function f(e){process.stderr.write(`${JSON.stringify(e)}\n`)}export{l as repairMcpConfigs};
|
|
2
|
+
//# sourceMappingURL=repair-mcp-configs-Cf_D8oiF.mjs.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{h as e,l as t,u as n}from"./init-
|
|
2
|
-
//# sourceMappingURL=src-
|
|
1
|
+
import{h as e,l as t,u as n}from"./init-B8tzV3F-.mjs";import"./loader-rYeE94aY.mjs";import"./preview-BgafVsFZ.mjs";function r(r,i,a={}){let o=[];for(let t of i){let i=e[t],s=i.projectConfigPath?.(r);if(!s){o.push({editorId:t,outcome:`skipped-no-project-surface`});continue}let c;try{c=n(i,r,a,void 0,s)}catch(e){o.push({editorId:t,outcome:`failed`,error:e instanceof Error?e.message:String(e)});continue}if(c.action===`written`||c.action===`overwritten`){o.push({editorId:t,outcome:c.action});continue}if(c.action===`failed`){o.push({editorId:t,outcome:`failed`,error:c.error});continue}o.push({editorId:t,outcome:`failed`,error:`unexpected project-scope action: ${c.action}`})}return{editorOutcomes:o,claudeLaunchJson:i.includes(`claude`)?t(r,a):void 0}}export{r as t};
|
|
2
|
+
//# sourceMappingURL=src-B37eTbSY.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{l as e}from"./start-D6i_BQSW.mjs";export{e as startCommand};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import{n as e,t}from"./esm-CEs3LWY3.mjs";import{pn as n}from"./dist-
|
|
1
|
+
import{n as e,t}from"./esm-CEs3LWY3.mjs";import{pn as n}from"./dist-D1HyCuHh.mjs";import{n as r}from"./constants-N3KA3gdq.mjs";import{spawn as i}from"node:child_process";import{join as a}from"node:path";import{closeSync as o,existsSync as s,mkdirSync as c,openSync as l,statSync as u}from"node:fs";import{homedir as d}from"node:os";import{setTimeout as f}from"node:timers/promises";const p=`Open Knowledge.app`,m=`/Applications/${p}`;function h(){return{platform:process.platform,env:process.env,execPath:process.execPath,isTTY:process.stdout.isTTY,statSync:e=>{try{return u(e,{throwIfNoEntry:!1})??null}catch{return null}}}}function g(e){if(e.env.ELECTRON_RUN_AS_NODE===`1`){let t=/(.+?\.app)\/Contents\/MacOS\//.exec(e.execPath);if(t?.[1])return t[1]}if(_(e,m))return m;let t=a(e.homeDir??d(),`Applications`,p);return _(e,t)?t:null}function _(e,t){try{let n=a(t,`Contents`,`MacOS`,`Open Knowledge`),r=e.statSync(n);return r&&typeof r.isFile==`function`?r.isFile():!1}catch{return!1}}function v(e){if(e.env.OK_FORCE_BROWSER===`1`)return{available:!1,reason:`force-browser`};if(e.platform!==`darwin`)return{available:!1,reason:`darwin-only`};let t;try{t=g(e)}catch{return{available:!1,reason:`stat-error`}}return t?e.env.OK_FORCE_DESKTOP===`1`?{available:!0,reason:`available`,bundlePath:t}:e.isTTY!==!0||e.env.SSH_CONNECTION||e.env.SSH_TTY?{available:!1,reason:`headless`,bundlePath:t}:{available:!0,reason:`available`,bundlePath:t}:{available:!1,reason:`no-bundle`}}function y(e){(e.log??(e=>console.error(e)))("Launching Open Knowledge desktop (use `ok start` for the browser server, or `OK_FORCE_BROWSER=1` to always skip)"),e.spawn(`open`,[`-b`,`com.inkeep.open-knowledge`],{detached:!0,stdio:`ignore`}).unref()}function b(e=`no-bundle`){switch(e){case`no-bundle`:return`Desktop app not found at ${m}. Install via DMG, or omit --mode for browser mode.`;case`darwin-only`:return`Desktop app is macOS-only on this release. Use --mode=browser, or omit --mode for the server fallback.`;case`headless`:return`Desktop launch is gated in headless contexts (CI, SSH, non-TTY stdout). Set OK_FORCE_DESKTOP=1 to override, or use --mode=browser.`;case`force-browser`:return`OK_FORCE_BROWSER=1 is set — desktop dispatch is disabled. Unset it to use --mode=app.`;case`stat-error`:return`Failed to inspect desktop bundle at ${m} (filesystem error). Check permissions or use --mode=browser.`;case`available`:return`Desktop app appears available at ${m} but launch dispatch did not fire (caller bug).`}}function x(){let e=process.execPath,t=process.argv[1];return t?{command:e,prefixArgs:[t]}:(console.warn(`[self-spawn] process.argv[1] is empty — falling back to \`npx -y @inkeep/open-knowledge@latest\`. This re-introduces the registry-fetch surface that re-exec was fixing. Observed argv: ${JSON.stringify(process.argv)}`),{command:`npx`,prefixArgs:[`-y`,`@inkeep/open-knowledge@latest`]})}function S(e,t){return e.host??t.HOST??`localhost`}var C=class extends Error{cwd;constructor(e){super("This directory isn't set up yet. Run `ok init` first, then `ok start` again."),this.name=`OkDirMissingError`,this.cwd=e}};function w(e){return e.uiLock?e.isAlive(e.uiLock.pid)?{action:`skip`,reason:`alive`,pid:e.uiLock.pid,port:e.uiLock.port}:{action:`spawn`,reason:`stale`,stalePid:e.uiLock.pid}:{action:`spawn`,reason:`absent`}}function T(e){s(e.lockDir)||c(e.lockDir,{recursive:!0});let t=l(a(e.lockDir,`last-spawn-error.log`),`w`),n=e.spawn??i,{PORT:r,...u}=process.env,d=x();try{let r=n(d.command,[...d.prefixArgs,...e.args??[`ui`]],{detached:!0,stdio:[`ignore`,`ignore`,t],cwd:e.cwd,env:u});return r.unref(),r}finally{try{o(t)}catch{}}}async function E(e){let t=e.now()+e.timeoutMs;for(;e.now()<t;){let t=e.readUiLock();if(t&&t.port>0)return t.port;await e.sleep(e.pollIntervalMs)}let n=e.readUiLock();return n&&n.port>0?n.port:null}function D(e){let t=e.sigtermGraceMs??1e4,n=e.sigtermPollIntervalMs??200,r=e.sleep??(e=>f(e));return async()=>{try{let i=e.readUiLock();if(i&&e.isAlive(i.pid))try{e.killPid(i.pid,`SIGTERM`),e.log?.info({pid:i.pid,port:i.port},`idle-shutdown: SIGTERM UI sibling`);let a=Date.now()+t;for(;Date.now()<a&&e.isAlive(i.pid);)await r(n);if(e.isAlive(i.pid))try{e.killPid(i.pid,`SIGKILL`),e.log?.warn({pid:i.pid,graceMs:t},`idle-shutdown: SIGTERM grace expired — escalated to SIGKILL`)}catch(t){e.log?.error({pid:i.pid,err:t instanceof Error?t.message:String(t)},`idle-shutdown: SIGKILL failed`)}}catch(t){e.log?.warn({pid:i.pid,err:t instanceof Error?t.message:String(t)},`idle-shutdown: failed to SIGTERM UI sibling`)}}catch(t){e.log?.warn({err:t instanceof Error?t.message:String(t)},`idle-shutdown: UI lookup failed; proceeding with destroy`)}await e.destroy()}}async function O(e){let{config:t,cwd:r,host:i}=e,a=e.skipAutoInit??!1,o=e.skipUiAutoSpawn??!1,s=e.idleThresholdMs??18e5,{existsSync:c,mkdirSync:l}=await import(`node:fs`),{bootServer:u,getLogger:d,isProcessAlive:p,readUiLock:m,resolveContentDir:h}=await import(`./dist-DnmXfGWp.mjs`),g=e.log??d(`start`);if(!a&&!n(r))throw new C(r);try{(e.repairMcpConfigsFn??(await import(`./repair-mcp-configs-Cf_D8oiF.mjs`)).repairMcpConfigs)({projectDir:r})}catch(e){g.warn({err:e},`[start] mcp-config repair sweep failed; continuing`)}try{(e.repairLaunchJsonFn??(await import(`./repair-launch-json-DCk5QB13.mjs`)).repairLaunchJson)({projectDir:r})}catch(e){g.warn({err:e},`[start] launch.json repair sweep failed; continuing`)}let _=h(t,r);c(_)||(l(_,{recursive:!0}),g.info({contentDir:_},`Created content directory`));let v=null,y=await u({config:t,contentDir:_,projectDir:r,contentRoot:t.content.dir,port:e.port,host:i,quiet:!1,localOpCliArgs:[process.execPath,process.argv[1]],attachUiSibling:!0,idleShutdownMs:s,skipAutoInit:!0,spawnUiSiblingFn:async({lockDir:t})=>{if(v=w({uiLock:m(t),isAlive:p}),v.action===`spawn`&&!o)try{T({lockDir:t,cwd:r,spawn:e.spawn}),g.info({reason:v.reason},`[start] auto-spawned ok ui sibling`)}catch(e){console.warn(`[start] failed to auto-spawn ok ui: ${e instanceof Error?e.message:String(e)}`)}else v.action===`skip`&&g.info({port:v.port,pid:v.pid},`UI already running at port ${v.port}`)},idleShutdownHandler:e=>D({readUiLock:()=>m(y.lockDir),isAlive:p,killPid:(e,t)=>{process.kill(e,t)},destroy:e,log:g}),log:g});v||={action:`skip`,reason:`alive`,pid:0,port:0};let b=v,x=null;if(b.action===`skip`)x=b.port>0?b.port:null;else if(!o){let t=e.uiBindTimeoutMs??3e3;x=await E({readUiLock:()=>m(y.lockDir),now:Date.now,sleep:e=>f(e),timeoutMs:t,pollIntervalMs:50}),x===null&&g.warn({timeoutMs:t},`[start] ok ui did not bind within timeout — banner falls back to API URL`)}return{httpServer:y.httpServer,destroy:y.destroy,lockDir:y.lockDir,contentDir:_,port:y.port,ready:y.ready,degraded:y.degraded,uiSpawnDecision:v,resolvedUiPort:x}}function k(t){if(t===`browser`||t===`app`)return t;throw new e(`--mode must be 'browser' or 'app'`)}async function A(e,t){let{renderBanner:n}=await import(`./banner-KC_FjiUK.mjs`),{dim:i,error:a,warning:o}=await import(`./colors-T3xmlXQT.mjs`),s=process.cwd(),c=e,l=S(t,process.env),u=t.port===void 0?void 0:Number(t.port),d=process.env.PORT?Number(process.env.PORT):void 0,f=u??d,p;try{p=await O({config:c,cwd:s,host:l,port:f})}catch(e){e instanceof C&&(console.error(a(e.message)),process.exit(1));let t=j(e,s,await import(`./dist-DnmXfGWp.mjs`));t!==null&&(console.error(a(t)),process.exit(1)),console.error(`${a(`Failed to start:`)} ${e instanceof Error?e.stack??e.message:String(e)}`),process.exit(1)}let m=!1,h=async e=>{if(!m){m=!0,console.log(i(`\nShutting down (${e})`));try{await p.destroy()}catch(e){console.error(`${a(`destroy() failed:`)} ${e instanceof Error?e.stack??e.message:String(e)}`),process.exitCode=1}process.exit(process.exitCode??0)}};process.once(`SIGINT`,()=>{h(`SIGINT`)}),process.once(`SIGTERM`,()=>{h(`SIGTERM`)});let g=`http://${l}:${p.port}`,_=l===`0.0.0.0`||l===`::`?`http://0.0.0.0:${p.port}`:void 0,v=p.resolvedUiPort,y=v!==null&&v>0?`http://${l}:${v}`:g;console.log(n({name:`open-knowledge`,version:r,localUrl:y,apiUrl:y===g?void 0:g,networkUrl:_}));let b={"shadow-repo":`Version history and branch-switch safety unavailable`,"file-watcher":`External file changes will not sync to the editor`,"head-watcher":`Git branch switches may cause document inconsistency`};p.ready.then(async()=>{if(p.degraded.length>0){console.log();for(let e of p.degraded){let t=b[e]??`${e} (check server logs for details)`;console.warn(` ${o(`⚠`)} ${o(e)}: ${i(t)}`)}console.log()}if(t.open){let{openBrowser:e}=await import(`./open-browser-Be-7qaQ9.mjs`);e(y)}}).catch(e=>{console.error(` ${a(`Server initialization failed:`)} ${e instanceof Error?e.message:String(e)}`)})}function j(e,t,n){let r=n.ServerLockCollisionError;if(r===void 0||!(e instanceof r))return null;try{let e=a(t,`.ok`),r=n.readServerLock(e);return r?r.kind===`interactive`?`Open Knowledge desktop is currently running on this project. Quit it or use --cwd to point elsewhere.`:r.kind===`mcp-spawned`?"An MCP-spawned server holds this lock; it should release on idle-shutdown (~30 min). Or run `ok stop`.":"Open Knowledge server is already running on this project — check `ok status` or `ok stop`.":"Open Knowledge server is already running on this project — check `ok status` or `ok stop`."}catch{return null}}function M(e){return new t(`start`).description(`Start the knowledge base collab server`).option(`-p, --port <port>`,`Server port`,void 0).option(`-H, --host <host>`,`Server host`,void 0).option(`--open`,`Open browser after start`).option(`--mode <mode>`,`Force dispatch mode: 'browser' or 'app'`,k).action(async t=>{let n=e();if(t.mode===`app`){t.open&&(process.stderr.write(`error: option '--mode=app' cannot be combined with '--open' (--open opens a browser tab against the local server, which app mode does not boot)
|
|
2
2
|
`),process.exit(2));let e=[];if(t.port!==void 0&&e.push(`--port`),t.host!==void 0&&e.push(`--host`),e.length>0){let t=process.env.OK_LOG_LEVEL??`info`;(t===`debug`||t===`trace`)&&console.error(`--mode=app: ignoring ${e.join(`, `)}`)}let n=v(h());if(n.available){y({spawn:i});return}console.error(b(n.reason)),process.exit(1)}await A(n,t)})}export{w as a,T as c,x as d,h as f,D as i,M as l,y as m,E as n,S as o,v as p,O as r,A as s,C as t,j as u};
|
|
3
|
-
//# sourceMappingURL=start-
|
|
3
|
+
//# sourceMappingURL=start-D6i_BQSW.mjs.map
|
package/package.json
CHANGED
package/dist/init-BMRmWZ_f.mjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{c as e}from"./init-CWEExvCP.mjs";export{e as runInit};
|
package/dist/loader-NzmQDL0I.mjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{n as e}from"./loader-B8GTCsV6.mjs";export{e as loadConfig};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{n as e,t}from"./preview-DDcsbT6L.mjs";export{t as formatPreviewBlock,e as previewContent};
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./ActivityPanelDiffView-EaCFURAu.js","./chunk-CFjPhJqf.js","./compiler-runtime-CVnuRdak.js","./ActivityPanelDiffView-legcy4jI.css"])))=>i.map(i=>d[i]);
|
|
2
|
-
import{o as e}from"./chunk-CFjPhJqf.js";import{t}from"./preload-helper-2ej06EnG.js";import{n,r,t as i}from"./compiler-runtime-CVnuRdak.js";import{Mn as a,Nn as o,Z as s,hn as c,jn as l,n as u,r as d}from"./DocumentContext-mhvvV02u.js";import{J as f,Pt as p,h as m,q as h}from"./doc-hash-CGOOAxMs.js";import{C as g,t as _}from"./button-jHkzz0kg.js";import{f as v,i as y,m as b,r as x,t as S}from"./agent-presence-C9zIlaSm.js";import{a as C,c as w,i as T,o as E,s as D,t as O,x as k}from"./dialog-aTGC_OHs.js";import{i as A,n as ee,t as te}from"./tooltip-1yQ0AYa7.js";var ne=g(`rewind`,[[`path`,{d:`M12 6a2 2 0 0 0-3.414-1.414l-6 6a2 2 0 0 0 0 2.828l6 6A2 2 0 0 0 12 18z`,key:`2a1g8i`}],[`path`,{d:`M22 6a2 2 0 0 0-3.414-1.414l-6 6a2 2 0 0 0 0 2.828l6 6A2 2 0 0 0 22 18z`,key:`rg3s36`}]]),j=i(),M=e(n(),1),re=500,ie=64;async function ae(e){let t=`/api/agent-activity?agentId=${encodeURIComponent(e)}`,n=await fetch(t),r;try{r=await n.json()}catch(e){throw new s(`Could not parse /api/agent-activity response.`,{cause:e,status:n.status})}if(!n.ok){let e=p.safeParse(r);throw e.success?Error(e.data.title):new s(`/api/agent-activity returned a non-RFC-9457 error response.`,{cause:e.error,status:n.status})}let i=h.safeParse(r);if(!i.success)throw new s(`/api/agent-activity returned a body that did not match AgentActivitySuccessSchema.`,{cause:i.error,status:n.status});return i.data}async function oe(e,t,n){let r=`/api/agent-burst-diff?agentId=${encodeURIComponent(e)}&docName=${encodeURIComponent(t)}&stackIndex=${n}`,i=await fetch(r),a;try{a=await i.json()}catch(e){throw new s(`Could not parse /api/agent-burst-diff response.`,{cause:e,status:i.status})}if(!i.ok){let e=p.safeParse(a);throw e.success?Error(e.data.title):new s(`/api/agent-burst-diff returned a non-RFC-9457 error response.`,{cause:e.error,status:i.status})}let o=f.safeParse(a);if(!o.success)throw new s(`/api/agent-burst-diff returned a body that did not match AgentBurstDiffSuccessSchema.`,{cause:o.error,status:i.status});return o.data.diff}function se(e){let t=(0,j.c)(23),{systemProvider:n}=u(),[r,i]=(0,M.useState)(null),[a,o]=(0,M.useState)(`idle`),[s,c]=(0,M.useState)(null),l;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(l=new y(ie),t[0]=l):l=t[0];let d=(0,M.useRef)(l),f=(0,M.useRef)(0),p;t[1]===n?p=t[2]:(p=e=>{let t=f.current+=1;o(`loading`),c(null),ae(e).then(r=>{if(f.current!==t)return;let a=le(n,e);i({...r,writingDocs:a}),o(`ready`)}).catch(e=>{f.current===t&&(c(e instanceof Error?e.message:String(e)),o(`error`))})},t[1]=n,t[2]=p);let h=p,g;t[3]!==e||t[4]!==h?(g=()=>{if(!e){f.current+=1,i(null),o(`idle`),c(null),d.current.clear();return}d.current.clear(),h(e);let t=null,n=m(n=>{n.includes(`session-activity`)&&(t&&clearTimeout(t),t=setTimeout(()=>{t=null,h(e)},re))});return()=>{t&&clearTimeout(t),n()}},t[3]=e,t[4]=h,t[5]=g):g=t[5];let _;t[6]===e?_=t[7]:(_=[e],t[6]=e,t[7]=_),(0,M.useEffect)(g,_);let v,b;t[8]!==e||t[9]!==n?(v=()=>{if(!e||!n)return;let t=()=>{if(!n.awareness)return;let t=le(n,e);i(e=>!e||ce(e.writingDocs,t)?e:{...e,writingDocs:t})},r=n.awareness;if(!r||typeof r.on!=`function`){t();return}r.on(`update`,t),t();let a=setInterval(t,1e3);return()=>{clearInterval(a),typeof r.off==`function`&&r.off(`update`,t)}},b=[e,n],t[8]=e,t[9]=n,t[10]=v,t[11]=b):(v=t[10],b=t[11]),(0,M.useEffect)(v,b);let x;t[12]===e?x=t[13]:(x=async(t,n)=>{if(!e)return``;let r=`${t}\0${n}`,i=d.current.get(r);if(i!==void 0)return i;let a=await oe(e,t,n);return d.current.set(r,a),a},t[12]=e,t[13]=x);let S=x,C;t[14]!==e||t[15]!==h?(C=()=>{e&&h(e)},t[14]=e,t[15]=h,t[16]=C):C=t[16];let w=C,T;return t[17]!==r||t[18]!==s||t[19]!==S||t[20]!==w||t[21]!==a?(T={data:r,status:a,error:s,reload:w,fetchBurstDiff:S},t[17]=r,t[18]=s,t[19]=S,t[20]=w,t[21]=a,t[22]=T):T=t[22],T}function ce(e,t){if(e.size!==t.size)return!1;for(let n of e)if(!t.has(n))return!1;return!0}function le(e,t){let n=new Set;if(!e)return n;let r=e.awareness;if(!S(r))return n;let i=[t,t.startsWith(`agent-`)?t.slice(6):`agent-${t}`];for(let e of r.getStates().values()){let t=e.agentPresence;if(t)for(let e of i){let r=t[e];r&&r.mode===`writing`&&r.currentDoc&&n.add(r.currentDoc)}}return n}var N=r(),ue=(0,M.lazy)(async()=>({default:(await t(()=>import(`./ActivityPanelDiffView-EaCFURAu.js`),__vite__mapDeps([0,1,2,3]),import.meta.url)).ActivityPanelDiffView}));function de(e,t){let n=Math.max(0,t-e);return n<6e4?`${Math.round(n/1e3)}s ago`:n<36e5?`${Math.round(n/6e4)}m ago`:new Date(e).toLocaleTimeString(void 0,{hour:`2-digit`,minute:`2-digit`,second:`2-digit`})}function fe(e){let t=(0,j.c)(38),{burst:n,docName:r,fetchBurstDiff:i}=e,[s,c]=(0,M.useState)(!1),[l,u]=(0,M.useState)(null),[d,f]=(0,M.useState)(null),[p,m]=(0,M.useState)(!1),[h,g]=(0,M.useState)(P),_,v;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(_=()=>{let e=setInterval(()=>g(Date.now()),3e4);return()=>clearInterval(e)},v=[],t[0]=_,t[1]=v):(_=t[0],v=t[1]),(0,M.useEffect)(_,v);let y;t[2]!==n.stackIndex||t[3]!==l||t[4]!==r||t[5]!==s||t[6]!==i||t[7]!==p?(y=()=>{let e=!s;c(e),e&&l===null&&!p&&(m(!0),f(null),i(r,n.stackIndex).then(e=>{u(e),m(!1)}).catch(e=>{f(e instanceof Error?e.message:String(e)),m(!1)}))},t[2]=n.stackIndex,t[3]=l,t[4]=r,t[5]=s,t[6]=i,t[7]=p,t[8]=y):y=t[8];let b=y,x=`${s?`Collapse`:`Expand`} burst ${n.stackIndex+1} diff`,S;t[9]===s?S=t[10]:(S=s?(0,N.jsx)(o,{className:`size-3 shrink-0`,"aria-hidden":`true`}):(0,N.jsx)(a,{className:`size-3 shrink-0`,"aria-hidden":`true`}),t[9]=s,t[10]=S);let C;t[11]!==n.ts||t[12]!==h?(C=de(n.ts,h),t[11]=n.ts,t[12]=h,t[13]=C):C=t[13];let w;t[14]===C?w=t[15]:(w=(0,N.jsx)(`span`,{className:`font-mono`,children:C}),t[14]=C,t[15]=w);let T;t[16]===n.additions?T=t[17]:(T=(0,N.jsxs)(`span`,{className:`text-green-600 dark:text-green-400`,children:[`+`,n.additions]}),t[16]=n.additions,t[17]=T);let E;t[18]===n.deletions?E=t[19]:(E=(0,N.jsxs)(`span`,{className:`text-red-600 dark:text-red-400`,children:[`−`,n.deletions]}),t[18]=n.deletions,t[19]=E);let D;t[20]!==T||t[21]!==E?(D=(0,N.jsxs)(`span`,{className:`ml-auto font-mono`,children:[T,` `,E]}),t[20]=T,t[21]=E,t[22]=D):D=t[22];let O;t[23]!==s||t[24]!==D||t[25]!==x||t[26]!==S||t[27]!==w||t[28]!==b?(O=(0,N.jsxs)(`button`,{type:`button`,onClick:b,className:`flex w-full items-center gap-2 px-4 py-1.5 text-xs text-muted-foreground hover:bg-muted/40`,"aria-expanded":s,"aria-label":x,children:[S,w,D]}),t[23]=s,t[24]=D,t[25]=x,t[26]=S,t[27]=w,t[28]=b,t[29]=O):O=t[29];let k;t[30]!==l||t[31]!==s||t[32]!==d||t[33]!==p?(k=s?(0,N.jsx)(`div`,{className:`bg-muted/20`,children:p?(0,N.jsx)(`div`,{className:`px-4 py-2 text-xs text-muted-foreground italic`,children:`Loading diff`}):d?(0,N.jsxs)(`div`,{className:`px-4 py-2 text-xs text-destructive`,children:[`Failed: `,d]}):l===null?(0,N.jsx)(`div`,{className:`px-4 py-2 text-xs text-muted-foreground italic`,children:`No diff.`}):(0,N.jsx)(M.Suspense,{fallback:(0,N.jsx)(`div`,{className:`px-4 py-2 text-xs text-muted-foreground italic`,children:`Loading diff`}),children:(0,N.jsx)(ue,{diff:l})})}):null,t[30]=l,t[31]=s,t[32]=d,t[33]=p,t[34]=k):k=t[34];let A;return t[35]!==O||t[36]!==k?(A=(0,N.jsxs)(`div`,{className:`border-t border-border/50`,children:[O,k]}),t[35]=O,t[36]=k,t[37]=A):A=t[37],A}function P(){return Date.now()}function pe(e,t){let n=Math.max(0,t-e);return n<6e4?`${Math.round(n/1e3)}s ago`:n<36e5?`${Math.round(n/6e4)}m ago`:`${Math.round(n/36e5)}h ago`}function F(e){let t=(0,j.c)(93),{file:n,sessionAlive:r,isWriting:i,onNavigate:s,onUndoLast:c,onUndoAll:l,fetchBurstDiff:u}=e,[d,f]=(0,M.useState)(!1),[p,m]=(0,M.useState)(!1),[h,g]=(0,M.useState)(!1),[y,b]=(0,M.useState)(he),x,S;if(t[0]===Symbol.for(`react.memo_cache_sentinel`)?(x=()=>{let e=setInterval(()=>b(Date.now()),3e4);return()=>clearInterval(e)},S=[],t[0]=x,t[1]=S):(x=t[0],S=t[1]),(0,M.useEffect)(x,S),n.bursts.length===0)return null;let k=!r||n.bursts.length===0||h,re=r?n.bursts.length===0?`Nothing to undo on this file`:null:`Session ended — undo unavailable`,ie;t[2]!==k||t[3]!==n.docName||t[4]!==c?(ie=e=>{e.stopPropagation(),!k&&(g(!0),Promise.resolve(c(n.docName)).finally(()=>g(!1)))},t[2]=k,t[3]=n.docName,t[4]=c,t[5]=ie):ie=t[5];let ae=ie,oe;t[6]===k?oe=t[7]:(oe=e=>{e.stopPropagation(),!k&&m(!0)},t[6]=k,t[7]=oe);let se=oe,ce;t[8]!==k||t[9]!==n.docName||t[10]!==l?(ce=()=>{m(!1),!k&&(g(!0),Promise.resolve(l(n.docName)).finally(()=>g(!1)))},t[8]=k,t[9]=n.docName,t[10]=l,t[11]=ce):ce=t[11];let le=ce,ue;t[12]===Symbol.for(`react.memo_cache_sentinel`)?(ue=()=>f(me),t[12]=ue):ue=t[12];let de=d?`Collapse ${n.docName}`:`Expand ${n.docName}`,P;t[13]===d?P=t[14]:(P=d?(0,N.jsx)(o,{className:`size-4`,"aria-hidden":`true`}):(0,N.jsx)(a,{className:`size-4`,"aria-hidden":`true`}),t[13]=d,t[14]=P);let F;t[15]!==d||t[16]!==de||t[17]!==P?(F=(0,N.jsx)(`button`,{type:`button`,onClick:ue,className:`flex size-5 shrink-0 items-center justify-center rounded hover:bg-muted`,"aria-expanded":d,"aria-label":de,"data-testid":`activity-panel-file-row-carrot`,children:P}),t[15]=d,t[16]=de,t[17]=P,t[18]=F):F=t[18];let I;t[19]!==n.docName||t[20]!==s?(I=()=>s(n.docName),t[19]=n.docName,t[20]=s,t[21]=I):I=t[21];let ge=`Navigate to ${n.docName}`,L;t[22]!==n.docName||t[23]!==I||t[24]!==ge?(L=(0,N.jsx)(`button`,{type:`button`,onClick:I,className:`min-w-0 flex-1 truncate text-left text-foreground hover:underline focus-visible:outline-ring`,"aria-label":ge,"data-testid":`activity-panel-file-row-filename`,title:n.docName,children:n.docName}),t[22]=n.docName,t[23]=I,t[24]=ge,t[25]=L):L=t[25];let _e=`Undo last edit on ${n.docName}`,ve;t[26]===Symbol.for(`react.memo_cache_sentinel`)?(ve=(0,N.jsx)(v,{className:`size-3.5`,"aria-hidden":`true`}),t[26]=ve):ve=t[26];let R;t[27]!==k||t[28]!==ae||t[29]!==_e?(R=(0,N.jsx)(A,{asChild:!0,children:(0,N.jsx)(_,{type:`button`,variant:`ghost`,size:`icon`,className:`size-6 shrink-0`,onClick:ae,disabled:k,"aria-label":_e,"data-testid":`activity-panel-undo-last`,children:ve})}),t[27]=k,t[28]=ae,t[29]=_e,t[30]=R):R=t[30];let ye=re??`Undo last edit`,z;t[31]===ye?z=t[32]:(z=(0,N.jsx)(ee,{side:`bottom`,children:ye}),t[31]=ye,t[32]=z);let B;t[33]!==R||t[34]!==z?(B=(0,N.jsxs)(te,{children:[R,z]}),t[33]=R,t[34]=z,t[35]=B):B=t[35];let be=`Undo all edits on ${n.docName}`,xe;t[36]===Symbol.for(`react.memo_cache_sentinel`)?(xe=(0,N.jsx)(ne,{className:`size-3.5`,"aria-hidden":`true`}),t[36]=xe):xe=t[36];let V;t[37]!==k||t[38]!==se||t[39]!==be?(V=(0,N.jsx)(A,{asChild:!0,children:(0,N.jsx)(_,{type:`button`,variant:`ghost`,size:`icon`,className:`size-6 shrink-0`,onClick:se,disabled:k,"aria-label":be,"data-testid":`activity-panel-undo-all`,children:xe})}),t[37]=k,t[38]=se,t[39]=be,t[40]=V):V=t[40];let Se=re??`Undo all edits`,H;t[41]===Se?H=t[42]:(H=(0,N.jsx)(ee,{side:`bottom`,children:Se}),t[41]=Se,t[42]=H);let U;t[43]!==V||t[44]!==H?(U=(0,N.jsxs)(te,{children:[V,H]}),t[43]=V,t[44]=H,t[45]=U):U=t[45];let W;t[46]===n.additionsTotal?W=t[47]:(W=(0,N.jsxs)(`span`,{className:`text-green-600 dark:text-green-400`,children:[`+`,n.additionsTotal]}),t[46]=n.additionsTotal,t[47]=W);let G;t[48]===n.deletionsTotal?G=t[49]:(G=(0,N.jsxs)(`span`,{className:`text-red-600 dark:text-red-400`,children:[`−`,n.deletionsTotal]}),t[48]=n.deletionsTotal,t[49]=G);let K;t[50]!==W||t[51]!==G?(K=(0,N.jsxs)(`span`,{className:`shrink-0 font-mono text-xs`,children:[W,` `,G]}),t[50]=W,t[51]=G,t[52]=K):K=t[52];let q;t[53]!==n.lastTs||t[54]!==y?(q=pe(n.lastTs,y),t[53]=n.lastTs,t[54]=y,t[55]=q):q=t[55];let J;t[56]===q?J=t[57]:(J=(0,N.jsx)(`span`,{className:`shrink-0 font-mono text-[11px] text-muted-foreground`,children:q}),t[56]=q,t[57]=J);let Y;t[58]===i?Y=t[59]:(Y=i?(0,N.jsx)(`span`,{className:`shrink-0 text-[11px] text-primary animate-pulse`,role:`status`,children:`writing`}):null,t[58]=i,t[59]=Y);let X;t[60]!==L||t[61]!==B||t[62]!==U||t[63]!==K||t[64]!==J||t[65]!==Y||t[66]!==F?(X=(0,N.jsxs)(`div`,{className:`flex items-center gap-2 px-3 py-2 text-sm`,children:[F,L,B,U,K,J,Y]}),t[60]=L,t[61]=B,t[62]=U,t[63]=K,t[64]=J,t[65]=Y,t[66]=F,t[67]=X):X=t[67];let Z;t[68]!==d||t[69]!==u||t[70]!==n.bursts||t[71]!==n.docName?(Z=d?(0,N.jsx)(`div`,{children:n.bursts.map(e=>(0,N.jsx)(fe,{burst:e,docName:n.docName,fetchBurstDiff:u},`${n.docName}:${e.stackIndex}`))}):null,t[68]=d,t[69]=u,t[70]=n.bursts,t[71]=n.docName,t[72]=Z):Z=t[72];let Ce;t[73]===Symbol.for(`react.memo_cache_sentinel`)?(Ce=(0,N.jsx)(w,{children:`Undo all edits on this file?`}),t[73]=Ce):Ce=t[73];let Q;t[74]===n.docName?Q=t[75]:(Q=(0,N.jsx)(`span`,{className:`font-mono text-foreground`,children:n.docName}),t[74]=n.docName,t[75]=Q);let we=n.bursts.length===1?``:`s`,Te;t[76]!==n.bursts.length||t[77]!==Q||t[78]!==we?(Te=(0,N.jsxs)(D,{children:[Ce,(0,N.jsxs)(C,{children:[`This will revert every change this agent has made to`,` `,Q,` in their current session (`,n.bursts.length,` burst`,we,`). Other files and other writers are not affected.`]})]}),t[76]=n.bursts.length,t[77]=Q,t[78]=we,t[79]=Te):Te=t[79];let Ee;t[80]===Symbol.for(`react.memo_cache_sentinel`)?(Ee=(0,N.jsx)(_,{type:`button`,variant:`outline`,onClick:()=>m(!1),"data-testid":`activity-panel-undo-all-cancel`,children:`Cancel`}),t[80]=Ee):Ee=t[80];let De;t[81]===le?De=t[82]:(De=(0,N.jsxs)(E,{children:[Ee,(0,N.jsx)(_,{type:`button`,variant:`destructive`,onClick:le,"data-testid":`activity-panel-undo-all-confirm`,children:`Undo all`})]}),t[81]=le,t[82]=De);let Oe;t[83]!==Te||t[84]!==De?(Oe=(0,N.jsxs)(T,{className:`sm:max-w-md`,children:[Te,De]}),t[83]=Te,t[84]=De,t[85]=Oe):Oe=t[85];let $;t[86]!==p||t[87]!==Oe?($=(0,N.jsx)(O,{open:p,onOpenChange:m,children:Oe}),t[86]=p,t[87]=Oe,t[88]=$):$=t[88];let ke;return t[89]!==X||t[90]!==Z||t[91]!==$?(ke=(0,N.jsxs)(`div`,{className:`border-b border-border`,"data-testid":`activity-panel-file-row`,children:[X,Z,$]}),t[89]=X,t[90]=Z,t[91]=$,t[92]=ke):ke=t[92],ke}function me(e){return!e}function he(){return Date.now()}async function I(e){let t=await fetch(`/api/agent-undo`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({...e,agentId:e.connectionId})});if(!t.ok)throw Error(`agent-undo failed: HTTP ${t.status}`)}function ge(e){return`#/${e.split(`/`).map(e=>encodeURIComponent(e)).join(`/`)}`}function L(e){typeof window>`u`||(window.location.hash=ge(e))}function _e(){let e=(0,j.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,N.jsxs)(`div`,{className:`flex h-full items-center justify-center p-6 text-muted-foreground`,role:`status`,"aria-busy":`true`,children:[(0,N.jsx)(c,{className:`mr-2 size-4 animate-spin`,"aria-hidden":`true`}),(0,N.jsx)(`span`,{className:`text-sm`,children:`Loading agent activity`})]}),e[0]=t):t=e[0],t}function ve(e){let t=(0,j.c)(9),{error:n,onRetry:r}=e,i;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(i=(0,N.jsx)(l,{className:`size-6 text-destructive`,"aria-hidden":`true`}),t[0]=i):i=t[0];let a;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(a=(0,N.jsx)(`p`,{className:`text-sm font-medium`,children:`Failed to load activity`}),t[1]=a):a=t[1];let o;t[2]===n?o=t[3]:(o=(0,N.jsxs)(`div`,{className:`space-y-1`,children:[a,(0,N.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:n})]}),t[2]=n,t[3]=o);let s;t[4]===r?s=t[5]:(s=(0,N.jsx)(_,{type:`button`,variant:`outline`,size:`sm`,onClick:r,children:`Retry`}),t[4]=r,t[5]=s);let c;return t[6]!==o||t[7]!==s?(c=(0,N.jsxs)(`div`,{className:`flex flex-col items-center gap-3 p-6 text-center`,role:`alert`,"data-testid":`activity-panel-error`,children:[i,o,s]}),t[6]=o,t[7]=s,t[8]=c):c=t[8],c}function R(){let e=(0,j.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,N.jsx)(`div`,{className:`flex h-full items-center justify-center p-6 text-muted-foreground`,"data-testid":`activity-panel-empty`,children:(0,N.jsx)(`p`,{className:`text-sm italic`,children:`No edits yet.`})}),e[0]=t):t=e[0],t}function ye(e){let t=(0,j.c)(8),{onExit:n}=e,r;t[0]===n?r=t[1]:(r=(0,N.jsx)(z,{onClick:n}),t[0]=n,t[1]=r);let i;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(i=(0,N.jsx)(`h2`,{className:`truncate text-sm font-medium`,children:`Agent activity`}),t[2]=i):i=t[2];let a;t[3]===r?a=t[4]:(a=(0,N.jsxs)(`div`,{className:`flex shrink-0 flex-row items-center gap-2 border-b border-border px-3 py-2`,children:[r,i]}),t[3]=r,t[4]=a);let o;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(o=(0,N.jsx)(`div`,{className:`flex flex-1 items-center justify-center p-6 text-muted-foreground`,children:(0,N.jsx)(`p`,{className:`text-center text-sm italic`,children:`Click an agent's avatar in the presence bar to view their session.`})}),t[5]=o):o=t[5];let s;return t[6]===a?s=t[7]:(s=(0,N.jsxs)(`section`,{className:`flex h-full min-h-0 flex-col`,"data-testid":`activity-panel-no-agent`,"aria-label":`Agent activity`,children:[a,o]}),t[6]=a,t[7]=s),s}function z(e){let t=(0,j.c)(6),{onClick:n}=e,r;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(r=(0,N.jsx)(b,{}),t[0]=r):r=t[0];let i;t[1]===n?i=t[2]:(i=(0,N.jsx)(A,{asChild:!0,children:(0,N.jsx)(_,{type:`button`,variant:`ghost`,size:`icon`,className:`size-7 shrink-0`,onClick:n,"aria-label":`Back to document view`,"data-testid":`docpanel-exit-agent-mode`,children:r})}),t[1]=n,t[2]=i);let a;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(a=(0,N.jsx)(ee,{side:`bottom`,children:`Back to document view`}),t[3]=a):a=t[3];let o;return t[4]===i?o=t[5]:(o=(0,N.jsxs)(te,{children:[i,a]}),t[4]=i,t[5]=o),o}function B(e){let t=(0,j.c)(9),{lastTs:n}=e,[r]=(0,M.useState)(be),i;t[0]!==n||t[1]!==r?(i=n?xe(r-n):null,t[0]=n,t[1]=r,t[2]=i):i=t[2];let a=i,o;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(o=(0,N.jsx)(`span`,{className:`font-medium`,children:`Session ended`}),t[3]=o):o=t[3];let s;t[4]===a?s=t[5]:(s=a?(0,N.jsxs)(`span`,{children:[` · `,a]}):null,t[4]=a,t[5]=s);let c;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(c=(0,N.jsx)(`div`,{className:`mt-1 opacity-80`,children:`Undo buttons are disabled — per-session state has been garbage-collected.`}),t[6]=c):c=t[6];let l;return t[7]===s?l=t[8]:(l=(0,N.jsxs)(`div`,{className:`border-b border-border bg-muted/40 px-4 py-3 text-xs text-muted-foreground`,"data-testid":`activity-panel-session-ended`,children:[o,s,c]}),t[7]=s,t[8]=l),l}function be(){return Date.now()}function xe(e){let t=Math.max(0,e);return t<6e4?`${Math.round(t/1e3)}s ago`:t<36e5?`${Math.round(t/6e4)}m ago`:`${Math.round(t/36e5)}h ago`}function V(e){let t=(0,j.c)(10),{agent:n,size:r}=e,i=r===void 0?28:r,a;t[0]!==n.color||t[1]!==i?(a={backgroundColor:n.color,width:i,height:i},t[0]=n.color,t[1]=i,t[2]=a):a=t[2];let o=i*.57,s=i*.57,c;t[3]!==n.icon||t[4]!==o||t[5]!==s?(c=(0,N.jsx)(x,{icon:n.icon,width:o,height:s}),t[3]=n.icon,t[4]=o,t[5]=s,t[6]=c):c=t[6];let l;return t[7]!==a||t[8]!==c?(l=(0,N.jsx)(`span`,{className:`inline-flex shrink-0 items-center justify-center rounded-full text-white ring-2 ring-background`,style:a,"aria-hidden":`true`,children:c}),t[7]=a,t[8]=c,t[9]=l):l=t[9],l}function Se(e){let t=(0,j.c)(21),{data:n,status:r,error:i,reload:a,fetchBurstDiff:o,onExit:s,onNavigate:c,onUndoLast:l,onUndoAll:u}=e,d=n?.files?.[0]?.lastTs??null,f;t[0]===s?f=t[1]:(f=(0,N.jsx)(z,{onClick:s}),t[0]=s,t[1]=f);let p;t[2]!==n||t[3]!==d?(p=n?.agent?(0,N.jsxs)(N.Fragment,{children:[(0,N.jsx)(V,{agent:n.agent}),(0,N.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,N.jsx)(`h2`,{className:`truncate text-sm font-medium`,children:n.agent.displayName}),(0,N.jsxs)(`p`,{className:`truncate text-xs text-muted-foreground`,children:[n.sessionAlive?`Active`:d===null?`No edit session yet`:`Ended`,n.files.length>0?` · ${n.files.length} file${n.files.length===1?``:`s`}`:``]})]})]}):(0,N.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,N.jsx)(`h2`,{className:`truncate text-sm font-medium`,children:`Agent activity`})}),t[2]=n,t[3]=d,t[4]=p):p=t[4];let m;t[5]!==f||t[6]!==p?(m=(0,N.jsxs)(`div`,{className:`flex flex-row items-center gap-2 border-b border-border px-3 py-2 shrink-0`,children:[f,p]}),t[5]=f,t[6]=p,t[7]=m):m=t[7];let h;t[8]!==n||t[9]!==i||t[10]!==o||t[11]!==d||t[12]!==c||t[13]!==u||t[14]!==l||t[15]!==a||t[16]!==r?(h=(0,N.jsx)(`div`,{className:`flex-1 overflow-y-auto`,"data-testid":`activity-panel-body`,children:r===`loading`&&n===null?(0,N.jsx)(_e,{}):r===`error`&&i?(0,N.jsx)(ve,{error:i,onRetry:a}):n===null?(0,N.jsx)(R,{}):(0,N.jsxs)(N.Fragment,{children:[!n.sessionAlive&&d!==null?(0,N.jsx)(B,{lastTs:d}):null,n.files.length===0?(0,N.jsx)(R,{}):n.files.map(e=>(0,N.jsx)(F,{file:e,sessionAlive:n.sessionAlive,isWriting:n.writingDocs.has(e.docName),onNavigate:c,onUndoLast:l,onUndoAll:u,fetchBurstDiff:o},e.docName))]})}),t[8]=n,t[9]=i,t[10]=o,t[11]=d,t[12]=c,t[13]=u,t[14]=l,t[15]=a,t[16]=r,t[17]=h):h=t[17];let g;return t[18]!==m||t[19]!==h?(g=(0,N.jsxs)(`section`,{className:`flex h-full min-h-0 flex-col`,"data-testid":`activity-panel`,"aria-label":`Agent activity`,children:[m,h]}),t[18]=m,t[19]=h,t[20]=g):g=t[20],g}function H(){let e=(0,j.c)(22),{docPanelAgentId:t,closeActivityPanel:n}=u(),{openDocumentTransition:r}=d(),{data:i,status:a,error:o,reload:s,fetchBurstDiff:c}=se(t);if(t===null){let t;return e[0]===n?t=e[1]:(t=(0,N.jsx)(ye,{onExit:n}),e[0]=n,e[1]=t),t}let l;e[2]===r?l=e[3]:(l=e=>{r(e),L(e)},e[2]=r,e[3]=l);let f=l,p;e[4]!==i||e[5]!==t||e[6]!==s?(p=async e=>{try{await I({connectionId:t,docName:e,scope:`last`,agentName:i?.agent?.displayName}),s()}catch(e){let t=e,n=t instanceof Error?t.message:String(t);k.error(`Undo failed: ${n}`),s()}},e[4]=i,e[5]=t,e[6]=s,e[7]=p):p=e[7];let m=p,h;e[8]!==i||e[9]!==t||e[10]!==s?(h=async e=>{try{await I({connectionId:t,docName:e,scope:`file`,agentName:i?.agent?.displayName}),k.success(`Undone all edits on ${e}`),s()}catch(e){let t=e,n=t instanceof Error?t.message:String(t);k.error(`Undo all failed: ${n}`),s()}},e[8]=i,e[9]=t,e[10]=s,e[11]=h):h=e[11];let g=h,_;return e[12]!==n||e[13]!==i||e[14]!==o||e[15]!==c||e[16]!==f||e[17]!==g||e[18]!==m||e[19]!==s||e[20]!==a?(_=(0,N.jsx)(Se,{data:i,status:a,error:o,reload:s,fetchBurstDiff:c,onExit:n,onNavigate:f,onUndoLast:m,onUndoAll:g}),e[12]=n,e[13]=i,e[14]=o,e[15]=c,e[16]=f,e[17]=g,e[18]=m,e[19]=s,e[20]=a,e[21]=_):_=e[21],_}export{H as ActivityModeContent};
|