agi 0.4.0 → 0.4.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.d.mts +30 -5
- package/dist/index.d.ts +30 -5
- package/dist/index.js +22 -46
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +22 -46
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -554,6 +554,7 @@ declare class SessionsResource {
|
|
|
554
554
|
restoreFromEnvironmentId?: string;
|
|
555
555
|
agentSessionType?: string;
|
|
556
556
|
cdpUrl?: string;
|
|
557
|
+
environmentType?: string;
|
|
557
558
|
}): Promise<SessionResponse>;
|
|
558
559
|
/**
|
|
559
560
|
* List all sessions for the authenticated user
|
|
@@ -1143,7 +1144,7 @@ declare class APIError extends AGIError {
|
|
|
1143
1144
|
* - Events are emitted on stdout (driver -> SDK)
|
|
1144
1145
|
* - Commands are sent on stdin (SDK -> driver)
|
|
1145
1146
|
*/
|
|
1146
|
-
type EventType = 'ready' | 'state_change' | 'thinking' | 'action' | 'confirm' | 'ask_question' | 'finished' | 'error' | 'screenshot_captured';
|
|
1147
|
+
type EventType = 'ready' | 'state_change' | 'thinking' | 'action' | 'confirm' | 'ask_question' | 'finished' | 'error' | 'screenshot_captured' | 'session_created';
|
|
1147
1148
|
type CommandType = 'start' | 'screenshot' | 'pause' | 'resume' | 'stop' | 'confirm' | 'answer';
|
|
1148
1149
|
type DriverState = 'idle' | 'running' | 'paused' | 'waiting_confirmation' | 'waiting_answer' | 'finished' | 'stopped' | 'error';
|
|
1149
1150
|
interface BaseEvent {
|
|
@@ -1198,7 +1199,17 @@ interface ScreenshotCapturedEvent extends BaseEvent {
|
|
|
1198
1199
|
width: number;
|
|
1199
1200
|
height: number;
|
|
1200
1201
|
}
|
|
1201
|
-
|
|
1202
|
+
/**
|
|
1203
|
+
* Emitted after the driver creates an API session.
|
|
1204
|
+
*/
|
|
1205
|
+
interface SessionCreatedEvent extends BaseEvent {
|
|
1206
|
+
event: 'session_created';
|
|
1207
|
+
session_id: string;
|
|
1208
|
+
agent_url: string;
|
|
1209
|
+
environment_url?: string;
|
|
1210
|
+
vnc_url?: string;
|
|
1211
|
+
}
|
|
1212
|
+
type DriverEvent = ReadyEvent | StateChangeEvent | ThinkingEvent | ActionEvent | ConfirmEvent | AskQuestionEvent | FinishedEvent | ErrorEvent | ScreenshotCapturedEvent | SessionCreatedEvent;
|
|
1202
1213
|
interface DriverAction {
|
|
1203
1214
|
type: string;
|
|
1204
1215
|
x?: number;
|
|
@@ -1217,8 +1228,14 @@ interface StartCommand extends BaseCommand {
|
|
|
1217
1228
|
screen_height: number;
|
|
1218
1229
|
platform: 'desktop' | 'android';
|
|
1219
1230
|
model: string;
|
|
1220
|
-
/** "local" for autonomous mode, "" for legacy SDK-driven mode */
|
|
1231
|
+
/** "local" for autonomous mode, "remote" for managed VM, "" for legacy SDK-driven mode */
|
|
1221
1232
|
mode?: string;
|
|
1233
|
+
/** Agent name for the AGI API (e.g., "agi-2-claude") */
|
|
1234
|
+
agent_name?: string;
|
|
1235
|
+
/** AGI API base URL (default: "https://api.agi.tech") */
|
|
1236
|
+
api_url?: string;
|
|
1237
|
+
/** Environment type for remote mode ("ubuntu-1" or "chrome-1") */
|
|
1238
|
+
environment_type?: string;
|
|
1222
1239
|
}
|
|
1223
1240
|
interface ScreenshotCommand extends BaseCommand {
|
|
1224
1241
|
command: 'screenshot';
|
|
@@ -1265,8 +1282,14 @@ interface DriverOptions {
|
|
|
1265
1282
|
model?: string;
|
|
1266
1283
|
/** Platform type (default: 'desktop') */
|
|
1267
1284
|
platform?: 'desktop' | 'android';
|
|
1268
|
-
/** "local" for autonomous mode, "" for legacy SDK-driven mode */
|
|
1285
|
+
/** "local" for autonomous mode, "remote" for managed VM, "" for legacy SDK-driven mode */
|
|
1269
1286
|
mode?: string;
|
|
1287
|
+
/** Agent name for the AGI API (e.g., "agi-2-claude") */
|
|
1288
|
+
agentName?: string;
|
|
1289
|
+
/** AGI API base URL (default: "https://api.agi.tech") */
|
|
1290
|
+
apiUrl?: string;
|
|
1291
|
+
/** Environment type for remote mode ("ubuntu-1" or "chrome-1") */
|
|
1292
|
+
environmentType?: string;
|
|
1270
1293
|
/** Environment variables to pass to the driver process */
|
|
1271
1294
|
env?: Record<string, string>;
|
|
1272
1295
|
}
|
|
@@ -1312,10 +1335,12 @@ interface DriverResult {
|
|
|
1312
1335
|
*/
|
|
1313
1336
|
declare class AgentDriver extends EventEmitter {
|
|
1314
1337
|
private readonly binaryPath;
|
|
1315
|
-
private readonly pythonFallback;
|
|
1316
1338
|
private readonly model;
|
|
1317
1339
|
private readonly platform;
|
|
1318
1340
|
private readonly mode;
|
|
1341
|
+
private readonly agentName;
|
|
1342
|
+
private readonly apiUrl;
|
|
1343
|
+
private readonly environmentType;
|
|
1319
1344
|
private readonly env;
|
|
1320
1345
|
private process;
|
|
1321
1346
|
private readline;
|
package/dist/index.d.ts
CHANGED
|
@@ -554,6 +554,7 @@ declare class SessionsResource {
|
|
|
554
554
|
restoreFromEnvironmentId?: string;
|
|
555
555
|
agentSessionType?: string;
|
|
556
556
|
cdpUrl?: string;
|
|
557
|
+
environmentType?: string;
|
|
557
558
|
}): Promise<SessionResponse>;
|
|
558
559
|
/**
|
|
559
560
|
* List all sessions for the authenticated user
|
|
@@ -1143,7 +1144,7 @@ declare class APIError extends AGIError {
|
|
|
1143
1144
|
* - Events are emitted on stdout (driver -> SDK)
|
|
1144
1145
|
* - Commands are sent on stdin (SDK -> driver)
|
|
1145
1146
|
*/
|
|
1146
|
-
type EventType = 'ready' | 'state_change' | 'thinking' | 'action' | 'confirm' | 'ask_question' | 'finished' | 'error' | 'screenshot_captured';
|
|
1147
|
+
type EventType = 'ready' | 'state_change' | 'thinking' | 'action' | 'confirm' | 'ask_question' | 'finished' | 'error' | 'screenshot_captured' | 'session_created';
|
|
1147
1148
|
type CommandType = 'start' | 'screenshot' | 'pause' | 'resume' | 'stop' | 'confirm' | 'answer';
|
|
1148
1149
|
type DriverState = 'idle' | 'running' | 'paused' | 'waiting_confirmation' | 'waiting_answer' | 'finished' | 'stopped' | 'error';
|
|
1149
1150
|
interface BaseEvent {
|
|
@@ -1198,7 +1199,17 @@ interface ScreenshotCapturedEvent extends BaseEvent {
|
|
|
1198
1199
|
width: number;
|
|
1199
1200
|
height: number;
|
|
1200
1201
|
}
|
|
1201
|
-
|
|
1202
|
+
/**
|
|
1203
|
+
* Emitted after the driver creates an API session.
|
|
1204
|
+
*/
|
|
1205
|
+
interface SessionCreatedEvent extends BaseEvent {
|
|
1206
|
+
event: 'session_created';
|
|
1207
|
+
session_id: string;
|
|
1208
|
+
agent_url: string;
|
|
1209
|
+
environment_url?: string;
|
|
1210
|
+
vnc_url?: string;
|
|
1211
|
+
}
|
|
1212
|
+
type DriverEvent = ReadyEvent | StateChangeEvent | ThinkingEvent | ActionEvent | ConfirmEvent | AskQuestionEvent | FinishedEvent | ErrorEvent | ScreenshotCapturedEvent | SessionCreatedEvent;
|
|
1202
1213
|
interface DriverAction {
|
|
1203
1214
|
type: string;
|
|
1204
1215
|
x?: number;
|
|
@@ -1217,8 +1228,14 @@ interface StartCommand extends BaseCommand {
|
|
|
1217
1228
|
screen_height: number;
|
|
1218
1229
|
platform: 'desktop' | 'android';
|
|
1219
1230
|
model: string;
|
|
1220
|
-
/** "local" for autonomous mode, "" for legacy SDK-driven mode */
|
|
1231
|
+
/** "local" for autonomous mode, "remote" for managed VM, "" for legacy SDK-driven mode */
|
|
1221
1232
|
mode?: string;
|
|
1233
|
+
/** Agent name for the AGI API (e.g., "agi-2-claude") */
|
|
1234
|
+
agent_name?: string;
|
|
1235
|
+
/** AGI API base URL (default: "https://api.agi.tech") */
|
|
1236
|
+
api_url?: string;
|
|
1237
|
+
/** Environment type for remote mode ("ubuntu-1" or "chrome-1") */
|
|
1238
|
+
environment_type?: string;
|
|
1222
1239
|
}
|
|
1223
1240
|
interface ScreenshotCommand extends BaseCommand {
|
|
1224
1241
|
command: 'screenshot';
|
|
@@ -1265,8 +1282,14 @@ interface DriverOptions {
|
|
|
1265
1282
|
model?: string;
|
|
1266
1283
|
/** Platform type (default: 'desktop') */
|
|
1267
1284
|
platform?: 'desktop' | 'android';
|
|
1268
|
-
/** "local" for autonomous mode, "" for legacy SDK-driven mode */
|
|
1285
|
+
/** "local" for autonomous mode, "remote" for managed VM, "" for legacy SDK-driven mode */
|
|
1269
1286
|
mode?: string;
|
|
1287
|
+
/** Agent name for the AGI API (e.g., "agi-2-claude") */
|
|
1288
|
+
agentName?: string;
|
|
1289
|
+
/** AGI API base URL (default: "https://api.agi.tech") */
|
|
1290
|
+
apiUrl?: string;
|
|
1291
|
+
/** Environment type for remote mode ("ubuntu-1" or "chrome-1") */
|
|
1292
|
+
environmentType?: string;
|
|
1270
1293
|
/** Environment variables to pass to the driver process */
|
|
1271
1294
|
env?: Record<string, string>;
|
|
1272
1295
|
}
|
|
@@ -1312,10 +1335,12 @@ interface DriverResult {
|
|
|
1312
1335
|
*/
|
|
1313
1336
|
declare class AgentDriver extends EventEmitter {
|
|
1314
1337
|
private readonly binaryPath;
|
|
1315
|
-
private readonly pythonFallback;
|
|
1316
1338
|
private readonly model;
|
|
1317
1339
|
private readonly platform;
|
|
1318
1340
|
private readonly mode;
|
|
1341
|
+
private readonly agentName;
|
|
1342
|
+
private readonly apiUrl;
|
|
1343
|
+
private readonly environmentType;
|
|
1319
1344
|
private readonly env;
|
|
1320
1345
|
private process;
|
|
1321
1346
|
private readline;
|
package/dist/index.js
CHANGED
|
@@ -674,6 +674,7 @@ var SessionsResource = class {
|
|
|
674
674
|
payload.agent_session_type = options.agentSessionType;
|
|
675
675
|
}
|
|
676
676
|
if (options?.cdpUrl) payload.cdp_url = options.cdpUrl;
|
|
677
|
+
if (options?.environmentType) payload.environment_type = options.environmentType;
|
|
677
678
|
const response = await this.http.request("POST", "/v1/sessions", {
|
|
678
679
|
json: payload
|
|
679
680
|
});
|
|
@@ -1305,16 +1306,6 @@ function getSearchPaths(platformId) {
|
|
|
1305
1306
|
}
|
|
1306
1307
|
return paths;
|
|
1307
1308
|
}
|
|
1308
|
-
function getPythonFallback() {
|
|
1309
|
-
const driverPath = process.env.AGI_DRIVER_PATH;
|
|
1310
|
-
if (driverPath && fs.existsSync(path.join(driverPath, "__main__.py"))) {
|
|
1311
|
-
return {
|
|
1312
|
-
command: process.env.PYTHON_PATH || "python",
|
|
1313
|
-
args: ["-m", "agi_driver"]
|
|
1314
|
-
};
|
|
1315
|
-
}
|
|
1316
|
-
return null;
|
|
1317
|
-
}
|
|
1318
1309
|
function findBinaryPath() {
|
|
1319
1310
|
const platformId = getPlatformId();
|
|
1320
1311
|
const searchPaths = getSearchPaths(platformId);
|
|
@@ -1348,10 +1339,12 @@ function serializeCommand(command) {
|
|
|
1348
1339
|
// src/driver/driver.ts
|
|
1349
1340
|
var AgentDriver = class extends events.EventEmitter {
|
|
1350
1341
|
binaryPath;
|
|
1351
|
-
pythonFallback;
|
|
1352
1342
|
model;
|
|
1353
1343
|
platform;
|
|
1354
1344
|
mode;
|
|
1345
|
+
agentName;
|
|
1346
|
+
apiUrl;
|
|
1347
|
+
environmentType;
|
|
1355
1348
|
env;
|
|
1356
1349
|
process = null;
|
|
1357
1350
|
readline = null;
|
|
@@ -1367,21 +1360,13 @@ var AgentDriver = class extends events.EventEmitter {
|
|
|
1367
1360
|
pendingAnswer = null;
|
|
1368
1361
|
constructor(options = {}) {
|
|
1369
1362
|
super();
|
|
1370
|
-
|
|
1371
|
-
try {
|
|
1372
|
-
binaryPath = options.binaryPath ?? findBinaryPath();
|
|
1373
|
-
} catch {
|
|
1374
|
-
}
|
|
1375
|
-
this.binaryPath = binaryPath;
|
|
1376
|
-
this.pythonFallback = binaryPath ? null : getPythonFallback();
|
|
1377
|
-
if (!this.binaryPath && !this.pythonFallback) {
|
|
1378
|
-
throw new Error(
|
|
1379
|
-
"Could not find agi-driver binary and Python fallback is not available. Set AGI_DRIVER_PATH to the agi_driver source directory for development."
|
|
1380
|
-
);
|
|
1381
|
-
}
|
|
1363
|
+
this.binaryPath = options.binaryPath ?? findBinaryPath();
|
|
1382
1364
|
this.model = options.model ?? "claude-sonnet";
|
|
1383
1365
|
this.platform = options.platform ?? "desktop";
|
|
1384
1366
|
this.mode = options.mode ?? "";
|
|
1367
|
+
this.agentName = options.agentName ?? "";
|
|
1368
|
+
this.apiUrl = options.apiUrl ?? "";
|
|
1369
|
+
this.environmentType = options.environmentType ?? "";
|
|
1385
1370
|
this.env = options.env ?? {};
|
|
1386
1371
|
}
|
|
1387
1372
|
/**
|
|
@@ -1428,28 +1413,13 @@ var AgentDriver = class extends events.EventEmitter {
|
|
|
1428
1413
|
return new Promise((resolve, reject) => {
|
|
1429
1414
|
this.resolveStart = resolve;
|
|
1430
1415
|
this.rejectStart = reject;
|
|
1431
|
-
|
|
1432
|
-
|
|
1433
|
-
|
|
1434
|
-
env
|
|
1435
|
-
|
|
1436
|
-
|
|
1437
|
-
|
|
1438
|
-
});
|
|
1439
|
-
} else if (this.pythonFallback) {
|
|
1440
|
-
this.process = child_process.spawn(this.pythonFallback.command, this.pythonFallback.args, {
|
|
1441
|
-
stdio: ["pipe", "pipe", "pipe"],
|
|
1442
|
-
env: {
|
|
1443
|
-
...process.env,
|
|
1444
|
-
...this.env,
|
|
1445
|
-
PYTHONPATH: process.env.AGI_DRIVER_PATH ? `${process.env.AGI_DRIVER_PATH}/..` : ""
|
|
1446
|
-
},
|
|
1447
|
-
cwd: process.env.AGI_DRIVER_PATH ? `${process.env.AGI_DRIVER_PATH}/..` : void 0
|
|
1448
|
-
});
|
|
1449
|
-
} else {
|
|
1450
|
-
reject(new Error("No binary or Python fallback available"));
|
|
1451
|
-
return;
|
|
1452
|
-
}
|
|
1416
|
+
this.process = child_process.spawn(this.binaryPath, [], {
|
|
1417
|
+
stdio: ["pipe", "pipe", "pipe"],
|
|
1418
|
+
env: {
|
|
1419
|
+
...process.env,
|
|
1420
|
+
...this.env
|
|
1421
|
+
}
|
|
1422
|
+
});
|
|
1453
1423
|
this.process.on("error", (err) => {
|
|
1454
1424
|
this.cleanup();
|
|
1455
1425
|
if (this.rejectStart) {
|
|
@@ -1494,7 +1464,10 @@ var AgentDriver = class extends events.EventEmitter {
|
|
|
1494
1464
|
screen_height: screenHeight,
|
|
1495
1465
|
platform: this.platform,
|
|
1496
1466
|
model: this.model,
|
|
1497
|
-
mode: mode ?? this.mode
|
|
1467
|
+
mode: mode ?? this.mode,
|
|
1468
|
+
agent_name: this.agentName || void 0,
|
|
1469
|
+
api_url: this.apiUrl || void 0,
|
|
1470
|
+
environment_type: this.environmentType || void 0
|
|
1498
1471
|
};
|
|
1499
1472
|
this.sendCommand(startCmd);
|
|
1500
1473
|
});
|
|
@@ -1667,6 +1640,9 @@ var AgentDriver = class extends events.EventEmitter {
|
|
|
1667
1640
|
case "screenshot_captured":
|
|
1668
1641
|
this.emit("screenshot_captured", event);
|
|
1669
1642
|
break;
|
|
1643
|
+
case "session_created":
|
|
1644
|
+
this.emit("session_created", event);
|
|
1645
|
+
break;
|
|
1670
1646
|
case "finished":
|
|
1671
1647
|
this.handleFinished(event);
|
|
1672
1648
|
break;
|