repoburg 1.3.229 → 1.3.233

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.
@@ -90,6 +90,7 @@ async function loadAgentPane(opts = {}) {
90
90
  });
91
91
  },
92
92
  shutdown: mod.shutdownAllProviders,
93
+ handleVscodeUpgrade: mod.handleVscodeWebUpgrade,
93
94
  close: () => fastify.close(),
94
95
  };
95
96
  }
@@ -118,6 +119,14 @@ function createUpgradeRouter(pane, daemonWss, guard) {
118
119
  socket.write('HTTP/1.1 403 Forbidden\r\n\r\n');
119
120
  socket.destroy();
120
121
  };
122
+ if (pane && url.startsWith('/vscode')) {
123
+ if (pane.handleVscodeUpgrade) {
124
+ pane.handleVscodeUpgrade(req, socket, head);
125
+ return;
126
+ }
127
+ reject();
128
+ return;
129
+ }
121
130
  if (pane && url.startsWith('/ws')) {
122
131
  if (!guard) {
123
132
  guardedUpgrade();
@@ -140,6 +140,28 @@ describe('createUpgradeRouter', () => {
140
140
  route({ url: '/ws' }, {}, Buffer.alloc(0));
141
141
  expect(daemonWss.handleUpgrade).toHaveBeenCalled();
142
142
  });
143
+ it('sends /vscode upgrades to the embedded pane proxy', () => {
144
+ const pane = {
145
+ handleWsUpgrade: jest.fn(),
146
+ handleVscodeUpgrade: jest.fn(),
147
+ };
148
+ const daemonWss = { handleUpgrade: jest.fn(), emit: jest.fn() };
149
+ const route = (0, agentPane_1.createUpgradeRouter)(pane, daemonWss);
150
+ route({ url: '/vscode/stable-hash/' }, {}, Buffer.alloc(0));
151
+ expect(pane.handleVscodeUpgrade).toHaveBeenCalled();
152
+ expect(pane.handleWsUpgrade).not.toHaveBeenCalled();
153
+ expect(daemonWss.handleUpgrade).not.toHaveBeenCalled();
154
+ });
155
+ it('destroys /vscode upgrades when the pane bundle has no proxy handler', () => {
156
+ const pane = { handleWsUpgrade: jest.fn() };
157
+ const daemonWss = { handleUpgrade: jest.fn(), emit: jest.fn() };
158
+ const route = (0, agentPane_1.createUpgradeRouter)(pane, daemonWss);
159
+ const socket = { write: jest.fn(), destroy: jest.fn() };
160
+ route({ url: '/vscode/' }, socket, Buffer.alloc(0));
161
+ expect(socket.write).toHaveBeenCalledWith(expect.stringContaining('403'));
162
+ expect(socket.destroy).toHaveBeenCalled();
163
+ expect(daemonWss.handleUpgrade).not.toHaveBeenCalled();
164
+ });
143
165
  });
144
166
  describe('loadAgentPane', () => {
145
167
  it('returns null when disabled via the kill-switch', async () => {
@@ -46,6 +46,11 @@ async function main() {
46
46
  // Embedded agent-pane API. MUST precede express.json() — Fastify parses its
47
47
  // own request bodies; the stream can only be consumed once.
48
48
  app.all('/api/*', (0, agentPane_1.createPaneDelegate)(pane));
49
+ // Same-origin VS Code web proxy (/vscode/* in the embedded app). Route-style
50
+ // mount (not app.use) keeps req.url intact — serve-web serves under the
51
+ // /vscode base path. Unauthenticated by design: the connection token is the
52
+ // secret (see createUpgradeRouter). Must also precede express.json().
53
+ app.all(['/vscode', '/vscode/*'], (0, agentPane_1.createPaneDelegate)(pane));
49
54
  app.use(express_1.default.json());
50
55
  // Tunnel lifecycle API — local-only; the CF ingress edge blocks /remote/*
51
56
  // for tunnel traffic (see account-server CloudflareService.setIngress).
@@ -39,10 +39,13 @@ function validateSid(sid) {
39
39
  }
40
40
  return sid;
41
41
  }
42
- /** Validate a batch body: an array of flat event objects with known types. */
42
+ /** Validate a batch body: a non-empty array of flat event objects with known
43
+ * types. Empty batches are rejected — probes/healthchecks must not create
44
+ * empty session files in the data directory. */
43
45
  function validateEvents(events) {
44
- if (!Array.isArray(events))
45
- throw new Error('events must be an array');
46
+ if (!Array.isArray(events) || events.length === 0) {
47
+ throw new Error('events must be a non-empty array');
48
+ }
46
49
  for (const ev of events) {
47
50
  if (typeof ev !== 'object' || ev === null)
48
51
  throw new Error('event must be an object');
@@ -30,6 +30,8 @@ describe('collector', () => {
30
30
  expect(() => (0, collector_1.validateEvents)('nope')).toThrow();
31
31
  expect(() => (0, collector_1.validateEvents)([{ type: 'bogus' }])).toThrow();
32
32
  expect(() => (0, collector_1.validateEvents)([null])).toThrow();
33
+ // Empty batches would create empty session files (healthcheck noise).
34
+ expect(() => (0, collector_1.validateEvents)([])).toThrow();
33
35
  });
34
36
  it('appends events as JSONL lines in order', () => {
35
37
  const events = [
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "repoburg",
3
- "version": "1.3.229",
3
+ "version": "1.3.233",
4
4
  "description": "A local AI-powered software developer assistant that runs on your own machine.",
5
5
  "author": "Celal Ertug",
6
6
  "license": "SEE LICENSE IN LICENSE",
@@ -1 +1 @@
1
- "use strict";(()=>{function l(t,r){return(e,o={})=>{let i={ts:Date.now(),t:Date.now()-t.t0,sid:t.sid,type:e,...o};try{r.push(i)}catch{}}}function S(t){if(!(t instanceof Element))return"";if(t.id)return`#${t.id}`;let r=t.tagName.toLowerCase(),e=t.classList.length?"."+Array.from(t.classList).slice(0,2).join("."):"";return r+e}function f(t){let r=e=>{t("click",{target:S(e.target)})};return document.addEventListener("click",r,!0),()=>document.removeEventListener("click",r,!0)}function m(t,r=500){let e=0,o=null,i=new MutationObserver(n=>{e+=n.length,o===null&&(o=setTimeout(()=>{o=null;let c=e;e=0,c>0&&t("dom_update",{count:c})},r))});try{i.observe(document.documentElement,{childList:!0,subtree:!0})}catch{}return()=>{o!==null&&clearTimeout(o),i.disconnect()}}function h(t){let r=o=>{t("error",{message:o.message})},e=o=>{t("error",{message:String(o.reason?.message??o.reason)})};return window.addEventListener("error",r),window.addEventListener("unhandledrejection",e),()=>{window.removeEventListener("error",r),window.removeEventListener("unhandledrejection",e)}}var T=0,v=()=>`r${++T}`,y=t=>t.includes("/recorder/events");function I(t){return typeof t=="string"?t:t instanceof URL?t.href:t.url}function E(t){let r=[],e=window.fetch.bind(window);window.fetch=(n,c)=>{let a=I(n);if(y(a))return e(n,c);let s=(c?.method??"GET").toUpperCase(),u=v(),d=Date.now();return t("request_start",{reqId:u,method:s,url:a}),e(n,c).then(p=>(t("request_end",{reqId:u,method:s,url:a,status:p.status,dur:Date.now()-d}),p),p=>{throw t("request_fail",{reqId:u,method:s,url:a,message:String(p?.message??p),dur:Date.now()-d}),p})},r.push(()=>{window.fetch=e});let o=XMLHttpRequest.prototype.open,i=XMLHttpRequest.prototype.send;return XMLHttpRequest.prototype.open=function(n,c,...a){return this.__recMethod=String(n).toUpperCase(),this.__recUrl=String(c),o.apply(this,[n,c,...a])},XMLHttpRequest.prototype.send=function(...n){if(y(this.__recUrl??""))return i.apply(this,n);let c=v(),a=this.__recMethod??"GET",s=this.__recUrl??"",u=Date.now();return t("request_start",{reqId:c,method:a,url:s}),this.addEventListener("loadend",()=>{let d=Date.now()-u;this.status===0||this.status>=400?t("request_fail",{reqId:c,method:a,url:s,status:this.status,dur:d}):t("request_end",{reqId:c,method:a,url:s,status:this.status,dur:d})}),i.apply(this,n)},r.push(()=>{XMLHttpRequest.prototype.open=o,XMLHttpRequest.prototype.send=i}),()=>r.forEach(n=>n())}function g(t){let r=[],e=(i,n,c)=>{try{let a=new PerformanceObserver(s=>{for(let u of s.getEntries())n(u)});a.observe({type:i,buffered:!0,...c}),r.push(a)}catch{}};e("longtask",i=>t("long_task",{dur:Math.round(i.duration)})),e("largest-contentful-paint",i=>t("lcp",{value:Math.round(i.startTime)}));let o=new Set;return e("event",i=>{let n=i;n.duration<50||!n.interactionId||o.has(n.interactionId)||(o.size>=1e3&&o.clear(),o.add(n.interactionId),t("inp",{value:Math.round(n.duration)}))},{durationThreshold:16}),e("layout-shift",i=>{let n=i;n.hadRecentInput||t("cls",{value:Math.round(n.value*1e3)/1e3})}),()=>r.forEach(i=>{try{i.disconnect()}catch{}})}function w(t){let r=()=>t("route_change",{route:location.pathname}),e=history.pushState.bind(history),o=history.replaceState.bind(history),i=(...a)=>{let s=e(...a);return r(),s},n=(...a)=>{let s=o(...a);return r(),s};history.pushState=i,history.replaceState=n;let c=()=>r();return window.addEventListener("popstate",c),()=>{history.pushState=e,history.replaceState=o,window.removeEventListener("popstate",c)}}function R(t,r=1e3){let e=0,o=null,i=()=>{e=Date.now(),t("scroll",{y:Math.round(window.scrollY)})},n=()=>{if(Date.now()-e<r){o===null&&(o=setTimeout(()=>{o=null,i()},r));return}i()};return window.addEventListener("scroll",n,{passive:!0}),()=>{o!==null&&clearTimeout(o),window.removeEventListener("scroll",n)}}function q(){try{return crypto.randomUUID().replace(/-/g,"").slice(0,12)}catch{return Array.from({length:12},()=>Math.floor(Math.random()*36).toString(36)).join("")}}function b(){return{sid:q(),t0:Date.now()}}var _="/recorder/events";function L(t,r={}){let e=r.fetch??((...s)=>fetch(...s)),o=r.sendBeacon??((s,u)=>{try{return navigator.sendBeacon(s,u)}catch{return!1}}),i=r.onUnload??(s=>{document.addEventListener("pagehide",s),document.addEventListener("visibilitychange",()=>{document.visibilityState==="hidden"&&s()})}),n=[],c=(s,u)=>{if(s.length===0)return;let d=JSON.stringify({sid:t,events:s});try{if(u&&o(_,d))return;e(_,{method:"POST",headers:{"content-type":"application/json"},body:d,keepalive:!0}).catch(()=>{})}catch{}},a={push(s){n.push(s),n.length>=100&&a.flush()},flush(s=!1){let u=n;n=[],c(u,s)}};return(r.setInterval??((s,u)=>setInterval(s,u)))(()=>a.flush(),2e3),i(()=>a.flush(!0)),a}(function(){let r=window;if(!r.__repoburgRecorder){r.__repoburgRecorder=!0;try{M()}catch{}}})();function M(){let t=b(),r=L(t.sid),e=l(t,r);e("session_start",{route:location.pathname}),w(e),f(e),R(e),m(e),E(e),h(e),g(e),document.addEventListener("pagehide",()=>{e("session_end"),r.flush(!0)})}})();
1
+ "use strict";(()=>{function v(t,r){return(e,o={})=>{let i={ts:Date.now(),t:Date.now()-t.t0,sid:t.sid,type:e,...o};try{r.push(i)}catch{}}}function k(t){if(!(t instanceof Element))return"";if(t.id)return`#${t.id}`;let r=t.tagName.toLowerCase(),e=t.classList.length?"."+Array.from(t.classList).slice(0,2).join("."):"";return r+e}function y(t){let r=e=>{t("click",{target:k(e.target)})};return document.addEventListener("click",r,!0),()=>document.removeEventListener("click",r,!0)}function g(t,r=500){let e=0,o=null,i=new MutationObserver(n=>{e+=n.length,o===null&&(o=setTimeout(()=>{o=null;let s=e;e=0,s>0&&t("dom_update",{count:s})},r))});try{i.observe(document.documentElement,{childList:!0,subtree:!0})}catch{}return()=>{o!==null&&clearTimeout(o),i.disconnect()}}function E(t){let r=o=>{t("error",{message:o.message})},e=o=>{t("error",{message:String(o.reason?.message??o.reason)})};return window.addEventListener("error",r),window.addEventListener("unhandledrejection",e),()=>{window.removeEventListener("error",r),window.removeEventListener("unhandledrejection",e)}}var U=0,w=()=>`r${++U}`,R=t=>t.includes("/recorder/events");function x(t){return typeof t=="string"?t:t instanceof URL?t.href:t.url}function _(t){let r=[],e=window.fetch.bind(window);window.fetch=(n,s)=>{let c=x(n);if(R(c))return e(n,s);let u=(s?.method??"GET").toUpperCase(),f=w(),l=Date.now();return t("request_start",{reqId:f,method:u,url:c}),e(n,s).then(d=>(t("request_end",{reqId:f,method:u,url:c,status:d.status,dur:Date.now()-l}),d),d=>{throw t("request_fail",{reqId:f,method:u,url:c,message:String(d?.message??d),dur:Date.now()-l}),d})},r.push(()=>{window.fetch=e});let o=XMLHttpRequest.prototype.open,i=XMLHttpRequest.prototype.send;return XMLHttpRequest.prototype.open=function(n,s,...c){return this.__recMethod=String(n).toUpperCase(),this.__recUrl=String(s),o.apply(this,[n,s,...c])},XMLHttpRequest.prototype.send=function(...n){if(R(this.__recUrl??""))return i.apply(this,n);let s=w(),c=this.__recMethod??"GET",u=this.__recUrl??"",f=Date.now();return t("request_start",{reqId:s,method:c,url:u}),this.addEventListener("loadend",()=>{let l=Date.now()-f;this.status===0||this.status>=400?t("request_fail",{reqId:s,method:c,url:u,status:this.status,dur:l}):t("request_end",{reqId:s,method:c,url:u,status:this.status,dur:l})}),i.apply(this,n)},r.push(()=>{XMLHttpRequest.prototype.open=o,XMLHttpRequest.prototype.send=i}),()=>r.forEach(n=>n())}function S(t){let r=[],e=(i,n,s)=>{try{let c=new PerformanceObserver(u=>{for(let f of u.getEntries())n(f)});c.observe({type:i,buffered:!0,...s}),r.push(c)}catch{}};e("longtask",i=>t("long_task",{dur:Math.round(i.duration)})),e("largest-contentful-paint",i=>t("lcp",{value:Math.round(i.startTime)}));let o=new Set;return e("event",i=>{let n=i;n.duration<50||!n.interactionId||o.has(n.interactionId)||(o.size>=1e3&&o.clear(),o.add(n.interactionId),t("inp",{value:Math.round(n.duration)}))},{durationThreshold:16}),e("layout-shift",i=>{let n=i;n.hadRecentInput||t("cls",{value:Math.round(n.value*1e3)/1e3})}),()=>r.forEach(i=>{try{i.disconnect()}catch{}})}function b(t){let r=()=>t("route_change",{route:location.pathname}),e=history.pushState.bind(history),o=history.replaceState.bind(history),i=(...c)=>{let u=e(...c);return r(),u},n=(...c)=>{let u=o(...c);return r(),u};history.pushState=i,history.replaceState=n;let s=()=>r();return window.addEventListener("popstate",s),()=>{history.pushState=e,history.replaceState=o,window.removeEventListener("popstate",s)}}function L(t,r=1e3){let e=0,o=null,i=()=>{e=Date.now(),t("scroll",{y:Math.round(window.scrollY)})},n=()=>{if(Date.now()-e<r){o===null&&(o=setTimeout(()=>{o=null,i()},r));return}i()};return window.addEventListener("scroll",n,{passive:!0}),()=>{o!==null&&clearTimeout(o),window.removeEventListener("scroll",n)}}function D(){try{return crypto.randomUUID().replace(/-/g,"").slice(0,12)}catch{return Array.from({length:12},()=>Math.floor(Math.random()*36).toString(36)).join("")}}function I(){return{sid:D(),t0:Date.now()}}var T="/recorder/events";var m="__repoburgRecorder.pending";function M(t,r={}){let e=r.fetch??((...a)=>fetch(...a)),o=r.sendBeacon??((a,p)=>{try{return navigator.sendBeacon(a,p)}catch{return!1}}),i=r.onUnload??(a=>{document.addEventListener("pagehide",a),document.addEventListener("visibilitychange",()=>{document.visibilityState==="hidden"&&a()})}),n=r.storage===void 0?P():r.storage,s=q(),c=()=>{if(n)try{s.length===0?n.removeItem(m):n.setItem(m,JSON.stringify(s))}catch{}},u=a=>{s=s.concat(a),s.length>1e3&&(s=s.slice(s.length-1e3)),c()},f=(a,p)=>{if(a.length===0)return;let h=JSON.stringify({sid:t,events:a});try{if(p&&o(T,new Blob([h],{type:"application/json"}))){c();return}e(T,{method:"POST",headers:{"content-type":"application/json"},body:h,keepalive:!0}).then(()=>c()).catch(()=>u(a))}catch{u(a)}},l=[],d={push(a){l.push(a),l.length>=100&&d.flush()},flush(a=!1){let p=s.concat(l);s=[],l=[],f(p,a)}};return(r.setInterval??((a,p)=>setInterval(a,p)))(()=>d.flush(),2e3),i(()=>d.flush(!0)),d;function P(){try{return window.localStorage}catch{return null}}function q(){if(!n)return[];try{let a=n.getItem(m),p=a?JSON.parse(a):null;return Array.isArray(p)?p:[]}catch{return[]}}}(function(){let r=window;if(!r.__repoburgRecorder){r.__repoburgRecorder=!0;try{N()}catch{}}})();function N(){let t=I(),r=M(t.sid),e=v(t,r);e("session_start",{route:location.pathname}),b(e),y(e),L(e),g(e),_(e),E(e),S(e),document.addEventListener("pagehide",()=>{e("session_end"),r.flush(!0)})}})();
Binary file