turno-browser 0.2.0 → 0.4.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 +228 -0
- package/README.md +205 -16
- package/dist/act-model.d.ts +85 -0
- package/dist/act-model.js +116 -0
- package/dist/act.d.ts +37 -0
- package/dist/act.js +599 -0
- package/dist/api.d.ts +96 -0
- package/dist/api.js +88 -0
- package/dist/argv.d.ts +55 -3
- package/dist/argv.js +190 -10
- package/dist/batch.d.ts +19 -0
- package/dist/batch.js +148 -0
- package/dist/bench.d.ts +1 -1
- package/dist/bench.js +21 -5
- package/dist/bin/mcp.js +108 -12
- package/dist/captcha.d.ts +77 -0
- package/dist/captcha.js +333 -0
- package/dist/cdp-relay.d.ts +20 -0
- package/dist/cdp-relay.js +101 -0
- package/dist/chrome-features.d.ts +23 -0
- package/dist/chrome-features.js +44 -0
- package/dist/detectors.d.ts +11 -0
- package/dist/detectors.js +46 -4
- package/dist/diagnose.d.ts +45 -0
- package/dist/diagnose.js +326 -0
- package/dist/doctor.d.ts +85 -0
- package/dist/doctor.js +556 -0
- package/dist/engine-attach.d.ts +27 -0
- package/dist/engine-attach.js +165 -0
- package/dist/engine-camoufox.d.ts +32 -0
- package/dist/engine-camoufox.js +270 -0
- package/dist/engine-lightpanda.d.ts +72 -0
- package/dist/engine-lightpanda.js +292 -0
- package/dist/engine.d.ts +119 -0
- package/dist/engine.js +355 -0
- package/dist/flows.d.ts +127 -0
- package/dist/flows.js +294 -0
- package/dist/governor.d.ts +119 -0
- package/dist/governor.js +325 -0
- package/dist/health.d.ts +60 -0
- package/dist/health.js +86 -0
- package/dist/host.d.ts +95 -0
- package/dist/host.js +1181 -0
- package/dist/human-input.d.ts +84 -0
- package/dist/human-input.js +443 -0
- package/dist/humanize.d.ts +123 -0
- package/dist/humanize.js +241 -0
- package/dist/identities.d.ts +23 -10
- package/dist/identities.js +45 -37
- package/dist/idle-timer.d.ts +12 -0
- package/dist/idle-timer.js +25 -0
- package/dist/ids.d.ts +9 -0
- package/dist/ids.js +34 -0
- package/dist/index.d.ts +21 -6
- package/dist/index.js +19 -18
- package/dist/lifecycle.d.ts +99 -0
- package/dist/lifecycle.js +172 -0
- package/dist/live-client.d.ts +22 -0
- package/dist/live-client.js +93 -0
- package/dist/live-page.d.ts +11 -0
- package/dist/live-page.js +143 -0
- package/dist/live-server.d.ts +173 -0
- package/dist/live-server.js +640 -0
- package/dist/live.d.ts +120 -0
- package/dist/live.js +203 -0
- package/dist/login-tool.d.ts +45 -0
- package/dist/login-tool.js +233 -0
- package/dist/login.d.ts +8 -3
- package/dist/login.js +65 -26
- package/dist/network-chrome.d.ts +74 -0
- package/dist/network-chrome.js +178 -0
- package/dist/network.d.ts +125 -0
- package/dist/network.js +263 -0
- package/dist/opt-in-settings.d.ts +69 -0
- package/dist/opt-in-settings.js +151 -0
- package/dist/patchright.d.ts +4 -2
- package/dist/patchright.js +4 -2
- package/dist/recorder.d.ts +88 -0
- package/dist/recorder.js +538 -0
- package/dist/recordings.d.ts +116 -0
- package/dist/recordings.js +474 -0
- package/dist/redact.d.ts +34 -0
- package/dist/redact.js +135 -0
- package/dist/replay.d.ts +20 -0
- package/dist/replay.js +382 -0
- package/dist/reputation.d.ts +89 -0
- package/dist/reputation.js +203 -0
- package/dist/resources.d.ts +76 -0
- package/dist/resources.js +341 -0
- package/dist/runtime-lock.d.ts +59 -0
- package/dist/runtime-lock.js +131 -0
- package/dist/sealed.d.ts +8 -0
- package/dist/sealed.js +96 -0
- package/dist/session-export.d.ts +67 -0
- package/dist/session-export.js +194 -0
- package/dist/session.d.ts +20 -0
- package/dist/session.js +30 -0
- package/dist/settings.d.ts +246 -0
- package/dist/settings.js +530 -0
- package/dist/sharing.d.ts +96 -0
- package/dist/sharing.js +269 -0
- package/dist/snippet.d.ts +8 -0
- package/dist/snippet.js +22 -0
- package/dist/tab-locks.d.ts +63 -0
- package/dist/tab-locks.js +179 -0
- package/dist/tools.d.ts +111 -0
- package/dist/tools.js +59 -0
- package/dist/totp.d.ts +32 -0
- package/dist/totp.js +82 -0
- package/dist/tuning.d.ts +76 -0
- package/dist/tuning.js +69 -0
- package/dist/units.d.ts +8 -0
- package/dist/units.js +20 -0
- package/dist/upstream.d.ts +243 -0
- package/dist/upstream.js +46 -0
- package/dist/vault.d.ts +91 -0
- package/dist/vault.js +273 -0
- package/npm-shrinkwrap.json +1074 -3
- package/package.json +5 -4
- package/dist/paths.d.ts +0 -17
- package/dist/paths.js +0 -17
package/dist/settings.js
ADDED
|
@@ -0,0 +1,530 @@
|
|
|
1
|
+
import { existsSync, mkdirSync, readFileSync, renameSync, writeFileSync } from "node:fs";
|
|
2
|
+
import { dirname, join } from "node:path";
|
|
3
|
+
import { browserPaths as paths } from "turno-core/paths";
|
|
4
|
+
import { actProblems, captchaProblems } from "./opt-in-settings.js";
|
|
5
|
+
import { parseAttachTarget } from "./engine-attach.js";
|
|
6
|
+
import { IdentityError, assertIdentityId } from "./ids.js";
|
|
7
|
+
import { HUMANIZE_LEVELS } from "./humanize.js";
|
|
8
|
+
import { networkEngineClash, networkProblems } from "./network.js";
|
|
9
|
+
import { parseDuration, parseSize } from "./units.js";
|
|
10
|
+
/**
|
|
11
|
+
* identity.json: what stays fixed for one browser identity, so a site sees the same person in
|
|
12
|
+
* the same place every time. It sits next to the Chrome profile directory
|
|
13
|
+
* (`<data>/browser/identities/<id>.json`), never inside it, so Chrome never reads or rewrites it
|
|
14
|
+
* and copying a profile does not copy it by accident.
|
|
15
|
+
*
|
|
16
|
+
* - `timezone`: an IANA zone. Chrome gets it as `timezoneId`, only when it differs from the
|
|
17
|
+
* system's (an identity set up at home keeps that zone on a trip).
|
|
18
|
+
* - `languages`: the Accept-Language order, passed as Chrome's own `--accept-lang`, so the
|
|
19
|
+
* header keeps Chrome's q-values and `navigator.languages` matches it. Without it, `locale`
|
|
20
|
+
* gives `[locale, base language]`.
|
|
21
|
+
* - `locale`: also passed as `--lang` (Chrome's UI and, on Linux and Windows, `Intl`). It is not
|
|
22
|
+
* Playwright's `locale` option: that one collapses Accept-Language to a single value, which no
|
|
23
|
+
* installed Chrome sends (measured with Chrome 157).
|
|
24
|
+
* - `region`: the two-letter country the identity's sites know it from. Recorded, not applied.
|
|
25
|
+
* - `health`: a URL and a text or selector that proves the identity is signed in (session
|
|
26
|
+
* health, `health.ts`).
|
|
27
|
+
* - `tabs`, `backgroundThrottling`, `settle`, `block`, `cache` (format 2): how the host runs this
|
|
28
|
+
* identity's Chrome
|
|
29
|
+
* (`tuning.ts`): the tab governor and background tab throttling.
|
|
30
|
+
* - `keychain` (format 3): where Chrome gets the key that encrypts the profile's cookies.
|
|
31
|
+
* `"mock"` (the default, also when the key is missing) keeps Playwright's
|
|
32
|
+
* `--use-mock-keychain` and `--password-store=basic`, a fixed public key; `"system"` drops
|
|
33
|
+
* them, so Chrome uses the macOS Keychain or the Linux Secret Service.
|
|
34
|
+
* - `humanize` (format 4): human-like pointer, typing and scrolling (`humanize.ts`), off by default.
|
|
35
|
+
* - `sharing` (format 5): `"session"` (the default) serves one agent session at a time;
|
|
36
|
+
* `"tabs"` lets several sessions use the browser at once, each in its own locked tabs
|
|
37
|
+
* (`sharing.ts`; mcp.toml then runs the server with `exclusive = false`).
|
|
38
|
+
* - `engine`, `attach` (format 6): which engine runs the identity (`engine.ts`). `engine:
|
|
39
|
+
* "lightpanda"` is read mode; `attach` connects to a Chrome the user already has open
|
|
40
|
+
* (`"auto"`, a user data dir, or a loopback endpoint). Both off by default.
|
|
41
|
+
* - `record` (format 7): what turno-browser records for this identity, all off by default:
|
|
42
|
+
* `flows` (every session's actions as a flow, `recorder.ts`), `traces` (Playwright traces) and
|
|
43
|
+
* `screenshots` (one per action), the last two under the identity's state folder with a
|
|
44
|
+
* size cap (`maxSize`, default 200MB) and the oldest recordings removed first (`recordings.ts`).
|
|
45
|
+
* - `act`, `captcha` (format 8): natural language actions and captcha solving, both off by
|
|
46
|
+
* default and both sending page content to a model or a solver the user picks
|
|
47
|
+
* (`opt-in-settings.ts`). Keys are `keychain:` references, never values.
|
|
48
|
+
* - `tabLocks` (format 9): with `"sharing": "tabs"`, how long a call waits for a tab another
|
|
49
|
+
* session holds (`wait`, default 10s) and how long a session without calls keeps its tabs
|
|
50
|
+
* (`release`, default 5m) (`tab-locks.ts`). No effect with `"sharing": "session"`.
|
|
51
|
+
* - `live` (format 10): the live view and take-over (`live.ts`), off by default: `enabled` serves
|
|
52
|
+
* a view of the agent's tab on 127.0.0.1 and lets the user pause the agent; `wait` is how long
|
|
53
|
+
* a paused call waits for the user to resume before it fails (default 2m).
|
|
54
|
+
* - `userAgent`, `proxy` (format 11), and the `"camoufox"` value of `engine`: opt-in network and
|
|
55
|
+
* user agent settings (`network.ts`) and Camoufox as an alternate engine
|
|
56
|
+
* (`engine-camoufox.ts`), all off by default.
|
|
57
|
+
*
|
|
58
|
+
* A missing file means Chrome's own defaults, as before identity.json existed.
|
|
59
|
+
*/
|
|
60
|
+
/**
|
|
61
|
+
* The newest format version of identity.json this package reads, in its `version` key: turno's
|
|
62
|
+
* state-file convention, where a file without `version` is format 1 and a newer one
|
|
63
|
+
* is refused. Format 2 adds the browser keys (`FORMAT_2_KEYS`); a file is written as format 2
|
|
64
|
+
* only when it uses one of them, so an older turno-browser keeps reading every other file and
|
|
65
|
+
* refuses one it would misread with "update turno-browser".
|
|
66
|
+
*/
|
|
67
|
+
export const IDENTITY_FORMAT_VERSION = 11;
|
|
68
|
+
/** The keys format 2 added. */
|
|
69
|
+
const FORMAT_2_KEYS = ["tabs", "backgroundThrottling", "settle", "block", "cache"];
|
|
70
|
+
/** The keys format 3 added. */
|
|
71
|
+
const FORMAT_3_KEYS = ["keychain"];
|
|
72
|
+
/** The keys format 4 added. */
|
|
73
|
+
const FORMAT_4_KEYS = ["humanize"];
|
|
74
|
+
/** The keys format 5 added. */
|
|
75
|
+
const FORMAT_5_KEYS = ["sharing"];
|
|
76
|
+
/** The keys format 6 added. */
|
|
77
|
+
const FORMAT_6_KEYS = ["engine", "attach"];
|
|
78
|
+
/** The keys format 7 added. */
|
|
79
|
+
const FORMAT_7_KEYS = ["record"];
|
|
80
|
+
/** The keys format 8 added. */
|
|
81
|
+
const FORMAT_8_KEYS = ["act", "captcha"];
|
|
82
|
+
/** The keys format 9 added. */
|
|
83
|
+
const FORMAT_9_KEYS = ["tabLocks"];
|
|
84
|
+
/** Longest `tabLocks.wait`: a call that waits longer for a tab is better off opening its own. */
|
|
85
|
+
const MAX_TAB_LOCK_WAIT_MS = 10 * 60_000;
|
|
86
|
+
/** Longest `tabLocks.release`. */
|
|
87
|
+
const MAX_TAB_LOCK_RELEASE_MS = 24 * 3_600_000;
|
|
88
|
+
/** The keys format 10 added. */
|
|
89
|
+
const FORMAT_10_KEYS = ["live"];
|
|
90
|
+
/** Bounds of `live.wait`. */
|
|
91
|
+
export const MIN_LIVE_WAIT_MS = 5_000;
|
|
92
|
+
export const MAX_LIVE_WAIT_MS = 30 * 60_000;
|
|
93
|
+
/** The keys format 11 added (the `"camoufox"` engine also writes format 11). */
|
|
94
|
+
const FORMAT_11_KEYS = ["userAgent", "proxy"];
|
|
95
|
+
/** The values of `engine`: `"chrome"` (the default), read mode, and Camoufox (format 11). */
|
|
96
|
+
const ENGINE_VALUES = ["chrome", "lightpanda", "camoufox"];
|
|
97
|
+
/** Recordings size cap bounds. */
|
|
98
|
+
const MIN_RECORD_BYTES = 10 * 1024 ** 2;
|
|
99
|
+
const MAX_RECORD_BYTES = 10 * 1024 ** 3;
|
|
100
|
+
/** Playwright's switches that give Chrome a fixed key instead of the OS store's. */
|
|
101
|
+
const MOCK_KEYCHAIN_SWITCHES = ["--use-mock-keychain", "--password-store=basic"];
|
|
102
|
+
/** Resource types `block.types` may name: the heavy ones a page usually works without. */
|
|
103
|
+
const BLOCKABLE_TYPES = ["image", "media", "font"];
|
|
104
|
+
/** Largest cache accepted. */
|
|
105
|
+
const MAX_CACHE_BYTES = 10 * 1024 ** 3;
|
|
106
|
+
/** Longest `settle` accepted: past this, a wait is a `browser_wait_for`, not a settle. */
|
|
107
|
+
const MAX_SETTLE_MS = 10_000;
|
|
108
|
+
const KEYS = new Set([
|
|
109
|
+
"version",
|
|
110
|
+
"timezone",
|
|
111
|
+
"locale",
|
|
112
|
+
"languages",
|
|
113
|
+
"region",
|
|
114
|
+
"health",
|
|
115
|
+
...FORMAT_2_KEYS,
|
|
116
|
+
...FORMAT_3_KEYS,
|
|
117
|
+
...FORMAT_4_KEYS,
|
|
118
|
+
...FORMAT_5_KEYS,
|
|
119
|
+
...FORMAT_6_KEYS,
|
|
120
|
+
...FORMAT_7_KEYS,
|
|
121
|
+
...FORMAT_8_KEYS,
|
|
122
|
+
...FORMAT_9_KEYS,
|
|
123
|
+
...FORMAT_10_KEYS,
|
|
124
|
+
...FORMAT_11_KEYS,
|
|
125
|
+
"created",
|
|
126
|
+
"updated",
|
|
127
|
+
]);
|
|
128
|
+
/**
|
|
129
|
+
* The Chrome switches to drop for this identity's keychain setting, as Playwright launch
|
|
130
|
+
* options: nothing for the default mock keychain.
|
|
131
|
+
*/
|
|
132
|
+
export function keychainArgs(settings) {
|
|
133
|
+
return settings?.keychain === "system" ? { ignoreDefaultArgs: [...MOCK_KEYCHAIN_SWITCHES] } : {};
|
|
134
|
+
}
|
|
135
|
+
/**
|
|
136
|
+
* The environment for a Chrome this process launches for an identity: the caller's, so HOME
|
|
137
|
+
* and the XDG folders follow the identity's environment instead of this process's.
|
|
138
|
+
*/
|
|
139
|
+
export function chromeEnv(env) {
|
|
140
|
+
const out = {};
|
|
141
|
+
for (const [k, v] of Object.entries(env))
|
|
142
|
+
if (v !== undefined)
|
|
143
|
+
out[k] = v;
|
|
144
|
+
return out;
|
|
145
|
+
}
|
|
146
|
+
const isObject = (v) => typeof v === "object" && v !== null && !Array.isArray(v);
|
|
147
|
+
function unknownKeys(v, allowed, prefix, out) {
|
|
148
|
+
for (const k of Object.keys(v))
|
|
149
|
+
if (!allowed.includes(k))
|
|
150
|
+
out.push(`unknown key "${prefix}.${k}"`);
|
|
151
|
+
}
|
|
152
|
+
/** Problems with the format 2 keys, in key order. */
|
|
153
|
+
function browserProblems(v, out) {
|
|
154
|
+
if (v.tabs !== undefined) {
|
|
155
|
+
const t = v.tabs;
|
|
156
|
+
if (!isObject(t))
|
|
157
|
+
out.push("tabs must be an object with max, popups, park or close");
|
|
158
|
+
else {
|
|
159
|
+
if (t.max !== undefined && (typeof t.max !== "number" || !Number.isInteger(t.max) || t.max < 0 || t.max > 100))
|
|
160
|
+
out.push("tabs.max must be a whole number from 0 (no cap) to 100");
|
|
161
|
+
if (t.popups !== undefined && t.popups !== "close" && t.popups !== "keep")
|
|
162
|
+
out.push('tabs.popups must be "close" or "keep"');
|
|
163
|
+
for (const k of ["park", "close"]) {
|
|
164
|
+
if (t[k] !== undefined && (typeof t[k] !== "string" || parseDuration(t[k]) === undefined))
|
|
165
|
+
out.push(`tabs.${k} must be a duration like "5m" or "0" (off)`);
|
|
166
|
+
}
|
|
167
|
+
unknownKeys(t, ["max", "popups", "park", "close"], "tabs", out);
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
if (v.backgroundThrottling !== undefined && typeof v.backgroundThrottling !== "boolean")
|
|
171
|
+
out.push("backgroundThrottling must be true or false");
|
|
172
|
+
if (v.settle !== undefined) {
|
|
173
|
+
const ms = typeof v.settle === "string" ? parseDuration(v.settle) : undefined;
|
|
174
|
+
if (ms === undefined || ms > MAX_SETTLE_MS)
|
|
175
|
+
out.push('settle must be a duration from "0" to "10s", like "250ms"');
|
|
176
|
+
}
|
|
177
|
+
if (v.block !== undefined) {
|
|
178
|
+
const b = v.block;
|
|
179
|
+
if (!isObject(b))
|
|
180
|
+
out.push("block must be an object with trackers, types or patterns");
|
|
181
|
+
else {
|
|
182
|
+
if (b.trackers !== undefined && typeof b.trackers !== "boolean")
|
|
183
|
+
out.push("block.trackers must be true or false");
|
|
184
|
+
if (b.types !== undefined &&
|
|
185
|
+
(!Array.isArray(b.types) || b.types.some((t) => !BLOCKABLE_TYPES.includes(t)))) {
|
|
186
|
+
out.push(`block.types must be a list of ${BLOCKABLE_TYPES.map((t) => `"${t}"`).join(", ")}`);
|
|
187
|
+
}
|
|
188
|
+
if (b.patterns !== undefined &&
|
|
189
|
+
(!Array.isArray(b.patterns) ||
|
|
190
|
+
b.patterns.length > 500 ||
|
|
191
|
+
b.patterns.some((p) => typeof p !== "string" || !p.trim() || /\s/.test(p)))) {
|
|
192
|
+
out.push("block.patterns must be a list of host names or URL patterns without spaces (at most 500)");
|
|
193
|
+
}
|
|
194
|
+
unknownKeys(b, ["trackers", "types", "patterns"], "block", out);
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
if (v.keychain !== undefined && v.keychain !== "mock" && v.keychain !== "system")
|
|
198
|
+
out.push('keychain must be "mock" (the default) or "system"');
|
|
199
|
+
humanizeProblems(v.humanize, out);
|
|
200
|
+
if (v.sharing !== undefined && v.sharing !== "session" && v.sharing !== "tabs")
|
|
201
|
+
out.push('sharing must be "session" (the default, one agent session at a time) or "tabs"');
|
|
202
|
+
engineProblems(v, out);
|
|
203
|
+
recordProblems(v, out);
|
|
204
|
+
actProblems(v.act, out);
|
|
205
|
+
captchaProblems(v.captcha, v, out);
|
|
206
|
+
tabLockProblems(v.tabLocks, out);
|
|
207
|
+
liveProblems(v.live, out);
|
|
208
|
+
networkProblems(v, out);
|
|
209
|
+
const networkClash = networkEngineClash(engineOf(v), v);
|
|
210
|
+
if (networkClash)
|
|
211
|
+
out.push(networkClash);
|
|
212
|
+
if (v.cache !== undefined) {
|
|
213
|
+
const c = v.cache;
|
|
214
|
+
if (!isObject(c))
|
|
215
|
+
out.push('cache must be an object, like {} or { "maxSize": "100MB" }');
|
|
216
|
+
else {
|
|
217
|
+
if (c.maxSize !== undefined) {
|
|
218
|
+
const bytes = typeof c.maxSize === "string" ? parseSize(c.maxSize) : undefined;
|
|
219
|
+
if (bytes === undefined || bytes < 1024 ** 2 || bytes > MAX_CACHE_BYTES)
|
|
220
|
+
out.push('cache.maxSize must be a size from "1MB" to "10GB", like "100MB"');
|
|
221
|
+
}
|
|
222
|
+
unknownKeys(c, ["maxSize"], "cache", out);
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
function tabLockProblems(t, out) {
|
|
227
|
+
if (t === undefined)
|
|
228
|
+
return;
|
|
229
|
+
if (!isObject(t)) {
|
|
230
|
+
out.push('tabLocks must be an object, like { "wait": "30s", "release": "10m" }');
|
|
231
|
+
return;
|
|
232
|
+
}
|
|
233
|
+
const ms = (v) => (typeof v === "string" ? parseDuration(v) : undefined);
|
|
234
|
+
if (t.wait !== undefined) {
|
|
235
|
+
const wait = ms(t.wait);
|
|
236
|
+
if (wait === undefined || wait > MAX_TAB_LOCK_WAIT_MS)
|
|
237
|
+
out.push('tabLocks.wait must be a duration from "0" (fail at once) to "10m", like "30s"');
|
|
238
|
+
}
|
|
239
|
+
if (t.release !== undefined) {
|
|
240
|
+
const release = ms(t.release);
|
|
241
|
+
if (release === undefined || release > MAX_TAB_LOCK_RELEASE_MS)
|
|
242
|
+
out.push('tabLocks.release must be a duration from "0" (free between calls) to "24h", like "10m"');
|
|
243
|
+
}
|
|
244
|
+
unknownKeys(t, ["wait", "release"], "tabLocks", out);
|
|
245
|
+
}
|
|
246
|
+
function humanizeProblems(h, out) {
|
|
247
|
+
if (h === undefined)
|
|
248
|
+
return;
|
|
249
|
+
if (!isObject(h)) {
|
|
250
|
+
out.push('humanize must be an object, like { "level": "light" }');
|
|
251
|
+
return;
|
|
252
|
+
}
|
|
253
|
+
if (!HUMANIZE_LEVELS.includes(h.level))
|
|
254
|
+
out.push(`humanize.level must be ${HUMANIZE_LEVELS.map((l) => `"${l}"`).join(", ")}`);
|
|
255
|
+
if (h.seed !== undefined &&
|
|
256
|
+
(typeof h.seed !== "number" || !Number.isInteger(h.seed) || h.seed < 0 || h.seed >= 2 ** 32))
|
|
257
|
+
out.push("humanize.seed must be a whole number from 0 to 4294967295");
|
|
258
|
+
unknownKeys(h, ["level", "seed"], "humanize", out);
|
|
259
|
+
}
|
|
260
|
+
/** The engine identity.json asks for: attach wins, like at launch. */
|
|
261
|
+
function engineOf(v) {
|
|
262
|
+
return v.attach !== undefined ? "attach" : String(v.engine ?? "chrome");
|
|
263
|
+
}
|
|
264
|
+
/** Problems with the format 6 keys (and the format 11 `"camoufox"` engine). */
|
|
265
|
+
function engineProblems(v, out) {
|
|
266
|
+
if (v.engine !== undefined && !ENGINE_VALUES.includes(v.engine))
|
|
267
|
+
out.push('engine must be "chrome" (the default), "lightpanda" (read mode) or "camoufox"');
|
|
268
|
+
if (v.engine === "camoufox" && v.keychain === "system")
|
|
269
|
+
out.push('keychain does not go with engine "camoufox": it sets how Chrome encrypts its cookies');
|
|
270
|
+
if (v.attach !== undefined) {
|
|
271
|
+
const target = typeof v.attach === "string" ? parseAttachTarget(v.attach) : { error: "attach must be a string" };
|
|
272
|
+
if ("error" in target)
|
|
273
|
+
out.push(target.error);
|
|
274
|
+
else if (v.engine === "lightpanda" || v.engine === "camoufox")
|
|
275
|
+
out.push(`attach does not go with engine "${v.engine}": pick one`);
|
|
276
|
+
else if (v.sharing === "tabs")
|
|
277
|
+
out.push('attach does not go with sharing "tabs": pick one');
|
|
278
|
+
}
|
|
279
|
+
const level = isObject(v.humanize) ? v.humanize.level : undefined;
|
|
280
|
+
if (v.engine === "lightpanda" && level !== undefined && level !== "off")
|
|
281
|
+
out.push('humanize does not go with engine "lightpanda": read mode lays out no page to move a pointer over');
|
|
282
|
+
}
|
|
283
|
+
/** Problems with the format 7 `record` key, alone and with the engine keys. */
|
|
284
|
+
function recordProblems(v, out) {
|
|
285
|
+
if (v.record === undefined)
|
|
286
|
+
return;
|
|
287
|
+
const r = v.record;
|
|
288
|
+
if (!isObject(r)) {
|
|
289
|
+
out.push("record must be an object with flows, traces, screenshots or maxSize");
|
|
290
|
+
return;
|
|
291
|
+
}
|
|
292
|
+
for (const k of ["flows", "traces", "screenshots"])
|
|
293
|
+
if (r[k] !== undefined && typeof r[k] !== "boolean")
|
|
294
|
+
out.push(`record.${k} must be true or false`);
|
|
295
|
+
if (r.maxSize !== undefined) {
|
|
296
|
+
const bytes = typeof r.maxSize === "string" ? parseSize(r.maxSize) : undefined;
|
|
297
|
+
if (bytes === undefined || bytes < MIN_RECORD_BYTES || bytes > MAX_RECORD_BYTES)
|
|
298
|
+
out.push('record.maxSize must be a size from "10MB" to "10GB", like "200MB"');
|
|
299
|
+
}
|
|
300
|
+
unknownKeys(r, ["flows", "traces", "screenshots", "maxSize"], "record", out);
|
|
301
|
+
const clash = recordEngineClash(engineOf(v), r);
|
|
302
|
+
if (clash)
|
|
303
|
+
out.push(clash);
|
|
304
|
+
}
|
|
305
|
+
/** Problems with the format 8 `live` key. */
|
|
306
|
+
function liveProblems(l, out) {
|
|
307
|
+
if (l === undefined)
|
|
308
|
+
return;
|
|
309
|
+
if (!isObject(l)) {
|
|
310
|
+
out.push('live must be an object, like { "enabled": true }');
|
|
311
|
+
return;
|
|
312
|
+
}
|
|
313
|
+
if (l.enabled !== undefined && typeof l.enabled !== "boolean")
|
|
314
|
+
out.push("live.enabled must be true or false");
|
|
315
|
+
if (l.wait !== undefined) {
|
|
316
|
+
const ms = typeof l.wait === "string" ? parseDuration(l.wait) : undefined;
|
|
317
|
+
if (ms === undefined || ms < MIN_LIVE_WAIT_MS || ms > MAX_LIVE_WAIT_MS)
|
|
318
|
+
out.push('live.wait must be a duration from "5s" to "30m", like "2m"');
|
|
319
|
+
}
|
|
320
|
+
unknownKeys(l, ["enabled", "wait"], "live", out);
|
|
321
|
+
}
|
|
322
|
+
/**
|
|
323
|
+
* Why an engine cannot record what `record` asks for. Attach mode: a trace covers every tab of
|
|
324
|
+
* the browser, the user's own too, so neither traces nor screenshots are taken there. Read mode:
|
|
325
|
+
* Lightpanda renders no page, so there is nothing to screenshot or screencast.
|
|
326
|
+
*/
|
|
327
|
+
export function recordEngineClash(engine, record) {
|
|
328
|
+
const asked = [record.traces === true && "traces", record.screenshots === true && "screenshots"].filter(Boolean);
|
|
329
|
+
if (!asked.length)
|
|
330
|
+
return undefined;
|
|
331
|
+
const what = `record.${asked.join(" and record.")}`;
|
|
332
|
+
if (engine === "attach")
|
|
333
|
+
return `${what} do not go with attach mode: a trace or screenshot could show your own tabs. Keep record.flows only, or drop attach`;
|
|
334
|
+
if (engine === "lightpanda")
|
|
335
|
+
return `${what} do not go with engine "lightpanda": read mode renders no page to screenshot or trace. Keep record.flows only, or use engine "chrome"`;
|
|
336
|
+
return undefined;
|
|
337
|
+
}
|
|
338
|
+
export function identitySettingsPath(id, env = process.env) {
|
|
339
|
+
assertIdentityId(id);
|
|
340
|
+
return join(paths(env).identitiesDir, `${id}.json`);
|
|
341
|
+
}
|
|
342
|
+
/** The system's IANA time zone, as Chrome reports it when nothing overrides it. */
|
|
343
|
+
export function systemTimezone() {
|
|
344
|
+
return Intl.DateTimeFormat().resolvedOptions().timeZone;
|
|
345
|
+
}
|
|
346
|
+
function validTimezone(tz) {
|
|
347
|
+
try {
|
|
348
|
+
new Intl.DateTimeFormat("en-US", { timeZone: tz });
|
|
349
|
+
return true;
|
|
350
|
+
}
|
|
351
|
+
catch {
|
|
352
|
+
return false;
|
|
353
|
+
}
|
|
354
|
+
}
|
|
355
|
+
/** The canonical form of a BCP 47 tag ("es-mx" is "es-MX"), or undefined when it is not one. */
|
|
356
|
+
function canonicalLocale(tag) {
|
|
357
|
+
try {
|
|
358
|
+
const [c] = Intl.getCanonicalLocales(tag);
|
|
359
|
+
return c;
|
|
360
|
+
}
|
|
361
|
+
catch {
|
|
362
|
+
return undefined;
|
|
363
|
+
}
|
|
364
|
+
}
|
|
365
|
+
const isoDate = (v) => typeof v === "string" && !Number.isNaN(Date.parse(v)) && /^\d{4}-\d{2}-\d{2}T/.test(v);
|
|
366
|
+
/** Everything wrong with a parsed identity.json, in key order; empty when it is valid. */
|
|
367
|
+
function problemsOf(raw) {
|
|
368
|
+
if (typeof raw !== "object" || raw === null || Array.isArray(raw))
|
|
369
|
+
return ["must be a JSON object"];
|
|
370
|
+
const v = raw;
|
|
371
|
+
const out = [];
|
|
372
|
+
if (v.version !== undefined && (typeof v.version !== "number" || !Number.isInteger(v.version) || v.version < 1))
|
|
373
|
+
out.push("version must be a positive integer");
|
|
374
|
+
else if (typeof v.version === "number" && v.version > IDENTITY_FORMAT_VERSION) {
|
|
375
|
+
return [
|
|
376
|
+
`is format ${v.version}, from a newer turno-browser (this one reads up to ${IDENTITY_FORMAT_VERSION}); update turno-browser`,
|
|
377
|
+
];
|
|
378
|
+
}
|
|
379
|
+
if (v.timezone !== undefined) {
|
|
380
|
+
if (typeof v.timezone !== "string")
|
|
381
|
+
out.push("timezone must be a string");
|
|
382
|
+
else if (!validTimezone(v.timezone))
|
|
383
|
+
out.push(`timezone "${v.timezone}" is not an IANA time zone (for example "Europe/Madrid")`);
|
|
384
|
+
}
|
|
385
|
+
if (v.locale !== undefined) {
|
|
386
|
+
if (typeof v.locale !== "string" || !canonicalLocale(v.locale))
|
|
387
|
+
out.push(`locale "${String(v.locale)}" is not a language tag (for example "es-MX")`);
|
|
388
|
+
}
|
|
389
|
+
if (v.languages !== undefined) {
|
|
390
|
+
if (!Array.isArray(v.languages) || v.languages.some((l) => typeof l !== "string" || !canonicalLocale(l)))
|
|
391
|
+
out.push("languages must be a list of language tags");
|
|
392
|
+
else if (v.languages.length === 0)
|
|
393
|
+
out.push("languages needs at least one language tag");
|
|
394
|
+
}
|
|
395
|
+
if (v.region !== undefined && (typeof v.region !== "string" || !/^[A-Z]{2}$/.test(v.region))) {
|
|
396
|
+
out.push(`region "${String(v.region)}" must be a two-letter country code (for example "MX")`);
|
|
397
|
+
}
|
|
398
|
+
if (v.health !== undefined) {
|
|
399
|
+
const h = v.health;
|
|
400
|
+
if (typeof h !== "object" || h === null || Array.isArray(h))
|
|
401
|
+
out.push("health must be an object with url and text or selector");
|
|
402
|
+
else {
|
|
403
|
+
if (typeof h.url !== "string" || !/^https?:\/\//.test(h.url))
|
|
404
|
+
out.push("health.url must start with http:// or https://");
|
|
405
|
+
for (const k of ["text", "selector"])
|
|
406
|
+
if (h[k] !== undefined && (typeof h[k] !== "string" || !h[k]))
|
|
407
|
+
out.push(`health.${k} must be a non-empty string`);
|
|
408
|
+
if (h.text === undefined && h.selector === undefined)
|
|
409
|
+
out.push("health needs text or selector (what only a signed-in page shows)");
|
|
410
|
+
for (const k of Object.keys(h))
|
|
411
|
+
if (!["url", "text", "selector"].includes(k))
|
|
412
|
+
out.push(`unknown key "health.${k}"`);
|
|
413
|
+
}
|
|
414
|
+
}
|
|
415
|
+
browserProblems(v, out);
|
|
416
|
+
if (!isoDate(v.created))
|
|
417
|
+
out.push("created must be an ISO date");
|
|
418
|
+
if (!isoDate(v.updated))
|
|
419
|
+
out.push("updated must be an ISO date");
|
|
420
|
+
for (const k of Object.keys(v))
|
|
421
|
+
if (!KEYS.has(k))
|
|
422
|
+
out.push(`unknown key "${k}"`);
|
|
423
|
+
return out;
|
|
424
|
+
}
|
|
425
|
+
/** Reads identity.json without throwing: for `turno browser doctor`. */
|
|
426
|
+
export function checkIdentitySettings(id, env = process.env) {
|
|
427
|
+
const path = identitySettingsPath(id, env);
|
|
428
|
+
let text;
|
|
429
|
+
try {
|
|
430
|
+
text = readFileSync(path, "utf8");
|
|
431
|
+
}
|
|
432
|
+
catch (err) {
|
|
433
|
+
if (err.code === "ENOENT")
|
|
434
|
+
return { path, problems: [] };
|
|
435
|
+
return { path, problems: [`cannot be read: ${err.message}`] };
|
|
436
|
+
}
|
|
437
|
+
let raw;
|
|
438
|
+
try {
|
|
439
|
+
raw = JSON.parse(text);
|
|
440
|
+
}
|
|
441
|
+
catch {
|
|
442
|
+
return { path, problems: ["is not valid JSON"] };
|
|
443
|
+
}
|
|
444
|
+
const problems = problemsOf(raw);
|
|
445
|
+
return problems.length ? { path, problems } : { path, settings: raw, problems };
|
|
446
|
+
}
|
|
447
|
+
/** identity.json of the identity, undefined when there is none. Throws when it is invalid. */
|
|
448
|
+
export function readIdentitySettings(id, env = process.env) {
|
|
449
|
+
const { path, settings, problems } = checkIdentitySettings(id, env);
|
|
450
|
+
if (problems.length)
|
|
451
|
+
throw new IdentityError(`identity.json of "${id}" (${path}) ${problems[0].startsWith("is ") ? problems[0] : `is invalid: ${problems.join("; ")}`}`);
|
|
452
|
+
return settings;
|
|
453
|
+
}
|
|
454
|
+
/**
|
|
455
|
+
* Applies a patch and writes the file (mode 600, through a rename so a reader never sees half
|
|
456
|
+
* a file). Validates first: a bad value throws and leaves the file as it was.
|
|
457
|
+
*/
|
|
458
|
+
export function writeIdentitySettings(id, patch, env = process.env, now = new Date()) {
|
|
459
|
+
const path = identitySettingsPath(id, env);
|
|
460
|
+
const current = existsSync(path) ? readIdentitySettings(id, env) : undefined;
|
|
461
|
+
const stamp = now.toISOString();
|
|
462
|
+
const next = { ...current, created: current?.created ?? stamp, updated: stamp };
|
|
463
|
+
for (const [key, value] of Object.entries(patch)) {
|
|
464
|
+
if (value === undefined)
|
|
465
|
+
continue;
|
|
466
|
+
if (value === null)
|
|
467
|
+
delete next[key];
|
|
468
|
+
else
|
|
469
|
+
next[key] = value;
|
|
470
|
+
}
|
|
471
|
+
const formats = [
|
|
472
|
+
FORMAT_11_KEYS,
|
|
473
|
+
FORMAT_10_KEYS,
|
|
474
|
+
FORMAT_9_KEYS,
|
|
475
|
+
FORMAT_8_KEYS,
|
|
476
|
+
FORMAT_7_KEYS,
|
|
477
|
+
FORMAT_6_KEYS,
|
|
478
|
+
FORMAT_5_KEYS,
|
|
479
|
+
FORMAT_4_KEYS,
|
|
480
|
+
FORMAT_3_KEYS,
|
|
481
|
+
FORMAT_2_KEYS,
|
|
482
|
+
];
|
|
483
|
+
// Camoufox is an engine value, not a key: it writes format 11, so an older turno-browser refuses it.
|
|
484
|
+
const newest = next.engine === "camoufox" ? 0 : formats.findIndex((keys) => keys.some((k) => next[k] !== undefined));
|
|
485
|
+
next.version = newest < 0 ? 1 : IDENTITY_FORMAT_VERSION - newest;
|
|
486
|
+
if (typeof next.locale === "string")
|
|
487
|
+
next.locale = canonicalLocale(next.locale) ?? next.locale;
|
|
488
|
+
if (Array.isArray(next.languages))
|
|
489
|
+
next.languages = next.languages.map((l) => canonicalLocale(l) ?? l);
|
|
490
|
+
if (typeof next.region === "string" && /^[a-z]{2}$/i.test(next.region))
|
|
491
|
+
next.region = next.region.toUpperCase();
|
|
492
|
+
const problems = problemsOf(next);
|
|
493
|
+
if (problems.length)
|
|
494
|
+
throw new IdentityError(`identity "${id}": ${problems.join("; ")}`);
|
|
495
|
+
// Stable key order, whatever order the patch came in.
|
|
496
|
+
const ordered = Object.fromEntries([...KEYS].filter((k) => next[k] !== undefined).map((k) => [k, next[k]]));
|
|
497
|
+
mkdirSync(dirname(path), { recursive: true, mode: 0o700 });
|
|
498
|
+
const tmp = `${path}.${process.pid}.tmp`;
|
|
499
|
+
writeFileSync(tmp, `${JSON.stringify(ordered, null, 2)}\n`, { mode: 0o600 });
|
|
500
|
+
renameSync(tmp, path);
|
|
501
|
+
return ordered;
|
|
502
|
+
}
|
|
503
|
+
/** The Accept-Language order: `languages`, else the locale and its base language. */
|
|
504
|
+
export function acceptLanguages(settings) {
|
|
505
|
+
if (settings.languages?.length)
|
|
506
|
+
return settings.languages;
|
|
507
|
+
if (!settings.locale)
|
|
508
|
+
return undefined;
|
|
509
|
+
const base = settings.locale.split("-")[0];
|
|
510
|
+
return base === settings.locale ? [settings.locale] : [settings.locale, base];
|
|
511
|
+
}
|
|
512
|
+
const hasArg = (args, flag) => args.some((a) => a === flag || a.startsWith(`${flag}=`));
|
|
513
|
+
/**
|
|
514
|
+
* What the chrome engine adds at launch for these settings. Flags and context options the user
|
|
515
|
+
* already set (through `--config` or the Playwright MCP flags) always win.
|
|
516
|
+
*/
|
|
517
|
+
export function launchSettings(settings, userArgs, systemTz, userContext = {}) {
|
|
518
|
+
const out = { args: [] };
|
|
519
|
+
if (!settings)
|
|
520
|
+
return out;
|
|
521
|
+
if (settings.locale && !hasArg(userArgs, "--lang"))
|
|
522
|
+
out.args.push(`--lang=${settings.locale}`);
|
|
523
|
+
const languages = acceptLanguages(settings);
|
|
524
|
+
if (languages && !hasArg(userArgs, "--accept-lang") && userContext.locale === undefined)
|
|
525
|
+
out.args.push(`--accept-lang=${languages.join(",")}`);
|
|
526
|
+
if (settings.timezone && settings.timezone !== systemTz && userContext.timezoneId === undefined)
|
|
527
|
+
out.timezoneId = settings.timezone;
|
|
528
|
+
return out;
|
|
529
|
+
}
|
|
530
|
+
//# sourceMappingURL=settings.js.map
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import type { BrowserContext, Page } from "patchright-core";
|
|
2
|
+
import type { TabView } from "./governor.js";
|
|
3
|
+
import { type TabLockPolicy, TabLocks } from "./tab-locks.js";
|
|
4
|
+
import { type BrowserBackendInstance, type McpConfig, type ToolResult } from "./upstream.js";
|
|
5
|
+
/**
|
|
6
|
+
* `"sharing": "tabs"`: several agent sessions work in one identity's browser at once, each in
|
|
7
|
+
* its own tabs. mcpd relays every session's calls over the one stdio connection of a shared,
|
|
8
|
+
* non-exclusive server and tells them apart by `_meta["io.turno/session"]`.
|
|
9
|
+
*
|
|
10
|
+
* Why one upstream `BrowserBackend` per session: upstream keeps the current tab, the tab list,
|
|
11
|
+
* the modal states and the snapshot refs in the backend's `Context`, and each tool reads the
|
|
12
|
+
* current tab more than once while it runs (the action, then the snapshot of the result). One
|
|
13
|
+
* backend for every session would mean either a single current tab, so two sessions' calls
|
|
14
|
+
* would have to run one after the other, or a current tab swapped under a call in flight.
|
|
15
|
+
* Several backends on one browser context work (verified with patchright-core 1.64.3 and a
|
|
16
|
+
* real Chrome, `test/tab-sharing.test.ts`): each `Context` lists every page of the context,
|
|
17
|
+
* keeps its own current tab, and two sessions' navigations run at the same time on their own
|
|
18
|
+
* tabs; disposing one leaves the pages and the browser alone. What turno adds:
|
|
19
|
+
*
|
|
20
|
+
* - The first backend (the one that launched the browser) stays the root: it owns the browser's
|
|
21
|
+
* lifetime, the idle limit and upstream's routes and init scripts. The others get a config
|
|
22
|
+
* without `initScript`, `initPage` and the network origins, so a page is not set up once per
|
|
23
|
+
* session, and their disposal closes nothing.
|
|
24
|
+
* - Upstream points a backend that has no current tab at whatever page opens next, and at a
|
|
25
|
+
* neighbour when its tab closes. Before every call turno points the session's backend at the
|
|
26
|
+
* session's own tab (the one it last worked on, else the one it last used, else a free current
|
|
27
|
+
* tab, else a new one), and locks it (`tab-locks.ts`).
|
|
28
|
+
* - `browser_close` closes only the session's tabs: the browser stays for the others.
|
|
29
|
+
*/
|
|
30
|
+
export type SharingMode = "session" | "tabs";
|
|
31
|
+
/** One session's backend and the config copy it reads on every call. */
|
|
32
|
+
export interface SessionView {
|
|
33
|
+
backend: BrowserBackendInstance;
|
|
34
|
+
config: McpConfig;
|
|
35
|
+
}
|
|
36
|
+
export interface TabSharingOptions {
|
|
37
|
+
context: BrowserContext;
|
|
38
|
+
/** The backend that launched the browser: it serves calls without a session id. */
|
|
39
|
+
root: SessionView;
|
|
40
|
+
/** A new backend on the same browser context (config from `viewConfig`). */
|
|
41
|
+
createView(): Promise<SessionView>;
|
|
42
|
+
policy: TabLockPolicy;
|
|
43
|
+
now?: () => number;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* The config of a session's backend: the root's, without what upstream installs on the browser
|
|
47
|
+
* context for each backend (init scripts, the init page module, the allowed and blocked origin
|
|
48
|
+
* routes). The root installed them already and keeps them for the life of the browser.
|
|
49
|
+
*/
|
|
50
|
+
export declare function viewConfig(config: McpConfig): McpConfig;
|
|
51
|
+
export declare class TabSharing {
|
|
52
|
+
private readonly options;
|
|
53
|
+
readonly locks: TabLocks<Page>;
|
|
54
|
+
private readonly views;
|
|
55
|
+
private readonly ready;
|
|
56
|
+
/** The tab each session last worked on. */
|
|
57
|
+
private readonly working;
|
|
58
|
+
private readonly watched;
|
|
59
|
+
private disposed;
|
|
60
|
+
constructor(options: TabSharingOptions);
|
|
61
|
+
/** The backend of `session`, created on its first call (`DIRECT_SESSION`: the root). */
|
|
62
|
+
view(session: string): Promise<SessionView>;
|
|
63
|
+
/** The tabs as one session's backend sees them, for the tab governor. */
|
|
64
|
+
tabView(view: SessionView): TabView;
|
|
65
|
+
/** Who holds a page, for the tab governor's cap. */
|
|
66
|
+
owner(page: Page): string | undefined;
|
|
67
|
+
/** Every page a session works on now: the governor never parks or closes them. */
|
|
68
|
+
protectedPages(): Page[];
|
|
69
|
+
/** A page Chrome opened: a popup belongs to the session that holds its opener. */
|
|
70
|
+
adopt(page: Page): Promise<void>;
|
|
71
|
+
/**
|
|
72
|
+
* Before a stock call of `session`: points its backend at its own tab and locks the tab the call
|
|
73
|
+
* acts on. Returns the error for the call when another session holds that tab past the wait.
|
|
74
|
+
*/
|
|
75
|
+
before(session: string, name: string, args: Record<string, unknown>, view: SessionView, signal?: AbortSignal): Promise<string | undefined>;
|
|
76
|
+
/** After a call of `session`: the tab its backend now points at is its own. */
|
|
77
|
+
after(session: string, view: SessionView): void;
|
|
78
|
+
/** `browser_close` of one session: closes its tabs and lets go of them; the browser stays. */
|
|
79
|
+
close(session: string): Promise<ToolResult>;
|
|
80
|
+
/** mcpd said the session ended: its tabs are free (they stay open; the tab governor parks and closes them). */
|
|
81
|
+
endSession(session: string): Promise<void>;
|
|
82
|
+
/** Marks, in a tab list of a result, the tabs other sessions hold. */
|
|
83
|
+
annotate(text: string, session: string, view: SessionView): string;
|
|
84
|
+
/** The browser closed: every session's backend goes (the root is the host's). */
|
|
85
|
+
dispose(): void;
|
|
86
|
+
/** The tab `session` should act on, or undefined when it needs a new one. */
|
|
87
|
+
private pick;
|
|
88
|
+
/** Points the backend at `page` without bringing it to the front. */
|
|
89
|
+
private select;
|
|
90
|
+
private lock;
|
|
91
|
+
private claim;
|
|
92
|
+
private watch;
|
|
93
|
+
/** Backends of sessions that lapsed (no call for `releaseMs`) go; a new call makes a new one. */
|
|
94
|
+
private prune;
|
|
95
|
+
private dropView;
|
|
96
|
+
}
|