@sandbox-agent/cli-shared 0.3.1 → 0.4.0-rc.1
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/index.cjs +3 -13
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +3 -13
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -56,19 +56,11 @@ function assertExecutable(binPath, fs) {
|
|
|
56
56
|
}
|
|
57
57
|
}
|
|
58
58
|
function formatNonExecutableBinaryMessage(options) {
|
|
59
|
-
const {
|
|
60
|
-
binPath,
|
|
61
|
-
trustPackages,
|
|
62
|
-
bunInstallBlocks,
|
|
63
|
-
genericInstallCommands,
|
|
64
|
-
binaryName
|
|
65
|
-
} = options;
|
|
59
|
+
const { binPath, trustPackages, bunInstallBlocks, genericInstallCommands, binaryName } = options;
|
|
66
60
|
const label = binaryName ?? "sandbox-agent";
|
|
67
61
|
const lines = [`${label} binary is not executable: ${binPath}`];
|
|
68
62
|
if (isBunRuntime()) {
|
|
69
|
-
lines.push(
|
|
70
|
-
"Allow Bun to run postinstall scripts for native binaries and reinstall:"
|
|
71
|
-
);
|
|
63
|
+
lines.push("Allow Bun to run postinstall scripts for native binaries and reinstall:");
|
|
72
64
|
for (const block of bunInstallBlocks) {
|
|
73
65
|
lines.push(`${block.label}:`);
|
|
74
66
|
for (const command of block.commands) {
|
|
@@ -78,9 +70,7 @@ function formatNonExecutableBinaryMessage(options) {
|
|
|
78
70
|
lines.push(`Or run: chmod +x "${binPath}"`);
|
|
79
71
|
return lines.join("\n");
|
|
80
72
|
}
|
|
81
|
-
lines.push(
|
|
82
|
-
"Postinstall scripts for native packages did not run, so the binary was left non-executable."
|
|
83
|
-
);
|
|
73
|
+
lines.push("Postinstall scripts for native packages did not run, so the binary was left non-executable.");
|
|
84
74
|
if (genericInstallCommands && genericInstallCommands.length > 0) {
|
|
85
75
|
lines.push("Reinstall with scripts enabled:");
|
|
86
76
|
for (const command of genericInstallCommands) {
|
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["export type InstallCommandBlock = {\n
|
|
1
|
+
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["export type InstallCommandBlock = {\n label: string;\n commands: string[];\n};\n\nexport type NonExecutableBinaryMessageOptions = {\n binPath: string;\n trustPackages: string;\n bunInstallBlocks: InstallCommandBlock[];\n genericInstallCommands?: string[];\n binaryName?: string;\n};\n\nexport type FsSubset = {\n accessSync: (path: string, mode?: number) => void;\n chmodSync: (path: string, mode: number) => void;\n constants: { X_OK: number };\n};\n\nexport function isBunRuntime(): boolean {\n if (typeof process?.versions?.bun === \"string\") return true;\n const userAgent = process?.env?.npm_config_user_agent || \"\";\n return userAgent.includes(\"bun/\");\n}\n\nconst PERMISSION_ERRORS = new Set([\"EACCES\", \"EPERM\", \"ENOEXEC\"]);\n\nfunction isPermissionError(error: unknown): boolean {\n if (!error || typeof error !== \"object\") return false;\n const code = (error as { code?: unknown }).code;\n return typeof code === \"string\" && PERMISSION_ERRORS.has(code);\n}\n\n/**\n * Checks if a binary is executable and attempts to make it executable if not.\n * Returns true if the binary is (or was made) executable, false if it couldn't\n * be made executable due to permission errors. Throws for other errors.\n *\n * Requires fs to be passed in to avoid static imports that break browser builds.\n */\nexport function assertExecutable(binPath: string, fs: FsSubset): boolean {\n if (process.platform === \"win32\") {\n return true;\n }\n\n try {\n fs.accessSync(binPath, fs.constants.X_OK);\n return true;\n } catch {\n // Not executable, try to fix\n }\n\n try {\n fs.chmodSync(binPath, 0o755);\n return true;\n } catch (error) {\n if (isPermissionError(error)) {\n return false;\n }\n throw error;\n }\n}\n\nexport function formatNonExecutableBinaryMessage(options: NonExecutableBinaryMessageOptions): string {\n const { binPath, trustPackages, bunInstallBlocks, genericInstallCommands, binaryName } = options;\n\n const label = binaryName ?? \"sandbox-agent\";\n const lines = [`${label} binary is not executable: ${binPath}`];\n\n if (isBunRuntime()) {\n lines.push(\"Allow Bun to run postinstall scripts for native binaries and reinstall:\");\n for (const block of bunInstallBlocks) {\n lines.push(`${block.label}:`);\n for (const command of block.commands) {\n lines.push(` ${command}`);\n }\n }\n lines.push(`Or run: chmod +x \"${binPath}\"`);\n return lines.join(\"\\n\");\n }\n\n lines.push(\"Postinstall scripts for native packages did not run, so the binary was left non-executable.\");\n if (genericInstallCommands && genericInstallCommands.length > 0) {\n lines.push(\"Reinstall with scripts enabled:\");\n for (const command of genericInstallCommands) {\n lines.push(` ${command}`);\n }\n } else {\n lines.push(\"Reinstall with scripts enabled for:\");\n lines.push(` ${trustPackages}`);\n }\n lines.push(`Or run: chmod +x \"${binPath}\"`);\n return lines.join(\"\\n\");\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAmBO,SAAS,eAAwB;AACtC,MAAI,OAAO,SAAS,UAAU,QAAQ,SAAU,QAAO;AACvD,QAAM,YAAY,SAAS,KAAK,yBAAyB;AACzD,SAAO,UAAU,SAAS,MAAM;AAClC;AAEA,IAAM,oBAAoB,oBAAI,IAAI,CAAC,UAAU,SAAS,SAAS,CAAC;AAEhE,SAAS,kBAAkB,OAAyB;AAClD,MAAI,CAAC,SAAS,OAAO,UAAU,SAAU,QAAO;AAChD,QAAM,OAAQ,MAA6B;AAC3C,SAAO,OAAO,SAAS,YAAY,kBAAkB,IAAI,IAAI;AAC/D;AASO,SAAS,iBAAiB,SAAiB,IAAuB;AACvE,MAAI,QAAQ,aAAa,SAAS;AAChC,WAAO;AAAA,EACT;AAEA,MAAI;AACF,OAAG,WAAW,SAAS,GAAG,UAAU,IAAI;AACxC,WAAO;AAAA,EACT,QAAQ;AAAA,EAER;AAEA,MAAI;AACF,OAAG,UAAU,SAAS,GAAK;AAC3B,WAAO;AAAA,EACT,SAAS,OAAO;AACd,QAAI,kBAAkB,KAAK,GAAG;AAC5B,aAAO;AAAA,IACT;AACA,UAAM;AAAA,EACR;AACF;AAEO,SAAS,iCAAiC,SAAoD;AACnG,QAAM,EAAE,SAAS,eAAe,kBAAkB,wBAAwB,WAAW,IAAI;AAEzF,QAAM,QAAQ,cAAc;AAC5B,QAAM,QAAQ,CAAC,GAAG,KAAK,8BAA8B,OAAO,EAAE;AAE9D,MAAI,aAAa,GAAG;AAClB,UAAM,KAAK,yEAAyE;AACpF,eAAW,SAAS,kBAAkB;AACpC,YAAM,KAAK,GAAG,MAAM,KAAK,GAAG;AAC5B,iBAAW,WAAW,MAAM,UAAU;AACpC,cAAM,KAAK,KAAK,OAAO,EAAE;AAAA,MAC3B;AAAA,IACF;AACA,UAAM,KAAK,qBAAqB,OAAO,GAAG;AAC1C,WAAO,MAAM,KAAK,IAAI;AAAA,EACxB;AAEA,QAAM,KAAK,6FAA6F;AACxG,MAAI,0BAA0B,uBAAuB,SAAS,GAAG;AAC/D,UAAM,KAAK,iCAAiC;AAC5C,eAAW,WAAW,wBAAwB;AAC5C,YAAM,KAAK,KAAK,OAAO,EAAE;AAAA,IAC3B;AAAA,EACF,OAAO;AACL,UAAM,KAAK,qCAAqC;AAChD,UAAM,KAAK,KAAK,aAAa,EAAE;AAAA,EACjC;AACA,QAAM,KAAK,qBAAqB,OAAO,GAAG;AAC1C,SAAO,MAAM,KAAK,IAAI;AACxB;","names":[]}
|
package/dist/index.js
CHANGED
|
@@ -30,19 +30,11 @@ function assertExecutable(binPath, fs) {
|
|
|
30
30
|
}
|
|
31
31
|
}
|
|
32
32
|
function formatNonExecutableBinaryMessage(options) {
|
|
33
|
-
const {
|
|
34
|
-
binPath,
|
|
35
|
-
trustPackages,
|
|
36
|
-
bunInstallBlocks,
|
|
37
|
-
genericInstallCommands,
|
|
38
|
-
binaryName
|
|
39
|
-
} = options;
|
|
33
|
+
const { binPath, trustPackages, bunInstallBlocks, genericInstallCommands, binaryName } = options;
|
|
40
34
|
const label = binaryName ?? "sandbox-agent";
|
|
41
35
|
const lines = [`${label} binary is not executable: ${binPath}`];
|
|
42
36
|
if (isBunRuntime()) {
|
|
43
|
-
lines.push(
|
|
44
|
-
"Allow Bun to run postinstall scripts for native binaries and reinstall:"
|
|
45
|
-
);
|
|
37
|
+
lines.push("Allow Bun to run postinstall scripts for native binaries and reinstall:");
|
|
46
38
|
for (const block of bunInstallBlocks) {
|
|
47
39
|
lines.push(`${block.label}:`);
|
|
48
40
|
for (const command of block.commands) {
|
|
@@ -52,9 +44,7 @@ function formatNonExecutableBinaryMessage(options) {
|
|
|
52
44
|
lines.push(`Or run: chmod +x "${binPath}"`);
|
|
53
45
|
return lines.join("\n");
|
|
54
46
|
}
|
|
55
|
-
lines.push(
|
|
56
|
-
"Postinstall scripts for native packages did not run, so the binary was left non-executable."
|
|
57
|
-
);
|
|
47
|
+
lines.push("Postinstall scripts for native packages did not run, so the binary was left non-executable.");
|
|
58
48
|
if (genericInstallCommands && genericInstallCommands.length > 0) {
|
|
59
49
|
lines.push("Reinstall with scripts enabled:");
|
|
60
50
|
for (const command of genericInstallCommands) {
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["export type InstallCommandBlock = {\n
|
|
1
|
+
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["export type InstallCommandBlock = {\n label: string;\n commands: string[];\n};\n\nexport type NonExecutableBinaryMessageOptions = {\n binPath: string;\n trustPackages: string;\n bunInstallBlocks: InstallCommandBlock[];\n genericInstallCommands?: string[];\n binaryName?: string;\n};\n\nexport type FsSubset = {\n accessSync: (path: string, mode?: number) => void;\n chmodSync: (path: string, mode: number) => void;\n constants: { X_OK: number };\n};\n\nexport function isBunRuntime(): boolean {\n if (typeof process?.versions?.bun === \"string\") return true;\n const userAgent = process?.env?.npm_config_user_agent || \"\";\n return userAgent.includes(\"bun/\");\n}\n\nconst PERMISSION_ERRORS = new Set([\"EACCES\", \"EPERM\", \"ENOEXEC\"]);\n\nfunction isPermissionError(error: unknown): boolean {\n if (!error || typeof error !== \"object\") return false;\n const code = (error as { code?: unknown }).code;\n return typeof code === \"string\" && PERMISSION_ERRORS.has(code);\n}\n\n/**\n * Checks if a binary is executable and attempts to make it executable if not.\n * Returns true if the binary is (or was made) executable, false if it couldn't\n * be made executable due to permission errors. Throws for other errors.\n *\n * Requires fs to be passed in to avoid static imports that break browser builds.\n */\nexport function assertExecutable(binPath: string, fs: FsSubset): boolean {\n if (process.platform === \"win32\") {\n return true;\n }\n\n try {\n fs.accessSync(binPath, fs.constants.X_OK);\n return true;\n } catch {\n // Not executable, try to fix\n }\n\n try {\n fs.chmodSync(binPath, 0o755);\n return true;\n } catch (error) {\n if (isPermissionError(error)) {\n return false;\n }\n throw error;\n }\n}\n\nexport function formatNonExecutableBinaryMessage(options: NonExecutableBinaryMessageOptions): string {\n const { binPath, trustPackages, bunInstallBlocks, genericInstallCommands, binaryName } = options;\n\n const label = binaryName ?? \"sandbox-agent\";\n const lines = [`${label} binary is not executable: ${binPath}`];\n\n if (isBunRuntime()) {\n lines.push(\"Allow Bun to run postinstall scripts for native binaries and reinstall:\");\n for (const block of bunInstallBlocks) {\n lines.push(`${block.label}:`);\n for (const command of block.commands) {\n lines.push(` ${command}`);\n }\n }\n lines.push(`Or run: chmod +x \"${binPath}\"`);\n return lines.join(\"\\n\");\n }\n\n lines.push(\"Postinstall scripts for native packages did not run, so the binary was left non-executable.\");\n if (genericInstallCommands && genericInstallCommands.length > 0) {\n lines.push(\"Reinstall with scripts enabled:\");\n for (const command of genericInstallCommands) {\n lines.push(` ${command}`);\n }\n } else {\n lines.push(\"Reinstall with scripts enabled for:\");\n lines.push(` ${trustPackages}`);\n }\n lines.push(`Or run: chmod +x \"${binPath}\"`);\n return lines.join(\"\\n\");\n}\n"],"mappings":";AAmBO,SAAS,eAAwB;AACtC,MAAI,OAAO,SAAS,UAAU,QAAQ,SAAU,QAAO;AACvD,QAAM,YAAY,SAAS,KAAK,yBAAyB;AACzD,SAAO,UAAU,SAAS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