@sandbox-agent/cli-shared 0.1.6 → 0.1.7
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 +9 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +9 -2
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -56,8 +56,15 @@ function assertExecutable(binPath, fs) {
|
|
|
56
56
|
}
|
|
57
57
|
}
|
|
58
58
|
function formatNonExecutableBinaryMessage(options) {
|
|
59
|
-
const {
|
|
60
|
-
|
|
59
|
+
const {
|
|
60
|
+
binPath,
|
|
61
|
+
trustPackages,
|
|
62
|
+
bunInstallBlocks,
|
|
63
|
+
genericInstallCommands,
|
|
64
|
+
binaryName
|
|
65
|
+
} = options;
|
|
66
|
+
const label = binaryName ?? "sandbox-agent";
|
|
67
|
+
const lines = [`${label} binary is not executable: ${binPath}`];
|
|
61
68
|
if (isBunRuntime()) {
|
|
62
69
|
lines.push(
|
|
63
70
|
"Allow Bun to run postinstall scripts for native binaries and reinstall:"
|
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["export type InstallCommandBlock = {\n\tlabel: string;\n\tcommands: string[];\n};\n\nexport type NonExecutableBinaryMessageOptions = {\n\tbinPath: string;\n\ttrustPackages: string;\n\tbunInstallBlocks: InstallCommandBlock[];\n\tgenericInstallCommands?: string[];\n};\n\nexport type FsSubset = {\n\taccessSync: (path: string, mode?: number) => void;\n\tchmodSync: (path: string, mode: number) => void;\n\tconstants: { X_OK: number };\n};\n\nexport function isBunRuntime(): boolean {\n\tif (typeof process?.versions?.bun === \"string\") return true;\n\tconst userAgent = process?.env?.npm_config_user_agent || \"\";\n\treturn userAgent.includes(\"bun/\");\n}\n\nconst PERMISSION_ERRORS = new Set([\"EACCES\", \"EPERM\", \"ENOEXEC\"]);\n\nfunction isPermissionError(error: unknown): boolean {\n\tif (!error || typeof error !== \"object\") return false;\n\tconst code = (error as { code?: unknown }).code;\n\treturn 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\tif (process.platform === \"win32\") {\n\t\treturn true;\n\t}\n\n\ttry {\n\t\tfs.accessSync(binPath, fs.constants.X_OK);\n\t\treturn true;\n\t} catch {\n\t\t// Not executable, try to fix\n\t}\n\n\ttry {\n\t\tfs.chmodSync(binPath, 0o755);\n\t\treturn true;\n\t} catch (error) {\n\t\tif (isPermissionError(error)) {\n\t\t\treturn false;\n\t\t}\n\t\tthrow error;\n\t}\n}\n\nexport function formatNonExecutableBinaryMessage(\n\toptions: NonExecutableBinaryMessageOptions,\n): string {\n\tconst {
|
|
1
|
+
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["export type InstallCommandBlock = {\n\tlabel: string;\n\tcommands: string[];\n};\n\nexport type NonExecutableBinaryMessageOptions = {\n\tbinPath: string;\n\ttrustPackages: string;\n\tbunInstallBlocks: InstallCommandBlock[];\n\tgenericInstallCommands?: string[];\n\tbinaryName?: string;\n};\n\nexport type FsSubset = {\n\taccessSync: (path: string, mode?: number) => void;\n\tchmodSync: (path: string, mode: number) => void;\n\tconstants: { X_OK: number };\n};\n\nexport function isBunRuntime(): boolean {\n\tif (typeof process?.versions?.bun === \"string\") return true;\n\tconst userAgent = process?.env?.npm_config_user_agent || \"\";\n\treturn userAgent.includes(\"bun/\");\n}\n\nconst PERMISSION_ERRORS = new Set([\"EACCES\", \"EPERM\", \"ENOEXEC\"]);\n\nfunction isPermissionError(error: unknown): boolean {\n\tif (!error || typeof error !== \"object\") return false;\n\tconst code = (error as { code?: unknown }).code;\n\treturn 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\tif (process.platform === \"win32\") {\n\t\treturn true;\n\t}\n\n\ttry {\n\t\tfs.accessSync(binPath, fs.constants.X_OK);\n\t\treturn true;\n\t} catch {\n\t\t// Not executable, try to fix\n\t}\n\n\ttry {\n\t\tfs.chmodSync(binPath, 0o755);\n\t\treturn true;\n\t} catch (error) {\n\t\tif (isPermissionError(error)) {\n\t\t\treturn false;\n\t\t}\n\t\tthrow error;\n\t}\n}\n\nexport function formatNonExecutableBinaryMessage(\n\toptions: NonExecutableBinaryMessageOptions,\n): string {\n\tconst {\n\t\tbinPath,\n\t\ttrustPackages,\n\t\tbunInstallBlocks,\n\t\tgenericInstallCommands,\n\t\tbinaryName,\n\t} = options;\n\n\tconst label = binaryName ?? \"sandbox-agent\";\n\tconst lines = [`${label} binary is not executable: ${binPath}`];\n\n\tif (isBunRuntime()) {\n\t\tlines.push(\n\t\t\t\"Allow Bun to run postinstall scripts for native binaries and reinstall:\",\n\t\t);\n\t\tfor (const block of bunInstallBlocks) {\n\t\t\tlines.push(`${block.label}:`);\n\t\t\tfor (const command of block.commands) {\n\t\t\t\tlines.push(` ${command}`);\n\t\t\t}\n\t\t}\n\t\tlines.push(`Or run: chmod +x \"${binPath}\"`);\n\t\treturn lines.join(\"\\n\");\n\t}\n\n\tlines.push(\n\t\t\"Postinstall scripts for native packages did not run, so the binary was left non-executable.\",\n\t);\n\tif (genericInstallCommands && genericInstallCommands.length > 0) {\n\t\tlines.push(\"Reinstall with scripts enabled:\");\n\t\tfor (const command of genericInstallCommands) {\n\t\t\tlines.push(` ${command}`);\n\t\t}\n\t} else {\n\t\tlines.push(\"Reinstall with scripts enabled for:\");\n\t\tlines.push(` ${trustPackages}`);\n\t}\n\tlines.push(`Or run: chmod +x \"${binPath}\"`);\n\treturn lines.join(\"\\n\");\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAmBO,SAAS,eAAwB;AACvC,MAAI,OAAO,SAAS,UAAU,QAAQ,SAAU,QAAO;AACvD,QAAM,YAAY,SAAS,KAAK,yBAAyB;AACzD,SAAO,UAAU,SAAS,MAAM;AACjC;AAEA,IAAM,oBAAoB,oBAAI,IAAI,CAAC,UAAU,SAAS,SAAS,CAAC;AAEhE,SAAS,kBAAkB,OAAyB;AACnD,MAAI,CAAC,SAAS,OAAO,UAAU,SAAU,QAAO;AAChD,QAAM,OAAQ,MAA6B;AAC3C,SAAO,OAAO,SAAS,YAAY,kBAAkB,IAAI,IAAI;AAC9D;AASO,SAAS,iBAAiB,SAAiB,IAAuB;AACxE,MAAI,QAAQ,aAAa,SAAS;AACjC,WAAO;AAAA,EACR;AAEA,MAAI;AACH,OAAG,WAAW,SAAS,GAAG,UAAU,IAAI;AACxC,WAAO;AAAA,EACR,QAAQ;AAAA,EAER;AAEA,MAAI;AACH,OAAG,UAAU,SAAS,GAAK;AAC3B,WAAO;AAAA,EACR,SAAS,OAAO;AACf,QAAI,kBAAkB,KAAK,GAAG;AAC7B,aAAO;AAAA,IACR;AACA,UAAM;AAAA,EACP;AACD;AAEO,SAAS,iCACf,SACS;AACT,QAAM;AAAA,IACL;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACD,IAAI;AAEJ,QAAM,QAAQ,cAAc;AAC5B,QAAM,QAAQ,CAAC,GAAG,KAAK,8BAA8B,OAAO,EAAE;AAE9D,MAAI,aAAa,GAAG;AACnB,UAAM;AAAA,MACL;AAAA,IACD;AACA,eAAW,SAAS,kBAAkB;AACrC,YAAM,KAAK,GAAG,MAAM,KAAK,GAAG;AAC5B,iBAAW,WAAW,MAAM,UAAU;AACrC,cAAM,KAAK,KAAK,OAAO,EAAE;AAAA,MAC1B;AAAA,IACD;AACA,UAAM,KAAK,qBAAqB,OAAO,GAAG;AAC1C,WAAO,MAAM,KAAK,IAAI;AAAA,EACvB;AAEA,QAAM;AAAA,IACL;AAAA,EACD;AACA,MAAI,0BAA0B,uBAAuB,SAAS,GAAG;AAChE,UAAM,KAAK,iCAAiC;AAC5C,eAAW,WAAW,wBAAwB;AAC7C,YAAM,KAAK,KAAK,OAAO,EAAE;AAAA,IAC1B;AAAA,EACD,OAAO;AACN,UAAM,KAAK,qCAAqC;AAChD,UAAM,KAAK,KAAK,aAAa,EAAE;AAAA,EAChC;AACA,QAAM,KAAK,qBAAqB,OAAO,GAAG;AAC1C,SAAO,MAAM,KAAK,IAAI;AACvB;","names":[]}
|
package/dist/index.d.cts
CHANGED
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -30,8 +30,15 @@ function assertExecutable(binPath, fs) {
|
|
|
30
30
|
}
|
|
31
31
|
}
|
|
32
32
|
function formatNonExecutableBinaryMessage(options) {
|
|
33
|
-
const {
|
|
34
|
-
|
|
33
|
+
const {
|
|
34
|
+
binPath,
|
|
35
|
+
trustPackages,
|
|
36
|
+
bunInstallBlocks,
|
|
37
|
+
genericInstallCommands,
|
|
38
|
+
binaryName
|
|
39
|
+
} = options;
|
|
40
|
+
const label = binaryName ?? "sandbox-agent";
|
|
41
|
+
const lines = [`${label} binary is not executable: ${binPath}`];
|
|
35
42
|
if (isBunRuntime()) {
|
|
36
43
|
lines.push(
|
|
37
44
|
"Allow Bun to run postinstall scripts for native binaries and reinstall:"
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["export type InstallCommandBlock = {\n\tlabel: string;\n\tcommands: string[];\n};\n\nexport type NonExecutableBinaryMessageOptions = {\n\tbinPath: string;\n\ttrustPackages: string;\n\tbunInstallBlocks: InstallCommandBlock[];\n\tgenericInstallCommands?: string[];\n};\n\nexport type FsSubset = {\n\taccessSync: (path: string, mode?: number) => void;\n\tchmodSync: (path: string, mode: number) => void;\n\tconstants: { X_OK: number };\n};\n\nexport function isBunRuntime(): boolean {\n\tif (typeof process?.versions?.bun === \"string\") return true;\n\tconst userAgent = process?.env?.npm_config_user_agent || \"\";\n\treturn userAgent.includes(\"bun/\");\n}\n\nconst PERMISSION_ERRORS = new Set([\"EACCES\", \"EPERM\", \"ENOEXEC\"]);\n\nfunction isPermissionError(error: unknown): boolean {\n\tif (!error || typeof error !== \"object\") return false;\n\tconst code = (error as { code?: unknown }).code;\n\treturn 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\tif (process.platform === \"win32\") {\n\t\treturn true;\n\t}\n\n\ttry {\n\t\tfs.accessSync(binPath, fs.constants.X_OK);\n\t\treturn true;\n\t} catch {\n\t\t// Not executable, try to fix\n\t}\n\n\ttry {\n\t\tfs.chmodSync(binPath, 0o755);\n\t\treturn true;\n\t} catch (error) {\n\t\tif (isPermissionError(error)) {\n\t\t\treturn false;\n\t\t}\n\t\tthrow error;\n\t}\n}\n\nexport function formatNonExecutableBinaryMessage(\n\toptions: NonExecutableBinaryMessageOptions,\n): string {\n\tconst {
|
|
1
|
+
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["export type InstallCommandBlock = {\n\tlabel: string;\n\tcommands: string[];\n};\n\nexport type NonExecutableBinaryMessageOptions = {\n\tbinPath: string;\n\ttrustPackages: string;\n\tbunInstallBlocks: InstallCommandBlock[];\n\tgenericInstallCommands?: string[];\n\tbinaryName?: string;\n};\n\nexport type FsSubset = {\n\taccessSync: (path: string, mode?: number) => void;\n\tchmodSync: (path: string, mode: number) => void;\n\tconstants: { X_OK: number };\n};\n\nexport function isBunRuntime(): boolean {\n\tif (typeof process?.versions?.bun === \"string\") return true;\n\tconst userAgent = process?.env?.npm_config_user_agent || \"\";\n\treturn userAgent.includes(\"bun/\");\n}\n\nconst PERMISSION_ERRORS = new Set([\"EACCES\", \"EPERM\", \"ENOEXEC\"]);\n\nfunction isPermissionError(error: unknown): boolean {\n\tif (!error || typeof error !== \"object\") return false;\n\tconst code = (error as { code?: unknown }).code;\n\treturn 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\tif (process.platform === \"win32\") {\n\t\treturn true;\n\t}\n\n\ttry {\n\t\tfs.accessSync(binPath, fs.constants.X_OK);\n\t\treturn true;\n\t} catch {\n\t\t// Not executable, try to fix\n\t}\n\n\ttry {\n\t\tfs.chmodSync(binPath, 0o755);\n\t\treturn true;\n\t} catch (error) {\n\t\tif (isPermissionError(error)) {\n\t\t\treturn false;\n\t\t}\n\t\tthrow error;\n\t}\n}\n\nexport function formatNonExecutableBinaryMessage(\n\toptions: NonExecutableBinaryMessageOptions,\n): string {\n\tconst {\n\t\tbinPath,\n\t\ttrustPackages,\n\t\tbunInstallBlocks,\n\t\tgenericInstallCommands,\n\t\tbinaryName,\n\t} = options;\n\n\tconst label = binaryName ?? \"sandbox-agent\";\n\tconst lines = [`${label} binary is not executable: ${binPath}`];\n\n\tif (isBunRuntime()) {\n\t\tlines.push(\n\t\t\t\"Allow Bun to run postinstall scripts for native binaries and reinstall:\",\n\t\t);\n\t\tfor (const block of bunInstallBlocks) {\n\t\t\tlines.push(`${block.label}:`);\n\t\t\tfor (const command of block.commands) {\n\t\t\t\tlines.push(` ${command}`);\n\t\t\t}\n\t\t}\n\t\tlines.push(`Or run: chmod +x \"${binPath}\"`);\n\t\treturn lines.join(\"\\n\");\n\t}\n\n\tlines.push(\n\t\t\"Postinstall scripts for native packages did not run, so the binary was left non-executable.\",\n\t);\n\tif (genericInstallCommands && genericInstallCommands.length > 0) {\n\t\tlines.push(\"Reinstall with scripts enabled:\");\n\t\tfor (const command of genericInstallCommands) {\n\t\t\tlines.push(` ${command}`);\n\t\t}\n\t} else {\n\t\tlines.push(\"Reinstall with scripts enabled for:\");\n\t\tlines.push(` ${trustPackages}`);\n\t}\n\tlines.push(`Or run: chmod +x \"${binPath}\"`);\n\treturn lines.join(\"\\n\");\n}\n"],"mappings":";AAmBO,SAAS,eAAwB;AACvC,MAAI,OAAO,SAAS,UAAU,QAAQ,SAAU,QAAO;AACvD,QAAM,YAAY,SAAS,KAAK,yBAAyB;AACzD,SAAO,UAAU,SAAS,MAAM;AACjC;AAEA,IAAM,oBAAoB,oBAAI,IAAI,CAAC,UAAU,SAAS,SAAS,CAAC;AAEhE,SAAS,kBAAkB,OAAyB;AACnD,MAAI,CAAC,SAAS,OAAO,UAAU,SAAU,QAAO;AAChD,QAAM,OAAQ,MAA6B;AAC3C,SAAO,OAAO,SAAS,YAAY,kBAAkB,IAAI,IAAI;AAC9D;AASO,SAAS,iBAAiB,SAAiB,IAAuB;AACxE,MAAI,QAAQ,aAAa,SAAS;AACjC,WAAO;AAAA,EACR;AAEA,MAAI;AACH,OAAG,WAAW,SAAS,GAAG,UAAU,IAAI;AACxC,WAAO;AAAA,EACR,QAAQ;AAAA,EAER;AAEA,MAAI;AACH,OAAG,UAAU,SAAS,GAAK;AAC3B,WAAO;AAAA,EACR,SAAS,OAAO;AACf,QAAI,kBAAkB,KAAK,GAAG;AAC7B,aAAO;AAAA,IACR;AACA,UAAM;AAAA,EACP;AACD;AAEO,SAAS,iCACf,SACS;AACT,QAAM;AAAA,IACL;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACD,IAAI;AAEJ,QAAM,QAAQ,cAAc;AAC5B,QAAM,QAAQ,CAAC,GAAG,KAAK,8BAA8B,OAAO,EAAE;AAE9D,MAAI,aAAa,GAAG;AACnB,UAAM;AAAA,MACL;AAAA,IACD;AACA,eAAW,SAAS,kBAAkB;AACrC,YAAM,KAAK,GAAG,MAAM,KAAK,GAAG;AAC5B,iBAAW,WAAW,MAAM,UAAU;AACrC,cAAM,KAAK,KAAK,OAAO,EAAE;AAAA,MAC1B;AAAA,IACD;AACA,UAAM,KAAK,qBAAqB,OAAO,GAAG;AAC1C,WAAO,MAAM,KAAK,IAAI;AAAA,EACvB;AAEA,QAAM;AAAA,IACL;AAAA,EACD;AACA,MAAI,0BAA0B,uBAAuB,SAAS,GAAG;AAChE,UAAM,KAAK,iCAAiC;AAC5C,eAAW,WAAW,wBAAwB;AAC7C,YAAM,KAAK,KAAK,OAAO,EAAE;AAAA,IAC1B;AAAA,EACD,OAAO;AACN,UAAM,KAAK,qCAAqC;AAChD,UAAM,KAAK,KAAK,aAAa,EAAE;AAAA,EAChC;AACA,QAAM,KAAK,qBAAqB,OAAO,GAAG;AAC1C,SAAO,MAAM,KAAK,IAAI;AACvB;","names":[]}
|