@nomac/sdk 0.0.0-stage → 1.1.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.
@@ -0,0 +1,145 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.hex = exports.Http = exports.sleep = exports.DEFAULT_BASE_URL = void 0;
4
+ exports.fromBase64 = fromBase64;
5
+ exports.toBase64 = toBase64;
6
+ exports.asBytes = asBytes;
7
+ const errors_ts_1 = require("./errors.js");
8
+ exports.DEFAULT_BASE_URL = "https://nomac.app";
9
+ // Statuses that pass: NoMac or the Mac busy for a moment.
10
+ const PASSING = new Set([429, 502, 503, 504]);
11
+ const ATTEMPTS = 6;
12
+ const sleep = (ms) => new Promise(resolve => setTimeout(resolve, ms));
13
+ exports.sleep = sleep;
14
+ const pause = (attempt, retryAfter) => (0, exports.sleep)(retryAfter !== undefined && Number.isFinite(retryAfter) && retryAfter > 0 ? Math.min(retryAfter, 30) * 1000 : attempt * 2000);
15
+ class Http {
16
+ #auth;
17
+ #base;
18
+ #fetch;
19
+ constructor(options = {}) {
20
+ const credential = options.apiKey ?? options.token ?? globalThis.process?.env?.NOMAC_API_KEY;
21
+ if (!credential)
22
+ throw new errors_ts_1.NoMacError("credential_required", "Pass apiKey (the account's nmk_ key) or token (one Mac's nmm_ or one phone's nmp_ token), or set NOMAC_API_KEY.");
23
+ this.#auth = `Bearer ${credential}`;
24
+ this.#base = (options.baseUrl ?? exports.DEFAULT_BASE_URL).replace(/\/+$/, "");
25
+ this.#fetch = options.fetch ?? globalThis.fetch.bind(globalThis);
26
+ }
27
+ /**
28
+ * One call to the REST API: JSON in and out, NoMac's error as a NoMacError. A read, a stop and a request with a key are sent
29
+ * again up to five times when NoMac is busy or does not answer, and a keyed request NoMac is still starting (operation_pending)
30
+ * is asked again with its key. A request without a key is sent again only after a 429 rate_limited, which nothing did. A
31
+ * keyed request's error carries its key (requestKey), so its result can be read later instead of doing it twice.
32
+ */
33
+ async request(method, path, { body, idempotencyKey, timeoutMs = 90_000 } = {}) {
34
+ const headers = { authorization: this.#auth };
35
+ if (idempotencyKey)
36
+ headers["idempotency-key"] = idempotencyKey;
37
+ if (body !== undefined)
38
+ headers["content-type"] = "application/json";
39
+ const repeatable = method === "GET" || method === "DELETE" || Boolean(idempotencyKey);
40
+ const keyed = (error) => { if (idempotencyKey)
41
+ error.requestKey = idempotencyKey; return error; };
42
+ for (let attempt = 1;; attempt++) {
43
+ let response;
44
+ try {
45
+ response = await this.#fetch(`${this.#base}${path}`, { method, headers, body: body === undefined ? undefined : JSON.stringify(body), signal: AbortSignal.timeout(timeoutMs) });
46
+ }
47
+ catch (error) {
48
+ if (repeatable && attempt < ATTEMPTS) {
49
+ await pause(attempt);
50
+ continue;
51
+ }
52
+ throw keyed(new errors_ts_1.NoMacError("unreachable", `NoMac did not answer (${describe(error)}).${idempotencyKey ? ` Send the same request with the same key (${idempotencyKey}) to read its result; it is never done twice.` : ""}`));
53
+ }
54
+ const text = await response.text();
55
+ let payload = {};
56
+ try {
57
+ payload = text ? JSON.parse(text) : {};
58
+ }
59
+ catch {
60
+ payload = {};
61
+ }
62
+ if (response.ok)
63
+ return payload;
64
+ // A repeated DELETE whose first try was taken (its answer lost on the way) finds nothing left to delete.
65
+ if (method === "DELETE" && attempt > 1 && response.status === 404 && /\/webhooks\//.test(path))
66
+ return { deleted: true };
67
+ const error = payload?.error ?? {};
68
+ const again = (PASSING.has(response.status) && (repeatable || (response.status === 429 && error.code === "rate_limited")))
69
+ // A keyed request still being started by an earlier try of it: the same key answers it once started.
70
+ || (Boolean(idempotencyKey) && error.code === "operation_pending");
71
+ if (again && attempt < ATTEMPTS) {
72
+ await pause(attempt, Number(response.headers.get("retry-after") ?? error.retry_after_seconds ?? undefined));
73
+ continue;
74
+ }
75
+ throw keyed(new errors_ts_1.NoMacError(error.code ?? `http_${response.status}`, error.message ?? `NoMac answered ${response.status}.`, response.status, error));
76
+ }
77
+ }
78
+ /** PUTs bytes (a Blob as it is, never read into memory first) to a link NoMac signed: no NoMac credential goes with them. */
79
+ async upload(url, data) {
80
+ let response;
81
+ try {
82
+ response = await this.#fetch(url, { method: "PUT", body: data, signal: AbortSignal.timeout(30 * 60_000) });
83
+ }
84
+ catch (error) {
85
+ throw new errors_ts_1.NoMacError("upload_failed", `The upload did not reach NoMac's storage (${cause(error)}); a network that allows only some hosts must allow *.r2.cloudflarestorage.com.`);
86
+ }
87
+ if (!response.ok)
88
+ throw new errors_ts_1.NoMacError("upload_failed", `The upload was refused (${response.status}); ask for a new upload link.`, response.status);
89
+ }
90
+ /** GETs bytes from a link NoMac signed (a download link): no NoMac credential goes with them. */
91
+ async download(url) {
92
+ return new Uint8Array(await (await this.#get(url)).arrayBuffer());
93
+ }
94
+ /** The same download as a stream, so a large file never sits in memory. */
95
+ async downloadStream(url) {
96
+ const response = await this.#get(url);
97
+ if (!response.body)
98
+ throw new errors_ts_1.NoMacError("download_failed", "The download arrived without a body; ask for a new download link.");
99
+ return response.body;
100
+ }
101
+ async #get(url) {
102
+ let response;
103
+ try {
104
+ response = await this.#fetch(url, { signal: AbortSignal.timeout(30 * 60_000) });
105
+ }
106
+ catch (error) {
107
+ throw new errors_ts_1.NoMacError("download_failed", `The download did not arrive (${cause(error)}); a network that allows only some hosts must allow *.r2.cloudflarestorage.com.`);
108
+ }
109
+ if (!response.ok)
110
+ throw new errors_ts_1.NoMacError("download_failed", `The download was refused (${response.status}); ask for a new download link.`, response.status);
111
+ return response;
112
+ }
113
+ }
114
+ exports.Http = Http;
115
+ const describe = (error) => error?.message ?? String(error);
116
+ /** What a failed fetch says, with its underlying cause (Node's "fetch failed" names it only there). */
117
+ const cause = (error) => {
118
+ const e = error;
119
+ return [e?.message, e?.cause?.code ?? e?.cause?.message].filter(Boolean).join(": ") || String(error);
120
+ };
121
+ /** Base64 to bytes and back, in any runtime with atob and btoa. */
122
+ function fromBase64(data) {
123
+ const binary = atob(data);
124
+ const bytes = new Uint8Array(binary.length);
125
+ for (let i = 0; i < binary.length; i++)
126
+ bytes[i] = binary.charCodeAt(i);
127
+ return bytes;
128
+ }
129
+ function toBase64(bytes) {
130
+ let binary = "";
131
+ for (let i = 0; i < bytes.length; i += 0x8000)
132
+ binary += String.fromCharCode(...bytes.subarray(i, i + 0x8000));
133
+ return btoa(binary);
134
+ }
135
+ async function asBytes(data) {
136
+ if (typeof data === "string")
137
+ return new TextEncoder().encode(data);
138
+ if (data instanceof Uint8Array)
139
+ return data;
140
+ if (data instanceof ArrayBuffer)
141
+ return new Uint8Array(data);
142
+ return new Uint8Array(await data.arrayBuffer());
143
+ }
144
+ const hex = (bytes) => Array.from(new Uint8Array(bytes), b => b.toString(16).padStart(2, "0")).join("");
145
+ exports.hex = hex;
@@ -0,0 +1,42 @@
1
+ /**
2
+ * NoMac from JavaScript and TypeScript: a cloud Mac or an iPhone Simulator for each of your users and agents, billed per minute,
3
+ * over NoMac's REST API (https://nomac.app/docs/api). No dependencies; runs wherever fetch and Web Crypto do (Node 20 and later,
4
+ * Bun, Deno, workers).
5
+ */
6
+ import { Labels, Webhooks } from "./account.ts";
7
+ import { Embed } from "./embed.ts";
8
+ import { type ClientOptions, type RequestOptions } from "./http.ts";
9
+ import { Mac, Macs } from "./mac.ts";
10
+ import { Phone, Phones } from "./phone.ts";
11
+ import type { Credits } from "./types.ts";
12
+ export declare class NoMac {
13
+ #private;
14
+ /** Macs: start one (for one of your users with a label), read, list. */
15
+ readonly macs: Macs;
16
+ /** Phones (iPhone and iPad Simulators): start one, read, list. */
17
+ readonly phones: Phones;
18
+ /** Your users, by label: what NoMac keeps for each, and deleting it. */
19
+ readonly labels: Labels;
20
+ /** Webhooks for your users' Macs, drives and phones, and the account's credit. */
21
+ readonly webhooks: Webhooks;
22
+ /** Where your users' view links may be shown: the sites that may frame them, and a visitor your server signs. */
23
+ readonly embed: Embed;
24
+ /** With the account's API key (apiKey, or NOMAC_API_KEY), or with one Mac's or phone's token (token), for that one only. */
25
+ constructor(options?: ClientOptions);
26
+ /** A Mac by its id, without reading it: what a Mac's token reaches (new NoMac({ token }).mac(id)). */
27
+ mac(id: string): Mac;
28
+ /** A phone by its id, without reading it: what a phone's token reaches. */
29
+ phone(id: string): Phone;
30
+ /** The account's prepaid credit: what it can spend and the time that buys. */
31
+ credits(): Promise<Credits>;
32
+ /** One call to the REST API directly: JSON in and out, NoMac's error as a NoMacError. */
33
+ request<T = Record<string, any>>(method: string, path: string, options?: RequestOptions): Promise<T>;
34
+ }
35
+ export { NoMacError, requestKey } from "./errors.ts";
36
+ export { verifyWebhook } from "./webhooks.ts";
37
+ export { Embed, signVisitor } from "./embed.ts";
38
+ export { Mac, Macs, MacFiles, MacJobs } from "./mac.ts";
39
+ export { Phone, Phones } from "./phone.ts";
40
+ export { Labels, Webhooks } from "./account.ts";
41
+ export type { ClientOptions, RequestOptions } from "./http.ts";
42
+ export type * from "./types.ts";
@@ -0,0 +1,71 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Webhooks = exports.Labels = exports.Phones = exports.Phone = exports.MacJobs = exports.MacFiles = exports.Macs = exports.Mac = exports.signVisitor = exports.Embed = exports.verifyWebhook = exports.requestKey = exports.NoMacError = exports.NoMac = void 0;
4
+ /**
5
+ * NoMac from JavaScript and TypeScript: a cloud Mac or an iPhone Simulator for each of your users and agents, billed per minute,
6
+ * over NoMac's REST API (https://nomac.app/docs/api). No dependencies; runs wherever fetch and Web Crypto do (Node 20 and later,
7
+ * Bun, Deno, workers).
8
+ */
9
+ const account_ts_1 = require("./account.js");
10
+ const embed_ts_1 = require("./embed.js");
11
+ const http_ts_1 = require("./http.js");
12
+ const mac_ts_1 = require("./mac.js");
13
+ const phone_ts_1 = require("./phone.js");
14
+ class NoMac {
15
+ #http;
16
+ /** Macs: start one (for one of your users with a label), read, list. */
17
+ macs;
18
+ /** Phones (iPhone and iPad Simulators): start one, read, list. */
19
+ phones;
20
+ /** Your users, by label: what NoMac keeps for each, and deleting it. */
21
+ labels;
22
+ /** Webhooks for your users' Macs, drives and phones, and the account's credit. */
23
+ webhooks;
24
+ /** Where your users' view links may be shown: the sites that may frame them, and a visitor your server signs. */
25
+ embed;
26
+ /** With the account's API key (apiKey, or NOMAC_API_KEY), or with one Mac's or phone's token (token), for that one only. */
27
+ constructor(options = {}) {
28
+ this.#http = new http_ts_1.Http(options);
29
+ this.macs = new mac_ts_1.Macs(this.#http);
30
+ this.phones = new phone_ts_1.Phones(this.#http);
31
+ this.labels = new account_ts_1.Labels(this.#http);
32
+ this.webhooks = new account_ts_1.Webhooks(this.#http);
33
+ this.embed = new embed_ts_1.Embed(this.#http);
34
+ }
35
+ /** A Mac by its id, without reading it: what a Mac's token reaches (new NoMac({ token }).mac(id)). */
36
+ mac(id) {
37
+ return new mac_ts_1.Mac(this.#http, { id });
38
+ }
39
+ /** A phone by its id, without reading it: what a phone's token reaches. */
40
+ phone(id) {
41
+ return new phone_ts_1.Phone(this.#http, { id });
42
+ }
43
+ /** The account's prepaid credit: what it can spend and the time that buys. */
44
+ credits() {
45
+ return (0, account_ts_1.credits)(this.#http);
46
+ }
47
+ /** One call to the REST API directly: JSON in and out, NoMac's error as a NoMacError. */
48
+ request(method, path, options) {
49
+ return this.#http.request(method, path, options);
50
+ }
51
+ }
52
+ exports.NoMac = NoMac;
53
+ var errors_ts_1 = require("./errors.js");
54
+ Object.defineProperty(exports, "NoMacError", { enumerable: true, get: function () { return errors_ts_1.NoMacError; } });
55
+ Object.defineProperty(exports, "requestKey", { enumerable: true, get: function () { return errors_ts_1.requestKey; } });
56
+ var webhooks_ts_1 = require("./webhooks.js");
57
+ Object.defineProperty(exports, "verifyWebhook", { enumerable: true, get: function () { return webhooks_ts_1.verifyWebhook; } });
58
+ var embed_ts_2 = require("./embed.js");
59
+ Object.defineProperty(exports, "Embed", { enumerable: true, get: function () { return embed_ts_2.Embed; } });
60
+ Object.defineProperty(exports, "signVisitor", { enumerable: true, get: function () { return embed_ts_2.signVisitor; } });
61
+ var mac_ts_2 = require("./mac.js");
62
+ Object.defineProperty(exports, "Mac", { enumerable: true, get: function () { return mac_ts_2.Mac; } });
63
+ Object.defineProperty(exports, "Macs", { enumerable: true, get: function () { return mac_ts_2.Macs; } });
64
+ Object.defineProperty(exports, "MacFiles", { enumerable: true, get: function () { return mac_ts_2.MacFiles; } });
65
+ Object.defineProperty(exports, "MacJobs", { enumerable: true, get: function () { return mac_ts_2.MacJobs; } });
66
+ var phone_ts_2 = require("./phone.js");
67
+ Object.defineProperty(exports, "Phone", { enumerable: true, get: function () { return phone_ts_2.Phone; } });
68
+ Object.defineProperty(exports, "Phones", { enumerable: true, get: function () { return phone_ts_2.Phones; } });
69
+ var account_ts_2 = require("./account.js");
70
+ Object.defineProperty(exports, "Labels", { enumerable: true, get: function () { return account_ts_2.Labels; } });
71
+ Object.defineProperty(exports, "Webhooks", { enumerable: true, get: function () { return account_ts_2.Webhooks; } });
@@ -0,0 +1,176 @@
1
+ import { type Transport } from "./http.ts";
2
+ import type { CommandResult, FileLink, InputAction, Job, MacSession, MacStartOptions, RunOptions, Screenshot, SessionToken, StopNotice, ViewLink, ViewLinkOptions } from "./types.ts";
3
+ /** The account's Macs: start one (for one of your users with a label), read one, list them. */
4
+ export declare class Macs {
5
+ #private;
6
+ constructor(http: Transport);
7
+ /**
8
+ * Starts a Mac and answers it at once (queued, then provisioning): mac.waitUntilReady() follows it, usually under a minute.
9
+ * With label, it is your user's Mac: their drive at ~/drive and none of the account's secrets; with reuse too, the user's
10
+ * running Mac is the answer (mac.reused). Pass the same idempotencyKey to retry a start.
11
+ */
12
+ start(options?: MacStartOptions, { idempotencyKey }?: {
13
+ idempotencyKey?: string;
14
+ }): Promise<Mac>;
15
+ /** A Mac by its id, read. */
16
+ get(id: string): Promise<Mac>;
17
+ /**
18
+ * Your users' Macs, newest first: one user's (label) or all of them (labeled: true), live or ended, a page at a time
19
+ * (before: the last id of the page before; more says whether another follows). Without label or labeled, the newest
20
+ * 100 of the account's own Macs.
21
+ */
22
+ list(filter?: {
23
+ label?: string;
24
+ labeled?: boolean;
25
+ state?: "live" | "ended";
26
+ before?: string;
27
+ limit?: number;
28
+ }): Promise<{
29
+ macs: Mac[];
30
+ more: boolean;
31
+ }>;
32
+ }
33
+ /** A Mac: its session (state, label, drive, cost, limits) and what can be done on it. */
34
+ export declare class Mac {
35
+ #private;
36
+ readonly id: string;
37
+ session: MacSession;
38
+ /** Whether a start with reuse answered this running Mac instead of a new one. */
39
+ readonly reused: boolean;
40
+ /** As of the last refresh(), run() or extend(): set in the Mac's last 15 minutes before a limit or the credit's end. */
41
+ stopNotice: StopNotice | null;
42
+ readonly files: MacFiles;
43
+ readonly jobs: MacJobs;
44
+ constructor(http: Transport, session: MacSession, reused?: boolean);
45
+ get state(): import("./types.ts").SessionState;
46
+ /** Your user's id, for a Mac started with a label. */
47
+ get label(): string | undefined;
48
+ /** Reads the Mac again. */
49
+ refresh(): Promise<this>;
50
+ /**
51
+ * Waits until the Mac is ready: usually under a minute. A start waiting in line (queue_seconds) is waited for until its line
52
+ * ends, whatever timeoutMs says, so a Mac that starts in its turn is never left running unwatched.
53
+ */
54
+ waitUntilReady({ timeoutMs, intervalMs }?: {
55
+ timeoutMs?: number;
56
+ intervalMs?: number;
57
+ }): Promise<this>;
58
+ /**
59
+ * Runs a command and waits for it to end: {exitCode, stdout, stderr}, with the whole output. A string runs in bash -lc
60
+ * (pipes, &&, globs); an array runs as it is. A command that ends with a non-zero code is answered, not thrown.
61
+ */
62
+ run(command: string | string[], options?: RunOptions & {
63
+ timeoutMs?: number;
64
+ }): Promise<CommandResult>;
65
+ /** A JPEG of the desktop (1440x900, image pixels are screen points) or of the booted Simulator, with what is on the screen. */
66
+ screenshot({ target }?: {
67
+ target?: "screen" | "simulator";
68
+ }): Promise<Screenshot>;
69
+ /** The keyboard and mouse, which macOS takes as a person's (also on the lock screen and in password dialogs). Not repeated by itself: a retry types again. */
70
+ input(action: InputAction | (Omit<Extract<InputAction, {
71
+ action: "key";
72
+ }>, "keys"> & {
73
+ keys: string;
74
+ })): Promise<Record<string, any>>;
75
+ /** Starts a video of the screen (or of the Simulator), which stops by itself after maxSeconds (300 by default, 1,800 at most). */
76
+ startRecording({ target, maxSeconds }?: {
77
+ target?: "screen" | "simulator";
78
+ maxSeconds?: number;
79
+ }): Promise<Record<string, any>>;
80
+ /** Stops the recording and answers its MP4 as a download link ({recording, link}); safe to repeat. */
81
+ stopRecording(): Promise<Record<string, any>>;
82
+ /** The Mac's login password ({user, password, variable}), also $NOMAC_MAC_PASSWORD on the Mac; each read is audited. */
83
+ password(): Promise<{
84
+ user: string;
85
+ password: string;
86
+ variable: string;
87
+ }>;
88
+ /**
89
+ * A link to the Mac's desktop for a person, no sign-in, in a browser or an iframe (add ?embed=1): watch only, or control
90
+ * (one controller at a time; the newest takes over). Your user's Mac only (started with a label). Lasts 2 hours by default,
91
+ * a day at most; DELETE .../token (revokeTokens) ends it. allowedOrigins keeps it to frames on your sites, and visitor to your
92
+ * user, signed by your server (signVisitor); the account's embed settings apply when they are left out.
93
+ */
94
+ viewLink(options?: ViewLinkOptions): Promise<ViewLink>;
95
+ /**
96
+ * A token for this Mac only, to hand your user or their agent: new NoMac({ token }).mac(id) reaches its commands, files,
97
+ * screen, input and view links, never another Mac, a start, a stop or the account. 2 hours by default, a day at most.
98
+ */
99
+ token({ minutes }?: {
100
+ minutes?: number;
101
+ }): Promise<SessionToken>;
102
+ /** Revokes every token and link of this Mac made so far; the Mac runs on, and new ones work. The account's key only. */
103
+ revokeTokens(): Promise<{
104
+ revoked_at: string;
105
+ }>;
106
+ /**
107
+ * Keeps the Mac running longer: its time limit goes up by minutes (60 by default; a Mac has no longest time), and its
108
+ * spend cap by what that time costs. The account's key only. Not sent again by itself: a repeat adds more time.
109
+ */
110
+ extend({ minutes }?: {
111
+ minutes?: number;
112
+ }): Promise<this>;
113
+ /**
114
+ * Stops the Mac: it and every file outside ~/drive are deleted, and ~/drive is saved for the next Mac. The account's key
115
+ * only. confirm: stop it even while another API key is using it (the account's own Macs ask; a user's Mac never does).
116
+ */
117
+ stop({ confirm }?: {
118
+ confirm?: boolean;
119
+ }): Promise<this>;
120
+ }
121
+ /** Commands on a Mac: start one, read it, wait for its end, cancel it. mac.run() is start and wait in one. */
122
+ export declare class MacJobs {
123
+ #private;
124
+ constructor(http: Transport, base: string, notice: (notice: StopNotice | undefined) => void);
125
+ /** Starts a command (a string runs in bash -lc) and answers its job, maybe already ended. The same idempotencyKey never runs it twice. */
126
+ start(command: string | string[], { cwd, env, timeoutSeconds, idempotencyKey }?: RunOptions): Promise<Job>;
127
+ /** A job as it is now; with waitSeconds (up to 50), waits that long for it to end first. */
128
+ get(id: string, { waitSeconds }?: {
129
+ waitSeconds?: number;
130
+ }): Promise<Job>;
131
+ /**
132
+ * Waits for a job (its id, or the job start answered) to end and answers its whole output. Never run a command again for its
133
+ * output: wait for its job.
134
+ */
135
+ wait(job: string | Job, { timeoutMs }?: {
136
+ timeoutMs?: number;
137
+ }): Promise<CommandResult>;
138
+ /** Stops a running command and what it started; a finished one is answered as it is. */
139
+ cancel(id: string): Promise<Job>;
140
+ }
141
+ /** Files on a Mac: up to 3 MiB in a call, and any size up to 2 GiB through a link. Relative paths are in the workspace; ~ is home. */
142
+ export declare class MacFiles {
143
+ #private;
144
+ constructor(http: Transport, base: string);
145
+ /** Writes a file (folders made, the file replaced in one step, so safe to repeat). Larger than 3 MiB goes by an upload link. */
146
+ write(path: string, content: string | Uint8Array | ArrayBuffer | Blob, { executable }?: {
147
+ executable?: boolean;
148
+ }): Promise<Record<string, any>>;
149
+ /** A file's bytes, any size up to 2 GiB (larger than 3 MiB comes by a download link). */
150
+ readBytes(path: string): Promise<Uint8Array>;
151
+ /** A text file, as UTF-8. */
152
+ read(path: string): Promise<string>;
153
+ /**
154
+ * A link that puts one file on the Mac at path, for a person (url: a page, no account) or a program (upload_url, then the
155
+ * link's own address to place it): extract unpacks a zip or tar into path. 60 minutes by default, a day at most.
156
+ */
157
+ uploadLink(path: string, options?: {
158
+ executable?: boolean;
159
+ extract?: "zip" | "tar";
160
+ minutes?: number;
161
+ }): Promise<FileLink>;
162
+ /** A link to a file or a folder (as a zip) on the Mac, which keeps working after the Mac stops, until it expires. */
163
+ downloadLink(path: string, options?: {
164
+ minutes?: number;
165
+ waitSeconds?: number;
166
+ }): Promise<FileLink>;
167
+ /** Puts bytes on the Mac at path through an upload link, and waits until the Mac has them. */
168
+ upload(path: string, data: string | Uint8Array | ArrayBuffer | Blob, options?: {
169
+ executable?: boolean;
170
+ extract?: "zip" | "tar";
171
+ }): Promise<Record<string, any>>;
172
+ /** A file's bytes (a folder's as a zip) from the Mac through a download link. */
173
+ download(path: string): Promise<Uint8Array>;
174
+ /** The same as a stream, for a file too large to hold in memory (up to 2 GiB): pipe it to a file or onward. */
175
+ downloadStream(path: string): Promise<ReadableStream<Uint8Array>>;
176
+ }