openfox 1.6.63 → 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.
@@ -1,3 +1,6 @@
1
+ import {
2
+ startInspectProxy
3
+ } from "./chunk-NRUMWHLX.js";
1
4
  import {
2
5
  createProcess,
3
6
  getPlatformShell,
@@ -3380,7 +3383,7 @@ var callSubAgentTool = {
3380
3383
  };
3381
3384
  }
3382
3385
  try {
3383
- const { getToolRegistryForAgent: getToolRegistryForAgent2 } = await import("./tools-PYJRXESR.js");
3386
+ const { getToolRegistryForAgent: getToolRegistryForAgent2 } = await import("./tools-AQEL6ZJG.js");
3384
3387
  const toolRegistry = getToolRegistryForAgent2(agentDef);
3385
3388
  const turnMetrics = new TurnMetrics();
3386
3389
  const result = await executeSubAgent({
@@ -3637,283 +3640,12 @@ var webFetchTool = createTool(
3637
3640
  import { spawn as spawn4 } from "child_process";
3638
3641
  import { readFile as readFile7, writeFile as writeFile5, mkdir as mkdir4 } from "fs/promises";
3639
3642
  import { resolve as resolve5, join as join6 } from "path";
3640
-
3641
- // src/server/dev-server/inspect-proxy.ts
3642
- import net from "net";
3643
- import zlib from "zlib";
3644
- import fs from "fs";
3645
- import "http";
3646
- var INJECT_SCRIPT = '<script src="/__inspect__.js"></script>';
3647
- var proxyPool = /* @__PURE__ */ new Map();
3648
- var nextOffset = 0;
3649
- function getAvailablePort() {
3650
- const base = Number(process.env["OPENFOX_BASE_PROXY_PORT"] ?? 1e4);
3651
- const used = /* @__PURE__ */ new Set();
3652
- for (const instance of proxyPool.values()) {
3653
- const addr = instance.server.address();
3654
- if (addr && typeof addr === "object") used.add(addr.port);
3655
- }
3656
- for (let port = base + 1; port < base + 200; port++) {
3657
- if (!used.has(port)) return port;
3658
- }
3659
- return base + (nextOffset++ % 200 + 1);
3660
- }
3661
- function parseReqHeaders(str) {
3662
- const lines = str.split("\r\n");
3663
- const method = lines[0].split(" ")[0];
3664
- const url = lines[0].split(" ")[1];
3665
- const headers = parseHeaderLines(lines);
3666
- return { method, url, headers };
3667
- }
3668
- function parseResHeaders(str) {
3669
- const lines = str.split("\r\n");
3670
- const status = parseInt(lines[0].split(" ")[1] || "200");
3671
- const headers = parseHeaderLines(lines);
3672
- return { status, headers };
3673
- }
3674
- function parseHeaderLines(lines) {
3675
- const headers = {};
3676
- for (let i = 1; i < lines.length; i++) {
3677
- const line = lines[i];
3678
- if (!line) break;
3679
- const ci = line.indexOf(":");
3680
- if (ci < 0) continue;
3681
- headers[line.slice(0, ci).toLowerCase()] = line.slice(ci + 1).trim();
3682
- }
3683
- return headers;
3684
- }
3685
- function buildResponse(status, headers, body) {
3686
- const statusLine = `HTTP/1.1 ${status} ${status === 200 ? "OK" : status === 404 ? "Not Found" : "Error"}`;
3687
- const headerLines = Object.entries(headers).map(([k, v]) => `${k}: ${v}`).join("\r\n");
3688
- const head = Buffer.from(`${statusLine}\r
3689
- ${headerLines}\r
3690
- \r
3691
- `, "utf8");
3692
- return Buffer.concat([head, body]);
3693
- }
3694
- function forwardHtml(client, body, resHeaders, status) {
3695
- const bi = body.indexOf("</body>");
3696
- const hi = body.indexOf("</head>");
3697
- let modified;
3698
- if (bi >= 0) {
3699
- modified = Buffer.concat([body.slice(0, bi), Buffer.from(INJECT_SCRIPT, "utf8"), body.slice(bi)]);
3700
- } else if (hi >= 0) {
3701
- modified = Buffer.concat([body.slice(0, hi), Buffer.from(INJECT_SCRIPT, "utf8"), body.slice(hi)]);
3702
- } else {
3703
- client.write(body);
3704
- return;
3705
- }
3706
- const newH = { ...resHeaders };
3707
- delete newH["content-length"];
3708
- delete newH["transfer-encoding"];
3709
- newH["content-length"] = Buffer.byteLength(modified).toString();
3710
- const newHead = `HTTP/1.1 ${status} OK\r
3711
- ` + Object.entries(newH).map(([k, v]) => `${k}: ${v}`).join("\r\n") + "\r\n\r\n";
3712
- client.write(Buffer.from(newHead, "utf8"));
3713
- client.write(modified);
3714
- }
3715
- function forwardHtmlChunk(client, chunk) {
3716
- const str = chunk.toString("utf8");
3717
- const bi = str.indexOf("</body>");
3718
- const hi = str.indexOf("</head>");
3719
- if (bi >= 0) {
3720
- const modified = Buffer.from(str.slice(0, bi) + INJECT_SCRIPT + str.slice(bi), "utf8");
3721
- client.write(modified);
3722
- } else if (hi >= 0) {
3723
- const modified = Buffer.from(str.slice(0, hi) + INJECT_SCRIPT + str.slice(hi), "utf8");
3724
- client.write(modified);
3725
- } else {
3726
- client.write(chunk);
3727
- }
3728
- }
3729
- function startInspectProxy(target, sessionManager) {
3730
- const port = getAvailablePort();
3731
- const server = net.createServer((client) => {
3732
- let clientHead = "";
3733
- let clientParsed = false;
3734
- client.on("data", (chunk) => {
3735
- if (clientParsed) return;
3736
- clientHead += chunk.toString("utf8");
3737
- const he = clientHead.indexOf("\r\n\r\n");
3738
- if (he < 0) return;
3739
- const { method, url, headers } = parseReqHeaders(clientHead);
3740
- const isWS = headers["upgrade"] === "websocket";
3741
- clientParsed = true;
3742
- if (url === "/__inspect__.js") {
3743
- const inspectPath = new URL("./server/public/__inspect__.js", import.meta.url);
3744
- let inspectJs = null;
3745
- try {
3746
- inspectJs = fs.readFileSync(inspectPath);
3747
- } catch {
3748
- const resp2 = buildResponse(404, { "Content-Type": "text/plain" }, Buffer.from("Not found"));
3749
- client.write(resp2);
3750
- client.end();
3751
- return;
3752
- }
3753
- const resp = buildResponse(200, { "Content-Type": "application/javascript", "Content-Length": inspectJs.length.toString() }, inspectJs);
3754
- client.write(resp);
3755
- client.end();
3756
- return;
3757
- }
3758
- if (url === "/__openfox_feedback" && method === "POST") {
3759
- const contentLength = parseInt(headers["content-length"] || "0", 10);
3760
- let bodyData = chunk.slice(he + 4);
3761
- let bodyTotal = bodyData.length;
3762
- const handleFeedback = () => {
3763
- try {
3764
- const { sessionId, element, annotation, pageUrl } = JSON.parse(bodyData.toString("utf8"));
3765
- if (sessionId) {
3766
- const elementDesc = element ? `${element.tag}${element.id ? "#" + element.id : ""}` : "unknown";
3767
- const htmlSnippet = element?.outerHTML ? `
3768
- Html: ${element.outerHTML.slice(0, 300)}` : "";
3769
- const content = `# User feedback from page inspection on dev_server
3770
-
3771
- ## Context
3772
-
3773
- Page: ${pageUrl || ""}
3774
- Element: ${elementDesc}
3775
- xPath: ${element?.xpath || ""}${htmlSnippet}
3776
-
3777
- ## Feedback
3778
-
3779
- ${annotation || "(none)"}`;
3780
- sessionManager.queueMessage(sessionId, "asap", content, [], "ui_feedback");
3781
- }
3782
- client.write(buildResponse(200, { "Content-Type": "application/json" }, Buffer.from('{"success":true}')));
3783
- } catch {
3784
- client.write(buildResponse(400, { "Content-Type": "application/json" }, Buffer.from('{"error":"Invalid request"}')));
3785
- }
3786
- client.end();
3787
- };
3788
- if (bodyTotal >= contentLength) {
3789
- handleFeedback();
3790
- return;
3791
- }
3792
- client.on("data", (more) => {
3793
- bodyData = Buffer.concat([bodyData, more]);
3794
- bodyTotal += more.length;
3795
- if (bodyTotal < contentLength) return;
3796
- handleFeedback();
3797
- });
3798
- return;
3799
- }
3800
- const targetParts = target.replace(/^https?:\/\//, "").split(":");
3801
- const targetHost = targetParts[0] ?? "127.0.0.1";
3802
- const targetPort = parseInt(targetParts[1] ?? "80");
3803
- if (isWS) {
3804
- const server3 = net.connect(targetPort, targetHost);
3805
- server3.on("error", () => client.destroy());
3806
- client.on("error", () => server3.destroy());
3807
- server3.write(clientHead);
3808
- server3.pipe(client);
3809
- client.pipe(server3);
3810
- return;
3811
- }
3812
- const server2 = net.connect(targetPort, targetHost);
3813
- server2.on("error", () => client.destroy());
3814
- client.on("error", () => server2.destroy());
3815
- server2.write(clientHead);
3816
- client.pipe(server2);
3817
- let serverHeadBuf = "";
3818
- let serverParsed = false;
3819
- let isHtml = false;
3820
- let enc = null;
3821
- let status = 200;
3822
- let resHeaders = {};
3823
- let bodyBuf = [];
3824
- let headEnd = -1;
3825
- server2.on("data", (sChunk) => {
3826
- if (!serverParsed) {
3827
- serverHeadBuf += sChunk.toString("utf8");
3828
- const sHe = serverHeadBuf.indexOf("\r\n\r\n");
3829
- if (sHe < 0) return;
3830
- headEnd = sHe + 4;
3831
- const p = parseResHeaders(serverHeadBuf.slice(0, sHe));
3832
- status = p.status;
3833
- resHeaders = p.headers;
3834
- isHtml = (resHeaders["content-type"] || "").includes("text/html");
3835
- enc = resHeaders["content-encoding"] || null;
3836
- serverParsed = true;
3837
- if (isHtml && enc) {
3838
- bodyBuf.push(sChunk.slice(headEnd));
3839
- return;
3840
- }
3841
- if (isHtml) {
3842
- const body = sChunk.slice(headEnd);
3843
- forwardHtml(client, body, resHeaders, status);
3844
- return;
3845
- }
3846
- client.write(sChunk);
3847
- return;
3848
- }
3849
- if (isHtml && enc) {
3850
- bodyBuf.push(sChunk);
3851
- return;
3852
- }
3853
- if (isHtml) {
3854
- forwardHtmlChunk(client, sChunk);
3855
- return;
3856
- }
3857
- client.write(sChunk);
3858
- });
3859
- server2.on("end", () => {
3860
- if (!serverParsed) {
3861
- client.end();
3862
- return;
3863
- }
3864
- if (isHtml && enc) {
3865
- const fullBody = Buffer.concat(bodyBuf);
3866
- let text;
3867
- try {
3868
- if (enc === "gzip") text = zlib.gunzipSync(fullBody).toString("utf8");
3869
- else if (enc === "deflate") text = zlib.inflateSync(fullBody).toString("utf8");
3870
- else text = fullBody.toString("utf8");
3871
- } catch {
3872
- client.end();
3873
- return;
3874
- }
3875
- const bi = text.indexOf("</body>");
3876
- const hi = text.indexOf("</head>");
3877
- let modified;
3878
- if (bi >= 0) modified = text.slice(0, bi) + INJECT_SCRIPT + text.slice(bi);
3879
- else if (hi >= 0) modified = text.slice(0, hi) + INJECT_SCRIPT + text.slice(hi);
3880
- else {
3881
- client.end();
3882
- return;
3883
- }
3884
- let compressed;
3885
- if (enc === "gzip") compressed = zlib.gzipSync(Buffer.from(modified, "utf8"));
3886
- else if (enc === "deflate") compressed = zlib.deflateSync(Buffer.from(modified, "utf8"));
3887
- else compressed = Buffer.from(modified, "utf8");
3888
- const newH = { ...resHeaders };
3889
- delete newH["content-length"];
3890
- const headStr = `HTTP/1.1 ${status} OK\r
3891
- ` + Object.entries(newH).map(([k, v]) => `${k}: ${v}`).join("\r\n") + "\r\n\r\n";
3892
- client.write(Buffer.from(headStr, "utf8"));
3893
- client.write(compressed);
3894
- }
3895
- client.end();
3896
- });
3897
- });
3898
- client.on("error", () => {
3899
- });
3900
- });
3901
- server.listen(port, "0.0.0.0", () => {
3902
- logger.debug("Inspect proxy listening", { port, target });
3903
- });
3904
- proxyPool.set(target, { server, target });
3905
- const cleanup = () => {
3906
- server.close();
3907
- proxyPool.delete(target);
3908
- logger.debug("Inspect proxy stopped", { port, target });
3909
- };
3910
- return { port, cleanup };
3911
- }
3912
-
3913
- // src/server/dev-server/manager.ts
3914
3643
  var MAX_LOG_LINES = 2e3;
3915
3644
  var MAX_LOG_BYTES = 1e5;
3916
- var CONFIG_PATH = ".openfox/dev.json";
3645
+ var getDevServerConfigPath = (workdir) => {
3646
+ const mode = getRuntimeConfig().mode ?? "production";
3647
+ return join6(resolve5(workdir), ".openfox", `${mode === "development" ? "dev-dev" : "dev"}.json`);
3648
+ };
3917
3649
  var ERROR_PATTERNS = [
3918
3650
  /EADDRINUSE/,
3919
3651
  /EACCES/,
@@ -3972,7 +3704,7 @@ var DevServerManager = class {
3972
3704
  }
3973
3705
  async loadConfig(workdir) {
3974
3706
  try {
3975
- const configPath = join6(this.resolveWorkdir(workdir), CONFIG_PATH);
3707
+ const configPath = getDevServerConfigPath(workdir);
3976
3708
  const raw = await readFile7(configPath, "utf-8");
3977
3709
  const parsed = JSON.parse(raw);
3978
3710
  if (!parsed.command || !parsed.url) return null;
@@ -3990,7 +3722,7 @@ var DevServerManager = class {
3990
3722
  const resolved = this.resolveWorkdir(workdir);
3991
3723
  const dirPath = join6(resolved, ".openfox");
3992
3724
  await mkdir4(dirPath, { recursive: true });
3993
- const configPath = join6(resolved, CONFIG_PATH);
3725
+ const configPath = getDevServerConfigPath(workdir);
3994
3726
  await writeFile5(configPath, JSON.stringify(config, null, 2) + "\n", "utf-8");
3995
3727
  }
3996
3728
  async start(workdir) {
@@ -4151,7 +3883,7 @@ var devServerTool = createTool(
4151
3883
  type: "function",
4152
3884
  function: {
4153
3885
  name: "dev_server",
4154
- description: "Control the project dev server. Start, stop, restart, check status, or fetch logs with optional pagination. The dev server command and URL are configured in .openfox/dev.json.",
3886
+ description: "Control the project dev server. Start, stop, restart, check status, or fetch logs with optional pagination. The dev server command and URL are configured in .openfox/dev-dev.json (dev mode) or .openfox/dev.json (prod).",
4155
3887
  parameters: {
4156
3888
  type: "object",
4157
3889
  properties: {
@@ -4215,7 +3947,7 @@ var devServerTool = createTool(
4215
3947
  }
4216
3948
  if (!status.config) {
4217
3949
  return helpers.error(
4218
- 'No .openfox/dev.json config found. Create one with:\n\n{\n "command": "npm run dev",\n "url": "http://localhost:3000",\n "hotReload": true\n}'
3950
+ 'No .openfox/dev-dev.json (dev mode) or .openfox/dev.json (prod) config found. Create one with:\n\n{\n "command": "npm run dev",\n "url": "http://localhost:3000",\n "hotReload": true\n}'
4219
3951
  );
4220
3952
  }
4221
3953
  return helpers.success(JSON.stringify({
@@ -4384,12 +4116,12 @@ These processes run independently of agent turns and persist across session comp
4384
4116
  }
4385
4117
  const since = args.since ?? 0;
4386
4118
  const maxLines = Math.min(args.maxLines ?? 500, 2e3);
4387
- const { lines, totalLines, nextOffset: nextOffset2, hasMore } = getProcessLogs(args.processId, since, maxLines);
4119
+ const { lines, totalLines, nextOffset, hasMore } = getProcessLogs(args.processId, since, maxLines);
4388
4120
  return helpers.success(JSON.stringify({
4389
4121
  processId: args.processId,
4390
4122
  lines,
4391
4123
  totalLines,
4392
- nextOffset: nextOffset2,
4124
+ nextOffset,
4393
4125
  hasMore,
4394
4126
  truncated: hasMore
4395
4127
  }, null, 2));
@@ -4805,4 +4537,4 @@ export {
4805
4537
  getToolRegistryForAgent,
4806
4538
  createToolRegistry
4807
4539
  };
4808
- //# sourceMappingURL=chunk-NKKB55E4.js.map
4540
+ //# sourceMappingURL=chunk-PU4AOT3E.js.map
package/dist/cli/dev.js CHANGED
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
  import {
3
3
  runCli
4
- } from "../chunk-KPSKC34U.js";
4
+ } from "../chunk-2F2BUO46.js";
5
5
  import {
6
6
  logger
7
7
  } from "../chunk-PNBH3RAX.js";
package/dist/cli/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
  import {
3
3
  runCli
4
- } from "../chunk-KPSKC34U.js";
4
+ } from "../chunk-2F2BUO46.js";
5
5
  import {
6
6
  logger
7
7
  } from "../chunk-PNBH3RAX.js";
@@ -0,0 +1,10 @@
1
+ import {
2
+ startInspectProxy,
3
+ stopAllInspectProxies
4
+ } from "./chunk-NRUMWHLX.js";
5
+ import "./chunk-PNBH3RAX.js";
6
+ export {
7
+ startInspectProxy,
8
+ stopAllInspectProxies
9
+ };
10
+ //# sourceMappingURL=inspect-proxy-M5222JOC.js.map
@@ -3,7 +3,7 @@ import {
3
3
  runBuilderTurn,
4
4
  runChatTurn,
5
5
  runVerifierTurn
6
- } from "./chunk-OIDMZVTJ.js";
6
+ } from "./chunk-7XO4OW2P.js";
7
7
  import {
8
8
  TurnMetrics,
9
9
  createChatDoneEvent,
@@ -11,7 +11,8 @@ import {
11
11
  createMessageStartEvent,
12
12
  createToolCallEvent,
13
13
  createToolResultEvent
14
- } from "./chunk-NKKB55E4.js";
14
+ } from "./chunk-PU4AOT3E.js";
15
+ import "./chunk-NRUMWHLX.js";
15
16
  import "./chunk-NBU6KIOD.js";
16
17
  import "./chunk-574HZVLE.js";
17
18
  import "./chunk-7JPKRM6M.js";
@@ -39,4 +40,4 @@ export {
39
40
  runChatTurn,
40
41
  runVerifierTurn
41
42
  };
42
- //# sourceMappingURL=orchestrator-6V4V2ODS.js.map
43
+ //# sourceMappingURL=orchestrator-UEDPSWG6.js.map
package/dist/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "openfox",
3
- "version": "1.6.63",
3
+ "version": "1.6.65",
4
4
  "description": "Local-LLM-first agentic coding assistant",
5
5
  "type": "module",
6
6
  "bin": {
@@ -173,7 +173,7 @@ var QueueProcessor = class {
173
173
  backend: provider?.backend ?? llmClient.getBackend(),
174
174
  model: llmClient.getModel()
175
175
  };
176
- const { runChatTurn } = await import("./orchestrator-6V4V2ODS.js");
176
+ const { runChatTurn } = await import("./orchestrator-UEDPSWG6.js");
177
177
  const runChatTurnParams = buildRunChatTurnParams({
178
178
  sessionManager,
179
179
  sessionId,
@@ -210,4 +210,4 @@ var QueueProcessor = class {
210
210
  export {
211
211
  QueueProcessor
212
212
  };
213
- //# sourceMappingURL=processor-NEW6ZPBK.js.map
213
+ //# sourceMappingURL=processor-TSSCNWED.js.map
@@ -6,9 +6,10 @@ import {
6
6
  import {
7
7
  VERSION,
8
8
  createServer
9
- } from "./chunk-QIBXSYCE.js";
10
- import "./chunk-OIDMZVTJ.js";
11
- import "./chunk-NKKB55E4.js";
9
+ } from "./chunk-A2Q6JCPK.js";
10
+ import "./chunk-7XO4OW2P.js";
11
+ import "./chunk-PU4AOT3E.js";
12
+ import "./chunk-NRUMWHLX.js";
12
13
  import "./chunk-NBU6KIOD.js";
13
14
  import "./chunk-574HZVLE.js";
14
15
  import "./chunk-7JPKRM6M.js";
@@ -187,4 +188,4 @@ async function runServe(options) {
187
188
  export {
188
189
  runServe
189
190
  };
190
- //# sourceMappingURL=serve-5Z74LI7X.js.map
191
+ //# sourceMappingURL=serve-NM33QHGG.js.map
@@ -1,9 +1,10 @@
1
1
  import {
2
2
  createServer,
3
3
  createServerHandle
4
- } from "../chunk-QIBXSYCE.js";
5
- import "../chunk-OIDMZVTJ.js";
6
- import "../chunk-NKKB55E4.js";
4
+ } from "../chunk-A2Q6JCPK.js";
5
+ import "../chunk-7XO4OW2P.js";
6
+ import "../chunk-PU4AOT3E.js";
7
+ import "../chunk-NRUMWHLX.js";
7
8
  import "../chunk-NBU6KIOD.js";
8
9
  import "../chunk-574HZVLE.js";
9
10
  import "../chunk-7JPKRM6M.js";
@@ -72,6 +72,20 @@
72
72
  return '/' + parts.join('/');
73
73
  }
74
74
 
75
+ function stripSvgAndGetText(el) {
76
+ try {
77
+ var clone = el.cloneNode(true);
78
+ var svgs = clone.querySelectorAll('svg');
79
+ for (var i = 0; i < svgs.length; i++) {
80
+ svgs[i].remove();
81
+ }
82
+ var text = (clone.textContent || '').replace(/\s+/g, ' ').trim();
83
+ return text.slice(0, 500) || null;
84
+ } catch (e) {
85
+ return null;
86
+ }
87
+ }
88
+
75
89
  function buildElementData(el) {
76
90
  var attrs = {};
77
91
  if (el.attributes) {
@@ -97,6 +111,7 @@
97
111
  className: (typeof el.className === 'string' ? el.className : '') || null,
98
112
  xpath: generateXPath(el),
99
113
  text: (el.innerText || '').slice(0, 500) || null,
114
+ textContent: stripSvgAndGetText(el),
100
115
  outerHTML: (el.outerHTML || '').slice(0, 1000) || '',
101
116
  rect: { x: rect.left, y: rect.top, width: rect.width, height: rect.height },
102
117
  attributes: attrs
@@ -11,7 +11,8 @@ import {
11
11
  requestPathAccess,
12
12
  stepDoneTool,
13
13
  validateToolAction
14
- } from "./chunk-NKKB55E4.js";
14
+ } from "./chunk-PU4AOT3E.js";
15
+ import "./chunk-NRUMWHLX.js";
15
16
  import "./chunk-NBU6KIOD.js";
16
17
  import "./chunk-574HZVLE.js";
17
18
  import "./chunk-7JPKRM6M.js";
@@ -48,4 +49,4 @@ export {
48
49
  stepDoneTool,
49
50
  validateToolAction
50
51
  };
51
- //# sourceMappingURL=tools-PYJRXESR.js.map
52
+ //# sourceMappingURL=tools-AQEL6ZJG.js.map