tracer-sh 0.3.2 → 0.3.3
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 +6 -2
- package/packages/server/dist/{chunk-YL5JSOUN.js → chunk-N2HWGQP2.js} +1 -1
- package/packages/server/dist/{chunk-IAWOYD5E.js → chunk-XTJ4UUIY.js} +1 -1
- package/packages/server/dist/{chunk-5GQDB6U7.js → chunk-ZAYYPDZP.js} +12 -3
- package/packages/server/dist/{dist-ZMUHFP5T.js → dist-L5BLKJXH.js} +1 -1
- package/packages/server/dist/{domain-knowledge-B2IREATL.js → domain-knowledge-6MEHHDWL.js} +1 -1
- package/packages/server/dist/{domain-knowledge-U2RLSFM2.js → domain-knowledge-HC2HKQB3.js} +1 -1
- package/packages/server/dist/{domain-knowledge-K3OB4NDB.js → domain-knowledge-RET7XGI5.js} +1 -1
- package/packages/server/dist/index.js +46 -44
- package/packages/server/dist/{multipart-parser-ONCUQ5VA.js → multipart-parser-MCEP54QZ.js} +2 -2
- package/packages/server/dist/{src-434DTNEL.js → src-TVEEC6CW.js} +3 -3
- package/packages/server/dist/{token-4YFRZJYT.js → token-R3E2IC23.js} +2 -2
- package/packages/server/dist/{token-util-CTKMWUIG.js → token-util-BJYJMNB3.js} +2 -2
- package/packages/web/dist/assets/{SearchableSelect-BGG4ZQsh.js → SearchableSelect-BfcFMllA.js} +1 -1
- package/packages/web/dist/assets/{Settings-CbI-LDKy.js → Settings-BcbW-KcM.js} +1 -1
- package/packages/web/dist/assets/{highlighted-body-OFNGDK62-DZkDbKbU.js → highlighted-body-OFNGDK62-BA7knzgi.js} +1 -1
- package/packages/web/dist/assets/{index-D555Ai5J.js → index-L_n_IFmZ.js} +2 -2
- package/packages/web/dist/assets/{mermaid-GHXKKRXX-B2DXmpLw.js → mermaid-GHXKKRXX-C5BzUoQE.js} +3 -3
- package/packages/web/dist/index.html +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import{t as m,r as f,j as e,S as I,c as _,b as a,C as E,u as X,W as V,A as ee,d as de,g as ue,m as O,p as G,e as se,M as me}from"./index-D555Ai5J.js";import{S as te}from"./SearchableSelect-BGG4ZQsh.js";function W({type:s,label:t,note:l}){const i=m.useUtils(),{data:o,isLoading:x}=m.settings.getApiKey.useQuery(s),p=m.settings.saveApiKey.useMutation({onSuccess:()=>i.settings.getApiKey.invalidate(s)}),d=m.settings.removeApiKey.useMutation({onSuccess:()=>i.settings.getApiKey.invalidate(s)}),[h,r]=f.useState(!1),[g,u]=f.useState(""),[v,b]=f.useState(!1);async function C(){await p.mutateAsync({type:s,apiKey:g}),u(""),r(!1)}async function c(){await d.mutateAsync(s),r(!1),b(!1)}return x?e.jsx("div",{className:"px-4 py-3",children:e.jsx(I,{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:t}),e.jsx("span",{className:a.maskedKey+" flex-1 truncate",style:o?{color:_.success}:void 0,children:o?o.maskedApiKey:"Not configured"}),!h&&e.jsx("button",{onClick:()=>{u(""),r(!0)},className:a.secondaryBtn+" text-xs px-3 py-1",children:o?"Edit":"Add"})]}),h&&e.jsxs("div",{className:"mt-3 pt-3 border-t border-[#e8e6e1] space-y-2",children:[l&&e.jsx("div",{children:l}),e.jsx("input",{type:g?"password":"text",value:g,onChange:N=>u(N.target.value),placeholder:o?.maskedApiKey??"Enter API key",className:a.input}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{onClick:C,disabled:!g||p.isPending,className:a.primaryBtn+" text-xs px-3 py-1",children:p.isPending?e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsx(I,{size:"sm"})," Saving..."]}):"Save"}),e.jsx("button",{onClick:()=>r(!1),disabled:p.isPending,className:a.secondaryBtn+" text-xs px-3 py-1",children:"Cancel"}),o&&e.jsx("button",{onClick:()=>b(!0),disabled:d.isPending,className:a.dangerBtn+" text-xs px-3 py-1",children:"Remove"})]})]}),e.jsx(E,{open:v,title:"Remove API key",message:`Remove the ${t} API key?`,confirmLabel:"Remove",onConfirm:c,onCancel:()=>b(!1)})]})}function J({checked:s,onChange:t,disabled:l,"aria-label":i}){return e.jsx("button",{type:"button",role:"switch","aria-checked":s,"aria-label":i,disabled:l,onClick:()=>t(!s),className:`relative inline-flex h-5 w-9 items-center rounded-full transition-colors ${s?"bg-[#2b5ea7]":"bg-[#d4d2cd]"} ${l?"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 H({status:s,label:t}){return e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:`inline-block h-2 w-2 rounded-full ${a.statusDot[s]}`}),t&&e.jsx("span",{className:a.statusLabel,children:t})]})}function xe(){const s=m.useUtils(),{data:t,isLoading:l}=m.settings.getVertexConfig.useQuery(),i=X(),o=!!t,x=i.data,p=x?.ok??!1,d=o&&p,h=()=>{s.settings.getVertexConfig.invalidate(),s.provider.listVertexModels.invalidate()},r=m.settings.saveVertexConfig.useMutation({onSuccess:h}),g=m.settings.removeVertexConfig.useMutation({onSuccess:h}),u=r.isPending||g.isPending,[v,b]=f.useState(!1),{data:C,isLoading:c}=m.provider.listGcpProjects.useQuery(void 0,{staleTime:V.updateCheckStaleTimeMs,enabled:d}),N=f.useMemo(()=>(C??[]).map(y=>({value:y.projectId,label:y.name?`${y.name} (${y.projectId})`:y.projectId,displayLabel:y.name||y.projectId})),[C]);function S(y){y?r.mutate({}):b(!0)}function k(){g.mutate(),b(!1)}function j(y){y!==t?.projectId&&r.mutate({projectId:y})}return l?e.jsx("div",{className:"px-4 py-3",children:e.jsx(I,{size:"sm"})}):e.jsxs("div",{className:"px-4 py-3",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(J,{checked:o,onChange:S,disabled:u,"aria-label":"Enable Vertex AI"}),e.jsx("span",{className:"text-sm font-medium",children:"Vertex AI"}),o?e.jsx(H,{status:d?"connected":"disconnected"}):e.jsx("span",{className:"text-xs opacity-40",children:"Not configured"})]}),o&&e.jsx("div",{className:"mt-3 pt-3 border-t border-[#e8e6e1]",children:i.isLoading?e.jsxs("div",{className:"flex items-center gap-2 text-xs text-[#666666]",children:[e.jsx(I,{size:"sm"})," Checking authentication…"]}):p?e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("span",{className:"text-xs text-[#666666] whitespace-nowrap w-14",children:"Project"}),e.jsx("div",{className:"flex-1",children:e.jsx(te,{options:N,value:t?.projectId??"",onChange:j,placeholder:c?"Loading...":"Select project...",storageKey:"gcp-projectId",fitContent:!0,disabled:c||u})})]}),e.jsx(pe,{value:t?.location??"global",onCommit:y=>{const P=y.trim()||"global";P!==t?.location&&r.mutate({location:P})},disabled:u})]}):e.jsx("p",{className:a.warnText,children:x&&!x.ok?x.message:"Not authenticated. Run: gcloud auth application-default login"})}),e.jsx(E,{open:v,title:"Disable Vertex AI",message:"Disable Vertex AI? Your project selection will be removed.",confirmLabel:"Disable",onConfirm:k,onCancel:()=>b(!1)})]})}function pe({value:s,onCommit:t,disabled:l}){const[i,o]=f.useState(s);return f.useEffect(()=>o(s),[s]),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("span",{className:"text-xs text-[#666666] whitespace-nowrap w-14",children:"Location"}),e.jsx("input",{type:"text",value:i,onChange:x=>o(x.target.value),onBlur:()=>t(i),onKeyDown:x=>{x.key==="Enter"&&x.currentTarget.blur()},placeholder:"global",disabled:l,className:a.input})]})}function ge({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:a.tableHeaderRow,children:[e.jsx("th",{className:a.tableHeaderCell+" text-xs py-2",children:"Model"}),e.jsx("th",{className:a.tableHeaderCell+" text-xs py-2",children:"Provider"}),e.jsx("th",{className:a.tableHeaderCell+" text-xs py-2 text-right",children:"Input ($/M)"}),e.jsx("th",{className:a.tableHeaderCell+" text-xs py-2 text-right",children:"Output ($/M)"})]})}),e.jsx("tbody",{className:"divide-y divide-[#e8e6e1]",children:ee.map(t=>{const l=s.has(t.provider);return e.jsxs("tr",{style:l?{color:_.success}:{color:_.inkFaint},children:[e.jsx("td",{className:"px-4 py-2 font-mono text-xs",children:t.modelId}),e.jsx("td",{className:"px-4 py-2 capitalize",children:t.provider}),e.jsxs("td",{className:"px-4 py-2 text-right font-mono text-xs",children:["$",t.inputPrice.toFixed(2)]}),e.jsxs("td",{className:"px-4 py-2 text-right font-mono text-xs",children:["$",t.outputPrice.toFixed(2)]})]},t.modelId)})})]})})}function $({children:s}){return e.jsx("div",{className:"text-xs leading-relaxed rounded border border-[#d4d2cd] bg-[#f5f4f1] p-3 space-y-2",children:s})}const Z="underline break-all text-[#0052cc]",he=e.jsxs($,{children:[e.jsxs("div",{children:["Create a Gemini API key at:",e.jsx("br",{}),e.jsx("a",{href:"https://aistudio.google.com/api-keys",target:"_blank",rel:"noopener noreferrer",className:Z,children:"https://aistudio.google.com/api-keys"})]}),e.jsx("div",{className:"opacity-80",children:"This key powers the Gemini models Tracer uses to run chats and analyze your data — it is the model provider, not a data source. Tracer sends your prompts and the data it has already fetched to Google's Gemini API for inference; it grants no access back into your Google account."})]});function fe(){const[s,t]=f.useState(!1),l=de();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(W,{type:"anthropic",label:"Anthropic"}),e.jsx(W,{type:"google",label:"Google AI",note:he}),e.jsx(xe,{})]}),e.jsxs("div",{className:"bg-white border border-[#d4d2cd] rounded overflow-hidden",children:[e.jsxs("button",{onClick:()=>t(!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(ge,{configuredProviders:l})]})]})}function ne({value:s,models:t,onChange:l,loading:i,disabled:o,label:x="Model"}){const p=ue(t),d=O(s),r=!t.some(u=>O(u)===d)&&!i;function g(u){const v=u.indexOf(":");l({provider:u.slice(0,v),modelId:u.slice(v+1)})}return e.jsxs("div",{className:"flex items-start gap-3 mt-3 pt-3 border-t border-[#d4d2cd]",children:[e.jsx("span",{className:"text-xs text-[#666666] whitespace-nowrap w-14 mt-2",children:x}),e.jsxs("div",{className:"flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"shrink-0 inline-flex items-center rounded px-1.5 py-0.5 text-[10px] font-medium bg-[#f0eee9] text-[#666666] border border-[#d4d2cd]",children:G(s.provider)}),e.jsxs("div",{className:"relative flex-1",children:[e.jsxs("select",{value:d,onChange:u=>g(u.target.value),disabled:o,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:[r&&e.jsx("optgroup",{label:"Unavailable",children:e.jsxs("option",{value:d,children:[G(s.provider)," · ",s.modelId]})}),p.map(u=>e.jsx("optgroup",{label:u.label,children:u.models.map(v=>e.jsx("option",{value:O(v),children:v.modelId},O(v)))},u.provider))]}),e.jsx("span",{className:"pointer-events-none absolute right-2 top-1/2 -translate-y-1/2 text-[#9c9890] text-[10px]",children:"▾"})]})]}),r&&e.jsxs("p",{className:a.warnText+" mt-1.5",children:[G(s.provider)," · ",s.modelId," isn’t available. Configure its provider or pick another model."]})]})]})}const je=ee[0];function ve({providerType:s}){const t=m.useUtils(),{data:l,isLoading:i}=m.settings.getSubAgentModel.useQuery(s),o=m.settings.saveSubAgentModel.useMutation({onSuccess:()=>t.settings.getSubAgentModel.invalidate(s)}),{models:x,isLoading:p}=se();if(i)return null;const d=l??je;return e.jsx(ne,{value:d,models:x,loading:p,disabled:o.isPending,onChange:h=>o.mutate({providerType:s,model:{provider:h.provider,modelId:h.modelId}})})}function be({existingConfig:s}){const t=m.useUtils(),l=X(),{data:i,isLoading:o}=m.provider.listGcpProjects.useQuery(void 0,{staleTime:V.updateCheckStaleTimeMs}),x=m.provider.saveConfig.useMutation({onSuccess:()=>{t.provider.getConfigs.invalidate(),t.provider.list.invalidate()}}),p=f.useMemo(()=>(i??[]).map(r=>({value:r.projectId,label:r.name?`${r.name} (${r.projectId})`:r.projectId,displayLabel:r.name||r.projectId})),[i]),d=s.projectId??"";if(l.data&&!l.data.ok)return null;function h(r){r!==d&&x.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(te,{options:p,value:d,onChange:h,placeholder:o?"Loading...":"Select project...",storageKey:"gcp-projectId",fitContent:!0,disabled:o||x.isPending})})]})}function ye({type:s,label:t,connected:l,configured:i,onConfigure:o,onToggle:x,togglePending:p,toggleError:d,pingError:h,hasConfigFields:r,existingConfig:g}){const u=i||l;return e.jsxs("div",{className:a.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(J,{checked:i,onChange:v=>{v&&r?o():x(v)},disabled:p}),e.jsx("span",{className:"font-medium",children:t}),u?e.jsx(H,{status:l?"connected":"disconnected"}):e.jsx("span",{className:"text-xs opacity-40",children:"Not configured"})]}),e.jsx("button",{onClick:o,className:`${a.secondaryBtn} ${i&&r?"":"invisible"}`,children:"Edit"})]}),u&&e.jsx(ve,{providerType:s}),u&&s==="gcp"&&g&&e.jsx(be,{existingConfig:g}),h&&!l&&e.jsx("p",{className:a.warnText+" mt-2",children:h}),d&&e.jsx("p",{className:a.errorText+" mt-2",children:d})]})}function Y(s,t){return!!s&&!!t&&s===t}function ae({open:s,label:t,configFields:l,formValues:i,onFormChange:o,existingConfig:x,saveResult:p,savePending:d,configured:h,note:r,onSave:g,onClose:u,onRemove:v}){const b=l.some(c=>c.required!==!1&&c.type==="password"&&Y(i[c.key],x?.[c.key])),C=l.some(c=>c.required!==!1&&!i[c.key]);return e.jsxs(me,{open:s,onClose:u,children:[e.jsxs("div",{className:a.dialogTitle+" text-base mb-4",children:["Configure ",t]}),r&&e.jsx("div",{className:"mb-4",children:r}),e.jsx("div",{className:"space-y-3",children:l.map(c=>{const N=c.type==="password"&&Y(i[c.key],x?.[c.key]);return e.jsxs("div",{children:[e.jsxs("label",{className:a.sectionTitle,children:[c.label,c.required===!1&&e.jsx("span",{className:"text-xs opacity-40 ml-1",children:"(optional)"})]}),e.jsx("input",{type:c.type==="password"&&i[c.key]&&!N?"password":"text",value:i[c.key]??"",onChange:S=>o(c.key,S.target.value),onFocus:S=>{N&&S.target.select()},placeholder:`Enter ${c.label.toLowerCase()}`,className:`${a.input} ${N?"!text-[#999] !border-l-2 !border-l-amber-400":""}`})]},c.key)})}),e.jsxs("div",{className:"flex items-center gap-2 mt-4 pt-4 border-t border-[#d4d2cd]",children:[e.jsx("button",{onClick:g,disabled:C||b||d,className:a.primaryBtn,children:d?e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsx(I,{size:"sm"})," Saving..."]}):"Save & Test"}),e.jsx("button",{onClick:u,disabled:d,className:a.secondaryBtn,children:"Cancel"}),h&&e.jsx("button",{onClick:v,disabled:d,className:a.dangerBtn,children:"Remove"})]}),b&&!d&&!p&&e.jsx("p",{className:"mt-2 text-xs text-amber-600",children:"Re-enter highlighted fields to save"}),p&&e.jsx("div",{className:`mt-3 ${p.success?a.successText:a.errorText}`,children:p.success?"Connected successfully":p.error||"Connection failed"})]})}const Ne={newrelic:e.jsxs($,{children:[e.jsxs("div",{children:["Create a ",e.jsx("span",{className:"font-medium",children:"User key"})," at:",e.jsx("br",{}),e.jsx("a",{href:"https://one.newrelic.com/admin-portal/api-keys/home",target:"_blank",rel:"noopener noreferrer",className:Z,children:"https://one.newrelic.com/admin-portal/api-keys/home"}),e.jsx("br",{}),"Your numeric Account ID is shown on the same page."]}),e.jsxs("div",{children:[e.jsx("div",{className:"font-medium",children:"What Tracer can do with it"}),e.jsx("ul",{className:"list-disc ml-4 mt-1 space-y-0.5",children:e.jsxs("li",{children:[e.jsx("span",{className:"font-medium",children:"Run read-only NRQL queries"})," against your account — to inspect metrics, logs, traces, and errors while investigating."]})})]}),e.jsx("div",{className:"opacity-80",children:"It only reads via NRQL. It cannot write, modify, deploy, or delete anything. A New Relic User key inherits your role, so for least privilege use a user scoped to read-only access."})]}),posthog:e.jsxs($,{children:[e.jsxs("div",{children:["Create a ",e.jsx("span",{className:"font-medium",children:"Personal API key"})," in your PostHog instance at:",e.jsx("br",{}),e.jsx("span",{className:"font-mono",children:"/settings/user-api-keys"}),e.jsx("br",{}),"Grant it the single scope ",e.jsx("span",{className:"font-medium",children:"Query → Read"}),". The Project ID is in Settings → Project. Set Host only if you are not on US cloud (e.g.",e.jsx("span",{className:"font-mono",children:" eu.posthog.com"})," or a self-hosted URL)."]}),e.jsxs("div",{children:[e.jsx("div",{className:"font-medium",children:"What Tracer can do with it"}),e.jsx("ul",{className:"list-disc ml-4 mt-1 space-y-0.5",children:e.jsxs("li",{children:[e.jsx("span",{className:"font-medium",children:"Run read-only HogQL queries"})," against the project — to inspect events, persons, and analytics while investigating."]})})]}),e.jsxs("div",{className:"opacity-80",children:["With only the ",e.jsx("span",{className:"font-medium",children:"Query → Read"})," scope it cannot create, modify, or delete anything in PostHog, and it reaches only the project you configure."]})]})};function Ce(s,t){const l={};for(const i of s)l[i.key]=t?.[i.key]??"";return l}function we(){const s=m.useUtils(),{data:t,isLoading:l}=m.provider.list.useQuery(),{data:i,isLoading:o}=m.provider.getConfigs.useQuery(),{data:x,isLoading:p}=m.provider.getRegisteredTypes.useQuery(),{data:d}=m.provider.ping.useQuery(void 0,{staleTime:V.sessionStaleTimeMs,refetchOnMount:"always"}),h=m.provider.saveConfig.useMutation({onSuccess:()=>{s.provider.list.invalidate(),s.provider.getConfigs.invalidate(),s.provider.ping.invalidate()}}),r=m.provider.removeConfig.useMutation({onSuccess:()=>{s.provider.list.invalidate(),s.provider.getConfigs.invalidate(),s.provider.ping.invalidate()}}),[g,u]=f.useState(null),[v,b]=f.useState({}),[C,c]=f.useState(null),[N,S]=f.useState(null),[k,j]=f.useState({});function y(n){const w=i?.find(M=>M.type===n),A=x?.find(M=>M.type===n);b(Ce(A?.configFields??[],w?.config)),c(null),u(n)}function P(){u(null),b({}),c(null)}async function U(n){c(null);try{const w=await h.mutateAsync({type:n,config:v});c(w),w.success&&(u(null),b({}))}catch{c({success:!1,error:"Failed to save configuration"})}}async function F(n,w){if(w){j(A=>{const M={...A};return delete M[n],M});try{const A=await h.mutateAsync({type:n,config:{}});A.success||j(M=>({...M,[n]:A.error??"Connection failed"}))}catch{j(A=>({...A,[n]:"Failed to save configuration"}))}}else S(n)}async function K(n){await r.mutateAsync(n),u(null),b({}),c(null),S(null)}const z=l||o||p,R=x??[];if(z)return e.jsx(I,{size:"lg",centered:!0});const T=g?R.find(n=>n.type===g):null,B=g?i?.find(n=>n.type===g):null;return e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"flex flex-wrap gap-3",children:R.map(({type:n,label:w,configFields:A})=>{const M=t?.find(L=>L.type===n),q=i?.find(L=>L.type===n),oe=!!q,D=d?.find(L=>L.type===n),le=D?D.ok:!!M?.connected,re=A.length>0,ce=D&&!D.ok?D.error:void 0;return e.jsx(ye,{type:n,label:w,connected:le,configured:oe,onConfigure:()=>y(n),onToggle:L=>F(n,L),togglePending:h.isPending||r.isPending,toggleError:k[n],pingError:ce,hasConfigFields:re,existingConfig:q?.config},n)})}),g&&T&&e.jsx(ae,{open:!0,label:T.label,configFields:T.configFields,formValues:v,onFormChange:(n,w)=>b(A=>({...A,[n]:w})),existingConfig:B?.config??null,saveResult:C,savePending:h.isPending,configured:!!B,note:Ne[g],onSave:()=>U(g),onClose:P,onRemove:()=>S(g)}),e.jsx(E,{open:N!==null,title:"Disable provider",message:`Disable ${R.find(n=>n.type===N)?.label??N}?`,confirmLabel:"Disable",onConfirm:()=>{N&&K(N)},onCancel:()=>S(null)})]})}const Se=[{key:"domain",label:"Domain (yourco → yourco.atlassian.net)",type:"text"},{key:"email",label:"Email",type:"text"},{key:"apiToken",label:"API Token",type:"password"}],ke=e.jsxs($,{children:[e.jsxs("div",{children:["Create a token (use the plain ",e.jsx("span",{className:"font-medium",children:"Create API token"}),', not "with scopes") at:',e.jsx("br",{}),e.jsx("a",{href:"https://id.atlassian.com/manage-profile/security/api-tokens",target:"_blank",rel:"noopener noreferrer",className:Z,children:"https://id.atlassian.com/manage-profile/security/api-tokens"})]}),e.jsxs("div",{children:[e.jsx("div",{className:"font-medium",children:"What Tracer can do with it"}),e.jsxs("ul",{className:"list-disc ml-4 mt-1 space-y-0.5",children:[e.jsxs("li",{children:[e.jsx("span",{className:"font-medium",children:"Read an issue"})," — summary, description, status, type, priority, assignee, reporter, labels, components, fix versions, resolution, dates, and its comment thread"]}),e.jsxs("li",{children:[e.jsx("span",{className:"font-medium",children:"Post a comment"})," — plain text, only when you ask"]})]})]}),e.jsx("div",{className:"opacity-80",children:"It cannot edit, transition, delete, bulk-read, or administer anything else. The token uses its account's permissions, so for least privilege point it at a Jira account limited to the projects Tracer should touch."})]});function Ae(){const s=m.useUtils(),{data:t,isLoading:l}=m.integrations.getJira.useQuery(),i=m.integrations.saveJira.useMutation({onSuccess:()=>s.integrations.getJira.invalidate()}),o=m.integrations.removeJira.useMutation({onSuccess:()=>s.integrations.getJira.invalidate()}),[x,p]=f.useState(!1),[d,h]=f.useState({}),[r,g]=f.useState(null),[u,v]=f.useState(!1),b=!!t?.configured,C=t?.config??null;function c(){h({domain:C?.domain??"",email:C?.email??"",apiToken:C?.apiToken??""}),g(null),p(!0)}function N(){p(!1),h({}),g(null)}async function S(){g(null);try{const j=await i.mutateAsync({domain:d.domain??"",email:d.email??"",apiToken:d.apiToken??""});g(j),j.success&&N()}catch{g({success:!1,error:"Failed to save configuration"})}}async function k(){await o.mutateAsync(),v(!1),N()}return l?e.jsx(I,{size:"lg",centered:!0}):e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"flex flex-wrap gap-3",children:e.jsx("div",{className:a.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(J,{checked:b,onChange:j=>{j?c():v(!0)},disabled:i.isPending||o.isPending}),e.jsx("span",{className:"font-medium",children:"Jira"}),b?e.jsx(H,{status:"connected"}):e.jsx("span",{className:"text-xs opacity-40",children:"Not configured"})]}),e.jsx("button",{onClick:c,className:`${a.secondaryBtn} ${b?"":"invisible"}`,children:"Edit"})]})})}),x&&e.jsx(ae,{open:!0,label:"Jira",configFields:Se,formValues:d,onFormChange:(j,y)=>h(P=>({...P,[j]:y})),existingConfig:C,saveResult:r,savePending:i.isPending,configured:b,note:ke,onSave:S,onClose:N,onRemove:()=>v(!0)}),e.jsx(E,{open:u,title:"Disable Jira",message:"Disable the Jira integration?",confirmLabel:"Disable",onConfirm:k,onCancel:()=>v(!1)})]})}function Me({memory:s,editingId:t,editNote:l,setEditNote:i,onUpdate:o,onCancelEdit:x,onStartEdit:p,onDelete:d,updatePending:h,removePending:r}){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:t===s.id?e.jsxs("div",{className:"space-y-2",children:[e.jsx("input",{type:"text",value:l,onChange:g=>i(g.target.value),className:a.input}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{onClick:()=>o(s.id),disabled:!l||h,className:a.primaryBtn,children:"Save"}),e.jsx("button",{onClick:x,disabled:h,className:a.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()})]})}),t!==s.id&&e.jsxs("div",{className:"flex items-center gap-1 shrink-0",children:[e.jsx("button",{onClick:()=>p(s.id,s.note),className:a.secondaryBtn,children:"Edit"}),e.jsx("button",{onClick:()=>d(s.id),disabled:r,className:a.dangerBtn,children:"Delete"})]})]})}function Pe(){const s=m.useUtils(),{data:t,isLoading:l}=m.memory.list.useQuery(),{data:i}=m.provider.getRegisteredTypes.useQuery(),o=m.memory.create.useMutation({onSuccess:()=>{s.memory.list.invalidate(),P(""),j("unified"),S(!1)}}),x=m.memory.update.useMutation({onSuccess:()=>s.memory.list.invalidate()}),p=m.memory.remove.useMutation({onSuccess:()=>s.memory.list.invalidate()}),[d,h]=f.useState(null),r=m.memory.optimize.useMutation({onSuccess:n=>{s.memory.list.invalidate(),h(n.stats)}}),[g,u]=f.useState(null),[v,b]=f.useState(""),[C,c]=f.useState(null),[N,S]=f.useState(!1),[k,j]=f.useState("unified"),[y,P]=f.useState("");function U(n,w){u(n),b(w)}async function F(n){await x.mutateAsync({id:n,note:v}),u(null),b("")}function K(){u(null),b("")}const z=[{value:"unified",label:"Unified"},...(i??[]).map(n=>({value:n.type,label:n.label}))],R=5;if(l)return e.jsx(I,{size:"lg",centered:!0});const T=new Map;if(t)for(const n of t){const w=T.get(n.toolName)??[];w.push(n),T.set(n.toolName,w)}const B={editingId:g,editNote:v,setEditNote:b,onUpdate:F,onCancelEdit:K,onStartEdit:U,onDelete:n=>c(n),updatePending:x.isPending,removePending:p.isPending};return e.jsxs("div",{className:"space-y-4",children:[N?e.jsxs("div",{className:a.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:n=>{j(n.target.value),n.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:z.map(n=>e.jsx("option",{value:n.value,children:n.label},n.value))})]}),e.jsxs("div",{children:[e.jsx("label",{className:a.sectionTitle,children:"Note"}),e.jsx("input",{type:"text",value:y,onChange:n=>P(n.target.value),onKeyDown:n=>{n.key==="Enter"&&y.trim()&&!o.isPending&&o.mutate({toolName:k,note:y})},placeholder:"Reusable lesson or pattern...",className:a.input})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{onClick:()=>o.mutate({toolName:k,note:y}),disabled:!y.trim()||o.isPending,className:a.primaryBtn,children:o.isPending?e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsx(I,{size:"sm"})," Saving..."]}):"Save"}),e.jsx("button",{onClick:()=>{S(!1),P(""),j("unified")},disabled:o.isPending,className:a.secondaryBtn,children:"Cancel"})]})]}):e.jsx("button",{onClick:()=>S(!0),className:a.secondaryBtn,children:"+ Add Memory"}),T.size===0&&e.jsx("div",{className:a.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."})}),[...T.entries()].map(([n,w])=>{const A=w.length>R;return e.jsxs("div",{className:a.settingsCard,children:[e.jsxs("div",{className:"mb-3 flex items-center gap-2",children:[e.jsx("span",{className:`${a.badge} ${a.badgeVariants.info}`,children:n}),A&&e.jsxs("span",{className:"text-xs text-[#666666]",children:[w.length," memories"]}),e.jsx("button",{onClick:()=>r.mutate({toolName:n}),disabled:r.isPending||w.length===0,className:`ml-auto ${a.outlineBtn}`,title:"Optimize memories with AI",children:r.isPending&&r.variables?.toolName===n?e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(I,{size:"sm"})," Optimizing..."]}):"Optimize"})]}),e.jsx("ul",{className:`space-y-2${A?" max-h-64 overflow-y-auto":""}`,children:w.map(M=>e.jsx(Me,{memory:M,...B},M.id))})]},n)}),e.jsx(E,{open:C!==null,title:"Delete memory",message:"Delete this agent memory?",onConfirm:()=>{C!==null&&p.mutate({id:C}),c(null)},onCancel:()=>c(null)}),e.jsx(E,{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:()=>h(null),onCancel:()=>h(null)})]})}function Ie(){const s=m.useUtils(),{data:t,isLoading:l}=m.settings.getChatModel.useQuery(),i=m.settings.saveChatModel.useMutation({onSuccess:()=>s.settings.getChatModel.invalidate()}),{models:o,isLoading:x}=se();return l||!t?null:e.jsx(ne,{value:t,models:o,loading:x,disabled:i.isPending,onChange:p=>i.mutate({provider:p.provider,modelId:p.modelId})})}const Q=["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 ie(s){try{const t=new Intl.DateTimeFormat("en-US",{timeZone:s,timeZoneName:"short"}).formatToParts(new Date).find(i=>i.type==="timeZoneName")?.value??"",l=new Intl.DateTimeFormat("en-US",{timeZone:s,timeZoneName:"shortOffset"}).formatToParts(new Date).find(i=>i.type==="timeZoneName")?.value??"";return`${t} (${l})`}catch{return s}}const Te=new Map(Q.map(s=>[s,ie(s)]));function Le(){const s=m.useUtils(),{data:t,isLoading:l}=m.settings.getAgentConfig.useQuery(),i=m.settings.saveAgentConfig.useMutation({onSuccess:()=>{s.settings.getAgentConfig.invalidate(),c(!1)}}),[o,x]=f.useState(""),[p,d]=f.useState(100),[h,r]=f.useState(50),[g,u]=f.useState(1024),[v,b]=f.useState(1e4),[C,c]=f.useState(!1);if(f.useEffect(()=>{t&&(x(t.timezone),d(t.directModeMaxSteps),r(t.subAgentMaxSteps),u(t.thinkingBudgetGoogle),b(t.thinkingBudgetAnthropic),c(!1))},[t]),l||!t)return null;const N=C&&(o!==t.timezone||p!==t.directModeMaxSteps||h!==t.subAgentMaxSteps||g!==t.thinkingBudgetGoogle||v!==t.thinkingBudgetAnthropic);function S(){i.mutate({timezone:o,directModeMaxSteps:p,subAgentMaxSteps:h,thinkingBudgetGoogle:g,thinkingBudgetAnthropic:v})}function k(){c(!0)}return e.jsxs("div",{className:"max-w-lg space-y-3",children:[e.jsxs("div",{className:a.settingsCard,children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-sm font-medium",children:"Unified mode model"}),e.jsx("span",{className:"text-xs opacity-40",children:"used when chat scope is “ALL”"})]}),e.jsx(Ie,{})]}),e.jsxs("div",{className:a.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:o,onChange:j=>{x(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:[Q.map(j=>e.jsx("option",{value:j,children:Te.get(j)??j},j)),!Q.includes(o)&&e.jsx("option",{value:o,children:ie(o)})]})]}),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:p,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:h,onChange:j=>{r(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:g,onChange:j=>{u(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=>{b(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:S,disabled:!N||i.isPending,className:a.primaryBtn,children:i.isPending?"Saving...":"Save"}),i.isSuccess&&!C&&e.jsx("span",{className:a.successText,children:"Saved"})]})]})]})}function De(){return e.jsxs("div",{className:a.page,children:[e.jsxs("div",{children:[e.jsx("h3",{className:a.sectionTitle,children:"LLM API Keys"}),e.jsx(fe,{})]}),e.jsxs("div",{children:[e.jsx("h3",{className:a.sectionTitle,children:"Data Providers"}),e.jsx(we,{})]}),e.jsxs("div",{children:[e.jsx("h3",{className:a.sectionTitle,children:"Integrations"}),e.jsx(Ae,{})]}),e.jsxs("div",{children:[e.jsx("h3",{className:a.sectionTitle,children:"Agent Configuration"}),e.jsx(Le,{})]}),e.jsxs("div",{children:[e.jsx("h3",{className:a.sectionTitle,children:"Agent Memory"}),e.jsx(Pe,{})]})]})}export{De as Settings};
|
|
1
|
+
import{t as m,r as f,j as e,S as I,c as _,b as a,C as E,u as X,W as V,A as ee,d as de,g as ue,m as O,p as G,e as se,M as me}from"./index-L_n_IFmZ.js";import{S as te}from"./SearchableSelect-BfcFMllA.js";function W({type:s,label:t,note:l}){const i=m.useUtils(),{data:o,isLoading:x}=m.settings.getApiKey.useQuery(s),p=m.settings.saveApiKey.useMutation({onSuccess:()=>i.settings.getApiKey.invalidate(s)}),d=m.settings.removeApiKey.useMutation({onSuccess:()=>i.settings.getApiKey.invalidate(s)}),[h,r]=f.useState(!1),[g,u]=f.useState(""),[v,b]=f.useState(!1);async function C(){await p.mutateAsync({type:s,apiKey:g}),u(""),r(!1)}async function c(){await d.mutateAsync(s),r(!1),b(!1)}return x?e.jsx("div",{className:"px-4 py-3",children:e.jsx(I,{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:t}),e.jsx("span",{className:a.maskedKey+" flex-1 truncate",style:o?{color:_.success}:void 0,children:o?o.maskedApiKey:"Not configured"}),!h&&e.jsx("button",{onClick:()=>{u(""),r(!0)},className:a.secondaryBtn+" text-xs px-3 py-1",children:o?"Edit":"Add"})]}),h&&e.jsxs("div",{className:"mt-3 pt-3 border-t border-[#e8e6e1] space-y-2",children:[l&&e.jsx("div",{children:l}),e.jsx("input",{type:g?"password":"text",value:g,onChange:N=>u(N.target.value),placeholder:o?.maskedApiKey??"Enter API key",className:a.input}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{onClick:C,disabled:!g||p.isPending,className:a.primaryBtn+" text-xs px-3 py-1",children:p.isPending?e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsx(I,{size:"sm"})," Saving..."]}):"Save"}),e.jsx("button",{onClick:()=>r(!1),disabled:p.isPending,className:a.secondaryBtn+" text-xs px-3 py-1",children:"Cancel"}),o&&e.jsx("button",{onClick:()=>b(!0),disabled:d.isPending,className:a.dangerBtn+" text-xs px-3 py-1",children:"Remove"})]})]}),e.jsx(E,{open:v,title:"Remove API key",message:`Remove the ${t} API key?`,confirmLabel:"Remove",onConfirm:c,onCancel:()=>b(!1)})]})}function J({checked:s,onChange:t,disabled:l,"aria-label":i}){return e.jsx("button",{type:"button",role:"switch","aria-checked":s,"aria-label":i,disabled:l,onClick:()=>t(!s),className:`relative inline-flex h-5 w-9 items-center rounded-full transition-colors ${s?"bg-[#2b5ea7]":"bg-[#d4d2cd]"} ${l?"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 H({status:s,label:t}){return e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:`inline-block h-2 w-2 rounded-full ${a.statusDot[s]}`}),t&&e.jsx("span",{className:a.statusLabel,children:t})]})}function xe(){const s=m.useUtils(),{data:t,isLoading:l}=m.settings.getVertexConfig.useQuery(),i=X(),o=!!t,x=i.data,p=x?.ok??!1,d=o&&p,h=()=>{s.settings.getVertexConfig.invalidate(),s.provider.listVertexModels.invalidate()},r=m.settings.saveVertexConfig.useMutation({onSuccess:h}),g=m.settings.removeVertexConfig.useMutation({onSuccess:h}),u=r.isPending||g.isPending,[v,b]=f.useState(!1),{data:C,isLoading:c}=m.provider.listGcpProjects.useQuery(void 0,{staleTime:V.updateCheckStaleTimeMs,enabled:d}),N=f.useMemo(()=>(C??[]).map(y=>({value:y.projectId,label:y.name?`${y.name} (${y.projectId})`:y.projectId,displayLabel:y.name||y.projectId})),[C]);function S(y){y?r.mutate({}):b(!0)}function k(){g.mutate(),b(!1)}function j(y){y!==t?.projectId&&r.mutate({projectId:y})}return l?e.jsx("div",{className:"px-4 py-3",children:e.jsx(I,{size:"sm"})}):e.jsxs("div",{className:"px-4 py-3",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(J,{checked:o,onChange:S,disabled:u,"aria-label":"Enable Vertex AI"}),e.jsx("span",{className:"text-sm font-medium",children:"Vertex AI"}),o?e.jsx(H,{status:d?"connected":"disconnected"}):e.jsx("span",{className:"text-xs opacity-40",children:"Not configured"})]}),o&&e.jsx("div",{className:"mt-3 pt-3 border-t border-[#e8e6e1]",children:i.isLoading?e.jsxs("div",{className:"flex items-center gap-2 text-xs text-[#666666]",children:[e.jsx(I,{size:"sm"})," Checking authentication…"]}):p?e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("span",{className:"text-xs text-[#666666] whitespace-nowrap w-14",children:"Project"}),e.jsx("div",{className:"flex-1",children:e.jsx(te,{options:N,value:t?.projectId??"",onChange:j,placeholder:c?"Loading...":"Select project...",storageKey:"gcp-projectId",fitContent:!0,disabled:c||u})})]}),e.jsx(pe,{value:t?.location??"global",onCommit:y=>{const P=y.trim()||"global";P!==t?.location&&r.mutate({location:P})},disabled:u})]}):e.jsx("p",{className:a.warnText,children:x&&!x.ok?x.message:"Not authenticated. Run: gcloud auth application-default login"})}),e.jsx(E,{open:v,title:"Disable Vertex AI",message:"Disable Vertex AI? Your project selection will be removed.",confirmLabel:"Disable",onConfirm:k,onCancel:()=>b(!1)})]})}function pe({value:s,onCommit:t,disabled:l}){const[i,o]=f.useState(s);return f.useEffect(()=>o(s),[s]),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("span",{className:"text-xs text-[#666666] whitespace-nowrap w-14",children:"Location"}),e.jsx("input",{type:"text",value:i,onChange:x=>o(x.target.value),onBlur:()=>t(i),onKeyDown:x=>{x.key==="Enter"&&x.currentTarget.blur()},placeholder:"global",disabled:l,className:a.input})]})}function ge({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:a.tableHeaderRow,children:[e.jsx("th",{className:a.tableHeaderCell+" text-xs py-2",children:"Model"}),e.jsx("th",{className:a.tableHeaderCell+" text-xs py-2",children:"Provider"}),e.jsx("th",{className:a.tableHeaderCell+" text-xs py-2 text-right",children:"Input ($/M)"}),e.jsx("th",{className:a.tableHeaderCell+" text-xs py-2 text-right",children:"Output ($/M)"})]})}),e.jsx("tbody",{className:"divide-y divide-[#e8e6e1]",children:ee.map(t=>{const l=s.has(t.provider);return e.jsxs("tr",{style:l?{color:_.success}:{color:_.inkFaint},children:[e.jsx("td",{className:"px-4 py-2 font-mono text-xs",children:t.modelId}),e.jsx("td",{className:"px-4 py-2 capitalize",children:t.provider}),e.jsxs("td",{className:"px-4 py-2 text-right font-mono text-xs",children:["$",t.inputPrice.toFixed(2)]}),e.jsxs("td",{className:"px-4 py-2 text-right font-mono text-xs",children:["$",t.outputPrice.toFixed(2)]})]},t.modelId)})})]})})}function $({children:s}){return e.jsx("div",{className:"text-xs leading-relaxed rounded border border-[#d4d2cd] bg-[#f5f4f1] p-3 space-y-2",children:s})}const Z="underline break-all text-[#0052cc]",he=e.jsxs($,{children:[e.jsxs("div",{children:["Create a Gemini API key at:",e.jsx("br",{}),e.jsx("a",{href:"https://aistudio.google.com/api-keys",target:"_blank",rel:"noopener noreferrer",className:Z,children:"https://aistudio.google.com/api-keys"})]}),e.jsx("div",{className:"opacity-80",children:"This key powers the Gemini models Tracer uses to run chats and analyze your data — it is the model provider, not a data source. Tracer sends your prompts and the data it has already fetched to Google's Gemini API for inference; it grants no access back into your Google account."})]});function fe(){const[s,t]=f.useState(!1),l=de();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(W,{type:"anthropic",label:"Anthropic"}),e.jsx(W,{type:"google",label:"Google AI",note:he}),e.jsx(xe,{})]}),e.jsxs("div",{className:"bg-white border border-[#d4d2cd] rounded overflow-hidden",children:[e.jsxs("button",{onClick:()=>t(!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(ge,{configuredProviders:l})]})]})}function ne({value:s,models:t,onChange:l,loading:i,disabled:o,label:x="Model"}){const p=ue(t),d=O(s),r=!t.some(u=>O(u)===d)&&!i;function g(u){const v=u.indexOf(":");l({provider:u.slice(0,v),modelId:u.slice(v+1)})}return e.jsxs("div",{className:"flex items-start gap-3 mt-3 pt-3 border-t border-[#d4d2cd]",children:[e.jsx("span",{className:"text-xs text-[#666666] whitespace-nowrap w-14 mt-2",children:x}),e.jsxs("div",{className:"flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"shrink-0 inline-flex items-center rounded px-1.5 py-0.5 text-[10px] font-medium bg-[#f0eee9] text-[#666666] border border-[#d4d2cd]",children:G(s.provider)}),e.jsxs("div",{className:"relative flex-1",children:[e.jsxs("select",{value:d,onChange:u=>g(u.target.value),disabled:o,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:[r&&e.jsx("optgroup",{label:"Unavailable",children:e.jsxs("option",{value:d,children:[G(s.provider)," · ",s.modelId]})}),p.map(u=>e.jsx("optgroup",{label:u.label,children:u.models.map(v=>e.jsx("option",{value:O(v),children:v.modelId},O(v)))},u.provider))]}),e.jsx("span",{className:"pointer-events-none absolute right-2 top-1/2 -translate-y-1/2 text-[#9c9890] text-[10px]",children:"▾"})]})]}),r&&e.jsxs("p",{className:a.warnText+" mt-1.5",children:[G(s.provider)," · ",s.modelId," isn’t available. Configure its provider or pick another model."]})]})]})}const je=ee[0];function ve({providerType:s}){const t=m.useUtils(),{data:l,isLoading:i}=m.settings.getSubAgentModel.useQuery(s),o=m.settings.saveSubAgentModel.useMutation({onSuccess:()=>t.settings.getSubAgentModel.invalidate(s)}),{models:x,isLoading:p}=se();if(i)return null;const d=l??je;return e.jsx(ne,{value:d,models:x,loading:p,disabled:o.isPending,onChange:h=>o.mutate({providerType:s,model:{provider:h.provider,modelId:h.modelId}})})}function be({existingConfig:s}){const t=m.useUtils(),l=X(),{data:i,isLoading:o}=m.provider.listGcpProjects.useQuery(void 0,{staleTime:V.updateCheckStaleTimeMs}),x=m.provider.saveConfig.useMutation({onSuccess:()=>{t.provider.getConfigs.invalidate(),t.provider.list.invalidate()}}),p=f.useMemo(()=>(i??[]).map(r=>({value:r.projectId,label:r.name?`${r.name} (${r.projectId})`:r.projectId,displayLabel:r.name||r.projectId})),[i]),d=s.projectId??"";if(l.data&&!l.data.ok)return null;function h(r){r!==d&&x.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(te,{options:p,value:d,onChange:h,placeholder:o?"Loading...":"Select project...",storageKey:"gcp-projectId",fitContent:!0,disabled:o||x.isPending})})]})}function ye({type:s,label:t,connected:l,configured:i,onConfigure:o,onToggle:x,togglePending:p,toggleError:d,pingError:h,hasConfigFields:r,existingConfig:g}){const u=i||l;return e.jsxs("div",{className:a.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(J,{checked:i,onChange:v=>{v&&r?o():x(v)},disabled:p}),e.jsx("span",{className:"font-medium",children:t}),u?e.jsx(H,{status:l?"connected":"disconnected"}):e.jsx("span",{className:"text-xs opacity-40",children:"Not configured"})]}),e.jsx("button",{onClick:o,className:`${a.secondaryBtn} ${i&&r?"":"invisible"}`,children:"Edit"})]}),u&&e.jsx(ve,{providerType:s}),u&&s==="gcp"&&g&&e.jsx(be,{existingConfig:g}),h&&!l&&e.jsx("p",{className:a.warnText+" mt-2",children:h}),d&&e.jsx("p",{className:a.errorText+" mt-2",children:d})]})}function Y(s,t){return!!s&&!!t&&s===t}function ae({open:s,label:t,configFields:l,formValues:i,onFormChange:o,existingConfig:x,saveResult:p,savePending:d,configured:h,note:r,onSave:g,onClose:u,onRemove:v}){const b=l.some(c=>c.required!==!1&&c.type==="password"&&Y(i[c.key],x?.[c.key])),C=l.some(c=>c.required!==!1&&!i[c.key]);return e.jsxs(me,{open:s,onClose:u,children:[e.jsxs("div",{className:a.dialogTitle+" text-base mb-4",children:["Configure ",t]}),r&&e.jsx("div",{className:"mb-4",children:r}),e.jsx("div",{className:"space-y-3",children:l.map(c=>{const N=c.type==="password"&&Y(i[c.key],x?.[c.key]);return e.jsxs("div",{children:[e.jsxs("label",{className:a.sectionTitle,children:[c.label,c.required===!1&&e.jsx("span",{className:"text-xs opacity-40 ml-1",children:"(optional)"})]}),e.jsx("input",{type:c.type==="password"&&i[c.key]&&!N?"password":"text",value:i[c.key]??"",onChange:S=>o(c.key,S.target.value),onFocus:S=>{N&&S.target.select()},placeholder:`Enter ${c.label.toLowerCase()}`,className:`${a.input} ${N?"!text-[#999] !border-l-2 !border-l-amber-400":""}`})]},c.key)})}),e.jsxs("div",{className:"flex items-center gap-2 mt-4 pt-4 border-t border-[#d4d2cd]",children:[e.jsx("button",{onClick:g,disabled:C||b||d,className:a.primaryBtn,children:d?e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsx(I,{size:"sm"})," Saving..."]}):"Save & Test"}),e.jsx("button",{onClick:u,disabled:d,className:a.secondaryBtn,children:"Cancel"}),h&&e.jsx("button",{onClick:v,disabled:d,className:a.dangerBtn,children:"Remove"})]}),b&&!d&&!p&&e.jsx("p",{className:"mt-2 text-xs text-amber-600",children:"Re-enter highlighted fields to save"}),p&&e.jsx("div",{className:`mt-3 ${p.success?a.successText:a.errorText}`,children:p.success?"Connected successfully":p.error||"Connection failed"})]})}const Ne={newrelic:e.jsxs($,{children:[e.jsxs("div",{children:["Create a ",e.jsx("span",{className:"font-medium",children:"User key"})," at:",e.jsx("br",{}),e.jsx("a",{href:"https://one.newrelic.com/admin-portal/api-keys/home",target:"_blank",rel:"noopener noreferrer",className:Z,children:"https://one.newrelic.com/admin-portal/api-keys/home"}),e.jsx("br",{}),"Your numeric Account ID is shown on the same page."]}),e.jsxs("div",{children:[e.jsx("div",{className:"font-medium",children:"What Tracer can do with it"}),e.jsx("ul",{className:"list-disc ml-4 mt-1 space-y-0.5",children:e.jsxs("li",{children:[e.jsx("span",{className:"font-medium",children:"Run read-only NRQL queries"})," against your account — to inspect metrics, logs, traces, and errors while investigating."]})})]}),e.jsx("div",{className:"opacity-80",children:"It only reads via NRQL. It cannot write, modify, deploy, or delete anything. A New Relic User key inherits your role, so for least privilege use a user scoped to read-only access."})]}),posthog:e.jsxs($,{children:[e.jsxs("div",{children:["Create a ",e.jsx("span",{className:"font-medium",children:"Personal API key"})," in your PostHog instance at:",e.jsx("br",{}),e.jsx("span",{className:"font-mono",children:"/settings/user-api-keys"}),e.jsx("br",{}),"Grant it the single scope ",e.jsx("span",{className:"font-medium",children:"Query → Read"}),". The Project ID is in Settings → Project. Set Host only if you are not on US cloud (e.g.",e.jsx("span",{className:"font-mono",children:" eu.posthog.com"})," or a self-hosted URL)."]}),e.jsxs("div",{children:[e.jsx("div",{className:"font-medium",children:"What Tracer can do with it"}),e.jsx("ul",{className:"list-disc ml-4 mt-1 space-y-0.5",children:e.jsxs("li",{children:[e.jsx("span",{className:"font-medium",children:"Run read-only HogQL queries"})," against the project — to inspect events, persons, and analytics while investigating."]})})]}),e.jsxs("div",{className:"opacity-80",children:["With only the ",e.jsx("span",{className:"font-medium",children:"Query → Read"})," scope it cannot create, modify, or delete anything in PostHog, and it reaches only the project you configure."]})]})};function Ce(s,t){const l={};for(const i of s)l[i.key]=t?.[i.key]??"";return l}function we(){const s=m.useUtils(),{data:t,isLoading:l}=m.provider.list.useQuery(),{data:i,isLoading:o}=m.provider.getConfigs.useQuery(),{data:x,isLoading:p}=m.provider.getRegisteredTypes.useQuery(),{data:d}=m.provider.ping.useQuery(void 0,{staleTime:V.sessionStaleTimeMs,refetchOnMount:"always"}),h=m.provider.saveConfig.useMutation({onSuccess:()=>{s.provider.list.invalidate(),s.provider.getConfigs.invalidate(),s.provider.ping.invalidate()}}),r=m.provider.removeConfig.useMutation({onSuccess:()=>{s.provider.list.invalidate(),s.provider.getConfigs.invalidate(),s.provider.ping.invalidate()}}),[g,u]=f.useState(null),[v,b]=f.useState({}),[C,c]=f.useState(null),[N,S]=f.useState(null),[k,j]=f.useState({});function y(n){const w=i?.find(M=>M.type===n),A=x?.find(M=>M.type===n);b(Ce(A?.configFields??[],w?.config)),c(null),u(n)}function P(){u(null),b({}),c(null)}async function U(n){c(null);try{const w=await h.mutateAsync({type:n,config:v});c(w),w.success&&(u(null),b({}))}catch{c({success:!1,error:"Failed to save configuration"})}}async function F(n,w){if(w){j(A=>{const M={...A};return delete M[n],M});try{const A=await h.mutateAsync({type:n,config:{}});A.success||j(M=>({...M,[n]:A.error??"Connection failed"}))}catch{j(A=>({...A,[n]:"Failed to save configuration"}))}}else S(n)}async function K(n){await r.mutateAsync(n),u(null),b({}),c(null),S(null)}const z=l||o||p,R=x??[];if(z)return e.jsx(I,{size:"lg",centered:!0});const T=g?R.find(n=>n.type===g):null,B=g?i?.find(n=>n.type===g):null;return e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"flex flex-wrap gap-3",children:R.map(({type:n,label:w,configFields:A})=>{const M=t?.find(L=>L.type===n),q=i?.find(L=>L.type===n),oe=!!q,D=d?.find(L=>L.type===n),le=D?D.ok:!!M?.connected,re=A.length>0,ce=D&&!D.ok?D.error:void 0;return e.jsx(ye,{type:n,label:w,connected:le,configured:oe,onConfigure:()=>y(n),onToggle:L=>F(n,L),togglePending:h.isPending||r.isPending,toggleError:k[n],pingError:ce,hasConfigFields:re,existingConfig:q?.config},n)})}),g&&T&&e.jsx(ae,{open:!0,label:T.label,configFields:T.configFields,formValues:v,onFormChange:(n,w)=>b(A=>({...A,[n]:w})),existingConfig:B?.config??null,saveResult:C,savePending:h.isPending,configured:!!B,note:Ne[g],onSave:()=>U(g),onClose:P,onRemove:()=>S(g)}),e.jsx(E,{open:N!==null,title:"Disable provider",message:`Disable ${R.find(n=>n.type===N)?.label??N}?`,confirmLabel:"Disable",onConfirm:()=>{N&&K(N)},onCancel:()=>S(null)})]})}const Se=[{key:"domain",label:"Domain (yourco → yourco.atlassian.net)",type:"text"},{key:"email",label:"Email",type:"text"},{key:"apiToken",label:"API Token",type:"password"}],ke=e.jsxs($,{children:[e.jsxs("div",{children:["Create a token (use the plain ",e.jsx("span",{className:"font-medium",children:"Create API token"}),', not "with scopes") at:',e.jsx("br",{}),e.jsx("a",{href:"https://id.atlassian.com/manage-profile/security/api-tokens",target:"_blank",rel:"noopener noreferrer",className:Z,children:"https://id.atlassian.com/manage-profile/security/api-tokens"})]}),e.jsxs("div",{children:[e.jsx("div",{className:"font-medium",children:"What Tracer can do with it"}),e.jsxs("ul",{className:"list-disc ml-4 mt-1 space-y-0.5",children:[e.jsxs("li",{children:[e.jsx("span",{className:"font-medium",children:"Read an issue"})," — summary, description, status, type, priority, assignee, reporter, labels, components, fix versions, resolution, dates, and its comment thread"]}),e.jsxs("li",{children:[e.jsx("span",{className:"font-medium",children:"Post a comment"})," — plain text, only when you ask"]})]})]}),e.jsx("div",{className:"opacity-80",children:"It cannot edit, transition, delete, bulk-read, or administer anything else. The token uses its account's permissions, so for least privilege point it at a Jira account limited to the projects Tracer should touch."})]});function Ae(){const s=m.useUtils(),{data:t,isLoading:l}=m.integrations.getJira.useQuery(),i=m.integrations.saveJira.useMutation({onSuccess:()=>s.integrations.getJira.invalidate()}),o=m.integrations.removeJira.useMutation({onSuccess:()=>s.integrations.getJira.invalidate()}),[x,p]=f.useState(!1),[d,h]=f.useState({}),[r,g]=f.useState(null),[u,v]=f.useState(!1),b=!!t?.configured,C=t?.config??null;function c(){h({domain:C?.domain??"",email:C?.email??"",apiToken:C?.apiToken??""}),g(null),p(!0)}function N(){p(!1),h({}),g(null)}async function S(){g(null);try{const j=await i.mutateAsync({domain:d.domain??"",email:d.email??"",apiToken:d.apiToken??""});g(j),j.success&&N()}catch{g({success:!1,error:"Failed to save configuration"})}}async function k(){await o.mutateAsync(),v(!1),N()}return l?e.jsx(I,{size:"lg",centered:!0}):e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"flex flex-wrap gap-3",children:e.jsx("div",{className:a.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(J,{checked:b,onChange:j=>{j?c():v(!0)},disabled:i.isPending||o.isPending}),e.jsx("span",{className:"font-medium",children:"Jira"}),b?e.jsx(H,{status:"connected"}):e.jsx("span",{className:"text-xs opacity-40",children:"Not configured"})]}),e.jsx("button",{onClick:c,className:`${a.secondaryBtn} ${b?"":"invisible"}`,children:"Edit"})]})})}),x&&e.jsx(ae,{open:!0,label:"Jira",configFields:Se,formValues:d,onFormChange:(j,y)=>h(P=>({...P,[j]:y})),existingConfig:C,saveResult:r,savePending:i.isPending,configured:b,note:ke,onSave:S,onClose:N,onRemove:()=>v(!0)}),e.jsx(E,{open:u,title:"Disable Jira",message:"Disable the Jira integration?",confirmLabel:"Disable",onConfirm:k,onCancel:()=>v(!1)})]})}function Me({memory:s,editingId:t,editNote:l,setEditNote:i,onUpdate:o,onCancelEdit:x,onStartEdit:p,onDelete:d,updatePending:h,removePending:r}){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:t===s.id?e.jsxs("div",{className:"space-y-2",children:[e.jsx("input",{type:"text",value:l,onChange:g=>i(g.target.value),className:a.input}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{onClick:()=>o(s.id),disabled:!l||h,className:a.primaryBtn,children:"Save"}),e.jsx("button",{onClick:x,disabled:h,className:a.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()})]})}),t!==s.id&&e.jsxs("div",{className:"flex items-center gap-1 shrink-0",children:[e.jsx("button",{onClick:()=>p(s.id,s.note),className:a.secondaryBtn,children:"Edit"}),e.jsx("button",{onClick:()=>d(s.id),disabled:r,className:a.dangerBtn,children:"Delete"})]})]})}function Pe(){const s=m.useUtils(),{data:t,isLoading:l}=m.memory.list.useQuery(),{data:i}=m.provider.getRegisteredTypes.useQuery(),o=m.memory.create.useMutation({onSuccess:()=>{s.memory.list.invalidate(),P(""),j("unified"),S(!1)}}),x=m.memory.update.useMutation({onSuccess:()=>s.memory.list.invalidate()}),p=m.memory.remove.useMutation({onSuccess:()=>s.memory.list.invalidate()}),[d,h]=f.useState(null),r=m.memory.optimize.useMutation({onSuccess:n=>{s.memory.list.invalidate(),h(n.stats)}}),[g,u]=f.useState(null),[v,b]=f.useState(""),[C,c]=f.useState(null),[N,S]=f.useState(!1),[k,j]=f.useState("unified"),[y,P]=f.useState("");function U(n,w){u(n),b(w)}async function F(n){await x.mutateAsync({id:n,note:v}),u(null),b("")}function K(){u(null),b("")}const z=[{value:"unified",label:"Unified"},...(i??[]).map(n=>({value:n.type,label:n.label}))],R=5;if(l)return e.jsx(I,{size:"lg",centered:!0});const T=new Map;if(t)for(const n of t){const w=T.get(n.toolName)??[];w.push(n),T.set(n.toolName,w)}const B={editingId:g,editNote:v,setEditNote:b,onUpdate:F,onCancelEdit:K,onStartEdit:U,onDelete:n=>c(n),updatePending:x.isPending,removePending:p.isPending};return e.jsxs("div",{className:"space-y-4",children:[N?e.jsxs("div",{className:a.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:n=>{j(n.target.value),n.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:z.map(n=>e.jsx("option",{value:n.value,children:n.label},n.value))})]}),e.jsxs("div",{children:[e.jsx("label",{className:a.sectionTitle,children:"Note"}),e.jsx("input",{type:"text",value:y,onChange:n=>P(n.target.value),onKeyDown:n=>{n.key==="Enter"&&y.trim()&&!o.isPending&&o.mutate({toolName:k,note:y})},placeholder:"Reusable lesson or pattern...",className:a.input})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{onClick:()=>o.mutate({toolName:k,note:y}),disabled:!y.trim()||o.isPending,className:a.primaryBtn,children:o.isPending?e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsx(I,{size:"sm"})," Saving..."]}):"Save"}),e.jsx("button",{onClick:()=>{S(!1),P(""),j("unified")},disabled:o.isPending,className:a.secondaryBtn,children:"Cancel"})]})]}):e.jsx("button",{onClick:()=>S(!0),className:a.secondaryBtn,children:"+ Add Memory"}),T.size===0&&e.jsx("div",{className:a.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."})}),[...T.entries()].map(([n,w])=>{const A=w.length>R;return e.jsxs("div",{className:a.settingsCard,children:[e.jsxs("div",{className:"mb-3 flex items-center gap-2",children:[e.jsx("span",{className:`${a.badge} ${a.badgeVariants.info}`,children:n}),A&&e.jsxs("span",{className:"text-xs text-[#666666]",children:[w.length," memories"]}),e.jsx("button",{onClick:()=>r.mutate({toolName:n}),disabled:r.isPending||w.length===0,className:`ml-auto ${a.outlineBtn}`,title:"Optimize memories with AI",children:r.isPending&&r.variables?.toolName===n?e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(I,{size:"sm"})," Optimizing..."]}):"Optimize"})]}),e.jsx("ul",{className:`space-y-2${A?" max-h-64 overflow-y-auto":""}`,children:w.map(M=>e.jsx(Me,{memory:M,...B},M.id))})]},n)}),e.jsx(E,{open:C!==null,title:"Delete memory",message:"Delete this agent memory?",onConfirm:()=>{C!==null&&p.mutate({id:C}),c(null)},onCancel:()=>c(null)}),e.jsx(E,{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:()=>h(null),onCancel:()=>h(null)})]})}function Ie(){const s=m.useUtils(),{data:t,isLoading:l}=m.settings.getChatModel.useQuery(),i=m.settings.saveChatModel.useMutation({onSuccess:()=>s.settings.getChatModel.invalidate()}),{models:o,isLoading:x}=se();return l||!t?null:e.jsx(ne,{value:t,models:o,loading:x,disabled:i.isPending,onChange:p=>i.mutate({provider:p.provider,modelId:p.modelId})})}const Q=["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 ie(s){try{const t=new Intl.DateTimeFormat("en-US",{timeZone:s,timeZoneName:"short"}).formatToParts(new Date).find(i=>i.type==="timeZoneName")?.value??"",l=new Intl.DateTimeFormat("en-US",{timeZone:s,timeZoneName:"shortOffset"}).formatToParts(new Date).find(i=>i.type==="timeZoneName")?.value??"";return`${t} (${l})`}catch{return s}}const Te=new Map(Q.map(s=>[s,ie(s)]));function Le(){const s=m.useUtils(),{data:t,isLoading:l}=m.settings.getAgentConfig.useQuery(),i=m.settings.saveAgentConfig.useMutation({onSuccess:()=>{s.settings.getAgentConfig.invalidate(),c(!1)}}),[o,x]=f.useState(""),[p,d]=f.useState(100),[h,r]=f.useState(50),[g,u]=f.useState(1024),[v,b]=f.useState(1e4),[C,c]=f.useState(!1);if(f.useEffect(()=>{t&&(x(t.timezone),d(t.directModeMaxSteps),r(t.subAgentMaxSteps),u(t.thinkingBudgetGoogle),b(t.thinkingBudgetAnthropic),c(!1))},[t]),l||!t)return null;const N=C&&(o!==t.timezone||p!==t.directModeMaxSteps||h!==t.subAgentMaxSteps||g!==t.thinkingBudgetGoogle||v!==t.thinkingBudgetAnthropic);function S(){i.mutate({timezone:o,directModeMaxSteps:p,subAgentMaxSteps:h,thinkingBudgetGoogle:g,thinkingBudgetAnthropic:v})}function k(){c(!0)}return e.jsxs("div",{className:"max-w-lg space-y-3",children:[e.jsxs("div",{className:a.settingsCard,children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-sm font-medium",children:"Unified mode model"}),e.jsx("span",{className:"text-xs opacity-40",children:"used when chat scope is “ALL”"})]}),e.jsx(Ie,{})]}),e.jsxs("div",{className:a.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:o,onChange:j=>{x(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:[Q.map(j=>e.jsx("option",{value:j,children:Te.get(j)??j},j)),!Q.includes(o)&&e.jsx("option",{value:o,children:ie(o)})]})]}),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:p,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:h,onChange:j=>{r(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:g,onChange:j=>{u(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=>{b(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:S,disabled:!N||i.isPending,className:a.primaryBtn,children:i.isPending?"Saving...":"Save"}),i.isSuccess&&!C&&e.jsx("span",{className:a.successText,children:"Saved"})]})]})]})}function De(){return e.jsxs("div",{className:a.page,children:[e.jsxs("div",{children:[e.jsx("h3",{className:a.sectionTitle,children:"LLM API Keys"}),e.jsx(fe,{})]}),e.jsxs("div",{children:[e.jsx("h3",{className:a.sectionTitle,children:"Data Providers"}),e.jsx(we,{})]}),e.jsxs("div",{children:[e.jsx("h3",{className:a.sectionTitle,children:"Integrations"}),e.jsx(Ae,{})]}),e.jsxs("div",{children:[e.jsx("h3",{className:a.sectionTitle,children:"Agent Configuration"}),e.jsx(Le,{})]}),e.jsxs("div",{children:[e.jsx("h3",{className:a.sectionTitle,children:"Agent Memory"}),e.jsx(Pe,{})]})]})}export{De as Settings};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{R as p,L as x,A as d}from"./mermaid-GHXKKRXX-
|
|
1
|
+
import{R as p,L as x,A as d}from"./mermaid-GHXKKRXX-C5BzUoQE.js";import{r,j as f}from"./index-L_n_IFmZ.js";import"./SearchableSelect-BfcFMllA.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};
|