tracer-sh 0.2.4 → 0.2.5

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": "tracer-sh",
3
- "version": "0.2.4",
3
+ "version": "0.2.5",
4
4
  "type": "module",
5
5
  "description": "Local-first debugging & analysis platform",
6
6
  "license": "SEE LICENSE IN LICENSE",
@@ -16556,6 +16556,14 @@ var ImportedAnalysisSchema = external_exports.object({
16556
16556
  parts: external_exports.array(external_exports.looseObject({ type: external_exports.string() })).max(200)
16557
16557
  });
16558
16558
 
16559
+ // ../shared/src/feature-flags.ts
16560
+ var FEATURES = {
16561
+ /** Dashboard page with grid widgets. */
16562
+ dashboards: false,
16563
+ /** Monitor page with alerting. */
16564
+ monitors: false
16565
+ };
16566
+
16559
16567
  // src/config.ts
16560
16568
  var CONFIG = {
16561
16569
  /** HTTP server port. Override with TRACER_PORT env var. */
@@ -20472,6 +20480,8 @@ chmodSync(TRACER_HOME, 448);
20472
20480
  chmodSync(dataDir, 448);
20473
20481
  var sqlite = new Database(join2(dataDir, "tracer.db"));
20474
20482
  sqlite.pragma("journal_mode = WAL");
20483
+ sqlite.pragma("synchronous = NORMAL");
20484
+ sqlite.pragma("busy_timeout = 5000");
20475
20485
  sqlite.pragma("foreign_keys = ON");
20476
20486
  var db = drizzle(sqlite, { schema: schema_exports });
20477
20487
 
@@ -57559,6 +57569,7 @@ No observability providers are currently configured. If the user asks about obse
57559
57569
  });
57560
57570
  const title = sessionTitle(enrichedMessages);
57561
57571
  const now2 = unixNow();
57572
+ const messagesJson = JSON.stringify(enrichedMessages);
57562
57573
  recordAgentRun(context2.db, {
57563
57574
  sessionId,
57564
57575
  agentType: "chat",
@@ -57568,7 +57579,7 @@ No observability providers are currently configured. If the user asks about obse
57568
57579
  context2.db.insert(chatSessions).values({
57569
57580
  id: sessionId,
57570
57581
  title,
57571
- messages: JSON.stringify(enrichedMessages),
57582
+ messages: messagesJson,
57572
57583
  status: "done",
57573
57584
  createdAt: now2,
57574
57585
  updatedAt: now2
@@ -57576,7 +57587,7 @@ No observability providers are currently configured. If the user asks about obse
57576
57587
  target: chatSessions.id,
57577
57588
  set: {
57578
57589
  title: sql`CASE WHEN ${chatSessions.title} = ${DEFAULT_SESSION_TITLE} THEN ${title} ELSE ${chatSessions.title} END`,
57579
- messages: JSON.stringify(enrichedMessages),
57590
+ messages: messagesJson,
57580
57591
  status: sql`CASE WHEN ${chatSessions.status} = 'idle' THEN 'idle' ELSE 'done' END`,
57581
57592
  updatedAt: now2
57582
57593
  }
@@ -58731,24 +58742,31 @@ function mountStaticFiles(app) {
58731
58742
  const webRoot = webCandidates.find((d) => existsSync(resolve3(d, "index.html")));
58732
58743
  if (!webRoot) return;
58733
58744
  const indexHtml = readFileSync4(resolve3(webRoot, "index.html"), "utf-8");
58745
+ const fileCache = /* @__PURE__ */ new Map();
58734
58746
  app.use("*", async (c, next) => {
58735
58747
  const reqPath = c.req.path.slice(1);
58736
58748
  if (!reqPath) {
58737
58749
  await next();
58738
58750
  return;
58739
58751
  }
58740
- const filePath = resolve3(webRoot, reqPath);
58741
- if (filePath.startsWith(webRoot) && existsSync(filePath) && !statSync(filePath).isDirectory()) {
58752
+ let file2 = fileCache.get(reqPath);
58753
+ if (!file2) {
58754
+ const filePath = resolve3(webRoot, reqPath);
58755
+ if (!filePath.startsWith(webRoot) || !existsSync(filePath) || statSync(filePath).isDirectory()) {
58756
+ await next();
58757
+ return;
58758
+ }
58742
58759
  const mime = MIME_TYPES[extname(filePath)] || "application/octet-stream";
58743
58760
  const headers = { "Content-Type": mime };
58744
58761
  if (reqPath.startsWith("assets/")) {
58745
58762
  headers["Cache-Control"] = "public, max-age=31536000, immutable";
58746
58763
  }
58747
- return c.body(readFileSync4(filePath), { headers });
58764
+ file2 = { body: readFileSync4(filePath), headers };
58765
+ fileCache.set(reqPath, file2);
58748
58766
  }
58749
- await next();
58767
+ return c.body(file2.body, { headers: file2.headers });
58750
58768
  });
58751
- app.get("*", (c) => c.html(indexHtml));
58769
+ app.get("*", (c) => c.html(indexHtml, 200, { "Cache-Control": "no-cache" }));
58752
58770
  }
58753
58771
 
58754
58772
  // src/http/app.ts
@@ -58892,8 +58910,8 @@ async function main() {
58892
58910
  });
58893
58911
  const context2 = createContext({ db, providers });
58894
58912
  const app = createApp(context2);
58895
- const scheduler = new MonitorScheduler(db, providers);
58896
- scheduler.start();
58913
+ const scheduler = FEATURES.monitors ? new MonitorScheduler(db, providers) : null;
58914
+ scheduler?.start();
58897
58915
  const server = serve({ fetch: app.fetch, port: CONFIG.port, hostname: CONFIG.host }, (info) => {
58898
58916
  console.log(`Tracer server running on http://localhost:${info.port}`);
58899
58917
  });
@@ -58907,7 +58925,7 @@ Port ${CONFIG.port} is already in use. Run: lsof -ti :${CONFIG.port} | xargs kil
58907
58925
  });
58908
58926
  const shutdown = async (code = 0) => {
58909
58927
  const timeout = setTimeout(() => process.exit(code === 0 ? 1 : code), CONFIG.shutdownGracePeriodMs);
58910
- await scheduler.stop();
58928
+ await scheduler?.stop();
58911
58929
  for (const p of providers.getAllProviders()) {
58912
58930
  await p.dispose().catch(() => {
58913
58931
  });
@@ -1 +1 @@
1
- import{a as q,r as s,j as r}from"./index-DqPm6rps.js";var P=q();function $(c){const n=c?`tracer:starred:${c}`:null,[i,S]=s.useState(()=>{if(!n)return new Set;try{const a=localStorage.getItem(n);return a?new Set(JSON.parse(a)):new Set}catch{return new Set}});return[i,a=>{S(u=>{const t=new Set(u);return t.has(a)?t.delete(a):t.add(a),n&&localStorage.setItem(n,JSON.stringify([...t])),t})}]}function I({options:c,value:n,onChange:i,placeholder:S="Select...",storageKey:v,fitContent:a,disabled:u}){const[t,l]=s.useState(!1),[w,y]=s.useState(""),f=s.useRef(null),j=s.useRef(null),N=s.useRef(null),g=s.useRef(null),[x,C]=$(v),[m,L]=s.useState({top:0,left:0,minWidth:0});s.useEffect(()=>{if(!t)return;const e=d=>{f.current?.contains(d.target)||j.current?.contains(d.target)||l(!1)};return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[t]);const R=s.useCallback(()=>{if(!f.current)return;const e=f.current.getBoundingClientRect();L({top:e.bottom+4,left:e.left,minWidth:e.width})},[]);s.useEffect(()=>{t&&(R(),y(""),requestAnimationFrame(()=>N.current?.focus()))},[t,R]);const h=c.find(e=>e.value===n),p=s.useMemo(()=>{const e=w.toLowerCase();return[...e?c.filter(o=>o.label.toLowerCase().includes(e)||o.value.toLowerCase().includes(e)):c].sort((o,b)=>{const k=x.has(o.value)?0:1,E=x.has(b.value)?0:1;return k!==E?k-E:o.label.localeCompare(b.label)})},[c,w,x]);s.useEffect(()=>{if(t&&n&&g.current){const e=g.current.querySelector(`[data-value="${CSS.escape(n)}"]`);e&&e.scrollIntoView({block:"nearest"})}},[t,n]);const W=t?P.createPortal(r.jsxs("div",{ref:j,className:"fixed z-[100] bg-white border border-[#d4d2cd] rounded shadow-lg",style:{top:m.top,left:m.left,minWidth:m.minWidth,width:a?"max-content":m.minWidth},children:[r.jsx("div",{className:"p-1.5 border-b border-[#e8e6e1]",children:r.jsx("input",{ref:N,type:"text",value:w,onChange:e=>y(e.target.value),placeholder:"Search...",className:"w-full px-2 py-1.5 text-xs text-[#2c2c2c] font-sans bg-[#f5f4f0] border border-[#e8e6e1] rounded focus:outline-none focus:border-[#2b5ea7] placeholder:text-[#9c9890]",onKeyDown:e=>{e.key==="Escape"&&l(!1),e.key==="Enter"&&p.length>0&&(i(p[0].value),l(!1))}})}),r.jsx("div",{ref:g,className:"max-h-[280px] overflow-y-auto",children:p.length===0?r.jsx("div",{className:"px-3 py-3 text-xs text-[#9c9890] text-center",children:"No projects found"}):p.map(e=>{const d=e.value===n,o=x.has(e.value);return r.jsxs("div",{"data-value":e.value,className:`flex items-center gap-1.5 px-2 py-1.5 text-xs font-sans cursor-pointer transition-colors ${d?"bg-[#2b5ea7]/10 text-[#2b5ea7]":"text-[#2c2c2c] hover:bg-[#f5f4f0]"}`,onClick:()=>{i(e.value),l(!1)},children:[r.jsx("button",{type:"button",onClick:b=>{b.stopPropagation(),C(e.value)},className:`shrink-0 w-4 h-4 flex items-center justify-center text-[10px] transition-colors ${o?"text-[#d4a017]":"text-[#d4d2cd] hover:text-[#9c9890]"}`,title:o?"Unstar":"Star to pin to top",children:o?"★":"☆"}),r.jsx("span",{className:a?"whitespace-nowrap":"truncate flex-1",children:e.label})]},e.value)})})]}),document.body):null;return r.jsxs(r.Fragment,{children:[r.jsxs("button",{ref:f,type:"button",onClick:()=>!u&&l(!t),disabled:u,className:"w-full bg-white border border-[#d4d2cd] rounded px-3 py-2 text-xs text-[#2c2c2c] font-sans text-left flex items-center justify-between focus:outline-none focus:border-[#2b5ea7] hover:border-[#b0ada6] transition-colors disabled:opacity-50 disabled:cursor-not-allowed",children:[r.jsx("span",{className:h?"text-[#2c2c2c] truncate":"text-[#9c9890]",children:h?h.displayLabel??h.label:S}),r.jsx("span",{className:"text-[#9c9890] text-[10px] ml-2 shrink-0 transition-transform duration-200",style:{transform:t?"rotate(180deg)":"rotate(0deg)"},children:"▾"})]}),W]})}export{I as S,P as r,$ as u};
1
+ import{a as q,r as s,j as r}from"./index-B7y1naN3.js";var P=q();function $(c){const n=c?`tracer:starred:${c}`:null,[i,S]=s.useState(()=>{if(!n)return new Set;try{const a=localStorage.getItem(n);return a?new Set(JSON.parse(a)):new Set}catch{return new Set}});return[i,a=>{S(u=>{const t=new Set(u);return t.has(a)?t.delete(a):t.add(a),n&&localStorage.setItem(n,JSON.stringify([...t])),t})}]}function I({options:c,value:n,onChange:i,placeholder:S="Select...",storageKey:v,fitContent:a,disabled:u}){const[t,l]=s.useState(!1),[w,y]=s.useState(""),f=s.useRef(null),j=s.useRef(null),N=s.useRef(null),g=s.useRef(null),[x,C]=$(v),[m,L]=s.useState({top:0,left:0,minWidth:0});s.useEffect(()=>{if(!t)return;const e=d=>{f.current?.contains(d.target)||j.current?.contains(d.target)||l(!1)};return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[t]);const R=s.useCallback(()=>{if(!f.current)return;const e=f.current.getBoundingClientRect();L({top:e.bottom+4,left:e.left,minWidth:e.width})},[]);s.useEffect(()=>{t&&(R(),y(""),requestAnimationFrame(()=>N.current?.focus()))},[t,R]);const h=c.find(e=>e.value===n),p=s.useMemo(()=>{const e=w.toLowerCase();return[...e?c.filter(o=>o.label.toLowerCase().includes(e)||o.value.toLowerCase().includes(e)):c].sort((o,b)=>{const k=x.has(o.value)?0:1,E=x.has(b.value)?0:1;return k!==E?k-E:o.label.localeCompare(b.label)})},[c,w,x]);s.useEffect(()=>{if(t&&n&&g.current){const e=g.current.querySelector(`[data-value="${CSS.escape(n)}"]`);e&&e.scrollIntoView({block:"nearest"})}},[t,n]);const W=t?P.createPortal(r.jsxs("div",{ref:j,className:"fixed z-[100] bg-white border border-[#d4d2cd] rounded shadow-lg",style:{top:m.top,left:m.left,minWidth:m.minWidth,width:a?"max-content":m.minWidth},children:[r.jsx("div",{className:"p-1.5 border-b border-[#e8e6e1]",children:r.jsx("input",{ref:N,type:"text",value:w,onChange:e=>y(e.target.value),placeholder:"Search...",className:"w-full px-2 py-1.5 text-xs text-[#2c2c2c] font-sans bg-[#f5f4f0] border border-[#e8e6e1] rounded focus:outline-none focus:border-[#2b5ea7] placeholder:text-[#9c9890]",onKeyDown:e=>{e.key==="Escape"&&l(!1),e.key==="Enter"&&p.length>0&&(i(p[0].value),l(!1))}})}),r.jsx("div",{ref:g,className:"max-h-[280px] overflow-y-auto",children:p.length===0?r.jsx("div",{className:"px-3 py-3 text-xs text-[#9c9890] text-center",children:"No projects found"}):p.map(e=>{const d=e.value===n,o=x.has(e.value);return r.jsxs("div",{"data-value":e.value,className:`flex items-center gap-1.5 px-2 py-1.5 text-xs font-sans cursor-pointer transition-colors ${d?"bg-[#2b5ea7]/10 text-[#2b5ea7]":"text-[#2c2c2c] hover:bg-[#f5f4f0]"}`,onClick:()=>{i(e.value),l(!1)},children:[r.jsx("button",{type:"button",onClick:b=>{b.stopPropagation(),C(e.value)},className:`shrink-0 w-4 h-4 flex items-center justify-center text-[10px] transition-colors ${o?"text-[#d4a017]":"text-[#d4d2cd] hover:text-[#9c9890]"}`,title:o?"Unstar":"Star to pin to top",children:o?"★":"☆"}),r.jsx("span",{className:a?"whitespace-nowrap":"truncate flex-1",children:e.label})]},e.value)})})]}),document.body):null;return r.jsxs(r.Fragment,{children:[r.jsxs("button",{ref:f,type:"button",onClick:()=>!u&&l(!t),disabled:u,className:"w-full bg-white border border-[#d4d2cd] rounded px-3 py-2 text-xs text-[#2c2c2c] font-sans text-left flex items-center justify-between focus:outline-none focus:border-[#2b5ea7] hover:border-[#b0ada6] transition-colors disabled:opacity-50 disabled:cursor-not-allowed",children:[r.jsx("span",{className:h?"text-[#2c2c2c] truncate":"text-[#9c9890]",children:h?h.displayLabel??h.label:S}),r.jsx("span",{className:"text-[#9c9890] text-[10px] ml-2 shrink-0 transition-transform duration-200",style:{transform:t?"rotate(180deg)":"rotate(0deg)"},children:"▾"})]}),W]})}export{I as S,P as r,$ as u};
@@ -1 +1 @@
1
- import{t as p,r as g,j as e,S as T,c as _,b as i,C as K,A as B,u as ee,d as se,W as q,M as te}from"./index-DqPm6rps.js";import{S as ne}from"./SearchableSelect-CvsTUEdo.js";function Z({type:s,label:n}){const o=p.useUtils(),{data:a,isLoading:c}=p.settings.getApiKey.useQuery(s),m=p.settings.saveApiKey.useMutation({onSuccess:()=>o.settings.getApiKey.invalidate(s)}),x=p.settings.removeApiKey.useMutation({onSuccess:()=>o.settings.getApiKey.invalidate(s)}),[d,r]=g.useState(!1),[h,l]=g.useState(""),[f,v]=g.useState(!1);async function N(){await m.mutateAsync({type:s,apiKey:h}),l(""),r(!1)}async function u(){await x.mutateAsync(s),r(!1),v(!1)}return c?e.jsx("div",{className:"px-4 py-3",children:e.jsx(T,{size:"sm"})}):e.jsxs("div",{className:"px-4 py-3",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx("span",{className:"text-sm font-medium w-24 shrink-0",children:n}),e.jsx("span",{className:i.maskedKey+" flex-1 truncate",style:a?{color:_.success}:void 0,children:a?a.maskedApiKey:"Not configured"}),!d&&e.jsx("button",{onClick:()=>{l(""),r(!0)},className:i.secondaryBtn+" text-xs px-3 py-1",children:a?"Edit":"Add"})]}),d&&e.jsxs("div",{className:"mt-3 pt-3 border-t border-[#e8e6e1] space-y-2",children:[e.jsx("input",{type:h?"password":"text",value:h,onChange:b=>l(b.target.value),placeholder:a?.maskedApiKey??"Enter API key",className:i.input}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{onClick:N,disabled:!h||m.isPending,className:i.primaryBtn+" text-xs px-3 py-1",children:m.isPending?e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsx(T,{size:"sm"})," Saving..."]}):"Save"}),e.jsx("button",{onClick:()=>r(!1),disabled:m.isPending,className:i.secondaryBtn+" text-xs px-3 py-1",children:"Cancel"}),a&&e.jsx("button",{onClick:()=>v(!0),disabled:x.isPending,className:i.dangerBtn+" text-xs px-3 py-1",children:"Remove"})]})]}),e.jsx(K,{open:f,title:"Remove API key",message:`Remove the ${n} API key?`,confirmLabel:"Remove",onConfirm:u,onCancel:()=>v(!1)})]})}function ie({configuredProviders:s}){return e.jsx("div",{className:"border-t border-[#e8e6e1]",children:e.jsxs("table",{className:"w-full text-sm",children:[e.jsx("thead",{children:e.jsxs("tr",{className:i.tableHeaderRow,children:[e.jsx("th",{className:i.tableHeaderCell+" text-xs py-2",children:"Model"}),e.jsx("th",{className:i.tableHeaderCell+" text-xs py-2",children:"Provider"}),e.jsx("th",{className:i.tableHeaderCell+" text-xs py-2 text-right",children:"Input ($/M)"}),e.jsx("th",{className:i.tableHeaderCell+" text-xs py-2 text-right",children:"Output ($/M)"})]})}),e.jsx("tbody",{className:"divide-y divide-[#e8e6e1]",children:B.map(n=>{const o=s.has(n.provider);return e.jsxs("tr",{style:o?{color:_.success}:{color:_.inkFaint},children:[e.jsx("td",{className:"px-4 py-2 font-mono text-xs",children:n.modelId}),e.jsx("td",{className:"px-4 py-2 capitalize",children:n.provider}),e.jsxs("td",{className:"px-4 py-2 text-right font-mono text-xs",children:["$",n.inputPrice.toFixed(2)]}),e.jsxs("td",{className:"px-4 py-2 text-right font-mono text-xs",children:["$",n.outputPrice.toFixed(2)]})]},n.modelId)})})]})})}function ae(){const[s,n]=g.useState(!1),o=ee();return e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"max-w-lg bg-white border border-[#d4d2cd] rounded divide-y divide-[#e8e6e1] overflow-hidden",children:[e.jsx(Z,{type:"anthropic",label:"Anthropic"}),e.jsx(Z,{type:"google",label:"Google AI"})]}),e.jsxs("div",{className:"bg-white border border-[#d4d2cd] rounded overflow-hidden",children:[e.jsxs("button",{onClick:()=>n(!s),className:"w-full flex items-center justify-between px-4 py-3 text-sm text-[#666666] hover:bg-[#f5f4f0] transition-colors font-sans",children:[e.jsx("span",{className:"font-medium",children:"Model Pricing"}),e.jsx("span",{className:"text-xs transition-transform duration-200",style:{transform:s?"rotate(180deg)":"rotate(0deg)"},children:"▾"})]}),s&&e.jsx(ie,{configuredProviders:o})]})]})}function oe({status:s,label:n}){return e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:`inline-block h-2 w-2 rounded-full ${i.statusDot[s]}`}),n&&e.jsx("span",{className:i.statusLabel,children:n})]})}const U=`${B[1]?.provider??B[0].provider}:${B[1]?.modelId??B[0].modelId}`;function le({providerType:s}){const n=p.useUtils(),{data:o,isLoading:a}=p.settings.getSubAgentModel.useQuery(s),c=p.settings.saveSubAgentModel.useMutation({onSuccess:()=>n.settings.getSubAgentModel.invalidate(s)}),m=se(),x=o?`${o.provider}:${o.modelId}`:U,d=m.some(l=>`${l.provider}:${l.modelId}`===x),r=d?x:`${m[0].provider}:${m[0].modelId}`;if(g.useEffect(()=>{!a&&o&&!d&&c.mutate({providerType:s,model:null})},[a,d]),a)return null;function h(l){if(l===U&&!o)return;const f=m.find(v=>`${v.provider}:${v.modelId}`===l);f&&(l===U?c.mutate({providerType:s,model:null}):c.mutate({providerType:s,model:{provider:f.provider,modelId:f.modelId}}))}return e.jsxs("div",{className:"flex items-center gap-3 mt-3 pt-3 border-t border-[#d4d2cd]",children:[e.jsx("span",{className:"text-xs text-[#666666] whitespace-nowrap w-14",children:"Model"}),e.jsxs("div",{className:"relative flex-1",children:[e.jsx("select",{value:r,onChange:l=>h(l.target.value),disabled:c.isPending,className:"w-full appearance-none bg-white border border-[#d4d2cd] rounded px-3 py-2 pr-7 text-xs text-[#2c2c2c] focus:outline-none focus:border-[#2b5ea7] font-sans disabled:opacity-50 disabled:cursor-not-allowed",children:m.map(l=>e.jsx("option",{value:`${l.provider}:${l.modelId}`,children:l.modelId},`${l.provider}:${l.modelId}`))}),e.jsx("span",{className:"pointer-events-none absolute right-2 top-1/2 -translate-y-1/2 text-[#9c9890] text-[10px]",children:"▾"})]})]})}function re({existingConfig:s}){const n=p.useUtils(),{data:o,isLoading:a}=p.provider.listGcpProjects.useQuery(void 0,{staleTime:q.updateCheckStaleTimeMs}),c=p.provider.saveConfig.useMutation({onSuccess:()=>{n.provider.getConfigs.invalidate(),n.provider.list.invalidate()}}),m=g.useMemo(()=>(o??[]).map(r=>({value:r.projectId,label:r.name?`${r.name} (${r.projectId})`:r.projectId,displayLabel:r.name||r.projectId})),[o]),x=s.projectId??"";function d(r){r!==x&&c.mutate({type:"gcp",config:{...s,projectId:r}})}return e.jsxs("div",{className:"flex items-center gap-3 mt-3 pt-3 border-t border-[#d4d2cd]",children:[e.jsx("span",{className:"text-xs text-[#666666] whitespace-nowrap w-14",children:"Project"}),e.jsx("div",{className:"flex-1",children:e.jsx(ne,{options:m,value:x,onChange:d,placeholder:a?"Loading...":"Select project...",storageKey:"gcp-projectId",fitContent:!0,disabled:a||c.isPending})})]})}function ce({checked:s,onChange:n,disabled:o,"aria-label":a}){return e.jsx("button",{type:"button",role:"switch","aria-checked":s,"aria-label":a,disabled:o,onClick:()=>n(!s),className:`relative inline-flex h-5 w-9 items-center rounded-full transition-colors ${s?"bg-[#2b5ea7]":"bg-[#d4d2cd]"} ${o?"opacity-50 cursor-not-allowed":"cursor-pointer"}`,children:e.jsx("span",{className:`inline-block h-3.5 w-3.5 rounded-full bg-white transition-transform ${s?"translate-x-[18px]":"translate-x-[3px]"}`})})}function de({type:s,label:n,connected:o,configured:a,onConfigure:c,onToggle:m,togglePending:x,toggleError:d,pingError:r,hasConfigFields:h,existingConfig:l}){const f=a||o;return e.jsxs("div",{className:i.settingsCard+" w-80",children:[e.jsxs("div",{className:"flex items-center justify-between gap-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ce,{checked:a,onChange:v=>{v&&h?c():m(v)},disabled:x}),e.jsx("span",{className:"font-medium",children:n}),f?e.jsx(oe,{status:o?"connected":"disconnected"}):e.jsx("span",{className:"text-xs opacity-40",children:"Not configured"})]}),e.jsx("button",{onClick:c,className:`${i.secondaryBtn} ${a&&h?"":"invisible"}`,children:"Edit"})]}),f&&e.jsx(le,{providerType:s}),f&&s==="gcp"&&l&&e.jsx(re,{existingConfig:l}),r&&!o&&e.jsx("p",{className:i.warnText+" mt-2",children:r}),d&&e.jsx("p",{className:i.errorText+" mt-2",children:d})]})}function H(s,n){return!!s&&!!n&&s===n}function ue({open:s,label:n,configFields:o,formValues:a,onFormChange:c,existingConfig:m,saveResult:x,savePending:d,configured:r,onSave:h,onClose:l,onRemove:f}){const v=o.some(u=>u.required!==!1&&u.type==="password"&&H(a[u.key],m?.[u.key])),N=o.some(u=>u.required!==!1&&!a[u.key]);return e.jsxs(te,{open:s,onClose:l,children:[e.jsxs("div",{className:i.dialogTitle+" text-base mb-4",children:["Configure ",n]}),e.jsx("div",{className:"space-y-3",children:o.map(u=>{const b=u.type==="password"&&H(a[u.key],m?.[u.key]);return e.jsxs("div",{children:[e.jsxs("label",{className:i.sectionTitle,children:[u.label,u.required===!1&&e.jsx("span",{className:"text-xs opacity-40 ml-1",children:"(optional)"})]}),e.jsx("input",{type:u.type==="password"&&a[u.key]&&!b?"password":"text",value:a[u.key]??"",onChange:S=>c(u.key,S.target.value),onFocus:S=>{b&&S.target.select()},placeholder:`Enter ${u.label.toLowerCase()}`,className:`${i.input} ${b?"!text-[#999] !border-l-2 !border-l-amber-400":""}`})]},u.key)})}),e.jsxs("div",{className:"flex items-center gap-2 mt-4 pt-4 border-t border-[#d4d2cd]",children:[e.jsx("button",{onClick:h,disabled:N||v||d,className:i.primaryBtn,children:d?e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsx(T,{size:"sm"})," Saving..."]}):"Save & Test"}),e.jsx("button",{onClick:l,disabled:d,className:i.secondaryBtn,children:"Cancel"}),r&&e.jsx("button",{onClick:f,disabled:d,className:i.dangerBtn,children:"Remove"})]}),v&&!d&&!x&&e.jsx("p",{className:"mt-2 text-xs text-amber-600",children:"Re-enter highlighted fields to save"}),x&&e.jsx("div",{className:`mt-3 ${x.success?i.successText:i.errorText}`,children:x.success?"Connected successfully":x.error||"Connection failed"})]})}function me(s,n){const o={};for(const a of s)o[a.key]=n?.[a.key]??"";return o}function xe(){const s=p.useUtils(),{data:n,isLoading:o}=p.provider.list.useQuery(),{data:a,isLoading:c}=p.provider.getConfigs.useQuery(),{data:m,isLoading:x}=p.provider.getRegisteredTypes.useQuery(),{data:d}=p.provider.ping.useQuery(void 0,{staleTime:q.sessionStaleTimeMs,refetchOnMount:"always"}),r=p.provider.saveConfig.useMutation({onSuccess:()=>{s.provider.list.invalidate(),s.provider.getConfigs.invalidate(),s.provider.ping.invalidate()}}),h=p.provider.removeConfig.useMutation({onSuccess:()=>{s.provider.list.invalidate(),s.provider.getConfigs.invalidate(),s.provider.ping.invalidate()}}),[l,f]=g.useState(null),[v,N]=g.useState({}),[u,b]=g.useState(null),[S,A]=g.useState(null),[k,j]=g.useState({});function P(t){const y=a?.find(w=>w.type===t),C=m?.find(w=>w.type===t);N(me(C?.configFields??[],y?.config)),b(null),f(t)}function E(){f(null),N({}),b(null)}async function R(t){b(null);try{const y=await r.mutateAsync({type:t,config:v});b(y),y.success&&(f(null),N({}))}catch{b({success:!1,error:"Failed to save configuration"})}}async function z(t,y){if(y){j(C=>{const w={...C};return delete w[t],w});try{const C=await r.mutateAsync({type:t,config:{}});C.success||j(w=>({...w,[t]:C.error??"Connection failed"}))}catch{j(C=>({...C,[t]:"Failed to save configuration"}))}}else A(t)}async function F(t){await h.mutateAsync(t),f(null),N({}),b(null),A(null)}const O=o||c||x,$=m??[];if(O)return e.jsx(T,{size:"lg",centered:!0});const M=l?$.find(t=>t.type===l):null,D=l?a?.find(t=>t.type===l):null;return e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"flex flex-wrap gap-3",children:$.map(({type:t,label:y,configFields:C})=>{const w=n?.find(I=>I.type===t),Q=a?.find(I=>I.type===t),W=!!Q,L=d?.find(I=>I.type===t),Y=L?L.ok:!!w?.connected,J=C.length>0,X=L&&!L.ok?L.error:void 0;return e.jsx(de,{type:t,label:y,connected:Y,configured:W,onConfigure:()=>P(t),onToggle:I=>z(t,I),togglePending:r.isPending||h.isPending,toggleError:k[t],pingError:X,hasConfigFields:J,existingConfig:Q?.config},t)})}),l&&M&&e.jsx(ue,{open:!0,label:M.label,configFields:M.configFields,formValues:v,onFormChange:(t,y)=>N(C=>({...C,[t]:y})),existingConfig:D?.config??null,saveResult:u,savePending:r.isPending,configured:!!D,onSave:()=>R(l),onClose:E,onRemove:()=>A(l)}),e.jsx(K,{open:S!==null,title:"Disable provider",message:`Disable ${$.find(t=>t.type===S)?.label??S}?`,confirmLabel:"Disable",onConfirm:()=>{S&&F(S)},onCancel:()=>A(null)})]})}function pe({memory:s,editingId:n,editNote:o,setEditNote:a,onUpdate:c,onCancelEdit:m,onStartEdit:x,onDelete:d,updatePending:r,removePending:h}){return e.jsxs("li",{className:"flex items-start justify-between gap-3 py-1.5 border-b border-[#d4d2cd] last:border-b-0",children:[e.jsx("div",{className:"flex-1 min-w-0",children:n===s.id?e.jsxs("div",{className:"space-y-2",children:[e.jsx("input",{type:"text",value:o,onChange:l=>a(l.target.value),className:i.input}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{onClick:()=>c(s.id),disabled:!o||r,className:i.primaryBtn,children:"Save"}),e.jsx("button",{onClick:m,disabled:r,className:i.secondaryBtn,children:"Cancel"})]})]}):e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"text-sm text-[#444444]",children:s.note}),s.reviewNote&&e.jsx("p",{className:"text-xs text-[#9c9890] italic mt-0.5",children:s.reviewNote}),e.jsx("p",{className:"text-xs text-[#666666] mt-0.5",children:new Date(s.createdAt*1e3).toLocaleDateString()})]})}),n!==s.id&&e.jsxs("div",{className:"flex items-center gap-1 shrink-0",children:[e.jsx("button",{onClick:()=>x(s.id,s.note),className:i.secondaryBtn,children:"Edit"}),e.jsx("button",{onClick:()=>d(s.id),disabled:h,className:i.dangerBtn,children:"Delete"})]})]})}function ge(){const s=p.useUtils(),{data:n,isLoading:o}=p.memory.list.useQuery(),{data:a}=p.provider.getRegisteredTypes.useQuery(),c=p.memory.create.useMutation({onSuccess:()=>{s.memory.list.invalidate(),E(""),j("unified"),A(!1)}}),m=p.memory.update.useMutation({onSuccess:()=>s.memory.list.invalidate()}),x=p.memory.remove.useMutation({onSuccess:()=>s.memory.list.invalidate()}),[d,r]=g.useState(null),h=p.memory.optimize.useMutation({onSuccess:t=>{s.memory.list.invalidate(),r(t.stats)}}),[l,f]=g.useState(null),[v,N]=g.useState(""),[u,b]=g.useState(null),[S,A]=g.useState(!1),[k,j]=g.useState("unified"),[P,E]=g.useState("");function R(t,y){f(t),N(y)}async function z(t){await m.mutateAsync({id:t,note:v}),f(null),N("")}function F(){f(null),N("")}const O=[{value:"unified",label:"Unified"},...(a??[]).map(t=>({value:t.type,label:t.label}))],$=5;if(o)return e.jsx(T,{size:"lg",centered:!0});const M=new Map;if(n)for(const t of n){const y=M.get(t.toolName)??[];y.push(t),M.set(t.toolName,y)}const D={editingId:l,editNote:v,setEditNote:N,onUpdate:z,onCancelEdit:F,onStartEdit:R,onDelete:t=>b(t),updatePending:m.isPending,removePending:x.isPending};return e.jsxs("div",{className:"space-y-4",children:[S?e.jsxs("div",{className:i.settingsCard+" space-y-3",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("label",{className:"text-sm font-medium text-[#666666] font-sans",children:"Provider"}),e.jsx("select",{value:k,onChange:t=>{j(t.target.value),t.target.blur()},className:"bg-white border border-[#d4d2cd] rounded px-3 py-2 pr-8 text-sm text-[#2c2c2c] focus:outline-none focus:border-[#2b5ea7] font-sans appearance-none bg-[length:16px_16px] bg-[right_8px_center] bg-no-repeat",style:{backgroundImage:`url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23666666' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E")`},children:O.map(t=>e.jsx("option",{value:t.value,children:t.label},t.value))})]}),e.jsxs("div",{children:[e.jsx("label",{className:i.sectionTitle,children:"Note"}),e.jsx("input",{type:"text",value:P,onChange:t=>E(t.target.value),onKeyDown:t=>{t.key==="Enter"&&P.trim()&&!c.isPending&&c.mutate({toolName:k,note:P})},placeholder:"Reusable lesson or pattern...",className:i.input})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{onClick:()=>c.mutate({toolName:k,note:P}),disabled:!P.trim()||c.isPending,className:i.primaryBtn,children:c.isPending?e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsx(T,{size:"sm"})," Saving..."]}):"Save"}),e.jsx("button",{onClick:()=>{A(!1),E(""),j("unified")},disabled:c.isPending,className:i.secondaryBtn,children:"Cancel"})]})]}):e.jsx("button",{onClick:()=>A(!0),className:i.secondaryBtn,children:"+ Add Memory"}),M.size===0&&e.jsx("div",{className:i.settingsCard,children:e.jsx("p",{className:"text-sm text-[#666666]",children:"No memories yet. The agent will save notes here as it learns from tool usage."})}),[...M.entries()].map(([t,y])=>{const C=y.length>$;return e.jsxs("div",{className:i.settingsCard,children:[e.jsxs("div",{className:"mb-3 flex items-center gap-2",children:[e.jsx("span",{className:`${i.badge} ${i.badgeVariants.info}`,children:t}),C&&e.jsxs("span",{className:"text-xs text-[#666666]",children:[y.length," memories"]}),e.jsx("button",{onClick:()=>h.mutate({toolName:t}),disabled:h.isPending||y.length===0,className:`ml-auto ${i.outlineBtn}`,title:"Optimize memories with AI",children:h.isPending&&h.variables?.toolName===t?e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(T,{size:"sm"})," Optimizing..."]}):"Optimize"})]}),e.jsx("ul",{className:`space-y-2${C?" max-h-64 overflow-y-auto":""}`,children:y.map(w=>e.jsx(pe,{memory:w,...D},w.id))})]},t)}),e.jsx(K,{open:u!==null,title:"Delete memory",message:"Delete this agent memory?",onConfirm:()=>{u!==null&&x.mutate({id:u}),b(null)},onCancel:()=>b(null)}),e.jsx(K,{open:d!==null,title:"Optimization Complete",message:d&&e.jsxs("div",{className:"space-y-1.5 text-sm text-[#444444]",children:[e.jsxs("p",{children:["Kept: ",e.jsx("span",{className:"font-medium",children:d.kept})]}),e.jsxs("p",{children:["Updated: ",e.jsx("span",{className:"font-medium",children:d.updated})]}),e.jsxs("p",{children:["Deleted: ",e.jsx("span",{className:"font-medium",children:d.deleted})]})]}),confirmLabel:"OK",cancelLabel:null,confirmStyle:"primary",onConfirm:()=>r(null),onCancel:()=>r(null)})]})}const G=["Pacific/Auckland","Australia/Sydney","Asia/Tokyo","Asia/Shanghai","Asia/Kolkata","Asia/Dubai","Europe/Moscow","Europe/Berlin","UTC","Europe/London","America/Sao_Paulo","America/New_York","America/Chicago","America/Denver","America/Los_Angeles","Pacific/Honolulu"];function V(s){try{const n=new Intl.DateTimeFormat("en-US",{timeZone:s,timeZoneName:"short"}).formatToParts(new Date).find(a=>a.type==="timeZoneName")?.value??"",o=new Intl.DateTimeFormat("en-US",{timeZone:s,timeZoneName:"shortOffset"}).formatToParts(new Date).find(a=>a.type==="timeZoneName")?.value??"";return`${n} (${o})`}catch{return s}}const he=new Map(G.map(s=>[s,V(s)]));function fe(){const s=p.useUtils(),{data:n,isLoading:o}=p.settings.getAgentConfig.useQuery(),a=p.settings.saveAgentConfig.useMutation({onSuccess:()=>{s.settings.getAgentConfig.invalidate(),b(!1)}}),[c,m]=g.useState(""),[x,d]=g.useState(100),[r,h]=g.useState(50),[l,f]=g.useState(1024),[v,N]=g.useState(1e4),[u,b]=g.useState(!1);if(g.useEffect(()=>{n&&(m(n.timezone),d(n.directModeMaxSteps),h(n.subAgentMaxSteps),f(n.thinkingBudgetGoogle),N(n.thinkingBudgetAnthropic),b(!1))},[n]),o||!n)return null;const S=u&&(c!==n.timezone||x!==n.directModeMaxSteps||r!==n.subAgentMaxSteps||l!==n.thinkingBudgetGoogle||v!==n.thinkingBudgetAnthropic);function A(){a.mutate({timezone:c,directModeMaxSteps:x,subAgentMaxSteps:r,thinkingBudgetGoogle:l,thinkingBudgetAnthropic:v})}function k(){b(!0)}return e.jsx("div",{className:"max-w-lg",children:e.jsxs("div",{className:i.settingsCard,children:[e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx("label",{className:"text-xs text-[#666666] w-44 shrink-0",children:"Timezone"}),e.jsxs("select",{value:c,onChange:j=>{m(j.target.value),k()},className:"appearance-none bg-white border border-[#d4d2cd] rounded px-3 py-1.5 text-xs text-[#2c2c2c] focus:outline-none focus:border-[#2b5ea7] font-sans",children:[G.map(j=>e.jsx("option",{value:j,children:he.get(j)??j},j)),!G.includes(c)&&e.jsx("option",{value:c,children:V(c)})]})]}),e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx("label",{className:"text-xs text-[#666666] w-44 shrink-0",children:"Direct mode max steps"}),e.jsx("input",{type:"number",min:1,max:500,value:x,onChange:j=>{d(Number(j.target.value)),k()},className:"w-20 bg-white border border-[#d4d2cd] rounded px-3 py-1.5 text-xs text-[#2c2c2c] focus:outline-none focus:border-[#2b5ea7] font-mono"})]}),e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx("label",{className:"text-xs text-[#666666] w-44 shrink-0",children:"Sub-agent max steps"}),e.jsx("input",{type:"number",min:1,max:500,value:r,onChange:j=>{h(Number(j.target.value)),k()},className:"w-20 bg-white border border-[#d4d2cd] rounded px-3 py-1.5 text-xs text-[#2c2c2c] focus:outline-none focus:border-[#2b5ea7] font-mono"})]}),e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx("label",{className:"text-xs text-[#666666] w-44 shrink-0",children:"Google thinking budget"}),e.jsx("input",{type:"number",min:0,max:1e5,step:256,value:l,onChange:j=>{f(Number(j.target.value)),k()},className:"w-24 bg-white border border-[#d4d2cd] rounded px-3 py-1.5 text-xs text-[#2c2c2c] focus:outline-none focus:border-[#2b5ea7] font-mono"}),e.jsx("span",{className:"text-[10px] text-[#9c9890]",children:"tokens"})]}),e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx("label",{className:"text-xs text-[#666666] w-44 shrink-0",children:"Anthropic thinking budget"}),e.jsx("input",{type:"number",min:0,max:1e5,step:1e3,value:v,onChange:j=>{N(Number(j.target.value)),k()},className:"w-24 bg-white border border-[#d4d2cd] rounded px-3 py-1.5 text-xs text-[#2c2c2c] focus:outline-none focus:border-[#2b5ea7] font-mono"}),e.jsx("span",{className:"text-[10px] text-[#9c9890]",children:"tokens"})]})]}),e.jsxs("div",{className:"flex items-center gap-3 mt-4 pt-3 border-t border-[#e8e6e1]",children:[e.jsx("button",{onClick:A,disabled:!S||a.isPending,className:i.primaryBtn,children:a.isPending?"Saving...":"Save"}),a.isSuccess&&!u&&e.jsx("span",{className:i.successText,children:"Saved"})]})]})})}function be(){return e.jsxs("div",{className:i.page,children:[e.jsxs("div",{children:[e.jsx("h3",{className:i.sectionTitle,children:"LLM API Keys"}),e.jsx(ae,{})]}),e.jsxs("div",{children:[e.jsx("h3",{className:i.sectionTitle,children:"Data Providers"}),e.jsx(xe,{})]}),e.jsxs("div",{children:[e.jsx("h3",{className:i.sectionTitle,children:"Agent Configuration"}),e.jsx(fe,{})]}),e.jsxs("div",{children:[e.jsx("h3",{className:i.sectionTitle,children:"Agent Memory"}),e.jsx(ge,{})]})]})}export{be as Settings};
1
+ import{t as p,r as g,j as e,S as T,c as _,b as i,C as K,A as B,u as ee,d as se,W as q,M as te}from"./index-B7y1naN3.js";import{S as ne}from"./SearchableSelect-B006wjjM.js";function Z({type:s,label:n}){const o=p.useUtils(),{data:a,isLoading:c}=p.settings.getApiKey.useQuery(s),m=p.settings.saveApiKey.useMutation({onSuccess:()=>o.settings.getApiKey.invalidate(s)}),x=p.settings.removeApiKey.useMutation({onSuccess:()=>o.settings.getApiKey.invalidate(s)}),[d,r]=g.useState(!1),[h,l]=g.useState(""),[f,v]=g.useState(!1);async function N(){await m.mutateAsync({type:s,apiKey:h}),l(""),r(!1)}async function u(){await x.mutateAsync(s),r(!1),v(!1)}return c?e.jsx("div",{className:"px-4 py-3",children:e.jsx(T,{size:"sm"})}):e.jsxs("div",{className:"px-4 py-3",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx("span",{className:"text-sm font-medium w-24 shrink-0",children:n}),e.jsx("span",{className:i.maskedKey+" flex-1 truncate",style:a?{color:_.success}:void 0,children:a?a.maskedApiKey:"Not configured"}),!d&&e.jsx("button",{onClick:()=>{l(""),r(!0)},className:i.secondaryBtn+" text-xs px-3 py-1",children:a?"Edit":"Add"})]}),d&&e.jsxs("div",{className:"mt-3 pt-3 border-t border-[#e8e6e1] space-y-2",children:[e.jsx("input",{type:h?"password":"text",value:h,onChange:b=>l(b.target.value),placeholder:a?.maskedApiKey??"Enter API key",className:i.input}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{onClick:N,disabled:!h||m.isPending,className:i.primaryBtn+" text-xs px-3 py-1",children:m.isPending?e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsx(T,{size:"sm"})," Saving..."]}):"Save"}),e.jsx("button",{onClick:()=>r(!1),disabled:m.isPending,className:i.secondaryBtn+" text-xs px-3 py-1",children:"Cancel"}),a&&e.jsx("button",{onClick:()=>v(!0),disabled:x.isPending,className:i.dangerBtn+" text-xs px-3 py-1",children:"Remove"})]})]}),e.jsx(K,{open:f,title:"Remove API key",message:`Remove the ${n} API key?`,confirmLabel:"Remove",onConfirm:u,onCancel:()=>v(!1)})]})}function ie({configuredProviders:s}){return e.jsx("div",{className:"border-t border-[#e8e6e1]",children:e.jsxs("table",{className:"w-full text-sm",children:[e.jsx("thead",{children:e.jsxs("tr",{className:i.tableHeaderRow,children:[e.jsx("th",{className:i.tableHeaderCell+" text-xs py-2",children:"Model"}),e.jsx("th",{className:i.tableHeaderCell+" text-xs py-2",children:"Provider"}),e.jsx("th",{className:i.tableHeaderCell+" text-xs py-2 text-right",children:"Input ($/M)"}),e.jsx("th",{className:i.tableHeaderCell+" text-xs py-2 text-right",children:"Output ($/M)"})]})}),e.jsx("tbody",{className:"divide-y divide-[#e8e6e1]",children:B.map(n=>{const o=s.has(n.provider);return e.jsxs("tr",{style:o?{color:_.success}:{color:_.inkFaint},children:[e.jsx("td",{className:"px-4 py-2 font-mono text-xs",children:n.modelId}),e.jsx("td",{className:"px-4 py-2 capitalize",children:n.provider}),e.jsxs("td",{className:"px-4 py-2 text-right font-mono text-xs",children:["$",n.inputPrice.toFixed(2)]}),e.jsxs("td",{className:"px-4 py-2 text-right font-mono text-xs",children:["$",n.outputPrice.toFixed(2)]})]},n.modelId)})})]})})}function ae(){const[s,n]=g.useState(!1),o=ee();return e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"max-w-lg bg-white border border-[#d4d2cd] rounded divide-y divide-[#e8e6e1] overflow-hidden",children:[e.jsx(Z,{type:"anthropic",label:"Anthropic"}),e.jsx(Z,{type:"google",label:"Google AI"})]}),e.jsxs("div",{className:"bg-white border border-[#d4d2cd] rounded overflow-hidden",children:[e.jsxs("button",{onClick:()=>n(!s),className:"w-full flex items-center justify-between px-4 py-3 text-sm text-[#666666] hover:bg-[#f5f4f0] transition-colors font-sans",children:[e.jsx("span",{className:"font-medium",children:"Model Pricing"}),e.jsx("span",{className:"text-xs transition-transform duration-200",style:{transform:s?"rotate(180deg)":"rotate(0deg)"},children:"▾"})]}),s&&e.jsx(ie,{configuredProviders:o})]})]})}function oe({status:s,label:n}){return e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:`inline-block h-2 w-2 rounded-full ${i.statusDot[s]}`}),n&&e.jsx("span",{className:i.statusLabel,children:n})]})}const U=`${B[1]?.provider??B[0].provider}:${B[1]?.modelId??B[0].modelId}`;function le({providerType:s}){const n=p.useUtils(),{data:o,isLoading:a}=p.settings.getSubAgentModel.useQuery(s),c=p.settings.saveSubAgentModel.useMutation({onSuccess:()=>n.settings.getSubAgentModel.invalidate(s)}),m=se(),x=o?`${o.provider}:${o.modelId}`:U,d=m.some(l=>`${l.provider}:${l.modelId}`===x),r=d?x:`${m[0].provider}:${m[0].modelId}`;if(g.useEffect(()=>{!a&&o&&!d&&c.mutate({providerType:s,model:null})},[a,d]),a)return null;function h(l){if(l===U&&!o)return;const f=m.find(v=>`${v.provider}:${v.modelId}`===l);f&&(l===U?c.mutate({providerType:s,model:null}):c.mutate({providerType:s,model:{provider:f.provider,modelId:f.modelId}}))}return e.jsxs("div",{className:"flex items-center gap-3 mt-3 pt-3 border-t border-[#d4d2cd]",children:[e.jsx("span",{className:"text-xs text-[#666666] whitespace-nowrap w-14",children:"Model"}),e.jsxs("div",{className:"relative flex-1",children:[e.jsx("select",{value:r,onChange:l=>h(l.target.value),disabled:c.isPending,className:"w-full appearance-none bg-white border border-[#d4d2cd] rounded px-3 py-2 pr-7 text-xs text-[#2c2c2c] focus:outline-none focus:border-[#2b5ea7] font-sans disabled:opacity-50 disabled:cursor-not-allowed",children:m.map(l=>e.jsx("option",{value:`${l.provider}:${l.modelId}`,children:l.modelId},`${l.provider}:${l.modelId}`))}),e.jsx("span",{className:"pointer-events-none absolute right-2 top-1/2 -translate-y-1/2 text-[#9c9890] text-[10px]",children:"▾"})]})]})}function re({existingConfig:s}){const n=p.useUtils(),{data:o,isLoading:a}=p.provider.listGcpProjects.useQuery(void 0,{staleTime:q.updateCheckStaleTimeMs}),c=p.provider.saveConfig.useMutation({onSuccess:()=>{n.provider.getConfigs.invalidate(),n.provider.list.invalidate()}}),m=g.useMemo(()=>(o??[]).map(r=>({value:r.projectId,label:r.name?`${r.name} (${r.projectId})`:r.projectId,displayLabel:r.name||r.projectId})),[o]),x=s.projectId??"";function d(r){r!==x&&c.mutate({type:"gcp",config:{...s,projectId:r}})}return e.jsxs("div",{className:"flex items-center gap-3 mt-3 pt-3 border-t border-[#d4d2cd]",children:[e.jsx("span",{className:"text-xs text-[#666666] whitespace-nowrap w-14",children:"Project"}),e.jsx("div",{className:"flex-1",children:e.jsx(ne,{options:m,value:x,onChange:d,placeholder:a?"Loading...":"Select project...",storageKey:"gcp-projectId",fitContent:!0,disabled:a||c.isPending})})]})}function ce({checked:s,onChange:n,disabled:o,"aria-label":a}){return e.jsx("button",{type:"button",role:"switch","aria-checked":s,"aria-label":a,disabled:o,onClick:()=>n(!s),className:`relative inline-flex h-5 w-9 items-center rounded-full transition-colors ${s?"bg-[#2b5ea7]":"bg-[#d4d2cd]"} ${o?"opacity-50 cursor-not-allowed":"cursor-pointer"}`,children:e.jsx("span",{className:`inline-block h-3.5 w-3.5 rounded-full bg-white transition-transform ${s?"translate-x-[18px]":"translate-x-[3px]"}`})})}function de({type:s,label:n,connected:o,configured:a,onConfigure:c,onToggle:m,togglePending:x,toggleError:d,pingError:r,hasConfigFields:h,existingConfig:l}){const f=a||o;return e.jsxs("div",{className:i.settingsCard+" w-80",children:[e.jsxs("div",{className:"flex items-center justify-between gap-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ce,{checked:a,onChange:v=>{v&&h?c():m(v)},disabled:x}),e.jsx("span",{className:"font-medium",children:n}),f?e.jsx(oe,{status:o?"connected":"disconnected"}):e.jsx("span",{className:"text-xs opacity-40",children:"Not configured"})]}),e.jsx("button",{onClick:c,className:`${i.secondaryBtn} ${a&&h?"":"invisible"}`,children:"Edit"})]}),f&&e.jsx(le,{providerType:s}),f&&s==="gcp"&&l&&e.jsx(re,{existingConfig:l}),r&&!o&&e.jsx("p",{className:i.warnText+" mt-2",children:r}),d&&e.jsx("p",{className:i.errorText+" mt-2",children:d})]})}function H(s,n){return!!s&&!!n&&s===n}function ue({open:s,label:n,configFields:o,formValues:a,onFormChange:c,existingConfig:m,saveResult:x,savePending:d,configured:r,onSave:h,onClose:l,onRemove:f}){const v=o.some(u=>u.required!==!1&&u.type==="password"&&H(a[u.key],m?.[u.key])),N=o.some(u=>u.required!==!1&&!a[u.key]);return e.jsxs(te,{open:s,onClose:l,children:[e.jsxs("div",{className:i.dialogTitle+" text-base mb-4",children:["Configure ",n]}),e.jsx("div",{className:"space-y-3",children:o.map(u=>{const b=u.type==="password"&&H(a[u.key],m?.[u.key]);return e.jsxs("div",{children:[e.jsxs("label",{className:i.sectionTitle,children:[u.label,u.required===!1&&e.jsx("span",{className:"text-xs opacity-40 ml-1",children:"(optional)"})]}),e.jsx("input",{type:u.type==="password"&&a[u.key]&&!b?"password":"text",value:a[u.key]??"",onChange:S=>c(u.key,S.target.value),onFocus:S=>{b&&S.target.select()},placeholder:`Enter ${u.label.toLowerCase()}`,className:`${i.input} ${b?"!text-[#999] !border-l-2 !border-l-amber-400":""}`})]},u.key)})}),e.jsxs("div",{className:"flex items-center gap-2 mt-4 pt-4 border-t border-[#d4d2cd]",children:[e.jsx("button",{onClick:h,disabled:N||v||d,className:i.primaryBtn,children:d?e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsx(T,{size:"sm"})," Saving..."]}):"Save & Test"}),e.jsx("button",{onClick:l,disabled:d,className:i.secondaryBtn,children:"Cancel"}),r&&e.jsx("button",{onClick:f,disabled:d,className:i.dangerBtn,children:"Remove"})]}),v&&!d&&!x&&e.jsx("p",{className:"mt-2 text-xs text-amber-600",children:"Re-enter highlighted fields to save"}),x&&e.jsx("div",{className:`mt-3 ${x.success?i.successText:i.errorText}`,children:x.success?"Connected successfully":x.error||"Connection failed"})]})}function me(s,n){const o={};for(const a of s)o[a.key]=n?.[a.key]??"";return o}function xe(){const s=p.useUtils(),{data:n,isLoading:o}=p.provider.list.useQuery(),{data:a,isLoading:c}=p.provider.getConfigs.useQuery(),{data:m,isLoading:x}=p.provider.getRegisteredTypes.useQuery(),{data:d}=p.provider.ping.useQuery(void 0,{staleTime:q.sessionStaleTimeMs,refetchOnMount:"always"}),r=p.provider.saveConfig.useMutation({onSuccess:()=>{s.provider.list.invalidate(),s.provider.getConfigs.invalidate(),s.provider.ping.invalidate()}}),h=p.provider.removeConfig.useMutation({onSuccess:()=>{s.provider.list.invalidate(),s.provider.getConfigs.invalidate(),s.provider.ping.invalidate()}}),[l,f]=g.useState(null),[v,N]=g.useState({}),[u,b]=g.useState(null),[S,A]=g.useState(null),[k,j]=g.useState({});function P(t){const y=a?.find(w=>w.type===t),C=m?.find(w=>w.type===t);N(me(C?.configFields??[],y?.config)),b(null),f(t)}function E(){f(null),N({}),b(null)}async function R(t){b(null);try{const y=await r.mutateAsync({type:t,config:v});b(y),y.success&&(f(null),N({}))}catch{b({success:!1,error:"Failed to save configuration"})}}async function z(t,y){if(y){j(C=>{const w={...C};return delete w[t],w});try{const C=await r.mutateAsync({type:t,config:{}});C.success||j(w=>({...w,[t]:C.error??"Connection failed"}))}catch{j(C=>({...C,[t]:"Failed to save configuration"}))}}else A(t)}async function F(t){await h.mutateAsync(t),f(null),N({}),b(null),A(null)}const O=o||c||x,$=m??[];if(O)return e.jsx(T,{size:"lg",centered:!0});const M=l?$.find(t=>t.type===l):null,D=l?a?.find(t=>t.type===l):null;return e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"flex flex-wrap gap-3",children:$.map(({type:t,label:y,configFields:C})=>{const w=n?.find(I=>I.type===t),Q=a?.find(I=>I.type===t),W=!!Q,L=d?.find(I=>I.type===t),Y=L?L.ok:!!w?.connected,J=C.length>0,X=L&&!L.ok?L.error:void 0;return e.jsx(de,{type:t,label:y,connected:Y,configured:W,onConfigure:()=>P(t),onToggle:I=>z(t,I),togglePending:r.isPending||h.isPending,toggleError:k[t],pingError:X,hasConfigFields:J,existingConfig:Q?.config},t)})}),l&&M&&e.jsx(ue,{open:!0,label:M.label,configFields:M.configFields,formValues:v,onFormChange:(t,y)=>N(C=>({...C,[t]:y})),existingConfig:D?.config??null,saveResult:u,savePending:r.isPending,configured:!!D,onSave:()=>R(l),onClose:E,onRemove:()=>A(l)}),e.jsx(K,{open:S!==null,title:"Disable provider",message:`Disable ${$.find(t=>t.type===S)?.label??S}?`,confirmLabel:"Disable",onConfirm:()=>{S&&F(S)},onCancel:()=>A(null)})]})}function pe({memory:s,editingId:n,editNote:o,setEditNote:a,onUpdate:c,onCancelEdit:m,onStartEdit:x,onDelete:d,updatePending:r,removePending:h}){return e.jsxs("li",{className:"flex items-start justify-between gap-3 py-1.5 border-b border-[#d4d2cd] last:border-b-0",children:[e.jsx("div",{className:"flex-1 min-w-0",children:n===s.id?e.jsxs("div",{className:"space-y-2",children:[e.jsx("input",{type:"text",value:o,onChange:l=>a(l.target.value),className:i.input}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{onClick:()=>c(s.id),disabled:!o||r,className:i.primaryBtn,children:"Save"}),e.jsx("button",{onClick:m,disabled:r,className:i.secondaryBtn,children:"Cancel"})]})]}):e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"text-sm text-[#444444]",children:s.note}),s.reviewNote&&e.jsx("p",{className:"text-xs text-[#9c9890] italic mt-0.5",children:s.reviewNote}),e.jsx("p",{className:"text-xs text-[#666666] mt-0.5",children:new Date(s.createdAt*1e3).toLocaleDateString()})]})}),n!==s.id&&e.jsxs("div",{className:"flex items-center gap-1 shrink-0",children:[e.jsx("button",{onClick:()=>x(s.id,s.note),className:i.secondaryBtn,children:"Edit"}),e.jsx("button",{onClick:()=>d(s.id),disabled:h,className:i.dangerBtn,children:"Delete"})]})]})}function ge(){const s=p.useUtils(),{data:n,isLoading:o}=p.memory.list.useQuery(),{data:a}=p.provider.getRegisteredTypes.useQuery(),c=p.memory.create.useMutation({onSuccess:()=>{s.memory.list.invalidate(),E(""),j("unified"),A(!1)}}),m=p.memory.update.useMutation({onSuccess:()=>s.memory.list.invalidate()}),x=p.memory.remove.useMutation({onSuccess:()=>s.memory.list.invalidate()}),[d,r]=g.useState(null),h=p.memory.optimize.useMutation({onSuccess:t=>{s.memory.list.invalidate(),r(t.stats)}}),[l,f]=g.useState(null),[v,N]=g.useState(""),[u,b]=g.useState(null),[S,A]=g.useState(!1),[k,j]=g.useState("unified"),[P,E]=g.useState("");function R(t,y){f(t),N(y)}async function z(t){await m.mutateAsync({id:t,note:v}),f(null),N("")}function F(){f(null),N("")}const O=[{value:"unified",label:"Unified"},...(a??[]).map(t=>({value:t.type,label:t.label}))],$=5;if(o)return e.jsx(T,{size:"lg",centered:!0});const M=new Map;if(n)for(const t of n){const y=M.get(t.toolName)??[];y.push(t),M.set(t.toolName,y)}const D={editingId:l,editNote:v,setEditNote:N,onUpdate:z,onCancelEdit:F,onStartEdit:R,onDelete:t=>b(t),updatePending:m.isPending,removePending:x.isPending};return e.jsxs("div",{className:"space-y-4",children:[S?e.jsxs("div",{className:i.settingsCard+" space-y-3",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("label",{className:"text-sm font-medium text-[#666666] font-sans",children:"Provider"}),e.jsx("select",{value:k,onChange:t=>{j(t.target.value),t.target.blur()},className:"bg-white border border-[#d4d2cd] rounded px-3 py-2 pr-8 text-sm text-[#2c2c2c] focus:outline-none focus:border-[#2b5ea7] font-sans appearance-none bg-[length:16px_16px] bg-[right_8px_center] bg-no-repeat",style:{backgroundImage:`url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23666666' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E")`},children:O.map(t=>e.jsx("option",{value:t.value,children:t.label},t.value))})]}),e.jsxs("div",{children:[e.jsx("label",{className:i.sectionTitle,children:"Note"}),e.jsx("input",{type:"text",value:P,onChange:t=>E(t.target.value),onKeyDown:t=>{t.key==="Enter"&&P.trim()&&!c.isPending&&c.mutate({toolName:k,note:P})},placeholder:"Reusable lesson or pattern...",className:i.input})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{onClick:()=>c.mutate({toolName:k,note:P}),disabled:!P.trim()||c.isPending,className:i.primaryBtn,children:c.isPending?e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsx(T,{size:"sm"})," Saving..."]}):"Save"}),e.jsx("button",{onClick:()=>{A(!1),E(""),j("unified")},disabled:c.isPending,className:i.secondaryBtn,children:"Cancel"})]})]}):e.jsx("button",{onClick:()=>A(!0),className:i.secondaryBtn,children:"+ Add Memory"}),M.size===0&&e.jsx("div",{className:i.settingsCard,children:e.jsx("p",{className:"text-sm text-[#666666]",children:"No memories yet. The agent will save notes here as it learns from tool usage."})}),[...M.entries()].map(([t,y])=>{const C=y.length>$;return e.jsxs("div",{className:i.settingsCard,children:[e.jsxs("div",{className:"mb-3 flex items-center gap-2",children:[e.jsx("span",{className:`${i.badge} ${i.badgeVariants.info}`,children:t}),C&&e.jsxs("span",{className:"text-xs text-[#666666]",children:[y.length," memories"]}),e.jsx("button",{onClick:()=>h.mutate({toolName:t}),disabled:h.isPending||y.length===0,className:`ml-auto ${i.outlineBtn}`,title:"Optimize memories with AI",children:h.isPending&&h.variables?.toolName===t?e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(T,{size:"sm"})," Optimizing..."]}):"Optimize"})]}),e.jsx("ul",{className:`space-y-2${C?" max-h-64 overflow-y-auto":""}`,children:y.map(w=>e.jsx(pe,{memory:w,...D},w.id))})]},t)}),e.jsx(K,{open:u!==null,title:"Delete memory",message:"Delete this agent memory?",onConfirm:()=>{u!==null&&x.mutate({id:u}),b(null)},onCancel:()=>b(null)}),e.jsx(K,{open:d!==null,title:"Optimization Complete",message:d&&e.jsxs("div",{className:"space-y-1.5 text-sm text-[#444444]",children:[e.jsxs("p",{children:["Kept: ",e.jsx("span",{className:"font-medium",children:d.kept})]}),e.jsxs("p",{children:["Updated: ",e.jsx("span",{className:"font-medium",children:d.updated})]}),e.jsxs("p",{children:["Deleted: ",e.jsx("span",{className:"font-medium",children:d.deleted})]})]}),confirmLabel:"OK",cancelLabel:null,confirmStyle:"primary",onConfirm:()=>r(null),onCancel:()=>r(null)})]})}const G=["Pacific/Auckland","Australia/Sydney","Asia/Tokyo","Asia/Shanghai","Asia/Kolkata","Asia/Dubai","Europe/Moscow","Europe/Berlin","UTC","Europe/London","America/Sao_Paulo","America/New_York","America/Chicago","America/Denver","America/Los_Angeles","Pacific/Honolulu"];function V(s){try{const n=new Intl.DateTimeFormat("en-US",{timeZone:s,timeZoneName:"short"}).formatToParts(new Date).find(a=>a.type==="timeZoneName")?.value??"",o=new Intl.DateTimeFormat("en-US",{timeZone:s,timeZoneName:"shortOffset"}).formatToParts(new Date).find(a=>a.type==="timeZoneName")?.value??"";return`${n} (${o})`}catch{return s}}const he=new Map(G.map(s=>[s,V(s)]));function fe(){const s=p.useUtils(),{data:n,isLoading:o}=p.settings.getAgentConfig.useQuery(),a=p.settings.saveAgentConfig.useMutation({onSuccess:()=>{s.settings.getAgentConfig.invalidate(),b(!1)}}),[c,m]=g.useState(""),[x,d]=g.useState(100),[r,h]=g.useState(50),[l,f]=g.useState(1024),[v,N]=g.useState(1e4),[u,b]=g.useState(!1);if(g.useEffect(()=>{n&&(m(n.timezone),d(n.directModeMaxSteps),h(n.subAgentMaxSteps),f(n.thinkingBudgetGoogle),N(n.thinkingBudgetAnthropic),b(!1))},[n]),o||!n)return null;const S=u&&(c!==n.timezone||x!==n.directModeMaxSteps||r!==n.subAgentMaxSteps||l!==n.thinkingBudgetGoogle||v!==n.thinkingBudgetAnthropic);function A(){a.mutate({timezone:c,directModeMaxSteps:x,subAgentMaxSteps:r,thinkingBudgetGoogle:l,thinkingBudgetAnthropic:v})}function k(){b(!0)}return e.jsx("div",{className:"max-w-lg",children:e.jsxs("div",{className:i.settingsCard,children:[e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx("label",{className:"text-xs text-[#666666] w-44 shrink-0",children:"Timezone"}),e.jsxs("select",{value:c,onChange:j=>{m(j.target.value),k()},className:"appearance-none bg-white border border-[#d4d2cd] rounded px-3 py-1.5 text-xs text-[#2c2c2c] focus:outline-none focus:border-[#2b5ea7] font-sans",children:[G.map(j=>e.jsx("option",{value:j,children:he.get(j)??j},j)),!G.includes(c)&&e.jsx("option",{value:c,children:V(c)})]})]}),e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx("label",{className:"text-xs text-[#666666] w-44 shrink-0",children:"Direct mode max steps"}),e.jsx("input",{type:"number",min:1,max:500,value:x,onChange:j=>{d(Number(j.target.value)),k()},className:"w-20 bg-white border border-[#d4d2cd] rounded px-3 py-1.5 text-xs text-[#2c2c2c] focus:outline-none focus:border-[#2b5ea7] font-mono"})]}),e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx("label",{className:"text-xs text-[#666666] w-44 shrink-0",children:"Sub-agent max steps"}),e.jsx("input",{type:"number",min:1,max:500,value:r,onChange:j=>{h(Number(j.target.value)),k()},className:"w-20 bg-white border border-[#d4d2cd] rounded px-3 py-1.5 text-xs text-[#2c2c2c] focus:outline-none focus:border-[#2b5ea7] font-mono"})]}),e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx("label",{className:"text-xs text-[#666666] w-44 shrink-0",children:"Google thinking budget"}),e.jsx("input",{type:"number",min:0,max:1e5,step:256,value:l,onChange:j=>{f(Number(j.target.value)),k()},className:"w-24 bg-white border border-[#d4d2cd] rounded px-3 py-1.5 text-xs text-[#2c2c2c] focus:outline-none focus:border-[#2b5ea7] font-mono"}),e.jsx("span",{className:"text-[10px] text-[#9c9890]",children:"tokens"})]}),e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx("label",{className:"text-xs text-[#666666] w-44 shrink-0",children:"Anthropic thinking budget"}),e.jsx("input",{type:"number",min:0,max:1e5,step:1e3,value:v,onChange:j=>{N(Number(j.target.value)),k()},className:"w-24 bg-white border border-[#d4d2cd] rounded px-3 py-1.5 text-xs text-[#2c2c2c] focus:outline-none focus:border-[#2b5ea7] font-mono"}),e.jsx("span",{className:"text-[10px] text-[#9c9890]",children:"tokens"})]})]}),e.jsxs("div",{className:"flex items-center gap-3 mt-4 pt-3 border-t border-[#e8e6e1]",children:[e.jsx("button",{onClick:A,disabled:!S||a.isPending,className:i.primaryBtn,children:a.isPending?"Saving...":"Save"}),a.isSuccess&&!u&&e.jsx("span",{className:i.successText,children:"Saved"})]})]})})}function be(){return e.jsxs("div",{className:i.page,children:[e.jsxs("div",{children:[e.jsx("h3",{className:i.sectionTitle,children:"LLM API Keys"}),e.jsx(ae,{})]}),e.jsxs("div",{children:[e.jsx("h3",{className:i.sectionTitle,children:"Data Providers"}),e.jsx(xe,{})]}),e.jsxs("div",{children:[e.jsx("h3",{className:i.sectionTitle,children:"Agent Configuration"}),e.jsx(fe,{})]}),e.jsxs("div",{children:[e.jsx("h3",{className:i.sectionTitle,children:"Agent Memory"}),e.jsx(ge,{})]})]})}export{be as Settings};
@@ -1 +1 @@
1
- import{R as p,L as x,A as d}from"./mermaid-GHXKKRXX-DQ_Kyq22.js";import{r,j as f}from"./index-DqPm6rps.js";import"./SearchableSelect-CvsTUEdo.js";var j=({code:i,language:e,raw:t,className:m,startLine:u,lineNumbers:n,...g})=>{let{shikiTheme:o}=r.useContext(p),a=x(),[h,s]=r.useState(t);return r.useEffect(()=>{if(!a){s(t);return}let l=a.highlight({code:i,language:e,themes:o},c=>{s(c)});l&&s(l)},[i,e,o,a,t]),f.jsx(d,{className:m,language:e,lineNumbers:n,result:h,startLine:u,...g})};export{j as HighlightedCodeBlockBody};
1
+ import{R as p,L as x,A as d}from"./mermaid-GHXKKRXX-Cga6EKax.js";import{r,j as f}from"./index-B7y1naN3.js";import"./SearchableSelect-B006wjjM.js";var j=({code:i,language:e,raw:t,className:m,startLine:u,lineNumbers:n,...g})=>{let{shikiTheme:o}=r.useContext(p),a=x(),[h,s]=r.useState(t);return r.useEffect(()=>{if(!a){s(t);return}let l=a.highlight({code:i,language:e,themes:o},c=>{s(c)});l&&s(l)},[i,e,o,a,t]),f.jsx(d,{className:m,language:e,lineNumbers:n,result:h,startLine:u,...g})};export{j as HighlightedCodeBlockBody};