modelos-secure 0.3.9__py3-none-win_amd64.whl

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.
Files changed (32) hide show
  1. modelos_secure/__init__.py +0 -0
  2. modelos_secure/_cli/README.md +63 -0
  3. modelos_secure/_cli/assets/login-D0M0qeoI.js +1 -0
  4. modelos_secure/_cli/assets/login-UmFsH3I5.js +936 -0
  5. modelos_secure/_cli/cli.js +23653 -0
  6. modelos_secure/_cli/hook/clients.mjs +278 -0
  7. modelos_secure/_cli/hook/edge.mjs +411 -0
  8. modelos_secure/_cli/hook/hook.mjs +338 -0
  9. modelos_secure/_cli/hook/hosts.d.mts +2 -0
  10. modelos_secure/_cli/hook/hosts.mjs +26 -0
  11. modelos_secure/_cli/hook/loader.mjs +12 -0
  12. modelos_secure/_cli/hook/rewrite.mjs +95 -0
  13. modelos_secure/_cli/node.exe +4 -0
  14. modelos_secure/_cli/python/modelos_secure/__init__.py +0 -0
  15. modelos_secure/_cli/python/modelos_secure/clients.py +457 -0
  16. modelos_secure/_cli/python/modelos_secure/edge.py +365 -0
  17. modelos_secure/_cli/python/modelos_secure/hook.py +574 -0
  18. modelos_secure/_cli/python/requirements.txt +0 -0
  19. modelos_secure/_cli/python/sitecustomize.py +13 -0
  20. modelos_secure/_cli/wasm/tree-sitter-javascript.wasm +0 -0
  21. modelos_secure/_cli/wasm/tree-sitter-python.wasm +0 -0
  22. modelos_secure/_cli/wasm/tree-sitter-tsx.wasm +0 -0
  23. modelos_secure/_cli/wasm/tree-sitter-typescript.wasm +0 -0
  24. modelos_secure/_cli/wasm/web-tree-sitter.wasm +0 -0
  25. modelos_secure/_launcher.py +11 -0
  26. modelos_secure/clients.py +457 -0
  27. modelos_secure/edge.py +365 -0
  28. modelos_secure/hook.py +574 -0
  29. modelos_secure-0.3.9.dist-info/METADATA +71 -0
  30. modelos_secure-0.3.9.dist-info/RECORD +32 -0
  31. modelos_secure-0.3.9.dist-info/WHEEL +4 -0
  32. modelos_secure-0.3.9.dist-info/entry_points.txt +2 -0
@@ -0,0 +1,936 @@
1
+ import { join } from "node:path";
2
+ import { chmod, mkdir, readFile, writeFile } from "node:fs/promises";
3
+ import { homedir } from "node:os";
4
+ import { Agent, request } from "node:https";
5
+ import { checkServerIdentity, connect } from "node:tls";
6
+ import { connect as connect$1, isIP } from "node:net";
7
+ import { execFile, spawn } from "node:child_process";
8
+ import { createHash, randomBytes } from "node:crypto";
9
+ import { createServer as createServer$1 } from "node:http";
10
+ import { emitKeypressEvents } from "node:readline";
11
+ // src/upstream.ts
12
+ var LOOPBACK = /^(localhost|127(\.\d{1,3}){3}|::1|\[::1\])$/i;
13
+ /** A literal private or link-local address: inside the network, which a way out does not lead to. */
14
+ function insideNetwork(host) {
15
+ const address = host.replace(/^\[|\]$/g, "");
16
+ if (isIP(address) === 6) return /^(f[cd][0-9a-f]{2}|fe80):/i.test(address);
17
+ if (isIP(address) !== 4) return false;
18
+ const [a = 0, b = 0] = address.split(".").map(Number);
19
+ return a === 10 || a === 192 && b === 168 || a === 169 && b === 254 || a === 172 && b >= 16 && b <= 31;
20
+ }
21
+ var isLoopback = (host) => LOOPBACK.test(host);
22
+ /** NO_PROXY as curl reads it: `*`, a host, a domain and everything under it, with or without a port. */
23
+ function excluded(host, port, noProxy) {
24
+ return noProxy.split(",").map((entry) => entry.trim().toLowerCase()).filter(Boolean).some((entry) => {
25
+ if (entry === "*") return true;
26
+ const [name = "", onlyPort] = entry.replace(/^\*?\./, "").split(":");
27
+ if (onlyPort && onlyPort !== port) return false;
28
+ return host === name || host.endsWith(`.${name}`);
29
+ });
30
+ }
31
+ /**
32
+ * The proxy a destination is reached through, or null when it is reached directly. Never a proxy
33
+ * for this machine, for a private address written as numbers, or for what NO_PROXY names.
34
+ */
35
+ function proxyFor(destination, env = process.env) {
36
+ const host = destination.hostname.toLowerCase();
37
+ if (isLoopback(host) || insideNetwork(host)) return null;
38
+ const https = destination.protocol === "https:";
39
+ if (excluded(host, destination.port || (https ? "443" : "80"), env.NO_PROXY ?? env.no_proxy ?? "")) return null;
40
+ const value = ((https ? env.HTTPS_PROXY ?? env.https_proxy : env.HTTP_PROXY ?? env.http_proxy) ?? env.ALL_PROXY ?? env.all_proxy)?.trim();
41
+ if (!value) return null;
42
+ try {
43
+ const proxy = new URL(value.includes("://") ? value : `http://${value}`);
44
+ return /^https?:$/.test(proxy.protocol) ? proxy : null;
45
+ } catch {
46
+ return null;
47
+ }
48
+ }
49
+ /** A proxy would not make a connection. Its message says what was blocked and what to do. */
50
+ var ProxyRefused = class extends Error {
51
+ code = "PROXY_REFUSED";
52
+ status;
53
+ host;
54
+ proxy;
55
+ constructor(proxy, host, status) {
56
+ super(refusedWords(proxy.host, host, status));
57
+ this.proxy = proxy.host;
58
+ this.host = host;
59
+ this.status = status;
60
+ }
61
+ };
62
+ /** Fixed words around the names: which proxy, what it blocked, and what the person can do. */
63
+ function refusedWords(proxy, host, status) {
64
+ if (status === 0) return `The proxy at ${proxy}, from HTTPS_PROXY, cannot be reached from this machine, so ${host} was not reached. Check HTTPS_PROXY, or unset it if this network needs no proxy.`;
65
+ if (status === 407) return `The proxy at ${proxy} asks for a sign-in before it connects to ${host} (407). Put the user and password in HTTPS_PROXY, as http://user:password@${proxy}, or use the proxy address your company gives for tools that cannot sign in.`;
66
+ return `The proxy at ${proxy} refused the connection to ${host} (${status.toString()}). If ${host} is inside your network, add it to NO_PROXY. Otherwise ask whoever runs the proxy to allow ${host}.`;
67
+ }
68
+ /** The header a proxy with a user and password in its address expects. */
69
+ function proxyAuthorization(proxy) {
70
+ if (!proxy.username) return {};
71
+ const pair = `${decodeURIComponent(proxy.username)}:${decodeURIComponent(proxy.password)}`;
72
+ return { "proxy-authorization": `Basic ${Buffer.from(pair).toString("base64")}` };
73
+ }
74
+ /**
75
+ * Opens a connection to host:port through a proxy, with CONNECT. Resolves with the socket once the
76
+ * proxy has connected it, and with anything the far side already sent.
77
+ */
78
+ function tunnel(proxy, host, port) {
79
+ return new Promise((resolve, reject) => {
80
+ const proxyPort = Number(proxy.port || (proxy.protocol === "https:" ? 443 : 80));
81
+ const socket = proxy.protocol === "https:" ? connect({
82
+ host: proxy.hostname,
83
+ port: proxyPort,
84
+ servername: proxy.hostname
85
+ }) : connect$1(proxyPort, proxy.hostname);
86
+ const failed = (status) => {
87
+ socket.destroy();
88
+ reject(new ProxyRefused(proxy, host, status));
89
+ };
90
+ socket.setTimeout(3e4, () => failed(0));
91
+ socket.once("error", () => failed(0));
92
+ socket.once(proxy.protocol === "https:" ? "secureConnect" : "connect", () => {
93
+ const target = `${host}:${port.toString()}`;
94
+ const auth = proxyAuthorization(proxy)["proxy-authorization"];
95
+ socket.write(`CONNECT ${target} HTTP/1.1\r\nHost: ${target}\r\n${auth ? `Proxy-Authorization: ${auth}\r\n` : ""}\r\n`);
96
+ });
97
+ let seen = Buffer.alloc(0);
98
+ const onData = (chunk) => {
99
+ seen = Buffer.concat([seen, chunk]);
100
+ const end = seen.indexOf("\r\n\r\n");
101
+ if (end < 0) {
102
+ if (seen.length > 16384) failed(0);
103
+ return;
104
+ }
105
+ socket.off("data", onData);
106
+ const status = Number(/^HTTP\/1\.[01] (\d{3})/.exec(seen.toString("latin1"))?.[1]);
107
+ if (status < 200 || status > 299 || Number.isNaN(status)) return failed(Number.isNaN(status) ? 0 : status);
108
+ socket.setTimeout(0);
109
+ socket.removeAllListeners("error");
110
+ resolve({
111
+ socket,
112
+ head: seen.subarray(end + 4)
113
+ });
114
+ };
115
+ socket.on("data", onData);
116
+ });
117
+ }
118
+ // src/tls.ts
119
+ /**
120
+ * A fetch over https that never follows a redirect. With `name`, it connects to the URL's host and
121
+ * checks its certificate against that name. With `proxy`, it goes through that proxy by CONNECT,
122
+ * and the certificate checked is still the far side's own. ADRs 0055 and 0113.
123
+ */
124
+ function httpsFetch(options) {
125
+ return async (url, init = {}) => {
126
+ const target = new URL(url);
127
+ const name = options.name ?? target.hostname;
128
+ const tunnelled = options.proxy ? await tunnel(options.proxy, target.hostname, Number(target.port || 443)) : null;
129
+ return new Promise((resolve, reject) => {
130
+ const outgoing = request(target, {
131
+ method: init.method ?? "GET",
132
+ headers: init.headers,
133
+ servername: name,
134
+ checkServerIdentity: (_host, certificate) => checkServerIdentity(name, certificate),
135
+ signal: init.signal,
136
+ ...tunnelled ? { agent: overTunnel(tunnelled.socket, name) } : {}
137
+ }, (incoming) => {
138
+ const chunks = [];
139
+ incoming.on("data", (chunk) => chunks.push(chunk));
140
+ incoming.on("error", reject);
141
+ incoming.on("end", () => {
142
+ const headers = new Headers();
143
+ for (const [key, value] of Object.entries(incoming.headers)) if (value !== void 0) headers.set(key, Array.isArray(value) ? value.join(", ") : value);
144
+ const status = incoming.statusCode ?? 502;
145
+ resolve(new Response(status === 204 || status === 304 ? null : Buffer.concat(chunks), {
146
+ status,
147
+ headers
148
+ }));
149
+ });
150
+ });
151
+ outgoing.on("error", reject);
152
+ if (init.body !== void 0) outgoing.write(init.body);
153
+ outgoing.end();
154
+ });
155
+ };
156
+ }
157
+ /** An agent whose one connection is TLS over a socket a proxy has already connected. */
158
+ function overTunnel(socket, name) {
159
+ const agent = new Agent({
160
+ keepAlive: false,
161
+ maxSockets: 1
162
+ });
163
+ agent.createConnection = () => connect({
164
+ socket,
165
+ servername: name,
166
+ checkServerIdentity: (_host, certificate) => checkServerIdentity(name, certificate)
167
+ });
168
+ return agent;
169
+ }
170
+ /** What went wrong reaching an address, in plain words, from the error Node gave. */
171
+ function networkMessage(error, url, tlsName) {
172
+ if (error instanceof ProxyRefused) return error.message;
173
+ const cause = error?.cause;
174
+ const code = (typeof cause?.code === "string" ? cause.code : void 0) ?? error?.code;
175
+ let host = url;
176
+ try {
177
+ host = new URL(url).hostname;
178
+ } catch {}
179
+ switch (code) {
180
+ case "ERR_TLS_CERT_ALTNAME_INVALID": return tlsName ? `The certificate at ${host} is not issued for ${tlsName}. Copy the login command from the tokens page again.` : `The certificate at ${host} is not issued for that address. If it is issued for a name, such as one in your company's domain, log in again with --tls-name and that name.`;
181
+ case "DEPTH_ZERO_SELF_SIGNED_CERT":
182
+ case "SELF_SIGNED_CERT_IN_CHAIN":
183
+ case "UNABLE_TO_VERIFY_LEAF_SIGNATURE":
184
+ case "UNABLE_TO_GET_ISSUER_CERT_LOCALLY": return `This machine does not trust the certificate at ${host}. If your company adds its own certificates to this machine, set NODE_OPTIONS=--use-system-ca and try again.`;
185
+ case "CERT_HAS_EXPIRED": return `The certificate at ${host} has expired. Tell whoever runs that address.`;
186
+ case "ENOTFOUND":
187
+ case "EAI_AGAIN": return `${host} cannot be found from this machine. Check the address.`;
188
+ case "ECONNREFUSED":
189
+ case "ECONNRESET":
190
+ case "ETIMEDOUT":
191
+ case "EHOSTUNREACH":
192
+ case "ENETUNREACH":
193
+ case "UND_ERR_CONNECT_TIMEOUT": return `${host} cannot be reached from this machine. It may only be reachable on the company network.`;
194
+ default: return `The request to ${host} failed${code ? ` (${code})` : ""}.`;
195
+ }
196
+ }
197
+ // src/ui.ts
198
+ var env = process.env;
199
+ var tty = Boolean(process.stdout.isTTY);
200
+ var color = tty && !env.NO_COLOR;
201
+ /** Whether the terminal takes 24-bit colour, so the app's own tokens can be used; else the basic eight. */
202
+ var trueColor = color && /truecolor|24bit/i.test(env.COLORTERM ?? "") ? true : false;
203
+ /**
204
+ * Unicode marks, unless the terminal is known not to show them: a dumb terminal, or a Windows
205
+ * console outside Windows Terminal, whose code page is often not UTF-8.
206
+ */
207
+ var unicode = env.TERM !== "dumb" && !env.MODELOS_SECURE_ASCII && !(process.platform === "win32" && !env.WT_SESSION && !env.TERM_PROGRAM);
208
+ /** Terminals that draw OSC 8 links as links; the rest get the address in words. */
209
+ var linksWork = tty && Boolean(env.WT_SESSION || /^(iTerm\.app|vscode|WezTerm|Hyper|ghostty|kitty|WarpTerminal)$/.test(env.TERM_PROGRAM ?? "") || Number(env.VTE_VERSION ?? 0) >= 5e3 || env.KONSOLE_VERSION);
210
+ var TOKENS = {
211
+ red: {
212
+ rgb: [
213
+ 196,
214
+ 42,
215
+ 30
216
+ ],
217
+ basic: "31"
218
+ },
219
+ blue: {
220
+ rgb: [
221
+ 29,
222
+ 88,
223
+ 194
224
+ ],
225
+ basic: "34"
226
+ },
227
+ grey: {
228
+ rgb: [
229
+ 93,
230
+ 104,
231
+ 128
232
+ ],
233
+ basic: "90"
234
+ }
235
+ };
236
+ var paint = (code, text) => color ? `\u001b[${code}m${text}\u001b[0m` : text;
237
+ var tone = (name, text) => paint(trueColor ? `38;2;${TOKENS[name].rgb.join(";")}` : TOKENS[name].basic, text);
238
+ var red = (t) => tone("red", t);
239
+ var blue = (t) => tone("blue", t);
240
+ var grey = (t) => tone("grey", t);
241
+ var bold = (t) => paint("1", t);
242
+ var interactive = () => Boolean(process.stdin.isTTY && process.stdout.isTTY) && !env.CI;
243
+ var pointer = unicode ? "›" : ">";
244
+ /** The marks beside a step, a need or a result: done, not met, could not tell. Plain letters off Unicode. */
245
+ var mark = {
246
+ yes: unicode ? "✓" : "+",
247
+ no: unicode ? "✗" : "x",
248
+ maybe: "?",
249
+ dot: unicode ? "·" : "-"
250
+ };
251
+ var plural = (n, one, many = `${one}s`) => `${n.toLocaleString("en-GB")} ${n === 1 ? one : many}`;
252
+ /** The terminal's width, 80 off a terminal or when it will not say. */
253
+ var columns = () => process.stdout.columns || 80;
254
+ /** Visible length: escape sequences take no room. */
255
+ var visible = (text) => text.replace(/\u001b\][^\u0007]*\u0007|\u001b\[[0-9;]*m/g, "").length;
256
+ /**
257
+ * Text wrapped to the terminal, each later line indented like the first word. A word longer than
258
+ * the width is left whole, so an address is never cut.
259
+ */
260
+ function wrap(text, width = columns(), indent) {
261
+ return text.split("\n").map((line) => {
262
+ if (visible(line) <= width) return line;
263
+ const lead = indent ?? /^\s*/.exec(line)?.[0].length ?? 0;
264
+ const pad = " ".repeat(lead);
265
+ const words = line.trim().split(/\s+/).filter(Boolean);
266
+ const lines = [];
267
+ let current = "";
268
+ for (const word of words) {
269
+ const next = current ? `${current} ${word}` : word;
270
+ if (current && lead + visible(next) > width) {
271
+ lines.push(pad + current);
272
+ current = word;
273
+ } else current = next;
274
+ }
275
+ if (current || lines.length === 0) lines.push(pad + current);
276
+ return lines.join("\n");
277
+ }).join("\n");
278
+ }
279
+ /** Says a line, wrapped to the terminal. Off a terminal, lines stay whole for a log. */
280
+ function say(line = "") {
281
+ console.log(tty ? wrap(line) : line);
282
+ }
283
+ /** An address a person can open: a link where the terminal draws one, the address in words elsewhere. */
284
+ var link = (text, url) => linksWork ? `\u001b]8;;${url}\u0007${text}\u001b]8;;\u0007` : text === url ? url : `${text} ${grey(url)}`;
285
+ var STEP_WIDTH = 13;
286
+ var lastStep = "";
287
+ var stepStarted = Date.now();
288
+ /** The last step that finished, so a stop can say where it happened. */
289
+ var lastFinishedStep = () => lastStep;
290
+ /** Work to finish before the process ends on Ctrl-C, such as stopping a review it started. */
291
+ var onStop = [];
292
+ function beforeStopping(work) {
293
+ onStop.push(work);
294
+ return () => {
295
+ onStop.splice(onStop.indexOf(work), 1);
296
+ };
297
+ }
298
+ async function finishBeforeStopping() {
299
+ await Promise.race([Promise.allSettled(onStop.map((work) => work())), new Promise((resolve) => setTimeout(resolve, 5e3))]);
300
+ }
301
+ /** A span of time in a few characters: "0.4 s", "12 s", "3 min 05 s". */
302
+ function elapsed(ms) {
303
+ if (ms < 1e4) return `${(ms / 1e3).toFixed(1)} s`;
304
+ if (ms < 6e4) return `${Math.round(ms / 1e3).toString()} s`;
305
+ const minutes = Math.floor(ms / 6e4);
306
+ const seconds = Math.round(ms % 6e4 / 1e3);
307
+ return `${minutes.toString()} min ${seconds.toString().padStart(2, "0")} s`;
308
+ }
309
+ /**
310
+ * One line that changes in place while work goes on, at a terminal only: what is being read now.
311
+ * An empty line clears it. Off a terminal it writes nothing, so a log holds only finished steps.
312
+ */
313
+ function status(line) {
314
+ if (!tty) return;
315
+ const width = Math.max(20, columns() - 4);
316
+ process.stdout.write(`\r\u001b[2K${line ? ` ${grey(line.slice(0, width))}` : ""}`);
317
+ }
318
+ /**
319
+ * A step that finished: its mark, its name in a fixed column, what it found, and how long it took
320
+ * since the step before, at the right edge. A step still asking or waiting has no mark yet.
321
+ */
322
+ function step(name, detail, state = "done") {
323
+ const now = Date.now();
324
+ const took = state === "done" && now - stepStarted >= 100 ? grey(elapsed(now - stepStarted)) : "";
325
+ if (state === "done") {
326
+ lastStep = name;
327
+ stepStarted = now;
328
+ }
329
+ const lead = ` ${state === "done" ? mark.yes : " "} ${bold(name.padEnd(STEP_WIDTH))}`;
330
+ const room = columns() - visible(lead) - visible(took) - 2;
331
+ const body = tty && visible(detail) > room && room > 20 ? wrap(detail, room, 0).split("\n").map((l, i) => i === 0 ? l : " ".repeat(visible(lead)) + l).join("\n") : detail;
332
+ const first = body.split("\n")[0] ?? "";
333
+ const gap = Math.max(2, columns() - visible(lead) - visible(first) - visible(took) - 1);
334
+ const rest = body.split("\n").slice(1);
335
+ console.log(`${lead}${first}${took ? `${" ".repeat(tty ? gap : 2)}${took}` : ""}${rest.length ? `\n${rest.join("\n")}` : ""}`);
336
+ }
337
+ /** Rows of label and value, the labels in one column, the values wrapped beside them. */
338
+ function rows(items) {
339
+ const width = Math.max(...items.map(([label]) => label.length)) + 2;
340
+ for (const [label, value] of items) {
341
+ const lead = ` ${grey(label.padEnd(width))}`;
342
+ const room = columns() - 2 - width;
343
+ const lines = (tty ? wrap(value, room, 0) : value).split("\n");
344
+ console.log(`${lead}${lines[0] ?? ""}${lines.slice(1).map((l) => `\n${" ".repeat(2 + width)}${l}`).join("")}`);
345
+ }
346
+ }
347
+ var RECOMMENDED = " (recommended)";
348
+ /**
349
+ * The choices as the lines they take on screen, one each and none wider than the window. The
350
+ * picker redraws by moving up exactly this many lines, so a line that wrapped would leave the one
351
+ * above it standing: seen on an 80-column window, where "Yes" appeared twice.
352
+ */
353
+ function choiceLines(choices, index, columns) {
354
+ return choices.map((choice, i) => {
355
+ const tail = choice.recommended ? RECOMMENDED : "";
356
+ const room = Math.max(8, columns - 1 - 4 - tail.length);
357
+ const label = choice.label.length > room ? `${choice.label.slice(0, room - 1)}${unicode ? "…" : "~"}` : choice.label;
358
+ return ` ${i === index ? blue(pointer) : " "} ${label}${tail ? grey(tail) : ""}`;
359
+ });
360
+ }
361
+ /** One question, one reason, a default. Arrows, Enter and the first letter of each choice. */
362
+ async function ask(question, why, choices) {
363
+ const start = Math.max(0, choices.findIndex((c) => c.recommended));
364
+ say();
365
+ say(` ${question}`);
366
+ if (why) say(` ${grey(`Why we ask: ${why}`)}`);
367
+ say();
368
+ if (!interactive()) {
369
+ const chosen = choices[start];
370
+ say(` ${pointer} ${chosen.label}`);
371
+ return chosen.value;
372
+ }
373
+ let index = start;
374
+ const render = (first) => {
375
+ if (!first) process.stdout.write(`\u001b[${choices.length.toString()}A`);
376
+ const columns = process.stdout.columns || 80;
377
+ for (const line of choiceLines(choices, index, columns)) process.stdout.write(`\u001b[2K${line}\n`);
378
+ };
379
+ render(true);
380
+ return new Promise((resolve, reject) => {
381
+ emitKeypressEvents(process.stdin);
382
+ process.stdin.setRawMode(true);
383
+ process.stdin.resume();
384
+ const done = () => {
385
+ process.stdin.off("keypress", onKey);
386
+ process.stdin.setRawMode(false);
387
+ process.stdin.pause();
388
+ };
389
+ const onKey = (text, key) => {
390
+ if (key.ctrl && key.name === "c") {
391
+ done();
392
+ reject(new Interrupted());
393
+ return;
394
+ }
395
+ if (key.name === "up") index = (index - 1 + choices.length) % choices.length;
396
+ else if (key.name === "down") index = (index + 1) % choices.length;
397
+ else if (key.name === "return" || key.name === "enter") {
398
+ done();
399
+ resolve(choices[index].value);
400
+ return;
401
+ } else if (text) {
402
+ const match = choices.findIndex((c) => c.label.toLowerCase().startsWith(text.toLowerCase()));
403
+ if (match >= 0) index = match;
404
+ }
405
+ render(false);
406
+ };
407
+ process.stdin.on("keypress", onKey);
408
+ });
409
+ }
410
+ /** Reads a line. Used only when a person has to type something, such as a command. */
411
+ async function askText(question, secret = false) {
412
+ process.stdout.write(` ${question} `);
413
+ if (!interactive()) return "";
414
+ return new Promise((resolve, reject) => {
415
+ let value = "";
416
+ emitKeypressEvents(process.stdin);
417
+ process.stdin.setRawMode(true);
418
+ process.stdin.resume();
419
+ const onKey = (text, key) => {
420
+ if (key.ctrl && key.name === "c") {
421
+ process.stdin.off("keypress", onKey);
422
+ process.stdin.setRawMode(false);
423
+ process.stdin.pause();
424
+ process.stdout.write("\n");
425
+ reject(new Interrupted());
426
+ return;
427
+ }
428
+ if (key.name === "return" || key.name === "enter") {
429
+ process.stdin.off("keypress", onKey);
430
+ process.stdin.setRawMode(false);
431
+ process.stdin.pause();
432
+ process.stdout.write("\n");
433
+ resolve(value.trim());
434
+ return;
435
+ }
436
+ if (key.name === "backspace") {
437
+ if (value && !secret) process.stdout.write("\b \b");
438
+ value = value.slice(0, -1);
439
+ } else if (key.name === "tab") return;
440
+ else if (text && !key.ctrl) {
441
+ value += text;
442
+ if (!secret) process.stdout.write(text);
443
+ }
444
+ };
445
+ process.stdin.on("keypress", onKey);
446
+ });
447
+ }
448
+ var Interrupted = class extends Error {};
449
+ // src/google.ts
450
+ var AUTHORIZE = "https://accounts.google.com/o/oauth2/v2/auth";
451
+ var TOKEN = "https://oauth2.googleapis.com/token";
452
+ /** A person has this long to finish signing in in the browser. */
453
+ var SIGN_IN_WAIT_MS = 3e5;
454
+ /** The sign-in was refused by Google: it expired, or was revoked. Only login can mend it. */
455
+ var SignInRefused = class extends Error {};
456
+ /** Reads a JWT's claims without checking its signature. Only for showing who and when. */
457
+ function claims(token) {
458
+ try {
459
+ const payload = token.split(".")[1] ?? "";
460
+ const parsed = JSON.parse(Buffer.from(payload, "base64url").toString("utf8"));
461
+ return {
462
+ email: typeof parsed.email === "string" ? parsed.email : void 0,
463
+ exp: typeof parsed.exp === "number" ? parsed.exp : void 0
464
+ };
465
+ } catch {
466
+ return {};
467
+ }
468
+ }
469
+ var expiresAt = (token) => {
470
+ const exp = claims(token).exp;
471
+ return exp === void 0 ? void 0 : exp * 1e3;
472
+ };
473
+ var fresh = (expires, now = Date.now()) => expires !== void 0 && expires - 6e4 > now;
474
+ async function tokenRequest(form) {
475
+ const via = proxyFor(new URL(TOKEN));
476
+ const init = {
477
+ method: "POST",
478
+ headers: { "content-type": "application/x-www-form-urlencoded" },
479
+ body: new URLSearchParams(form).toString()
480
+ };
481
+ const response = await (via ? httpsFetch({ proxy: via })(TOKEN, init) : fetch(TOKEN, init)).catch((error) => {
482
+ throw new Error(error instanceof ProxyRefused ? `I can't reach Google to sign in. ${error.message}` : `I can't reach Google to sign in: ${error instanceof Error ? error.message : String(error)}.`);
483
+ });
484
+ const body = await response.json().catch(() => ({}));
485
+ return {
486
+ status: response.status,
487
+ body
488
+ };
489
+ }
490
+ function signedIn(previous, body) {
491
+ if (!body.id_token) throw new Error("Google answered without an ID token. Check that the client ID on the tokens page is a Desktop app client.");
492
+ return {
493
+ ...previous,
494
+ refreshToken: body.refresh_token ?? previous.refreshToken,
495
+ idToken: body.id_token,
496
+ expiresAt: expiresAt(body.id_token),
497
+ email: claims(body.id_token).email ?? previous.email
498
+ };
499
+ }
500
+ /** Renews the ID token with the refresh token. Google needs the client secret for this too. */
501
+ async function renew(signIn) {
502
+ if (!signIn.refreshToken) throw new SignInRefused();
503
+ const { status, body } = await tokenRequest({
504
+ client_id: signIn.clientId,
505
+ client_secret: signIn.clientSecret,
506
+ refresh_token: signIn.refreshToken,
507
+ grant_type: "refresh_token"
508
+ });
509
+ if (body.error === "invalid_grant" || status === 401) throw new SignInRefused();
510
+ if (status !== 200) throw new Error(`Google did not renew the sign-in: ${body.error_description ?? body.error ?? `it answered ${status.toString()}`}.`);
511
+ return signedIn(signIn, body);
512
+ }
513
+ /** The address the browser is sent to. Exported so the request can be checked. */
514
+ function authorizeUrl(input) {
515
+ return `${AUTHORIZE}?${new URLSearchParams({
516
+ client_id: input.clientId,
517
+ redirect_uri: input.redirectUri,
518
+ response_type: "code",
519
+ scope: "openid email",
520
+ code_challenge: input.challenge,
521
+ code_challenge_method: "S256",
522
+ state: input.state,
523
+ access_type: "offline",
524
+ prompt: "consent"
525
+ }).toString()}`;
526
+ }
527
+ function openBrowser(url) {
528
+ const [command, args] = process.platform === "darwin" ? ["open", [url]] : process.platform === "win32" ? ["rundll32", ["url.dll,FileProtocolHandler", url]] : ["xdg-open", [url]];
529
+ try {
530
+ const child = spawn(command, args, {
531
+ stdio: "ignore",
532
+ detached: true
533
+ });
534
+ child.on("error", () => void 0);
535
+ child.unref();
536
+ } catch {}
537
+ }
538
+ var PAGE = (text) => `<!doctype html><meta charset="utf-8"><title>ModelOS Secure</title><body style="font: 14px/20px system-ui, sans-serif; margin: 48px">${text}</body>`;
539
+ /**
540
+ * Signs a person in with Google in their browser: the authorization code flow with PKCE and a
541
+ * loopback address on this machine, as Google asks of desktop apps.
542
+ */
543
+ async function signInWithGoogle(clientId, clientSecret) {
544
+ const verifier = randomBytes(32).toString("base64url");
545
+ const challenge = createHash("sha256").update(verifier).digest("base64url");
546
+ const state = randomBytes(16).toString("base64url");
547
+ const server = createServer$1();
548
+ await new Promise((resolve, reject) => {
549
+ server.once("error", reject);
550
+ server.listen(0, "127.0.0.1", () => resolve());
551
+ });
552
+ const address = server.address();
553
+ const redirectUri = `http://127.0.0.1:${(typeof address === "object" && address ? address.port : 0).toString()}`;
554
+ const { status, body } = await tokenRequest({
555
+ client_id: clientId,
556
+ client_secret: clientSecret,
557
+ code: await new Promise((resolve, reject) => {
558
+ const timer = setTimeout(() => {
559
+ server.close();
560
+ reject(/* @__PURE__ */ new Error("The Google sign-in was not finished within 5 minutes. Run modelos-secure login again."));
561
+ }, SIGN_IN_WAIT_MS);
562
+ server.on("request", (request, response) => {
563
+ const url = new URL(request.url ?? "/", redirectUri);
564
+ if (url.pathname !== "/" || url.searchParams.get("state") !== state) {
565
+ response.writeHead(404).end();
566
+ return;
567
+ }
568
+ const error = url.searchParams.get("error");
569
+ const got = url.searchParams.get("code");
570
+ response.writeHead(200, { "content-type": "text/html; charset=utf-8" });
571
+ response.end(PAGE(got ? "Signed in. Go back to the terminal to finish." : "The sign-in did not finish. Go back to the terminal."));
572
+ clearTimeout(timer);
573
+ server.close();
574
+ if (got) resolve(got);
575
+ else reject(/* @__PURE__ */ new Error(error === "access_denied" ? "The Google sign-in was cancelled. Run modelos-secure login again to sign in." : `Google did not sign you in: ${error ?? "no code came back"}.`));
576
+ });
577
+ const url = authorizeUrl({
578
+ clientId,
579
+ redirectUri,
580
+ challenge,
581
+ state
582
+ });
583
+ say(" Sign in with Google in your browser. If it does not open, open:");
584
+ say(` ${url}`);
585
+ openBrowser(url);
586
+ }),
587
+ code_verifier: verifier,
588
+ redirect_uri: redirectUri,
589
+ grant_type: "authorization_code"
590
+ });
591
+ if (status !== 200) throw new Error(`Google did not finish the sign-in: ${body.error_description ?? body.error ?? `it answered ${status.toString()}`}. Check the client ID and secret against the tokens page.`);
592
+ return signedIn({
593
+ clientId,
594
+ clientSecret
595
+ }, body);
596
+ }
597
+ /**
598
+ * An ID token from gcloud for the given audience. This works when gcloud is signed in as a
599
+ * service account, as in CI, and returns null otherwise.
600
+ */
601
+ function gcloudIdentityToken(audience) {
602
+ if (!/^[\w.-]+$/.test(audience)) return Promise.resolve(null);
603
+ return new Promise((resolve) => {
604
+ execFile("gcloud", [
605
+ "auth",
606
+ "print-identity-token",
607
+ `--audiences=${audience}`
608
+ ], {
609
+ timeout: 3e4,
610
+ shell: process.platform === "win32",
611
+ windowsHide: true
612
+ }, (error, stdout) => {
613
+ const token = String(stdout).trim();
614
+ resolve(!error && token.split(".").length === 3 ? token : null);
615
+ });
616
+ });
617
+ }
618
+ // src/iap.ts
619
+ /**
620
+ * The Google credential for one connection, in this order: MODELOS_SECURE_IAP_TOKEN as it is;
621
+ * the person signed in with login, renewed near its expiry; an ID token from gcloud when a
622
+ * client ID is known, which works for a service account; or nothing, as on a local stack.
623
+ */
624
+ function proxyCredentials(google, options = {}) {
625
+ let signIn = google;
626
+ let refused = false;
627
+ let fromGcloud = null;
628
+ let pending = null;
629
+ const find = async () => {
630
+ const env = options.env ?? process.env;
631
+ const now = (options.now ?? Date.now)();
632
+ const given = env.MODELOS_SECURE_IAP_TOKEN?.trim();
633
+ if (given) return {
634
+ token: given,
635
+ source: "env",
636
+ email: claims(given).email
637
+ };
638
+ if (signIn?.refreshToken || signIn?.idToken) {
639
+ if (refused) throw new SignInRefused();
640
+ if (!signIn.idToken || !fresh(signIn.expiresAt, now)) {
641
+ try {
642
+ signIn = await (options.renew ?? renew)(signIn);
643
+ } catch (error) {
644
+ if (error instanceof SignInRefused) refused = true;
645
+ throw error;
646
+ }
647
+ await options.saved?.(signIn).catch(() => void 0);
648
+ }
649
+ return {
650
+ token: signIn.idToken,
651
+ source: "signed-in",
652
+ email: signIn.email
653
+ };
654
+ }
655
+ const audience = env.MODELOS_SECURE_CLIENT_ID?.trim() || signIn?.clientId;
656
+ if (audience) {
657
+ if (!fromGcloud || fromGcloud.token && !fresh(fromGcloud.expires, now)) {
658
+ const token = await (options.gcloud ?? gcloudIdentityToken)(audience);
659
+ fromGcloud = {
660
+ token,
661
+ expires: token ? expiresAt(token) : void 0
662
+ };
663
+ }
664
+ if (fromGcloud.token) return {
665
+ token: fromGcloud.token,
666
+ source: "gcloud",
667
+ email: claims(fromGcloud.token).email
668
+ };
669
+ }
670
+ return { source: "none" };
671
+ };
672
+ return {
673
+ /** One lookup at a time, so many runners waiting at once renew the sign-in once. */
674
+ get() {
675
+ pending ??= find().finally(() => {
676
+ pending = null;
677
+ });
678
+ return pending;
679
+ } };
680
+ }
681
+ /**
682
+ * Whether an answer came from IAP, or from something that is not the app, rather than from our
683
+ * API. Our API always answers JSON, with an `error` field when it says no. IAP answers with a
684
+ * page or plain text and marks it with x-goog-iap-generated-response, and may send a request
685
+ * with no credential to Google's sign-in page.
686
+ */
687
+ function refusalKind(answer) {
688
+ const { status, headers, body, sent } = answer;
689
+ if (status >= 300 && status < 400) {
690
+ const location = headers.get("location") ?? "";
691
+ if (!(() => {
692
+ try {
693
+ return new URL(location).hostname === "accounts.google.com";
694
+ } catch {
695
+ return false;
696
+ }
697
+ })()) return "not-the-app";
698
+ return sent ? "refused" : "no-sign-in";
699
+ }
700
+ const json = typeof body === "object" && body !== null;
701
+ const ours = json && typeof body.error === "string";
702
+ const fromIap = headers.get("x-goog-iap-generated-response") === "true";
703
+ if ((status === 401 || status === 403) && (fromIap || !ours)) {
704
+ if (!sent) return "no-sign-in";
705
+ return status === 401 ? "refused" : "not-allowed";
706
+ }
707
+ const page = (headers.get("content-type") ?? "").includes("text/html");
708
+ if (!json && status < 500 && (status < 300 || page)) return "not-the-app";
709
+ return null;
710
+ }
711
+ /**
712
+ * IAP's own words for a refusal, when it gave them as plain text, such as "Invalid bearer token.
713
+ * Audience doesn't match the allowlisted oauth clients for this application." A page gives none.
714
+ */
715
+ function iapReason(headers, text) {
716
+ if ((headers.get("content-type") ?? "").includes("html")) return void 0;
717
+ const line = text.trim().split("\n")[0]?.trim() ?? "";
718
+ if (!(headers.get("x-goog-iap-generated-response") === "true" || line.startsWith("Invalid IAP credentials")) || !line || line.startsWith("<")) return void 0;
719
+ const words = line.replace(/^Invalid IAP credentials:\s*/i, "").slice(0, 240).trim();
720
+ if (!words) return void 0;
721
+ return /[.!?]$/.test(words) ? words : `${words}.`;
722
+ }
723
+ /** What happened, why, and what to do, in the voice of the CLI's other failures. */
724
+ function refusalMessage(kind, credential, url, ci = Boolean(process.env.CI), detail = {}) {
725
+ if (kind === "not-the-app") return `${url} answered, but it is not ModelOS Secure. Check the address against the login command on the tokens page.`;
726
+ if (kind === "no-sign-in") return ci ? "This address needs a Google sign-in, and none was found. In CI, set MODELOS_SECURE_CLIENT_ID with gcloud signed in as a service account, or set MODELOS_SECURE_IAP_TOKEN." : "This address needs a Google sign-in, and this machine has none yet. Run modelos-secure login with the command from the tokens page.";
727
+ if (kind === "not-allowed") return credential.email ? `You are signed in to Google as ${credential.email}, but that account is not allowed through to ModelOS Secure. Ask whoever runs ModelOS Secure to give it access.` : "This Google account is not allowed through to ModelOS Secure. Ask whoever runs ModelOS Secure to give it access.";
728
+ const said = detail.reason ? `It said: ${detail.reason}` : detail.redirected ? "It sent the request to its sign-in page instead." : "";
729
+ if (credential.source === "env") return `Google refused the token in MODELOS_SECURE_IAP_TOKEN: it has expired, or it was made for another client ID. Make a new one for the client ID on the tokens page.${said ? ` ${said}` : ""}`;
730
+ if (credential.source === "gcloud") return `Google refused the identity token from gcloud: it was made for another client ID, or the account is not a service account. Check MODELOS_SECURE_CLIENT_ID against the tokens page.${said ? ` ${said}` : ""}`;
731
+ if (said) return `Google did not let your sign-in through to ModelOS Secure. ${said} Run modelos-secure login again. If it says the same, send this message to whoever runs ModelOS Secure.`;
732
+ return "Google refused your sign-in: it has expired or was revoked. Run modelos-secure login again.";
733
+ }
734
+ // src/api.ts
735
+ var folder = () => join(homedir(), ".modelos-secure");
736
+ var credentials = () => join(folder(), "credentials.json");
737
+ var trim = (url) => url.replace(/\/$/, "");
738
+ async function readSaved() {
739
+ return readFile(credentials(), "utf8").then((t) => JSON.parse(t)).catch(() => null);
740
+ }
741
+ async function readConnection() {
742
+ const saved = await readSaved();
743
+ const url = process.env.MODELOS_SECURE_URL ?? saved?.url;
744
+ const token = process.env.MODELOS_SECURE_TOKEN ?? saved?.token;
745
+ if (!url || !token) return null;
746
+ const same = Boolean(saved?.url && trim(saved.url) === trim(url));
747
+ const google = same ? saved?.google : void 0;
748
+ const tlsName = process.env.MODELOS_SECURE_TLS_NAME ?? (same ? saved?.tlsName : void 0);
749
+ return {
750
+ url: trim(url),
751
+ token,
752
+ ...google ? { google } : {},
753
+ ...tlsName ? { tlsName } : {}
754
+ };
755
+ }
756
+ /** The same connection at another address. The Google sign-in goes only to the same origin. */
757
+ function atAddress(connection, url) {
758
+ const origin = (u) => {
759
+ try {
760
+ return new URL(u).origin;
761
+ } catch {
762
+ return null;
763
+ }
764
+ };
765
+ return origin(url) !== null && origin(url) === origin(connection.url) ? {
766
+ ...connection,
767
+ url: trim(url)
768
+ } : {
769
+ url: trim(url),
770
+ token: connection.token
771
+ };
772
+ }
773
+ async function saveConnection(connection) {
774
+ await mkdir(folder(), {
775
+ recursive: true,
776
+ mode: 448
777
+ });
778
+ await writeFile(credentials(), JSON.stringify(connection), { mode: 384 });
779
+ await chmod(credentials(), 384);
780
+ }
781
+ /** Keeps a renewed Google sign-in, if the saved one is still the one that was renewed. */
782
+ async function saveRenewed(url, google) {
783
+ const saved = await readSaved();
784
+ if (saved?.url && saved.token && trim(saved.url) === url && saved.google?.clientId === google.clientId) await saveConnection({
785
+ url: saved.url,
786
+ token: saved.token,
787
+ google,
788
+ ...saved.tlsName ? { tlsName: saved.tlsName } : {}
789
+ });
790
+ }
791
+ var ApiError = class extends Error {
792
+ status;
793
+ constructor(message, status) {
794
+ super(message);
795
+ this.status = status;
796
+ }
797
+ };
798
+ /** IAP, or something that is not the app, answered instead of ModelOS Secure. */
799
+ var IapRefusal = class extends ApiError {
800
+ kind;
801
+ constructor(kind, status, message) {
802
+ super(message, status);
803
+ this.kind = kind;
804
+ }
805
+ };
806
+ /** Hosts a token may reach over plain http: this machine only, as in local development. */
807
+ var LOCAL_HOSTS = /* @__PURE__ */ new Set([
808
+ "localhost",
809
+ "127.0.0.1",
810
+ "[::1]"
811
+ ]);
812
+ function apiClient(connection, options = {}) {
813
+ const target = new URL(connection.url);
814
+ if (target.protocol === "http:" && !LOCAL_HOSTS.has(target.hostname)) throw new Error(`The address ${target.origin} starts with http://, so your token would travel in clear. Use its https:// address.`);
815
+ const proxy = proxyCredentials(connection.google, {
816
+ saved: (google) => saveRenewed(connection.url, google),
817
+ ...options
818
+ });
819
+ /** The Google credential this client sends. A refused sign-in is an IAP refusal. */
820
+ const credential = async () => {
821
+ try {
822
+ return await proxy.get();
823
+ } catch (error) {
824
+ if (!(error instanceof SignInRefused)) throw error;
825
+ throw new IapRefusal("refused", 401, refusalMessage("refused", {
826
+ source: "signed-in",
827
+ email: connection.google?.email
828
+ }, connection.url));
829
+ }
830
+ };
831
+ const call = async (method, path, body, signal) => {
832
+ const sent = await credential();
833
+ const url = `${connection.url}/api/v1${path}`;
834
+ const headers = {
835
+ authorization: `Bearer ${sent.token ?? connection.token}`,
836
+ "x-modelos-secure-token": connection.token,
837
+ ...body ? { "content-type": body.type } : {}
838
+ };
839
+ const via = proxyFor(new URL(url));
840
+ const response = await (connection.tlsName || via ? httpsFetch({
841
+ name: connection.tlsName,
842
+ proxy: via
843
+ })(url, {
844
+ method,
845
+ headers,
846
+ body: body?.text,
847
+ signal
848
+ }) : fetch(url, {
849
+ method,
850
+ redirect: "manual",
851
+ headers,
852
+ body: body?.text,
853
+ signal
854
+ })).catch((error) => {
855
+ if (signal?.aborted) throw error;
856
+ throw new ApiError(networkMessage(error, connection.url, connection.tlsName), 0);
857
+ });
858
+ const text = await response.text();
859
+ let parsed;
860
+ try {
861
+ parsed = JSON.parse(text);
862
+ } catch {
863
+ parsed = void 0;
864
+ }
865
+ const kind = refusalKind({
866
+ status: response.status,
867
+ headers: response.headers,
868
+ body: parsed,
869
+ sent: Boolean(sent.token)
870
+ });
871
+ if (kind) throw new IapRefusal(kind, response.status, refusalMessage(kind, sent, connection.url, void 0, {
872
+ reason: iapReason(response.headers, text),
873
+ redirected: response.status >= 300 && response.status < 400
874
+ }));
875
+ if (!response.ok) {
876
+ const error = typeof parsed === "object" && parsed !== null ? parsed.error : void 0;
877
+ throw new ApiError(typeof error === "string" ? error : `The server answered ${response.status.toString()}.`, response.status);
878
+ }
879
+ return parsed;
880
+ };
881
+ return {
882
+ credential,
883
+ postText: (path, text) => call("POST", path, {
884
+ text,
885
+ type: "text/csv"
886
+ }),
887
+ get: (path) => call("GET", path),
888
+ post: (path, body, signal) => call("POST", path, body === void 0 ? void 0 : {
889
+ text: JSON.stringify(body),
890
+ type: "application/json"
891
+ }, signal)
892
+ };
893
+ }
894
+ // src/commands/login.ts
895
+ /** Reads a login command pasted at the address prompt, or a bare address. */
896
+ function parseLoginLine(line) {
897
+ const words = line.trim().split(/\s+/).filter(Boolean);
898
+ const after = (name) => {
899
+ const index = words.indexOf(`--${name}`);
900
+ return index >= 0 ? words[index + 1] : void 0;
901
+ };
902
+ if (!words.some((w) => w.startsWith("--"))) return words[0] ? { url: words[0] } : {};
903
+ return {
904
+ url: after("url"),
905
+ clientId: after("client-id"),
906
+ clientSecret: after("client-secret"),
907
+ tlsName: after("tls-name")
908
+ };
909
+ }
910
+ async function loginCommand(given = {}) {
911
+ let url = given.url ?? process.env.MODELOS_SECURE_URL;
912
+ let { clientId, clientSecret, tlsName } = given;
913
+ if (!url) {
914
+ const pasted = parseLoginLine(await askText("Where is ModelOS Secure? Paste the login command from the tokens page, or type the address:"));
915
+ url = pasted.url;
916
+ clientId ??= pasted.clientId;
917
+ clientSecret ??= pasted.clientSecret;
918
+ tlsName ??= pasted.tlsName;
919
+ }
920
+ tlsName ??= process.env.MODELOS_SECURE_TLS_NAME;
921
+ if (!url) throw new Error("A login needs the address. Copy the login command from the tokens page.");
922
+ if (clientId && !clientSecret) throw new Error("The client ID needs its client secret. Copy the whole login command from the tokens page.");
923
+ const token = process.env.MODELOS_SECURE_TOKEN ?? await askText("Paste a workspace token from the tokens page:", true);
924
+ if (!token) throw new Error("A login needs a workspace token. Create one on the tokens page.");
925
+ const connection = {
926
+ url: url.replace(/\/$/, ""),
927
+ token,
928
+ ...tlsName ? { tlsName } : {}
929
+ };
930
+ if (clientId && clientSecret) connection.google = await signInWithGoogle(clientId, clientSecret);
931
+ const me = await apiClient(connection).get("/whoami");
932
+ await saveConnection(connection);
933
+ const who = connection.google?.email;
934
+ say(`Saved. This machine now works in ${me.workspace}${who ? `, signed in to Google as ${who}` : ""}.`);
935
+ }
936
+ export { tunnel as A, rows as C, ProxyRefused as D, step as E, proxyAuthorization as O, red as S, status as T, interactive as _, apiClient as a, mark as b, Interrupted as c, beforeStopping as d, blue as f, grey as g, finishBeforeStopping as h, IapRefusal as i, proxyFor as k, ask as l, elapsed as m, parseLoginLine as n, atAddress as o, bold as p, ApiError as r, readConnection as s, loginCommand as t, askText as u, lastFinishedStep as v, say as w, plural as x, link as y };