openfox 1.6.64 → 1.6.65

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.
@@ -2,7 +2,8 @@ import {
2
2
  maybeAutoCompactContext,
3
3
  performManualContextCompaction,
4
4
  resolveCompactionStatsIdentity
5
- } from "./chunk-7TMH3MPE.js";
5
+ } from "./chunk-PU4AOT3E.js";
6
+ import "./chunk-NRUMWHLX.js";
6
7
  import "./chunk-NBU6KIOD.js";
7
8
  import "./chunk-574HZVLE.js";
8
9
  import "./chunk-7JPKRM6M.js";
@@ -23,4 +24,4 @@ export {
23
24
  performManualContextCompaction,
24
25
  resolveCompactionStatsIdentity
25
26
  };
26
- //# sourceMappingURL=auto-compaction-XYMFQXXX.js.map
27
+ //# sourceMappingURL=auto-compaction-ASDCDWKT.js.map
@@ -8,8 +8,9 @@ import {
8
8
  } from "./chunk-ENAZTRCR.js";
9
9
  import {
10
10
  runChatTurn
11
- } from "./chunk-YF3ERP7E.js";
12
- import "./chunk-7TMH3MPE.js";
11
+ } from "./chunk-7XO4OW2P.js";
12
+ import "./chunk-PU4AOT3E.js";
13
+ import "./chunk-NRUMWHLX.js";
13
14
  import "./chunk-NBU6KIOD.js";
14
15
  import "./chunk-574HZVLE.js";
15
16
  import "./chunk-7JPKRM6M.js";
@@ -60,7 +61,7 @@ async function startChatSession(sessionId, content, deps, options) {
60
61
  sessionManager.setRunning(sessionId, true);
61
62
  broadcastForSession(sessionId, createSessionRunningMessage(true));
62
63
  try {
63
- const { maybeAutoCompactContext } = await import("./auto-compaction-XYMFQXXX.js");
64
+ const { maybeAutoCompactContext } = await import("./auto-compaction-ASDCDWKT.js");
64
65
  await maybeAutoCompactContext({
65
66
  sessionManager,
66
67
  sessionId,
@@ -169,4 +170,4 @@ export {
169
170
  startChatSession,
170
171
  stopSessionExecution
171
172
  };
172
- //# sourceMappingURL=chat-handler-24P6R3SB.js.map
173
+ //# sourceMappingURL=chat-handler-647QWEHP.js.map
@@ -179,7 +179,7 @@ async function runCli(options) {
179
179
  if (!configExists) {
180
180
  await runNetworkSetup(mode);
181
181
  }
182
- const { runServe } = await import("./serve-55UYT2JO.js");
182
+ const { runServe } = await import("./serve-NM33QHGG.js");
183
183
  await runServe({
184
184
  mode,
185
185
  port: values.port ? parseInt(values.port) : void 0,
@@ -192,4 +192,4 @@ async function runCli(options) {
192
192
  export {
193
193
  runCli
194
194
  };
195
- //# sourceMappingURL=chunk-OXQGLKLE.js.map
195
+ //# sourceMappingURL=chunk-2F2BUO46.js.map
@@ -13,7 +13,7 @@ import {
13
13
  getToolRegistryForAgent,
14
14
  loadAllAgentsDefault,
15
15
  runTopLevelAgentLoop
16
- } from "./chunk-7TMH3MPE.js";
16
+ } from "./chunk-PU4AOT3E.js";
17
17
  import {
18
18
  getCurrentContextWindowId,
19
19
  getEventStore
@@ -293,4 +293,4 @@ export {
293
293
  runBuilderTurn,
294
294
  runVerifierTurn
295
295
  };
296
- //# sourceMappingURL=chunk-YF3ERP7E.js.map
296
+ //# sourceMappingURL=chunk-7XO4OW2P.js.map
@@ -2,7 +2,7 @@ import {
2
2
  createVerifierNudgeConfig,
3
3
  runBuilderTurn,
4
4
  runChatTurn
5
- } from "./chunk-YF3ERP7E.js";
5
+ } from "./chunk-7XO4OW2P.js";
6
6
  import {
7
7
  TurnMetrics,
8
8
  agentExists,
@@ -38,7 +38,7 @@ import {
38
38
  setSkillEnabled,
39
39
  skillExists,
40
40
  spawnShellProcess
41
- } from "./chunk-7TMH3MPE.js";
41
+ } from "./chunk-PU4AOT3E.js";
42
42
  import {
43
43
  getPathSeparator,
44
44
  getPlatformShell,
@@ -5058,7 +5058,7 @@ function createTerminalRoutes() {
5058
5058
  }
5059
5059
 
5060
5060
  // src/constants.ts
5061
- var VERSION = "1.6.64";
5061
+ var VERSION = "1.6.65";
5062
5062
 
5063
5063
  // src/server/index.ts
5064
5064
  var __dirname2 = dirname5(fileURLToPath4(import.meta.url));
@@ -5361,7 +5361,7 @@ async function createServerHandle(config) {
5361
5361
  if (!callId || approved === void 0) {
5362
5362
  return res.status(400).json({ error: "callId and approved are required" });
5363
5363
  }
5364
- const { providePathConfirmation: providePathConfirmation2 } = await import("./tools-TSGPRFT2.js");
5364
+ const { providePathConfirmation: providePathConfirmation2 } = await import("./tools-AQEL6ZJG.js");
5365
5365
  const result = providePathConfirmation2(callId, approved, alwaysAllow);
5366
5366
  if (!result.found) {
5367
5367
  return res.status(404).json({ error: "No pending path confirmation with that ID" });
@@ -5386,7 +5386,7 @@ async function createServerHandle(config) {
5386
5386
  if (!callId || !answer) {
5387
5387
  return res.status(400).json({ error: "callId and answer are required" });
5388
5388
  }
5389
- const { provideAnswer: provideAnswer2 } = await import("./tools-TSGPRFT2.js");
5389
+ const { provideAnswer: provideAnswer2 } = await import("./tools-AQEL6ZJG.js");
5390
5390
  const found = provideAnswer2(callId, answer);
5391
5391
  if (!found) {
5392
5392
  return res.status(404).json({ error: "No pending question with that ID" });
@@ -5422,8 +5422,8 @@ async function createServerHandle(config) {
5422
5422
  if (!session) {
5423
5423
  return res.status(404).json({ error: "Session not found" });
5424
5424
  }
5425
- const { stopSessionExecution } = await import("./chat-handler-24P6R3SB.js");
5426
- const { cancelQuestionsForSession: cancelQuestionsForSession2, cancelPathConfirmationsForSession: cancelPathConfirmationsForSession2 } = await import("./tools-TSGPRFT2.js");
5425
+ const { stopSessionExecution } = await import("./chat-handler-647QWEHP.js");
5426
+ const { cancelQuestionsForSession: cancelQuestionsForSession2, cancelPathConfirmationsForSession: cancelPathConfirmationsForSession2 } = await import("./tools-AQEL6ZJG.js");
5427
5427
  stopSessionExecution(sessionId, sessionManager);
5428
5428
  abortSession(sessionId);
5429
5429
  cancelQuestionsForSession2(sessionId, "Session stopped by user");
@@ -5816,6 +5816,11 @@ async function createServerHandle(config) {
5816
5816
  }
5817
5817
  })
5818
5818
  );
5819
+ app.use("/__inspect__.js", (req, res) => {
5820
+ res.set("Access-Control-Allow-Origin", "*");
5821
+ res.set("Content-Type", "application/javascript");
5822
+ readFile3(join5(webDir, "public", "__inspect__.js")).then((content) => res.send(content)).catch(() => res.status(404).send("Not found"));
5823
+ });
5819
5824
  app.get("/*path", (req, res) => {
5820
5825
  if (req.path.startsWith("/api/")) {
5821
5826
  return;
@@ -5858,6 +5863,16 @@ async function createServerHandle(config) {
5858
5863
  }
5859
5864
  })
5860
5865
  );
5866
+ app.use("/__inspect__.js", (req, res) => {
5867
+ res.set("Access-Control-Allow-Origin", "*");
5868
+ res.set("Content-Type", "application/javascript");
5869
+ readFile3(join5(distWebDir, "__inspect__.js")).then((content) => res.send(content)).catch(() => res.status(404).send("Not found"));
5870
+ });
5871
+ app.use("/__inspect__.js", (req, res) => {
5872
+ res.set("Access-Control-Allow-Origin", "*");
5873
+ res.set("Content-Type", "application/javascript");
5874
+ readFile3(join5(distWebDir, "__inspect__.js")).then((content) => res.send(content)).catch(() => res.status(404).send("Not found"));
5875
+ });
5861
5876
  app.get("/", (_req, res) => {
5862
5877
  readFile3(join5(distWebDir, "index.html"), "utf-8").then((content) => res.send(content)).catch(() => {
5863
5878
  res.status(404).send("Web UI not built. Run `npm run build:web`");
@@ -5882,7 +5897,7 @@ async function createServerHandle(config) {
5882
5897
  providerManager
5883
5898
  );
5884
5899
  const wss = wssExports.wss;
5885
- const { QueueProcessor } = await import("./processor-GSMNLIRM.js");
5900
+ const { QueueProcessor } = await import("./processor-TSSCNWED.js");
5886
5901
  const queueProcessor = new QueueProcessor({
5887
5902
  sessionManager,
5888
5903
  providerManager,
@@ -5920,6 +5935,8 @@ async function createServerHandle(config) {
5920
5935
  logger.info("Shutting down...");
5921
5936
  void (async () => {
5922
5937
  await devServerManager.stopAll();
5938
+ const { stopAllInspectProxies } = await import("./inspect-proxy-M5222JOC.js");
5939
+ stopAllInspectProxies();
5923
5940
  const { cleanupAllProcesses } = await import("./store-2IF3ZSLD.js");
5924
5941
  cleanupAllProcesses();
5925
5942
  viteServer?.close();
@@ -5955,4 +5972,4 @@ export {
5955
5972
  createServerHandle,
5956
5973
  createServer
5957
5974
  };
5958
- //# sourceMappingURL=chunk-JY7BGPTB.js.map
5975
+ //# sourceMappingURL=chunk-A2Q6JCPK.js.map
@@ -0,0 +1,294 @@
1
+ import {
2
+ logger
3
+ } from "./chunk-PNBH3RAX.js";
4
+
5
+ // src/server/dev-server/inspect-proxy.ts
6
+ import net from "net";
7
+ import zlib from "zlib";
8
+ var OPENFOX_BASE_PORT = Number(process.env["OPENFOX_PORT"] ?? 10369);
9
+ var INJECT_SCRIPT = `<script src="http://127.0.0.1:${OPENFOX_BASE_PORT}/__inspect__.js"></script>`;
10
+ var proxyPool = /* @__PURE__ */ new Map();
11
+ var nextOffset = 0;
12
+ function getAvailablePort() {
13
+ const base = Number(process.env["OPENFOX_PORT"] ?? 10369);
14
+ const used = /* @__PURE__ */ new Set();
15
+ for (const instance of proxyPool.values()) {
16
+ const addr = instance.server.address();
17
+ if (addr && typeof addr === "object") used.add(addr.port);
18
+ }
19
+ for (let port = base + 1; port < base + 200; port++) {
20
+ if (!used.has(port)) return port;
21
+ }
22
+ return base + (nextOffset++ % 200 + 1);
23
+ }
24
+ function parseReqHeaders(str) {
25
+ const lines = str.split("\r\n");
26
+ const method = lines[0].split(" ")[0];
27
+ const url = lines[0].split(" ")[1];
28
+ const headers = parseHeaderLines(lines);
29
+ return { method, url, headers };
30
+ }
31
+ function parseResHeaders(str) {
32
+ const lines = str.split("\r\n");
33
+ const status = parseInt(lines[0].split(" ")[1] || "200");
34
+ const headers = parseHeaderLines(lines);
35
+ return { status, headers };
36
+ }
37
+ function parseHeaderLines(lines) {
38
+ const headers = {};
39
+ for (let i = 1; i < lines.length; i++) {
40
+ const line = lines[i];
41
+ if (!line) break;
42
+ const ci = line.indexOf(":");
43
+ if (ci < 0) continue;
44
+ headers[line.slice(0, ci).toLowerCase()] = line.slice(ci + 1).trim();
45
+ }
46
+ return headers;
47
+ }
48
+ function buildResponse(status, headers, body) {
49
+ const statusLine = `HTTP/1.1 ${status} ${status === 200 ? "OK" : status === 404 ? "Not Found" : "Error"}`;
50
+ const headerLines = Object.entries(headers).map(([k, v]) => `${k}: ${v}`).join("\r\n");
51
+ const head = Buffer.from(`${statusLine}\r
52
+ ${headerLines}\r
53
+ \r
54
+ `, "utf8");
55
+ return Buffer.concat([head, body]);
56
+ }
57
+ function dechunk(buf) {
58
+ const str = buf.toString("utf8");
59
+ const parts = [];
60
+ let pos = 0;
61
+ while (pos < str.length) {
62
+ const nlIdx = str.indexOf("\r\n", pos);
63
+ if (nlIdx < 0) break;
64
+ const sizeStr = str.slice(pos, nlIdx);
65
+ const size = parseInt(sizeStr, 16);
66
+ if (isNaN(size) || size < 0) break;
67
+ if (size === 0) break;
68
+ const chunkStart = nlIdx + 2;
69
+ const chunkEnd = chunkStart + size;
70
+ if (chunkEnd > str.length) break;
71
+ parts.push(str.slice(chunkStart, chunkEnd));
72
+ pos = chunkEnd + 2;
73
+ }
74
+ return Buffer.from(parts.join(""), "utf8");
75
+ }
76
+ function startInspectProxy(target, sessionManager) {
77
+ const port = getAvailablePort();
78
+ const server = net.createServer((client) => {
79
+ let clientHead = "";
80
+ let clientParsed = false;
81
+ let targetSocket;
82
+ client.on("data", (chunk) => {
83
+ if (clientParsed) {
84
+ targetSocket?.write(chunk);
85
+ return;
86
+ }
87
+ clientHead += chunk.toString("utf8");
88
+ const he = clientHead.indexOf("\r\n\r\n");
89
+ if (he < 0) return;
90
+ const { method, url, headers } = parseReqHeaders(clientHead);
91
+ const isWS = headers["upgrade"] === "websocket";
92
+ clientParsed = true;
93
+ if (url === "/__openfox_feedback" && method === "POST") {
94
+ const contentLength = parseInt(headers["content-length"] || "0", 10);
95
+ let bodyData = chunk.slice(he + 4);
96
+ let bodyTotal = bodyData.length;
97
+ const handleFeedback = () => {
98
+ try {
99
+ const { sessionId, element, annotation, pageUrl } = JSON.parse(bodyData.toString("utf8"));
100
+ if (sessionId) {
101
+ const elementDesc = element ? `${element.tag}${element.id ? "#" + element.id : ""}` : "unknown";
102
+ const htmlSnippet = element?.outerHTML ? `
103
+ Html: ${element.outerHTML.slice(0, 300)}` : "";
104
+ const textSnippet = element?.textContent ? `
105
+ Text (SVG-stripped): ${element.textContent.slice(0, 500)}` : "";
106
+ const content = `# User feedback from page inspection on dev_server
107
+
108
+ ## Context
109
+
110
+ Page: ${pageUrl || ""}
111
+ Element: ${elementDesc}
112
+ xPath: ${element?.xpath || ""}${htmlSnippet}${textSnippet}
113
+
114
+ ## Feedback
115
+
116
+ ${annotation || "(none)"}`;
117
+ sessionManager.queueMessage(sessionId, "asap", content, [], "ui_feedback");
118
+ }
119
+ client.write(buildResponse(200, { "Content-Type": "application/json" }, Buffer.from('{"success":true}')));
120
+ } catch {
121
+ client.write(buildResponse(400, { "Content-Type": "application/json" }, Buffer.from('{"error":"Invalid request"}')));
122
+ }
123
+ client.end();
124
+ };
125
+ if (bodyTotal >= contentLength) {
126
+ handleFeedback();
127
+ return;
128
+ }
129
+ client.on("data", (more) => {
130
+ bodyData = Buffer.concat([bodyData, more]);
131
+ bodyTotal += more.length;
132
+ if (bodyTotal < contentLength) return;
133
+ handleFeedback();
134
+ });
135
+ return;
136
+ }
137
+ const targetParts = target.replace(/^https?:\/\//, "").split(":");
138
+ const targetHost = targetParts[0] ?? "127.0.0.1";
139
+ const targetPort = parseInt(targetParts[1] ?? "80");
140
+ if (isWS) {
141
+ targetSocket = net.connect(targetPort, targetHost);
142
+ targetSocket.on("error", () => client.destroy());
143
+ client.on("error", () => targetSocket.destroy());
144
+ targetSocket.write(clientHead);
145
+ targetSocket.pipe(client);
146
+ client.pipe(targetSocket);
147
+ return;
148
+ }
149
+ targetSocket = net.connect(targetPort, targetHost);
150
+ targetSocket.on("error", () => client.destroy());
151
+ client.on("error", () => targetSocket.destroy());
152
+ client.on("data", (chunk2) => targetSocket.write(chunk2));
153
+ client.on("end", () => targetSocket.end());
154
+ const connClose = "\r\nConnection: close";
155
+ const reqEnd = clientHead.indexOf("\r\n\r\n");
156
+ const forwardHead = clientHead.slice(0, reqEnd) + connClose + clientHead.slice(reqEnd);
157
+ targetSocket.write(forwardHead);
158
+ targetSocket.on("close", () => {
159
+ if (!client.destroyed) client.end();
160
+ });
161
+ let serverHeadBuf = "";
162
+ let serverParsed = false;
163
+ let isHtml = false;
164
+ let enc = null;
165
+ let status = 200;
166
+ let resHeaders = {};
167
+ let bodyBuf = [];
168
+ let headEnd = -1;
169
+ targetSocket.on("data", (sChunk) => {
170
+ if (!serverParsed) {
171
+ serverHeadBuf += sChunk.toString("utf8");
172
+ const sHe = serverHeadBuf.indexOf("\r\n\r\n");
173
+ if (sHe < 0) return;
174
+ headEnd = sHe + 4;
175
+ const p = parseResHeaders(serverHeadBuf.slice(0, sHe));
176
+ status = p.status;
177
+ resHeaders = p.headers;
178
+ isHtml = (resHeaders["content-type"] || "").includes("text/html");
179
+ enc = resHeaders["content-encoding"] || null;
180
+ const isChunked = (resHeaders["transfer-encoding"] || "").toLowerCase() === "chunked";
181
+ serverParsed = true;
182
+ if (isHtml && enc) {
183
+ bodyBuf.push(sChunk.slice(headEnd));
184
+ return;
185
+ }
186
+ if (isHtml && isChunked) {
187
+ bodyBuf.push(sChunk.slice(headEnd));
188
+ return;
189
+ }
190
+ if (isHtml) {
191
+ bodyBuf.push(sChunk.slice(headEnd));
192
+ return;
193
+ }
194
+ client.write(sChunk);
195
+ return;
196
+ }
197
+ if (isHtml && enc) {
198
+ bodyBuf.push(sChunk);
199
+ return;
200
+ }
201
+ if (isHtml) {
202
+ bodyBuf.push(sChunk);
203
+ return;
204
+ }
205
+ client.write(sChunk);
206
+ });
207
+ targetSocket.on("end", () => {
208
+ if (!serverParsed) {
209
+ client.end();
210
+ return;
211
+ }
212
+ if (isHtml && enc) {
213
+ const fullBody = Buffer.concat(bodyBuf);
214
+ let text;
215
+ try {
216
+ if (enc === "gzip") text = zlib.gunzipSync(fullBody).toString("utf8");
217
+ else if (enc === "deflate") text = zlib.inflateSync(fullBody).toString("utf8");
218
+ else text = fullBody.toString("utf8");
219
+ } catch {
220
+ client.end();
221
+ return;
222
+ }
223
+ const bi = text.indexOf("</body>");
224
+ const hi = text.indexOf("</head>");
225
+ let modified;
226
+ if (bi >= 0) modified = text.slice(0, bi) + INJECT_SCRIPT + text.slice(bi);
227
+ else if (hi >= 0) modified = text.slice(0, hi) + INJECT_SCRIPT + text.slice(hi);
228
+ else {
229
+ client.end();
230
+ return;
231
+ }
232
+ let compressed;
233
+ if (enc === "gzip") compressed = zlib.gzipSync(Buffer.from(modified, "utf8"));
234
+ else if (enc === "deflate") compressed = zlib.deflateSync(Buffer.from(modified, "utf8"));
235
+ else compressed = Buffer.from(modified, "utf8");
236
+ const newH = { ...resHeaders };
237
+ delete newH["content-length"];
238
+ newH["connection"] = "close";
239
+ const headStr = `HTTP/1.1 ${status} OK\r
240
+ ` + Object.entries(newH).map(([k, v]) => `${k}: ${v}`).join("\r\n") + "\r\n\r\n";
241
+ client.write(Buffer.from(headStr, "utf8"));
242
+ client.write(compressed);
243
+ } else if (isHtml && bodyBuf.length > 0) {
244
+ const fullBody = Buffer.concat(bodyBuf);
245
+ const isChunked = (resHeaders["transfer-encoding"] || "").toLowerCase() === "chunked";
246
+ const dechunks = isChunked ? dechunk(fullBody) : fullBody;
247
+ const bi = dechunks.indexOf("</body>");
248
+ const hi = dechunks.indexOf("</head>");
249
+ let modified;
250
+ if (bi >= 0) modified = Buffer.concat([dechunks.slice(0, bi), Buffer.from(INJECT_SCRIPT, "utf8"), dechunks.slice(bi)]);
251
+ else if (hi >= 0) modified = Buffer.concat([dechunks.slice(0, hi), Buffer.from(INJECT_SCRIPT, "utf8"), dechunks.slice(hi)]);
252
+ else {
253
+ client.end();
254
+ return;
255
+ }
256
+ const newH = { ...resHeaders, "content-type": "text/html; charset=utf-8" };
257
+ delete newH["content-length"];
258
+ delete newH["transfer-encoding"];
259
+ newH["connection"] = "close";
260
+ newH["content-length"] = Buffer.byteLength(modified).toString();
261
+ const headStr = `HTTP/1.1 ${status} OK\r
262
+ ` + Object.entries(newH).map(([k, v]) => `${k}: ${v}`).join("\r\n") + "\r\n\r\n";
263
+ client.write(Buffer.from(headStr, "utf8"));
264
+ client.write(modified);
265
+ }
266
+ client.end();
267
+ });
268
+ });
269
+ client.on("error", () => {
270
+ });
271
+ });
272
+ server.listen(port, "0.0.0.0", () => {
273
+ logger.debug("Inspect proxy listening", { port, target });
274
+ });
275
+ proxyPool.set(target, { server, target });
276
+ const cleanup = () => {
277
+ server.close();
278
+ proxyPool.delete(target);
279
+ logger.debug("Inspect proxy stopped", { port, target });
280
+ };
281
+ return { port, cleanup };
282
+ }
283
+ function stopAllInspectProxies() {
284
+ for (const instance of proxyPool.values()) {
285
+ instance.server.close();
286
+ }
287
+ proxyPool.clear();
288
+ }
289
+
290
+ export {
291
+ startInspectProxy,
292
+ stopAllInspectProxies
293
+ };
294
+ //# sourceMappingURL=chunk-NRUMWHLX.js.map