@aiden-ade/sandbox-agent 0.1.12 → 0.1.13
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 +109 -20
- package/package.json +12 -11
package/dist/index.cjs
CHANGED
|
@@ -5304,17 +5304,39 @@ function buildPlanModePrefix(promptText) {
|
|
|
5304
5304
|
promptText
|
|
5305
5305
|
].join("\n");
|
|
5306
5306
|
}
|
|
5307
|
-
function
|
|
5307
|
+
function planCliSpawn(command, args, env = process.env) {
|
|
5308
5308
|
const isWindows = process.platform === "win32";
|
|
5309
|
-
|
|
5309
|
+
const comSpec = env.ComSpec ?? process.env.ComSpec ?? "cmd.exe";
|
|
5310
|
+
if (isWindows && /\.(cmd|bat)$/i.test(command)) {
|
|
5311
|
+
return {
|
|
5312
|
+
file: comSpec,
|
|
5313
|
+
args: ["/d", "/s", "/c", command, ...args],
|
|
5314
|
+
shell: false,
|
|
5315
|
+
windowsHide: true
|
|
5316
|
+
};
|
|
5317
|
+
}
|
|
5318
|
+
if (isWindows && /[\\/]/.test(command) && /\.exe$/i.test(command)) {
|
|
5319
|
+
return { file: command, args, shell: false, windowsHide: true };
|
|
5320
|
+
}
|
|
5321
|
+
return {
|
|
5322
|
+
file: command,
|
|
5323
|
+
args,
|
|
5324
|
+
shell: isWindows,
|
|
5325
|
+
windowsHide: isWindows ? true : void 0
|
|
5326
|
+
};
|
|
5327
|
+
}
|
|
5328
|
+
function spawnCli(command, args, context) {
|
|
5329
|
+
const plan = planCliSpawn(command, args, context.env);
|
|
5330
|
+
return (0, import_child_process.spawn)(plan.file, plan.args, {
|
|
5310
5331
|
cwd: context.cwd,
|
|
5311
5332
|
env: context.env,
|
|
5312
5333
|
stdio: ["pipe", "pipe", "pipe"],
|
|
5313
|
-
shell:
|
|
5334
|
+
shell: plan.shell,
|
|
5335
|
+
windowsHide: plan.windowsHide,
|
|
5314
5336
|
// Detached on Unix creates a new process group so we can kill the entire tree
|
|
5315
5337
|
// (CLI tools spawn child processes for tool execution that would otherwise be orphaned).
|
|
5316
5338
|
// On Windows, detached opens a new console — shell mode handles grouping instead.
|
|
5317
|
-
detached:
|
|
5339
|
+
detached: process.platform !== "win32"
|
|
5318
5340
|
});
|
|
5319
5341
|
}
|
|
5320
5342
|
function createGenericCliBackend(options) {
|
|
@@ -7186,6 +7208,7 @@ var import_node_os2 = require("os");
|
|
|
7186
7208
|
|
|
7187
7209
|
// src/cli-executable.ts
|
|
7188
7210
|
var import_node_fs = require("fs");
|
|
7211
|
+
var import_node_child_process = require("child_process");
|
|
7189
7212
|
var import_node_os = require("os");
|
|
7190
7213
|
var import_node_path = require("path");
|
|
7191
7214
|
var PROVIDER_CLI_COMMANDS = {
|
|
@@ -7200,6 +7223,54 @@ var BACKEND_CLI_COMMANDS = {
|
|
|
7200
7223
|
gemini_cli: "gemini",
|
|
7201
7224
|
gemini: "gemini"
|
|
7202
7225
|
};
|
|
7226
|
+
var resolvedCliCache = /* @__PURE__ */ new Map();
|
|
7227
|
+
function getDaemonCliEnvironment() {
|
|
7228
|
+
return augmentCliPath(process.env);
|
|
7229
|
+
}
|
|
7230
|
+
function cacheResolvedCli(command, resolvedPath) {
|
|
7231
|
+
resolvedCliCache.set(command, resolvedPath);
|
|
7232
|
+
}
|
|
7233
|
+
function getCachedResolvedCli(command) {
|
|
7234
|
+
return resolvedCliCache.get(command);
|
|
7235
|
+
}
|
|
7236
|
+
function resolveViaWhere(command, env) {
|
|
7237
|
+
if ((0, import_node_os.platform)() !== "win32") return null;
|
|
7238
|
+
const whereExe = (0, import_node_path.join)(env.SystemRoot ?? process.env.SystemRoot ?? "C:\\Windows", "System32", "where.exe");
|
|
7239
|
+
if (!(0, import_node_fs.existsSync)(whereExe)) return null;
|
|
7240
|
+
const result = (0, import_node_child_process.spawnSync)(whereExe, [command], {
|
|
7241
|
+
encoding: "utf8",
|
|
7242
|
+
env,
|
|
7243
|
+
windowsHide: true,
|
|
7244
|
+
timeout: 3e3
|
|
7245
|
+
});
|
|
7246
|
+
if (result.error || result.status !== 0) return null;
|
|
7247
|
+
for (const line of result.stdout.split(/\r?\n/)) {
|
|
7248
|
+
const trimmed = line.trim();
|
|
7249
|
+
if (!trimmed) continue;
|
|
7250
|
+
if (isRunnableFile(trimmed)) return trimmed;
|
|
7251
|
+
}
|
|
7252
|
+
return null;
|
|
7253
|
+
}
|
|
7254
|
+
function runCliVersionProbe(executable, env, args = ["--version"]) {
|
|
7255
|
+
const isWin = (0, import_node_os.platform)() === "win32";
|
|
7256
|
+
if (isWin && /\.(cmd|bat)$/i.test(executable)) {
|
|
7257
|
+
const comSpec = env.ComSpec ?? process.env.ComSpec ?? "cmd.exe";
|
|
7258
|
+
return (0, import_node_child_process.spawnSync)(comSpec, ["/d", "/s", "/c", executable, ...args], {
|
|
7259
|
+
encoding: "utf8",
|
|
7260
|
+
timeout: 3e3,
|
|
7261
|
+
env,
|
|
7262
|
+
windowsHide: true
|
|
7263
|
+
});
|
|
7264
|
+
}
|
|
7265
|
+
const useShell = isWin && !/[\\/]/.test(executable);
|
|
7266
|
+
return (0, import_node_child_process.spawnSync)(executable, args, {
|
|
7267
|
+
encoding: "utf8",
|
|
7268
|
+
timeout: 3e3,
|
|
7269
|
+
env,
|
|
7270
|
+
shell: useShell,
|
|
7271
|
+
windowsHide: isWin ? true : void 0
|
|
7272
|
+
});
|
|
7273
|
+
}
|
|
7203
7274
|
function pathSeparator() {
|
|
7204
7275
|
return (0, import_node_os.platform)() === "win32" ? ";" : ":";
|
|
7205
7276
|
}
|
|
@@ -7251,9 +7322,15 @@ function augmentCliPath(env) {
|
|
|
7251
7322
|
PATH: missing.length > 0 ? `${missing.join(pathSeparator())}${pathSeparator()}${basePath}` : basePath
|
|
7252
7323
|
};
|
|
7253
7324
|
}
|
|
7254
|
-
function resolveCliExecutable(command, env =
|
|
7325
|
+
function resolveCliExecutable(command, env = getDaemonCliEnvironment()) {
|
|
7255
7326
|
const trimmed = command.trim();
|
|
7256
7327
|
if (!trimmed) return null;
|
|
7328
|
+
const cached = resolvedCliCache.get(trimmed);
|
|
7329
|
+
if (cached && isRunnableFile(cached)) return cached;
|
|
7330
|
+
if ((trimmed.includes("/") || trimmed.includes("\\")) && isRunnableFile(trimmed)) {
|
|
7331
|
+
resolvedCliCache.set(trimmed, trimmed);
|
|
7332
|
+
return trimmed;
|
|
7333
|
+
}
|
|
7257
7334
|
const enriched = augmentCliPath(env);
|
|
7258
7335
|
const home = enriched.HOME || enriched.USERPROFILE || (0, import_node_os.homedir)();
|
|
7259
7336
|
const isWin = (0, import_node_os.platform)() === "win32";
|
|
@@ -7282,24 +7359,39 @@ function resolveCliExecutable(command, env = process.env) {
|
|
|
7282
7359
|
for (const candidate of candidates) {
|
|
7283
7360
|
if (seen.has(candidate)) continue;
|
|
7284
7361
|
seen.add(candidate);
|
|
7285
|
-
if (isRunnableFile(candidate))
|
|
7362
|
+
if (isRunnableFile(candidate)) {
|
|
7363
|
+
resolvedCliCache.set(trimmed, candidate);
|
|
7364
|
+
return candidate;
|
|
7365
|
+
}
|
|
7366
|
+
}
|
|
7367
|
+
const viaWhere = resolveViaWhere(trimmed, enriched);
|
|
7368
|
+
if (viaWhere) {
|
|
7369
|
+
resolvedCliCache.set(trimmed, viaWhere);
|
|
7370
|
+
return viaWhere;
|
|
7286
7371
|
}
|
|
7287
7372
|
return null;
|
|
7288
7373
|
}
|
|
7289
|
-
function resolveProviderCliCommand(provider) {
|
|
7374
|
+
function resolveProviderCliCommand(provider, env = getDaemonCliEnvironment()) {
|
|
7290
7375
|
const spec = PROVIDER_CLI_COMMANDS[provider];
|
|
7291
7376
|
const override = process.env[spec.envVar]?.trim();
|
|
7292
7377
|
if (override) {
|
|
7293
|
-
|
|
7378
|
+
const resolved2 = resolveCliExecutable(override, env) ?? (isRunnableFile(override) ? override : null);
|
|
7379
|
+
if (resolved2) cacheResolvedCli(spec.command, resolved2);
|
|
7380
|
+
return resolved2;
|
|
7294
7381
|
}
|
|
7295
|
-
|
|
7382
|
+
const resolved = resolveCliExecutable(spec.command, env);
|
|
7383
|
+
if (resolved) cacheResolvedCli(spec.command, resolved);
|
|
7384
|
+
return resolved;
|
|
7296
7385
|
}
|
|
7297
|
-
function resolveBackendRuntimeCommand(backendKind, env =
|
|
7386
|
+
function resolveBackendRuntimeCommand(backendKind, env = getDaemonCliEnvironment()) {
|
|
7298
7387
|
if (!backendKind) return void 0;
|
|
7299
7388
|
const command = BACKEND_CLI_COMMANDS[backendKind];
|
|
7300
7389
|
if (!command) return void 0;
|
|
7390
|
+
const cached = getCachedResolvedCli(command);
|
|
7391
|
+
if (cached && isRunnableFile(cached)) return cached;
|
|
7301
7392
|
const envOverride = command === "codex" ? env.AIDEN_CODEX_PATH : command === "claude" ? env.AIDEN_CLAUDE_PATH : command === "gemini" ? env.AIDEN_GEMINI_PATH : void 0;
|
|
7302
7393
|
const resolved = resolveCliExecutable(envOverride?.trim() || command, env);
|
|
7394
|
+
if (resolved) cacheResolvedCli(command, resolved);
|
|
7303
7395
|
return resolved ?? void 0;
|
|
7304
7396
|
}
|
|
7305
7397
|
|
|
@@ -7434,7 +7526,7 @@ var CoreAgent = class _CoreAgent extends BaseMachineAgent {
|
|
|
7434
7526
|
for (const [key, value2] of Object.entries(process.env)) {
|
|
7435
7527
|
if (value2 !== void 0) env[key] = value2;
|
|
7436
7528
|
}
|
|
7437
|
-
const augmented =
|
|
7529
|
+
const augmented = getDaemonCliEnvironment();
|
|
7438
7530
|
if ((0, import_node_os2.platform)() !== "win32") {
|
|
7439
7531
|
const home = augmented.HOME ?? "/home/user";
|
|
7440
7532
|
const extraPaths = [`${home}/.local/node/bin`, `${home}/.local/bin`];
|
|
@@ -11269,7 +11361,7 @@ var WSClient = class {
|
|
|
11269
11361
|
};
|
|
11270
11362
|
|
|
11271
11363
|
// src/version.ts
|
|
11272
|
-
var AGENT_VERSION = "0.1.
|
|
11364
|
+
var AGENT_VERSION = "0.1.13";
|
|
11273
11365
|
|
|
11274
11366
|
// src/sandbox.ts
|
|
11275
11367
|
async function runSandbox(config) {
|
|
@@ -11450,7 +11542,6 @@ var import_node_http = __toESM(require("http"), 1);
|
|
|
11450
11542
|
var import_node_crypto = require("crypto");
|
|
11451
11543
|
var import_node_os3 = require("os");
|
|
11452
11544
|
var import_node_path2 = require("path");
|
|
11453
|
-
var import_node_child_process = require("child_process");
|
|
11454
11545
|
var PRODUCTION_API_URL = "https://api.aiden-platform.com";
|
|
11455
11546
|
var PRODUCTION_WS_URL = "wss://ws.aiden-platform.com";
|
|
11456
11547
|
var LOCAL_API_URL = "http://localhost:8400";
|
|
@@ -11519,12 +11610,10 @@ function sleep(ms) {
|
|
|
11519
11610
|
return new Promise((resolve2) => setTimeout(resolve2, ms));
|
|
11520
11611
|
}
|
|
11521
11612
|
function commandVersion(command, args = ["--version"]) {
|
|
11522
|
-
const
|
|
11523
|
-
const
|
|
11524
|
-
|
|
11525
|
-
|
|
11526
|
-
env: augmentCliPath(process.env)
|
|
11527
|
-
});
|
|
11613
|
+
const env = getDaemonCliEnvironment();
|
|
11614
|
+
const executable = command === "claude" ? resolveProviderCliCommand("claude_cli", env) : command === "codex" ? resolveProviderCliCommand("codex", env) : command === "gemini" ? resolveProviderCliCommand("gemini", env) : resolveCliExecutable(command, env);
|
|
11615
|
+
if (!executable) return void 0;
|
|
11616
|
+
const result = runCliVersionProbe(executable, env, args);
|
|
11528
11617
|
if (result.error || result.status !== 0) return void 0;
|
|
11529
11618
|
return (result.stdout || result.stderr).split("\n")[0]?.trim() || void 0;
|
|
11530
11619
|
}
|
|
@@ -11795,7 +11884,7 @@ async function startDaemon(args) {
|
|
|
11795
11884
|
if (!runtimeCommand && backendKind) {
|
|
11796
11885
|
socket.emit("agent.rejected", {
|
|
11797
11886
|
runId: payload.runId,
|
|
11798
|
-
message: `CLI command not found for ${backendKind}. Install
|
|
11887
|
+
message: `CLI command not found for ${backendKind}. Install the provider CLI and restart the daemon.`
|
|
11799
11888
|
});
|
|
11800
11889
|
return;
|
|
11801
11890
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aiden-ade/sandbox-agent",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.13",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"bin": {
|
|
6
6
|
"aiden-agent": "./dist/index.cjs"
|
|
@@ -11,21 +11,22 @@
|
|
|
11
11
|
"publishConfig": {
|
|
12
12
|
"access": "public"
|
|
13
13
|
},
|
|
14
|
+
"scripts": {
|
|
15
|
+
"build": "tsup",
|
|
16
|
+
"dev": "tsx src/index.ts",
|
|
17
|
+
"prepack": "pnpm build",
|
|
18
|
+
"test": "vitest run",
|
|
19
|
+
"type-check": "tsc --noEmit"
|
|
20
|
+
},
|
|
14
21
|
"dependencies": {},
|
|
15
22
|
"devDependencies": {
|
|
23
|
+
"@aiden/agent-core": "workspace:*",
|
|
24
|
+
"@aiden/shared": "workspace:*",
|
|
16
25
|
"socket.io-client": "^4.8.0",
|
|
17
26
|
"socket.io": "^4.8.0",
|
|
18
27
|
"@types/node": "^22.0.0",
|
|
19
28
|
"tsup": "^8.5.1",
|
|
20
29
|
"tsx": "^4.19.0",
|
|
21
|
-
"typescript": "~5.9.3"
|
|
22
|
-
"@aiden/agent-core": "0.1.0",
|
|
23
|
-
"@aiden/shared": "0.1.0"
|
|
24
|
-
},
|
|
25
|
-
"scripts": {
|
|
26
|
-
"build": "tsup",
|
|
27
|
-
"dev": "tsx src/index.ts",
|
|
28
|
-
"test": "vitest run",
|
|
29
|
-
"type-check": "tsc --noEmit"
|
|
30
|
+
"typescript": "~5.9.3"
|
|
30
31
|
}
|
|
31
|
-
}
|
|
32
|
+
}
|