@aiden-ade/sandbox-agent 0.1.10 → 0.1.12
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 +263 -54
- package/package.json +11 -11
package/dist/index.cjs
CHANGED
|
@@ -7181,6 +7181,128 @@ Prefer relative paths and keep your work scoped to this project.`
|
|
|
7181
7181
|
}
|
|
7182
7182
|
};
|
|
7183
7183
|
|
|
7184
|
+
// src/core-agent.ts
|
|
7185
|
+
var import_node_os2 = require("os");
|
|
7186
|
+
|
|
7187
|
+
// src/cli-executable.ts
|
|
7188
|
+
var import_node_fs = require("fs");
|
|
7189
|
+
var import_node_os = require("os");
|
|
7190
|
+
var import_node_path = require("path");
|
|
7191
|
+
var PROVIDER_CLI_COMMANDS = {
|
|
7192
|
+
claude_cli: { provider: "claude_cli", command: "claude", envVar: "AIDEN_CLAUDE_PATH" },
|
|
7193
|
+
codex: { provider: "codex", command: "codex", envVar: "AIDEN_CODEX_PATH" },
|
|
7194
|
+
gemini: { provider: "gemini", command: "gemini", envVar: "AIDEN_GEMINI_PATH" }
|
|
7195
|
+
};
|
|
7196
|
+
var BACKEND_CLI_COMMANDS = {
|
|
7197
|
+
claude_cli: "claude",
|
|
7198
|
+
codex: "codex",
|
|
7199
|
+
codex_app_server: "codex",
|
|
7200
|
+
gemini_cli: "gemini",
|
|
7201
|
+
gemini: "gemini"
|
|
7202
|
+
};
|
|
7203
|
+
function pathSeparator() {
|
|
7204
|
+
return (0, import_node_os.platform)() === "win32" ? ";" : ":";
|
|
7205
|
+
}
|
|
7206
|
+
function splitPath(pathValue) {
|
|
7207
|
+
if (!pathValue) return [];
|
|
7208
|
+
return pathValue.split(pathSeparator()).filter(Boolean);
|
|
7209
|
+
}
|
|
7210
|
+
function isRunnableFile(path) {
|
|
7211
|
+
if (!(0, import_node_fs.existsSync)(path)) return false;
|
|
7212
|
+
if ((0, import_node_os.platform)() === "win32") return true;
|
|
7213
|
+
try {
|
|
7214
|
+
(0, import_node_fs.accessSync)(path, import_node_fs.constants.X_OK);
|
|
7215
|
+
return true;
|
|
7216
|
+
} catch {
|
|
7217
|
+
return false;
|
|
7218
|
+
}
|
|
7219
|
+
}
|
|
7220
|
+
function windowsCommandCandidates(command, pathExt) {
|
|
7221
|
+
const trimmed = command.trim();
|
|
7222
|
+
if (!trimmed) return [];
|
|
7223
|
+
const hasExtension = /\.[a-z0-9]+$/i.test(trimmed);
|
|
7224
|
+
if (hasExtension) return [trimmed];
|
|
7225
|
+
const extensions = pathExt.split(";").map((ext) => ext.trim()).filter(Boolean);
|
|
7226
|
+
return [trimmed, ...extensions.map((ext) => `${trimmed}${ext}`)];
|
|
7227
|
+
}
|
|
7228
|
+
function augmentCliPath(env) {
|
|
7229
|
+
const home = env.HOME || env.USERPROFILE || (0, import_node_os.homedir)();
|
|
7230
|
+
const isWin = (0, import_node_os.platform)() === "win32";
|
|
7231
|
+
const extraPaths = isWin ? [
|
|
7232
|
+
(0, import_node_path.join)(home, "AppData", "Roaming", "npm"),
|
|
7233
|
+
(0, import_node_path.join)(home, "AppData", "Local", "Programs", "Microsoft", "WindowsApps"),
|
|
7234
|
+
(0, import_node_path.join)(home, ".local", "bin"),
|
|
7235
|
+
"C:\\Program Files\\nodejs",
|
|
7236
|
+
"C:\\Program Files\\Git\\cmd"
|
|
7237
|
+
] : [
|
|
7238
|
+
(0, import_node_path.join)(home, ".local", "bin"),
|
|
7239
|
+
(0, import_node_path.join)(home, ".local", "node", "bin"),
|
|
7240
|
+
(0, import_node_path.join)(home, ".bun", "bin"),
|
|
7241
|
+
(0, import_node_path.join)(home, ".cargo", "bin"),
|
|
7242
|
+
"/opt/homebrew/bin",
|
|
7243
|
+
"/usr/local/bin"
|
|
7244
|
+
];
|
|
7245
|
+
const basePath = env.PATH ?? "";
|
|
7246
|
+
const existing = new Set(splitPath(basePath));
|
|
7247
|
+
const missing = extraPaths.filter((dir) => !existing.has(dir));
|
|
7248
|
+
if (missing.length === 0) return env;
|
|
7249
|
+
return {
|
|
7250
|
+
...env,
|
|
7251
|
+
PATH: missing.length > 0 ? `${missing.join(pathSeparator())}${pathSeparator()}${basePath}` : basePath
|
|
7252
|
+
};
|
|
7253
|
+
}
|
|
7254
|
+
function resolveCliExecutable(command, env = process.env) {
|
|
7255
|
+
const trimmed = command.trim();
|
|
7256
|
+
if (!trimmed) return null;
|
|
7257
|
+
const enriched = augmentCliPath(env);
|
|
7258
|
+
const home = enriched.HOME || enriched.USERPROFILE || (0, import_node_os.homedir)();
|
|
7259
|
+
const isWin = (0, import_node_os.platform)() === "win32";
|
|
7260
|
+
const pathExt = enriched.PATHEXT ?? (isWin ? ".EXE;.CMD;.BAT;.COM" : "");
|
|
7261
|
+
const names = isWin ? windowsCommandCandidates(trimmed, pathExt) : [trimmed];
|
|
7262
|
+
const candidates = [];
|
|
7263
|
+
for (const name of names) {
|
|
7264
|
+
if (name.includes("/") || name.includes("\\")) {
|
|
7265
|
+
candidates.push(name);
|
|
7266
|
+
continue;
|
|
7267
|
+
}
|
|
7268
|
+
for (const dir of splitPath(enriched.PATH)) {
|
|
7269
|
+
candidates.push((0, import_node_path.join)(dir, name));
|
|
7270
|
+
}
|
|
7271
|
+
candidates.push(
|
|
7272
|
+
(0, import_node_path.join)(home, ".local", "bin", name),
|
|
7273
|
+
(0, import_node_path.join)(home, ".local", "node", "bin", name)
|
|
7274
|
+
);
|
|
7275
|
+
if (!isWin) {
|
|
7276
|
+
candidates.push((0, import_node_path.join)("/opt/homebrew/bin", name), (0, import_node_path.join)("/usr/local/bin", name));
|
|
7277
|
+
} else {
|
|
7278
|
+
candidates.push((0, import_node_path.join)(home, "AppData", "Roaming", "npm", name));
|
|
7279
|
+
}
|
|
7280
|
+
}
|
|
7281
|
+
const seen = /* @__PURE__ */ new Set();
|
|
7282
|
+
for (const candidate of candidates) {
|
|
7283
|
+
if (seen.has(candidate)) continue;
|
|
7284
|
+
seen.add(candidate);
|
|
7285
|
+
if (isRunnableFile(candidate)) return candidate;
|
|
7286
|
+
}
|
|
7287
|
+
return null;
|
|
7288
|
+
}
|
|
7289
|
+
function resolveProviderCliCommand(provider) {
|
|
7290
|
+
const spec = PROVIDER_CLI_COMMANDS[provider];
|
|
7291
|
+
const override = process.env[spec.envVar]?.trim();
|
|
7292
|
+
if (override) {
|
|
7293
|
+
return resolveCliExecutable(override) ?? (isRunnableFile(override) ? override : null);
|
|
7294
|
+
}
|
|
7295
|
+
return resolveCliExecutable(spec.command);
|
|
7296
|
+
}
|
|
7297
|
+
function resolveBackendRuntimeCommand(backendKind, env = process.env) {
|
|
7298
|
+
if (!backendKind) return void 0;
|
|
7299
|
+
const command = BACKEND_CLI_COMMANDS[backendKind];
|
|
7300
|
+
if (!command) return void 0;
|
|
7301
|
+
const envOverride = command === "codex" ? env.AIDEN_CODEX_PATH : command === "claude" ? env.AIDEN_CLAUDE_PATH : command === "gemini" ? env.AIDEN_GEMINI_PATH : void 0;
|
|
7302
|
+
const resolved = resolveCliExecutable(envOverride?.trim() || command, env);
|
|
7303
|
+
return resolved ?? void 0;
|
|
7304
|
+
}
|
|
7305
|
+
|
|
7184
7306
|
// src/core-agent.ts
|
|
7185
7307
|
var CoreAgent = class _CoreAgent extends BaseMachineAgent {
|
|
7186
7308
|
childProcess = null;
|
|
@@ -7308,18 +7430,23 @@ var CoreAgent = class _CoreAgent extends BaseMachineAgent {
|
|
|
7308
7430
|
};
|
|
7309
7431
|
}
|
|
7310
7432
|
async buildCliEnvironment() {
|
|
7311
|
-
const loginEnv = process.env;
|
|
7312
7433
|
const env = {};
|
|
7313
|
-
for (const [key, value2] of Object.entries(
|
|
7434
|
+
for (const [key, value2] of Object.entries(process.env)) {
|
|
7314
7435
|
if (value2 !== void 0) env[key] = value2;
|
|
7315
7436
|
}
|
|
7316
|
-
const
|
|
7317
|
-
|
|
7318
|
-
|
|
7319
|
-
|
|
7320
|
-
|
|
7321
|
-
|
|
7322
|
-
|
|
7437
|
+
const augmented = augmentCliPath(env);
|
|
7438
|
+
if ((0, import_node_os2.platform)() !== "win32") {
|
|
7439
|
+
const home = augmented.HOME ?? "/home/user";
|
|
7440
|
+
const extraPaths = [`${home}/.local/node/bin`, `${home}/.local/bin`];
|
|
7441
|
+
const separator = ":";
|
|
7442
|
+
const basePath = augmented.PATH ?? "";
|
|
7443
|
+
const existingSegments = new Set(basePath.split(separator).filter(Boolean));
|
|
7444
|
+
const missing = extraPaths.filter((p) => !existingSegments.has(p));
|
|
7445
|
+
if (missing.length > 0) {
|
|
7446
|
+
augmented.PATH = `${missing.join(separator)}${separator}${basePath}`;
|
|
7447
|
+
}
|
|
7448
|
+
}
|
|
7449
|
+
return augmented;
|
|
7323
7450
|
}
|
|
7324
7451
|
buildExtraSystemPromptParts(config) {
|
|
7325
7452
|
const parts2 = [];
|
|
@@ -11142,7 +11269,7 @@ var WSClient = class {
|
|
|
11142
11269
|
};
|
|
11143
11270
|
|
|
11144
11271
|
// src/version.ts
|
|
11145
|
-
var AGENT_VERSION = "0.1.
|
|
11272
|
+
var AGENT_VERSION = "0.1.12";
|
|
11146
11273
|
|
|
11147
11274
|
// src/sandbox.ts
|
|
11148
11275
|
async function runSandbox(config) {
|
|
@@ -11318,29 +11445,70 @@ async function runSandbox(config) {
|
|
|
11318
11445
|
}
|
|
11319
11446
|
|
|
11320
11447
|
// src/daemon.ts
|
|
11321
|
-
var
|
|
11448
|
+
var import_node_fs2 = require("fs");
|
|
11322
11449
|
var import_node_http = __toESM(require("http"), 1);
|
|
11323
11450
|
var import_node_crypto = require("crypto");
|
|
11324
|
-
var
|
|
11325
|
-
var
|
|
11451
|
+
var import_node_os3 = require("os");
|
|
11452
|
+
var import_node_path2 = require("path");
|
|
11326
11453
|
var import_node_child_process = require("child_process");
|
|
11327
|
-
var
|
|
11454
|
+
var PRODUCTION_API_URL = "https://api.aiden-platform.com";
|
|
11455
|
+
var PRODUCTION_WS_URL = "wss://ws.aiden-platform.com";
|
|
11456
|
+
var LOCAL_API_URL = "http://localhost:8400";
|
|
11457
|
+
var LOCAL_WS_URL = "ws://localhost:8401";
|
|
11458
|
+
function getConfigPath() {
|
|
11459
|
+
return process.env.AIDEN_AGENT_CONFIG_PATH ?? (0, import_node_path2.join)((0, import_node_os3.homedir)(), ".aiden", "agent", "config.json");
|
|
11460
|
+
}
|
|
11461
|
+
function getEndpointDefaultsPath() {
|
|
11462
|
+
return process.env.AIDEN_AGENT_ENDPOINTS_PATH ?? (0, import_node_path2.join)((0, import_node_path2.dirname)(getConfigPath()), "endpoints.json");
|
|
11463
|
+
}
|
|
11328
11464
|
function readConfig() {
|
|
11329
|
-
|
|
11330
|
-
|
|
11465
|
+
const configPath = getConfigPath();
|
|
11466
|
+
if (!(0, import_node_fs2.existsSync)(configPath)) return {};
|
|
11467
|
+
return JSON.parse((0, import_node_fs2.readFileSync)(configPath, "utf8"));
|
|
11468
|
+
}
|
|
11469
|
+
function readEndpointDefaults() {
|
|
11470
|
+
const endpointsPath = getEndpointDefaultsPath();
|
|
11471
|
+
if (!(0, import_node_fs2.existsSync)(endpointsPath)) return {};
|
|
11472
|
+
try {
|
|
11473
|
+
return JSON.parse((0, import_node_fs2.readFileSync)(endpointsPath, "utf8"));
|
|
11474
|
+
} catch {
|
|
11475
|
+
return {};
|
|
11476
|
+
}
|
|
11331
11477
|
}
|
|
11332
11478
|
function writeConfig(config) {
|
|
11333
|
-
|
|
11334
|
-
(0,
|
|
11479
|
+
const configPath = getConfigPath();
|
|
11480
|
+
(0, import_node_fs2.mkdirSync)((0, import_node_path2.dirname)(configPath), { recursive: true, mode: 448 });
|
|
11481
|
+
(0, import_node_fs2.writeFileSync)(configPath, JSON.stringify(config, null, 2), { mode: 384 });
|
|
11335
11482
|
}
|
|
11336
11483
|
function removeConfig() {
|
|
11337
|
-
|
|
11484
|
+
const configPath = getConfigPath();
|
|
11485
|
+
if ((0, import_node_fs2.existsSync)(configPath)) (0, import_node_fs2.rmSync)(configPath, { force: true });
|
|
11338
11486
|
}
|
|
11339
11487
|
function argValue(args, name) {
|
|
11340
11488
|
const index = args.indexOf(name);
|
|
11341
11489
|
if (index === -1) return void 0;
|
|
11342
11490
|
return args[index + 1];
|
|
11343
11491
|
}
|
|
11492
|
+
function resolveEndpointProfile(args) {
|
|
11493
|
+
const profile = argValue(args, "--profile") ?? process.env.AIDEN_AGENT_PROFILE;
|
|
11494
|
+
if (!profile) return "production";
|
|
11495
|
+
if (profile === "production" || profile === "prod") return "production";
|
|
11496
|
+
if (profile === "local" || profile === "dev") return "local";
|
|
11497
|
+
throw new Error("Unsupported endpoint profile. Use --profile production or --profile local.");
|
|
11498
|
+
}
|
|
11499
|
+
function resolveEndpoints(args, stored = {}) {
|
|
11500
|
+
const requestedProfile = resolveEndpointProfile(args);
|
|
11501
|
+
const profileApiUrl = requestedProfile === "local" ? LOCAL_API_URL : PRODUCTION_API_URL;
|
|
11502
|
+
const profileWsUrl = requestedProfile === "local" ? LOCAL_WS_URL : PRODUCTION_WS_URL;
|
|
11503
|
+
const endpointDefaults = readEndpointDefaults();
|
|
11504
|
+
const apiUrl = argValue(args, "--api-url") ?? process.env.AIDEN_API_URL ?? stored.apiUrl ?? endpointDefaults.apiUrl ?? profileApiUrl;
|
|
11505
|
+
const wsUrl = argValue(args, "--ws-url") ?? process.env.AIDEN_WS_URL ?? stored.wsUrl ?? endpointDefaults.wsUrl ?? profileWsUrl;
|
|
11506
|
+
const endpointProfile = apiUrl === profileApiUrl && wsUrl === profileWsUrl ? requestedProfile : apiUrl === endpointDefaults.apiUrl && wsUrl === endpointDefaults.wsUrl && endpointDefaults.endpointProfile ? endpointDefaults.endpointProfile : "custom";
|
|
11507
|
+
return { apiUrl, wsUrl, endpointProfile };
|
|
11508
|
+
}
|
|
11509
|
+
function isLocalEndpoint(url2) {
|
|
11510
|
+
return Boolean(url2 && /^(https?|wss?):\/\/(localhost|127\.0\.0\.1)(:\d+)?(\/|$)/.test(url2));
|
|
11511
|
+
}
|
|
11344
11512
|
function getLocalApiPort(args, stored) {
|
|
11345
11513
|
const raw = argValue(args, "--local-api-port") ?? process.env.AIDEN_AGENT_LOCAL_API_PORT;
|
|
11346
11514
|
if (raw) return Number.parseInt(raw, 10);
|
|
@@ -11351,20 +11519,26 @@ function sleep(ms) {
|
|
|
11351
11519
|
return new Promise((resolve2) => setTimeout(resolve2, ms));
|
|
11352
11520
|
}
|
|
11353
11521
|
function commandVersion(command, args = ["--version"]) {
|
|
11354
|
-
const
|
|
11522
|
+
const executable = resolveCliExecutable(command) ?? command;
|
|
11523
|
+
const result = (0, import_node_child_process.spawnSync)(executable, args, {
|
|
11524
|
+
encoding: "utf8",
|
|
11525
|
+
timeout: 3e3,
|
|
11526
|
+
env: augmentCliPath(process.env)
|
|
11527
|
+
});
|
|
11355
11528
|
if (result.error || result.status !== 0) return void 0;
|
|
11356
11529
|
return (result.stdout || result.stderr).split("\n")[0]?.trim() || void 0;
|
|
11357
11530
|
}
|
|
11531
|
+
function normalizeBackendKind(backendKind) {
|
|
11532
|
+
if (backendKind === "codex") return "codex_app_server";
|
|
11533
|
+
return backendKind;
|
|
11534
|
+
}
|
|
11358
11535
|
function discoverCapabilities() {
|
|
11359
11536
|
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
11360
|
-
const providers = [
|
|
11361
|
-
{ provider: "claude_cli", command: process.env.AIDEN_CLAUDE_PATH ?? "claude" },
|
|
11362
|
-
{ provider: "codex", command: process.env.AIDEN_CODEX_PATH ?? "codex" },
|
|
11363
|
-
{ provider: "gemini", command: process.env.AIDEN_GEMINI_PATH ?? "gemini" }
|
|
11364
|
-
];
|
|
11537
|
+
const providers = ["claude_cli", "codex", "gemini"];
|
|
11365
11538
|
return {
|
|
11366
|
-
agents: providers.map((
|
|
11367
|
-
const
|
|
11539
|
+
agents: providers.map((provider) => {
|
|
11540
|
+
const executable = resolveProviderCliCommand(provider);
|
|
11541
|
+
const version = executable ? commandVersion(executable) : void 0;
|
|
11368
11542
|
return {
|
|
11369
11543
|
provider,
|
|
11370
11544
|
available: Boolean(version),
|
|
@@ -11449,16 +11623,19 @@ var RuntimePresenter = class {
|
|
|
11449
11623
|
}
|
|
11450
11624
|
};
|
|
11451
11625
|
async function setupDaemon(args) {
|
|
11452
|
-
const apiUrl =
|
|
11453
|
-
const wsUrl = argValue(args, "--ws-url") ?? process.env.AIDEN_WS_URL ?? "ws://localhost:8401";
|
|
11626
|
+
const { apiUrl, wsUrl, endpointProfile } = resolveEndpoints(args);
|
|
11454
11627
|
const teamId = argValue(args, "--team") ?? process.env.AIDEN_TEAM_ID;
|
|
11455
11628
|
const setupToken = argValue(args, "--setup-token") ?? process.env.AIDEN_RUNTIME_SETUP_TOKEN;
|
|
11456
11629
|
const token = argValue(args, "--token") ?? process.env.AIDEN_SETUP_TOKEN;
|
|
11457
|
-
const displayName = argValue(args, "--name") ?? (0,
|
|
11630
|
+
const displayName = argValue(args, "--name") ?? (0, import_node_os3.hostname)();
|
|
11458
11631
|
const legacyLocalMachineId = argValue(args, "--legacy-local-machine-id") ?? process.env.AIDEN_LEGACY_LOCAL_MACHINE_ID;
|
|
11632
|
+
const scope = argValue(args, "--scope") ?? process.env.AIDEN_RUNTIME_SCOPE ?? "team";
|
|
11633
|
+
if (scope !== "team" && scope !== "user") {
|
|
11634
|
+
throw new Error("setup --scope must be either 'team' or 'user'");
|
|
11635
|
+
}
|
|
11459
11636
|
if (!setupToken && (!teamId || !token)) {
|
|
11460
11637
|
throw new Error(
|
|
11461
|
-
"setup requires
|
|
11638
|
+
"setup requires --setup-token <token> or --team <team-id> and --token <aiden PAT>.\nFor normal setup, copy the setup token from Aiden and run: aiden-agent setup --setup-token <token>\nFor browser authorization, run: aiden-agent login"
|
|
11462
11639
|
);
|
|
11463
11640
|
}
|
|
11464
11641
|
const response = await fetch(`${apiUrl}/public/runtimes${setupToken ? "/register-with-setup-token" : ""}`, {
|
|
@@ -11471,18 +11648,18 @@ async function setupDaemon(args) {
|
|
|
11471
11648
|
...teamId ? { teamId } : {},
|
|
11472
11649
|
...setupToken ? { setupToken } : {},
|
|
11473
11650
|
displayName,
|
|
11474
|
-
hostname: (0,
|
|
11651
|
+
hostname: (0, import_node_os3.hostname)(),
|
|
11475
11652
|
...legacyLocalMachineId ? { legacyLocalMachineId } : {},
|
|
11476
11653
|
runtimeKind: "machine",
|
|
11477
11654
|
managementKind: "user_managed",
|
|
11478
11655
|
hostKind: "daemon",
|
|
11479
11656
|
lifecycle: "durable",
|
|
11480
|
-
ownerType:
|
|
11481
|
-
visibility:
|
|
11657
|
+
ownerType: scope,
|
|
11658
|
+
visibility: scope,
|
|
11482
11659
|
capabilities: discoverCapabilities(),
|
|
11483
11660
|
metadata: {
|
|
11484
|
-
platform: (0,
|
|
11485
|
-
arch: (0,
|
|
11661
|
+
platform: (0, import_node_os3.platform)(),
|
|
11662
|
+
arch: (0, import_node_os3.arch)(),
|
|
11486
11663
|
agentVersion: AGENT_VERSION
|
|
11487
11664
|
}
|
|
11488
11665
|
})
|
|
@@ -11494,6 +11671,7 @@ async function setupDaemon(args) {
|
|
|
11494
11671
|
writeConfig({
|
|
11495
11672
|
apiUrl,
|
|
11496
11673
|
wsUrl,
|
|
11674
|
+
endpointProfile,
|
|
11497
11675
|
teamId,
|
|
11498
11676
|
runtimeId: body.runtime.id,
|
|
11499
11677
|
runtimeToken: body.runtimeToken,
|
|
@@ -11501,23 +11679,22 @@ async function setupDaemon(args) {
|
|
|
11501
11679
|
localApiToken: (0, import_node_crypto.randomBytes)(24).toString("hex"),
|
|
11502
11680
|
displayName: body.runtime.displayName ?? displayName
|
|
11503
11681
|
});
|
|
11504
|
-
console.info("[aiden-agent] Runtime registered", { runtimeId: body.runtime.id, configPath:
|
|
11682
|
+
console.info("[aiden-agent] Runtime registered", { runtimeId: body.runtime.id, configPath: getConfigPath() });
|
|
11505
11683
|
}
|
|
11506
11684
|
async function loginWithDeviceCode(args) {
|
|
11507
|
-
const apiUrl =
|
|
11508
|
-
const
|
|
11509
|
-
const displayName = argValue(args, "--name") ?? (0, import_node_os.hostname)();
|
|
11685
|
+
const { apiUrl, wsUrl, endpointProfile } = resolveEndpoints(args);
|
|
11686
|
+
const displayName = argValue(args, "--name") ?? (0, import_node_os3.hostname)();
|
|
11510
11687
|
const maxPolls = Number.parseInt(argValue(args, "--max-polls") ?? "300", 10);
|
|
11511
11688
|
const start = await fetch(`${apiUrl}/public/runtimes/device-authorizations`, {
|
|
11512
11689
|
method: "POST",
|
|
11513
11690
|
headers: { "content-type": "application/json" },
|
|
11514
11691
|
body: JSON.stringify({
|
|
11515
11692
|
displayName,
|
|
11516
|
-
hostname: (0,
|
|
11693
|
+
hostname: (0, import_node_os3.hostname)(),
|
|
11517
11694
|
capabilities: discoverCapabilities(),
|
|
11518
11695
|
metadata: {
|
|
11519
|
-
platform: (0,
|
|
11520
|
-
arch: (0,
|
|
11696
|
+
platform: (0, import_node_os3.platform)(),
|
|
11697
|
+
arch: (0, import_node_os3.arch)(),
|
|
11521
11698
|
agentVersion: AGENT_VERSION
|
|
11522
11699
|
}
|
|
11523
11700
|
})
|
|
@@ -11544,6 +11721,7 @@ async function loginWithDeviceCode(args) {
|
|
|
11544
11721
|
writeConfig({
|
|
11545
11722
|
apiUrl,
|
|
11546
11723
|
wsUrl,
|
|
11724
|
+
endpointProfile,
|
|
11547
11725
|
teamId: body.runtime.teamId ?? void 0,
|
|
11548
11726
|
runtimeId: body.runtime.id,
|
|
11549
11727
|
runtimeToken: body.runtimeToken,
|
|
@@ -11551,7 +11729,7 @@ async function loginWithDeviceCode(args) {
|
|
|
11551
11729
|
localApiToken: (0, import_node_crypto.randomBytes)(24).toString("hex"),
|
|
11552
11730
|
displayName: body.runtime.displayName ?? displayName
|
|
11553
11731
|
});
|
|
11554
|
-
console.info("[aiden-agent] Runtime registered", { runtimeId: body.runtime.id, configPath:
|
|
11732
|
+
console.info("[aiden-agent] Runtime registered", { runtimeId: body.runtime.id, configPath: getConfigPath() });
|
|
11555
11733
|
return;
|
|
11556
11734
|
}
|
|
11557
11735
|
throw new Error("device authorization timed out before approval");
|
|
@@ -11612,11 +11790,21 @@ async function startDaemon(args) {
|
|
|
11612
11790
|
socket.emit("agent.rejected", { runId: payload.runId, message: "Run is already active" });
|
|
11613
11791
|
return;
|
|
11614
11792
|
}
|
|
11793
|
+
const backendKind = normalizeBackendKind(payload.backendKind);
|
|
11794
|
+
const runtimeCommand = resolveBackendRuntimeCommand(backendKind ?? payload.backendKind);
|
|
11795
|
+
if (!runtimeCommand && backendKind) {
|
|
11796
|
+
socket.emit("agent.rejected", {
|
|
11797
|
+
runId: payload.runId,
|
|
11798
|
+
message: `CLI command not found for ${backendKind}. Install it or set the full path via AIDEN_CODEX_PATH / AIDEN_CLAUDE_PATH / AIDEN_GEMINI_PATH.`
|
|
11799
|
+
});
|
|
11800
|
+
return;
|
|
11801
|
+
}
|
|
11615
11802
|
socket.emit("agent.accepted", { runId: payload.runId });
|
|
11616
11803
|
pushLog(`accepted run=${payload.runId}`);
|
|
11617
11804
|
const presenter = new RuntimePresenter(socket, payload.conversationId, payload.runId);
|
|
11618
11805
|
const agent = new CoreAgent(presenter, {
|
|
11619
|
-
backendKind
|
|
11806
|
+
backendKind,
|
|
11807
|
+
runtimeCommand
|
|
11620
11808
|
});
|
|
11621
11809
|
activeAgents.set(payload.runId, agent);
|
|
11622
11810
|
const cwd = payload.projectPath ?? process.cwd();
|
|
@@ -11625,7 +11813,8 @@ async function startDaemon(args) {
|
|
|
11625
11813
|
maxIterations: payload.maxIterations ?? 50,
|
|
11626
11814
|
teamPath: cwd,
|
|
11627
11815
|
cwd,
|
|
11628
|
-
backendKind
|
|
11816
|
+
backendKind,
|
|
11817
|
+
runtimeCommand,
|
|
11629
11818
|
agentId: payload.agentId,
|
|
11630
11819
|
agentPrompt: payload.agentPrompt,
|
|
11631
11820
|
mode: payload.mode ?? "agent",
|
|
@@ -11796,17 +11985,27 @@ async function revokeRuntimeToken(args) {
|
|
|
11796
11985
|
}
|
|
11797
11986
|
function logoutDaemon() {
|
|
11798
11987
|
removeConfig();
|
|
11799
|
-
console.info("[aiden-agent] Runtime config removed", { configPath:
|
|
11988
|
+
console.info("[aiden-agent] Runtime config removed", { configPath: getConfigPath() });
|
|
11800
11989
|
}
|
|
11801
11990
|
function printStatus() {
|
|
11802
11991
|
const config = readConfig();
|
|
11992
|
+
const configured = Boolean(config.runtimeId && config.runtimeToken && config.wsUrl);
|
|
11993
|
+
const warnings = [];
|
|
11994
|
+
if ((isLocalEndpoint(config.apiUrl) || isLocalEndpoint(config.wsUrl)) && config.endpointProfile !== "local") {
|
|
11995
|
+
warnings.push("Configured endpoint points at localhost. Use --profile local only for local development.");
|
|
11996
|
+
}
|
|
11803
11997
|
console.info(JSON.stringify({
|
|
11804
|
-
|
|
11998
|
+
mode: "runtime",
|
|
11999
|
+
configured,
|
|
11805
12000
|
runtimeId: config.runtimeId ?? null,
|
|
12001
|
+
apiUrl: config.apiUrl ?? null,
|
|
11806
12002
|
wsUrl: config.wsUrl ?? null,
|
|
12003
|
+
endpointProfile: config.endpointProfile ?? null,
|
|
11807
12004
|
localApiPort: config.localApiPort ?? null,
|
|
11808
12005
|
hasLocalApiToken: Boolean(config.localApiToken),
|
|
11809
|
-
configPath:
|
|
12006
|
+
configPath: getConfigPath(),
|
|
12007
|
+
note: configured ? "Durable runtime config is present. Start it with: aiden-agent daemon" : "No durable runtime configured. Cloud sandbox sessions are launched by Aiden with session env vars and do not appear in this local config.",
|
|
12008
|
+
warnings
|
|
11810
12009
|
}, null, 2));
|
|
11811
12010
|
}
|
|
11812
12011
|
async function printDoctor(args = []) {
|
|
@@ -11834,10 +12033,13 @@ async function printDoctor(args = []) {
|
|
|
11834
12033
|
}
|
|
11835
12034
|
console.info(JSON.stringify({
|
|
11836
12035
|
version: AGENT_VERSION,
|
|
11837
|
-
configPath:
|
|
12036
|
+
configPath: getConfigPath(),
|
|
11838
12037
|
configured: Boolean(config.runtimeId && config.runtimeToken && config.wsUrl),
|
|
11839
12038
|
runtimeId: config.runtimeId ?? null,
|
|
12039
|
+
apiUrl: config.apiUrl ?? null,
|
|
11840
12040
|
wsUrl: config.wsUrl ?? null,
|
|
12041
|
+
endpointProfile: config.endpointProfile ?? null,
|
|
12042
|
+
warnings: (isLocalEndpoint(config.apiUrl) || isLocalEndpoint(config.wsUrl)) && config.endpointProfile !== "local" ? ["Configured endpoint points at localhost. Use --profile local only for local development."] : [],
|
|
11841
12043
|
synced,
|
|
11842
12044
|
syncError,
|
|
11843
12045
|
capabilities
|
|
@@ -11858,12 +12060,17 @@ Commands:
|
|
|
11858
12060
|
doctor Check local CLI capabilities
|
|
11859
12061
|
logout Remove local runtime configuration
|
|
11860
12062
|
token Rotate or revoke the configured runtime token
|
|
11861
|
-
run-session
|
|
12063
|
+
run-session Internal: run one ephemeral sandbox/session from AIDEN_* env vars
|
|
11862
12064
|
|
|
11863
12065
|
Common flows:
|
|
11864
|
-
aiden-agent
|
|
11865
|
-
aiden-agent
|
|
12066
|
+
aiden-agent login
|
|
12067
|
+
aiden-agent setup --setup-token <token>
|
|
12068
|
+
aiden-agent setup --setup-token <token> --scope user
|
|
11866
12069
|
aiden-agent daemon
|
|
12070
|
+
|
|
12071
|
+
Local development:
|
|
12072
|
+
aiden-agent login --profile local
|
|
12073
|
+
aiden-agent setup --profile local --setup-token <token>
|
|
11867
12074
|
`;
|
|
11868
12075
|
function hasRunSessionEnv(env) {
|
|
11869
12076
|
return Boolean(
|
|
@@ -11899,7 +12106,9 @@ async function runSessionFromEnv() {
|
|
|
11899
12106
|
const effortLevel = process.env.AIDEN_EFFORT_LEVEL || void 0;
|
|
11900
12107
|
const providerSessionId = process.env.AIDEN_PROVIDER_SESSION_ID || void 0;
|
|
11901
12108
|
if (!wsUrl || !sessionId || !taskId || !sessionToken || task == null) {
|
|
11902
|
-
throw new Error(
|
|
12109
|
+
throw new Error(
|
|
12110
|
+
"run-session is an internal Aiden sandbox/session command and must be launched by Aiden with session env vars. Missing required env vars: AIDEN_WS_URL, AIDEN_SESSION_ID, AIDEN_TASK_ID, AIDEN_SESSION_TOKEN, AIDEN_TASK"
|
|
12111
|
+
);
|
|
11903
12112
|
}
|
|
11904
12113
|
console.info("[aiden-agent] Starting", { sessionId, taskId, projectPath, backendKind, agentId, mode, model, version: AGENT_VERSION });
|
|
11905
12114
|
await runSandbox({
|
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.12",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"bin": {
|
|
6
6
|
"aiden-agent": "./dist/index.cjs"
|
|
@@ -11,21 +11,21 @@
|
|
|
11
11
|
"publishConfig": {
|
|
12
12
|
"access": "public"
|
|
13
13
|
},
|
|
14
|
-
"scripts": {
|
|
15
|
-
"build": "tsup",
|
|
16
|
-
"dev": "tsx src/index.ts",
|
|
17
|
-
"test": "vitest run",
|
|
18
|
-
"type-check": "tsc --noEmit"
|
|
19
|
-
},
|
|
20
14
|
"dependencies": {},
|
|
21
15
|
"devDependencies": {
|
|
22
|
-
"@aiden/agent-core": "workspace:*",
|
|
23
|
-
"@aiden/shared": "workspace:*",
|
|
24
16
|
"socket.io-client": "^4.8.0",
|
|
25
17
|
"socket.io": "^4.8.0",
|
|
26
18
|
"@types/node": "^22.0.0",
|
|
27
19
|
"tsup": "^8.5.1",
|
|
28
20
|
"tsx": "^4.19.0",
|
|
29
|
-
"typescript": "~5.9.3"
|
|
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
30
|
}
|
|
31
|
-
}
|
|
31
|
+
}
|