@airtop/sdk 1.0.0-alpha2.12 → 1.0.0-alpha2.14

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 CHANGED
@@ -9,7 +9,7 @@ var require_package = __commonJS({
9
9
  module.exports = {
10
10
  name: "@airtop/sdk",
11
11
  description: "Airtop SDK for TypeScript",
12
- version: "1.0.0-alpha2.12",
12
+ version: "1.0.0-alpha2.14",
13
13
  type: "module",
14
14
  main: "./dist/index.cjs",
15
15
  module: "./dist/index.js",
@@ -47,7 +47,7 @@ var require_package = __commonJS({
47
47
  },
48
48
  dependencies: {
49
49
  "@airtop/json-schema-adapter": "workspace:*",
50
- "@airtop/core": "0.1.0-alpha.28",
50
+ "@airtop/core": "0.1.0-alpha.29",
51
51
  "date-fns": "4.1.0",
52
52
  loglayer: "6.3.3",
53
53
  "serialize-error": "12.0.0",
@@ -373,6 +373,19 @@ var AirtopNode = class {
373
373
  };
374
374
  return this.windowClient.findOne(prompt, augmentedConfig, requestOptions);
375
375
  }
376
+ /**
377
+ * Find one element in the node
378
+ * @param prompt - The prompt to use for the find one
379
+ * @param config - The configuration to use for the find one
380
+ * @param requestOptions - The request options to use for the find one
381
+ */
382
+ async findOneOptional(prompt, config, requestOptions = {}) {
383
+ const augmentedConfig = {
384
+ ...config,
385
+ nodeHandleId: this.nodeHandleId
386
+ };
387
+ return this.windowClient.findOneOptional(prompt, augmentedConfig, requestOptions);
388
+ }
376
389
  /**
377
390
  * Find many elements in the node
378
391
  * @param prompt - The prompt to use for the find many
@@ -386,6 +399,19 @@ var AirtopNode = class {
386
399
  };
387
400
  return this.windowClient.findMany(prompt, augmentedConfig, requestOptions);
388
401
  }
402
+ /**
403
+ * Find many elements in the node
404
+ * @param prompt - The prompt to use for the find many
405
+ * @param config - The configuration to use for the find many
406
+ * @param requestOptions - The request options to use for the find many
407
+ */
408
+ async findManyOptional(prompt, config, requestOptions = {}) {
409
+ const augmentedConfig = {
410
+ ...config,
411
+ nodeHandleId: this.nodeHandleId
412
+ };
413
+ return this.windowClient.findManyOptional(prompt, augmentedConfig, requestOptions);
414
+ }
389
415
  };
390
416
 
391
417
  // src/window/AirtopWindowScreenshot.ts
@@ -1422,6 +1448,189 @@ function registerAirtopPlugin(plugin) {
1422
1448
  }
1423
1449
  }
1424
1450
 
1451
+ // src/agent/AirtopAgentClient.ts
1452
+ var _process = require('process');
1453
+
1454
+
1455
+
1456
+
1457
+
1458
+ var AirtopAgentClient = class extends AirtopBase {
1459
+ /**
1460
+ * Creates a new instance of the Airtop SDK.
1461
+ * @param config - Configuration options for the Airtop SDK
1462
+ */
1463
+ constructor(config) {
1464
+ super({
1465
+ logLevel: _optionalChain([config, 'optionalAccess', _16 => _16.logLevel]),
1466
+ client: new (0, _core.Airtop)({
1467
+ maxRetries: 0,
1468
+ timeout: _datefns.minutesToMilliseconds.call(void 0, 1),
1469
+ apiKey: config.apiKey,
1470
+ baseURL: _optionalChain([config, 'optionalAccess', _17 => _17.airtopUrl]),
1471
+ logLevel: _optionalChain([config, 'optionalAccess', _18 => _18.logLevel]) || "off",
1472
+ defaultHeaders: {
1473
+ "x-airtop-sdk-source": "typescript",
1474
+ "x-airtop-sdk-version": _process.version
1475
+ }
1476
+ }),
1477
+ log: _optionalChain([config, 'optionalAccess', _19 => _19.logger]) || new (0, _loglayer.LogLayer)({
1478
+ errorSerializer: _serializeerror.serializeError,
1479
+ transport: new (0, _loglayer.ConsoleTransport)({
1480
+ logger: console,
1481
+ messageField: "message",
1482
+ enabled: config.logLevel !== "off",
1483
+ level: config.logLevel === "off" ? "error" : config.logLevel || "error"
1484
+ }),
1485
+ contextFieldName: "context",
1486
+ metadataFieldName: "metadata"
1487
+ }),
1488
+ outputSchemaAdapter: config.outputSchemaAdapter,
1489
+ jobId: config.jobId
1490
+ });
1491
+ this.log.withPrefix("[Airtop SDK]");
1492
+ this.client.logLevel = config.logLevel;
1493
+ this.client.logger = {
1494
+ debug: (message, ...rest) => {
1495
+ processLogMessage(this.log, "debug", message, rest);
1496
+ },
1497
+ error: (message, ...rest) => {
1498
+ processLogMessage(this.log, "error", message, rest);
1499
+ },
1500
+ info: (message, ...rest) => {
1501
+ processLogMessage(this.log, "info", message, rest);
1502
+ },
1503
+ warn: (message, ...rest) => {
1504
+ processLogMessage(this.log, "warn", message, rest);
1505
+ }
1506
+ };
1507
+ }
1508
+ /**
1509
+ * Creates a new agent.
1510
+ * @param params - Parameters for creating the agent. Corresponds to `AirtopAgentCreateAgentParams`.
1511
+ * @param requestOptions - Request options.
1512
+ * @returns The created agent data, `AirtopCreateAgentResponse`.
1513
+ */
1514
+ async createAgent(params, requestOptions = {}) {
1515
+ this.log.info("Creating agent");
1516
+ return this.client.agents.createAgent(params, this.resolveRequestOptions(requestOptions));
1517
+ }
1518
+ /**
1519
+ * Retrieves a specific agent by its ID.
1520
+ * @param agentId - The ID of the agent to retrieve.
1521
+ * @param requestOptions - Request options.
1522
+ * @returns The agent data, `AirtopGetAgentResponse`.
1523
+ */
1524
+ async getAgent(agentId, requestOptions = {}) {
1525
+ this.log.withMetadata({ agentId }).info("Retrieving agent");
1526
+ return this.client.agents.getAgent(agentId, this.resolveRequestOptions(requestOptions));
1527
+ }
1528
+ /**
1529
+ * Lists agents.
1530
+ * @param params - Optional parameters for listing agents (e.g., pagination). Corresponds to `AirtopAgentGetAgentsParams`.
1531
+ * @param requestOptions - Request options.
1532
+ * @returns A list of agents, `AirtopGetAgentsResponse`.
1533
+ */
1534
+ async listAgents(params, requestOptions = {}) {
1535
+ this.log.info("Listing agents");
1536
+ return this.client.agents.getAgents(params, this.resolveRequestOptions(requestOptions));
1537
+ }
1538
+ /**
1539
+ * Updates an existing agent.
1540
+ * @param agentId - The ID of the agent to update.
1541
+ * @param params - The new data for the agent. Corresponds to `AirtopAgentUpdateAgentParams`.
1542
+ * @param requestOptions - Request options.
1543
+ * @returns The updated agent data, `AirtopUpdateAgentResponse`.
1544
+ */
1545
+ async updateAgent(agentId, params, requestOptions = {}) {
1546
+ this.log.withMetadata({ agentId }).info("Updating agent");
1547
+ return this.client.agents.updateAgent(agentId, params, this.resolveRequestOptions(requestOptions));
1548
+ }
1549
+ /**
1550
+ * Deletes one or more agents.
1551
+ * @param params - Parameters for deleting agents. Corresponds to `AirtopAgentDeleteAgentsParams`.
1552
+ * @param requestOptions - Request options.
1553
+ * @returns A response confirming the deletion, `AirtopDeleteAgentsResponse`.
1554
+ */
1555
+ async deleteAgents(params, requestOptions = {}) {
1556
+ this.log.info("Deleting agent(s)");
1557
+ return this.client.agents.deleteAgents(params, this.resolveRequestOptions(requestOptions));
1558
+ }
1559
+ /**
1560
+ * Duplicates an agent.
1561
+ * @param agentId - The ID of the agent to duplicate.
1562
+ * @param params - Parameters for duplicating the agent (e.g., new name). Corresponds to `AirtopAgentDuplicateAgentParams`.
1563
+ * @param requestOptions - Request options.
1564
+ * @returns The duplicated agent data, `AirtopDuplicateAgentResponse`.
1565
+ */
1566
+ async duplicateAgent(agentId, params, requestOptions = {}) {
1567
+ this.log.withMetadata({ agentId }).info("Duplicating agent");
1568
+ return this.client.agents.duplicateAgent(agentId, params, this.resolveRequestOptions(requestOptions));
1569
+ }
1570
+ /**
1571
+ * Creates a new version for an agent.
1572
+ * @param agentId - The ID of the agent for which to create a version.
1573
+ * @param params - Parameters for creating the agent version. Corresponds to `AirtopAgentCreateVersionParams`.
1574
+ * @param requestOptions - Request options.
1575
+ * @returns The created agent version data, `AirtopCreateAgentVersionResponse`.
1576
+ */
1577
+ async createAgentVersion(agentId, params, requestOptions = {}) {
1578
+ this.log.withMetadata({ agentId }).info("Creating agent version");
1579
+ return this.client.agents.createVersion(agentId, params, this.resolveRequestOptions(requestOptions));
1580
+ }
1581
+ /**
1582
+ * Lists versions of an agent.
1583
+ * @param agentId - The ID of the agent whose versions to list.
1584
+ * @param params - Optional parameters for listing agent versions. Corresponds to `AirtopAgentGetVersionsParams`.
1585
+ * @param requestOptions - Request options.
1586
+ * @returns A list of agent versions, `AirtopGetAgentVersionsResponse`.
1587
+ */
1588
+ async listAgentVersions(agentId, params, requestOptions = {}) {
1589
+ this.log.withMetadata({ agentId }).info("Listing agent versions");
1590
+ return this.client.agents.getVersions(agentId, params, this.resolveRequestOptions(requestOptions));
1591
+ }
1592
+ /**
1593
+ * Creates an invocation for an agent.
1594
+ * @param agentId - The ID of the agent for which to create an invocation.
1595
+ * @param params - Parameters for creating the agent invocation. Corresponds to `AirtopAgentCreateInvocationParams`.
1596
+ * @param requestOptions - Request options.
1597
+ * @returns The created agent invocation data, `AirtopCreateAgentInvocationResponse`.
1598
+ */
1599
+ async createAgentInvocation(agentId, params, requestOptions = {}) {
1600
+ this.log.withMetadata({ agentId }).info("Creating agent invocation");
1601
+ return this.client.agents.createInvocation(agentId, params, this.resolveRequestOptions(requestOptions));
1602
+ }
1603
+ /**
1604
+ * Lists invocations of an agent.
1605
+ * @param agentIds - The ID of the agent whose invocations to list.
1606
+ * @param params - Optional parameters for listing agent invocations. Corresponds to `AirtopAgentGetInvocationsParams`.
1607
+ * @param requestOptions - Request options.
1608
+ * @returns A list of agent invocations, `AirtopGetAgentInvocationsResponse`.
1609
+ */
1610
+ async listAgentInvocations(agentIds, params, requestOptions = {}) {
1611
+ this.log.withMetadata({ agentId: agentIds }).info("Listing agent invocations");
1612
+ return this.client.agents.getInvocations(agentIds, params, this.resolveRequestOptions(requestOptions));
1613
+ }
1614
+ /**
1615
+ * Cancels a specific invocation of an agent.
1616
+ * @param agentId - The ID of the agent.
1617
+ * @param invocationId - The ID of the invocation to cancel.
1618
+ * @param paramsBody - Optional body parameters for cancelling the invocation. Corresponds to `AirtopAgentCancelInvocationParams`.
1619
+ * @param requestOptions - Request options.
1620
+ * @returns A promise that resolves when the operation is complete.
1621
+ */
1622
+ async cancelAgentInvocation(agentId, invocationId, paramsBody, requestOptions = {}) {
1623
+ this.log.withMetadata({ agentId, invocationId }).info("Cancelling agent invocation");
1624
+ const resolvedOptions = this.resolveRequestOptions(requestOptions);
1625
+ const finalOptions = { ...resolvedOptions };
1626
+ const params = { id: agentId, ...paramsBody };
1627
+ if (paramsBody) {
1628
+ finalOptions.body = paramsBody;
1629
+ }
1630
+ await this.client.agents.cancelInvocation(invocationId, params, finalOptions);
1631
+ }
1632
+ };
1633
+
1425
1634
  // src/AirtopMocks.ts
1426
1635
 
1427
1636
 
@@ -1526,5 +1735,6 @@ var AirtopMocks = class {
1526
1735
 
1527
1736
 
1528
1737
 
1529
- exports.AirtopBase = AirtopBase; exports.AirtopClient = AirtopClient; exports.AirtopError = AirtopError; exports.AirtopMocks = AirtopMocks; exports.AirtopNode = AirtopNode; exports.AirtopPluginAugmentationType = AirtopPluginAugmentationType; exports.AirtopSession = AirtopSession; exports.AirtopSessionClient = AirtopSessionClient; exports.AirtopWindow = AirtopWindow; exports.AirtopWindowClient = AirtopWindowClient; exports.AirtopWindowScreenshot = AirtopWindowScreenshot; exports.WindowNavigateDirection = WindowNavigateDirection; exports.registerAirtopPlugin = registerAirtopPlugin;
1738
+
1739
+ exports.AirtopAgentClient = AirtopAgentClient; exports.AirtopBase = AirtopBase; exports.AirtopClient = AirtopClient; exports.AirtopError = AirtopError; exports.AirtopMocks = AirtopMocks; exports.AirtopNode = AirtopNode; exports.AirtopPluginAugmentationType = AirtopPluginAugmentationType; exports.AirtopSession = AirtopSession; exports.AirtopSessionClient = AirtopSessionClient; exports.AirtopWindow = AirtopWindow; exports.AirtopWindowClient = AirtopWindowClient; exports.AirtopWindowScreenshot = AirtopWindowScreenshot; exports.WindowNavigateDirection = WindowNavigateDirection; exports.registerAirtopPlugin = registerAirtopPlugin;
1530
1740
  //# sourceMappingURL=index.cjs.map