turno-browser 0.7.0 → 0.8.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/CHANGELOG.md +13 -0
- package/README.md +5 -1
- package/dist/act.js +4 -29
- package/dist/agent-cursor-overlay.d.ts +10 -0
- package/dist/agent-cursor-overlay.js +50 -5
- package/dist/agent-cursor.d.ts +39 -7
- package/dist/agent-cursor.js +106 -20
- package/dist/cli/flows.js +3 -0
- package/dist/cli/identity.js +3 -4
- package/dist/cli/init.js +4 -2
- package/dist/engine-camoufox.js +1 -0
- package/dist/engine-lightpanda.js +1 -0
- package/dist/host.d.ts +7 -0
- package/dist/host.js +313 -76
- package/dist/human-step-overlay.d.ts +73 -0
- package/dist/human-step-overlay.js +285 -0
- package/dist/human-step.d.ts +128 -0
- package/dist/human-step.js +521 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/live-server.d.ts +7 -3
- package/dist/live-server.js +13 -15
- package/dist/live.d.ts +20 -1
- package/dist/live.js +52 -10
- package/dist/network-redact.d.ts +28 -0
- package/dist/network-redact.js +202 -0
- package/dist/recorder.d.ts +0 -21
- package/dist/recorder.js +1 -41
- package/dist/recordings.d.ts +5 -0
- package/dist/recordings.js +4 -2
- package/dist/redact.d.ts +7 -0
- package/dist/redact.js +32 -1
- package/dist/replay.d.ts +2 -0
- package/dist/replay.js +33 -14
- package/dist/reputation.d.ts +5 -0
- package/dist/reputation.js +12 -7
- package/dist/sensitive.d.ts +79 -0
- package/dist/sensitive.js +275 -0
- package/dist/session.d.ts +12 -0
- package/dist/session.js +24 -0
- package/dist/tools.d.ts +5 -0
- package/dist/tools.js +9 -1
- package/dist/upstream.d.ts +5 -0
- package/dist/watch.d.ts +60 -0
- package/dist/watch.js +114 -0
- package/npm-shrinkwrap.json +2 -2
- package/package.json +1 -1
package/dist/watch.d.ts
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import type { Page } from "patchright-core";
|
|
2
|
+
import { PauseGate, type PauseHold, type TabState } from "./live.js";
|
|
3
|
+
import type { LiveBrowser } from "./live-server.js";
|
|
4
|
+
/**
|
|
5
|
+
* What the host holds calls with and compares the tabs by: the pause gate of one browser, the
|
|
6
|
+
* tab each session worked on last, and the calls in flight. With the live view on it is the live
|
|
7
|
+
* server (`live-server.ts`), which also streams the page and takes the user's own pause. Without
|
|
8
|
+
* it, a `PlainWatch` does the same for the pauses a call can start itself: a person step
|
|
9
|
+
* (`browser_request_human`) holds every session of the browser while the person acts.
|
|
10
|
+
*/
|
|
11
|
+
export interface BrowserWatch {
|
|
12
|
+
readonly gate: PauseGate;
|
|
13
|
+
readonly paused: boolean;
|
|
14
|
+
/** How long a call held by the user's own pause waits. */
|
|
15
|
+
readonly waitMs: number;
|
|
16
|
+
/** Agent calls running now. */
|
|
17
|
+
readonly inFlight: number;
|
|
18
|
+
/** A browser launched; returns what to call when it goes away. */
|
|
19
|
+
bind(browser: LiveBrowser): () => void;
|
|
20
|
+
/** The page a call of `session` worked on. */
|
|
21
|
+
follow(session: string, page: Page | undefined): void;
|
|
22
|
+
/** The page the last call of `session` worked on (it may have closed since). */
|
|
23
|
+
lastPage(session: string): Page | undefined;
|
|
24
|
+
/** The id the notes give a tab. */
|
|
25
|
+
idOf(page: Page): number;
|
|
26
|
+
/** The tabs now, as the notes compare them. */
|
|
27
|
+
tabStates(): Promise<TabState[]>;
|
|
28
|
+
/** An agent call starts; returns what to call when it ends. */
|
|
29
|
+
begin(): () => void;
|
|
30
|
+
/** Starts a pause (false when one is on); `front` brings the shown tab to the front. */
|
|
31
|
+
pause(by: string, front?: boolean, hold?: PauseHold): Promise<boolean>;
|
|
32
|
+
/** Ends the pause and lets the held calls go; false when there was none. */
|
|
33
|
+
resume(): boolean;
|
|
34
|
+
}
|
|
35
|
+
/** The tab's title, or "" when the page does not answer within a second. */
|
|
36
|
+
export declare function titleOf(page: Page): Promise<string>;
|
|
37
|
+
/** The watch of a browser without the live view: no stream, no socket, no user pause. */
|
|
38
|
+
export declare class PlainWatch implements BrowserWatch {
|
|
39
|
+
readonly waitMs: number;
|
|
40
|
+
readonly gate: PauseGate;
|
|
41
|
+
private browser;
|
|
42
|
+
private heldBrowser;
|
|
43
|
+
private readonly lastBySession;
|
|
44
|
+
private readonly ids;
|
|
45
|
+
private nextId;
|
|
46
|
+
private busy;
|
|
47
|
+
constructor(waitMs?: number);
|
|
48
|
+
get paused(): boolean;
|
|
49
|
+
get inFlight(): number;
|
|
50
|
+
bind(browser: LiveBrowser): () => void;
|
|
51
|
+
follow(session: string, page: Page | undefined): void;
|
|
52
|
+
lastPage(session: string): Page | undefined;
|
|
53
|
+
idOf(page: Page): number;
|
|
54
|
+
/** The agent's pages: every page, or in attach mode only those the agent worked on. */
|
|
55
|
+
private pages;
|
|
56
|
+
tabStates(): Promise<TabState[]>;
|
|
57
|
+
begin(): () => void;
|
|
58
|
+
pause(by: string, _front?: boolean, hold?: PauseHold): Promise<boolean>;
|
|
59
|
+
resume(): boolean;
|
|
60
|
+
}
|
package/dist/watch.js
ADDED
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
import { DEFAULT_LIVE_WAIT_MS, PauseGate } from "./live.js";
|
|
2
|
+
/** The tab's title, or "" when the page does not answer within a second. */
|
|
3
|
+
export async function titleOf(page) {
|
|
4
|
+
let timer;
|
|
5
|
+
const late = new Promise((r) => {
|
|
6
|
+
timer = setTimeout(() => r(""), 1_000);
|
|
7
|
+
});
|
|
8
|
+
try {
|
|
9
|
+
return await Promise.race([page.title().catch(() => ""), late]);
|
|
10
|
+
}
|
|
11
|
+
finally {
|
|
12
|
+
clearTimeout(timer);
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
/** The watch of a browser without the live view: no stream, no socket, no user pause. */
|
|
16
|
+
export class PlainWatch {
|
|
17
|
+
waitMs;
|
|
18
|
+
gate = new PauseGate();
|
|
19
|
+
browser;
|
|
20
|
+
heldBrowser;
|
|
21
|
+
lastBySession = new Map();
|
|
22
|
+
ids = new WeakMap();
|
|
23
|
+
nextId = 1;
|
|
24
|
+
busy = 0;
|
|
25
|
+
constructor(waitMs = DEFAULT_LIVE_WAIT_MS) {
|
|
26
|
+
this.waitMs = waitMs;
|
|
27
|
+
}
|
|
28
|
+
get paused() {
|
|
29
|
+
return this.gate.paused !== undefined;
|
|
30
|
+
}
|
|
31
|
+
get inFlight() {
|
|
32
|
+
return this.busy;
|
|
33
|
+
}
|
|
34
|
+
bind(browser) {
|
|
35
|
+
this.browser = browser;
|
|
36
|
+
this.lastBySession.clear();
|
|
37
|
+
if (this.paused && this.heldBrowser !== browser) {
|
|
38
|
+
this.heldBrowser = browser;
|
|
39
|
+
void browser.onPause?.().catch(() => { });
|
|
40
|
+
}
|
|
41
|
+
return () => {
|
|
42
|
+
if (this.browser !== browser)
|
|
43
|
+
return;
|
|
44
|
+
this.browser = undefined;
|
|
45
|
+
if (this.heldBrowser === browser)
|
|
46
|
+
this.heldBrowser = undefined;
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
follow(session, page) {
|
|
50
|
+
if (page && !page.isClosed())
|
|
51
|
+
this.lastBySession.set(session, page);
|
|
52
|
+
}
|
|
53
|
+
lastPage(session) {
|
|
54
|
+
return this.lastBySession.get(session);
|
|
55
|
+
}
|
|
56
|
+
idOf(page) {
|
|
57
|
+
let id = this.ids.get(page);
|
|
58
|
+
if (id === undefined) {
|
|
59
|
+
id = this.nextId++;
|
|
60
|
+
this.ids.set(page, id);
|
|
61
|
+
}
|
|
62
|
+
return id;
|
|
63
|
+
}
|
|
64
|
+
/** The agent's pages: every page, or in attach mode only those the agent worked on. */
|
|
65
|
+
pages() {
|
|
66
|
+
const b = this.browser;
|
|
67
|
+
if (!b)
|
|
68
|
+
return [];
|
|
69
|
+
if (b.userBrowser)
|
|
70
|
+
return [...new Set(this.lastBySession.values())].filter((p) => !p.isClosed());
|
|
71
|
+
try {
|
|
72
|
+
return b.context.pages().filter((p) => !p.isClosed());
|
|
73
|
+
}
|
|
74
|
+
catch {
|
|
75
|
+
return [];
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
async tabStates() {
|
|
79
|
+
return await Promise.all(this.pages().map(async (p) => ({
|
|
80
|
+
id: this.idOf(p),
|
|
81
|
+
url: this.browser?.urlOf?.(p) ?? p.url(),
|
|
82
|
+
title: await titleOf(p),
|
|
83
|
+
})));
|
|
84
|
+
}
|
|
85
|
+
begin() {
|
|
86
|
+
this.busy++;
|
|
87
|
+
let done = false;
|
|
88
|
+
return () => {
|
|
89
|
+
if (done)
|
|
90
|
+
return;
|
|
91
|
+
done = true;
|
|
92
|
+
this.busy--;
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
async pause(by, _front = false, hold = {}) {
|
|
96
|
+
if (!this.gate.start(by, this.tabStates(), hold))
|
|
97
|
+
return false;
|
|
98
|
+
const b = this.browser;
|
|
99
|
+
if (b) {
|
|
100
|
+
this.heldBrowser = b;
|
|
101
|
+
await b.onPause?.().catch(() => { });
|
|
102
|
+
}
|
|
103
|
+
return true;
|
|
104
|
+
}
|
|
105
|
+
resume() {
|
|
106
|
+
if (!this.gate.resume())
|
|
107
|
+
return false;
|
|
108
|
+
const b = this.heldBrowser;
|
|
109
|
+
this.heldBrowser = undefined;
|
|
110
|
+
b?.onResume?.();
|
|
111
|
+
return true;
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
//# sourceMappingURL=watch.js.map
|
package/npm-shrinkwrap.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "turno-browser",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.8.0",
|
|
4
4
|
"lockfileVersion": 3,
|
|
5
5
|
"requires": true,
|
|
6
6
|
"packages": {
|
|
7
7
|
"": {
|
|
8
8
|
"name": "turno-browser",
|
|
9
|
-
"version": "0.
|
|
9
|
+
"version": "0.8.0",
|
|
10
10
|
"license": "Apache-2.0",
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"@modelcontextprotocol/sdk": "1.32.2",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "turno-browser",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.8.0",
|
|
4
4
|
"description": "A browser your agents use with your accounts. It stays light on your machine, and the model never sees your passwords.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"author": "William Frank Monroy Mamani (https://github.com/william-monroy)",
|