@aiden-ade/sandbox-agent 0.1.10 → 0.1.11
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 +89 -24
- package/package.json +2 -1
package/dist/index.cjs
CHANGED
|
@@ -11142,7 +11142,7 @@ var WSClient = class {
|
|
|
11142
11142
|
};
|
|
11143
11143
|
|
|
11144
11144
|
// src/version.ts
|
|
11145
|
-
var AGENT_VERSION = "0.1.
|
|
11145
|
+
var AGENT_VERSION = "0.1.11";
|
|
11146
11146
|
|
|
11147
11147
|
// src/sandbox.ts
|
|
11148
11148
|
async function runSandbox(config) {
|
|
@@ -11324,23 +11324,64 @@ var import_node_crypto = require("crypto");
|
|
|
11324
11324
|
var import_node_os = require("os");
|
|
11325
11325
|
var import_node_path = require("path");
|
|
11326
11326
|
var import_node_child_process = require("child_process");
|
|
11327
|
-
var
|
|
11327
|
+
var PRODUCTION_API_URL = "https://api.aiden-platform.com";
|
|
11328
|
+
var PRODUCTION_WS_URL = "wss://ws.aiden-platform.com";
|
|
11329
|
+
var LOCAL_API_URL = "http://localhost:8400";
|
|
11330
|
+
var LOCAL_WS_URL = "ws://localhost:8401";
|
|
11331
|
+
function getConfigPath() {
|
|
11332
|
+
return process.env.AIDEN_AGENT_CONFIG_PATH ?? (0, import_node_path.join)((0, import_node_os.homedir)(), ".aiden", "agent", "config.json");
|
|
11333
|
+
}
|
|
11334
|
+
function getEndpointDefaultsPath() {
|
|
11335
|
+
return process.env.AIDEN_AGENT_ENDPOINTS_PATH ?? (0, import_node_path.join)((0, import_node_path.dirname)(getConfigPath()), "endpoints.json");
|
|
11336
|
+
}
|
|
11328
11337
|
function readConfig() {
|
|
11329
|
-
|
|
11330
|
-
|
|
11338
|
+
const configPath = getConfigPath();
|
|
11339
|
+
if (!(0, import_node_fs.existsSync)(configPath)) return {};
|
|
11340
|
+
return JSON.parse((0, import_node_fs.readFileSync)(configPath, "utf8"));
|
|
11341
|
+
}
|
|
11342
|
+
function readEndpointDefaults() {
|
|
11343
|
+
const endpointsPath = getEndpointDefaultsPath();
|
|
11344
|
+
if (!(0, import_node_fs.existsSync)(endpointsPath)) return {};
|
|
11345
|
+
try {
|
|
11346
|
+
return JSON.parse((0, import_node_fs.readFileSync)(endpointsPath, "utf8"));
|
|
11347
|
+
} catch {
|
|
11348
|
+
return {};
|
|
11349
|
+
}
|
|
11331
11350
|
}
|
|
11332
11351
|
function writeConfig(config) {
|
|
11333
|
-
|
|
11334
|
-
(0, import_node_fs.
|
|
11352
|
+
const configPath = getConfigPath();
|
|
11353
|
+
(0, import_node_fs.mkdirSync)((0, import_node_path.dirname)(configPath), { recursive: true, mode: 448 });
|
|
11354
|
+
(0, import_node_fs.writeFileSync)(configPath, JSON.stringify(config, null, 2), { mode: 384 });
|
|
11335
11355
|
}
|
|
11336
11356
|
function removeConfig() {
|
|
11337
|
-
|
|
11357
|
+
const configPath = getConfigPath();
|
|
11358
|
+
if ((0, import_node_fs.existsSync)(configPath)) (0, import_node_fs.rmSync)(configPath, { force: true });
|
|
11338
11359
|
}
|
|
11339
11360
|
function argValue(args, name) {
|
|
11340
11361
|
const index = args.indexOf(name);
|
|
11341
11362
|
if (index === -1) return void 0;
|
|
11342
11363
|
return args[index + 1];
|
|
11343
11364
|
}
|
|
11365
|
+
function resolveEndpointProfile(args) {
|
|
11366
|
+
const profile = argValue(args, "--profile") ?? process.env.AIDEN_AGENT_PROFILE;
|
|
11367
|
+
if (!profile) return "production";
|
|
11368
|
+
if (profile === "production" || profile === "prod") return "production";
|
|
11369
|
+
if (profile === "local" || profile === "dev") return "local";
|
|
11370
|
+
throw new Error("Unsupported endpoint profile. Use --profile production or --profile local.");
|
|
11371
|
+
}
|
|
11372
|
+
function resolveEndpoints(args, stored = {}) {
|
|
11373
|
+
const requestedProfile = resolveEndpointProfile(args);
|
|
11374
|
+
const profileApiUrl = requestedProfile === "local" ? LOCAL_API_URL : PRODUCTION_API_URL;
|
|
11375
|
+
const profileWsUrl = requestedProfile === "local" ? LOCAL_WS_URL : PRODUCTION_WS_URL;
|
|
11376
|
+
const endpointDefaults = readEndpointDefaults();
|
|
11377
|
+
const apiUrl = argValue(args, "--api-url") ?? process.env.AIDEN_API_URL ?? stored.apiUrl ?? endpointDefaults.apiUrl ?? profileApiUrl;
|
|
11378
|
+
const wsUrl = argValue(args, "--ws-url") ?? process.env.AIDEN_WS_URL ?? stored.wsUrl ?? endpointDefaults.wsUrl ?? profileWsUrl;
|
|
11379
|
+
const endpointProfile = apiUrl === profileApiUrl && wsUrl === profileWsUrl ? requestedProfile : apiUrl === endpointDefaults.apiUrl && wsUrl === endpointDefaults.wsUrl && endpointDefaults.endpointProfile ? endpointDefaults.endpointProfile : "custom";
|
|
11380
|
+
return { apiUrl, wsUrl, endpointProfile };
|
|
11381
|
+
}
|
|
11382
|
+
function isLocalEndpoint(url2) {
|
|
11383
|
+
return Boolean(url2 && /^(https?|wss?):\/\/(localhost|127\.0\.0\.1)(:\d+)?(\/|$)/.test(url2));
|
|
11384
|
+
}
|
|
11344
11385
|
function getLocalApiPort(args, stored) {
|
|
11345
11386
|
const raw = argValue(args, "--local-api-port") ?? process.env.AIDEN_AGENT_LOCAL_API_PORT;
|
|
11346
11387
|
if (raw) return Number.parseInt(raw, 10);
|
|
@@ -11449,16 +11490,19 @@ var RuntimePresenter = class {
|
|
|
11449
11490
|
}
|
|
11450
11491
|
};
|
|
11451
11492
|
async function setupDaemon(args) {
|
|
11452
|
-
const apiUrl =
|
|
11453
|
-
const wsUrl = argValue(args, "--ws-url") ?? process.env.AIDEN_WS_URL ?? "ws://localhost:8401";
|
|
11493
|
+
const { apiUrl, wsUrl, endpointProfile } = resolveEndpoints(args);
|
|
11454
11494
|
const teamId = argValue(args, "--team") ?? process.env.AIDEN_TEAM_ID;
|
|
11455
11495
|
const setupToken = argValue(args, "--setup-token") ?? process.env.AIDEN_RUNTIME_SETUP_TOKEN;
|
|
11456
11496
|
const token = argValue(args, "--token") ?? process.env.AIDEN_SETUP_TOKEN;
|
|
11457
11497
|
const displayName = argValue(args, "--name") ?? (0, import_node_os.hostname)();
|
|
11458
11498
|
const legacyLocalMachineId = argValue(args, "--legacy-local-machine-id") ?? process.env.AIDEN_LEGACY_LOCAL_MACHINE_ID;
|
|
11499
|
+
const scope = argValue(args, "--scope") ?? process.env.AIDEN_RUNTIME_SCOPE ?? "team";
|
|
11500
|
+
if (scope !== "team" && scope !== "user") {
|
|
11501
|
+
throw new Error("setup --scope must be either 'team' or 'user'");
|
|
11502
|
+
}
|
|
11459
11503
|
if (!setupToken && (!teamId || !token)) {
|
|
11460
11504
|
throw new Error(
|
|
11461
|
-
"setup requires
|
|
11505
|
+
"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
11506
|
);
|
|
11463
11507
|
}
|
|
11464
11508
|
const response = await fetch(`${apiUrl}/public/runtimes${setupToken ? "/register-with-setup-token" : ""}`, {
|
|
@@ -11477,8 +11521,8 @@ async function setupDaemon(args) {
|
|
|
11477
11521
|
managementKind: "user_managed",
|
|
11478
11522
|
hostKind: "daemon",
|
|
11479
11523
|
lifecycle: "durable",
|
|
11480
|
-
ownerType:
|
|
11481
|
-
visibility:
|
|
11524
|
+
ownerType: scope,
|
|
11525
|
+
visibility: scope,
|
|
11482
11526
|
capabilities: discoverCapabilities(),
|
|
11483
11527
|
metadata: {
|
|
11484
11528
|
platform: (0, import_node_os.platform)(),
|
|
@@ -11494,6 +11538,7 @@ async function setupDaemon(args) {
|
|
|
11494
11538
|
writeConfig({
|
|
11495
11539
|
apiUrl,
|
|
11496
11540
|
wsUrl,
|
|
11541
|
+
endpointProfile,
|
|
11497
11542
|
teamId,
|
|
11498
11543
|
runtimeId: body.runtime.id,
|
|
11499
11544
|
runtimeToken: body.runtimeToken,
|
|
@@ -11501,11 +11546,10 @@ async function setupDaemon(args) {
|
|
|
11501
11546
|
localApiToken: (0, import_node_crypto.randomBytes)(24).toString("hex"),
|
|
11502
11547
|
displayName: body.runtime.displayName ?? displayName
|
|
11503
11548
|
});
|
|
11504
|
-
console.info("[aiden-agent] Runtime registered", { runtimeId: body.runtime.id, configPath:
|
|
11549
|
+
console.info("[aiden-agent] Runtime registered", { runtimeId: body.runtime.id, configPath: getConfigPath() });
|
|
11505
11550
|
}
|
|
11506
11551
|
async function loginWithDeviceCode(args) {
|
|
11507
|
-
const apiUrl =
|
|
11508
|
-
const wsUrl = argValue(args, "--ws-url") ?? process.env.AIDEN_WS_URL ?? "ws://localhost:8401";
|
|
11552
|
+
const { apiUrl, wsUrl, endpointProfile } = resolveEndpoints(args);
|
|
11509
11553
|
const displayName = argValue(args, "--name") ?? (0, import_node_os.hostname)();
|
|
11510
11554
|
const maxPolls = Number.parseInt(argValue(args, "--max-polls") ?? "300", 10);
|
|
11511
11555
|
const start = await fetch(`${apiUrl}/public/runtimes/device-authorizations`, {
|
|
@@ -11544,6 +11588,7 @@ async function loginWithDeviceCode(args) {
|
|
|
11544
11588
|
writeConfig({
|
|
11545
11589
|
apiUrl,
|
|
11546
11590
|
wsUrl,
|
|
11591
|
+
endpointProfile,
|
|
11547
11592
|
teamId: body.runtime.teamId ?? void 0,
|
|
11548
11593
|
runtimeId: body.runtime.id,
|
|
11549
11594
|
runtimeToken: body.runtimeToken,
|
|
@@ -11551,7 +11596,7 @@ async function loginWithDeviceCode(args) {
|
|
|
11551
11596
|
localApiToken: (0, import_node_crypto.randomBytes)(24).toString("hex"),
|
|
11552
11597
|
displayName: body.runtime.displayName ?? displayName
|
|
11553
11598
|
});
|
|
11554
|
-
console.info("[aiden-agent] Runtime registered", { runtimeId: body.runtime.id, configPath:
|
|
11599
|
+
console.info("[aiden-agent] Runtime registered", { runtimeId: body.runtime.id, configPath: getConfigPath() });
|
|
11555
11600
|
return;
|
|
11556
11601
|
}
|
|
11557
11602
|
throw new Error("device authorization timed out before approval");
|
|
@@ -11796,17 +11841,27 @@ async function revokeRuntimeToken(args) {
|
|
|
11796
11841
|
}
|
|
11797
11842
|
function logoutDaemon() {
|
|
11798
11843
|
removeConfig();
|
|
11799
|
-
console.info("[aiden-agent] Runtime config removed", { configPath:
|
|
11844
|
+
console.info("[aiden-agent] Runtime config removed", { configPath: getConfigPath() });
|
|
11800
11845
|
}
|
|
11801
11846
|
function printStatus() {
|
|
11802
11847
|
const config = readConfig();
|
|
11848
|
+
const configured = Boolean(config.runtimeId && config.runtimeToken && config.wsUrl);
|
|
11849
|
+
const warnings = [];
|
|
11850
|
+
if ((isLocalEndpoint(config.apiUrl) || isLocalEndpoint(config.wsUrl)) && config.endpointProfile !== "local") {
|
|
11851
|
+
warnings.push("Configured endpoint points at localhost. Use --profile local only for local development.");
|
|
11852
|
+
}
|
|
11803
11853
|
console.info(JSON.stringify({
|
|
11804
|
-
|
|
11854
|
+
mode: "runtime",
|
|
11855
|
+
configured,
|
|
11805
11856
|
runtimeId: config.runtimeId ?? null,
|
|
11857
|
+
apiUrl: config.apiUrl ?? null,
|
|
11806
11858
|
wsUrl: config.wsUrl ?? null,
|
|
11859
|
+
endpointProfile: config.endpointProfile ?? null,
|
|
11807
11860
|
localApiPort: config.localApiPort ?? null,
|
|
11808
11861
|
hasLocalApiToken: Boolean(config.localApiToken),
|
|
11809
|
-
configPath:
|
|
11862
|
+
configPath: getConfigPath(),
|
|
11863
|
+
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.",
|
|
11864
|
+
warnings
|
|
11810
11865
|
}, null, 2));
|
|
11811
11866
|
}
|
|
11812
11867
|
async function printDoctor(args = []) {
|
|
@@ -11834,10 +11889,13 @@ async function printDoctor(args = []) {
|
|
|
11834
11889
|
}
|
|
11835
11890
|
console.info(JSON.stringify({
|
|
11836
11891
|
version: AGENT_VERSION,
|
|
11837
|
-
configPath:
|
|
11892
|
+
configPath: getConfigPath(),
|
|
11838
11893
|
configured: Boolean(config.runtimeId && config.runtimeToken && config.wsUrl),
|
|
11839
11894
|
runtimeId: config.runtimeId ?? null,
|
|
11895
|
+
apiUrl: config.apiUrl ?? null,
|
|
11840
11896
|
wsUrl: config.wsUrl ?? null,
|
|
11897
|
+
endpointProfile: config.endpointProfile ?? null,
|
|
11898
|
+
warnings: (isLocalEndpoint(config.apiUrl) || isLocalEndpoint(config.wsUrl)) && config.endpointProfile !== "local" ? ["Configured endpoint points at localhost. Use --profile local only for local development."] : [],
|
|
11841
11899
|
synced,
|
|
11842
11900
|
syncError,
|
|
11843
11901
|
capabilities
|
|
@@ -11858,12 +11916,17 @@ Commands:
|
|
|
11858
11916
|
doctor Check local CLI capabilities
|
|
11859
11917
|
logout Remove local runtime configuration
|
|
11860
11918
|
token Rotate or revoke the configured runtime token
|
|
11861
|
-
run-session
|
|
11919
|
+
run-session Internal: run one ephemeral sandbox/session from AIDEN_* env vars
|
|
11862
11920
|
|
|
11863
11921
|
Common flows:
|
|
11864
|
-
aiden-agent
|
|
11865
|
-
aiden-agent
|
|
11922
|
+
aiden-agent login
|
|
11923
|
+
aiden-agent setup --setup-token <token>
|
|
11924
|
+
aiden-agent setup --setup-token <token> --scope user
|
|
11866
11925
|
aiden-agent daemon
|
|
11926
|
+
|
|
11927
|
+
Local development:
|
|
11928
|
+
aiden-agent login --profile local
|
|
11929
|
+
aiden-agent setup --profile local --setup-token <token>
|
|
11867
11930
|
`;
|
|
11868
11931
|
function hasRunSessionEnv(env) {
|
|
11869
11932
|
return Boolean(
|
|
@@ -11899,7 +11962,9 @@ async function runSessionFromEnv() {
|
|
|
11899
11962
|
const effortLevel = process.env.AIDEN_EFFORT_LEVEL || void 0;
|
|
11900
11963
|
const providerSessionId = process.env.AIDEN_PROVIDER_SESSION_ID || void 0;
|
|
11901
11964
|
if (!wsUrl || !sessionId || !taskId || !sessionToken || task == null) {
|
|
11902
|
-
throw new Error(
|
|
11965
|
+
throw new Error(
|
|
11966
|
+
"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"
|
|
11967
|
+
);
|
|
11903
11968
|
}
|
|
11904
11969
|
console.info("[aiden-agent] Starting", { sessionId, taskId, projectPath, backendKind, agentId, mode, model, version: AGENT_VERSION });
|
|
11905
11970
|
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.11",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"bin": {
|
|
6
6
|
"aiden-agent": "./dist/index.cjs"
|
|
@@ -14,6 +14,7 @@
|
|
|
14
14
|
"scripts": {
|
|
15
15
|
"build": "tsup",
|
|
16
16
|
"dev": "tsx src/index.ts",
|
|
17
|
+
"prepack": "pnpm build",
|
|
17
18
|
"test": "vitest run",
|
|
18
19
|
"type-check": "tsc --noEmit"
|
|
19
20
|
},
|