@rubytech/create-realagent 1.0.650 → 1.0.651

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rubytech/create-realagent",
3
- "version": "1.0.650",
3
+ "version": "1.0.651",
4
4
  "description": "Install Real Agent — Built for agents. By agents.",
5
5
  "bin": {
6
6
  "create-realagent": "./dist/index.js"
@@ -25,12 +25,18 @@
25
25
  // "selector drift" from "empty account" — both shapes arrive via
26
26
  // stdout).
27
27
 
28
+ import { appendFileSync } from "node:fs";
28
29
  import { writeFile } from "node:fs/promises";
29
30
  import { resolve } from "node:path";
30
31
  import { homedir } from "node:os";
31
32
 
32
- const CDP_HOST = "127.0.0.1";
33
- const CDP_PORT = 9222;
33
+ // CDP host/port default to the VNC Chromium's localhost bind; env overrides
34
+ // exist solely so the vitest regression under platform/ui/__tests__ can force
35
+ // a deterministic ECONNREFUSED (point at 127.0.0.1:1 — RFC 6335 reserved,
36
+ // guaranteed-refused on every platform) without depending on whether a dev
37
+ // machine happens to have VNC Chromium running on 9222.
38
+ const CDP_HOST = process.env.LIST_CF_DOMAINS_CDP_HOST ?? "127.0.0.1";
39
+ const CDP_PORT = Number(process.env.LIST_CF_DOMAINS_CDP_PORT ?? 9222);
34
40
 
35
41
  // Phase budgets total 30s (enforced by the shell wrapper's `timeout`).
36
42
  // Individual steps get sub-budgets so an early stall does not eat the
@@ -50,11 +56,42 @@ type Reason =
50
56
  | "table-wait-timeout"
51
57
  | "runtime-error";
52
58
 
59
+ // Sticky flag: once a stream-log write fails (EACCES, ENOENT, …), skip
60
+ // subsequent file writes for the rest of this process. Repeated appends to an
61
+ // unwritable path would spam stderr with identical `phase=stream-log-write-failed`
62
+ // lines and crowd result.stderr that the route handler regex reads. Losing a
63
+ // log line is strictly better than aborting the scrape — observability failure
64
+ // must not mask the scrape's real signal.
65
+ let streamLogWriteFailed = false;
66
+
53
67
  function logPhase(line: string): void {
54
- // Written to stderr; shell wrapper tees to STREAM_LOG_PATH with timestamp.
55
- // Keeping format parity with `_stream-log.sh phase_line` on the bash side
56
- // means the tailer regex and grepping by `[list-cf-domains]` work uniformly.
68
+ // Stderr: preserved for direct-SSH invocation parity AND for runFormSpawn's
69
+ // in-memory `result.stderr`, which the route handler greps for `reason=<enum>`
70
+ // on non-zero exit. Removing this write would break the form's error-card path.
57
71
  process.stderr.write(`[list-cf-domains] ${line}\n`);
72
+
73
+ // Stream log: direct write by the TS helper (not via wrapper tee) so phase
74
+ // lines reach the per-conversation file the Task 592 tailer reads, even on
75
+ // exit 0 where runFormSpawn discards `result.stderr`. Format parity with
76
+ // `_stream-log.sh phase_line`: `[<ISO-ts>] [<scope>] <content>\n`, asserted
77
+ // by the vitest regression under platform/ui/__tests__. Sync append so the
78
+ // terminal `phase=script-exit code=0 count=N` lands before process exit.
79
+ const streamLogPath = process.env.STREAM_LOG_PATH;
80
+ if (!streamLogPath || streamLogWriteFailed) return;
81
+ try {
82
+ appendFileSync(
83
+ streamLogPath,
84
+ `[${new Date().toISOString()}] [list-cf-domains] ${line}\n`,
85
+ );
86
+ } catch (err) {
87
+ streamLogWriteFailed = true;
88
+ const detail = (err instanceof Error ? err.message : String(err))
89
+ .slice(0, 200)
90
+ .replace(/"/g, "'");
91
+ process.stderr.write(
92
+ `[list-cf-domains] phase=stream-log-write-failed detail="${detail}"\n`,
93
+ );
94
+ }
58
95
  }
59
96
 
60
97
  function die(reason: Reason, detail = ""): never {
@@ -1 +1 @@
1
- import{o as e}from"./chunk-DD-I1_y5.js";import{a as t,n,r,t as i}from"./jsx-runtime-Cb-WunFZ.js";import{a,i as o,n as s,o as c,r as l,t as u}from"./share-2-DkF8neDM.js";import{n as d,t as f}from"./file-CRrDfnO1.js";import{t as p}from"./house-D1CBraxB.js";import{t as m}from"./trash-2-Dde58AAR.js";var h=n(`circle-arrow-up`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`m16 12-4-4-4 4`,key:`177agl`}],[`path`,{d:`M12 16V8`,key:`1sbj14`}]]),g=n(`folder`,[[`path`,{d:`M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z`,key:`1kt360`}]]),_=n(`upload`,[[`path`,{d:`M12 3v12`,key:`1x0j5s`}],[`path`,{d:`m17 8-5-5-5 5`,key:`7q97r8`}],[`path`,{d:`M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4`,key:`ih7n3h`}]]),v=r(),y=e(t(),1),b=i();function x(){let[e,t]=(0,y.useState)(null),[n,r]=(0,y.useState)(!1);return(0,y.useEffect)(()=>{try{t(sessionStorage.getItem(`maxy-admin-session-key`))}catch{t(null)}r(!0)},[]),n?e?(0,b.jsxs)(`div`,{className:`data-page`,children:[(0,b.jsxs)(`header`,{className:`data-header`,children:[(0,b.jsxs)(`h1`,{className:`data-title`,children:[(0,b.jsx)(c,{size:18}),` Data`]}),(0,b.jsx)(S,{})]}),(0,b.jsxs)(`main`,{className:`data-main`,children:[(0,b.jsx)(C,{sessionKey:e}),(0,b.jsx)(O,{sessionKey:e})]})]}):(0,b.jsxs)(`div`,{className:`data-page`,children:[(0,b.jsx)(`header`,{className:`data-header`,children:(0,b.jsxs)(`h1`,{className:`data-title`,children:[(0,b.jsx)(c,{size:18}),` Data`]})}),(0,b.jsxs)(`div`,{className:`data-empty`,children:[(0,b.jsx)(`p`,{children:`You are not signed in.`}),(0,b.jsxs)(`p`,{children:[`Open the `,(0,b.jsx)(`a`,{href:`/`,className:`data-link`,children:`main admin page`}),` and log in, then return here.`]})]})]}):(0,b.jsx)(`div`,{className:`data-page`,children:(0,b.jsxs)(`div`,{className:`data-loading`,children:[(0,b.jsx)(a,{size:18,className:`spin`}),` Loading…`]})})}function S(){let[e,t]=(0,y.useState)(!1),n=(0,y.useRef)(null);(0,y.useEffect)(()=>{if(!e)return;let r=e=>{n.current&&(n.current.contains(e.target)||t(!1))},i=e=>{e.key===`Escape`&&t(!1)};return document.addEventListener(`mousedown`,r),document.addEventListener(`keydown`,i),()=>{document.removeEventListener(`mousedown`,r),document.removeEventListener(`keydown`,i)}},[e]);let r=(0,y.useCallback)(()=>{try{sessionStorage.removeItem(`maxy-admin-session-key`)}catch{}window.location.href=`/`},[]);return(0,b.jsxs)(`div`,{className:`chat-burger-wrap`,ref:n,children:[(0,b.jsx)(`button`,{type:`button`,className:`chat-burger`,onClick:()=>t(e=>!e),"aria-label":`Menu`,"aria-haspopup":`true`,"aria-expanded":e,children:(0,b.jsx)(l,{size:20})}),e&&(0,b.jsxs)(`div`,{className:`chat-menu`,children:[(0,b.jsxs)(`button`,{type:`button`,className:`chat-menu-item`,onClick:()=>{t(!1),window.location.href=`/`},children:[(0,b.jsx)(p,{size:14}),` Chat`]}),(0,b.jsxs)(`button`,{type:`button`,className:`chat-menu-item`,onClick:()=>{t(!1),window.location.href=`/graph`},children:[(0,b.jsx)(u,{size:14}),` Graph`]}),(0,b.jsx)(`div`,{className:`chat-menu-divider`}),(0,b.jsxs)(`button`,{type:`button`,className:`chat-menu-item`,onClick:()=>{t(!1),r()},children:[(0,b.jsx)(o,{size:14}),` Log out`]})]})]})}function C({sessionKey:e}){let[t,n]=(0,y.useState)(``),[r,i]=(0,y.useState)(``),[o,c]=(0,y.useState)(null),[l,u]=(0,y.useState)(!1),[d,f]=(0,y.useState)(null);return(0,y.useEffect)(()=>{let e=t.trim();if(!e){i(``),c(null);return}let n=setTimeout(()=>i(e),300);return()=>clearTimeout(n)},[t]),(0,y.useEffect)(()=>{if(!r)return;let t=!1;u(!0),f(null);let n=`/api/admin/graph-search?session_key=${encodeURIComponent(e)}&q=${encodeURIComponent(r)}&limit=20`;return fetch(n).then(async e=>{let t=await e.json().catch(()=>({error:`HTTP ${e.status}`}));if(!e.ok)throw Error(t.error??`HTTP ${e.status}`);return t}).then(e=>{t||c(e.results)}).catch(e=>{t||f(e instanceof Error?e.message:String(e))}).finally(()=>{t||u(!1)}),()=>{t=!0}},[r,e]),(0,b.jsxs)(`section`,{className:`data-panel`,children:[(0,b.jsx)(`h2`,{className:`data-panel-title`,children:`Search`}),(0,b.jsx)(`p`,{className:`data-panel-subtitle`,children:`Find anything in your knowledge base by keyword.`}),(0,b.jsxs)(`div`,{className:`data-search-input`,children:[(0,b.jsx)(s,{size:14}),(0,b.jsx)(`input`,{type:`text`,placeholder:`Search your knowledge…`,value:t,onChange:e=>n(e.target.value),autoFocus:!0,autoComplete:`off`,spellCheck:!1}),l&&(0,b.jsx)(a,{size:14,className:`spin`})]}),d&&(0,b.jsxs)(`div`,{className:`data-error`,children:[`Search failed: `,d]}),o&&!l&&(0,b.jsxs)(`div`,{className:`data-results-meta`,children:[o.length,` result`,o.length===1?``:`s`]}),o&&o.length===0&&!l&&(0,b.jsx)(`div`,{className:`data-empty-results`,children:`No matches. Try a different keyword.`}),o&&o.length>0&&(0,b.jsx)(`ul`,{className:`data-results`,children:o.map(e=>(0,b.jsx)(w,{hit:e},e.nodeId))})]})}function w({hit:e}){let t=E(e.properties),n=D(e.properties),r=T(e.labels),[i,a]=(0,y.useState)(!1),o=n&&n.length>280,s=i||!o?n:n?.slice(0,280)+`…`;return(0,b.jsxs)(`li`,{className:`data-result`,children:[r&&(0,b.jsx)(`div`,{className:`data-result-header`,children:(0,b.jsx)(`span`,{className:`data-result-labels`,children:r})}),t&&(0,b.jsx)(`div`,{className:`data-result-title`,children:t}),n&&(0,b.jsx)(`pre`,{className:`data-result-body`,children:s}),o&&(0,b.jsx)(`button`,{type:`button`,className:`data-result-toggle`,onClick:()=>a(e=>!e),children:i?`Show less`:`Show more`})]})}function T(e){if(e.length===0)return null;let t=e[0].replace(/([a-z])([A-Z])/g,`$1 $2`);return t.charAt(0).toUpperCase()+t.slice(1).toLowerCase()}function E(e){for(let t of[`title`,`name`,`summary`,`headline`]){let n=e[t];if(typeof n==`string`&&n.length>0)return n.length>140?n.slice(0,140)+`…`:n}return null}function D(e){for(let t of[`content`,`summary`,`body`,`description`,`text`]){let n=e[t];if(typeof n==`string`&&n.length>0)return n}return null}function O({sessionKey:e}){let[t,n]=(0,y.useState)(`.`),[r,i]=(0,y.useState)(null),[o,s]=(0,y.useState)([]),[c,l]=(0,y.useState)(!1),[u,p]=(0,y.useState)(null),[v,x]=(0,y.useState)(!1),[S,C]=(0,y.useState)(null),[w,T]=(0,y.useState)(null),[E,D]=(0,y.useState)(null),O=(0,y.useRef)(null),[j,M]=(0,y.useState)(0);(0,y.useEffect)(()=>{let n=!1;l(!0),p(null);let r=`/api/admin/files?session_key=${encodeURIComponent(e)}&path=${encodeURIComponent(t===`.`?``:t)}`;return fetch(r).then(async e=>{let t=await e.json().catch(()=>({error:`HTTP ${e.status}`}));if(!e.ok)throw Error(t.error??`HTTP ${e.status}`);return t}).then(e=>{n||(i(e.entries),s(e.displayPath??[]))}).catch(e=>{n||(i([]),s([]),p(e instanceof Error?e.message:String(e)))}).finally(()=>{n||l(!1)}),()=>{n=!0}},[e,t,j]);let N=(0,y.useCallback)(e=>{n(e)},[]),P=(0,y.useCallback)(()=>{if(t===`.`||t===``)return;let e=t.split(`/`).filter(Boolean);e.pop(),n(e.length===0?`.`:e.join(`/`))},[t]),F=(0,y.useCallback)(n=>{let r=t===`.`?n.name:`${t}/${n.name}`,i=`/api/admin/files/download?session_key=${encodeURIComponent(e)}&path=${encodeURIComponent(r)}`,a=document.createElement(`a`);a.href=i,a.rel=`noopener noreferrer`,document.body.appendChild(a),a.click(),a.remove()},[t,e]),I=(0,y.useCallback)(()=>{O.current?.click()},[]),L=(0,y.useCallback)(async n=>{let r=n.displayName??n.name;if(!window.confirm(`Delete ${r}?`))return;let i=t===`.`?n.name:`${t}/${n.name}`;T(null),D(n.name);try{let t=`/api/admin/files?session_key=${encodeURIComponent(e)}&path=${encodeURIComponent(i)}`,n=await fetch(t,{method:`DELETE`}),r=await n.json().catch(()=>({error:`HTTP ${n.status}`}));if(!n.ok)throw Error(r.error??`HTTP ${n.status}`);M(e=>e+1)}catch(e){T(e instanceof Error?e.message:String(e))}finally{D(null)}},[t,e]),R=(0,y.useCallback)(async t=>{C(null),x(!0);try{let r=new FormData;r.append(`session_key`,e),r.append(`file`,t);let i=await fetch(`/api/admin/files/upload`,{method:`POST`,body:r}),a=await i.json().catch(()=>({error:`HTTP ${i.status}`}));if(!i.ok)throw Error(a.error??`HTTP ${i.status}`);n(a.path.split(`/`).slice(0,-1).join(`/`)||`.`),M(e=>e+1)}catch(e){C(e instanceof Error?e.message:String(e))}finally{x(!1),O.current&&(O.current.value=``)}},[e]);return(0,b.jsxs)(`section`,{className:`data-panel`,children:[(0,b.jsxs)(`div`,{className:`data-panel-heading`,children:[(0,b.jsx)(`h2`,{className:`data-panel-title`,children:`Files`}),(0,b.jsxs)(`div`,{className:`data-file-actions`,children:[(0,b.jsxs)(`button`,{type:`button`,className:`data-btn`,onClick:I,disabled:v,children:[v?(0,b.jsx)(a,{size:14,className:`spin`}):(0,b.jsx)(_,{size:14}),` Upload`]}),(0,b.jsx)(`input`,{type:`file`,ref:O,hidden:!0,onChange:e=>{let t=e.target.files?.[0];t&&R(t)}})]})]}),(0,b.jsxs)(`p`,{className:`data-panel-subtitle`,children:[`Everything under your install's `,(0,b.jsx)(`code`,{children:`data/`}),` directory. Click a folder to open it, a file to download it. Uploads go to `,(0,b.jsx)(`code`,{children:`data/uploads/`}),`.`]}),(0,b.jsxs)(`div`,{className:`data-breadcrumbs`,children:[(0,b.jsx)(`button`,{type:`button`,className:`data-crumb`,onClick:()=>N(`.`),children:`data`}),o.map((e,t)=>{let n=o.slice(0,t+1).map(e=>e.name).join(`/`);return(0,b.jsxs)(`span`,{className:`data-crumb-wrap`,children:[(0,b.jsx)(`span`,{className:`data-crumb-sep`,children:`/`}),(0,b.jsx)(`button`,{type:`button`,className:`data-crumb`,onClick:()=>N(n),title:e.name,children:e.displayName??e.name})]},n)}),t!==`.`&&(0,b.jsxs)(`button`,{type:`button`,className:`data-btn data-btn-ghost data-up-btn`,onClick:P,children:[(0,b.jsx)(h,{size:14}),` Up`]})]}),S&&(0,b.jsxs)(`div`,{className:`data-error`,children:[`Upload failed: `,S]}),w&&(0,b.jsxs)(`div`,{className:`data-error`,children:[`Delete failed: `,w]}),u&&(0,b.jsx)(`div`,{className:`data-error`,children:u}),c&&(0,b.jsxs)(`div`,{className:`data-loading`,children:[(0,b.jsx)(a,{size:14,className:`spin`}),` Loading…`]}),!c&&r&&r.length===0&&!u&&(0,b.jsx)(`div`,{className:`data-empty-results`,children:`Empty directory.`}),!c&&r&&r.length>0&&(0,b.jsx)(`ul`,{className:`data-entries`,children:r.map(e=>{let n=e.displayName??e.name,r=E===e.name;return(0,b.jsx)(`li`,{className:`data-entry`,children:e.kind===`directory`?(0,b.jsxs)(`button`,{type:`button`,className:`data-entry-btn`,onClick:()=>N(t===`.`?e.name:`${t}/${e.name}`),children:[(0,b.jsx)(g,{size:14}),(0,b.jsx)(`span`,{className:`data-entry-name`,title:e.name,children:n})]}):e.kind===`file`?(0,b.jsxs)(b.Fragment,{children:[(0,b.jsxs)(`button`,{type:`button`,className:`data-entry-btn`,onClick:()=>F(e),title:`Download ${n}`,children:[(0,b.jsx)(f,{size:14}),(0,b.jsx)(`span`,{className:`data-entry-name`,title:e.name,children:n}),(0,b.jsxs)(`span`,{className:`data-entry-meta`,title:`Modified ${A(e.modifiedAt)}`,children:[k(e.sizeBytes),` · `,A(e.modifiedAt)]}),(0,b.jsx)(d,{size:12,className:`data-entry-download-icon`})]}),(0,b.jsx)(`button`,{type:`button`,className:`data-entry-delete`,onClick:()=>L(e),disabled:r,title:`Delete ${n}`,"aria-label":`Delete ${n}`,children:r?(0,b.jsx)(a,{size:14,className:`spin`}):(0,b.jsx)(m,{size:14})})]}):(0,b.jsxs)(`div`,{className:`data-entry-btn data-entry-disabled`,children:[(0,b.jsx)(f,{size:14}),(0,b.jsx)(`span`,{className:`data-entry-name`,children:n}),(0,b.jsx)(`span`,{className:`data-entry-meta`,children:`special`})]})},e.name)})})]})}function k(e){return e==null?``:e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:e<1024*1024*1024?`${(e/1024/1024).toFixed(1)} MB`:`${(e/1024/1024/1024).toFixed(1)} GB`}function A(e){try{let t=new Date(e);if(isNaN(t.getTime()))return`—`;let n=typeof navigator<`u`?navigator.languages&&navigator.languages.length>0?[...navigator.languages]:[navigator.language]:void 0;return t.toLocaleString(n,{dateStyle:`medium`,timeStyle:`short`})}catch{return`—`}}(0,v.createRoot)(document.getElementById(`root`)).render((0,b.jsx)(x,{}));
1
+ import{o as e}from"./chunk-DD-I1_y5.js";import{a as t,n,r,t as i}from"./jsx-runtime-Cb-WunFZ.js";import{a,i as o,n as s,o as c,r as l,t as u}from"./share-2-DkF8neDM.js";import{n as d,t as f}from"./file-CRrDfnO1.js";import{t as p}from"./house-D1CBraxB.js";import{t as m}from"./trash-2-Dde58AAR.js";var h=n(`circle-arrow-up`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`m16 12-4-4-4 4`,key:`177agl`}],[`path`,{d:`M12 16V8`,key:`1sbj14`}]]),g=n(`folder`,[[`path`,{d:`M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z`,key:`1kt360`}]]),_=n(`upload`,[[`path`,{d:`M12 3v12`,key:`1x0j5s`}],[`path`,{d:`m17 8-5-5-5 5`,key:`7q97r8`}],[`path`,{d:`M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4`,key:`ih7n3h`}]]),v=r(),y=e(t(),1),b=i();function x(){let[e,t]=(0,y.useState)(null),[n,r]=(0,y.useState)(!1);return(0,y.useEffect)(()=>{try{t(sessionStorage.getItem(`maxy-admin-session-key`))}catch{t(null)}r(!0)},[]),n?e?(0,b.jsxs)(`div`,{className:`data-page`,children:[(0,b.jsxs)(`header`,{className:`data-header`,children:[(0,b.jsxs)(`h1`,{className:`data-title`,children:[(0,b.jsx)(c,{size:18}),` Data`]}),(0,b.jsx)(S,{})]}),(0,b.jsxs)(`main`,{className:`data-main`,children:[(0,b.jsx)(C,{sessionKey:e}),(0,b.jsx)(O,{sessionKey:e})]})]}):(0,b.jsxs)(`div`,{className:`data-page`,children:[(0,b.jsx)(`header`,{className:`data-header`,children:(0,b.jsxs)(`h1`,{className:`data-title`,children:[(0,b.jsx)(c,{size:18}),` Data`]})}),(0,b.jsxs)(`div`,{className:`data-empty`,children:[(0,b.jsx)(`p`,{children:`You are not signed in.`}),(0,b.jsxs)(`p`,{children:[`Open the `,(0,b.jsx)(`a`,{href:`/`,className:`data-link`,children:`main admin page`}),` and log in, then return here.`]})]})]}):(0,b.jsx)(`div`,{className:`data-page`,children:(0,b.jsxs)(`div`,{className:`data-loading`,children:[(0,b.jsx)(a,{size:18,className:`spin`}),` Loading…`]})})}function S(){let[e,t]=(0,y.useState)(!1),n=(0,y.useRef)(null);(0,y.useEffect)(()=>{if(!e)return;let r=e=>{n.current&&(n.current.contains(e.target)||t(!1))},i=e=>{e.key===`Escape`&&t(!1)};return document.addEventListener(`mousedown`,r),document.addEventListener(`keydown`,i),()=>{document.removeEventListener(`mousedown`,r),document.removeEventListener(`keydown`,i)}},[e]);let r=(0,y.useCallback)(()=>{try{sessionStorage.removeItem(`maxy-admin-session-key`)}catch{}window.location.href=`/`},[]);return(0,b.jsxs)(`div`,{className:`chat-burger-wrap`,ref:n,children:[(0,b.jsx)(`button`,{type:`button`,className:`chat-burger`,onClick:()=>t(e=>!e),"aria-label":`Menu`,"aria-haspopup":`true`,"aria-expanded":e,children:(0,b.jsx)(l,{size:20})}),e&&(0,b.jsxs)(`div`,{className:`chat-menu`,children:[(0,b.jsxs)(`button`,{type:`button`,className:`chat-menu-item`,onClick:()=>{t(!1),window.location.href=`/`},children:[(0,b.jsx)(p,{size:14}),` Chat`]}),(0,b.jsxs)(`button`,{type:`button`,className:`chat-menu-item`,onClick:()=>{t(!1),window.location.href=`/graph`},children:[(0,b.jsx)(u,{size:14}),` Graph`]}),(0,b.jsx)(`div`,{className:`chat-menu-divider`}),(0,b.jsxs)(`button`,{type:`button`,className:`chat-menu-item`,onClick:()=>{t(!1),r()},children:[(0,b.jsx)(o,{size:14}),` Log out`]})]})]})}function C({sessionKey:e}){let[t,n]=(0,y.useState)(``),[r,i]=(0,y.useState)(``),[o,c]=(0,y.useState)(null),[l,u]=(0,y.useState)(!1),[d,f]=(0,y.useState)(null);return(0,y.useEffect)(()=>{let e=t.trim();if(!e){i(``),c(null);return}let n=setTimeout(()=>i(e),300);return()=>clearTimeout(n)},[t]),(0,y.useEffect)(()=>{if(!r)return;let t=!1;u(!0),f(null);let n=`/api/admin/graph-search?session_key=${encodeURIComponent(e)}&q=${encodeURIComponent(r)}&limit=20`;return fetch(n).then(async e=>{let t=await e.json().catch(()=>({error:`HTTP ${e.status}`}));if(!e.ok)throw Error(t.error??`HTTP ${e.status}`);return t}).then(e=>{t||c(e.results)}).catch(e=>{t||f(e instanceof Error?e.message:String(e))}).finally(()=>{t||u(!1)}),()=>{t=!0}},[r,e]),(0,b.jsxs)(`section`,{className:`data-panel`,children:[(0,b.jsx)(`h2`,{className:`data-panel-title`,children:`Search`}),(0,b.jsx)(`p`,{className:`data-panel-subtitle`,children:`Find anything in your knowledge base by keyword.`}),(0,b.jsxs)(`div`,{className:`data-search-input`,children:[(0,b.jsx)(s,{size:14}),(0,b.jsx)(`input`,{type:`text`,placeholder:`Search your knowledge…`,value:t,onChange:e=>n(e.target.value),autoFocus:!0,autoComplete:`off`,spellCheck:!1}),l&&(0,b.jsx)(a,{size:14,className:`spin`})]}),d&&(0,b.jsxs)(`div`,{className:`data-error`,children:[`Search failed: `,d]}),o&&!l&&(0,b.jsxs)(`div`,{className:`data-results-meta`,children:[o.length,` result`,o.length===1?``:`s`]}),o&&o.length===0&&!l&&(0,b.jsx)(`div`,{className:`data-empty-results`,children:`No matches. Try a different keyword.`}),o&&o.length>0&&(0,b.jsx)(`ul`,{className:`data-results`,children:o.map(e=>(0,b.jsx)(w,{hit:e},e.nodeId))})]})}function w({hit:e}){let t=E(e.properties),n=D(e.properties),r=T(e.labels),[i,a]=(0,y.useState)(!1),o=n&&n.length>280,s=i||!o?n:n?.slice(0,280)+`…`;return(0,b.jsxs)(`li`,{className:`data-result`,children:[r&&(0,b.jsx)(`div`,{className:`data-result-header`,children:(0,b.jsx)(`span`,{className:`data-result-labels`,children:r})}),t&&(0,b.jsx)(`div`,{className:`data-result-title`,children:t}),n&&(0,b.jsx)(`pre`,{className:`data-result-body`,children:s}),o&&(0,b.jsx)(`button`,{type:`button`,className:`data-result-toggle`,onClick:()=>a(e=>!e),children:i?`Show less`:`Show more`})]})}function T(e){if(e.length===0)return null;let t=e[0].replace(/([a-z])([A-Z])/g,`$1 $2`);return t.charAt(0).toUpperCase()+t.slice(1).toLowerCase()}function E(e){for(let t of[`title`,`name`,`summary`,`headline`]){let n=e[t];if(typeof n==`string`&&n.length>0)return n.length>140?n.slice(0,140)+`…`:n}return null}function D(e){for(let t of[`content`,`summary`,`body`,`description`,`text`]){let n=e[t];if(typeof n==`string`&&n.length>0)return n}return null}function O({sessionKey:e}){let[t,n]=(0,y.useState)(`.`),[r,i]=(0,y.useState)(null),[o,s]=(0,y.useState)([]),[c,l]=(0,y.useState)(!1),[u,p]=(0,y.useState)(null),[v,x]=(0,y.useState)(!1),[S,C]=(0,y.useState)(null),[w,T]=(0,y.useState)(null),[E,D]=(0,y.useState)(null),[O,j]=(0,y.useState)(null),M=(0,y.useRef)(null),[N,P]=(0,y.useState)(0);(0,y.useEffect)(()=>{let n=!1;l(!0),p(null);let r=`/api/admin/files?session_key=${encodeURIComponent(e)}&path=${encodeURIComponent(t===`.`?``:t)}`;return fetch(r).then(async e=>{let t=await e.json().catch(()=>({error:`HTTP ${e.status}`}));if(!e.ok)throw Error(t.error??`HTTP ${e.status}`);return t}).then(e=>{n||(i(e.entries),s(e.displayPath??[]))}).catch(e=>{n||(i([]),s([]),p(e instanceof Error?e.message:String(e)))}).finally(()=>{n||l(!1)}),()=>{n=!0}},[e,t,N]);let F=(0,y.useCallback)(e=>{n(e)},[]),I=(0,y.useCallback)(()=>{if(t===`.`||t===``)return;let e=t.split(`/`).filter(Boolean);e.pop(),n(e.length===0?`.`:e.join(`/`))},[t]),L=(0,y.useCallback)(n=>{let r=t===`.`?n.name:`${t}/${n.name}`,i=`/api/admin/files/download?session_key=${encodeURIComponent(e)}&path=${encodeURIComponent(r)}`,a=document.createElement(`a`);a.href=i,a.rel=`noopener noreferrer`,document.body.appendChild(a),a.click(),a.remove()},[t,e]),R=(0,y.useCallback)(()=>{M.current?.click()},[]);(0,y.useCallback)(e=>{T(null),j(e.name)},[]),(0,y.useCallback)(()=>{j(null)},[]),(0,y.useCallback)(async n=>{let r=t===`.`?n.name:`${t}/${n.name}`;T(null),j(null),D(n.name);try{let t=`/api/admin/files?session_key=${encodeURIComponent(e)}&path=${encodeURIComponent(r)}`,n=await fetch(t,{method:`DELETE`}),i=await n.json().catch(()=>({error:`HTTP ${n.status}`}));if(!n.ok)throw Error(i.error??`HTTP ${n.status}`);P(e=>e+1)}catch(e){T(e instanceof Error?e.message:String(e))}finally{D(null)}},[t,e]),(0,y.useEffect)(()=>{if(!O)return;let e=e=>{e.key===`Escape`&&j(null)};return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},[O]);let z=(0,y.useCallback)(async t=>{C(null),x(!0);try{let r=new FormData;r.append(`session_key`,e),r.append(`file`,t);let i=await fetch(`/api/admin/files/upload`,{method:`POST`,body:r}),a=await i.json().catch(()=>({error:`HTTP ${i.status}`}));if(!i.ok)throw Error(a.error??`HTTP ${i.status}`);n(a.path.split(`/`).slice(0,-1).join(`/`)||`.`),P(e=>e+1)}catch(e){C(e instanceof Error?e.message:String(e))}finally{x(!1),M.current&&(M.current.value=``)}},[e]);return(0,b.jsxs)(`section`,{className:`data-panel`,children:[(0,b.jsxs)(`div`,{className:`data-panel-heading`,children:[(0,b.jsx)(`h2`,{className:`data-panel-title`,children:`Files`}),(0,b.jsxs)(`div`,{className:`data-file-actions`,children:[(0,b.jsxs)(`button`,{type:`button`,className:`data-btn`,onClick:R,disabled:v,children:[v?(0,b.jsx)(a,{size:14,className:`spin`}):(0,b.jsx)(_,{size:14}),` Upload`]}),(0,b.jsx)(`input`,{type:`file`,ref:M,hidden:!0,onChange:e=>{let t=e.target.files?.[0];t&&z(t)}})]})]}),(0,b.jsxs)(`p`,{className:`data-panel-subtitle`,children:[`Everything under your install's `,(0,b.jsx)(`code`,{children:`data/`}),` directory. Click a folder to open it, a file to download it. Uploads go to `,(0,b.jsx)(`code`,{children:`data/uploads/`}),`.`]}),(0,b.jsxs)(`div`,{className:`data-breadcrumbs`,children:[(0,b.jsx)(`button`,{type:`button`,className:`data-crumb`,onClick:()=>F(`.`),children:`data`}),o.map((e,t)=>{let n=o.slice(0,t+1).map(e=>e.name).join(`/`);return(0,b.jsxs)(`span`,{className:`data-crumb-wrap`,children:[(0,b.jsx)(`span`,{className:`data-crumb-sep`,children:`/`}),(0,b.jsx)(`button`,{type:`button`,className:`data-crumb`,onClick:()=>F(n),title:e.name,children:e.displayName??e.name})]},n)}),t!==`.`&&(0,b.jsxs)(`button`,{type:`button`,className:`data-btn data-btn-ghost data-up-btn`,onClick:I,children:[(0,b.jsx)(h,{size:14}),` Up`]})]}),S&&(0,b.jsxs)(`div`,{className:`data-error`,children:[`Upload failed: `,S]}),w&&(0,b.jsxs)(`div`,{className:`data-error`,children:[`Delete failed: `,w]}),u&&(0,b.jsx)(`div`,{className:`data-error`,children:u}),c&&(0,b.jsxs)(`div`,{className:`data-loading`,children:[(0,b.jsx)(a,{size:14,className:`spin`}),` Loading…`]}),!c&&r&&r.length===0&&!u&&(0,b.jsx)(`div`,{className:`data-empty-results`,children:`Empty directory.`}),!c&&r&&r.length>0&&(0,b.jsx)(`ul`,{className:`data-entries`,children:r.map(e=>{let n=e.displayName??e.name,r=E===e.name;return(0,b.jsx)(`li`,{className:`data-entry`,children:e.kind===`directory`?(0,b.jsxs)(`button`,{type:`button`,className:`data-entry-btn`,onClick:()=>F(t===`.`?e.name:`${t}/${e.name}`),children:[(0,b.jsx)(g,{size:14}),(0,b.jsx)(`span`,{className:`data-entry-name`,title:e.name,children:n})]}):e.kind===`file`?(0,b.jsxs)(b.Fragment,{children:[(0,b.jsxs)(`button`,{type:`button`,className:`data-entry-btn`,onClick:()=>L(e),title:`Download ${n}`,children:[(0,b.jsx)(f,{size:14}),(0,b.jsx)(`span`,{className:`data-entry-name`,title:e.name,children:n}),(0,b.jsxs)(`span`,{className:`data-entry-meta`,title:`Modified ${A(e.modifiedAt)}`,children:[k(e.sizeBytes),` · `,A(e.modifiedAt)]}),(0,b.jsx)(d,{size:12,className:`data-entry-download-icon`})]}),(0,b.jsx)(`button`,{type:`button`,className:`data-entry-delete`,onClick:()=>handleDelete(e),disabled:r,title:`Delete ${n}`,"aria-label":`Delete ${n}`,children:r?(0,b.jsx)(a,{size:14,className:`spin`}):(0,b.jsx)(m,{size:14})})]}):(0,b.jsxs)(`div`,{className:`data-entry-btn data-entry-disabled`,children:[(0,b.jsx)(f,{size:14}),(0,b.jsx)(`span`,{className:`data-entry-name`,children:n}),(0,b.jsx)(`span`,{className:`data-entry-meta`,children:`special`})]})},e.name)})})]})}function k(e){return e==null?``:e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:e<1024*1024*1024?`${(e/1024/1024).toFixed(1)} MB`:`${(e/1024/1024/1024).toFixed(1)} GB`}function A(e){try{let t=new Date(e);if(isNaN(t.getTime()))return`—`;let n=typeof navigator<`u`?navigator.languages&&navigator.languages.length>0?[...navigator.languages]:[navigator.language]:void 0;return t.toLocaleString(n,{dateStyle:`medium`,timeStyle:`short`})}catch{return`—`}}(0,v.createRoot)(document.getElementById(`root`)).render((0,b.jsx)(x,{}));
@@ -5,7 +5,7 @@
5
5
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
6
  <title>Data — Maxy</title>
7
7
  <link rel="icon" href="/favicon.ico">
8
- <script type="module" crossorigin src="/assets/data-BajF3t1i.js"></script>
8
+ <script type="module" crossorigin src="/assets/data-C-b1pXeA.js"></script>
9
9
  <link rel="modulepreload" crossorigin href="/assets/chunk-DD-I1_y5.js">
10
10
  <link rel="modulepreload" crossorigin href="/assets/jsx-runtime-Cb-WunFZ.js">
11
11
  <link rel="modulepreload" crossorigin href="/assets/share-2-DkF8neDM.js">