openfox 1.6.79 → 1.6.80

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.
@@ -0,0 +1,111 @@
1
+ import {
2
+ createProject
3
+ } from "./chunk-CMQCO27Y.js";
4
+ import "./chunk-KIOUKC3Z.js";
5
+ import "./chunk-K44MW7JJ.js";
6
+
7
+ // src/server/utils/project-creator.ts
8
+ import { execSync } from "child_process";
9
+ import { join } from "path";
10
+ function validateProjectName(name) {
11
+ if (!name || name.trim() === "") {
12
+ return { valid: false, error: "Project name cannot be empty" };
13
+ }
14
+ if (!/^[a-zA-Z0-9._ -]+$/.test(name)) {
15
+ return {
16
+ valid: false,
17
+ error: "Project name can only contain letters, numbers, hyphens, underscores, dots, and spaces"
18
+ };
19
+ }
20
+ if (name.includes("/") || name.includes("\\") || name.includes("..")) {
21
+ return { valid: false, error: "Project name cannot contain path separators" };
22
+ }
23
+ return { valid: true };
24
+ }
25
+ async function directoryExists(path) {
26
+ try {
27
+ const { access } = await import("fs/promises");
28
+ const { constants } = await import("fs");
29
+ await access(path, constants.F_OK);
30
+ return true;
31
+ } catch {
32
+ return false;
33
+ }
34
+ }
35
+ async function createDirectoryWithGit(projectName, workdir) {
36
+ const validation = validateProjectName(projectName);
37
+ if (!validation.valid) {
38
+ throw new Error(validation.error);
39
+ }
40
+ const fullPath = workdir.replace(/\/+$/, "");
41
+ const { stat, mkdir, rm, access, constants } = await import("fs/promises");
42
+ const dirAlreadyExisted = await access(fullPath, constants.F_OK).then(() => true).catch(() => false);
43
+ try {
44
+ const stats = await stat(fullPath);
45
+ if (!stats.isDirectory()) {
46
+ throw new Error(`A file named '${projectName}' already exists at ${fullPath}`);
47
+ }
48
+ } catch (err) {
49
+ if (err instanceof Error && "code" in err && err.code === "ENOENT") {
50
+ try {
51
+ await mkdir(fullPath, { recursive: true });
52
+ } catch (mkdirErr) {
53
+ if (mkdirErr instanceof Error && "code" in mkdirErr && mkdirErr.code === "EACCES") {
54
+ const eaccError = mkdirErr;
55
+ const permError = new Error(`Permission denied: cannot create directory at ${fullPath}`, {
56
+ cause: eaccError
57
+ });
58
+ permError.code = "EACCES";
59
+ throw permError;
60
+ }
61
+ throw mkdirErr;
62
+ }
63
+ } else if (err instanceof Error && "code" in err && err.code === "EACCES") {
64
+ const eaccError = err;
65
+ const permError = new Error(`Permission denied: cannot access directory at ${fullPath}`, {
66
+ cause: eaccError
67
+ });
68
+ permError.code = "EACCES";
69
+ throw permError;
70
+ } else {
71
+ throw err;
72
+ }
73
+ }
74
+ if (!await directoryExists(join(fullPath, ".git"))) {
75
+ try {
76
+ execSync("git init", { cwd: fullPath, stdio: "pipe" });
77
+ } catch (gitErr) {
78
+ const errMsg = gitErr instanceof Error ? gitErr.message : "Unknown";
79
+ const exitCode = gitErr.status ?? gitErr.exitCode;
80
+ const isPermission = errMsg.includes("Permission denied") || exitCode === 128;
81
+ let sudoSuccess = false;
82
+ if (isPermission) {
83
+ try {
84
+ const currentUser = execSync("id -un", { encoding: "utf-8" }).trim();
85
+ execSync(`sudo -u ${currentUser} git init`, { cwd: fullPath, stdio: "pipe" });
86
+ sudoSuccess = true;
87
+ } catch {
88
+ }
89
+ }
90
+ if (!sudoSuccess) {
91
+ const permError = new Error(`Failed to initialize git: ${errMsg}`);
92
+ if (isPermission) {
93
+ permError.code = "EACCES";
94
+ }
95
+ if (!dirAlreadyExisted) {
96
+ try {
97
+ await rm(fullPath, { recursive: true, force: true });
98
+ } catch {
99
+ }
100
+ }
101
+ throw permError;
102
+ }
103
+ }
104
+ }
105
+ return createProject(projectName, fullPath);
106
+ }
107
+ export {
108
+ createDirectoryWithGit,
109
+ validateProjectName
110
+ };
111
+ //# sourceMappingURL=project-creator-GPOIXKX4.js.map
@@ -35,7 +35,7 @@ import {
35
35
  parseClientMessage,
36
36
  serializeServerMessage,
37
37
  storedEventToServerMessage
38
- } from "./chunk-STYHKCG7.js";
38
+ } from "./chunk-UF6D2IPO.js";
39
39
  import "./chunk-NDJ6FKSP.js";
40
40
  export {
41
41
  createChatAskUserMessage,
@@ -75,4 +75,4 @@ export {
75
75
  serializeServerMessage,
76
76
  storedEventToServerMessage
77
77
  };
78
- //# sourceMappingURL=protocol-4CTV7OZC.js.map
78
+ //# sourceMappingURL=protocol-IXFNYZEX.js.map
@@ -6,9 +6,9 @@ import {
6
6
  import {
7
7
  VERSION,
8
8
  createServer
9
- } from "./chunk-3JU4NOQD.js";
10
- import "./chunk-BG7QCFGG.js";
11
- import "./chunk-UCZSBKG7.js";
9
+ } from "./chunk-YLLWWYDA.js";
10
+ import "./chunk-HPTMW2FT.js";
11
+ import "./chunk-7DOKXSMI.js";
12
12
  import "./chunk-OXI26S7U.js";
13
13
  import "./chunk-CMQCO27Y.js";
14
14
  import "./chunk-DL6ZILAF.js";
@@ -17,10 +17,10 @@ import "./chunk-VRGRAQDG.js";
17
17
  import "./chunk-WR6QCJJO.js";
18
18
  import "./chunk-TGWEH2BC.js";
19
19
  import "./chunk-CUDAT6SS.js";
20
- import "./chunk-RJRG2VER.js";
20
+ import "./chunk-LHKXWUEK.js";
21
21
  import "./chunk-KIOUKC3Z.js";
22
22
  import "./chunk-TS5XFQ2D.js";
23
- import "./chunk-STYHKCG7.js";
23
+ import "./chunk-UF6D2IPO.js";
24
24
  import "./chunk-BJYPTN5S.js";
25
25
  import "./chunk-RGRBWDZP.js";
26
26
  import "./chunk-NDJ6FKSP.js";
@@ -190,4 +190,4 @@ async function runServe(options) {
190
190
  export {
191
191
  runServe
192
192
  };
193
- //# sourceMappingURL=serve-55GF3KJW.js.map
193
+ //# sourceMappingURL=serve-U5FU7YWD.js.map
@@ -1,9 +1,9 @@
1
1
  import {
2
2
  createServer,
3
3
  createServerHandle
4
- } from "../chunk-3JU4NOQD.js";
5
- import "../chunk-BG7QCFGG.js";
6
- import "../chunk-UCZSBKG7.js";
4
+ } from "../chunk-YLLWWYDA.js";
5
+ import "../chunk-HPTMW2FT.js";
6
+ import "../chunk-7DOKXSMI.js";
7
7
  import "../chunk-OXI26S7U.js";
8
8
  import "../chunk-CMQCO27Y.js";
9
9
  import "../chunk-DL6ZILAF.js";
@@ -12,10 +12,10 @@ import "../chunk-VRGRAQDG.js";
12
12
  import "../chunk-WR6QCJJO.js";
13
13
  import "../chunk-TGWEH2BC.js";
14
14
  import "../chunk-CUDAT6SS.js";
15
- import "../chunk-RJRG2VER.js";
15
+ import "../chunk-LHKXWUEK.js";
16
16
  import "../chunk-KIOUKC3Z.js";
17
17
  import "../chunk-TS5XFQ2D.js";
18
- import "../chunk-STYHKCG7.js";
18
+ import "../chunk-UF6D2IPO.js";
19
19
  import "../chunk-BJYPTN5S.js";
20
20
  import "../chunk-RGRBWDZP.js";
21
21
  import "../chunk-NDJ6FKSP.js";
@@ -11,17 +11,17 @@ import {
11
11
  requestPathAccess,
12
12
  stepDoneTool,
13
13
  validateToolAction
14
- } from "./chunk-UCZSBKG7.js";
14
+ } from "./chunk-7DOKXSMI.js";
15
15
  import "./chunk-OXI26S7U.js";
16
16
  import "./chunk-CMQCO27Y.js";
17
17
  import "./chunk-DL6ZILAF.js";
18
18
  import "./chunk-PBGOZMVY.js";
19
19
  import "./chunk-VRGRAQDG.js";
20
20
  import "./chunk-CUDAT6SS.js";
21
- import "./chunk-RJRG2VER.js";
21
+ import "./chunk-LHKXWUEK.js";
22
22
  import "./chunk-KIOUKC3Z.js";
23
23
  import "./chunk-TS5XFQ2D.js";
24
- import "./chunk-STYHKCG7.js";
24
+ import "./chunk-UF6D2IPO.js";
25
25
  import {
26
26
  AskUserInterrupt,
27
27
  cancelQuestionsForSession,
@@ -49,4 +49,4 @@ export {
49
49
  stepDoneTool,
50
50
  validateToolAction
51
51
  };
52
- //# sourceMappingURL=tools-W6OPDFQV.js.map
52
+ //# sourceMappingURL=tools-B4KSCOWC.js.map