@inkeep/open-knowledge 0.0.0-dev-20260428211426 → 0.0.0-dev-20260429030631

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.
Files changed (36) hide show
  1. package/dist/cli.mjs +235 -232
  2. package/dist/constants-B-gLpuaA.mjs +2 -0
  3. package/dist/{dist-Ct-gJ7iD.mjs → dist-B7U9dfgx.mjs} +1 -1
  4. package/dist/{dist-0qFIeeXA.mjs → dist-D6sXBEzw.mjs} +11 -11
  5. package/dist/index.mjs +1 -1
  6. package/dist/{init-CMkePWjl.mjs → init-BBiPSV-w.mjs} +22 -7
  7. package/dist/init-BEo-n_Uy.mjs +1 -0
  8. package/dist/{init-D0YdyLe_.mjs → init-DktmtY_7.mjs} +4 -4
  9. package/dist/init-yNwtj9hS.mjs +1 -0
  10. package/dist/loader-CX_sYqFb.mjs +1 -0
  11. package/dist/{loader-BJU3jneI.mjs → loader-E7RjFMCP.mjs} +2 -2
  12. package/dist/paths-CIFllhl9.mjs +1 -0
  13. package/dist/{paths-CNpYe27Q.mjs → paths-t5fX6xpy.mjs} +2 -2
  14. package/dist/preview-B3wdzX-m.mjs +1 -0
  15. package/dist/{preview-CXP9kBv6.mjs → preview-CfwdEokP.mjs} +2 -2
  16. package/dist/public/assets/{ActivityModeContent-Ccu_n0bV.js → ActivityModeContent-DB-Anrff.js} +1 -1
  17. package/dist/public/assets/{DocumentContext-C1msvcHp.js → DocumentContext-BQEvrOdm.js} +1 -1
  18. package/dist/public/assets/McpConsentDialogBody-KLtPoa1G.js +1 -0
  19. package/dist/public/assets/{SourceEditor-OFesfBB2.js → SourceEditor-pg77Ty2h.js} +1 -1
  20. package/dist/public/assets/{clipboard-DAcKCHl1.js → clipboard-DO2TbwyY.js} +1 -1
  21. package/dist/public/assets/{index-CwFTGDhe.js → index-Did2wKqz.js} +63 -63
  22. package/dist/public/index.html +3 -3
  23. package/dist/src-C0IVz8Sw.mjs +1 -0
  24. package/dist/start-B8Duv9Ct.mjs +2 -0
  25. package/dist/start-BDCAyg0c.mjs +1 -0
  26. package/package.json +1 -1
  27. package/dist/constants-DCJlLBSi.mjs +0 -2
  28. package/dist/init-D-5Gc0uq.mjs +0 -1
  29. package/dist/init-DUA_XKK1.mjs +0 -1
  30. package/dist/loader-1GTY76cQ.mjs +0 -1
  31. package/dist/paths-fx16Ahvg.mjs +0 -1
  32. package/dist/preview-CHvLSbhb.mjs +0 -1
  33. package/dist/public/assets/McpConsentDialogBody-Csjet19t.js +0 -1
  34. package/dist/src-BIqAAP5m.mjs +0 -1
  35. package/dist/start-BOjBm-nL.mjs +0 -2
  36. package/dist/start-CZFHRjtT.mjs +0 -1
package/dist/index.mjs CHANGED
@@ -1 +1 @@
1
- import{c as e,i as t,l as n,s as r,t as i,u as a}from"./init-D0YdyLe_.mjs";import{n as o,r as s}from"./loader-BJU3jneI.mjs";import"./src-BIqAAP5m.mjs";export{n as ALL_EDITOR_IDS,s as ConfigSchema,a as EDITOR_TARGETS,i as detectInstalledEditors,o as loadConfig,t as readExistingMcpEntry,r as writeEditorMcpConfig,e as writeUserMcpConfigs};
1
+ import{c as e,i as t,l as n,s as r,t as i,u as a}from"./init-DktmtY_7.mjs";import{n as o,r as s}from"./loader-E7RjFMCP.mjs";import"./src-C0IVz8Sw.mjs";export{n as ALL_EDITOR_IDS,s as ConfigSchema,a as EDITOR_TARGETS,i as detectInstalledEditors,o as loadConfig,t as readExistingMcpEntry,r as writeEditorMcpConfig,e as writeUserMcpConfigs};
@@ -1,4 +1,4 @@
1
- import{n as e,t}from"./constants-DCJlLBSi.mjs";import{p as n}from"./dist-CXdg7KnM.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
1
+ import{n as e,t}from"./constants-B-gLpuaA.mjs";import{p as n}from"./dist-CXdg7KnM.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
@@ -110,11 +110,26 @@ import{n as e,t}from"./constants-DCJlLBSi.mjs";import{p as n}from"./dist-CXdg7Kn
110
110
  # title: Articles
111
111
  # description: Canonical knowledge committed after a team decision. Produced by the \`consolidate\` tool with a \`supersedes:\` chain tying back to the research that preceded it.
112
112
  # tags: [article, canonical, layer-consolidate]
113
- `;function u(e,t){return a(e)?!1:(c(e,t,`utf-8`),!0)}function d(e){let t=r(e,`.gitignore`),i=`# Open Knowledge — local editor config (not tracked upstream)\n${n}/\n`;if(!a(t))return c(t,i,`utf-8`),`created`;let o=s(t,`utf-8`),l=new Set([n,`${n}/`,`/${n}`,`/${n}/`]);return o.split(`
114
- `).map(e=>e.trim()).some(e=>l.has(e))?`already-present`:(c(t,`${o}${o.length===0||o.endsWith(`
113
+ `;function u(e,t){return a(e)?!1:(c(e,t,`utf-8`),!0)}function d(e,t){if(!a(e))return c(e,t,`utf-8`),`created`;let n=t.split(`
114
+ `).map(e=>e.trim()).filter(e=>e.length>0&&!e.startsWith(`#`)),r=s(e,`utf-8`),i=new Set(r.split(`
115
+ `).map(e=>e.trim())),o=n.filter(e=>!i.has(e));return o.length===0?`unchanged`:(c(e,`${r}${r.length===0||r.endsWith(`
115
116
  `)?``:`
116
- `}${o.length>0&&!o.endsWith(`
117
+ `}${o.join(`
118
+ `)}\n`,`utf-8`),`updated`)}const f=`# Per-machine runtime state — never commit. All Open Knowledge ignore rules
119
+ # live here so the project root .gitignore stays free of OK-internal paths.
117
120
 
118
- `)?`
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-CMkePWjl.mjs.map
121
+ # Derived caches
122
+ ${t}/
123
+
124
+ # Per-process locks
125
+ server.lock
126
+ ui.lock
127
+
128
+ # Sync watermarks + per-machine principal identity
129
+ sync-state.json
130
+ principal.json
131
+
132
+ # MCP spawn diagnostics
133
+ last-spawn-error.log
134
+ `;function p(a){let s=i(a,n),c=[],p=[],m=[];o(s,{recursive:!0}),o(r(s,t),{recursive:!0});let h=d(r(s,`.gitignore`),f);return h===`created`?c.push(`.gitignore`):h===`updated`?p.push(`.gitignore`):m.push(`.gitignore`),u(r(s,`config.yml`),l)?c.push(e):m.push(e),{created:c,updated:p,skipped:m}}export{p as t};
135
+ //# sourceMappingURL=init-BBiPSV-w.mjs.map
@@ -0,0 +1 @@
1
+ import{o as e}from"./init-DktmtY_7.mjs";export{e as runInit};
@@ -1,4 +1,4 @@
1
- import{n as e,t}from"./esm-wByiX8MO.mjs";import{r as n}from"./constants-DCJlLBSi.mjs";import{p as r}from"./dist-CXdg7KnM.mjs";import{Y as i,Z as a,_ as o,lt as s}from"./dist-0qFIeeXA.mjs";import{n as c}from"./init-CMkePWjl.mjs";import{t as l}from"./preview-CXP9kBv6.mjs";import{s as u,t as d}from"./colors-DoPZvo1q.mjs";import{t as f}from"./is-object-BNVklKxg.mjs";import{basename as p,dirname as m,join as h,posix as g,relative as _,resolve as v,sep as y,win32 as b}from"node:path";import{existsSync as x,mkdirSync as S,readFileSync as C,writeFileSync as w}from"node:fs";import{homedir as T}from"node:os";import E from"@inquirer/checkbox";
1
+ import{n as e,t}from"./esm-wByiX8MO.mjs";import{r as n}from"./constants-B-gLpuaA.mjs";import{p as r}from"./dist-CXdg7KnM.mjs";import{Y as i,Z as a,_ as o,lt as s}from"./dist-D6sXBEzw.mjs";import{t as c}from"./init-BBiPSV-w.mjs";import{t as l}from"./preview-CfwdEokP.mjs";import{s as u,t as d}from"./colors-DoPZvo1q.mjs";import{t as f}from"./is-object-BNVklKxg.mjs";import{basename as p,dirname as m,join as h,posix as g,relative as _,resolve as v,sep as y,win32 as b}from"node:path";import{existsSync as x,mkdirSync as S,readFileSync as C,writeFileSync as w}from"node:fs";import{homedir as T}from"node:os";import E from"@inquirer/checkbox";
2
2
  /*!
3
3
  * Copyright (c) Squirrel Chat et al., All rights reserved.
4
4
  * SPDX-License-Identifier: BSD-3-Clause
@@ -249,7 +249,7 @@ let F=/^[a-z0-9-_]+$/i;function I(e){let t=typeof e;if(t===`object`){if(Array.is
249
249
  `?r:r+`
250
250
  `}const B=[`claude`,`claude-desktop`,`cursor`,`vscode`,`windsurf`,`codex`],Ce=[`@inkeep/open-knowledge`,`mcp`],we={MCP_DEBUG:`1`,OK_LOG_FILE:`/tmp/ok-mcp.log`};function V(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=v(e);if(p(t)===`cli.mjs`&&p(m(t))===`dist`)return t;let n=t.split(y),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 h(i.length===0?y:i.join(y),`packages`,`cli`,`dist`,`cli.mjs`)}function H(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:[v(t),`mcp`]}}return e.mode===`dev`?{command:`node`,args:[V(e.cliEntryPath),`mcp`],env:{...we}}:{command:`npx`,args:[...Ce]}}function U(e){return e===`win32`?b:g}function Te(e={}){let t=e.platformName??process.platform,n=e.home??T(),r=e.env??process.env,i=U(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??T();return U(t).join(n,`.claude.json`)}function W(e={}){let t=e.platformName??process.platform,n=e.home??T(),r=e.env??process.env;if(t===`darwin`)return g.join(n,`Library`,`Application Support`,`Claude`,`claude_desktop_config.json`);if(t===`win32`){let e=r.APPDATA??b.join(n,`AppData`,`Roaming`);return b.join(e,`Claude`,`claude_desktop_config.json`)}throw Error(`Claude Desktop is not available on ${t}. Supported: macOS, Windows.`)}function De(e={}){let t=e.platformName??process.platform,n=e.home??T();return U(t).join(n,`.cursor`,`mcp.json`)}function Oe(e={}){return U(e.platformName??process.platform).join(Te(e),`Code`,`User`,`mcp.json`)}function ke(e={}){let t=e.platformName??process.platform,n=e.home??T();return U(t).join(n,`.codeium`,`windsurf`,`mcp_config.json`)}function Ae(e={}){let t=e.platformName??process.platform,n=e.home??T();return(e.env??process.env).CODEX_HOME??U(t).join(n,`.codex`)}function je(e={}){return U(e.platformName??process.platform).join(Ae(e),`config.toml`)}function G(e,t){if(e===t)return!0;if(Array.isArray(e)&&Array.isArray(t))return e.length===t.length&&e.every((e,n)=>G(e,t[n]));if(f(e)&&f(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=>G(e[n],t[n]))}return!1}function Me(e,t){return Object.entries(t).every(([t,n])=>G(e[t],n))}function Ne(e,t){return{...e,...t}}function K(e){return{...e,isCompatible(t,n,r){return Me(t,e.buildEntry(n,r))},mergeManagedFields(t,n,r){return Ne(t,e.buildEntry(n,r))}}}const q={claude:K({id:`claude`,label:`Claude Code`,configPath:(e,t)=>Ee({home:t}),format:`json`,topLevelKey:`mcpServers`,serverName:()=>n,buildEntry:(e,t)=>H(t),scope:`global`,detectPath:(e,t)=>h(t??T(),`.claude`),projectConfigPath:e=>h(e,`.mcp.json`)}),"claude-desktop":K({id:`claude-desktop`,label:`Claude Desktop`,configPath:(e,t)=>W({home:t}),format:`json`,topLevelKey:`mcpServers`,serverName:()=>n,buildEntry:(e,t)=>H(t),scope:`global`,detectPath:(e,t)=>m(W({home:t}))}),cursor:K({id:`cursor`,label:`Cursor`,configPath:(e,t)=>De({home:t}),format:`json`,topLevelKey:`mcpServers`,serverName:()=>n,buildEntry:(e,t)=>H(t),scope:`global`,detectPath:(e,t)=>m(De({home:t})),projectConfigPath:e=>h(e,`.cursor`,`mcp.json`)}),vscode:K({id:`vscode`,label:`VS Code`,configPath:(e,t)=>Oe({home:t}),format:`json`,topLevelKey:`servers`,serverName:()=>n,buildEntry:(e,t)=>({type:`stdio`,...H(t)}),scope:`global`,detectPath:(e,t)=>m(Oe({home:t})),projectConfigPath:e=>h(e,`.vscode`,`mcp.json`)}),windsurf:K({id:`windsurf`,label:`Windsurf`,configPath:(e,t)=>ke({home:t}),format:`json`,topLevelKey:`mcpServers`,serverName:()=>n,buildEntry:(e,t)=>H(t),scope:`global`,detectPath:(e,t)=>m(ke({home:t}))}),codex:K({id:`codex`,label:`Codex`,configPath:(e,t)=>je({home:t}),format:`toml`,topLevelKey:`mcp_servers`,serverName:()=>n,buildEntry:(e,t)=>H(t),scope:`global`,detectPath:(e,t)=>m(je({home:t})),projectConfigPath:e=>h(e,`.codex`,`config.toml`)})};function J(e){let t=e.filter(e=>!(e in q));if(t.length>0)throw Error(`Unknown editor(s): ${t.join(`, `)}. Valid options: ${B.join(`, `)}`);return e.map(e=>q[e])}function Pe(e){if(!x(e))return{};let t=C(e,`utf-8`).trim();if(t===``)return{};try{let n=JSON.parse(t);if(f(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 Fe(e){if(!x(e))return{};let t=C(e,`utf-8`).trim();if(t===``)return{};try{let n=_e(t);if(f(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 Ie(e,t){S(m(e),{recursive:!0}),w(e,`${JSON.stringify(t,null,2)}\n`,`utf-8`)}function Le(e,t){S(m(e),{recursive:!0});let n=Se(t);w(e,n.endsWith(`
251
251
  `)?n:`${n}\n`,`utf-8`)}const Re=e=>e!==`project`,Y=e=>e!==`user`;async function ze(){let e=await E({message:`Where should the MCP server be configured?
252
- `,required:!1,theme:{icon:{checked:`[x]`,unchecked:`[ ]`}},choices:[{name:`User-level (~/.claude.json, ~/.cursor/mcp.json, …)`,value:`user`,checked:!0},{name:`Project-level (.mcp.json, .cursor/mcp.json, …)`,value:`project`,checked:!0}]});return e.includes(`user`)&&e.includes(`project`)?`both`:e.includes(`user`)?`user`:e.includes(`project`)?`project`:null}async function Be(e){return e.mcp===!1?null:e.scope?e.scope:e.isTTY??process.stdout.isTTY?(e.promptFn??ze)():`both`}const Ve=`0.0.1`,X=`open-knowledge-ui`;function He(e,t={}){let n=h(e,`.claude`,`launch.json`),r=t.mode===`dev`?{name:X,runtimeExecutable:`node`,runtimeArgs:[V(t.cliEntryPath),`ui`],port:3e3}:{name:X,runtimeExecutable:`npx`,runtimeArgs:[`@inkeep/open-knowledge`,`ui`],port:3e3};try{if(!x(n))return S(m(n),{recursive:!0}),w(n,`${JSON.stringify({version:Ve,configurations:[r]},null,2)}\n`,`utf-8`),{action:`created`,configPath:n};let e=C(n,`utf-8`).trim(),t=e?JSON.parse(e):{};if(!f(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=>f(e)&&e.name===X);a>=0?i[a]=r:i.push(r);let o={...t,version:t.version??Ve,configurations:i};return w(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 x(e.detectPath?.(t,n)??m(e.configPath(t,n)))}catch{return!1}}function Q(e,t,n,r,i){let a=e.serverName(t),o;try{o=i??e.configPath(t,r)}catch(t){return{editorId:e.id,label:e.label,action:`failed`,configPath:``,serverName:a,error:t instanceof Error?t.message:String(t)}}if(!i&&!n.skipAvailabilityCheck&&!Z(e,t,r))return{editorId:e.id,label:e.label,action:`skipped-missing`,configPath:o,serverName:a};let s;try{s=e.format===`toml`?Fe(o):Pe(o)}catch(t){return{editorId:e.id,label:e.label,action:`failed`,configPath:o,serverName:a,error:t instanceof Error?t.message:String(t)}}let c=s[e.topLevelKey]??{},l=c[a],u;try{u=e.buildEntry(t,n)}catch(t){return{editorId:e.id,label:e.label,action:`failed`,configPath:o,serverName:a,error:t instanceof Error?t.message:String(t)}}let d={...s,[e.topLevelKey]:{...c,[a]:u}};try{e.format===`toml`?Le(o,d):Ie(o,d)}catch(t){return{editorId:e.id,label:e.label,action:`failed`,configPath:o,serverName:a,error:t instanceof Error?t.message:String(t)}}return{editorId:e.id,label:e.label,action:l===void 0?`written`:`overwritten`,configPath:o,serverName:a,...i===void 0?{}:{configScope:`project`}}}function Ue(e,t){let n=e.projectConfigPath?.(t);if(!(!n||!x(n)))return{editorId:e.id,label:e.label,path:n}}async function We(e){let t=J(e.editors),n={mode:`published`,cliPath:e.cliPath,skipAvailabilityCheck:!0};return t.map(t=>Q(t,``,n,e.home))}function Ge(e,t,n){let r;try{r=e.configPath(t,n)}catch{return null}let i;try{i=e.format===`toml`?Fe(r):Pe(r)}catch{return null}let a=i[e.topLevelKey];if(!f(a))return null;let o=a[e.serverName(t)];return f(o)?o:null}async function Ke(e={}){let t=v(e.cwd??process.cwd()),n={mode:e.pin?`pinned`:e.devMcp?`dev`:`published`,cliEntryPath:e.cliEntryPath},r=await a(t),o;try{o=c(t)}catch(n){let i=q.claude.configPath(t,e.home);return{contentCreated:[],contentSkipped:[],editors:[],legacyProjectConfigs:[],didGitInit:r.didInit,claudeDesktopDetected:!1,mcpAction:`failed`,mcpPath:i,mcpError:`Content scaffolding failed: ${n instanceof Error?n.message:String(n)}`}}let l=await Be({scope:e.scope,mcp:e.mcp,isTTY:e.isTTY,promptFn:e.promptFn}),u=e.editors??$(t,e.home),d=e.editors??B.filter(e=>q[e].projectConfigPath!==void 0),f=J(u),p=J(d),m=e.mcp===!1||l===null,h=Array.from(new Map([...f,...m?[]:p].map(e=>[e.id,e])).values()),g=f.filter(n=>Z(n,t,e.home)),_=[],y=new Set;for(let r of h){if(m){let n=``;try{n=r.configPath(t,e.home)}catch{}_.push({editorId:r.id,label:r.label,action:`skipped-flag`,configPath:n,serverName:r.serverName(t)});continue}if(Re(l)&&f.includes(r)&&_.push(Q(r,t,n,e.home)),Y(l)&&p.includes(r)&&r.projectConfigPath){let i=r.projectConfigPath(t),a=Q(r,t,n,e.home,i);_.push(a),(a.action===`written`||a.action===`overwritten`)&&y.add(i)}}let b=!m&&l!==null&&Y(l)?p.filter(e=>!e.projectConfigPath).map(e=>e.label):void 0,x=m?[]:g.map(e=>Ue(e,t)).filter(e=>e!==void 0).filter(e=>!y.has(e.path)),S=g.some(e=>e.id===`claude`)&&!m?He(t,n):void 0,C=await(e.installUserSkill??s)({home:e.home}),w=i({home:e.home}),T=m?`skipped-flag`:`skipped-missing`,E=_.find(e=>e.editorId===`claude`)??_[0]??{action:T,configPath:q.claude.configPath(t,e.home)};return{contentCreated:o.created,contentSkipped:o.skipped,editors:_,legacyProjectConfigs:x,launchJson:S,skillInstall:C,didGitInit:r.didInit,claudeDesktopDetected:w,mcpAction:E.action,mcpPath:E.configPath,mcpError:`error`in E?E.error:void 0,projectScopeUnsupportedLabels:b}}function qe(e,t){let n=[],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`),c=e=>{let n=e.configPath.startsWith(t)?_(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&&n.push(`Initialized git repo at ${t}/.git/ (default branch: main)`);let f=h(t,r);if(e.contentCreated.length>0?(n.push(`Content scaffolded at ${f}/`),n.push(` Created: ${e.contentCreated.join(`, `)}`)):n.push(`Content already present at ${f}/`),e.contentSkipped.length>0&&n.push(` Skipped (already exist): ${e.contentSkipped.join(`, `)}`),n.push(``),e.mcpError&&e.editors.length===0)n.push(`Warning: ${e.mcpError}`);else if(e.editors.length===0)if(n.push(`MCP server configuration:`),e.mcpAction===`skipped-flag`)n.push(` MCP config not written — use without --no-mcp to configure editors`);else if(e.projectScopeUnsupportedLabels&&e.projectScopeUnsupportedLabels.length>0){let t=e.projectScopeUnsupportedLabels.join(`, `),r=e.projectScopeUnsupportedLabels.length===1?`does`:`do`;n.push(` ${t} ${r} not support project-level config; skipped`)}else n.push(` No supported editor config directories detected; skipped MCP registration`);else if(o)n.push(`MCP config not written — use without --no-mcp to configure editors`);else if(s)n.push(`MCP server configuration:`),n.push(` No supported editor config directories detected; skipped MCP registration`);else{n.push(`MCP server configuration:`);for(let r of e.editors){let i=r.configPath.startsWith(t)?_(t,r.configPath):r.configPath.replace(/^\/Users\/[^/]+/,`~`),a=r.serverName===`open-knowledge`?``:` (${r.serverName})`,o=r.configScope===`project`?` (project)`:``,s=`${r.label}${o}`,l=` `.repeat(Math.max(1,20-s.length)),u=r.editorId===`claude-desktop`&&(r.action===`written`||r.action===`overwritten`)?` — quit and relaunch Claude Desktop to activate`:``;switch(r.action){case`written`:n.push(` ${s}${l}${i} registered${a}${u}`);break;case`overwritten`:n.push(` ${s}${l}${i} updated${a}${u}`);break;case`skipped-missing`:n.push(` ${s}${l}${i} config root missing; skipped`);break;case`failed`:n.push(` ${s}${l}${i} FAILED: ${r.error}`);break;case`skipped-flag`:break}r.editorId===`claude`&&e.launchJson&&n.push(c(e.launchJson))}if(e.projectScopeUnsupportedLabels&&e.projectScopeUnsupportedLabels.length>0){let t=e.projectScopeUnsupportedLabels.join(`, `),r=e.projectScopeUnsupportedLabels.length===1?`does`:`do`;n.push(` ${t} ${r} not support project-level config; skipped`)}}if(a&&(n.push(``),n.push(`For failed editors, add the MCP server entry manually. See:`),n.push(` https://github.com/inkeep/open-knowledge#mcp-setup`)),e.legacyProjectConfigs.length>0){n.push(``),n.push(`Project MCP configs found:`);for(let r of e.legacyProjectConfigs)n.push(` ${r.label} ${_(t,r.path)}`);n.push(` These project-local files may override the global config. Remove them if you want fully user-scoped MCP setup in this project.`)}if(e.skillInstall)switch(n.push(``),n.push(`User-global skill:`),e.skillInstall){case`installed`:n.push(" open-knowledge installed to detected agent hosts via `npx skills`");break;case`skip-current`:n.push(` open-knowledge already installed at current version`);break;case`failed`:n.push(` ${u(`open-knowledge install failed — MCP still configured; run manually:`)}`),n.push(` ${u(` npx skills@~1.5.0 add <bundled-path> --agent '*' -g -y --copy`)}`);break}if(e.claudeDesktopDetected&&(n.push(``),n.push(`Claude Desktop App detected. To enable in Claude Chat & Cowork, run: ${d(`ok install-skill`)}`)),e.preview?(n.push(``),n.push(l(e.preview,t))):e.previewWarning&&(n.push(``),n.push(`Content preview unavailable: ${e.previewWarning}`)),i){let t=new Set,r=e.editors.filter(e=>e.action===`written`||e.action===`overwritten`).filter(e=>!t.has(e.editorId)&&t.add(e.editorId)).map(e=>e.label);n.push(``),n.push(`Next steps:`),n.push(` 1. Open your editor (${r.join(` / `)})`),n.push(` 2. Approve the MCP server when prompted`),n.push(` 3. (Optional) scaffold the starter knowledge-base structure:`),n.push(` - ok seed`),n.push(` 4. Use the three MCP workflow tools as you build the wiki:`),n.push(` - mcp__open-knowledge__ingest — capture an external source`),n.push(` - mcp__open-knowledge__research — gather sources and write findings`),n.push(` - mcp__open-knowledge__consolidate — promote research to canonical articles`)}return n.join(`
252
+ `,required:!1,theme:{icon:{checked:`[x]`,unchecked:`[ ]`}},choices:[{name:`User-level (~/.claude.json, ~/.cursor/mcp.json, …)`,value:`user`,checked:!0},{name:`Project-level (.mcp.json, .cursor/mcp.json, …)`,value:`project`,checked:!0}]});return e.includes(`user`)&&e.includes(`project`)?`both`:e.includes(`user`)?`user`:e.includes(`project`)?`project`:null}async function Be(e){return e.mcp===!1?null:e.scope?e.scope:e.isTTY??process.stdout.isTTY?(e.promptFn??ze)():`both`}const Ve=`0.0.1`,X=`open-knowledge-ui`;function He(e,t={}){let n=h(e,`.claude`,`launch.json`),r=t.mode===`dev`?{name:X,runtimeExecutable:`node`,runtimeArgs:[V(t.cliEntryPath),`ui`],port:3e3}:{name:X,runtimeExecutable:`npx`,runtimeArgs:[`@inkeep/open-knowledge`,`ui`],port:3e3};try{if(!x(n))return S(m(n),{recursive:!0}),w(n,`${JSON.stringify({version:Ve,configurations:[r]},null,2)}\n`,`utf-8`),{action:`created`,configPath:n};let e=C(n,`utf-8`).trim(),t=e?JSON.parse(e):{};if(!f(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=>f(e)&&e.name===X);a>=0?i[a]=r:i.push(r);let o={...t,version:t.version??Ve,configurations:i};return w(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 x(e.detectPath?.(t,n)??m(e.configPath(t,n)))}catch{return!1}}function Q(e,t,n,r,i){let a=e.serverName(t),o;try{o=i??e.configPath(t,r)}catch(t){return{editorId:e.id,label:e.label,action:`failed`,configPath:``,serverName:a,error:t instanceof Error?t.message:String(t)}}if(!i&&!n.skipAvailabilityCheck&&!Z(e,t,r))return{editorId:e.id,label:e.label,action:`skipped-missing`,configPath:o,serverName:a};let s;try{s=e.format===`toml`?Fe(o):Pe(o)}catch(t){return{editorId:e.id,label:e.label,action:`failed`,configPath:o,serverName:a,error:t instanceof Error?t.message:String(t)}}let c=s[e.topLevelKey]??{},l=c[a],u;try{u=e.buildEntry(t,n)}catch(t){return{editorId:e.id,label:e.label,action:`failed`,configPath:o,serverName:a,error:t instanceof Error?t.message:String(t)}}let d={...s,[e.topLevelKey]:{...c,[a]:u}};try{e.format===`toml`?Le(o,d):Ie(o,d)}catch(t){return{editorId:e.id,label:e.label,action:`failed`,configPath:o,serverName:a,error:t instanceof Error?t.message:String(t)}}return{editorId:e.id,label:e.label,action:l===void 0?`written`:`overwritten`,configPath:o,serverName:a,...i===void 0?{}:{configScope:`project`}}}function Ue(e,t){let n=e.projectConfigPath?.(t);if(!(!n||!x(n)))return{editorId:e.id,label:e.label,path:n}}async function We(e){let t=J(e.editors),n={mode:`published`,cliPath:e.cliPath,skipAvailabilityCheck:!0};return t.map(t=>Q(t,``,n,e.home))}function Ge(e,t,n){let r;try{r=e.configPath(t,n)}catch{return null}let i;try{i=e.format===`toml`?Fe(r):Pe(r)}catch{return null}let a=i[e.topLevelKey];if(!f(a))return null;let o=a[e.serverName(t)];return f(o)?o:null}async function Ke(e={}){let t=v(e.cwd??process.cwd()),n={mode:e.pin?`pinned`:e.devMcp?`dev`:`published`,cliEntryPath:e.cliEntryPath},r=await a(t),o;try{o=c(t)}catch(n){let i=q.claude.configPath(t,e.home);return{contentCreated:[],contentUpdated:[],contentSkipped:[],editors:[],legacyProjectConfigs:[],didGitInit:r.didInit,claudeDesktopDetected:!1,mcpAction:`failed`,mcpPath:i,mcpError:`Content scaffolding failed: ${n instanceof Error?n.message:String(n)}`}}let l=await Be({scope:e.scope,mcp:e.mcp,isTTY:e.isTTY,promptFn:e.promptFn}),u=e.editors??$(t,e.home),d=e.editors??B.filter(e=>q[e].projectConfigPath!==void 0),f=J(u),p=J(d),m=e.mcp===!1||l===null,h=Array.from(new Map([...f,...m?[]:p].map(e=>[e.id,e])).values()),g=f.filter(n=>Z(n,t,e.home)),_=[],y=new Set;for(let r of h){if(m){let n=``;try{n=r.configPath(t,e.home)}catch{}_.push({editorId:r.id,label:r.label,action:`skipped-flag`,configPath:n,serverName:r.serverName(t)});continue}if(Re(l)&&f.includes(r)&&_.push(Q(r,t,n,e.home)),Y(l)&&p.includes(r)&&r.projectConfigPath){let i=r.projectConfigPath(t),a=Q(r,t,n,e.home,i);_.push(a),(a.action===`written`||a.action===`overwritten`)&&y.add(i)}}let b=!m&&l!==null&&Y(l)?p.filter(e=>!e.projectConfigPath).map(e=>e.label):void 0,x=m?[]:g.map(e=>Ue(e,t)).filter(e=>e!==void 0).filter(e=>!y.has(e.path)),S=g.some(e=>e.id===`claude`)&&!m?He(t,n):void 0,C=await(e.installUserSkill??s)({home:e.home}),w=i({home:e.home}),T=m?`skipped-flag`:`skipped-missing`,E=_.find(e=>e.editorId===`claude`)??_[0]??{action:T,configPath:q.claude.configPath(t,e.home)};return{contentCreated:o.created,contentUpdated:o.updated,contentSkipped:o.skipped,editors:_,legacyProjectConfigs:x,launchJson:S,skillInstall:C,didGitInit:r.didInit,claudeDesktopDetected:w,mcpAction:E.action,mcpPath:E.configPath,mcpError:`error`in E?E.error:void 0,projectScopeUnsupportedLabels:b}}function qe(e,t){let n=[],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`),c=e=>{let n=e.configPath.startsWith(t)?_(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&&n.push(`Initialized git repo at ${t}/.git/ (default branch: main)`);let f=h(t,r);if(e.contentCreated.length>0||e.contentUpdated.length>0?(n.push(`Content scaffolded at ${f}/`),e.contentCreated.length>0&&n.push(` Created: ${e.contentCreated.join(`, `)}`),e.contentUpdated.length>0&&n.push(` Updated: ${e.contentUpdated.join(`, `)}`)):n.push(`Content already present at ${f}/`),e.contentSkipped.length>0&&n.push(` Skipped (already exist): ${e.contentSkipped.join(`, `)}`),n.push(``),e.mcpError&&e.editors.length===0)n.push(`Warning: ${e.mcpError}`);else if(e.editors.length===0)if(n.push(`MCP server configuration:`),e.mcpAction===`skipped-flag`)n.push(` MCP config not written — use without --no-mcp to configure editors`);else if(e.projectScopeUnsupportedLabels&&e.projectScopeUnsupportedLabels.length>0){let t=e.projectScopeUnsupportedLabels.join(`, `),r=e.projectScopeUnsupportedLabels.length===1?`does`:`do`;n.push(` ${t} ${r} not support project-level config; skipped`)}else n.push(` No supported editor config directories detected; skipped MCP registration`);else if(o)n.push(`MCP config not written — use without --no-mcp to configure editors`);else if(s)n.push(`MCP server configuration:`),n.push(` No supported editor config directories detected; skipped MCP registration`);else{n.push(`MCP server configuration:`);for(let r of e.editors){let i=r.configPath.startsWith(t)?_(t,r.configPath):r.configPath.replace(/^\/Users\/[^/]+/,`~`),a=r.serverName===`open-knowledge`?``:` (${r.serverName})`,o=r.configScope===`project`?` (project)`:``,s=`${r.label}${o}`,l=` `.repeat(Math.max(1,20-s.length)),u=r.editorId===`claude-desktop`&&(r.action===`written`||r.action===`overwritten`)?` — quit and relaunch Claude Desktop to activate`:``;switch(r.action){case`written`:n.push(` ${s}${l}${i} registered${a}${u}`);break;case`overwritten`:n.push(` ${s}${l}${i} updated${a}${u}`);break;case`skipped-missing`:n.push(` ${s}${l}${i} config root missing; skipped`);break;case`failed`:n.push(` ${s}${l}${i} FAILED: ${r.error}`);break;case`skipped-flag`:break}r.editorId===`claude`&&e.launchJson&&n.push(c(e.launchJson))}if(e.projectScopeUnsupportedLabels&&e.projectScopeUnsupportedLabels.length>0){let t=e.projectScopeUnsupportedLabels.join(`, `),r=e.projectScopeUnsupportedLabels.length===1?`does`:`do`;n.push(` ${t} ${r} not support project-level config; skipped`)}}if(a&&(n.push(``),n.push(`For failed editors, add the MCP server entry manually. See:`),n.push(` https://github.com/inkeep/open-knowledge#mcp-setup`)),e.legacyProjectConfigs.length>0){n.push(``),n.push(`Project MCP configs found:`);for(let r of e.legacyProjectConfigs)n.push(` ${r.label} ${_(t,r.path)}`);n.push(` These project-local files may override the global config. Remove them if you want fully user-scoped MCP setup in this project.`)}if(e.skillInstall)switch(n.push(``),n.push(`User-global skill:`),e.skillInstall){case`installed`:n.push(" open-knowledge installed to detected agent hosts via `npx skills`");break;case`skip-current`:n.push(` open-knowledge already installed at current version`);break;case`failed`:n.push(` ${u(`open-knowledge install failed — MCP still configured; run manually:`)}`),n.push(` ${u(` npx skills@~1.5.0 add <bundled-path> --agent '*' -g -y --copy`)}`);break}if(e.claudeDesktopDetected&&(n.push(``),n.push(`Claude Desktop App detected. To enable in Claude Chat & Cowork, run: ${d(`ok install-skill`)}`)),e.preview?(n.push(``),n.push(l(e.preview,t))):e.previewWarning&&(n.push(``),n.push(`Content preview unavailable: ${e.previewWarning}`)),i){let t=new Set,r=e.editors.filter(e=>e.action===`written`||e.action===`overwritten`).filter(e=>!t.has(e.editorId)&&t.add(e.editorId)).map(e=>e.label);n.push(``),n.push(`Next steps:`),n.push(` 1. Open your editor (${r.join(` / `)})`),n.push(` 2. Approve the MCP server when prompted`),n.push(` 3. (Optional) scaffold the starter knowledge-base structure:`),n.push(` - ok seed`),n.push(` 4. Use the three MCP workflow tools as you build the wiki:`),n.push(` - mcp__open-knowledge__ingest — capture an external source`),n.push(` - mcp__open-knowledge__research — gather sources and write findings`),n.push(` - mcp__open-knowledge__consolidate — promote research to canonical articles`)}return n.join(`
253
253
  `)}function $(e,t){let n=[];for(let r of B)Z(q[r],e,t)&&n.push(r);return n}function Je(){return new t(`init`).description(`Scaffold ${r}/ 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 ${r}/ 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`).addOption(new e(`--scope <scope>`,`Write MCP config at user level, project level, or both`).choices([`user`,`project`,`both`])).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 Ke({cwd:t,mcp:e.mcp,devMcp:e.devMcp,scope:e.scope,pin:e.pin})}catch(e){if(e instanceof o){process.stderr.write(`open-knowledge requires git to initialize a parent repo. Install git or run 'git init' yourself, then re-run.
254
- `),e.stderr&&process.stderr.write(`${e.stderr.trim()}\n`),process.exitCode=1;return}throw e}try{let{previewContent:e}=await import(`./preview-CHvLSbhb.mjs`),{loadConfig:r}=await import(`./loader-1GTY76cQ.mjs`),{resolveContentDir:i}=await import(`./paths-fx16Ahvg.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(`${qe(n,t)}\n`),(n.editors.some(e=>e.action===`failed`)||n.mcpAction===`failed`)&&(process.exitCode=1)})}export{Be as a,We as c,Ge as i,B as l,qe as n,Ke as o,Je as r,Q as s,$ as t,q as u};
255
- //# sourceMappingURL=init-D0YdyLe_.mjs.map
254
+ `),e.stderr&&process.stderr.write(`${e.stderr.trim()}\n`),process.exitCode=1;return}throw e}try{let{previewContent:e}=await import(`./preview-B3wdzX-m.mjs`),{loadConfig:r}=await import(`./loader-CX_sYqFb.mjs`),{resolveContentDir:i}=await import(`./paths-CIFllhl9.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(`${qe(n,t)}\n`),(n.editors.some(e=>e.action===`failed`)||n.mcpAction===`failed`)&&(process.exitCode=1)})}export{Be as a,We as c,Ge as i,B as l,qe as n,Ke as o,Je as r,Q as s,$ as t,q as u};
255
+ //# sourceMappingURL=init-DktmtY_7.mjs.map
@@ -0,0 +1 @@
1
+ import{t as e}from"./init-BBiPSV-w.mjs";export{e as initContent};
@@ -0,0 +1 @@
1
+ import{n as e}from"./loader-E7RjFMCP.mjs";export{e as loadConfig};
@@ -1,3 +1,3 @@
1
- import{t as e}from"./dist-BCyi1oM7.mjs";import{n as t}from"./constants-DCJlLBSi.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-CXdg7KnM.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(`
1
+ import{t as e}from"./dist-BCyi1oM7.mjs";import{n as t}from"./constants-B-gLpuaA.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-CXdg7KnM.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-BJU3jneI.mjs.map
3
+ //# sourceMappingURL=loader-E7RjFMCP.mjs.map
@@ -0,0 +1 @@
1
+ import{n as e,t}from"./paths-t5fX6xpy.mjs";export{t as resolveContentDir,e as resolveLockDir};
@@ -1,2 +1,2 @@
1
- import"./constants-DCJlLBSi.mjs";import{p as e}from"./dist-CXdg7KnM.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-CNpYe27Q.mjs.map
1
+ import"./constants-B-gLpuaA.mjs";import{p as e}from"./dist-CXdg7KnM.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-t5fX6xpy.mjs.map
@@ -0,0 +1 @@
1
+ import{n as e,t}from"./preview-CfwdEokP.mjs";export{t as formatPreviewBlock,e as previewContent};
@@ -1,3 +1,3 @@
1
- import"./constants-DCJlLBSi.mjs";import{p as e}from"./dist-CXdg7KnM.mjs";import{W as t}from"./dist-0qFIeeXA.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(`
1
+ import"./constants-B-gLpuaA.mjs";import{p as e}from"./dist-CXdg7KnM.mjs";import{W as t}from"./dist-D6sXBEzw.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-CXP9kBv6.mjs.map
3
+ //# sourceMappingURL=preview-CfwdEokP.mjs.map
@@ -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{f as s,g as c,h as l,i as u,m as d,r as f,t as p}from"./agent-presence-BXsx4eTl.js";import{lt as m,n as h,r as g,yt as _}from"./DocumentContext-C1msvcHp.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-D0MnQ7ZX.js";import{i as O}from"./PageListContext-B5SWnlyE.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),l;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(l=new u(ee),t[0]=l):l=t[0];let d=(0,j.useRef)(l),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),[u,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)(l,{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]!==u||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…`}):u?(0,P.jsxs)(`div`,{className:`px-4 py-2 text-xs text-destructive`,children:[`Failed: `,u]}):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]=u,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:u,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]!==u?(ce=()=>{g(!1),!N&&(w(!0),Promise.resolve(u(n.docName)).finally(()=>w(!1)))},t[8]=N,t[9]=n.docName,t[10]=u,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)(l,{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{f as s,g as c,h as l,i as u,m as d,r as f,t as p}from"./agent-presence-BXsx4eTl.js";import{lt as m,n as h,r as g,yt as _}from"./DocumentContext-BQEvrOdm.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-D0MnQ7ZX.js";import{i as O}from"./PageListContext-B5SWnlyE.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),l;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(l=new u(ee),t[0]=l):l=t[0];let d=(0,j.useRef)(l),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),[u,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)(l,{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]!==u||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…`}):u?(0,P.jsxs)(`div`,{className:`px-4 py-2 text-xs text-destructive`,children:[`Failed: `,u]}):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]=u,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:u,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]!==u?(ce=()=>{g(!1),!N&&(w(!0),Promise.resolve(u(n.docName)).finally(()=>w(!1)))},t[8]=N,t[9]=n.docName,t[10]=u,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)(l,{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};