turno-browser 0.4.0 → 0.5.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 +24 -0
- package/README.md +92 -149
- package/dist/act-model.js +4 -3
- package/dist/act.js +2 -1
- package/dist/api.d.ts +63 -2
- package/dist/api.js +14 -4
- package/dist/background-state.d.ts +54 -0
- package/dist/background-state.js +97 -0
- package/dist/background.d.ts +69 -0
- package/dist/background.js +458 -0
- package/dist/bin/mcp.js +48 -8
- package/dist/captcha.js +3 -2
- package/dist/cli/background.d.ts +11 -0
- package/dist/cli/background.js +132 -0
- package/dist/cli/commands.d.ts +16 -0
- package/dist/cli/commands.js +515 -0
- package/dist/cli/context.d.ts +75 -0
- package/dist/cli/context.js +44 -0
- package/dist/cli/do-background.d.ts +27 -0
- package/dist/cli/do-background.js +212 -0
- package/dist/cli/do.d.ts +85 -0
- package/dist/cli/do.js +558 -0
- package/dist/cli/flows.d.ts +28 -0
- package/dist/cli/flows.js +303 -0
- package/dist/cli/identity.d.ts +37 -0
- package/dist/cli/identity.js +906 -0
- package/dist/cli/live.d.ts +7 -0
- package/dist/cli/live.js +99 -0
- package/dist/cli/main.d.ts +16 -0
- package/dist/cli/main.js +171 -0
- package/dist/cli/secret.d.ts +4 -0
- package/dist/cli/secret.js +151 -0
- package/dist/cli/session.d.ts +6 -0
- package/dist/cli/session.js +106 -0
- package/dist/cli/setup.d.ts +7 -0
- package/dist/cli/setup.js +180 -0
- package/dist/cli/vault.d.ts +5 -0
- package/dist/cli/vault.js +192 -0
- package/dist/client.d.ts +82 -0
- package/dist/client.js +303 -0
- package/dist/doctor.js +34 -1
- package/dist/engine-camoufox.js +5 -4
- package/dist/engine-lightpanda.js +3 -2
- package/dist/engine.js +2 -1
- package/dist/health.js +2 -1
- package/dist/host.d.ts +21 -0
- package/dist/host.js +75 -15
- package/dist/human-input.js +7 -2
- package/dist/identities.js +2 -1
- package/dist/index.d.ts +5 -1
- package/dist/index.js +2 -0
- package/dist/lifecycle.d.ts +2 -0
- package/dist/lifecycle.js +2 -1
- package/dist/live-client.js +8 -6
- package/dist/live-page.d.ts +0 -7
- package/dist/live-page.js +3 -2
- package/dist/live-server.js +6 -3
- package/dist/live.js +2 -1
- package/dist/login-tool.js +3 -2
- package/dist/login.js +2 -1
- package/dist/names.d.ts +28 -0
- package/dist/names.js +25 -0
- package/dist/network.d.ts +1 -1
- package/dist/network.js +4 -3
- package/dist/opt-in-settings.js +3 -2
- package/dist/replay.js +4 -3
- package/dist/runtime-lock.js +3 -2
- package/dist/vault.js +5 -4
- package/npm-shrinkwrap.json +6 -5
- package/package.json +13 -7
package/dist/human-input.js
CHANGED
|
@@ -31,8 +31,13 @@ export const HUMANIZED_TOOLS = new Set([
|
|
|
31
31
|
"browser_mouse_drag_xy",
|
|
32
32
|
"browser_mouse_wheel",
|
|
33
33
|
]);
|
|
34
|
-
/**
|
|
35
|
-
|
|
34
|
+
/**
|
|
35
|
+
* How long the steps before an action wait for its element: past it, Playwright's own call runs
|
|
36
|
+
* (a plain fill or click, without the human-like path). 1 second was too short on a busy machine,
|
|
37
|
+
* where reading the field or aiming at it can take longer and the action quietly lost its
|
|
38
|
+
* humanize; the wait only runs out when the element is missing, so a longer one costs little.
|
|
39
|
+
*/
|
|
40
|
+
const PREPARE_TIMEOUT_MS = 3000;
|
|
36
41
|
/** A scroll longer than this is a jump (a person drags the scroll bar or presses End). */
|
|
37
42
|
const MAX_WHEEL_PX = 3000;
|
|
38
43
|
/** How far back the reputation log makes `adaptive` use `full` on a site. */
|
package/dist/identities.js
CHANGED
|
@@ -7,6 +7,7 @@ import { removeFlows } from "./flows.js";
|
|
|
7
7
|
import { inUseMessage, readRuntimeLock, runtimeLockAlive } from "./runtime-lock.js";
|
|
8
8
|
import { identitySettingsPath, systemTimezone, writeIdentitySettings } from "./settings.js";
|
|
9
9
|
import { vaultHasSites, vaultPath } from "./vault.js";
|
|
10
|
+
import { names } from "./names.js";
|
|
10
11
|
export { IdentityError, assertIdentityId, identityDir, identityStateDir, isValidIdentityId };
|
|
11
12
|
export function identityExists(id, env = process.env) {
|
|
12
13
|
const dir = identityDir(id, env);
|
|
@@ -62,7 +63,7 @@ export function removeIdentity(id, env = process.env) {
|
|
|
62
63
|
if (isInUse(id, env))
|
|
63
64
|
throw new IdentityError(`identity "${id}" is in use by a running Chrome; close it first`);
|
|
64
65
|
if (vaultHasSites(id, env))
|
|
65
|
-
throw new IdentityError(`identity "${id}" still has vault credentials; remove them first (
|
|
66
|
+
throw new IdentityError(`identity "${id}" still has vault credentials; remove them first (${names().browser} remove does)`);
|
|
66
67
|
rmSync(dir, { recursive: true, force: true });
|
|
67
68
|
rmSync(vaultPath(id, env), { force: true });
|
|
68
69
|
rmSync(identitySettingsPath(id, env), { force: true });
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
export { API_VERSION, type ApiVersion, type BrowserApi, api } from "./api.js";
|
|
1
|
+
export { API_VERSION, type ApiVersion, type BrowserApi, type BrowserFunctions, api } from "./api.js";
|
|
2
|
+
export { type BrowserCli, browserCli as cli } from "./cli/commands.js";
|
|
3
|
+
export type { BrowserCliHost, CliDeps, CliNames, OpenUrl, VaultInput } from "./cli/context.js";
|
|
4
|
+
export type { DoSession, DoSessionInfo, DoTarget, DoTransport, ToolResult } from "./cli/do.js";
|
|
2
5
|
export { SESSION_CAPABILITY, SESSION_ENDED_METHOD, SESSION_META_KEY } from "./session.js";
|
|
3
6
|
export { manifestSnippet } from "./snippet.js";
|
|
4
7
|
export { IdentityError, type IdentityInfo, addIdentity, assertIdentityId, identityDir, identityExists, identityStateDir, inUseBy, isInUse, isValidIdentityId, listIdentities, parseSingletonLock, removeIdentity, } from "./identities.js";
|
|
@@ -12,6 +15,7 @@ export { type BenchOptions, type BenchReport, DETECTORS, ENGINES, ENGINE_ALIASES
|
|
|
12
15
|
export { CHALLENGE_MARKERS, type ChallengeKind, classifyChallenge, detectChallenge, parseRebrowser, parseSannysoft, } from "./detectors.js";
|
|
13
16
|
export { type LoginOptions, loginIdentity } from "./login.js";
|
|
14
17
|
export { LiveError, liveLink, livePause, liveResume, liveStatus } from "./live-client.js";
|
|
18
|
+
export { BackgroundError, type BackgroundSession, type BackgroundState, type CallOptions, type OpenSessionOptions, type StartBackgroundOptions, type StartedBackground, backgroundStatus, openBackgroundSession, startBackground, stopBackground, } from "./client.js";
|
|
15
19
|
export type { LiveStatus } from "./live-server.js";
|
|
16
20
|
export { type TotpParams, TotpError, parseTotpSecret, totp } from "./totp.js";
|
|
17
21
|
export { SealError } from "./sealed.js";
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { fileURLToPath } from "node:url";
|
|
2
2
|
export { API_VERSION, api } from "./api.js";
|
|
3
|
+
export { browserCli as cli } from "./cli/commands.js";
|
|
3
4
|
export { SESSION_CAPABILITY, SESSION_ENDED_METHOD, SESSION_META_KEY } from "./session.js";
|
|
4
5
|
export { manifestSnippet } from "./snippet.js";
|
|
5
6
|
export { IdentityError, addIdentity, assertIdentityId, identityDir, identityExists, identityStateDir, inUseBy, isInUse, isValidIdentityId, listIdentities, parseSingletonLock, removeIdentity, } from "./identities.js";
|
|
@@ -13,6 +14,7 @@ export { DETECTORS, ENGINES, ENGINE_ALIASES, defaultEngines, engineId, formatBen
|
|
|
13
14
|
export { CHALLENGE_MARKERS, classifyChallenge, detectChallenge, parseRebrowser, parseSannysoft, } from "./detectors.js";
|
|
14
15
|
export { loginIdentity } from "./login.js";
|
|
15
16
|
export { LiveError, liveLink, livePause, liveResume, liveStatus } from "./live-client.js";
|
|
17
|
+
export { BackgroundError, backgroundStatus, openBackgroundSession, startBackground, stopBackground, } from "./client.js";
|
|
16
18
|
export { TotpError, parseTotpSecret, totp } from "./totp.js";
|
|
17
19
|
export { SealError } from "./sealed.js";
|
|
18
20
|
export { exportSession, importSession, readSessionExport, } from "./session-export.js";
|
package/dist/lifecycle.d.ts
CHANGED
|
@@ -87,6 +87,8 @@ export interface ShutdownOptions {
|
|
|
87
87
|
graceMs?: number;
|
|
88
88
|
/** Time Chrome gets after SIGTERM before this process exits and its group gets SIGKILL. */
|
|
89
89
|
termMs?: number;
|
|
90
|
+
/** False for a server without an MCP client on stdin (`--background`): its stdin closing means nothing. */
|
|
91
|
+
stdin?: boolean;
|
|
90
92
|
}
|
|
91
93
|
/**
|
|
92
94
|
* Bound the shutdown of this server. The program's own watchdog closes the browser when stdin
|
package/dist/lifecycle.js
CHANGED
|
@@ -156,7 +156,8 @@ export function installShutdownGuard(userDataDir, opts = {}) {
|
|
|
156
156
|
setTimeout(() => process.exit(0), termMs).unref();
|
|
157
157
|
}, graceMs).unref();
|
|
158
158
|
};
|
|
159
|
-
|
|
159
|
+
if (opts.stdin !== false)
|
|
160
|
+
process.stdin.once("close", begin);
|
|
160
161
|
process.on("SIGTERM", begin);
|
|
161
162
|
process.on("SIGINT", begin);
|
|
162
163
|
process.on("SIGHUP", () => {
|
package/dist/live-client.js
CHANGED
|
@@ -3,6 +3,7 @@ import { request } from "node:http";
|
|
|
3
3
|
import { pidAlive } from "turno-core/process";
|
|
4
4
|
import { assertIdentityId } from "./ids.js";
|
|
5
5
|
import { liveFilePath } from "./live.js";
|
|
6
|
+
import { names } from "./names.js";
|
|
6
7
|
/**
|
|
7
8
|
* What `turno browser live|pause|resume` use: the running server's live view, reached over its
|
|
8
9
|
* control socket (`live-server.ts`). Nothing here holds a token; a link for the view comes
|
|
@@ -30,7 +31,7 @@ export function readLiveFile(id, env = process.env) {
|
|
|
30
31
|
}
|
|
31
32
|
return data;
|
|
32
33
|
}
|
|
33
|
-
function call(socket, method, path) {
|
|
34
|
+
function call(socket, method, path, payload = {}) {
|
|
34
35
|
return new Promise((resolve, reject) => {
|
|
35
36
|
const req = request({ socketPath: socket, method, path, headers: { host: "turno-live" }, timeout: 10_000 }, (res) => {
|
|
36
37
|
const chunks = [];
|
|
@@ -49,18 +50,18 @@ function call(socket, method, path) {
|
|
|
49
50
|
req.on("timeout", () => req.destroy(new Error("the live view server did not answer in 10s")));
|
|
50
51
|
req.on("error", reject);
|
|
51
52
|
if (method === "POST")
|
|
52
|
-
req.end(
|
|
53
|
+
req.end(JSON.stringify(payload));
|
|
53
54
|
else
|
|
54
55
|
req.end();
|
|
55
56
|
});
|
|
56
57
|
}
|
|
57
|
-
async function ask(id, method, path, env) {
|
|
58
|
+
async function ask(id, method, path, env, payload) {
|
|
58
59
|
const live = readLiveFile(id, env);
|
|
59
60
|
if (!live)
|
|
60
|
-
throw new LiveError(`no turno-browser-mcp serves "${id}" with the live view right now. It is off by default: turn it on with
|
|
61
|
+
throw new LiveError(`no turno-browser-mcp serves "${id}" with the live view right now. It is off by default: turn it on with ${names().browser} set ${id} --live true, and it starts with the next server (an agent session starts one).`);
|
|
61
62
|
let out;
|
|
62
63
|
try {
|
|
63
|
-
out = await call(live.socket, method, path);
|
|
64
|
+
out = await call(live.socket, method, path, payload);
|
|
64
65
|
}
|
|
65
66
|
catch (error) {
|
|
66
67
|
throw new LiveError(`cannot reach the live view of "${id}" (pid ${live.pid}): ${error.message}`);
|
|
@@ -78,7 +79,8 @@ export async function liveStatus(id, env = process.env) {
|
|
|
78
79
|
}
|
|
79
80
|
/** Pauses the agent of `id`: its next call waits until `liveResume`. */
|
|
80
81
|
export async function livePause(id, env = process.env) {
|
|
81
|
-
|
|
82
|
+
// The command the person typed, so the agent is told who paused it (`turno browser pause` inside turno).
|
|
83
|
+
return (await ask(id, "POST", "/pause", env, { by: `${names().browser} pause` }));
|
|
82
84
|
}
|
|
83
85
|
export async function liveResume(id, env = process.env) {
|
|
84
86
|
return (await ask(id, "POST", "/resume", env));
|
package/dist/live-page.d.ts
CHANGED
|
@@ -1,10 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* The live view page: one HTML document with its style and script inline, allowed by a nonce
|
|
3
|
-
* in the Content-Security-Policy. It reads the server's events (`/events`: the state and the
|
|
4
|
-
* frames of the tab it shows), and posts Pause, Resume, the tab to show and, while the agent is
|
|
5
|
-
* paused, the user's clicks, keys and scrolls. Text from pages (titles, URLs) only ever goes into
|
|
6
|
-
* `textContent`, never into HTML.
|
|
7
|
-
*/
|
|
8
1
|
/** The page, with the nonce the response's Content-Security-Policy allows. */
|
|
9
2
|
export declare function livePage(nonce: string): string;
|
|
10
3
|
/** What a browser without the view's cookie sees. */
|
package/dist/live-page.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { names } from "./names.js";
|
|
1
2
|
/**
|
|
2
3
|
* The live view page: one HTML document with its style and script inline, allowed by a nonce
|
|
3
4
|
* in the Content-Security-Policy. It reads the server's events (`/events`: the state and the
|
|
@@ -83,7 +84,7 @@ events.addEventListener("frame", (e) => {
|
|
|
83
84
|
size = { w: f.w, h: f.h };
|
|
84
85
|
frame.src = "data:image/jpeg;base64," + f.data;
|
|
85
86
|
});
|
|
86
|
-
events.onerror = () => { $("status").textContent = "Disconnected: the server stopped or restarted. Open the view again with turno
|
|
87
|
+
events.onerror = () => { $("status").textContent = "Disconnected: the server stopped or restarted. Open the view again with turno-browser live."; };
|
|
87
88
|
$("pause").onclick = () => post("/pause");
|
|
88
89
|
$("resume").onclick = () => post("/resume");
|
|
89
90
|
function point(e) {
|
|
@@ -137,7 +138,7 @@ export function livePage(nonce) {
|
|
|
137
138
|
export function deniedPage(identity) {
|
|
138
139
|
return `<!doctype html>
|
|
139
140
|
<html lang="en"><head><meta charset="utf-8"><title>turno live view</title></head>
|
|
140
|
-
<body><p>This live view needs a fresh link. Run <code
|
|
141
|
+
<body><p>This live view needs a fresh link. Run <code>${names().browser} live ${identity}</code>: it opens one that works once.</p></body></html>
|
|
141
142
|
`;
|
|
142
143
|
}
|
|
143
144
|
//# sourceMappingURL=live-page.js.map
|
package/dist/live-server.js
CHANGED
|
@@ -5,6 +5,7 @@ import { tmpdir } from "node:os";
|
|
|
5
5
|
import { dirname, join } from "node:path";
|
|
6
6
|
import { PauseGate, liveFilePath } from "./live.js";
|
|
7
7
|
import { deniedPage, livePage } from "./live-page.js";
|
|
8
|
+
import { names } from "./names.js";
|
|
8
9
|
/** How long a link's code works. */
|
|
9
10
|
const CODE_MS = 2 * 60_000;
|
|
10
11
|
/** Largest request body accepted. */
|
|
@@ -168,7 +169,7 @@ export class LiveServer {
|
|
|
168
169
|
v.write(": ping\n\n");
|
|
169
170
|
}, 15_000);
|
|
170
171
|
this.heartbeat.unref();
|
|
171
|
-
this.o.log?.(`live view on http://127.0.0.1:${this.port} for "${this.o.identity.id}"; open it with:
|
|
172
|
+
this.o.log?.(`live view on http://127.0.0.1:${this.port} for "${this.o.identity.id}"; open it with: ${names().browser} live ${this.o.identity.id}`);
|
|
172
173
|
}
|
|
173
174
|
cleanupFiles() {
|
|
174
175
|
const file = liveFilePath(this.o.identity.id, this.o.identity.env);
|
|
@@ -520,8 +521,10 @@ export class LiveServer {
|
|
|
520
521
|
if (route === "GET /events" && !trusted)
|
|
521
522
|
return this.events(req, res);
|
|
522
523
|
if (route === "POST /pause") {
|
|
523
|
-
await readJson(req);
|
|
524
|
-
|
|
524
|
+
const body = await readJson(req);
|
|
525
|
+
// The command that paused, as the local client names it; only a short command name is taken.
|
|
526
|
+
const by = typeof body.by === "string" && /^[a-z][a-z -]{0,38} pause$/.test(body.by) ? body.by : undefined;
|
|
527
|
+
await this.pause(trusted ? (by ?? `${names().browser} pause`) : "the live view", trusted);
|
|
525
528
|
return this.json(res, 200, await this.fullStatus());
|
|
526
529
|
}
|
|
527
530
|
if (route === "POST /resume") {
|
package/dist/live.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { join } from "node:path";
|
|
2
2
|
import { identityStateDir } from "./ids.js";
|
|
3
3
|
import { parseDuration } from "./units.js";
|
|
4
|
+
import { names } from "./names.js";
|
|
4
5
|
/**
|
|
5
6
|
* The live view and take-over, the part that needs no browser: the policy (identity.json `live`
|
|
6
7
|
* and the server flags), the pause gate that holds the agent's calls while the user acts, and
|
|
@@ -198,6 +199,6 @@ export function resumeNote(o) {
|
|
|
198
199
|
export function timeoutMessage(identity, tool, pausedMs, by, waitMs) {
|
|
199
200
|
return (`The user paused browser identity "${identity}" ${formatPause(pausedMs)} ago (${by}) and has not resumed it ` +
|
|
200
201
|
`within ${formatPause(waitMs)}, so ${tool} was not run. The user is probably acting in the browser: wait, or ask ` +
|
|
201
|
-
`them to resume (Resume in the live view, or
|
|
202
|
+
`them to resume (Resume in the live view, or ${names().browser} resume ${identity}), then call again.`);
|
|
202
203
|
}
|
|
203
204
|
//# sourceMappingURL=live.js.map
|
package/dist/login-tool.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { totp, totpSecondsLeft } from "./totp.js";
|
|
2
2
|
import { upstream } from "./upstream.js";
|
|
3
3
|
import { VaultError, originAllowed, readCredential, vaultSite } from "./vault.js";
|
|
4
|
+
import { names as commandNames } from "./names.js";
|
|
4
5
|
const TEXT = ':not([type="password"]):not([type="hidden"]):not([type="checkbox"]):not([type="radio"]):not([type="submit"]):not([type="button"])';
|
|
5
6
|
const SELECTORS = {
|
|
6
7
|
password: 'input[type="password"]',
|
|
@@ -49,7 +50,7 @@ function schema() {
|
|
|
49
50
|
"You name the site; the values are never shown to you, and they are hidden from every later result of this server.",
|
|
50
51
|
"The current page must be on the site's own sign-in page (the origins it was stored with).",
|
|
51
52
|
"Fields found on the page are filled (a two-step sign-in needs one call per step). It does not submit the form unless the identity allows it: click the sign-in button yourself afterwards.",
|
|
52
|
-
|
|
53
|
+
`The person adds credentials with \`${commandNames().browser} vault add <identity> <site>\`.`,
|
|
53
54
|
].join(" "),
|
|
54
55
|
inputSchema: z.object({
|
|
55
56
|
site: z.string().describe("The site key in the vault, for example github"),
|
|
@@ -119,7 +120,7 @@ export function loginTool() {
|
|
|
119
120
|
const siteKey = params.site;
|
|
120
121
|
const found = vaultSite(id, siteKey, env);
|
|
121
122
|
if (!found)
|
|
122
|
-
throw new VaultError(`identity "${id}" has no credentials for "${siteKey}" in its vault; the person adds them with:
|
|
123
|
+
throw new VaultError(`identity "${id}" has no credentials for "${siteKey}" in its vault; the person adds them with: ${commandNames().browser} vault add ${id} ${siteKey} --url <sign-in page>`);
|
|
123
124
|
const { site, submit } = found;
|
|
124
125
|
const page = ctx.stock?.currentPage();
|
|
125
126
|
if (!page)
|
package/dist/login.js
CHANGED
|
@@ -5,6 +5,7 @@ import { readLockPid } from "./lifecycle.js";
|
|
|
5
5
|
import { CHROME_PROXY_ARGS, resolveProxy } from "./network.js";
|
|
6
6
|
import { acquireRuntimeLock } from "./runtime-lock.js";
|
|
7
7
|
import { chromeEnv, keychainArgs, launchSettings, readIdentitySettings, systemTimezone } from "./settings.js";
|
|
8
|
+
import { names } from "./names.js";
|
|
8
9
|
/**
|
|
9
10
|
* Opens the identity's persistent Chrome headed, with the same launch settings as the MCP
|
|
10
11
|
* server (Chrome channel, no fixed viewport, the identity's languages and time zone), and
|
|
@@ -25,7 +26,7 @@ export async function loginIdentity(id, options = {}) {
|
|
|
25
26
|
throw new IdentityError(`identity "${id}" is in use (an MCP session holds its Chrome); close it first`);
|
|
26
27
|
const settings = readIdentitySettings(id, env);
|
|
27
28
|
if (settings?.engine === "camoufox" && settings.attach === undefined)
|
|
28
|
-
throw new IdentityError(`identity "${id}" runs on Camoufox, which keeps its own profile, and
|
|
29
|
+
throw new IdentityError(`identity "${id}" runs on Camoufox, which keeps its own profile, and \`${names().browser} login\` opens the Chrome profile: sign in from an agent session (browser_login with the vault), or use --engine chrome`);
|
|
29
30
|
// Read before the lock, so a missing secret leaves nothing to undo; the value goes only to Chrome.
|
|
30
31
|
const proxy = settings?.proxy ? await resolveProxy(settings.proxy, env, () => { }) : undefined;
|
|
31
32
|
const held = acquireRuntimeLock(id, env, { holder: "login" });
|
package/dist/names.d.ts
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* How the commands a message suggests are typed. turno-browser's own commands work for every
|
|
3
|
+
* install, so messages name them by default (`turno-browser login school`), the MCP server's
|
|
4
|
+
* included. When turno-cli runs the identity commands as `turno browser <cmd>` and
|
|
5
|
+
* `turno identity ... browser:<id>`, its host sets turno's names for that process, so its
|
|
6
|
+
* hints, errors and doctor fixes keep naming the commands the person typed.
|
|
7
|
+
*/
|
|
8
|
+
/** How the commands are typed, for hints, examples and messages. */
|
|
9
|
+
export interface CliNames {
|
|
10
|
+
/** The program, as errors start: `turno-browser` or `turno`. */
|
|
11
|
+
program: string;
|
|
12
|
+
/** How a browser subcommand is typed: `turno-browser` or `turno browser`. */
|
|
13
|
+
browser: string;
|
|
14
|
+
/** The word messages put before a subcommand name: "" or "browser ". */
|
|
15
|
+
subject: string;
|
|
16
|
+
/** How a command on one identity is typed: `turno-browser add school`, `turno identity add browser:school`. */
|
|
17
|
+
identity(sub: string, id: string): string;
|
|
18
|
+
/** How a person stores a secret store item that a `keychain:<item>` reference names. */
|
|
19
|
+
secretSet(item: string): string;
|
|
20
|
+
/** The secret store in short, where a line has no room for `secretSet` (default: `secretSet("<item>")`). */
|
|
21
|
+
secretStore?: string;
|
|
22
|
+
}
|
|
23
|
+
/** The names of turno-browser on its own. */
|
|
24
|
+
export declare const STANDALONE_NAMES: CliNames;
|
|
25
|
+
/** The names messages of this process use. */
|
|
26
|
+
export declare function names(): CliNames;
|
|
27
|
+
/** Use `n` for the messages of this process (a host's names); `STANDALONE_NAMES` restores. */
|
|
28
|
+
export declare function useNames(n: CliNames): void;
|
package/dist/names.js
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* How the commands a message suggests are typed. turno-browser's own commands work for every
|
|
3
|
+
* install, so messages name them by default (`turno-browser login school`), the MCP server's
|
|
4
|
+
* included. When turno-cli runs the identity commands as `turno browser <cmd>` and
|
|
5
|
+
* `turno identity ... browser:<id>`, its host sets turno's names for that process, so its
|
|
6
|
+
* hints, errors and doctor fixes keep naming the commands the person typed.
|
|
7
|
+
*/
|
|
8
|
+
/** The names of turno-browser on its own. */
|
|
9
|
+
export const STANDALONE_NAMES = {
|
|
10
|
+
program: "turno-browser",
|
|
11
|
+
browser: "turno-browser",
|
|
12
|
+
subject: "",
|
|
13
|
+
identity: (sub, id) => `turno-browser ${sub} ${id}`,
|
|
14
|
+
secretSet: (item) => `turno-browser secret set ${item}`,
|
|
15
|
+
};
|
|
16
|
+
let current = STANDALONE_NAMES;
|
|
17
|
+
/** The names messages of this process use. */
|
|
18
|
+
export function names() {
|
|
19
|
+
return current;
|
|
20
|
+
}
|
|
21
|
+
/** Use `n` for the messages of this process (a host's names); `STANDALONE_NAMES` restores. */
|
|
22
|
+
export function useNames(n) {
|
|
23
|
+
current = n;
|
|
24
|
+
}
|
|
25
|
+
//# sourceMappingURL=names.js.map
|
package/dist/network.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { type SecretStore } from "turno-core/secrets";
|
|
2
2
|
/**
|
|
3
3
|
* Opt-in network and user agent settings of an identity (identity.json format 11), both off by
|
|
4
|
-
* default
|
|
4
|
+
* default and the user's choice: a real Chrome on the user's own connection is already
|
|
5
5
|
* the most coherent browser a site can see, and these settings can only keep it coherent or
|
|
6
6
|
* break it. The docs say what each one costs.
|
|
7
7
|
*
|
package/dist/network.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { secretStore } from "turno-core/secrets";
|
|
2
|
+
import { names } from "./names.js";
|
|
2
3
|
/**
|
|
3
4
|
* Opt-in network and user agent settings of an identity (identity.json format 11), both off by
|
|
4
|
-
* default
|
|
5
|
+
* default and the user's choice: a real Chrome on the user's own connection is already
|
|
5
6
|
* the most coherent browser a site can see, and these settings can only keep it coherent or
|
|
6
7
|
* break it. The docs say what each one costs.
|
|
7
8
|
*
|
|
@@ -76,7 +77,7 @@ export function networkProblems(v, out) {
|
|
|
76
77
|
out.push("proxy.username must be a user name or a keychain:<item> reference");
|
|
77
78
|
if (p.password !== undefined) {
|
|
78
79
|
if (typeof p.password !== "string" || !p.password.startsWith(KEYCHAIN) || p.password.length <= KEYCHAIN.length)
|
|
79
|
-
out.push(
|
|
80
|
+
out.push(`proxy.password must be a keychain:<item> reference (store it with: ${names().secretSet("<item>")}): identity.json never holds a password`);
|
|
80
81
|
}
|
|
81
82
|
if (p.password !== undefined && p.username === undefined)
|
|
82
83
|
out.push("proxy.password needs proxy.username");
|
|
@@ -133,7 +134,7 @@ export async function resolveProxy(proxy, env, secret, store = secretStore(env))
|
|
|
133
134
|
throw new Error(`the secret store could not read the proxy ${what} (${ref})`);
|
|
134
135
|
}
|
|
135
136
|
if (value === undefined || value === "")
|
|
136
|
-
throw new Error(`the secret store has no item "${item}" for the proxy ${what} (store it with:
|
|
137
|
+
throw new Error(`the secret store has no item "${item}" for the proxy ${what} (store it with: ${names().secretSet(item)})`);
|
|
137
138
|
return value;
|
|
138
139
|
};
|
|
139
140
|
const username = await read(proxy.username, "user name");
|
package/dist/opt-in-settings.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { parseDuration } from "./units.js";
|
|
2
|
+
import { names } from "./names.js";
|
|
2
3
|
/**
|
|
3
4
|
* The format 8 keys of identity.json: natural language actions (`act`) and captcha solving
|
|
4
5
|
* (`captcha`). Both are off until the key is there, and both send page content to a third
|
|
@@ -65,12 +66,12 @@ function timeoutProblem(key, v, out) {
|
|
|
65
66
|
function keyProblem(key, v, out, required) {
|
|
66
67
|
if (v === undefined) {
|
|
67
68
|
if (required)
|
|
68
|
-
out.push(`${key} is required: a keychain:<item> reference (
|
|
69
|
+
out.push(`${key} is required: a keychain:<item> reference (${names().secretSet("<item>")})`);
|
|
69
70
|
return;
|
|
70
71
|
}
|
|
71
72
|
// Never echo the value: a pasted key would land in a terminal or a log.
|
|
72
73
|
if (!isKeychainRef(v))
|
|
73
|
-
out.push(`${key} must be a keychain:<item> reference (store the key with
|
|
74
|
+
out.push(`${key} must be a keychain:<item> reference (store the key with ${names().secretSet("<item>")}), never the key itself`);
|
|
74
75
|
}
|
|
75
76
|
function endpointProblem(key, v, out) {
|
|
76
77
|
if (typeof v !== "string" || !allowedEndpoint(v))
|
package/dist/replay.js
CHANGED
|
@@ -3,6 +3,7 @@ import { secretStore } from "turno-core/secrets";
|
|
|
3
3
|
import { FlowError, describeStep, fillParams, listFlows, paramRefs, readFlow, resolveParams, setPath, } from "./flows.js";
|
|
4
4
|
import { loginTool } from "./login-tool.js";
|
|
5
5
|
import { upstream } from "./upstream.js";
|
|
6
|
+
import { names } from "./names.js";
|
|
6
7
|
/**
|
|
7
8
|
* `browser_replay` and `browser_flows`: run a saved flow again, and list the saved ones.
|
|
8
9
|
*
|
|
@@ -173,7 +174,7 @@ async function prepareParams(ctx, flow, given) {
|
|
|
173
174
|
};
|
|
174
175
|
if (missing.length)
|
|
175
176
|
return {
|
|
176
|
-
error: `flow "${flow.name}" needs ${missing.map((p) => `"${p.name}"${p.sensitive ? " (sensitive)" : ""}`).join(", ")}: pass them in params; a value written keychain:<item> is read from the secret store (
|
|
177
|
+
error: `flow "${flow.name}" needs ${missing.map((p) => `"${p.name}"${p.sensitive ? " (sensitive)" : ""}`).join(", ")}: pass them in params; a value written keychain:<item> is read from the secret store (${names().secretSet("<item>")}) so it never passes through you.`,
|
|
177
178
|
};
|
|
178
179
|
const secret = new Set();
|
|
179
180
|
const refs = new Set();
|
|
@@ -187,7 +188,7 @@ async function prepareParams(ctx, flow, given) {
|
|
|
187
188
|
const read = await store.get(item).catch(() => undefined);
|
|
188
189
|
if (read === undefined)
|
|
189
190
|
return {
|
|
190
|
-
error: `parameter "${p.name}": the secret store has no item "${item}" (store it with:
|
|
191
|
+
error: `parameter "${p.name}": the secret store has no item "${item}" (store it with: ${names().secretSet(item)})`,
|
|
191
192
|
};
|
|
192
193
|
v = read;
|
|
193
194
|
values[p.name] = v;
|
|
@@ -360,7 +361,7 @@ export async function replayFlow(id, flow, options = {}) {
|
|
|
360
361
|
env: Object.fromEntries(Object.entries(env).filter((e) => e[1] !== undefined)),
|
|
361
362
|
stderr: "pipe",
|
|
362
363
|
});
|
|
363
|
-
const client = new Client({ name:
|
|
364
|
+
const client = new Client({ name: `${names().browser} replay`, version: "1" });
|
|
364
365
|
await client.connect(transport);
|
|
365
366
|
try {
|
|
366
367
|
const result = await client.callTool({
|
package/dist/runtime-lock.js
CHANGED
|
@@ -2,6 +2,7 @@ import { mkdirSync, readFileSync, renameSync, rmSync, writeFileSync } from "node
|
|
|
2
2
|
import { join } from "node:path";
|
|
3
3
|
import { pidAlive } from "turno-core/process";
|
|
4
4
|
import { IdentityError, identityStateDir } from "./ids.js";
|
|
5
|
+
import { names } from "./names.js";
|
|
5
6
|
export class IdentityInUseError extends IdentityError {
|
|
6
7
|
lock;
|
|
7
8
|
constructor(message, lock) {
|
|
@@ -42,10 +43,10 @@ export function runtimeLockAlive(lock) {
|
|
|
42
43
|
export function inUseMessage(id, lock) {
|
|
43
44
|
const pids = `pid ${lock.nodePid}${lock.chromePid ? `, Chrome pid ${lock.chromePid}` : ""}`;
|
|
44
45
|
if (lock.holder === "login") {
|
|
45
|
-
return `browser identity "${id}" is in use by
|
|
46
|
+
return `browser identity "${id}" is in use by ${names().browser} login (${pids}) since ${lock.startedAt}. Close that Chrome window to finish the login, then try again.`;
|
|
46
47
|
}
|
|
47
48
|
if (lock.holder === "export" || lock.holder === "import") {
|
|
48
|
-
return `browser identity "${id}" is in use by
|
|
49
|
+
return `browser identity "${id}" is in use by ${names().browser} ${lock.holder} (${pids}) since ${lock.startedAt}. Wait for it to finish, then try again.`;
|
|
49
50
|
}
|
|
50
51
|
return (`browser identity "${id}" is in use by turno-browser-mcp (${pids}) since ${lock.startedAt}. ` +
|
|
51
52
|
"One identity drives one Chrome at a time: wait for that session to end (mcpd stops the server after its lease or idle time), " +
|
package/dist/vault.js
CHANGED
|
@@ -4,6 +4,7 @@ import { browserPaths, writePrivateFile } from "turno-core/paths";
|
|
|
4
4
|
import { requireSecretStore } from "turno-core/secrets";
|
|
5
5
|
import { IdentityError, assertIdentityId, identityDir } from "./ids.js";
|
|
6
6
|
import { parseTotpSecret } from "./totp.js";
|
|
7
|
+
import { names } from "./names.js";
|
|
7
8
|
/**
|
|
8
9
|
* The credential vault of a browser identity: a username, a password and optionally
|
|
9
10
|
* a TOTP secret per site, so `browser_login` can fill a sign-in form without the model ever
|
|
@@ -144,7 +145,7 @@ export async function vaultAdd(id, site, input, options = {}) {
|
|
|
144
145
|
assertIdentityId(id);
|
|
145
146
|
assertSiteKey(site);
|
|
146
147
|
if (!existsDir(identityDir(id, env)))
|
|
147
|
-
throw new VaultError(`identity "${id}" does not exist (
|
|
148
|
+
throw new VaultError(`identity "${id}" does not exist (${names().browser} add ${id})`);
|
|
148
149
|
if (!input.urls.length)
|
|
149
150
|
throw new VaultError("give the sign-in page with --url (for example --url https://github.com/login)");
|
|
150
151
|
const origins = [...new Set(input.urls.map(vaultOrigin))];
|
|
@@ -203,7 +204,7 @@ export function vaultSetSubmit(id, submit, options = {}) {
|
|
|
203
204
|
if (submit !== "confirm" && submit !== "auto")
|
|
204
205
|
throw new VaultError(`submit must be "confirm" or "auto"`);
|
|
205
206
|
if (!existsDir(identityDir(id, env)))
|
|
206
|
-
throw new VaultError(`identity "${id}" does not exist (
|
|
207
|
+
throw new VaultError(`identity "${id}" does not exist (${names().browser} add ${id})`);
|
|
207
208
|
const index = readIndex(id, env);
|
|
208
209
|
index.submit = submit;
|
|
209
210
|
writeIndex(id, index, env);
|
|
@@ -232,7 +233,7 @@ function isCredential(v) {
|
|
|
232
233
|
export async function readCredential(id, site, options = {}) {
|
|
233
234
|
const raw = await guarded(`reading ${site}`, () => storeOf(options).get(vaultItem(id, site)));
|
|
234
235
|
if (raw === undefined)
|
|
235
|
-
throw new VaultError(`the credentials of "${site}" are missing from the secret store; add them again with
|
|
236
|
+
throw new VaultError(`the credentials of "${site}" are missing from the secret store; add them again with ${names().browser} vault add ${id} ${site}`);
|
|
236
237
|
let v;
|
|
237
238
|
try {
|
|
238
239
|
v = JSON.parse(raw);
|
|
@@ -241,7 +242,7 @@ export async function readCredential(id, site, options = {}) {
|
|
|
241
242
|
v = undefined;
|
|
242
243
|
}
|
|
243
244
|
if (!isCredential(v))
|
|
244
|
-
throw new VaultError(`the secret store item of "${site}" is not a turno-browser credential; add it again with
|
|
245
|
+
throw new VaultError(`the secret store item of "${site}" is not a turno-browser credential; add it again with ${names().browser} vault add ${id} ${site}`);
|
|
245
246
|
return { username: v.username, password: v.password, ...(v.totp ? { totp: v.totp } : {}) };
|
|
246
247
|
}
|
|
247
248
|
/** True when the identity's vault lists any site (an unreadable index counts as yes). */
|
package/npm-shrinkwrap.json
CHANGED
|
@@ -1,19 +1,20 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "turno-browser",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.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.5.0",
|
|
10
10
|
"license": "Apache-2.0",
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"@modelcontextprotocol/sdk": "1.32.2",
|
|
13
13
|
"patchright-core": "1.64.3",
|
|
14
|
-
"turno-core": "0.
|
|
14
|
+
"turno-core": "0.2.0"
|
|
15
15
|
},
|
|
16
16
|
"bin": {
|
|
17
|
+
"turno-browser": "dist/cli/main.js",
|
|
17
18
|
"turno-browser-mcp": "dist/bin/mcp.js"
|
|
18
19
|
},
|
|
19
20
|
"engines": {
|
|
@@ -1017,8 +1018,8 @@
|
|
|
1017
1018
|
}
|
|
1018
1019
|
},
|
|
1019
1020
|
"node_modules/turno-core": {
|
|
1020
|
-
"version": "0.
|
|
1021
|
-
"resolved": "https://registry.npmjs.org/turno-core/-/turno-core-0.
|
|
1021
|
+
"version": "0.2.0",
|
|
1022
|
+
"resolved": "https://registry.npmjs.org/turno-core/-/turno-core-0.2.0.tgz",
|
|
1022
1023
|
"license": "Apache-2.0",
|
|
1023
1024
|
"engines": {
|
|
1024
1025
|
"node": ">=22.11"
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "turno-browser",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "0.5.0",
|
|
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)",
|
|
7
7
|
"homepage": "https://turno.wimo.dev",
|
|
@@ -27,6 +27,7 @@
|
|
|
27
27
|
"./package.json": "./package.json"
|
|
28
28
|
},
|
|
29
29
|
"bin": {
|
|
30
|
+
"turno-browser": "dist/cli/main.js",
|
|
30
31
|
"turno-browser-mcp": "dist/bin/mcp.js"
|
|
31
32
|
},
|
|
32
33
|
"files": [
|
|
@@ -41,7 +42,7 @@
|
|
|
41
42
|
"dependencies": {
|
|
42
43
|
"@modelcontextprotocol/sdk": "1.32.2",
|
|
43
44
|
"patchright-core": "1.64.3",
|
|
44
|
-
"turno-core": "0.
|
|
45
|
+
"turno-core": "0.2.0"
|
|
45
46
|
},
|
|
46
47
|
"devDependencies": {
|
|
47
48
|
"@types/node": "^26.6.6",
|
|
@@ -55,15 +56,20 @@
|
|
|
55
56
|
"keywords": [
|
|
56
57
|
"mcp",
|
|
57
58
|
"model-context-protocol",
|
|
59
|
+
"mcp-server",
|
|
58
60
|
"browser",
|
|
59
61
|
"chrome",
|
|
60
|
-
"
|
|
61
|
-
"
|
|
62
|
-
"
|
|
62
|
+
"browser-automation",
|
|
63
|
+
"ai-agents",
|
|
64
|
+
"coding-agents",
|
|
65
|
+
"browser-identities",
|
|
66
|
+
"signed-in-sessions",
|
|
67
|
+
"credential-vault",
|
|
68
|
+
"playwright"
|
|
63
69
|
],
|
|
64
70
|
"mcpName": "io.github.wimo-dev/turno-browser",
|
|
65
71
|
"scripts": {
|
|
66
|
-
"build": "rm -rf dist && tsc -p tsconfig.build.json && chmod +x dist/bin/mcp.js",
|
|
72
|
+
"build": "rm -rf dist && tsc -p tsconfig.build.json && chmod +x dist/bin/mcp.js dist/cli/main.js",
|
|
67
73
|
"typecheck": "tsc -p tsconfig.json --noEmit",
|
|
68
74
|
"test": "vitest run"
|
|
69
75
|
}
|