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.mjs CHANGED
@@ -671,6 +671,7 @@ var SessionsResource = class {
671
671
  payload.agent_session_type = options.agentSessionType;
672
672
  }
673
673
  if (options?.cdpUrl) payload.cdp_url = options.cdpUrl;
674
+ if (options?.environmentType) payload.environment_type = options.environmentType;
674
675
  const response = await this.http.request("POST", "/v1/sessions", {
675
676
  json: payload
676
677
  });
@@ -1302,16 +1303,6 @@ function getSearchPaths(platformId) {
1302
1303
  }
1303
1304
  return paths;
1304
1305
  }
1305
- function getPythonFallback() {
1306
- const driverPath = process.env.AGI_DRIVER_PATH;
1307
- if (driverPath && existsSync(join(driverPath, "__main__.py"))) {
1308
- return {
1309
- command: process.env.PYTHON_PATH || "python",
1310
- args: ["-m", "agi_driver"]
1311
- };
1312
- }
1313
- return null;
1314
- }
1315
1306
  function findBinaryPath() {
1316
1307
  const platformId = getPlatformId();
1317
1308
  const searchPaths = getSearchPaths(platformId);
@@ -1345,10 +1336,12 @@ function serializeCommand(command) {
1345
1336
  // src/driver/driver.ts
1346
1337
  var AgentDriver = class extends EventEmitter {
1347
1338
  binaryPath;
1348
- pythonFallback;
1349
1339
  model;
1350
1340
  platform;
1351
1341
  mode;
1342
+ agentName;
1343
+ apiUrl;
1344
+ environmentType;
1352
1345
  env;
1353
1346
  process = null;
1354
1347
  readline = null;
@@ -1364,21 +1357,13 @@ var AgentDriver = class extends EventEmitter {
1364
1357
  pendingAnswer = null;
1365
1358
  constructor(options = {}) {
1366
1359
  super();
1367
- let binaryPath = null;
1368
- try {
1369
- binaryPath = options.binaryPath ?? findBinaryPath();
1370
- } catch {
1371
- }
1372
- this.binaryPath = binaryPath;
1373
- this.pythonFallback = binaryPath ? null : getPythonFallback();
1374
- if (!this.binaryPath && !this.pythonFallback) {
1375
- throw new Error(
1376
- "Could not find agi-driver binary and Python fallback is not available. Set AGI_DRIVER_PATH to the agi_driver source directory for development."
1377
- );
1378
- }
1360
+ this.binaryPath = options.binaryPath ?? findBinaryPath();
1379
1361
  this.model = options.model ?? "claude-sonnet";
1380
1362
  this.platform = options.platform ?? "desktop";
1381
1363
  this.mode = options.mode ?? "";
1364
+ this.agentName = options.agentName ?? "";
1365
+ this.apiUrl = options.apiUrl ?? "";
1366
+ this.environmentType = options.environmentType ?? "";
1382
1367
  this.env = options.env ?? {};
1383
1368
  }
1384
1369
  /**
@@ -1425,28 +1410,13 @@ var AgentDriver = class extends EventEmitter {
1425
1410
  return new Promise((resolve, reject) => {
1426
1411
  this.resolveStart = resolve;
1427
1412
  this.rejectStart = reject;
1428
- if (this.binaryPath) {
1429
- this.process = spawn(this.binaryPath, [], {
1430
- stdio: ["pipe", "pipe", "pipe"],
1431
- env: {
1432
- ...process.env,
1433
- ...this.env
1434
- }
1435
- });
1436
- } else if (this.pythonFallback) {
1437
- this.process = spawn(this.pythonFallback.command, this.pythonFallback.args, {
1438
- stdio: ["pipe", "pipe", "pipe"],
1439
- env: {
1440
- ...process.env,
1441
- ...this.env,
1442
- PYTHONPATH: process.env.AGI_DRIVER_PATH ? `${process.env.AGI_DRIVER_PATH}/..` : ""
1443
- },
1444
- cwd: process.env.AGI_DRIVER_PATH ? `${process.env.AGI_DRIVER_PATH}/..` : void 0
1445
- });
1446
- } else {
1447
- reject(new Error("No binary or Python fallback available"));
1448
- return;
1449
- }
1413
+ this.process = spawn(this.binaryPath, [], {
1414
+ stdio: ["pipe", "pipe", "pipe"],
1415
+ env: {
1416
+ ...process.env,
1417
+ ...this.env
1418
+ }
1419
+ });
1450
1420
  this.process.on("error", (err) => {
1451
1421
  this.cleanup();
1452
1422
  if (this.rejectStart) {
@@ -1491,7 +1461,10 @@ var AgentDriver = class extends EventEmitter {
1491
1461
  screen_height: screenHeight,
1492
1462
  platform: this.platform,
1493
1463
  model: this.model,
1494
- mode: mode ?? this.mode
1464
+ mode: mode ?? this.mode,
1465
+ agent_name: this.agentName || void 0,
1466
+ api_url: this.apiUrl || void 0,
1467
+ environment_type: this.environmentType || void 0
1495
1468
  };
1496
1469
  this.sendCommand(startCmd);
1497
1470
  });
@@ -1664,6 +1637,9 @@ var AgentDriver = class extends EventEmitter {
1664
1637
  case "screenshot_captured":
1665
1638
  this.emit("screenshot_captured", event);
1666
1639
  break;
1640
+ case "session_created":
1641
+ this.emit("session_created", event);
1642
+ break;
1667
1643
  case "finished":
1668
1644
  this.handleFinished(event);
1669
1645
  break;