@openchamber/web 1.5.9 → 1.6.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/{ToolOutputDialog-Dz-mXTUL.js → ToolOutputDialog-BSKxzwkK.js} +1 -1
- package/dist/assets/{index-6-7dM4cm.js → index-D8WE2_bP.js} +2 -2
- package/dist/assets/main-QfYtNqzD.js +265 -0
- package/dist/index.html +1 -1
- package/package.json +1 -1
- package/server/index.js +9 -0
- package/dist/assets/main-C3SPutdi.js +0 -265
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{q as L,j as e,bI as j,bS as g,aF as P,bs as C,aT as _,bv as w,a5 as T,a4 as z,av as v,bV as D,bW as F,bX as O,b_ as I,b$ as W,a6 as $}from"./vendor-.bun-Bui932eM.js";import{D as R,a as H,c as b,b as B,t as f,g as p,f as V,p as Q,r as E,d as G,e as q,h as A,S as K,i as U}from"./main-
|
|
1
|
+
import{q as L,j as e,bI as j,bS as g,aF as P,bs as C,aT as _,bv as w,a5 as T,a4 as z,av as v,bV as D,bW as F,bX as O,b_ as I,b$ as W,a6 as $}from"./vendor-.bun-Bui932eM.js";import{D as R,a as H,c as b,b as B,t as f,g as p,f as V,p as Q,r as E,d as G,e as q,h as A,S as K,i as U}from"./main-QfYtNqzD.js";import"./index-D8WE2_bP.js";const X=r=>{const s="h-3.5 w-3.5 flex-shrink-0",t=r.toLowerCase();return t==="reasoning"?e.jsx(P,{className:s}):t==="image-preview"?e.jsx(C,{className:s}):t==="edit"||t==="multiedit"||t==="apply_patch"||t==="str_replace"||t==="str_replace_based_edit_tool"?e.jsx(_,{className:s}):t==="write"||t==="create"||t==="file_write"?e.jsx(w,{className:s}):t==="read"||t==="view"||t==="file_read"||t==="cat"?e.jsx(w,{className:s}):t==="bash"||t==="shell"||t==="cmd"||t==="terminal"?e.jsx(T,{className:s}):t==="list"||t==="ls"||t==="dir"||t==="list_files"?e.jsx(z,{className:s}):t==="search"||t==="grep"||t==="find"||t==="ripgrep"?e.jsx(v,{className:s}):t==="glob"?e.jsx(D,{className:s}):t==="fetch"||t==="curl"||t==="wget"||t==="webfetch"?e.jsx(F,{className:s}):t==="web-search"||t==="websearch"||t==="search_web"||t==="google"||t==="bing"||t==="duckduckgo"?e.jsx(v,{className:s}):t==="todowrite"||t==="todoread"?e.jsx(O,{className:s}):t==="plan_enter"?e.jsx(I,{className:s}):t==="plan_exit"?e.jsx(W,{className:s}):t.startsWith("git")?e.jsx($,{className:s}):e.jsx(j,{className:s})},Z=({popup:r,onOpenChange:s,syntaxTheme:t,isMobile:u})=>{const[y,N]=L.useState(u?"unified":"side-by-side");return e.jsx(R,{open:r.open,onOpenChange:s,children:e.jsxs(H,{className:b("overflow-hidden flex flex-col min-h-0 pt-3 pb-4 px-4 gap-1","[&>button]:top-1.5",u?"w-[95vw] max-w-[95vw]":"max-w-5xl",u?"[&>button]:right-1":"[&>button]:top-2.5 [&>button]:right-4"),style:{maxHeight:"90vh"},children:[e.jsx("div",{className:"flex-shrink-0 pb-1",children:e.jsxs("div",{className:"flex items-start gap-2 text-foreground typography-ui-header font-semibold",children:[r.metadata?.tool?X(r.metadata.tool):e.jsx(j,{className:"h-3.5 w-3.5 text-foreground flex-shrink-0"}),e.jsx("span",{className:"break-words flex-1 leading-tight",children:r.title}),r.isDiff&&e.jsx(B,{mode:y,onModeChange:N,className:"mr-8 flex-shrink-0"})]})}),e.jsx("div",{className:"flex-1 min-h-0 rounded-xl border border-border/30 bg-muted/10 overflow-hidden",children:e.jsxs("div",{className:"tool-output-surface h-full max-h-[75vh] overflow-y-auto px-3 pr-4",children:[r.metadata?.input&&typeof r.metadata.input=="object"&&Object.keys(r.metadata.input).length>0&&r.metadata?.tool!=="todowrite"&&r.metadata?.tool!=="todoread"&&r.metadata?.tool!=="apply_patch"?(()=>{const n=r.metadata,m=n.input,a=i=>{const o=m[i];return typeof o=="string"?o:typeof o=="number"?String(o):null};return e.jsxs("div",{className:"border-b border-border/20 p-4 -mx-3",children:[e.jsx("div",{className:"typography-markdown font-medium text-muted-foreground mb-2 px-3",children:n.tool==="bash"?"Command:":n.tool==="task"?"Task Details:":"Input:"}),n.tool==="bash"&&a("command")?e.jsx("div",{className:"tool-input-surface bg-transparent rounded-xl border border-border/20 mx-3",children:e.jsx(g,{style:t,language:"bash",PreTag:"div",customStyle:f.getPopupStyles(),codeTagProps:{style:{background:"transparent",backgroundColor:"transparent",fontSize:"inherit"}},wrapLongLines:!0,children:a("command")})}):n.tool==="task"&&a("prompt")?e.jsxs("div",{className:"tool-input-surface bg-transparent rounded-xl border border-border/20 font-mono whitespace-pre-wrap text-foreground/90 mx-3",style:f.getPopupStyles(),children:[a("description")?`Task: ${a("description")}
|
|
2
2
|
`:"",a("subagent_type")?`Agent Type: ${a("subagent_type")}
|
|
3
3
|
`:"",`Instructions:
|
|
4
4
|
${a("prompt")}`]}):n.tool==="write"&&a("content")?e.jsx("div",{className:"tool-input-surface bg-transparent rounded-xl border border-border/20 mx-3",children:e.jsx(g,{style:t,language:p(a("filePath")||a("file_path")||"")||"text",PreTag:"div",customStyle:f.getPopupStyles(),codeTagProps:{style:{background:"transparent",backgroundColor:"transparent",fontSize:"inherit"}},wrapLongLines:!0,children:a("content")})}):e.jsx("div",{className:"tool-input-surface bg-transparent rounded-xl border border-border/20 font-mono whitespace-pre-wrap text-foreground/90 mx-3",style:f.getPopupStyles(),children:V(m,n.tool)})]})})():null,r.isDiff?y==="unified"?e.jsx("div",{className:"typography-code",children:Q(r.content).map((n,m)=>e.jsxs("div",{className:"border-b border-border/20 last:border-b-0",children:[e.jsx("div",{className:b("bg-muted/20 px-3 py-2 font-medium text-muted-foreground border-b border-border/10 sticky top-0 z-10 break-words -mx-3",u?"typography-micro":"typography-markdown"),children:`${n.file} (line ${n.oldStart})`}),e.jsx("div",{children:n.lines.map((a,i)=>e.jsxs("div",{className:b("typography-code font-mono px-3 py-0.5 flex",a.type==="context"&&"bg-transparent",a.type==="removed"&&"bg-transparent",a.type==="added"&&"bg-transparent"),style:{lineHeight:"1.1",...a.type==="removed"?{backgroundColor:"var(--tools-edit-removed-bg)"}:a.type==="added"?{backgroundColor:"var(--tools-edit-added-bg)"}:{}},children:[e.jsx("span",{className:"text-muted-foreground/60 w-10 flex-shrink-0 text-right pr-3 self-start select-none",children:a.lineNumber||""}),e.jsx("div",{className:"flex-1 min-w-0",children:(()=>{const o=typeof r.metadata?.input=="object"&&r.metadata.input!==null?r.metadata.input.file_path||r.metadata.input.filePath:null,l=typeof o=="string"?o:"",d=typeof n=="object"&&n!==null&&"file"in n?n.file:null,h=l||(typeof d=="string"?d:"")||"";return e.jsx(g,{style:t,language:p(h)||"text",PreTag:"div",wrapLines:!0,wrapLongLines:!0,customStyle:{margin:0,padding:0,fontSize:"inherit",background:"transparent",backgroundColor:"transparent",borderRadius:0,overflow:"visible",whiteSpace:"pre-wrap",wordBreak:"break-all",overflowWrap:"anywhere"},codeTagProps:{style:{background:"transparent",backgroundColor:"transparent"}},children:a.content})})()})]},i))})]},m))}):r.diffHunks?e.jsx("div",{className:"typography-code",children:r.diffHunks.map((n,m)=>e.jsxs("div",{className:"border-b border-border/20 last:border-b-0",children:[e.jsx("div",{className:b("bg-muted/20 px-3 py-2 font-medium text-muted-foreground border-b border-border/10 sticky top-0 z-10 break-words -mx-3",u?"typography-micro":"typography-markdown"),children:`${n.file} (line ${n.oldStart})`}),e.jsx("div",{children:n.lines.map((a,i)=>e.jsxs("div",{className:"grid grid-cols-2 divide-x divide-border/20",children:[e.jsx("div",{className:b("typography-code font-mono px-3 py-0.5 overflow-hidden",a.leftLine.type==="context"&&"bg-transparent",a.leftLine.type==="empty"&&"bg-transparent"),style:{lineHeight:"1.1",...a.leftLine.type==="removed"?{backgroundColor:"var(--tools-edit-removed-bg)"}:{}},children:e.jsxs("div",{className:"flex",children:[e.jsx("span",{className:"text-muted-foreground/60 w-10 flex-shrink-0 text-right pr-3 self-start select-none",children:a.leftLine.lineNumber||""}),e.jsx("div",{className:"flex-1 min-w-0",children:a.leftLine.content&&e.jsx(g,{style:t,language:(()=>{const o=r.metadata?.input,l=typeof o=="object"&&o!==null?o:{},d=l.file_path||l.filePath,c=n.file;return p(typeof d=="string"?d:c)||"text"})(),PreTag:"div",wrapLines:!0,wrapLongLines:!0,customStyle:{margin:0,padding:0,fontSize:"inherit",background:"transparent",backgroundColor:"transparent",borderRadius:0,overflow:"visible",whiteSpace:"pre-wrap",wordBreak:"break-all",overflowWrap:"anywhere"},codeTagProps:{style:{background:"transparent",backgroundColor:"transparent"}},children:a.leftLine.content})})]})}),e.jsx("div",{className:b("typography-code font-mono px-3 py-0.5 overflow-hidden",a.rightLine.type==="context"&&"bg-transparent",a.rightLine.type==="empty"&&"bg-transparent"),style:{lineHeight:"1.1",...a.rightLine.type==="added"?{backgroundColor:"var(--tools-edit-added-bg)"}:{}},children:e.jsxs("div",{className:"flex",children:[e.jsx("span",{className:"text-muted-foreground/60 w-10 flex-shrink-0 text-right pr-3 self-start select-none",children:a.rightLine.lineNumber||""}),e.jsx("div",{className:"flex-1 min-w-0",children:a.rightLine.content&&e.jsx(g,{style:t,language:(()=>{const o=r.metadata?.input,l=typeof o=="object"&&o!==null?o:{},d=l.file_path||l.filePath,c=n.file;return p(typeof d=="string"?d:c)||"text"})(),PreTag:"div",wrapLines:!0,wrapLongLines:!0,customStyle:{margin:0,padding:0,fontSize:"inherit",background:"transparent",backgroundColor:"transparent",borderRadius:0,overflow:"visible",whiteSpace:"pre-wrap",wordBreak:"break-all",overflowWrap:"anywhere"},codeTagProps:{style:{background:"transparent",backgroundColor:"transparent"}},children:a.rightLine.content})})]})})]},i))})]},m))}):null:r.image?e.jsx("div",{className:"p-4",children:e.jsxs("div",{className:"flex flex-col items-center gap-3",children:[e.jsx("div",{className:"max-h-[70vh] overflow-hidden rounded-2xl border border-border/40 bg-muted/10",children:e.jsx("img",{src:r.image.url,alt:r.image.filename||r.title||"Image preview",className:"block h-full max-h-[70vh] w-auto max-w-full object-contain",loading:"lazy"})}),r.image.filename&&e.jsx("span",{className:"typography-meta text-muted-foreground text-center",children:r.image.filename})]})}):r.content?e.jsx("div",{className:"p-4",children:(()=>{const n=r.metadata?.tool;if(n==="todowrite"||n==="todoread")return E(r.content)||e.jsx(g,{style:t,language:"json",PreTag:"div",wrapLongLines:!0,customStyle:f.getPopupContainerStyles(),codeTagProps:{style:{background:"transparent",backgroundColor:"transparent",fontSize:"inherit"}},children:r.content});if(n==="list")return G(r.content)||e.jsx("pre",{className:"typography-markdown bg-muted/30 p-2 rounded-xl border border-border/20 font-mono whitespace-pre-wrap",children:r.content});if(n==="grep")return q(r.content,u)||e.jsx("pre",{className:"typography-code bg-muted/30 p-2 rounded-xl border border-border/20 font-mono whitespace-pre-wrap",children:r.content});if(n==="glob")return A(r.content,u)||e.jsx("pre",{className:"typography-code bg-muted/30 p-2 rounded-xl border border-border/20 font-mono whitespace-pre-wrap",children:r.content});if(n==="task"||n==="reasoning")return e.jsx("div",{className:n==="reasoning"?"text-muted-foreground/70":"",children:e.jsx(K,{content:r.content,variant:"tool"})});if(n==="web-search"||n==="websearch"||n==="search_web")return U(r.content)||e.jsx(g,{style:t,language:"text",PreTag:"div",wrapLongLines:!0,customStyle:f.getPopupContainerStyles(),codeTagProps:{style:{background:"transparent",backgroundColor:"transparent",fontSize:"inherit"}},children:r.content});if(n==="read"){const m=r.content.split(`
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/vendor-.bun-Bui932eM.js","assets/vendor--Jn2c0Clh.css","assets/main-
|
|
2
|
-
import{_ as C}from"./vendor-.bun-Bui932eM.js";(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const n of document.querySelectorAll('link[rel="modulepreload"]'))o(n);new MutationObserver(n=>{for(const s of n)if(s.type==="childList")for(const c of s.addedNodes)c.tagName==="LINK"&&c.rel==="modulepreload"&&o(c)}).observe(document,{childList:!0,subtree:!0});function r(n){const s={};return n.integrity&&(s.integrity=n.integrity),n.referrerPolicy&&(s.referrerPolicy=n.referrerPolicy),n.crossOrigin==="use-credentials"?s.credentials="include":n.crossOrigin==="anonymous"?s.credentials="omit":s.credentials="same-origin",s}function o(n){if(n.ep)return;n.ep=!0;const s=r(n);fetch(n.href,s)}})();async function $(e){const t=await fetch("/api/terminal/create",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({cwd:e.cwd,cols:e.cols||80,rows:e.rows||24})});if(!t.ok){const r=await t.json().catch(()=>({error:"Failed to create terminal"}));throw new Error(r.error||"Failed to create terminal session")}return t.json()}function N(e,t,r,o={}){const{maxRetries:n=3,initialRetryDelay:s=1e3,maxRetryDelay:c=8e3,connectionTimeout:p=1e4}=o;let d=null,f=0,y=null,l=null,m=!1,b=!1,g=!1;const j=()=>{y&&(clearTimeout(y),y=null),l&&(clearTimeout(l),l=null)},S=()=>{m=!0,j(),d&&(d.close(),d=null)},k=()=>{if(!(m||g)){if(d&&d.readyState!==EventSource.CLOSED){console.warn("Attempted to create duplicate EventSource, skipping");return}b=!1,d=new EventSource(`/api/terminal/${e}/stream`),l=setTimeout(()=>{!b&&d?.readyState!==EventSource.OPEN&&(console.error("Terminal connection timeout"),d?.close(),O(new Error("Connection timeout"),!1))},p),d.onopen=()=>{b||(b=!0,f=0,j(),t({type:"connected"}))},d.onmessage=T=>{try{const w=JSON.parse(T.data);w.type==="exit"&&(g=!0,S()),t(w)}catch(w){console.error("Failed to parse terminal event:",w),r?.(w,!1)}},d.onerror=T=>{console.error("Terminal stream error:",T,"readyState:",d?.readyState),j();const w=g||d?.readyState===EventSource.CLOSED;d?.close(),d=null,g||O(new Error("Terminal stream connection error"),w)}}},O=(T,w)=>{if(!(m||g))if(f<n&&!w){f++;const P=Math.min(s*Math.pow(2,f-1),c);console.log(`Reconnecting to terminal stream (attempt ${f}/${n}) in ${P}ms`),t({type:"reconnecting",attempt:f,maxAttempts:n}),y=setTimeout(()=>{!m&&!g&&k()},P)}else console.error(`Terminal connection failed after ${f} attempts`),r?.(T,!0),S()};return k(),S}async function v(e,t){const r=await fetch(`/api/terminal/${e}/input`,{method:"POST",headers:{"Content-Type":"text/plain"},body:t});if(!r.ok){const o=await r.json().catch(()=>({error:"Failed to send input"}));throw new Error(o.error||"Failed to send terminal input")}}async function A(e,t,r){const o=await fetch(`/api/terminal/${e}/resize`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({cols:t,rows:r})});if(!o.ok){const n=await o.json().catch(()=>({error:"Failed to resize terminal"}));throw new Error(n.error||"Failed to resize terminal")}}async function G(e){const t=await fetch(`/api/terminal/${e}`,{method:"DELETE"});if(!t.ok){const r=await t.json().catch(()=>({error:"Failed to close terminal"}));throw new Error(r.error||"Failed to close terminal")}}async function I(e,t){const r=await fetch(`/api/terminal/${e}/restart`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({cwd:t.cwd,cols:t.cols??80,rows:t.rows??24})});if(!r.ok){const o=await r.json().catch(()=>({error:"Failed to restart terminal"}));throw new Error(o.error||"Failed to restart terminal")}return r.json()}async function R(e){const t=await fetch("/api/terminal/force-kill",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)});if(!t.ok){const r=await t.json().catch(()=>({error:"Failed to force kill terminal"}));throw new Error(r.error||"Failed to force kill terminal")}}const D=e=>{const t=e?.retry;return{maxRetries:t?.maxRetries??3,initialRetryDelay:t?.initialDelayMs??1e3,maxRetryDelay:t?.maxDelayMs??8e3,connectionTimeout:e?.connectionTimeoutMs??1e4}},J=()=>({async createSession(e){return $(e)},connect(e,t,r){const o=N(e,t.onEvent,t.onError,D(r));return{close:()=>o()}},async sendInput(e,t){await v(e,t)},async resize(e){await A(e.sessionId,e.cols,e.rows)},async close(e){await G(e)},async restartSession(e,t){return I(e,{cwd:t.cwd??"",cols:t.cols,rows:t.rows})},async forceKill(e){await R(e)}}),L=()=>{if(typeof window>"u")return"";const e=window.__OPENCHAMBER_DESKTOP_SERVER__?.origin;return e||window.location.origin},a="/api/git";function i(e,t,r){const o=new URL(e,L());if(t&&o.searchParams.set("directory",t),r)for(const[n,s]of Object.entries(r))s!==void 0&&o.searchParams.set(n,String(s));return o.toString()}async function _(e){const t=await fetch(i(`${a}/check`,e));if(!t.ok)throw new Error(`Failed to check git repository: ${t.statusText}`);return(await t.json()).isGitRepository}async function W(e){const t=await fetch(i(`${a}/status`,e));if(!t.ok)throw new Error(`Failed to get git status: ${t.statusText}`);return t.json()}async function B(e,t){const{path:r,staged:o,contextLines:n}=t;if(!r)throw new Error("path is required to fetch git diff");const s=await fetch(i(`${a}/diff`,e,{path:r,staged:o?"true":void 0,context:n}));if(!s.ok)throw new Error(`Failed to get git diff: ${s.statusText}`);return s.json()}async function U(e,t){const{path:r,staged:o}=t;if(!r)throw new Error("path is required to fetch git file diff");const n=await fetch(i(`${a}/file-diff`,e,{path:r,staged:o?"true":void 0}));if(!n.ok)throw new Error(`Failed to get git file diff: ${n.statusText}`);return n.json()}async function q(e,t){if(!t)throw new Error("path is required to revert git changes");const r=await fetch(i(`${a}/revert`,e),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:t})});if(!r.ok){const o=await r.json().catch(()=>({error:r.statusText}));throw new Error(o.error||"Failed to revert git changes")}}async function M(e){if(!e)return!1;const t=await fetch(i(`${a}/worktree-type`,e));if(!t.ok)throw new Error(`Failed to detect worktree type: ${t.statusText}`);return!!(await t.json()).linked}async function H(e){const t=await fetch(i(`${a}/branches`,e));if(!t.ok)throw new Error(`Failed to get branches: ${t.statusText}`);return t.json()}async function z(e,t){if(!t?.branch)throw new Error("branch is required to delete a branch");const r=await fetch(i(`${a}/branches`,e),{method:"DELETE",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)});if(!r.ok){const o=await r.json().catch(()=>({error:r.statusText}));throw new Error(o.error||"Failed to delete branch")}return r.json()}async function V(e,t){if(!t?.branch)throw new Error("branch is required to delete remote branch");const r=await fetch(i(`${a}/remote-branches`,e),{method:"DELETE",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)});if(!r.ok){const o=await r.json().catch(()=>({error:r.statusText}));throw new Error(o.error||"Failed to delete remote branch")}return r.json()}async function K(e,t){if(!Array.isArray(t)||t.length===0)throw new Error("No files provided to generate commit message");const r=await fetch(i(`${a}/commit-message`,e),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({files:t})});if(!r.ok){const c=await r.json().catch(()=>({error:r.statusText}));throw new Error(c.error||"Failed to generate commit message")}const o=await r.json();if(!o?.message||typeof o.message!="object")throw new Error("Malformed commit generation response");const n=typeof o.message.subject=="string"&&o.message.subject.trim().length>0?o.message.subject.trim():"",s=Array.isArray(o.message.highlights)?o.message.highlights.filter(c=>typeof c=="string"&&c.trim().length>0).map(c=>c.trim()):[];return{message:{subject:n,highlights:s}}}async function Q(e,t){const{base:r,head:o}=t;if(!r||!o)throw new Error("base and head are required");const n=await fetch(i(`${a}/pr-description`,e),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({base:r,head:o})});if(!n.ok){const d=await n.json().catch(()=>({error:n.statusText}));throw new Error(d.error||"Failed to generate PR description")}const s=await n.json().catch(()=>null),c=typeof s?.title=="string"?s.title:"",p=typeof s?.body=="string"?s.body:"";if(!c&&!p)throw new Error("Malformed PR description response");return{title:c,body:p}}async function X(e){const t=await fetch(i(`${a}/worktrees`,e));if(!t.ok){const r=await t.json().catch(()=>({error:t.statusText}));throw new Error(r.error||"Failed to list worktrees")}return t.json()}async function Y(e,t){if(!t?.path||!t?.branch)throw new Error("path and branch are required to add a worktree");const r=await fetch(i(`${a}/worktrees`,e),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)});if(!r.ok){const o=await r.json().catch(()=>({error:r.statusText}));throw new Error(o.error||"Failed to add worktree")}return r.json()}async function Z(e,t){if(!t?.path)throw new Error("path is required to remove a worktree");const r=await fetch(i(`${a}/worktrees`,e),{method:"DELETE",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)});if(!r.ok){const o=await r.json().catch(()=>({error:r.statusText}));throw new Error(o.error||"Failed to remove worktree")}return r.json()}async function tt(e){const t=await fetch(i(`${a}/ignore-openchamber`,e),{method:"POST"});if(!t.ok){const r=await t.json().catch(()=>({error:t.statusText}));throw new Error(r.error||"Failed to update git ignore")}}async function et(e,t,r={}){const o=await fetch(i(`${a}/commit`,e),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({message:t,addAll:r.addAll??!1,files:r.files})});if(!o.ok){const n=await o.json().catch(()=>({error:o.statusText}));throw new Error(n.error||"Failed to create commit")}return o.json()}async function rt(e,t={}){const r=await fetch(i(`${a}/push`,e),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)});if(!r.ok){const o=await r.json().catch(()=>({error:r.statusText}));throw new Error(o.error||"Failed to push")}return r.json()}async function ot(e,t={}){const r=await fetch(i(`${a}/pull`,e),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)});if(!r.ok){const o=await r.json().catch(()=>({error:r.statusText}));throw new Error(o.error||"Failed to pull")}return r.json()}async function nt(e,t={}){const r=await fetch(i(`${a}/fetch`,e),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)});if(!r.ok){const o=await r.json().catch(()=>({error:r.statusText}));throw new Error(o.error||"Failed to fetch")}return r.json()}async function st(e,t){const r=await fetch(i(`${a}/checkout`,e),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({branch:t})});if(!r.ok){const o=await r.json().catch(()=>({error:r.statusText}));throw new Error(o.error||"Failed to checkout branch")}return r.json()}async function at(e,t,r){const o=await fetch(i(`${a}/branches`,e),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:t,startPoint:r})});if(!o.ok){const n=await o.json().catch(()=>({error:o.statusText}));throw new Error(n.error||"Failed to create branch")}return o.json()}async function it(e,t,r){const o=await fetch(i(`${a}/branches/rename`,e),{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({oldName:t,newName:r})});if(!o.ok){const n=await o.json().catch(()=>({error:o.statusText}));throw new Error(n.error||"Failed to rename branch")}return o.json()}async function ct(e,t={}){const r=await fetch(i(`${a}/log`,e,{maxCount:t.maxCount,from:t.from,to:t.to,file:t.file}));if(!r.ok)throw new Error(`Failed to get git log: ${r.statusText}`);return r.json()}async function lt(e,t){const r=await fetch(i(`${a}/commit-files`,e,{hash:t}));if(!r.ok)throw new Error(`Failed to get commit files: ${r.statusText}`);return r.json()}async function dt(){const e=await fetch(i(`${a}/identities`,void 0));if(!e.ok)throw new Error(`Failed to get git identities: ${e.statusText}`);return e.json()}async function ut(e){const t=await fetch(i(`${a}/identities`,void 0),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)});if(!t.ok){const r=await t.json().catch(()=>({error:t.statusText}));throw new Error(r.error||"Failed to create git identity")}return t.json()}async function ht(e,t){const r=await fetch(i(`${a}/identities/${e}`,void 0),{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)});if(!r.ok){const o=await r.json().catch(()=>({error:r.statusText}));throw new Error(o.error||"Failed to update git identity")}return r.json()}async function pt(e){const t=await fetch(i(`${a}/identities/${e}`,void 0),{method:"DELETE"});if(!t.ok){const r=await t.json().catch(()=>({error:t.statusText}));throw new Error(r.error||"Failed to delete git identity")}}async function ft(e){if(!e)return null;const t=await fetch(i(`${a}/current-identity`,e));if(!t.ok)throw new Error(`Failed to get current git identity: ${t.statusText}`);const r=await t.json();return r?{userName:r.userName??null,userEmail:r.userEmail??null,sshCommand:r.sshCommand??null}:null}async function wt(e){if(!e)return!1;const t=await fetch(i(`${a}/has-local-identity`,e));if(!t.ok)throw new Error(`Failed to check local identity: ${t.statusText}`);return(await t.json().catch(()=>null))?.hasLocalIdentity===!0}async function Nt(){const e=await fetch(i(`${a}/global-identity`,void 0));if(!e.ok)throw new Error(`Failed to get global git identity: ${e.statusText}`);const t=await e.json();return!t||!t.userName&&!t.userEmail?null:{userName:t.userName??null,userEmail:t.userEmail??null,sshCommand:t.sshCommand??null}}async function yt(e,t){const r=await fetch(i(`${a}/set-identity`,e),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({profileId:t})});if(!r.ok){const o=await r.json().catch(()=>({error:r.statusText}));throw new Error(o.error||"Failed to set git identity")}return r.json()}async function vt(){const e=await fetch(i(`${a}/discover-credentials`,void 0));if(!e.ok)throw new Error(`Failed to discover git credentials: ${e.statusText}`);return e.json()}const mt=()=>({checkIsGitRepository:_,getGitStatus:W,getGitDiff:B,getGitFileDiff:U,revertGitFile:q,isLinkedWorktree:M,getGitBranches:H,deleteGitBranch:z,deleteRemoteBranch:V,generateCommitMessage:K,generatePullRequestDescription:Q,listGitWorktrees:X,addGitWorktree:Y,removeGitWorktree:Z,ensureOpenChamberIgnored:tt,createGitCommit(e,t,r){return et(e,t,r)},gitPush:rt,gitPull:ot,gitFetch:nt,checkoutBranch:st,createBranch:at,renameBranch:it,getGitLog(e,t){return ct(e,t)},getCommitFiles:lt,getCurrentGitIdentity:ft,hasLocalIdentity:wt,setGitIdentity:yt,getGitIdentities:dt,createGitIdentity:ut,updateGitIdentity:ht,deleteGitIdentity:pt}),h=e=>e.replace(/\\/g,"/"),gt=(e,t)=>{const r=h(t?.directory||t?.path||e),o=Array.isArray(t?.entries)?t.entries:[];return{directory:r,entries:o.filter(n=>!!(n&&typeof n.name=="string"&&typeof n.path=="string")).map(n=>({name:n.name,path:h(n.path),isDirectory:!!n.isDirectory}))}},Tt=()=>({async listDirectory(e){const t=h(e),r=new URLSearchParams;t&&r.set("path",t);const o=await fetch(`/api/fs/list${r.toString()?`?${r.toString()}`:""}`);if(!o.ok){const s=await o.json().catch(()=>({error:o.statusText}));throw new Error(s.error||"Failed to list directory")}const n=await o.json();return gt(t,n)},async search(e){const t=new URLSearchParams,r=h(e.directory);r&&t.set("directory",r),t.set("q",e.query),typeof e.maxResults=="number"&&Number.isFinite(e.maxResults)&&t.set("limit",String(e.maxResults)),e.includeHidden&&t.set("includeHidden","true");const o=await fetch(`/api/fs/search?${t.toString()}`);if(!o.ok){const c=await o.json().catch(()=>({error:o.statusText}));throw new Error(c.error||"Failed to search files")}const n=await o.json();return(Array.isArray(n?.files)?n.files:[]).filter(c=>!!(c&&typeof c.path=="string")).map(c=>({path:h(c.path),preview:typeof c.relativePath=="string"&&c.relativePath.length>0?[h(c.relativePath)]:void 0}))},async createDirectory(e){const t=h(e),r=await fetch("/api/fs/mkdir",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:t})});if(!r.ok){const n=await r.json().catch(()=>({error:r.statusText}));throw new Error(n.error||"Failed to create directory")}const o=await r.json();return{success:!!o?.success,path:typeof o?.path=="string"?h(o.path):t}},async readFile(e){const t=h(e),r=await fetch(`/api/fs/read?path=${encodeURIComponent(t)}`);if(!r.ok){const n=await r.json().catch(()=>({error:r.statusText}));throw new Error(n.error||"Failed to read file")}return{content:await r.text(),path:t}},async writeFile(e,t){const r=h(e),o=await fetch("/api/fs/write",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:r,content:t})});if(!o.ok){const s=await o.json().catch(()=>({error:o.statusText}));throw new Error(s.error||"Failed to write file")}const n=await o.json().catch(()=>({}));return{success:!!n.success,path:typeof n.path=="string"?h(n.path):r}},async delete(e){const t=h(e),r=await fetch("/api/fs/delete",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:t})});if(!r.ok){const n=await r.json().catch(()=>({error:r.statusText}));throw new Error(n.error||"Failed to delete file")}return{success:!!(await r.json().catch(()=>({}))).success}},async rename(e,t){const r=await fetch("/api/fs/rename",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({oldPath:e,newPath:t})});if(!r.ok){const n=await r.json().catch(()=>({error:r.statusText}));throw new Error(n.error||"Failed to rename file")}const o=await r.json().catch(()=>({}));return{success:!!o.success,path:typeof o.path=="string"?h(o.path):t}}}),F="/api/config/settings",bt="/api/config/reload",x=e=>!e||typeof e!="object"?{}:e,Et=()=>({async load(){const e=await fetch(F,{method:"GET",headers:{Accept:"application/json"}});if(!e.ok)throw new Error(`Failed to load settings: ${e.statusText}`);return{settings:x(await e.json().catch(()=>({}))),source:"web"}},async save(e){const t=await fetch(F,{method:"PUT",headers:{"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify(e)});if(!t.ok){const o=await t.json().catch(()=>({error:t.statusText}));throw new Error(o.error||"Failed to save settings")}return x(await t.json().catch(()=>({})))},async restartOpenCode(){const e=await fetch(bt,{method:"POST"});if(!e.ok){const t=await e.json().catch(()=>({error:e.statusText}));throw new Error(t.error||"Failed to restart OpenCode")}return{restarted:!0}}}),jt=()=>({async requestDirectoryAccess(e){return{success:!0,path:e.path}},async startAccessingDirectory(e){return{success:!0}},async stopAccessingDirectory(e){return{success:!0}}}),St=async e=>{if(typeof Notification>"u")return console.info("Notifications not supported in this environment",e),!1;if(Notification.permission==="default"&&await Notification.requestPermission()!=="granted"||Notification.permission!=="granted")return console.warn("Notification permission not granted"),!1;try{return new Notification(e?.title??"OpenChamber",{body:e?.body,tag:e?.tag}),!0}catch(t){return console.warn("Failed to send notification",t),!1}},kt=()=>({async notifyAgentCompletion(e){return St(e)},canNotify:()=>typeof Notification<"u"?Notification.permission==="granted":!1}),Ot=()=>({async getAvailableTools(){const e=await fetch("/api/experimental/tool/ids");if(!e.ok)throw new Error(`Tools API returned ${e.status} ${e.statusText}`);const t=await e.json();if(!Array.isArray(t))throw new Error("Tools API returned invalid data format");return t.filter(r=>typeof r=="string"&&r!=="invalid").sort()}}),E=async(e,t)=>{try{const r=await fetch(e,{...t,credentials:"include",headers:{Accept:"application/json",...t?.headers??{}}});return r.ok?await r.json():null}catch{return null}},Pt=()=>({async getVapidPublicKey(){return E("/api/push/vapid-public-key")},async subscribe(e){return E("/api/push/subscribe",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)})},async unsubscribe(e){return E("/api/push/subscribe",{method:"DELETE",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)})},async setVisibility(e){return E("/api/push/visibility",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e),keepalive:!0})}}),u=async e=>await e.json().catch(()=>null),Ft=()=>({async authStatus(){const e=await fetch("/api/github/auth/status",{method:"GET",headers:{Accept:"application/json"}}),t=await u(e);if(!e.ok||!t)throw new Error(t?.error||e.statusText||"Failed to load GitHub status");return t},async authStart(){const e=await fetch("/api/github/auth/start",{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify({})}),t=await u(e);if(!e.ok||!t||!("deviceCode"in t))throw new Error(t?.error||e.statusText||"Failed to start GitHub auth");return t},async authComplete(e){const t=await fetch("/api/github/auth/complete",{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify({deviceCode:e})}),r=await u(t);if(!t.ok||!r)throw new Error(r?.error||t.statusText||"Failed to complete GitHub auth");return r},async authDisconnect(){const e=await fetch("/api/github/auth",{method:"DELETE",headers:{Accept:"application/json"}}),t=await u(e);if(!e.ok)throw new Error(t?.error||e.statusText||"Failed to disconnect GitHub");return{removed:!!t?.removed}},async authActivate(e){const t=await fetch("/api/github/auth/activate",{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify({accountId:e})}),r=await u(t);if(!t.ok||!r)throw new Error(r?.error||t.statusText||"Failed to activate GitHub account");return r},async me(){const e=await fetch("/api/github/me",{method:"GET",headers:{Accept:"application/json"}}),t=await u(e);if(!e.ok||!t)throw new Error(t?.error||e.statusText||"Failed to fetch GitHub user");return t},async prStatus(e,t){const r=await fetch(`/api/github/pr/status?directory=${encodeURIComponent(e)}&branch=${encodeURIComponent(t)}`,{method:"GET",headers:{Accept:"application/json"}}),o=await u(r);if(!r.ok||!o)throw new Error(o?.error||r.statusText||"Failed to load PR status");return o},async prCreate(e){const t=await fetch("/api/github/pr/create",{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify(e)}),r=await u(t);if(!t.ok||!r)throw new Error(r?.error||t.statusText||"Failed to create PR");return r},async prMerge(e){const t=await fetch("/api/github/pr/merge",{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify(e)}),r=await u(t);if(!t.ok||!r)throw new Error(r?.error||t.statusText||"Failed to merge PR");return r},async prReady(e){const t=await fetch("/api/github/pr/ready",{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify(e)}),r=await u(t);if(!t.ok||!r)throw new Error(r?.error||t.statusText||"Failed to mark PR ready");return r},async prsList(e,t){const r=t?.page??1,o=await fetch(`/api/github/pulls/list?directory=${encodeURIComponent(e)}&page=${encodeURIComponent(String(r))}`,{method:"GET",headers:{Accept:"application/json"}}),n=await u(o);if(!o.ok||!n)throw new Error(n?.error||o.statusText||"Failed to load pull requests");return n},async prContext(e,t,r){const o=new URL("/api/github/pulls/context",window.location.origin);o.searchParams.set("directory",e),o.searchParams.set("number",String(t)),r?.includeDiff&&o.searchParams.set("diff","1"),r?.includeCheckDetails&&o.searchParams.set("checkDetails","1");const n=await fetch(o.toString(),{method:"GET",headers:{Accept:"application/json"}}),s=await u(n);if(!n.ok||!s)throw new Error(s?.error||n.statusText||"Failed to load pull request context");return s},async issuesList(e,t){const r=t?.page??1,o=await fetch(`/api/github/issues/list?directory=${encodeURIComponent(e)}&page=${encodeURIComponent(String(r))}`,{method:"GET",headers:{Accept:"application/json"}}),n=await u(o);if(!o.ok||!n)throw new Error(n?.error||o.statusText||"Failed to load issues");return n},async issueGet(e,t){const r=await fetch(`/api/github/issues/get?directory=${encodeURIComponent(e)}&number=${encodeURIComponent(String(t))}`,{method:"GET",headers:{Accept:"application/json"}}),o=await u(r);if(!r.ok||!o)throw new Error(o?.error||r.statusText||"Failed to load issue");return o},async issueComments(e,t){const r=await fetch(`/api/github/issues/comments?directory=${encodeURIComponent(e)}&number=${encodeURIComponent(String(t))}`,{method:"GET",headers:{Accept:"application/json"}}),o=await u(r);if(!r.ok||!o)throw new Error(o?.error||r.statusText||"Failed to load issue comments");return o}}),xt=()=>({runtime:{platform:"web",isDesktop:!1,isVSCode:!1,label:"web"},terminal:J(),git:mt(),files:Tt(),settings:Et(),permissions:jt(),notifications:kt(),github:Ft(),push:Pt(),tools:Ot()});function Ct(e={}){const{immediate:t=!1,onNeedRefresh:r,onOfflineReady:o,onRegistered:n,onRegisteredSW:s,onRegisterError:c}=e;let p,d;const f=async(l=!0)=>{await d};async function y(){if("serviceWorker"in navigator){if(p=await C(async()=>{const{Workbox:l}=await import("./vendor-.bun-Bui932eM.js").then(m=>m.di);return{Workbox:l}},__vite__mapDeps([0,1])).then(({Workbox:l})=>new l("/sw.js",{scope:"/",type:"classic"})).catch(l=>{c?.(l)}),!p)return;p.addEventListener("activated",l=>{(l.isUpdate||l.isExternal)&&window.location.reload()}),p.addEventListener("installed",l=>{l.isUpdate||o?.()}),p.register({immediate:t}).then(l=>{s?s("/sw.js",l):n?.(l)}).catch(l=>{c?.(l)})}}return d=y(),f}window.__OPENCHAMBER_RUNTIME_APIS__=xt();Ct({onRegistered(e){e&&setInterval(()=>{e.update()},3600*1e3)},onRegisterError(e){console.warn("[PWA] service worker registration failed:",e)}});C(()=>import("./main-C3SPutdi.js").then(e=>e.m),__vite__mapDeps([2,0,1,3]));export{V as a,pt as b,_ as c,z as d,ut as e,vt as f,W as g,Nt as h,dt as i,H as j,it as k,X as l,nt as m,Q as n,Z as r,ht as u};
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/vendor-.bun-Bui932eM.js","assets/vendor--Jn2c0Clh.css","assets/main-QfYtNqzD.js","assets/main-C1GggQif.css"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{_ as C}from"./vendor-.bun-Bui932eM.js";(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const n of document.querySelectorAll('link[rel="modulepreload"]'))o(n);new MutationObserver(n=>{for(const s of n)if(s.type==="childList")for(const c of s.addedNodes)c.tagName==="LINK"&&c.rel==="modulepreload"&&o(c)}).observe(document,{childList:!0,subtree:!0});function r(n){const s={};return n.integrity&&(s.integrity=n.integrity),n.referrerPolicy&&(s.referrerPolicy=n.referrerPolicy),n.crossOrigin==="use-credentials"?s.credentials="include":n.crossOrigin==="anonymous"?s.credentials="omit":s.credentials="same-origin",s}function o(n){if(n.ep)return;n.ep=!0;const s=r(n);fetch(n.href,s)}})();async function $(e){const t=await fetch("/api/terminal/create",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({cwd:e.cwd,cols:e.cols||80,rows:e.rows||24})});if(!t.ok){const r=await t.json().catch(()=>({error:"Failed to create terminal"}));throw new Error(r.error||"Failed to create terminal session")}return t.json()}function N(e,t,r,o={}){const{maxRetries:n=3,initialRetryDelay:s=1e3,maxRetryDelay:c=8e3,connectionTimeout:p=1e4}=o;let d=null,f=0,y=null,l=null,m=!1,b=!1,g=!1;const j=()=>{y&&(clearTimeout(y),y=null),l&&(clearTimeout(l),l=null)},S=()=>{m=!0,j(),d&&(d.close(),d=null)},k=()=>{if(!(m||g)){if(d&&d.readyState!==EventSource.CLOSED){console.warn("Attempted to create duplicate EventSource, skipping");return}b=!1,d=new EventSource(`/api/terminal/${e}/stream`),l=setTimeout(()=>{!b&&d?.readyState!==EventSource.OPEN&&(console.error("Terminal connection timeout"),d?.close(),O(new Error("Connection timeout"),!1))},p),d.onopen=()=>{b||(b=!0,f=0,j(),t({type:"connected"}))},d.onmessage=T=>{try{const w=JSON.parse(T.data);w.type==="exit"&&(g=!0,S()),t(w)}catch(w){console.error("Failed to parse terminal event:",w),r?.(w,!1)}},d.onerror=T=>{console.error("Terminal stream error:",T,"readyState:",d?.readyState),j();const w=g||d?.readyState===EventSource.CLOSED;d?.close(),d=null,g||O(new Error("Terminal stream connection error"),w)}}},O=(T,w)=>{if(!(m||g))if(f<n&&!w){f++;const P=Math.min(s*Math.pow(2,f-1),c);console.log(`Reconnecting to terminal stream (attempt ${f}/${n}) in ${P}ms`),t({type:"reconnecting",attempt:f,maxAttempts:n}),y=setTimeout(()=>{!m&&!g&&k()},P)}else console.error(`Terminal connection failed after ${f} attempts`),r?.(T,!0),S()};return k(),S}async function v(e,t){const r=await fetch(`/api/terminal/${e}/input`,{method:"POST",headers:{"Content-Type":"text/plain"},body:t});if(!r.ok){const o=await r.json().catch(()=>({error:"Failed to send input"}));throw new Error(o.error||"Failed to send terminal input")}}async function A(e,t,r){const o=await fetch(`/api/terminal/${e}/resize`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({cols:t,rows:r})});if(!o.ok){const n=await o.json().catch(()=>({error:"Failed to resize terminal"}));throw new Error(n.error||"Failed to resize terminal")}}async function G(e){const t=await fetch(`/api/terminal/${e}`,{method:"DELETE"});if(!t.ok){const r=await t.json().catch(()=>({error:"Failed to close terminal"}));throw new Error(r.error||"Failed to close terminal")}}async function I(e,t){const r=await fetch(`/api/terminal/${e}/restart`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({cwd:t.cwd,cols:t.cols??80,rows:t.rows??24})});if(!r.ok){const o=await r.json().catch(()=>({error:"Failed to restart terminal"}));throw new Error(o.error||"Failed to restart terminal")}return r.json()}async function R(e){const t=await fetch("/api/terminal/force-kill",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)});if(!t.ok){const r=await t.json().catch(()=>({error:"Failed to force kill terminal"}));throw new Error(r.error||"Failed to force kill terminal")}}const D=e=>{const t=e?.retry;return{maxRetries:t?.maxRetries??3,initialRetryDelay:t?.initialDelayMs??1e3,maxRetryDelay:t?.maxDelayMs??8e3,connectionTimeout:e?.connectionTimeoutMs??1e4}},J=()=>({async createSession(e){return $(e)},connect(e,t,r){const o=N(e,t.onEvent,t.onError,D(r));return{close:()=>o()}},async sendInput(e,t){await v(e,t)},async resize(e){await A(e.sessionId,e.cols,e.rows)},async close(e){await G(e)},async restartSession(e,t){return I(e,{cwd:t.cwd??"",cols:t.cols,rows:t.rows})},async forceKill(e){await R(e)}}),L=()=>{if(typeof window>"u")return"";const e=window.__OPENCHAMBER_DESKTOP_SERVER__?.origin;return e||window.location.origin},a="/api/git";function i(e,t,r){const o=new URL(e,L());if(t&&o.searchParams.set("directory",t),r)for(const[n,s]of Object.entries(r))s!==void 0&&o.searchParams.set(n,String(s));return o.toString()}async function _(e){const t=await fetch(i(`${a}/check`,e));if(!t.ok)throw new Error(`Failed to check git repository: ${t.statusText}`);return(await t.json()).isGitRepository}async function W(e){const t=await fetch(i(`${a}/status`,e));if(!t.ok)throw new Error(`Failed to get git status: ${t.statusText}`);return t.json()}async function B(e,t){const{path:r,staged:o,contextLines:n}=t;if(!r)throw new Error("path is required to fetch git diff");const s=await fetch(i(`${a}/diff`,e,{path:r,staged:o?"true":void 0,context:n}));if(!s.ok)throw new Error(`Failed to get git diff: ${s.statusText}`);return s.json()}async function U(e,t){const{path:r,staged:o}=t;if(!r)throw new Error("path is required to fetch git file diff");const n=await fetch(i(`${a}/file-diff`,e,{path:r,staged:o?"true":void 0}));if(!n.ok)throw new Error(`Failed to get git file diff: ${n.statusText}`);return n.json()}async function q(e,t){if(!t)throw new Error("path is required to revert git changes");const r=await fetch(i(`${a}/revert`,e),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:t})});if(!r.ok){const o=await r.json().catch(()=>({error:r.statusText}));throw new Error(o.error||"Failed to revert git changes")}}async function M(e){if(!e)return!1;const t=await fetch(i(`${a}/worktree-type`,e));if(!t.ok)throw new Error(`Failed to detect worktree type: ${t.statusText}`);return!!(await t.json()).linked}async function H(e){const t=await fetch(i(`${a}/branches`,e));if(!t.ok)throw new Error(`Failed to get branches: ${t.statusText}`);return t.json()}async function z(e,t){if(!t?.branch)throw new Error("branch is required to delete a branch");const r=await fetch(i(`${a}/branches`,e),{method:"DELETE",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)});if(!r.ok){const o=await r.json().catch(()=>({error:r.statusText}));throw new Error(o.error||"Failed to delete branch")}return r.json()}async function V(e,t){if(!t?.branch)throw new Error("branch is required to delete remote branch");const r=await fetch(i(`${a}/remote-branches`,e),{method:"DELETE",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)});if(!r.ok){const o=await r.json().catch(()=>({error:r.statusText}));throw new Error(o.error||"Failed to delete remote branch")}return r.json()}async function K(e,t){if(!Array.isArray(t)||t.length===0)throw new Error("No files provided to generate commit message");const r=await fetch(i(`${a}/commit-message`,e),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({files:t})});if(!r.ok){const c=await r.json().catch(()=>({error:r.statusText}));throw new Error(c.error||"Failed to generate commit message")}const o=await r.json();if(!o?.message||typeof o.message!="object")throw new Error("Malformed commit generation response");const n=typeof o.message.subject=="string"&&o.message.subject.trim().length>0?o.message.subject.trim():"",s=Array.isArray(o.message.highlights)?o.message.highlights.filter(c=>typeof c=="string"&&c.trim().length>0).map(c=>c.trim()):[];return{message:{subject:n,highlights:s}}}async function Q(e,t){const{base:r,head:o}=t;if(!r||!o)throw new Error("base and head are required");const n=await fetch(i(`${a}/pr-description`,e),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({base:r,head:o})});if(!n.ok){const d=await n.json().catch(()=>({error:n.statusText}));throw new Error(d.error||"Failed to generate PR description")}const s=await n.json().catch(()=>null),c=typeof s?.title=="string"?s.title:"",p=typeof s?.body=="string"?s.body:"";if(!c&&!p)throw new Error("Malformed PR description response");return{title:c,body:p}}async function X(e){const t=await fetch(i(`${a}/worktrees`,e));if(!t.ok){const r=await t.json().catch(()=>({error:t.statusText}));throw new Error(r.error||"Failed to list worktrees")}return t.json()}async function Y(e,t){if(!t?.path||!t?.branch)throw new Error("path and branch are required to add a worktree");const r=await fetch(i(`${a}/worktrees`,e),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)});if(!r.ok){const o=await r.json().catch(()=>({error:r.statusText}));throw new Error(o.error||"Failed to add worktree")}return r.json()}async function Z(e,t){if(!t?.path)throw new Error("path is required to remove a worktree");const r=await fetch(i(`${a}/worktrees`,e),{method:"DELETE",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)});if(!r.ok){const o=await r.json().catch(()=>({error:r.statusText}));throw new Error(o.error||"Failed to remove worktree")}return r.json()}async function tt(e){const t=await fetch(i(`${a}/ignore-openchamber`,e),{method:"POST"});if(!t.ok){const r=await t.json().catch(()=>({error:t.statusText}));throw new Error(r.error||"Failed to update git ignore")}}async function et(e,t,r={}){const o=await fetch(i(`${a}/commit`,e),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({message:t,addAll:r.addAll??!1,files:r.files})});if(!o.ok){const n=await o.json().catch(()=>({error:o.statusText}));throw new Error(n.error||"Failed to create commit")}return o.json()}async function rt(e,t={}){const r=await fetch(i(`${a}/push`,e),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)});if(!r.ok){const o=await r.json().catch(()=>({error:r.statusText}));throw new Error(o.error||"Failed to push")}return r.json()}async function ot(e,t={}){const r=await fetch(i(`${a}/pull`,e),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)});if(!r.ok){const o=await r.json().catch(()=>({error:r.statusText}));throw new Error(o.error||"Failed to pull")}return r.json()}async function nt(e,t={}){const r=await fetch(i(`${a}/fetch`,e),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)});if(!r.ok){const o=await r.json().catch(()=>({error:r.statusText}));throw new Error(o.error||"Failed to fetch")}return r.json()}async function st(e,t){const r=await fetch(i(`${a}/checkout`,e),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({branch:t})});if(!r.ok){const o=await r.json().catch(()=>({error:r.statusText}));throw new Error(o.error||"Failed to checkout branch")}return r.json()}async function at(e,t,r){const o=await fetch(i(`${a}/branches`,e),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:t,startPoint:r})});if(!o.ok){const n=await o.json().catch(()=>({error:o.statusText}));throw new Error(n.error||"Failed to create branch")}return o.json()}async function it(e,t,r){const o=await fetch(i(`${a}/branches/rename`,e),{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({oldName:t,newName:r})});if(!o.ok){const n=await o.json().catch(()=>({error:o.statusText}));throw new Error(n.error||"Failed to rename branch")}return o.json()}async function ct(e,t={}){const r=await fetch(i(`${a}/log`,e,{maxCount:t.maxCount,from:t.from,to:t.to,file:t.file}));if(!r.ok)throw new Error(`Failed to get git log: ${r.statusText}`);return r.json()}async function lt(e,t){const r=await fetch(i(`${a}/commit-files`,e,{hash:t}));if(!r.ok)throw new Error(`Failed to get commit files: ${r.statusText}`);return r.json()}async function dt(){const e=await fetch(i(`${a}/identities`,void 0));if(!e.ok)throw new Error(`Failed to get git identities: ${e.statusText}`);return e.json()}async function ut(e){const t=await fetch(i(`${a}/identities`,void 0),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)});if(!t.ok){const r=await t.json().catch(()=>({error:t.statusText}));throw new Error(r.error||"Failed to create git identity")}return t.json()}async function ht(e,t){const r=await fetch(i(`${a}/identities/${e}`,void 0),{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)});if(!r.ok){const o=await r.json().catch(()=>({error:r.statusText}));throw new Error(o.error||"Failed to update git identity")}return r.json()}async function pt(e){const t=await fetch(i(`${a}/identities/${e}`,void 0),{method:"DELETE"});if(!t.ok){const r=await t.json().catch(()=>({error:t.statusText}));throw new Error(r.error||"Failed to delete git identity")}}async function ft(e){if(!e)return null;const t=await fetch(i(`${a}/current-identity`,e));if(!t.ok)throw new Error(`Failed to get current git identity: ${t.statusText}`);const r=await t.json();return r?{userName:r.userName??null,userEmail:r.userEmail??null,sshCommand:r.sshCommand??null}:null}async function wt(e){if(!e)return!1;const t=await fetch(i(`${a}/has-local-identity`,e));if(!t.ok)throw new Error(`Failed to check local identity: ${t.statusText}`);return(await t.json().catch(()=>null))?.hasLocalIdentity===!0}async function Nt(){const e=await fetch(i(`${a}/global-identity`,void 0));if(!e.ok)throw new Error(`Failed to get global git identity: ${e.statusText}`);const t=await e.json();return!t||!t.userName&&!t.userEmail?null:{userName:t.userName??null,userEmail:t.userEmail??null,sshCommand:t.sshCommand??null}}async function yt(e,t){const r=await fetch(i(`${a}/set-identity`,e),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({profileId:t})});if(!r.ok){const o=await r.json().catch(()=>({error:r.statusText}));throw new Error(o.error||"Failed to set git identity")}return r.json()}async function vt(){const e=await fetch(i(`${a}/discover-credentials`,void 0));if(!e.ok)throw new Error(`Failed to discover git credentials: ${e.statusText}`);return e.json()}const mt=()=>({checkIsGitRepository:_,getGitStatus:W,getGitDiff:B,getGitFileDiff:U,revertGitFile:q,isLinkedWorktree:M,getGitBranches:H,deleteGitBranch:z,deleteRemoteBranch:V,generateCommitMessage:K,generatePullRequestDescription:Q,listGitWorktrees:X,addGitWorktree:Y,removeGitWorktree:Z,ensureOpenChamberIgnored:tt,createGitCommit(e,t,r){return et(e,t,r)},gitPush:rt,gitPull:ot,gitFetch:nt,checkoutBranch:st,createBranch:at,renameBranch:it,getGitLog(e,t){return ct(e,t)},getCommitFiles:lt,getCurrentGitIdentity:ft,hasLocalIdentity:wt,setGitIdentity:yt,getGitIdentities:dt,createGitIdentity:ut,updateGitIdentity:ht,deleteGitIdentity:pt}),h=e=>e.replace(/\\/g,"/"),gt=(e,t)=>{const r=h(t?.directory||t?.path||e),o=Array.isArray(t?.entries)?t.entries:[];return{directory:r,entries:o.filter(n=>!!(n&&typeof n.name=="string"&&typeof n.path=="string")).map(n=>({name:n.name,path:h(n.path),isDirectory:!!n.isDirectory}))}},Tt=()=>({async listDirectory(e){const t=h(e),r=new URLSearchParams;t&&r.set("path",t);const o=await fetch(`/api/fs/list${r.toString()?`?${r.toString()}`:""}`);if(!o.ok){const s=await o.json().catch(()=>({error:o.statusText}));throw new Error(s.error||"Failed to list directory")}const n=await o.json();return gt(t,n)},async search(e){const t=new URLSearchParams,r=h(e.directory);r&&t.set("directory",r),t.set("q",e.query),typeof e.maxResults=="number"&&Number.isFinite(e.maxResults)&&t.set("limit",String(e.maxResults)),e.includeHidden&&t.set("includeHidden","true");const o=await fetch(`/api/fs/search?${t.toString()}`);if(!o.ok){const c=await o.json().catch(()=>({error:o.statusText}));throw new Error(c.error||"Failed to search files")}const n=await o.json();return(Array.isArray(n?.files)?n.files:[]).filter(c=>!!(c&&typeof c.path=="string")).map(c=>({path:h(c.path),preview:typeof c.relativePath=="string"&&c.relativePath.length>0?[h(c.relativePath)]:void 0}))},async createDirectory(e){const t=h(e),r=await fetch("/api/fs/mkdir",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:t})});if(!r.ok){const n=await r.json().catch(()=>({error:r.statusText}));throw new Error(n.error||"Failed to create directory")}const o=await r.json();return{success:!!o?.success,path:typeof o?.path=="string"?h(o.path):t}},async readFile(e){const t=h(e),r=await fetch(`/api/fs/read?path=${encodeURIComponent(t)}`);if(!r.ok){const n=await r.json().catch(()=>({error:r.statusText}));throw new Error(n.error||"Failed to read file")}return{content:await r.text(),path:t}},async writeFile(e,t){const r=h(e),o=await fetch("/api/fs/write",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:r,content:t})});if(!o.ok){const s=await o.json().catch(()=>({error:o.statusText}));throw new Error(s.error||"Failed to write file")}const n=await o.json().catch(()=>({}));return{success:!!n.success,path:typeof n.path=="string"?h(n.path):r}},async delete(e){const t=h(e),r=await fetch("/api/fs/delete",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:t})});if(!r.ok){const n=await r.json().catch(()=>({error:r.statusText}));throw new Error(n.error||"Failed to delete file")}return{success:!!(await r.json().catch(()=>({}))).success}},async rename(e,t){const r=await fetch("/api/fs/rename",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({oldPath:e,newPath:t})});if(!r.ok){const n=await r.json().catch(()=>({error:r.statusText}));throw new Error(n.error||"Failed to rename file")}const o=await r.json().catch(()=>({}));return{success:!!o.success,path:typeof o.path=="string"?h(o.path):t}}}),F="/api/config/settings",bt="/api/config/reload",x=e=>!e||typeof e!="object"?{}:e,Et=()=>({async load(){const e=await fetch(F,{method:"GET",headers:{Accept:"application/json"}});if(!e.ok)throw new Error(`Failed to load settings: ${e.statusText}`);return{settings:x(await e.json().catch(()=>({}))),source:"web"}},async save(e){const t=await fetch(F,{method:"PUT",headers:{"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify(e)});if(!t.ok){const o=await t.json().catch(()=>({error:t.statusText}));throw new Error(o.error||"Failed to save settings")}return x(await t.json().catch(()=>({})))},async restartOpenCode(){const e=await fetch(bt,{method:"POST"});if(!e.ok){const t=await e.json().catch(()=>({error:e.statusText}));throw new Error(t.error||"Failed to restart OpenCode")}return{restarted:!0}}}),jt=()=>({async requestDirectoryAccess(e){return{success:!0,path:e.path}},async startAccessingDirectory(e){return{success:!0}},async stopAccessingDirectory(e){return{success:!0}}}),St=async e=>{if(typeof Notification>"u")return console.info("Notifications not supported in this environment",e),!1;if(Notification.permission==="default"&&await Notification.requestPermission()!=="granted"||Notification.permission!=="granted")return console.warn("Notification permission not granted"),!1;try{return new Notification(e?.title??"OpenChamber",{body:e?.body,tag:e?.tag}),!0}catch(t){return console.warn("Failed to send notification",t),!1}},kt=()=>({async notifyAgentCompletion(e){return St(e)},canNotify:()=>typeof Notification<"u"?Notification.permission==="granted":!1}),Ot=()=>({async getAvailableTools(){const e=await fetch("/api/experimental/tool/ids");if(!e.ok)throw new Error(`Tools API returned ${e.status} ${e.statusText}`);const t=await e.json();if(!Array.isArray(t))throw new Error("Tools API returned invalid data format");return t.filter(r=>typeof r=="string"&&r!=="invalid").sort()}}),E=async(e,t)=>{try{const r=await fetch(e,{...t,credentials:"include",headers:{Accept:"application/json",...t?.headers??{}}});return r.ok?await r.json():null}catch{return null}},Pt=()=>({async getVapidPublicKey(){return E("/api/push/vapid-public-key")},async subscribe(e){return E("/api/push/subscribe",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)})},async unsubscribe(e){return E("/api/push/subscribe",{method:"DELETE",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)})},async setVisibility(e){return E("/api/push/visibility",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e),keepalive:!0})}}),u=async e=>await e.json().catch(()=>null),Ft=()=>({async authStatus(){const e=await fetch("/api/github/auth/status",{method:"GET",headers:{Accept:"application/json"}}),t=await u(e);if(!e.ok||!t)throw new Error(t?.error||e.statusText||"Failed to load GitHub status");return t},async authStart(){const e=await fetch("/api/github/auth/start",{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify({})}),t=await u(e);if(!e.ok||!t||!("deviceCode"in t))throw new Error(t?.error||e.statusText||"Failed to start GitHub auth");return t},async authComplete(e){const t=await fetch("/api/github/auth/complete",{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify({deviceCode:e})}),r=await u(t);if(!t.ok||!r)throw new Error(r?.error||t.statusText||"Failed to complete GitHub auth");return r},async authDisconnect(){const e=await fetch("/api/github/auth",{method:"DELETE",headers:{Accept:"application/json"}}),t=await u(e);if(!e.ok)throw new Error(t?.error||e.statusText||"Failed to disconnect GitHub");return{removed:!!t?.removed}},async authActivate(e){const t=await fetch("/api/github/auth/activate",{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify({accountId:e})}),r=await u(t);if(!t.ok||!r)throw new Error(r?.error||t.statusText||"Failed to activate GitHub account");return r},async me(){const e=await fetch("/api/github/me",{method:"GET",headers:{Accept:"application/json"}}),t=await u(e);if(!e.ok||!t)throw new Error(t?.error||e.statusText||"Failed to fetch GitHub user");return t},async prStatus(e,t){const r=await fetch(`/api/github/pr/status?directory=${encodeURIComponent(e)}&branch=${encodeURIComponent(t)}`,{method:"GET",headers:{Accept:"application/json"}}),o=await u(r);if(!r.ok||!o)throw new Error(o?.error||r.statusText||"Failed to load PR status");return o},async prCreate(e){const t=await fetch("/api/github/pr/create",{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify(e)}),r=await u(t);if(!t.ok||!r)throw new Error(r?.error||t.statusText||"Failed to create PR");return r},async prMerge(e){const t=await fetch("/api/github/pr/merge",{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify(e)}),r=await u(t);if(!t.ok||!r)throw new Error(r?.error||t.statusText||"Failed to merge PR");return r},async prReady(e){const t=await fetch("/api/github/pr/ready",{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify(e)}),r=await u(t);if(!t.ok||!r)throw new Error(r?.error||t.statusText||"Failed to mark PR ready");return r},async prsList(e,t){const r=t?.page??1,o=await fetch(`/api/github/pulls/list?directory=${encodeURIComponent(e)}&page=${encodeURIComponent(String(r))}`,{method:"GET",headers:{Accept:"application/json"}}),n=await u(o);if(!o.ok||!n)throw new Error(n?.error||o.statusText||"Failed to load pull requests");return n},async prContext(e,t,r){const o=new URL("/api/github/pulls/context",window.location.origin);o.searchParams.set("directory",e),o.searchParams.set("number",String(t)),r?.includeDiff&&o.searchParams.set("diff","1"),r?.includeCheckDetails&&o.searchParams.set("checkDetails","1");const n=await fetch(o.toString(),{method:"GET",headers:{Accept:"application/json"}}),s=await u(n);if(!n.ok||!s)throw new Error(s?.error||n.statusText||"Failed to load pull request context");return s},async issuesList(e,t){const r=t?.page??1,o=await fetch(`/api/github/issues/list?directory=${encodeURIComponent(e)}&page=${encodeURIComponent(String(r))}`,{method:"GET",headers:{Accept:"application/json"}}),n=await u(o);if(!o.ok||!n)throw new Error(n?.error||o.statusText||"Failed to load issues");return n},async issueGet(e,t){const r=await fetch(`/api/github/issues/get?directory=${encodeURIComponent(e)}&number=${encodeURIComponent(String(t))}`,{method:"GET",headers:{Accept:"application/json"}}),o=await u(r);if(!r.ok||!o)throw new Error(o?.error||r.statusText||"Failed to load issue");return o},async issueComments(e,t){const r=await fetch(`/api/github/issues/comments?directory=${encodeURIComponent(e)}&number=${encodeURIComponent(String(t))}`,{method:"GET",headers:{Accept:"application/json"}}),o=await u(r);if(!r.ok||!o)throw new Error(o?.error||r.statusText||"Failed to load issue comments");return o}}),xt=()=>({runtime:{platform:"web",isDesktop:!1,isVSCode:!1,label:"web"},terminal:J(),git:mt(),files:Tt(),settings:Et(),permissions:jt(),notifications:kt(),github:Ft(),push:Pt(),tools:Ot()});function Ct(e={}){const{immediate:t=!1,onNeedRefresh:r,onOfflineReady:o,onRegistered:n,onRegisteredSW:s,onRegisterError:c}=e;let p,d;const f=async(l=!0)=>{await d};async function y(){if("serviceWorker"in navigator){if(p=await C(async()=>{const{Workbox:l}=await import("./vendor-.bun-Bui932eM.js").then(m=>m.di);return{Workbox:l}},__vite__mapDeps([0,1])).then(({Workbox:l})=>new l("/sw.js",{scope:"/",type:"classic"})).catch(l=>{c?.(l)}),!p)return;p.addEventListener("activated",l=>{(l.isUpdate||l.isExternal)&&window.location.reload()}),p.addEventListener("installed",l=>{l.isUpdate||o?.()}),p.register({immediate:t}).then(l=>{s?s("/sw.js",l):n?.(l)}).catch(l=>{c?.(l)})}}return d=y(),f}window.__OPENCHAMBER_RUNTIME_APIS__=xt();Ct({onRegistered(e){e&&setInterval(()=>{e.update()},3600*1e3)},onRegisterError(e){console.warn("[PWA] service worker registration failed:",e)}});C(()=>import("./main-QfYtNqzD.js").then(e=>e.m),__vite__mapDeps([2,0,1,3]));export{V as a,pt as b,_ as c,z as d,ut as e,vt as f,W as g,Nt as h,dt as i,H as j,it as k,X as l,nt as m,Q as n,Z as r,ht as u};
|