claude-code-session-manager 0.122.1 → 0.123.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/assets/{AgentLibrary-C2qUX9WU.js → AgentLibrary-DxWN3FSN.js} +2 -2
- package/dist/assets/{Button-ssBzvFha.js → Button-CISLFSKb.js} +1 -1
- package/dist/assets/DataModel-CYPbhGrx.js +1 -0
- package/dist/assets/{History-BRdRp1J_.js → History-Fhouektw.js} +2 -2
- package/dist/assets/{Hooks--hiGPBQy.js → Hooks-COfIcyYV.js} +3 -3
- package/dist/assets/{Library-0XYvkhh2.js → Library-Bt5WOyyu.js} +7 -7
- package/dist/assets/ListDetail-DH7uzYd5.js +1 -0
- package/dist/assets/{McpServers-CCjHSwFm.js → McpServers-CwyVEzMN.js} +2 -2
- package/dist/assets/{Memory-C7RXoVO4.js → Memory-k9TWT9N4.js} +8 -8
- package/dist/assets/{Panel-C92O_aAH.js → Panel-Di8JqCYN.js} +1 -1
- package/dist/assets/{Permissions-DuTJ1FUb.js → Permissions-FFs6Rq1H.js} +3 -3
- package/dist/assets/{Plugins-DSXsP4hM.js → Plugins-uK5vl_RE.js} +2 -2
- package/dist/assets/{ProvenanceBadge-CWdDkU1m.js → ProvenanceBadge-CGDyGDoN.js} +1 -1
- package/dist/assets/{SaveBar-ob2dJJjH.js → SaveBar-Cnwc_XfF.js} +1 -1
- package/dist/assets/{Scheduler-Du4HgPKY.js → Scheduler-aACa6_mC.js} +7 -7
- package/dist/assets/{ScopeSwitcher-Dv_6M_Ci.js → ScopeSwitcher-CoG3CSlC.js} +1 -1
- package/dist/assets/Settings-BG0RM6Di.js +4 -0
- package/dist/assets/{SkillReferenceGraph-Dx1Qs8Y0.js → SkillReferenceGraph-COffGu_A.js} +1 -1
- package/dist/assets/Skills--qQpFjjf.js +2 -0
- package/dist/assets/SystemPrompt-Cr9RRSiZ.js +1 -0
- package/dist/assets/TagLibrary-D_ZbXwBv.js +1 -0
- package/dist/assets/{TiptapBody-Cihe5er3.js → TiptapBody-CCHsa8Jv.js} +1 -1
- package/dist/assets/{Toggle-CpYVC8bF.js → Toggle-BUOj4pws.js} +1 -1
- package/dist/assets/{ViewTabs-C3FN6P_C.js → ViewTabs-BdpsL7yr.js} +1 -1
- package/dist/assets/{historyTotals-C4Rs37Cd.js → historyTotals-Dx6ca881.js} +1 -1
- package/dist/assets/{index-Dd7UQabV.css → index-BnKaYERU.css} +1 -1
- package/dist/assets/{index-S-F5jp_h.js → index-CkNGj8FA.js} +151 -151
- package/dist/assets/{settingsSchema-BZcdzHTQ.js → settingsSchema-BZhkpr9e.js} +1 -1
- package/dist/assets/{skillFrontmatter-EfNERt4b.js → skillFrontmatter-N13KGqbs.js} +1 -1
- package/dist/assets/{useAgentsDirWatch-BfbrFvB3.js → useAgentsDirWatch-De9UsbDt.js} +1 -1
- package/dist/index.html +2 -2
- package/package.json +1 -1
- package/plugins/session-manager-dev/skills/develop/SKILL.md +29 -25
- package/scripts/scheduler-mcp-server.cjs +124 -74
- package/src/main/agentLibrary.cjs +8 -3
- package/src/main/build-info.json +4 -4
- package/src/main/crashDiagnostics.cjs +24 -0
- package/src/main/historyAggregator.cjs +41 -7
- package/src/main/index.cjs +13 -3
- package/src/main/ipcSchemas.cjs +30 -22
- package/src/main/lib/activeSessions.cjs +93 -32
- package/src/main/lib/epic/delegationReadiness.cjs +2 -0
- package/src/main/lib/epic/delegationSelfHeal.cjs +77 -0
- package/src/main/lib/epic/epicMint.cjs +1 -1
- package/src/main/lib/epic/epicStandingInstructions.cjs +73 -0
- package/src/main/lib/epic/guardSpawnSettings.cjs +76 -0
- package/src/main/lib/feedback-remote/crossProjectFeedback.cjs +9 -2
- package/src/main/lib/feedback-remote/remoteClientSessions.cjs +3 -11
- package/src/main/lib/feedback-remote/remoteE2eCrypto.cjs +1 -1
- package/src/main/lib/git/gitWorktree.cjs +9 -4
- package/src/main/lib/git/worktreeDeps.cjs +13 -2
- package/src/main/lib/git/worktreeSetup.cjs +212 -0
- package/src/main/lib/mcpToolCatalog.cjs +31 -2
- package/src/main/lib/persona-macro/agentPersonaSchema.cjs +4 -0
- package/src/main/lib/persona-macro/shippedPersonaSeeds.cjs +23 -0
- package/src/main/lib/prd/prdAgentType.cjs +28 -0
- package/src/main/lib/prd/prdBodyPatch.cjs +138 -0
- package/src/main/lib/prd/prdCreate.cjs +205 -32
- package/src/main/lib/prd/prdGateFiles.cjs +31 -0
- package/src/main/lib/scheduler/definitionOfDone.cjs +24 -3
- package/src/main/lib/scheduler/queueStore.cjs +5 -4
- package/src/main/lib/scheduler/scheduleJobSchema.cjs +1 -0
- package/src/main/lib/scheduler/schedulerBatch.cjs +43 -5
- package/src/main/lib/scheduler/schedulerPaths.cjs +2 -0
- package/src/main/lib/scheduler/watchdogHelpers.cjs +114 -22
- package/src/main/lib/telemetry/mainHeapSnapshot.cjs +69 -0
- package/src/main/lib/telemetry/telemetryBoot.cjs +25 -3
- package/src/main/lib/telemetry/telemetryClient.cjs +12 -0
- package/src/main/lib/telemetry/telemetryCounters.cjs +25 -2
- package/src/main/pty.cjs +0 -53
- package/src/main/runVerify.cjs +38 -11
- package/src/main/scheduler/prdParser.cjs +3 -0
- package/src/main/scheduler/prdPaths.cjs +48 -2
- package/src/main/scheduler.cjs +124 -29
- package/src/main/seedDevPlugin.cjs +1 -1
- package/src/main/seedSchedulerMcp.cjs +1 -1
- package/src/main/templates/PRD_AUTHORING.md +8 -4
- package/src/main/webRemote.cjs +38 -132
- package/src/preload/api.d.ts +4 -52
- package/src/preload/index.cjs +0 -24
- package/src/seed/agents/dev-lead.md +2 -1
- package/src/seed/agents/validator.md +2 -1
- package/dist/assets/DataModel-CENoTvc2.js +0 -1
- package/dist/assets/ListDetail-CkKXAM59.js +0 -1
- package/dist/assets/RemoteMachines-BFmbIGpW.js +0 -3
- package/dist/assets/Settings-DMoI0cqB.js +0 -4
- package/dist/assets/Skills-DYWQTQB1.js +0 -2
- package/dist/assets/SystemPrompt-Df0IfOuI.js +0 -1
- package/dist/assets/TagLibrary-BuMsGx-2.js +0 -1
- package/dist/assets/useRemotePeers-CKVakQPc.js +0 -1
- package/src/main/lib/feedback-remote/relayClientAuth.cjs +0 -133
- package/src/main/remoteClient.cjs +0 -334
- package/src/main/remoteClientIpc.cjs +0 -133
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import{aF as o,ap as e,S as I,A as ee,n as V,Y as $e,a5 as Le,aX as ve,bf as X,b6 as ye,a as F,bg as _e,aZ as Fe,ba as Ue,b7 as Be,b0 as Ge,c as le,aD as He,b4 as Je,be as oe,a_ as q,ar as Ke,aw as Ve,J as We,N as ce,aO as Xe}from"./index-S-F5jp_h.js";import{P as Ye}from"./Panel-C92O_aAH.js";import{S as qe}from"./ScopeSwitcher-Dv_6M_Ci.js";import{S as je}from"./SaveBar-ob2dJJjH.js";import{u as ze,s as de,E as Ze}from"./settingsSchema-BZcdzHTQ.js";import{V as Qe}from"./ViewTabs-C3FN6P_C.js";import{T as W}from"./Toggle-CpYVC8bF.js";import{u as et,b as J,P as O,E as ne,R as we,a as Ne,S as te}from"./useRemotePeers-CKVakQPc.js";import"./monaco-editor-BsIlgG7c.js";import"./claude-settings-schema-COigsajx.js";const tt=[{id:"essentials",title:"Essentials",summary:"The knobs you reach for first.",keys:["model","language","outputStyle","permissions"]},{id:"git",title:"Git & Commits",summary:"How Claude writes commits and pull requests on your behalf.",keys:["attribution","includeGitInstructions","includeCoAuthoredBy"]},{id:"memory",title:"Memory & Plans",summary:"Context Claude keeps between sessions and where it files plans.",keys:["autoMemoryEnabled","plansDirectory","claudeMdExcludes","respectGitignore"]},{id:"model",title:"Model & Reasoning",summary:"Model allow/override lists, reasoning depth, and fast-mode toggles — machine-wide, with no per-Epic override yet. An Epic's Agent persona model (Agent Library) still wins over Essentials' plain model default.",advanced:!0,keys:["availableModels","modelOverrides","effortLevel","fastMode","fastModePerSessionOptIn","alwaysThinkingEnabled","fallbackModel","enforceAvailableModels","teammateDefaultModel","advisorModel"]},{id:"interface",title:"Interface",summary:"Visual polish — spinners, progress bars, motion.",keys:["spinnerTipsEnabled","spinnerTipsOverride","spinnerVerbs","terminalProgressBarEnabled","showTurnDuration","prefersReducedMotion","companyAnnouncements","statusLine","teammateMode"]},{id:"updates",title:"Updates & Cleanup",summary:"Release channel and how long transcripts stick around.",keys:["autoUpdatesChannel","cleanupPeriodDays"]},{id:"env",title:"Environment & Auth",summary:"Environment variables and auth-helper scripts.",keys:["env","apiKeyHelper","awsCredentialExport","awsAuthRefresh"]},{id:"hooks",title:"Hooks",summary:"Scripts Claude runs before/after tool use.",keys:["hooks","disableAllHooks","allowedHttpHookUrls","httpHookAllowedEnvVars"]},{id:"mcp",title:"MCP Servers",summary:"External tool providers Claude can talk to.",keys:["enableAllProjectMcpServers","enabledMcpjsonServers","disabledMcpjsonServers"]},{id:"plugins",title:"Plugins",summary:"Installed plugins, marketplaces, and per-plugin configuration.",keys:["enabledPlugins","extraKnownMarketplaces","skippedPlugins","skippedMarketplaces","pluginConfigs"]},{id:"filesystem",title:"File Picker & Sandbox",summary:"How Claude browses files and the sandbox it runs in.",keys:["fileSuggestion","sandbox","worktree"]},{id:"login",title:"Login",summary:"Which login method to force on startup.",keys:["forceLoginMethod","forceLoginOrgUUID"]},{id:"feedback",title:"Feedback",summary:"Session-quality surveys.",keys:["feedbackSurveyRate"]},{id:"advanced",title:"Advanced / Enterprise",summary:"Managed-settings-only keys and enterprise allow/denylists.",advanced:!0,keys:["allowedMcpServers","deniedMcpServers","allowManagedHooksOnly","allowManagedPermissionRulesOnly","allowManagedMcpServersOnly","strictKnownMarketplaces","blockedMarketplaces","pluginTrustMessage","otelHeadersHelper","skipWebFetchPreflight"]}],st={mcp:"MCP",url:"URL",urls:"URLs",http:"HTTP",ui:"UI",id:"ID",uuid:"UUID",api:"API",aws:"AWS",otel:"OTel",json:"JSON"};function ke(t){return t.replace(/^\$/,"").replace(/([a-z])([A-Z])/g,"$1 $2").replace(/([A-Z]+)([A-Z][a-z])/g,"$1 $2").toLowerCase().split(/\s+/).filter(Boolean).map((i,r)=>{const a=st[i];return a||(r===0?i.charAt(0).toUpperCase()+i.slice(1):i)}).join(" ")}function Se(t){const s=new Set,n=[];for(const r of tt){const a=r.keys.filter(d=>t.has(d));a.forEach(d=>s.add(d)),a.length!==0&&n.push({id:r.id,title:r.title,summary:r.summary,advanced:!!r.advanced,keys:a})}const i=Array.from(t).filter(r=>!s.has(r)&&r!=="$schema").sort();return i.length>0&&n.push({id:"other",title:"Other",summary:"Keys not yet grouped.",advanced:!1,keys:i}),n}function nt(t,s){return Se(t).map(n=>({id:n.id,title:n.title,advanced:n.advanced,total:n.keys.length,setCount:n.keys.filter(i=>s.has(i)).length}))}const at={};function Ce(t,s){if(s)return{text:s,authored:!1};const n=at[t];return n?{text:n,authored:!0}:null}const rt={essentials:"star",git:"link",memory:"memory",model:"sparkle",interface:"eye",updates:"reload",env:"keys",hooks:"hooks",mcp:"mcp",plugins:"plugins",filesystem:"folder",login:"lock",feedback:"send",advanced:"shield",other:"dot"},it=["user","project","local","default"],lt={user:"user",project:"project",local:"local",default:"default"};function ot({node:t,targetScope:s,onOverride:n,schema:i}){const[r,a]=o.useState(""),[d,u]=o.useState(!1),[m,g]=o.useState(!0),f=t.kind==="object"?t:null,N=f?Object.keys(f.children):[],x=i.rootKeys(),b=new Set([...N,...x]),c=o.useMemo(()=>Se(b),[Array.from(b).sort().join(",")]),j=o.useMemo(()=>nt(b,new Set(N)),[Array.from(b).sort().join(","),N.join(",")]),[R,A]=o.useState(null),v=o.useRef(null),E=h=>{const w=c.find(l=>l.id===h);w!=null&&w.advanced&&!d&&u(!0),A(h)};o.useEffect(()=>{if(!R)return;A(null);const h=v.current,w=document.getElementById(`settings-group-${R}`);if(!h||!w)return;const l=w.getBoundingClientRect().top-h.getBoundingClientRect().top;h.scrollBy({top:l,behavior:"smooth"})},[R]);const C=o.useMemo(()=>c.filter(h=>d||!h.advanced).map(h=>({...h,keys:h.keys.filter(w=>{const l=(f==null?void 0:f.children[w])!==void 0;if(!m&&!l)return!1;if(!r.trim())return!0;const S=i.at([w]);return[w,ke(w),(S==null?void 0:S.description)??""].join(" ").toLowerCase().includes(r.toLowerCase())})})).filter(h=>h.keys.length>0),[c,r,d,m,f,i]);return e.jsxs("div",{className:"h-full flex flex-col",children:[e.jsxs("div",{className:"shrink-0 border-b border-line bg-bg-elev px-3 py-1.5 flex items-center gap-3 text-xs",children:[e.jsxs("span",{className:"text-fg-faint",children:["writing overrides to"," ",e.jsx("span",{className:"text-fg-dim font-medium",children:I[s].label})]}),e.jsxs("label",{className:"flex items-center gap-1 text-fg-faint cursor-pointer",children:[e.jsx("input",{type:"checkbox",checked:m,onChange:h=>g(h.target.checked),className:"accent-accent"}),"show not-yet-configured"]}),e.jsxs("label",{className:"flex items-center gap-1 text-fg-faint cursor-pointer",children:[e.jsx("input",{type:"checkbox",checked:d,onChange:h=>u(h.target.checked),className:"accent-accent"}),"show advanced"]}),e.jsx("div",{className:"flex-1"}),e.jsx("input",{value:r,onChange:h=>a(h.target.value),placeholder:"search settings…",className:"bg-bg border border-line rounded px-2 py-1 text-xs text-fg w-64"})]}),e.jsxs("div",{className:"flex-1 flex overflow-hidden",children:[e.jsx(ct,{groups:j,onJump:E}),e.jsxs("div",{ref:v,className:"flex-1 overflow-auto py-3",children:[C.map(h=>e.jsx(dt,{id:h.id,title:h.title,summary:h.summary,advanced:h.advanced,children:h.keys.map(w=>{const l=f==null?void 0:f.children[w],S=i.at([w]);return e.jsx(xt,{keyName:w,node:l,info:S,targetScope:s,onOverride:(y,M)=>n([w],y,M)},w)})},h.id)),C.length===0&&e.jsxs("div",{className:"px-6 py-12 text-center text-fg-faint text-sm",children:['no settings match "',r,'"']})]})]})]})}function ct({groups:t,onJump:s}){return e.jsx("nav",{className:"shrink-0 w-48 border-r border-line bg-bg-elev/30 overflow-y-auto py-3",children:t.map(n=>e.jsxs("button",{onClick:()=>s(n.id),className:"w-full flex items-center gap-2 px-3 py-2 text-left hover:bg-bg-hi transition-colors",title:`jump to ${n.title}`,children:[e.jsx(ee,{name:rt[n.id]??"dot",size:15,className:"text-fg-faint shrink-0"}),e.jsx("span",{className:"flex-1 min-w-0 truncate text-xs text-fg-dim",children:n.title}),e.jsxs("span",{className:"text-[10px] text-fg-faint font-mono shrink-0",children:[n.setCount,"/",n.total]})]},n.id))})}function dt({id:t,title:s,summary:n,advanced:i,children:r}){const[a,d]=o.useState(!0);return e.jsxs("section",{id:`settings-group-${t}`,className:"mx-4 mb-4 rounded-lg border border-line shadow-sm bg-bg-elev/50 overflow-hidden",children:[e.jsxs("header",{className:"px-4 py-3 bg-bg-elev cursor-pointer hover:bg-bg-hi flex items-center gap-3 border-b border-line",onClick:()=>d(!a),children:[e.jsx("span",{className:"text-fg-faint w-3",children:a?"▾":"▸"}),e.jsxs("div",{className:"flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("h2",{className:"text-fg text-base font-semibold",children:s}),i&&e.jsx("span",{className:"text-[9px] px-1.5 py-0 rounded border border-yellow-900/40 bg-yellow-950/30 text-yellow-500/80 uppercase tracking-wide",children:"advanced"})]}),e.jsx("p",{className:"text-fg-dim text-sm mt-0.5",children:n})]})]}),a&&e.jsx("div",{className:"divide-y divide-line/60",children:r})]})}function xt({keyName:t,node:s,info:n,targetScope:i,onOverride:r}){const[a,d]=o.useState(!1),[u,m]=o.useState(!1),g=ke(t),f=s!==void 0,x=(s==null?void 0:s.kind)==="leaf"?s:null,b=(s==null?void 0:s.kind)==="object"||(s==null?void 0:s.kind)==="array",c=n==null?void 0:n.default,j=x&&c!==void 0&&Ee(x.value,c),R=vt({isSet:f,leafNode:x,defaultVal:c,isDefault:!!j,node:s}),A=ut(x,c),v=A.length>=2,E=!!x&&!j,C=Ce(t,n==null?void 0:n.description);return e.jsx("div",{className:"px-4 py-3 hover:bg-bg-elev/20",children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("button",{onClick:()=>d(!a),className:"text-fg-faint hover:text-fg w-3 mt-0.5",title:a?"collapse":"expand",children:a?"▾":"▸"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-baseline gap-2 flex-wrap",children:[e.jsx("h3",{className:"text-fg text-sm",children:g}),e.jsx(yt,{kind:R.kind,label:R.label}),v&&e.jsxs("button",{onClick:h=>{h.stopPropagation(),a||d(!0),m(w=>!w)},className:"text-[9px] px-1.5 py-0 rounded border border-blue-900/40 bg-blue-950/30 text-blue-300/90 uppercase tracking-wide hover:bg-blue-900/40",title:"this key is defined in multiple scopes — click to expand",children:["drift · ",A.map(h=>lt[h]).join(" · ")]}),E&&x&&e.jsx("button",{onClick:h=>{h.stopPropagation(),r(void 0,x.winner)},className:"text-[9px] px-1.5 py-0 rounded border border-line bg-bg-elev text-fg-faint uppercase tracking-wide hover:text-fg hover:bg-bg-hi",title:`reset · delete from ${I[x.winner].label}`,children:"↺ reset"}),(n==null?void 0:n.deprecated)&&e.jsx("span",{className:"text-[9px] px-1 py-0 rounded border border-yellow-900/40 bg-yellow-950/30 text-yellow-500/80 uppercase tracking-wide",children:"deprecated"}),(n==null?void 0:n.required)&&!f&&e.jsx("span",{className:"text-[9px] px-1 py-0 rounded border border-red-900/40 bg-red-950/30 text-red-400/80 uppercase tracking-wide",children:"required"})]}),C&&e.jsx("p",{className:`text-fg-dim text-xs mt-0.5 leading-relaxed ${C.authored?"inline-block border-b border-dotted border-fg-faint/70 cursor-help":""}`,title:C.authored?"In-app-authored description — not from the official Claude Code schema":void 0,children:jt(C.text)}),a&&u&&x&&e.jsx(pt,{leaf:x,defaultVal:c,onReset:h=>r(void 0,h)}),a&&e.jsx(mt,{keyName:t,node:s,info:n,targetScope:i,onOverride:h=>r(h)})]}),e.jsx("div",{className:"shrink-0",children:!a&&e.jsx(bt,{node:s,info:n,onSet:h=>{r(h)},disabled:b&&f})})]})})}function ut(t,s){if(!t)return[];const n=new Set;n.add(t.winner);for(const i of t.shadowed)n.add(i.scope);return s!==void 0&&n.add("default"),it.filter(i=>n.has(i))}function pt({leaf:t,defaultVal:s,onReset:n}){const i={};i[t.winner]={value:t.value,winner:!0};for(const r of t.shadowed)i[r.scope]={value:r.value,winner:!1};return e.jsxs("div",{className:"mt-2 border border-line rounded bg-bg-elev/40 text-xs",children:[e.jsx("div",{className:"px-2 py-1 text-fg-faint border-b border-line/60",children:"Values across all scopes (winner highlighted · reset removes that scope's value):"}),e.jsxs("div",{className:"divide-y divide-line/60",children:[["user","project","local"].map(r=>{const a=i[r],d=a!==void 0;return e.jsxs("div",{className:"grid grid-cols-[5rem_1fr_auto] gap-2 px-2 py-1 items-center",children:[e.jsx("span",{className:"text-fg-faint",children:I[r].label}),e.jsx("span",{className:`font-mono truncate ${a!=null&&a.winner?"text-accent":"text-fg-dim"}`,children:d?U(a.value):e.jsx("span",{className:"text-fg-faint",children:"—"})}),d?e.jsx("button",{onClick:()=>n(r),className:"text-[9px] px-1.5 py-0 rounded border border-line text-fg-faint uppercase tracking-wide hover:text-fg hover:bg-bg-hi",title:`delete this key from ${I[r].label}`,children:"↺"}):e.jsx("span",{})]},r)}),e.jsxs("div",{className:"grid grid-cols-[5rem_1fr_auto] gap-2 px-2 py-1 items-center",children:[e.jsx("span",{className:"text-fg-faint",children:"Default"}),e.jsx("span",{className:"font-mono text-fg-dim truncate",children:s!==void 0?U(s):e.jsx("span",{className:"text-fg-faint",children:"—"})}),e.jsx("span",{})]})]})]})}function mt({keyName:t,node:s,info:n,targetScope:i,onOverride:r}){const d=(s==null?void 0:s.kind)==="leaf"?s:null,u=Ce(t,n==null?void 0:n.description);return e.jsxs("div",{className:"mt-3 space-y-2 text-xs",children:[u&&e.jsx("p",{className:`text-fg-dim leading-relaxed whitespace-pre-wrap ${u.authored?"inline-block border-b border-dotted border-fg-faint/70 cursor-help":""}`,title:u.authored?"In-app-authored description — not from the official Claude Code schema":void 0,children:u.text}),e.jsxs("dl",{className:"grid grid-cols-[auto_1fr] gap-x-3 gap-y-1 text-fg-faint",children:[(n==null?void 0:n.type)&&e.jsxs(e.Fragment,{children:[e.jsx("dt",{children:"Type"}),e.jsx("dd",{className:"text-fg-dim font-mono",children:Array.isArray(n.type)?n.type.join(" | "):n.type})]}),(n==null?void 0:n.default)!==void 0&&e.jsxs(e.Fragment,{children:[e.jsx("dt",{children:"Default"}),e.jsx("dd",{className:"text-fg-dim font-mono",children:U(n.default)})]}),(n==null?void 0:n.enum)&&e.jsxs(e.Fragment,{children:[e.jsx("dt",{children:"Options"}),e.jsx("dd",{className:"text-fg-dim font-mono",children:n.enum.map(m=>String(m)).join(" | ")})]}),d&&e.jsxs(e.Fragment,{children:[e.jsx("dt",{children:"Current"}),e.jsxs("dd",{className:"font-mono",children:[e.jsx("span",{className:"text-fg-dim",children:U(d.value)}),e.jsxs("span",{className:"ml-2 text-fg-faint",children:["from ",I[d.winner].label]})]})]}),d&&d.shadowed.length>0&&e.jsxs(e.Fragment,{children:[e.jsx("dt",{children:"Shadowed"}),e.jsx("dd",{className:"space-y-0.5",children:d.shadowed.map((m,g)=>e.jsxs("div",{className:"font-mono text-fg-faint line-through",children:[U(m.value)," —"," ",e.jsx("span",{className:"no-underline",children:I[m.scope].label})]},g))})]}),(s==null?void 0:s.kind)==="array"&&e.jsxs(e.Fragment,{children:[e.jsx("dt",{children:"Accumulated"}),e.jsxs("dd",{className:"text-fg-dim",children:[s.items.length," items across all scopes"]})]})]}),e.jsx("div",{className:"pt-2 flex items-center gap-2 flex-wrap border-t border-line/60",children:e.jsx(ft,{keyName:t,node:s,info:n,onChange:r,targetScope:i})})]})}function ft({node:t,info:s,onChange:n,targetScope:i}){const a=(t==null?void 0:t.kind)==="leaf"?t.value:s==null?void 0:s.default,d=Re(s==null?void 0:s.type);if(d==="boolean"){const u=a===!0;return e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-fg-faint",children:"Set to:"}),e.jsx("div",{className:"inline-flex rounded border border-line overflow-hidden",children:[{v:!0,label:"on"},{v:!1,label:"off"}].map(({v:m,label:g})=>e.jsx("button",{onClick:()=>n(m),className:`px-3 py-0.5 text-xs transition-colors ${u===m?"bg-accent text-bg":"bg-bg-elev text-fg-dim hover:bg-bg-hi hover:text-fg"}`,children:g},g))}),e.jsxs("span",{className:"text-fg-faint",children:["→ ",I[i].label]})]})}return s!=null&&s.enum?e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsx("span",{className:"text-fg-faint",children:"Choose:"}),s.enum.map(u=>{const m=Ee(a,u);return e.jsx("button",{onClick:()=>n(u),className:`px-2 py-0.5 text-xs rounded border ${m?"bg-accent text-bg border-accent":"bg-bg-elev text-fg-dim border-line hover:text-fg hover:bg-bg-hi"}`,children:String(u)},String(u))}),e.jsxs("span",{className:"text-fg-faint",children:["→ ",I[i].label]})]}):d==="integer"||d==="number"?e.jsx(ht,{value:typeof a=="number"?a:void 0,integer:d==="integer",onCommit:n,target:I[i].label}):d==="string"?e.jsx(gt,{value:typeof a=="string"?a:"",onCommit:n,target:I[i].label}):e.jsxs("div",{className:"text-fg-faint",children:["Complex value (",d??"object/array",") — use the"," ",e.jsx("span",{className:"text-fg-dim",children:"Raw"})," tab to edit."]})}function ht({value:t,integer:s,onCommit:n,target:i}){const[r,a]=o.useState(t!==void 0?String(t):""),d=()=>{const u=s?parseInt(r,10):parseFloat(r);Number.isNaN(u)||n(u)};return e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-fg-faint",children:"Set to:"}),e.jsx("input",{type:"number",value:r,onChange:u=>a(u.target.value),onBlur:d,onKeyDown:u=>{u.key==="Enter"&&u.target.blur()},className:"w-24 bg-bg border border-line rounded px-2 py-0.5 text-xs text-fg"}),e.jsxs("button",{onClick:d,className:"px-2 py-0.5 text-xs border border-accent/50 rounded text-accent hover:bg-accent hover:text-bg",children:["save → ",i]})]})}function gt({value:t,onCommit:s,target:n}){const[i,r]=o.useState(t);return e.jsxs("div",{className:"flex items-center gap-2 flex-1 min-w-0",children:[e.jsx("span",{className:"text-fg-faint shrink-0",children:"Set to:"}),e.jsx("input",{type:"text",value:i,onChange:a=>r(a.target.value),onKeyDown:a=>{a.key==="Enter"&&s(i)},className:"flex-1 min-w-0 bg-bg border border-line rounded px-2 py-0.5 text-xs text-fg"}),e.jsxs("button",{onClick:()=>s(i),className:"shrink-0 px-2 py-0.5 text-xs border border-accent/50 rounded text-accent hover:bg-accent hover:text-bg",children:["save → ",n]})]})}function bt({node:t,info:s,onSet:n,disabled:i}){const r=(t==null?void 0:t.kind)==="leaf",a=Re(s==null?void 0:s.type);if(i)return null;if(a==="boolean"){const d=r&&t.value===!0;return e.jsx("button",{onClick:()=>n(!d),className:`px-2.5 py-0.5 text-xs rounded border transition-colors ${d?"bg-accent/15 text-accent border-accent/40 hover:bg-accent hover:text-bg":"bg-bg-elev text-fg-dim border-line hover:text-fg hover:bg-bg-hi"}`,title:"toggle",children:d?"on":"off"})}return null}function vt({isSet:t,leafNode:s,defaultVal:n,isDefault:i,node:r}){return t?(r==null?void 0:r.kind)==="array"?{kind:"accumulated",label:`${r.items.length} items`}:(r==null?void 0:r.kind)==="object"?{kind:"set",label:"configured"}:s?i?{kind:"default",label:`= default · ${I[s.winner].label}`}:s.shadowed.length>0?{kind:"override",label:`overriding ${s.shadowed.length} scope(s)`}:{kind:"set",label:`set in ${I[s.winner].label}`}:{kind:"set",label:"configured"}:n!==void 0?{kind:"default",label:`using default: ${U(n)}`}:{kind:"unset",label:"not configured"}}function yt({kind:t,label:s}){const n={set:"bg-accent/15 text-accent border-accent/30",default:"bg-bg-hi text-fg-dim border-line",unset:"bg-bg-elev text-fg-faint border-line",override:"bg-purple-950/30 text-purple-400/80 border-purple-900/40",accumulated:"bg-blue-950/30 text-blue-400/80 border-blue-900/40"}[t];return e.jsx("span",{className:`text-[9px] px-1.5 py-0 rounded border uppercase tracking-wide ${n}`,children:s})}function Re(t){if(t)return Array.isArray(t)?t.find(n=>n!=="null")??t[0]:t}function Ee(t,s){return t===s?!0:typeof t!=typeof s?!1:t&&s&&typeof t=="object"?JSON.stringify(t)===JSON.stringify(s):!1}function jt(t){const s=t.trim().split(`
|
|
2
|
-
`)[0],n=s.match(/^([^.!?]+[.!?])/);return n?n[1]:s.length>120?s.slice(0,120)+"…":s}function U(t){if(typeof t=="string")return t===""?'""':JSON.stringify(t);if(t===null)return"null";if(t===void 0)return"—";if(typeof t=="object"){const s=JSON.stringify(t);return s.length>60?s.slice(0,60)+"…":s}return String(t)}const wt=1440*60*1e3;function xe(t){if(!t)return"never";const s=new Date(t).getTime();return Number.isNaN(s)?"never":new Date(s).toLocaleString()}function ue(t){return t?new Date(t).toLocaleString():"never"}function Nt(){return e.jsxs("div",{className:"p-4 max-w-3xl space-y-8 text-sm",children:[e.jsx(kt,{}),e.jsx("hr",{className:"border-line"}),e.jsx(St,{})]})}function kt(){const[t,s]=o.useState(null),[n,i]=o.useState(null),[r,a]=o.useState(null),[d,u]=o.useState(null),[m,g]=o.useState(!1),[f,N]=o.useState(null),[x,b]=o.useState(null);if(o.useEffect(()=>{let v=!1;return Promise.all([window.api.otel.getConfig(),window.api.otel.status(),window.api.otel.configPath()]).then(([E,C,h])=>{v||(s(E),a(E),i(C),u(h))}).catch(E=>{console.warn("[telemetry] load failed:",E==null?void 0:E.message)}),()=>{v=!0}},[]),!r||!t)return e.jsx(V,{title:"loading…"});const c=JSON.stringify(r)!==JSON.stringify(t),j=(v,E)=>{N(null),a({...r,[v]:E})},R=async()=>{g(!0),N(null);try{const v=await window.api.otel.setConfig(r);!v.ok&&v.error&&N(v.error),s(v.config),a(v.config),i(v.status),b(Date.now())}catch(v){N(v instanceof Error?v.message:String(v))}finally{g(!1)}},A=()=>{N(null),a(t)};return e.jsxs("div",{className:"space-y-5",children:[e.jsxs("header",{className:"space-y-1",children:[e.jsx("h2",{className:"text-fg text-base font-medium",children:"OpenTelemetry export"}),e.jsx("p",{className:"text-fg-dim text-xs leading-relaxed",children:"When enabled, every classified transcript event (tool_use, todo_write, plan, usage, agent_spawn) is mirrored as a 0-duration OTLP/HTTP span. Point this at a local collector (Jaeger, Grafana Tempo, SigNoz, Honeycomb) for cross-session analysis."}),d&&e.jsxs("p",{className:"text-fg-faint text-[11px]",children:["stored at ",e.jsx("span",{className:"font-mono",children:d})]})]}),e.jsxs("section",{className:"border border-line rounded p-3 space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-fg",children:"Export transcripts to OTEL"}),e.jsx("div",{className:"text-fg-faint text-xs",children:"Toggle off to disable all span emission immediately."})]}),e.jsx(W,{checked:r.enabled,onChange:v=>j("enabled",v),label:r.enabled?"on":"off"})]}),e.jsxs("label",{className:"block space-y-1",children:[e.jsx("span",{className:"text-fg-dim text-xs",children:"OTLP/HTTP traces endpoint"}),e.jsx("input",{type:"text",value:r.endpoint,onChange:v=>j("endpoint",v.target.value),placeholder:"http://localhost:4318/v1/traces",className:"w-full bg-bg border border-line rounded px-2 py-1 text-fg font-mono text-xs"})]}),e.jsxs("label",{className:"block space-y-1",children:[e.jsxs("span",{className:"text-fg-dim text-xs",children:["Headers (newline-separated ",e.jsx("span",{className:"font-mono",children:"Key: Value"}),")"]}),e.jsx("textarea",{value:r.headers,onChange:v=>j("headers",v.target.value),placeholder:"x-honeycomb-team: YOUR_API_KEY",rows:3,className:"w-full bg-bg border border-line rounded px-2 py-1 text-fg font-mono text-xs"})]}),e.jsxs("label",{className:"block space-y-1",children:[e.jsx("span",{className:"text-fg-dim text-xs",children:"Service name"}),e.jsx("input",{type:"text",value:r.serviceName,onChange:v=>j("serviceName",v.target.value),placeholder:"session-manager",className:"w-full bg-bg border border-line rounded px-2 py-1 text-fg font-mono text-xs"})]}),e.jsxs("div",{className:"flex items-start justify-between gap-3 pt-1",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-fg",children:"Include content (PII)"}),e.jsxs("div",{className:"text-fg-faint text-xs leading-relaxed",children:["Adds tool inputs, plan text, and agent prompts to span attributes. Off by default — matches upstream Claude Code's ",e.jsx("span",{className:"font-mono",children:"OTEL_LOG_USER_PROMPTS"})," opt-in."]})]}),e.jsx(W,{checked:r.includeContent,onChange:v=>j("includeContent",v),label:r.includeContent?"on":"off"})]})]}),n&&e.jsxs("section",{className:"border border-line rounded p-3 text-xs space-y-1",children:[e.jsx("div",{className:"text-fg-dim",children:"Runtime status"}),e.jsxs("div",{children:[e.jsx("span",{className:"text-fg-faint",children:"enabled:"})," ",e.jsx("span",{className:n.enabled?"text-accent":"text-fg-dim",children:String(n.enabled)})]}),n.error&&e.jsxs("div",{className:"text-red-400 break-words",children:[e.jsx("span",{className:"text-fg-faint",children:"error:"})," ",n.error]}),!n.error&&n.enabled&&e.jsx("div",{className:"text-fg-faint",children:"spans batched and exported in the background. Verify by enabling and pointing at a local Jaeger."})]}),e.jsxs("footer",{className:"flex items-center gap-3 pt-2 border-t border-line",children:[e.jsx("button",{onClick:R,disabled:!c||m,className:"px-3 py-1 text-xs rounded bg-accent text-bg disabled:opacity-50 disabled:cursor-not-allowed",children:m?"saving…":"Save"}),e.jsx("button",{onClick:A,disabled:!c||m,className:"px-3 py-1 text-xs rounded border border-line text-fg-dim hover:text-fg disabled:opacity-50 disabled:cursor-not-allowed",children:"Revert"}),f&&e.jsx("span",{className:"text-red-400 text-xs",children:f}),!f&&x&&!c&&e.jsx("span",{className:"text-fg-faint text-xs",children:"saved"})]})]})}function St(){const[t,s]=o.useState(null),[n,i]=o.useState(null),[r,a]=o.useState("Copy"),[d,u]=o.useState(!1),[m,g]=o.useState(null),[f,N]=o.useState(null),[x,b]=o.useState(null),[c,j]=o.useState(!1),R=()=>{window.api.telemetry.status().then(i).catch(l=>{console.warn("[product-telemetry] status reload failed:",l==null?void 0:l.message)})};if(o.useEffect(()=>{let l=!1;return Promise.all([window.api.telemetry.getConfig(),window.api.telemetry.status()]).then(([S,y])=>{l||(s(S),i(y))}).catch(S=>{console.warn("[product-telemetry] load failed:",S==null?void 0:S.message)}),()=>{l=!0}},[]),!t||!n)return e.jsx(V,{title:"loading…"});const A=async l=>{N(null);try{const S=await window.api.telemetry.setConfig(l);s(S.config),i(S.status)}catch(S){N(S instanceof Error?S.message:String(S))}},v=l=>{A({...t,enabled:l})},E=async()=>{await Le(t.installId)?(a("Copied"),setTimeout(()=>a("Copy"),1500)):ve.error("Could not copy install id to the clipboard")},C=async()=>{u(!0),g(null);try{const l=await window.api.telemetry.flushNow();g(`sent ${l.sent.length}, failed ${l.failed.length}`),R()}catch(l){g(l instanceof Error?l.message:String(l))}finally{u(!1)}},h=async()=>{if(c){j(!1);return}try{const l=await window.api.telemetry.recentRecords();b(l),j(!0)}catch(l){console.warn("[product-telemetry] recentRecords failed:",l instanceof Error?l.message:l)}},w=t.lastDailyFlushAt?new Date(t.lastDailyFlushAt).getTime()+wt:null;return e.jsxs("div",{className:"space-y-5","data-testid":"product-telemetry-section",children:[e.jsxs("header",{className:"space-y-1",children:[e.jsx("h2",{className:"text-fg text-base font-medium",children:"Product telemetry (bilko.run)"}),e.jsxs("p",{className:"text-fg-dim text-xs leading-relaxed",children:["Anonymous, strictly non-identifying usage/error reporting that helps improve this app. On by default; switchable off in one click. See"," ",e.jsx("span",{className:"font-mono",children:"session-manager-operations/architecture/telemetry.md"})," for the full data model."]})]}),e.jsx($e,{cfg:t,onSaved:(l,S)=>{s(l),i(S)}}),e.jsxs("section",{className:"border border-line rounded p-3 space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-fg",children:"Send anonymous product telemetry"}),e.jsx("div",{className:"text-fg-faint text-xs",children:"Sent on start-up, after an update, and once a day. Strictly anonymous — an install id only, never an email, name, or other identifier."})]}),e.jsx(W,{checked:t.enabled,onChange:v,label:t.enabled?"on":"off"})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("div",{className:"text-fg-dim text-xs",children:"Anonymous install id"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("input",{type:"text",readOnly:!0,value:t.installId,"aria-label":"Anonymous install identifier",className:"flex-1 bg-bg border border-line rounded px-2 py-1 text-fg font-mono text-xs"}),e.jsx("button",{onClick:E,className:"px-2 py-1 text-xs rounded border border-line text-fg-dim hover:text-fg",children:r})]})]}),e.jsxs("div",{className:"space-y-1 text-xs",children:[e.jsx("div",{className:"text-fg-faint",children:"Endpoint"}),e.jsx("div",{className:"font-mono text-fg-dim break-all",children:t.endpoint})]}),e.jsxs("div",{className:"space-y-1 text-xs",children:[e.jsx("div",{className:"text-fg-faint",children:"Send cadence"}),e.jsx("div",{className:"text-fg-dim",children:"on start-up, after an update, and once a day"})]}),f&&e.jsx("div",{className:"text-red-400 text-xs",children:f})]}),n.pendingCount>0&&n.sentCount===0&&e.jsxs("section",{"data-testid":"telemetry-never-delivered-warning",className:"border border-red-400 rounded p-3 text-xs space-y-1 text-red-400",children:[e.jsx("div",{className:"font-medium",children:"Never delivered"}),e.jsxs("div",{className:"leading-relaxed",children:[n.pendingCount," record",n.pendingCount===1?"":"s",' queued but none have ever been sent to bilko.run on this install. Check the endpoint/network, or click "Send now" below.']})]}),e.jsxs("section",{className:"border border-line rounded p-3 text-xs space-y-1.5",children:[e.jsx("div",{className:"text-fg-dim",children:"Runtime status"}),e.jsxs("div",{children:[e.jsx("span",{className:"text-fg-faint",children:"last send:"})," ",ue(n.lastFlushAt)]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-fg-faint",children:"next daily send due:"})," ",xe(w?new Date(w).toISOString():null)]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-fg-faint",children:"queued records:"})," ",n.pendingCount]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-fg-faint",children:"delivered so far:"})," ",n.sentCount]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-fg-faint",children:"de-duplicated:"})," ",n.dedupedAppends]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-fg-faint",children:"evicted:"})," ",n.evictedCount]}),n.backlog&&e.jsxs("div",{className:"text-fg-faint",children:["last backlog drain (",n.backlog.reason,", ",xe(n.backlog.ranAt),"):"," ",n.backlog.linesEnqueued," enqueued, ",n.backlog.linesConfirmed," confirmed,"," ",n.backlog.watermarksRewound," watermarks rewound"]}),n.lastError&&e.jsxs("div",{className:"text-red-400 break-words",children:[e.jsx("span",{className:"text-fg-faint",children:"last error:"})," ",n.lastError.message," ","(",ue(n.lastError.at),")"]})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("button",{onClick:C,disabled:d,className:"px-3 py-1 text-xs rounded bg-accent text-bg disabled:opacity-50 disabled:cursor-not-allowed",children:d?"sending…":"Send now"}),m&&e.jsx("span",{className:"text-fg-faint text-xs",children:m})]}),e.jsxs("section",{className:"space-y-2",children:[e.jsx("button",{onClick:h,className:"px-3 py-1 text-xs rounded border border-line text-fg-dim hover:text-fg",children:c?"Hide last records":"Inspect last records sent"}),c&&e.jsx("pre",{"data-testid":"telemetry-inspector-json",className:"bg-bg border border-line rounded p-2 text-[11px] font-mono overflow-auto max-h-96 whitespace-pre-wrap",children:JSON.stringify(x??[],null,2)})]})]})}const se="relay_client_auth_unavailable",K=t=>(t==null?void 0:t.message)||String(t),Ct=["relay_client_unpaired","token_revoked"],pe={invalid_code:"That code didn't match. Check it and try again.",code_expired:"That code expired. Mint a new one on bilko.run → Desktop clients.",invalid_code_format:"Codes are 8 letters or numbers. Check it and try again.",rate_limited:"Too many tries. Wait a minute and try again.",relay_client_unpaired:"This computer is no longer connected to your account. Enter a new code to reconnect."};function me(t){return Object.prototype.hasOwnProperty.call(pe,t)?pe[t]:`Pairing failed (${t})`}const fe=t=>{const s=/^v?(\d+)\.(\d+)\.(\d+)/.exec(t.trim());return s?[Number(s[1]),Number(s[2]),Number(s[3])]:null};function Rt(t,s){const n=fe(t),i=fe(s);if(!n||!i)return!1;for(let r=0;r<3;r++)if(n[r]!==i[r])return n[r]>i[r];return!1}function Et({peer:t,onConnect:s,onRevoke:n,onConfirmSas:i}){var x;const r=t.status==="authenticated",[a,d]=o.useState(null),u=((x=_e())==null?void 0:x.latest)??null;o.useEffect(()=>{if(!r){d(null);return}let b=!1;return window.api.remoteClient.send(t.peerId,"cmd:app:version").then(c=>{b||d(typeof c=="string"?c:null)}).catch(()=>{b||d(null)}),()=>{b=!0}},[t.peerId,r]);const m=a!=null&&u!=null&&Rt(u,a),g=t.status==="failed"&&t.reason===se,f=t.status==="connecting",N=new Date(t.pairedAt).toLocaleString();return e.jsxs("div",{className:"space-y-2","data-testid":"remote-machine-row",children:[e.jsx(we,{testId:"remote-machine",icon:"terminal",title:t.machineName,badge:r?e.jsx(F,{tone:"default",className:"!text-sage !border-sage/40",children:"online"}):void 0,subtitle:`${t.peerId} · last seen ${N}`,action:e.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[!r&&!g&&t.status!=="pending_sas"&&e.jsx(O,{testId:"remote-machine-connect",disabled:f,onClick:()=>s(t.peerId),children:f?"Connecting…":"Connect"}),e.jsx(Ne,{testId:"remote-machine-revoke",onClick:()=>n(t.peerId),children:"Revoke"})]})}),a&&e.jsxs("p",{"data-testid":"remote-machine-version",className:"text-[12.5px] leading-snug text-fg-faint",children:["v",a]}),m&&e.jsx("p",{"data-testid":"remote-machine-update-available",className:"text-[12.5px] leading-snug text-fg-faint",children:`Update available on ${t.machineName} (v${a} → v${u}) — update it on that machine`}),g&&e.jsx("p",{"data-testid":"remote-machine-unavailable",className:"text-[12.5px] leading-snug text-fg-faint",children:"The bilko.run relay does not support desktop clients yet"}),t.status==="pending_sas"&&t.sas&&e.jsx(te,{peer:"other machine",testId:"remote-machine-sas",codeTestId:"remote-machine-sas-code",confirmTestId:"remote-machine-sas-confirm",code:t.sas,onConfirm:()=>i(t.peerId)})]})}function At({paired:t,revoked:s,peers:n,onAuthChanged:i,onAdded:r}){const a=X(l=>l.show),[d,u]=o.useState(""),[m,g]=o.useState(!1),[f,N]=o.useState(!1),[x,b]=o.useState(null),[c,j]=o.useState({}),R=async()=>{g(!0);try{const l=await window.api.remoteClient.pair(d.trim());l.ok?(N(!1),u(""),i()):l.error===se?N(!0):a("error",me(l.error??"unknown"))}catch(l){a("error",K(l))}finally{g(!1)}},A=async()=>{g(!0);try{const l=await window.api.remoteClient.devices();l.ok?b(l.devices??[]):l.error===se?N(!0):a("error",me(l.error??"unknown"))}catch(l){a("error",K(l))}finally{g(!1)}},v=async l=>{try{await window.api.remoteClient.add(l,c[l]??`Machine ${l.slice(0,8)}`),r()}catch(S){a("error",K(S))}},E=async()=>{try{await window.api.remoteClient.unpair(),b(null),i()}catch(l){a("error",K(l))}},C=f&&e.jsx("p",{"data-testid":"remote-machine-unavailable",className:"text-[12.5px] leading-snug text-fg-faint",children:"The bilko.run relay does not support desktop clients yet"});if(!t)return e.jsxs("div",{className:"space-y-2 mb-3","data-testid":"remote-client-pairing",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("input",{"data-testid":"remote-client-code",value:d,maxLength:8,onChange:l=>u(l.target.value),placeholder:"8-character code",className:"px-2 py-1 text-[13px] rounded border border-line bg-transparent"}),e.jsx(O,{testId:"remote-client-pair",disabled:m||d.trim().length===0,onClick:()=>{R()},children:"Pair"})]}),e.jsx("p",{className:"text-[12.5px] leading-snug text-fg-faint",children:"Mint a desktop code on your phone: Session Manager remote → Desktop clients."}),s&&e.jsx("p",{"data-testid":"remote-client-revoked",className:"text-[12.5px] leading-snug text-fg-faint",children:"This computer was disconnected from your account on bilko.run. Enter a new code to reconnect."}),C]});const h=new Set(n.map(l=>l.deviceId)),w=(x??[]).filter(l=>!h.has(l.deviceId));return e.jsxs("div",{className:"space-y-2 mb-3","data-testid":"remote-client-pairing",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(O,{testId:"remote-client-find",disabled:m,onClick:()=>{A()},children:"Find my devices"}),e.jsx(O,{testId:"remote-client-unpair",kind:"ghost",onClick:()=>{E()},children:"Unpair"})]}),C,x&&w.length===0&&e.jsx(ne,{testId:"remote-client-devices-empty",children:"No other devices to add."}),w.map(l=>e.jsxs("div",{"data-testid":"remote-client-device",className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-[12.5px] text-fg-faint shrink-0",children:l.email}),e.jsx(F,{tone:"default",className:l.isOnline?"!text-sage !border-sage/40":void 0,children:l.isOnline?"online":"offline"}),e.jsx("input",{"data-testid":"remote-client-name",value:c[l.deviceId]??`Machine ${l.deviceId.slice(0,8)}`,onChange:S=>j(y=>({...y,[l.deviceId]:S.target.value})),className:"px-2 py-1 text-[13px] rounded border border-line bg-transparent min-w-0"}),e.jsx(O,{testId:"remote-client-add",onClick:()=>{v(l.deviceId)},children:"Add"})]},l.deviceId))]})}function It(){const t=X(c=>c.show),s=ye(c=>c.openPanel),[n,i]=o.useState(!1),[r,a]=o.useState(!1),d=o.useCallback(async()=>{try{const c=(await window.api.remoteClient.authStatus()).paired;i(c),c&&a(!1)}catch(c){t("error",K(c))}},[t]),u=o.useCallback(c=>{c.reason&&Ct.includes(c.reason)&&(c.reason==="token_revoked"&&a(!0),d())},[d]),{peers:m,refresh:g,connect:f,confirmSas:N,revoke:x}=et(u);o.useEffect(()=>{d()},[d]);const b=o.useCallback(c=>x(c),[x]);return e.jsxs("div",{"data-testid":"remote-machines",children:[e.jsx(J,{right:m.length>0?e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("span",{className:"text-[11.5px] text-fg-faint",children:[m.length," paired"]}),e.jsx(O,{testId:"remote-machines-open-view",onClick:()=>s("remote"),children:"Open Remote view"})]}):void 0,children:"Remote machines"}),e.jsx(At,{paired:n,revoked:r,peers:m,onAuthChanged:()=>{d()},onAdded:()=>{g()}}),m.length===0?e.jsx(ne,{testId:"remote-machines-empty",children:"No machines paired yet."}):e.jsx("div",{className:"space-y-2",children:m.map(c=>e.jsx(Et,{peer:c,onConnect:f,onRevoke:b,onConfirmSas:N},c.peerId))})]})}function he({label:t,hint:s,on:n,onChange:i,warn:r,disabled:a,first:d,testId:u}){return e.jsxs("div",{className:`flex items-center justify-between gap-4 px-[18px] py-[15px] ${d?"":"border-t border-rule"} ${a?"opacity-50":""}`,children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"text-sm font-semibold text-fg mb-0.5",children:t}),e.jsxs("div",{className:`text-[12.5px] leading-snug flex items-center gap-1.5 ${r?"text-honey-dark":"text-fg-faint"}`,children:[r&&e.jsx("span",{"aria-hidden":!0,children:"⚠"}),s]})]}),e.jsx("span",{"data-testid":u,className:"inline-flex",children:e.jsx(W,{checked:n,onChange:a?()=>{}:i,disabled:a})})]})}function Tt({device:t,online:s,onRevoke:n,revoking:i}){const r=t.lastConnectedAt?new Date(t.lastConnectedAt).toLocaleString():`paired ${new Date(t.issuedAt).toLocaleDateString()}`;return e.jsx(we,{testId:"settings-remote-device",icon:"wifi",title:t.deviceName,badge:s?e.jsx(F,{tone:"default",className:"!text-sage !border-sage/40",children:"online"}):void 0,subtitle:`${t.deviceId} · last seen ${r}`,action:e.jsx(Ne,{testId:"settings-remote-revoke",onClick:()=>n(t.deviceId),disabled:i})})}const $=t=>(t==null?void 0:t.message)||String(t);function Pt(){var ie;const t=X(p=>p.show),[s,n]=o.useState(null),[i,r]=o.useState(!0),[a,d]=o.useState(!1),[u,m]=o.useState(!1),[g,f]=o.useState("idle"),[N,x]=o.useState(""),[b,c]=o.useState(null),[j,R]=o.useState(!1),[A,v]=o.useState([]),[E,C]=o.useState(!1),h=o.useRef(null);o.useEffect(()=>{let p=!1;const k=()=>window.api.webRemote.getStatus().then(D=>{p||n(D)}).catch(()=>{});window.api.webRemote.getStatus().then(D=>{p||(n(D),r(!1))}).catch(D=>{p||(t("error",`Remote status: ${$(D)}`),r(!1))});const De=window.api.webRemote.onStatus(D=>n(D)),Oe=window.api.webRemote.onTokenRevoked(()=>{t("warn","Remote device token was revoked. Re-pair to reconnect."),k()}),Me=window.api.webRemote.onRevokedAll(({revokedCount:D})=>{t("info",`Panic: all ${D} device(s) revoked and sessions torn down.`),k()});return()=>{p=!0,De(),Oe(),Me()}},[t]),o.useEffect(()=>{if(g!=="enter-otp")return;const p=setTimeout(()=>{var k;return(k=h.current)==null?void 0:k.focus()},50);return()=>clearTimeout(p)},[g]);const w=async()=>n(await window.api.webRemote.getStatus()),l=async()=>{if(s){d(!0);try{const p=s.enabled?await window.api.webRemote.disable():await window.api.webRemote.enable();p&&p.ok===!1&&t("error",p.error||"Failed to change remote state."),await w()}catch(p){t("error",`Failed: ${$(p)}`)}finally{d(!1)}}},S=async()=>{if(s){m(!0);try{const p=s.remoteControlEnabled?await window.api.webRemote.disableControl():await window.api.webRemote.enableControl();p&&p.ok===!1&&t("error",p.error||"Failed to change command writes."),await w()}catch(p){t("error",`Failed: ${$(p)}`)}finally{m(!1)}}},y=async()=>{const p=N.trim().toUpperCase();if(!/^[A-Z0-9]{8}$/.test(p)){t("warn","Pairing code must be 8 alphanumeric characters.");return}f("pairing");try{const k=await window.api.webRemote.pair(p);if(!k.ok){t("error",k.error||"Pairing failed."),f("enter-otp");return}t("info","Device paired successfully."),x(""),f("idle"),await w()}catch(k){t("error",`Pairing error: ${$(k)}`),f("enter-otp")}},M=async p=>{c(p);try{const k=await window.api.webRemote.revokeDevice(p);if(!k.ok){t("error",k.error||"Revoke failed.");return}await w()}catch(k){t("error",`Revoke error: ${$(k)}`)}finally{c(null)}},P=async()=>{R(!0);try{const p=await window.api.webRemote.revokeAll();p.ok||t("error",p.error||"Panic revoke failed.")}catch(p){t("error",`Panic revoke error: ${$(p)}`)}finally{R(!1)}},ae=async()=>{if(E){C(!1);return}try{const p=await window.api.webRemote.auditTail(100);if(!p.ok){t("error",`Audit log: ${p.error||"unavailable"}`);return}v(p.lines??[]),C(!0)}catch(p){t("error",`Audit log: ${$(p)}`)}},_=async p=>{try{const k=await window.api.webRemote.confirmSas(p);k!=null&&k.ok||t("error",`SAS confirm failed: ${(k==null?void 0:k.error)??"unexpected state — reconnect the mobile app"}`)}catch(k){t("error",`SAS confirm failed: ${$(k)}`)}};if(i)return e.jsx("div",{className:"p-6 text-fg-faint text-sm",children:"Loading…"});const T=(s==null?void 0:s.enabled)??!1,L=(s==null?void 0:s.remoteControlEnabled)??!1,Y=(s==null?void 0:s.connected)??!1,B=(s==null?void 0:s.e2eActive)??!1,Ie=(s==null?void 0:s.e2eAuthenticated)??!1,Te=(s==null?void 0:s.e2eState)??"idle",re=(s==null?void 0:s.pendingSas)??null,Z=((s==null?void 0:s.clients)??[]).filter(p=>p.state==="pending_sas"&&p.pendingSas),G=(s==null?void 0:s.devices)??[],H=T&&Y,Pe=Y?((ie=G.reduce((p,k)=>k.lastConnectedAt&&(!p||(p.lastConnectedAt??"")<k.lastConnectedAt)?k:p,null))==null?void 0:ie.deviceId)??null:null;return e.jsxs("div",{"data-testid":"settings-remote",className:"p-4 max-w-[760px] space-y-[22px]",children:[Z.length>0?Z.map((p,k)=>e.jsxs("div",{"data-testid":"settings-remote-sas-row",children:[Z.length>1&&e.jsx("div",{className:"text-[12px] font-semibold text-fg-dim mb-1",children:p.clientId??"Phone"}),e.jsx(te,{testId:k===0?"settings-remote-sas":void 0,codeTestId:k===0?"settings-remote-sas-code":void 0,confirmTestId:k===0?"settings-remote-sas-confirm":void 0,code:p.pendingSas,onConfirm:()=>_(p.key)})]},p.key)):re&&e.jsx(te,{testId:"settings-remote-sas",codeTestId:"settings-remote-sas-code",confirmTestId:"settings-remote-sas-confirm",code:re,onConfirm:()=>_()}),Te==="failed"&&e.jsxs("div",{className:"flex items-center gap-3.5 px-5 py-4 rounded-2xl border border-[#eccdbe] bg-[#f8e8e0]",children:[e.jsx("span",{className:"w-4 h-4 rounded-full bg-accent text-white grid place-items-center text-[11px] font-bold shrink-0",children:"!"}),e.jsxs("div",{className:"text-[13px] text-[#9a3f1f]",children:[e.jsx("strong",{className:"font-semibold",children:"E2E key exchange failed."})," ",e.jsx("span",{className:"text-fg-dim",children:"The session key could not be established. Reconnect the mobile app to retry."})]})]}),e.jsxs("div",{className:`flex items-center gap-3.5 px-5 py-4 rounded-2xl border ${H?"border-[#e8cdb9] bg-[#f5e9df]":"border-line bg-bg-hi"}`,children:[e.jsx("span",{className:`w-[38px] h-[38px] rounded-[11px] shrink-0 grid place-items-center ${H?"bg-[#f0d9c8] text-accent":"bg-[#e4ebd6] text-sage"}`,children:e.jsx(ee,{name:H?"wifi":"shield",size:20})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"text-[14.5px] font-semibold text-fg mb-0.5",children:H?"Remote control is active":T?"Remote control is idle":"Remote control is off"}),e.jsx("div",{className:"text-[13px] text-fg-dim leading-snug",children:H?"A web session can send commands to this machine. Revoke below if unexpected.":T&&(s==null?void 0:s.linkState)==="repair-needed"?"The relay no longer recognises this device. Re-pair it with a new code to reconnect.":T?"The relay is on but no device is connected. Pair a device to begin.":"The relay connection is closed — no remote commands are accepted. Enable it below only when you need it."})]}),B&&Ie?e.jsx(F,{tone:"default",className:"!text-sage !border-sage/40",children:"E2E authenticated"}):B?e.jsx(F,{tone:"warn",children:"E2E · awaiting SAS"}):e.jsx(F,{tone:"dim",children:"relay only · not E2E yet"})]}),e.jsxs("div",{children:[e.jsx(J,{children:"Remote control"}),e.jsxs("div",{className:"bg-bg-hi border border-line rounded-2xl overflow-hidden",children:[e.jsx(he,{first:!0,testId:"settings-remote-enable",label:"Allow remote control from the web",hint:"Master switch. When off, the relay refuses every connection.",on:T,disabled:a,onChange:()=>{a||l()}}),e.jsx(he,{testId:"settings-remote-control",label:"Allow command writes (pty + scheduler)",hint:L?"A paired device can run shell commands and queue jobs on this machine.":"Paired devices can watch session output but cannot send commands.",warn:L,disabled:!T||u,on:L&&T,onChange:()=>{T&&!u&&S()}})]})]}),e.jsxs("div",{children:[e.jsx(J,{children:"Pair a device"}),g==="idle"?e.jsxs("div",{className:"flex items-center justify-between gap-4 bg-bg-hi border border-line rounded-2xl px-5 py-[18px]",children:[e.jsxs("div",{"data-testid":"settings-remote-pair-hint",className:"text-[13.5px] text-fg-dim leading-relaxed max-w-[420px]",children:["On your phone open ",e.jsx("strong",{className:"text-fg font-semibold",children:"bilko.run/projects/session-manager"}),", sign in, and tap"," ",e.jsx("strong",{className:"text-fg font-semibold",children:"Generate pairing code"}),". Enter the 8-character code here."]}),e.jsx(O,{testId:"settings-remote-pair-start",kind:"soft",icon:"link",onClick:()=>f("enter-otp"),children:"Pair Device…"})]}):e.jsxs("div",{className:"flex items-center gap-5 bg-bg-hi border border-accent/40 rounded-2xl px-6 py-[22px]",children:[e.jsx("span",{className:"w-[52px] h-[52px] rounded-xl bg-bg border border-line grid place-items-center text-accent shrink-0",children:e.jsx(ee,{name:"link",size:24})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"text-[11.5px] font-bold uppercase tracking-[0.8px] text-fg-faint mb-2",children:"Enter the code from your phone"}),e.jsx("input",{ref:h,"data-testid":"settings-remote-otp",value:N,onChange:p=>x(p.target.value.toUpperCase().replace(/[^A-Z0-9]/g,"")),onKeyDown:p=>{p.key==="Enter"&&y()},maxLength:8,placeholder:"XXXXXXXX",disabled:g==="pairing",className:"w-full bg-transparent border-0 outline-none font-mono text-[30px] font-semibold tracking-[6px] text-fg placeholder:text-fg-faint/40 disabled:opacity-50"})]}),e.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[e.jsx(O,{testId:"settings-remote-pair-confirm",kind:"soft",onClick:y,disabled:g==="pairing"||N.length<8,children:g==="pairing"?"Pairing…":"Confirm"}),e.jsx(O,{kind:"ghost",onClick:()=>{f("idle"),x("")},disabled:g==="pairing",children:"cancel"})]})]})]}),e.jsxs("div",{children:[e.jsx(J,{right:G.length>0?e.jsxs("span",{className:"text-[11.5px] text-fg-faint",children:[G.length," paired"]}):void 0,children:"Paired devices"}),G.length===0?e.jsx(ne,{children:"No devices paired yet."}):e.jsx("div",{className:"space-y-2",children:G.map(p=>e.jsx(Tt,{device:p,online:p.deviceId===Pe,onRevoke:M,revoking:b===p.deviceId},p.deviceId))})]}),e.jsx(It,{}),e.jsxs("div",{children:[e.jsx(J,{right:e.jsx("button",{"data-testid":"settings-remote-audit-toggle",onClick:ae,className:"text-[12px] text-fg-faint hover:text-fg-dim transition-colors",children:E?"Hide":"Show last 100 · 0600, stays on this machine"}),children:"Audit log"}),E&&e.jsx("div",{className:"bg-bg-hi border border-line rounded-xl overflow-auto max-h-64 mb-2",children:A.length===0?e.jsx("p",{className:"p-4 text-[12.5px] text-fg-faint",children:"No entries today."}):e.jsx("pre",{"data-testid":"settings-remote-audit",className:"p-4 text-[12px] text-fg-dim font-mono whitespace-pre-wrap leading-relaxed",children:A.join(`
|
|
3
|
-
`)})}),e.jsxs("p",{className:"text-[12px] text-fg-faint",children:["Full log at"," ",e.jsx("code",{className:"font-mono text-fg-faint",children:"~/.claude/session-manager/logs/remote-audit-YYYY-MM-DD.log"})," ","(0600, never leaves this machine)"]})]}),e.jsxs("div",{className:"flex items-center justify-between gap-4 bg-[#f8e8e0] border border-[#eccdbe] rounded-2xl px-5 py-4",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx("span",{className:"w-4 h-4 rounded-full bg-accent text-white grid place-items-center text-[11px] font-bold shrink-0",children:"!"}),e.jsx("span",{className:"text-sm font-semibold text-[#9a3f1f]",children:"Panic — disconnect & revoke everything"})]}),e.jsx("div",{className:"text-[12.5px] text-fg-dim leading-snug max-w-[440px]",children:"Tears down every active session and invalidates all paired-device tokens. Devices must re-pair. Use if you suspect compromise."})]}),e.jsx("button",{"data-testid":"settings-remote-revoke-all",onClick:P,disabled:j,className:"shrink-0 rounded-lg bg-accent text-white px-[18px] py-2 text-[13px] font-semibold hover:opacity-90 disabled:opacity-50 transition-opacity",children:j?"Revoking…":"Revoke all"})]})]})}const z="px-2 py-1 rounded border border-line text-xs text-fg hover:bg-bg-hi disabled:opacity-50";function Dt(){const t=Fe(),s=X(u=>u.show),n=async u=>{try{const g=await u();g&&g.ok===!1&&s("error",g.error??"Update action failed")}catch(m){s("error",m instanceof Error?m.message:String(m))}};if(!t)return null;const{state:i}=t,r=i==="unsupported",a=t.latest?`v${t.latest}`:"—",d=()=>{window.confirm("Installing now will stop all running jobs and terminals. Continue?")&&n(()=>window.api.updater.install(!0))};return e.jsxs("section",{"data-testid":"settings-updates",className:"border border-line rounded p-3 space-y-3",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx("span",{className:"text-fg text-xs font-medium",children:"Updates"}),e.jsxs("div",{className:"text-fg-dim text-xs flex gap-4",children:[e.jsxs("span",{children:["Current v",t.current]}),e.jsxs("span",{children:["Latest ",a]})]})]}),r?e.jsx("p",{className:"text-fg-faint text-[11px]",children:"Auto-update runs only in the installed Windows app or the Linux AppImage. npx builds update via npx."}):e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(W,{checked:t.enabled,onChange:u=>void n(()=>window.api.updater.setEnabled(u)),label:"Update automatically"}),e.jsx("button",{type:"button","data-testid":"updates-check",className:z,disabled:i==="checking"||i==="downloading",onClick:()=>void n(()=>window.api.updater.check()),children:"Check for updates"})]}),i==="checking"&&e.jsx("p",{className:"text-fg-dim text-xs",children:"Checking…"}),i==="downloading"&&e.jsxs("p",{className:"text-fg-dim text-xs",children:["Downloading… ",t.progress!=null?`${Math.round(t.progress)}%`:""]}),i==="ready"&&e.jsxs("button",{type:"button","data-testid":"updates-install",className:z,onClick:()=>void n(()=>window.api.updater.install(!1)),children:["Restart to install v",t.latest]}),i==="deferred"&&e.jsxs("div",{className:"space-y-2",children:[e.jsxs("p",{className:"text-fg-dim text-xs",children:["Waiting for ",t.busyReason??"work"," to finish"]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("button",{type:"button",className:z,onClick:d,children:"Install now"}),e.jsx("button",{type:"button",className:z,onClick:()=>void n(()=>window.api.updater.cancelDeferred()),children:"Cancel"})]})]}),i==="error"&&e.jsx("p",{className:"text-red-400 text-xs",children:t.error})]})}const Ot=[{key:"maxAgeDays",label:"Run logs: keep for",unit:"days",min:3,max:3650},{key:"runsArchiveDays",label:"Runs archive: keep for",unit:"days",min:1,max:3650},{key:"auditLogMonths",label:"Audit log: keep for",unit:"months",min:1,max:120},{key:"reservedMarkersKeep",label:"Reserved markers: keep",unit:"markers",min:1,max:1e5}],Mt="w-24 px-2 py-1 rounded border border-line bg-transparent text-xs text-fg";function ge(t,s){return s==="maxAgeDays"?t.runLogs.maxAgeDays:t[s]}function $t(t,s){return t==="maxAgeDays"?{runLogs:{maxAgeDays:s}}:{[t]:s}}function Ae(t){if(!Number.isFinite(t)||t<=0)return"0 B";const s=["B","KB","MB","GB","TB"];let n=0,i=t;for(;i>=1024&&n<s.length-1;)i/=1024,n++;return`${n===0?i:i.toFixed(1)} ${s[n]}`}function Q(t,s,n){return`${t}: ${Ae(s)} in ${n.toLocaleString("en-US")} files`}function Lt(){const t=X(x=>x.show),[s,n]=o.useState(null),[i,r]=o.useState({}),[a,d]=o.useState(null),u=o.useCallback(x=>t("error",x instanceof Error?x.message:String(x)),[t]),m=o.useCallback(async()=>{try{d(await window.api.opsRetention.preview())}catch(x){u(x)}},[u]);o.useEffect(()=>{let x=!0;return window.api.opsRetention.get().then(b=>{x&&n(b)}).catch(b=>{x&&u(b)}),m(),()=>{x=!1}},[u,m]);const g=async x=>{if(!s)return;const b=i[x.key];if(b===void 0)return;const c=Number(b);if(r(R=>{const{[x.key]:A,...v}=R;return v}),b.trim()===""||!Number.isFinite(c))return;const j=Math.min(x.max,Math.max(x.min,Math.round(c)));if(j!==ge(s,x.key))try{n(await window.api.opsRetention.set($t(x.key,j))),await m()}catch(R){u(R)}},f=a?a.runLogs.bytes+a.runsArchive.bytes+a.tmp.bytes:0,N=a?a.runLogs.files+a.runsArchive.entries+a.tmp.files:0;return e.jsxs("section",{"data-testid":"settings-ops-retention",className:"border border-line rounded p-3 space-y-3",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx("span",{className:"text-fg text-xs font-medium",children:"Ops data retention"}),e.jsx("p",{className:"text-fg-faint text-[11px]",children:"How long the daily sweep keeps scheduler and audit data. Machine-wide."})]}),s&&e.jsxs("div",{className:"space-y-2",children:[Ot.map(x=>e.jsxs("label",{className:"flex items-center gap-2 text-xs text-fg-dim",children:[e.jsx("span",{className:"w-48",children:x.label}),e.jsx("input",{type:"number","data-testid":`ops-retention-${x.key}`,className:Mt,min:x.min,max:x.max,value:i[x.key]??String(ge(s,x.key)),onChange:b=>r(c=>({...c,[x.key]:b.target.value})),onBlur:()=>void g(x)}),e.jsx("span",{className:"text-fg-faint",children:x.unit})]},x.key)),e.jsx("p",{className:"text-fg-dim text-xs",children:"Archived transcripts: kept forever"})]}),a&&e.jsxs("div",{"data-testid":"ops-retention-preview",className:"space-y-1 text-xs text-fg-dim",children:[e.jsxs("div",{className:"text-fg",children:["Current policy would free ",Ae(f)," in ",N.toLocaleString("en-US")," files"]}),e.jsx("div",{children:Q("Run logs",a.runLogs.bytes,a.runLogs.files)}),e.jsx("div",{children:Q("Runs archive",a.runsArchive.bytes,a.runsArchive.entries)}),e.jsx("div",{children:Q("Stale temp files",a.tmp.bytes,a.tmp.files)}),e.jsx("p",{className:"text-fg-faint text-[11px]",children:"Nothing is deleted until the daily sweep runs."})]})]})}const _t={compact:"Compact",roomy:"Roomy"};function Ft(){const{model:t,setModel:s}=Ue(),{catalog:n}=Be(null),{density:i,setDensity:r}=Ge();return e.jsxs("div",{className:"p-4 max-w-3xl space-y-5 text-sm",children:[e.jsxs("header",{className:"space-y-1",children:[e.jsx("h2",{className:"text-fg text-base font-medium",children:"Session Manager preferences"}),e.jsx("p",{className:"text-fg-dim text-xs leading-relaxed",children:"Native app preferences, stored locally — not part of Claude Code's own settings."})]}),e.jsxs("section",{className:"border border-line rounded p-3 space-y-3",children:[e.jsxs("div",{className:"block space-y-1",children:[e.jsx("span",{className:"text-fg-dim text-xs",children:"Default model for raw sessions"}),e.jsx(le,{options:He(n),value:t,onChange:s,mono:!0}),e.jsx("span",{className:"text-fg-faint text-[11px]",children:"Used when opening a raw interactive session without an explicit per-launch override."})]}),e.jsxs("div",{className:"block space-y-1",children:[e.jsx("span",{className:"text-fg-dim text-xs",children:"Density"}),e.jsx(le,{options:["compact","roomy"],value:i,onChange:a=>r(a),labels:_t}),e.jsx("span",{className:"text-fg-faint text-[11px]",children:"Compact tightens spacing across the app's chrome; Roomy is the default."})]})]}),e.jsx(Dt,{}),e.jsx(Lt,{})]})}function Ut({cwd:t}){const[s,n]=o.useState(!1),[i,r]=o.useState(!1),[a,d]=o.useState(!1),[u,m]=o.useState(!1);o.useEffect(()=>{var b,c;let x=!1;return n(!1),Promise.resolve((c=(b=window.api.promptSessions)==null?void 0:b.getWorktreeDisabled)==null?void 0:c.call(b,{cwd:t})).then(j=>{x||(r((j==null?void 0:j.disabled)??!1),d((j==null?void 0:j.disabled)??!1),n(!0))},()=>{x||n(!0)}),()=>{x=!0}},[t]);const g=s&&a!==i,f=()=>{var x,b;m(!0),Promise.resolve((b=(x=window.api.promptSessions)==null?void 0:x.setWorktreeDisabled)==null?void 0:b.call(x,{cwd:t,disabled:a})).then(c=>{r((c==null?void 0:c.disabled)??a),d((c==null?void 0:c.disabled)??a)}).catch(c=>ve.error(c instanceof Error?c.message:String(c))).finally(()=>m(!1))},N=()=>d(i);return e.jsxs("div",{"data-testid":"settings-epic-isolation",className:"border-b border-line bg-bg-elev px-3 py-2.5 text-[11.5px] leading-snug",children:[e.jsxs("label",{className:"flex items-start gap-2",children:[e.jsx("input",{type:"checkbox",checked:a,disabled:!s||u,onChange:x=>d(x.target.checked),"data-testid":"settings-epic-isolation-checkbox",className:"mt-0.5"}),e.jsxs("span",{children:[e.jsx("span",{className:"font-semibold text-fg",children:"Disable Epic worktree isolation for this project"}),e.jsxs("span",{className:"block text-fg-dim",children:["Off by default — each active Epic runs in its own isolated ",e.jsx("code",{children:"git worktree"})," (branch"," ",e.jsx("code",{children:"sm-epic/<id>"}),"), merged back to main at an explicit checkpoint. Turning this on makes every new Epic in this project run directly in the shared working tree instead, same as before this feature existed."]})]})]}),g&&e.jsx(je,{dirty:g,busy:u,onSave:f,onRevert:N})]})}const be={user:{title:"Global settings",body:"This is the real ~/.claude/settings.json on disk — the same file the claude CLI reads on every session it starts. Edits apply machine-wide, to every project and every session."},project:{title:"Project settings",body:"This is the real <project>/.claude/settings.json on disk, checked into git. Edits apply to every current and future session in this project, for anyone who clones it."},local:{title:"Local settings",body:"This is the real <project>/.claude/settings.local.json on disk, gitignored. Edits apply to every current and future session in this project, on this machine only."}};function Bt(){const t=Je(),s=oe(y=>y.tabs),n=oe(y=>y.activeTabId),i=s.find(y=>y.id===n)??null,r=(i==null?void 0:i.cwd)??null,a=ye(y=>y.navFace),d=o.useRef(!1),u=o.useRef(a),[m,g]=o.useState(()=>a==="project"&&r?"project":"user"),[f,N]=o.useState("effective");o.useEffect(()=>{if(u.current!==a){if(u.current=a,d.current){d.current=!1;return}g(a==="project"&&r?"project":"user")}},[a,r]),o.useEffect(()=>{a==="project"&&(f==="telemetry"||f==="remote"||f==="app")&&N("effective")},[a,f]);const x=y=>{d.current=!0,g(y)},b=ze(ce,t,r),c=b[m]??null,j=q(y=>y.files),R=q(y=>y.setDraft),A=q(y=>y.saveJson),v=q(y=>y.revert),[E,C]=o.useState(null),h=o.useMemo(()=>Ke(Ve(j,b)),[j,b]),w=(y,M,P)=>{var B;const _=b[P??m];if(!_)return;C(null);const T=((B=j[_])==null?void 0:B.draftRaw)??"";let L={};if(T.trim())try{L=JSON.parse(T)}catch{L={}}const Y=Xe(L,y,M);R(_,JSON.stringify(Y,null,2)+`
|
|
4
|
-
`)};if(!t)return e.jsx(V,{title:"loading…"});const l=c?j[c]:null,S=y=>y!=="user"&&!r;return e.jsx(Ye,{toolbar:e.jsxs(e.Fragment,{children:[e.jsx(Qe,{options:[{key:"effective",label:"Guided"},{key:"tree",label:"Tree"},{key:"raw",label:"Raw"},...a==="home"?[{key:"telemetry",label:"Telemetry"},{key:"remote",label:"Phone remote"},{key:"app",label:"Session Manager"}]:[]],active:f,onChange:N}),f!=="telemetry"&&f!=="remote"&&f!=="app"&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"mx-2 text-fg-faint",children:"·"}),e.jsx(qe,{scopes:ce.scopes,active:m,onChange:x,annotate:y=>{if(S(y))return{exists:!1};const M=b[y];if(!M)return null;const P=j[M];return{exists:(P==null?void 0:P.exists)??!1,dirty:(P==null?void 0:P.dirty)??!1}}}),e.jsx("span",{className:"ml-3 text-fg-faint truncate",children:f==="effective"?`overrides → ${c??"—"}`:c??"—"})]}),e.jsx("div",{className:"flex-1"}),e.jsx("a",{href:"https://code.claude.com/docs/en/settings",target:"_blank",rel:"noreferrer",className:"text-fg-faint hover:text-fg-dim underline-offset-2 hover:underline",children:"schema reference ↗"})]}),footer:f!=="telemetry"&&f!=="remote"&&f!=="app"&&c&&l?e.jsx(je,{dirty:l.dirty,busy:l.busy,parseError:E||l.parseError,lastSavedAt:l.lastSavedAt,leading:l.exists?null:e.jsx("span",{children:"file will be created on save"}),onSave:async()=>{C(null);const y=await A(c);y.ok||C(y.error??"save failed")},onRevert:()=>{C(null),v(c)}}):null,children:f==="telemetry"?e.jsx(Nt,{}):f==="remote"?e.jsx(Pt,{}):f==="app"?e.jsx(Ft,{}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{"data-testid":"settings-scope-note",className:"sticky top-0 z-10 border-b border-line bg-bg-elev px-3 py-2 text-[11.5px] leading-snug",children:[e.jsx("span",{className:"font-semibold text-fg",children:be[m].title}),e.jsx("span",{className:"mx-1.5 text-fg-faint",children:"·"}),e.jsx("span",{className:"text-fg-dim",children:be[m].body}),c&&e.jsx("span",{className:"ml-1.5 font-mono text-fg-faint",children:c})]}),m==="project"&&r&&e.jsx(Ut,{cwd:r}),S(m)?e.jsx(V,{title:"no active project",hint:"open a tab in a project directory to edit project or local settings"}):f==="effective"?e.jsx(ot,{node:h,targetScope:m,onOverride:w,schema:de()}):f==="tree"?e.jsx(Ze,{node:h,targetScope:m,onOverride:w,schema:de()}):c&&l?e.jsx(We,{path:c,value:l.draftRaw,onChange:y=>{C(null),R(c,y)}}):e.jsx(V,{title:"resolving…"})]})})}const Zt=o.memo(Bt);export{be as SETTINGS_SCOPE_NOTES,Zt as Settings};
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{aF as a,b4 as ce,aY as de,b6 as ue,aX as E,a_ as d,a$ as fe,ap as s,n as T}from"./index-S-F5jp_h.js";import{P as I}from"./Panel-C92O_aAH.js";import{L as me}from"./ListDetail-CkKXAM59.js";import{p as pe,r as he,M as xe,s as ve}from"./skillFrontmatter-EfNERt4b.js";import{S as ge}from"./SaveBar-ob2dJJjH.js";import{S as K}from"./ScopeSwitcher-Dv_6M_Ci.js";import{T as ke}from"./Toggle-CpYVC8bF.js";import{P as Q}from"./ProvenanceBadge-CWdDkU1m.js";import{l as je}from"./listSkills-C1aWKf0T.js";import{S as be,V}from"./Library-0XYvkhh2.js";import"./monaco-editor-BsIlgG7c.js";import"./Button-ssBzvFha.js";const Se=250,we=2e3;function ye(m,p){return{user:{skills:`${m}/.claude/skills`,commands:`${m}/.claude/commands`},project:p?{skills:`${p}/.claude/skills`,commands:`${p}/.claude/commands`}:null}}function Ce(){const m=ce(),p=de(),x=(p==null?void 0:p.cwd)??null,v=ue(t=>t.navFace),S=a.useRef(!1),B=a.useRef(v),[u,$]=a.useState(()=>v==="project"&&x?"project":"user"),[f,w]=a.useState([]),[o,D]=a.useState(null),[y,L]=a.useState("installed"),[O,Z]=a.useState(""),[q,H]=a.useState([]),[U,F]=a.useState(null),C=a.useMemo(()=>m?ye(m,x):null,[m,x]);a.useEffect(()=>{if(B.current!==v){if(B.current=v,S.current){S.current=!1;return}$(v==="project"&&x?"project":"user")}},[v,x]);const c=a.useMemo(()=>C?u==="user"?C.user:C.project:null,[u,C]),P=a.useRef(0),N=a.useCallback(async()=>{const t=++P.current;if(!c){w([]),H([]);return}const l=[],n=[];try{const e=await je(c.skills);n.push(...e.errors);for(const r of e.entries)l.push({kind:"skills",scope:u,name:r.name,path:r.path,dir:r.dir,disabled:he(r.text),description:pe(r.text).description??void 0})}catch(e){n.push({path:c.skills,error:e instanceof Error?e.message:String(e)})}try{const e=await window.api.config.listDir(c.commands,{filesOnly:!0});e.ok||n.push({path:c.commands,error:e.error??"failed to list directory"});for(const r of e.entries)r.name.endsWith(".md")&&l.push({kind:"commands",scope:u,name:r.name.replace(/\.md$/,""),path:r.path,dir:null,disabled:!1})}catch(e){n.push({path:c.commands,error:e instanceof Error?e.message:String(e)})}if(P.current===t){for(const e of n)E.error(`Could not read ${e.path}: ${e.error}`);H(n),l.sort((e,r)=>e.kind===r.kind?e.name.localeCompare(r.name):e.kind==="skills"?-1:1),w(l),D(e=>{var r;return l.find(i=>i.path===e)?e:((r=l[0])==null?void 0:r.path)??null})}},[c,u]);a.useEffect(()=>{N()},[N]),a.useEffect(()=>()=>{P.current+=1},[]);const X=a.useRef(N);X.current=N;const Y=a.useRef(f);Y.current=f;const z=a.useRef(o);z.current=o;const g=a.useRef(null),A=a.useRef(!1),M=a.useRef(!1),W=a.useCallback(async()=>{if(A.current){M.current=!0;return}A.current=!0;try{await X.current()}finally{A.current=!1}M.current&&(M.current=!1,W())},[]);a.useEffect(()=>()=>{g.current&&clearTimeout(g.current)},[]);const ee=a.useCallback(t=>{var r;const l=z.current,n=l?Y.current.find(i=>i.path===l):null,e=l?(r=d.getState().files[l])==null?void 0:r.lastSavedAt:null;n!=null&&n.dir&&e&&Date.now()-e<we&&(t===n.dir||n.dir.startsWith(`${t}/`))||(g.current&&clearTimeout(g.current),g.current=setTimeout(()=>{g.current=null,W()},Se))},[W]);fe(c?[c.skills,c.commands]:[],ee);const b=d(t=>t.files),te=d(t=>t.loadText),se=d(t=>t.setDraft),re=d(t=>t.saveText),ae=d(t=>t.revert),ne=d(t=>t.watchFile),G=d(t=>t.unwatchFile);async function le(t,l){const n=await window.api.config.readText(t.path);if(!n.exists)return;const e=ve(n.text,l);if(e===n.text)return;const r=await window.api.config.writeText(t.path,e);if(!r.ok){E.error(r.error??"failed to update skill");return}w(i=>i.map(j=>j.path===t.path?{...j,disabled:l}:j)),d.getState().files[t.path]&&d.getState().loadText(t.path,!0)}async function oe(t){if(!t.dir)return;F(null);const l=await window.api.files.delete(t.dir);if(!l.ok){E.error(l.error??"failed to remove skill");return}E.info(`Removed "${t.name}" — moved to trash`),G(t.path),w(n=>{const e=n.filter(r=>r.path!==t.path);return D(r=>{var i;return r!==t.path?r:((i=e[0])==null?void 0:i.path)??null}),e})}a.useEffect(()=>{if(o)return b[o]||te(o),ne(o),()=>G(o)},[o]);const[ie,R]=a.useState(null);if(!m)return s.jsx(T,{title:"loading…"});if(y==="library")return s.jsx(I,{toolbar:s.jsx(V,{active:y,onChange:L,installedLabel:"Installed",libraryLabel:"Library"}),children:s.jsx(be,{})});if(u==="project"&&!x)return s.jsx(I,{toolbar:s.jsxs(s.Fragment,{children:[s.jsx(V,{active:y,onChange:L}),s.jsx("span",{className:"mx-2 text-fg-faint",children:"·"}),s.jsx(K,{scopes:["user","project"],active:u,onChange:t=>{S.current=!0,$(t)}})]}),children:s.jsx(T,{title:"no active project",hint:"open a tab in a project directory to view project skills & commands"})});const h=f.find(t=>t.path===o)??null,k=o?b[o]:null;return s.jsx(I,{toolbar:s.jsxs(s.Fragment,{children:[s.jsx(V,{active:y,onChange:L}),s.jsx("span",{className:"mx-2 text-fg-faint",children:"·"}),s.jsx(K,{scopes:["user","project"],active:u,onChange:t=>{S.current=!0,$(t)}}),s.jsxs("span",{className:"ml-3 text-fg-faint",children:[f.length," ",f.length===1?"item":"items"]}),s.jsx("div",{className:"flex-1"}),h&&s.jsx(Q,{scope:h.scope,input:{type:h.kind==="commands"?"command":"skill",name:h.name}}),s.jsx("span",{className:"ml-2 text-fg-faint truncate",children:(h==null?void 0:h.path)??""})]}),footer:o&&k?s.jsx(ge,{dirty:k.dirty,busy:k.busy,parseError:ie,lastSavedAt:k.lastSavedAt,onSave:async()=>{R(null);const t=await re(o);t.ok||R(t.error??"save failed")},onRevert:()=>{R(null),ae(o)}}):null,children:s.jsx(me,{sidebar:s.jsxs("div",{className:"py-1",children:[s.jsx("div",{className:"px-2 pb-1",children:s.jsx("input",{value:O,onChange:t=>Z(t.target.value),placeholder:"filter…",className:"w-full bg-bg border border-line rounded px-2 py-0.5 text-xs text-fg"})}),["skills","commands"].map(t=>{const l=O.toLowerCase(),n=f.filter(e=>e.kind===t&&(!l||e.name.toLowerCase().includes(l)));return s.jsxs("div",{className:"mb-3",children:[s.jsx("div",{className:"px-3 py-1 text-xs uppercase tracking-wider text-fg-faint",children:t==="skills"?"Skills":"Slash Commands"}),n.length===0?s.jsx("div",{className:"px-3 py-1 text-xs text-fg-faint italic",children:"none"}):n.map(e=>{var i,j,J;const r=e.kind==="skills";return s.jsxs("div",{className:`w-full px-3 py-1 text-xs flex items-center justify-between gap-2 ${o===e.path?"bg-bg-hi text-fg":"text-fg-dim hover:text-fg hover:bg-bg-hi"}`,children:[s.jsxs("button",{onClick:()=>D(e.path),className:"flex-1 min-w-0 text-left",children:[s.jsxs("div",{className:`truncate ${e.disabled?"line-through opacity-50":""}`,title:e.disabled?"Disabled — Claude will not auto-invoke this skill":void 0,children:[e.kind==="commands"?"/":"",e.name]}),e.description&&s.jsx("div",{className:"truncate text-fg-faint",children:e.description})]}),s.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[s.jsx(Q,{interactive:!1,scope:e.scope,input:{type:e.kind==="commands"?"command":"skill",name:e.name}}),((i=b[e.path])==null?void 0:i.dirty)&&s.jsx("span",{className:"w-1 h-1 rounded-full bg-accent"}),r&&s.jsx("span",{title:(j=b[e.path])!=null&&j.dirty?"This skill has unsaved edits — save or revert before toggling":void 0,children:s.jsx(ke,{checked:!e.disabled,disabled:!!((J=b[e.path])!=null&&J.dirty),onChange:_=>void le(e,!_)})}),e.kind==="skills"&&U===e.path&&s.jsxs("span",{className:"flex items-center gap-1",children:[s.jsx("button",{onClick:()=>void oe(e),title:`Remove ${e.name} — moves the folder to trash; reinstall from the Library`,className:"text-[10px] font-semibold text-red-400 hover:text-red-300",children:"confirm"}),s.jsx("button",{onClick:()=>F(null),title:"Cancel",className:"text-[10px] text-fg-faint hover:text-fg",children:"cancel"})]}),e.kind==="skills"&&U!==e.path&&s.jsx("button",{onClick:_=>{_.stopPropagation(),F(e.path)},title:"Remove skill — moves the folder to trash; reinstall from the Library","aria-label":`Remove ${e.name}`,className:"text-fg-faint hover:text-red-400 leading-none px-0.5",children:"✕"})]})]},e.path)})]},t)})]}),detail:o&&k?s.jsx("div",{className:"h-full",children:s.jsx(xe,{path:o,value:k.draftRaw,onChange:t=>{R(null),se(o,t)}})}):f.length===0&&q.length>0?s.jsx("div",{"data-testid":"skills-list-error",children:s.jsx(T,{title:"could not list skills or commands",hint:q.map(t=>`${t.path}: ${t.error}`).join(`
|
|
2
|
-
`)})}):s.jsx(T,{title:f.length===0?"no skills or commands":"select an item"})})})}const _e=a.memo(Ce);export{_e as Skills};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{aF as i,a_ as g,ap as e,a2 as R,aX as _,b3 as O,an as B,ao as I,aT as V,a7 as $,e as z,h as M,t as T,s as D,l as H,ac as X,b4 as q,C as G,n as A,ab as J}from"./index-S-F5jp_h.js";import{P as F}from"./Panel-C92O_aAH.js";import{S as K}from"./SaveBar-ob2dJJjH.js";import{f as Q,V as P}from"./Library-0XYvkhh2.js";import"./monaco-editor-BsIlgG7c.js";import"./Button-ssBzvFha.js";import"./listSkills-C1aWKf0T.js";const W=300;function Y({activePath:s,selectedPath:o,onSelect:f}){const[l,a]=i.useState([]),h=i.useRef(0),r=i.useRef(f);r.current=f;const y=g(n=>{var d;return s?(d=n.files[s])==null?void 0:d.diskRaw:void 0}),u=i.useRef(null);if(i.useEffect(()=>{r.current(null)},[s]),i.useEffect(()=>{if(h.current+=1,!s){u.current=null,a([]);return}const n=u.current!==s;u.current=s;let d=!1;const m=()=>{h.current+=1;const b=h.current;window.api.config.parseImports(s).then(v=>{d||h.current!==b||(v.ok?a(v.imports):(a([]),_.error(v.error||"failed to parse @-imports")))})},j=n?null:setTimeout(m,W);return n&&m(),()=>{d=!0,j&&clearTimeout(j)}},[s,y]),l.length===0||!s)return null;const x=o===s||o===null;return e.jsxs("div",{className:"w-64 shrink-0 border-r border-line bg-bg-elev overflow-auto","data-testid":"referenced-files-rail",children:[e.jsxs("div",{className:"px-3 py-2 text-[10px] uppercase tracking-wide text-fg-faint border-b border-line",children:["Documents · ",l.length+1]}),e.jsxs("button",{type:"button",onClick:()=>f(null),"aria-current":x,"data-testid":"referenced-file-root",className:`w-full text-left px-3 py-2 border-b border-line ${x?"bg-bg-hi text-fg":"text-fg-dim hover:bg-bg"}`,children:[e.jsx("div",{className:"text-[11.5px] font-medium truncate",children:R(s)}),e.jsx("div",{className:"text-[10px] text-fg-faint truncate",title:s,children:"this system prompt"})]}),l.map(n=>{const d=!n.ok||!n.exists,m=o===n.path;return e.jsxs("button",{type:"button",onClick:()=>f(n),"aria-current":m,"data-testid":"referenced-file-row",className:`w-full text-left px-3 py-2 border-b border-line last:border-b-0 ${m?"bg-bg-hi text-fg":"text-fg-dim hover:bg-bg"}`,children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("span",{className:"text-[11.5px] font-medium truncate flex-1",children:R(n.path)}),d&&e.jsx("span",{className:"shrink-0 px-1.5 py-0.5 rounded text-[9px] uppercase tracking-wide text-amber-400/90 border border-amber-400/30","data-testid":"referenced-file-missing",children:"missing"})]}),e.jsx("div",{className:"text-[10px] text-fg-faint truncate",title:n.path,children:n.path}),e.jsxs("div",{className:"text-[10px] text-fg-faint",children:[n.sizeBytes.toLocaleString()," bytes · ~",n.tokenEstimate.toLocaleString()," tokens"]})]},n.path)})]})}function Z({path:s,value:o,onChange:f,onSave:l,readOnly:a,defaultMode:h,headerRight:r,hideStatusBar:y}){const u=O(),x=B(s),n=I(s),d=V(s),[m,j]=i.useState(()=>a&&n?"preview":h??$(s)),[b,v]=i.useState(!0),[w,L]=i.useState(null),E=i.useRef(null),c=i.useRef(null),k=i.useCallback(t=>{E.current=t},[]),S=i.useCallback(()=>E.current,[]),C=a?n?["preview","edit"]:[]:d?["edit","preview","split"]:n?["edit","preview"]:[],p=n?m:"edit",N=e.jsx(z,{path:s,name:R(s),value:o,onChange:f,onSave:()=>l==null?void 0:l(),onReady:k,onCursor:L,readOnly:a});return e.jsxs("div",{className:"flex flex-col h-full min-h-0","data-testid":"document-editor-pane",children:[e.jsxs("div",{className:"flex items-center gap-1 px-2 h-7 shrink-0 border-b border-line bg-bg-elev",children:[e.jsx("span",{className:"text-[11px] font-medium text-fg truncate",children:R(s)}),a&&e.jsx("span",{className:"ml-1 px-1.5 py-0.5 rounded text-[9px] uppercase tracking-wide text-fg-faint border border-line",children:"read-only"}),e.jsx("div",{className:"flex-1"}),r,x&&(p==="preview"||p==="split")&&e.jsx("button",{onClick:()=>v(t=>!t),"data-testid":"document-outline-toggle",className:`px-2 py-0.5 text-[10px] border border-line rounded ${b?"bg-bg-hi text-fg":"text-fg-faint hover:text-fg"}`,title:"Toggle document outline",children:"Outline"}),C.length>0&&e.jsx("div",{className:"flex items-center ml-1 rounded border border-line overflow-hidden","data-testid":"document-mode-toggle",children:C.map(t=>e.jsx("button",{onClick:()=>j(t),className:`px-2 py-0.5 text-[10px] capitalize transition-colors ${p===t?"bg-bg-hi text-fg":"text-fg-faint hover:text-fg"}`,children:t},t))})]}),e.jsx("div",{className:"flex-1 min-h-0",children:p==="split"&&x?e.jsxs("div",{className:"flex h-full",children:[b&&e.jsx(M,{text:o,scrollRef:c}),e.jsxs("div",{className:"flex-1 min-w-0 flex flex-col border-r border-line",children:[!a&&e.jsx(T,{getEditor:S}),e.jsx("div",{className:"flex-1 min-h-0",children:N})]}),e.jsx("div",{className:"flex-1 min-w-0",children:e.jsx(D,{ref:c,text:o,flush:!0,wideMeasure:u.wideMeasure})})]}):p==="preview"&&x?e.jsxs("div",{className:"flex h-full",children:[b&&e.jsx(M,{text:o,scrollRef:c}),e.jsx("div",{className:"flex-1 min-w-0",children:e.jsx(D,{ref:c,text:o,wideMeasure:u.wideMeasure})})]}):x?e.jsxs("div",{className:"flex flex-col h-full",children:[!a&&e.jsx(T,{getEditor:S}),e.jsx("div",{className:"flex-1 min-h-0",children:N})]}):N}),!y&&e.jsx(H,{text:o,cursor:w,language:X(s)||void 0})]})}const U={title:"User system prompt",body:"This is the real ~/.claude/CLAUDE.md on disk — the instructions the claude CLI loads into every session it starts on this machine, in every project. A project's own CLAUDE.md / CLAUDE.local.md are read from that project's directory when a session launches there; they are not edited here."};function ee(){const s=q(),[o,f]=i.useState("installed"),l=i.useMemo(()=>s?G.resolve("user",s,null):null,[s]),[a,h]=i.useState(null),r=(a==null?void 0:a.path)??l,y=!!a&&(!a.ok||!a.exists),u=g(t=>t.files),x=g(t=>t.loadText),n=g(t=>t.setDraft),d=g(t=>t.saveText),m=g(t=>t.revert),j=g(t=>t.watchFile),b=g(t=>t.unwatchFile);i.useEffect(()=>{if(l)return x(l,!0),j(l),()=>{b(l)}},[l]),i.useEffect(()=>{if(!(!r||r===l))return x(r,!0),j(r),()=>{b(r)}},[r,l]);const[v,w]=i.useState(null),L=i.useCallback(t=>{w(null),h(t)},[]);if(!s)return e.jsx(A,{title:"loading…"});if(o==="library")return e.jsx(F,{toolbar:e.jsx(P,{active:o,onChange:f,installedLabel:"Editor",libraryLabel:"Presets"}),children:e.jsx(Q,{})});const E=l?u[l]:null,c=r?u[r]:null,k=(c==null?void 0:c.draftRaw)??"",S=J(k),C=k.length,p=y,N=async()=>{if(!r)return;w(null);const t=await d(r);t.ok||w(t.error??"save failed")};return e.jsx(F,{toolbar:e.jsxs(e.Fragment,{children:[e.jsx(P,{active:o,onChange:f,installedLabel:"Editor",libraryLabel:"Presets"}),e.jsx("span",{className:"mx-2 text-fg-faint",children:"·"}),e.jsx("span",{className:"text-fg-dim",children:"User scope"}),e.jsx("span",{className:"ml-3 text-fg-faint truncate",children:r??"—"}),e.jsx("div",{className:"flex-1"}),e.jsxs("span",{className:"text-fg-faint",children:[C.toLocaleString()," chars · ~",S.toLocaleString()," tokens"]})]}),footer:r&&c&&!p?e.jsx(K,{dirty:c.dirty,busy:c.busy,parseError:v,lastSavedAt:c.lastSavedAt,leading:c.exists?a?e.jsx("span",{children:"editing an imported file"}):null:e.jsx("span",{children:"file will be created on save"}),onSave:N,onRevert:()=>{w(null),m(r)}}):null,children:l&&E?e.jsxs("div",{className:"h-full flex flex-col",children:[e.jsxs("div",{"data-testid":"system-prompt-scope-note",className:"shrink-0 border-b border-line bg-bg-elev px-3 py-2 text-[11.5px] leading-snug",children:[e.jsx("span",{className:"font-semibold text-fg",children:U.title}),e.jsx("span",{className:"mx-1.5 text-fg-faint",children:"·"}),e.jsx("span",{className:"text-fg-dim",children:U.body}),e.jsx("span",{className:"ml-1.5 font-mono text-fg-faint",children:l})]}),e.jsxs("div",{className:"flex-1 min-h-0 flex",children:[e.jsx(Y,{activePath:l,selectedPath:r,onSelect:L}),e.jsxs("div",{className:"flex-1 min-w-0 flex flex-col",children:[p&&e.jsx("div",{"data-testid":"system-prompt-missing-note",className:"shrink-0 border-b border-line bg-bg-elev px-3 py-1.5 text-[11px] text-amber-400/90",children:"This import does not resolve to a readable file — the CLI will skip it."}),r&&e.jsx("div",{className:"flex-1 min-h-0",children:e.jsx(Z,{path:r,value:k,readOnly:p,defaultMode:"split",onChange:t=>{w(null),n(r,t)},onSave:()=>{N()}},r)})]})]})]}):e.jsx(A,{title:"resolving…"})})}const oe=i.memo(ee);export{oe as SystemPrompt};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{aF as r,W as p,ap as e,n as k,aW as w,aX as b,a1 as y}from"./index-S-F5jp_h.js";import{P}from"./Panel-C92O_aAH.js";import{L as E}from"./ListDetail-CkKXAM59.js";import{u as S,a as v,t as N}from"./useAgentsDirWatch-BfbrFvB3.js";import"./monaco-editor-BsIlgG7c.js";function $(){const[s,i]=r.useState(p[0].tag),[l,g]=r.useState(null),[h,x]=r.useState(!1),c=r.useRef(!0);r.useEffect(()=>()=>{c.current=!1},[]);const f=r.useRef(0),o=async()=>{const t=++f.current;try{const n=await window.api.agents.listPersonas();c.current&&f.current===t&&g(n)}catch(n){if(!c.current||f.current!==t)return;g([]),b.error(n.message||"failed to load agent personas")}};r.useEffect(()=>{o()},[]),r.useEffect(()=>window.api.agents.onChanged(()=>o()),[]),S(null,()=>o());const m=p.find(t=>t.tag===s)??null,a=async(t,n)=>{try{await window.api.agents.savePersona(v(t,{tags:N([...t.tags,n])})),x(!1),await o()}catch(d){b.error(d.message||"failed to assign tag")}},u=async(t,n)=>{try{await window.api.agents.savePersona(v(t,{tags:N(t.tags.filter(d=>d!==n))})),await o()}catch(d){b.error(d.message||"failed to remove tag")}};return e.jsx(P,{toolbar:e.jsxs("span",{className:"text-fg-faint",children:[p.length," tag",p.length===1?"":"s"]}),children:e.jsx(E,{sidebar:e.jsx("div",{className:"py-1",children:p.map(t=>{const n=w(t.tag),d=s===t.tag,j=(l==null?void 0:l.filter(T=>T.tags.includes(t.tag)).length)??0;return e.jsxs("button",{onClick:()=>{i(t.tag),x(!1)},className:`w-full text-left px-3 py-1.5 text-xs flex items-center gap-2 border-l-2 ${d?"bg-bg-hi text-fg border-accent":"text-fg-dim hover:text-fg hover:bg-bg-hi border-transparent"}`,children:[e.jsxs("span",{className:`px-1.5 py-0.5 rounded text-[10px] font-mono font-semibold ${n.bg} ${n.text} ${n.border?"border border-current/30":""}`,children:["#",t.tag]}),e.jsx("span",{className:"truncate",children:t.label}),j>0&&e.jsx("span",{className:"ml-auto text-[10.5px] text-fg-faint font-mono shrink-0",children:j})]},t.tag)})}),detail:m?e.jsx(C,{entry:m,personas:l,adding:h,setAdding:x,onAssign:a,onUnassign:u}):e.jsx(k,{title:"select a tag"})})})}const q=r.memo($);function C({entry:s,personas:i,adding:l,setAdding:g,onAssign:h,onUnassign:x}){const c=w(s.tag),f=y(s.tag),o=(i==null?void 0:i.filter(a=>a.tags.includes(s.tag)))??[],m=(i==null?void 0:i.filter(a=>!a.tags.includes(s.tag)))??[];return e.jsxs("div",{className:"p-4 space-y-4 max-w-3xl",children:[e.jsxs("div",{className:"flex items-center gap-2.5",children:[e.jsxs("span",{className:`px-2 py-1 rounded text-xs font-mono font-semibold ${c.bg} ${c.text} ${c.border?"border border-current/30":""}`,children:["#",s.tag]}),e.jsx("span",{className:"text-sm font-semibold text-fg",children:s.label})]}),e.jsx("div",{className:"text-xs text-fg-dim leading-relaxed",children:s.description}),e.jsxs("div",{children:[e.jsx("div",{className:"text-[10.5px] uppercase tracking-wide text-fg-faint mb-1.5 font-mono",children:"/develop eagerness"}),e.jsx("span",{className:"px-1.5 py-0.5 text-[10px] rounded border border-line text-fg-dim font-mono",children:s.developEagerness})]}),e.jsxs("div",{children:[e.jsx("div",{className:"text-[10.5px] uppercase tracking-wide text-fg-faint mb-1.5 font-mono",children:"develops via"}),e.jsx("span",{className:"px-1.5 py-0.5 text-[10px] rounded border border-line text-fg-dim font-mono",children:s.developsVia})]}),e.jsxs("div",{children:[e.jsx("div",{className:"text-[10.5px] uppercase tracking-wide text-fg-faint mb-1.5 font-mono",children:"agents carrying this tag"}),i===null?e.jsx("div",{className:"text-xs text-fg-faint italic",children:"loading…"}):e.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[o.map(a=>e.jsxs("span",{className:"inline-flex items-center gap-1.5 bg-bg-elev border border-line rounded px-2 py-0.5 text-[11px] font-mono text-fg-dim",children:[a.name,e.jsx("button",{onClick:()=>x(a,s.tag),title:"Remove this tag from the agent",className:"text-fg-faint hover:text-fg",children:"×"})]},a.name)),o.length===0&&!l&&e.jsx("span",{className:"text-xs text-fg-faint italic mr-1",children:"no agent carries this tag yet."}),l?m.length>0?e.jsxs("select",{autoFocus:!0,defaultValue:"",onChange:a=>{const u=i.find(t=>t.name===a.target.value);u&&h(u,s.tag)},onBlur:()=>g(!1),className:"bg-bg border border-line rounded px-2 py-0.5 text-[11px] text-fg font-mono",children:[e.jsx("option",{value:"",disabled:!0,children:"pick an agent…"}),m.map(a=>e.jsx("option",{value:a.name,children:a.name},a.name))]}):e.jsx("span",{className:"text-xs text-fg-faint italic",children:"every agent already carries this tag."}):e.jsx("button",{onClick:()=>g(!0),className:"px-2 py-0.5 rounded-full text-[11px] font-mono border border-line text-fg-faint hover:text-fg hover:bg-bg-hi",children:"+ assign agent"})]})]}),e.jsxs("div",{children:[e.jsx("div",{className:"text-[10.5px] uppercase tracking-wide text-fg-faint mb-1.5 font-mono",children:"opening framing — sent before the human's goal"}),e.jsx("pre",{className:"text-xs text-fg-dim whitespace-pre-wrap bg-bg-elev border border-line rounded p-3 leading-relaxed font-sans",children:f.initialPromptTemplate})]})]})}export{q as TagLibrary};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{ap as t,A as f,bf as g,aF as d}from"./index-S-F5jp_h.js";function j({children:s,right:e}){return t.jsxs("div",{className:"flex items-baseline justify-between mb-2.5",children:[t.jsx("span",{className:"text-[11.5px] font-bold uppercase tracking-[0.8px] text-fg-faint",children:s}),e]})}function y({kind:s="soft",icon:e,children:c,onClick:i,disabled:o,testId:n}){return t.jsxs("button",{type:"button","data-testid":n,onClick:i,disabled:o,className:`shrink-0 inline-flex items-center gap-2 rounded-lg px-3.5 py-2 text-[13px] font-semibold transition-colors disabled:opacity-50 ${s==="soft"?"bg-bg-hi border border-line text-fg hover:bg-bg":"text-fg-dim hover:text-fg"}`,children:[e&&t.jsx(f,{name:e,size:15}),c]})}function N({icon:s,title:e,subtitle:c,badge:i,action:o,testId:n}){return t.jsxs("div",{"data-testid":n,className:"flex items-center gap-3.5 bg-bg-hi border border-line rounded-xl px-[18px] py-3.5",children:[t.jsx("span",{className:"w-[34px] h-[34px] rounded-lg bg-bg border border-line grid place-items-center text-fg-dim shrink-0",children:t.jsx(f,{name:s,size:17})}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsxs("div",{className:"flex items-center gap-2.5 mb-0.5",children:[t.jsx("span",{className:"text-sm font-semibold text-fg truncate",children:e}),i]}),t.jsx("div",{className:"font-mono text-[11.5px] text-fg-faint truncate",children:c})]}),o]})}function v({onClick:s,disabled:e,testId:c,children:i="Revoke"}){return t.jsx("button",{"data-testid":c,onClick:s,disabled:e,className:"shrink-0 rounded-lg border border-line bg-bg text-accent px-3.5 py-1.5 text-[12.5px] font-semibold hover:bg-bg-hi disabled:opacity-50 transition-colors",children:i})}function k({code:s,onConfirm:e,testId:c,codeTestId:i,confirmTestId:o,peer:n="browser"}){return t.jsxs("div",{"data-testid":c,className:"flex items-start gap-3.5 px-5 py-4 rounded-2xl border border-accent/40 bg-accent/[0.06]",children:[t.jsx("span",{className:"w-[38px] h-[38px] rounded-[11px] shrink-0 grid place-items-center bg-bg-hi text-accent",children:t.jsx(f,{name:"shield",size:20})}),t.jsxs("div",{className:"flex-1 min-w-0 text-sm text-fg",children:[t.jsx("strong",{className:"font-semibold",children:"Verify E2E session."})," Compare this code with the ",n," — they must match.",t.jsx("div",{"data-testid":i,className:"my-2 text-3xl font-mono tracking-[0.3em] text-center text-accent select-all",children:s}),t.jsx("p",{className:"text-[12.5px] text-fg-faint mb-3",children:"If the codes match, confirm below. Mutating commands are blocked until confirmed."}),t.jsx("button",{"data-testid":o,onClick:e,className:"rounded-lg bg-accent text-white px-4 py-2 text-[13px] font-semibold hover:opacity-90 transition-opacity",children:"Codes match — confirm"})]})]})}function C({children:s,testId:e}){return t.jsx("div",{"data-testid":e,className:"bg-bg-hi border border-line rounded-xl p-5 text-center text-[13.5px] text-fg-faint italic font-serif",children:s})}const m=s=>(s==null?void 0:s.message)||String(s);function S(s){const e=g(r=>r.show),[c,i]=d.useState([]),o=d.useRef(s);o.current=s;const n=d.useCallback(async()=>{try{i(await window.api.remoteClient.list())}catch(r){e("error",m(r))}},[e]);d.useEffect(()=>{n();const r=window.api.remoteClient.onStatus(a=>{var x;(x=o.current)==null||x.call(o,a),i(l=>l.map(b=>b.peerId===a.peerId?{...b,status:a.status,reason:a.reason,sas:a.sas}:b))});return()=>{r()}},[n]);const p=d.useCallback(async r=>{try{const a=await window.api.remoteClient.connect(r);i(x=>x.map(l=>l.peerId===r?{...l,status:a.status,reason:a.reason,sas:a.sas}:l))}catch(a){e("error",m(a))}},[e]),u=d.useCallback(async r=>{try{const a=await window.api.remoteClient.confirmSas(r);a.ok||e("error",a.reason??"SAS confirmation failed"),await n()}catch(a){e("error",m(a))}},[e,n]),h=d.useCallback(async r=>{try{await window.api.remoteClient.remove(r),await n()}catch(a){e("error",m(a))}},[e,n]);return{peers:c,refresh:n,connect:p,confirmSas:u,revoke:h}}export{C as E,y as P,N as R,k as S,v as a,j as b,S as u};
|
|
@@ -1,133 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
// Desktop credential for acting as a 'browser'-role relay client against
|
|
4
|
-
// bilko.run's sm-relay client endpoints. Pairs with a one-time client code,
|
|
5
|
-
// stores the long-lived client token at 0600, and exchanges it for one-time WS
|
|
6
|
-
// tickets and the owner's device list. No Electron imports.
|
|
7
|
-
|
|
8
|
-
const fs = require('node:fs');
|
|
9
|
-
const https = require('node:https');
|
|
10
|
-
const path = require('node:path');
|
|
11
|
-
const { claudeHome } = require('../scheduler/schedulerPaths.cjs');
|
|
12
|
-
const { writeJsonAtomicSync, readJsonOrSync } = require('../util/atomicFs.cjs');
|
|
13
|
-
|
|
14
|
-
const RELAY_CLIENT_API_BASE = 'https://bilko.run/api/sm-relay';
|
|
15
|
-
const REQUEST_TIMEOUT_MS = 15_000;
|
|
16
|
-
const CLIENT_NAME_MAX = 64;
|
|
17
|
-
|
|
18
|
-
/** Default transport: resolves { status, json }; never includes headers in errors. */
|
|
19
|
-
function defaultRequest({ method, url, headers = {}, body }) {
|
|
20
|
-
return new Promise((resolve, reject) => {
|
|
21
|
-
let parsed;
|
|
22
|
-
try { parsed = new URL(url); } catch { reject(new Error('invalid_url')); return; }
|
|
23
|
-
if (parsed.protocol !== 'https:') {
|
|
24
|
-
reject(new Error('Only https:// allowed for relay API calls'));
|
|
25
|
-
return;
|
|
26
|
-
}
|
|
27
|
-
const outHeaders = { ...headers };
|
|
28
|
-
if (body != null) outHeaders['Content-Length'] = Buffer.byteLength(body);
|
|
29
|
-
const req = https.request({
|
|
30
|
-
hostname: parsed.hostname,
|
|
31
|
-
port: parsed.port || 443,
|
|
32
|
-
path: parsed.pathname + (parsed.search || ''),
|
|
33
|
-
method,
|
|
34
|
-
headers: outHeaders,
|
|
35
|
-
rejectUnauthorized: true,
|
|
36
|
-
}, (res) => {
|
|
37
|
-
let data = '';
|
|
38
|
-
res.on('data', (c) => { data += c; });
|
|
39
|
-
res.on('end', () => {
|
|
40
|
-
let json = null;
|
|
41
|
-
try { json = JSON.parse(data); } catch { /* non-JSON body */ }
|
|
42
|
-
resolve({ status: res.statusCode, json });
|
|
43
|
-
});
|
|
44
|
-
});
|
|
45
|
-
req.on('error', (err) => reject(new Error(err.message)));
|
|
46
|
-
req.setTimeout(REQUEST_TIMEOUT_MS, () => { req.destroy(new Error('timeout')); });
|
|
47
|
-
if (body != null) req.write(body);
|
|
48
|
-
req.end();
|
|
49
|
-
});
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
function defaultTokenPath() {
|
|
53
|
-
return path.join(claudeHome(), 'session-manager', 'relay-client.json');
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
function createRelayClientAuth({ tokenPath, request = defaultRequest } = {}) {
|
|
57
|
-
const file = tokenPath || defaultTokenPath();
|
|
58
|
-
|
|
59
|
-
function readStored() {
|
|
60
|
-
const data = readJsonOrSync(file, null);
|
|
61
|
-
return data && typeof data.clientToken === 'string' && data.clientToken ? data : null;
|
|
62
|
-
}
|
|
63
|
-
function clearToken() {
|
|
64
|
-
fs.rmSync(file, { force: true });
|
|
65
|
-
}
|
|
66
|
-
function isPaired() { return readStored() !== null; }
|
|
67
|
-
function getClientId() { return readStored()?.clientId ?? null; }
|
|
68
|
-
|
|
69
|
-
async function pair(code, clientName) {
|
|
70
|
-
const body = { code: String(code ?? '').trim().toUpperCase() };
|
|
71
|
-
const name = typeof clientName === 'string' ? clientName.slice(0, CLIENT_NAME_MAX) : '';
|
|
72
|
-
if (name) body.clientName = name;
|
|
73
|
-
const res = await request({
|
|
74
|
-
method: 'POST',
|
|
75
|
-
url: `${RELAY_CLIENT_API_BASE}/client-pair`,
|
|
76
|
-
headers: { 'Content-Type': 'application/json' },
|
|
77
|
-
body: JSON.stringify(body),
|
|
78
|
-
});
|
|
79
|
-
const json = res.json || {};
|
|
80
|
-
if (res.status === 404) return { ok: false, error: 'relay_client_auth_unavailable' };
|
|
81
|
-
if (res.status !== 200) return { ok: false, error: json.error || `HTTP ${res.status}` };
|
|
82
|
-
if (!json.clientToken) return { ok: false, error: 'relay_auth_failed' };
|
|
83
|
-
writeJsonAtomicSync(file, {
|
|
84
|
-
clientToken: json.clientToken,
|
|
85
|
-
clientId: json.clientId,
|
|
86
|
-
pairedAt: new Date().toISOString(),
|
|
87
|
-
}, { mode: 0o600 });
|
|
88
|
-
return { ok: true, clientId: json.clientId };
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
/** Authenticated call; maps status codes to the module's error vocabulary. */
|
|
92
|
-
async function authed(method, route, body) {
|
|
93
|
-
const stored = readStored();
|
|
94
|
-
if (!stored) throw new Error('relay_client_unpaired');
|
|
95
|
-
const headers = { Authorization: `Bearer ${stored.clientToken}` };
|
|
96
|
-
if (body != null) headers['Content-Type'] = 'application/json';
|
|
97
|
-
const res = await request({ method, url: `${RELAY_CLIENT_API_BASE}${route}`, headers, body });
|
|
98
|
-
if (res.status === 401) {
|
|
99
|
-
clearToken();
|
|
100
|
-
throw new Error('relay_client_unpaired');
|
|
101
|
-
}
|
|
102
|
-
if (res.status === 404) throw new Error('relay_client_auth_unavailable');
|
|
103
|
-
if (res.status < 200 || res.status >= 300) {
|
|
104
|
-
throw new Error((res.json && res.json.error) || `HTTP ${res.status}`);
|
|
105
|
-
}
|
|
106
|
-
return res.json || {};
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
// Optional peer argument is accepted and ignored (remoteClient passes it).
|
|
110
|
-
async function getBrowserTicket(_peer) {
|
|
111
|
-
const json = await authed('POST', '/client-ticket', '{}');
|
|
112
|
-
if (!json.ticket) throw new Error('relay_auth_failed');
|
|
113
|
-
return json.ticket;
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
async function listDevices() {
|
|
117
|
-
const json = await authed('GET', '/client/devices');
|
|
118
|
-
return Array.isArray(json.devices) ? json.devices : [];
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
async function getDevicePubKey(deviceId) {
|
|
122
|
-
const devices = await listDevices();
|
|
123
|
-
const hit = devices.find((d) => d && d.deviceId === deviceId);
|
|
124
|
-
if (!hit) throw new Error('device_not_found');
|
|
125
|
-
return hit.devicePubKey;
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
return { pair, getBrowserTicket, getDevicePubKey, listDevices, isPaired, getClientId, clearToken };
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
const relayClientAuth = createRelayClientAuth();
|
|
132
|
-
|
|
133
|
-
module.exports = { createRelayClientAuth, relayClientAuth, RELAY_CLIENT_API_BASE };
|