heyatlas 1.8.2 → 1.9.0
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/cli.js +17 -0
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -5559,6 +5559,22 @@ class AtlasTunnel {
|
|
|
5559
5559
|
};
|
|
5560
5560
|
});
|
|
5561
5561
|
}
|
|
5562
|
+
async waitForState(timeoutMs = 1e4) {
|
|
5563
|
+
if (this.currentState)
|
|
5564
|
+
return;
|
|
5565
|
+
return new Promise((resolve, reject) => {
|
|
5566
|
+
const timeout = setTimeout(() => reject(new Error("Timed out waiting for state")), timeoutMs);
|
|
5567
|
+
const check = () => {
|
|
5568
|
+
if (this.currentState) {
|
|
5569
|
+
clearTimeout(timeout);
|
|
5570
|
+
resolve();
|
|
5571
|
+
} else {
|
|
5572
|
+
setTimeout(check, 100);
|
|
5573
|
+
}
|
|
5574
|
+
};
|
|
5575
|
+
check();
|
|
5576
|
+
});
|
|
5577
|
+
}
|
|
5562
5578
|
handleStateUpdate(state, source) {
|
|
5563
5579
|
if (source === "server") {
|
|
5564
5580
|
this.currentState = state;
|
|
@@ -52574,6 +52590,7 @@ async function connect(agentType, options = {}) {
|
|
|
52574
52590
|
const taskData = JSON.parse(fs.readFileSync(options.taskFile, "utf-8"));
|
|
52575
52591
|
console.log(`Task: ${taskData.description.slice(0, 80)}...`);
|
|
52576
52592
|
await tunnel.connect(credentials.userId, agent.name);
|
|
52593
|
+
await tunnel.waitForState();
|
|
52577
52594
|
console.log("Tunnel established");
|
|
52578
52595
|
try {
|
|
52579
52596
|
await handleTask(taskData, agent, tunnel);
|