@inkeep/open-knowledge 0.0.0-dev-20260501045551 → 0.0.0-dev-20260501055434
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 +255 -256
- package/dist/constants-Csaa4YGL.mjs +2 -0
- package/dist/dist-B0koAhBW.mjs +1 -0
- package/dist/{dist-BKxD-v-w.mjs → dist-C8iO0ddp.mjs} +9 -9
- package/dist/index.mjs +1 -1
- package/dist/init-1oapVq0V.mjs +1 -0
- package/dist/{init-CD1Q6xzB.mjs → init-BUnpt_ZF.mjs} +5 -5
- package/dist/init-C5RZF4cZ.mjs +1 -0
- package/dist/{init-C4wke4uB.mjs → init-tG0EK1Je.mjs} +2 -2
- package/dist/loader-C5AIUzdN.mjs +1 -0
- package/dist/{loader-LlG0LgdL.mjs → loader-CZE2QlA_.mjs} +2 -2
- package/dist/paths-C5pgWwxG.mjs +1 -0
- package/dist/paths-DfmL-9oM.mjs +2 -0
- package/dist/preview-BbFOb5YQ.mjs +1 -0
- package/dist/{preview-BaEgnUY0.mjs → preview-BlPt157K.mjs} +2 -2
- package/dist/public/assets/{ActivityModeContent-BLbgxGR9.js → ActivityModeContent-BSkmKRy4.js} +1 -1
- package/dist/public/assets/{DocumentContext-CjSzCZL0.js → DocumentContext-D3zjM2ax.js} +9 -9
- package/dist/public/assets/{SettingsPane-ztNlE-yh.js → SettingsPane-Bj0EiYda.js} +1 -1
- package/dist/public/assets/{SourceEditor-D-FWP4Ng.js → SourceEditor-Dz2Lc5LE.js} +1 -1
- package/dist/public/assets/{clipboard-DiHLkR-W.js → clipboard-i7TzBQ01.js} +1 -1
- package/dist/public/assets/{config-validation-events-GcLpFEMN.js → config-validation-events-DpHbVC_H.js} +1 -1
- package/dist/public/assets/{index-kpNzOlZa.js → index-BnZvzQ-9.js} +71 -71
- package/dist/public/index.html +4 -4
- package/dist/src-0PRCLtO_.mjs +1 -0
- package/dist/start-ID3eMpDo.mjs +1 -0
- package/dist/{start-cf2OdewF.mjs → start-eK3J-xIV.mjs} +2 -2
- package/package.json +1 -1
- package/dist/constants-CYAWu1t_.mjs +0 -2
- package/dist/dist-BuWOuGGO.mjs +0 -1
- package/dist/init-3aNImgts.mjs +0 -1
- package/dist/init-DcSlN0vZ.mjs +0 -1
- package/dist/loader-C-9Jcwv3.mjs +0 -1
- package/dist/paths-CinA1Uub.mjs +0 -2
- package/dist/paths-D8xkWudL.mjs +0 -1
- package/dist/preview-j16n7DSe.mjs +0 -1
- package/dist/src-aFcF98AM.mjs +0 -1
- package/dist/start-DW0GxweG.mjs +0 -1
package/dist/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{n as e,r as t}from"./loader-
|
|
1
|
+
import{n as e,r as t}from"./loader-CZE2QlA_.mjs";import{c as n,i as r,l as i,s as a,t as o,u as s}from"./init-BUnpt_ZF.mjs";import"./src-0PRCLtO_.mjs";export{i as ALL_EDITOR_IDS,t as ConfigSchema,s as EDITOR_TARGETS,o as detectInstalledEditors,e as loadConfig,r as readExistingMcpEntry,a as writeEditorMcpConfig,n as writeUserMcpConfigs};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{o as e}from"./init-BUnpt_ZF.mjs";export{e as runInit};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{n as e,t}from"./esm-wByiX8MO.mjs";import{$ as n}from"./dist-Bk22-nn7.mjs";import{r}from"./constants-
|
|
1
|
+
import{n as e,t}from"./esm-wByiX8MO.mjs";import{$ as n}from"./dist-Bk22-nn7.mjs";import{r}from"./constants-Csaa4YGL.mjs";import{Q as i,_ as a,et as o,ft as s}from"./dist-C8iO0ddp.mjs";import{t as c}from"./is-object-CEU0BgQ5.mjs";import{n as l}from"./init-tG0EK1Je.mjs";import{t as u}from"./preview-BlPt157K.mjs";import{i as d,o as f,r as p,s as m,t as h}from"./colors-BdAXRiXe.mjs";import{basename as g,dirname as _,join as v,posix as y,relative as b,resolve as x,sep as S,win32 as C}from"node:path";import{existsSync as w,mkdirSync as T,readFileSync as E,writeFileSync as D}from"node:fs";import{homedir as O}from"node:os";import ee 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 L=/^[a-z0-9-_]+$/i;function R(e){let t=typeof e;if(t===`object`){if(Array.is
|
|
|
249
249
|
`?r:r+`
|
|
250
250
|
`}const H=[`claude`,`claude-desktop`,`cursor`,`vscode`,`windsurf`,`codex`],we=[`@inkeep/open-knowledge`,`mcp`],Te={MCP_DEBUG:`1`,OK_LOG_FILE:`/tmp/ok-mcp.log`};function U(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=x(e);if(g(t)===`cli.mjs`&&g(_(t))===`dist`)return t;let n=t.split(S),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 v(i.length===0?S:i.join(S),`packages`,`cli`,`dist`,`cli.mjs`)}function W(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:[x(t),`mcp`]}}return e.mode===`dev`?{command:`node`,args:[U(e.cliEntryPath),`mcp`],env:{...Te}}:{command:`npx`,args:[...we]}}function G(e){return e===`win32`?C:y}function Ee(e={}){let t=e.platformName??process.platform,n=e.home??O(),r=e.env??process.env,i=G(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 De(e={}){let t=e.platformName??process.platform,n=e.home??O();return G(t).join(n,`.claude.json`)}function Oe(e={}){let t=e.platformName??process.platform,n=e.home??O(),r=e.env??process.env;if(t===`darwin`)return y.join(n,`Library`,`Application Support`,`Claude`,`claude_desktop_config.json`);if(t===`win32`){let e=r.APPDATA??C.join(n,`AppData`,`Roaming`);return C.join(e,`Claude`,`claude_desktop_config.json`)}throw Error(`Claude Desktop is not available on ${t}. Supported: macOS, Windows.`)}function ke(e={}){let t=e.platformName??process.platform,n=e.home??O();return G(t).join(n,`.cursor`,`mcp.json`)}function Ae(e={}){return G(e.platformName??process.platform).join(Ee(e),`Code`,`User`,`mcp.json`)}function je(e={}){let t=e.platformName??process.platform,n=e.home??O();return G(t).join(n,`.codeium`,`windsurf`,`mcp_config.json`)}function Me(e={}){let t=e.platformName??process.platform,n=e.home??O();return(e.env??process.env).CODEX_HOME??G(t).join(n,`.codex`)}function Ne(e={}){return G(e.platformName??process.platform).join(Me(e),`config.toml`)}function K(e,t){if(e===t)return!0;if(Array.isArray(e)&&Array.isArray(t))return e.length===t.length&&e.every((e,n)=>K(e,t[n]));if(c(e)&&c(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=>K(e[n],t[n]))}return!1}function Pe(e,t){return Object.entries(t).every(([t,n])=>K(e[t],n))}function Fe(e,t){return{...e,...t}}function q(e){return{...e,isCompatible(t,n,r){return Pe(t,e.buildEntry(n,r))},mergeManagedFields(t,n,r){return Fe(t,e.buildEntry(n,r))}}}const J={claude:q({id:`claude`,label:`Claude Code`,configPath:(e,t)=>De({home:t}),format:`json`,topLevelKey:`mcpServers`,serverName:()=>r,buildEntry:(e,t)=>W(t),scope:`global`,detectPath:(e,t)=>v(t??O(),`.claude`),projectConfigPath:e=>v(e,`.mcp.json`)}),"claude-desktop":q({id:`claude-desktop`,label:`Claude Desktop`,configPath:(e,t)=>Oe({home:t}),format:`json`,topLevelKey:`mcpServers`,serverName:()=>r,buildEntry:(e,t)=>W(t),scope:`global`,detectPath:(e,t)=>_(Oe({home:t}))}),cursor:q({id:`cursor`,label:`Cursor`,configPath:(e,t)=>ke({home:t}),format:`json`,topLevelKey:`mcpServers`,serverName:()=>r,buildEntry:(e,t)=>W(t),scope:`global`,detectPath:(e,t)=>_(ke({home:t})),projectConfigPath:e=>v(e,`.cursor`,`mcp.json`)}),vscode:q({id:`vscode`,label:`VS Code`,configPath:(e,t)=>Ae({home:t}),format:`json`,topLevelKey:`servers`,serverName:()=>r,buildEntry:(e,t)=>({type:`stdio`,...W(t)}),scope:`global`,detectPath:(e,t)=>_(Ae({home:t})),projectConfigPath:e=>v(e,`.vscode`,`mcp.json`)}),windsurf:q({id:`windsurf`,label:`Windsurf`,configPath:(e,t)=>je({home:t}),format:`json`,topLevelKey:`mcpServers`,serverName:()=>r,buildEntry:(e,t)=>W(t),scope:`global`,detectPath:(e,t)=>_(je({home:t}))}),codex:q({id:`codex`,label:`Codex`,configPath:(e,t)=>Ne({home:t}),format:`toml`,topLevelKey:`mcp_servers`,serverName:()=>r,buildEntry:(e,t)=>W(t),scope:`global`,detectPath:(e,t)=>_(Ne({home:t})),projectConfigPath:e=>v(e,`.codex`,`config.toml`)})};function Y(e){let t=e.filter(e=>!(e in J));if(t.length>0)throw Error(`Unknown editor(s): ${t.join(`, `)}. Valid options: ${H.join(`, `)}`);return e.map(e=>J[e])}function Ie(e){if(!w(e))return{};let t=E(e,`utf-8`).trim();if(t===``)return{};try{let n=JSON.parse(t);if(c(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 Le(e){if(!w(e))return{};let t=E(e,`utf-8`).trim();if(t===``)return{};try{let n=ve(t);if(c(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 Re(e,t){T(_(e),{recursive:!0}),D(e,`${JSON.stringify(t,null,2)}\n`,`utf-8`)}function ze(e,t){T(_(e),{recursive:!0});let n=Ce(t);D(e,n.endsWith(`
|
|
251
251
|
`)?n:`${n}\n`,`utf-8`)}const Be=e=>e!==`project`,Ve=e=>e!==`user`;async function He(){let e=await ee({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 Ue(e){return e.mcp===!1?null:e.scope?e.scope:e.isTTY??process.stdout.isTTY?(e.promptFn??He)():`both`}const We=`0.0.1`,X=`open-knowledge-ui`;function Ge(e,t={}){let n=v(e,`.claude`,`launch.json`),r=t.mode===`dev`?{name:X,runtimeExecutable:`node`,runtimeArgs:[U(t.cliEntryPath),`ui`],port:3e3}:{name:X,runtimeExecutable:`npx`,runtimeArgs:[`@inkeep/open-knowledge`,`ui`],port:3e3};try{if(!w(n))return T(_(n),{recursive:!0}),D(n,`${JSON.stringify({version:We,configurations:[r]},null,2)}\n`,`utf-8`),{action:`created`,configPath:n};let e=E(n,`utf-8`).trim(),t=e?JSON.parse(e):{};if(!c(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=>c(e)&&e.name===X);a>=0?i[a]=r:i.push(r);let o={...t,version:t.version??We,configurations:i};return D(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 w(e.detectPath?.(t,n)??_(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`?Le(o):Ie(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`?ze(o,d):Re(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 Ke(e,t){let n=e.projectConfigPath?.(t);if(!(!n||!w(n)))return{editorId:e.id,label:e.label,path:n}}async function qe(e){let t=Y(e.editors),n={mode:`published`,cliPath:e.cliPath,skipAvailabilityCheck:!0};return t.map(t=>Q(t,``,n,e.home))}function Je(e,t,n){let r;try{r=e.configPath(t,n)}catch{return null}let i;try{i=e.format===`toml`?Le(r):Ie(r)}catch{return null}let a=i[e.topLevelKey];if(!c(a))return null;let o=a[e.serverName(t)];return c(o)?o:null}async function Ye(e={}){let t=x(e.cwd??process.cwd()),n={mode:e.pin?`pinned`:e.devMcp?`dev`:`published`,cliEntryPath:e.cliEntryPath},r=await
|
|
253
|
-
`)}function $(e,t){let n=[];for(let r of H)Z(J[r],e,t)&&n.push(r);return n}function Ze(){return new t(`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`).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 Ye({cwd:t,mcp:e.mcp,devMcp:e.devMcp,scope:e.scope,pin:e.pin})}catch(e){if(e instanceof
|
|
254
|
-
`),e.stderr&&process.stderr.write(`${e.stderr.trim()}\n`),process.exitCode=1;return}throw e}try{let{previewContent:e}=await import(`./preview-
|
|
255
|
-
//# sourceMappingURL=init-
|
|
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 Ue(e){return e.mcp===!1?null:e.scope?e.scope:e.isTTY??process.stdout.isTTY?(e.promptFn??He)():`both`}const We=`0.0.1`,X=`open-knowledge-ui`;function Ge(e,t={}){let n=v(e,`.claude`,`launch.json`),r=t.mode===`dev`?{name:X,runtimeExecutable:`node`,runtimeArgs:[U(t.cliEntryPath),`ui`],port:3e3}:{name:X,runtimeExecutable:`npx`,runtimeArgs:[`@inkeep/open-knowledge`,`ui`],port:3e3};try{if(!w(n))return T(_(n),{recursive:!0}),D(n,`${JSON.stringify({version:We,configurations:[r]},null,2)}\n`,`utf-8`),{action:`created`,configPath:n};let e=E(n,`utf-8`).trim(),t=e?JSON.parse(e):{};if(!c(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=>c(e)&&e.name===X);a>=0?i[a]=r:i.push(r);let o={...t,version:t.version??We,configurations:i};return D(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 w(e.detectPath?.(t,n)??_(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`?Le(o):Ie(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`?ze(o,d):Re(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 Ke(e,t){let n=e.projectConfigPath?.(t);if(!(!n||!w(n)))return{editorId:e.id,label:e.label,path:n}}async function qe(e){let t=Y(e.editors),n={mode:`published`,cliPath:e.cliPath,skipAvailabilityCheck:!0};return t.map(t=>Q(t,``,n,e.home))}function Je(e,t,n){let r;try{r=e.configPath(t,n)}catch{return null}let i;try{i=e.format===`toml`?Le(r):Ie(r)}catch{return null}let a=i[e.topLevelKey];if(!c(a))return null;let o=a[e.serverName(t)];return c(o)?o:null}async function Ye(e={}){let t=x(e.cwd??process.cwd()),n={mode:e.pin?`pinned`:e.devMcp?`dev`:`published`,cliEntryPath:e.cliEntryPath},r=await o(t),a;try{a=l(t)}catch(n){let i=J.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 c=await Ue({scope:e.scope,mcp:e.mcp,isTTY:e.isTTY,promptFn:e.promptFn}),u=e.editors??$(t,e.home),d=e.editors??H.filter(e=>J[e].projectConfigPath!==void 0),f=Y(u),p=Y(d),m=e.mcp===!1||c===null,h=Array.from(new Map([...f,...m?[]:p].map(e=>[e.id,e])).values()),g=f.filter(n=>Z(n,t,e.home)),_=[],v=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(Be(c)&&f.includes(r)&&_.push(Q(r,t,n,e.home)),Ve(c)&&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`)&&v.add(i)}}let y=!m&&c!==null&&Ve(c)?p.filter(e=>!e.projectConfigPath).map(e=>e.label):void 0,b=m?[]:g.map(e=>Ke(e,t)).filter(e=>e!==void 0).filter(e=>!v.has(e.path)),S=g.some(e=>e.id===`claude`)&&!m?Ge(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:J.claude.configPath(t,e.home)};return{contentCreated:a.created,contentUpdated:a.updated,contentSkipped:a.skipped,editors:_,legacyProjectConfigs:b,launchJson:S,skillInstall:C,didGitInit:r.didInit,claudeDesktopDetected:w,mcpAction:E.action,mcpPath:E.configPath,mcpError:`error`in E?E.error:void 0,projectScopeUnsupportedLabels:y}}function Xe(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`),c=e=>{let n=e.configPath.startsWith(t)?b(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 l=v(t,n);if(e.contentCreated.length>0||e.contentUpdated.length>0?(r.push(h(`Content scaffolded at ${l}/`)),e.contentCreated.length>0&&r.push(` Created: ${e.contentCreated.join(`, `)}`),e.contentUpdated.length>0&&r.push(` Updated: ${e.contentUpdated.join(`, `)}`)):r.push(h(`Content already present at ${l}/`)),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)if(r.push(h(`MCP server configuration:`)),e.mcpAction===`skipped-flag`)r.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(`, `),n=e.projectScopeUnsupportedLabels.length===1?`does`:`do`;r.push(` ${t} ${n} not support project-level config; skipped`)}else r.push(` 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(h(`MCP server configuration:`)),r.push(` No supported editor config directories detected; skipped MCP registration`);else{r.push(h(`MCP server configuration:`));for(let n of e.editors){let i=n.configPath.startsWith(t)?b(t,n.configPath):n.configPath.replace(/^\/Users\/[^/]+/,`~`),a=n.serverName===`open-knowledge`?``:` (${n.serverName})`,o=n.configScope===`project`?` (project)`:``,s=`${n.label}${o}`,l=` `.repeat(Math.max(1,20-s.length)),u=n.editorId===`claude-desktop`&&(n.action===`written`||n.action===`overwritten`)?` — quit and relaunch Claude Desktop to activate`:``;switch(n.action){case`written`:r.push(` ${s}${l}${i} ${f(`registered`)}${a}${u}`);break;case`overwritten`:r.push(` ${s}${l}${i} ${f(`updated`)}${a}${u}`);break;case`skipped-missing`:r.push(` ${s}${l}${i} config root missing; skipped`);break;case`failed`:r.push(` ${s}${l}${i} ${p(`FAILED`)}: ${n.error}`);break;case`skipped-flag`:break}n.editorId===`claude`&&e.launchJson&&r.push(c(e.launchJson))}if(e.projectScopeUnsupportedLabels&&e.projectScopeUnsupportedLabels.length>0){let t=e.projectScopeUnsupportedLabels.join(`, `),n=e.projectScopeUnsupportedLabels.length===1?`does`:`do`;r.push(` ${t} ${n} not support project-level config; skipped`)}}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(`Project MCP configs found:`);for(let n of e.legacyProjectConfigs)r.push(` ${n.label} ${b(t,n.path)}`);r.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(r.push(``),r.push(h(`User-global skill:`)),e.skillInstall){case`installed`:r.push(` open-knowledge ${f(`installed to detected agent hosts`)} via \`npx skills\``);break;case`skip-current`:r.push(` open-knowledge ${f(`already installed at current version`)}`);break;case`failed`:r.push(` ${m(`open-knowledge install failed — MCP still configured; run manually:`)}`),r.push(` ${m(` 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: ${h(`ok install-skill`)}`)),e.preview?(r.push(``),r.push(u(e.preview,t))):e.previewWarning&&(r.push(``),r.push(`Content preview unavailable: ${e.previewWarning}`)),i){let t=new Set,n=e.editors.filter(e=>e.action===`written`||e.action===`overwritten`).filter(e=>!t.has(e.editorId)&&t.add(e.editorId)).map(e=>e.label);r.push(``),r.push(`${f(`✓`)} ${h(`Next steps:`)}`),r.push(` 1. Open your editor (${d(n.join(` / `))})`),r.push(` 2. Approve the MCP server when prompted`),r.push(` 3. (Optional) scaffold the starter knowledge-base structure:`),r.push(` - ${d(`ok seed`)}`),r.push(` 4. Use the three MCP workflow tools as you build the wiki:`),r.push(` - ${d(`mcp__open-knowledge__ingest`)} — capture an external source`),r.push(` - ${d(`mcp__open-knowledge__research`)} — gather sources and write findings`),r.push(` - ${d(`mcp__open-knowledge__consolidate`)} — promote research to canonical articles`)}return r.join(`
|
|
253
|
+
`)}function $(e,t){let n=[];for(let r of H)Z(J[r],e,t)&&n.push(r);return n}function Ze(){return new t(`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`).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 Ye({cwd:t,mcp:e.mcp,devMcp:e.devMcp,scope:e.scope,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.
|
|
254
|
+
`),e.stderr&&process.stderr.write(`${e.stderr.trim()}\n`),process.exitCode=1;return}throw e}try{let{previewContent:e}=await import(`./preview-BbFOb5YQ.mjs`),{loadConfig:r}=await import(`./loader-C5AIUzdN.mjs`),{resolveContentDir:i}=await import(`./paths-C5pgWwxG.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(`${Xe(n,t)}\n`),(n.editors.some(e=>e.action===`failed`)||n.mcpAction===`failed`)&&(process.exitCode=1)})}export{Ue as a,qe as c,Je as i,H as l,Xe as n,Ye as o,Ze as r,Q as s,$ as t,J as u};
|
|
255
|
+
//# sourceMappingURL=init-BUnpt_ZF.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{n as e}from"./init-tG0EK1Je.mjs";export{e as initContent};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{$ as e,X as t}from"./dist-Bk22-nn7.mjs";import{i as n,n as r,t as i}from"./constants-
|
|
1
|
+
import{$ as e,X as t}from"./dist-Bk22-nn7.mjs";import{i as n,n as r,t as i}from"./constants-Csaa4YGL.mjs";import{join as a,resolve as o}from"node:path";import{existsSync as s,mkdirSync as c,readFileSync as l,writeFileSync as u}from"node:fs";function d(n){return`# yaml-language-server: $schema=https://unpkg.com/@inkeep/open-knowledge@latest/dist/schemas/${t}/config.project.schema.json
|
|
2
2
|
# Open Knowledge — project configuration
|
|
3
3
|
#
|
|
4
4
|
# This file overrides built-in defaults for this project. Every key below
|
|
@@ -141,4 +141,4 @@ state.json
|
|
|
141
141
|
# MCP spawn diagnostics
|
|
142
142
|
last-spawn-error.log
|
|
143
143
|
`;function h(t){let s=o(t,e),l=[],u=[],h=[];c(s,{recursive:!0}),c(a(s,i),{recursive:!0});let g=p(a(s,`.gitignore`),m);return g===`created`?l.push(`.gitignore`):g===`updated`?u.push(`.gitignore`):h.push(`.gitignore`),f(a(s,`config.yml`),d(n))?l.push(r):h.push(r),{created:l,updated:u,skipped:h}}export{h as n,d as t};
|
|
144
|
-
//# sourceMappingURL=init-
|
|
144
|
+
//# sourceMappingURL=init-tG0EK1Je.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{n as e}from"./loader-CZE2QlA_.mjs";export{e as loadConfig};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{$ as e,F as t,Rt as n,Z as r,nt as i}from"./dist-Bk22-nn7.mjs";import{n as a}from"./constants-
|
|
2
|
-
//# sourceMappingURL=loader-
|
|
1
|
+
import{$ as e,F as t,Rt as n,Z as r,nt as i}from"./dist-Bk22-nn7.mjs";import{n as a}from"./constants-Csaa4YGL.mjs";import{r as o}from"./server-CYax-BjV.mjs";import{t as s}from"./is-object-CEU0BgQ5.mjs";import{resolve as c}from"node:path";import{existsSync as l,readFileSync as u}from"node:fs";import{homedir as d}from"node:os";import{realpath as f}from"node:fs/promises";async function p(e){let t=c(e);try{return await f(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 m=r;var h=n();function g(e,t){let n={...e};for(let r of Object.keys(t)){let i=e[r],a=t[r];s(a)&&s(i)?n[r]=g(i,a):a!==void 0&&(n[r]=a)}return n}function _(e){if(!l(e))return{value:null,path:e,source:null,doc:null};let t;try{t=u(e,`utf-8`)}catch(t){return console.warn(`[config] Failed to read ${e}: ${t instanceof Error?t.message:t}`),{value:null,path:e,source:null,doc:null}}let n=(0,h.parseDocument)(t);if(n.errors.length>0)return console.warn(`[config] Failed to parse ${e}: ${n.errors.map(e=>e.message).join(`; `)}`),{value:null,path:e,source:t,doc:null};let r=n.toJSON();return s(r)?{value:r,path:e,source:t,doc:n}:{value:null,path:e,source:t,doc:n}}function v(e,t){return e.map(e=>{let n=e.path.map(e=>typeof e==`symbol`?String(e):e),r={path:n,message:e.message,issueCode:e.code};if(t.doc!==null&&t.source!==null){let e=i({file:t.path,source:t.source,doc:t.doc,path:n});if(e!==void 0)return{...r,source:e}}return r})}function y(n){let r=n??process.cwd(),i=[],l=c(d(),e,a),u=o({absPath:l}),f={};u.valid&&u.source!==void 0?(f=g(f,u.value),i.push(l)):u.valid;let p=c(r,e,a),h=_(p);h.value!==null&&(f=g(f,h.value),i.push(p));let y=f.upload;s(y)&&y.maxBytes!==void 0&&console.warn(`[config] upload.maxBytes is deprecated and ignored — streaming uploads have no user-facing cap. Remove the key to silence this warning.`);let b=m.safeParse(f);if(!b.success){let e={code:`SCHEMA_INVALID`,issues:v(b.error.issues,h)};throw Error(t(e))}return{config:b.data,sources:i}}function b(e,t=process.env){let n=e;return t.HOST&&(n={...n,server:{...n.server,host:t.HOST}}),n}function x(e){let t=e.env??process.env,n=e.cacheMs??1e3,r=e.loadConfigFn??y,i=new Map,a=new Map,o=p(e.startupCwd);return async s=>{let c=await p(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=b(e.startupConfig,t);return i.set(c,{config:r,expiresAt:Date.now()+n}),r}let a=b(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{p as i,y as n,m as r,x as t};
|
|
2
|
+
//# sourceMappingURL=loader-CZE2QlA_.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{n as e,t}from"./paths-DfmL-9oM.mjs";export{t as resolveContentDir,e as resolveLockDir};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{n as e,t}from"./preview-BlPt157K.mjs";export{t as formatPreviewBlock,e as previewContent};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import{$ as e}from"./dist-Bk22-nn7.mjs";import"./constants-
|
|
1
|
+
import{$ as e}from"./dist-Bk22-nn7.mjs";import"./constants-Csaa4YGL.mjs";import{q as t}from"./dist-C8iO0ddp.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-BlPt157K.mjs.map
|
package/dist/public/assets/{ActivityModeContent-BLbgxGR9.js → ActivityModeContent-BSkmKRy4.js}
RENAMED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./ActivityPanelDiffView-C1vRNF09.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{i as t}from"./propagation-api-LnD10wq2.js";import{n,r,t as i}from"./compiler-runtime-Y11fyRVL.js";import{o as a}from"./toggle-group-n36XMgMC.js";import{S as o,t as s}from"./button-Dyz7QGIk.js";import{Mt as c,Nt as l,Pt as u,St as d,n as f,r as p}from"./DocumentContext-CjSzCZL0.js";import{f as m,i as h,m as g,r as _,t as v}from"./agent-presence-BxT9uQ-C.js";import{a as y,c as b,i as x,o as S,s as C,t as w,x as T}from"./dialog-FUclf-NK.js";import{i as E,n as D,t as O}from"./tooltip-BM5o_T0o.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}=f(),[r,i]=(0,j.useState)(null),[o,s]=(0,j.useState)(`idle`),[c,l]=(0,j.useState)(null),u;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(u=new h(ee),t[0]=u):u=t[0];let d=(0,j.useRef)(u),p=(0,j.useRef)(0),m;t[1]===n?m=t[2]:(m=e=>{let t=p.current+=1;s(`loading`),l(null),te(e).then(r=>{if(p.current!==t)return;let a=ie(n,e);i({...r,writingDocs:a}),s(`ready`)}).catch(e=>{p.current===t&&(l(e instanceof Error?e.message:String(e)),s(`error`))})},t[1]=n,t[2]=m);let g=m,_;t[3]!==e||t[4]!==g?(_=()=>{if(!e){p.current+=1,i(null),s(`idle`),l(null),d.current.clear();return}d.current.clear(),g(e);let t=null,n=a(n=>{n.includes(`session-activity`)&&(t&&clearTimeout(t),t=setTimeout(()=>{t=null,g(e)},M))});return()=>{t&&clearTimeout(t),n()}},t[3]=e,t[4]=g,t[5]=_):_=t[5];let v;t[6]===e?v=t[7]:(v=[e],t[6]=e,t[7]=v),(0,j.useEffect)(_,v);let y,b;t[8]!==e||t[9]!==n?(y=()=>{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)}},b=[e,n],t[8]=e,t[9]=n,t[10]=y,t[11]=b):(y=t[10],b=t[11]),(0,j.useEffect)(y,b);let x;t[12]===e?x=t[13]:(x=async(t,n)=>{if(!e)return``;let r=`${t}\0${n}`,i=d.current.get(r);if(i!==void 0)return i;let a=await N(e,t,n);return d.current.set(r,a),a},t[12]=e,t[13]=x);let S=x,C;t[14]!==e||t[15]!==g?(C=()=>{e&&g(e)},t[14]=e,t[15]=g,t[16]=C):C=t[16];let w=C,T;return t[17]!==r||t[18]!==c||t[19]!==S||t[20]!==w||t[21]!==o?(T={data:r,status:o,error:c,reload:w,fetchBurstDiff:S},t[17]=r,t[18]=c,t[19]=S,t[20]=w,t[21]=o,t[22]=T):T=t[22],T}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(!v(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-C1vRNF09.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),[d,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)(l,{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]!==d||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…`}):d?(0,P.jsxs)(`div`,{className:`px-4 py-2 text-xs text-destructive`,children:[`Failed: `,d]}):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]=d,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:a,onUndoLast:o,onUndoAll:c,fetchBurstDiff:d}=e,[f,p]=(0,j.useState)(!1),[h,g]=(0,j.useState)(!1),[_,v]=(0,j.useState)(!1),[T,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]!==o?(re=e=>{e.stopPropagation(),!N&&(v(!0),Promise.resolve(o(n.docName)).finally(()=>v(!1)))},t[2]=N,t[3]=n.docName,t[4]=o,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]!==c?(ce=()=>{g(!1),!N&&(v(!0),Promise.resolve(c(n.docName)).finally(()=>v(!1)))},t[8]=N,t[9]=n.docName,t[10]=c,t[11]=ce):ce=t[11];let ue=ce,F;t[12]===Symbol.for(`react.memo_cache_sentinel`)?(F=()=>p(de),t[12]=F):F=t[12];let pe=f?`Collapse ${n.docName}`:`Expand ${n.docName}`,I;t[13]===f?I=t[14]:(I=f?(0,P.jsx)(u,{className:`size-4`,"aria-hidden":`true`}):(0,P.jsx)(l,{className:`size-4`,"aria-hidden":`true`}),t[13]=f,t[14]=I);let L;t[15]!==f||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":f,"aria-label":pe,"data-testid":`activity-panel-file-row-carrot`,children:I}),t[15]=f,t[16]=pe,t[17]=I,t[18]=L):L=t[18];let R;t[19]!==n.docName||t[20]!==a?(R=()=>a(n.docName),t[19]=n.docName,t[20]=a,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)(m,{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)(E,{asChild:!0,children:(0,P.jsx)(s,{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)(D,{side:`bottom`,children:_e}),t[31]=_e,t[32]=V);let H;t[33]!==B||t[34]!==V?(H=(0,P.jsxs)(O,{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)(E,{asChild:!0,children:(0,P.jsx)(s,{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)(D,{side:`bottom`,children:xe}),t[41]=xe,t[42]=U);let W;t[43]!==be||t[44]!==U?(W=(0,P.jsxs)(O,{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]!==T?(J=le(n.lastTs,T),t[53]=n.lastTs,t[54]=T,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]!==f||t[69]!==d||t[70]!==n.bursts||t[71]!==n.docName?(Q=f?(0,P.jsx)(`div`,{children:n.bursts.map(e=>(0,P.jsx)(se,{burst:e,docName:n.docName,fetchBurstDiff:d},`${n.docName}:${e.stackIndex}`))}):null,t[68]=f,t[69]=d,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)(b,{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)(C,{children:[Se,(0,P.jsxs)(y,{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)(s,{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)(S,{children:[Ee,(0,P.jsx)(s,{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)(x,{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)(w,{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)(d,{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)(c,{className:`size-6 text-destructive`,"aria-hidden":`true`}),t[0]=i):i=t[0];let a;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(a=(0,P.jsx)(`p`,{className:`text-sm font-medium`,children:`Failed to load activity`}),t[1]=a):a=t[1];let o;t[2]===n?o=t[3]:(o=(0,P.jsxs)(`div`,{className:`space-y-1`,children:[a,(0,P.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:n})]}),t[2]=n,t[3]=o);let l;t[4]===r?l=t[5]:(l=(0,P.jsx)(s,{type:`button`,variant:`outline`,size:`sm`,onClick:r,children:`Retry`}),t[4]=r,t[5]=l);let u;return t[6]!==o||t[7]!==l?(u=(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,o,l]}),t[6]=o,t[7]=l,t[8]=u):u=t[8],u}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)(g,{}),t[0]=r):r=t[0];let i;t[1]===n?i=t[2]:(i=(0,P.jsx)(E,{asChild:!0,children:(0,P.jsx)(s,{type:`button`,variant:`ghost`,size:`icon`,className:`size-7 shrink-0`,onClick:n,"aria-label":`Back to document view`,"data-testid":`docpanel-exit-agent-mode`,children:r})}),t[1]=n,t[2]=i);let a;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(a=(0,P.jsx)(D,{side:`bottom`,children:`Back to document view`}),t[3]=a):a=t[3];let o;return t[4]===i?o=t[5]:(o=(0,P.jsxs)(O,{children:[i,a]}),t[4]=i,t[5]=o),o}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)(_,{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}=f(),{openDocumentTransition:r}=p(),{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);T.error(`Undo failed: ${n}`),s()}},e[4]=i,e[5]=t,e[6]=s,e[7]=d):d=e[7];let m=d,h;e[8]!==i||e[9]!==t||e[10]!==s?(h=async e=>{try{await F({connectionId:t,docName:e,scope:`file`,agentName:i?.agent?.displayName}),T.success(`Undone all edits on ${e}`),s()}catch(e){let t=e,n=t instanceof Error?t.message:String(t);T.error(`Undo all failed: ${n}`),s()}},e[8]=i,e[9]=t,e[10]=s,e[11]=h):h=e[11];let g=h,_;return e[12]!==n||e[13]!==i||e[14]!==o||e[15]!==c||e[16]!==u||e[17]!==g||e[18]!==m||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:m,onUndoAll:g}),e[12]=n,e[13]=i,e[14]=o,e[15]=c,e[16]=u,e[17]=g,e[18]=m,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{i as t}from"./propagation-api-LnD10wq2.js";import{n,r,t as i}from"./compiler-runtime-Y11fyRVL.js";import{o as a}from"./toggle-group-n36XMgMC.js";import{S as o,t as s}from"./button-Dyz7QGIk.js";import{Mt as c,Nt as l,Pt as u,St as d,n as f,r as p}from"./DocumentContext-D3zjM2ax.js";import{f as m,i as h,m as g,r as _,t as v}from"./agent-presence-BxT9uQ-C.js";import{a as y,c as b,i as x,o as S,s as C,t as w,x as T}from"./dialog-FUclf-NK.js";import{i as E,n as D,t as O}from"./tooltip-BM5o_T0o.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}=f(),[r,i]=(0,j.useState)(null),[o,s]=(0,j.useState)(`idle`),[c,l]=(0,j.useState)(null),u;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(u=new h(ee),t[0]=u):u=t[0];let d=(0,j.useRef)(u),p=(0,j.useRef)(0),m;t[1]===n?m=t[2]:(m=e=>{let t=p.current+=1;s(`loading`),l(null),te(e).then(r=>{if(p.current!==t)return;let a=ie(n,e);i({...r,writingDocs:a}),s(`ready`)}).catch(e=>{p.current===t&&(l(e instanceof Error?e.message:String(e)),s(`error`))})},t[1]=n,t[2]=m);let g=m,_;t[3]!==e||t[4]!==g?(_=()=>{if(!e){p.current+=1,i(null),s(`idle`),l(null),d.current.clear();return}d.current.clear(),g(e);let t=null,n=a(n=>{n.includes(`session-activity`)&&(t&&clearTimeout(t),t=setTimeout(()=>{t=null,g(e)},M))});return()=>{t&&clearTimeout(t),n()}},t[3]=e,t[4]=g,t[5]=_):_=t[5];let v;t[6]===e?v=t[7]:(v=[e],t[6]=e,t[7]=v),(0,j.useEffect)(_,v);let y,b;t[8]!==e||t[9]!==n?(y=()=>{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)}},b=[e,n],t[8]=e,t[9]=n,t[10]=y,t[11]=b):(y=t[10],b=t[11]),(0,j.useEffect)(y,b);let x;t[12]===e?x=t[13]:(x=async(t,n)=>{if(!e)return``;let r=`${t}\0${n}`,i=d.current.get(r);if(i!==void 0)return i;let a=await N(e,t,n);return d.current.set(r,a),a},t[12]=e,t[13]=x);let S=x,C;t[14]!==e||t[15]!==g?(C=()=>{e&&g(e)},t[14]=e,t[15]=g,t[16]=C):C=t[16];let w=C,T;return t[17]!==r||t[18]!==c||t[19]!==S||t[20]!==w||t[21]!==o?(T={data:r,status:o,error:c,reload:w,fetchBurstDiff:S},t[17]=r,t[18]=c,t[19]=S,t[20]=w,t[21]=o,t[22]=T):T=t[22],T}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(!v(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-C1vRNF09.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),[d,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)(l,{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]!==d||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…`}):d?(0,P.jsxs)(`div`,{className:`px-4 py-2 text-xs text-destructive`,children:[`Failed: `,d]}):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]=d,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:a,onUndoLast:o,onUndoAll:c,fetchBurstDiff:d}=e,[f,p]=(0,j.useState)(!1),[h,g]=(0,j.useState)(!1),[_,v]=(0,j.useState)(!1),[T,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]!==o?(re=e=>{e.stopPropagation(),!N&&(v(!0),Promise.resolve(o(n.docName)).finally(()=>v(!1)))},t[2]=N,t[3]=n.docName,t[4]=o,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]!==c?(ce=()=>{g(!1),!N&&(v(!0),Promise.resolve(c(n.docName)).finally(()=>v(!1)))},t[8]=N,t[9]=n.docName,t[10]=c,t[11]=ce):ce=t[11];let ue=ce,F;t[12]===Symbol.for(`react.memo_cache_sentinel`)?(F=()=>p(de),t[12]=F):F=t[12];let pe=f?`Collapse ${n.docName}`:`Expand ${n.docName}`,I;t[13]===f?I=t[14]:(I=f?(0,P.jsx)(u,{className:`size-4`,"aria-hidden":`true`}):(0,P.jsx)(l,{className:`size-4`,"aria-hidden":`true`}),t[13]=f,t[14]=I);let L;t[15]!==f||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":f,"aria-label":pe,"data-testid":`activity-panel-file-row-carrot`,children:I}),t[15]=f,t[16]=pe,t[17]=I,t[18]=L):L=t[18];let R;t[19]!==n.docName||t[20]!==a?(R=()=>a(n.docName),t[19]=n.docName,t[20]=a,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)(m,{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)(E,{asChild:!0,children:(0,P.jsx)(s,{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)(D,{side:`bottom`,children:_e}),t[31]=_e,t[32]=V);let H;t[33]!==B||t[34]!==V?(H=(0,P.jsxs)(O,{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)(E,{asChild:!0,children:(0,P.jsx)(s,{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)(D,{side:`bottom`,children:xe}),t[41]=xe,t[42]=U);let W;t[43]!==be||t[44]!==U?(W=(0,P.jsxs)(O,{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]!==T?(J=le(n.lastTs,T),t[53]=n.lastTs,t[54]=T,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]!==f||t[69]!==d||t[70]!==n.bursts||t[71]!==n.docName?(Q=f?(0,P.jsx)(`div`,{children:n.bursts.map(e=>(0,P.jsx)(se,{burst:e,docName:n.docName,fetchBurstDiff:d},`${n.docName}:${e.stackIndex}`))}):null,t[68]=f,t[69]=d,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)(b,{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)(C,{children:[Se,(0,P.jsxs)(y,{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)(s,{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)(S,{children:[Ee,(0,P.jsx)(s,{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)(x,{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)(w,{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)(d,{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)(c,{className:`size-6 text-destructive`,"aria-hidden":`true`}),t[0]=i):i=t[0];let a;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(a=(0,P.jsx)(`p`,{className:`text-sm font-medium`,children:`Failed to load activity`}),t[1]=a):a=t[1];let o;t[2]===n?o=t[3]:(o=(0,P.jsxs)(`div`,{className:`space-y-1`,children:[a,(0,P.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:n})]}),t[2]=n,t[3]=o);let l;t[4]===r?l=t[5]:(l=(0,P.jsx)(s,{type:`button`,variant:`outline`,size:`sm`,onClick:r,children:`Retry`}),t[4]=r,t[5]=l);let u;return t[6]!==o||t[7]!==l?(u=(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,o,l]}),t[6]=o,t[7]=l,t[8]=u):u=t[8],u}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)(g,{}),t[0]=r):r=t[0];let i;t[1]===n?i=t[2]:(i=(0,P.jsx)(E,{asChild:!0,children:(0,P.jsx)(s,{type:`button`,variant:`ghost`,size:`icon`,className:`size-7 shrink-0`,onClick:n,"aria-label":`Back to document view`,"data-testid":`docpanel-exit-agent-mode`,children:r})}),t[1]=n,t[2]=i);let a;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(a=(0,P.jsx)(D,{side:`bottom`,children:`Back to document view`}),t[3]=a):a=t[3];let o;return t[4]===i?o=t[5]:(o=(0,P.jsxs)(O,{children:[i,a]}),t[4]=i,t[5]=o),o}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)(_,{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}=f(),{openDocumentTransition:r}=p(),{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);T.error(`Undo failed: ${n}`),s()}},e[4]=i,e[5]=t,e[6]=s,e[7]=d):d=e[7];let m=d,h;e[8]!==i||e[9]!==t||e[10]!==s?(h=async e=>{try{await F({connectionId:t,docName:e,scope:`file`,agentName:i?.agent?.displayName}),T.success(`Undone all edits on ${e}`),s()}catch(e){let t=e,n=t instanceof Error?t.message:String(t);T.error(`Undo all failed: ${n}`),s()}},e[8]=i,e[9]=t,e[10]=s,e[11]=h):h=e[11];let g=h,_;return e[12]!==n||e[13]!==i||e[14]!==o||e[15]!==c||e[16]!==u||e[17]!==g||e[18]!==m||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:m,onUndoAll:g}),e[12]=n,e[13]=i,e[14]=o,e[15]=c,e[16]=u,e[17]=g,e[18]=m,e[19]=s,e[20]=a,e[21]=_):_=e[21],_}export{ve as ActivityModeContent};
|