@ant0/cli 0.3.22-beta.3 → 0.3.22-beta.8

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.
@@ -627,6 +627,8 @@ export interface paths {
627
627
  timeout_s?: number;
628
628
  /** Format: uuid */
629
629
  conflict_profile_id?: string;
630
+ /** @description Override the saved headless setting for this run. */
631
+ headless?: boolean;
630
632
  };
631
633
  };
632
634
  };
@@ -9715,7 +9717,7 @@ export type webhooks = Record<string, never>;
9715
9717
  export interface components {
9716
9718
  schemas: {
9717
9719
  ApiError: {
9718
- /** @description Namespaced, client-stable code: validation_failed, unauthorized, not_found, profile.not_found, profile.name_taken, profile.ambiguous_name, profile.already_running, profile.not_running, profile.running, profile.folder_in_use, profile.folder_denied, profile.trashed, profile.not_trashed, proxy.not_found, proxy.in_use, proxy.change_ip_failed, proxy.change_ip_refused, proxy.unreachable, browser.not_found, browser.not_installed, browser.in_use, browser.install_failed, browser.store_unavailable, browser.download_interrupted, browser.checksum_mismatch, job.not_found, identity.generation_failed, identity.model_unavailable, identity.platform_not_ready, identity.platform_unavailable, identity.change_pending, identity.combo_disabled, launch.failed, launch.timeout, launch.sandbox_unavailable, cookies.invalid, cookies.cdp_failed, cookies.too_large, extension.not_found, extension.invalid, extension.in_use, extension.exists, storage.full, storage.readonly, storage.io, internal; account and licence: auth.invalid_credentials, auth.totp_required, auth.totp_invalid, auth.email_unverified, auth.rate_limited, device.limit, device.unknown, device.kx_conflict, device.fingerprint_unavailable, licence.required, licence.expired, licence.offline, licence.profile_limit, licence.feature, licence.invalid, workspace.suspended, workspace.lapsed, profile.locked, ticket.invalid, engine.grant_denied, engine.activation_required (Free benefit not yet activated: a normal state, show an activation step), engine.unavailable. */
9720
+ /** @description Namespaced, client-stable code: validation_failed, unauthorized, not_found, profile.not_found, profile.name_taken, profile.ambiguous_name, profile.already_running, profile.not_running, profile.running, profile.folder_in_use, profile.folder_denied, profile.trashed, profile.not_trashed, proxy.not_found, proxy.in_use, proxy.change_ip_failed, proxy.change_ip_refused, proxy.unreachable, proxy.geo_unavailable, browser.not_found, browser.not_installed, browser.in_use, browser.install_failed, browser.store_unavailable, browser.download_interrupted, browser.checksum_mismatch, job.not_found, identity.generation_failed, identity.model_unavailable, identity.platform_not_ready, identity.platform_unavailable, identity.change_pending, identity.combo_disabled, launch.failed, launch.timeout, launch.sandbox_unavailable, cookies.invalid, cookies.cdp_failed, cookies.too_large, extension.not_found, extension.invalid, extension.in_use, extension.exists, storage.full, storage.readonly, storage.io, internal; account and licence: auth.invalid_credentials, auth.totp_required, auth.totp_invalid, auth.email_unverified, auth.rate_limited, device.limit, device.unknown, device.kx_conflict, device.fingerprint_unavailable, licence.required, licence.expired, licence.offline, licence.profile_limit, licence.feature, licence.invalid, workspace.suspended, workspace.lapsed, profile.locked, ticket.invalid, engine.grant_denied, engine.activation_required (Free benefit not yet activated: a normal state, show an activation step), engine.unavailable. */
9719
9721
  error: string;
9720
9722
  message: string;
9721
9723
  /** @description Ajv issues for validation_failed; `{ code, path }` for storage.*; `{ code }` (the daemon-side install code) for browser.* install failures. */
@@ -9826,7 +9828,7 @@ export interface components {
9826
9828
  * Ant0 event v1
9827
9829
  * @description One event on the WebSocket /v1/events stream (JSON lines). Discriminated on "type".
9828
9830
  */
9829
- Ant0Event: components["schemas"]["Ant0EventProfileState"] | components["schemas"]["Ant0EventProfileLifecycle"] | components["schemas"]["Ant0EventInventoryBulkChanged"] | components["schemas"]["Ant0EventBrowserInstall"] | components["schemas"]["Ant0EventAssetInstall"] | components["schemas"]["Ant0EventProxyCheck"] | components["schemas"]["Ant0EventLicenceChanged"] | components["schemas"]["Ant0EventSyncChanged"] | components["schemas"]["Ant0EventSyncProgress"] | components["schemas"]["Ant0EventSyncConflict"] | components["schemas"]["Ant0EventTeamChanged"] | components["schemas"]["Ant0EventBetaChannel"] | components["schemas"]["Ant0EventDaemonLog"];
9831
+ Ant0Event: components["schemas"]["Ant0EventProfileState"] | components["schemas"]["Ant0EventProfileLifecycle"] | components["schemas"]["Ant0EventInventoryBulkChanged"] | components["schemas"]["Ant0EventBrowserInstall"] | components["schemas"]["Ant0EventAssetInstall"] | components["schemas"]["Ant0EventProxyCheck"] | components["schemas"]["Ant0EventLicenceChanged"] | components["schemas"]["Ant0EventSyncChanged"] | components["schemas"]["Ant0EventSyncProgress"] | components["schemas"]["Ant0EventSyncConflict"] | components["schemas"]["Ant0EventTeamChanged"] | components["schemas"]["Ant0EventBetaChannel"] | components["schemas"]["Ant0EventHumanRequest"] | components["schemas"]["Ant0EventDaemonLog"];
9830
9832
  /** Format: date-time */
9831
9833
  Ant0EventAt: string;
9832
9834
  Ant0EventProfileState: {
@@ -9989,6 +9991,19 @@ export interface components {
9989
9991
  channel: "stable" | "beta";
9990
9992
  at: components["schemas"]["Ant0EventAt"];
9991
9993
  };
9994
+ /** @description A hand-off request to the person (human.requested) or its end (human.resolved). Ids and kind only; the reason is fetched over the API. */
9995
+ Ant0EventHumanRequest: {
9996
+ /**
9997
+ * @description discriminator enum property added by openapi-typescript
9998
+ * @enum {string}
9999
+ */
10000
+ type: "Ant0EventHumanRequest";
10001
+ request_id: string;
10002
+ profile_id: string;
10003
+ /** @enum {unknown} */
10004
+ kind: "human" | "approval";
10005
+ at: components["schemas"]["Ant0EventAt"];
10006
+ };
9992
10007
  Ant0EventDaemonLog: {
9993
10008
  /**
9994
10009
  * @description discriminator enum property added by openapi-typescript
@@ -10245,7 +10260,7 @@ export interface components {
10245
10260
  runtime: components["schemas"]["Session"] | null;
10246
10261
  deleted_at: string | null;
10247
10262
  /**
10248
- * @description OS persona the browser presents: `overrides.platform` (passed to the engine as `--fingerprint-platform`), else the OS of the persisted synthetic/captured persona (`compatibility.os_family`, known once the identity has been previewed or launched); null when neither is known or the identity is native.
10263
+ * @description OS the browser presents: `overrides.platform`, else the OS of the profile's saved identity (`compatibility.os_family`, known once the identity has been previewed or launched); null when neither is known or the identity is native.
10249
10264
  * @enum {null|string}
10250
10265
  */
10251
10266
  platform: "windows" | "linux" | "macos" | "android" | null;
@@ -10472,7 +10487,7 @@ export interface components {
10472
10487
  status: string | null;
10473
10488
  pinned: boolean;
10474
10489
  /**
10475
- * @description OS persona the browser presents: `overrides.platform` (passed to the engine as `--fingerprint-platform`), else the OS of the persisted synthetic/captured persona (`compatibility.os_family`, known once the identity has been previewed or launched); null when neither is known or the identity is native.
10490
+ * @description OS the browser presents: `overrides.platform`, else the OS of the profile's saved identity (`compatibility.os_family`, known once the identity has been previewed or launched); null when neither is known or the identity is native.
10476
10491
  * @enum {null|string}
10477
10492
  */
10478
10493
  platform: "windows" | "linux" | "macos" | "android" | null;
@@ -10499,7 +10514,7 @@ export interface components {
10499
10514
  status: string | null;
10500
10515
  pinned: boolean;
10501
10516
  /**
10502
- * @description OS persona the browser presents: `overrides.platform` (passed to the engine as `--fingerprint-platform`), else the OS of the persisted synthetic/captured persona (`compatibility.os_family`, known once the identity has been previewed or launched); null when neither is known or the identity is native.
10517
+ * @description OS the browser presents: `overrides.platform`, else the OS of the profile's saved identity (`compatibility.os_family`, known once the identity has been previewed or launched); null when neither is known or the identity is native.
10503
10518
  * @enum {null|string}
10504
10519
  */
10505
10520
  platform: "windows" | "linux" | "macos" | "android" | null;
@@ -470,7 +470,7 @@ export function registerProfiles(program, ctx) {
470
470
  });
471
471
  profiles
472
472
  .command("identity <id>")
473
- .description("Preview the fingerprint persona the profile will launch with")
473
+ .description("Preview the browser settings the profile will start with")
474
474
  .action(async (id) => {
475
475
  const data = unwrap(await ctx.client().GET("/v1/profiles/{id}/identity", { params: { path: { id } } }));
476
476
  ctx.emit(data, () => {
package/dist/program.js CHANGED
@@ -145,13 +145,31 @@ export function buildProgram(ctx) {
145
145
  "and beta page actions (snapshot, navigate, click, type, fill, select, keys, wait, " +
146
146
  "screenshot, text, tabs); local connection only")
147
147
  .command("serve")
148
- .description("Serve MCP over stdio using an already-running local daemon")
149
- .option("--stdio", "use the stdio MCP transport (required)")
148
+ .description("Serve MCP over stdio using an already-running local daemon (--http is the desktop-local mode)")
149
+ .option("--stdio", "use the stdio MCP transport")
150
+ .option("--http", "desktop-local mode, started by the Ant0 app: 127.0.0.1 only, --port is the listen port, " +
151
+ "the bearer token is the first line of stdin (requires --token-stdin)")
152
+ .option("--token-stdin", "read the HTTP bearer token from the first line of stdin")
150
153
  .action(async (options) => {
151
- if (!options.stdio)
154
+ if (options.http && options.stdio)
155
+ throw new UsageError("use only one of --stdio and --http");
156
+ if (!options.stdio && !options.http)
152
157
  throw new UsageError("mcp serve requires --stdio");
153
158
  if (ctx.json)
154
159
  throw new UsageError("mcp serve does not accept --json");
160
+ if (options.http) {
161
+ if (!options.tokenStdin)
162
+ throw new UsageError("mcp serve --http requires --token-stdin");
163
+ if (ctx.globals.port === undefined)
164
+ throw new UsageError("mcp serve --http requires --port");
165
+ if (ctx.globals.credentialFile !== undefined ||
166
+ ctx.io.env.ANT0_API_KEY !== undefined ||
167
+ ctx.globals.apiKeyStdin === true)
168
+ throw new UsageError("mcp serve --http uses the local token, not an API key");
169
+ }
170
+ else if (options.tokenStdin) {
171
+ throw new UsageError("--token-stdin is only for mcp serve --http");
172
+ }
155
173
  const stdin = ctx.io.stdin ?? process.stdin;
156
174
  if (!(stdin instanceof Readable) || !(ctx.io.stdout instanceof Writable)) {
157
175
  throw new CliError("mcp: stdio streams required");
@@ -159,6 +177,18 @@ export function buildProgram(ctx) {
159
177
  let mcp;
160
178
  try {
161
179
  mcp = await import("@ant0/mcp");
180
+ if (options.http) {
181
+ // Here --port is the LISTEN port, not the daemon's: the daemon is found from the
182
+ // home (ant0d.pid), $ANT0D_HOST and $ANT0D_PORT, and the two must differ.
183
+ // The only stdout line in this mode, written after the bind succeeded (no token).
184
+ await mcp.serveDesktopLocalFromStdin(stdin, {
185
+ ...(ctx.globals.home !== undefined ? { home: ctx.globals.home } : {}),
186
+ listenPort: ctx.globals.port,
187
+ env: ctx.io.env,
188
+ ...(ctx.io.signal ? { signal: ctx.io.signal } : {}),
189
+ }, (handle) => void ctx.io.stdout.write(`ant0: mcp: listening 127.0.0.1:${handle.port}\n`));
190
+ return;
191
+ }
162
192
  await mcp.serveStdio({
163
193
  ...(ctx.globals.home !== undefined ? { home: ctx.globals.home } : {}),
164
194
  ...(ctx.globals.port !== undefined ? { port: ctx.globals.port } : {}),
@@ -172,6 +202,8 @@ export function buildProgram(ctx) {
172
202
  }, ctx.runtime?.outputWorker);
173
203
  }
174
204
  catch (error) {
205
+ if (mcp && error instanceof mcp.PortInUseFailure)
206
+ throw new CliError("mcp: port in use");
175
207
  if (mcp && error instanceof mcp.McpFailure) {
176
208
  if (error.code === "unavailable")
177
209
  throw new DaemonNotRunningError("mcp: local daemon unavailable");
@@ -1,10 +1,40 @@
1
1
  import type { ProxyCreate } from "./proxy-types.js";
2
+ /**
3
+ * This module must stay side-effect free and renderer-safe: it is published as the
4
+ * `@ant0/schemas/proxy-parse` subpath so the desktop webview can use it without the package barrel
5
+ * (which compiles Ajv validators at import and needs `unsafe-eval`). Import only `./errors.js` and
6
+ * types; no Node built-ins, no top-level work.
7
+ */
8
+ /** Stable, input-free reason for a rejected line (see {@link inspectProxyLine}). */
9
+ export type ProxyParseCode = "empty" | "whitespace" | "not_url" | "bad_scheme" | "has_path" | "missing_host" | "bad_host" | "bad_ipv6_host" | "bad_port" | "port_range" | "ipv6_bracket" | "ipv6_bare" | "missing_port" | "trailing" | "bad_encoding" | "socks4_password" | "expected_form";
2
10
  export interface ParsedHostPort {
3
11
  host: string;
4
12
  port: number;
5
13
  }
6
14
  /** Display form used for default names: IPv6 hosts are bracketed. */
7
15
  export declare function formatHostPort(host: string, port: number): string;
16
+ /** Outcome of {@link inspectProxyLine}. */
17
+ export type ProxyLineInspection = {
18
+ ok: true;
19
+ proxy: ProxyCreate;
20
+ } | {
21
+ ok: false;
22
+ code: ProxyParseCode;
23
+ /** The same generic message `parseProxyLine` throws. */
24
+ message: string;
25
+ /**
26
+ * The offending piece of the input (host, port text, scheme, trailing text), when the
27
+ * code has one. It can contain user input: show it on screen to the person who typed it,
28
+ * but never log it, send it anywhere or put it in an error.
29
+ */
30
+ fragment?: string;
31
+ };
32
+ /**
33
+ * `parseProxyLine` as a result instead of a throw, with the stable failure code (and the
34
+ * offending fragment) so a UI can phrase its own message. Same grammar, same checks, same order.
35
+ * Unlike a thrown error, a failure here may carry input fragments; see {@link ProxyLineInspection}.
36
+ */
37
+ export declare function inspectProxyLine(line: string): ProxyLineInspection;
8
38
  /**
9
39
  * Parse `scheme://[user[:pass]@]host[:port][/]` for `http`, `https`, `socks5` (and `socks5h`,
10
40
  * mapped to `socks5`) and `socks4` (and `socks4a`, mapped to `socks4`; no password). Credentials before `@` are percent-decoded; a raw `@` inside the password
@@ -1,4 +1,21 @@
1
1
  import { ParseError } from "./parse-error.js";
2
+ /**
3
+ * Internal failure carrying the code and the offending fragment. It never leaves this module:
4
+ * `parseProxyUrl`/`parseProxyLine` rethrow it as a {@link ParseError} with the generic message
5
+ * only, so thrown errors never echo input or credentials.
6
+ */
7
+ class ProxyParseFailure extends Error {
8
+ code;
9
+ fragment;
10
+ constructor(code, message, fragment) {
11
+ super(message);
12
+ this.code = code;
13
+ this.fragment = fragment;
14
+ }
15
+ }
16
+ function fail(code, message, fragment) {
17
+ throw new ProxyParseFailure(code, message, fragment);
18
+ }
2
19
  const SCHEME_ALIASES = {
3
20
  http: "http",
4
21
  https: "https",
@@ -25,17 +42,17 @@ export function formatHostPort(host, port) {
25
42
  }
26
43
  function parsePort(text) {
27
44
  if (!PORT_RE.test(text))
28
- throw new ParseError("invalid port: expected 1..65535");
45
+ fail("bad_port", "invalid port: expected 1..65535", text);
29
46
  const port = Number(text);
30
47
  if (port < 1 || port > 65535)
31
- throw new ParseError("port is out of range 1..65535");
48
+ fail("port_range", "port is out of range 1..65535", String(port));
32
49
  return port;
33
50
  }
34
51
  function checkHost(host) {
35
52
  if (host === "")
36
- throw new ParseError("missing host");
53
+ fail("missing_host", "missing host");
37
54
  if (!HOST_RE.test(host))
38
- throw new ParseError("invalid host");
55
+ fail("bad_host", "invalid host", host);
39
56
  return host;
40
57
  }
41
58
  /**
@@ -65,15 +82,15 @@ function splitHostPort(text, defaultPort) {
65
82
  if (text.startsWith("[")) {
66
83
  const close = text.indexOf("]");
67
84
  if (close < 0)
68
- throw new ParseError("unterminated IPv6 bracket");
85
+ fail("ipv6_bracket", "unterminated IPv6 bracket");
69
86
  host = text.slice(1, close);
70
87
  after = text.slice(close + 1);
71
88
  if (!host.includes(":"))
72
- throw new ParseError("invalid IPv6 host");
89
+ fail("bad_ipv6_host", "invalid IPv6 host", host);
73
90
  }
74
91
  else {
75
92
  if (looksLikeBareIpv6(text)) {
76
- throw new ParseError("IPv6 hosts must be written in brackets, e.g. [2001:db8::1]:1080");
93
+ fail("ipv6_bare", "IPv6 hosts must be written in brackets, e.g. [2001:db8::1]:1080");
77
94
  }
78
95
  const colon = text.indexOf(":");
79
96
  host = colon < 0 ? text : text.slice(0, colon);
@@ -82,17 +99,17 @@ function splitHostPort(text, defaultPort) {
82
99
  checkHost(host);
83
100
  if (after === "") {
84
101
  if (defaultPort === undefined)
85
- throw new ParseError("missing port");
102
+ fail("missing_port", "missing port");
86
103
  return { host, port: defaultPort, rest: "" };
87
104
  }
88
105
  if (!after.startsWith(":"))
89
- throw new ParseError("unexpected text after host");
106
+ fail("trailing", "unexpected text after host", after);
90
107
  const next = after.indexOf(":", 1);
91
108
  const portText = next < 0 ? after.slice(1) : after.slice(1, next);
92
109
  const rest = next < 0 ? "" : after.slice(next);
93
110
  if (portText === "") {
94
111
  if (defaultPort === undefined)
95
- throw new ParseError("missing port");
112
+ fail("missing_port", "missing port");
96
113
  return { host, port: defaultPort, rest };
97
114
  }
98
115
  return { host, port: parsePort(portText), rest };
@@ -102,7 +119,7 @@ function decodeComponent(text, what) {
102
119
  return decodeURIComponent(text);
103
120
  }
104
121
  catch {
105
- throw new ParseError(`invalid percent-encoding in ${what}`);
122
+ fail("bad_encoding", `invalid percent-encoding in ${what}`);
106
123
  }
107
124
  }
108
125
  function splitUserInfo(userInfo, decode) {
@@ -123,7 +140,7 @@ function splitUserInfo(userInfo, decode) {
123
140
  }
124
141
  function build(type, host, port, creds) {
125
142
  if (type === "socks4" && creds.password !== undefined) {
126
- throw new ParseError("SOCKS4 proxies have a user ID but no password; remove the password or use socks5");
143
+ fail("socks4_password", "SOCKS4 proxies have a user ID but no password; remove the password or use socks5");
127
144
  }
128
145
  const out = { name: formatHostPort(host, port).slice(0, 120), type, host, port };
129
146
  if (creds.username !== undefined)
@@ -132,6 +149,38 @@ function build(type, host, port, creds) {
132
149
  out.password = creds.password;
133
150
  return out;
134
151
  }
152
+ /** Run a parser and rethrow its failure as a {@link ParseError} carrying the generic message only. */
153
+ function generic(run) {
154
+ try {
155
+ return run();
156
+ }
157
+ catch (error) {
158
+ if (error instanceof ProxyParseFailure)
159
+ throw new ParseError(error.message);
160
+ throw error;
161
+ }
162
+ }
163
+ /**
164
+ * `parseProxyLine` as a result instead of a throw, with the stable failure code (and the
165
+ * offending fragment) so a UI can phrase its own message. Same grammar, same checks, same order.
166
+ * Unlike a thrown error, a failure here may carry input fragments; see {@link ProxyLineInspection}.
167
+ */
168
+ export function inspectProxyLine(line) {
169
+ try {
170
+ return { ok: true, proxy: proxyLine(line) };
171
+ }
172
+ catch (error) {
173
+ if (error instanceof ProxyParseFailure) {
174
+ return {
175
+ ok: false,
176
+ code: error.code,
177
+ message: error.message,
178
+ ...(error.fragment === undefined ? {} : { fragment: error.fragment }),
179
+ };
180
+ }
181
+ throw error;
182
+ }
183
+ }
135
184
  /**
136
185
  * Parse `scheme://[user[:pass]@]host[:port][/]` for `http`, `https`, `socks5` (and `socks5h`,
137
186
  * mapped to `socks5`) and `socks4` (and `socks4a`, mapped to `socks4`; no password). Credentials before `@` are percent-decoded; a raw `@` inside the password
@@ -142,13 +191,17 @@ function build(type, host, port, creds) {
142
191
  * @throws {ParseError}
143
192
  */
144
193
  export function parseProxyUrl(url) {
194
+ return generic(() => proxyUrl(url));
195
+ }
196
+ function proxyUrl(url) {
145
197
  const m = URL_RE.exec(url.trim());
146
198
  if (!m)
147
- throw new ParseError("not a proxy URL: expected scheme://host:port");
199
+ fail("not_url", "not a proxy URL: expected scheme://host:port");
148
200
  const scheme = (m[1] ?? "").toLowerCase();
149
201
  const type = SCHEME_ALIASES[scheme];
150
- if (!type)
151
- throw new ParseError("unsupported proxy type: expected http, https, socks5 or socks4");
202
+ if (!type) {
203
+ fail("bad_scheme", "unsupported proxy type: expected http, https, socks5 or socks4", scheme);
204
+ }
152
205
  let rest = m[2] ?? "";
153
206
  // Strip an optional trailing "/" (providers often paste "http://host:port/").
154
207
  if (rest.endsWith("/"))
@@ -159,12 +212,12 @@ export function parseProxyUrl(url) {
159
212
  // With "@" the host:port part must be clean; without it only the host/port segment is checked
160
213
  // so a "/" inside a verbatim ":user:pass" suffix is not mistaken for a path.
161
214
  if (at >= 0 ? /[/?#]/.test(hostPort) : PATH_AFTER_HOST_PORT.test(hostPort)) {
162
- throw new ParseError("proxy URL must not contain a path, query or fragment");
215
+ fail("has_path", "proxy URL must not contain a path, query or fragment");
163
216
  }
164
217
  const { host, port, rest: tail } = splitHostPort(hostPort, DEFAULT_PORTS[type]);
165
218
  if (at >= 0) {
166
219
  if (tail !== "")
167
- throw new ParseError("unexpected text after port");
220
+ fail("trailing", "unexpected text after port", tail);
168
221
  return build(type, host, port, splitUserInfo(userInfo, true));
169
222
  }
170
223
  if (tail === "")
@@ -172,7 +225,7 @@ export function parseProxyUrl(url) {
172
225
  // scheme://host:port:user:pass (a common provider export format); credentials verbatim.
173
226
  const creds = splitUserInfo(tail.slice(1), false);
174
227
  if (creds.username === undefined && creds.password === undefined) {
175
- throw new ParseError("unexpected text after port");
228
+ fail("trailing", "unexpected text after port", tail);
176
229
  }
177
230
  return build(type, host, port, creds);
178
231
  }
@@ -189,19 +242,22 @@ export function parseProxyUrl(url) {
189
242
  * @throws {ParseError}
190
243
  */
191
244
  export function parseProxyLine(line) {
245
+ return generic(() => proxyLine(line));
246
+ }
247
+ function proxyLine(line) {
192
248
  const text = line.trim();
193
249
  if (text === "")
194
- throw new ParseError("empty proxy line");
250
+ fail("empty", "empty proxy line");
195
251
  if (/^[A-Za-z][A-Za-z0-9+.-]*:\/\//.test(text))
196
- return parseProxyUrl(text);
252
+ return proxyUrl(text);
197
253
  if (/\s/.test(text))
198
- throw new ParseError("proxy line must not contain whitespace");
254
+ fail("whitespace", "proxy line must not contain whitespace");
199
255
  const at = text.lastIndexOf("@");
200
256
  if (at >= 0) {
201
257
  const creds = splitUserInfo(text.slice(0, at), false);
202
258
  const { host, port, rest } = splitHostPort(text.slice(at + 1));
203
259
  if (rest !== "")
204
- throw new ParseError("unexpected text after port");
260
+ fail("trailing", "unexpected text after port", rest);
205
261
  return build("http", host, port, creds);
206
262
  }
207
263
  const { host, port, rest } = splitHostPort(text);
@@ -210,7 +266,7 @@ export function parseProxyLine(line) {
210
266
  // rest is ":user[:pass[:more...]]"; everything after the user's colon is the password.
211
267
  const creds = splitUserInfo(rest.slice(1), false);
212
268
  if (creds.username === undefined && creds.password === undefined) {
213
- throw new ParseError("expected host:port or host:port:user:pass");
269
+ fail("expected_form", "expected host:port or host:port:user:pass");
214
270
  }
215
271
  return build("http", host, port, creds);
216
272
  }
package/dist/version.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /** What `ant0 --version` prints: the Ant0 release this CLI belongs to, else the package version. */
2
- export const CLI_VERSION = typeof __ANT0_VERSION__ === "string" ? __ANT0_VERSION__ : "0.3.22-beta.3";
2
+ export const CLI_VERSION = typeof __ANT0_VERSION__ === "string" ? __ANT0_VERSION__ : "0.3.22-beta.8";
3
3
  function majorMinor(version) {
4
4
  return /^(\d+)\.(\d+)(?:\.|-|$)/.exec(version)?.slice(1, 3).join(".");
5
5
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ant0/cli",
3
- "version": "0.3.22-beta.3",
3
+ "version": "0.3.22-beta.8",
4
4
  "description": "The Ant0 command line: profiles, proxies, browsers and more, over the local Ant0 API.",
5
5
  "license": "BSD-3-Clause",
6
6
  "type": "module",
@@ -50,7 +50,7 @@
50
50
  "check:forbidden": "node scripts/check-forbidden.mjs"
51
51
  },
52
52
  "dependencies": {
53
- "@ant0/mcp": "0.3.22-beta.2",
53
+ "@ant0/mcp": "0.3.22-beta.8",
54
54
  "commander": "15.0.0",
55
55
  "openapi-fetch": "0.17.0"
56
56
  },