@inkeep/open-knowledge 0.0.0-dev-20260428030816 → 0.0.0-dev-20260428063152
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/cli.mjs +9 -9
- package/dist/constants-Dvx0Ir4Z.mjs +2 -0
- package/dist/{dist-BVi1kLgS.mjs → dist-6JXIwkTW.mjs} +13 -13
- package/dist/dist-Rkr9VTaR.mjs +1 -0
- package/dist/index.d.mts +17 -1
- package/dist/index.mjs +1 -1
- package/dist/{init-lR-iOYyJ.mjs → init-0_AyRou2.mjs} +25 -25
- package/dist/init-6aL4nNLi.mjs +1 -0
- package/dist/{init-DzmV7EWn.mjs → init-BrxpN5Ku.mjs} +2 -2
- package/dist/init-DSlKInSe.mjs +1 -0
- package/dist/loader-BKi1CcCu.mjs +1 -0
- package/dist/{loader-Dftbh71h.mjs → loader-Dt0KH_I_.mjs} +2 -2
- package/dist/{paths-9SFXgdez.mjs → paths-3Ss4Y-ca.mjs} +2 -2
- package/dist/paths-CUrzOOI7.mjs +1 -0
- package/dist/{preview-BWEEPmtf.mjs → preview-CYJ8l4Py.mjs} +2 -2
- package/dist/preview-yvwsGk-r.mjs +1 -0
- package/dist/public/assets/{ActivityModeContent-QSE28ToP.js → ActivityModeContent-JeYMJ8N-.js} +1 -1
- package/dist/public/assets/{DocumentContext-C7zXwLGg.js → DocumentContext-D9TYylem.js} +1 -1
- package/dist/public/assets/McpConsentDialogBody-BNfu0z8x.js +1 -0
- package/dist/public/assets/{SourceEditor-B5_U1uud.js → SourceEditor-DBzpEf4D.js} +2 -2
- package/dist/public/assets/{clipboard-BcHcwwH2.js → clipboard-C0HbTlCM.js} +3 -3
- package/dist/public/assets/{index-CfLPPlu0.js → index-CjMTCid5.js} +72 -72
- package/dist/public/index.html +3 -3
- package/dist/server-lock-n3Y5JWNv-3o7br8XE.mjs +2 -0
- package/dist/server-lock-n3Y5JWNv-DXpg9_eU.mjs +1 -0
- package/dist/src-I5zW2G1z.mjs +1 -0
- package/dist/start-5b45Y8cg.mjs +1 -0
- package/dist/{start-YQGf2koi.mjs → start-BPdIGn_L.mjs} +2 -2
- package/package.json +1 -1
- package/dist/constants-BFC8WUGR.mjs +0 -2
- package/dist/dist-DlLqW1l-.mjs +0 -1
- package/dist/init-CpubW-xy.mjs +0 -1
- package/dist/init-Kk_OD9gS.mjs +0 -1
- package/dist/loader-BVRsmTqA.mjs +0 -1
- package/dist/paths-tkdx_ODM.mjs +0 -1
- package/dist/preview-BJIwF_YN.mjs +0 -1
- package/dist/public/assets/McpConsentDialogBody-FBruOF3J.js +0 -1
- package/dist/server-lock-CH0GCP_4-DXqutMlt.mjs +0 -2
- package/dist/server-lock-CH0GCP_4-MazZqjDk.mjs +0 -1
- package/dist/src-CEe0tBjV.mjs +0 -1
- package/dist/start-Bt3IMsVN.mjs +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import"./dist-DRC09WNZ.mjs";import{l as e,o as t}from"./server-lock-n3Y5JWNv-3o7br8XE.mjs";import{Ct as n,D as r,Dt as i,E as a,Gt as o,N as s,Z as c,_ as l,et as u}from"./dist-6JXIwkTW.mjs";export{l as ProjectGitInitError,a as UiLockCollisionError,r as acquireUiLock,s as bootServer,c as ensureProjectGit,u as getLogger,t as isProcessAlive,e as readServerLock,n as readUiLock,i as releaseUiLock,o as updateUiLockPort};
|
package/dist/index.d.mts
CHANGED
|
@@ -1,7 +1,23 @@
|
|
|
1
1
|
//#region src/commands/editors.d.ts
|
|
2
2
|
type EditorId = 'claude' | 'claude-desktop' | 'cursor' | 'vscode' | 'windsurf' | 'codex';
|
|
3
3
|
declare const ALL_EDITOR_IDS: EditorId[];
|
|
4
|
-
|
|
4
|
+
/**
|
|
5
|
+
* MCP install modes for `ok init`-written editor configs.
|
|
6
|
+
*
|
|
7
|
+
* - `'published'` (default) — `{command: 'npx', args: ['@inkeep/open-knowledge', 'mcp']}`.
|
|
8
|
+
* Self-heals after CLI reinstalls; the version each editor's MCP child runs
|
|
9
|
+
* may drift over time (the protocol gate at `cli/mcp/server-discovery.ts`
|
|
10
|
+
* refuses on mismatch).
|
|
11
|
+
* - `'dev'` — `{command: 'node', args: [<dist/cli.mjs>, 'mcp'], env: {...}}`.
|
|
12
|
+
* Used by `--dev-mcp` for monorepo development against a worktree-local CLI.
|
|
13
|
+
* - `'pinned'` — `{command: 'node', args: [<absolute process.argv[1]>, 'mcp']}`.
|
|
14
|
+
* Used by `ok init --pin` (specs/2026-04-24-cross-install-version-handshake
|
|
15
|
+
* §3 G7 + D14). The absolute path is the cli entry of whatever ran `ok init`.
|
|
16
|
+
* Recommended pin target is M6's stable shim at `/usr/local/bin/ok` (the
|
|
17
|
+
* desktop's auto-updater replaces the symlink target atomically); volatile
|
|
18
|
+
* pins (worktree dist, npx-cache) silently stale.
|
|
19
|
+
*/
|
|
20
|
+
type McpInstallMode = 'published' | 'dev' | 'pinned';
|
|
5
21
|
interface McpInstallOptions {
|
|
6
22
|
mode?: McpInstallMode;
|
|
7
23
|
cliEntryPath?: string;
|
package/dist/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{c as e,i as t,l as n,o as r,s as i,t as a}from"./init-
|
|
1
|
+
import{c as e,i as t,l as n,o as r,s as i,t as a}from"./init-0_AyRou2.mjs";import{n as o,r as s}from"./loader-Dt0KH_I_.mjs";import"./src-I5zW2G1z.mjs";export{e as ALL_EDITOR_IDS,s as ConfigSchema,n as EDITOR_TARGETS,a as detectInstalledEditors,o as loadConfig,t as readExistingMcpEntry,r as writeEditorMcpConfig,i as writeUserMcpConfigs};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{t as e}from"./esm-29fM6BBO.mjs";import{r as t}from"./constants-
|
|
1
|
+
import{t as e}from"./esm-29fM6BBO.mjs";import{r as t}from"./constants-Dvx0Ir4Z.mjs";import{p as n}from"./dist-DRC09WNZ.mjs";import{Y as r,Z as i,_ as a,lt as o}from"./dist-6JXIwkTW.mjs";import{n as s}from"./init-BrxpN5Ku.mjs";import{t as c}from"./preview-CYJ8l4Py.mjs";import{s as l,t as u}from"./colors-DoPZvo1q.mjs";import{t as d}from"./is-object-BNVklKxg.mjs";import{basename as f,dirname as p,join as m,posix as h,relative as g,resolve as _,sep as v,win32 as y}from"node:path";import{existsSync as b,mkdirSync as x,readFileSync as S,writeFileSync as C}from"node:fs";import{homedir as w}from"node:os";
|
|
2
2
|
/*!
|
|
3
3
|
* Copyright (c) Squirrel Chat et al., All rights reserved.
|
|
4
4
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
@@ -26,9 +26,9 @@ import{t as e}from"./esm-29fM6BBO.mjs";import{r as t}from"./constants-BFC8WUGR.m
|
|
|
26
26
|
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
27
27
|
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
28
28
|
*/
|
|
29
|
-
function
|
|
29
|
+
function ee(e,t){let n=e.slice(0,t).split(/\r\n|\n|\r/g);return[n.length,n.pop().length+1]}function te(e,t,n){let r=e.split(/\r\n|\n|\r/g),i=``,a=(Math.log10(t+1)|0)+1;for(let e=t-1;e<=t+1;e++){let o=r[e-1];o&&(i+=e.toString().padEnd(a,` `),i+=`: `,i+=o,i+=`
|
|
30
30
|
`,e===t&&(i+=` `.repeat(a+n+2),i+=`^
|
|
31
|
-
`))}return i}var
|
|
31
|
+
`))}return i}var T=class extends Error{line;column;codeblock;constructor(e,t){let[n,r]=ee(t.toml,t.ptr),i=te(t.toml,n,r);super(`Invalid TOML document: ${e}\n\n${i}`,t),this.line=n,this.column=r,this.codeblock=i}};
|
|
32
32
|
/*!
|
|
33
33
|
* Copyright (c) Squirrel Chat et al., All rights reserved.
|
|
34
34
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
@@ -56,14 +56,14 @@ function te(e,t){let n=e.slice(0,t).split(/\r\n|\n|\r/g);return[n.length,n.pop()
|
|
|
56
56
|
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
57
57
|
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
58
58
|
*/
|
|
59
|
-
function
|
|
60
|
-
`,t);return e[r-1]===`\r`&&r--,r<=n?r:-1}function
|
|
59
|
+
function ne(e,t){let n=0;for(;e[t-++n]===`\\`;);return--n&&n%2}function E(e,t=0,n=e.length){let r=e.indexOf(`
|
|
60
|
+
`,t);return e[r-1]===`\r`&&r--,r<=n?r:-1}function D(e,t){for(let n=t;n<e.length;n++){let r=e[n];if(r===`
|
|
61
61
|
`)return n;if(r===`\r`&&e[n+1]===`
|
|
62
|
-
`)return n+1;if(r<` `&&r!==` `||r===``)throw new
|
|
62
|
+
`)return n+1;if(r<` `&&r!==` `||r===``)throw new T(`control characters are not allowed in comments`,{toml:e,ptr:t})}return e.length}function O(e,t,n,r){let i;for(;;){for(;(i=e[t])===` `||i===` `||!n&&(i===`
|
|
63
63
|
`||i===`\r`&&e[t+1]===`
|
|
64
|
-
`);)t++;if(r||i!==`#`)break;t=
|
|
64
|
+
`);)t++;if(r||i!==`#`)break;t=D(e,t)}return t}function re(e,t,n,r,i=!1){if(!r)return t=E(e,t),t<0?e.length:t;for(let a=t;a<e.length;a++){let t=e[a];if(t===`#`)a=E(e,a);else if(t===n)return a+1;else if(t===r||i&&(t===`
|
|
65
65
|
`||t===`\r`&&e[a+1]===`
|
|
66
|
-
`))return a}throw new
|
|
66
|
+
`))return a}throw new T(`cannot find end of structure`,{toml:e,ptr:t})}function k(e,t){let n=e[t],r=n===e[t+1]&&e[t+1]===e[t+2]?e.slice(t,t+3):n;t+=r.length-1;do t=e.indexOf(r,++t);while(t>-1&&n!==`'`&&ne(e,t));return t>-1&&(t+=r.length,r.length>1&&(e[t]===n&&t++,e[t]===n&&t++)),t}
|
|
67
67
|
/*!
|
|
68
68
|
* Copyright (c) Squirrel Chat et al., All rights reserved.
|
|
69
69
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
@@ -91,7 +91,7 @@ function re(e,t){let n=0;for(;e[t-++n]===`\\`;);return--n&&n%2}function T(e,t=0,
|
|
|
91
91
|
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
92
92
|
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
93
93
|
*/
|
|
94
|
-
let
|
|
94
|
+
let ie=/^(\d{4}-\d{2}-\d{2})?[T ]?(?:(\d{2}):\d{2}(?::\d{2}(?:\.\d+)?)?)?(Z|[-+]\d{2}:\d{2})?$/i;var ae=class e extends Date{#e=!1;#t=!1;#n=null;constructor(e){let t=!0,n=!0,r=`Z`;if(typeof e==`string`){let i=e.match(ie);i?(i[1]||(t=!1,e=`0000-01-01T${e}`),n=!!i[2],n&&e[10]===` `&&(e=e.replace(` `,`T`)),i[2]&&+i[2]>23?e=``:(r=i[3]||null,e=e.toUpperCase(),!r&&n&&(e+=`Z`))):e=``}super(e),isNaN(this.getTime())||(this.#e=t,this.#t=n,this.#n=r)}isDateTime(){return this.#e&&this.#t}isLocal(){return!this.#e||!this.#t||!this.#n}isDate(){return this.#e&&!this.#t}isTime(){return this.#t&&!this.#e}isValid(){return this.#e||this.#t}toISOString(){let e=super.toISOString();if(this.isDate())return e.slice(0,10);if(this.isTime())return e.slice(11,23);if(this.#n===null)return e.slice(0,-1);if(this.#n===`Z`)return e;let t=this.#n.slice(1,3)*60+ +this.#n.slice(4,6);return t=this.#n[0]===`-`?t:-t,new Date(this.getTime()-t*6e4).toISOString().slice(0,-1)+this.#n}static wrapAsOffsetDateTime(t,n=`Z`){let r=new e(t);return r.#n=n,r}static wrapAsLocalDateTime(t){let n=new e(t);return n.#n=null,n}static wrapAsLocalDate(t){let n=new e(t);return n.#t=!1,n.#n=null,n}static wrapAsLocalTime(t){let n=new e(t);return n.#e=!1,n.#n=null,n}};
|
|
95
95
|
/*!
|
|
96
96
|
* Copyright (c) Squirrel Chat et al., All rights reserved.
|
|
97
97
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
@@ -119,13 +119,13 @@ let ae=/^(\d{4}-\d{2}-\d{2})?[T ]?(?:(\d{2}):\d{2}(?::\d{2}(?:\.\d+)?)?)?(Z|[-+]
|
|
|
119
119
|
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
120
120
|
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
121
121
|
*/
|
|
122
|
-
let
|
|
122
|
+
let oe=/^((0x[0-9a-fA-F](_?[0-9a-fA-F])*)|(([+-]|0[ob])?\d(_?\d)*))$/,se=/^[+-]?\d(_?\d)*(\.\d(_?\d)*)?([eE][+-]?\d(_?\d)*)?$/,ce=/^[+-]?0[0-9_]/,le=/^[0-9a-f]{2,8}$/i,ue={b:`\b`,t:` `,n:`
|
|
123
123
|
`,f:`\f`,r:`\r`,e:`\x1B`,'"':`"`,"\\":`\\`};function de(e,t=0,n=e.length){let r=e[t]===`'`,i=e[t++]===e[t]&&e[t]===e[t+1];i&&(n-=2,e[t+=2]===`\r`&&t++,e[t]===`
|
|
124
124
|
`&&t++);let a=0,o,s=``,c=t;for(;t<n-1;){let n=e[t++];if(n===`
|
|
125
125
|
`||n===`\r`&&e[t]===`
|
|
126
|
-
`){if(!i)throw new
|
|
127
|
-
`||n===` `||n===` `||n===`\r`)){if(t=
|
|
128
|
-
`&&e[t]!==`\r`)throw new
|
|
126
|
+
`){if(!i)throw new T(`newlines are not allowed in strings`,{toml:e,ptr:t-1})}else if(n<` `&&n!==` `||n===``)throw new T(`control characters are not allowed in strings`,{toml:e,ptr:t-1});if(o){if(o=!1,n===`x`||n===`u`||n===`U`){let r=e.slice(t,t+=n===`x`?2:n===`u`?4:8);if(!le.test(r))throw new T(`invalid unicode escape`,{toml:e,ptr:a});try{s+=String.fromCodePoint(parseInt(r,16))}catch{throw new T(`invalid unicode escape`,{toml:e,ptr:a})}}else if(i&&(n===`
|
|
127
|
+
`||n===` `||n===` `||n===`\r`)){if(t=O(e,t-1,!0),e[t]!==`
|
|
128
|
+
`&&e[t]!==`\r`)throw new T(`invalid escape: only line-ending whitespace may be escaped`,{toml:e,ptr:a});t=O(e,t)}else if(n in ue)s+=ue[n];else throw new T(`unrecognized escape sequence`,{toml:e,ptr:a});c=t}else !r&&n===`\\`&&(a=t-1,o=!0,s+=e.slice(c,a))}return s+e.slice(c,n-1)}function fe(e,t,n,r){if(e===`true`)return!0;if(e===`false`)return!1;if(e===`-inf`)return-1/0;if(e===`inf`||e===`+inf`)return 1/0;if(e===`nan`||e===`+nan`||e===`-nan`)return NaN;if(e===`-0`)return r?0n:0;let i=oe.test(e);if(i||se.test(e)){if(ce.test(e))throw new T(`leading zeroes are not allowed`,{toml:t,ptr:n});e=e.replace(/_/g,``);let a=+e;if(isNaN(a))throw new T(`invalid number`,{toml:t,ptr:n});if(i){if((i=!Number.isSafeInteger(a))&&!r)throw new T(`integer value cannot be represented losslessly`,{toml:t,ptr:n});(i||r===!0)&&(a=BigInt(e))}return a}let a=new ae(e);if(!a.isValid())throw new T(`invalid value`,{toml:t,ptr:n});return a}
|
|
129
129
|
/*!
|
|
130
130
|
* Copyright (c) Squirrel Chat et al., All rights reserved.
|
|
131
131
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
@@ -153,8 +153,8 @@ let se=/^((0x[0-9a-fA-F](_?[0-9a-fA-F])*)|(([+-]|0[ob])?\d(_?\d)*))$/,ce=/^[+-]?
|
|
|
153
153
|
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
154
154
|
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
155
155
|
*/
|
|
156
|
-
function pe(e,t,n){let r=e.slice(t,n),i=r.indexOf(`#`);return i>-1&&(
|
|
157
|
-
`&&e[o]!==`\r`)throw new
|
|
156
|
+
function pe(e,t,n){let r=e.slice(t,n),i=r.indexOf(`#`);return i>-1&&(D(e,i),r=r.slice(0,i)),[r.trimEnd(),i]}function A(e,t,n,r,i){if(r===0)throw new T(`document contains excessively nested structures. aborting.`,{toml:e,ptr:t});let a=e[t];if(a===`[`||a===`{`){let[o,s]=a===`[`?ge(e,t,r,i):he(e,t,r,i);if(n){if(s=O(e,s),e[s]===`,`)s++;else if(e[s]!==n)throw new T(`expected comma or end of structure`,{toml:e,ptr:s})}return[o,s]}let o;if(a===`"`||a===`'`){o=k(e,t);let r=de(e,t,o);if(n){if(o=O(e,o),e[o]&&e[o]!==`,`&&e[o]!==n&&e[o]!==`
|
|
157
|
+
`&&e[o]!==`\r`)throw new T(`unexpected character encountered`,{toml:e,ptr:o});o+=+(e[o]===`,`)}return[r,o]}o=re(e,t,`,`,n);let s=pe(e,t,o-+(e[o-1]===`,`));if(!s[0])throw new T(`incomplete key-value declaration: no value specified`,{toml:e,ptr:t});return n&&s[1]>-1&&(o=O(e,t+s[1]),o+=+(e[o]===`,`)),[fe(s[0],e,t,i),o]}
|
|
158
158
|
/*!
|
|
159
159
|
* Copyright (c) Squirrel Chat et al., All rights reserved.
|
|
160
160
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
@@ -182,9 +182,9 @@ function pe(e,t,n){let r=e.slice(t,n),i=r.indexOf(`#`);return i>-1&&(E(e,i),r=r.
|
|
|
182
182
|
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
183
183
|
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
184
184
|
*/
|
|
185
|
-
let me=/^[a-zA-Z0-9-_]+[ \t]*$/;function j(e,t,n=`=`){let r=t-1,i=[],a=e.indexOf(n,t);if(a<0)throw new
|
|
186
|
-
`&&o!==`\r`){let o,s=i,c=!1,[l,u]=j(e,t-1);for(let n=0;n<l.length;n++){if(n&&(s=c?s[o]:s[o]={}),o=l[n],(c=Object.hasOwn(s,o))&&(typeof s[o]!=`object`||a.has(s[o])))throw new
|
|
187
|
-
`&&a!==`\r`){let a=A(e,t-1,`]`,n-1,r);i.push(a[0]),t=a[1]}if(!a)throw new
|
|
185
|
+
let me=/^[a-zA-Z0-9-_]+[ \t]*$/;function j(e,t,n=`=`){let r=t-1,i=[],a=e.indexOf(n,t);if(a<0)throw new T(`incomplete key-value: cannot find end of key`,{toml:e,ptr:t});do{let o=e[t=++r];if(o!==` `&&o!==` `)if(o===`"`||o===`'`){if(o===e[t+1]&&o===e[t+2])throw new T(`multiline strings are not allowed in keys`,{toml:e,ptr:t});let s=k(e,t);if(s<0)throw new T(`unfinished string encountered`,{toml:e,ptr:t});r=e.indexOf(`.`,s);let c=e.slice(s,r<0||r>a?a:r),l=E(c);if(l>-1)throw new T(`newlines are not allowed in keys`,{toml:e,ptr:t+r+l});if(c.trimStart())throw new T(`found extra tokens after the string part`,{toml:e,ptr:s});if(a<s&&(a=e.indexOf(n,s),a<0))throw new T(`incomplete key-value: cannot find end of key`,{toml:e,ptr:t});i.push(de(e,t,s))}else{r=e.indexOf(`.`,t);let n=e.slice(t,r<0||r>a?a:r);if(!me.test(n))throw new T(`only letter, numbers, dashes and underscores are allowed in keys`,{toml:e,ptr:t});i.push(n.trimEnd())}}while(r+1&&r<a);return[i,O(e,a+1,!0,!0)]}function he(e,t,n,r){let i={},a=new Set,o;for(t++;(o=e[t++])!==`}`&&o;)if(o===`,`)throw new T(`expected value, found comma`,{toml:e,ptr:t-1});else if(o===`#`)t=D(e,t);else if(o!==` `&&o!==` `&&o!==`
|
|
186
|
+
`&&o!==`\r`){let o,s=i,c=!1,[l,u]=j(e,t-1);for(let n=0;n<l.length;n++){if(n&&(s=c?s[o]:s[o]={}),o=l[n],(c=Object.hasOwn(s,o))&&(typeof s[o]!=`object`||a.has(s[o])))throw new T(`trying to redefine an already defined value`,{toml:e,ptr:t});!c&&o===`__proto__`&&Object.defineProperty(s,o,{enumerable:!0,configurable:!0,writable:!0})}if(c)throw new T(`trying to redefine an already defined value`,{toml:e,ptr:t});let[d,f]=A(e,u,`}`,n-1,r);a.add(d),s[o]=d,t=f}if(!o)throw new T(`unfinished table encountered`,{toml:e,ptr:t});return[i,t]}function ge(e,t,n,r){let i=[],a;for(t++;(a=e[t++])!==`]`&&a;)if(a===`,`)throw new T(`expected value, found comma`,{toml:e,ptr:t-1});else if(a===`#`)t=D(e,t);else if(a!==` `&&a!==` `&&a!==`
|
|
187
|
+
`&&a!==`\r`){let a=A(e,t-1,`]`,n-1,r);i.push(a[0]),t=a[1]}if(!a)throw new T(`unfinished array encountered`,{toml:e,ptr:t});return[i,t]}
|
|
188
188
|
/*!
|
|
189
189
|
* Copyright (c) Squirrel Chat et al., All rights reserved.
|
|
190
190
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
@@ -212,8 +212,8 @@ let me=/^[a-zA-Z0-9-_]+[ \t]*$/;function j(e,t,n=`=`){let r=t-1,i=[],a=e.indexOf
|
|
|
212
212
|
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
213
213
|
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
214
214
|
*/
|
|
215
|
-
function M(e,t,n,r){let i=t,a=n,o,s=!1,c;for(let t=0;t<e.length;t++){if(t){if(i=s?i[o]:i[o]={},a=(c=a[o]).c,r===0&&(c.t===1||c.t===2))return null;if(c.t===2){let e=i.length-1;i=i[e],a=a[e].c}}if(o=e[t],(s=Object.hasOwn(i,o))&&a[o]?.t===0&&a[o]?.d)return null;s||(o===`__proto__`&&(Object.defineProperty(i,o,{enumerable:!0,configurable:!0,writable:!0}),Object.defineProperty(a,o,{enumerable:!0,configurable:!0,writable:!0})),a[o]={t:t<e.length-1&&r===2?3:r,d:!1,i:0,c:{}})}if(c=a[o],c.t!==r&&!(r===1&&c.t===3)||(r===2&&(c.d||(c.d=!0,i[o]=[]),i[o].push(i={}),c.c[c.i++]=c={t:1,d:!1,i:0,c:{}}),c.d))return null;if(c.d=!0,r===1)i=s?i[o]:i[o]={};else if(r===0&&s)return null;return[o,i,c.c]}function _e(e,{maxDepth:t=1e3,integersAsBigInt:n}={}){let r={},i={},a=r,o=i;for(let s=
|
|
216
|
-
`&&e[s]!==`\r`)throw new
|
|
215
|
+
function M(e,t,n,r){let i=t,a=n,o,s=!1,c;for(let t=0;t<e.length;t++){if(t){if(i=s?i[o]:i[o]={},a=(c=a[o]).c,r===0&&(c.t===1||c.t===2))return null;if(c.t===2){let e=i.length-1;i=i[e],a=a[e].c}}if(o=e[t],(s=Object.hasOwn(i,o))&&a[o]?.t===0&&a[o]?.d)return null;s||(o===`__proto__`&&(Object.defineProperty(i,o,{enumerable:!0,configurable:!0,writable:!0}),Object.defineProperty(a,o,{enumerable:!0,configurable:!0,writable:!0})),a[o]={t:t<e.length-1&&r===2?3:r,d:!1,i:0,c:{}})}if(c=a[o],c.t!==r&&!(r===1&&c.t===3)||(r===2&&(c.d||(c.d=!0,i[o]=[]),i[o].push(i={}),c.c[c.i++]=c={t:1,d:!1,i:0,c:{}}),c.d))return null;if(c.d=!0,r===1)i=s?i[o]:i[o]={};else if(r===0&&s)return null;return[o,i,c.c]}function _e(e,{maxDepth:t=1e3,integersAsBigInt:n}={}){let r={},i={},a=r,o=i;for(let s=O(e,0);s<e.length;){if(e[s]===`[`){let t=e[++s]===`[`,n=j(e,s+=+t,`]`);if(t){if(e[n[1]-1]!==`]`)throw new T(`expected end of table declaration`,{toml:e,ptr:n[1]-1});n[1]++}let c=M(n[0],r,i,t?2:1);if(!c)throw new T(`trying to redefine an already defined table or value`,{toml:e,ptr:s});o=c[2],a=c[1],s=n[1]}else{let r=j(e,s),i=M(r[0],a,o,0);if(!i)throw new T(`trying to redefine an already defined table or value`,{toml:e,ptr:s});let c=A(e,r[1],void 0,t,n);i[1][i[0]]=c[0],s=c[1]}if(s=O(e,s,!0),e[s]&&e[s]!==`
|
|
216
|
+
`&&e[s]!==`\r`)throw new T(`each key-value declaration must be followed by an end-of-line`,{toml:e,ptr:s});s=O(e,s)}return r}
|
|
217
217
|
/*!
|
|
218
218
|
* Copyright (c) Squirrel Chat et al., All rights reserved.
|
|
219
219
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
@@ -247,8 +247,8 @@ let N=/^[a-z0-9-_]+$/i;function P(e){let t=typeof e;if(t===`object`){if(Array.is
|
|
|
247
247
|
`)+L(e,t[c],e,r-1,i)}else a+=s,a+=` = `,a+=I(t[c],e,r,i),a+=`
|
|
248
248
|
`}}return e&&(a||!o)&&(a=a?`[${e}]\n${a}`:`[${e}]`),a&&o?`${a}\n${o}`:a||o}function Se(e,{maxDepth:t=1e3,numbersAsFloat:n=!1}={}){if(P(e)!==`object`)throw TypeError(`stringify can only be called with an object`);let r=L(0,e,``,t,n);return r[r.length-1]===`
|
|
249
249
|
`?r:r+`
|
|
250
|
-
`}const R=[`claude`,`claude-desktop`,`cursor`,`vscode`,`windsurf`,`codex`],Ce=[`@inkeep/open-knowledge`,`mcp`],we={MCP_DEBUG:`1`,OK_LOG_FILE:`/tmp/ok-mcp.log`};function z(e=process.argv[1]){if(!e)throw Error(`Cannot infer the local CLI entry for --dev-mcp because process.argv[1] is empty.`);let t=
|
|
251
|
-
`)?n:`${n}\n`,`utf-8`)}const Fe=`0.0.1`,X=`open-knowledge-ui`;function Ie(e,t={}){let n=m(e,`.claude`,`launch.json`),r=t.mode===`dev`?{name:X,runtimeExecutable:`node`,runtimeArgs:[z(t.cliEntryPath),`ui`],port:3e3}:{name:X,runtimeExecutable:`npx`,runtimeArgs:[`@inkeep/open-knowledge`,`ui`],port:3e3};try{if(!
|
|
252
|
-
`)}function $(e,t){let n=[];for(let r of R)Z(Y[r],e,t)&&n.push(r);return n}function He(){return new e(`init`).description(`Scaffold ${n}/ in the current directory and register the MCP server for your editor(s)`).option(`--mcp`,`Register the MCP server for selected editors (default: true)`,!0).option(`--no-mcp`,`Scaffold the ${n}/ directory but do not touch MCP config`).option(`--dev-mcp`,`Register a local dev MCP entry using node + packages/cli/dist/cli.mjs with debug logging`).action(async e=>{let t=process.cwd(),n;try{n=await Be({cwd:t,mcp:e.mcp,devMcp:e.devMcp})}catch(e){if(e instanceof
|
|
253
|
-
`),e.stderr&&process.stderr.write(`${e.stderr.trim()}\n`),process.exitCode=1;return}throw e}try{let{previewContent:e}=await import(`./preview-
|
|
254
|
-
//# sourceMappingURL=init-
|
|
250
|
+
`}const R=[`claude`,`claude-desktop`,`cursor`,`vscode`,`windsurf`,`codex`],Ce=[`@inkeep/open-knowledge`,`mcp`],we={MCP_DEBUG:`1`,OK_LOG_FILE:`/tmp/ok-mcp.log`};function z(e=process.argv[1]){if(!e)throw Error(`Cannot infer the local CLI entry for --dev-mcp because process.argv[1] is empty.`);let t=_(e);if(f(t)===`cli.mjs`&&f(p(t))===`dist`)return t;let n=t.split(v),r=n.lastIndexOf(`packages`);if(r===-1||n[r+1]!==`cli`)throw Error(`Cannot infer the repo root for --dev-mcp from ${t}. Run the local CLI from this repo so the built dist path can be derived.`);let i=n.slice(0,r);return m(i.length===0?v:i.join(v),`packages`,`cli`,`dist`,`cli.mjs`)}function B(e={}){if(e.cliPath)return{command:e.cliPath,args:[`mcp`]};if(e.mode===`pinned`){let t=e.cliEntryPath??process.argv[1];if(!t)throw Error("Cannot pin MCP entry — process.argv[1] is empty. Pass --no-pin to use the default `npx` entry.");return{command:`node`,args:[_(t),`mcp`]}}return e.mode===`dev`?{command:`node`,args:[z(e.cliEntryPath),`mcp`],env:{...we}}:{command:`npx`,args:[...Ce]}}function V(e){return e===`win32`?y:h}function Te(e={}){let t=e.platformName??process.platform,n=e.home??w(),r=e.env??process.env,i=V(t);return t===`darwin`?i.join(n,`Library`,`Application Support`):t===`win32`?r.APPDATA??i.join(n,`AppData`,`Roaming`):r.XDG_CONFIG_HOME??i.join(n,`.config`)}function Ee(e={}){let t=e.platformName??process.platform,n=e.home??w();return V(t).join(n,`.claude.json`)}function H(e={}){let t=e.platformName??process.platform,n=e.home??w(),r=e.env??process.env;if(t===`darwin`)return h.join(n,`Library`,`Application Support`,`Claude`,`claude_desktop_config.json`);if(t===`win32`){let e=r.APPDATA??y.join(n,`AppData`,`Roaming`);return y.join(e,`Claude`,`claude_desktop_config.json`)}throw Error(`Claude Desktop is not available on ${t}. Supported: macOS, Windows.`)}function U(e={}){let t=e.platformName??process.platform,n=e.home??w();return V(t).join(n,`.cursor`,`mcp.json`)}function W(e={}){return V(e.platformName??process.platform).join(Te(e),`Code`,`User`,`mcp.json`)}function G(e={}){let t=e.platformName??process.platform,n=e.home??w();return V(t).join(n,`.codeium`,`windsurf`,`mcp_config.json`)}function De(e={}){let t=e.platformName??process.platform,n=e.home??w();return(e.env??process.env).CODEX_HOME??V(t).join(n,`.codex`)}function K(e={}){return V(e.platformName??process.platform).join(De(e),`config.toml`)}function q(e,t){if(e===t)return!0;if(Array.isArray(e)&&Array.isArray(t))return e.length===t.length&&e.every((e,n)=>q(e,t[n]));if(d(e)&&d(t)){let n=Object.keys(e).sort(),r=Object.keys(t).sort();return n.length===r.length&&n.every((e,t)=>e===r[t])&&n.every(n=>q(e[n],t[n]))}return!1}function Oe(e,t){return Object.entries(t).every(([t,n])=>q(e[t],n))}function ke(e,t){return{...e,...t}}function J(e){return{...e,isCompatible(t,n,r){return Oe(t,e.buildEntry(n,r))},mergeManagedFields(t,n,r){return ke(t,e.buildEntry(n,r))}}}const Y={claude:J({id:`claude`,label:`Claude Code`,configPath:(e,t)=>Ee({home:t}),format:`json`,topLevelKey:`mcpServers`,serverName:()=>t,buildEntry:(e,t)=>B(t),scope:`global`,detectPath:(e,t)=>m(t??w(),`.claude`),legacyProjectConfigPath:e=>m(e,`.mcp.json`)}),"claude-desktop":J({id:`claude-desktop`,label:`Claude Desktop`,configPath:(e,t)=>H({home:t}),format:`json`,topLevelKey:`mcpServers`,serverName:()=>t,buildEntry:(e,t)=>B(t),scope:`global`,detectPath:(e,t)=>p(H({home:t}))}),cursor:J({id:`cursor`,label:`Cursor`,configPath:(e,t)=>U({home:t}),format:`json`,topLevelKey:`mcpServers`,serverName:()=>t,buildEntry:(e,t)=>B(t),scope:`global`,detectPath:(e,t)=>p(U({home:t})),legacyProjectConfigPath:e=>m(e,`.cursor`,`mcp.json`)}),vscode:J({id:`vscode`,label:`VS Code`,configPath:(e,t)=>W({home:t}),format:`json`,topLevelKey:`servers`,serverName:()=>t,buildEntry:(e,t)=>({type:`stdio`,...B(t)}),scope:`global`,detectPath:(e,t)=>p(W({home:t})),legacyProjectConfigPath:e=>m(e,`.vscode`,`mcp.json`)}),windsurf:J({id:`windsurf`,label:`Windsurf`,configPath:(e,t)=>G({home:t}),format:`json`,topLevelKey:`mcpServers`,serverName:()=>t,buildEntry:(e,t)=>B(t),scope:`global`,detectPath:(e,t)=>p(G({home:t}))}),codex:J({id:`codex`,label:`Codex`,configPath:(e,t)=>K({home:t}),format:`toml`,topLevelKey:`mcp_servers`,serverName:()=>t,buildEntry:(e,t)=>B(t),scope:`global`,detectPath:(e,t)=>p(K({home:t})),legacyProjectConfigPath:e=>m(e,`.codex`,`config.toml`)})};function Ae(e){let t=e.filter(e=>!(e in Y));if(t.length>0)throw Error(`Unknown editor(s): ${t.join(`, `)}. Valid options: ${R.join(`, `)}`);return e.map(e=>Y[e])}function je(e){if(!b(e))return{};let t=S(e,`utf-8`).trim();if(t===``)return{};try{let n=JSON.parse(t);if(d(n))return n;throw Error(`${e} root must be a JSON object`)}catch(t){throw t instanceof SyntaxError?Error(`${e} contains invalid JSON: ${t.message}`):t}}function Me(e){if(!b(e))return{};let t=S(e,`utf-8`).trim();if(t===``)return{};try{let n=_e(t);if(d(n))return n;throw Error(`${e} root must be a TOML table`)}catch(t){throw Error(`${e} contains invalid TOML: ${t instanceof Error?t.message:String(t)}`)}}function Ne(e,t){x(p(e),{recursive:!0}),C(e,`${JSON.stringify(t,null,2)}\n`,`utf-8`)}function Pe(e,t){x(p(e),{recursive:!0});let n=Se(t);C(e,n.endsWith(`
|
|
251
|
+
`)?n:`${n}\n`,`utf-8`)}const Fe=`0.0.1`,X=`open-knowledge-ui`;function Ie(e,t={}){let n=m(e,`.claude`,`launch.json`),r=t.mode===`dev`?{name:X,runtimeExecutable:`node`,runtimeArgs:[z(t.cliEntryPath),`ui`],port:3e3}:{name:X,runtimeExecutable:`npx`,runtimeArgs:[`@inkeep/open-knowledge`,`ui`],port:3e3};try{if(!b(n))return x(p(n),{recursive:!0}),C(n,`${JSON.stringify({version:Fe,configurations:[r]},null,2)}\n`,`utf-8`),{action:`created`,configPath:n};let e=S(n,`utf-8`).trim(),t=e?JSON.parse(e):{};if(!d(t))return{action:`failed`,configPath:n,error:`launch.json root is not an object`};let i=Array.isArray(t.configurations)?t.configurations:[],a=i.findIndex(e=>d(e)&&e.name===X);a>=0?i[a]=r:i.push(r);let o={...t,version:t.version??Fe,configurations:i};return C(n,`${JSON.stringify(o,null,2)}\n`,`utf-8`),{action:a>=0?`merged`:`created`,configPath:n}}catch(e){return{action:`failed`,configPath:n,error:e instanceof Error?e.message:String(e)}}}function Z(e,t,n){try{return b(e.detectPath?.(t,n)??p(e.configPath(t,n)))}catch{return!1}}function Q(e,t,n,r){let i=e.serverName(t),a;try{a=e.configPath(t,r)}catch(t){return{editorId:e.id,label:e.label,action:`failed`,configPath:``,serverName:i,error:t instanceof Error?t.message:String(t)}}if(!n.skipAvailabilityCheck&&!Z(e,t,r))return{editorId:e.id,label:e.label,action:`skipped-missing`,configPath:a,serverName:i};let o;try{o=e.format===`toml`?Me(a):je(a)}catch(t){return{editorId:e.id,label:e.label,action:`failed`,configPath:a,serverName:i,error:t instanceof Error?t.message:String(t)}}let s=o[e.topLevelKey]??{},c=s[i],l;try{l=e.buildEntry(t,n)}catch(t){return{editorId:e.id,label:e.label,action:`failed`,configPath:a,serverName:i,error:t instanceof Error?t.message:String(t)}}let u={...o,[e.topLevelKey]:{...s,[i]:l}};try{e.format===`toml`?Pe(a,u):Ne(a,u)}catch(t){return{editorId:e.id,label:e.label,action:`failed`,configPath:a,serverName:i,error:t instanceof Error?t.message:String(t)}}return{editorId:e.id,label:e.label,action:c===void 0?`written`:`overwritten`,configPath:a,serverName:i}}function Le(e,t){let n=e.legacyProjectConfigPath?.(t);if(!(!n||!b(n)))return{editorId:e.id,label:e.label,path:n}}async function Re(e){let t=Ae(e.editors),n={mode:`published`,cliPath:e.cliPath,skipAvailabilityCheck:!0};return t.map(t=>Q(t,``,n,e.home))}function ze(e,t,n){let r;try{r=e.configPath(t,n)}catch{return null}let i;try{i=e.format===`toml`?Me(r):je(r)}catch{return null}let a=i[e.topLevelKey];if(!d(a))return null;let o=a[e.serverName(t)];return d(o)?o:null}async function Be(e={}){let t=_(e.cwd??process.cwd()),n={mode:e.pin?`pinned`:e.devMcp?`dev`:`published`,cliEntryPath:e.cliEntryPath},a=await i(t),c;try{c=s(t)}catch(n){let r=Y.claude.configPath(t,e.home);return{contentCreated:[],contentSkipped:[],editors:[],legacyProjectConfigs:[],didGitInit:a.didInit,claudeDesktopDetected:!1,mcpAction:`failed`,mcpPath:r,mcpError:`Content scaffolding failed: ${n instanceof Error?n.message:String(n)}`}}let l=Ae(e.editors??$(t,e.home)),u=l.filter(n=>Z(n,t,e.home)),d=[];for(let r of l){if(e.mcp===!1){let n=``;try{n=r.configPath(t,e.home)}catch{}d.push({editorId:r.id,label:r.label,action:`skipped-flag`,configPath:n,serverName:r.serverName(t)});continue}d.push(Q(r,t,n,e.home))}let f=e.mcp===!1?[]:u.map(e=>Le(e,t)).filter(e=>e!==void 0),p=u.some(e=>e.id===`claude`)&&e.mcp!==!1?Ie(t,n):void 0,m=await(e.installUserSkill??o)({home:e.home}),h=r({home:e.home}),g=e.mcp===!1?`skipped-flag`:`skipped-missing`,v=d.find(e=>e.editorId===`claude`)??d[0]??{action:g,configPath:Y.claude.configPath(t,e.home)};return{contentCreated:c.created,contentSkipped:c.skipped,editors:d,legacyProjectConfigs:f,launchJson:p,skillInstall:m,didGitInit:a.didInit,claudeDesktopDetected:h,mcpAction:v.action,mcpPath:v.configPath,mcpError:`error`in v?v.error:void 0}}function Ve(e,t){let r=[],i=e.editors.some(e=>e.action===`written`||e.action===`overwritten`),a=e.editors.some(e=>e.action===`failed`),o=e.editors.length>0&&e.editors.every(e=>e.action===`skipped-flag`),s=e.editors.length>0&&e.editors.every(e=>e.action===`skipped-missing`),d=e=>{let n=e.configPath.startsWith(t)?g(t,e.configPath):e.configPath;switch(e.action){case`created`:return` app preview server ${n} configured for Claude Code Desktop embedded browser`;case`merged`:return` app preview server ${n} updated for Claude Code Desktop embedded browser`;case`failed`:return` app preview server ${n} FAILED: ${e.error}`}};e.didGitInit&&r.push(`Initialized git repo at ${t}/.git/ (default branch: main)`);let f=m(t,n);if(e.contentCreated.length>0?(r.push(`Content scaffolded at ${f}/`),r.push(` Created: ${e.contentCreated.join(`, `)}`)):r.push(`Content already present at ${f}/`),e.contentSkipped.length>0&&r.push(` Skipped (already exist): ${e.contentSkipped.join(`, `)}`),r.push(``),e.mcpError&&e.editors.length===0)r.push(`Warning: ${e.mcpError}`);else if(e.editors.length===0)r.push(`MCP server configuration:`),r.push(e.mcpAction===`skipped-flag`?` MCP config not written — use without --no-mcp to configure editors`:` No supported editor config directories detected; skipped MCP registration`);else if(o)r.push(`MCP config not written — use without --no-mcp to configure editors`);else if(s)r.push(`MCP server configuration:`),r.push(` No supported editor config directories detected; skipped MCP registration`);else{r.push(`MCP server configuration:`);for(let n of e.editors){let i=n.configPath.startsWith(t)?g(t,n.configPath):n.configPath.replace(/^\/Users\/[^/]+/,`~`),a=n.serverName===`open-knowledge`?``:` (${n.serverName})`,o=` `.repeat(Math.max(1,14-n.label.length)),s=n.editorId===`claude-desktop`&&(n.action===`written`||n.action===`overwritten`)?` — quit and relaunch Claude Desktop to activate`:``;switch(n.action){case`written`:r.push(` ${n.label}${o}${i} registered${a}${s}`);break;case`overwritten`:r.push(` ${n.label}${o}${i} updated${a}${s}`);break;case`skipped-missing`:r.push(` ${n.label}${o}${i} config root missing; skipped`);break;case`failed`:r.push(` ${n.label}${o}${i} FAILED: ${n.error}`);break;case`skipped-flag`:break}n.editorId===`claude`&&e.launchJson&&r.push(d(e.launchJson))}}if(a&&(r.push(``),r.push(`For failed editors, add the MCP server entry manually. See:`),r.push(` https://github.com/inkeep/open-knowledge#mcp-setup`)),e.legacyProjectConfigs.length>0){r.push(``),r.push(`Legacy project MCP configs detected:`);for(let n of e.legacyProjectConfigs)r.push(` ${n.label} ${g(t,n.path)}`);r.push(` These project-local files may override the new global config. Remove them if you want fully user-scoped MCP setup in this project.`)}if(e.skillInstall)switch(r.push(``),r.push(`User-global skill:`),e.skillInstall){case`installed`:r.push(" open-knowledge installed to detected agent hosts via `npx skills`");break;case`skip-current`:r.push(` open-knowledge already installed at current version`);break;case`failed`:r.push(` ${l(`open-knowledge install failed — MCP still configured; run manually:`)}`),r.push(` ${l(` npx skills@~1.5.0 add <bundled-path> --agent '*' -g -y --copy`)}`);break}if(e.claudeDesktopDetected&&(r.push(``),r.push(`Claude Desktop App detected. To enable in Claude Chat & Cowork, run: ${u(`ok install-skill`)}`)),e.preview?(r.push(``),r.push(c(e.preview,t))):e.previewWarning&&(r.push(``),r.push(`Content preview unavailable: ${e.previewWarning}`)),i){let t=e.editors.filter(e=>e.action===`written`||e.action===`overwritten`).map(e=>e.label);r.push(``),r.push(`Next steps:`),r.push(` 1. Open your editor (${t.join(` / `)})`),r.push(` 2. Approve the MCP server when prompted`),r.push(` 3. (Optional) scaffold the starter knowledge-base structure:`),r.push(` - ok seed`),r.push(` 4. Use the three MCP workflow tools as you build the wiki:`),r.push(` - mcp__open-knowledge__ingest — capture an external source`),r.push(` - mcp__open-knowledge__research — gather sources and write findings`),r.push(` - mcp__open-knowledge__consolidate — promote research to canonical articles`)}return r.join(`
|
|
252
|
+
`)}function $(e,t){let n=[];for(let r of R)Z(Y[r],e,t)&&n.push(r);return n}function He(){return new e(`init`).description(`Scaffold ${n}/ in the current directory and register the MCP server for your editor(s)`).option(`--mcp`,`Register the MCP server for selected editors (default: true)`,!0).option(`--no-mcp`,`Scaffold the ${n}/ directory but do not touch MCP config`).option(`--dev-mcp`,`Register a local dev MCP entry using node + packages/cli/dist/cli.mjs with debug logging`).option(`--pin`,"Pin the MCP entry to the absolute path of the current CLI binary instead of `npx`. Use a stable shim like /usr/local/bin/ok for upgrade-safe pinning; npx-cache or worktree paths will go stale on reinstall.").option(`--no-pin`,"Use the default unpinned `npx @inkeep/open-knowledge mcp` MCP entry").action(async e=>{let t=process.cwd(),n;try{n=await Be({cwd:t,mcp:e.mcp,devMcp:e.devMcp,pin:e.pin})}catch(e){if(e instanceof a){process.stderr.write(`open-knowledge requires git to initialize a parent repo. Install git or run 'git init' yourself, then re-run.
|
|
253
|
+
`),e.stderr&&process.stderr.write(`${e.stderr.trim()}\n`),process.exitCode=1;return}throw e}try{let{previewContent:e}=await import(`./preview-yvwsGk-r.mjs`),{loadConfig:r}=await import(`./loader-BKi1CcCu.mjs`),{resolveContentDir:i}=await import(`./paths-CUrzOOI7.mjs`),{config:a}=r(t),o=i(a,t);n.preview=e({projectDir:t,contentDir:o,include:a.content.include,exclude:a.content.exclude})}catch(e){n.previewWarning=e instanceof Error?e.message:String(e)}process.stdout.write(`${Ve(n,t)}\n`),(n.editors.some(e=>e.action===`failed`)||n.mcpAction===`failed`)&&(process.exitCode=1)})}export{Be as a,R as c,ze as i,Y as l,Ve as n,Q as o,He as r,Re as s,$ as t};
|
|
254
|
+
//# sourceMappingURL=init-0_AyRou2.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as e,i as t,n,o as r,r as i,s as a,t as o}from"./init-0_AyRou2.mjs";export{o as detectInstalledEditors,n as formatInitResult,i as initCommand,t as readExistingMcpEntry,e as runInit,r as writeEditorMcpConfig,a as writeUserMcpConfigs};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{n as e,t}from"./constants-
|
|
1
|
+
import{n as e,t}from"./constants-Dvx0Ir4Z.mjs";import{p as n}from"./dist-DRC09WNZ.mjs";import{join as r,resolve as i}from"node:path";import{existsSync as a,mkdirSync as o,readFileSync as s,writeFileSync as c}from"node:fs";const l=`# Open Knowledge — workspace configuration
|
|
2
2
|
#
|
|
3
3
|
# This file overrides built-in defaults for this workspace. Every key below
|
|
4
4
|
# is commented out and shows its current default value. Uncomment any key
|
|
@@ -117,4 +117,4 @@ import{n as e,t}from"./constants-BFC8WUGR.mjs";import{p as n}from"./dist-DRC09WN
|
|
|
117
117
|
|
|
118
118
|
`)?`
|
|
119
119
|
`:``}${i}`,`utf-8`),`appended`)}const f=[{name:`.gitignore`,content:`${t}/\nserver.lock\nui.lock\nsync-state.json\n`},{name:e,content:l}];function p(e){let a=i(e,n),s=[],c=[];o(a,{recursive:!0}),o(r(a,t),{recursive:!0});for(let e of f)u(r(a,e.name),e.content)?s.push(e.name):c.push(e.name);return{created:s,skipped:c}}export{p as n,d as t};
|
|
120
|
-
//# sourceMappingURL=init-
|
|
120
|
+
//# sourceMappingURL=init-BrxpN5Ku.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{n as e,t}from"./init-BrxpN5Ku.mjs";export{t as ensureOkGitignoredAtRoot,e as initContent};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{n as e}from"./loader-Dt0KH_I_.mjs";export{e as loadConfig};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import{t as e}from"./dist-BCyi1oM7.mjs";import{n as t}from"./constants-
|
|
1
|
+
import{t as e}from"./dist-BCyi1oM7.mjs";import{n as t}from"./constants-Dvx0Ir4Z.mjs";import{B as n,K as r,Z as i,et as a,p as o,q as s,z as c}from"./dist-DRC09WNZ.mjs";import{t as l}from"./is-object-BNVklKxg.mjs";import{resolve as u}from"node:path";import{existsSync as d,readFileSync as f}from"node:fs";import{homedir as p}from"node:os";import{realpath as m}from"node:fs/promises";async function h(e){let t=u(e);try{return await m(t)}catch(e){if(e.code!==`ENOENT`){let n=e instanceof Error?e.message:String(e);console.warn(`[normalize-cwd] realpath failed for ${t}: ${n}`)}return t}}const g=s({title:i().optional(),description:i().optional(),tags:c(i()).optional()}).strict(),_=s({match:i().min(1,"`match` must be a non-empty glob pattern (e.g. 'specs/**' or 'reports/*/**')"),frontmatter:g}).strict(),v=s({content:s({dir:i().default(`.`),include:c(i()).min(1).default([`**/*.md`,`**/*.mdx`]),exclude:c(i()).default([])}).default({dir:`.`,include:[`**/*.md`,`**/*.mdx`],exclude:[]}),github:s({oauthAppClientId:i().default(`Ov23liqlSd0V1MwR6rhI`)}).default({oauthAppClientId:`Ov23liqlSd0V1MwR6rhI`}),sync:s({enabled:n().optional(),pushIntervalSeconds:r().int().min(1).default(60),pullIntervalSeconds:r().int().min(1).default(30),autoCommit:n().default(!0),autoPush:n().default(!0),autoPull:n().default(!0),commitMessage:i().default(`auto`)}).default({pushIntervalSeconds:60,pullIntervalSeconds:30,autoCommit:!0,autoPush:!0,autoPull:!0,commitMessage:`auto`}),server:s({port:r().int().min(0).max(65535).default(0),host:i().regex(/^[\w.\-:]+$/,`Invalid hostname`).default(`localhost`),openOnAgentEdit:n().default(!1)}).default({port:0,host:`localhost`,openOnAgentEdit:!1}),persistence:s({debounceMs:r().int().min(0).default(2e3),maxDebounceMs:r().int().min(0).default(1e4)}).default({debounceMs:2e3,maxDebounceMs:1e4}),preview:s({baseUrl:a().optional()}).default({}),folders:c(_).default([]),mcp:s({autoStart:n().default(!0),tools:s({read_document:s({historyDepth:r().int().min(0).default(5)}).default({historyDepth:5}),search:s({maxResults:r().int().min(1).default(50)}).default({maxResults:50})}).default({read_document:{historyDepth:5},search:{maxResults:50}})}).default({autoStart:!0,tools:{read_document:{historyDepth:5},search:{maxResults:50}}})});var y=e();function b(e,t){let n={...e};for(let r of Object.keys(t)){let i=e[r],a=t[r];l(a)&&l(i)?n[r]=b(i,a):a!==void 0&&(n[r]=a)}return n}function x(e){if(!d(e))return null;try{let t=(0,y.parse)(f(e,`utf-8`));return l(t)?t:null}catch(t){return console.warn(`[config] Failed to parse ${e}: ${t instanceof Error?t.message:t}`),null}}function S(e){let n=e??process.cwd(),r=[],i=u(p(),o,t),a={},s=x(i);s&&(a=b(a,s),r.push(i));let c=u(n,o,t),l=x(c);l&&(a=b(a,l),r.push(c));let d=v.safeParse(a);if(!d.success){let e=d.error.issues.map(e=>` ${e.path.join(`.`)}: ${e.message}`);throw Error(`Invalid configuration:\n${e.join(`
|
|
2
2
|
`)}`)}return{config:d.data,sources:r}}function C(e,t=process.env){let n=e;return t.PORT&&(n={...n,server:{...n.server,port:Number(t.PORT)}}),t.HOST&&(n={...n,server:{...n.server,host:t.HOST}}),n}function w(e){let t=e.env??process.env,n=e.cacheMs??1e3,r=e.loadConfigFn??S,i=new Map,a=new Map,o=h(e.startupCwd);return async s=>{let c=await h(s??e.startupCwd),l=Date.now(),u=i.get(c);if(u&&u.expiresAt>l)return u.config;let d=a.get(c);if(d)return await d;let f=(async()=>{if(c===await o){let r=C(e.startupConfig,t);return i.set(c,{config:r,expiresAt:Date.now()+n}),r}let a=C(r(c).config,t);return i.set(c,{config:a,expiresAt:Date.now()+n}),a})();a.set(c,f);try{return await f}finally{a.delete(c)}}}export{h as i,S as n,v as r,w as t};
|
|
3
|
-
//# sourceMappingURL=loader-
|
|
3
|
+
//# sourceMappingURL=loader-Dt0KH_I_.mjs.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import"./constants-
|
|
2
|
-
//# sourceMappingURL=paths-
|
|
1
|
+
import"./constants-Dvx0Ir4Z.mjs";import{p as e}from"./dist-DRC09WNZ.mjs";import{resolve as t}from"node:path";function n(e,n){return t(n,e.content.dir)}function r(n){return t(n,e)}export{r as n,n as t};
|
|
2
|
+
//# sourceMappingURL=paths-3Ss4Y-ca.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{n as e,t}from"./paths-3Ss4Y-ca.mjs";export{t as resolveContentDir,e as resolveLockDir};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import"./constants-
|
|
1
|
+
import"./constants-Dvx0Ir4Z.mjs";import{p as e}from"./dist-DRC09WNZ.mjs";import{W as t}from"./dist-6JXIwkTW.mjs";import{join as n,relative as r}from"node:path";import{existsSync as i,lstatSync as a,readdirSync as o,realpathSync as s,statSync as c}from"node:fs";function l(e){let{projectDir:i,contentDir:l,include:u,exclude:d,sampleCap:f=5}=e,p=[],m=[];try{a(l)}catch(e){return{totalCount:0,sample:[],contentDir:l,include:u,exclude:d,warnings:[`cannot access content directory ${l}: ${e instanceof Error?e.message:String(e)}`]}}let h;try{h=t({projectDir:i,contentDir:l,includePatterns:u,excludePatterns:d})}catch(e){return{totalCount:0,sample:[],contentDir:l,include:u,exclude:d,warnings:[e instanceof Error?e.message:String(e)]}}function g(e){let t;try{t=o(e,{withFileTypes:!0})}catch(t){let n=t instanceof Error?t.message:String(t);p.push(`could not read directory ${r(l,e)||`.`}: ${n}`);return}for(let i of t){let t=n(e,i.name);if(i.isSymbolicLink()){let e;try{e=s(t)}catch(e){let n=e.code;n===`ENOENT`||n===`ELOOP`?p.push(`broken or cyclic symlink: ${r(l,t)}`):p.push(`cannot resolve symlink ${r(l,t)}: ${n??`unknown error`}`);continue}let n;try{n=c(e)}catch{continue}if(n.isDirectory()){let e=r(l,t);if(h.isDirExcluded(e))continue;g(t)}else if(n.isFile()){let e=r(l,t);if(h.isExcluded(e))continue;m.push(e)}}else if(i.isDirectory()){let e=r(l,t);if(h.isDirExcluded(e))continue;g(t)}else if(i.isFile()){let e=r(l,t);if(h.isExcluded(e))continue;m.push(e)}}}return g(l),{totalCount:m.length,sample:m.slice(0,f),contentDir:l,include:u,exclude:d,warnings:p}}function u(t,a){let o=[],s=r(a,t.contentDir),c=s===``?`./`:`./${s}`;o.push(`Content:`),o.push(` Found ${t.totalCount} markdown files in ${c}`);let l=t.include.join(`, `),u=t.exclude.length>0?t.exclude.join(`, `):`(none)`;if(o.push(` Scope: include=${l} exclude=${u}`),t.sample.length>0){let e=t.sample.join(`, `),n=t.totalCount>t.sample.length?`, …`:``;o.push(` Sample: ${e}${n}`)}if(t.warnings.length>0)for(let e of t.warnings)o.push(` Warning: ${e}`);return o.push(``),i(n(a,`.open-knowledge`,`config.yml`))?(o.push(` To adjust, edit ${e}/config.yml:`),o.push(` content:`),o.push(` include: ${JSON.stringify(t.include)}`),o.push(` exclude: ${JSON.stringify(t.exclude)}`)):(o.push(" Run `open-knowledge init` to scaffold config, then adjust:"),o.push(` ${e}/config.yml → content.include / content.exclude`)),o.push(``),o.push(` Re-check anytime: open-knowledge preview`),o.join(`
|
|
2
2
|
`)}export{l as n,u as t};
|
|
3
|
-
//# sourceMappingURL=preview-
|
|
3
|
+
//# sourceMappingURL=preview-CYJ8l4Py.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{n as e,t}from"./preview-CYJ8l4Py.mjs";export{t as formatPreviewBlock,e as previewContent};
|
package/dist/public/assets/{ActivityModeContent-QSE28ToP.js → ActivityModeContent-JeYMJ8N-.js}
RENAMED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./ActivityPanelDiffView-D-EUyEh6.js","./chunk-DECur_0Z.js","./compiler-runtime-Y11fyRVL.js","./ActivityPanelDiffView-legcy4jI.css"])))=>i.map(i=>d[i]);
|
|
2
|
-
import{r as e}from"./chunk-DECur_0Z.js";import{d as t}from"./propagation-api-Bugyj7xy.js";import{n,r,t as i}from"./compiler-runtime-Y11fyRVL.js";import{t as a,x as o}from"./button-BPXuMr5W.js";import{d as s,h as c,i as l,m as u,p as d,r as f,t as p}from"./agent-presence-CN4nWhyr.js";import{ct as m,n as h,r as g,yt as _}from"./DocumentContext-C7zXwLGg.js";import{a as v,c as y,i as b,o as x,s as S,t as C,x as w}from"./dialog-CtSN0d2b.js";import{i as T,n as E,t as D}from"./tooltip-nCu_fYrg.js";import{i as O}from"./PageListContext-DNRRECTw.js";var k=o(`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`}]]),A=i(),j=e(n(),1),M=500,ee=64;async function te(e){let t=`/api/agent-activity?agentId=${encodeURIComponent(e)}`,n=await fetch(t);if(!n.ok)throw Error(`agent-activity fetch failed: HTTP ${n.status}`);let r=await n.json();if(!r.ok)throw Error(r.error??`agent-activity fetch not ok`);return{sessionAlive:r.sessionAlive??!1,agent:r.agent??null,files:r.files??[]}}async function N(e,t,n){let r=`/api/agent-burst-diff?agentId=${encodeURIComponent(e)}&docName=${encodeURIComponent(t)}&stackIndex=${n}`,i=await fetch(r);if(!i.ok)throw Error(`agent-burst-diff fetch failed: HTTP ${i.status}`);let a=await i.json();if(!a.ok)throw Error(a.error??`agent-burst-diff fetch not ok`);return a.diff??``}function ne(e){let t=(0,A.c)(23),{systemProvider:n}=h(),[r,i]=(0,j.useState)(null),[a,o]=(0,j.useState)(`idle`),[s,c]=(0,j.useState)(null),u;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(u=new l(ee),t[0]=u):u=t[0];let d=(0,j.useRef)(u),f=(0,j.useRef)(0),p;t[1]===n?p=t[2]:(p=e=>{let t=f.current+=1;o(`loading`),c(null),te(e).then(r=>{if(f.current!==t)return;let a=ie(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 m=p,g;t[3]!==e||t[4]!==m?(g=()=>{if(!e){f.current+=1,i(null),o(`idle`),c(null),d.current.clear();return}d.current.clear(),m(e);let t=null,n=O(n=>{n.includes(`session-activity`)&&(t&&clearTimeout(t),t=setTimeout(()=>{t=null,m(e)},M))});return()=>{t&&clearTimeout(t),n()}},t[3]=e,t[4]=m,t[5]=g):g=t[5];let _;t[6]===e?_=t[7]:(_=[e],t[6]=e,t[7]=_),(0,j.useEffect)(g,_);let v,y;t[8]!==e||t[9]!==n?(v=()=>{if(!e||!n)return;let t=()=>{if(!n.awareness)return;let t=ie(n,e);i(e=>!e||re(e.writingDocs,t)?e:{...e,writingDocs:t})},r=n.awareness;if(!r||typeof r.on!=`function`){t();return}r.on(`update`,t),t();let a=setInterval(t,1e3);return()=>{clearInterval(a),typeof r.off==`function`&&r.off(`update`,t)}},y=[e,n],t[8]=e,t[9]=n,t[10]=v,t[11]=y):(v=t[10],y=t[11]),(0,j.useEffect)(v,y);let b;t[12]===e?b=t[13]:(b=async(t,n)=>{if(!e)return``;let r=`${t}\0${n}`,i=d.current.get(r);if(i!==void 0)return i;let a=await N(e,t,n);return d.current.set(r,a),a},t[12]=e,t[13]=b);let x=b,S;t[14]!==e||t[15]!==m?(S=()=>{e&&m(e)},t[14]=e,t[15]=m,t[16]=S):S=t[16];let C=S,w;return t[17]!==r||t[18]!==s||t[19]!==x||t[20]!==C||t[21]!==a?(w={data:r,status:a,error:s,reload:C,fetchBurstDiff:x},t[17]=r,t[18]=s,t[19]=x,t[20]=C,t[21]=a,t[22]=w):w=t[22],w}function re(e,t){if(e.size!==t.size)return!1;for(let n of e)if(!t.has(n))return!1;return!0}function ie(e,t){let n=new Set;if(!e)return n;let r=e.awareness;if(!p(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 P=r(),ae=(0,j.lazy)(async()=>({default:(await t(()=>import(`./ActivityPanelDiffView-D-EUyEh6.js`),__vite__mapDeps([0,1,2,3]),import.meta.url)).ActivityPanelDiffView}));function oe(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 se(e){let t=(0,A.c)(38),{burst:n,docName:r,fetchBurstDiff:i}=e,[a,o]=(0,j.useState)(!1),[s,c]=(0,j.useState)(null),[l,f]=(0,j.useState)(null),[p,m]=(0,j.useState)(!1),[h,g]=(0,j.useState)(ce),_,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,j.useEffect)(_,v);let y;t[2]!==n.stackIndex||t[3]!==s||t[4]!==r||t[5]!==a||t[6]!==i||t[7]!==p?(y=()=>{let e=!a;o(e),e&&s===null&&!p&&(m(!0),f(null),i(r,n.stackIndex).then(e=>{c(e),m(!1)}).catch(e=>{f(e instanceof Error?e.message:String(e)),m(!1)}))},t[2]=n.stackIndex,t[3]=s,t[4]=r,t[5]=a,t[6]=i,t[7]=p,t[8]=y):y=t[8];let b=y,x=`${a?`Collapse`:`Expand`} burst ${n.stackIndex+1} diff`,S;t[9]===a?S=t[10]:(S=a?(0,P.jsx)(u,{className:`size-3 shrink-0`,"aria-hidden":`true`}):(0,P.jsx)(d,{className:`size-3 shrink-0`,"aria-hidden":`true`}),t[9]=a,t[10]=S);let C;t[11]!==n.ts||t[12]!==h?(C=oe(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,P.jsx)(`span`,{className:`font-mono`,children:C}),t[14]=C,t[15]=w);let T;t[16]===n.additions?T=t[17]:(T=(0,P.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,P.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,P.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]!==a||t[24]!==D||t[25]!==x||t[26]!==S||t[27]!==w||t[28]!==b?(O=(0,P.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":a,"aria-label":x,children:[S,w,D]}),t[23]=a,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]!==s||t[31]!==a||t[32]!==l||t[33]!==p?(k=a?(0,P.jsx)(`div`,{className:`bg-muted/20`,children:p?(0,P.jsx)(`div`,{className:`px-4 py-2 text-xs text-muted-foreground italic`,children:`Loading diff…`}):l?(0,P.jsxs)(`div`,{className:`px-4 py-2 text-xs text-destructive`,children:[`Failed: `,l]}):s===null?(0,P.jsx)(`div`,{className:`px-4 py-2 text-xs text-muted-foreground italic`,children:`No diff.`}):(0,P.jsx)(j.Suspense,{fallback:(0,P.jsx)(`div`,{className:`px-4 py-2 text-xs text-muted-foreground italic`,children:`Loading diff…`}),children:(0,P.jsx)(ae,{diff:s})})}):null,t[30]=s,t[31]=a,t[32]=l,t[33]=p,t[34]=k):k=t[34];let M;return t[35]!==O||t[36]!==k?(M=(0,P.jsxs)(`div`,{className:`border-t border-border/50`,children:[O,k]}),t[35]=O,t[36]=k,t[37]=M):M=t[37],M}function ce(){return Date.now()}function le(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 ue(e){let t=(0,A.c)(93),{file:n,sessionAlive:r,isWriting:i,onNavigate:o,onUndoLast:c,onUndoAll:l,fetchBurstDiff:f}=e,[p,m]=(0,j.useState)(!1),[h,g]=(0,j.useState)(!1),[_,w]=(0,j.useState)(!1),[O,M]=(0,j.useState)(fe),ee,te;if(t[0]===Symbol.for(`react.memo_cache_sentinel`)?(ee=()=>{let e=setInterval(()=>M(Date.now()),3e4);return()=>clearInterval(e)},te=[],t[0]=ee,t[1]=te):(ee=t[0],te=t[1]),(0,j.useEffect)(ee,te),n.bursts.length===0)return null;let N=!r||n.bursts.length===0||_,ne=r?n.bursts.length===0?`Nothing to undo on this file`:null:`Session ended — undo unavailable`,re;t[2]!==N||t[3]!==n.docName||t[4]!==c?(re=e=>{e.stopPropagation(),!N&&(w(!0),Promise.resolve(c(n.docName)).finally(()=>w(!1)))},t[2]=N,t[3]=n.docName,t[4]=c,t[5]=re):re=t[5];let ie=re,ae;t[6]===N?ae=t[7]:(ae=e=>{e.stopPropagation(),!N&&g(!0)},t[6]=N,t[7]=ae);let oe=ae,ce;t[8]!==N||t[9]!==n.docName||t[10]!==l?(ce=()=>{g(!1),!N&&(w(!0),Promise.resolve(l(n.docName)).finally(()=>w(!1)))},t[8]=N,t[9]=n.docName,t[10]=l,t[11]=ce):ce=t[11];let ue=ce,F;t[12]===Symbol.for(`react.memo_cache_sentinel`)?(F=()=>m(de),t[12]=F):F=t[12];let pe=p?`Collapse ${n.docName}`:`Expand ${n.docName}`,I;t[13]===p?I=t[14]:(I=p?(0,P.jsx)(u,{className:`size-4`,"aria-hidden":`true`}):(0,P.jsx)(d,{className:`size-4`,"aria-hidden":`true`}),t[13]=p,t[14]=I);let L;t[15]!==p||t[16]!==pe||t[17]!==I?(L=(0,P.jsx)(`button`,{type:`button`,onClick:F,className:`flex size-5 shrink-0 items-center justify-center rounded hover:bg-muted`,"aria-expanded":p,"aria-label":pe,"data-testid":`activity-panel-file-row-carrot`,children:I}),t[15]=p,t[16]=pe,t[17]=I,t[18]=L):L=t[18];let R;t[19]!==n.docName||t[20]!==o?(R=()=>o(n.docName),t[19]=n.docName,t[20]=o,t[21]=R):R=t[21];let me=`Navigate to ${n.docName}`,z;t[22]!==n.docName||t[23]!==R||t[24]!==me?(z=(0,P.jsx)(`button`,{type:`button`,onClick:R,className:`min-w-0 flex-1 truncate text-left text-foreground hover:underline focus-visible:outline-ring`,"aria-label":me,"data-testid":`activity-panel-file-row-filename`,title:n.docName,children:n.docName}),t[22]=n.docName,t[23]=R,t[24]=me,t[25]=z):z=t[25];let he=`Undo last edit on ${n.docName}`,ge;t[26]===Symbol.for(`react.memo_cache_sentinel`)?(ge=(0,P.jsx)(s,{className:`size-3.5`,"aria-hidden":`true`}),t[26]=ge):ge=t[26];let B;t[27]!==N||t[28]!==ie||t[29]!==he?(B=(0,P.jsx)(T,{asChild:!0,children:(0,P.jsx)(a,{type:`button`,variant:`ghost`,size:`icon`,className:`size-6 shrink-0`,onClick:ie,disabled:N,"aria-label":he,"data-testid":`activity-panel-undo-last`,children:ge})}),t[27]=N,t[28]=ie,t[29]=he,t[30]=B):B=t[30];let _e=ne??`Undo last edit`,V;t[31]===_e?V=t[32]:(V=(0,P.jsx)(E,{side:`bottom`,children:_e}),t[31]=_e,t[32]=V);let H;t[33]!==B||t[34]!==V?(H=(0,P.jsxs)(D,{children:[B,V]}),t[33]=B,t[34]=V,t[35]=H):H=t[35];let ve=`Undo all edits on ${n.docName}`,ye;t[36]===Symbol.for(`react.memo_cache_sentinel`)?(ye=(0,P.jsx)(k,{className:`size-3.5`,"aria-hidden":`true`}),t[36]=ye):ye=t[36];let be;t[37]!==N||t[38]!==oe||t[39]!==ve?(be=(0,P.jsx)(T,{asChild:!0,children:(0,P.jsx)(a,{type:`button`,variant:`ghost`,size:`icon`,className:`size-6 shrink-0`,onClick:oe,disabled:N,"aria-label":ve,"data-testid":`activity-panel-undo-all`,children:ye})}),t[37]=N,t[38]=oe,t[39]=ve,t[40]=be):be=t[40];let xe=ne??`Undo all edits`,U;t[41]===xe?U=t[42]:(U=(0,P.jsx)(E,{side:`bottom`,children:xe}),t[41]=xe,t[42]=U);let W;t[43]!==be||t[44]!==U?(W=(0,P.jsxs)(D,{children:[be,U]}),t[43]=be,t[44]=U,t[45]=W):W=t[45];let G;t[46]===n.additionsTotal?G=t[47]:(G=(0,P.jsxs)(`span`,{className:`text-green-600 dark:text-green-400`,children:[`+`,n.additionsTotal]}),t[46]=n.additionsTotal,t[47]=G);let K;t[48]===n.deletionsTotal?K=t[49]:(K=(0,P.jsxs)(`span`,{className:`text-red-600 dark:text-red-400`,children:[`−`,n.deletionsTotal]}),t[48]=n.deletionsTotal,t[49]=K);let q;t[50]!==G||t[51]!==K?(q=(0,P.jsxs)(`span`,{className:`shrink-0 font-mono text-xs`,children:[G,` `,K]}),t[50]=G,t[51]=K,t[52]=q):q=t[52];let J;t[53]!==n.lastTs||t[54]!==O?(J=le(n.lastTs,O),t[53]=n.lastTs,t[54]=O,t[55]=J):J=t[55];let Y;t[56]===J?Y=t[57]:(Y=(0,P.jsx)(`span`,{className:`shrink-0 font-mono text-[11px] text-muted-foreground`,children:J}),t[56]=J,t[57]=Y);let X;t[58]===i?X=t[59]:(X=i?(0,P.jsx)(`span`,{className:`shrink-0 text-[11px] text-primary animate-pulse`,role:`status`,children:`writing…`}):null,t[58]=i,t[59]=X);let Z;t[60]!==z||t[61]!==H||t[62]!==W||t[63]!==q||t[64]!==Y||t[65]!==X||t[66]!==L?(Z=(0,P.jsxs)(`div`,{className:`flex items-center gap-2 px-3 py-2 text-sm`,children:[L,z,H,W,q,Y,X]}),t[60]=z,t[61]=H,t[62]=W,t[63]=q,t[64]=Y,t[65]=X,t[66]=L,t[67]=Z):Z=t[67];let Q;t[68]!==p||t[69]!==f||t[70]!==n.bursts||t[71]!==n.docName?(Q=p?(0,P.jsx)(`div`,{children:n.bursts.map(e=>(0,P.jsx)(se,{burst:e,docName:n.docName,fetchBurstDiff:f},`${n.docName}:${e.stackIndex}`))}):null,t[68]=p,t[69]=f,t[70]=n.bursts,t[71]=n.docName,t[72]=Q):Q=t[72];let Se;t[73]===Symbol.for(`react.memo_cache_sentinel`)?(Se=(0,P.jsx)(y,{children:`Undo all edits on this file?`}),t[73]=Se):Se=t[73];let Ce;t[74]===n.docName?Ce=t[75]:(Ce=(0,P.jsx)(`span`,{className:`font-mono text-foreground`,children:n.docName}),t[74]=n.docName,t[75]=Ce);let we=n.bursts.length===1?``:`s`,Te;t[76]!==n.bursts.length||t[77]!==Ce||t[78]!==we?(Te=(0,P.jsxs)(S,{children:[Se,(0,P.jsxs)(v,{children:[`This will revert every change this agent has made to`,` `,Ce,` in their current session (`,n.bursts.length,` burst`,we,`). Other files and other writers are not affected.`]})]}),t[76]=n.bursts.length,t[77]=Ce,t[78]=we,t[79]=Te):Te=t[79];let Ee;t[80]===Symbol.for(`react.memo_cache_sentinel`)?(Ee=(0,P.jsx)(a,{type:`button`,variant:`outline`,onClick:()=>g(!1),"data-testid":`activity-panel-undo-all-cancel`,children:`Cancel`}),t[80]=Ee):Ee=t[80];let De;t[81]===ue?De=t[82]:(De=(0,P.jsxs)(x,{children:[Ee,(0,P.jsx)(a,{type:`button`,variant:`destructive`,onClick:ue,"data-testid":`activity-panel-undo-all-confirm`,children:`Undo all`})]}),t[81]=ue,t[82]=De);let Oe;t[83]!==Te||t[84]!==De?(Oe=(0,P.jsxs)(b,{className:`sm:max-w-md`,children:[Te,De]}),t[83]=Te,t[84]=De,t[85]=Oe):Oe=t[85];let $;t[86]!==h||t[87]!==Oe?($=(0,P.jsx)(C,{open:h,onOpenChange:g,children:Oe}),t[86]=h,t[87]=Oe,t[88]=$):$=t[88];let ke;return t[89]!==Z||t[90]!==Q||t[91]!==$?(ke=(0,P.jsxs)(`div`,{className:`border-b border-border`,"data-testid":`activity-panel-file-row`,children:[Z,Q,$]}),t[89]=Z,t[90]=Q,t[91]=$,t[92]=ke):ke=t[92],ke}function de(e){return!e}function fe(){return Date.now()}async function F(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 pe(e){return`#/${e.split(`/`).map(e=>encodeURIComponent(e)).join(`/`)}`}function I(e){typeof window>`u`||(window.location.hash=pe(e))}function L(){let e=(0,A.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,P.jsxs)(`div`,{className:`flex h-full items-center justify-center p-6 text-muted-foreground`,role:`status`,"aria-busy":`true`,children:[(0,P.jsx)(m,{className:`mr-2 size-4 animate-spin`,"aria-hidden":`true`}),(0,P.jsx)(`span`,{className:`text-sm`,children:`Loading agent activity…`})]}),e[0]=t):t=e[0],t}function R(e){let t=(0,A.c)(9),{error:n,onRetry:r}=e,i;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(i=(0,P.jsx)(_,{className:`size-6 text-destructive`,"aria-hidden":`true`}),t[0]=i):i=t[0];let o;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(o=(0,P.jsx)(`p`,{className:`text-sm font-medium`,children:`Failed to load activity`}),t[1]=o):o=t[1];let s;t[2]===n?s=t[3]:(s=(0,P.jsxs)(`div`,{className:`space-y-1`,children:[o,(0,P.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:n})]}),t[2]=n,t[3]=s);let c;t[4]===r?c=t[5]:(c=(0,P.jsx)(a,{type:`button`,variant:`outline`,size:`sm`,onClick:r,children:`Retry`}),t[4]=r,t[5]=c);let l;return t[6]!==s||t[7]!==c?(l=(0,P.jsxs)(`div`,{className:`flex flex-col items-center gap-3 p-6 text-center`,role:`alert`,"data-testid":`activity-panel-error`,children:[i,s,c]}),t[6]=s,t[7]=c,t[8]=l):l=t[8],l}function me(){let e=(0,A.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,P.jsx)(`div`,{className:`flex h-full items-center justify-center p-6 text-muted-foreground`,"data-testid":`activity-panel-empty`,children:(0,P.jsx)(`p`,{className:`text-sm italic`,children:`No edits yet.`})}),e[0]=t):t=e[0],t}function z(e){let t=(0,A.c)(8),{onExit:n}=e,r;t[0]===n?r=t[1]:(r=(0,P.jsx)(he,{onClick:n}),t[0]=n,t[1]=r);let i;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(i=(0,P.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,P.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,P.jsx)(`div`,{className:`flex flex-1 items-center justify-center p-6 text-muted-foreground`,children:(0,P.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,P.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 he(e){let t=(0,A.c)(6),{onClick:n}=e,r;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(r=(0,P.jsx)(c,{}),t[0]=r):r=t[0];let i;t[1]===n?i=t[2]:(i=(0,P.jsx)(T,{asChild:!0,children:(0,P.jsx)(a,{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 o;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(o=(0,P.jsx)(E,{side:`bottom`,children:`Back to document view`}),t[3]=o):o=t[3];let s;return t[4]===i?s=t[5]:(s=(0,P.jsxs)(D,{children:[i,o]}),t[4]=i,t[5]=s),s}function ge(e){let t=(0,A.c)(9),{lastTs:n}=e,[r]=(0,j.useState)(B),i;t[0]!==n||t[1]!==r?(i=n?_e(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,P.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,P.jsxs)(`span`,{children:[` · `,a]}):null,t[4]=a,t[5]=s);let c;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(c=(0,P.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,P.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 B(){return Date.now()}function _e(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,A.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,P.jsx)(f,{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,P.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 H(e){let t=(0,A.c)(20),{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,P.jsx)(he,{onClick:s}),t[0]=s,t[1]=f);let p;t[2]===n?p=t[3]:(p=n?.agent?(0,P.jsxs)(P.Fragment,{children:[(0,P.jsx)(V,{agent:n.agent}),(0,P.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,P.jsx)(`h2`,{className:`truncate text-sm font-medium`,children:n.agent.displayName}),(0,P.jsxs)(`p`,{className:`truncate text-xs text-muted-foreground`,children:[n.sessionAlive?`Active`:`Ended`,n.files.length>0?` · ${n.files.length} file${n.files.length===1?``:`s`}`:``]})]})]}):(0,P.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,P.jsx)(`h2`,{className:`truncate text-sm font-medium`,children:`Agent activity`})}),t[2]=n,t[3]=p);let m;t[4]!==f||t[5]!==p?(m=(0,P.jsxs)(`div`,{className:`flex flex-row items-center gap-2 border-b border-border px-3 py-2 shrink-0`,children:[f,p]}),t[4]=f,t[5]=p,t[6]=m):m=t[6];let h;t[7]!==n||t[8]!==i||t[9]!==o||t[10]!==d||t[11]!==c||t[12]!==u||t[13]!==l||t[14]!==a||t[15]!==r?(h=(0,P.jsx)(`div`,{className:`flex-1 overflow-y-auto`,"data-testid":`activity-panel-body`,children:r===`loading`&&n===null?(0,P.jsx)(L,{}):r===`error`&&i?(0,P.jsx)(R,{error:i,onRetry:a}):n===null?(0,P.jsx)(me,{}):(0,P.jsxs)(P.Fragment,{children:[n.sessionAlive?null:(0,P.jsx)(ge,{lastTs:d}),n.files.length===0?(0,P.jsx)(me,{}):n.files.map(e=>(0,P.jsx)(ue,{file:e,sessionAlive:n.sessionAlive,isWriting:n.writingDocs.has(e.docName),onNavigate:c,onUndoLast:l,onUndoAll:u,fetchBurstDiff:o},e.docName))]})}),t[7]=n,t[8]=i,t[9]=o,t[10]=d,t[11]=c,t[12]=u,t[13]=l,t[14]=a,t[15]=r,t[16]=h):h=t[16];let g;return t[17]!==m||t[18]!==h?(g=(0,P.jsxs)(`section`,{className:`flex h-full min-h-0 flex-col`,"data-testid":`activity-panel`,"aria-label":`Agent activity`,children:[m,h]}),t[17]=m,t[18]=h,t[19]=g):g=t[19],g}function ve(){let e=(0,A.c)(22),{docPanelAgentId:t,closeActivityPanel:n}=h(),{openDocumentTransition:r}=g(),{data:i,status:a,error:o,reload:s,fetchBurstDiff:c}=ne(t);if(t===null){let t;return e[0]===n?t=e[1]:(t=(0,P.jsx)(z,{onExit:n}),e[0]=n,e[1]=t),t}let l;e[2]===r?l=e[3]:(l=e=>{r(e),I(e)},e[2]=r,e[3]=l);let u=l,d;e[4]!==i||e[5]!==t||e[6]!==s?(d=async e=>{try{await F({connectionId:t,docName:e,scope:`last`,agentName:i?.agent?.displayName}),s()}catch(e){let t=e,n=t instanceof Error?t.message:String(t);w.error(`Undo failed: ${n}`),s()}},e[4]=i,e[5]=t,e[6]=s,e[7]=d):d=e[7];let f=d,p;e[8]!==i||e[9]!==t||e[10]!==s?(p=async e=>{try{await F({connectionId:t,docName:e,scope:`file`,agentName:i?.agent?.displayName}),w.success(`Undone all edits on ${e}`),s()}catch(e){let t=e,n=t instanceof Error?t.message:String(t);w.error(`Undo all failed: ${n}`),s()}},e[8]=i,e[9]=t,e[10]=s,e[11]=p):p=e[11];let m=p,_;return e[12]!==n||e[13]!==i||e[14]!==o||e[15]!==c||e[16]!==u||e[17]!==m||e[18]!==f||e[19]!==s||e[20]!==a?(_=(0,P.jsx)(H,{data:i,status:a,error:o,reload:s,fetchBurstDiff:c,onExit:n,onNavigate:u,onUndoLast:f,onUndoAll:m}),e[12]=n,e[13]=i,e[14]=o,e[15]=c,e[16]=u,e[17]=m,e[18]=f,e[19]=s,e[20]=a,e[21]=_):_=e[21],_}export{ve as ActivityModeContent};
|
|
2
|
+
import{r as e}from"./chunk-DECur_0Z.js";import{d as t}from"./propagation-api-Bugyj7xy.js";import{n,r,t as i}from"./compiler-runtime-Y11fyRVL.js";import{t as a,x as o}from"./button-BPXuMr5W.js";import{d as s,h as c,i as l,m as u,p as d,r as f,t as p}from"./agent-presence-CN4nWhyr.js";import{bt as m,lt as h,n as g,r as _}from"./DocumentContext-D9TYylem.js";import{a as v,c as y,i as b,o as x,s as S,t as C,x as w}from"./dialog-CtSN0d2b.js";import{i as T,n as E,t as D}from"./tooltip-nCu_fYrg.js";import{i as O}from"./PageListContext-DNRRECTw.js";var k=o(`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`}]]),A=i(),j=e(n(),1),M=500,ee=64;async function te(e){let t=`/api/agent-activity?agentId=${encodeURIComponent(e)}`,n=await fetch(t);if(!n.ok)throw Error(`agent-activity fetch failed: HTTP ${n.status}`);let r=await n.json();if(!r.ok)throw Error(r.error??`agent-activity fetch not ok`);return{sessionAlive:r.sessionAlive??!1,agent:r.agent??null,files:r.files??[]}}async function N(e,t,n){let r=`/api/agent-burst-diff?agentId=${encodeURIComponent(e)}&docName=${encodeURIComponent(t)}&stackIndex=${n}`,i=await fetch(r);if(!i.ok)throw Error(`agent-burst-diff fetch failed: HTTP ${i.status}`);let a=await i.json();if(!a.ok)throw Error(a.error??`agent-burst-diff fetch not ok`);return a.diff??``}function ne(e){let t=(0,A.c)(23),{systemProvider:n}=g(),[r,i]=(0,j.useState)(null),[a,o]=(0,j.useState)(`idle`),[s,c]=(0,j.useState)(null),u;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(u=new l(ee),t[0]=u):u=t[0];let d=(0,j.useRef)(u),f=(0,j.useRef)(0),p;t[1]===n?p=t[2]:(p=e=>{let t=f.current+=1;o(`loading`),c(null),te(e).then(r=>{if(f.current!==t)return;let a=ie(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 m=p,h;t[3]!==e||t[4]!==m?(h=()=>{if(!e){f.current+=1,i(null),o(`idle`),c(null),d.current.clear();return}d.current.clear(),m(e);let t=null,n=O(n=>{n.includes(`session-activity`)&&(t&&clearTimeout(t),t=setTimeout(()=>{t=null,m(e)},M))});return()=>{t&&clearTimeout(t),n()}},t[3]=e,t[4]=m,t[5]=h):h=t[5];let _;t[6]===e?_=t[7]:(_=[e],t[6]=e,t[7]=_),(0,j.useEffect)(h,_);let v,y;t[8]!==e||t[9]!==n?(v=()=>{if(!e||!n)return;let t=()=>{if(!n.awareness)return;let t=ie(n,e);i(e=>!e||re(e.writingDocs,t)?e:{...e,writingDocs:t})},r=n.awareness;if(!r||typeof r.on!=`function`){t();return}r.on(`update`,t),t();let a=setInterval(t,1e3);return()=>{clearInterval(a),typeof r.off==`function`&&r.off(`update`,t)}},y=[e,n],t[8]=e,t[9]=n,t[10]=v,t[11]=y):(v=t[10],y=t[11]),(0,j.useEffect)(v,y);let b;t[12]===e?b=t[13]:(b=async(t,n)=>{if(!e)return``;let r=`${t}\0${n}`,i=d.current.get(r);if(i!==void 0)return i;let a=await N(e,t,n);return d.current.set(r,a),a},t[12]=e,t[13]=b);let x=b,S;t[14]!==e||t[15]!==m?(S=()=>{e&&m(e)},t[14]=e,t[15]=m,t[16]=S):S=t[16];let C=S,w;return t[17]!==r||t[18]!==s||t[19]!==x||t[20]!==C||t[21]!==a?(w={data:r,status:a,error:s,reload:C,fetchBurstDiff:x},t[17]=r,t[18]=s,t[19]=x,t[20]=C,t[21]=a,t[22]=w):w=t[22],w}function re(e,t){if(e.size!==t.size)return!1;for(let n of e)if(!t.has(n))return!1;return!0}function ie(e,t){let n=new Set;if(!e)return n;let r=e.awareness;if(!p(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 P=r(),ae=(0,j.lazy)(async()=>({default:(await t(()=>import(`./ActivityPanelDiffView-D-EUyEh6.js`),__vite__mapDeps([0,1,2,3]),import.meta.url)).ActivityPanelDiffView}));function oe(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 se(e){let t=(0,A.c)(38),{burst:n,docName:r,fetchBurstDiff:i}=e,[a,o]=(0,j.useState)(!1),[s,c]=(0,j.useState)(null),[l,f]=(0,j.useState)(null),[p,m]=(0,j.useState)(!1),[h,g]=(0,j.useState)(ce),_,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,j.useEffect)(_,v);let y;t[2]!==n.stackIndex||t[3]!==s||t[4]!==r||t[5]!==a||t[6]!==i||t[7]!==p?(y=()=>{let e=!a;o(e),e&&s===null&&!p&&(m(!0),f(null),i(r,n.stackIndex).then(e=>{c(e),m(!1)}).catch(e=>{f(e instanceof Error?e.message:String(e)),m(!1)}))},t[2]=n.stackIndex,t[3]=s,t[4]=r,t[5]=a,t[6]=i,t[7]=p,t[8]=y):y=t[8];let b=y,x=`${a?`Collapse`:`Expand`} burst ${n.stackIndex+1} diff`,S;t[9]===a?S=t[10]:(S=a?(0,P.jsx)(u,{className:`size-3 shrink-0`,"aria-hidden":`true`}):(0,P.jsx)(d,{className:`size-3 shrink-0`,"aria-hidden":`true`}),t[9]=a,t[10]=S);let C;t[11]!==n.ts||t[12]!==h?(C=oe(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,P.jsx)(`span`,{className:`font-mono`,children:C}),t[14]=C,t[15]=w);let T;t[16]===n.additions?T=t[17]:(T=(0,P.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,P.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,P.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]!==a||t[24]!==D||t[25]!==x||t[26]!==S||t[27]!==w||t[28]!==b?(O=(0,P.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":a,"aria-label":x,children:[S,w,D]}),t[23]=a,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]!==s||t[31]!==a||t[32]!==l||t[33]!==p?(k=a?(0,P.jsx)(`div`,{className:`bg-muted/20`,children:p?(0,P.jsx)(`div`,{className:`px-4 py-2 text-xs text-muted-foreground italic`,children:`Loading diff…`}):l?(0,P.jsxs)(`div`,{className:`px-4 py-2 text-xs text-destructive`,children:[`Failed: `,l]}):s===null?(0,P.jsx)(`div`,{className:`px-4 py-2 text-xs text-muted-foreground italic`,children:`No diff.`}):(0,P.jsx)(j.Suspense,{fallback:(0,P.jsx)(`div`,{className:`px-4 py-2 text-xs text-muted-foreground italic`,children:`Loading diff…`}),children:(0,P.jsx)(ae,{diff:s})})}):null,t[30]=s,t[31]=a,t[32]=l,t[33]=p,t[34]=k):k=t[34];let M;return t[35]!==O||t[36]!==k?(M=(0,P.jsxs)(`div`,{className:`border-t border-border/50`,children:[O,k]}),t[35]=O,t[36]=k,t[37]=M):M=t[37],M}function ce(){return Date.now()}function le(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 ue(e){let t=(0,A.c)(93),{file:n,sessionAlive:r,isWriting:i,onNavigate:o,onUndoLast:c,onUndoAll:l,fetchBurstDiff:f}=e,[p,m]=(0,j.useState)(!1),[h,g]=(0,j.useState)(!1),[_,w]=(0,j.useState)(!1),[O,M]=(0,j.useState)(fe),ee,te;if(t[0]===Symbol.for(`react.memo_cache_sentinel`)?(ee=()=>{let e=setInterval(()=>M(Date.now()),3e4);return()=>clearInterval(e)},te=[],t[0]=ee,t[1]=te):(ee=t[0],te=t[1]),(0,j.useEffect)(ee,te),n.bursts.length===0)return null;let N=!r||n.bursts.length===0||_,ne=r?n.bursts.length===0?`Nothing to undo on this file`:null:`Session ended — undo unavailable`,re;t[2]!==N||t[3]!==n.docName||t[4]!==c?(re=e=>{e.stopPropagation(),!N&&(w(!0),Promise.resolve(c(n.docName)).finally(()=>w(!1)))},t[2]=N,t[3]=n.docName,t[4]=c,t[5]=re):re=t[5];let ie=re,ae;t[6]===N?ae=t[7]:(ae=e=>{e.stopPropagation(),!N&&g(!0)},t[6]=N,t[7]=ae);let oe=ae,ce;t[8]!==N||t[9]!==n.docName||t[10]!==l?(ce=()=>{g(!1),!N&&(w(!0),Promise.resolve(l(n.docName)).finally(()=>w(!1)))},t[8]=N,t[9]=n.docName,t[10]=l,t[11]=ce):ce=t[11];let ue=ce,F;t[12]===Symbol.for(`react.memo_cache_sentinel`)?(F=()=>m(de),t[12]=F):F=t[12];let pe=p?`Collapse ${n.docName}`:`Expand ${n.docName}`,I;t[13]===p?I=t[14]:(I=p?(0,P.jsx)(u,{className:`size-4`,"aria-hidden":`true`}):(0,P.jsx)(d,{className:`size-4`,"aria-hidden":`true`}),t[13]=p,t[14]=I);let L;t[15]!==p||t[16]!==pe||t[17]!==I?(L=(0,P.jsx)(`button`,{type:`button`,onClick:F,className:`flex size-5 shrink-0 items-center justify-center rounded hover:bg-muted`,"aria-expanded":p,"aria-label":pe,"data-testid":`activity-panel-file-row-carrot`,children:I}),t[15]=p,t[16]=pe,t[17]=I,t[18]=L):L=t[18];let R;t[19]!==n.docName||t[20]!==o?(R=()=>o(n.docName),t[19]=n.docName,t[20]=o,t[21]=R):R=t[21];let me=`Navigate to ${n.docName}`,z;t[22]!==n.docName||t[23]!==R||t[24]!==me?(z=(0,P.jsx)(`button`,{type:`button`,onClick:R,className:`min-w-0 flex-1 truncate text-left text-foreground hover:underline focus-visible:outline-ring`,"aria-label":me,"data-testid":`activity-panel-file-row-filename`,title:n.docName,children:n.docName}),t[22]=n.docName,t[23]=R,t[24]=me,t[25]=z):z=t[25];let he=`Undo last edit on ${n.docName}`,ge;t[26]===Symbol.for(`react.memo_cache_sentinel`)?(ge=(0,P.jsx)(s,{className:`size-3.5`,"aria-hidden":`true`}),t[26]=ge):ge=t[26];let B;t[27]!==N||t[28]!==ie||t[29]!==he?(B=(0,P.jsx)(T,{asChild:!0,children:(0,P.jsx)(a,{type:`button`,variant:`ghost`,size:`icon`,className:`size-6 shrink-0`,onClick:ie,disabled:N,"aria-label":he,"data-testid":`activity-panel-undo-last`,children:ge})}),t[27]=N,t[28]=ie,t[29]=he,t[30]=B):B=t[30];let _e=ne??`Undo last edit`,V;t[31]===_e?V=t[32]:(V=(0,P.jsx)(E,{side:`bottom`,children:_e}),t[31]=_e,t[32]=V);let H;t[33]!==B||t[34]!==V?(H=(0,P.jsxs)(D,{children:[B,V]}),t[33]=B,t[34]=V,t[35]=H):H=t[35];let ve=`Undo all edits on ${n.docName}`,ye;t[36]===Symbol.for(`react.memo_cache_sentinel`)?(ye=(0,P.jsx)(k,{className:`size-3.5`,"aria-hidden":`true`}),t[36]=ye):ye=t[36];let be;t[37]!==N||t[38]!==oe||t[39]!==ve?(be=(0,P.jsx)(T,{asChild:!0,children:(0,P.jsx)(a,{type:`button`,variant:`ghost`,size:`icon`,className:`size-6 shrink-0`,onClick:oe,disabled:N,"aria-label":ve,"data-testid":`activity-panel-undo-all`,children:ye})}),t[37]=N,t[38]=oe,t[39]=ve,t[40]=be):be=t[40];let xe=ne??`Undo all edits`,U;t[41]===xe?U=t[42]:(U=(0,P.jsx)(E,{side:`bottom`,children:xe}),t[41]=xe,t[42]=U);let W;t[43]!==be||t[44]!==U?(W=(0,P.jsxs)(D,{children:[be,U]}),t[43]=be,t[44]=U,t[45]=W):W=t[45];let G;t[46]===n.additionsTotal?G=t[47]:(G=(0,P.jsxs)(`span`,{className:`text-green-600 dark:text-green-400`,children:[`+`,n.additionsTotal]}),t[46]=n.additionsTotal,t[47]=G);let K;t[48]===n.deletionsTotal?K=t[49]:(K=(0,P.jsxs)(`span`,{className:`text-red-600 dark:text-red-400`,children:[`−`,n.deletionsTotal]}),t[48]=n.deletionsTotal,t[49]=K);let q;t[50]!==G||t[51]!==K?(q=(0,P.jsxs)(`span`,{className:`shrink-0 font-mono text-xs`,children:[G,` `,K]}),t[50]=G,t[51]=K,t[52]=q):q=t[52];let J;t[53]!==n.lastTs||t[54]!==O?(J=le(n.lastTs,O),t[53]=n.lastTs,t[54]=O,t[55]=J):J=t[55];let Y;t[56]===J?Y=t[57]:(Y=(0,P.jsx)(`span`,{className:`shrink-0 font-mono text-[11px] text-muted-foreground`,children:J}),t[56]=J,t[57]=Y);let X;t[58]===i?X=t[59]:(X=i?(0,P.jsx)(`span`,{className:`shrink-0 text-[11px] text-primary animate-pulse`,role:`status`,children:`writing…`}):null,t[58]=i,t[59]=X);let Z;t[60]!==z||t[61]!==H||t[62]!==W||t[63]!==q||t[64]!==Y||t[65]!==X||t[66]!==L?(Z=(0,P.jsxs)(`div`,{className:`flex items-center gap-2 px-3 py-2 text-sm`,children:[L,z,H,W,q,Y,X]}),t[60]=z,t[61]=H,t[62]=W,t[63]=q,t[64]=Y,t[65]=X,t[66]=L,t[67]=Z):Z=t[67];let Q;t[68]!==p||t[69]!==f||t[70]!==n.bursts||t[71]!==n.docName?(Q=p?(0,P.jsx)(`div`,{children:n.bursts.map(e=>(0,P.jsx)(se,{burst:e,docName:n.docName,fetchBurstDiff:f},`${n.docName}:${e.stackIndex}`))}):null,t[68]=p,t[69]=f,t[70]=n.bursts,t[71]=n.docName,t[72]=Q):Q=t[72];let Se;t[73]===Symbol.for(`react.memo_cache_sentinel`)?(Se=(0,P.jsx)(y,{children:`Undo all edits on this file?`}),t[73]=Se):Se=t[73];let Ce;t[74]===n.docName?Ce=t[75]:(Ce=(0,P.jsx)(`span`,{className:`font-mono text-foreground`,children:n.docName}),t[74]=n.docName,t[75]=Ce);let we=n.bursts.length===1?``:`s`,Te;t[76]!==n.bursts.length||t[77]!==Ce||t[78]!==we?(Te=(0,P.jsxs)(S,{children:[Se,(0,P.jsxs)(v,{children:[`This will revert every change this agent has made to`,` `,Ce,` in their current session (`,n.bursts.length,` burst`,we,`). Other files and other writers are not affected.`]})]}),t[76]=n.bursts.length,t[77]=Ce,t[78]=we,t[79]=Te):Te=t[79];let Ee;t[80]===Symbol.for(`react.memo_cache_sentinel`)?(Ee=(0,P.jsx)(a,{type:`button`,variant:`outline`,onClick:()=>g(!1),"data-testid":`activity-panel-undo-all-cancel`,children:`Cancel`}),t[80]=Ee):Ee=t[80];let De;t[81]===ue?De=t[82]:(De=(0,P.jsxs)(x,{children:[Ee,(0,P.jsx)(a,{type:`button`,variant:`destructive`,onClick:ue,"data-testid":`activity-panel-undo-all-confirm`,children:`Undo all`})]}),t[81]=ue,t[82]=De);let Oe;t[83]!==Te||t[84]!==De?(Oe=(0,P.jsxs)(b,{className:`sm:max-w-md`,children:[Te,De]}),t[83]=Te,t[84]=De,t[85]=Oe):Oe=t[85];let $;t[86]!==h||t[87]!==Oe?($=(0,P.jsx)(C,{open:h,onOpenChange:g,children:Oe}),t[86]=h,t[87]=Oe,t[88]=$):$=t[88];let ke;return t[89]!==Z||t[90]!==Q||t[91]!==$?(ke=(0,P.jsxs)(`div`,{className:`border-b border-border`,"data-testid":`activity-panel-file-row`,children:[Z,Q,$]}),t[89]=Z,t[90]=Q,t[91]=$,t[92]=ke):ke=t[92],ke}function de(e){return!e}function fe(){return Date.now()}async function F(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 pe(e){return`#/${e.split(`/`).map(e=>encodeURIComponent(e)).join(`/`)}`}function I(e){typeof window>`u`||(window.location.hash=pe(e))}function L(){let e=(0,A.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,P.jsxs)(`div`,{className:`flex h-full items-center justify-center p-6 text-muted-foreground`,role:`status`,"aria-busy":`true`,children:[(0,P.jsx)(h,{className:`mr-2 size-4 animate-spin`,"aria-hidden":`true`}),(0,P.jsx)(`span`,{className:`text-sm`,children:`Loading agent activity…`})]}),e[0]=t):t=e[0],t}function R(e){let t=(0,A.c)(9),{error:n,onRetry:r}=e,i;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(i=(0,P.jsx)(m,{className:`size-6 text-destructive`,"aria-hidden":`true`}),t[0]=i):i=t[0];let o;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(o=(0,P.jsx)(`p`,{className:`text-sm font-medium`,children:`Failed to load activity`}),t[1]=o):o=t[1];let s;t[2]===n?s=t[3]:(s=(0,P.jsxs)(`div`,{className:`space-y-1`,children:[o,(0,P.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:n})]}),t[2]=n,t[3]=s);let c;t[4]===r?c=t[5]:(c=(0,P.jsx)(a,{type:`button`,variant:`outline`,size:`sm`,onClick:r,children:`Retry`}),t[4]=r,t[5]=c);let l;return t[6]!==s||t[7]!==c?(l=(0,P.jsxs)(`div`,{className:`flex flex-col items-center gap-3 p-6 text-center`,role:`alert`,"data-testid":`activity-panel-error`,children:[i,s,c]}),t[6]=s,t[7]=c,t[8]=l):l=t[8],l}function me(){let e=(0,A.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,P.jsx)(`div`,{className:`flex h-full items-center justify-center p-6 text-muted-foreground`,"data-testid":`activity-panel-empty`,children:(0,P.jsx)(`p`,{className:`text-sm italic`,children:`No edits yet.`})}),e[0]=t):t=e[0],t}function z(e){let t=(0,A.c)(8),{onExit:n}=e,r;t[0]===n?r=t[1]:(r=(0,P.jsx)(he,{onClick:n}),t[0]=n,t[1]=r);let i;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(i=(0,P.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,P.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,P.jsx)(`div`,{className:`flex flex-1 items-center justify-center p-6 text-muted-foreground`,children:(0,P.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,P.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 he(e){let t=(0,A.c)(6),{onClick:n}=e,r;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(r=(0,P.jsx)(c,{}),t[0]=r):r=t[0];let i;t[1]===n?i=t[2]:(i=(0,P.jsx)(T,{asChild:!0,children:(0,P.jsx)(a,{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 o;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(o=(0,P.jsx)(E,{side:`bottom`,children:`Back to document view`}),t[3]=o):o=t[3];let s;return t[4]===i?s=t[5]:(s=(0,P.jsxs)(D,{children:[i,o]}),t[4]=i,t[5]=s),s}function ge(e){let t=(0,A.c)(9),{lastTs:n}=e,[r]=(0,j.useState)(B),i;t[0]!==n||t[1]!==r?(i=n?_e(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,P.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,P.jsxs)(`span`,{children:[` · `,a]}):null,t[4]=a,t[5]=s);let c;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(c=(0,P.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,P.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 B(){return Date.now()}function _e(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,A.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,P.jsx)(f,{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,P.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 H(e){let t=(0,A.c)(20),{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,P.jsx)(he,{onClick:s}),t[0]=s,t[1]=f);let p;t[2]===n?p=t[3]:(p=n?.agent?(0,P.jsxs)(P.Fragment,{children:[(0,P.jsx)(V,{agent:n.agent}),(0,P.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,P.jsx)(`h2`,{className:`truncate text-sm font-medium`,children:n.agent.displayName}),(0,P.jsxs)(`p`,{className:`truncate text-xs text-muted-foreground`,children:[n.sessionAlive?`Active`:`Ended`,n.files.length>0?` · ${n.files.length} file${n.files.length===1?``:`s`}`:``]})]})]}):(0,P.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,P.jsx)(`h2`,{className:`truncate text-sm font-medium`,children:`Agent activity`})}),t[2]=n,t[3]=p);let m;t[4]!==f||t[5]!==p?(m=(0,P.jsxs)(`div`,{className:`flex flex-row items-center gap-2 border-b border-border px-3 py-2 shrink-0`,children:[f,p]}),t[4]=f,t[5]=p,t[6]=m):m=t[6];let h;t[7]!==n||t[8]!==i||t[9]!==o||t[10]!==d||t[11]!==c||t[12]!==u||t[13]!==l||t[14]!==a||t[15]!==r?(h=(0,P.jsx)(`div`,{className:`flex-1 overflow-y-auto`,"data-testid":`activity-panel-body`,children:r===`loading`&&n===null?(0,P.jsx)(L,{}):r===`error`&&i?(0,P.jsx)(R,{error:i,onRetry:a}):n===null?(0,P.jsx)(me,{}):(0,P.jsxs)(P.Fragment,{children:[n.sessionAlive?null:(0,P.jsx)(ge,{lastTs:d}),n.files.length===0?(0,P.jsx)(me,{}):n.files.map(e=>(0,P.jsx)(ue,{file:e,sessionAlive:n.sessionAlive,isWriting:n.writingDocs.has(e.docName),onNavigate:c,onUndoLast:l,onUndoAll:u,fetchBurstDiff:o},e.docName))]})}),t[7]=n,t[8]=i,t[9]=o,t[10]=d,t[11]=c,t[12]=u,t[13]=l,t[14]=a,t[15]=r,t[16]=h):h=t[16];let g;return t[17]!==m||t[18]!==h?(g=(0,P.jsxs)(`section`,{className:`flex h-full min-h-0 flex-col`,"data-testid":`activity-panel`,"aria-label":`Agent activity`,children:[m,h]}),t[17]=m,t[18]=h,t[19]=g):g=t[19],g}function ve(){let e=(0,A.c)(22),{docPanelAgentId:t,closeActivityPanel:n}=g(),{openDocumentTransition:r}=_(),{data:i,status:a,error:o,reload:s,fetchBurstDiff:c}=ne(t);if(t===null){let t;return e[0]===n?t=e[1]:(t=(0,P.jsx)(z,{onExit:n}),e[0]=n,e[1]=t),t}let l;e[2]===r?l=e[3]:(l=e=>{r(e),I(e)},e[2]=r,e[3]=l);let u=l,d;e[4]!==i||e[5]!==t||e[6]!==s?(d=async e=>{try{await F({connectionId:t,docName:e,scope:`last`,agentName:i?.agent?.displayName}),s()}catch(e){let t=e,n=t instanceof Error?t.message:String(t);w.error(`Undo failed: ${n}`),s()}},e[4]=i,e[5]=t,e[6]=s,e[7]=d):d=e[7];let f=d,p;e[8]!==i||e[9]!==t||e[10]!==s?(p=async e=>{try{await F({connectionId:t,docName:e,scope:`file`,agentName:i?.agent?.displayName}),w.success(`Undone all edits on ${e}`),s()}catch(e){let t=e,n=t instanceof Error?t.message:String(t);w.error(`Undo all failed: ${n}`),s()}},e[8]=i,e[9]=t,e[10]=s,e[11]=p):p=e[11];let m=p,h;return e[12]!==n||e[13]!==i||e[14]!==o||e[15]!==c||e[16]!==u||e[17]!==m||e[18]!==f||e[19]!==s||e[20]!==a?(h=(0,P.jsx)(H,{data:i,status:a,error:o,reload:s,fetchBurstDiff:c,onExit:n,onNavigate:u,onUndoLast:f,onUndoAll:m}),e[12]=n,e[13]=i,e[14]=o,e[15]=c,e[16]=u,e[17]=m,e[18]=f,e[19]=s,e[20]=a,e[21]=h):h=e[21],h}export{ve as ActivityModeContent};
|