@inkeep/open-knowledge 0.5.0-beta.21 → 0.5.0-beta.23
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/assets/skills/open-knowledge/SKILL.md +1 -1
- package/dist/{banner-DdbR6AZr.mjs → banner-KC_FjiUK.mjs} +1 -1
- package/dist/cli.mjs +42 -41
- package/dist/constants-UznaWgKW.mjs +2 -0
- package/dist/{dist-Be0To_ZO.mjs → dist-C2u-rxF1.mjs} +1 -1
- package/dist/{dist-pXZHJhkA.mjs → dist-CibAeq--.mjs} +2 -2
- package/dist/index.mjs +1 -1
- package/dist/init-9f8VdHd7.mjs +1 -0
- package/dist/{init-DzR46fd1.mjs → init-BtC2SMv8.mjs} +6 -6
- package/dist/loader-ChlCdDN9.mjs +1 -0
- package/dist/{loader-DwNW79Kd.mjs → loader-D-WyaDzc.mjs} +2 -2
- package/dist/{open-browser-BOeCxs2W.mjs → open-browser-Be-7qaQ9.mjs} +1 -1
- package/dist/{preview-xvI7NDqX.mjs → preview-87-KFMPd.mjs} +2 -2
- package/dist/preview-D5HXmkil.mjs +1 -0
- package/dist/public/assets/ActivityModeContent-4zLTqVCC.js +2 -0
- package/dist/public/assets/{DocumentContext-YWII9sVm.js → DocumentContext-mhvvV02u.js} +10 -10
- package/dist/public/assets/{GraphPanel-BmhccH_K.js → GraphPanel-BGdpuLXE.js} +3 -3
- package/dist/public/assets/{SettingsDialog-BLylznoD.js → SettingsDialog-YV23t38c.js} +2 -2
- package/dist/public/assets/{SourceEditor-Bi21q-DL.js → SourceEditor-CZ1jZux8.js} +1 -1
- package/dist/public/assets/{config-validation-events-Dnk5hVFm.js → config-validation-events-B8ssr9T7.js} +3 -3
- package/dist/public/assets/{doc-hash-D0E42f7E.js → doc-hash-CGOOAxMs.js} +1 -1
- package/dist/public/assets/index-Dem5cTAO.js +1853 -0
- package/dist/public/assets/{target-navigation-intent-B2g_ui3h.js → target-navigation-intent-B4Stg_GZ.js} +1 -1
- package/dist/public/assets/{toggle-group-CPBWIRG3.js → toggle-group-FOEgJa6h.js} +1 -1
- package/dist/public/assets/{tooltip-Cbd9CeO5.js → tooltip-1yQ0AYa7.js} +1 -1
- package/dist/public/assets/{typing-burst-detector-B0_5HYmy.js → typing-burst-detector-CPAaH_c3.js} +2 -2
- package/dist/public/index.html +8 -8
- package/dist/repair-launch-json-JMXFIk5a.mjs +2 -0
- package/dist/repair-mcp-configs-Bay0Zqru.mjs +2 -0
- package/dist/src-B_Y-6c9W.mjs +2 -0
- package/dist/start--xgfEslo.mjs +3 -0
- package/dist/start-Dc0l88_T.mjs +1 -0
- package/package.json +1 -1
- package/dist/constants-E3p7nhGa.mjs +0 -2
- package/dist/init-DRNhMBUZ.mjs +0 -1
- package/dist/loader-C13KhFbm.mjs +0 -1
- package/dist/preview-B6LY5kDY.mjs +0 -1
- package/dist/public/assets/ActivityModeContent-BS4JoRCC.js +0 -2
- package/dist/public/assets/index-p0rA34CH.js +0 -1853
- package/dist/repair-mcp-configs-BE_1I-Cj.mjs +0 -2
- package/dist/src-Dbjmbz2J.mjs +0 -2
- package/dist/start-CFVMbPig.mjs +0 -1
- package/dist/start-Cv7sP3Zd.mjs +0 -3
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{Jr as e,f as t,fi as n,ji as r,qr as i,vi as a}from"./dist-
|
|
1
|
+
import{Jr as e,f as t,fi as n,ji as r,qr as i,vi as a}from"./dist-CibAeq--.mjs";import{t as o}from"./constants-UznaWgKW.mjs";import{t as s}from"./is-object-DF0ZeuvD.mjs";import{resolve as c}from"node:path";import{existsSync as l,readFileSync as u}from"node:fs";import{realpath as d}from"node:fs/promises";async function f(e){let t=c(e);try{return await d(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}}var p=r();function m(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]=m(i,a):a!==void 0&&(n[r]=a)}return n}function h(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,p.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}}const g=[`include`,`exclude`];function _(e){let t="Run `ok config migrate` to strip the obsolete key from config.yml automatically, or remove it by hand.";return e===`exclude`?[`Move these patterns to .okignore at the project root (gitignore syntax, 1:1 migration).`,t].join(` `):[`content.include has been removed.`,`For subdirectory scoping, set content.dir in .ok/config.yml instead.`,`For pattern-based filtering, use .okignore (gitignore syntax — exclude-only; do not copy include patterns directly).`,t].join(` `)}function v(e){let t=e.value;if(!s(t))return[];let n=t.content;if(!s(n))return[];let r=[];for(let t of g)if(t in n){let n=[`content`,t],i;e.doc!==null&&e.source!==null&&(i=a({file:e.path,source:e.source,doc:e.doc,path:n})),r.push({code:`REMOVED_KEY`,path:n,redirect:_(t),...i===void 0?{}:{source:i}})}return r}function y(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=a({file:t.path,source:t.source,doc:t.doc,path:n});if(e!==void 0)return{...r,source:e}}return r})}function b(r){let a=r??process.cwd(),s=[],l=e(`user`,a),u=i({absPath:l}),d={};u.valid&&u.source!==void 0?(d=m(d,u.value),s.push(l)):u.valid;let f=c(a,`.ok`,o),p=h(f);if(p.value!==null){let e=v(p);if(e.length>0)throw Error(e.map(n).join(`
|
|
2
2
|
|
|
3
3
|
`));d=m(d,p.value),s.push(f)}x(d,[`upload`,`maxBytes`],`streaming uploads have no user-facing cap`),x(d,[`github`,`oauthAppClientId`],`use the OPEN_KNOWLEDGE_GITHUB_CLIENT_ID env var instead`),x(d,[`server`,`host`],`use the --host flag or HOST env var instead`),x(d,[`server`,`openOnAgentEdit`]),x(d,[`mcp`,`autoStart`],`to disable auto-start, set OK_MCP_AUTOSTART=0`),x(d,[`mcp`,`tools`,`read_document`,`historyDepth`]),x(d,[`mcp`,`tools`,`grep`,`maxResults`]),x(d,[`mcp`,`tools`,`search`,`maxResults`]),x(d,[`preview`,`baseUrl`],"preview URLs now resolve only to the running UI process — start one with `ok ui`");let g=t.safeParse(d);if(!g.success){let e={code:`SCHEMA_INVALID`,issues:y(g.error.issues,p)};throw Error(n(e))}return{config:g.data,sources:s}}function x(e,t,n){let r=e;for(let e=0;e<t.length-1;e++){if(!s(r))return;r=r[t[e]]}if(!s(r))return;let i=t[t.length-1];if(r[i]===void 0)return;let a=t.join(`.`);console.warn(`[config] ${a} is no longer user-configurable; ${n??`the value is hardcoded in @inkeep/open-knowledge-core`}. Remove the key to silence this warning.`)}function S(e){let t=e.cacheMs??1e3,n=e.loadConfigFn??b,r=new Map,i=new Map,a=f(e.startupCwd);return async o=>{let s=await f(o??e.startupCwd),c=Date.now(),l=r.get(s);if(l&&l.expiresAt>c)return l.config;let u=i.get(s);if(u)return await u;let d=(async()=>{if(s===await a)return r.set(s,{config:e.startupConfig,expiresAt:Date.now()+t}),e.startupConfig;let i=n(s).config;return r.set(s,{config:i,expiresAt:Date.now()+t}),i})();i.set(s,d);try{return await d}finally{i.delete(s)}}}export{b as n,S as t};
|
|
4
|
-
//# sourceMappingURL=loader-
|
|
4
|
+
//# sourceMappingURL=loader-D-WyaDzc.mjs.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import{execFile as e}from"node:child_process";const t=new Set([`http:`,`https:`]),n=/[\u0000-\u0020\u007F-\u009F"'`\\&|<>^()$;{}[\]*?!~]/;function r(e,t){console.warn(`Could not auto-open browser (${t}); visit ${e} manually`)}function i(i){let a;try{a=new URL(i)}catch{r(i,`invalid URL`);return}if(!t.has(a.protocol)){r(i,`unsupported scheme '${a.protocol}'`);return}if(n.test(i)){r(i,`URL contains unsafe characters`);return}e(process.platform===`darwin`?`open`:process.platform===`win32`?`cmd`:`xdg-open`,process.platform===`win32`?[`/c`,`start`,``,i]:[i],e=>{e&&console.warn(`Could not auto-open browser (${e.message}); visit ${i} manually`)})}export{i as openBrowser};
|
|
2
|
-
//# sourceMappingURL=open-browser-
|
|
2
|
+
//# sourceMappingURL=open-browser-Be-7qaQ9.mjs.map
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import{Ct as e}from"./dist-
|
|
1
|
+
import{Ct as e}from"./dist-CibAeq--.mjs";import"./constants-UznaWgKW.mjs";import{join as t,relative as n}from"node:path";import{existsSync as r,lstatSync as i,readdirSync as a,realpathSync as o,statSync as s}from"node:fs";function c(r){let{projectDir:c,contentDir:l,sampleCap:u=5}=r,d=[],f=[];try{i(l)}catch(e){return{totalCount:0,sample:[],contentDir:l,warnings:[`cannot access content directory ${l}: ${e instanceof Error?e.message:String(e)}`]}}let p;try{p=e({projectDir:c,contentDir:l})}catch(e){return{totalCount:0,sample:[],contentDir:l,warnings:[e instanceof Error?e.message:String(e)]}}function m(e){let r;try{r=a(e,{withFileTypes:!0})}catch(t){let r=t instanceof Error?t.message:String(t);d.push(`could not read directory ${n(l,e)||`.`}: ${r}`);return}for(let i of r){let r=t(e,i.name);if(i.isSymbolicLink()){let e;try{e=o(r)}catch(e){let t=e.code;t===`ENOENT`||t===`ELOOP`?d.push(`broken or cyclic symlink: ${n(l,r)}`):d.push(`cannot resolve symlink ${n(l,r)}: ${t??`unknown error`}`);continue}let t;try{t=s(e)}catch{continue}if(t.isDirectory()){let e=n(l,r);if(p.isDirExcluded(e))continue;m(r)}else if(t.isFile()){let e=n(l,r);if(p.isExcluded(e))continue;f.push(e)}}else if(i.isDirectory()){let e=n(l,r);if(p.isDirExcluded(e))continue;m(r)}else if(i.isFile()){let e=n(l,r);if(p.isExcluded(e))continue;f.push(e)}}}return m(l),{totalCount:f.length,sample:f.slice(0,u),contentDir:l,warnings:d}}function l(e,i){let a=[],o=n(i,e.contentDir),s=o===``?`./`:`./${o}`;if(a.push(`Content:`),a.push(` Found ${e.totalCount} markdown files in ${s}`),e.sample.length>0){let t=e.sample.join(`, `),n=e.totalCount>e.sample.length?`, …`:``;a.push(` Sample: ${t}${n}`)}if(e.warnings.length>0)for(let t of e.warnings)a.push(` Warning: ${t}`);return a.push(``),r(t(i,`.ok`,`config.yml`))?(a.push(` To adjust scope, add patterns to .okignore at the project root.`),a.push(` To change the content root, edit .ok/config.yml → content.dir.`)):a.push(" Run `open-knowledge init` to scaffold config + .okignore."),a.push(``),a.push(` Re-check anytime: open-knowledge preview`),a.join(`
|
|
2
2
|
`)}export{c as n,l as t};
|
|
3
|
-
//# sourceMappingURL=preview-
|
|
3
|
+
//# sourceMappingURL=preview-87-KFMPd.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{n as e,t}from"./preview-87-KFMPd.mjs";export{t as formatPreviewBlock,e as previewContent};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./ActivityPanelDiffView-EaCFURAu.js","./chunk-CFjPhJqf.js","./compiler-runtime-CVnuRdak.js","./ActivityPanelDiffView-legcy4jI.css"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{o as e}from"./chunk-CFjPhJqf.js";import{t}from"./preload-helper-2ej06EnG.js";import{n,r,t as i}from"./compiler-runtime-CVnuRdak.js";import{Mn as a,Nn as o,Z as s,hn as c,jn as l,n as u,r as d}from"./DocumentContext-mhvvV02u.js";import{J as f,Pt as p,h as m,q as h}from"./doc-hash-CGOOAxMs.js";import{C as g,t as _}from"./button-jHkzz0kg.js";import{f as v,i as y,m as b,r as x,t as S}from"./agent-presence-C9zIlaSm.js";import{a as C,c as w,i as T,o as E,s as D,t as O,x as k}from"./dialog-aTGC_OHs.js";import{i as A,n as ee,t as te}from"./tooltip-1yQ0AYa7.js";var ne=g(`rewind`,[[`path`,{d:`M12 6a2 2 0 0 0-3.414-1.414l-6 6a2 2 0 0 0 0 2.828l6 6A2 2 0 0 0 12 18z`,key:`2a1g8i`}],[`path`,{d:`M22 6a2 2 0 0 0-3.414-1.414l-6 6a2 2 0 0 0 0 2.828l6 6A2 2 0 0 0 22 18z`,key:`rg3s36`}]]),j=i(),M=e(n(),1),re=500,ie=64;async function ae(e){let t=`/api/agent-activity?agentId=${encodeURIComponent(e)}`,n=await fetch(t),r;try{r=await n.json()}catch(e){throw new s(`Could not parse /api/agent-activity response.`,{cause:e,status:n.status})}if(!n.ok){let e=p.safeParse(r);throw e.success?Error(e.data.title):new s(`/api/agent-activity returned a non-RFC-9457 error response.`,{cause:e.error,status:n.status})}let i=h.safeParse(r);if(!i.success)throw new s(`/api/agent-activity returned a body that did not match AgentActivitySuccessSchema.`,{cause:i.error,status:n.status});return i.data}async function oe(e,t,n){let r=`/api/agent-burst-diff?agentId=${encodeURIComponent(e)}&docName=${encodeURIComponent(t)}&stackIndex=${n}`,i=await fetch(r),a;try{a=await i.json()}catch(e){throw new s(`Could not parse /api/agent-burst-diff response.`,{cause:e,status:i.status})}if(!i.ok){let e=p.safeParse(a);throw e.success?Error(e.data.title):new s(`/api/agent-burst-diff returned a non-RFC-9457 error response.`,{cause:e.error,status:i.status})}let o=f.safeParse(a);if(!o.success)throw new s(`/api/agent-burst-diff returned a body that did not match AgentBurstDiffSuccessSchema.`,{cause:o.error,status:i.status});return o.data.diff}function se(e){let t=(0,j.c)(23),{systemProvider:n}=u(),[r,i]=(0,M.useState)(null),[a,o]=(0,M.useState)(`idle`),[s,c]=(0,M.useState)(null),l;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(l=new y(ie),t[0]=l):l=t[0];let d=(0,M.useRef)(l),f=(0,M.useRef)(0),p;t[1]===n?p=t[2]:(p=e=>{let t=f.current+=1;o(`loading`),c(null),ae(e).then(r=>{if(f.current!==t)return;let a=le(n,e);i({...r,writingDocs:a}),o(`ready`)}).catch(e=>{f.current===t&&(c(e instanceof Error?e.message:String(e)),o(`error`))})},t[1]=n,t[2]=p);let h=p,g;t[3]!==e||t[4]!==h?(g=()=>{if(!e){f.current+=1,i(null),o(`idle`),c(null),d.current.clear();return}d.current.clear(),h(e);let t=null,n=m(n=>{n.includes(`session-activity`)&&(t&&clearTimeout(t),t=setTimeout(()=>{t=null,h(e)},re))});return()=>{t&&clearTimeout(t),n()}},t[3]=e,t[4]=h,t[5]=g):g=t[5];let _;t[6]===e?_=t[7]:(_=[e],t[6]=e,t[7]=_),(0,M.useEffect)(g,_);let v,b;t[8]!==e||t[9]!==n?(v=()=>{if(!e||!n)return;let t=()=>{if(!n.awareness)return;let t=le(n,e);i(e=>!e||ce(e.writingDocs,t)?e:{...e,writingDocs:t})},r=n.awareness;if(!r||typeof r.on!=`function`){t();return}r.on(`update`,t),t();let a=setInterval(t,1e3);return()=>{clearInterval(a),typeof r.off==`function`&&r.off(`update`,t)}},b=[e,n],t[8]=e,t[9]=n,t[10]=v,t[11]=b):(v=t[10],b=t[11]),(0,M.useEffect)(v,b);let x;t[12]===e?x=t[13]:(x=async(t,n)=>{if(!e)return``;let r=`${t}\0${n}`,i=d.current.get(r);if(i!==void 0)return i;let a=await oe(e,t,n);return d.current.set(r,a),a},t[12]=e,t[13]=x);let S=x,C;t[14]!==e||t[15]!==h?(C=()=>{e&&h(e)},t[14]=e,t[15]=h,t[16]=C):C=t[16];let w=C,T;return t[17]!==r||t[18]!==s||t[19]!==S||t[20]!==w||t[21]!==a?(T={data:r,status:a,error:s,reload:w,fetchBurstDiff:S},t[17]=r,t[18]=s,t[19]=S,t[20]=w,t[21]=a,t[22]=T):T=t[22],T}function ce(e,t){if(e.size!==t.size)return!1;for(let n of e)if(!t.has(n))return!1;return!0}function le(e,t){let n=new Set;if(!e)return n;let r=e.awareness;if(!S(r))return n;let i=[t,t.startsWith(`agent-`)?t.slice(6):`agent-${t}`];for(let e of r.getStates().values()){let t=e.agentPresence;if(t)for(let e of i){let r=t[e];r&&r.mode===`writing`&&r.currentDoc&&n.add(r.currentDoc)}}return n}var N=r(),ue=(0,M.lazy)(async()=>({default:(await t(()=>import(`./ActivityPanelDiffView-EaCFURAu.js`),__vite__mapDeps([0,1,2,3]),import.meta.url)).ActivityPanelDiffView}));function de(e,t){let n=Math.max(0,t-e);return n<6e4?`${Math.round(n/1e3)}s ago`:n<36e5?`${Math.round(n/6e4)}m ago`:new Date(e).toLocaleTimeString(void 0,{hour:`2-digit`,minute:`2-digit`,second:`2-digit`})}function fe(e){let t=(0,j.c)(38),{burst:n,docName:r,fetchBurstDiff:i}=e,[s,c]=(0,M.useState)(!1),[l,u]=(0,M.useState)(null),[d,f]=(0,M.useState)(null),[p,m]=(0,M.useState)(!1),[h,g]=(0,M.useState)(P),_,v;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(_=()=>{let e=setInterval(()=>g(Date.now()),3e4);return()=>clearInterval(e)},v=[],t[0]=_,t[1]=v):(_=t[0],v=t[1]),(0,M.useEffect)(_,v);let y;t[2]!==n.stackIndex||t[3]!==l||t[4]!==r||t[5]!==s||t[6]!==i||t[7]!==p?(y=()=>{let e=!s;c(e),e&&l===null&&!p&&(m(!0),f(null),i(r,n.stackIndex).then(e=>{u(e),m(!1)}).catch(e=>{f(e instanceof Error?e.message:String(e)),m(!1)}))},t[2]=n.stackIndex,t[3]=l,t[4]=r,t[5]=s,t[6]=i,t[7]=p,t[8]=y):y=t[8];let b=y,x=`${s?`Collapse`:`Expand`} burst ${n.stackIndex+1} diff`,S;t[9]===s?S=t[10]:(S=s?(0,N.jsx)(o,{className:`size-3 shrink-0`,"aria-hidden":`true`}):(0,N.jsx)(a,{className:`size-3 shrink-0`,"aria-hidden":`true`}),t[9]=s,t[10]=S);let C;t[11]!==n.ts||t[12]!==h?(C=de(n.ts,h),t[11]=n.ts,t[12]=h,t[13]=C):C=t[13];let w;t[14]===C?w=t[15]:(w=(0,N.jsx)(`span`,{className:`font-mono`,children:C}),t[14]=C,t[15]=w);let T;t[16]===n.additions?T=t[17]:(T=(0,N.jsxs)(`span`,{className:`text-green-600 dark:text-green-400`,children:[`+`,n.additions]}),t[16]=n.additions,t[17]=T);let E;t[18]===n.deletions?E=t[19]:(E=(0,N.jsxs)(`span`,{className:`text-red-600 dark:text-red-400`,children:[`−`,n.deletions]}),t[18]=n.deletions,t[19]=E);let D;t[20]!==T||t[21]!==E?(D=(0,N.jsxs)(`span`,{className:`ml-auto font-mono`,children:[T,` `,E]}),t[20]=T,t[21]=E,t[22]=D):D=t[22];let O;t[23]!==s||t[24]!==D||t[25]!==x||t[26]!==S||t[27]!==w||t[28]!==b?(O=(0,N.jsxs)(`button`,{type:`button`,onClick:b,className:`flex w-full items-center gap-2 px-4 py-1.5 text-xs text-muted-foreground hover:bg-muted/40`,"aria-expanded":s,"aria-label":x,children:[S,w,D]}),t[23]=s,t[24]=D,t[25]=x,t[26]=S,t[27]=w,t[28]=b,t[29]=O):O=t[29];let k;t[30]!==l||t[31]!==s||t[32]!==d||t[33]!==p?(k=s?(0,N.jsx)(`div`,{className:`bg-muted/20`,children:p?(0,N.jsx)(`div`,{className:`px-4 py-2 text-xs text-muted-foreground italic`,children:`Loading diff`}):d?(0,N.jsxs)(`div`,{className:`px-4 py-2 text-xs text-destructive`,children:[`Failed: `,d]}):l===null?(0,N.jsx)(`div`,{className:`px-4 py-2 text-xs text-muted-foreground italic`,children:`No diff.`}):(0,N.jsx)(M.Suspense,{fallback:(0,N.jsx)(`div`,{className:`px-4 py-2 text-xs text-muted-foreground italic`,children:`Loading diff`}),children:(0,N.jsx)(ue,{diff:l})})}):null,t[30]=l,t[31]=s,t[32]=d,t[33]=p,t[34]=k):k=t[34];let A;return t[35]!==O||t[36]!==k?(A=(0,N.jsxs)(`div`,{className:`border-t border-border/50`,children:[O,k]}),t[35]=O,t[36]=k,t[37]=A):A=t[37],A}function P(){return Date.now()}function pe(e,t){let n=Math.max(0,t-e);return n<6e4?`${Math.round(n/1e3)}s ago`:n<36e5?`${Math.round(n/6e4)}m ago`:`${Math.round(n/36e5)}h ago`}function F(e){let t=(0,j.c)(93),{file:n,sessionAlive:r,isWriting:i,onNavigate:s,onUndoLast:c,onUndoAll:l,fetchBurstDiff:u}=e,[d,f]=(0,M.useState)(!1),[p,m]=(0,M.useState)(!1),[h,g]=(0,M.useState)(!1),[y,b]=(0,M.useState)(he),x,S;if(t[0]===Symbol.for(`react.memo_cache_sentinel`)?(x=()=>{let e=setInterval(()=>b(Date.now()),3e4);return()=>clearInterval(e)},S=[],t[0]=x,t[1]=S):(x=t[0],S=t[1]),(0,M.useEffect)(x,S),n.bursts.length===0)return null;let k=!r||n.bursts.length===0||h,re=r?n.bursts.length===0?`Nothing to undo on this file`:null:`Session ended — undo unavailable`,ie;t[2]!==k||t[3]!==n.docName||t[4]!==c?(ie=e=>{e.stopPropagation(),!k&&(g(!0),Promise.resolve(c(n.docName)).finally(()=>g(!1)))},t[2]=k,t[3]=n.docName,t[4]=c,t[5]=ie):ie=t[5];let ae=ie,oe;t[6]===k?oe=t[7]:(oe=e=>{e.stopPropagation(),!k&&m(!0)},t[6]=k,t[7]=oe);let se=oe,ce;t[8]!==k||t[9]!==n.docName||t[10]!==l?(ce=()=>{m(!1),!k&&(g(!0),Promise.resolve(l(n.docName)).finally(()=>g(!1)))},t[8]=k,t[9]=n.docName,t[10]=l,t[11]=ce):ce=t[11];let le=ce,ue;t[12]===Symbol.for(`react.memo_cache_sentinel`)?(ue=()=>f(me),t[12]=ue):ue=t[12];let de=d?`Collapse ${n.docName}`:`Expand ${n.docName}`,P;t[13]===d?P=t[14]:(P=d?(0,N.jsx)(o,{className:`size-4`,"aria-hidden":`true`}):(0,N.jsx)(a,{className:`size-4`,"aria-hidden":`true`}),t[13]=d,t[14]=P);let F;t[15]!==d||t[16]!==de||t[17]!==P?(F=(0,N.jsx)(`button`,{type:`button`,onClick:ue,className:`flex size-5 shrink-0 items-center justify-center rounded hover:bg-muted`,"aria-expanded":d,"aria-label":de,"data-testid":`activity-panel-file-row-carrot`,children:P}),t[15]=d,t[16]=de,t[17]=P,t[18]=F):F=t[18];let I;t[19]!==n.docName||t[20]!==s?(I=()=>s(n.docName),t[19]=n.docName,t[20]=s,t[21]=I):I=t[21];let ge=`Navigate to ${n.docName}`,L;t[22]!==n.docName||t[23]!==I||t[24]!==ge?(L=(0,N.jsx)(`button`,{type:`button`,onClick:I,className:`min-w-0 flex-1 truncate text-left text-foreground hover:underline focus-visible:outline-ring`,"aria-label":ge,"data-testid":`activity-panel-file-row-filename`,title:n.docName,children:n.docName}),t[22]=n.docName,t[23]=I,t[24]=ge,t[25]=L):L=t[25];let _e=`Undo last edit on ${n.docName}`,ve;t[26]===Symbol.for(`react.memo_cache_sentinel`)?(ve=(0,N.jsx)(v,{className:`size-3.5`,"aria-hidden":`true`}),t[26]=ve):ve=t[26];let R;t[27]!==k||t[28]!==ae||t[29]!==_e?(R=(0,N.jsx)(A,{asChild:!0,children:(0,N.jsx)(_,{type:`button`,variant:`ghost`,size:`icon`,className:`size-6 shrink-0`,onClick:ae,disabled:k,"aria-label":_e,"data-testid":`activity-panel-undo-last`,children:ve})}),t[27]=k,t[28]=ae,t[29]=_e,t[30]=R):R=t[30];let ye=re??`Undo last edit`,z;t[31]===ye?z=t[32]:(z=(0,N.jsx)(ee,{side:`bottom`,children:ye}),t[31]=ye,t[32]=z);let B;t[33]!==R||t[34]!==z?(B=(0,N.jsxs)(te,{children:[R,z]}),t[33]=R,t[34]=z,t[35]=B):B=t[35];let be=`Undo all edits on ${n.docName}`,xe;t[36]===Symbol.for(`react.memo_cache_sentinel`)?(xe=(0,N.jsx)(ne,{className:`size-3.5`,"aria-hidden":`true`}),t[36]=xe):xe=t[36];let V;t[37]!==k||t[38]!==se||t[39]!==be?(V=(0,N.jsx)(A,{asChild:!0,children:(0,N.jsx)(_,{type:`button`,variant:`ghost`,size:`icon`,className:`size-6 shrink-0`,onClick:se,disabled:k,"aria-label":be,"data-testid":`activity-panel-undo-all`,children:xe})}),t[37]=k,t[38]=se,t[39]=be,t[40]=V):V=t[40];let Se=re??`Undo all edits`,H;t[41]===Se?H=t[42]:(H=(0,N.jsx)(ee,{side:`bottom`,children:Se}),t[41]=Se,t[42]=H);let U;t[43]!==V||t[44]!==H?(U=(0,N.jsxs)(te,{children:[V,H]}),t[43]=V,t[44]=H,t[45]=U):U=t[45];let W;t[46]===n.additionsTotal?W=t[47]:(W=(0,N.jsxs)(`span`,{className:`text-green-600 dark:text-green-400`,children:[`+`,n.additionsTotal]}),t[46]=n.additionsTotal,t[47]=W);let G;t[48]===n.deletionsTotal?G=t[49]:(G=(0,N.jsxs)(`span`,{className:`text-red-600 dark:text-red-400`,children:[`−`,n.deletionsTotal]}),t[48]=n.deletionsTotal,t[49]=G);let K;t[50]!==W||t[51]!==G?(K=(0,N.jsxs)(`span`,{className:`shrink-0 font-mono text-xs`,children:[W,` `,G]}),t[50]=W,t[51]=G,t[52]=K):K=t[52];let q;t[53]!==n.lastTs||t[54]!==y?(q=pe(n.lastTs,y),t[53]=n.lastTs,t[54]=y,t[55]=q):q=t[55];let J;t[56]===q?J=t[57]:(J=(0,N.jsx)(`span`,{className:`shrink-0 font-mono text-[11px] text-muted-foreground`,children:q}),t[56]=q,t[57]=J);let Y;t[58]===i?Y=t[59]:(Y=i?(0,N.jsx)(`span`,{className:`shrink-0 text-[11px] text-primary animate-pulse`,role:`status`,children:`writing`}):null,t[58]=i,t[59]=Y);let X;t[60]!==L||t[61]!==B||t[62]!==U||t[63]!==K||t[64]!==J||t[65]!==Y||t[66]!==F?(X=(0,N.jsxs)(`div`,{className:`flex items-center gap-2 px-3 py-2 text-sm`,children:[F,L,B,U,K,J,Y]}),t[60]=L,t[61]=B,t[62]=U,t[63]=K,t[64]=J,t[65]=Y,t[66]=F,t[67]=X):X=t[67];let Z;t[68]!==d||t[69]!==u||t[70]!==n.bursts||t[71]!==n.docName?(Z=d?(0,N.jsx)(`div`,{children:n.bursts.map(e=>(0,N.jsx)(fe,{burst:e,docName:n.docName,fetchBurstDiff:u},`${n.docName}:${e.stackIndex}`))}):null,t[68]=d,t[69]=u,t[70]=n.bursts,t[71]=n.docName,t[72]=Z):Z=t[72];let Ce;t[73]===Symbol.for(`react.memo_cache_sentinel`)?(Ce=(0,N.jsx)(w,{children:`Undo all edits on this file?`}),t[73]=Ce):Ce=t[73];let Q;t[74]===n.docName?Q=t[75]:(Q=(0,N.jsx)(`span`,{className:`font-mono text-foreground`,children:n.docName}),t[74]=n.docName,t[75]=Q);let we=n.bursts.length===1?``:`s`,Te;t[76]!==n.bursts.length||t[77]!==Q||t[78]!==we?(Te=(0,N.jsxs)(D,{children:[Ce,(0,N.jsxs)(C,{children:[`This will revert every change this agent has made to`,` `,Q,` in their current session (`,n.bursts.length,` burst`,we,`). Other files and other writers are not affected.`]})]}),t[76]=n.bursts.length,t[77]=Q,t[78]=we,t[79]=Te):Te=t[79];let Ee;t[80]===Symbol.for(`react.memo_cache_sentinel`)?(Ee=(0,N.jsx)(_,{type:`button`,variant:`outline`,onClick:()=>m(!1),"data-testid":`activity-panel-undo-all-cancel`,children:`Cancel`}),t[80]=Ee):Ee=t[80];let De;t[81]===le?De=t[82]:(De=(0,N.jsxs)(E,{children:[Ee,(0,N.jsx)(_,{type:`button`,variant:`destructive`,onClick:le,"data-testid":`activity-panel-undo-all-confirm`,children:`Undo all`})]}),t[81]=le,t[82]=De);let Oe;t[83]!==Te||t[84]!==De?(Oe=(0,N.jsxs)(T,{className:`sm:max-w-md`,children:[Te,De]}),t[83]=Te,t[84]=De,t[85]=Oe):Oe=t[85];let $;t[86]!==p||t[87]!==Oe?($=(0,N.jsx)(O,{open:p,onOpenChange:m,children:Oe}),t[86]=p,t[87]=Oe,t[88]=$):$=t[88];let ke;return t[89]!==X||t[90]!==Z||t[91]!==$?(ke=(0,N.jsxs)(`div`,{className:`border-b border-border`,"data-testid":`activity-panel-file-row`,children:[X,Z,$]}),t[89]=X,t[90]=Z,t[91]=$,t[92]=ke):ke=t[92],ke}function me(e){return!e}function he(){return Date.now()}async function I(e){let t=await fetch(`/api/agent-undo`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({...e,agentId:e.connectionId})});if(!t.ok)throw Error(`agent-undo failed: HTTP ${t.status}`)}function ge(e){return`#/${e.split(`/`).map(e=>encodeURIComponent(e)).join(`/`)}`}function L(e){typeof window>`u`||(window.location.hash=ge(e))}function _e(){let e=(0,j.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,N.jsxs)(`div`,{className:`flex h-full items-center justify-center p-6 text-muted-foreground`,role:`status`,"aria-busy":`true`,children:[(0,N.jsx)(c,{className:`mr-2 size-4 animate-spin`,"aria-hidden":`true`}),(0,N.jsx)(`span`,{className:`text-sm`,children:`Loading agent activity`})]}),e[0]=t):t=e[0],t}function ve(e){let t=(0,j.c)(9),{error:n,onRetry:r}=e,i;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(i=(0,N.jsx)(l,{className:`size-6 text-destructive`,"aria-hidden":`true`}),t[0]=i):i=t[0];let a;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(a=(0,N.jsx)(`p`,{className:`text-sm font-medium`,children:`Failed to load activity`}),t[1]=a):a=t[1];let o;t[2]===n?o=t[3]:(o=(0,N.jsxs)(`div`,{className:`space-y-1`,children:[a,(0,N.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:n})]}),t[2]=n,t[3]=o);let s;t[4]===r?s=t[5]:(s=(0,N.jsx)(_,{type:`button`,variant:`outline`,size:`sm`,onClick:r,children:`Retry`}),t[4]=r,t[5]=s);let c;return t[6]!==o||t[7]!==s?(c=(0,N.jsxs)(`div`,{className:`flex flex-col items-center gap-3 p-6 text-center`,role:`alert`,"data-testid":`activity-panel-error`,children:[i,o,s]}),t[6]=o,t[7]=s,t[8]=c):c=t[8],c}function R(){let e=(0,j.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,N.jsx)(`div`,{className:`flex h-full items-center justify-center p-6 text-muted-foreground`,"data-testid":`activity-panel-empty`,children:(0,N.jsx)(`p`,{className:`text-sm italic`,children:`No edits yet.`})}),e[0]=t):t=e[0],t}function ye(e){let t=(0,j.c)(8),{onExit:n}=e,r;t[0]===n?r=t[1]:(r=(0,N.jsx)(z,{onClick:n}),t[0]=n,t[1]=r);let i;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(i=(0,N.jsx)(`h2`,{className:`truncate text-sm font-medium`,children:`Agent activity`}),t[2]=i):i=t[2];let a;t[3]===r?a=t[4]:(a=(0,N.jsxs)(`div`,{className:`flex shrink-0 flex-row items-center gap-2 border-b border-border px-3 py-2`,children:[r,i]}),t[3]=r,t[4]=a);let o;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(o=(0,N.jsx)(`div`,{className:`flex flex-1 items-center justify-center p-6 text-muted-foreground`,children:(0,N.jsx)(`p`,{className:`text-center text-sm italic`,children:`Click an agent's avatar in the presence bar to view their session.`})}),t[5]=o):o=t[5];let s;return t[6]===a?s=t[7]:(s=(0,N.jsxs)(`section`,{className:`flex h-full min-h-0 flex-col`,"data-testid":`activity-panel-no-agent`,"aria-label":`Agent activity`,children:[a,o]}),t[6]=a,t[7]=s),s}function z(e){let t=(0,j.c)(6),{onClick:n}=e,r;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(r=(0,N.jsx)(b,{}),t[0]=r):r=t[0];let i;t[1]===n?i=t[2]:(i=(0,N.jsx)(A,{asChild:!0,children:(0,N.jsx)(_,{type:`button`,variant:`ghost`,size:`icon`,className:`size-7 shrink-0`,onClick:n,"aria-label":`Back to document view`,"data-testid":`docpanel-exit-agent-mode`,children:r})}),t[1]=n,t[2]=i);let a;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(a=(0,N.jsx)(ee,{side:`bottom`,children:`Back to document view`}),t[3]=a):a=t[3];let o;return t[4]===i?o=t[5]:(o=(0,N.jsxs)(te,{children:[i,a]}),t[4]=i,t[5]=o),o}function B(e){let t=(0,j.c)(9),{lastTs:n}=e,[r]=(0,M.useState)(be),i;t[0]!==n||t[1]!==r?(i=n?xe(r-n):null,t[0]=n,t[1]=r,t[2]=i):i=t[2];let a=i,o;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(o=(0,N.jsx)(`span`,{className:`font-medium`,children:`Session ended`}),t[3]=o):o=t[3];let s;t[4]===a?s=t[5]:(s=a?(0,N.jsxs)(`span`,{children:[` · `,a]}):null,t[4]=a,t[5]=s);let c;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(c=(0,N.jsx)(`div`,{className:`mt-1 opacity-80`,children:`Undo buttons are disabled — per-session state has been garbage-collected.`}),t[6]=c):c=t[6];let l;return t[7]===s?l=t[8]:(l=(0,N.jsxs)(`div`,{className:`border-b border-border bg-muted/40 px-4 py-3 text-xs text-muted-foreground`,"data-testid":`activity-panel-session-ended`,children:[o,s,c]}),t[7]=s,t[8]=l),l}function be(){return Date.now()}function xe(e){let t=Math.max(0,e);return t<6e4?`${Math.round(t/1e3)}s ago`:t<36e5?`${Math.round(t/6e4)}m ago`:`${Math.round(t/36e5)}h ago`}function V(e){let t=(0,j.c)(10),{agent:n,size:r}=e,i=r===void 0?28:r,a;t[0]!==n.color||t[1]!==i?(a={backgroundColor:n.color,width:i,height:i},t[0]=n.color,t[1]=i,t[2]=a):a=t[2];let o=i*.57,s=i*.57,c;t[3]!==n.icon||t[4]!==o||t[5]!==s?(c=(0,N.jsx)(x,{icon:n.icon,width:o,height:s}),t[3]=n.icon,t[4]=o,t[5]=s,t[6]=c):c=t[6];let l;return t[7]!==a||t[8]!==c?(l=(0,N.jsx)(`span`,{className:`inline-flex shrink-0 items-center justify-center rounded-full text-white ring-2 ring-background`,style:a,"aria-hidden":`true`,children:c}),t[7]=a,t[8]=c,t[9]=l):l=t[9],l}function Se(e){let t=(0,j.c)(21),{data:n,status:r,error:i,reload:a,fetchBurstDiff:o,onExit:s,onNavigate:c,onUndoLast:l,onUndoAll:u}=e,d=n?.files?.[0]?.lastTs??null,f;t[0]===s?f=t[1]:(f=(0,N.jsx)(z,{onClick:s}),t[0]=s,t[1]=f);let p;t[2]!==n||t[3]!==d?(p=n?.agent?(0,N.jsxs)(N.Fragment,{children:[(0,N.jsx)(V,{agent:n.agent}),(0,N.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,N.jsx)(`h2`,{className:`truncate text-sm font-medium`,children:n.agent.displayName}),(0,N.jsxs)(`p`,{className:`truncate text-xs text-muted-foreground`,children:[n.sessionAlive?`Active`:d===null?`No edit session yet`:`Ended`,n.files.length>0?` · ${n.files.length} file${n.files.length===1?``:`s`}`:``]})]})]}):(0,N.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,N.jsx)(`h2`,{className:`truncate text-sm font-medium`,children:`Agent activity`})}),t[2]=n,t[3]=d,t[4]=p):p=t[4];let m;t[5]!==f||t[6]!==p?(m=(0,N.jsxs)(`div`,{className:`flex flex-row items-center gap-2 border-b border-border px-3 py-2 shrink-0`,children:[f,p]}),t[5]=f,t[6]=p,t[7]=m):m=t[7];let h;t[8]!==n||t[9]!==i||t[10]!==o||t[11]!==d||t[12]!==c||t[13]!==u||t[14]!==l||t[15]!==a||t[16]!==r?(h=(0,N.jsx)(`div`,{className:`flex-1 overflow-y-auto`,"data-testid":`activity-panel-body`,children:r===`loading`&&n===null?(0,N.jsx)(_e,{}):r===`error`&&i?(0,N.jsx)(ve,{error:i,onRetry:a}):n===null?(0,N.jsx)(R,{}):(0,N.jsxs)(N.Fragment,{children:[!n.sessionAlive&&d!==null?(0,N.jsx)(B,{lastTs:d}):null,n.files.length===0?(0,N.jsx)(R,{}):n.files.map(e=>(0,N.jsx)(F,{file:e,sessionAlive:n.sessionAlive,isWriting:n.writingDocs.has(e.docName),onNavigate:c,onUndoLast:l,onUndoAll:u,fetchBurstDiff:o},e.docName))]})}),t[8]=n,t[9]=i,t[10]=o,t[11]=d,t[12]=c,t[13]=u,t[14]=l,t[15]=a,t[16]=r,t[17]=h):h=t[17];let g;return t[18]!==m||t[19]!==h?(g=(0,N.jsxs)(`section`,{className:`flex h-full min-h-0 flex-col`,"data-testid":`activity-panel`,"aria-label":`Agent activity`,children:[m,h]}),t[18]=m,t[19]=h,t[20]=g):g=t[20],g}function H(){let e=(0,j.c)(22),{docPanelAgentId:t,closeActivityPanel:n}=u(),{openDocumentTransition:r}=d(),{data:i,status:a,error:o,reload:s,fetchBurstDiff:c}=se(t);if(t===null){let t;return e[0]===n?t=e[1]:(t=(0,N.jsx)(ye,{onExit:n}),e[0]=n,e[1]=t),t}let l;e[2]===r?l=e[3]:(l=e=>{r(e),L(e)},e[2]=r,e[3]=l);let f=l,p;e[4]!==i||e[5]!==t||e[6]!==s?(p=async e=>{try{await I({connectionId:t,docName:e,scope:`last`,agentName:i?.agent?.displayName}),s()}catch(e){let t=e,n=t instanceof Error?t.message:String(t);k.error(`Undo failed: ${n}`),s()}},e[4]=i,e[5]=t,e[6]=s,e[7]=p):p=e[7];let m=p,h;e[8]!==i||e[9]!==t||e[10]!==s?(h=async e=>{try{await I({connectionId:t,docName:e,scope:`file`,agentName:i?.agent?.displayName}),k.success(`Undone all edits on ${e}`),s()}catch(e){let t=e,n=t instanceof Error?t.message:String(t);k.error(`Undo all failed: ${n}`),s()}},e[8]=i,e[9]=t,e[10]=s,e[11]=h):h=e[11];let g=h,_;return e[12]!==n||e[13]!==i||e[14]!==o||e[15]!==c||e[16]!==f||e[17]!==g||e[18]!==m||e[19]!==s||e[20]!==a?(_=(0,N.jsx)(Se,{data:i,status:a,error:o,reload:s,fetchBurstDiff:c,onExit:n,onNavigate:f,onUndoLast:m,onUndoAll:g}),e[12]=n,e[13]=i,e[14]=o,e[15]=c,e[16]=f,e[17]=g,e[18]=m,e[19]=s,e[20]=a,e[21]=_):_=e[21],_}export{H as ActivityModeContent};
|