@alfe.ai/remote 0.1.1 → 0.2.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/index.cjs +21 -4
- package/dist/index.d.cts +3 -2
- package/dist/index.d.ts +3 -2
- package/dist/index.js +21 -4
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -581,12 +581,29 @@ var TurnController = class {
|
|
|
581
581
|
/**
|
|
582
582
|
* Resolve once the agent is (again) allowed to drive. Resolves immediately if
|
|
583
583
|
* the agent already holds the token; otherwise parks until `releaseHuman()`.
|
|
584
|
-
* Every automation op awaits this before touching the page.
|
|
584
|
+
* Every automation op awaits this before touching the page. Cancellation
|
|
585
|
+
* removes only this waiter and never changes the current human owner.
|
|
585
586
|
*/
|
|
586
|
-
acquireAgent() {
|
|
587
|
+
acquireAgent(signal) {
|
|
588
|
+
if (signal?.aborted) return Promise.reject(/* @__PURE__ */ new Error("Agent turn acquisition interrupted"));
|
|
587
589
|
if (this.owner === "agent") return Promise.resolve();
|
|
588
|
-
return new Promise((resolve) => {
|
|
589
|
-
|
|
590
|
+
return new Promise((resolve, reject) => {
|
|
591
|
+
const cleanup = () => {
|
|
592
|
+
const index = this.waiters.indexOf(resume);
|
|
593
|
+
if (index !== -1) this.waiters.splice(index, 1);
|
|
594
|
+
signal?.removeEventListener("abort", onAbort);
|
|
595
|
+
};
|
|
596
|
+
const resume = () => {
|
|
597
|
+
cleanup();
|
|
598
|
+
resolve();
|
|
599
|
+
};
|
|
600
|
+
const onAbort = () => {
|
|
601
|
+
cleanup();
|
|
602
|
+
reject(/* @__PURE__ */ new Error("Agent turn acquisition interrupted"));
|
|
603
|
+
};
|
|
604
|
+
this.waiters.push(resume);
|
|
605
|
+
signal?.addEventListener("abort", onAbort, { once: true });
|
|
606
|
+
if (signal?.aborted) onAbort();
|
|
590
607
|
});
|
|
591
608
|
}
|
|
592
609
|
/**
|
package/dist/index.d.cts
CHANGED
|
@@ -244,9 +244,10 @@ declare class TurnController {
|
|
|
244
244
|
/**
|
|
245
245
|
* Resolve once the agent is (again) allowed to drive. Resolves immediately if
|
|
246
246
|
* the agent already holds the token; otherwise parks until `releaseHuman()`.
|
|
247
|
-
* Every automation op awaits this before touching the page.
|
|
247
|
+
* Every automation op awaits this before touching the page. Cancellation
|
|
248
|
+
* removes only this waiter and never changes the current human owner.
|
|
248
249
|
*/
|
|
249
|
-
acquireAgent(): Promise<void>;
|
|
250
|
+
acquireAgent(signal?: AbortSignal): Promise<void>;
|
|
250
251
|
/**
|
|
251
252
|
* Grant control to a human. Succeeds unless a human already holds it (single
|
|
252
253
|
* controller). "Human request always wins over the agent" — the agent parks
|
package/dist/index.d.ts
CHANGED
|
@@ -244,9 +244,10 @@ declare class TurnController {
|
|
|
244
244
|
/**
|
|
245
245
|
* Resolve once the agent is (again) allowed to drive. Resolves immediately if
|
|
246
246
|
* the agent already holds the token; otherwise parks until `releaseHuman()`.
|
|
247
|
-
* Every automation op awaits this before touching the page.
|
|
247
|
+
* Every automation op awaits this before touching the page. Cancellation
|
|
248
|
+
* removes only this waiter and never changes the current human owner.
|
|
248
249
|
*/
|
|
249
|
-
acquireAgent(): Promise<void>;
|
|
250
|
+
acquireAgent(signal?: AbortSignal): Promise<void>;
|
|
250
251
|
/**
|
|
251
252
|
* Grant control to a human. Succeeds unless a human already holds it (single
|
|
252
253
|
* controller). "Human request always wins over the agent" — the agent parks
|
package/dist/index.js
CHANGED
|
@@ -557,12 +557,29 @@ var TurnController = class {
|
|
|
557
557
|
/**
|
|
558
558
|
* Resolve once the agent is (again) allowed to drive. Resolves immediately if
|
|
559
559
|
* the agent already holds the token; otherwise parks until `releaseHuman()`.
|
|
560
|
-
* Every automation op awaits this before touching the page.
|
|
560
|
+
* Every automation op awaits this before touching the page. Cancellation
|
|
561
|
+
* removes only this waiter and never changes the current human owner.
|
|
561
562
|
*/
|
|
562
|
-
acquireAgent() {
|
|
563
|
+
acquireAgent(signal) {
|
|
564
|
+
if (signal?.aborted) return Promise.reject(/* @__PURE__ */ new Error("Agent turn acquisition interrupted"));
|
|
563
565
|
if (this.owner === "agent") return Promise.resolve();
|
|
564
|
-
return new Promise((resolve) => {
|
|
565
|
-
|
|
566
|
+
return new Promise((resolve, reject) => {
|
|
567
|
+
const cleanup = () => {
|
|
568
|
+
const index = this.waiters.indexOf(resume);
|
|
569
|
+
if (index !== -1) this.waiters.splice(index, 1);
|
|
570
|
+
signal?.removeEventListener("abort", onAbort);
|
|
571
|
+
};
|
|
572
|
+
const resume = () => {
|
|
573
|
+
cleanup();
|
|
574
|
+
resolve();
|
|
575
|
+
};
|
|
576
|
+
const onAbort = () => {
|
|
577
|
+
cleanup();
|
|
578
|
+
reject(/* @__PURE__ */ new Error("Agent turn acquisition interrupted"));
|
|
579
|
+
};
|
|
580
|
+
this.waiters.push(resume);
|
|
581
|
+
signal?.addEventListener("abort", onAbort, { once: true });
|
|
582
|
+
if (signal?.aborted) onAbort();
|
|
566
583
|
});
|
|
567
584
|
}
|
|
568
585
|
/**
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@alfe.ai/remote",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"description": "Runtime-agnostic transport for the Alfe interactive remote-control relay — multiplexes browser screencast and terminal PTY surfaces over one outbound WebSocket",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|